@vouchfor/embeds 1.2.2 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. package/dist/es/{browser-4d54600e.js → browser-97265c29.js} +2 -2
  2. package/dist/es/{browser-4d54600e.js.map → browser-97265c29.js.map} +1 -1
  3. package/dist/es/embeds.js +1 -1
  4. package/dist/es/{index-14868944.js → index-d15aeb56.js} +632 -640
  5. package/dist/es/index-d15aeb56.js.map +1 -0
  6. package/dist/es/src/components/PlayerEmbed/index.d.ts +73 -0
  7. package/dist/iife/dialog-embed/{browser-d8ab928d.js → browser-c8adca59.js} +2 -2
  8. package/dist/iife/dialog-embed/{browser-d8ab928d.js.map → browser-c8adca59.js.map} +1 -1
  9. package/dist/iife/dialog-embed/embed.iife.js +38 -38
  10. package/dist/iife/dialog-embed/embed.iife.js.map +1 -1
  11. package/dist/iife/dialog-embed/embed.js +1 -1
  12. package/dist/iife/dialog-embed/{index-568f189c.js → index-eb3ec3b3.js} +667 -675
  13. package/dist/iife/dialog-embed/index-eb3ec3b3.js.map +1 -0
  14. package/dist/iife/dialog-embed/src/components/PlayerEmbed/index.d.ts +73 -0
  15. package/dist/iife/embeds.iife.js +38 -38
  16. package/dist/iife/embeds.iife.js.map +1 -1
  17. package/dist/iife/player-embed/{browser-951710ee.js → browser-7e2003a9.js} +2 -2
  18. package/dist/iife/player-embed/{browser-951710ee.js.map → browser-7e2003a9.js.map} +1 -1
  19. package/dist/iife/player-embed/embed.iife.js +34 -34
  20. package/dist/iife/player-embed/embed.iife.js.map +1 -1
  21. package/dist/iife/player-embed/embed.js +1 -1
  22. package/dist/iife/player-embed/{index-86dfade0.js → index-4541048e.js} +3343 -3351
  23. package/dist/iife/player-embed/index-4541048e.js.map +1 -0
  24. package/dist/iife/player-embed/src/components/PlayerEmbed/index.d.ts +73 -0
  25. package/package.json +2 -2
  26. package/src/components/PlayerEmbed/index.ts +106 -5
  27. package/dist/es/index-14868944.js.map +0 -1
  28. package/dist/iife/dialog-embed/index-568f189c.js.map +0 -1
  29. package/dist/iife/player-embed/index-86dfade0.js.map +0 -1
  30. package/src/mixins/media-player-proxy.ts +0 -116
@@ -1,4 +1,4 @@
1
- var TS=Object.defineProperty;var kS=(ae,Qi,Di)=>Qi in ae?TS(ae,Qi,{enumerable:!0,configurable:!0,writable:!0,value:Di}):ae[Qi]=Di;var bg=(ae,Qi,Di)=>(kS(ae,typeof Qi!="symbol"?Qi+"":Qi,Di),Di);var embeds=function(ae){var r2;"use strict";function Qi(i,t){for(var e=0;e<t.length;e++){const r=t[e];if(typeof r!="string"&&!Array.isArray(r)){for(const n in r)if(n!=="default"&&!(n in i)){const o=Object.getOwnPropertyDescriptor(r,n);o&&Object.defineProperty(i,n,o.get?o:{enumerable:!0,get:()=>r[n]})}}}return Object.freeze(Object.defineProperty(i,Symbol.toStringTag,{value:"Module"}))}/**
1
+ var AS=Object.defineProperty;var TS=(ae,Qi,Di)=>Qi in ae?AS(ae,Qi,{enumerable:!0,configurable:!0,writable:!0,value:Di}):ae[Qi]=Di;var bg=(ae,Qi,Di)=>(TS(ae,typeof Qi!="symbol"?Qi+"":Qi,Di),Di);var embeds=function(ae){var r2;"use strict";function Qi(i,t){for(var e=0;e<t.length;e++){const r=t[e];if(typeof r!="string"&&!Array.isArray(r)){for(const n in r)if(n!=="default"&&!(n in i)){const o=Object.getOwnPropertyDescriptor(r,n);o&&Object.defineProperty(i,n,o.get?o:{enumerable:!0,get:()=>r[n]})}}}return Object.freeze(Object.defineProperty(i,Symbol.toStringTag,{value:"Module"}))}/**
2
2
  * @license
3
3
  * Copyright 2019 Google LLC
4
4
  * SPDX-License-Identifier: BSD-3-Clause
@@ -86,8 +86,8 @@ ${t}`,Bm=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),Gm=Objec
86
86
  `+Array(vt.message.length+1).join("=")+`
87
87
  `+C(N,Z)):vt}}function bt(N,G){var Z;return G.cache&&G.name&&G.storage.templates.get(G.name)?G.storage.templates.get(G.name):(Z=typeof N=="function"?N:j(N,G),G.cache&&G.name&&G.storage.templates.define(G.name,Z),Z)}Pt.l.bind(Pt),e.compile=j,e.compileScope=O,e.compileScopeIntoFunction=x,e.compileToString=C,e.defaultConfig=Pt,e.filters=wt,e.getConfig=F,e.helpers=kt,e.nativeHelpers=ft,e.parse=w,e.render=function(N,G,Z,gt){var vt=F(Z||{});if(!vt.async)return bt(N,vt)(G,vt);if(!gt){if(typeof o=="function")return new o(function(It,Bt){try{It(bt(N,vt)(G,vt))}catch(Xt){Bt(Xt)}});throw r("Please provide a callback function, this env doesn't support Promises")}try{bt(N,vt)(G,vt,gt)}catch(It){return gt(It)}},e.templates=J,Object.defineProperty(e,"__esModule",{value:!0})})})(Ql,Ql.exports);var po=Ql.exports,Jl={exports:{}};(function(i,t){var e=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof fo<"u"&&fo,r=function(){function o(){this.fetch=!1,this.DOMException=e.DOMException}return o.prototype=e,new o}();(function(o){(function(l){var d=typeof o<"u"&&o||typeof self<"u"&&self||typeof d<"u"&&d,f={searchParams:"URLSearchParams"in d,iterable:"Symbol"in d&&"iterator"in Symbol,blob:"FileReader"in d&&"Blob"in d&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in d,arrayBuffer:"ArrayBuffer"in d};function p(F){return F&&DataView.prototype.isPrototypeOf(F)}if(f.arrayBuffer)var g=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],v=ArrayBuffer.isView||function(F){return F&&g.indexOf(Object.prototype.toString.call(F))>-1};function E(F){if(typeof F!="string"&&(F=String(F)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(F)||F==="")throw new TypeError('Invalid character in header field name: "'+F+'"');return F.toLowerCase()}function A(F){return typeof F!="string"&&(F=String(F)),F}function T(F){var j={next:function(){var bt=F.shift();return{done:bt===void 0,value:bt}}};return f.iterable&&(j[Symbol.iterator]=function(){return j}),j}function w(F){this.map={},F instanceof w?F.forEach(function(j,bt){this.append(bt,j)},this):Array.isArray(F)?F.forEach(function(j){this.append(j[0],j[1])},this):F&&Object.getOwnPropertyNames(F).forEach(function(j){this.append(j,F[j])},this)}w.prototype.append=function(F,j){F=E(F),j=A(j);var bt=this.map[F];this.map[F]=bt?bt+", "+j:j},w.prototype.delete=function(F){delete this.map[E(F)]},w.prototype.get=function(F){return F=E(F),this.has(F)?this.map[F]:null},w.prototype.has=function(F){return this.map.hasOwnProperty(E(F))},w.prototype.set=function(F,j){this.map[E(F)]=A(j)},w.prototype.forEach=function(F,j){for(var bt in this.map)this.map.hasOwnProperty(bt)&&F.call(j,this.map[bt],bt,this)},w.prototype.keys=function(){var F=[];return this.forEach(function(j,bt){F.push(bt)}),T(F)},w.prototype.values=function(){var F=[];return this.forEach(function(j){F.push(j)}),T(F)},w.prototype.entries=function(){var F=[];return this.forEach(function(j,bt){F.push([bt,j])}),T(F)},f.iterable&&(w.prototype[Symbol.iterator]=w.prototype.entries);function C(F){if(F.bodyUsed)return Promise.reject(new TypeError("Already read"));F.bodyUsed=!0}function D(F){return new Promise(function(j,bt){F.onload=function(){j(F.result)},F.onerror=function(){bt(F.error)}})}function M(F){var j=new FileReader,bt=D(j);return j.readAsArrayBuffer(F),bt}function U(F){var j=new FileReader,bt=D(j);return j.readAsText(F),bt}function x(F){for(var j=new Uint8Array(F),bt=new Array(j.length),N=0;N<j.length;N++)bt[N]=String.fromCharCode(j[N]);return bt.join("")}function O(F){if(F.slice)return F.slice(0);var j=new Uint8Array(F.byteLength);return j.set(new Uint8Array(F)),j.buffer}function K(){return this.bodyUsed=!1,this._initBody=function(F){this.bodyUsed=this.bodyUsed,this._bodyInit=F,F?typeof F=="string"?this._bodyText=F:f.blob&&Blob.prototype.isPrototypeOf(F)?this._bodyBlob=F:f.formData&&FormData.prototype.isPrototypeOf(F)?this._bodyFormData=F:f.searchParams&&URLSearchParams.prototype.isPrototypeOf(F)?this._bodyText=F.toString():f.arrayBuffer&&f.blob&&p(F)?(this._bodyArrayBuffer=O(F.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):f.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(F)||v(F))?this._bodyArrayBuffer=O(F):this._bodyText=F=Object.prototype.toString.call(F):this._bodyText="",this.headers.get("content-type")||(typeof F=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):f.searchParams&&URLSearchParams.prototype.isPrototypeOf(F)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},f.blob&&(this.blob=function(){var F=C(this);if(F)return F;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 F=C(this);return F||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}else return this.blob().then(M)}),this.text=function(){var F=C(this);if(F)return F;if(this._bodyBlob)return U(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(x(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},f.formData&&(this.formData=function(){return this.text().then(J)}),this.json=function(){return this.text().then(JSON.parse)},this}var B=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function at(F){var j=F.toUpperCase();return B.indexOf(j)>-1?j:F}function st(F,j){if(!(this instanceof st))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');j=j||{};var bt=j.body;if(F instanceof st){if(F.bodyUsed)throw new TypeError("Already read");this.url=F.url,this.credentials=F.credentials,j.headers||(this.headers=new w(F.headers)),this.method=F.method,this.mode=F.mode,this.signal=F.signal,!bt&&F._bodyInit!=null&&(bt=F._bodyInit,F.bodyUsed=!0)}else this.url=String(F);if(this.credentials=j.credentials||this.credentials||"same-origin",(j.headers||!this.headers)&&(this.headers=new w(j.headers)),this.method=at(j.method||this.method||"GET"),this.mode=j.mode||this.mode||null,this.signal=j.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&bt)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(bt),(this.method==="GET"||this.method==="HEAD")&&(j.cache==="no-store"||j.cache==="no-cache")){var N=/([?&])_=[^&]*/;if(N.test(this.url))this.url=this.url.replace(N,"$1_="+new Date().getTime());else{var G=/\?/;this.url+=(G.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}st.prototype.clone=function(){return new st(this,{body:this._bodyInit})};function J(F){var j=new FormData;return F.trim().split("&").forEach(function(bt){if(bt){var N=bt.split("="),G=N.shift().replace(/\+/g," "),Z=N.join("=").replace(/\+/g," ");j.append(decodeURIComponent(G),decodeURIComponent(Z))}}),j}function kt(F){var j=new w,bt=F.replace(/\r?\n[\t ]+/g," ");return bt.split("\r").map(function(N){return N.indexOf(`
88
88
  `)===0?N.substr(1,N.length):N}).forEach(function(N){var G=N.split(":"),Z=G.shift().trim();if(Z){var gt=G.join(":").trim();j.append(Z,gt)}}),j}K.call(st.prototype);function ft(F,j){if(!(this instanceof ft))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');j||(j={}),this.type="default",this.status=j.status===void 0?200:j.status,this.ok=this.status>=200&&this.status<300,this.statusText=j.statusText===void 0?"":""+j.statusText,this.headers=new w(j.headers),this.url=j.url||"",this._initBody(F)}K.call(ft.prototype),ft.prototype.clone=function(){return new ft(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new w(this.headers),url:this.url})},ft.error=function(){var F=new ft(null,{status:0,statusText:""});return F.type="error",F};var wt=[301,302,303,307,308];ft.redirect=function(F,j){if(wt.indexOf(j)===-1)throw new RangeError("Invalid status code");return new ft(null,{status:j,headers:{location:F}})},l.DOMException=d.DOMException;try{new l.DOMException}catch{l.DOMException=function(j,bt){this.message=j,this.name=bt;var N=Error(j);this.stack=N.stack},l.DOMException.prototype=Object.create(Error.prototype),l.DOMException.prototype.constructor=l.DOMException}function Pt(F,j){return new Promise(function(bt,N){var G=new st(F,j);if(G.signal&&G.signal.aborted)return N(new l.DOMException("Aborted","AbortError"));var Z=new XMLHttpRequest;function gt(){Z.abort()}Z.onload=function(){var It={status:Z.status,statusText:Z.statusText,headers:kt(Z.getAllResponseHeaders()||"")};It.url="responseURL"in Z?Z.responseURL:It.headers.get("X-Request-URL");var Bt="response"in Z?Z.response:Z.responseText;setTimeout(function(){bt(new ft(Bt,It))},0)},Z.onerror=function(){setTimeout(function(){N(new TypeError("Network request failed"))},0)},Z.ontimeout=function(){setTimeout(function(){N(new TypeError("Network request failed"))},0)},Z.onabort=function(){setTimeout(function(){N(new l.DOMException("Aborted","AbortError"))},0)};function vt(It){try{return It===""&&d.location.href?d.location.href:It}catch{return It}}Z.open(G.method,vt(G.url),!0),G.credentials==="include"?Z.withCredentials=!0:G.credentials==="omit"&&(Z.withCredentials=!1),"responseType"in Z&&(f.blob?Z.responseType="blob":f.arrayBuffer&&G.headers.get("Content-Type")&&G.headers.get("Content-Type").indexOf("application/octet-stream")!==-1&&(Z.responseType="arraybuffer")),j&&typeof j.headers=="object"&&!(j.headers instanceof w)?Object.getOwnPropertyNames(j.headers).forEach(function(It){Z.setRequestHeader(It,A(j.headers[It]))}):G.headers.forEach(function(It,Bt){Z.setRequestHeader(Bt,It)}),G.signal&&(G.signal.addEventListener("abort",gt),Z.onreadystatechange=function(){Z.readyState===4&&G.signal.removeEventListener("abort",gt)}),Z.send(typeof G._bodyInit>"u"?null:G._bodyInit)})}return Pt.polyfill=!0,d.fetch||(d.fetch=Pt,d.Headers=w,d.Request=st,d.Response=ft),l.Headers=w,l.Request=st,l.Response=ft,l.fetch=Pt,l})({})})(r),r.fetch.ponyfill=!0,delete r.fetch.polyfill;var n=e.fetch?e:r;t=n.fetch,t.default=n.fetch,t.fetch=n.fetch,t.Headers=n.Headers,t.Request=n.Request,t.Response=n.Response,i.exports=t})(Jl,Jl.exports);var jm=Jl.exports;const Km=ql(jm);function tc({canvas:i,scenes:t,currentTime:e}){if(t&&i){const r=t.scenes.filter(({start:o,duration:l})=>e>=o&&e<=o+l);if(r.length<=0)return;const n=i.getContext("2d");if(n){const o=t.transitionDuration,l=Math.max(...t.scenes.map(({start:d,duration:f})=>d+f));n.globalCompositeOperation="lighter",n.clearRect(0,0,i.width,i.height),r.forEach(({start:d,duration:f,draw:p,transitionCanvas:g})=>{if(n.globalAlpha=1,g.width=g.height=0,g.width=i.width,g.height=i.height,g.getContext("2d")){const v=d+f,E=d===0,A=v===l;p({currentTime:e,canvas:g}),!E&&e>=d&&e<=d+o?n.globalAlpha=Math.max(0,Math.min(1,(e-d)/o)):!A&&e>=v-o&&e<=v&&(n.globalAlpha=Math.max(0,Math.min(1,(v-e)/o))),n.drawImage(g,0,0,i.width,i.height)}})}}}function zm(i){if(typeof i=="string"){const[t,e]=i.split(":");return Math.min(parseFloat(t),parseFloat(e))}return i}function Ym(i){if(typeof i=="string"){const[t,e]=i.split(":"),r=parseFloat(t),n=parseFloat(e);return r/n}return i}function ec({resolution:i,aspectRatio:t}){const e=zm(i),r=Ym(t),n=r>=1,o=Math.min(n?e*r:e/r,e),l=Math.max(n?e*r:e/r,e);return{resolution:e,aspectRatio:r,height:n?o:l,width:n?l:o}}function Xm({format:i,resolution:t,aspectRatio:e,sourceWidth:r,sourceHeight:n}){const{width:o,height:l}=ec({resolution:t,aspectRatio:e}),d=r/n,f=e>d;let p=1;if(i==="letterbox"||i==="letterbox-video")p=f?l/n:o/r;else if(i==="squarebox"){const T=Math.min(l,o);p=r>=n?T/n:T/r}else i==="crop"&&(p=f?o/r:l/n);const g=o/p,v=l/p,E=(r-g)/2,A=(n-v)/2;return{sx:E,sy:A,sWidth:g,sHeight:v,scale:p}}function pa({source:i,sx:t,sy:e,sw:r,sh:n,dx:o,dy:l,dw:d,dh:f}){const p=(i==null?void 0:i.naturalWidth)??(i==null?void 0:i.videoWidth)??(i==null?void 0:i.width),g=(i==null?void 0:i.naturalHeight)??(i==null?void 0:i.videoHeight)??(i==null?void 0:i.height);t=t??0,e=e??0,r=r??p,n=n??g,r<0&&(t+=r,r=Math.abs(r)),n<0&&(e+=n,n=Math.abs(n)),d<0&&(o+=d,d=Math.abs(d)),f<0&&(l+=f,f=Math.abs(f));const v=Math.max(t,0),E=Math.min(t+r,p),A=Math.max(e,0),T=Math.min(e+n,g),w=d/r,C=f/n;return[i,v,A,E-v,T-A,t<0?o-t*w:o,e<0?l-e*C:l,(E-v)*w,(T-A)*C]}function gu({context:i,source:t,crop:e,format:r="letterbox",posX:n,posY:o,drawAreaWidth:l,drawAreaHeight:d,sourceWidth:f,sourceHeight:p,cropCanvas:g,letterboxCanvas:v}){const{x:E,y:A,width:T,height:w}=e??{},C=f*(E??0),D=p*(A??0),M=f*Math.min(1-(E??0),T??1),U=p*Math.min(1-(A??0),w??1),x=g.getContext("2d");if(x){g.width=M,g.height=U;const j=pa({source:t,sx:C,sy:D,sw:M,sh:U,dx:0,dy:0,dw:M,dh:U});x.drawImage(...j)}const O=M/U,{sx:K,sy:B,sWidth:at,sHeight:st,scale:J}=Xm({resolution:Math.min(l,d),aspectRatio:l/d,format:r,sourceWidth:M,sourceHeight:U}),kt=g&&typeof i.filter<"u";if(r==="letterbox"||r==="squarebox"||r==="letterbox-video"&&!kt){if(K<0){const j=Math.abs(K)*J;i.fillStyle="black",i.beginPath(),i.rect(n,o,j,d),i.rect(n+l-j,o,j,d),i.fill(),i.closePath()}if(B<0){const j=Math.abs(B)*J;i.fillStyle="black",i.beginPath(),i.rect(n,o,l,j),i.rect(n,o+d-j,l,j),i.fill(),i.closePath()}}if(r==="letterbox-video"&&kt){const j=v.getContext("2d");if(j){v.width=M,v.height=U,i.save(),i.globalCompositeOperation="destination-out",i.fillRect(n,o,l,d);const bt=pa({source:g,sx:K,sy:B,sw:at,sh:st,dx:n,dy:o,dw:l,dh:d});i.globalCompositeOperation="source-over",i.drawImage(...bt),j.save();const N=1.2,G=-(M*N-M)/2,Z=-(U*N-U)/2,gt=Math.min(M/20,U/20);if(j.filter=`blur(${gt}px) brightness(20%)`,j.translate(G,Z),j.scale(N,N),j.drawImage(g,0,0,M,U),j.restore(),i.globalCompositeOperation="destination-over",K<0){const vt=l/O,It=d/vt,Bt=pa({source:v,sy:(1-It)*U/2,sh:It*U,dx:n,dy:o,dw:l,dh:d});i.drawImage(...Bt)}if(B<0){const vt=d*O,It=l/vt,Bt=pa({source:v,sx:(1-It)*M/2,sw:It*M,dx:n,dy:o,dw:l,dh:d});i.drawImage(...Bt)}i.restore()}}else{const j=pa({source:g,sx:K,sy:B,sw:at,sh:st,dx:n,dy:o,dw:l,dh:d});i.drawImage(...j)}const ft=K*-1*J,wt=B*-1*J,Pt=l-ft*2,F=d-wt*2;return{dx:ft,dy:wt,dw:Pt,dh:F}}const Zm=(i,t,e,r)=>{if(e==="length"||e==="prototype"||e==="arguments"||e==="caller")return;const n=Object.getOwnPropertyDescriptor(i,e),o=Object.getOwnPropertyDescriptor(t,e);!qm(n,o)&&r||Object.defineProperty(i,e,o)},qm=function(i,t){return i===void 0||i.configurable||i.writable===t.writable&&i.enumerable===t.enumerable&&i.configurable===t.configurable&&(i.writable||i.value===t.value)},Qm=(i,t)=>{const e=Object.getPrototypeOf(t);e!==Object.getPrototypeOf(i)&&Object.setPrototypeOf(i,e)},Jm=(i,t)=>`/* Wrapped ${i}*/
89
- ${t}`,t1=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),e1=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),r1=(i,t,e)=>{const r=e===""?"":`with ${e.trim()}() `,n=Jm.bind(null,r,t.toString());Object.defineProperty(n,"name",e1),Object.defineProperty(i,"toString",{...t1,value:n})};function i1(i,t,{ignoreNonConfigurable:e=!1}={}){const{name:r}=i;for(const n of Reflect.ownKeys(t))Zm(i,t,n,e);return Qm(i,t),r1(i,t,r),i}const s1=new WeakMap,mu=new WeakMap;function rc(i,{cacheKey:t,cache:e=new Map,maxAge:r}={}){if(r===0)return i;if(typeof r=="number"){if(r>2147483647)throw new TypeError("The `maxAge` option cannot exceed 2147483647.");if(r<0)throw new TypeError("The `maxAge` option should not be a negative number.")}const n=function(...o){var l;const d=t?t(o):o[0],f=e.get(d);if(f)return f.data;const p=i.apply(this,o);if(e.set(d,{data:p,maxAge:r?Date.now()+r:Number.POSITIVE_INFINITY}),typeof r=="number"&&r!==Number.POSITIVE_INFINITY){const g=setTimeout(()=>{e.delete(d)},r);(l=g.unref)==null||l.call(g);const v=mu.get(i)??new Set;v.add(g),mu.set(i,v)}return p};return i1(n,i,{ignoreNonConfigurable:!0}),s1.set(n,e),n}function vu({context:i,word:t,maxW:e=1/0}){const r=[],n=i.measureText(t);if(n.width<e)return[{text:t,metrics:n}];for(let o=0;o<t.length;o++){const l=r[r.length-1],d=((l==null?void 0:l.text)??"")+t[o],f=i.measureText(d);f.width<e?r[l?r.length-1:0]={text:d,metrics:f}:r.push({text:t[o],metrics:i.measureText(t[o])})}return r}const yu=rc(({font:i,scale:t,context:e,maxW:r,maxH:n,text:o,minSize:l,maxSize:d})=>{var f,p;let g=0;if(d){g=(l??0)*t;let v=0;for(;d*t>g+1;){g+=1;const E=xo({context:e,font:i,fontSize:g,text:o,maxW:r});if(v=E.reduce((A,T)=>(T.metrics.width>A&&(A=T.metrics.width),A),0),v>r||E.length*g>n){g-=1;break}}}else g=parseFloat(((p=(f=i.match(Io))==null?void 0:f.groups)==null?void 0:p.value)??"0")*t;return g},{cacheKey:([{font:i,text:t,minSize:e,maxSize:r,scale:n,maxW:o,maxH:l}])=>`${i}_${t}_${e}_${r}_${n}_${o}_${l}`});function n1(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var we={},ic={},oe={};Object.defineProperty(oe,"__esModule",{value:!0}),oe.default=oe.Wrap=oe.Unit=oe.PrintOptions=oe.PositionType=oe.Overflow=oe.NodeType=oe.MeasureMode=oe.LogLevel=oe.Justify=oe.Gutter=oe.FlexDirection=oe.ExperimentalFeature=oe.Errata=oe.Edge=oe.Display=oe.Direction=oe.Dimension=oe.Align=void 0;let es=function(i){return i[i.Auto=0]="Auto",i[i.FlexStart=1]="FlexStart",i[i.Center=2]="Center",i[i.FlexEnd=3]="FlexEnd",i[i.Stretch=4]="Stretch",i[i.Baseline=5]="Baseline",i[i.SpaceBetween=6]="SpaceBetween",i[i.SpaceAround=7]="SpaceAround",i}({});oe.Align=es;let sc=function(i){return i[i.Width=0]="Width",i[i.Height=1]="Height",i}({});oe.Dimension=sc;let go=function(i){return i[i.Inherit=0]="Inherit",i[i.LTR=1]="LTR",i[i.RTL=2]="RTL",i}({});oe.Direction=go;let nc=function(i){return i[i.Flex=0]="Flex",i[i.None=1]="None",i}({});oe.Display=nc;let Pi=function(i){return i[i.Left=0]="Left",i[i.Top=1]="Top",i[i.Right=2]="Right",i[i.Bottom=3]="Bottom",i[i.Start=4]="Start",i[i.End=5]="End",i[i.Horizontal=6]="Horizontal",i[i.Vertical=7]="Vertical",i[i.All=8]="All",i}({});oe.Edge=Pi;let ga=function(i){return i[i.None=0]="None",i[i.StretchFlexBasis=1]="StretchFlexBasis",i[i.All=2147483647]="All",i[i.Classic=2147483646]="Classic",i}({});oe.Errata=ga;let mo=function(i){return i[i.WebFlexBasis=0]="WebFlexBasis",i[i.AbsolutePercentageAgainstPaddingEdge=1]="AbsolutePercentageAgainstPaddingEdge",i[i.FixJNILocalRefOverflows=2]="FixJNILocalRefOverflows",i}({});oe.ExperimentalFeature=mo;let ma=function(i){return i[i.Column=0]="Column",i[i.ColumnReverse=1]="ColumnReverse",i[i.Row=2]="Row",i[i.RowReverse=3]="RowReverse",i}({});oe.FlexDirection=ma;let vo=function(i){return i[i.Column=0]="Column",i[i.Row=1]="Row",i[i.All=2]="All",i}({});oe.Gutter=vo;let sn=function(i){return i[i.FlexStart=0]="FlexStart",i[i.Center=1]="Center",i[i.FlexEnd=2]="FlexEnd",i[i.SpaceBetween=3]="SpaceBetween",i[i.SpaceAround=4]="SpaceAround",i[i.SpaceEvenly=5]="SpaceEvenly",i}({});oe.Justify=sn;let nn=function(i){return i[i.Error=0]="Error",i[i.Warn=1]="Warn",i[i.Info=2]="Info",i[i.Debug=3]="Debug",i[i.Verbose=4]="Verbose",i[i.Fatal=5]="Fatal",i}({});oe.LogLevel=nn;let yo=function(i){return i[i.Undefined=0]="Undefined",i[i.Exactly=1]="Exactly",i[i.AtMost=2]="AtMost",i}({});oe.MeasureMode=yo;let ac=function(i){return i[i.Default=0]="Default",i[i.Text=1]="Text",i}({});oe.NodeType=ac;let bo=function(i){return i[i.Visible=0]="Visible",i[i.Hidden=1]="Hidden",i[i.Scroll=2]="Scroll",i}({});oe.Overflow=bo;let Eo=function(i){return i[i.Static=0]="Static",i[i.Relative=1]="Relative",i[i.Absolute=2]="Absolute",i}({});oe.PositionType=Eo;let Ao=function(i){return i[i.Layout=1]="Layout",i[i.Style=2]="Style",i[i.Children=4]="Children",i}({});oe.PrintOptions=Ao;let va=function(i){return i[i.Undefined=0]="Undefined",i[i.Point=1]="Point",i[i.Percent=2]="Percent",i[i.Auto=3]="Auto",i}({});oe.Unit=va;let To=function(i){return i[i.NoWrap=0]="NoWrap",i[i.Wrap=1]="Wrap",i[i.WrapReverse=2]="WrapReverse",i}({});oe.Wrap=To;var a1={ALIGN_AUTO:es.Auto,ALIGN_FLEX_START:es.FlexStart,ALIGN_CENTER:es.Center,ALIGN_FLEX_END:es.FlexEnd,ALIGN_STRETCH:es.Stretch,ALIGN_BASELINE:es.Baseline,ALIGN_SPACE_BETWEEN:es.SpaceBetween,ALIGN_SPACE_AROUND:es.SpaceAround,DIMENSION_WIDTH:sc.Width,DIMENSION_HEIGHT:sc.Height,DIRECTION_INHERIT:go.Inherit,DIRECTION_LTR:go.LTR,DIRECTION_RTL:go.RTL,DISPLAY_FLEX:nc.Flex,DISPLAY_NONE:nc.None,EDGE_LEFT:Pi.Left,EDGE_TOP:Pi.Top,EDGE_RIGHT:Pi.Right,EDGE_BOTTOM:Pi.Bottom,EDGE_START:Pi.Start,EDGE_END:Pi.End,EDGE_HORIZONTAL:Pi.Horizontal,EDGE_VERTICAL:Pi.Vertical,EDGE_ALL:Pi.All,ERRATA_NONE:ga.None,ERRATA_STRETCH_FLEX_BASIS:ga.StretchFlexBasis,ERRATA_ALL:ga.All,ERRATA_CLASSIC:ga.Classic,EXPERIMENTAL_FEATURE_WEB_FLEX_BASIS:mo.WebFlexBasis,EXPERIMENTAL_FEATURE_ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE:mo.AbsolutePercentageAgainstPaddingEdge,EXPERIMENTAL_FEATURE_FIX_JNILOCAL_REF_OVERFLOWS:mo.FixJNILocalRefOverflows,FLEX_DIRECTION_COLUMN:ma.Column,FLEX_DIRECTION_COLUMN_REVERSE:ma.ColumnReverse,FLEX_DIRECTION_ROW:ma.Row,FLEX_DIRECTION_ROW_REVERSE:ma.RowReverse,GUTTER_COLUMN:vo.Column,GUTTER_ROW:vo.Row,GUTTER_ALL:vo.All,JUSTIFY_FLEX_START:sn.FlexStart,JUSTIFY_CENTER:sn.Center,JUSTIFY_FLEX_END:sn.FlexEnd,JUSTIFY_SPACE_BETWEEN:sn.SpaceBetween,JUSTIFY_SPACE_AROUND:sn.SpaceAround,JUSTIFY_SPACE_EVENLY:sn.SpaceEvenly,LOG_LEVEL_ERROR:nn.Error,LOG_LEVEL_WARN:nn.Warn,LOG_LEVEL_INFO:nn.Info,LOG_LEVEL_DEBUG:nn.Debug,LOG_LEVEL_VERBOSE:nn.Verbose,LOG_LEVEL_FATAL:nn.Fatal,MEASURE_MODE_UNDEFINED:yo.Undefined,MEASURE_MODE_EXACTLY:yo.Exactly,MEASURE_MODE_AT_MOST:yo.AtMost,NODE_TYPE_DEFAULT:ac.Default,NODE_TYPE_TEXT:ac.Text,OVERFLOW_VISIBLE:bo.Visible,OVERFLOW_HIDDEN:bo.Hidden,OVERFLOW_SCROLL:bo.Scroll,POSITION_TYPE_STATIC:Eo.Static,POSITION_TYPE_RELATIVE:Eo.Relative,POSITION_TYPE_ABSOLUTE:Eo.Absolute,PRINT_OPTIONS_LAYOUT:Ao.Layout,PRINT_OPTIONS_STYLE:Ao.Style,PRINT_OPTIONS_CHILDREN:Ao.Children,UNIT_UNDEFINED:va.Undefined,UNIT_POINT:va.Point,UNIT_PERCENT:va.Percent,UNIT_AUTO:va.Auto,WRAP_NO_WRAP:To.NoWrap,WRAP_WRAP:To.Wrap,WRAP_WRAP_REVERSE:To.WrapReverse};oe.default=a1,Object.defineProperty(ic,"__esModule",{value:!0}),ic.default=l1;var Ss=o1(oe);function bu(i){if(typeof WeakMap!="function")return null;var t=new WeakMap,e=new WeakMap;return(bu=function(r){return r?e:t})(i)}function o1(i,t){if(!t&&i&&i.__esModule)return i;if(i===null||typeof i!="object"&&typeof i!="function")return{default:i};var e=bu(t);if(e&&e.has(i))return e.get(i);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in i)if(o!=="default"&&Object.prototype.hasOwnProperty.call(i,o)){var l=n?Object.getOwnPropertyDescriptor(i,o):null;l&&(l.get||l.set)?Object.defineProperty(r,o,l):r[o]=i[o]}return r.default=i,e&&e.set(i,r),r}function l1(i){function t(n,o,l){const d=n[o];n[o]=function(){for(var f=arguments.length,p=new Array(f),g=0;g<f;g++)p[g]=arguments[g];return l.call(this,d,...p)}}for(const n of["setPosition","setMargin","setFlexBasis","setWidth","setHeight","setMinWidth","setMinHeight","setMaxWidth","setMaxHeight","setPadding"]){const o={[Ss.Unit.Point]:i.Node.prototype[n],[Ss.Unit.Percent]:i.Node.prototype[`${n}Percent`],[Ss.Unit.Auto]:i.Node.prototype[`${n}Auto`]};t(i.Node.prototype,n,function(l){for(var d=arguments.length,f=new Array(d>1?d-1:0),p=1;p<d;p++)f[p-1]=arguments[p];const g=f.pop();let v,E;if(g==="auto")v=Ss.Unit.Auto,E=void 0;else if(typeof g=="object")v=g.unit,E=g.valueOf();else if(v=typeof g=="string"&&g.endsWith("%")?Ss.Unit.Percent:Ss.Unit.Point,E=parseFloat(g),!Number.isNaN(g)&&Number.isNaN(E))throw new Error(`Invalid value ${g} for ${n}`);if(!o[v])throw new Error(`Failed to execute "${n}": Unsupported unit '${g}'`);return E!==void 0?o[v].call(this,...f,E):o[v].call(this,...f)})}function e(n){return i.MeasureCallback.implement({measure:function(){const{width:o,height:l}=n(...arguments);return{width:o??NaN,height:l??NaN}}})}t(i.Node.prototype,"setMeasureFunc",function(n,o){return o?n.call(this,e(o)):this.unsetMeasureFunc()});function r(n){return i.DirtiedCallback.implement({dirtied:n})}return t(i.Node.prototype,"setDirtiedFunc",function(n,o){n.call(this,r(o))}),t(i.Config.prototype,"free",function(){i.Config.destroy(this)}),t(i.Node,"create",(n,o)=>o?i.Node.createWithConfig(o):i.Node.createDefault()),t(i.Node.prototype,"free",function(){i.Node.destroy(this)}),t(i.Node.prototype,"freeRecursive",function(){for(let n=0,o=this.getChildCount();n<o;++n)this.getChild(0).freeRecursive();this.free()}),t(i.Node.prototype,"calculateLayout",function(n){let o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:NaN,l=arguments.length>2&&arguments[2]!==void 0?arguments[2]:NaN,d=arguments.length>3&&arguments[3]!==void 0?arguments[3]:Ss.Direction.LTR;return n.call(this,o,l,d)}),{Config:i.Config,Node:i.Node,...Ss.default}}var Eu={exports:{}};(function(i,t){var e=(()=>{var r=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return function(n){n=n||{};var o;o||(o=typeof n<"u"?n:{});var l,d;o.ready=new Promise(function(_,L){l=_,d=L});var f=Object.assign({},o),p="";typeof document<"u"&&document.currentScript&&(p=document.currentScript.src),r&&(p=r),p.indexOf("blob:")!==0?p=p.substr(0,p.replace(/[?#].*/,"").lastIndexOf("/")+1):p="";var g=o.print||console.log.bind(console),v=o.printErr||console.warn.bind(console);Object.assign(o,f),f=null;var E;o.wasmBinary&&(E=o.wasmBinary),o.noExitRuntime;function A(){this.buffer=new ArrayBuffer(F/65536*65536)}function T(){}function w(_){this.exports=function(L){function H(nr){return nr.set=function(ue,oi){this[ue]=oi},nr.get=function(ue){return this[ue]},nr}for(var V,rt=new Uint8Array(123),yt=25;yt>=0;--yt)rt[48+yt]=52+yt,rt[65+yt]=yt,rt[97+yt]=26+yt;rt[43]=62,rt[47]=63;function lt(nr,ue,oi){for(var Br,pt,Vi=0,c=ue,Tt=oi.length,Hn=ue+(Tt*3>>2)-(oi[Tt-2]=="=")-(oi[Tt-1]=="=");Vi<Tt;Vi+=4)Br=rt[oi.charCodeAt(Vi+1)],pt=rt[oi.charCodeAt(Vi+2)],nr[c++]=rt[oi.charCodeAt(Vi)]<<2|Br>>4,c<Hn&&(nr[c++]=Br<<4|pt>>2),c<Hn&&(nr[c++]=pt<<6|rt[oi.charCodeAt(Vi+3)])}function Lt(nr){lt(V,1024,"T25seSBsZWFmIG5vZGVzIHdpdGggY3VzdG9tIG1lYXN1cmUgZnVuY3Rpb25zIHNob3VsZCBtYW51YWxseSBtYXJrIHRoZW1zZWx2ZXMgYXMgZGlydHkAaXNEaXJ0eQBtYXJrRGlydHkAZGVzdHJveQBzZXREaXNwbGF5AGdldERpc3BsYXkAc2V0RmxleAAtKyAgIDBYMHgALTBYKzBYIDBYLTB4KzB4IDB4AHNldEZsZXhHcm93AGdldEZsZXhHcm93AHNldE92ZXJmbG93AGdldE92ZXJmbG93AGNhbGN1bGF0ZUxheW91dABnZXRDb21wdXRlZExheW91dAB1bnNpZ25lZCBzaG9ydABnZXRDaGlsZENvdW50AHVuc2lnbmVkIGludABzZXRKdXN0aWZ5Q29udGVudABnZXRKdXN0aWZ5Q29udGVudABzZXRBbGlnbkNvbnRlbnQAZ2V0QWxpZ25Db250ZW50AGdldFBhcmVudABpbXBsZW1lbnQAc2V0TWF4SGVpZ2h0UGVyY2VudABzZXRIZWlnaHRQZXJjZW50AHNldE1pbkhlaWdodFBlcmNlbnQAc2V0RmxleEJhc2lzUGVyY2VudABzZXRQb3NpdGlvblBlcmNlbnQAc2V0TWFyZ2luUGVyY2VudABzZXRNYXhXaWR0aFBlcmNlbnQAc2V0V2lkdGhQZXJjZW50AHNldE1pbldpZHRoUGVyY2VudABzZXRQYWRkaW5nUGVyY2VudABjcmVhdGVEZWZhdWx0AHVuaXQAcmlnaHQAaGVpZ2h0AHNldE1heEhlaWdodABnZXRNYXhIZWlnaHQAc2V0SGVpZ2h0AGdldEhlaWdodABzZXRNaW5IZWlnaHQAZ2V0TWluSGVpZ2h0AGdldENvbXB1dGVkSGVpZ2h0AGdldENvbXB1dGVkUmlnaHQAbGVmdABnZXRDb21wdXRlZExlZnQAcmVzZXQAX19kZXN0cnVjdABmbG9hdAB1aW50NjRfdAB1c2VXZWJEZWZhdWx0cwBzZXRVc2VXZWJEZWZhdWx0cwBzZXRBbGlnbkl0ZW1zAGdldEFsaWduSXRlbXMAc2V0RmxleEJhc2lzAGdldEZsZXhCYXNpcwBDYW5ub3QgZ2V0IGxheW91dCBwcm9wZXJ0aWVzIG9mIG11bHRpLWVkZ2Ugc2hvcnRoYW5kcwB1c2VMZWdhY3lTdHJldGNoQmVoYXZpb3VyAHNldFVzZUxlZ2FjeVN0cmV0Y2hCZWhhdmlvdXIAc2V0UG9pbnRTY2FsZUZhY3RvcgBNZWFzdXJlQ2FsbGJhY2tXcmFwcGVyAERpcnRpZWRDYWxsYmFja1dyYXBwZXIAQ2Fubm90IHJlc2V0IGEgbm9kZSBzdGlsbCBhdHRhY2hlZCB0byBhIG93bmVyAHNldEJvcmRlcgBnZXRCb3JkZXIAZ2V0Q29tcHV0ZWRCb3JkZXIAdW5zaWduZWQgY2hhcgB0b3AAZ2V0Q29tcHV0ZWRUb3AAc2V0RmxleFdyYXAAZ2V0RmxleFdyYXAAc2V0R2FwAGdldEdhcAAlcABzZXRIZWlnaHRBdXRvAHNldEZsZXhCYXNpc0F1dG8Ac2V0TWFyZ2luQXV0bwBzZXRXaWR0aEF1dG8AU2NhbGUgZmFjdG9yIHNob3VsZCBub3QgYmUgbGVzcyB0aGFuIHplcm8Ac2V0QXNwZWN0UmF0aW8AZ2V0QXNwZWN0UmF0aW8Ac2V0UG9zaXRpb24AZ2V0UG9zaXRpb24Abm90aWZ5T25EZXN0cnVjdGlvbgBzZXRGbGV4RGlyZWN0aW9uAGdldEZsZXhEaXJlY3Rpb24Ac2V0TWFyZ2luAGdldE1hcmdpbgBnZXRDb21wdXRlZE1hcmdpbgBuYW4AYm90dG9tAGdldENvbXB1dGVkQm90dG9tAGJvb2wAZW1zY3JpcHRlbjo6dmFsAHNldEZsZXhTaHJpbmsAZ2V0RmxleFNocmluawBNZWFzdXJlQ2FsbGJhY2sARGlydGllZENhbGxiYWNrAHdpZHRoAHNldE1heFdpZHRoAGdldE1heFdpZHRoAHNldFdpZHRoAGdldFdpZHRoAHNldE1pbldpZHRoAGdldE1pbldpZHRoAGdldENvbXB1dGVkV2lkdGgAdW5zaWduZWQgbG9uZwBzdGQ6OndzdHJpbmcAc3RkOjpzdHJpbmcAc3RkOjp1MTZzdHJpbmcAc3RkOjp1MzJzdHJpbmcAc2V0UGFkZGluZwBnZXRQYWRkaW5nAGdldENvbXB1dGVkUGFkZGluZwBBdHRlbXB0aW5nIHRvIGNvbnN0cnVjdCBZR05vZGUgd2l0aCBudWxsIGNvbmZpZwBUcmllZCB0byBjb25zdHJ1Y3QgWUdOb2RlIHdpdGggbnVsbCBjb25maWcAY3JlYXRlV2l0aENvbmZpZwBpbmYAc2V0QWxpZ25TZWxmAGdldEFsaWduU2VsZgBTaXplAHZhbHVlAFZhbHVlAGNyZWF0ZQBtZWFzdXJlAHNldFBvc2l0aW9uVHlwZQBnZXRQb3NpdGlvblR5cGUAaXNSZWZlcmVuY2VCYXNlbGluZQBzZXRJc1JlZmVyZW5jZUJhc2VsaW5lAGNvcHlTdHlsZQBkb3VibGUATm9kZQBleHRlbmQAaW5zZXJ0Q2hpbGQAZ2V0Q2hpbGQAcmVtb3ZlQ2hpbGQAdm9pZABhdmFpbGFibGVIZWlnaHQgaXMgaW5kZWZpbml0ZSBzbyBoZWlnaHRNZWFzdXJlTW9kZSBtdXN0IGJlIFlHTWVhc3VyZU1vZGVVbmRlZmluZWQAYXZhaWxhYmxlV2lkdGggaXMgaW5kZWZpbml0ZSBzbyB3aWR0aE1lYXN1cmVNb2RlIG11c3QgYmUgWUdNZWFzdXJlTW9kZVVuZGVmaW5lZABzZXRFeHBlcmltZW50YWxGZWF0dXJlRW5hYmxlZABpc0V4cGVyaW1lbnRhbEZlYXR1cmVFbmFibGVkAGRpcnRpZWQAQ2Fubm90IHJlc2V0IGEgbm9kZSB3aGljaCBzdGlsbCBoYXMgY2hpbGRyZW4gYXR0YWNoZWQAdW5zZXRNZWFzdXJlRnVuYwB1bnNldERpcnRpZWRGdW5jAHNldEVycmF0YQBnZXRFcnJhdGEARXhwZWN0IGN1c3RvbSBiYXNlbGluZSBmdW5jdGlvbiB0byBub3QgcmV0dXJuIE5hTgBOQU4ASU5GAGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PHNob3J0PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzx1bnNpZ25lZCBzaG9ydD4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8aW50PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzx1bnNpZ25lZCBpbnQ+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PGZsb2F0PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzx1aW50OF90PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzxpbnQ4X3Q+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PHVpbnQxNl90PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzxpbnQxNl90PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzx1aW50MzJfdD4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8aW50MzJfdD4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8Y2hhcj4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8dW5zaWduZWQgY2hhcj4Ac3RkOjpiYXNpY19zdHJpbmc8dW5zaWduZWQgY2hhcj4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8c2lnbmVkIGNoYXI+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PGxvbmc+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PHVuc2lnbmVkIGxvbmc+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PGRvdWJsZT4AQ2hpbGQgYWxyZWFkeSBoYXMgYSBvd25lciwgaXQgbXVzdCBiZSByZW1vdmVkIGZpcnN0LgBDYW5ub3Qgc2V0IG1lYXN1cmUgZnVuY3Rpb246IE5vZGVzIHdpdGggbWVhc3VyZSBmdW5jdGlvbnMgY2Fubm90IGhhdmUgY2hpbGRyZW4uAENhbm5vdCBhZGQgY2hpbGQ6IE5vZGVzIHdpdGggbWVhc3VyZSBmdW5jdGlvbnMgY2Fubm90IGhhdmUgY2hpbGRyZW4uAChudWxsKQAlcwoAAQAAAAMAAAAAAAAAAgAAAAMAAAABAAAAAgAAAAAAAAABAAAAAQ=="),lt(V,4338,"wH8DAAAAAADAfwAAAABpaQB2AHZp"),lt(V,4368,"exsAAHkbAAC5GwAAsxsAALkbAACzGwAAaWlpZmlmaQCsGwAAfBsAAHZpaQB9GwAAwBsAAGlpaQ=="),lt(V,4432,"xwAAAMgAAADJ"),lt(V,4452,"xwAAAMoAAADLAAAArBs="),lt(V,4480,"exsAALkbAACzGwAAuRsAALMbAADAGwAAuxsAAMAbAABpaWlpAAAAAKwbAACRGwAArBsAAJMbAACUGwAAwBs="),lt(V,4552,"zAAAAM0AAADO"),lt(V,4572,"zAAAAM8AAADLAAAAlxsAAKwbAACXGw=="),lt(V,4608,"rBsAAJcbAACzGwAArRsAAHZpaWlpAAAArBsAAJcbAAC5GwAAdmlpZgAAAACsGwAAlxsAAK0bAAB2aWlpAAAAAKwbAACXGwAAsxsAAK0bAACYGwAAsxsAAK0bAACYGwAAsxsAAJgbAABpAGRpaQB2aWlkAACcGwAAnBsAAJcbAACsGwAAnBsAAKwbAACcGwAAmxsAAKwbAACcGwAAsxsAAKwbAACcGwAAsxsAALobAAB2aWlpZAAAAKwbAACcGwAAuhsAALMbAACdGwAAmhsAAJ0bAACzGwAAmhsAAJ0bAAC6GwAAnRsAALobAACdGwAAsxsAAGRpaWkAAAAAuRsAAJwbAACzGwAAZmlpaQAAAACsGwAAnBsAAJwbAAC0GwAArBsAAJwbAACcGwAAtBsAAJ0bAACcGwAAnBsAAJwbAACcGwAAtBsAAK0bAACcGwAArBsAAJwbAACtGwAArBsAAJwbAAB5GwAArBsAAJwbAACRGwAArRsAAJ0bAAAAAAAArBsAAJwbAAC6GwAAuhsAALMbAAB2aWlkZGkAAJkbAACdGw=="),lt(V,5040,"GQAKABkZGQAAAAAFAAAAAAAACQAAAAALAAAAAAAAAAAZABEKGRkZAwoHAAEACQsYAAAJBgsAAAsABhkAAAAZGRk="),lt(V,5121,"DgAAAAAAAAAAGQAKDRkZGQANAAACAAkOAAAACQAOAAAO"),lt(V,5179,"DA=="),lt(V,5191,"EwAAAAATAAAAAAkMAAAAAAAMAAAM"),lt(V,5237,"EA=="),lt(V,5249,"DwAAAAQPAAAAAAkQAAAAAAAQAAAQ"),lt(V,5295,"Eg=="),lt(V,5307,"EQAAAAARAAAAAAkSAAAAAAASAAASAAAaAAAAGhoa"),lt(V,5362,"GgAAABoaGgAAAAAAAAk="),lt(V,5411,"FA=="),lt(V,5423,"FwAAAAAXAAAAAAkUAAAAAAAUAAAU"),lt(V,5469,"Fg=="),lt(V,5481,"FQAAAAAVAAAAAAkWAAAAAAAWAAAWAAAwMTIzNDU2Nzg5QUJDREVG"),lt(V,5556,"1Q=="),lt(V,5596,"//////////8="),lt(V,5664,"8B8BAAAAAAAF"),lt(V,5684,"0A=="),lt(V,5708,"0QAAANIAAADUGw=="),lt(V,5732,"Ag=="),lt(V,5748,"//////////8="),lt(V,5816,"BQ=="),lt(V,5828,"0w=="),lt(V,5852,"0QAAANQAAADoGwAAAAQ="),lt(V,5876,"AQ=="),lt(V,5892,"/////wo="),lt(V,5960,"1g==")}var xt=new ArrayBuffer(16),Dt=new Int32Array(xt),Ut=new Float32Array(xt),Kt=new Float64Array(xt);function te(nr){return Dt[nr]}function Ot(nr,ue){Dt[nr]=ue}function ke(){return Kt[0]}function Er(nr){Kt[0]=nr}function pe(){throw new Error("abort")}function Jr(nr){Ut[2]=nr}function Gt(){return Ut[2]}function yl(nr){var ue=nr.a,oi=ue.a,Br=oi.buffer;oi.grow=AS;var pt=new Int8Array(Br),Vi=new Int16Array(Br),c=new Int32Array(Br),Tt=new Uint8Array(Br),Hn=new Uint16Array(Br),c2=new Uint32Array(Br),I=new Float32Array(Br),je=new Float64Array(Br),Ke=Math.imul,m=Math.fround,Xe=Math.abs,Ai=Math.clz32,vk=Math.min,yk=Math.max,zt=NaN,h2=1/0,_t=ue.b,Cr=ue.c,us=ue.d,fs=ue.e,Us=ue.f,Vn=ue.g,Ka=ue.h,bl=ue.i,qh=ue.j,Qh=ue.k,Jh=ue.l,d2=ue.m,u2=ue.n,f2=ue.o,p2=ue.p,g2=ue.q,bk=ue.r,Ek=ue.s,Ak=ue.t,Tk=ue.u,kk=ue.v,wk=ue.w,Sk=ue.x,Rk=ue.y,_k=ue.z,Lk=ue.A,Ck=ue.B,Ik=ue.C,xk=ue.D,St=73712,Gr=0;function m2(s,a,h,u,y,b,k,S,P,z,tt,dt,Q,et){var $=0,W=m(0),Y=0,q=m(0),nt=0,ot=m(0),mt=0,Et=m(0),Ct=0,Mt=0,Ft=m(0),Vt=0,qt=0,he=m(0),ye=m(0),Pe=m(0),Ue=m(0),Ge=0,ze=m(0),qe=m(0),ar=0,or=0,kr=m(0),Mr=0,ei=0,Nr=0,Wr=0,ri=m(0),ii=0,Ii=0,xi=0,Yi=0,Xi=m(0),Zi=0,qi=0,ps=0,gs=0,ms=m(0),Vs=0,Ws=0,js=0,Ks=m(0),zs=0,Ys=m(0),Xa=0,Za=m(0),qa=m(0),Qa=m(0),Ja=0,_l=m(0),pd=0,gd=m(0),md=m(0),vd=m(0),yd=m(0),bd=0,ug=0,fg=0,pg=0,gg=0,mg=0,vg=0,yg=0,Qe=0,Je=m(0),Xn=m(0);$=St-384|0,St=$;t:{i:{r:{if(!(y&&a!=a)){if(!(b&&h!=h)){if(Y=(P?0:4)+tt|0,c[Y>>2]=c[Y>>2]+1,Y=c[s+24>>2]&3,pd=(u|0)<=1?1:u,Wr=Y||pd,pt[s+300|0]=Tt[s+300|0]&252|Wr&3,Y=s+252|0,u=((Wr|0)!=1)<<3,Vs=(Wr|0)==2?3:2,ot=ge(s,Vs,k),I[Y+u>>2]=ot,nt=Y,Y=((Wr|0)==1)<<3,ye=Re(s,Vs,k),I[nt+Y>>2]=ye,Et=ge(s,0,k),I[s+256>>2]=Et,Ue=Re(s,0,k),I[s+264>>2]=Ue,nt=s+268|0,Qe=nt+u|0,Je=ve(s,Vs),I[Qe>>2]=Je,Qe=Y+nt|0,Je=_e(s,Vs),I[Qe>>2]=Je,W=ve(s,0),I[s+272>>2]=W,ze=_e(s,0),I[s+280>>2]=ze,nt=u,u=s+284|0,Qe=nt+u|0,Je=Ne(s,Vs,k),I[Qe>>2]=Je,Qe=u+Y|0,Je=Fe(s,Vs,k),I[Qe>>2]=Je,q=Ne(s,0,k),I[s+288>>2]=q,Ft=Fe(s,0,k),I[s+296>>2]=Ft,ot=m(ot+ye),ye=m(Et+Ue),u=c[s+8>>2],u){Et=m(m(m(I[s+284>>2]+I[s+292>>2])+I[s+268>>2])+I[s+276>>2]),h=m(b?h-ye:zt),W=m(m(q+Ft)+W),q=m(y?a-ot:zt),a=q;e:{if(a!=a)break e;if(a=m(q-Et),a!=a){a=m(0);break e}a=fe(a,m(0))}ot=m(W+ze),W=h;e:{if(h!=h)break e;if(W=m(h-ot),W!=W){W=m(0);break e}W=fe(W,m(0))}if(!((y|0)!=1|(b|0)!=1)){a=Ze(s,2,q,k),u=a!=a,W=m(m(Ne(s,2,k)+ve(s,2))+m(Fe(s,2,k)+_e(s,2)));e:{if(!(u|W!=W)){a=fe(a,W);break e}a=u?W:a}I[s+516>>2]=a,a=Ze(s,0,h,S),u=a!=a,h=m(m(Ne(s,0,k)+ve(s,0))+m(Fe(s,0,k)+_e(s,0)));e:{if(!(u|h!=h)){a=fe(a,h);break e}a=u?h:a}I[s+520>>2]=a;break t}e:{if(Tt[s+4|0]&16){$t[u|0]($+24|0,s,a,y,W,b,0);break e}$t[u|0]($+24|0,s,a,y,W,b)}c[tt+20>>2]=c[tt+20>>2]+1,u=(et<<2)+tt|0,c[u+24>>2]=c[u+24>>2]+1,a=m(Et+I[$+24>>2]),a=Ze(s,2,y?(y|0)==2?a:q:a,k),u=a!=a,W=m(m(Ne(s,2,k)+ve(s,2))+m(Fe(s,2,k)+_e(s,2)));e:{if(!(u|W!=W)){a=fe(a,W);break e}a=u?W:a}I[s+516>>2]=a,a=m(ot+I[$+28>>2]),a=Ze(s,0,b?(b|0)==2?a:h:a,S),u=a!=a,h=m(m(Ne(s,0,k)+ve(s,0))+m(Fe(s,0,k)+_e(s,0)));e:{if(!(u|h!=h)){a=fe(a,h);break e}a=u?h:a}I[s+520>>2]=a;break t}if(u=c[s+556>>2],et=c[s+560>>2],(u|0)==(et|0)){ye=m(h-ye),a=Ze(s,2,y&-3?m(a-ot):m(m(m(I[s+284>>2]+I[s+292>>2])+I[s+268>>2])+I[s+276>>2]),k),u=a!=a,h=m(m(Ne(s,2,k)+ve(s,2))+m(Fe(s,2,k)+_e(s,2)));e:{if(!(u|h!=h)){a=fe(a,h);break e}a=u?h:a}I[s+516>>2]=a,a=Ze(s,0,b&-3?ye:m(m(m(q+Ft)+W)+ze),S),u=a!=a,h=m(m(Ne(s,0,k)+ve(s,0))+m(Fe(s,0,k)+_e(s,0)));e:{if(!(u|h!=h)){a=fe(a,h);break e}a=u?h:a}I[s+520>>2]=a;break t}e:{if(P||(W=m(a-ot),q=m(h-ye),!(!(!(W<=m(0))|(y|0)!=2)&W==W|!(!(q<=m(0))|(b|0)!=2)&q==q)&((y|0)!=1|(b|0)!=1)))break e;a=Ze(s,2,W!=W||(y|0)==2&&W<m(0)?m(0):W,k),u=a!=a,h=m(m(Ne(s,2,k)+ve(s,2))+m(Fe(s,2,k)+_e(s,2)));s:{if(!(u|h!=h)){a=fe(a,h);break s}a=u?h:a}I[s+516>>2]=a,a=Ze(s,0,q!=q||(b|0)==2&&q<m(0)?m(0):q,S),u=a!=a,h=m(m(Ne(s,0,k)+ve(s,0))+m(Fe(s,0,k)+_e(s,0)));s:{if(!(u|h!=h)){a=fe(a,h);break s}a=u?h:a}I[s+520>>2]=a;break t}for(ar=et-u|0,Yi=ar>>2;Y=c[u>>2],c[Y+552>>2]!=(s|0)&&(nt=c[s+568>>2],Y=I2(c[nt>>2],Tt[nt+8|0],Y,s,Ct,0),c[u>>2]=Y,c[Y+552>>2]=s),Ct=Ct+1|0,u=u+4|0,(et|0)!=(u|0););pt[s+300|0]=Tt[s+300|0]&251,Ct=3,Mr=c[s+24>>2],u=Mr>>>2&3;e:{s:{n:{if((Wr|0)==2){et=0;a:switch(u-2|0){case 0:break e;case 1:break a;default:break n}Ct=2;break e}if(Ct=2,et=0,u>>>0>1)break s}et=Ct}Ct=u}gd=m(a-ot),Xi=m(m(Ne(s,Ct,k)+ve(s,Ct))+m(Fe(s,Ct,k)+_e(s,Ct))),ze=m(Ne(s,et,k)+ve(s,et)),ri=m(ze+m(Fe(s,et,k)+_e(s,et))),ii=Ct>>>0>1,Et=A2(s,0,gd,ii?Xi:ri,k),md=m(h-ye),qe=A2(s,1,md,ii?ri:Xi,S),Ue=ii?qe:Et,ye=ii?Et:qe,Zi=c[s+560>>2],Y=c[s+556>>2],ei=ii?y:b;e:{if((ei|0)!=1)break e;if((Y|0)==(Zi|0))break r;for(u=Y;;){nt=c[u>>2];s:{if(!B2(nt))break s;if(qt=0,mt)break e;n:{a:{if(!c[nt+552>>2]){W=m(0);break a}if(h=I[nt+32>>2],h!=h&&(W=m(0),h=I[nt+28>>2],!(h>m(0))))break a;if(W=h,h!=h)break n}if(m(Xe(W))<m(9999999747378752e-20))break e}if(a=zn(nt),a!=a){mt=nt;break s}if(mt=nt,m(Xe(a))<m(9999999747378752e-20))break e}if(qt=mt,u=u+4|0,(Zi|0)==(u|0))break}}if((Y|0)==(Zi|0))break r;for(Xa=(Wr|0)<=1?1:Wr,Ws=Et!=Et,qi=Ws|(y|0)!=1,ps=qe==qe,js=Et==Et,W=m(0);;){Vt=c[Y>>2],E2(Vt),nt=c[Vt+24>>2];e:{if(nt&4194304){if(w2(Vt,0),u=Tt[Vt+4|0],nt=u|1,pt[Vt+4|0]=nt,!(u&4))break e;pt[Vt+4|0]=nt&251;break e}if(P&&(u=nt&3,x2(Vt,u||Xa,ye,Ue,Et),nt=c[Vt+24>>2]),(nt&196608)==131072)break e;s:{if((Vt|0)==(qt|0)){c[qt+308>>2]=0,c[qt+304>>2]=Q,h=m(0);break s}gs=c[s+24>>2],u=gs>>>2&3;n:{a:{if((Wr|0)!=2)break a;mt=3;o:switch(u-2|0){case 0:break n;case 1:break o;default:break a}mt=2;break n}mt=u}Ii=mt>>>0>1,ot=Ii?Et:qe,h=m(0),a=I[Vt+40>>2];n:{a:{Mt=c[Vt+40>>2];o:{if((Mt|0)==2139156720)break o;if((Mt|0)==2140081935)break a;u=4336;l:{if((Mt|0)!=2141891242){if(a==a)break l;u=4344}h=I[u>>2];c:{h:switch(Mt=c[u+4>>2],Mt|0){case 0:case 3:break h;default:break c}if(a=m(zt),!(I[Vt+28>>2]>m(0)))break n;Mt=pt[c[Vt+568>>2]+8|0]&1,u=Mt?2143289344:0,Mt=Mt?3:1,h=(Ot(2,u),Gt())}switch(a=m(zt),Mt-1|0){case 0:break a;case 1:break o;default:break n}}if(h=(Ot(2,(Mt&-1073741825)+536870912|0),Gt()),!(Mt&1073741824))break a}a=m(m(ot*h)*m(.009999999776482582));break n}a=h}h=I[Vt+572>>2],Mt=0;n:{a:switch(Ge=c[Vt+576>>2],Ge|0){case 0:case 3:break n;default:break a}if(q=I[Vt+572>>2],!((Ge|0)!=1|q!=q)){if(h<m(0))break n;Mt=1;break n}if(Mt=1,(Ge|0)!=2|q!=q||(Mt=0,h<m(0)))break n;Mt=js}q=I[Vt+580>>2],u=0;n:{a:switch(or=c[Vt+584>>2],or|0){case 0:case 3:break n;default:break a}if(Ft=I[Vt+580>>2],!((or|0)!=1|Ft!=Ft)){if(q<m(0))break n;u=1;break n}if(u=1,(or|0)!=2|Ft!=Ft||(u=0,q<m(0)))break n;u=ps}n:{a:{if(!(a!=a|ot!=ot)){if(h=I[Vt+308>>2],(!(pt[c[Vt+568>>2]+12|0]&1)|c[Vt+304>>2]==(Q|0))&h==h)break n;if(h=m(m(Ne(Vt,mt,Et)+ve(Vt,mt))+m(Fe(Vt,mt,Et)+_e(Vt,mt))),!(h<=a)&a<h)break a;h=a;break a}if(Mt&Ii){q=m(m(Ne(Vt,2,Et)+ve(Vt,2))+m(Fe(Vt,2,Et)+_e(Vt,2))),a=m(zt);o:switch(Ge-1|0){case 1:h=m(m(Et*h)*m(.009999999776482582));case 0:if(a=h,q<=a)break a;break;default:break o}if(!(a==a|q==q)){h=a;break a}if(a<q){h=q;break a}h=a!=a?q:a;break a}if(!(Ii|u^1)){a=m(m(Ne(Vt,0,Et)+ve(Vt,0))+m(Fe(Vt,0,Et)+_e(Vt,0))),h=m(zt);o:switch(or-1|0){case 1:q=m(m(qe*q)*m(.009999999776482582));case 0:if(h=q,a<=h)break a;break;default:break o}if(h!=h&a!=a)break a;if(a>h){h=a;break a}h=h!=h?a:h;break a}if(c[$+360>>2]=2143289344,c[$+24>>2]=2143289344,Nr=0,c[$+356>>2]=0,c[$+352>>2]=0,Ft=m(ge(Vt,2,Et)+Re(Vt,2,Et)),he=ge(Vt,0,Et),Pe=Re(Vt,0,Et),ot=m(zt),xi=0,a=m(zt),Mt){o:{l:switch(Ge-1|0){case 0:a=h;break o;case 1:break l;default:break o}a=m(m(Et*h)*m(.009999999776482582))}c[$+356>>2]=1,a=m(Ft+a),I[$+24>>2]=a,xi=1}if(he=m(he+Pe),u){h=m(zt);o:{l:switch(or-1|0){case 0:h=q;break o;case 1:break l;default:break o}h=m(m(qe*q)*m(.009999999776482582))}c[$+352>>2]=1,ot=m(he+h),I[$+360>>2]=ot,Nr=1}Ge=(gs&3145728)==2097152,or=mt>>>0<2;o:{l:{c:{if(!(Ge&or)){if(Ge|Ws)break l;if(a!=a)break c;break l}if(Ws|a==a)break o}xi=2,c[$+356>>2]=2,I[$+24>>2]=Et,a=Et}l:{if(!Ge||or){if(Ge|qe!=qe)break o;if(ot!=ot)break l;break o}if(ot==ot|qe!=qe)break o}Nr=2,c[$+352>>2]=2,I[$+360>>2]=qe,ot=qe}h=I[Vt+224>>2],Ge=h!=h;o:{if(Ge)break o;l:{if(!(Ii|(xi|0)!=1)){c[$+352>>2]=1,I[$+360>>2]=he+m(m(a-Ft)/h);break l}if(or|(Nr|0)!=1)break o;c[$+356>>2]=1,I[$+24>>2]=m(m(ot-he)*h)+Ft}Nr=1,xi=1}nt=nt>>>13&7,nt=nt||gs>>>10&7;o:{if((nt|0)==5|(xi|0)==1|(Ii|(Mt|qi))|(nt|0)!=4||(c[$+356>>2]=1,I[$+24>>2]=Et,Ge))break o;Nr=1,c[$+352>>2]=1,I[$+360>>2]=m(Et-Ft)/h}o:{if(or|(b|0)!=1|qe!=qe|u|(nt|0)!=4|(Nr|0)==1||(c[$+352>>2]=1,I[$+360>>2]=qe,Ge))break o;c[$+356>>2]=1,I[$+24>>2]=m(qe-he)*h}if(Wn(Vt,2,Et,Et,$+356|0,$+24|0),Wn(Vt,0,qe,Et,$+352|0,$+360|0),vn(Vt,I[$+24>>2],I[$+360>>2],Wr,c[$+356>>2],c[$+352>>2],Et,qe,0,5,z,tt,dt,Q),a=I[(Vt+(c[(mt<<2)+4320>>2]<<2)|0)+516>>2],u=a!=a,h=m(m(Ne(Vt,mt,Et)+ve(Vt,mt))+m(Fe(Vt,mt,Et)+_e(Vt,mt))),!(u|h!=h)){h=fe(a,h);break a}h=u?h:a}I[Vt+308>>2]=h}c[Vt+304>>2]=Q}W=m(W+m(h+m(ge(Vt,Ct,Et)+Re(Vt,Ct,Et))))}if(Y=Y+4|0,(Zi|0)==(Y|0))break}break i}c[$>>2]=3072,li(s,$),ti(),pe()}c[$+16>>2]=3154,li(s,$+16|0),ti(),pe()}W=m(0)}a=m(W+m(0)),Za=ii?S:k,Ks=ii?k:S,ar>>>0>=5&&(a=m(m(El(s,Ct,Ue)*m(Yi-1>>>0))+a)),u=a>ye,Zi=Mr&786432,ps=(ei|0)==2&&Zi&&u?1:ei,Vt=ii?b:y,Ii=(Vt|0)==1,ug=Ii&(P^1),ii=Ct>>>0<2,fg=Vt&-3,Ws=s+208|0,b=et<<2,or=b+4288|0,pg=Ii&!Zi,gg=(Vt|0)!=1|P,Y=Ct<<2,xi=Y+4288|0,js=Y+4320|0,gs=Ue==Ue,mg=gs<<1,Ge=b+4320|0,vg=!ei|!u,Xa=$+52|0,vd=El(s,et,Ue),nt=0,u=0,Nr=0;i:{for(;;){ei=u,Vr($+24|0,0,44),u=c[s+560>>2],b=c[s+556>>2];r:{if((u|0)==(b|0))break r;if(u=u-b|0,(u|0)<0)break i;if(Y=Ya($+360|0,u>>2,0,Xa),u=c[$+44>>2],b=c[$+48>>2]-u|0,b=Bs(c[$+364>>2]-b|0,u,b),u=c[$+44>>2],c[$+364>>2]=u,c[$+44>>2]=b,mt=c[$+368>>2],Mt=c[$+372>>2],b=c[$+48>>2],c[$+368>>2]=b,qt=c[$+52>>2],c[$+48>>2]=mt,c[$+52>>2]=Mt,c[$+372>>2]=qt,c[Y>>2]=u,(u|0)!=(b|0)&&(c[$+368>>2]=b+((u-b|0)+3&-4)),!u)break r;Ar(u)}qt=c[s+24>>2],u=qt>>>2&3;r:{e:{if(b=qt&3,((b||pd)|0)!=2)break e;mt=3;s:switch(u-2|0){case 0:break r;case 1:break s;default:break e}mt=2;break r}mt=u}W=El(s,mt,Et),Y=nt,Mt=c[s+560>>2],b=c[s+556>>2];r:{if(Y>>>0>=Mt-b>>2>>>0)break r;for(qt=qt&786432,h=m(0);;){if(Mt-b>>2>>>0<=Y>>>0)break i;if(u=c[(Y<<2)+b>>2],ar=c[u+24>>2],!(ar&4194304|(ar&196608)==131072)){if(c[u+548>>2]=ei,a=ge(u,mt,Et),q=Re(u,mt,Et),b=c[$+24>>2],ot=(Y|0)==(nt|0)?m(0):W,a=m(a+q),q=I[u+308>>2],Ft=Ze(u,mt,q,Ks),!(!b||!(m(ot+m(a+m(h+Ft)))>ye)|!qt))break r;if(c[$+24>>2]=b+1,ot=m(ot+m(a+Ft)),I[$+28>>2]=ot+I[$+28>>2],B2(u)){e:{if(!c[u+552>>2]){a=m(0);break e}if(a=I[u+32>>2],a==a)break e;a=I[u+28>>2],a=a>m(0)?a:m(0)}I[$+32>>2]=a+I[$+32>>2],Qe=$,Je=m(I[$+36>>2]-m(zn(u)*q)),I[Qe+36>>2]=Je}b=c[$+48>>2];e:{if((b|0)!=c[$+52>>2]){c[b>>2]=u,c[$+48>>2]=b+4;break e}if(b=b-c[$+44>>2]|0,ar=b>>2,Mt=ar+1|0,Mt>>>0>=1073741824)break i;if(Mr=b>>1,Mt=Ya($+360|0,b>>>0>=2147483644?1073741823:Mt>>>0<Mr>>>0?Mr:Mt,ar,Xa),c[c[$+368>>2]>>2]=u,c[$+368>>2]=c[$+368>>2]+4,u=c[$+44>>2],b=c[$+48>>2]-u|0,b=Bs(c[$+364>>2]-b|0,u,b),u=c[$+44>>2],c[$+364>>2]=u,c[$+44>>2]=b,ar=c[$+368>>2],Mr=c[$+372>>2],b=c[$+48>>2],c[$+368>>2]=b,qi=c[$+52>>2],c[$+48>>2]=ar,c[$+52>>2]=Mr,c[$+372>>2]=qi,c[Mt>>2]=u,(u|0)!=(b|0)&&(c[$+368>>2]=b+((u-b|0)+3&-4)),!u)break e;Ar(u)}b=c[s+556>>2],Mt=c[s+560>>2],h=m(h+ot)}if(Y=Y+1|0,!(Y>>>0<Mt-b>>2>>>0))break}}Pe=I[$+32>>2],!(Pe>m(0))|!(Pe<m(1))||(c[$+32>>2]=1065353216,Pe=m(1)),kr=I[$+36>>2],!(kr>m(0))|!(kr<m(1))||(c[$+36>>2]=1065353216,kr=m(1)),c[$+40>>2]=Y,Ft=I[$+28>>2],mt=c[$+24>>2],Nr&&Ar(Nr),q=I[$+56>>2],ar=c[$+48>>2],Nr=c[$+44>>2];r:{e:{s:{n:{if((ps|0)==1)break n;h=m(0),a=I[Ws>>2];a:{o:{u=c[Ws>>2];l:{if((u|0)==2139156720)break l;if((u|0)==2140081935)break o;b=4336;c:{if((u|0)!=2141891242){if(a==a)break c;b=4344}switch(h=I[b>>2],a=m(zt),c[b+4>>2]-1|0){case 0:break o;case 1:break l;default:break a}}if(h=(Ot(2,(u&-1073741825)+536870912|0),Gt()),!(u&1073741824))break o}a=m(m(h*k)*m(.009999999776482582));break a}a=h}h=m(0),W=I[s+216>>2];a:{o:{u=c[s+216>>2];l:{if((u|0)==2139156720)break l;if((u|0)==2140081935)break o;b=4336;c:{if((u|0)!=2141891242){if(W==W)break c;b=4344}switch(h=I[b>>2],W=m(zt),c[b+4>>2]-1|0){case 0:break o;case 1:break l;default:break a}}if(h=(Ot(2,(u&-1073741825)+536870912|0),Gt()),!(u&1073741824))break o}W=m(m(h*k)*m(.009999999776482582));break a}W=h}h=m(0),ot=I[s+212>>2];a:{o:{u=c[s+212>>2];l:{if((u|0)==2139156720)break l;if((u|0)==2140081935)break o;b=4336;c:{if((u|0)!=2141891242){if(ot==ot)break c;b=4344}switch(h=I[b>>2],ot=m(zt),c[b+4>>2]-1|0){case 0:break o;case 1:break l;default:break a}}if(h=(Ot(2,(u&-1073741825)+536870912|0),Gt()),!(u&1073741824))break o}ot=m(m(h*S)*m(.009999999776482582));break a}ot=h}h=m(0),he=I[s+220>>2];a:{o:{u=c[s+220>>2];l:{if((u|0)==2139156720)break l;if((u|0)==2140081935)break o;b=4336;c:{if((u|0)!=2141891242){if(he==he)break c;b=4344}switch(h=I[b>>2],he=m(zt),c[b+4>>2]-1|0){case 0:break o;case 1:break l;default:break a}}if(h=(Ot(2,(u&-1073741825)+536870912|0),Gt()),!(u&1073741824))break o}he=m(m(h*S)*m(.009999999776482582));break a}he=h}if(u=Ct>>>0>1,h=m((u?a:ot)-Xi),h==h&h>Ft||(h=m((u?W:he)-Xi),h==h&h<Ft))break s;if(pt[c[s+568>>2]+16|0]&1)break n;if(h=Ft,!c[s+552>>2]|Pe==m(0))break e;a=I[s+32>>2];a:{o:{if(a==a){h=a;break o}if(h=I[s+28>>2],!(h>m(0)))break a}if(h!=h){h=ye;break e}a=I[s+32>>2]}if(a!=a&&(h=Ft,a=I[s+28>>2],!(a>m(0)))||(h=ye,a!=m(0)))break e;h=Ft;break e}h=ye}if(h!=h)break e;q=m(h-Ft);break r}if(!(Ft<m(0)))break r;q=m(-Ft)}if(ye=h,!ug){r:{if((ar|0)==(Nr|0)){ot=m(0);break r}for(he=m(0),b=Nr;;){u=c[b>>2],Ft=I[u+308>>2],h=Ze(u,Ct,Ft,Ks);e:{if(q<m(0)){if(a=m(h*m(-zn(u))),!(a>m(0)|a<m(0)))break e;W=m(m(m(q/kr)*a)+h),a=Ze(u,Ct,W,ye),Mt=a!=a,ot=m(m(Ne(u,Ct,Et)+ve(u,Ct))+m(Fe(u,Ct,Et)+_e(u,Ct)));s:{if(!(Mt|ot!=ot)){a=fe(a,ot);break s}a=Mt?ot:a}if(W!=W|a!=a|a==W)break e;he=m(he+m(a-h)),kr=m(m(zn(u)*Ft)+kr);break e}if(!(q>m(0))|!c[u+552>>2]||(W=I[u+32>>2],W!=W&&(W=I[u+28>>2],!(W>m(0))))||!(W<m(0)|W>m(0)))break e;ot=m(m(m(q/Pe)*W)+h),a=Ze(u,Ct,ot,ye),Mt=a!=a,Ft=m(m(Ne(u,Ct,Et)+ve(u,Ct))+m(Fe(u,Ct,Et)+_e(u,Ct)));s:{if(!(Mt|Ft!=Ft)){a=fe(a,Ft);break s}a=Mt?Ft:a}if(ot!=ot|a!=a|a==ot)break e;Pe=m(Pe-W),he=m(he+m(a-h))}if(b=b+4|0,(ar|0)==(b|0))break}for(he=m(q-he),qa=m(he/kr),Qa=m(he/Pe),Ja=Ii&(vg|!(Tt[s+26|0]&12)),qi=!Ja,Mr=c[Ge>>2],ot=m(0),Mt=Nr;;){u=c[Mt>>2],Ft=Ze(u,Ct,I[u+308>>2],Ks);e:{s:{if(he<m(0)){if(W=Ft,a=m(W*m(-zn(u))),a==m(0))break e;a=kr==m(0)?m(Ft+a):m(m(qa*a)+Ft);break s}if(W=Ft,!(he>m(0))|!c[u+552>>2]||(a=I[u+32>>2],a!=a&&(a=I[u+28>>2],!(a>m(0))))||!(a<m(0)|a>m(0)))break e;a=m(m(Qa*a)+Ft)}if(a=Ze(u,Ct,a,ye),b=a!=a,h=m(m(Ne(u,Ct,Et)+ve(u,Ct))+m(Fe(u,Ct,Et)+_e(u,Ct))),!(b|h!=h)){W=fe(a,h);break e}W=b?h:a}a=ge(u,Ct,Et),h=Re(u,Ct,Et),Pe=ge(u,et,Et),_l=Re(u,et,Et),h=m(a+h),yd=m(W+h),I[$+352>>2]=yd,c[$+344>>2]=1,Pe=m(Pe+_l),a=I[u+224>>2];e:{if(a==a){c[$+348>>2]=1,h=m(yd-h),I[$+356>>2]=Pe+m(ii?h*a:h/a);break e}s:{if(zs=Ue!=Ue,zs)break s;qt=(Mr<<3)+u|0,a=I[qt+572>>2];n:{a:{o:{l:switch(b=c[qt+576>>2],b|0){case 0:case 3:break o;default:break l}if(h=I[qt+572>>2],(b|0)!=1|h!=h)break a;if(!(qi|!(a<m(0))))break n;break s}if(!Ja)break s;break n}if(qi|(!(a<m(0))|((b|0)!=2|h!=h)))break s}if(b=c[u+24>>2]>>>13&7,b||(b=c[s+24>>2]>>>10&7),(b|0)!=4||(bn($+24|0,u,et),c[$+28>>2]==3)||(yn($+360|0,u,et),c[$+364>>2]==3))break s;c[$+348>>2]=1,I[$+356>>2]=Ue;break e}qt=(Mr<<3)+u|0,h=I[qt+572>>2];s:{n:{a:{o:{l:switch(b=c[qt+576>>2],b|0){case 0:case 3:break o;default:break l}if(a=I[qt+572>>2],!((b|0)!=1|a!=a)){if(a=h,a<m(0))break o;break s}if((b|0)!=2|a!=a)break a;if(zs)break o;if(!(h<m(0)))break n}c[$+348>>2]=mg,I[$+356>>2]=Ue;break e}a=m(zt);a:switch(b-1|0){case 1:break n;case 0:break a;default:break s}a=h;break s}a=m(m(Ue*h)*m(.009999999776482582))}a=m(Pe+a),I[$+356>>2]=a,c[$+348>>2]=(Ii|(b|0)!=2)&a==a}Wn(u,Ct,ye,Et,$+344|0,$+352|0),Wn(u,et,Ue,Et,$+348|0,$+356|0),qt=(Mr<<3)+u|0,a=I[qt+572>>2];e:{s:{n:{a:switch(b=c[qt+576>>2],b|0){case 0:case 3:break n;default:break a}if(h=I[qt+572>>2],!((b|0)!=1|h!=h)){if(a<m(0))break n;break s}if((b|0)!=2|h!=h)break s;if(a<m(0))break n;if(qt=0,gs)break e}if(qt=0,b=c[u+24>>2]>>>13&7,b||(b=c[s+24>>2]>>>10&7),(b|0)!=4||(bn($+24|0,u,et),c[$+28>>2]==3))break e;yn($+360|0,u,et),qt=c[$+364>>2]!=3;break e}qt=0}a=I[$+352>>2],h=I[$+356>>2],b=Ct>>>0>1,Pe=b?a:h,a=b?h:a,zs=c[$+344>>2],bd=c[$+348>>2],yg=b?zs:bd,zs=b?bd:zs,b=(qt^1)&P,vn(u,Pe,a,Tt[s+300|0]&3,yg,zs,Et,qe,b,b?4:7,z,tt,dt,Q),ot=m(ot+m(W-Ft)),b=Tt[s+300|0];e:{s:{if(b&4){qt=b&251;break s}if(qt=b&251,b=0,!(Tt[u+300|0]&4))break e}b=4}if(pt[s+300|0]=b|qt,Mt=Mt+4|0,(ar|0)==(Mt|0))break}}q=m(q-ot)}u=Tt[s+300|0],pt[s+300|0]=u&251|(q<m(0)?4:u&4),he=m(Ne(s,Ct,k)+ve(s,Ct)),qa=m(Fe(s,Ct,k)+_e(s,Ct)),Ft=El(s,Ct,k);r:{if(!(!(q>m(0))|(ps|0)!=2)){ot=m(0),h=m(0);e:{s:{u=Ws+(c[js>>2]<<2)|0,a=I[u>>2],u=c[u>>2],b=(u|0)==2139156720;n:{if(!b){if(Mt=(u|0)==2140081935,Mt)break s;if(qt=(u|0)==2141891242,qt|a!=a)break r;if(Mt)break s;if(qt)break r;if(h=(Ot(2,(u&-1073741825)+536870912|0),Gt()),!(u&1073741824))break n}h=m(m(Ks*h)*m(.009999999776482582))}if(h!=h)break r;h=m(0);n:{if(b)break n;if((u|0)==2140081935)break s;b=4336;a:{if((u|0)!=2141891242){if(a==a)break a;b=4344}switch(h=I[b>>2],W=m(zt),c[b+4>>2]-1|0){case 0:break s;case 1:break n;default:break e}}if(h=(Ot(2,(u&-1073741825)+536870912|0),Gt()),!(u&1073741824))break s}W=m(m(Ks*h)*m(.009999999776482582));break e}W=h}if(a=m(m(m(W-he)-qa)-m(ye-q)),a!=a)break r;ot=fe(a,m(0));break r}ot=q}qt=Y>>>0<=nt>>>0;r:{if(!qt){for(ar=c[s+556>>2],u=c[s+560>>2]-ar>>2,Mr=u>>>0<nt>>>0?nt:u,Mt=0,u=nt;;){if((u|0)==(Mr|0))break i;if(b=c[ar+(u<<2)>>2],(c[b+24>>2]&196608)!=131072&&(qi=$+24|0,bn(qi,b,Ct),Ja=c[$+28>>2],yn(qi,b,Ct),Mt=(((Ja|0)==3)+Mt|0)+(c[$+28>>2]==3)|0),u=u+1|0,(Y|0)==(u|0))break}if(Pe=m(0),h=Ft,Mt)break r}Pe=m(0),Mt=0,h=Ft;e:switch((c[s+24>>2]>>>4&7)-1|0){case 0:Pe=m(ot*m(.5));break r;case 1:Pe=ot;break r;case 2:if(mt>>>0<2)break r;h=m(Ft+m((Je=m(0),Xn=fe(ot,m(0)),Qe=ot!=ot,(Qe?Je:Xn)/m(mt-1>>>0))));break r;case 4:Pe=m(ot/m(mt+1>>>0)),h=m(Ft+Pe);break r;case 3:break e;default:break r}Pe=m(m(ot*m(.5))/m(mt>>>0)),h=m(m(Pe+Pe)+Ft)}if(a=m(he+Pe),q=m(0),ar=P2(s),qt)h=m(0);else{for(Mr=Y-1|0,Qa=m(ot/m(Mt|0)),he=m(0),W=m(0),u=nt;;){if(b=c[s+556>>2],c[s+560>>2]-b>>2>>>0<=u>>>0)break i;b=c[b+(u<<2)>>2],mt=b+228|0,Hr($+24|0,mt,320),h=m(h-((u|0)==(Mr|0)?Ft:m(0))),Mt=c[b+24>>2];r:{if(Mt&4194304)break r;e:{if((Mt&196608)==131072){if(!ci(b,Ct))break e;if(!P)break r;ot=Gs(b,Ct,ye),kr=ve(s,Ct),_l=ge(b,Ct,Et),I[mt+(c[xi>>2]<<2)>>2]=_l+m(ot+kr);break r}if(bn($+360|0,b,Ct),a=m(a+(c[$+364>>2]==3?Qa:m(-0))),P&&(Mt=mt,mt=c[xi>>2]<<2,I[Mt+mt>>2]=a+I[mt+($+24|0)>>2]),yn($+360|0,b,Ct),a=m(a+(c[$+364>>2]==3?Qa:m(-0))),!gg){a=m(a+m(m(h+m(ge(b,Ct,Et)+Re(b,Ct,Et)))+I[$+104>>2])),q=Ue;break r}if(mt=b+516|0,a=m(a+m(h+m(I[mt+(c[js>>2]<<2)>>2]+m(ge(b,Ct,Et)+Re(b,Ct,Et))))),ar){ot=Al(b),kr=ge(b,0,Et),ot=m(ot+kr),kr=m(m(I[b+520>>2]+m(ge(b,0,Et)+Re(b,0,Et)))-ot),b=he!=he;s:{if(!(b|ot!=ot)){he=fe(he,ot);break s}he=b?ot:he}if(b=W!=W,!(b|kr!=kr)){W=fe(W,kr);break r}W=b?kr:W;break r}if(ot=m(I[mt+(c[Ge>>2]<<2)>>2]+m(ge(b,et,Et)+Re(b,et,Et))),b=q!=q,!(ot!=ot|b)){q=fe(q,ot);break r}q=b?ot:q;break r}if(!P)break r;b=c[xi>>2]<<2,ot=I[b+($+24|0)>>2],Qe=b+mt|0,Je=m(Pe+m(ot+ve(s,Ct))),I[Qe>>2]=Je}if(u=u+1|0,(Y|0)==(u|0))break}h=m(W+he)}if(q=ar?h:q,ot=Ue,!fg){h=Ze(s,et,m(ri+q),Za),u=h!=h,W=m(m(Ne(s,et,k)+ve(s,et))+m(Fe(s,et,k)+_e(s,et)));r:{if(!(u|W!=W)){h=fe(h,W);break r}h=u?W:h}ot=m(h-ri)}h=Ze(s,et,m(ri+(pg?Ue:q)),Za),u=h!=h,W=m(m(Ne(s,et,k)+ve(s,et))+m(Fe(s,et,k)+_e(s,et)));r:{if(!(u|W!=W)){h=fe(h,W);break r}h=u?W:h}if(W=m(h-ri),!(qt|!P))for(;;){if(u=c[s+556>>2],c[s+560>>2]-u>>2>>>0<=nt>>>0)break i;mt=c[u+(nt<<2)>>2],u=c[mt+24>>2];r:{if(u&4194304)break r;if((u&196608)==131072){e:{if(!ci(mt,et)){b=c[or>>2];break e}if(h=Gs(mt,et,Ue),q=ve(s,et),Ft=ge(mt,et,Et),b=c[or>>2],h=m(Ft+m(h+q)),I[(mt+(b<<2)|0)+228>>2]=h,h==h)break r}Qe=mt+(b<<2)|0,Je=m(ve(s,et)+ge(mt,et,Et)),I[Qe+228>>2]=Je;break r}b=u>>>13&7,b||(b=c[s+24>>2]>>>10&7);e:{s:{if((b|0)==5){b=c[s+24>>2]&8?5:1;break s}if((b|0)!=4||(bn($+24|0,mt,et),b=4,c[$+28>>2]==3)||(yn($+360|0,mt,et),c[$+364>>2]==3))break s;b=mt+(c[Ge>>2]<<3)|0,q=I[b+572>>2];n:{a:switch(u=c[b+576>>2],u|0){case 0:case 3:break n;default:break a}if(Ft=I[b+572>>2],!((u|0)!=1|Ft!=Ft)){if(h=ze,q<m(0))break n;break e}if(h=ze,gs&!(q<m(0))|((u|0)!=2|Ft!=Ft))break e}q=I[(mt+(c[js>>2]<<2)|0)+516>>2],h=W,Ft=I[mt+224>>2],Ft==Ft&&(h=m(m(ge(mt,et,Et)+Re(mt,et,Et))+m(ii?q*Ft:q/Ft))),I[$+360>>2]=h,Qe=$,Je=m(q+m(ge(mt,Ct,Et)+Re(mt,Ct,Et))),I[Qe+24>>2]=Je,c[$+356>>2]=1,c[$+352>>2]=1,Wn(mt,Ct,ye,Et,$+356|0,$+24|0),Wn(mt,et,Ue,Et,$+352|0,$+360|0),q=I[$+360>>2],Ft=I[$+24>>2],u=Ct>>>0>1,h=u?q:Ft,q=u?Ft:q,u=(Zi|0)!=0&(c[s+24>>2]&896)!=512,vn(mt,q,h,Wr,!(u&ii|q!=q),(!u|ii)&h==h,Et,qe,1,2,z,tt,dt,Q),h=ze;break e}h=I[(mt+(c[Ge>>2]<<2)|0)+516>>2],q=ge(mt,et,Et),Ft=Re(mt,et,Et),bn($+24|0,mt,et),q=m(ot-m(h+m(q+Ft)));s:{if(c[$+28>>2]!=3||(yn($+360|0,mt,et),c[$+364>>2]!=3))break s;h=m(q*m(.5)),h=m(ze+(Je=m(0),Xn=fe(h,m(0)),Qe=h!=h,Qe?Je:Xn));break e}if(yn($+24|0,mt,et),h=ze,c[$+28>>2]==3)break e;if(bn($+24|0,mt,et),c[$+28>>2]==3){h=m(ze+(Je=m(0),Xn=fe(q,m(0)),Qe=q!=q,Qe?Je:Xn));break e}s:switch(b-1|0){case 1:h=m(ze+m(q*m(.5)));break e;case 0:break e;default:break s}h=m(ze+q)}u=mt+(c[or>>2]<<2)|0,I[u+228>>2]=h+m(ms+I[u+228>>2])}if(nt=nt+1|0,(nt|0)==(Y|0))break}h=m((ei?vd:m(0))+W),u=Ys!=Ys,a=m(qa+a);r:{if(!(u|a!=a)){Ys=fe(Ys,a);break r}Ys=u?a:Ys}if(ms=m(ms+h),u=ei+1|0,nt=Y,!(Yi>>>0>Y>>>0))break}r:{if(!P||!Zi&&!P2(s))break r;he=m(0);e:{s:{if(Ue!=Ue)break s;a=m(Ue-ms);n:switch((c[s+24>>2]>>>7&7)-2|0){case 0:ze=m(ze+m(a*m(.5)));break s;case 2:if(!(Ue>ms))break s;he=m(a/m(u>>>0));break s;case 5:if(Ue>ms){if(ze=m(ze+m(a/m(u<<1>>>0))),u>>>0<2)break s;he=m(a/m(u>>>0));break e}ze=m(ze+m(a*m(.5)));break s;case 4:if(!(Ue>ms)|u>>>0<2)break s;he=m(a/m(ei>>>0));break e;case 1:break n;default:break s}ze=m(ze+a)}if(!u)break r}for(Mt=0,u=0,b=0;;){if(q=m(0),h=m(0),a=m(0),W=m(0),Y=u,Yi>>>0>u>>>0){e:{for(;;){if(b=c[s+556>>2],c[s+560>>2]-b>>2>>>0<=Y>>>0)break i;nt=c[b+(Y<<2)>>2],mt=c[nt+24>>2];s:{if(mt&4194304|(mt&196608)==131072)break s;if(b=Y,c[nt+548>>2]!=(Mt|0))break e;a=I[(nt+(c[Ge>>2]<<2)|0)+516>>2];n:{if(!(a>=m(0)))break n;if(b=h!=h,a=m(a+m(ge(nt,et,Et)+Re(nt,et,Et))),!(b|a!=a)){h=fe(h,a);break n}h=b?a:h}if(b=mt>>>13&7,b||(b=c[s+24>>2]>>>10&7),!(Tt[s+24|0]&8)|(b|0)!=5)break s;a=Al(nt),ot=ge(nt,0,Et),a=m(a+ot),ot=m(m(I[nt+520>>2]+m(ge(nt,0,Et)+Re(nt,0,Et)))-a),b=h!=h,nt=W!=W;n:{if(!(nt|a!=a)){W=fe(W,a);break n}W=nt?a:W}nt=q!=q;n:{if(!(nt|ot!=ot)){q=fe(q,ot);break n}q=nt?ot:q}if(a=m(W+q),!(b|a!=a)){h=fe(h,a);break s}h=b?a:h}if(Y=Y+1|0,(Yi|0)==(Y|0))break}b=Yi}a=h}if(ot=m(ze+(Mt?vd:m(0))),h=m(he+a),ze=m(ot+h),u>>>0<b>>>0)for(Ft=m(ot+W);;){if(Y=c[s+556>>2],c[s+560>>2]-Y>>2>>>0<=u>>>0)break i;nt=c[Y+(u<<2)>>2],Y=c[nt+24>>2];e:{if(Y&4194304|(Y&196608)==131072)break e;Y=Y>>>13&7,Y||(Y=c[s+24>>2]>>>10&7);s:{n:switch(Y-1|0){case 4:if(Tt[s+24|0]&8)break s;case 0:a=ge(nt,et,Et),I[(nt+(c[or>>2]<<2)|0)+228>>2]=ot+a;break e;case 2:a=Re(nt,et,Et),Y=nt+228|0,I[Y+(c[or>>2]<<2)>>2]=m(ze-a)-I[(Y+(c[Ge>>2]<<2)|0)+288>>2];break e;case 1:Y=nt+228|0,I[Y+(c[or>>2]<<2)>>2]=ot+m(m(h-I[(Y+(c[Ge>>2]<<2)|0)+288>>2])*m(.5));break e;case 3:break n;default:break e}a=ge(nt,et,Et),I[(nt+(c[or>>2]<<2)|0)+228>>2]=ot+a,mt=nt+(c[Ge>>2]<<3)|0,a=I[mt+572>>2];n:{a:switch(Y=c[mt+576>>2],Y|0){case 0:case 3:break n;default:break a}if(W=I[mt+572>>2],!((Y|0)!=1|W!=W)){if(a<m(0))break n;break e}if(gs&!(a<m(0))|((Y|0)!=2|W!=W))break e}n:{if(Ct>>>0>=2){q=h,a=I[nt+516>>2],W=m(a+m(ge(nt,Ct,Et)+Re(nt,Ct,Et)));break n}q=m(I[nt+520>>2]+m(ge(nt,et,Et)+Re(nt,et,Et))),a=I[nt+516>>2],W=h}n:{a:{if(!(W!=W|a!=a)){if(m(Xe(m(W-a)))<m(9999999747378752e-20))break a;break n}if(W==W|a==a)break n}if(a=I[nt+520>>2],Y=a!=a,!(Y|q!=q)){if(!(m(Xe(m(q-a)))<m(9999999747378752e-20)))break n;break e}if(q==q)break n;if(Y)break e}vn(nt,W,q,Wr,1,1,Et,qe,1,3,z,tt,dt,Q);break e}Qe=nt,Je=m(m(Ft-Al(nt))+Gs(nt,0,Ue)),I[Qe+232>>2]=Je}if(u=u+1|0,(b|0)==(u|0))break}if(Y=(Mt|0)!=(ei|0),Mt=Mt+1|0,u=b,!Y)break}}mt=s+516|0,a=Ze(s,2,gd,k),u=a!=a,h=m(m(Ne(s,2,k)+ve(s,2))+m(Fe(s,2,k)+_e(s,2)));r:{if(!(u|h!=h)){a=fe(a,h);break r}a=u?h:a}I[mt>>2]=a,a=Ze(s,0,md,S),u=a!=a,h=m(m(Ne(s,0,k)+ve(s,0))+m(Fe(s,0,k)+_e(s,0)));r:{if(!(u|h!=h)){a=fe(a,h);break r}a=u?h:a}I[s+520>>2]=a;r:{e:{s:{if(ps&&(u=c[s+24>>2]>>>20&3,(u|0)==2|(ps|0)!=2))break s;if(a=Ze(s,Ct,Ys,Ks),u=a!=a,h=m(m(Ne(s,Ct,k)+ve(s,Ct))+m(Fe(s,Ct,k)+_e(s,Ct))),!(u|h!=h)){a=fe(a,h);break e}a=u?h:a;break e}if((ps|0)!=2|(u|0)!=2)break r;h=m(Xi+ye),u=h!=h,a=Ze(s,Ct,Ys,Ks);s:{if(!(u|a!=a)){a=ld(h,a);break s}a=u?a:h}if(u=a!=a,!(u|Xi!=Xi)){a=fe(a,Xi);break e}a=u?Xi:a}I[mt+(c[js>>2]<<2)>>2]=a}r:{e:{s:{if(Vt&&(b=(Vt|0)!=2,u=c[s+24>>2]>>>20&3,b|(u|0)==2))break s;if(a=Ze(s,et,m(ri+ms),Za),u=a!=a,h=m(m(Ne(s,et,k)+ve(s,et))+m(Fe(s,et,k)+_e(s,et))),!(u|h!=h)){a=fe(a,h);break e}a=u?h:a;break e}if(b|(u|0)!=2)break r;h=m(ri+Ue),u=h!=h,a=Ze(s,et,m(ri+ms),Za);s:{if(!(u|a!=a)){a=ld(h,a);break s}a=u?a:h}if(u=a!=a,!(u|ri!=ri)){a=fe(a,ri);break e}a=u?ri:a}I[mt+(c[Ge>>2]<<2)>>2]=a}r:{if(!P)break r;if((c[s+24>>2]&786432)==524288)for(b=Yi>>>0<=1?1:Yi,P=c[s+556>>2],nt=c[s+560>>2]-P>>2,u=0;Y=0,Y=u>>>0<nt>>>0?c[P+(u<<2)>>2]:Y,(c[Y+24>>2]&196608)!=131072&&(Y=Y+228|0,Mt=Y+(c[or>>2]<<2)|0,qt=c[Ge>>2]<<2,I[Mt>>2]=m(I[qt+mt>>2]-I[Mt>>2])-I[(Y+qt|0)+288>>2]),u=u+1|0,(b|0)!=(u|0););if(b=c[s+556>>2],P=c[s+560>>2],(b|0)!=(P|0))for(Mt=((Ct>>>0>1?ps:y)|0)!=0;;){y=c[b>>2];e:{if((c[y+24>>2]&4390912)!=131072)break e;W=Et,ye=qe,Tt[c[s+568>>2]+12|0]&2&&(ye=I[s+520>>2],W=I[s+516>>2]),u=c[s+24>>2]>>>2&3;s:{n:{if((Wr|0)==2){nt=0,Y=3;a:switch(u-2|0){case 0:break s;case 1:break a;default:break n}Y=2;break s}if(nt=0,u>>>0<=1)break n;Y=u;break s}Y=u,nt=Vs}S=m(ge(y,2,W)+Re(y,2,W)),k=ge(y,0,W),q=Re(y,0,W),a=I[y+572>>2];s:{n:{a:switch(u=c[y+576>>2],u|0){case 0:case 3:break n;default:break a}h=I[y+572>>2];a:{if(!((u|0)!=1|h!=h)){if(h=a,!(a<m(0)))break a;break n}o:{if(!((u|0)!=2|h!=h)){if(W!=W|a<m(0))break n;break o}h=m(zt);l:switch(u-1|0){case 1:break o;case 0:break l;default:break a}h=a;break a}h=m(m(W*a)*m(.009999999776482582))}h=m(S+h);break s}if(h=m(zt),!ci(y,2)||!wl(y,2))break s;if(a=Ze(y,2,m(m(I[s+516>>2]-m(ve(s,2)+_e(s,2)))-m(Gs(y,2,W)+za(y,2,W))),W),u=a!=a,h=m(m(Ne(y,2,W)+ve(y,2))+m(Fe(y,2,W)+_e(y,2))),!(u|h!=h)){h=fe(a,h);break s}h=u?h:a}q=m(k+q);s:{n:{a:{o:{l:{c:{h:{qt=h!=h,k=I[y+580>>2];f:{d:{p:switch(u=c[y+584>>2],u|0){case 0:case 3:break d;default:break p}a=I[y+580>>2];p:{if(!((u|0)!=1|a!=a)){if(a=k,!(a<m(0)))break p;break d}v:{if(!((u|0)!=2|a!=a)){if(ye!=ye|k<m(0))break d;break v}a=m(zt);y:switch(u-1|0){case 1:break v;case 0:break y;default:break p}a=k;break p}a=m(m(ye*k)*m(.009999999776482582))}a=m(q+a);break f}d:{if(ci(y,0)&&wl(y,0))break d;if(a=m(zt),h==h)break h;break a}if(a=Ze(y,0,m(m(I[s+520>>2]-m(ve(s,0)+_e(s,0)))-m(Gs(y,0,ye)+za(y,0,ye))),ye),u=a!=a,k=m(m(Ne(y,0,W)+ve(y,0))+m(Fe(y,0,W)+_e(y,0))),!(u|k!=k)){a=fe(a,k);break f}a=u?k:a}if((qt|0)==(a!=a|0)||(ot=I[y+224>>2],ot!=ot))break l;if(h!=h){h=m(m(m(a-q)*ot)+S);break l}if(a==a)break l;break c}if(ot=I[y+224>>2],ot!=ot)break o}a=m(q+m(m(h-S)/ot))}if(h!=h)break a;if(a==a)break s}u=0;break n}u=1}qt=W>m(0),ei=u&Mt&Y>>>0<2,h=ei&&qt?W:h,u=u^1,vn(y,h,a,Wr,ei&&qt?2:u,a==a,h,a,0,6,z,tt,dt,Q),h=m(I[y+516>>2]+rg(y,2,W)),a=m(I[y+520>>2]+rg(y,0,W))}vn(y,h,a,Wr,1,1,h,a,1,1,z,tt,dt,Q);s:{n:{a:{if(!wl(y,Y)||ci(y,Y))break a;u=c[(Y<<2)+4320>>2]<<2,a=Y>>>0<2?ye:W,a=m(m(m(m(I[u+mt>>2]-I[(u+y|0)+516>>2])-_e(s,Y))-Re(y,Y,a))-za(y,Y,a));break n}if(!(ci(y,Y)|(c[s+24>>2]&112)!=16)){u=c[(Y<<2)+4320>>2]<<2,a=m(m(I[u+mt>>2]-I[(u+y|0)+516>>2])*m(.5));break n}if(!(ci(y,Y)|(c[s+24>>2]&112)!=32)){u=c[(Y<<2)+4320>>2]<<2,a=m(I[u+mt>>2]-I[(u+y|0)+516>>2]);break n}if(!(Tt[c[s+568>>2]+12|0]&2)||!ci(y,Y))break s;a=I[mt+(c[(Y<<2)+4320>>2]<<2)>>2],a=m(m(Gs(y,Y,a)+ve(s,Y))+ge(y,Y,a))}I[(y+(c[(Y<<2)+4288>>2]<<2)|0)+228>>2]=a}s:{n:{if(!wl(y,nt)||ci(y,nt))break n;u=c[(nt<<2)+4320>>2]<<2,a=Y>>>0<2?W:ye,a=m(m(m(m(I[u+mt>>2]-I[(u+y|0)+516>>2])-_e(s,nt))-Re(y,nt,a))-za(y,nt,a));break s}n:{if(ci(y,nt)||(u=c[y+24>>2]>>>13&7,u||(u=c[s+24>>2]>>>10&7),(u|0)!=2))break n;u=c[(nt<<2)+4320>>2]<<2,a=m(m(I[u+mt>>2]-I[(u+y|0)+516>>2])*m(.5));break s}n:{if(ci(y,nt))break n;Y=c[y+24>>2]>>>13&7,u=c[s+24>>2],Y=Y||u>>>10&7;a:{if((Y|0)==5){if((u&786432)==524288)break a;break n}if(((Y|0)==3|0)==((u&786432)==524288|0))break n}u=c[(nt<<2)+4320>>2]<<2,a=m(I[u+mt>>2]-I[(u+y|0)+516>>2]);break s}if(!(Tt[c[s+568>>2]+12|0]&2)||!ci(y,nt))break e;a=I[mt+(c[(nt<<2)+4320>>2]<<2)>>2],a=m(m(Gs(y,nt,a)+ve(s,nt))+ge(y,nt,a))}I[(y+(c[(nt<<2)+4288>>2]<<2)|0)+228>>2]=a}if(b=b+4|0,(P|0)==(b|0))break}if(!((et|Ct)&1))break r;for(b=et&1,P=Ct&1,z=Yi>>>0<=1?1:Yi,tt=(et<<2)+4304|0,dt=(Ct<<2)+4304|0,Q=c[s+556>>2],et=c[s+560>>2]-Q>>2,s=0;;){if((s|0)==(et|0))break i;u=c[Q+(s<<2)>>2];e:{if(Tt[u+26|0]&64||(P&&(y=u+228|0,Y=c[js>>2]<<2,I[y+(c[dt>>2]<<2)>>2]=m(I[Y+mt>>2]-I[(y+Y|0)+288>>2])-I[y+(c[xi>>2]<<2)>>2]),!b))break e;u=u+228|0,y=c[Ge>>2]<<2,I[u+(c[tt>>2]<<2)>>2]=m(I[y+mt>>2]-I[(u+y|0)+288>>2])-I[u+(c[or>>2]<<2)>>2]}if(s=s+1|0,(z|0)==(s|0))break}}if(!Nr)break t;Ar(Nr);break t}Us(),pe()}St=$+384|0}function v2(){var s=0,a=0;Vn(7032,7033,7034,0,4352,17,4355,0,4355,0,2529,4357,18),s=ht(8),c[s>>2]=8,c[s+4>>2]=1,_t(7032,2922,6,4368,4392,19,s|0,1),Vn(7036,7037,7038,7032,4352,20,4352,21,4352,22,2001,4357,23),s=ht(4),c[s>>2]=24,_t(7036,2359,2,4400,4408,25,s|0,0),us(7032,1398,2,4412,4420,26,27),us(7032,3027,3,4500,4512,28,29),Vn(7056,7057,7058,0,4352,30,4355,0,4355,0,2545,4357,31),s=ht(8),c[s>>2]=8,c[s+4>>2]=1,_t(7056,3293,2,4520,4408,32,s|0,1),Vn(7059,7060,7061,7056,4352,33,4352,34,4352,35,2024,4357,36),s=ht(4),c[s>>2]=37,_t(7059,2359,2,4528,4408,38,s|0,0),us(7056,1398,2,4536,4420,39,40),us(7056,3027,3,4500,4512,28,41),Vn(7062,7063,7064,0,4352,42,4355,0,4355,0,2861,4357,43),p2(7062,1,4584,4352,44,45),us(7062,2915,1,4584,4352,44,45),us(7062,1129,2,4588,4408,46,47),s=ht(8),c[s+4>>2]=0,c[s>>2]=48,_t(7062,3234,4,4608,4624,49,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=50,_t(7062,1981,3,4632,4644,51,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=52,_t(7062,1952,3,4652,4664,53,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=54,_t(7062,3389,3,4672,4664,55,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=56,_t(7062,1800,3,4652,4664,53,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=57,_t(7062,3264,3,4684,4512,58,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=59,_t(7062,1926,2,4696,4420,60,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=61,_t(7062,3399,2,4704,4420,62,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=63,_t(7062,1785,2,4696,4420,60,s|0,0),Jh(7065,1271,4712,64,4357,65),Yn(1732,0),Yn(1612,8),Yn(2145,16),Yn(2455,24),Yn(2561,32),Yn(1618,40),Qh(7065),Jh(7035,2898,4712,66,4357,67),z2(2561,0),z2(1618,8),Qh(7035),Jh(7066,2909,4712,68,4357,69),s=ht(4),c[s>>2]=8,a=ht(4),c[a>>2]=8,bl(7066,2903,7098,4714,70,s|0,7098,4718,71,a|0),s=ht(4),c[s>>2]=0,a=ht(4),c[a>>2]=0,bl(7066,1607,7091,4420,72,s|0,7091,4664,73,a|0),Qh(7066),Vn(7067,7068,7069,0,4352,74,4355,0,4355,0,3022,4357,75),p2(7067,1,4724,4352,76,77),us(7067,1593,1,4724,4352,76,77),us(7067,2851,2,4728,4420,78,79),us(7067,1129,2,4736,4408,80,81),s=ht(8),c[s+4>>2]=0,c[s>>2]=82,_t(7067,1753,2,4736,4408,83,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=84,_t(7067,3005,3,4744,4664,85,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=86,_t(7067,2930,3,4756,4664,87,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=88,_t(7067,2335,4,4768,4784,89,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=90,_t(7067,1485,4,4768,4784,89,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=91,_t(7067,1356,3,4756,4664,87,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=92,_t(7067,1818,3,4756,4664,87,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=93,_t(7067,2872,3,4756,4664,87,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=94,_t(7067,2379,3,4756,4664,87,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=95,_t(7067,2164,3,4756,4664,87,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=96,_t(7067,1320,3,4756,4664,87,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=97,_t(7067,2413,4,4768,4784,89,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=98,_t(7067,1504,4,4768,4784,89,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=99,_t(7067,2236,3,4756,4664,87,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=100,_t(7067,1220,3,4756,4664,87,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=101,_t(7067,1137,3,4756,4664,87,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=102,_t(7067,1159,3,4792,4718,103,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=104,_t(7067,1846,3,4792,4718,103,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=105,_t(7067,1465,3,4792,4718,103,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=106,_t(7067,2219,2,4736,4408,83,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=107,_t(7067,1196,3,4792,4718,103,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=108,_t(7067,2501,3,4792,4718,103,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=109,_t(7067,2591,3,4792,4718,103,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=110,_t(7067,1540,3,4792,4718,103,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=111,_t(7067,2250,2,4736,4408,83,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=112,_t(7067,1651,3,4792,4718,103,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=113,_t(7067,1428,3,4792,4718,103,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=114,_t(7067,2205,2,4736,4408,83,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=115,_t(7067,2609,3,4792,4718,103,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=116,_t(7067,1556,3,4792,4718,103,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=117,_t(7067,1671,3,4792,4718,103,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=118,_t(7067,1445,3,4792,4718,103,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=119,_t(7067,2567,3,4792,4718,103,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=120,_t(7067,1521,3,4792,4718,103,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=121,_t(7067,1625,3,4792,4718,103,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=122,_t(7067,1408,3,4792,4718,103,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=123,_t(7067,2305,3,4792,4718,103,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=124,_t(7067,2093,4,4768,4784,89,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=125,_t(7067,2719,4,4768,4784,89,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=126,_t(7067,1575,4,4768,4784,89,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=127,_t(7067,2188,4,4768,4784,89,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=128,_t(7067,2946,2,4804,4420,129,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=130,_t(7067,2347,3,4812,4512,131,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=132,_t(7067,1372,2,4804,4420,129,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=133,_t(7067,1832,2,4804,4420,129,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=134,_t(7067,2885,2,4804,4420,129,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=135,_t(7067,2396,2,4804,4420,129,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=136,_t(7067,2176,2,4804,4420,129,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=137,_t(7067,1338,2,4804,4420,129,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=138,_t(7067,2423,3,4812,4512,131,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=139,_t(7067,1859,2,4824,4420,140,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=141,_t(7067,1208,2,4832,4714,142,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=143,_t(7067,2515,2,4832,4714,142,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=144,_t(7067,2600,2,4824,4420,140,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=145,_t(7067,1661,2,4824,4420,140,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=146,_t(7067,2621,2,4824,4420,140,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=147,_t(7067,1684,2,4824,4420,140,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=148,_t(7067,2579,2,4824,4420,140,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=149,_t(7067,1638,2,4824,4420,140,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=150,_t(7067,2320,2,4832,4714,142,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=151,_t(7067,2103,3,4840,4852,152,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=153,_t(7067,1232,2,4804,4420,129,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=154,_t(7067,1148,2,4804,4420,129,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=155,_t(7067,2730,3,4812,4512,131,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=156,_t(7067,2195,3,4860,4872,157,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=158,_t(7067,3034,4,4880,4624,159,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=160,_t(7067,3055,3,4896,4664,161,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=162,_t(7067,1293,2,4908,4420,163,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=164,_t(7067,1388,2,4916,4420,165,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=166,_t(7067,3046,3,4924,4512,167,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=168,_t(7067,2962,2,4936,4420,169,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=170,_t(7067,2982,3,4944,4664,171,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=172,_t(7067,3357,3,4956,4664,173,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=174,_t(7067,3355,2,4736,4408,83,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=175,_t(7067,3374,3,4968,4664,176,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=177,_t(7067,3372,2,4736,4408,83,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=178,_t(7067,1119,2,4736,4408,83,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=179,_t(7067,1111,2,4980,4420,180,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=181,_t(7067,1244,5,4992,5012,182,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=183,_t(7067,1737,2,4832,4714,142,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=184,_t(7067,1715,2,4832,4714,142,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=185,_t(7067,2149,2,4832,4714,142,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=186,_t(7067,2462,2,4832,4714,142,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=187,_t(7067,2633,2,4832,4714,142,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=188,_t(7067,1697,2,4832,4714,142,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=189,_t(7067,1260,2,5020,4420,190,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=191,_t(7067,2433,3,4840,4852,152,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=192,_t(7067,2113,3,4840,4852,152,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=193,_t(7067,2741,3,4840,4852,152,s|0,0)}function Dk(s,a,h,u,y,b){s=s|0,a=+a,h=h|0,u=u|0,y=y|0,b=b|0;var k=0,S=0,P=0,z=0,tt=0,dt=0,Q=0,et=0,$=0,W=0,Y=0,q=0,nt=0,ot=0,mt=0,Et=0,Ct=0,Mt=0,Ft=0;Q=St-560|0,St=Q,c[Q+44>>2]=0,Er(+a),k=te(1)|0,te(0)|0;t:{if((k|0)<0){nt=1,Mt=1177,a=-a,Er(+a),k=te(1)|0,te(0)|0;break t}if(y&2048){nt=1,Mt=1180;break t}nt=y&1,Mt=nt?1183:1178,Ft=!nt}t:{if((k&2146435072)==2146435072){k=nt+3|0,Tr(s,32,h,k,y&-65537),pr(s,Mt,nt),u=b&32,pr(s,a!=a?u?2451:3459:u?2868:3463,3),Tr(s,32,h,k,y^8192),et=(h|0)<(k|0)?k:h;break t}mt=Q+16|0;i:{r:{e:{if(a=M2(a,Q+44|0),a=a+a,a!=0){if(k=c[Q+44>>2],c[Q+44>>2]=k-1,Et=b|32,(Et|0)!=97)break e;break i}if(Et=b|32,(Et|0)==97)break i;tt=c[Q+44>>2],dt=(u|0)<0?6:u;break r}tt=k-29|0,c[Q+44>>2]=tt,a=a*268435456,dt=(u|0)<0?6:u}for(Y=(Q+48|0)+((tt|0)>=0?288:0)|0,S=Y;a<4294967296&a>=0?u=~~a>>>0:u=0,c[S>>2]=u,S=S+4|0,a=(a-+(u>>>0))*1e9,a!=0;);r:{if((tt|0)<=0){u=tt,k=S,P=Y;break r}for(P=Y,u=tt;;){$=(u|0)>=29?29:u,k=S-4|0;e:{if(P>>>0>k>>>0)break e;for(u=0;z=c[k>>2],Ct=u,u=$&31,($&63)>>>0>=32?(et=z<<u,u=0):(et=(1<<u)-1&z>>>32-u,u=z<<u),Ct=Ct+u|0,z=et+W|0,u=k2(Ct,u>>>0>Ct>>>0?z+1|0:z,1e9),z=od(u,Gr,-1e9,0)+Ct|0,c[k>>2]=z,k=k-4|0,P>>>0<=k>>>0;);if(!u)break e;P=P-4|0,c[P>>2]=u}for(;k=S,P>>>0<k>>>0&&(S=k-4|0,!c[S>>2]););if(u=c[Q+44>>2]-$|0,c[Q+44>>2]=u,S=k,!((u|0)>0))break}}if((u|0)<0)for(ot=((dt+25>>>0)/9|0)+1|0,W=(Et|0)==102;;){u=0-u|0,et=(u|0)>=9?9:u;r:{if(k>>>0<=P>>>0){S=c[P>>2];break r}for($=1e9>>>et|0,z=-1<<et^-1,u=0,S=P;Ct=u,u=c[S>>2],c[S>>2]=Ct+(u>>>et|0),u=Ke($,u&z),S=S+4|0,S>>>0<k>>>0;);if(S=c[P>>2],!u)break r;c[k>>2]=u,k=k+4|0}if(u=et+c[Q+44>>2]|0,c[Q+44>>2]=u,P=(!S<<2)+P|0,S=W?Y:P,k=k-S>>2>(ot|0)?S+(ot<<2)|0:k,!((u|0)<0))break}u=0;r:{if(k>>>0<=P>>>0||(u=Ke(Y-P>>2,9),S=10,z=c[P>>2],z>>>0<10))break r;for(;u=u+1|0,S=Ke(S,10),z>>>0>=S>>>0;);}if(S=(dt-((Et|0)!=102?u:0)|0)-((Et|0)==103&(dt|0)!=0)|0,(S|0)<(Ke(k-Y>>2,9)-9|0)){if($=S+9216|0,z=($|0)/9|0,tt=((((tt|0)<0?4:292)+Q|0)+(z<<2)|0)-4048|0,S=10,et=$+Ke(z,-9)|0,(et|0)<=7)for(;S=Ke(S,10),et=et+1|0,(et|0)!=8;);$=c[tt>>2],ot=($>>>0)/(S>>>0)|0,W=Ke(ot,S),z=tt+4|0;r:{if(($|0)==(W|0)&(z|0)==(k|0))break r;$=$-W|0;e:{if(!(ot&1)&&(a=9007199254740992,!(pt[tt-4|0]&1)|((S|0)!=1e9|P>>>0>=tt>>>0)))break e;a=9007199254740994}if(q=(k|0)==(z|0)?1:1.5,z=S>>>1|0,q=z>>>0>$>>>0?.5:(z|0)==($|0)?q:1.5,Tt[Mt|0]!=45|Ft||(q=-q,a=-a),c[tt>>2]=W,a+q==a)break r;if(u=S+W|0,c[tt>>2]=u,u>>>0>=1e9)for(;c[tt>>2]=0,tt=tt-4|0,tt>>>0<P>>>0&&(P=P-4|0,c[P>>2]=0),u=c[tt>>2]+1|0,c[tt>>2]=u,u>>>0>999999999;);if(u=Ke(Y-P>>2,9),S=10,z=c[P>>2],z>>>0<10)break r;for(;u=u+1|0,S=Ke(S,10),z>>>0>=S>>>0;);}S=tt+4|0,k=k>>>0>S>>>0?S:k}for(;z=k,$=k>>>0<=P>>>0,!$&&(k=z-4|0,!c[k>>2]););r:{if((Et|0)!=103){tt=y&8;break r}if(S=dt||1,k=(S|0)>(u|0)&(u|0)>-5,dt=(k?u^-1:-1)+S|0,b=(k?-1:-2)+b|0,tt=y&8,tt)break r;k=-9;e:{if($||(tt=c[z-4>>2],!tt)||(et=10,k=0,(tt>>>0)%10|0))break e;for(;S=k,k=k+1|0,et=Ke(et,10),!((tt>>>0)%(et>>>0)|0););k=S^-1}if(S=Ke(z-Y>>2,9),(b&-33)==70){tt=0,k=(k+S|0)-9|0,k=(k|0)>0?k:0,dt=(k|0)>(dt|0)?dt:k;break r}tt=0,k=((u+S|0)+k|0)-9|0,k=(k|0)>0?k:0,dt=(k|0)>(dt|0)?dt:k}if(et=-1,$=tt|dt,(($?2147483645:2147483646)|0)<(dt|0))break t;W=((($|0)!=0)+dt|0)+1|0,S=b&-33;r:{if((S|0)==70){if((W^2147483647)<(u|0))break t;k=(u|0)>0?u:0;break r}if(k=u>>31,k=jn((k^u)-k|0,0,mt),(mt-k|0)<=1)for(;k=k-1|0,pt[k|0]=48,(mt-k|0)<2;);if(ot=k-2|0,pt[ot|0]=b,pt[k-1|0]=(u|0)<0?45:43,k=mt-ot|0,(k|0)>(W^2147483647))break t}if(u=k+W|0,(u|0)>(nt^2147483647))break t;W=u+nt|0,Tr(s,32,h,W,y),pr(s,Mt,nt),Tr(s,48,h,W,y^65536);r:{e:{s:{if((S|0)==70){for(b=Q+16|0,u=b|8,tt=b|9,S=P>>>0>Y>>>0?Y:P,P=S;;){k=jn(c[P>>2],0,tt);n:{if((S|0)!=(P|0)){if(Q+16>>>0>=k>>>0)break n;for(;k=k-1|0,pt[k|0]=48,Q+16>>>0<k>>>0;);break n}if((k|0)!=(tt|0))break n;pt[Q+24|0]=48,k=u}if(pr(s,k,tt-k|0),P=P+4|0,!(Y>>>0>=P>>>0))break}if($&&pr(s,4275,1),(dt|0)<=0|P>>>0>=z>>>0)break s;for(;;){if(k=jn(c[P>>2],0,tt),k>>>0>Q+16>>>0)for(;k=k-1|0,pt[k|0]=48,Q+16>>>0<k>>>0;);if(pr(s,k,(dt|0)>=9?9:dt),k=dt-9|0,P=P+4|0,z>>>0<=P>>>0)break e;if(u=(dt|0)>9,dt=k,!u)break}break e}n:{if((dt|0)<0)break n;for(Y=P>>>0<z>>>0?z:P+4|0,b=Q+16|0,u=b|8,z=b|9,S=P;;){k=jn(c[S>>2],0,z),(z|0)==(k|0)&&(pt[Q+24|0]=48,k=u);a:{if((S|0)!=(P|0)){if(Q+16>>>0>=k>>>0)break a;for(;k=k-1|0,pt[k|0]=48,Q+16>>>0<k>>>0;);break a}if(pr(s,k,1),k=k+1|0,!(tt|dt))break a;pr(s,4275,1)}if(b=z-k|0,pr(s,k,(b|0)>(dt|0)?dt:b),dt=dt-b|0,S=S+4|0,Y>>>0<=S>>>0)break n;if(!((dt|0)>=0))break}}Tr(s,48,dt+18|0,18,0),pr(s,ot,mt-ot|0);break r}k=dt}Tr(s,48,k+9|0,9,0)}Tr(s,32,h,W,y^8192),et=(h|0)<(W|0)?W:h;break t}tt=(b<<26>>31&9)+Mt|0;i:{if(u>>>0>11)break i;for(k=12-u|0,q=16;q=q*16,k=k-1|0,!!k;);if(Tt[tt|0]==45){a=-(q+(-a-q));break i}a=a+q-q}for(Y=nt|2,P=b&32,S=c[Q+44>>2],k=S>>31,k=jn((k^S)-k|0,0,mt),(mt|0)==(k|0)&&(pt[Q+15|0]=48,k=Q+15|0),dt=k-2|0,pt[dt|0]=b+15,pt[k-1|0]=(S|0)<0?45:43,k=y&8,S=Q+16|0;b=S,Xe(a)<2147483648?z=~~a:z=-2147483648,pt[S|0]=P|Tt[z+5504|0],a=(a-+(z|0))*16,S=b+1|0,!(k|(u|0)>0)&a==0|(S-(Q+16|0)|0)!=1||(pt[b+1|0]=46,S=b+2|0),a!=0;);if(et=-1,k=mt-dt|0,b=k+Y|0,(2147483645-b|0)<(u|0))break t;i:{r:{if(!u||(P=S-(Q+16|0)|0,(P-2|0)>=(u|0)))break r;u=u+2|0;break i}P=S-(Q+16|0)|0,u=P}b=u+b|0,Tr(s,32,h,b,y),pr(s,tt,Y),Tr(s,48,h,b,y^65536),pr(s,Q+16|0,P),Tr(s,48,u-P|0,0,0),pr(s,dt,k),Tr(s,32,h,b,y^8192),et=(h|0)<(b|0)?b:h}return St=Q+560|0,et|0}function y2(s,a,h,u,y,b,k){var S=0,P=0,z=0,tt=0,dt=0,Q=0,et=0,$=0,W=0,Y=0,q=0,nt=0,ot=0,mt=0,Et=0,Ct=0,Mt=0,Ft=0,Vt=0,qt=0;z=St-80|0,St=z,c[z+76>>2]=a,Ft=z+55|0,ot=z+56|0;t:{i:{r:{e:{s:for(;;){if(tt=a,(W^2147483647)<(S|0))break e;W=S+W|0;n:{a:{o:{if(S=tt,P=Tt[S|0],P)for(;;){l:{a=P&255;c:{if(!a){a=S;break c}if((a|0)!=37)break l;for(P=S;;){if(Tt[P+1|0]!=37){a=P;break c}if(S=S+1|0,dt=Tt[P+2|0],a=P+2|0,P=a,(dt|0)!=37)break}}if(S=S-tt|0,Mt=W^2147483647,(S|0)>(Mt|0))break e;if(s&&pr(s,tt,S),S)continue s;c[z+76>>2]=a,S=a+1|0,q=-1,P=pt[a+1|0],!Rl(P)|Tt[a+2|0]!=36||(q=P-48|0,mt=1,S=a+3|0),c[z+76>>2]=S,$=0,P=pt[S|0],a=P-32|0;c:{if(a>>>0>31){dt=S;break c}if(dt=S,a=1<<a,!(a&75913))break c;for(;;){if(dt=S+1|0,c[z+76>>2]=dt,$=a|$,P=pt[S+1|0],a=P-32|0,a>>>0>=32)break c;if(S=dt,a=1<<a,!(a&75913))break}}c:{if((P|0)==42){a=pt[dt+1|0];h:{if(!(!Rl(a)|Tt[dt+2|0]!=36)){c[((a<<2)+y|0)-192>>2]=10,P=dt+3|0,mt=1,Y=c[((pt[dt+1|0]<<3)+u|0)-384>>2];break h}if(mt)break o;if(P=dt+1|0,!s){c[z+76>>2]=P,mt=0,Y=0;break c}a=c[h>>2],c[h>>2]=a+4,mt=0,Y=c[a>>2]}if(c[z+76>>2]=P,(Y|0)>=0)break c;Y=0-Y|0,$=$|8192;break c}if(Y=G2(z+76|0),(Y|0)<0)break e;P=c[z+76>>2]}S=0,et=-1;c:{if(Tt[P|0]!=46){a=P,nt=0;break c}if(Tt[P+1|0]==42){a=pt[P+2|0];h:{if(!(!Rl(a)|Tt[P+3|0]!=36)){c[((a<<2)+y|0)-192>>2]=10,a=P+4|0,et=c[((pt[P+2|0]<<3)+u|0)-384>>2];break h}if(mt)break o;if(a=P+2|0,et=0,!s)break h;P=c[h>>2],c[h>>2]=P+4,et=c[P>>2]}c[z+76>>2]=a,nt=(et^-1)>>>31|0;break c}c[z+76>>2]=P+1,et=G2(z+76|0),a=c[z+76>>2],nt=1}for(;;){if(Q=S,dt=28,Et=a,S=pt[a|0],S-123>>>0<4294967238)break r;if(a=Et+1|0,S=Tt[(S+Ke(Q,58)|0)+4975|0],!(S-1>>>0<8))break}c[z+76>>2]=a;c:{h:{if((S|0)!=27){if(!S)break r;if((q|0)>=0){c[(q<<2)+y>>2]=S,S=(q<<3)+u|0,P=c[S+4>>2],c[z+64>>2]=c[S>>2],c[z+68>>2]=P;break h}if(!s)break n;_2(z- -64|0,S,h,k);break c}if((q|0)>=0)break r}if(S=0,!s)continue s}P=$&-65537,$=$&8192?P:$,q=0,Ct=1167,dt=ot;c:{h:{f:{d:{p:{v:{y:{u:{g:{b:{m:{T:{k:{E:{w:{A:switch(S=pt[Et|0],S=Q&&(S&15)==3?S&-33:S,S-88|0){case 11:break c;case 9:case 13:case 14:case 15:break h;case 27:break y;case 12:case 17:break b;case 23:break m;case 0:case 32:break T;case 24:break k;case 22:break E;case 29:break w;case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 10:case 16:case 18:case 19:case 20:case 21:case 25:case 26:case 28:case 30:case 31:break a;default:break A}A:switch(S-65|0){case 0:case 4:case 5:case 6:break h;case 2:break p;case 1:case 3:break a;default:break A}if((S|0)==83)break v;break a}P=c[z+64>>2],Q=c[z+68>>2],S=1167;break g}S=0;E:switch(Q&255){case 0:c[c[z+64>>2]>>2]=W;continue s;case 1:c[c[z+64>>2]>>2]=W;continue s;case 2:tt=c[z+64>>2],c[tt>>2]=W,c[tt+4>>2]=W>>31;continue s;case 3:Vi[c[z+64>>2]>>1]=W;continue s;case 4:pt[c[z+64>>2]]=W;continue s;case 6:c[c[z+64>>2]>>2]=W;continue s;case 7:break E;default:continue s}tt=c[z+64>>2],c[tt>>2]=W,c[tt+4>>2]=W>>31;continue s}et=et>>>0<=8?8:et,$=$|8,S=120}if(tt=ot,P=c[z+64>>2],Q=c[z+68>>2],P|Q)for(Vt=S&32;tt=tt-1|0,pt[tt|0]=Vt|Tt[(P&15)+5504|0],qt=!Q&P>>>0>15|(Q|0)!=0,Et=Q,Q=Q>>>4|0,P=(Et&15)<<28|P>>>4,!!qt;);if(!($&8)|!(c[z+64>>2]|c[z+68>>2]))break u;Ct=(S>>>4|0)+1167|0,q=2;break u}if(S=ot,tt=c[z+68>>2],Q=tt,P=c[z+64>>2],tt|P)for(;S=S-1|0,pt[S|0]=P&7|48,Et=!Q&P>>>0>7|(Q|0)!=0,tt=Q,Q=tt>>>3|0,P=(tt&7)<<29|P>>>3,!!Et;);if(tt=S,!($&8))break u;S=ot-tt|0,et=(S|0)<(et|0)?et:S+1|0;break u}if(P=c[z+64>>2],S=c[z+68>>2],Q=S,(S|0)<0){tt=0-(Q+((P|0)!=0)|0)|0,Q=tt,P=0-P|0,c[z+64>>2]=P,c[z+68>>2]=tt,q=1,S=1167;break g}if($&2048){q=1,S=1168;break g}q=$&1,S=q?1169:1167}Ct=S,tt=jn(P,Q,ot)}if((et|0)<0&&nt)break e;if($=nt?$&-65537:$,S=c[z+64>>2],P=c[z+68>>2],!((S|P)!=0|et)){tt=ot,et=0;break a}S=!(S|P)+(ot-tt|0)|0,et=(S|0)<(et|0)?et:S;break a}$=0,nt=et>>>0>=2147483647?2147483647:et,Q=nt,dt=(Q|0)!=0;y:{u:{S=c[z+64>>2],tt=S||4277,S=tt;g:{b:{m:{if(!(S&3)|!Q)break m;for(;;){if($=Tt[S|0],!$)break b;if(Q=Q-1|0,dt=(Q|0)!=0,S=S+1|0,!(S&3))break m;if(!Q)break}}if(!dt)break u;m:{if(!(!Tt[S|0]|Q>>>0<4))for(;;){if(dt=c[S>>2],(dt^-1)&dt-16843009&-2139062144)break m;if(S=S+4|0,Q=Q-4|0,!(Q>>>0>3))break}if(!Q)break u}dt=0;break g}dt=1}for(;;){if(!dt){$=Tt[S|0],dt=1;continue}if(!$)break y;if(S=S+1|0,Q=Q-1|0,!Q)break u;dt=0}}S=0}if(S=S?S-tt|0:nt,dt=S+tt|0,(et|0)>=0){$=P,et=S;break a}if($=P,et=S,Tt[dt|0])break e;break a}if(et){P=c[z+64>>2];break d}S=0,Tr(s,32,Y,0,$);break f}c[z+12>>2]=0,c[z+8>>2]=c[z+64>>2],P=z+8|0,c[z+64>>2]=P,et=-1}S=0;d:{for(;;){if(tt=c[P>>2],!tt)break d;if(tt=K2(z+4|0,tt),dt=(tt|0)<0,!(dt|tt>>>0>et-S>>>0)){if(P=P+4|0,S=S+tt|0,et>>>0>S>>>0)continue;break d}break}if(dt)break i}if(dt=61,(S|0)<0)break r;if(Tr(s,32,Y,S,$),!S){S=0;break f}for(dt=0,P=c[z+64>>2];;){if(tt=c[P>>2],!tt||(tt=K2(z+4|0,tt),dt=tt+dt|0,dt>>>0>S>>>0))break f;if(pr(s,z+4|0,tt),P=P+4|0,!(S>>>0>dt>>>0))break}}Tr(s,32,Y,S,$^8192),S=(S|0)<(Y|0)?Y:S;continue s}if((et|0)<0&&nt)break e;if(dt=61,S=$t[b|0](s,je[z+64>>3],Y,et,$,S)|0,(S|0)>=0)continue s;break r}pt[z+55|0]=c[z+64>>2],et=1,tt=Ft,$=P;break a}P=Tt[S+1|0],S=S+1|0}if(s)break t;if(!mt)break n;for(S=1;;){if(s=c[(S<<2)+y>>2],s){if(_2((S<<3)+u|0,s,h,k),W=1,S=S+1|0,(S|0)!=10)continue;break t}break}if(W=1,S>>>0>=10)break t;for(;;){if(c[(S<<2)+y>>2])break o;if(S=S+1|0,(S|0)==10)break}break t}dt=28;break r}if(Q=dt-tt|0,et=(et|0)>(Q|0)?et:Q,(et|0)>(q^2147483647))break e;if(dt=61,P=et+q|0,S=(P|0)<(Y|0)?Y:P,(Mt|0)<(S|0))break r;Tr(s,32,S,P,$),pr(s,Ct,q),Tr(s,48,S,P,$^65536),Tr(s,48,et,Q,0),pr(s,tt,Q),Tr(s,32,S,P,$^8192);continue}break}W=0;break t}dt=61}c[1781]=dt}W=-1}return St=z+80|0,W}function Pk(s,a,h,u){s=s|0,a=+a,h=+h,u=u|0;var y=m(0),b=m(0),k=0,S=m(0),P=0,z=m(0),tt=0,dt=m(0),Q=0;Q=St+-64|0,St=Q,k=c[s>>2],Vr(Q+8|0,0,56),c[1755]=c[1755]+1,E2(k),S=m(a),b=I[k+572>>2];t:{i:{r:switch(s=c[k+576>>2],s|0){case 0:case 3:break i;default:break r}y=I[k+572>>2];r:{if(!((s|0)!=1|y!=y)){if(y=b,!(y<m(0)))break r;break i}e:{if(!((s|0)!=2|y!=y)){if(S!=S|b<m(0))break i;break e}y=m(zt);s:switch(s-1|0){case 1:break e;case 0:break s;default:break r}y=b;break r}y=m(m(b*S)*m(.009999999776482582))}dt=m(y+m(ge(k,2,S)+Re(k,2,S))),tt=1;break t}y=m(0),b=I[k+216>>2];i:{r:{s=c[k+216>>2];e:{s:{if((s|0)==2139156720)break s;if((s|0)==2140081935)break i;tt=4336;n:{if((s|0)!=2141891242){if(b==b)break n;tt=4344}switch(y=I[tt>>2],c[tt+4>>2]-1|0){case 0:break e;case 1:break s;default:break r}}if(y=(Ot(2,(s&-1073741825)+536870912|0),Gt()),!(s&1073741824))break e}y=m(m(y*S)*m(.009999999776482582))}if(y!=y)break r;y=m(0);e:{if((s|0)==2139156720)break e;if((s|0)==2140081935)break i;P=4336;s:{if((s|0)!=2141891242){if(b==b)break s;P=4344}switch(y=I[P>>2],dt=m(zt),tt=2,c[P+4>>2]-1|0){case 1:break e;case 0:break i;default:break t}}if(y=(Ot(2,(s&-1073741825)+536870912|0),Gt()),!(s&1073741824))break i}dt=m(m(y*S)*m(.009999999776482582)),tt=2;break t}tt=S==S,dt=S;break t}tt=2,dt=y}z=m(h),b=I[k+580>>2];t:{i:{r:switch(s=c[k+584>>2],s|0){case 0:case 3:break i;default:break r}y=I[k+580>>2];r:{if(!((s|0)!=1|y!=y)){if(y=b,!(y<m(0)))break r;break i}e:{if(!((s|0)!=2|y!=y)){if(z!=z|b<m(0))break i;break e}y=m(zt);s:switch(s-1|0){case 1:break e;case 0:break s;default:break r}y=b;break r}y=m(m(b*z)*m(.009999999776482582))}b=m(y+m(ge(k,0,S)+Re(k,0,S))),s=1;break t}y=m(0),b=I[k+220>>2];i:{r:{s=c[k+220>>2];e:{s:{if((s|0)==2139156720)break s;if((s|0)==2140081935)break i;P=4336;n:{if((s|0)!=2141891242){if(b==b)break n;P=4344}switch(y=I[P>>2],c[P+4>>2]-1|0){case 0:break e;case 1:break s;default:break r}}if(y=(Ot(2,(s&-1073741825)+536870912|0),Gt()),!(s&1073741824))break e}y=m(m(y*z)*m(.009999999776482582))}if(y!=y)break r;y=m(0);e:{if((s|0)==2139156720)break e;if((s|0)==2140081935)break i;P=4336;s:{if((s|0)!=2141891242){if(b==b)break s;P=4344}switch(y=I[P>>2],b=m(zt),s=2,c[P+4>>2]-1|0){case 0:break i;case 1:break e;default:break t}}if(y=(Ot(2,(s&-1073741825)+536870912|0),Gt()),!(s&1073741824))break i}b=m(m(y*z)*m(.009999999776482582)),s=2;break t}s=z==z,b=z;break t}s=2,b=y}vn(k,dt,b,u,tt,s,S,z,1,0,c[k+568>>2],Q+8|0,0,c[1755])&&(x2(k,Tt[k+300|0]&3,S,z,S),L2(k,+I[c[k+568>>2]+20>>2],0,0)),St=Q- -64|0}function Ok(s,a){s=s|0,a=a|0;var h=0,u=m(0),y=0,b=0,k=m(0),S=0,P=0,z=0,tt=m(0);t:{P=c[a>>2],a=c[s>>2];i:{if((c[P+24>>2]^c[a+24>>2])&8388607)break i;tt=I[P+40>>2],y=c[P+40>>2],u=I[a+40>>2];r:{e:{if(h=c[a+40>>2],(h|0)!=2139156720){if(k=m(zt),s=3,(h|0)==2141891242)break r;if((h|0)!=2140081935)break e;k=m(0),s=1;break r}s=2;break r}if(s=0,u!=u)break r;k=(Ot(2,(h&-1073741825)+536870912|0),Gt()),s=h&1073741824?2:1}r:{e:{if((y|0)!=2139156720){if(u=m(zt),h=3,(y|0)==2141891242)break r;if((y|0)!=2140081935)break e;u=m(0),h=1;break r}u=m(0),h=2;break r}if(h=0,tt!=tt)break r;u=(Ot(2,(y&-1073741825)+536870912|0),Gt()),h=y&1073741824?2:1}if((h|0)!=(s|0)|!(!s|k!=k&u!=u|m(Xe(m(k-u)))<m(9999999747378752e-20))||(h=a+44|0,b=P+44|0,c[h>>2]!=c[b>>2]))break i;s=0;r:{for(;;){if(y=s,s=s+1|0,(s|0)==9)break r;if(S=s<<2,c[S+h>>2]!=c[b+S>>2])break}if(y>>>0<8)break i}if(h=a+80|0,b=P+80|0,c[h>>2]!=c[b>>2])break i;s=0;r:{for(;;){if(y=s,s=s+1|0,(s|0)==9)break r;if(S=s<<2,c[S+h>>2]!=c[b+S>>2])break}if(y>>>0<8)break i}if(h=a+116|0,b=P+116|0,c[h>>2]!=c[b>>2])break i;s=0;r:{for(;;){if(y=s,s=s+1|0,(s|0)==9)break r;if(S=s<<2,c[S+h>>2]!=c[b+S>>2])break}if(y>>>0<8)break i}if(h=a+152|0,b=P+152|0,c[h>>2]!=c[b>>2])break i;s=0;r:{for(;;){if(y=s,s=s+1|0,(s|0)==9)break r;if(S=s<<2,c[S+h>>2]!=c[b+S>>2])break}if(y>>>0<8)break i}if(h=a+188|0,b=P+188|0,c[h>>2]!=c[b>>2])break i;s=0;r:{for(;;){if(y=s,s=s+1|0,(s|0)==3)break r;if(S=s<<2,c[S+h>>2]!=c[b+S>>2])break}if(y>>>0<2)break i}for(S=P+200|0,z=a+200|0,s=0,y=1;;){r:{if(s=s<<2,h=c[s+S>>2],b=c[s+z>>2],!y)break r;if(y=0,s=1,(h|0)==(b|0))continue}break}if((h|0)!=(b|0))break i;for(S=P+208|0,z=a+208|0,s=0,y=1;;){r:{if(s=s<<2,h=c[s+S>>2],b=c[s+z>>2],!y)break r;if(y=0,s=1,(h|0)==(b|0))continue}break}if((h|0)!=(b|0))break i;for(S=P+216|0,z=a+216|0,s=0,y=1;;){r:{if(s=s<<2,h=c[s+S>>2],b=c[s+z>>2],!y)break r;if(y=0,s=1,(h|0)==(b|0))continue}break}if((h|0)!=(b|0)||(k=I[P+28>>2],s=k!=k,u=I[a+28>>2],(s|0)==(u==u|0)|!(s|u!=u)&u!=k)||(u=I[a+32>>2],k=I[P+32>>2],(u==u|0)==(k!=k|0)|u==u&u!=k)||(k=I[P+36>>2],s=k!=k,u=I[a+36>>2],(s|0)==(u==u|0)|!s&u!=k))break i;if(s=0,u=I[a+224>>2],u!=u&&(s=1,k=I[P+224>>2],k!=k)||(k=u,u=I[P+224>>2],k==u|u!=u&s))break t}for(Hr(a+24|0,P+24|0,204);;){if(s=Tt[a+4|0],s&4)break t;if(pt[a+4|0]=s|4,s=c[a+20>>2],s&&$t[s|0](a),c[a+308>>2]=2143289344,a=c[a+552>>2],!a)break}}}function $k(s,a){s=s|0,a=a|0;var h=0,u=0,y=0,b=0,k=0,S=0,P=0,z=0,tt=0,dt=0,Q=0,et=0,$=0,W=0,Y=0,q=0;h=a,a=c[a>>2]+7&-8,c[h>>2]=a+16,$=s,P=c[a>>2],u=c[a+4>>2],s=c[a+12>>2],Q=s,k=St-32|0,St=k,s=s&2147483647,S=s,y=s-1006698496|0,s=s-1140785152|0,h=c[a+8>>2],a=h;t:{if((y|0)==(s|0)&a>>>0<a>>>0|s>>>0>y>>>0){if(s=h,h=Q<<4|s>>>28,a=s<<4|u>>>28,s=h,u=u&268435455,(u|0)==134217728&(P|0)!=0|u>>>0>134217728){s=s+1073741824|0,a=a+1|0,s=a?s:s+1|0;break t}if(s=s+1073741824|0,P|(u|0)!=134217728)break t;u=a&1,a=u+a|0,s=a>>>0<u>>>0?s+1|0:s;break t}if(!(!a&(S|0)==2147418112?!(u|P):S>>>0<2147418112)){s=h,h=Q<<4|s>>>28,a=s<<4|u>>>28,s=h&524287|2146959360;break t}if(a=0,s=2146435072,S>>>0>1140785151||(s=0,et=S>>>16|0,et>>>0<15249))break t;a=P,s=u,y=Q&65535|65536,S=y,dt=h,b=h,z=et-15233|0;i:{if(z&64){h=a,y=z+-64|0,a=y&31,(y&63)>>>0>=32?(s=h<<a,b=0):(s=(1<<a)-1&h>>>32-a|s<<a,b=h<<a),y=s,a=0,s=0;break i}if(!z)break i;tt=b,b=z&31,(z&63)>>>0>=32?(h=tt<<b,b=0):(h=(1<<b)-1&tt>>>32-b|y<<b,b=tt<<b),y=h,W=b,tt=a,h=64-z|0,b=h&31,(h&63)>>>0>=32?(h=0,a=s>>>b|0):(h=s>>>b|0,a=((1<<b)-1&s)<<32-b|tt>>>b),b=W|a,y=h|y,a=z&31,(z&63)>>>0>=32?(h=tt<<a,a=0):(h=(1<<a)-1&tt>>>32-a|s<<a,a=tt<<a),s=h}c[k+16>>2]=a,c[k+20>>2]=s,c[k+24>>2]=b,c[k+28>>2]=y,a=15361-et|0;i:{if(a&64){u=dt,a=a+-64|0,s=a&31,(a&63)>>>0>=32?(h=0,P=S>>>s|0):(h=S>>>s|0,P=((1<<s)-1&S)<<32-s|u>>>s),u=h,dt=0,S=0;break i}if(!a)break i;y=dt,s=64-a|0,h=s&31,(s&63)>>>0>=32?(s=y<<h,b=0):(s=(1<<h)-1&y>>>32-h|S<<h,b=y<<h),y=P,P=a&31,(a&63)>>>0>=32?(h=0,y=u>>>P|0):(h=u>>>P|0,y=((1<<P)-1&u)<<32-P|y>>>P),P=b|y,u=s|h,y=dt,h=a&31,(a&63)>>>0>=32?(s=0,dt=S>>>h|0):(s=S>>>h|0,dt=((1<<h)-1&S)<<32-h|y>>>h),S=s}if(c[k>>2]=P,c[k+4>>2]=u,c[k+8>>2]=dt,c[k+12>>2]=S,a=c[k+8>>2],s=c[k+12>>2]<<4|a>>>28,a=a<<4,h=c[k>>2],S=c[k+4>>2],a=S>>>28|a,u=S&268435455,h=h|(c[k+16>>2]|c[k+24>>2]|(c[k+20>>2]|c[k+28>>2]))!=0,(u|0)==134217728&(h|0)!=0|u>>>0>134217728){a=a+1|0,s=a?s:s+1|0;break t}if(h|(u|0)!=134217728)break t;h=a,a=a+(a&1)|0,s=h>>>0>a>>>0?s+1|0:s}St=k+32|0,Ot(0,a|0),Ot(1,Q&-2147483648|s),Y=$,q=+ke(),je[Y>>3]=q}function vn(s,a,h,u,y,b,k,S,P,z,tt,dt,Q,et){var $=m(0),W=0,Y=0,q=0,nt=0,ot=m(0),mt=0,Et=0,Ct=m(0);t:{if(!(c[s+312>>2]!=(et|0)&&Tt[s+4|0]&4)&&(nt=0,c[s+316>>2]==(u|0)))break t;c[s+540>>2]=-1082130432,c[s+544>>2]=-1082130432,c[s+532>>2]=0,c[s+536>>2]=0,c[s+524>>2]=-1082130432,c[s+528>>2]=-1082130432,c[s+320>>2]=0,nt=1}mt=Q+1|0;t:{i:{r:{e:{if(c[s+8>>2]){if(ot=ge(s,2,k),Ct=Re(s,2,k),$=m(ge(s,0,k)+Re(s,0,k)),Q=s+524|0,ot=m(ot+Ct),T2(y,a,b,h,c[s+532>>2],I[Q>>2],c[s+536>>2],I[s+528>>2],I[s+540>>2],I[s+544>>2],ot,$,tt))break r;if(Y=c[s+320>>2],!Y)break e;for(W=s+324|0;;){if(Q=W+Ke(q,24)|0,T2(y,a,b,h,c[Q+8>>2],I[Q>>2],c[Q+12>>2],I[Q+4>>2],I[Q+16>>2],I[Q+20>>2],ot,$,tt))break r;if(q=q+1|0,(Y|0)==(q|0))break}break e}if(!P){if(Et=c[s+320>>2],!Et)break e;for(Y=s+324|0;;){W=Ke(q,24),Q=W+Y|0,$=I[Q>>2];s:{n:{if(!($!=$|a!=a)){if(m(Xe(m($-a)))<m(9999999747378752e-20))break n;break s}if($==$|a==a)break s}W=Y+W|0,$=I[W+4>>2];n:{if(!($!=$|h!=h)){if(m(Xe(m($-h)))<m(9999999747378752e-20))break n;break s}if($==$|h==h)break s}if(c[W+8>>2]!=(y|0))break s;if(c[W+12>>2]==(b|0))break r}if(q=q+1|0,(Et|0)==(q|0))break}break e}Q=s+524|0,$=I[Q>>2];s:{if(!($!=$|a!=a)){if(m(Xe(m($-a)))<m(9999999747378752e-20))break s;break e}if($==$|a==a)break e}W=c[s+532>>2]==(y|0)&&c[s+536>>2]==(b|0)?Q:0,$=I[s+528>>2],Q=$!=$,Y=h!=h;s:{if(Q|Y){Q=Q&Y;break s}Q=m(Xe(m($-h)))<m(9999999747378752e-20)}Q=Q?W:0;break r}m2(s,a,h,u,y,b,k,S,P,tt,dt,mt,et,z),c[s+316>>2]=u;break i}if(!(!Q|nt)){I[s+516>>2]=I[Q+16>>2],I[s+520>>2]=I[Q+20>>2],u=(P?12:16)+dt|0,c[u>>2]=c[u>>2]+1;break t}if(m2(s,a,h,u,y,b,k,S,P,tt,dt,mt,et,z),c[s+316>>2]=u,Q)break t}Q=c[s+320>>2],u=Q+1|0,u>>>0>c2[dt+8>>2]&&(c[dt+8>>2]=u),(Q|0)==8&&(c[s+320>>2]=0,Q=0),P?u=s+524|0:(c[s+320>>2]=Q+1,u=(Ke(Q,24)+s|0)+324|0),c[u+12>>2]=b,c[u+8>>2]=y,I[u+4>>2]=h,I[u>>2]=a,I[u+16>>2]=I[s+516>>2],I[u+20>>2]=I[s+520>>2],Q=0}t:{if(!P||(u=c[s+520>>2],c[s+244>>2]=c[s+516>>2],c[s+248>>2]=u,u=Tt[s+4|0],y=u|1,pt[s+4|0]=y,!(u&4)))break t;pt[s+4|0]=y&251}return c[s+312>>2]=et,!Q|nt}function td(s){s=s|0;var a=0,h=0,u=0,y=0,b=0,k=0,S=0,P=0,z=0,tt=0,dt=0;S=8;t:{if(s>>>0>4294967239)break t;i:{for(;;){S=S>>>0<=8?8:S,a=c[1751],b=a,y=c[1750],s=s>>>0<=8?8:s+3&-4;r:{if(s>>>0<=127){k=(s>>>3|0)-1|0;break r}if(u=Ai(s),k=((s>>>29-u^4)-(u<<2)|0)+110|0,s>>>0<=4095)break r;u=((s>>>30-u^2)-(u<<1)|0)+71|0,k=u>>>0>=63?63:u}if(h=k&31,(k&63)>>>0>=32?(u=0,a=a>>>h|0):(u=a>>>h|0,a=((1<<h)-1&a)<<32-h|y>>>h),a|u){for(;;){y=u;r:{if(a|u){h=u-1|0,P=h+1|0,b=h,h=a-1|0,b=(h|0)!=-1?P:b,u=Ai(u^b),u=(u|0)==32?Ai(a^h)+32|0:u,h=63-u|0,Gr=0-(u>>>0>63)|0;break r}Gr=0,h=64}b=h,h=b&31,(b&63)>>>0>=32?(u=0,a=y>>>h|0):(u=y>>>h|0,a=((1<<h)-1&y)<<32-h|a>>>h),P=a,k=b+k|0,h=k<<4,a=c[h+5976>>2],b=h+5968|0;r:{if((a|0)!=(b|0)){if(y=id(a,S,s),y)break t;y=c[a+4>>2],c[y+8>>2]=c[a+8>>2],c[c[a+8>>2]+4>>2]=y,c[a+8>>2]=b,y=h+5972|0,c[a+4>>2]=c[y>>2],c[y>>2]=a,c[c[a+4>>2]+8>>2]=a,k=k+1|0,a=(u&1)<<31|P>>>1,u=u>>>1|0;break r}z=c[1751],b=k&63,a=b,y=a&31,a>>>0>=32?(a=0,h=-1>>>y|0):(a=-1>>>y|0,h=a|(1<<y)-1<<32-y),h=h&-2,y=b&31,b>>>0>=32?(a=h<<y,h=0):(a=(1<<y)-1&h>>>32-y|a<<y,h=h<<y),tt=h,y=a,b=0-k&63,h=b,a=h&31,h>>>0>=32?(a=-1<<a,h=0):(h=-1<<a,a=h|(1<<a)-1&-1>>>32-a),dt=h&-2,h=b&31,b>>>0>=32?(b=0,a=a>>>h|0):(b=a>>>h|0,a=((1<<h)-1&a)<<32-h|dt>>>h),a=a|tt,Gr=y|b,c[1750]=c[1750]&a,c[1751]=Gr&z,a=P^1}if(!(a|u))break}b=c[1751],y=c[1750]}r:{if(y|b){u=Ai(b),h=63-((u|0)==32?Ai(y)+32|0:u)|0,a=h<<4,u=c[a+5976>>2];e:{if(!b&y>>>0<1073741824||(k=99,a=a+5968|0,(a|0)==(u|0)))break e;for(;;){if(!k)break e;if(y=id(u,S,s),y)break t;if(k=k-1|0,u=c[u+8>>2],(a|0)==(u|0))break}u=a}if(rd(s+48|0))break r;if(!u||(a=(h<<4)+5968|0,(a|0)==(u|0)))break i;for(;;){if(y=id(u,S,s),y)break t;if(u=c[u+8>>2],(a|0)==(u|0))break}break i}if(!rd(s+48|0))break i}if(y=0,S-1&S)break t;if(!(s>>>0<=4294967239))break}break t}y=0}return y|0}function Mk(s,a,h){s=s|0,a=a|0,h=h|0;var u=0,y=0,b=0,k=0,S=0,P=0,z=0,tt=0,dt=0,Q=0;S=St-80|0,St=S,s=c[s>>2];t:{i:{if(P=c[a>>2],!c[P+552>>2]){if(c[s+8>>2])break i;a=c[s+556>>2],k=a+(h<<2)|0,u=c[s+560>>2],y=s+564|0,b=c[y>>2];r:{if(u>>>0<b>>>0){if((u|0)==(k|0)){c[k>>2]=P,c[s+560>>2]=k+4;break r}if(h=u,a=u-4|0,u>>>0>a>>>0)for(;c[h>>2]=c[a>>2],h=h+4|0,a=a+4|0,u>>>0>a>>>0;);c[s+560>>2]=h,a=k+4|0,(a|0)!=(u|0)&&(a=u-a|0,Bs(u-(a&-4)|0,k,a)),c[k>>2]=P;break r}if(u=(u-a>>2)+1|0,u>>>0>=1073741824)break t;a=b-a|0,b=a>>1,y=Ya(S+32|0,a>>>0>=2147483644?1073741823:u>>>0<b>>>0?b:u,h,y),h=c[y+8>>2];e:{if((h|0)!=c[y+12>>2])break e;if(a=c[y+4>>2],u=c[y>>2],a>>>0>u>>>0){u=((a-u>>2)+1|0)/-2<<2,z=u+a|0,b=a,a=h-a|0,h=Bs(z,b,a)+a|0,c[y+8>>2]=h,c[y+4>>2]=u+c[y+4>>2];break e}a=(h|0)==(u|0)?1:h-u>>1,b=Ya(S+56|0,a,a>>>2|0,c[y+16>>2]),u=c[b+8>>2],a=c[y+4>>2],h=c[y+8>>2];s:{if((a|0)==(h|0)){h=u,u=a;break s}for(h=(h-a|0)+u|0;c[u>>2]=c[a>>2],a=a+4|0,u=u+4|0,(u|0)!=(h|0););a=c[y+8>>2],u=c[y+4>>2]}if(z=c[y>>2],c[y>>2]=c[b>>2],c[b>>2]=z,c[y+4>>2]=c[b+4>>2],c[b+4>>2]=u,c[y+8>>2]=h,c[b+8>>2]=a,tt=c[y+12>>2],c[y+12>>2]=c[b+12>>2],c[b+12>>2]=tt,(a|0)!=(u|0)&&(c[b+8>>2]=((u-a|0)+3&-4)+a),!z)break e;Ar(z),h=c[y+8>>2]}if(c[h>>2]=P,c[y+8>>2]=c[y+8>>2]+4,a=c[s+556>>2],h=k-a|0,dt=y,Q=Bs(c[y+4>>2]-h|0,a,h),c[dt+4>>2]=Q,u=c[s+560>>2]-k|0,k=Bs(c[y+8>>2],k,u),a=c[s+556>>2],c[s+556>>2]=c[y+4>>2],c[y+4>>2]=a,h=c[s+560>>2],c[s+560>>2]=u+k,c[y+8>>2]=h,u=c[s+564>>2],c[s+564>>2]=c[y+12>>2],c[y>>2]=a,c[y+12>>2]=u,(a|0)!=(h|0)&&(c[y+8>>2]=h+((a-h|0)+3&-4)),!a)break r;Ar(a)}for(c[P+552>>2]=s;a=Tt[s+4|0],!!(!(a&4)&&(pt[s+4|0]=a|4,a=c[s+20>>2],a&&$t[a|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],s)););St=S+80|0;return}c[S+16>>2]=4075,li(s,S+16|0),ti(),pe()}c[S>>2]=4208,li(s,S),ti(),pe()}Us(),pe()}function b2(s,a){var h=0,u=0;for(c[s>>2]=0,c[s+8>>2]=0,c[s+12>>2]=0,c[s+16>>2]=0,c[s+20>>2]=0,c[s+24>>2]=0,c[s+36>>2]=2143289344,c[s+40>>2]=2141891242,c[s+28>>2]=2143289344,c[s+32>>2]=2143289344,pt[s+4|0]=Tt[s+4|0]&128,u=Vr(s+44|0,0,36);c[u+(h<<2)>>2]=2143289344,h=h+1|0,(h|0)!=9;);for(h=0,u=Vr(s+80|0,0,36);c[u+(h<<2)>>2]=2143289344,h=h+1|0,(h|0)!=9;);for(h=0,u=Vr(s+116|0,0,36);c[u+(h<<2)>>2]=2143289344,h=h+1|0,(h|0)!=9;);for(h=0,u=Vr(s+152|0,0,36);c[u+(h<<2)>>2]=2143289344,h=h+1|0,(h|0)!=9;);for(h=0,c[s+196>>2]=0,u=s+188|0,c[u>>2]=0,c[u+4>>2]=0;c[u+(h<<2)>>2]=2143289344,h=h+1|0,(h|0)!=3;);for(c[s+24>>2]=4224,c[s+224>>2]=2143289344,c[s+216>>2]=2143289344,c[s+220>>2]=2143289344,c[s+208>>2]=2143289344,c[s+212>>2]=2143289344,c[s+200>>2]=2141891242,c[s+204>>2]=2141891242,Vr(s+228|0,0,288),c[s+244>>2]=2143289344,c[s+248>>2]=2143289344,Vr(s+252|0,0,49),c[s+308>>2]=2143289344,u=s+516|0,h=s+324|0;c[h+16>>2]=-1082130432,c[h+20>>2]=-1082130432,c[h+8>>2]=0,c[h+12>>2]=0,c[h>>2]=-1082130432,c[h+4>>2]=-1082130432,h=h+24|0,(u|0)!=(h|0););return c[s+548>>2]=0,c[s+552>>2]=0,c[s+516>>2]=2143289344,c[s+520>>2]=2143289344,c[s+572>>2]=2143289344,c[s+576>>2]=0,c[s+568>>2]=a,c[s+540>>2]=-1082130432,c[s+544>>2]=-1082130432,c[s+532>>2]=0,c[s+536>>2]=0,c[s+524>>2]=-1082130432,c[s+528>>2]=-1082130432,c[s+556>>2]=0,c[s+560>>2]=0,c[s+564>>2]=0,c[s+580>>2]=2143289344,c[s+584>>2]=0,Q2((a|0)!=0,2760),pt[s+4|0]=Tt[s+4|0]|1,pt[a+8|0]&1&&(c[s+24>>2]=c[s+24>>2]&-909|520),s}function Ze(s,a,h,u){var y=m(0),b=m(0),k=0,S=m(0);t:{i:{r:{e:{s:{n:{if(a>>>0<=1){b=I[s+212>>2],a=c[s+212>>2];a:{if((a|0)==2139156720)break a;if((a|0)==2140081935)break n;k=4336;o:{if((a|0)!=2141891242){if(b==b)break o;k=4344}switch(y=I[k>>2],b=m(zt),c[k+4>>2]-1|0){case 0:break n;case 1:break a;default:break s}}if(y=(Ot(2,(a&-1073741825)+536870912|0),Gt()),!(a&1073741824))break n}b=m(m(y*u)*m(.009999999776482582));break s}b=I[s+208>>2];a:{o:{a=c[s+208>>2];l:{if((a|0)==2139156720)break l;if((a|0)==2140081935)break o;k=4336;c:{if((a|0)!=2141891242){if(b==b)break c;k=4344}switch(y=I[k>>2],b=m(zt),c[k+4>>2]-1|0){case 0:break o;case 1:break l;default:break a}}if(y=(Ot(2,(a&-1073741825)+536870912|0),Gt()),!(a&1073741824))break o}b=m(m(y*u)*m(.009999999776482582));break a}b=y}y=m(0),S=I[s+216>>2],s=c[s+216>>2];a:{if((s|0)==2139156720)break a;if((s|0)==2140081935)break r;a=4336;o:{if((s|0)!=2141891242){if(S==S)break o;a=4344}switch(y=I[a>>2],c[a+4>>2]-1|0){case 1:break a;case 0:break e;default:break i}}if(y=(Ot(2,(s&-1073741825)+536870912|0),Gt()),!(s&1073741824))break e}y=m(m(y*u)*m(.009999999776482582));break e}b=y}y=m(0),S=I[s+220>>2],s=c[s+220>>2];s:{if((s|0)==2139156720)break s;if((s|0)==2140081935)break r;a=4336;n:{if((s|0)!=2141891242){if(S==S)break n;a=4344}switch(y=I[a>>2],c[a+4>>2]-1|0){case 1:break s;case 0:break e;default:break i}}if(y=(Ot(2,(s&-1073741825)+536870912|0),Gt()),!(s&1073741824))break e}y=m(m(y*u)*m(.009999999776482582))}if(!(y>=m(0)))break i}if(h>y)break t}if(!(b>=m(0)))return h;y=h<b?b:h}return y}function E2(s){var a=0,h=0,u=m(0),y=m(0),b=m(0),k=0,S=0,P=0,z=0,tt=0,dt=0,Q=0,et=0,$=0;for(k=St-16|0,c[k+8>>2]=0,c[k+12>>2]=1,tt=s+200|0,dt=s+572|0,Q=s+208|0,et=s+216|0,s=0;;){$=s,z=c[(k+8|0)+(s<<2)>>2],S=z<<2,s=et+S|0,u=I[s>>2];t:{i:{r:{e:{s:{n:{if(a=c[s>>2],P=(a|0)==2139156720,!(P|(a|0)==2140081935|(a|0)==2141891242)&u!=u)break n;s=S+Q|0,y=I[s>>2],h=c[s>>2];a:{o:{if((h|0)!=2139156720){if(b=m(zt),s=3,(h|0)==2141891242)break a;if((h|0)!=2140081935)break o;b=m(0),s=1;break a}b=m(0),s=2;break a}if(s=0,y!=y)break a;b=(Ot(2,(h&-1073741825)+536870912|0),Gt()),s=h&1073741824?2:1}h=s;a:{o:{if(!P){if(y=m(zt),s=3,(a|0)==2141891242)break a;if((a|0)!=2140081935)break o;y=m(0),s=1;break a}y=m(0),s=2;break a}if(s=0,u!=u)break a;y=(Ot(2,(a&-1073741825)+536870912|0),Gt()),s=a&1073741824?2:1}if((h|0)!=(s|0)|!(!s|y!=y&b!=b|m(Xe(m(y-b)))<m(9999999747378752e-20)))break n;if(s=0,P)break s;if((a|0)==2140081935)break i;if((a|0)==2141891242)break r;if(u!=u)break e;s=(a&-1073741825)+536870912|0,a=a&1073741824?2:1;break t}if(s=0,a=S+tt|0,u=I[a>>2],a=c[a>>2],(a|0)==2139156720)break s;if((a|0)==2140081935)break i;if((a|0)==2141891242)break r;if(u!=u)break e;s=(a&-1073741825)+536870912|0,a=a&1073741824?2:1;break t}a=2;break t}s=2143289344,a=0;break t}s=2143289344,a=3;break t}a=1}if(h=(z<<3)+dt|0,c[h+4>>2]=a,c[h>>2]=s,s=1,!!($&1))break}}function Hr(s,a,h){var u=0,y=0,b=0;if(h>>>0>=512)return Rk(s|0,a|0,h|0),s;y=s+h|0;t:{if(!((s^a)&3)){i:{if(!(s&3)){h=s;break i}if(!h){h=s;break i}for(h=s;;){if(pt[h|0]=Tt[a|0],a=a+1|0,h=h+1|0,!(h&3))break i;if(!(h>>>0<y>>>0))break}}u=y&-4;i:{if(u>>>0<64||(b=u+-64|0,b>>>0<h>>>0))break i;for(;c[h>>2]=c[a>>2],c[h+4>>2]=c[a+4>>2],c[h+8>>2]=c[a+8>>2],c[h+12>>2]=c[a+12>>2],c[h+16>>2]=c[a+16>>2],c[h+20>>2]=c[a+20>>2],c[h+24>>2]=c[a+24>>2],c[h+28>>2]=c[a+28>>2],c[h+32>>2]=c[a+32>>2],c[h+36>>2]=c[a+36>>2],c[h+40>>2]=c[a+40>>2],c[h+44>>2]=c[a+44>>2],c[h+48>>2]=c[a+48>>2],c[h+52>>2]=c[a+52>>2],c[h+56>>2]=c[a+56>>2],c[h+60>>2]=c[a+60>>2],a=a- -64|0,h=h- -64|0,b>>>0>=h>>>0;);}if(h>>>0>=u>>>0)break t;for(;c[h>>2]=c[a>>2],a=a+4|0,h=h+4|0,u>>>0>h>>>0;);break t}if(y>>>0<4){h=s;break t}if(u=y-4|0,u>>>0<s>>>0){h=s;break t}for(h=s;pt[h|0]=Tt[a|0],pt[h+1|0]=Tt[a+1|0],pt[h+2|0]=Tt[a+2|0],pt[h+3|0]=Tt[a+3|0],a=a+4|0,h=h+4|0,u>>>0>=h>>>0;);}if(h>>>0<y>>>0)for(;pt[h|0]=Tt[a|0],a=a+1|0,h=h+1|0,(y|0)!=(h|0););return s}function A2(s,a,h,u,y){var b=m(0),k=0,S=m(0),P=m(0),z=0,tt=0,dt=m(0),Q=m(0),et=0;if(S=m(h-u),tt=S!=S,!tt){h=m(0),k=(a<<2)+s|0,b=I[k+208>>2];t:{i:{k=c[k+208>>2];r:{e:{if((k|0)==2139156720)break e;if((k|0)==2140081935)break i;z=4336;s:{if((k|0)!=2141891242){if(b==b)break s;z=4344}switch(h=I[z>>2],c[z+4>>2]-1|0){case 0:break r;case 1:break e;default:break t}}if(h=(Ot(2,(k&-1073741825)+536870912|0),Gt()),!(k&1073741824))break r}h=m(m(h*y)*m(.009999999776482582))}if(h==h)break i;break t}P=m(h-u)}h=m(0),s=(a<<2)+s|0,b=I[s+216>>2];t:{i:{a=c[s+216>>2];r:{e:{if((a|0)==2139156720)break e;if((a|0)==2140081935)break i;s=4336;s:{if((a|0)!=2141891242){if(b==b)break s;s=4344}switch(h=I[s>>2],b=m(34028234663852886e22),c[s+4>>2]-1|0){case 0:break r;case 1:break e;default:break t}}if(h=(Ot(2,(a&-1073741825)+536870912|0),Gt()),!(a&1073741824))break r}h=m(m(h*y)*m(.009999999776482582))}if(h==h)break i;b=m(34028234663852886e22);break t}b=m(h-u)}if(h=(dt=S,Q=ld(S,b),et=b!=b|tt,et?dt:Q),s=h!=h,!(s|P!=P))return fe(h,P);S=s?P:h}return S}function T2(s,a,h,u,y,b,k,S,P,z,tt,dt,Q){var et=m(0),$=m(0),W=0,Y=0,q=m(0),nt=m(0),ot=m(0),mt=0,Et=0;if(P<m(0)|z<m(0))s=0;else{q=b,nt=a,ot=u,$=S;t:{if(!Q||(et=I[Q+20>>2],$=S,et==m(0)))break t;mt=+et,nt=Ki(+a,mt,0,0),ot=Ki(+u,mt,0,0),q=Ki(+b,mt,0,0),$=Ki(+S,mt,0,0)}et=$,Q=0;t:{if((s|0)!=(y|0))break t;if(Et=q!=q,Q=nt!=nt,Et|Q){Q=Q&Et;break t}Q=m(Xe(m(q-nt)))<m(9999999747378752e-20)}Et=Q;t:{if((h|0)!=(k|0))break t;if(W=et!=et,Q=ot!=ot,W|Q){W=Q&W;break t}W=m(Xe(m(et-ot)))<m(9999999747378752e-20)}Y=1,Q=1;t:{if(Et)break t;a=m(a-tt);i:{if((s|0)==1)break i;if(s=(s|0)!=2,!(s|y)){if(!(a>=P))break i;break t}if(Q=0,!(a<b)|(s|(y|0)!=2|(a!=a|b!=b|P!=P))||(Q=1,a>=P))break t}if(y=a!=a,s=P!=P,y|s){Q=s&y;break t}Q=m(Xe(m(a-P)))<m(9999999747378752e-20)}t:{if(W)break t;a=m(u-dt);i:{if((h|0)==1)break i;if(s=(h|0)!=2,!(s|k)){if(!(a>=z))break i;break t}if(Y=0,!(a<S)|(s|(k|0)!=2|(a!=a|S!=S|z!=z))||(Y=1,a>=z))break t}if(h=a!=a,s=z!=z,h|s){Y=s&h;break t}Y=m(Xe(m(a-z)))<m(9999999747378752e-20)}s=Q&Y}return s}function ed(s){var a=0,h=0,u=0,y=0,b=0,k=0,S=0,P=0;if(Er(+s),b=te(1)|0,u=te(0)|0,y=b>>>20&2047,(y|0)==2047)return s=s*1,s/s;if(a=u<<1,k=b<<1|u>>>31,!a&(k|0)==2145386496|k>>>0<2145386496)return!a&(k|0)==2145386496?s*0:s;t:{if(!y){if(y=0,h=u<<12,a=b<<12|u>>>20,(a|0)>0|(a|0)>=0)for(;y=y-1|0,a=a<<1|h>>>31,h=h<<1,!!((a|0)>0|(a|0)>=0););a=1-y|0,h=a&31,(a&63)>>>0>=32?(a=u<<h,u=0):(a=(1<<h)-1&u>>>32-h|b<<h,u=u<<h);break t}a=b&1048575|1048576}if(h=u,(y|0)>1023){for(;;){t:{if(u=a+-1048576|0,(u|0)<0||(a=u,a|h))break t;return s*0}if(a=a<<1|h>>>31,h=h<<1,y=y-1|0,!((y|0)>1023))break}y=1023}t:{if(u=a+-1048576|0,(u|0)<0||(a=u,a|h))break t;return s*0}if((a|0)==1048575|a>>>0<1048575)for(;y=y-1|0,u=a>>>0<524288,k=a<<1|h>>>31,h=h<<1,a=k,!!u;);return P=b&-2147483648,k=a+-1048576|y<<20,S=h,b=a,S=h,u=1-y|0,h=u&31,(u&63)>>>0>=32?(a=0,u=b>>>h|0):(a=b>>>h|0,u=((1<<h)-1&b)<<32-h|S>>>h),h=(y|0)>0,Ot(0,(h?S:u)|0),Ot(1,(h?k:a)|P),+ke()}function rd(s){var a=0,h=0,u=0,y=0,b=0;u=c[1416],a=s+7&-8,h=u+a|0;t:{i:{if(h>>>0<=u>>>0&&a||h>>>0>dg()<<16>>>0&&!(Sk(h|0)|0))break i;c[1416]=h;break t}c[1781]=48,u=-1}if((u|0)!=-1){a=s+u|0,h=a-16|0,c[h+12>>2]=16,c[h>>2]=16,s=c[1748],s?b=c[s+8>>2]:b=0;t:{i:{if((b|0)==(u|0)){if(y=u-(c[u-4>>2]&-2)|0,b=c[y-4>>2],c[s+8>>2]=a,s=y-(b&-2)|0,a=-16,!(pt[(s+c[s>>2]|0)-4|0]&1))break i;a=c[s+4>>2],c[a+8>>2]=c[s+8>>2],c[c[s+8>>2]+4>>2]=a,h=h-s|0,c[s>>2]=h;break t}c[u+12>>2]=16,c[u>>2]=16,c[u+8>>2]=a,c[u+4>>2]=s,c[1748]=u,a=16}s=a+u|0,h=h-s|0,c[s>>2]=h}c[((h&-4)+s|0)-4>>2]=h|1,a=c[s>>2]-8|0;t:{if(a>>>0<=127){h=(a>>>3|0)-1|0;break t}if(y=Ai(a),h=((a>>>29-y^4)-(y<<2)|0)+110|0,a>>>0<=4095)break t;h=((a>>>30-y^2)-(y<<1)|0)+71|0,h=h>>>0>=63?63:h}a=h<<4,c[s+4>>2]=a+5968,a=a+5976|0,c[s+8>>2]=c[a>>2],c[a>>2]=s,c[c[s+8>>2]+4>>2]=s,a=c[1750],y=c[1751],s=h&31,(h&63)>>>0>=32?(h=1<<s,b=0):(b=1<<s,h=b-1&1>>>32-s),c[1750]=b|a,c[1751]=h|y}return(u|0)!=-1}function k2(s,a,h){var u=0,y=0,b=0,k=0,S=0,P=0,z=0,tt=0,dt=0;t:{i:{r:{e:{s:{n:{a:{o:{l:{c:{if(a){if(!h)break c;break l}s=(s>>>0)/(h>>>0)|0,Gr=0;break t}if(!s)break o;break a}if(!(h-1&h))break n;b=(Ai(h)+33|0)-Ai(a)|0,k=0-b|0;break e}s=(a>>>0)/0|0,Gr=0;break t}if(u=32-Ai(a)|0,u>>>0<31)break s;break r}if((h|0)==1)break i;b=h?31-Ai(h-1^h)|0:32,h=b&31,(b&63)>>>0>=32?s=a>>>h|0:(u=a>>>h|0,s=((1<<h)-1&a)<<32-h|s>>>h),Gr=u;break t}b=u+1|0,k=63-u|0}if(u=b&63,y=u&31,u>>>0>=32?(u=0,S=a>>>y|0):(u=a>>>y|0,S=((1<<y)-1&a)<<32-y|s>>>y),k=k&63,y=k&31,k>>>0>=32?(a=s<<y,s=0):(a=(1<<y)-1&s>>>32-y|a<<y,s=s<<y),b)for(k=h-1|0,dt=(k|0)==-1?-1:0;P=u<<1|S>>>31,u=S<<1|a>>>31,y=dt-(P+(u>>>0>k>>>0)|0)>>31,z=h&y,S=u-z|0,u=P-(u>>>0<z>>>0)|0,a=a<<1|s>>>31,s=tt|s<<1,tt=y&1,b=b-1|0,!!b;);Gr=a<<1|s>>>31,s=tt|s<<1;break t}s=0,a=0}Gr=a}return s}function El(s,a,h){var u=m(0),y=m(0);t:{i:{r:{if((a&-2)==2){if(a=c[s+188>>2],u=I[s+188>>2],(a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|u==u||(a=c[s+196>>2],u=I[s+196>>2],(a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|u==u))break r;break i}if(a=c[s+192>>2],u=I[s+192>>2],(a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|u==u||(u=I[s+196>>2],a=c[s+196>>2],(a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242))break r;if(u!=u)break i}u=m(0);r:{e:{if((a|0)==2139156720)break e;if((a|0)==2140081935)break t;s=4336;s:{if((a|0)!=2141891242){if(u=(Ot(2,a),Gt()),u==u)break s;s=4344}switch(u=I[s>>2],y=m(zt),c[s+4>>2]-1|0){case 0:break t;case 1:break e;default:break r}}if(u=(Ot(2,(a&-1073741825)+536870912|0),Gt()),!(a&1073741824))break t}y=m(m(u*h)*m(.009999999776482582))}return y}u=m(0)}return u}function w2(s,a){var h=0,u=0,y=0,b=0,k=0,S=0;for(h=St-320|0,St=h,u=Vr(h,0,288),h=u,c[h+16>>2]=2143289344,c[h+20>>2]=2143289344,Vr(h+24|0,0,49),c[h+80>>2]=2143289344,b=h+288|0,y=h+96|0;h=y,c[h+16>>2]=-1082130432,c[h+20>>2]=-1082130432,c[h+8>>2]=0,c[h+12>>2]=0,c[h>>2]=-1082130432,c[h+4>>2]=-1082130432,y=h+24|0,(b|0)!=(y|0););if(c[u+312>>2]=-1082130432,c[u+316>>2]=-1082130432,c[u+304>>2]=0,c[u+308>>2]=0,c[u+296>>2]=-1082130432,c[u+300>>2]=-1082130432,c[u+288>>2]=2143289344,c[u+292>>2]=2143289344,Hr(s+228|0,u,320),c[s+244>>2]=0,c[s+248>>2]=0,pt[s+4|0]=Tt[s+4|0]|1,y=c[s+556>>2],k=c[s+560>>2],(y|0)!=(k|0))for(;h=c[y>>2],c[h+552>>2]!=(s|0)&&(b=c[s+568>>2],h=I2(c[b>>2],Tt[b+8|0],h,s,S,a),c[y>>2]=h,c[h+552>>2]=s,h=c[y>>2]),w2(h,a),S=S+1|0,y=y+4|0,(k|0)!=(y|0););St=u+320|0}function id(s,a,h){var u=0,y=0,b=0,k=0;if(u=s+4|0,y=(u+a|0)-1&0-a,a=c[s>>2],y+h>>>0<=(a+s|0)-4>>>0){b=c[s+4>>2],c[b+8>>2]=c[s+8>>2],c[c[s+8>>2]+4>>2]=b,(u|0)!=(y|0)&&(y=y-u|0,b=s-(c[s-4>>2]&-2)|0,u=y+c[b>>2]|0,c[b>>2]=u,c[(b+(u&-4)|0)-4>>2]=u,s=s+y|0,a=a-y|0,c[s>>2]=a);t:{if(h+24>>>0<=a>>>0){u=(s+h|0)+8|0,a=(a-h|0)-8|0,c[u>>2]=a,c[(u+(a&-4)|0)-4>>2]=a|1,y=c[u>>2]-8|0;i:{if(y>>>0<=127){a=(y>>>3|0)-1|0;break i}if(b=Ai(y),a=((y>>>29-b^4)-(b<<2)|0)+110|0,y>>>0<=4095)break i;a=((y>>>30-b^2)-(b<<1)|0)+71|0,a=a>>>0>=63?63:a}y=a<<4,c[u+4>>2]=y+5968,y=y+5976|0,c[u+8>>2]=c[y>>2],c[y>>2]=u,c[c[u+8>>2]+4>>2]=u,y=c[1750],b=c[1751],u=a&31,(a&63)>>>0>=32?(a=1<<u,u=0):(k=1<<u,a=k-1&1>>>32-u,u=k),c[1750]=u|y,c[1751]=a|b,a=h+8|0,c[s>>2]=a,c[((a&-4)+s|0)-4>>2]=a;break t}c[(s+a|0)-4>>2]=a}s=s+4|0}else s=0;return s}function Nk(s,a){s=s|0,a=a|0;var h=0,u=0,y=0,b=0;y=St-320|0,St=y,s=c[s>>2];t:{if(c[s+560>>2]==c[s+556>>2]||(u=c[a>>2],a=c[u+552>>2],!$2(s,u)))break t;if((s|0)==(a|0)){for(h=Vr(y,0,288),a=h,c[a+16>>2]=2143289344,c[a+20>>2]=2143289344,Vr(a+24|0,0,49),c[a+80>>2]=2143289344,b=a+288|0,a=a+96|0;c[a+16>>2]=-1082130432,c[a+20>>2]=-1082130432,c[a+8>>2]=0,c[a+12>>2]=0,c[a>>2]=-1082130432,c[a+4>>2]=-1082130432,a=a+24|0,(b|0)!=(a|0););c[h+312>>2]=-1082130432,c[h+316>>2]=-1082130432,c[h+304>>2]=0,c[h+308>>2]=0,c[h+296>>2]=-1082130432,c[h+300>>2]=-1082130432,c[h+288>>2]=2143289344,c[h+292>>2]=2143289344,Hr(u+228|0,h,320),c[u+552>>2]=0}for(;;){if(a=Tt[s+4|0],a&4)break t;if(pt[s+4|0]=a|4,a=c[s+20>>2],a&&$t[a|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}St=y+320|0}function S2(s){s=s|0;var a=0,h=0,u=0,y=0,b=0,k=0,S=0;if(s){if(k=St-32|0,St=k,a=c[s>>2],u=c[a+552>>2],u&&($2(u,a),c[a+552>>2]=0),u=c[a+556>>2],h=c[a+560>>2],(u|0)!=(h|0))for(h=h-u>>2,y=h>>>0<=1?1:h,h=0;c[c[(h<<2)+u>>2]+552>>2]=0,h=h+1|0,(y|0)!=(h|0););c[a+560>>2]=u,h=a+564|0;t:{if(c[h>>2]==(u|0)||(h=Ya(k+8|0,0,0,h),y=c[a+556>>2],b=c[a+560>>2]-y|0,u=c[h+4>>2]-b|0,b=Bs(u,y,b),y=c[a+556>>2],c[a+556>>2]=b,c[h+4>>2]=y,b=c[a+560>>2],c[a+560>>2]=c[h+8>>2],c[h+8>>2]=b,S=c[a+564>>2],c[a+564>>2]=c[h+12>>2],c[h>>2]=y,c[h+12>>2]=S,(y|0)!=(b|0)&&(c[h+8>>2]=b+((y-b|0)+3&-4)),!y))break t;Ar(y),u=c[a+556>>2]}u&&(c[a+560>>2]=u,Ar(u)),Ar(a),a=c[s+8>>2],c[s+8>>2]=0,a&&$t[c[c[a>>2]+4>>2]](a),a=c[s+4>>2],c[s+4>>2]=0,a&&$t[c[c[a>>2]+4>>2]](a),St=k+32|0,Ar(s)}}function Fk(s){s=s|0;var a=0,h=0,u=0;u=St-624|0,St=u,a=c[s+4>>2],c[s+4>>2]=0,a&&$t[c[c[a>>2]+4>>2]](a),a=c[s+8>>2],c[s+8>>2]=0,a&&$t[c[c[a>>2]+4>>2]](a);t:{if(s=c[s>>2],c[s+560>>2]==c[s+556>>2]){if(c[s+552>>2])break t;a=b2(u+32|0,c[s+568>>2]),h=c[a+4>>2],c[s>>2]=c[a>>2],c[s+4>>2]=h,h=c[a+20>>2],c[s+16>>2]=c[a+16>>2],c[s+20>>2]=h,h=c[a+12>>2],c[s+8>>2]=c[a+8>>2],c[s+12>>2]=h,Hr(s+24|0,a+24|0,204),Hr(s+228|0,a+228|0,328),h=c[s+556>>2],h&&(c[s+560>>2]=h,Ar(h)),c[s+556>>2]=c[a+556>>2],c[s+560>>2]=c[a+560>>2],c[s+564>>2]=c[a+564>>2],c[s+584>>2]=c[a+584>>2],h=c[a+580>>2],c[s+576>>2]=c[a+576>>2],c[s+580>>2]=h,h=c[a+572>>2],c[s+568>>2]=c[a+568>>2],c[s+572>>2]=h,St=u+624|0;return}c[u+16>>2]=3301,li(s,u+16|0),ti(),pe()}c[u>>2]=2047,li(s,u),ti(),pe()}function R2(){xk(7084,3067),Ik(7085,2480,1,1,0),fs(7086,2140,1,-128,127),fs(7087,2133,1,-128,127),fs(7088,2131,1,0,255),fs(7089,1287,2,-32768,32767),fs(7090,1278,2,0,65535),fs(7091,1316,4,-2147483648,2147483647),fs(7092,1307,4,0,-1),fs(7093,2659,4,-2147483648,2147483647),fs(7094,2650,4,0,-1),ig(7095,1777,-2147483648,2147483647),ig(7096,1776,0,-1),u2(7097,1770,4),u2(7098,3015,8),f2(7099,2677),f2(7100,3904),qh(7101,4,2664),qh(7102,2,2689),qh(7103,4,2704),Ck(7104,2485),Cr(7105,0,3835),Cr(7106,0,3937),Cr(7107,1,3865),Cr(7108,2,3467),Cr(7109,3,3498),Cr(7110,4,3538),Cr(7111,5,3567),Cr(7112,4,3974),Cr(7113,5,4004),Cr(7106,0,3669),Cr(7107,1,3636),Cr(7108,2,3735),Cr(7109,3,3701),Cr(7110,4,3802),Cr(7111,5,3768),Cr(7114,6,3605),Cr(7115,7,4043)}function Bs(s,a,h){var u=0,y=0;t:{if((s|0)==(a|0))break t;if(y=s+h|0,a-y>>>0<=0-(h<<1)>>>0)return Hr(s,a,h);u=(s^a)&3;i:{r:{if(s>>>0<a>>>0){if(u){u=s;break i}if(!(s&3)){u=s;break r}for(u=s;;){if(!h)break t;if(pt[u|0]=Tt[a|0],a=a+1|0,h=h-1|0,u=u+1|0,!(u&3))break}break r}e:{if(u)break e;if(y&3)for(;;){if(!h)break t;if(h=h-1|0,u=h+s|0,pt[u|0]=Tt[a+h|0],!(u&3))break}if(h>>>0<=3)break e;for(;h=h-4|0,c[h+s>>2]=c[a+h>>2],h>>>0>3;);}if(!h)break t;for(;h=h-1|0,pt[h+s|0]=Tt[a+h|0],!!h;);break t}if(h>>>0<=3)break i;for(;c[u>>2]=c[a>>2],a=a+4|0,u=u+4|0,h=h-4|0,h>>>0>3;);}if(!h)break t;for(;pt[u|0]=Tt[a|0],u=u+1|0,a=a+1|0,h=h-1|0,!!h;);}return s}function _2(s,a,h,u){t:switch(a-9|0){case 0:a=c[h>>2],c[h>>2]=a+4,c[s>>2]=c[a>>2];return;case 6:a=c[h>>2],c[h>>2]=a+4,a=Vi[a>>1],c[s>>2]=a,c[s+4>>2]=a>>31;return;case 7:a=c[h>>2],c[h>>2]=a+4,c[s>>2]=Hn[a>>1],c[s+4>>2]=0;return;case 8:a=c[h>>2],c[h>>2]=a+4,a=pt[a|0],c[s>>2]=a,c[s+4>>2]=a>>31;return;case 9:a=c[h>>2],c[h>>2]=a+4,c[s>>2]=Tt[a|0],c[s+4>>2]=0;return;case 16:a=c[h>>2]+7&-8,c[h>>2]=a+8,je[s>>3]=je[a>>3];return;case 17:$t[u|0](s,h);default:return;case 1:case 4:case 14:a=c[h>>2],c[h>>2]=a+4,a=c[a>>2],c[s>>2]=a,c[s+4>>2]=a>>31;return;case 2:case 5:case 11:case 15:a=c[h>>2],c[h>>2]=a+4,c[s>>2]=c[a>>2],c[s+4>>2]=0;return;case 3:case 10:case 12:case 13:break t}a=c[h>>2]+7&-8,c[h>>2]=a+8,h=c[a+4>>2],c[s>>2]=c[a>>2],c[s+4>>2]=h}function L2(s,a,h,u){var y=0,b=0,k=0,S=0,P=0,z=0,tt=0,dt=0,Q=0,et=m(0),$=m(0),W=m(0),Y=0,q=m(0);t:{if(a==0||(et=I[s+248>>2],$=I[s+244>>2],W=I[s+232>>2],P=+I[s+228>>2],y=Tt[s+4|0]&8,b=y>>>3|0,Y=s,q=Ki(P,a,0,b),I[Y+228>>2]=q,z=+W,Y=s,q=Ki(z,a,0,b),I[Y+232>>2]=q,tt=+$,k=ed(tt*a),b=k==k&Xe(k)<1e-4,S=!(b|k!=k?b:Xe(k+-1)<1e-4),dt=+et,k=ed(dt*a),b=k==k&Xe(k)<1e-4,Q=!(b|k!=k?b:Xe(k+-1)<1e-4),b=0,h=P+h,y=(y|0)!=0,Y=s,q=m(Ki(h+tt,a,y&S,y&!S)-Ki(h,a,0,y)),I[Y+244>>2]=q,u=z+u,Y=s,q=m(Ki(u+dt,a,y&Q,y&!Q)-Ki(u,a,0,y)),I[Y+248>>2]=q,y=c[s+560>>2],S=c[s+556>>2],(y|0)==(S|0)))break t;for(y=y-S>>2,S=y>>>0<=1?1:y;y=c[s+556>>2],c[s+560>>2]-y>>2>>>0>b>>>0?y=c[y+(b<<2)>>2]:y=0,L2(y,a,h,u),b=b+1|0,(S|0)!=(b|0););}}function Vr(s,a,h){var u=0,y=0,b=0,k=0;t:{if(!h||(pt[s|0]=a,u=s+h|0,pt[u-1|0]=a,h>>>0<3)||(pt[s+2|0]=a,pt[s+1|0]=a,pt[u-3|0]=a,pt[u-2|0]=a,h>>>0<7)||(pt[s+3|0]=a,pt[u-4|0]=a,h>>>0<9)||(u=0-s&3,y=u+s|0,a=Ke(a&255,16843009),c[y>>2]=a,u=h-u&-4,h=u+y|0,c[h-4>>2]=a,u>>>0<9)||(c[y+8>>2]=a,c[y+4>>2]=a,c[h-8>>2]=a,c[h-12>>2]=a,u>>>0<25)||(c[y+24>>2]=a,c[y+20>>2]=a,c[y+16>>2]=a,c[y+12>>2]=a,c[h-16>>2]=a,c[h-20>>2]=a,c[h-24>>2]=a,c[h-28>>2]=a,k=y&4|24,h=u-k|0,h>>>0<32))break t;for(u=od(a,0,1,1),b=Gr,a=y+k|0;c[a+24>>2]=u,c[a+28>>2]=b,c[a+16>>2]=u,c[a+20>>2]=b,c[a+8>>2]=u,c[a+12>>2]=b,c[a>>2]=u,c[a+4>>2]=b,a=a+32|0,h=h-32|0,h>>>0>31;);}return s}function Ar(s){s=s|0;var a=0,h=0,u=0,y=0,b=0;if(s){a=s-4|0,y=c[a>>2],h=y,u=a,b=c[s-8>>2],s=b&-2,(s|0)!=(b|0)&&(u=a-s|0,h=c[u+4>>2],c[h+8>>2]=c[u+8>>2],c[c[u+8>>2]+4>>2]=h,h=s+y|0),s=a+y|0,a=c[s>>2],(a|0)!=c[(s+a|0)-4>>2]&&(y=c[s+4>>2],c[y+8>>2]=c[s+8>>2],c[c[s+8>>2]+4>>2]=y,h=a+h|0),c[u>>2]=h,c[((h&-4)+u|0)-4>>2]=h|1,a=c[u>>2]-8|0;t:{if(a>>>0<=127){s=(a>>>3|0)-1|0;break t}if(h=Ai(a),s=((a>>>29-h^4)-(h<<2)|0)+110|0,a>>>0<=4095)break t;s=((a>>>30-h^2)-(h<<1)|0)+71|0,s=s>>>0>=63?63:s}a=s<<4,c[u+4>>2]=a+5968,a=a+5976|0,c[u+8>>2]=c[a>>2],c[a>>2]=u,c[c[u+8>>2]+4>>2]=u,a=c[1750],h=c[1751],u=s&31,(s&63)>>>0>=32?(s=1<<u,y=0):(y=1<<u,s=y-1&1>>>32-u),c[1750]=y|a,c[1751]=s|h}}function Uk(s,a,h){s=s|0,a=a|0,h=h|0;var u=0,y=0,b=0,k=0,S=0,P=0,z=0;u=St-32|0,St=u,y=c[s+28>>2],c[u+16>>2]=y,b=c[s+20>>2],c[u+28>>2]=h,c[u+24>>2]=a,a=b-y|0,c[u+20>>2]=a,b=a+h|0,P=2,a=u+16|0;t:{for(;;){i:{r:{e:{if(!eg(_k(c[s+60>>2],a|0,P|0,u+12|0)|0)){if(k=c[u+12>>2],(k|0)==(b|0))break e;if((k|0)>=0)break r;break i}if((b|0)!=-1)break i}a=c[s+44>>2],c[s+28>>2]=a,c[s+20>>2]=a,c[s+16>>2]=a+c[s+48>>2],s=h;break t}S=c[a+4>>2],z=S>>>0<k>>>0,y=(z<<3)+a|0,S=k-(z?S:0)|0,c[y>>2]=S+c[y>>2],a=(z?12:4)+a|0,c[a>>2]=c[a>>2]-S,b=b-k|0,P=P-z|0,a=y;continue}break}if(c[s+28>>2]=0,c[s+16>>2]=0,c[s+20>>2]=0,c[s>>2]=c[s>>2]|32,s=0,(P|0)==2)break t;s=h-c[a+4>>2]|0}return St=u+32|0,s|0}function Bk(s){s=s|0;var a=0,h=0,u=0,y=0,b=0;h=St-96|0,St=h,c[h>>2]=s,u=St-16|0,St=u,c[u+12>>2]=h,s=St-144|0,St=s,s=Hr(s,5520,144),b=h+16|0,a=b,c[s+44>>2]=a,c[s+20>>2]=a,y=-2-a|0,y=y>>>0>=2147483647?2147483647:y,c[s+48>>2]=y,a=a+y|0,c[s+28>>2]=a,c[s+16>>2]=a,C2(s,2202,h,0,0),y&&(a=c[s+20>>2],pt[a-((a|0)==c[s+16>>2])|0]=0),St=s+144|0,St=u+16|0,s=b;t:{if(s&3)for(;;){if(!Tt[s|0])break t;if(s=s+1|0,!(s&3))break}for(;a=s,s=s+4|0,u=c[a>>2],!((u^-1)&u-16843009&-2139062144););for(;s=a,a=s+1|0,!!Tt[s|0];);}return s=(s-b|0)+1|0,a=td(s),a?s=Hr(a,b,s):s=0,St=h+96|0,s|0}function C2(s,a,h,u,y){var b=0,k=0,S=0,P=0;b=St-208|0,St=b,c[b+204>>2]=h,h=b+160|0,Vr(h,0,40),c[b+200>>2]=c[b+204>>2];t:{if((y2(0,a,b+200|0,b+80|0,h,u,y)|0)<0){y=-1;break t}P=c[s+76>>2]>=0,k=c[s>>2],c[s+72>>2]<=0&&(c[s>>2]=k&-33);i:{r:{e:{if(!c[s+48>>2]){c[s+48>>2]=80,c[s+28>>2]=0,c[s+16>>2]=0,c[s+20>>2]=0,S=c[s+44>>2],c[s+44>>2]=b;break e}if(c[s+16>>2])break r}if(h=-1,H2(s))break i}h=y2(s,a,b+200|0,b+80|0,b+160|0,u,y)}if(S&&($t[c[s+36>>2]](s,0,0)|0,c[s+48>>2]=0,c[s+44>>2]=S,c[s+28>>2]=0,a=c[s+20>>2],c[s+16>>2]=0,c[s+20>>2]=0,h=a?h:-1),a=s,s=c[s>>2],c[a>>2]=s|k&32,y=s&32?-1:h,!P)break t}return St=b+208|0,y}function Al(s){var a=0,h=m(0),u=0,y=0,b=0,k=0,S=0,P=m(0),z=0;b=St-16|0,St=b,a=c[s+12>>2];t:{if(a){P=I[s+520>>2],h=I[s+516>>2];i:{if(Tt[s+4|0]&32){h=m($t[a|0](s,h,P,0));break i}h=m($t[a|0](s,h,P))}if(h==h)break t;c[b>>2]=3409,li(s,b),ti(),pe()}i:{r:{if(k=c[s+556>>2],a=c[s+560>>2],(k|0)!=(a|0)){for(a=a-k>>2,z=a>>>0<=1?1:a;;){if(y=c[(S<<2)+k>>2],!c[y+548>>2]){if(a=c[y+24>>2],(a&196608)!=131072){if(a=a>>>13&7,a||(a=c[s+24>>2]>>>10&7),Tt[y+4|0]&2|(Tt[s+24|0]&8?(a|0)==5:0))break r;u=u||y}if(S=S+1|0,(z|0)!=(S|0))continue}break}if(u)break i}h=I[s+520>>2];break t}u=y}h=m(Al(u)+I[u+232>>2])}return St=b+16|0,h}function Wn(s,a,h,u,y,b){var k=0,S=m(0),P=0,z=m(0);k=(c[(a<<2)+4320>>2]<<2)+s|0,S=I[k+216>>2];t:{i:{k=c[k+216>>2];r:{if((k|0)==2139156720)break r;if((k|0)==2140081935)break i;P=4336;e:{if((k|0)!=2141891242){if(S==S)break e;P=4344}switch(z=I[P>>2],S=m(zt),c[P+4>>2]-1|0){case 0:break i;case 1:break r;default:break t}}if(z=(Ot(2,(k&-1073741825)+536870912|0),Gt()),!(k&1073741824))break i}S=m(m(z*h)*m(.009999999776482582));break t}S=z}u=m(S+m(ge(s,a,u)+Re(s,a,u)));t:{i:{r:switch(c[y>>2]){case 1:case 2:h=I[b>>2],u=u!=u||h<u?h:u;break i;case 0:break r;default:break t}if(u!=u)break t;c[y>>2]=2}I[b>>2]=u}}function Ne(s,a,h){var u=m(0),y=m(0),b=0,k=m(0);s=s+116|0,b=c[(a<<2)+4288>>2];t:{if((a&-2)==2){a=Wi(s,4,b,2140081935);break t}a=ji(s,b,2140081935)}t:{i:{r:{e:{if((a|0)==2139156720)break e;if((a|0)==2140081935)break t;s=4336;s:{if((a|0)!=2141891242){if(u=(Ot(2,a),Gt()),u==u)break s;s=4344}switch(u=I[s>>2],y=m(zt),c[s+4>>2]-1|0){case 0:break r;case 1:break e;default:break i}}if(u=(Ot(2,(a&-1073741825)+536870912|0),Gt()),!(a&1073741824))break r}u=m(m(u*h)*m(.009999999776482582))}if(u>=m(0))return u;if(y=u,u<m(0))break t}k=y==y?y:m(0)}return k}function Fe(s,a,h){var u=m(0),y=m(0),b=0,k=m(0);s=s+116|0,b=c[(a<<2)+4304>>2];t:{if((a&-2)==2){a=Wi(s,5,b,2140081935);break t}a=ji(s,b,2140081935)}t:{i:{r:{e:{if((a|0)==2139156720)break e;if((a|0)==2140081935)break t;s=4336;s:{if((a|0)!=2141891242){if(u=(Ot(2,a),Gt()),u==u)break s;s=4344}switch(u=I[s>>2],y=m(zt),c[s+4>>2]-1|0){case 0:break r;case 1:break e;default:break i}}if(u=(Ot(2,(a&-1073741825)+536870912|0),Gt()),!(a&1073741824))break r}u=m(m(u*h)*m(.009999999776482582))}if(u>=m(0))return u;if(y=u,u<m(0))break t}k=y==y?y:m(0)}return k}function I2(s,a,h,u,y,b){var k=0;t:{i:{if(s){r:{if(a&4){b=$t[s|0](h,u,y,b)|0;break r}b=$t[s|0](h,u,y)|0}if(b)break i}if(b=ht(588),a=Hr(b,h,552),c[a+564>>2]=0,c[a+556>>2]=0,c[a+560>>2]=0,y=c[h+556>>2],u=c[h+560>>2],(y|0)!=(u|0)){if(k=u-y|0,(k|0)<0)break t;for(s=ht(k),c[a+556>>2]=s,c[a+564>>2]=s+k;c[s>>2]=c[y>>2],s=s+4|0,y=y+4|0,(u|0)!=(y|0););c[a+560>>2]=s}s=c[h+572>>2],c[a+568>>2]=c[h+568>>2],c[a+572>>2]=s,c[a+584>>2]=c[h+584>>2],s=c[h+580>>2],c[a+576>>2]=c[h+576>>2],c[a+580>>2]=s,c[a+552>>2]=0}return b}Us(),pe()}function li(s,a){var h=0,u=0,y=0;y=St-16|0,St=y,c[y+12>>2]=a;t:{i:{if(!s){a=c[y+12>>2];break i}if(a=c[y+12>>2],h=c[s+568>>2],!h)break i;if(u=c[h+4>>2],Tt[h+8|0]&8){$t[u|0](h,s,5,0,4284,a)|0;break t}$t[u|0](h,s,5,4284,a)|0;break t}i:{if(!Tt[7016]){h=ht(28),c[h+20>>2]=1065353216,c[h+24>>2]=0,c[h+12>>2]=0,c[h+16>>2]=0,c[h>>2]=0,pt[h+8|0]=0,u=1,c[h+4>>2]=1,c[1753]=h,pt[7016]=1,c[1752]=c[1752]+1;break i}if(h=c[1753],u=c[h+4>>2],!(Tt[h+8|0]&8))break i;$t[u|0](h,s,5,0,4284,a)|0;break t}$t[u|0](h,s,5,4284,a)|0}St=y+16|0}function za(s,a,h){var u=m(0),y=0,b=m(0);s=s+80|0,y=c[(a<<2)+4304>>2];t:{i:{if((a&-2)==2){a=Wi(s,5,y,2140081935);break i}a=ji(s,y,2140081935)}i:{r:{if((a|0)==2139156720)break r;if((a|0)==2140081935)break t;s=4336;e:{if((a|0)!=2141891242){if(u=(Ot(2,a),Gt()),u==u)break e;s=4344}switch(u=I[s>>2],b=m(zt),c[s+4>>2]-1|0){case 0:break t;case 1:break r;default:break i}}if(u=(Ot(2,(a&-1073741825)+536870912|0),Gt()),!(a&1073741824))break t}b=m(m(u*h)*m(.009999999776482582))}return b}return u}function Gs(s,a,h){var u=m(0),y=0,b=m(0);s=s+80|0,y=c[(a<<2)+4288>>2];t:{i:{if((a&-2)==2){a=Wi(s,4,y,2140081935);break i}a=ji(s,y,2140081935)}i:{r:{if((a|0)==2139156720)break r;if((a|0)==2140081935)break t;s=4336;e:{if((a|0)!=2141891242){if(u=(Ot(2,a),Gt()),u==u)break e;s=4344}switch(u=I[s>>2],b=m(zt),c[s+4>>2]-1|0){case 0:break t;case 1:break r;default:break i}}if(u=(Ot(2,(a&-1073741825)+536870912|0),Gt()),!(a&1073741824))break t}b=m(m(u*h)*m(.009999999776482582))}return b}return u}function Wi(s,a,h,u){var y=m(0);a=(a<<2)+s|0,y=I[a>>2],a=c[a>>2];t:{if((a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|y==y||(a=(h<<2)+s|0,y=I[a>>2],a=c[a>>2],(a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|y==y)||(a=c[s+24>>2],y=I[s+24>>2],(a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|y==y)||(y=I[s+32>>2],s=c[s+32>>2],!((s|0)==2139156720|(s|0)==2140081935|(s|0)==2141891242)&&(a=u,y!=y)))break t;a=s}return a}function Gk(s,a){s=s|0,a=m(a);var h=0,u=0,y=0;if(h=St-16|0,St=h,s=c[s>>2],!(a>=m(0))){c[h>>2]=2263,u=St-16|0,St=u,c[u+12>>2]=h;t:{if(s)break t;if(Tt[7016]){s=c[1753];break t}s=ht(28),c[s+20>>2]=1065353216,c[s+24>>2]=0,c[s+12>>2]=0,c[s+16>>2]=0,c[s>>2]=0,pt[s+8|0]=0,c[s+4>>2]=1,c[1753]=s,pt[7016]=1,c[1752]=c[1752]+1}y=c[s+4>>2];t:{if(Tt[s+8|0]&8){$t[y|0](s,0,5,0,4284,h)|0;break t}$t[y|0](s,0,5,4284,h)|0}St=u+16|0,ti(),pe()}I[s+20>>2]=a==m(0)?m(0):a,St=h+16|0}function x2(s,a,h,u,y){var b=0,k=0,S=m(0),P=0;b=2,k=c[s+24>>2]>>>2&3;t:{i:{r:{if(!(!c[s+552>>2]|(a|0)!=2)){a=0,b=3;e:switch(k-2|0){case 0:break t;case 1:break e;default:break r}b=2;break t}if(a=0,k>>>0>1)break i}a=b}b=k}h=q2(s,b,h),u=q2(s,a,u),S=ge(s,b,y),k=s+228|0,P=b<<2,I[k+(c[P+4288>>2]<<2)>>2]=h+S,S=Re(s,b,y),I[k+(c[P+4304>>2]<<2)>>2]=h+S,h=ge(s,a,y),b=a<<2,I[k+(c[b+4288>>2]<<2)>>2]=u+h,h=Re(s,a,y),I[k+(c[b+4304>>2]<<2)>>2]=u+h}function Hk(s,a,h,u,y,b){s=s|0,a=a|0,h=m(h),u=u|0,y=m(y),b=b|0;var k=0,S=0,P=0;k=St-48|0,St=k,P=c[a+8>>2];t:{if(pt[7052]&1){a=c[1762];break t}a=d2(5,4480)|0,pt[7052]=1,c[1762]=a}c[k+40>>2]=b,I[k+32>>2]=y,c[k+24>>2]=u,I[k+16>>2]=h,S=+Ak(a|0,P|0,2922,k+12|0,k+16|0);t:{if(S<4294967296&S>=0){a=~~S>>>0;break t}a=0}u=c[k+12>>2],b=c[a+4>>2],c[s>>2]=c[a>>2],c[s+4>>2]=b,b=c[a+12>>2],c[s+8>>2]=c[a+8>>2],c[s+12>>2]=b,Ek(u|0),St=k+48|0}function Vk(s,a,h){s=s|0,a=a|0,h=h|0;var u=0,y=0,b=0,k=0;if(u=St-32|0,St=u,y=c[a>>2],y>>>0<2147483632){t:{i:{if(y>>>0>=11){b=(y|15)+1|0,k=ht(b),c[u+16>>2]=b|-2147483648,c[u+8>>2]=k,c[u+12>>2]=y,b=y+k|0;break i}if(pt[u+19|0]=y,k=u+8|0,b=k+y|0,!y)break t}Hr(k,a+4|0,y)}return pt[b|0]=0,c[u>>2]=h,$t[s|0](u+24|0,u+8|0,u),bk(c[u+24>>2]),s=c[u+24>>2],Ka(s|0),Ka(c[u>>2]),pt[u+19|0]<0&&Ar(c[u+8>>2]),St=u+32|0,s|0}Us(),pe()}function pr(s,a,h){var u=0,y=0,b=0;if(!(Tt[s|0]&32))t:{u=a,a=s,s=c[a+16>>2];i:{if(!s){if(H2(a))break i;s=c[a+16>>2]}if(b=c[a+20>>2],s-b>>>0<h>>>0){$t[c[a+36>>2]](a,u,h)|0;break t}r:{if(c[a+80>>2]<0)break r;for(s=h;;){if(y=s,!s)break r;if(s=y-1|0,Tt[u+s|0]==10)break}if($t[c[a+36>>2]](a,u,y)>>>0<y>>>0)break i;u=u+y|0,h=h-y|0,b=c[a+20>>2]}Hr(b,u,h),c[a+20>>2]=c[a+20>>2]+h}}}function sd(s,a,h){var u=0,y=0,b=0;u=St-16|0,St=u,y=s+24|0,$t[a|0](u+8|0,y),b=c[u+12>>2];t:{if((c[c[u+8>>2]>>2]&7<<b)>>b==(h|0))break t;for($t[a|0](u+8|0,y),a=c[u+8>>2],y=a,b=c[a>>2],a=c[u+12>>2],c[y>>2]=b&(7<<a^-1)|(h&7)<<a;;){if(a=Tt[s+4|0],a&4)break t;if(pt[s+4|0]=a|4,a=c[s+20>>2],a&&$t[a|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}St=u+16|0}function ji(s,a,h){var u=m(0);a=(a<<2)+s|0,u=I[a>>2],a=c[a>>2];t:{if((a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|u==u||(a=c[s+28>>2],u=I[s+28>>2],(a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|u==u)||(u=I[s+32>>2],s=c[s+32>>2],!((s|0)==2139156720|(s|0)==2140081935|(s|0)==2141891242)&&(a=h,u!=u)))break t;a=s}return a}function Re(s,a,h){var u=m(0),y=0;s=s+44|0,y=c[(a<<2)+4304>>2];t:{if((a&-2)==2){s=Wi(s,5,y,2140081935);break t}s=ji(s,y,2140081935)}t:{if((s|0)!=2139156720){if((s|0)==2140081935|(s|0)==2141891242)break t;if(u=(Ot(2,s),Gt()),u!=u)return m(zt);if(u=(Ot(2,(s&-1073741825)+536870912|0),Gt()),!(s&1073741824))break t}u=m(m(u*h)*m(.009999999776482582))}return u}function ge(s,a,h){var u=m(0),y=0;s=s+44|0,y=c[(a<<2)+4288>>2];t:{if((a&-2)==2){s=Wi(s,4,y,2140081935);break t}s=ji(s,y,2140081935)}t:{if((s|0)!=2139156720){if((s|0)==2140081935|(s|0)==2141891242)break t;if(u=(Ot(2,s),Gt()),u!=u)return m(zt);if(u=(Ot(2,(s&-1073741825)+536870912|0),Gt()),!(s&1073741824))break t}u=m(m(u*h)*m(.009999999776482582))}return u}function Wk(s,a,h){s=s|0,a=a|0,h=h|0;var u=0,y=0,b=0,k=0,S=0;return y=c[s+84>>2],b=c[y>>2],u=c[y+4>>2],S=c[s+28>>2],k=c[s+20>>2]-S|0,k=u>>>0<k>>>0?u:k,k&&(Hr(b,S,k),b=k+c[y>>2]|0,c[y>>2]=b,u=c[y+4>>2]-k|0,c[y+4>>2]=u),u=h>>>0>u>>>0?u:h,u&&(Hr(b,a,u),b=u+c[y>>2]|0,c[y>>2]=b,c[y+4>>2]=c[y+4>>2]-u),pt[b|0]=0,a=c[s+44>>2],c[s+28>>2]=a,c[s+20>>2]=a,h|0}function _e(s,a){var h=m(0),u=0;s=s+152|0,u=c[(a<<2)+4304>>2];t:{if((a&-2)==2){s=Wi(s,5,u,2140081935);break t}s=ji(s,u,2140081935)}h=m(0);t:{if((s|0)==2139156720||(h=m(0),(s|0)==2140081935))break t;i:{if((s|0)==2141891242||(h=(Ot(2,s),Gt()),h!=h))break i;h=(Ot(2,(s&-1073741825)+536870912|0),Gt());break t}h=m(zt)}return fe(h,m(0))}function ve(s,a){var h=m(0),u=0;s=s+152|0,u=c[(a<<2)+4288>>2];t:{if((a&-2)==2){s=Wi(s,4,u,2140081935);break t}s=ji(s,u,2140081935)}h=m(0);t:{if((s|0)==2139156720||(h=m(0),(s|0)==2140081935))break t;i:{if((s|0)==2141891242||(h=(Ot(2,s),Gt()),h!=h))break i;h=(Ot(2,(s&-1073741825)+536870912|0),Gt());break t}h=m(zt)}return fe(h,m(0))}function jk(s,a,h){s=s|0,a=a|0,h=h|0;var u=0,y=0,b=m(0);u=2,a=c[a>>2]+(h<<2)|0,b=I[a+116>>2];t:{i:{if(a=c[a+116>>2],(a|0)!=2139156720){if(y=zt,(a|0)==2141891242){u=3;break t}if((a|0)!=2140081935)break i;y=0,u=1;break t}break t}if(b!=b){u=0;break t}u=a&1073741824?2:1,y=(Ot(2,(a&-1073741825)+536870912|0),+Gt())}je[s+8>>3]=y,c[s>>2]=u}function Kk(s,a,h){s=s|0,a=a|0,h=h|0;var u=0,y=0,b=m(0);u=2,a=c[a>>2]+(h<<2)|0,b=I[a+80>>2];t:{i:{if(a=c[a+80>>2],(a|0)!=2139156720){if(y=zt,(a|0)==2141891242){u=3;break t}if((a|0)!=2140081935)break i;y=0,u=1;break t}break t}if(b!=b){u=0;break t}u=a&1073741824?2:1,y=(Ot(2,(a&-1073741825)+536870912|0),+Gt())}je[s+8>>3]=y,c[s>>2]=u}function zk(s,a,h){s=s|0,a=a|0,h=h|0;var u=0,y=0,b=m(0);u=2,a=c[a>>2]+(h<<2)|0,b=I[a+44>>2];t:{i:{if(a=c[a+44>>2],(a|0)!=2139156720){if(y=zt,(a|0)==2141891242){u=3;break t}if((a|0)!=2140081935)break i;y=0,u=1;break t}break t}if(b!=b){u=0;break t}u=a&1073741824?2:1,y=(Ot(2,(a&-1073741825)+536870912|0),+Gt())}je[s+8>>3]=y,c[s>>2]=u}function Ki(s,a,h,u){var y=0,b=0,k=0;s=s*a,y=ed(s),y=y<0?y+1:y,k=y!=y;t:{if(!(k|!(Xe(y)<1e-4))){s=s-y;break t}i:{if(y!=y){s=s-y;break i}if(s=s-y,!(Xe(y+-1)<1e-4))break i;s=s+1;break t}if(h){s=s+1;break t}if(u)break t;b=0;i:{if(k||(b=1,y>.5))break i;b=Xe(y+-.5)<1e-4?1:0}s=s+b}return s!=s|a!=a?m(zt):m(s/a)}function D2(s,a){var h=m(0);t:{if((a|0)!=2139156720){if((a|0)!=2140081935){if((a|0)!=2141891242)break t;c[s>>2]=2143289344,c[s+4>>2]=3;return}c[s>>2]=0,c[s+4>>2]=1;return}c[s>>2]=0,c[s+4>>2]=2;return}if(h=(Ot(2,a),Gt()),h!=h){c[s>>2]=2143289344,c[s+4>>2]=0;return}c[s+4>>2]=a&1073741824?2:1,c[s>>2]=(a&-1073741825)+536870912}function P2(s){var a=0,h=0,u=0;h=c[s+24>>2];t:{if(!(h&8)||(a=1,(h&7168)==5120)||(a=0,u=c[s+560>>2],h=c[s+556>>2],(u|0)==(h|0)))break t;for(s=u-h>>2,u=s>>>0<=1?1:s,s=0;;){if(a=c[c[h+(s<<2)>>2]+24>>2],a=(a&196608)!=131072&(a&57344)==40960,a)break t;if(s=s+1|0,(u|0)==(s|0))break}}return a}function Yk(s,a){s=s|0,a=a|0;var h=0,u=0,y=m(0);a=c[a>>2],y=I[a+220>>2];t:{i:{if(a=c[a+220>>2],(a|0)!=2139156720){if(u=zt,h=3,(a|0)==2141891242)break t;if((a|0)!=2140081935)break i;u=0,h=1;break t}h=2;break t}if(h=0,y!=y)break t;u=(Ot(2,(a&-1073741825)+536870912|0),+Gt()),h=a&1073741824?2:1}a=h,je[s+8>>3]=u,c[s>>2]=a}function Xk(s,a){s=s|0,a=a|0;var h=0,u=0,y=m(0);a=c[a>>2],y=I[a+200>>2];t:{i:{if(a=c[a+200>>2],(a|0)!=2139156720){if(u=zt,h=3,(a|0)==2141891242)break t;if((a|0)!=2140081935)break i;u=0,h=1;break t}h=2;break t}if(h=0,y!=y)break t;u=(Ot(2,(a&-1073741825)+536870912|0),+Gt()),h=a&1073741824?2:1}a=h,je[s+8>>3]=u,c[s>>2]=a}function Zk(s,a){s=s|0,a=a|0;var h=0,u=0,y=m(0);a=c[a>>2],y=I[a+204>>2];t:{i:{if(a=c[a+204>>2],(a|0)!=2139156720){if(u=zt,h=3,(a|0)==2141891242)break t;if((a|0)!=2140081935)break i;u=0,h=1;break t}h=2;break t}if(h=0,y!=y)break t;u=(Ot(2,(a&-1073741825)+536870912|0),+Gt()),h=a&1073741824?2:1}a=h,je[s+8>>3]=u,c[s>>2]=a}function qk(s,a){s=s|0,a=a|0;var h=0,u=0,y=m(0);a=c[a>>2],y=I[a+208>>2];t:{i:{if(a=c[a+208>>2],(a|0)!=2139156720){if(u=zt,h=3,(a|0)==2141891242)break t;if((a|0)!=2140081935)break i;u=0,h=1;break t}h=2;break t}if(h=0,y!=y)break t;u=(Ot(2,(a&-1073741825)+536870912|0),+Gt()),h=a&1073741824?2:1}a=h,je[s+8>>3]=u,c[s>>2]=a}function Qk(s,a){s=s|0,a=a|0;var h=0,u=0,y=m(0);a=c[a>>2],y=I[a+212>>2];t:{i:{if(a=c[a+212>>2],(a|0)!=2139156720){if(u=zt,h=3,(a|0)==2141891242)break t;if((a|0)!=2140081935)break i;u=0,h=1;break t}h=2;break t}if(h=0,y!=y)break t;u=(Ot(2,(a&-1073741825)+536870912|0),+Gt()),h=a&1073741824?2:1}a=h,je[s+8>>3]=u,c[s>>2]=a}function Jk(s,a){s=s|0,a=a|0;var h=0,u=0,y=m(0);a=c[a>>2],y=I[a+216>>2];t:{i:{if(a=c[a+216>>2],(a|0)!=2139156720){if(u=zt,h=3,(a|0)==2141891242)break t;if((a|0)!=2140081935)break i;u=0,h=1;break t}h=2;break t}if(h=0,y!=y)break t;u=(Ot(2,(a&-1073741825)+536870912|0),+Gt()),h=a&1073741824?2:1}a=h,je[s+8>>3]=u,c[s>>2]=a}function t3(s,a){s=s|0,a=a|0;var h=0;if(h=St-16|0,St=h,s=c[s>>2],(a|0)<6){St=h+16|0;t:{i:switch(a-4|0){case 0:if(a=s+260|0,(Tt[s+300|0]&3)==2)break t;a=s+252|0;break t;case 1:if(a=s+252|0,(Tt[s+300|0]&3)==2)break t;a=s+260|0;break t;default:break i}a=(s+(a<<2)|0)+252|0}return+I[a>>2]}c[h>>2]=1872,li(s,h),ti(),pe()}function e3(s,a){s=s|0,a=a|0;var h=0;if(h=St-16|0,St=h,s=c[s>>2],(a|0)<6){St=h+16|0;t:{i:switch(a-4|0){case 0:if(a=s+276|0,(Tt[s+300|0]&3)==2)break t;a=s+268|0;break t;case 1:if(a=s+268|0,(Tt[s+300|0]&3)==2)break t;a=s+276|0;break t;default:break i}a=(s+(a<<2)|0)+268|0}return+I[a>>2]}c[h>>2]=1872,li(s,h),ti(),pe()}function r3(s,a){s=s|0,a=a|0;var h=0;if(h=St-16|0,St=h,s=c[s>>2],(a|0)<6){St=h+16|0;t:{i:switch(a-4|0){case 0:if(a=s+292|0,(Tt[s+300|0]&3)==2)break t;a=s+284|0;break t;case 1:if(a=s+284|0,(Tt[s+300|0]&3)==2)break t;a=s+292|0;break t;default:break i}a=(s+(a<<2)|0)+284|0}return+I[a>>2]}c[h>>2]=1872,li(s,h),ti(),pe()}function i3(s,a){s=s|0,a=a|0;var h=0,u=m(0),y=m(0);u=m(zt),a=c[a>>2],y=I[a+40>>2],a=c[a+40>>2],h=3;t:{if((a|0)==2141891242)break t;if((a|0)==2140081935){u=m(0),h=1;break t}if((a|0)==2139156720){u=m(0),h=2;break t}if(h=0,y!=y)break t;u=(Ot(2,(a&-1073741825)+536870912|0),Gt()),h=a&1073741824?2:1}c[s>>2]=h,je[s+8>>3]=u}function zi(s){var a=0,h=m(0);a=2143289344;t:{if(m(Xe(s))==m(h2)|s!=s||(a=2139156720,s<m(10842021724855044e-35)&s>m(-10842021724855044e-35)|s==m(0)))break t;h=(Ot(2,(Jr(s),te(2)&-2147483648|1602224127)),Gt()),a=(Jr(s>m(0xffffff0000000000)||s<m(-0xffffff0000000000)?h:s),te(2)-536870912|1073741824)}return a}function Ti(s){var a=0,h=m(0);a=2143289344;t:{if(m(Xe(s))==m(h2)|s!=s||(a=2140081935,s<m(10842021724855044e-35)&s>m(-10842021724855044e-35)|s==m(0)))break t;h=(Ot(2,(Jr(s),te(2)&-2147483648|1610612735)),Gt()),a=(Jr(s>m(36893485948395848e3)||s<m(-36893485948395848e3)?h:s),te(2)-536870912|0)}return a}function s3(s,a){s=s|0,a=a|0;var h=m(0),u=m(0);s=c[s>>2]+(a<<2)|0,u=I[s+188>>2];t:{i:{if(s=c[s+188>>2],(s|0)==2139156720|(s|0)==2140081935)break i;if(h=m(zt),(s|0)==2141891242|u!=u)break t;if((s|0)==2139156720)break i;return m((Ot(2,(s&-1073741825)+536870912|0),Gt()))}h=m(0)}return m(h)}function n3(s,a,h,u,y,b){s=s|0,a=a|0,h=m(h),u=u|0,y=m(y),b=b|0;var k=0,S=0;return k=St-16|0,St=k,S=c[s>>2],s=c[s+4>>2],a=(s>>1)+a|0,s&1&&(S=c[S+c[a>>2]>>2]),$t[S|0](k,a,h,u,y,b),s=ht(16),a=c[k+12>>2],c[s+8>>2]=c[k+8>>2],c[s+12>>2]=a,a=c[k+4>>2],c[s>>2]=c[k>>2],c[s+4>>2]=a,St=k+16|0,s|0}function O2(s,a){t:{if(a){a=tg(c[a>>2]);break t}i:{if(Tt[7016]){a=c[1753];break i}a=ht(28),c[a+20>>2]=1065353216,c[a+24>>2]=0,c[a+12>>2]=0,c[a+16>>2]=0,c[a>>2]=0,pt[a+8|0]=0,c[a+4>>2]=1,c[1753]=a,pt[7016]=1,c[1752]=c[1752]+1}a=tg(a)}return c[s+4>>2]=0,c[s+8>>2]=0,c[s>>2]=a,c[a>>2]=s,s}function a3(s,a,h){s=s|0,a=a|0,h=+h;var u=0,y=0;t:{if(s=c[s>>2],a=s+(a<<2)|0,y=c[a+152>>2],u=Ti(m(h)),(y|0)==(u|0))break t;for(c[a+152>>2]=u;;){if(a=Tt[s+4|0],a&4)break t;if(pt[s+4|0]=a|4,a=c[s+20>>2],a&&$t[a|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function o3(s,a,h){s=s|0,a=a|0,h=+h;var u=0,y=0;t:{if(s=c[s>>2],a=s+(a<<2)|0,y=c[a+188>>2],u=Ti(m(h)),(y|0)==(u|0))break t;for(c[a+188>>2]=u;;){if(a=Tt[s+4|0],a&4)break t;if(pt[s+4|0]=a|4,a=c[s+20>>2],a&&$t[a|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function l3(s,a){s=s|0,a=a|0;var h=0,u=m(0);s=c[s>>2]+(a<<2)|0,u=I[s+152>>2];t:{i:{if(s=c[s+152>>2],(s|0)==2139156720|(s|0)==2140081935)break i;if(h=zt,(s|0)==2141891242|u!=u)break t;if((s|0)==2139156720)break i;return Ot(2,(s&-1073741825)+536870912|0),+Gt()}h=0}return+h}function c3(s,a){s=s|0,a=a|0;var h=0;t:{if(s=c[s>>2],h=c[s+24>>2],(h>>>20&3)==(a|0))break t;for(c[s+24>>2]=h&-3145729|a<<20&3145728;;){if(a=Tt[s+4|0],a&4)break t;if(pt[s+4|0]=a|4,a=c[s+20>>2],a&&$t[a|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function jn(s,a,h){var u=0,y=0,b=0;t:{if(!a){u=s;break t}for(;u=k2(s,a,10),y=Gr,s=od(u,y,246,0)+s|0,h=h-1|0,pt[h|0]=s|48,b=a>>>0>9,s=u,a=y,!!b;);}if(u)for(;h=h-1|0,s=(u>>>0)/10|0,pt[h|0]=Ke(s,246)+u|48,a=u>>>0>9,u=s,!!a;);return h}function h3(s,a){s=s|0,a=a|0;var h=0;t:{if(s=c[s>>2],h=c[s+24>>2],(h>>>22&1)==(a|0))break t;for(c[s+24>>2]=h&-4194305|a<<22&4194304;;){if(a=Tt[s+4|0],a&4)break t;if(pt[s+4|0]=a|4,a=c[s+20>>2],a&&$t[a|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function d3(s,a){s=s|0,a=a|0;var h=0;t:{if(s=c[s>>2],h=c[s+24>>2],(h>>>18&3)==(a|0))break t;for(c[s+24>>2]=h&-786433|a<<18&786432;;){if(a=Tt[s+4|0],a&4)break t;if(pt[s+4|0]=a|4,a=c[s+20>>2],a&&$t[a|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function u3(s,a){s=s|0,a=a|0;var h=0;t:{if(s=c[s>>2],h=c[s+24>>2],(h>>>16&3)==(a|0))break t;for(c[s+24>>2]=h&-196609|a<<16&196608;;){if(a=Tt[s+4|0],a&4)break t;if(pt[s+4|0]=a|4,a=c[s+20>>2],a&&$t[a|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function f3(s,a){s=s|0,a=+a;var h=0,u=m(0),y=m(0);t:{if(u=m(a),s=c[s>>2],y=I[s+224>>2],u==y|u!=u&y!=y)break t;for(I[s+224>>2]=u;;){if(h=Tt[s+4|0],h&4)break t;if(pt[s+4|0]=h|4,h=c[s+20>>2],h&&$t[h|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function p3(s,a){s=s|0,a=+a;var h=0,u=m(0),y=m(0);t:{if(u=m(a),s=c[s>>2],y=I[s+28>>2],u==y|u!=u&y!=y)break t;for(I[s+28>>2]=u;;){if(h=Tt[s+4|0],h&4)break t;if(pt[s+4|0]=h|4,h=c[s+20>>2],h&&$t[h|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function g3(s,a){s=s|0,a=+a;var h=0,u=m(0),y=m(0);t:{if(u=m(a),s=c[s>>2],y=I[s+32>>2],u==y|u!=u&y!=y)break t;for(I[s+32>>2]=u;;){if(h=Tt[s+4|0],h&4)break t;if(pt[s+4|0]=h|4,h=c[s+20>>2],h&&$t[h|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function m3(s,a){s=s|0,a=+a;var h=0,u=m(0),y=m(0);t:{if(u=m(a),s=c[s>>2],y=I[s+36>>2],u==y|u!=u&y!=y)break t;for(I[s+36>>2]=u;;){if(h=Tt[s+4|0],h&4)break t;if(pt[s+4|0]=h|4,h=c[s+20>>2],h&&$t[h|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function v3(s,a){s=s|0,a=a|0;var h=0;t:{if(s=c[s>>2],h=c[s+24>>2],(h>>>4&7)==(a|0))break t;for(c[s+24>>2]=h&-113|a<<4&112;;){if(a=Tt[s+4|0],a&4)break t;if(pt[s+4|0]=a|4,a=c[s+20>>2],a&&$t[a|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function y3(s,a){s=s|0,a=a|0;var h=0;t:{if(s=c[s>>2],h=c[s+24>>2],(h>>>2&3)==(a|0))break t;for(c[s+24>>2]=h&-13|a<<2&12;;){if(a=Tt[s+4|0],a&4)break t;if(pt[s+4|0]=a|4,a=c[s+20>>2],a&&$t[a|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function b3(s,a){s=s|0,a=a|0;var h=0;t:{if(s=c[s>>2],h=Tt[s+4|0],((h&2)>>>1|0)==(a|0))break t;for(pt[s+4|0]=h&253|(a?2:0);;){if(a=Tt[s+4|0],a&4)break t;if(pt[s+4|0]=a|4,a=c[s+20>>2],a&&$t[a|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function E3(s,a,h){s=s|0,a=a|0,h=h|0;var u=0,y=0;return u=St-16|0,St=u,y=c[s>>2],s=c[s+4>>2],a=(s>>1)+a|0,s&1&&(y=c[y+c[a>>2]>>2]),$t[y|0](u,a,h),s=ht(16),a=c[u+12>>2],c[s+8>>2]=c[u+8>>2],c[s+12>>2]=a,a=c[u+4>>2],c[s>>2]=c[u>>2],c[s+4>>2]=a,St=u+16|0,s|0}function $2(s,a){var h=0,u=0;t:{i:{if(h=c[s+556>>2],u=c[s+560>>2],(h|0)==(u|0))break i;for(;;){if(c[h>>2]==(a|0))break i;if(h=h+4|0,(u|0)==(h|0))break}break t}if((h|0)==(u|0))break t;return a=h+4|0,Bs(h,a,u-a|0),c[s+560>>2]=u-4,1}return 0}function A3(s){s=s|0;var a=0,h=0;if(h=St-16|0,St=h,s=c[s>>2],c[s+8>>2]){for(;a=Tt[s+4|0],!!(!(a&4)&&(pt[s+4|0]=a|4,a=c[s+20>>2],a&&$t[a|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],s)););St=h+16|0;return}c[h>>2]=1024,li(s,h),ti(),pe()}function M2(s,a){var h=0,u=0,y=0;if(Er(+s),u=te(1)|0,y=te(0)|0,h=u>>>20&2047,(h|0)!=2047){if(!h)return s==0?h=0:(s=M2(s*18446744073709552e3,a),h=c[a>>2]+-64|0),c[a>>2]=h,s;c[a>>2]=h-1022,Ot(0,y|0),Ot(1,u&-2146435073|1071644672),s=+ke()}return s}function T3(s,a){s=s|0,a=a|0;var h=0,u=0;return h=St-16|0,St=h,u=c[s>>2],s=c[s+4>>2],a=(s>>1)+a|0,s&1&&(u=c[u+c[a>>2]>>2]),$t[u|0](h,a),s=ht(16),a=c[h+12>>2],c[s+8>>2]=c[h+8>>2],c[s+12>>2]=a,a=c[h+4>>2],c[s>>2]=c[h>>2],c[s+4>>2]=a,St=h+16|0,s|0}function Tl(s,a,h){var u=0;t:{if(u=s+24|0,c[(u+(a<<2)|0)+184>>2]==(h|0))break t;for(c[((a<<2)+u|0)+184>>2]=h;;){if(a=Tt[s+4|0],a&4)break t;if(pt[s+4|0]=a|4,a=c[s+20>>2],a&&$t[a|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function kl(s,a,h){var u=0;t:{if(u=s+24|0,c[(u+(a<<2)|0)+192>>2]==(h|0))break t;for(c[((a<<2)+u|0)+192>>2]=h;;){if(a=Tt[s+4|0],a&4)break t;if(pt[s+4|0]=a|4,a=c[s+20>>2],a&&$t[a|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function Kn(s,a,h){var u=0;t:{if(u=s+24|0,c[(u+(a<<2)|0)+176>>2]==(h|0))break t;for(c[((a<<2)+u|0)+176>>2]=h;;){if(a=Tt[s+4|0],a&4)break t;if(pt[s+4|0]=a|4,a=c[s+20>>2],a&&$t[a|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function nd(s,a){var h=0,u=0,y=0;t:{if(h=s+24|0,c[h+16>>2]==(a|0))break t;for(u=$t[9](h)|0,y=a,c[u+16>>2]=y;;){if(a=Tt[s+4|0],a&4)break t;if(pt[s+4|0]=a|4,a=c[s+20>>2],a&&$t[a|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function N2(s,a,h){var u=0;t:{if(u=s+24|0,c[(u+(a<<2)|0)+92>>2]==(h|0))break t;for(c[((a<<2)+u|0)+92>>2]=h;;){if(a=Tt[s+4|0],a&4)break t;if(pt[s+4|0]=a|4,a=c[s+20>>2],a&&$t[a|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function ad(s,a,h){var u=0;t:{if(u=s+24|0,c[(u+(a<<2)|0)+20>>2]==(h|0))break t;for(c[((a<<2)+u|0)+20>>2]=h;;){if(a=Tt[s+4|0],a&4)break t;if(pt[s+4|0]=a|4,a=c[s+20>>2],a&&$t[a|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function F2(s,a,h){var u=0;t:{if(u=s+24|0,c[(u+(a<<2)|0)+56>>2]==(h|0))break t;for(c[((a<<2)+u|0)+56>>2]=h;;){if(a=Tt[s+4|0],a&4)break t;if(pt[s+4|0]=a|4,a=c[s+20>>2],a&&$t[a|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function k3(){for(var s=0,a=0,h=0;a=s<<4,h=a+5968|0,c[a+5972>>2]=h,c[a+5976>>2]=h,s=s+1|0,(s|0)!=64;);rd(48),c[1756]=16,c[1757]=0,v2(),c[1757]=c[1768],c[1768]=7024,c[1769]=198,c[1770]=0,R2(),c[1770]=c[1768],c[1768]=7076}function ci(s,a){var h=0,u=m(0);s=s+80|0,h=c[(a<<2)+4288>>2];t:{if((a&-2)==2){s=Wi(s,4,h,2143289344);break t}s=ji(s,h,2143289344)}return(s|0)==2139156720|(s|0)==2140081935|(s|0)==2141891242?s=1:(u=(Ot(2,s),Gt()),s=u==u),s}function wl(s,a){var h=0,u=m(0);s=s+80|0,h=c[(a<<2)+4304>>2];t:{if((a&-2)==2){s=Wi(s,5,h,2143289344);break t}s=ji(s,h,2143289344)}return(s|0)==2139156720|(s|0)==2140081935|(s|0)==2141891242?s=1:(u=(Ot(2,s),Gt()),s=u==u),s}function od(s,a,h,u){var y=0,b=0,k=0,S=0,P=0,z=0;return y=h>>>16|0,b=s>>>16|0,z=Ke(y,b),k=h&65535,S=s&65535,P=Ke(k,S),b=(P>>>16|0)+Ke(b,k)|0,y=(b&65535)+Ke(y,S)|0,Gr=(Ke(a,h)+z|0)+Ke(s,u)+(b>>>16)+(y>>>16)|0,P&65535|y<<16}function U2(s,a){var h=0,u=0,y=0;u=St-16|0,St=u,h=Tt[s+4|0],y=h&-17,pt[s+4|0]=y;t:{if(a){if(c[s+560>>2]!=c[s+556>>2])break t;h=y|8}else h=h&231;c[s+8>>2]=a,pt[s+4|0]=h,St=u+16|0;return}c[u>>2]=4128,li(s,u),ti(),pe()}function B2(s){var a=0,h=m(0);a=0;t:{if((c[s+24>>2]&196608)==131072)break t;i:{if(!c[s+552>>2]||(h=I[s+32>>2],h!=h&&(h=I[s+28>>2],!(h>m(0)))))break i;if(a=1,h!=m(0))break t}a=zn(s)!=m(0)}return a}function Tr(s,a,h,u,y){var b=0;if(b=St-256|0,St=b,!(y&73728|(h|0)<=(u|0))){if(u=h-u|0,h=u>>>0<256,Vr(b,a&255,h?u:256),!h)for(;pr(s,b,256),u=u-256|0,u>>>0>255;);pr(s,b,u)}St=b+256|0}function yn(s,a,h){var u=0,y=m(0);t:{if((h&-2)==2&&(u=a- -64|0,y=I[u>>2],u=c[u>>2],(u|0)==2139156720|(u|0)==2140081935|(u|0)==2141891242|y==y))break t;u=c[((c[(h<<2)+4304>>2]<<2)+a|0)+44>>2]}D2(s,u)}function bn(s,a,h){var u=0,y=m(0);t:{if((h&-2)==2&&(u=c[a+60>>2],y=I[a+60>>2],(u|0)==2139156720|(u|0)==2140081935|(u|0)==2141891242|y==y))break t;u=c[((c[(h<<2)+4288>>2]<<2)+a|0)+44>>2]}D2(s,u)}function zn(s){var a=m(0),h=m(0);if(!c[s+552>>2])return m(0);a=I[s+36>>2];t:{if(a==a||(a=m(1),pt[c[s+568>>2]+8|0]&1)||(a=m(0),h=I[s+28>>2],!(h<m(0))))break t;a=m(-h)}return a}function G2(s){var a=0,h=0,u=0;for(u=c[s>>2];;){if(h=pt[u|0],Rl(h)){u=u+1|0,c[s>>2]=u,a>>>0<=214748364?(h=h-48|0,a=Ke(a,10),a=(h|0)>(a^2147483647)?-1:h+a|0):a=-1;continue}break}return a}function Ya(s,a,h,u){var y=0;c[s+12>>2]=0,c[s+16>>2]=u;t:{if(a){if(a>>>0>=1073741824)break t;y=ht(a<<2)}return c[s>>2]=y,h=(h<<2)+y|0,c[s+8>>2]=h,c[s+12>>2]=(a<<2)+y,c[s+4>>2]=h,s}fd(),pe()}function H2(s){var a=0;return a=c[s+72>>2],c[s+72>>2]=a-1|a,a=c[s>>2],a&8?(c[s>>2]=a|32,-1):(c[s+4>>2]=0,c[s+8>>2]=0,a=c[s+44>>2],c[s+28>>2]=a,c[s+20>>2]=a,c[s+16>>2]=a+c[s+48>>2],0)}function w3(s,a,h,u,y,b){s=s|0,a=a|0,h=m(h),u=u|0,y=m(y),b=b|0;var k=0;k=St-16|0,St=k,a=c[c[a>>2]+4>>2],$t[c[c[a>>2]+8>>2]](k,a,h,u,y,b),I[s>>2]=je[k>>3],I[s+4>>2]=je[k+8>>3],St=k+16|0}function S3(){var s=0,a=0;return a=ht(4),s=ht(28),c[s+20>>2]=1065353216,c[s+24>>2]=0,c[s+12>>2]=0,c[s+16>>2]=0,c[s>>2]=0,pt[s+8|0]=0,c[s+4>>2]=1,c[1752]=c[1752]+1,c[a>>2]=s,a|0}function R3(s,a){s=s|0,a=a|0,a=c[a>>2],je[s>>3]=I[a+228>>2],je[s+8>>3]=I[a+236>>2],je[s+16>>3]=I[a+232>>2],je[s+24>>3]=I[a+240>>2],je[s+32>>3]=I[a+244>>2],je[s+40>>3]=I[a+248>>2]}function _3(s,a){s=s|0,a=a|0;var h=0,u=0;return h=St-48|0,St=h,u=c[s>>2],s=c[s+4>>2],a=(s>>1)+a|0,s&1&&(u=c[u+c[a>>2]>>2]),$t[u|0](h,a),s=Hr(ht(48),h,48),St=h+48|0,s|0}function L3(s,a,h,u){s=s|0,a=a|0,h=h|0,u=u|0;var y=0;return y=St-16|0,St=y,s=eg(kk(c[s+60>>2],a|0,h|0,u&255,y+8|0)|0),St=y+16|0,Gr=s?-1:c[y+12>>2],(s?-1:c[y+8>>2])|0}function C3(s,a){s=s|0,a=a|0;var h=0,u=0;h=c[s>>2],s=c[h+556>>2];t:{if(c[h+560>>2]-s>>2>>>0<=a>>>0||(s=c[s+(a<<2)>>2],!s))break t;u=c[s>>2]}return u|0}function I3(s,a,h){if(s=s|0,a=a|0,h=h|0,a>>>0<3){a=1<<a,s=c[s>>2],h?a=a|c[s+12>>2]:a=c[s+12>>2]&(a^-1),c[s+12>>2]=a;return}Us(),pe()}function x3(s,a,h,u,y){s=s|0,a=a|0,h=+h,u=+u,y=y|0;var b=0;b=c[s>>2],s=c[s+4>>2],a=(s>>1)+a|0,s&1&&(b=c[b+c[a>>2]>>2]),$t[b|0](a,h,u,y)}function D3(s,a,h){s=s|0,a=a|0,h=h|0;var u=0;return u=c[s>>2],s=c[s+4>>2],a=(s>>1)+a|0,s&1&&(u=c[u+c[a>>2]>>2]),m(m($t[u|0](a,h)))}function V2(s,a,h,u){s=s|0,a=a|0,h=h|0,u=u|0;var y=0;y=c[s>>2],s=c[s+4>>2],a=(s>>1)+a|0,s&1&&(y=c[y+c[a>>2]>>2]),$t[y|0](a,h,u)}function W2(s,a,h){s=s|0,a=a|0,h=h|0;var u=0;return u=c[s>>2],s=c[s+4>>2],a=(s>>1)+a|0,s&1&&(u=c[u+c[a>>2]>>2]),$t[u|0](a,h)|0}function P3(s,a,h,u){s=s|0,a=a|0,h=h|0,u=+u;var y=0;y=c[s>>2],s=c[s+4>>2],a=(s>>1)+a|0,s&1&&(y=c[y+c[a>>2]>>2]),$t[y|0](a,h,u)}function O3(s,a,h){s=s|0,a=a|0,h=h|0;var u=0;return u=c[s>>2],s=c[s+4>>2],a=(s>>1)+a|0,s&1&&(u=c[u+c[a>>2]>>2]),+$t[u|0](a,h)}function ht(s){var a=0;s=s||1;t:{for(;;){if(a=td(s),a)break t;if(a=c[2042],a){$t[a|0]();continue}break}Us(),pe()}return a}function $3(s,a,h){s=s|0,a=a|0,h=m(h);var u=0;u=c[s>>2],s=c[s+4>>2],a=(s>>1)+a|0,s&1&&(u=c[u+c[a>>2]>>2]),$t[u|0](a,h)}function Hs(s,a,h){s=s|0,a=a|0,h=h|0;var u=0;u=c[s>>2],s=c[s+4>>2],a=(s>>1)+a|0,s&1&&(u=c[u+c[a>>2]>>2]),$t[u|0](a,h)}function En(s,a){s=s|0,a=a|0;var h=0;return h=c[s>>2],s=c[s+4>>2],a=(s>>1)+a|0,s&1&&(h=c[h+c[a>>2]>>2]),$t[h|0](a)|0}function ld(s,a){return Jr(s),(te(2)&2147483647)>>>0<=2139095040?(Jr(a),(te(2)&2147483647)>>>0>2139095040?s:m(vk(s,a))):a}function fe(s,a){return Jr(s),(te(2)&2147483647)>>>0<=2139095040?(Jr(a),(te(2)&2147483647)>>>0>2139095040?s:m(yk(s,a))):a}function j2(s,a){s=s|0,a=a|0;var h=0;return h=St-16|0,St=h,c[h+8>>2]=a,s=$t[s|0](h+8|0)|0,Ka(c[h+8>>2]),St=h+16|0,s|0}function M3(s,a,h){s=s|0,a=a|0,h=+h;var u=0;u=c[s>>2],s=c[s+4>>2],a=(s>>1)+a|0,s&1&&(u=c[u+c[a>>2]>>2]),$t[u|0](a,h)}function N3(s,a,h,u,y){return h=h|0,u=u|0,y=y|0,h&&(h|0)!=5?ng(5816,u,y)|0:ng(5672,u,y)|0}function K2(s,a){if(!s)return 0;t:{if(!((a&-128)==57216|a>>>0<=127)){c[1781]=25,s=-1;break t}pt[s|0]=a,s=1}return s}function F3(s,a){s=s|0,a=a|0;var h=0;return h=c[s>>2],s=c[s+4>>2],a=(s>>1)+a|0,s&1&&(h=c[h+c[a>>2]>>2]),+$t[h|0](a)}function z2(s,a){var h=0,u=0;h=ht(4),c[h>>2]=a,u=ht(4),c[u>>2]=a,bl(7035,s|0,7098,4714,196,h|0,7098,4718,197,u|0)}function Yn(s,a){var h=0,u=0;h=ht(4),c[h>>2]=a,u=ht(4),c[u>>2]=a,bl(7065,s|0,7098,4714,194,h|0,7098,4718,195,u|0)}function cd(s,a){var h=0;t:{if(pt[7044]&1){h=c[1760];break t}h=d2(1,4464)|0,pt[7044]=1,c[1760]=h}Tk(h|0,s|0,a|0,0)}function U3(s,a){s=s|0,a=a|0;var h=0;h=c[s+8>>2],c[s+8>>2]=a,h&&$t[c[c[h>>2]+4>>2]](h),c[c[s>>2]+20>>2]=15}function B3(s,a,h){s=s|0,a=a|0,h=h|0;var u=0,y=0;u=s,y=g2((pt[a+11|0]<0?c[a>>2]:a)|0,7036,c[h>>2])|0,c[u>>2]=y}function G3(s,a,h){s=s|0,a=a|0,h=h|0;var u=0,y=0;u=s,y=g2((pt[a+11|0]<0?c[a>>2]:a)|0,7059,c[h>>2])|0,c[u>>2]=y}function Y2(s,a){s=s|0,a=a|0;var h=0;h=c[s>>2],s=c[s+4>>2],a=(s>>1)+a|0,s&1&&(h=c[h+c[a>>2]>>2]),$t[h|0](a)}function H3(s){s=s|0;var a=m(0);return s=c[s>>2],a=I[s+36>>2],a!=a&&(a=pt[c[s+568>>2]+8|0]&1?m(1):m(0)),+a}function V3(s,a){s=s|0,a=a|0;var h=0;h=c[s+4>>2],c[s+4>>2]=a,h&&$t[c[c[h>>2]+4>>2]](h),U2(c[s>>2],14)}function W3(s){s=s|0;var a=0;a=c[s+8>>2],c[s+8>>2]=0,a&&$t[c[c[a>>2]+4>>2]](a),c[c[s>>2]+20>>2]=0}function j3(s){s=s|0;var a=0;return a=ht(12),pt[a+4|0]=0,c[a+8>>2]=c[s>>2],c[s>>2]=0,c[a>>2]=4432,a|0}function K3(s){s=s|0;var a=0;return a=ht(12),pt[a+4|0]=0,c[a+8>>2]=c[s>>2],c[s>>2]=0,c[a>>2]=4552,a|0}function z3(){var s=0;if(s=c[1768],s)for(;$t[c[s>>2]](),s=c[s+4>>2],!!s;);}function Y3(s){s=s|0;var a=0;a=c[s+4>>2],c[s+4>>2]=0,a&&$t[c[c[a>>2]+4>>2]](a),U2(c[s>>2],0)}function X2(s){return s=s|0,c[s>>2]=4572,Tt[s+4|0]&&cd(c[s+8>>2],1759),Ka(c[s+8>>2]),s|0}function Z2(s){return s=s|0,c[s>>2]=4452,Tt[s+4|0]&&cd(c[s+8>>2],1759),Ka(c[s+8>>2]),s|0}function X3(){var s=0;return s=ht(16),c[s>>2]=0,c[s+4>>2]=0,c[s+8>>2]=0,c[s+12>>2]=0,s|0}function q2(s,a,h){return ci(s,a)?Gs(s,a,h):(h=za(s,a,h),h==h&&(h=m(-h)),h)}function Q2(s,a){var h=0;h=St-16|0,St=h,s||(c[h>>2]=a,li(0,h),ti(),pe()),St=h+16|0}function J2(s){s=s|0;var a=0;s&&(a=c[s>>2],a&&Ar(a),c[1752]=c[1752]-1,Ar(s))}function Z3(s,a){return s=s|0,a=a|0,a>>>0>=3&&(Us(),pe()),c[c[s>>2]+12>>2]>>>a&1}function q3(s,a,h,u,y){return s=s|0,a=a|0,h=h|0,u=u|0,y=y|0,$t[s|0](a,h,u,y)|0}function Q3(){var s=0;return s=ht(16),c[s+8>>2]=0,c[s+12>>2]=0,c[s>>2]=0,s|0}function J3(s){s=s|0;var a=m(0);return a=I[c[s>>2]+224>>2],+(a!=a?m(zt):a)}function tw(s){return s=s|0,s=c[c[s>>2]+552>>2],s?c[s>>2]:0}function ew(s){s=s|0;var a=m(0);return a=I[c[s>>2]+32>>2],+(a==a?a:m(0))}function tg(s){var a=0;return a=b2(ht(588),s),Q2((s|0)!=0,2808),a}function rw(s,a){s=s|0,a=a|0,s=c[s>>2],c[s+16>>2]=c[s+16>>2]&-2|a}function iw(s){return s=s|0,s=c[s>>2],c[s+560>>2]-c[s+556>>2]>>2}function sw(s,a){s=s|0,a=a|0,s=c[s>>2],pt[s+8|0]=Tt[s+8|0]&254|a}function nw(s){s=s|0,s=c[c[s>>2]+8>>2],$t[c[c[s>>2]+8>>2]](s)}function aw(s,a,h){s=s|0,a=a|0,h=+h,ad(c[s>>2],a,Ti(m(h)))}function ow(s,a,h){s=s|0,a=a|0,h=+h,ad(c[s>>2],a,zi(m(h)))}function lw(s,a,h,u){return Gr=0,0}function cw(s,a,h){s=s|0,a=a|0,h=+h,N2(c[s>>2],a,Ti(m(h)))}function hw(s,a,h){s=s|0,a=a|0,h=+h,N2(c[s>>2],a,zi(m(h)))}function dw(s,a,h){s=s|0,a=a|0,h=+h,F2(c[s>>2],a,Ti(m(h)))}function uw(s,a,h){s=s|0,a=a|0,h=+h,F2(c[s>>2],a,zi(m(h)))}function fw(s,a,h){s=s|0,a=a|0,h=h|0,c[c[s>>2]+a>>2]=h}function pw(s,a){s=s|0,a=a|0,ad(c[s>>2],a,2141891242)}function hd(s,a,h){s=s|0,a=a|0,h=+h,je[c[s>>2]+a>>3]=h}function gw(s){return s=s|0,(Tt[c[s>>2]+4|0]&2)>>>1|0}function mw(s){return s=s|0,(Tt[c[s>>2]+4|0]&4)>>>2|0}function vw(s,a){s=s|0,a=a|0,c[s+4>>2]=10,c[s>>2]=a}function yw(s,a){s=s|0,a=a|0,c[s+4>>2]=13,c[s>>2]=a}function bw(s){return s=s|0,c[c[s>>2]+24>>2]>>>10&7}function Ew(s){return s=s|0,c[c[s>>2]+24>>2]>>>13&7}function dd(s,a){return s=s|0,a=a|0,+je[c[s>>2]+a>>3]}function Aw(s){return s=s|0,c[c[s>>2]+24>>2]>>>18&3}function Tw(s){return s=s|0,c[c[s>>2]+24>>2]>>>20&3}function kw(s){return s=s|0,c[c[s>>2]+24>>2]>>>22&1}function ww(s,a){return s=s|0,a=a|0,c[c[s>>2]+a>>2]}function Sw(s,a){s=s|0,a=+a,Kn(c[s>>2],0,Ti(m(a)))}function Rw(s,a){s=s|0,a=+a,Kn(c[s>>2],0,zi(m(a)))}function _w(s,a){s=s|0,a=+a,Kn(c[s>>2],1,Ti(m(a)))}function Lw(s,a){s=s|0,a=+a,Kn(c[s>>2],1,zi(m(a)))}function Cw(s,a){s=s|0,a=a|0,c[s+4>>2]=7,c[s>>2]=a}function Iw(s,a){s=s|0,a=+a,Tl(c[s>>2],0,Ti(m(a)))}function xw(s,a){s=s|0,a=+a,Tl(c[s>>2],0,zi(m(a)))}function Dw(s,a){s=s|0,a=+a,Tl(c[s>>2],1,Ti(m(a)))}function Pw(s,a){s=s|0,a=+a,Tl(c[s>>2],1,zi(m(a)))}function Ow(s,a){s=s|0,a=+a,kl(c[s>>2],0,Ti(m(a)))}function $w(s,a){s=s|0,a=+a,kl(c[s>>2],1,Ti(m(a)))}function Mw(s,a){s=s|0,a=+a,kl(c[s>>2],1,zi(m(a)))}function Nw(s){return s=s|0,c[c[s>>2]+24>>2]>>>7&7}function Fw(s){return s=s|0,c[c[s>>2]+24>>2]>>>2&3}function Uw(s){return s=s|0,c[c[s>>2]+24>>2]>>>4&7}function Sl(s){s=s|0,s&&$t[c[c[s>>2]+4>>2]](s)}function Bw(s,a){s=s|0,a=+a,kl(c[s>>2],0,zi(m(a)))}function eg(s){return s?(c[1781]=s,-1):0}function Gw(s,a){s=s|0,a=+a,nd(c[s>>2],Ti(m(a)))}function Hw(s,a){s=s|0,a=+a,nd(c[s>>2],zi(m(a)))}function rg(s,a,h){return m(ge(s,a,h)+Re(s,a,h))}function Vw(s,a){return s=s|0,a=a|0,$t[s|0](a)|0}function ig(s,a,h,u){wk(s|0,a|0,8,0,h|0,-1,u|0)}function Ww(s,a){s=s|0,a=a|0,c[c[s>>2]+16>>2]=a}function jw(s){return s=s|0,c[c[s>>2]+16>>2]&1}function Kw(s){return s=s|0,Hn[c[s>>2]+26>>1]&3}function zw(s){s=s|0,Kn(c[s>>2],0,2141891242)}function Yw(s){s=s|0,Kn(c[s>>2],1,2141891242)}function Xw(s){return s=s|0,+I[c[s>>2]+228>>2]}function Zw(s){return s=s|0,+I[c[s>>2]+236>>2]}function qw(s){return s=s|0,+I[c[s>>2]+232>>2]}function Qw(s){return s=s|0,+I[c[s>>2]+240>>2]}function Jw(s){return s=s|0,+I[c[s>>2]+244>>2]}function tS(s){return s=s|0,+I[c[s>>2]+248>>2]}function eS(s){return s=s|0,Lk(c[s+60>>2])|0}function rS(s){return s=s|0,c[c[s>>2]+16>>2]}function iS(s){return s=s|0,pt[c[s>>2]+8|0]&1}function sS(s,a){s=s|0,a=a|0,sd(c[s>>2],5,a)}function nS(s,a){s=s|0,a=a|0,sd(c[s>>2],6,a)}function aS(s,a){s=s|0,a=a|0,sd(c[s>>2],7,a)}function oS(s){s=s|0,nd(c[s>>2],2141891242)}function sg(s,a){s=s|0,a=a|0,$t[c[s>>2]](a)}function lS(s){return s=s|0,O2(ht(12),s)|0}function cS(s){s=s|0,cd(c[s+8>>2],3293)}function ng(s,a,h){return C2(s,a,h,2,3)}function ag(s){return s=s|0,$t[s|0]()|0}function og(s,a){s=s|0,a=a|0,$t[s|0](a)}function hS(){return Vr(ht(48),0,48)|0}function ti(){$t[c[1490]](),fd(),pe()}function dS(){return O2(ht(12),0)|0}function ud(s){s=s|0,s&&Ar(s)}function Rl(s){return s-48>>>0<10}function uS(s){return 7032}function fS(s){return 7036}function pS(s){return 7056}function gS(s){return 7059}function mS(s){return 7062}function vS(s){return 7067}function Ci(s){return s=s|0,s|0}function lg(s){s=s|0,pt[s+4|0]=1}function yS(s){s=s|0,Ar(X2(s))}function bS(s){s=s|0,Ar(Z2(s))}function ES(s){return 0}function cg(s){pe()}function hg(){fd(),pe()}function fd(){Us(),pe()}V=Tt,Lt();var $t=H([null,N3,Dk,$k,Ci,Cw,vw,yw,Ci,Ci,Ci,Ci,Ci,Ci,w3,nw,v2,uS,Sl,n3,fS,Ci,Ci,Sl,lg,sg,j2,j3,Vk,B3,pS,Sl,Y2,gS,Ci,Ci,Sl,lg,sg,j2,K3,G3,mS,J2,ag,S3,og,J2,I3,V2,Gk,$3,rw,Hs,Ww,Hs,sw,Z3,W2,jw,En,rS,En,iS,hS,ud,X3,ud,Q3,ud,dd,hd,ww,fw,vS,S2,ag,dS,Vw,lS,og,S2,Fk,Y2,Ok,Hs,u3,Hs,dw,P3,uw,sS,nS,aS,y3,d3,v3,aw,ow,pw,c3,h3,p3,M3,Gw,Hw,oS,g3,m3,Sw,Rw,zw,_w,Lw,Yw,Iw,xw,Dw,Pw,Ow,Bw,$w,Mw,f3,a3,cw,hw,o3,Kw,En,Kk,E3,Nw,bw,Ew,Fw,Aw,Uw,zk,i3,T3,ew,F3,H3,Xk,Zk,qk,Qk,Jk,Yk,J3,l3,O3,Tw,kw,jk,s3,D3,Mk,V2,Nk,Hs,iw,En,tw,En,C3,W2,gw,En,b3,Hs,V3,Hs,Y3,U3,Hs,W3,A3,mw,En,Pk,x3,Xw,Zw,qw,Qw,Jw,tS,R3,_3,t3,e3,r3,dd,hd,dd,hd,R2,Z2,bS,Hk,cg,hg,X2,yS,cS,cg,eS,Uk,L3,ES,lw,Wk,hg]);function dg(){return Br.byteLength/65536|0}function AS(s){s=s|0;var a=dg()|0,h=a+s|0;if(a<h&&h<65536){var u=new ArrayBuffer(Ke(h,65536)),y=new Int8Array(u);y.set(pt),pt=new Int8Array(u),Vi=new Int16Array(u),c=new Int32Array(u),Tt=new Uint8Array(u),Hn=new Uint16Array(u),c2=new Uint32Array(u),I=new Float32Array(u),je=new Float64Array(u),Br=u,oi.buffer=Br,V=Tt}return a}return{E:k3,F:Bk,G:z3,H:td,I:$t,J:Ar,K:q3}}return yl(L)}(_)}var C=Error,D={};E=[],typeof D!="object"&&It("no native wasm support detected");var M,U=!1;function x(_,L,H){H=L+H;for(var V="";!(L>=H);){var rt=_[L++];if(!rt)break;if(rt&128){var yt=_[L++]&63;if((rt&224)==192)V+=String.fromCharCode((rt&31)<<6|yt);else{var lt=_[L++]&63;rt=(rt&240)==224?(rt&15)<<12|yt<<6|lt:(rt&7)<<18|yt<<12|lt<<6|_[L++]&63,65536>rt?V+=String.fromCharCode(rt):(rt-=65536,V+=String.fromCharCode(55296|rt>>10,56320|rt&1023))}}else V+=String.fromCharCode(rt)}return V}var O,K,B,at,st,J,kt,ft,wt;function Pt(_){O=_,o.HEAP8=K=new Int8Array(_),o.HEAP16=at=new Int16Array(_),o.HEAP32=J=new Int32Array(_),o.HEAPU8=B=new Uint8Array(_),o.HEAPU16=st=new Uint16Array(_),o.HEAPU32=kt=new Uint32Array(_),o.HEAPF32=ft=new Float32Array(_),o.HEAPF64=wt=new Float64Array(_)}var F=o.INITIAL_MEMORY||16777216;o.wasmMemory?M=o.wasmMemory:M=new A,M&&(O=M.buffer),F=O.byteLength,Pt(O);var j,bt=[],N=[],G=[];function Z(){var _=o.preRun.shift();bt.unshift(_)}var gt=0,vt=null;function It(_){throw o.onAbort&&o.onAbort(_),_="Aborted("+_+")",v(_),U=!0,_=new C(_+". Build with -sASSERTIONS for more info."),d(_),_}function Bt(_){return _.startsWith("data:application/octet-stream;base64,")}var Xt;if(Xt="<<< WASM_BINARY_FILE >>>",!Bt(Xt)){var me=Xt;Xt=o.locateFile?o.locateFile(me,p):p+me}function be(_){var L=Xt;try{try{if(L==Xt&&E)new Uint8Array(E);else{if(Bt(L)){try{var H=pk(L.slice(37)),V=new Uint8Array(H.length);for(L=0;L<H.length;++L)V[L]=H.charCodeAt(L);var rt=V}catch{throw Error("Converting base64 string to bytes failed.")}var yt=rt}else yt=void 0;if(!yt)throw"sync fetching of the wasm failed: you can preload it to Module['wasmBinary'] manually, or emcc.py will do that for you when generating HTML (but not JS)"}}catch(xt){It(xt)}var lt=new T,Lt=new w(_)}catch(xt){throw _=xt.toString(),v("failed to compile wasm module: "+_),(_.includes("imported Memory")||_.includes("memory import"))&&v("Memory size incompatibility issues may be due to changing INITIAL_MEMORY at runtime to something too large. Use ALLOW_MEMORY_GROWTH to allow any size memory (and also make sure not to set INITIAL_MEMORY at runtime to something smaller than it was at compile time)."),xt}return[Lt,lt]}function Ee(_){for(;0<_.length;)_.shift()(o)}function Ye(_){if(_===void 0)return"_unknown";_=_.replace(/[^a-zA-Z0-9_]/g,"$");var L=_.charCodeAt(0);return 48<=L&&57>=L?"_"+_:_}function Le(_,L){return _=Ye(_),function(){return L.apply(this,arguments)}}var Wt=[{},{value:void 0},{value:null},{value:!0},{value:!1}],se=[];function le(_){var L=Error,H=Le(_,function(V){this.name=_,this.message=V,V=Error(V).stack,V!==void 0&&(this.stack=this.toString()+`
90
- `+V.replace(/^Error(:[^\n]*)?\n/,""))});return H.prototype=Object.create(L.prototype),H.prototype.constructor=H,H.prototype.toString=function(){return this.message===void 0?this.name:this.name+": "+this.message},H}var De=void 0;function Nt(_){throw new De(_)}var ne=_=>(_||Nt("Cannot use deleted val. handle = "+_),Wt[_].value),ee=_=>{switch(_){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:var L=se.length?se.pop():Wt.length;return Wt[L]={fa:1,value:_},L}},$e=void 0,Me=void 0;function ce(_){for(var L="";B[_];)L+=Me[B[_++]];return L}var Ce=[];function ie(){for(;Ce.length;){var _=Ce.pop();_.L.Z=!1,_.delete()}}var Ie=void 0,We={};function Pr(_,L){for(L===void 0&&Nt("ptr should not be undefined");_.P;)L=_.aa(L),_=_.P;return L}var Be={};function br(_){_=mk(_);var L=ce(_);return Fs(_),L}function cs(_,L){var H=Be[_];return H===void 0&&Nt(L+" has unknown type "+br(_)),H}function fr(){}var _i=!1;function Os(_){--_.count.value,_.count.value===0&&(_.S?_.T.V(_.S):_.O.M.V(_.N))}function $s(_,L,H){return L===H?_:H.P===void 0?null:(_=$s(_,L,H.P),_===null?null:H.ma(_))}var ai={};function ct(_,L){return L=Pr(_,L),We[L]}var Ht=void 0;function Zt(_){throw new Ht(_)}function Ae(_,L){return L.O&&L.N||Zt("makeClassHandle requires ptr and ptrType"),!!L.T!=!!L.S&&Zt("Both smartPtrType and smartPtr must be specified"),L.count={value:1},de(Object.create(_,{L:{value:L}}))}function de(_){return typeof FinalizationRegistry>"u"?(de=L=>L,_):(_i=new FinalizationRegistry(L=>{Os(L.L)}),de=L=>{var H=L.L;return H.S&&_i.register(L,{L:H},L),L},fr=L=>{_i.unregister(L)},de(_))}var lr={};function Or(_){for(;_.length;){var L=_.pop();_.pop()(L)}}function vi(_){return this.fromWireType(J[_>>2])}var hs={},yi={};function bi(_,L,H){function V(Lt){Lt=H(Lt),Lt.length!==_.length&&Zt("Mismatched type converter count");for(var xt=0;xt<_.length;++xt)$r(_[xt],Lt[xt])}_.forEach(function(Lt){yi[Lt]=L});var rt=Array(L.length),yt=[],lt=0;L.forEach((Lt,xt)=>{Be.hasOwnProperty(Lt)?rt[xt]=Be[Lt]:(yt.push(Lt),hs.hasOwnProperty(Lt)||(hs[Lt]=[]),hs[Lt].push(()=>{rt[xt]=Be[Lt],++lt,lt===yt.length&&V(rt)}))}),yt.length===0&&V(rt)}function Ms(_){switch(_){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: "+_)}}function $r(_,L,H={}){if(!("argPackAdvance"in L))throw new TypeError("registerType registeredInstance requires argPackAdvance");var V=L.name;if(_||Nt('type "'+V+'" must have a positive integer typeid pointer'),Be.hasOwnProperty(_)){if(H.ta)return;Nt("Cannot register type '"+V+"' twice")}Be[_]=L,delete yi[_],hs.hasOwnProperty(_)&&(L=hs[_],delete hs[_],L.forEach(rt=>rt()))}function ja(_){Nt(_.L.O.M.name+" instance already deleted")}function Ei(){}function Ns(_,L,H){if(_[L].R===void 0){var V=_[L];_[L]=function(){return _[L].R.hasOwnProperty(arguments.length)||Nt("Function '"+H+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+_[L].R+")!"),_[L].R[arguments.length].apply(this,arguments)},_[L].R=[],_[L].R[V.Y]=V}}function XT(_,L){o.hasOwnProperty(_)?(Nt("Cannot register public name '"+_+"' twice"),Ns(o,_,_),o.hasOwnProperty(void 0)&&Nt("Cannot register multiple overloads of a function with the same number of arguments (undefined)!"),o[_].R[void 0]=L):o[_]=L}function ZT(_,L,H,V,rt,yt,lt,Lt){this.name=_,this.constructor=L,this.W=H,this.V=V,this.P=rt,this.oa=yt,this.aa=lt,this.ma=Lt,this.ia=[]}function Kh(_,L,H){for(;L!==H;)L.aa||Nt("Expected null or instance of "+H.name+", got an instance of "+L.name),_=L.aa(_),L=L.P;return _}function qT(_,L){return L===null?(this.da&&Nt("null is not a valid "+this.name),0):(L.L||Nt('Cannot pass "'+Zh(L)+'" as a '+this.name),L.L.N||Nt("Cannot pass deleted object as a pointer of type "+this.name),Kh(L.L.N,L.L.O.M,this.M))}function QT(_,L){if(L===null){if(this.da&&Nt("null is not a valid "+this.name),this.ca){var H=this.ea();return _!==null&&_.push(this.V,H),H}return 0}if(L.L||Nt('Cannot pass "'+Zh(L)+'" as a '+this.name),L.L.N||Nt("Cannot pass deleted object as a pointer of type "+this.name),!this.ba&&L.L.O.ba&&Nt("Cannot convert argument of type "+(L.L.T?L.L.T.name:L.L.O.name)+" to parameter type "+this.name),H=Kh(L.L.N,L.L.O.M,this.M),this.ca)switch(L.L.S===void 0&&Nt("Passing raw pointer to smart pointer is illegal"),this.Aa){case 0:L.L.T===this?H=L.L.S:Nt("Cannot convert argument of type "+(L.L.T?L.L.T.name:L.L.O.name)+" to parameter type "+this.name);break;case 1:H=L.L.S;break;case 2:if(L.L.T===this)H=L.L.S;else{var V=L.clone();H=this.wa(H,ee(function(){V.delete()})),_!==null&&_.push(this.V,H)}break;default:Nt("Unsupporting sharing policy")}return H}function JT(_,L){return L===null?(this.da&&Nt("null is not a valid "+this.name),0):(L.L||Nt('Cannot pass "'+Zh(L)+'" as a '+this.name),L.L.N||Nt("Cannot pass deleted object as a pointer of type "+this.name),L.L.O.ba&&Nt("Cannot convert argument of type "+L.L.O.name+" to parameter type "+this.name),Kh(L.L.N,L.L.O.M,this.M))}function ds(_,L,H,V){this.name=_,this.M=L,this.da=H,this.ba=V,this.ca=!1,this.V=this.wa=this.ea=this.ja=this.Aa=this.va=void 0,L.P!==void 0?this.toWireType=QT:(this.toWireType=V?qT:JT,this.U=null)}function tk(_,L){o.hasOwnProperty(_)||Zt("Replacing nonexistant public symbol"),o[_]=L,o[_].Y=void 0}function ek(_,L){var H=[];return function(){if(H.length=0,Object.assign(H,arguments),_.includes("j")){var V=o["dynCall_"+_];V=H&&H.length?V.apply(null,[L].concat(H)):V.call(null,L)}else V=j.get(L).apply(null,H);return V}}function Li(_,L){_=ce(_);var H=_.includes("j")?ek(_,L):j.get(L);return typeof H!="function"&&Nt("unknown function pointer with signature "+_+": "+L),H}var i2=void 0;function pl(_,L){function H(yt){rt[yt]||Be[yt]||(yi[yt]?yi[yt].forEach(H):(V.push(yt),rt[yt]=!0))}var V=[],rt={};throw L.forEach(H),new i2(_+": "+V.map(br).join([", "]))}function zh(_,L,H,V,rt){var yt=L.length;2>yt&&Nt("argTypes array size mismatch! Must at least get return value and 'this' types!");var lt=L[1]!==null&&H!==null,Lt=!1;for(H=1;H<L.length;++H)if(L[H]!==null&&L[H].U===void 0){Lt=!0;break}var xt=L[0].name!=="void",Dt=yt-2,Ut=Array(Dt),Kt=[],te=[];return function(){if(arguments.length!==Dt&&Nt("function "+_+" called with "+arguments.length+" arguments, expected "+Dt+" args!"),te.length=0,Kt.length=lt?2:1,Kt[0]=rt,lt){var Ot=L[1].toWireType(te,this);Kt[1]=Ot}for(var ke=0;ke<Dt;++ke)Ut[ke]=L[ke+2].toWireType(te,arguments[ke]),Kt.push(Ut[ke]);if(ke=V.apply(null,Kt),Lt)Or(te);else for(var Er=lt?1:2;Er<L.length;Er++){var pe=Er===1?Ot:Ut[Er-2];L[Er].U!==null&&L[Er].U(pe)}return Ot=xt?L[0].fromWireType(ke):void 0,Ot}}function Yh(_,L){for(var H=[],V=0;V<_;V++)H.push(kt[L+4*V>>2]);return H}function Xh(_){4<_&&--Wt[_].fa===0&&(Wt[_]=void 0,se.push(_))}function Zh(_){if(_===null)return"null";var L=typeof _;return L==="object"||L==="array"||L==="function"?_.toString():""+_}function rk(_,L){switch(L){case 2:return function(H){return this.fromWireType(ft[H>>2])};case 3:return function(H){return this.fromWireType(wt[H>>3])};default:throw new TypeError("Unknown float type: "+_)}}function ik(_,L,H){switch(L){case 0:return H?function(V){return K[V]}:function(V){return B[V]};case 1:return H?function(V){return at[V>>1]}:function(V){return st[V>>1]};case 2:return H?function(V){return J[V>>2]}:function(V){return kt[V>>2]};default:throw new TypeError("Unknown integer type: "+_)}}function sk(_,L){for(var H="",V=0;!(V>=L/2);++V){var rt=at[_+2*V>>1];if(rt==0)break;H+=String.fromCharCode(rt)}return H}function nk(_,L,H){if(H===void 0&&(H=2147483647),2>H)return 0;H-=2;var V=L;H=H<2*_.length?H/2:_.length;for(var rt=0;rt<H;++rt)at[L>>1]=_.charCodeAt(rt),L+=2;return at[L>>1]=0,L-V}function ak(_){return 2*_.length}function ok(_,L){for(var H=0,V="";!(H>=L/4);){var rt=J[_+4*H>>2];if(rt==0)break;++H,65536<=rt?(rt-=65536,V+=String.fromCharCode(55296|rt>>10,56320|rt&1023)):V+=String.fromCharCode(rt)}return V}function lk(_,L,H){if(H===void 0&&(H=2147483647),4>H)return 0;var V=L;H=V+H-4;for(var rt=0;rt<_.length;++rt){var yt=_.charCodeAt(rt);if(55296<=yt&&57343>=yt){var lt=_.charCodeAt(++rt);yt=65536+((yt&1023)<<10)|lt&1023}if(J[L>>2]=yt,L+=4,L+4>H)break}return J[L>>2]=0,L-V}function ck(_){for(var L=0,H=0;H<_.length;++H){var V=_.charCodeAt(H);55296<=V&&57343>=V&&++H,L+=4}return L}var hk={};function s2(_){var L=hk[_];return L===void 0?ce(_):L}var gl=[];function dk(_){var L=gl.length;return gl.push(_),L}function uk(_,L){for(var H=Array(_),V=0;V<_;++V)H[V]=cs(kt[L+4*V>>2],"parameter "+V);return H}var n2=[],fk=[null,[],[]];De=o.BindingError=le("BindingError"),o.count_emval_handles=function(){for(var _=0,L=5;L<Wt.length;++L)Wt[L]!==void 0&&++_;return _},o.get_first_emval=function(){for(var _=5;_<Wt.length;++_)if(Wt[_]!==void 0)return Wt[_];return null},$e=o.PureVirtualError=le("PureVirtualError");for(var a2=Array(256),ml=0;256>ml;++ml)a2[ml]=String.fromCharCode(ml);Me=a2,o.getInheritedInstanceCount=function(){return Object.keys(We).length},o.getLiveInheritedInstances=function(){var _=[],L;for(L in We)We.hasOwnProperty(L)&&_.push(We[L]);return _},o.flushPendingDeletes=ie,o.setDelayFunction=function(_){Ie=_,Ce.length&&Ie&&Ie(ie)},Ht=o.InternalError=le("InternalError"),Ei.prototype.isAliasOf=function(_){if(!(this instanceof Ei&&_ instanceof Ei))return!1;var L=this.L.O.M,H=this.L.N,V=_.L.O.M;for(_=_.L.N;L.P;)H=L.aa(H),L=L.P;for(;V.P;)_=V.aa(_),V=V.P;return L===V&&H===_},Ei.prototype.clone=function(){if(this.L.N||ja(this),this.L.$)return this.L.count.value+=1,this;var _=de,L=Object,H=L.create,V=Object.getPrototypeOf(this),rt=this.L;return _=_(H.call(L,V,{L:{value:{count:rt.count,Z:rt.Z,$:rt.$,N:rt.N,O:rt.O,S:rt.S,T:rt.T}}})),_.L.count.value+=1,_.L.Z=!1,_},Ei.prototype.delete=function(){this.L.N||ja(this),this.L.Z&&!this.L.$&&Nt("Object already scheduled for deletion"),fr(this),Os(this.L),this.L.$||(this.L.S=void 0,this.L.N=void 0)},Ei.prototype.isDeleted=function(){return!this.L.N},Ei.prototype.deleteLater=function(){return this.L.N||ja(this),this.L.Z&&!this.L.$&&Nt("Object already scheduled for deletion"),Ce.push(this),Ce.length===1&&Ie&&Ie(ie),this.L.Z=!0,this},ds.prototype.pa=function(_){return this.ja&&(_=this.ja(_)),_},ds.prototype.ga=function(_){this.V&&this.V(_)},ds.prototype.argPackAdvance=8,ds.prototype.readValueFromPointer=vi,ds.prototype.deleteObject=function(_){_!==null&&_.delete()},ds.prototype.fromWireType=function(_){function L(){return this.ca?Ae(this.M.W,{O:this.va,N:H,T:this,S:_}):Ae(this.M.W,{O:this,N:_})}var H=this.pa(_);if(!H)return this.ga(_),null;var V=ct(this.M,H);if(V!==void 0)return V.L.count.value===0?(V.L.N=H,V.L.S=_,V.clone()):(V=V.clone(),this.ga(_),V);if(V=this.M.oa(H),V=ai[V],!V)return L.call(this);V=this.ba?V.ka:V.pointerType;var rt=$s(H,this.M,V.M);return rt===null?L.call(this):this.ca?Ae(V.M.W,{O:V,N:rt,T:this,S:_}):Ae(V.M.W,{O:V,N:rt})},i2=o.UnboundTypeError=le("UnboundTypeError");var pk=typeof atob=="function"?atob:function(_){var L="",H=0;_=_.replace(/[^A-Za-z0-9\+\/=]/g,"");do{var V="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(_.charAt(H++)),rt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(_.charAt(H++)),yt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(_.charAt(H++)),lt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(_.charAt(H++));V=V<<2|rt>>4,rt=(rt&15)<<4|yt>>2;var Lt=(yt&3)<<6|lt;L+=String.fromCharCode(V),yt!==64&&(L+=String.fromCharCode(rt)),lt!==64&&(L+=String.fromCharCode(Lt))}while(H<_.length);return L},gk={q:function(_,L,H){_=ce(_),L=cs(L,"wrapper"),H=ne(H);var V=[].slice,rt=L.M,yt=rt.W,lt=rt.P.W,Lt=rt.P.constructor;_=Le(_,function(){rt.P.ia.forEach((function(Dt){if(this[Dt]===lt[Dt])throw new $e("Pure virtual function "+Dt+" must be implemented in JavaScript")}).bind(this)),Object.defineProperty(this,"__parent",{value:yt}),this.__construct.apply(this,V.call(arguments))}),yt.__construct=function(){this===yt&&Nt("Pass correct 'this' to __construct");var Dt=Lt.implement.apply(void 0,[this].concat(V.call(arguments)));fr(Dt);var Ut=Dt.L;Dt.notifyOnDestruction(),Ut.$=!0,Object.defineProperties(this,{L:{value:Ut}}),de(this),Dt=Ut.N,Dt=Pr(rt,Dt),We.hasOwnProperty(Dt)?Nt("Tried to register registered instance: "+Dt):We[Dt]=this},yt.__destruct=function(){this===yt&&Nt("Pass correct 'this' to __destruct"),fr(this);var Dt=this.L.N;Dt=Pr(rt,Dt),We.hasOwnProperty(Dt)?delete We[Dt]:Nt("Tried to unregister unregistered instance: "+Dt)},_.prototype=Object.create(yt);for(var xt in H)_.prototype[xt]=H[xt];return ee(_)},k:function(_){var L=lr[_];delete lr[_];var H=L.ea,V=L.V,rt=L.ha,yt=rt.map(lt=>lt.sa).concat(rt.map(lt=>lt.ya));bi([_],yt,lt=>{var Lt={};return rt.forEach((xt,Dt)=>{var Ut=lt[Dt],Kt=xt.qa,te=xt.ra,Ot=lt[Dt+rt.length],ke=xt.xa,Er=xt.za;Lt[xt.na]={read:pe=>Ut.fromWireType(Kt(te,pe)),write:(pe,Jr)=>{var Gt=[];ke(Er,pe,Ot.toWireType(Gt,Jr)),Or(Gt)}}}),[{name:L.name,fromWireType:function(xt){var Dt={},Ut;for(Ut in Lt)Dt[Ut]=Lt[Ut].read(xt);return V(xt),Dt},toWireType:function(xt,Dt){for(var Ut in Lt)if(!(Ut in Dt))throw new TypeError('Missing field: "'+Ut+'"');var Kt=H();for(Ut in Lt)Lt[Ut].write(Kt,Dt[Ut]);return xt!==null&&xt.push(V,Kt),Kt},argPackAdvance:8,readValueFromPointer:vi,U:V}]})},w:function(){},C:function(_,L,H,V,rt){var yt=Ms(H);L=ce(L),$r(_,{name:L,fromWireType:function(lt){return!!lt},toWireType:function(lt,Lt){return Lt?V:rt},argPackAdvance:8,readValueFromPointer:function(lt){if(H===1)var Lt=K;else if(H===2)Lt=at;else if(H===4)Lt=J;else throw new TypeError("Unknown boolean type size: "+L);return this.fromWireType(Lt[lt>>yt])},U:null})},g:function(_,L,H,V,rt,yt,lt,Lt,xt,Dt,Ut,Kt,te){Ut=ce(Ut),yt=Li(rt,yt),Lt&&(Lt=Li(lt,Lt)),Dt&&(Dt=Li(xt,Dt)),te=Li(Kt,te);var Ot=Ye(Ut);XT(Ot,function(){pl("Cannot construct "+Ut+" due to unbound types",[V])}),bi([_,L,H],V?[V]:[],function(ke){if(ke=ke[0],V)var Er=ke.M,pe=Er.W;else pe=Ei.prototype;ke=Le(Ot,function(){if(Object.getPrototypeOf(this)!==Jr)throw new De("Use 'new' to construct "+Ut);if(Gt.X===void 0)throw new De(Ut+" has no accessible constructor");var nr=Gt.X[arguments.length];if(nr===void 0)throw new De("Tried to invoke ctor of "+Ut+" with invalid number of parameters ("+arguments.length+") - expected ("+Object.keys(Gt.X).toString()+") parameters instead!");return nr.apply(this,arguments)});var Jr=Object.create(pe,{constructor:{value:ke}});ke.prototype=Jr;var Gt=new ZT(Ut,ke,Jr,te,Er,yt,Lt,Dt);Er=new ds(Ut,Gt,!0,!1),pe=new ds(Ut+"*",Gt,!1,!1);var yl=new ds(Ut+" const*",Gt,!1,!0);return ai[_]={pointerType:pe,ka:yl},tk(Ot,ke),[Er,pe,yl]})},d:function(_,L,H,V,rt,yt,lt){var Lt=Yh(H,V);L=ce(L),yt=Li(rt,yt),bi([],[_],function(xt){function Dt(){pl("Cannot call "+Ut+" due to unbound types",Lt)}xt=xt[0];var Ut=xt.name+"."+L;L.startsWith("@@")&&(L=Symbol[L.substring(2)]);var Kt=xt.M.constructor;return Kt[L]===void 0?(Dt.Y=H-1,Kt[L]=Dt):(Ns(Kt,L,Ut),Kt[L].R[H-1]=Dt),bi([],Lt,function(te){return te=zh(Ut,[te[0],null].concat(te.slice(1)),null,yt,lt),Kt[L].R===void 0?(te.Y=H-1,Kt[L]=te):Kt[L].R[H-1]=te,[]}),[]})},p:function(_,L,H,V,rt,yt){0<L||It();var lt=Yh(L,H);rt=Li(V,rt),bi([],[_],function(Lt){Lt=Lt[0];var xt="constructor "+Lt.name;if(Lt.M.X===void 0&&(Lt.M.X=[]),Lt.M.X[L-1]!==void 0)throw new De("Cannot register multiple constructors with identical number of parameters ("+(L-1)+") for class '"+Lt.name+"'! Overload resolution is currently only performed using the parameter count, not actual type info!");return Lt.M.X[L-1]=()=>{pl("Cannot construct "+Lt.name+" due to unbound types",lt)},bi([],lt,function(Dt){return Dt.splice(1,0,null),Lt.M.X[L-1]=zh(xt,Dt,null,rt,yt),[]}),[]})},b:function(_,L,H,V,rt,yt,lt,Lt){var xt=Yh(H,V);L=ce(L),yt=Li(rt,yt),bi([],[_],function(Dt){function Ut(){pl("Cannot call "+Kt+" due to unbound types",xt)}Dt=Dt[0];var Kt=Dt.name+"."+L;L.startsWith("@@")&&(L=Symbol[L.substring(2)]),Lt&&Dt.M.ia.push(L);var te=Dt.M.W,Ot=te[L];return Ot===void 0||Ot.R===void 0&&Ot.className!==Dt.name&&Ot.Y===H-2?(Ut.Y=H-2,Ut.className=Dt.name,te[L]=Ut):(Ns(te,L,Kt),te[L].R[H-2]=Ut),bi([],xt,function(ke){return ke=zh(Kt,ke,Dt,yt,lt),te[L].R===void 0?(ke.Y=H-2,te[L]=ke):te[L].R[H-2]=ke,[]}),[]})},B:function(_,L){L=ce(L),$r(_,{name:L,fromWireType:function(H){var V=ne(H);return Xh(H),V},toWireType:function(H,V){return ee(V)},argPackAdvance:8,readValueFromPointer:vi,U:null})},n:function(_,L,H){H=Ms(H),L=ce(L),$r(_,{name:L,fromWireType:function(V){return V},toWireType:function(V,rt){return rt},argPackAdvance:8,readValueFromPointer:rk(L,H),U:null})},e:function(_,L,H,V,rt){L=ce(L),rt===-1&&(rt=4294967295),rt=Ms(H);var yt=Lt=>Lt;if(V===0){var lt=32-8*H;yt=Lt=>Lt<<lt>>>lt}H=L.includes("unsigned")?function(Lt,xt){return xt>>>0}:function(Lt,xt){return xt},$r(_,{name:L,fromWireType:yt,toWireType:H,argPackAdvance:8,readValueFromPointer:ik(L,rt,V!==0),U:null})},c:function(_,L,H){function V(yt){yt>>=2;var lt=kt;return new rt(O,lt[yt+1],lt[yt])}var rt=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][L];H=ce(H),$r(_,{name:H,fromWireType:V,argPackAdvance:8,readValueFromPointer:V},{ta:!0})},o:function(_,L){L=ce(L);var H=L==="std::string";$r(_,{name:L,fromWireType:function(V){var rt=kt[V>>2],yt=V+4;if(H)for(var lt=yt,Lt=0;Lt<=rt;++Lt){var xt=yt+Lt;if(Lt==rt||B[xt]==0){if(lt=lt?x(B,lt,xt-lt):"",Dt===void 0)var Dt=lt;else Dt+=String.fromCharCode(0),Dt+=lt;lt=xt+1}}else{for(Dt=Array(rt),Lt=0;Lt<rt;++Lt)Dt[Lt]=String.fromCharCode(B[yt+Lt]);Dt=Dt.join("")}return Fs(V),Dt},toWireType:function(V,rt){rt instanceof ArrayBuffer&&(rt=new Uint8Array(rt));var yt,lt=typeof rt=="string";if(lt||rt instanceof Uint8Array||rt instanceof Uint8ClampedArray||rt instanceof Int8Array||Nt("Cannot pass non-string to std::string"),H&&lt){var Lt=0;for(yt=0;yt<rt.length;++yt){var xt=rt.charCodeAt(yt);127>=xt?Lt++:2047>=xt?Lt+=2:55296<=xt&&57343>=xt?(Lt+=4,++yt):Lt+=3}yt=Lt}else yt=rt.length;if(Lt=o2(4+yt+1),xt=Lt+4,kt[Lt>>2]=yt,H&&lt){if(lt=xt,xt=yt+1,yt=B,0<xt){xt=lt+xt-1;for(var Dt=0;Dt<rt.length;++Dt){var Ut=rt.charCodeAt(Dt);if(55296<=Ut&&57343>=Ut){var Kt=rt.charCodeAt(++Dt);Ut=65536+((Ut&1023)<<10)|Kt&1023}if(127>=Ut){if(lt>=xt)break;yt[lt++]=Ut}else{if(2047>=Ut){if(lt+1>=xt)break;yt[lt++]=192|Ut>>6}else{if(65535>=Ut){if(lt+2>=xt)break;yt[lt++]=224|Ut>>12}else{if(lt+3>=xt)break;yt[lt++]=240|Ut>>18,yt[lt++]=128|Ut>>12&63}yt[lt++]=128|Ut>>6&63}yt[lt++]=128|Ut&63}}yt[lt]=0}}else if(lt)for(lt=0;lt<yt;++lt)Dt=rt.charCodeAt(lt),255<Dt&&(Fs(xt),Nt("String has UTF-16 code units that do not fit in 8 bits")),B[xt+lt]=Dt;else for(lt=0;lt<yt;++lt)B[xt+lt]=rt[lt];return V!==null&&V.push(Fs,Lt),Lt},argPackAdvance:8,readValueFromPointer:vi,U:function(V){Fs(V)}})},j:function(_,L,H){if(H=ce(H),L===2)var V=sk,rt=nk,yt=ak,lt=()=>st,Lt=1;else L===4&&(V=ok,rt=lk,yt=ck,lt=()=>kt,Lt=2);$r(_,{name:H,fromWireType:function(xt){for(var Dt=kt[xt>>2],Ut=lt(),Kt,te=xt+4,Ot=0;Ot<=Dt;++Ot){var ke=xt+4+Ot*L;(Ot==Dt||Ut[ke>>Lt]==0)&&(te=V(te,ke-te),Kt===void 0?Kt=te:(Kt+=String.fromCharCode(0),Kt+=te),te=ke+L)}return Fs(xt),Kt},toWireType:function(xt,Dt){typeof Dt!="string"&&Nt("Cannot pass non-string to C++ string type "+H);var Ut=yt(Dt),Kt=o2(4+Ut+L);return kt[Kt>>2]=Ut>>Lt,rt(Dt,Kt+4,Ut+L),xt!==null&&xt.push(Fs,Kt),Kt},argPackAdvance:8,readValueFromPointer:vi,U:function(xt){Fs(xt)}})},l:function(_,L,H,V,rt,yt){lr[_]={name:ce(L),ea:Li(H,V),V:Li(rt,yt),ha:[]}},i:function(_,L,H,V,rt,yt,lt,Lt,xt,Dt){lr[_].ha.push({na:ce(L),sa:H,qa:Li(V,rt),ra:yt,ya:lt,xa:Li(Lt,xt),za:Dt})},D:function(_,L){L=ce(L),$r(_,{ua:!0,name:L,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},t:function(_,L,H,V,rt){_=gl[_],L=ne(L),H=s2(H);var yt=[];return kt[V>>2]=ee(yt),_(L,H,yt,rt)},u:function(_,L,H,V){_=gl[_],L=ne(L),H=s2(H),_(L,H,null,V)},h:Xh,m:function(_,L){var H=uk(_,L),V=H[0];L=V.name+"_$"+H.slice(1).map(function(lt){return lt.name}).join("_")+"$";var rt=n2[L];if(rt!==void 0)return rt;var yt=Array(_-1);return rt=dk((lt,Lt,xt,Dt)=>{for(var Ut=0,Kt=0;Kt<_-1;++Kt)yt[Kt]=H[Kt+1].readValueFromPointer(Dt+Ut),Ut+=H[Kt+1].argPackAdvance;for(lt=lt[Lt].apply(lt,yt),Kt=0;Kt<_-1;++Kt)H[Kt+1].la&&H[Kt+1].la(yt[Kt]);if(!V.ua)return V.toWireType(xt,lt)}),n2[L]=rt},r:function(_){4<_&&(Wt[_].fa+=1)},s:function(_){var L=ne(_);Or(L),Xh(_)},f:function(){It("")},y:function(_,L,H){B.copyWithin(_,L,L+H)},x:function(_){var L=B.length;if(_>>>=0,2147483648<_)return!1;for(var H=1;4>=H;H*=2){var V=L*(1+.2/H);V=Math.min(V,_+100663296);var rt=Math;V=Math.max(_,V),rt=rt.min.call(rt,2147483648,V+(65536-V%65536)%65536);t:{try{M.grow(rt-O.byteLength+65535>>>16),Pt(M.buffer);var yt=1;break t}catch{}yt=void 0}if(yt)return!0}return!1},A:function(){return 52},v:function(){return 70},z:function(_,L,H,V){for(var rt=0,yt=0;yt<H;yt++){var lt=kt[L>>2],Lt=kt[L+4>>2];L+=8;for(var xt=0;xt<Lt;xt++){var Dt=B[lt+xt],Ut=fk[_];Dt===0||Dt===10?((_===1?g:v)(x(Ut,0)),Ut.length=0):Ut.push(Dt)}rt+=Lt}return kt[V>>2]=rt,0},a:M},Gn=function(){function _(H){o.asm=H.exports,j=o.asm.I,N.unshift(o.asm.E),gt--,o.monitorRunDependencies&&o.monitorRunDependencies(gt),gt==0&&vt&&(H=vt,vt=null,H())}var L={a:gk};if(gt++,o.monitorRunDependencies&&o.monitorRunDependencies(gt),o.instantiateWasm)try{return o.instantiateWasm(L,_)}catch(H){v("Module.instantiateWasm callback failed with error: "+H),d(H)}return L=be(L),_(L[0]),o.asm}();o.___wasm_call_ctors=Gn.E;var mk=o.___getTypeName=Gn.F;o.__embind_initialize_bindings=Gn.G;var o2=o._malloc=Gn.H,Fs=o._free=Gn.J;o.dynCall_jiji=Gn.K;var vl;vt=function _(){vl||l2(),vl||(vt=_)};function l2(){function _(){if(!vl&&(vl=!0,o.calledRun=!0,!U)){if(Ee(N),l(o),o.onRuntimeInitialized&&o.onRuntimeInitialized(),o.postRun)for(typeof o.postRun=="function"&&(o.postRun=[o.postRun]);o.postRun.length;){var L=o.postRun.shift();G.unshift(L)}Ee(G)}}if(!(0<gt)){if(o.preRun)for(typeof o.preRun=="function"&&(o.preRun=[o.preRun]);o.preRun.length;)Z();Ee(bt),0<gt||(o.setStatus?(o.setStatus("Running..."),setTimeout(function(){setTimeout(function(){o.setStatus("")},1),_()},1)):_())}}if(o.preInit)for(typeof o.preInit=="function"&&(o.preInit=[o.preInit]);0<o.preInit.length;)o.preInit.pop()();return l2(),n}})();i.exports=e})(Eu);var c1=Eu.exports;(function(i){Object.defineProperty(i,"__esModule",{value:!0});var t={};i.default=void 0;var e=n(ic),r=oe;Object.keys(r).forEach(function(d){d==="default"||d==="__esModule"||Object.prototype.hasOwnProperty.call(t,d)||d in i&&i[d]===r[d]||Object.defineProperty(i,d,{enumerable:!0,get:function(){return r[d]}})});function n(d){return d&&d.__esModule?d:{default:d}}const o=c1;var l=(0,e.default)(o());i.default=l})(we);const Au=n1(we);function h1(i,t){return typeof i=="number"?{top:i*t,right:i*t,bottom:i*t,left:i*t}:{top:typeof i.top=="number"?i.top*t:i.top,right:typeof i.right=="number"?i.right*t:i.right,bottom:typeof i.bottom=="number"?i.bottom*t:i.bottom,left:typeof i.left=="number"?i.left*t:i.left}}function Tu(i,t){return typeof i=="number"?{top:i*t,right:i*t,bottom:i*t,left:i*t}:{top:(typeof i.top=="number"?i.top*t:i.top)??0,right:(typeof i.right=="number"?i.right*t:i.right)??0,bottom:(typeof i.bottom=="number"?i.bottom*t:i.bottom)??0,left:(typeof i.left=="number"?i.left*t:i.left)??0}}function ku(i,{layout:t,scale:e=1}){const{position:r="static",inset:n,width:o,height:l,minWidth:d,minHeight:f,maxWidth:p,maxHeight:g,flex:v,gap:E,margin:A,padding:T,direction:w="column",align:C="start",alignSelf:D,justify:M="start"}=t,U={static:we.PositionType.Static,relative:we.PositionType.Relative,absolute:we.PositionType.Absolute};if(i.setPositionType(U[r]),n){const{top:B,right:at,bottom:st,left:J}=h1(n,e);B&&i.setPosition(we.Edge.Top,B),at&&i.setPosition(we.Edge.Right,at),st&&i.setPosition(we.Edge.Bottom,st),J&&i.setPosition(we.Edge.Left,J)}const x={row:we.FlexDirection.Row,column:we.FlexDirection.Column,"row-reverse":we.FlexDirection.RowReverse,"column-reverse":we.FlexDirection.ColumnReverse};i.setFlexDirection(x[w]);const O={start:we.Align.FlexStart,end:we.Align.FlexEnd,center:we.Align.Center,stretch:we.Align.Stretch};i.setAlignItems(O[C]),D&&i.setAlignSelf(O[D]);const K={start:we.Justify.FlexStart,end:we.Justify.FlexEnd,center:we.Justify.Center,"space-between":we.Justify.SpaceBetween,"space-around":we.Justify.SpaceAround,"space-evenly":we.Justify.SpaceEvenly};if(i.setJustifyContent(K[M]),A){const{top:B,right:at,bottom:st,left:J}=Tu(A,e);i.setMargin(we.Edge.Top,B),i.setMargin(we.Edge.Right,at),i.setMargin(we.Edge.Bottom,st),i.setMargin(we.Edge.Left,J)}if(T){const{top:B,right:at,bottom:st,left:J}=Tu(T,e);i.setPadding(we.Edge.Top,B),i.setPadding(we.Edge.Right,at),i.setPadding(we.Edge.Bottom,st),i.setPadding(we.Edge.Left,J)}v&&i.setFlex(v),i.setGap(we.Gutter.All,(E??0)*e),o&&i.setWidth(typeof o=="number"?o*e:o),l&&(typeof l=="function"?i.setHeight("100%"):i.setHeight(typeof l=="number"?l*e:l)),d&&i.setMinWidth(typeof d=="number"?d*e:d),f&&i.setMinHeight(typeof f=="number"?f*e:f),p&&i.setMaxWidth(typeof p=="number"?p*e:p),g&&i.setMaxHeight(typeof g=="number"?g*e:g)}function wu({canvas:i,debug:t=!1,scale:e=1,position:r=[]}){r.forEach(({x:n,y:o,width:l,height:d,childNodes:f,element:p})=>{const g=i.getContext("2d",{alpha:!1});if(g){const{draw:v}=p;v&&(g.save(),v({scale:e,dx:n,dy:o,dw:l,dh:d}),t&&(g.strokeStyle="red",g.strokeRect(n,o,l,d))),wu({canvas:i,debug:t,scale:e,position:f}),g.restore()}})}function Su(i,t,e){const r=t.map((n,o)=>{const l=Au.Node.create(),{radius:d,elements:f=[],draw:p,...g}=n;return ku(l,{layout:g,scale:e}),i.insertChild(l,o),{node:l,element:n,childNodes:Su(l,f,e)}});return i.calculateLayout(),r}function Ru(i,t,e=0,r=0){const{top:n,left:o}=i.getComputedLayout();return t.map(({node:l,element:d,childNodes:f})=>{const{top:p,left:g,width:v,height:E}=l.getComputedLayout(),A=e+g,T=r+p;return{x:o+A,y:n+T,width:v,height:E,element:d,childNodes:Ru(i,f,A,T)}})}function _u(i,t){i.forEach(({node:e,element:r,childNodes:n})=>{const{height:o}=r;if(o&&typeof o=="function"){const l=e.getComputedWidth(),d=e.getComputedHeight(),f=o({width:l,maxHeight:d,scale:t});e.setHeight(f)}_u(n,t)})}function d1({canvas:i,origin:t,elements:e,...r}){const n={inset:{top:0,left:0},width:i.width,height:i.height,...t},o=Au.Node.create();ku(o,{layout:n}),o.calculateLayout();const{width:l,height:d}=o.getComputedLayout(),f=Math.min(l,d)/1080,p=Su(o,e,f);_u(p,f),o.calculateLayout();const g=Ru(o,p);return wu({...r,scale:f,canvas:i,position:g})}var Lu=function(){};const u1=(i,t,e)=>Math.min(Math.max(e,i),t),Cu=(i,t,e)=>{const r=t-i;return r===0?1:(e-i)/r},oc=(i,t,e)=>-e*i+e*t+i,Iu=(i,t)=>e=>Math.max(Math.min(e,t),i),ya=i=>i%1?Number(i.toFixed(5)):i,ko=/(-)?([\d]*\.?[\d])+/g,lc=/(#[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,f1=/^(#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2}(-?[\d\.]+%?)\s*[\,\/]?\s*[\d\.]*%?\))$/i;function ba(i){return typeof i=="string"}const wo={test:i=>typeof i=="number",parse:parseFloat,transform:i=>i},xu=Object.assign(Object.assign({},wo),{transform:Iu(0,1)});Object.assign(Object.assign({},wo),{default:1});const p1=i=>({test:t=>ba(t)&&t.endsWith(i)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${i}`}),Ea=p1("%");Object.assign(Object.assign({},Ea),{parse:i=>Ea.parse(i)/100,transform:i=>Ea.transform(i*100)});const cc=(i,t)=>e=>!!(ba(e)&&f1.test(e)&&e.startsWith(i)||t&&Object.prototype.hasOwnProperty.call(e,t)),Du=(i,t,e)=>r=>{if(!ba(r))return r;const[n,o,l,d]=r.match(ko);return{[i]:parseFloat(n),[t]:parseFloat(o),[e]:parseFloat(l),alpha:d!==void 0?parseFloat(d):1}},an={test:cc("hsl","hue"),parse:Du("hue","saturation","lightness"),transform:({hue:i,saturation:t,lightness:e,alpha:r=1})=>"hsla("+Math.round(i)+", "+Ea.transform(ya(t))+", "+Ea.transform(ya(e))+", "+ya(xu.transform(r))+")"},g1=Iu(0,255),hc=Object.assign(Object.assign({},wo),{transform:i=>Math.round(g1(i))}),Rs={test:cc("rgb","red"),parse:Du("red","green","blue"),transform:({red:i,green:t,blue:e,alpha:r=1})=>"rgba("+hc.transform(i)+", "+hc.transform(t)+", "+hc.transform(e)+", "+ya(xu.transform(r))+")"};function m1(i){let t="",e="",r="",n="";return i.length>5?(t=i.substr(1,2),e=i.substr(3,2),r=i.substr(5,2),n=i.substr(7,2)):(t=i.substr(1,1),e=i.substr(2,1),r=i.substr(3,1),n=i.substr(4,1),t+=t,e+=e,r+=r,n+=n),{red:parseInt(t,16),green:parseInt(e,16),blue:parseInt(r,16),alpha:n?parseInt(n,16)/255:1}}const dc={test:cc("#"),parse:m1,transform:Rs.transform},So={test:i=>Rs.test(i)||dc.test(i)||an.test(i),parse:i=>Rs.test(i)?Rs.parse(i):an.test(i)?an.parse(i):dc.parse(i),transform:i=>ba(i)?i:i.hasOwnProperty("red")?Rs.transform(i):an.transform(i)},Pu="${c}",Ou="${n}";function v1(i){var t,e,r,n;return isNaN(i)&&ba(i)&&((e=(t=i.match(ko))===null||t===void 0?void 0:t.length)!==null&&e!==void 0?e:0)+((n=(r=i.match(lc))===null||r===void 0?void 0:r.length)!==null&&n!==void 0?n:0)>0}function $u(i){typeof i=="number"&&(i=`${i}`);const t=[];let e=0;const r=i.match(lc);r&&(e=r.length,i=i.replace(lc,Pu),t.push(...r.map(So.parse)));const n=i.match(ko);return n&&(i=i.replace(ko,Ou),t.push(...n.map(wo.parse))),{values:t,numColors:e,tokenised:i}}function Mu(i){return $u(i).values}function Nu(i){const{values:t,numColors:e,tokenised:r}=$u(i),n=t.length;return o=>{let l=r;for(let d=0;d<n;d++)l=l.replace(d<e?Pu:Ou,d<e?So.transform(o[d]):ya(o[d]));return l}}const y1=i=>typeof i=="number"?0:i;function b1(i){const t=Mu(i);return Nu(i)(t.map(y1))}const Fu={test:v1,parse:Mu,createTransformer:Nu,getAnimatableNone:b1};function uc(i,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<.16666666666666666?i+(t-i)*6*e:e<.5?t:e<.6666666666666666?i+(t-i)*(.6666666666666666-e)*6:i}function Uu({hue:i,saturation:t,lightness:e,alpha:r}){i/=360,t/=100,e/=100;let n=0,o=0,l=0;if(!t)n=o=l=e;else{const d=e<.5?e*(1+t):e+t-e*t,f=2*e-d;n=uc(f,d,i+.3333333333333333),o=uc(f,d,i),l=uc(f,d,i-.3333333333333333)}return{red:Math.round(n*255),green:Math.round(o*255),blue:Math.round(l*255),alpha:r}}const E1=(i,t,e)=>{const r=i*i,n=t*t;return Math.sqrt(Math.max(0,e*(n-r)+r))},A1=[dc,Rs,an],Bu=i=>A1.find(t=>t.test(i)),Gu=(i,t)=>{let e=Bu(i),r=Bu(t),n=e.parse(i),o=r.parse(t);e===an&&(n=Uu(n),e=Rs),r===an&&(o=Uu(o),r=Rs);const l=Object.assign({},n);return d=>{for(const f in l)f!=="alpha"&&(l[f]=E1(n[f],o[f],d));return l.alpha=oc(n.alpha,o.alpha,d),e.transform(l)}},T1=i=>typeof i=="number",k1=(i,t)=>e=>t(i(e)),Hu=(...i)=>i.reduce(k1);function Vu(i,t){return T1(i)?e=>oc(i,t,e):So.test(i)?Gu(i,t):Ku(i,t)}const Wu=(i,t)=>{const e=[...i],r=e.length,n=i.map((o,l)=>Vu(o,t[l]));return o=>{for(let l=0;l<r;l++)e[l]=n[l](o);return e}},w1=(i,t)=>{const e=Object.assign(Object.assign({},i),t),r={};for(const n in e)i[n]!==void 0&&t[n]!==void 0&&(r[n]=Vu(i[n],t[n]));return n=>{for(const o in r)e[o]=r[o](n);return e}};function ju(i){const t=Fu.parse(i),e=t.length;let r=0,n=0,o=0;for(let l=0;l<e;l++)r||typeof t[l]=="number"?r++:t[l].hue!==void 0?o++:n++;return{parsed:t,numNumbers:r,numRGB:n,numHSL:o}}const Ku=(i,t)=>{const e=Fu.createTransformer(t),r=ju(i),n=ju(t);return r.numHSL===n.numHSL&&r.numRGB===n.numRGB&&r.numNumbers>=n.numNumbers?Hu(Wu(r.parsed,n.parsed),e):o=>`${o>0?t:i}`},S1=(i,t)=>e=>oc(i,t,e);function R1(i){if(typeof i=="number")return S1;if(typeof i=="string")return So.test(i)?Gu:Ku;if(Array.isArray(i))return Wu;if(typeof i=="object")return w1}function _1(i,t,e){const r=[],n=e||R1(i[0]),o=i.length-1;for(let l=0;l<o;l++){let d=n(i[l],i[l+1]);if(t){const f=Array.isArray(t)?t[l]:t;d=Hu(f,d)}r.push(d)}return r}function L1([i,t],[e]){return r=>e(Cu(i,t,r))}function C1(i,t){const e=i.length,r=e-1;return n=>{let o=0,l=!1;if(n<=i[0]?l=!0:n>=i[r]&&(o=r-1,l=!0),!l){let f=1;for(;f<e&&!(i[f]>n||f===r);f++);o=f-1}const d=Cu(i[o],i[o+1],n);return t[o](d)}}function I1(i,t,{clamp:e=!0,ease:r,mixer:n}={}){const o=i.length;Lu(o===t.length),Lu(!r||!Array.isArray(r)||r.length===o-1),i[0]>i[o-1]&&(i=[].concat(i),t=[].concat(t),i.reverse(),t.reverse());const l=_1(t,r,n),d=o===2?L1(i,l):C1(i,l);return e?f=>d(u1(i[0],i[o-1],f)):d}const Ro=i=>t=>1-i(1-t),fc=i=>t=>t<=.5?i(2*t)/2:(2-i(2*(1-t)))/2,x1=i=>t=>Math.pow(t,i),zu=i=>t=>t*t*((i+1)*t-i),D1=i=>{const t=zu(i);return e=>(e*=2)<1?.5*t(e):.5*(2-Math.pow(2,-10*(e-1)))},Yu=1.525,P1=4/11,O1=8/11,$1=9/10,M1=i=>i,pc=x1(2),N1=Ro(pc),F1=fc(pc),Xu=i=>1-Math.sin(Math.acos(i)),Zu=Ro(Xu),U1=fc(Zu),gc=zu(Yu),B1=Ro(gc),G1=fc(gc),H1=D1(Yu),V1=4356/361,W1=35442/1805,j1=16061/1805,_o=i=>{if(i===1||i===0)return i;const t=i*i;return i<P1?7.5625*t:i<O1?9.075*t-9.9*i+3.4:i<$1?V1*t-W1*i+j1:10.8*i*i-20.52*i+10.72},K1=Ro(_o),z1=i=>i<.5?.5*(1-_o(1-i*2)):.5*_o(i*2-1)+.5,Y1={linear:M1,easeIn:pc,easeInOut:F1,easeOut:N1,circIn:Xu,circInOut:U1,circOut:Zu,backIn:gc,backInOut:G1,backOut:B1,anticipate:H1,bounceIn:K1,bounceInOut:z1,bounceOut:_o},Lo=rc((i,t,{clamp:e=!0,ease:r="easeIn",...n}={})=>I1(i,t,{...n,clamp:e,ease:Y1[r]}),{cacheKey:([i,t,e])=>JSON.stringify({from:i,to:t,options:e})}),qu=[{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 Co({text:i,font:t}){let e=t;return qu.forEach(({family:r,regex:n})=>{n.exec(i)&&(e+=`, ${r}`)}),e}const rs=1.8,Io=/(?<value>\d+\.?\d*)(?=px)/;function X1(i,t=1){return typeof i=="number"?{topLeft:i*t,topRight:i*t,bottomRight:i*t,bottomLeft:i*t}:{topLeft:((i==null?void 0:i.topLeft)??0)*t,topRight:((i==null?void 0:i.topRight)??0)*t,bottomRight:((i==null?void 0:i.bottomRight)??0)*t,bottomLeft:((i==null?void 0:i.bottomLeft)??0)*t}}function Qu(i){const{visible:t,node:e}=i,r=[...(e==null?void 0:e.elements)??[],...(i==null?void 0:i.elements)??[]];return t??(e&&e.type!=="box"&&e.type!=="gradient"?!!e.value:r==null?void 0:r.some(n=>Qu(n)))}function Ju({debug:i=!1,canvas:t,cropCanvas:e,posterCanvas:r,letterboxCanvas:n,elements:o=[],currentTime:l,contentTime:d,sceneTime:f,totalDuration:p,contentDuration:g,sceneDuration:v}){return o.map(E=>{var A,T,w,C,D,M,U,x;const{node:O,transient:K=[{from:0,duration:1/0}]}=E,B=t.getContext("2d"),at={total:l,content:d,scene:f},st={total:p,content:g,scene:v},J=K.reduce((kt,{type:ft="scene",from:wt,duration:Pt,animation:F})=>{const j=wt<0?st[ft]+wt:wt;return at[ft]>=j&&at[ft]<=j+Pt&&(kt={type:ft,animation:F,duration:Pt,from:j}),kt},null);if(B&&J&&Qu(E)){let kt=E.width,ft=E.height;if((O==null?void 0:O.type)==="text"&&O.value){const wt=Co({text:O.value,font:O.font});B.save(),O.wrap?ft=({width:Pt,maxHeight:F,scale:j})=>{var bt,N;const G=yu({font:wt,scale:j,context:B,maxW:Pt,maxH:F,text:O.value??"",minSize:(bt=O.fill)==null?void 0:bt.minSize,maxSize:(N=O.fill)==null?void 0:N.maxSize});return xo({context:B,font:wt,fontSize:G,text:O.value??"",maxW:Pt}).length*G}:(B.font=wt,kt=B.measureText(O.value).width,ft=parseFloat(((T=(A=wt.match(Io))==null?void 0:A.groups)==null?void 0:T.value)??"0")),B.restore()}if((O==null?void 0:O.type)==="image"&&O.image&&O.size){const wt=((w=O.image)==null?void 0:w.naturalWidth)??((C=O.image)==null?void 0:C.width),Pt=((D=O.image)==null?void 0:D.naturalHeight)??((M=O.image)==null?void 0:M.height),F=wt/Pt,j=(U=O.size)==null?void 0:U.width,bt=(x=O.size)==null?void 0:x.height;kt=j??(F>=1?(bt??0)*F:(bt??0)/F),ft=bt??(F<1?(j??0)*F:(j??0)/F)}return{...E,width:kt,height:ft,elements:Ju({debug:i,canvas:t,cropCanvas:e,posterCanvas:r,letterboxCanvas:n,elements:E.elements,currentTime:l,contentTime:d,sceneTime:f,totalDuration:p,contentDuration:g,sceneDuration:v}),draw:({dx:wt,dy:Pt,dw:F,dh:j,scale:bt})=>{var N,G,Z,gt,vt,It,Bt,Xt,me,be,Ee,Ye,Le;const{type:Wt="scene",from:se,duration:le,animation:De={type:"fade",duration:.3333333333333333,easing:{in:"easeOut",out:"easeOut"}}}=J;if(De){const{type:Nt,duration:ne,easing:{in:ee="easeOut",out:$e="easeOut"}={}}=De;if(se>0&&at[Wt]<=se+ne)switch(Nt){case"fade":{const Me=Lo([se,se+ne],[0,1],{ease:ee});B.globalAlpha=Me(at[Wt]);break}case"slide":{const{options:Me}=De,ce={up:[{x:0,y:j},{x:0,y:0}],right:[{x:F,y:0},{x:0,y:0}],down:[{x:0,y:-j},{x:0,y:0}],left:[{x:-F,y:0},{x:0,y:0}]},Ce=Lo([se,se+ne],ce[Me.direction.in],{ease:ee}),{x:ie,y:Ie}=Ce(at[Wt]);B.translate(ie,Ie);break}}if(se+le<st[Wt]&&se+le-ne<=at[Wt])switch(Nt){case"fade":{const Me=Lo([se+le-ne,se+le],[1,0],{ease:$e});B.globalAlpha=Me(at[Wt]);break}case"slide":{const{options:Me}=De,ce={up:[{x:0,y:0},{x:0,y:-j}],right:[{x:0,y:0},{x:F,y:0}],down:[{x:0,y:0},{x:0,y:j}],left:[{x:0,y:0},{x:-F,y:0}]},Ce=Lo([se+le-ne,se+le],ce[Me.direction.out],{ease:$e}),{x:ie,y:Ie}=Ce(at[Wt]);B.translate(ie,Ie);break}}}if(O){const{type:Nt}=O;if(E.radius){const{topLeft:ne,topRight:ee,bottomRight:$e,bottomLeft:Me}=X1(E.radius,bt);B.beginPath(),B.moveTo(wt+Math.min(j/rs,ne),Pt),B.lineTo(wt+F-Math.min(j/rs,ee),Pt),B.quadraticCurveTo(wt+F,Pt,wt+F,Pt+Math.min(j/rs,ee)),B.lineTo(wt+F,Pt+j-Math.min(j/rs,$e)),B.quadraticCurveTo(wt+F,Pt+j,wt+F-Math.min(j/rs,$e),Pt+j),B.lineTo(wt+Math.min(j/rs,Me),Pt+j),B.quadraticCurveTo(wt,Pt+j,wt,Pt+j-Math.min(j/rs,Me)),B.lineTo(wt,Pt+Math.min(j/rs,ne)),B.quadraticCurveTo(wt,Pt,wt+Math.min(j/rs,ne),Pt),B.closePath(),i&&(B.strokeStyle="blue",B.stroke()),B.clip()}if(Nt==="box"&&(B.fillStyle=O.background,B.fillRect(wt,Pt,F,j)),Nt==="text"&&O.value){const{align:ne="left"}=O,ee=Co({text:O.value,font:O.font}),$e=yu({font:ee,scale:bt,context:B,maxW:F,maxH:j,text:O.value??"",minSize:(N=O.fill)==null?void 0:N.minSize,maxSize:(G=O.fill)==null?void 0:G.maxSize});B.font=ee.replace(Io,$e.toString()),B.textBaseline="top",B.fillStyle=O.color,B.textAlign=ne;const Me={left:wt,center:wt+F/2,right:wt+F};O.wrap?xo({context:B,font:ee,fontSize:$e,text:O.value,maxW:F}).forEach((ce,Ce)=>{B.fillText(ce.text,Me[ne],Pt+$e*Ce)}):B.fillText(O.value,Me[ne],Pt)}if(Nt==="image"&&O.image&&B.drawImage(O.image,wt,Pt,F,j),Nt==="video"&&((Z=O.video)!=null&&Z.node||(gt=O.video)!=null&&gt.getSource)){const ne=O.format??"letterbox",ee=((It=(vt=O.video)==null?void 0:vt.getSource)==null?void 0:It.call(vt,f))??O.video.node,$e=(ee==null?void 0:ee.videoWidth)??(ee==null?void 0:ee.naturalWidth)??(ee==null?void 0:ee.width),Me=(ee==null?void 0:ee.videoHeight)??(ee==null?void 0:ee.naturalHeight)??(ee==null?void 0:ee.height);if($e&&Me){const{dx:Ce,dy:ie,dw:Ie,dh:We}=gu({context:B,cropCanvas:e,letterboxCanvas:n,source:ee,format:ne,crop:(Bt=O==null?void 0:O.value)==null?void 0:Bt.crop,sourceWidth:$e,sourceHeight:Me,posX:wt,posY:Pt,drawAreaWidth:F,drawAreaHeight:j});O.elements&&mc({debug:i,canvas:t,cropCanvas:e,posterCanvas:r,letterboxCanvas:n,elements:O.elements,currentTime:l,contentTime:d,sceneTime:f,totalDuration:p,contentDuration:g,sceneDuration:v,origin:{inset:{top:Math.max(Pt,Pt+ie),left:Math.max(wt,wt+Ce)},width:Math.min(F,Ie),height:Math.min(j,We)}})}const ce=1/3;if(O.poster&&l>=0&&l<=ce){B.save(),B.globalAlpha=1-l/ce;const Ce=((Xt=O.poster)==null?void 0:Xt.naturalWidth)??((me=O.poster)==null?void 0:me.width),ie=((be=O.poster)==null?void 0:be.naturalHeight)??((Ee=O.poster)==null?void 0:Ee.height);r.width=r.height=0,r.width=F,r.height=j;const Ie=r.getContext("2d");if(Ie&&Ce&&ie){const{dx:We,dy:Pr,dw:Be,dh:br}=gu({context:Ie,cropCanvas:e,letterboxCanvas:n,source:O.poster,format:ne,crop:(Ye=O==null?void 0:O.value)==null?void 0:Ye.crop,sourceWidth:Ce,sourceHeight:ie,posX:0,posY:0,drawAreaWidth:F,drawAreaHeight:j});O.elements&&mc({debug:i,canvas:r,cropCanvas:e,posterCanvas:r,letterboxCanvas:n,elements:O.elements,currentTime:l,contentTime:d,sceneTime:f,totalDuration:p,contentDuration:g,sceneDuration:v,origin:{inset:{top:Math.max(0,Pr),left:Math.max(0,We)},width:Math.min(F,Be),height:Math.min(j,br)}}),B.drawImage(r,wt,Pt,F,j),B.restore()}}}if(Nt==="gradient"&&O.value){const ne=B.createLinearGradient(wt+F,Pt,wt+F,Pt+j);(Le=O.value)==null||Le.forEach(ee=>{ne.addColorStop(ee.percent,ee.color)}),B.fillStyle=ne,B.fillRect(wt,Pt,F,j)}}}}}}).filter(Boolean)}function mc({debug:i,canvas:t,cropCanvas:e,posterCanvas:r,letterboxCanvas:n,elements:o,currentTime:l,contentTime:d,sceneTime:f,totalDuration:p,contentDuration:g,sceneDuration:v,...E}){return d1({...E,debug:i,canvas:t,elements:Ju({debug:i,canvas:t,cropCanvas:e,posterCanvas:r,letterboxCanvas:n,elements:o,currentTime:l,contentTime:d,sceneTime:f,totalDuration:p,contentDuration:g,sceneDuration:v})})}const xo=rc(({context:i,font:t,fontSize:e,text:r,maxW:n=1/0})=>{try{return i.save(),i.font=t.replace(Io,e.toString()),r.split(`
89
+ ${t}`,t1=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),e1=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),r1=(i,t,e)=>{const r=e===""?"":`with ${e.trim()}() `,n=Jm.bind(null,r,t.toString());Object.defineProperty(n,"name",e1),Object.defineProperty(i,"toString",{...t1,value:n})};function i1(i,t,{ignoreNonConfigurable:e=!1}={}){const{name:r}=i;for(const n of Reflect.ownKeys(t))Zm(i,t,n,e);return Qm(i,t),r1(i,t,r),i}const s1=new WeakMap,mu=new WeakMap;function rc(i,{cacheKey:t,cache:e=new Map,maxAge:r}={}){if(r===0)return i;if(typeof r=="number"){if(r>2147483647)throw new TypeError("The `maxAge` option cannot exceed 2147483647.");if(r<0)throw new TypeError("The `maxAge` option should not be a negative number.")}const n=function(...o){var l;const d=t?t(o):o[0],f=e.get(d);if(f)return f.data;const p=i.apply(this,o);if(e.set(d,{data:p,maxAge:r?Date.now()+r:Number.POSITIVE_INFINITY}),typeof r=="number"&&r!==Number.POSITIVE_INFINITY){const g=setTimeout(()=>{e.delete(d)},r);(l=g.unref)==null||l.call(g);const v=mu.get(i)??new Set;v.add(g),mu.set(i,v)}return p};return i1(n,i,{ignoreNonConfigurable:!0}),s1.set(n,e),n}function vu({context:i,word:t,maxW:e=1/0}){const r=[],n=i.measureText(t);if(n.width<e)return[{text:t,metrics:n}];for(let o=0;o<t.length;o++){const l=r[r.length-1],d=((l==null?void 0:l.text)??"")+t[o],f=i.measureText(d);f.width<e?r[l?r.length-1:0]={text:d,metrics:f}:r.push({text:t[o],metrics:i.measureText(t[o])})}return r}const yu=rc(({font:i,scale:t,context:e,maxW:r,maxH:n,text:o,minSize:l,maxSize:d})=>{var f,p;let g=0;if(d){g=(l??0)*t;let v=0;for(;d*t>g+1;){g+=1;const E=xo({context:e,font:i,fontSize:g,text:o,maxW:r});if(v=E.reduce((A,T)=>(T.metrics.width>A&&(A=T.metrics.width),A),0),v>r||E.length*g>n){g-=1;break}}}else g=parseFloat(((p=(f=i.match(Io))==null?void 0:f.groups)==null?void 0:p.value)??"0")*t;return g},{cacheKey:([{font:i,text:t,minSize:e,maxSize:r,scale:n,maxW:o,maxH:l}])=>`${i}_${t}_${e}_${r}_${n}_${o}_${l}`});function n1(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var we={},ic={},oe={};Object.defineProperty(oe,"__esModule",{value:!0}),oe.default=oe.Wrap=oe.Unit=oe.PrintOptions=oe.PositionType=oe.Overflow=oe.NodeType=oe.MeasureMode=oe.LogLevel=oe.Justify=oe.Gutter=oe.FlexDirection=oe.ExperimentalFeature=oe.Errata=oe.Edge=oe.Display=oe.Direction=oe.Dimension=oe.Align=void 0;let es=function(i){return i[i.Auto=0]="Auto",i[i.FlexStart=1]="FlexStart",i[i.Center=2]="Center",i[i.FlexEnd=3]="FlexEnd",i[i.Stretch=4]="Stretch",i[i.Baseline=5]="Baseline",i[i.SpaceBetween=6]="SpaceBetween",i[i.SpaceAround=7]="SpaceAround",i}({});oe.Align=es;let sc=function(i){return i[i.Width=0]="Width",i[i.Height=1]="Height",i}({});oe.Dimension=sc;let go=function(i){return i[i.Inherit=0]="Inherit",i[i.LTR=1]="LTR",i[i.RTL=2]="RTL",i}({});oe.Direction=go;let nc=function(i){return i[i.Flex=0]="Flex",i[i.None=1]="None",i}({});oe.Display=nc;let Pi=function(i){return i[i.Left=0]="Left",i[i.Top=1]="Top",i[i.Right=2]="Right",i[i.Bottom=3]="Bottom",i[i.Start=4]="Start",i[i.End=5]="End",i[i.Horizontal=6]="Horizontal",i[i.Vertical=7]="Vertical",i[i.All=8]="All",i}({});oe.Edge=Pi;let ga=function(i){return i[i.None=0]="None",i[i.StretchFlexBasis=1]="StretchFlexBasis",i[i.All=2147483647]="All",i[i.Classic=2147483646]="Classic",i}({});oe.Errata=ga;let mo=function(i){return i[i.WebFlexBasis=0]="WebFlexBasis",i[i.AbsolutePercentageAgainstPaddingEdge=1]="AbsolutePercentageAgainstPaddingEdge",i[i.FixJNILocalRefOverflows=2]="FixJNILocalRefOverflows",i}({});oe.ExperimentalFeature=mo;let ma=function(i){return i[i.Column=0]="Column",i[i.ColumnReverse=1]="ColumnReverse",i[i.Row=2]="Row",i[i.RowReverse=3]="RowReverse",i}({});oe.FlexDirection=ma;let vo=function(i){return i[i.Column=0]="Column",i[i.Row=1]="Row",i[i.All=2]="All",i}({});oe.Gutter=vo;let sn=function(i){return i[i.FlexStart=0]="FlexStart",i[i.Center=1]="Center",i[i.FlexEnd=2]="FlexEnd",i[i.SpaceBetween=3]="SpaceBetween",i[i.SpaceAround=4]="SpaceAround",i[i.SpaceEvenly=5]="SpaceEvenly",i}({});oe.Justify=sn;let nn=function(i){return i[i.Error=0]="Error",i[i.Warn=1]="Warn",i[i.Info=2]="Info",i[i.Debug=3]="Debug",i[i.Verbose=4]="Verbose",i[i.Fatal=5]="Fatal",i}({});oe.LogLevel=nn;let yo=function(i){return i[i.Undefined=0]="Undefined",i[i.Exactly=1]="Exactly",i[i.AtMost=2]="AtMost",i}({});oe.MeasureMode=yo;let ac=function(i){return i[i.Default=0]="Default",i[i.Text=1]="Text",i}({});oe.NodeType=ac;let bo=function(i){return i[i.Visible=0]="Visible",i[i.Hidden=1]="Hidden",i[i.Scroll=2]="Scroll",i}({});oe.Overflow=bo;let Eo=function(i){return i[i.Static=0]="Static",i[i.Relative=1]="Relative",i[i.Absolute=2]="Absolute",i}({});oe.PositionType=Eo;let Ao=function(i){return i[i.Layout=1]="Layout",i[i.Style=2]="Style",i[i.Children=4]="Children",i}({});oe.PrintOptions=Ao;let va=function(i){return i[i.Undefined=0]="Undefined",i[i.Point=1]="Point",i[i.Percent=2]="Percent",i[i.Auto=3]="Auto",i}({});oe.Unit=va;let To=function(i){return i[i.NoWrap=0]="NoWrap",i[i.Wrap=1]="Wrap",i[i.WrapReverse=2]="WrapReverse",i}({});oe.Wrap=To;var a1={ALIGN_AUTO:es.Auto,ALIGN_FLEX_START:es.FlexStart,ALIGN_CENTER:es.Center,ALIGN_FLEX_END:es.FlexEnd,ALIGN_STRETCH:es.Stretch,ALIGN_BASELINE:es.Baseline,ALIGN_SPACE_BETWEEN:es.SpaceBetween,ALIGN_SPACE_AROUND:es.SpaceAround,DIMENSION_WIDTH:sc.Width,DIMENSION_HEIGHT:sc.Height,DIRECTION_INHERIT:go.Inherit,DIRECTION_LTR:go.LTR,DIRECTION_RTL:go.RTL,DISPLAY_FLEX:nc.Flex,DISPLAY_NONE:nc.None,EDGE_LEFT:Pi.Left,EDGE_TOP:Pi.Top,EDGE_RIGHT:Pi.Right,EDGE_BOTTOM:Pi.Bottom,EDGE_START:Pi.Start,EDGE_END:Pi.End,EDGE_HORIZONTAL:Pi.Horizontal,EDGE_VERTICAL:Pi.Vertical,EDGE_ALL:Pi.All,ERRATA_NONE:ga.None,ERRATA_STRETCH_FLEX_BASIS:ga.StretchFlexBasis,ERRATA_ALL:ga.All,ERRATA_CLASSIC:ga.Classic,EXPERIMENTAL_FEATURE_WEB_FLEX_BASIS:mo.WebFlexBasis,EXPERIMENTAL_FEATURE_ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE:mo.AbsolutePercentageAgainstPaddingEdge,EXPERIMENTAL_FEATURE_FIX_JNILOCAL_REF_OVERFLOWS:mo.FixJNILocalRefOverflows,FLEX_DIRECTION_COLUMN:ma.Column,FLEX_DIRECTION_COLUMN_REVERSE:ma.ColumnReverse,FLEX_DIRECTION_ROW:ma.Row,FLEX_DIRECTION_ROW_REVERSE:ma.RowReverse,GUTTER_COLUMN:vo.Column,GUTTER_ROW:vo.Row,GUTTER_ALL:vo.All,JUSTIFY_FLEX_START:sn.FlexStart,JUSTIFY_CENTER:sn.Center,JUSTIFY_FLEX_END:sn.FlexEnd,JUSTIFY_SPACE_BETWEEN:sn.SpaceBetween,JUSTIFY_SPACE_AROUND:sn.SpaceAround,JUSTIFY_SPACE_EVENLY:sn.SpaceEvenly,LOG_LEVEL_ERROR:nn.Error,LOG_LEVEL_WARN:nn.Warn,LOG_LEVEL_INFO:nn.Info,LOG_LEVEL_DEBUG:nn.Debug,LOG_LEVEL_VERBOSE:nn.Verbose,LOG_LEVEL_FATAL:nn.Fatal,MEASURE_MODE_UNDEFINED:yo.Undefined,MEASURE_MODE_EXACTLY:yo.Exactly,MEASURE_MODE_AT_MOST:yo.AtMost,NODE_TYPE_DEFAULT:ac.Default,NODE_TYPE_TEXT:ac.Text,OVERFLOW_VISIBLE:bo.Visible,OVERFLOW_HIDDEN:bo.Hidden,OVERFLOW_SCROLL:bo.Scroll,POSITION_TYPE_STATIC:Eo.Static,POSITION_TYPE_RELATIVE:Eo.Relative,POSITION_TYPE_ABSOLUTE:Eo.Absolute,PRINT_OPTIONS_LAYOUT:Ao.Layout,PRINT_OPTIONS_STYLE:Ao.Style,PRINT_OPTIONS_CHILDREN:Ao.Children,UNIT_UNDEFINED:va.Undefined,UNIT_POINT:va.Point,UNIT_PERCENT:va.Percent,UNIT_AUTO:va.Auto,WRAP_NO_WRAP:To.NoWrap,WRAP_WRAP:To.Wrap,WRAP_WRAP_REVERSE:To.WrapReverse};oe.default=a1,Object.defineProperty(ic,"__esModule",{value:!0}),ic.default=l1;var Ss=o1(oe);function bu(i){if(typeof WeakMap!="function")return null;var t=new WeakMap,e=new WeakMap;return(bu=function(r){return r?e:t})(i)}function o1(i,t){if(!t&&i&&i.__esModule)return i;if(i===null||typeof i!="object"&&typeof i!="function")return{default:i};var e=bu(t);if(e&&e.has(i))return e.get(i);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in i)if(o!=="default"&&Object.prototype.hasOwnProperty.call(i,o)){var l=n?Object.getOwnPropertyDescriptor(i,o):null;l&&(l.get||l.set)?Object.defineProperty(r,o,l):r[o]=i[o]}return r.default=i,e&&e.set(i,r),r}function l1(i){function t(n,o,l){const d=n[o];n[o]=function(){for(var f=arguments.length,p=new Array(f),g=0;g<f;g++)p[g]=arguments[g];return l.call(this,d,...p)}}for(const n of["setPosition","setMargin","setFlexBasis","setWidth","setHeight","setMinWidth","setMinHeight","setMaxWidth","setMaxHeight","setPadding"]){const o={[Ss.Unit.Point]:i.Node.prototype[n],[Ss.Unit.Percent]:i.Node.prototype[`${n}Percent`],[Ss.Unit.Auto]:i.Node.prototype[`${n}Auto`]};t(i.Node.prototype,n,function(l){for(var d=arguments.length,f=new Array(d>1?d-1:0),p=1;p<d;p++)f[p-1]=arguments[p];const g=f.pop();let v,E;if(g==="auto")v=Ss.Unit.Auto,E=void 0;else if(typeof g=="object")v=g.unit,E=g.valueOf();else if(v=typeof g=="string"&&g.endsWith("%")?Ss.Unit.Percent:Ss.Unit.Point,E=parseFloat(g),!Number.isNaN(g)&&Number.isNaN(E))throw new Error(`Invalid value ${g} for ${n}`);if(!o[v])throw new Error(`Failed to execute "${n}": Unsupported unit '${g}'`);return E!==void 0?o[v].call(this,...f,E):o[v].call(this,...f)})}function e(n){return i.MeasureCallback.implement({measure:function(){const{width:o,height:l}=n(...arguments);return{width:o??NaN,height:l??NaN}}})}t(i.Node.prototype,"setMeasureFunc",function(n,o){return o?n.call(this,e(o)):this.unsetMeasureFunc()});function r(n){return i.DirtiedCallback.implement({dirtied:n})}return t(i.Node.prototype,"setDirtiedFunc",function(n,o){n.call(this,r(o))}),t(i.Config.prototype,"free",function(){i.Config.destroy(this)}),t(i.Node,"create",(n,o)=>o?i.Node.createWithConfig(o):i.Node.createDefault()),t(i.Node.prototype,"free",function(){i.Node.destroy(this)}),t(i.Node.prototype,"freeRecursive",function(){for(let n=0,o=this.getChildCount();n<o;++n)this.getChild(0).freeRecursive();this.free()}),t(i.Node.prototype,"calculateLayout",function(n){let o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:NaN,l=arguments.length>2&&arguments[2]!==void 0?arguments[2]:NaN,d=arguments.length>3&&arguments[3]!==void 0?arguments[3]:Ss.Direction.LTR;return n.call(this,o,l,d)}),{Config:i.Config,Node:i.Node,...Ss.default}}var Eu={exports:{}};(function(i,t){var e=(()=>{var r=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return function(n){n=n||{};var o;o||(o=typeof n<"u"?n:{});var l,d;o.ready=new Promise(function(_,L){l=_,d=L});var f=Object.assign({},o),p="";typeof document<"u"&&document.currentScript&&(p=document.currentScript.src),r&&(p=r),p.indexOf("blob:")!==0?p=p.substr(0,p.replace(/[?#].*/,"").lastIndexOf("/")+1):p="";var g=o.print||console.log.bind(console),v=o.printErr||console.warn.bind(console);Object.assign(o,f),f=null;var E;o.wasmBinary&&(E=o.wasmBinary),o.noExitRuntime;function A(){this.buffer=new ArrayBuffer(F/65536*65536)}function T(){}function w(_){this.exports=function(L){function H(nr){return nr.set=function(ue,oi){this[ue]=oi},nr.get=function(ue){return this[ue]},nr}for(var V,rt=new Uint8Array(123),yt=25;yt>=0;--yt)rt[48+yt]=52+yt,rt[65+yt]=yt,rt[97+yt]=26+yt;rt[43]=62,rt[47]=63;function lt(nr,ue,oi){for(var Br,pt,Vi=0,c=ue,Tt=oi.length,Hn=ue+(Tt*3>>2)-(oi[Tt-2]=="=")-(oi[Tt-1]=="=");Vi<Tt;Vi+=4)Br=rt[oi.charCodeAt(Vi+1)],pt=rt[oi.charCodeAt(Vi+2)],nr[c++]=rt[oi.charCodeAt(Vi)]<<2|Br>>4,c<Hn&&(nr[c++]=Br<<4|pt>>2),c<Hn&&(nr[c++]=pt<<6|rt[oi.charCodeAt(Vi+3)])}function Lt(nr){lt(V,1024,"T25seSBsZWFmIG5vZGVzIHdpdGggY3VzdG9tIG1lYXN1cmUgZnVuY3Rpb25zIHNob3VsZCBtYW51YWxseSBtYXJrIHRoZW1zZWx2ZXMgYXMgZGlydHkAaXNEaXJ0eQBtYXJrRGlydHkAZGVzdHJveQBzZXREaXNwbGF5AGdldERpc3BsYXkAc2V0RmxleAAtKyAgIDBYMHgALTBYKzBYIDBYLTB4KzB4IDB4AHNldEZsZXhHcm93AGdldEZsZXhHcm93AHNldE92ZXJmbG93AGdldE92ZXJmbG93AGNhbGN1bGF0ZUxheW91dABnZXRDb21wdXRlZExheW91dAB1bnNpZ25lZCBzaG9ydABnZXRDaGlsZENvdW50AHVuc2lnbmVkIGludABzZXRKdXN0aWZ5Q29udGVudABnZXRKdXN0aWZ5Q29udGVudABzZXRBbGlnbkNvbnRlbnQAZ2V0QWxpZ25Db250ZW50AGdldFBhcmVudABpbXBsZW1lbnQAc2V0TWF4SGVpZ2h0UGVyY2VudABzZXRIZWlnaHRQZXJjZW50AHNldE1pbkhlaWdodFBlcmNlbnQAc2V0RmxleEJhc2lzUGVyY2VudABzZXRQb3NpdGlvblBlcmNlbnQAc2V0TWFyZ2luUGVyY2VudABzZXRNYXhXaWR0aFBlcmNlbnQAc2V0V2lkdGhQZXJjZW50AHNldE1pbldpZHRoUGVyY2VudABzZXRQYWRkaW5nUGVyY2VudABjcmVhdGVEZWZhdWx0AHVuaXQAcmlnaHQAaGVpZ2h0AHNldE1heEhlaWdodABnZXRNYXhIZWlnaHQAc2V0SGVpZ2h0AGdldEhlaWdodABzZXRNaW5IZWlnaHQAZ2V0TWluSGVpZ2h0AGdldENvbXB1dGVkSGVpZ2h0AGdldENvbXB1dGVkUmlnaHQAbGVmdABnZXRDb21wdXRlZExlZnQAcmVzZXQAX19kZXN0cnVjdABmbG9hdAB1aW50NjRfdAB1c2VXZWJEZWZhdWx0cwBzZXRVc2VXZWJEZWZhdWx0cwBzZXRBbGlnbkl0ZW1zAGdldEFsaWduSXRlbXMAc2V0RmxleEJhc2lzAGdldEZsZXhCYXNpcwBDYW5ub3QgZ2V0IGxheW91dCBwcm9wZXJ0aWVzIG9mIG11bHRpLWVkZ2Ugc2hvcnRoYW5kcwB1c2VMZWdhY3lTdHJldGNoQmVoYXZpb3VyAHNldFVzZUxlZ2FjeVN0cmV0Y2hCZWhhdmlvdXIAc2V0UG9pbnRTY2FsZUZhY3RvcgBNZWFzdXJlQ2FsbGJhY2tXcmFwcGVyAERpcnRpZWRDYWxsYmFja1dyYXBwZXIAQ2Fubm90IHJlc2V0IGEgbm9kZSBzdGlsbCBhdHRhY2hlZCB0byBhIG93bmVyAHNldEJvcmRlcgBnZXRCb3JkZXIAZ2V0Q29tcHV0ZWRCb3JkZXIAdW5zaWduZWQgY2hhcgB0b3AAZ2V0Q29tcHV0ZWRUb3AAc2V0RmxleFdyYXAAZ2V0RmxleFdyYXAAc2V0R2FwAGdldEdhcAAlcABzZXRIZWlnaHRBdXRvAHNldEZsZXhCYXNpc0F1dG8Ac2V0TWFyZ2luQXV0bwBzZXRXaWR0aEF1dG8AU2NhbGUgZmFjdG9yIHNob3VsZCBub3QgYmUgbGVzcyB0aGFuIHplcm8Ac2V0QXNwZWN0UmF0aW8AZ2V0QXNwZWN0UmF0aW8Ac2V0UG9zaXRpb24AZ2V0UG9zaXRpb24Abm90aWZ5T25EZXN0cnVjdGlvbgBzZXRGbGV4RGlyZWN0aW9uAGdldEZsZXhEaXJlY3Rpb24Ac2V0TWFyZ2luAGdldE1hcmdpbgBnZXRDb21wdXRlZE1hcmdpbgBuYW4AYm90dG9tAGdldENvbXB1dGVkQm90dG9tAGJvb2wAZW1zY3JpcHRlbjo6dmFsAHNldEZsZXhTaHJpbmsAZ2V0RmxleFNocmluawBNZWFzdXJlQ2FsbGJhY2sARGlydGllZENhbGxiYWNrAHdpZHRoAHNldE1heFdpZHRoAGdldE1heFdpZHRoAHNldFdpZHRoAGdldFdpZHRoAHNldE1pbldpZHRoAGdldE1pbldpZHRoAGdldENvbXB1dGVkV2lkdGgAdW5zaWduZWQgbG9uZwBzdGQ6OndzdHJpbmcAc3RkOjpzdHJpbmcAc3RkOjp1MTZzdHJpbmcAc3RkOjp1MzJzdHJpbmcAc2V0UGFkZGluZwBnZXRQYWRkaW5nAGdldENvbXB1dGVkUGFkZGluZwBBdHRlbXB0aW5nIHRvIGNvbnN0cnVjdCBZR05vZGUgd2l0aCBudWxsIGNvbmZpZwBUcmllZCB0byBjb25zdHJ1Y3QgWUdOb2RlIHdpdGggbnVsbCBjb25maWcAY3JlYXRlV2l0aENvbmZpZwBpbmYAc2V0QWxpZ25TZWxmAGdldEFsaWduU2VsZgBTaXplAHZhbHVlAFZhbHVlAGNyZWF0ZQBtZWFzdXJlAHNldFBvc2l0aW9uVHlwZQBnZXRQb3NpdGlvblR5cGUAaXNSZWZlcmVuY2VCYXNlbGluZQBzZXRJc1JlZmVyZW5jZUJhc2VsaW5lAGNvcHlTdHlsZQBkb3VibGUATm9kZQBleHRlbmQAaW5zZXJ0Q2hpbGQAZ2V0Q2hpbGQAcmVtb3ZlQ2hpbGQAdm9pZABhdmFpbGFibGVIZWlnaHQgaXMgaW5kZWZpbml0ZSBzbyBoZWlnaHRNZWFzdXJlTW9kZSBtdXN0IGJlIFlHTWVhc3VyZU1vZGVVbmRlZmluZWQAYXZhaWxhYmxlV2lkdGggaXMgaW5kZWZpbml0ZSBzbyB3aWR0aE1lYXN1cmVNb2RlIG11c3QgYmUgWUdNZWFzdXJlTW9kZVVuZGVmaW5lZABzZXRFeHBlcmltZW50YWxGZWF0dXJlRW5hYmxlZABpc0V4cGVyaW1lbnRhbEZlYXR1cmVFbmFibGVkAGRpcnRpZWQAQ2Fubm90IHJlc2V0IGEgbm9kZSB3aGljaCBzdGlsbCBoYXMgY2hpbGRyZW4gYXR0YWNoZWQAdW5zZXRNZWFzdXJlRnVuYwB1bnNldERpcnRpZWRGdW5jAHNldEVycmF0YQBnZXRFcnJhdGEARXhwZWN0IGN1c3RvbSBiYXNlbGluZSBmdW5jdGlvbiB0byBub3QgcmV0dXJuIE5hTgBOQU4ASU5GAGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PHNob3J0PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzx1bnNpZ25lZCBzaG9ydD4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8aW50PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzx1bnNpZ25lZCBpbnQ+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PGZsb2F0PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzx1aW50OF90PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzxpbnQ4X3Q+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PHVpbnQxNl90PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzxpbnQxNl90PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzx1aW50MzJfdD4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8aW50MzJfdD4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8Y2hhcj4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8dW5zaWduZWQgY2hhcj4Ac3RkOjpiYXNpY19zdHJpbmc8dW5zaWduZWQgY2hhcj4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8c2lnbmVkIGNoYXI+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PGxvbmc+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PHVuc2lnbmVkIGxvbmc+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PGRvdWJsZT4AQ2hpbGQgYWxyZWFkeSBoYXMgYSBvd25lciwgaXQgbXVzdCBiZSByZW1vdmVkIGZpcnN0LgBDYW5ub3Qgc2V0IG1lYXN1cmUgZnVuY3Rpb246IE5vZGVzIHdpdGggbWVhc3VyZSBmdW5jdGlvbnMgY2Fubm90IGhhdmUgY2hpbGRyZW4uAENhbm5vdCBhZGQgY2hpbGQ6IE5vZGVzIHdpdGggbWVhc3VyZSBmdW5jdGlvbnMgY2Fubm90IGhhdmUgY2hpbGRyZW4uAChudWxsKQAlcwoAAQAAAAMAAAAAAAAAAgAAAAMAAAABAAAAAgAAAAAAAAABAAAAAQ=="),lt(V,4338,"wH8DAAAAAADAfwAAAABpaQB2AHZp"),lt(V,4368,"exsAAHkbAAC5GwAAsxsAALkbAACzGwAAaWlpZmlmaQCsGwAAfBsAAHZpaQB9GwAAwBsAAGlpaQ=="),lt(V,4432,"xwAAAMgAAADJ"),lt(V,4452,"xwAAAMoAAADLAAAArBs="),lt(V,4480,"exsAALkbAACzGwAAuRsAALMbAADAGwAAuxsAAMAbAABpaWlpAAAAAKwbAACRGwAArBsAAJMbAACUGwAAwBs="),lt(V,4552,"zAAAAM0AAADO"),lt(V,4572,"zAAAAM8AAADLAAAAlxsAAKwbAACXGw=="),lt(V,4608,"rBsAAJcbAACzGwAArRsAAHZpaWlpAAAArBsAAJcbAAC5GwAAdmlpZgAAAACsGwAAlxsAAK0bAAB2aWlpAAAAAKwbAACXGwAAsxsAAK0bAACYGwAAsxsAAK0bAACYGwAAsxsAAJgbAABpAGRpaQB2aWlkAACcGwAAnBsAAJcbAACsGwAAnBsAAKwbAACcGwAAmxsAAKwbAACcGwAAsxsAAKwbAACcGwAAsxsAALobAAB2aWlpZAAAAKwbAACcGwAAuhsAALMbAACdGwAAmhsAAJ0bAACzGwAAmhsAAJ0bAAC6GwAAnRsAALobAACdGwAAsxsAAGRpaWkAAAAAuRsAAJwbAACzGwAAZmlpaQAAAACsGwAAnBsAAJwbAAC0GwAArBsAAJwbAACcGwAAtBsAAJ0bAACcGwAAnBsAAJwbAACcGwAAtBsAAK0bAACcGwAArBsAAJwbAACtGwAArBsAAJwbAAB5GwAArBsAAJwbAACRGwAArRsAAJ0bAAAAAAAArBsAAJwbAAC6GwAAuhsAALMbAAB2aWlkZGkAAJkbAACdGw=="),lt(V,5040,"GQAKABkZGQAAAAAFAAAAAAAACQAAAAALAAAAAAAAAAAZABEKGRkZAwoHAAEACQsYAAAJBgsAAAsABhkAAAAZGRk="),lt(V,5121,"DgAAAAAAAAAAGQAKDRkZGQANAAACAAkOAAAACQAOAAAO"),lt(V,5179,"DA=="),lt(V,5191,"EwAAAAATAAAAAAkMAAAAAAAMAAAM"),lt(V,5237,"EA=="),lt(V,5249,"DwAAAAQPAAAAAAkQAAAAAAAQAAAQ"),lt(V,5295,"Eg=="),lt(V,5307,"EQAAAAARAAAAAAkSAAAAAAASAAASAAAaAAAAGhoa"),lt(V,5362,"GgAAABoaGgAAAAAAAAk="),lt(V,5411,"FA=="),lt(V,5423,"FwAAAAAXAAAAAAkUAAAAAAAUAAAU"),lt(V,5469,"Fg=="),lt(V,5481,"FQAAAAAVAAAAAAkWAAAAAAAWAAAWAAAwMTIzNDU2Nzg5QUJDREVG"),lt(V,5556,"1Q=="),lt(V,5596,"//////////8="),lt(V,5664,"8B8BAAAAAAAF"),lt(V,5684,"0A=="),lt(V,5708,"0QAAANIAAADUGw=="),lt(V,5732,"Ag=="),lt(V,5748,"//////////8="),lt(V,5816,"BQ=="),lt(V,5828,"0w=="),lt(V,5852,"0QAAANQAAADoGwAAAAQ="),lt(V,5876,"AQ=="),lt(V,5892,"/////wo="),lt(V,5960,"1g==")}var xt=new ArrayBuffer(16),Dt=new Int32Array(xt),Ut=new Float32Array(xt),Kt=new Float64Array(xt);function te(nr){return Dt[nr]}function Ot(nr,ue){Dt[nr]=ue}function ke(){return Kt[0]}function Er(nr){Kt[0]=nr}function pe(){throw new Error("abort")}function Jr(nr){Ut[2]=nr}function Gt(){return Ut[2]}function yl(nr){var ue=nr.a,oi=ue.a,Br=oi.buffer;oi.grow=ES;var pt=new Int8Array(Br),Vi=new Int16Array(Br),c=new Int32Array(Br),Tt=new Uint8Array(Br),Hn=new Uint16Array(Br),c2=new Uint32Array(Br),I=new Float32Array(Br),je=new Float64Array(Br),Ke=Math.imul,m=Math.fround,Xe=Math.abs,Ai=Math.clz32,mk=Math.min,vk=Math.max,zt=NaN,h2=1/0,_t=ue.b,Cr=ue.c,us=ue.d,fs=ue.e,Us=ue.f,Vn=ue.g,Ka=ue.h,bl=ue.i,qh=ue.j,Qh=ue.k,Jh=ue.l,d2=ue.m,u2=ue.n,f2=ue.o,p2=ue.p,g2=ue.q,yk=ue.r,bk=ue.s,Ek=ue.t,Ak=ue.u,Tk=ue.v,kk=ue.w,wk=ue.x,Sk=ue.y,Rk=ue.z,_k=ue.A,Lk=ue.B,Ck=ue.C,Ik=ue.D,St=73712,Gr=0;function m2(s,a,h,u,y,b,k,S,P,z,tt,dt,Q,et){var $=0,W=m(0),Y=0,q=m(0),nt=0,ot=m(0),mt=0,Et=m(0),Ct=0,Mt=0,Ft=m(0),Vt=0,qt=0,he=m(0),ye=m(0),Pe=m(0),Ue=m(0),Ge=0,ze=m(0),qe=m(0),ar=0,or=0,kr=m(0),Mr=0,ei=0,Nr=0,Wr=0,ri=m(0),ii=0,Ii=0,xi=0,Yi=0,Xi=m(0),Zi=0,qi=0,ps=0,gs=0,ms=m(0),Vs=0,Ws=0,js=0,Ks=m(0),zs=0,Ys=m(0),Xa=0,Za=m(0),qa=m(0),Qa=m(0),Ja=0,_l=m(0),pd=0,gd=m(0),md=m(0),vd=m(0),yd=m(0),bd=0,ug=0,fg=0,pg=0,gg=0,mg=0,vg=0,yg=0,Qe=0,Je=m(0),Xn=m(0);$=St-384|0,St=$;t:{i:{r:{if(!(y&&a!=a)){if(!(b&&h!=h)){if(Y=(P?0:4)+tt|0,c[Y>>2]=c[Y>>2]+1,Y=c[s+24>>2]&3,pd=(u|0)<=1?1:u,Wr=Y||pd,pt[s+300|0]=Tt[s+300|0]&252|Wr&3,Y=s+252|0,u=((Wr|0)!=1)<<3,Vs=(Wr|0)==2?3:2,ot=ge(s,Vs,k),I[Y+u>>2]=ot,nt=Y,Y=((Wr|0)==1)<<3,ye=Re(s,Vs,k),I[nt+Y>>2]=ye,Et=ge(s,0,k),I[s+256>>2]=Et,Ue=Re(s,0,k),I[s+264>>2]=Ue,nt=s+268|0,Qe=nt+u|0,Je=ve(s,Vs),I[Qe>>2]=Je,Qe=Y+nt|0,Je=_e(s,Vs),I[Qe>>2]=Je,W=ve(s,0),I[s+272>>2]=W,ze=_e(s,0),I[s+280>>2]=ze,nt=u,u=s+284|0,Qe=nt+u|0,Je=Ne(s,Vs,k),I[Qe>>2]=Je,Qe=u+Y|0,Je=Fe(s,Vs,k),I[Qe>>2]=Je,q=Ne(s,0,k),I[s+288>>2]=q,Ft=Fe(s,0,k),I[s+296>>2]=Ft,ot=m(ot+ye),ye=m(Et+Ue),u=c[s+8>>2],u){Et=m(m(m(I[s+284>>2]+I[s+292>>2])+I[s+268>>2])+I[s+276>>2]),h=m(b?h-ye:zt),W=m(m(q+Ft)+W),q=m(y?a-ot:zt),a=q;e:{if(a!=a)break e;if(a=m(q-Et),a!=a){a=m(0);break e}a=fe(a,m(0))}ot=m(W+ze),W=h;e:{if(h!=h)break e;if(W=m(h-ot),W!=W){W=m(0);break e}W=fe(W,m(0))}if(!((y|0)!=1|(b|0)!=1)){a=Ze(s,2,q,k),u=a!=a,W=m(m(Ne(s,2,k)+ve(s,2))+m(Fe(s,2,k)+_e(s,2)));e:{if(!(u|W!=W)){a=fe(a,W);break e}a=u?W:a}I[s+516>>2]=a,a=Ze(s,0,h,S),u=a!=a,h=m(m(Ne(s,0,k)+ve(s,0))+m(Fe(s,0,k)+_e(s,0)));e:{if(!(u|h!=h)){a=fe(a,h);break e}a=u?h:a}I[s+520>>2]=a;break t}e:{if(Tt[s+4|0]&16){$t[u|0]($+24|0,s,a,y,W,b,0);break e}$t[u|0]($+24|0,s,a,y,W,b)}c[tt+20>>2]=c[tt+20>>2]+1,u=(et<<2)+tt|0,c[u+24>>2]=c[u+24>>2]+1,a=m(Et+I[$+24>>2]),a=Ze(s,2,y?(y|0)==2?a:q:a,k),u=a!=a,W=m(m(Ne(s,2,k)+ve(s,2))+m(Fe(s,2,k)+_e(s,2)));e:{if(!(u|W!=W)){a=fe(a,W);break e}a=u?W:a}I[s+516>>2]=a,a=m(ot+I[$+28>>2]),a=Ze(s,0,b?(b|0)==2?a:h:a,S),u=a!=a,h=m(m(Ne(s,0,k)+ve(s,0))+m(Fe(s,0,k)+_e(s,0)));e:{if(!(u|h!=h)){a=fe(a,h);break e}a=u?h:a}I[s+520>>2]=a;break t}if(u=c[s+556>>2],et=c[s+560>>2],(u|0)==(et|0)){ye=m(h-ye),a=Ze(s,2,y&-3?m(a-ot):m(m(m(I[s+284>>2]+I[s+292>>2])+I[s+268>>2])+I[s+276>>2]),k),u=a!=a,h=m(m(Ne(s,2,k)+ve(s,2))+m(Fe(s,2,k)+_e(s,2)));e:{if(!(u|h!=h)){a=fe(a,h);break e}a=u?h:a}I[s+516>>2]=a,a=Ze(s,0,b&-3?ye:m(m(m(q+Ft)+W)+ze),S),u=a!=a,h=m(m(Ne(s,0,k)+ve(s,0))+m(Fe(s,0,k)+_e(s,0)));e:{if(!(u|h!=h)){a=fe(a,h);break e}a=u?h:a}I[s+520>>2]=a;break t}e:{if(P||(W=m(a-ot),q=m(h-ye),!(!(!(W<=m(0))|(y|0)!=2)&W==W|!(!(q<=m(0))|(b|0)!=2)&q==q)&((y|0)!=1|(b|0)!=1)))break e;a=Ze(s,2,W!=W||(y|0)==2&&W<m(0)?m(0):W,k),u=a!=a,h=m(m(Ne(s,2,k)+ve(s,2))+m(Fe(s,2,k)+_e(s,2)));s:{if(!(u|h!=h)){a=fe(a,h);break s}a=u?h:a}I[s+516>>2]=a,a=Ze(s,0,q!=q||(b|0)==2&&q<m(0)?m(0):q,S),u=a!=a,h=m(m(Ne(s,0,k)+ve(s,0))+m(Fe(s,0,k)+_e(s,0)));s:{if(!(u|h!=h)){a=fe(a,h);break s}a=u?h:a}I[s+520>>2]=a;break t}for(ar=et-u|0,Yi=ar>>2;Y=c[u>>2],c[Y+552>>2]!=(s|0)&&(nt=c[s+568>>2],Y=I2(c[nt>>2],Tt[nt+8|0],Y,s,Ct,0),c[u>>2]=Y,c[Y+552>>2]=s),Ct=Ct+1|0,u=u+4|0,(et|0)!=(u|0););pt[s+300|0]=Tt[s+300|0]&251,Ct=3,Mr=c[s+24>>2],u=Mr>>>2&3;e:{s:{n:{if((Wr|0)==2){et=0;a:switch(u-2|0){case 0:break e;case 1:break a;default:break n}Ct=2;break e}if(Ct=2,et=0,u>>>0>1)break s}et=Ct}Ct=u}gd=m(a-ot),Xi=m(m(Ne(s,Ct,k)+ve(s,Ct))+m(Fe(s,Ct,k)+_e(s,Ct))),ze=m(Ne(s,et,k)+ve(s,et)),ri=m(ze+m(Fe(s,et,k)+_e(s,et))),ii=Ct>>>0>1,Et=A2(s,0,gd,ii?Xi:ri,k),md=m(h-ye),qe=A2(s,1,md,ii?ri:Xi,S),Ue=ii?qe:Et,ye=ii?Et:qe,Zi=c[s+560>>2],Y=c[s+556>>2],ei=ii?y:b;e:{if((ei|0)!=1)break e;if((Y|0)==(Zi|0))break r;for(u=Y;;){nt=c[u>>2];s:{if(!B2(nt))break s;if(qt=0,mt)break e;n:{a:{if(!c[nt+552>>2]){W=m(0);break a}if(h=I[nt+32>>2],h!=h&&(W=m(0),h=I[nt+28>>2],!(h>m(0))))break a;if(W=h,h!=h)break n}if(m(Xe(W))<m(9999999747378752e-20))break e}if(a=zn(nt),a!=a){mt=nt;break s}if(mt=nt,m(Xe(a))<m(9999999747378752e-20))break e}if(qt=mt,u=u+4|0,(Zi|0)==(u|0))break}}if((Y|0)==(Zi|0))break r;for(Xa=(Wr|0)<=1?1:Wr,Ws=Et!=Et,qi=Ws|(y|0)!=1,ps=qe==qe,js=Et==Et,W=m(0);;){Vt=c[Y>>2],E2(Vt),nt=c[Vt+24>>2];e:{if(nt&4194304){if(w2(Vt,0),u=Tt[Vt+4|0],nt=u|1,pt[Vt+4|0]=nt,!(u&4))break e;pt[Vt+4|0]=nt&251;break e}if(P&&(u=nt&3,x2(Vt,u||Xa,ye,Ue,Et),nt=c[Vt+24>>2]),(nt&196608)==131072)break e;s:{if((Vt|0)==(qt|0)){c[qt+308>>2]=0,c[qt+304>>2]=Q,h=m(0);break s}gs=c[s+24>>2],u=gs>>>2&3;n:{a:{if((Wr|0)!=2)break a;mt=3;o:switch(u-2|0){case 0:break n;case 1:break o;default:break a}mt=2;break n}mt=u}Ii=mt>>>0>1,ot=Ii?Et:qe,h=m(0),a=I[Vt+40>>2];n:{a:{Mt=c[Vt+40>>2];o:{if((Mt|0)==2139156720)break o;if((Mt|0)==2140081935)break a;u=4336;l:{if((Mt|0)!=2141891242){if(a==a)break l;u=4344}h=I[u>>2];c:{h:switch(Mt=c[u+4>>2],Mt|0){case 0:case 3:break h;default:break c}if(a=m(zt),!(I[Vt+28>>2]>m(0)))break n;Mt=pt[c[Vt+568>>2]+8|0]&1,u=Mt?2143289344:0,Mt=Mt?3:1,h=(Ot(2,u),Gt())}switch(a=m(zt),Mt-1|0){case 0:break a;case 1:break o;default:break n}}if(h=(Ot(2,(Mt&-1073741825)+536870912|0),Gt()),!(Mt&1073741824))break a}a=m(m(ot*h)*m(.009999999776482582));break n}a=h}h=I[Vt+572>>2],Mt=0;n:{a:switch(Ge=c[Vt+576>>2],Ge|0){case 0:case 3:break n;default:break a}if(q=I[Vt+572>>2],!((Ge|0)!=1|q!=q)){if(h<m(0))break n;Mt=1;break n}if(Mt=1,(Ge|0)!=2|q!=q||(Mt=0,h<m(0)))break n;Mt=js}q=I[Vt+580>>2],u=0;n:{a:switch(or=c[Vt+584>>2],or|0){case 0:case 3:break n;default:break a}if(Ft=I[Vt+580>>2],!((or|0)!=1|Ft!=Ft)){if(q<m(0))break n;u=1;break n}if(u=1,(or|0)!=2|Ft!=Ft||(u=0,q<m(0)))break n;u=ps}n:{a:{if(!(a!=a|ot!=ot)){if(h=I[Vt+308>>2],(!(pt[c[Vt+568>>2]+12|0]&1)|c[Vt+304>>2]==(Q|0))&h==h)break n;if(h=m(m(Ne(Vt,mt,Et)+ve(Vt,mt))+m(Fe(Vt,mt,Et)+_e(Vt,mt))),!(h<=a)&a<h)break a;h=a;break a}if(Mt&Ii){q=m(m(Ne(Vt,2,Et)+ve(Vt,2))+m(Fe(Vt,2,Et)+_e(Vt,2))),a=m(zt);o:switch(Ge-1|0){case 1:h=m(m(Et*h)*m(.009999999776482582));case 0:if(a=h,q<=a)break a;break;default:break o}if(!(a==a|q==q)){h=a;break a}if(a<q){h=q;break a}h=a!=a?q:a;break a}if(!(Ii|u^1)){a=m(m(Ne(Vt,0,Et)+ve(Vt,0))+m(Fe(Vt,0,Et)+_e(Vt,0))),h=m(zt);o:switch(or-1|0){case 1:q=m(m(qe*q)*m(.009999999776482582));case 0:if(h=q,a<=h)break a;break;default:break o}if(h!=h&a!=a)break a;if(a>h){h=a;break a}h=h!=h?a:h;break a}if(c[$+360>>2]=2143289344,c[$+24>>2]=2143289344,Nr=0,c[$+356>>2]=0,c[$+352>>2]=0,Ft=m(ge(Vt,2,Et)+Re(Vt,2,Et)),he=ge(Vt,0,Et),Pe=Re(Vt,0,Et),ot=m(zt),xi=0,a=m(zt),Mt){o:{l:switch(Ge-1|0){case 0:a=h;break o;case 1:break l;default:break o}a=m(m(Et*h)*m(.009999999776482582))}c[$+356>>2]=1,a=m(Ft+a),I[$+24>>2]=a,xi=1}if(he=m(he+Pe),u){h=m(zt);o:{l:switch(or-1|0){case 0:h=q;break o;case 1:break l;default:break o}h=m(m(qe*q)*m(.009999999776482582))}c[$+352>>2]=1,ot=m(he+h),I[$+360>>2]=ot,Nr=1}Ge=(gs&3145728)==2097152,or=mt>>>0<2;o:{l:{c:{if(!(Ge&or)){if(Ge|Ws)break l;if(a!=a)break c;break l}if(Ws|a==a)break o}xi=2,c[$+356>>2]=2,I[$+24>>2]=Et,a=Et}l:{if(!Ge||or){if(Ge|qe!=qe)break o;if(ot!=ot)break l;break o}if(ot==ot|qe!=qe)break o}Nr=2,c[$+352>>2]=2,I[$+360>>2]=qe,ot=qe}h=I[Vt+224>>2],Ge=h!=h;o:{if(Ge)break o;l:{if(!(Ii|(xi|0)!=1)){c[$+352>>2]=1,I[$+360>>2]=he+m(m(a-Ft)/h);break l}if(or|(Nr|0)!=1)break o;c[$+356>>2]=1,I[$+24>>2]=m(m(ot-he)*h)+Ft}Nr=1,xi=1}nt=nt>>>13&7,nt=nt||gs>>>10&7;o:{if((nt|0)==5|(xi|0)==1|(Ii|(Mt|qi))|(nt|0)!=4||(c[$+356>>2]=1,I[$+24>>2]=Et,Ge))break o;Nr=1,c[$+352>>2]=1,I[$+360>>2]=m(Et-Ft)/h}o:{if(or|(b|0)!=1|qe!=qe|u|(nt|0)!=4|(Nr|0)==1||(c[$+352>>2]=1,I[$+360>>2]=qe,Ge))break o;c[$+356>>2]=1,I[$+24>>2]=m(qe-he)*h}if(Wn(Vt,2,Et,Et,$+356|0,$+24|0),Wn(Vt,0,qe,Et,$+352|0,$+360|0),vn(Vt,I[$+24>>2],I[$+360>>2],Wr,c[$+356>>2],c[$+352>>2],Et,qe,0,5,z,tt,dt,Q),a=I[(Vt+(c[(mt<<2)+4320>>2]<<2)|0)+516>>2],u=a!=a,h=m(m(Ne(Vt,mt,Et)+ve(Vt,mt))+m(Fe(Vt,mt,Et)+_e(Vt,mt))),!(u|h!=h)){h=fe(a,h);break a}h=u?h:a}I[Vt+308>>2]=h}c[Vt+304>>2]=Q}W=m(W+m(h+m(ge(Vt,Ct,Et)+Re(Vt,Ct,Et))))}if(Y=Y+4|0,(Zi|0)==(Y|0))break}break i}c[$>>2]=3072,li(s,$),ti(),pe()}c[$+16>>2]=3154,li(s,$+16|0),ti(),pe()}W=m(0)}a=m(W+m(0)),Za=ii?S:k,Ks=ii?k:S,ar>>>0>=5&&(a=m(m(El(s,Ct,Ue)*m(Yi-1>>>0))+a)),u=a>ye,Zi=Mr&786432,ps=(ei|0)==2&&Zi&&u?1:ei,Vt=ii?b:y,Ii=(Vt|0)==1,ug=Ii&(P^1),ii=Ct>>>0<2,fg=Vt&-3,Ws=s+208|0,b=et<<2,or=b+4288|0,pg=Ii&!Zi,gg=(Vt|0)!=1|P,Y=Ct<<2,xi=Y+4288|0,js=Y+4320|0,gs=Ue==Ue,mg=gs<<1,Ge=b+4320|0,vg=!ei|!u,Xa=$+52|0,vd=El(s,et,Ue),nt=0,u=0,Nr=0;i:{for(;;){ei=u,Vr($+24|0,0,44),u=c[s+560>>2],b=c[s+556>>2];r:{if((u|0)==(b|0))break r;if(u=u-b|0,(u|0)<0)break i;if(Y=Ya($+360|0,u>>2,0,Xa),u=c[$+44>>2],b=c[$+48>>2]-u|0,b=Bs(c[$+364>>2]-b|0,u,b),u=c[$+44>>2],c[$+364>>2]=u,c[$+44>>2]=b,mt=c[$+368>>2],Mt=c[$+372>>2],b=c[$+48>>2],c[$+368>>2]=b,qt=c[$+52>>2],c[$+48>>2]=mt,c[$+52>>2]=Mt,c[$+372>>2]=qt,c[Y>>2]=u,(u|0)!=(b|0)&&(c[$+368>>2]=b+((u-b|0)+3&-4)),!u)break r;Ar(u)}qt=c[s+24>>2],u=qt>>>2&3;r:{e:{if(b=qt&3,((b||pd)|0)!=2)break e;mt=3;s:switch(u-2|0){case 0:break r;case 1:break s;default:break e}mt=2;break r}mt=u}W=El(s,mt,Et),Y=nt,Mt=c[s+560>>2],b=c[s+556>>2];r:{if(Y>>>0>=Mt-b>>2>>>0)break r;for(qt=qt&786432,h=m(0);;){if(Mt-b>>2>>>0<=Y>>>0)break i;if(u=c[(Y<<2)+b>>2],ar=c[u+24>>2],!(ar&4194304|(ar&196608)==131072)){if(c[u+548>>2]=ei,a=ge(u,mt,Et),q=Re(u,mt,Et),b=c[$+24>>2],ot=(Y|0)==(nt|0)?m(0):W,a=m(a+q),q=I[u+308>>2],Ft=Ze(u,mt,q,Ks),!(!b||!(m(ot+m(a+m(h+Ft)))>ye)|!qt))break r;if(c[$+24>>2]=b+1,ot=m(ot+m(a+Ft)),I[$+28>>2]=ot+I[$+28>>2],B2(u)){e:{if(!c[u+552>>2]){a=m(0);break e}if(a=I[u+32>>2],a==a)break e;a=I[u+28>>2],a=a>m(0)?a:m(0)}I[$+32>>2]=a+I[$+32>>2],Qe=$,Je=m(I[$+36>>2]-m(zn(u)*q)),I[Qe+36>>2]=Je}b=c[$+48>>2];e:{if((b|0)!=c[$+52>>2]){c[b>>2]=u,c[$+48>>2]=b+4;break e}if(b=b-c[$+44>>2]|0,ar=b>>2,Mt=ar+1|0,Mt>>>0>=1073741824)break i;if(Mr=b>>1,Mt=Ya($+360|0,b>>>0>=2147483644?1073741823:Mt>>>0<Mr>>>0?Mr:Mt,ar,Xa),c[c[$+368>>2]>>2]=u,c[$+368>>2]=c[$+368>>2]+4,u=c[$+44>>2],b=c[$+48>>2]-u|0,b=Bs(c[$+364>>2]-b|0,u,b),u=c[$+44>>2],c[$+364>>2]=u,c[$+44>>2]=b,ar=c[$+368>>2],Mr=c[$+372>>2],b=c[$+48>>2],c[$+368>>2]=b,qi=c[$+52>>2],c[$+48>>2]=ar,c[$+52>>2]=Mr,c[$+372>>2]=qi,c[Mt>>2]=u,(u|0)!=(b|0)&&(c[$+368>>2]=b+((u-b|0)+3&-4)),!u)break e;Ar(u)}b=c[s+556>>2],Mt=c[s+560>>2],h=m(h+ot)}if(Y=Y+1|0,!(Y>>>0<Mt-b>>2>>>0))break}}Pe=I[$+32>>2],!(Pe>m(0))|!(Pe<m(1))||(c[$+32>>2]=1065353216,Pe=m(1)),kr=I[$+36>>2],!(kr>m(0))|!(kr<m(1))||(c[$+36>>2]=1065353216,kr=m(1)),c[$+40>>2]=Y,Ft=I[$+28>>2],mt=c[$+24>>2],Nr&&Ar(Nr),q=I[$+56>>2],ar=c[$+48>>2],Nr=c[$+44>>2];r:{e:{s:{n:{if((ps|0)==1)break n;h=m(0),a=I[Ws>>2];a:{o:{u=c[Ws>>2];l:{if((u|0)==2139156720)break l;if((u|0)==2140081935)break o;b=4336;c:{if((u|0)!=2141891242){if(a==a)break c;b=4344}switch(h=I[b>>2],a=m(zt),c[b+4>>2]-1|0){case 0:break o;case 1:break l;default:break a}}if(h=(Ot(2,(u&-1073741825)+536870912|0),Gt()),!(u&1073741824))break o}a=m(m(h*k)*m(.009999999776482582));break a}a=h}h=m(0),W=I[s+216>>2];a:{o:{u=c[s+216>>2];l:{if((u|0)==2139156720)break l;if((u|0)==2140081935)break o;b=4336;c:{if((u|0)!=2141891242){if(W==W)break c;b=4344}switch(h=I[b>>2],W=m(zt),c[b+4>>2]-1|0){case 0:break o;case 1:break l;default:break a}}if(h=(Ot(2,(u&-1073741825)+536870912|0),Gt()),!(u&1073741824))break o}W=m(m(h*k)*m(.009999999776482582));break a}W=h}h=m(0),ot=I[s+212>>2];a:{o:{u=c[s+212>>2];l:{if((u|0)==2139156720)break l;if((u|0)==2140081935)break o;b=4336;c:{if((u|0)!=2141891242){if(ot==ot)break c;b=4344}switch(h=I[b>>2],ot=m(zt),c[b+4>>2]-1|0){case 0:break o;case 1:break l;default:break a}}if(h=(Ot(2,(u&-1073741825)+536870912|0),Gt()),!(u&1073741824))break o}ot=m(m(h*S)*m(.009999999776482582));break a}ot=h}h=m(0),he=I[s+220>>2];a:{o:{u=c[s+220>>2];l:{if((u|0)==2139156720)break l;if((u|0)==2140081935)break o;b=4336;c:{if((u|0)!=2141891242){if(he==he)break c;b=4344}switch(h=I[b>>2],he=m(zt),c[b+4>>2]-1|0){case 0:break o;case 1:break l;default:break a}}if(h=(Ot(2,(u&-1073741825)+536870912|0),Gt()),!(u&1073741824))break o}he=m(m(h*S)*m(.009999999776482582));break a}he=h}if(u=Ct>>>0>1,h=m((u?a:ot)-Xi),h==h&h>Ft||(h=m((u?W:he)-Xi),h==h&h<Ft))break s;if(pt[c[s+568>>2]+16|0]&1)break n;if(h=Ft,!c[s+552>>2]|Pe==m(0))break e;a=I[s+32>>2];a:{o:{if(a==a){h=a;break o}if(h=I[s+28>>2],!(h>m(0)))break a}if(h!=h){h=ye;break e}a=I[s+32>>2]}if(a!=a&&(h=Ft,a=I[s+28>>2],!(a>m(0)))||(h=ye,a!=m(0)))break e;h=Ft;break e}h=ye}if(h!=h)break e;q=m(h-Ft);break r}if(!(Ft<m(0)))break r;q=m(-Ft)}if(ye=h,!ug){r:{if((ar|0)==(Nr|0)){ot=m(0);break r}for(he=m(0),b=Nr;;){u=c[b>>2],Ft=I[u+308>>2],h=Ze(u,Ct,Ft,Ks);e:{if(q<m(0)){if(a=m(h*m(-zn(u))),!(a>m(0)|a<m(0)))break e;W=m(m(m(q/kr)*a)+h),a=Ze(u,Ct,W,ye),Mt=a!=a,ot=m(m(Ne(u,Ct,Et)+ve(u,Ct))+m(Fe(u,Ct,Et)+_e(u,Ct)));s:{if(!(Mt|ot!=ot)){a=fe(a,ot);break s}a=Mt?ot:a}if(W!=W|a!=a|a==W)break e;he=m(he+m(a-h)),kr=m(m(zn(u)*Ft)+kr);break e}if(!(q>m(0))|!c[u+552>>2]||(W=I[u+32>>2],W!=W&&(W=I[u+28>>2],!(W>m(0))))||!(W<m(0)|W>m(0)))break e;ot=m(m(m(q/Pe)*W)+h),a=Ze(u,Ct,ot,ye),Mt=a!=a,Ft=m(m(Ne(u,Ct,Et)+ve(u,Ct))+m(Fe(u,Ct,Et)+_e(u,Ct)));s:{if(!(Mt|Ft!=Ft)){a=fe(a,Ft);break s}a=Mt?Ft:a}if(ot!=ot|a!=a|a==ot)break e;Pe=m(Pe-W),he=m(he+m(a-h))}if(b=b+4|0,(ar|0)==(b|0))break}for(he=m(q-he),qa=m(he/kr),Qa=m(he/Pe),Ja=Ii&(vg|!(Tt[s+26|0]&12)),qi=!Ja,Mr=c[Ge>>2],ot=m(0),Mt=Nr;;){u=c[Mt>>2],Ft=Ze(u,Ct,I[u+308>>2],Ks);e:{s:{if(he<m(0)){if(W=Ft,a=m(W*m(-zn(u))),a==m(0))break e;a=kr==m(0)?m(Ft+a):m(m(qa*a)+Ft);break s}if(W=Ft,!(he>m(0))|!c[u+552>>2]||(a=I[u+32>>2],a!=a&&(a=I[u+28>>2],!(a>m(0))))||!(a<m(0)|a>m(0)))break e;a=m(m(Qa*a)+Ft)}if(a=Ze(u,Ct,a,ye),b=a!=a,h=m(m(Ne(u,Ct,Et)+ve(u,Ct))+m(Fe(u,Ct,Et)+_e(u,Ct))),!(b|h!=h)){W=fe(a,h);break e}W=b?h:a}a=ge(u,Ct,Et),h=Re(u,Ct,Et),Pe=ge(u,et,Et),_l=Re(u,et,Et),h=m(a+h),yd=m(W+h),I[$+352>>2]=yd,c[$+344>>2]=1,Pe=m(Pe+_l),a=I[u+224>>2];e:{if(a==a){c[$+348>>2]=1,h=m(yd-h),I[$+356>>2]=Pe+m(ii?h*a:h/a);break e}s:{if(zs=Ue!=Ue,zs)break s;qt=(Mr<<3)+u|0,a=I[qt+572>>2];n:{a:{o:{l:switch(b=c[qt+576>>2],b|0){case 0:case 3:break o;default:break l}if(h=I[qt+572>>2],(b|0)!=1|h!=h)break a;if(!(qi|!(a<m(0))))break n;break s}if(!Ja)break s;break n}if(qi|(!(a<m(0))|((b|0)!=2|h!=h)))break s}if(b=c[u+24>>2]>>>13&7,b||(b=c[s+24>>2]>>>10&7),(b|0)!=4||(bn($+24|0,u,et),c[$+28>>2]==3)||(yn($+360|0,u,et),c[$+364>>2]==3))break s;c[$+348>>2]=1,I[$+356>>2]=Ue;break e}qt=(Mr<<3)+u|0,h=I[qt+572>>2];s:{n:{a:{o:{l:switch(b=c[qt+576>>2],b|0){case 0:case 3:break o;default:break l}if(a=I[qt+572>>2],!((b|0)!=1|a!=a)){if(a=h,a<m(0))break o;break s}if((b|0)!=2|a!=a)break a;if(zs)break o;if(!(h<m(0)))break n}c[$+348>>2]=mg,I[$+356>>2]=Ue;break e}a=m(zt);a:switch(b-1|0){case 1:break n;case 0:break a;default:break s}a=h;break s}a=m(m(Ue*h)*m(.009999999776482582))}a=m(Pe+a),I[$+356>>2]=a,c[$+348>>2]=(Ii|(b|0)!=2)&a==a}Wn(u,Ct,ye,Et,$+344|0,$+352|0),Wn(u,et,Ue,Et,$+348|0,$+356|0),qt=(Mr<<3)+u|0,a=I[qt+572>>2];e:{s:{n:{a:switch(b=c[qt+576>>2],b|0){case 0:case 3:break n;default:break a}if(h=I[qt+572>>2],!((b|0)!=1|h!=h)){if(a<m(0))break n;break s}if((b|0)!=2|h!=h)break s;if(a<m(0))break n;if(qt=0,gs)break e}if(qt=0,b=c[u+24>>2]>>>13&7,b||(b=c[s+24>>2]>>>10&7),(b|0)!=4||(bn($+24|0,u,et),c[$+28>>2]==3))break e;yn($+360|0,u,et),qt=c[$+364>>2]!=3;break e}qt=0}a=I[$+352>>2],h=I[$+356>>2],b=Ct>>>0>1,Pe=b?a:h,a=b?h:a,zs=c[$+344>>2],bd=c[$+348>>2],yg=b?zs:bd,zs=b?bd:zs,b=(qt^1)&P,vn(u,Pe,a,Tt[s+300|0]&3,yg,zs,Et,qe,b,b?4:7,z,tt,dt,Q),ot=m(ot+m(W-Ft)),b=Tt[s+300|0];e:{s:{if(b&4){qt=b&251;break s}if(qt=b&251,b=0,!(Tt[u+300|0]&4))break e}b=4}if(pt[s+300|0]=b|qt,Mt=Mt+4|0,(ar|0)==(Mt|0))break}}q=m(q-ot)}u=Tt[s+300|0],pt[s+300|0]=u&251|(q<m(0)?4:u&4),he=m(Ne(s,Ct,k)+ve(s,Ct)),qa=m(Fe(s,Ct,k)+_e(s,Ct)),Ft=El(s,Ct,k);r:{if(!(!(q>m(0))|(ps|0)!=2)){ot=m(0),h=m(0);e:{s:{u=Ws+(c[js>>2]<<2)|0,a=I[u>>2],u=c[u>>2],b=(u|0)==2139156720;n:{if(!b){if(Mt=(u|0)==2140081935,Mt)break s;if(qt=(u|0)==2141891242,qt|a!=a)break r;if(Mt)break s;if(qt)break r;if(h=(Ot(2,(u&-1073741825)+536870912|0),Gt()),!(u&1073741824))break n}h=m(m(Ks*h)*m(.009999999776482582))}if(h!=h)break r;h=m(0);n:{if(b)break n;if((u|0)==2140081935)break s;b=4336;a:{if((u|0)!=2141891242){if(a==a)break a;b=4344}switch(h=I[b>>2],W=m(zt),c[b+4>>2]-1|0){case 0:break s;case 1:break n;default:break e}}if(h=(Ot(2,(u&-1073741825)+536870912|0),Gt()),!(u&1073741824))break s}W=m(m(Ks*h)*m(.009999999776482582));break e}W=h}if(a=m(m(m(W-he)-qa)-m(ye-q)),a!=a)break r;ot=fe(a,m(0));break r}ot=q}qt=Y>>>0<=nt>>>0;r:{if(!qt){for(ar=c[s+556>>2],u=c[s+560>>2]-ar>>2,Mr=u>>>0<nt>>>0?nt:u,Mt=0,u=nt;;){if((u|0)==(Mr|0))break i;if(b=c[ar+(u<<2)>>2],(c[b+24>>2]&196608)!=131072&&(qi=$+24|0,bn(qi,b,Ct),Ja=c[$+28>>2],yn(qi,b,Ct),Mt=(((Ja|0)==3)+Mt|0)+(c[$+28>>2]==3)|0),u=u+1|0,(Y|0)==(u|0))break}if(Pe=m(0),h=Ft,Mt)break r}Pe=m(0),Mt=0,h=Ft;e:switch((c[s+24>>2]>>>4&7)-1|0){case 0:Pe=m(ot*m(.5));break r;case 1:Pe=ot;break r;case 2:if(mt>>>0<2)break r;h=m(Ft+m((Je=m(0),Xn=fe(ot,m(0)),Qe=ot!=ot,(Qe?Je:Xn)/m(mt-1>>>0))));break r;case 4:Pe=m(ot/m(mt+1>>>0)),h=m(Ft+Pe);break r;case 3:break e;default:break r}Pe=m(m(ot*m(.5))/m(mt>>>0)),h=m(m(Pe+Pe)+Ft)}if(a=m(he+Pe),q=m(0),ar=P2(s),qt)h=m(0);else{for(Mr=Y-1|0,Qa=m(ot/m(Mt|0)),he=m(0),W=m(0),u=nt;;){if(b=c[s+556>>2],c[s+560>>2]-b>>2>>>0<=u>>>0)break i;b=c[b+(u<<2)>>2],mt=b+228|0,Hr($+24|0,mt,320),h=m(h-((u|0)==(Mr|0)?Ft:m(0))),Mt=c[b+24>>2];r:{if(Mt&4194304)break r;e:{if((Mt&196608)==131072){if(!ci(b,Ct))break e;if(!P)break r;ot=Gs(b,Ct,ye),kr=ve(s,Ct),_l=ge(b,Ct,Et),I[mt+(c[xi>>2]<<2)>>2]=_l+m(ot+kr);break r}if(bn($+360|0,b,Ct),a=m(a+(c[$+364>>2]==3?Qa:m(-0))),P&&(Mt=mt,mt=c[xi>>2]<<2,I[Mt+mt>>2]=a+I[mt+($+24|0)>>2]),yn($+360|0,b,Ct),a=m(a+(c[$+364>>2]==3?Qa:m(-0))),!gg){a=m(a+m(m(h+m(ge(b,Ct,Et)+Re(b,Ct,Et)))+I[$+104>>2])),q=Ue;break r}if(mt=b+516|0,a=m(a+m(h+m(I[mt+(c[js>>2]<<2)>>2]+m(ge(b,Ct,Et)+Re(b,Ct,Et))))),ar){ot=Al(b),kr=ge(b,0,Et),ot=m(ot+kr),kr=m(m(I[b+520>>2]+m(ge(b,0,Et)+Re(b,0,Et)))-ot),b=he!=he;s:{if(!(b|ot!=ot)){he=fe(he,ot);break s}he=b?ot:he}if(b=W!=W,!(b|kr!=kr)){W=fe(W,kr);break r}W=b?kr:W;break r}if(ot=m(I[mt+(c[Ge>>2]<<2)>>2]+m(ge(b,et,Et)+Re(b,et,Et))),b=q!=q,!(ot!=ot|b)){q=fe(q,ot);break r}q=b?ot:q;break r}if(!P)break r;b=c[xi>>2]<<2,ot=I[b+($+24|0)>>2],Qe=b+mt|0,Je=m(Pe+m(ot+ve(s,Ct))),I[Qe>>2]=Je}if(u=u+1|0,(Y|0)==(u|0))break}h=m(W+he)}if(q=ar?h:q,ot=Ue,!fg){h=Ze(s,et,m(ri+q),Za),u=h!=h,W=m(m(Ne(s,et,k)+ve(s,et))+m(Fe(s,et,k)+_e(s,et)));r:{if(!(u|W!=W)){h=fe(h,W);break r}h=u?W:h}ot=m(h-ri)}h=Ze(s,et,m(ri+(pg?Ue:q)),Za),u=h!=h,W=m(m(Ne(s,et,k)+ve(s,et))+m(Fe(s,et,k)+_e(s,et)));r:{if(!(u|W!=W)){h=fe(h,W);break r}h=u?W:h}if(W=m(h-ri),!(qt|!P))for(;;){if(u=c[s+556>>2],c[s+560>>2]-u>>2>>>0<=nt>>>0)break i;mt=c[u+(nt<<2)>>2],u=c[mt+24>>2];r:{if(u&4194304)break r;if((u&196608)==131072){e:{if(!ci(mt,et)){b=c[or>>2];break e}if(h=Gs(mt,et,Ue),q=ve(s,et),Ft=ge(mt,et,Et),b=c[or>>2],h=m(Ft+m(h+q)),I[(mt+(b<<2)|0)+228>>2]=h,h==h)break r}Qe=mt+(b<<2)|0,Je=m(ve(s,et)+ge(mt,et,Et)),I[Qe+228>>2]=Je;break r}b=u>>>13&7,b||(b=c[s+24>>2]>>>10&7);e:{s:{if((b|0)==5){b=c[s+24>>2]&8?5:1;break s}if((b|0)!=4||(bn($+24|0,mt,et),b=4,c[$+28>>2]==3)||(yn($+360|0,mt,et),c[$+364>>2]==3))break s;b=mt+(c[Ge>>2]<<3)|0,q=I[b+572>>2];n:{a:switch(u=c[b+576>>2],u|0){case 0:case 3:break n;default:break a}if(Ft=I[b+572>>2],!((u|0)!=1|Ft!=Ft)){if(h=ze,q<m(0))break n;break e}if(h=ze,gs&!(q<m(0))|((u|0)!=2|Ft!=Ft))break e}q=I[(mt+(c[js>>2]<<2)|0)+516>>2],h=W,Ft=I[mt+224>>2],Ft==Ft&&(h=m(m(ge(mt,et,Et)+Re(mt,et,Et))+m(ii?q*Ft:q/Ft))),I[$+360>>2]=h,Qe=$,Je=m(q+m(ge(mt,Ct,Et)+Re(mt,Ct,Et))),I[Qe+24>>2]=Je,c[$+356>>2]=1,c[$+352>>2]=1,Wn(mt,Ct,ye,Et,$+356|0,$+24|0),Wn(mt,et,Ue,Et,$+352|0,$+360|0),q=I[$+360>>2],Ft=I[$+24>>2],u=Ct>>>0>1,h=u?q:Ft,q=u?Ft:q,u=(Zi|0)!=0&(c[s+24>>2]&896)!=512,vn(mt,q,h,Wr,!(u&ii|q!=q),(!u|ii)&h==h,Et,qe,1,2,z,tt,dt,Q),h=ze;break e}h=I[(mt+(c[Ge>>2]<<2)|0)+516>>2],q=ge(mt,et,Et),Ft=Re(mt,et,Et),bn($+24|0,mt,et),q=m(ot-m(h+m(q+Ft)));s:{if(c[$+28>>2]!=3||(yn($+360|0,mt,et),c[$+364>>2]!=3))break s;h=m(q*m(.5)),h=m(ze+(Je=m(0),Xn=fe(h,m(0)),Qe=h!=h,Qe?Je:Xn));break e}if(yn($+24|0,mt,et),h=ze,c[$+28>>2]==3)break e;if(bn($+24|0,mt,et),c[$+28>>2]==3){h=m(ze+(Je=m(0),Xn=fe(q,m(0)),Qe=q!=q,Qe?Je:Xn));break e}s:switch(b-1|0){case 1:h=m(ze+m(q*m(.5)));break e;case 0:break e;default:break s}h=m(ze+q)}u=mt+(c[or>>2]<<2)|0,I[u+228>>2]=h+m(ms+I[u+228>>2])}if(nt=nt+1|0,(nt|0)==(Y|0))break}h=m((ei?vd:m(0))+W),u=Ys!=Ys,a=m(qa+a);r:{if(!(u|a!=a)){Ys=fe(Ys,a);break r}Ys=u?a:Ys}if(ms=m(ms+h),u=ei+1|0,nt=Y,!(Yi>>>0>Y>>>0))break}r:{if(!P||!Zi&&!P2(s))break r;he=m(0);e:{s:{if(Ue!=Ue)break s;a=m(Ue-ms);n:switch((c[s+24>>2]>>>7&7)-2|0){case 0:ze=m(ze+m(a*m(.5)));break s;case 2:if(!(Ue>ms))break s;he=m(a/m(u>>>0));break s;case 5:if(Ue>ms){if(ze=m(ze+m(a/m(u<<1>>>0))),u>>>0<2)break s;he=m(a/m(u>>>0));break e}ze=m(ze+m(a*m(.5)));break s;case 4:if(!(Ue>ms)|u>>>0<2)break s;he=m(a/m(ei>>>0));break e;case 1:break n;default:break s}ze=m(ze+a)}if(!u)break r}for(Mt=0,u=0,b=0;;){if(q=m(0),h=m(0),a=m(0),W=m(0),Y=u,Yi>>>0>u>>>0){e:{for(;;){if(b=c[s+556>>2],c[s+560>>2]-b>>2>>>0<=Y>>>0)break i;nt=c[b+(Y<<2)>>2],mt=c[nt+24>>2];s:{if(mt&4194304|(mt&196608)==131072)break s;if(b=Y,c[nt+548>>2]!=(Mt|0))break e;a=I[(nt+(c[Ge>>2]<<2)|0)+516>>2];n:{if(!(a>=m(0)))break n;if(b=h!=h,a=m(a+m(ge(nt,et,Et)+Re(nt,et,Et))),!(b|a!=a)){h=fe(h,a);break n}h=b?a:h}if(b=mt>>>13&7,b||(b=c[s+24>>2]>>>10&7),!(Tt[s+24|0]&8)|(b|0)!=5)break s;a=Al(nt),ot=ge(nt,0,Et),a=m(a+ot),ot=m(m(I[nt+520>>2]+m(ge(nt,0,Et)+Re(nt,0,Et)))-a),b=h!=h,nt=W!=W;n:{if(!(nt|a!=a)){W=fe(W,a);break n}W=nt?a:W}nt=q!=q;n:{if(!(nt|ot!=ot)){q=fe(q,ot);break n}q=nt?ot:q}if(a=m(W+q),!(b|a!=a)){h=fe(h,a);break s}h=b?a:h}if(Y=Y+1|0,(Yi|0)==(Y|0))break}b=Yi}a=h}if(ot=m(ze+(Mt?vd:m(0))),h=m(he+a),ze=m(ot+h),u>>>0<b>>>0)for(Ft=m(ot+W);;){if(Y=c[s+556>>2],c[s+560>>2]-Y>>2>>>0<=u>>>0)break i;nt=c[Y+(u<<2)>>2],Y=c[nt+24>>2];e:{if(Y&4194304|(Y&196608)==131072)break e;Y=Y>>>13&7,Y||(Y=c[s+24>>2]>>>10&7);s:{n:switch(Y-1|0){case 4:if(Tt[s+24|0]&8)break s;case 0:a=ge(nt,et,Et),I[(nt+(c[or>>2]<<2)|0)+228>>2]=ot+a;break e;case 2:a=Re(nt,et,Et),Y=nt+228|0,I[Y+(c[or>>2]<<2)>>2]=m(ze-a)-I[(Y+(c[Ge>>2]<<2)|0)+288>>2];break e;case 1:Y=nt+228|0,I[Y+(c[or>>2]<<2)>>2]=ot+m(m(h-I[(Y+(c[Ge>>2]<<2)|0)+288>>2])*m(.5));break e;case 3:break n;default:break e}a=ge(nt,et,Et),I[(nt+(c[or>>2]<<2)|0)+228>>2]=ot+a,mt=nt+(c[Ge>>2]<<3)|0,a=I[mt+572>>2];n:{a:switch(Y=c[mt+576>>2],Y|0){case 0:case 3:break n;default:break a}if(W=I[mt+572>>2],!((Y|0)!=1|W!=W)){if(a<m(0))break n;break e}if(gs&!(a<m(0))|((Y|0)!=2|W!=W))break e}n:{if(Ct>>>0>=2){q=h,a=I[nt+516>>2],W=m(a+m(ge(nt,Ct,Et)+Re(nt,Ct,Et)));break n}q=m(I[nt+520>>2]+m(ge(nt,et,Et)+Re(nt,et,Et))),a=I[nt+516>>2],W=h}n:{a:{if(!(W!=W|a!=a)){if(m(Xe(m(W-a)))<m(9999999747378752e-20))break a;break n}if(W==W|a==a)break n}if(a=I[nt+520>>2],Y=a!=a,!(Y|q!=q)){if(!(m(Xe(m(q-a)))<m(9999999747378752e-20)))break n;break e}if(q==q)break n;if(Y)break e}vn(nt,W,q,Wr,1,1,Et,qe,1,3,z,tt,dt,Q);break e}Qe=nt,Je=m(m(Ft-Al(nt))+Gs(nt,0,Ue)),I[Qe+232>>2]=Je}if(u=u+1|0,(b|0)==(u|0))break}if(Y=(Mt|0)!=(ei|0),Mt=Mt+1|0,u=b,!Y)break}}mt=s+516|0,a=Ze(s,2,gd,k),u=a!=a,h=m(m(Ne(s,2,k)+ve(s,2))+m(Fe(s,2,k)+_e(s,2)));r:{if(!(u|h!=h)){a=fe(a,h);break r}a=u?h:a}I[mt>>2]=a,a=Ze(s,0,md,S),u=a!=a,h=m(m(Ne(s,0,k)+ve(s,0))+m(Fe(s,0,k)+_e(s,0)));r:{if(!(u|h!=h)){a=fe(a,h);break r}a=u?h:a}I[s+520>>2]=a;r:{e:{s:{if(ps&&(u=c[s+24>>2]>>>20&3,(u|0)==2|(ps|0)!=2))break s;if(a=Ze(s,Ct,Ys,Ks),u=a!=a,h=m(m(Ne(s,Ct,k)+ve(s,Ct))+m(Fe(s,Ct,k)+_e(s,Ct))),!(u|h!=h)){a=fe(a,h);break e}a=u?h:a;break e}if((ps|0)!=2|(u|0)!=2)break r;h=m(Xi+ye),u=h!=h,a=Ze(s,Ct,Ys,Ks);s:{if(!(u|a!=a)){a=ld(h,a);break s}a=u?a:h}if(u=a!=a,!(u|Xi!=Xi)){a=fe(a,Xi);break e}a=u?Xi:a}I[mt+(c[js>>2]<<2)>>2]=a}r:{e:{s:{if(Vt&&(b=(Vt|0)!=2,u=c[s+24>>2]>>>20&3,b|(u|0)==2))break s;if(a=Ze(s,et,m(ri+ms),Za),u=a!=a,h=m(m(Ne(s,et,k)+ve(s,et))+m(Fe(s,et,k)+_e(s,et))),!(u|h!=h)){a=fe(a,h);break e}a=u?h:a;break e}if(b|(u|0)!=2)break r;h=m(ri+Ue),u=h!=h,a=Ze(s,et,m(ri+ms),Za);s:{if(!(u|a!=a)){a=ld(h,a);break s}a=u?a:h}if(u=a!=a,!(u|ri!=ri)){a=fe(a,ri);break e}a=u?ri:a}I[mt+(c[Ge>>2]<<2)>>2]=a}r:{if(!P)break r;if((c[s+24>>2]&786432)==524288)for(b=Yi>>>0<=1?1:Yi,P=c[s+556>>2],nt=c[s+560>>2]-P>>2,u=0;Y=0,Y=u>>>0<nt>>>0?c[P+(u<<2)>>2]:Y,(c[Y+24>>2]&196608)!=131072&&(Y=Y+228|0,Mt=Y+(c[or>>2]<<2)|0,qt=c[Ge>>2]<<2,I[Mt>>2]=m(I[qt+mt>>2]-I[Mt>>2])-I[(Y+qt|0)+288>>2]),u=u+1|0,(b|0)!=(u|0););if(b=c[s+556>>2],P=c[s+560>>2],(b|0)!=(P|0))for(Mt=((Ct>>>0>1?ps:y)|0)!=0;;){y=c[b>>2];e:{if((c[y+24>>2]&4390912)!=131072)break e;W=Et,ye=qe,Tt[c[s+568>>2]+12|0]&2&&(ye=I[s+520>>2],W=I[s+516>>2]),u=c[s+24>>2]>>>2&3;s:{n:{if((Wr|0)==2){nt=0,Y=3;a:switch(u-2|0){case 0:break s;case 1:break a;default:break n}Y=2;break s}if(nt=0,u>>>0<=1)break n;Y=u;break s}Y=u,nt=Vs}S=m(ge(y,2,W)+Re(y,2,W)),k=ge(y,0,W),q=Re(y,0,W),a=I[y+572>>2];s:{n:{a:switch(u=c[y+576>>2],u|0){case 0:case 3:break n;default:break a}h=I[y+572>>2];a:{if(!((u|0)!=1|h!=h)){if(h=a,!(a<m(0)))break a;break n}o:{if(!((u|0)!=2|h!=h)){if(W!=W|a<m(0))break n;break o}h=m(zt);l:switch(u-1|0){case 1:break o;case 0:break l;default:break a}h=a;break a}h=m(m(W*a)*m(.009999999776482582))}h=m(S+h);break s}if(h=m(zt),!ci(y,2)||!wl(y,2))break s;if(a=Ze(y,2,m(m(I[s+516>>2]-m(ve(s,2)+_e(s,2)))-m(Gs(y,2,W)+za(y,2,W))),W),u=a!=a,h=m(m(Ne(y,2,W)+ve(y,2))+m(Fe(y,2,W)+_e(y,2))),!(u|h!=h)){h=fe(a,h);break s}h=u?h:a}q=m(k+q);s:{n:{a:{o:{l:{c:{h:{qt=h!=h,k=I[y+580>>2];f:{d:{p:switch(u=c[y+584>>2],u|0){case 0:case 3:break d;default:break p}a=I[y+580>>2];p:{if(!((u|0)!=1|a!=a)){if(a=k,!(a<m(0)))break p;break d}v:{if(!((u|0)!=2|a!=a)){if(ye!=ye|k<m(0))break d;break v}a=m(zt);y:switch(u-1|0){case 1:break v;case 0:break y;default:break p}a=k;break p}a=m(m(ye*k)*m(.009999999776482582))}a=m(q+a);break f}d:{if(ci(y,0)&&wl(y,0))break d;if(a=m(zt),h==h)break h;break a}if(a=Ze(y,0,m(m(I[s+520>>2]-m(ve(s,0)+_e(s,0)))-m(Gs(y,0,ye)+za(y,0,ye))),ye),u=a!=a,k=m(m(Ne(y,0,W)+ve(y,0))+m(Fe(y,0,W)+_e(y,0))),!(u|k!=k)){a=fe(a,k);break f}a=u?k:a}if((qt|0)==(a!=a|0)||(ot=I[y+224>>2],ot!=ot))break l;if(h!=h){h=m(m(m(a-q)*ot)+S);break l}if(a==a)break l;break c}if(ot=I[y+224>>2],ot!=ot)break o}a=m(q+m(m(h-S)/ot))}if(h!=h)break a;if(a==a)break s}u=0;break n}u=1}qt=W>m(0),ei=u&Mt&Y>>>0<2,h=ei&&qt?W:h,u=u^1,vn(y,h,a,Wr,ei&&qt?2:u,a==a,h,a,0,6,z,tt,dt,Q),h=m(I[y+516>>2]+rg(y,2,W)),a=m(I[y+520>>2]+rg(y,0,W))}vn(y,h,a,Wr,1,1,h,a,1,1,z,tt,dt,Q);s:{n:{a:{if(!wl(y,Y)||ci(y,Y))break a;u=c[(Y<<2)+4320>>2]<<2,a=Y>>>0<2?ye:W,a=m(m(m(m(I[u+mt>>2]-I[(u+y|0)+516>>2])-_e(s,Y))-Re(y,Y,a))-za(y,Y,a));break n}if(!(ci(y,Y)|(c[s+24>>2]&112)!=16)){u=c[(Y<<2)+4320>>2]<<2,a=m(m(I[u+mt>>2]-I[(u+y|0)+516>>2])*m(.5));break n}if(!(ci(y,Y)|(c[s+24>>2]&112)!=32)){u=c[(Y<<2)+4320>>2]<<2,a=m(I[u+mt>>2]-I[(u+y|0)+516>>2]);break n}if(!(Tt[c[s+568>>2]+12|0]&2)||!ci(y,Y))break s;a=I[mt+(c[(Y<<2)+4320>>2]<<2)>>2],a=m(m(Gs(y,Y,a)+ve(s,Y))+ge(y,Y,a))}I[(y+(c[(Y<<2)+4288>>2]<<2)|0)+228>>2]=a}s:{n:{if(!wl(y,nt)||ci(y,nt))break n;u=c[(nt<<2)+4320>>2]<<2,a=Y>>>0<2?W:ye,a=m(m(m(m(I[u+mt>>2]-I[(u+y|0)+516>>2])-_e(s,nt))-Re(y,nt,a))-za(y,nt,a));break s}n:{if(ci(y,nt)||(u=c[y+24>>2]>>>13&7,u||(u=c[s+24>>2]>>>10&7),(u|0)!=2))break n;u=c[(nt<<2)+4320>>2]<<2,a=m(m(I[u+mt>>2]-I[(u+y|0)+516>>2])*m(.5));break s}n:{if(ci(y,nt))break n;Y=c[y+24>>2]>>>13&7,u=c[s+24>>2],Y=Y||u>>>10&7;a:{if((Y|0)==5){if((u&786432)==524288)break a;break n}if(((Y|0)==3|0)==((u&786432)==524288|0))break n}u=c[(nt<<2)+4320>>2]<<2,a=m(I[u+mt>>2]-I[(u+y|0)+516>>2]);break s}if(!(Tt[c[s+568>>2]+12|0]&2)||!ci(y,nt))break e;a=I[mt+(c[(nt<<2)+4320>>2]<<2)>>2],a=m(m(Gs(y,nt,a)+ve(s,nt))+ge(y,nt,a))}I[(y+(c[(nt<<2)+4288>>2]<<2)|0)+228>>2]=a}if(b=b+4|0,(P|0)==(b|0))break}if(!((et|Ct)&1))break r;for(b=et&1,P=Ct&1,z=Yi>>>0<=1?1:Yi,tt=(et<<2)+4304|0,dt=(Ct<<2)+4304|0,Q=c[s+556>>2],et=c[s+560>>2]-Q>>2,s=0;;){if((s|0)==(et|0))break i;u=c[Q+(s<<2)>>2];e:{if(Tt[u+26|0]&64||(P&&(y=u+228|0,Y=c[js>>2]<<2,I[y+(c[dt>>2]<<2)>>2]=m(I[Y+mt>>2]-I[(y+Y|0)+288>>2])-I[y+(c[xi>>2]<<2)>>2]),!b))break e;u=u+228|0,y=c[Ge>>2]<<2,I[u+(c[tt>>2]<<2)>>2]=m(I[y+mt>>2]-I[(u+y|0)+288>>2])-I[u+(c[or>>2]<<2)>>2]}if(s=s+1|0,(z|0)==(s|0))break}}if(!Nr)break t;Ar(Nr);break t}Us(),pe()}St=$+384|0}function v2(){var s=0,a=0;Vn(7032,7033,7034,0,4352,17,4355,0,4355,0,2529,4357,18),s=ht(8),c[s>>2]=8,c[s+4>>2]=1,_t(7032,2922,6,4368,4392,19,s|0,1),Vn(7036,7037,7038,7032,4352,20,4352,21,4352,22,2001,4357,23),s=ht(4),c[s>>2]=24,_t(7036,2359,2,4400,4408,25,s|0,0),us(7032,1398,2,4412,4420,26,27),us(7032,3027,3,4500,4512,28,29),Vn(7056,7057,7058,0,4352,30,4355,0,4355,0,2545,4357,31),s=ht(8),c[s>>2]=8,c[s+4>>2]=1,_t(7056,3293,2,4520,4408,32,s|0,1),Vn(7059,7060,7061,7056,4352,33,4352,34,4352,35,2024,4357,36),s=ht(4),c[s>>2]=37,_t(7059,2359,2,4528,4408,38,s|0,0),us(7056,1398,2,4536,4420,39,40),us(7056,3027,3,4500,4512,28,41),Vn(7062,7063,7064,0,4352,42,4355,0,4355,0,2861,4357,43),p2(7062,1,4584,4352,44,45),us(7062,2915,1,4584,4352,44,45),us(7062,1129,2,4588,4408,46,47),s=ht(8),c[s+4>>2]=0,c[s>>2]=48,_t(7062,3234,4,4608,4624,49,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=50,_t(7062,1981,3,4632,4644,51,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=52,_t(7062,1952,3,4652,4664,53,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=54,_t(7062,3389,3,4672,4664,55,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=56,_t(7062,1800,3,4652,4664,53,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=57,_t(7062,3264,3,4684,4512,58,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=59,_t(7062,1926,2,4696,4420,60,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=61,_t(7062,3399,2,4704,4420,62,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=63,_t(7062,1785,2,4696,4420,60,s|0,0),Jh(7065,1271,4712,64,4357,65),Yn(1732,0),Yn(1612,8),Yn(2145,16),Yn(2455,24),Yn(2561,32),Yn(1618,40),Qh(7065),Jh(7035,2898,4712,66,4357,67),z2(2561,0),z2(1618,8),Qh(7035),Jh(7066,2909,4712,68,4357,69),s=ht(4),c[s>>2]=8,a=ht(4),c[a>>2]=8,bl(7066,2903,7098,4714,70,s|0,7098,4718,71,a|0),s=ht(4),c[s>>2]=0,a=ht(4),c[a>>2]=0,bl(7066,1607,7091,4420,72,s|0,7091,4664,73,a|0),Qh(7066),Vn(7067,7068,7069,0,4352,74,4355,0,4355,0,3022,4357,75),p2(7067,1,4724,4352,76,77),us(7067,1593,1,4724,4352,76,77),us(7067,2851,2,4728,4420,78,79),us(7067,1129,2,4736,4408,80,81),s=ht(8),c[s+4>>2]=0,c[s>>2]=82,_t(7067,1753,2,4736,4408,83,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=84,_t(7067,3005,3,4744,4664,85,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=86,_t(7067,2930,3,4756,4664,87,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=88,_t(7067,2335,4,4768,4784,89,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=90,_t(7067,1485,4,4768,4784,89,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=91,_t(7067,1356,3,4756,4664,87,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=92,_t(7067,1818,3,4756,4664,87,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=93,_t(7067,2872,3,4756,4664,87,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=94,_t(7067,2379,3,4756,4664,87,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=95,_t(7067,2164,3,4756,4664,87,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=96,_t(7067,1320,3,4756,4664,87,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=97,_t(7067,2413,4,4768,4784,89,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=98,_t(7067,1504,4,4768,4784,89,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=99,_t(7067,2236,3,4756,4664,87,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=100,_t(7067,1220,3,4756,4664,87,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=101,_t(7067,1137,3,4756,4664,87,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=102,_t(7067,1159,3,4792,4718,103,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=104,_t(7067,1846,3,4792,4718,103,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=105,_t(7067,1465,3,4792,4718,103,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=106,_t(7067,2219,2,4736,4408,83,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=107,_t(7067,1196,3,4792,4718,103,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=108,_t(7067,2501,3,4792,4718,103,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=109,_t(7067,2591,3,4792,4718,103,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=110,_t(7067,1540,3,4792,4718,103,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=111,_t(7067,2250,2,4736,4408,83,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=112,_t(7067,1651,3,4792,4718,103,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=113,_t(7067,1428,3,4792,4718,103,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=114,_t(7067,2205,2,4736,4408,83,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=115,_t(7067,2609,3,4792,4718,103,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=116,_t(7067,1556,3,4792,4718,103,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=117,_t(7067,1671,3,4792,4718,103,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=118,_t(7067,1445,3,4792,4718,103,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=119,_t(7067,2567,3,4792,4718,103,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=120,_t(7067,1521,3,4792,4718,103,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=121,_t(7067,1625,3,4792,4718,103,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=122,_t(7067,1408,3,4792,4718,103,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=123,_t(7067,2305,3,4792,4718,103,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=124,_t(7067,2093,4,4768,4784,89,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=125,_t(7067,2719,4,4768,4784,89,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=126,_t(7067,1575,4,4768,4784,89,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=127,_t(7067,2188,4,4768,4784,89,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=128,_t(7067,2946,2,4804,4420,129,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=130,_t(7067,2347,3,4812,4512,131,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=132,_t(7067,1372,2,4804,4420,129,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=133,_t(7067,1832,2,4804,4420,129,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=134,_t(7067,2885,2,4804,4420,129,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=135,_t(7067,2396,2,4804,4420,129,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=136,_t(7067,2176,2,4804,4420,129,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=137,_t(7067,1338,2,4804,4420,129,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=138,_t(7067,2423,3,4812,4512,131,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=139,_t(7067,1859,2,4824,4420,140,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=141,_t(7067,1208,2,4832,4714,142,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=143,_t(7067,2515,2,4832,4714,142,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=144,_t(7067,2600,2,4824,4420,140,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=145,_t(7067,1661,2,4824,4420,140,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=146,_t(7067,2621,2,4824,4420,140,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=147,_t(7067,1684,2,4824,4420,140,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=148,_t(7067,2579,2,4824,4420,140,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=149,_t(7067,1638,2,4824,4420,140,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=150,_t(7067,2320,2,4832,4714,142,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=151,_t(7067,2103,3,4840,4852,152,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=153,_t(7067,1232,2,4804,4420,129,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=154,_t(7067,1148,2,4804,4420,129,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=155,_t(7067,2730,3,4812,4512,131,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=156,_t(7067,2195,3,4860,4872,157,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=158,_t(7067,3034,4,4880,4624,159,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=160,_t(7067,3055,3,4896,4664,161,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=162,_t(7067,1293,2,4908,4420,163,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=164,_t(7067,1388,2,4916,4420,165,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=166,_t(7067,3046,3,4924,4512,167,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=168,_t(7067,2962,2,4936,4420,169,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=170,_t(7067,2982,3,4944,4664,171,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=172,_t(7067,3357,3,4956,4664,173,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=174,_t(7067,3355,2,4736,4408,83,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=175,_t(7067,3374,3,4968,4664,176,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=177,_t(7067,3372,2,4736,4408,83,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=178,_t(7067,1119,2,4736,4408,83,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=179,_t(7067,1111,2,4980,4420,180,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=181,_t(7067,1244,5,4992,5012,182,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=183,_t(7067,1737,2,4832,4714,142,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=184,_t(7067,1715,2,4832,4714,142,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=185,_t(7067,2149,2,4832,4714,142,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=186,_t(7067,2462,2,4832,4714,142,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=187,_t(7067,2633,2,4832,4714,142,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=188,_t(7067,1697,2,4832,4714,142,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=189,_t(7067,1260,2,5020,4420,190,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=191,_t(7067,2433,3,4840,4852,152,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=192,_t(7067,2113,3,4840,4852,152,s|0,0),s=ht(8),c[s+4>>2]=0,c[s>>2]=193,_t(7067,2741,3,4840,4852,152,s|0,0)}function xk(s,a,h,u,y,b){s=s|0,a=+a,h=h|0,u=u|0,y=y|0,b=b|0;var k=0,S=0,P=0,z=0,tt=0,dt=0,Q=0,et=0,$=0,W=0,Y=0,q=0,nt=0,ot=0,mt=0,Et=0,Ct=0,Mt=0,Ft=0;Q=St-560|0,St=Q,c[Q+44>>2]=0,Er(+a),k=te(1)|0,te(0)|0;t:{if((k|0)<0){nt=1,Mt=1177,a=-a,Er(+a),k=te(1)|0,te(0)|0;break t}if(y&2048){nt=1,Mt=1180;break t}nt=y&1,Mt=nt?1183:1178,Ft=!nt}t:{if((k&2146435072)==2146435072){k=nt+3|0,Tr(s,32,h,k,y&-65537),pr(s,Mt,nt),u=b&32,pr(s,a!=a?u?2451:3459:u?2868:3463,3),Tr(s,32,h,k,y^8192),et=(h|0)<(k|0)?k:h;break t}mt=Q+16|0;i:{r:{e:{if(a=M2(a,Q+44|0),a=a+a,a!=0){if(k=c[Q+44>>2],c[Q+44>>2]=k-1,Et=b|32,(Et|0)!=97)break e;break i}if(Et=b|32,(Et|0)==97)break i;tt=c[Q+44>>2],dt=(u|0)<0?6:u;break r}tt=k-29|0,c[Q+44>>2]=tt,a=a*268435456,dt=(u|0)<0?6:u}for(Y=(Q+48|0)+((tt|0)>=0?288:0)|0,S=Y;a<4294967296&a>=0?u=~~a>>>0:u=0,c[S>>2]=u,S=S+4|0,a=(a-+(u>>>0))*1e9,a!=0;);r:{if((tt|0)<=0){u=tt,k=S,P=Y;break r}for(P=Y,u=tt;;){$=(u|0)>=29?29:u,k=S-4|0;e:{if(P>>>0>k>>>0)break e;for(u=0;z=c[k>>2],Ct=u,u=$&31,($&63)>>>0>=32?(et=z<<u,u=0):(et=(1<<u)-1&z>>>32-u,u=z<<u),Ct=Ct+u|0,z=et+W|0,u=k2(Ct,u>>>0>Ct>>>0?z+1|0:z,1e9),z=od(u,Gr,-1e9,0)+Ct|0,c[k>>2]=z,k=k-4|0,P>>>0<=k>>>0;);if(!u)break e;P=P-4|0,c[P>>2]=u}for(;k=S,P>>>0<k>>>0&&(S=k-4|0,!c[S>>2]););if(u=c[Q+44>>2]-$|0,c[Q+44>>2]=u,S=k,!((u|0)>0))break}}if((u|0)<0)for(ot=((dt+25>>>0)/9|0)+1|0,W=(Et|0)==102;;){u=0-u|0,et=(u|0)>=9?9:u;r:{if(k>>>0<=P>>>0){S=c[P>>2];break r}for($=1e9>>>et|0,z=-1<<et^-1,u=0,S=P;Ct=u,u=c[S>>2],c[S>>2]=Ct+(u>>>et|0),u=Ke($,u&z),S=S+4|0,S>>>0<k>>>0;);if(S=c[P>>2],!u)break r;c[k>>2]=u,k=k+4|0}if(u=et+c[Q+44>>2]|0,c[Q+44>>2]=u,P=(!S<<2)+P|0,S=W?Y:P,k=k-S>>2>(ot|0)?S+(ot<<2)|0:k,!((u|0)<0))break}u=0;r:{if(k>>>0<=P>>>0||(u=Ke(Y-P>>2,9),S=10,z=c[P>>2],z>>>0<10))break r;for(;u=u+1|0,S=Ke(S,10),z>>>0>=S>>>0;);}if(S=(dt-((Et|0)!=102?u:0)|0)-((Et|0)==103&(dt|0)!=0)|0,(S|0)<(Ke(k-Y>>2,9)-9|0)){if($=S+9216|0,z=($|0)/9|0,tt=((((tt|0)<0?4:292)+Q|0)+(z<<2)|0)-4048|0,S=10,et=$+Ke(z,-9)|0,(et|0)<=7)for(;S=Ke(S,10),et=et+1|0,(et|0)!=8;);$=c[tt>>2],ot=($>>>0)/(S>>>0)|0,W=Ke(ot,S),z=tt+4|0;r:{if(($|0)==(W|0)&(z|0)==(k|0))break r;$=$-W|0;e:{if(!(ot&1)&&(a=9007199254740992,!(pt[tt-4|0]&1)|((S|0)!=1e9|P>>>0>=tt>>>0)))break e;a=9007199254740994}if(q=(k|0)==(z|0)?1:1.5,z=S>>>1|0,q=z>>>0>$>>>0?.5:(z|0)==($|0)?q:1.5,Tt[Mt|0]!=45|Ft||(q=-q,a=-a),c[tt>>2]=W,a+q==a)break r;if(u=S+W|0,c[tt>>2]=u,u>>>0>=1e9)for(;c[tt>>2]=0,tt=tt-4|0,tt>>>0<P>>>0&&(P=P-4|0,c[P>>2]=0),u=c[tt>>2]+1|0,c[tt>>2]=u,u>>>0>999999999;);if(u=Ke(Y-P>>2,9),S=10,z=c[P>>2],z>>>0<10)break r;for(;u=u+1|0,S=Ke(S,10),z>>>0>=S>>>0;);}S=tt+4|0,k=k>>>0>S>>>0?S:k}for(;z=k,$=k>>>0<=P>>>0,!$&&(k=z-4|0,!c[k>>2]););r:{if((Et|0)!=103){tt=y&8;break r}if(S=dt||1,k=(S|0)>(u|0)&(u|0)>-5,dt=(k?u^-1:-1)+S|0,b=(k?-1:-2)+b|0,tt=y&8,tt)break r;k=-9;e:{if($||(tt=c[z-4>>2],!tt)||(et=10,k=0,(tt>>>0)%10|0))break e;for(;S=k,k=k+1|0,et=Ke(et,10),!((tt>>>0)%(et>>>0)|0););k=S^-1}if(S=Ke(z-Y>>2,9),(b&-33)==70){tt=0,k=(k+S|0)-9|0,k=(k|0)>0?k:0,dt=(k|0)>(dt|0)?dt:k;break r}tt=0,k=((u+S|0)+k|0)-9|0,k=(k|0)>0?k:0,dt=(k|0)>(dt|0)?dt:k}if(et=-1,$=tt|dt,(($?2147483645:2147483646)|0)<(dt|0))break t;W=((($|0)!=0)+dt|0)+1|0,S=b&-33;r:{if((S|0)==70){if((W^2147483647)<(u|0))break t;k=(u|0)>0?u:0;break r}if(k=u>>31,k=jn((k^u)-k|0,0,mt),(mt-k|0)<=1)for(;k=k-1|0,pt[k|0]=48,(mt-k|0)<2;);if(ot=k-2|0,pt[ot|0]=b,pt[k-1|0]=(u|0)<0?45:43,k=mt-ot|0,(k|0)>(W^2147483647))break t}if(u=k+W|0,(u|0)>(nt^2147483647))break t;W=u+nt|0,Tr(s,32,h,W,y),pr(s,Mt,nt),Tr(s,48,h,W,y^65536);r:{e:{s:{if((S|0)==70){for(b=Q+16|0,u=b|8,tt=b|9,S=P>>>0>Y>>>0?Y:P,P=S;;){k=jn(c[P>>2],0,tt);n:{if((S|0)!=(P|0)){if(Q+16>>>0>=k>>>0)break n;for(;k=k-1|0,pt[k|0]=48,Q+16>>>0<k>>>0;);break n}if((k|0)!=(tt|0))break n;pt[Q+24|0]=48,k=u}if(pr(s,k,tt-k|0),P=P+4|0,!(Y>>>0>=P>>>0))break}if($&&pr(s,4275,1),(dt|0)<=0|P>>>0>=z>>>0)break s;for(;;){if(k=jn(c[P>>2],0,tt),k>>>0>Q+16>>>0)for(;k=k-1|0,pt[k|0]=48,Q+16>>>0<k>>>0;);if(pr(s,k,(dt|0)>=9?9:dt),k=dt-9|0,P=P+4|0,z>>>0<=P>>>0)break e;if(u=(dt|0)>9,dt=k,!u)break}break e}n:{if((dt|0)<0)break n;for(Y=P>>>0<z>>>0?z:P+4|0,b=Q+16|0,u=b|8,z=b|9,S=P;;){k=jn(c[S>>2],0,z),(z|0)==(k|0)&&(pt[Q+24|0]=48,k=u);a:{if((S|0)!=(P|0)){if(Q+16>>>0>=k>>>0)break a;for(;k=k-1|0,pt[k|0]=48,Q+16>>>0<k>>>0;);break a}if(pr(s,k,1),k=k+1|0,!(tt|dt))break a;pr(s,4275,1)}if(b=z-k|0,pr(s,k,(b|0)>(dt|0)?dt:b),dt=dt-b|0,S=S+4|0,Y>>>0<=S>>>0)break n;if(!((dt|0)>=0))break}}Tr(s,48,dt+18|0,18,0),pr(s,ot,mt-ot|0);break r}k=dt}Tr(s,48,k+9|0,9,0)}Tr(s,32,h,W,y^8192),et=(h|0)<(W|0)?W:h;break t}tt=(b<<26>>31&9)+Mt|0;i:{if(u>>>0>11)break i;for(k=12-u|0,q=16;q=q*16,k=k-1|0,!!k;);if(Tt[tt|0]==45){a=-(q+(-a-q));break i}a=a+q-q}for(Y=nt|2,P=b&32,S=c[Q+44>>2],k=S>>31,k=jn((k^S)-k|0,0,mt),(mt|0)==(k|0)&&(pt[Q+15|0]=48,k=Q+15|0),dt=k-2|0,pt[dt|0]=b+15,pt[k-1|0]=(S|0)<0?45:43,k=y&8,S=Q+16|0;b=S,Xe(a)<2147483648?z=~~a:z=-2147483648,pt[S|0]=P|Tt[z+5504|0],a=(a-+(z|0))*16,S=b+1|0,!(k|(u|0)>0)&a==0|(S-(Q+16|0)|0)!=1||(pt[b+1|0]=46,S=b+2|0),a!=0;);if(et=-1,k=mt-dt|0,b=k+Y|0,(2147483645-b|0)<(u|0))break t;i:{r:{if(!u||(P=S-(Q+16|0)|0,(P-2|0)>=(u|0)))break r;u=u+2|0;break i}P=S-(Q+16|0)|0,u=P}b=u+b|0,Tr(s,32,h,b,y),pr(s,tt,Y),Tr(s,48,h,b,y^65536),pr(s,Q+16|0,P),Tr(s,48,u-P|0,0,0),pr(s,dt,k),Tr(s,32,h,b,y^8192),et=(h|0)<(b|0)?b:h}return St=Q+560|0,et|0}function y2(s,a,h,u,y,b,k){var S=0,P=0,z=0,tt=0,dt=0,Q=0,et=0,$=0,W=0,Y=0,q=0,nt=0,ot=0,mt=0,Et=0,Ct=0,Mt=0,Ft=0,Vt=0,qt=0;z=St-80|0,St=z,c[z+76>>2]=a,Ft=z+55|0,ot=z+56|0;t:{i:{r:{e:{s:for(;;){if(tt=a,(W^2147483647)<(S|0))break e;W=S+W|0;n:{a:{o:{if(S=tt,P=Tt[S|0],P)for(;;){l:{a=P&255;c:{if(!a){a=S;break c}if((a|0)!=37)break l;for(P=S;;){if(Tt[P+1|0]!=37){a=P;break c}if(S=S+1|0,dt=Tt[P+2|0],a=P+2|0,P=a,(dt|0)!=37)break}}if(S=S-tt|0,Mt=W^2147483647,(S|0)>(Mt|0))break e;if(s&&pr(s,tt,S),S)continue s;c[z+76>>2]=a,S=a+1|0,q=-1,P=pt[a+1|0],!Rl(P)|Tt[a+2|0]!=36||(q=P-48|0,mt=1,S=a+3|0),c[z+76>>2]=S,$=0,P=pt[S|0],a=P-32|0;c:{if(a>>>0>31){dt=S;break c}if(dt=S,a=1<<a,!(a&75913))break c;for(;;){if(dt=S+1|0,c[z+76>>2]=dt,$=a|$,P=pt[S+1|0],a=P-32|0,a>>>0>=32)break c;if(S=dt,a=1<<a,!(a&75913))break}}c:{if((P|0)==42){a=pt[dt+1|0];h:{if(!(!Rl(a)|Tt[dt+2|0]!=36)){c[((a<<2)+y|0)-192>>2]=10,P=dt+3|0,mt=1,Y=c[((pt[dt+1|0]<<3)+u|0)-384>>2];break h}if(mt)break o;if(P=dt+1|0,!s){c[z+76>>2]=P,mt=0,Y=0;break c}a=c[h>>2],c[h>>2]=a+4,mt=0,Y=c[a>>2]}if(c[z+76>>2]=P,(Y|0)>=0)break c;Y=0-Y|0,$=$|8192;break c}if(Y=G2(z+76|0),(Y|0)<0)break e;P=c[z+76>>2]}S=0,et=-1;c:{if(Tt[P|0]!=46){a=P,nt=0;break c}if(Tt[P+1|0]==42){a=pt[P+2|0];h:{if(!(!Rl(a)|Tt[P+3|0]!=36)){c[((a<<2)+y|0)-192>>2]=10,a=P+4|0,et=c[((pt[P+2|0]<<3)+u|0)-384>>2];break h}if(mt)break o;if(a=P+2|0,et=0,!s)break h;P=c[h>>2],c[h>>2]=P+4,et=c[P>>2]}c[z+76>>2]=a,nt=(et^-1)>>>31|0;break c}c[z+76>>2]=P+1,et=G2(z+76|0),a=c[z+76>>2],nt=1}for(;;){if(Q=S,dt=28,Et=a,S=pt[a|0],S-123>>>0<4294967238)break r;if(a=Et+1|0,S=Tt[(S+Ke(Q,58)|0)+4975|0],!(S-1>>>0<8))break}c[z+76>>2]=a;c:{h:{if((S|0)!=27){if(!S)break r;if((q|0)>=0){c[(q<<2)+y>>2]=S,S=(q<<3)+u|0,P=c[S+4>>2],c[z+64>>2]=c[S>>2],c[z+68>>2]=P;break h}if(!s)break n;_2(z- -64|0,S,h,k);break c}if((q|0)>=0)break r}if(S=0,!s)continue s}P=$&-65537,$=$&8192?P:$,q=0,Ct=1167,dt=ot;c:{h:{f:{d:{p:{v:{y:{u:{g:{b:{m:{T:{k:{E:{w:{A:switch(S=pt[Et|0],S=Q&&(S&15)==3?S&-33:S,S-88|0){case 11:break c;case 9:case 13:case 14:case 15:break h;case 27:break y;case 12:case 17:break b;case 23:break m;case 0:case 32:break T;case 24:break k;case 22:break E;case 29:break w;case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 10:case 16:case 18:case 19:case 20:case 21:case 25:case 26:case 28:case 30:case 31:break a;default:break A}A:switch(S-65|0){case 0:case 4:case 5:case 6:break h;case 2:break p;case 1:case 3:break a;default:break A}if((S|0)==83)break v;break a}P=c[z+64>>2],Q=c[z+68>>2],S=1167;break g}S=0;E:switch(Q&255){case 0:c[c[z+64>>2]>>2]=W;continue s;case 1:c[c[z+64>>2]>>2]=W;continue s;case 2:tt=c[z+64>>2],c[tt>>2]=W,c[tt+4>>2]=W>>31;continue s;case 3:Vi[c[z+64>>2]>>1]=W;continue s;case 4:pt[c[z+64>>2]]=W;continue s;case 6:c[c[z+64>>2]>>2]=W;continue s;case 7:break E;default:continue s}tt=c[z+64>>2],c[tt>>2]=W,c[tt+4>>2]=W>>31;continue s}et=et>>>0<=8?8:et,$=$|8,S=120}if(tt=ot,P=c[z+64>>2],Q=c[z+68>>2],P|Q)for(Vt=S&32;tt=tt-1|0,pt[tt|0]=Vt|Tt[(P&15)+5504|0],qt=!Q&P>>>0>15|(Q|0)!=0,Et=Q,Q=Q>>>4|0,P=(Et&15)<<28|P>>>4,!!qt;);if(!($&8)|!(c[z+64>>2]|c[z+68>>2]))break u;Ct=(S>>>4|0)+1167|0,q=2;break u}if(S=ot,tt=c[z+68>>2],Q=tt,P=c[z+64>>2],tt|P)for(;S=S-1|0,pt[S|0]=P&7|48,Et=!Q&P>>>0>7|(Q|0)!=0,tt=Q,Q=tt>>>3|0,P=(tt&7)<<29|P>>>3,!!Et;);if(tt=S,!($&8))break u;S=ot-tt|0,et=(S|0)<(et|0)?et:S+1|0;break u}if(P=c[z+64>>2],S=c[z+68>>2],Q=S,(S|0)<0){tt=0-(Q+((P|0)!=0)|0)|0,Q=tt,P=0-P|0,c[z+64>>2]=P,c[z+68>>2]=tt,q=1,S=1167;break g}if($&2048){q=1,S=1168;break g}q=$&1,S=q?1169:1167}Ct=S,tt=jn(P,Q,ot)}if((et|0)<0&&nt)break e;if($=nt?$&-65537:$,S=c[z+64>>2],P=c[z+68>>2],!((S|P)!=0|et)){tt=ot,et=0;break a}S=!(S|P)+(ot-tt|0)|0,et=(S|0)<(et|0)?et:S;break a}$=0,nt=et>>>0>=2147483647?2147483647:et,Q=nt,dt=(Q|0)!=0;y:{u:{S=c[z+64>>2],tt=S||4277,S=tt;g:{b:{m:{if(!(S&3)|!Q)break m;for(;;){if($=Tt[S|0],!$)break b;if(Q=Q-1|0,dt=(Q|0)!=0,S=S+1|0,!(S&3))break m;if(!Q)break}}if(!dt)break u;m:{if(!(!Tt[S|0]|Q>>>0<4))for(;;){if(dt=c[S>>2],(dt^-1)&dt-16843009&-2139062144)break m;if(S=S+4|0,Q=Q-4|0,!(Q>>>0>3))break}if(!Q)break u}dt=0;break g}dt=1}for(;;){if(!dt){$=Tt[S|0],dt=1;continue}if(!$)break y;if(S=S+1|0,Q=Q-1|0,!Q)break u;dt=0}}S=0}if(S=S?S-tt|0:nt,dt=S+tt|0,(et|0)>=0){$=P,et=S;break a}if($=P,et=S,Tt[dt|0])break e;break a}if(et){P=c[z+64>>2];break d}S=0,Tr(s,32,Y,0,$);break f}c[z+12>>2]=0,c[z+8>>2]=c[z+64>>2],P=z+8|0,c[z+64>>2]=P,et=-1}S=0;d:{for(;;){if(tt=c[P>>2],!tt)break d;if(tt=K2(z+4|0,tt),dt=(tt|0)<0,!(dt|tt>>>0>et-S>>>0)){if(P=P+4|0,S=S+tt|0,et>>>0>S>>>0)continue;break d}break}if(dt)break i}if(dt=61,(S|0)<0)break r;if(Tr(s,32,Y,S,$),!S){S=0;break f}for(dt=0,P=c[z+64>>2];;){if(tt=c[P>>2],!tt||(tt=K2(z+4|0,tt),dt=tt+dt|0,dt>>>0>S>>>0))break f;if(pr(s,z+4|0,tt),P=P+4|0,!(S>>>0>dt>>>0))break}}Tr(s,32,Y,S,$^8192),S=(S|0)<(Y|0)?Y:S;continue s}if((et|0)<0&&nt)break e;if(dt=61,S=$t[b|0](s,je[z+64>>3],Y,et,$,S)|0,(S|0)>=0)continue s;break r}pt[z+55|0]=c[z+64>>2],et=1,tt=Ft,$=P;break a}P=Tt[S+1|0],S=S+1|0}if(s)break t;if(!mt)break n;for(S=1;;){if(s=c[(S<<2)+y>>2],s){if(_2((S<<3)+u|0,s,h,k),W=1,S=S+1|0,(S|0)!=10)continue;break t}break}if(W=1,S>>>0>=10)break t;for(;;){if(c[(S<<2)+y>>2])break o;if(S=S+1|0,(S|0)==10)break}break t}dt=28;break r}if(Q=dt-tt|0,et=(et|0)>(Q|0)?et:Q,(et|0)>(q^2147483647))break e;if(dt=61,P=et+q|0,S=(P|0)<(Y|0)?Y:P,(Mt|0)<(S|0))break r;Tr(s,32,S,P,$),pr(s,Ct,q),Tr(s,48,S,P,$^65536),Tr(s,48,et,Q,0),pr(s,tt,Q),Tr(s,32,S,P,$^8192);continue}break}W=0;break t}dt=61}c[1781]=dt}W=-1}return St=z+80|0,W}function Dk(s,a,h,u){s=s|0,a=+a,h=+h,u=u|0;var y=m(0),b=m(0),k=0,S=m(0),P=0,z=m(0),tt=0,dt=m(0),Q=0;Q=St+-64|0,St=Q,k=c[s>>2],Vr(Q+8|0,0,56),c[1755]=c[1755]+1,E2(k),S=m(a),b=I[k+572>>2];t:{i:{r:switch(s=c[k+576>>2],s|0){case 0:case 3:break i;default:break r}y=I[k+572>>2];r:{if(!((s|0)!=1|y!=y)){if(y=b,!(y<m(0)))break r;break i}e:{if(!((s|0)!=2|y!=y)){if(S!=S|b<m(0))break i;break e}y=m(zt);s:switch(s-1|0){case 1:break e;case 0:break s;default:break r}y=b;break r}y=m(m(b*S)*m(.009999999776482582))}dt=m(y+m(ge(k,2,S)+Re(k,2,S))),tt=1;break t}y=m(0),b=I[k+216>>2];i:{r:{s=c[k+216>>2];e:{s:{if((s|0)==2139156720)break s;if((s|0)==2140081935)break i;tt=4336;n:{if((s|0)!=2141891242){if(b==b)break n;tt=4344}switch(y=I[tt>>2],c[tt+4>>2]-1|0){case 0:break e;case 1:break s;default:break r}}if(y=(Ot(2,(s&-1073741825)+536870912|0),Gt()),!(s&1073741824))break e}y=m(m(y*S)*m(.009999999776482582))}if(y!=y)break r;y=m(0);e:{if((s|0)==2139156720)break e;if((s|0)==2140081935)break i;P=4336;s:{if((s|0)!=2141891242){if(b==b)break s;P=4344}switch(y=I[P>>2],dt=m(zt),tt=2,c[P+4>>2]-1|0){case 1:break e;case 0:break i;default:break t}}if(y=(Ot(2,(s&-1073741825)+536870912|0),Gt()),!(s&1073741824))break i}dt=m(m(y*S)*m(.009999999776482582)),tt=2;break t}tt=S==S,dt=S;break t}tt=2,dt=y}z=m(h),b=I[k+580>>2];t:{i:{r:switch(s=c[k+584>>2],s|0){case 0:case 3:break i;default:break r}y=I[k+580>>2];r:{if(!((s|0)!=1|y!=y)){if(y=b,!(y<m(0)))break r;break i}e:{if(!((s|0)!=2|y!=y)){if(z!=z|b<m(0))break i;break e}y=m(zt);s:switch(s-1|0){case 1:break e;case 0:break s;default:break r}y=b;break r}y=m(m(b*z)*m(.009999999776482582))}b=m(y+m(ge(k,0,S)+Re(k,0,S))),s=1;break t}y=m(0),b=I[k+220>>2];i:{r:{s=c[k+220>>2];e:{s:{if((s|0)==2139156720)break s;if((s|0)==2140081935)break i;P=4336;n:{if((s|0)!=2141891242){if(b==b)break n;P=4344}switch(y=I[P>>2],c[P+4>>2]-1|0){case 0:break e;case 1:break s;default:break r}}if(y=(Ot(2,(s&-1073741825)+536870912|0),Gt()),!(s&1073741824))break e}y=m(m(y*z)*m(.009999999776482582))}if(y!=y)break r;y=m(0);e:{if((s|0)==2139156720)break e;if((s|0)==2140081935)break i;P=4336;s:{if((s|0)!=2141891242){if(b==b)break s;P=4344}switch(y=I[P>>2],b=m(zt),s=2,c[P+4>>2]-1|0){case 0:break i;case 1:break e;default:break t}}if(y=(Ot(2,(s&-1073741825)+536870912|0),Gt()),!(s&1073741824))break i}b=m(m(y*z)*m(.009999999776482582)),s=2;break t}s=z==z,b=z;break t}s=2,b=y}vn(k,dt,b,u,tt,s,S,z,1,0,c[k+568>>2],Q+8|0,0,c[1755])&&(x2(k,Tt[k+300|0]&3,S,z,S),L2(k,+I[c[k+568>>2]+20>>2],0,0)),St=Q- -64|0}function Pk(s,a){s=s|0,a=a|0;var h=0,u=m(0),y=0,b=0,k=m(0),S=0,P=0,z=0,tt=m(0);t:{P=c[a>>2],a=c[s>>2];i:{if((c[P+24>>2]^c[a+24>>2])&8388607)break i;tt=I[P+40>>2],y=c[P+40>>2],u=I[a+40>>2];r:{e:{if(h=c[a+40>>2],(h|0)!=2139156720){if(k=m(zt),s=3,(h|0)==2141891242)break r;if((h|0)!=2140081935)break e;k=m(0),s=1;break r}s=2;break r}if(s=0,u!=u)break r;k=(Ot(2,(h&-1073741825)+536870912|0),Gt()),s=h&1073741824?2:1}r:{e:{if((y|0)!=2139156720){if(u=m(zt),h=3,(y|0)==2141891242)break r;if((y|0)!=2140081935)break e;u=m(0),h=1;break r}u=m(0),h=2;break r}if(h=0,tt!=tt)break r;u=(Ot(2,(y&-1073741825)+536870912|0),Gt()),h=y&1073741824?2:1}if((h|0)!=(s|0)|!(!s|k!=k&u!=u|m(Xe(m(k-u)))<m(9999999747378752e-20))||(h=a+44|0,b=P+44|0,c[h>>2]!=c[b>>2]))break i;s=0;r:{for(;;){if(y=s,s=s+1|0,(s|0)==9)break r;if(S=s<<2,c[S+h>>2]!=c[b+S>>2])break}if(y>>>0<8)break i}if(h=a+80|0,b=P+80|0,c[h>>2]!=c[b>>2])break i;s=0;r:{for(;;){if(y=s,s=s+1|0,(s|0)==9)break r;if(S=s<<2,c[S+h>>2]!=c[b+S>>2])break}if(y>>>0<8)break i}if(h=a+116|0,b=P+116|0,c[h>>2]!=c[b>>2])break i;s=0;r:{for(;;){if(y=s,s=s+1|0,(s|0)==9)break r;if(S=s<<2,c[S+h>>2]!=c[b+S>>2])break}if(y>>>0<8)break i}if(h=a+152|0,b=P+152|0,c[h>>2]!=c[b>>2])break i;s=0;r:{for(;;){if(y=s,s=s+1|0,(s|0)==9)break r;if(S=s<<2,c[S+h>>2]!=c[b+S>>2])break}if(y>>>0<8)break i}if(h=a+188|0,b=P+188|0,c[h>>2]!=c[b>>2])break i;s=0;r:{for(;;){if(y=s,s=s+1|0,(s|0)==3)break r;if(S=s<<2,c[S+h>>2]!=c[b+S>>2])break}if(y>>>0<2)break i}for(S=P+200|0,z=a+200|0,s=0,y=1;;){r:{if(s=s<<2,h=c[s+S>>2],b=c[s+z>>2],!y)break r;if(y=0,s=1,(h|0)==(b|0))continue}break}if((h|0)!=(b|0))break i;for(S=P+208|0,z=a+208|0,s=0,y=1;;){r:{if(s=s<<2,h=c[s+S>>2],b=c[s+z>>2],!y)break r;if(y=0,s=1,(h|0)==(b|0))continue}break}if((h|0)!=(b|0))break i;for(S=P+216|0,z=a+216|0,s=0,y=1;;){r:{if(s=s<<2,h=c[s+S>>2],b=c[s+z>>2],!y)break r;if(y=0,s=1,(h|0)==(b|0))continue}break}if((h|0)!=(b|0)||(k=I[P+28>>2],s=k!=k,u=I[a+28>>2],(s|0)==(u==u|0)|!(s|u!=u)&u!=k)||(u=I[a+32>>2],k=I[P+32>>2],(u==u|0)==(k!=k|0)|u==u&u!=k)||(k=I[P+36>>2],s=k!=k,u=I[a+36>>2],(s|0)==(u==u|0)|!s&u!=k))break i;if(s=0,u=I[a+224>>2],u!=u&&(s=1,k=I[P+224>>2],k!=k)||(k=u,u=I[P+224>>2],k==u|u!=u&s))break t}for(Hr(a+24|0,P+24|0,204);;){if(s=Tt[a+4|0],s&4)break t;if(pt[a+4|0]=s|4,s=c[a+20>>2],s&&$t[s|0](a),c[a+308>>2]=2143289344,a=c[a+552>>2],!a)break}}}function Ok(s,a){s=s|0,a=a|0;var h=0,u=0,y=0,b=0,k=0,S=0,P=0,z=0,tt=0,dt=0,Q=0,et=0,$=0,W=0,Y=0,q=0;h=a,a=c[a>>2]+7&-8,c[h>>2]=a+16,$=s,P=c[a>>2],u=c[a+4>>2],s=c[a+12>>2],Q=s,k=St-32|0,St=k,s=s&2147483647,S=s,y=s-1006698496|0,s=s-1140785152|0,h=c[a+8>>2],a=h;t:{if((y|0)==(s|0)&a>>>0<a>>>0|s>>>0>y>>>0){if(s=h,h=Q<<4|s>>>28,a=s<<4|u>>>28,s=h,u=u&268435455,(u|0)==134217728&(P|0)!=0|u>>>0>134217728){s=s+1073741824|0,a=a+1|0,s=a?s:s+1|0;break t}if(s=s+1073741824|0,P|(u|0)!=134217728)break t;u=a&1,a=u+a|0,s=a>>>0<u>>>0?s+1|0:s;break t}if(!(!a&(S|0)==2147418112?!(u|P):S>>>0<2147418112)){s=h,h=Q<<4|s>>>28,a=s<<4|u>>>28,s=h&524287|2146959360;break t}if(a=0,s=2146435072,S>>>0>1140785151||(s=0,et=S>>>16|0,et>>>0<15249))break t;a=P,s=u,y=Q&65535|65536,S=y,dt=h,b=h,z=et-15233|0;i:{if(z&64){h=a,y=z+-64|0,a=y&31,(y&63)>>>0>=32?(s=h<<a,b=0):(s=(1<<a)-1&h>>>32-a|s<<a,b=h<<a),y=s,a=0,s=0;break i}if(!z)break i;tt=b,b=z&31,(z&63)>>>0>=32?(h=tt<<b,b=0):(h=(1<<b)-1&tt>>>32-b|y<<b,b=tt<<b),y=h,W=b,tt=a,h=64-z|0,b=h&31,(h&63)>>>0>=32?(h=0,a=s>>>b|0):(h=s>>>b|0,a=((1<<b)-1&s)<<32-b|tt>>>b),b=W|a,y=h|y,a=z&31,(z&63)>>>0>=32?(h=tt<<a,a=0):(h=(1<<a)-1&tt>>>32-a|s<<a,a=tt<<a),s=h}c[k+16>>2]=a,c[k+20>>2]=s,c[k+24>>2]=b,c[k+28>>2]=y,a=15361-et|0;i:{if(a&64){u=dt,a=a+-64|0,s=a&31,(a&63)>>>0>=32?(h=0,P=S>>>s|0):(h=S>>>s|0,P=((1<<s)-1&S)<<32-s|u>>>s),u=h,dt=0,S=0;break i}if(!a)break i;y=dt,s=64-a|0,h=s&31,(s&63)>>>0>=32?(s=y<<h,b=0):(s=(1<<h)-1&y>>>32-h|S<<h,b=y<<h),y=P,P=a&31,(a&63)>>>0>=32?(h=0,y=u>>>P|0):(h=u>>>P|0,y=((1<<P)-1&u)<<32-P|y>>>P),P=b|y,u=s|h,y=dt,h=a&31,(a&63)>>>0>=32?(s=0,dt=S>>>h|0):(s=S>>>h|0,dt=((1<<h)-1&S)<<32-h|y>>>h),S=s}if(c[k>>2]=P,c[k+4>>2]=u,c[k+8>>2]=dt,c[k+12>>2]=S,a=c[k+8>>2],s=c[k+12>>2]<<4|a>>>28,a=a<<4,h=c[k>>2],S=c[k+4>>2],a=S>>>28|a,u=S&268435455,h=h|(c[k+16>>2]|c[k+24>>2]|(c[k+20>>2]|c[k+28>>2]))!=0,(u|0)==134217728&(h|0)!=0|u>>>0>134217728){a=a+1|0,s=a?s:s+1|0;break t}if(h|(u|0)!=134217728)break t;h=a,a=a+(a&1)|0,s=h>>>0>a>>>0?s+1|0:s}St=k+32|0,Ot(0,a|0),Ot(1,Q&-2147483648|s),Y=$,q=+ke(),je[Y>>3]=q}function vn(s,a,h,u,y,b,k,S,P,z,tt,dt,Q,et){var $=m(0),W=0,Y=0,q=0,nt=0,ot=m(0),mt=0,Et=0,Ct=m(0);t:{if(!(c[s+312>>2]!=(et|0)&&Tt[s+4|0]&4)&&(nt=0,c[s+316>>2]==(u|0)))break t;c[s+540>>2]=-1082130432,c[s+544>>2]=-1082130432,c[s+532>>2]=0,c[s+536>>2]=0,c[s+524>>2]=-1082130432,c[s+528>>2]=-1082130432,c[s+320>>2]=0,nt=1}mt=Q+1|0;t:{i:{r:{e:{if(c[s+8>>2]){if(ot=ge(s,2,k),Ct=Re(s,2,k),$=m(ge(s,0,k)+Re(s,0,k)),Q=s+524|0,ot=m(ot+Ct),T2(y,a,b,h,c[s+532>>2],I[Q>>2],c[s+536>>2],I[s+528>>2],I[s+540>>2],I[s+544>>2],ot,$,tt))break r;if(Y=c[s+320>>2],!Y)break e;for(W=s+324|0;;){if(Q=W+Ke(q,24)|0,T2(y,a,b,h,c[Q+8>>2],I[Q>>2],c[Q+12>>2],I[Q+4>>2],I[Q+16>>2],I[Q+20>>2],ot,$,tt))break r;if(q=q+1|0,(Y|0)==(q|0))break}break e}if(!P){if(Et=c[s+320>>2],!Et)break e;for(Y=s+324|0;;){W=Ke(q,24),Q=W+Y|0,$=I[Q>>2];s:{n:{if(!($!=$|a!=a)){if(m(Xe(m($-a)))<m(9999999747378752e-20))break n;break s}if($==$|a==a)break s}W=Y+W|0,$=I[W+4>>2];n:{if(!($!=$|h!=h)){if(m(Xe(m($-h)))<m(9999999747378752e-20))break n;break s}if($==$|h==h)break s}if(c[W+8>>2]!=(y|0))break s;if(c[W+12>>2]==(b|0))break r}if(q=q+1|0,(Et|0)==(q|0))break}break e}Q=s+524|0,$=I[Q>>2];s:{if(!($!=$|a!=a)){if(m(Xe(m($-a)))<m(9999999747378752e-20))break s;break e}if($==$|a==a)break e}W=c[s+532>>2]==(y|0)&&c[s+536>>2]==(b|0)?Q:0,$=I[s+528>>2],Q=$!=$,Y=h!=h;s:{if(Q|Y){Q=Q&Y;break s}Q=m(Xe(m($-h)))<m(9999999747378752e-20)}Q=Q?W:0;break r}m2(s,a,h,u,y,b,k,S,P,tt,dt,mt,et,z),c[s+316>>2]=u;break i}if(!(!Q|nt)){I[s+516>>2]=I[Q+16>>2],I[s+520>>2]=I[Q+20>>2],u=(P?12:16)+dt|0,c[u>>2]=c[u>>2]+1;break t}if(m2(s,a,h,u,y,b,k,S,P,tt,dt,mt,et,z),c[s+316>>2]=u,Q)break t}Q=c[s+320>>2],u=Q+1|0,u>>>0>c2[dt+8>>2]&&(c[dt+8>>2]=u),(Q|0)==8&&(c[s+320>>2]=0,Q=0),P?u=s+524|0:(c[s+320>>2]=Q+1,u=(Ke(Q,24)+s|0)+324|0),c[u+12>>2]=b,c[u+8>>2]=y,I[u+4>>2]=h,I[u>>2]=a,I[u+16>>2]=I[s+516>>2],I[u+20>>2]=I[s+520>>2],Q=0}t:{if(!P||(u=c[s+520>>2],c[s+244>>2]=c[s+516>>2],c[s+248>>2]=u,u=Tt[s+4|0],y=u|1,pt[s+4|0]=y,!(u&4)))break t;pt[s+4|0]=y&251}return c[s+312>>2]=et,!Q|nt}function td(s){s=s|0;var a=0,h=0,u=0,y=0,b=0,k=0,S=0,P=0,z=0,tt=0,dt=0;S=8;t:{if(s>>>0>4294967239)break t;i:{for(;;){S=S>>>0<=8?8:S,a=c[1751],b=a,y=c[1750],s=s>>>0<=8?8:s+3&-4;r:{if(s>>>0<=127){k=(s>>>3|0)-1|0;break r}if(u=Ai(s),k=((s>>>29-u^4)-(u<<2)|0)+110|0,s>>>0<=4095)break r;u=((s>>>30-u^2)-(u<<1)|0)+71|0,k=u>>>0>=63?63:u}if(h=k&31,(k&63)>>>0>=32?(u=0,a=a>>>h|0):(u=a>>>h|0,a=((1<<h)-1&a)<<32-h|y>>>h),a|u){for(;;){y=u;r:{if(a|u){h=u-1|0,P=h+1|0,b=h,h=a-1|0,b=(h|0)!=-1?P:b,u=Ai(u^b),u=(u|0)==32?Ai(a^h)+32|0:u,h=63-u|0,Gr=0-(u>>>0>63)|0;break r}Gr=0,h=64}b=h,h=b&31,(b&63)>>>0>=32?(u=0,a=y>>>h|0):(u=y>>>h|0,a=((1<<h)-1&y)<<32-h|a>>>h),P=a,k=b+k|0,h=k<<4,a=c[h+5976>>2],b=h+5968|0;r:{if((a|0)!=(b|0)){if(y=id(a,S,s),y)break t;y=c[a+4>>2],c[y+8>>2]=c[a+8>>2],c[c[a+8>>2]+4>>2]=y,c[a+8>>2]=b,y=h+5972|0,c[a+4>>2]=c[y>>2],c[y>>2]=a,c[c[a+4>>2]+8>>2]=a,k=k+1|0,a=(u&1)<<31|P>>>1,u=u>>>1|0;break r}z=c[1751],b=k&63,a=b,y=a&31,a>>>0>=32?(a=0,h=-1>>>y|0):(a=-1>>>y|0,h=a|(1<<y)-1<<32-y),h=h&-2,y=b&31,b>>>0>=32?(a=h<<y,h=0):(a=(1<<y)-1&h>>>32-y|a<<y,h=h<<y),tt=h,y=a,b=0-k&63,h=b,a=h&31,h>>>0>=32?(a=-1<<a,h=0):(h=-1<<a,a=h|(1<<a)-1&-1>>>32-a),dt=h&-2,h=b&31,b>>>0>=32?(b=0,a=a>>>h|0):(b=a>>>h|0,a=((1<<h)-1&a)<<32-h|dt>>>h),a=a|tt,Gr=y|b,c[1750]=c[1750]&a,c[1751]=Gr&z,a=P^1}if(!(a|u))break}b=c[1751],y=c[1750]}r:{if(y|b){u=Ai(b),h=63-((u|0)==32?Ai(y)+32|0:u)|0,a=h<<4,u=c[a+5976>>2];e:{if(!b&y>>>0<1073741824||(k=99,a=a+5968|0,(a|0)==(u|0)))break e;for(;;){if(!k)break e;if(y=id(u,S,s),y)break t;if(k=k-1|0,u=c[u+8>>2],(a|0)==(u|0))break}u=a}if(rd(s+48|0))break r;if(!u||(a=(h<<4)+5968|0,(a|0)==(u|0)))break i;for(;;){if(y=id(u,S,s),y)break t;if(u=c[u+8>>2],(a|0)==(u|0))break}break i}if(!rd(s+48|0))break i}if(y=0,S-1&S)break t;if(!(s>>>0<=4294967239))break}break t}y=0}return y|0}function $k(s,a,h){s=s|0,a=a|0,h=h|0;var u=0,y=0,b=0,k=0,S=0,P=0,z=0,tt=0,dt=0,Q=0;S=St-80|0,St=S,s=c[s>>2];t:{i:{if(P=c[a>>2],!c[P+552>>2]){if(c[s+8>>2])break i;a=c[s+556>>2],k=a+(h<<2)|0,u=c[s+560>>2],y=s+564|0,b=c[y>>2];r:{if(u>>>0<b>>>0){if((u|0)==(k|0)){c[k>>2]=P,c[s+560>>2]=k+4;break r}if(h=u,a=u-4|0,u>>>0>a>>>0)for(;c[h>>2]=c[a>>2],h=h+4|0,a=a+4|0,u>>>0>a>>>0;);c[s+560>>2]=h,a=k+4|0,(a|0)!=(u|0)&&(a=u-a|0,Bs(u-(a&-4)|0,k,a)),c[k>>2]=P;break r}if(u=(u-a>>2)+1|0,u>>>0>=1073741824)break t;a=b-a|0,b=a>>1,y=Ya(S+32|0,a>>>0>=2147483644?1073741823:u>>>0<b>>>0?b:u,h,y),h=c[y+8>>2];e:{if((h|0)!=c[y+12>>2])break e;if(a=c[y+4>>2],u=c[y>>2],a>>>0>u>>>0){u=((a-u>>2)+1|0)/-2<<2,z=u+a|0,b=a,a=h-a|0,h=Bs(z,b,a)+a|0,c[y+8>>2]=h,c[y+4>>2]=u+c[y+4>>2];break e}a=(h|0)==(u|0)?1:h-u>>1,b=Ya(S+56|0,a,a>>>2|0,c[y+16>>2]),u=c[b+8>>2],a=c[y+4>>2],h=c[y+8>>2];s:{if((a|0)==(h|0)){h=u,u=a;break s}for(h=(h-a|0)+u|0;c[u>>2]=c[a>>2],a=a+4|0,u=u+4|0,(u|0)!=(h|0););a=c[y+8>>2],u=c[y+4>>2]}if(z=c[y>>2],c[y>>2]=c[b>>2],c[b>>2]=z,c[y+4>>2]=c[b+4>>2],c[b+4>>2]=u,c[y+8>>2]=h,c[b+8>>2]=a,tt=c[y+12>>2],c[y+12>>2]=c[b+12>>2],c[b+12>>2]=tt,(a|0)!=(u|0)&&(c[b+8>>2]=((u-a|0)+3&-4)+a),!z)break e;Ar(z),h=c[y+8>>2]}if(c[h>>2]=P,c[y+8>>2]=c[y+8>>2]+4,a=c[s+556>>2],h=k-a|0,dt=y,Q=Bs(c[y+4>>2]-h|0,a,h),c[dt+4>>2]=Q,u=c[s+560>>2]-k|0,k=Bs(c[y+8>>2],k,u),a=c[s+556>>2],c[s+556>>2]=c[y+4>>2],c[y+4>>2]=a,h=c[s+560>>2],c[s+560>>2]=u+k,c[y+8>>2]=h,u=c[s+564>>2],c[s+564>>2]=c[y+12>>2],c[y>>2]=a,c[y+12>>2]=u,(a|0)!=(h|0)&&(c[y+8>>2]=h+((a-h|0)+3&-4)),!a)break r;Ar(a)}for(c[P+552>>2]=s;a=Tt[s+4|0],!!(!(a&4)&&(pt[s+4|0]=a|4,a=c[s+20>>2],a&&$t[a|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],s)););St=S+80|0;return}c[S+16>>2]=4075,li(s,S+16|0),ti(),pe()}c[S>>2]=4208,li(s,S),ti(),pe()}Us(),pe()}function b2(s,a){var h=0,u=0;for(c[s>>2]=0,c[s+8>>2]=0,c[s+12>>2]=0,c[s+16>>2]=0,c[s+20>>2]=0,c[s+24>>2]=0,c[s+36>>2]=2143289344,c[s+40>>2]=2141891242,c[s+28>>2]=2143289344,c[s+32>>2]=2143289344,pt[s+4|0]=Tt[s+4|0]&128,u=Vr(s+44|0,0,36);c[u+(h<<2)>>2]=2143289344,h=h+1|0,(h|0)!=9;);for(h=0,u=Vr(s+80|0,0,36);c[u+(h<<2)>>2]=2143289344,h=h+1|0,(h|0)!=9;);for(h=0,u=Vr(s+116|0,0,36);c[u+(h<<2)>>2]=2143289344,h=h+1|0,(h|0)!=9;);for(h=0,u=Vr(s+152|0,0,36);c[u+(h<<2)>>2]=2143289344,h=h+1|0,(h|0)!=9;);for(h=0,c[s+196>>2]=0,u=s+188|0,c[u>>2]=0,c[u+4>>2]=0;c[u+(h<<2)>>2]=2143289344,h=h+1|0,(h|0)!=3;);for(c[s+24>>2]=4224,c[s+224>>2]=2143289344,c[s+216>>2]=2143289344,c[s+220>>2]=2143289344,c[s+208>>2]=2143289344,c[s+212>>2]=2143289344,c[s+200>>2]=2141891242,c[s+204>>2]=2141891242,Vr(s+228|0,0,288),c[s+244>>2]=2143289344,c[s+248>>2]=2143289344,Vr(s+252|0,0,49),c[s+308>>2]=2143289344,u=s+516|0,h=s+324|0;c[h+16>>2]=-1082130432,c[h+20>>2]=-1082130432,c[h+8>>2]=0,c[h+12>>2]=0,c[h>>2]=-1082130432,c[h+4>>2]=-1082130432,h=h+24|0,(u|0)!=(h|0););return c[s+548>>2]=0,c[s+552>>2]=0,c[s+516>>2]=2143289344,c[s+520>>2]=2143289344,c[s+572>>2]=2143289344,c[s+576>>2]=0,c[s+568>>2]=a,c[s+540>>2]=-1082130432,c[s+544>>2]=-1082130432,c[s+532>>2]=0,c[s+536>>2]=0,c[s+524>>2]=-1082130432,c[s+528>>2]=-1082130432,c[s+556>>2]=0,c[s+560>>2]=0,c[s+564>>2]=0,c[s+580>>2]=2143289344,c[s+584>>2]=0,Q2((a|0)!=0,2760),pt[s+4|0]=Tt[s+4|0]|1,pt[a+8|0]&1&&(c[s+24>>2]=c[s+24>>2]&-909|520),s}function Ze(s,a,h,u){var y=m(0),b=m(0),k=0,S=m(0);t:{i:{r:{e:{s:{n:{if(a>>>0<=1){b=I[s+212>>2],a=c[s+212>>2];a:{if((a|0)==2139156720)break a;if((a|0)==2140081935)break n;k=4336;o:{if((a|0)!=2141891242){if(b==b)break o;k=4344}switch(y=I[k>>2],b=m(zt),c[k+4>>2]-1|0){case 0:break n;case 1:break a;default:break s}}if(y=(Ot(2,(a&-1073741825)+536870912|0),Gt()),!(a&1073741824))break n}b=m(m(y*u)*m(.009999999776482582));break s}b=I[s+208>>2];a:{o:{a=c[s+208>>2];l:{if((a|0)==2139156720)break l;if((a|0)==2140081935)break o;k=4336;c:{if((a|0)!=2141891242){if(b==b)break c;k=4344}switch(y=I[k>>2],b=m(zt),c[k+4>>2]-1|0){case 0:break o;case 1:break l;default:break a}}if(y=(Ot(2,(a&-1073741825)+536870912|0),Gt()),!(a&1073741824))break o}b=m(m(y*u)*m(.009999999776482582));break a}b=y}y=m(0),S=I[s+216>>2],s=c[s+216>>2];a:{if((s|0)==2139156720)break a;if((s|0)==2140081935)break r;a=4336;o:{if((s|0)!=2141891242){if(S==S)break o;a=4344}switch(y=I[a>>2],c[a+4>>2]-1|0){case 1:break a;case 0:break e;default:break i}}if(y=(Ot(2,(s&-1073741825)+536870912|0),Gt()),!(s&1073741824))break e}y=m(m(y*u)*m(.009999999776482582));break e}b=y}y=m(0),S=I[s+220>>2],s=c[s+220>>2];s:{if((s|0)==2139156720)break s;if((s|0)==2140081935)break r;a=4336;n:{if((s|0)!=2141891242){if(S==S)break n;a=4344}switch(y=I[a>>2],c[a+4>>2]-1|0){case 1:break s;case 0:break e;default:break i}}if(y=(Ot(2,(s&-1073741825)+536870912|0),Gt()),!(s&1073741824))break e}y=m(m(y*u)*m(.009999999776482582))}if(!(y>=m(0)))break i}if(h>y)break t}if(!(b>=m(0)))return h;y=h<b?b:h}return y}function E2(s){var a=0,h=0,u=m(0),y=m(0),b=m(0),k=0,S=0,P=0,z=0,tt=0,dt=0,Q=0,et=0,$=0;for(k=St-16|0,c[k+8>>2]=0,c[k+12>>2]=1,tt=s+200|0,dt=s+572|0,Q=s+208|0,et=s+216|0,s=0;;){$=s,z=c[(k+8|0)+(s<<2)>>2],S=z<<2,s=et+S|0,u=I[s>>2];t:{i:{r:{e:{s:{n:{if(a=c[s>>2],P=(a|0)==2139156720,!(P|(a|0)==2140081935|(a|0)==2141891242)&u!=u)break n;s=S+Q|0,y=I[s>>2],h=c[s>>2];a:{o:{if((h|0)!=2139156720){if(b=m(zt),s=3,(h|0)==2141891242)break a;if((h|0)!=2140081935)break o;b=m(0),s=1;break a}b=m(0),s=2;break a}if(s=0,y!=y)break a;b=(Ot(2,(h&-1073741825)+536870912|0),Gt()),s=h&1073741824?2:1}h=s;a:{o:{if(!P){if(y=m(zt),s=3,(a|0)==2141891242)break a;if((a|0)!=2140081935)break o;y=m(0),s=1;break a}y=m(0),s=2;break a}if(s=0,u!=u)break a;y=(Ot(2,(a&-1073741825)+536870912|0),Gt()),s=a&1073741824?2:1}if((h|0)!=(s|0)|!(!s|y!=y&b!=b|m(Xe(m(y-b)))<m(9999999747378752e-20)))break n;if(s=0,P)break s;if((a|0)==2140081935)break i;if((a|0)==2141891242)break r;if(u!=u)break e;s=(a&-1073741825)+536870912|0,a=a&1073741824?2:1;break t}if(s=0,a=S+tt|0,u=I[a>>2],a=c[a>>2],(a|0)==2139156720)break s;if((a|0)==2140081935)break i;if((a|0)==2141891242)break r;if(u!=u)break e;s=(a&-1073741825)+536870912|0,a=a&1073741824?2:1;break t}a=2;break t}s=2143289344,a=0;break t}s=2143289344,a=3;break t}a=1}if(h=(z<<3)+dt|0,c[h+4>>2]=a,c[h>>2]=s,s=1,!!($&1))break}}function Hr(s,a,h){var u=0,y=0,b=0;if(h>>>0>=512)return Sk(s|0,a|0,h|0),s;y=s+h|0;t:{if(!((s^a)&3)){i:{if(!(s&3)){h=s;break i}if(!h){h=s;break i}for(h=s;;){if(pt[h|0]=Tt[a|0],a=a+1|0,h=h+1|0,!(h&3))break i;if(!(h>>>0<y>>>0))break}}u=y&-4;i:{if(u>>>0<64||(b=u+-64|0,b>>>0<h>>>0))break i;for(;c[h>>2]=c[a>>2],c[h+4>>2]=c[a+4>>2],c[h+8>>2]=c[a+8>>2],c[h+12>>2]=c[a+12>>2],c[h+16>>2]=c[a+16>>2],c[h+20>>2]=c[a+20>>2],c[h+24>>2]=c[a+24>>2],c[h+28>>2]=c[a+28>>2],c[h+32>>2]=c[a+32>>2],c[h+36>>2]=c[a+36>>2],c[h+40>>2]=c[a+40>>2],c[h+44>>2]=c[a+44>>2],c[h+48>>2]=c[a+48>>2],c[h+52>>2]=c[a+52>>2],c[h+56>>2]=c[a+56>>2],c[h+60>>2]=c[a+60>>2],a=a- -64|0,h=h- -64|0,b>>>0>=h>>>0;);}if(h>>>0>=u>>>0)break t;for(;c[h>>2]=c[a>>2],a=a+4|0,h=h+4|0,u>>>0>h>>>0;);break t}if(y>>>0<4){h=s;break t}if(u=y-4|0,u>>>0<s>>>0){h=s;break t}for(h=s;pt[h|0]=Tt[a|0],pt[h+1|0]=Tt[a+1|0],pt[h+2|0]=Tt[a+2|0],pt[h+3|0]=Tt[a+3|0],a=a+4|0,h=h+4|0,u>>>0>=h>>>0;);}if(h>>>0<y>>>0)for(;pt[h|0]=Tt[a|0],a=a+1|0,h=h+1|0,(y|0)!=(h|0););return s}function A2(s,a,h,u,y){var b=m(0),k=0,S=m(0),P=m(0),z=0,tt=0,dt=m(0),Q=m(0),et=0;if(S=m(h-u),tt=S!=S,!tt){h=m(0),k=(a<<2)+s|0,b=I[k+208>>2];t:{i:{k=c[k+208>>2];r:{e:{if((k|0)==2139156720)break e;if((k|0)==2140081935)break i;z=4336;s:{if((k|0)!=2141891242){if(b==b)break s;z=4344}switch(h=I[z>>2],c[z+4>>2]-1|0){case 0:break r;case 1:break e;default:break t}}if(h=(Ot(2,(k&-1073741825)+536870912|0),Gt()),!(k&1073741824))break r}h=m(m(h*y)*m(.009999999776482582))}if(h==h)break i;break t}P=m(h-u)}h=m(0),s=(a<<2)+s|0,b=I[s+216>>2];t:{i:{a=c[s+216>>2];r:{e:{if((a|0)==2139156720)break e;if((a|0)==2140081935)break i;s=4336;s:{if((a|0)!=2141891242){if(b==b)break s;s=4344}switch(h=I[s>>2],b=m(34028234663852886e22),c[s+4>>2]-1|0){case 0:break r;case 1:break e;default:break t}}if(h=(Ot(2,(a&-1073741825)+536870912|0),Gt()),!(a&1073741824))break r}h=m(m(h*y)*m(.009999999776482582))}if(h==h)break i;b=m(34028234663852886e22);break t}b=m(h-u)}if(h=(dt=S,Q=ld(S,b),et=b!=b|tt,et?dt:Q),s=h!=h,!(s|P!=P))return fe(h,P);S=s?P:h}return S}function T2(s,a,h,u,y,b,k,S,P,z,tt,dt,Q){var et=m(0),$=m(0),W=0,Y=0,q=m(0),nt=m(0),ot=m(0),mt=0,Et=0;if(P<m(0)|z<m(0))s=0;else{q=b,nt=a,ot=u,$=S;t:{if(!Q||(et=I[Q+20>>2],$=S,et==m(0)))break t;mt=+et,nt=Ki(+a,mt,0,0),ot=Ki(+u,mt,0,0),q=Ki(+b,mt,0,0),$=Ki(+S,mt,0,0)}et=$,Q=0;t:{if((s|0)!=(y|0))break t;if(Et=q!=q,Q=nt!=nt,Et|Q){Q=Q&Et;break t}Q=m(Xe(m(q-nt)))<m(9999999747378752e-20)}Et=Q;t:{if((h|0)!=(k|0))break t;if(W=et!=et,Q=ot!=ot,W|Q){W=Q&W;break t}W=m(Xe(m(et-ot)))<m(9999999747378752e-20)}Y=1,Q=1;t:{if(Et)break t;a=m(a-tt);i:{if((s|0)==1)break i;if(s=(s|0)!=2,!(s|y)){if(!(a>=P))break i;break t}if(Q=0,!(a<b)|(s|(y|0)!=2|(a!=a|b!=b|P!=P))||(Q=1,a>=P))break t}if(y=a!=a,s=P!=P,y|s){Q=s&y;break t}Q=m(Xe(m(a-P)))<m(9999999747378752e-20)}t:{if(W)break t;a=m(u-dt);i:{if((h|0)==1)break i;if(s=(h|0)!=2,!(s|k)){if(!(a>=z))break i;break t}if(Y=0,!(a<S)|(s|(k|0)!=2|(a!=a|S!=S|z!=z))||(Y=1,a>=z))break t}if(h=a!=a,s=z!=z,h|s){Y=s&h;break t}Y=m(Xe(m(a-z)))<m(9999999747378752e-20)}s=Q&Y}return s}function ed(s){var a=0,h=0,u=0,y=0,b=0,k=0,S=0,P=0;if(Er(+s),b=te(1)|0,u=te(0)|0,y=b>>>20&2047,(y|0)==2047)return s=s*1,s/s;if(a=u<<1,k=b<<1|u>>>31,!a&(k|0)==2145386496|k>>>0<2145386496)return!a&(k|0)==2145386496?s*0:s;t:{if(!y){if(y=0,h=u<<12,a=b<<12|u>>>20,(a|0)>0|(a|0)>=0)for(;y=y-1|0,a=a<<1|h>>>31,h=h<<1,!!((a|0)>0|(a|0)>=0););a=1-y|0,h=a&31,(a&63)>>>0>=32?(a=u<<h,u=0):(a=(1<<h)-1&u>>>32-h|b<<h,u=u<<h);break t}a=b&1048575|1048576}if(h=u,(y|0)>1023){for(;;){t:{if(u=a+-1048576|0,(u|0)<0||(a=u,a|h))break t;return s*0}if(a=a<<1|h>>>31,h=h<<1,y=y-1|0,!((y|0)>1023))break}y=1023}t:{if(u=a+-1048576|0,(u|0)<0||(a=u,a|h))break t;return s*0}if((a|0)==1048575|a>>>0<1048575)for(;y=y-1|0,u=a>>>0<524288,k=a<<1|h>>>31,h=h<<1,a=k,!!u;);return P=b&-2147483648,k=a+-1048576|y<<20,S=h,b=a,S=h,u=1-y|0,h=u&31,(u&63)>>>0>=32?(a=0,u=b>>>h|0):(a=b>>>h|0,u=((1<<h)-1&b)<<32-h|S>>>h),h=(y|0)>0,Ot(0,(h?S:u)|0),Ot(1,(h?k:a)|P),+ke()}function rd(s){var a=0,h=0,u=0,y=0,b=0;u=c[1416],a=s+7&-8,h=u+a|0;t:{i:{if(h>>>0<=u>>>0&&a||h>>>0>dg()<<16>>>0&&!(wk(h|0)|0))break i;c[1416]=h;break t}c[1781]=48,u=-1}if((u|0)!=-1){a=s+u|0,h=a-16|0,c[h+12>>2]=16,c[h>>2]=16,s=c[1748],s?b=c[s+8>>2]:b=0;t:{i:{if((b|0)==(u|0)){if(y=u-(c[u-4>>2]&-2)|0,b=c[y-4>>2],c[s+8>>2]=a,s=y-(b&-2)|0,a=-16,!(pt[(s+c[s>>2]|0)-4|0]&1))break i;a=c[s+4>>2],c[a+8>>2]=c[s+8>>2],c[c[s+8>>2]+4>>2]=a,h=h-s|0,c[s>>2]=h;break t}c[u+12>>2]=16,c[u>>2]=16,c[u+8>>2]=a,c[u+4>>2]=s,c[1748]=u,a=16}s=a+u|0,h=h-s|0,c[s>>2]=h}c[((h&-4)+s|0)-4>>2]=h|1,a=c[s>>2]-8|0;t:{if(a>>>0<=127){h=(a>>>3|0)-1|0;break t}if(y=Ai(a),h=((a>>>29-y^4)-(y<<2)|0)+110|0,a>>>0<=4095)break t;h=((a>>>30-y^2)-(y<<1)|0)+71|0,h=h>>>0>=63?63:h}a=h<<4,c[s+4>>2]=a+5968,a=a+5976|0,c[s+8>>2]=c[a>>2],c[a>>2]=s,c[c[s+8>>2]+4>>2]=s,a=c[1750],y=c[1751],s=h&31,(h&63)>>>0>=32?(h=1<<s,b=0):(b=1<<s,h=b-1&1>>>32-s),c[1750]=b|a,c[1751]=h|y}return(u|0)!=-1}function k2(s,a,h){var u=0,y=0,b=0,k=0,S=0,P=0,z=0,tt=0,dt=0;t:{i:{r:{e:{s:{n:{a:{o:{l:{c:{if(a){if(!h)break c;break l}s=(s>>>0)/(h>>>0)|0,Gr=0;break t}if(!s)break o;break a}if(!(h-1&h))break n;b=(Ai(h)+33|0)-Ai(a)|0,k=0-b|0;break e}s=(a>>>0)/0|0,Gr=0;break t}if(u=32-Ai(a)|0,u>>>0<31)break s;break r}if((h|0)==1)break i;b=h?31-Ai(h-1^h)|0:32,h=b&31,(b&63)>>>0>=32?s=a>>>h|0:(u=a>>>h|0,s=((1<<h)-1&a)<<32-h|s>>>h),Gr=u;break t}b=u+1|0,k=63-u|0}if(u=b&63,y=u&31,u>>>0>=32?(u=0,S=a>>>y|0):(u=a>>>y|0,S=((1<<y)-1&a)<<32-y|s>>>y),k=k&63,y=k&31,k>>>0>=32?(a=s<<y,s=0):(a=(1<<y)-1&s>>>32-y|a<<y,s=s<<y),b)for(k=h-1|0,dt=(k|0)==-1?-1:0;P=u<<1|S>>>31,u=S<<1|a>>>31,y=dt-(P+(u>>>0>k>>>0)|0)>>31,z=h&y,S=u-z|0,u=P-(u>>>0<z>>>0)|0,a=a<<1|s>>>31,s=tt|s<<1,tt=y&1,b=b-1|0,!!b;);Gr=a<<1|s>>>31,s=tt|s<<1;break t}s=0,a=0}Gr=a}return s}function El(s,a,h){var u=m(0),y=m(0);t:{i:{r:{if((a&-2)==2){if(a=c[s+188>>2],u=I[s+188>>2],(a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|u==u||(a=c[s+196>>2],u=I[s+196>>2],(a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|u==u))break r;break i}if(a=c[s+192>>2],u=I[s+192>>2],(a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|u==u||(u=I[s+196>>2],a=c[s+196>>2],(a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242))break r;if(u!=u)break i}u=m(0);r:{e:{if((a|0)==2139156720)break e;if((a|0)==2140081935)break t;s=4336;s:{if((a|0)!=2141891242){if(u=(Ot(2,a),Gt()),u==u)break s;s=4344}switch(u=I[s>>2],y=m(zt),c[s+4>>2]-1|0){case 0:break t;case 1:break e;default:break r}}if(u=(Ot(2,(a&-1073741825)+536870912|0),Gt()),!(a&1073741824))break t}y=m(m(u*h)*m(.009999999776482582))}return y}u=m(0)}return u}function w2(s,a){var h=0,u=0,y=0,b=0,k=0,S=0;for(h=St-320|0,St=h,u=Vr(h,0,288),h=u,c[h+16>>2]=2143289344,c[h+20>>2]=2143289344,Vr(h+24|0,0,49),c[h+80>>2]=2143289344,b=h+288|0,y=h+96|0;h=y,c[h+16>>2]=-1082130432,c[h+20>>2]=-1082130432,c[h+8>>2]=0,c[h+12>>2]=0,c[h>>2]=-1082130432,c[h+4>>2]=-1082130432,y=h+24|0,(b|0)!=(y|0););if(c[u+312>>2]=-1082130432,c[u+316>>2]=-1082130432,c[u+304>>2]=0,c[u+308>>2]=0,c[u+296>>2]=-1082130432,c[u+300>>2]=-1082130432,c[u+288>>2]=2143289344,c[u+292>>2]=2143289344,Hr(s+228|0,u,320),c[s+244>>2]=0,c[s+248>>2]=0,pt[s+4|0]=Tt[s+4|0]|1,y=c[s+556>>2],k=c[s+560>>2],(y|0)!=(k|0))for(;h=c[y>>2],c[h+552>>2]!=(s|0)&&(b=c[s+568>>2],h=I2(c[b>>2],Tt[b+8|0],h,s,S,a),c[y>>2]=h,c[h+552>>2]=s,h=c[y>>2]),w2(h,a),S=S+1|0,y=y+4|0,(k|0)!=(y|0););St=u+320|0}function id(s,a,h){var u=0,y=0,b=0,k=0;if(u=s+4|0,y=(u+a|0)-1&0-a,a=c[s>>2],y+h>>>0<=(a+s|0)-4>>>0){b=c[s+4>>2],c[b+8>>2]=c[s+8>>2],c[c[s+8>>2]+4>>2]=b,(u|0)!=(y|0)&&(y=y-u|0,b=s-(c[s-4>>2]&-2)|0,u=y+c[b>>2]|0,c[b>>2]=u,c[(b+(u&-4)|0)-4>>2]=u,s=s+y|0,a=a-y|0,c[s>>2]=a);t:{if(h+24>>>0<=a>>>0){u=(s+h|0)+8|0,a=(a-h|0)-8|0,c[u>>2]=a,c[(u+(a&-4)|0)-4>>2]=a|1,y=c[u>>2]-8|0;i:{if(y>>>0<=127){a=(y>>>3|0)-1|0;break i}if(b=Ai(y),a=((y>>>29-b^4)-(b<<2)|0)+110|0,y>>>0<=4095)break i;a=((y>>>30-b^2)-(b<<1)|0)+71|0,a=a>>>0>=63?63:a}y=a<<4,c[u+4>>2]=y+5968,y=y+5976|0,c[u+8>>2]=c[y>>2],c[y>>2]=u,c[c[u+8>>2]+4>>2]=u,y=c[1750],b=c[1751],u=a&31,(a&63)>>>0>=32?(a=1<<u,u=0):(k=1<<u,a=k-1&1>>>32-u,u=k),c[1750]=u|y,c[1751]=a|b,a=h+8|0,c[s>>2]=a,c[((a&-4)+s|0)-4>>2]=a;break t}c[(s+a|0)-4>>2]=a}s=s+4|0}else s=0;return s}function Mk(s,a){s=s|0,a=a|0;var h=0,u=0,y=0,b=0;y=St-320|0,St=y,s=c[s>>2];t:{if(c[s+560>>2]==c[s+556>>2]||(u=c[a>>2],a=c[u+552>>2],!$2(s,u)))break t;if((s|0)==(a|0)){for(h=Vr(y,0,288),a=h,c[a+16>>2]=2143289344,c[a+20>>2]=2143289344,Vr(a+24|0,0,49),c[a+80>>2]=2143289344,b=a+288|0,a=a+96|0;c[a+16>>2]=-1082130432,c[a+20>>2]=-1082130432,c[a+8>>2]=0,c[a+12>>2]=0,c[a>>2]=-1082130432,c[a+4>>2]=-1082130432,a=a+24|0,(b|0)!=(a|0););c[h+312>>2]=-1082130432,c[h+316>>2]=-1082130432,c[h+304>>2]=0,c[h+308>>2]=0,c[h+296>>2]=-1082130432,c[h+300>>2]=-1082130432,c[h+288>>2]=2143289344,c[h+292>>2]=2143289344,Hr(u+228|0,h,320),c[u+552>>2]=0}for(;;){if(a=Tt[s+4|0],a&4)break t;if(pt[s+4|0]=a|4,a=c[s+20>>2],a&&$t[a|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}St=y+320|0}function S2(s){s=s|0;var a=0,h=0,u=0,y=0,b=0,k=0,S=0;if(s){if(k=St-32|0,St=k,a=c[s>>2],u=c[a+552>>2],u&&($2(u,a),c[a+552>>2]=0),u=c[a+556>>2],h=c[a+560>>2],(u|0)!=(h|0))for(h=h-u>>2,y=h>>>0<=1?1:h,h=0;c[c[(h<<2)+u>>2]+552>>2]=0,h=h+1|0,(y|0)!=(h|0););c[a+560>>2]=u,h=a+564|0;t:{if(c[h>>2]==(u|0)||(h=Ya(k+8|0,0,0,h),y=c[a+556>>2],b=c[a+560>>2]-y|0,u=c[h+4>>2]-b|0,b=Bs(u,y,b),y=c[a+556>>2],c[a+556>>2]=b,c[h+4>>2]=y,b=c[a+560>>2],c[a+560>>2]=c[h+8>>2],c[h+8>>2]=b,S=c[a+564>>2],c[a+564>>2]=c[h+12>>2],c[h>>2]=y,c[h+12>>2]=S,(y|0)!=(b|0)&&(c[h+8>>2]=b+((y-b|0)+3&-4)),!y))break t;Ar(y),u=c[a+556>>2]}u&&(c[a+560>>2]=u,Ar(u)),Ar(a),a=c[s+8>>2],c[s+8>>2]=0,a&&$t[c[c[a>>2]+4>>2]](a),a=c[s+4>>2],c[s+4>>2]=0,a&&$t[c[c[a>>2]+4>>2]](a),St=k+32|0,Ar(s)}}function Nk(s){s=s|0;var a=0,h=0,u=0;u=St-624|0,St=u,a=c[s+4>>2],c[s+4>>2]=0,a&&$t[c[c[a>>2]+4>>2]](a),a=c[s+8>>2],c[s+8>>2]=0,a&&$t[c[c[a>>2]+4>>2]](a);t:{if(s=c[s>>2],c[s+560>>2]==c[s+556>>2]){if(c[s+552>>2])break t;a=b2(u+32|0,c[s+568>>2]),h=c[a+4>>2],c[s>>2]=c[a>>2],c[s+4>>2]=h,h=c[a+20>>2],c[s+16>>2]=c[a+16>>2],c[s+20>>2]=h,h=c[a+12>>2],c[s+8>>2]=c[a+8>>2],c[s+12>>2]=h,Hr(s+24|0,a+24|0,204),Hr(s+228|0,a+228|0,328),h=c[s+556>>2],h&&(c[s+560>>2]=h,Ar(h)),c[s+556>>2]=c[a+556>>2],c[s+560>>2]=c[a+560>>2],c[s+564>>2]=c[a+564>>2],c[s+584>>2]=c[a+584>>2],h=c[a+580>>2],c[s+576>>2]=c[a+576>>2],c[s+580>>2]=h,h=c[a+572>>2],c[s+568>>2]=c[a+568>>2],c[s+572>>2]=h,St=u+624|0;return}c[u+16>>2]=3301,li(s,u+16|0),ti(),pe()}c[u>>2]=2047,li(s,u),ti(),pe()}function R2(){Ik(7084,3067),Ck(7085,2480,1,1,0),fs(7086,2140,1,-128,127),fs(7087,2133,1,-128,127),fs(7088,2131,1,0,255),fs(7089,1287,2,-32768,32767),fs(7090,1278,2,0,65535),fs(7091,1316,4,-2147483648,2147483647),fs(7092,1307,4,0,-1),fs(7093,2659,4,-2147483648,2147483647),fs(7094,2650,4,0,-1),ig(7095,1777,-2147483648,2147483647),ig(7096,1776,0,-1),u2(7097,1770,4),u2(7098,3015,8),f2(7099,2677),f2(7100,3904),qh(7101,4,2664),qh(7102,2,2689),qh(7103,4,2704),Lk(7104,2485),Cr(7105,0,3835),Cr(7106,0,3937),Cr(7107,1,3865),Cr(7108,2,3467),Cr(7109,3,3498),Cr(7110,4,3538),Cr(7111,5,3567),Cr(7112,4,3974),Cr(7113,5,4004),Cr(7106,0,3669),Cr(7107,1,3636),Cr(7108,2,3735),Cr(7109,3,3701),Cr(7110,4,3802),Cr(7111,5,3768),Cr(7114,6,3605),Cr(7115,7,4043)}function Bs(s,a,h){var u=0,y=0;t:{if((s|0)==(a|0))break t;if(y=s+h|0,a-y>>>0<=0-(h<<1)>>>0)return Hr(s,a,h);u=(s^a)&3;i:{r:{if(s>>>0<a>>>0){if(u){u=s;break i}if(!(s&3)){u=s;break r}for(u=s;;){if(!h)break t;if(pt[u|0]=Tt[a|0],a=a+1|0,h=h-1|0,u=u+1|0,!(u&3))break}break r}e:{if(u)break e;if(y&3)for(;;){if(!h)break t;if(h=h-1|0,u=h+s|0,pt[u|0]=Tt[a+h|0],!(u&3))break}if(h>>>0<=3)break e;for(;h=h-4|0,c[h+s>>2]=c[a+h>>2],h>>>0>3;);}if(!h)break t;for(;h=h-1|0,pt[h+s|0]=Tt[a+h|0],!!h;);break t}if(h>>>0<=3)break i;for(;c[u>>2]=c[a>>2],a=a+4|0,u=u+4|0,h=h-4|0,h>>>0>3;);}if(!h)break t;for(;pt[u|0]=Tt[a|0],u=u+1|0,a=a+1|0,h=h-1|0,!!h;);}return s}function _2(s,a,h,u){t:switch(a-9|0){case 0:a=c[h>>2],c[h>>2]=a+4,c[s>>2]=c[a>>2];return;case 6:a=c[h>>2],c[h>>2]=a+4,a=Vi[a>>1],c[s>>2]=a,c[s+4>>2]=a>>31;return;case 7:a=c[h>>2],c[h>>2]=a+4,c[s>>2]=Hn[a>>1],c[s+4>>2]=0;return;case 8:a=c[h>>2],c[h>>2]=a+4,a=pt[a|0],c[s>>2]=a,c[s+4>>2]=a>>31;return;case 9:a=c[h>>2],c[h>>2]=a+4,c[s>>2]=Tt[a|0],c[s+4>>2]=0;return;case 16:a=c[h>>2]+7&-8,c[h>>2]=a+8,je[s>>3]=je[a>>3];return;case 17:$t[u|0](s,h);default:return;case 1:case 4:case 14:a=c[h>>2],c[h>>2]=a+4,a=c[a>>2],c[s>>2]=a,c[s+4>>2]=a>>31;return;case 2:case 5:case 11:case 15:a=c[h>>2],c[h>>2]=a+4,c[s>>2]=c[a>>2],c[s+4>>2]=0;return;case 3:case 10:case 12:case 13:break t}a=c[h>>2]+7&-8,c[h>>2]=a+8,h=c[a+4>>2],c[s>>2]=c[a>>2],c[s+4>>2]=h}function L2(s,a,h,u){var y=0,b=0,k=0,S=0,P=0,z=0,tt=0,dt=0,Q=0,et=m(0),$=m(0),W=m(0),Y=0,q=m(0);t:{if(a==0||(et=I[s+248>>2],$=I[s+244>>2],W=I[s+232>>2],P=+I[s+228>>2],y=Tt[s+4|0]&8,b=y>>>3|0,Y=s,q=Ki(P,a,0,b),I[Y+228>>2]=q,z=+W,Y=s,q=Ki(z,a,0,b),I[Y+232>>2]=q,tt=+$,k=ed(tt*a),b=k==k&Xe(k)<1e-4,S=!(b|k!=k?b:Xe(k+-1)<1e-4),dt=+et,k=ed(dt*a),b=k==k&Xe(k)<1e-4,Q=!(b|k!=k?b:Xe(k+-1)<1e-4),b=0,h=P+h,y=(y|0)!=0,Y=s,q=m(Ki(h+tt,a,y&S,y&!S)-Ki(h,a,0,y)),I[Y+244>>2]=q,u=z+u,Y=s,q=m(Ki(u+dt,a,y&Q,y&!Q)-Ki(u,a,0,y)),I[Y+248>>2]=q,y=c[s+560>>2],S=c[s+556>>2],(y|0)==(S|0)))break t;for(y=y-S>>2,S=y>>>0<=1?1:y;y=c[s+556>>2],c[s+560>>2]-y>>2>>>0>b>>>0?y=c[y+(b<<2)>>2]:y=0,L2(y,a,h,u),b=b+1|0,(S|0)!=(b|0););}}function Vr(s,a,h){var u=0,y=0,b=0,k=0;t:{if(!h||(pt[s|0]=a,u=s+h|0,pt[u-1|0]=a,h>>>0<3)||(pt[s+2|0]=a,pt[s+1|0]=a,pt[u-3|0]=a,pt[u-2|0]=a,h>>>0<7)||(pt[s+3|0]=a,pt[u-4|0]=a,h>>>0<9)||(u=0-s&3,y=u+s|0,a=Ke(a&255,16843009),c[y>>2]=a,u=h-u&-4,h=u+y|0,c[h-4>>2]=a,u>>>0<9)||(c[y+8>>2]=a,c[y+4>>2]=a,c[h-8>>2]=a,c[h-12>>2]=a,u>>>0<25)||(c[y+24>>2]=a,c[y+20>>2]=a,c[y+16>>2]=a,c[y+12>>2]=a,c[h-16>>2]=a,c[h-20>>2]=a,c[h-24>>2]=a,c[h-28>>2]=a,k=y&4|24,h=u-k|0,h>>>0<32))break t;for(u=od(a,0,1,1),b=Gr,a=y+k|0;c[a+24>>2]=u,c[a+28>>2]=b,c[a+16>>2]=u,c[a+20>>2]=b,c[a+8>>2]=u,c[a+12>>2]=b,c[a>>2]=u,c[a+4>>2]=b,a=a+32|0,h=h-32|0,h>>>0>31;);}return s}function Ar(s){s=s|0;var a=0,h=0,u=0,y=0,b=0;if(s){a=s-4|0,y=c[a>>2],h=y,u=a,b=c[s-8>>2],s=b&-2,(s|0)!=(b|0)&&(u=a-s|0,h=c[u+4>>2],c[h+8>>2]=c[u+8>>2],c[c[u+8>>2]+4>>2]=h,h=s+y|0),s=a+y|0,a=c[s>>2],(a|0)!=c[(s+a|0)-4>>2]&&(y=c[s+4>>2],c[y+8>>2]=c[s+8>>2],c[c[s+8>>2]+4>>2]=y,h=a+h|0),c[u>>2]=h,c[((h&-4)+u|0)-4>>2]=h|1,a=c[u>>2]-8|0;t:{if(a>>>0<=127){s=(a>>>3|0)-1|0;break t}if(h=Ai(a),s=((a>>>29-h^4)-(h<<2)|0)+110|0,a>>>0<=4095)break t;s=((a>>>30-h^2)-(h<<1)|0)+71|0,s=s>>>0>=63?63:s}a=s<<4,c[u+4>>2]=a+5968,a=a+5976|0,c[u+8>>2]=c[a>>2],c[a>>2]=u,c[c[u+8>>2]+4>>2]=u,a=c[1750],h=c[1751],u=s&31,(s&63)>>>0>=32?(s=1<<u,y=0):(y=1<<u,s=y-1&1>>>32-u),c[1750]=y|a,c[1751]=s|h}}function Fk(s,a,h){s=s|0,a=a|0,h=h|0;var u=0,y=0,b=0,k=0,S=0,P=0,z=0;u=St-32|0,St=u,y=c[s+28>>2],c[u+16>>2]=y,b=c[s+20>>2],c[u+28>>2]=h,c[u+24>>2]=a,a=b-y|0,c[u+20>>2]=a,b=a+h|0,P=2,a=u+16|0;t:{for(;;){i:{r:{e:{if(!eg(Rk(c[s+60>>2],a|0,P|0,u+12|0)|0)){if(k=c[u+12>>2],(k|0)==(b|0))break e;if((k|0)>=0)break r;break i}if((b|0)!=-1)break i}a=c[s+44>>2],c[s+28>>2]=a,c[s+20>>2]=a,c[s+16>>2]=a+c[s+48>>2],s=h;break t}S=c[a+4>>2],z=S>>>0<k>>>0,y=(z<<3)+a|0,S=k-(z?S:0)|0,c[y>>2]=S+c[y>>2],a=(z?12:4)+a|0,c[a>>2]=c[a>>2]-S,b=b-k|0,P=P-z|0,a=y;continue}break}if(c[s+28>>2]=0,c[s+16>>2]=0,c[s+20>>2]=0,c[s>>2]=c[s>>2]|32,s=0,(P|0)==2)break t;s=h-c[a+4>>2]|0}return St=u+32|0,s|0}function Uk(s){s=s|0;var a=0,h=0,u=0,y=0,b=0;h=St-96|0,St=h,c[h>>2]=s,u=St-16|0,St=u,c[u+12>>2]=h,s=St-144|0,St=s,s=Hr(s,5520,144),b=h+16|0,a=b,c[s+44>>2]=a,c[s+20>>2]=a,y=-2-a|0,y=y>>>0>=2147483647?2147483647:y,c[s+48>>2]=y,a=a+y|0,c[s+28>>2]=a,c[s+16>>2]=a,C2(s,2202,h,0,0),y&&(a=c[s+20>>2],pt[a-((a|0)==c[s+16>>2])|0]=0),St=s+144|0,St=u+16|0,s=b;t:{if(s&3)for(;;){if(!Tt[s|0])break t;if(s=s+1|0,!(s&3))break}for(;a=s,s=s+4|0,u=c[a>>2],!((u^-1)&u-16843009&-2139062144););for(;s=a,a=s+1|0,!!Tt[s|0];);}return s=(s-b|0)+1|0,a=td(s),a?s=Hr(a,b,s):s=0,St=h+96|0,s|0}function C2(s,a,h,u,y){var b=0,k=0,S=0,P=0;b=St-208|0,St=b,c[b+204>>2]=h,h=b+160|0,Vr(h,0,40),c[b+200>>2]=c[b+204>>2];t:{if((y2(0,a,b+200|0,b+80|0,h,u,y)|0)<0){y=-1;break t}P=c[s+76>>2]>=0,k=c[s>>2],c[s+72>>2]<=0&&(c[s>>2]=k&-33);i:{r:{e:{if(!c[s+48>>2]){c[s+48>>2]=80,c[s+28>>2]=0,c[s+16>>2]=0,c[s+20>>2]=0,S=c[s+44>>2],c[s+44>>2]=b;break e}if(c[s+16>>2])break r}if(h=-1,H2(s))break i}h=y2(s,a,b+200|0,b+80|0,b+160|0,u,y)}if(S&&($t[c[s+36>>2]](s,0,0)|0,c[s+48>>2]=0,c[s+44>>2]=S,c[s+28>>2]=0,a=c[s+20>>2],c[s+16>>2]=0,c[s+20>>2]=0,h=a?h:-1),a=s,s=c[s>>2],c[a>>2]=s|k&32,y=s&32?-1:h,!P)break t}return St=b+208|0,y}function Al(s){var a=0,h=m(0),u=0,y=0,b=0,k=0,S=0,P=m(0),z=0;b=St-16|0,St=b,a=c[s+12>>2];t:{if(a){P=I[s+520>>2],h=I[s+516>>2];i:{if(Tt[s+4|0]&32){h=m($t[a|0](s,h,P,0));break i}h=m($t[a|0](s,h,P))}if(h==h)break t;c[b>>2]=3409,li(s,b),ti(),pe()}i:{r:{if(k=c[s+556>>2],a=c[s+560>>2],(k|0)!=(a|0)){for(a=a-k>>2,z=a>>>0<=1?1:a;;){if(y=c[(S<<2)+k>>2],!c[y+548>>2]){if(a=c[y+24>>2],(a&196608)!=131072){if(a=a>>>13&7,a||(a=c[s+24>>2]>>>10&7),Tt[y+4|0]&2|(Tt[s+24|0]&8?(a|0)==5:0))break r;u=u||y}if(S=S+1|0,(z|0)!=(S|0))continue}break}if(u)break i}h=I[s+520>>2];break t}u=y}h=m(Al(u)+I[u+232>>2])}return St=b+16|0,h}function Wn(s,a,h,u,y,b){var k=0,S=m(0),P=0,z=m(0);k=(c[(a<<2)+4320>>2]<<2)+s|0,S=I[k+216>>2];t:{i:{k=c[k+216>>2];r:{if((k|0)==2139156720)break r;if((k|0)==2140081935)break i;P=4336;e:{if((k|0)!=2141891242){if(S==S)break e;P=4344}switch(z=I[P>>2],S=m(zt),c[P+4>>2]-1|0){case 0:break i;case 1:break r;default:break t}}if(z=(Ot(2,(k&-1073741825)+536870912|0),Gt()),!(k&1073741824))break i}S=m(m(z*h)*m(.009999999776482582));break t}S=z}u=m(S+m(ge(s,a,u)+Re(s,a,u)));t:{i:{r:switch(c[y>>2]){case 1:case 2:h=I[b>>2],u=u!=u||h<u?h:u;break i;case 0:break r;default:break t}if(u!=u)break t;c[y>>2]=2}I[b>>2]=u}}function Ne(s,a,h){var u=m(0),y=m(0),b=0,k=m(0);s=s+116|0,b=c[(a<<2)+4288>>2];t:{if((a&-2)==2){a=Wi(s,4,b,2140081935);break t}a=ji(s,b,2140081935)}t:{i:{r:{e:{if((a|0)==2139156720)break e;if((a|0)==2140081935)break t;s=4336;s:{if((a|0)!=2141891242){if(u=(Ot(2,a),Gt()),u==u)break s;s=4344}switch(u=I[s>>2],y=m(zt),c[s+4>>2]-1|0){case 0:break r;case 1:break e;default:break i}}if(u=(Ot(2,(a&-1073741825)+536870912|0),Gt()),!(a&1073741824))break r}u=m(m(u*h)*m(.009999999776482582))}if(u>=m(0))return u;if(y=u,u<m(0))break t}k=y==y?y:m(0)}return k}function Fe(s,a,h){var u=m(0),y=m(0),b=0,k=m(0);s=s+116|0,b=c[(a<<2)+4304>>2];t:{if((a&-2)==2){a=Wi(s,5,b,2140081935);break t}a=ji(s,b,2140081935)}t:{i:{r:{e:{if((a|0)==2139156720)break e;if((a|0)==2140081935)break t;s=4336;s:{if((a|0)!=2141891242){if(u=(Ot(2,a),Gt()),u==u)break s;s=4344}switch(u=I[s>>2],y=m(zt),c[s+4>>2]-1|0){case 0:break r;case 1:break e;default:break i}}if(u=(Ot(2,(a&-1073741825)+536870912|0),Gt()),!(a&1073741824))break r}u=m(m(u*h)*m(.009999999776482582))}if(u>=m(0))return u;if(y=u,u<m(0))break t}k=y==y?y:m(0)}return k}function I2(s,a,h,u,y,b){var k=0;t:{i:{if(s){r:{if(a&4){b=$t[s|0](h,u,y,b)|0;break r}b=$t[s|0](h,u,y)|0}if(b)break i}if(b=ht(588),a=Hr(b,h,552),c[a+564>>2]=0,c[a+556>>2]=0,c[a+560>>2]=0,y=c[h+556>>2],u=c[h+560>>2],(y|0)!=(u|0)){if(k=u-y|0,(k|0)<0)break t;for(s=ht(k),c[a+556>>2]=s,c[a+564>>2]=s+k;c[s>>2]=c[y>>2],s=s+4|0,y=y+4|0,(u|0)!=(y|0););c[a+560>>2]=s}s=c[h+572>>2],c[a+568>>2]=c[h+568>>2],c[a+572>>2]=s,c[a+584>>2]=c[h+584>>2],s=c[h+580>>2],c[a+576>>2]=c[h+576>>2],c[a+580>>2]=s,c[a+552>>2]=0}return b}Us(),pe()}function li(s,a){var h=0,u=0,y=0;y=St-16|0,St=y,c[y+12>>2]=a;t:{i:{if(!s){a=c[y+12>>2];break i}if(a=c[y+12>>2],h=c[s+568>>2],!h)break i;if(u=c[h+4>>2],Tt[h+8|0]&8){$t[u|0](h,s,5,0,4284,a)|0;break t}$t[u|0](h,s,5,4284,a)|0;break t}i:{if(!Tt[7016]){h=ht(28),c[h+20>>2]=1065353216,c[h+24>>2]=0,c[h+12>>2]=0,c[h+16>>2]=0,c[h>>2]=0,pt[h+8|0]=0,u=1,c[h+4>>2]=1,c[1753]=h,pt[7016]=1,c[1752]=c[1752]+1;break i}if(h=c[1753],u=c[h+4>>2],!(Tt[h+8|0]&8))break i;$t[u|0](h,s,5,0,4284,a)|0;break t}$t[u|0](h,s,5,4284,a)|0}St=y+16|0}function za(s,a,h){var u=m(0),y=0,b=m(0);s=s+80|0,y=c[(a<<2)+4304>>2];t:{i:{if((a&-2)==2){a=Wi(s,5,y,2140081935);break i}a=ji(s,y,2140081935)}i:{r:{if((a|0)==2139156720)break r;if((a|0)==2140081935)break t;s=4336;e:{if((a|0)!=2141891242){if(u=(Ot(2,a),Gt()),u==u)break e;s=4344}switch(u=I[s>>2],b=m(zt),c[s+4>>2]-1|0){case 0:break t;case 1:break r;default:break i}}if(u=(Ot(2,(a&-1073741825)+536870912|0),Gt()),!(a&1073741824))break t}b=m(m(u*h)*m(.009999999776482582))}return b}return u}function Gs(s,a,h){var u=m(0),y=0,b=m(0);s=s+80|0,y=c[(a<<2)+4288>>2];t:{i:{if((a&-2)==2){a=Wi(s,4,y,2140081935);break i}a=ji(s,y,2140081935)}i:{r:{if((a|0)==2139156720)break r;if((a|0)==2140081935)break t;s=4336;e:{if((a|0)!=2141891242){if(u=(Ot(2,a),Gt()),u==u)break e;s=4344}switch(u=I[s>>2],b=m(zt),c[s+4>>2]-1|0){case 0:break t;case 1:break r;default:break i}}if(u=(Ot(2,(a&-1073741825)+536870912|0),Gt()),!(a&1073741824))break t}b=m(m(u*h)*m(.009999999776482582))}return b}return u}function Wi(s,a,h,u){var y=m(0);a=(a<<2)+s|0,y=I[a>>2],a=c[a>>2];t:{if((a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|y==y||(a=(h<<2)+s|0,y=I[a>>2],a=c[a>>2],(a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|y==y)||(a=c[s+24>>2],y=I[s+24>>2],(a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|y==y)||(y=I[s+32>>2],s=c[s+32>>2],!((s|0)==2139156720|(s|0)==2140081935|(s|0)==2141891242)&&(a=u,y!=y)))break t;a=s}return a}function Bk(s,a){s=s|0,a=m(a);var h=0,u=0,y=0;if(h=St-16|0,St=h,s=c[s>>2],!(a>=m(0))){c[h>>2]=2263,u=St-16|0,St=u,c[u+12>>2]=h;t:{if(s)break t;if(Tt[7016]){s=c[1753];break t}s=ht(28),c[s+20>>2]=1065353216,c[s+24>>2]=0,c[s+12>>2]=0,c[s+16>>2]=0,c[s>>2]=0,pt[s+8|0]=0,c[s+4>>2]=1,c[1753]=s,pt[7016]=1,c[1752]=c[1752]+1}y=c[s+4>>2];t:{if(Tt[s+8|0]&8){$t[y|0](s,0,5,0,4284,h)|0;break t}$t[y|0](s,0,5,4284,h)|0}St=u+16|0,ti(),pe()}I[s+20>>2]=a==m(0)?m(0):a,St=h+16|0}function x2(s,a,h,u,y){var b=0,k=0,S=m(0),P=0;b=2,k=c[s+24>>2]>>>2&3;t:{i:{r:{if(!(!c[s+552>>2]|(a|0)!=2)){a=0,b=3;e:switch(k-2|0){case 0:break t;case 1:break e;default:break r}b=2;break t}if(a=0,k>>>0>1)break i}a=b}b=k}h=q2(s,b,h),u=q2(s,a,u),S=ge(s,b,y),k=s+228|0,P=b<<2,I[k+(c[P+4288>>2]<<2)>>2]=h+S,S=Re(s,b,y),I[k+(c[P+4304>>2]<<2)>>2]=h+S,h=ge(s,a,y),b=a<<2,I[k+(c[b+4288>>2]<<2)>>2]=u+h,h=Re(s,a,y),I[k+(c[b+4304>>2]<<2)>>2]=u+h}function Gk(s,a,h,u,y,b){s=s|0,a=a|0,h=m(h),u=u|0,y=m(y),b=b|0;var k=0,S=0,P=0;k=St-48|0,St=k,P=c[a+8>>2];t:{if(pt[7052]&1){a=c[1762];break t}a=d2(5,4480)|0,pt[7052]=1,c[1762]=a}c[k+40>>2]=b,I[k+32>>2]=y,c[k+24>>2]=u,I[k+16>>2]=h,S=+Ek(a|0,P|0,2922,k+12|0,k+16|0);t:{if(S<4294967296&S>=0){a=~~S>>>0;break t}a=0}u=c[k+12>>2],b=c[a+4>>2],c[s>>2]=c[a>>2],c[s+4>>2]=b,b=c[a+12>>2],c[s+8>>2]=c[a+8>>2],c[s+12>>2]=b,bk(u|0),St=k+48|0}function Hk(s,a,h){s=s|0,a=a|0,h=h|0;var u=0,y=0,b=0,k=0;if(u=St-32|0,St=u,y=c[a>>2],y>>>0<2147483632){t:{i:{if(y>>>0>=11){b=(y|15)+1|0,k=ht(b),c[u+16>>2]=b|-2147483648,c[u+8>>2]=k,c[u+12>>2]=y,b=y+k|0;break i}if(pt[u+19|0]=y,k=u+8|0,b=k+y|0,!y)break t}Hr(k,a+4|0,y)}return pt[b|0]=0,c[u>>2]=h,$t[s|0](u+24|0,u+8|0,u),yk(c[u+24>>2]),s=c[u+24>>2],Ka(s|0),Ka(c[u>>2]),pt[u+19|0]<0&&Ar(c[u+8>>2]),St=u+32|0,s|0}Us(),pe()}function pr(s,a,h){var u=0,y=0,b=0;if(!(Tt[s|0]&32))t:{u=a,a=s,s=c[a+16>>2];i:{if(!s){if(H2(a))break i;s=c[a+16>>2]}if(b=c[a+20>>2],s-b>>>0<h>>>0){$t[c[a+36>>2]](a,u,h)|0;break t}r:{if(c[a+80>>2]<0)break r;for(s=h;;){if(y=s,!s)break r;if(s=y-1|0,Tt[u+s|0]==10)break}if($t[c[a+36>>2]](a,u,y)>>>0<y>>>0)break i;u=u+y|0,h=h-y|0,b=c[a+20>>2]}Hr(b,u,h),c[a+20>>2]=c[a+20>>2]+h}}}function sd(s,a,h){var u=0,y=0,b=0;u=St-16|0,St=u,y=s+24|0,$t[a|0](u+8|0,y),b=c[u+12>>2];t:{if((c[c[u+8>>2]>>2]&7<<b)>>b==(h|0))break t;for($t[a|0](u+8|0,y),a=c[u+8>>2],y=a,b=c[a>>2],a=c[u+12>>2],c[y>>2]=b&(7<<a^-1)|(h&7)<<a;;){if(a=Tt[s+4|0],a&4)break t;if(pt[s+4|0]=a|4,a=c[s+20>>2],a&&$t[a|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}St=u+16|0}function ji(s,a,h){var u=m(0);a=(a<<2)+s|0,u=I[a>>2],a=c[a>>2];t:{if((a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|u==u||(a=c[s+28>>2],u=I[s+28>>2],(a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|u==u)||(u=I[s+32>>2],s=c[s+32>>2],!((s|0)==2139156720|(s|0)==2140081935|(s|0)==2141891242)&&(a=h,u!=u)))break t;a=s}return a}function Re(s,a,h){var u=m(0),y=0;s=s+44|0,y=c[(a<<2)+4304>>2];t:{if((a&-2)==2){s=Wi(s,5,y,2140081935);break t}s=ji(s,y,2140081935)}t:{if((s|0)!=2139156720){if((s|0)==2140081935|(s|0)==2141891242)break t;if(u=(Ot(2,s),Gt()),u!=u)return m(zt);if(u=(Ot(2,(s&-1073741825)+536870912|0),Gt()),!(s&1073741824))break t}u=m(m(u*h)*m(.009999999776482582))}return u}function ge(s,a,h){var u=m(0),y=0;s=s+44|0,y=c[(a<<2)+4288>>2];t:{if((a&-2)==2){s=Wi(s,4,y,2140081935);break t}s=ji(s,y,2140081935)}t:{if((s|0)!=2139156720){if((s|0)==2140081935|(s|0)==2141891242)break t;if(u=(Ot(2,s),Gt()),u!=u)return m(zt);if(u=(Ot(2,(s&-1073741825)+536870912|0),Gt()),!(s&1073741824))break t}u=m(m(u*h)*m(.009999999776482582))}return u}function Vk(s,a,h){s=s|0,a=a|0,h=h|0;var u=0,y=0,b=0,k=0,S=0;return y=c[s+84>>2],b=c[y>>2],u=c[y+4>>2],S=c[s+28>>2],k=c[s+20>>2]-S|0,k=u>>>0<k>>>0?u:k,k&&(Hr(b,S,k),b=k+c[y>>2]|0,c[y>>2]=b,u=c[y+4>>2]-k|0,c[y+4>>2]=u),u=h>>>0>u>>>0?u:h,u&&(Hr(b,a,u),b=u+c[y>>2]|0,c[y>>2]=b,c[y+4>>2]=c[y+4>>2]-u),pt[b|0]=0,a=c[s+44>>2],c[s+28>>2]=a,c[s+20>>2]=a,h|0}function _e(s,a){var h=m(0),u=0;s=s+152|0,u=c[(a<<2)+4304>>2];t:{if((a&-2)==2){s=Wi(s,5,u,2140081935);break t}s=ji(s,u,2140081935)}h=m(0);t:{if((s|0)==2139156720||(h=m(0),(s|0)==2140081935))break t;i:{if((s|0)==2141891242||(h=(Ot(2,s),Gt()),h!=h))break i;h=(Ot(2,(s&-1073741825)+536870912|0),Gt());break t}h=m(zt)}return fe(h,m(0))}function ve(s,a){var h=m(0),u=0;s=s+152|0,u=c[(a<<2)+4288>>2];t:{if((a&-2)==2){s=Wi(s,4,u,2140081935);break t}s=ji(s,u,2140081935)}h=m(0);t:{if((s|0)==2139156720||(h=m(0),(s|0)==2140081935))break t;i:{if((s|0)==2141891242||(h=(Ot(2,s),Gt()),h!=h))break i;h=(Ot(2,(s&-1073741825)+536870912|0),Gt());break t}h=m(zt)}return fe(h,m(0))}function Wk(s,a,h){s=s|0,a=a|0,h=h|0;var u=0,y=0,b=m(0);u=2,a=c[a>>2]+(h<<2)|0,b=I[a+116>>2];t:{i:{if(a=c[a+116>>2],(a|0)!=2139156720){if(y=zt,(a|0)==2141891242){u=3;break t}if((a|0)!=2140081935)break i;y=0,u=1;break t}break t}if(b!=b){u=0;break t}u=a&1073741824?2:1,y=(Ot(2,(a&-1073741825)+536870912|0),+Gt())}je[s+8>>3]=y,c[s>>2]=u}function jk(s,a,h){s=s|0,a=a|0,h=h|0;var u=0,y=0,b=m(0);u=2,a=c[a>>2]+(h<<2)|0,b=I[a+80>>2];t:{i:{if(a=c[a+80>>2],(a|0)!=2139156720){if(y=zt,(a|0)==2141891242){u=3;break t}if((a|0)!=2140081935)break i;y=0,u=1;break t}break t}if(b!=b){u=0;break t}u=a&1073741824?2:1,y=(Ot(2,(a&-1073741825)+536870912|0),+Gt())}je[s+8>>3]=y,c[s>>2]=u}function Kk(s,a,h){s=s|0,a=a|0,h=h|0;var u=0,y=0,b=m(0);u=2,a=c[a>>2]+(h<<2)|0,b=I[a+44>>2];t:{i:{if(a=c[a+44>>2],(a|0)!=2139156720){if(y=zt,(a|0)==2141891242){u=3;break t}if((a|0)!=2140081935)break i;y=0,u=1;break t}break t}if(b!=b){u=0;break t}u=a&1073741824?2:1,y=(Ot(2,(a&-1073741825)+536870912|0),+Gt())}je[s+8>>3]=y,c[s>>2]=u}function Ki(s,a,h,u){var y=0,b=0,k=0;s=s*a,y=ed(s),y=y<0?y+1:y,k=y!=y;t:{if(!(k|!(Xe(y)<1e-4))){s=s-y;break t}i:{if(y!=y){s=s-y;break i}if(s=s-y,!(Xe(y+-1)<1e-4))break i;s=s+1;break t}if(h){s=s+1;break t}if(u)break t;b=0;i:{if(k||(b=1,y>.5))break i;b=Xe(y+-.5)<1e-4?1:0}s=s+b}return s!=s|a!=a?m(zt):m(s/a)}function D2(s,a){var h=m(0);t:{if((a|0)!=2139156720){if((a|0)!=2140081935){if((a|0)!=2141891242)break t;c[s>>2]=2143289344,c[s+4>>2]=3;return}c[s>>2]=0,c[s+4>>2]=1;return}c[s>>2]=0,c[s+4>>2]=2;return}if(h=(Ot(2,a),Gt()),h!=h){c[s>>2]=2143289344,c[s+4>>2]=0;return}c[s+4>>2]=a&1073741824?2:1,c[s>>2]=(a&-1073741825)+536870912}function P2(s){var a=0,h=0,u=0;h=c[s+24>>2];t:{if(!(h&8)||(a=1,(h&7168)==5120)||(a=0,u=c[s+560>>2],h=c[s+556>>2],(u|0)==(h|0)))break t;for(s=u-h>>2,u=s>>>0<=1?1:s,s=0;;){if(a=c[c[h+(s<<2)>>2]+24>>2],a=(a&196608)!=131072&(a&57344)==40960,a)break t;if(s=s+1|0,(u|0)==(s|0))break}}return a}function zk(s,a){s=s|0,a=a|0;var h=0,u=0,y=m(0);a=c[a>>2],y=I[a+220>>2];t:{i:{if(a=c[a+220>>2],(a|0)!=2139156720){if(u=zt,h=3,(a|0)==2141891242)break t;if((a|0)!=2140081935)break i;u=0,h=1;break t}h=2;break t}if(h=0,y!=y)break t;u=(Ot(2,(a&-1073741825)+536870912|0),+Gt()),h=a&1073741824?2:1}a=h,je[s+8>>3]=u,c[s>>2]=a}function Yk(s,a){s=s|0,a=a|0;var h=0,u=0,y=m(0);a=c[a>>2],y=I[a+200>>2];t:{i:{if(a=c[a+200>>2],(a|0)!=2139156720){if(u=zt,h=3,(a|0)==2141891242)break t;if((a|0)!=2140081935)break i;u=0,h=1;break t}h=2;break t}if(h=0,y!=y)break t;u=(Ot(2,(a&-1073741825)+536870912|0),+Gt()),h=a&1073741824?2:1}a=h,je[s+8>>3]=u,c[s>>2]=a}function Xk(s,a){s=s|0,a=a|0;var h=0,u=0,y=m(0);a=c[a>>2],y=I[a+204>>2];t:{i:{if(a=c[a+204>>2],(a|0)!=2139156720){if(u=zt,h=3,(a|0)==2141891242)break t;if((a|0)!=2140081935)break i;u=0,h=1;break t}h=2;break t}if(h=0,y!=y)break t;u=(Ot(2,(a&-1073741825)+536870912|0),+Gt()),h=a&1073741824?2:1}a=h,je[s+8>>3]=u,c[s>>2]=a}function Zk(s,a){s=s|0,a=a|0;var h=0,u=0,y=m(0);a=c[a>>2],y=I[a+208>>2];t:{i:{if(a=c[a+208>>2],(a|0)!=2139156720){if(u=zt,h=3,(a|0)==2141891242)break t;if((a|0)!=2140081935)break i;u=0,h=1;break t}h=2;break t}if(h=0,y!=y)break t;u=(Ot(2,(a&-1073741825)+536870912|0),+Gt()),h=a&1073741824?2:1}a=h,je[s+8>>3]=u,c[s>>2]=a}function qk(s,a){s=s|0,a=a|0;var h=0,u=0,y=m(0);a=c[a>>2],y=I[a+212>>2];t:{i:{if(a=c[a+212>>2],(a|0)!=2139156720){if(u=zt,h=3,(a|0)==2141891242)break t;if((a|0)!=2140081935)break i;u=0,h=1;break t}h=2;break t}if(h=0,y!=y)break t;u=(Ot(2,(a&-1073741825)+536870912|0),+Gt()),h=a&1073741824?2:1}a=h,je[s+8>>3]=u,c[s>>2]=a}function Qk(s,a){s=s|0,a=a|0;var h=0,u=0,y=m(0);a=c[a>>2],y=I[a+216>>2];t:{i:{if(a=c[a+216>>2],(a|0)!=2139156720){if(u=zt,h=3,(a|0)==2141891242)break t;if((a|0)!=2140081935)break i;u=0,h=1;break t}h=2;break t}if(h=0,y!=y)break t;u=(Ot(2,(a&-1073741825)+536870912|0),+Gt()),h=a&1073741824?2:1}a=h,je[s+8>>3]=u,c[s>>2]=a}function Jk(s,a){s=s|0,a=a|0;var h=0;if(h=St-16|0,St=h,s=c[s>>2],(a|0)<6){St=h+16|0;t:{i:switch(a-4|0){case 0:if(a=s+260|0,(Tt[s+300|0]&3)==2)break t;a=s+252|0;break t;case 1:if(a=s+252|0,(Tt[s+300|0]&3)==2)break t;a=s+260|0;break t;default:break i}a=(s+(a<<2)|0)+252|0}return+I[a>>2]}c[h>>2]=1872,li(s,h),ti(),pe()}function t3(s,a){s=s|0,a=a|0;var h=0;if(h=St-16|0,St=h,s=c[s>>2],(a|0)<6){St=h+16|0;t:{i:switch(a-4|0){case 0:if(a=s+276|0,(Tt[s+300|0]&3)==2)break t;a=s+268|0;break t;case 1:if(a=s+268|0,(Tt[s+300|0]&3)==2)break t;a=s+276|0;break t;default:break i}a=(s+(a<<2)|0)+268|0}return+I[a>>2]}c[h>>2]=1872,li(s,h),ti(),pe()}function e3(s,a){s=s|0,a=a|0;var h=0;if(h=St-16|0,St=h,s=c[s>>2],(a|0)<6){St=h+16|0;t:{i:switch(a-4|0){case 0:if(a=s+292|0,(Tt[s+300|0]&3)==2)break t;a=s+284|0;break t;case 1:if(a=s+284|0,(Tt[s+300|0]&3)==2)break t;a=s+292|0;break t;default:break i}a=(s+(a<<2)|0)+284|0}return+I[a>>2]}c[h>>2]=1872,li(s,h),ti(),pe()}function r3(s,a){s=s|0,a=a|0;var h=0,u=m(0),y=m(0);u=m(zt),a=c[a>>2],y=I[a+40>>2],a=c[a+40>>2],h=3;t:{if((a|0)==2141891242)break t;if((a|0)==2140081935){u=m(0),h=1;break t}if((a|0)==2139156720){u=m(0),h=2;break t}if(h=0,y!=y)break t;u=(Ot(2,(a&-1073741825)+536870912|0),Gt()),h=a&1073741824?2:1}c[s>>2]=h,je[s+8>>3]=u}function zi(s){var a=0,h=m(0);a=2143289344;t:{if(m(Xe(s))==m(h2)|s!=s||(a=2139156720,s<m(10842021724855044e-35)&s>m(-10842021724855044e-35)|s==m(0)))break t;h=(Ot(2,(Jr(s),te(2)&-2147483648|1602224127)),Gt()),a=(Jr(s>m(0xffffff0000000000)||s<m(-0xffffff0000000000)?h:s),te(2)-536870912|1073741824)}return a}function Ti(s){var a=0,h=m(0);a=2143289344;t:{if(m(Xe(s))==m(h2)|s!=s||(a=2140081935,s<m(10842021724855044e-35)&s>m(-10842021724855044e-35)|s==m(0)))break t;h=(Ot(2,(Jr(s),te(2)&-2147483648|1610612735)),Gt()),a=(Jr(s>m(36893485948395848e3)||s<m(-36893485948395848e3)?h:s),te(2)-536870912|0)}return a}function i3(s,a){s=s|0,a=a|0;var h=m(0),u=m(0);s=c[s>>2]+(a<<2)|0,u=I[s+188>>2];t:{i:{if(s=c[s+188>>2],(s|0)==2139156720|(s|0)==2140081935)break i;if(h=m(zt),(s|0)==2141891242|u!=u)break t;if((s|0)==2139156720)break i;return m((Ot(2,(s&-1073741825)+536870912|0),Gt()))}h=m(0)}return m(h)}function s3(s,a,h,u,y,b){s=s|0,a=a|0,h=m(h),u=u|0,y=m(y),b=b|0;var k=0,S=0;return k=St-16|0,St=k,S=c[s>>2],s=c[s+4>>2],a=(s>>1)+a|0,s&1&&(S=c[S+c[a>>2]>>2]),$t[S|0](k,a,h,u,y,b),s=ht(16),a=c[k+12>>2],c[s+8>>2]=c[k+8>>2],c[s+12>>2]=a,a=c[k+4>>2],c[s>>2]=c[k>>2],c[s+4>>2]=a,St=k+16|0,s|0}function O2(s,a){t:{if(a){a=tg(c[a>>2]);break t}i:{if(Tt[7016]){a=c[1753];break i}a=ht(28),c[a+20>>2]=1065353216,c[a+24>>2]=0,c[a+12>>2]=0,c[a+16>>2]=0,c[a>>2]=0,pt[a+8|0]=0,c[a+4>>2]=1,c[1753]=a,pt[7016]=1,c[1752]=c[1752]+1}a=tg(a)}return c[s+4>>2]=0,c[s+8>>2]=0,c[s>>2]=a,c[a>>2]=s,s}function n3(s,a,h){s=s|0,a=a|0,h=+h;var u=0,y=0;t:{if(s=c[s>>2],a=s+(a<<2)|0,y=c[a+152>>2],u=Ti(m(h)),(y|0)==(u|0))break t;for(c[a+152>>2]=u;;){if(a=Tt[s+4|0],a&4)break t;if(pt[s+4|0]=a|4,a=c[s+20>>2],a&&$t[a|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function a3(s,a,h){s=s|0,a=a|0,h=+h;var u=0,y=0;t:{if(s=c[s>>2],a=s+(a<<2)|0,y=c[a+188>>2],u=Ti(m(h)),(y|0)==(u|0))break t;for(c[a+188>>2]=u;;){if(a=Tt[s+4|0],a&4)break t;if(pt[s+4|0]=a|4,a=c[s+20>>2],a&&$t[a|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function o3(s,a){s=s|0,a=a|0;var h=0,u=m(0);s=c[s>>2]+(a<<2)|0,u=I[s+152>>2];t:{i:{if(s=c[s+152>>2],(s|0)==2139156720|(s|0)==2140081935)break i;if(h=zt,(s|0)==2141891242|u!=u)break t;if((s|0)==2139156720)break i;return Ot(2,(s&-1073741825)+536870912|0),+Gt()}h=0}return+h}function l3(s,a){s=s|0,a=a|0;var h=0;t:{if(s=c[s>>2],h=c[s+24>>2],(h>>>20&3)==(a|0))break t;for(c[s+24>>2]=h&-3145729|a<<20&3145728;;){if(a=Tt[s+4|0],a&4)break t;if(pt[s+4|0]=a|4,a=c[s+20>>2],a&&$t[a|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function jn(s,a,h){var u=0,y=0,b=0;t:{if(!a){u=s;break t}for(;u=k2(s,a,10),y=Gr,s=od(u,y,246,0)+s|0,h=h-1|0,pt[h|0]=s|48,b=a>>>0>9,s=u,a=y,!!b;);}if(u)for(;h=h-1|0,s=(u>>>0)/10|0,pt[h|0]=Ke(s,246)+u|48,a=u>>>0>9,u=s,!!a;);return h}function c3(s,a){s=s|0,a=a|0;var h=0;t:{if(s=c[s>>2],h=c[s+24>>2],(h>>>22&1)==(a|0))break t;for(c[s+24>>2]=h&-4194305|a<<22&4194304;;){if(a=Tt[s+4|0],a&4)break t;if(pt[s+4|0]=a|4,a=c[s+20>>2],a&&$t[a|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function h3(s,a){s=s|0,a=a|0;var h=0;t:{if(s=c[s>>2],h=c[s+24>>2],(h>>>18&3)==(a|0))break t;for(c[s+24>>2]=h&-786433|a<<18&786432;;){if(a=Tt[s+4|0],a&4)break t;if(pt[s+4|0]=a|4,a=c[s+20>>2],a&&$t[a|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function d3(s,a){s=s|0,a=a|0;var h=0;t:{if(s=c[s>>2],h=c[s+24>>2],(h>>>16&3)==(a|0))break t;for(c[s+24>>2]=h&-196609|a<<16&196608;;){if(a=Tt[s+4|0],a&4)break t;if(pt[s+4|0]=a|4,a=c[s+20>>2],a&&$t[a|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function u3(s,a){s=s|0,a=+a;var h=0,u=m(0),y=m(0);t:{if(u=m(a),s=c[s>>2],y=I[s+224>>2],u==y|u!=u&y!=y)break t;for(I[s+224>>2]=u;;){if(h=Tt[s+4|0],h&4)break t;if(pt[s+4|0]=h|4,h=c[s+20>>2],h&&$t[h|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function f3(s,a){s=s|0,a=+a;var h=0,u=m(0),y=m(0);t:{if(u=m(a),s=c[s>>2],y=I[s+28>>2],u==y|u!=u&y!=y)break t;for(I[s+28>>2]=u;;){if(h=Tt[s+4|0],h&4)break t;if(pt[s+4|0]=h|4,h=c[s+20>>2],h&&$t[h|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function p3(s,a){s=s|0,a=+a;var h=0,u=m(0),y=m(0);t:{if(u=m(a),s=c[s>>2],y=I[s+32>>2],u==y|u!=u&y!=y)break t;for(I[s+32>>2]=u;;){if(h=Tt[s+4|0],h&4)break t;if(pt[s+4|0]=h|4,h=c[s+20>>2],h&&$t[h|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function g3(s,a){s=s|0,a=+a;var h=0,u=m(0),y=m(0);t:{if(u=m(a),s=c[s>>2],y=I[s+36>>2],u==y|u!=u&y!=y)break t;for(I[s+36>>2]=u;;){if(h=Tt[s+4|0],h&4)break t;if(pt[s+4|0]=h|4,h=c[s+20>>2],h&&$t[h|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function m3(s,a){s=s|0,a=a|0;var h=0;t:{if(s=c[s>>2],h=c[s+24>>2],(h>>>4&7)==(a|0))break t;for(c[s+24>>2]=h&-113|a<<4&112;;){if(a=Tt[s+4|0],a&4)break t;if(pt[s+4|0]=a|4,a=c[s+20>>2],a&&$t[a|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function v3(s,a){s=s|0,a=a|0;var h=0;t:{if(s=c[s>>2],h=c[s+24>>2],(h>>>2&3)==(a|0))break t;for(c[s+24>>2]=h&-13|a<<2&12;;){if(a=Tt[s+4|0],a&4)break t;if(pt[s+4|0]=a|4,a=c[s+20>>2],a&&$t[a|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function y3(s,a){s=s|0,a=a|0;var h=0;t:{if(s=c[s>>2],h=Tt[s+4|0],((h&2)>>>1|0)==(a|0))break t;for(pt[s+4|0]=h&253|(a?2:0);;){if(a=Tt[s+4|0],a&4)break t;if(pt[s+4|0]=a|4,a=c[s+20>>2],a&&$t[a|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function b3(s,a,h){s=s|0,a=a|0,h=h|0;var u=0,y=0;return u=St-16|0,St=u,y=c[s>>2],s=c[s+4>>2],a=(s>>1)+a|0,s&1&&(y=c[y+c[a>>2]>>2]),$t[y|0](u,a,h),s=ht(16),a=c[u+12>>2],c[s+8>>2]=c[u+8>>2],c[s+12>>2]=a,a=c[u+4>>2],c[s>>2]=c[u>>2],c[s+4>>2]=a,St=u+16|0,s|0}function $2(s,a){var h=0,u=0;t:{i:{if(h=c[s+556>>2],u=c[s+560>>2],(h|0)==(u|0))break i;for(;;){if(c[h>>2]==(a|0))break i;if(h=h+4|0,(u|0)==(h|0))break}break t}if((h|0)==(u|0))break t;return a=h+4|0,Bs(h,a,u-a|0),c[s+560>>2]=u-4,1}return 0}function E3(s){s=s|0;var a=0,h=0;if(h=St-16|0,St=h,s=c[s>>2],c[s+8>>2]){for(;a=Tt[s+4|0],!!(!(a&4)&&(pt[s+4|0]=a|4,a=c[s+20>>2],a&&$t[a|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],s)););St=h+16|0;return}c[h>>2]=1024,li(s,h),ti(),pe()}function M2(s,a){var h=0,u=0,y=0;if(Er(+s),u=te(1)|0,y=te(0)|0,h=u>>>20&2047,(h|0)!=2047){if(!h)return s==0?h=0:(s=M2(s*18446744073709552e3,a),h=c[a>>2]+-64|0),c[a>>2]=h,s;c[a>>2]=h-1022,Ot(0,y|0),Ot(1,u&-2146435073|1071644672),s=+ke()}return s}function A3(s,a){s=s|0,a=a|0;var h=0,u=0;return h=St-16|0,St=h,u=c[s>>2],s=c[s+4>>2],a=(s>>1)+a|0,s&1&&(u=c[u+c[a>>2]>>2]),$t[u|0](h,a),s=ht(16),a=c[h+12>>2],c[s+8>>2]=c[h+8>>2],c[s+12>>2]=a,a=c[h+4>>2],c[s>>2]=c[h>>2],c[s+4>>2]=a,St=h+16|0,s|0}function Tl(s,a,h){var u=0;t:{if(u=s+24|0,c[(u+(a<<2)|0)+184>>2]==(h|0))break t;for(c[((a<<2)+u|0)+184>>2]=h;;){if(a=Tt[s+4|0],a&4)break t;if(pt[s+4|0]=a|4,a=c[s+20>>2],a&&$t[a|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function kl(s,a,h){var u=0;t:{if(u=s+24|0,c[(u+(a<<2)|0)+192>>2]==(h|0))break t;for(c[((a<<2)+u|0)+192>>2]=h;;){if(a=Tt[s+4|0],a&4)break t;if(pt[s+4|0]=a|4,a=c[s+20>>2],a&&$t[a|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function Kn(s,a,h){var u=0;t:{if(u=s+24|0,c[(u+(a<<2)|0)+176>>2]==(h|0))break t;for(c[((a<<2)+u|0)+176>>2]=h;;){if(a=Tt[s+4|0],a&4)break t;if(pt[s+4|0]=a|4,a=c[s+20>>2],a&&$t[a|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function nd(s,a){var h=0,u=0,y=0;t:{if(h=s+24|0,c[h+16>>2]==(a|0))break t;for(u=$t[9](h)|0,y=a,c[u+16>>2]=y;;){if(a=Tt[s+4|0],a&4)break t;if(pt[s+4|0]=a|4,a=c[s+20>>2],a&&$t[a|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function N2(s,a,h){var u=0;t:{if(u=s+24|0,c[(u+(a<<2)|0)+92>>2]==(h|0))break t;for(c[((a<<2)+u|0)+92>>2]=h;;){if(a=Tt[s+4|0],a&4)break t;if(pt[s+4|0]=a|4,a=c[s+20>>2],a&&$t[a|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function ad(s,a,h){var u=0;t:{if(u=s+24|0,c[(u+(a<<2)|0)+20>>2]==(h|0))break t;for(c[((a<<2)+u|0)+20>>2]=h;;){if(a=Tt[s+4|0],a&4)break t;if(pt[s+4|0]=a|4,a=c[s+20>>2],a&&$t[a|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function F2(s,a,h){var u=0;t:{if(u=s+24|0,c[(u+(a<<2)|0)+56>>2]==(h|0))break t;for(c[((a<<2)+u|0)+56>>2]=h;;){if(a=Tt[s+4|0],a&4)break t;if(pt[s+4|0]=a|4,a=c[s+20>>2],a&&$t[a|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function T3(){for(var s=0,a=0,h=0;a=s<<4,h=a+5968|0,c[a+5972>>2]=h,c[a+5976>>2]=h,s=s+1|0,(s|0)!=64;);rd(48),c[1756]=16,c[1757]=0,v2(),c[1757]=c[1768],c[1768]=7024,c[1769]=198,c[1770]=0,R2(),c[1770]=c[1768],c[1768]=7076}function ci(s,a){var h=0,u=m(0);s=s+80|0,h=c[(a<<2)+4288>>2];t:{if((a&-2)==2){s=Wi(s,4,h,2143289344);break t}s=ji(s,h,2143289344)}return(s|0)==2139156720|(s|0)==2140081935|(s|0)==2141891242?s=1:(u=(Ot(2,s),Gt()),s=u==u),s}function wl(s,a){var h=0,u=m(0);s=s+80|0,h=c[(a<<2)+4304>>2];t:{if((a&-2)==2){s=Wi(s,5,h,2143289344);break t}s=ji(s,h,2143289344)}return(s|0)==2139156720|(s|0)==2140081935|(s|0)==2141891242?s=1:(u=(Ot(2,s),Gt()),s=u==u),s}function od(s,a,h,u){var y=0,b=0,k=0,S=0,P=0,z=0;return y=h>>>16|0,b=s>>>16|0,z=Ke(y,b),k=h&65535,S=s&65535,P=Ke(k,S),b=(P>>>16|0)+Ke(b,k)|0,y=(b&65535)+Ke(y,S)|0,Gr=(Ke(a,h)+z|0)+Ke(s,u)+(b>>>16)+(y>>>16)|0,P&65535|y<<16}function U2(s,a){var h=0,u=0,y=0;u=St-16|0,St=u,h=Tt[s+4|0],y=h&-17,pt[s+4|0]=y;t:{if(a){if(c[s+560>>2]!=c[s+556>>2])break t;h=y|8}else h=h&231;c[s+8>>2]=a,pt[s+4|0]=h,St=u+16|0;return}c[u>>2]=4128,li(s,u),ti(),pe()}function B2(s){var a=0,h=m(0);a=0;t:{if((c[s+24>>2]&196608)==131072)break t;i:{if(!c[s+552>>2]||(h=I[s+32>>2],h!=h&&(h=I[s+28>>2],!(h>m(0)))))break i;if(a=1,h!=m(0))break t}a=zn(s)!=m(0)}return a}function Tr(s,a,h,u,y){var b=0;if(b=St-256|0,St=b,!(y&73728|(h|0)<=(u|0))){if(u=h-u|0,h=u>>>0<256,Vr(b,a&255,h?u:256),!h)for(;pr(s,b,256),u=u-256|0,u>>>0>255;);pr(s,b,u)}St=b+256|0}function yn(s,a,h){var u=0,y=m(0);t:{if((h&-2)==2&&(u=a- -64|0,y=I[u>>2],u=c[u>>2],(u|0)==2139156720|(u|0)==2140081935|(u|0)==2141891242|y==y))break t;u=c[((c[(h<<2)+4304>>2]<<2)+a|0)+44>>2]}D2(s,u)}function bn(s,a,h){var u=0,y=m(0);t:{if((h&-2)==2&&(u=c[a+60>>2],y=I[a+60>>2],(u|0)==2139156720|(u|0)==2140081935|(u|0)==2141891242|y==y))break t;u=c[((c[(h<<2)+4288>>2]<<2)+a|0)+44>>2]}D2(s,u)}function zn(s){var a=m(0),h=m(0);if(!c[s+552>>2])return m(0);a=I[s+36>>2];t:{if(a==a||(a=m(1),pt[c[s+568>>2]+8|0]&1)||(a=m(0),h=I[s+28>>2],!(h<m(0))))break t;a=m(-h)}return a}function G2(s){var a=0,h=0,u=0;for(u=c[s>>2];;){if(h=pt[u|0],Rl(h)){u=u+1|0,c[s>>2]=u,a>>>0<=214748364?(h=h-48|0,a=Ke(a,10),a=(h|0)>(a^2147483647)?-1:h+a|0):a=-1;continue}break}return a}function Ya(s,a,h,u){var y=0;c[s+12>>2]=0,c[s+16>>2]=u;t:{if(a){if(a>>>0>=1073741824)break t;y=ht(a<<2)}return c[s>>2]=y,h=(h<<2)+y|0,c[s+8>>2]=h,c[s+12>>2]=(a<<2)+y,c[s+4>>2]=h,s}fd(),pe()}function H2(s){var a=0;return a=c[s+72>>2],c[s+72>>2]=a-1|a,a=c[s>>2],a&8?(c[s>>2]=a|32,-1):(c[s+4>>2]=0,c[s+8>>2]=0,a=c[s+44>>2],c[s+28>>2]=a,c[s+20>>2]=a,c[s+16>>2]=a+c[s+48>>2],0)}function k3(s,a,h,u,y,b){s=s|0,a=a|0,h=m(h),u=u|0,y=m(y),b=b|0;var k=0;k=St-16|0,St=k,a=c[c[a>>2]+4>>2],$t[c[c[a>>2]+8>>2]](k,a,h,u,y,b),I[s>>2]=je[k>>3],I[s+4>>2]=je[k+8>>3],St=k+16|0}function w3(){var s=0,a=0;return a=ht(4),s=ht(28),c[s+20>>2]=1065353216,c[s+24>>2]=0,c[s+12>>2]=0,c[s+16>>2]=0,c[s>>2]=0,pt[s+8|0]=0,c[s+4>>2]=1,c[1752]=c[1752]+1,c[a>>2]=s,a|0}function S3(s,a){s=s|0,a=a|0,a=c[a>>2],je[s>>3]=I[a+228>>2],je[s+8>>3]=I[a+236>>2],je[s+16>>3]=I[a+232>>2],je[s+24>>3]=I[a+240>>2],je[s+32>>3]=I[a+244>>2],je[s+40>>3]=I[a+248>>2]}function R3(s,a){s=s|0,a=a|0;var h=0,u=0;return h=St-48|0,St=h,u=c[s>>2],s=c[s+4>>2],a=(s>>1)+a|0,s&1&&(u=c[u+c[a>>2]>>2]),$t[u|0](h,a),s=Hr(ht(48),h,48),St=h+48|0,s|0}function _3(s,a,h,u){s=s|0,a=a|0,h=h|0,u=u|0;var y=0;return y=St-16|0,St=y,s=eg(Tk(c[s+60>>2],a|0,h|0,u&255,y+8|0)|0),St=y+16|0,Gr=s?-1:c[y+12>>2],(s?-1:c[y+8>>2])|0}function L3(s,a){s=s|0,a=a|0;var h=0,u=0;h=c[s>>2],s=c[h+556>>2];t:{if(c[h+560>>2]-s>>2>>>0<=a>>>0||(s=c[s+(a<<2)>>2],!s))break t;u=c[s>>2]}return u|0}function C3(s,a,h){if(s=s|0,a=a|0,h=h|0,a>>>0<3){a=1<<a,s=c[s>>2],h?a=a|c[s+12>>2]:a=c[s+12>>2]&(a^-1),c[s+12>>2]=a;return}Us(),pe()}function I3(s,a,h,u,y){s=s|0,a=a|0,h=+h,u=+u,y=y|0;var b=0;b=c[s>>2],s=c[s+4>>2],a=(s>>1)+a|0,s&1&&(b=c[b+c[a>>2]>>2]),$t[b|0](a,h,u,y)}function x3(s,a,h){s=s|0,a=a|0,h=h|0;var u=0;return u=c[s>>2],s=c[s+4>>2],a=(s>>1)+a|0,s&1&&(u=c[u+c[a>>2]>>2]),m(m($t[u|0](a,h)))}function V2(s,a,h,u){s=s|0,a=a|0,h=h|0,u=u|0;var y=0;y=c[s>>2],s=c[s+4>>2],a=(s>>1)+a|0,s&1&&(y=c[y+c[a>>2]>>2]),$t[y|0](a,h,u)}function W2(s,a,h){s=s|0,a=a|0,h=h|0;var u=0;return u=c[s>>2],s=c[s+4>>2],a=(s>>1)+a|0,s&1&&(u=c[u+c[a>>2]>>2]),$t[u|0](a,h)|0}function D3(s,a,h,u){s=s|0,a=a|0,h=h|0,u=+u;var y=0;y=c[s>>2],s=c[s+4>>2],a=(s>>1)+a|0,s&1&&(y=c[y+c[a>>2]>>2]),$t[y|0](a,h,u)}function P3(s,a,h){s=s|0,a=a|0,h=h|0;var u=0;return u=c[s>>2],s=c[s+4>>2],a=(s>>1)+a|0,s&1&&(u=c[u+c[a>>2]>>2]),+$t[u|0](a,h)}function ht(s){var a=0;s=s||1;t:{for(;;){if(a=td(s),a)break t;if(a=c[2042],a){$t[a|0]();continue}break}Us(),pe()}return a}function O3(s,a,h){s=s|0,a=a|0,h=m(h);var u=0;u=c[s>>2],s=c[s+4>>2],a=(s>>1)+a|0,s&1&&(u=c[u+c[a>>2]>>2]),$t[u|0](a,h)}function Hs(s,a,h){s=s|0,a=a|0,h=h|0;var u=0;u=c[s>>2],s=c[s+4>>2],a=(s>>1)+a|0,s&1&&(u=c[u+c[a>>2]>>2]),$t[u|0](a,h)}function En(s,a){s=s|0,a=a|0;var h=0;return h=c[s>>2],s=c[s+4>>2],a=(s>>1)+a|0,s&1&&(h=c[h+c[a>>2]>>2]),$t[h|0](a)|0}function ld(s,a){return Jr(s),(te(2)&2147483647)>>>0<=2139095040?(Jr(a),(te(2)&2147483647)>>>0>2139095040?s:m(mk(s,a))):a}function fe(s,a){return Jr(s),(te(2)&2147483647)>>>0<=2139095040?(Jr(a),(te(2)&2147483647)>>>0>2139095040?s:m(vk(s,a))):a}function j2(s,a){s=s|0,a=a|0;var h=0;return h=St-16|0,St=h,c[h+8>>2]=a,s=$t[s|0](h+8|0)|0,Ka(c[h+8>>2]),St=h+16|0,s|0}function $3(s,a,h){s=s|0,a=a|0,h=+h;var u=0;u=c[s>>2],s=c[s+4>>2],a=(s>>1)+a|0,s&1&&(u=c[u+c[a>>2]>>2]),$t[u|0](a,h)}function M3(s,a,h,u,y){return h=h|0,u=u|0,y=y|0,h&&(h|0)!=5?ng(5816,u,y)|0:ng(5672,u,y)|0}function K2(s,a){if(!s)return 0;t:{if(!((a&-128)==57216|a>>>0<=127)){c[1781]=25,s=-1;break t}pt[s|0]=a,s=1}return s}function N3(s,a){s=s|0,a=a|0;var h=0;return h=c[s>>2],s=c[s+4>>2],a=(s>>1)+a|0,s&1&&(h=c[h+c[a>>2]>>2]),+$t[h|0](a)}function z2(s,a){var h=0,u=0;h=ht(4),c[h>>2]=a,u=ht(4),c[u>>2]=a,bl(7035,s|0,7098,4714,196,h|0,7098,4718,197,u|0)}function Yn(s,a){var h=0,u=0;h=ht(4),c[h>>2]=a,u=ht(4),c[u>>2]=a,bl(7065,s|0,7098,4714,194,h|0,7098,4718,195,u|0)}function cd(s,a){var h=0;t:{if(pt[7044]&1){h=c[1760];break t}h=d2(1,4464)|0,pt[7044]=1,c[1760]=h}Ak(h|0,s|0,a|0,0)}function F3(s,a){s=s|0,a=a|0;var h=0;h=c[s+8>>2],c[s+8>>2]=a,h&&$t[c[c[h>>2]+4>>2]](h),c[c[s>>2]+20>>2]=15}function U3(s,a,h){s=s|0,a=a|0,h=h|0;var u=0,y=0;u=s,y=g2((pt[a+11|0]<0?c[a>>2]:a)|0,7036,c[h>>2])|0,c[u>>2]=y}function B3(s,a,h){s=s|0,a=a|0,h=h|0;var u=0,y=0;u=s,y=g2((pt[a+11|0]<0?c[a>>2]:a)|0,7059,c[h>>2])|0,c[u>>2]=y}function Y2(s,a){s=s|0,a=a|0;var h=0;h=c[s>>2],s=c[s+4>>2],a=(s>>1)+a|0,s&1&&(h=c[h+c[a>>2]>>2]),$t[h|0](a)}function G3(s){s=s|0;var a=m(0);return s=c[s>>2],a=I[s+36>>2],a!=a&&(a=pt[c[s+568>>2]+8|0]&1?m(1):m(0)),+a}function H3(s,a){s=s|0,a=a|0;var h=0;h=c[s+4>>2],c[s+4>>2]=a,h&&$t[c[c[h>>2]+4>>2]](h),U2(c[s>>2],14)}function V3(s){s=s|0;var a=0;a=c[s+8>>2],c[s+8>>2]=0,a&&$t[c[c[a>>2]+4>>2]](a),c[c[s>>2]+20>>2]=0}function W3(s){s=s|0;var a=0;return a=ht(12),pt[a+4|0]=0,c[a+8>>2]=c[s>>2],c[s>>2]=0,c[a>>2]=4432,a|0}function j3(s){s=s|0;var a=0;return a=ht(12),pt[a+4|0]=0,c[a+8>>2]=c[s>>2],c[s>>2]=0,c[a>>2]=4552,a|0}function K3(){var s=0;if(s=c[1768],s)for(;$t[c[s>>2]](),s=c[s+4>>2],!!s;);}function z3(s){s=s|0;var a=0;a=c[s+4>>2],c[s+4>>2]=0,a&&$t[c[c[a>>2]+4>>2]](a),U2(c[s>>2],0)}function X2(s){return s=s|0,c[s>>2]=4572,Tt[s+4|0]&&cd(c[s+8>>2],1759),Ka(c[s+8>>2]),s|0}function Z2(s){return s=s|0,c[s>>2]=4452,Tt[s+4|0]&&cd(c[s+8>>2],1759),Ka(c[s+8>>2]),s|0}function Y3(){var s=0;return s=ht(16),c[s>>2]=0,c[s+4>>2]=0,c[s+8>>2]=0,c[s+12>>2]=0,s|0}function q2(s,a,h){return ci(s,a)?Gs(s,a,h):(h=za(s,a,h),h==h&&(h=m(-h)),h)}function Q2(s,a){var h=0;h=St-16|0,St=h,s||(c[h>>2]=a,li(0,h),ti(),pe()),St=h+16|0}function J2(s){s=s|0;var a=0;s&&(a=c[s>>2],a&&Ar(a),c[1752]=c[1752]-1,Ar(s))}function X3(s,a){return s=s|0,a=a|0,a>>>0>=3&&(Us(),pe()),c[c[s>>2]+12>>2]>>>a&1}function Z3(s,a,h,u,y){return s=s|0,a=a|0,h=h|0,u=u|0,y=y|0,$t[s|0](a,h,u,y)|0}function q3(){var s=0;return s=ht(16),c[s+8>>2]=0,c[s+12>>2]=0,c[s>>2]=0,s|0}function Q3(s){s=s|0;var a=m(0);return a=I[c[s>>2]+224>>2],+(a!=a?m(zt):a)}function J3(s){return s=s|0,s=c[c[s>>2]+552>>2],s?c[s>>2]:0}function tw(s){s=s|0;var a=m(0);return a=I[c[s>>2]+32>>2],+(a==a?a:m(0))}function tg(s){var a=0;return a=b2(ht(588),s),Q2((s|0)!=0,2808),a}function ew(s,a){s=s|0,a=a|0,s=c[s>>2],c[s+16>>2]=c[s+16>>2]&-2|a}function rw(s){return s=s|0,s=c[s>>2],c[s+560>>2]-c[s+556>>2]>>2}function iw(s,a){s=s|0,a=a|0,s=c[s>>2],pt[s+8|0]=Tt[s+8|0]&254|a}function sw(s){s=s|0,s=c[c[s>>2]+8>>2],$t[c[c[s>>2]+8>>2]](s)}function nw(s,a,h){s=s|0,a=a|0,h=+h,ad(c[s>>2],a,Ti(m(h)))}function aw(s,a,h){s=s|0,a=a|0,h=+h,ad(c[s>>2],a,zi(m(h)))}function ow(s,a,h,u){return Gr=0,0}function lw(s,a,h){s=s|0,a=a|0,h=+h,N2(c[s>>2],a,Ti(m(h)))}function cw(s,a,h){s=s|0,a=a|0,h=+h,N2(c[s>>2],a,zi(m(h)))}function hw(s,a,h){s=s|0,a=a|0,h=+h,F2(c[s>>2],a,Ti(m(h)))}function dw(s,a,h){s=s|0,a=a|0,h=+h,F2(c[s>>2],a,zi(m(h)))}function uw(s,a,h){s=s|0,a=a|0,h=h|0,c[c[s>>2]+a>>2]=h}function fw(s,a){s=s|0,a=a|0,ad(c[s>>2],a,2141891242)}function hd(s,a,h){s=s|0,a=a|0,h=+h,je[c[s>>2]+a>>3]=h}function pw(s){return s=s|0,(Tt[c[s>>2]+4|0]&2)>>>1|0}function gw(s){return s=s|0,(Tt[c[s>>2]+4|0]&4)>>>2|0}function mw(s,a){s=s|0,a=a|0,c[s+4>>2]=10,c[s>>2]=a}function vw(s,a){s=s|0,a=a|0,c[s+4>>2]=13,c[s>>2]=a}function yw(s){return s=s|0,c[c[s>>2]+24>>2]>>>10&7}function bw(s){return s=s|0,c[c[s>>2]+24>>2]>>>13&7}function dd(s,a){return s=s|0,a=a|0,+je[c[s>>2]+a>>3]}function Ew(s){return s=s|0,c[c[s>>2]+24>>2]>>>18&3}function Aw(s){return s=s|0,c[c[s>>2]+24>>2]>>>20&3}function Tw(s){return s=s|0,c[c[s>>2]+24>>2]>>>22&1}function kw(s,a){return s=s|0,a=a|0,c[c[s>>2]+a>>2]}function ww(s,a){s=s|0,a=+a,Kn(c[s>>2],0,Ti(m(a)))}function Sw(s,a){s=s|0,a=+a,Kn(c[s>>2],0,zi(m(a)))}function Rw(s,a){s=s|0,a=+a,Kn(c[s>>2],1,Ti(m(a)))}function _w(s,a){s=s|0,a=+a,Kn(c[s>>2],1,zi(m(a)))}function Lw(s,a){s=s|0,a=a|0,c[s+4>>2]=7,c[s>>2]=a}function Cw(s,a){s=s|0,a=+a,Tl(c[s>>2],0,Ti(m(a)))}function Iw(s,a){s=s|0,a=+a,Tl(c[s>>2],0,zi(m(a)))}function xw(s,a){s=s|0,a=+a,Tl(c[s>>2],1,Ti(m(a)))}function Dw(s,a){s=s|0,a=+a,Tl(c[s>>2],1,zi(m(a)))}function Pw(s,a){s=s|0,a=+a,kl(c[s>>2],0,Ti(m(a)))}function Ow(s,a){s=s|0,a=+a,kl(c[s>>2],1,Ti(m(a)))}function $w(s,a){s=s|0,a=+a,kl(c[s>>2],1,zi(m(a)))}function Mw(s){return s=s|0,c[c[s>>2]+24>>2]>>>7&7}function Nw(s){return s=s|0,c[c[s>>2]+24>>2]>>>2&3}function Fw(s){return s=s|0,c[c[s>>2]+24>>2]>>>4&7}function Sl(s){s=s|0,s&&$t[c[c[s>>2]+4>>2]](s)}function Uw(s,a){s=s|0,a=+a,kl(c[s>>2],0,zi(m(a)))}function eg(s){return s?(c[1781]=s,-1):0}function Bw(s,a){s=s|0,a=+a,nd(c[s>>2],Ti(m(a)))}function Gw(s,a){s=s|0,a=+a,nd(c[s>>2],zi(m(a)))}function rg(s,a,h){return m(ge(s,a,h)+Re(s,a,h))}function Hw(s,a){return s=s|0,a=a|0,$t[s|0](a)|0}function ig(s,a,h,u){kk(s|0,a|0,8,0,h|0,-1,u|0)}function Vw(s,a){s=s|0,a=a|0,c[c[s>>2]+16>>2]=a}function Ww(s){return s=s|0,c[c[s>>2]+16>>2]&1}function jw(s){return s=s|0,Hn[c[s>>2]+26>>1]&3}function Kw(s){s=s|0,Kn(c[s>>2],0,2141891242)}function zw(s){s=s|0,Kn(c[s>>2],1,2141891242)}function Yw(s){return s=s|0,+I[c[s>>2]+228>>2]}function Xw(s){return s=s|0,+I[c[s>>2]+236>>2]}function Zw(s){return s=s|0,+I[c[s>>2]+232>>2]}function qw(s){return s=s|0,+I[c[s>>2]+240>>2]}function Qw(s){return s=s|0,+I[c[s>>2]+244>>2]}function Jw(s){return s=s|0,+I[c[s>>2]+248>>2]}function tS(s){return s=s|0,_k(c[s+60>>2])|0}function eS(s){return s=s|0,c[c[s>>2]+16>>2]}function rS(s){return s=s|0,pt[c[s>>2]+8|0]&1}function iS(s,a){s=s|0,a=a|0,sd(c[s>>2],5,a)}function sS(s,a){s=s|0,a=a|0,sd(c[s>>2],6,a)}function nS(s,a){s=s|0,a=a|0,sd(c[s>>2],7,a)}function aS(s){s=s|0,nd(c[s>>2],2141891242)}function sg(s,a){s=s|0,a=a|0,$t[c[s>>2]](a)}function oS(s){return s=s|0,O2(ht(12),s)|0}function lS(s){s=s|0,cd(c[s+8>>2],3293)}function ng(s,a,h){return C2(s,a,h,2,3)}function ag(s){return s=s|0,$t[s|0]()|0}function og(s,a){s=s|0,a=a|0,$t[s|0](a)}function cS(){return Vr(ht(48),0,48)|0}function ti(){$t[c[1490]](),fd(),pe()}function hS(){return O2(ht(12),0)|0}function ud(s){s=s|0,s&&Ar(s)}function Rl(s){return s-48>>>0<10}function dS(s){return 7032}function uS(s){return 7036}function fS(s){return 7056}function pS(s){return 7059}function gS(s){return 7062}function mS(s){return 7067}function Ci(s){return s=s|0,s|0}function lg(s){s=s|0,pt[s+4|0]=1}function vS(s){s=s|0,Ar(X2(s))}function yS(s){s=s|0,Ar(Z2(s))}function bS(s){return 0}function cg(s){pe()}function hg(){fd(),pe()}function fd(){Us(),pe()}V=Tt,Lt();var $t=H([null,M3,xk,Ok,Ci,Lw,mw,vw,Ci,Ci,Ci,Ci,Ci,Ci,k3,sw,v2,dS,Sl,s3,uS,Ci,Ci,Sl,lg,sg,j2,W3,Hk,U3,fS,Sl,Y2,pS,Ci,Ci,Sl,lg,sg,j2,j3,B3,gS,J2,ag,w3,og,J2,C3,V2,Bk,O3,ew,Hs,Vw,Hs,iw,X3,W2,Ww,En,eS,En,rS,cS,ud,Y3,ud,q3,ud,dd,hd,kw,uw,mS,S2,ag,hS,Hw,oS,og,S2,Nk,Y2,Pk,Hs,d3,Hs,hw,D3,dw,iS,sS,nS,v3,h3,m3,nw,aw,fw,l3,c3,f3,$3,Bw,Gw,aS,p3,g3,ww,Sw,Kw,Rw,_w,zw,Cw,Iw,xw,Dw,Pw,Uw,Ow,$w,u3,n3,lw,cw,a3,jw,En,jk,b3,Mw,yw,bw,Nw,Ew,Fw,Kk,r3,A3,tw,N3,G3,Yk,Xk,Zk,qk,Qk,zk,Q3,o3,P3,Aw,Tw,Wk,i3,x3,$k,V2,Mk,Hs,rw,En,J3,En,L3,W2,pw,En,y3,Hs,H3,Hs,z3,F3,Hs,V3,E3,gw,En,Dk,I3,Yw,Xw,Zw,qw,Qw,Jw,S3,R3,Jk,t3,e3,dd,hd,dd,hd,R2,Z2,yS,Gk,cg,hg,X2,vS,lS,cg,tS,Fk,_3,bS,ow,Vk,hg]);function dg(){return Br.byteLength/65536|0}function ES(s){s=s|0;var a=dg()|0,h=a+s|0;if(a<h&&h<65536){var u=new ArrayBuffer(Ke(h,65536)),y=new Int8Array(u);y.set(pt),pt=new Int8Array(u),Vi=new Int16Array(u),c=new Int32Array(u),Tt=new Uint8Array(u),Hn=new Uint16Array(u),c2=new Uint32Array(u),I=new Float32Array(u),je=new Float64Array(u),Br=u,oi.buffer=Br,V=Tt}return a}return{E:T3,F:Uk,G:K3,H:td,I:$t,J:Ar,K:Z3}}return yl(L)}(_)}var C=Error,D={};E=[],typeof D!="object"&&It("no native wasm support detected");var M,U=!1;function x(_,L,H){H=L+H;for(var V="";!(L>=H);){var rt=_[L++];if(!rt)break;if(rt&128){var yt=_[L++]&63;if((rt&224)==192)V+=String.fromCharCode((rt&31)<<6|yt);else{var lt=_[L++]&63;rt=(rt&240)==224?(rt&15)<<12|yt<<6|lt:(rt&7)<<18|yt<<12|lt<<6|_[L++]&63,65536>rt?V+=String.fromCharCode(rt):(rt-=65536,V+=String.fromCharCode(55296|rt>>10,56320|rt&1023))}}else V+=String.fromCharCode(rt)}return V}var O,K,B,at,st,J,kt,ft,wt;function Pt(_){O=_,o.HEAP8=K=new Int8Array(_),o.HEAP16=at=new Int16Array(_),o.HEAP32=J=new Int32Array(_),o.HEAPU8=B=new Uint8Array(_),o.HEAPU16=st=new Uint16Array(_),o.HEAPU32=kt=new Uint32Array(_),o.HEAPF32=ft=new Float32Array(_),o.HEAPF64=wt=new Float64Array(_)}var F=o.INITIAL_MEMORY||16777216;o.wasmMemory?M=o.wasmMemory:M=new A,M&&(O=M.buffer),F=O.byteLength,Pt(O);var j,bt=[],N=[],G=[];function Z(){var _=o.preRun.shift();bt.unshift(_)}var gt=0,vt=null;function It(_){throw o.onAbort&&o.onAbort(_),_="Aborted("+_+")",v(_),U=!0,_=new C(_+". Build with -sASSERTIONS for more info."),d(_),_}function Bt(_){return _.startsWith("data:application/octet-stream;base64,")}var Xt;if(Xt="<<< WASM_BINARY_FILE >>>",!Bt(Xt)){var me=Xt;Xt=o.locateFile?o.locateFile(me,p):p+me}function be(_){var L=Xt;try{try{if(L==Xt&&E)new Uint8Array(E);else{if(Bt(L)){try{var H=fk(L.slice(37)),V=new Uint8Array(H.length);for(L=0;L<H.length;++L)V[L]=H.charCodeAt(L);var rt=V}catch{throw Error("Converting base64 string to bytes failed.")}var yt=rt}else yt=void 0;if(!yt)throw"sync fetching of the wasm failed: you can preload it to Module['wasmBinary'] manually, or emcc.py will do that for you when generating HTML (but not JS)"}}catch(xt){It(xt)}var lt=new T,Lt=new w(_)}catch(xt){throw _=xt.toString(),v("failed to compile wasm module: "+_),(_.includes("imported Memory")||_.includes("memory import"))&&v("Memory size incompatibility issues may be due to changing INITIAL_MEMORY at runtime to something too large. Use ALLOW_MEMORY_GROWTH to allow any size memory (and also make sure not to set INITIAL_MEMORY at runtime to something smaller than it was at compile time)."),xt}return[Lt,lt]}function Ee(_){for(;0<_.length;)_.shift()(o)}function Ye(_){if(_===void 0)return"_unknown";_=_.replace(/[^a-zA-Z0-9_]/g,"$");var L=_.charCodeAt(0);return 48<=L&&57>=L?"_"+_:_}function Le(_,L){return _=Ye(_),function(){return L.apply(this,arguments)}}var Wt=[{},{value:void 0},{value:null},{value:!0},{value:!1}],se=[];function le(_){var L=Error,H=Le(_,function(V){this.name=_,this.message=V,V=Error(V).stack,V!==void 0&&(this.stack=this.toString()+`
90
+ `+V.replace(/^Error(:[^\n]*)?\n/,""))});return H.prototype=Object.create(L.prototype),H.prototype.constructor=H,H.prototype.toString=function(){return this.message===void 0?this.name:this.name+": "+this.message},H}var De=void 0;function Nt(_){throw new De(_)}var ne=_=>(_||Nt("Cannot use deleted val. handle = "+_),Wt[_].value),ee=_=>{switch(_){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:var L=se.length?se.pop():Wt.length;return Wt[L]={fa:1,value:_},L}},$e=void 0,Me=void 0;function ce(_){for(var L="";B[_];)L+=Me[B[_++]];return L}var Ce=[];function ie(){for(;Ce.length;){var _=Ce.pop();_.L.Z=!1,_.delete()}}var Ie=void 0,We={};function Pr(_,L){for(L===void 0&&Nt("ptr should not be undefined");_.P;)L=_.aa(L),_=_.P;return L}var Be={};function br(_){_=gk(_);var L=ce(_);return Fs(_),L}function cs(_,L){var H=Be[_];return H===void 0&&Nt(L+" has unknown type "+br(_)),H}function fr(){}var _i=!1;function Os(_){--_.count.value,_.count.value===0&&(_.S?_.T.V(_.S):_.O.M.V(_.N))}function $s(_,L,H){return L===H?_:H.P===void 0?null:(_=$s(_,L,H.P),_===null?null:H.ma(_))}var ai={};function ct(_,L){return L=Pr(_,L),We[L]}var Ht=void 0;function Zt(_){throw new Ht(_)}function Ae(_,L){return L.O&&L.N||Zt("makeClassHandle requires ptr and ptrType"),!!L.T!=!!L.S&&Zt("Both smartPtrType and smartPtr must be specified"),L.count={value:1},de(Object.create(_,{L:{value:L}}))}function de(_){return typeof FinalizationRegistry>"u"?(de=L=>L,_):(_i=new FinalizationRegistry(L=>{Os(L.L)}),de=L=>{var H=L.L;return H.S&&_i.register(L,{L:H},L),L},fr=L=>{_i.unregister(L)},de(_))}var lr={};function Or(_){for(;_.length;){var L=_.pop();_.pop()(L)}}function vi(_){return this.fromWireType(J[_>>2])}var hs={},yi={};function bi(_,L,H){function V(Lt){Lt=H(Lt),Lt.length!==_.length&&Zt("Mismatched type converter count");for(var xt=0;xt<_.length;++xt)$r(_[xt],Lt[xt])}_.forEach(function(Lt){yi[Lt]=L});var rt=Array(L.length),yt=[],lt=0;L.forEach((Lt,xt)=>{Be.hasOwnProperty(Lt)?rt[xt]=Be[Lt]:(yt.push(Lt),hs.hasOwnProperty(Lt)||(hs[Lt]=[]),hs[Lt].push(()=>{rt[xt]=Be[Lt],++lt,lt===yt.length&&V(rt)}))}),yt.length===0&&V(rt)}function Ms(_){switch(_){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: "+_)}}function $r(_,L,H={}){if(!("argPackAdvance"in L))throw new TypeError("registerType registeredInstance requires argPackAdvance");var V=L.name;if(_||Nt('type "'+V+'" must have a positive integer typeid pointer'),Be.hasOwnProperty(_)){if(H.ta)return;Nt("Cannot register type '"+V+"' twice")}Be[_]=L,delete yi[_],hs.hasOwnProperty(_)&&(L=hs[_],delete hs[_],L.forEach(rt=>rt()))}function ja(_){Nt(_.L.O.M.name+" instance already deleted")}function Ei(){}function Ns(_,L,H){if(_[L].R===void 0){var V=_[L];_[L]=function(){return _[L].R.hasOwnProperty(arguments.length)||Nt("Function '"+H+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+_[L].R+")!"),_[L].R[arguments.length].apply(this,arguments)},_[L].R=[],_[L].R[V.Y]=V}}function YT(_,L){o.hasOwnProperty(_)?(Nt("Cannot register public name '"+_+"' twice"),Ns(o,_,_),o.hasOwnProperty(void 0)&&Nt("Cannot register multiple overloads of a function with the same number of arguments (undefined)!"),o[_].R[void 0]=L):o[_]=L}function XT(_,L,H,V,rt,yt,lt,Lt){this.name=_,this.constructor=L,this.W=H,this.V=V,this.P=rt,this.oa=yt,this.aa=lt,this.ma=Lt,this.ia=[]}function Kh(_,L,H){for(;L!==H;)L.aa||Nt("Expected null or instance of "+H.name+", got an instance of "+L.name),_=L.aa(_),L=L.P;return _}function ZT(_,L){return L===null?(this.da&&Nt("null is not a valid "+this.name),0):(L.L||Nt('Cannot pass "'+Zh(L)+'" as a '+this.name),L.L.N||Nt("Cannot pass deleted object as a pointer of type "+this.name),Kh(L.L.N,L.L.O.M,this.M))}function qT(_,L){if(L===null){if(this.da&&Nt("null is not a valid "+this.name),this.ca){var H=this.ea();return _!==null&&_.push(this.V,H),H}return 0}if(L.L||Nt('Cannot pass "'+Zh(L)+'" as a '+this.name),L.L.N||Nt("Cannot pass deleted object as a pointer of type "+this.name),!this.ba&&L.L.O.ba&&Nt("Cannot convert argument of type "+(L.L.T?L.L.T.name:L.L.O.name)+" to parameter type "+this.name),H=Kh(L.L.N,L.L.O.M,this.M),this.ca)switch(L.L.S===void 0&&Nt("Passing raw pointer to smart pointer is illegal"),this.Aa){case 0:L.L.T===this?H=L.L.S:Nt("Cannot convert argument of type "+(L.L.T?L.L.T.name:L.L.O.name)+" to parameter type "+this.name);break;case 1:H=L.L.S;break;case 2:if(L.L.T===this)H=L.L.S;else{var V=L.clone();H=this.wa(H,ee(function(){V.delete()})),_!==null&&_.push(this.V,H)}break;default:Nt("Unsupporting sharing policy")}return H}function QT(_,L){return L===null?(this.da&&Nt("null is not a valid "+this.name),0):(L.L||Nt('Cannot pass "'+Zh(L)+'" as a '+this.name),L.L.N||Nt("Cannot pass deleted object as a pointer of type "+this.name),L.L.O.ba&&Nt("Cannot convert argument of type "+L.L.O.name+" to parameter type "+this.name),Kh(L.L.N,L.L.O.M,this.M))}function ds(_,L,H,V){this.name=_,this.M=L,this.da=H,this.ba=V,this.ca=!1,this.V=this.wa=this.ea=this.ja=this.Aa=this.va=void 0,L.P!==void 0?this.toWireType=qT:(this.toWireType=V?ZT:QT,this.U=null)}function JT(_,L){o.hasOwnProperty(_)||Zt("Replacing nonexistant public symbol"),o[_]=L,o[_].Y=void 0}function tk(_,L){var H=[];return function(){if(H.length=0,Object.assign(H,arguments),_.includes("j")){var V=o["dynCall_"+_];V=H&&H.length?V.apply(null,[L].concat(H)):V.call(null,L)}else V=j.get(L).apply(null,H);return V}}function Li(_,L){_=ce(_);var H=_.includes("j")?tk(_,L):j.get(L);return typeof H!="function"&&Nt("unknown function pointer with signature "+_+": "+L),H}var i2=void 0;function pl(_,L){function H(yt){rt[yt]||Be[yt]||(yi[yt]?yi[yt].forEach(H):(V.push(yt),rt[yt]=!0))}var V=[],rt={};throw L.forEach(H),new i2(_+": "+V.map(br).join([", "]))}function zh(_,L,H,V,rt){var yt=L.length;2>yt&&Nt("argTypes array size mismatch! Must at least get return value and 'this' types!");var lt=L[1]!==null&&H!==null,Lt=!1;for(H=1;H<L.length;++H)if(L[H]!==null&&L[H].U===void 0){Lt=!0;break}var xt=L[0].name!=="void",Dt=yt-2,Ut=Array(Dt),Kt=[],te=[];return function(){if(arguments.length!==Dt&&Nt("function "+_+" called with "+arguments.length+" arguments, expected "+Dt+" args!"),te.length=0,Kt.length=lt?2:1,Kt[0]=rt,lt){var Ot=L[1].toWireType(te,this);Kt[1]=Ot}for(var ke=0;ke<Dt;++ke)Ut[ke]=L[ke+2].toWireType(te,arguments[ke]),Kt.push(Ut[ke]);if(ke=V.apply(null,Kt),Lt)Or(te);else for(var Er=lt?1:2;Er<L.length;Er++){var pe=Er===1?Ot:Ut[Er-2];L[Er].U!==null&&L[Er].U(pe)}return Ot=xt?L[0].fromWireType(ke):void 0,Ot}}function Yh(_,L){for(var H=[],V=0;V<_;V++)H.push(kt[L+4*V>>2]);return H}function Xh(_){4<_&&--Wt[_].fa===0&&(Wt[_]=void 0,se.push(_))}function Zh(_){if(_===null)return"null";var L=typeof _;return L==="object"||L==="array"||L==="function"?_.toString():""+_}function ek(_,L){switch(L){case 2:return function(H){return this.fromWireType(ft[H>>2])};case 3:return function(H){return this.fromWireType(wt[H>>3])};default:throw new TypeError("Unknown float type: "+_)}}function rk(_,L,H){switch(L){case 0:return H?function(V){return K[V]}:function(V){return B[V]};case 1:return H?function(V){return at[V>>1]}:function(V){return st[V>>1]};case 2:return H?function(V){return J[V>>2]}:function(V){return kt[V>>2]};default:throw new TypeError("Unknown integer type: "+_)}}function ik(_,L){for(var H="",V=0;!(V>=L/2);++V){var rt=at[_+2*V>>1];if(rt==0)break;H+=String.fromCharCode(rt)}return H}function sk(_,L,H){if(H===void 0&&(H=2147483647),2>H)return 0;H-=2;var V=L;H=H<2*_.length?H/2:_.length;for(var rt=0;rt<H;++rt)at[L>>1]=_.charCodeAt(rt),L+=2;return at[L>>1]=0,L-V}function nk(_){return 2*_.length}function ak(_,L){for(var H=0,V="";!(H>=L/4);){var rt=J[_+4*H>>2];if(rt==0)break;++H,65536<=rt?(rt-=65536,V+=String.fromCharCode(55296|rt>>10,56320|rt&1023)):V+=String.fromCharCode(rt)}return V}function ok(_,L,H){if(H===void 0&&(H=2147483647),4>H)return 0;var V=L;H=V+H-4;for(var rt=0;rt<_.length;++rt){var yt=_.charCodeAt(rt);if(55296<=yt&&57343>=yt){var lt=_.charCodeAt(++rt);yt=65536+((yt&1023)<<10)|lt&1023}if(J[L>>2]=yt,L+=4,L+4>H)break}return J[L>>2]=0,L-V}function lk(_){for(var L=0,H=0;H<_.length;++H){var V=_.charCodeAt(H);55296<=V&&57343>=V&&++H,L+=4}return L}var ck={};function s2(_){var L=ck[_];return L===void 0?ce(_):L}var gl=[];function hk(_){var L=gl.length;return gl.push(_),L}function dk(_,L){for(var H=Array(_),V=0;V<_;++V)H[V]=cs(kt[L+4*V>>2],"parameter "+V);return H}var n2=[],uk=[null,[],[]];De=o.BindingError=le("BindingError"),o.count_emval_handles=function(){for(var _=0,L=5;L<Wt.length;++L)Wt[L]!==void 0&&++_;return _},o.get_first_emval=function(){for(var _=5;_<Wt.length;++_)if(Wt[_]!==void 0)return Wt[_];return null},$e=o.PureVirtualError=le("PureVirtualError");for(var a2=Array(256),ml=0;256>ml;++ml)a2[ml]=String.fromCharCode(ml);Me=a2,o.getInheritedInstanceCount=function(){return Object.keys(We).length},o.getLiveInheritedInstances=function(){var _=[],L;for(L in We)We.hasOwnProperty(L)&&_.push(We[L]);return _},o.flushPendingDeletes=ie,o.setDelayFunction=function(_){Ie=_,Ce.length&&Ie&&Ie(ie)},Ht=o.InternalError=le("InternalError"),Ei.prototype.isAliasOf=function(_){if(!(this instanceof Ei&&_ instanceof Ei))return!1;var L=this.L.O.M,H=this.L.N,V=_.L.O.M;for(_=_.L.N;L.P;)H=L.aa(H),L=L.P;for(;V.P;)_=V.aa(_),V=V.P;return L===V&&H===_},Ei.prototype.clone=function(){if(this.L.N||ja(this),this.L.$)return this.L.count.value+=1,this;var _=de,L=Object,H=L.create,V=Object.getPrototypeOf(this),rt=this.L;return _=_(H.call(L,V,{L:{value:{count:rt.count,Z:rt.Z,$:rt.$,N:rt.N,O:rt.O,S:rt.S,T:rt.T}}})),_.L.count.value+=1,_.L.Z=!1,_},Ei.prototype.delete=function(){this.L.N||ja(this),this.L.Z&&!this.L.$&&Nt("Object already scheduled for deletion"),fr(this),Os(this.L),this.L.$||(this.L.S=void 0,this.L.N=void 0)},Ei.prototype.isDeleted=function(){return!this.L.N},Ei.prototype.deleteLater=function(){return this.L.N||ja(this),this.L.Z&&!this.L.$&&Nt("Object already scheduled for deletion"),Ce.push(this),Ce.length===1&&Ie&&Ie(ie),this.L.Z=!0,this},ds.prototype.pa=function(_){return this.ja&&(_=this.ja(_)),_},ds.prototype.ga=function(_){this.V&&this.V(_)},ds.prototype.argPackAdvance=8,ds.prototype.readValueFromPointer=vi,ds.prototype.deleteObject=function(_){_!==null&&_.delete()},ds.prototype.fromWireType=function(_){function L(){return this.ca?Ae(this.M.W,{O:this.va,N:H,T:this,S:_}):Ae(this.M.W,{O:this,N:_})}var H=this.pa(_);if(!H)return this.ga(_),null;var V=ct(this.M,H);if(V!==void 0)return V.L.count.value===0?(V.L.N=H,V.L.S=_,V.clone()):(V=V.clone(),this.ga(_),V);if(V=this.M.oa(H),V=ai[V],!V)return L.call(this);V=this.ba?V.ka:V.pointerType;var rt=$s(H,this.M,V.M);return rt===null?L.call(this):this.ca?Ae(V.M.W,{O:V,N:rt,T:this,S:_}):Ae(V.M.W,{O:V,N:rt})},i2=o.UnboundTypeError=le("UnboundTypeError");var fk=typeof atob=="function"?atob:function(_){var L="",H=0;_=_.replace(/[^A-Za-z0-9\+\/=]/g,"");do{var V="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(_.charAt(H++)),rt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(_.charAt(H++)),yt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(_.charAt(H++)),lt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(_.charAt(H++));V=V<<2|rt>>4,rt=(rt&15)<<4|yt>>2;var Lt=(yt&3)<<6|lt;L+=String.fromCharCode(V),yt!==64&&(L+=String.fromCharCode(rt)),lt!==64&&(L+=String.fromCharCode(Lt))}while(H<_.length);return L},pk={q:function(_,L,H){_=ce(_),L=cs(L,"wrapper"),H=ne(H);var V=[].slice,rt=L.M,yt=rt.W,lt=rt.P.W,Lt=rt.P.constructor;_=Le(_,function(){rt.P.ia.forEach((function(Dt){if(this[Dt]===lt[Dt])throw new $e("Pure virtual function "+Dt+" must be implemented in JavaScript")}).bind(this)),Object.defineProperty(this,"__parent",{value:yt}),this.__construct.apply(this,V.call(arguments))}),yt.__construct=function(){this===yt&&Nt("Pass correct 'this' to __construct");var Dt=Lt.implement.apply(void 0,[this].concat(V.call(arguments)));fr(Dt);var Ut=Dt.L;Dt.notifyOnDestruction(),Ut.$=!0,Object.defineProperties(this,{L:{value:Ut}}),de(this),Dt=Ut.N,Dt=Pr(rt,Dt),We.hasOwnProperty(Dt)?Nt("Tried to register registered instance: "+Dt):We[Dt]=this},yt.__destruct=function(){this===yt&&Nt("Pass correct 'this' to __destruct"),fr(this);var Dt=this.L.N;Dt=Pr(rt,Dt),We.hasOwnProperty(Dt)?delete We[Dt]:Nt("Tried to unregister unregistered instance: "+Dt)},_.prototype=Object.create(yt);for(var xt in H)_.prototype[xt]=H[xt];return ee(_)},k:function(_){var L=lr[_];delete lr[_];var H=L.ea,V=L.V,rt=L.ha,yt=rt.map(lt=>lt.sa).concat(rt.map(lt=>lt.ya));bi([_],yt,lt=>{var Lt={};return rt.forEach((xt,Dt)=>{var Ut=lt[Dt],Kt=xt.qa,te=xt.ra,Ot=lt[Dt+rt.length],ke=xt.xa,Er=xt.za;Lt[xt.na]={read:pe=>Ut.fromWireType(Kt(te,pe)),write:(pe,Jr)=>{var Gt=[];ke(Er,pe,Ot.toWireType(Gt,Jr)),Or(Gt)}}}),[{name:L.name,fromWireType:function(xt){var Dt={},Ut;for(Ut in Lt)Dt[Ut]=Lt[Ut].read(xt);return V(xt),Dt},toWireType:function(xt,Dt){for(var Ut in Lt)if(!(Ut in Dt))throw new TypeError('Missing field: "'+Ut+'"');var Kt=H();for(Ut in Lt)Lt[Ut].write(Kt,Dt[Ut]);return xt!==null&&xt.push(V,Kt),Kt},argPackAdvance:8,readValueFromPointer:vi,U:V}]})},w:function(){},C:function(_,L,H,V,rt){var yt=Ms(H);L=ce(L),$r(_,{name:L,fromWireType:function(lt){return!!lt},toWireType:function(lt,Lt){return Lt?V:rt},argPackAdvance:8,readValueFromPointer:function(lt){if(H===1)var Lt=K;else if(H===2)Lt=at;else if(H===4)Lt=J;else throw new TypeError("Unknown boolean type size: "+L);return this.fromWireType(Lt[lt>>yt])},U:null})},g:function(_,L,H,V,rt,yt,lt,Lt,xt,Dt,Ut,Kt,te){Ut=ce(Ut),yt=Li(rt,yt),Lt&&(Lt=Li(lt,Lt)),Dt&&(Dt=Li(xt,Dt)),te=Li(Kt,te);var Ot=Ye(Ut);YT(Ot,function(){pl("Cannot construct "+Ut+" due to unbound types",[V])}),bi([_,L,H],V?[V]:[],function(ke){if(ke=ke[0],V)var Er=ke.M,pe=Er.W;else pe=Ei.prototype;ke=Le(Ot,function(){if(Object.getPrototypeOf(this)!==Jr)throw new De("Use 'new' to construct "+Ut);if(Gt.X===void 0)throw new De(Ut+" has no accessible constructor");var nr=Gt.X[arguments.length];if(nr===void 0)throw new De("Tried to invoke ctor of "+Ut+" with invalid number of parameters ("+arguments.length+") - expected ("+Object.keys(Gt.X).toString()+") parameters instead!");return nr.apply(this,arguments)});var Jr=Object.create(pe,{constructor:{value:ke}});ke.prototype=Jr;var Gt=new XT(Ut,ke,Jr,te,Er,yt,Lt,Dt);Er=new ds(Ut,Gt,!0,!1),pe=new ds(Ut+"*",Gt,!1,!1);var yl=new ds(Ut+" const*",Gt,!1,!0);return ai[_]={pointerType:pe,ka:yl},JT(Ot,ke),[Er,pe,yl]})},d:function(_,L,H,V,rt,yt,lt){var Lt=Yh(H,V);L=ce(L),yt=Li(rt,yt),bi([],[_],function(xt){function Dt(){pl("Cannot call "+Ut+" due to unbound types",Lt)}xt=xt[0];var Ut=xt.name+"."+L;L.startsWith("@@")&&(L=Symbol[L.substring(2)]);var Kt=xt.M.constructor;return Kt[L]===void 0?(Dt.Y=H-1,Kt[L]=Dt):(Ns(Kt,L,Ut),Kt[L].R[H-1]=Dt),bi([],Lt,function(te){return te=zh(Ut,[te[0],null].concat(te.slice(1)),null,yt,lt),Kt[L].R===void 0?(te.Y=H-1,Kt[L]=te):Kt[L].R[H-1]=te,[]}),[]})},p:function(_,L,H,V,rt,yt){0<L||It();var lt=Yh(L,H);rt=Li(V,rt),bi([],[_],function(Lt){Lt=Lt[0];var xt="constructor "+Lt.name;if(Lt.M.X===void 0&&(Lt.M.X=[]),Lt.M.X[L-1]!==void 0)throw new De("Cannot register multiple constructors with identical number of parameters ("+(L-1)+") for class '"+Lt.name+"'! Overload resolution is currently only performed using the parameter count, not actual type info!");return Lt.M.X[L-1]=()=>{pl("Cannot construct "+Lt.name+" due to unbound types",lt)},bi([],lt,function(Dt){return Dt.splice(1,0,null),Lt.M.X[L-1]=zh(xt,Dt,null,rt,yt),[]}),[]})},b:function(_,L,H,V,rt,yt,lt,Lt){var xt=Yh(H,V);L=ce(L),yt=Li(rt,yt),bi([],[_],function(Dt){function Ut(){pl("Cannot call "+Kt+" due to unbound types",xt)}Dt=Dt[0];var Kt=Dt.name+"."+L;L.startsWith("@@")&&(L=Symbol[L.substring(2)]),Lt&&Dt.M.ia.push(L);var te=Dt.M.W,Ot=te[L];return Ot===void 0||Ot.R===void 0&&Ot.className!==Dt.name&&Ot.Y===H-2?(Ut.Y=H-2,Ut.className=Dt.name,te[L]=Ut):(Ns(te,L,Kt),te[L].R[H-2]=Ut),bi([],xt,function(ke){return ke=zh(Kt,ke,Dt,yt,lt),te[L].R===void 0?(ke.Y=H-2,te[L]=ke):te[L].R[H-2]=ke,[]}),[]})},B:function(_,L){L=ce(L),$r(_,{name:L,fromWireType:function(H){var V=ne(H);return Xh(H),V},toWireType:function(H,V){return ee(V)},argPackAdvance:8,readValueFromPointer:vi,U:null})},n:function(_,L,H){H=Ms(H),L=ce(L),$r(_,{name:L,fromWireType:function(V){return V},toWireType:function(V,rt){return rt},argPackAdvance:8,readValueFromPointer:ek(L,H),U:null})},e:function(_,L,H,V,rt){L=ce(L),rt===-1&&(rt=4294967295),rt=Ms(H);var yt=Lt=>Lt;if(V===0){var lt=32-8*H;yt=Lt=>Lt<<lt>>>lt}H=L.includes("unsigned")?function(Lt,xt){return xt>>>0}:function(Lt,xt){return xt},$r(_,{name:L,fromWireType:yt,toWireType:H,argPackAdvance:8,readValueFromPointer:rk(L,rt,V!==0),U:null})},c:function(_,L,H){function V(yt){yt>>=2;var lt=kt;return new rt(O,lt[yt+1],lt[yt])}var rt=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][L];H=ce(H),$r(_,{name:H,fromWireType:V,argPackAdvance:8,readValueFromPointer:V},{ta:!0})},o:function(_,L){L=ce(L);var H=L==="std::string";$r(_,{name:L,fromWireType:function(V){var rt=kt[V>>2],yt=V+4;if(H)for(var lt=yt,Lt=0;Lt<=rt;++Lt){var xt=yt+Lt;if(Lt==rt||B[xt]==0){if(lt=lt?x(B,lt,xt-lt):"",Dt===void 0)var Dt=lt;else Dt+=String.fromCharCode(0),Dt+=lt;lt=xt+1}}else{for(Dt=Array(rt),Lt=0;Lt<rt;++Lt)Dt[Lt]=String.fromCharCode(B[yt+Lt]);Dt=Dt.join("")}return Fs(V),Dt},toWireType:function(V,rt){rt instanceof ArrayBuffer&&(rt=new Uint8Array(rt));var yt,lt=typeof rt=="string";if(lt||rt instanceof Uint8Array||rt instanceof Uint8ClampedArray||rt instanceof Int8Array||Nt("Cannot pass non-string to std::string"),H&&lt){var Lt=0;for(yt=0;yt<rt.length;++yt){var xt=rt.charCodeAt(yt);127>=xt?Lt++:2047>=xt?Lt+=2:55296<=xt&&57343>=xt?(Lt+=4,++yt):Lt+=3}yt=Lt}else yt=rt.length;if(Lt=o2(4+yt+1),xt=Lt+4,kt[Lt>>2]=yt,H&&lt){if(lt=xt,xt=yt+1,yt=B,0<xt){xt=lt+xt-1;for(var Dt=0;Dt<rt.length;++Dt){var Ut=rt.charCodeAt(Dt);if(55296<=Ut&&57343>=Ut){var Kt=rt.charCodeAt(++Dt);Ut=65536+((Ut&1023)<<10)|Kt&1023}if(127>=Ut){if(lt>=xt)break;yt[lt++]=Ut}else{if(2047>=Ut){if(lt+1>=xt)break;yt[lt++]=192|Ut>>6}else{if(65535>=Ut){if(lt+2>=xt)break;yt[lt++]=224|Ut>>12}else{if(lt+3>=xt)break;yt[lt++]=240|Ut>>18,yt[lt++]=128|Ut>>12&63}yt[lt++]=128|Ut>>6&63}yt[lt++]=128|Ut&63}}yt[lt]=0}}else if(lt)for(lt=0;lt<yt;++lt)Dt=rt.charCodeAt(lt),255<Dt&&(Fs(xt),Nt("String has UTF-16 code units that do not fit in 8 bits")),B[xt+lt]=Dt;else for(lt=0;lt<yt;++lt)B[xt+lt]=rt[lt];return V!==null&&V.push(Fs,Lt),Lt},argPackAdvance:8,readValueFromPointer:vi,U:function(V){Fs(V)}})},j:function(_,L,H){if(H=ce(H),L===2)var V=ik,rt=sk,yt=nk,lt=()=>st,Lt=1;else L===4&&(V=ak,rt=ok,yt=lk,lt=()=>kt,Lt=2);$r(_,{name:H,fromWireType:function(xt){for(var Dt=kt[xt>>2],Ut=lt(),Kt,te=xt+4,Ot=0;Ot<=Dt;++Ot){var ke=xt+4+Ot*L;(Ot==Dt||Ut[ke>>Lt]==0)&&(te=V(te,ke-te),Kt===void 0?Kt=te:(Kt+=String.fromCharCode(0),Kt+=te),te=ke+L)}return Fs(xt),Kt},toWireType:function(xt,Dt){typeof Dt!="string"&&Nt("Cannot pass non-string to C++ string type "+H);var Ut=yt(Dt),Kt=o2(4+Ut+L);return kt[Kt>>2]=Ut>>Lt,rt(Dt,Kt+4,Ut+L),xt!==null&&xt.push(Fs,Kt),Kt},argPackAdvance:8,readValueFromPointer:vi,U:function(xt){Fs(xt)}})},l:function(_,L,H,V,rt,yt){lr[_]={name:ce(L),ea:Li(H,V),V:Li(rt,yt),ha:[]}},i:function(_,L,H,V,rt,yt,lt,Lt,xt,Dt){lr[_].ha.push({na:ce(L),sa:H,qa:Li(V,rt),ra:yt,ya:lt,xa:Li(Lt,xt),za:Dt})},D:function(_,L){L=ce(L),$r(_,{ua:!0,name:L,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},t:function(_,L,H,V,rt){_=gl[_],L=ne(L),H=s2(H);var yt=[];return kt[V>>2]=ee(yt),_(L,H,yt,rt)},u:function(_,L,H,V){_=gl[_],L=ne(L),H=s2(H),_(L,H,null,V)},h:Xh,m:function(_,L){var H=dk(_,L),V=H[0];L=V.name+"_$"+H.slice(1).map(function(lt){return lt.name}).join("_")+"$";var rt=n2[L];if(rt!==void 0)return rt;var yt=Array(_-1);return rt=hk((lt,Lt,xt,Dt)=>{for(var Ut=0,Kt=0;Kt<_-1;++Kt)yt[Kt]=H[Kt+1].readValueFromPointer(Dt+Ut),Ut+=H[Kt+1].argPackAdvance;for(lt=lt[Lt].apply(lt,yt),Kt=0;Kt<_-1;++Kt)H[Kt+1].la&&H[Kt+1].la(yt[Kt]);if(!V.ua)return V.toWireType(xt,lt)}),n2[L]=rt},r:function(_){4<_&&(Wt[_].fa+=1)},s:function(_){var L=ne(_);Or(L),Xh(_)},f:function(){It("")},y:function(_,L,H){B.copyWithin(_,L,L+H)},x:function(_){var L=B.length;if(_>>>=0,2147483648<_)return!1;for(var H=1;4>=H;H*=2){var V=L*(1+.2/H);V=Math.min(V,_+100663296);var rt=Math;V=Math.max(_,V),rt=rt.min.call(rt,2147483648,V+(65536-V%65536)%65536);t:{try{M.grow(rt-O.byteLength+65535>>>16),Pt(M.buffer);var yt=1;break t}catch{}yt=void 0}if(yt)return!0}return!1},A:function(){return 52},v:function(){return 70},z:function(_,L,H,V){for(var rt=0,yt=0;yt<H;yt++){var lt=kt[L>>2],Lt=kt[L+4>>2];L+=8;for(var xt=0;xt<Lt;xt++){var Dt=B[lt+xt],Ut=uk[_];Dt===0||Dt===10?((_===1?g:v)(x(Ut,0)),Ut.length=0):Ut.push(Dt)}rt+=Lt}return kt[V>>2]=rt,0},a:M},Gn=function(){function _(H){o.asm=H.exports,j=o.asm.I,N.unshift(o.asm.E),gt--,o.monitorRunDependencies&&o.monitorRunDependencies(gt),gt==0&&vt&&(H=vt,vt=null,H())}var L={a:pk};if(gt++,o.monitorRunDependencies&&o.monitorRunDependencies(gt),o.instantiateWasm)try{return o.instantiateWasm(L,_)}catch(H){v("Module.instantiateWasm callback failed with error: "+H),d(H)}return L=be(L),_(L[0]),o.asm}();o.___wasm_call_ctors=Gn.E;var gk=o.___getTypeName=Gn.F;o.__embind_initialize_bindings=Gn.G;var o2=o._malloc=Gn.H,Fs=o._free=Gn.J;o.dynCall_jiji=Gn.K;var vl;vt=function _(){vl||l2(),vl||(vt=_)};function l2(){function _(){if(!vl&&(vl=!0,o.calledRun=!0,!U)){if(Ee(N),l(o),o.onRuntimeInitialized&&o.onRuntimeInitialized(),o.postRun)for(typeof o.postRun=="function"&&(o.postRun=[o.postRun]);o.postRun.length;){var L=o.postRun.shift();G.unshift(L)}Ee(G)}}if(!(0<gt)){if(o.preRun)for(typeof o.preRun=="function"&&(o.preRun=[o.preRun]);o.preRun.length;)Z();Ee(bt),0<gt||(o.setStatus?(o.setStatus("Running..."),setTimeout(function(){setTimeout(function(){o.setStatus("")},1),_()},1)):_())}}if(o.preInit)for(typeof o.preInit=="function"&&(o.preInit=[o.preInit]);0<o.preInit.length;)o.preInit.pop()();return l2(),n}})();i.exports=e})(Eu);var c1=Eu.exports;(function(i){Object.defineProperty(i,"__esModule",{value:!0});var t={};i.default=void 0;var e=n(ic),r=oe;Object.keys(r).forEach(function(d){d==="default"||d==="__esModule"||Object.prototype.hasOwnProperty.call(t,d)||d in i&&i[d]===r[d]||Object.defineProperty(i,d,{enumerable:!0,get:function(){return r[d]}})});function n(d){return d&&d.__esModule?d:{default:d}}const o=c1;var l=(0,e.default)(o());i.default=l})(we);const Au=n1(we);function h1(i,t){return typeof i=="number"?{top:i*t,right:i*t,bottom:i*t,left:i*t}:{top:typeof i.top=="number"?i.top*t:i.top,right:typeof i.right=="number"?i.right*t:i.right,bottom:typeof i.bottom=="number"?i.bottom*t:i.bottom,left:typeof i.left=="number"?i.left*t:i.left}}function Tu(i,t){return typeof i=="number"?{top:i*t,right:i*t,bottom:i*t,left:i*t}:{top:(typeof i.top=="number"?i.top*t:i.top)??0,right:(typeof i.right=="number"?i.right*t:i.right)??0,bottom:(typeof i.bottom=="number"?i.bottom*t:i.bottom)??0,left:(typeof i.left=="number"?i.left*t:i.left)??0}}function ku(i,{layout:t,scale:e=1}){const{position:r="static",inset:n,width:o,height:l,minWidth:d,minHeight:f,maxWidth:p,maxHeight:g,flex:v,gap:E,margin:A,padding:T,direction:w="column",align:C="start",alignSelf:D,justify:M="start"}=t,U={static:we.PositionType.Static,relative:we.PositionType.Relative,absolute:we.PositionType.Absolute};if(i.setPositionType(U[r]),n){const{top:B,right:at,bottom:st,left:J}=h1(n,e);B&&i.setPosition(we.Edge.Top,B),at&&i.setPosition(we.Edge.Right,at),st&&i.setPosition(we.Edge.Bottom,st),J&&i.setPosition(we.Edge.Left,J)}const x={row:we.FlexDirection.Row,column:we.FlexDirection.Column,"row-reverse":we.FlexDirection.RowReverse,"column-reverse":we.FlexDirection.ColumnReverse};i.setFlexDirection(x[w]);const O={start:we.Align.FlexStart,end:we.Align.FlexEnd,center:we.Align.Center,stretch:we.Align.Stretch};i.setAlignItems(O[C]),D&&i.setAlignSelf(O[D]);const K={start:we.Justify.FlexStart,end:we.Justify.FlexEnd,center:we.Justify.Center,"space-between":we.Justify.SpaceBetween,"space-around":we.Justify.SpaceAround,"space-evenly":we.Justify.SpaceEvenly};if(i.setJustifyContent(K[M]),A){const{top:B,right:at,bottom:st,left:J}=Tu(A,e);i.setMargin(we.Edge.Top,B),i.setMargin(we.Edge.Right,at),i.setMargin(we.Edge.Bottom,st),i.setMargin(we.Edge.Left,J)}if(T){const{top:B,right:at,bottom:st,left:J}=Tu(T,e);i.setPadding(we.Edge.Top,B),i.setPadding(we.Edge.Right,at),i.setPadding(we.Edge.Bottom,st),i.setPadding(we.Edge.Left,J)}v&&i.setFlex(v),i.setGap(we.Gutter.All,(E??0)*e),o&&i.setWidth(typeof o=="number"?o*e:o),l&&(typeof l=="function"?i.setHeight("100%"):i.setHeight(typeof l=="number"?l*e:l)),d&&i.setMinWidth(typeof d=="number"?d*e:d),f&&i.setMinHeight(typeof f=="number"?f*e:f),p&&i.setMaxWidth(typeof p=="number"?p*e:p),g&&i.setMaxHeight(typeof g=="number"?g*e:g)}function wu({canvas:i,debug:t=!1,scale:e=1,position:r=[]}){r.forEach(({x:n,y:o,width:l,height:d,childNodes:f,element:p})=>{const g=i.getContext("2d",{alpha:!1});if(g){const{draw:v}=p;v&&(g.save(),v({scale:e,dx:n,dy:o,dw:l,dh:d}),t&&(g.strokeStyle="red",g.strokeRect(n,o,l,d))),wu({canvas:i,debug:t,scale:e,position:f}),g.restore()}})}function Su(i,t,e){const r=t.map((n,o)=>{const l=Au.Node.create(),{radius:d,elements:f=[],draw:p,...g}=n;return ku(l,{layout:g,scale:e}),i.insertChild(l,o),{node:l,element:n,childNodes:Su(l,f,e)}});return i.calculateLayout(),r}function Ru(i,t,e=0,r=0){const{top:n,left:o}=i.getComputedLayout();return t.map(({node:l,element:d,childNodes:f})=>{const{top:p,left:g,width:v,height:E}=l.getComputedLayout(),A=e+g,T=r+p;return{x:o+A,y:n+T,width:v,height:E,element:d,childNodes:Ru(i,f,A,T)}})}function _u(i,t){i.forEach(({node:e,element:r,childNodes:n})=>{const{height:o}=r;if(o&&typeof o=="function"){const l=e.getComputedWidth(),d=e.getComputedHeight(),f=o({width:l,maxHeight:d,scale:t});e.setHeight(f)}_u(n,t)})}function d1({canvas:i,origin:t,elements:e,...r}){const n={inset:{top:0,left:0},width:i.width,height:i.height,...t},o=Au.Node.create();ku(o,{layout:n}),o.calculateLayout();const{width:l,height:d}=o.getComputedLayout(),f=Math.min(l,d)/1080,p=Su(o,e,f);_u(p,f),o.calculateLayout();const g=Ru(o,p);return wu({...r,scale:f,canvas:i,position:g})}var Lu=function(){};const u1=(i,t,e)=>Math.min(Math.max(e,i),t),Cu=(i,t,e)=>{const r=t-i;return r===0?1:(e-i)/r},oc=(i,t,e)=>-e*i+e*t+i,Iu=(i,t)=>e=>Math.max(Math.min(e,t),i),ya=i=>i%1?Number(i.toFixed(5)):i,ko=/(-)?([\d]*\.?[\d])+/g,lc=/(#[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,f1=/^(#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2}(-?[\d\.]+%?)\s*[\,\/]?\s*[\d\.]*%?\))$/i;function ba(i){return typeof i=="string"}const wo={test:i=>typeof i=="number",parse:parseFloat,transform:i=>i},xu=Object.assign(Object.assign({},wo),{transform:Iu(0,1)});Object.assign(Object.assign({},wo),{default:1});const p1=i=>({test:t=>ba(t)&&t.endsWith(i)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${i}`}),Ea=p1("%");Object.assign(Object.assign({},Ea),{parse:i=>Ea.parse(i)/100,transform:i=>Ea.transform(i*100)});const cc=(i,t)=>e=>!!(ba(e)&&f1.test(e)&&e.startsWith(i)||t&&Object.prototype.hasOwnProperty.call(e,t)),Du=(i,t,e)=>r=>{if(!ba(r))return r;const[n,o,l,d]=r.match(ko);return{[i]:parseFloat(n),[t]:parseFloat(o),[e]:parseFloat(l),alpha:d!==void 0?parseFloat(d):1}},an={test:cc("hsl","hue"),parse:Du("hue","saturation","lightness"),transform:({hue:i,saturation:t,lightness:e,alpha:r=1})=>"hsla("+Math.round(i)+", "+Ea.transform(ya(t))+", "+Ea.transform(ya(e))+", "+ya(xu.transform(r))+")"},g1=Iu(0,255),hc=Object.assign(Object.assign({},wo),{transform:i=>Math.round(g1(i))}),Rs={test:cc("rgb","red"),parse:Du("red","green","blue"),transform:({red:i,green:t,blue:e,alpha:r=1})=>"rgba("+hc.transform(i)+", "+hc.transform(t)+", "+hc.transform(e)+", "+ya(xu.transform(r))+")"};function m1(i){let t="",e="",r="",n="";return i.length>5?(t=i.substr(1,2),e=i.substr(3,2),r=i.substr(5,2),n=i.substr(7,2)):(t=i.substr(1,1),e=i.substr(2,1),r=i.substr(3,1),n=i.substr(4,1),t+=t,e+=e,r+=r,n+=n),{red:parseInt(t,16),green:parseInt(e,16),blue:parseInt(r,16),alpha:n?parseInt(n,16)/255:1}}const dc={test:cc("#"),parse:m1,transform:Rs.transform},So={test:i=>Rs.test(i)||dc.test(i)||an.test(i),parse:i=>Rs.test(i)?Rs.parse(i):an.test(i)?an.parse(i):dc.parse(i),transform:i=>ba(i)?i:i.hasOwnProperty("red")?Rs.transform(i):an.transform(i)},Pu="${c}",Ou="${n}";function v1(i){var t,e,r,n;return isNaN(i)&&ba(i)&&((e=(t=i.match(ko))===null||t===void 0?void 0:t.length)!==null&&e!==void 0?e:0)+((n=(r=i.match(lc))===null||r===void 0?void 0:r.length)!==null&&n!==void 0?n:0)>0}function $u(i){typeof i=="number"&&(i=`${i}`);const t=[];let e=0;const r=i.match(lc);r&&(e=r.length,i=i.replace(lc,Pu),t.push(...r.map(So.parse)));const n=i.match(ko);return n&&(i=i.replace(ko,Ou),t.push(...n.map(wo.parse))),{values:t,numColors:e,tokenised:i}}function Mu(i){return $u(i).values}function Nu(i){const{values:t,numColors:e,tokenised:r}=$u(i),n=t.length;return o=>{let l=r;for(let d=0;d<n;d++)l=l.replace(d<e?Pu:Ou,d<e?So.transform(o[d]):ya(o[d]));return l}}const y1=i=>typeof i=="number"?0:i;function b1(i){const t=Mu(i);return Nu(i)(t.map(y1))}const Fu={test:v1,parse:Mu,createTransformer:Nu,getAnimatableNone:b1};function uc(i,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<.16666666666666666?i+(t-i)*6*e:e<.5?t:e<.6666666666666666?i+(t-i)*(.6666666666666666-e)*6:i}function Uu({hue:i,saturation:t,lightness:e,alpha:r}){i/=360,t/=100,e/=100;let n=0,o=0,l=0;if(!t)n=o=l=e;else{const d=e<.5?e*(1+t):e+t-e*t,f=2*e-d;n=uc(f,d,i+.3333333333333333),o=uc(f,d,i),l=uc(f,d,i-.3333333333333333)}return{red:Math.round(n*255),green:Math.round(o*255),blue:Math.round(l*255),alpha:r}}const E1=(i,t,e)=>{const r=i*i,n=t*t;return Math.sqrt(Math.max(0,e*(n-r)+r))},A1=[dc,Rs,an],Bu=i=>A1.find(t=>t.test(i)),Gu=(i,t)=>{let e=Bu(i),r=Bu(t),n=e.parse(i),o=r.parse(t);e===an&&(n=Uu(n),e=Rs),r===an&&(o=Uu(o),r=Rs);const l=Object.assign({},n);return d=>{for(const f in l)f!=="alpha"&&(l[f]=E1(n[f],o[f],d));return l.alpha=oc(n.alpha,o.alpha,d),e.transform(l)}},T1=i=>typeof i=="number",k1=(i,t)=>e=>t(i(e)),Hu=(...i)=>i.reduce(k1);function Vu(i,t){return T1(i)?e=>oc(i,t,e):So.test(i)?Gu(i,t):Ku(i,t)}const Wu=(i,t)=>{const e=[...i],r=e.length,n=i.map((o,l)=>Vu(o,t[l]));return o=>{for(let l=0;l<r;l++)e[l]=n[l](o);return e}},w1=(i,t)=>{const e=Object.assign(Object.assign({},i),t),r={};for(const n in e)i[n]!==void 0&&t[n]!==void 0&&(r[n]=Vu(i[n],t[n]));return n=>{for(const o in r)e[o]=r[o](n);return e}};function ju(i){const t=Fu.parse(i),e=t.length;let r=0,n=0,o=0;for(let l=0;l<e;l++)r||typeof t[l]=="number"?r++:t[l].hue!==void 0?o++:n++;return{parsed:t,numNumbers:r,numRGB:n,numHSL:o}}const Ku=(i,t)=>{const e=Fu.createTransformer(t),r=ju(i),n=ju(t);return r.numHSL===n.numHSL&&r.numRGB===n.numRGB&&r.numNumbers>=n.numNumbers?Hu(Wu(r.parsed,n.parsed),e):o=>`${o>0?t:i}`},S1=(i,t)=>e=>oc(i,t,e);function R1(i){if(typeof i=="number")return S1;if(typeof i=="string")return So.test(i)?Gu:Ku;if(Array.isArray(i))return Wu;if(typeof i=="object")return w1}function _1(i,t,e){const r=[],n=e||R1(i[0]),o=i.length-1;for(let l=0;l<o;l++){let d=n(i[l],i[l+1]);if(t){const f=Array.isArray(t)?t[l]:t;d=Hu(f,d)}r.push(d)}return r}function L1([i,t],[e]){return r=>e(Cu(i,t,r))}function C1(i,t){const e=i.length,r=e-1;return n=>{let o=0,l=!1;if(n<=i[0]?l=!0:n>=i[r]&&(o=r-1,l=!0),!l){let f=1;for(;f<e&&!(i[f]>n||f===r);f++);o=f-1}const d=Cu(i[o],i[o+1],n);return t[o](d)}}function I1(i,t,{clamp:e=!0,ease:r,mixer:n}={}){const o=i.length;Lu(o===t.length),Lu(!r||!Array.isArray(r)||r.length===o-1),i[0]>i[o-1]&&(i=[].concat(i),t=[].concat(t),i.reverse(),t.reverse());const l=_1(t,r,n),d=o===2?L1(i,l):C1(i,l);return e?f=>d(u1(i[0],i[o-1],f)):d}const Ro=i=>t=>1-i(1-t),fc=i=>t=>t<=.5?i(2*t)/2:(2-i(2*(1-t)))/2,x1=i=>t=>Math.pow(t,i),zu=i=>t=>t*t*((i+1)*t-i),D1=i=>{const t=zu(i);return e=>(e*=2)<1?.5*t(e):.5*(2-Math.pow(2,-10*(e-1)))},Yu=1.525,P1=4/11,O1=8/11,$1=9/10,M1=i=>i,pc=x1(2),N1=Ro(pc),F1=fc(pc),Xu=i=>1-Math.sin(Math.acos(i)),Zu=Ro(Xu),U1=fc(Zu),gc=zu(Yu),B1=Ro(gc),G1=fc(gc),H1=D1(Yu),V1=4356/361,W1=35442/1805,j1=16061/1805,_o=i=>{if(i===1||i===0)return i;const t=i*i;return i<P1?7.5625*t:i<O1?9.075*t-9.9*i+3.4:i<$1?V1*t-W1*i+j1:10.8*i*i-20.52*i+10.72},K1=Ro(_o),z1=i=>i<.5?.5*(1-_o(1-i*2)):.5*_o(i*2-1)+.5,Y1={linear:M1,easeIn:pc,easeInOut:F1,easeOut:N1,circIn:Xu,circInOut:U1,circOut:Zu,backIn:gc,backInOut:G1,backOut:B1,anticipate:H1,bounceIn:K1,bounceInOut:z1,bounceOut:_o},Lo=rc((i,t,{clamp:e=!0,ease:r="easeIn",...n}={})=>I1(i,t,{...n,clamp:e,ease:Y1[r]}),{cacheKey:([i,t,e])=>JSON.stringify({from:i,to:t,options:e})}),qu=[{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 Co({text:i,font:t}){let e=t;return qu.forEach(({family:r,regex:n})=>{n.exec(i)&&(e+=`, ${r}`)}),e}const rs=1.8,Io=/(?<value>\d+\.?\d*)(?=px)/;function X1(i,t=1){return typeof i=="number"?{topLeft:i*t,topRight:i*t,bottomRight:i*t,bottomLeft:i*t}:{topLeft:((i==null?void 0:i.topLeft)??0)*t,topRight:((i==null?void 0:i.topRight)??0)*t,bottomRight:((i==null?void 0:i.bottomRight)??0)*t,bottomLeft:((i==null?void 0:i.bottomLeft)??0)*t}}function Qu(i){const{visible:t,node:e}=i,r=[...(e==null?void 0:e.elements)??[],...(i==null?void 0:i.elements)??[]];return t??(e&&e.type!=="box"&&e.type!=="gradient"?!!e.value:r==null?void 0:r.some(n=>Qu(n)))}function Ju({debug:i=!1,canvas:t,cropCanvas:e,posterCanvas:r,letterboxCanvas:n,elements:o=[],currentTime:l,contentTime:d,sceneTime:f,totalDuration:p,contentDuration:g,sceneDuration:v}){return o.map(E=>{var A,T,w,C,D,M,U,x;const{node:O,transient:K=[{from:0,duration:1/0}]}=E,B=t.getContext("2d"),at={total:l,content:d,scene:f},st={total:p,content:g,scene:v},J=K.reduce((kt,{type:ft="scene",from:wt,duration:Pt,animation:F})=>{const j=wt<0?st[ft]+wt:wt;return at[ft]>=j&&at[ft]<=j+Pt&&(kt={type:ft,animation:F,duration:Pt,from:j}),kt},null);if(B&&J&&Qu(E)){let kt=E.width,ft=E.height;if((O==null?void 0:O.type)==="text"&&O.value){const wt=Co({text:O.value,font:O.font});B.save(),O.wrap?ft=({width:Pt,maxHeight:F,scale:j})=>{var bt,N;const G=yu({font:wt,scale:j,context:B,maxW:Pt,maxH:F,text:O.value??"",minSize:(bt=O.fill)==null?void 0:bt.minSize,maxSize:(N=O.fill)==null?void 0:N.maxSize});return xo({context:B,font:wt,fontSize:G,text:O.value??"",maxW:Pt}).length*G}:(B.font=wt,kt=B.measureText(O.value).width,ft=parseFloat(((T=(A=wt.match(Io))==null?void 0:A.groups)==null?void 0:T.value)??"0")),B.restore()}if((O==null?void 0:O.type)==="image"&&O.image&&O.size){const wt=((w=O.image)==null?void 0:w.naturalWidth)??((C=O.image)==null?void 0:C.width),Pt=((D=O.image)==null?void 0:D.naturalHeight)??((M=O.image)==null?void 0:M.height),F=wt/Pt,j=(U=O.size)==null?void 0:U.width,bt=(x=O.size)==null?void 0:x.height;kt=j??(F>=1?(bt??0)*F:(bt??0)/F),ft=bt??(F<1?(j??0)*F:(j??0)/F)}return{...E,width:kt,height:ft,elements:Ju({debug:i,canvas:t,cropCanvas:e,posterCanvas:r,letterboxCanvas:n,elements:E.elements,currentTime:l,contentTime:d,sceneTime:f,totalDuration:p,contentDuration:g,sceneDuration:v}),draw:({dx:wt,dy:Pt,dw:F,dh:j,scale:bt})=>{var N,G,Z,gt,vt,It,Bt,Xt,me,be,Ee,Ye,Le;const{type:Wt="scene",from:se,duration:le,animation:De={type:"fade",duration:.3333333333333333,easing:{in:"easeOut",out:"easeOut"}}}=J;if(De){const{type:Nt,duration:ne,easing:{in:ee="easeOut",out:$e="easeOut"}={}}=De;if(se>0&&at[Wt]<=se+ne)switch(Nt){case"fade":{const Me=Lo([se,se+ne],[0,1],{ease:ee});B.globalAlpha=Me(at[Wt]);break}case"slide":{const{options:Me}=De,ce={up:[{x:0,y:j},{x:0,y:0}],right:[{x:F,y:0},{x:0,y:0}],down:[{x:0,y:-j},{x:0,y:0}],left:[{x:-F,y:0},{x:0,y:0}]},Ce=Lo([se,se+ne],ce[Me.direction.in],{ease:ee}),{x:ie,y:Ie}=Ce(at[Wt]);B.translate(ie,Ie);break}}if(se+le<st[Wt]&&se+le-ne<=at[Wt])switch(Nt){case"fade":{const Me=Lo([se+le-ne,se+le],[1,0],{ease:$e});B.globalAlpha=Me(at[Wt]);break}case"slide":{const{options:Me}=De,ce={up:[{x:0,y:0},{x:0,y:-j}],right:[{x:0,y:0},{x:F,y:0}],down:[{x:0,y:0},{x:0,y:j}],left:[{x:0,y:0},{x:-F,y:0}]},Ce=Lo([se+le-ne,se+le],ce[Me.direction.out],{ease:$e}),{x:ie,y:Ie}=Ce(at[Wt]);B.translate(ie,Ie);break}}}if(O){const{type:Nt}=O;if(E.radius){const{topLeft:ne,topRight:ee,bottomRight:$e,bottomLeft:Me}=X1(E.radius,bt);B.beginPath(),B.moveTo(wt+Math.min(j/rs,ne),Pt),B.lineTo(wt+F-Math.min(j/rs,ee),Pt),B.quadraticCurveTo(wt+F,Pt,wt+F,Pt+Math.min(j/rs,ee)),B.lineTo(wt+F,Pt+j-Math.min(j/rs,$e)),B.quadraticCurveTo(wt+F,Pt+j,wt+F-Math.min(j/rs,$e),Pt+j),B.lineTo(wt+Math.min(j/rs,Me),Pt+j),B.quadraticCurveTo(wt,Pt+j,wt,Pt+j-Math.min(j/rs,Me)),B.lineTo(wt,Pt+Math.min(j/rs,ne)),B.quadraticCurveTo(wt,Pt,wt+Math.min(j/rs,ne),Pt),B.closePath(),i&&(B.strokeStyle="blue",B.stroke()),B.clip()}if(Nt==="box"&&(B.fillStyle=O.background,B.fillRect(wt,Pt,F,j)),Nt==="text"&&O.value){const{align:ne="left"}=O,ee=Co({text:O.value,font:O.font}),$e=yu({font:ee,scale:bt,context:B,maxW:F,maxH:j,text:O.value??"",minSize:(N=O.fill)==null?void 0:N.minSize,maxSize:(G=O.fill)==null?void 0:G.maxSize});B.font=ee.replace(Io,$e.toString()),B.textBaseline="top",B.fillStyle=O.color,B.textAlign=ne;const Me={left:wt,center:wt+F/2,right:wt+F};O.wrap?xo({context:B,font:ee,fontSize:$e,text:O.value,maxW:F}).forEach((ce,Ce)=>{B.fillText(ce.text,Me[ne],Pt+$e*Ce)}):B.fillText(O.value,Me[ne],Pt)}if(Nt==="image"&&O.image&&B.drawImage(O.image,wt,Pt,F,j),Nt==="video"&&((Z=O.video)!=null&&Z.node||(gt=O.video)!=null&&gt.getSource)){const ne=O.format??"letterbox",ee=((It=(vt=O.video)==null?void 0:vt.getSource)==null?void 0:It.call(vt,f))??O.video.node,$e=(ee==null?void 0:ee.videoWidth)??(ee==null?void 0:ee.naturalWidth)??(ee==null?void 0:ee.width),Me=(ee==null?void 0:ee.videoHeight)??(ee==null?void 0:ee.naturalHeight)??(ee==null?void 0:ee.height);if($e&&Me){const{dx:Ce,dy:ie,dw:Ie,dh:We}=gu({context:B,cropCanvas:e,letterboxCanvas:n,source:ee,format:ne,crop:(Bt=O==null?void 0:O.value)==null?void 0:Bt.crop,sourceWidth:$e,sourceHeight:Me,posX:wt,posY:Pt,drawAreaWidth:F,drawAreaHeight:j});O.elements&&mc({debug:i,canvas:t,cropCanvas:e,posterCanvas:r,letterboxCanvas:n,elements:O.elements,currentTime:l,contentTime:d,sceneTime:f,totalDuration:p,contentDuration:g,sceneDuration:v,origin:{inset:{top:Math.max(Pt,Pt+ie),left:Math.max(wt,wt+Ce)},width:Math.min(F,Ie),height:Math.min(j,We)}})}const ce=1/3;if(O.poster&&l>=0&&l<=ce){B.save(),B.globalAlpha=1-l/ce;const Ce=((Xt=O.poster)==null?void 0:Xt.naturalWidth)??((me=O.poster)==null?void 0:me.width),ie=((be=O.poster)==null?void 0:be.naturalHeight)??((Ee=O.poster)==null?void 0:Ee.height);r.width=r.height=0,r.width=F,r.height=j;const Ie=r.getContext("2d");if(Ie&&Ce&&ie){const{dx:We,dy:Pr,dw:Be,dh:br}=gu({context:Ie,cropCanvas:e,letterboxCanvas:n,source:O.poster,format:ne,crop:(Ye=O==null?void 0:O.value)==null?void 0:Ye.crop,sourceWidth:Ce,sourceHeight:ie,posX:0,posY:0,drawAreaWidth:F,drawAreaHeight:j});O.elements&&mc({debug:i,canvas:r,cropCanvas:e,posterCanvas:r,letterboxCanvas:n,elements:O.elements,currentTime:l,contentTime:d,sceneTime:f,totalDuration:p,contentDuration:g,sceneDuration:v,origin:{inset:{top:Math.max(0,Pr),left:Math.max(0,We)},width:Math.min(F,Be),height:Math.min(j,br)}}),B.drawImage(r,wt,Pt,F,j),B.restore()}}}if(Nt==="gradient"&&O.value){const ne=B.createLinearGradient(wt+F,Pt,wt+F,Pt+j);(Le=O.value)==null||Le.forEach(ee=>{ne.addColorStop(ee.percent,ee.color)}),B.fillStyle=ne,B.fillRect(wt,Pt,F,j)}}}}}}).filter(Boolean)}function mc({debug:i,canvas:t,cropCanvas:e,posterCanvas:r,letterboxCanvas:n,elements:o,currentTime:l,contentTime:d,sceneTime:f,totalDuration:p,contentDuration:g,sceneDuration:v,...E}){return d1({...E,debug:i,canvas:t,elements:Ju({debug:i,canvas:t,cropCanvas:e,posterCanvas:r,letterboxCanvas:n,elements:o,currentTime:l,contentTime:d,sceneTime:f,totalDuration:p,contentDuration:g,sceneDuration:v})})}const xo=rc(({context:i,font:t,fontSize:e,text:r,maxW:n=1/0})=>{try{return i.save(),i.font=t.replace(Io,e.toString()),r.split(`
91
91
  `).flatMap(o=>{const l=o.split(" ").filter(Boolean);return l.length?l.slice(1).reduce((d,f)=>{const p=`${d[d.length-1].text} ${f}`.trim(),g=i.measureText(p);return g.width>n?d=[...d,...vu({context:i,word:f,maxW:n})]:d[d.length-1]={text:p,metrics:g},d},vu({context:i,word:l[0],maxW:n})):{text:"",metrics:i.measureText("")}})}finally{i.restore()}},{cacheKey:([{font:i,fontSize:t,text:e,maxW:r}])=>`${i}_${t}_${e}_${r}`}),Z1=/\d{0,2}:?\d{2}:\d{2}\.\d{3}\s-->\s\d{0,2}:?\d{2}:\d{2}\.\d{3}\s{1,2}.*/g,q1=/\d{0,2}:?\d{2}:\d{2}\.\d{3}/g;function t0(i){if(!i)return[];const t=i.match(Z1);return t?t==null?void 0:t.map(e=>{const[r,n]=e.replace(`\r
92
92
  `,`
93
93
  `).split(`
@@ -168,7 +168,7 @@ ${t}`,t1=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),e1=Objec
168
168
  "width": {{ it.root?.answer?.settings?.crop?.width }},
169
169
  "height": {{ it.root?.answer?.settings?.crop?.height }}
170
170
  }
171
- }`}],root:"{{ it.outro?.questions?.items }}"}],system:!0,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()},tv={id:"073977ec-6384-4329-b7c5-8275fb513e74",name:"None",entityId:"none",templateId:"a95e537e-fb4d-4d2f-9c72-86c0925c7176",templates:[J1],meta:{frameRate:30,resolution:720,transitionDuration:1/3},system:!0,default:0,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()};async function ev(){if(typeof window>"u"){const i=await Promise.resolve().then(()=>e2);return new i.Image}return new Image}const e0=ws(async function(i){return i?new Promise((t,e)=>{ev().then(r=>{r.onload=()=>{t(r)},r.onerror=n=>{e(n)},r.src=i})}):null});async function vc({element:i,meta:t},e,r){var n,o,l;let d={...i};const{node:f}=i;if((f==null?void 0:f.type)==="video"&&((n=f==null?void 0:f.value)!=null&&n.src||(o=f==null?void 0:f.value)!=null&&o.playlist)){const p=await e(f.value,t);let g;try{g=await e0(f.value.poster)}catch{g=null}d={...d,node:{...f,video:p,poster:g,meta:await r(f.value,p.node,t)}}}if((f==null?void 0:f.type)==="image"&&f.value){let p;try{p=await e0(f.value)}catch{p=null}d={...d,node:{...f,image:p}}}return d.node&&(l=i.node)!=null&&l.elements&&(d.node.elements=await Promise.all(i.node.elements.map(p=>vc({element:p,meta:t},e,r)))),i.elements&&(d.elements=await Promise.all(i.elements.map(p=>vc({element:p,meta:t},e,r)))),d}async function Po(){if(typeof window>"u"){const i=await Promise.resolve().then(()=>e2),t=new i.Canvas;return t.gpu=!1,t}return document.createElement("canvas")}async function rv(i){var t;try{if((t=await Km(i,{method:"HEAD"}))!=null&&t.ok)return i}catch{return}}async function iv({sources:i}){let t=null;if(i){const e=i.filter(Boolean).map(r=>rv(r));t=(await Promise.all(e)).find(Boolean)}return t}function Aa(i=[]){var t;for(const e of i){if(((t=e==null?void 0:e.node)==null?void 0:t.type)==="video")return e.node;const r=Aa(e==null?void 0:e.elements);if(r)return r}}function sv(i,t){return i.reduce((e,r,n)=>[...e,r.map(({duration:o},l)=>n===i.length-1&&l===r.length-1?o:o-t)],[])}function nv(i){if(i===null||typeof i!="object")return!1;if(Object.getPrototypeOf(i)===null)return!0;let t=i;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(i)===t}function av(i){return i.replace(/\\/g,"\\\\").replace(/\//g,"\\/").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t").replace(/\f/g,"\\f").replace(/"/g,'\\"')}function Oo(i){return i.flatMap(t=>t).reduce((t,e)=>t+e,0)}po.filters.define("parse",i=>typeof i>"u"?null:typeof i=="string"?`"${av(i)}"`:nv(i)||Array.isArray(i)?JSON.stringify(i):i),po.helpers.define("resolve-source",ws(async i=>{const{sources:t}=i.params[0]??{},e=t==null?void 0:t.filter(Boolean),r=e==null?void 0:e.find(l=>l.includes("blob:")),n=e==null?void 0:e.find(l=>!l.includes("http")),o=r??n??await iv({sources:t});return o?`"${o}"`:"null"},{cacheKey:([i])=>JSON.stringify(i.params[0]??{})}));const Ta=(i,t,e)=>po.render(i,t,po.getConfig({autoEscape:!1,defaultFilter:"parse",async:!0,asyncHelpers:["resolve-source"],...e}));async function Sn({data:i,template:t,burnCaptions:e=!1,debug:r=!1},n,o){var l,d,f,p;const g=t??tv;if(!((l=g.templates)!=null&&l.length))throw new Error(`No templates found for template instance: ${g.id}`);let v=g.templates.find(({version:U})=>U===yc);if(!v){const U=g.templates.map(({version:x})=>`"${x}"`).join(", ");console.warn(`Template renderer expects template version "${yc}" but got ${U}`),v=g.templates[g.templates.length-1]}const E=await Promise.all(v.content.map(async({scenes:U,root:x})=>{const O={...g.options,...i,intro:g.intro,outro:g.outro};async function K(B,at){return Promise.all(U.map(async({layout:st,duration:J,data:kt,options:ft})=>{var wt,Pt,F;const j={...O,index:at,root:B},bt=kt?JSON.parse(await Ta(kt,j)):{},N=ft?JSON.parse(await Ta(ft,j)):{},G=J?parseFloat(await Ta(J,j)):NaN,Z=(wt=v.layouts.find(Bt=>Bt.name===st))==null?void 0:wt.tree;if(!Z)throw new Error(`Layout tree "${st}" not found in template "${v.id}" layouts.`);const gt=JSON.parse(await Ta(Z,{...bt,...N})),vt=await Promise.all(gt.flatMap(Bt=>vc({element:Bt,meta:g.meta},n,o))),It=Aa(vt);return{duration:(isNaN(G)?null:G)??((Pt=It==null?void 0:It.meta)==null?void 0:Pt.duration)??0,captions:(F=It==null?void 0:It.meta)==null?void 0:F.captions,elements:vt}}))}if(x){const B=JSON.parse(await Ta(x,O));return Array.isArray(B)?(await Promise.all(B.map(async(at,st)=>K(at,st)))).flatMap(at=>at):K(B,null)}return K(i,null)}));if(E.every(U=>U.every(x=>{const O=Aa(x.elements);return!(O!=null&&O.value.src)&&!(O!=null&&O.value.playlist)}))){const U=E.flatMap(x=>x.map(O=>{const K=Aa(O.elements);return!(K!=null&&K.value.src)&&!(K!=null&&K.value.playlist)&&(K==null?void 0:K.value.id)}).filter(Boolean)).join(", ");throw new Error(`Video(s) with ID ${U} failed to load, video can not be processed`)}if(E.every(U=>U.every(x=>x.duration<=0)))throw new Error("No scenes have any duration, video can not be processed");const A=E.reduce((U,x)=>{const O=x.filter(K=>K.duration>0);return O.length>0&&(U=[...U,O]),U},[]),T=((d=g.meta)==null?void 0:d.frameRate)??30,w=((f=g.meta)==null?void 0:f.resolution)??720,C=((p=g.meta)==null?void 0:p.transitionDuration)??1/3,D=sv(A,C),M=Oo(D);return{scenes:(await Promise.all(A.map((U,x)=>{const O=Oo(D[x]),K=Oo(D.slice(0,x));return Promise.all(U.map(async({duration:B,captions:at,elements:st},J)=>{var kt,ft;const wt=await Po(),Pt=await Po(),F=await Po(),j=await Po(),bt=Aa(st),N=Oo([...D.slice(0,x),...D[x].slice(0,J)]);return{draw:({canvas:G,currentTime:Z})=>{const gt=Math.max(0,Z-K),vt=Math.max(0,Z-N);mc({debug:r,canvas:G,cropCanvas:wt,posterCanvas:j,letterboxCanvas:Pt,elements:st,currentTime:Z,contentTime:gt,sceneTime:vt,totalDuration:M,contentDuration:O,sceneDuration:B}),at&&e&&Q1({canvas:G,dx:0,dy:0,dw:G.width,dh:G.height,vttCaptions:at,sceneTime:vt+((bt==null?void 0:bt.meta.start)??0)})},duration:B,transitionCanvas:F,start:N,video:bt==null?void 0:bt.video,videoMeta:bt==null?void 0:bt.meta,audio:{duration:B,src:(kt=bt==null?void 0:bt.value)==null?void 0:kt.src,start:(ft=bt==null?void 0:bt.meta)==null?void 0:ft.start}}}))}))).flatMap(U=>U),frameRate:T,resolution:w,transitionDuration:C,fonts:v.fonts??[],duration:M}}const yc="2",ov={name:"@vouchfor/embeds",version:"1.2.2",license:"MIT",author:"Aaron Williams",main:"dist/es/embeds.js",module:"dist/es/embeds.js",type:"module",types:"dist/es/src/index.d.ts",exports:{".":"./dist/es/embeds.js"},files:["dist","src"],publishConfig:{tag:"latest",access:"public"},scripts:{build:"rm -rf dist && tsc && yarn build:self","build:deps":"yarn --cwd ../media-player build","build:self":"vite build --mode iife && vite build --mode es && node scripts/build.cjs","build:package":"yarn build","build:storybook":"yarn prebuild && storybook build","generate:manifest":"wca src --outFile custom-elements.json",lint:"eslint . --quiet","lint:fix":"eslint . --fix","lint:staged":"lint-staged",prepublishOnly:"yarn build",size:"size-limit",storybook:"yarn prebuild && storybook dev -p 6007",prebuild:"yarn build:deps && yarn generate:manifest",test:"rm -rf test/lib && yarn prebuild && vite build --mode test && web-test-runner","test:ci":"yarn test --config web-test-runner.ci.config.js"},"lint-staged":{"**/*.{ts,tsx,js}":"eslint --fix --quiet","**/*.{md,json,yml}":"prettier --write"},dependencies:{"@a11y/focus-trap":"^1.0.5","@lit/task":"^1.0.0","@vouchfor/media-player":"^2.1.0",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 lv(i){const{publicApiUrl:t}=uo(i),e=ks();return navigator.sendBeacon(`${t}/api/visitor`,JSON.stringify({visitorId:e})),e}function cv(i){var o,l,d,f,p,g,v,E,A,T,w,C;if(typeof window>"u")return{client:null,tab:null,request:ks()};let t=(l=(o=window.localStorage)==null?void 0:o.getItem)==null?void 0:l.call(o,"vouch-uid-visitor"),e=(f=(d=window.localStorage)==null?void 0:d.getItem)==null?void 0:f.call(d,"vouch-uid-client"),r=(g=(p=window.sessionStorage)==null?void 0:p.getItem)==null?void 0:g.call(p,"vouch-uid-tab");const n=ks();return t||(t=lv(i),(E=(v=window.localStorage)==null?void 0:v.setItem)==null||E.call(v,"vouch-uid-visitor",t)),e||(e=ks(),(T=(A=window.localStorage)==null?void 0:A.setItem)==null||T.call(A,"vouch-uid-client",e)),r||(r=ks(),(C=(w=window.sessionStorage)==null?void 0:w.setItem)==null||C.call(w,"vouch-uid-tab",r)),{client:e,tab:r,request:n,visitor:t}}function hv(i,t){return i&&"vouchId"in i?i.vouchId:(t==null?void 0:t.id)??null}function dv(i="embedded_player"){var n,o;const[t,e]=((o=(n=Intl.DateTimeFormat().resolvedOptions().timeZone)==null?void 0:n.split)==null?void 0:o.call(n,"/"))??[],r={};return[...new URLSearchParams(location.search).entries()].forEach(([l,d])=>{if(/utm/.test(l)){const f=l.toLowerCase().replace(/[-_][a-z0-9]/g,p=>p.slice(-1).toUpperCase());r[f]=d}}),{source:i,time:new Date,region:e,country:t,screenHeight:window.screen.height,screenWidth:window.screen.width,referrer:document.referrer,currentUrl:location.href,embedType:"media-player-embed",embedVersion:ov.version,templateVersion:yc,...r}}const r0=1;class uv{constructor(t){this._batchedEvents=[],this._hasPlayed=!1,this._hasLoaded={},this._answersViewed={},this._streamStartTime={},this._streamLatestTime={},this._currentlyPlayingVideo=null,this._createTrackingEvent=(e,r)=>{const n=hv(r,this.host.vouch);!n||this.host.disableTracking||this._batchedEvents.push({event:e,payload:{...r,vouchId:n,time:new Date().toISOString()}})},this._sendTrackingEvent=()=>{if(this._batchedEvents.length<=0)return;const{publicApiUrl:e}=uo(this.host.env),{client:r,tab:n,request:o,visitor:l}=cv(this.host.env);navigator.sendBeacon(`${e}/api/batchevents`,JSON.stringify({payload:{events:this._batchedEvents},context:{"x-uid-client":r,"x-uid-tab":n,"x-uid-request":o,"x-uid-visitor":l,"x-reporting-metadata":dv(this.host.trackingSource)}})),this._batchedEvents=[]},this._streamEnded=()=>{if(this._currentlyPlayingVideo){const{id:e,key:r}=this._currentlyPlayingVideo;this._streamLatestTime[r]>this._streamStartTime[r]+r0&&this._createTrackingEvent("VIDEO_STREAMED",{answerId:e,streamStart:this._streamStartTime[r],streamEnd:this._streamLatestTime[r]}),delete this._streamStartTime[r],delete this._streamLatestTime[r]}},this._handleVouchLoaded=({detail:e})=>{e&&(this._hasLoaded[e]||(this._createTrackingEvent("VOUCH_LOADED",{vouchId:e}),this._hasLoaded[e]=!0))},this._handlePlay=()=>{this._hasPlayed||(this._createTrackingEvent("VIDEO_PLAYED",{streamStart:this.host.currentTime}),this._hasPlayed=!0)},this._handleVideoPlay=({detail:{id:e,key:r}})=>{this._answersViewed[r]||(this._createTrackingEvent("VOUCH_RESPONSE_VIEWED",{answerId:e}),this._answersViewed[r]=!0)},this._handleVideoTimeUpdate=({detail:{id:e,key:r,node:n}})=>{var o,l;!this.host.paused&&e===((l=(o=this.host.scene)==null?void 0:o.video)==null?void 0:l.id)&&(this._currentlyPlayingVideo={id:e,key:r,node:n},this._streamLatestTime[r]=n.currentTime,this._streamStartTime[r]||(this._streamStartTime[r]=n.currentTime,this._streamLatestTime[r]=n.currentTime))},this._handleVideoPause=({detail:{id:e,key:r}})=>{this._streamLatestTime[r]>this._streamStartTime[r]+r0&&this._createTrackingEvent("VIDEO_STREAMED",{answerId:e,streamStart:this._streamStartTime[r],streamEnd:this._streamLatestTime[r]}),delete this._streamStartTime[r],delete this._streamLatestTime[r]},this._pageUnloading=()=>{this._streamEnded(),this._sendTrackingEvent()},this._handleVisibilityChange=()=>{document.visibilityState==="hidden"&&this._pageUnloading()},this._handlePageHide=()=>{this._pageUnloading()},this.host=t,t.addController(this)}hostConnected(){requestAnimationFrame(()=>{var t,e,r,n;"onvisibilitychange"in document?document.addEventListener("visibilitychange",this._handleVisibilityChange):window.addEventListener("pagehide",this._handlePageHide),this.host.addEventListener("vouch:loaded",this._handleVouchLoaded),(t=this.host.mediaPlayer)==null||t.addEventListener("play",this._handlePlay),(e=this.host.mediaPlayer)==null||e.addEventListener("video:play",this._handleVideoPlay),(r=this.host.mediaPlayer)==null||r.addEventListener("video:pause",this._handleVideoPause),(n=this.host.mediaPlayer)==null||n.addEventListener("video:timeupdate",this._handleVideoTimeUpdate)})}hostDisconnected(){var t,e,r,n;this._pageUnloading(),"onvisibilitychange"in document?document.removeEventListener("visibilitychange",this._handleVisibilityChange):window.removeEventListener("pagehide",this._handlePageHide),this.host.removeEventListener("vouch:loaded",this._handleVouchLoaded),(t=this.host.mediaPlayer)==null||t.removeEventListener("play",this._handlePlay),(e=this.host.mediaPlayer)==null||e.removeEventListener("video:play",this._handleVideoPlay),(r=this.host.mediaPlayer)==null||r.removeEventListener("video:pause",this._handleVideoPause),(n=this.host.mediaPlayer)==null||n.removeEventListener("video:timeupdate",this._handleVideoTimeUpdate)}}const fv=i=>{class t extends i{constructor(){super(...arguments),this._mediaPlayerRef=wr()}get waiting(){var r;return(r=this._mediaPlayerRef.value)==null?void 0:r.waiting}get initialised(){var r;return(r=this._mediaPlayerRef.value)==null?void 0:r.initialised}get seeking(){var r;return(r=this._mediaPlayerRef.value)==null?void 0:r.seeking}get paused(){var r;return(r=this._mediaPlayerRef.value)==null?void 0:r.paused}get captions(){var r;return(r=this._mediaPlayerRef.value)==null?void 0:r.captions}get fullscreen(){var r;return(r=this._mediaPlayerRef.value)==null?void 0:r.fullscreen}get duration(){var r;return(r=this._mediaPlayerRef.value)==null?void 0:r.duration}set currentTime(r){this._mediaPlayerRef.value&&(this._mediaPlayerRef.value.currentTime=r)}get currentTime(){var r;return((r=this._mediaPlayerRef.value)==null?void 0:r.currentTime)??0}set playbackRate(r){this._mediaPlayerRef.value&&(this._mediaPlayerRef.value.playbackRate=r)}get playbackRate(){var r;return((r=this._mediaPlayerRef.value)==null?void 0:r.playbackRate)??1}set volume(r){this._mediaPlayerRef.value&&(this._mediaPlayerRef.value.volume=r)}get volume(){var r;return((r=this._mediaPlayerRef.value)==null?void 0:r.volume)??1}set muted(r){this._mediaPlayerRef.value&&(this._mediaPlayerRef.value.muted=r)}get muted(){var r;return((r=this._mediaPlayerRef.value)==null?void 0:r.muted)??!1}get scene(){var r;return((r=this._mediaPlayerRef.value)==null?void 0:r.scene)??null}get scenes(){var r;return((r=this._mediaPlayerRef.value)==null?void 0:r.scenes)??[]}get sceneConfig(){var r;return((r=this._mediaPlayerRef.value)==null?void 0:r.sceneConfig)??null}get videoState(){var r;return(r=this._mediaPlayerRef.value)==null?void 0:r.videoState}get mediaPlayer(){return this._mediaPlayerRef.value}play(){var r;(r=this._mediaPlayerRef.value)==null||r.play()}pause(){var r;(r=this._mediaPlayerRef.value)==null||r.pause()}reset(r=0,n=!1){var o;(o=this._mediaPlayerRef.value)==null||o.reset(r,n)}setScene(r){var n;(n=this._mediaPlayerRef.value)==null||n.setScene(r)}}return t};/**
171
+ }`}],root:"{{ it.outro?.questions?.items }}"}],system:!0,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()},tv={id:"073977ec-6384-4329-b7c5-8275fb513e74",name:"None",entityId:"none",templateId:"a95e537e-fb4d-4d2f-9c72-86c0925c7176",templates:[J1],meta:{frameRate:30,resolution:720,transitionDuration:1/3},system:!0,default:0,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()};async function ev(){if(typeof window>"u"){const i=await Promise.resolve().then(()=>e2);return new i.Image}return new Image}const e0=ws(async function(i){return i?new Promise((t,e)=>{ev().then(r=>{r.onload=()=>{t(r)},r.onerror=n=>{e(n)},r.src=i})}):null});async function vc({element:i,meta:t},e,r){var n,o,l;let d={...i};const{node:f}=i;if((f==null?void 0:f.type)==="video"&&((n=f==null?void 0:f.value)!=null&&n.src||(o=f==null?void 0:f.value)!=null&&o.playlist)){const p=await e(f.value,t);let g;try{g=await e0(f.value.poster)}catch{g=null}d={...d,node:{...f,video:p,poster:g,meta:await r(f.value,p.node,t)}}}if((f==null?void 0:f.type)==="image"&&f.value){let p;try{p=await e0(f.value)}catch{p=null}d={...d,node:{...f,image:p}}}return d.node&&(l=i.node)!=null&&l.elements&&(d.node.elements=await Promise.all(i.node.elements.map(p=>vc({element:p,meta:t},e,r)))),i.elements&&(d.elements=await Promise.all(i.elements.map(p=>vc({element:p,meta:t},e,r)))),d}async function Po(){if(typeof window>"u"){const i=await Promise.resolve().then(()=>e2),t=new i.Canvas;return t.gpu=!1,t}return document.createElement("canvas")}async function rv(i){var t;try{if((t=await Km(i,{method:"HEAD"}))!=null&&t.ok)return i}catch{return}}async function iv({sources:i}){let t=null;if(i){const e=i.filter(Boolean).map(r=>rv(r));t=(await Promise.all(e)).find(Boolean)}return t}function Aa(i=[]){var t;for(const e of i){if(((t=e==null?void 0:e.node)==null?void 0:t.type)==="video")return e.node;const r=Aa(e==null?void 0:e.elements);if(r)return r}}function sv(i,t){return i.reduce((e,r,n)=>[...e,r.map(({duration:o},l)=>n===i.length-1&&l===r.length-1?o:o-t)],[])}function nv(i){if(i===null||typeof i!="object")return!1;if(Object.getPrototypeOf(i)===null)return!0;let t=i;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(i)===t}function av(i){return i.replace(/\\/g,"\\\\").replace(/\//g,"\\/").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t").replace(/\f/g,"\\f").replace(/"/g,'\\"')}function Oo(i){return i.flatMap(t=>t).reduce((t,e)=>t+e,0)}po.filters.define("parse",i=>typeof i>"u"?null:typeof i=="string"?`"${av(i)}"`:nv(i)||Array.isArray(i)?JSON.stringify(i):i),po.helpers.define("resolve-source",ws(async i=>{const{sources:t}=i.params[0]??{},e=t==null?void 0:t.filter(Boolean),r=e==null?void 0:e.find(l=>l.includes("blob:")),n=e==null?void 0:e.find(l=>!l.includes("http")),o=r??n??await iv({sources:t});return o?`"${o}"`:"null"},{cacheKey:([i])=>JSON.stringify(i.params[0]??{})}));const Ta=(i,t,e)=>po.render(i,t,po.getConfig({autoEscape:!1,defaultFilter:"parse",async:!0,asyncHelpers:["resolve-source"],...e}));async function Sn({data:i,template:t,burnCaptions:e=!1,debug:r=!1},n,o){var l,d,f,p;const g=t??tv;if(!((l=g.templates)!=null&&l.length))throw new Error(`No templates found for template instance: ${g.id}`);let v=g.templates.find(({version:U})=>U===yc);if(!v){const U=g.templates.map(({version:x})=>`"${x}"`).join(", ");console.warn(`Template renderer expects template version "${yc}" but got ${U}`),v=g.templates[g.templates.length-1]}const E=await Promise.all(v.content.map(async({scenes:U,root:x})=>{const O={...g.options,...i,intro:g.intro,outro:g.outro};async function K(B,at){return Promise.all(U.map(async({layout:st,duration:J,data:kt,options:ft})=>{var wt,Pt,F;const j={...O,index:at,root:B},bt=kt?JSON.parse(await Ta(kt,j)):{},N=ft?JSON.parse(await Ta(ft,j)):{},G=J?parseFloat(await Ta(J,j)):NaN,Z=(wt=v.layouts.find(Bt=>Bt.name===st))==null?void 0:wt.tree;if(!Z)throw new Error(`Layout tree "${st}" not found in template "${v.id}" layouts.`);const gt=JSON.parse(await Ta(Z,{...bt,...N})),vt=await Promise.all(gt.flatMap(Bt=>vc({element:Bt,meta:g.meta},n,o))),It=Aa(vt);return{duration:(isNaN(G)?null:G)??((Pt=It==null?void 0:It.meta)==null?void 0:Pt.duration)??0,captions:(F=It==null?void 0:It.meta)==null?void 0:F.captions,elements:vt}}))}if(x){const B=JSON.parse(await Ta(x,O));return Array.isArray(B)?(await Promise.all(B.map(async(at,st)=>K(at,st)))).flatMap(at=>at):K(B,null)}return K(i,null)}));if(E.every(U=>U.every(x=>{const O=Aa(x.elements);return!(O!=null&&O.value.src)&&!(O!=null&&O.value.playlist)}))){const U=E.flatMap(x=>x.map(O=>{const K=Aa(O.elements);return!(K!=null&&K.value.src)&&!(K!=null&&K.value.playlist)&&(K==null?void 0:K.value.id)}).filter(Boolean)).join(", ");throw new Error(`Video(s) with ID ${U} failed to load, video can not be processed`)}if(E.every(U=>U.every(x=>x.duration<=0)))throw new Error("No scenes have any duration, video can not be processed");const A=E.reduce((U,x)=>{const O=x.filter(K=>K.duration>0);return O.length>0&&(U=[...U,O]),U},[]),T=((d=g.meta)==null?void 0:d.frameRate)??30,w=((f=g.meta)==null?void 0:f.resolution)??720,C=((p=g.meta)==null?void 0:p.transitionDuration)??1/3,D=sv(A,C),M=Oo(D);return{scenes:(await Promise.all(A.map((U,x)=>{const O=Oo(D[x]),K=Oo(D.slice(0,x));return Promise.all(U.map(async({duration:B,captions:at,elements:st},J)=>{var kt,ft;const wt=await Po(),Pt=await Po(),F=await Po(),j=await Po(),bt=Aa(st),N=Oo([...D.slice(0,x),...D[x].slice(0,J)]);return{draw:({canvas:G,currentTime:Z})=>{const gt=Math.max(0,Z-K),vt=Math.max(0,Z-N);mc({debug:r,canvas:G,cropCanvas:wt,posterCanvas:j,letterboxCanvas:Pt,elements:st,currentTime:Z,contentTime:gt,sceneTime:vt,totalDuration:M,contentDuration:O,sceneDuration:B}),at&&e&&Q1({canvas:G,dx:0,dy:0,dw:G.width,dh:G.height,vttCaptions:at,sceneTime:vt+((bt==null?void 0:bt.meta.start)??0)})},duration:B,transitionCanvas:F,start:N,video:bt==null?void 0:bt.video,videoMeta:bt==null?void 0:bt.meta,audio:{duration:B,src:(kt=bt==null?void 0:bt.value)==null?void 0:kt.src,start:(ft=bt==null?void 0:bt.meta)==null?void 0:ft.start}}}))}))).flatMap(U=>U),frameRate:T,resolution:w,transitionDuration:C,fonts:v.fonts??[],duration:M}}const yc="2",ov={name:"@vouchfor/embeds",version:"1.2.3",license:"MIT",author:"Aaron Williams",main:"dist/es/embeds.js",module:"dist/es/embeds.js",type:"module",types:"dist/es/src/index.d.ts",exports:{".":"./dist/es/embeds.js"},files:["dist","src"],publishConfig:{tag:"latest",access:"public"},scripts:{build:"rm -rf dist && tsc && yarn build:self","build:deps":"yarn --cwd ../media-player build","build:self":"vite build --mode iife && vite build --mode es && node scripts/build.cjs","build:package":"yarn build","build:storybook":"yarn prebuild && storybook build","generate:manifest":"wca src --outFile custom-elements.json",lint:"eslint . --quiet","lint:fix":"eslint . --fix","lint:staged":"lint-staged",prepublishOnly:"yarn build",size:"size-limit",storybook:"yarn prebuild && storybook dev -p 6007",prebuild:"yarn build:deps && yarn generate:manifest",test:"rm -rf test/lib && yarn prebuild && vite build --mode test && web-test-runner","test:ci":"yarn test --config web-test-runner.ci.config.js"},"lint-staged":{"**/*.{ts,tsx,js}":"eslint --fix --quiet","**/*.{md,json,yml}":"prettier --write"},dependencies:{"@a11y/focus-trap":"^1.0.5","@lit/task":"^1.0.0","@vouchfor/media-player":"^2.1.2",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 lv(i){const{publicApiUrl:t}=uo(i),e=ks();return navigator.sendBeacon(`${t}/api/visitor`,JSON.stringify({visitorId:e})),e}function cv(i){var o,l,d,f,p,g,v,E,A,T,w,C;if(typeof window>"u")return{client:null,tab:null,request:ks()};let t=(l=(o=window.localStorage)==null?void 0:o.getItem)==null?void 0:l.call(o,"vouch-uid-visitor"),e=(f=(d=window.localStorage)==null?void 0:d.getItem)==null?void 0:f.call(d,"vouch-uid-client"),r=(g=(p=window.sessionStorage)==null?void 0:p.getItem)==null?void 0:g.call(p,"vouch-uid-tab");const n=ks();return t||(t=lv(i),(E=(v=window.localStorage)==null?void 0:v.setItem)==null||E.call(v,"vouch-uid-visitor",t)),e||(e=ks(),(T=(A=window.localStorage)==null?void 0:A.setItem)==null||T.call(A,"vouch-uid-client",e)),r||(r=ks(),(C=(w=window.sessionStorage)==null?void 0:w.setItem)==null||C.call(w,"vouch-uid-tab",r)),{client:e,tab:r,request:n,visitor:t}}function hv(i,t){return i&&"vouchId"in i?i.vouchId:(t==null?void 0:t.id)??null}function dv(i="embedded_player"){var n,o;const[t,e]=((o=(n=Intl.DateTimeFormat().resolvedOptions().timeZone)==null?void 0:n.split)==null?void 0:o.call(n,"/"))??[],r={};return[...new URLSearchParams(location.search).entries()].forEach(([l,d])=>{if(/utm/.test(l)){const f=l.toLowerCase().replace(/[-_][a-z0-9]/g,p=>p.slice(-1).toUpperCase());r[f]=d}}),{source:i,time:new Date,region:e,country:t,screenHeight:window.screen.height,screenWidth:window.screen.width,referrer:document.referrer,currentUrl:location.href,embedType:"media-player-embed",embedVersion:ov.version,templateVersion:yc,...r}}const r0=1;class uv{constructor(t){this._batchedEvents=[],this._hasPlayed=!1,this._hasLoaded={},this._answersViewed={},this._streamStartTime={},this._streamLatestTime={},this._currentlyPlayingVideo=null,this._createTrackingEvent=(e,r)=>{const n=hv(r,this.host.vouch);!n||this.host.disableTracking||this._batchedEvents.push({event:e,payload:{...r,vouchId:n,time:new Date().toISOString()}})},this._sendTrackingEvent=()=>{if(this._batchedEvents.length<=0)return;const{publicApiUrl:e}=uo(this.host.env),{client:r,tab:n,request:o,visitor:l}=cv(this.host.env);navigator.sendBeacon(`${e}/api/batchevents`,JSON.stringify({payload:{events:this._batchedEvents},context:{"x-uid-client":r,"x-uid-tab":n,"x-uid-request":o,"x-uid-visitor":l,"x-reporting-metadata":dv(this.host.trackingSource)}})),this._batchedEvents=[]},this._streamEnded=()=>{if(this._currentlyPlayingVideo){const{id:e,key:r}=this._currentlyPlayingVideo;this._streamLatestTime[r]>this._streamStartTime[r]+r0&&this._createTrackingEvent("VIDEO_STREAMED",{answerId:e,streamStart:this._streamStartTime[r],streamEnd:this._streamLatestTime[r]}),delete this._streamStartTime[r],delete this._streamLatestTime[r]}},this._handleVouchLoaded=({detail:e})=>{e&&(this._hasLoaded[e]||(this._createTrackingEvent("VOUCH_LOADED",{vouchId:e}),this._hasLoaded[e]=!0))},this._handlePlay=()=>{this._hasPlayed||(this._createTrackingEvent("VIDEO_PLAYED",{streamStart:this.host.currentTime}),this._hasPlayed=!0)},this._handleVideoPlay=({detail:{id:e,key:r}})=>{this._answersViewed[r]||(this._createTrackingEvent("VOUCH_RESPONSE_VIEWED",{answerId:e}),this._answersViewed[r]=!0)},this._handleVideoTimeUpdate=({detail:{id:e,key:r,node:n}})=>{var o,l;!this.host.paused&&e===((l=(o=this.host.scene)==null?void 0:o.video)==null?void 0:l.id)&&(this._currentlyPlayingVideo={id:e,key:r,node:n},this._streamLatestTime[r]=n.currentTime,this._streamStartTime[r]||(this._streamStartTime[r]=n.currentTime,this._streamLatestTime[r]=n.currentTime))},this._handleVideoPause=({detail:{id:e,key:r}})=>{this._streamLatestTime[r]>this._streamStartTime[r]+r0&&this._createTrackingEvent("VIDEO_STREAMED",{answerId:e,streamStart:this._streamStartTime[r],streamEnd:this._streamLatestTime[r]}),delete this._streamStartTime[r],delete this._streamLatestTime[r]},this._pageUnloading=()=>{this._streamEnded(),this._sendTrackingEvent()},this._handleVisibilityChange=()=>{document.visibilityState==="hidden"&&this._pageUnloading()},this._handlePageHide=()=>{this._pageUnloading()},this.host=t,t.addController(this)}hostConnected(){requestAnimationFrame(()=>{var t,e,r,n;"onvisibilitychange"in document?document.addEventListener("visibilitychange",this._handleVisibilityChange):window.addEventListener("pagehide",this._handlePageHide),this.host.addEventListener("vouch:loaded",this._handleVouchLoaded),(t=this.host.mediaPlayer)==null||t.addEventListener("play",this._handlePlay),(e=this.host.mediaPlayer)==null||e.addEventListener("video:play",this._handleVideoPlay),(r=this.host.mediaPlayer)==null||r.addEventListener("video:pause",this._handleVideoPause),(n=this.host.mediaPlayer)==null||n.addEventListener("video:timeupdate",this._handleVideoTimeUpdate)})}hostDisconnected(){var t,e,r,n;this._pageUnloading(),"onvisibilitychange"in document?document.removeEventListener("visibilitychange",this._handleVisibilityChange):window.removeEventListener("pagehide",this._handlePageHide),this.host.removeEventListener("vouch:loaded",this._handleVouchLoaded),(t=this.host.mediaPlayer)==null||t.removeEventListener("play",this._handlePlay),(e=this.host.mediaPlayer)==null||e.removeEventListener("video:play",this._handleVideoPlay),(r=this.host.mediaPlayer)==null||r.removeEventListener("video:pause",this._handleVideoPause),(n=this.host.mediaPlayer)==null||n.removeEventListener("video:timeupdate",this._handleVideoTimeUpdate)}}/**
172
172
  * @license
173
173
  * Copyright 2018 Google LLC
174
174
  * SPDX-License-Identifier: BSD-3-Clause
@@ -176,36 +176,36 @@ ${t}`,t1=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),e1=Objec
176
176
  * @license
177
177
  * Copyright 2018 Google LLC
178
178
  * SPDX-License-Identifier: BSD-3-Clause
179
- */const i0="important",pv=" !"+i0,ka=wn(class extends ha{constructor(i){var t;if(super(i),i.type!==kn.ATTRIBUTE||i.name!=="style"||((t=i.strings)==null?void 0:t.length)>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(i){return Object.keys(i).reduce((t,e)=>{const r=i[e];return r==null?t:t+`${e=e.includes("-")?e:e.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${r};`},"")}update(i,[t]){const{style:e}=i.element;if(this.ut===void 0)return this.ut=new Set(Object.keys(t)),this.render(t);for(const r of this.ut)t[r]==null&&(this.ut.delete(r),r.includes("-")?e.removeProperty(r):e[r]=null);for(const r in t){const n=t[r];if(n!=null){this.ut.add(r);const o=typeof n=="string"&&n.endsWith(pv);r.includes("-")||o?e.setProperty(r,o?n.slice(0,-11):n,o?i0:""):e[r]=n}}return ys}});var gv=wa;wa.flatten=wa,wa.unflatten=a0;function s0(i){return i&&i.constructor&&typeof i.constructor.isBuffer=="function"&&i.constructor.isBuffer(i)}function n0(i){return i}function wa(i,t){t=t||{};const e=t.delimiter||".",r=t.maxDepth,n=t.transformKey||n0,o={};function l(d,f,p){p=p||1,Object.keys(d).forEach(function(g){const v=d[g],E=t.safe&&Array.isArray(v),A=Object.prototype.toString.call(v),T=s0(v),w=A==="[object Object]"||A==="[object Array]",C=f?f+e+n(g):n(g);if(!E&&!T&&w&&Object.keys(v).length&&(!t.maxDepth||p<r))return l(v,C,p+1);o[C]=v})}return l(i),o}function a0(i,t){t=t||{};const e=t.delimiter||".",r=t.overwrite||!1,n=t.transformKey||n0,o={};if(s0(i)||Object.prototype.toString.call(i)!=="[object Object]")return i;function d(g){const v=Number(g);return isNaN(v)||g.indexOf(".")!==-1||t.object?g:v}function f(g,v,E){return Object.keys(E).reduce(function(A,T){return A[g+e+T]=E[T],A},v)}function p(g){const v=Object.prototype.toString.call(g),E=v==="[object Array]",A=v==="[object Object]";if(g){if(E)return!g.length;if(A)return!Object.keys(g).length}else return!0}return i=Object.keys(i).reduce(function(g,v){const E=Object.prototype.toString.call(i[v]);return!(E==="[object Object]"||E==="[object Array]")||p(i[v])?(g[v]=i[v],g):f(v,g,wa(i[v],t))},{}),Object.keys(i).forEach(function(g){const v=g.split(e).map(n);let E=d(v.shift()),A=d(v[0]),T=o;for(;A!==void 0;){if(E==="__proto__")return;const w=Object.prototype.toString.call(T[E]),C=w==="[object Object]"||w==="[object Array]";if(!r&&!C&&typeof T[E]<"u")return;(r&&!C||!r&&T[E]==null)&&(T[E]=typeof A=="number"&&!t.object?[]:{}),T=T[E],v.length>0&&(E=d(v.shift()),A=d(v[0]))}T[E]=a0(i[g],t)}),o}const mv=ql(gv);/**
179
+ */const i0="important",fv=" !"+i0,ka=wn(class extends ha{constructor(i){var t;if(super(i),i.type!==kn.ATTRIBUTE||i.name!=="style"||((t=i.strings)==null?void 0:t.length)>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(i){return Object.keys(i).reduce((t,e)=>{const r=i[e];return r==null?t:t+`${e=e.includes("-")?e:e.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${r};`},"")}update(i,[t]){const{style:e}=i.element;if(this.ut===void 0)return this.ut=new Set(Object.keys(t)),this.render(t);for(const r of this.ut)t[r]==null&&(this.ut.delete(r),r.includes("-")?e.removeProperty(r):e[r]=null);for(const r in t){const n=t[r];if(n!=null){this.ut.add(r);const o=typeof n=="string"&&n.endsWith(fv);r.includes("-")||o?e.setProperty(r,o?n.slice(0,-11):n,o?i0:""):e[r]=n}}return ys}});var pv=wa;wa.flatten=wa,wa.unflatten=a0;function s0(i){return i&&i.constructor&&typeof i.constructor.isBuffer=="function"&&i.constructor.isBuffer(i)}function n0(i){return i}function wa(i,t){t=t||{};const e=t.delimiter||".",r=t.maxDepth,n=t.transformKey||n0,o={};function l(d,f,p){p=p||1,Object.keys(d).forEach(function(g){const v=d[g],E=t.safe&&Array.isArray(v),A=Object.prototype.toString.call(v),T=s0(v),w=A==="[object Object]"||A==="[object Array]",C=f?f+e+n(g):n(g);if(!E&&!T&&w&&Object.keys(v).length&&(!t.maxDepth||p<r))return l(v,C,p+1);o[C]=v})}return l(i),o}function a0(i,t){t=t||{};const e=t.delimiter||".",r=t.overwrite||!1,n=t.transformKey||n0,o={};if(s0(i)||Object.prototype.toString.call(i)!=="[object Object]")return i;function d(g){const v=Number(g);return isNaN(v)||g.indexOf(".")!==-1||t.object?g:v}function f(g,v,E){return Object.keys(E).reduce(function(A,T){return A[g+e+T]=E[T],A},v)}function p(g){const v=Object.prototype.toString.call(g),E=v==="[object Array]",A=v==="[object Object]";if(g){if(E)return!g.length;if(A)return!Object.keys(g).length}else return!0}return i=Object.keys(i).reduce(function(g,v){const E=Object.prototype.toString.call(i[v]);return!(E==="[object Object]"||E==="[object Array]")||p(i[v])?(g[v]=i[v],g):f(v,g,wa(i[v],t))},{}),Object.keys(i).forEach(function(g){const v=g.split(e).map(n);let E=d(v.shift()),A=d(v[0]),T=o;for(;A!==void 0;){if(E==="__proto__")return;const w=Object.prototype.toString.call(T[E]),C=w==="[object Object]"||w==="[object Array]";if(!r&&!C&&typeof T[E]<"u")return;(r&&!C||!r&&T[E]==null)&&(T[E]=typeof A=="number"&&!t.object?[]:{}),T=T[E],v.length>0&&(E=d(v.shift()),A=d(v[0]))}T[E]=a0(i[g],t)}),o}const gv=ql(pv);/**
180
180
  * @license
181
181
  * Copyright 2017 Google LLC
182
182
  * SPDX-License-Identifier: BSD-3-Clause
183
- */const o0=(i,t,e)=>{const r=new Map;for(let n=t;n<=e;n++)r.set(i[n],n);return r},l0=wn(class extends ha{constructor(i){if(super(i),i.type!==kn.CHILD)throw Error("repeat() can only be used in text expressions")}ht(i,t,e){let r;e===void 0?e=t:t!==void 0&&(r=t);const n=[],o=[];let l=0;for(const d of i)n[l]=r?r(d,l):l,o[l]=e(d,l),l++;return{values:o,keys:n}}render(i,t,e){return this.ht(i,t,e).values}update(i,[t,e,r]){const n=nm(i),{values:o,keys:l}=this.ht(t,e,r);if(!Array.isArray(n))return this.dt=l,o;const d=this.dt??(this.dt=[]),f=[];let p,g,v=0,E=n.length-1,A=0,T=o.length-1;for(;v<=E&&A<=T;)if(n[v]===null)v++;else if(n[E]===null)E--;else if(d[v]===l[A])f[A]=rn(n[v],o[A]),v++,A++;else if(d[E]===l[T])f[T]=rn(n[E],o[T]),E--,T--;else if(d[v]===l[T])f[T]=rn(n[v],o[T]),ca(i,f[T+1],n[v]),v++,T--;else if(d[E]===l[A])f[A]=rn(n[E],o[A]),ca(i,n[v],n[E]),E--,A++;else if(p===void 0&&(p=o0(l,A,T),g=o0(d,v,E)),p.has(d[v]))if(p.has(d[E])){const w=g.get(l[A]),C=w!==void 0?n[w]:null;if(C===null){const D=ca(i,n[v]);rn(D,o[A]),f[A]=D}else f[A]=rn(C,o[A]),ca(i,n[v],C),n[w]=null;A++}else jl(n[E]),E--;else jl(n[v]),v++;for(;A<=T;){const w=ca(i,f[T+1]);rn(w,o[A]),f[A++]=w}for(;v<=E;){const w=n[v++];w!==null&&jl(w)}return this.dt=l,sm(i,f),ys}});var jr="top",hi="bottom",di="right",Kr="left",bc="auto",Sa=[jr,hi,di,Kr],Rn="start",Ra="end",vv="clippingParents",c0="viewport",_a="popper",yv="reference",h0=Sa.reduce(function(i,t){return i.concat([t+"-"+Rn,t+"-"+Ra])},[]),d0=[].concat(Sa,[bc]).reduce(function(i,t){return i.concat([t,t+"-"+Rn,t+"-"+Ra])},[]),bv="beforeRead",Ev="read",Av="afterRead",Tv="beforeMain",kv="main",wv="afterMain",Sv="beforeWrite",Rv="write",_v="afterWrite",Lv=[bv,Ev,Av,Tv,kv,wv,Sv,Rv,_v];function Oi(i){return i?(i.nodeName||"").toLowerCase():null}function si(i){if(i==null)return window;if(i.toString()!=="[object Window]"){var t=i.ownerDocument;return t&&t.defaultView||window}return i}function on(i){var t=si(i).Element;return i instanceof t||i instanceof Element}function ui(i){var t=si(i).HTMLElement;return i instanceof t||i instanceof HTMLElement}function Ec(i){if(typeof ShadowRoot>"u")return!1;var t=si(i).ShadowRoot;return i instanceof t||i instanceof ShadowRoot}function Cv(i){var t=i.state;Object.keys(t.elements).forEach(function(e){var r=t.styles[e]||{},n=t.attributes[e]||{},o=t.elements[e];!ui(o)||!Oi(o)||(Object.assign(o.style,r),Object.keys(n).forEach(function(l){var d=n[l];d===!1?o.removeAttribute(l):o.setAttribute(l,d===!0?"":d)}))})}function Iv(i){var t=i.state,e={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(t.elements.popper.style,e.popper),t.styles=e,t.elements.arrow&&Object.assign(t.elements.arrow.style,e.arrow),function(){Object.keys(t.elements).forEach(function(r){var n=t.elements[r],o=t.attributes[r]||{},l=Object.keys(t.styles.hasOwnProperty(r)?t.styles[r]:e[r]),d=l.reduce(function(f,p){return f[p]="",f},{});!ui(n)||!Oi(n)||(Object.assign(n.style,d),Object.keys(o).forEach(function(f){n.removeAttribute(f)}))})}}const u0={name:"applyStyles",enabled:!0,phase:"write",fn:Cv,effect:Iv,requires:["computeStyles"]};function $i(i){return i.split("-")[0]}var ln=Math.max,$o=Math.min,_n=Math.round;function Ac(){var i=navigator.userAgentData;return i!=null&&i.brands&&Array.isArray(i.brands)?i.brands.map(function(t){return t.brand+"/"+t.version}).join(" "):navigator.userAgent}function f0(){return!/^((?!chrome|android).)*safari/i.test(Ac())}function Ln(i,t,e){t===void 0&&(t=!1),e===void 0&&(e=!1);var r=i.getBoundingClientRect(),n=1,o=1;t&&ui(i)&&(n=i.offsetWidth>0&&_n(r.width)/i.offsetWidth||1,o=i.offsetHeight>0&&_n(r.height)/i.offsetHeight||1);var l=on(i)?si(i):window,d=l.visualViewport,f=!f0()&&e,p=(r.left+(f&&d?d.offsetLeft:0))/n,g=(r.top+(f&&d?d.offsetTop:0))/o,v=r.width/n,E=r.height/o;return{width:v,height:E,top:g,right:p+v,bottom:g+E,left:p,x:p,y:g}}function Tc(i){var t=Ln(i),e=i.offsetWidth,r=i.offsetHeight;return Math.abs(t.width-e)<=1&&(e=t.width),Math.abs(t.height-r)<=1&&(r=t.height),{x:i.offsetLeft,y:i.offsetTop,width:e,height:r}}function p0(i,t){var e=t.getRootNode&&t.getRootNode();if(i.contains(t))return!0;if(e&&Ec(e)){var r=t;do{if(r&&i.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function is(i){return si(i).getComputedStyle(i)}function xv(i){return["table","td","th"].indexOf(Oi(i))>=0}function _s(i){return((on(i)?i.ownerDocument:i.document)||window.document).documentElement}function Mo(i){return Oi(i)==="html"?i:i.assignedSlot||i.parentNode||(Ec(i)?i.host:null)||_s(i)}function g0(i){return!ui(i)||is(i).position==="fixed"?null:i.offsetParent}function Dv(i){var t=/firefox/i.test(Ac()),e=/Trident/i.test(Ac());if(e&&ui(i)){var r=is(i);if(r.position==="fixed")return null}var n=Mo(i);for(Ec(n)&&(n=n.host);ui(n)&&["html","body"].indexOf(Oi(n))<0;){var o=is(n);if(o.transform!=="none"||o.perspective!=="none"||o.contain==="paint"||["transform","perspective"].indexOf(o.willChange)!==-1||t&&o.willChange==="filter"||t&&o.filter&&o.filter!=="none")return n;n=n.parentNode}return null}function La(i){for(var t=si(i),e=g0(i);e&&xv(e)&&is(e).position==="static";)e=g0(e);return e&&(Oi(e)==="html"||Oi(e)==="body"&&is(e).position==="static")?t:e||Dv(i)||t}function kc(i){return["top","bottom"].indexOf(i)>=0?"x":"y"}function Ca(i,t,e){return ln(i,$o(t,e))}function Pv(i,t,e){var r=Ca(i,t,e);return r>e?e:r}function m0(){return{top:0,right:0,bottom:0,left:0}}function v0(i){return Object.assign({},m0(),i)}function y0(i,t){return t.reduce(function(e,r){return e[r]=i,e},{})}var Ov=function(t,e){return t=typeof t=="function"?t(Object.assign({},e.rects,{placement:e.placement})):t,v0(typeof t!="number"?t:y0(t,Sa))};function $v(i){var t,e=i.state,r=i.name,n=i.options,o=e.elements.arrow,l=e.modifiersData.popperOffsets,d=$i(e.placement),f=kc(d),p=[Kr,di].indexOf(d)>=0,g=p?"height":"width";if(!(!o||!l)){var v=Ov(n.padding,e),E=Tc(o),A=f==="y"?jr:Kr,T=f==="y"?hi:di,w=e.rects.reference[g]+e.rects.reference[f]-l[f]-e.rects.popper[g],C=l[f]-e.rects.reference[f],D=La(o),M=D?f==="y"?D.clientHeight||0:D.clientWidth||0:0,U=w/2-C/2,x=v[A],O=M-E[g]-v[T],K=M/2-E[g]/2+U,B=Ca(x,K,O),at=f;e.modifiersData[r]=(t={},t[at]=B,t.centerOffset=B-K,t)}}function Mv(i){var t=i.state,e=i.options,r=e.element,n=r===void 0?"[data-popper-arrow]":r;n!=null&&(typeof n=="string"&&(n=t.elements.popper.querySelector(n),!n)||p0(t.elements.popper,n)&&(t.elements.arrow=n))}const Nv={name:"arrow",enabled:!0,phase:"main",fn:$v,effect:Mv,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function Cn(i){return i.split("-")[1]}var Fv={top:"auto",right:"auto",bottom:"auto",left:"auto"};function Uv(i,t){var e=i.x,r=i.y,n=t.devicePixelRatio||1;return{x:_n(e*n)/n||0,y:_n(r*n)/n||0}}function b0(i){var t,e=i.popper,r=i.popperRect,n=i.placement,o=i.variation,l=i.offsets,d=i.position,f=i.gpuAcceleration,p=i.adaptive,g=i.roundOffsets,v=i.isFixed,E=l.x,A=E===void 0?0:E,T=l.y,w=T===void 0?0:T,C=typeof g=="function"?g({x:A,y:w}):{x:A,y:w};A=C.x,w=C.y;var D=l.hasOwnProperty("x"),M=l.hasOwnProperty("y"),U=Kr,x=jr,O=window;if(p){var K=La(e),B="clientHeight",at="clientWidth";if(K===si(e)&&(K=_s(e),is(K).position!=="static"&&d==="absolute"&&(B="scrollHeight",at="scrollWidth")),K=K,n===jr||(n===Kr||n===di)&&o===Ra){x=hi;var st=v&&K===O&&O.visualViewport?O.visualViewport.height:K[B];w-=st-r.height,w*=f?1:-1}if(n===Kr||(n===jr||n===hi)&&o===Ra){U=di;var J=v&&K===O&&O.visualViewport?O.visualViewport.width:K[at];A-=J-r.width,A*=f?1:-1}}var kt=Object.assign({position:d},p&&Fv),ft=g===!0?Uv({x:A,y:w},si(e)):{x:A,y:w};if(A=ft.x,w=ft.y,f){var wt;return Object.assign({},kt,(wt={},wt[x]=M?"0":"",wt[U]=D?"0":"",wt.transform=(O.devicePixelRatio||1)<=1?"translate("+A+"px, "+w+"px)":"translate3d("+A+"px, "+w+"px, 0)",wt))}return Object.assign({},kt,(t={},t[x]=M?w+"px":"",t[U]=D?A+"px":"",t.transform="",t))}function Bv(i){var t=i.state,e=i.options,r=e.gpuAcceleration,n=r===void 0?!0:r,o=e.adaptive,l=o===void 0?!0:o,d=e.roundOffsets,f=d===void 0?!0:d,p={placement:$i(t.placement),variation:Cn(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:n,isFixed:t.options.strategy==="fixed"};t.modifiersData.popperOffsets!=null&&(t.styles.popper=Object.assign({},t.styles.popper,b0(Object.assign({},p,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:l,roundOffsets:f})))),t.modifiersData.arrow!=null&&(t.styles.arrow=Object.assign({},t.styles.arrow,b0(Object.assign({},p,{offsets:t.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:f})))),t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-placement":t.placement})}const Gv={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:Bv,data:{}};var No={passive:!0};function Hv(i){var t=i.state,e=i.instance,r=i.options,n=r.scroll,o=n===void 0?!0:n,l=r.resize,d=l===void 0?!0:l,f=si(t.elements.popper),p=[].concat(t.scrollParents.reference,t.scrollParents.popper);return o&&p.forEach(function(g){g.addEventListener("scroll",e.update,No)}),d&&f.addEventListener("resize",e.update,No),function(){o&&p.forEach(function(g){g.removeEventListener("scroll",e.update,No)}),d&&f.removeEventListener("resize",e.update,No)}}const Vv={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:Hv,data:{}};var Wv={left:"right",right:"left",bottom:"top",top:"bottom"};function Fo(i){return i.replace(/left|right|bottom|top/g,function(t){return Wv[t]})}var jv={start:"end",end:"start"};function E0(i){return i.replace(/start|end/g,function(t){return jv[t]})}function wc(i){var t=si(i),e=t.pageXOffset,r=t.pageYOffset;return{scrollLeft:e,scrollTop:r}}function Sc(i){return Ln(_s(i)).left+wc(i).scrollLeft}function Kv(i,t){var e=si(i),r=_s(i),n=e.visualViewport,o=r.clientWidth,l=r.clientHeight,d=0,f=0;if(n){o=n.width,l=n.height;var p=f0();(p||!p&&t==="fixed")&&(d=n.offsetLeft,f=n.offsetTop)}return{width:o,height:l,x:d+Sc(i),y:f}}function zv(i){var t,e=_s(i),r=wc(i),n=(t=i.ownerDocument)==null?void 0:t.body,o=ln(e.scrollWidth,e.clientWidth,n?n.scrollWidth:0,n?n.clientWidth:0),l=ln(e.scrollHeight,e.clientHeight,n?n.scrollHeight:0,n?n.clientHeight:0),d=-r.scrollLeft+Sc(i),f=-r.scrollTop;return is(n||e).direction==="rtl"&&(d+=ln(e.clientWidth,n?n.clientWidth:0)-o),{width:o,height:l,x:d,y:f}}function Rc(i){var t=is(i),e=t.overflow,r=t.overflowX,n=t.overflowY;return/auto|scroll|overlay|hidden/.test(e+n+r)}function A0(i){return["html","body","#document"].indexOf(Oi(i))>=0?i.ownerDocument.body:ui(i)&&Rc(i)?i:A0(Mo(i))}function Ia(i,t){var e;t===void 0&&(t=[]);var r=A0(i),n=r===((e=i.ownerDocument)==null?void 0:e.body),o=si(r),l=n?[o].concat(o.visualViewport||[],Rc(r)?r:[]):r,d=t.concat(l);return n?d:d.concat(Ia(Mo(l)))}function _c(i){return Object.assign({},i,{left:i.x,top:i.y,right:i.x+i.width,bottom:i.y+i.height})}function Yv(i,t){var e=Ln(i,!1,t==="fixed");return e.top=e.top+i.clientTop,e.left=e.left+i.clientLeft,e.bottom=e.top+i.clientHeight,e.right=e.left+i.clientWidth,e.width=i.clientWidth,e.height=i.clientHeight,e.x=e.left,e.y=e.top,e}function T0(i,t,e){return t===c0?_c(Kv(i,e)):on(t)?Yv(t,e):_c(zv(_s(i)))}function Xv(i){var t=Ia(Mo(i)),e=["absolute","fixed"].indexOf(is(i).position)>=0,r=e&&ui(i)?La(i):i;return on(r)?t.filter(function(n){return on(n)&&p0(n,r)&&Oi(n)!=="body"}):[]}function Zv(i,t,e,r){var n=t==="clippingParents"?Xv(i):[].concat(t),o=[].concat(n,[e]),l=o[0],d=o.reduce(function(f,p){var g=T0(i,p,r);return f.top=ln(g.top,f.top),f.right=$o(g.right,f.right),f.bottom=$o(g.bottom,f.bottom),f.left=ln(g.left,f.left),f},T0(i,l,r));return d.width=d.right-d.left,d.height=d.bottom-d.top,d.x=d.left,d.y=d.top,d}function k0(i){var t=i.reference,e=i.element,r=i.placement,n=r?$i(r):null,o=r?Cn(r):null,l=t.x+t.width/2-e.width/2,d=t.y+t.height/2-e.height/2,f;switch(n){case jr:f={x:l,y:t.y-e.height};break;case hi:f={x:l,y:t.y+t.height};break;case di:f={x:t.x+t.width,y:d};break;case Kr:f={x:t.x-e.width,y:d};break;default:f={x:t.x,y:t.y}}var p=n?kc(n):null;if(p!=null){var g=p==="y"?"height":"width";switch(o){case Rn:f[p]=f[p]-(t[g]/2-e[g]/2);break;case Ra:f[p]=f[p]+(t[g]/2-e[g]/2);break}}return f}function xa(i,t){t===void 0&&(t={});var e=t,r=e.placement,n=r===void 0?i.placement:r,o=e.strategy,l=o===void 0?i.strategy:o,d=e.boundary,f=d===void 0?vv:d,p=e.rootBoundary,g=p===void 0?c0:p,v=e.elementContext,E=v===void 0?_a:v,A=e.altBoundary,T=A===void 0?!1:A,w=e.padding,C=w===void 0?0:w,D=v0(typeof C!="number"?C:y0(C,Sa)),M=E===_a?yv:_a,U=i.rects.popper,x=i.elements[T?M:E],O=Zv(on(x)?x:x.contextElement||_s(i.elements.popper),f,g,l),K=Ln(i.elements.reference),B=k0({reference:K,element:U,strategy:"absolute",placement:n}),at=_c(Object.assign({},U,B)),st=E===_a?at:K,J={top:O.top-st.top+D.top,bottom:st.bottom-O.bottom+D.bottom,left:O.left-st.left+D.left,right:st.right-O.right+D.right},kt=i.modifiersData.offset;if(E===_a&&kt){var ft=kt[n];Object.keys(J).forEach(function(wt){var Pt=[di,hi].indexOf(wt)>=0?1:-1,F=[jr,hi].indexOf(wt)>=0?"y":"x";J[wt]+=ft[F]*Pt})}return J}function qv(i,t){t===void 0&&(t={});var e=t,r=e.placement,n=e.boundary,o=e.rootBoundary,l=e.padding,d=e.flipVariations,f=e.allowedAutoPlacements,p=f===void 0?d0:f,g=Cn(r),v=g?d?h0:h0.filter(function(T){return Cn(T)===g}):Sa,E=v.filter(function(T){return p.indexOf(T)>=0});E.length===0&&(E=v);var A=E.reduce(function(T,w){return T[w]=xa(i,{placement:w,boundary:n,rootBoundary:o,padding:l})[$i(w)],T},{});return Object.keys(A).sort(function(T,w){return A[T]-A[w]})}function Qv(i){if($i(i)===bc)return[];var t=Fo(i);return[E0(i),t,E0(t)]}function Jv(i){var t=i.state,e=i.options,r=i.name;if(!t.modifiersData[r]._skip){for(var n=e.mainAxis,o=n===void 0?!0:n,l=e.altAxis,d=l===void 0?!0:l,f=e.fallbackPlacements,p=e.padding,g=e.boundary,v=e.rootBoundary,E=e.altBoundary,A=e.flipVariations,T=A===void 0?!0:A,w=e.allowedAutoPlacements,C=t.options.placement,D=$i(C),M=D===C,U=f||(M||!T?[Fo(C)]:Qv(C)),x=[C].concat(U).reduce(function(Bt,Xt){return Bt.concat($i(Xt)===bc?qv(t,{placement:Xt,boundary:g,rootBoundary:v,padding:p,flipVariations:T,allowedAutoPlacements:w}):Xt)},[]),O=t.rects.reference,K=t.rects.popper,B=new Map,at=!0,st=x[0],J=0;J<x.length;J++){var kt=x[J],ft=$i(kt),wt=Cn(kt)===Rn,Pt=[jr,hi].indexOf(ft)>=0,F=Pt?"width":"height",j=xa(t,{placement:kt,boundary:g,rootBoundary:v,altBoundary:E,padding:p}),bt=Pt?wt?di:Kr:wt?hi:jr;O[F]>K[F]&&(bt=Fo(bt));var N=Fo(bt),G=[];if(o&&G.push(j[ft]<=0),d&&G.push(j[bt]<=0,j[N]<=0),G.every(function(Bt){return Bt})){st=kt,at=!1;break}B.set(kt,G)}if(at)for(var Z=T?3:1,gt=function(Xt){var me=x.find(function(be){var Ee=B.get(be);if(Ee)return Ee.slice(0,Xt).every(function(Ye){return Ye})});if(me)return st=me,"break"},vt=Z;vt>0;vt--){var It=gt(vt);if(It==="break")break}t.placement!==st&&(t.modifiersData[r]._skip=!0,t.placement=st,t.reset=!0)}}const ty={name:"flip",enabled:!0,phase:"main",fn:Jv,requiresIfExists:["offset"],data:{_skip:!1}};function w0(i,t,e){return e===void 0&&(e={x:0,y:0}),{top:i.top-t.height-e.y,right:i.right-t.width+e.x,bottom:i.bottom-t.height+e.y,left:i.left-t.width-e.x}}function S0(i){return[jr,di,hi,Kr].some(function(t){return i[t]>=0})}function ey(i){var t=i.state,e=i.name,r=t.rects.reference,n=t.rects.popper,o=t.modifiersData.preventOverflow,l=xa(t,{elementContext:"reference"}),d=xa(t,{altBoundary:!0}),f=w0(l,r),p=w0(d,n,o),g=S0(f),v=S0(p);t.modifiersData[e]={referenceClippingOffsets:f,popperEscapeOffsets:p,isReferenceHidden:g,hasPopperEscaped:v},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":g,"data-popper-escaped":v})}const ry={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:ey};function iy(i,t,e){var r=$i(i),n=[Kr,jr].indexOf(r)>=0?-1:1,o=typeof e=="function"?e(Object.assign({},t,{placement:i})):e,l=o[0],d=o[1];return l=l||0,d=(d||0)*n,[Kr,di].indexOf(r)>=0?{x:d,y:l}:{x:l,y:d}}function sy(i){var t=i.state,e=i.options,r=i.name,n=e.offset,o=n===void 0?[0,0]:n,l=d0.reduce(function(g,v){return g[v]=iy(v,t.rects,o),g},{}),d=l[t.placement],f=d.x,p=d.y;t.modifiersData.popperOffsets!=null&&(t.modifiersData.popperOffsets.x+=f,t.modifiersData.popperOffsets.y+=p),t.modifiersData[r]=l}const ny={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:sy};function ay(i){var t=i.state,e=i.name;t.modifiersData[e]=k0({reference:t.rects.reference,element:t.rects.popper,strategy:"absolute",placement:t.placement})}const oy={name:"popperOffsets",enabled:!0,phase:"read",fn:ay,data:{}};function ly(i){return i==="x"?"y":"x"}function cy(i){var t=i.state,e=i.options,r=i.name,n=e.mainAxis,o=n===void 0?!0:n,l=e.altAxis,d=l===void 0?!1:l,f=e.boundary,p=e.rootBoundary,g=e.altBoundary,v=e.padding,E=e.tether,A=E===void 0?!0:E,T=e.tetherOffset,w=T===void 0?0:T,C=xa(t,{boundary:f,rootBoundary:p,padding:v,altBoundary:g}),D=$i(t.placement),M=Cn(t.placement),U=!M,x=kc(D),O=ly(x),K=t.modifiersData.popperOffsets,B=t.rects.reference,at=t.rects.popper,st=typeof w=="function"?w(Object.assign({},t.rects,{placement:t.placement})):w,J=typeof st=="number"?{mainAxis:st,altAxis:st}:Object.assign({mainAxis:0,altAxis:0},st),kt=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,ft={x:0,y:0};if(K){if(o){var wt,Pt=x==="y"?jr:Kr,F=x==="y"?hi:di,j=x==="y"?"height":"width",bt=K[x],N=bt+C[Pt],G=bt-C[F],Z=A?-at[j]/2:0,gt=M===Rn?B[j]:at[j],vt=M===Rn?-at[j]:-B[j],It=t.elements.arrow,Bt=A&&It?Tc(It):{width:0,height:0},Xt=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:m0(),me=Xt[Pt],be=Xt[F],Ee=Ca(0,B[j],Bt[j]),Ye=U?B[j]/2-Z-Ee-me-J.mainAxis:gt-Ee-me-J.mainAxis,Le=U?-B[j]/2+Z+Ee+be+J.mainAxis:vt+Ee+be+J.mainAxis,Wt=t.elements.arrow&&La(t.elements.arrow),se=Wt?x==="y"?Wt.clientTop||0:Wt.clientLeft||0:0,le=(wt=kt==null?void 0:kt[x])!=null?wt:0,De=bt+Ye-le-se,Nt=bt+Le-le,ne=Ca(A?$o(N,De):N,bt,A?ln(G,Nt):G);K[x]=ne,ft[x]=ne-bt}if(d){var ee,$e=x==="x"?jr:Kr,Me=x==="x"?hi:di,ce=K[O],Ce=O==="y"?"height":"width",ie=ce+C[$e],Ie=ce-C[Me],We=[jr,Kr].indexOf(D)!==-1,Pr=(ee=kt==null?void 0:kt[O])!=null?ee:0,Be=We?ie:ce-B[Ce]-at[Ce]-Pr+J.altAxis,br=We?ce+B[Ce]+at[Ce]-Pr-J.altAxis:Ie,cs=A&&We?Pv(Be,ce,br):Ca(A?Be:ie,ce,A?br:Ie);K[O]=cs,ft[O]=cs-ce}t.modifiersData[r]=ft}}const hy={name:"preventOverflow",enabled:!0,phase:"main",fn:cy,requiresIfExists:["offset"]};function dy(i){return{scrollLeft:i.scrollLeft,scrollTop:i.scrollTop}}function uy(i){return i===si(i)||!ui(i)?wc(i):dy(i)}function fy(i){var t=i.getBoundingClientRect(),e=_n(t.width)/i.offsetWidth||1,r=_n(t.height)/i.offsetHeight||1;return e!==1||r!==1}function py(i,t,e){e===void 0&&(e=!1);var r=ui(t),n=ui(t)&&fy(t),o=_s(t),l=Ln(i,n,e),d={scrollLeft:0,scrollTop:0},f={x:0,y:0};return(r||!r&&!e)&&((Oi(t)!=="body"||Rc(o))&&(d=uy(t)),ui(t)?(f=Ln(t,!0),f.x+=t.clientLeft,f.y+=t.clientTop):o&&(f.x=Sc(o))),{x:l.left+d.scrollLeft-f.x,y:l.top+d.scrollTop-f.y,width:l.width,height:l.height}}function gy(i){var t=new Map,e=new Set,r=[];i.forEach(function(o){t.set(o.name,o)});function n(o){e.add(o.name);var l=[].concat(o.requires||[],o.requiresIfExists||[]);l.forEach(function(d){if(!e.has(d)){var f=t.get(d);f&&n(f)}}),r.push(o)}return i.forEach(function(o){e.has(o.name)||n(o)}),r}function my(i){var t=gy(i);return Lv.reduce(function(e,r){return e.concat(t.filter(function(n){return n.phase===r}))},[])}function vy(i){var t;return function(){return t||(t=new Promise(function(e){Promise.resolve().then(function(){t=void 0,e(i())})})),t}}function yy(i){var t=i.reduce(function(e,r){var n=e[r.name];return e[r.name]=n?Object.assign({},n,r,{options:Object.assign({},n.options,r.options),data:Object.assign({},n.data,r.data)}):r,e},{});return Object.keys(t).map(function(e){return t[e]})}var R0={placement:"bottom",modifiers:[],strategy:"absolute"};function _0(){for(var i=arguments.length,t=new Array(i),e=0;e<i;e++)t[e]=arguments[e];return!t.some(function(r){return!(r&&typeof r.getBoundingClientRect=="function")})}function by(i){i===void 0&&(i={});var t=i,e=t.defaultModifiers,r=e===void 0?[]:e,n=t.defaultOptions,o=n===void 0?R0:n;return function(d,f,p){p===void 0&&(p=o);var g={placement:"bottom",orderedModifiers:[],options:Object.assign({},R0,o),modifiersData:{},elements:{reference:d,popper:f},attributes:{},styles:{}},v=[],E=!1,A={state:g,setOptions:function(D){var M=typeof D=="function"?D(g.options):D;w(),g.options=Object.assign({},o,g.options,M),g.scrollParents={reference:on(d)?Ia(d):d.contextElement?Ia(d.contextElement):[],popper:Ia(f)};var U=my(yy([].concat(r,g.options.modifiers)));return g.orderedModifiers=U.filter(function(x){return x.enabled}),T(),A.update()},forceUpdate:function(){if(!E){var D=g.elements,M=D.reference,U=D.popper;if(_0(M,U)){g.rects={reference:py(M,La(U),g.options.strategy==="fixed"),popper:Tc(U)},g.reset=!1,g.placement=g.options.placement,g.orderedModifiers.forEach(function(J){return g.modifiersData[J.name]=Object.assign({},J.data)});for(var x=0;x<g.orderedModifiers.length;x++){if(g.reset===!0){g.reset=!1,x=-1;continue}var O=g.orderedModifiers[x],K=O.fn,B=O.options,at=B===void 0?{}:B,st=O.name;typeof K=="function"&&(g=K({state:g,options:at,name:st,instance:A})||g)}}}},update:vy(function(){return new Promise(function(C){A.forceUpdate(),C(g)})}),destroy:function(){w(),E=!0}};if(!_0(d,f))return A;A.setOptions(p).then(function(C){!E&&p.onFirstUpdate&&p.onFirstUpdate(C)});function T(){g.orderedModifiers.forEach(function(C){var D=C.name,M=C.options,U=M===void 0?{}:M,x=C.effect;if(typeof x=="function"){var O=x({state:g,name:D,instance:A,options:U}),K=function(){};v.push(O||K)}})}function w(){v.forEach(function(C){return C()}),v=[]}return A}}var Ey=[Vv,oy,Gv,u0,ny,ty,hy,Nv,ry],Ay=by({defaultModifiers:Ey}),Ty="tippy-box",L0="tippy-content",ky="tippy-backdrop",C0="tippy-arrow",I0="tippy-svg-arrow",cn={passive:!0,capture:!0},x0=function(){return document.body};function Lc(i,t,e){if(Array.isArray(i)){var r=i[t];return r??(Array.isArray(e)?e[t]:e)}return i}function Cc(i,t){var e={}.toString.call(i);return e.indexOf("[object")===0&&e.indexOf(t+"]")>-1}function D0(i,t){return typeof i=="function"?i.apply(void 0,t):i}function P0(i,t){if(t===0)return i;var e;return function(r){clearTimeout(e),e=setTimeout(function(){i(r)},t)}}function wy(i){return i.split(/\s+/).filter(Boolean)}function In(i){return[].concat(i)}function O0(i,t){i.indexOf(t)===-1&&i.push(t)}function Sy(i){return i.filter(function(t,e){return i.indexOf(t)===e})}function Ry(i){return i.split("-")[0]}function Uo(i){return[].slice.call(i)}function $0(i){return Object.keys(i).reduce(function(t,e){return i[e]!==void 0&&(t[e]=i[e]),t},{})}function Da(){return document.createElement("div")}function Bo(i){return["Element","Fragment"].some(function(t){return Cc(i,t)})}function _y(i){return Cc(i,"NodeList")}function Ly(i){return Cc(i,"MouseEvent")}function Cy(i){return!!(i&&i._tippy&&i._tippy.reference===i)}function Iy(i){return Bo(i)?[i]:_y(i)?Uo(i):Array.isArray(i)?i:Uo(document.querySelectorAll(i))}function Ic(i,t){i.forEach(function(e){e&&(e.style.transitionDuration=t+"ms")})}function M0(i,t){i.forEach(function(e){e&&e.setAttribute("data-state",t)})}function xy(i){var t,e=In(i),r=e[0];return r!=null&&(t=r.ownerDocument)!=null&&t.body?r.ownerDocument:document}function Dy(i,t){var e=t.clientX,r=t.clientY;return i.every(function(n){var o=n.popperRect,l=n.popperState,d=n.props,f=d.interactiveBorder,p=Ry(l.placement),g=l.modifiersData.offset;if(!g)return!0;var v=p==="bottom"?g.top.y:0,E=p==="top"?g.bottom.y:0,A=p==="right"?g.left.x:0,T=p==="left"?g.right.x:0,w=o.top-r+v>f,C=r-o.bottom-E>f,D=o.left-e+A>f,M=e-o.right-T>f;return w||C||D||M})}function xc(i,t,e){var r=t+"EventListener";["transitionend","webkitTransitionEnd"].forEach(function(n){i[r](n,e)})}function N0(i,t){for(var e=t;e;){var r;if(i.contains(e))return!0;e=e.getRootNode==null||(r=e.getRootNode())==null?void 0:r.host}return!1}var Mi={isTouch:!1},F0=0;function Py(){Mi.isTouch||(Mi.isTouch=!0,window.performance&&document.addEventListener("mousemove",U0))}function U0(){var i=performance.now();i-F0<20&&(Mi.isTouch=!1,document.removeEventListener("mousemove",U0)),F0=i}function Oy(){var i=document.activeElement;if(Cy(i)){var t=i._tippy;i.blur&&!t.state.isVisible&&i.blur()}}function $y(){document.addEventListener("touchstart",Py,cn),window.addEventListener("blur",Oy)}var My=typeof window<"u"&&typeof document<"u",Ny=My?!!window.msCrypto:!1,Fy={animateFill:!1,followCursor:!1,inlinePositioning:!1,sticky:!1},Uy={allowHTML:!1,animation:"fade",arrow:!0,content:"",inertia:!1,maxWidth:350,role:"tooltip",theme:"",zIndex:9999},ki=Object.assign({appendTo:x0,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},Fy,Uy),By=Object.keys(ki),Gy=function(t){var e=Object.keys(t);e.forEach(function(r){ki[r]=t[r]})};function B0(i){var t=i.plugins||[],e=t.reduce(function(r,n){var o=n.name,l=n.defaultValue;if(o){var d;r[o]=i[o]!==void 0?i[o]:(d=ki[o])!=null?d:l}return r},{});return Object.assign({},i,e)}function Hy(i,t){var e=t?Object.keys(B0(Object.assign({},ki,{plugins:t}))):By,r=e.reduce(function(n,o){var l=(i.getAttribute("data-tippy-"+o)||"").trim();if(!l)return n;if(o==="content")n[o]=l;else try{n[o]=JSON.parse(l)}catch{n[o]=l}return n},{});return r}function G0(i,t){var e=Object.assign({},t,{content:D0(t.content,[i])},t.ignoreAttributes?{}:Hy(i,t.plugins));return e.aria=Object.assign({},ki.aria,e.aria),e.aria={expanded:e.aria.expanded==="auto"?t.interactive:e.aria.expanded,content:e.aria.content==="auto"?t.interactive?null:"describedby":e.aria.content},e}var Vy=function(){return"innerHTML"};function Dc(i,t){i[Vy()]=t}function H0(i){var t=Da();return i===!0?t.className=C0:(t.className=I0,Bo(i)?t.appendChild(i):Dc(t,i)),t}function V0(i,t){Bo(t.content)?(Dc(i,""),i.appendChild(t.content)):typeof t.content!="function"&&(t.allowHTML?Dc(i,t.content):i.textContent=t.content)}function Pc(i){var t=i.firstElementChild,e=Uo(t.children);return{box:t,content:e.find(function(r){return r.classList.contains(L0)}),arrow:e.find(function(r){return r.classList.contains(C0)||r.classList.contains(I0)}),backdrop:e.find(function(r){return r.classList.contains(ky)})}}function W0(i){var t=Da(),e=Da();e.className=Ty,e.setAttribute("data-state","hidden"),e.setAttribute("tabindex","-1");var r=Da();r.className=L0,r.setAttribute("data-state","hidden"),V0(r,i.props),t.appendChild(e),e.appendChild(r),n(i.props,i.props);function n(o,l){var d=Pc(t),f=d.box,p=d.content,g=d.arrow;l.theme?f.setAttribute("data-theme",l.theme):f.removeAttribute("data-theme"),typeof l.animation=="string"?f.setAttribute("data-animation",l.animation):f.removeAttribute("data-animation"),l.inertia?f.setAttribute("data-inertia",""):f.removeAttribute("data-inertia"),f.style.maxWidth=typeof l.maxWidth=="number"?l.maxWidth+"px":l.maxWidth,l.role?f.setAttribute("role",l.role):f.removeAttribute("role"),(o.content!==l.content||o.allowHTML!==l.allowHTML)&&V0(p,i.props),l.arrow?g?o.arrow!==l.arrow&&(f.removeChild(g),f.appendChild(H0(l.arrow))):f.appendChild(H0(l.arrow)):g&&f.removeChild(g)}return{popper:t,onUpdate:n}}W0.$$tippy=!0;var Wy=1,Go=[],Oc=[];function jy(i,t){var e=G0(i,Object.assign({},ki,B0($0(t)))),r,n,o,l=!1,d=!1,f=!1,p=!1,g,v,E,A=[],T=P0(De,e.interactiveDebounce),w,C=Wy++,D=null,M=Sy(e.plugins),U={isEnabled:!0,isVisible:!1,isDestroyed:!1,isMounted:!1,isShown:!1},x={id:C,reference:i,popper:Da(),popperInstance:D,props:e,state:U,plugins:M,clearDelayTimeouts:Be,setProps:br,setContent:cs,show:fr,hide:_i,hideWithInteractivity:Os,enable:We,disable:Pr,unmount:$s,destroy:ai};if(!e.render)return x;var O=e.render(x),K=O.popper,B=O.onUpdate;K.setAttribute("data-tippy-root",""),K.id="tippy-"+x.id,x.popper=K,i._tippy=x,K._tippy=x;var at=M.map(function(ct){return ct.fn(x)}),st=i.hasAttribute("aria-expanded");return Wt(),Z(),bt(),N("onCreate",[x]),e.showOnCreate&&ie(),K.addEventListener("mouseenter",function(){x.props.interactive&&x.state.isVisible&&x.clearDelayTimeouts()}),K.addEventListener("mouseleave",function(){x.props.interactive&&x.props.trigger.indexOf("mouseenter")>=0&&Pt().addEventListener("mousemove",T)}),x;function J(){var ct=x.props.touch;return Array.isArray(ct)?ct:[ct,0]}function kt(){return J()[0]==="hold"}function ft(){var ct;return!!((ct=x.props.render)!=null&&ct.$$tippy)}function wt(){return w||i}function Pt(){var ct=wt().parentNode;return ct?xy(ct):document}function F(){return Pc(K)}function j(ct){return x.state.isMounted&&!x.state.isVisible||Mi.isTouch||g&&g.type==="focus"?0:Lc(x.props.delay,ct?0:1,ki.delay)}function bt(ct){ct===void 0&&(ct=!1),K.style.pointerEvents=x.props.interactive&&!ct?"":"none",K.style.zIndex=""+x.props.zIndex}function N(ct,Ht,Zt){if(Zt===void 0&&(Zt=!0),at.forEach(function(de){de[ct]&&de[ct].apply(de,Ht)}),Zt){var Ae;(Ae=x.props)[ct].apply(Ae,Ht)}}function G(){var ct=x.props.aria;if(ct.content){var Ht="aria-"+ct.content,Zt=K.id,Ae=In(x.props.triggerTarget||i);Ae.forEach(function(de){var lr=de.getAttribute(Ht);if(x.state.isVisible)de.setAttribute(Ht,lr?lr+" "+Zt:Zt);else{var Or=lr&&lr.replace(Zt,"").trim();Or?de.setAttribute(Ht,Or):de.removeAttribute(Ht)}})}}function Z(){if(!(st||!x.props.aria.expanded)){var ct=In(x.props.triggerTarget||i);ct.forEach(function(Ht){x.props.interactive?Ht.setAttribute("aria-expanded",x.state.isVisible&&Ht===wt()?"true":"false"):Ht.removeAttribute("aria-expanded")})}}function gt(){Pt().removeEventListener("mousemove",T),Go=Go.filter(function(ct){return ct!==T})}function vt(ct){if(!(Mi.isTouch&&(f||ct.type==="mousedown"))){var Ht=ct.composedPath&&ct.composedPath()[0]||ct.target;if(!(x.props.interactive&&N0(K,Ht))){if(In(x.props.triggerTarget||i).some(function(Zt){return N0(Zt,Ht)})){if(Mi.isTouch||x.state.isVisible&&x.props.trigger.indexOf("click")>=0)return}else N("onClickOutside",[x,ct]);x.props.hideOnClick===!0&&(x.clearDelayTimeouts(),x.hide(),d=!0,setTimeout(function(){d=!1}),x.state.isMounted||me())}}}function It(){f=!0}function Bt(){f=!1}function Xt(){var ct=Pt();ct.addEventListener("mousedown",vt,!0),ct.addEventListener("touchend",vt,cn),ct.addEventListener("touchstart",Bt,cn),ct.addEventListener("touchmove",It,cn)}function me(){var ct=Pt();ct.removeEventListener("mousedown",vt,!0),ct.removeEventListener("touchend",vt,cn),ct.removeEventListener("touchstart",Bt,cn),ct.removeEventListener("touchmove",It,cn)}function be(ct,Ht){Ye(ct,function(){!x.state.isVisible&&K.parentNode&&K.parentNode.contains(K)&&Ht()})}function Ee(ct,Ht){Ye(ct,Ht)}function Ye(ct,Ht){var Zt=F().box;function Ae(de){de.target===Zt&&(xc(Zt,"remove",Ae),Ht())}if(ct===0)return Ht();xc(Zt,"remove",v),xc(Zt,"add",Ae),v=Ae}function Le(ct,Ht,Zt){Zt===void 0&&(Zt=!1);var Ae=In(x.props.triggerTarget||i);Ae.forEach(function(de){de.addEventListener(ct,Ht,Zt),A.push({node:de,eventType:ct,handler:Ht,options:Zt})})}function Wt(){kt()&&(Le("touchstart",le,{passive:!0}),Le("touchend",Nt,{passive:!0})),wy(x.props.trigger).forEach(function(ct){if(ct!=="manual")switch(Le(ct,le),ct){case"mouseenter":Le("mouseleave",Nt);break;case"focus":Le(Ny?"focusout":"blur",ne);break;case"focusin":Le("focusout",ne);break}})}function se(){A.forEach(function(ct){var Ht=ct.node,Zt=ct.eventType,Ae=ct.handler,de=ct.options;Ht.removeEventListener(Zt,Ae,de)}),A=[]}function le(ct){var Ht,Zt=!1;if(!(!x.state.isEnabled||ee(ct)||d)){var Ae=((Ht=g)==null?void 0:Ht.type)==="focus";g=ct,w=ct.currentTarget,Z(),!x.state.isVisible&&Ly(ct)&&Go.forEach(function(de){return de(ct)}),ct.type==="click"&&(x.props.trigger.indexOf("mouseenter")<0||l)&&x.props.hideOnClick!==!1&&x.state.isVisible?Zt=!0:ie(ct),ct.type==="click"&&(l=!Zt),Zt&&!Ae&&Ie(ct)}}function De(ct){var Ht=ct.target,Zt=wt().contains(Ht)||K.contains(Ht);if(!(ct.type==="mousemove"&&Zt)){var Ae=Ce().concat(K).map(function(de){var lr,Or=de._tippy,vi=(lr=Or.popperInstance)==null?void 0:lr.state;return vi?{popperRect:de.getBoundingClientRect(),popperState:vi,props:e}:null}).filter(Boolean);Dy(Ae,ct)&&(gt(),Ie(ct))}}function Nt(ct){var Ht=ee(ct)||x.props.trigger.indexOf("click")>=0&&l;if(!Ht){if(x.props.interactive){x.hideWithInteractivity(ct);return}Ie(ct)}}function ne(ct){x.props.trigger.indexOf("focusin")<0&&ct.target!==wt()||x.props.interactive&&ct.relatedTarget&&K.contains(ct.relatedTarget)||Ie(ct)}function ee(ct){return Mi.isTouch?kt()!==ct.type.indexOf("touch")>=0:!1}function $e(){Me();var ct=x.props,Ht=ct.popperOptions,Zt=ct.placement,Ae=ct.offset,de=ct.getReferenceClientRect,lr=ct.moveTransition,Or=ft()?Pc(K).arrow:null,vi=de?{getBoundingClientRect:de,contextElement:de.contextElement||wt()}:i,hs={name:"$$tippy",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(Ms){var $r=Ms.state;if(ft()){var ja=F(),Ei=ja.box;["placement","reference-hidden","escaped"].forEach(function(Ns){Ns==="placement"?Ei.setAttribute("data-placement",$r.placement):$r.attributes.popper["data-popper-"+Ns]?Ei.setAttribute("data-"+Ns,""):Ei.removeAttribute("data-"+Ns)}),$r.attributes.popper={}}}},yi=[{name:"offset",options:{offset:Ae}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!lr}},hs];ft()&&Or&&yi.push({name:"arrow",options:{element:Or,padding:3}}),yi.push.apply(yi,(Ht==null?void 0:Ht.modifiers)||[]),x.popperInstance=Ay(vi,K,Object.assign({},Ht,{placement:Zt,onFirstUpdate:E,modifiers:yi}))}function Me(){x.popperInstance&&(x.popperInstance.destroy(),x.popperInstance=null)}function ce(){var ct=x.props.appendTo,Ht,Zt=wt();x.props.interactive&&ct===x0||ct==="parent"?Ht=Zt.parentNode:Ht=D0(ct,[Zt]),Ht.contains(K)||Ht.appendChild(K),x.state.isMounted=!0,$e()}function Ce(){return Uo(K.querySelectorAll("[data-tippy-root]"))}function ie(ct){x.clearDelayTimeouts(),ct&&N("onTrigger",[x,ct]),Xt();var Ht=j(!0),Zt=J(),Ae=Zt[0],de=Zt[1];Mi.isTouch&&Ae==="hold"&&de&&(Ht=de),Ht?r=setTimeout(function(){x.show()},Ht):x.show()}function Ie(ct){if(x.clearDelayTimeouts(),N("onUntrigger",[x,ct]),!x.state.isVisible){me();return}if(!(x.props.trigger.indexOf("mouseenter")>=0&&x.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(ct.type)>=0&&l)){var Ht=j(!1);Ht?n=setTimeout(function(){x.state.isVisible&&x.hide()},Ht):o=requestAnimationFrame(function(){x.hide()})}}function We(){x.state.isEnabled=!0}function Pr(){x.hide(),x.state.isEnabled=!1}function Be(){clearTimeout(r),clearTimeout(n),cancelAnimationFrame(o)}function br(ct){if(!x.state.isDestroyed){N("onBeforeUpdate",[x,ct]),se();var Ht=x.props,Zt=G0(i,Object.assign({},Ht,$0(ct),{ignoreAttributes:!0}));x.props=Zt,Wt(),Ht.interactiveDebounce!==Zt.interactiveDebounce&&(gt(),T=P0(De,Zt.interactiveDebounce)),Ht.triggerTarget&&!Zt.triggerTarget?In(Ht.triggerTarget).forEach(function(Ae){Ae.removeAttribute("aria-expanded")}):Zt.triggerTarget&&i.removeAttribute("aria-expanded"),Z(),bt(),B&&B(Ht,Zt),x.popperInstance&&($e(),Ce().forEach(function(Ae){requestAnimationFrame(Ae._tippy.popperInstance.forceUpdate)})),N("onAfterUpdate",[x,ct])}}function cs(ct){x.setProps({content:ct})}function fr(){var ct=x.state.isVisible,Ht=x.state.isDestroyed,Zt=!x.state.isEnabled,Ae=Mi.isTouch&&!x.props.touch,de=Lc(x.props.duration,0,ki.duration);if(!(ct||Ht||Zt||Ae)&&!wt().hasAttribute("disabled")&&(N("onShow",[x],!1),x.props.onShow(x)!==!1)){if(x.state.isVisible=!0,ft()&&(K.style.visibility="visible"),bt(),Xt(),x.state.isMounted||(K.style.transition="none"),ft()){var lr=F(),Or=lr.box,vi=lr.content;Ic([Or,vi],0)}E=function(){var yi;if(!(!x.state.isVisible||p)){if(p=!0,K.offsetHeight,K.style.transition=x.props.moveTransition,ft()&&x.props.animation){var bi=F(),Ms=bi.box,$r=bi.content;Ic([Ms,$r],de),M0([Ms,$r],"visible")}G(),Z(),O0(Oc,x),(yi=x.popperInstance)==null||yi.forceUpdate(),N("onMount",[x]),x.props.animation&&ft()&&Ee(de,function(){x.state.isShown=!0,N("onShown",[x])})}},ce()}}function _i(){var ct=!x.state.isVisible,Ht=x.state.isDestroyed,Zt=!x.state.isEnabled,Ae=Lc(x.props.duration,1,ki.duration);if(!(ct||Ht||Zt)&&(N("onHide",[x],!1),x.props.onHide(x)!==!1)){if(x.state.isVisible=!1,x.state.isShown=!1,p=!1,l=!1,ft()&&(K.style.visibility="hidden"),gt(),me(),bt(!0),ft()){var de=F(),lr=de.box,Or=de.content;x.props.animation&&(Ic([lr,Or],Ae),M0([lr,Or],"hidden"))}G(),Z(),x.props.animation?ft()&&be(Ae,x.unmount):x.unmount()}}function Os(ct){Pt().addEventListener("mousemove",T),O0(Go,T),T(ct)}function $s(){x.state.isVisible&&x.hide(),x.state.isMounted&&(Me(),Ce().forEach(function(ct){ct._tippy.unmount()}),K.parentNode&&K.parentNode.removeChild(K),Oc=Oc.filter(function(ct){return ct!==x}),x.state.isMounted=!1,N("onHidden",[x]))}function ai(){x.state.isDestroyed||(x.clearDelayTimeouts(),x.unmount(),se(),delete i._tippy,x.state.isDestroyed=!0,N("onDestroy",[x]))}}function hn(i,t){t===void 0&&(t={});var e=ki.plugins.concat(t.plugins||[]);$y();var r=Object.assign({},t,{plugins:e}),n=Iy(i),o=n.reduce(function(l,d){var f=d&&jy(d,r);return f&&l.push(f),l},[]);return Bo(i)?o[0]:o}hn.defaultProps=ki,hn.setDefaultProps=Gy,hn.currentInput=Mi,Object.assign({},u0,{effect:function(t){var e=t.state,r={popper:{position:e.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};Object.assign(e.elements.popper.style,r.popper),e.styles=r,e.elements.arrow&&Object.assign(e.elements.arrow.style,r.arrow)}}),hn.setDefaultProps({render:W0});class Ni extends Error{constructor(t,e=new Error,r=!1){super(),this.fatal=!1,this.fatal=r,this.stack=e.stack,this.message=[t,e.message].filter(Boolean).join(" - ")}}const Ky=5;class zy{constructor(t){this._caption="",this._currentTime=0,this._activeScenes=[],this._upcomingScenes=[],this._canvas=wr(),this._controls=wr(),this.host=t}set activeScenes(t){if(t!==this._activeScenes){const e=t[0],r=this._activeScenes[0];this._activeScenes=t,e!==r&&(this.host.dispatchEvent(new CustomEvent("scenechange",{detail:t[0]})),this.host.requestUpdate())}}get activeScenes(){return this._activeScenes}set currentTime(t){var e,r,n,o,l;const d=Math.min(this.host.duration,Math.max(0,t));this._currentTime=d,this.activeScenes=((e=this.host.scenes)==null?void 0:e.filter(({start:g,duration:v})=>d>=g&&d<g+v))??[],this._upcomingScenes=((r=this.host.scenes)==null?void 0:r.filter(({start:g})=>d>=g-Ky&&d<g))??[],this.loadScenes(),this.syncVideoState(),(n=this._controls.value)==null||n.setAttribute("currentTime",d.toString());const f=this.activeScenes[0],p=t0((o=f==null?void 0:f.videoMeta)==null?void 0:o.captions);this.caption=((l=p.find(({start:g,end:v})=>{var E;const A=d-f.start+(((E=f.videoMeta)==null?void 0:E.start)??0);return g&&v&&A>=Do(g)&&A<=Do(v)}))==null?void 0:l.text)??"",this.draw(d),!this.host.paused&&!this.host.loading&&!this.host.processing&&!this.host.waiting&&this.host.dispatchEvent(new CustomEvent("timeupdate",{detail:d}))}get currentTime(){return this._currentTime}set caption(t){t!==this._caption&&(this._caption=t,this.host.requestUpdate())}get caption(){return this._caption}canvas(){return Sr(this._canvas)}controls(){return Sr(this._controls)}loadScenes(){[...this.activeScenes,...this._upcomingScenes].forEach(t=>{var e,r,n;const{start:o,duration:l,video:d,videoMeta:f}=t,p=this.host.currentTime>0||this.host.preload==="auto"||!this.host.paused;if(d&&f){const{key:g,hls:v,node:E}=d,{start:A,duration:T}=f,w=this.host.videoState[g];E&&w&&(E.currentTime>=A+T||E.ended||p&&(v?(e=v.startLoadOnce)==null||e.call(v,E.currentTime):w.initialised||(r=E.startLoadOnce)==null||r.call(E)))}else if(p){const g=`${o}-${l}`,v=this.host._sceneController.videoState[g];this.host.duration&&!((n=v==null?void 0:v.buffered)!=null&&n.length)&&(this.host._sceneController.videoState={...this.host._sceneController.videoState,[g]:{...v,buffered:[{start:Math.max(0,o/this.host.duration*100),end:Math.min((o+l)/this.host.duration*100,100)}]}})}})}syncVideoState(){var t;(t=this.host.scenes)==null||t.forEach(e=>{if(e.video){const{key:r,node:n}=e.video,o=this.host.videoState[r],l=this.activeScenes.includes(e);if(n&&o)if(l&&!this.host.waiting&&!this.host.loading&&!this.host.paused){if(n.paused&&o.initialised)try{return n.play()}catch(d){throw new Ni("Video play error",d,!0)}}else n.paused||n.pause()}})}draw(t=this.currentTime){var e,r;this.host.sceneConfig&&this._canvas.value&&((r=(e=this.host).compilation)==null||r.call(e,{currentTime:t,scenes:this.host.sceneConfig,canvas:this._canvas.value}))}clear(){var t;const e=this._canvas.value;(t=e==null?void 0:e.getContext("2d"))==null||t.clearRect(0,0,e.width,e.height)}}function Yy(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var j0={exports:{}};(function(i,t){(function(e){var r=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,n=/^(?=([^\/?#]*))\1([^]*)$/,o=/(?:\/|^)\.(?=\/)/g,l=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,d={buildAbsoluteURL:function(f,p,g){if(g=g||{},f=f.trim(),p=p.trim(),!p){if(!g.alwaysNormalize)return f;var v=d.parseURL(f);if(!v)throw new Error("Error trying to parse base URL.");return v.path=d.normalizePath(v.path),d.buildURLFromParts(v)}var E=d.parseURL(p);if(!E)throw new Error("Error trying to parse relative URL.");if(E.scheme)return g.alwaysNormalize?(E.path=d.normalizePath(E.path),d.buildURLFromParts(E)):p;var A=d.parseURL(f);if(!A)throw new Error("Error trying to parse base URL.");if(!A.netLoc&&A.path&&A.path[0]!=="/"){var T=n.exec(A.path);A.netLoc=T[1],A.path=T[2]}A.netLoc&&!A.path&&(A.path="/");var w={scheme:A.scheme,netLoc:E.netLoc,path:null,params:E.params,query:E.query,fragment:E.fragment};if(!E.netLoc&&(w.netLoc=A.netLoc,E.path[0]!=="/"))if(!E.path)w.path=A.path,E.params||(w.params=A.params,E.query||(w.query=A.query));else{var C=A.path,D=C.substring(0,C.lastIndexOf("/")+1)+E.path;w.path=d.normalizePath(D)}return w.path===null&&(w.path=g.alwaysNormalize?d.normalizePath(E.path):E.path),d.buildURLFromParts(w)},parseURL:function(f){var p=r.exec(f);return p?{scheme:p[1]||"",netLoc:p[2]||"",path:p[3]||"",params:p[4]||"",query:p[5]||"",fragment:p[6]||""}:null},normalizePath:function(f){for(f=f.split("").reverse().join("").replace(o,"");f.length!==(f=f.replace(l,"")).length;);return f.split("").reverse().join("")},buildURLFromParts:function(f){return f.scheme+f.netLoc+f.path+f.params+f.query+f.fragment}};i.exports=d})()})(j0);var $c=j0.exports;function K0(i,t){var e=Object.keys(i);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(i);t&&(r=r.filter(function(n){return Object.getOwnPropertyDescriptor(i,n).enumerable})),e.push.apply(e,r)}return e}function zr(i){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?K0(Object(e),!0).forEach(function(r){Xy(i,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(e)):K0(Object(e)).forEach(function(r){Object.defineProperty(i,r,Object.getOwnPropertyDescriptor(e,r))})}return i}function Xy(i,t,e){return t=qy(t),t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}function dr(){return dr=Object.assign?Object.assign.bind():function(i){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(i[r]=e[r])}return i},dr.apply(this,arguments)}function Zy(i,t){if(typeof i!="object"||i===null)return i;var e=i[Symbol.toPrimitive];if(e!==void 0){var r=e.call(i,t||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(i)}function qy(i){var t=Zy(i,"string");return typeof t=="symbol"?t:String(t)}const jt=Number.isFinite||function(i){return typeof i=="number"&&isFinite(i)};let R=function(i){return i.MEDIA_ATTACHING="hlsMediaAttaching",i.MEDIA_ATTACHED="hlsMediaAttached",i.MEDIA_DETACHING="hlsMediaDetaching",i.MEDIA_DETACHED="hlsMediaDetached",i.BUFFER_RESET="hlsBufferReset",i.BUFFER_CODECS="hlsBufferCodecs",i.BUFFER_CREATED="hlsBufferCreated",i.BUFFER_APPENDING="hlsBufferAppending",i.BUFFER_APPENDED="hlsBufferAppended",i.BUFFER_EOS="hlsBufferEos",i.BUFFER_FLUSHING="hlsBufferFlushing",i.BUFFER_FLUSHED="hlsBufferFlushed",i.MANIFEST_LOADING="hlsManifestLoading",i.MANIFEST_LOADED="hlsManifestLoaded",i.MANIFEST_PARSED="hlsManifestParsed",i.LEVEL_SWITCHING="hlsLevelSwitching",i.LEVEL_SWITCHED="hlsLevelSwitched",i.LEVEL_LOADING="hlsLevelLoading",i.LEVEL_LOADED="hlsLevelLoaded",i.LEVEL_UPDATED="hlsLevelUpdated",i.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",i.LEVELS_UPDATED="hlsLevelsUpdated",i.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",i.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",i.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",i.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",i.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",i.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",i.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",i.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",i.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",i.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",i.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",i.CUES_PARSED="hlsCuesParsed",i.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",i.INIT_PTS_FOUND="hlsInitPtsFound",i.FRAG_LOADING="hlsFragLoading",i.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",i.FRAG_LOADED="hlsFragLoaded",i.FRAG_DECRYPTED="hlsFragDecrypted",i.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",i.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",i.FRAG_PARSING_METADATA="hlsFragParsingMetadata",i.FRAG_PARSED="hlsFragParsed",i.FRAG_BUFFERED="hlsFragBuffered",i.FRAG_CHANGED="hlsFragChanged",i.FPS_DROP="hlsFpsDrop",i.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",i.ERROR="hlsError",i.DESTROYING="hlsDestroying",i.KEY_LOADING="hlsKeyLoading",i.KEY_LOADED="hlsKeyLoaded",i.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",i.BACK_BUFFER_REACHED="hlsBackBufferReached",i}({}),Qt=function(i){return i.NETWORK_ERROR="networkError",i.MEDIA_ERROR="mediaError",i.KEY_SYSTEM_ERROR="keySystemError",i.MUX_ERROR="muxError",i.OTHER_ERROR="otherError",i}({}),ut=function(i){return i.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",i.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",i.KEY_SYSTEM_NO_SESSION="keySystemNoSession",i.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",i.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",i.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",i.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",i.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",i.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",i.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",i.MANIFEST_LOAD_ERROR="manifestLoadError",i.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",i.MANIFEST_PARSING_ERROR="manifestParsingError",i.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",i.LEVEL_EMPTY_ERROR="levelEmptyError",i.LEVEL_LOAD_ERROR="levelLoadError",i.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",i.LEVEL_PARSING_ERROR="levelParsingError",i.LEVEL_SWITCH_ERROR="levelSwitchError",i.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",i.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",i.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",i.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",i.FRAG_LOAD_ERROR="fragLoadError",i.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",i.FRAG_DECRYPT_ERROR="fragDecryptError",i.FRAG_PARSING_ERROR="fragParsingError",i.FRAG_GAP="fragGap",i.REMUX_ALLOC_ERROR="remuxAllocError",i.KEY_LOAD_ERROR="keyLoadError",i.KEY_LOAD_TIMEOUT="keyLoadTimeOut",i.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",i.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",i.BUFFER_APPEND_ERROR="bufferAppendError",i.BUFFER_APPENDING_ERROR="bufferAppendingError",i.BUFFER_STALLED_ERROR="bufferStalledError",i.BUFFER_FULL_ERROR="bufferFullError",i.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",i.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",i.INTERNAL_EXCEPTION="internalException",i.INTERNAL_ABORTED="aborted",i.UNKNOWN="unknown",i}({});const dn=function(){},Mc={trace:dn,debug:dn,log:dn,warn:dn,info:dn,error:dn};let Pa=Mc;function Qy(i){const t=self.console[i];return t?t.bind(self.console,`[${i}] >`):dn}function Jy(i,...t){t.forEach(function(e){Pa[e]=i[e]?i[e].bind(i):Qy(e)})}function tb(i,t){if(self.console&&i===!0||typeof i=="object"){Jy(i,"debug","log","info","warn","error");try{Pa.log(`Debug logs enabled for "${t}" in hls.js version 1.4.12`)}catch{Pa=Mc}}else Pa=Mc}const X=Pa,eb=/^(\d+)x(\d+)$/,z0=/(.+?)=(".*?"|.*?)(?:,|$)/g;class tr{constructor(t){typeof t=="string"&&(t=tr.parseAttrList(t));for(const e in t)t.hasOwnProperty(e)&&(e.substring(0,2)==="X-"&&(this.clientAttrs=this.clientAttrs||[],this.clientAttrs.push(e)),this[e]=t[e])}decimalInteger(t){const e=parseInt(this[t],10);return e>Number.MAX_SAFE_INTEGER?1/0:e}hexadecimalInteger(t){if(this[t]){let e=(this[t]||"0x").slice(2);e=(e.length&1?"0":"")+e;const r=new Uint8Array(e.length/2);for(let n=0;n<e.length/2;n++)r[n]=parseInt(e.slice(n*2,n*2+2),16);return r}else return null}hexadecimalIntegerAsNumber(t){const e=parseInt(this[t],16);return e>Number.MAX_SAFE_INTEGER?1/0:e}decimalFloatingPoint(t){return parseFloat(this[t])}optionalFloat(t,e){const r=this[t];return r?parseFloat(r):e}enumeratedString(t){return this[t]}bool(t){return this[t]==="YES"}decimalResolution(t){const e=eb.exec(this[t]);if(e!==null)return{width:parseInt(e[1],10),height:parseInt(e[2],10)}}static parseAttrList(t){let e;const r={},n='"';for(z0.lastIndex=0;(e=z0.exec(t))!==null;){let o=e[2];o.indexOf(n)===0&&o.lastIndexOf(n)===o.length-1&&(o=o.slice(1,-1));const l=e[1].trim();r[l]=o}return r}}function rb(i){return i!=="ID"&&i!=="CLASS"&&i!=="START-DATE"&&i!=="DURATION"&&i!=="END-DATE"&&i!=="END-ON-NEXT"}function ib(i){return i==="SCTE35-OUT"||i==="SCTE35-IN"}class Y0{constructor(t,e){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,e){const r=e.attr;for(const n in r)if(Object.prototype.hasOwnProperty.call(t,n)&&t[n]!==r[n]){X.warn(`DATERANGE tag attribute: "${n}" does not match for tags with ID: "${t.ID}"`),this._badValueForSameId=n;break}t=dr(new tr({}),r,t)}if(this.attr=t,this._startDate=new Date(t["START-DATE"]),"END-DATE"in this.attr){const r=new Date(this.attr["END-DATE"]);jt(r.getTime())&&(this._endDate=r)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get startDate(){return this._startDate}get endDate(){if(this._endDate)return this._endDate;const t=this.duration;return t!==null?new Date(this._startDate.getTime()+t*1e3):null}get duration(){if("DURATION"in this.attr){const t=this.attr.decimalFloatingPoint("DURATION");if(jt(t))return t}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isValid(){return!!this.id&&!this._badValueForSameId&&jt(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}class Ho{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 Oe={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"};class X0{constructor(t){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[Oe.AUDIO]:null,[Oe.VIDEO]:null,[Oe.AUDIOVIDEO]:null},this.baseurl=t}setByteRange(t,e){const r=t.split("@",2),n=[];r.length===1?n[0]=e?e.byteRangeEndOffset:0:n[0]=parseInt(r[1]),n[1]=parseInt(r[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=$c.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(t){this._url=t}}class Nc extends X0{constructor(t,e){super(e),this._decryptdata=null,this.rawProgramDateTime=null,this.programDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.stats=new Ho,this.urlId=0,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.type=t}get decryptdata(){const{levelkeys:t}=this;if(!t&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){const e=this.levelkeys.identity;if(e)this._decryptdata=e.getDecryptData(this.sn);else{const r=Object.keys(this.levelkeys);if(r.length===1)return this._decryptdata=this.levelkeys[r[0]].getDecryptData(this.sn)}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(this.programDateTime===null||!jt(this.programDateTime))return null;const t=jt(this.duration)?this.duration:0;return this.programDateTime+t*1e3}get encrypted(){var t;if((t=this._decryptdata)!=null&&t.encrypted)return!0;if(this.levelkeys){const e=Object.keys(this.levelkeys),r=e.length;if(r>1||r===1&&this.levelkeys[e[0]].encrypted)return!0}return!1}setKeyFormat(t){if(this.levelkeys){const e=this.levelkeys[t];e&&!this._decryptdata&&(this._decryptdata=e.getDecryptData(this.sn))}}abortRequests(){var t,e;(t=this.loader)==null||t.abort(),(e=this.keyLoader)==null||e.abort()}setElementaryStreamInfo(t,e,r,n,o,l=!1){const{elementaryStreams:d}=this,f=d[t];if(!f){d[t]={startPTS:e,endPTS:r,startDTS:n,endDTS:o,partial:l};return}f.startPTS=Math.min(f.startPTS,e),f.endPTS=Math.max(f.endPTS,r),f.startDTS=Math.min(f.startDTS,n),f.endDTS=Math.max(f.endDTS,o)}clearElementaryStreamInfo(){const{elementaryStreams:t}=this;t[Oe.AUDIO]=null,t[Oe.VIDEO]=null,t[Oe.AUDIOVIDEO]=null}}class sb extends X0{constructor(t,e,r,n,o){super(r),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 Ho,this.duration=t.decimalFloatingPoint("DURATION"),this.gap=t.bool("GAP"),this.independent=t.bool("INDEPENDENT"),this.relurl=t.enumeratedString("URI"),this.fragment=e,this.index=n;const l=t.enumeratedString("BYTERANGE");l&&this.setByteRange(l,o),o&&(this.fragOffset=o.fragOffset+o.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){const{elementaryStreams:t}=this;return!!(t.audio||t.video||t.audiovideo)}}const nb=10;class ab{constructor(t){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=t}reloaded(t){if(!t){this.advanced=!0,this.updated=!0;return}const e=this.lastPartSn-t.lastPartSn,r=this.lastPartIndex-t.lastPartIndex;this.updated=this.endSN!==t.endSN||!!r||!!e||!this.live,this.advanced=this.endSN>t.endSN||e>0||e===0&&r>0,this.updated||this.advanced?this.misses=Math.floor(t.misses*.6):this.misses=t.misses+1,this.availabilityDelay=t.availabilityDelay}get hasProgramDateTime(){return this.fragments.length?jt(this.fragments[this.fragments.length-1].programDateTime):!1}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||nb}get drift(){const t=this.driftEndTime-this.driftStartTime;return t>0?(this.driftEnd-this.driftStart)*1e3/t:1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var t;return(t=this.partList)!=null&&t.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){var t;return(t=this.fragments)!=null&&t.length?this.fragments[this.fragments.length-1].end:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var t;return(t=this.partList)!=null&&t.length?this.partList[this.partList.length-1].index:-1}get lastPartSn(){var t;return(t=this.partList)!=null&&t.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}function Fc(i){return Uint8Array.from(atob(i),t=>t.charCodeAt(0))}function ob(i){const t=Z0(i).subarray(0,16),e=new Uint8Array(16);return e.set(t,16-t.length),e}function lb(i){const t=function(e,r,n){const o=e[r];e[r]=e[n],e[n]=o};t(i,0,3),t(i,1,2),t(i,4,5),t(i,6,7)}function cb(i){const t=i.split(":");let e=null;if(t[0]==="data"&&t.length===2){const r=t[1].split(";"),n=r[r.length-1].split(",");if(n.length===2){const o=n[0]==="base64",l=n[1];o?(r.splice(-1,1),e=Fc(l)):e=ob(l)}}return e}function Z0(i){return Uint8Array.from(unescape(encodeURIComponent(i)),t=>t.charCodeAt(0))}var er={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},Yr={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function q0(i){switch(i){case Yr.FAIRPLAY:return er.FAIRPLAY;case Yr.PLAYREADY:return er.PLAYREADY;case Yr.WIDEVINE:return er.WIDEVINE;case Yr.CLEARKEY:return er.CLEARKEY}}var Q0={WIDEVINE:"edef8ba979d64acea3c827dcd51d21ed"};function hb(i){if(i===Q0.WIDEVINE)return er.WIDEVINE}function J0(i){switch(i){case er.FAIRPLAY:return Yr.FAIRPLAY;case er.PLAYREADY:return Yr.PLAYREADY;case er.WIDEVINE:return Yr.WIDEVINE;case er.CLEARKEY:return Yr.CLEARKEY}}function Uc(i){const{drmSystems:t,widevineLicenseUrl:e}=i,r=t?[er.FAIRPLAY,er.WIDEVINE,er.PLAYREADY,er.CLEARKEY].filter(n=>!!t[n]):[];return!r[er.WIDEVINE]&&e&&r.push(er.WIDEVINE),r}const tf=function(){return typeof self<"u"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function db(i,t,e,r){let n;switch(i){case er.FAIRPLAY:n=["cenc","sinf"];break;case er.WIDEVINE:case er.PLAYREADY:n=["cenc"];break;case er.CLEARKEY:n=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${i}`)}return ub(n,t,e,r)}function ub(i,t,e,r){return[{initDataTypes:i,persistentState:r.persistentState||"not-allowed",distinctiveIdentifier:r.distinctiveIdentifier||"not-allowed",sessionTypes:r.sessionTypes||[r.sessionType||"temporary"],audioCapabilities:t.map(n=>({contentType:`audio/mp4; codecs="${n}"`,robustness:r.audioRobustness||"",encryptionScheme:r.audioEncryptionScheme||null})),videoCapabilities:e.map(n=>({contentType:`video/mp4; codecs="${n}"`,robustness:r.videoRobustness||"",encryptionScheme:r.videoEncryptionScheme||null}))}]}function un(i,t,e){return Uint8Array.prototype.slice?i.slice(t,e):new Uint8Array(Array.prototype.slice.call(i,t,e))}const Bc=(i,t)=>t+10<=i.length&&i[t]===73&&i[t+1]===68&&i[t+2]===51&&i[t+3]<255&&i[t+4]<255&&i[t+6]<128&&i[t+7]<128&&i[t+8]<128&&i[t+9]<128,ef=(i,t)=>t+10<=i.length&&i[t]===51&&i[t+1]===68&&i[t+2]===73&&i[t+3]<255&&i[t+4]<255&&i[t+6]<128&&i[t+7]<128&&i[t+8]<128&&i[t+9]<128,Vo=(i,t)=>{const e=t;let r=0;for(;Bc(i,t);){r+=10;const n=Wo(i,t+6);r+=n,ef(i,t+10)&&(r+=10),t+=r}if(r>0)return i.subarray(e,e+r)},Wo=(i,t)=>{let e=0;return e=(i[t]&127)<<21,e|=(i[t+1]&127)<<14,e|=(i[t+2]&127)<<7,e|=i[t+3]&127,e},fb=(i,t)=>Bc(i,t)&&Wo(i,t+6)+10<=i.length-t,pb=i=>{const t=sf(i);for(let e=0;e<t.length;e++){const r=t[e];if(rf(r))return Eb(r)}},rf=i=>i&&i.key==="PRIV"&&i.info==="com.apple.streaming.transportStreamTimestamp",gb=i=>{const t=String.fromCharCode(i[0],i[1],i[2],i[3]),e=Wo(i,4),r=10;return{type:t,size:e,data:i.subarray(r,r+e)}},sf=i=>{let t=0;const e=[];for(;Bc(i,t);){const r=Wo(i,t+6);t+=10;const n=t+r;for(;t+8<n;){const o=gb(i.subarray(t)),l=mb(o);l&&e.push(l),t+=o.size+10}ef(i,t)&&(t+=10)}return e},mb=i=>i.type==="PRIV"?vb(i):i.type[0]==="W"?bb(i):yb(i),vb=i=>{if(i.size<2)return;const t=Fi(i.data,!0),e=new Uint8Array(i.data.subarray(t.length+1));return{key:i.type,info:t,data:e.buffer}},yb=i=>{if(i.size<2)return;if(i.type==="TXXX"){let e=1;const r=Fi(i.data.subarray(e),!0);e+=r.length+1;const n=Fi(i.data.subarray(e));return{key:i.type,info:r,data:n}}const t=Fi(i.data.subarray(1));return{key:i.type,data:t}},bb=i=>{if(i.type==="WXXX"){if(i.size<2)return;let e=1;const r=Fi(i.data.subarray(e),!0);e+=r.length+1;const n=Fi(i.data.subarray(e));return{key:i.type,info:r,data:n}}const t=Fi(i.data);return{key:i.type,data:t}},Eb=i=>{if(i.data.byteLength===8){const t=new Uint8Array(i.data),e=t[3]&1;let r=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return r/=45,e&&(r+=4772185884e-2),Math.round(r)}},Fi=(i,t=!1)=>{const e=Ab();if(e){const p=e.decode(i);if(t){const g=p.indexOf("\0");return g!==-1?p.substring(0,g):p}return p.replace(/\0/g,"")}const r=i.length;let n,o,l,d="",f=0;for(;f<r;){if(n=i[f++],n===0&&t)return d;if(!(n===0||n===3))switch(n>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:d+=String.fromCharCode(n);break;case 12:case 13:o=i[f++],d+=String.fromCharCode((n&31)<<6|o&63);break;case 14:o=i[f++],l=i[f++],d+=String.fromCharCode((n&15)<<12|(o&63)<<6|(l&63)<<0);break}}return d};let Gc;function Ab(){return!Gc&&typeof self.TextDecoder<"u"&&(Gc=new self.TextDecoder("utf-8")),Gc}const Ui={hexDump:function(i){let t="";for(let e=0;e<i.length;e++){let r=i[e].toString(16);r.length<2&&(r="0"+r),t+=r}return t}},jo=Math.pow(2,32)-1,Tb=[].push,nf={video:1,audio:2,id3:3,text:4};function _r(i){return String.fromCharCode.apply(null,i)}function af(i,t){const e=i[t]<<8|i[t+1];return e<0?65536+e:e}function re(i,t){const e=of(i,t);return e<0?4294967296+e:e}function of(i,t){return i[t]<<24|i[t+1]<<16|i[t+2]<<8|i[t+3]}function Hc(i,t,e){i[t]=e>>24,i[t+1]=e>>16&255,i[t+2]=e>>8&255,i[t+3]=e&255}function Te(i,t){const e=[];if(!t.length)return e;const r=i.byteLength;for(let n=0;n<r;){const o=re(i,n),l=_r(i.subarray(n+4,n+8)),d=o>1?n+o:r;if(l===t[0])if(t.length===1)e.push(i.subarray(n+8,d));else{const f=Te(i.subarray(n+8,d),t.slice(1));f.length&&Tb.apply(e,f)}n=d}return e}function kb(i){const t=[],e=i[0];let r=8;const n=re(i,r);r+=4;const o=0,l=0;e===0?r+=8:r+=16,r+=2;let d=i.length+l;const f=af(i,r);r+=2;for(let p=0;p<f;p++){let g=r;const v=re(i,g);g+=4;const E=v&2147483647;if((v&2147483648)>>>31===1)return X.warn("SIDX has hierarchical references (not supported)"),null;const A=re(i,g);g+=4,t.push({referenceSize:E,subsegmentDuration:A,info:{duration:A/n,start:d,end:d+E-1}}),d+=E,g+=4,r=g}return{earliestPresentationTime:o,timescale:n,version:e,referencesCount:f,references:t}}function lf(i){const t=[],e=Te(i,["moov","trak"]);for(let r=0;r<e.length;r++){const n=e[r],o=Te(n,["tkhd"])[0];if(o){let l=o[0],d=l===0?12:20;const f=re(o,d),p=Te(n,["mdia","mdhd"])[0];if(p){l=p[0],d=l===0?12:20;const g=re(p,d),v=Te(n,["mdia","hdlr"])[0];if(v){const E=_r(v.subarray(8,12)),A={soun:Oe.AUDIO,vide:Oe.VIDEO}[E];if(A){const T=Te(n,["mdia","minf","stbl","stsd"])[0];let w;T&&(w=_r(T.subarray(12,16))),t[f]={timescale:g,type:A},t[A]={timescale:g,id:f,codec:w}}}}}}return Te(i,["moov","mvex","trex"]).forEach(r=>{const n=re(r,4),o=t[n];o&&(o.default={duration:re(r,12),flags:re(r,20)})}),t}function wb(i,t){if(!i||!t)return i;const e=t.keyId;return e&&t.isCommonEncryption&&Te(i,["moov","trak"]).forEach(r=>{const n=Te(r,["mdia","minf","stbl","stsd"])[0].subarray(8);let o=Te(n,["enca"]);const l=o.length>0;l||(o=Te(n,["encv"])),o.forEach(d=>{const f=l?d.subarray(28):d.subarray(78);Te(f,["sinf"]).forEach(p=>{const g=cf(p);if(g){const v=g.subarray(8,24);v.some(E=>E!==0)||(X.log(`[eme] Patching keyId in 'enc${l?"a":"v"}>sinf>>tenc' box: ${Ui.hexDump(v)} -> ${Ui.hexDump(e)}`),g.set(e,8))}})})}),i}function cf(i){const t=Te(i,["schm"])[0];if(t){const e=_r(t.subarray(4,8));if(e==="cbcs"||e==="cenc")return Te(i,["schi","tenc"])[0]}return X.error("[eme] missing 'schm' box"),null}function Sb(i,t){return Te(t,["moof","traf"]).reduce((e,r)=>{const n=Te(r,["tfdt"])[0],o=n[0],l=Te(r,["tfhd"]).reduce((d,f)=>{const p=re(f,4),g=i[p];if(g){let v=re(n,4);if(o===1){if(v===jo)return X.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),d;v*=jo+1,v+=re(n,8)}const E=g.timescale||9e4,A=v/E;if(isFinite(A)&&(d===null||A<d))return A}return d},null);return l!==null&&isFinite(l)&&(e===null||l<e)?l:e},null)}function Rb(i,t){let e=0,r=0,n=0;const o=Te(i,["moof","traf"]);for(let l=0;l<o.length;l++){const d=o[l],f=Te(d,["tfhd"])[0],p=re(f,4),g=t[p];if(!g)continue;const v=g.default,E=re(f,0)|(v==null?void 0:v.flags);let A=v==null?void 0:v.duration;E&8&&(E&2?A=re(f,12):A=re(f,8));const T=g.timescale||9e4,w=Te(d,["trun"]);for(let C=0;C<w.length;C++){if(e=_b(w[C]),!e&&A){const D=re(w[C],4);e=A*D}g.type===Oe.VIDEO?r+=e/T:g.type===Oe.AUDIO&&(n+=e/T)}}if(r===0&&n===0){let l=0;const d=Te(i,["sidx"]);for(let f=0;f<d.length;f++){const p=kb(d[f]);p!=null&&p.references&&(l+=p.references.reduce((g,v)=>g+v.info.duration||0,0))}return l}return r||n}function _b(i){const t=re(i,0);let e=8;t&1&&(e+=4),t&4&&(e+=4);let r=0;const n=re(i,4);for(let o=0;o<n;o++){if(t&256){const l=re(i,e);r+=l,e+=4}t&512&&(e+=4),t&1024&&(e+=4),t&2048&&(e+=4)}return r}function Lb(i,t,e){Te(t,["moof","traf"]).forEach(r=>{Te(r,["tfhd"]).forEach(n=>{const o=re(n,4),l=i[o];if(!l)return;const d=l.timescale||9e4;Te(r,["tfdt"]).forEach(f=>{const p=f[0];let g=re(f,4);if(p===0)g-=e*d,g=Math.max(g,0),Hc(f,4,g);else{g*=Math.pow(2,32),g+=re(f,8),g-=e*d,g=Math.max(g,0);const v=Math.floor(g/(jo+1)),E=Math.floor(g%(jo+1));Hc(f,4,v),Hc(f,8,E)}})})})}function Cb(i){const t={valid:null,remainder:null},e=Te(i,["moof"]);if(e){if(e.length<2)return t.remainder=i,t}else return t;const r=e[e.length-1];return t.valid=un(i,0,r.byteOffset-8),t.remainder=un(i,r.byteOffset-8),t}function fn(i,t){const e=new Uint8Array(i.length+t.length);return e.set(i),e.set(t,i.length),e}function hf(i,t){const e=[],r=t.samples,n=t.timescale,o=t.id;let l=!1;return Te(r,["moof"]).map(d=>{const f=d.byteOffset-8;Te(d,["traf"]).map(p=>{const g=Te(p,["tfdt"]).map(v=>{const E=v[0];let A=re(v,4);return E===1&&(A*=Math.pow(2,32),A+=re(v,8)),A/n})[0];return g!==void 0&&(i=g),Te(p,["tfhd"]).map(v=>{const E=re(v,4),A=re(v,0)&16777215,T=(A&1)!==0,w=(A&2)!==0,C=(A&8)!==0;let D=0;const M=(A&16)!==0;let U=0;const x=(A&32)!==0;let O=8;E===o&&(T&&(O+=8),w&&(O+=4),C&&(D=re(v,O),O+=4),M&&(U=re(v,O),O+=4),x&&(O+=4),t.type==="video"&&(l=Ib(t.codec)),Te(p,["trun"]).map(K=>{const B=K[0],at=re(K,0)&16777215,st=(at&1)!==0;let J=0;const kt=(at&4)!==0,ft=(at&256)!==0;let wt=0;const Pt=(at&512)!==0;let F=0;const j=(at&1024)!==0,bt=(at&2048)!==0;let N=0;const G=re(K,4);let Z=8;st&&(J=re(K,Z),Z+=4),kt&&(Z+=4);let gt=J+f;for(let vt=0;vt<G;vt++){if(ft?(wt=re(K,Z),Z+=4):wt=D,Pt?(F=re(K,Z),Z+=4):F=U,j&&(Z+=4),bt&&(B===0?N=re(K,Z):N=of(K,Z),Z+=4),t.type===Oe.VIDEO){let It=0;for(;It<F;){const Bt=re(r,gt);if(gt+=4,xb(l,r[gt])){const Xt=r.subarray(gt,gt+Bt);df(Xt,l?2:1,i+N/n,e)}gt+=Bt,It+=Bt+4}}i+=wt/n}}))})})}),e}function Ib(i){if(!i)return!1;const t=i.indexOf("."),e=t<0?i:i.substring(0,t);return e==="hvc1"||e==="hev1"||e==="dvh1"||e==="dvhe"}function xb(i,t){if(i){const e=t>>1&63;return e===39||e===40}else return(t&31)===6}function df(i,t,e,r){const n=uf(i);let o=0;o+=t;let l=0,d=0,f=!1,p=0;for(;o<n.length;){l=0;do{if(o>=n.length)break;p=n[o++],l+=p}while(p===255);d=0;do{if(o>=n.length)break;p=n[o++],d+=p}while(p===255);const g=n.length-o;if(!f&&l===4&&o<n.length){if(f=!0,n[o++]===181){const v=af(n,o);if(o+=2,v===49){const E=re(n,o);if(o+=4,E===1195456820){const A=n[o++];if(A===3){const T=n[o++],w=31&T,C=64&T,D=C?2+w*3:0,M=new Uint8Array(D);if(C){M[0]=T;for(let U=1;U<D;U++)M[U]=n[o++]}r.push({type:A,payloadType:l,pts:e,bytes:M})}}}}}else if(l===5&&d<g){if(f=!0,d>16){const v=[];for(let T=0;T<16;T++){const w=n[o++].toString(16);v.push(w.length==1?"0"+w:w),(T===3||T===5||T===7||T===9)&&v.push("-")}const E=d-16,A=new Uint8Array(E);for(let T=0;T<E;T++)A[T]=n[o++];r.push({payloadType:l,pts:e,uuid:v.join(""),userData:Fi(A),userDataBytes:A})}}else if(d<g)o+=d;else if(d>g)break}}function uf(i){const t=i.byteLength,e=[];let r=1;for(;r<t-2;)i[r]===0&&i[r+1]===0&&i[r+2]===3?(e.push(r+2),r+=2):r++;if(e.length===0)return i;const n=t-e.length,o=new Uint8Array(n);let l=0;for(r=0;r<n;l++,r++)l===e[0]&&(l++,e.shift()),o[r]=i[l];return o}function Db(i){const t=i[0];let e="",r="",n=0,o=0,l=0,d=0,f=0,p=0;if(t===0){for(;_r(i.subarray(p,p+1))!=="\0";)e+=_r(i.subarray(p,p+1)),p+=1;for(e+=_r(i.subarray(p,p+1)),p+=1;_r(i.subarray(p,p+1))!=="\0";)r+=_r(i.subarray(p,p+1)),p+=1;r+=_r(i.subarray(p,p+1)),p+=1,n=re(i,12),o=re(i,16),d=re(i,20),f=re(i,24),p=28}else if(t===1){p+=4,n=re(i,p),p+=4;const v=re(i,p);p+=4;const E=re(i,p);for(p+=4,l=4294967296*v+E,Number.isSafeInteger(l)||(l=Number.MAX_SAFE_INTEGER,X.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),d=re(i,p),p+=4,f=re(i,p),p+=4;_r(i.subarray(p,p+1))!=="\0";)e+=_r(i.subarray(p,p+1)),p+=1;for(e+=_r(i.subarray(p,p+1)),p+=1;_r(i.subarray(p,p+1))!=="\0";)r+=_r(i.subarray(p,p+1)),p+=1;r+=_r(i.subarray(p,p+1)),p+=1}const g=i.subarray(p,i.byteLength);return{schemeIdUri:e,value:r,timeScale:n,presentationTime:l,presentationTimeDelta:o,eventDuration:d,id:f,payload:g}}function Pb(i,...t){const e=t.length;let r=8,n=e;for(;n--;)r+=t[n].byteLength;const o=new Uint8Array(r);for(o[0]=r>>24&255,o[1]=r>>16&255,o[2]=r>>8&255,o[3]=r&255,o.set(i,4),n=0,r=8;n<e;n++)o.set(t[n],r),r+=t[n].byteLength;return o}function Ob(i,t,e){if(i.byteLength!==16)throw new RangeError("Invalid system id");let r,n;if(t){r=1,n=new Uint8Array(t.length*16);for(let d=0;d<t.length;d++){const f=t[d];if(f.byteLength!==16)throw new RangeError("Invalid key");n.set(f,d*16)}}else r=0,n=new Uint8Array;let o;r>0?(o=new Uint8Array(4),t.length>0&&new DataView(o.buffer).setUint32(0,t.length,!1)):o=new Uint8Array;const l=new Uint8Array(4);return e&&e.byteLength>0&&new DataView(l.buffer).setUint32(0,e.byteLength,!1),Pb([112,115,115,104],new Uint8Array([r,0,0,0]),i,o,n,l,e||new Uint8Array)}function $b(i){if(!(i instanceof ArrayBuffer)||i.byteLength<32)return null;const t={version:0,systemId:"",kids:null,data:null},e=new DataView(i),r=e.getUint32(0);if(i.byteLength!==r&&r>44||e.getUint32(4)!==1886614376||(t.version=e.getUint32(8)>>>24,t.version>1))return null;t.systemId=Ui.hexDump(new Uint8Array(i,12,16));const n=e.getUint32(28);if(t.version===0){if(r-32<n)return null;t.data=new Uint8Array(i,32,n)}else if(t.version===1){t.kids=[];for(let o=0;o<n;o++)t.kids.push(new Uint8Array(i,32+o*16,16))}return t}let Ko={};class Oa{static clearKeyUriToKeyIdMap(){Ko={}}constructor(t,e,r,n=[1],o=null){this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=t,this.uri=e,this.keyFormat=r,this.keyFormatVersions=n,this.iv=o,this.encrypted=t?t!=="NONE":!1,this.isCommonEncryption=this.encrypted&&t!=="AES-128"}isSupported(){if(this.method){if(this.method==="AES-128"||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES";switch(this.keyFormat){case Yr.FAIRPLAY:case Yr.WIDEVINE:case Yr.PLAYREADY:case Yr.CLEARKEY:return["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1}getDecryptData(t){if(!this.encrypted||!this.uri)return null;if(this.method==="AES-128"&&this.uri&&!this.iv){typeof t!="number"&&(this.method==="AES-128"&&!this.iv&&X.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),t=0);const r=Mb(t);return new Oa(this.method,this.uri,"identity",this.keyFormatVersions,r)}const e=cb(this.uri);if(e)switch(this.keyFormat){case Yr.WIDEVINE:this.pssh=e,e.length>=22&&(this.keyId=e.subarray(e.length-22,e.length-6));break;case Yr.PLAYREADY:{const r=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=Ob(r,null,e);const n=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2),o=String.fromCharCode.apply(null,Array.from(n)),l=o.substring(o.indexOf("<"),o.length),d=new DOMParser().parseFromString(l,"text/xml").getElementsByTagName("KID")[0];if(d){const f=d.childNodes[0]?d.childNodes[0].nodeValue:d.getAttribute("VALUE");if(f){const p=Fc(f).subarray(0,16);lb(p),this.keyId=p}}break}default:{let r=e.subarray(0,16);if(r.length!==16){const n=new Uint8Array(16);n.set(r,16-r.length),r=n}this.keyId=r;break}}if(!this.keyId||this.keyId.byteLength!==16){let r=Ko[this.uri];if(!r){const n=Object.keys(Ko).length%Number.MAX_SAFE_INTEGER;r=new Uint8Array(16),new DataView(r.buffer,12,4).setUint32(0,n),Ko[this.uri]=r}this.keyId=r}return this}}function Mb(i){const t=new Uint8Array(16);for(let e=12;e<16;e++)t[e]=i>>8*(15-e)&255;return t}const ff=/\{\$([a-zA-Z0-9-_]+)\}/g;function pf(i){return ff.test(i)}function Xr(i,t,e){if(i.variableList!==null||i.hasVariableRefs)for(let r=e.length;r--;){const n=e[r],o=t[n];o&&(t[n]=Vc(i,o))}}function Vc(i,t){if(i.variableList!==null||i.hasVariableRefs){const e=i.variableList;return t.replace(ff,r=>{const n=r.substring(2,r.length-1),o=e==null?void 0:e[n];return o===void 0?(i.playlistParsingError||(i.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${n}"`)),r):o})}return t}function gf(i,t,e){let r=i.variableList;r||(i.variableList=r={});let n,o;if("QUERYPARAM"in t){n=t.QUERYPARAM;try{const l=new self.URL(e).searchParams;if(l.has(n))o=l.get(n);else throw new Error(`"${n}" does not match any query parameter in URI: "${e}"`)}catch(l){i.playlistParsingError||(i.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${l.message}`))}}else n=t.NAME,o=t.VALUE;n in r?i.playlistParsingError||(i.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${n}"`)):r[n]=o||""}function Nb(i,t,e){const r=t.IMPORT;if(e&&r in e){let n=i.variableList;n||(i.variableList=n={}),n[r]=e[r]}else i.playlistParsingError||(i.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${r}"`))}function zo(){if(!(typeof self>"u"))return self.MediaSource||self.WebKitMediaSource}const Fb={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}},mf=zo();function Ub(i,t){const e=Fb[t];return!!e&&e[i.slice(0,4)]===!0}function Wc(i,t){var e;return(e=mf==null?void 0:mf.isTypeSupported(`${t||"video"}/mp4;codecs="${i}"`))!=null?e:!1}const vf=/#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,yf=/#EXT-X-MEDIA:(.*)/g,Bb=/^#EXT(?:INF|-X-TARGETDURATION):/m,bf=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),Gb=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 wi{static findGroup(t,e){for(let r=0;r<t.length;r++){const n=t[r];if(n.id===e)return n}}static convertAVC1ToAVCOTI(t){const e=t.split(".");if(e.length>2){let r=e.shift()+".";return r+=parseInt(e.shift()).toString(16),r+=("000"+parseInt(e.shift()).toString(16)).slice(-4),r}return t}static resolve(t,e){return $c.buildAbsoluteURL(e,t,{alwaysNormalize:!0})}static isMediaPlaylist(t){return Bb.test(t)}static parseMasterPlaylist(t,e){const r=pf(t),n={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:r},o=[];vf.lastIndex=0;let l;for(;(l=vf.exec(t))!=null;)if(l[1]){var d;const p=new tr(l[1]);Xr(n,p,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);const g=Vc(n,l[2]),v={attrs:p,bitrate:p.decimalInteger("AVERAGE-BANDWIDTH")||p.decimalInteger("BANDWIDTH"),name:p.NAME,url:wi.resolve(g,e)},E=p.decimalResolution("RESOLUTION");E&&(v.width=E.width,v.height=E.height),Hb((p.CODECS||"").split(/[ ,]+/).filter(A=>A),v),v.videoCodec&&v.videoCodec.indexOf("avc1")!==-1&&(v.videoCodec=wi.convertAVC1ToAVCOTI(v.videoCodec)),(d=v.unknownCodecs)!=null&&d.length||o.push(v),n.levels.push(v)}else if(l[3]){const p=l[3],g=l[4];switch(p){case"SESSION-DATA":{const v=new tr(g);Xr(n,v,["DATA-ID","LANGUAGE","VALUE","URI"]);const E=v["DATA-ID"];E&&(n.sessionData===null&&(n.sessionData={}),n.sessionData[E]=v);break}case"SESSION-KEY":{const v=Ef(g,e,n);v.encrypted&&v.isSupported()?(n.sessionKeys===null&&(n.sessionKeys=[]),n.sessionKeys.push(v)):X.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${g}"`);break}case"DEFINE":{{const v=new tr(g);Xr(n,v,["NAME","VALUE","QUERYPARAM"]),gf(n,v,e)}break}case"CONTENT-STEERING":{const v=new tr(g);Xr(n,v,["SERVER-URI","PATHWAY-ID"]),n.contentSteering={uri:wi.resolve(v["SERVER-URI"],e),pathwayId:v["PATHWAY-ID"]||"."};break}case"START":{n.startTimeOffset=Af(g);break}}}const f=o.length>0&&o.length<n.levels.length;return n.levels=f?o:n.levels,n.levels.length===0&&(n.playlistParsingError=new Error("no levels found in manifest")),n}static parseMasterPlaylistMedia(t,e,r){let n;const o={},l=r.levels,d={AUDIO:l.map(p=>({id:p.attrs.AUDIO,audioCodec:p.audioCodec})),SUBTITLES:l.map(p=>({id:p.attrs.SUBTITLES,textCodec:p.textCodec})),"CLOSED-CAPTIONS":[]};let f=0;for(yf.lastIndex=0;(n=yf.exec(t))!==null;){const p=new tr(n[1]),g=p.TYPE;if(g){const v=d[g],E=o[g]||[];o[g]=E,Xr(r,p,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);const A={attrs:p,bitrate:0,id:f++,groupId:p["GROUP-ID"]||"",instreamId:p["INSTREAM-ID"],name:p.NAME||p.LANGUAGE||"",type:g,default:p.bool("DEFAULT"),autoselect:p.bool("AUTOSELECT"),forced:p.bool("FORCED"),lang:p.LANGUAGE,url:p.URI?wi.resolve(p.URI,e):""};if(v!=null&&v.length){const T=wi.findGroup(v,A.groupId)||v[0];Tf(A,T,"audioCodec"),Tf(A,T,"textCodec")}E.push(A)}}return o}static parseLevelPlaylist(t,e,r,n,o,l){const d=new ab(e),f=d.fragments;let p=null,g=0,v=0,E=0,A=0,T=null,w=new Nc(n,e),C,D,M,U=-1,x=!1;for(bf.lastIndex=0,d.m3u8=t,d.hasVariableRefs=pf(t);(C=bf.exec(t))!==null;){x&&(x=!1,w=new Nc(n,e),w.start=E,w.sn=g,w.cc=A,w.level=r,p&&(w.initSegment=p,w.rawProgramDateTime=p.rawProgramDateTime,p.rawProgramDateTime=null));const at=C[1];if(at){w.duration=parseFloat(at);const st=(" "+C[2]).slice(1);w.title=st||null,w.tagList.push(st?["INF",at,st]:["INF",at])}else if(C[3]){if(jt(w.duration)){w.start=E,M&&Sf(w,M,d),w.sn=g,w.level=r,w.cc=A,w.urlId=o,f.push(w);const st=(" "+C[3]).slice(1);w.relurl=Vc(d,st),kf(w,T),T=w,E+=w.duration,g++,v=0,x=!0}}else if(C[4]){const st=(" "+C[4]).slice(1);T?w.setByteRange(st,T):w.setByteRange(st)}else if(C[5])w.rawProgramDateTime=(" "+C[5]).slice(1),w.tagList.push(["PROGRAM-DATE-TIME",w.rawProgramDateTime]),U===-1&&(U=f.length);else{if(C=C[0].match(Gb),!C){X.warn("No matches on slow regex match for level playlist!");continue}for(D=1;D<C.length&&!(typeof C[D]<"u");D++);const st=(" "+C[D]).slice(1),J=(" "+C[D+1]).slice(1),kt=C[D+2]?(" "+C[D+2]).slice(1):"";switch(st){case"PLAYLIST-TYPE":d.type=J.toUpperCase();break;case"MEDIA-SEQUENCE":g=d.startSN=parseInt(J);break;case"SKIP":{const ft=new tr(J);Xr(d,ft,["RECENTLY-REMOVED-DATERANGES"]);const wt=ft.decimalInteger("SKIPPED-SEGMENTS");if(jt(wt)){d.skippedSegments=wt;for(let F=wt;F--;)f.unshift(null);g+=wt}const Pt=ft.enumeratedString("RECENTLY-REMOVED-DATERANGES");Pt&&(d.recentlyRemovedDateranges=Pt.split(" "));break}case"TARGETDURATION":d.targetduration=Math.max(parseInt(J),1);break;case"VERSION":d.version=parseInt(J);break;case"EXTM3U":break;case"ENDLIST":d.live=!1;break;case"#":(J||kt)&&w.tagList.push(kt?[J,kt]:[J]);break;case"DISCONTINUITY":A++,w.tagList.push(["DIS"]);break;case"GAP":w.gap=!0,w.tagList.push([st]);break;case"BITRATE":w.tagList.push([st,J]);break;case"DATERANGE":{const ft=new tr(J);Xr(d,ft,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),Xr(d,ft,ft.clientAttrs);const wt=new Y0(ft,d.dateRanges[ft.ID]);wt.isValid||d.skippedSegments?d.dateRanges[wt.id]=wt:X.warn(`Ignoring invalid DATERANGE tag: "${J}"`),w.tagList.push(["EXT-X-DATERANGE",J]);break}case"DEFINE":{{const ft=new tr(J);Xr(d,ft,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in ft?Nb(d,ft,l):gf(d,ft,e)}break}case"DISCONTINUITY-SEQUENCE":A=parseInt(J);break;case"KEY":{const ft=Ef(J,e,d);if(ft.isSupported()){if(ft.method==="NONE"){M=void 0;break}M||(M={}),M[ft.keyFormat]&&(M=dr({},M)),M[ft.keyFormat]=ft}else X.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${J}"`);break}case"START":d.startTimeOffset=Af(J);break;case"MAP":{const ft=new tr(J);if(Xr(d,ft,["BYTERANGE","URI"]),w.duration){const wt=new Nc(n,e);wf(wt,ft,r,M),p=wt,w.initSegment=p,p.rawProgramDateTime&&!w.rawProgramDateTime&&(w.rawProgramDateTime=p.rawProgramDateTime)}else wf(w,ft,r,M),p=w,x=!0;break}case"SERVER-CONTROL":{const ft=new tr(J);d.canBlockReload=ft.bool("CAN-BLOCK-RELOAD"),d.canSkipUntil=ft.optionalFloat("CAN-SKIP-UNTIL",0),d.canSkipDateRanges=d.canSkipUntil>0&&ft.bool("CAN-SKIP-DATERANGES"),d.partHoldBack=ft.optionalFloat("PART-HOLD-BACK",0),d.holdBack=ft.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{const ft=new tr(J);d.partTarget=ft.decimalFloatingPoint("PART-TARGET");break}case"PART":{let ft=d.partList;ft||(ft=d.partList=[]);const wt=v>0?ft[ft.length-1]:void 0,Pt=v++,F=new tr(J);Xr(d,F,["BYTERANGE","URI"]);const j=new sb(F,w,e,Pt,wt);ft.push(j),w.duration+=j.duration;break}case"PRELOAD-HINT":{const ft=new tr(J);Xr(d,ft,["URI"]),d.preloadHint=ft;break}case"RENDITION-REPORT":{const ft=new tr(J);Xr(d,ft,["URI"]),d.renditionReports=d.renditionReports||[],d.renditionReports.push(ft);break}default:X.warn(`line parsed but not handled: ${C}`);break}}}T&&!T.relurl?(f.pop(),E-=T.duration,d.partList&&(d.fragmentHint=T)):d.partList&&(kf(w,T),w.cc=A,d.fragmentHint=w,M&&Sf(w,M,d));const O=f.length,K=f[0],B=f[O-1];if(E+=d.skippedSegments*d.targetduration,E>0&&O&&B){d.averagetargetduration=E/O;const at=B.sn;d.endSN=at!=="initSegment"?at:0,d.live||(B.endList=!0),K&&(d.startCC=K.cc)}else d.endSN=0,d.startCC=0;return d.fragmentHint&&(E+=d.fragmentHint.duration),d.totalduration=E,d.endCC=A,U>0&&Vb(f,U),d}}function Ef(i,t,e){var r,n;const o=new tr(i);Xr(e,o,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);const l=(r=o.METHOD)!=null?r:"",d=o.URI,f=o.hexadecimalInteger("IV"),p=o.KEYFORMATVERSIONS,g=(n=o.KEYFORMAT)!=null?n:"identity";d&&o.IV&&!f&&X.error(`Invalid IV: ${o.IV}`);const v=d?wi.resolve(d,t):"",E=(p||"1").split("/").map(Number).filter(Number.isFinite);return new Oa(l,v,g,E,f)}function Af(i){const t=new tr(i).decimalFloatingPoint("TIME-OFFSET");return jt(t)?t:null}function Hb(i,t){["video","audio","text"].forEach(e=>{const r=i.filter(n=>Ub(n,e));if(r.length){const n=r.filter(o=>o.lastIndexOf("avc1",0)===0||o.lastIndexOf("mp4a",0)===0);t[`${e}Codec`]=n.length>0?n[0]:r[0],i=i.filter(o=>r.indexOf(o)===-1)}}),t.unknownCodecs=i}function Tf(i,t,e){const r=t[e];r&&(i[e]=r)}function Vb(i,t){let e=i[t];for(let r=t;r--;){const n=i[r];if(!n)return;n.programDateTime=e.programDateTime-n.duration*1e3,e=n}}function kf(i,t){i.rawProgramDateTime?i.programDateTime=Date.parse(i.rawProgramDateTime):t!=null&&t.programDateTime&&(i.programDateTime=t.endProgramDateTime),jt(i.programDateTime)||(i.programDateTime=null,i.rawProgramDateTime=null)}function wf(i,t,e,r){i.relurl=t.URI,t.BYTERANGE&&i.setByteRange(t.BYTERANGE),i.level=e,i.sn="initSegment",r&&(i.levelkeys=r),i.initSegment=null}function Sf(i,t,e){i.levelkeys=t;const{encryptedFragments:r}=e;(!r.length||r[r.length-1].levelkeys!==t)&&Object.keys(t).some(n=>t[n].isCommonEncryption)&&r.push(i)}var Se={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},Jt={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function Rf(i){const{type:t}=i;switch(t){case Se.AUDIO_TRACK:return Jt.AUDIO;case Se.SUBTITLE_TRACK:return Jt.SUBTITLE;default:return Jt.MAIN}}function jc(i,t){let e=i.url;return(e===void 0||e.indexOf("data:")===0)&&(e=t.url),e}class Wb{constructor(t){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=t,this.registerListeners()}startLoad(t){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){const{hls:t}=this;t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.LEVEL_LOADING,this.onLevelLoading,this),t.on(R.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.on(R.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){const{hls:t}=this;t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.LEVEL_LOADING,this.onLevelLoading,this),t.off(R.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.off(R.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}createInternalLoader(t){const e=this.hls.config,r=e.pLoader,n=e.loader,o=r||n,l=new o(e);return this.loaders[t.type]=l,l}getInternalLoader(t){return this.loaders[t.type]}resetInternalLoader(t){this.loaders[t]&&delete this.loaders[t]}destroyInternalLoaders(){for(const t in this.loaders){const e=this.loaders[t];e&&e.destroy(),this.resetInternalLoader(t)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(t,e){const{url:r}=e;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:Se.MANIFEST,url:r,deliveryDirectives:null})}onLevelLoading(t,e){const{id:r,level:n,url:o,deliveryDirectives:l}=e;this.load({id:r,level:n,responseType:"text",type:Se.LEVEL,url:o,deliveryDirectives:l})}onAudioTrackLoading(t,e){const{id:r,groupId:n,url:o,deliveryDirectives:l}=e;this.load({id:r,groupId:n,level:null,responseType:"text",type:Se.AUDIO_TRACK,url:o,deliveryDirectives:l})}onSubtitleTrackLoading(t,e){const{id:r,groupId:n,url:o,deliveryDirectives:l}=e;this.load({id:r,groupId:n,level:null,responseType:"text",type:Se.SUBTITLE_TRACK,url:o,deliveryDirectives:l})}load(t){var e;const r=this.hls.config;let n=this.getInternalLoader(t);if(n){const p=n.context;if(p&&p.url===t.url){X.trace("[playlist-loader]: playlist request ongoing");return}X.log(`[playlist-loader]: aborting previous loader for type: ${t.type}`),n.abort()}let o;if(t.type===Se.MANIFEST?o=r.manifestLoadPolicy.default:o=dr({},r.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),n=this.createInternalLoader(t),(e=t.deliveryDirectives)!=null&&e.part){let p;if(t.type===Se.LEVEL&&t.level!==null?p=this.hls.levels[t.level].details:t.type===Se.AUDIO_TRACK&&t.id!==null?p=this.hls.audioTracks[t.id].details:t.type===Se.SUBTITLE_TRACK&&t.id!==null&&(p=this.hls.subtitleTracks[t.id].details),p){const g=p.partTarget,v=p.targetduration;if(g&&v){const E=Math.max(g*3,v*.8)*1e3;o=dr({},o,{maxTimeToFirstByteMs:Math.min(E,o.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(E,o.maxTimeToFirstByteMs)})}}}const l=o.errorRetry||o.timeoutRetry||{},d={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:l.maxNumRetry||0,retryDelay:l.retryDelayMs||0,maxRetryDelay:l.maxRetryDelayMs||0},f={onSuccess:(p,g,v,E)=>{const A=this.getInternalLoader(v);this.resetInternalLoader(v.type);const T=p.data;if(T.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(p,v,new Error("no EXTM3U delimiter"),E||null,g);return}g.parsing.start=performance.now(),wi.isMediaPlaylist(T)?this.handleTrackOrLevelPlaylist(p,g,v,E||null,A):this.handleMasterPlaylist(p,g,v,E)},onError:(p,g,v,E)=>{this.handleNetworkError(g,v,!1,p,E)},onTimeout:(p,g,v)=>{this.handleNetworkError(g,v,!0,void 0,p)}};n.load(t,d,f)}handleMasterPlaylist(t,e,r,n){const o=this.hls,l=t.data,d=jc(t,r),f=wi.parseMasterPlaylist(l,d);if(f.playlistParsingError){this.handleManifestParsingError(t,r,f.playlistParsingError,n,e);return}const{contentSteering:p,levels:g,sessionData:v,sessionKeys:E,startTimeOffset:A,variableList:T}=f;this.variableList=T;const{AUDIO:w=[],SUBTITLES:C,"CLOSED-CAPTIONS":D}=wi.parseMasterPlaylistMedia(l,d,f);w.length&&!w.some(M=>!M.url)&&g[0].audioCodec&&!g[0].attrs.AUDIO&&(X.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),w.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new tr({}),bitrate:0,url:""})),o.trigger(R.MANIFEST_LOADED,{levels:g,audioTracks:w,subtitles:C,captions:D,contentSteering:p,url:d,stats:e,networkDetails:n,sessionData:v,sessionKeys:E,startTimeOffset:A,variableList:T})}handleTrackOrLevelPlaylist(t,e,r,n,o){const l=this.hls,{id:d,level:f,type:p}=r,g=jc(t,r),v=jt(d)?d:0,E=jt(f)?f:v,A=Rf(r),T=wi.parseLevelPlaylist(t.data,g,E,A,v,this.variableList);if(p===Se.MANIFEST){const w={attrs:new tr({}),bitrate:0,details:T,name:"",url:g};l.trigger(R.MANIFEST_LOADED,{levels:[w],audioTracks:[],url:g,stats:e,networkDetails:n,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}e.parsing.end=performance.now(),r.levelDetails=T,this.handlePlaylistLoaded(T,t,e,r,n,o)}handleManifestParsingError(t,e,r,n,o){this.hls.trigger(R.ERROR,{type:Qt.NETWORK_ERROR,details:ut.MANIFEST_PARSING_ERROR,fatal:e.type===Se.MANIFEST,url:t.url,err:r,error:r,reason:r.message,response:t,context:e,networkDetails:n,stats:o})}handleNetworkError(t,e,r=!1,n,o){let l=`A network ${r?"timeout":"error"+(n?" (status "+n.code+")":"")} occurred while loading ${t.type}`;t.type===Se.LEVEL?l+=`: ${t.level} id: ${t.id}`:(t.type===Se.AUDIO_TRACK||t.type===Se.SUBTITLE_TRACK)&&(l+=` id: ${t.id} group-id: "${t.groupId}"`);const d=new Error(l);X.warn(`[playlist-loader]: ${l}`);let f=ut.UNKNOWN,p=!1;const g=this.getInternalLoader(t);switch(t.type){case Se.MANIFEST:f=r?ut.MANIFEST_LOAD_TIMEOUT:ut.MANIFEST_LOAD_ERROR,p=!0;break;case Se.LEVEL:f=r?ut.LEVEL_LOAD_TIMEOUT:ut.LEVEL_LOAD_ERROR,p=!1;break;case Se.AUDIO_TRACK:f=r?ut.AUDIO_TRACK_LOAD_TIMEOUT:ut.AUDIO_TRACK_LOAD_ERROR,p=!1;break;case Se.SUBTITLE_TRACK:f=r?ut.SUBTITLE_TRACK_LOAD_TIMEOUT:ut.SUBTITLE_LOAD_ERROR,p=!1;break}g&&this.resetInternalLoader(t.type);const v={type:Qt.NETWORK_ERROR,details:f,fatal:p,url:t.url,loader:g,context:t,error:d,networkDetails:e,stats:o};if(n){const E=(e==null?void 0:e.url)||t.url;v.response=zr({url:E,data:void 0},n)}this.hls.trigger(R.ERROR,v)}handlePlaylistLoaded(t,e,r,n,o,l){const d=this.hls,{type:f,level:p,id:g,groupId:v,deliveryDirectives:E}=n,A=jc(e,n),T=Rf(n),w=typeof n.level=="number"&&T===Jt.MAIN?p:void 0;if(!t.fragments.length){const D=new Error("No Segments found in Playlist");d.trigger(R.ERROR,{type:Qt.NETWORK_ERROR,details:ut.LEVEL_EMPTY_ERROR,fatal:!1,url:A,error:D,reason:D.message,response:e,context:n,level:w,parent:T,networkDetails:o,stats:r});return}t.targetduration||(t.playlistParsingError=new Error("Missing Target Duration"));const C=t.playlistParsingError;if(C){d.trigger(R.ERROR,{type:Qt.NETWORK_ERROR,details:ut.LEVEL_PARSING_ERROR,fatal:!1,url:A,error:C,reason:C.message,response:e,context:n,level:w,parent:T,networkDetails:o,stats:r});return}switch(t.live&&l&&(l.getCacheAge&&(t.ageHeader=l.getCacheAge()||0),(!l.getCacheAge||isNaN(t.ageHeader))&&(t.ageHeader=0)),f){case Se.MANIFEST:case Se.LEVEL:d.trigger(R.LEVEL_LOADED,{details:t,level:w||0,id:g||0,stats:r,networkDetails:o,deliveryDirectives:E});break;case Se.AUDIO_TRACK:d.trigger(R.AUDIO_TRACK_LOADED,{details:t,id:g||0,groupId:v||"",stats:r,networkDetails:o,deliveryDirectives:E});break;case Se.SUBTITLE_TRACK:d.trigger(R.SUBTITLE_TRACK_LOADED,{details:t,id:g||0,groupId:v||"",stats:r,networkDetails:o,deliveryDirectives:E});break}}}function _f(i,t){let e;try{e=new Event("addtrack")}catch{e=document.createEvent("Event"),e.initEvent("addtrack",!1,!1)}e.track=i,t.dispatchEvent(e)}function Lf(i,t){const e=i.mode;if(e==="disabled"&&(i.mode="hidden"),i.cues&&!i.cues.getCueById(t.id))try{if(i.addCue(t),!i.cues.getCueById(t.id))throw new Error(`addCue is failed for: ${t}`)}catch(r){X.debug(`[texttrack-utils]: ${r}`);try{const n=new self.TextTrackCue(t.startTime,t.endTime,t.text);n.id=t.id,i.addCue(n)}catch(n){X.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${n}`)}}e==="disabled"&&(i.mode=e)}function xn(i){const t=i.mode;if(t==="disabled"&&(i.mode="hidden"),i.cues)for(let e=i.cues.length;e--;)i.removeCue(i.cues[e]);t==="disabled"&&(i.mode=t)}function Kc(i,t,e,r){const n=i.mode;if(n==="disabled"&&(i.mode="hidden"),i.cues&&i.cues.length>0){const o=Kb(i.cues,t,e);for(let l=0;l<o.length;l++)(!r||r(o[l]))&&i.removeCue(o[l])}n==="disabled"&&(i.mode=n)}function jb(i,t){if(t<i[0].startTime)return 0;const e=i.length-1;if(t>i[e].endTime)return-1;let r=0,n=e;for(;r<=n;){const o=Math.floor((n+r)/2);if(t<i[o].startTime)n=o-1;else if(t>i[o].startTime&&r<e)r=o+1;else return o}return i[r].startTime-t<t-i[n].startTime?r:n}function Kb(i,t,e){const r=[],n=jb(i,t);if(n>-1)for(let o=n,l=i.length;o<l;o++){const d=i[o];if(d.startTime>=t&&d.endTime<=e)r.push(d);else if(d.startTime>e)return r}return r}var Si={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"};const zb=.25;function zc(){if(!(typeof self>"u"))return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}const Yo=(()=>{const i=zc();try{new i(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function Yc(i,t){return i.getTime()/1e3-t}function Yb(i){return Uint8Array.from(i.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}class Xb{constructor(t){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=t,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null}_registerListeners(){const{hls:t}=this;t.on(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.on(R.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(R.LEVEL_UPDATED,this.onLevelUpdated,this)}_unregisterListeners(){const{hls:t}=this;t.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.off(R.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(R.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(t,e){this.media=e.media}onMediaDetaching(){this.id3Track&&(xn(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(t){const e=this.getID3Track(t.textTracks);return e.mode="hidden",e}getID3Track(t){if(this.media){for(let e=0;e<t.length;e++){const r=t[e];if(r.kind==="metadata"&&r.label==="id3")return _f(r,this.media),r}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(t,e){if(!this.media)return;const{hls:{config:{enableEmsgMetadataCues:r,enableID3MetadataCues:n}}}=this;if(!r&&!n)return;const{samples:o}=e;this.id3Track||(this.id3Track=this.createTrack(this.media));const l=zc();for(let d=0;d<o.length;d++){const f=o[d].type;if(f===Si.emsg&&!r||!n)continue;const p=sf(o[d].data);if(p){const g=o[d].pts;let v=g+o[d].duration;v>Yo&&(v=Yo),v-g<=0&&(v=g+zb);for(let E=0;E<p.length;E++){const A=p[E];if(!rf(A)){this.updateId3CueEnds(g,f);const T=new l(g,v,"");T.value=A,f&&(T.type=f),this.id3Track.addCue(T)}}}}}updateId3CueEnds(t,e){var r;const n=(r=this.id3Track)==null?void 0:r.cues;if(n)for(let o=n.length;o--;){const l=n[o];l.type===e&&l.startTime<t&&l.endTime===Yo&&(l.endTime=t)}}onBufferFlushing(t,{startOffset:e,endOffset:r,type:n}){const{id3Track:o,hls:l}=this;if(!l)return;const{config:{enableEmsgMetadataCues:d,enableID3MetadataCues:f}}=l;if(o&&(d||f)){let p;n==="audio"?p=g=>g.type===Si.audioId3&&f:n==="video"?p=g=>g.type===Si.emsg&&d:p=g=>g.type===Si.audioId3&&f||g.type===Si.emsg&&d,Kc(o,e,r,p)}}onLevelUpdated(t,{details:e}){if(!this.media||!e.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;const{dateRangeCuesAppended:r,id3Track:n}=this,{dateRanges:o}=e,l=Object.keys(o);if(n){const g=Object.keys(r).filter(v=>!l.includes(v));for(let v=g.length;v--;){const E=g[v];Object.keys(r[E].cues).forEach(A=>{n.removeCue(r[E].cues[A])}),delete r[E]}}const d=e.fragments[e.fragments.length-1];if(l.length===0||!jt(d==null?void 0:d.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));const f=d.programDateTime/1e3-d.start,p=zc();for(let g=0;g<l.length;g++){const v=l[g],E=o[v],A=r[v],T=(A==null?void 0:A.cues)||{};let w=(A==null?void 0:A.durationKnown)||!1;const C=Yc(E.startDate,f);let D=Yo;const M=E.endDate;if(M)D=Yc(M,f),w=!0;else if(E.endOnNext&&!w){const x=l.reduce((O,K)=>{const B=o[K];return B.class===E.class&&B.id!==K&&B.startDate>E.startDate&&O.push(B),O},[]).sort((O,K)=>O.startDate.getTime()-K.startDate.getTime())[0];x&&(D=Yc(x.startDate,f),w=!0)}const U=Object.keys(E.attr);for(let x=0;x<U.length;x++){const O=U[x];if(!rb(O))continue;let K=T[O];if(K)w&&!A.durationKnown&&(K.endTime=D);else{let B=E.attr[O];K=new p(C,D,""),ib(O)&&(B=Yb(B)),K.value={key:O,data:B},K.type=Si.dateRange,K.id=v,this.id3Track.addCue(K),T[O]=K}}r[v]={cues:T,dateRange:E,durationKnown:w}}}}class Zb{constructor(t){this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=()=>this.timeupdate(),this.hls=t,this.config=t.config,this.registerListeners()}get latency(){return this._latency||0}get maxLatency(){const{config:t,levelDetails:e}=this;return t.liveMaxLatencyDuration!==void 0?t.liveMaxLatencyDuration:e?t.liveMaxLatencyDurationCount*e.targetduration:0}get targetLatency(){const{levelDetails:t}=this;if(t===null)return null;const{holdBack:e,partHoldBack:r,targetduration:n}=t,{liveSyncDuration:o,liveSyncDurationCount:l,lowLatencyMode:d}=this.config,f=this.hls.userConfig;let p=d&&r||e;(f.liveSyncDuration||f.liveSyncDurationCount||p===0)&&(p=o!==void 0?o:l*n);const g=n,v=1;return p+Math.min(this.stallCount*v,g)}get liveSyncPosition(){const t=this.estimateLiveEdge(),e=this.targetLatency,r=this.levelDetails;if(t===null||e===null||r===null)return null;const n=r.edge,o=t-e-this.edgeStalled,l=n-r.totalduration,d=n-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(l,o),d)}get drift(){const{levelDetails:t}=this;return t===null?1:t.drift}get edgeStalled(){const{levelDetails:t}=this;if(t===null)return 0;const e=(this.config.lowLatencyMode&&t.partTarget||t.targetduration)*3;return Math.max(t.age-e,0)}get forwardBufferLength(){const{media:t,levelDetails:e}=this;if(!t||!e)return 0;const r=t.buffered.length;return(r?t.buffered.end(r-1):e.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null}registerListeners(){this.hls.on(R.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(R.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(R.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(R.ERROR,this.onError,this)}unregisterListeners(){this.hls.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(R.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(R.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(R.ERROR,this.onError,this)}onMediaAttached(t,e){this.media=e.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)}onManifestLoading(){this.levelDetails=null,this._latency=null,this.stallCount=0}onLevelUpdated(t,{details:e}){this.levelDetails=e,e.advanced&&this.timeupdate(),!e.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)}onError(t,e){var r;e.details===ut.BUFFER_STALLED_ERROR&&(this.stallCount++,(r=this.levelDetails)!=null&&r.live&&X.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))}timeupdate(){const{media:t,levelDetails:e}=this;if(!t||!e)return;this.currentTime=t.currentTime;const r=this.computeLatency();if(r===null)return;this._latency=r;const{lowLatencyMode:n,maxLiveSyncPlaybackRate:o}=this.config;if(!n||o===1)return;const l=this.targetLatency;if(l===null)return;const d=r-l,f=Math.min(this.maxLatency,l+e.targetduration),p=d<f;if(e.live&&p&&d>.05&&this.forwardBufferLength>1){const g=Math.min(2,Math.max(1,o)),v=Math.round(2/(1+Math.exp(-.75*d-this.edgeStalled))*20)/20;t.playbackRate=Math.min(g,Math.max(1,v))}else t.playbackRate!==1&&t.playbackRate!==0&&(t.playbackRate=1)}estimateLiveEdge(){const{levelDetails:t}=this;return t===null?null:t.edge+t.age}computeLatency(){const t=this.estimateLiveEdge();return t===null?null:t-this.currentTime}}const Xc=["NONE","TYPE-0","TYPE-1",null];var $a={No:"",Yes:"YES",v2:"v2"};function qb(i,t){const{canSkipUntil:e,canSkipDateRanges:r,endSN:n}=i,o=t!==void 0?t-n:0;return e&&o<e?r?$a.v2:$a.Yes:$a.No}class Cf{constructor(t,e,r){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=t,this.part=e,this.skip=r}addDirectives(t){const e=new self.URL(t);return this.msn!==void 0&&e.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&e.searchParams.set("_HLS_part",this.part.toString()),this.skip&&e.searchParams.set("_HLS_skip",this.skip),e.href}}class Ma{constructor(t){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[t.url],this._attrs=[t.attrs],this.bitrate=t.bitrate,t.details&&(this.details=t.details),this.id=t.id||0,this.name=t.name,this.width=t.width||0,this.height=t.height||0,this.audioCodec=t.audioCodec,this.videoCodec=t.videoCodec,this.unknownCodecs=t.unknownCodecs,this.codecSet=[t.videoCodec,t.audioCodec].filter(e=>e).join(",").replace(/\.[^.,]+/g,"")}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get attrs(){return this._attrs[this._urlId]}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get uri(){return this.url[this._urlId]||""}get urlId(){return this._urlId}set urlId(t){const e=t%this.url.length;this._urlId!==e&&(this.fragmentError=0,this.loadError=0,this.details=void 0,this._urlId=e)}get audioGroupId(){var t;return(t=this.audioGroupIds)==null?void 0:t[this.urlId]}get textGroupId(){var t;return(t=this.textGroupIds)==null?void 0:t[this.urlId]}addFallback(t){this.url.push(t.url),this._attrs.push(t.attrs)}}function Zc(i,t){const e=t.startPTS;if(jt(e)){let r=0,n;t.sn>i.sn?(r=e-i.start,n=i):(r=i.start-e,n=t),n.duration!==r&&(n.duration=r)}else t.sn>i.sn?i.cc===t.cc&&i.minEndPTS?t.start=i.start+(i.minEndPTS-i.start):t.start=i.start+i.duration:t.start=Math.max(i.start-t.duration,0)}function If(i,t,e,r,n,o){r-e<=0&&(X.warn("Fragment should have a positive duration",t),r=e+t.duration,o=n+t.duration);let l=e,d=r;const f=t.startPTS,p=t.endPTS;if(jt(f)){const w=Math.abs(f-e);jt(t.deltaPTS)?t.deltaPTS=Math.max(w,t.deltaPTS):t.deltaPTS=w,l=Math.max(e,f),e=Math.min(e,f),n=Math.min(n,t.startDTS),d=Math.min(r,p),r=Math.max(r,p),o=Math.max(o,t.endDTS)}const g=e-t.start;t.start!==0&&(t.start=e),t.duration=r-t.start,t.startPTS=e,t.maxStartPTS=l,t.startDTS=n,t.endPTS=r,t.minEndPTS=d,t.endDTS=o;const v=t.sn;if(!i||v<i.startSN||v>i.endSN)return 0;let E;const A=v-i.startSN,T=i.fragments;for(T[A]=t,E=A;E>0;E--)Zc(T[E],T[E-1]);for(E=A;E<T.length-1;E++)Zc(T[E],T[E+1]);return i.fragmentHint&&Zc(T[T.length-1],i.fragmentHint),i.PTSKnown=i.alignedSliding=!0,g}function Qb(i,t){let e=null;const r=i.fragments;for(let f=r.length-1;f>=0;f--){const p=r[f].initSegment;if(p){e=p;break}}i.fragmentHint&&delete i.fragmentHint.endPTS;let n=0,o;if(e4(i,t,(f,p)=>{f.relurl&&(n=f.cc-p.cc),jt(f.startPTS)&&jt(f.endPTS)&&(p.start=p.startPTS=f.startPTS,p.startDTS=f.startDTS,p.maxStartPTS=f.maxStartPTS,p.endPTS=f.endPTS,p.endDTS=f.endDTS,p.minEndPTS=f.minEndPTS,p.duration=f.endPTS-f.startPTS,p.duration&&(o=p),t.PTSKnown=t.alignedSliding=!0),p.elementaryStreams=f.elementaryStreams,p.loader=f.loader,p.stats=f.stats,p.urlId=f.urlId,f.initSegment&&(p.initSegment=f.initSegment,e=f.initSegment)}),e&&(t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments).forEach(f=>{var p;(!f.initSegment||f.initSegment.relurl===((p=e)==null?void 0:p.relurl))&&(f.initSegment=e)}),t.skippedSegments)if(t.deltaUpdateFailed=t.fragments.some(f=>!f),t.deltaUpdateFailed){X.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let f=t.skippedSegments;f--;)t.fragments.shift();t.startSN=t.fragments[0].sn,t.startCC=t.fragments[0].cc}else t.canSkipDateRanges&&(t.dateRanges=Jb(i.dateRanges,t.dateRanges,t.recentlyRemovedDateranges));const l=t.fragments;if(n){X.warn("discontinuity sliding from playlist, take drift into account");for(let f=0;f<l.length;f++)l[f].cc+=n}t.skippedSegments&&(t.startCC=t.fragments[0].cc),t4(i.partList,t.partList,(f,p)=>{p.elementaryStreams=f.elementaryStreams,p.stats=f.stats}),o?If(t,o,o.startPTS,o.endPTS,o.startDTS,o.endDTS):xf(i,t),l.length&&(t.totalduration=t.edge-l[0].start),t.driftStartTime=i.driftStartTime,t.driftStart=i.driftStart;const d=t.advancedDateTime;if(t.advanced&&d){const f=t.edge;t.driftStart||(t.driftStartTime=d,t.driftStart=f),t.driftEndTime=d,t.driftEnd=f}else t.driftEndTime=i.driftEndTime,t.driftEnd=i.driftEnd,t.advancedDateTime=i.advancedDateTime}function Jb(i,t,e){const r=dr({},i);return e&&e.forEach(n=>{delete r[n]}),Object.keys(t).forEach(n=>{const o=new Y0(t[n].attr,r[n]);o.isValid?r[n]=o:X.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(t[n].attr)}"`)}),r}function t4(i,t,e){if(i&&t){let r=0;for(let n=0,o=i.length;n<=o;n++){const l=i[n],d=t[n+r];l&&d&&l.index===d.index&&l.fragment.sn===d.fragment.sn?e(l,d):r--}}}function e4(i,t,e){const r=t.skippedSegments,n=Math.max(i.startSN,t.startSN)-t.startSN,o=(i.fragmentHint?1:0)+(r?t.endSN:Math.min(i.endSN,t.endSN))-t.startSN,l=t.startSN-i.startSN,d=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,f=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments;for(let p=n;p<=o;p++){const g=f[l+p];let v=d[p];r&&!v&&p<r&&(v=t.fragments[p]=g),g&&v&&e(g,v)}}function xf(i,t){const e=t.startSN+t.skippedSegments-i.startSN,r=i.fragments;e<0||e>=r.length||qc(t,r[e].start)}function qc(i,t){if(t){const e=i.fragments;for(let r=i.skippedSegments;r<e.length;r++)e[r].start+=t;i.fragmentHint&&(i.fragmentHint.start+=t)}}function r4(i,t=1/0){let e=1e3*i.targetduration;if(i.updated){const r=i.fragments,n=4;if(r.length&&e*n>t){const o=r[r.length-1].duration*1e3;o<e&&(e=o)}}else e/=2;return Math.round(e)}function i4(i,t,e){if(!(i!=null&&i.details))return null;const r=i.details;let n=r.fragments[t-r.startSN];return n||(n=r.fragmentHint,n&&n.sn===t)?n:t<r.startSN&&e&&e.sn===t?e:null}function Df(i,t,e){var r;return i!=null&&i.details?Pf((r=i.details)==null?void 0:r.partList,t,e):null}function Pf(i,t,e){if(i)for(let r=i.length;r--;){const n=i[r];if(n.index===e&&n.fragment.sn===t)return n}return null}function Xo(i){switch(i.details){case ut.FRAG_LOAD_TIMEOUT:case ut.KEY_LOAD_TIMEOUT:case ut.LEVEL_LOAD_TIMEOUT:case ut.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function Of(i,t){const e=Xo(t);return i.default[`${e?"timeout":"error"}Retry`]}function Qc(i,t){const e=i.backoff==="linear"?1:Math.pow(2,t);return Math.min(e*i.retryDelayMs,i.maxRetryDelayMs)}function $f(i){return zr(zr({},i),{errorRetry:null,timeoutRetry:null})}function Zo(i,t,e,r){return!!i&&t<i.maxNumRetry&&(s4(r)||!!e)}function s4(i){return i===0&&navigator.onLine===!1||!!i&&(i<400||i>499)}const Mf={search:function(i,t){let e=0,r=i.length-1,n=null,o=null;for(;e<=r;){n=(e+r)/2|0,o=i[n];const l=t(o);if(l>0)e=n+1;else if(l<0)r=n-1;else return o}return null}};function n4(i,t,e){if(t===null||!Array.isArray(i)||!i.length||!jt(t))return null;const r=i[0].programDateTime;if(t<(r||0))return null;const n=i[i.length-1].endProgramDateTime;if(t>=(n||0))return null;e=e||0;for(let o=0;o<i.length;++o){const l=i[o];if(a4(t,e,l))return l}return null}function Na(i,t,e=0,r=0){let n=null;if(i?n=t[i.sn-t[0].sn+1]||null:e===0&&t[0].start===0&&(n=t[0]),n&&Jc(e,r,n)===0)return n;const o=Mf.search(t,Jc.bind(null,e,r));return o&&(o!==i||!n)?o:n}function Jc(i=0,t=0,e){if(e.start<=i&&e.start+e.duration>i)return 0;const r=Math.min(t,e.duration+(e.deltaPTS?e.deltaPTS:0));return e.start+e.duration-r<=i?1:e.start-r>i&&e.start?-1:0}function a4(i,t,e){const r=Math.min(t,e.duration+(e.deltaPTS?e.deltaPTS:0))*1e3;return(e.endProgramDateTime||0)-r>i}function o4(i,t){return Mf.search(i,e=>e.cc<t?1:e.cc>t?-1:0)}const l4=3e5;var Ir={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},fi={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4};class c4{constructor(t){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=t,this.log=X.log.bind(X,"[info]:"),this.warn=X.warn.bind(X,"[warning]:"),this.error=X.error.bind(X,"[error]:"),this.registerListeners()}registerListeners(){const t=this.hls;t.on(R.ERROR,this.onError,this),t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const t=this.hls;t&&(t.off(R.ERROR,this.onError,this),t.off(R.ERROR,this.onErrorOut,this),t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}}startLoad(t){this.playlistError=0}stopLoad(){}getVariantLevelIndex(t){return(t==null?void 0:t.type)===Jt.MAIN?t.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={}}onLevelUpdated(){this.playlistError=0}onError(t,e){var r,n;if(e.fatal)return;const o=this.hls,l=e.context;switch(e.details){case ut.FRAG_LOAD_ERROR:case ut.FRAG_LOAD_TIMEOUT:case ut.KEY_LOAD_ERROR:case ut.KEY_LOAD_TIMEOUT:e.errorAction=this.getFragRetryOrSwitchAction(e);return;case ut.FRAG_PARSING_ERROR:if((r=e.frag)!=null&&r.gap){e.errorAction={action:Ir.DoNothing,flags:fi.None};return}case ut.FRAG_GAP:case ut.FRAG_DECRYPT_ERROR:{e.errorAction=this.getFragRetryOrSwitchAction(e),e.errorAction.action=Ir.SendAlternateToPenaltyBox;return}case ut.LEVEL_EMPTY_ERROR:case ut.LEVEL_PARSING_ERROR:{var d,f;const p=e.parent===Jt.MAIN?e.level:o.loadLevel;e.details===ut.LEVEL_EMPTY_ERROR&&(d=e.context)!=null&&(f=d.levelDetails)!=null&&f.live?e.errorAction=this.getPlaylistRetryOrSwitchAction(e,p):(e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,p))}return;case ut.LEVEL_LOAD_ERROR:case ut.LEVEL_LOAD_TIMEOUT:typeof(l==null?void 0:l.level)=="number"&&(e.errorAction=this.getPlaylistRetryOrSwitchAction(e,l.level));return;case ut.AUDIO_TRACK_LOAD_ERROR:case ut.AUDIO_TRACK_LOAD_TIMEOUT:case ut.SUBTITLE_LOAD_ERROR:case ut.SUBTITLE_TRACK_LOAD_TIMEOUT:if(l){const p=o.levels[o.loadLevel];if(p&&(l.type===Se.AUDIO_TRACK&&l.groupId===p.audioGroupId||l.type===Se.SUBTITLE_TRACK&&l.groupId===p.textGroupId)){e.errorAction=this.getPlaylistRetryOrSwitchAction(e,o.loadLevel),e.errorAction.action=Ir.SendAlternateToPenaltyBox,e.errorAction.flags=fi.MoveAllAlternatesMatchingHost;return}}return;case ut.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{const p=o.levels[o.loadLevel],g=p==null?void 0:p.attrs["HDCP-LEVEL"];g&&(e.errorAction={action:Ir.SendAlternateToPenaltyBox,flags:fi.MoveAllAlternatesMatchingHDCP,hdcpLevel:g})}return;case ut.BUFFER_ADD_CODEC_ERROR:case ut.REMUX_ALLOC_ERROR:e.errorAction=this.getLevelSwitchAction(e,(n=e.level)!=null?n:o.loadLevel);return;case ut.INTERNAL_EXCEPTION:case ut.BUFFER_APPENDING_ERROR:case ut.BUFFER_APPEND_ERROR:case ut.BUFFER_FULL_ERROR:case ut.LEVEL_SWITCH_ERROR:case ut.BUFFER_STALLED_ERROR:case ut.BUFFER_SEEK_OVER_HOLE:case ut.BUFFER_NUDGE_ON_STALL:e.errorAction={action:Ir.DoNothing,flags:fi.None};return}if(e.type===Qt.KEY_SYSTEM_ERROR){const p=this.getVariantLevelIndex(e.frag);e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,p);return}}getPlaylistRetryOrSwitchAction(t,e){var r;const n=this.hls,o=Of(n.config.playlistLoadPolicy,t),l=this.playlistError++,d=(r=t.response)==null?void 0:r.code;if(Zo(o,l,Xo(t),d))return{action:Ir.RetryRequest,flags:fi.None,retryConfig:o,retryCount:l};const f=this.getLevelSwitchAction(t,e);return o&&(f.retryConfig=o,f.retryCount=l),f}getFragRetryOrSwitchAction(t){const e=this.hls,r=this.getVariantLevelIndex(t.frag),n=e.levels[r],{fragLoadPolicy:o,keyLoadPolicy:l}=e.config,d=Of(t.details.startsWith("key")?l:o,t),f=e.levels.reduce((v,E)=>v+E.fragmentError,0);if(n){var p;t.details!==ut.FRAG_GAP&&n.fragmentError++;const v=(p=t.response)==null?void 0:p.code;if(Zo(d,f,Xo(t),v))return{action:Ir.RetryRequest,flags:fi.None,retryConfig:d,retryCount:f}}const g=this.getLevelSwitchAction(t,r);return d&&(g.retryConfig=d,g.retryCount=f),g}getLevelSwitchAction(t,e){const r=this.hls;e==null&&(e=r.loadLevel);const n=this.hls.levels[e];if(n&&(n.loadError++,r.autoLevelEnabled)){var o,l;let d=-1;const{levels:f,loadLevel:p,minAutoLevel:g,maxAutoLevel:v}=r,E=(o=t.frag)==null?void 0:o.type,{type:A,groupId:T}=(l=t.context)!=null?l:{};for(let w=f.length;w--;){const C=(w+p)%f.length;if(C!==p&&C>=g&&C<=v&&f[C].loadError===0){const D=f[C];if(t.details===ut.FRAG_GAP&&t.frag){const M=f[C].details;if(M){const U=Na(t.frag,M.fragments,t.frag.start);if(U!=null&&U.gap)continue}}else if(A===Se.AUDIO_TRACK&&T===D.audioGroupId||A===Se.SUBTITLE_TRACK&&T===D.textGroupId||E===Jt.AUDIO&&n.audioGroupId===D.audioGroupId||E===Jt.SUBTITLE&&n.textGroupId===D.textGroupId)continue;d=C;break}}if(d>-1&&r.loadLevel!==d)return t.levelRetry=!0,this.playlistError=0,{action:Ir.SendAlternateToPenaltyBox,flags:fi.None,nextAutoLevel:d}}return{action:Ir.SendAlternateToPenaltyBox,flags:fi.MoveAllAlternatesMatchingHost}}onErrorOut(t,e){var r;switch((r=e.errorAction)==null?void 0:r.action){case Ir.DoNothing:break;case Ir.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(e),!e.errorAction.resolved&&e.details!==ut.FRAG_GAP&&(e.fatal=!0);break}if(e.fatal){this.hls.stopLoad();return}}sendAlternateToPenaltyBox(t){const e=this.hls,r=t.errorAction;if(!r)return;const{flags:n,hdcpLevel:o,nextAutoLevel:l}=r;switch(n){case fi.None:this.switchLevel(t,l);break;case fi.MoveAllAlternatesMatchingHost:r.resolved||(r.resolved=this.redundantFailover(t));break;case fi.MoveAllAlternatesMatchingHDCP:o&&(e.maxHdcpLevel=Xc[Xc.indexOf(o)-1],r.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${e.maxHdcpLevel}" or lower`);break}r.resolved||this.switchLevel(t,l)}switchLevel(t,e){e!==void 0&&t.errorAction&&(this.warn(`switching to level ${e} after ${t.details}`),this.hls.nextAutoLevel=e,t.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)}redundantFailover(t){const{hls:e,penalizedRenditions:r}=this,n=t.parent===Jt.MAIN?t.level:e.loadLevel,o=e.levels[n],l=o.url.length,d=t.frag?t.frag.urlId:o.urlId;o.urlId===d&&(!t.frag||o.details)&&this.penalizeRendition(o,t);for(let f=1;f<l;f++){const p=(d+f)%l,g=r[p];if(!g||h4(g,t,r[d]))return this.warn(`Switching to Redundant Stream ${p+1}/${l}: "${o.url[p]}" after ${t.details}`),this.playlistError=0,e.levels.forEach(v=>{v.urlId=p}),e.nextLoadLevel=n,!0}return!1}penalizeRendition(t,e){const{penalizedRenditions:r}=this,n=r[t.urlId]||{lastErrorPerfMs:0,errors:[],details:void 0};n.lastErrorPerfMs=performance.now(),n.errors.push(e),n.details=t.details,r[t.urlId]=n}}function h4(i,t,e){if(performance.now()-i.lastErrorPerfMs>l4)return!0;const r=i.details;if(t.details===ut.FRAG_GAP&&r&&t.frag){const n=t.frag.start,o=Na(null,r.fragments,n);if(o&&!o.gap)return!0}if(e&&i.errors.length<e.errors.length){const n=i.errors[i.errors.length-1];if(r&&n.frag&&t.frag&&Math.abs(n.frag.start-t.frag.start)>r.targetduration*3)return!0}return!1}class th{constructor(t,e){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=X.log.bind(X,`${e}:`),this.warn=X.warn.bind(X,`${e}:`),this.hls=t}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){clearTimeout(this.timer),this.timer=-1}startLoad(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(t,e){const r=e==null?void 0:e.renditionReports;if(r){let n=-1;for(let o=0;o<r.length;o++){const l=r[o];let d;try{d=new self.URL(l.URI,e.url).href}catch(f){X.warn(`Could not construct new URL for Rendition Report: ${f}`),d=l.URI||""}if(d===t){n=o;break}else d===t.substring(0,d.length)&&(n=o)}if(n!==-1){const o=r[n],l=parseInt(o["LAST-MSN"])||(e==null?void 0:e.lastPartSn);let d=parseInt(o["LAST-PART"])||(e==null?void 0:e.lastPartIndex);if(this.hls.config.lowLatencyMode){const f=Math.min(e.age-e.partTarget,e.targetduration);d>=0&&f>e.partTarget&&(d+=1)}return new Cf(l,d>=0?d:void 0,$a.No)}}}loadPlaylist(t){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())}shouldLoadPlaylist(t){return this.canLoad&&!!t&&!!t.url&&(!t.details||t.details.live)}shouldReloadPlaylist(t){return this.timer===-1&&this.requestScheduled===-1&&this.shouldLoadPlaylist(t)}playlistLoaded(t,e,r){const{details:n,stats:o}=e,l=self.performance.now(),d=o.loading.first?Math.max(0,l-o.loading.first):0;if(n.advancedDateTime=Date.now()-d,n.live||r!=null&&r.live){if(n.reloaded(r),r&&this.log(`live playlist ${t} ${n.advanced?"REFRESHED "+n.lastPartSn+"-"+n.lastPartIndex:n.updated?"UPDATED":"MISSED"}`),r&&n.fragments.length>0&&Qb(r,n),!this.canLoad||!n.live)return;let f,p,g;if(n.canBlockReload&&n.endSN&&n.advanced){const C=this.hls.config.lowLatencyMode,D=n.lastPartSn,M=n.endSN,U=n.lastPartIndex,x=U!==-1,O=D===M,K=C?0:U;x?(p=O?M+1:D,g=O?K:U+1):p=M+1;const B=n.age,at=B+n.ageHeader;let st=Math.min(at-n.partTarget,n.targetduration*1.5);if(st>0){if(r&&st>r.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${r.tuneInGoal} to: ${st} with playlist age: ${n.age}`),st=0;else{const J=Math.floor(st/n.targetduration);if(p+=J,g!==void 0){const kt=Math.round(st%n.targetduration/n.partTarget);g+=kt}this.log(`CDN Tune-in age: ${n.ageHeader}s last advanced ${B.toFixed(2)}s goal: ${st} skip sn ${J} to part ${g}`)}n.tuneInGoal=st}if(f=this.getDeliveryDirectives(n,e.deliveryDirectives,p,g),C||!O){this.loadPlaylist(f);return}}else(n.canBlockReload||n.canSkipUntil)&&(f=this.getDeliveryDirectives(n,e.deliveryDirectives,p,g));const v=this.hls.mainForwardBufferInfo,E=v?v.end-v.len:0,A=(n.edge-E)*1e3,T=r4(n,A);n.updated&&l>this.requestScheduled+T&&(this.requestScheduled=o.loading.start),p!==void 0&&n.canBlockReload?this.requestScheduled=o.loading.first+T-(n.partTarget*1e3||1e3):this.requestScheduled===-1||this.requestScheduled+T<l?this.requestScheduled=l:this.requestScheduled-l<=0&&(this.requestScheduled+=T);let w=this.requestScheduled-l;w=Math.max(0,w),this.log(`reload live playlist ${t} in ${Math.round(w)} ms`),this.timer=self.setTimeout(()=>this.loadPlaylist(f),w)}else this.clearTimer()}getDeliveryDirectives(t,e,r,n){let o=qb(t,r);return e!=null&&e.skip&&t.deltaUpdateFailed&&(r=e.msn,n=e.part,o=$a.No),new Cf(r,n,o)}checkRetry(t){const e=t.details,r=Xo(t),n=t.errorAction,{action:o,retryCount:l=0,retryConfig:d}=n||{},f=!!n&&!!d&&(o===Ir.RetryRequest||!n.resolved&&o===Ir.SendAlternateToPenaltyBox);if(f){var p;if(this.requestScheduled=-1,l>=d.maxNumRetry)return!1;if(r&&(p=t.context)!=null&&p.deliveryDirectives)this.warn(`Retrying playlist loading ${l+1}/${d.maxNumRetry} after "${e}" without delivery-directives`),this.loadPlaylist();else{const g=Qc(d,l);this.timer=self.setTimeout(()=>this.loadPlaylist(),g),this.warn(`Retrying playlist loading ${l+1}/${d.maxNumRetry} after "${e}" in ${g}ms`)}t.levelRetry=!0,n.resolved=!0}return f}}let eh;class d4 extends th{constructor(t,e){super(t,"[level-controller]"),this._levels=[],this._firstLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=e,this._registerListeners()}_registerListeners(){const{hls:t}=this;t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(R.LEVEL_LOADED,this.onLevelLoaded,this),t.on(R.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(R.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(R.FRAG_LOADED,this.onFragLoaded,this),t.on(R.ERROR,this.onError,this)}_unregisterListeners(){const{hls:t}=this;t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(R.LEVEL_LOADED,this.onLevelLoaded,this),t.off(R.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(R.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(R.FRAG_LOADED,this.onFragLoaded,this),t.off(R.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}startLoad(){this._levels.forEach(t=>{t.loadError=0,t.fragmentError=0}),super.startLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[]}onManifestLoading(t,e){this.resetLevels()}onManifestLoaded(t,e){const r=[],n={};let o;e.levels.forEach(l=>{var d;const f=l.attrs;((d=l.audioCodec)==null?void 0:d.indexOf("mp4a.40.34"))!==-1&&(eh||(eh=/chrome|firefox/i.test(navigator.userAgent)),eh&&(l.audioCodec=void 0));const{AUDIO:p,CODECS:g,"FRAME-RATE":v,"PATHWAY-ID":E,RESOLUTION:A,SUBTITLES:T}=f,w=`${`${E||"."}-`}${l.bitrate}-${A}-${v}-${g}`;o=n[w],o?o.addFallback(l):(o=new Ma(l),n[w]=o,r.push(o)),qo(o,"audio",p),qo(o,"text",T)}),this.filterAndSortMediaOptions(r,e)}filterAndSortMediaOptions(t,e){let r=[],n=[],o=!1,l=!1,d=!1,f=t.filter(({audioCodec:A,videoCodec:T,width:w,height:C,unknownCodecs:D})=>(o||(o=!!(w&&C)),l||(l=!!T),d||(d=!!A),!(D!=null&&D.length)&&(!A||Wc(A,"audio"))&&(!T||Wc(T,"video"))));if((o||l)&&d&&(f=f.filter(({videoCodec:A,width:T,height:w})=>!!A||!!(T&&w))),f.length===0){Promise.resolve().then(()=>{if(this.hls){const A=new Error("no level with compatible codecs found in manifest");this.hls.trigger(R.ERROR,{type:Qt.MEDIA_ERROR,details:ut.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:e.url,error:A,reason:A.message})}});return}e.audioTracks&&(r=e.audioTracks.filter(A=>!A.audioCodec||Wc(A.audioCodec,"audio")),Nf(r)),e.subtitles&&(n=e.subtitles,Nf(n));const p=f.slice(0);f.sort((A,T)=>A.attrs["HDCP-LEVEL"]!==T.attrs["HDCP-LEVEL"]?(A.attrs["HDCP-LEVEL"]||"")>(T.attrs["HDCP-LEVEL"]||"")?1:-1:A.bitrate!==T.bitrate?A.bitrate-T.bitrate:A.attrs["FRAME-RATE"]!==T.attrs["FRAME-RATE"]?A.attrs.decimalFloatingPoint("FRAME-RATE")-T.attrs.decimalFloatingPoint("FRAME-RATE"):A.attrs.SCORE!==T.attrs.SCORE?A.attrs.decimalFloatingPoint("SCORE")-T.attrs.decimalFloatingPoint("SCORE"):o&&A.height!==T.height?A.height-T.height:0);let g=p[0];if(this.steering&&(f=this.steering.filterParsedLevels(f),f.length!==p.length)){for(let A=0;A<p.length;A++)if(p[A].pathwayId===f[0].pathwayId){g=p[A];break}}this._levels=f;for(let A=0;A<f.length;A++)if(f[A]===g){this._firstLevel=A,this.log(`manifest loaded, ${f.length} level(s) found, first bitrate: ${g.bitrate}`);break}const v=d&&!l,E={levels:f,audioTracks:r,subtitleTracks:n,sessionData:e.sessionData,sessionKeys:e.sessionKeys,firstLevel:this._firstLevel,stats:e.stats,audio:d,video:l,altAudio:!v&&r.some(A=>!!A.url)};this.hls.trigger(R.MANIFEST_PARSED,E),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}get levels(){return this._levels.length===0?null:this._levels}get level(){return this.currentLevelIndex}set level(t){const e=this._levels;if(e.length===0)return;if(t<0||t>=e.length){const g=new Error("invalid level idx"),v=t<0;if(this.hls.trigger(R.ERROR,{type:Qt.OTHER_ERROR,details:ut.LEVEL_SWITCH_ERROR,level:t,fatal:v,error:g,reason:g.message}),v)return;t=Math.min(t,e.length-1)}const r=this.currentLevelIndex,n=this.currentLevel,o=n?n.attrs["PATHWAY-ID"]:void 0,l=e[t],d=l.attrs["PATHWAY-ID"];if(this.currentLevelIndex=t,this.currentLevel=l,r===t&&l.details&&n&&o===d)return;this.log(`Switching to level ${t}${d?" with Pathway "+d:""} from level ${r}${o?" with Pathway "+o:""}`);const f=dr({},l,{level:t,maxBitrate:l.maxBitrate,attrs:l.attrs,uri:l.uri,urlId:l.urlId});delete f._attrs,delete f._urlId,this.hls.trigger(R.LEVEL_SWITCHING,f);const p=l.details;if(!p||p.live){const g=this.switchParams(l.uri,n==null?void 0:n.details);this.loadPlaylist(g)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(t){this.manualLevelIndex=t,this._startLevel===void 0&&(this._startLevel=t),t!==-1&&(this.level=t)}get firstLevel(){return this._firstLevel}set firstLevel(t){this._firstLevel=t}get startLevel(){if(this._startLevel===void 0){const t=this.hls.config.startLevel;return t!==void 0?t:this._firstLevel}else return this._startLevel}set startLevel(t){this._startLevel=t}onError(t,e){e.fatal||!e.context||e.context.type===Se.LEVEL&&e.context.level===this.level&&this.checkRetry(e)}onFragLoaded(t,{frag:e}){if(e!==void 0&&e.type===Jt.MAIN){const r=this._levels[e.level];r!==void 0&&(r.loadError=0)}}onLevelLoaded(t,e){var r;const{level:n,details:o}=e,l=this._levels[n];if(!l){var d;this.warn(`Invalid level index ${n}`),(d=e.deliveryDirectives)!=null&&d.skip&&(o.deltaUpdateFailed=!0);return}n===this.currentLevelIndex?(l.fragmentError===0&&(l.loadError=0),this.playlistLoaded(n,e,l.details)):(r=e.deliveryDirectives)!=null&&r.skip&&(o.deltaUpdateFailed=!0)}onAudioTrackSwitched(t,e){const r=this.currentLevel;if(!r)return;const n=this.hls.audioTracks[e.id].groupId;if(r.audioGroupIds&&r.audioGroupId!==n){let o=-1;for(let l=0;l<r.audioGroupIds.length;l++)if(r.audioGroupIds[l]===n){o=l;break}o!==-1&&o!==r.urlId&&(r.urlId=o,this.canLoad&&this.startLoad())}}loadPlaylist(t){super.loadPlaylist();const e=this.currentLevelIndex,r=this.currentLevel;if(r&&this.shouldLoadPlaylist(r)){const n=r.urlId;let o=r.uri;if(t)try{o=t.addDirectives(o)}catch(d){this.warn(`Could not construct new URL with HLS Delivery Directives: ${d}`)}const l=r.attrs["PATHWAY-ID"];this.log(`Loading level index ${e}${(t==null?void 0:t.msn)!==void 0?" at sn "+t.msn+" part "+t.part:""} with${l?" Pathway "+l:""} URI ${n+1}/${r.url.length} ${o}`),this.clearTimer(),this.hls.trigger(R.LEVEL_LOADING,{url:o,level:e,id:n,deliveryDirectives:t||null})}}get nextLoadLevel(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(t){this.level=t,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=t)}removeLevel(t,e){const r=(o,l)=>l!==e,n=this._levels.filter((o,l)=>l!==t?!0:o.url.length>1&&e!==void 0?(o.url=o.url.filter(r),o.audioGroupIds&&(o.audioGroupIds=o.audioGroupIds.filter(r)),o.textGroupIds&&(o.textGroupIds=o.textGroupIds.filter(r)),o.urlId=0,!0):(this.steering&&this.steering.removeLevel(o),!1));this.hls.trigger(R.LEVELS_UPDATED,{levels:n})}onLevelsUpdated(t,{levels:e}){e.forEach((r,n)=>{const{details:o}=r;o!=null&&o.fragments&&o.fragments.forEach(l=>{l.level=n})}),this._levels=e}}function qo(i,t,e){e&&(t==="audio"?(i.audioGroupIds||(i.audioGroupIds=[]),i.audioGroupIds[i.url.length-1]=e):t==="text"&&(i.textGroupIds||(i.textGroupIds=[]),i.textGroupIds[i.url.length-1]=e))}function Nf(i){const t={};i.forEach(e=>{const r=e.groupId||"";e.id=t[r]=t[r]||0,t[r]++})}var vr={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"};class u4{constructor(t){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=t,this._registerListeners()}_registerListeners(){const{hls:t}=this;t.on(R.BUFFER_APPENDED,this.onBufferAppended,this),t.on(R.FRAG_BUFFERED,this.onFragBuffered,this),t.on(R.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){const{hls:t}=this;t.off(R.BUFFER_APPENDED,this.onBufferAppended,this),t.off(R.FRAG_BUFFERED,this.onFragBuffered,this),t.off(R.FRAG_LOADED,this.onFragLoaded,this)}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(t,e){const r=this.activePartLists[e];if(r)for(let n=r.length;n--;){const o=r[n];if(!o)break;const l=o.end;if(o.start<=t&&l!==null&&t<=l)return o}return this.getBufferedFrag(t,e)}getBufferedFrag(t,e){const{fragments:r}=this,n=Object.keys(r);for(let o=n.length;o--;){const l=r[n[o]];if((l==null?void 0:l.body.type)===e&&l.buffered){const d=l.body;if(d.start<=t&&t<=d.end)return d}}return null}detectEvictedFragments(t,e,r,n){this.timeRanges&&(this.timeRanges[t]=e);const o=(n==null?void 0:n.fragment.sn)||-1;Object.keys(this.fragments).forEach(l=>{const d=this.fragments[l];if(!d||o>=d.body.sn)return;if(!d.buffered&&!d.loaded){d.body.type===r&&this.removeFragment(d.body);return}const f=d.range[t];f&&f.time.some(p=>{const g=!this.isTimeBuffered(p.startPTS,p.endPTS,e);return g&&this.removeFragment(d.body),g})})}detectPartialFragments(t){const e=this.timeRanges,{frag:r,part:n}=t;if(!e||r.sn==="initSegment")return;const o=Dn(r),l=this.fragments[o];if(!l||l.buffered&&r.gap)return;const d=!r.relurl;Object.keys(e).forEach(f=>{const p=r.elementaryStreams[f];if(!p)return;const g=e[f],v=d||p.partial===!0;l.range[f]=this.getBufferedTimes(r,n,v,g)}),l.loaded=null,Object.keys(l.range).length?(l.buffered=!0,(l.body.endList=r.endList||l.body.endList)&&(this.endListFragments[l.body.type]=l),Qo(l)||this.removeParts(r.sn-1,r.type)):this.removeFragment(l.body)}removeParts(t,e){const r=this.activePartLists[e];r&&(this.activePartLists[e]=r.filter(n=>n.fragment.sn>=t))}fragBuffered(t,e){const r=Dn(t);let n=this.fragments[r];!n&&e&&(n=this.fragments[r]={body:t,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},t.gap&&(this.hasGaps=!0)),n&&(n.loaded=null,n.buffered=!0)}getBufferedTimes(t,e,r,n){const o={time:[],partial:r},l=t.start,d=t.end,f=t.minEndPTS||d,p=t.maxStartPTS||l;for(let g=0;g<n.length;g++){const v=n.start(g)-this.bufferPadding,E=n.end(g)+this.bufferPadding;if(p>=v&&f<=E){o.time.push({startPTS:Math.max(l,n.start(g)),endPTS:Math.min(d,n.end(g))});break}else if(l<E&&d>v)o.partial=!0,o.time.push({startPTS:Math.max(l,n.start(g)),endPTS:Math.min(d,n.end(g))});else if(d<=v)break}return o}getPartialFragment(t){let e=null,r,n,o,l=0;const{bufferPadding:d,fragments:f}=this;return Object.keys(f).forEach(p=>{const g=f[p];g&&Qo(g)&&(n=g.body.start-d,o=g.body.end+d,t>=n&&t<=o&&(r=Math.min(t-n,o-t),l<=r&&(e=g.body,l=r)))}),e}isEndListAppended(t){const e=this.endListFragments[t];return e!==void 0&&(e.buffered||Qo(e))}getState(t){const e=Dn(t),r=this.fragments[e];return r?r.buffered?Qo(r)?vr.PARTIAL:vr.OK:vr.APPENDING:vr.NOT_LOADED}isTimeBuffered(t,e,r){let n,o;for(let l=0;l<r.length;l++){if(n=r.start(l)-this.bufferPadding,o=r.end(l)+this.bufferPadding,t>=n&&e<=o)return!0;if(e<=n)return!1}return!1}onFragLoaded(t,e){const{frag:r,part:n}=e;if(r.sn==="initSegment"||r.bitrateTest)return;const o=n?null:e,l=Dn(r);this.fragments[l]={body:r,appendedPTS:null,loaded:o,buffered:!1,range:Object.create(null)}}onBufferAppended(t,e){const{frag:r,part:n,timeRanges:o}=e;if(r.sn==="initSegment")return;const l=r.type;if(n){let d=this.activePartLists[l];d||(this.activePartLists[l]=d=[]),d.push(n)}this.timeRanges=o,Object.keys(o).forEach(d=>{const f=o[d];this.detectEvictedFragments(d,f,l,n)})}onFragBuffered(t,e){this.detectPartialFragments(e)}hasFragment(t){const e=Dn(t);return!!this.fragments[e]}hasParts(t){var e;return!!((e=this.activePartLists[t])!=null&&e.length)}removeFragmentsInRange(t,e,r,n,o){n&&!this.hasGaps||Object.keys(this.fragments).forEach(l=>{const d=this.fragments[l];if(!d)return;const f=d.body;f.type!==r||n&&!f.gap||f.start<e&&f.end>t&&(d.buffered||o)&&this.removeFragment(f)})}removeFragment(t){const e=Dn(t);t.stats.loaded=0,t.clearElementaryStreamInfo();const r=this.activePartLists[t.type];if(r){const n=t.sn;this.activePartLists[t.type]=r.filter(o=>o.fragment.sn!==n)}delete this.fragments[e],t.endList&&delete this.endListFragments[t.type]}removeAllFragments(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1}}function Qo(i){var t,e,r;return i.buffered&&(i.body.gap||((t=i.range.video)==null?void 0:t.partial)||((e=i.range.audio)==null?void 0:e.partial)||((r=i.range.audiovideo)==null?void 0:r.partial))}function Dn(i){return`${i.type}_${i.level}_${i.urlId}_${i.sn}`}const Ff=Math.pow(2,17);class f4{constructor(t){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=t}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(t,e){const r=t.url;if(!r)return Promise.reject(new ss({type:Qt.NETWORK_ERROR,details:ut.FRAG_LOAD_ERROR,fatal:!1,frag:t,error:new Error(`Fragment does not have a ${r?"part list":"url"}`),networkDetails:null}));this.abort();const n=this.config,o=n.fLoader,l=n.loader;return new Promise((d,f)=>{if(this.loader&&this.loader.destroy(),t.gap)if(t.tagList.some(A=>A[0]==="GAP")){f(Bf(t));return}else t.gap=!1;const p=this.loader=t.loader=o?new o(n):new l(n),g=Uf(t),v=$f(n.fragLoadPolicy.default),E={loadPolicy:v,timeout:v.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:t.sn==="initSegment"?1/0:Ff};t.stats=p.stats,p.load(g,E,{onSuccess:(A,T,w,C)=>{this.resetLoader(t,p);let D=A.data;w.resetIV&&t.decryptdata&&(t.decryptdata.iv=new Uint8Array(D.slice(0,16)),D=D.slice(16)),d({frag:t,part:null,payload:D,networkDetails:C})},onError:(A,T,w,C)=>{this.resetLoader(t,p),f(new ss({type:Qt.NETWORK_ERROR,details:ut.FRAG_LOAD_ERROR,fatal:!1,frag:t,response:zr({url:r,data:void 0},A),error:new Error(`HTTP Error ${A.code} ${A.text}`),networkDetails:w,stats:C}))},onAbort:(A,T,w)=>{this.resetLoader(t,p),f(new ss({type:Qt.NETWORK_ERROR,details:ut.INTERNAL_ABORTED,fatal:!1,frag:t,error:new Error("Aborted"),networkDetails:w,stats:A}))},onTimeout:(A,T,w)=>{this.resetLoader(t,p),f(new ss({type:Qt.NETWORK_ERROR,details:ut.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,error:new Error(`Timeout after ${E.timeout}ms`),networkDetails:w,stats:A}))},onProgress:(A,T,w,C)=>{e&&e({frag:t,part:null,payload:w,networkDetails:C})}})})}loadPart(t,e,r){this.abort();const n=this.config,o=n.fLoader,l=n.loader;return new Promise((d,f)=>{if(this.loader&&this.loader.destroy(),t.gap||e.gap){f(Bf(t,e));return}const p=this.loader=t.loader=o?new o(n):new l(n),g=Uf(t,e),v=$f(n.fragLoadPolicy.default),E={loadPolicy:v,timeout:v.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:Ff};e.stats=p.stats,p.load(g,E,{onSuccess:(A,T,w,C)=>{this.resetLoader(t,p),this.updateStatsFromPart(t,e);const D={frag:t,part:e,payload:A.data,networkDetails:C};r(D),d(D)},onError:(A,T,w,C)=>{this.resetLoader(t,p),f(new ss({type:Qt.NETWORK_ERROR,details:ut.FRAG_LOAD_ERROR,fatal:!1,frag:t,part:e,response:zr({url:g.url,data:void 0},A),error:new Error(`HTTP Error ${A.code} ${A.text}`),networkDetails:w,stats:C}))},onAbort:(A,T,w)=>{t.stats.aborted=e.stats.aborted,this.resetLoader(t,p),f(new ss({type:Qt.NETWORK_ERROR,details:ut.INTERNAL_ABORTED,fatal:!1,frag:t,part:e,error:new Error("Aborted"),networkDetails:w,stats:A}))},onTimeout:(A,T,w)=>{this.resetLoader(t,p),f(new ss({type:Qt.NETWORK_ERROR,details:ut.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,part:e,error:new Error(`Timeout after ${E.timeout}ms`),networkDetails:w,stats:A}))}})})}updateStatsFromPart(t,e){const r=t.stats,n=e.stats,o=n.total;if(r.loaded+=n.loaded,o){const f=Math.round(t.duration/e.duration),p=Math.min(Math.round(r.loaded/o),f),g=(f-p)*Math.round(r.loaded/p);r.total=r.loaded+g}else r.total=Math.max(r.loaded,r.total);const l=r.loading,d=n.loading;l.start?l.first+=d.first-d.start:(l.start=d.start,l.first=d.first),l.end=d.end}resetLoader(t,e){t.loader=null,this.loader===e&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),e.destroy()}}function Uf(i,t=null){const e=t||i,r={frag:i,part:t,responseType:"arraybuffer",url:e.url,headers:{},rangeStart:0,rangeEnd:0},n=e.byteRangeStartOffset,o=e.byteRangeEndOffset;if(jt(n)&&jt(o)){var l;let d=n,f=o;if(i.sn==="initSegment"&&((l=i.decryptdata)==null?void 0:l.method)==="AES-128"){const p=o-n;p%16&&(f=o+(16-p%16)),n!==0&&(r.resetIV=!0,d=n-16)}r.rangeStart=d,r.rangeEnd=f}return r}function Bf(i,t){const e=new Error(`GAP ${i.gap?"tag":"attribute"} found`),r={type:Qt.MEDIA_ERROR,details:ut.FRAG_GAP,fatal:!1,frag:i,error:e,networkDetails:null};return t&&(r.part=t),(t||i).stats.aborted=!0,new ss(r)}class ss extends Error{constructor(t){super(t.error.message),this.data=void 0,this.data=t}}class p4{constructor(t){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=t}abort(t){for(const e in this.keyUriToKeyInfo){const r=this.keyUriToKeyInfo[e].loader;if(r){if(t&&t!==r.context.frag.type)return;r.abort()}}}detach(){for(const t in this.keyUriToKeyInfo){const e=this.keyUriToKeyInfo[t];(e.mediaKeySessionContext||e.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[t]}}destroy(){this.detach();for(const t in this.keyUriToKeyInfo){const e=this.keyUriToKeyInfo[t].loader;e&&e.destroy()}this.keyUriToKeyInfo={}}createKeyLoadError(t,e=ut.KEY_LOAD_ERROR,r,n,o){return new ss({type:Qt.NETWORK_ERROR,details:e,fatal:!1,frag:t,response:o,error:r,networkDetails:n})}loadClear(t,e){if(this.emeController&&this.config.emeEnabled){const{sn:r,cc:n}=t;for(let o=0;o<e.length;o++){const l=e[o];if(n<=l.cc&&(r==="initSegment"||l.sn==="initSegment"||r<l.sn)){this.emeController.selectKeySystemFormat(l).then(d=>{l.setKeyFormat(d)});break}}}}load(t){return!t.decryptdata&&t.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(t).then(e=>this.loadInternal(t,e)):this.loadInternal(t)}loadInternal(t,e){var r,n;e&&t.setKeyFormat(e);const o=t.decryptdata;if(!o){const p=new Error(e?`Expected frag.decryptdata to be defined after setting format ${e}`:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(t,ut.KEY_LOAD_ERROR,p))}const l=o.uri;if(!l)return Promise.reject(this.createKeyLoadError(t,ut.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${l}"`)));let d=this.keyUriToKeyInfo[l];if((r=d)!=null&&r.decryptdata.key)return o.key=d.decryptdata.key,Promise.resolve({frag:t,keyInfo:d});if((n=d)!=null&&n.keyLoadPromise){var f;switch((f=d.mediaKeySessionContext)==null?void 0:f.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return d.keyLoadPromise.then(p=>(o.key=p.keyInfo.decryptdata.key,{frag:t,keyInfo:d}))}}switch(d=this.keyUriToKeyInfo[l]={decryptdata:o,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},o.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return o.keyFormat==="identity"?this.loadKeyHTTP(d,t):this.loadKeyEME(d,t);case"AES-128":return this.loadKeyHTTP(d,t);default:return Promise.reject(this.createKeyLoadError(t,ut.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${o.method}"`)))}}loadKeyEME(t,e){const r={frag:e,keyInfo:t};if(this.emeController&&this.config.emeEnabled){const n=this.emeController.loadKey(r);if(n)return(t.keyLoadPromise=n.then(o=>(t.mediaKeySessionContext=o,r))).catch(o=>{throw t.keyLoadPromise=null,o})}return Promise.resolve(r)}loadKeyHTTP(t,e){const r=this.config,n=r.loader,o=new n(r);return e.keyLoader=t.loader=o,t.keyLoadPromise=new Promise((l,d)=>{const f={keyInfo:t,frag:e,responseType:"arraybuffer",url:t.decryptdata.uri},p=r.keyLoadPolicy.default,g={loadPolicy:p,timeout:p.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},v={onSuccess:(E,A,T,w)=>{const{frag:C,keyInfo:D,url:M}=T;if(!C.decryptdata||D!==this.keyUriToKeyInfo[M])return d(this.createKeyLoadError(C,ut.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),w));D.decryptdata.key=C.decryptdata.key=new Uint8Array(E.data),C.keyLoader=null,D.loader=null,l({frag:C,keyInfo:D})},onError:(E,A,T,w)=>{this.resetLoader(A),d(this.createKeyLoadError(e,ut.KEY_LOAD_ERROR,new Error(`HTTP Error ${E.code} loading key ${E.text}`),T,zr({url:f.url,data:void 0},E)))},onTimeout:(E,A,T)=>{this.resetLoader(A),d(this.createKeyLoadError(e,ut.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),T))},onAbort:(E,A,T)=>{this.resetLoader(A),d(this.createKeyLoadError(e,ut.INTERNAL_ABORTED,new Error("key loading aborted"),T))}};o.load(f,g,v)})}resetLoader(t){const{frag:e,keyInfo:r,url:n}=t,o=r.loader;e.keyLoader===o&&(e.keyLoader=null,r.loader=null),delete this.keyUriToKeyInfo[n],o&&o.destroy()}}class g4{constructor(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed()}onHandlerDestroying(){this.clearNextTick(),this.clearInterval()}onHandlerDestroyed(){}hasInterval(){return!!this._tickInterval}hasNextTick(){return!!this._tickTimer}setInterval(t){return this._tickInterval?!1:(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,t),!0)}clearInterval(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1}clearNextTick(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1}tick(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}}const m4={length:0,start:()=>0,end:()=>0};class Ve{static isBuffered(t,e){try{if(t){const r=Ve.getBuffered(t);for(let n=0;n<r.length;n++)if(e>=r.start(n)&&e<=r.end(n))return!0}}catch{}return!1}static bufferInfo(t,e,r){try{if(t){const n=Ve.getBuffered(t),o=[];let l;for(l=0;l<n.length;l++)o.push({start:n.start(l),end:n.end(l)});return this.bufferedInfo(o,e,r)}}catch{}return{len:0,start:e,end:e,nextStart:void 0}}static bufferedInfo(t,e,r){e=Math.max(0,e),t.sort(function(p,g){return p.start-g.start||g.end-p.end});let n=[];if(r)for(let p=0;p<t.length;p++){const g=n.length;if(g){const v=n[g-1].end;t[p].start-v<r?t[p].end>v&&(n[g-1].end=t[p].end):n.push(t[p])}else n.push(t[p])}else n=t;let o=0,l,d=e,f=e;for(let p=0;p<n.length;p++){const g=n[p].start,v=n[p].end;if(e+r>=g&&e<v)d=g,f=v,o=f-e;else if(e+r<g){l=g;break}}return{len:o,start:d||0,end:f||0,nextStart:l}}static getBuffered(t){try{return t.buffered}catch(e){return X.log("failed to get media.buffered",e),m4}}}class rh{constructor(t,e,r,n=0,o=-1,l=!1){this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing=Jo(),this.buffering={audio:Jo(),video:Jo(),audiovideo:Jo()},this.level=t,this.sn=e,this.id=r,this.size=n,this.part=o,this.partial=l}}function Jo(){return{start:0,executeStart:0,executeEnd:0,end:0}}function Gf(i,t){let e=null;for(let r=0,n=i.length;r<n;r++){const o=i[r];if(o&&o.cc===t){e=o;break}}return e}function v4(i,t,e){return!!(t.details&&(e.endCC>e.startCC||i&&i.cc<e.startCC))}function y4(i,t,e=0){const r=i.fragments,n=t.fragments;if(!n.length||!r.length){X.log("No fragments to align");return}const o=Gf(r,n[0].cc);if(!o||o&&!o.startPTS){X.log("No frag in previous level to align on");return}return o}function Hf(i,t){if(i){const e=i.start+t;i.start=i.startPTS=e,i.endPTS=e+i.duration}}function ih(i,t){const e=t.fragments;for(let r=0,n=e.length;r<n;r++)Hf(e[r],i);t.fragmentHint&&Hf(t.fragmentHint,i),t.alignedSliding=!0}function b4(i,t,e){t&&(E4(i,e,t),!e.alignedSliding&&t.details&&A4(e,t.details),!e.alignedSliding&&t.details&&!e.skippedSegments&&xf(t.details,e))}function E4(i,t,e){if(v4(i,e,t)){const r=y4(e.details,t);r&&jt(r.start)&&(X.log(`Adjusting PTS using last level due to CC increase within current level ${t.url}`),ih(r.start,t))}}function A4(i,t){if(!t.fragments.length||!i.hasProgramDateTime||!t.hasProgramDateTime)return;const e=t.fragments[0].programDateTime,r=i.fragments[0].programDateTime,n=(r-e)/1e3+t.fragments[0].start;n&&jt(n)&&(X.log(`Adjusting PTS using programDateTime delta ${r-e}ms, sliding:${n.toFixed(3)} ${i.url} `),ih(n,i))}function Vf(i,t){if(!i.hasProgramDateTime||!t.hasProgramDateTime)return;const e=i.fragments,r=t.fragments;if(!e.length||!r.length)return;const n=Math.round(r.length/2)-1,o=r[n],l=Gf(e,o.cc)||e[Math.round(e.length/2)-1],d=o.programDateTime,f=l.programDateTime;if(d===null||f===null)return;const p=(f-d)/1e3-(l.start-o.start);ih(p,i)}class T4{constructor(t,e){this.subtle=void 0,this.aesIV=void 0,this.subtle=t,this.aesIV=e}decrypt(t,e){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},e,t)}}class k4{constructor(t,e){this.subtle=void 0,this.key=void 0,this.subtle=t,this.key=e}expandKey(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])}}function w4(i){const t=i.byteLength,e=t&&new DataView(i.buffer).getUint8(t-1);return e?un(i,0,t-e):i}class S4{constructor(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}uint8ArrayToUint32Array_(t){const e=new DataView(t),r=new Uint32Array(4);for(let n=0;n<4;n++)r[n]=e.getUint32(n*4);return r}initTable(){const t=this.sBox,e=this.invSBox,r=this.subMix,n=r[0],o=r[1],l=r[2],d=r[3],f=this.invSubMix,p=f[0],g=f[1],v=f[2],E=f[3],A=new Uint32Array(256);let T=0,w=0,C=0;for(C=0;C<256;C++)C<128?A[C]=C<<1:A[C]=C<<1^283;for(C=0;C<256;C++){let D=w^w<<1^w<<2^w<<3^w<<4;D=D>>>8^D&255^99,t[T]=D,e[D]=T;const M=A[T],U=A[M],x=A[U];let O=A[D]*257^D*16843008;n[T]=O<<24|O>>>8,o[T]=O<<16|O>>>16,l[T]=O<<8|O>>>24,d[T]=O,O=x*16843009^U*65537^M*257^T*16843008,p[D]=O<<24|O>>>8,g[D]=O<<16|O>>>16,v[D]=O<<8|O>>>24,E[D]=O,T?(T=M^A[A[A[x^M]]],w^=A[A[w]]):T=w=1}}expandKey(t){const e=this.uint8ArrayToUint32Array_(t);let r=!0,n=0;for(;n<e.length&&r;)r=e[n]===this.key[n],n++;if(r)return;this.key=e;const o=this.keySize=e.length;if(o!==4&&o!==6&&o!==8)throw new Error("Invalid aes key size="+o);const l=this.ksRows=(o+6+1)*4;let d,f;const p=this.keySchedule=new Uint32Array(l),g=this.invKeySchedule=new Uint32Array(l),v=this.sBox,E=this.rcon,A=this.invSubMix,T=A[0],w=A[1],C=A[2],D=A[3];let M,U;for(d=0;d<l;d++){if(d<o){M=p[d]=e[d];continue}U=M,d%o===0?(U=U<<8|U>>>24,U=v[U>>>24]<<24|v[U>>>16&255]<<16|v[U>>>8&255]<<8|v[U&255],U^=E[d/o|0]<<24):o>6&&d%o===4&&(U=v[U>>>24]<<24|v[U>>>16&255]<<16|v[U>>>8&255]<<8|v[U&255]),p[d]=M=(p[d-o]^U)>>>0}for(f=0;f<l;f++)d=l-f,f&3?U=p[d]:U=p[d-4],f<4||d<=4?g[f]=U:g[f]=T[v[U>>>24]]^w[v[U>>>16&255]]^C[v[U>>>8&255]]^D[v[U&255]],g[f]=g[f]>>>0}networkToHostOrderSwap(t){return t<<24|(t&65280)<<8|(t&16711680)>>8|t>>>24}decrypt(t,e,r){const n=this.keySize+6,o=this.invKeySchedule,l=this.invSBox,d=this.invSubMix,f=d[0],p=d[1],g=d[2],v=d[3],E=this.uint8ArrayToUint32Array_(r);let A=E[0],T=E[1],w=E[2],C=E[3];const D=new Int32Array(t),M=new Int32Array(D.length);let U,x,O,K,B,at,st,J,kt,ft,wt,Pt,F,j;const bt=this.networkToHostOrderSwap;for(;e<D.length;){for(kt=bt(D[e]),ft=bt(D[e+1]),wt=bt(D[e+2]),Pt=bt(D[e+3]),B=kt^o[0],at=Pt^o[1],st=wt^o[2],J=ft^o[3],F=4,j=1;j<n;j++)U=f[B>>>24]^p[at>>16&255]^g[st>>8&255]^v[J&255]^o[F],x=f[at>>>24]^p[st>>16&255]^g[J>>8&255]^v[B&255]^o[F+1],O=f[st>>>24]^p[J>>16&255]^g[B>>8&255]^v[at&255]^o[F+2],K=f[J>>>24]^p[B>>16&255]^g[at>>8&255]^v[st&255]^o[F+3],B=U,at=x,st=O,J=K,F=F+4;U=l[B>>>24]<<24^l[at>>16&255]<<16^l[st>>8&255]<<8^l[J&255]^o[F],x=l[at>>>24]<<24^l[st>>16&255]<<16^l[J>>8&255]<<8^l[B&255]^o[F+1],O=l[st>>>24]<<24^l[J>>16&255]<<16^l[B>>8&255]<<8^l[at&255]^o[F+2],K=l[J>>>24]<<24^l[B>>16&255]<<16^l[at>>8&255]<<8^l[st&255]^o[F+3],M[e]=bt(U^A),M[e+1]=bt(K^T),M[e+2]=bt(O^w),M[e+3]=bt(x^C),A=kt,T=ft,w=wt,C=Pt,e=e+4}return M.buffer}}const R4=16;class sh{constructor(t,{removePKCS7Padding:e=!0}={}){if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.useSoftware=t.enableSoftwareAES,this.removePKCS7Padding=e,e)try{const r=self.crypto;r&&(this.subtle=r.subtle||r.webkitSubtle)}catch{}this.subtle===null&&(this.useSoftware=!0)}destroy(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}isSync(){return this.useSoftware}flush(){const{currentResult:t,remainderData:e}=this;if(!t||e)return this.reset(),null;const r=new Uint8Array(t);return this.reset(),this.removePKCS7Padding?w4(r):r}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(t,e,r){return this.useSoftware?new Promise((n,o)=>{this.softwareDecrypt(new Uint8Array(t),e,r);const l=this.flush();l?n(l.buffer):o(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(t),e,r)}softwareDecrypt(t,e,r){const{currentIV:n,currentResult:o,remainderData:l}=this;this.logOnce("JS AES decrypt"),l&&(t=fn(l,t),this.remainderData=null);const d=this.getValidChunk(t);if(!d.length)return null;n&&(r=n);let f=this.softwareDecrypter;f||(f=this.softwareDecrypter=new S4),f.expandKey(e);const p=o;return this.currentResult=f.decrypt(d.buffer,0,r),this.currentIV=un(d,-16).buffer,p||null}webCryptoDecrypt(t,e,r){const n=this.subtle;return(this.key!==e||!this.fastAesKey)&&(this.key=e,this.fastAesKey=new k4(n,e)),this.fastAesKey.expandKey().then(o=>n?(this.logOnce("WebCrypto AES decrypt"),new T4(n,new Uint8Array(r)).decrypt(t.buffer,o)):Promise.reject(new Error("web crypto not initialized"))).catch(o=>(X.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${o.name}: ${o.message}`),this.onWebCryptoError(t,e,r)))}onWebCryptoError(t,e,r){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(t,e,r);const n=this.flush();if(n)return n.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(t){let e=t;const r=t.length-t.length%R4;return r!==t.length&&(e=un(t,0,r),this.remainderData=un(t,r)),e}logOnce(t){this.logEnabled&&(X.log(`[decrypter]: ${t}`),this.logEnabled=!1)}}const _4={toString:function(i){let t="";const e=i.length;for(let r=0;r<e;r++)t+=`[${i.start(r).toFixed(3)}-${i.end(r).toFixed(3)}]`;return t}},Rt={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 nh extends g4{constructor(t,e,r,n,o){super(),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=Rt.STOPPED,this.playlistType=void 0,this.media=null,this.mediaBuffer=null,this.config=void 0,this.bitrateTest=!1,this.lastCurrentTime=0,this.nextLoadPosition=0,this.startPosition=0,this.startTimeOffset=null,this.loadedmetadata=!1,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.keyLoader=void 0,this.levelLastLoaded=null,this.startFragRequested=!1,this.decrypter=void 0,this.initPTS=[],this.onvseeking=null,this.onvended=null,this.logPrefix="",this.log=void 0,this.warn=void 0,this.playlistType=o,this.logPrefix=n,this.log=X.log.bind(X,`${n}:`),this.warn=X.warn.bind(X,`${n}:`),this.hls=t,this.fragmentLoader=new f4(t.config),this.keyLoader=r,this.fragmentTracker=e,this.config=t.config,this.decrypter=new sh(t.config),t.on(R.MANIFEST_LOADED,this.onManifestLoaded,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(t){}stopLoad(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);const t=this.fragCurrent;t!=null&&t.loader&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=Rt.STOPPED}_streamEnded(t,e){if(e.live||t.nextStart||!t.end||!this.media)return!1;const r=e.partList;if(r!=null&&r.length){const o=r[r.length-1];return Ve.isBuffered(this.media,o.start+o.duration/2)}const n=e.fragments[e.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(n)}getLevelDetails(){if(this.levels&&this.levelLastLoaded!==null){var t;return(t=this.levels[this.levelLastLoaded])==null?void 0:t.details}}onMediaAttached(t,e){const r=this.media=this.mediaBuffer=e.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),r.addEventListener("seeking",this.onvseeking),r.addEventListener("ended",this.onvended);const n=this.config;this.levels&&n.autoStartLoad&&this.state===Rt.STOPPED&&this.startLoad(n.startPosition)}onMediaDetaching(){const t=this.media;t!=null&&t.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),t&&this.onvseeking&&this.onvended&&(t.removeEventListener("seeking",this.onvseeking),t.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}onMediaSeeking(){const{config:t,fragCurrent:e,media:r,mediaBuffer:n,state:o}=this,l=r?r.currentTime:0,d=Ve.bufferInfo(n||r,l,t.maxBufferHole);if(this.log(`media seeking to ${jt(l)?l.toFixed(3):l}, state: ${o}`),this.state===Rt.ENDED)this.resetLoadingState();else if(e){const f=t.maxFragLookUpTolerance,p=e.start-f,g=e.start+e.duration+f;if(!d.len||g<d.start||p>d.end){const v=l>g;(l<p||v)&&(v&&e.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),e.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}r&&(this.fragmentTracker.removeFragmentsInRange(l,1/0,this.playlistType,!0),this.lastCurrentTime=l),!this.loadedmetadata&&!d.len&&(this.nextLoadPosition=this.startPosition=l),this.tickImmediate()}onMediaEnded(){this.startPosition=this.lastCurrentTime=0}onManifestLoaded(t,e){this.startTimeOffset=e.startTimeOffset,this.initPTS=[]}onHandlerDestroying(){this.stopLoad(),super.onHandlerDestroying()}onHandlerDestroyed(){this.state=Rt.STOPPED,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,super.onHandlerDestroyed()}loadFragment(t,e,r){this._loadFragForPlayback(t,e,r)}_loadFragForPlayback(t,e,r){const n=o=>{if(this.fragContextChanged(t)){this.warn(`Fragment ${t.sn}${o.part?" p: "+o.part.index:""} of level ${t.level} was dropped during download.`),this.fragmentTracker.removeFragment(t);return}t.stats.chunkCount++,this._handleFragmentLoadProgress(o)};this._doFragLoad(t,e,r,n).then(o=>{if(!o)return;const l=this.state;if(this.fragContextChanged(t)){(l===Rt.FRAG_LOADING||!this.fragCurrent&&l===Rt.PARSING)&&(this.fragmentTracker.removeFragment(t),this.state=Rt.IDLE);return}"payload"in o&&(this.log(`Loaded fragment ${t.sn} of level ${t.level}`),this.hls.trigger(R.FRAG_LOADED,o)),this._handleFragmentLoadComplete(o)}).catch(o=>{this.state===Rt.STOPPED||this.state===Rt.ERROR||(this.warn(o),this.resetFragmentLoading(t))})}clearTrackerIfNeeded(t){var e;const{fragmentTracker:r}=this;if(r.getState(t)===vr.APPENDING){const n=t.type,o=this.getFwdBufferInfo(this.mediaBuffer,n),l=Math.max(t.duration,o?o.len:this.config.maxBufferLength);this.reduceMaxBufferLength(l)&&r.removeFragment(t)}else((e=this.mediaBuffer)==null?void 0:e.buffered.length)===0?r.removeAllFragments():r.hasParts(t.type)&&(r.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type}),r.getState(t)===vr.PARTIAL&&r.removeFragment(t))}checkLiveUpdate(t){if(t.updated&&!t.live){const e=t.fragments[t.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type})}t.fragments[0]||(t.deltaUpdateFailed=!0)}flushMainBuffer(t,e,r=null){if(!(t-e))return;const n={startOffset:t,endOffset:e,type:r};this.hls.trigger(R.BUFFER_FLUSHING,n)}_loadInitSegment(t,e){this._doFragLoad(t,e).then(r=>{if(!r||this.fragContextChanged(t)||!this.levels)throw new Error("init load aborted");return r}).then(r=>{const{hls:n}=this,{payload:o}=r,l=t.decryptdata;if(o&&o.byteLength>0&&l&&l.key&&l.iv&&l.method==="AES-128"){const d=self.performance.now();return this.decrypter.decrypt(new Uint8Array(o),l.key.buffer,l.iv.buffer).catch(f=>{throw n.trigger(R.ERROR,{type:Qt.MEDIA_ERROR,details:ut.FRAG_DECRYPT_ERROR,fatal:!1,error:f,reason:f.message,frag:t}),f}).then(f=>{const p=self.performance.now();return n.trigger(R.FRAG_DECRYPTED,{frag:t,payload:f,stats:{tstart:d,tdecrypt:p}}),r.payload=f,r})}return r}).then(r=>{const{fragCurrent:n,hls:o,levels:l}=this;if(!l)throw new Error("init load aborted, missing levels");const d=t.stats;this.state=Rt.IDLE,e.fragmentError=0,t.data=new Uint8Array(r.payload),d.parsing.start=d.buffering.start=self.performance.now(),d.parsing.end=d.buffering.end=self.performance.now(),r.frag===n&&o.trigger(R.FRAG_BUFFERED,{stats:d,frag:n,part:null,id:t.type}),this.tick()}).catch(r=>{this.state===Rt.STOPPED||this.state===Rt.ERROR||(this.warn(r),this.resetFragmentLoading(t))})}fragContextChanged(t){const{fragCurrent:e}=this;return!t||!e||t.level!==e.level||t.sn!==e.sn||t.urlId!==e.urlId}fragBufferedComplete(t,e){var r,n,o,l;const d=this.mediaBuffer?this.mediaBuffer:this.media;this.log(`Buffered ${t.type} sn: ${t.sn}${e?" part: "+e.index:""} of ${this.playlistType===Jt.MAIN?"level":"track"} ${t.level} (frag:[${((r=t.startPTS)!=null?r:NaN).toFixed(3)}-${((n=t.endPTS)!=null?n:NaN).toFixed(3)}] > buffer:${d?_4.toString(Ve.getBuffered(d)):"(detached)"})`),this.state=Rt.IDLE,d&&(!this.loadedmetadata&&t.type==Jt.MAIN&&d.buffered.length&&((o=this.fragCurrent)==null?void 0:o.sn)===((l=this.fragPrevious)==null?void 0:l.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())}seekToStartPos(){}_handleFragmentLoadComplete(t){const{transmuxer:e}=this;if(!e)return;const{frag:r,part:n,partsLoaded:o}=t,l=!o||o.length===0||o.some(f=>!f),d=new rh(r.level,r.sn,r.stats.chunkCount+1,0,n?n.index:-1,!l);e.flush(d)}_handleFragmentLoadProgress(t){}_doFragLoad(t,e,r=null,n){var o;const l=e==null?void 0:e.details;if(!this.levels||!l)throw new Error(`frag load aborted, missing level${l?"":" detail"}s`);let d=null;if(t.encrypted&&!((o=t.decryptdata)!=null&&o.key)?(this.log(`Loading key for ${t.sn} of [${l.startSN}-${l.endSN}], ${this.logPrefix==="[stream-controller]"?"level":"track"} ${t.level}`),this.state=Rt.KEY_LOADING,this.fragCurrent=t,d=this.keyLoader.load(t).then(g=>{if(!this.fragContextChanged(g.frag))return this.hls.trigger(R.KEY_LOADED,g),this.state===Rt.KEY_LOADING&&(this.state=Rt.IDLE),g}),this.hls.trigger(R.KEY_LOADING,{frag:t}),this.fragCurrent===null&&(d=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))):!t.encrypted&&l.encryptedFragments.length&&this.keyLoader.loadClear(t,l.encryptedFragments),r=Math.max(t.start,r||0),this.config.lowLatencyMode&&t.sn!=="initSegment"){const g=l.partList;if(g&&n){r>t.end&&l.fragmentHint&&(t=l.fragmentHint);const v=this.getNextPart(g,t,r);if(v>-1){const E=g[v];this.log(`Loading part sn: ${t.sn} p: ${E.index} cc: ${t.cc} of playlist [${l.startSN}-${l.endSN}] parts [0-${v}-${g.length-1}] ${this.logPrefix==="[stream-controller]"?"level":"track"}: ${t.level}, target: ${parseFloat(r.toFixed(3))}`),this.nextLoadPosition=E.start+E.duration,this.state=Rt.FRAG_LOADING;let A;return d?A=d.then(T=>!T||this.fragContextChanged(T.frag)?null:this.doFragPartsLoad(t,E,e,n)).catch(T=>this.handleFragLoadError(T)):A=this.doFragPartsLoad(t,E,e,n).catch(T=>this.handleFragLoadError(T)),this.hls.trigger(R.FRAG_LOADING,{frag:t,part:E,targetBufferTime:r}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):A}else if(!t.url||this.loadedEndOfParts(g,r))return Promise.resolve(null)}}this.log(`Loading fragment ${t.sn} cc: ${t.cc} ${l?"of ["+l.startSN+"-"+l.endSN+"] ":""}${this.logPrefix==="[stream-controller]"?"level":"track"}: ${t.level}, target: ${parseFloat(r.toFixed(3))}`),jt(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=Rt.FRAG_LOADING;const f=this.config.progressive;let p;return f&&d?p=d.then(g=>!g||this.fragContextChanged(g==null?void 0:g.frag)?null:this.fragmentLoader.load(t,n)).catch(g=>this.handleFragLoadError(g)):p=Promise.all([this.fragmentLoader.load(t,f?n:void 0),d]).then(([g])=>(!f&&g&&n&&n(g),g)).catch(g=>this.handleFragLoadError(g)),this.hls.trigger(R.FRAG_LOADING,{frag:t,targetBufferTime:r}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):p}doFragPartsLoad(t,e,r,n){return new Promise((o,l)=>{var d;const f=[],p=(d=r.details)==null?void 0:d.partList,g=v=>{this.fragmentLoader.loadPart(t,v,n).then(E=>{f[v.index]=E;const A=E.part;this.hls.trigger(R.FRAG_LOADED,E);const T=Df(r,t.sn,v.index+1)||Pf(p,t.sn,v.index+1);if(T)g(T);else return o({frag:t,part:A,partsLoaded:f})}).catch(l)};g(e)})}handleFragLoadError(t){if("data"in t){const e=t.data;t.data&&e.details===ut.INTERNAL_ABORTED?this.handleFragLoadAborted(e.frag,e.part):this.hls.trigger(R.ERROR,e)}else this.hls.trigger(R.ERROR,{type:Qt.OTHER_ERROR,details:ut.INTERNAL_EXCEPTION,err:t,error:t,fatal:!0});return null}_handleTransmuxerFlush(t){const e=this.getCurrentContext(t);if(!e||this.state!==Rt.PARSING){!this.fragCurrent&&this.state!==Rt.STOPPED&&this.state!==Rt.ERROR&&(this.state=Rt.IDLE);return}const{frag:r,part:n,level:o}=e,l=self.performance.now();r.stats.parsing.end=l,n&&(n.stats.parsing.end=l),this.updateLevelTiming(r,n,o,t.partial)}getCurrentContext(t){const{levels:e,fragCurrent:r}=this,{level:n,sn:o,part:l}=t;if(!(e!=null&&e[n]))return this.warn(`Levels object was unset while buffering fragment ${o} of level ${n}. The current chunk will not be buffered.`),null;const d=e[n],f=l>-1?Df(d,o,l):null,p=f?f.fragment:i4(d,o,r);return p?(r&&r!==p&&(p.stats=r.stats),{frag:p,part:f,level:d}):null}bufferFragmentData(t,e,r,n,o){var l;if(!t||this.state!==Rt.PARSING)return;const{data1:d,data2:f}=t;let p=d;if(d&&f&&(p=fn(d,f)),!((l=p)!=null&&l.length))return;const g={type:t.type,frag:e,part:r,chunkMeta:n,parent:e.type,data:p};if(this.hls.trigger(R.BUFFER_APPENDING,g),t.dropped&&t.independent&&!r){if(o)return;this.flushBufferGap(e)}}flushBufferGap(t){const e=this.media;if(!e)return;if(!Ve.isBuffered(e,e.currentTime)){this.flushMainBuffer(0,t.start);return}const r=e.currentTime,n=Ve.bufferInfo(e,r,0),o=t.duration,l=Math.min(this.config.maxFragLookUpTolerance*2,o*.25),d=Math.max(Math.min(t.start-l,n.end-l),r+l);t.start-d>l&&this.flushMainBuffer(d,t.start)}getFwdBufferInfo(t,e){const r=this.getLoadPosition();return jt(r)?this.getFwdBufferInfoAtPos(t,r,e):null}getFwdBufferInfoAtPos(t,e,r){const{config:{maxBufferHole:n}}=this,o=Ve.bufferInfo(t,e,n);if(o.len===0&&o.nextStart!==void 0){const l=this.fragmentTracker.getBufferedFrag(e,r);if(l&&o.nextStart<l.end)return Ve.bufferInfo(t,e,Math.max(o.nextStart,n))}return o}getMaxBufferLength(t){const{config:e}=this;let r;return t?r=Math.max(8*e.maxBufferSize/t,e.maxBufferLength):r=e.maxBufferLength,Math.min(r,e.maxMaxBufferLength)}reduceMaxBufferLength(t){const e=this.config,r=t||e.maxBufferLength;return e.maxMaxBufferLength>=r?(e.maxMaxBufferLength/=2,this.warn(`Reduce max buffer length to ${e.maxMaxBufferLength}s`),!0):!1}getAppendedFrag(t,e=Jt.MAIN){const r=this.fragmentTracker.getAppendedFrag(t,Jt.MAIN);return r&&"fragment"in r?r.fragment:r}getNextFragment(t,e){const r=e.fragments,n=r.length;if(!n)return null;const{config:o}=this,l=r[0].start;let d;if(e.live){const f=o.initialLiveManifestSize;if(n<f)return this.warn(`Not enough fragments to start playback (have: ${n}, need: ${f})`),null;!e.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(d=this.getInitialLiveFragment(e,r),this.startPosition=d?this.hls.liveSyncPosition||d.start:t)}else t<=l&&(d=r[0]);if(!d){const f=o.lowLatencyMode?e.partEnd:e.fragmentEnd;d=this.getFragmentAtPosition(t,f,e)}return this.mapToInitFragWhenRequired(d)}isLoopLoading(t,e){const r=this.fragmentTracker.getState(t);return(r===vr.OK||r===vr.PARTIAL&&!!t.gap)&&this.nextLoadPosition>e}getNextFragmentLoopLoading(t,e,r,n,o){const l=t.gap,d=this.getNextFragment(this.nextLoadPosition,e);if(d===null)return d;if(t=d,l&&t&&!t.gap&&r.nextStart){const f=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,r.nextStart,n);if(f!==null&&r.len+f.len>=o)return this.log(`buffer full after gaps in "${n}" playlist starting at sn: ${t.sn}`),null}return t}mapToInitFragWhenRequired(t){return t!=null&&t.initSegment&&!(t!=null&&t.initSegment.data)&&!this.bitrateTest?t.initSegment:t}getNextPart(t,e,r){let n=-1,o=!1,l=!0;for(let d=0,f=t.length;d<f;d++){const p=t[d];if(l=l&&!p.independent,n>-1&&r<p.start)break;const g=p.loaded;g?n=-1:(o||p.independent||l)&&p.fragment===e&&(n=d),o=g}return n}loadedEndOfParts(t,e){const r=t[t.length-1];return r&&e>r.start&&r.loaded}getInitialLiveFragment(t,e){const r=this.fragPrevious;let n=null;if(r){if(t.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${r.programDateTime}`),n=n4(e,r.endProgramDateTime,this.config.maxFragLookUpTolerance)),!n){const o=r.sn+1;if(o>=t.startSN&&o<=t.endSN){const l=e[o-t.startSN];r.cc===l.cc&&(n=l,this.log(`Live playlist, switching playlist, load frag with next SN: ${n.sn}`))}n||(n=o4(e,r.cc),n&&this.log(`Live playlist, switching playlist, load frag with same CC: ${n.sn}`))}}else{const o=this.hls.liveSyncPosition;o!==null&&(n=this.getFragmentAtPosition(o,this.bitrateTest?t.fragmentEnd:t.edge,t))}return n}getFragmentAtPosition(t,e,r){const{config:n}=this;let{fragPrevious:o}=this,{fragments:l,endSN:d}=r;const{fragmentHint:f}=r,p=n.maxFragLookUpTolerance,g=r.partList,v=!!(n.lowLatencyMode&&g!=null&&g.length&&f);v&&f&&!this.bitrateTest&&(l=l.concat(f),d=f.sn);let E;if(t<e){const A=t>e-p?0:p;E=Na(o,l,t,A)}else E=l[l.length-1];if(E){const A=E.sn-r.startSN,T=this.fragmentTracker.getState(E);if((T===vr.OK||T===vr.PARTIAL&&E.gap)&&(o=E),o&&E.sn===o.sn&&(!v||g[0].fragment.sn>E.sn)&&o&&E.level===o.level){const w=l[A+1];E.sn<d&&this.fragmentTracker.getState(w)!==vr.OK?E=w:E=null}}return E}synchronizeToLiveEdge(t){const{config:e,media:r}=this;if(!r)return;const n=this.hls.liveSyncPosition,o=r.currentTime,l=t.fragments[0].start,d=t.edge,f=o>=l-e.maxFragLookUpTolerance&&o<=d;if(n!==null&&r.duration>n&&(o<n||!f)){const p=e.liveMaxLatencyDuration!==void 0?e.liveMaxLatencyDuration:e.liveMaxLatencyDurationCount*t.targetduration;(!f&&r.readyState<4||o<d-p)&&(this.loadedmetadata||(this.nextLoadPosition=n),r.readyState&&(this.warn(`Playback: ${o.toFixed(3)} is located too far from the end of live sliding playlist: ${d}, reset currentTime to : ${n.toFixed(3)}`),r.currentTime=n))}}alignPlaylists(t,e){const{levels:r,levelLastLoaded:n,fragPrevious:o}=this,l=n!==null?r[n]:null,d=t.fragments.length;if(!d)return this.warn("No fragments in live playlist"),0;const f=t.fragments[0].start,p=!e,g=t.alignedSliding&&jt(f);if(p||!g&&!f){b4(o,l,t);const v=t.fragments[0].start;return this.log(`Live playlist sliding: ${v.toFixed(2)} start-sn: ${e?e.startSN:"na"}->${t.startSN} prev-sn: ${o?o.sn:"na"} fragments: ${d}`),v}return f}waitForCdnTuneIn(t){return t.live&&t.canBlockReload&&t.partTarget&&t.tuneInGoal>Math.max(t.partHoldBack,t.partTarget*3)}setStartPosition(t,e){let r=this.startPosition;if(r<e&&(r=-1),r===-1||this.lastCurrentTime===-1){const n=this.startTimeOffset!==null,o=n?this.startTimeOffset:t.startTimeOffset;o!==null&&jt(o)?(r=e+o,o<0&&(r+=t.totalduration),r=Math.min(Math.max(e,r),e+t.totalduration),this.log(`Start time offset ${o} found in ${n?"multivariant":"media"} playlist, adjust startPosition to ${r}`),this.startPosition=r):t.live?r=this.hls.liveSyncPosition||e:this.startPosition=r=0,this.lastCurrentTime=r}this.nextLoadPosition=r}getLoadPosition(){const{media:t}=this;let e=0;return this.loadedmetadata&&t?e=t.currentTime:this.nextLoadPosition&&(e=this.nextLoadPosition),e}handleFragLoadAborted(t,e){this.transmuxer&&t.sn!=="initSegment"&&t.stats.aborted&&(this.warn(`Fragment ${t.sn}${e?" part "+e.index:""} of level ${t.level} was aborted`),this.resetFragmentLoading(t))}resetFragmentLoading(t){(!this.fragCurrent||!this.fragContextChanged(t)&&this.state!==Rt.FRAG_LOADING_WAITING_RETRY)&&(this.state=Rt.IDLE)}onFragmentOrKeyLoadError(t,e){if(e.chunkMeta&&!e.frag){const v=this.getCurrentContext(e.chunkMeta);v&&(e.frag=v.frag)}const r=e.frag;if(!r||r.type!==t||!this.levels)return;if(this.fragContextChanged(r)){var n;this.warn(`Frag load error must match current frag to retry ${r.url} > ${(n=this.fragCurrent)==null?void 0:n.url}`);return}const o=e.details===ut.FRAG_GAP;o&&this.fragmentTracker.fragBuffered(r,!0);const l=e.errorAction,{action:d,retryCount:f=0,retryConfig:p}=l||{};if(l&&d===Ir.RetryRequest&&p){var g;this.resetStartWhenNotLoaded((g=this.levelLastLoaded)!=null?g:r.level);const v=Qc(p,f);this.warn(`Fragment ${r.sn} of ${t} ${r.level} errored with ${e.details}, retrying loading ${f+1}/${p.maxNumRetry} in ${v}ms`),l.resolved=!0,this.retryDate=self.performance.now()+v,this.state=Rt.FRAG_LOADING_WAITING_RETRY}else p&&l?(this.resetFragmentErrors(t),f<p.maxNumRetry?o||(l.resolved=!0):X.warn(`${e.details} reached or exceeded max retry (${f})`)):(l==null?void 0:l.action)===Ir.SendAlternateToPenaltyBox?this.state=Rt.WAITING_LEVEL:this.state=Rt.ERROR;this.tickImmediate()}reduceLengthAndFlushBuffer(t){if(this.state===Rt.PARSING||this.state===Rt.PARSED){const e=t.parent,r=this.getFwdBufferInfo(this.mediaBuffer,e),n=r&&r.len>.5;n&&this.reduceMaxBufferLength(r.len);const o=!n;return o&&this.warn(`Buffer full error while media.currentTime is not buffered, flush ${e} buffer`),t.frag&&(this.fragmentTracker.removeFragment(t.frag),this.nextLoadPosition=t.frag.start),this.resetLoadingState(),o}return!1}resetFragmentErrors(t){t===Jt.AUDIO&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==Rt.STOPPED&&(this.state=Rt.IDLE)}afterBufferFlushed(t,e,r){if(!t)return;const n=Ve.getBuffered(t);this.fragmentTracker.detectEvictedFragments(e,n,r),this.state===Rt.ENDED&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=Rt.IDLE}resetStartWhenNotLoaded(t){if(!this.loadedmetadata){this.startFragRequested=!1;const e=this.levels?this.levels[t].details:null;e!=null&&e.live?(this.startPosition=-1,this.setStartPosition(e,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(t){var e;this.warn(`The loading context changed while buffering fragment ${t.sn} of level ${t.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded((e=this.levelLastLoaded)!=null?e:t.level),this.resetLoadingState()}removeUnbufferedFrags(t=0){this.fragmentTracker.removeFragmentsInRange(t,1/0,this.playlistType,!1,!0)}updateLevelTiming(t,e,r,n){var o;const l=r.details;if(!l){this.warn("level.details undefined");return}if(Object.keys(t.elementaryStreams).reduce((d,f)=>{const p=t.elementaryStreams[f];if(p){const g=p.endPTS-p.startPTS;if(g<=0)return this.warn(`Could not parse fragment ${t.sn} ${f} duration reliably (${g})`),d||!1;const v=n?0:If(l,t,p.startPTS,p.endPTS,p.startDTS,p.endDTS);return this.hls.trigger(R.LEVEL_PTS_UPDATED,{details:l,level:r,drift:v,type:f,frag:t,start:p.startPTS,end:p.endPTS}),!0}return d},!1))r.fragmentError=0;else if(((o=this.transmuxer)==null?void 0:o.error)===null){const d=new Error(`Found no media in fragment ${t.sn} of level ${t.level} resetting transmuxer to fallback to playlist timing`);if(r.fragmentError===0&&(r.fragmentError++,t.gap=!0,this.fragmentTracker.removeFragment(t),this.fragmentTracker.fragBuffered(t,!0)),this.warn(d.message),this.hls.trigger(R.ERROR,{type:Qt.MEDIA_ERROR,details:ut.FRAG_PARSING_ERROR,fatal:!1,error:d,frag:t,reason:`Found no media in msn ${t.sn} of level "${r.url}"`}),!this.hls)return;this.resetTransmuxer()}this.state=Rt.PARSED,this.hls.trigger(R.FRAG_PARSED,{frag:t,part:e})}resetTransmuxer(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)}recoverWorkerError(t){if(t.event==="demuxerWorker"){var e,r,n;this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded((e=(r=this.levelLastLoaded)!=null?r:(n=this.fragCurrent)==null?void 0:n.level)!=null?e:0),this.resetLoadingState()}}set state(t){const e=this._state;e!==t&&(this._state=t,this.log(`${e}->${t}`))}get state(){return this._state}}function Wf(){return self.SourceBuffer||self.WebKitSourceBuffer}function L4(){const i=zo();if(!i)return!1;const t=Wf(),e=i&&typeof i.isTypeSupported=="function"&&i.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),r=!t||t.prototype&&typeof t.prototype.appendBuffer=="function"&&typeof t.prototype.remove=="function";return!!e&&!!r}function C4(){var i;const t=Wf();return typeof(t==null||(i=t.prototype)==null?void 0:i.changeType)=="function"}function I4(){return typeof __HLS_WORKER_BUNDLE__=="function"}function x4(){const i=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),t=self.URL.createObjectURL(i);return{worker:new self.Worker(t),objectURL:t}}function D4(i){const t=new self.URL(i,self.location.href).href;return{worker:new self.Worker(t),scriptURL:t}}function Bi(i="",t=9e4){return{type:i,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}class jf{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(t,e,r,n){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(t){this.initPTS=t,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(t,e){return!1}appendFrame(t,e,r){}demux(t,e){this.cachedData&&(t=fn(this.cachedData,t),this.cachedData=null);let r=Vo(t,0),n=r?r.length:0,o;const l=this._audioTrack,d=this._id3Track,f=r?pb(r):void 0,p=t.length;for((this.basePTS===null||this.frameIndex===0&&jt(f))&&(this.basePTS=P4(f,e,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),r&&r.length>0&&d.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:Si.audioId3,duration:Number.POSITIVE_INFINITY});n<p;){if(this.canParse(t,n)){const g=this.appendFrame(l,t,n);g?(this.frameIndex++,this.lastPTS=g.sample.pts,n+=g.length,o=n):n=p}else fb(t,n)?(r=Vo(t,n),d.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:Si.audioId3,duration:Number.POSITIVE_INFINITY}),n+=r.length,o=n):n++;if(n===p&&o!==p){const g=un(t,o);this.cachedData?this.cachedData=fn(this.cachedData,g):this.cachedData=g}}return{audioTrack:l,videoTrack:Bi(),id3Track:d,textTrack:Bi()}}demuxSampleAes(t,e,r){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(t){const e=this.cachedData;return e&&(this.cachedData=null,this.demux(e,0)),{audioTrack:this._audioTrack,videoTrack:Bi(),id3Track:this._id3Track,textTrack:Bi()}}destroy(){}}const P4=(i,t,e)=>{if(jt(i))return i*90;const r=e?e.baseTime*9e4/e.timescale:0;return t*9e4+r};function O4(i,t,e,r){let n,o,l,d;const f=navigator.userAgent.toLowerCase(),p=r,g=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];n=((t[e+2]&192)>>>6)+1;const v=(t[e+2]&60)>>>2;if(v>g.length-1){i.trigger(R.ERROR,{type:Qt.MEDIA_ERROR,details:ut.FRAG_PARSING_ERROR,fatal:!0,reason:`invalid ADTS sampling index:${v}`});return}return l=(t[e+2]&1)<<2,l|=(t[e+3]&192)>>>6,X.log(`manifest codec:${r}, ADTS type:${n}, samplingIndex:${v}`),/firefox/i.test(f)?v>=6?(n=5,d=new Array(4),o=v-3):(n=2,d=new Array(2),o=v):f.indexOf("android")!==-1?(n=2,d=new Array(2),o=v):(n=5,d=new Array(4),r&&(r.indexOf("mp4a.40.29")!==-1||r.indexOf("mp4a.40.5")!==-1)||!r&&v>=6?o=v-3:((r&&r.indexOf("mp4a.40.2")!==-1&&(v>=6&&l===1||/vivaldi/i.test(f))||!r&&l===1)&&(n=2,d=new Array(2)),o=v)),d[0]=n<<3,d[0]|=(v&14)>>1,d[1]|=(v&1)<<7,d[1]|=l<<3,n===5&&(d[1]|=(o&14)>>1,d[2]=(o&1)<<7,d[2]|=8,d[3]=0),{config:d,samplerate:g[v],channelCount:l,codec:"mp4a.40."+n,manifestCodec:p}}function Kf(i,t){return i[t]===255&&(i[t+1]&246)===240}function zf(i,t){return i[t+1]&1?7:9}function ah(i,t){return(i[t+3]&3)<<11|i[t+4]<<3|(i[t+5]&224)>>>5}function $4(i,t){return t+5<i.length}function tl(i,t){return t+1<i.length&&Kf(i,t)}function M4(i,t){return $4(i,t)&&Kf(i,t)&&ah(i,t)<=i.length-t}function N4(i,t){if(tl(i,t)){const e=zf(i,t);if(t+e>=i.length)return!1;const r=ah(i,t);if(r<=e)return!1;const n=t+r;return n===i.length||tl(i,n)}return!1}function Yf(i,t,e,r,n){if(!i.samplerate){const o=O4(t,e,r,n);if(!o)return;i.config=o.config,i.samplerate=o.samplerate,i.channelCount=o.channelCount,i.codec=o.codec,i.manifestCodec=o.manifestCodec,X.log(`parsed codec:${i.codec}, rate:${o.samplerate}, channels:${o.channelCount}`)}}function Xf(i){return 9216e4/i}function F4(i,t){const e=zf(i,t);if(t+e<=i.length){const r=ah(i,t)-e;if(r>0)return{headerLength:e,frameLength:r}}}function Zf(i,t,e,r,n){const o=Xf(i.samplerate),l=r+n*o,d=F4(t,e);let f;if(d){const{frameLength:g,headerLength:v}=d,E=v+g,A=Math.max(0,e+E-t.length);A?(f=new Uint8Array(E-v),f.set(t.subarray(e+v,t.length),0)):f=t.subarray(e+v,e+E);const T={unit:f,pts:l};return A||i.samples.push(T),{sample:T,length:E,missing:A}}const p=t.length-e;return f=new Uint8Array(p),f.set(t.subarray(e,t.length),0),{sample:{unit:f,pts:l},length:p,missing:-1}}class U4 extends jf{constructor(t,e){super(),this.observer=void 0,this.config=void 0,this.observer=t,this.config=e}resetInitSegment(t,e,r,n){super.resetInitSegment(t,e,r,n),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:e,duration:n,inputTimeScale:9e4,dropped:0}}static probe(t){if(!t)return!1;let e=(Vo(t,0)||[]).length;for(let r=t.length;e<r;e++)if(N4(t,e))return X.log("ADTS sync word found !"),!0;return!1}canParse(t,e){return M4(t,e)}appendFrame(t,e,r){Yf(t,this.observer,e,r,t.manifestCodec);const n=Zf(t,e,r,this.basePTS,this.frameIndex);if(n&&n.missing===0)return n}}const B4=/\/emsg[-/]ID3/i;class G4{constructor(t,e){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=e}resetTimeStamp(){}resetInitSegment(t,e,r,n){const o=this.videoTrack=Bi("video",1),l=this.audioTrack=Bi("audio",1),d=this.txtTrack=Bi("text",1);if(this.id3Track=Bi("id3",1),this.timeOffset=0,!(t!=null&&t.byteLength))return;const f=lf(t);if(f.video){const{id:p,timescale:g,codec:v}=f.video;o.id=p,o.timescale=d.timescale=g,o.codec=v}if(f.audio){const{id:p,timescale:g,codec:v}=f.audio;l.id=p,l.timescale=g,l.codec=v}d.id=nf.text,o.sampleDuration=0,o.duration=l.duration=n}resetContiguity(){this.remainderData=null}static probe(t){return t=t.length>16384?t.subarray(0,16384):t,Te(t,["moof"]).length>0}demux(t,e){this.timeOffset=e;let r=t;const n=this.videoTrack,o=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=fn(this.remainderData,t));const d=Cb(r);this.remainderData=d.remainder,n.samples=d.valid||new Uint8Array}else n.samples=r;const l=this.extractID3Track(n,e);return o.samples=hf(e,n),{videoTrack:n,audioTrack:this.audioTrack,id3Track:l,textTrack:this.txtTrack}}flush(){const t=this.timeOffset,e=this.videoTrack,r=this.txtTrack;e.samples=this.remainderData||new Uint8Array,this.remainderData=null;const n=this.extractID3Track(e,this.timeOffset);return r.samples=hf(t,e),{videoTrack:e,audioTrack:Bi(),id3Track:n,textTrack:Bi()}}extractID3Track(t,e){const r=this.id3Track;if(t.samples.length){const n=Te(t.samples,["emsg"]);n&&n.forEach(o=>{const l=Db(o);if(B4.test(l.schemeIdUri)){const d=jt(l.presentationTime)?l.presentationTime/l.timeScale:e+l.presentationTimeDelta/l.timeScale;let f=l.eventDuration===4294967295?Number.POSITIVE_INFINITY:l.eventDuration/l.timeScale;f<=.001&&(f=Number.POSITIVE_INFINITY);const p=l.payload;r.samples.push({data:p,len:p.byteLength,dts:d,pts:d,type:Si.emsg,duration:f})}})}return r}demuxSampleAes(t,e,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){}}let el=null;const H4=[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],V4=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],W4=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],j4=[0,1,1,4];function qf(i,t,e,r,n){if(e+24>t.length)return;const o=Qf(t,e);if(o&&e+o.frameLength<=t.length){const l=o.samplesPerFrame*9e4/o.sampleRate,d=r+n*l,f={unit:t.subarray(e,e+o.frameLength),pts:d,dts:d};return i.config=[],i.channelCount=o.channelCount,i.samplerate=o.sampleRate,i.samples.push(f),{sample:f,length:o.frameLength,missing:0}}}function Qf(i,t){const e=i[t+1]>>3&3,r=i[t+1]>>1&3,n=i[t+2]>>4&15,o=i[t+2]>>2&3;if(e!==1&&n!==0&&n!==15&&o!==3){const l=i[t+2]>>1&1,d=i[t+3]>>6,f=e===3?3-r:r===3?3:4,p=H4[f*14+n-1]*1e3,g=V4[(e===3?0:e===2?1:2)*3+o],v=d===3?1:2,E=W4[e][r],A=j4[r],T=E*8*A,w=Math.floor(E*p/g+l)*A;if(el===null){const C=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);el=C?parseInt(C[1]):0}return el&&el<=87&&r===2&&p>=224e3&&d===0&&(i[t+3]=i[t+3]|128),{sampleRate:g,channelCount:v,frameLength:w,samplesPerFrame:T}}}function oh(i,t){return i[t]===255&&(i[t+1]&224)===224&&(i[t+1]&6)!==0}function Jf(i,t){return t+1<i.length&&oh(i,t)}function K4(i,t){return oh(i,t)&&4<=i.length-t}function z4(i,t){if(t+1<i.length&&oh(i,t)){const e=Qf(i,t);let r=4;e!=null&&e.frameLength&&(r=e.frameLength);const n=t+r;return n===i.length||Jf(i,n)}return!1}class tp{constructor(t){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=t,this.bytesAvailable=t.byteLength,this.word=0,this.bitsAvailable=0}loadWord(){const t=this.data,e=this.bytesAvailable,r=t.byteLength-e,n=new Uint8Array(4),o=Math.min(4,e);if(o===0)throw new Error("no bytes available");n.set(t.subarray(r,r+o)),this.word=new DataView(n.buffer).getUint32(0),this.bitsAvailable=o*8,this.bytesAvailable-=o}skipBits(t){let e;t=Math.min(t,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>t?(this.word<<=t,this.bitsAvailable-=t):(t-=this.bitsAvailable,e=t>>3,t-=e<<3,this.bytesAvailable-=e,this.loadWord(),this.word<<=t,this.bitsAvailable-=t)}readBits(t){let e=Math.min(this.bitsAvailable,t);const r=this.word>>>32-e;if(t>32&&X.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=e,this.bitsAvailable>0)this.word<<=e;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");return e=t-e,e>0&&this.bitsAvailable?r<<e|this.readBits(e):r}skipLZ(){let t;for(t=0;t<this.bitsAvailable;++t)if(this.word&2147483648>>>t)return this.word<<=t,this.bitsAvailable-=t,t;return this.loadWord(),t+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){const t=this.skipLZ();return this.readBits(t+1)-1}readEG(){const t=this.readUEG();return 1&t?1+t>>>1:-1*(t>>>1)}readBoolean(){return this.readBits(1)===1}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}skipScalingList(t){let e=8,r=8,n;for(let o=0;o<t;o++)r!==0&&(n=this.readEG(),r=(e+n+256)%256),e=r===0?e:r}readSPS(){let t=0,e=0,r=0,n=0,o,l,d;const f=this.readUByte.bind(this),p=this.readBits.bind(this),g=this.readUEG.bind(this),v=this.readBoolean.bind(this),E=this.skipBits.bind(this),A=this.skipEG.bind(this),T=this.skipUEG.bind(this),w=this.skipScalingList.bind(this);f();const C=f();if(p(5),E(3),f(),T(),C===100||C===110||C===122||C===244||C===44||C===83||C===86||C===118||C===128){const K=g();if(K===3&&E(1),T(),T(),E(1),v())for(l=K!==3?8:12,d=0;d<l;d++)v()&&(d<6?w(16):w(64))}T();const D=g();if(D===0)g();else if(D===1)for(E(1),A(),A(),o=g(),d=0;d<o;d++)A();T(),E(1);const M=g(),U=g(),x=p(1);x===0&&E(1),E(1),v()&&(t=g(),e=g(),r=g(),n=g());let O=[1,1];if(v()&&v())switch(f()){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=[f()<<8|f(),f()<<8|f()];break}}return{width:Math.ceil((M+1)*16-t*2-e*2),height:(2-x)*(U+1)*16-(x?2:4)*(r+n),pixelRatio:O}}readSliceType(){return this.readUByte(),this.readUEG(),this.readUEG()}}class Y4{constructor(t,e,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new sh(e,{removePKCS7Padding:!1})}decryptBuffer(t){return this.decrypter.decrypt(t,this.keyData.key.buffer,this.keyData.iv.buffer)}decryptAacSample(t,e,r){const n=t[e].unit;if(n.length<=16)return;const o=n.subarray(16,n.length-n.length%16),l=o.buffer.slice(o.byteOffset,o.byteOffset+o.length);this.decryptBuffer(l).then(d=>{const f=new Uint8Array(d);n.set(f,16),this.decrypter.isSync()||this.decryptAacSamples(t,e+1,r)})}decryptAacSamples(t,e,r){for(;;e++){if(e>=t.length){r();return}if(!(t[e].unit.length<32)&&(this.decryptAacSample(t,e,r),!this.decrypter.isSync()))return}}getAvcEncryptedData(t){const e=Math.floor((t.length-48)/160)*16+16,r=new Int8Array(e);let n=0;for(let o=32;o<t.length-16;o+=160,n+=16)r.set(t.subarray(o,o+16),n);return r}getAvcDecryptedUnit(t,e){const r=new Uint8Array(e);let n=0;for(let o=32;o<t.length-16;o+=160,n+=16)t.set(r.subarray(n,n+16),o);return t}decryptAvcSample(t,e,r,n,o){const l=uf(o.data),d=this.getAvcEncryptedData(l);this.decryptBuffer(d.buffer).then(f=>{o.data=this.getAvcDecryptedUnit(l,f),this.decrypter.isSync()||this.decryptAvcSamples(t,e,r+1,n)})}decryptAvcSamples(t,e,r,n){if(t instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;e++,r=0){if(e>=t.length){n();return}const o=t[e].units;for(;!(r>=o.length);r++){const l=o[r];if(!(l.data.length<=48||l.type!==1&&l.type!==5)&&(this.decryptAvcSample(t,e,r,n,l),!this.decrypter.isSync()))return}}}}const xr=188;class Ls{constructor(t,e,r){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=t,this.config=e,this.typeSupported=r}static probe(t){const e=Ls.syncOffset(t);return e>0&&X.warn(`MPEG2-TS detected but first sync word found @ offset ${e}`),e!==-1}static syncOffset(t){const e=t.length;let r=Math.min(xr*5,t.length-xr)+1,n=0;for(;n<r;){let o=!1,l=-1,d=0;for(let f=n;f<e;f+=xr)if(t[f]===71){if(d++,l===-1&&(l=f,l!==0&&(r=Math.min(l+xr*99,t.length-xr)+1)),o||(o=lh(t,f)===0),o&&d>1&&(l===0&&d>2||f+xr>r))return l}else{if(d)return-1;break}n++}return-1}static createTrack(t,e){return{container:t==="video"||t==="audio"?"video/mp2t":void 0,type:t,id:nf[t],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:t==="audio"?e:void 0}}resetInitSegment(t,e,r,n){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=Ls.createTrack("video"),this._audioTrack=Ls.createTrack("audio",n),this._id3Track=Ls.createTrack("id3"),this._txtTrack=Ls.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=e,this.videoCodec=r,this._duration=n}resetTimeStamp(){}resetContiguity(){const{_audioTrack:t,_avcTrack:e,_id3Track:r}=this;t&&(t.pesData=null),e&&(e.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null}demux(t,e,r=!1,n=!1){r||(this.sampleAes=null);let o;const l=this._avcTrack,d=this._audioTrack,f=this._id3Track,p=this._txtTrack;let g=l.pid,v=l.pesData,E=d.pid,A=f.pid,T=d.pesData,w=f.pesData,C=null,D=this.pmtParsed,M=this._pmtId,U=t.length;if(this.remainderData&&(t=fn(this.remainderData,t),U=t.length,this.remainderData=null),U<xr&&!n)return this.remainderData=t,{audioTrack:d,videoTrack:l,id3Track:f,textTrack:p};const x=Math.max(0,Ls.syncOffset(t));U-=(U-x)%xr,U<t.byteLength&&!n&&(this.remainderData=new Uint8Array(t.buffer,U,t.buffer.byteLength-U));let O=0;for(let B=x;B<U;B+=xr)if(t[B]===71){const at=!!(t[B+1]&64),st=lh(t,B),J=(t[B+3]&48)>>4;let kt;if(J>1){if(kt=B+5+t[B+4],kt===B+xr)continue}else kt=B+4;switch(st){case g:at&&(v&&(o=Pn(v))&&this.parseAVCPES(l,p,o,!1),v={data:[],size:0}),v&&(v.data.push(t.subarray(kt,B+xr)),v.size+=B+xr-kt);break;case E:if(at){if(T&&(o=Pn(T)))switch(d.segmentCodec){case"aac":this.parseAACPES(d,o);break;case"mp3":this.parseMPEGPES(d,o);break}T={data:[],size:0}}T&&(T.data.push(t.subarray(kt,B+xr)),T.size+=B+xr-kt);break;case A:at&&(w&&(o=Pn(w))&&this.parseID3PES(f,o),w={data:[],size:0}),w&&(w.data.push(t.subarray(kt,B+xr)),w.size+=B+xr-kt);break;case 0:at&&(kt+=t[kt]+1),M=this._pmtId=X4(t,kt);break;case M:{at&&(kt+=t[kt]+1);const ft=Z4(t,kt,this.typeSupported,r);g=ft.avc,g>0&&(l.pid=g),E=ft.audio,E>0&&(d.pid=E,d.segmentCodec=ft.segmentCodec),A=ft.id3,A>0&&(f.pid=A),C!==null&&!D&&(X.warn(`MPEG-TS PMT found at ${B} after unknown PID '${C}'. Backtracking to sync byte @${x} to parse all TS packets.`),C=null,B=x-188),D=this.pmtParsed=!0;break}case 17:case 8191:break;default:C=st;break}}else O++;if(O>0){const B=new Error(`Found ${O} TS packet/s that do not start with 0x47`);this.observer.emit(R.ERROR,R.ERROR,{type:Qt.MEDIA_ERROR,details:ut.FRAG_PARSING_ERROR,fatal:!1,error:B,reason:B.message})}l.pesData=v,d.pesData=T,f.pesData=w;const K={audioTrack:d,videoTrack:l,id3Track:f,textTrack:p};return n&&this.extractRemainingSamples(K),K}flush(){const{remainderData:t}=this;this.remainderData=null;let e;return t?e=this.demux(t,-1,!1,!0):e={videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(e),this.sampleAes?this.decrypt(e,this.sampleAes):e}extractRemainingSamples(t){const{audioTrack:e,videoTrack:r,id3Track:n,textTrack:o}=t,l=r.pesData,d=e.pesData,f=n.pesData;let p;if(l&&(p=Pn(l))?(this.parseAVCPES(r,o,p,!0),r.pesData=null):r.pesData=l,d&&(p=Pn(d))){switch(e.segmentCodec){case"aac":this.parseAACPES(e,p);break;case"mp3":this.parseMPEGPES(e,p);break}e.pesData=null}else d!=null&&d.size&&X.log("last AAC PES packet truncated,might overlap between fragments"),e.pesData=d;f&&(p=Pn(f))?(this.parseID3PES(n,p),n.pesData=null):n.pesData=f}demuxSampleAes(t,e,r){const n=this.demux(t,r,!0,!this.config.progressive),o=this.sampleAes=new Y4(this.observer,this.config,e);return this.decrypt(n,o)}decrypt(t,e){return new Promise(r=>{const{audioTrack:n,videoTrack:o}=t;n.samples&&n.segmentCodec==="aac"?e.decryptAacSamples(n.samples,0,()=>{o.samples?e.decryptAvcSamples(o.samples,0,0,()=>{r(t)}):r(t)}):o.samples&&e.decryptAvcSamples(o.samples,0,0,()=>{r(t)})})}destroy(){this._duration=0}parseAVCPES(t,e,r,n){const o=this.parseAVCNALu(t,r.data);let l=this.avcSample,d,f=!1;r.data=null,l&&o.length&&!t.audFound&&(Fa(l,t),l=this.avcSample=rl(!1,r.pts,r.dts,"")),o.forEach(p=>{var g;switch(p.type){case 1:{let E=!1;d=!0;const A=p.data;if(f&&A.length>4){const T=new tp(A).readSliceType();(T===2||T===4||T===7||T===9)&&(E=!0)}if(E){var v;(v=l)!=null&&v.frame&&!l.key&&(Fa(l,t),l=this.avcSample=null)}l||(l=this.avcSample=rl(!0,r.pts,r.dts,"")),l.frame=!0,l.key=E;break}case 5:d=!0,(g=l)!=null&&g.frame&&!l.key&&(Fa(l,t),l=this.avcSample=null),l||(l=this.avcSample=rl(!0,r.pts,r.dts,"")),l.key=!0,l.frame=!0;break;case 6:{d=!0,df(p.data,1,r.pts,e.samples);break}case 7:if(d=!0,f=!0,!t.sps){const E=p.data,A=new tp(E).readSPS();t.width=A.width,t.height=A.height,t.pixelRatio=A.pixelRatio,t.sps=[E],t.duration=this._duration;const T=E.subarray(1,4);let w="avc1.";for(let C=0;C<3;C++){let D=T[C].toString(16);D.length<2&&(D="0"+D),w+=D}t.codec=w}break;case 8:d=!0,t.pps||(t.pps=[p.data]);break;case 9:d=!1,t.audFound=!0,l&&Fa(l,t),l=this.avcSample=rl(!1,r.pts,r.dts,"");break;case 12:d=!0;break;default:d=!1,l&&(l.debug+="unknown NAL "+p.type+" ");break}l&&d&&l.units.push(p)}),n&&l&&(Fa(l,t),this.avcSample=null)}getLastNalUnit(t){var e;let r=this.avcSample,n;if((!r||r.units.length===0)&&(r=t[t.length-1]),(e=r)!=null&&e.units){const o=r.units;n=o[o.length-1]}return n}parseAVCNALu(t,e){const r=e.byteLength;let n=t.naluState||0;const o=n,l=[];let d=0,f,p,g,v=-1,E=0;for(n===-1&&(v=0,E=e[0]&31,n=0,d=1);d<r;){if(f=e[d++],!n){n=f?0:1;continue}if(n===1){n=f?0:2;continue}if(!f)n=3;else if(f===1){if(v>=0){const A={data:e.subarray(v,d-n-1),type:E};l.push(A)}else{const A=this.getLastNalUnit(t.samples);if(A&&(o&&d<=4-o&&A.state&&(A.data=A.data.subarray(0,A.data.byteLength-o)),p=d-n-1,p>0)){const T=new Uint8Array(A.data.byteLength+p);T.set(A.data,0),T.set(e.subarray(0,p),A.data.byteLength),A.data=T,A.state=0}}d<r?(g=e[d]&31,v=d,E=g,n=0):n=-1}else n=0}if(v>=0&&n>=0){const A={data:e.subarray(v,r),type:E,state:n};l.push(A)}if(l.length===0){const A=this.getLastNalUnit(t.samples);if(A){const T=new Uint8Array(A.data.byteLength+e.byteLength);T.set(A.data,0),T.set(e,A.data.byteLength),A.data=T}}return t.naluState=n,l}parseAACPES(t,e){let r=0;const n=this.aacOverFlow;let o=e.data;if(n){this.aacOverFlow=null;const v=n.missing,E=n.sample.unit.byteLength;if(v===-1){const A=new Uint8Array(E+o.byteLength);A.set(n.sample.unit,0),A.set(o,E),o=A}else{const A=E-v;n.sample.unit.set(o.subarray(0,v),A),t.samples.push(n.sample),r=n.missing}}let l,d;for(l=r,d=o.length;l<d-1&&!tl(o,l);l++);if(l!==r){let v;const E=l<d-1;E?v=`AAC PES did not start with ADTS header,offset:${l}`:v="No ADTS header found in AAC PES";const A=new Error(v);if(X.warn(`parsing error: ${v}`),this.observer.emit(R.ERROR,R.ERROR,{type:Qt.MEDIA_ERROR,details:ut.FRAG_PARSING_ERROR,fatal:!1,levelRetry:E,error:A,reason:v}),!E)return}Yf(t,this.observer,o,l,this.audioCodec);let f;if(e.pts!==void 0)f=e.pts;else if(n){const v=Xf(t.samplerate);f=n.sample.pts+v}else{X.warn("[tsdemuxer]: AAC PES unknown PTS");return}let p=0,g;for(;l<d;)if(g=Zf(t,o,l,f,p),l+=g.length,g.missing){this.aacOverFlow=g;break}else for(p++;l<d-1&&!tl(o,l);l++);}parseMPEGPES(t,e){const r=e.data,n=r.length;let o=0,l=0;const d=e.pts;if(d===void 0){X.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;l<n;)if(Jf(r,l)){const f=qf(t,r,l,d,o);if(f)l+=f.length,o++;else break}else l++}parseID3PES(t,e){if(e.pts===void 0){X.warn("[tsdemuxer]: ID3 PES unknown PTS");return}const r=dr({},e,{type:this._avcTrack?Si.emsg:Si.audioId3,duration:Number.POSITIVE_INFINITY});t.samples.push(r)}}function rl(i,t,e,r){return{key:i,frame:!1,pts:t,dts:e,units:[],debug:r,length:0}}function lh(i,t){return((i[t+1]&31)<<8)+i[t+2]}function X4(i,t){return(i[t+10]&31)<<8|i[t+11]}function Z4(i,t,e,r){const n={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},o=(i[t+1]&15)<<8|i[t+2],l=t+3+o-4,d=(i[t+10]&15)<<8|i[t+11];for(t+=12+d;t<l;){const f=lh(i,t);switch(i[t]){case 207:if(!r){X.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:n.audio===-1&&(n.audio=f);break;case 21:n.id3===-1&&(n.id3=f);break;case 219:if(!r){X.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:n.avc===-1&&(n.avc=f);break;case 3:case 4:e.mpeg!==!0&&e.mp3!==!0?X.log("MPEG audio found, not supported in this browser"):n.audio===-1&&(n.audio=f,n.segmentCodec="mp3");break;case 36:X.warn("Unsupported HEVC stream type found");break}t+=((i[t+3]&15)<<8|i[t+4])+5}return n}function Pn(i){let t=0,e,r,n,o,l;const d=i.data;if(!i||i.size===0)return null;for(;d[0].length<19&&d.length>1;){const f=new Uint8Array(d[0].length+d[1].length);f.set(d[0]),f.set(d[1],d[0].length),d[0]=f,d.splice(1,1)}if(e=d[0],(e[0]<<16)+(e[1]<<8)+e[2]===1){if(r=(e[4]<<8)+e[5],r&&r>i.size-6)return null;const f=e[7];f&192&&(o=(e[9]&14)*536870912+(e[10]&255)*4194304+(e[11]&254)*16384+(e[12]&255)*128+(e[13]&254)/2,f&64?(l=(e[14]&14)*536870912+(e[15]&255)*4194304+(e[16]&254)*16384+(e[17]&255)*128+(e[18]&254)/2,o-l>54e5&&(X.warn(`${Math.round((o-l)/9e4)}s delta between PTS and DTS, align them`),o=l)):l=o),n=e[8];let p=n+9;if(i.size<=p)return null;i.size-=p;const g=new Uint8Array(i.size);for(let v=0,E=d.length;v<E;v++){e=d[v];let A=e.byteLength;if(p)if(p>A){p-=A;continue}else e=e.subarray(p),A-=p,p=0;g.set(e,t),t+=A}return r&&(r-=n+3),{data:g,pts:o,dts:l,len:r}}return null}function Fa(i,t){if(i.units.length&&i.frame){if(i.pts===void 0){const e=t.samples,r=e.length;if(r){const n=e[r-1];i.pts=n.pts,i.dts=n.dts}else{t.dropped++;return}}t.samples.push(i)}i.debug.length&&X.log(i.pts+"/"+i.dts+":"+i.debug)}class q4 extends jf{resetInitSegment(t,e,r,n){super.resetInitSegment(t,e,r,n),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:e,duration:n,inputTimeScale:9e4,dropped:0}}static probe(t){if(!t)return!1;let e=(Vo(t,0)||[]).length;for(let r=t.length;e<r;e++)if(z4(t,e))return X.log("MPEG Audio sync word found !"),!0;return!1}canParse(t,e){return K4(t,e)}appendFrame(t,e,r){if(this.basePTS!==null)return qf(t,e,r,this.basePTS,this.frameIndex)}}class ep{static getSilentFrame(t,e){switch(t){case"mp4a.40.2":if(e===1)return new Uint8Array([0,200,0,128,35,128]);if(e===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(e===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(e===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(e===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(e===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(e===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(e===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(e===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}}}const Cs=Math.pow(2,32)-1;class it{static init(){it.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};let t;for(t in it.types)it.types.hasOwnProperty(t)&&(it.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);const e=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),r=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]);it.HDLR_TYPES={video:e,audio:r};const n=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),o=new Uint8Array([0,0,0,0,0,0,0,0]);it.STTS=it.STSC=it.STCO=o,it.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),it.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),it.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),it.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);const l=new Uint8Array([105,115,111,109]),d=new Uint8Array([97,118,99,49]),f=new Uint8Array([0,0,0,1]);it.FTYP=it.box(it.types.ftyp,l,f,l,d),it.DINF=it.box(it.types.dinf,it.box(it.types.dref,n))}static box(t,...e){let r=8,n=e.length;const o=n;for(;n--;)r+=e[n].byteLength;const l=new Uint8Array(r);for(l[0]=r>>24&255,l[1]=r>>16&255,l[2]=r>>8&255,l[3]=r&255,l.set(t,4),n=0,r=8;n<o;n++)l.set(e[n],r),r+=e[n].byteLength;return l}static hdlr(t){return it.box(it.types.hdlr,it.HDLR_TYPES[t])}static mdat(t){return it.box(it.types.mdat,t)}static mdhd(t,e){e*=t;const r=Math.floor(e/(Cs+1)),n=Math.floor(e%(Cs+1));return it.box(it.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,t&255,r>>24,r>>16&255,r>>8&255,r&255,n>>24,n>>16&255,n>>8&255,n&255,85,196,0,0]))}static mdia(t){return it.box(it.types.mdia,it.mdhd(t.timescale,t.duration),it.hdlr(t.type),it.minf(t))}static mfhd(t){return it.box(it.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255]))}static minf(t){return t.type==="audio"?it.box(it.types.minf,it.box(it.types.smhd,it.SMHD),it.DINF,it.stbl(t)):it.box(it.types.minf,it.box(it.types.vmhd,it.VMHD),it.DINF,it.stbl(t))}static moof(t,e,r){return it.box(it.types.moof,it.mfhd(t),it.traf(r,e))}static moov(t){let e=t.length;const r=[];for(;e--;)r[e]=it.trak(t[e]);return it.box.apply(null,[it.types.moov,it.mvhd(t[0].timescale,t[0].duration)].concat(r).concat(it.mvex(t)))}static mvex(t){let e=t.length;const r=[];for(;e--;)r[e]=it.trex(t[e]);return it.box.apply(null,[it.types.mvex,...r])}static mvhd(t,e){e*=t;const r=Math.floor(e/(Cs+1)),n=Math.floor(e%(Cs+1)),o=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,t&255,r>>24,r>>16&255,r>>8&255,r&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 it.box(it.types.mvhd,o)}static sdtp(t){const e=t.samples||[],r=new Uint8Array(4+e.length);let n,o;for(n=0;n<e.length;n++)o=e[n].flags,r[n+4]=o.dependsOn<<4|o.isDependedOn<<2|o.hasRedundancy;return it.box(it.types.sdtp,r)}static stbl(t){return it.box(it.types.stbl,it.stsd(t),it.box(it.types.stts,it.STTS),it.box(it.types.stsc,it.STSC),it.box(it.types.stsz,it.STSZ),it.box(it.types.stco,it.STCO))}static avc1(t){let e=[],r=[],n,o,l;for(n=0;n<t.sps.length;n++)o=t.sps[n],l=o.byteLength,e.push(l>>>8&255),e.push(l&255),e=e.concat(Array.prototype.slice.call(o));for(n=0;n<t.pps.length;n++)o=t.pps[n],l=o.byteLength,r.push(l>>>8&255),r.push(l&255),r=r.concat(Array.prototype.slice.call(o));const d=it.box(it.types.avcC,new Uint8Array([1,e[3],e[4],e[5],255,224|t.sps.length].concat(e).concat([t.pps.length]).concat(r))),f=t.width,p=t.height,g=t.pixelRatio[0],v=t.pixelRatio[1];return it.box(it.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,f>>8&255,f&255,p>>8&255,p&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),d,it.box(it.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),it.box(it.types.pasp,new Uint8Array([g>>24,g>>16&255,g>>8&255,g&255,v>>24,v>>16&255,v>>8&255,v&255])))}static esds(t){const e=t.config.length;return new Uint8Array([0,0,0,0,3,23+e,0,1,0,4,15+e,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([e]).concat(t.config).concat([6,1,2]))}static mp4a(t){const e=t.samplerate;return it.box(it.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,e>>8&255,e&255,0,0]),it.box(it.types.esds,it.esds(t)))}static mp3(t){const e=t.samplerate;return it.box(it.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,e>>8&255,e&255,0,0]))}static stsd(t){return t.type==="audio"?t.segmentCodec==="mp3"&&t.codec==="mp3"?it.box(it.types.stsd,it.STSD,it.mp3(t)):it.box(it.types.stsd,it.STSD,it.mp4a(t)):it.box(it.types.stsd,it.STSD,it.avc1(t))}static tkhd(t){const e=t.id,r=t.duration*t.timescale,n=t.width,o=t.height,l=Math.floor(r/(Cs+1)),d=Math.floor(r%(Cs+1));return it.box(it.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,0,0,0,0,l>>24,l>>16&255,l>>8&255,l&255,d>>24,d>>16&255,d>>8&255,d&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,n>>8&255,n&255,0,0,o>>8&255,o&255,0,0]))}static traf(t,e){const r=it.sdtp(t),n=t.id,o=Math.floor(e/(Cs+1)),l=Math.floor(e%(Cs+1));return it.box(it.types.traf,it.box(it.types.tfhd,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,n&255])),it.box(it.types.tfdt,new Uint8Array([1,0,0,0,o>>24,o>>16&255,o>>8&255,o&255,l>>24,l>>16&255,l>>8&255,l&255])),it.trun(t,r.length+16+20+8+16+8+8),r)}static trak(t){return t.duration=t.duration||4294967295,it.box(it.types.trak,it.tkhd(t),it.mdia(t))}static trex(t){const e=t.id;return it.box(it.types.trex,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(t,e){const r=t.samples||[],n=r.length,o=12+16*n,l=new Uint8Array(o);let d,f,p,g,v,E;for(e+=8+o,l.set([t.type==="video"?1:0,0,15,1,n>>>24&255,n>>>16&255,n>>>8&255,n&255,e>>>24&255,e>>>16&255,e>>>8&255,e&255],0),d=0;d<n;d++)f=r[d],p=f.duration,g=f.size,v=f.flags,E=f.cts,l.set([p>>>24&255,p>>>16&255,p>>>8&255,p&255,g>>>24&255,g>>>16&255,g>>>8&255,g&255,v.isLeading<<2|v.dependsOn,v.isDependedOn<<6|v.hasRedundancy<<4|v.paddingValue<<1|v.isNonSync,v.degradPrio&61440,v.degradPrio&15,E>>>24&255,E>>>16&255,E>>>8&255,E&255],12+16*d);return it.box(it.types.trun,l)}static initSegment(t){it.types||it.init();const e=it.moov(t),r=new Uint8Array(it.FTYP.byteLength+e.byteLength);return r.set(it.FTYP),r.set(e,it.FTYP.byteLength),r}}it.types=void 0,it.HDLR_TYPES=void 0,it.STTS=void 0,it.STSC=void 0,it.STCO=void 0,it.STSZ=void 0,it.VMHD=void 0,it.SMHD=void 0,it.STSD=void 0,it.FTYP=void 0,it.DINF=void 0;const rp=9e4;function ch(i,t,e=1,r=!1){const n=i*t*e;return r?Math.round(n):n}function Q4(i,t,e=1,r=!1){return ch(i,t,1/e,r)}function Ua(i,t=!1){return ch(i,1e3,1/rp,t)}function J4(i,t=1){return ch(i,rp,1/t)}const tE=10*1e3,ip=1024,eE=1152;let il=null,hh=null;class dh{constructor(t,e,r,n=""){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=t,this.config=e,this.typeSupported=r,this.ISGenerated=!1,il===null){const o=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);il=o?parseInt(o[1]):0}if(hh===null){const o=navigator.userAgent.match(/Safari\/(\d+)/i);hh=o?parseInt(o[1]):0}}destroy(){}resetTimeStamp(t){X.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=t}resetNextTimestamp(){X.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){X.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1}getVideoStartPts(t){let e=!1;const r=t.reduce((n,o)=>{const l=o.pts-n;return l<-4294967296?(e=!0,pi(n,o.pts)):l>0?n:o.pts},t[0].pts);return e&&X.debug("PTS rollover detected"),r}remux(t,e,r,n,o,l,d,f){let p,g,v,E,A,T,w=o,C=o;const D=t.pid>-1,M=e.pid>-1,U=e.samples.length,x=t.samples.length>0,O=d&&U>0||U>1;if((!D||x)&&(!M||O)||this.ISGenerated||d){this.ISGenerated||(v=this.generateIS(t,e,o,l));const K=this.isVideoContiguous;let B=-1,at;if(O&&(B=rE(e.samples),!K&&this.config.forceKeyFrameOnDiscontinuity))if(T=!0,B>0){X.warn(`[mp4-remuxer]: Dropped ${B} out of ${U} video samples due to a missing keyframe`);const st=this.getVideoStartPts(e.samples);e.samples=e.samples.slice(B),e.dropped+=B,C+=(e.samples[0].pts-st)/e.inputTimeScale,at=C}else B===-1&&(X.warn(`[mp4-remuxer]: No keyframe found out of ${U} video samples`),T=!1);if(this.ISGenerated){if(x&&O){const st=this.getVideoStartPts(e.samples),J=(pi(t.samples[0].pts,st)-st)/e.inputTimeScale;w+=Math.max(0,J),C+=Math.max(0,-J)}if(x){if(t.samplerate||(X.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),v=this.generateIS(t,e,o,l)),g=this.remuxAudio(t,w,this.isAudioContiguous,l,M||O||f===Jt.AUDIO?C:void 0),O){const st=g?g.endPTS-g.startPTS:0;e.inputTimeScale||(X.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),v=this.generateIS(t,e,o,l)),p=this.remuxVideo(e,C,K,st)}}else O&&(p=this.remuxVideo(e,C,K,0));p&&(p.firstKeyFrame=B,p.independent=B!==-1,p.firstKeyFramePTS=at)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(A=sp(r,o,this._initPTS,this._initDTS)),n.samples.length&&(E=np(n,o,this._initPTS))),{audio:g,video:p,initSegment:v,independent:T,text:E,id3:A}}generateIS(t,e,r,n){const o=t.samples,l=e.samples,d=this.typeSupported,f={},p=this._initPTS;let g=!p||n,v="audio/mp4",E,A,T;if(g&&(E=A=1/0),t.config&&o.length){switch(t.timescale=t.samplerate,t.segmentCodec){case"mp3":d.mpeg?(v="audio/mpeg",t.codec=""):d.mp3&&(t.codec="mp3");break}f.audio={id:"audio",container:v,codec:t.codec,initSegment:t.segmentCodec==="mp3"&&d.mpeg?new Uint8Array(0):it.initSegment([t]),metadata:{channelCount:t.channelCount}},g&&(T=t.inputTimeScale,!p||T!==p.timescale?E=A=o[0].pts-Math.round(T*r):g=!1)}if(e.sps&&e.pps&&l.length&&(e.timescale=e.inputTimeScale,f.video={id:"main",container:"video/mp4",codec:e.codec,initSegment:it.initSegment([e]),metadata:{width:e.width,height:e.height}},g))if(T=e.inputTimeScale,!p||T!==p.timescale){const w=this.getVideoStartPts(l),C=Math.round(T*r);A=Math.min(A,pi(l[0].dts,w)-C),E=Math.min(E,w-C)}else g=!1;if(Object.keys(f).length)return this.ISGenerated=!0,g?(this._initPTS={baseTime:E,timescale:T},this._initDTS={baseTime:A,timescale:T}):E=T=void 0,{tracks:f,initPTS:E,timescale:T}}remuxVideo(t,e,r,n){const o=t.inputTimeScale,l=t.samples,d=[],f=l.length,p=this._initPTS;let g=this.nextAvcDts,v=8,E=this.videoSampleDuration,A,T,w=Number.POSITIVE_INFINITY,C=Number.NEGATIVE_INFINITY,D=!1;if(!r||g===null){const N=e*o,G=l[0].pts-pi(l[0].dts,l[0].pts);g=N-G}const M=p.baseTime*o/p.timescale;for(let N=0;N<f;N++){const G=l[N];G.pts=pi(G.pts-M,g),G.dts=pi(G.dts-M,g),G.dts<l[N>0?N-1:N].dts&&(D=!0)}D&&l.sort(function(N,G){const Z=N.dts-G.dts,gt=N.pts-G.pts;return Z||gt}),A=l[0].dts,T=l[l.length-1].dts;const U=T-A,x=U?Math.round(U/(f-1)):E||t.inputTimeScale/30;if(r){const N=A-g,G=N>x,Z=N<-1;if((G||Z)&&(G?X.warn(`AVC: ${Ua(N,!0)} ms (${N}dts) hole between fragments detected, filling it`):X.warn(`AVC: ${Ua(-N,!0)} ms (${N}dts) overlapping between fragments detected`),!Z||g>=l[0].pts)){A=g;const gt=l[0].pts-N;l[0].dts=A,l[0].pts=gt,X.log(`Video: First PTS/DTS adjusted: ${Ua(gt,!0)}/${Ua(A,!0)}, delta: ${Ua(N,!0)} ms`)}}A=Math.max(0,A);let O=0,K=0;for(let N=0;N<f;N++){const G=l[N],Z=G.units,gt=Z.length;let vt=0;for(let It=0;It<gt;It++)vt+=Z[It].data.length;K+=vt,O+=gt,G.length=vt,G.dts=Math.max(G.dts,A),w=Math.min(G.pts,w),C=Math.max(G.pts,C)}T=l[f-1].dts;const B=K+4*O+8;let at;try{at=new Uint8Array(B)}catch(N){this.observer.emit(R.ERROR,R.ERROR,{type:Qt.MUX_ERROR,details:ut.REMUX_ALLOC_ERROR,fatal:!1,error:N,bytes:B,reason:`fail allocating video mdat ${B}`});return}const st=new DataView(at.buffer);st.setUint32(0,B),at.set(it.types.mdat,4);let J=!1,kt=Number.POSITIVE_INFINITY,ft=Number.POSITIVE_INFINITY,wt=Number.NEGATIVE_INFINITY,Pt=Number.NEGATIVE_INFINITY;for(let N=0;N<f;N++){const G=l[N],Z=G.units;let gt=0;for(let Bt=0,Xt=Z.length;Bt<Xt;Bt++){const me=Z[Bt],be=me.data,Ee=me.data.byteLength;st.setUint32(v,Ee),v+=4,at.set(be,v),v+=Ee,gt+=4+Ee}let vt;if(N<f-1)E=l[N+1].dts-G.dts,vt=l[N+1].pts-G.pts;else{const Bt=this.config,Xt=N>0?G.dts-l[N-1].dts:x;if(vt=N>0?G.pts-l[N-1].pts:x,Bt.stretchShortVideoTrack&&this.nextAudioPts!==null){const me=Math.floor(Bt.maxBufferHole*o),be=(n?w+n*o:this.nextAudioPts)-G.pts;be>me?(E=be-Xt,E<0?E=Xt:J=!0,X.log(`[mp4-remuxer]: It is approximately ${be/90} ms to the next segment; using duration ${E/90} ms for the last video frame.`)):E=Xt}else E=Xt}const It=Math.round(G.pts-G.dts);kt=Math.min(kt,E),wt=Math.max(wt,E),ft=Math.min(ft,vt),Pt=Math.max(Pt,vt),d.push(new ap(G.key,E,gt,It))}if(d.length){if(il){if(il<70){const N=d[0].flags;N.dependsOn=2,N.isNonSync=0}}else if(hh&&Pt-ft<wt-kt&&x/wt<.025&&d[0].cts===0){X.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let N=A;for(let G=0,Z=d.length;G<Z;G++){const gt=N+d[G].duration,vt=N+d[G].cts;if(G<Z-1){const It=gt+d[G+1].cts;d[G].duration=It-vt}else d[G].duration=G?d[G-1].duration:x;d[G].cts=0,N=gt}}}E=J||!E?x:E,this.nextAvcDts=g=T+E,this.videoSampleDuration=E,this.isVideoContiguous=!0;const F=it.moof(t.sequenceNumber++,A,dr({},t,{samples:d})),j="video",bt={data1:F,data2:at,startPTS:w/o,endPTS:(C+E)/o,startDTS:A/o,endDTS:g/o,type:j,hasAudio:!1,hasVideo:!0,nb:d.length,dropped:t.dropped};return t.samples=[],t.dropped=0,bt}remuxAudio(t,e,r,n,o){const l=t.inputTimeScale,d=t.samplerate?t.samplerate:l,f=l/d,p=t.segmentCodec==="aac"?ip:eE,g=p*f,v=this._initPTS,E=t.segmentCodec==="mp3"&&this.typeSupported.mpeg,A=[],T=o!==void 0;let w=t.samples,C=E?0:8,D=this.nextAudioPts||-1;const M=e*l,U=v.baseTime*l/v.timescale;if(this.isAudioContiguous=r=r||w.length&&D>0&&(n&&Math.abs(M-D)<9e3||Math.abs(pi(w[0].pts-U,M)-D)<20*g),w.forEach(function(F){F.pts=pi(F.pts-U,M)}),!r||D<0){if(w=w.filter(F=>F.pts>=0),!w.length)return;o===0?D=0:n&&!T?D=Math.max(0,M):D=w[0].pts}if(t.segmentCodec==="aac"){const F=this.config.maxAudioFramesDrift;for(let j=0,bt=D;j<w.length;j++){const N=w[j],G=N.pts,Z=G-bt,gt=Math.abs(1e3*Z/l);if(Z<=-F*g&&T)j===0&&(X.warn(`Audio frame @ ${(G/l).toFixed(3)}s overlaps nextAudioPts by ${Math.round(1e3*Z/l)} ms.`),this.nextAudioPts=D=bt=G);else if(Z>=F*g&&gt<tE&&T){let vt=Math.round(Z/g);bt=G-vt*g,bt<0&&(vt--,bt+=g),j===0&&(this.nextAudioPts=D=bt),X.warn(`[mp4-remuxer]: Injecting ${vt} audio frame @ ${(bt/l).toFixed(3)}s due to ${Math.round(1e3*Z/l)} ms gap.`);for(let It=0;It<vt;It++){const Bt=Math.max(bt,0);let Xt=ep.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);Xt||(X.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),Xt=N.unit.subarray()),w.splice(j,0,{unit:Xt,pts:Bt}),bt+=g,j++}}N.pts=bt,bt+=g}}let x=null,O=null,K,B=0,at=w.length;for(;at--;)B+=w[at].unit.byteLength;for(let F=0,j=w.length;F<j;F++){const bt=w[F],N=bt.unit;let G=bt.pts;if(O!==null){const gt=A[F-1];gt.duration=Math.round((G-O)/f)}else if(r&&t.segmentCodec==="aac"&&(G=D),x=G,B>0){B+=C;try{K=new Uint8Array(B)}catch(gt){this.observer.emit(R.ERROR,R.ERROR,{type:Qt.MUX_ERROR,details:ut.REMUX_ALLOC_ERROR,fatal:!1,error:gt,bytes:B,reason:`fail allocating audio mdat ${B}`});return}E||(new DataView(K.buffer).setUint32(0,B),K.set(it.types.mdat,4))}else return;K.set(N,C);const Z=N.byteLength;C+=Z,A.push(new ap(!0,p,Z,0)),O=G}const st=A.length;if(!st)return;const J=A[A.length-1];this.nextAudioPts=D=O+f*J.duration;const kt=E?new Uint8Array(0):it.moof(t.sequenceNumber++,x/f,dr({},t,{samples:A}));t.samples=[];const ft=x/l,wt=D/l,Pt={data1:kt,data2:K,startPTS:ft,endPTS:wt,startDTS:ft,endDTS:wt,type:"audio",hasAudio:!0,hasVideo:!1,nb:st};return this.isAudioContiguous=!0,Pt}remuxEmptyAudio(t,e,r,n){const o=t.inputTimeScale,l=t.samplerate?t.samplerate:o,d=o/l,f=this.nextAudioPts,p=this._initDTS,g=p.baseTime*9e4/p.timescale,v=(f!==null?f:n.startDTS*o)+g,E=n.endDTS*o+g,A=d*ip,T=Math.ceil((E-v)/A),w=ep.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);if(X.warn("[mp4-remuxer]: remux empty Audio"),!w){X.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}const C=[];for(let D=0;D<T;D++){const M=v+D*A;C.push({unit:w,pts:M,dts:M})}return t.samples=C,this.remuxAudio(t,e,r,!1)}}function pi(i,t){let e;if(t===null)return i;for(t<i?e=-8589934592:e=8589934592;Math.abs(i-t)>4294967296;)i+=e;return i}function rE(i){for(let t=0;t<i.length;t++)if(i[t].key)return t;return-1}function sp(i,t,e,r){const n=i.samples.length;if(!n)return;const o=i.inputTimeScale;for(let d=0;d<n;d++){const f=i.samples[d];f.pts=pi(f.pts-e.baseTime*o/e.timescale,t*o)/o,f.dts=pi(f.dts-r.baseTime*o/r.timescale,t*o)/o}const l=i.samples;return i.samples=[],{samples:l}}function np(i,t,e){const r=i.samples.length;if(!r)return;const n=i.inputTimeScale;for(let l=0;l<r;l++){const d=i.samples[l];d.pts=pi(d.pts-e.baseTime*n/e.timescale,t*n)/n}i.samples.sort((l,d)=>l.pts-d.pts);const o=i.samples;return i.samples=[],{samples:o}}class ap{constructor(t,e,r,n){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=e,this.size=r,this.cts=n,this.flags=new iE(t)}}class iE{constructor(t){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=t?2:1,this.isNonSync=t?0:1}}class sE{constructor(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null}destroy(){}resetTimeStamp(t){this.initPTS=t,this.lastEndTime=null}resetNextTimestamp(){this.lastEndTime=null}resetInitSegment(t,e,r,n){this.audioCodec=e,this.videoCodec=r,this.generateInitSegment(wb(t,n)),this.emitInitSegment=!0}generateInitSegment(t){let{audioCodec:e,videoCodec:r}=this;if(!(t!=null&&t.byteLength)){this.initTracks=void 0,this.initData=void 0;return}const n=this.initData=lf(t);e||(e=op(n.audio,Oe.AUDIO)),r||(r=op(n.video,Oe.VIDEO));const o={};n.audio&&n.video?o.audiovideo={container:"video/mp4",codec:e+","+r,initSegment:t,id:"main"}:n.audio?o.audio={container:"audio/mp4",codec:e,initSegment:t,id:"audio"}:n.video?o.video={container:"video/mp4",codec:r,initSegment:t,id:"main"}:X.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=o}remux(t,e,r,n,o,l){var d,f;let{initPTS:p,lastEndTime:g}=this;const v={audio:void 0,video:void 0,text:n,id3:r,initSegment:void 0};jt(g)||(g=this.lastEndTime=o||0);const E=e.samples;if(!(E!=null&&E.length))return v;const A={initPTS:void 0,timescale:1};let T=this.initData;if((d=T)!=null&&d.length||(this.generateInitSegment(E),T=this.initData),!((f=T)!=null&&f.length))return X.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),v;this.emitInitSegment&&(A.tracks=this.initTracks,this.emitInitSegment=!1);const w=Rb(E,T),C=Sb(T,E),D=C===null?o:C;(nE(p,D,o,w)||A.timescale!==p.timescale&&l)&&(A.initPTS=D-o,p&&p.timescale===1&&X.warn(`Adjusting initPTS by ${A.initPTS-p.baseTime}`),this.initPTS=p={baseTime:A.initPTS,timescale:1});const M=t?D-p.baseTime/p.timescale:g,U=M+w;Lb(T,E,p.baseTime/p.timescale),w>0?this.lastEndTime=U:(X.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const x=!!T.audio,O=!!T.video;let K="";x&&(K+="audio"),O&&(K+="video");const B={data1:E,startPTS:M,startDTS:M,endPTS:U,endDTS:U,type:K,hasAudio:x,hasVideo:O,nb:1,dropped:0};return v.audio=B.type==="audio"?B:void 0,v.video=B.type!=="audio"?B:void 0,v.initSegment=A,v.id3=sp(r,o,p,p),n.samples.length&&(v.text=np(n,o,p)),v}}function nE(i,t,e,r){if(i===null)return!0;const n=Math.max(r,1),o=t-i.baseTime/i.timescale;return Math.abs(o-e)>n}function op(i,t){const e=i==null?void 0:i.codec;return e&&e.length>4?e:e==="hvc1"||e==="hev1"?"hvc1.1.6.L120.90":e==="av01"?"av01.0.04M.08":e==="avc1"||t===Oe.VIDEO?"avc1.42e01e":"mp4a.40.5"}let ns;try{ns=self.performance.now.bind(self.performance)}catch{X.debug("Unable to use Performance API on this environment"),ns=typeof self<"u"&&self.Date.now}const uh=[{demux:G4,remux:sE},{demux:Ls,remux:dh},{demux:U4,remux:dh},{demux:q4,remux:dh}];class lp{constructor(t,e,r,n,o){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=t,this.typeSupported=e,this.config=r,this.vendor=n,this.id=o}configure(t){this.transmuxConfig=t,this.decrypter&&this.decrypter.reset()}push(t,e,r,n){const o=r.transmuxing;o.executeStart=ns();let l=new Uint8Array(t);const{currentTransmuxState:d,transmuxConfig:f}=this;n&&(this.currentTransmuxState=n);const{contiguous:p,discontinuity:g,trackSwitch:v,accurateTimeOffset:E,timeOffset:A,initSegmentChange:T}=n||d,{audioCodec:w,videoCodec:C,defaultInitPts:D,duration:M,initSegmentData:U}=f,x=aE(l,e);if(x&&x.method==="AES-128"){const at=this.getDecrypter();if(at.isSync()){let st=at.softwareDecrypt(l,x.key.buffer,x.iv.buffer);if(r.part>-1&&(st=at.flush()),!st)return o.executeEnd=ns(),fh(r);l=new Uint8Array(st)}else return this.decryptionPromise=at.webCryptoDecrypt(l,x.key.buffer,x.iv.buffer).then(st=>{const J=this.push(st,null,r);return this.decryptionPromise=null,J}),this.decryptionPromise}const O=this.needsProbing(g,v);if(O){const at=this.configureTransmuxer(l);if(at)return X.warn(`[transmuxer] ${at.message}`),this.observer.emit(R.ERROR,R.ERROR,{type:Qt.MEDIA_ERROR,details:ut.FRAG_PARSING_ERROR,fatal:!1,error:at,reason:at.message}),o.executeEnd=ns(),fh(r)}(g||v||T||O)&&this.resetInitSegment(U,w,C,M,e),(g||T||O)&&this.resetInitialTimestamp(D),p||this.resetContiguity();const K=this.transmux(l,x,A,E,r),B=this.currentTransmuxState;return B.contiguous=!0,B.discontinuity=!1,B.trackSwitch=!1,o.executeEnd=ns(),K}flush(t){const e=t.transmuxing;e.executeStart=ns();const{decrypter:r,currentTransmuxState:n,decryptionPromise:o}=this;if(o)return o.then(()=>this.flush(t));const l=[],{timeOffset:d}=n;if(r){const v=r.flush();v&&l.push(this.push(v,null,t))}const{demuxer:f,remuxer:p}=this;if(!f||!p)return e.executeEnd=ns(),[fh(t)];const g=f.flush(d);return sl(g)?g.then(v=>(this.flushRemux(l,v,t),l)):(this.flushRemux(l,g,t),l)}flushRemux(t,e,r){const{audioTrack:n,videoTrack:o,id3Track:l,textTrack:d}=e,{accurateTimeOffset:f,timeOffset:p}=this.currentTransmuxState;X.log(`[transmuxer.ts]: Flushed fragment ${r.sn}${r.part>-1?" p: "+r.part:""} of level ${r.level}`);const g=this.remuxer.remux(n,o,l,d,p,f,!0,this.id);t.push({remuxResult:g,chunkMeta:r}),r.transmuxing.executeEnd=ns()}resetInitialTimestamp(t){const{demuxer:e,remuxer:r}=this;!e||!r||(e.resetTimeStamp(t),r.resetTimeStamp(t))}resetContiguity(){const{demuxer:t,remuxer:e}=this;!t||!e||(t.resetContiguity(),e.resetNextTimestamp())}resetInitSegment(t,e,r,n,o){const{demuxer:l,remuxer:d}=this;!l||!d||(l.resetInitSegment(t,e,r,n),d.resetInitSegment(t,e,r,o))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(t,e,r,n,o){let l;return e&&e.method==="SAMPLE-AES"?l=this.transmuxSampleAes(t,e,r,n,o):l=this.transmuxUnencrypted(t,r,n,o),l}transmuxUnencrypted(t,e,r,n){const{audioTrack:o,videoTrack:l,id3Track:d,textTrack:f}=this.demuxer.demux(t,e,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(o,l,d,f,e,r,!1,this.id),chunkMeta:n}}transmuxSampleAes(t,e,r,n,o){return this.demuxer.demuxSampleAes(t,e,r).then(l=>({remuxResult:this.remuxer.remux(l.audioTrack,l.videoTrack,l.id3Track,l.textTrack,r,n,!1,this.id),chunkMeta:o}))}configureTransmuxer(t){const{config:e,observer:r,typeSupported:n,vendor:o}=this;let l;for(let v=0,E=uh.length;v<E;v++)if(uh[v].demux.probe(t)){l=uh[v];break}if(!l)return new Error("Failed to find demuxer by probing fragment data");const d=this.demuxer,f=this.remuxer,p=l.remux,g=l.demux;(!f||!(f instanceof p))&&(this.remuxer=new p(r,e,n,o)),(!d||!(d instanceof g))&&(this.demuxer=new g(r,e,n),this.probe=g.probe)}needsProbing(t,e){return!this.demuxer||!this.remuxer||t||e}getDecrypter(){let t=this.decrypter;return t||(t=this.decrypter=new sh(this.config)),t}}function aE(i,t){let e=null;return i.byteLength>0&&t!=null&&t.key!=null&&t.iv!==null&&t.method!=null&&(e=t),e}const fh=i=>({remuxResult:{},chunkMeta:i});function sl(i){return"then"in i&&i.then instanceof Function}class oE{constructor(t,e,r,n,o){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=t,this.videoCodec=e,this.initSegmentData=r,this.duration=n,this.defaultInitPts=o||null}}class lE{constructor(t,e,r,n,o,l){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=t,this.contiguous=e,this.accurateTimeOffset=r,this.trackSwitch=n,this.timeOffset=o,this.initSegmentChange=l}}var cp={exports:{}};(function(i){var t=Object.prototype.hasOwnProperty,e="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(e=!1));function n(f,p,g){this.fn=f,this.context=p,this.once=g||!1}function o(f,p,g,v,E){if(typeof g!="function")throw new TypeError("The listener must be a function");var A=new n(g,v||f,E),T=e?e+p:p;return f._events[T]?f._events[T].fn?f._events[T]=[f._events[T],A]:f._events[T].push(A):(f._events[T]=A,f._eventsCount++),f}function l(f,p){--f._eventsCount===0?f._events=new r:delete f._events[p]}function d(){this._events=new r,this._eventsCount=0}d.prototype.eventNames=function(){var f=[],p,g;if(this._eventsCount===0)return f;for(g in p=this._events)t.call(p,g)&&f.push(e?g.slice(1):g);return Object.getOwnPropertySymbols?f.concat(Object.getOwnPropertySymbols(p)):f},d.prototype.listeners=function(f){var p=e?e+f:f,g=this._events[p];if(!g)return[];if(g.fn)return[g.fn];for(var v=0,E=g.length,A=new Array(E);v<E;v++)A[v]=g[v].fn;return A},d.prototype.listenerCount=function(f){var p=e?e+f:f,g=this._events[p];return g?g.fn?1:g.length:0},d.prototype.emit=function(f,p,g,v,E,A){var T=e?e+f:f;if(!this._events[T])return!1;var w=this._events[T],C=arguments.length,D,M;if(w.fn){switch(w.once&&this.removeListener(f,w.fn,void 0,!0),C){case 1:return w.fn.call(w.context),!0;case 2:return w.fn.call(w.context,p),!0;case 3:return w.fn.call(w.context,p,g),!0;case 4:return w.fn.call(w.context,p,g,v),!0;case 5:return w.fn.call(w.context,p,g,v,E),!0;case 6:return w.fn.call(w.context,p,g,v,E,A),!0}for(M=1,D=new Array(C-1);M<C;M++)D[M-1]=arguments[M];w.fn.apply(w.context,D)}else{var U=w.length,x;for(M=0;M<U;M++)switch(w[M].once&&this.removeListener(f,w[M].fn,void 0,!0),C){case 1:w[M].fn.call(w[M].context);break;case 2:w[M].fn.call(w[M].context,p);break;case 3:w[M].fn.call(w[M].context,p,g);break;case 4:w[M].fn.call(w[M].context,p,g,v);break;default:if(!D)for(x=1,D=new Array(C-1);x<C;x++)D[x-1]=arguments[x];w[M].fn.apply(w[M].context,D)}}return!0},d.prototype.on=function(f,p,g){return o(this,f,p,g,!1)},d.prototype.once=function(f,p,g){return o(this,f,p,g,!0)},d.prototype.removeListener=function(f,p,g,v){var E=e?e+f:f;if(!this._events[E])return this;if(!p)return l(this,E),this;var A=this._events[E];if(A.fn)A.fn===p&&(!v||A.once)&&(!g||A.context===g)&&l(this,E);else{for(var T=0,w=[],C=A.length;T<C;T++)(A[T].fn!==p||v&&!A[T].once||g&&A[T].context!==g)&&w.push(A[T]);w.length?this._events[E]=w.length===1?w[0]:w:l(this,E)}return this},d.prototype.removeAllListeners=function(f){var p;return f?(p=e?e+f:f,this._events[p]&&l(this,p)):(this._events=new r,this._eventsCount=0),this},d.prototype.off=d.prototype.removeListener,d.prototype.addListener=d.prototype.on,d.prefixed=e,d.EventEmitter=d,i.exports=d})(cp);var cE=cp.exports,ph=Yy(cE);const gh=zo()||{isTypeSupported:()=>!1};class hp{constructor(t,e,r,n){this.error=null,this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;const o=t.config;this.hls=t,this.id=e,this.useWorker=!!o.enableWorker,this.onTransmuxComplete=r,this.onFlush=n;const l=(p,g)=>{g=g||{},g.frag=this.frag,g.id=this.id,p===R.ERROR&&(this.error=g.error),this.hls.trigger(p,g)};this.observer=new ph,this.observer.on(R.FRAG_DECRYPTED,l),this.observer.on(R.ERROR,l);const d={mp4:gh.isTypeSupported("video/mp4"),mpeg:gh.isTypeSupported("audio/mpeg"),mp3:gh.isTypeSupported('audio/mp4; codecs="mp3"')},f=navigator.vendor;if(this.useWorker&&typeof Worker<"u"&&(o.workerPath||I4())){try{o.workerPath?(X.log(`loading Web Worker ${o.workerPath} for "${e}"`),this.workerContext=D4(o.workerPath)):(X.log(`injecting Web Worker for "${e}"`),this.workerContext=x4()),this.onwmsg=g=>this.onWorkerMessage(g);const{worker:p}=this.workerContext;p.addEventListener("message",this.onwmsg),p.onerror=g=>{const v=new Error(`${g.message} (${g.filename}:${g.lineno})`);o.enableWorker=!1,X.warn(`Error in "${e}" Web Worker, fallback to inline`),this.hls.trigger(R.ERROR,{type:Qt.OTHER_ERROR,details:ut.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:v})},p.postMessage({cmd:"init",typeSupported:d,vendor:f,id:e,config:JSON.stringify(o)})}catch(p){X.warn(`Error setting up "${e}" Web Worker, fallback to inline`,p),this.resetWorker(),this.error=null,this.transmuxer=new lp(this.observer,d,o,f,e)}return}this.transmuxer=new lp(this.observer,d,o,f,e)}resetWorker(){if(this.workerContext){const{worker:t,objectURL:e}=this.workerContext;e&&self.URL.revokeObjectURL(e),t.removeEventListener("message",this.onwmsg),t.onerror=null,t.terminate(),this.workerContext=null}}destroy(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{const e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}const t=this.observer;t&&t.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null}push(t,e,r,n,o,l,d,f,p,g){var v,E;p.transmuxing.start=self.performance.now();const{transmuxer:A}=this,T=l?l.start:o.start,w=o.decryptdata,C=this.frag,D=!(C&&o.cc===C.cc),M=!(C&&p.level===C.level),U=C?p.sn-C.sn:-1,x=this.part?p.part-this.part.index:-1,O=U===0&&p.id>1&&p.id===(C==null?void 0:C.stats.chunkCount),K=!M&&(U===1||U===0&&(x===1||O&&x<=0)),B=self.performance.now();(M||U||o.stats.parsing.start===0)&&(o.stats.parsing.start=B),l&&(x||!K)&&(l.stats.parsing.start=B);const at=!(C&&((v=o.initSegment)==null?void 0:v.url)===((E=C.initSegment)==null?void 0:E.url)),st=new lE(D,K,f,M,T,at);if(!K||D||at){X.log(`[transmuxer-interface, ${o.type}]: Starting new transmux session for sn: ${p.sn} p: ${p.part} level: ${p.level} id: ${p.id}
183
+ */const o0=(i,t,e)=>{const r=new Map;for(let n=t;n<=e;n++)r.set(i[n],n);return r},l0=wn(class extends ha{constructor(i){if(super(i),i.type!==kn.CHILD)throw Error("repeat() can only be used in text expressions")}ht(i,t,e){let r;e===void 0?e=t:t!==void 0&&(r=t);const n=[],o=[];let l=0;for(const d of i)n[l]=r?r(d,l):l,o[l]=e(d,l),l++;return{values:o,keys:n}}render(i,t,e){return this.ht(i,t,e).values}update(i,[t,e,r]){const n=nm(i),{values:o,keys:l}=this.ht(t,e,r);if(!Array.isArray(n))return this.dt=l,o;const d=this.dt??(this.dt=[]),f=[];let p,g,v=0,E=n.length-1,A=0,T=o.length-1;for(;v<=E&&A<=T;)if(n[v]===null)v++;else if(n[E]===null)E--;else if(d[v]===l[A])f[A]=rn(n[v],o[A]),v++,A++;else if(d[E]===l[T])f[T]=rn(n[E],o[T]),E--,T--;else if(d[v]===l[T])f[T]=rn(n[v],o[T]),ca(i,f[T+1],n[v]),v++,T--;else if(d[E]===l[A])f[A]=rn(n[E],o[A]),ca(i,n[v],n[E]),E--,A++;else if(p===void 0&&(p=o0(l,A,T),g=o0(d,v,E)),p.has(d[v]))if(p.has(d[E])){const w=g.get(l[A]),C=w!==void 0?n[w]:null;if(C===null){const D=ca(i,n[v]);rn(D,o[A]),f[A]=D}else f[A]=rn(C,o[A]),ca(i,n[v],C),n[w]=null;A++}else jl(n[E]),E--;else jl(n[v]),v++;for(;A<=T;){const w=ca(i,f[T+1]);rn(w,o[A]),f[A++]=w}for(;v<=E;){const w=n[v++];w!==null&&jl(w)}return this.dt=l,sm(i,f),ys}});var jr="top",hi="bottom",di="right",Kr="left",bc="auto",Sa=[jr,hi,di,Kr],Rn="start",Ra="end",mv="clippingParents",c0="viewport",_a="popper",vv="reference",h0=Sa.reduce(function(i,t){return i.concat([t+"-"+Rn,t+"-"+Ra])},[]),d0=[].concat(Sa,[bc]).reduce(function(i,t){return i.concat([t,t+"-"+Rn,t+"-"+Ra])},[]),yv="beforeRead",bv="read",Ev="afterRead",Av="beforeMain",Tv="main",kv="afterMain",wv="beforeWrite",Sv="write",Rv="afterWrite",_v=[yv,bv,Ev,Av,Tv,kv,wv,Sv,Rv];function Oi(i){return i?(i.nodeName||"").toLowerCase():null}function si(i){if(i==null)return window;if(i.toString()!=="[object Window]"){var t=i.ownerDocument;return t&&t.defaultView||window}return i}function on(i){var t=si(i).Element;return i instanceof t||i instanceof Element}function ui(i){var t=si(i).HTMLElement;return i instanceof t||i instanceof HTMLElement}function Ec(i){if(typeof ShadowRoot>"u")return!1;var t=si(i).ShadowRoot;return i instanceof t||i instanceof ShadowRoot}function Lv(i){var t=i.state;Object.keys(t.elements).forEach(function(e){var r=t.styles[e]||{},n=t.attributes[e]||{},o=t.elements[e];!ui(o)||!Oi(o)||(Object.assign(o.style,r),Object.keys(n).forEach(function(l){var d=n[l];d===!1?o.removeAttribute(l):o.setAttribute(l,d===!0?"":d)}))})}function Cv(i){var t=i.state,e={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(t.elements.popper.style,e.popper),t.styles=e,t.elements.arrow&&Object.assign(t.elements.arrow.style,e.arrow),function(){Object.keys(t.elements).forEach(function(r){var n=t.elements[r],o=t.attributes[r]||{},l=Object.keys(t.styles.hasOwnProperty(r)?t.styles[r]:e[r]),d=l.reduce(function(f,p){return f[p]="",f},{});!ui(n)||!Oi(n)||(Object.assign(n.style,d),Object.keys(o).forEach(function(f){n.removeAttribute(f)}))})}}const u0={name:"applyStyles",enabled:!0,phase:"write",fn:Lv,effect:Cv,requires:["computeStyles"]};function $i(i){return i.split("-")[0]}var ln=Math.max,$o=Math.min,_n=Math.round;function Ac(){var i=navigator.userAgentData;return i!=null&&i.brands&&Array.isArray(i.brands)?i.brands.map(function(t){return t.brand+"/"+t.version}).join(" "):navigator.userAgent}function f0(){return!/^((?!chrome|android).)*safari/i.test(Ac())}function Ln(i,t,e){t===void 0&&(t=!1),e===void 0&&(e=!1);var r=i.getBoundingClientRect(),n=1,o=1;t&&ui(i)&&(n=i.offsetWidth>0&&_n(r.width)/i.offsetWidth||1,o=i.offsetHeight>0&&_n(r.height)/i.offsetHeight||1);var l=on(i)?si(i):window,d=l.visualViewport,f=!f0()&&e,p=(r.left+(f&&d?d.offsetLeft:0))/n,g=(r.top+(f&&d?d.offsetTop:0))/o,v=r.width/n,E=r.height/o;return{width:v,height:E,top:g,right:p+v,bottom:g+E,left:p,x:p,y:g}}function Tc(i){var t=Ln(i),e=i.offsetWidth,r=i.offsetHeight;return Math.abs(t.width-e)<=1&&(e=t.width),Math.abs(t.height-r)<=1&&(r=t.height),{x:i.offsetLeft,y:i.offsetTop,width:e,height:r}}function p0(i,t){var e=t.getRootNode&&t.getRootNode();if(i.contains(t))return!0;if(e&&Ec(e)){var r=t;do{if(r&&i.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function is(i){return si(i).getComputedStyle(i)}function Iv(i){return["table","td","th"].indexOf(Oi(i))>=0}function _s(i){return((on(i)?i.ownerDocument:i.document)||window.document).documentElement}function Mo(i){return Oi(i)==="html"?i:i.assignedSlot||i.parentNode||(Ec(i)?i.host:null)||_s(i)}function g0(i){return!ui(i)||is(i).position==="fixed"?null:i.offsetParent}function xv(i){var t=/firefox/i.test(Ac()),e=/Trident/i.test(Ac());if(e&&ui(i)){var r=is(i);if(r.position==="fixed")return null}var n=Mo(i);for(Ec(n)&&(n=n.host);ui(n)&&["html","body"].indexOf(Oi(n))<0;){var o=is(n);if(o.transform!=="none"||o.perspective!=="none"||o.contain==="paint"||["transform","perspective"].indexOf(o.willChange)!==-1||t&&o.willChange==="filter"||t&&o.filter&&o.filter!=="none")return n;n=n.parentNode}return null}function La(i){for(var t=si(i),e=g0(i);e&&Iv(e)&&is(e).position==="static";)e=g0(e);return e&&(Oi(e)==="html"||Oi(e)==="body"&&is(e).position==="static")?t:e||xv(i)||t}function kc(i){return["top","bottom"].indexOf(i)>=0?"x":"y"}function Ca(i,t,e){return ln(i,$o(t,e))}function Dv(i,t,e){var r=Ca(i,t,e);return r>e?e:r}function m0(){return{top:0,right:0,bottom:0,left:0}}function v0(i){return Object.assign({},m0(),i)}function y0(i,t){return t.reduce(function(e,r){return e[r]=i,e},{})}var Pv=function(t,e){return t=typeof t=="function"?t(Object.assign({},e.rects,{placement:e.placement})):t,v0(typeof t!="number"?t:y0(t,Sa))};function Ov(i){var t,e=i.state,r=i.name,n=i.options,o=e.elements.arrow,l=e.modifiersData.popperOffsets,d=$i(e.placement),f=kc(d),p=[Kr,di].indexOf(d)>=0,g=p?"height":"width";if(!(!o||!l)){var v=Pv(n.padding,e),E=Tc(o),A=f==="y"?jr:Kr,T=f==="y"?hi:di,w=e.rects.reference[g]+e.rects.reference[f]-l[f]-e.rects.popper[g],C=l[f]-e.rects.reference[f],D=La(o),M=D?f==="y"?D.clientHeight||0:D.clientWidth||0:0,U=w/2-C/2,x=v[A],O=M-E[g]-v[T],K=M/2-E[g]/2+U,B=Ca(x,K,O),at=f;e.modifiersData[r]=(t={},t[at]=B,t.centerOffset=B-K,t)}}function $v(i){var t=i.state,e=i.options,r=e.element,n=r===void 0?"[data-popper-arrow]":r;n!=null&&(typeof n=="string"&&(n=t.elements.popper.querySelector(n),!n)||p0(t.elements.popper,n)&&(t.elements.arrow=n))}const Mv={name:"arrow",enabled:!0,phase:"main",fn:Ov,effect:$v,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function Cn(i){return i.split("-")[1]}var Nv={top:"auto",right:"auto",bottom:"auto",left:"auto"};function Fv(i,t){var e=i.x,r=i.y,n=t.devicePixelRatio||1;return{x:_n(e*n)/n||0,y:_n(r*n)/n||0}}function b0(i){var t,e=i.popper,r=i.popperRect,n=i.placement,o=i.variation,l=i.offsets,d=i.position,f=i.gpuAcceleration,p=i.adaptive,g=i.roundOffsets,v=i.isFixed,E=l.x,A=E===void 0?0:E,T=l.y,w=T===void 0?0:T,C=typeof g=="function"?g({x:A,y:w}):{x:A,y:w};A=C.x,w=C.y;var D=l.hasOwnProperty("x"),M=l.hasOwnProperty("y"),U=Kr,x=jr,O=window;if(p){var K=La(e),B="clientHeight",at="clientWidth";if(K===si(e)&&(K=_s(e),is(K).position!=="static"&&d==="absolute"&&(B="scrollHeight",at="scrollWidth")),K=K,n===jr||(n===Kr||n===di)&&o===Ra){x=hi;var st=v&&K===O&&O.visualViewport?O.visualViewport.height:K[B];w-=st-r.height,w*=f?1:-1}if(n===Kr||(n===jr||n===hi)&&o===Ra){U=di;var J=v&&K===O&&O.visualViewport?O.visualViewport.width:K[at];A-=J-r.width,A*=f?1:-1}}var kt=Object.assign({position:d},p&&Nv),ft=g===!0?Fv({x:A,y:w},si(e)):{x:A,y:w};if(A=ft.x,w=ft.y,f){var wt;return Object.assign({},kt,(wt={},wt[x]=M?"0":"",wt[U]=D?"0":"",wt.transform=(O.devicePixelRatio||1)<=1?"translate("+A+"px, "+w+"px)":"translate3d("+A+"px, "+w+"px, 0)",wt))}return Object.assign({},kt,(t={},t[x]=M?w+"px":"",t[U]=D?A+"px":"",t.transform="",t))}function Uv(i){var t=i.state,e=i.options,r=e.gpuAcceleration,n=r===void 0?!0:r,o=e.adaptive,l=o===void 0?!0:o,d=e.roundOffsets,f=d===void 0?!0:d,p={placement:$i(t.placement),variation:Cn(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:n,isFixed:t.options.strategy==="fixed"};t.modifiersData.popperOffsets!=null&&(t.styles.popper=Object.assign({},t.styles.popper,b0(Object.assign({},p,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:l,roundOffsets:f})))),t.modifiersData.arrow!=null&&(t.styles.arrow=Object.assign({},t.styles.arrow,b0(Object.assign({},p,{offsets:t.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:f})))),t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-placement":t.placement})}const Bv={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:Uv,data:{}};var No={passive:!0};function Gv(i){var t=i.state,e=i.instance,r=i.options,n=r.scroll,o=n===void 0?!0:n,l=r.resize,d=l===void 0?!0:l,f=si(t.elements.popper),p=[].concat(t.scrollParents.reference,t.scrollParents.popper);return o&&p.forEach(function(g){g.addEventListener("scroll",e.update,No)}),d&&f.addEventListener("resize",e.update,No),function(){o&&p.forEach(function(g){g.removeEventListener("scroll",e.update,No)}),d&&f.removeEventListener("resize",e.update,No)}}const Hv={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:Gv,data:{}};var Vv={left:"right",right:"left",bottom:"top",top:"bottom"};function Fo(i){return i.replace(/left|right|bottom|top/g,function(t){return Vv[t]})}var Wv={start:"end",end:"start"};function E0(i){return i.replace(/start|end/g,function(t){return Wv[t]})}function wc(i){var t=si(i),e=t.pageXOffset,r=t.pageYOffset;return{scrollLeft:e,scrollTop:r}}function Sc(i){return Ln(_s(i)).left+wc(i).scrollLeft}function jv(i,t){var e=si(i),r=_s(i),n=e.visualViewport,o=r.clientWidth,l=r.clientHeight,d=0,f=0;if(n){o=n.width,l=n.height;var p=f0();(p||!p&&t==="fixed")&&(d=n.offsetLeft,f=n.offsetTop)}return{width:o,height:l,x:d+Sc(i),y:f}}function Kv(i){var t,e=_s(i),r=wc(i),n=(t=i.ownerDocument)==null?void 0:t.body,o=ln(e.scrollWidth,e.clientWidth,n?n.scrollWidth:0,n?n.clientWidth:0),l=ln(e.scrollHeight,e.clientHeight,n?n.scrollHeight:0,n?n.clientHeight:0),d=-r.scrollLeft+Sc(i),f=-r.scrollTop;return is(n||e).direction==="rtl"&&(d+=ln(e.clientWidth,n?n.clientWidth:0)-o),{width:o,height:l,x:d,y:f}}function Rc(i){var t=is(i),e=t.overflow,r=t.overflowX,n=t.overflowY;return/auto|scroll|overlay|hidden/.test(e+n+r)}function A0(i){return["html","body","#document"].indexOf(Oi(i))>=0?i.ownerDocument.body:ui(i)&&Rc(i)?i:A0(Mo(i))}function Ia(i,t){var e;t===void 0&&(t=[]);var r=A0(i),n=r===((e=i.ownerDocument)==null?void 0:e.body),o=si(r),l=n?[o].concat(o.visualViewport||[],Rc(r)?r:[]):r,d=t.concat(l);return n?d:d.concat(Ia(Mo(l)))}function _c(i){return Object.assign({},i,{left:i.x,top:i.y,right:i.x+i.width,bottom:i.y+i.height})}function zv(i,t){var e=Ln(i,!1,t==="fixed");return e.top=e.top+i.clientTop,e.left=e.left+i.clientLeft,e.bottom=e.top+i.clientHeight,e.right=e.left+i.clientWidth,e.width=i.clientWidth,e.height=i.clientHeight,e.x=e.left,e.y=e.top,e}function T0(i,t,e){return t===c0?_c(jv(i,e)):on(t)?zv(t,e):_c(Kv(_s(i)))}function Yv(i){var t=Ia(Mo(i)),e=["absolute","fixed"].indexOf(is(i).position)>=0,r=e&&ui(i)?La(i):i;return on(r)?t.filter(function(n){return on(n)&&p0(n,r)&&Oi(n)!=="body"}):[]}function Xv(i,t,e,r){var n=t==="clippingParents"?Yv(i):[].concat(t),o=[].concat(n,[e]),l=o[0],d=o.reduce(function(f,p){var g=T0(i,p,r);return f.top=ln(g.top,f.top),f.right=$o(g.right,f.right),f.bottom=$o(g.bottom,f.bottom),f.left=ln(g.left,f.left),f},T0(i,l,r));return d.width=d.right-d.left,d.height=d.bottom-d.top,d.x=d.left,d.y=d.top,d}function k0(i){var t=i.reference,e=i.element,r=i.placement,n=r?$i(r):null,o=r?Cn(r):null,l=t.x+t.width/2-e.width/2,d=t.y+t.height/2-e.height/2,f;switch(n){case jr:f={x:l,y:t.y-e.height};break;case hi:f={x:l,y:t.y+t.height};break;case di:f={x:t.x+t.width,y:d};break;case Kr:f={x:t.x-e.width,y:d};break;default:f={x:t.x,y:t.y}}var p=n?kc(n):null;if(p!=null){var g=p==="y"?"height":"width";switch(o){case Rn:f[p]=f[p]-(t[g]/2-e[g]/2);break;case Ra:f[p]=f[p]+(t[g]/2-e[g]/2);break}}return f}function xa(i,t){t===void 0&&(t={});var e=t,r=e.placement,n=r===void 0?i.placement:r,o=e.strategy,l=o===void 0?i.strategy:o,d=e.boundary,f=d===void 0?mv:d,p=e.rootBoundary,g=p===void 0?c0:p,v=e.elementContext,E=v===void 0?_a:v,A=e.altBoundary,T=A===void 0?!1:A,w=e.padding,C=w===void 0?0:w,D=v0(typeof C!="number"?C:y0(C,Sa)),M=E===_a?vv:_a,U=i.rects.popper,x=i.elements[T?M:E],O=Xv(on(x)?x:x.contextElement||_s(i.elements.popper),f,g,l),K=Ln(i.elements.reference),B=k0({reference:K,element:U,strategy:"absolute",placement:n}),at=_c(Object.assign({},U,B)),st=E===_a?at:K,J={top:O.top-st.top+D.top,bottom:st.bottom-O.bottom+D.bottom,left:O.left-st.left+D.left,right:st.right-O.right+D.right},kt=i.modifiersData.offset;if(E===_a&&kt){var ft=kt[n];Object.keys(J).forEach(function(wt){var Pt=[di,hi].indexOf(wt)>=0?1:-1,F=[jr,hi].indexOf(wt)>=0?"y":"x";J[wt]+=ft[F]*Pt})}return J}function Zv(i,t){t===void 0&&(t={});var e=t,r=e.placement,n=e.boundary,o=e.rootBoundary,l=e.padding,d=e.flipVariations,f=e.allowedAutoPlacements,p=f===void 0?d0:f,g=Cn(r),v=g?d?h0:h0.filter(function(T){return Cn(T)===g}):Sa,E=v.filter(function(T){return p.indexOf(T)>=0});E.length===0&&(E=v);var A=E.reduce(function(T,w){return T[w]=xa(i,{placement:w,boundary:n,rootBoundary:o,padding:l})[$i(w)],T},{});return Object.keys(A).sort(function(T,w){return A[T]-A[w]})}function qv(i){if($i(i)===bc)return[];var t=Fo(i);return[E0(i),t,E0(t)]}function Qv(i){var t=i.state,e=i.options,r=i.name;if(!t.modifiersData[r]._skip){for(var n=e.mainAxis,o=n===void 0?!0:n,l=e.altAxis,d=l===void 0?!0:l,f=e.fallbackPlacements,p=e.padding,g=e.boundary,v=e.rootBoundary,E=e.altBoundary,A=e.flipVariations,T=A===void 0?!0:A,w=e.allowedAutoPlacements,C=t.options.placement,D=$i(C),M=D===C,U=f||(M||!T?[Fo(C)]:qv(C)),x=[C].concat(U).reduce(function(Bt,Xt){return Bt.concat($i(Xt)===bc?Zv(t,{placement:Xt,boundary:g,rootBoundary:v,padding:p,flipVariations:T,allowedAutoPlacements:w}):Xt)},[]),O=t.rects.reference,K=t.rects.popper,B=new Map,at=!0,st=x[0],J=0;J<x.length;J++){var kt=x[J],ft=$i(kt),wt=Cn(kt)===Rn,Pt=[jr,hi].indexOf(ft)>=0,F=Pt?"width":"height",j=xa(t,{placement:kt,boundary:g,rootBoundary:v,altBoundary:E,padding:p}),bt=Pt?wt?di:Kr:wt?hi:jr;O[F]>K[F]&&(bt=Fo(bt));var N=Fo(bt),G=[];if(o&&G.push(j[ft]<=0),d&&G.push(j[bt]<=0,j[N]<=0),G.every(function(Bt){return Bt})){st=kt,at=!1;break}B.set(kt,G)}if(at)for(var Z=T?3:1,gt=function(Xt){var me=x.find(function(be){var Ee=B.get(be);if(Ee)return Ee.slice(0,Xt).every(function(Ye){return Ye})});if(me)return st=me,"break"},vt=Z;vt>0;vt--){var It=gt(vt);if(It==="break")break}t.placement!==st&&(t.modifiersData[r]._skip=!0,t.placement=st,t.reset=!0)}}const Jv={name:"flip",enabled:!0,phase:"main",fn:Qv,requiresIfExists:["offset"],data:{_skip:!1}};function w0(i,t,e){return e===void 0&&(e={x:0,y:0}),{top:i.top-t.height-e.y,right:i.right-t.width+e.x,bottom:i.bottom-t.height+e.y,left:i.left-t.width-e.x}}function S0(i){return[jr,di,hi,Kr].some(function(t){return i[t]>=0})}function ty(i){var t=i.state,e=i.name,r=t.rects.reference,n=t.rects.popper,o=t.modifiersData.preventOverflow,l=xa(t,{elementContext:"reference"}),d=xa(t,{altBoundary:!0}),f=w0(l,r),p=w0(d,n,o),g=S0(f),v=S0(p);t.modifiersData[e]={referenceClippingOffsets:f,popperEscapeOffsets:p,isReferenceHidden:g,hasPopperEscaped:v},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":g,"data-popper-escaped":v})}const ey={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:ty};function ry(i,t,e){var r=$i(i),n=[Kr,jr].indexOf(r)>=0?-1:1,o=typeof e=="function"?e(Object.assign({},t,{placement:i})):e,l=o[0],d=o[1];return l=l||0,d=(d||0)*n,[Kr,di].indexOf(r)>=0?{x:d,y:l}:{x:l,y:d}}function iy(i){var t=i.state,e=i.options,r=i.name,n=e.offset,o=n===void 0?[0,0]:n,l=d0.reduce(function(g,v){return g[v]=ry(v,t.rects,o),g},{}),d=l[t.placement],f=d.x,p=d.y;t.modifiersData.popperOffsets!=null&&(t.modifiersData.popperOffsets.x+=f,t.modifiersData.popperOffsets.y+=p),t.modifiersData[r]=l}const sy={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:iy};function ny(i){var t=i.state,e=i.name;t.modifiersData[e]=k0({reference:t.rects.reference,element:t.rects.popper,strategy:"absolute",placement:t.placement})}const ay={name:"popperOffsets",enabled:!0,phase:"read",fn:ny,data:{}};function oy(i){return i==="x"?"y":"x"}function ly(i){var t=i.state,e=i.options,r=i.name,n=e.mainAxis,o=n===void 0?!0:n,l=e.altAxis,d=l===void 0?!1:l,f=e.boundary,p=e.rootBoundary,g=e.altBoundary,v=e.padding,E=e.tether,A=E===void 0?!0:E,T=e.tetherOffset,w=T===void 0?0:T,C=xa(t,{boundary:f,rootBoundary:p,padding:v,altBoundary:g}),D=$i(t.placement),M=Cn(t.placement),U=!M,x=kc(D),O=oy(x),K=t.modifiersData.popperOffsets,B=t.rects.reference,at=t.rects.popper,st=typeof w=="function"?w(Object.assign({},t.rects,{placement:t.placement})):w,J=typeof st=="number"?{mainAxis:st,altAxis:st}:Object.assign({mainAxis:0,altAxis:0},st),kt=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,ft={x:0,y:0};if(K){if(o){var wt,Pt=x==="y"?jr:Kr,F=x==="y"?hi:di,j=x==="y"?"height":"width",bt=K[x],N=bt+C[Pt],G=bt-C[F],Z=A?-at[j]/2:0,gt=M===Rn?B[j]:at[j],vt=M===Rn?-at[j]:-B[j],It=t.elements.arrow,Bt=A&&It?Tc(It):{width:0,height:0},Xt=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:m0(),me=Xt[Pt],be=Xt[F],Ee=Ca(0,B[j],Bt[j]),Ye=U?B[j]/2-Z-Ee-me-J.mainAxis:gt-Ee-me-J.mainAxis,Le=U?-B[j]/2+Z+Ee+be+J.mainAxis:vt+Ee+be+J.mainAxis,Wt=t.elements.arrow&&La(t.elements.arrow),se=Wt?x==="y"?Wt.clientTop||0:Wt.clientLeft||0:0,le=(wt=kt==null?void 0:kt[x])!=null?wt:0,De=bt+Ye-le-se,Nt=bt+Le-le,ne=Ca(A?$o(N,De):N,bt,A?ln(G,Nt):G);K[x]=ne,ft[x]=ne-bt}if(d){var ee,$e=x==="x"?jr:Kr,Me=x==="x"?hi:di,ce=K[O],Ce=O==="y"?"height":"width",ie=ce+C[$e],Ie=ce-C[Me],We=[jr,Kr].indexOf(D)!==-1,Pr=(ee=kt==null?void 0:kt[O])!=null?ee:0,Be=We?ie:ce-B[Ce]-at[Ce]-Pr+J.altAxis,br=We?ce+B[Ce]+at[Ce]-Pr-J.altAxis:Ie,cs=A&&We?Dv(Be,ce,br):Ca(A?Be:ie,ce,A?br:Ie);K[O]=cs,ft[O]=cs-ce}t.modifiersData[r]=ft}}const cy={name:"preventOverflow",enabled:!0,phase:"main",fn:ly,requiresIfExists:["offset"]};function hy(i){return{scrollLeft:i.scrollLeft,scrollTop:i.scrollTop}}function dy(i){return i===si(i)||!ui(i)?wc(i):hy(i)}function uy(i){var t=i.getBoundingClientRect(),e=_n(t.width)/i.offsetWidth||1,r=_n(t.height)/i.offsetHeight||1;return e!==1||r!==1}function fy(i,t,e){e===void 0&&(e=!1);var r=ui(t),n=ui(t)&&uy(t),o=_s(t),l=Ln(i,n,e),d={scrollLeft:0,scrollTop:0},f={x:0,y:0};return(r||!r&&!e)&&((Oi(t)!=="body"||Rc(o))&&(d=dy(t)),ui(t)?(f=Ln(t,!0),f.x+=t.clientLeft,f.y+=t.clientTop):o&&(f.x=Sc(o))),{x:l.left+d.scrollLeft-f.x,y:l.top+d.scrollTop-f.y,width:l.width,height:l.height}}function py(i){var t=new Map,e=new Set,r=[];i.forEach(function(o){t.set(o.name,o)});function n(o){e.add(o.name);var l=[].concat(o.requires||[],o.requiresIfExists||[]);l.forEach(function(d){if(!e.has(d)){var f=t.get(d);f&&n(f)}}),r.push(o)}return i.forEach(function(o){e.has(o.name)||n(o)}),r}function gy(i){var t=py(i);return _v.reduce(function(e,r){return e.concat(t.filter(function(n){return n.phase===r}))},[])}function my(i){var t;return function(){return t||(t=new Promise(function(e){Promise.resolve().then(function(){t=void 0,e(i())})})),t}}function vy(i){var t=i.reduce(function(e,r){var n=e[r.name];return e[r.name]=n?Object.assign({},n,r,{options:Object.assign({},n.options,r.options),data:Object.assign({},n.data,r.data)}):r,e},{});return Object.keys(t).map(function(e){return t[e]})}var R0={placement:"bottom",modifiers:[],strategy:"absolute"};function _0(){for(var i=arguments.length,t=new Array(i),e=0;e<i;e++)t[e]=arguments[e];return!t.some(function(r){return!(r&&typeof r.getBoundingClientRect=="function")})}function yy(i){i===void 0&&(i={});var t=i,e=t.defaultModifiers,r=e===void 0?[]:e,n=t.defaultOptions,o=n===void 0?R0:n;return function(d,f,p){p===void 0&&(p=o);var g={placement:"bottom",orderedModifiers:[],options:Object.assign({},R0,o),modifiersData:{},elements:{reference:d,popper:f},attributes:{},styles:{}},v=[],E=!1,A={state:g,setOptions:function(D){var M=typeof D=="function"?D(g.options):D;w(),g.options=Object.assign({},o,g.options,M),g.scrollParents={reference:on(d)?Ia(d):d.contextElement?Ia(d.contextElement):[],popper:Ia(f)};var U=gy(vy([].concat(r,g.options.modifiers)));return g.orderedModifiers=U.filter(function(x){return x.enabled}),T(),A.update()},forceUpdate:function(){if(!E){var D=g.elements,M=D.reference,U=D.popper;if(_0(M,U)){g.rects={reference:fy(M,La(U),g.options.strategy==="fixed"),popper:Tc(U)},g.reset=!1,g.placement=g.options.placement,g.orderedModifiers.forEach(function(J){return g.modifiersData[J.name]=Object.assign({},J.data)});for(var x=0;x<g.orderedModifiers.length;x++){if(g.reset===!0){g.reset=!1,x=-1;continue}var O=g.orderedModifiers[x],K=O.fn,B=O.options,at=B===void 0?{}:B,st=O.name;typeof K=="function"&&(g=K({state:g,options:at,name:st,instance:A})||g)}}}},update:my(function(){return new Promise(function(C){A.forceUpdate(),C(g)})}),destroy:function(){w(),E=!0}};if(!_0(d,f))return A;A.setOptions(p).then(function(C){!E&&p.onFirstUpdate&&p.onFirstUpdate(C)});function T(){g.orderedModifiers.forEach(function(C){var D=C.name,M=C.options,U=M===void 0?{}:M,x=C.effect;if(typeof x=="function"){var O=x({state:g,name:D,instance:A,options:U}),K=function(){};v.push(O||K)}})}function w(){v.forEach(function(C){return C()}),v=[]}return A}}var by=[Hv,ay,Bv,u0,sy,Jv,cy,Mv,ey],Ey=yy({defaultModifiers:by}),Ay="tippy-box",L0="tippy-content",Ty="tippy-backdrop",C0="tippy-arrow",I0="tippy-svg-arrow",cn={passive:!0,capture:!0},x0=function(){return document.body};function Lc(i,t,e){if(Array.isArray(i)){var r=i[t];return r??(Array.isArray(e)?e[t]:e)}return i}function Cc(i,t){var e={}.toString.call(i);return e.indexOf("[object")===0&&e.indexOf(t+"]")>-1}function D0(i,t){return typeof i=="function"?i.apply(void 0,t):i}function P0(i,t){if(t===0)return i;var e;return function(r){clearTimeout(e),e=setTimeout(function(){i(r)},t)}}function ky(i){return i.split(/\s+/).filter(Boolean)}function In(i){return[].concat(i)}function O0(i,t){i.indexOf(t)===-1&&i.push(t)}function wy(i){return i.filter(function(t,e){return i.indexOf(t)===e})}function Sy(i){return i.split("-")[0]}function Uo(i){return[].slice.call(i)}function $0(i){return Object.keys(i).reduce(function(t,e){return i[e]!==void 0&&(t[e]=i[e]),t},{})}function Da(){return document.createElement("div")}function Bo(i){return["Element","Fragment"].some(function(t){return Cc(i,t)})}function Ry(i){return Cc(i,"NodeList")}function _y(i){return Cc(i,"MouseEvent")}function Ly(i){return!!(i&&i._tippy&&i._tippy.reference===i)}function Cy(i){return Bo(i)?[i]:Ry(i)?Uo(i):Array.isArray(i)?i:Uo(document.querySelectorAll(i))}function Ic(i,t){i.forEach(function(e){e&&(e.style.transitionDuration=t+"ms")})}function M0(i,t){i.forEach(function(e){e&&e.setAttribute("data-state",t)})}function Iy(i){var t,e=In(i),r=e[0];return r!=null&&(t=r.ownerDocument)!=null&&t.body?r.ownerDocument:document}function xy(i,t){var e=t.clientX,r=t.clientY;return i.every(function(n){var o=n.popperRect,l=n.popperState,d=n.props,f=d.interactiveBorder,p=Sy(l.placement),g=l.modifiersData.offset;if(!g)return!0;var v=p==="bottom"?g.top.y:0,E=p==="top"?g.bottom.y:0,A=p==="right"?g.left.x:0,T=p==="left"?g.right.x:0,w=o.top-r+v>f,C=r-o.bottom-E>f,D=o.left-e+A>f,M=e-o.right-T>f;return w||C||D||M})}function xc(i,t,e){var r=t+"EventListener";["transitionend","webkitTransitionEnd"].forEach(function(n){i[r](n,e)})}function N0(i,t){for(var e=t;e;){var r;if(i.contains(e))return!0;e=e.getRootNode==null||(r=e.getRootNode())==null?void 0:r.host}return!1}var Mi={isTouch:!1},F0=0;function Dy(){Mi.isTouch||(Mi.isTouch=!0,window.performance&&document.addEventListener("mousemove",U0))}function U0(){var i=performance.now();i-F0<20&&(Mi.isTouch=!1,document.removeEventListener("mousemove",U0)),F0=i}function Py(){var i=document.activeElement;if(Ly(i)){var t=i._tippy;i.blur&&!t.state.isVisible&&i.blur()}}function Oy(){document.addEventListener("touchstart",Dy,cn),window.addEventListener("blur",Py)}var $y=typeof window<"u"&&typeof document<"u",My=$y?!!window.msCrypto:!1,Ny={animateFill:!1,followCursor:!1,inlinePositioning:!1,sticky:!1},Fy={allowHTML:!1,animation:"fade",arrow:!0,content:"",inertia:!1,maxWidth:350,role:"tooltip",theme:"",zIndex:9999},ki=Object.assign({appendTo:x0,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},Ny,Fy),Uy=Object.keys(ki),By=function(t){var e=Object.keys(t);e.forEach(function(r){ki[r]=t[r]})};function B0(i){var t=i.plugins||[],e=t.reduce(function(r,n){var o=n.name,l=n.defaultValue;if(o){var d;r[o]=i[o]!==void 0?i[o]:(d=ki[o])!=null?d:l}return r},{});return Object.assign({},i,e)}function Gy(i,t){var e=t?Object.keys(B0(Object.assign({},ki,{plugins:t}))):Uy,r=e.reduce(function(n,o){var l=(i.getAttribute("data-tippy-"+o)||"").trim();if(!l)return n;if(o==="content")n[o]=l;else try{n[o]=JSON.parse(l)}catch{n[o]=l}return n},{});return r}function G0(i,t){var e=Object.assign({},t,{content:D0(t.content,[i])},t.ignoreAttributes?{}:Gy(i,t.plugins));return e.aria=Object.assign({},ki.aria,e.aria),e.aria={expanded:e.aria.expanded==="auto"?t.interactive:e.aria.expanded,content:e.aria.content==="auto"?t.interactive?null:"describedby":e.aria.content},e}var Hy=function(){return"innerHTML"};function Dc(i,t){i[Hy()]=t}function H0(i){var t=Da();return i===!0?t.className=C0:(t.className=I0,Bo(i)?t.appendChild(i):Dc(t,i)),t}function V0(i,t){Bo(t.content)?(Dc(i,""),i.appendChild(t.content)):typeof t.content!="function"&&(t.allowHTML?Dc(i,t.content):i.textContent=t.content)}function Pc(i){var t=i.firstElementChild,e=Uo(t.children);return{box:t,content:e.find(function(r){return r.classList.contains(L0)}),arrow:e.find(function(r){return r.classList.contains(C0)||r.classList.contains(I0)}),backdrop:e.find(function(r){return r.classList.contains(Ty)})}}function W0(i){var t=Da(),e=Da();e.className=Ay,e.setAttribute("data-state","hidden"),e.setAttribute("tabindex","-1");var r=Da();r.className=L0,r.setAttribute("data-state","hidden"),V0(r,i.props),t.appendChild(e),e.appendChild(r),n(i.props,i.props);function n(o,l){var d=Pc(t),f=d.box,p=d.content,g=d.arrow;l.theme?f.setAttribute("data-theme",l.theme):f.removeAttribute("data-theme"),typeof l.animation=="string"?f.setAttribute("data-animation",l.animation):f.removeAttribute("data-animation"),l.inertia?f.setAttribute("data-inertia",""):f.removeAttribute("data-inertia"),f.style.maxWidth=typeof l.maxWidth=="number"?l.maxWidth+"px":l.maxWidth,l.role?f.setAttribute("role",l.role):f.removeAttribute("role"),(o.content!==l.content||o.allowHTML!==l.allowHTML)&&V0(p,i.props),l.arrow?g?o.arrow!==l.arrow&&(f.removeChild(g),f.appendChild(H0(l.arrow))):f.appendChild(H0(l.arrow)):g&&f.removeChild(g)}return{popper:t,onUpdate:n}}W0.$$tippy=!0;var Vy=1,Go=[],Oc=[];function Wy(i,t){var e=G0(i,Object.assign({},ki,B0($0(t)))),r,n,o,l=!1,d=!1,f=!1,p=!1,g,v,E,A=[],T=P0(De,e.interactiveDebounce),w,C=Vy++,D=null,M=wy(e.plugins),U={isEnabled:!0,isVisible:!1,isDestroyed:!1,isMounted:!1,isShown:!1},x={id:C,reference:i,popper:Da(),popperInstance:D,props:e,state:U,plugins:M,clearDelayTimeouts:Be,setProps:br,setContent:cs,show:fr,hide:_i,hideWithInteractivity:Os,enable:We,disable:Pr,unmount:$s,destroy:ai};if(!e.render)return x;var O=e.render(x),K=O.popper,B=O.onUpdate;K.setAttribute("data-tippy-root",""),K.id="tippy-"+x.id,x.popper=K,i._tippy=x,K._tippy=x;var at=M.map(function(ct){return ct.fn(x)}),st=i.hasAttribute("aria-expanded");return Wt(),Z(),bt(),N("onCreate",[x]),e.showOnCreate&&ie(),K.addEventListener("mouseenter",function(){x.props.interactive&&x.state.isVisible&&x.clearDelayTimeouts()}),K.addEventListener("mouseleave",function(){x.props.interactive&&x.props.trigger.indexOf("mouseenter")>=0&&Pt().addEventListener("mousemove",T)}),x;function J(){var ct=x.props.touch;return Array.isArray(ct)?ct:[ct,0]}function kt(){return J()[0]==="hold"}function ft(){var ct;return!!((ct=x.props.render)!=null&&ct.$$tippy)}function wt(){return w||i}function Pt(){var ct=wt().parentNode;return ct?Iy(ct):document}function F(){return Pc(K)}function j(ct){return x.state.isMounted&&!x.state.isVisible||Mi.isTouch||g&&g.type==="focus"?0:Lc(x.props.delay,ct?0:1,ki.delay)}function bt(ct){ct===void 0&&(ct=!1),K.style.pointerEvents=x.props.interactive&&!ct?"":"none",K.style.zIndex=""+x.props.zIndex}function N(ct,Ht,Zt){if(Zt===void 0&&(Zt=!0),at.forEach(function(de){de[ct]&&de[ct].apply(de,Ht)}),Zt){var Ae;(Ae=x.props)[ct].apply(Ae,Ht)}}function G(){var ct=x.props.aria;if(ct.content){var Ht="aria-"+ct.content,Zt=K.id,Ae=In(x.props.triggerTarget||i);Ae.forEach(function(de){var lr=de.getAttribute(Ht);if(x.state.isVisible)de.setAttribute(Ht,lr?lr+" "+Zt:Zt);else{var Or=lr&&lr.replace(Zt,"").trim();Or?de.setAttribute(Ht,Or):de.removeAttribute(Ht)}})}}function Z(){if(!(st||!x.props.aria.expanded)){var ct=In(x.props.triggerTarget||i);ct.forEach(function(Ht){x.props.interactive?Ht.setAttribute("aria-expanded",x.state.isVisible&&Ht===wt()?"true":"false"):Ht.removeAttribute("aria-expanded")})}}function gt(){Pt().removeEventListener("mousemove",T),Go=Go.filter(function(ct){return ct!==T})}function vt(ct){if(!(Mi.isTouch&&(f||ct.type==="mousedown"))){var Ht=ct.composedPath&&ct.composedPath()[0]||ct.target;if(!(x.props.interactive&&N0(K,Ht))){if(In(x.props.triggerTarget||i).some(function(Zt){return N0(Zt,Ht)})){if(Mi.isTouch||x.state.isVisible&&x.props.trigger.indexOf("click")>=0)return}else N("onClickOutside",[x,ct]);x.props.hideOnClick===!0&&(x.clearDelayTimeouts(),x.hide(),d=!0,setTimeout(function(){d=!1}),x.state.isMounted||me())}}}function It(){f=!0}function Bt(){f=!1}function Xt(){var ct=Pt();ct.addEventListener("mousedown",vt,!0),ct.addEventListener("touchend",vt,cn),ct.addEventListener("touchstart",Bt,cn),ct.addEventListener("touchmove",It,cn)}function me(){var ct=Pt();ct.removeEventListener("mousedown",vt,!0),ct.removeEventListener("touchend",vt,cn),ct.removeEventListener("touchstart",Bt,cn),ct.removeEventListener("touchmove",It,cn)}function be(ct,Ht){Ye(ct,function(){!x.state.isVisible&&K.parentNode&&K.parentNode.contains(K)&&Ht()})}function Ee(ct,Ht){Ye(ct,Ht)}function Ye(ct,Ht){var Zt=F().box;function Ae(de){de.target===Zt&&(xc(Zt,"remove",Ae),Ht())}if(ct===0)return Ht();xc(Zt,"remove",v),xc(Zt,"add",Ae),v=Ae}function Le(ct,Ht,Zt){Zt===void 0&&(Zt=!1);var Ae=In(x.props.triggerTarget||i);Ae.forEach(function(de){de.addEventListener(ct,Ht,Zt),A.push({node:de,eventType:ct,handler:Ht,options:Zt})})}function Wt(){kt()&&(Le("touchstart",le,{passive:!0}),Le("touchend",Nt,{passive:!0})),ky(x.props.trigger).forEach(function(ct){if(ct!=="manual")switch(Le(ct,le),ct){case"mouseenter":Le("mouseleave",Nt);break;case"focus":Le(My?"focusout":"blur",ne);break;case"focusin":Le("focusout",ne);break}})}function se(){A.forEach(function(ct){var Ht=ct.node,Zt=ct.eventType,Ae=ct.handler,de=ct.options;Ht.removeEventListener(Zt,Ae,de)}),A=[]}function le(ct){var Ht,Zt=!1;if(!(!x.state.isEnabled||ee(ct)||d)){var Ae=((Ht=g)==null?void 0:Ht.type)==="focus";g=ct,w=ct.currentTarget,Z(),!x.state.isVisible&&_y(ct)&&Go.forEach(function(de){return de(ct)}),ct.type==="click"&&(x.props.trigger.indexOf("mouseenter")<0||l)&&x.props.hideOnClick!==!1&&x.state.isVisible?Zt=!0:ie(ct),ct.type==="click"&&(l=!Zt),Zt&&!Ae&&Ie(ct)}}function De(ct){var Ht=ct.target,Zt=wt().contains(Ht)||K.contains(Ht);if(!(ct.type==="mousemove"&&Zt)){var Ae=Ce().concat(K).map(function(de){var lr,Or=de._tippy,vi=(lr=Or.popperInstance)==null?void 0:lr.state;return vi?{popperRect:de.getBoundingClientRect(),popperState:vi,props:e}:null}).filter(Boolean);xy(Ae,ct)&&(gt(),Ie(ct))}}function Nt(ct){var Ht=ee(ct)||x.props.trigger.indexOf("click")>=0&&l;if(!Ht){if(x.props.interactive){x.hideWithInteractivity(ct);return}Ie(ct)}}function ne(ct){x.props.trigger.indexOf("focusin")<0&&ct.target!==wt()||x.props.interactive&&ct.relatedTarget&&K.contains(ct.relatedTarget)||Ie(ct)}function ee(ct){return Mi.isTouch?kt()!==ct.type.indexOf("touch")>=0:!1}function $e(){Me();var ct=x.props,Ht=ct.popperOptions,Zt=ct.placement,Ae=ct.offset,de=ct.getReferenceClientRect,lr=ct.moveTransition,Or=ft()?Pc(K).arrow:null,vi=de?{getBoundingClientRect:de,contextElement:de.contextElement||wt()}:i,hs={name:"$$tippy",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(Ms){var $r=Ms.state;if(ft()){var ja=F(),Ei=ja.box;["placement","reference-hidden","escaped"].forEach(function(Ns){Ns==="placement"?Ei.setAttribute("data-placement",$r.placement):$r.attributes.popper["data-popper-"+Ns]?Ei.setAttribute("data-"+Ns,""):Ei.removeAttribute("data-"+Ns)}),$r.attributes.popper={}}}},yi=[{name:"offset",options:{offset:Ae}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!lr}},hs];ft()&&Or&&yi.push({name:"arrow",options:{element:Or,padding:3}}),yi.push.apply(yi,(Ht==null?void 0:Ht.modifiers)||[]),x.popperInstance=Ey(vi,K,Object.assign({},Ht,{placement:Zt,onFirstUpdate:E,modifiers:yi}))}function Me(){x.popperInstance&&(x.popperInstance.destroy(),x.popperInstance=null)}function ce(){var ct=x.props.appendTo,Ht,Zt=wt();x.props.interactive&&ct===x0||ct==="parent"?Ht=Zt.parentNode:Ht=D0(ct,[Zt]),Ht.contains(K)||Ht.appendChild(K),x.state.isMounted=!0,$e()}function Ce(){return Uo(K.querySelectorAll("[data-tippy-root]"))}function ie(ct){x.clearDelayTimeouts(),ct&&N("onTrigger",[x,ct]),Xt();var Ht=j(!0),Zt=J(),Ae=Zt[0],de=Zt[1];Mi.isTouch&&Ae==="hold"&&de&&(Ht=de),Ht?r=setTimeout(function(){x.show()},Ht):x.show()}function Ie(ct){if(x.clearDelayTimeouts(),N("onUntrigger",[x,ct]),!x.state.isVisible){me();return}if(!(x.props.trigger.indexOf("mouseenter")>=0&&x.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(ct.type)>=0&&l)){var Ht=j(!1);Ht?n=setTimeout(function(){x.state.isVisible&&x.hide()},Ht):o=requestAnimationFrame(function(){x.hide()})}}function We(){x.state.isEnabled=!0}function Pr(){x.hide(),x.state.isEnabled=!1}function Be(){clearTimeout(r),clearTimeout(n),cancelAnimationFrame(o)}function br(ct){if(!x.state.isDestroyed){N("onBeforeUpdate",[x,ct]),se();var Ht=x.props,Zt=G0(i,Object.assign({},Ht,$0(ct),{ignoreAttributes:!0}));x.props=Zt,Wt(),Ht.interactiveDebounce!==Zt.interactiveDebounce&&(gt(),T=P0(De,Zt.interactiveDebounce)),Ht.triggerTarget&&!Zt.triggerTarget?In(Ht.triggerTarget).forEach(function(Ae){Ae.removeAttribute("aria-expanded")}):Zt.triggerTarget&&i.removeAttribute("aria-expanded"),Z(),bt(),B&&B(Ht,Zt),x.popperInstance&&($e(),Ce().forEach(function(Ae){requestAnimationFrame(Ae._tippy.popperInstance.forceUpdate)})),N("onAfterUpdate",[x,ct])}}function cs(ct){x.setProps({content:ct})}function fr(){var ct=x.state.isVisible,Ht=x.state.isDestroyed,Zt=!x.state.isEnabled,Ae=Mi.isTouch&&!x.props.touch,de=Lc(x.props.duration,0,ki.duration);if(!(ct||Ht||Zt||Ae)&&!wt().hasAttribute("disabled")&&(N("onShow",[x],!1),x.props.onShow(x)!==!1)){if(x.state.isVisible=!0,ft()&&(K.style.visibility="visible"),bt(),Xt(),x.state.isMounted||(K.style.transition="none"),ft()){var lr=F(),Or=lr.box,vi=lr.content;Ic([Or,vi],0)}E=function(){var yi;if(!(!x.state.isVisible||p)){if(p=!0,K.offsetHeight,K.style.transition=x.props.moveTransition,ft()&&x.props.animation){var bi=F(),Ms=bi.box,$r=bi.content;Ic([Ms,$r],de),M0([Ms,$r],"visible")}G(),Z(),O0(Oc,x),(yi=x.popperInstance)==null||yi.forceUpdate(),N("onMount",[x]),x.props.animation&&ft()&&Ee(de,function(){x.state.isShown=!0,N("onShown",[x])})}},ce()}}function _i(){var ct=!x.state.isVisible,Ht=x.state.isDestroyed,Zt=!x.state.isEnabled,Ae=Lc(x.props.duration,1,ki.duration);if(!(ct||Ht||Zt)&&(N("onHide",[x],!1),x.props.onHide(x)!==!1)){if(x.state.isVisible=!1,x.state.isShown=!1,p=!1,l=!1,ft()&&(K.style.visibility="hidden"),gt(),me(),bt(!0),ft()){var de=F(),lr=de.box,Or=de.content;x.props.animation&&(Ic([lr,Or],Ae),M0([lr,Or],"hidden"))}G(),Z(),x.props.animation?ft()&&be(Ae,x.unmount):x.unmount()}}function Os(ct){Pt().addEventListener("mousemove",T),O0(Go,T),T(ct)}function $s(){x.state.isVisible&&x.hide(),x.state.isMounted&&(Me(),Ce().forEach(function(ct){ct._tippy.unmount()}),K.parentNode&&K.parentNode.removeChild(K),Oc=Oc.filter(function(ct){return ct!==x}),x.state.isMounted=!1,N("onHidden",[x]))}function ai(){x.state.isDestroyed||(x.clearDelayTimeouts(),x.unmount(),se(),delete i._tippy,x.state.isDestroyed=!0,N("onDestroy",[x]))}}function hn(i,t){t===void 0&&(t={});var e=ki.plugins.concat(t.plugins||[]);Oy();var r=Object.assign({},t,{plugins:e}),n=Cy(i),o=n.reduce(function(l,d){var f=d&&Wy(d,r);return f&&l.push(f),l},[]);return Bo(i)?o[0]:o}hn.defaultProps=ki,hn.setDefaultProps=By,hn.currentInput=Mi,Object.assign({},u0,{effect:function(t){var e=t.state,r={popper:{position:e.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};Object.assign(e.elements.popper.style,r.popper),e.styles=r,e.elements.arrow&&Object.assign(e.elements.arrow.style,r.arrow)}}),hn.setDefaultProps({render:W0});class Ni extends Error{constructor(t,e=new Error,r=!1){super(),this.fatal=!1,this.fatal=r,this.stack=e.stack,this.message=[t,e.message].filter(Boolean).join(" - ")}}const jy=5;class Ky{constructor(t){this._caption="",this._currentTime=0,this._activeScenes=[],this._upcomingScenes=[],this._canvas=wr(),this._controls=wr(),this.host=t}set activeScenes(t){if(t!==this._activeScenes){const e=t[0],r=this._activeScenes[0];this._activeScenes=t,e!==r&&(this.host.dispatchEvent(new CustomEvent("scenechange",{detail:t[0]})),this.host.requestUpdate())}}get activeScenes(){return this._activeScenes}set currentTime(t){var e,r,n,o,l;const d=Math.min(this.host.duration,Math.max(0,t));this._currentTime=d,this.activeScenes=((e=this.host.scenes)==null?void 0:e.filter(({start:g,duration:v})=>d>=g&&d<g+v))??[],this._upcomingScenes=((r=this.host.scenes)==null?void 0:r.filter(({start:g})=>d>=g-jy&&d<g))??[],this.loadScenes(),this.syncVideoState(),(n=this._controls.value)==null||n.setAttribute("currentTime",d.toString());const f=this.activeScenes[0],p=t0((o=f==null?void 0:f.videoMeta)==null?void 0:o.captions);this.caption=((l=p.find(({start:g,end:v})=>{var E;const A=d-f.start+(((E=f.videoMeta)==null?void 0:E.start)??0);return g&&v&&A>=Do(g)&&A<=Do(v)}))==null?void 0:l.text)??"",this.draw(d),!this.host.paused&&!this.host.loading&&!this.host.processing&&!this.host.waiting&&this.host.dispatchEvent(new CustomEvent("timeupdate",{detail:d}))}get currentTime(){return this._currentTime}set caption(t){t!==this._caption&&(this._caption=t,this.host.requestUpdate())}get caption(){return this._caption}canvas(){return Sr(this._canvas)}controls(){return Sr(this._controls)}loadScenes(){[...this.activeScenes,...this._upcomingScenes].forEach(t=>{var e,r,n;const{start:o,duration:l,video:d,videoMeta:f}=t,p=this.host.currentTime>0||this.host.preload==="auto"||!this.host.paused;if(d&&f){const{key:g,hls:v,node:E}=d,{start:A,duration:T}=f,w=this.host.videoState[g];E&&w&&(E.currentTime>=A+T||E.ended||p&&(v?(e=v.startLoadOnce)==null||e.call(v,E.currentTime):w.initialised||(r=E.startLoadOnce)==null||r.call(E)))}else if(p){const g=`${o}-${l}`,v=this.host._sceneController.videoState[g];this.host.duration&&!((n=v==null?void 0:v.buffered)!=null&&n.length)&&(this.host._sceneController.videoState={...this.host._sceneController.videoState,[g]:{...v,buffered:[{start:Math.max(0,o/this.host.duration*100),end:Math.min((o+l)/this.host.duration*100,100)}]}})}})}syncVideoState(){var t;(t=this.host.scenes)==null||t.forEach(e=>{if(e.video){const{key:r,node:n}=e.video,o=this.host.videoState[r],l=this.activeScenes.includes(e);if(n&&o)if(l&&!this.host.waiting&&!this.host.loading&&!this.host.paused){if(n.paused&&o.initialised)try{return n.play()}catch(d){throw new Ni("Video play error",d,!0)}}else n.paused||n.pause()}})}draw(t=this.currentTime){var e,r;this.host.sceneConfig&&this._canvas.value&&((r=(e=this.host).compilation)==null||r.call(e,{currentTime:t,scenes:this.host.sceneConfig,canvas:this._canvas.value}))}clear(){var t;const e=this._canvas.value;(t=e==null?void 0:e.getContext("2d"))==null||t.clearRect(0,0,e.width,e.height)}}function zy(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var j0={exports:{}};(function(i,t){(function(e){var r=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,n=/^(?=([^\/?#]*))\1([^]*)$/,o=/(?:\/|^)\.(?=\/)/g,l=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,d={buildAbsoluteURL:function(f,p,g){if(g=g||{},f=f.trim(),p=p.trim(),!p){if(!g.alwaysNormalize)return f;var v=d.parseURL(f);if(!v)throw new Error("Error trying to parse base URL.");return v.path=d.normalizePath(v.path),d.buildURLFromParts(v)}var E=d.parseURL(p);if(!E)throw new Error("Error trying to parse relative URL.");if(E.scheme)return g.alwaysNormalize?(E.path=d.normalizePath(E.path),d.buildURLFromParts(E)):p;var A=d.parseURL(f);if(!A)throw new Error("Error trying to parse base URL.");if(!A.netLoc&&A.path&&A.path[0]!=="/"){var T=n.exec(A.path);A.netLoc=T[1],A.path=T[2]}A.netLoc&&!A.path&&(A.path="/");var w={scheme:A.scheme,netLoc:E.netLoc,path:null,params:E.params,query:E.query,fragment:E.fragment};if(!E.netLoc&&(w.netLoc=A.netLoc,E.path[0]!=="/"))if(!E.path)w.path=A.path,E.params||(w.params=A.params,E.query||(w.query=A.query));else{var C=A.path,D=C.substring(0,C.lastIndexOf("/")+1)+E.path;w.path=d.normalizePath(D)}return w.path===null&&(w.path=g.alwaysNormalize?d.normalizePath(E.path):E.path),d.buildURLFromParts(w)},parseURL:function(f){var p=r.exec(f);return p?{scheme:p[1]||"",netLoc:p[2]||"",path:p[3]||"",params:p[4]||"",query:p[5]||"",fragment:p[6]||""}:null},normalizePath:function(f){for(f=f.split("").reverse().join("").replace(o,"");f.length!==(f=f.replace(l,"")).length;);return f.split("").reverse().join("")},buildURLFromParts:function(f){return f.scheme+f.netLoc+f.path+f.params+f.query+f.fragment}};i.exports=d})()})(j0);var $c=j0.exports;function K0(i,t){var e=Object.keys(i);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(i);t&&(r=r.filter(function(n){return Object.getOwnPropertyDescriptor(i,n).enumerable})),e.push.apply(e,r)}return e}function zr(i){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?K0(Object(e),!0).forEach(function(r){Yy(i,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(e)):K0(Object(e)).forEach(function(r){Object.defineProperty(i,r,Object.getOwnPropertyDescriptor(e,r))})}return i}function Yy(i,t,e){return t=Zy(t),t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}function dr(){return dr=Object.assign?Object.assign.bind():function(i){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(i[r]=e[r])}return i},dr.apply(this,arguments)}function Xy(i,t){if(typeof i!="object"||i===null)return i;var e=i[Symbol.toPrimitive];if(e!==void 0){var r=e.call(i,t||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(i)}function Zy(i){var t=Xy(i,"string");return typeof t=="symbol"?t:String(t)}const jt=Number.isFinite||function(i){return typeof i=="number"&&isFinite(i)};let R=function(i){return i.MEDIA_ATTACHING="hlsMediaAttaching",i.MEDIA_ATTACHED="hlsMediaAttached",i.MEDIA_DETACHING="hlsMediaDetaching",i.MEDIA_DETACHED="hlsMediaDetached",i.BUFFER_RESET="hlsBufferReset",i.BUFFER_CODECS="hlsBufferCodecs",i.BUFFER_CREATED="hlsBufferCreated",i.BUFFER_APPENDING="hlsBufferAppending",i.BUFFER_APPENDED="hlsBufferAppended",i.BUFFER_EOS="hlsBufferEos",i.BUFFER_FLUSHING="hlsBufferFlushing",i.BUFFER_FLUSHED="hlsBufferFlushed",i.MANIFEST_LOADING="hlsManifestLoading",i.MANIFEST_LOADED="hlsManifestLoaded",i.MANIFEST_PARSED="hlsManifestParsed",i.LEVEL_SWITCHING="hlsLevelSwitching",i.LEVEL_SWITCHED="hlsLevelSwitched",i.LEVEL_LOADING="hlsLevelLoading",i.LEVEL_LOADED="hlsLevelLoaded",i.LEVEL_UPDATED="hlsLevelUpdated",i.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",i.LEVELS_UPDATED="hlsLevelsUpdated",i.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",i.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",i.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",i.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",i.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",i.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",i.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",i.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",i.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",i.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",i.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",i.CUES_PARSED="hlsCuesParsed",i.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",i.INIT_PTS_FOUND="hlsInitPtsFound",i.FRAG_LOADING="hlsFragLoading",i.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",i.FRAG_LOADED="hlsFragLoaded",i.FRAG_DECRYPTED="hlsFragDecrypted",i.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",i.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",i.FRAG_PARSING_METADATA="hlsFragParsingMetadata",i.FRAG_PARSED="hlsFragParsed",i.FRAG_BUFFERED="hlsFragBuffered",i.FRAG_CHANGED="hlsFragChanged",i.FPS_DROP="hlsFpsDrop",i.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",i.ERROR="hlsError",i.DESTROYING="hlsDestroying",i.KEY_LOADING="hlsKeyLoading",i.KEY_LOADED="hlsKeyLoaded",i.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",i.BACK_BUFFER_REACHED="hlsBackBufferReached",i}({}),Qt=function(i){return i.NETWORK_ERROR="networkError",i.MEDIA_ERROR="mediaError",i.KEY_SYSTEM_ERROR="keySystemError",i.MUX_ERROR="muxError",i.OTHER_ERROR="otherError",i}({}),ut=function(i){return i.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",i.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",i.KEY_SYSTEM_NO_SESSION="keySystemNoSession",i.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",i.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",i.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",i.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",i.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",i.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",i.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",i.MANIFEST_LOAD_ERROR="manifestLoadError",i.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",i.MANIFEST_PARSING_ERROR="manifestParsingError",i.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",i.LEVEL_EMPTY_ERROR="levelEmptyError",i.LEVEL_LOAD_ERROR="levelLoadError",i.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",i.LEVEL_PARSING_ERROR="levelParsingError",i.LEVEL_SWITCH_ERROR="levelSwitchError",i.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",i.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",i.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",i.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",i.FRAG_LOAD_ERROR="fragLoadError",i.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",i.FRAG_DECRYPT_ERROR="fragDecryptError",i.FRAG_PARSING_ERROR="fragParsingError",i.FRAG_GAP="fragGap",i.REMUX_ALLOC_ERROR="remuxAllocError",i.KEY_LOAD_ERROR="keyLoadError",i.KEY_LOAD_TIMEOUT="keyLoadTimeOut",i.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",i.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",i.BUFFER_APPEND_ERROR="bufferAppendError",i.BUFFER_APPENDING_ERROR="bufferAppendingError",i.BUFFER_STALLED_ERROR="bufferStalledError",i.BUFFER_FULL_ERROR="bufferFullError",i.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",i.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",i.INTERNAL_EXCEPTION="internalException",i.INTERNAL_ABORTED="aborted",i.UNKNOWN="unknown",i}({});const dn=function(){},Mc={trace:dn,debug:dn,log:dn,warn:dn,info:dn,error:dn};let Pa=Mc;function qy(i){const t=self.console[i];return t?t.bind(self.console,`[${i}] >`):dn}function Qy(i,...t){t.forEach(function(e){Pa[e]=i[e]?i[e].bind(i):qy(e)})}function Jy(i,t){if(self.console&&i===!0||typeof i=="object"){Qy(i,"debug","log","info","warn","error");try{Pa.log(`Debug logs enabled for "${t}" in hls.js version 1.4.12`)}catch{Pa=Mc}}else Pa=Mc}const X=Pa,tb=/^(\d+)x(\d+)$/,z0=/(.+?)=(".*?"|.*?)(?:,|$)/g;class tr{constructor(t){typeof t=="string"&&(t=tr.parseAttrList(t));for(const e in t)t.hasOwnProperty(e)&&(e.substring(0,2)==="X-"&&(this.clientAttrs=this.clientAttrs||[],this.clientAttrs.push(e)),this[e]=t[e])}decimalInteger(t){const e=parseInt(this[t],10);return e>Number.MAX_SAFE_INTEGER?1/0:e}hexadecimalInteger(t){if(this[t]){let e=(this[t]||"0x").slice(2);e=(e.length&1?"0":"")+e;const r=new Uint8Array(e.length/2);for(let n=0;n<e.length/2;n++)r[n]=parseInt(e.slice(n*2,n*2+2),16);return r}else return null}hexadecimalIntegerAsNumber(t){const e=parseInt(this[t],16);return e>Number.MAX_SAFE_INTEGER?1/0:e}decimalFloatingPoint(t){return parseFloat(this[t])}optionalFloat(t,e){const r=this[t];return r?parseFloat(r):e}enumeratedString(t){return this[t]}bool(t){return this[t]==="YES"}decimalResolution(t){const e=tb.exec(this[t]);if(e!==null)return{width:parseInt(e[1],10),height:parseInt(e[2],10)}}static parseAttrList(t){let e;const r={},n='"';for(z0.lastIndex=0;(e=z0.exec(t))!==null;){let o=e[2];o.indexOf(n)===0&&o.lastIndexOf(n)===o.length-1&&(o=o.slice(1,-1));const l=e[1].trim();r[l]=o}return r}}function eb(i){return i!=="ID"&&i!=="CLASS"&&i!=="START-DATE"&&i!=="DURATION"&&i!=="END-DATE"&&i!=="END-ON-NEXT"}function rb(i){return i==="SCTE35-OUT"||i==="SCTE35-IN"}class Y0{constructor(t,e){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,e){const r=e.attr;for(const n in r)if(Object.prototype.hasOwnProperty.call(t,n)&&t[n]!==r[n]){X.warn(`DATERANGE tag attribute: "${n}" does not match for tags with ID: "${t.ID}"`),this._badValueForSameId=n;break}t=dr(new tr({}),r,t)}if(this.attr=t,this._startDate=new Date(t["START-DATE"]),"END-DATE"in this.attr){const r=new Date(this.attr["END-DATE"]);jt(r.getTime())&&(this._endDate=r)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get startDate(){return this._startDate}get endDate(){if(this._endDate)return this._endDate;const t=this.duration;return t!==null?new Date(this._startDate.getTime()+t*1e3):null}get duration(){if("DURATION"in this.attr){const t=this.attr.decimalFloatingPoint("DURATION");if(jt(t))return t}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isValid(){return!!this.id&&!this._badValueForSameId&&jt(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}class Ho{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 Oe={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"};class X0{constructor(t){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[Oe.AUDIO]:null,[Oe.VIDEO]:null,[Oe.AUDIOVIDEO]:null},this.baseurl=t}setByteRange(t,e){const r=t.split("@",2),n=[];r.length===1?n[0]=e?e.byteRangeEndOffset:0:n[0]=parseInt(r[1]),n[1]=parseInt(r[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=$c.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(t){this._url=t}}class Nc extends X0{constructor(t,e){super(e),this._decryptdata=null,this.rawProgramDateTime=null,this.programDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.stats=new Ho,this.urlId=0,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.type=t}get decryptdata(){const{levelkeys:t}=this;if(!t&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){const e=this.levelkeys.identity;if(e)this._decryptdata=e.getDecryptData(this.sn);else{const r=Object.keys(this.levelkeys);if(r.length===1)return this._decryptdata=this.levelkeys[r[0]].getDecryptData(this.sn)}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(this.programDateTime===null||!jt(this.programDateTime))return null;const t=jt(this.duration)?this.duration:0;return this.programDateTime+t*1e3}get encrypted(){var t;if((t=this._decryptdata)!=null&&t.encrypted)return!0;if(this.levelkeys){const e=Object.keys(this.levelkeys),r=e.length;if(r>1||r===1&&this.levelkeys[e[0]].encrypted)return!0}return!1}setKeyFormat(t){if(this.levelkeys){const e=this.levelkeys[t];e&&!this._decryptdata&&(this._decryptdata=e.getDecryptData(this.sn))}}abortRequests(){var t,e;(t=this.loader)==null||t.abort(),(e=this.keyLoader)==null||e.abort()}setElementaryStreamInfo(t,e,r,n,o,l=!1){const{elementaryStreams:d}=this,f=d[t];if(!f){d[t]={startPTS:e,endPTS:r,startDTS:n,endDTS:o,partial:l};return}f.startPTS=Math.min(f.startPTS,e),f.endPTS=Math.max(f.endPTS,r),f.startDTS=Math.min(f.startDTS,n),f.endDTS=Math.max(f.endDTS,o)}clearElementaryStreamInfo(){const{elementaryStreams:t}=this;t[Oe.AUDIO]=null,t[Oe.VIDEO]=null,t[Oe.AUDIOVIDEO]=null}}class ib extends X0{constructor(t,e,r,n,o){super(r),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 Ho,this.duration=t.decimalFloatingPoint("DURATION"),this.gap=t.bool("GAP"),this.independent=t.bool("INDEPENDENT"),this.relurl=t.enumeratedString("URI"),this.fragment=e,this.index=n;const l=t.enumeratedString("BYTERANGE");l&&this.setByteRange(l,o),o&&(this.fragOffset=o.fragOffset+o.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){const{elementaryStreams:t}=this;return!!(t.audio||t.video||t.audiovideo)}}const sb=10;class nb{constructor(t){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=t}reloaded(t){if(!t){this.advanced=!0,this.updated=!0;return}const e=this.lastPartSn-t.lastPartSn,r=this.lastPartIndex-t.lastPartIndex;this.updated=this.endSN!==t.endSN||!!r||!!e||!this.live,this.advanced=this.endSN>t.endSN||e>0||e===0&&r>0,this.updated||this.advanced?this.misses=Math.floor(t.misses*.6):this.misses=t.misses+1,this.availabilityDelay=t.availabilityDelay}get hasProgramDateTime(){return this.fragments.length?jt(this.fragments[this.fragments.length-1].programDateTime):!1}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||sb}get drift(){const t=this.driftEndTime-this.driftStartTime;return t>0?(this.driftEnd-this.driftStart)*1e3/t:1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var t;return(t=this.partList)!=null&&t.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){var t;return(t=this.fragments)!=null&&t.length?this.fragments[this.fragments.length-1].end:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var t;return(t=this.partList)!=null&&t.length?this.partList[this.partList.length-1].index:-1}get lastPartSn(){var t;return(t=this.partList)!=null&&t.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}function Fc(i){return Uint8Array.from(atob(i),t=>t.charCodeAt(0))}function ab(i){const t=Z0(i).subarray(0,16),e=new Uint8Array(16);return e.set(t,16-t.length),e}function ob(i){const t=function(e,r,n){const o=e[r];e[r]=e[n],e[n]=o};t(i,0,3),t(i,1,2),t(i,4,5),t(i,6,7)}function lb(i){const t=i.split(":");let e=null;if(t[0]==="data"&&t.length===2){const r=t[1].split(";"),n=r[r.length-1].split(",");if(n.length===2){const o=n[0]==="base64",l=n[1];o?(r.splice(-1,1),e=Fc(l)):e=ab(l)}}return e}function Z0(i){return Uint8Array.from(unescape(encodeURIComponent(i)),t=>t.charCodeAt(0))}var er={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},Yr={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function q0(i){switch(i){case Yr.FAIRPLAY:return er.FAIRPLAY;case Yr.PLAYREADY:return er.PLAYREADY;case Yr.WIDEVINE:return er.WIDEVINE;case Yr.CLEARKEY:return er.CLEARKEY}}var Q0={WIDEVINE:"edef8ba979d64acea3c827dcd51d21ed"};function cb(i){if(i===Q0.WIDEVINE)return er.WIDEVINE}function J0(i){switch(i){case er.FAIRPLAY:return Yr.FAIRPLAY;case er.PLAYREADY:return Yr.PLAYREADY;case er.WIDEVINE:return Yr.WIDEVINE;case er.CLEARKEY:return Yr.CLEARKEY}}function Uc(i){const{drmSystems:t,widevineLicenseUrl:e}=i,r=t?[er.FAIRPLAY,er.WIDEVINE,er.PLAYREADY,er.CLEARKEY].filter(n=>!!t[n]):[];return!r[er.WIDEVINE]&&e&&r.push(er.WIDEVINE),r}const tf=function(){return typeof self<"u"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function hb(i,t,e,r){let n;switch(i){case er.FAIRPLAY:n=["cenc","sinf"];break;case er.WIDEVINE:case er.PLAYREADY:n=["cenc"];break;case er.CLEARKEY:n=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${i}`)}return db(n,t,e,r)}function db(i,t,e,r){return[{initDataTypes:i,persistentState:r.persistentState||"not-allowed",distinctiveIdentifier:r.distinctiveIdentifier||"not-allowed",sessionTypes:r.sessionTypes||[r.sessionType||"temporary"],audioCapabilities:t.map(n=>({contentType:`audio/mp4; codecs="${n}"`,robustness:r.audioRobustness||"",encryptionScheme:r.audioEncryptionScheme||null})),videoCapabilities:e.map(n=>({contentType:`video/mp4; codecs="${n}"`,robustness:r.videoRobustness||"",encryptionScheme:r.videoEncryptionScheme||null}))}]}function un(i,t,e){return Uint8Array.prototype.slice?i.slice(t,e):new Uint8Array(Array.prototype.slice.call(i,t,e))}const Bc=(i,t)=>t+10<=i.length&&i[t]===73&&i[t+1]===68&&i[t+2]===51&&i[t+3]<255&&i[t+4]<255&&i[t+6]<128&&i[t+7]<128&&i[t+8]<128&&i[t+9]<128,ef=(i,t)=>t+10<=i.length&&i[t]===51&&i[t+1]===68&&i[t+2]===73&&i[t+3]<255&&i[t+4]<255&&i[t+6]<128&&i[t+7]<128&&i[t+8]<128&&i[t+9]<128,Vo=(i,t)=>{const e=t;let r=0;for(;Bc(i,t);){r+=10;const n=Wo(i,t+6);r+=n,ef(i,t+10)&&(r+=10),t+=r}if(r>0)return i.subarray(e,e+r)},Wo=(i,t)=>{let e=0;return e=(i[t]&127)<<21,e|=(i[t+1]&127)<<14,e|=(i[t+2]&127)<<7,e|=i[t+3]&127,e},ub=(i,t)=>Bc(i,t)&&Wo(i,t+6)+10<=i.length-t,fb=i=>{const t=sf(i);for(let e=0;e<t.length;e++){const r=t[e];if(rf(r))return bb(r)}},rf=i=>i&&i.key==="PRIV"&&i.info==="com.apple.streaming.transportStreamTimestamp",pb=i=>{const t=String.fromCharCode(i[0],i[1],i[2],i[3]),e=Wo(i,4),r=10;return{type:t,size:e,data:i.subarray(r,r+e)}},sf=i=>{let t=0;const e=[];for(;Bc(i,t);){const r=Wo(i,t+6);t+=10;const n=t+r;for(;t+8<n;){const o=pb(i.subarray(t)),l=gb(o);l&&e.push(l),t+=o.size+10}ef(i,t)&&(t+=10)}return e},gb=i=>i.type==="PRIV"?mb(i):i.type[0]==="W"?yb(i):vb(i),mb=i=>{if(i.size<2)return;const t=Fi(i.data,!0),e=new Uint8Array(i.data.subarray(t.length+1));return{key:i.type,info:t,data:e.buffer}},vb=i=>{if(i.size<2)return;if(i.type==="TXXX"){let e=1;const r=Fi(i.data.subarray(e),!0);e+=r.length+1;const n=Fi(i.data.subarray(e));return{key:i.type,info:r,data:n}}const t=Fi(i.data.subarray(1));return{key:i.type,data:t}},yb=i=>{if(i.type==="WXXX"){if(i.size<2)return;let e=1;const r=Fi(i.data.subarray(e),!0);e+=r.length+1;const n=Fi(i.data.subarray(e));return{key:i.type,info:r,data:n}}const t=Fi(i.data);return{key:i.type,data:t}},bb=i=>{if(i.data.byteLength===8){const t=new Uint8Array(i.data),e=t[3]&1;let r=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return r/=45,e&&(r+=4772185884e-2),Math.round(r)}},Fi=(i,t=!1)=>{const e=Eb();if(e){const p=e.decode(i);if(t){const g=p.indexOf("\0");return g!==-1?p.substring(0,g):p}return p.replace(/\0/g,"")}const r=i.length;let n,o,l,d="",f=0;for(;f<r;){if(n=i[f++],n===0&&t)return d;if(!(n===0||n===3))switch(n>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:d+=String.fromCharCode(n);break;case 12:case 13:o=i[f++],d+=String.fromCharCode((n&31)<<6|o&63);break;case 14:o=i[f++],l=i[f++],d+=String.fromCharCode((n&15)<<12|(o&63)<<6|(l&63)<<0);break}}return d};let Gc;function Eb(){return!Gc&&typeof self.TextDecoder<"u"&&(Gc=new self.TextDecoder("utf-8")),Gc}const Ui={hexDump:function(i){let t="";for(let e=0;e<i.length;e++){let r=i[e].toString(16);r.length<2&&(r="0"+r),t+=r}return t}},jo=Math.pow(2,32)-1,Ab=[].push,nf={video:1,audio:2,id3:3,text:4};function _r(i){return String.fromCharCode.apply(null,i)}function af(i,t){const e=i[t]<<8|i[t+1];return e<0?65536+e:e}function re(i,t){const e=of(i,t);return e<0?4294967296+e:e}function of(i,t){return i[t]<<24|i[t+1]<<16|i[t+2]<<8|i[t+3]}function Hc(i,t,e){i[t]=e>>24,i[t+1]=e>>16&255,i[t+2]=e>>8&255,i[t+3]=e&255}function Te(i,t){const e=[];if(!t.length)return e;const r=i.byteLength;for(let n=0;n<r;){const o=re(i,n),l=_r(i.subarray(n+4,n+8)),d=o>1?n+o:r;if(l===t[0])if(t.length===1)e.push(i.subarray(n+8,d));else{const f=Te(i.subarray(n+8,d),t.slice(1));f.length&&Ab.apply(e,f)}n=d}return e}function Tb(i){const t=[],e=i[0];let r=8;const n=re(i,r);r+=4;const o=0,l=0;e===0?r+=8:r+=16,r+=2;let d=i.length+l;const f=af(i,r);r+=2;for(let p=0;p<f;p++){let g=r;const v=re(i,g);g+=4;const E=v&2147483647;if((v&2147483648)>>>31===1)return X.warn("SIDX has hierarchical references (not supported)"),null;const A=re(i,g);g+=4,t.push({referenceSize:E,subsegmentDuration:A,info:{duration:A/n,start:d,end:d+E-1}}),d+=E,g+=4,r=g}return{earliestPresentationTime:o,timescale:n,version:e,referencesCount:f,references:t}}function lf(i){const t=[],e=Te(i,["moov","trak"]);for(let r=0;r<e.length;r++){const n=e[r],o=Te(n,["tkhd"])[0];if(o){let l=o[0],d=l===0?12:20;const f=re(o,d),p=Te(n,["mdia","mdhd"])[0];if(p){l=p[0],d=l===0?12:20;const g=re(p,d),v=Te(n,["mdia","hdlr"])[0];if(v){const E=_r(v.subarray(8,12)),A={soun:Oe.AUDIO,vide:Oe.VIDEO}[E];if(A){const T=Te(n,["mdia","minf","stbl","stsd"])[0];let w;T&&(w=_r(T.subarray(12,16))),t[f]={timescale:g,type:A},t[A]={timescale:g,id:f,codec:w}}}}}}return Te(i,["moov","mvex","trex"]).forEach(r=>{const n=re(r,4),o=t[n];o&&(o.default={duration:re(r,12),flags:re(r,20)})}),t}function kb(i,t){if(!i||!t)return i;const e=t.keyId;return e&&t.isCommonEncryption&&Te(i,["moov","trak"]).forEach(r=>{const n=Te(r,["mdia","minf","stbl","stsd"])[0].subarray(8);let o=Te(n,["enca"]);const l=o.length>0;l||(o=Te(n,["encv"])),o.forEach(d=>{const f=l?d.subarray(28):d.subarray(78);Te(f,["sinf"]).forEach(p=>{const g=cf(p);if(g){const v=g.subarray(8,24);v.some(E=>E!==0)||(X.log(`[eme] Patching keyId in 'enc${l?"a":"v"}>sinf>>tenc' box: ${Ui.hexDump(v)} -> ${Ui.hexDump(e)}`),g.set(e,8))}})})}),i}function cf(i){const t=Te(i,["schm"])[0];if(t){const e=_r(t.subarray(4,8));if(e==="cbcs"||e==="cenc")return Te(i,["schi","tenc"])[0]}return X.error("[eme] missing 'schm' box"),null}function wb(i,t){return Te(t,["moof","traf"]).reduce((e,r)=>{const n=Te(r,["tfdt"])[0],o=n[0],l=Te(r,["tfhd"]).reduce((d,f)=>{const p=re(f,4),g=i[p];if(g){let v=re(n,4);if(o===1){if(v===jo)return X.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),d;v*=jo+1,v+=re(n,8)}const E=g.timescale||9e4,A=v/E;if(isFinite(A)&&(d===null||A<d))return A}return d},null);return l!==null&&isFinite(l)&&(e===null||l<e)?l:e},null)}function Sb(i,t){let e=0,r=0,n=0;const o=Te(i,["moof","traf"]);for(let l=0;l<o.length;l++){const d=o[l],f=Te(d,["tfhd"])[0],p=re(f,4),g=t[p];if(!g)continue;const v=g.default,E=re(f,0)|(v==null?void 0:v.flags);let A=v==null?void 0:v.duration;E&8&&(E&2?A=re(f,12):A=re(f,8));const T=g.timescale||9e4,w=Te(d,["trun"]);for(let C=0;C<w.length;C++){if(e=Rb(w[C]),!e&&A){const D=re(w[C],4);e=A*D}g.type===Oe.VIDEO?r+=e/T:g.type===Oe.AUDIO&&(n+=e/T)}}if(r===0&&n===0){let l=0;const d=Te(i,["sidx"]);for(let f=0;f<d.length;f++){const p=Tb(d[f]);p!=null&&p.references&&(l+=p.references.reduce((g,v)=>g+v.info.duration||0,0))}return l}return r||n}function Rb(i){const t=re(i,0);let e=8;t&1&&(e+=4),t&4&&(e+=4);let r=0;const n=re(i,4);for(let o=0;o<n;o++){if(t&256){const l=re(i,e);r+=l,e+=4}t&512&&(e+=4),t&1024&&(e+=4),t&2048&&(e+=4)}return r}function _b(i,t,e){Te(t,["moof","traf"]).forEach(r=>{Te(r,["tfhd"]).forEach(n=>{const o=re(n,4),l=i[o];if(!l)return;const d=l.timescale||9e4;Te(r,["tfdt"]).forEach(f=>{const p=f[0];let g=re(f,4);if(p===0)g-=e*d,g=Math.max(g,0),Hc(f,4,g);else{g*=Math.pow(2,32),g+=re(f,8),g-=e*d,g=Math.max(g,0);const v=Math.floor(g/(jo+1)),E=Math.floor(g%(jo+1));Hc(f,4,v),Hc(f,8,E)}})})})}function Lb(i){const t={valid:null,remainder:null},e=Te(i,["moof"]);if(e){if(e.length<2)return t.remainder=i,t}else return t;const r=e[e.length-1];return t.valid=un(i,0,r.byteOffset-8),t.remainder=un(i,r.byteOffset-8),t}function fn(i,t){const e=new Uint8Array(i.length+t.length);return e.set(i),e.set(t,i.length),e}function hf(i,t){const e=[],r=t.samples,n=t.timescale,o=t.id;let l=!1;return Te(r,["moof"]).map(d=>{const f=d.byteOffset-8;Te(d,["traf"]).map(p=>{const g=Te(p,["tfdt"]).map(v=>{const E=v[0];let A=re(v,4);return E===1&&(A*=Math.pow(2,32),A+=re(v,8)),A/n})[0];return g!==void 0&&(i=g),Te(p,["tfhd"]).map(v=>{const E=re(v,4),A=re(v,0)&16777215,T=(A&1)!==0,w=(A&2)!==0,C=(A&8)!==0;let D=0;const M=(A&16)!==0;let U=0;const x=(A&32)!==0;let O=8;E===o&&(T&&(O+=8),w&&(O+=4),C&&(D=re(v,O),O+=4),M&&(U=re(v,O),O+=4),x&&(O+=4),t.type==="video"&&(l=Cb(t.codec)),Te(p,["trun"]).map(K=>{const B=K[0],at=re(K,0)&16777215,st=(at&1)!==0;let J=0;const kt=(at&4)!==0,ft=(at&256)!==0;let wt=0;const Pt=(at&512)!==0;let F=0;const j=(at&1024)!==0,bt=(at&2048)!==0;let N=0;const G=re(K,4);let Z=8;st&&(J=re(K,Z),Z+=4),kt&&(Z+=4);let gt=J+f;for(let vt=0;vt<G;vt++){if(ft?(wt=re(K,Z),Z+=4):wt=D,Pt?(F=re(K,Z),Z+=4):F=U,j&&(Z+=4),bt&&(B===0?N=re(K,Z):N=of(K,Z),Z+=4),t.type===Oe.VIDEO){let It=0;for(;It<F;){const Bt=re(r,gt);if(gt+=4,Ib(l,r[gt])){const Xt=r.subarray(gt,gt+Bt);df(Xt,l?2:1,i+N/n,e)}gt+=Bt,It+=Bt+4}}i+=wt/n}}))})})}),e}function Cb(i){if(!i)return!1;const t=i.indexOf("."),e=t<0?i:i.substring(0,t);return e==="hvc1"||e==="hev1"||e==="dvh1"||e==="dvhe"}function Ib(i,t){if(i){const e=t>>1&63;return e===39||e===40}else return(t&31)===6}function df(i,t,e,r){const n=uf(i);let o=0;o+=t;let l=0,d=0,f=!1,p=0;for(;o<n.length;){l=0;do{if(o>=n.length)break;p=n[o++],l+=p}while(p===255);d=0;do{if(o>=n.length)break;p=n[o++],d+=p}while(p===255);const g=n.length-o;if(!f&&l===4&&o<n.length){if(f=!0,n[o++]===181){const v=af(n,o);if(o+=2,v===49){const E=re(n,o);if(o+=4,E===1195456820){const A=n[o++];if(A===3){const T=n[o++],w=31&T,C=64&T,D=C?2+w*3:0,M=new Uint8Array(D);if(C){M[0]=T;for(let U=1;U<D;U++)M[U]=n[o++]}r.push({type:A,payloadType:l,pts:e,bytes:M})}}}}}else if(l===5&&d<g){if(f=!0,d>16){const v=[];for(let T=0;T<16;T++){const w=n[o++].toString(16);v.push(w.length==1?"0"+w:w),(T===3||T===5||T===7||T===9)&&v.push("-")}const E=d-16,A=new Uint8Array(E);for(let T=0;T<E;T++)A[T]=n[o++];r.push({payloadType:l,pts:e,uuid:v.join(""),userData:Fi(A),userDataBytes:A})}}else if(d<g)o+=d;else if(d>g)break}}function uf(i){const t=i.byteLength,e=[];let r=1;for(;r<t-2;)i[r]===0&&i[r+1]===0&&i[r+2]===3?(e.push(r+2),r+=2):r++;if(e.length===0)return i;const n=t-e.length,o=new Uint8Array(n);let l=0;for(r=0;r<n;l++,r++)l===e[0]&&(l++,e.shift()),o[r]=i[l];return o}function xb(i){const t=i[0];let e="",r="",n=0,o=0,l=0,d=0,f=0,p=0;if(t===0){for(;_r(i.subarray(p,p+1))!=="\0";)e+=_r(i.subarray(p,p+1)),p+=1;for(e+=_r(i.subarray(p,p+1)),p+=1;_r(i.subarray(p,p+1))!=="\0";)r+=_r(i.subarray(p,p+1)),p+=1;r+=_r(i.subarray(p,p+1)),p+=1,n=re(i,12),o=re(i,16),d=re(i,20),f=re(i,24),p=28}else if(t===1){p+=4,n=re(i,p),p+=4;const v=re(i,p);p+=4;const E=re(i,p);for(p+=4,l=4294967296*v+E,Number.isSafeInteger(l)||(l=Number.MAX_SAFE_INTEGER,X.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),d=re(i,p),p+=4,f=re(i,p),p+=4;_r(i.subarray(p,p+1))!=="\0";)e+=_r(i.subarray(p,p+1)),p+=1;for(e+=_r(i.subarray(p,p+1)),p+=1;_r(i.subarray(p,p+1))!=="\0";)r+=_r(i.subarray(p,p+1)),p+=1;r+=_r(i.subarray(p,p+1)),p+=1}const g=i.subarray(p,i.byteLength);return{schemeIdUri:e,value:r,timeScale:n,presentationTime:l,presentationTimeDelta:o,eventDuration:d,id:f,payload:g}}function Db(i,...t){const e=t.length;let r=8,n=e;for(;n--;)r+=t[n].byteLength;const o=new Uint8Array(r);for(o[0]=r>>24&255,o[1]=r>>16&255,o[2]=r>>8&255,o[3]=r&255,o.set(i,4),n=0,r=8;n<e;n++)o.set(t[n],r),r+=t[n].byteLength;return o}function Pb(i,t,e){if(i.byteLength!==16)throw new RangeError("Invalid system id");let r,n;if(t){r=1,n=new Uint8Array(t.length*16);for(let d=0;d<t.length;d++){const f=t[d];if(f.byteLength!==16)throw new RangeError("Invalid key");n.set(f,d*16)}}else r=0,n=new Uint8Array;let o;r>0?(o=new Uint8Array(4),t.length>0&&new DataView(o.buffer).setUint32(0,t.length,!1)):o=new Uint8Array;const l=new Uint8Array(4);return e&&e.byteLength>0&&new DataView(l.buffer).setUint32(0,e.byteLength,!1),Db([112,115,115,104],new Uint8Array([r,0,0,0]),i,o,n,l,e||new Uint8Array)}function Ob(i){if(!(i instanceof ArrayBuffer)||i.byteLength<32)return null;const t={version:0,systemId:"",kids:null,data:null},e=new DataView(i),r=e.getUint32(0);if(i.byteLength!==r&&r>44||e.getUint32(4)!==1886614376||(t.version=e.getUint32(8)>>>24,t.version>1))return null;t.systemId=Ui.hexDump(new Uint8Array(i,12,16));const n=e.getUint32(28);if(t.version===0){if(r-32<n)return null;t.data=new Uint8Array(i,32,n)}else if(t.version===1){t.kids=[];for(let o=0;o<n;o++)t.kids.push(new Uint8Array(i,32+o*16,16))}return t}let Ko={};class Oa{static clearKeyUriToKeyIdMap(){Ko={}}constructor(t,e,r,n=[1],o=null){this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=t,this.uri=e,this.keyFormat=r,this.keyFormatVersions=n,this.iv=o,this.encrypted=t?t!=="NONE":!1,this.isCommonEncryption=this.encrypted&&t!=="AES-128"}isSupported(){if(this.method){if(this.method==="AES-128"||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES";switch(this.keyFormat){case Yr.FAIRPLAY:case Yr.WIDEVINE:case Yr.PLAYREADY:case Yr.CLEARKEY:return["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1}getDecryptData(t){if(!this.encrypted||!this.uri)return null;if(this.method==="AES-128"&&this.uri&&!this.iv){typeof t!="number"&&(this.method==="AES-128"&&!this.iv&&X.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),t=0);const r=$b(t);return new Oa(this.method,this.uri,"identity",this.keyFormatVersions,r)}const e=lb(this.uri);if(e)switch(this.keyFormat){case Yr.WIDEVINE:this.pssh=e,e.length>=22&&(this.keyId=e.subarray(e.length-22,e.length-6));break;case Yr.PLAYREADY:{const r=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=Pb(r,null,e);const n=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2),o=String.fromCharCode.apply(null,Array.from(n)),l=o.substring(o.indexOf("<"),o.length),d=new DOMParser().parseFromString(l,"text/xml").getElementsByTagName("KID")[0];if(d){const f=d.childNodes[0]?d.childNodes[0].nodeValue:d.getAttribute("VALUE");if(f){const p=Fc(f).subarray(0,16);ob(p),this.keyId=p}}break}default:{let r=e.subarray(0,16);if(r.length!==16){const n=new Uint8Array(16);n.set(r,16-r.length),r=n}this.keyId=r;break}}if(!this.keyId||this.keyId.byteLength!==16){let r=Ko[this.uri];if(!r){const n=Object.keys(Ko).length%Number.MAX_SAFE_INTEGER;r=new Uint8Array(16),new DataView(r.buffer,12,4).setUint32(0,n),Ko[this.uri]=r}this.keyId=r}return this}}function $b(i){const t=new Uint8Array(16);for(let e=12;e<16;e++)t[e]=i>>8*(15-e)&255;return t}const ff=/\{\$([a-zA-Z0-9-_]+)\}/g;function pf(i){return ff.test(i)}function Xr(i,t,e){if(i.variableList!==null||i.hasVariableRefs)for(let r=e.length;r--;){const n=e[r],o=t[n];o&&(t[n]=Vc(i,o))}}function Vc(i,t){if(i.variableList!==null||i.hasVariableRefs){const e=i.variableList;return t.replace(ff,r=>{const n=r.substring(2,r.length-1),o=e==null?void 0:e[n];return o===void 0?(i.playlistParsingError||(i.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${n}"`)),r):o})}return t}function gf(i,t,e){let r=i.variableList;r||(i.variableList=r={});let n,o;if("QUERYPARAM"in t){n=t.QUERYPARAM;try{const l=new self.URL(e).searchParams;if(l.has(n))o=l.get(n);else throw new Error(`"${n}" does not match any query parameter in URI: "${e}"`)}catch(l){i.playlistParsingError||(i.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${l.message}`))}}else n=t.NAME,o=t.VALUE;n in r?i.playlistParsingError||(i.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${n}"`)):r[n]=o||""}function Mb(i,t,e){const r=t.IMPORT;if(e&&r in e){let n=i.variableList;n||(i.variableList=n={}),n[r]=e[r]}else i.playlistParsingError||(i.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${r}"`))}function zo(){if(!(typeof self>"u"))return self.MediaSource||self.WebKitMediaSource}const Nb={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}},mf=zo();function Fb(i,t){const e=Nb[t];return!!e&&e[i.slice(0,4)]===!0}function Wc(i,t){var e;return(e=mf==null?void 0:mf.isTypeSupported(`${t||"video"}/mp4;codecs="${i}"`))!=null?e:!1}const vf=/#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,yf=/#EXT-X-MEDIA:(.*)/g,Ub=/^#EXT(?:INF|-X-TARGETDURATION):/m,bf=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),Bb=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 wi{static findGroup(t,e){for(let r=0;r<t.length;r++){const n=t[r];if(n.id===e)return n}}static convertAVC1ToAVCOTI(t){const e=t.split(".");if(e.length>2){let r=e.shift()+".";return r+=parseInt(e.shift()).toString(16),r+=("000"+parseInt(e.shift()).toString(16)).slice(-4),r}return t}static resolve(t,e){return $c.buildAbsoluteURL(e,t,{alwaysNormalize:!0})}static isMediaPlaylist(t){return Ub.test(t)}static parseMasterPlaylist(t,e){const r=pf(t),n={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:r},o=[];vf.lastIndex=0;let l;for(;(l=vf.exec(t))!=null;)if(l[1]){var d;const p=new tr(l[1]);Xr(n,p,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);const g=Vc(n,l[2]),v={attrs:p,bitrate:p.decimalInteger("AVERAGE-BANDWIDTH")||p.decimalInteger("BANDWIDTH"),name:p.NAME,url:wi.resolve(g,e)},E=p.decimalResolution("RESOLUTION");E&&(v.width=E.width,v.height=E.height),Gb((p.CODECS||"").split(/[ ,]+/).filter(A=>A),v),v.videoCodec&&v.videoCodec.indexOf("avc1")!==-1&&(v.videoCodec=wi.convertAVC1ToAVCOTI(v.videoCodec)),(d=v.unknownCodecs)!=null&&d.length||o.push(v),n.levels.push(v)}else if(l[3]){const p=l[3],g=l[4];switch(p){case"SESSION-DATA":{const v=new tr(g);Xr(n,v,["DATA-ID","LANGUAGE","VALUE","URI"]);const E=v["DATA-ID"];E&&(n.sessionData===null&&(n.sessionData={}),n.sessionData[E]=v);break}case"SESSION-KEY":{const v=Ef(g,e,n);v.encrypted&&v.isSupported()?(n.sessionKeys===null&&(n.sessionKeys=[]),n.sessionKeys.push(v)):X.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${g}"`);break}case"DEFINE":{{const v=new tr(g);Xr(n,v,["NAME","VALUE","QUERYPARAM"]),gf(n,v,e)}break}case"CONTENT-STEERING":{const v=new tr(g);Xr(n,v,["SERVER-URI","PATHWAY-ID"]),n.contentSteering={uri:wi.resolve(v["SERVER-URI"],e),pathwayId:v["PATHWAY-ID"]||"."};break}case"START":{n.startTimeOffset=Af(g);break}}}const f=o.length>0&&o.length<n.levels.length;return n.levels=f?o:n.levels,n.levels.length===0&&(n.playlistParsingError=new Error("no levels found in manifest")),n}static parseMasterPlaylistMedia(t,e,r){let n;const o={},l=r.levels,d={AUDIO:l.map(p=>({id:p.attrs.AUDIO,audioCodec:p.audioCodec})),SUBTITLES:l.map(p=>({id:p.attrs.SUBTITLES,textCodec:p.textCodec})),"CLOSED-CAPTIONS":[]};let f=0;for(yf.lastIndex=0;(n=yf.exec(t))!==null;){const p=new tr(n[1]),g=p.TYPE;if(g){const v=d[g],E=o[g]||[];o[g]=E,Xr(r,p,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);const A={attrs:p,bitrate:0,id:f++,groupId:p["GROUP-ID"]||"",instreamId:p["INSTREAM-ID"],name:p.NAME||p.LANGUAGE||"",type:g,default:p.bool("DEFAULT"),autoselect:p.bool("AUTOSELECT"),forced:p.bool("FORCED"),lang:p.LANGUAGE,url:p.URI?wi.resolve(p.URI,e):""};if(v!=null&&v.length){const T=wi.findGroup(v,A.groupId)||v[0];Tf(A,T,"audioCodec"),Tf(A,T,"textCodec")}E.push(A)}}return o}static parseLevelPlaylist(t,e,r,n,o,l){const d=new nb(e),f=d.fragments;let p=null,g=0,v=0,E=0,A=0,T=null,w=new Nc(n,e),C,D,M,U=-1,x=!1;for(bf.lastIndex=0,d.m3u8=t,d.hasVariableRefs=pf(t);(C=bf.exec(t))!==null;){x&&(x=!1,w=new Nc(n,e),w.start=E,w.sn=g,w.cc=A,w.level=r,p&&(w.initSegment=p,w.rawProgramDateTime=p.rawProgramDateTime,p.rawProgramDateTime=null));const at=C[1];if(at){w.duration=parseFloat(at);const st=(" "+C[2]).slice(1);w.title=st||null,w.tagList.push(st?["INF",at,st]:["INF",at])}else if(C[3]){if(jt(w.duration)){w.start=E,M&&Sf(w,M,d),w.sn=g,w.level=r,w.cc=A,w.urlId=o,f.push(w);const st=(" "+C[3]).slice(1);w.relurl=Vc(d,st),kf(w,T),T=w,E+=w.duration,g++,v=0,x=!0}}else if(C[4]){const st=(" "+C[4]).slice(1);T?w.setByteRange(st,T):w.setByteRange(st)}else if(C[5])w.rawProgramDateTime=(" "+C[5]).slice(1),w.tagList.push(["PROGRAM-DATE-TIME",w.rawProgramDateTime]),U===-1&&(U=f.length);else{if(C=C[0].match(Bb),!C){X.warn("No matches on slow regex match for level playlist!");continue}for(D=1;D<C.length&&!(typeof C[D]<"u");D++);const st=(" "+C[D]).slice(1),J=(" "+C[D+1]).slice(1),kt=C[D+2]?(" "+C[D+2]).slice(1):"";switch(st){case"PLAYLIST-TYPE":d.type=J.toUpperCase();break;case"MEDIA-SEQUENCE":g=d.startSN=parseInt(J);break;case"SKIP":{const ft=new tr(J);Xr(d,ft,["RECENTLY-REMOVED-DATERANGES"]);const wt=ft.decimalInteger("SKIPPED-SEGMENTS");if(jt(wt)){d.skippedSegments=wt;for(let F=wt;F--;)f.unshift(null);g+=wt}const Pt=ft.enumeratedString("RECENTLY-REMOVED-DATERANGES");Pt&&(d.recentlyRemovedDateranges=Pt.split(" "));break}case"TARGETDURATION":d.targetduration=Math.max(parseInt(J),1);break;case"VERSION":d.version=parseInt(J);break;case"EXTM3U":break;case"ENDLIST":d.live=!1;break;case"#":(J||kt)&&w.tagList.push(kt?[J,kt]:[J]);break;case"DISCONTINUITY":A++,w.tagList.push(["DIS"]);break;case"GAP":w.gap=!0,w.tagList.push([st]);break;case"BITRATE":w.tagList.push([st,J]);break;case"DATERANGE":{const ft=new tr(J);Xr(d,ft,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),Xr(d,ft,ft.clientAttrs);const wt=new Y0(ft,d.dateRanges[ft.ID]);wt.isValid||d.skippedSegments?d.dateRanges[wt.id]=wt:X.warn(`Ignoring invalid DATERANGE tag: "${J}"`),w.tagList.push(["EXT-X-DATERANGE",J]);break}case"DEFINE":{{const ft=new tr(J);Xr(d,ft,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in ft?Mb(d,ft,l):gf(d,ft,e)}break}case"DISCONTINUITY-SEQUENCE":A=parseInt(J);break;case"KEY":{const ft=Ef(J,e,d);if(ft.isSupported()){if(ft.method==="NONE"){M=void 0;break}M||(M={}),M[ft.keyFormat]&&(M=dr({},M)),M[ft.keyFormat]=ft}else X.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${J}"`);break}case"START":d.startTimeOffset=Af(J);break;case"MAP":{const ft=new tr(J);if(Xr(d,ft,["BYTERANGE","URI"]),w.duration){const wt=new Nc(n,e);wf(wt,ft,r,M),p=wt,w.initSegment=p,p.rawProgramDateTime&&!w.rawProgramDateTime&&(w.rawProgramDateTime=p.rawProgramDateTime)}else wf(w,ft,r,M),p=w,x=!0;break}case"SERVER-CONTROL":{const ft=new tr(J);d.canBlockReload=ft.bool("CAN-BLOCK-RELOAD"),d.canSkipUntil=ft.optionalFloat("CAN-SKIP-UNTIL",0),d.canSkipDateRanges=d.canSkipUntil>0&&ft.bool("CAN-SKIP-DATERANGES"),d.partHoldBack=ft.optionalFloat("PART-HOLD-BACK",0),d.holdBack=ft.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{const ft=new tr(J);d.partTarget=ft.decimalFloatingPoint("PART-TARGET");break}case"PART":{let ft=d.partList;ft||(ft=d.partList=[]);const wt=v>0?ft[ft.length-1]:void 0,Pt=v++,F=new tr(J);Xr(d,F,["BYTERANGE","URI"]);const j=new ib(F,w,e,Pt,wt);ft.push(j),w.duration+=j.duration;break}case"PRELOAD-HINT":{const ft=new tr(J);Xr(d,ft,["URI"]),d.preloadHint=ft;break}case"RENDITION-REPORT":{const ft=new tr(J);Xr(d,ft,["URI"]),d.renditionReports=d.renditionReports||[],d.renditionReports.push(ft);break}default:X.warn(`line parsed but not handled: ${C}`);break}}}T&&!T.relurl?(f.pop(),E-=T.duration,d.partList&&(d.fragmentHint=T)):d.partList&&(kf(w,T),w.cc=A,d.fragmentHint=w,M&&Sf(w,M,d));const O=f.length,K=f[0],B=f[O-1];if(E+=d.skippedSegments*d.targetduration,E>0&&O&&B){d.averagetargetduration=E/O;const at=B.sn;d.endSN=at!=="initSegment"?at:0,d.live||(B.endList=!0),K&&(d.startCC=K.cc)}else d.endSN=0,d.startCC=0;return d.fragmentHint&&(E+=d.fragmentHint.duration),d.totalduration=E,d.endCC=A,U>0&&Hb(f,U),d}}function Ef(i,t,e){var r,n;const o=new tr(i);Xr(e,o,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);const l=(r=o.METHOD)!=null?r:"",d=o.URI,f=o.hexadecimalInteger("IV"),p=o.KEYFORMATVERSIONS,g=(n=o.KEYFORMAT)!=null?n:"identity";d&&o.IV&&!f&&X.error(`Invalid IV: ${o.IV}`);const v=d?wi.resolve(d,t):"",E=(p||"1").split("/").map(Number).filter(Number.isFinite);return new Oa(l,v,g,E,f)}function Af(i){const t=new tr(i).decimalFloatingPoint("TIME-OFFSET");return jt(t)?t:null}function Gb(i,t){["video","audio","text"].forEach(e=>{const r=i.filter(n=>Fb(n,e));if(r.length){const n=r.filter(o=>o.lastIndexOf("avc1",0)===0||o.lastIndexOf("mp4a",0)===0);t[`${e}Codec`]=n.length>0?n[0]:r[0],i=i.filter(o=>r.indexOf(o)===-1)}}),t.unknownCodecs=i}function Tf(i,t,e){const r=t[e];r&&(i[e]=r)}function Hb(i,t){let e=i[t];for(let r=t;r--;){const n=i[r];if(!n)return;n.programDateTime=e.programDateTime-n.duration*1e3,e=n}}function kf(i,t){i.rawProgramDateTime?i.programDateTime=Date.parse(i.rawProgramDateTime):t!=null&&t.programDateTime&&(i.programDateTime=t.endProgramDateTime),jt(i.programDateTime)||(i.programDateTime=null,i.rawProgramDateTime=null)}function wf(i,t,e,r){i.relurl=t.URI,t.BYTERANGE&&i.setByteRange(t.BYTERANGE),i.level=e,i.sn="initSegment",r&&(i.levelkeys=r),i.initSegment=null}function Sf(i,t,e){i.levelkeys=t;const{encryptedFragments:r}=e;(!r.length||r[r.length-1].levelkeys!==t)&&Object.keys(t).some(n=>t[n].isCommonEncryption)&&r.push(i)}var Se={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},Jt={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function Rf(i){const{type:t}=i;switch(t){case Se.AUDIO_TRACK:return Jt.AUDIO;case Se.SUBTITLE_TRACK:return Jt.SUBTITLE;default:return Jt.MAIN}}function jc(i,t){let e=i.url;return(e===void 0||e.indexOf("data:")===0)&&(e=t.url),e}class Vb{constructor(t){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=t,this.registerListeners()}startLoad(t){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){const{hls:t}=this;t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.LEVEL_LOADING,this.onLevelLoading,this),t.on(R.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.on(R.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){const{hls:t}=this;t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.LEVEL_LOADING,this.onLevelLoading,this),t.off(R.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.off(R.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}createInternalLoader(t){const e=this.hls.config,r=e.pLoader,n=e.loader,o=r||n,l=new o(e);return this.loaders[t.type]=l,l}getInternalLoader(t){return this.loaders[t.type]}resetInternalLoader(t){this.loaders[t]&&delete this.loaders[t]}destroyInternalLoaders(){for(const t in this.loaders){const e=this.loaders[t];e&&e.destroy(),this.resetInternalLoader(t)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(t,e){const{url:r}=e;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:Se.MANIFEST,url:r,deliveryDirectives:null})}onLevelLoading(t,e){const{id:r,level:n,url:o,deliveryDirectives:l}=e;this.load({id:r,level:n,responseType:"text",type:Se.LEVEL,url:o,deliveryDirectives:l})}onAudioTrackLoading(t,e){const{id:r,groupId:n,url:o,deliveryDirectives:l}=e;this.load({id:r,groupId:n,level:null,responseType:"text",type:Se.AUDIO_TRACK,url:o,deliveryDirectives:l})}onSubtitleTrackLoading(t,e){const{id:r,groupId:n,url:o,deliveryDirectives:l}=e;this.load({id:r,groupId:n,level:null,responseType:"text",type:Se.SUBTITLE_TRACK,url:o,deliveryDirectives:l})}load(t){var e;const r=this.hls.config;let n=this.getInternalLoader(t);if(n){const p=n.context;if(p&&p.url===t.url){X.trace("[playlist-loader]: playlist request ongoing");return}X.log(`[playlist-loader]: aborting previous loader for type: ${t.type}`),n.abort()}let o;if(t.type===Se.MANIFEST?o=r.manifestLoadPolicy.default:o=dr({},r.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),n=this.createInternalLoader(t),(e=t.deliveryDirectives)!=null&&e.part){let p;if(t.type===Se.LEVEL&&t.level!==null?p=this.hls.levels[t.level].details:t.type===Se.AUDIO_TRACK&&t.id!==null?p=this.hls.audioTracks[t.id].details:t.type===Se.SUBTITLE_TRACK&&t.id!==null&&(p=this.hls.subtitleTracks[t.id].details),p){const g=p.partTarget,v=p.targetduration;if(g&&v){const E=Math.max(g*3,v*.8)*1e3;o=dr({},o,{maxTimeToFirstByteMs:Math.min(E,o.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(E,o.maxTimeToFirstByteMs)})}}}const l=o.errorRetry||o.timeoutRetry||{},d={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:l.maxNumRetry||0,retryDelay:l.retryDelayMs||0,maxRetryDelay:l.maxRetryDelayMs||0},f={onSuccess:(p,g,v,E)=>{const A=this.getInternalLoader(v);this.resetInternalLoader(v.type);const T=p.data;if(T.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(p,v,new Error("no EXTM3U delimiter"),E||null,g);return}g.parsing.start=performance.now(),wi.isMediaPlaylist(T)?this.handleTrackOrLevelPlaylist(p,g,v,E||null,A):this.handleMasterPlaylist(p,g,v,E)},onError:(p,g,v,E)=>{this.handleNetworkError(g,v,!1,p,E)},onTimeout:(p,g,v)=>{this.handleNetworkError(g,v,!0,void 0,p)}};n.load(t,d,f)}handleMasterPlaylist(t,e,r,n){const o=this.hls,l=t.data,d=jc(t,r),f=wi.parseMasterPlaylist(l,d);if(f.playlistParsingError){this.handleManifestParsingError(t,r,f.playlistParsingError,n,e);return}const{contentSteering:p,levels:g,sessionData:v,sessionKeys:E,startTimeOffset:A,variableList:T}=f;this.variableList=T;const{AUDIO:w=[],SUBTITLES:C,"CLOSED-CAPTIONS":D}=wi.parseMasterPlaylistMedia(l,d,f);w.length&&!w.some(M=>!M.url)&&g[0].audioCodec&&!g[0].attrs.AUDIO&&(X.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),w.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new tr({}),bitrate:0,url:""})),o.trigger(R.MANIFEST_LOADED,{levels:g,audioTracks:w,subtitles:C,captions:D,contentSteering:p,url:d,stats:e,networkDetails:n,sessionData:v,sessionKeys:E,startTimeOffset:A,variableList:T})}handleTrackOrLevelPlaylist(t,e,r,n,o){const l=this.hls,{id:d,level:f,type:p}=r,g=jc(t,r),v=jt(d)?d:0,E=jt(f)?f:v,A=Rf(r),T=wi.parseLevelPlaylist(t.data,g,E,A,v,this.variableList);if(p===Se.MANIFEST){const w={attrs:new tr({}),bitrate:0,details:T,name:"",url:g};l.trigger(R.MANIFEST_LOADED,{levels:[w],audioTracks:[],url:g,stats:e,networkDetails:n,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}e.parsing.end=performance.now(),r.levelDetails=T,this.handlePlaylistLoaded(T,t,e,r,n,o)}handleManifestParsingError(t,e,r,n,o){this.hls.trigger(R.ERROR,{type:Qt.NETWORK_ERROR,details:ut.MANIFEST_PARSING_ERROR,fatal:e.type===Se.MANIFEST,url:t.url,err:r,error:r,reason:r.message,response:t,context:e,networkDetails:n,stats:o})}handleNetworkError(t,e,r=!1,n,o){let l=`A network ${r?"timeout":"error"+(n?" (status "+n.code+")":"")} occurred while loading ${t.type}`;t.type===Se.LEVEL?l+=`: ${t.level} id: ${t.id}`:(t.type===Se.AUDIO_TRACK||t.type===Se.SUBTITLE_TRACK)&&(l+=` id: ${t.id} group-id: "${t.groupId}"`);const d=new Error(l);X.warn(`[playlist-loader]: ${l}`);let f=ut.UNKNOWN,p=!1;const g=this.getInternalLoader(t);switch(t.type){case Se.MANIFEST:f=r?ut.MANIFEST_LOAD_TIMEOUT:ut.MANIFEST_LOAD_ERROR,p=!0;break;case Se.LEVEL:f=r?ut.LEVEL_LOAD_TIMEOUT:ut.LEVEL_LOAD_ERROR,p=!1;break;case Se.AUDIO_TRACK:f=r?ut.AUDIO_TRACK_LOAD_TIMEOUT:ut.AUDIO_TRACK_LOAD_ERROR,p=!1;break;case Se.SUBTITLE_TRACK:f=r?ut.SUBTITLE_TRACK_LOAD_TIMEOUT:ut.SUBTITLE_LOAD_ERROR,p=!1;break}g&&this.resetInternalLoader(t.type);const v={type:Qt.NETWORK_ERROR,details:f,fatal:p,url:t.url,loader:g,context:t,error:d,networkDetails:e,stats:o};if(n){const E=(e==null?void 0:e.url)||t.url;v.response=zr({url:E,data:void 0},n)}this.hls.trigger(R.ERROR,v)}handlePlaylistLoaded(t,e,r,n,o,l){const d=this.hls,{type:f,level:p,id:g,groupId:v,deliveryDirectives:E}=n,A=jc(e,n),T=Rf(n),w=typeof n.level=="number"&&T===Jt.MAIN?p:void 0;if(!t.fragments.length){const D=new Error("No Segments found in Playlist");d.trigger(R.ERROR,{type:Qt.NETWORK_ERROR,details:ut.LEVEL_EMPTY_ERROR,fatal:!1,url:A,error:D,reason:D.message,response:e,context:n,level:w,parent:T,networkDetails:o,stats:r});return}t.targetduration||(t.playlistParsingError=new Error("Missing Target Duration"));const C=t.playlistParsingError;if(C){d.trigger(R.ERROR,{type:Qt.NETWORK_ERROR,details:ut.LEVEL_PARSING_ERROR,fatal:!1,url:A,error:C,reason:C.message,response:e,context:n,level:w,parent:T,networkDetails:o,stats:r});return}switch(t.live&&l&&(l.getCacheAge&&(t.ageHeader=l.getCacheAge()||0),(!l.getCacheAge||isNaN(t.ageHeader))&&(t.ageHeader=0)),f){case Se.MANIFEST:case Se.LEVEL:d.trigger(R.LEVEL_LOADED,{details:t,level:w||0,id:g||0,stats:r,networkDetails:o,deliveryDirectives:E});break;case Se.AUDIO_TRACK:d.trigger(R.AUDIO_TRACK_LOADED,{details:t,id:g||0,groupId:v||"",stats:r,networkDetails:o,deliveryDirectives:E});break;case Se.SUBTITLE_TRACK:d.trigger(R.SUBTITLE_TRACK_LOADED,{details:t,id:g||0,groupId:v||"",stats:r,networkDetails:o,deliveryDirectives:E});break}}}function _f(i,t){let e;try{e=new Event("addtrack")}catch{e=document.createEvent("Event"),e.initEvent("addtrack",!1,!1)}e.track=i,t.dispatchEvent(e)}function Lf(i,t){const e=i.mode;if(e==="disabled"&&(i.mode="hidden"),i.cues&&!i.cues.getCueById(t.id))try{if(i.addCue(t),!i.cues.getCueById(t.id))throw new Error(`addCue is failed for: ${t}`)}catch(r){X.debug(`[texttrack-utils]: ${r}`);try{const n=new self.TextTrackCue(t.startTime,t.endTime,t.text);n.id=t.id,i.addCue(n)}catch(n){X.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${n}`)}}e==="disabled"&&(i.mode=e)}function xn(i){const t=i.mode;if(t==="disabled"&&(i.mode="hidden"),i.cues)for(let e=i.cues.length;e--;)i.removeCue(i.cues[e]);t==="disabled"&&(i.mode=t)}function Kc(i,t,e,r){const n=i.mode;if(n==="disabled"&&(i.mode="hidden"),i.cues&&i.cues.length>0){const o=jb(i.cues,t,e);for(let l=0;l<o.length;l++)(!r||r(o[l]))&&i.removeCue(o[l])}n==="disabled"&&(i.mode=n)}function Wb(i,t){if(t<i[0].startTime)return 0;const e=i.length-1;if(t>i[e].endTime)return-1;let r=0,n=e;for(;r<=n;){const o=Math.floor((n+r)/2);if(t<i[o].startTime)n=o-1;else if(t>i[o].startTime&&r<e)r=o+1;else return o}return i[r].startTime-t<t-i[n].startTime?r:n}function jb(i,t,e){const r=[],n=Wb(i,t);if(n>-1)for(let o=n,l=i.length;o<l;o++){const d=i[o];if(d.startTime>=t&&d.endTime<=e)r.push(d);else if(d.startTime>e)return r}return r}var Si={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"};const Kb=.25;function zc(){if(!(typeof self>"u"))return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}const Yo=(()=>{const i=zc();try{new i(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function Yc(i,t){return i.getTime()/1e3-t}function zb(i){return Uint8Array.from(i.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}class Yb{constructor(t){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=t,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null}_registerListeners(){const{hls:t}=this;t.on(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.on(R.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(R.LEVEL_UPDATED,this.onLevelUpdated,this)}_unregisterListeners(){const{hls:t}=this;t.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.off(R.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(R.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(t,e){this.media=e.media}onMediaDetaching(){this.id3Track&&(xn(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(t){const e=this.getID3Track(t.textTracks);return e.mode="hidden",e}getID3Track(t){if(this.media){for(let e=0;e<t.length;e++){const r=t[e];if(r.kind==="metadata"&&r.label==="id3")return _f(r,this.media),r}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(t,e){if(!this.media)return;const{hls:{config:{enableEmsgMetadataCues:r,enableID3MetadataCues:n}}}=this;if(!r&&!n)return;const{samples:o}=e;this.id3Track||(this.id3Track=this.createTrack(this.media));const l=zc();for(let d=0;d<o.length;d++){const f=o[d].type;if(f===Si.emsg&&!r||!n)continue;const p=sf(o[d].data);if(p){const g=o[d].pts;let v=g+o[d].duration;v>Yo&&(v=Yo),v-g<=0&&(v=g+Kb);for(let E=0;E<p.length;E++){const A=p[E];if(!rf(A)){this.updateId3CueEnds(g,f);const T=new l(g,v,"");T.value=A,f&&(T.type=f),this.id3Track.addCue(T)}}}}}updateId3CueEnds(t,e){var r;const n=(r=this.id3Track)==null?void 0:r.cues;if(n)for(let o=n.length;o--;){const l=n[o];l.type===e&&l.startTime<t&&l.endTime===Yo&&(l.endTime=t)}}onBufferFlushing(t,{startOffset:e,endOffset:r,type:n}){const{id3Track:o,hls:l}=this;if(!l)return;const{config:{enableEmsgMetadataCues:d,enableID3MetadataCues:f}}=l;if(o&&(d||f)){let p;n==="audio"?p=g=>g.type===Si.audioId3&&f:n==="video"?p=g=>g.type===Si.emsg&&d:p=g=>g.type===Si.audioId3&&f||g.type===Si.emsg&&d,Kc(o,e,r,p)}}onLevelUpdated(t,{details:e}){if(!this.media||!e.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;const{dateRangeCuesAppended:r,id3Track:n}=this,{dateRanges:o}=e,l=Object.keys(o);if(n){const g=Object.keys(r).filter(v=>!l.includes(v));for(let v=g.length;v--;){const E=g[v];Object.keys(r[E].cues).forEach(A=>{n.removeCue(r[E].cues[A])}),delete r[E]}}const d=e.fragments[e.fragments.length-1];if(l.length===0||!jt(d==null?void 0:d.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));const f=d.programDateTime/1e3-d.start,p=zc();for(let g=0;g<l.length;g++){const v=l[g],E=o[v],A=r[v],T=(A==null?void 0:A.cues)||{};let w=(A==null?void 0:A.durationKnown)||!1;const C=Yc(E.startDate,f);let D=Yo;const M=E.endDate;if(M)D=Yc(M,f),w=!0;else if(E.endOnNext&&!w){const x=l.reduce((O,K)=>{const B=o[K];return B.class===E.class&&B.id!==K&&B.startDate>E.startDate&&O.push(B),O},[]).sort((O,K)=>O.startDate.getTime()-K.startDate.getTime())[0];x&&(D=Yc(x.startDate,f),w=!0)}const U=Object.keys(E.attr);for(let x=0;x<U.length;x++){const O=U[x];if(!eb(O))continue;let K=T[O];if(K)w&&!A.durationKnown&&(K.endTime=D);else{let B=E.attr[O];K=new p(C,D,""),rb(O)&&(B=zb(B)),K.value={key:O,data:B},K.type=Si.dateRange,K.id=v,this.id3Track.addCue(K),T[O]=K}}r[v]={cues:T,dateRange:E,durationKnown:w}}}}class Xb{constructor(t){this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=()=>this.timeupdate(),this.hls=t,this.config=t.config,this.registerListeners()}get latency(){return this._latency||0}get maxLatency(){const{config:t,levelDetails:e}=this;return t.liveMaxLatencyDuration!==void 0?t.liveMaxLatencyDuration:e?t.liveMaxLatencyDurationCount*e.targetduration:0}get targetLatency(){const{levelDetails:t}=this;if(t===null)return null;const{holdBack:e,partHoldBack:r,targetduration:n}=t,{liveSyncDuration:o,liveSyncDurationCount:l,lowLatencyMode:d}=this.config,f=this.hls.userConfig;let p=d&&r||e;(f.liveSyncDuration||f.liveSyncDurationCount||p===0)&&(p=o!==void 0?o:l*n);const g=n,v=1;return p+Math.min(this.stallCount*v,g)}get liveSyncPosition(){const t=this.estimateLiveEdge(),e=this.targetLatency,r=this.levelDetails;if(t===null||e===null||r===null)return null;const n=r.edge,o=t-e-this.edgeStalled,l=n-r.totalduration,d=n-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(l,o),d)}get drift(){const{levelDetails:t}=this;return t===null?1:t.drift}get edgeStalled(){const{levelDetails:t}=this;if(t===null)return 0;const e=(this.config.lowLatencyMode&&t.partTarget||t.targetduration)*3;return Math.max(t.age-e,0)}get forwardBufferLength(){const{media:t,levelDetails:e}=this;if(!t||!e)return 0;const r=t.buffered.length;return(r?t.buffered.end(r-1):e.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null}registerListeners(){this.hls.on(R.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(R.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(R.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(R.ERROR,this.onError,this)}unregisterListeners(){this.hls.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(R.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(R.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(R.ERROR,this.onError,this)}onMediaAttached(t,e){this.media=e.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)}onManifestLoading(){this.levelDetails=null,this._latency=null,this.stallCount=0}onLevelUpdated(t,{details:e}){this.levelDetails=e,e.advanced&&this.timeupdate(),!e.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)}onError(t,e){var r;e.details===ut.BUFFER_STALLED_ERROR&&(this.stallCount++,(r=this.levelDetails)!=null&&r.live&&X.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))}timeupdate(){const{media:t,levelDetails:e}=this;if(!t||!e)return;this.currentTime=t.currentTime;const r=this.computeLatency();if(r===null)return;this._latency=r;const{lowLatencyMode:n,maxLiveSyncPlaybackRate:o}=this.config;if(!n||o===1)return;const l=this.targetLatency;if(l===null)return;const d=r-l,f=Math.min(this.maxLatency,l+e.targetduration),p=d<f;if(e.live&&p&&d>.05&&this.forwardBufferLength>1){const g=Math.min(2,Math.max(1,o)),v=Math.round(2/(1+Math.exp(-.75*d-this.edgeStalled))*20)/20;t.playbackRate=Math.min(g,Math.max(1,v))}else t.playbackRate!==1&&t.playbackRate!==0&&(t.playbackRate=1)}estimateLiveEdge(){const{levelDetails:t}=this;return t===null?null:t.edge+t.age}computeLatency(){const t=this.estimateLiveEdge();return t===null?null:t-this.currentTime}}const Xc=["NONE","TYPE-0","TYPE-1",null];var $a={No:"",Yes:"YES",v2:"v2"};function Zb(i,t){const{canSkipUntil:e,canSkipDateRanges:r,endSN:n}=i,o=t!==void 0?t-n:0;return e&&o<e?r?$a.v2:$a.Yes:$a.No}class Cf{constructor(t,e,r){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=t,this.part=e,this.skip=r}addDirectives(t){const e=new self.URL(t);return this.msn!==void 0&&e.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&e.searchParams.set("_HLS_part",this.part.toString()),this.skip&&e.searchParams.set("_HLS_skip",this.skip),e.href}}class Ma{constructor(t){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[t.url],this._attrs=[t.attrs],this.bitrate=t.bitrate,t.details&&(this.details=t.details),this.id=t.id||0,this.name=t.name,this.width=t.width||0,this.height=t.height||0,this.audioCodec=t.audioCodec,this.videoCodec=t.videoCodec,this.unknownCodecs=t.unknownCodecs,this.codecSet=[t.videoCodec,t.audioCodec].filter(e=>e).join(",").replace(/\.[^.,]+/g,"")}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get attrs(){return this._attrs[this._urlId]}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get uri(){return this.url[this._urlId]||""}get urlId(){return this._urlId}set urlId(t){const e=t%this.url.length;this._urlId!==e&&(this.fragmentError=0,this.loadError=0,this.details=void 0,this._urlId=e)}get audioGroupId(){var t;return(t=this.audioGroupIds)==null?void 0:t[this.urlId]}get textGroupId(){var t;return(t=this.textGroupIds)==null?void 0:t[this.urlId]}addFallback(t){this.url.push(t.url),this._attrs.push(t.attrs)}}function Zc(i,t){const e=t.startPTS;if(jt(e)){let r=0,n;t.sn>i.sn?(r=e-i.start,n=i):(r=i.start-e,n=t),n.duration!==r&&(n.duration=r)}else t.sn>i.sn?i.cc===t.cc&&i.minEndPTS?t.start=i.start+(i.minEndPTS-i.start):t.start=i.start+i.duration:t.start=Math.max(i.start-t.duration,0)}function If(i,t,e,r,n,o){r-e<=0&&(X.warn("Fragment should have a positive duration",t),r=e+t.duration,o=n+t.duration);let l=e,d=r;const f=t.startPTS,p=t.endPTS;if(jt(f)){const w=Math.abs(f-e);jt(t.deltaPTS)?t.deltaPTS=Math.max(w,t.deltaPTS):t.deltaPTS=w,l=Math.max(e,f),e=Math.min(e,f),n=Math.min(n,t.startDTS),d=Math.min(r,p),r=Math.max(r,p),o=Math.max(o,t.endDTS)}const g=e-t.start;t.start!==0&&(t.start=e),t.duration=r-t.start,t.startPTS=e,t.maxStartPTS=l,t.startDTS=n,t.endPTS=r,t.minEndPTS=d,t.endDTS=o;const v=t.sn;if(!i||v<i.startSN||v>i.endSN)return 0;let E;const A=v-i.startSN,T=i.fragments;for(T[A]=t,E=A;E>0;E--)Zc(T[E],T[E-1]);for(E=A;E<T.length-1;E++)Zc(T[E],T[E+1]);return i.fragmentHint&&Zc(T[T.length-1],i.fragmentHint),i.PTSKnown=i.alignedSliding=!0,g}function qb(i,t){let e=null;const r=i.fragments;for(let f=r.length-1;f>=0;f--){const p=r[f].initSegment;if(p){e=p;break}}i.fragmentHint&&delete i.fragmentHint.endPTS;let n=0,o;if(t4(i,t,(f,p)=>{f.relurl&&(n=f.cc-p.cc),jt(f.startPTS)&&jt(f.endPTS)&&(p.start=p.startPTS=f.startPTS,p.startDTS=f.startDTS,p.maxStartPTS=f.maxStartPTS,p.endPTS=f.endPTS,p.endDTS=f.endDTS,p.minEndPTS=f.minEndPTS,p.duration=f.endPTS-f.startPTS,p.duration&&(o=p),t.PTSKnown=t.alignedSliding=!0),p.elementaryStreams=f.elementaryStreams,p.loader=f.loader,p.stats=f.stats,p.urlId=f.urlId,f.initSegment&&(p.initSegment=f.initSegment,e=f.initSegment)}),e&&(t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments).forEach(f=>{var p;(!f.initSegment||f.initSegment.relurl===((p=e)==null?void 0:p.relurl))&&(f.initSegment=e)}),t.skippedSegments)if(t.deltaUpdateFailed=t.fragments.some(f=>!f),t.deltaUpdateFailed){X.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let f=t.skippedSegments;f--;)t.fragments.shift();t.startSN=t.fragments[0].sn,t.startCC=t.fragments[0].cc}else t.canSkipDateRanges&&(t.dateRanges=Qb(i.dateRanges,t.dateRanges,t.recentlyRemovedDateranges));const l=t.fragments;if(n){X.warn("discontinuity sliding from playlist, take drift into account");for(let f=0;f<l.length;f++)l[f].cc+=n}t.skippedSegments&&(t.startCC=t.fragments[0].cc),Jb(i.partList,t.partList,(f,p)=>{p.elementaryStreams=f.elementaryStreams,p.stats=f.stats}),o?If(t,o,o.startPTS,o.endPTS,o.startDTS,o.endDTS):xf(i,t),l.length&&(t.totalduration=t.edge-l[0].start),t.driftStartTime=i.driftStartTime,t.driftStart=i.driftStart;const d=t.advancedDateTime;if(t.advanced&&d){const f=t.edge;t.driftStart||(t.driftStartTime=d,t.driftStart=f),t.driftEndTime=d,t.driftEnd=f}else t.driftEndTime=i.driftEndTime,t.driftEnd=i.driftEnd,t.advancedDateTime=i.advancedDateTime}function Qb(i,t,e){const r=dr({},i);return e&&e.forEach(n=>{delete r[n]}),Object.keys(t).forEach(n=>{const o=new Y0(t[n].attr,r[n]);o.isValid?r[n]=o:X.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(t[n].attr)}"`)}),r}function Jb(i,t,e){if(i&&t){let r=0;for(let n=0,o=i.length;n<=o;n++){const l=i[n],d=t[n+r];l&&d&&l.index===d.index&&l.fragment.sn===d.fragment.sn?e(l,d):r--}}}function t4(i,t,e){const r=t.skippedSegments,n=Math.max(i.startSN,t.startSN)-t.startSN,o=(i.fragmentHint?1:0)+(r?t.endSN:Math.min(i.endSN,t.endSN))-t.startSN,l=t.startSN-i.startSN,d=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,f=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments;for(let p=n;p<=o;p++){const g=f[l+p];let v=d[p];r&&!v&&p<r&&(v=t.fragments[p]=g),g&&v&&e(g,v)}}function xf(i,t){const e=t.startSN+t.skippedSegments-i.startSN,r=i.fragments;e<0||e>=r.length||qc(t,r[e].start)}function qc(i,t){if(t){const e=i.fragments;for(let r=i.skippedSegments;r<e.length;r++)e[r].start+=t;i.fragmentHint&&(i.fragmentHint.start+=t)}}function e4(i,t=1/0){let e=1e3*i.targetduration;if(i.updated){const r=i.fragments,n=4;if(r.length&&e*n>t){const o=r[r.length-1].duration*1e3;o<e&&(e=o)}}else e/=2;return Math.round(e)}function r4(i,t,e){if(!(i!=null&&i.details))return null;const r=i.details;let n=r.fragments[t-r.startSN];return n||(n=r.fragmentHint,n&&n.sn===t)?n:t<r.startSN&&e&&e.sn===t?e:null}function Df(i,t,e){var r;return i!=null&&i.details?Pf((r=i.details)==null?void 0:r.partList,t,e):null}function Pf(i,t,e){if(i)for(let r=i.length;r--;){const n=i[r];if(n.index===e&&n.fragment.sn===t)return n}return null}function Xo(i){switch(i.details){case ut.FRAG_LOAD_TIMEOUT:case ut.KEY_LOAD_TIMEOUT:case ut.LEVEL_LOAD_TIMEOUT:case ut.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function Of(i,t){const e=Xo(t);return i.default[`${e?"timeout":"error"}Retry`]}function Qc(i,t){const e=i.backoff==="linear"?1:Math.pow(2,t);return Math.min(e*i.retryDelayMs,i.maxRetryDelayMs)}function $f(i){return zr(zr({},i),{errorRetry:null,timeoutRetry:null})}function Zo(i,t,e,r){return!!i&&t<i.maxNumRetry&&(i4(r)||!!e)}function i4(i){return i===0&&navigator.onLine===!1||!!i&&(i<400||i>499)}const Mf={search:function(i,t){let e=0,r=i.length-1,n=null,o=null;for(;e<=r;){n=(e+r)/2|0,o=i[n];const l=t(o);if(l>0)e=n+1;else if(l<0)r=n-1;else return o}return null}};function s4(i,t,e){if(t===null||!Array.isArray(i)||!i.length||!jt(t))return null;const r=i[0].programDateTime;if(t<(r||0))return null;const n=i[i.length-1].endProgramDateTime;if(t>=(n||0))return null;e=e||0;for(let o=0;o<i.length;++o){const l=i[o];if(n4(t,e,l))return l}return null}function Na(i,t,e=0,r=0){let n=null;if(i?n=t[i.sn-t[0].sn+1]||null:e===0&&t[0].start===0&&(n=t[0]),n&&Jc(e,r,n)===0)return n;const o=Mf.search(t,Jc.bind(null,e,r));return o&&(o!==i||!n)?o:n}function Jc(i=0,t=0,e){if(e.start<=i&&e.start+e.duration>i)return 0;const r=Math.min(t,e.duration+(e.deltaPTS?e.deltaPTS:0));return e.start+e.duration-r<=i?1:e.start-r>i&&e.start?-1:0}function n4(i,t,e){const r=Math.min(t,e.duration+(e.deltaPTS?e.deltaPTS:0))*1e3;return(e.endProgramDateTime||0)-r>i}function a4(i,t){return Mf.search(i,e=>e.cc<t?1:e.cc>t?-1:0)}const o4=3e5;var Ir={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},fi={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4};class l4{constructor(t){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=t,this.log=X.log.bind(X,"[info]:"),this.warn=X.warn.bind(X,"[warning]:"),this.error=X.error.bind(X,"[error]:"),this.registerListeners()}registerListeners(){const t=this.hls;t.on(R.ERROR,this.onError,this),t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const t=this.hls;t&&(t.off(R.ERROR,this.onError,this),t.off(R.ERROR,this.onErrorOut,this),t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}}startLoad(t){this.playlistError=0}stopLoad(){}getVariantLevelIndex(t){return(t==null?void 0:t.type)===Jt.MAIN?t.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={}}onLevelUpdated(){this.playlistError=0}onError(t,e){var r,n;if(e.fatal)return;const o=this.hls,l=e.context;switch(e.details){case ut.FRAG_LOAD_ERROR:case ut.FRAG_LOAD_TIMEOUT:case ut.KEY_LOAD_ERROR:case ut.KEY_LOAD_TIMEOUT:e.errorAction=this.getFragRetryOrSwitchAction(e);return;case ut.FRAG_PARSING_ERROR:if((r=e.frag)!=null&&r.gap){e.errorAction={action:Ir.DoNothing,flags:fi.None};return}case ut.FRAG_GAP:case ut.FRAG_DECRYPT_ERROR:{e.errorAction=this.getFragRetryOrSwitchAction(e),e.errorAction.action=Ir.SendAlternateToPenaltyBox;return}case ut.LEVEL_EMPTY_ERROR:case ut.LEVEL_PARSING_ERROR:{var d,f;const p=e.parent===Jt.MAIN?e.level:o.loadLevel;e.details===ut.LEVEL_EMPTY_ERROR&&(d=e.context)!=null&&(f=d.levelDetails)!=null&&f.live?e.errorAction=this.getPlaylistRetryOrSwitchAction(e,p):(e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,p))}return;case ut.LEVEL_LOAD_ERROR:case ut.LEVEL_LOAD_TIMEOUT:typeof(l==null?void 0:l.level)=="number"&&(e.errorAction=this.getPlaylistRetryOrSwitchAction(e,l.level));return;case ut.AUDIO_TRACK_LOAD_ERROR:case ut.AUDIO_TRACK_LOAD_TIMEOUT:case ut.SUBTITLE_LOAD_ERROR:case ut.SUBTITLE_TRACK_LOAD_TIMEOUT:if(l){const p=o.levels[o.loadLevel];if(p&&(l.type===Se.AUDIO_TRACK&&l.groupId===p.audioGroupId||l.type===Se.SUBTITLE_TRACK&&l.groupId===p.textGroupId)){e.errorAction=this.getPlaylistRetryOrSwitchAction(e,o.loadLevel),e.errorAction.action=Ir.SendAlternateToPenaltyBox,e.errorAction.flags=fi.MoveAllAlternatesMatchingHost;return}}return;case ut.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{const p=o.levels[o.loadLevel],g=p==null?void 0:p.attrs["HDCP-LEVEL"];g&&(e.errorAction={action:Ir.SendAlternateToPenaltyBox,flags:fi.MoveAllAlternatesMatchingHDCP,hdcpLevel:g})}return;case ut.BUFFER_ADD_CODEC_ERROR:case ut.REMUX_ALLOC_ERROR:e.errorAction=this.getLevelSwitchAction(e,(n=e.level)!=null?n:o.loadLevel);return;case ut.INTERNAL_EXCEPTION:case ut.BUFFER_APPENDING_ERROR:case ut.BUFFER_APPEND_ERROR:case ut.BUFFER_FULL_ERROR:case ut.LEVEL_SWITCH_ERROR:case ut.BUFFER_STALLED_ERROR:case ut.BUFFER_SEEK_OVER_HOLE:case ut.BUFFER_NUDGE_ON_STALL:e.errorAction={action:Ir.DoNothing,flags:fi.None};return}if(e.type===Qt.KEY_SYSTEM_ERROR){const p=this.getVariantLevelIndex(e.frag);e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,p);return}}getPlaylistRetryOrSwitchAction(t,e){var r;const n=this.hls,o=Of(n.config.playlistLoadPolicy,t),l=this.playlistError++,d=(r=t.response)==null?void 0:r.code;if(Zo(o,l,Xo(t),d))return{action:Ir.RetryRequest,flags:fi.None,retryConfig:o,retryCount:l};const f=this.getLevelSwitchAction(t,e);return o&&(f.retryConfig=o,f.retryCount=l),f}getFragRetryOrSwitchAction(t){const e=this.hls,r=this.getVariantLevelIndex(t.frag),n=e.levels[r],{fragLoadPolicy:o,keyLoadPolicy:l}=e.config,d=Of(t.details.startsWith("key")?l:o,t),f=e.levels.reduce((v,E)=>v+E.fragmentError,0);if(n){var p;t.details!==ut.FRAG_GAP&&n.fragmentError++;const v=(p=t.response)==null?void 0:p.code;if(Zo(d,f,Xo(t),v))return{action:Ir.RetryRequest,flags:fi.None,retryConfig:d,retryCount:f}}const g=this.getLevelSwitchAction(t,r);return d&&(g.retryConfig=d,g.retryCount=f),g}getLevelSwitchAction(t,e){const r=this.hls;e==null&&(e=r.loadLevel);const n=this.hls.levels[e];if(n&&(n.loadError++,r.autoLevelEnabled)){var o,l;let d=-1;const{levels:f,loadLevel:p,minAutoLevel:g,maxAutoLevel:v}=r,E=(o=t.frag)==null?void 0:o.type,{type:A,groupId:T}=(l=t.context)!=null?l:{};for(let w=f.length;w--;){const C=(w+p)%f.length;if(C!==p&&C>=g&&C<=v&&f[C].loadError===0){const D=f[C];if(t.details===ut.FRAG_GAP&&t.frag){const M=f[C].details;if(M){const U=Na(t.frag,M.fragments,t.frag.start);if(U!=null&&U.gap)continue}}else if(A===Se.AUDIO_TRACK&&T===D.audioGroupId||A===Se.SUBTITLE_TRACK&&T===D.textGroupId||E===Jt.AUDIO&&n.audioGroupId===D.audioGroupId||E===Jt.SUBTITLE&&n.textGroupId===D.textGroupId)continue;d=C;break}}if(d>-1&&r.loadLevel!==d)return t.levelRetry=!0,this.playlistError=0,{action:Ir.SendAlternateToPenaltyBox,flags:fi.None,nextAutoLevel:d}}return{action:Ir.SendAlternateToPenaltyBox,flags:fi.MoveAllAlternatesMatchingHost}}onErrorOut(t,e){var r;switch((r=e.errorAction)==null?void 0:r.action){case Ir.DoNothing:break;case Ir.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(e),!e.errorAction.resolved&&e.details!==ut.FRAG_GAP&&(e.fatal=!0);break}if(e.fatal){this.hls.stopLoad();return}}sendAlternateToPenaltyBox(t){const e=this.hls,r=t.errorAction;if(!r)return;const{flags:n,hdcpLevel:o,nextAutoLevel:l}=r;switch(n){case fi.None:this.switchLevel(t,l);break;case fi.MoveAllAlternatesMatchingHost:r.resolved||(r.resolved=this.redundantFailover(t));break;case fi.MoveAllAlternatesMatchingHDCP:o&&(e.maxHdcpLevel=Xc[Xc.indexOf(o)-1],r.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${e.maxHdcpLevel}" or lower`);break}r.resolved||this.switchLevel(t,l)}switchLevel(t,e){e!==void 0&&t.errorAction&&(this.warn(`switching to level ${e} after ${t.details}`),this.hls.nextAutoLevel=e,t.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)}redundantFailover(t){const{hls:e,penalizedRenditions:r}=this,n=t.parent===Jt.MAIN?t.level:e.loadLevel,o=e.levels[n],l=o.url.length,d=t.frag?t.frag.urlId:o.urlId;o.urlId===d&&(!t.frag||o.details)&&this.penalizeRendition(o,t);for(let f=1;f<l;f++){const p=(d+f)%l,g=r[p];if(!g||c4(g,t,r[d]))return this.warn(`Switching to Redundant Stream ${p+1}/${l}: "${o.url[p]}" after ${t.details}`),this.playlistError=0,e.levels.forEach(v=>{v.urlId=p}),e.nextLoadLevel=n,!0}return!1}penalizeRendition(t,e){const{penalizedRenditions:r}=this,n=r[t.urlId]||{lastErrorPerfMs:0,errors:[],details:void 0};n.lastErrorPerfMs=performance.now(),n.errors.push(e),n.details=t.details,r[t.urlId]=n}}function c4(i,t,e){if(performance.now()-i.lastErrorPerfMs>o4)return!0;const r=i.details;if(t.details===ut.FRAG_GAP&&r&&t.frag){const n=t.frag.start,o=Na(null,r.fragments,n);if(o&&!o.gap)return!0}if(e&&i.errors.length<e.errors.length){const n=i.errors[i.errors.length-1];if(r&&n.frag&&t.frag&&Math.abs(n.frag.start-t.frag.start)>r.targetduration*3)return!0}return!1}class th{constructor(t,e){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=X.log.bind(X,`${e}:`),this.warn=X.warn.bind(X,`${e}:`),this.hls=t}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){clearTimeout(this.timer),this.timer=-1}startLoad(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(t,e){const r=e==null?void 0:e.renditionReports;if(r){let n=-1;for(let o=0;o<r.length;o++){const l=r[o];let d;try{d=new self.URL(l.URI,e.url).href}catch(f){X.warn(`Could not construct new URL for Rendition Report: ${f}`),d=l.URI||""}if(d===t){n=o;break}else d===t.substring(0,d.length)&&(n=o)}if(n!==-1){const o=r[n],l=parseInt(o["LAST-MSN"])||(e==null?void 0:e.lastPartSn);let d=parseInt(o["LAST-PART"])||(e==null?void 0:e.lastPartIndex);if(this.hls.config.lowLatencyMode){const f=Math.min(e.age-e.partTarget,e.targetduration);d>=0&&f>e.partTarget&&(d+=1)}return new Cf(l,d>=0?d:void 0,$a.No)}}}loadPlaylist(t){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())}shouldLoadPlaylist(t){return this.canLoad&&!!t&&!!t.url&&(!t.details||t.details.live)}shouldReloadPlaylist(t){return this.timer===-1&&this.requestScheduled===-1&&this.shouldLoadPlaylist(t)}playlistLoaded(t,e,r){const{details:n,stats:o}=e,l=self.performance.now(),d=o.loading.first?Math.max(0,l-o.loading.first):0;if(n.advancedDateTime=Date.now()-d,n.live||r!=null&&r.live){if(n.reloaded(r),r&&this.log(`live playlist ${t} ${n.advanced?"REFRESHED "+n.lastPartSn+"-"+n.lastPartIndex:n.updated?"UPDATED":"MISSED"}`),r&&n.fragments.length>0&&qb(r,n),!this.canLoad||!n.live)return;let f,p,g;if(n.canBlockReload&&n.endSN&&n.advanced){const C=this.hls.config.lowLatencyMode,D=n.lastPartSn,M=n.endSN,U=n.lastPartIndex,x=U!==-1,O=D===M,K=C?0:U;x?(p=O?M+1:D,g=O?K:U+1):p=M+1;const B=n.age,at=B+n.ageHeader;let st=Math.min(at-n.partTarget,n.targetduration*1.5);if(st>0){if(r&&st>r.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${r.tuneInGoal} to: ${st} with playlist age: ${n.age}`),st=0;else{const J=Math.floor(st/n.targetduration);if(p+=J,g!==void 0){const kt=Math.round(st%n.targetduration/n.partTarget);g+=kt}this.log(`CDN Tune-in age: ${n.ageHeader}s last advanced ${B.toFixed(2)}s goal: ${st} skip sn ${J} to part ${g}`)}n.tuneInGoal=st}if(f=this.getDeliveryDirectives(n,e.deliveryDirectives,p,g),C||!O){this.loadPlaylist(f);return}}else(n.canBlockReload||n.canSkipUntil)&&(f=this.getDeliveryDirectives(n,e.deliveryDirectives,p,g));const v=this.hls.mainForwardBufferInfo,E=v?v.end-v.len:0,A=(n.edge-E)*1e3,T=e4(n,A);n.updated&&l>this.requestScheduled+T&&(this.requestScheduled=o.loading.start),p!==void 0&&n.canBlockReload?this.requestScheduled=o.loading.first+T-(n.partTarget*1e3||1e3):this.requestScheduled===-1||this.requestScheduled+T<l?this.requestScheduled=l:this.requestScheduled-l<=0&&(this.requestScheduled+=T);let w=this.requestScheduled-l;w=Math.max(0,w),this.log(`reload live playlist ${t} in ${Math.round(w)} ms`),this.timer=self.setTimeout(()=>this.loadPlaylist(f),w)}else this.clearTimer()}getDeliveryDirectives(t,e,r,n){let o=Zb(t,r);return e!=null&&e.skip&&t.deltaUpdateFailed&&(r=e.msn,n=e.part,o=$a.No),new Cf(r,n,o)}checkRetry(t){const e=t.details,r=Xo(t),n=t.errorAction,{action:o,retryCount:l=0,retryConfig:d}=n||{},f=!!n&&!!d&&(o===Ir.RetryRequest||!n.resolved&&o===Ir.SendAlternateToPenaltyBox);if(f){var p;if(this.requestScheduled=-1,l>=d.maxNumRetry)return!1;if(r&&(p=t.context)!=null&&p.deliveryDirectives)this.warn(`Retrying playlist loading ${l+1}/${d.maxNumRetry} after "${e}" without delivery-directives`),this.loadPlaylist();else{const g=Qc(d,l);this.timer=self.setTimeout(()=>this.loadPlaylist(),g),this.warn(`Retrying playlist loading ${l+1}/${d.maxNumRetry} after "${e}" in ${g}ms`)}t.levelRetry=!0,n.resolved=!0}return f}}let eh;class h4 extends th{constructor(t,e){super(t,"[level-controller]"),this._levels=[],this._firstLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=e,this._registerListeners()}_registerListeners(){const{hls:t}=this;t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(R.LEVEL_LOADED,this.onLevelLoaded,this),t.on(R.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(R.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(R.FRAG_LOADED,this.onFragLoaded,this),t.on(R.ERROR,this.onError,this)}_unregisterListeners(){const{hls:t}=this;t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(R.LEVEL_LOADED,this.onLevelLoaded,this),t.off(R.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(R.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(R.FRAG_LOADED,this.onFragLoaded,this),t.off(R.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}startLoad(){this._levels.forEach(t=>{t.loadError=0,t.fragmentError=0}),super.startLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[]}onManifestLoading(t,e){this.resetLevels()}onManifestLoaded(t,e){const r=[],n={};let o;e.levels.forEach(l=>{var d;const f=l.attrs;((d=l.audioCodec)==null?void 0:d.indexOf("mp4a.40.34"))!==-1&&(eh||(eh=/chrome|firefox/i.test(navigator.userAgent)),eh&&(l.audioCodec=void 0));const{AUDIO:p,CODECS:g,"FRAME-RATE":v,"PATHWAY-ID":E,RESOLUTION:A,SUBTITLES:T}=f,w=`${`${E||"."}-`}${l.bitrate}-${A}-${v}-${g}`;o=n[w],o?o.addFallback(l):(o=new Ma(l),n[w]=o,r.push(o)),qo(o,"audio",p),qo(o,"text",T)}),this.filterAndSortMediaOptions(r,e)}filterAndSortMediaOptions(t,e){let r=[],n=[],o=!1,l=!1,d=!1,f=t.filter(({audioCodec:A,videoCodec:T,width:w,height:C,unknownCodecs:D})=>(o||(o=!!(w&&C)),l||(l=!!T),d||(d=!!A),!(D!=null&&D.length)&&(!A||Wc(A,"audio"))&&(!T||Wc(T,"video"))));if((o||l)&&d&&(f=f.filter(({videoCodec:A,width:T,height:w})=>!!A||!!(T&&w))),f.length===0){Promise.resolve().then(()=>{if(this.hls){const A=new Error("no level with compatible codecs found in manifest");this.hls.trigger(R.ERROR,{type:Qt.MEDIA_ERROR,details:ut.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:e.url,error:A,reason:A.message})}});return}e.audioTracks&&(r=e.audioTracks.filter(A=>!A.audioCodec||Wc(A.audioCodec,"audio")),Nf(r)),e.subtitles&&(n=e.subtitles,Nf(n));const p=f.slice(0);f.sort((A,T)=>A.attrs["HDCP-LEVEL"]!==T.attrs["HDCP-LEVEL"]?(A.attrs["HDCP-LEVEL"]||"")>(T.attrs["HDCP-LEVEL"]||"")?1:-1:A.bitrate!==T.bitrate?A.bitrate-T.bitrate:A.attrs["FRAME-RATE"]!==T.attrs["FRAME-RATE"]?A.attrs.decimalFloatingPoint("FRAME-RATE")-T.attrs.decimalFloatingPoint("FRAME-RATE"):A.attrs.SCORE!==T.attrs.SCORE?A.attrs.decimalFloatingPoint("SCORE")-T.attrs.decimalFloatingPoint("SCORE"):o&&A.height!==T.height?A.height-T.height:0);let g=p[0];if(this.steering&&(f=this.steering.filterParsedLevels(f),f.length!==p.length)){for(let A=0;A<p.length;A++)if(p[A].pathwayId===f[0].pathwayId){g=p[A];break}}this._levels=f;for(let A=0;A<f.length;A++)if(f[A]===g){this._firstLevel=A,this.log(`manifest loaded, ${f.length} level(s) found, first bitrate: ${g.bitrate}`);break}const v=d&&!l,E={levels:f,audioTracks:r,subtitleTracks:n,sessionData:e.sessionData,sessionKeys:e.sessionKeys,firstLevel:this._firstLevel,stats:e.stats,audio:d,video:l,altAudio:!v&&r.some(A=>!!A.url)};this.hls.trigger(R.MANIFEST_PARSED,E),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}get levels(){return this._levels.length===0?null:this._levels}get level(){return this.currentLevelIndex}set level(t){const e=this._levels;if(e.length===0)return;if(t<0||t>=e.length){const g=new Error("invalid level idx"),v=t<0;if(this.hls.trigger(R.ERROR,{type:Qt.OTHER_ERROR,details:ut.LEVEL_SWITCH_ERROR,level:t,fatal:v,error:g,reason:g.message}),v)return;t=Math.min(t,e.length-1)}const r=this.currentLevelIndex,n=this.currentLevel,o=n?n.attrs["PATHWAY-ID"]:void 0,l=e[t],d=l.attrs["PATHWAY-ID"];if(this.currentLevelIndex=t,this.currentLevel=l,r===t&&l.details&&n&&o===d)return;this.log(`Switching to level ${t}${d?" with Pathway "+d:""} from level ${r}${o?" with Pathway "+o:""}`);const f=dr({},l,{level:t,maxBitrate:l.maxBitrate,attrs:l.attrs,uri:l.uri,urlId:l.urlId});delete f._attrs,delete f._urlId,this.hls.trigger(R.LEVEL_SWITCHING,f);const p=l.details;if(!p||p.live){const g=this.switchParams(l.uri,n==null?void 0:n.details);this.loadPlaylist(g)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(t){this.manualLevelIndex=t,this._startLevel===void 0&&(this._startLevel=t),t!==-1&&(this.level=t)}get firstLevel(){return this._firstLevel}set firstLevel(t){this._firstLevel=t}get startLevel(){if(this._startLevel===void 0){const t=this.hls.config.startLevel;return t!==void 0?t:this._firstLevel}else return this._startLevel}set startLevel(t){this._startLevel=t}onError(t,e){e.fatal||!e.context||e.context.type===Se.LEVEL&&e.context.level===this.level&&this.checkRetry(e)}onFragLoaded(t,{frag:e}){if(e!==void 0&&e.type===Jt.MAIN){const r=this._levels[e.level];r!==void 0&&(r.loadError=0)}}onLevelLoaded(t,e){var r;const{level:n,details:o}=e,l=this._levels[n];if(!l){var d;this.warn(`Invalid level index ${n}`),(d=e.deliveryDirectives)!=null&&d.skip&&(o.deltaUpdateFailed=!0);return}n===this.currentLevelIndex?(l.fragmentError===0&&(l.loadError=0),this.playlistLoaded(n,e,l.details)):(r=e.deliveryDirectives)!=null&&r.skip&&(o.deltaUpdateFailed=!0)}onAudioTrackSwitched(t,e){const r=this.currentLevel;if(!r)return;const n=this.hls.audioTracks[e.id].groupId;if(r.audioGroupIds&&r.audioGroupId!==n){let o=-1;for(let l=0;l<r.audioGroupIds.length;l++)if(r.audioGroupIds[l]===n){o=l;break}o!==-1&&o!==r.urlId&&(r.urlId=o,this.canLoad&&this.startLoad())}}loadPlaylist(t){super.loadPlaylist();const e=this.currentLevelIndex,r=this.currentLevel;if(r&&this.shouldLoadPlaylist(r)){const n=r.urlId;let o=r.uri;if(t)try{o=t.addDirectives(o)}catch(d){this.warn(`Could not construct new URL with HLS Delivery Directives: ${d}`)}const l=r.attrs["PATHWAY-ID"];this.log(`Loading level index ${e}${(t==null?void 0:t.msn)!==void 0?" at sn "+t.msn+" part "+t.part:""} with${l?" Pathway "+l:""} URI ${n+1}/${r.url.length} ${o}`),this.clearTimer(),this.hls.trigger(R.LEVEL_LOADING,{url:o,level:e,id:n,deliveryDirectives:t||null})}}get nextLoadLevel(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(t){this.level=t,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=t)}removeLevel(t,e){const r=(o,l)=>l!==e,n=this._levels.filter((o,l)=>l!==t?!0:o.url.length>1&&e!==void 0?(o.url=o.url.filter(r),o.audioGroupIds&&(o.audioGroupIds=o.audioGroupIds.filter(r)),o.textGroupIds&&(o.textGroupIds=o.textGroupIds.filter(r)),o.urlId=0,!0):(this.steering&&this.steering.removeLevel(o),!1));this.hls.trigger(R.LEVELS_UPDATED,{levels:n})}onLevelsUpdated(t,{levels:e}){e.forEach((r,n)=>{const{details:o}=r;o!=null&&o.fragments&&o.fragments.forEach(l=>{l.level=n})}),this._levels=e}}function qo(i,t,e){e&&(t==="audio"?(i.audioGroupIds||(i.audioGroupIds=[]),i.audioGroupIds[i.url.length-1]=e):t==="text"&&(i.textGroupIds||(i.textGroupIds=[]),i.textGroupIds[i.url.length-1]=e))}function Nf(i){const t={};i.forEach(e=>{const r=e.groupId||"";e.id=t[r]=t[r]||0,t[r]++})}var vr={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"};class d4{constructor(t){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=t,this._registerListeners()}_registerListeners(){const{hls:t}=this;t.on(R.BUFFER_APPENDED,this.onBufferAppended,this),t.on(R.FRAG_BUFFERED,this.onFragBuffered,this),t.on(R.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){const{hls:t}=this;t.off(R.BUFFER_APPENDED,this.onBufferAppended,this),t.off(R.FRAG_BUFFERED,this.onFragBuffered,this),t.off(R.FRAG_LOADED,this.onFragLoaded,this)}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(t,e){const r=this.activePartLists[e];if(r)for(let n=r.length;n--;){const o=r[n];if(!o)break;const l=o.end;if(o.start<=t&&l!==null&&t<=l)return o}return this.getBufferedFrag(t,e)}getBufferedFrag(t,e){const{fragments:r}=this,n=Object.keys(r);for(let o=n.length;o--;){const l=r[n[o]];if((l==null?void 0:l.body.type)===e&&l.buffered){const d=l.body;if(d.start<=t&&t<=d.end)return d}}return null}detectEvictedFragments(t,e,r,n){this.timeRanges&&(this.timeRanges[t]=e);const o=(n==null?void 0:n.fragment.sn)||-1;Object.keys(this.fragments).forEach(l=>{const d=this.fragments[l];if(!d||o>=d.body.sn)return;if(!d.buffered&&!d.loaded){d.body.type===r&&this.removeFragment(d.body);return}const f=d.range[t];f&&f.time.some(p=>{const g=!this.isTimeBuffered(p.startPTS,p.endPTS,e);return g&&this.removeFragment(d.body),g})})}detectPartialFragments(t){const e=this.timeRanges,{frag:r,part:n}=t;if(!e||r.sn==="initSegment")return;const o=Dn(r),l=this.fragments[o];if(!l||l.buffered&&r.gap)return;const d=!r.relurl;Object.keys(e).forEach(f=>{const p=r.elementaryStreams[f];if(!p)return;const g=e[f],v=d||p.partial===!0;l.range[f]=this.getBufferedTimes(r,n,v,g)}),l.loaded=null,Object.keys(l.range).length?(l.buffered=!0,(l.body.endList=r.endList||l.body.endList)&&(this.endListFragments[l.body.type]=l),Qo(l)||this.removeParts(r.sn-1,r.type)):this.removeFragment(l.body)}removeParts(t,e){const r=this.activePartLists[e];r&&(this.activePartLists[e]=r.filter(n=>n.fragment.sn>=t))}fragBuffered(t,e){const r=Dn(t);let n=this.fragments[r];!n&&e&&(n=this.fragments[r]={body:t,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},t.gap&&(this.hasGaps=!0)),n&&(n.loaded=null,n.buffered=!0)}getBufferedTimes(t,e,r,n){const o={time:[],partial:r},l=t.start,d=t.end,f=t.minEndPTS||d,p=t.maxStartPTS||l;for(let g=0;g<n.length;g++){const v=n.start(g)-this.bufferPadding,E=n.end(g)+this.bufferPadding;if(p>=v&&f<=E){o.time.push({startPTS:Math.max(l,n.start(g)),endPTS:Math.min(d,n.end(g))});break}else if(l<E&&d>v)o.partial=!0,o.time.push({startPTS:Math.max(l,n.start(g)),endPTS:Math.min(d,n.end(g))});else if(d<=v)break}return o}getPartialFragment(t){let e=null,r,n,o,l=0;const{bufferPadding:d,fragments:f}=this;return Object.keys(f).forEach(p=>{const g=f[p];g&&Qo(g)&&(n=g.body.start-d,o=g.body.end+d,t>=n&&t<=o&&(r=Math.min(t-n,o-t),l<=r&&(e=g.body,l=r)))}),e}isEndListAppended(t){const e=this.endListFragments[t];return e!==void 0&&(e.buffered||Qo(e))}getState(t){const e=Dn(t),r=this.fragments[e];return r?r.buffered?Qo(r)?vr.PARTIAL:vr.OK:vr.APPENDING:vr.NOT_LOADED}isTimeBuffered(t,e,r){let n,o;for(let l=0;l<r.length;l++){if(n=r.start(l)-this.bufferPadding,o=r.end(l)+this.bufferPadding,t>=n&&e<=o)return!0;if(e<=n)return!1}return!1}onFragLoaded(t,e){const{frag:r,part:n}=e;if(r.sn==="initSegment"||r.bitrateTest)return;const o=n?null:e,l=Dn(r);this.fragments[l]={body:r,appendedPTS:null,loaded:o,buffered:!1,range:Object.create(null)}}onBufferAppended(t,e){const{frag:r,part:n,timeRanges:o}=e;if(r.sn==="initSegment")return;const l=r.type;if(n){let d=this.activePartLists[l];d||(this.activePartLists[l]=d=[]),d.push(n)}this.timeRanges=o,Object.keys(o).forEach(d=>{const f=o[d];this.detectEvictedFragments(d,f,l,n)})}onFragBuffered(t,e){this.detectPartialFragments(e)}hasFragment(t){const e=Dn(t);return!!this.fragments[e]}hasParts(t){var e;return!!((e=this.activePartLists[t])!=null&&e.length)}removeFragmentsInRange(t,e,r,n,o){n&&!this.hasGaps||Object.keys(this.fragments).forEach(l=>{const d=this.fragments[l];if(!d)return;const f=d.body;f.type!==r||n&&!f.gap||f.start<e&&f.end>t&&(d.buffered||o)&&this.removeFragment(f)})}removeFragment(t){const e=Dn(t);t.stats.loaded=0,t.clearElementaryStreamInfo();const r=this.activePartLists[t.type];if(r){const n=t.sn;this.activePartLists[t.type]=r.filter(o=>o.fragment.sn!==n)}delete this.fragments[e],t.endList&&delete this.endListFragments[t.type]}removeAllFragments(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1}}function Qo(i){var t,e,r;return i.buffered&&(i.body.gap||((t=i.range.video)==null?void 0:t.partial)||((e=i.range.audio)==null?void 0:e.partial)||((r=i.range.audiovideo)==null?void 0:r.partial))}function Dn(i){return`${i.type}_${i.level}_${i.urlId}_${i.sn}`}const Ff=Math.pow(2,17);class u4{constructor(t){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=t}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(t,e){const r=t.url;if(!r)return Promise.reject(new ss({type:Qt.NETWORK_ERROR,details:ut.FRAG_LOAD_ERROR,fatal:!1,frag:t,error:new Error(`Fragment does not have a ${r?"part list":"url"}`),networkDetails:null}));this.abort();const n=this.config,o=n.fLoader,l=n.loader;return new Promise((d,f)=>{if(this.loader&&this.loader.destroy(),t.gap)if(t.tagList.some(A=>A[0]==="GAP")){f(Bf(t));return}else t.gap=!1;const p=this.loader=t.loader=o?new o(n):new l(n),g=Uf(t),v=$f(n.fragLoadPolicy.default),E={loadPolicy:v,timeout:v.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:t.sn==="initSegment"?1/0:Ff};t.stats=p.stats,p.load(g,E,{onSuccess:(A,T,w,C)=>{this.resetLoader(t,p);let D=A.data;w.resetIV&&t.decryptdata&&(t.decryptdata.iv=new Uint8Array(D.slice(0,16)),D=D.slice(16)),d({frag:t,part:null,payload:D,networkDetails:C})},onError:(A,T,w,C)=>{this.resetLoader(t,p),f(new ss({type:Qt.NETWORK_ERROR,details:ut.FRAG_LOAD_ERROR,fatal:!1,frag:t,response:zr({url:r,data:void 0},A),error:new Error(`HTTP Error ${A.code} ${A.text}`),networkDetails:w,stats:C}))},onAbort:(A,T,w)=>{this.resetLoader(t,p),f(new ss({type:Qt.NETWORK_ERROR,details:ut.INTERNAL_ABORTED,fatal:!1,frag:t,error:new Error("Aborted"),networkDetails:w,stats:A}))},onTimeout:(A,T,w)=>{this.resetLoader(t,p),f(new ss({type:Qt.NETWORK_ERROR,details:ut.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,error:new Error(`Timeout after ${E.timeout}ms`),networkDetails:w,stats:A}))},onProgress:(A,T,w,C)=>{e&&e({frag:t,part:null,payload:w,networkDetails:C})}})})}loadPart(t,e,r){this.abort();const n=this.config,o=n.fLoader,l=n.loader;return new Promise((d,f)=>{if(this.loader&&this.loader.destroy(),t.gap||e.gap){f(Bf(t,e));return}const p=this.loader=t.loader=o?new o(n):new l(n),g=Uf(t,e),v=$f(n.fragLoadPolicy.default),E={loadPolicy:v,timeout:v.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:Ff};e.stats=p.stats,p.load(g,E,{onSuccess:(A,T,w,C)=>{this.resetLoader(t,p),this.updateStatsFromPart(t,e);const D={frag:t,part:e,payload:A.data,networkDetails:C};r(D),d(D)},onError:(A,T,w,C)=>{this.resetLoader(t,p),f(new ss({type:Qt.NETWORK_ERROR,details:ut.FRAG_LOAD_ERROR,fatal:!1,frag:t,part:e,response:zr({url:g.url,data:void 0},A),error:new Error(`HTTP Error ${A.code} ${A.text}`),networkDetails:w,stats:C}))},onAbort:(A,T,w)=>{t.stats.aborted=e.stats.aborted,this.resetLoader(t,p),f(new ss({type:Qt.NETWORK_ERROR,details:ut.INTERNAL_ABORTED,fatal:!1,frag:t,part:e,error:new Error("Aborted"),networkDetails:w,stats:A}))},onTimeout:(A,T,w)=>{this.resetLoader(t,p),f(new ss({type:Qt.NETWORK_ERROR,details:ut.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,part:e,error:new Error(`Timeout after ${E.timeout}ms`),networkDetails:w,stats:A}))}})})}updateStatsFromPart(t,e){const r=t.stats,n=e.stats,o=n.total;if(r.loaded+=n.loaded,o){const f=Math.round(t.duration/e.duration),p=Math.min(Math.round(r.loaded/o),f),g=(f-p)*Math.round(r.loaded/p);r.total=r.loaded+g}else r.total=Math.max(r.loaded,r.total);const l=r.loading,d=n.loading;l.start?l.first+=d.first-d.start:(l.start=d.start,l.first=d.first),l.end=d.end}resetLoader(t,e){t.loader=null,this.loader===e&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),e.destroy()}}function Uf(i,t=null){const e=t||i,r={frag:i,part:t,responseType:"arraybuffer",url:e.url,headers:{},rangeStart:0,rangeEnd:0},n=e.byteRangeStartOffset,o=e.byteRangeEndOffset;if(jt(n)&&jt(o)){var l;let d=n,f=o;if(i.sn==="initSegment"&&((l=i.decryptdata)==null?void 0:l.method)==="AES-128"){const p=o-n;p%16&&(f=o+(16-p%16)),n!==0&&(r.resetIV=!0,d=n-16)}r.rangeStart=d,r.rangeEnd=f}return r}function Bf(i,t){const e=new Error(`GAP ${i.gap?"tag":"attribute"} found`),r={type:Qt.MEDIA_ERROR,details:ut.FRAG_GAP,fatal:!1,frag:i,error:e,networkDetails:null};return t&&(r.part=t),(t||i).stats.aborted=!0,new ss(r)}class ss extends Error{constructor(t){super(t.error.message),this.data=void 0,this.data=t}}class f4{constructor(t){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=t}abort(t){for(const e in this.keyUriToKeyInfo){const r=this.keyUriToKeyInfo[e].loader;if(r){if(t&&t!==r.context.frag.type)return;r.abort()}}}detach(){for(const t in this.keyUriToKeyInfo){const e=this.keyUriToKeyInfo[t];(e.mediaKeySessionContext||e.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[t]}}destroy(){this.detach();for(const t in this.keyUriToKeyInfo){const e=this.keyUriToKeyInfo[t].loader;e&&e.destroy()}this.keyUriToKeyInfo={}}createKeyLoadError(t,e=ut.KEY_LOAD_ERROR,r,n,o){return new ss({type:Qt.NETWORK_ERROR,details:e,fatal:!1,frag:t,response:o,error:r,networkDetails:n})}loadClear(t,e){if(this.emeController&&this.config.emeEnabled){const{sn:r,cc:n}=t;for(let o=0;o<e.length;o++){const l=e[o];if(n<=l.cc&&(r==="initSegment"||l.sn==="initSegment"||r<l.sn)){this.emeController.selectKeySystemFormat(l).then(d=>{l.setKeyFormat(d)});break}}}}load(t){return!t.decryptdata&&t.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(t).then(e=>this.loadInternal(t,e)):this.loadInternal(t)}loadInternal(t,e){var r,n;e&&t.setKeyFormat(e);const o=t.decryptdata;if(!o){const p=new Error(e?`Expected frag.decryptdata to be defined after setting format ${e}`:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(t,ut.KEY_LOAD_ERROR,p))}const l=o.uri;if(!l)return Promise.reject(this.createKeyLoadError(t,ut.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${l}"`)));let d=this.keyUriToKeyInfo[l];if((r=d)!=null&&r.decryptdata.key)return o.key=d.decryptdata.key,Promise.resolve({frag:t,keyInfo:d});if((n=d)!=null&&n.keyLoadPromise){var f;switch((f=d.mediaKeySessionContext)==null?void 0:f.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return d.keyLoadPromise.then(p=>(o.key=p.keyInfo.decryptdata.key,{frag:t,keyInfo:d}))}}switch(d=this.keyUriToKeyInfo[l]={decryptdata:o,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},o.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return o.keyFormat==="identity"?this.loadKeyHTTP(d,t):this.loadKeyEME(d,t);case"AES-128":return this.loadKeyHTTP(d,t);default:return Promise.reject(this.createKeyLoadError(t,ut.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${o.method}"`)))}}loadKeyEME(t,e){const r={frag:e,keyInfo:t};if(this.emeController&&this.config.emeEnabled){const n=this.emeController.loadKey(r);if(n)return(t.keyLoadPromise=n.then(o=>(t.mediaKeySessionContext=o,r))).catch(o=>{throw t.keyLoadPromise=null,o})}return Promise.resolve(r)}loadKeyHTTP(t,e){const r=this.config,n=r.loader,o=new n(r);return e.keyLoader=t.loader=o,t.keyLoadPromise=new Promise((l,d)=>{const f={keyInfo:t,frag:e,responseType:"arraybuffer",url:t.decryptdata.uri},p=r.keyLoadPolicy.default,g={loadPolicy:p,timeout:p.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},v={onSuccess:(E,A,T,w)=>{const{frag:C,keyInfo:D,url:M}=T;if(!C.decryptdata||D!==this.keyUriToKeyInfo[M])return d(this.createKeyLoadError(C,ut.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),w));D.decryptdata.key=C.decryptdata.key=new Uint8Array(E.data),C.keyLoader=null,D.loader=null,l({frag:C,keyInfo:D})},onError:(E,A,T,w)=>{this.resetLoader(A),d(this.createKeyLoadError(e,ut.KEY_LOAD_ERROR,new Error(`HTTP Error ${E.code} loading key ${E.text}`),T,zr({url:f.url,data:void 0},E)))},onTimeout:(E,A,T)=>{this.resetLoader(A),d(this.createKeyLoadError(e,ut.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),T))},onAbort:(E,A,T)=>{this.resetLoader(A),d(this.createKeyLoadError(e,ut.INTERNAL_ABORTED,new Error("key loading aborted"),T))}};o.load(f,g,v)})}resetLoader(t){const{frag:e,keyInfo:r,url:n}=t,o=r.loader;e.keyLoader===o&&(e.keyLoader=null,r.loader=null),delete this.keyUriToKeyInfo[n],o&&o.destroy()}}class p4{constructor(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed()}onHandlerDestroying(){this.clearNextTick(),this.clearInterval()}onHandlerDestroyed(){}hasInterval(){return!!this._tickInterval}hasNextTick(){return!!this._tickTimer}setInterval(t){return this._tickInterval?!1:(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,t),!0)}clearInterval(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1}clearNextTick(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1}tick(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}}const g4={length:0,start:()=>0,end:()=>0};class Ve{static isBuffered(t,e){try{if(t){const r=Ve.getBuffered(t);for(let n=0;n<r.length;n++)if(e>=r.start(n)&&e<=r.end(n))return!0}}catch{}return!1}static bufferInfo(t,e,r){try{if(t){const n=Ve.getBuffered(t),o=[];let l;for(l=0;l<n.length;l++)o.push({start:n.start(l),end:n.end(l)});return this.bufferedInfo(o,e,r)}}catch{}return{len:0,start:e,end:e,nextStart:void 0}}static bufferedInfo(t,e,r){e=Math.max(0,e),t.sort(function(p,g){return p.start-g.start||g.end-p.end});let n=[];if(r)for(let p=0;p<t.length;p++){const g=n.length;if(g){const v=n[g-1].end;t[p].start-v<r?t[p].end>v&&(n[g-1].end=t[p].end):n.push(t[p])}else n.push(t[p])}else n=t;let o=0,l,d=e,f=e;for(let p=0;p<n.length;p++){const g=n[p].start,v=n[p].end;if(e+r>=g&&e<v)d=g,f=v,o=f-e;else if(e+r<g){l=g;break}}return{len:o,start:d||0,end:f||0,nextStart:l}}static getBuffered(t){try{return t.buffered}catch(e){return X.log("failed to get media.buffered",e),g4}}}class rh{constructor(t,e,r,n=0,o=-1,l=!1){this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing=Jo(),this.buffering={audio:Jo(),video:Jo(),audiovideo:Jo()},this.level=t,this.sn=e,this.id=r,this.size=n,this.part=o,this.partial=l}}function Jo(){return{start:0,executeStart:0,executeEnd:0,end:0}}function Gf(i,t){let e=null;for(let r=0,n=i.length;r<n;r++){const o=i[r];if(o&&o.cc===t){e=o;break}}return e}function m4(i,t,e){return!!(t.details&&(e.endCC>e.startCC||i&&i.cc<e.startCC))}function v4(i,t,e=0){const r=i.fragments,n=t.fragments;if(!n.length||!r.length){X.log("No fragments to align");return}const o=Gf(r,n[0].cc);if(!o||o&&!o.startPTS){X.log("No frag in previous level to align on");return}return o}function Hf(i,t){if(i){const e=i.start+t;i.start=i.startPTS=e,i.endPTS=e+i.duration}}function ih(i,t){const e=t.fragments;for(let r=0,n=e.length;r<n;r++)Hf(e[r],i);t.fragmentHint&&Hf(t.fragmentHint,i),t.alignedSliding=!0}function y4(i,t,e){t&&(b4(i,e,t),!e.alignedSliding&&t.details&&E4(e,t.details),!e.alignedSliding&&t.details&&!e.skippedSegments&&xf(t.details,e))}function b4(i,t,e){if(m4(i,e,t)){const r=v4(e.details,t);r&&jt(r.start)&&(X.log(`Adjusting PTS using last level due to CC increase within current level ${t.url}`),ih(r.start,t))}}function E4(i,t){if(!t.fragments.length||!i.hasProgramDateTime||!t.hasProgramDateTime)return;const e=t.fragments[0].programDateTime,r=i.fragments[0].programDateTime,n=(r-e)/1e3+t.fragments[0].start;n&&jt(n)&&(X.log(`Adjusting PTS using programDateTime delta ${r-e}ms, sliding:${n.toFixed(3)} ${i.url} `),ih(n,i))}function Vf(i,t){if(!i.hasProgramDateTime||!t.hasProgramDateTime)return;const e=i.fragments,r=t.fragments;if(!e.length||!r.length)return;const n=Math.round(r.length/2)-1,o=r[n],l=Gf(e,o.cc)||e[Math.round(e.length/2)-1],d=o.programDateTime,f=l.programDateTime;if(d===null||f===null)return;const p=(f-d)/1e3-(l.start-o.start);ih(p,i)}class A4{constructor(t,e){this.subtle=void 0,this.aesIV=void 0,this.subtle=t,this.aesIV=e}decrypt(t,e){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},e,t)}}class T4{constructor(t,e){this.subtle=void 0,this.key=void 0,this.subtle=t,this.key=e}expandKey(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])}}function k4(i){const t=i.byteLength,e=t&&new DataView(i.buffer).getUint8(t-1);return e?un(i,0,t-e):i}class w4{constructor(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}uint8ArrayToUint32Array_(t){const e=new DataView(t),r=new Uint32Array(4);for(let n=0;n<4;n++)r[n]=e.getUint32(n*4);return r}initTable(){const t=this.sBox,e=this.invSBox,r=this.subMix,n=r[0],o=r[1],l=r[2],d=r[3],f=this.invSubMix,p=f[0],g=f[1],v=f[2],E=f[3],A=new Uint32Array(256);let T=0,w=0,C=0;for(C=0;C<256;C++)C<128?A[C]=C<<1:A[C]=C<<1^283;for(C=0;C<256;C++){let D=w^w<<1^w<<2^w<<3^w<<4;D=D>>>8^D&255^99,t[T]=D,e[D]=T;const M=A[T],U=A[M],x=A[U];let O=A[D]*257^D*16843008;n[T]=O<<24|O>>>8,o[T]=O<<16|O>>>16,l[T]=O<<8|O>>>24,d[T]=O,O=x*16843009^U*65537^M*257^T*16843008,p[D]=O<<24|O>>>8,g[D]=O<<16|O>>>16,v[D]=O<<8|O>>>24,E[D]=O,T?(T=M^A[A[A[x^M]]],w^=A[A[w]]):T=w=1}}expandKey(t){const e=this.uint8ArrayToUint32Array_(t);let r=!0,n=0;for(;n<e.length&&r;)r=e[n]===this.key[n],n++;if(r)return;this.key=e;const o=this.keySize=e.length;if(o!==4&&o!==6&&o!==8)throw new Error("Invalid aes key size="+o);const l=this.ksRows=(o+6+1)*4;let d,f;const p=this.keySchedule=new Uint32Array(l),g=this.invKeySchedule=new Uint32Array(l),v=this.sBox,E=this.rcon,A=this.invSubMix,T=A[0],w=A[1],C=A[2],D=A[3];let M,U;for(d=0;d<l;d++){if(d<o){M=p[d]=e[d];continue}U=M,d%o===0?(U=U<<8|U>>>24,U=v[U>>>24]<<24|v[U>>>16&255]<<16|v[U>>>8&255]<<8|v[U&255],U^=E[d/o|0]<<24):o>6&&d%o===4&&(U=v[U>>>24]<<24|v[U>>>16&255]<<16|v[U>>>8&255]<<8|v[U&255]),p[d]=M=(p[d-o]^U)>>>0}for(f=0;f<l;f++)d=l-f,f&3?U=p[d]:U=p[d-4],f<4||d<=4?g[f]=U:g[f]=T[v[U>>>24]]^w[v[U>>>16&255]]^C[v[U>>>8&255]]^D[v[U&255]],g[f]=g[f]>>>0}networkToHostOrderSwap(t){return t<<24|(t&65280)<<8|(t&16711680)>>8|t>>>24}decrypt(t,e,r){const n=this.keySize+6,o=this.invKeySchedule,l=this.invSBox,d=this.invSubMix,f=d[0],p=d[1],g=d[2],v=d[3],E=this.uint8ArrayToUint32Array_(r);let A=E[0],T=E[1],w=E[2],C=E[3];const D=new Int32Array(t),M=new Int32Array(D.length);let U,x,O,K,B,at,st,J,kt,ft,wt,Pt,F,j;const bt=this.networkToHostOrderSwap;for(;e<D.length;){for(kt=bt(D[e]),ft=bt(D[e+1]),wt=bt(D[e+2]),Pt=bt(D[e+3]),B=kt^o[0],at=Pt^o[1],st=wt^o[2],J=ft^o[3],F=4,j=1;j<n;j++)U=f[B>>>24]^p[at>>16&255]^g[st>>8&255]^v[J&255]^o[F],x=f[at>>>24]^p[st>>16&255]^g[J>>8&255]^v[B&255]^o[F+1],O=f[st>>>24]^p[J>>16&255]^g[B>>8&255]^v[at&255]^o[F+2],K=f[J>>>24]^p[B>>16&255]^g[at>>8&255]^v[st&255]^o[F+3],B=U,at=x,st=O,J=K,F=F+4;U=l[B>>>24]<<24^l[at>>16&255]<<16^l[st>>8&255]<<8^l[J&255]^o[F],x=l[at>>>24]<<24^l[st>>16&255]<<16^l[J>>8&255]<<8^l[B&255]^o[F+1],O=l[st>>>24]<<24^l[J>>16&255]<<16^l[B>>8&255]<<8^l[at&255]^o[F+2],K=l[J>>>24]<<24^l[B>>16&255]<<16^l[at>>8&255]<<8^l[st&255]^o[F+3],M[e]=bt(U^A),M[e+1]=bt(K^T),M[e+2]=bt(O^w),M[e+3]=bt(x^C),A=kt,T=ft,w=wt,C=Pt,e=e+4}return M.buffer}}const S4=16;class sh{constructor(t,{removePKCS7Padding:e=!0}={}){if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.useSoftware=t.enableSoftwareAES,this.removePKCS7Padding=e,e)try{const r=self.crypto;r&&(this.subtle=r.subtle||r.webkitSubtle)}catch{}this.subtle===null&&(this.useSoftware=!0)}destroy(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}isSync(){return this.useSoftware}flush(){const{currentResult:t,remainderData:e}=this;if(!t||e)return this.reset(),null;const r=new Uint8Array(t);return this.reset(),this.removePKCS7Padding?k4(r):r}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(t,e,r){return this.useSoftware?new Promise((n,o)=>{this.softwareDecrypt(new Uint8Array(t),e,r);const l=this.flush();l?n(l.buffer):o(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(t),e,r)}softwareDecrypt(t,e,r){const{currentIV:n,currentResult:o,remainderData:l}=this;this.logOnce("JS AES decrypt"),l&&(t=fn(l,t),this.remainderData=null);const d=this.getValidChunk(t);if(!d.length)return null;n&&(r=n);let f=this.softwareDecrypter;f||(f=this.softwareDecrypter=new w4),f.expandKey(e);const p=o;return this.currentResult=f.decrypt(d.buffer,0,r),this.currentIV=un(d,-16).buffer,p||null}webCryptoDecrypt(t,e,r){const n=this.subtle;return(this.key!==e||!this.fastAesKey)&&(this.key=e,this.fastAesKey=new T4(n,e)),this.fastAesKey.expandKey().then(o=>n?(this.logOnce("WebCrypto AES decrypt"),new A4(n,new Uint8Array(r)).decrypt(t.buffer,o)):Promise.reject(new Error("web crypto not initialized"))).catch(o=>(X.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${o.name}: ${o.message}`),this.onWebCryptoError(t,e,r)))}onWebCryptoError(t,e,r){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(t,e,r);const n=this.flush();if(n)return n.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(t){let e=t;const r=t.length-t.length%S4;return r!==t.length&&(e=un(t,0,r),this.remainderData=un(t,r)),e}logOnce(t){this.logEnabled&&(X.log(`[decrypter]: ${t}`),this.logEnabled=!1)}}const R4={toString:function(i){let t="";const e=i.length;for(let r=0;r<e;r++)t+=`[${i.start(r).toFixed(3)}-${i.end(r).toFixed(3)}]`;return t}},Rt={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 nh extends p4{constructor(t,e,r,n,o){super(),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=Rt.STOPPED,this.playlistType=void 0,this.media=null,this.mediaBuffer=null,this.config=void 0,this.bitrateTest=!1,this.lastCurrentTime=0,this.nextLoadPosition=0,this.startPosition=0,this.startTimeOffset=null,this.loadedmetadata=!1,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.keyLoader=void 0,this.levelLastLoaded=null,this.startFragRequested=!1,this.decrypter=void 0,this.initPTS=[],this.onvseeking=null,this.onvended=null,this.logPrefix="",this.log=void 0,this.warn=void 0,this.playlistType=o,this.logPrefix=n,this.log=X.log.bind(X,`${n}:`),this.warn=X.warn.bind(X,`${n}:`),this.hls=t,this.fragmentLoader=new u4(t.config),this.keyLoader=r,this.fragmentTracker=e,this.config=t.config,this.decrypter=new sh(t.config),t.on(R.MANIFEST_LOADED,this.onManifestLoaded,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(t){}stopLoad(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);const t=this.fragCurrent;t!=null&&t.loader&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=Rt.STOPPED}_streamEnded(t,e){if(e.live||t.nextStart||!t.end||!this.media)return!1;const r=e.partList;if(r!=null&&r.length){const o=r[r.length-1];return Ve.isBuffered(this.media,o.start+o.duration/2)}const n=e.fragments[e.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(n)}getLevelDetails(){if(this.levels&&this.levelLastLoaded!==null){var t;return(t=this.levels[this.levelLastLoaded])==null?void 0:t.details}}onMediaAttached(t,e){const r=this.media=this.mediaBuffer=e.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),r.addEventListener("seeking",this.onvseeking),r.addEventListener("ended",this.onvended);const n=this.config;this.levels&&n.autoStartLoad&&this.state===Rt.STOPPED&&this.startLoad(n.startPosition)}onMediaDetaching(){const t=this.media;t!=null&&t.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),t&&this.onvseeking&&this.onvended&&(t.removeEventListener("seeking",this.onvseeking),t.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}onMediaSeeking(){const{config:t,fragCurrent:e,media:r,mediaBuffer:n,state:o}=this,l=r?r.currentTime:0,d=Ve.bufferInfo(n||r,l,t.maxBufferHole);if(this.log(`media seeking to ${jt(l)?l.toFixed(3):l}, state: ${o}`),this.state===Rt.ENDED)this.resetLoadingState();else if(e){const f=t.maxFragLookUpTolerance,p=e.start-f,g=e.start+e.duration+f;if(!d.len||g<d.start||p>d.end){const v=l>g;(l<p||v)&&(v&&e.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),e.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}r&&(this.fragmentTracker.removeFragmentsInRange(l,1/0,this.playlistType,!0),this.lastCurrentTime=l),!this.loadedmetadata&&!d.len&&(this.nextLoadPosition=this.startPosition=l),this.tickImmediate()}onMediaEnded(){this.startPosition=this.lastCurrentTime=0}onManifestLoaded(t,e){this.startTimeOffset=e.startTimeOffset,this.initPTS=[]}onHandlerDestroying(){this.stopLoad(),super.onHandlerDestroying()}onHandlerDestroyed(){this.state=Rt.STOPPED,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,super.onHandlerDestroyed()}loadFragment(t,e,r){this._loadFragForPlayback(t,e,r)}_loadFragForPlayback(t,e,r){const n=o=>{if(this.fragContextChanged(t)){this.warn(`Fragment ${t.sn}${o.part?" p: "+o.part.index:""} of level ${t.level} was dropped during download.`),this.fragmentTracker.removeFragment(t);return}t.stats.chunkCount++,this._handleFragmentLoadProgress(o)};this._doFragLoad(t,e,r,n).then(o=>{if(!o)return;const l=this.state;if(this.fragContextChanged(t)){(l===Rt.FRAG_LOADING||!this.fragCurrent&&l===Rt.PARSING)&&(this.fragmentTracker.removeFragment(t),this.state=Rt.IDLE);return}"payload"in o&&(this.log(`Loaded fragment ${t.sn} of level ${t.level}`),this.hls.trigger(R.FRAG_LOADED,o)),this._handleFragmentLoadComplete(o)}).catch(o=>{this.state===Rt.STOPPED||this.state===Rt.ERROR||(this.warn(o),this.resetFragmentLoading(t))})}clearTrackerIfNeeded(t){var e;const{fragmentTracker:r}=this;if(r.getState(t)===vr.APPENDING){const n=t.type,o=this.getFwdBufferInfo(this.mediaBuffer,n),l=Math.max(t.duration,o?o.len:this.config.maxBufferLength);this.reduceMaxBufferLength(l)&&r.removeFragment(t)}else((e=this.mediaBuffer)==null?void 0:e.buffered.length)===0?r.removeAllFragments():r.hasParts(t.type)&&(r.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type}),r.getState(t)===vr.PARTIAL&&r.removeFragment(t))}checkLiveUpdate(t){if(t.updated&&!t.live){const e=t.fragments[t.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type})}t.fragments[0]||(t.deltaUpdateFailed=!0)}flushMainBuffer(t,e,r=null){if(!(t-e))return;const n={startOffset:t,endOffset:e,type:r};this.hls.trigger(R.BUFFER_FLUSHING,n)}_loadInitSegment(t,e){this._doFragLoad(t,e).then(r=>{if(!r||this.fragContextChanged(t)||!this.levels)throw new Error("init load aborted");return r}).then(r=>{const{hls:n}=this,{payload:o}=r,l=t.decryptdata;if(o&&o.byteLength>0&&l&&l.key&&l.iv&&l.method==="AES-128"){const d=self.performance.now();return this.decrypter.decrypt(new Uint8Array(o),l.key.buffer,l.iv.buffer).catch(f=>{throw n.trigger(R.ERROR,{type:Qt.MEDIA_ERROR,details:ut.FRAG_DECRYPT_ERROR,fatal:!1,error:f,reason:f.message,frag:t}),f}).then(f=>{const p=self.performance.now();return n.trigger(R.FRAG_DECRYPTED,{frag:t,payload:f,stats:{tstart:d,tdecrypt:p}}),r.payload=f,r})}return r}).then(r=>{const{fragCurrent:n,hls:o,levels:l}=this;if(!l)throw new Error("init load aborted, missing levels");const d=t.stats;this.state=Rt.IDLE,e.fragmentError=0,t.data=new Uint8Array(r.payload),d.parsing.start=d.buffering.start=self.performance.now(),d.parsing.end=d.buffering.end=self.performance.now(),r.frag===n&&o.trigger(R.FRAG_BUFFERED,{stats:d,frag:n,part:null,id:t.type}),this.tick()}).catch(r=>{this.state===Rt.STOPPED||this.state===Rt.ERROR||(this.warn(r),this.resetFragmentLoading(t))})}fragContextChanged(t){const{fragCurrent:e}=this;return!t||!e||t.level!==e.level||t.sn!==e.sn||t.urlId!==e.urlId}fragBufferedComplete(t,e){var r,n,o,l;const d=this.mediaBuffer?this.mediaBuffer:this.media;this.log(`Buffered ${t.type} sn: ${t.sn}${e?" part: "+e.index:""} of ${this.playlistType===Jt.MAIN?"level":"track"} ${t.level} (frag:[${((r=t.startPTS)!=null?r:NaN).toFixed(3)}-${((n=t.endPTS)!=null?n:NaN).toFixed(3)}] > buffer:${d?R4.toString(Ve.getBuffered(d)):"(detached)"})`),this.state=Rt.IDLE,d&&(!this.loadedmetadata&&t.type==Jt.MAIN&&d.buffered.length&&((o=this.fragCurrent)==null?void 0:o.sn)===((l=this.fragPrevious)==null?void 0:l.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())}seekToStartPos(){}_handleFragmentLoadComplete(t){const{transmuxer:e}=this;if(!e)return;const{frag:r,part:n,partsLoaded:o}=t,l=!o||o.length===0||o.some(f=>!f),d=new rh(r.level,r.sn,r.stats.chunkCount+1,0,n?n.index:-1,!l);e.flush(d)}_handleFragmentLoadProgress(t){}_doFragLoad(t,e,r=null,n){var o;const l=e==null?void 0:e.details;if(!this.levels||!l)throw new Error(`frag load aborted, missing level${l?"":" detail"}s`);let d=null;if(t.encrypted&&!((o=t.decryptdata)!=null&&o.key)?(this.log(`Loading key for ${t.sn} of [${l.startSN}-${l.endSN}], ${this.logPrefix==="[stream-controller]"?"level":"track"} ${t.level}`),this.state=Rt.KEY_LOADING,this.fragCurrent=t,d=this.keyLoader.load(t).then(g=>{if(!this.fragContextChanged(g.frag))return this.hls.trigger(R.KEY_LOADED,g),this.state===Rt.KEY_LOADING&&(this.state=Rt.IDLE),g}),this.hls.trigger(R.KEY_LOADING,{frag:t}),this.fragCurrent===null&&(d=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))):!t.encrypted&&l.encryptedFragments.length&&this.keyLoader.loadClear(t,l.encryptedFragments),r=Math.max(t.start,r||0),this.config.lowLatencyMode&&t.sn!=="initSegment"){const g=l.partList;if(g&&n){r>t.end&&l.fragmentHint&&(t=l.fragmentHint);const v=this.getNextPart(g,t,r);if(v>-1){const E=g[v];this.log(`Loading part sn: ${t.sn} p: ${E.index} cc: ${t.cc} of playlist [${l.startSN}-${l.endSN}] parts [0-${v}-${g.length-1}] ${this.logPrefix==="[stream-controller]"?"level":"track"}: ${t.level}, target: ${parseFloat(r.toFixed(3))}`),this.nextLoadPosition=E.start+E.duration,this.state=Rt.FRAG_LOADING;let A;return d?A=d.then(T=>!T||this.fragContextChanged(T.frag)?null:this.doFragPartsLoad(t,E,e,n)).catch(T=>this.handleFragLoadError(T)):A=this.doFragPartsLoad(t,E,e,n).catch(T=>this.handleFragLoadError(T)),this.hls.trigger(R.FRAG_LOADING,{frag:t,part:E,targetBufferTime:r}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):A}else if(!t.url||this.loadedEndOfParts(g,r))return Promise.resolve(null)}}this.log(`Loading fragment ${t.sn} cc: ${t.cc} ${l?"of ["+l.startSN+"-"+l.endSN+"] ":""}${this.logPrefix==="[stream-controller]"?"level":"track"}: ${t.level}, target: ${parseFloat(r.toFixed(3))}`),jt(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=Rt.FRAG_LOADING;const f=this.config.progressive;let p;return f&&d?p=d.then(g=>!g||this.fragContextChanged(g==null?void 0:g.frag)?null:this.fragmentLoader.load(t,n)).catch(g=>this.handleFragLoadError(g)):p=Promise.all([this.fragmentLoader.load(t,f?n:void 0),d]).then(([g])=>(!f&&g&&n&&n(g),g)).catch(g=>this.handleFragLoadError(g)),this.hls.trigger(R.FRAG_LOADING,{frag:t,targetBufferTime:r}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):p}doFragPartsLoad(t,e,r,n){return new Promise((o,l)=>{var d;const f=[],p=(d=r.details)==null?void 0:d.partList,g=v=>{this.fragmentLoader.loadPart(t,v,n).then(E=>{f[v.index]=E;const A=E.part;this.hls.trigger(R.FRAG_LOADED,E);const T=Df(r,t.sn,v.index+1)||Pf(p,t.sn,v.index+1);if(T)g(T);else return o({frag:t,part:A,partsLoaded:f})}).catch(l)};g(e)})}handleFragLoadError(t){if("data"in t){const e=t.data;t.data&&e.details===ut.INTERNAL_ABORTED?this.handleFragLoadAborted(e.frag,e.part):this.hls.trigger(R.ERROR,e)}else this.hls.trigger(R.ERROR,{type:Qt.OTHER_ERROR,details:ut.INTERNAL_EXCEPTION,err:t,error:t,fatal:!0});return null}_handleTransmuxerFlush(t){const e=this.getCurrentContext(t);if(!e||this.state!==Rt.PARSING){!this.fragCurrent&&this.state!==Rt.STOPPED&&this.state!==Rt.ERROR&&(this.state=Rt.IDLE);return}const{frag:r,part:n,level:o}=e,l=self.performance.now();r.stats.parsing.end=l,n&&(n.stats.parsing.end=l),this.updateLevelTiming(r,n,o,t.partial)}getCurrentContext(t){const{levels:e,fragCurrent:r}=this,{level:n,sn:o,part:l}=t;if(!(e!=null&&e[n]))return this.warn(`Levels object was unset while buffering fragment ${o} of level ${n}. The current chunk will not be buffered.`),null;const d=e[n],f=l>-1?Df(d,o,l):null,p=f?f.fragment:r4(d,o,r);return p?(r&&r!==p&&(p.stats=r.stats),{frag:p,part:f,level:d}):null}bufferFragmentData(t,e,r,n,o){var l;if(!t||this.state!==Rt.PARSING)return;const{data1:d,data2:f}=t;let p=d;if(d&&f&&(p=fn(d,f)),!((l=p)!=null&&l.length))return;const g={type:t.type,frag:e,part:r,chunkMeta:n,parent:e.type,data:p};if(this.hls.trigger(R.BUFFER_APPENDING,g),t.dropped&&t.independent&&!r){if(o)return;this.flushBufferGap(e)}}flushBufferGap(t){const e=this.media;if(!e)return;if(!Ve.isBuffered(e,e.currentTime)){this.flushMainBuffer(0,t.start);return}const r=e.currentTime,n=Ve.bufferInfo(e,r,0),o=t.duration,l=Math.min(this.config.maxFragLookUpTolerance*2,o*.25),d=Math.max(Math.min(t.start-l,n.end-l),r+l);t.start-d>l&&this.flushMainBuffer(d,t.start)}getFwdBufferInfo(t,e){const r=this.getLoadPosition();return jt(r)?this.getFwdBufferInfoAtPos(t,r,e):null}getFwdBufferInfoAtPos(t,e,r){const{config:{maxBufferHole:n}}=this,o=Ve.bufferInfo(t,e,n);if(o.len===0&&o.nextStart!==void 0){const l=this.fragmentTracker.getBufferedFrag(e,r);if(l&&o.nextStart<l.end)return Ve.bufferInfo(t,e,Math.max(o.nextStart,n))}return o}getMaxBufferLength(t){const{config:e}=this;let r;return t?r=Math.max(8*e.maxBufferSize/t,e.maxBufferLength):r=e.maxBufferLength,Math.min(r,e.maxMaxBufferLength)}reduceMaxBufferLength(t){const e=this.config,r=t||e.maxBufferLength;return e.maxMaxBufferLength>=r?(e.maxMaxBufferLength/=2,this.warn(`Reduce max buffer length to ${e.maxMaxBufferLength}s`),!0):!1}getAppendedFrag(t,e=Jt.MAIN){const r=this.fragmentTracker.getAppendedFrag(t,Jt.MAIN);return r&&"fragment"in r?r.fragment:r}getNextFragment(t,e){const r=e.fragments,n=r.length;if(!n)return null;const{config:o}=this,l=r[0].start;let d;if(e.live){const f=o.initialLiveManifestSize;if(n<f)return this.warn(`Not enough fragments to start playback (have: ${n}, need: ${f})`),null;!e.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(d=this.getInitialLiveFragment(e,r),this.startPosition=d?this.hls.liveSyncPosition||d.start:t)}else t<=l&&(d=r[0]);if(!d){const f=o.lowLatencyMode?e.partEnd:e.fragmentEnd;d=this.getFragmentAtPosition(t,f,e)}return this.mapToInitFragWhenRequired(d)}isLoopLoading(t,e){const r=this.fragmentTracker.getState(t);return(r===vr.OK||r===vr.PARTIAL&&!!t.gap)&&this.nextLoadPosition>e}getNextFragmentLoopLoading(t,e,r,n,o){const l=t.gap,d=this.getNextFragment(this.nextLoadPosition,e);if(d===null)return d;if(t=d,l&&t&&!t.gap&&r.nextStart){const f=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,r.nextStart,n);if(f!==null&&r.len+f.len>=o)return this.log(`buffer full after gaps in "${n}" playlist starting at sn: ${t.sn}`),null}return t}mapToInitFragWhenRequired(t){return t!=null&&t.initSegment&&!(t!=null&&t.initSegment.data)&&!this.bitrateTest?t.initSegment:t}getNextPart(t,e,r){let n=-1,o=!1,l=!0;for(let d=0,f=t.length;d<f;d++){const p=t[d];if(l=l&&!p.independent,n>-1&&r<p.start)break;const g=p.loaded;g?n=-1:(o||p.independent||l)&&p.fragment===e&&(n=d),o=g}return n}loadedEndOfParts(t,e){const r=t[t.length-1];return r&&e>r.start&&r.loaded}getInitialLiveFragment(t,e){const r=this.fragPrevious;let n=null;if(r){if(t.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${r.programDateTime}`),n=s4(e,r.endProgramDateTime,this.config.maxFragLookUpTolerance)),!n){const o=r.sn+1;if(o>=t.startSN&&o<=t.endSN){const l=e[o-t.startSN];r.cc===l.cc&&(n=l,this.log(`Live playlist, switching playlist, load frag with next SN: ${n.sn}`))}n||(n=a4(e,r.cc),n&&this.log(`Live playlist, switching playlist, load frag with same CC: ${n.sn}`))}}else{const o=this.hls.liveSyncPosition;o!==null&&(n=this.getFragmentAtPosition(o,this.bitrateTest?t.fragmentEnd:t.edge,t))}return n}getFragmentAtPosition(t,e,r){const{config:n}=this;let{fragPrevious:o}=this,{fragments:l,endSN:d}=r;const{fragmentHint:f}=r,p=n.maxFragLookUpTolerance,g=r.partList,v=!!(n.lowLatencyMode&&g!=null&&g.length&&f);v&&f&&!this.bitrateTest&&(l=l.concat(f),d=f.sn);let E;if(t<e){const A=t>e-p?0:p;E=Na(o,l,t,A)}else E=l[l.length-1];if(E){const A=E.sn-r.startSN,T=this.fragmentTracker.getState(E);if((T===vr.OK||T===vr.PARTIAL&&E.gap)&&(o=E),o&&E.sn===o.sn&&(!v||g[0].fragment.sn>E.sn)&&o&&E.level===o.level){const w=l[A+1];E.sn<d&&this.fragmentTracker.getState(w)!==vr.OK?E=w:E=null}}return E}synchronizeToLiveEdge(t){const{config:e,media:r}=this;if(!r)return;const n=this.hls.liveSyncPosition,o=r.currentTime,l=t.fragments[0].start,d=t.edge,f=o>=l-e.maxFragLookUpTolerance&&o<=d;if(n!==null&&r.duration>n&&(o<n||!f)){const p=e.liveMaxLatencyDuration!==void 0?e.liveMaxLatencyDuration:e.liveMaxLatencyDurationCount*t.targetduration;(!f&&r.readyState<4||o<d-p)&&(this.loadedmetadata||(this.nextLoadPosition=n),r.readyState&&(this.warn(`Playback: ${o.toFixed(3)} is located too far from the end of live sliding playlist: ${d}, reset currentTime to : ${n.toFixed(3)}`),r.currentTime=n))}}alignPlaylists(t,e){const{levels:r,levelLastLoaded:n,fragPrevious:o}=this,l=n!==null?r[n]:null,d=t.fragments.length;if(!d)return this.warn("No fragments in live playlist"),0;const f=t.fragments[0].start,p=!e,g=t.alignedSliding&&jt(f);if(p||!g&&!f){y4(o,l,t);const v=t.fragments[0].start;return this.log(`Live playlist sliding: ${v.toFixed(2)} start-sn: ${e?e.startSN:"na"}->${t.startSN} prev-sn: ${o?o.sn:"na"} fragments: ${d}`),v}return f}waitForCdnTuneIn(t){return t.live&&t.canBlockReload&&t.partTarget&&t.tuneInGoal>Math.max(t.partHoldBack,t.partTarget*3)}setStartPosition(t,e){let r=this.startPosition;if(r<e&&(r=-1),r===-1||this.lastCurrentTime===-1){const n=this.startTimeOffset!==null,o=n?this.startTimeOffset:t.startTimeOffset;o!==null&&jt(o)?(r=e+o,o<0&&(r+=t.totalduration),r=Math.min(Math.max(e,r),e+t.totalduration),this.log(`Start time offset ${o} found in ${n?"multivariant":"media"} playlist, adjust startPosition to ${r}`),this.startPosition=r):t.live?r=this.hls.liveSyncPosition||e:this.startPosition=r=0,this.lastCurrentTime=r}this.nextLoadPosition=r}getLoadPosition(){const{media:t}=this;let e=0;return this.loadedmetadata&&t?e=t.currentTime:this.nextLoadPosition&&(e=this.nextLoadPosition),e}handleFragLoadAborted(t,e){this.transmuxer&&t.sn!=="initSegment"&&t.stats.aborted&&(this.warn(`Fragment ${t.sn}${e?" part "+e.index:""} of level ${t.level} was aborted`),this.resetFragmentLoading(t))}resetFragmentLoading(t){(!this.fragCurrent||!this.fragContextChanged(t)&&this.state!==Rt.FRAG_LOADING_WAITING_RETRY)&&(this.state=Rt.IDLE)}onFragmentOrKeyLoadError(t,e){if(e.chunkMeta&&!e.frag){const v=this.getCurrentContext(e.chunkMeta);v&&(e.frag=v.frag)}const r=e.frag;if(!r||r.type!==t||!this.levels)return;if(this.fragContextChanged(r)){var n;this.warn(`Frag load error must match current frag to retry ${r.url} > ${(n=this.fragCurrent)==null?void 0:n.url}`);return}const o=e.details===ut.FRAG_GAP;o&&this.fragmentTracker.fragBuffered(r,!0);const l=e.errorAction,{action:d,retryCount:f=0,retryConfig:p}=l||{};if(l&&d===Ir.RetryRequest&&p){var g;this.resetStartWhenNotLoaded((g=this.levelLastLoaded)!=null?g:r.level);const v=Qc(p,f);this.warn(`Fragment ${r.sn} of ${t} ${r.level} errored with ${e.details}, retrying loading ${f+1}/${p.maxNumRetry} in ${v}ms`),l.resolved=!0,this.retryDate=self.performance.now()+v,this.state=Rt.FRAG_LOADING_WAITING_RETRY}else p&&l?(this.resetFragmentErrors(t),f<p.maxNumRetry?o||(l.resolved=!0):X.warn(`${e.details} reached or exceeded max retry (${f})`)):(l==null?void 0:l.action)===Ir.SendAlternateToPenaltyBox?this.state=Rt.WAITING_LEVEL:this.state=Rt.ERROR;this.tickImmediate()}reduceLengthAndFlushBuffer(t){if(this.state===Rt.PARSING||this.state===Rt.PARSED){const e=t.parent,r=this.getFwdBufferInfo(this.mediaBuffer,e),n=r&&r.len>.5;n&&this.reduceMaxBufferLength(r.len);const o=!n;return o&&this.warn(`Buffer full error while media.currentTime is not buffered, flush ${e} buffer`),t.frag&&(this.fragmentTracker.removeFragment(t.frag),this.nextLoadPosition=t.frag.start),this.resetLoadingState(),o}return!1}resetFragmentErrors(t){t===Jt.AUDIO&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==Rt.STOPPED&&(this.state=Rt.IDLE)}afterBufferFlushed(t,e,r){if(!t)return;const n=Ve.getBuffered(t);this.fragmentTracker.detectEvictedFragments(e,n,r),this.state===Rt.ENDED&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=Rt.IDLE}resetStartWhenNotLoaded(t){if(!this.loadedmetadata){this.startFragRequested=!1;const e=this.levels?this.levels[t].details:null;e!=null&&e.live?(this.startPosition=-1,this.setStartPosition(e,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(t){var e;this.warn(`The loading context changed while buffering fragment ${t.sn} of level ${t.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded((e=this.levelLastLoaded)!=null?e:t.level),this.resetLoadingState()}removeUnbufferedFrags(t=0){this.fragmentTracker.removeFragmentsInRange(t,1/0,this.playlistType,!1,!0)}updateLevelTiming(t,e,r,n){var o;const l=r.details;if(!l){this.warn("level.details undefined");return}if(Object.keys(t.elementaryStreams).reduce((d,f)=>{const p=t.elementaryStreams[f];if(p){const g=p.endPTS-p.startPTS;if(g<=0)return this.warn(`Could not parse fragment ${t.sn} ${f} duration reliably (${g})`),d||!1;const v=n?0:If(l,t,p.startPTS,p.endPTS,p.startDTS,p.endDTS);return this.hls.trigger(R.LEVEL_PTS_UPDATED,{details:l,level:r,drift:v,type:f,frag:t,start:p.startPTS,end:p.endPTS}),!0}return d},!1))r.fragmentError=0;else if(((o=this.transmuxer)==null?void 0:o.error)===null){const d=new Error(`Found no media in fragment ${t.sn} of level ${t.level} resetting transmuxer to fallback to playlist timing`);if(r.fragmentError===0&&(r.fragmentError++,t.gap=!0,this.fragmentTracker.removeFragment(t),this.fragmentTracker.fragBuffered(t,!0)),this.warn(d.message),this.hls.trigger(R.ERROR,{type:Qt.MEDIA_ERROR,details:ut.FRAG_PARSING_ERROR,fatal:!1,error:d,frag:t,reason:`Found no media in msn ${t.sn} of level "${r.url}"`}),!this.hls)return;this.resetTransmuxer()}this.state=Rt.PARSED,this.hls.trigger(R.FRAG_PARSED,{frag:t,part:e})}resetTransmuxer(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)}recoverWorkerError(t){if(t.event==="demuxerWorker"){var e,r,n;this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded((e=(r=this.levelLastLoaded)!=null?r:(n=this.fragCurrent)==null?void 0:n.level)!=null?e:0),this.resetLoadingState()}}set state(t){const e=this._state;e!==t&&(this._state=t,this.log(`${e}->${t}`))}get state(){return this._state}}function Wf(){return self.SourceBuffer||self.WebKitSourceBuffer}function _4(){const i=zo();if(!i)return!1;const t=Wf(),e=i&&typeof i.isTypeSupported=="function"&&i.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),r=!t||t.prototype&&typeof t.prototype.appendBuffer=="function"&&typeof t.prototype.remove=="function";return!!e&&!!r}function L4(){var i;const t=Wf();return typeof(t==null||(i=t.prototype)==null?void 0:i.changeType)=="function"}function C4(){return typeof __HLS_WORKER_BUNDLE__=="function"}function I4(){const i=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),t=self.URL.createObjectURL(i);return{worker:new self.Worker(t),objectURL:t}}function x4(i){const t=new self.URL(i,self.location.href).href;return{worker:new self.Worker(t),scriptURL:t}}function Bi(i="",t=9e4){return{type:i,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}class jf{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(t,e,r,n){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(t){this.initPTS=t,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(t,e){return!1}appendFrame(t,e,r){}demux(t,e){this.cachedData&&(t=fn(this.cachedData,t),this.cachedData=null);let r=Vo(t,0),n=r?r.length:0,o;const l=this._audioTrack,d=this._id3Track,f=r?fb(r):void 0,p=t.length;for((this.basePTS===null||this.frameIndex===0&&jt(f))&&(this.basePTS=D4(f,e,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),r&&r.length>0&&d.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:Si.audioId3,duration:Number.POSITIVE_INFINITY});n<p;){if(this.canParse(t,n)){const g=this.appendFrame(l,t,n);g?(this.frameIndex++,this.lastPTS=g.sample.pts,n+=g.length,o=n):n=p}else ub(t,n)?(r=Vo(t,n),d.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:Si.audioId3,duration:Number.POSITIVE_INFINITY}),n+=r.length,o=n):n++;if(n===p&&o!==p){const g=un(t,o);this.cachedData?this.cachedData=fn(this.cachedData,g):this.cachedData=g}}return{audioTrack:l,videoTrack:Bi(),id3Track:d,textTrack:Bi()}}demuxSampleAes(t,e,r){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(t){const e=this.cachedData;return e&&(this.cachedData=null,this.demux(e,0)),{audioTrack:this._audioTrack,videoTrack:Bi(),id3Track:this._id3Track,textTrack:Bi()}}destroy(){}}const D4=(i,t,e)=>{if(jt(i))return i*90;const r=e?e.baseTime*9e4/e.timescale:0;return t*9e4+r};function P4(i,t,e,r){let n,o,l,d;const f=navigator.userAgent.toLowerCase(),p=r,g=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];n=((t[e+2]&192)>>>6)+1;const v=(t[e+2]&60)>>>2;if(v>g.length-1){i.trigger(R.ERROR,{type:Qt.MEDIA_ERROR,details:ut.FRAG_PARSING_ERROR,fatal:!0,reason:`invalid ADTS sampling index:${v}`});return}return l=(t[e+2]&1)<<2,l|=(t[e+3]&192)>>>6,X.log(`manifest codec:${r}, ADTS type:${n}, samplingIndex:${v}`),/firefox/i.test(f)?v>=6?(n=5,d=new Array(4),o=v-3):(n=2,d=new Array(2),o=v):f.indexOf("android")!==-1?(n=2,d=new Array(2),o=v):(n=5,d=new Array(4),r&&(r.indexOf("mp4a.40.29")!==-1||r.indexOf("mp4a.40.5")!==-1)||!r&&v>=6?o=v-3:((r&&r.indexOf("mp4a.40.2")!==-1&&(v>=6&&l===1||/vivaldi/i.test(f))||!r&&l===1)&&(n=2,d=new Array(2)),o=v)),d[0]=n<<3,d[0]|=(v&14)>>1,d[1]|=(v&1)<<7,d[1]|=l<<3,n===5&&(d[1]|=(o&14)>>1,d[2]=(o&1)<<7,d[2]|=8,d[3]=0),{config:d,samplerate:g[v],channelCount:l,codec:"mp4a.40."+n,manifestCodec:p}}function Kf(i,t){return i[t]===255&&(i[t+1]&246)===240}function zf(i,t){return i[t+1]&1?7:9}function ah(i,t){return(i[t+3]&3)<<11|i[t+4]<<3|(i[t+5]&224)>>>5}function O4(i,t){return t+5<i.length}function tl(i,t){return t+1<i.length&&Kf(i,t)}function $4(i,t){return O4(i,t)&&Kf(i,t)&&ah(i,t)<=i.length-t}function M4(i,t){if(tl(i,t)){const e=zf(i,t);if(t+e>=i.length)return!1;const r=ah(i,t);if(r<=e)return!1;const n=t+r;return n===i.length||tl(i,n)}return!1}function Yf(i,t,e,r,n){if(!i.samplerate){const o=P4(t,e,r,n);if(!o)return;i.config=o.config,i.samplerate=o.samplerate,i.channelCount=o.channelCount,i.codec=o.codec,i.manifestCodec=o.manifestCodec,X.log(`parsed codec:${i.codec}, rate:${o.samplerate}, channels:${o.channelCount}`)}}function Xf(i){return 9216e4/i}function N4(i,t){const e=zf(i,t);if(t+e<=i.length){const r=ah(i,t)-e;if(r>0)return{headerLength:e,frameLength:r}}}function Zf(i,t,e,r,n){const o=Xf(i.samplerate),l=r+n*o,d=N4(t,e);let f;if(d){const{frameLength:g,headerLength:v}=d,E=v+g,A=Math.max(0,e+E-t.length);A?(f=new Uint8Array(E-v),f.set(t.subarray(e+v,t.length),0)):f=t.subarray(e+v,e+E);const T={unit:f,pts:l};return A||i.samples.push(T),{sample:T,length:E,missing:A}}const p=t.length-e;return f=new Uint8Array(p),f.set(t.subarray(e,t.length),0),{sample:{unit:f,pts:l},length:p,missing:-1}}class F4 extends jf{constructor(t,e){super(),this.observer=void 0,this.config=void 0,this.observer=t,this.config=e}resetInitSegment(t,e,r,n){super.resetInitSegment(t,e,r,n),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:e,duration:n,inputTimeScale:9e4,dropped:0}}static probe(t){if(!t)return!1;let e=(Vo(t,0)||[]).length;for(let r=t.length;e<r;e++)if(M4(t,e))return X.log("ADTS sync word found !"),!0;return!1}canParse(t,e){return $4(t,e)}appendFrame(t,e,r){Yf(t,this.observer,e,r,t.manifestCodec);const n=Zf(t,e,r,this.basePTS,this.frameIndex);if(n&&n.missing===0)return n}}const U4=/\/emsg[-/]ID3/i;class B4{constructor(t,e){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=e}resetTimeStamp(){}resetInitSegment(t,e,r,n){const o=this.videoTrack=Bi("video",1),l=this.audioTrack=Bi("audio",1),d=this.txtTrack=Bi("text",1);if(this.id3Track=Bi("id3",1),this.timeOffset=0,!(t!=null&&t.byteLength))return;const f=lf(t);if(f.video){const{id:p,timescale:g,codec:v}=f.video;o.id=p,o.timescale=d.timescale=g,o.codec=v}if(f.audio){const{id:p,timescale:g,codec:v}=f.audio;l.id=p,l.timescale=g,l.codec=v}d.id=nf.text,o.sampleDuration=0,o.duration=l.duration=n}resetContiguity(){this.remainderData=null}static probe(t){return t=t.length>16384?t.subarray(0,16384):t,Te(t,["moof"]).length>0}demux(t,e){this.timeOffset=e;let r=t;const n=this.videoTrack,o=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=fn(this.remainderData,t));const d=Lb(r);this.remainderData=d.remainder,n.samples=d.valid||new Uint8Array}else n.samples=r;const l=this.extractID3Track(n,e);return o.samples=hf(e,n),{videoTrack:n,audioTrack:this.audioTrack,id3Track:l,textTrack:this.txtTrack}}flush(){const t=this.timeOffset,e=this.videoTrack,r=this.txtTrack;e.samples=this.remainderData||new Uint8Array,this.remainderData=null;const n=this.extractID3Track(e,this.timeOffset);return r.samples=hf(t,e),{videoTrack:e,audioTrack:Bi(),id3Track:n,textTrack:Bi()}}extractID3Track(t,e){const r=this.id3Track;if(t.samples.length){const n=Te(t.samples,["emsg"]);n&&n.forEach(o=>{const l=xb(o);if(U4.test(l.schemeIdUri)){const d=jt(l.presentationTime)?l.presentationTime/l.timeScale:e+l.presentationTimeDelta/l.timeScale;let f=l.eventDuration===4294967295?Number.POSITIVE_INFINITY:l.eventDuration/l.timeScale;f<=.001&&(f=Number.POSITIVE_INFINITY);const p=l.payload;r.samples.push({data:p,len:p.byteLength,dts:d,pts:d,type:Si.emsg,duration:f})}})}return r}demuxSampleAes(t,e,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){}}let el=null;const G4=[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],H4=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],V4=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],W4=[0,1,1,4];function qf(i,t,e,r,n){if(e+24>t.length)return;const o=Qf(t,e);if(o&&e+o.frameLength<=t.length){const l=o.samplesPerFrame*9e4/o.sampleRate,d=r+n*l,f={unit:t.subarray(e,e+o.frameLength),pts:d,dts:d};return i.config=[],i.channelCount=o.channelCount,i.samplerate=o.sampleRate,i.samples.push(f),{sample:f,length:o.frameLength,missing:0}}}function Qf(i,t){const e=i[t+1]>>3&3,r=i[t+1]>>1&3,n=i[t+2]>>4&15,o=i[t+2]>>2&3;if(e!==1&&n!==0&&n!==15&&o!==3){const l=i[t+2]>>1&1,d=i[t+3]>>6,f=e===3?3-r:r===3?3:4,p=G4[f*14+n-1]*1e3,g=H4[(e===3?0:e===2?1:2)*3+o],v=d===3?1:2,E=V4[e][r],A=W4[r],T=E*8*A,w=Math.floor(E*p/g+l)*A;if(el===null){const C=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);el=C?parseInt(C[1]):0}return el&&el<=87&&r===2&&p>=224e3&&d===0&&(i[t+3]=i[t+3]|128),{sampleRate:g,channelCount:v,frameLength:w,samplesPerFrame:T}}}function oh(i,t){return i[t]===255&&(i[t+1]&224)===224&&(i[t+1]&6)!==0}function Jf(i,t){return t+1<i.length&&oh(i,t)}function j4(i,t){return oh(i,t)&&4<=i.length-t}function K4(i,t){if(t+1<i.length&&oh(i,t)){const e=Qf(i,t);let r=4;e!=null&&e.frameLength&&(r=e.frameLength);const n=t+r;return n===i.length||Jf(i,n)}return!1}class tp{constructor(t){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=t,this.bytesAvailable=t.byteLength,this.word=0,this.bitsAvailable=0}loadWord(){const t=this.data,e=this.bytesAvailable,r=t.byteLength-e,n=new Uint8Array(4),o=Math.min(4,e);if(o===0)throw new Error("no bytes available");n.set(t.subarray(r,r+o)),this.word=new DataView(n.buffer).getUint32(0),this.bitsAvailable=o*8,this.bytesAvailable-=o}skipBits(t){let e;t=Math.min(t,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>t?(this.word<<=t,this.bitsAvailable-=t):(t-=this.bitsAvailable,e=t>>3,t-=e<<3,this.bytesAvailable-=e,this.loadWord(),this.word<<=t,this.bitsAvailable-=t)}readBits(t){let e=Math.min(this.bitsAvailable,t);const r=this.word>>>32-e;if(t>32&&X.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=e,this.bitsAvailable>0)this.word<<=e;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");return e=t-e,e>0&&this.bitsAvailable?r<<e|this.readBits(e):r}skipLZ(){let t;for(t=0;t<this.bitsAvailable;++t)if(this.word&2147483648>>>t)return this.word<<=t,this.bitsAvailable-=t,t;return this.loadWord(),t+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){const t=this.skipLZ();return this.readBits(t+1)-1}readEG(){const t=this.readUEG();return 1&t?1+t>>>1:-1*(t>>>1)}readBoolean(){return this.readBits(1)===1}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}skipScalingList(t){let e=8,r=8,n;for(let o=0;o<t;o++)r!==0&&(n=this.readEG(),r=(e+n+256)%256),e=r===0?e:r}readSPS(){let t=0,e=0,r=0,n=0,o,l,d;const f=this.readUByte.bind(this),p=this.readBits.bind(this),g=this.readUEG.bind(this),v=this.readBoolean.bind(this),E=this.skipBits.bind(this),A=this.skipEG.bind(this),T=this.skipUEG.bind(this),w=this.skipScalingList.bind(this);f();const C=f();if(p(5),E(3),f(),T(),C===100||C===110||C===122||C===244||C===44||C===83||C===86||C===118||C===128){const K=g();if(K===3&&E(1),T(),T(),E(1),v())for(l=K!==3?8:12,d=0;d<l;d++)v()&&(d<6?w(16):w(64))}T();const D=g();if(D===0)g();else if(D===1)for(E(1),A(),A(),o=g(),d=0;d<o;d++)A();T(),E(1);const M=g(),U=g(),x=p(1);x===0&&E(1),E(1),v()&&(t=g(),e=g(),r=g(),n=g());let O=[1,1];if(v()&&v())switch(f()){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=[f()<<8|f(),f()<<8|f()];break}}return{width:Math.ceil((M+1)*16-t*2-e*2),height:(2-x)*(U+1)*16-(x?2:4)*(r+n),pixelRatio:O}}readSliceType(){return this.readUByte(),this.readUEG(),this.readUEG()}}class z4{constructor(t,e,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new sh(e,{removePKCS7Padding:!1})}decryptBuffer(t){return this.decrypter.decrypt(t,this.keyData.key.buffer,this.keyData.iv.buffer)}decryptAacSample(t,e,r){const n=t[e].unit;if(n.length<=16)return;const o=n.subarray(16,n.length-n.length%16),l=o.buffer.slice(o.byteOffset,o.byteOffset+o.length);this.decryptBuffer(l).then(d=>{const f=new Uint8Array(d);n.set(f,16),this.decrypter.isSync()||this.decryptAacSamples(t,e+1,r)})}decryptAacSamples(t,e,r){for(;;e++){if(e>=t.length){r();return}if(!(t[e].unit.length<32)&&(this.decryptAacSample(t,e,r),!this.decrypter.isSync()))return}}getAvcEncryptedData(t){const e=Math.floor((t.length-48)/160)*16+16,r=new Int8Array(e);let n=0;for(let o=32;o<t.length-16;o+=160,n+=16)r.set(t.subarray(o,o+16),n);return r}getAvcDecryptedUnit(t,e){const r=new Uint8Array(e);let n=0;for(let o=32;o<t.length-16;o+=160,n+=16)t.set(r.subarray(n,n+16),o);return t}decryptAvcSample(t,e,r,n,o){const l=uf(o.data),d=this.getAvcEncryptedData(l);this.decryptBuffer(d.buffer).then(f=>{o.data=this.getAvcDecryptedUnit(l,f),this.decrypter.isSync()||this.decryptAvcSamples(t,e,r+1,n)})}decryptAvcSamples(t,e,r,n){if(t instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;e++,r=0){if(e>=t.length){n();return}const o=t[e].units;for(;!(r>=o.length);r++){const l=o[r];if(!(l.data.length<=48||l.type!==1&&l.type!==5)&&(this.decryptAvcSample(t,e,r,n,l),!this.decrypter.isSync()))return}}}}const xr=188;class Ls{constructor(t,e,r){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=t,this.config=e,this.typeSupported=r}static probe(t){const e=Ls.syncOffset(t);return e>0&&X.warn(`MPEG2-TS detected but first sync word found @ offset ${e}`),e!==-1}static syncOffset(t){const e=t.length;let r=Math.min(xr*5,t.length-xr)+1,n=0;for(;n<r;){let o=!1,l=-1,d=0;for(let f=n;f<e;f+=xr)if(t[f]===71){if(d++,l===-1&&(l=f,l!==0&&(r=Math.min(l+xr*99,t.length-xr)+1)),o||(o=lh(t,f)===0),o&&d>1&&(l===0&&d>2||f+xr>r))return l}else{if(d)return-1;break}n++}return-1}static createTrack(t,e){return{container:t==="video"||t==="audio"?"video/mp2t":void 0,type:t,id:nf[t],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:t==="audio"?e:void 0}}resetInitSegment(t,e,r,n){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=Ls.createTrack("video"),this._audioTrack=Ls.createTrack("audio",n),this._id3Track=Ls.createTrack("id3"),this._txtTrack=Ls.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=e,this.videoCodec=r,this._duration=n}resetTimeStamp(){}resetContiguity(){const{_audioTrack:t,_avcTrack:e,_id3Track:r}=this;t&&(t.pesData=null),e&&(e.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null}demux(t,e,r=!1,n=!1){r||(this.sampleAes=null);let o;const l=this._avcTrack,d=this._audioTrack,f=this._id3Track,p=this._txtTrack;let g=l.pid,v=l.pesData,E=d.pid,A=f.pid,T=d.pesData,w=f.pesData,C=null,D=this.pmtParsed,M=this._pmtId,U=t.length;if(this.remainderData&&(t=fn(this.remainderData,t),U=t.length,this.remainderData=null),U<xr&&!n)return this.remainderData=t,{audioTrack:d,videoTrack:l,id3Track:f,textTrack:p};const x=Math.max(0,Ls.syncOffset(t));U-=(U-x)%xr,U<t.byteLength&&!n&&(this.remainderData=new Uint8Array(t.buffer,U,t.buffer.byteLength-U));let O=0;for(let B=x;B<U;B+=xr)if(t[B]===71){const at=!!(t[B+1]&64),st=lh(t,B),J=(t[B+3]&48)>>4;let kt;if(J>1){if(kt=B+5+t[B+4],kt===B+xr)continue}else kt=B+4;switch(st){case g:at&&(v&&(o=Pn(v))&&this.parseAVCPES(l,p,o,!1),v={data:[],size:0}),v&&(v.data.push(t.subarray(kt,B+xr)),v.size+=B+xr-kt);break;case E:if(at){if(T&&(o=Pn(T)))switch(d.segmentCodec){case"aac":this.parseAACPES(d,o);break;case"mp3":this.parseMPEGPES(d,o);break}T={data:[],size:0}}T&&(T.data.push(t.subarray(kt,B+xr)),T.size+=B+xr-kt);break;case A:at&&(w&&(o=Pn(w))&&this.parseID3PES(f,o),w={data:[],size:0}),w&&(w.data.push(t.subarray(kt,B+xr)),w.size+=B+xr-kt);break;case 0:at&&(kt+=t[kt]+1),M=this._pmtId=Y4(t,kt);break;case M:{at&&(kt+=t[kt]+1);const ft=X4(t,kt,this.typeSupported,r);g=ft.avc,g>0&&(l.pid=g),E=ft.audio,E>0&&(d.pid=E,d.segmentCodec=ft.segmentCodec),A=ft.id3,A>0&&(f.pid=A),C!==null&&!D&&(X.warn(`MPEG-TS PMT found at ${B} after unknown PID '${C}'. Backtracking to sync byte @${x} to parse all TS packets.`),C=null,B=x-188),D=this.pmtParsed=!0;break}case 17:case 8191:break;default:C=st;break}}else O++;if(O>0){const B=new Error(`Found ${O} TS packet/s that do not start with 0x47`);this.observer.emit(R.ERROR,R.ERROR,{type:Qt.MEDIA_ERROR,details:ut.FRAG_PARSING_ERROR,fatal:!1,error:B,reason:B.message})}l.pesData=v,d.pesData=T,f.pesData=w;const K={audioTrack:d,videoTrack:l,id3Track:f,textTrack:p};return n&&this.extractRemainingSamples(K),K}flush(){const{remainderData:t}=this;this.remainderData=null;let e;return t?e=this.demux(t,-1,!1,!0):e={videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(e),this.sampleAes?this.decrypt(e,this.sampleAes):e}extractRemainingSamples(t){const{audioTrack:e,videoTrack:r,id3Track:n,textTrack:o}=t,l=r.pesData,d=e.pesData,f=n.pesData;let p;if(l&&(p=Pn(l))?(this.parseAVCPES(r,o,p,!0),r.pesData=null):r.pesData=l,d&&(p=Pn(d))){switch(e.segmentCodec){case"aac":this.parseAACPES(e,p);break;case"mp3":this.parseMPEGPES(e,p);break}e.pesData=null}else d!=null&&d.size&&X.log("last AAC PES packet truncated,might overlap between fragments"),e.pesData=d;f&&(p=Pn(f))?(this.parseID3PES(n,p),n.pesData=null):n.pesData=f}demuxSampleAes(t,e,r){const n=this.demux(t,r,!0,!this.config.progressive),o=this.sampleAes=new z4(this.observer,this.config,e);return this.decrypt(n,o)}decrypt(t,e){return new Promise(r=>{const{audioTrack:n,videoTrack:o}=t;n.samples&&n.segmentCodec==="aac"?e.decryptAacSamples(n.samples,0,()=>{o.samples?e.decryptAvcSamples(o.samples,0,0,()=>{r(t)}):r(t)}):o.samples&&e.decryptAvcSamples(o.samples,0,0,()=>{r(t)})})}destroy(){this._duration=0}parseAVCPES(t,e,r,n){const o=this.parseAVCNALu(t,r.data);let l=this.avcSample,d,f=!1;r.data=null,l&&o.length&&!t.audFound&&(Fa(l,t),l=this.avcSample=rl(!1,r.pts,r.dts,"")),o.forEach(p=>{var g;switch(p.type){case 1:{let E=!1;d=!0;const A=p.data;if(f&&A.length>4){const T=new tp(A).readSliceType();(T===2||T===4||T===7||T===9)&&(E=!0)}if(E){var v;(v=l)!=null&&v.frame&&!l.key&&(Fa(l,t),l=this.avcSample=null)}l||(l=this.avcSample=rl(!0,r.pts,r.dts,"")),l.frame=!0,l.key=E;break}case 5:d=!0,(g=l)!=null&&g.frame&&!l.key&&(Fa(l,t),l=this.avcSample=null),l||(l=this.avcSample=rl(!0,r.pts,r.dts,"")),l.key=!0,l.frame=!0;break;case 6:{d=!0,df(p.data,1,r.pts,e.samples);break}case 7:if(d=!0,f=!0,!t.sps){const E=p.data,A=new tp(E).readSPS();t.width=A.width,t.height=A.height,t.pixelRatio=A.pixelRatio,t.sps=[E],t.duration=this._duration;const T=E.subarray(1,4);let w="avc1.";for(let C=0;C<3;C++){let D=T[C].toString(16);D.length<2&&(D="0"+D),w+=D}t.codec=w}break;case 8:d=!0,t.pps||(t.pps=[p.data]);break;case 9:d=!1,t.audFound=!0,l&&Fa(l,t),l=this.avcSample=rl(!1,r.pts,r.dts,"");break;case 12:d=!0;break;default:d=!1,l&&(l.debug+="unknown NAL "+p.type+" ");break}l&&d&&l.units.push(p)}),n&&l&&(Fa(l,t),this.avcSample=null)}getLastNalUnit(t){var e;let r=this.avcSample,n;if((!r||r.units.length===0)&&(r=t[t.length-1]),(e=r)!=null&&e.units){const o=r.units;n=o[o.length-1]}return n}parseAVCNALu(t,e){const r=e.byteLength;let n=t.naluState||0;const o=n,l=[];let d=0,f,p,g,v=-1,E=0;for(n===-1&&(v=0,E=e[0]&31,n=0,d=1);d<r;){if(f=e[d++],!n){n=f?0:1;continue}if(n===1){n=f?0:2;continue}if(!f)n=3;else if(f===1){if(v>=0){const A={data:e.subarray(v,d-n-1),type:E};l.push(A)}else{const A=this.getLastNalUnit(t.samples);if(A&&(o&&d<=4-o&&A.state&&(A.data=A.data.subarray(0,A.data.byteLength-o)),p=d-n-1,p>0)){const T=new Uint8Array(A.data.byteLength+p);T.set(A.data,0),T.set(e.subarray(0,p),A.data.byteLength),A.data=T,A.state=0}}d<r?(g=e[d]&31,v=d,E=g,n=0):n=-1}else n=0}if(v>=0&&n>=0){const A={data:e.subarray(v,r),type:E,state:n};l.push(A)}if(l.length===0){const A=this.getLastNalUnit(t.samples);if(A){const T=new Uint8Array(A.data.byteLength+e.byteLength);T.set(A.data,0),T.set(e,A.data.byteLength),A.data=T}}return t.naluState=n,l}parseAACPES(t,e){let r=0;const n=this.aacOverFlow;let o=e.data;if(n){this.aacOverFlow=null;const v=n.missing,E=n.sample.unit.byteLength;if(v===-1){const A=new Uint8Array(E+o.byteLength);A.set(n.sample.unit,0),A.set(o,E),o=A}else{const A=E-v;n.sample.unit.set(o.subarray(0,v),A),t.samples.push(n.sample),r=n.missing}}let l,d;for(l=r,d=o.length;l<d-1&&!tl(o,l);l++);if(l!==r){let v;const E=l<d-1;E?v=`AAC PES did not start with ADTS header,offset:${l}`:v="No ADTS header found in AAC PES";const A=new Error(v);if(X.warn(`parsing error: ${v}`),this.observer.emit(R.ERROR,R.ERROR,{type:Qt.MEDIA_ERROR,details:ut.FRAG_PARSING_ERROR,fatal:!1,levelRetry:E,error:A,reason:v}),!E)return}Yf(t,this.observer,o,l,this.audioCodec);let f;if(e.pts!==void 0)f=e.pts;else if(n){const v=Xf(t.samplerate);f=n.sample.pts+v}else{X.warn("[tsdemuxer]: AAC PES unknown PTS");return}let p=0,g;for(;l<d;)if(g=Zf(t,o,l,f,p),l+=g.length,g.missing){this.aacOverFlow=g;break}else for(p++;l<d-1&&!tl(o,l);l++);}parseMPEGPES(t,e){const r=e.data,n=r.length;let o=0,l=0;const d=e.pts;if(d===void 0){X.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;l<n;)if(Jf(r,l)){const f=qf(t,r,l,d,o);if(f)l+=f.length,o++;else break}else l++}parseID3PES(t,e){if(e.pts===void 0){X.warn("[tsdemuxer]: ID3 PES unknown PTS");return}const r=dr({},e,{type:this._avcTrack?Si.emsg:Si.audioId3,duration:Number.POSITIVE_INFINITY});t.samples.push(r)}}function rl(i,t,e,r){return{key:i,frame:!1,pts:t,dts:e,units:[],debug:r,length:0}}function lh(i,t){return((i[t+1]&31)<<8)+i[t+2]}function Y4(i,t){return(i[t+10]&31)<<8|i[t+11]}function X4(i,t,e,r){const n={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},o=(i[t+1]&15)<<8|i[t+2],l=t+3+o-4,d=(i[t+10]&15)<<8|i[t+11];for(t+=12+d;t<l;){const f=lh(i,t);switch(i[t]){case 207:if(!r){X.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:n.audio===-1&&(n.audio=f);break;case 21:n.id3===-1&&(n.id3=f);break;case 219:if(!r){X.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:n.avc===-1&&(n.avc=f);break;case 3:case 4:e.mpeg!==!0&&e.mp3!==!0?X.log("MPEG audio found, not supported in this browser"):n.audio===-1&&(n.audio=f,n.segmentCodec="mp3");break;case 36:X.warn("Unsupported HEVC stream type found");break}t+=((i[t+3]&15)<<8|i[t+4])+5}return n}function Pn(i){let t=0,e,r,n,o,l;const d=i.data;if(!i||i.size===0)return null;for(;d[0].length<19&&d.length>1;){const f=new Uint8Array(d[0].length+d[1].length);f.set(d[0]),f.set(d[1],d[0].length),d[0]=f,d.splice(1,1)}if(e=d[0],(e[0]<<16)+(e[1]<<8)+e[2]===1){if(r=(e[4]<<8)+e[5],r&&r>i.size-6)return null;const f=e[7];f&192&&(o=(e[9]&14)*536870912+(e[10]&255)*4194304+(e[11]&254)*16384+(e[12]&255)*128+(e[13]&254)/2,f&64?(l=(e[14]&14)*536870912+(e[15]&255)*4194304+(e[16]&254)*16384+(e[17]&255)*128+(e[18]&254)/2,o-l>54e5&&(X.warn(`${Math.round((o-l)/9e4)}s delta between PTS and DTS, align them`),o=l)):l=o),n=e[8];let p=n+9;if(i.size<=p)return null;i.size-=p;const g=new Uint8Array(i.size);for(let v=0,E=d.length;v<E;v++){e=d[v];let A=e.byteLength;if(p)if(p>A){p-=A;continue}else e=e.subarray(p),A-=p,p=0;g.set(e,t),t+=A}return r&&(r-=n+3),{data:g,pts:o,dts:l,len:r}}return null}function Fa(i,t){if(i.units.length&&i.frame){if(i.pts===void 0){const e=t.samples,r=e.length;if(r){const n=e[r-1];i.pts=n.pts,i.dts=n.dts}else{t.dropped++;return}}t.samples.push(i)}i.debug.length&&X.log(i.pts+"/"+i.dts+":"+i.debug)}class Z4 extends jf{resetInitSegment(t,e,r,n){super.resetInitSegment(t,e,r,n),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:e,duration:n,inputTimeScale:9e4,dropped:0}}static probe(t){if(!t)return!1;let e=(Vo(t,0)||[]).length;for(let r=t.length;e<r;e++)if(K4(t,e))return X.log("MPEG Audio sync word found !"),!0;return!1}canParse(t,e){return j4(t,e)}appendFrame(t,e,r){if(this.basePTS!==null)return qf(t,e,r,this.basePTS,this.frameIndex)}}class ep{static getSilentFrame(t,e){switch(t){case"mp4a.40.2":if(e===1)return new Uint8Array([0,200,0,128,35,128]);if(e===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(e===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(e===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(e===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(e===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(e===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(e===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(e===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}}}const Cs=Math.pow(2,32)-1;class it{static init(){it.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};let t;for(t in it.types)it.types.hasOwnProperty(t)&&(it.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);const e=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),r=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]);it.HDLR_TYPES={video:e,audio:r};const n=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),o=new Uint8Array([0,0,0,0,0,0,0,0]);it.STTS=it.STSC=it.STCO=o,it.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),it.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),it.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),it.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);const l=new Uint8Array([105,115,111,109]),d=new Uint8Array([97,118,99,49]),f=new Uint8Array([0,0,0,1]);it.FTYP=it.box(it.types.ftyp,l,f,l,d),it.DINF=it.box(it.types.dinf,it.box(it.types.dref,n))}static box(t,...e){let r=8,n=e.length;const o=n;for(;n--;)r+=e[n].byteLength;const l=new Uint8Array(r);for(l[0]=r>>24&255,l[1]=r>>16&255,l[2]=r>>8&255,l[3]=r&255,l.set(t,4),n=0,r=8;n<o;n++)l.set(e[n],r),r+=e[n].byteLength;return l}static hdlr(t){return it.box(it.types.hdlr,it.HDLR_TYPES[t])}static mdat(t){return it.box(it.types.mdat,t)}static mdhd(t,e){e*=t;const r=Math.floor(e/(Cs+1)),n=Math.floor(e%(Cs+1));return it.box(it.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,t&255,r>>24,r>>16&255,r>>8&255,r&255,n>>24,n>>16&255,n>>8&255,n&255,85,196,0,0]))}static mdia(t){return it.box(it.types.mdia,it.mdhd(t.timescale,t.duration),it.hdlr(t.type),it.minf(t))}static mfhd(t){return it.box(it.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255]))}static minf(t){return t.type==="audio"?it.box(it.types.minf,it.box(it.types.smhd,it.SMHD),it.DINF,it.stbl(t)):it.box(it.types.minf,it.box(it.types.vmhd,it.VMHD),it.DINF,it.stbl(t))}static moof(t,e,r){return it.box(it.types.moof,it.mfhd(t),it.traf(r,e))}static moov(t){let e=t.length;const r=[];for(;e--;)r[e]=it.trak(t[e]);return it.box.apply(null,[it.types.moov,it.mvhd(t[0].timescale,t[0].duration)].concat(r).concat(it.mvex(t)))}static mvex(t){let e=t.length;const r=[];for(;e--;)r[e]=it.trex(t[e]);return it.box.apply(null,[it.types.mvex,...r])}static mvhd(t,e){e*=t;const r=Math.floor(e/(Cs+1)),n=Math.floor(e%(Cs+1)),o=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,t&255,r>>24,r>>16&255,r>>8&255,r&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 it.box(it.types.mvhd,o)}static sdtp(t){const e=t.samples||[],r=new Uint8Array(4+e.length);let n,o;for(n=0;n<e.length;n++)o=e[n].flags,r[n+4]=o.dependsOn<<4|o.isDependedOn<<2|o.hasRedundancy;return it.box(it.types.sdtp,r)}static stbl(t){return it.box(it.types.stbl,it.stsd(t),it.box(it.types.stts,it.STTS),it.box(it.types.stsc,it.STSC),it.box(it.types.stsz,it.STSZ),it.box(it.types.stco,it.STCO))}static avc1(t){let e=[],r=[],n,o,l;for(n=0;n<t.sps.length;n++)o=t.sps[n],l=o.byteLength,e.push(l>>>8&255),e.push(l&255),e=e.concat(Array.prototype.slice.call(o));for(n=0;n<t.pps.length;n++)o=t.pps[n],l=o.byteLength,r.push(l>>>8&255),r.push(l&255),r=r.concat(Array.prototype.slice.call(o));const d=it.box(it.types.avcC,new Uint8Array([1,e[3],e[4],e[5],255,224|t.sps.length].concat(e).concat([t.pps.length]).concat(r))),f=t.width,p=t.height,g=t.pixelRatio[0],v=t.pixelRatio[1];return it.box(it.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,f>>8&255,f&255,p>>8&255,p&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),d,it.box(it.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),it.box(it.types.pasp,new Uint8Array([g>>24,g>>16&255,g>>8&255,g&255,v>>24,v>>16&255,v>>8&255,v&255])))}static esds(t){const e=t.config.length;return new Uint8Array([0,0,0,0,3,23+e,0,1,0,4,15+e,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([e]).concat(t.config).concat([6,1,2]))}static mp4a(t){const e=t.samplerate;return it.box(it.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,e>>8&255,e&255,0,0]),it.box(it.types.esds,it.esds(t)))}static mp3(t){const e=t.samplerate;return it.box(it.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,e>>8&255,e&255,0,0]))}static stsd(t){return t.type==="audio"?t.segmentCodec==="mp3"&&t.codec==="mp3"?it.box(it.types.stsd,it.STSD,it.mp3(t)):it.box(it.types.stsd,it.STSD,it.mp4a(t)):it.box(it.types.stsd,it.STSD,it.avc1(t))}static tkhd(t){const e=t.id,r=t.duration*t.timescale,n=t.width,o=t.height,l=Math.floor(r/(Cs+1)),d=Math.floor(r%(Cs+1));return it.box(it.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,0,0,0,0,l>>24,l>>16&255,l>>8&255,l&255,d>>24,d>>16&255,d>>8&255,d&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,n>>8&255,n&255,0,0,o>>8&255,o&255,0,0]))}static traf(t,e){const r=it.sdtp(t),n=t.id,o=Math.floor(e/(Cs+1)),l=Math.floor(e%(Cs+1));return it.box(it.types.traf,it.box(it.types.tfhd,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,n&255])),it.box(it.types.tfdt,new Uint8Array([1,0,0,0,o>>24,o>>16&255,o>>8&255,o&255,l>>24,l>>16&255,l>>8&255,l&255])),it.trun(t,r.length+16+20+8+16+8+8),r)}static trak(t){return t.duration=t.duration||4294967295,it.box(it.types.trak,it.tkhd(t),it.mdia(t))}static trex(t){const e=t.id;return it.box(it.types.trex,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(t,e){const r=t.samples||[],n=r.length,o=12+16*n,l=new Uint8Array(o);let d,f,p,g,v,E;for(e+=8+o,l.set([t.type==="video"?1:0,0,15,1,n>>>24&255,n>>>16&255,n>>>8&255,n&255,e>>>24&255,e>>>16&255,e>>>8&255,e&255],0),d=0;d<n;d++)f=r[d],p=f.duration,g=f.size,v=f.flags,E=f.cts,l.set([p>>>24&255,p>>>16&255,p>>>8&255,p&255,g>>>24&255,g>>>16&255,g>>>8&255,g&255,v.isLeading<<2|v.dependsOn,v.isDependedOn<<6|v.hasRedundancy<<4|v.paddingValue<<1|v.isNonSync,v.degradPrio&61440,v.degradPrio&15,E>>>24&255,E>>>16&255,E>>>8&255,E&255],12+16*d);return it.box(it.types.trun,l)}static initSegment(t){it.types||it.init();const e=it.moov(t),r=new Uint8Array(it.FTYP.byteLength+e.byteLength);return r.set(it.FTYP),r.set(e,it.FTYP.byteLength),r}}it.types=void 0,it.HDLR_TYPES=void 0,it.STTS=void 0,it.STSC=void 0,it.STCO=void 0,it.STSZ=void 0,it.VMHD=void 0,it.SMHD=void 0,it.STSD=void 0,it.FTYP=void 0,it.DINF=void 0;const rp=9e4;function ch(i,t,e=1,r=!1){const n=i*t*e;return r?Math.round(n):n}function q4(i,t,e=1,r=!1){return ch(i,t,1/e,r)}function Ua(i,t=!1){return ch(i,1e3,1/rp,t)}function Q4(i,t=1){return ch(i,rp,1/t)}const J4=10*1e3,ip=1024,tE=1152;let il=null,hh=null;class dh{constructor(t,e,r,n=""){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=t,this.config=e,this.typeSupported=r,this.ISGenerated=!1,il===null){const o=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);il=o?parseInt(o[1]):0}if(hh===null){const o=navigator.userAgent.match(/Safari\/(\d+)/i);hh=o?parseInt(o[1]):0}}destroy(){}resetTimeStamp(t){X.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=t}resetNextTimestamp(){X.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){X.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1}getVideoStartPts(t){let e=!1;const r=t.reduce((n,o)=>{const l=o.pts-n;return l<-4294967296?(e=!0,pi(n,o.pts)):l>0?n:o.pts},t[0].pts);return e&&X.debug("PTS rollover detected"),r}remux(t,e,r,n,o,l,d,f){let p,g,v,E,A,T,w=o,C=o;const D=t.pid>-1,M=e.pid>-1,U=e.samples.length,x=t.samples.length>0,O=d&&U>0||U>1;if((!D||x)&&(!M||O)||this.ISGenerated||d){this.ISGenerated||(v=this.generateIS(t,e,o,l));const K=this.isVideoContiguous;let B=-1,at;if(O&&(B=eE(e.samples),!K&&this.config.forceKeyFrameOnDiscontinuity))if(T=!0,B>0){X.warn(`[mp4-remuxer]: Dropped ${B} out of ${U} video samples due to a missing keyframe`);const st=this.getVideoStartPts(e.samples);e.samples=e.samples.slice(B),e.dropped+=B,C+=(e.samples[0].pts-st)/e.inputTimeScale,at=C}else B===-1&&(X.warn(`[mp4-remuxer]: No keyframe found out of ${U} video samples`),T=!1);if(this.ISGenerated){if(x&&O){const st=this.getVideoStartPts(e.samples),J=(pi(t.samples[0].pts,st)-st)/e.inputTimeScale;w+=Math.max(0,J),C+=Math.max(0,-J)}if(x){if(t.samplerate||(X.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),v=this.generateIS(t,e,o,l)),g=this.remuxAudio(t,w,this.isAudioContiguous,l,M||O||f===Jt.AUDIO?C:void 0),O){const st=g?g.endPTS-g.startPTS:0;e.inputTimeScale||(X.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),v=this.generateIS(t,e,o,l)),p=this.remuxVideo(e,C,K,st)}}else O&&(p=this.remuxVideo(e,C,K,0));p&&(p.firstKeyFrame=B,p.independent=B!==-1,p.firstKeyFramePTS=at)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(A=sp(r,o,this._initPTS,this._initDTS)),n.samples.length&&(E=np(n,o,this._initPTS))),{audio:g,video:p,initSegment:v,independent:T,text:E,id3:A}}generateIS(t,e,r,n){const o=t.samples,l=e.samples,d=this.typeSupported,f={},p=this._initPTS;let g=!p||n,v="audio/mp4",E,A,T;if(g&&(E=A=1/0),t.config&&o.length){switch(t.timescale=t.samplerate,t.segmentCodec){case"mp3":d.mpeg?(v="audio/mpeg",t.codec=""):d.mp3&&(t.codec="mp3");break}f.audio={id:"audio",container:v,codec:t.codec,initSegment:t.segmentCodec==="mp3"&&d.mpeg?new Uint8Array(0):it.initSegment([t]),metadata:{channelCount:t.channelCount}},g&&(T=t.inputTimeScale,!p||T!==p.timescale?E=A=o[0].pts-Math.round(T*r):g=!1)}if(e.sps&&e.pps&&l.length&&(e.timescale=e.inputTimeScale,f.video={id:"main",container:"video/mp4",codec:e.codec,initSegment:it.initSegment([e]),metadata:{width:e.width,height:e.height}},g))if(T=e.inputTimeScale,!p||T!==p.timescale){const w=this.getVideoStartPts(l),C=Math.round(T*r);A=Math.min(A,pi(l[0].dts,w)-C),E=Math.min(E,w-C)}else g=!1;if(Object.keys(f).length)return this.ISGenerated=!0,g?(this._initPTS={baseTime:E,timescale:T},this._initDTS={baseTime:A,timescale:T}):E=T=void 0,{tracks:f,initPTS:E,timescale:T}}remuxVideo(t,e,r,n){const o=t.inputTimeScale,l=t.samples,d=[],f=l.length,p=this._initPTS;let g=this.nextAvcDts,v=8,E=this.videoSampleDuration,A,T,w=Number.POSITIVE_INFINITY,C=Number.NEGATIVE_INFINITY,D=!1;if(!r||g===null){const N=e*o,G=l[0].pts-pi(l[0].dts,l[0].pts);g=N-G}const M=p.baseTime*o/p.timescale;for(let N=0;N<f;N++){const G=l[N];G.pts=pi(G.pts-M,g),G.dts=pi(G.dts-M,g),G.dts<l[N>0?N-1:N].dts&&(D=!0)}D&&l.sort(function(N,G){const Z=N.dts-G.dts,gt=N.pts-G.pts;return Z||gt}),A=l[0].dts,T=l[l.length-1].dts;const U=T-A,x=U?Math.round(U/(f-1)):E||t.inputTimeScale/30;if(r){const N=A-g,G=N>x,Z=N<-1;if((G||Z)&&(G?X.warn(`AVC: ${Ua(N,!0)} ms (${N}dts) hole between fragments detected, filling it`):X.warn(`AVC: ${Ua(-N,!0)} ms (${N}dts) overlapping between fragments detected`),!Z||g>=l[0].pts)){A=g;const gt=l[0].pts-N;l[0].dts=A,l[0].pts=gt,X.log(`Video: First PTS/DTS adjusted: ${Ua(gt,!0)}/${Ua(A,!0)}, delta: ${Ua(N,!0)} ms`)}}A=Math.max(0,A);let O=0,K=0;for(let N=0;N<f;N++){const G=l[N],Z=G.units,gt=Z.length;let vt=0;for(let It=0;It<gt;It++)vt+=Z[It].data.length;K+=vt,O+=gt,G.length=vt,G.dts=Math.max(G.dts,A),w=Math.min(G.pts,w),C=Math.max(G.pts,C)}T=l[f-1].dts;const B=K+4*O+8;let at;try{at=new Uint8Array(B)}catch(N){this.observer.emit(R.ERROR,R.ERROR,{type:Qt.MUX_ERROR,details:ut.REMUX_ALLOC_ERROR,fatal:!1,error:N,bytes:B,reason:`fail allocating video mdat ${B}`});return}const st=new DataView(at.buffer);st.setUint32(0,B),at.set(it.types.mdat,4);let J=!1,kt=Number.POSITIVE_INFINITY,ft=Number.POSITIVE_INFINITY,wt=Number.NEGATIVE_INFINITY,Pt=Number.NEGATIVE_INFINITY;for(let N=0;N<f;N++){const G=l[N],Z=G.units;let gt=0;for(let Bt=0,Xt=Z.length;Bt<Xt;Bt++){const me=Z[Bt],be=me.data,Ee=me.data.byteLength;st.setUint32(v,Ee),v+=4,at.set(be,v),v+=Ee,gt+=4+Ee}let vt;if(N<f-1)E=l[N+1].dts-G.dts,vt=l[N+1].pts-G.pts;else{const Bt=this.config,Xt=N>0?G.dts-l[N-1].dts:x;if(vt=N>0?G.pts-l[N-1].pts:x,Bt.stretchShortVideoTrack&&this.nextAudioPts!==null){const me=Math.floor(Bt.maxBufferHole*o),be=(n?w+n*o:this.nextAudioPts)-G.pts;be>me?(E=be-Xt,E<0?E=Xt:J=!0,X.log(`[mp4-remuxer]: It is approximately ${be/90} ms to the next segment; using duration ${E/90} ms for the last video frame.`)):E=Xt}else E=Xt}const It=Math.round(G.pts-G.dts);kt=Math.min(kt,E),wt=Math.max(wt,E),ft=Math.min(ft,vt),Pt=Math.max(Pt,vt),d.push(new ap(G.key,E,gt,It))}if(d.length){if(il){if(il<70){const N=d[0].flags;N.dependsOn=2,N.isNonSync=0}}else if(hh&&Pt-ft<wt-kt&&x/wt<.025&&d[0].cts===0){X.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let N=A;for(let G=0,Z=d.length;G<Z;G++){const gt=N+d[G].duration,vt=N+d[G].cts;if(G<Z-1){const It=gt+d[G+1].cts;d[G].duration=It-vt}else d[G].duration=G?d[G-1].duration:x;d[G].cts=0,N=gt}}}E=J||!E?x:E,this.nextAvcDts=g=T+E,this.videoSampleDuration=E,this.isVideoContiguous=!0;const F=it.moof(t.sequenceNumber++,A,dr({},t,{samples:d})),j="video",bt={data1:F,data2:at,startPTS:w/o,endPTS:(C+E)/o,startDTS:A/o,endDTS:g/o,type:j,hasAudio:!1,hasVideo:!0,nb:d.length,dropped:t.dropped};return t.samples=[],t.dropped=0,bt}remuxAudio(t,e,r,n,o){const l=t.inputTimeScale,d=t.samplerate?t.samplerate:l,f=l/d,p=t.segmentCodec==="aac"?ip:tE,g=p*f,v=this._initPTS,E=t.segmentCodec==="mp3"&&this.typeSupported.mpeg,A=[],T=o!==void 0;let w=t.samples,C=E?0:8,D=this.nextAudioPts||-1;const M=e*l,U=v.baseTime*l/v.timescale;if(this.isAudioContiguous=r=r||w.length&&D>0&&(n&&Math.abs(M-D)<9e3||Math.abs(pi(w[0].pts-U,M)-D)<20*g),w.forEach(function(F){F.pts=pi(F.pts-U,M)}),!r||D<0){if(w=w.filter(F=>F.pts>=0),!w.length)return;o===0?D=0:n&&!T?D=Math.max(0,M):D=w[0].pts}if(t.segmentCodec==="aac"){const F=this.config.maxAudioFramesDrift;for(let j=0,bt=D;j<w.length;j++){const N=w[j],G=N.pts,Z=G-bt,gt=Math.abs(1e3*Z/l);if(Z<=-F*g&&T)j===0&&(X.warn(`Audio frame @ ${(G/l).toFixed(3)}s overlaps nextAudioPts by ${Math.round(1e3*Z/l)} ms.`),this.nextAudioPts=D=bt=G);else if(Z>=F*g&&gt<J4&&T){let vt=Math.round(Z/g);bt=G-vt*g,bt<0&&(vt--,bt+=g),j===0&&(this.nextAudioPts=D=bt),X.warn(`[mp4-remuxer]: Injecting ${vt} audio frame @ ${(bt/l).toFixed(3)}s due to ${Math.round(1e3*Z/l)} ms gap.`);for(let It=0;It<vt;It++){const Bt=Math.max(bt,0);let Xt=ep.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);Xt||(X.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),Xt=N.unit.subarray()),w.splice(j,0,{unit:Xt,pts:Bt}),bt+=g,j++}}N.pts=bt,bt+=g}}let x=null,O=null,K,B=0,at=w.length;for(;at--;)B+=w[at].unit.byteLength;for(let F=0,j=w.length;F<j;F++){const bt=w[F],N=bt.unit;let G=bt.pts;if(O!==null){const gt=A[F-1];gt.duration=Math.round((G-O)/f)}else if(r&&t.segmentCodec==="aac"&&(G=D),x=G,B>0){B+=C;try{K=new Uint8Array(B)}catch(gt){this.observer.emit(R.ERROR,R.ERROR,{type:Qt.MUX_ERROR,details:ut.REMUX_ALLOC_ERROR,fatal:!1,error:gt,bytes:B,reason:`fail allocating audio mdat ${B}`});return}E||(new DataView(K.buffer).setUint32(0,B),K.set(it.types.mdat,4))}else return;K.set(N,C);const Z=N.byteLength;C+=Z,A.push(new ap(!0,p,Z,0)),O=G}const st=A.length;if(!st)return;const J=A[A.length-1];this.nextAudioPts=D=O+f*J.duration;const kt=E?new Uint8Array(0):it.moof(t.sequenceNumber++,x/f,dr({},t,{samples:A}));t.samples=[];const ft=x/l,wt=D/l,Pt={data1:kt,data2:K,startPTS:ft,endPTS:wt,startDTS:ft,endDTS:wt,type:"audio",hasAudio:!0,hasVideo:!1,nb:st};return this.isAudioContiguous=!0,Pt}remuxEmptyAudio(t,e,r,n){const o=t.inputTimeScale,l=t.samplerate?t.samplerate:o,d=o/l,f=this.nextAudioPts,p=this._initDTS,g=p.baseTime*9e4/p.timescale,v=(f!==null?f:n.startDTS*o)+g,E=n.endDTS*o+g,A=d*ip,T=Math.ceil((E-v)/A),w=ep.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);if(X.warn("[mp4-remuxer]: remux empty Audio"),!w){X.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}const C=[];for(let D=0;D<T;D++){const M=v+D*A;C.push({unit:w,pts:M,dts:M})}return t.samples=C,this.remuxAudio(t,e,r,!1)}}function pi(i,t){let e;if(t===null)return i;for(t<i?e=-8589934592:e=8589934592;Math.abs(i-t)>4294967296;)i+=e;return i}function eE(i){for(let t=0;t<i.length;t++)if(i[t].key)return t;return-1}function sp(i,t,e,r){const n=i.samples.length;if(!n)return;const o=i.inputTimeScale;for(let d=0;d<n;d++){const f=i.samples[d];f.pts=pi(f.pts-e.baseTime*o/e.timescale,t*o)/o,f.dts=pi(f.dts-r.baseTime*o/r.timescale,t*o)/o}const l=i.samples;return i.samples=[],{samples:l}}function np(i,t,e){const r=i.samples.length;if(!r)return;const n=i.inputTimeScale;for(let l=0;l<r;l++){const d=i.samples[l];d.pts=pi(d.pts-e.baseTime*n/e.timescale,t*n)/n}i.samples.sort((l,d)=>l.pts-d.pts);const o=i.samples;return i.samples=[],{samples:o}}class ap{constructor(t,e,r,n){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=e,this.size=r,this.cts=n,this.flags=new rE(t)}}class rE{constructor(t){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=t?2:1,this.isNonSync=t?0:1}}class iE{constructor(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null}destroy(){}resetTimeStamp(t){this.initPTS=t,this.lastEndTime=null}resetNextTimestamp(){this.lastEndTime=null}resetInitSegment(t,e,r,n){this.audioCodec=e,this.videoCodec=r,this.generateInitSegment(kb(t,n)),this.emitInitSegment=!0}generateInitSegment(t){let{audioCodec:e,videoCodec:r}=this;if(!(t!=null&&t.byteLength)){this.initTracks=void 0,this.initData=void 0;return}const n=this.initData=lf(t);e||(e=op(n.audio,Oe.AUDIO)),r||(r=op(n.video,Oe.VIDEO));const o={};n.audio&&n.video?o.audiovideo={container:"video/mp4",codec:e+","+r,initSegment:t,id:"main"}:n.audio?o.audio={container:"audio/mp4",codec:e,initSegment:t,id:"audio"}:n.video?o.video={container:"video/mp4",codec:r,initSegment:t,id:"main"}:X.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=o}remux(t,e,r,n,o,l){var d,f;let{initPTS:p,lastEndTime:g}=this;const v={audio:void 0,video:void 0,text:n,id3:r,initSegment:void 0};jt(g)||(g=this.lastEndTime=o||0);const E=e.samples;if(!(E!=null&&E.length))return v;const A={initPTS:void 0,timescale:1};let T=this.initData;if((d=T)!=null&&d.length||(this.generateInitSegment(E),T=this.initData),!((f=T)!=null&&f.length))return X.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),v;this.emitInitSegment&&(A.tracks=this.initTracks,this.emitInitSegment=!1);const w=Sb(E,T),C=wb(T,E),D=C===null?o:C;(sE(p,D,o,w)||A.timescale!==p.timescale&&l)&&(A.initPTS=D-o,p&&p.timescale===1&&X.warn(`Adjusting initPTS by ${A.initPTS-p.baseTime}`),this.initPTS=p={baseTime:A.initPTS,timescale:1});const M=t?D-p.baseTime/p.timescale:g,U=M+w;_b(T,E,p.baseTime/p.timescale),w>0?this.lastEndTime=U:(X.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const x=!!T.audio,O=!!T.video;let K="";x&&(K+="audio"),O&&(K+="video");const B={data1:E,startPTS:M,startDTS:M,endPTS:U,endDTS:U,type:K,hasAudio:x,hasVideo:O,nb:1,dropped:0};return v.audio=B.type==="audio"?B:void 0,v.video=B.type!=="audio"?B:void 0,v.initSegment=A,v.id3=sp(r,o,p,p),n.samples.length&&(v.text=np(n,o,p)),v}}function sE(i,t,e,r){if(i===null)return!0;const n=Math.max(r,1),o=t-i.baseTime/i.timescale;return Math.abs(o-e)>n}function op(i,t){const e=i==null?void 0:i.codec;return e&&e.length>4?e:e==="hvc1"||e==="hev1"?"hvc1.1.6.L120.90":e==="av01"?"av01.0.04M.08":e==="avc1"||t===Oe.VIDEO?"avc1.42e01e":"mp4a.40.5"}let ns;try{ns=self.performance.now.bind(self.performance)}catch{X.debug("Unable to use Performance API on this environment"),ns=typeof self<"u"&&self.Date.now}const uh=[{demux:B4,remux:iE},{demux:Ls,remux:dh},{demux:F4,remux:dh},{demux:Z4,remux:dh}];class lp{constructor(t,e,r,n,o){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=t,this.typeSupported=e,this.config=r,this.vendor=n,this.id=o}configure(t){this.transmuxConfig=t,this.decrypter&&this.decrypter.reset()}push(t,e,r,n){const o=r.transmuxing;o.executeStart=ns();let l=new Uint8Array(t);const{currentTransmuxState:d,transmuxConfig:f}=this;n&&(this.currentTransmuxState=n);const{contiguous:p,discontinuity:g,trackSwitch:v,accurateTimeOffset:E,timeOffset:A,initSegmentChange:T}=n||d,{audioCodec:w,videoCodec:C,defaultInitPts:D,duration:M,initSegmentData:U}=f,x=nE(l,e);if(x&&x.method==="AES-128"){const at=this.getDecrypter();if(at.isSync()){let st=at.softwareDecrypt(l,x.key.buffer,x.iv.buffer);if(r.part>-1&&(st=at.flush()),!st)return o.executeEnd=ns(),fh(r);l=new Uint8Array(st)}else return this.decryptionPromise=at.webCryptoDecrypt(l,x.key.buffer,x.iv.buffer).then(st=>{const J=this.push(st,null,r);return this.decryptionPromise=null,J}),this.decryptionPromise}const O=this.needsProbing(g,v);if(O){const at=this.configureTransmuxer(l);if(at)return X.warn(`[transmuxer] ${at.message}`),this.observer.emit(R.ERROR,R.ERROR,{type:Qt.MEDIA_ERROR,details:ut.FRAG_PARSING_ERROR,fatal:!1,error:at,reason:at.message}),o.executeEnd=ns(),fh(r)}(g||v||T||O)&&this.resetInitSegment(U,w,C,M,e),(g||T||O)&&this.resetInitialTimestamp(D),p||this.resetContiguity();const K=this.transmux(l,x,A,E,r),B=this.currentTransmuxState;return B.contiguous=!0,B.discontinuity=!1,B.trackSwitch=!1,o.executeEnd=ns(),K}flush(t){const e=t.transmuxing;e.executeStart=ns();const{decrypter:r,currentTransmuxState:n,decryptionPromise:o}=this;if(o)return o.then(()=>this.flush(t));const l=[],{timeOffset:d}=n;if(r){const v=r.flush();v&&l.push(this.push(v,null,t))}const{demuxer:f,remuxer:p}=this;if(!f||!p)return e.executeEnd=ns(),[fh(t)];const g=f.flush(d);return sl(g)?g.then(v=>(this.flushRemux(l,v,t),l)):(this.flushRemux(l,g,t),l)}flushRemux(t,e,r){const{audioTrack:n,videoTrack:o,id3Track:l,textTrack:d}=e,{accurateTimeOffset:f,timeOffset:p}=this.currentTransmuxState;X.log(`[transmuxer.ts]: Flushed fragment ${r.sn}${r.part>-1?" p: "+r.part:""} of level ${r.level}`);const g=this.remuxer.remux(n,o,l,d,p,f,!0,this.id);t.push({remuxResult:g,chunkMeta:r}),r.transmuxing.executeEnd=ns()}resetInitialTimestamp(t){const{demuxer:e,remuxer:r}=this;!e||!r||(e.resetTimeStamp(t),r.resetTimeStamp(t))}resetContiguity(){const{demuxer:t,remuxer:e}=this;!t||!e||(t.resetContiguity(),e.resetNextTimestamp())}resetInitSegment(t,e,r,n,o){const{demuxer:l,remuxer:d}=this;!l||!d||(l.resetInitSegment(t,e,r,n),d.resetInitSegment(t,e,r,o))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(t,e,r,n,o){let l;return e&&e.method==="SAMPLE-AES"?l=this.transmuxSampleAes(t,e,r,n,o):l=this.transmuxUnencrypted(t,r,n,o),l}transmuxUnencrypted(t,e,r,n){const{audioTrack:o,videoTrack:l,id3Track:d,textTrack:f}=this.demuxer.demux(t,e,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(o,l,d,f,e,r,!1,this.id),chunkMeta:n}}transmuxSampleAes(t,e,r,n,o){return this.demuxer.demuxSampleAes(t,e,r).then(l=>({remuxResult:this.remuxer.remux(l.audioTrack,l.videoTrack,l.id3Track,l.textTrack,r,n,!1,this.id),chunkMeta:o}))}configureTransmuxer(t){const{config:e,observer:r,typeSupported:n,vendor:o}=this;let l;for(let v=0,E=uh.length;v<E;v++)if(uh[v].demux.probe(t)){l=uh[v];break}if(!l)return new Error("Failed to find demuxer by probing fragment data");const d=this.demuxer,f=this.remuxer,p=l.remux,g=l.demux;(!f||!(f instanceof p))&&(this.remuxer=new p(r,e,n,o)),(!d||!(d instanceof g))&&(this.demuxer=new g(r,e,n),this.probe=g.probe)}needsProbing(t,e){return!this.demuxer||!this.remuxer||t||e}getDecrypter(){let t=this.decrypter;return t||(t=this.decrypter=new sh(this.config)),t}}function nE(i,t){let e=null;return i.byteLength>0&&t!=null&&t.key!=null&&t.iv!==null&&t.method!=null&&(e=t),e}const fh=i=>({remuxResult:{},chunkMeta:i});function sl(i){return"then"in i&&i.then instanceof Function}class aE{constructor(t,e,r,n,o){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=t,this.videoCodec=e,this.initSegmentData=r,this.duration=n,this.defaultInitPts=o||null}}class oE{constructor(t,e,r,n,o,l){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=t,this.contiguous=e,this.accurateTimeOffset=r,this.trackSwitch=n,this.timeOffset=o,this.initSegmentChange=l}}var cp={exports:{}};(function(i){var t=Object.prototype.hasOwnProperty,e="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(e=!1));function n(f,p,g){this.fn=f,this.context=p,this.once=g||!1}function o(f,p,g,v,E){if(typeof g!="function")throw new TypeError("The listener must be a function");var A=new n(g,v||f,E),T=e?e+p:p;return f._events[T]?f._events[T].fn?f._events[T]=[f._events[T],A]:f._events[T].push(A):(f._events[T]=A,f._eventsCount++),f}function l(f,p){--f._eventsCount===0?f._events=new r:delete f._events[p]}function d(){this._events=new r,this._eventsCount=0}d.prototype.eventNames=function(){var f=[],p,g;if(this._eventsCount===0)return f;for(g in p=this._events)t.call(p,g)&&f.push(e?g.slice(1):g);return Object.getOwnPropertySymbols?f.concat(Object.getOwnPropertySymbols(p)):f},d.prototype.listeners=function(f){var p=e?e+f:f,g=this._events[p];if(!g)return[];if(g.fn)return[g.fn];for(var v=0,E=g.length,A=new Array(E);v<E;v++)A[v]=g[v].fn;return A},d.prototype.listenerCount=function(f){var p=e?e+f:f,g=this._events[p];return g?g.fn?1:g.length:0},d.prototype.emit=function(f,p,g,v,E,A){var T=e?e+f:f;if(!this._events[T])return!1;var w=this._events[T],C=arguments.length,D,M;if(w.fn){switch(w.once&&this.removeListener(f,w.fn,void 0,!0),C){case 1:return w.fn.call(w.context),!0;case 2:return w.fn.call(w.context,p),!0;case 3:return w.fn.call(w.context,p,g),!0;case 4:return w.fn.call(w.context,p,g,v),!0;case 5:return w.fn.call(w.context,p,g,v,E),!0;case 6:return w.fn.call(w.context,p,g,v,E,A),!0}for(M=1,D=new Array(C-1);M<C;M++)D[M-1]=arguments[M];w.fn.apply(w.context,D)}else{var U=w.length,x;for(M=0;M<U;M++)switch(w[M].once&&this.removeListener(f,w[M].fn,void 0,!0),C){case 1:w[M].fn.call(w[M].context);break;case 2:w[M].fn.call(w[M].context,p);break;case 3:w[M].fn.call(w[M].context,p,g);break;case 4:w[M].fn.call(w[M].context,p,g,v);break;default:if(!D)for(x=1,D=new Array(C-1);x<C;x++)D[x-1]=arguments[x];w[M].fn.apply(w[M].context,D)}}return!0},d.prototype.on=function(f,p,g){return o(this,f,p,g,!1)},d.prototype.once=function(f,p,g){return o(this,f,p,g,!0)},d.prototype.removeListener=function(f,p,g,v){var E=e?e+f:f;if(!this._events[E])return this;if(!p)return l(this,E),this;var A=this._events[E];if(A.fn)A.fn===p&&(!v||A.once)&&(!g||A.context===g)&&l(this,E);else{for(var T=0,w=[],C=A.length;T<C;T++)(A[T].fn!==p||v&&!A[T].once||g&&A[T].context!==g)&&w.push(A[T]);w.length?this._events[E]=w.length===1?w[0]:w:l(this,E)}return this},d.prototype.removeAllListeners=function(f){var p;return f?(p=e?e+f:f,this._events[p]&&l(this,p)):(this._events=new r,this._eventsCount=0),this},d.prototype.off=d.prototype.removeListener,d.prototype.addListener=d.prototype.on,d.prefixed=e,d.EventEmitter=d,i.exports=d})(cp);var lE=cp.exports,ph=zy(lE);const gh=zo()||{isTypeSupported:()=>!1};class hp{constructor(t,e,r,n){this.error=null,this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;const o=t.config;this.hls=t,this.id=e,this.useWorker=!!o.enableWorker,this.onTransmuxComplete=r,this.onFlush=n;const l=(p,g)=>{g=g||{},g.frag=this.frag,g.id=this.id,p===R.ERROR&&(this.error=g.error),this.hls.trigger(p,g)};this.observer=new ph,this.observer.on(R.FRAG_DECRYPTED,l),this.observer.on(R.ERROR,l);const d={mp4:gh.isTypeSupported("video/mp4"),mpeg:gh.isTypeSupported("audio/mpeg"),mp3:gh.isTypeSupported('audio/mp4; codecs="mp3"')},f=navigator.vendor;if(this.useWorker&&typeof Worker<"u"&&(o.workerPath||C4())){try{o.workerPath?(X.log(`loading Web Worker ${o.workerPath} for "${e}"`),this.workerContext=x4(o.workerPath)):(X.log(`injecting Web Worker for "${e}"`),this.workerContext=I4()),this.onwmsg=g=>this.onWorkerMessage(g);const{worker:p}=this.workerContext;p.addEventListener("message",this.onwmsg),p.onerror=g=>{const v=new Error(`${g.message} (${g.filename}:${g.lineno})`);o.enableWorker=!1,X.warn(`Error in "${e}" Web Worker, fallback to inline`),this.hls.trigger(R.ERROR,{type:Qt.OTHER_ERROR,details:ut.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:v})},p.postMessage({cmd:"init",typeSupported:d,vendor:f,id:e,config:JSON.stringify(o)})}catch(p){X.warn(`Error setting up "${e}" Web Worker, fallback to inline`,p),this.resetWorker(),this.error=null,this.transmuxer=new lp(this.observer,d,o,f,e)}return}this.transmuxer=new lp(this.observer,d,o,f,e)}resetWorker(){if(this.workerContext){const{worker:t,objectURL:e}=this.workerContext;e&&self.URL.revokeObjectURL(e),t.removeEventListener("message",this.onwmsg),t.onerror=null,t.terminate(),this.workerContext=null}}destroy(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{const e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}const t=this.observer;t&&t.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null}push(t,e,r,n,o,l,d,f,p,g){var v,E;p.transmuxing.start=self.performance.now();const{transmuxer:A}=this,T=l?l.start:o.start,w=o.decryptdata,C=this.frag,D=!(C&&o.cc===C.cc),M=!(C&&p.level===C.level),U=C?p.sn-C.sn:-1,x=this.part?p.part-this.part.index:-1,O=U===0&&p.id>1&&p.id===(C==null?void 0:C.stats.chunkCount),K=!M&&(U===1||U===0&&(x===1||O&&x<=0)),B=self.performance.now();(M||U||o.stats.parsing.start===0)&&(o.stats.parsing.start=B),l&&(x||!K)&&(l.stats.parsing.start=B);const at=!(C&&((v=o.initSegment)==null?void 0:v.url)===((E=C.initSegment)==null?void 0:E.url)),st=new oE(D,K,f,M,T,at);if(!K||D||at){X.log(`[transmuxer-interface, ${o.type}]: Starting new transmux session for sn: ${p.sn} p: ${p.part} level: ${p.level} id: ${p.id}
184
184
  discontinuity: ${D}
185
185
  trackSwitch: ${M}
186
186
  contiguous: ${K}
187
187
  accurateTimeOffset: ${f}
188
188
  timeOffset: ${T}
189
- initSegmentChange: ${at}`);const J=new oE(r,n,e,d,g);this.configureTransmuxer(J)}if(this.frag=o,this.part=l,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:t,decryptdata:w,chunkMeta:p,state:st},t instanceof ArrayBuffer?[t]:[]);else if(A){const J=A.push(t,w,p,st);sl(J)?(A.async=!0,J.then(kt=>{this.handleTransmuxComplete(kt)}).catch(kt=>{this.transmuxerError(kt,p,"transmuxer-interface push error")})):(A.async=!1,this.handleTransmuxComplete(J))}}flush(t){t.transmuxing.start=self.performance.now();const{transmuxer:e}=this;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:t});else if(e){let r=e.flush(t);sl(r)||e.async?(sl(r)||(r=Promise.resolve(r)),r.then(n=>{this.handleFlushResult(n,t)}).catch(n=>{this.transmuxerError(n,t,"transmuxer-interface flush error")})):this.handleFlushResult(r,t)}}transmuxerError(t,e,r){this.hls&&(this.error=t,this.hls.trigger(R.ERROR,{type:Qt.MEDIA_ERROR,details:ut.FRAG_PARSING_ERROR,chunkMeta:e,fatal:!1,error:t,err:t,reason:r}))}handleFlushResult(t,e){t.forEach(r=>{this.handleTransmuxComplete(r)}),this.onFlush(e)}onWorkerMessage(t){const e=t.data,r=this.hls;switch(e.event){case"init":{var n;const o=(n=this.workerContext)==null?void 0:n.objectURL;o&&self.URL.revokeObjectURL(o);break}case"transmuxComplete":{this.handleTransmuxComplete(e.data);break}case"flush":{this.onFlush(e.data);break}case"workerLog":X[e.data.logType]&&X[e.data.logType](e.data.message);break;default:{e.data=e.data||{},e.data.frag=this.frag,e.data.id=this.id,r.trigger(e.event,e.data);break}}}configureTransmuxer(t){const{transmuxer:e}=this;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:t}):e&&e.configure(t)}handleTransmuxComplete(t){t.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(t)}}const hE=250,mh=2,dE=.1,uE=.05;class fE{constructor(t,e,r,n){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=t,this.media=e,this.fragmentTracker=r,this.hls=n}destroy(){this.media=null,this.hls=this.fragmentTracker=null}poll(t,e){const{config:r,media:n,stalled:o}=this;if(n===null)return;const{currentTime:l,seeking:d}=n,f=this.seeking&&!d,p=!this.seeking&&d;if(this.seeking=d,l!==t){if(this.moved=!0,o!==null){if(this.stallReported){const D=self.performance.now()-o;X.warn(`playback not stuck anymore @${l}, after ${Math.round(D)}ms`),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if(p||f){this.stalled=null;return}if(n.paused&&!d||n.ended||n.playbackRate===0||!Ve.getBuffered(n).length)return;const g=Ve.bufferInfo(n,l,0),v=g.len>0,E=g.nextStart||0;if(!v&&!E)return;if(d){const D=g.len>mh,M=!E||e&&e.start<=l||E-l>mh&&!this.fragmentTracker.getPartialFragment(l);if(D||M)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var A;const D=Math.max(E,g.start||0)-l,M=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,U=!(M==null||(A=M.details)==null)&&A.live?M.details.targetduration*2:mh,x=this.fragmentTracker.getPartialFragment(l);if(D>0&&(D<=U||x)){this._trySkipBufferHole(x);return}}const T=self.performance.now();if(o===null){this.stalled=T;return}const w=T-o;if(!d&&w>=hE&&(this._reportStall(g),!this.media))return;const C=Ve.bufferInfo(n,l,r.maxBufferHole);this._tryFixBufferStall(C,w)}_tryFixBufferStall(t,e){const{config:r,fragmentTracker:n,media:o}=this;if(o===null)return;const l=o.currentTime,d=n.getPartialFragment(l);d&&(this._trySkipBufferHole(d)||!this.media)||(t.len>r.maxBufferHole||t.nextStart&&t.nextStart-l<r.maxBufferHole)&&e>r.highBufferWatchdogPeriod*1e3&&(X.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}_reportStall(t){const{hls:e,media:r,stallReported:n}=this;if(!n&&r){this.stallReported=!0;const o=new Error(`Playback stalling at @${r.currentTime} due to low buffer (${JSON.stringify(t)})`);X.warn(o.message),e.trigger(R.ERROR,{type:Qt.MEDIA_ERROR,details:ut.BUFFER_STALLED_ERROR,fatal:!1,error:o,buffer:t.len})}}_trySkipBufferHole(t){const{config:e,hls:r,media:n}=this;if(n===null)return 0;const o=n.currentTime,l=Ve.bufferInfo(n,o,0),d=o<l.start?l.start:l.nextStart;if(d){const f=l.len<=e.maxBufferHole,p=l.len>0&&l.len<1&&n.readyState<3,g=d-o;if(g>0&&(f||p)){if(g>e.maxBufferHole){const{fragmentTracker:E}=this;let A=!1;if(o===0){const T=E.getAppendedFrag(0,Jt.MAIN);T&&d<T.end&&(A=!0)}if(!A){const T=t||E.getAppendedFrag(o,Jt.MAIN);if(T){let w=!1,C=T.end;for(;C<d;){const D=E.getPartialFragment(C);if(D)C+=D.duration;else{w=!0;break}}if(w)return 0}}}const v=Math.max(d+uE,o+dE);if(X.warn(`skipping hole, adjusting currentTime from ${o} to ${v}`),this.moved=!0,this.stalled=null,n.currentTime=v,t&&!t.gap){const E=new Error(`fragment loaded with buffer holes, seeking from ${o} to ${v}`);r.trigger(R.ERROR,{type:Qt.MEDIA_ERROR,details:ut.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:E,reason:E.message,frag:t})}return v}}return 0}_tryNudgeBuffer(){const{config:t,hls:e,media:r,nudgeRetry:n}=this;if(r===null)return;const o=r.currentTime;if(this.nudgeRetry++,n<t.nudgeMaxRetry){const l=o+(n+1)*t.nudgeOffset,d=new Error(`Nudging 'currentTime' from ${o} to ${l}`);X.warn(d.message),r.currentTime=l,e.trigger(R.ERROR,{type:Qt.MEDIA_ERROR,details:ut.BUFFER_NUDGE_ON_STALL,error:d,fatal:!1})}else{const l=new Error(`Playhead still not moving while enough data buffered @${o} after ${t.nudgeMaxRetry} nudges`);X.error(l.message),e.trigger(R.ERROR,{type:Qt.MEDIA_ERROR,details:ut.BUFFER_STALLED_ERROR,error:l,fatal:!0})}}}const pE=100;class gE extends nh{constructor(t,e,r){super(t,e,r,"[stream-controller]",Jt.MAIN),this.audioCodecSwap=!1,this.gapController=null,this.level=-1,this._forceStartLoad=!1,this.altAudio=!1,this.audioOnly=!1,this.fragPlaying=null,this.onvplaying=null,this.onvseeked=null,this.fragLastKbps=0,this.couldBacktrack=!1,this.backtrackFragment=null,this.audioCodecSwitch=!1,this.videoBuffer=null,this._registerListeners()}_registerListeners(){const{hls:t}=this;t.on(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.MANIFEST_PARSED,this.onManifestParsed,this),t.on(R.LEVEL_LOADING,this.onLevelLoading,this),t.on(R.LEVEL_LOADED,this.onLevelLoaded,this),t.on(R.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.on(R.ERROR,this.onError,this),t.on(R.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(R.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(R.BUFFER_CREATED,this.onBufferCreated,this),t.on(R.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(R.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(R.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:t}=this;t.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.MANIFEST_PARSED,this.onManifestParsed,this),t.off(R.LEVEL_LOADED,this.onLevelLoaded,this),t.off(R.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.off(R.ERROR,this.onError,this),t.off(R.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(R.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(R.BUFFER_CREATED,this.onBufferCreated,this),t.off(R.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(R.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(R.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this._unregisterListeners(),this.onMediaDetaching()}startLoad(t){if(this.levels){const{lastCurrentTime:e,hls:r}=this;if(this.stopLoad(),this.setInterval(pE),this.level=-1,!this.startFragRequested){let n=r.startLevel;n===-1&&(r.config.testBandwidth&&this.levels.length>1?(n=0,this.bitrateTest=!0):n=r.nextAutoLevel),this.level=r.nextLoadLevel=n,this.loadedmetadata=!1}e>0&&t===-1&&(this.log(`Override startPosition with lastCurrentTime @${e.toFixed(3)}`),t=e),this.state=Rt.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this._forceStartLoad=!0,this.state=Rt.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case Rt.WAITING_LEVEL:{var t;const{levels:r,level:n}=this,o=r==null||(t=r[n])==null?void 0:t.details;if(o&&(!o.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(o))break;this.state=Rt.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=Rt.IDLE;break}break}case Rt.FRAG_LOADING_WAITING_RETRY:{var e;const r=self.performance.now(),n=this.retryDate;(!n||r>=n||(e=this.media)!=null&&e.seeking)&&(this.resetStartWhenNotLoaded(this.level),this.state=Rt.IDLE)}break}this.state===Rt.IDLE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){super.onTickEnd(),this.checkBuffer(),this.checkFragmentChanged()}doTickIdle(){const{hls:t,levelLastLoaded:e,levels:r,media:n}=this,{config:o,nextLoadLevel:l}=t;if(e===null||!n&&(this.startFragRequested||!o.startFragPrefetch)||this.altAudio&&this.audioOnly||!(r!=null&&r[l]))return;const d=r[l],f=this.getMainFwdBufferInfo();if(f===null)return;const p=this.getLevelDetails();if(p&&this._streamEnded(f,p)){const C={};this.altAudio&&(C.type="video"),this.hls.trigger(R.BUFFER_EOS,C),this.state=Rt.ENDED;return}t.loadLevel!==l&&t.manualLevel===-1&&this.log(`Adapting to level ${l} from level ${this.level}`),this.level=t.nextLoadLevel=l;const g=d.details;if(!g||this.state===Rt.WAITING_LEVEL||g.live&&this.levelLastLoaded!==l){this.level=l,this.state=Rt.WAITING_LEVEL;return}const v=f.len,E=this.getMaxBufferLength(d.maxBitrate);if(v>=E)return;this.backtrackFragment&&this.backtrackFragment.start>f.end&&(this.backtrackFragment=null);const A=this.backtrackFragment?this.backtrackFragment.start:f.end;let T=this.getNextFragment(A,g);if(this.couldBacktrack&&!this.fragPrevious&&T&&T.sn!=="initSegment"&&this.fragmentTracker.getState(T)!==vr.OK){var w;const C=((w=this.backtrackFragment)!=null?w:T).sn-g.startSN,D=g.fragments[C-1];D&&T.cc===D.cc&&(T=D,this.fragmentTracker.removeFragment(D))}else this.backtrackFragment&&f.len&&(this.backtrackFragment=null);if(T&&this.isLoopLoading(T,A)){if(!T.gap){const C=this.audioOnly&&!this.altAudio?Oe.AUDIO:Oe.VIDEO,D=(C===Oe.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;D&&this.afterBufferFlushed(D,C,Jt.MAIN)}T=this.getNextFragmentLoopLoading(T,g,f,Jt.MAIN,E)}T&&(T.initSegment&&!T.initSegment.data&&!this.bitrateTest&&(T=T.initSegment),this.loadFragment(T,d,A))}loadFragment(t,e,r){const n=this.fragmentTracker.getState(t);this.fragCurrent=t,n===vr.NOT_LOADED||n===vr.PARTIAL?t.sn==="initSegment"?this._loadInitSegment(t,e):this.bitrateTest?(this.log(`Fragment ${t.sn} of level ${t.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(t,e)):(this.startFragRequested=!0,super.loadFragment(t,e,r)):this.clearTrackerIfNeeded(t)}getBufferedFrag(t){return this.fragmentTracker.getBufferedFrag(t,Jt.MAIN)}followingBufferedFrag(t){return t?this.getBufferedFrag(t.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}nextLevelSwitch(){const{levels:t,media:e}=this;if(e!=null&&e.readyState){let r;const n=this.getAppendedFrag(e.currentTime);n&&n.start>1&&this.flushMainBuffer(0,n.start-1);const o=this.getLevelDetails();if(o!=null&&o.live){const d=this.getMainFwdBufferInfo();if(!d||d.len<o.targetduration*2)return}if(!e.paused&&t){const d=this.hls.nextLoadLevel,f=t[d],p=this.fragLastKbps;p&&this.fragCurrent?r=this.fragCurrent.duration*f.maxBitrate/(1e3*p)+1:r=0}else r=0;const l=this.getBufferedFrag(e.currentTime+r);if(l){const d=this.followingBufferedFrag(l);if(d){this.abortCurrentFrag();const f=d.maxStartPTS?d.maxStartPTS:d.start,p=d.duration,g=Math.max(l.end,f+Math.min(Math.max(p-this.config.maxFragLookUpTolerance,p*.5),p*.75));this.flushMainBuffer(g,Number.POSITIVE_INFINITY)}}}}abortCurrentFrag(){const t=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,t&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.state){case Rt.KEY_LOADING:case Rt.FRAG_LOADING:case Rt.FRAG_LOADING_WAITING_RETRY:case Rt.PARSING:case Rt.PARSED:this.state=Rt.IDLE;break}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(t,e){super.flushMainBuffer(t,e,this.altAudio?"video":null)}onMediaAttached(t,e){super.onMediaAttached(t,e);const r=e.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),r.addEventListener("playing",this.onvplaying),r.addEventListener("seeked",this.onvseeked),this.gapController=new fE(this.config,r,this.fragmentTracker,this.hls)}onMediaDetaching(){const{media:t}=this;t&&this.onvplaying&&this.onvseeked&&(t.removeEventListener("playing",this.onvplaying),t.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),super.onMediaDetaching()}onMediaPlaying(){this.tick()}onMediaSeeked(){const t=this.media,e=t?t.currentTime:null;jt(e)&&this.log(`Media seeked to ${e.toFixed(3)}`);const r=this.getMainFwdBufferInfo();if(r===null||r.len===0){this.warn(`Main forward buffer length on "seeked" event ${r?r.len:"empty"})`);return}this.tick()}onManifestLoading(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(R.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.levels=this.fragPlaying=this.backtrackFragment=null,this.altAudio=this.audioOnly=!1}onManifestParsed(t,e){let r=!1,n=!1,o;e.levels.forEach(l=>{o=l.audioCodec,o&&(o.indexOf("mp4a.40.2")!==-1&&(r=!0),o.indexOf("mp4a.40.5")!==-1&&(n=!0))}),this.audioCodecSwitch=r&&n&&!C4(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=e.levels,this.startFragRequested=!1}onLevelLoading(t,e){const{levels:r}=this;if(!r||this.state!==Rt.IDLE)return;const n=r[e.level];(!n.details||n.details.live&&this.levelLastLoaded!==e.level||this.waitForCdnTuneIn(n.details))&&(this.state=Rt.WAITING_LEVEL)}onLevelLoaded(t,e){var r;const{levels:n}=this,o=e.level,l=e.details,d=l.totalduration;if(!n){this.warn(`Levels were reset while loading level ${o}`);return}this.log(`Level ${o} loaded [${l.startSN},${l.endSN}]${l.lastPartSn?`[part-${l.lastPartSn}-${l.lastPartIndex}]`:""}, cc [${l.startCC}, ${l.endCC}] duration:${d}`);const f=n[o],p=this.fragCurrent;p&&(this.state===Rt.FRAG_LOADING||this.state===Rt.FRAG_LOADING_WAITING_RETRY)&&(p.level!==e.level||p.urlId!==f.urlId)&&p.loader&&this.abortCurrentFrag();let g=0;if(l.live||(r=f.details)!=null&&r.live){if(this.checkLiveUpdate(l),l.deltaUpdateFailed)return;g=this.alignPlaylists(l,f.details)}if(f.details=l,this.levelLastLoaded=o,this.hls.trigger(R.LEVEL_UPDATED,{details:l,level:o}),this.state===Rt.WAITING_LEVEL){if(this.waitForCdnTuneIn(l))return;this.state=Rt.IDLE}this.startFragRequested?l.live&&this.synchronizeToLiveEdge(l):this.setStartPosition(l,g),this.tick()}_handleFragmentLoadProgress(t){var e;const{frag:r,part:n,payload:o}=t,{levels:l}=this;if(!l){this.warn(`Levels were reset while fragment load was in progress. Fragment ${r.sn} of level ${r.level} will not be buffered`);return}const d=l[r.level],f=d.details;if(!f){this.warn(`Dropping fragment ${r.sn} of level ${r.level} after level details were reset`),this.fragmentTracker.removeFragment(r);return}const p=d.videoCodec,g=f.PTSKnown||!f.live,v=(e=r.initSegment)==null?void 0:e.data,E=this._getAudioCodec(d),A=this.transmuxer=this.transmuxer||new hp(this.hls,Jt.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),T=n?n.index:-1,w=T!==-1,C=new rh(r.level,r.sn,r.stats.chunkCount,o.byteLength,T,w),D=this.initPTS[r.cc];A.push(o,v,E,p,r,n,f.totalduration,g,C,D)}onAudioTrackSwitching(t,e){const r=this.altAudio;if(!e.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;const o=this.fragCurrent;o&&(this.log("Switching to main audio track, cancel main fragment load"),o.abortRequests(),this.fragmentTracker.removeFragment(o)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();const n=this.hls;r&&(n.trigger(R.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),n.trigger(R.AUDIO_TRACK_SWITCHED,e)}}onAudioTrackSwitched(t,e){const r=e.id,n=!!this.hls.audioTracks[r].url;if(n){const o=this.videoBuffer;o&&this.mediaBuffer!==o&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=o)}this.altAudio=n,this.tick()}onBufferCreated(t,e){const r=e.tracks;let n,o,l=!1;for(const d in r){const f=r[d];if(f.id==="main"){if(o=d,n=f,d==="video"){const p=r[d];p&&(this.videoBuffer=p.buffer)}}else l=!0}l&&n?(this.log(`Alternate track found, use ${o}.buffered to schedule main fragment loading`),this.mediaBuffer=n.buffer):this.mediaBuffer=this.media}onFragBuffered(t,e){const{frag:r,part:n}=e;if(r&&r.type!==Jt.MAIN)return;if(this.fragContextChanged(r)){this.warn(`Fragment ${r.sn}${n?" p: "+n.index:""} of level ${r.level} finished buffering, but was aborted. state: ${this.state}`),this.state===Rt.PARSED&&(this.state=Rt.IDLE);return}const o=n?n.stats:r.stats;this.fragLastKbps=Math.round(8*o.total/(o.buffering.end-o.loading.first)),r.sn!=="initSegment"&&(this.fragPrevious=r),this.fragBufferedComplete(r,n)}onError(t,e){var r;if(e.fatal){this.state=Rt.ERROR;return}switch(e.details){case ut.FRAG_GAP:case ut.FRAG_PARSING_ERROR:case ut.FRAG_DECRYPT_ERROR:case ut.FRAG_LOAD_ERROR:case ut.FRAG_LOAD_TIMEOUT:case ut.KEY_LOAD_ERROR:case ut.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Jt.MAIN,e);break;case ut.LEVEL_LOAD_ERROR:case ut.LEVEL_LOAD_TIMEOUT:case ut.LEVEL_PARSING_ERROR:!e.levelRetry&&this.state===Rt.WAITING_LEVEL&&((r=e.context)==null?void 0:r.type)===Se.LEVEL&&(this.state=Rt.IDLE);break;case ut.BUFFER_FULL_ERROR:if(!e.parent||e.parent!=="main")return;this.reduceLengthAndFlushBuffer(e)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case ut.INTERNAL_EXCEPTION:this.recoverWorkerError(e);break}}checkBuffer(){const{media:t,gapController:e}=this;if(!(!t||!e||!t.readyState)){if(this.loadedmetadata||!Ve.getBuffered(t).length){const r=this.state!==Rt.IDLE?this.fragCurrent:null;e.poll(this.lastCurrentTime,r)}this.lastCurrentTime=t.currentTime}}onFragLoadEmergencyAborted(){this.state=Rt.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()}onBufferFlushed(t,{type:e}){if(e!==Oe.AUDIO||this.audioOnly&&!this.altAudio){const r=(e===Oe.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(r,e,Jt.MAIN)}}onLevelsUpdated(t,e){this.levels=e.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){const{media:t}=this;if(!t)return;const e=t.currentTime;let r=this.startPosition;if(r>=0&&e<r){if(t.seeking){this.log(`could not seek to ${r}, already seeking at ${e}`);return}const n=Ve.getBuffered(t),o=(n.length?n.start(0):0)-r;o>0&&(o<this.config.maxBufferHole||o<this.config.maxFragLookUpTolerance)&&(this.log(`adjusting start position by ${o} to match buffer start`),r+=o,this.startPosition=r),this.log(`seek to target start position ${r} from current time ${e}`),t.currentTime=r}}_getAudioCodec(t){let e=this.config.defaultAudioCodec||t.audioCodec;return this.audioCodecSwap&&e&&(this.log("Swapping audio codec"),e.indexOf("mp4a.40.5")!==-1?e="mp4a.40.2":e="mp4a.40.5"),e}_loadBitrateTestFrag(t,e){t.bitrateTest=!0,this._doFragLoad(t,e).then(r=>{const{hls:n}=this;if(!r||this.fragContextChanged(t))return;e.fragmentError=0,this.state=Rt.IDLE,this.startFragRequested=!1,this.bitrateTest=!1;const o=t.stats;o.parsing.start=o.parsing.end=o.buffering.start=o.buffering.end=self.performance.now(),n.trigger(R.FRAG_LOADED,r),t.bitrateTest=!1})}_handleTransmuxComplete(t){var e;const r="main",{hls:n}=this,{remuxResult:o,chunkMeta:l}=t,d=this.getCurrentContext(l);if(!d){this.resetWhenMissingContext(l);return}const{frag:f,part:p,level:g}=d,{video:v,text:E,id3:A,initSegment:T}=o,{details:w}=g,C=this.altAudio?void 0:o.audio;if(this.fragContextChanged(f)){this.fragmentTracker.removeFragment(f);return}if(this.state=Rt.PARSING,T){if(T!=null&&T.tracks){const U=f.initSegment||f;this._bufferInitSegment(g,T.tracks,U,l),n.trigger(R.FRAG_PARSING_INIT_SEGMENT,{frag:U,id:r,tracks:T.tracks})}const D=T.initPTS,M=T.timescale;jt(D)&&(this.initPTS[f.cc]={baseTime:D,timescale:M},n.trigger(R.INIT_PTS_FOUND,{frag:f,id:r,initPTS:D,timescale:M}))}if(v&&w&&f.sn!=="initSegment"){const D=w.fragments[f.sn-1-w.startSN],M=f.sn===w.startSN,U=!D||f.cc>D.cc;if(o.independent!==!1){const{startPTS:x,endPTS:O,startDTS:K,endDTS:B}=v;if(p)p.elementaryStreams[v.type]={startPTS:x,endPTS:O,startDTS:K,endDTS:B};else if(v.firstKeyFrame&&v.independent&&l.id===1&&!U&&(this.couldBacktrack=!0),v.dropped&&v.independent){const at=this.getMainFwdBufferInfo(),st=(at?at.end:this.getLoadPosition())+this.config.maxBufferHole,J=v.firstKeyFramePTS?v.firstKeyFramePTS:x;if(!M&&st<J-this.config.maxBufferHole&&!U){this.backtrack(f);return}else U&&(f.gap=!0);f.setElementaryStreamInfo(v.type,f.start,O,f.start,B,!0)}f.setElementaryStreamInfo(v.type,x,O,K,B),this.backtrackFragment&&(this.backtrackFragment=f),this.bufferFragmentData(v,f,p,l,M||U)}else if(M||U)f.gap=!0;else{this.backtrack(f);return}}if(C){const{startPTS:D,endPTS:M,startDTS:U,endDTS:x}=C;p&&(p.elementaryStreams[Oe.AUDIO]={startPTS:D,endPTS:M,startDTS:U,endDTS:x}),f.setElementaryStreamInfo(Oe.AUDIO,D,M,U,x),this.bufferFragmentData(C,f,p,l)}if(w&&A!=null&&(e=A.samples)!=null&&e.length){const D={id:r,frag:f,details:w,samples:A.samples};n.trigger(R.FRAG_PARSING_METADATA,D)}if(w&&E){const D={id:r,frag:f,details:w,samples:E.samples};n.trigger(R.FRAG_PARSING_USERDATA,D)}}_bufferInitSegment(t,e,r,n){if(this.state!==Rt.PARSING)return;this.audioOnly=!!e.audio&&!e.video,this.altAudio&&!this.audioOnly&&delete e.audio;const{audio:o,video:l,audiovideo:d}=e;if(o){let f=t.audioCodec;const p=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(f&&(f.indexOf("mp4a.40.5")!==-1?f="mp4a.40.2":f="mp4a.40.5"),o.metadata.channelCount!==1&&p.indexOf("firefox")===-1&&(f="mp4a.40.5")),p.indexOf("android")!==-1&&o.container!=="audio/mpeg"&&(f="mp4a.40.2",this.log(`Android: force audio codec to ${f}`)),t.audioCodec&&t.audioCodec!==f&&this.log(`Swapping manifest audio codec "${t.audioCodec}" for "${f}"`),o.levelCodec=f,o.id="main",this.log(`Init audio buffer, container:${o.container}, codecs[selected/level/parsed]=[${f||""}/${t.audioCodec||""}/${o.codec}]`)}l&&(l.levelCodec=t.videoCodec,l.id="main",this.log(`Init video buffer, container:${l.container}, codecs[level/parsed]=[${t.videoCodec||""}/${l.codec}]`)),d&&this.log(`Init audiovideo buffer, container:${d.container}, codecs[level/parsed]=[${t.attrs.CODECS||""}/${d.codec}]`),this.hls.trigger(R.BUFFER_CODECS,e),Object.keys(e).forEach(f=>{const p=e[f].initSegment;p!=null&&p.byteLength&&this.hls.trigger(R.BUFFER_APPENDING,{type:f,data:p,frag:r,part:null,chunkMeta:n,parent:r.type})}),this.tick()}getMainFwdBufferInfo(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,Jt.MAIN)}backtrack(t){this.couldBacktrack=!0,this.backtrackFragment=t,this.resetTransmuxer(),this.flushBufferGap(t),this.fragmentTracker.removeFragment(t),this.fragPrevious=null,this.nextLoadPosition=t.start,this.state=Rt.IDLE}checkFragmentChanged(){const t=this.media;let e=null;if(t&&t.readyState>1&&t.seeking===!1){const r=t.currentTime;if(Ve.isBuffered(t,r)?e=this.getAppendedFrag(r):Ve.isBuffered(t,r+.1)&&(e=this.getAppendedFrag(r+.1)),e){this.backtrackFragment=null;const n=this.fragPlaying,o=e.level;(!n||e.sn!==n.sn||n.level!==o||e.urlId!==n.urlId)&&(this.fragPlaying=e,this.hls.trigger(R.FRAG_CHANGED,{frag:e}),(!n||n.level!==o)&&this.hls.trigger(R.LEVEL_SWITCHED,{level:o}))}}}get nextLevel(){const t=this.nextBufferedFrag;return t?t.level:-1}get currentFrag(){const t=this.media;return t?this.fragPlaying||this.getAppendedFrag(t.currentTime):null}get currentProgramDateTime(){const t=this.media;if(t){const e=t.currentTime,r=this.currentFrag;if(r&&jt(e)&&jt(r.programDateTime)){const n=r.programDateTime+(e-r.start)*1e3;return new Date(n)}}return null}get currentLevel(){const t=this.currentFrag;return t?t.level:-1}get nextBufferedFrag(){const t=this.currentFrag;return t?this.followingBufferedFrag(t):null}get forceStartLoad(){return this._forceStartLoad}}class On{constructor(t,e=0,r=0){this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=t,this.alpha_=t?Math.exp(Math.log(.5)/t):0,this.estimate_=e,this.totalWeight_=r}sample(t,e){const r=Math.pow(this.alpha_,t);this.estimate_=e*(1-r)+r*this.estimate_,this.totalWeight_+=t}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){const t=1-Math.pow(this.alpha_,this.totalWeight_);if(t)return this.estimate_/t}return this.estimate_}}class mE{constructor(t,e,r,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_=r,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new On(t),this.fast_=new On(e),this.defaultTTFB_=n,this.ttfb_=new On(t)}update(t,e){const{slow_:r,fast_:n,ttfb_:o}=this;r.halfLife!==t&&(this.slow_=new On(t,r.getEstimate(),r.getTotalWeight())),n.halfLife!==e&&(this.fast_=new On(e,n.getEstimate(),n.getTotalWeight())),o.halfLife!==t&&(this.ttfb_=new On(t,o.getEstimate(),o.getTotalWeight()))}sample(t,e){t=Math.max(t,this.minDelayMs_);const r=8*e,n=t/1e3,o=r/n;this.fast_.sample(n,o),this.slow_.sample(n,o)}sampleTTFB(t){const e=t/1e3,r=Math.sqrt(2)*Math.exp(-Math.pow(e,2)/2);this.ttfb_.sample(r,Math.max(t,5))}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}destroy(){}}class vE{constructor(t){this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=-1,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=t;const e=t.config;this.bwEstimator=new mE(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate),this.registerListeners()}registerListeners(){const{hls:t}=this;t.on(R.FRAG_LOADING,this.onFragLoading,this),t.on(R.FRAG_LOADED,this.onFragLoaded,this),t.on(R.FRAG_BUFFERED,this.onFragBuffered,this),t.on(R.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(R.LEVEL_LOADED,this.onLevelLoaded,this)}unregisterListeners(){const{hls:t}=this;t.off(R.FRAG_LOADING,this.onFragLoading,this),t.off(R.FRAG_LOADED,this.onFragLoaded,this),t.off(R.FRAG_BUFFERED,this.onFragBuffered,this),t.off(R.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(R.LEVEL_LOADED,this.onLevelLoaded,this)}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null}onFragLoading(t,e){var r;const n=e.frag;this.ignoreFragment(n)||(this.fragCurrent=n,this.partCurrent=(r=e.part)!=null?r:null,this.clearTimer(),this.timer=self.setInterval(this.onCheck,100))}onLevelSwitching(t,e){this.clearTimer()}getTimeToLoadFrag(t,e,r,n){const o=t+r/e,l=n?this.lastLevelLoadSec:0;return o+l}onLevelLoaded(t,e){const r=this.hls.config,{total:n,bwEstimate:o}=e.stats;jt(n)&&jt(o)&&(this.lastLevelLoadSec=8*n/o),e.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)}_abandonRulesCheck(){const{fragCurrent:t,partCurrent:e,hls:r}=this,{autoLevelEnabled:n,media:o}=r;if(!t||!o)return;const l=performance.now(),d=e?e.stats:t.stats,f=e?e.duration:t.duration,p=l-d.loading.start;if(d.aborted||d.loaded&&d.loaded===d.total||t.level===0){this.clearTimer(),this._nextAutoLevel=-1;return}if(!n||o.paused||!o.playbackRate||!o.readyState)return;const g=r.mainForwardBufferInfo;if(g===null)return;const v=this.bwEstimator.getEstimateTTFB(),E=Math.abs(o.playbackRate);if(p<=Math.max(v,1e3*(f/(E*2))))return;const A=g.len/E;if(A>=2*f/E)return;const T=d.loading.first?d.loading.first-d.loading.start:-1,w=d.loaded&&T>-1,C=this.bwEstimator.getEstimate(),{levels:D,minAutoLevel:M}=r,U=D[t.level],x=d.total||Math.max(d.loaded,Math.round(f*U.maxBitrate/8));let O=p-T;O<1&&w&&(O=Math.min(p,d.loaded*8/C));const K=w?d.loaded*1e3/O:0,B=K?(x-d.loaded)/K:x*8/C+v/1e3;if(B<=A)return;const at=K?K*8:C;let st=Number.POSITIVE_INFINITY,J;for(J=t.level-1;J>M;J--){const kt=D[J].maxBitrate;if(st=this.getTimeToLoadFrag(v/1e3,at,f*kt,!D[J].details),st<A)break}st>=B||st>f*10||(r.nextLoadLevel=J,w?this.bwEstimator.sample(p-Math.min(v,T),d.loaded):this.bwEstimator.sampleTTFB(p),this.clearTimer(),X.warn(`[abr] Fragment ${t.sn}${e?" part "+e.index:""} of level ${t.level} is loading too slowly;
189
+ initSegmentChange: ${at}`);const J=new aE(r,n,e,d,g);this.configureTransmuxer(J)}if(this.frag=o,this.part=l,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:t,decryptdata:w,chunkMeta:p,state:st},t instanceof ArrayBuffer?[t]:[]);else if(A){const J=A.push(t,w,p,st);sl(J)?(A.async=!0,J.then(kt=>{this.handleTransmuxComplete(kt)}).catch(kt=>{this.transmuxerError(kt,p,"transmuxer-interface push error")})):(A.async=!1,this.handleTransmuxComplete(J))}}flush(t){t.transmuxing.start=self.performance.now();const{transmuxer:e}=this;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:t});else if(e){let r=e.flush(t);sl(r)||e.async?(sl(r)||(r=Promise.resolve(r)),r.then(n=>{this.handleFlushResult(n,t)}).catch(n=>{this.transmuxerError(n,t,"transmuxer-interface flush error")})):this.handleFlushResult(r,t)}}transmuxerError(t,e,r){this.hls&&(this.error=t,this.hls.trigger(R.ERROR,{type:Qt.MEDIA_ERROR,details:ut.FRAG_PARSING_ERROR,chunkMeta:e,fatal:!1,error:t,err:t,reason:r}))}handleFlushResult(t,e){t.forEach(r=>{this.handleTransmuxComplete(r)}),this.onFlush(e)}onWorkerMessage(t){const e=t.data,r=this.hls;switch(e.event){case"init":{var n;const o=(n=this.workerContext)==null?void 0:n.objectURL;o&&self.URL.revokeObjectURL(o);break}case"transmuxComplete":{this.handleTransmuxComplete(e.data);break}case"flush":{this.onFlush(e.data);break}case"workerLog":X[e.data.logType]&&X[e.data.logType](e.data.message);break;default:{e.data=e.data||{},e.data.frag=this.frag,e.data.id=this.id,r.trigger(e.event,e.data);break}}}configureTransmuxer(t){const{transmuxer:e}=this;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:t}):e&&e.configure(t)}handleTransmuxComplete(t){t.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(t)}}const cE=250,mh=2,hE=.1,dE=.05;class uE{constructor(t,e,r,n){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=t,this.media=e,this.fragmentTracker=r,this.hls=n}destroy(){this.media=null,this.hls=this.fragmentTracker=null}poll(t,e){const{config:r,media:n,stalled:o}=this;if(n===null)return;const{currentTime:l,seeking:d}=n,f=this.seeking&&!d,p=!this.seeking&&d;if(this.seeking=d,l!==t){if(this.moved=!0,o!==null){if(this.stallReported){const D=self.performance.now()-o;X.warn(`playback not stuck anymore @${l}, after ${Math.round(D)}ms`),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if(p||f){this.stalled=null;return}if(n.paused&&!d||n.ended||n.playbackRate===0||!Ve.getBuffered(n).length)return;const g=Ve.bufferInfo(n,l,0),v=g.len>0,E=g.nextStart||0;if(!v&&!E)return;if(d){const D=g.len>mh,M=!E||e&&e.start<=l||E-l>mh&&!this.fragmentTracker.getPartialFragment(l);if(D||M)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var A;const D=Math.max(E,g.start||0)-l,M=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,U=!(M==null||(A=M.details)==null)&&A.live?M.details.targetduration*2:mh,x=this.fragmentTracker.getPartialFragment(l);if(D>0&&(D<=U||x)){this._trySkipBufferHole(x);return}}const T=self.performance.now();if(o===null){this.stalled=T;return}const w=T-o;if(!d&&w>=cE&&(this._reportStall(g),!this.media))return;const C=Ve.bufferInfo(n,l,r.maxBufferHole);this._tryFixBufferStall(C,w)}_tryFixBufferStall(t,e){const{config:r,fragmentTracker:n,media:o}=this;if(o===null)return;const l=o.currentTime,d=n.getPartialFragment(l);d&&(this._trySkipBufferHole(d)||!this.media)||(t.len>r.maxBufferHole||t.nextStart&&t.nextStart-l<r.maxBufferHole)&&e>r.highBufferWatchdogPeriod*1e3&&(X.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}_reportStall(t){const{hls:e,media:r,stallReported:n}=this;if(!n&&r){this.stallReported=!0;const o=new Error(`Playback stalling at @${r.currentTime} due to low buffer (${JSON.stringify(t)})`);X.warn(o.message),e.trigger(R.ERROR,{type:Qt.MEDIA_ERROR,details:ut.BUFFER_STALLED_ERROR,fatal:!1,error:o,buffer:t.len})}}_trySkipBufferHole(t){const{config:e,hls:r,media:n}=this;if(n===null)return 0;const o=n.currentTime,l=Ve.bufferInfo(n,o,0),d=o<l.start?l.start:l.nextStart;if(d){const f=l.len<=e.maxBufferHole,p=l.len>0&&l.len<1&&n.readyState<3,g=d-o;if(g>0&&(f||p)){if(g>e.maxBufferHole){const{fragmentTracker:E}=this;let A=!1;if(o===0){const T=E.getAppendedFrag(0,Jt.MAIN);T&&d<T.end&&(A=!0)}if(!A){const T=t||E.getAppendedFrag(o,Jt.MAIN);if(T){let w=!1,C=T.end;for(;C<d;){const D=E.getPartialFragment(C);if(D)C+=D.duration;else{w=!0;break}}if(w)return 0}}}const v=Math.max(d+dE,o+hE);if(X.warn(`skipping hole, adjusting currentTime from ${o} to ${v}`),this.moved=!0,this.stalled=null,n.currentTime=v,t&&!t.gap){const E=new Error(`fragment loaded with buffer holes, seeking from ${o} to ${v}`);r.trigger(R.ERROR,{type:Qt.MEDIA_ERROR,details:ut.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:E,reason:E.message,frag:t})}return v}}return 0}_tryNudgeBuffer(){const{config:t,hls:e,media:r,nudgeRetry:n}=this;if(r===null)return;const o=r.currentTime;if(this.nudgeRetry++,n<t.nudgeMaxRetry){const l=o+(n+1)*t.nudgeOffset,d=new Error(`Nudging 'currentTime' from ${o} to ${l}`);X.warn(d.message),r.currentTime=l,e.trigger(R.ERROR,{type:Qt.MEDIA_ERROR,details:ut.BUFFER_NUDGE_ON_STALL,error:d,fatal:!1})}else{const l=new Error(`Playhead still not moving while enough data buffered @${o} after ${t.nudgeMaxRetry} nudges`);X.error(l.message),e.trigger(R.ERROR,{type:Qt.MEDIA_ERROR,details:ut.BUFFER_STALLED_ERROR,error:l,fatal:!0})}}}const fE=100;class pE extends nh{constructor(t,e,r){super(t,e,r,"[stream-controller]",Jt.MAIN),this.audioCodecSwap=!1,this.gapController=null,this.level=-1,this._forceStartLoad=!1,this.altAudio=!1,this.audioOnly=!1,this.fragPlaying=null,this.onvplaying=null,this.onvseeked=null,this.fragLastKbps=0,this.couldBacktrack=!1,this.backtrackFragment=null,this.audioCodecSwitch=!1,this.videoBuffer=null,this._registerListeners()}_registerListeners(){const{hls:t}=this;t.on(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.MANIFEST_PARSED,this.onManifestParsed,this),t.on(R.LEVEL_LOADING,this.onLevelLoading,this),t.on(R.LEVEL_LOADED,this.onLevelLoaded,this),t.on(R.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.on(R.ERROR,this.onError,this),t.on(R.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(R.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(R.BUFFER_CREATED,this.onBufferCreated,this),t.on(R.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(R.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(R.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:t}=this;t.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.MANIFEST_PARSED,this.onManifestParsed,this),t.off(R.LEVEL_LOADED,this.onLevelLoaded,this),t.off(R.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.off(R.ERROR,this.onError,this),t.off(R.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(R.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(R.BUFFER_CREATED,this.onBufferCreated,this),t.off(R.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(R.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(R.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this._unregisterListeners(),this.onMediaDetaching()}startLoad(t){if(this.levels){const{lastCurrentTime:e,hls:r}=this;if(this.stopLoad(),this.setInterval(fE),this.level=-1,!this.startFragRequested){let n=r.startLevel;n===-1&&(r.config.testBandwidth&&this.levels.length>1?(n=0,this.bitrateTest=!0):n=r.nextAutoLevel),this.level=r.nextLoadLevel=n,this.loadedmetadata=!1}e>0&&t===-1&&(this.log(`Override startPosition with lastCurrentTime @${e.toFixed(3)}`),t=e),this.state=Rt.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this._forceStartLoad=!0,this.state=Rt.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case Rt.WAITING_LEVEL:{var t;const{levels:r,level:n}=this,o=r==null||(t=r[n])==null?void 0:t.details;if(o&&(!o.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(o))break;this.state=Rt.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=Rt.IDLE;break}break}case Rt.FRAG_LOADING_WAITING_RETRY:{var e;const r=self.performance.now(),n=this.retryDate;(!n||r>=n||(e=this.media)!=null&&e.seeking)&&(this.resetStartWhenNotLoaded(this.level),this.state=Rt.IDLE)}break}this.state===Rt.IDLE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){super.onTickEnd(),this.checkBuffer(),this.checkFragmentChanged()}doTickIdle(){const{hls:t,levelLastLoaded:e,levels:r,media:n}=this,{config:o,nextLoadLevel:l}=t;if(e===null||!n&&(this.startFragRequested||!o.startFragPrefetch)||this.altAudio&&this.audioOnly||!(r!=null&&r[l]))return;const d=r[l],f=this.getMainFwdBufferInfo();if(f===null)return;const p=this.getLevelDetails();if(p&&this._streamEnded(f,p)){const C={};this.altAudio&&(C.type="video"),this.hls.trigger(R.BUFFER_EOS,C),this.state=Rt.ENDED;return}t.loadLevel!==l&&t.manualLevel===-1&&this.log(`Adapting to level ${l} from level ${this.level}`),this.level=t.nextLoadLevel=l;const g=d.details;if(!g||this.state===Rt.WAITING_LEVEL||g.live&&this.levelLastLoaded!==l){this.level=l,this.state=Rt.WAITING_LEVEL;return}const v=f.len,E=this.getMaxBufferLength(d.maxBitrate);if(v>=E)return;this.backtrackFragment&&this.backtrackFragment.start>f.end&&(this.backtrackFragment=null);const A=this.backtrackFragment?this.backtrackFragment.start:f.end;let T=this.getNextFragment(A,g);if(this.couldBacktrack&&!this.fragPrevious&&T&&T.sn!=="initSegment"&&this.fragmentTracker.getState(T)!==vr.OK){var w;const C=((w=this.backtrackFragment)!=null?w:T).sn-g.startSN,D=g.fragments[C-1];D&&T.cc===D.cc&&(T=D,this.fragmentTracker.removeFragment(D))}else this.backtrackFragment&&f.len&&(this.backtrackFragment=null);if(T&&this.isLoopLoading(T,A)){if(!T.gap){const C=this.audioOnly&&!this.altAudio?Oe.AUDIO:Oe.VIDEO,D=(C===Oe.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;D&&this.afterBufferFlushed(D,C,Jt.MAIN)}T=this.getNextFragmentLoopLoading(T,g,f,Jt.MAIN,E)}T&&(T.initSegment&&!T.initSegment.data&&!this.bitrateTest&&(T=T.initSegment),this.loadFragment(T,d,A))}loadFragment(t,e,r){const n=this.fragmentTracker.getState(t);this.fragCurrent=t,n===vr.NOT_LOADED||n===vr.PARTIAL?t.sn==="initSegment"?this._loadInitSegment(t,e):this.bitrateTest?(this.log(`Fragment ${t.sn} of level ${t.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(t,e)):(this.startFragRequested=!0,super.loadFragment(t,e,r)):this.clearTrackerIfNeeded(t)}getBufferedFrag(t){return this.fragmentTracker.getBufferedFrag(t,Jt.MAIN)}followingBufferedFrag(t){return t?this.getBufferedFrag(t.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}nextLevelSwitch(){const{levels:t,media:e}=this;if(e!=null&&e.readyState){let r;const n=this.getAppendedFrag(e.currentTime);n&&n.start>1&&this.flushMainBuffer(0,n.start-1);const o=this.getLevelDetails();if(o!=null&&o.live){const d=this.getMainFwdBufferInfo();if(!d||d.len<o.targetduration*2)return}if(!e.paused&&t){const d=this.hls.nextLoadLevel,f=t[d],p=this.fragLastKbps;p&&this.fragCurrent?r=this.fragCurrent.duration*f.maxBitrate/(1e3*p)+1:r=0}else r=0;const l=this.getBufferedFrag(e.currentTime+r);if(l){const d=this.followingBufferedFrag(l);if(d){this.abortCurrentFrag();const f=d.maxStartPTS?d.maxStartPTS:d.start,p=d.duration,g=Math.max(l.end,f+Math.min(Math.max(p-this.config.maxFragLookUpTolerance,p*.5),p*.75));this.flushMainBuffer(g,Number.POSITIVE_INFINITY)}}}}abortCurrentFrag(){const t=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,t&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.state){case Rt.KEY_LOADING:case Rt.FRAG_LOADING:case Rt.FRAG_LOADING_WAITING_RETRY:case Rt.PARSING:case Rt.PARSED:this.state=Rt.IDLE;break}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(t,e){super.flushMainBuffer(t,e,this.altAudio?"video":null)}onMediaAttached(t,e){super.onMediaAttached(t,e);const r=e.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),r.addEventListener("playing",this.onvplaying),r.addEventListener("seeked",this.onvseeked),this.gapController=new uE(this.config,r,this.fragmentTracker,this.hls)}onMediaDetaching(){const{media:t}=this;t&&this.onvplaying&&this.onvseeked&&(t.removeEventListener("playing",this.onvplaying),t.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),super.onMediaDetaching()}onMediaPlaying(){this.tick()}onMediaSeeked(){const t=this.media,e=t?t.currentTime:null;jt(e)&&this.log(`Media seeked to ${e.toFixed(3)}`);const r=this.getMainFwdBufferInfo();if(r===null||r.len===0){this.warn(`Main forward buffer length on "seeked" event ${r?r.len:"empty"})`);return}this.tick()}onManifestLoading(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(R.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.levels=this.fragPlaying=this.backtrackFragment=null,this.altAudio=this.audioOnly=!1}onManifestParsed(t,e){let r=!1,n=!1,o;e.levels.forEach(l=>{o=l.audioCodec,o&&(o.indexOf("mp4a.40.2")!==-1&&(r=!0),o.indexOf("mp4a.40.5")!==-1&&(n=!0))}),this.audioCodecSwitch=r&&n&&!L4(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=e.levels,this.startFragRequested=!1}onLevelLoading(t,e){const{levels:r}=this;if(!r||this.state!==Rt.IDLE)return;const n=r[e.level];(!n.details||n.details.live&&this.levelLastLoaded!==e.level||this.waitForCdnTuneIn(n.details))&&(this.state=Rt.WAITING_LEVEL)}onLevelLoaded(t,e){var r;const{levels:n}=this,o=e.level,l=e.details,d=l.totalduration;if(!n){this.warn(`Levels were reset while loading level ${o}`);return}this.log(`Level ${o} loaded [${l.startSN},${l.endSN}]${l.lastPartSn?`[part-${l.lastPartSn}-${l.lastPartIndex}]`:""}, cc [${l.startCC}, ${l.endCC}] duration:${d}`);const f=n[o],p=this.fragCurrent;p&&(this.state===Rt.FRAG_LOADING||this.state===Rt.FRAG_LOADING_WAITING_RETRY)&&(p.level!==e.level||p.urlId!==f.urlId)&&p.loader&&this.abortCurrentFrag();let g=0;if(l.live||(r=f.details)!=null&&r.live){if(this.checkLiveUpdate(l),l.deltaUpdateFailed)return;g=this.alignPlaylists(l,f.details)}if(f.details=l,this.levelLastLoaded=o,this.hls.trigger(R.LEVEL_UPDATED,{details:l,level:o}),this.state===Rt.WAITING_LEVEL){if(this.waitForCdnTuneIn(l))return;this.state=Rt.IDLE}this.startFragRequested?l.live&&this.synchronizeToLiveEdge(l):this.setStartPosition(l,g),this.tick()}_handleFragmentLoadProgress(t){var e;const{frag:r,part:n,payload:o}=t,{levels:l}=this;if(!l){this.warn(`Levels were reset while fragment load was in progress. Fragment ${r.sn} of level ${r.level} will not be buffered`);return}const d=l[r.level],f=d.details;if(!f){this.warn(`Dropping fragment ${r.sn} of level ${r.level} after level details were reset`),this.fragmentTracker.removeFragment(r);return}const p=d.videoCodec,g=f.PTSKnown||!f.live,v=(e=r.initSegment)==null?void 0:e.data,E=this._getAudioCodec(d),A=this.transmuxer=this.transmuxer||new hp(this.hls,Jt.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),T=n?n.index:-1,w=T!==-1,C=new rh(r.level,r.sn,r.stats.chunkCount,o.byteLength,T,w),D=this.initPTS[r.cc];A.push(o,v,E,p,r,n,f.totalduration,g,C,D)}onAudioTrackSwitching(t,e){const r=this.altAudio;if(!e.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;const o=this.fragCurrent;o&&(this.log("Switching to main audio track, cancel main fragment load"),o.abortRequests(),this.fragmentTracker.removeFragment(o)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();const n=this.hls;r&&(n.trigger(R.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),n.trigger(R.AUDIO_TRACK_SWITCHED,e)}}onAudioTrackSwitched(t,e){const r=e.id,n=!!this.hls.audioTracks[r].url;if(n){const o=this.videoBuffer;o&&this.mediaBuffer!==o&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=o)}this.altAudio=n,this.tick()}onBufferCreated(t,e){const r=e.tracks;let n,o,l=!1;for(const d in r){const f=r[d];if(f.id==="main"){if(o=d,n=f,d==="video"){const p=r[d];p&&(this.videoBuffer=p.buffer)}}else l=!0}l&&n?(this.log(`Alternate track found, use ${o}.buffered to schedule main fragment loading`),this.mediaBuffer=n.buffer):this.mediaBuffer=this.media}onFragBuffered(t,e){const{frag:r,part:n}=e;if(r&&r.type!==Jt.MAIN)return;if(this.fragContextChanged(r)){this.warn(`Fragment ${r.sn}${n?" p: "+n.index:""} of level ${r.level} finished buffering, but was aborted. state: ${this.state}`),this.state===Rt.PARSED&&(this.state=Rt.IDLE);return}const o=n?n.stats:r.stats;this.fragLastKbps=Math.round(8*o.total/(o.buffering.end-o.loading.first)),r.sn!=="initSegment"&&(this.fragPrevious=r),this.fragBufferedComplete(r,n)}onError(t,e){var r;if(e.fatal){this.state=Rt.ERROR;return}switch(e.details){case ut.FRAG_GAP:case ut.FRAG_PARSING_ERROR:case ut.FRAG_DECRYPT_ERROR:case ut.FRAG_LOAD_ERROR:case ut.FRAG_LOAD_TIMEOUT:case ut.KEY_LOAD_ERROR:case ut.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Jt.MAIN,e);break;case ut.LEVEL_LOAD_ERROR:case ut.LEVEL_LOAD_TIMEOUT:case ut.LEVEL_PARSING_ERROR:!e.levelRetry&&this.state===Rt.WAITING_LEVEL&&((r=e.context)==null?void 0:r.type)===Se.LEVEL&&(this.state=Rt.IDLE);break;case ut.BUFFER_FULL_ERROR:if(!e.parent||e.parent!=="main")return;this.reduceLengthAndFlushBuffer(e)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case ut.INTERNAL_EXCEPTION:this.recoverWorkerError(e);break}}checkBuffer(){const{media:t,gapController:e}=this;if(!(!t||!e||!t.readyState)){if(this.loadedmetadata||!Ve.getBuffered(t).length){const r=this.state!==Rt.IDLE?this.fragCurrent:null;e.poll(this.lastCurrentTime,r)}this.lastCurrentTime=t.currentTime}}onFragLoadEmergencyAborted(){this.state=Rt.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()}onBufferFlushed(t,{type:e}){if(e!==Oe.AUDIO||this.audioOnly&&!this.altAudio){const r=(e===Oe.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(r,e,Jt.MAIN)}}onLevelsUpdated(t,e){this.levels=e.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){const{media:t}=this;if(!t)return;const e=t.currentTime;let r=this.startPosition;if(r>=0&&e<r){if(t.seeking){this.log(`could not seek to ${r}, already seeking at ${e}`);return}const n=Ve.getBuffered(t),o=(n.length?n.start(0):0)-r;o>0&&(o<this.config.maxBufferHole||o<this.config.maxFragLookUpTolerance)&&(this.log(`adjusting start position by ${o} to match buffer start`),r+=o,this.startPosition=r),this.log(`seek to target start position ${r} from current time ${e}`),t.currentTime=r}}_getAudioCodec(t){let e=this.config.defaultAudioCodec||t.audioCodec;return this.audioCodecSwap&&e&&(this.log("Swapping audio codec"),e.indexOf("mp4a.40.5")!==-1?e="mp4a.40.2":e="mp4a.40.5"),e}_loadBitrateTestFrag(t,e){t.bitrateTest=!0,this._doFragLoad(t,e).then(r=>{const{hls:n}=this;if(!r||this.fragContextChanged(t))return;e.fragmentError=0,this.state=Rt.IDLE,this.startFragRequested=!1,this.bitrateTest=!1;const o=t.stats;o.parsing.start=o.parsing.end=o.buffering.start=o.buffering.end=self.performance.now(),n.trigger(R.FRAG_LOADED,r),t.bitrateTest=!1})}_handleTransmuxComplete(t){var e;const r="main",{hls:n}=this,{remuxResult:o,chunkMeta:l}=t,d=this.getCurrentContext(l);if(!d){this.resetWhenMissingContext(l);return}const{frag:f,part:p,level:g}=d,{video:v,text:E,id3:A,initSegment:T}=o,{details:w}=g,C=this.altAudio?void 0:o.audio;if(this.fragContextChanged(f)){this.fragmentTracker.removeFragment(f);return}if(this.state=Rt.PARSING,T){if(T!=null&&T.tracks){const U=f.initSegment||f;this._bufferInitSegment(g,T.tracks,U,l),n.trigger(R.FRAG_PARSING_INIT_SEGMENT,{frag:U,id:r,tracks:T.tracks})}const D=T.initPTS,M=T.timescale;jt(D)&&(this.initPTS[f.cc]={baseTime:D,timescale:M},n.trigger(R.INIT_PTS_FOUND,{frag:f,id:r,initPTS:D,timescale:M}))}if(v&&w&&f.sn!=="initSegment"){const D=w.fragments[f.sn-1-w.startSN],M=f.sn===w.startSN,U=!D||f.cc>D.cc;if(o.independent!==!1){const{startPTS:x,endPTS:O,startDTS:K,endDTS:B}=v;if(p)p.elementaryStreams[v.type]={startPTS:x,endPTS:O,startDTS:K,endDTS:B};else if(v.firstKeyFrame&&v.independent&&l.id===1&&!U&&(this.couldBacktrack=!0),v.dropped&&v.independent){const at=this.getMainFwdBufferInfo(),st=(at?at.end:this.getLoadPosition())+this.config.maxBufferHole,J=v.firstKeyFramePTS?v.firstKeyFramePTS:x;if(!M&&st<J-this.config.maxBufferHole&&!U){this.backtrack(f);return}else U&&(f.gap=!0);f.setElementaryStreamInfo(v.type,f.start,O,f.start,B,!0)}f.setElementaryStreamInfo(v.type,x,O,K,B),this.backtrackFragment&&(this.backtrackFragment=f),this.bufferFragmentData(v,f,p,l,M||U)}else if(M||U)f.gap=!0;else{this.backtrack(f);return}}if(C){const{startPTS:D,endPTS:M,startDTS:U,endDTS:x}=C;p&&(p.elementaryStreams[Oe.AUDIO]={startPTS:D,endPTS:M,startDTS:U,endDTS:x}),f.setElementaryStreamInfo(Oe.AUDIO,D,M,U,x),this.bufferFragmentData(C,f,p,l)}if(w&&A!=null&&(e=A.samples)!=null&&e.length){const D={id:r,frag:f,details:w,samples:A.samples};n.trigger(R.FRAG_PARSING_METADATA,D)}if(w&&E){const D={id:r,frag:f,details:w,samples:E.samples};n.trigger(R.FRAG_PARSING_USERDATA,D)}}_bufferInitSegment(t,e,r,n){if(this.state!==Rt.PARSING)return;this.audioOnly=!!e.audio&&!e.video,this.altAudio&&!this.audioOnly&&delete e.audio;const{audio:o,video:l,audiovideo:d}=e;if(o){let f=t.audioCodec;const p=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(f&&(f.indexOf("mp4a.40.5")!==-1?f="mp4a.40.2":f="mp4a.40.5"),o.metadata.channelCount!==1&&p.indexOf("firefox")===-1&&(f="mp4a.40.5")),p.indexOf("android")!==-1&&o.container!=="audio/mpeg"&&(f="mp4a.40.2",this.log(`Android: force audio codec to ${f}`)),t.audioCodec&&t.audioCodec!==f&&this.log(`Swapping manifest audio codec "${t.audioCodec}" for "${f}"`),o.levelCodec=f,o.id="main",this.log(`Init audio buffer, container:${o.container}, codecs[selected/level/parsed]=[${f||""}/${t.audioCodec||""}/${o.codec}]`)}l&&(l.levelCodec=t.videoCodec,l.id="main",this.log(`Init video buffer, container:${l.container}, codecs[level/parsed]=[${t.videoCodec||""}/${l.codec}]`)),d&&this.log(`Init audiovideo buffer, container:${d.container}, codecs[level/parsed]=[${t.attrs.CODECS||""}/${d.codec}]`),this.hls.trigger(R.BUFFER_CODECS,e),Object.keys(e).forEach(f=>{const p=e[f].initSegment;p!=null&&p.byteLength&&this.hls.trigger(R.BUFFER_APPENDING,{type:f,data:p,frag:r,part:null,chunkMeta:n,parent:r.type})}),this.tick()}getMainFwdBufferInfo(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,Jt.MAIN)}backtrack(t){this.couldBacktrack=!0,this.backtrackFragment=t,this.resetTransmuxer(),this.flushBufferGap(t),this.fragmentTracker.removeFragment(t),this.fragPrevious=null,this.nextLoadPosition=t.start,this.state=Rt.IDLE}checkFragmentChanged(){const t=this.media;let e=null;if(t&&t.readyState>1&&t.seeking===!1){const r=t.currentTime;if(Ve.isBuffered(t,r)?e=this.getAppendedFrag(r):Ve.isBuffered(t,r+.1)&&(e=this.getAppendedFrag(r+.1)),e){this.backtrackFragment=null;const n=this.fragPlaying,o=e.level;(!n||e.sn!==n.sn||n.level!==o||e.urlId!==n.urlId)&&(this.fragPlaying=e,this.hls.trigger(R.FRAG_CHANGED,{frag:e}),(!n||n.level!==o)&&this.hls.trigger(R.LEVEL_SWITCHED,{level:o}))}}}get nextLevel(){const t=this.nextBufferedFrag;return t?t.level:-1}get currentFrag(){const t=this.media;return t?this.fragPlaying||this.getAppendedFrag(t.currentTime):null}get currentProgramDateTime(){const t=this.media;if(t){const e=t.currentTime,r=this.currentFrag;if(r&&jt(e)&&jt(r.programDateTime)){const n=r.programDateTime+(e-r.start)*1e3;return new Date(n)}}return null}get currentLevel(){const t=this.currentFrag;return t?t.level:-1}get nextBufferedFrag(){const t=this.currentFrag;return t?this.followingBufferedFrag(t):null}get forceStartLoad(){return this._forceStartLoad}}class On{constructor(t,e=0,r=0){this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=t,this.alpha_=t?Math.exp(Math.log(.5)/t):0,this.estimate_=e,this.totalWeight_=r}sample(t,e){const r=Math.pow(this.alpha_,t);this.estimate_=e*(1-r)+r*this.estimate_,this.totalWeight_+=t}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){const t=1-Math.pow(this.alpha_,this.totalWeight_);if(t)return this.estimate_/t}return this.estimate_}}class gE{constructor(t,e,r,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_=r,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new On(t),this.fast_=new On(e),this.defaultTTFB_=n,this.ttfb_=new On(t)}update(t,e){const{slow_:r,fast_:n,ttfb_:o}=this;r.halfLife!==t&&(this.slow_=new On(t,r.getEstimate(),r.getTotalWeight())),n.halfLife!==e&&(this.fast_=new On(e,n.getEstimate(),n.getTotalWeight())),o.halfLife!==t&&(this.ttfb_=new On(t,o.getEstimate(),o.getTotalWeight()))}sample(t,e){t=Math.max(t,this.minDelayMs_);const r=8*e,n=t/1e3,o=r/n;this.fast_.sample(n,o),this.slow_.sample(n,o)}sampleTTFB(t){const e=t/1e3,r=Math.sqrt(2)*Math.exp(-Math.pow(e,2)/2);this.ttfb_.sample(r,Math.max(t,5))}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}destroy(){}}class mE{constructor(t){this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=-1,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=t;const e=t.config;this.bwEstimator=new gE(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate),this.registerListeners()}registerListeners(){const{hls:t}=this;t.on(R.FRAG_LOADING,this.onFragLoading,this),t.on(R.FRAG_LOADED,this.onFragLoaded,this),t.on(R.FRAG_BUFFERED,this.onFragBuffered,this),t.on(R.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(R.LEVEL_LOADED,this.onLevelLoaded,this)}unregisterListeners(){const{hls:t}=this;t.off(R.FRAG_LOADING,this.onFragLoading,this),t.off(R.FRAG_LOADED,this.onFragLoaded,this),t.off(R.FRAG_BUFFERED,this.onFragBuffered,this),t.off(R.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(R.LEVEL_LOADED,this.onLevelLoaded,this)}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null}onFragLoading(t,e){var r;const n=e.frag;this.ignoreFragment(n)||(this.fragCurrent=n,this.partCurrent=(r=e.part)!=null?r:null,this.clearTimer(),this.timer=self.setInterval(this.onCheck,100))}onLevelSwitching(t,e){this.clearTimer()}getTimeToLoadFrag(t,e,r,n){const o=t+r/e,l=n?this.lastLevelLoadSec:0;return o+l}onLevelLoaded(t,e){const r=this.hls.config,{total:n,bwEstimate:o}=e.stats;jt(n)&&jt(o)&&(this.lastLevelLoadSec=8*n/o),e.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)}_abandonRulesCheck(){const{fragCurrent:t,partCurrent:e,hls:r}=this,{autoLevelEnabled:n,media:o}=r;if(!t||!o)return;const l=performance.now(),d=e?e.stats:t.stats,f=e?e.duration:t.duration,p=l-d.loading.start;if(d.aborted||d.loaded&&d.loaded===d.total||t.level===0){this.clearTimer(),this._nextAutoLevel=-1;return}if(!n||o.paused||!o.playbackRate||!o.readyState)return;const g=r.mainForwardBufferInfo;if(g===null)return;const v=this.bwEstimator.getEstimateTTFB(),E=Math.abs(o.playbackRate);if(p<=Math.max(v,1e3*(f/(E*2))))return;const A=g.len/E;if(A>=2*f/E)return;const T=d.loading.first?d.loading.first-d.loading.start:-1,w=d.loaded&&T>-1,C=this.bwEstimator.getEstimate(),{levels:D,minAutoLevel:M}=r,U=D[t.level],x=d.total||Math.max(d.loaded,Math.round(f*U.maxBitrate/8));let O=p-T;O<1&&w&&(O=Math.min(p,d.loaded*8/C));const K=w?d.loaded*1e3/O:0,B=K?(x-d.loaded)/K:x*8/C+v/1e3;if(B<=A)return;const at=K?K*8:C;let st=Number.POSITIVE_INFINITY,J;for(J=t.level-1;J>M;J--){const kt=D[J].maxBitrate;if(st=this.getTimeToLoadFrag(v/1e3,at,f*kt,!D[J].details),st<A)break}st>=B||st>f*10||(r.nextLoadLevel=J,w?this.bwEstimator.sample(p-Math.min(v,T),d.loaded):this.bwEstimator.sampleTTFB(p),this.clearTimer(),X.warn(`[abr] Fragment ${t.sn}${e?" part "+e.index:""} of level ${t.level} is loading too slowly;
190
190
  Time to underbuffer: ${A.toFixed(3)} s
191
191
  Estimated load time for current fragment: ${B.toFixed(3)} s
192
192
  Estimated load time for down switch fragment: ${st.toFixed(3)} s
193
193
  TTFB estimate: ${T}
194
194
  Current BW estimate: ${jt(C)?(C/1024).toFixed(3):"Unknown"} Kb/s
195
195
  New BW estimate: ${(this.bwEstimator.getEstimate()/1024).toFixed(3)} Kb/s
196
- Aborting and switching to level ${J}`),t.loader&&(this.fragCurrent=this.partCurrent=null,t.abortRequests()),r.trigger(R.FRAG_LOAD_EMERGENCY_ABORTED,{frag:t,part:e,stats:d}))}onFragLoaded(t,{frag:e,part:r}){const n=r?r.stats:e.stats;if(e.type===Jt.MAIN&&this.bwEstimator.sampleTTFB(n.loading.first-n.loading.start),!this.ignoreFragment(e)){if(this.clearTimer(),this.lastLoadedFragLevel=e.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){const o=r?r.duration:e.duration,l=this.hls.levels[e.level],d=(l.loaded?l.loaded.bytes:0)+n.loaded,f=(l.loaded?l.loaded.duration:0)+o;l.loaded={bytes:d,duration:f},l.realBitrate=Math.round(8*d/f)}if(e.bitrateTest){const o={stats:n,frag:e,part:r,id:e.type};this.onFragBuffered(R.FRAG_BUFFERED,o),e.bitrateTest=!1}}}onFragBuffered(t,e){const{frag:r,part:n}=e,o=n!=null&&n.stats.loaded?n.stats:r.stats;if(o.aborted||this.ignoreFragment(r))return;const l=o.parsing.end-o.loading.start-Math.min(o.loading.first-o.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(l,o.loaded),o.bwEstimate=this.bwEstimator.getEstimate(),r.bitrateTest?this.bitrateTestDelay=l/1e3:this.bitrateTestDelay=0}ignoreFragment(t){return t.type!==Jt.MAIN||t.sn==="initSegment"}clearTimer(){self.clearInterval(this.timer)}get nextAutoLevel(){const t=this._nextAutoLevel,e=this.bwEstimator;if(t!==-1&&!e.canEstimate())return t;let r=this.getNextABRAutoLevel();if(t!==-1){const n=this.hls.levels;if(n.length>Math.max(t,r)&&n[t].loadError<=n[r].loadError)return t}return t!==-1&&(r=Math.min(t,r)),r}getNextABRAutoLevel(){const{fragCurrent:t,partCurrent:e,hls:r}=this,{maxAutoLevel:n,config:o,minAutoLevel:l,media:d}=r,f=e?e.duration:t?t.duration:0,p=d&&d.playbackRate!==0?Math.abs(d.playbackRate):1,g=this.bwEstimator?this.bwEstimator.getEstimate():o.abrEwmaDefaultEstimate,v=r.mainForwardBufferInfo,E=(v?v.len:0)/p;let A=this.findBestLevel(g,l,n,E,o.abrBandWidthFactor,o.abrBandWidthUpFactor);if(A>=0)return A;X.trace(`[abr] ${E?"rebuffering expected":"buffer is empty"}, finding optimal quality level`);let T=f?Math.min(f,o.maxStarvationDelay):o.maxStarvationDelay,w=o.abrBandWidthFactor,C=o.abrBandWidthUpFactor;if(!E){const D=this.bitrateTestDelay;D&&(T=(f?Math.min(f,o.maxLoadingDelay):o.maxLoadingDelay)-D,X.trace(`[abr] bitrate test took ${Math.round(1e3*D)}ms, set first fragment max fetchDuration to ${Math.round(1e3*T)} ms`),w=C=1)}return A=this.findBestLevel(g,l,n,E+T,w,C),Math.max(A,0)}findBestLevel(t,e,r,n,o,l){var d;const{fragCurrent:f,partCurrent:p,lastLoadedFragLevel:g}=this,{levels:v}=this.hls,E=v[g],A=!!(E!=null&&(d=E.details)!=null&&d.live),T=E==null?void 0:E.codecSet,w=p?p.duration:f?f.duration:0,C=this.bwEstimator.getEstimateTTFB()/1e3;let D=e,M=-1;for(let U=r;U>=e;U--){const x=v[U];if(!x||T&&x.codecSet!==T){x&&(D=Math.min(U,D),M=Math.max(U,M));continue}M!==-1&&X.trace(`[abr] Skipped level(s) ${D}-${M} with CODECS:"${v[M].attrs.CODECS}"; not compatible with "${E.attrs.CODECS}"`);const O=x.details,K=(p?O==null?void 0:O.partTarget:O==null?void 0:O.averagetargetduration)||w;let B;U<=g?B=o*t:B=l*t;const at=v[U].maxBitrate,st=this.getTimeToLoadFrag(C,B,at*K,O===void 0);if(X.trace(`[abr] level:${U} adjustedbw-bitrate:${Math.round(B-at)} avgDuration:${K.toFixed(1)} maxFetchDuration:${n.toFixed(1)} fetchDuration:${st.toFixed(1)}`),B>at&&(st===0||!jt(st)||A&&!this.bitrateTestDelay||st<n))return U}return-1}set nextAutoLevel(t){this._nextAutoLevel=t}}class dp{constructor(){this.chunks=[],this.dataLength=0}push(t){this.chunks.push(t),this.dataLength+=t.length}flush(){const{chunks:t,dataLength:e}=this;let r;if(t.length)t.length===1?r=t[0]:r=yE(t,e);else return new Uint8Array(0);return this.reset(),r}reset(){this.chunks.length=0,this.dataLength=0}}function yE(i,t){const e=new Uint8Array(t);let r=0;for(let n=0;n<i.length;n++){const o=i[n];e.set(o,r),r+=o.length}return e}const up=100;class bE extends nh{constructor(t,e,r){super(t,e,r,"[audio-stream-controller]",Jt.AUDIO),this.videoBuffer=null,this.videoTrackCC=-1,this.waitingVideoCC=-1,this.bufferedTrack=null,this.switchingTrack=null,this.trackId=-1,this.waitingData=null,this.mainDetails=null,this.bufferFlushed=!1,this.cachedTrackLoadedData=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),this.mainDetails=null,this.bufferedTrack=null,this.switchingTrack=null}_registerListeners(){const{hls:t}=this;t.on(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.LEVEL_LOADED,this.onLevelLoaded,this),t.on(R.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.on(R.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(R.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(R.ERROR,this.onError,this),t.on(R.BUFFER_RESET,this.onBufferReset,this),t.on(R.BUFFER_CREATED,this.onBufferCreated,this),t.on(R.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(R.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(R.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:t}=this;t.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.LEVEL_LOADED,this.onLevelLoaded,this),t.off(R.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.off(R.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(R.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(R.ERROR,this.onError,this),t.off(R.BUFFER_RESET,this.onBufferReset,this),t.off(R.BUFFER_CREATED,this.onBufferCreated,this),t.off(R.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(R.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(R.FRAG_BUFFERED,this.onFragBuffered,this)}onInitPtsFound(t,{frag:e,id:r,initPTS:n,timescale:o}){if(r==="main"){const l=e.cc;this.initPTS[e.cc]={baseTime:n,timescale:o},this.log(`InitPTS for cc: ${l} found from main: ${n}`),this.videoTrackCC=l,this.state===Rt.WAITING_INIT_PTS&&this.tick()}}startLoad(t){if(!this.levels){this.startPosition=t,this.state=Rt.STOPPED;return}const e=this.lastCurrentTime;this.stopLoad(),this.setInterval(up),e>0&&t===-1?(this.log(`Override startPosition with lastCurrentTime @${e.toFixed(3)}`),t=e,this.state=Rt.IDLE):(this.loadedmetadata=!1,this.state=Rt.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}doTick(){switch(this.state){case Rt.IDLE:this.doTickIdle();break;case Rt.WAITING_TRACK:{var t;const{levels:r,trackId:n}=this,o=r==null||(t=r[n])==null?void 0:t.details;if(o){if(this.waitForCdnTuneIn(o))break;this.state=Rt.WAITING_INIT_PTS}break}case Rt.FRAG_LOADING_WAITING_RETRY:{var e;const r=performance.now(),n=this.retryDate;(!n||r>=n||(e=this.media)!=null&&e.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=Rt.IDLE);break}case Rt.WAITING_INIT_PTS:{const r=this.waitingData;if(r){const{frag:n,part:o,cache:l,complete:d}=r;if(this.initPTS[n.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=Rt.FRAG_LOADING;const f=l.flush(),p={frag:n,part:o,payload:f,networkDetails:null};this._handleFragmentLoadProgress(p),d&&super._handleFragmentLoadComplete(p)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log(`Waiting fragment cc (${n.cc}) cancelled because video is at cc ${this.videoTrackCC}`),this.clearWaitingFragment();else{const f=this.getLoadPosition(),p=Ve.bufferInfo(this.mediaBuffer,f,this.config.maxBufferHole);Jc(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=Rt.IDLE}}this.onTickEnd()}clearWaitingFragment(){const t=this.waitingData;t&&(this.fragmentTracker.removeFragment(t.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=Rt.IDLE)}resetLoadingState(){this.clearWaitingFragment(),super.resetLoadingState()}onTickEnd(){const{media:t}=this;t!=null&&t.readyState&&(this.lastCurrentTime=t.currentTime)}doTickIdle(){const{hls:t,levels:e,media:r,trackId:n}=this,o=t.config;if(!(e!=null&&e[n])||!r&&(this.startFragRequested||!o.startFragPrefetch))return;const l=e[n],d=l.details;if(!d||d.live&&this.levelLastLoaded!==n||this.waitForCdnTuneIn(d)){this.state=Rt.WAITING_TRACK;return}const f=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&f&&(this.bufferFlushed=!1,this.afterBufferFlushed(f,Oe.AUDIO,Jt.AUDIO));const p=this.getFwdBufferInfo(f,Jt.AUDIO);if(p===null)return;const{bufferedTrack:g,switchingTrack:v}=this;if(!v&&this._streamEnded(p,d)){t.trigger(R.BUFFER_EOS,{type:"audio"}),this.state=Rt.ENDED;return}const E=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,Jt.MAIN),A=p.len,T=this.getMaxBufferLength(E==null?void 0:E.len);if(A>=T&&!v)return;const w=d.fragments[0].start;let C=p.end;if(v&&r){const x=this.getLoadPosition();g&&v.attrs!==g.attrs&&(C=x),d.PTSKnown&&x<w&&(p.end>w||p.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),r.currentTime=w+.05)}let D=this.getNextFragment(C,d),M=!1;if(D&&this.isLoopLoading(D,C)&&(M=!!D.gap,D=this.getNextFragmentLoopLoading(D,d,p,Jt.MAIN,T)),!D){this.bufferFlushed=!0;return}const U=E&&D.start>E.end+d.targetduration;if(U||!(E!=null&&E.len)&&p.len){const x=this.getAppendedFrag(D.start,Jt.MAIN);if(x===null||(M||(M=!!x.gap||!!U&&E.len===0),U&&!M||M&&p.nextStart&&p.nextStart<x.end))return}this.loadFragment(D,l,C)}getMaxBufferLength(t){const e=super.getMaxBufferLength();return t?Math.min(Math.max(e,t),this.config.maxMaxBufferLength):e}onMediaDetaching(){this.videoBuffer=null,super.onMediaDetaching()}onAudioTracksUpdated(t,{audioTracks:e}){this.resetTransmuxer(),this.levels=e.map(r=>new Ma(r))}onAudioTrackSwitching(t,e){const r=!!e.url;this.trackId=e.id;const{fragCurrent:n}=this;n&&(n.abortRequests(),this.removeUnbufferedFrags(n.start)),this.resetLoadingState(),r?this.setInterval(up):this.resetTransmuxer(),r?(this.switchingTrack=e,this.state=Rt.IDLE):(this.switchingTrack=null,this.bufferedTrack=e,this.state=Rt.STOPPED),this.tick()}onManifestLoading(){this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1,this.levels=this.mainDetails=this.waitingData=this.bufferedTrack=this.cachedTrackLoadedData=this.switchingTrack=null,this.startFragRequested=!1,this.trackId=this.videoTrackCC=this.waitingVideoCC=-1}onLevelLoaded(t,e){this.mainDetails=e.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(R.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)}onAudioTrackLoaded(t,e){var r;if(this.mainDetails==null){this.cachedTrackLoadedData=e;return}const{levels:n}=this,{details:o,id:l}=e;if(!n){this.warn(`Audio tracks were reset while loading level ${l}`);return}this.log(`Track ${l} loaded [${o.startSN},${o.endSN}]${o.lastPartSn?`[part-${o.lastPartSn}-${o.lastPartIndex}]`:""},duration:${o.totalduration}`);const d=n[l];let f=0;if(o.live||(r=d.details)!=null&&r.live){this.checkLiveUpdate(o);const p=this.mainDetails;if(o.deltaUpdateFailed||!p)return;!d.details&&o.hasProgramDateTime&&p.hasProgramDateTime?(Vf(o,p),f=o.fragments[0].start):f=this.alignPlaylists(o,d.details)}d.details=o,this.levelLastLoaded=l,!this.startFragRequested&&(this.mainDetails||!o.live)&&this.setStartPosition(d.details,f),this.state===Rt.WAITING_TRACK&&!this.waitForCdnTuneIn(o)&&(this.state=Rt.IDLE),this.tick()}_handleFragmentLoadProgress(t){var e;const{frag:r,part:n,payload:o}=t,{config:l,trackId:d,levels:f}=this;if(!f){this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${r.sn} of level ${r.level} will not be buffered`);return}const p=f[d];if(!p){this.warn("Audio track is undefined on fragment load progress");return}const g=p.details;if(!g){this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(r.start);return}const v=l.defaultAudioCodec||p.audioCodec||"mp4a.40.2";let E=this.transmuxer;E||(E=this.transmuxer=new hp(this.hls,Jt.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));const A=this.initPTS[r.cc],T=(e=r.initSegment)==null?void 0:e.data;if(A!==void 0){const w=n?n.index:-1,C=w!==-1,D=new rh(r.level,r.sn,r.stats.chunkCount,o.byteLength,w,C);E.push(o,T,v,"",r,n,g.totalduration,!1,D,A)}else{this.log(`Unknown video PTS for cc ${r.cc}, waiting for video PTS before demuxing audio frag ${r.sn} of [${g.startSN} ,${g.endSN}],track ${d}`);const{cache:w}=this.waitingData=this.waitingData||{frag:r,part:n,cache:new dp,complete:!1};w.push(new Uint8Array(o)),this.waitingVideoCC=this.videoTrackCC,this.state=Rt.WAITING_INIT_PTS}}_handleFragmentLoadComplete(t){if(this.waitingData){this.waitingData.complete=!0;return}super._handleFragmentLoadComplete(t)}onBufferReset(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1}onBufferCreated(t,e){const r=e.tracks.audio;r&&(this.mediaBuffer=r.buffer||null),e.tracks.video&&(this.videoBuffer=e.tracks.video.buffer||null)}onFragBuffered(t,e){const{frag:r,part:n}=e;if(r.type!==Jt.AUDIO){if(!this.loadedmetadata&&r.type===Jt.MAIN){const o=this.videoBuffer||this.media;o&&Ve.getBuffered(o).length&&(this.loadedmetadata=!0)}return}if(this.fragContextChanged(r)){this.warn(`Fragment ${r.sn}${n?" p: "+n.index:""} of level ${r.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);return}if(r.sn!=="initSegment"){this.fragPrevious=r;const o=this.switchingTrack;o&&(this.bufferedTrack=o,this.switchingTrack=null,this.hls.trigger(R.AUDIO_TRACK_SWITCHED,zr({},o)))}this.fragBufferedComplete(r,n)}onError(t,e){var r;if(e.fatal){this.state=Rt.ERROR;return}switch(e.details){case ut.FRAG_GAP:case ut.FRAG_PARSING_ERROR:case ut.FRAG_DECRYPT_ERROR:case ut.FRAG_LOAD_ERROR:case ut.FRAG_LOAD_TIMEOUT:case ut.KEY_LOAD_ERROR:case ut.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Jt.AUDIO,e);break;case ut.AUDIO_TRACK_LOAD_ERROR:case ut.AUDIO_TRACK_LOAD_TIMEOUT:case ut.LEVEL_PARSING_ERROR:!e.levelRetry&&this.state===Rt.WAITING_TRACK&&((r=e.context)==null?void 0:r.type)===Se.AUDIO_TRACK&&(this.state=Rt.IDLE);break;case ut.BUFFER_FULL_ERROR:if(!e.parent||e.parent!=="audio")return;this.reduceLengthAndFlushBuffer(e)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case ut.INTERNAL_EXCEPTION:this.recoverWorkerError(e);break}}onBufferFlushed(t,{type:e}){e===Oe.AUDIO&&(this.bufferFlushed=!0,this.state===Rt.ENDED&&(this.state=Rt.IDLE))}_handleTransmuxComplete(t){var e;const r="audio",{hls:n}=this,{remuxResult:o,chunkMeta:l}=t,d=this.getCurrentContext(l);if(!d){this.resetWhenMissingContext(l);return}const{frag:f,part:p,level:g}=d,{details:v}=g,{audio:E,text:A,id3:T,initSegment:w}=o;if(this.fragContextChanged(f)||!v){this.fragmentTracker.removeFragment(f);return}if(this.state=Rt.PARSING,this.switchingTrack&&E&&this.completeAudioSwitch(this.switchingTrack),w!=null&&w.tracks){const C=f.initSegment||f;this._bufferInitSegment(w.tracks,C,l),n.trigger(R.FRAG_PARSING_INIT_SEGMENT,{frag:C,id:r,tracks:w.tracks})}if(E){const{startPTS:C,endPTS:D,startDTS:M,endDTS:U}=E;p&&(p.elementaryStreams[Oe.AUDIO]={startPTS:C,endPTS:D,startDTS:M,endDTS:U}),f.setElementaryStreamInfo(Oe.AUDIO,C,D,M,U),this.bufferFragmentData(E,f,p,l)}if(T!=null&&(e=T.samples)!=null&&e.length){const C=dr({id:r,frag:f,details:v},T);n.trigger(R.FRAG_PARSING_METADATA,C)}if(A){const C=dr({id:r,frag:f,details:v},A);n.trigger(R.FRAG_PARSING_USERDATA,C)}}_bufferInitSegment(t,e,r){if(this.state!==Rt.PARSING)return;t.video&&delete t.video;const n=t.audio;if(!n)return;n.levelCodec=n.codec,n.id="audio",this.log(`Init audio buffer, container:${n.container}, codecs[parsed]=[${n.codec}]`),this.hls.trigger(R.BUFFER_CODECS,t);const o=n.initSegment;if(o!=null&&o.byteLength){const l={type:"audio",frag:e,part:null,chunkMeta:r,parent:e.type,data:o};this.hls.trigger(R.BUFFER_APPENDING,l)}this.tick()}loadFragment(t,e,r){const n=this.fragmentTracker.getState(t);if(this.fragCurrent=t,this.switchingTrack||n===vr.NOT_LOADED||n===vr.PARTIAL){var o;t.sn==="initSegment"?this._loadInitSegment(t,e):(o=e.details)!=null&&o.live&&!this.initPTS[t.cc]?(this.log(`Waiting for video PTS in continuity counter ${t.cc} of live stream before loading audio fragment ${t.sn} of level ${this.trackId}`),this.state=Rt.WAITING_INIT_PTS):(this.startFragRequested=!0,super.loadFragment(t,e,r))}else this.clearTrackerIfNeeded(t)}completeAudioSwitch(t){const{hls:e,media:r,bufferedTrack:n}=this,o=n==null?void 0:n.attrs,l=t.attrs;r&&o&&(o.CHANNELS!==l.CHANNELS||o.NAME!==l.NAME||o.LANGUAGE!==l.LANGUAGE)&&(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio")),this.bufferedTrack=t,this.switchingTrack=null,e.trigger(R.AUDIO_TRACK_SWITCHED,zr({},t))}}class EE extends th{constructor(t){super(t,"[audio-track-controller]"),this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){const{hls:t}=this;t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.MANIFEST_PARSED,this.onManifestParsed,this),t.on(R.LEVEL_LOADING,this.onLevelLoading,this),t.on(R.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(R.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(R.ERROR,this.onError,this)}unregisterListeners(){const{hls:t}=this;t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.MANIFEST_PARSED,this.onManifestParsed,this),t.off(R.LEVEL_LOADING,this.onLevelLoading,this),t.off(R.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(R.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(R.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(t,e){this.tracks=e.audioTracks||[]}onAudioTrackLoaded(t,e){const{id:r,groupId:n,details:o}=e,l=this.tracksInGroup[r];if(!l||l.groupId!==n){this.warn(`Track with id:${r} and group:${n} not found in active group ${l.groupId}`);return}const d=l.details;l.details=e.details,this.log(`audio-track ${r} "${l.name}" lang:${l.lang} group:${n} loaded [${o.startSN}-${o.endSN}]`),r===this.trackId&&this.playlistLoaded(r,e,d)}onLevelLoading(t,e){this.switchLevel(e.level)}onLevelSwitching(t,e){this.switchLevel(e.level)}switchLevel(t){const e=this.hls.levels[t];if(!(e!=null&&e.audioGroupIds))return;const r=e.audioGroupIds[e.urlId];if(this.groupId!==r){this.groupId=r||null;const n=this.tracks.filter(l=>!r||l.groupId===r);this.selectDefaultTrack&&!n.some(l=>l.default)&&(this.selectDefaultTrack=!1),this.tracksInGroup=n;const o={audioTracks:n};this.log(`Updating audio tracks, ${n.length} track(s) found in group:${r}`),this.hls.trigger(R.AUDIO_TRACKS_UPDATED,o),this.selectInitialTrack()}else this.shouldReloadPlaylist(this.currentTrack)&&this.setAudioTrack(this.trackId)}onError(t,e){e.fatal||!e.context||e.context.type===Se.AUDIO_TRACK&&e.context.id===this.trackId&&e.context.groupId===this.groupId&&(this.requestScheduled=-1,this.checkRetry(e))}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(t){this.selectDefaultTrack=!1,this.setAudioTrack(t)}setAudioTrack(t){const e=this.tracksInGroup;if(t<0||t>=e.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();const r=this.currentTrack;e[this.trackId];const n=e[t],{groupId:o,name:l}=n;if(this.log(`Switching to audio-track ${t} "${l}" lang:${n.lang} group:${o}`),this.trackId=t,this.currentTrack=n,this.selectDefaultTrack=!1,this.hls.trigger(R.AUDIO_TRACK_SWITCHING,zr({},n)),n.details&&!n.details.live)return;const d=this.switchParams(n.url,r==null?void 0:r.details);this.loadPlaylist(d)}selectInitialTrack(){const t=this.tracksInGroup,e=this.findTrackId(this.currentTrack)|this.findTrackId(null);if(e!==-1)this.setAudioTrack(e);else{const r=new Error(`No track found for running audio group-ID: ${this.groupId} track count: ${t.length}`);this.warn(r.message),this.hls.trigger(R.ERROR,{type:Qt.MEDIA_ERROR,details:ut.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:r})}}findTrackId(t){const e=this.tracksInGroup;for(let r=0;r<e.length;r++){const n=e[r];if((!this.selectDefaultTrack||n.default)&&(!t||t.attrs["STABLE-RENDITION-ID"]!==void 0&&t.attrs["STABLE-RENDITION-ID"]===n.attrs["STABLE-RENDITION-ID"]||t.name===n.name&&t.lang===n.lang))return n.id}return-1}loadPlaylist(t){super.loadPlaylist();const e=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(e)){const r=e.id,n=e.groupId;let o=e.url;if(t)try{o=t.addDirectives(o)}catch(l){this.warn(`Could not construct new URL with HLS Delivery Directives: ${l}`)}this.log(`loading audio-track playlist ${r} "${e.name}" lang:${e.lang} group:${n}`),this.clearTimer(),this.hls.trigger(R.AUDIO_TRACK_LOADING,{url:o,id:r,groupId:n,deliveryDirectives:t||null})}}}function fp(i,t){if(i.length!==t.length)return!1;for(let e=0;e<i.length;e++)if(!AE(i[e].attrs,t[e].attrs))return!1;return!0}function AE(i,t){const e=i["STABLE-RENDITION-ID"];return e?e===t["STABLE-RENDITION-ID"]:!["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED"].some(r=>i[r]!==t[r])}const pp=500;class TE extends nh{constructor(t,e,r){super(t,e,r,"[subtitle-stream-controller]",Jt.SUBTITLE),this.levels=[],this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),this.mainDetails=null}_registerListeners(){const{hls:t}=this;t.on(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.LEVEL_LOADED,this.onLevelLoaded,this),t.on(R.ERROR,this.onError,this),t.on(R.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(R.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.on(R.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(R.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.on(R.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(R.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:t}=this;t.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.LEVEL_LOADED,this.onLevelLoaded,this),t.off(R.ERROR,this.onError,this),t.off(R.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(R.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.off(R.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(R.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.off(R.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(R.FRAG_BUFFERED,this.onFragBuffered,this)}startLoad(t){this.stopLoad(),this.state=Rt.IDLE,this.setInterval(pp),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}onManifestLoading(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()}onMediaDetaching(){this.tracksBuffered=[],super.onMediaDetaching()}onLevelLoaded(t,e){this.mainDetails=e.details}onSubtitleFragProcessed(t,e){const{frag:r,success:n}=e;if(this.fragPrevious=r,this.state=Rt.IDLE,!n)return;const o=this.tracksBuffered[this.currentTrackId];if(!o)return;let l;const d=r.start;for(let p=0;p<o.length;p++)if(d>=o[p].start&&d<=o[p].end){l=o[p];break}const f=r.start+r.duration;l?l.end=f:(l={start:d,end:f},o.push(l)),this.fragmentTracker.fragBuffered(r)}onBufferFlushing(t,e){const{startOffset:r,endOffset:n}=e;if(r===0&&n!==Number.POSITIVE_INFINITY){const o=n-1;if(o<=0)return;e.endOffsetSubtitles=Math.max(0,o),this.tracksBuffered.forEach(l=>{for(let d=0;d<l.length;){if(l[d].end<=o){l.shift();continue}else if(l[d].start<o)l[d].start=o;else break;d++}}),this.fragmentTracker.removeFragmentsInRange(r,o,Jt.SUBTITLE)}}onFragBuffered(t,e){if(!this.loadedmetadata&&e.frag.type===Jt.MAIN){var r;(r=this.media)!=null&&r.buffered.length&&(this.loadedmetadata=!0)}}onError(t,e){const r=e.frag;(r==null?void 0:r.type)===Jt.SUBTITLE&&(this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==Rt.STOPPED&&(this.state=Rt.IDLE))}onSubtitleTracksUpdated(t,{subtitleTracks:e}){if(fp(this.levels,e)){this.levels=e.map(r=>new Ma(r));return}this.tracksBuffered=[],this.levels=e.map(r=>{const n=new Ma(r);return this.tracksBuffered[n.id]=[],n}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,Jt.SUBTITLE),this.fragPrevious=null,this.mediaBuffer=null}onSubtitleTrackSwitch(t,e){if(this.currentTrackId=e.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}const r=this.levels[this.currentTrackId];r!=null&&r.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,r&&this.setInterval(pp)}onSubtitleTrackLoaded(t,e){var r;const{details:n,id:o}=e,{currentTrackId:l,levels:d}=this;if(!d.length)return;const f=d[l];if(o>=d.length||o!==l||!f)return;this.mediaBuffer=this.mediaBufferTimeRanges;let p=0;if(n.live||(r=f.details)!=null&&r.live){const g=this.mainDetails;if(n.deltaUpdateFailed||!g)return;const v=g.fragments[0];f.details?(p=this.alignPlaylists(n,f.details),p===0&&v&&(p=v.start,qc(n,p))):n.hasProgramDateTime&&g.hasProgramDateTime?(Vf(n,g),p=n.fragments[0].start):v&&(p=v.start,qc(n,p))}f.details=n,this.levelLastLoaded=o,!this.startFragRequested&&(this.mainDetails||!n.live)&&this.setStartPosition(f.details,p),this.tick(),n.live&&!this.fragCurrent&&this.media&&this.state===Rt.IDLE&&(Na(null,n.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),f.details=void 0))}_handleFragmentLoadComplete(t){const{frag:e,payload:r}=t,n=e.decryptdata,o=this.hls;if(!this.fragContextChanged(e)&&r&&r.byteLength>0&&n&&n.key&&n.iv&&n.method==="AES-128"){const l=performance.now();this.decrypter.decrypt(new Uint8Array(r),n.key.buffer,n.iv.buffer).catch(d=>{throw o.trigger(R.ERROR,{type:Qt.MEDIA_ERROR,details:ut.FRAG_DECRYPT_ERROR,fatal:!1,error:d,reason:d.message,frag:e}),d}).then(d=>{const f=performance.now();o.trigger(R.FRAG_DECRYPTED,{frag:e,payload:d,stats:{tstart:l,tdecrypt:f}})}).catch(d=>{this.warn(`${d.name}: ${d.message}`),this.state=Rt.IDLE})}}doTick(){if(!this.media){this.state=Rt.IDLE;return}if(this.state===Rt.IDLE){const{currentTrackId:t,levels:e}=this,r=e[t];if(!e.length||!r||!r.details)return;const{config:n}=this,o=this.getLoadPosition(),l=Ve.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],o,n.maxBufferHole),{end:d,len:f}=l,p=this.getFwdBufferInfo(this.media,Jt.MAIN),g=r.details,v=this.getMaxBufferLength(p==null?void 0:p.len)+g.levelTargetDuration;if(f>v)return;const E=g.fragments,A=E.length,T=g.edge;let w=null;const C=this.fragPrevious;if(d<T){const D=n.maxFragLookUpTolerance,M=d>T-D?0:D;w=Na(C,E,Math.max(E[0].start,d),M),!w&&C&&C.start<E[0].start&&(w=E[0])}else w=E[A-1];if(!w)return;if(w=this.mapToInitFragWhenRequired(w),w.sn!=="initSegment"){const D=w.sn-g.startSN,M=E[D-1];M&&M.cc===w.cc&&this.fragmentTracker.getState(M)===vr.NOT_LOADED&&(w=M)}this.fragmentTracker.getState(w)===vr.NOT_LOADED&&this.loadFragment(w,r,d)}}getMaxBufferLength(t){const e=super.getMaxBufferLength();return t?Math.max(e,t):e}loadFragment(t,e,r){this.fragCurrent=t,t.sn==="initSegment"?this._loadInitSegment(t,e):(this.startFragRequested=!0,super.loadFragment(t,e,r))}get mediaBufferTimeRanges(){return new kE(this.tracksBuffered[this.currentTrackId]||[])}}class kE{constructor(t){this.buffered=void 0;const e=(r,n,o)=>{if(n=n>>>0,n>o-1)throw new DOMException(`Failed to execute '${r}' on 'TimeRanges': The index provided (${n}) is greater than the maximum bound (${o})`);return t[n][r]};this.buffered={get length(){return t.length},end(r){return e("end",r,t.length)},start(r){return e("start",r,t.length)}}}}class wE extends th{constructor(t){super(t,"[subtitle-track-controller]"),this.media=null,this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0,this.queuedDefaultTrack=-1,this.trackChangeListener=()=>this.onTextTracksChanged(),this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.registerListeners()}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,super.destroy()}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(t){this._subtitleDisplay=t,this.trackId>-1&&this.toggleTrackModes(this.trackId)}registerListeners(){const{hls:t}=this;t.on(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.MANIFEST_PARSED,this.onManifestParsed,this),t.on(R.LEVEL_LOADING,this.onLevelLoading,this),t.on(R.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(R.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(R.ERROR,this.onError,this)}unregisterListeners(){const{hls:t}=this;t.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.MANIFEST_PARSED,this.onManifestParsed,this),t.off(R.LEVEL_LOADING,this.onLevelLoading,this),t.off(R.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(R.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(R.ERROR,this.onError,this)}onMediaAttached(t,e){this.media=e.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))}pollTrackChange(t){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,t)}onMediaDetaching(){this.media&&(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),vh(this.media.textTracks).forEach(t=>{xn(t)}),this.subtitleTrack=-1,this.media=null)}onManifestLoading(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(t,e){this.tracks=e.subtitleTracks}onSubtitleTrackLoaded(t,e){const{id:r,details:n}=e,{trackId:o}=this,l=this.tracksInGroup[o];if(!l){this.warn(`Invalid subtitle track id ${r}`);return}const d=l.details;l.details=e.details,this.log(`subtitle track ${r} loaded [${n.startSN}-${n.endSN}]`),r===this.trackId&&this.playlistLoaded(r,e,d)}onLevelLoading(t,e){this.switchLevel(e.level)}onLevelSwitching(t,e){this.switchLevel(e.level)}switchLevel(t){const e=this.hls.levels[t];if(!(e!=null&&e.textGroupIds))return;const r=e.textGroupIds[e.urlId],n=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;if(this.groupId!==r){const o=this.tracks.filter(f=>!r||f.groupId===r);this.tracksInGroup=o;const l=this.findTrackId(n==null?void 0:n.name)||this.findTrackId();this.groupId=r||null;const d={subtitleTracks:o};this.log(`Updating subtitle tracks, ${o.length} track(s) found in "${r}" group-id`),this.hls.trigger(R.SUBTITLE_TRACKS_UPDATED,d),l!==-1&&this.setSubtitleTrack(l,n)}else this.shouldReloadPlaylist(n)&&this.setSubtitleTrack(this.trackId,n)}findTrackId(t){const e=this.tracksInGroup;for(let r=0;r<e.length;r++){const n=e[r];if((!this.selectDefaultTrack||n.default)&&(!t||t===n.name))return n.id}return-1}onError(t,e){e.fatal||!e.context||e.context.type===Se.SUBTITLE_TRACK&&e.context.id===this.trackId&&e.context.groupId===this.groupId&&this.checkRetry(e)}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(t){this.selectDefaultTrack=!1;const e=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(t,e)}loadPlaylist(t){super.loadPlaylist();const e=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(e)){const r=e.id,n=e.groupId;let o=e.url;if(t)try{o=t.addDirectives(o)}catch(l){this.warn(`Could not construct new URL with HLS Delivery Directives: ${l}`)}this.log(`Loading subtitle playlist for id ${r}`),this.hls.trigger(R.SUBTITLE_TRACK_LOADING,{url:o,id:r,groupId:n,deliveryDirectives:t||null})}}toggleTrackModes(t){const{media:e,trackId:r}=this;if(!e)return;const n=vh(e.textTracks),o=n.filter(d=>d.groupId===this.groupId);if(t===-1)[].slice.call(n).forEach(d=>{d.mode="disabled"});else{const d=o[r];d&&(d.mode="disabled")}const l=o[t];l&&(l.mode=this.subtitleDisplay?"showing":"hidden")}setSubtitleTrack(t,e){var r;const n=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=t;return}if(this.trackId!==t&&this.toggleTrackModes(t),this.trackId===t&&(t===-1||(r=n[t])!=null&&r.details)||t<-1||t>=n.length)return;this.clearTimer();const o=n[t];if(this.log(`Switching to subtitle-track ${t}`+(o?` "${o.name}" lang:${o.lang} group:${o.groupId}`:"")),this.trackId=t,o){const{id:l,groupId:d="",name:f,type:p,url:g}=o;this.hls.trigger(R.SUBTITLE_TRACK_SWITCH,{id:l,groupId:d,name:f,type:p,url:g});const v=this.switchParams(o.url,e==null?void 0:e.details);this.loadPlaylist(v)}else this.hls.trigger(R.SUBTITLE_TRACK_SWITCH,{id:t})}onTextTracksChanged(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let t=-1;const e=vh(this.media.textTracks);for(let r=0;r<e.length;r++)if(e[r].mode==="hidden")t=r;else if(e[r].mode==="showing"){t=r;break}this.subtitleTrack!==t&&(this.subtitleTrack=t)}}function vh(i){const t=[];for(let e=0;e<i.length;e++){const r=i[e];(r.kind==="subtitles"||r.kind==="captions")&&r.label&&t.push(i[e])}return t}class SE{constructor(t){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=t}append(t,e){const r=this.queues[e];r.push(t),r.length===1&&this.buffers[e]&&this.executeNext(e)}insertAbort(t,e){this.queues[e].unshift(t),this.executeNext(e)}appendBlocker(t){let e;const r=new Promise(o=>{e=o}),n={execute:e,onStart:()=>{},onComplete:()=>{},onError:()=>{}};return this.append(n,t),r}executeNext(t){const{buffers:e,queues:r}=this,n=e[t],o=r[t];if(o.length){const l=o[0];try{l.execute()}catch(d){X.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),l.onError(d),n!=null&&n.updating||(o.shift(),this.executeNext(t))}}}shiftAndExecuteNext(t){this.queues[t].shift(),this.executeNext(t)}current(t){return this.queues[t][0]}}const gp=zo(),mp=/([ha]vc.)(?:\.[^.,]+)+/;class RE{constructor(t){this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=()=>{const{media:e,mediaSource:r}=this;X.log("[buffer-controller]: Media source opened"),e&&(e.removeEventListener("emptied",this._onMediaEmptied),this.updateMediaElementDuration(),this.hls.trigger(R.MEDIA_ATTACHED,{media:e})),r&&r.removeEventListener("sourceopen",this._onMediaSourceOpen),this.checkPendingTracks()},this._onMediaSourceClose=()=>{X.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=()=>{X.log("[buffer-controller]: Media source ended")},this._onMediaEmptied=()=>{const{media:e,_objectUrl:r}=this;e&&e.src!==r&&X.error(`Media element src was set while attaching MediaSource (${r} > ${e.src})`)},this.hls=t,this._initSourceBuffer(),this.registerListeners()}hasSourceTypes(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null}registerListeners(){const{hls:t}=this;t.on(R.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.MANIFEST_PARSED,this.onManifestParsed,this),t.on(R.BUFFER_RESET,this.onBufferReset,this),t.on(R.BUFFER_APPENDING,this.onBufferAppending,this),t.on(R.BUFFER_CODECS,this.onBufferCodecs,this),t.on(R.BUFFER_EOS,this.onBufferEos,this),t.on(R.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(R.LEVEL_UPDATED,this.onLevelUpdated,this),t.on(R.FRAG_PARSED,this.onFragParsed,this),t.on(R.FRAG_CHANGED,this.onFragChanged,this)}unregisterListeners(){const{hls:t}=this;t.off(R.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.MANIFEST_PARSED,this.onManifestParsed,this),t.off(R.BUFFER_RESET,this.onBufferReset,this),t.off(R.BUFFER_APPENDING,this.onBufferAppending,this),t.off(R.BUFFER_CODECS,this.onBufferCodecs,this),t.off(R.BUFFER_EOS,this.onBufferEos,this),t.off(R.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(R.LEVEL_UPDATED,this.onLevelUpdated,this),t.off(R.FRAG_PARSED,this.onFragParsed,this),t.off(R.FRAG_CHANGED,this.onFragChanged,this)}_initSourceBuffer(){this.sourceBuffer={},this.operationQueue=new SE(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.lastMpegAudioChunk=null}onManifestLoading(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null}onManifestParsed(t,e){let r=2;(e.audio&&!e.video||!e.altAudio)&&(r=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r,X.log(`${this.bufferCodecEventsExpected} bufferCodec event(s) expected`)}onMediaAttaching(t,e){const r=this.media=e.media;if(r&&gp){const n=this.mediaSource=new gp;n.addEventListener("sourceopen",this._onMediaSourceOpen),n.addEventListener("sourceended",this._onMediaSourceEnded),n.addEventListener("sourceclose",this._onMediaSourceClose),r.src=self.URL.createObjectURL(n),this._objectUrl=r.src,r.addEventListener("emptied",this._onMediaEmptied)}}onMediaDetaching(){const{media:t,mediaSource:e,_objectUrl:r}=this;if(e){if(X.log("[buffer-controller]: media source detaching"),e.readyState==="open")try{e.endOfStream()}catch(n){X.warn(`[buffer-controller]: onMediaDetaching: ${n.message} while calling endOfStream`)}this.onBufferReset(),e.removeEventListener("sourceopen",this._onMediaSourceOpen),e.removeEventListener("sourceended",this._onMediaSourceEnded),e.removeEventListener("sourceclose",this._onMediaSourceClose),t&&(t.removeEventListener("emptied",this._onMediaEmptied),r&&self.URL.revokeObjectURL(r),t.src===r?(t.removeAttribute("src"),t.load()):X.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(R.MEDIA_DETACHED,void 0)}onBufferReset(){this.getSourceBufferTypes().forEach(t=>{const e=this.sourceBuffer[t];try{e&&(this.removeBufferListeners(t),this.mediaSource&&this.mediaSource.removeSourceBuffer(e),this.sourceBuffer[t]=void 0)}catch(r){X.warn(`[buffer-controller]: Failed to reset the ${t} buffer`,r)}}),this._initSourceBuffer()}onBufferCodecs(t,e){const r=this.getSourceBufferTypes().length;Object.keys(e).forEach(n=>{if(r){const o=this.tracks[n];if(o&&typeof o.buffer.changeType=="function"){const{id:l,codec:d,levelCodec:f,container:p,metadata:g}=e[n],v=(o.levelCodec||o.codec).replace(mp,"$1"),E=(f||d).replace(mp,"$1");if(v!==E){const A=`${p};codecs=${f||d}`;this.appendChangeType(n,A),X.log(`[buffer-controller]: switching codec ${v} to ${E}`),this.tracks[n]={buffer:o.buffer,codec:d,container:p,levelCodec:f,metadata:g,id:l}}}}else this.pendingTracks[n]=e[n]}),!r&&(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())}appendChangeType(t,e){const{operationQueue:r}=this,n={execute:()=>{const o=this.sourceBuffer[t];o&&(X.log(`[buffer-controller]: changing ${t} sourceBuffer type to ${e}`),o.changeType(e)),r.shiftAndExecuteNext(t)},onStart:()=>{},onComplete:()=>{},onError:o=>{X.warn(`[buffer-controller]: Failed to change ${t} SourceBuffer type`,o)}};r.append(n,t)}onBufferAppending(t,e){const{hls:r,operationQueue:n,tracks:o}=this,{data:l,type:d,frag:f,part:p,chunkMeta:g}=e,v=g.buffering[d],E=self.performance.now();v.start=E;const A=f.stats.buffering,T=p?p.stats.buffering:null;A.start===0&&(A.start=E),T&&T.start===0&&(T.start=E);const w=o.audio;let C=!1;d==="audio"&&(w==null?void 0:w.container)==="audio/mpeg"&&(C=!this.lastMpegAudioChunk||g.id===1||this.lastMpegAudioChunk.sn!==g.sn,this.lastMpegAudioChunk=g);const D=f.start,M={execute:()=>{if(v.executeStart=self.performance.now(),C){const U=this.sourceBuffer[d];if(U){const x=D-U.timestampOffset;Math.abs(x)>=.1&&(X.log(`[buffer-controller]: Updating audio SourceBuffer timestampOffset to ${D} (delta: ${x}) sn: ${f.sn})`),U.timestampOffset=D)}}this.appendExecutor(l,d)},onStart:()=>{},onComplete:()=>{const U=self.performance.now();v.executeEnd=v.end=U,A.first===0&&(A.first=U),T&&T.first===0&&(T.first=U);const{sourceBuffer:x}=this,O={};for(const K in x)O[K]=Ve.getBuffered(x[K]);this.appendError=0,this.hls.trigger(R.BUFFER_APPENDED,{type:d,frag:f,part:p,chunkMeta:g,parent:f.type,timeRanges:O})},onError:U=>{X.error(`[buffer-controller]: Error encountered while trying to append to the ${d} SourceBuffer`,U);const x={type:Qt.MEDIA_ERROR,parent:f.type,details:ut.BUFFER_APPEND_ERROR,frag:f,part:p,chunkMeta:g,error:U,err:U,fatal:!1};U.code===DOMException.QUOTA_EXCEEDED_ERR?x.details=ut.BUFFER_FULL_ERROR:(this.appendError++,x.details=ut.BUFFER_APPEND_ERROR,this.appendError>r.config.appendErrorMaxRetry&&(X.error(`[buffer-controller]: Failed ${r.config.appendErrorMaxRetry} times to append segment in sourceBuffer`),x.fatal=!0)),r.trigger(R.ERROR,x)}};n.append(M,d)}onBufferFlushing(t,e){const{operationQueue:r}=this,n=o=>({execute:this.removeExecutor.bind(this,o,e.startOffset,e.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger(R.BUFFER_FLUSHED,{type:o})},onError:l=>{X.warn(`[buffer-controller]: Failed to remove from ${o} SourceBuffer`,l)}});e.type?r.append(n(e.type),e.type):this.getSourceBufferTypes().forEach(o=>{r.append(n(o),o)})}onFragParsed(t,e){const{frag:r,part:n}=e,o=[],l=n?n.elementaryStreams:r.elementaryStreams;l[Oe.AUDIOVIDEO]?o.push("audiovideo"):(l[Oe.AUDIO]&&o.push("audio"),l[Oe.VIDEO]&&o.push("video"));const d=()=>{const f=self.performance.now();r.stats.buffering.end=f,n&&(n.stats.buffering.end=f);const p=n?n.stats:r.stats;this.hls.trigger(R.FRAG_BUFFERED,{frag:r,part:n,stats:p,id:r.type})};o.length===0&&X.warn(`Fragments must have at least one ElementaryStreamType set. type: ${r.type} level: ${r.level} sn: ${r.sn}`),this.blockBuffers(d,o)}onFragChanged(t,e){this.flushBackBuffer()}onBufferEos(t,e){this.getSourceBufferTypes().reduce((r,n)=>{const o=this.sourceBuffer[n];return o&&(!e.type||e.type===n)&&(o.ending=!0,o.ended||(o.ended=!0,X.log(`[buffer-controller]: ${n} sourceBuffer now EOS`))),r&&!!(!o||o.ended)},!0)&&(X.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers(()=>{this.getSourceBufferTypes().forEach(n=>{const o=this.sourceBuffer[n];o&&(o.ending=!1)});const{mediaSource:r}=this;if(!r||r.readyState!=="open"){r&&X.info(`[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: ${r.readyState}`);return}X.log("[buffer-controller]: Calling mediaSource.endOfStream()"),r.endOfStream()}))}onLevelUpdated(t,{details:e}){e.fragments.length&&(this.details=e,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())}flushBackBuffer(){const{hls:t,details:e,media:r,sourceBuffer:n}=this;if(!r||e===null)return;const o=this.getSourceBufferTypes();if(!o.length)return;const l=e.live&&t.config.liveBackBufferLength!==null?t.config.liveBackBufferLength:t.config.backBufferLength;if(!jt(l)||l<0)return;const d=r.currentTime,f=e.levelTargetDuration,p=Math.max(l,f),g=Math.floor(d/f)*f-p;o.forEach(v=>{const E=n[v];if(E){const A=Ve.getBuffered(E);if(A.length>0&&g>A.start(0)){if(t.trigger(R.BACK_BUFFER_REACHED,{bufferEnd:g}),e.live)t.trigger(R.LIVE_BACK_BUFFER_REACHED,{bufferEnd:g});else if(E.ended&&A.end(A.length-1)-d<f*2){X.info(`[buffer-controller]: Cannot flush ${v} back buffer while SourceBuffer is in ended state`);return}t.trigger(R.BUFFER_FLUSHING,{startOffset:0,endOffset:g,type:v})}}})}updateMediaElementDuration(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;const{details:t,hls:e,media:r,mediaSource:n}=this,o=t.fragments[0].start+t.totalduration,l=r.duration,d=jt(n.duration)?n.duration:0;t.live&&e.config.liveDurationInfinity?(X.log("[buffer-controller]: Media Source duration is set to Infinity"),n.duration=1/0,this.updateSeekableRange(t)):(o>d&&o>l||!jt(l))&&(X.log(`[buffer-controller]: Updating Media Source duration to ${o.toFixed(3)}`),n.duration=o)}updateSeekableRange(t){const e=this.mediaSource,r=t.fragments;if(r.length&&t.live&&e!=null&&e.setLiveSeekableRange){const n=Math.max(0,r[0].start),o=Math.max(n,n+t.totalduration);e.setLiveSeekableRange(n,o)}}checkPendingTracks(){const{bufferCodecEventsExpected:t,operationQueue:e,pendingTracks:r}=this,n=Object.keys(r).length;if(n&&!t||n===2){this.createSourceBuffers(r),this.pendingTracks={};const o=this.getSourceBufferTypes();if(o.length)this.hls.trigger(R.BUFFER_CREATED,{tracks:this.tracks}),o.forEach(l=>{e.executeNext(l)});else{const l=new Error("could not create source buffer for media codec(s)");this.hls.trigger(R.ERROR,{type:Qt.MEDIA_ERROR,details:ut.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:l,reason:l.message})}}}createSourceBuffers(t){const{sourceBuffer:e,mediaSource:r}=this;if(!r)throw Error("createSourceBuffers called when mediaSource was null");for(const n in t)if(!e[n]){const o=t[n];if(!o)throw Error(`source buffer exists for track ${n}, however track does not`);const l=o.levelCodec||o.codec,d=`${o.container};codecs=${l}`;X.log(`[buffer-controller]: creating sourceBuffer(${d})`);try{const f=e[n]=r.addSourceBuffer(d),p=n;this.addBufferListener(p,"updatestart",this._onSBUpdateStart),this.addBufferListener(p,"updateend",this._onSBUpdateEnd),this.addBufferListener(p,"error",this._onSBUpdateError),this.tracks[n]={buffer:f,codec:l,container:o.container,levelCodec:o.levelCodec,metadata:o.metadata,id:o.id}}catch(f){X.error(`[buffer-controller]: error while trying to add sourceBuffer: ${f.message}`),this.hls.trigger(R.ERROR,{type:Qt.MEDIA_ERROR,details:ut.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:f,mimeType:d})}}}_onSBUpdateStart(t){const{operationQueue:e}=this;e.current(t).onStart()}_onSBUpdateEnd(t){const{operationQueue:e}=this;e.current(t).onComplete(),e.shiftAndExecuteNext(t)}_onSBUpdateError(t,e){const r=new Error(`${t} SourceBuffer error`);X.error(`[buffer-controller]: ${r}`,e),this.hls.trigger(R.ERROR,{type:Qt.MEDIA_ERROR,details:ut.BUFFER_APPENDING_ERROR,error:r,fatal:!1});const n=this.operationQueue.current(t);n&&n.onError(e)}removeExecutor(t,e,r){const{media:n,mediaSource:o,operationQueue:l,sourceBuffer:d}=this,f=d[t];if(!n||!o||!f){X.warn(`[buffer-controller]: Attempting to remove from the ${t} SourceBuffer, but it does not exist`),l.shiftAndExecuteNext(t);return}const p=jt(n.duration)?n.duration:1/0,g=jt(o.duration)?o.duration:1/0,v=Math.max(0,e),E=Math.min(r,p,g);E>v&&!f.ending?(f.ended=!1,X.log(`[buffer-controller]: Removing [${v},${E}] from the ${t} SourceBuffer`),f.remove(v,E)):l.shiftAndExecuteNext(t)}appendExecutor(t,e){const{operationQueue:r,sourceBuffer:n}=this,o=n[e];if(!o){X.warn(`[buffer-controller]: Attempting to append to the ${e} SourceBuffer, but it does not exist`),r.shiftAndExecuteNext(e);return}o.ended=!1,o.appendBuffer(t)}blockBuffers(t,e=this.getSourceBufferTypes()){if(!e.length){X.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(t);return}const{operationQueue:r}=this,n=e.map(o=>r.appendBlocker(o));Promise.all(n).then(()=>{t(),e.forEach(o=>{const l=this.sourceBuffer[o];l!=null&&l.updating||r.shiftAndExecuteNext(o)})})}getSourceBufferTypes(){return Object.keys(this.sourceBuffer)}addBufferListener(t,e,r){const n=this.sourceBuffer[t];if(!n)return;const o=r.bind(this,t);this.listeners[t].push({event:e,listener:o}),n.addEventListener(e,o)}removeBufferListeners(t){const e=this.sourceBuffer[t];e&&this.listeners[t].forEach(r=>{e.removeEventListener(r.event,r.listener)})}}const vp={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},yp=function(i){let t=i;return vp.hasOwnProperty(i)&&(t=vp[i]),String.fromCharCode(t)},Ri=15,as=100,_E={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},LE={17:2,18:4,21:6,22:8,23:10,19:13,20:15},CE={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},IE={25:2,26:4,29:6,30:8,31:10,27:13,28:15},xE=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class DE{constructor(){this.time=null,this.verboseLevel=0}log(t,e){if(this.verboseLevel>=t){const r=typeof e=="function"?e():e;X.log(`${this.time} [${t}] ${r}`)}}}const pn=function(i){const t=[];for(let e=0;e<i.length;e++)t.push(i[e].toString(16));return t};class bp{constructor(t,e,r,n,o){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=t||"white",this.underline=e||!1,this.italics=r||!1,this.background=n||"black",this.flash=o||!1}reset(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}setStyles(t){const e=["foreground","underline","italics","background","flash"];for(let r=0;r<e.length;r++){const n=e[r];t.hasOwnProperty(n)&&(this[n]=t[n])}}isDefault(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash}equals(t){return this.foreground===t.foreground&&this.underline===t.underline&&this.italics===t.italics&&this.background===t.background&&this.flash===t.flash}copy(t){this.foreground=t.foreground,this.underline=t.underline,this.italics=t.italics,this.background=t.background,this.flash=t.flash}toString(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}}class PE{constructor(t,e,r,n,o,l){this.uchar=void 0,this.penState=void 0,this.uchar=t||" ",this.penState=new bp(e,r,n,o,l)}reset(){this.uchar=" ",this.penState.reset()}setChar(t,e){this.uchar=t,this.penState.copy(e)}setPenState(t){this.penState.copy(t)}equals(t){return this.uchar===t.uchar&&this.penState.equals(t.penState)}copy(t){this.uchar=t.uchar,this.penState.copy(t.penState)}isEmpty(){return this.uchar===" "&&this.penState.isDefault()}}class OE{constructor(t){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(let e=0;e<as;e++)this.chars.push(new PE);this.logger=t,this.pos=0,this.currPenState=new bp}equals(t){let e=!0;for(let r=0;r<as;r++)if(!this.chars[r].equals(t.chars[r])){e=!1;break}return e}copy(t){for(let e=0;e<as;e++)this.chars[e].copy(t.chars[e])}isEmpty(){let t=!0;for(let e=0;e<as;e++)if(!this.chars[e].isEmpty()){t=!1;break}return t}setCursor(t){this.pos!==t&&(this.pos=t),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>as&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=as)}moveCursor(t){const e=this.pos+t;if(t>1)for(let r=this.pos+1;r<e+1;r++)this.chars[r].setPenState(this.currPenState);this.setCursor(e)}backSpace(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}insertChar(t){t>=144&&this.backSpace();const e=yp(t);if(this.pos>=as){this.logger.log(0,()=>"Cannot insert "+t.toString(16)+" ("+e+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(e,this.currPenState),this.moveCursor(1)}clearFromPos(t){let e;for(e=t;e<as;e++)this.chars[e].reset()}clear(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}clearToEndOfRow(){this.clearFromPos(this.pos)}getTextString(){const t=[];let e=!0;for(let r=0;r<as;r++){const n=this.chars[r].uchar;n!==" "&&(e=!1),t.push(n)}return e?"":t.join("")}setPenStyles(t){this.currPenState.setStyles(t),this.chars[this.pos].setPenState(this.currPenState)}}class yh{constructor(t){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(let e=0;e<Ri;e++)this.rows.push(new OE(t));this.logger=t,this.currRow=Ri-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}reset(){for(let t=0;t<Ri;t++)this.rows[t].clear();this.currRow=Ri-1}equals(t){let e=!0;for(let r=0;r<Ri;r++)if(!this.rows[r].equals(t.rows[r])){e=!1;break}return e}copy(t){for(let e=0;e<Ri;e++)this.rows[e].copy(t.rows[e])}isEmpty(){let t=!0;for(let e=0;e<Ri;e++)if(!this.rows[e].isEmpty()){t=!1;break}return t}backSpace(){this.rows[this.currRow].backSpace()}clearToEndOfRow(){this.rows[this.currRow].clearToEndOfRow()}insertChar(t){this.rows[this.currRow].insertChar(t)}setPen(t){this.rows[this.currRow].setPenStyles(t)}moveCursor(t){this.rows[this.currRow].moveCursor(t)}setCursor(t){this.logger.log(2,"setCursor: "+t),this.rows[this.currRow].setCursor(t)}setPAC(t){this.logger.log(2,()=>"pacData = "+JSON.stringify(t));let e=t.row-1;if(this.nrRollUpRows&&e<this.nrRollUpRows-1&&(e=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==e){for(let d=0;d<Ri;d++)this.rows[d].clear();const o=this.currRow+1-this.nrRollUpRows,l=this.lastOutputScreen;if(l){const d=l.rows[o].cueStartTime,f=this.logger.time;if(d&&f!==null&&d<f)for(let p=0;p<this.nrRollUpRows;p++)this.rows[e-this.nrRollUpRows+p+1].copy(l.rows[o+p])}}this.currRow=e;const r=this.rows[this.currRow];if(t.indent!==null){const o=t.indent,l=Math.max(o-1,0);r.setCursor(t.indent),t.color=r.chars[l].penState.foreground}const n={foreground:t.color,underline:t.underline,italics:t.italics,background:"black",flash:!1};this.setPen(n)}setBkgData(t){this.logger.log(2,()=>"bkgData = "+JSON.stringify(t)),this.backSpace(),this.setPen(t),this.insertChar(32)}setRollUpRows(t){this.nrRollUpRows=t}rollUp(){if(this.nrRollUpRows===null){this.logger.log(3,"roll_up but nrRollUpRows not set yet");return}this.logger.log(1,()=>this.getDisplayText());const t=this.currRow+1-this.nrRollUpRows,e=this.rows.splice(t,1)[0];e.clear(),this.rows.splice(this.currRow,0,e),this.logger.log(2,"Rolling up")}getDisplayText(t){t=t||!1;const e=[];let r="",n=-1;for(let o=0;o<Ri;o++){const l=this.rows[o].getTextString();l&&(n=o+1,t?e.push("Row "+n+": '"+l+"'"):e.push(l.trim()))}return e.length>0&&(t?r="["+e.join(" | ")+"]":r=e.join(`
197
- `)),r}getTextAndFormat(){return this.rows}}class Ep{constructor(t,e,r){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=t,this.outputFilter=e,this.mode=null,this.verbose=0,this.displayedMemory=new yh(r),this.nonDisplayedMemory=new yh(r),this.lastOutputScreen=new yh(r),this.currRollUpRow=this.displayedMemory.rows[Ri-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=r}reset(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[Ri-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}getHandler(){return this.outputFilter}setHandler(t){this.outputFilter=t}setPAC(t){this.writeScreen.setPAC(t)}setBkgData(t){this.writeScreen.setBkgData(t)}setMode(t){t!==this.mode&&(this.mode=t,this.logger.log(2,()=>"MODE="+t),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=t)}insertChars(t){for(let r=0;r<t.length;r++)this.writeScreen.insertChar(t[r]);const e=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,()=>e+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(1,()=>"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())}ccRCL(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}ccBS(){this.logger.log(2,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}ccAOF(){}ccAON(){}ccDER(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}ccRU(t){this.logger.log(2,"RU("+t+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(t)}ccFON(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}ccRDC(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}ccTR(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}ccRTD(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}ccEDM(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}ccCR(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}ccENM(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}ccEOC(){if(this.logger.log(2,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){const t=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=t,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,()=>"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)}ccTO(t){this.logger.log(2,"TO("+t+") - Tab Offset"),this.writeScreen.moveCursor(t)}ccMIDROW(t){const e={flash:!1};if(e.underline=t%2===1,e.italics=t>=46,e.italics)e.foreground="white";else{const r=Math.floor(t/2)-16,n=["white","green","blue","cyan","red","yellow","magenta"];e.foreground=n[r]}this.logger.log(2,"MIDROW: "+JSON.stringify(e)),this.writeScreen.setPen(e)}outputDataUpdate(t=!1){const e=this.logger.time;e!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=e:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,e,this.lastOutputScreen),t&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:e),this.lastOutputScreen.copy(this.displayedMemory))}cueSplitAtTime(t){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,t,this.displayedMemory),this.cueStartTime=t))}}class Ap{constructor(t,e,r){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;const n=new DE;this.channels=[null,new Ep(t,e,n),new Ep(t+1,r,n)],this.cmdHistory=kp(),this.logger=n}getHandler(t){return this.channels[t].getHandler()}setHandler(t,e){this.channels[t].setHandler(e)}addData(t,e){let r,n,o,l=!1;this.logger.time=t;for(let d=0;d<e.length;d+=2)if(n=e[d]&127,o=e[d+1]&127,!(n===0&&o===0)){if(this.logger.log(3,"["+pn([e[d],e[d+1]])+"] -> ("+pn([n,o])+")"),r=this.parseCmd(n,o),r||(r=this.parseMidrow(n,o)),r||(r=this.parsePAC(n,o)),r||(r=this.parseBackgroundAttributes(n,o)),!r&&(l=this.parseChars(n,o),l)){const f=this.currentChannel;f&&f>0?this.channels[f].insertChars(l):this.logger.log(2,"No channel found yet. TEXT-MODE?")}!r&&!l&&this.logger.log(2,"Couldn't parse cleaned data "+pn([n,o])+" orig: "+pn([e[d],e[d+1]]))}}parseCmd(t,e){const{cmdHistory:r}=this,n=(t===20||t===28||t===21||t===29)&&e>=32&&e<=47,o=(t===23||t===31)&&e>=33&&e<=35;if(!(n||o))return!1;if(Tp(t,e,r))return $n(null,null,r),this.logger.log(3,"Repeated command ("+pn([t,e])+") is dropped"),!0;const l=t===20||t===21||t===23?1:2,d=this.channels[l];return t===20||t===21||t===28||t===29?e===32?d.ccRCL():e===33?d.ccBS():e===34?d.ccAOF():e===35?d.ccAON():e===36?d.ccDER():e===37?d.ccRU(2):e===38?d.ccRU(3):e===39?d.ccRU(4):e===40?d.ccFON():e===41?d.ccRDC():e===42?d.ccTR():e===43?d.ccRTD():e===44?d.ccEDM():e===45?d.ccCR():e===46?d.ccENM():e===47&&d.ccEOC():d.ccTO(e-32),$n(t,e,r),this.currentChannel=l,!0}parseMidrow(t,e){let r=0;if((t===17||t===25)&&e>=32&&e<=47){if(t===17?r=1:r=2,r!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;const n=this.channels[r];return n?(n.ccMIDROW(e),this.logger.log(3,"MIDROW ("+pn([t,e])+")"),!0):!1}return!1}parsePAC(t,e){let r;const n=this.cmdHistory,o=(t>=17&&t<=23||t>=25&&t<=31)&&e>=64&&e<=127,l=(t===16||t===24)&&e>=64&&e<=95;if(!(o||l))return!1;if(Tp(t,e,n))return $n(null,null,n),!0;const d=t<=23?1:2;e>=64&&e<=95?r=d===1?_E[t]:CE[t]:r=d===1?LE[t]:IE[t];const f=this.channels[d];return f?(f.setPAC(this.interpretPAC(r,e)),$n(t,e,n),this.currentChannel=d,!0):!1}interpretPAC(t,e){let r;const n={color:null,italics:!1,indent:null,underline:!1,row:t};return e>95?r=e-96:r=e-64,n.underline=(r&1)===1,r<=13?n.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(n.italics=!0,n.color="white"):n.indent=Math.floor((r-16)/2)*4,n}parseChars(t,e){let r,n=null,o=null;if(t>=25?(r=2,o=t-8):(r=1,o=t),o>=17&&o<=19){let l;o===17?l=e+80:o===18?l=e+112:l=e+144,this.logger.log(2,"Special char '"+yp(l)+"' in channel "+r),n=[l]}else t>=32&&t<=127&&(n=e===0?[t]:[t,e]);if(n){const l=pn(n);this.logger.log(3,"Char codes = "+l.join(",")),$n(t,e,this.cmdHistory)}return n}parseBackgroundAttributes(t,e){const r=(t===16||t===24)&&e>=32&&e<=47,n=(t===23||t===31)&&e>=45&&e<=47;if(!(r||n))return!1;let o;const l={};t===16||t===24?(o=Math.floor((e-32)/2),l.background=xE[o],e%2===1&&(l.background=l.background+"_semi")):e===45?l.background="transparent":(l.foreground="black",e===47&&(l.underline=!0));const d=t<=23?1:2;return this.channels[d].setBkgData(l),$n(t,e,this.cmdHistory),!0}reset(){for(let t=0;t<Object.keys(this.channels).length;t++){const e=this.channels[t];e&&e.reset()}this.cmdHistory=kp()}cueSplitAtTime(t){for(let e=0;e<this.channels.length;e++){const r=this.channels[e];r&&r.cueSplitAtTime(t)}}}function $n(i,t,e){e.a=i,e.b=t}function Tp(i,t,e){return e.a===i&&e.b===t}function kp(){return{a:null,b:null}}class nl{constructor(t,e){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=t,this.trackName=e}dispatchCue(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(t,e,r){(this.startTime===null||this.startTime>t)&&(this.startTime=t),this.endTime=e,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}}var bh=function(){if(typeof self<"u"&&self.VTTCue)return self.VTTCue;const i=["","lr","rl"],t=["start","middle","end","left","right"];function e(d,f){if(typeof f!="string"||!Array.isArray(d))return!1;const p=f.toLowerCase();return~d.indexOf(p)?p:!1}function r(d){return e(i,d)}function n(d){return e(t,d)}function o(d,...f){let p=1;for(;p<arguments.length;p++){const g=arguments[p];for(const v in g)d[v]=g[v]}return d}function l(d,f,p){const g=this,v={enumerable:!0};g.hasBeenReset=!1;let E="",A=!1,T=d,w=f,C=p,D=null,M="",U=!0,x="auto",O="start",K=50,B="middle",at=50,st="middle";Object.defineProperty(g,"id",o({},v,{get:function(){return E},set:function(J){E=""+J}})),Object.defineProperty(g,"pauseOnExit",o({},v,{get:function(){return A},set:function(J){A=!!J}})),Object.defineProperty(g,"startTime",o({},v,{get:function(){return T},set:function(J){if(typeof J!="number")throw new TypeError("Start time must be set to a number.");T=J,this.hasBeenReset=!0}})),Object.defineProperty(g,"endTime",o({},v,{get:function(){return w},set:function(J){if(typeof J!="number")throw new TypeError("End time must be set to a number.");w=J,this.hasBeenReset=!0}})),Object.defineProperty(g,"text",o({},v,{get:function(){return C},set:function(J){C=""+J,this.hasBeenReset=!0}})),Object.defineProperty(g,"region",o({},v,{get:function(){return D},set:function(J){D=J,this.hasBeenReset=!0}})),Object.defineProperty(g,"vertical",o({},v,{get:function(){return M},set:function(J){const kt=r(J);if(kt===!1)throw new SyntaxError("An invalid or illegal string was specified.");M=kt,this.hasBeenReset=!0}})),Object.defineProperty(g,"snapToLines",o({},v,{get:function(){return U},set:function(J){U=!!J,this.hasBeenReset=!0}})),Object.defineProperty(g,"line",o({},v,{get:function(){return x},set:function(J){if(typeof J!="number"&&J!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");x=J,this.hasBeenReset=!0}})),Object.defineProperty(g,"lineAlign",o({},v,{get:function(){return O},set:function(J){const kt=n(J);if(!kt)throw new SyntaxError("An invalid or illegal string was specified.");O=kt,this.hasBeenReset=!0}})),Object.defineProperty(g,"position",o({},v,{get:function(){return K},set:function(J){if(J<0||J>100)throw new Error("Position must be between 0 and 100.");K=J,this.hasBeenReset=!0}})),Object.defineProperty(g,"positionAlign",o({},v,{get:function(){return B},set:function(J){const kt=n(J);if(!kt)throw new SyntaxError("An invalid or illegal string was specified.");B=kt,this.hasBeenReset=!0}})),Object.defineProperty(g,"size",o({},v,{get:function(){return at},set:function(J){if(J<0||J>100)throw new Error("Size must be between 0 and 100.");at=J,this.hasBeenReset=!0}})),Object.defineProperty(g,"align",o({},v,{get:function(){return st},set:function(J){const kt=n(J);if(!kt)throw new SyntaxError("An invalid or illegal string was specified.");st=kt,this.hasBeenReset=!0}})),g.displayState=void 0}return l.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},l}();class $E{decode(t,e){if(!t)return"";if(typeof t!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(t))}}function wp(i){function t(r,n,o,l){return(r|0)*3600+(n|0)*60+(o|0)+parseFloat(l||0)}const e=i.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return e?parseFloat(e[2])>59?t(e[2],e[3],0,e[4]):t(e[1],e[2],e[3],e[4]):null}class ME{constructor(){this.values=Object.create(null)}set(t,e){!this.get(t)&&e!==""&&(this.values[t]=e)}get(t,e,r){return r?this.has(t)?this.values[t]:e[r]:this.has(t)?this.values[t]:e}has(t){return t in this.values}alt(t,e,r){for(let n=0;n<r.length;++n)if(e===r[n]){this.set(t,e);break}}integer(t,e){/^-?\d+$/.test(e)&&this.set(t,parseInt(e,10))}percent(t,e){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(e)){const r=parseFloat(e);if(r>=0&&r<=100)return this.set(t,r),!0}return!1}}function Sp(i,t,e,r){const n=r?i.split(r):[i];for(const o in n){if(typeof n[o]!="string")continue;const l=n[o].split(e);if(l.length!==2)continue;const d=l[0],f=l[1];t(d,f)}}const Eh=new bh(0,0,""),al=Eh.align==="middle"?"middle":"center";function NE(i,t,e){const r=i;function n(){const d=wp(i);if(d===null)throw new Error("Malformed timestamp: "+r);return i=i.replace(/^[^\sa-zA-Z-]+/,""),d}function o(d,f){const p=new ME;Sp(d,function(E,A){let T;switch(E){case"region":for(let w=e.length-1;w>=0;w--)if(e[w].id===A){p.set(E,e[w].region);break}break;case"vertical":p.alt(E,A,["rl","lr"]);break;case"line":T=A.split(","),p.integer(E,T[0]),p.percent(E,T[0])&&p.set("snapToLines",!1),p.alt(E,T[0],["auto"]),T.length===2&&p.alt("lineAlign",T[1],["start",al,"end"]);break;case"position":T=A.split(","),p.percent(E,T[0]),T.length===2&&p.alt("positionAlign",T[1],["start",al,"end","line-left","line-right","auto"]);break;case"size":p.percent(E,A);break;case"align":p.alt(E,A,["start",al,"end","left","right"]);break}},/:/,/\s/),f.region=p.get("region",null),f.vertical=p.get("vertical","");let g=p.get("line","auto");g==="auto"&&Eh.line===-1&&(g=-1),f.line=g,f.lineAlign=p.get("lineAlign","start"),f.snapToLines=p.get("snapToLines",!0),f.size=p.get("size",100),f.align=p.get("align",al);let v=p.get("position","auto");v==="auto"&&Eh.position===50&&(v=f.align==="start"||f.align==="left"?0:f.align==="end"||f.align==="right"?100:50),f.position=v}function l(){i=i.replace(/^\s+/,"")}if(l(),t.startTime=n(),l(),i.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+r);i=i.slice(3),l(),t.endTime=n(),l(),o(i,t)}function Rp(i){return i.replace(/<br(?: \/)?>/gi,`
198
- `)}class FE{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new $E,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(t){const e=this;t&&(e.buffer+=e.decoder.decode(t,{stream:!0}));function r(){let o=e.buffer,l=0;for(o=Rp(o);l<o.length&&o[l]!=="\r"&&o[l]!==`
196
+ Aborting and switching to level ${J}`),t.loader&&(this.fragCurrent=this.partCurrent=null,t.abortRequests()),r.trigger(R.FRAG_LOAD_EMERGENCY_ABORTED,{frag:t,part:e,stats:d}))}onFragLoaded(t,{frag:e,part:r}){const n=r?r.stats:e.stats;if(e.type===Jt.MAIN&&this.bwEstimator.sampleTTFB(n.loading.first-n.loading.start),!this.ignoreFragment(e)){if(this.clearTimer(),this.lastLoadedFragLevel=e.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){const o=r?r.duration:e.duration,l=this.hls.levels[e.level],d=(l.loaded?l.loaded.bytes:0)+n.loaded,f=(l.loaded?l.loaded.duration:0)+o;l.loaded={bytes:d,duration:f},l.realBitrate=Math.round(8*d/f)}if(e.bitrateTest){const o={stats:n,frag:e,part:r,id:e.type};this.onFragBuffered(R.FRAG_BUFFERED,o),e.bitrateTest=!1}}}onFragBuffered(t,e){const{frag:r,part:n}=e,o=n!=null&&n.stats.loaded?n.stats:r.stats;if(o.aborted||this.ignoreFragment(r))return;const l=o.parsing.end-o.loading.start-Math.min(o.loading.first-o.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(l,o.loaded),o.bwEstimate=this.bwEstimator.getEstimate(),r.bitrateTest?this.bitrateTestDelay=l/1e3:this.bitrateTestDelay=0}ignoreFragment(t){return t.type!==Jt.MAIN||t.sn==="initSegment"}clearTimer(){self.clearInterval(this.timer)}get nextAutoLevel(){const t=this._nextAutoLevel,e=this.bwEstimator;if(t!==-1&&!e.canEstimate())return t;let r=this.getNextABRAutoLevel();if(t!==-1){const n=this.hls.levels;if(n.length>Math.max(t,r)&&n[t].loadError<=n[r].loadError)return t}return t!==-1&&(r=Math.min(t,r)),r}getNextABRAutoLevel(){const{fragCurrent:t,partCurrent:e,hls:r}=this,{maxAutoLevel:n,config:o,minAutoLevel:l,media:d}=r,f=e?e.duration:t?t.duration:0,p=d&&d.playbackRate!==0?Math.abs(d.playbackRate):1,g=this.bwEstimator?this.bwEstimator.getEstimate():o.abrEwmaDefaultEstimate,v=r.mainForwardBufferInfo,E=(v?v.len:0)/p;let A=this.findBestLevel(g,l,n,E,o.abrBandWidthFactor,o.abrBandWidthUpFactor);if(A>=0)return A;X.trace(`[abr] ${E?"rebuffering expected":"buffer is empty"}, finding optimal quality level`);let T=f?Math.min(f,o.maxStarvationDelay):o.maxStarvationDelay,w=o.abrBandWidthFactor,C=o.abrBandWidthUpFactor;if(!E){const D=this.bitrateTestDelay;D&&(T=(f?Math.min(f,o.maxLoadingDelay):o.maxLoadingDelay)-D,X.trace(`[abr] bitrate test took ${Math.round(1e3*D)}ms, set first fragment max fetchDuration to ${Math.round(1e3*T)} ms`),w=C=1)}return A=this.findBestLevel(g,l,n,E+T,w,C),Math.max(A,0)}findBestLevel(t,e,r,n,o,l){var d;const{fragCurrent:f,partCurrent:p,lastLoadedFragLevel:g}=this,{levels:v}=this.hls,E=v[g],A=!!(E!=null&&(d=E.details)!=null&&d.live),T=E==null?void 0:E.codecSet,w=p?p.duration:f?f.duration:0,C=this.bwEstimator.getEstimateTTFB()/1e3;let D=e,M=-1;for(let U=r;U>=e;U--){const x=v[U];if(!x||T&&x.codecSet!==T){x&&(D=Math.min(U,D),M=Math.max(U,M));continue}M!==-1&&X.trace(`[abr] Skipped level(s) ${D}-${M} with CODECS:"${v[M].attrs.CODECS}"; not compatible with "${E.attrs.CODECS}"`);const O=x.details,K=(p?O==null?void 0:O.partTarget:O==null?void 0:O.averagetargetduration)||w;let B;U<=g?B=o*t:B=l*t;const at=v[U].maxBitrate,st=this.getTimeToLoadFrag(C,B,at*K,O===void 0);if(X.trace(`[abr] level:${U} adjustedbw-bitrate:${Math.round(B-at)} avgDuration:${K.toFixed(1)} maxFetchDuration:${n.toFixed(1)} fetchDuration:${st.toFixed(1)}`),B>at&&(st===0||!jt(st)||A&&!this.bitrateTestDelay||st<n))return U}return-1}set nextAutoLevel(t){this._nextAutoLevel=t}}class dp{constructor(){this.chunks=[],this.dataLength=0}push(t){this.chunks.push(t),this.dataLength+=t.length}flush(){const{chunks:t,dataLength:e}=this;let r;if(t.length)t.length===1?r=t[0]:r=vE(t,e);else return new Uint8Array(0);return this.reset(),r}reset(){this.chunks.length=0,this.dataLength=0}}function vE(i,t){const e=new Uint8Array(t);let r=0;for(let n=0;n<i.length;n++){const o=i[n];e.set(o,r),r+=o.length}return e}const up=100;class yE extends nh{constructor(t,e,r){super(t,e,r,"[audio-stream-controller]",Jt.AUDIO),this.videoBuffer=null,this.videoTrackCC=-1,this.waitingVideoCC=-1,this.bufferedTrack=null,this.switchingTrack=null,this.trackId=-1,this.waitingData=null,this.mainDetails=null,this.bufferFlushed=!1,this.cachedTrackLoadedData=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),this.mainDetails=null,this.bufferedTrack=null,this.switchingTrack=null}_registerListeners(){const{hls:t}=this;t.on(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.LEVEL_LOADED,this.onLevelLoaded,this),t.on(R.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.on(R.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(R.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(R.ERROR,this.onError,this),t.on(R.BUFFER_RESET,this.onBufferReset,this),t.on(R.BUFFER_CREATED,this.onBufferCreated,this),t.on(R.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(R.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(R.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:t}=this;t.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.LEVEL_LOADED,this.onLevelLoaded,this),t.off(R.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.off(R.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(R.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(R.ERROR,this.onError,this),t.off(R.BUFFER_RESET,this.onBufferReset,this),t.off(R.BUFFER_CREATED,this.onBufferCreated,this),t.off(R.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(R.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(R.FRAG_BUFFERED,this.onFragBuffered,this)}onInitPtsFound(t,{frag:e,id:r,initPTS:n,timescale:o}){if(r==="main"){const l=e.cc;this.initPTS[e.cc]={baseTime:n,timescale:o},this.log(`InitPTS for cc: ${l} found from main: ${n}`),this.videoTrackCC=l,this.state===Rt.WAITING_INIT_PTS&&this.tick()}}startLoad(t){if(!this.levels){this.startPosition=t,this.state=Rt.STOPPED;return}const e=this.lastCurrentTime;this.stopLoad(),this.setInterval(up),e>0&&t===-1?(this.log(`Override startPosition with lastCurrentTime @${e.toFixed(3)}`),t=e,this.state=Rt.IDLE):(this.loadedmetadata=!1,this.state=Rt.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}doTick(){switch(this.state){case Rt.IDLE:this.doTickIdle();break;case Rt.WAITING_TRACK:{var t;const{levels:r,trackId:n}=this,o=r==null||(t=r[n])==null?void 0:t.details;if(o){if(this.waitForCdnTuneIn(o))break;this.state=Rt.WAITING_INIT_PTS}break}case Rt.FRAG_LOADING_WAITING_RETRY:{var e;const r=performance.now(),n=this.retryDate;(!n||r>=n||(e=this.media)!=null&&e.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=Rt.IDLE);break}case Rt.WAITING_INIT_PTS:{const r=this.waitingData;if(r){const{frag:n,part:o,cache:l,complete:d}=r;if(this.initPTS[n.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=Rt.FRAG_LOADING;const f=l.flush(),p={frag:n,part:o,payload:f,networkDetails:null};this._handleFragmentLoadProgress(p),d&&super._handleFragmentLoadComplete(p)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log(`Waiting fragment cc (${n.cc}) cancelled because video is at cc ${this.videoTrackCC}`),this.clearWaitingFragment();else{const f=this.getLoadPosition(),p=Ve.bufferInfo(this.mediaBuffer,f,this.config.maxBufferHole);Jc(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=Rt.IDLE}}this.onTickEnd()}clearWaitingFragment(){const t=this.waitingData;t&&(this.fragmentTracker.removeFragment(t.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=Rt.IDLE)}resetLoadingState(){this.clearWaitingFragment(),super.resetLoadingState()}onTickEnd(){const{media:t}=this;t!=null&&t.readyState&&(this.lastCurrentTime=t.currentTime)}doTickIdle(){const{hls:t,levels:e,media:r,trackId:n}=this,o=t.config;if(!(e!=null&&e[n])||!r&&(this.startFragRequested||!o.startFragPrefetch))return;const l=e[n],d=l.details;if(!d||d.live&&this.levelLastLoaded!==n||this.waitForCdnTuneIn(d)){this.state=Rt.WAITING_TRACK;return}const f=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&f&&(this.bufferFlushed=!1,this.afterBufferFlushed(f,Oe.AUDIO,Jt.AUDIO));const p=this.getFwdBufferInfo(f,Jt.AUDIO);if(p===null)return;const{bufferedTrack:g,switchingTrack:v}=this;if(!v&&this._streamEnded(p,d)){t.trigger(R.BUFFER_EOS,{type:"audio"}),this.state=Rt.ENDED;return}const E=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,Jt.MAIN),A=p.len,T=this.getMaxBufferLength(E==null?void 0:E.len);if(A>=T&&!v)return;const w=d.fragments[0].start;let C=p.end;if(v&&r){const x=this.getLoadPosition();g&&v.attrs!==g.attrs&&(C=x),d.PTSKnown&&x<w&&(p.end>w||p.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),r.currentTime=w+.05)}let D=this.getNextFragment(C,d),M=!1;if(D&&this.isLoopLoading(D,C)&&(M=!!D.gap,D=this.getNextFragmentLoopLoading(D,d,p,Jt.MAIN,T)),!D){this.bufferFlushed=!0;return}const U=E&&D.start>E.end+d.targetduration;if(U||!(E!=null&&E.len)&&p.len){const x=this.getAppendedFrag(D.start,Jt.MAIN);if(x===null||(M||(M=!!x.gap||!!U&&E.len===0),U&&!M||M&&p.nextStart&&p.nextStart<x.end))return}this.loadFragment(D,l,C)}getMaxBufferLength(t){const e=super.getMaxBufferLength();return t?Math.min(Math.max(e,t),this.config.maxMaxBufferLength):e}onMediaDetaching(){this.videoBuffer=null,super.onMediaDetaching()}onAudioTracksUpdated(t,{audioTracks:e}){this.resetTransmuxer(),this.levels=e.map(r=>new Ma(r))}onAudioTrackSwitching(t,e){const r=!!e.url;this.trackId=e.id;const{fragCurrent:n}=this;n&&(n.abortRequests(),this.removeUnbufferedFrags(n.start)),this.resetLoadingState(),r?this.setInterval(up):this.resetTransmuxer(),r?(this.switchingTrack=e,this.state=Rt.IDLE):(this.switchingTrack=null,this.bufferedTrack=e,this.state=Rt.STOPPED),this.tick()}onManifestLoading(){this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1,this.levels=this.mainDetails=this.waitingData=this.bufferedTrack=this.cachedTrackLoadedData=this.switchingTrack=null,this.startFragRequested=!1,this.trackId=this.videoTrackCC=this.waitingVideoCC=-1}onLevelLoaded(t,e){this.mainDetails=e.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(R.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)}onAudioTrackLoaded(t,e){var r;if(this.mainDetails==null){this.cachedTrackLoadedData=e;return}const{levels:n}=this,{details:o,id:l}=e;if(!n){this.warn(`Audio tracks were reset while loading level ${l}`);return}this.log(`Track ${l} loaded [${o.startSN},${o.endSN}]${o.lastPartSn?`[part-${o.lastPartSn}-${o.lastPartIndex}]`:""},duration:${o.totalduration}`);const d=n[l];let f=0;if(o.live||(r=d.details)!=null&&r.live){this.checkLiveUpdate(o);const p=this.mainDetails;if(o.deltaUpdateFailed||!p)return;!d.details&&o.hasProgramDateTime&&p.hasProgramDateTime?(Vf(o,p),f=o.fragments[0].start):f=this.alignPlaylists(o,d.details)}d.details=o,this.levelLastLoaded=l,!this.startFragRequested&&(this.mainDetails||!o.live)&&this.setStartPosition(d.details,f),this.state===Rt.WAITING_TRACK&&!this.waitForCdnTuneIn(o)&&(this.state=Rt.IDLE),this.tick()}_handleFragmentLoadProgress(t){var e;const{frag:r,part:n,payload:o}=t,{config:l,trackId:d,levels:f}=this;if(!f){this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${r.sn} of level ${r.level} will not be buffered`);return}const p=f[d];if(!p){this.warn("Audio track is undefined on fragment load progress");return}const g=p.details;if(!g){this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(r.start);return}const v=l.defaultAudioCodec||p.audioCodec||"mp4a.40.2";let E=this.transmuxer;E||(E=this.transmuxer=new hp(this.hls,Jt.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));const A=this.initPTS[r.cc],T=(e=r.initSegment)==null?void 0:e.data;if(A!==void 0){const w=n?n.index:-1,C=w!==-1,D=new rh(r.level,r.sn,r.stats.chunkCount,o.byteLength,w,C);E.push(o,T,v,"",r,n,g.totalduration,!1,D,A)}else{this.log(`Unknown video PTS for cc ${r.cc}, waiting for video PTS before demuxing audio frag ${r.sn} of [${g.startSN} ,${g.endSN}],track ${d}`);const{cache:w}=this.waitingData=this.waitingData||{frag:r,part:n,cache:new dp,complete:!1};w.push(new Uint8Array(o)),this.waitingVideoCC=this.videoTrackCC,this.state=Rt.WAITING_INIT_PTS}}_handleFragmentLoadComplete(t){if(this.waitingData){this.waitingData.complete=!0;return}super._handleFragmentLoadComplete(t)}onBufferReset(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1}onBufferCreated(t,e){const r=e.tracks.audio;r&&(this.mediaBuffer=r.buffer||null),e.tracks.video&&(this.videoBuffer=e.tracks.video.buffer||null)}onFragBuffered(t,e){const{frag:r,part:n}=e;if(r.type!==Jt.AUDIO){if(!this.loadedmetadata&&r.type===Jt.MAIN){const o=this.videoBuffer||this.media;o&&Ve.getBuffered(o).length&&(this.loadedmetadata=!0)}return}if(this.fragContextChanged(r)){this.warn(`Fragment ${r.sn}${n?" p: "+n.index:""} of level ${r.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);return}if(r.sn!=="initSegment"){this.fragPrevious=r;const o=this.switchingTrack;o&&(this.bufferedTrack=o,this.switchingTrack=null,this.hls.trigger(R.AUDIO_TRACK_SWITCHED,zr({},o)))}this.fragBufferedComplete(r,n)}onError(t,e){var r;if(e.fatal){this.state=Rt.ERROR;return}switch(e.details){case ut.FRAG_GAP:case ut.FRAG_PARSING_ERROR:case ut.FRAG_DECRYPT_ERROR:case ut.FRAG_LOAD_ERROR:case ut.FRAG_LOAD_TIMEOUT:case ut.KEY_LOAD_ERROR:case ut.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Jt.AUDIO,e);break;case ut.AUDIO_TRACK_LOAD_ERROR:case ut.AUDIO_TRACK_LOAD_TIMEOUT:case ut.LEVEL_PARSING_ERROR:!e.levelRetry&&this.state===Rt.WAITING_TRACK&&((r=e.context)==null?void 0:r.type)===Se.AUDIO_TRACK&&(this.state=Rt.IDLE);break;case ut.BUFFER_FULL_ERROR:if(!e.parent||e.parent!=="audio")return;this.reduceLengthAndFlushBuffer(e)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case ut.INTERNAL_EXCEPTION:this.recoverWorkerError(e);break}}onBufferFlushed(t,{type:e}){e===Oe.AUDIO&&(this.bufferFlushed=!0,this.state===Rt.ENDED&&(this.state=Rt.IDLE))}_handleTransmuxComplete(t){var e;const r="audio",{hls:n}=this,{remuxResult:o,chunkMeta:l}=t,d=this.getCurrentContext(l);if(!d){this.resetWhenMissingContext(l);return}const{frag:f,part:p,level:g}=d,{details:v}=g,{audio:E,text:A,id3:T,initSegment:w}=o;if(this.fragContextChanged(f)||!v){this.fragmentTracker.removeFragment(f);return}if(this.state=Rt.PARSING,this.switchingTrack&&E&&this.completeAudioSwitch(this.switchingTrack),w!=null&&w.tracks){const C=f.initSegment||f;this._bufferInitSegment(w.tracks,C,l),n.trigger(R.FRAG_PARSING_INIT_SEGMENT,{frag:C,id:r,tracks:w.tracks})}if(E){const{startPTS:C,endPTS:D,startDTS:M,endDTS:U}=E;p&&(p.elementaryStreams[Oe.AUDIO]={startPTS:C,endPTS:D,startDTS:M,endDTS:U}),f.setElementaryStreamInfo(Oe.AUDIO,C,D,M,U),this.bufferFragmentData(E,f,p,l)}if(T!=null&&(e=T.samples)!=null&&e.length){const C=dr({id:r,frag:f,details:v},T);n.trigger(R.FRAG_PARSING_METADATA,C)}if(A){const C=dr({id:r,frag:f,details:v},A);n.trigger(R.FRAG_PARSING_USERDATA,C)}}_bufferInitSegment(t,e,r){if(this.state!==Rt.PARSING)return;t.video&&delete t.video;const n=t.audio;if(!n)return;n.levelCodec=n.codec,n.id="audio",this.log(`Init audio buffer, container:${n.container}, codecs[parsed]=[${n.codec}]`),this.hls.trigger(R.BUFFER_CODECS,t);const o=n.initSegment;if(o!=null&&o.byteLength){const l={type:"audio",frag:e,part:null,chunkMeta:r,parent:e.type,data:o};this.hls.trigger(R.BUFFER_APPENDING,l)}this.tick()}loadFragment(t,e,r){const n=this.fragmentTracker.getState(t);if(this.fragCurrent=t,this.switchingTrack||n===vr.NOT_LOADED||n===vr.PARTIAL){var o;t.sn==="initSegment"?this._loadInitSegment(t,e):(o=e.details)!=null&&o.live&&!this.initPTS[t.cc]?(this.log(`Waiting for video PTS in continuity counter ${t.cc} of live stream before loading audio fragment ${t.sn} of level ${this.trackId}`),this.state=Rt.WAITING_INIT_PTS):(this.startFragRequested=!0,super.loadFragment(t,e,r))}else this.clearTrackerIfNeeded(t)}completeAudioSwitch(t){const{hls:e,media:r,bufferedTrack:n}=this,o=n==null?void 0:n.attrs,l=t.attrs;r&&o&&(o.CHANNELS!==l.CHANNELS||o.NAME!==l.NAME||o.LANGUAGE!==l.LANGUAGE)&&(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio")),this.bufferedTrack=t,this.switchingTrack=null,e.trigger(R.AUDIO_TRACK_SWITCHED,zr({},t))}}class bE extends th{constructor(t){super(t,"[audio-track-controller]"),this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){const{hls:t}=this;t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.MANIFEST_PARSED,this.onManifestParsed,this),t.on(R.LEVEL_LOADING,this.onLevelLoading,this),t.on(R.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(R.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(R.ERROR,this.onError,this)}unregisterListeners(){const{hls:t}=this;t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.MANIFEST_PARSED,this.onManifestParsed,this),t.off(R.LEVEL_LOADING,this.onLevelLoading,this),t.off(R.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(R.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(R.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(t,e){this.tracks=e.audioTracks||[]}onAudioTrackLoaded(t,e){const{id:r,groupId:n,details:o}=e,l=this.tracksInGroup[r];if(!l||l.groupId!==n){this.warn(`Track with id:${r} and group:${n} not found in active group ${l.groupId}`);return}const d=l.details;l.details=e.details,this.log(`audio-track ${r} "${l.name}" lang:${l.lang} group:${n} loaded [${o.startSN}-${o.endSN}]`),r===this.trackId&&this.playlistLoaded(r,e,d)}onLevelLoading(t,e){this.switchLevel(e.level)}onLevelSwitching(t,e){this.switchLevel(e.level)}switchLevel(t){const e=this.hls.levels[t];if(!(e!=null&&e.audioGroupIds))return;const r=e.audioGroupIds[e.urlId];if(this.groupId!==r){this.groupId=r||null;const n=this.tracks.filter(l=>!r||l.groupId===r);this.selectDefaultTrack&&!n.some(l=>l.default)&&(this.selectDefaultTrack=!1),this.tracksInGroup=n;const o={audioTracks:n};this.log(`Updating audio tracks, ${n.length} track(s) found in group:${r}`),this.hls.trigger(R.AUDIO_TRACKS_UPDATED,o),this.selectInitialTrack()}else this.shouldReloadPlaylist(this.currentTrack)&&this.setAudioTrack(this.trackId)}onError(t,e){e.fatal||!e.context||e.context.type===Se.AUDIO_TRACK&&e.context.id===this.trackId&&e.context.groupId===this.groupId&&(this.requestScheduled=-1,this.checkRetry(e))}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(t){this.selectDefaultTrack=!1,this.setAudioTrack(t)}setAudioTrack(t){const e=this.tracksInGroup;if(t<0||t>=e.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();const r=this.currentTrack;e[this.trackId];const n=e[t],{groupId:o,name:l}=n;if(this.log(`Switching to audio-track ${t} "${l}" lang:${n.lang} group:${o}`),this.trackId=t,this.currentTrack=n,this.selectDefaultTrack=!1,this.hls.trigger(R.AUDIO_TRACK_SWITCHING,zr({},n)),n.details&&!n.details.live)return;const d=this.switchParams(n.url,r==null?void 0:r.details);this.loadPlaylist(d)}selectInitialTrack(){const t=this.tracksInGroup,e=this.findTrackId(this.currentTrack)|this.findTrackId(null);if(e!==-1)this.setAudioTrack(e);else{const r=new Error(`No track found for running audio group-ID: ${this.groupId} track count: ${t.length}`);this.warn(r.message),this.hls.trigger(R.ERROR,{type:Qt.MEDIA_ERROR,details:ut.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:r})}}findTrackId(t){const e=this.tracksInGroup;for(let r=0;r<e.length;r++){const n=e[r];if((!this.selectDefaultTrack||n.default)&&(!t||t.attrs["STABLE-RENDITION-ID"]!==void 0&&t.attrs["STABLE-RENDITION-ID"]===n.attrs["STABLE-RENDITION-ID"]||t.name===n.name&&t.lang===n.lang))return n.id}return-1}loadPlaylist(t){super.loadPlaylist();const e=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(e)){const r=e.id,n=e.groupId;let o=e.url;if(t)try{o=t.addDirectives(o)}catch(l){this.warn(`Could not construct new URL with HLS Delivery Directives: ${l}`)}this.log(`loading audio-track playlist ${r} "${e.name}" lang:${e.lang} group:${n}`),this.clearTimer(),this.hls.trigger(R.AUDIO_TRACK_LOADING,{url:o,id:r,groupId:n,deliveryDirectives:t||null})}}}function fp(i,t){if(i.length!==t.length)return!1;for(let e=0;e<i.length;e++)if(!EE(i[e].attrs,t[e].attrs))return!1;return!0}function EE(i,t){const e=i["STABLE-RENDITION-ID"];return e?e===t["STABLE-RENDITION-ID"]:!["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED"].some(r=>i[r]!==t[r])}const pp=500;class AE extends nh{constructor(t,e,r){super(t,e,r,"[subtitle-stream-controller]",Jt.SUBTITLE),this.levels=[],this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),this.mainDetails=null}_registerListeners(){const{hls:t}=this;t.on(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.LEVEL_LOADED,this.onLevelLoaded,this),t.on(R.ERROR,this.onError,this),t.on(R.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(R.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.on(R.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(R.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.on(R.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(R.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:t}=this;t.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.LEVEL_LOADED,this.onLevelLoaded,this),t.off(R.ERROR,this.onError,this),t.off(R.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(R.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.off(R.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(R.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.off(R.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(R.FRAG_BUFFERED,this.onFragBuffered,this)}startLoad(t){this.stopLoad(),this.state=Rt.IDLE,this.setInterval(pp),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}onManifestLoading(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()}onMediaDetaching(){this.tracksBuffered=[],super.onMediaDetaching()}onLevelLoaded(t,e){this.mainDetails=e.details}onSubtitleFragProcessed(t,e){const{frag:r,success:n}=e;if(this.fragPrevious=r,this.state=Rt.IDLE,!n)return;const o=this.tracksBuffered[this.currentTrackId];if(!o)return;let l;const d=r.start;for(let p=0;p<o.length;p++)if(d>=o[p].start&&d<=o[p].end){l=o[p];break}const f=r.start+r.duration;l?l.end=f:(l={start:d,end:f},o.push(l)),this.fragmentTracker.fragBuffered(r)}onBufferFlushing(t,e){const{startOffset:r,endOffset:n}=e;if(r===0&&n!==Number.POSITIVE_INFINITY){const o=n-1;if(o<=0)return;e.endOffsetSubtitles=Math.max(0,o),this.tracksBuffered.forEach(l=>{for(let d=0;d<l.length;){if(l[d].end<=o){l.shift();continue}else if(l[d].start<o)l[d].start=o;else break;d++}}),this.fragmentTracker.removeFragmentsInRange(r,o,Jt.SUBTITLE)}}onFragBuffered(t,e){if(!this.loadedmetadata&&e.frag.type===Jt.MAIN){var r;(r=this.media)!=null&&r.buffered.length&&(this.loadedmetadata=!0)}}onError(t,e){const r=e.frag;(r==null?void 0:r.type)===Jt.SUBTITLE&&(this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==Rt.STOPPED&&(this.state=Rt.IDLE))}onSubtitleTracksUpdated(t,{subtitleTracks:e}){if(fp(this.levels,e)){this.levels=e.map(r=>new Ma(r));return}this.tracksBuffered=[],this.levels=e.map(r=>{const n=new Ma(r);return this.tracksBuffered[n.id]=[],n}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,Jt.SUBTITLE),this.fragPrevious=null,this.mediaBuffer=null}onSubtitleTrackSwitch(t,e){if(this.currentTrackId=e.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}const r=this.levels[this.currentTrackId];r!=null&&r.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,r&&this.setInterval(pp)}onSubtitleTrackLoaded(t,e){var r;const{details:n,id:o}=e,{currentTrackId:l,levels:d}=this;if(!d.length)return;const f=d[l];if(o>=d.length||o!==l||!f)return;this.mediaBuffer=this.mediaBufferTimeRanges;let p=0;if(n.live||(r=f.details)!=null&&r.live){const g=this.mainDetails;if(n.deltaUpdateFailed||!g)return;const v=g.fragments[0];f.details?(p=this.alignPlaylists(n,f.details),p===0&&v&&(p=v.start,qc(n,p))):n.hasProgramDateTime&&g.hasProgramDateTime?(Vf(n,g),p=n.fragments[0].start):v&&(p=v.start,qc(n,p))}f.details=n,this.levelLastLoaded=o,!this.startFragRequested&&(this.mainDetails||!n.live)&&this.setStartPosition(f.details,p),this.tick(),n.live&&!this.fragCurrent&&this.media&&this.state===Rt.IDLE&&(Na(null,n.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),f.details=void 0))}_handleFragmentLoadComplete(t){const{frag:e,payload:r}=t,n=e.decryptdata,o=this.hls;if(!this.fragContextChanged(e)&&r&&r.byteLength>0&&n&&n.key&&n.iv&&n.method==="AES-128"){const l=performance.now();this.decrypter.decrypt(new Uint8Array(r),n.key.buffer,n.iv.buffer).catch(d=>{throw o.trigger(R.ERROR,{type:Qt.MEDIA_ERROR,details:ut.FRAG_DECRYPT_ERROR,fatal:!1,error:d,reason:d.message,frag:e}),d}).then(d=>{const f=performance.now();o.trigger(R.FRAG_DECRYPTED,{frag:e,payload:d,stats:{tstart:l,tdecrypt:f}})}).catch(d=>{this.warn(`${d.name}: ${d.message}`),this.state=Rt.IDLE})}}doTick(){if(!this.media){this.state=Rt.IDLE;return}if(this.state===Rt.IDLE){const{currentTrackId:t,levels:e}=this,r=e[t];if(!e.length||!r||!r.details)return;const{config:n}=this,o=this.getLoadPosition(),l=Ve.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],o,n.maxBufferHole),{end:d,len:f}=l,p=this.getFwdBufferInfo(this.media,Jt.MAIN),g=r.details,v=this.getMaxBufferLength(p==null?void 0:p.len)+g.levelTargetDuration;if(f>v)return;const E=g.fragments,A=E.length,T=g.edge;let w=null;const C=this.fragPrevious;if(d<T){const D=n.maxFragLookUpTolerance,M=d>T-D?0:D;w=Na(C,E,Math.max(E[0].start,d),M),!w&&C&&C.start<E[0].start&&(w=E[0])}else w=E[A-1];if(!w)return;if(w=this.mapToInitFragWhenRequired(w),w.sn!=="initSegment"){const D=w.sn-g.startSN,M=E[D-1];M&&M.cc===w.cc&&this.fragmentTracker.getState(M)===vr.NOT_LOADED&&(w=M)}this.fragmentTracker.getState(w)===vr.NOT_LOADED&&this.loadFragment(w,r,d)}}getMaxBufferLength(t){const e=super.getMaxBufferLength();return t?Math.max(e,t):e}loadFragment(t,e,r){this.fragCurrent=t,t.sn==="initSegment"?this._loadInitSegment(t,e):(this.startFragRequested=!0,super.loadFragment(t,e,r))}get mediaBufferTimeRanges(){return new TE(this.tracksBuffered[this.currentTrackId]||[])}}class TE{constructor(t){this.buffered=void 0;const e=(r,n,o)=>{if(n=n>>>0,n>o-1)throw new DOMException(`Failed to execute '${r}' on 'TimeRanges': The index provided (${n}) is greater than the maximum bound (${o})`);return t[n][r]};this.buffered={get length(){return t.length},end(r){return e("end",r,t.length)},start(r){return e("start",r,t.length)}}}}class kE extends th{constructor(t){super(t,"[subtitle-track-controller]"),this.media=null,this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0,this.queuedDefaultTrack=-1,this.trackChangeListener=()=>this.onTextTracksChanged(),this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.registerListeners()}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,super.destroy()}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(t){this._subtitleDisplay=t,this.trackId>-1&&this.toggleTrackModes(this.trackId)}registerListeners(){const{hls:t}=this;t.on(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.MANIFEST_PARSED,this.onManifestParsed,this),t.on(R.LEVEL_LOADING,this.onLevelLoading,this),t.on(R.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(R.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(R.ERROR,this.onError,this)}unregisterListeners(){const{hls:t}=this;t.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.MANIFEST_PARSED,this.onManifestParsed,this),t.off(R.LEVEL_LOADING,this.onLevelLoading,this),t.off(R.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(R.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(R.ERROR,this.onError,this)}onMediaAttached(t,e){this.media=e.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))}pollTrackChange(t){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,t)}onMediaDetaching(){this.media&&(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),vh(this.media.textTracks).forEach(t=>{xn(t)}),this.subtitleTrack=-1,this.media=null)}onManifestLoading(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(t,e){this.tracks=e.subtitleTracks}onSubtitleTrackLoaded(t,e){const{id:r,details:n}=e,{trackId:o}=this,l=this.tracksInGroup[o];if(!l){this.warn(`Invalid subtitle track id ${r}`);return}const d=l.details;l.details=e.details,this.log(`subtitle track ${r} loaded [${n.startSN}-${n.endSN}]`),r===this.trackId&&this.playlistLoaded(r,e,d)}onLevelLoading(t,e){this.switchLevel(e.level)}onLevelSwitching(t,e){this.switchLevel(e.level)}switchLevel(t){const e=this.hls.levels[t];if(!(e!=null&&e.textGroupIds))return;const r=e.textGroupIds[e.urlId],n=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;if(this.groupId!==r){const o=this.tracks.filter(f=>!r||f.groupId===r);this.tracksInGroup=o;const l=this.findTrackId(n==null?void 0:n.name)||this.findTrackId();this.groupId=r||null;const d={subtitleTracks:o};this.log(`Updating subtitle tracks, ${o.length} track(s) found in "${r}" group-id`),this.hls.trigger(R.SUBTITLE_TRACKS_UPDATED,d),l!==-1&&this.setSubtitleTrack(l,n)}else this.shouldReloadPlaylist(n)&&this.setSubtitleTrack(this.trackId,n)}findTrackId(t){const e=this.tracksInGroup;for(let r=0;r<e.length;r++){const n=e[r];if((!this.selectDefaultTrack||n.default)&&(!t||t===n.name))return n.id}return-1}onError(t,e){e.fatal||!e.context||e.context.type===Se.SUBTITLE_TRACK&&e.context.id===this.trackId&&e.context.groupId===this.groupId&&this.checkRetry(e)}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(t){this.selectDefaultTrack=!1;const e=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(t,e)}loadPlaylist(t){super.loadPlaylist();const e=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(e)){const r=e.id,n=e.groupId;let o=e.url;if(t)try{o=t.addDirectives(o)}catch(l){this.warn(`Could not construct new URL with HLS Delivery Directives: ${l}`)}this.log(`Loading subtitle playlist for id ${r}`),this.hls.trigger(R.SUBTITLE_TRACK_LOADING,{url:o,id:r,groupId:n,deliveryDirectives:t||null})}}toggleTrackModes(t){const{media:e,trackId:r}=this;if(!e)return;const n=vh(e.textTracks),o=n.filter(d=>d.groupId===this.groupId);if(t===-1)[].slice.call(n).forEach(d=>{d.mode="disabled"});else{const d=o[r];d&&(d.mode="disabled")}const l=o[t];l&&(l.mode=this.subtitleDisplay?"showing":"hidden")}setSubtitleTrack(t,e){var r;const n=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=t;return}if(this.trackId!==t&&this.toggleTrackModes(t),this.trackId===t&&(t===-1||(r=n[t])!=null&&r.details)||t<-1||t>=n.length)return;this.clearTimer();const o=n[t];if(this.log(`Switching to subtitle-track ${t}`+(o?` "${o.name}" lang:${o.lang} group:${o.groupId}`:"")),this.trackId=t,o){const{id:l,groupId:d="",name:f,type:p,url:g}=o;this.hls.trigger(R.SUBTITLE_TRACK_SWITCH,{id:l,groupId:d,name:f,type:p,url:g});const v=this.switchParams(o.url,e==null?void 0:e.details);this.loadPlaylist(v)}else this.hls.trigger(R.SUBTITLE_TRACK_SWITCH,{id:t})}onTextTracksChanged(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let t=-1;const e=vh(this.media.textTracks);for(let r=0;r<e.length;r++)if(e[r].mode==="hidden")t=r;else if(e[r].mode==="showing"){t=r;break}this.subtitleTrack!==t&&(this.subtitleTrack=t)}}function vh(i){const t=[];for(let e=0;e<i.length;e++){const r=i[e];(r.kind==="subtitles"||r.kind==="captions")&&r.label&&t.push(i[e])}return t}class wE{constructor(t){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=t}append(t,e){const r=this.queues[e];r.push(t),r.length===1&&this.buffers[e]&&this.executeNext(e)}insertAbort(t,e){this.queues[e].unshift(t),this.executeNext(e)}appendBlocker(t){let e;const r=new Promise(o=>{e=o}),n={execute:e,onStart:()=>{},onComplete:()=>{},onError:()=>{}};return this.append(n,t),r}executeNext(t){const{buffers:e,queues:r}=this,n=e[t],o=r[t];if(o.length){const l=o[0];try{l.execute()}catch(d){X.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),l.onError(d),n!=null&&n.updating||(o.shift(),this.executeNext(t))}}}shiftAndExecuteNext(t){this.queues[t].shift(),this.executeNext(t)}current(t){return this.queues[t][0]}}const gp=zo(),mp=/([ha]vc.)(?:\.[^.,]+)+/;class SE{constructor(t){this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=()=>{const{media:e,mediaSource:r}=this;X.log("[buffer-controller]: Media source opened"),e&&(e.removeEventListener("emptied",this._onMediaEmptied),this.updateMediaElementDuration(),this.hls.trigger(R.MEDIA_ATTACHED,{media:e})),r&&r.removeEventListener("sourceopen",this._onMediaSourceOpen),this.checkPendingTracks()},this._onMediaSourceClose=()=>{X.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=()=>{X.log("[buffer-controller]: Media source ended")},this._onMediaEmptied=()=>{const{media:e,_objectUrl:r}=this;e&&e.src!==r&&X.error(`Media element src was set while attaching MediaSource (${r} > ${e.src})`)},this.hls=t,this._initSourceBuffer(),this.registerListeners()}hasSourceTypes(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null}registerListeners(){const{hls:t}=this;t.on(R.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.MANIFEST_PARSED,this.onManifestParsed,this),t.on(R.BUFFER_RESET,this.onBufferReset,this),t.on(R.BUFFER_APPENDING,this.onBufferAppending,this),t.on(R.BUFFER_CODECS,this.onBufferCodecs,this),t.on(R.BUFFER_EOS,this.onBufferEos,this),t.on(R.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(R.LEVEL_UPDATED,this.onLevelUpdated,this),t.on(R.FRAG_PARSED,this.onFragParsed,this),t.on(R.FRAG_CHANGED,this.onFragChanged,this)}unregisterListeners(){const{hls:t}=this;t.off(R.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.MANIFEST_PARSED,this.onManifestParsed,this),t.off(R.BUFFER_RESET,this.onBufferReset,this),t.off(R.BUFFER_APPENDING,this.onBufferAppending,this),t.off(R.BUFFER_CODECS,this.onBufferCodecs,this),t.off(R.BUFFER_EOS,this.onBufferEos,this),t.off(R.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(R.LEVEL_UPDATED,this.onLevelUpdated,this),t.off(R.FRAG_PARSED,this.onFragParsed,this),t.off(R.FRAG_CHANGED,this.onFragChanged,this)}_initSourceBuffer(){this.sourceBuffer={},this.operationQueue=new wE(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.lastMpegAudioChunk=null}onManifestLoading(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null}onManifestParsed(t,e){let r=2;(e.audio&&!e.video||!e.altAudio)&&(r=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r,X.log(`${this.bufferCodecEventsExpected} bufferCodec event(s) expected`)}onMediaAttaching(t,e){const r=this.media=e.media;if(r&&gp){const n=this.mediaSource=new gp;n.addEventListener("sourceopen",this._onMediaSourceOpen),n.addEventListener("sourceended",this._onMediaSourceEnded),n.addEventListener("sourceclose",this._onMediaSourceClose),r.src=self.URL.createObjectURL(n),this._objectUrl=r.src,r.addEventListener("emptied",this._onMediaEmptied)}}onMediaDetaching(){const{media:t,mediaSource:e,_objectUrl:r}=this;if(e){if(X.log("[buffer-controller]: media source detaching"),e.readyState==="open")try{e.endOfStream()}catch(n){X.warn(`[buffer-controller]: onMediaDetaching: ${n.message} while calling endOfStream`)}this.onBufferReset(),e.removeEventListener("sourceopen",this._onMediaSourceOpen),e.removeEventListener("sourceended",this._onMediaSourceEnded),e.removeEventListener("sourceclose",this._onMediaSourceClose),t&&(t.removeEventListener("emptied",this._onMediaEmptied),r&&self.URL.revokeObjectURL(r),t.src===r?(t.removeAttribute("src"),t.load()):X.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(R.MEDIA_DETACHED,void 0)}onBufferReset(){this.getSourceBufferTypes().forEach(t=>{const e=this.sourceBuffer[t];try{e&&(this.removeBufferListeners(t),this.mediaSource&&this.mediaSource.removeSourceBuffer(e),this.sourceBuffer[t]=void 0)}catch(r){X.warn(`[buffer-controller]: Failed to reset the ${t} buffer`,r)}}),this._initSourceBuffer()}onBufferCodecs(t,e){const r=this.getSourceBufferTypes().length;Object.keys(e).forEach(n=>{if(r){const o=this.tracks[n];if(o&&typeof o.buffer.changeType=="function"){const{id:l,codec:d,levelCodec:f,container:p,metadata:g}=e[n],v=(o.levelCodec||o.codec).replace(mp,"$1"),E=(f||d).replace(mp,"$1");if(v!==E){const A=`${p};codecs=${f||d}`;this.appendChangeType(n,A),X.log(`[buffer-controller]: switching codec ${v} to ${E}`),this.tracks[n]={buffer:o.buffer,codec:d,container:p,levelCodec:f,metadata:g,id:l}}}}else this.pendingTracks[n]=e[n]}),!r&&(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())}appendChangeType(t,e){const{operationQueue:r}=this,n={execute:()=>{const o=this.sourceBuffer[t];o&&(X.log(`[buffer-controller]: changing ${t} sourceBuffer type to ${e}`),o.changeType(e)),r.shiftAndExecuteNext(t)},onStart:()=>{},onComplete:()=>{},onError:o=>{X.warn(`[buffer-controller]: Failed to change ${t} SourceBuffer type`,o)}};r.append(n,t)}onBufferAppending(t,e){const{hls:r,operationQueue:n,tracks:o}=this,{data:l,type:d,frag:f,part:p,chunkMeta:g}=e,v=g.buffering[d],E=self.performance.now();v.start=E;const A=f.stats.buffering,T=p?p.stats.buffering:null;A.start===0&&(A.start=E),T&&T.start===0&&(T.start=E);const w=o.audio;let C=!1;d==="audio"&&(w==null?void 0:w.container)==="audio/mpeg"&&(C=!this.lastMpegAudioChunk||g.id===1||this.lastMpegAudioChunk.sn!==g.sn,this.lastMpegAudioChunk=g);const D=f.start,M={execute:()=>{if(v.executeStart=self.performance.now(),C){const U=this.sourceBuffer[d];if(U){const x=D-U.timestampOffset;Math.abs(x)>=.1&&(X.log(`[buffer-controller]: Updating audio SourceBuffer timestampOffset to ${D} (delta: ${x}) sn: ${f.sn})`),U.timestampOffset=D)}}this.appendExecutor(l,d)},onStart:()=>{},onComplete:()=>{const U=self.performance.now();v.executeEnd=v.end=U,A.first===0&&(A.first=U),T&&T.first===0&&(T.first=U);const{sourceBuffer:x}=this,O={};for(const K in x)O[K]=Ve.getBuffered(x[K]);this.appendError=0,this.hls.trigger(R.BUFFER_APPENDED,{type:d,frag:f,part:p,chunkMeta:g,parent:f.type,timeRanges:O})},onError:U=>{X.error(`[buffer-controller]: Error encountered while trying to append to the ${d} SourceBuffer`,U);const x={type:Qt.MEDIA_ERROR,parent:f.type,details:ut.BUFFER_APPEND_ERROR,frag:f,part:p,chunkMeta:g,error:U,err:U,fatal:!1};U.code===DOMException.QUOTA_EXCEEDED_ERR?x.details=ut.BUFFER_FULL_ERROR:(this.appendError++,x.details=ut.BUFFER_APPEND_ERROR,this.appendError>r.config.appendErrorMaxRetry&&(X.error(`[buffer-controller]: Failed ${r.config.appendErrorMaxRetry} times to append segment in sourceBuffer`),x.fatal=!0)),r.trigger(R.ERROR,x)}};n.append(M,d)}onBufferFlushing(t,e){const{operationQueue:r}=this,n=o=>({execute:this.removeExecutor.bind(this,o,e.startOffset,e.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger(R.BUFFER_FLUSHED,{type:o})},onError:l=>{X.warn(`[buffer-controller]: Failed to remove from ${o} SourceBuffer`,l)}});e.type?r.append(n(e.type),e.type):this.getSourceBufferTypes().forEach(o=>{r.append(n(o),o)})}onFragParsed(t,e){const{frag:r,part:n}=e,o=[],l=n?n.elementaryStreams:r.elementaryStreams;l[Oe.AUDIOVIDEO]?o.push("audiovideo"):(l[Oe.AUDIO]&&o.push("audio"),l[Oe.VIDEO]&&o.push("video"));const d=()=>{const f=self.performance.now();r.stats.buffering.end=f,n&&(n.stats.buffering.end=f);const p=n?n.stats:r.stats;this.hls.trigger(R.FRAG_BUFFERED,{frag:r,part:n,stats:p,id:r.type})};o.length===0&&X.warn(`Fragments must have at least one ElementaryStreamType set. type: ${r.type} level: ${r.level} sn: ${r.sn}`),this.blockBuffers(d,o)}onFragChanged(t,e){this.flushBackBuffer()}onBufferEos(t,e){this.getSourceBufferTypes().reduce((r,n)=>{const o=this.sourceBuffer[n];return o&&(!e.type||e.type===n)&&(o.ending=!0,o.ended||(o.ended=!0,X.log(`[buffer-controller]: ${n} sourceBuffer now EOS`))),r&&!!(!o||o.ended)},!0)&&(X.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers(()=>{this.getSourceBufferTypes().forEach(n=>{const o=this.sourceBuffer[n];o&&(o.ending=!1)});const{mediaSource:r}=this;if(!r||r.readyState!=="open"){r&&X.info(`[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: ${r.readyState}`);return}X.log("[buffer-controller]: Calling mediaSource.endOfStream()"),r.endOfStream()}))}onLevelUpdated(t,{details:e}){e.fragments.length&&(this.details=e,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())}flushBackBuffer(){const{hls:t,details:e,media:r,sourceBuffer:n}=this;if(!r||e===null)return;const o=this.getSourceBufferTypes();if(!o.length)return;const l=e.live&&t.config.liveBackBufferLength!==null?t.config.liveBackBufferLength:t.config.backBufferLength;if(!jt(l)||l<0)return;const d=r.currentTime,f=e.levelTargetDuration,p=Math.max(l,f),g=Math.floor(d/f)*f-p;o.forEach(v=>{const E=n[v];if(E){const A=Ve.getBuffered(E);if(A.length>0&&g>A.start(0)){if(t.trigger(R.BACK_BUFFER_REACHED,{bufferEnd:g}),e.live)t.trigger(R.LIVE_BACK_BUFFER_REACHED,{bufferEnd:g});else if(E.ended&&A.end(A.length-1)-d<f*2){X.info(`[buffer-controller]: Cannot flush ${v} back buffer while SourceBuffer is in ended state`);return}t.trigger(R.BUFFER_FLUSHING,{startOffset:0,endOffset:g,type:v})}}})}updateMediaElementDuration(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;const{details:t,hls:e,media:r,mediaSource:n}=this,o=t.fragments[0].start+t.totalduration,l=r.duration,d=jt(n.duration)?n.duration:0;t.live&&e.config.liveDurationInfinity?(X.log("[buffer-controller]: Media Source duration is set to Infinity"),n.duration=1/0,this.updateSeekableRange(t)):(o>d&&o>l||!jt(l))&&(X.log(`[buffer-controller]: Updating Media Source duration to ${o.toFixed(3)}`),n.duration=o)}updateSeekableRange(t){const e=this.mediaSource,r=t.fragments;if(r.length&&t.live&&e!=null&&e.setLiveSeekableRange){const n=Math.max(0,r[0].start),o=Math.max(n,n+t.totalduration);e.setLiveSeekableRange(n,o)}}checkPendingTracks(){const{bufferCodecEventsExpected:t,operationQueue:e,pendingTracks:r}=this,n=Object.keys(r).length;if(n&&!t||n===2){this.createSourceBuffers(r),this.pendingTracks={};const o=this.getSourceBufferTypes();if(o.length)this.hls.trigger(R.BUFFER_CREATED,{tracks:this.tracks}),o.forEach(l=>{e.executeNext(l)});else{const l=new Error("could not create source buffer for media codec(s)");this.hls.trigger(R.ERROR,{type:Qt.MEDIA_ERROR,details:ut.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:l,reason:l.message})}}}createSourceBuffers(t){const{sourceBuffer:e,mediaSource:r}=this;if(!r)throw Error("createSourceBuffers called when mediaSource was null");for(const n in t)if(!e[n]){const o=t[n];if(!o)throw Error(`source buffer exists for track ${n}, however track does not`);const l=o.levelCodec||o.codec,d=`${o.container};codecs=${l}`;X.log(`[buffer-controller]: creating sourceBuffer(${d})`);try{const f=e[n]=r.addSourceBuffer(d),p=n;this.addBufferListener(p,"updatestart",this._onSBUpdateStart),this.addBufferListener(p,"updateend",this._onSBUpdateEnd),this.addBufferListener(p,"error",this._onSBUpdateError),this.tracks[n]={buffer:f,codec:l,container:o.container,levelCodec:o.levelCodec,metadata:o.metadata,id:o.id}}catch(f){X.error(`[buffer-controller]: error while trying to add sourceBuffer: ${f.message}`),this.hls.trigger(R.ERROR,{type:Qt.MEDIA_ERROR,details:ut.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:f,mimeType:d})}}}_onSBUpdateStart(t){const{operationQueue:e}=this;e.current(t).onStart()}_onSBUpdateEnd(t){const{operationQueue:e}=this;e.current(t).onComplete(),e.shiftAndExecuteNext(t)}_onSBUpdateError(t,e){const r=new Error(`${t} SourceBuffer error`);X.error(`[buffer-controller]: ${r}`,e),this.hls.trigger(R.ERROR,{type:Qt.MEDIA_ERROR,details:ut.BUFFER_APPENDING_ERROR,error:r,fatal:!1});const n=this.operationQueue.current(t);n&&n.onError(e)}removeExecutor(t,e,r){const{media:n,mediaSource:o,operationQueue:l,sourceBuffer:d}=this,f=d[t];if(!n||!o||!f){X.warn(`[buffer-controller]: Attempting to remove from the ${t} SourceBuffer, but it does not exist`),l.shiftAndExecuteNext(t);return}const p=jt(n.duration)?n.duration:1/0,g=jt(o.duration)?o.duration:1/0,v=Math.max(0,e),E=Math.min(r,p,g);E>v&&!f.ending?(f.ended=!1,X.log(`[buffer-controller]: Removing [${v},${E}] from the ${t} SourceBuffer`),f.remove(v,E)):l.shiftAndExecuteNext(t)}appendExecutor(t,e){const{operationQueue:r,sourceBuffer:n}=this,o=n[e];if(!o){X.warn(`[buffer-controller]: Attempting to append to the ${e} SourceBuffer, but it does not exist`),r.shiftAndExecuteNext(e);return}o.ended=!1,o.appendBuffer(t)}blockBuffers(t,e=this.getSourceBufferTypes()){if(!e.length){X.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(t);return}const{operationQueue:r}=this,n=e.map(o=>r.appendBlocker(o));Promise.all(n).then(()=>{t(),e.forEach(o=>{const l=this.sourceBuffer[o];l!=null&&l.updating||r.shiftAndExecuteNext(o)})})}getSourceBufferTypes(){return Object.keys(this.sourceBuffer)}addBufferListener(t,e,r){const n=this.sourceBuffer[t];if(!n)return;const o=r.bind(this,t);this.listeners[t].push({event:e,listener:o}),n.addEventListener(e,o)}removeBufferListeners(t){const e=this.sourceBuffer[t];e&&this.listeners[t].forEach(r=>{e.removeEventListener(r.event,r.listener)})}}const vp={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},yp=function(i){let t=i;return vp.hasOwnProperty(i)&&(t=vp[i]),String.fromCharCode(t)},Ri=15,as=100,RE={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},_E={17:2,18:4,21:6,22:8,23:10,19:13,20:15},LE={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},CE={25:2,26:4,29:6,30:8,31:10,27:13,28:15},IE=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class xE{constructor(){this.time=null,this.verboseLevel=0}log(t,e){if(this.verboseLevel>=t){const r=typeof e=="function"?e():e;X.log(`${this.time} [${t}] ${r}`)}}}const pn=function(i){const t=[];for(let e=0;e<i.length;e++)t.push(i[e].toString(16));return t};class bp{constructor(t,e,r,n,o){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=t||"white",this.underline=e||!1,this.italics=r||!1,this.background=n||"black",this.flash=o||!1}reset(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}setStyles(t){const e=["foreground","underline","italics","background","flash"];for(let r=0;r<e.length;r++){const n=e[r];t.hasOwnProperty(n)&&(this[n]=t[n])}}isDefault(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash}equals(t){return this.foreground===t.foreground&&this.underline===t.underline&&this.italics===t.italics&&this.background===t.background&&this.flash===t.flash}copy(t){this.foreground=t.foreground,this.underline=t.underline,this.italics=t.italics,this.background=t.background,this.flash=t.flash}toString(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}}class DE{constructor(t,e,r,n,o,l){this.uchar=void 0,this.penState=void 0,this.uchar=t||" ",this.penState=new bp(e,r,n,o,l)}reset(){this.uchar=" ",this.penState.reset()}setChar(t,e){this.uchar=t,this.penState.copy(e)}setPenState(t){this.penState.copy(t)}equals(t){return this.uchar===t.uchar&&this.penState.equals(t.penState)}copy(t){this.uchar=t.uchar,this.penState.copy(t.penState)}isEmpty(){return this.uchar===" "&&this.penState.isDefault()}}class PE{constructor(t){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(let e=0;e<as;e++)this.chars.push(new DE);this.logger=t,this.pos=0,this.currPenState=new bp}equals(t){let e=!0;for(let r=0;r<as;r++)if(!this.chars[r].equals(t.chars[r])){e=!1;break}return e}copy(t){for(let e=0;e<as;e++)this.chars[e].copy(t.chars[e])}isEmpty(){let t=!0;for(let e=0;e<as;e++)if(!this.chars[e].isEmpty()){t=!1;break}return t}setCursor(t){this.pos!==t&&(this.pos=t),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>as&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=as)}moveCursor(t){const e=this.pos+t;if(t>1)for(let r=this.pos+1;r<e+1;r++)this.chars[r].setPenState(this.currPenState);this.setCursor(e)}backSpace(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}insertChar(t){t>=144&&this.backSpace();const e=yp(t);if(this.pos>=as){this.logger.log(0,()=>"Cannot insert "+t.toString(16)+" ("+e+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(e,this.currPenState),this.moveCursor(1)}clearFromPos(t){let e;for(e=t;e<as;e++)this.chars[e].reset()}clear(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}clearToEndOfRow(){this.clearFromPos(this.pos)}getTextString(){const t=[];let e=!0;for(let r=0;r<as;r++){const n=this.chars[r].uchar;n!==" "&&(e=!1),t.push(n)}return e?"":t.join("")}setPenStyles(t){this.currPenState.setStyles(t),this.chars[this.pos].setPenState(this.currPenState)}}class yh{constructor(t){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(let e=0;e<Ri;e++)this.rows.push(new PE(t));this.logger=t,this.currRow=Ri-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}reset(){for(let t=0;t<Ri;t++)this.rows[t].clear();this.currRow=Ri-1}equals(t){let e=!0;for(let r=0;r<Ri;r++)if(!this.rows[r].equals(t.rows[r])){e=!1;break}return e}copy(t){for(let e=0;e<Ri;e++)this.rows[e].copy(t.rows[e])}isEmpty(){let t=!0;for(let e=0;e<Ri;e++)if(!this.rows[e].isEmpty()){t=!1;break}return t}backSpace(){this.rows[this.currRow].backSpace()}clearToEndOfRow(){this.rows[this.currRow].clearToEndOfRow()}insertChar(t){this.rows[this.currRow].insertChar(t)}setPen(t){this.rows[this.currRow].setPenStyles(t)}moveCursor(t){this.rows[this.currRow].moveCursor(t)}setCursor(t){this.logger.log(2,"setCursor: "+t),this.rows[this.currRow].setCursor(t)}setPAC(t){this.logger.log(2,()=>"pacData = "+JSON.stringify(t));let e=t.row-1;if(this.nrRollUpRows&&e<this.nrRollUpRows-1&&(e=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==e){for(let d=0;d<Ri;d++)this.rows[d].clear();const o=this.currRow+1-this.nrRollUpRows,l=this.lastOutputScreen;if(l){const d=l.rows[o].cueStartTime,f=this.logger.time;if(d&&f!==null&&d<f)for(let p=0;p<this.nrRollUpRows;p++)this.rows[e-this.nrRollUpRows+p+1].copy(l.rows[o+p])}}this.currRow=e;const r=this.rows[this.currRow];if(t.indent!==null){const o=t.indent,l=Math.max(o-1,0);r.setCursor(t.indent),t.color=r.chars[l].penState.foreground}const n={foreground:t.color,underline:t.underline,italics:t.italics,background:"black",flash:!1};this.setPen(n)}setBkgData(t){this.logger.log(2,()=>"bkgData = "+JSON.stringify(t)),this.backSpace(),this.setPen(t),this.insertChar(32)}setRollUpRows(t){this.nrRollUpRows=t}rollUp(){if(this.nrRollUpRows===null){this.logger.log(3,"roll_up but nrRollUpRows not set yet");return}this.logger.log(1,()=>this.getDisplayText());const t=this.currRow+1-this.nrRollUpRows,e=this.rows.splice(t,1)[0];e.clear(),this.rows.splice(this.currRow,0,e),this.logger.log(2,"Rolling up")}getDisplayText(t){t=t||!1;const e=[];let r="",n=-1;for(let o=0;o<Ri;o++){const l=this.rows[o].getTextString();l&&(n=o+1,t?e.push("Row "+n+": '"+l+"'"):e.push(l.trim()))}return e.length>0&&(t?r="["+e.join(" | ")+"]":r=e.join(`
197
+ `)),r}getTextAndFormat(){return this.rows}}class Ep{constructor(t,e,r){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=t,this.outputFilter=e,this.mode=null,this.verbose=0,this.displayedMemory=new yh(r),this.nonDisplayedMemory=new yh(r),this.lastOutputScreen=new yh(r),this.currRollUpRow=this.displayedMemory.rows[Ri-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=r}reset(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[Ri-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}getHandler(){return this.outputFilter}setHandler(t){this.outputFilter=t}setPAC(t){this.writeScreen.setPAC(t)}setBkgData(t){this.writeScreen.setBkgData(t)}setMode(t){t!==this.mode&&(this.mode=t,this.logger.log(2,()=>"MODE="+t),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=t)}insertChars(t){for(let r=0;r<t.length;r++)this.writeScreen.insertChar(t[r]);const e=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,()=>e+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(1,()=>"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())}ccRCL(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}ccBS(){this.logger.log(2,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}ccAOF(){}ccAON(){}ccDER(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}ccRU(t){this.logger.log(2,"RU("+t+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(t)}ccFON(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}ccRDC(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}ccTR(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}ccRTD(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}ccEDM(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}ccCR(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}ccENM(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}ccEOC(){if(this.logger.log(2,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){const t=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=t,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,()=>"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)}ccTO(t){this.logger.log(2,"TO("+t+") - Tab Offset"),this.writeScreen.moveCursor(t)}ccMIDROW(t){const e={flash:!1};if(e.underline=t%2===1,e.italics=t>=46,e.italics)e.foreground="white";else{const r=Math.floor(t/2)-16,n=["white","green","blue","cyan","red","yellow","magenta"];e.foreground=n[r]}this.logger.log(2,"MIDROW: "+JSON.stringify(e)),this.writeScreen.setPen(e)}outputDataUpdate(t=!1){const e=this.logger.time;e!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=e:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,e,this.lastOutputScreen),t&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:e),this.lastOutputScreen.copy(this.displayedMemory))}cueSplitAtTime(t){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,t,this.displayedMemory),this.cueStartTime=t))}}class Ap{constructor(t,e,r){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;const n=new xE;this.channels=[null,new Ep(t,e,n),new Ep(t+1,r,n)],this.cmdHistory=kp(),this.logger=n}getHandler(t){return this.channels[t].getHandler()}setHandler(t,e){this.channels[t].setHandler(e)}addData(t,e){let r,n,o,l=!1;this.logger.time=t;for(let d=0;d<e.length;d+=2)if(n=e[d]&127,o=e[d+1]&127,!(n===0&&o===0)){if(this.logger.log(3,"["+pn([e[d],e[d+1]])+"] -> ("+pn([n,o])+")"),r=this.parseCmd(n,o),r||(r=this.parseMidrow(n,o)),r||(r=this.parsePAC(n,o)),r||(r=this.parseBackgroundAttributes(n,o)),!r&&(l=this.parseChars(n,o),l)){const f=this.currentChannel;f&&f>0?this.channels[f].insertChars(l):this.logger.log(2,"No channel found yet. TEXT-MODE?")}!r&&!l&&this.logger.log(2,"Couldn't parse cleaned data "+pn([n,o])+" orig: "+pn([e[d],e[d+1]]))}}parseCmd(t,e){const{cmdHistory:r}=this,n=(t===20||t===28||t===21||t===29)&&e>=32&&e<=47,o=(t===23||t===31)&&e>=33&&e<=35;if(!(n||o))return!1;if(Tp(t,e,r))return $n(null,null,r),this.logger.log(3,"Repeated command ("+pn([t,e])+") is dropped"),!0;const l=t===20||t===21||t===23?1:2,d=this.channels[l];return t===20||t===21||t===28||t===29?e===32?d.ccRCL():e===33?d.ccBS():e===34?d.ccAOF():e===35?d.ccAON():e===36?d.ccDER():e===37?d.ccRU(2):e===38?d.ccRU(3):e===39?d.ccRU(4):e===40?d.ccFON():e===41?d.ccRDC():e===42?d.ccTR():e===43?d.ccRTD():e===44?d.ccEDM():e===45?d.ccCR():e===46?d.ccENM():e===47&&d.ccEOC():d.ccTO(e-32),$n(t,e,r),this.currentChannel=l,!0}parseMidrow(t,e){let r=0;if((t===17||t===25)&&e>=32&&e<=47){if(t===17?r=1:r=2,r!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;const n=this.channels[r];return n?(n.ccMIDROW(e),this.logger.log(3,"MIDROW ("+pn([t,e])+")"),!0):!1}return!1}parsePAC(t,e){let r;const n=this.cmdHistory,o=(t>=17&&t<=23||t>=25&&t<=31)&&e>=64&&e<=127,l=(t===16||t===24)&&e>=64&&e<=95;if(!(o||l))return!1;if(Tp(t,e,n))return $n(null,null,n),!0;const d=t<=23?1:2;e>=64&&e<=95?r=d===1?RE[t]:LE[t]:r=d===1?_E[t]:CE[t];const f=this.channels[d];return f?(f.setPAC(this.interpretPAC(r,e)),$n(t,e,n),this.currentChannel=d,!0):!1}interpretPAC(t,e){let r;const n={color:null,italics:!1,indent:null,underline:!1,row:t};return e>95?r=e-96:r=e-64,n.underline=(r&1)===1,r<=13?n.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(n.italics=!0,n.color="white"):n.indent=Math.floor((r-16)/2)*4,n}parseChars(t,e){let r,n=null,o=null;if(t>=25?(r=2,o=t-8):(r=1,o=t),o>=17&&o<=19){let l;o===17?l=e+80:o===18?l=e+112:l=e+144,this.logger.log(2,"Special char '"+yp(l)+"' in channel "+r),n=[l]}else t>=32&&t<=127&&(n=e===0?[t]:[t,e]);if(n){const l=pn(n);this.logger.log(3,"Char codes = "+l.join(",")),$n(t,e,this.cmdHistory)}return n}parseBackgroundAttributes(t,e){const r=(t===16||t===24)&&e>=32&&e<=47,n=(t===23||t===31)&&e>=45&&e<=47;if(!(r||n))return!1;let o;const l={};t===16||t===24?(o=Math.floor((e-32)/2),l.background=IE[o],e%2===1&&(l.background=l.background+"_semi")):e===45?l.background="transparent":(l.foreground="black",e===47&&(l.underline=!0));const d=t<=23?1:2;return this.channels[d].setBkgData(l),$n(t,e,this.cmdHistory),!0}reset(){for(let t=0;t<Object.keys(this.channels).length;t++){const e=this.channels[t];e&&e.reset()}this.cmdHistory=kp()}cueSplitAtTime(t){for(let e=0;e<this.channels.length;e++){const r=this.channels[e];r&&r.cueSplitAtTime(t)}}}function $n(i,t,e){e.a=i,e.b=t}function Tp(i,t,e){return e.a===i&&e.b===t}function kp(){return{a:null,b:null}}class nl{constructor(t,e){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=t,this.trackName=e}dispatchCue(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(t,e,r){(this.startTime===null||this.startTime>t)&&(this.startTime=t),this.endTime=e,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}}var bh=function(){if(typeof self<"u"&&self.VTTCue)return self.VTTCue;const i=["","lr","rl"],t=["start","middle","end","left","right"];function e(d,f){if(typeof f!="string"||!Array.isArray(d))return!1;const p=f.toLowerCase();return~d.indexOf(p)?p:!1}function r(d){return e(i,d)}function n(d){return e(t,d)}function o(d,...f){let p=1;for(;p<arguments.length;p++){const g=arguments[p];for(const v in g)d[v]=g[v]}return d}function l(d,f,p){const g=this,v={enumerable:!0};g.hasBeenReset=!1;let E="",A=!1,T=d,w=f,C=p,D=null,M="",U=!0,x="auto",O="start",K=50,B="middle",at=50,st="middle";Object.defineProperty(g,"id",o({},v,{get:function(){return E},set:function(J){E=""+J}})),Object.defineProperty(g,"pauseOnExit",o({},v,{get:function(){return A},set:function(J){A=!!J}})),Object.defineProperty(g,"startTime",o({},v,{get:function(){return T},set:function(J){if(typeof J!="number")throw new TypeError("Start time must be set to a number.");T=J,this.hasBeenReset=!0}})),Object.defineProperty(g,"endTime",o({},v,{get:function(){return w},set:function(J){if(typeof J!="number")throw new TypeError("End time must be set to a number.");w=J,this.hasBeenReset=!0}})),Object.defineProperty(g,"text",o({},v,{get:function(){return C},set:function(J){C=""+J,this.hasBeenReset=!0}})),Object.defineProperty(g,"region",o({},v,{get:function(){return D},set:function(J){D=J,this.hasBeenReset=!0}})),Object.defineProperty(g,"vertical",o({},v,{get:function(){return M},set:function(J){const kt=r(J);if(kt===!1)throw new SyntaxError("An invalid or illegal string was specified.");M=kt,this.hasBeenReset=!0}})),Object.defineProperty(g,"snapToLines",o({},v,{get:function(){return U},set:function(J){U=!!J,this.hasBeenReset=!0}})),Object.defineProperty(g,"line",o({},v,{get:function(){return x},set:function(J){if(typeof J!="number"&&J!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");x=J,this.hasBeenReset=!0}})),Object.defineProperty(g,"lineAlign",o({},v,{get:function(){return O},set:function(J){const kt=n(J);if(!kt)throw new SyntaxError("An invalid or illegal string was specified.");O=kt,this.hasBeenReset=!0}})),Object.defineProperty(g,"position",o({},v,{get:function(){return K},set:function(J){if(J<0||J>100)throw new Error("Position must be between 0 and 100.");K=J,this.hasBeenReset=!0}})),Object.defineProperty(g,"positionAlign",o({},v,{get:function(){return B},set:function(J){const kt=n(J);if(!kt)throw new SyntaxError("An invalid or illegal string was specified.");B=kt,this.hasBeenReset=!0}})),Object.defineProperty(g,"size",o({},v,{get:function(){return at},set:function(J){if(J<0||J>100)throw new Error("Size must be between 0 and 100.");at=J,this.hasBeenReset=!0}})),Object.defineProperty(g,"align",o({},v,{get:function(){return st},set:function(J){const kt=n(J);if(!kt)throw new SyntaxError("An invalid or illegal string was specified.");st=kt,this.hasBeenReset=!0}})),g.displayState=void 0}return l.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},l}();class OE{decode(t,e){if(!t)return"";if(typeof t!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(t))}}function wp(i){function t(r,n,o,l){return(r|0)*3600+(n|0)*60+(o|0)+parseFloat(l||0)}const e=i.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return e?parseFloat(e[2])>59?t(e[2],e[3],0,e[4]):t(e[1],e[2],e[3],e[4]):null}class $E{constructor(){this.values=Object.create(null)}set(t,e){!this.get(t)&&e!==""&&(this.values[t]=e)}get(t,e,r){return r?this.has(t)?this.values[t]:e[r]:this.has(t)?this.values[t]:e}has(t){return t in this.values}alt(t,e,r){for(let n=0;n<r.length;++n)if(e===r[n]){this.set(t,e);break}}integer(t,e){/^-?\d+$/.test(e)&&this.set(t,parseInt(e,10))}percent(t,e){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(e)){const r=parseFloat(e);if(r>=0&&r<=100)return this.set(t,r),!0}return!1}}function Sp(i,t,e,r){const n=r?i.split(r):[i];for(const o in n){if(typeof n[o]!="string")continue;const l=n[o].split(e);if(l.length!==2)continue;const d=l[0],f=l[1];t(d,f)}}const Eh=new bh(0,0,""),al=Eh.align==="middle"?"middle":"center";function ME(i,t,e){const r=i;function n(){const d=wp(i);if(d===null)throw new Error("Malformed timestamp: "+r);return i=i.replace(/^[^\sa-zA-Z-]+/,""),d}function o(d,f){const p=new $E;Sp(d,function(E,A){let T;switch(E){case"region":for(let w=e.length-1;w>=0;w--)if(e[w].id===A){p.set(E,e[w].region);break}break;case"vertical":p.alt(E,A,["rl","lr"]);break;case"line":T=A.split(","),p.integer(E,T[0]),p.percent(E,T[0])&&p.set("snapToLines",!1),p.alt(E,T[0],["auto"]),T.length===2&&p.alt("lineAlign",T[1],["start",al,"end"]);break;case"position":T=A.split(","),p.percent(E,T[0]),T.length===2&&p.alt("positionAlign",T[1],["start",al,"end","line-left","line-right","auto"]);break;case"size":p.percent(E,A);break;case"align":p.alt(E,A,["start",al,"end","left","right"]);break}},/:/,/\s/),f.region=p.get("region",null),f.vertical=p.get("vertical","");let g=p.get("line","auto");g==="auto"&&Eh.line===-1&&(g=-1),f.line=g,f.lineAlign=p.get("lineAlign","start"),f.snapToLines=p.get("snapToLines",!0),f.size=p.get("size",100),f.align=p.get("align",al);let v=p.get("position","auto");v==="auto"&&Eh.position===50&&(v=f.align==="start"||f.align==="left"?0:f.align==="end"||f.align==="right"?100:50),f.position=v}function l(){i=i.replace(/^\s+/,"")}if(l(),t.startTime=n(),l(),i.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+r);i=i.slice(3),l(),t.endTime=n(),l(),o(i,t)}function Rp(i){return i.replace(/<br(?: \/)?>/gi,`
198
+ `)}class NE{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new OE,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(t){const e=this;t&&(e.buffer+=e.decoder.decode(t,{stream:!0}));function r(){let o=e.buffer,l=0;for(o=Rp(o);l<o.length&&o[l]!=="\r"&&o[l]!==`
199
199
  `;)++l;const d=o.slice(0,l);return o[l]==="\r"&&++l,o[l]===`
200
- `&&++l,e.buffer=o.slice(l),d}function n(o){Sp(o,function(l,d){},/:/)}try{let o="";if(e.state==="INITIAL"){if(!/\r\n|\n/.test(e.buffer))return this;o=r();const d=o.match(/^()?WEBVTT([ \t].*)?$/);if(!(d!=null&&d[0]))throw new Error("Malformed WebVTT signature.");e.state="HEADER"}let l=!1;for(;e.buffer;){if(!/\r\n|\n/.test(e.buffer))return this;switch(l?l=!1:o=r(),e.state){case"HEADER":/:/.test(o)?n(o):o||(e.state="ID");continue;case"NOTE":o||(e.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(o)){e.state="NOTE";break}if(!o)continue;if(e.cue=new bh(0,0,""),e.state="CUE",o.indexOf("-->")===-1){e.cue.id=o;continue}case"CUE":if(!e.cue){e.state="BADCUE";continue}try{NE(o,e.cue,e.regionList)}catch{e.cue=null,e.state="BADCUE";continue}e.state="CUETEXT";continue;case"CUETEXT":{const d=o.indexOf("-->")!==-1;if(!o||d&&(l=!0)){e.oncue&&e.cue&&e.oncue(e.cue),e.cue=null,e.state="ID";continue}if(e.cue===null)continue;e.cue.text&&(e.cue.text+=`
200
+ `&&++l,e.buffer=o.slice(l),d}function n(o){Sp(o,function(l,d){},/:/)}try{let o="";if(e.state==="INITIAL"){if(!/\r\n|\n/.test(e.buffer))return this;o=r();const d=o.match(/^()?WEBVTT([ \t].*)?$/);if(!(d!=null&&d[0]))throw new Error("Malformed WebVTT signature.");e.state="HEADER"}let l=!1;for(;e.buffer;){if(!/\r\n|\n/.test(e.buffer))return this;switch(l?l=!1:o=r(),e.state){case"HEADER":/:/.test(o)?n(o):o||(e.state="ID");continue;case"NOTE":o||(e.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(o)){e.state="NOTE";break}if(!o)continue;if(e.cue=new bh(0,0,""),e.state="CUE",o.indexOf("-->")===-1){e.cue.id=o;continue}case"CUE":if(!e.cue){e.state="BADCUE";continue}try{ME(o,e.cue,e.regionList)}catch{e.cue=null,e.state="BADCUE";continue}e.state="CUETEXT";continue;case"CUETEXT":{const d=o.indexOf("-->")!==-1;if(!o||d&&(l=!0)){e.oncue&&e.cue&&e.oncue(e.cue),e.cue=null,e.state="ID";continue}if(e.cue===null)continue;e.cue.text&&(e.cue.text+=`
201
201
  `),e.cue.text+=o}continue;case"BADCUE":o||(e.state="ID")}}}catch{e.state==="CUETEXT"&&e.cue&&e.oncue&&e.oncue(e.cue),e.cue=null,e.state=e.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this}flush(){const t=this;try{if((t.cue||t.state==="HEADER")&&(t.buffer+=`
202
202
 
203
- `,t.parse()),t.state==="INITIAL"||t.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(e){t.onparsingerror&&t.onparsingerror(e)}return t.onflush&&t.onflush(),this}}const UE=/\r\n|\n\r|\n|\r/g,Ah=function(i,t,e=0){return i.slice(e,e+t.length)===t},BE=function(i){let t=parseInt(i.slice(-3));const e=parseInt(i.slice(-6,-4)),r=parseInt(i.slice(-9,-7)),n=i.length>9?parseInt(i.substring(0,i.indexOf(":"))):0;if(!jt(t)||!jt(e)||!jt(r)||!jt(n))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${i}`);return t+=1e3*e,t+=60*1e3*r,t+=60*60*1e3*n,t},Th=function(i){let t=5381,e=i.length;for(;e;)t=t*33^i.charCodeAt(--e);return(t>>>0).toString()};function kh(i,t,e){return Th(i.toString())+Th(t.toString())+Th(e)}const GE=function(i,t,e){let r=i[t],n=i[r.prevCC];if(!n||!n.new&&r.new){i.ccOffset=i.presentationOffset=r.start,r.new=!1;return}for(;(o=n)!=null&&o.new;){var o;i.ccOffset+=r.start-n.start,r.new=!1,r=n,n=i[r.prevCC]}i.presentationOffset=e};function HE(i,t,e,r,n,o,l){const d=new FE,f=Fi(new Uint8Array(i)).trim().replace(UE,`
203
+ `,t.parse()),t.state==="INITIAL"||t.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(e){t.onparsingerror&&t.onparsingerror(e)}return t.onflush&&t.onflush(),this}}const FE=/\r\n|\n\r|\n|\r/g,Ah=function(i,t,e=0){return i.slice(e,e+t.length)===t},UE=function(i){let t=parseInt(i.slice(-3));const e=parseInt(i.slice(-6,-4)),r=parseInt(i.slice(-9,-7)),n=i.length>9?parseInt(i.substring(0,i.indexOf(":"))):0;if(!jt(t)||!jt(e)||!jt(r)||!jt(n))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${i}`);return t+=1e3*e,t+=60*1e3*r,t+=60*60*1e3*n,t},Th=function(i){let t=5381,e=i.length;for(;e;)t=t*33^i.charCodeAt(--e);return(t>>>0).toString()};function kh(i,t,e){return Th(i.toString())+Th(t.toString())+Th(e)}const BE=function(i,t,e){let r=i[t],n=i[r.prevCC];if(!n||!n.new&&r.new){i.ccOffset=i.presentationOffset=r.start,r.new=!1;return}for(;(o=n)!=null&&o.new;){var o;i.ccOffset+=r.start-n.start,r.new=!1,r=n,n=i[r.prevCC]}i.presentationOffset=e};function GE(i,t,e,r,n,o,l){const d=new NE,f=Fi(new Uint8Array(i)).trim().replace(FE,`
204
204
  `).split(`
205
- `),p=[],g=t?J4(t.baseTime,t.timescale):0;let v="00:00.000",E=0,A=0,T,w=!0;d.oncue=function(C){const D=e[r];let M=e.ccOffset;const U=(E-g)/9e4;if(D!=null&&D.new&&(A!==void 0?M=e.ccOffset=D.start:GE(e,r,U)),U){if(!t){T=new Error("Missing initPTS for VTT MPEGTS");return}M=U-e.presentationOffset}const x=C.endTime-C.startTime,O=pi((C.startTime+M-A)*9e4,n*9e4)/9e4;C.startTime=Math.max(O,0),C.endTime=Math.max(O+x,0);const K=C.text.trim();C.text=decodeURIComponent(encodeURIComponent(K)),C.id||(C.id=kh(C.startTime,C.endTime,K)),C.endTime>0&&p.push(C)},d.onparsingerror=function(C){T=C},d.onflush=function(){if(T){l(T);return}o(p)},f.forEach(C=>{if(w)if(Ah(C,"X-TIMESTAMP-MAP=")){w=!1,C.slice(16).split(",").forEach(D=>{Ah(D,"LOCAL:")?v=D.slice(6):Ah(D,"MPEGTS:")&&(E=parseInt(D.slice(7)))});try{A=BE(v)/1e3}catch(D){T=D}return}else C===""&&(w=!1);d.parse(C+`
206
- `)}),d.flush()}const wh="stpp.ttml.im1t",_p=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Lp=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,VE={left:"start",center:"center",right:"end",start:"start",end:"end"};function Cp(i,t,e,r){const n=Te(new Uint8Array(i),["mdat"]);if(n.length===0){r(new Error("Could not parse IMSC1 mdat"));return}const o=n.map(d=>Fi(d)),l=Q4(t.baseTime,1,t.timescale);try{o.forEach(d=>e(WE(d,l)))}catch(d){r(d)}}function WE(i,t){const e=new DOMParser().parseFromString(i,"text/xml").getElementsByTagName("tt")[0];if(!e)throw new Error("Invalid ttml");const r={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},n=Object.keys(r).reduce((p,g)=>(p[g]=e.getAttribute(`ttp:${g}`)||r[g],p),{}),o=e.getAttribute("xml:space")!=="preserve",l=Ip(Sh(e,"styling","style")),d=Ip(Sh(e,"layout","region")),f=Sh(e,"body","[begin]");return[].map.call(f,p=>{const g=xp(p,o);if(!g||!p.hasAttribute("begin"))return null;const v=_h(p.getAttribute("begin"),n),E=_h(p.getAttribute("dur"),n);let A=_h(p.getAttribute("end"),n);if(v===null)throw Dp(p);if(A===null){if(E===null)throw Dp(p);A=v+E}const T=new bh(v-t,A-t,g);T.id=kh(T.startTime,T.endTime,T.text);const w=d[p.getAttribute("region")],C=l[p.getAttribute("style")],D=jE(w,C,l),{textAlign:M}=D;if(M){const U=VE[M];U&&(T.lineAlign=U),T.align=M}return dr(T,D),T}).filter(p=>p!==null)}function Sh(i,t,e){const r=i.getElementsByTagName(t)[0];return r?[].slice.call(r.querySelectorAll(e)):[]}function Ip(i){return i.reduce((t,e)=>{const r=e.getAttribute("xml:id");return r&&(t[r]=e),t},{})}function xp(i,t){return[].slice.call(i.childNodes).reduce((e,r,n)=>{var o;return r.nodeName==="br"&&n?e+`
207
- `:(o=r.childNodes)!=null&&o.length?xp(r,t):t?e+r.textContent.trim().replace(/\s+/g," "):e+r.textContent},"")}function jE(i,t,e){const r="http://www.w3.org/ns/ttml#styling";let n=null;const o=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],l=i!=null&&i.hasAttribute("style")?i.getAttribute("style"):null;return l&&e.hasOwnProperty(l)&&(n=e[l]),o.reduce((d,f)=>{const p=Rh(t,r,f)||Rh(i,r,f)||Rh(n,r,f);return p&&(d[f]=p),d},{})}function Rh(i,t,e){return i&&i.hasAttributeNS(t,e)?i.getAttributeNS(t,e):null}function Dp(i){return new Error(`Could not parse ttml timestamp ${i}`)}function _h(i,t){if(!i)return null;let e=wp(i);return e===null&&(_p.test(i)?e=KE(i,t):Lp.test(i)&&(e=zE(i,t))),e}function KE(i,t){const e=_p.exec(i),r=(e[4]|0)+(e[5]|0)/t.subFrameRate;return(e[1]|0)*3600+(e[2]|0)*60+(e[3]|0)+r/t.frameRate}function zE(i,t){const e=Lp.exec(i),r=Number(e[1]);switch(e[2]){case"h":return r*3600;case"m":return r*60;case"ms":return r*1e3;case"f":return r/t.frameRate;case"t":return r/t.tickRate}return r}class YE{constructor(t){if(this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=Pp(),this.captionsProperties=void 0,this.hls=t,this.config=t.config,this.Cues=t.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},this.config.enableCEA708Captions){const e=new nl(this,"textTrack1"),r=new nl(this,"textTrack2"),n=new nl(this,"textTrack3"),o=new nl(this,"textTrack4");this.cea608Parser1=new Ap(1,e,r),this.cea608Parser2=new Ap(3,n,o)}t.on(R.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(R.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(R.FRAG_LOADING,this.onFragLoading,this),t.on(R.FRAG_LOADED,this.onFragLoaded,this),t.on(R.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.on(R.FRAG_DECRYPTED,this.onFragDecrypted,this),t.on(R.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(R.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.on(R.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:t}=this;t.off(R.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(R.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(R.FRAG_LOADING,this.onFragLoading,this),t.off(R.FRAG_LOADED,this.onFragLoaded,this),t.off(R.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.off(R.FRAG_DECRYPTED,this.onFragDecrypted,this),t.off(R.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(R.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.off(R.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null}addCues(t,e,r,n,o){let l=!1;for(let d=o.length;d--;){const f=o[d],p=ZE(f[0],f[1],e,r);if(p>=0&&(f[0]=Math.min(f[0],e),f[1]=Math.max(f[1],r),l=!0,p/(r-e)>.5))return}if(l||o.push([e,r]),this.config.renderTextTracksNatively){const d=this.captionsTracks[t];this.Cues.newCue(d,e,r,n)}else{const d=this.Cues.newCue(null,e,r,n);this.hls.trigger(R.CUES_PARSED,{type:"captions",cues:d,track:t})}}onInitPtsFound(t,{frag:e,id:r,initPTS:n,timescale:o}){const{unparsedVttFrags:l}=this;r==="main"&&(this.initPTS[e.cc]={baseTime:n,timescale:o}),l.length&&(this.unparsedVttFrags=[],l.forEach(d=>{this.onFragLoaded(R.FRAG_LOADED,d)}))}getExistingTrack(t){const{media:e}=this;if(e)for(let r=0;r<e.textTracks.length;r++){const n=e.textTracks[r];if(n[t])return n}return null}createCaptionsTrack(t){this.config.renderTextTracksNatively?this.createNativeTrack(t):this.createNonNativeTrack(t)}createNativeTrack(t){if(this.captionsTracks[t])return;const{captionsProperties:e,captionsTracks:r,media:n}=this,{label:o,languageCode:l}=e[t],d=this.getExistingTrack(t);if(d)r[t]=d,xn(r[t]),_f(r[t],n);else{const f=this.createTextTrack("captions",o,l);f&&(f[t]=!0,r[t]=f)}}createNonNativeTrack(t){if(this.nonNativeCaptionsTracks[t])return;const e=this.captionsProperties[t];if(!e)return;const r=e.label,n={_id:t,label:r,kind:"captions",default:e.media?!!e.media.default:!1,closedCaptions:e.media};this.nonNativeCaptionsTracks[t]=n,this.hls.trigger(R.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[n]})}createTextTrack(t,e,r){const n=this.media;if(n)return n.addTextTrack(t,e,r)}onMediaAttaching(t,e){this.media=e.media,this._cleanTracks()}onMediaDetaching(){const{captionsTracks:t}=this;Object.keys(t).forEach(e=>{xn(t[e]),delete t[e]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=Pp(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}_cleanTracks(){const{media:t}=this;if(!t)return;const e=t.textTracks;if(e)for(let r=0;r<e.length;r++)xn(e[r])}onSubtitleTracksUpdated(t,e){const r=e.subtitleTracks||[],n=r.some(o=>o.textCodec===wh);if(this.config.enableWebVTT||n&&this.config.enableIMSC1){if(fp(this.tracks,r)){this.tracks=r;return}if(this.textTracks=[],this.tracks=r,this.config.renderTextTracksNatively){const o=this.media?this.media.textTracks:null;this.tracks.forEach((l,d)=>{let f;if(o&&d<o.length){let p=null;for(let g=0;g<o.length;g++)if(XE(o[g],l)){p=o[g];break}p&&(f=p)}if(f)xn(f);else{const p=this._captionsOrSubtitlesFromCharacteristics(l);f=this.createTextTrack(p,l.name,l.lang),f&&(f.mode="disabled")}f&&(f.groupId=l.groupId,this.textTracks.push(f))})}else if(this.tracks.length){const o=this.tracks.map(l=>({label:l.name,kind:l.type.toLowerCase(),default:l.default,subtitleTrack:l}));this.hls.trigger(R.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:o})}}}_captionsOrSubtitlesFromCharacteristics(t){if(t.attrs.CHARACTERISTICS){const e=/transcribes-spoken-dialog/gi.test(t.attrs.CHARACTERISTICS),r=/describes-music-and-sound/gi.test(t.attrs.CHARACTERISTICS);if(e&&r)return"captions"}return"subtitles"}onManifestLoaded(t,e){this.config.enableCEA708Captions&&e.captions&&e.captions.forEach(r=>{const n=/(?:CC|SERVICE)([1-4])/.exec(r.instreamId);if(!n)return;const o=`textTrack${n[1]}`,l=this.captionsProperties[o];l&&(l.label=r.name,r.lang&&(l.languageCode=r.lang),l.media=r)})}closedCaptionsForLevel(t){const e=this.hls.levels[t.level];return e==null?void 0:e.attrs["CLOSED-CAPTIONS"]}onFragLoading(t,e){const{cea608Parser1:r,cea608Parser2:n,lastSn:o,lastPartIndex:l}=this;if(!(!this.enabled||!(r&&n))&&e.frag.type===Jt.MAIN){var d,f;const p=e.frag.sn,g=(d=e==null||(f=e.part)==null?void 0:f.index)!=null?d:-1;p===o+1||p===o&&g===l+1||(r.reset(),n.reset()),this.lastSn=p,this.lastPartIndex=g}}onFragLoaded(t,e){const{frag:r,payload:n}=e;if(r.type===Jt.SUBTITLE)if(n.byteLength){const o=r.decryptdata,l="stats"in e;if(o==null||!o.encrypted||l){const d=this.tracks[r.level],f=this.vttCCs;f[r.cc]||(f[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),d&&d.textCodec===wh?this._parseIMSC1(r,n):this._parseVTTs(e)}}else this.hls.trigger(R.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})}_parseIMSC1(t,e){const r=this.hls;Cp(e,this.initPTS[t.cc],n=>{this._appendCues(n,t.level),r.trigger(R.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:t})},n=>{X.log(`Failed to parse IMSC1: ${n}`),r.trigger(R.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:n})})}_parseVTTs(t){var e;const{frag:r,payload:n}=t,{initPTS:o,unparsedVttFrags:l}=this,d=o.length-1;if(!o[r.cc]&&d===-1){l.push(t);return}const f=this.hls,p=(e=r.initSegment)!=null&&e.data?fn(r.initSegment.data,new Uint8Array(n)):n;HE(p,this.initPTS[r.cc],this.vttCCs,r.cc,r.start,g=>{this._appendCues(g,r.level),f.trigger(R.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:r})},g=>{const v=g.message==="Missing initPTS for VTT MPEGTS";v?l.push(t):this._fallbackToIMSC1(r,n),X.log(`Failed to parse VTT cue: ${g}`),!(v&&d>r.cc)&&f.trigger(R.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:g})})}_fallbackToIMSC1(t,e){const r=this.tracks[t.level];r.textCodec||Cp(e,this.initPTS[t.cc],()=>{r.textCodec=wh,this._parseIMSC1(t,e)},()=>{r.textCodec="wvtt"})}_appendCues(t,e){const r=this.hls;if(this.config.renderTextTracksNatively){const n=this.textTracks[e];if(!n||n.mode==="disabled")return;t.forEach(o=>Lf(n,o))}else{const n=this.tracks[e];if(!n)return;const o=n.default?"default":"subtitles"+e;r.trigger(R.CUES_PARSED,{type:"subtitles",cues:t,track:o})}}onFragDecrypted(t,e){const{frag:r}=e;r.type===Jt.SUBTITLE&&this.onFragLoaded(R.FRAG_LOADED,e)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(t,e){const{cea608Parser1:r,cea608Parser2:n}=this;if(!this.enabled||!(r&&n))return;const{frag:o,samples:l}=e;if(!(o.type===Jt.MAIN&&this.closedCaptionsForLevel(o)==="NONE"))for(let d=0;d<l.length;d++){const f=l[d].bytes;if(f){const p=this.extractCea608Data(f);r.addData(l[d].pts,p[0]),n.addData(l[d].pts,p[1])}}}onBufferFlushing(t,{startOffset:e,endOffset:r,endOffsetSubtitles:n,type:o}){const{media:l}=this;if(!(!l||l.currentTime<r)){if(!o||o==="video"){const{captionsTracks:d}=this;Object.keys(d).forEach(f=>Kc(d[f],e,r))}if(this.config.renderTextTracksNatively&&e===0&&n!==void 0){const{textTracks:d}=this;Object.keys(d).forEach(f=>Kc(d[f],e,n))}}}extractCea608Data(t){const e=[[],[]],r=t[0]&31;let n=2;for(let o=0;o<r;o++){const l=t[n++],d=127&t[n++],f=127&t[n++];if(!(d===0&&f===0)&&4&l){const p=3&l;(p===0||p===1)&&(e[p].push(d),e[p].push(f))}}return e}}function XE(i,t){return!!i&&i.label===t.name&&!(i.textTrack1||i.textTrack2)}function ZE(i,t,e,r){return Math.min(t,r)-Math.max(i,e)}function Pp(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}class Lh{constructor(t){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=t,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}setStreamController(t){this.streamController=t}destroy(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){const{hls:t}=this;t.on(R.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.on(R.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(R.MANIFEST_PARSED,this.onManifestParsed,this),t.on(R.BUFFER_CODECS,this.onBufferCodecs,this),t.on(R.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:t}=this;t.off(R.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.off(R.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(R.MANIFEST_PARSED,this.onManifestParsed,this),t.off(R.BUFFER_CODECS,this.onBufferCodecs,this),t.off(R.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(t,e){const r=this.hls.levels[e.droppedLevel];this.isLevelAllowed(r)&&this.restrictedLevels.push({bitrate:r.bitrate,height:r.height,width:r.width})}onMediaAttaching(t,e){this.media=e.media instanceof HTMLVideoElement?e.media:null,this.clientRect=null}onManifestParsed(t,e){const r=this.hls;this.restrictedLevels=[],this.firstLevel=e.firstLevel,r.config.capLevelToPlayerSize&&e.video&&this.startCapping()}onBufferCodecs(t,e){this.hls.config.capLevelToPlayerSize&&e.video&&this.startCapping()}onMediaDetaching(){this.stopCapping()}detectPlayerSize(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){const t=this.hls.levels;if(t.length){const e=this.hls;e.autoLevelCapping=this.getMaxLevel(t.length-1),e.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=e.autoLevelCapping}}}getMaxLevel(t){const e=this.hls.levels;if(!e.length)return-1;const r=e.filter((n,o)=>this.isLevelAllowed(n)&&o<=t);return this.clientRect=null,Lh.getMaxLevelByMediaSize(r,this.mediaWidth,this.mediaHeight)}startCapping(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())}stopCapping(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)}getDimensions(){if(this.clientRect)return this.clientRect;const t=this.media,e={width:0,height:0};if(t){const r=t.getBoundingClientRect();e.width=r.width,e.height=r.height,!e.width&&!e.height&&(e.width=r.right-r.left||t.width||0,e.height=r.bottom-r.top||t.height||0)}return this.clientRect=e,e}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let t=1;if(!this.hls.config.ignoreDevicePixelRatio)try{t=self.devicePixelRatio}catch{}return t}isLevelAllowed(t){return!this.restrictedLevels.some(e=>t.bitrate===e.bitrate&&t.width===e.width&&t.height===e.height)}static getMaxLevelByMediaSize(t,e,r){if(!(t!=null&&t.length))return-1;const n=(l,d)=>d?l.width!==d.width||l.height!==d.height:!0;let o=t.length-1;for(let l=0;l<t.length;l+=1){const d=t[l];if((d.width>=e||d.height>=r)&&n(d,t[l+1])){o=l;break}}return o}}class qE{constructor(t){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=t,this.registerListeners()}setStreamController(t){this.streamController=t}registerListeners(){this.hls.on(R.MEDIA_ATTACHING,this.onMediaAttaching,this)}unregisterListeners(){this.hls.off(R.MEDIA_ATTACHING,this.onMediaAttaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(t,e){const r=this.hls.config;if(r.capLevelOnFPSDrop){const n=e.media instanceof self.HTMLVideoElement?e.media:null;this.media=n,n&&typeof n.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}}checkFPS(t,e,r){const n=performance.now();if(e){if(this.lastTime){const o=n-this.lastTime,l=r-this.lastDroppedFrames,d=e-this.lastDecodedFrames,f=1e3*l/o,p=this.hls;if(p.trigger(R.FPS_DROP,{currentDropped:l,currentDecoded:d,totalDroppedFrames:r}),f>0&&l>p.config.fpsDroppedMonitoringThreshold*d){let g=p.currentLevel;X.warn("drop FPS ratio greater than max allowed value for currentLevel: "+g),g>0&&(p.autoLevelCapping===-1||p.autoLevelCapping>=g)&&(g=g-1,p.trigger(R.FPS_DROP_LEVEL_CAPPING,{level:g,droppedLevel:p.currentLevel}),p.autoLevelCapping=g,this.streamController.nextLevelSwitch())}}this.lastTime=n,this.lastDroppedFrames=r,this.lastDecodedFrames=e}}checkFPSInterval(){const t=this.media;if(t)if(this.isVideoPlaybackQualityAvailable){const e=t.getVideoPlaybackQuality();this.checkFPS(t,e.totalVideoFrames,e.droppedVideoFrames)}else this.checkFPS(t,t.webkitDecodedFrameCount,t.webkitDroppedFrameCount)}}const ol="[eme]";class Mn{constructor(t){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=Mn.CDMCleanupPromise?[Mn.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=X.debug.bind(X,ol),this.log=X.log.bind(X,ol),this.warn=X.warn.bind(X,ol),this.error=X.error.bind(X,ol),this.hls=t,this.config=t.config,this.registerListeners()}destroy(){this.unregisterListeners(),this.onMediaDetached();const t=this.config;t.requestMediaKeySystemAccessFunc=null,t.licenseXhrSetup=t.licenseResponseCallback=void 0,t.drmSystems=t.drmSystemOptions={},this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null,this.config=null}registerListeners(){this.hls.on(R.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(R.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(R.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(R.MANIFEST_LOADED,this.onManifestLoaded,this)}unregisterListeners(){this.hls.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(R.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(R.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(R.MANIFEST_LOADED,this.onManifestLoaded,this)}getLicenseServerUrl(t){const{drmSystems:e,widevineLicenseUrl:r}=this.config,n=e[t];if(n)return n.licenseUrl;if(t===er.WIDEVINE&&r)return r;throw new Error(`no license server URL configured for key-system "${t}"`)}getServerCertificateUrl(t){const{drmSystems:e}=this.config,r=e[t];if(r)return r.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${t}"]`)}attemptKeySystemAccess(t){const e=this.hls.levels,r=(l,d,f)=>!!l&&f.indexOf(l)===d,n=e.map(l=>l.audioCodec).filter(r),o=e.map(l=>l.videoCodec).filter(r);return n.length+o.length===0&&o.push("avc1.42e01e"),new Promise((l,d)=>{const f=p=>{const g=p.shift();this.getMediaKeysPromise(g,n,o).then(v=>l({keySystem:g,mediaKeys:v})).catch(v=>{p.length?f(p):v instanceof gi?d(v):d(new gi({type:Qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_NO_ACCESS,error:v,fatal:!0},v.message))})};f(t)})}requestMediaKeySystemAccess(t,e){const{requestMediaKeySystemAccessFunc:r}=this.config;if(typeof r!="function"){let n=`Configured requestMediaKeySystemAccess is not a function ${r}`;return tf===null&&self.location.protocol==="http:"&&(n=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(n))}return r(t,e)}getMediaKeysPromise(t,e,r){const n=db(t,e,r,this.config.drmSystemOptions),o=this.keySystemAccessPromises[t];let l=o==null?void 0:o.keySystemAccess;if(!l){this.log(`Requesting encrypted media "${t}" key-system access with config: ${JSON.stringify(n)}`),l=this.requestMediaKeySystemAccess(t,n);const d=this.keySystemAccessPromises[t]={keySystemAccess:l};return l.catch(f=>{this.log(`Failed to obtain access to key-system "${t}": ${f}`)}),l.then(f=>{this.log(`Access for key-system "${f.keySystem}" obtained`);const p=this.fetchServerCertificate(t);return this.log(`Create media-keys for "${t}"`),d.mediaKeys=f.createMediaKeys().then(g=>(this.log(`Media-keys created for "${t}"`),p.then(v=>v?this.setMediaKeysServerCertificate(g,t,v):g))),d.mediaKeys.catch(g=>{this.error(`Failed to create media-keys for "${t}"}: ${g}`)}),d.mediaKeys})}return l.then(()=>o.mediaKeys)}createMediaKeySessionContext({decryptdata:t,keySystem:e,mediaKeys:r}){this.log(`Creating key-system session "${e}" keyId: ${Ui.hexDump(t.keyId||[])}`);const n=r.createSession(),o={decryptdata:t,keySystem:e,mediaKeys:r,mediaKeysSession:n,keyStatus:"status-pending"};return this.mediaKeySessions.push(o),o}renewKeySession(t){const e=t.decryptdata;if(e.pssh){const r=this.createMediaKeySessionContext(t),n=this.getKeyIdString(e),o="cenc";this.keyIdToKeySessionPromise[n]=this.generateRequestWithPreferredKeySession(r,o,e.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(t)}getKeyIdString(t){if(!t)throw new Error("Could not read keyId of undefined decryptdata");if(t.keyId===null)throw new Error("keyId is null");return Ui.hexDump(t.keyId)}updateKeySession(t,e){var r;const n=t.mediaKeysSession;return this.log(`Updating key-session "${n.sessionId}" for keyID ${Ui.hexDump(((r=t.decryptdata)==null?void 0:r.keyId)||[])}
208
- } (data length: ${e&&e.byteLength})`),n.update(e)}selectKeySystemFormat(t){const e=Object.keys(t.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${t.sn} ${t.type}: ${t.level}) key formats ${e.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(e)),this.keyFormatPromise}getKeyFormatPromise(t){return new Promise((e,r)=>{const n=Uc(this.config),o=t.map(q0).filter(l=>!!l&&n.indexOf(l)!==-1);return this.getKeySystemSelectionPromise(o).then(({keySystem:l})=>{const d=J0(l);d?e(d):r(new Error(`Unable to find format for key-system "${l}"`))}).catch(r)})}loadKey(t){const e=t.keyInfo.decryptdata,r=this.getKeyIdString(e),n=`(keyId: ${r} format: "${e.keyFormat}" method: ${e.method} uri: ${e.uri})`;this.log(`Starting session for key ${n}`);let o=this.keyIdToKeySessionPromise[r];return o||(o=this.keyIdToKeySessionPromise[r]=this.getKeySystemForKeyPromise(e).then(({keySystem:l,mediaKeys:d})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${t.frag.sn} ${t.frag.type}: ${t.frag.level} using key ${n}`),this.attemptSetMediaKeys(l,d).then(()=>{this.throwIfDestroyed();const f=this.createMediaKeySessionContext({keySystem:l,mediaKeys:d,decryptdata:e}),p="cenc";return this.generateRequestWithPreferredKeySession(f,p,e.pssh,"playlist-key")}))),o.catch(l=>this.handleError(l))),o}throwIfDestroyed(t="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(t){this.hls&&(this.error(t.message),t instanceof gi?this.hls.trigger(R.ERROR,t.data):this.hls.trigger(R.ERROR,{type:Qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_NO_KEYS,error:t,fatal:!0}))}getKeySystemForKeyPromise(t){const e=this.getKeyIdString(t),r=this.keyIdToKeySessionPromise[e];if(!r){const n=q0(t.keyFormat),o=n?[n]:Uc(this.config);return this.attemptKeySystemAccess(o)}return r}getKeySystemSelectionPromise(t){if(t.length||(t=Uc(this.config)),t.length===0)throw new gi({type:Qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${JSON.stringify({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(t)}_onMediaEncrypted(t){const{initDataType:e,initData:r}=t;if(this.debug(`"${t.type}" event: init data type: "${e}"`),r===null)return;let n,o;if(e==="sinf"&&this.config.drmSystems[er.FAIRPLAY]){const g=_r(new Uint8Array(r));try{const v=Fc(JSON.parse(g).sinf),E=cf(new Uint8Array(v));if(!E)return;n=E.subarray(8,24),o=er.FAIRPLAY}catch{this.warn('Failed to parse sinf "encrypted" event message initData');return}}else{const g=$b(r);if(g===null)return;g.version===0&&g.systemId===Q0.WIDEVINE&&g.data&&(n=g.data.subarray(8,24)),o=hb(g.systemId)}if(!o||!n)return;const l=Ui.hexDump(n),{keyIdToKeySessionPromise:d,mediaKeySessions:f}=this;let p=d[l];for(let g=0;g<f.length;g++){const v=f[g],E=v.decryptdata;if(E.pssh||!E.keyId)continue;const A=Ui.hexDump(E.keyId);if(l===A||E.uri.replace(/-/g,"").indexOf(l)!==-1){p=d[A],delete d[A],E.pssh=new Uint8Array(r),E.keyId=n,p=d[l]=p.then(()=>this.generateRequestWithPreferredKeySession(v,e,r,"encrypted-event-key-match"));break}}p||(p=d[l]=this.getKeySystemSelectionPromise([o]).then(({keySystem:g,mediaKeys:v})=>{var E;this.throwIfDestroyed();const A=new Oa("ISO-23001-7",l,(E=J0(g))!=null?E:"");return A.pssh=new Uint8Array(r),A.keyId=n,this.attemptSetMediaKeys(g,v).then(()=>{this.throwIfDestroyed();const T=this.createMediaKeySessionContext({decryptdata:A,keySystem:g,mediaKeys:v});return this.generateRequestWithPreferredKeySession(T,e,r,"encrypted-event-no-match")})})),p.catch(g=>this.handleError(g))}_onWaitingForKey(t){this.log(`"${t.type}" event`)}attemptSetMediaKeys(t,e){const r=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${t}"`);const n=Promise.all(r).then(()=>{if(!this.media)throw new Error("Attempted to set mediaKeys without media element attached");return this.media.setMediaKeys(e)});return this.setMediaKeysQueue.push(n),n.then(()=>{this.log(`Media-keys set for "${t}"`),r.push(n),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(o=>r.indexOf(o)===-1)})}generateRequestWithPreferredKeySession(t,e,r,n){var o,l;const d=(o=this.config.drmSystems)==null||(l=o[t.keySystem])==null?void 0:l.generateRequest;if(d)try{const E=d.call(this.hls,e,r,t);if(!E)throw new Error("Invalid response from configured generateRequest filter");e=E.initDataType,r=t.decryptdata.pssh=E.initData?new Uint8Array(E.initData):null}catch(E){var f;if(this.warn(E.message),(f=this.hls)!=null&&f.config.debug)throw E}if(r===null)return this.log(`Skipping key-session request for "${n}" (no initData)`),Promise.resolve(t);const p=this.getKeyIdString(t.decryptdata);this.log(`Generating key-session request for "${n}": ${p} (init data type: ${e} length: ${r?r.byteLength:null})`);const g=new ph;t.mediaKeysSession.onmessage=E=>{const A=t.mediaKeysSession;if(!A){g.emit("error",new Error("invalid state"));return}const{messageType:T,message:w}=E;this.log(`"${T}" message event for session "${A.sessionId}" message size: ${w.byteLength}`),T==="license-request"||T==="license-renewal"?this.renewLicense(t,w).catch(C=>{this.handleError(C),g.emit("error",C)}):T==="license-release"?t.keySystem===er.FAIRPLAY&&(this.updateKeySession(t,Z0("acknowledged")),this.removeSession(t)):this.warn(`unhandled media key message type "${T}"`)},t.mediaKeysSession.onkeystatuseschange=E=>{if(!t.mediaKeysSession){g.emit("error",new Error("invalid state"));return}this.onKeyStatusChange(t);const A=t.keyStatus;g.emit("keyStatus",A),A==="expired"&&(this.warn(`${t.keySystem} expired for key ${p}`),this.renewKeySession(t))};const v=new Promise((E,A)=>{g.on("error",A),g.on("keyStatus",T=>{T.startsWith("usable")?E():T==="output-restricted"?A(new gi({type:Qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):T==="internal-error"?A(new gi({type:Qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},`key status changed to "${T}"`)):T==="expired"?A(new Error("key expired while generating request")):this.warn(`unhandled key status change "${T}"`)})});return t.mediaKeysSession.generateRequest(e,r).then(()=>{var E;this.log(`Request generated for key-session "${(E=t.mediaKeysSession)==null?void 0:E.sessionId}" keyId: ${p}`)}).catch(E=>{throw new gi({type:Qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_NO_SESSION,error:E,fatal:!1},`Error generating key-session request: ${E}`)}).then(()=>v).catch(E=>{throw g.removeAllListeners(),this.removeSession(t),E}).then(()=>(g.removeAllListeners(),t))}onKeyStatusChange(t){t.mediaKeysSession.keyStatuses.forEach((e,r)=>{this.log(`key status change "${e}" for keyStatuses keyId: ${Ui.hexDump("buffer"in r?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):new Uint8Array(r))} session keyId: ${Ui.hexDump(new Uint8Array(t.decryptdata.keyId||[]))} uri: ${t.decryptdata.uri}`),t.keyStatus=e})}fetchServerCertificate(t){const e=this.config,r=e.loader,n=new r(e),o=this.getServerCertificateUrl(t);return o?(this.log(`Fetching serverCertificate for "${t}"`),new Promise((l,d)=>{const f={responseType:"arraybuffer",url:o},p=e.certLoadPolicy.default,g={loadPolicy:p,timeout:p.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},v={onSuccess:(E,A,T,w)=>{l(E.data)},onError:(E,A,T,w)=>{d(new gi({type:Qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:T,response:zr({url:f.url,data:void 0},E)},`"${t}" certificate request failed (${o}). Status: ${E.code} (${E.text})`))},onTimeout:(E,A,T)=>{d(new gi({type:Qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:T,response:{url:f.url,data:void 0}},`"${t}" certificate request timed out (${o})`))},onAbort:(E,A,T)=>{d(new Error("aborted"))}};n.load(f,g,v)})):Promise.resolve()}setMediaKeysServerCertificate(t,e,r){return new Promise((n,o)=>{t.setServerCertificate(r).then(l=>{this.log(`setServerCertificate ${l?"success":"not supported by CDM"} (${r==null?void 0:r.byteLength}) on "${e}"`),n(t)}).catch(l=>{o(new gi({type:Qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:l,fatal:!0},l.message))})})}renewLicense(t,e){return this.requestLicense(t,new Uint8Array(e)).then(r=>this.updateKeySession(t,new Uint8Array(r)).catch(n=>{throw new gi({type:Qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:n,fatal:!0},n.message)}))}setupLicenseXHR(t,e,r,n){const o=this.config.licenseXhrSetup;return o?Promise.resolve().then(()=>{if(!r.decryptdata)throw new Error("Key removed");return o.call(this.hls,t,e,r,n)}).catch(l=>{if(!r.decryptdata)throw l;return t.open("POST",e,!0),o.call(this.hls,t,e,r,n)}).then(l=>(t.readyState||t.open("POST",e,!0),{xhr:t,licenseChallenge:l||n})):(t.open("POST",e,!0),Promise.resolve({xhr:t,licenseChallenge:n}))}requestLicense(t,e){const r=this.config.keyLoadPolicy.default;return new Promise((n,o)=>{const l=this.getLicenseServerUrl(t.keySystem);this.log(`Sending license request to URL: ${l}`);const d=new XMLHttpRequest;d.responseType="arraybuffer",d.onreadystatechange=()=>{if(!this.hls||!t.mediaKeysSession)return o(new Error("invalid state"));if(d.readyState===4)if(d.status===200){this._requestLicenseFailureCount=0;let f=d.response;this.log(`License received ${f instanceof ArrayBuffer?f.byteLength:f}`);const p=this.config.licenseResponseCallback;if(p)try{f=p.call(this.hls,d,l,t)}catch(g){this.error(g)}n(f)}else{const f=r.errorRetry,p=f?f.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>p||d.status>=400&&d.status<500)o(new gi({type:Qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:d,response:{url:l,data:void 0,code:d.status,text:d.statusText}},`License Request XHR failed (${l}). Status: ${d.status} (${d.statusText})`));else{const g=p-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${g} attempts left`),this.requestLicense(t,e).then(n,o)}}},t.licenseXhr&&t.licenseXhr.readyState!==XMLHttpRequest.DONE&&t.licenseXhr.abort(),t.licenseXhr=d,this.setupLicenseXHR(d,l,t,e).then(({xhr:f,licenseChallenge:p})=>{f.send(p)})})}onMediaAttached(t,e){if(!this.config.emeEnabled)return;const r=e.media;this.media=r,r.addEventListener("encrypted",this.onMediaEncrypted),r.addEventListener("waitingforkey",this.onWaitingForKey)}onMediaDetached(){const t=this.media,e=this.mediaKeySessions;t&&(t.removeEventListener("encrypted",this.onMediaEncrypted),t.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},Oa.clearKeyUriToKeyIdMap();const r=e.length;Mn.CDMCleanupPromise=Promise.all(e.map(n=>this.removeSession(n)).concat(t==null?void 0:t.setMediaKeys(null).catch(n=>{this.log(`Could not clear media keys: ${n}. media.src: ${t==null?void 0:t.src}`)}))).then(()=>{r&&(this.log("finished closing key sessions and clearing media keys"),e.length=0)}).catch(n=>{this.log(`Could not close sessions and clear media keys: ${n}. media.src: ${t==null?void 0:t.src}`)})}onManifestLoading(){this.keyFormatPromise=null}onManifestLoaded(t,{sessionKeys:e}){if(!(!e||!this.config.emeEnabled)&&!this.keyFormatPromise){const r=e.reduce((n,o)=>(n.indexOf(o.keyFormat)===-1&&n.push(o.keyFormat),n),[]);this.log(`Selecting key-system from session-keys ${r.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(r)}}removeSession(t){const{mediaKeysSession:e,licenseXhr:r}=t;if(e){this.log(`Remove licenses and keys and close session ${e.sessionId}`),e.onmessage=null,e.onkeystatuseschange=null,r&&r.readyState!==XMLHttpRequest.DONE&&r.abort(),t.mediaKeysSession=t.decryptdata=t.licenseXhr=void 0;const n=this.mediaKeySessions.indexOf(t);return n>-1&&this.mediaKeySessions.splice(n,1),e.remove().catch(o=>{this.log(`Could not remove session: ${o}`)}).then(()=>e.close()).catch(o=>{this.log(`Could not close session: ${o}`)})}}}Mn.CDMCleanupPromise=void 0;class gi extends Error{constructor(t,e){super(e),this.data=void 0,t.error||(t.error=new Error(e)),this.data=t,t.err=t.error}}const QE=1;var Zr={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"};const JE="h";class Is{constructor(t){this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=n=>{try{this.apply(n,{ot:Zr.MANIFEST,su:!this.initialized})}catch(o){X.warn("Could not generate manifest CMCD data.",o)}},this.applyFragmentData=n=>{try{const o=n.frag,l=this.hls.levels[o.level],d=this.getObjectType(o),f={d:o.duration*1e3,ot:d};(d===Zr.VIDEO||d===Zr.AUDIO||d==Zr.MUXED)&&(f.br=l.bitrate/1e3,f.tb=this.getTopBandwidth(d)/1e3,f.bl=this.getBufferLength(d)),this.apply(n,f)}catch(o){X.warn("Could not generate segment CMCD data.",o)}},this.hls=t;const e=this.config=t.config,{cmcd:r}=e;r!=null&&(e.pLoader=this.createPlaylistLoader(),e.fLoader=this.createFragmentLoader(),this.sid=r.sessionId||Is.uuid(),this.cid=r.contentId,this.useHeaders=r.useHeaders===!0,this.registerListeners())}registerListeners(){const t=this.hls;t.on(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(R.MEDIA_DETACHED,this.onMediaDetached,this),t.on(R.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const t=this.hls;t.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(R.MEDIA_DETACHED,this.onMediaDetached,this),t.off(R.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null}onMediaAttached(t,e){this.media=e.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}onMediaDetached(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}onBufferCreated(t,e){var r,n;this.audioBuffer=(r=e.tracks.audio)==null?void 0:r.buffer,this.videoBuffer=(n=e.tracks.video)==null?void 0:n.buffer}createData(){var t;return{v:QE,sf:JE,sid:this.sid,cid:this.cid,pr:(t=this.media)==null?void 0:t.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(t,e={}){dr(e,this.createData());const r=e.ot===Zr.INIT||e.ot===Zr.VIDEO||e.ot===Zr.MUXED;if(this.starved&&r&&(e.bs=!0,e.su=!0,this.starved=!1),e.su==null&&(e.su=this.buffering),this.useHeaders){const n=Is.toHeaders(e);if(!Object.keys(n).length)return;t.headers||(t.headers={}),dr(t.headers,n)}else{const n=Is.toQuery(e);if(!n)return;t.url=Is.appendQueryToUri(t.url,n)}}getObjectType(t){const{type:e}=t;if(e==="subtitle")return Zr.TIMED_TEXT;if(t.sn==="initSegment")return Zr.INIT;if(e==="audio")return Zr.AUDIO;if(e==="main")return this.hls.audioTracks.length?Zr.VIDEO:Zr.MUXED}getTopBandwidth(t){let e=0,r;const n=this.hls;if(t===Zr.AUDIO)r=n.audioTracks;else{const o=n.maxAutoLevel,l=o>-1?o+1:n.levels.length;r=n.levels.slice(0,l)}for(const o of r)o.bitrate>e&&(e=o.bitrate);return e>0?e:NaN}getBufferLength(t){const e=this.hls.media,r=t===Zr.AUDIO?this.audioBuffer:this.videoBuffer;return!r||!e?NaN:Ve.bufferInfo(r,e.currentTime,this.config.maxBufferHole).len*1e3}createPlaylistLoader(){const{pLoader:t}=this.config,e=this.applyPlaylistData,r=t||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new r(n)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(n,o,l){e(n),this.loader.load(n,o,l)}}}createFragmentLoader(){const{fLoader:t}=this.config,e=this.applyFragmentData,r=t||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new r(n)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(n,o,l){e(n),this.loader.load(n,o,l)}}}static uuid(){const t=URL.createObjectURL(new Blob),e=t.toString();return URL.revokeObjectURL(t),e.slice(e.lastIndexOf("/")+1)}static serialize(t){const e=[],r=f=>!Number.isNaN(f)&&f!=null&&f!==""&&f!==!1,n=f=>Math.round(f),o=f=>n(f/100)*100,l={br:n,d:n,bl:o,dl:o,mtp:o,nor:f=>encodeURIComponent(f),rtp:o,tb:n},d=Object.keys(t||{}).sort();for(const f of d){let p=t[f];if(!r(p)||f==="v"&&p===1||f=="pr"&&p===1)continue;const g=l[f];g&&(p=g(p));const v=typeof p;let E;f==="ot"||f==="sf"||f==="st"?E=`${f}=${p}`:v==="boolean"?E=f:v==="number"?E=`${f}=${p}`:E=`${f}=${JSON.stringify(p)}`,e.push(E)}return e.join(",")}static toHeaders(t){const e=Object.keys(t),r={},n=["Object","Request","Session","Status"],o=[{},{},{},{}],l={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3};for(const d of e){const f=l[d]!=null?l[d]:1;o[f][d]=t[d]}for(let d=0;d<o.length;d++){const f=Is.serialize(o[d]);f&&(r[`CMCD-${n[d]}`]=f)}return r}static toQuery(t){return`CMCD=${encodeURIComponent(Is.serialize(t))}`}static appendQueryToUri(t,e){if(!e)return t;const r=t.includes("?")?"&":"?";return`${t}${r}${e}`}}const tA=3e5;class eA{constructor(t){this.hls=void 0,this.log=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this.pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=t,this.log=X.log.bind(X,"[content-steering]:"),this.registerListeners()}registerListeners(){const t=this.hls;t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(R.MANIFEST_PARSED,this.onManifestParsed,this),t.on(R.ERROR,this.onError,this)}unregisterListeners(){const t=this.hls;t&&(t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(R.MANIFEST_PARSED,this.onManifestParsed,this),t.off(R.ERROR,this.onError,this))}startLoad(){if(this.started=!0,self.clearTimeout(this.reloadTimer),this.enabled&&this.uri)if(this.updated){const t=Math.max(this.timeToLoad*1e3-(performance.now()-this.updated),0);this.scheduleRefresh(this.uri,t)}else this.loadSteeringManifest(this.uri)}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),self.clearTimeout(this.reloadTimer)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(t){const e=this.levels;e&&(this.levels=e.filter(r=>r!==t))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(t,e){const{contentSteering:r}=e;r!==null&&(this.pathwayId=r.pathwayId,this.uri=r.uri,this.started&&this.startLoad())}onManifestParsed(t,e){this.audioTracks=e.audioTracks,this.subtitleTracks=e.subtitleTracks}onError(t,e){const{errorAction:r}=e;if((r==null?void 0:r.action)===Ir.SendAlternateToPenaltyBox&&r.flags===fi.MoveAllAlternatesMatchingHost){let n=this.pathwayPriority;const o=this.pathwayId;this.penalizedPathways[o]||(this.penalizedPathways[o]=performance.now()),!n&&this.levels&&(n=this.levels.reduce((l,d)=>(l.indexOf(d.pathwayId)===-1&&l.push(d.pathwayId),l),[])),n&&n.length>1&&(this.updatePathwayPriority(n),r.resolved=this.pathwayId!==o)}}filterParsedLevels(t){this.levels=t;let e=this.getLevelsForPathway(this.pathwayId);if(e.length===0){const r=t[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${r}"`),e=this.getLevelsForPathway(r),this.pathwayId=r}return e.length!==t.length?(this.log(`Found ${e.length}/${t.length} levels in Pathway "${this.pathwayId}"`),e):t}getLevelsForPathway(t){return this.levels===null?[]:this.levels.filter(e=>t===e.pathwayId)}updatePathwayPriority(t){this.pathwayPriority=t;let e;const r=this.penalizedPathways,n=performance.now();Object.keys(r).forEach(o=>{n-r[o]>tA&&delete r[o]});for(let o=0;o<t.length;o++){const l=t[o];if(r[l])continue;if(l===this.pathwayId)return;const d=this.hls.nextLoadLevel,f=this.hls.levels[d];if(e=this.getLevelsForPathway(l),e.length>0){this.log(`Setting Pathway to "${l}"`),this.pathwayId=l,this.hls.trigger(R.LEVELS_UPDATED,{levels:e});const p=this.hls.levels[d];f&&p&&this.levels&&(p.attrs["STABLE-VARIANT-ID"]!==f.attrs["STABLE-VARIANT-ID"]&&p.bitrate!==f.bitrate&&this.log(`Unstable Pathways change from bitrate ${f.bitrate} to ${p.bitrate}`),this.hls.nextLoadLevel=d);break}}}clonePathways(t){const e=this.levels;if(!e)return;const r={},n={};t.forEach(o=>{const{ID:l,"BASE-ID":d,"URI-REPLACEMENT":f}=o;if(e.some(g=>g.pathwayId===l))return;const p=this.getLevelsForPathway(d).map(g=>{const v=dr({},g);v.details=void 0,v.url=$p(g.uri,g.attrs["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",f);const E=new tr(g.attrs);E["PATHWAY-ID"]=l;const A=E.AUDIO&&`${E.AUDIO}_clone_${l}`,T=E.SUBTITLES&&`${E.SUBTITLES}_clone_${l}`;A&&(r[E.AUDIO]=A,E.AUDIO=A),T&&(n[E.SUBTITLES]=T,E.SUBTITLES=T),v.attrs=E;const w=new Ma(v);return qo(w,"audio",A),qo(w,"text",T),w});e.push(...p),Op(this.audioTracks,r,f,l),Op(this.subtitleTracks,n,f,l)})}loadSteeringManifest(t){const e=this.hls.config,r=e.loader;this.loader&&this.loader.destroy(),this.loader=new r(e);let n;try{n=new self.URL(t)}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest URI: ${t}`);return}if(n.protocol!=="data:"){const g=(this.hls.bandwidthEstimate||e.abrEwmaDefaultEstimate)|0;n.searchParams.set("_HLS_pathway",this.pathwayId),n.searchParams.set("_HLS_throughput",""+g)}const o={responseType:"json",url:n.href},l=e.steeringManifestLoadPolicy.default,d=l.errorRetry||l.timeoutRetry||{},f={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:d.maxNumRetry||0,retryDelay:d.retryDelayMs||0,maxRetryDelay:d.maxRetryDelayMs||0},p={onSuccess:(g,v,E,A)=>{this.log(`Loaded steering manifest: "${n}"`);const T=g.data;if(T.VERSION!==1){this.log(`Steering VERSION ${T.VERSION} not supported!`);return}this.updated=performance.now(),this.timeToLoad=T.TTL;const{"RELOAD-URI":w,"PATHWAY-CLONES":C,"PATHWAY-PRIORITY":D}=T;if(w)try{this.uri=new self.URL(w,n).href}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${w}`);return}this.scheduleRefresh(this.uri||E.url),C&&this.clonePathways(C),D&&this.updatePathwayPriority(D)},onError:(g,v,E,A)=>{if(this.log(`Error loading steering manifest: ${g.code} ${g.text} (${v.url})`),this.stopLoad(),g.code===410){this.enabled=!1,this.log(`Steering manifest ${v.url} no longer available`);return}let T=this.timeToLoad*1e3;if(g.code===429){const w=this.loader;if(typeof(w==null?void 0:w.getResponseHeader)=="function"){const C=w.getResponseHeader("Retry-After");C&&(T=parseFloat(C)*1e3)}this.log(`Steering manifest ${v.url} rate limited`);return}this.scheduleRefresh(this.uri||v.url,T)},onTimeout:(g,v,E)=>{this.log(`Timeout loading steering manifest (${v.url})`),this.scheduleRefresh(this.uri||v.url)}};this.log(`Requesting steering manifest: ${n}`),this.loader.load(o,f,p)}scheduleRefresh(t,e=this.timeToLoad*1e3){self.clearTimeout(this.reloadTimer),this.reloadTimer=self.setTimeout(()=>{this.loadSteeringManifest(t)},e)}}function Op(i,t,e,r){i&&Object.keys(t).forEach(n=>{const o=i.filter(l=>l.groupId===n).map(l=>{const d=dr({},l);return d.details=void 0,d.attrs=new tr(d.attrs),d.url=d.attrs.URI=$p(l.url,l.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",e),d.groupId=d.attrs["GROUP-ID"]=t[n],d.attrs["PATHWAY-ID"]=r,d});i.push(...o)})}function $p(i,t,e,r){const{HOST:n,PARAMS:o,[e]:l}=r;let d;t&&(d=l==null?void 0:l[t],d&&(i=d));const f=new self.URL(i);return n&&!d&&(f.host=n),o&&Object.keys(o).sort().forEach(p=>{p&&f.searchParams.set(p,o[p])}),f.href}const rA=/^age:\s*[\d.]+\s*$/im;class Mp{constructor(t){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=t&&t.xhrSetup||null,this.stats=new Ho,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null}abortInternal(){const t=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),t&&(t.onreadystatechange=null,t.onprogress=null,t.readyState!==4&&(this.stats.aborted=!0,t.abort()))}abort(){var t;this.abortInternal(),(t=this.callbacks)!=null&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(t,e,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=t,this.config=e,this.callbacks=r,this.loadInternal()}loadInternal(){const{config:t,context:e}=this;if(!t)return;const r=this.loader=new self.XMLHttpRequest,n=this.stats;n.loading.first=0,n.loaded=0,n.aborted=!1;const o=this.xhrSetup;o?Promise.resolve().then(()=>{if(!this.stats.aborted)return o(r,e.url)}).catch(l=>(r.open("GET",e.url,!0),o(r,e.url))).then(()=>{this.stats.aborted||this.openAndSendXhr(r,e,t)}).catch(l=>{this.callbacks.onError({code:r.status,text:l.message},e,r,n)}):this.openAndSendXhr(r,e,t)}openAndSendXhr(t,e,r){t.readyState||t.open("GET",e.url,!0);const n=this.context.headers,{maxTimeToFirstByteMs:o,maxLoadTimeMs:l}=r.loadPolicy;if(n)for(const d in n)t.setRequestHeader(d,n[d]);e.rangeEnd&&t.setRequestHeader("Range","bytes="+e.rangeStart+"-"+(e.rangeEnd-1)),t.onreadystatechange=this.readystatechange.bind(this),t.onprogress=this.loadprogress.bind(this),t.responseType=e.responseType,self.clearTimeout(this.requestTimeout),r.timeout=o&&jt(o)?o:l,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.timeout),t.send()}readystatechange(){const{context:t,loader:e,stats:r}=this;if(!t||!e)return;const n=e.readyState,o=this.config;if(!r.aborted&&n>=2&&(r.loading.first===0&&(r.loading.first=Math.max(self.performance.now(),r.loading.start),o.timeout!==o.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),o.timeout=o.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),o.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start)))),n===4)){self.clearTimeout(this.requestTimeout),e.onreadystatechange=null,e.onprogress=null;const l=e.status,d=e.responseType!=="text";if(l>=200&&l<300&&(d&&e.response||e.responseText!==null)){r.loading.end=Math.max(self.performance.now(),r.loading.first);const f=d?e.response:e.responseText,p=e.responseType==="arraybuffer"?f.byteLength:f.length;if(r.loaded=r.total=p,r.bwEstimate=r.total*8e3/(r.loading.end-r.loading.first),!this.callbacks)return;const g=this.callbacks.onProgress;if(g&&g(r,t,f,e),!this.callbacks)return;const v={url:e.responseURL,data:f,code:l};this.callbacks.onSuccess(v,r,t,e)}else{const f=o.loadPolicy.errorRetry,p=r.retry;Zo(f,p,!1,l)?this.retry(f):(X.error(`${l} while loading ${t.url}`),this.callbacks.onError({code:l,text:e.statusText},t,e,r))}}}loadtimeout(){var t;const e=(t=this.config)==null?void 0:t.loadPolicy.timeoutRetry,r=this.stats.retry;if(Zo(e,r,!0))this.retry(e);else{X.warn(`timeout while loading ${this.context.url}`);const n=this.callbacks;n&&(this.abortInternal(),n.onTimeout(this.stats,this.context,this.loader))}}retry(t){const{context:e,stats:r}=this;this.retryDelay=Qc(t,r.retry),r.retry++,X.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${e.url}, retrying ${r.retry}/${t.maxNumRetry} in ${this.retryDelay}ms`),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)}loadprogress(t){const e=this.stats;e.loaded=t.loaded,t.lengthComputable&&(e.total=t.total)}getCacheAge(){let t=null;if(this.loader&&rA.test(this.loader.getAllResponseHeaders())){const e=this.loader.getResponseHeader("age");t=e?parseFloat(e):null}return t}getResponseHeader(t){return this.loader&&new RegExp(`^${t}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(t):null}}function iA(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}const sA=/(\d+)-(\d+)\/(\d+)/;class Np{constructor(t){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=t.fetchSetup||lA,this.controller=new self.AbortController,this.stats=new Ho}destroy(){this.loader=this.callbacks=null,this.abortInternal()}abortInternal(){const t=this.response;t!=null&&t.ok||(this.stats.aborted=!0,this.controller.abort())}abort(){var t;this.abortInternal(),(t=this.callbacks)!=null&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(t,e,r){const n=this.stats;if(n.loading.start)throw new Error("Loader can only be used once.");n.loading.start=self.performance.now();const o=nA(t,this.controller.signal),l=r.onProgress,d=t.responseType==="arraybuffer",f=d?"byteLength":"length",{maxTimeToFirstByteMs:p,maxLoadTimeMs:g}=e.loadPolicy;this.context=t,this.config=e,this.callbacks=r,this.request=this.fetchSetup(t,o),self.clearTimeout(this.requestTimeout),e.timeout=p&&jt(p)?p:g,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),r.onTimeout(n,t,this.response)},e.timeout),self.fetch(this.request).then(v=>{this.response=this.loader=v;const E=Math.max(self.performance.now(),n.loading.start);if(self.clearTimeout(this.requestTimeout),e.timeout=g,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),r.onTimeout(n,t,this.response)},g-(E-n.loading.start)),!v.ok){const{status:A,statusText:T}=v;throw new cA(T||"fetch, bad network response",A,v)}return n.loading.first=E,n.total=oA(v.headers)||n.total,l&&jt(e.highWaterMark)?this.loadProgressively(v,n,t,e.highWaterMark,l):d?v.arrayBuffer():t.responseType==="json"?v.json():v.text()}).then(v=>{const{response:E}=this;self.clearTimeout(this.requestTimeout),n.loading.end=Math.max(self.performance.now(),n.loading.first);const A=v[f];A&&(n.loaded=n.total=A);const T={url:E.url,data:v,code:E.status};l&&!jt(e.highWaterMark)&&l(n,t,v,E),r.onSuccess(T,n,t,E)}).catch(v=>{if(self.clearTimeout(this.requestTimeout),n.aborted)return;const E=v&&v.code||0,A=v?v.message:null;r.onError({code:E,text:A},t,v?v.details:null,n)})}getCacheAge(){let t=null;if(this.response){const e=this.response.headers.get("age");t=e?parseFloat(e):null}return t}getResponseHeader(t){return this.response?this.response.headers.get(t):null}loadProgressively(t,e,r,n=0,o){const l=new dp,d=t.body.getReader(),f=()=>d.read().then(p=>{if(p.done)return l.dataLength&&o(e,r,l.flush(),t),Promise.resolve(new ArrayBuffer(0));const g=p.value,v=g.length;return e.loaded+=v,v<n||l.dataLength?(l.push(g),l.dataLength>=n&&o(e,r,l.flush(),t)):o(e,r,g,t),f()}).catch(()=>Promise.reject());return f()}}function nA(i,t){const e={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(dr({},i.headers))};return i.rangeEnd&&e.headers.set("Range","bytes="+i.rangeStart+"-"+String(i.rangeEnd-1)),e}function aA(i){const t=sA.exec(i);if(t)return parseInt(t[2])-parseInt(t[1])+1}function oA(i){const t=i.get("Content-Range");if(t){const r=aA(t);if(jt(r))return r}const e=i.get("Content-Length");if(e)return parseInt(e)}function lA(i,t){return new self.Request(i.url,t)}class cA extends Error{constructor(t,e,r){super(t),this.code=void 0,this.details=void 0,this.code=e,this.details=r}}const hA=/\s/,dA={newCue(i,t,e,r){const n=[];let o,l,d,f,p;const g=self.VTTCue||self.TextTrackCue;for(let E=0;E<r.rows.length;E++)if(o=r.rows[E],d=!0,f=0,p="",!o.isEmpty()){var v;for(let w=0;w<o.chars.length;w++)hA.test(o.chars[w].uchar)&&d?f++:(p+=o.chars[w].uchar,d=!1);o.cueStartTime=t,t===e&&(e+=1e-4),f>=16?f--:f++;const A=Rp(p.trim()),T=kh(t,e,A);i!=null&&(v=i.cues)!=null&&v.getCueById(T)||(l=new g(t,e,A),l.id=T,l.line=E+1,l.align="left",l.position=10+Math.min(80,Math.floor(f*8/32)*10),n.push(l))}return i&&n.length&&(n.sort((E,A)=>E.line==="auto"||A.line==="auto"?0:E.line>8&&A.line>8?A.line-E.line:E.line-A.line),n.forEach(E=>Lf(i,E))),n}},uA={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},fA=zr(zr({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:Mp,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:vE,bufferController:RE,capLevelController:Lh,errorController:c4,fpsController:qE,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:tf,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,certLoadPolicy:{default:uA},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},pA()),{},{subtitleStreamController:TE,subtitleTrackController:wE,timelineController:YE,audioStreamController:bE,audioTrackController:EE,emeController:Mn,cmcdController:Is,contentSteeringController:eA});function pA(){return{cueHandler:dA,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 gA(i,t){if((t.liveSyncDurationCount||t.liveMaxLatencyDurationCount)&&(t.liveSyncDuration||t.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(t.liveMaxLatencyDurationCount!==void 0&&(t.liveSyncDurationCount===void 0||t.liveMaxLatencyDurationCount<=t.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(t.liveMaxLatencyDuration!==void 0&&(t.liveSyncDuration===void 0||t.liveMaxLatencyDuration<=t.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');const e=Ch(i),r=["manifest","level","frag"],n=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return r.forEach(o=>{const l=`${o==="level"?"playlist":o}LoadPolicy`,d=t[l]===void 0,f=[];n.forEach(p=>{const g=`${o}Loading${p}`,v=t[g];if(v!==void 0&&d){f.push(g);const E=e[l].default;switch(t[l]={default:E},p){case"TimeOut":E.maxLoadTimeMs=v,E.maxTimeToFirstByteMs=v;break;case"MaxRetry":E.errorRetry.maxNumRetry=v,E.timeoutRetry.maxNumRetry=v;break;case"RetryDelay":E.errorRetry.retryDelayMs=v,E.timeoutRetry.retryDelayMs=v;break;case"MaxRetryTimeout":E.errorRetry.maxRetryDelayMs=v,E.timeoutRetry.maxRetryDelayMs=v;break}}}),f.length&&X.warn(`hls.js config: "${f.join('", "')}" setting(s) are deprecated, use "${l}": ${JSON.stringify(t[l])}`)}),zr(zr({},e),t)}function Ch(i){return i&&typeof i=="object"?Array.isArray(i)?i.map(Ch):Object.keys(i).reduce((t,e)=>(t[e]=Ch(i[e]),t),{}):i}function mA(i){const t=i.loader;t!==Np&&t!==Mp?(X.log("[config]: Custom loader detected, cannot enable progressive streaming"),i.progressive=!1):iA()&&(i.loader=Np,i.progressive=!0,i.enableSoftwareAES=!0,X.log("[config]: Progressive streaming enabled, using FetchLoader"))}class os{static get version(){return"1.4.12"}static isSupported(){return L4()}static get Events(){return R}static get ErrorTypes(){return Qt}static get ErrorDetails(){return ut}static get DefaultConfig(){return os.defaultConfig?os.defaultConfig:fA}static set DefaultConfig(t){os.defaultConfig=t}constructor(t={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new ph,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,tb(t.debug||!1,"Hls instance");const e=this.config=gA(os.DefaultConfig,t);this.userConfig=t,this._autoLevelCapping=-1,e.progressive&&mA(e);const{abrController:r,bufferController:n,capLevelController:o,errorController:l,fpsController:d}=e,f=new l(this),p=this.abrController=new r(this),g=this.bufferController=new n(this),v=this.capLevelController=new o(this),E=new d(this),A=new Wb(this),T=new Xb(this),w=e.contentSteeringController,C=w?new w(this):null,D=this.levelController=new d4(this,C),M=new u4(this),U=new p4(this.config),x=this.streamController=new gE(this,M,U);v.setStreamController(x),E.setStreamController(x);const O=[A,D,x];C&&O.splice(1,0,C),this.networkControllers=O;const K=[p,g,v,E,T,M];this.audioTrackController=this.createController(e.audioTrackController,O);const B=e.audioStreamController;B&&O.push(new B(this,M,U)),this.subtitleTrackController=this.createController(e.subtitleTrackController,O);const at=e.subtitleStreamController;at&&O.push(new at(this,M,U)),this.createController(e.timelineController,K),U.emeController=this.emeController=this.createController(e.emeController,K),this.cmcdController=this.createController(e.cmcdController,K),this.latencyController=this.createController(Zb,K),this.coreComponents=K,O.push(f);const st=f.onErrorOut;typeof st=="function"&&this.on(R.ERROR,st,f)}createController(t,e){if(t){const r=new t(this);return e&&e.push(r),r}return null}on(t,e,r=this){this._emitter.on(t,e,r)}once(t,e,r=this){this._emitter.once(t,e,r)}removeAllListeners(t){this._emitter.removeAllListeners(t)}off(t,e,r=this,n){this._emitter.off(t,e,r,n)}listeners(t){return this._emitter.listeners(t)}emit(t,e,r){return this._emitter.emit(t,e,r)}trigger(t,e){if(this.config.debug)return this.emit(t,t,e);try{return this.emit(t,t,e)}catch(r){X.error("An internal error happened while handling event "+t+'. Error message: "'+r.message+'". Here is a stacktrace:',r),this.trigger(R.ERROR,{type:Qt.OTHER_ERROR,details:ut.INTERNAL_EXCEPTION,fatal:!1,event:t,error:r})}return!1}listenerCount(t){return this._emitter.listenerCount(t)}destroy(){X.log("destroy"),this.trigger(R.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(e=>e.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(e=>e.destroy()),this.coreComponents.length=0;const t=this.config;t.xhrSetup=t.fetchSetup=void 0,this.userConfig=null}attachMedia(t){X.log("attachMedia"),this._media=t,this.trigger(R.MEDIA_ATTACHING,{media:t})}detachMedia(){X.log("detachMedia"),this.trigger(R.MEDIA_DETACHING,void 0),this._media=null}loadSource(t){this.stopLoad();const e=this.media,r=this.url,n=this.url=$c.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});X.log(`loadSource:${n}`),e&&r&&(r!==n||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(e)),this.trigger(R.MANIFEST_LOADING,{url:t})}startLoad(t=-1){X.log(`startLoad(${t})`),this.networkControllers.forEach(e=>{e.startLoad(t)})}stopLoad(){X.log("stopLoad"),this.networkControllers.forEach(t=>{t.stopLoad()})}swapAudioCodec(){X.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){X.log("recoverMediaError");const t=this._media;this.detachMedia(),t&&this.attachMedia(t)}removeLevel(t,e=0){this.levelController.removeLevel(t,e)}get levels(){return this.levelController.levels||[]}get currentLevel(){return this.streamController.currentLevel}set currentLevel(t){X.log(`set currentLevel:${t}`),this.loadLevel=t,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(t){X.log(`set nextLevel:${t}`),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(t){X.log(`set loadLevel:${t}`),this.levelController.manualLevel=t}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(t){this.levelController.nextLoadLevel=t}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(t){X.log(`set firstLevel:${t}`),this.levelController.firstLevel=t}get startLevel(){return this.levelController.startLevel}set startLevel(t){X.log(`set startLevel:${t}`),t!==-1&&(t=Math.max(t,this.minAutoLevel)),this.levelController.startLevel=t}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(t){const e=!!t;e!==this.config.capLevelToPlayerSize&&(e?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=e)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){const{bwEstimator:t}=this.abrController;return t?t.getEstimate():NaN}get ttfbEstimate(){const{bwEstimator:t}=this.abrController;return t?t.getEstimateTTFB():NaN}set autoLevelCapping(t){this._autoLevelCapping!==t&&(X.log(`set autoLevelCapping:${t}`),this._autoLevelCapping=t)}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(t){Xc.indexOf(t)>-1&&(this._maxHdcpLevel=t)}get autoLevelEnabled(){return this.levelController.manualLevel===-1}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){const{levels:t,config:{minAutoBitrate:e}}=this;if(!t)return 0;const r=t.length;for(let n=0;n<r;n++)if(t[n].maxBitrate>=e)return n;return 0}get maxAutoLevel(){const{levels:t,autoLevelCapping:e,maxHdcpLevel:r}=this;let n;if(e===-1&&t&&t.length?n=t.length-1:n=e,r)for(let o=n;o--;){const l=t[o].attrs["HDCP-LEVEL"];if(l&&l<=r)return o}return n}get nextAutoLevel(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)}set nextAutoLevel(t){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,t)}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}get audioTracks(){const t=this.audioTrackController;return t?t.audioTracks:[]}get audioTrack(){const t=this.audioTrackController;return t?t.audioTrack:-1}set audioTrack(t){const e=this.audioTrackController;e&&(e.audioTrack=t)}get subtitleTracks(){const t=this.subtitleTrackController;return t?t.subtitleTracks:[]}get subtitleTrack(){const t=this.subtitleTrackController;return t?t.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(t){const e=this.subtitleTrackController;e&&(e.subtitleTrack=t)}get subtitleDisplay(){const t=this.subtitleTrackController;return t?t.subtitleDisplay:!1}set subtitleDisplay(t){const e=this.subtitleTrackController;e&&(e.subtitleDisplay=t)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(t){this.config.lowLatencyMode=t}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}}os.defaultConfig=void 0;function vA(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function yA(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function Ih(i){const{id:t,key:e,src:r,playlist:n,duration:o}=i;return new Promise(l=>{let d=null;const f=document.createElement("video");if(f.playsInline=!0,f.muted=!0,f.loop=!1,n&&!vA()&&os.isSupported()){let p=!1;d=new os({autoStartLoad:!0,xhrSetup:g=>{const{open:v}=g,E=n.split("?")[1];g.open=function(A,T,w){T.toString().includes("?")||(T+="?"+E),v.apply(this,[A,T,w])}}}),d.loadSource(n),d.attachMedia(f),d.startLoadOnce=(g=-1,v)=>{if(d&&!p){const E=d==null?void 0:d.levels.findIndex(A=>Math.min(A.height,A.width)===v);d.startLevel=d.firstLevel,d.startLoad(g),p=!0,d.currentLevel=E!==-1?E:d.firstLevel}},d.on(os.Events.LEVEL_LOADED,async()=>{p||d==null||d.stopLoad(),l({id:t,key:e,hls:d,config:i,node:f})})}else{f.src=r;let p=!1;if(f.startLoadOnce=()=>{p||(f.preload="auto",f.load(),p=!0)},o)f.preload="none",l({id:t,key:e,hls:d,config:i,node:f});else{f.preload="metadata";const g=async()=>{l({id:t,key:e,hls:d,config:i,node:f}),f.removeEventListener("loadedmetadata",g)};f.addEventListener("loadedmetadata",g)}}})}async function Fp(i){return i.duration===1/0?new Promise(t=>{i.currentTime=Number.MAX_SAFE_INTEGER,i.ontimeupdate=()=>{i.ontimeupdate=null,t(i.duration),i.currentTime=0}}):i.duration}const bA=ws(async function(i){return new FontFace(i.name,`url(${i.woff2??i.url})`,{style:i.style,weight:i.weight}).load()},{cacheKey:([i])=>JSON.stringify(i)});let EA=class{constructor(i){this._hasPlayed=!1,this._memoKey=null,this._lastDeps=null,this._duration=0,this._scenes=null,this._videos={},this._videoMeta={},this._videoState={},this._resolveVideo=ws(async t=>{const{id:e,key:r}=t,n=await Ih(t);n.node.volume=this.host.volume,n.node.playbackRate=this.host.playbackRate;const o={loadeddata:this._handleLoadedData,waiting:this._handleWaiting,canplay:this._handleCanPlay,progress:this._handleProgress,seeking:this._handleSeeking,seeked:this._handleSeeked,play:this._handlePlay,playing:this._handlePlaying,pause:this._handlePause,stalled:this._handleStalled,timeupdate:this._handleTimeUpdate,ended:this._handleEnded,error:this._handleError},l=Object.keys(o).reduce((d,f)=>{const p=f,g=o[p]({id:e,key:r,node:n.node});return d[p]=g,n.node.addEventListener(f,g),d},{});return{...n,listeners:l}},{cacheKey:([{id:t,key:e,src:r,playlist:n}])=>JSON.stringify({id:t,key:e,src:r==null?void 0:r.split("?")[0],playlist:n==null?void 0:n.split("?")[0]})}),this._resolveVideoMeta=ws(async(t,e)=>{const{id:r,captions:n,duration:o,startOffset:l,endOffset:d}=t,f=o??await Fp(e),p=(l??0)*f,g=(1-(d??0))*f;return{id:r,captions:n,start:p,duration:g-p}},{cacheKey:([{id:t,key:e,captions:r,duration:n,startOffset:o,endOffset:l}])=>JSON.stringify({id:t,key:e,captions:r,duration:n,startOffset:o,endOffset:l})}),this._handleLoadedData=({id:t,key:e,node:r})=>()=>{var n,o;const l=this.videoState[e];if(!(l!=null&&l.initialised)){this.videoState={...this.videoState,[e]:{...l,initialised:!0,waiting:!1,buffered:(l==null?void 0:l.buffered)??[]}};const d=(o=(n=this.scenes)==null?void 0:n.scenes)==null?void 0:o.find(({video:f})=>{f==null||f.key});d&&this._setVideoCurrentTime({scene:d,time:this.host.currentTime}),this.host.dispatchEvent(new CustomEvent("video:loadeddata",{detail:{id:t,key:e,node:r}}))}},this._handleWaiting=({key:t})=>()=>{const e=this.videoState[t];e!=null&&e.initialised&&!(e!=null&&e.waiting)&&(this.videoState={...this.videoState,[t]:{...e,waiting:!0}})},this._handleCanPlay=({key:t})=>()=>{const e=this.videoState[t];e!=null&&e.initialised&&e!=null&&e.waiting&&(this.videoState={...this.videoState,[t]:{...e,waiting:!1}}),this.host.paused&&this.host.draw()},this._handleProgress=({key:t,node:e})=>()=>{const r=this.videoState[t],n=this._getBufferSegments({key:t,node:e,duration:this.host.duration});this.videoState={...this.videoState,[t]:{...r,buffered:n}}},this._handleSeeking=({id:t,key:e,node:r})=>()=>{this.host.dispatchEvent(new CustomEvent("video:seeking",{detail:{id:t,key:e,node:r}}))},this._handleSeeked=({id:t,key:e,node:r})=>()=>{const n=this.videoState[e];n!=null&&n.initialised&&(this.host.draw(),this.host.dispatchEvent(new CustomEvent("video:seeked",{detail:{id:t,key:e,node:r}})))},this._handlePlay=({id:t,key:e,node:r})=>()=>{this.hasPlayed=!0,this.host.dispatchEvent(new CustomEvent("video:play",{detail:{id:t,key:e,node:r}}))},this._handlePlaying=({id:t,key:e,node:r})=>()=>{this.host.dispatchEvent(new CustomEvent("video:playing",{detail:{id:t,key:e,node:r}}))},this._handlePause=({id:t,key:e,node:r})=>()=>{this.host.dispatchEvent(new CustomEvent("video:pause",{detail:{id:t,key:e,node:r}}))},this._handleStalled=({id:t,key:e,node:r})=>()=>{this.host.dispatchEvent(new CustomEvent("video:stalled",{detail:{id:t,key:e,node:r}}))},this._handleTimeUpdate=({id:t,key:e,node:r})=>()=>{this.host.dispatchEvent(new CustomEvent("video:timeupdate",{detail:{id:t,key:e,node:r}}))},this._handleEnded=({id:t,key:e,node:r})=>()=>{this.host.dispatchEvent(new CustomEvent("video:ended",{detail:{id:t,key:e,node:r}}))},this._handleError=({id:t,key:e,node:r})=>()=>{const n=new Ni(`Video error - answer ${t} failed to load`);this.host.dispatchEvent(new ErrorEvent("error",{bubbles:!0,composed:!0,error:n,message:n.message})),this.host.dispatchEvent(new CustomEvent("video:error",{detail:{id:t,key:e,node:r}}))},this._cleanupVideo=t=>{var e;const r=this.videos[t];r&&(r.node.pause(),r.node.src="",(e=r.hls)==null||e.destroy(),Object.keys(r.listeners??{}).forEach(n=>{var o,l;if((o=this.videos)!=null&&o[t]){const d=(l=r.listeners)==null?void 0:l[n];d&&r.node.removeEventListener(n,d)}}),delete this.videos[t])},this.host=i,this.host.addController(this)}set hasPlayed(i){i!==this._hasPlayed&&(this._hasPlayed=i,this.host.requestUpdate())}get hasPlayed(){return this._hasPlayed}set duration(i){!isNaN(i)&&i!==this._duration&&(this._duration=i,this.host.requestUpdate(),this.host.dispatchEvent(new CustomEvent("durationchange",{detail:this._duration})))}get duration(){return this._duration}set scenes(i){i!==this._scenes&&(this._scenes=i,this.host.requestUpdate())}get scenes(){return this._scenes}set videos(i){i!==this._videos&&(this._videos=i,this.host.requestUpdate())}get videos(){return this._videos}set videoMeta(i){i!==this._videoMeta&&(this._videoMeta=i,this.host.requestUpdate())}get videoMeta(){return this._videoMeta}set videoState(i){i!==this._videoState&&(this._videoState=i,this.host.requestUpdate())}get videoState(){return this._videoState}_getBufferSegments({key:i,node:t,duration:e}){var r;const n=t==null?void 0:t.buffered,o=[],{start:l,video:d,videoMeta:f}=((r=this.scenes)==null?void 0:r.scenes.find(({video:p})=>i===(p==null?void 0:p.key)))??{};if(t&&n&&d&&f&&typeof l<"u")for(let p=0;p<n.length;p++){const g=n.start(p),v=n.end(p);Math.max(g,f.start)<=Math.min(v,f.start+f.duration)&&o.push({start:Math.max(0,(Math.max(g-f.start,0)+l)/e*100),end:Math.min((Math.min(v-f.start,f.duration)+l)/e*100,100)})}return o}_setupTask(){new co(this.host,async([i,t,e,r,n,o])=>{try{let l=null;if(this.host._errors=[],e||i){if(this.host._processing=!0,e){let f=null;if(r)try{f=await(await fetch(r,{method:"GET"})).text()}catch(g){const v=new Ni("Track failed to fetch",g);this.host.dispatchEvent(new ErrorEvent("error",{composed:!0,bubbles:!0,error:v,message:v.message}))}const p={questions:{items:[{answer:{id:"source",media:{[e.includes(".m3u8")?"playlist":"video"]:e},captions:{current:f}}}]}};try{this.scenes=await Sn({data:p,template:t,burnCaptions:n,debug:o},this._resolveVideo,this._resolveVideoMeta)}catch(g){try{this.scenes=await Sn({data:p,burnCaptions:n,debug:o},this._resolveVideo,this._resolveVideoMeta)}catch(v){throw new Ni("Fatal source template error",v,!0)}l=new Ni("Source template error",g)}}else try{this.scenes=await Sn({data:i,template:t,burnCaptions:n,debug:o},this._resolveVideo,this._resolveVideoMeta)}catch(f){try{this.scenes=await Sn({data:i,burnCaptions:n,debug:o},this._resolveVideo,this._resolveVideoMeta)}catch(p){throw new Ni("Fatal data template error",p,!0)}l=new Ni("Data template error",f)}Object.keys(this.videos).forEach(f=>{this.scenes.scenes.find(({video:p})=>f===(p==null?void 0:p.key))||this._videos[f].node.pause()});const d=this.scenes.scenes.reduce((f,{video:p})=>(p&&(f[p.key]=p),f),{});Object.keys(this.videos).join("|")!==Object.keys(d).join("|")&&this.host.reset(0,!1),this.videos=d,this.videoState={...this.videoState,...this.scenes.scenes.reduce((f,{video:p,start:g,duration:v})=>{var E;const A=(p==null?void 0:p.key)??`${g}-${v}`,T=this._getBufferSegments({key:A,node:p==null?void 0:p.node,duration:this.scenes.duration});return f[A]={initialised:!p,waiting:!!p,...this.videoState[A],buffered:p?T:(E=this.videoState[A])==null?void 0:E.buffered},f},{})},this.videoMeta=this.scenes.scenes.reduce((f,{video:p,videoMeta:g})=>(p&&g&&(f[p.key]=g),f),{}),(await Promise.all(this.scenes.fonts.map(f=>bA(f)))).forEach(f=>{document.fonts.add(f)}),this.duration=this.scenes.duration,this.host.paused&&this.host.reset(this.host.currentTime,!this.host.paused)}l&&this.host.dispatchEvent(new ErrorEvent("error",{composed:!0,bubbles:!0,error:l,message:l.message}))}catch(l){this.scenes=null,this.duration=0,this.host.dispatchEvent(new ErrorEvent("error",{composed:!0,bubbles:!0,error:l,message:l.message}))}finally{this.host._processing=!1}},()=>{const i=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===i)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=i,this._lastDeps=t,t})}_setVideoCurrentTime({time:i,scene:t}){const{start:e,video:r,videoMeta:n}=t;if(r&&r.node&&n&&typeof e<"u"){const o=i-e;r.node.currentTime=Math.max(n.start,Math.min(n.start+n.duration,o+n.start))}}setVideosCurrentTime(i){var t;(t=this.scenes)==null||t.scenes.forEach(e=>{this._setVideoCurrentTime({time:i,scene:e})})}hostConnected(){this._setupTask()}hostDisconnected(){Object.keys(this.videos).forEach(i=>{this._cleanupVideo(i)}),this.videos={}}};function AA(i){i.requestFullscreen?i.requestFullscreen():i.mozRequestFullScreen?i.mozRequestFullScreen():i.webkitRequestFullscreen?i.webkitRequestFullscreen():i.msRequestFullscreen&&i.msRequestFullscreen()}function TA(){document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen&&document.webkitExitFullscreen()}const xh=["progress","play-large","navigation","play","volume","current-time","duration","speed","captions","fullscreen","preview"],kA={id:"captions",event:"captions:click",label:"Closed Captions"},wA={id:"fullscreen",event:"fullscreen:click",label:"Full Screen"},Up={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}]},SA={id:"playbackRate",label:"Playback playbackRate",subItems:Up};class RA extends au{constructor(t){if(super(t),this.element=null,this.observer=void 0,t.type!==kn.ELEMENT)throw new Error("Resize directive must be used in an Element expression")}disconnected(){var t;(t=this.observer)==null||t.disconnect(),this.observer=void 0}reconnected(){var t;this.element&&((t=this.observer)==null||t.observe(this.element))}update(t,[e]){return this.isConnected&&!this.observer&&(this.observer=new ResizeObserver(e),this.element=t.element,this.observer.observe(this.element)),As}}const Dh=wn(RA);var Bp=Number.isNaN||function(i){return typeof i=="number"&&i!==i};function _A(i,t){return!!(i===t||Bp(i)&&Bp(t))}function LA(i,t){if(i.length!==t.length)return!1;for(var e=0;e<i.length;e++)if(!_A(i[e],t[e]))return!1;return!0}function CA(i,t){t===void 0&&(t=LA);var e=null;function r(){for(var n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];if(e&&e.lastThis===this&&t(n,e.lastArgs))return e.lastResult;var l=i.apply(this,n);return e={lastResult:l,lastArgs:n,lastThis:this},l}return r.clear=function(){e=null},r}const IA=CA(()=>{const i=new FontFace("Roobert","url(https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/Roobert-Regular.woff2)",{style:"normal",weight:"400"}),t=new FontFace("Roobert","url(https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/Roobert-SemiBold.woff2)",{style:"normal",weight:"600"}),e=new FontFace("Roobert Captions","url(https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/Roobert-Regular.woff2)",{style:"normal",weight:"400"}),r=qu.map(n=>({load:!1,font:new FontFace(n.family,`url(${n.url})`,{style:n.style})}));return[{load:!0,font:i},{load:!0,font:t},{load:!0,font:e},...r]}),Gi={"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"},xA={colors:Gi,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 ${Gi["dark-100"]}`,medium:`0 .125rem .625rem ${Gi["dark-100"]}`,large:`0 .25rem 1rem ${Gi["dark-50"]}`,xl:`.25rem .25rem 1rem ${Gi["dark-250"]}`,xxl:`0 .25rem 2rem ${Gi["dark-100"]}`,xxxl:`.25rem .25rem 3rem ${Gi["dark-250"]}`,toolbar:`0 -.625rem .625rem ${Gi["dark-50"]}`,text:`0 0 .25rem ${Gi["dark-250"]}`},timings:{fast:".1s",normal:".2s",slow:".3s"},easings:{linear:"linear"},focusOutline:{width:".2rem",color:Gi["dark-400"]},iconSizes:{small:"0.75rem",medium:"1rem",large:"1.5rem"}},Gp=mv.flatten(xA,{delimiter:"-"}),DA=Object.keys(Gp).map(i=>ra(`:host { --${i}: ${Gp[i]}; }`)),PA=i=>{class t extends i{firstUpdated(){IA().forEach(({load:r,font:n})=>{document.fonts.add(n),r&&n.load()})}}return t.styles=[(i==null?void 0:i.styles)??[],DA,cr`
205
+ `),p=[],g=t?Q4(t.baseTime,t.timescale):0;let v="00:00.000",E=0,A=0,T,w=!0;d.oncue=function(C){const D=e[r];let M=e.ccOffset;const U=(E-g)/9e4;if(D!=null&&D.new&&(A!==void 0?M=e.ccOffset=D.start:BE(e,r,U)),U){if(!t){T=new Error("Missing initPTS for VTT MPEGTS");return}M=U-e.presentationOffset}const x=C.endTime-C.startTime,O=pi((C.startTime+M-A)*9e4,n*9e4)/9e4;C.startTime=Math.max(O,0),C.endTime=Math.max(O+x,0);const K=C.text.trim();C.text=decodeURIComponent(encodeURIComponent(K)),C.id||(C.id=kh(C.startTime,C.endTime,K)),C.endTime>0&&p.push(C)},d.onparsingerror=function(C){T=C},d.onflush=function(){if(T){l(T);return}o(p)},f.forEach(C=>{if(w)if(Ah(C,"X-TIMESTAMP-MAP=")){w=!1,C.slice(16).split(",").forEach(D=>{Ah(D,"LOCAL:")?v=D.slice(6):Ah(D,"MPEGTS:")&&(E=parseInt(D.slice(7)))});try{A=UE(v)/1e3}catch(D){T=D}return}else C===""&&(w=!1);d.parse(C+`
206
+ `)}),d.flush()}const wh="stpp.ttml.im1t",_p=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Lp=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,HE={left:"start",center:"center",right:"end",start:"start",end:"end"};function Cp(i,t,e,r){const n=Te(new Uint8Array(i),["mdat"]);if(n.length===0){r(new Error("Could not parse IMSC1 mdat"));return}const o=n.map(d=>Fi(d)),l=q4(t.baseTime,1,t.timescale);try{o.forEach(d=>e(VE(d,l)))}catch(d){r(d)}}function VE(i,t){const e=new DOMParser().parseFromString(i,"text/xml").getElementsByTagName("tt")[0];if(!e)throw new Error("Invalid ttml");const r={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},n=Object.keys(r).reduce((p,g)=>(p[g]=e.getAttribute(`ttp:${g}`)||r[g],p),{}),o=e.getAttribute("xml:space")!=="preserve",l=Ip(Sh(e,"styling","style")),d=Ip(Sh(e,"layout","region")),f=Sh(e,"body","[begin]");return[].map.call(f,p=>{const g=xp(p,o);if(!g||!p.hasAttribute("begin"))return null;const v=_h(p.getAttribute("begin"),n),E=_h(p.getAttribute("dur"),n);let A=_h(p.getAttribute("end"),n);if(v===null)throw Dp(p);if(A===null){if(E===null)throw Dp(p);A=v+E}const T=new bh(v-t,A-t,g);T.id=kh(T.startTime,T.endTime,T.text);const w=d[p.getAttribute("region")],C=l[p.getAttribute("style")],D=WE(w,C,l),{textAlign:M}=D;if(M){const U=HE[M];U&&(T.lineAlign=U),T.align=M}return dr(T,D),T}).filter(p=>p!==null)}function Sh(i,t,e){const r=i.getElementsByTagName(t)[0];return r?[].slice.call(r.querySelectorAll(e)):[]}function Ip(i){return i.reduce((t,e)=>{const r=e.getAttribute("xml:id");return r&&(t[r]=e),t},{})}function xp(i,t){return[].slice.call(i.childNodes).reduce((e,r,n)=>{var o;return r.nodeName==="br"&&n?e+`
207
+ `:(o=r.childNodes)!=null&&o.length?xp(r,t):t?e+r.textContent.trim().replace(/\s+/g," "):e+r.textContent},"")}function WE(i,t,e){const r="http://www.w3.org/ns/ttml#styling";let n=null;const o=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],l=i!=null&&i.hasAttribute("style")?i.getAttribute("style"):null;return l&&e.hasOwnProperty(l)&&(n=e[l]),o.reduce((d,f)=>{const p=Rh(t,r,f)||Rh(i,r,f)||Rh(n,r,f);return p&&(d[f]=p),d},{})}function Rh(i,t,e){return i&&i.hasAttributeNS(t,e)?i.getAttributeNS(t,e):null}function Dp(i){return new Error(`Could not parse ttml timestamp ${i}`)}function _h(i,t){if(!i)return null;let e=wp(i);return e===null&&(_p.test(i)?e=jE(i,t):Lp.test(i)&&(e=KE(i,t))),e}function jE(i,t){const e=_p.exec(i),r=(e[4]|0)+(e[5]|0)/t.subFrameRate;return(e[1]|0)*3600+(e[2]|0)*60+(e[3]|0)+r/t.frameRate}function KE(i,t){const e=Lp.exec(i),r=Number(e[1]);switch(e[2]){case"h":return r*3600;case"m":return r*60;case"ms":return r*1e3;case"f":return r/t.frameRate;case"t":return r/t.tickRate}return r}class zE{constructor(t){if(this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=Pp(),this.captionsProperties=void 0,this.hls=t,this.config=t.config,this.Cues=t.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},this.config.enableCEA708Captions){const e=new nl(this,"textTrack1"),r=new nl(this,"textTrack2"),n=new nl(this,"textTrack3"),o=new nl(this,"textTrack4");this.cea608Parser1=new Ap(1,e,r),this.cea608Parser2=new Ap(3,n,o)}t.on(R.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(R.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(R.FRAG_LOADING,this.onFragLoading,this),t.on(R.FRAG_LOADED,this.onFragLoaded,this),t.on(R.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.on(R.FRAG_DECRYPTED,this.onFragDecrypted,this),t.on(R.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(R.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.on(R.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:t}=this;t.off(R.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(R.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(R.FRAG_LOADING,this.onFragLoading,this),t.off(R.FRAG_LOADED,this.onFragLoaded,this),t.off(R.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.off(R.FRAG_DECRYPTED,this.onFragDecrypted,this),t.off(R.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(R.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.off(R.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null}addCues(t,e,r,n,o){let l=!1;for(let d=o.length;d--;){const f=o[d],p=XE(f[0],f[1],e,r);if(p>=0&&(f[0]=Math.min(f[0],e),f[1]=Math.max(f[1],r),l=!0,p/(r-e)>.5))return}if(l||o.push([e,r]),this.config.renderTextTracksNatively){const d=this.captionsTracks[t];this.Cues.newCue(d,e,r,n)}else{const d=this.Cues.newCue(null,e,r,n);this.hls.trigger(R.CUES_PARSED,{type:"captions",cues:d,track:t})}}onInitPtsFound(t,{frag:e,id:r,initPTS:n,timescale:o}){const{unparsedVttFrags:l}=this;r==="main"&&(this.initPTS[e.cc]={baseTime:n,timescale:o}),l.length&&(this.unparsedVttFrags=[],l.forEach(d=>{this.onFragLoaded(R.FRAG_LOADED,d)}))}getExistingTrack(t){const{media:e}=this;if(e)for(let r=0;r<e.textTracks.length;r++){const n=e.textTracks[r];if(n[t])return n}return null}createCaptionsTrack(t){this.config.renderTextTracksNatively?this.createNativeTrack(t):this.createNonNativeTrack(t)}createNativeTrack(t){if(this.captionsTracks[t])return;const{captionsProperties:e,captionsTracks:r,media:n}=this,{label:o,languageCode:l}=e[t],d=this.getExistingTrack(t);if(d)r[t]=d,xn(r[t]),_f(r[t],n);else{const f=this.createTextTrack("captions",o,l);f&&(f[t]=!0,r[t]=f)}}createNonNativeTrack(t){if(this.nonNativeCaptionsTracks[t])return;const e=this.captionsProperties[t];if(!e)return;const r=e.label,n={_id:t,label:r,kind:"captions",default:e.media?!!e.media.default:!1,closedCaptions:e.media};this.nonNativeCaptionsTracks[t]=n,this.hls.trigger(R.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[n]})}createTextTrack(t,e,r){const n=this.media;if(n)return n.addTextTrack(t,e,r)}onMediaAttaching(t,e){this.media=e.media,this._cleanTracks()}onMediaDetaching(){const{captionsTracks:t}=this;Object.keys(t).forEach(e=>{xn(t[e]),delete t[e]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=Pp(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}_cleanTracks(){const{media:t}=this;if(!t)return;const e=t.textTracks;if(e)for(let r=0;r<e.length;r++)xn(e[r])}onSubtitleTracksUpdated(t,e){const r=e.subtitleTracks||[],n=r.some(o=>o.textCodec===wh);if(this.config.enableWebVTT||n&&this.config.enableIMSC1){if(fp(this.tracks,r)){this.tracks=r;return}if(this.textTracks=[],this.tracks=r,this.config.renderTextTracksNatively){const o=this.media?this.media.textTracks:null;this.tracks.forEach((l,d)=>{let f;if(o&&d<o.length){let p=null;for(let g=0;g<o.length;g++)if(YE(o[g],l)){p=o[g];break}p&&(f=p)}if(f)xn(f);else{const p=this._captionsOrSubtitlesFromCharacteristics(l);f=this.createTextTrack(p,l.name,l.lang),f&&(f.mode="disabled")}f&&(f.groupId=l.groupId,this.textTracks.push(f))})}else if(this.tracks.length){const o=this.tracks.map(l=>({label:l.name,kind:l.type.toLowerCase(),default:l.default,subtitleTrack:l}));this.hls.trigger(R.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:o})}}}_captionsOrSubtitlesFromCharacteristics(t){if(t.attrs.CHARACTERISTICS){const e=/transcribes-spoken-dialog/gi.test(t.attrs.CHARACTERISTICS),r=/describes-music-and-sound/gi.test(t.attrs.CHARACTERISTICS);if(e&&r)return"captions"}return"subtitles"}onManifestLoaded(t,e){this.config.enableCEA708Captions&&e.captions&&e.captions.forEach(r=>{const n=/(?:CC|SERVICE)([1-4])/.exec(r.instreamId);if(!n)return;const o=`textTrack${n[1]}`,l=this.captionsProperties[o];l&&(l.label=r.name,r.lang&&(l.languageCode=r.lang),l.media=r)})}closedCaptionsForLevel(t){const e=this.hls.levels[t.level];return e==null?void 0:e.attrs["CLOSED-CAPTIONS"]}onFragLoading(t,e){const{cea608Parser1:r,cea608Parser2:n,lastSn:o,lastPartIndex:l}=this;if(!(!this.enabled||!(r&&n))&&e.frag.type===Jt.MAIN){var d,f;const p=e.frag.sn,g=(d=e==null||(f=e.part)==null?void 0:f.index)!=null?d:-1;p===o+1||p===o&&g===l+1||(r.reset(),n.reset()),this.lastSn=p,this.lastPartIndex=g}}onFragLoaded(t,e){const{frag:r,payload:n}=e;if(r.type===Jt.SUBTITLE)if(n.byteLength){const o=r.decryptdata,l="stats"in e;if(o==null||!o.encrypted||l){const d=this.tracks[r.level],f=this.vttCCs;f[r.cc]||(f[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),d&&d.textCodec===wh?this._parseIMSC1(r,n):this._parseVTTs(e)}}else this.hls.trigger(R.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})}_parseIMSC1(t,e){const r=this.hls;Cp(e,this.initPTS[t.cc],n=>{this._appendCues(n,t.level),r.trigger(R.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:t})},n=>{X.log(`Failed to parse IMSC1: ${n}`),r.trigger(R.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:n})})}_parseVTTs(t){var e;const{frag:r,payload:n}=t,{initPTS:o,unparsedVttFrags:l}=this,d=o.length-1;if(!o[r.cc]&&d===-1){l.push(t);return}const f=this.hls,p=(e=r.initSegment)!=null&&e.data?fn(r.initSegment.data,new Uint8Array(n)):n;GE(p,this.initPTS[r.cc],this.vttCCs,r.cc,r.start,g=>{this._appendCues(g,r.level),f.trigger(R.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:r})},g=>{const v=g.message==="Missing initPTS for VTT MPEGTS";v?l.push(t):this._fallbackToIMSC1(r,n),X.log(`Failed to parse VTT cue: ${g}`),!(v&&d>r.cc)&&f.trigger(R.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:g})})}_fallbackToIMSC1(t,e){const r=this.tracks[t.level];r.textCodec||Cp(e,this.initPTS[t.cc],()=>{r.textCodec=wh,this._parseIMSC1(t,e)},()=>{r.textCodec="wvtt"})}_appendCues(t,e){const r=this.hls;if(this.config.renderTextTracksNatively){const n=this.textTracks[e];if(!n||n.mode==="disabled")return;t.forEach(o=>Lf(n,o))}else{const n=this.tracks[e];if(!n)return;const o=n.default?"default":"subtitles"+e;r.trigger(R.CUES_PARSED,{type:"subtitles",cues:t,track:o})}}onFragDecrypted(t,e){const{frag:r}=e;r.type===Jt.SUBTITLE&&this.onFragLoaded(R.FRAG_LOADED,e)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(t,e){const{cea608Parser1:r,cea608Parser2:n}=this;if(!this.enabled||!(r&&n))return;const{frag:o,samples:l}=e;if(!(o.type===Jt.MAIN&&this.closedCaptionsForLevel(o)==="NONE"))for(let d=0;d<l.length;d++){const f=l[d].bytes;if(f){const p=this.extractCea608Data(f);r.addData(l[d].pts,p[0]),n.addData(l[d].pts,p[1])}}}onBufferFlushing(t,{startOffset:e,endOffset:r,endOffsetSubtitles:n,type:o}){const{media:l}=this;if(!(!l||l.currentTime<r)){if(!o||o==="video"){const{captionsTracks:d}=this;Object.keys(d).forEach(f=>Kc(d[f],e,r))}if(this.config.renderTextTracksNatively&&e===0&&n!==void 0){const{textTracks:d}=this;Object.keys(d).forEach(f=>Kc(d[f],e,n))}}}extractCea608Data(t){const e=[[],[]],r=t[0]&31;let n=2;for(let o=0;o<r;o++){const l=t[n++],d=127&t[n++],f=127&t[n++];if(!(d===0&&f===0)&&4&l){const p=3&l;(p===0||p===1)&&(e[p].push(d),e[p].push(f))}}return e}}function YE(i,t){return!!i&&i.label===t.name&&!(i.textTrack1||i.textTrack2)}function XE(i,t,e,r){return Math.min(t,r)-Math.max(i,e)}function Pp(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}class Lh{constructor(t){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=t,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}setStreamController(t){this.streamController=t}destroy(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){const{hls:t}=this;t.on(R.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.on(R.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(R.MANIFEST_PARSED,this.onManifestParsed,this),t.on(R.BUFFER_CODECS,this.onBufferCodecs,this),t.on(R.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:t}=this;t.off(R.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.off(R.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(R.MANIFEST_PARSED,this.onManifestParsed,this),t.off(R.BUFFER_CODECS,this.onBufferCodecs,this),t.off(R.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(t,e){const r=this.hls.levels[e.droppedLevel];this.isLevelAllowed(r)&&this.restrictedLevels.push({bitrate:r.bitrate,height:r.height,width:r.width})}onMediaAttaching(t,e){this.media=e.media instanceof HTMLVideoElement?e.media:null,this.clientRect=null}onManifestParsed(t,e){const r=this.hls;this.restrictedLevels=[],this.firstLevel=e.firstLevel,r.config.capLevelToPlayerSize&&e.video&&this.startCapping()}onBufferCodecs(t,e){this.hls.config.capLevelToPlayerSize&&e.video&&this.startCapping()}onMediaDetaching(){this.stopCapping()}detectPlayerSize(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){const t=this.hls.levels;if(t.length){const e=this.hls;e.autoLevelCapping=this.getMaxLevel(t.length-1),e.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=e.autoLevelCapping}}}getMaxLevel(t){const e=this.hls.levels;if(!e.length)return-1;const r=e.filter((n,o)=>this.isLevelAllowed(n)&&o<=t);return this.clientRect=null,Lh.getMaxLevelByMediaSize(r,this.mediaWidth,this.mediaHeight)}startCapping(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())}stopCapping(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)}getDimensions(){if(this.clientRect)return this.clientRect;const t=this.media,e={width:0,height:0};if(t){const r=t.getBoundingClientRect();e.width=r.width,e.height=r.height,!e.width&&!e.height&&(e.width=r.right-r.left||t.width||0,e.height=r.bottom-r.top||t.height||0)}return this.clientRect=e,e}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let t=1;if(!this.hls.config.ignoreDevicePixelRatio)try{t=self.devicePixelRatio}catch{}return t}isLevelAllowed(t){return!this.restrictedLevels.some(e=>t.bitrate===e.bitrate&&t.width===e.width&&t.height===e.height)}static getMaxLevelByMediaSize(t,e,r){if(!(t!=null&&t.length))return-1;const n=(l,d)=>d?l.width!==d.width||l.height!==d.height:!0;let o=t.length-1;for(let l=0;l<t.length;l+=1){const d=t[l];if((d.width>=e||d.height>=r)&&n(d,t[l+1])){o=l;break}}return o}}class ZE{constructor(t){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=t,this.registerListeners()}setStreamController(t){this.streamController=t}registerListeners(){this.hls.on(R.MEDIA_ATTACHING,this.onMediaAttaching,this)}unregisterListeners(){this.hls.off(R.MEDIA_ATTACHING,this.onMediaAttaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(t,e){const r=this.hls.config;if(r.capLevelOnFPSDrop){const n=e.media instanceof self.HTMLVideoElement?e.media:null;this.media=n,n&&typeof n.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}}checkFPS(t,e,r){const n=performance.now();if(e){if(this.lastTime){const o=n-this.lastTime,l=r-this.lastDroppedFrames,d=e-this.lastDecodedFrames,f=1e3*l/o,p=this.hls;if(p.trigger(R.FPS_DROP,{currentDropped:l,currentDecoded:d,totalDroppedFrames:r}),f>0&&l>p.config.fpsDroppedMonitoringThreshold*d){let g=p.currentLevel;X.warn("drop FPS ratio greater than max allowed value for currentLevel: "+g),g>0&&(p.autoLevelCapping===-1||p.autoLevelCapping>=g)&&(g=g-1,p.trigger(R.FPS_DROP_LEVEL_CAPPING,{level:g,droppedLevel:p.currentLevel}),p.autoLevelCapping=g,this.streamController.nextLevelSwitch())}}this.lastTime=n,this.lastDroppedFrames=r,this.lastDecodedFrames=e}}checkFPSInterval(){const t=this.media;if(t)if(this.isVideoPlaybackQualityAvailable){const e=t.getVideoPlaybackQuality();this.checkFPS(t,e.totalVideoFrames,e.droppedVideoFrames)}else this.checkFPS(t,t.webkitDecodedFrameCount,t.webkitDroppedFrameCount)}}const ol="[eme]";class Mn{constructor(t){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=Mn.CDMCleanupPromise?[Mn.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=X.debug.bind(X,ol),this.log=X.log.bind(X,ol),this.warn=X.warn.bind(X,ol),this.error=X.error.bind(X,ol),this.hls=t,this.config=t.config,this.registerListeners()}destroy(){this.unregisterListeners(),this.onMediaDetached();const t=this.config;t.requestMediaKeySystemAccessFunc=null,t.licenseXhrSetup=t.licenseResponseCallback=void 0,t.drmSystems=t.drmSystemOptions={},this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null,this.config=null}registerListeners(){this.hls.on(R.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(R.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(R.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(R.MANIFEST_LOADED,this.onManifestLoaded,this)}unregisterListeners(){this.hls.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(R.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(R.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(R.MANIFEST_LOADED,this.onManifestLoaded,this)}getLicenseServerUrl(t){const{drmSystems:e,widevineLicenseUrl:r}=this.config,n=e[t];if(n)return n.licenseUrl;if(t===er.WIDEVINE&&r)return r;throw new Error(`no license server URL configured for key-system "${t}"`)}getServerCertificateUrl(t){const{drmSystems:e}=this.config,r=e[t];if(r)return r.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${t}"]`)}attemptKeySystemAccess(t){const e=this.hls.levels,r=(l,d,f)=>!!l&&f.indexOf(l)===d,n=e.map(l=>l.audioCodec).filter(r),o=e.map(l=>l.videoCodec).filter(r);return n.length+o.length===0&&o.push("avc1.42e01e"),new Promise((l,d)=>{const f=p=>{const g=p.shift();this.getMediaKeysPromise(g,n,o).then(v=>l({keySystem:g,mediaKeys:v})).catch(v=>{p.length?f(p):v instanceof gi?d(v):d(new gi({type:Qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_NO_ACCESS,error:v,fatal:!0},v.message))})};f(t)})}requestMediaKeySystemAccess(t,e){const{requestMediaKeySystemAccessFunc:r}=this.config;if(typeof r!="function"){let n=`Configured requestMediaKeySystemAccess is not a function ${r}`;return tf===null&&self.location.protocol==="http:"&&(n=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(n))}return r(t,e)}getMediaKeysPromise(t,e,r){const n=hb(t,e,r,this.config.drmSystemOptions),o=this.keySystemAccessPromises[t];let l=o==null?void 0:o.keySystemAccess;if(!l){this.log(`Requesting encrypted media "${t}" key-system access with config: ${JSON.stringify(n)}`),l=this.requestMediaKeySystemAccess(t,n);const d=this.keySystemAccessPromises[t]={keySystemAccess:l};return l.catch(f=>{this.log(`Failed to obtain access to key-system "${t}": ${f}`)}),l.then(f=>{this.log(`Access for key-system "${f.keySystem}" obtained`);const p=this.fetchServerCertificate(t);return this.log(`Create media-keys for "${t}"`),d.mediaKeys=f.createMediaKeys().then(g=>(this.log(`Media-keys created for "${t}"`),p.then(v=>v?this.setMediaKeysServerCertificate(g,t,v):g))),d.mediaKeys.catch(g=>{this.error(`Failed to create media-keys for "${t}"}: ${g}`)}),d.mediaKeys})}return l.then(()=>o.mediaKeys)}createMediaKeySessionContext({decryptdata:t,keySystem:e,mediaKeys:r}){this.log(`Creating key-system session "${e}" keyId: ${Ui.hexDump(t.keyId||[])}`);const n=r.createSession(),o={decryptdata:t,keySystem:e,mediaKeys:r,mediaKeysSession:n,keyStatus:"status-pending"};return this.mediaKeySessions.push(o),o}renewKeySession(t){const e=t.decryptdata;if(e.pssh){const r=this.createMediaKeySessionContext(t),n=this.getKeyIdString(e),o="cenc";this.keyIdToKeySessionPromise[n]=this.generateRequestWithPreferredKeySession(r,o,e.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(t)}getKeyIdString(t){if(!t)throw new Error("Could not read keyId of undefined decryptdata");if(t.keyId===null)throw new Error("keyId is null");return Ui.hexDump(t.keyId)}updateKeySession(t,e){var r;const n=t.mediaKeysSession;return this.log(`Updating key-session "${n.sessionId}" for keyID ${Ui.hexDump(((r=t.decryptdata)==null?void 0:r.keyId)||[])}
208
+ } (data length: ${e&&e.byteLength})`),n.update(e)}selectKeySystemFormat(t){const e=Object.keys(t.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${t.sn} ${t.type}: ${t.level}) key formats ${e.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(e)),this.keyFormatPromise}getKeyFormatPromise(t){return new Promise((e,r)=>{const n=Uc(this.config),o=t.map(q0).filter(l=>!!l&&n.indexOf(l)!==-1);return this.getKeySystemSelectionPromise(o).then(({keySystem:l})=>{const d=J0(l);d?e(d):r(new Error(`Unable to find format for key-system "${l}"`))}).catch(r)})}loadKey(t){const e=t.keyInfo.decryptdata,r=this.getKeyIdString(e),n=`(keyId: ${r} format: "${e.keyFormat}" method: ${e.method} uri: ${e.uri})`;this.log(`Starting session for key ${n}`);let o=this.keyIdToKeySessionPromise[r];return o||(o=this.keyIdToKeySessionPromise[r]=this.getKeySystemForKeyPromise(e).then(({keySystem:l,mediaKeys:d})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${t.frag.sn} ${t.frag.type}: ${t.frag.level} using key ${n}`),this.attemptSetMediaKeys(l,d).then(()=>{this.throwIfDestroyed();const f=this.createMediaKeySessionContext({keySystem:l,mediaKeys:d,decryptdata:e}),p="cenc";return this.generateRequestWithPreferredKeySession(f,p,e.pssh,"playlist-key")}))),o.catch(l=>this.handleError(l))),o}throwIfDestroyed(t="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(t){this.hls&&(this.error(t.message),t instanceof gi?this.hls.trigger(R.ERROR,t.data):this.hls.trigger(R.ERROR,{type:Qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_NO_KEYS,error:t,fatal:!0}))}getKeySystemForKeyPromise(t){const e=this.getKeyIdString(t),r=this.keyIdToKeySessionPromise[e];if(!r){const n=q0(t.keyFormat),o=n?[n]:Uc(this.config);return this.attemptKeySystemAccess(o)}return r}getKeySystemSelectionPromise(t){if(t.length||(t=Uc(this.config)),t.length===0)throw new gi({type:Qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${JSON.stringify({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(t)}_onMediaEncrypted(t){const{initDataType:e,initData:r}=t;if(this.debug(`"${t.type}" event: init data type: "${e}"`),r===null)return;let n,o;if(e==="sinf"&&this.config.drmSystems[er.FAIRPLAY]){const g=_r(new Uint8Array(r));try{const v=Fc(JSON.parse(g).sinf),E=cf(new Uint8Array(v));if(!E)return;n=E.subarray(8,24),o=er.FAIRPLAY}catch{this.warn('Failed to parse sinf "encrypted" event message initData');return}}else{const g=Ob(r);if(g===null)return;g.version===0&&g.systemId===Q0.WIDEVINE&&g.data&&(n=g.data.subarray(8,24)),o=cb(g.systemId)}if(!o||!n)return;const l=Ui.hexDump(n),{keyIdToKeySessionPromise:d,mediaKeySessions:f}=this;let p=d[l];for(let g=0;g<f.length;g++){const v=f[g],E=v.decryptdata;if(E.pssh||!E.keyId)continue;const A=Ui.hexDump(E.keyId);if(l===A||E.uri.replace(/-/g,"").indexOf(l)!==-1){p=d[A],delete d[A],E.pssh=new Uint8Array(r),E.keyId=n,p=d[l]=p.then(()=>this.generateRequestWithPreferredKeySession(v,e,r,"encrypted-event-key-match"));break}}p||(p=d[l]=this.getKeySystemSelectionPromise([o]).then(({keySystem:g,mediaKeys:v})=>{var E;this.throwIfDestroyed();const A=new Oa("ISO-23001-7",l,(E=J0(g))!=null?E:"");return A.pssh=new Uint8Array(r),A.keyId=n,this.attemptSetMediaKeys(g,v).then(()=>{this.throwIfDestroyed();const T=this.createMediaKeySessionContext({decryptdata:A,keySystem:g,mediaKeys:v});return this.generateRequestWithPreferredKeySession(T,e,r,"encrypted-event-no-match")})})),p.catch(g=>this.handleError(g))}_onWaitingForKey(t){this.log(`"${t.type}" event`)}attemptSetMediaKeys(t,e){const r=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${t}"`);const n=Promise.all(r).then(()=>{if(!this.media)throw new Error("Attempted to set mediaKeys without media element attached");return this.media.setMediaKeys(e)});return this.setMediaKeysQueue.push(n),n.then(()=>{this.log(`Media-keys set for "${t}"`),r.push(n),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(o=>r.indexOf(o)===-1)})}generateRequestWithPreferredKeySession(t,e,r,n){var o,l;const d=(o=this.config.drmSystems)==null||(l=o[t.keySystem])==null?void 0:l.generateRequest;if(d)try{const E=d.call(this.hls,e,r,t);if(!E)throw new Error("Invalid response from configured generateRequest filter");e=E.initDataType,r=t.decryptdata.pssh=E.initData?new Uint8Array(E.initData):null}catch(E){var f;if(this.warn(E.message),(f=this.hls)!=null&&f.config.debug)throw E}if(r===null)return this.log(`Skipping key-session request for "${n}" (no initData)`),Promise.resolve(t);const p=this.getKeyIdString(t.decryptdata);this.log(`Generating key-session request for "${n}": ${p} (init data type: ${e} length: ${r?r.byteLength:null})`);const g=new ph;t.mediaKeysSession.onmessage=E=>{const A=t.mediaKeysSession;if(!A){g.emit("error",new Error("invalid state"));return}const{messageType:T,message:w}=E;this.log(`"${T}" message event for session "${A.sessionId}" message size: ${w.byteLength}`),T==="license-request"||T==="license-renewal"?this.renewLicense(t,w).catch(C=>{this.handleError(C),g.emit("error",C)}):T==="license-release"?t.keySystem===er.FAIRPLAY&&(this.updateKeySession(t,Z0("acknowledged")),this.removeSession(t)):this.warn(`unhandled media key message type "${T}"`)},t.mediaKeysSession.onkeystatuseschange=E=>{if(!t.mediaKeysSession){g.emit("error",new Error("invalid state"));return}this.onKeyStatusChange(t);const A=t.keyStatus;g.emit("keyStatus",A),A==="expired"&&(this.warn(`${t.keySystem} expired for key ${p}`),this.renewKeySession(t))};const v=new Promise((E,A)=>{g.on("error",A),g.on("keyStatus",T=>{T.startsWith("usable")?E():T==="output-restricted"?A(new gi({type:Qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):T==="internal-error"?A(new gi({type:Qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},`key status changed to "${T}"`)):T==="expired"?A(new Error("key expired while generating request")):this.warn(`unhandled key status change "${T}"`)})});return t.mediaKeysSession.generateRequest(e,r).then(()=>{var E;this.log(`Request generated for key-session "${(E=t.mediaKeysSession)==null?void 0:E.sessionId}" keyId: ${p}`)}).catch(E=>{throw new gi({type:Qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_NO_SESSION,error:E,fatal:!1},`Error generating key-session request: ${E}`)}).then(()=>v).catch(E=>{throw g.removeAllListeners(),this.removeSession(t),E}).then(()=>(g.removeAllListeners(),t))}onKeyStatusChange(t){t.mediaKeysSession.keyStatuses.forEach((e,r)=>{this.log(`key status change "${e}" for keyStatuses keyId: ${Ui.hexDump("buffer"in r?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):new Uint8Array(r))} session keyId: ${Ui.hexDump(new Uint8Array(t.decryptdata.keyId||[]))} uri: ${t.decryptdata.uri}`),t.keyStatus=e})}fetchServerCertificate(t){const e=this.config,r=e.loader,n=new r(e),o=this.getServerCertificateUrl(t);return o?(this.log(`Fetching serverCertificate for "${t}"`),new Promise((l,d)=>{const f={responseType:"arraybuffer",url:o},p=e.certLoadPolicy.default,g={loadPolicy:p,timeout:p.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},v={onSuccess:(E,A,T,w)=>{l(E.data)},onError:(E,A,T,w)=>{d(new gi({type:Qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:T,response:zr({url:f.url,data:void 0},E)},`"${t}" certificate request failed (${o}). Status: ${E.code} (${E.text})`))},onTimeout:(E,A,T)=>{d(new gi({type:Qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:T,response:{url:f.url,data:void 0}},`"${t}" certificate request timed out (${o})`))},onAbort:(E,A,T)=>{d(new Error("aborted"))}};n.load(f,g,v)})):Promise.resolve()}setMediaKeysServerCertificate(t,e,r){return new Promise((n,o)=>{t.setServerCertificate(r).then(l=>{this.log(`setServerCertificate ${l?"success":"not supported by CDM"} (${r==null?void 0:r.byteLength}) on "${e}"`),n(t)}).catch(l=>{o(new gi({type:Qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:l,fatal:!0},l.message))})})}renewLicense(t,e){return this.requestLicense(t,new Uint8Array(e)).then(r=>this.updateKeySession(t,new Uint8Array(r)).catch(n=>{throw new gi({type:Qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:n,fatal:!0},n.message)}))}setupLicenseXHR(t,e,r,n){const o=this.config.licenseXhrSetup;return o?Promise.resolve().then(()=>{if(!r.decryptdata)throw new Error("Key removed");return o.call(this.hls,t,e,r,n)}).catch(l=>{if(!r.decryptdata)throw l;return t.open("POST",e,!0),o.call(this.hls,t,e,r,n)}).then(l=>(t.readyState||t.open("POST",e,!0),{xhr:t,licenseChallenge:l||n})):(t.open("POST",e,!0),Promise.resolve({xhr:t,licenseChallenge:n}))}requestLicense(t,e){const r=this.config.keyLoadPolicy.default;return new Promise((n,o)=>{const l=this.getLicenseServerUrl(t.keySystem);this.log(`Sending license request to URL: ${l}`);const d=new XMLHttpRequest;d.responseType="arraybuffer",d.onreadystatechange=()=>{if(!this.hls||!t.mediaKeysSession)return o(new Error("invalid state"));if(d.readyState===4)if(d.status===200){this._requestLicenseFailureCount=0;let f=d.response;this.log(`License received ${f instanceof ArrayBuffer?f.byteLength:f}`);const p=this.config.licenseResponseCallback;if(p)try{f=p.call(this.hls,d,l,t)}catch(g){this.error(g)}n(f)}else{const f=r.errorRetry,p=f?f.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>p||d.status>=400&&d.status<500)o(new gi({type:Qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:d,response:{url:l,data:void 0,code:d.status,text:d.statusText}},`License Request XHR failed (${l}). Status: ${d.status} (${d.statusText})`));else{const g=p-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${g} attempts left`),this.requestLicense(t,e).then(n,o)}}},t.licenseXhr&&t.licenseXhr.readyState!==XMLHttpRequest.DONE&&t.licenseXhr.abort(),t.licenseXhr=d,this.setupLicenseXHR(d,l,t,e).then(({xhr:f,licenseChallenge:p})=>{f.send(p)})})}onMediaAttached(t,e){if(!this.config.emeEnabled)return;const r=e.media;this.media=r,r.addEventListener("encrypted",this.onMediaEncrypted),r.addEventListener("waitingforkey",this.onWaitingForKey)}onMediaDetached(){const t=this.media,e=this.mediaKeySessions;t&&(t.removeEventListener("encrypted",this.onMediaEncrypted),t.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},Oa.clearKeyUriToKeyIdMap();const r=e.length;Mn.CDMCleanupPromise=Promise.all(e.map(n=>this.removeSession(n)).concat(t==null?void 0:t.setMediaKeys(null).catch(n=>{this.log(`Could not clear media keys: ${n}. media.src: ${t==null?void 0:t.src}`)}))).then(()=>{r&&(this.log("finished closing key sessions and clearing media keys"),e.length=0)}).catch(n=>{this.log(`Could not close sessions and clear media keys: ${n}. media.src: ${t==null?void 0:t.src}`)})}onManifestLoading(){this.keyFormatPromise=null}onManifestLoaded(t,{sessionKeys:e}){if(!(!e||!this.config.emeEnabled)&&!this.keyFormatPromise){const r=e.reduce((n,o)=>(n.indexOf(o.keyFormat)===-1&&n.push(o.keyFormat),n),[]);this.log(`Selecting key-system from session-keys ${r.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(r)}}removeSession(t){const{mediaKeysSession:e,licenseXhr:r}=t;if(e){this.log(`Remove licenses and keys and close session ${e.sessionId}`),e.onmessage=null,e.onkeystatuseschange=null,r&&r.readyState!==XMLHttpRequest.DONE&&r.abort(),t.mediaKeysSession=t.decryptdata=t.licenseXhr=void 0;const n=this.mediaKeySessions.indexOf(t);return n>-1&&this.mediaKeySessions.splice(n,1),e.remove().catch(o=>{this.log(`Could not remove session: ${o}`)}).then(()=>e.close()).catch(o=>{this.log(`Could not close session: ${o}`)})}}}Mn.CDMCleanupPromise=void 0;class gi extends Error{constructor(t,e){super(e),this.data=void 0,t.error||(t.error=new Error(e)),this.data=t,t.err=t.error}}const qE=1;var Zr={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"};const QE="h";class Is{constructor(t){this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=n=>{try{this.apply(n,{ot:Zr.MANIFEST,su:!this.initialized})}catch(o){X.warn("Could not generate manifest CMCD data.",o)}},this.applyFragmentData=n=>{try{const o=n.frag,l=this.hls.levels[o.level],d=this.getObjectType(o),f={d:o.duration*1e3,ot:d};(d===Zr.VIDEO||d===Zr.AUDIO||d==Zr.MUXED)&&(f.br=l.bitrate/1e3,f.tb=this.getTopBandwidth(d)/1e3,f.bl=this.getBufferLength(d)),this.apply(n,f)}catch(o){X.warn("Could not generate segment CMCD data.",o)}},this.hls=t;const e=this.config=t.config,{cmcd:r}=e;r!=null&&(e.pLoader=this.createPlaylistLoader(),e.fLoader=this.createFragmentLoader(),this.sid=r.sessionId||Is.uuid(),this.cid=r.contentId,this.useHeaders=r.useHeaders===!0,this.registerListeners())}registerListeners(){const t=this.hls;t.on(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(R.MEDIA_DETACHED,this.onMediaDetached,this),t.on(R.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const t=this.hls;t.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(R.MEDIA_DETACHED,this.onMediaDetached,this),t.off(R.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null}onMediaAttached(t,e){this.media=e.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}onMediaDetached(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}onBufferCreated(t,e){var r,n;this.audioBuffer=(r=e.tracks.audio)==null?void 0:r.buffer,this.videoBuffer=(n=e.tracks.video)==null?void 0:n.buffer}createData(){var t;return{v:qE,sf:QE,sid:this.sid,cid:this.cid,pr:(t=this.media)==null?void 0:t.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(t,e={}){dr(e,this.createData());const r=e.ot===Zr.INIT||e.ot===Zr.VIDEO||e.ot===Zr.MUXED;if(this.starved&&r&&(e.bs=!0,e.su=!0,this.starved=!1),e.su==null&&(e.su=this.buffering),this.useHeaders){const n=Is.toHeaders(e);if(!Object.keys(n).length)return;t.headers||(t.headers={}),dr(t.headers,n)}else{const n=Is.toQuery(e);if(!n)return;t.url=Is.appendQueryToUri(t.url,n)}}getObjectType(t){const{type:e}=t;if(e==="subtitle")return Zr.TIMED_TEXT;if(t.sn==="initSegment")return Zr.INIT;if(e==="audio")return Zr.AUDIO;if(e==="main")return this.hls.audioTracks.length?Zr.VIDEO:Zr.MUXED}getTopBandwidth(t){let e=0,r;const n=this.hls;if(t===Zr.AUDIO)r=n.audioTracks;else{const o=n.maxAutoLevel,l=o>-1?o+1:n.levels.length;r=n.levels.slice(0,l)}for(const o of r)o.bitrate>e&&(e=o.bitrate);return e>0?e:NaN}getBufferLength(t){const e=this.hls.media,r=t===Zr.AUDIO?this.audioBuffer:this.videoBuffer;return!r||!e?NaN:Ve.bufferInfo(r,e.currentTime,this.config.maxBufferHole).len*1e3}createPlaylistLoader(){const{pLoader:t}=this.config,e=this.applyPlaylistData,r=t||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new r(n)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(n,o,l){e(n),this.loader.load(n,o,l)}}}createFragmentLoader(){const{fLoader:t}=this.config,e=this.applyFragmentData,r=t||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new r(n)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(n,o,l){e(n),this.loader.load(n,o,l)}}}static uuid(){const t=URL.createObjectURL(new Blob),e=t.toString();return URL.revokeObjectURL(t),e.slice(e.lastIndexOf("/")+1)}static serialize(t){const e=[],r=f=>!Number.isNaN(f)&&f!=null&&f!==""&&f!==!1,n=f=>Math.round(f),o=f=>n(f/100)*100,l={br:n,d:n,bl:o,dl:o,mtp:o,nor:f=>encodeURIComponent(f),rtp:o,tb:n},d=Object.keys(t||{}).sort();for(const f of d){let p=t[f];if(!r(p)||f==="v"&&p===1||f=="pr"&&p===1)continue;const g=l[f];g&&(p=g(p));const v=typeof p;let E;f==="ot"||f==="sf"||f==="st"?E=`${f}=${p}`:v==="boolean"?E=f:v==="number"?E=`${f}=${p}`:E=`${f}=${JSON.stringify(p)}`,e.push(E)}return e.join(",")}static toHeaders(t){const e=Object.keys(t),r={},n=["Object","Request","Session","Status"],o=[{},{},{},{}],l={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3};for(const d of e){const f=l[d]!=null?l[d]:1;o[f][d]=t[d]}for(let d=0;d<o.length;d++){const f=Is.serialize(o[d]);f&&(r[`CMCD-${n[d]}`]=f)}return r}static toQuery(t){return`CMCD=${encodeURIComponent(Is.serialize(t))}`}static appendQueryToUri(t,e){if(!e)return t;const r=t.includes("?")?"&":"?";return`${t}${r}${e}`}}const JE=3e5;class tA{constructor(t){this.hls=void 0,this.log=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this.pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=t,this.log=X.log.bind(X,"[content-steering]:"),this.registerListeners()}registerListeners(){const t=this.hls;t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(R.MANIFEST_PARSED,this.onManifestParsed,this),t.on(R.ERROR,this.onError,this)}unregisterListeners(){const t=this.hls;t&&(t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(R.MANIFEST_PARSED,this.onManifestParsed,this),t.off(R.ERROR,this.onError,this))}startLoad(){if(this.started=!0,self.clearTimeout(this.reloadTimer),this.enabled&&this.uri)if(this.updated){const t=Math.max(this.timeToLoad*1e3-(performance.now()-this.updated),0);this.scheduleRefresh(this.uri,t)}else this.loadSteeringManifest(this.uri)}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),self.clearTimeout(this.reloadTimer)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(t){const e=this.levels;e&&(this.levels=e.filter(r=>r!==t))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(t,e){const{contentSteering:r}=e;r!==null&&(this.pathwayId=r.pathwayId,this.uri=r.uri,this.started&&this.startLoad())}onManifestParsed(t,e){this.audioTracks=e.audioTracks,this.subtitleTracks=e.subtitleTracks}onError(t,e){const{errorAction:r}=e;if((r==null?void 0:r.action)===Ir.SendAlternateToPenaltyBox&&r.flags===fi.MoveAllAlternatesMatchingHost){let n=this.pathwayPriority;const o=this.pathwayId;this.penalizedPathways[o]||(this.penalizedPathways[o]=performance.now()),!n&&this.levels&&(n=this.levels.reduce((l,d)=>(l.indexOf(d.pathwayId)===-1&&l.push(d.pathwayId),l),[])),n&&n.length>1&&(this.updatePathwayPriority(n),r.resolved=this.pathwayId!==o)}}filterParsedLevels(t){this.levels=t;let e=this.getLevelsForPathway(this.pathwayId);if(e.length===0){const r=t[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${r}"`),e=this.getLevelsForPathway(r),this.pathwayId=r}return e.length!==t.length?(this.log(`Found ${e.length}/${t.length} levels in Pathway "${this.pathwayId}"`),e):t}getLevelsForPathway(t){return this.levels===null?[]:this.levels.filter(e=>t===e.pathwayId)}updatePathwayPriority(t){this.pathwayPriority=t;let e;const r=this.penalizedPathways,n=performance.now();Object.keys(r).forEach(o=>{n-r[o]>JE&&delete r[o]});for(let o=0;o<t.length;o++){const l=t[o];if(r[l])continue;if(l===this.pathwayId)return;const d=this.hls.nextLoadLevel,f=this.hls.levels[d];if(e=this.getLevelsForPathway(l),e.length>0){this.log(`Setting Pathway to "${l}"`),this.pathwayId=l,this.hls.trigger(R.LEVELS_UPDATED,{levels:e});const p=this.hls.levels[d];f&&p&&this.levels&&(p.attrs["STABLE-VARIANT-ID"]!==f.attrs["STABLE-VARIANT-ID"]&&p.bitrate!==f.bitrate&&this.log(`Unstable Pathways change from bitrate ${f.bitrate} to ${p.bitrate}`),this.hls.nextLoadLevel=d);break}}}clonePathways(t){const e=this.levels;if(!e)return;const r={},n={};t.forEach(o=>{const{ID:l,"BASE-ID":d,"URI-REPLACEMENT":f}=o;if(e.some(g=>g.pathwayId===l))return;const p=this.getLevelsForPathway(d).map(g=>{const v=dr({},g);v.details=void 0,v.url=$p(g.uri,g.attrs["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",f);const E=new tr(g.attrs);E["PATHWAY-ID"]=l;const A=E.AUDIO&&`${E.AUDIO}_clone_${l}`,T=E.SUBTITLES&&`${E.SUBTITLES}_clone_${l}`;A&&(r[E.AUDIO]=A,E.AUDIO=A),T&&(n[E.SUBTITLES]=T,E.SUBTITLES=T),v.attrs=E;const w=new Ma(v);return qo(w,"audio",A),qo(w,"text",T),w});e.push(...p),Op(this.audioTracks,r,f,l),Op(this.subtitleTracks,n,f,l)})}loadSteeringManifest(t){const e=this.hls.config,r=e.loader;this.loader&&this.loader.destroy(),this.loader=new r(e);let n;try{n=new self.URL(t)}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest URI: ${t}`);return}if(n.protocol!=="data:"){const g=(this.hls.bandwidthEstimate||e.abrEwmaDefaultEstimate)|0;n.searchParams.set("_HLS_pathway",this.pathwayId),n.searchParams.set("_HLS_throughput",""+g)}const o={responseType:"json",url:n.href},l=e.steeringManifestLoadPolicy.default,d=l.errorRetry||l.timeoutRetry||{},f={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:d.maxNumRetry||0,retryDelay:d.retryDelayMs||0,maxRetryDelay:d.maxRetryDelayMs||0},p={onSuccess:(g,v,E,A)=>{this.log(`Loaded steering manifest: "${n}"`);const T=g.data;if(T.VERSION!==1){this.log(`Steering VERSION ${T.VERSION} not supported!`);return}this.updated=performance.now(),this.timeToLoad=T.TTL;const{"RELOAD-URI":w,"PATHWAY-CLONES":C,"PATHWAY-PRIORITY":D}=T;if(w)try{this.uri=new self.URL(w,n).href}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${w}`);return}this.scheduleRefresh(this.uri||E.url),C&&this.clonePathways(C),D&&this.updatePathwayPriority(D)},onError:(g,v,E,A)=>{if(this.log(`Error loading steering manifest: ${g.code} ${g.text} (${v.url})`),this.stopLoad(),g.code===410){this.enabled=!1,this.log(`Steering manifest ${v.url} no longer available`);return}let T=this.timeToLoad*1e3;if(g.code===429){const w=this.loader;if(typeof(w==null?void 0:w.getResponseHeader)=="function"){const C=w.getResponseHeader("Retry-After");C&&(T=parseFloat(C)*1e3)}this.log(`Steering manifest ${v.url} rate limited`);return}this.scheduleRefresh(this.uri||v.url,T)},onTimeout:(g,v,E)=>{this.log(`Timeout loading steering manifest (${v.url})`),this.scheduleRefresh(this.uri||v.url)}};this.log(`Requesting steering manifest: ${n}`),this.loader.load(o,f,p)}scheduleRefresh(t,e=this.timeToLoad*1e3){self.clearTimeout(this.reloadTimer),this.reloadTimer=self.setTimeout(()=>{this.loadSteeringManifest(t)},e)}}function Op(i,t,e,r){i&&Object.keys(t).forEach(n=>{const o=i.filter(l=>l.groupId===n).map(l=>{const d=dr({},l);return d.details=void 0,d.attrs=new tr(d.attrs),d.url=d.attrs.URI=$p(l.url,l.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",e),d.groupId=d.attrs["GROUP-ID"]=t[n],d.attrs["PATHWAY-ID"]=r,d});i.push(...o)})}function $p(i,t,e,r){const{HOST:n,PARAMS:o,[e]:l}=r;let d;t&&(d=l==null?void 0:l[t],d&&(i=d));const f=new self.URL(i);return n&&!d&&(f.host=n),o&&Object.keys(o).sort().forEach(p=>{p&&f.searchParams.set(p,o[p])}),f.href}const eA=/^age:\s*[\d.]+\s*$/im;class Mp{constructor(t){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=t&&t.xhrSetup||null,this.stats=new Ho,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null}abortInternal(){const t=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),t&&(t.onreadystatechange=null,t.onprogress=null,t.readyState!==4&&(this.stats.aborted=!0,t.abort()))}abort(){var t;this.abortInternal(),(t=this.callbacks)!=null&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(t,e,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=t,this.config=e,this.callbacks=r,this.loadInternal()}loadInternal(){const{config:t,context:e}=this;if(!t)return;const r=this.loader=new self.XMLHttpRequest,n=this.stats;n.loading.first=0,n.loaded=0,n.aborted=!1;const o=this.xhrSetup;o?Promise.resolve().then(()=>{if(!this.stats.aborted)return o(r,e.url)}).catch(l=>(r.open("GET",e.url,!0),o(r,e.url))).then(()=>{this.stats.aborted||this.openAndSendXhr(r,e,t)}).catch(l=>{this.callbacks.onError({code:r.status,text:l.message},e,r,n)}):this.openAndSendXhr(r,e,t)}openAndSendXhr(t,e,r){t.readyState||t.open("GET",e.url,!0);const n=this.context.headers,{maxTimeToFirstByteMs:o,maxLoadTimeMs:l}=r.loadPolicy;if(n)for(const d in n)t.setRequestHeader(d,n[d]);e.rangeEnd&&t.setRequestHeader("Range","bytes="+e.rangeStart+"-"+(e.rangeEnd-1)),t.onreadystatechange=this.readystatechange.bind(this),t.onprogress=this.loadprogress.bind(this),t.responseType=e.responseType,self.clearTimeout(this.requestTimeout),r.timeout=o&&jt(o)?o:l,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.timeout),t.send()}readystatechange(){const{context:t,loader:e,stats:r}=this;if(!t||!e)return;const n=e.readyState,o=this.config;if(!r.aborted&&n>=2&&(r.loading.first===0&&(r.loading.first=Math.max(self.performance.now(),r.loading.start),o.timeout!==o.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),o.timeout=o.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),o.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start)))),n===4)){self.clearTimeout(this.requestTimeout),e.onreadystatechange=null,e.onprogress=null;const l=e.status,d=e.responseType!=="text";if(l>=200&&l<300&&(d&&e.response||e.responseText!==null)){r.loading.end=Math.max(self.performance.now(),r.loading.first);const f=d?e.response:e.responseText,p=e.responseType==="arraybuffer"?f.byteLength:f.length;if(r.loaded=r.total=p,r.bwEstimate=r.total*8e3/(r.loading.end-r.loading.first),!this.callbacks)return;const g=this.callbacks.onProgress;if(g&&g(r,t,f,e),!this.callbacks)return;const v={url:e.responseURL,data:f,code:l};this.callbacks.onSuccess(v,r,t,e)}else{const f=o.loadPolicy.errorRetry,p=r.retry;Zo(f,p,!1,l)?this.retry(f):(X.error(`${l} while loading ${t.url}`),this.callbacks.onError({code:l,text:e.statusText},t,e,r))}}}loadtimeout(){var t;const e=(t=this.config)==null?void 0:t.loadPolicy.timeoutRetry,r=this.stats.retry;if(Zo(e,r,!0))this.retry(e);else{X.warn(`timeout while loading ${this.context.url}`);const n=this.callbacks;n&&(this.abortInternal(),n.onTimeout(this.stats,this.context,this.loader))}}retry(t){const{context:e,stats:r}=this;this.retryDelay=Qc(t,r.retry),r.retry++,X.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${e.url}, retrying ${r.retry}/${t.maxNumRetry} in ${this.retryDelay}ms`),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)}loadprogress(t){const e=this.stats;e.loaded=t.loaded,t.lengthComputable&&(e.total=t.total)}getCacheAge(){let t=null;if(this.loader&&eA.test(this.loader.getAllResponseHeaders())){const e=this.loader.getResponseHeader("age");t=e?parseFloat(e):null}return t}getResponseHeader(t){return this.loader&&new RegExp(`^${t}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(t):null}}function rA(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}const iA=/(\d+)-(\d+)\/(\d+)/;class Np{constructor(t){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=t.fetchSetup||oA,this.controller=new self.AbortController,this.stats=new Ho}destroy(){this.loader=this.callbacks=null,this.abortInternal()}abortInternal(){const t=this.response;t!=null&&t.ok||(this.stats.aborted=!0,this.controller.abort())}abort(){var t;this.abortInternal(),(t=this.callbacks)!=null&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(t,e,r){const n=this.stats;if(n.loading.start)throw new Error("Loader can only be used once.");n.loading.start=self.performance.now();const o=sA(t,this.controller.signal),l=r.onProgress,d=t.responseType==="arraybuffer",f=d?"byteLength":"length",{maxTimeToFirstByteMs:p,maxLoadTimeMs:g}=e.loadPolicy;this.context=t,this.config=e,this.callbacks=r,this.request=this.fetchSetup(t,o),self.clearTimeout(this.requestTimeout),e.timeout=p&&jt(p)?p:g,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),r.onTimeout(n,t,this.response)},e.timeout),self.fetch(this.request).then(v=>{this.response=this.loader=v;const E=Math.max(self.performance.now(),n.loading.start);if(self.clearTimeout(this.requestTimeout),e.timeout=g,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),r.onTimeout(n,t,this.response)},g-(E-n.loading.start)),!v.ok){const{status:A,statusText:T}=v;throw new lA(T||"fetch, bad network response",A,v)}return n.loading.first=E,n.total=aA(v.headers)||n.total,l&&jt(e.highWaterMark)?this.loadProgressively(v,n,t,e.highWaterMark,l):d?v.arrayBuffer():t.responseType==="json"?v.json():v.text()}).then(v=>{const{response:E}=this;self.clearTimeout(this.requestTimeout),n.loading.end=Math.max(self.performance.now(),n.loading.first);const A=v[f];A&&(n.loaded=n.total=A);const T={url:E.url,data:v,code:E.status};l&&!jt(e.highWaterMark)&&l(n,t,v,E),r.onSuccess(T,n,t,E)}).catch(v=>{if(self.clearTimeout(this.requestTimeout),n.aborted)return;const E=v&&v.code||0,A=v?v.message:null;r.onError({code:E,text:A},t,v?v.details:null,n)})}getCacheAge(){let t=null;if(this.response){const e=this.response.headers.get("age");t=e?parseFloat(e):null}return t}getResponseHeader(t){return this.response?this.response.headers.get(t):null}loadProgressively(t,e,r,n=0,o){const l=new dp,d=t.body.getReader(),f=()=>d.read().then(p=>{if(p.done)return l.dataLength&&o(e,r,l.flush(),t),Promise.resolve(new ArrayBuffer(0));const g=p.value,v=g.length;return e.loaded+=v,v<n||l.dataLength?(l.push(g),l.dataLength>=n&&o(e,r,l.flush(),t)):o(e,r,g,t),f()}).catch(()=>Promise.reject());return f()}}function sA(i,t){const e={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(dr({},i.headers))};return i.rangeEnd&&e.headers.set("Range","bytes="+i.rangeStart+"-"+String(i.rangeEnd-1)),e}function nA(i){const t=iA.exec(i);if(t)return parseInt(t[2])-parseInt(t[1])+1}function aA(i){const t=i.get("Content-Range");if(t){const r=nA(t);if(jt(r))return r}const e=i.get("Content-Length");if(e)return parseInt(e)}function oA(i,t){return new self.Request(i.url,t)}class lA extends Error{constructor(t,e,r){super(t),this.code=void 0,this.details=void 0,this.code=e,this.details=r}}const cA=/\s/,hA={newCue(i,t,e,r){const n=[];let o,l,d,f,p;const g=self.VTTCue||self.TextTrackCue;for(let E=0;E<r.rows.length;E++)if(o=r.rows[E],d=!0,f=0,p="",!o.isEmpty()){var v;for(let w=0;w<o.chars.length;w++)cA.test(o.chars[w].uchar)&&d?f++:(p+=o.chars[w].uchar,d=!1);o.cueStartTime=t,t===e&&(e+=1e-4),f>=16?f--:f++;const A=Rp(p.trim()),T=kh(t,e,A);i!=null&&(v=i.cues)!=null&&v.getCueById(T)||(l=new g(t,e,A),l.id=T,l.line=E+1,l.align="left",l.position=10+Math.min(80,Math.floor(f*8/32)*10),n.push(l))}return i&&n.length&&(n.sort((E,A)=>E.line==="auto"||A.line==="auto"?0:E.line>8&&A.line>8?A.line-E.line:E.line-A.line),n.forEach(E=>Lf(i,E))),n}},dA={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},uA=zr(zr({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:Mp,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:mE,bufferController:SE,capLevelController:Lh,errorController:l4,fpsController:ZE,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:tf,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,certLoadPolicy:{default:dA},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},fA()),{},{subtitleStreamController:AE,subtitleTrackController:kE,timelineController:zE,audioStreamController:yE,audioTrackController:bE,emeController:Mn,cmcdController:Is,contentSteeringController:tA});function fA(){return{cueHandler:hA,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 pA(i,t){if((t.liveSyncDurationCount||t.liveMaxLatencyDurationCount)&&(t.liveSyncDuration||t.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(t.liveMaxLatencyDurationCount!==void 0&&(t.liveSyncDurationCount===void 0||t.liveMaxLatencyDurationCount<=t.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(t.liveMaxLatencyDuration!==void 0&&(t.liveSyncDuration===void 0||t.liveMaxLatencyDuration<=t.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');const e=Ch(i),r=["manifest","level","frag"],n=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return r.forEach(o=>{const l=`${o==="level"?"playlist":o}LoadPolicy`,d=t[l]===void 0,f=[];n.forEach(p=>{const g=`${o}Loading${p}`,v=t[g];if(v!==void 0&&d){f.push(g);const E=e[l].default;switch(t[l]={default:E},p){case"TimeOut":E.maxLoadTimeMs=v,E.maxTimeToFirstByteMs=v;break;case"MaxRetry":E.errorRetry.maxNumRetry=v,E.timeoutRetry.maxNumRetry=v;break;case"RetryDelay":E.errorRetry.retryDelayMs=v,E.timeoutRetry.retryDelayMs=v;break;case"MaxRetryTimeout":E.errorRetry.maxRetryDelayMs=v,E.timeoutRetry.maxRetryDelayMs=v;break}}}),f.length&&X.warn(`hls.js config: "${f.join('", "')}" setting(s) are deprecated, use "${l}": ${JSON.stringify(t[l])}`)}),zr(zr({},e),t)}function Ch(i){return i&&typeof i=="object"?Array.isArray(i)?i.map(Ch):Object.keys(i).reduce((t,e)=>(t[e]=Ch(i[e]),t),{}):i}function gA(i){const t=i.loader;t!==Np&&t!==Mp?(X.log("[config]: Custom loader detected, cannot enable progressive streaming"),i.progressive=!1):rA()&&(i.loader=Np,i.progressive=!0,i.enableSoftwareAES=!0,X.log("[config]: Progressive streaming enabled, using FetchLoader"))}class os{static get version(){return"1.4.12"}static isSupported(){return _4()}static get Events(){return R}static get ErrorTypes(){return Qt}static get ErrorDetails(){return ut}static get DefaultConfig(){return os.defaultConfig?os.defaultConfig:uA}static set DefaultConfig(t){os.defaultConfig=t}constructor(t={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new ph,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,Jy(t.debug||!1,"Hls instance");const e=this.config=pA(os.DefaultConfig,t);this.userConfig=t,this._autoLevelCapping=-1,e.progressive&&gA(e);const{abrController:r,bufferController:n,capLevelController:o,errorController:l,fpsController:d}=e,f=new l(this),p=this.abrController=new r(this),g=this.bufferController=new n(this),v=this.capLevelController=new o(this),E=new d(this),A=new Vb(this),T=new Yb(this),w=e.contentSteeringController,C=w?new w(this):null,D=this.levelController=new h4(this,C),M=new d4(this),U=new f4(this.config),x=this.streamController=new pE(this,M,U);v.setStreamController(x),E.setStreamController(x);const O=[A,D,x];C&&O.splice(1,0,C),this.networkControllers=O;const K=[p,g,v,E,T,M];this.audioTrackController=this.createController(e.audioTrackController,O);const B=e.audioStreamController;B&&O.push(new B(this,M,U)),this.subtitleTrackController=this.createController(e.subtitleTrackController,O);const at=e.subtitleStreamController;at&&O.push(new at(this,M,U)),this.createController(e.timelineController,K),U.emeController=this.emeController=this.createController(e.emeController,K),this.cmcdController=this.createController(e.cmcdController,K),this.latencyController=this.createController(Xb,K),this.coreComponents=K,O.push(f);const st=f.onErrorOut;typeof st=="function"&&this.on(R.ERROR,st,f)}createController(t,e){if(t){const r=new t(this);return e&&e.push(r),r}return null}on(t,e,r=this){this._emitter.on(t,e,r)}once(t,e,r=this){this._emitter.once(t,e,r)}removeAllListeners(t){this._emitter.removeAllListeners(t)}off(t,e,r=this,n){this._emitter.off(t,e,r,n)}listeners(t){return this._emitter.listeners(t)}emit(t,e,r){return this._emitter.emit(t,e,r)}trigger(t,e){if(this.config.debug)return this.emit(t,t,e);try{return this.emit(t,t,e)}catch(r){X.error("An internal error happened while handling event "+t+'. Error message: "'+r.message+'". Here is a stacktrace:',r),this.trigger(R.ERROR,{type:Qt.OTHER_ERROR,details:ut.INTERNAL_EXCEPTION,fatal:!1,event:t,error:r})}return!1}listenerCount(t){return this._emitter.listenerCount(t)}destroy(){X.log("destroy"),this.trigger(R.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(e=>e.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(e=>e.destroy()),this.coreComponents.length=0;const t=this.config;t.xhrSetup=t.fetchSetup=void 0,this.userConfig=null}attachMedia(t){X.log("attachMedia"),this._media=t,this.trigger(R.MEDIA_ATTACHING,{media:t})}detachMedia(){X.log("detachMedia"),this.trigger(R.MEDIA_DETACHING,void 0),this._media=null}loadSource(t){this.stopLoad();const e=this.media,r=this.url,n=this.url=$c.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});X.log(`loadSource:${n}`),e&&r&&(r!==n||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(e)),this.trigger(R.MANIFEST_LOADING,{url:t})}startLoad(t=-1){X.log(`startLoad(${t})`),this.networkControllers.forEach(e=>{e.startLoad(t)})}stopLoad(){X.log("stopLoad"),this.networkControllers.forEach(t=>{t.stopLoad()})}swapAudioCodec(){X.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){X.log("recoverMediaError");const t=this._media;this.detachMedia(),t&&this.attachMedia(t)}removeLevel(t,e=0){this.levelController.removeLevel(t,e)}get levels(){return this.levelController.levels||[]}get currentLevel(){return this.streamController.currentLevel}set currentLevel(t){X.log(`set currentLevel:${t}`),this.loadLevel=t,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(t){X.log(`set nextLevel:${t}`),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(t){X.log(`set loadLevel:${t}`),this.levelController.manualLevel=t}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(t){this.levelController.nextLoadLevel=t}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(t){X.log(`set firstLevel:${t}`),this.levelController.firstLevel=t}get startLevel(){return this.levelController.startLevel}set startLevel(t){X.log(`set startLevel:${t}`),t!==-1&&(t=Math.max(t,this.minAutoLevel)),this.levelController.startLevel=t}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(t){const e=!!t;e!==this.config.capLevelToPlayerSize&&(e?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=e)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){const{bwEstimator:t}=this.abrController;return t?t.getEstimate():NaN}get ttfbEstimate(){const{bwEstimator:t}=this.abrController;return t?t.getEstimateTTFB():NaN}set autoLevelCapping(t){this._autoLevelCapping!==t&&(X.log(`set autoLevelCapping:${t}`),this._autoLevelCapping=t)}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(t){Xc.indexOf(t)>-1&&(this._maxHdcpLevel=t)}get autoLevelEnabled(){return this.levelController.manualLevel===-1}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){const{levels:t,config:{minAutoBitrate:e}}=this;if(!t)return 0;const r=t.length;for(let n=0;n<r;n++)if(t[n].maxBitrate>=e)return n;return 0}get maxAutoLevel(){const{levels:t,autoLevelCapping:e,maxHdcpLevel:r}=this;let n;if(e===-1&&t&&t.length?n=t.length-1:n=e,r)for(let o=n;o--;){const l=t[o].attrs["HDCP-LEVEL"];if(l&&l<=r)return o}return n}get nextAutoLevel(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)}set nextAutoLevel(t){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,t)}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}get audioTracks(){const t=this.audioTrackController;return t?t.audioTracks:[]}get audioTrack(){const t=this.audioTrackController;return t?t.audioTrack:-1}set audioTrack(t){const e=this.audioTrackController;e&&(e.audioTrack=t)}get subtitleTracks(){const t=this.subtitleTrackController;return t?t.subtitleTracks:[]}get subtitleTrack(){const t=this.subtitleTrackController;return t?t.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(t){const e=this.subtitleTrackController;e&&(e.subtitleTrack=t)}get subtitleDisplay(){const t=this.subtitleTrackController;return t?t.subtitleDisplay:!1}set subtitleDisplay(t){const e=this.subtitleTrackController;e&&(e.subtitleDisplay=t)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(t){this.config.lowLatencyMode=t}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}}os.defaultConfig=void 0;function mA(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function vA(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function Ih(i){const{id:t,key:e,src:r,playlist:n,duration:o}=i;return new Promise(l=>{let d=null;const f=document.createElement("video");if(f.playsInline=!0,f.muted=!0,f.loop=!1,n&&!mA()&&os.isSupported()){let p=!1;d=new os({autoStartLoad:!0,xhrSetup:g=>{const{open:v}=g,E=n.split("?")[1];g.open=function(A,T,w){T.toString().includes("?")||(T+="?"+E),v.apply(this,[A,T,w])}}}),d.loadSource(n),d.attachMedia(f),d.startLoadOnce=(g=-1,v)=>{if(d&&!p){const E=d==null?void 0:d.levels.findIndex(A=>Math.min(A.height,A.width)===v);d.startLevel=d.firstLevel,d.startLoad(g),p=!0,d.currentLevel=E!==-1?E:d.firstLevel}},d.on(os.Events.LEVEL_LOADED,async()=>{p||d==null||d.stopLoad(),l({id:t,key:e,hls:d,config:i,node:f})})}else{f.src=r;let p=!1;if(f.startLoadOnce=()=>{p||(f.preload="auto",f.load(),p=!0)},o)f.preload="none",l({id:t,key:e,hls:d,config:i,node:f});else{f.preload="metadata";const g=async()=>{l({id:t,key:e,hls:d,config:i,node:f}),f.removeEventListener("loadedmetadata",g)};f.addEventListener("loadedmetadata",g)}}})}async function Fp(i){return i.duration===1/0?new Promise(t=>{i.currentTime=Number.MAX_SAFE_INTEGER,i.ontimeupdate=()=>{i.ontimeupdate=null,t(i.duration),i.currentTime=0}}):i.duration}const yA=ws(async function(i){return new FontFace(i.name,`url(${i.woff2??i.url})`,{style:i.style,weight:i.weight}).load()},{cacheKey:([i])=>JSON.stringify(i)});let bA=class{constructor(i){this._hasPlayed=!1,this._memoKey=null,this._lastDeps=null,this._duration=0,this._scenes=null,this._videos={},this._videoMeta={},this._videoState={},this._resolveVideo=ws(async t=>{const{id:e,key:r}=t,n=await Ih(t);n.node.volume=this.host.volume,n.node.playbackRate=this.host.playbackRate;const o={loadeddata:this._handleLoadedData,waiting:this._handleWaiting,canplay:this._handleCanPlay,progress:this._handleProgress,seeking:this._handleSeeking,seeked:this._handleSeeked,play:this._handlePlay,playing:this._handlePlaying,pause:this._handlePause,stalled:this._handleStalled,timeupdate:this._handleTimeUpdate,ended:this._handleEnded,error:this._handleError},l=Object.keys(o).reduce((d,f)=>{const p=f,g=o[p]({id:e,key:r,node:n.node});return d[p]=g,n.node.addEventListener(f,g),d},{});return{...n,listeners:l}},{cacheKey:([{id:t,key:e,src:r,playlist:n}])=>JSON.stringify({id:t,key:e,src:r==null?void 0:r.split("?")[0],playlist:n==null?void 0:n.split("?")[0]})}),this._resolveVideoMeta=ws(async(t,e)=>{const{id:r,captions:n,duration:o,startOffset:l,endOffset:d}=t,f=o??await Fp(e),p=(l??0)*f,g=(1-(d??0))*f;return{id:r,captions:n,start:p,duration:g-p}},{cacheKey:([{id:t,key:e,captions:r,duration:n,startOffset:o,endOffset:l}])=>JSON.stringify({id:t,key:e,captions:r,duration:n,startOffset:o,endOffset:l})}),this._handleLoadedData=({id:t,key:e,node:r})=>()=>{var n,o;const l=this.videoState[e];if(!(l!=null&&l.initialised)){this.videoState={...this.videoState,[e]:{...l,initialised:!0,waiting:!1,buffered:(l==null?void 0:l.buffered)??[]}};const d=(o=(n=this.scenes)==null?void 0:n.scenes)==null?void 0:o.find(({video:f})=>{f==null||f.key});d&&this._setVideoCurrentTime({scene:d,time:this.host.currentTime}),this.host.dispatchEvent(new CustomEvent("video:loadeddata",{detail:{id:t,key:e,node:r}}))}},this._handleWaiting=({key:t})=>()=>{const e=this.videoState[t];e!=null&&e.initialised&&!(e!=null&&e.waiting)&&(this.videoState={...this.videoState,[t]:{...e,waiting:!0}})},this._handleCanPlay=({key:t})=>()=>{const e=this.videoState[t];e!=null&&e.initialised&&e!=null&&e.waiting&&(this.videoState={...this.videoState,[t]:{...e,waiting:!1}}),this.host.paused&&this.host.draw()},this._handleProgress=({key:t,node:e})=>()=>{const r=this.videoState[t],n=this._getBufferSegments({key:t,node:e,duration:this.host.duration});this.videoState={...this.videoState,[t]:{...r,buffered:n}}},this._handleSeeking=({id:t,key:e,node:r})=>()=>{this.host.dispatchEvent(new CustomEvent("video:seeking",{detail:{id:t,key:e,node:r}}))},this._handleSeeked=({id:t,key:e,node:r})=>()=>{const n=this.videoState[e];n!=null&&n.initialised&&(this.host.draw(),this.host.dispatchEvent(new CustomEvent("video:seeked",{detail:{id:t,key:e,node:r}})))},this._handlePlay=({id:t,key:e,node:r})=>()=>{this.hasPlayed=!0,this.host.dispatchEvent(new CustomEvent("video:play",{detail:{id:t,key:e,node:r}}))},this._handlePlaying=({id:t,key:e,node:r})=>()=>{this.host.dispatchEvent(new CustomEvent("video:playing",{detail:{id:t,key:e,node:r}}))},this._handlePause=({id:t,key:e,node:r})=>()=>{this.host.dispatchEvent(new CustomEvent("video:pause",{detail:{id:t,key:e,node:r}}))},this._handleStalled=({id:t,key:e,node:r})=>()=>{this.host.dispatchEvent(new CustomEvent("video:stalled",{detail:{id:t,key:e,node:r}}))},this._handleTimeUpdate=({id:t,key:e,node:r})=>()=>{this.host.dispatchEvent(new CustomEvent("video:timeupdate",{detail:{id:t,key:e,node:r}}))},this._handleEnded=({id:t,key:e,node:r})=>()=>{this.host.dispatchEvent(new CustomEvent("video:ended",{detail:{id:t,key:e,node:r}}))},this._handleError=({id:t,key:e,node:r})=>()=>{const n=new Ni(`Video error - answer ${t} failed to load`);this.host.dispatchEvent(new ErrorEvent("error",{bubbles:!0,composed:!0,error:n,message:n.message})),this.host.dispatchEvent(new CustomEvent("video:error",{detail:{id:t,key:e,node:r}}))},this._cleanupVideo=t=>{var e;const r=this.videos[t];r&&(r.node.pause(),r.node.src="",(e=r.hls)==null||e.destroy(),Object.keys(r.listeners??{}).forEach(n=>{var o,l;if((o=this.videos)!=null&&o[t]){const d=(l=r.listeners)==null?void 0:l[n];d&&r.node.removeEventListener(n,d)}}),delete this.videos[t])},this.host=i,this.host.addController(this)}set hasPlayed(i){i!==this._hasPlayed&&(this._hasPlayed=i,this.host.requestUpdate())}get hasPlayed(){return this._hasPlayed}set duration(i){!isNaN(i)&&i!==this._duration&&(this._duration=i,this.host.requestUpdate(),this.host.dispatchEvent(new CustomEvent("durationchange",{detail:this._duration})))}get duration(){return this._duration}set scenes(i){i!==this._scenes&&(this._scenes=i,this.host.requestUpdate())}get scenes(){return this._scenes}set videos(i){i!==this._videos&&(this._videos=i,this.host.requestUpdate())}get videos(){return this._videos}set videoMeta(i){i!==this._videoMeta&&(this._videoMeta=i,this.host.requestUpdate())}get videoMeta(){return this._videoMeta}set videoState(i){i!==this._videoState&&(this._videoState=i,this.host.requestUpdate())}get videoState(){return this._videoState}_getBufferSegments({key:i,node:t,duration:e}){var r;const n=t==null?void 0:t.buffered,o=[],{start:l,video:d,videoMeta:f}=((r=this.scenes)==null?void 0:r.scenes.find(({video:p})=>i===(p==null?void 0:p.key)))??{};if(t&&n&&d&&f&&typeof l<"u")for(let p=0;p<n.length;p++){const g=n.start(p),v=n.end(p);Math.max(g,f.start)<=Math.min(v,f.start+f.duration)&&o.push({start:Math.max(0,(Math.max(g-f.start,0)+l)/e*100),end:Math.min((Math.min(v-f.start,f.duration)+l)/e*100,100)})}return o}_setupTask(){new co(this.host,async([i,t,e,r,n,o])=>{try{let l=null;if(this.host._errors=[],e||i){if(this.host._processing=!0,e){let f=null;if(r)try{f=await(await fetch(r,{method:"GET"})).text()}catch(g){const v=new Ni("Track failed to fetch",g);this.host.dispatchEvent(new ErrorEvent("error",{composed:!0,bubbles:!0,error:v,message:v.message}))}const p={questions:{items:[{answer:{id:"source",media:{[e.includes(".m3u8")?"playlist":"video"]:e},captions:{current:f}}}]}};try{this.scenes=await Sn({data:p,template:t,burnCaptions:n,debug:o},this._resolveVideo,this._resolveVideoMeta)}catch(g){try{this.scenes=await Sn({data:p,burnCaptions:n,debug:o},this._resolveVideo,this._resolveVideoMeta)}catch(v){throw new Ni("Fatal source template error",v,!0)}l=new Ni("Source template error",g)}}else try{this.scenes=await Sn({data:i,template:t,burnCaptions:n,debug:o},this._resolveVideo,this._resolveVideoMeta)}catch(f){try{this.scenes=await Sn({data:i,burnCaptions:n,debug:o},this._resolveVideo,this._resolveVideoMeta)}catch(p){throw new Ni("Fatal data template error",p,!0)}l=new Ni("Data template error",f)}Object.keys(this.videos).forEach(f=>{this.scenes.scenes.find(({video:p})=>f===(p==null?void 0:p.key))||this._videos[f].node.pause()});const d=this.scenes.scenes.reduce((f,{video:p})=>(p&&(f[p.key]=p),f),{});Object.keys(this.videos).join("|")!==Object.keys(d).join("|")&&this.host.reset(0,!1),this.videos=d,this.videoState={...this.videoState,...this.scenes.scenes.reduce((f,{video:p,start:g,duration:v})=>{var E;const A=(p==null?void 0:p.key)??`${g}-${v}`,T=this._getBufferSegments({key:A,node:p==null?void 0:p.node,duration:this.scenes.duration});return f[A]={initialised:!p,waiting:!!p,...this.videoState[A],buffered:p?T:(E=this.videoState[A])==null?void 0:E.buffered},f},{})},this.videoMeta=this.scenes.scenes.reduce((f,{video:p,videoMeta:g})=>(p&&g&&(f[p.key]=g),f),{}),(await Promise.all(this.scenes.fonts.map(f=>yA(f)))).forEach(f=>{document.fonts.add(f)}),this.duration=this.scenes.duration,this.host.paused&&this.host.reset(this.host.currentTime,!this.host.paused)}l&&this.host.dispatchEvent(new ErrorEvent("error",{composed:!0,bubbles:!0,error:l,message:l.message}))}catch(l){this.scenes=null,this.duration=0,this.host.dispatchEvent(new ErrorEvent("error",{composed:!0,bubbles:!0,error:l,message:l.message}))}finally{this.host._processing=!1}},()=>{const i=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===i)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=i,this._lastDeps=t,t})}_setVideoCurrentTime({time:i,scene:t}){const{start:e,video:r,videoMeta:n}=t;if(r&&r.node&&n&&typeof e<"u"){const o=i-e;r.node.currentTime=Math.max(n.start,Math.min(n.start+n.duration,o+n.start))}}setVideosCurrentTime(i){var t;(t=this.scenes)==null||t.scenes.forEach(e=>{this._setVideoCurrentTime({time:i,scene:e})})}hostConnected(){this._setupTask()}hostDisconnected(){Object.keys(this.videos).forEach(i=>{this._cleanupVideo(i)}),this.videos={}}};function EA(i){i.requestFullscreen?i.requestFullscreen():i.mozRequestFullScreen?i.mozRequestFullScreen():i.webkitRequestFullscreen?i.webkitRequestFullscreen():i.msRequestFullscreen&&i.msRequestFullscreen()}function AA(){document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen&&document.webkitExitFullscreen()}const xh=["progress","play-large","navigation","play","volume","current-time","duration","speed","captions","fullscreen","preview"],TA={id:"captions",event:"captions:click",label:"Closed Captions"},kA={id:"fullscreen",event:"fullscreen:click",label:"Full Screen"},Up={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}]},wA={id:"playbackRate",label:"Playback playbackRate",subItems:Up};class SA extends au{constructor(t){if(super(t),this.element=null,this.observer=void 0,t.type!==kn.ELEMENT)throw new Error("Resize directive must be used in an Element expression")}disconnected(){var t;(t=this.observer)==null||t.disconnect(),this.observer=void 0}reconnected(){var t;this.element&&((t=this.observer)==null||t.observe(this.element))}update(t,[e]){return this.isConnected&&!this.observer&&(this.observer=new ResizeObserver(e),this.element=t.element,this.observer.observe(this.element)),As}}const Dh=wn(SA);var Bp=Number.isNaN||function(i){return typeof i=="number"&&i!==i};function RA(i,t){return!!(i===t||Bp(i)&&Bp(t))}function _A(i,t){if(i.length!==t.length)return!1;for(var e=0;e<i.length;e++)if(!RA(i[e],t[e]))return!1;return!0}function LA(i,t){t===void 0&&(t=_A);var e=null;function r(){for(var n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];if(e&&e.lastThis===this&&t(n,e.lastArgs))return e.lastResult;var l=i.apply(this,n);return e={lastResult:l,lastArgs:n,lastThis:this},l}return r.clear=function(){e=null},r}const CA=LA(()=>{const i=new FontFace("Roobert","url(https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/Roobert-Regular.woff2)",{style:"normal",weight:"400"}),t=new FontFace("Roobert","url(https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/Roobert-SemiBold.woff2)",{style:"normal",weight:"600"}),e=new FontFace("Roobert Captions","url(https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/Roobert-Regular.woff2)",{style:"normal",weight:"400"}),r=qu.map(n=>({load:!1,font:new FontFace(n.family,`url(${n.url})`,{style:n.style})}));return[{load:!0,font:i},{load:!0,font:t},{load:!0,font:e},...r]}),Gi={"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"},IA={colors:Gi,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 ${Gi["dark-100"]}`,medium:`0 .125rem .625rem ${Gi["dark-100"]}`,large:`0 .25rem 1rem ${Gi["dark-50"]}`,xl:`.25rem .25rem 1rem ${Gi["dark-250"]}`,xxl:`0 .25rem 2rem ${Gi["dark-100"]}`,xxxl:`.25rem .25rem 3rem ${Gi["dark-250"]}`,toolbar:`0 -.625rem .625rem ${Gi["dark-50"]}`,text:`0 0 .25rem ${Gi["dark-250"]}`},timings:{fast:".1s",normal:".2s",slow:".3s"},easings:{linear:"linear"},focusOutline:{width:".2rem",color:Gi["dark-400"]},iconSizes:{small:"0.75rem",medium:"1rem",large:"1.5rem"}},Gp=gv.flatten(IA,{delimiter:"-"}),xA=Object.keys(Gp).map(i=>ra(`:host { --${i}: ${Gp[i]}; }`)),DA=i=>{class t extends i{firstUpdated(){CA().forEach(({load:r,font:n})=>{document.fonts.add(n),r&&n.load()})}}return t.styles=[(i==null?void 0:i.styles)??[],xA,cr`
209
209
  :host {
210
210
  font-family: var(--fontFamilies-sans);
211
211
  font-size: var(--fontSizes-medium);
@@ -286,7 +286,7 @@ ${t}`,t1=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),e1=Objec
286
286
  scroll-behavior: auto !important;
287
287
  }
288
288
  }
289
- `],t},xe=PA(ts),OA=(i,t)=>(typeof window<"u"&&(window.customElements.get(i)??window.customElements.define(i,t)),t),$A=(i,t)=>{const{kind:e,elements:r}=t;return{kind:e,elements:r,finisher(n){typeof window<"u"&&(window.customElements.get(i)??window.customElements.define(i,n))}}},Fr=i=>t=>typeof t=="function"?OA(i,t):$A(i,t);class MA{constructor(t){this._memoKey=null,this._lastDeps=null,this._scenes=null,this._video=null,this._handleSeeked=()=>{this.host._draw()},this._resolveVideo=ws(async e=>{const r=await Ih(e);return r.node.play=async()=>{},r.node.addEventListener("seeked",this._handleSeeked),r},{cacheKey:([{id:e,src:r,playlist:n}])=>JSON.stringify({id:e,src:r==null?void 0:r.split("?")[0],playlist:n==null?void 0:n.split("?")[0]})}),this._resolveAnswer=ws(async e=>{const{id:r,key:n,poster:o}=e,{node:l}=await Ih(e),d=new Image;return{id:r,key:n,config:e,node:l,getSource:()=>(o&&d.src!==o&&(d.onload=()=>{this.host._draw()},d.src=o),d)}},{cacheKey:([{id:e,src:r,playlist:n,poster:o}])=>JSON.stringify({id:e,src:r==null?void 0:r.split("?")[0],playlist:n==null?void 0:n.split("?")[0],poster:o==null?void 0:o.split("?")[0]})}),this._resolveVideoMeta=ws(async(e,r)=>{const{id:n,duration:o,startOffset:l,endOffset:d}=e,f=o??await Fp(r),p=(l??0)*f,g=(1-(d??0))*f;return{id:n,start:p,duration:g-p}},{cacheKey:([{id:e,duration:r,startOffset:n,endOffset:o}])=>JSON.stringify({id:e,duration:r,startOffset:n,endOffset:o})}),this.host=t,this.host.addController(this)}set scenes(t){t!==this._scenes&&(this._scenes=t,this.host.requestUpdate())}get scenes(){return this._scenes}_setupTask(){new co(this.host,async([t,e,r])=>{var n,o;try{if(t){const l=t.includes(".m3u8")?"playlist":"video";try{this.scenes=await Sn({data:{questions:{items:[{answer:{id:"source",media:{[l]:t}}}]}},template:r},this._resolveVideo,this._resolveVideoMeta)}catch(d){throw new Ni("Video preview source template error",d)}this._video=((o=(n=this.scenes.scenes[0])==null?void 0:n.video)==null?void 0:o.node)??null}else if(e)try{this.scenes=await Sn({data:e,template:r},this._resolveAnswer,this._resolveVideoMeta)}catch(l){throw new Ni("Video preview data template error",l)}}catch(l){this.scenes=null,this.host.dispatchEvent(new ErrorEvent("error",{composed:!0,bubbles:!0,error:l,message:l.message}))}},()=>{const t=JSON.stringify({data:this.host.data,template:this.host.template});if(this._lastDeps&&this._memoKey===t)return this._lastDeps;const e=[this.host.src,this.host.data,this.host.template];return this._memoKey=t,this._lastDeps=e,e})}hostConnected(){this._setupTask()}hostDisconnected(){this._video&&(this._video.pause(),this._video.removeEventListener("seeked",this._handleSeeked),this._video.src="",this._video=null)}}function Hp(i,t,e){return Math.min(Math.max(t,i),e)}function Ph(i,t={}){const e=Math.max(0,i||0),r=Math.floor(e/3600),n=Math.floor(e%3600/60),o=Math.floor(e%3600%60),l=Math.floor(e%1*1e3);let d=r?`${r}:${`${n}`.padStart(2,"0")}:${`${o}`.padStart(2,"0")}`:`${n}:${`${o}`.padStart(2,"0")}`;return t.includeMs&&(d+=`:${`${l}`.padStart(3,"0")}`),d}var NA=Object.defineProperty,FA=Object.getOwnPropertyDescriptor,Nn=(i,t,e,r)=>{for(var n=r>1?void 0:r?FA(t,e):t,o=i.length-1,l;o>=0;o--)(l=i[o])&&(n=(r?l(t,e,n):l(n))||n);return r&&n&&NA(t,e,n),n};let xs=class extends xe{constructor(){super(...arguments),this.active=!1,this.size="small",this.rounded="medium",this.weight="light"}render(){return Yt`<button
289
+ `],t},xe=DA(ts),PA=(i,t)=>(typeof window<"u"&&(window.customElements.get(i)??window.customElements.define(i,t)),t),OA=(i,t)=>{const{kind:e,elements:r}=t;return{kind:e,elements:r,finisher(n){typeof window<"u"&&(window.customElements.get(i)??window.customElements.define(i,n))}}},Fr=i=>t=>typeof t=="function"?PA(i,t):OA(i,t);class $A{constructor(t){this._memoKey=null,this._lastDeps=null,this._scenes=null,this._video=null,this._handleSeeked=()=>{this.host._draw()},this._resolveVideo=ws(async e=>{const r=await Ih(e);return r.node.play=async()=>{},r.node.addEventListener("seeked",this._handleSeeked),r},{cacheKey:([{id:e,src:r,playlist:n}])=>JSON.stringify({id:e,src:r==null?void 0:r.split("?")[0],playlist:n==null?void 0:n.split("?")[0]})}),this._resolveAnswer=ws(async e=>{const{id:r,key:n,poster:o}=e,{node:l}=await Ih(e),d=new Image;return{id:r,key:n,config:e,node:l,getSource:()=>(o&&d.src!==o&&(d.onload=()=>{this.host._draw()},d.src=o),d)}},{cacheKey:([{id:e,src:r,playlist:n,poster:o}])=>JSON.stringify({id:e,src:r==null?void 0:r.split("?")[0],playlist:n==null?void 0:n.split("?")[0],poster:o==null?void 0:o.split("?")[0]})}),this._resolveVideoMeta=ws(async(e,r)=>{const{id:n,duration:o,startOffset:l,endOffset:d}=e,f=o??await Fp(r),p=(l??0)*f,g=(1-(d??0))*f;return{id:n,start:p,duration:g-p}},{cacheKey:([{id:e,duration:r,startOffset:n,endOffset:o}])=>JSON.stringify({id:e,duration:r,startOffset:n,endOffset:o})}),this.host=t,this.host.addController(this)}set scenes(t){t!==this._scenes&&(this._scenes=t,this.host.requestUpdate())}get scenes(){return this._scenes}_setupTask(){new co(this.host,async([t,e,r])=>{var n,o;try{if(t){const l=t.includes(".m3u8")?"playlist":"video";try{this.scenes=await Sn({data:{questions:{items:[{answer:{id:"source",media:{[l]:t}}}]}},template:r},this._resolveVideo,this._resolveVideoMeta)}catch(d){throw new Ni("Video preview source template error",d)}this._video=((o=(n=this.scenes.scenes[0])==null?void 0:n.video)==null?void 0:o.node)??null}else if(e)try{this.scenes=await Sn({data:e,template:r},this._resolveAnswer,this._resolveVideoMeta)}catch(l){throw new Ni("Video preview data template error",l)}}catch(l){this.scenes=null,this.host.dispatchEvent(new ErrorEvent("error",{composed:!0,bubbles:!0,error:l,message:l.message}))}},()=>{const t=JSON.stringify({data:this.host.data,template:this.host.template});if(this._lastDeps&&this._memoKey===t)return this._lastDeps;const e=[this.host.src,this.host.data,this.host.template];return this._memoKey=t,this._lastDeps=e,e})}hostConnected(){this._setupTask()}hostDisconnected(){this._video&&(this._video.pause(),this._video.removeEventListener("seeked",this._handleSeeked),this._video.src="",this._video=null)}}function Hp(i,t,e){return Math.min(Math.max(t,i),e)}function Ph(i,t={}){const e=Math.max(0,i||0),r=Math.floor(e/3600),n=Math.floor(e%3600/60),o=Math.floor(e%3600%60),l=Math.floor(e%1*1e3);let d=r?`${r}:${`${n}`.padStart(2,"0")}:${`${o}`.padStart(2,"0")}`:`${n}:${`${o}`.padStart(2,"0")}`;return t.includeMs&&(d+=`:${`${l}`.padStart(3,"0")}`),d}var MA=Object.defineProperty,NA=Object.getOwnPropertyDescriptor,Nn=(i,t,e,r)=>{for(var n=r>1?void 0:r?NA(t,e):t,o=i.length-1,l;o>=0;o--)(l=i[o])&&(n=(r?l(t,e,n):l(n))||n);return r&&n&&MA(t,e,n),n};let xs=class extends xe{constructor(){super(...arguments),this.active=!1,this.size="small",this.rounded="medium",this.weight="light"}render(){return Yt`<button
290
290
  class=${He({active:this.active,"size-tiny":this.size==="tiny","size-small":this.size==="small","size-large":this.size==="large","radius-medium":this.rounded==="medium","radius-full":this.rounded==="full","weight-light":this.weight==="light","weight-heavy":this.weight==="heavy"})}
291
291
  >
292
292
  <slot></slot>
@@ -528,14 +528,14 @@ ${t}`,t1=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),e1=Objec
528
528
  <path
529
529
  d="M9.853 23.246L4.86 7.688H0L7 27.42h5.52l7.265-19.733h-4.65L9.854 23.246zM95.12 7.08a8.905 8.905 0 00-4.648 1.294V0H86.14v27.419h4.332V16.087a4.656 4.656 0 014.649-4.65 4.656 4.656 0 014.649 4.65v11.332h4.332V16.087c.026-4.966-4.015-9.008-8.981-9.008zM57.188 19.02a4.656 4.656 0 01-4.649 4.649 4.656 4.656 0 01-4.649-4.65V7.689h-4.332V19.02c0 4.966 4.041 8.98 8.981 8.98 4.94 0 8.981-4.04 8.981-8.98V7.688h-4.332V19.02zM30.483 7.133c-5.732 0-10.408 4.675-10.408 10.407s4.676 10.408 10.408 10.408c5.732 0 10.408-4.676 10.408-10.408 0-5.732-4.676-10.407-10.408-10.407zm0 16.483a6.076 6.076 0 116.075-6.076c0 3.355-2.747 6.076-6.075 6.076zM74.517 23.616a6.076 6.076 0 010-12.151 6.132 6.132 0 015.045 2.668l3.592-2.43a10.473 10.473 0 00-8.637-4.57c-5.732 0-10.408 4.675-10.408 10.407s4.676 10.408 10.408 10.408a10.35 10.35 0 008.611-4.596l-3.593-2.43a5.975 5.975 0 01-5.018 2.694z"
530
530
  />
531
- </svg>`};var UA=Object.defineProperty,BA=Object.getOwnPropertyDescriptor,Wp=(i,t,e,r)=>{for(var n=r>1?void 0:r?BA(t,e):t,o=i.length-1,l;o>=0;o--)(l=i[o])&&(n=(r?l(t,e,n):l(n))||n);return r&&n&&UA(t,e,n),n};let ll=class extends xe{render(){return!this.icon||!Object.keys(Vp).includes(this.icon)?null:Vp[this.icon]()}};ll.styles=[xe.styles??[],cr`
531
+ </svg>`};var FA=Object.defineProperty,UA=Object.getOwnPropertyDescriptor,Wp=(i,t,e,r)=>{for(var n=r>1?void 0:r?UA(t,e):t,o=i.length-1,l;o>=0;o--)(l=i[o])&&(n=(r?l(t,e,n):l(n))||n);return r&&n&&FA(t,e,n),n};let ll=class extends xe{render(){return!this.icon||!Object.keys(Vp).includes(this.icon)?null:Vp[this.icon]()}};ll.styles=[xe.styles??[],cr`
532
532
  :host {
533
533
  display: flex;
534
534
  align-items: center;
535
535
  justify-content: center;
536
536
  flex-shrink: 0;
537
537
  }
538
- `],Wp([At({type:String})],ll.prototype,"icon",2),ll=Wp([Fr("vmp-icon")],ll);var GA=Object.defineProperty,HA=Object.getOwnPropertyDescriptor,Fn=(i,t,e,r)=>{for(var n=r>1?void 0:r?HA(t,e):t,o=i.length-1,l;o>=0;o--)(l=i[o])&&(n=(r?l(t,e,n):l(n))||n);return r&&n&&GA(t,e,n),n};let Ds=class extends xe{constructor(){super(...arguments),this.active=!1,this.size="small",this.rounded="medium",this.weight="light"}render(){return Yt`
538
+ `],Wp([At({type:String})],ll.prototype,"icon",2),ll=Wp([Fr("vmp-icon")],ll);var BA=Object.defineProperty,GA=Object.getOwnPropertyDescriptor,Fn=(i,t,e,r)=>{for(var n=r>1?void 0:r?GA(t,e):t,o=i.length-1,l;o>=0;o--)(l=i[o])&&(n=(r?l(t,e,n):l(n))||n);return r&&n&&BA(t,e,n),n};let Ds=class extends xe{constructor(){super(...arguments),this.active=!1,this.size="small",this.rounded="medium",this.weight="light"}render(){return Yt`
539
539
  <vmp-button
540
540
  ?active=${this.active}
541
541
  size=${hr(this.size)}
@@ -562,7 +562,7 @@ ${t}`,t1=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),e1=Objec
562
562
  height: 32px;
563
563
  width: 32px;
564
564
  }
565
- `],Fn([At({type:Boolean})],Ds.prototype,"active",2),Fn([At({type:String})],Ds.prototype,"size",2),Fn([At({type:String})],Ds.prototype,"rounded",2),Fn([At({type:String})],Ds.prototype,"weight",2),Fn([At({type:String})],Ds.prototype,"icon",2),Ds=Fn([Fr("vmp-icon-button")],Ds);var VA=Object.defineProperty,WA=Object.getOwnPropertyDescriptor,qr=(i,t,e,r)=>{for(var n=r>1?void 0:r?WA(t,e):t,o=i.length-1,l;o>=0;o--)(l=i[o])&&(n=(r?l(t,e,n):l(n))||n);return r&&n&&VA(t,e,n),n};let ls=class extends xe{constructor(){super(...arguments),this.disabled=!1,this.aspectRatio=1,this.compilation=tc,this._currentTime=0,this._sceneController=new MA(this),this._canvasRef=wr(),this._previewRef=wr(),this._previewTimeRef=wr(),this._handleScrubberMouseEnter=({detail:{x:i,y:t,elementLeft:e,elementRight:r}})=>{var n,o;if((n=this._previewRef)!=null&&n.value){const l=this._previewRef.value.getBoundingClientRect(),d=(o=this._previewRef.value.getRootNode().host)==null?void 0:o.getBoundingClientRect();l&&d&&(this._previewRef.value.style.opacity="1",this._previewRef.value.style.transform=`translate3d(${Hp(e-d.left,i-d.left-l.width/2,r-d.left-l.width)}px, ${t-d.top-l.height-28}px, 0)`)}},this._handleScrubberMouseMove=({detail:{time:i,x:t,elementLeft:e,elementRight:r}})=>{var n,o,l,d,f,p,g,v;if(this._currentTime=i,(n=this._sceneController.scenes)!=null&&n.scenes.length){const E=(f=(d=(l=(o=this._sceneController.scenes)==null?void 0:o.scenes)==null?void 0:l.find(({start:A,duration:T,video:w})=>w&&i>=A&&i<=A+T))==null?void 0:d.video)==null?void 0:f.node;if(E&&(E.currentTime=i),this._draw(),(p=this._previewRef)!=null&&p.value){const A=this._previewRef.value.getBoundingClientRect(),T=(g=this._previewRef.value.getRootNode().host)==null?void 0:g.getBoundingClientRect();if(A&&T){const w=this._previewRef.value.style.transform||"translate3d(0px, 0px, 0px)",[,C]=Array.from(w.matchAll(/([+-]?([0-9]*[.])?[0-9]+)(?=px)\w+/g));this._previewRef.value.style.transform=`translate3d(${Hp(e-T.left,t-T.left-A.width/2,r-T.left-A.width)}px, ${C[1]}px, 0)`}}this._previewTimeRef.value&&this._previewTimeRef.value.setAttribute("content",Ph(Math.max(0,Math.min(this._currentTime,(v=this._sceneController.scenes)==null?void 0:v.duration))))}},this._handleScrubberMouseLeave=()=>{var i;(i=this._previewRef)!=null&&i.value&&(this._previewRef.value.style.opacity="0")},this._handleScrubberResize=({detail:{y:i}})=>{var t,e;if((t=this._previewRef)!=null&&t.value){const r=this._previewRef.value.getBoundingClientRect(),n=(e=this._previewRef.value.getRootNode().host)==null?void 0:e.getBoundingClientRect();if(r&&n){const o=this._previewRef.value.style.transform||"translate3d(0px, 0px, 0px)",[l]=Array.from(o.matchAll(/([+-]?([0-9]*[.])?[0-9]+)(?=px)\w+/g));this._previewRef.value.style.transform=`translate3d(${l[1]}px, ${i-n.top-r.height-28}px, 0)`}}}}_draw(i=this._currentTime){var t,e;this._sceneController.scenes&&this._canvasRef.value&&((e=this.compilation)==null||e.call(this,{currentTime:Math.max(0,Math.min(i,(t=this._sceneController.scenes)==null?void 0:t.duration)),scenes:this._sceneController.scenes,canvas:this._canvasRef.value}))}connectedCallback(){super.connectedCallback(),document.addEventListener("scrubber:resize",this._handleScrubberResize),document.addEventListener("scrubber:mouseenter",this._handleScrubberMouseEnter),document.addEventListener("scrubber:mousemove",this._handleScrubberMouseMove),document.addEventListener("scrubber:mouseleave",this._handleScrubberMouseLeave)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("scrubber:resize",this._handleScrubberResize),document.removeEventListener("scrubber:mouseenter",this._handleScrubberMouseEnter),document.removeEventListener("scrubber:mousemove",this._handleScrubberMouseMove),document.removeEventListener("scrubber:mouseleave",this._handleScrubberMouseLeave)}render(){var i;const{height:t,width:e}=ec({resolution:180,aspectRatio:this.aspectRatio}),r=((i=this._sceneController.scenes)==null?void 0:i.scenes.length)??0;return!this.disabled&&(this.src||r>1)?Yt`
565
+ `],Fn([At({type:Boolean})],Ds.prototype,"active",2),Fn([At({type:String})],Ds.prototype,"size",2),Fn([At({type:String})],Ds.prototype,"rounded",2),Fn([At({type:String})],Ds.prototype,"weight",2),Fn([At({type:String})],Ds.prototype,"icon",2),Ds=Fn([Fr("vmp-icon-button")],Ds);var HA=Object.defineProperty,VA=Object.getOwnPropertyDescriptor,qr=(i,t,e,r)=>{for(var n=r>1?void 0:r?VA(t,e):t,o=i.length-1,l;o>=0;o--)(l=i[o])&&(n=(r?l(t,e,n):l(n))||n);return r&&n&&HA(t,e,n),n};let ls=class extends xe{constructor(){super(...arguments),this.disabled=!1,this.aspectRatio=1,this.compilation=tc,this._currentTime=0,this._sceneController=new $A(this),this._canvasRef=wr(),this._previewRef=wr(),this._previewTimeRef=wr(),this._handleScrubberMouseEnter=({detail:{x:i,y:t,elementLeft:e,elementRight:r}})=>{var n,o;if((n=this._previewRef)!=null&&n.value){const l=this._previewRef.value.getBoundingClientRect(),d=(o=this._previewRef.value.getRootNode().host)==null?void 0:o.getBoundingClientRect();l&&d&&(this._previewRef.value.style.opacity="1",this._previewRef.value.style.transform=`translate3d(${Hp(e-d.left,i-d.left-l.width/2,r-d.left-l.width)}px, ${t-d.top-l.height-28}px, 0)`)}},this._handleScrubberMouseMove=({detail:{time:i,x:t,elementLeft:e,elementRight:r}})=>{var n,o,l,d,f,p,g,v;if(this._currentTime=i,(n=this._sceneController.scenes)!=null&&n.scenes.length){const E=(f=(d=(l=(o=this._sceneController.scenes)==null?void 0:o.scenes)==null?void 0:l.find(({start:A,duration:T,video:w})=>w&&i>=A&&i<=A+T))==null?void 0:d.video)==null?void 0:f.node;if(E&&(E.currentTime=i),this._draw(),(p=this._previewRef)!=null&&p.value){const A=this._previewRef.value.getBoundingClientRect(),T=(g=this._previewRef.value.getRootNode().host)==null?void 0:g.getBoundingClientRect();if(A&&T){const w=this._previewRef.value.style.transform||"translate3d(0px, 0px, 0px)",[,C]=Array.from(w.matchAll(/([+-]?([0-9]*[.])?[0-9]+)(?=px)\w+/g));this._previewRef.value.style.transform=`translate3d(${Hp(e-T.left,t-T.left-A.width/2,r-T.left-A.width)}px, ${C[1]}px, 0)`}}this._previewTimeRef.value&&this._previewTimeRef.value.setAttribute("content",Ph(Math.max(0,Math.min(this._currentTime,(v=this._sceneController.scenes)==null?void 0:v.duration))))}},this._handleScrubberMouseLeave=()=>{var i;(i=this._previewRef)!=null&&i.value&&(this._previewRef.value.style.opacity="0")},this._handleScrubberResize=({detail:{y:i}})=>{var t,e;if((t=this._previewRef)!=null&&t.value){const r=this._previewRef.value.getBoundingClientRect(),n=(e=this._previewRef.value.getRootNode().host)==null?void 0:e.getBoundingClientRect();if(r&&n){const o=this._previewRef.value.style.transform||"translate3d(0px, 0px, 0px)",[l]=Array.from(o.matchAll(/([+-]?([0-9]*[.])?[0-9]+)(?=px)\w+/g));this._previewRef.value.style.transform=`translate3d(${l[1]}px, ${i-n.top-r.height-28}px, 0)`}}}}_draw(i=this._currentTime){var t,e;this._sceneController.scenes&&this._canvasRef.value&&((e=this.compilation)==null||e.call(this,{currentTime:Math.max(0,Math.min(i,(t=this._sceneController.scenes)==null?void 0:t.duration)),scenes:this._sceneController.scenes,canvas:this._canvasRef.value}))}connectedCallback(){super.connectedCallback(),document.addEventListener("scrubber:resize",this._handleScrubberResize),document.addEventListener("scrubber:mouseenter",this._handleScrubberMouseEnter),document.addEventListener("scrubber:mousemove",this._handleScrubberMouseMove),document.addEventListener("scrubber:mouseleave",this._handleScrubberMouseLeave)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("scrubber:resize",this._handleScrubberResize),document.removeEventListener("scrubber:mouseenter",this._handleScrubberMouseEnter),document.removeEventListener("scrubber:mousemove",this._handleScrubberMouseMove),document.removeEventListener("scrubber:mouseleave",this._handleScrubberMouseLeave)}render(){var i;const{height:t,width:e}=ec({resolution:180,aspectRatio:this.aspectRatio}),r=((i=this._sceneController.scenes)==null?void 0:i.scenes.length)??0;return!this.disabled&&(this.src||r>1)?Yt`
566
566
  <div
567
567
  ${Sr(this._previewRef)}
568
568
  class="preview"
@@ -611,8 +611,8 @@ ${t}`,t1=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),e1=Objec
611
611
  .aspectRatio=${this.aspectRatio}
612
612
  .compilation=${this.compilation}
613
613
  ></vmp-video-preview-content>
614
- `}};qr([At({type:String})],Ps.prototype,"src",2),qr([At({type:Object})],Ps.prototype,"data",2),qr([At({type:Object})],Ps.prototype,"template",2),qr([At({type:Boolean})],Ps.prototype,"disabled",2),qr([At({type:Number})],Ps.prototype,"aspectRatio",2),qr([At({attribute:!1})],Ps.prototype,"compilation",2),Ps=qr([Fr("vmp-video-preview")],Ps);class jA extends ha{constructor(t){if(super(t),t.type!==kn.ELEMENT)throw new Error("Resize directive must be used in an Element expression")}update(t,[e]){return e==null||e(t.element),As}}const jp=wn(jA);class KA{constructor(t){this.hiddenControls=[],this._measureRef=wr(),this._prevControlsWidth=0,this._hideables={},this._showables={},this._onResize=e=>{var r,n,o;const l=this._measureRef.value,d=(o=(n=(r=e==null?void 0:e[0])==null?void 0:r.borderBoxSize)==null?void 0:n[0])==null?void 0:o.inlineSize;if(l&&d&&d!==this._prevControlsWidth){Object.keys(this._hideables).forEach(p=>{this._hideables[p].element.style.display=""}),Object.keys(this._showables).forEach(p=>{this._showables[p].element.style.display="none"});const f=[];for(;l.scrollWidth>l.offsetWidth;){const p=Object.keys(this._hideables).find(v=>this._hideables[v].hideIndex===f.length);if(!p)break;const g=this._hideables[p].element;g&&(g.style.display="none"),f.push(p),Object.keys(this._showables).forEach(v=>{this._showables[v].showOn.some(E=>f.includes(E))&&(this._showables[v].element.style.display="flex")})}this.hiddenControls=f,this._prevControlsWidth=d,this.host.requestUpdate()}},this.host=t}measure(){return Sr(this._measureRef)}contain(){return Dh(this._onResize)}hide(t,e){return jp(r=>{this._hideables[t]={element:r,hideIndex:e}})}show(t,e){return jp(r=>{this._showables[t]={element:r,showOn:e}})}}const Oh=`.tippy-box[data-animation=shift-away-subtle][data-state=hidden]{opacity:0}.tippy-box[data-animation=shift-away-subtle][data-state=hidden][data-placement^=top]{transform:translateY(5px)}.tippy-box[data-animation=shift-away-subtle][data-state=hidden][data-placement^=bottom]{transform:translateY(-5px)}.tippy-box[data-animation=shift-away-subtle][data-state=hidden][data-placement^=left]{transform:translate(5px)}.tippy-box[data-animation=shift-away-subtle][data-state=hidden][data-placement^=right]{transform:translate(-5px)}
615
- `;var zA=Object.defineProperty,YA=Object.getOwnPropertyDescriptor,Ba=(i,t,e,r)=>{for(var n=r>1?void 0:r?YA(t,e):t,o=i.length-1,l;o>=0;o--)(l=i[o])&&(n=(r?l(t,e,n):l(n))||n);return r&&n&&zA(t,e,n),n};let gn=class extends xe{constructor(){super(...arguments),this.semibold=!1,this.truncate=!1,this.size="medium",this.content=""}render(){return Yt`
614
+ `}};qr([At({type:String})],Ps.prototype,"src",2),qr([At({type:Object})],Ps.prototype,"data",2),qr([At({type:Object})],Ps.prototype,"template",2),qr([At({type:Boolean})],Ps.prototype,"disabled",2),qr([At({type:Number})],Ps.prototype,"aspectRatio",2),qr([At({attribute:!1})],Ps.prototype,"compilation",2),Ps=qr([Fr("vmp-video-preview")],Ps);class WA extends ha{constructor(t){if(super(t),t.type!==kn.ELEMENT)throw new Error("Resize directive must be used in an Element expression")}update(t,[e]){return e==null||e(t.element),As}}const jp=wn(WA);class jA{constructor(t){this.hiddenControls=[],this._measureRef=wr(),this._prevControlsWidth=0,this._hideables={},this._showables={},this._onResize=e=>{var r,n,o;const l=this._measureRef.value,d=(o=(n=(r=e==null?void 0:e[0])==null?void 0:r.borderBoxSize)==null?void 0:n[0])==null?void 0:o.inlineSize;if(l&&d&&d!==this._prevControlsWidth){Object.keys(this._hideables).forEach(p=>{this._hideables[p].element.style.display=""}),Object.keys(this._showables).forEach(p=>{this._showables[p].element.style.display="none"});const f=[];for(;l.scrollWidth>l.offsetWidth;){const p=Object.keys(this._hideables).find(v=>this._hideables[v].hideIndex===f.length);if(!p)break;const g=this._hideables[p].element;g&&(g.style.display="none"),f.push(p),Object.keys(this._showables).forEach(v=>{this._showables[v].showOn.some(E=>f.includes(E))&&(this._showables[v].element.style.display="flex")})}this.hiddenControls=f,this._prevControlsWidth=d,this.host.requestUpdate()}},this.host=t}measure(){return Sr(this._measureRef)}contain(){return Dh(this._onResize)}hide(t,e){return jp(r=>{this._hideables[t]={element:r,hideIndex:e}})}show(t,e){return jp(r=>{this._showables[t]={element:r,showOn:e}})}}const Oh=`.tippy-box[data-animation=shift-away-subtle][data-state=hidden]{opacity:0}.tippy-box[data-animation=shift-away-subtle][data-state=hidden][data-placement^=top]{transform:translateY(5px)}.tippy-box[data-animation=shift-away-subtle][data-state=hidden][data-placement^=bottom]{transform:translateY(-5px)}.tippy-box[data-animation=shift-away-subtle][data-state=hidden][data-placement^=left]{transform:translate(5px)}.tippy-box[data-animation=shift-away-subtle][data-state=hidden][data-placement^=right]{transform:translate(-5px)}
615
+ `;var KA=Object.defineProperty,zA=Object.getOwnPropertyDescriptor,Ba=(i,t,e,r)=>{for(var n=r>1?void 0:r?zA(t,e):t,o=i.length-1,l;o>=0;o--)(l=i[o])&&(n=(r?l(t,e,n):l(n))||n);return r&&n&&KA(t,e,n),n};let gn=class extends xe{constructor(){super(...arguments),this.semibold=!1,this.truncate=!1,this.size="medium",this.content=""}render(){return Yt`
616
616
  <div
617
617
  part="content"
618
618
  class=${He({semibold:this.semibold,truncate:this.truncate,[this.size]:!0})}
@@ -657,7 +657,7 @@ ${t}`,t1=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),e1=Objec
657
657
  text-overflow: ellipsis;
658
658
  overflow: hidden;
659
659
  }
660
- `],Ba([At({type:Boolean})],gn.prototype,"semibold",2),Ba([At({type:Boolean})],gn.prototype,"truncate",2),Ba([At({type:String})],gn.prototype,"size",2),Ba([At({type:String})],gn.prototype,"content",2),gn=Ba([Fr("vmp-text")],gn);var XA=Object.defineProperty,ZA=Object.getOwnPropertyDescriptor,Ga=(i,t,e,r)=>{for(var n=r>1?void 0:r?ZA(t,e):t,o=i.length-1,l;o>=0;o--)(l=i[o])&&(n=(r?l(t,e,n):l(n))||n);return r&&n&&XA(t,e,n),n};let mn=class extends xe{constructor(){super(...arguments),this.activeItems=[],this.visibleItems=null,this.subItemsActive=null,this.tippy=null,this._contentRef=wr()}_handleBackClick(){this.subItemsActive=null,this.visibleItems=this.items??null}willUpdate(){this.visibleItems=this.visibleItems??this.items??null}updated(){var i,t;const e=(t=(i=this.items)==null?void 0:i.items.find(({id:r})=>this.subItemsActive===r))==null?void 0:t.subItems;this.visibleItems=e??this.items??null,e||(this.subItemsActive=null)}connectedCallback(){super.connectedCallback(),requestAnimationFrame(()=>{var i;const t=(i=this.shadowRoot)==null?void 0:i.querySelector("slot"),e=t==null?void 0:t.assignedElements()[0];e&&this._contentRef.value&&(this.tippy=hn(e,{content:this._contentRef.value,allowHTML:!0,arrow:!1,animation:"shift-away-subtle",interactive:!0,placement:"top",trigger:"click",onShow:()=>{this.dispatchEvent(new CustomEvent("menu:toggle",{detail:!0}))},onHide:()=>{this.dispatchEvent(new CustomEvent("menu:toggle",{detail:!1}))},appendTo:()=>this.shadowRoot}))})}disconnectedCallback(){var i;super.disconnectedCallback(),(i=this.tippy)==null||i.destroy()}render(){var i,t;return Yt`
660
+ `],Ba([At({type:Boolean})],gn.prototype,"semibold",2),Ba([At({type:Boolean})],gn.prototype,"truncate",2),Ba([At({type:String})],gn.prototype,"size",2),Ba([At({type:String})],gn.prototype,"content",2),gn=Ba([Fr("vmp-text")],gn);var YA=Object.defineProperty,XA=Object.getOwnPropertyDescriptor,Ga=(i,t,e,r)=>{for(var n=r>1?void 0:r?XA(t,e):t,o=i.length-1,l;o>=0;o--)(l=i[o])&&(n=(r?l(t,e,n):l(n))||n);return r&&n&&YA(t,e,n),n};let mn=class extends xe{constructor(){super(...arguments),this.activeItems=[],this.visibleItems=null,this.subItemsActive=null,this.tippy=null,this._contentRef=wr()}_handleBackClick(){this.subItemsActive=null,this.visibleItems=this.items??null}willUpdate(){this.visibleItems=this.visibleItems??this.items??null}updated(){var i,t;const e=(t=(i=this.items)==null?void 0:i.items.find(({id:r})=>this.subItemsActive===r))==null?void 0:t.subItems;this.visibleItems=e??this.items??null,e||(this.subItemsActive=null)}connectedCallback(){super.connectedCallback(),requestAnimationFrame(()=>{var i;const t=(i=this.shadowRoot)==null?void 0:i.querySelector("slot"),e=t==null?void 0:t.assignedElements()[0];e&&this._contentRef.value&&(this.tippy=hn(e,{content:this._contentRef.value,allowHTML:!0,arrow:!1,animation:"shift-away-subtle",interactive:!0,placement:"top",trigger:"click",onShow:()=>{this.dispatchEvent(new CustomEvent("menu:toggle",{detail:!0}))},onHide:()=>{this.dispatchEvent(new CustomEvent("menu:toggle",{detail:!1}))},appendTo:()=>this.shadowRoot}))})}disconnectedCallback(){var i;super.disconnectedCallback(),(i=this.tippy)==null||i.destroy()}render(){var i,t;return Yt`
661
661
  <slot></slot>
662
662
  <div ${Sr(this._contentRef)} class="content">
663
663
  <div class="title">
@@ -745,7 +745,7 @@ ${t}`,t1=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),e1=Objec
745
745
  height: 20px;
746
746
  width: 20px;
747
747
  }
748
- `],Ga([At({type:Object})],mn.prototype,"items",2),Ga([At({type:Array})],mn.prototype,"activeItems",2),Ga([mr()],mn.prototype,"visibleItems",2),Ga([mr()],mn.prototype,"subItemsActive",2),mn=Ga([Fr("vmp-menu")],mn);var qA=Object.defineProperty,QA=Object.getOwnPropertyDescriptor,$h=(i,t,e,r)=>{for(var n=r>1?void 0:r?QA(t,e):t,o=i.length-1,l;o>=0;o--)(l=i[o])&&(n=(r?l(t,e,n):l(n))||n);return r&&n&&qA(t,e,n),n};let Ha=class extends xe{constructor(){super(...arguments),this.content="",this.disabled=!1,this.tippy=null,this._contentRef=wr()}connectedCallback(){super.connectedCallback(),requestAnimationFrame(()=>{var i;const t=(i=this.shadowRoot)==null?void 0:i.querySelector("slot"),e=t==null?void 0:t.assignedElements()[0];e&&this._contentRef.value&&(this.tippy=hn(e,{content:this._contentRef.value,allowHTML:!0,arrow:!1,animation:"shift-away-subtle",interactive:!1,placement:"top",zIndex:1e4,appendTo:()=>this.shadowRoot}))})}disconnectedCallback(){var i;super.disconnectedCallback(),(i=this.tippy)==null||i.destroy()}updated(){var i,t;this.disabled?(i=this.tippy)==null||i.disable():(t=this.tippy)==null||t.enable()}render(){return Yt`
748
+ `],Ga([At({type:Object})],mn.prototype,"items",2),Ga([At({type:Array})],mn.prototype,"activeItems",2),Ga([mr()],mn.prototype,"visibleItems",2),Ga([mr()],mn.prototype,"subItemsActive",2),mn=Ga([Fr("vmp-menu")],mn);var ZA=Object.defineProperty,qA=Object.getOwnPropertyDescriptor,$h=(i,t,e,r)=>{for(var n=r>1?void 0:r?qA(t,e):t,o=i.length-1,l;o>=0;o--)(l=i[o])&&(n=(r?l(t,e,n):l(n))||n);return r&&n&&ZA(t,e,n),n};let Ha=class extends xe{constructor(){super(...arguments),this.content="",this.disabled=!1,this.tippy=null,this._contentRef=wr()}connectedCallback(){super.connectedCallback(),requestAnimationFrame(()=>{var i;const t=(i=this.shadowRoot)==null?void 0:i.querySelector("slot"),e=t==null?void 0:t.assignedElements()[0];e&&this._contentRef.value&&(this.tippy=hn(e,{content:this._contentRef.value,allowHTML:!0,arrow:!1,animation:"shift-away-subtle",interactive:!1,placement:"top",zIndex:1e4,appendTo:()=>this.shadowRoot}))})}disconnectedCallback(){var i;super.disconnectedCallback(),(i=this.tippy)==null||i.destroy()}updated(){var i,t;this.disabled?(i=this.tippy)==null||i.disable():(t=this.tippy)==null||t.enable()}render(){return Yt`
749
749
  <slot></slot>
750
750
  <div ${Sr(this._contentRef)} class="content">
751
751
  <vmp-text content=${this.content}></vmp-text>
@@ -764,7 +764,7 @@ ${t}`,t1=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),e1=Objec
764
764
  background: var(--colors-dark-800);
765
765
  border-radius: var(--radii-medium);
766
766
  }
767
- `],$h([At({type:String})],Ha.prototype,"content",2),$h([At({type:Boolean})],Ha.prototype,"disabled",2),Ha=$h([Fr("vmp-tooltip")],Ha);var JA=Object.defineProperty,tT=Object.getOwnPropertyDescriptor,Mh=(i,t,e,r)=>{for(var n=r>1?void 0:r?tT(t,e):t,o=i.length-1,l;o>=0;o--)(l=i[o])&&(n=(r?l(t,e,n):l(n))||n);return r&&n&&JA(t,e,n),n};let Va=class extends xe{constructor(){super(...arguments),this.volume=1,this.muted=!1,this.tippy=null,this._contentRef=wr(),this._anchorRef=wr(),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 i;super.disconnectedCallback(),(i=this.tippy)==null||i.destroy()}render(){return Yt`
767
+ `],$h([At({type:String})],Ha.prototype,"content",2),$h([At({type:Boolean})],Ha.prototype,"disabled",2),Ha=$h([Fr("vmp-tooltip")],Ha);var QA=Object.defineProperty,JA=Object.getOwnPropertyDescriptor,Mh=(i,t,e,r)=>{for(var n=r>1?void 0:r?JA(t,e):t,o=i.length-1,l;o>=0;o--)(l=i[o])&&(n=(r?l(t,e,n):l(n))||n);return r&&n&&QA(t,e,n),n};let Va=class extends xe{constructor(){super(...arguments),this.volume=1,this.muted=!1,this.tippy=null,this._contentRef=wr(),this._anchorRef=wr(),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 i;super.disconnectedCallback(),(i=this.tippy)==null||i.destroy()}render(){return Yt`
768
768
  <vmp-icon-button
769
769
  ${Sr(this._anchorRef)}
770
770
  icon=${this.muted||this.volume===0?"muted":this.volume<1/3?"volume-low":this.volume<2/3?"volume-medium":"volume-high"}
@@ -912,7 +912,7 @@ ${t}`,t1=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),e1=Objec
912
912
  --volume-slider-height: 8px;
913
913
  color: var(--colors-light-800);
914
914
  }
915
- `],Mh([At({type:Number})],Va.prototype,"volume",2),Mh([At({type:Boolean})],Va.prototype,"muted",2),Va=Mh([Fr("vmp-volume-button")],Va);var eT=Object.defineProperty,rT=Object.getOwnPropertyDescriptor,cl=(i,t,e,r)=>{for(var n=r>1?void 0:r?rT(t,e):t,o=i.length-1,l;o>=0;o--)(l=i[o])&&(n=(r?l(t,e,n):l(n))||n);return r&&n&&eT(t,e,n),n};let Un=class extends xe{constructor(){super(...arguments),this.duration=0,this.currentTime=0,this.buffer=[],this._containerRef=wr(),this._handleContainerResize=()=>{var i;const t=(i=this._containerRef.value)==null?void 0:i.getBoundingClientRect();this.dispatchEvent(new CustomEvent("scrubber:resize",{detail:t,bubbles:!0,composed:!0}))},this._handleMouseEnter=i=>{var t;const e=(t=this._containerRef.value)==null?void 0:t.getBoundingClientRect();this.dispatchEvent(new CustomEvent("scrubber:mouseenter",{detail:{x:i.clientX,y:i.clientY,elementLeft:(e==null?void 0:e.left)??0,elementRight:(e==null?void 0:e.right)??document.body.offsetWidth},bubbles:!0,composed:!0}))},this._handleMouseMove=i=>{var t;const e=(t=this._containerRef.value)==null?void 0:t.getBoundingClientRect(),r=(i.clientX-((e==null?void 0:e.left)??0))/((e==null?void 0:e.width)??1);this.dispatchEvent(new CustomEvent("scrubber:mousemove",{detail:{x:i.clientX,y:i.clientY,time:r*this.duration,elementLeft:(e==null?void 0:e.left)??0,elementRight:(e==null?void 0:e.right)??document.body.offsetWidth},bubbles:!0,composed:!0}))},this._handleMouseLeave=i=>{this.dispatchEvent(new CustomEvent("scrubber:mouseleave",{detail:{x:i.clientX,y:i.clientY},bubbles:!0,composed:!0}))}}render(){var i;const t=((i=this.buffer)==null?void 0:i.sort((e,r)=>e.start<r.start?-1:r.start<e.start?1:0).reduce((e,{start:r,end:n},o)=>{const l=e[o-1],d=Math.floor(r),f=Math.ceil(n);return e.push({id:r,start:Math.max(0,d),end:Math.min(f,100)}),l&&l.end>=r-1&&(e[o].start=l.end),e},[]))??[];return Yt`
915
+ `],Mh([At({type:Number})],Va.prototype,"volume",2),Mh([At({type:Boolean})],Va.prototype,"muted",2),Va=Mh([Fr("vmp-volume-button")],Va);var tT=Object.defineProperty,eT=Object.getOwnPropertyDescriptor,cl=(i,t,e,r)=>{for(var n=r>1?void 0:r?eT(t,e):t,o=i.length-1,l;o>=0;o--)(l=i[o])&&(n=(r?l(t,e,n):l(n))||n);return r&&n&&tT(t,e,n),n};let Un=class extends xe{constructor(){super(...arguments),this.duration=0,this.currentTime=0,this.buffer=[],this._containerRef=wr(),this._handleContainerResize=()=>{var i;const t=(i=this._containerRef.value)==null?void 0:i.getBoundingClientRect();this.dispatchEvent(new CustomEvent("scrubber:resize",{detail:t,bubbles:!0,composed:!0}))},this._handleMouseEnter=i=>{var t;const e=(t=this._containerRef.value)==null?void 0:t.getBoundingClientRect();this.dispatchEvent(new CustomEvent("scrubber:mouseenter",{detail:{x:i.clientX,y:i.clientY,elementLeft:(e==null?void 0:e.left)??0,elementRight:(e==null?void 0:e.right)??document.body.offsetWidth},bubbles:!0,composed:!0}))},this._handleMouseMove=i=>{var t;const e=(t=this._containerRef.value)==null?void 0:t.getBoundingClientRect(),r=(i.clientX-((e==null?void 0:e.left)??0))/((e==null?void 0:e.width)??1);this.dispatchEvent(new CustomEvent("scrubber:mousemove",{detail:{x:i.clientX,y:i.clientY,time:r*this.duration,elementLeft:(e==null?void 0:e.left)??0,elementRight:(e==null?void 0:e.right)??document.body.offsetWidth},bubbles:!0,composed:!0}))},this._handleMouseLeave=i=>{this.dispatchEvent(new CustomEvent("scrubber:mouseleave",{detail:{x:i.clientX,y:i.clientY},bubbles:!0,composed:!0}))}}render(){var i;const t=((i=this.buffer)==null?void 0:i.sort((e,r)=>e.start<r.start?-1:r.start<e.start?1:0).reduce((e,{start:r,end:n},o)=>{const l=e[o-1],d=Math.floor(r),f=Math.ceil(n);return e.push({id:r,start:Math.max(0,d),end:Math.min(f,100)}),l&&l.end>=r-1&&(e[o].start=l.end),e},[]))??[];return Yt`
916
916
  <div
917
917
  class="container"
918
918
  ${Sr(this._containerRef)}
@@ -1068,7 +1068,7 @@ ${t}`,t1=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),e1=Objec
1068
1068
  --player-scrubber-height: 16px;
1069
1069
  color: var(--colors-light-800);
1070
1070
  }
1071
- `],cl([At({type:Number})],Un.prototype,"duration",2),cl([At({type:Number})],Un.prototype,"currentTime",2),cl([At({type:Array})],Un.prototype,"buffer",2),Un=cl([Fr("vmp-progress-scrubber")],Un);var iT=Object.defineProperty,sT=Object.getOwnPropertyDescriptor,Lr=(i,t,e,r)=>{for(var n=r>1?void 0:r?sT(t,e):t,o=i.length-1,l;o>=0;o--)(l=i[o])&&(n=(r?l(t,e,n):l(n))||n);return r&&n&&iT(t,e,n),n};let ur=class extends xe{constructor(){super(...arguments),this.resizeHider=new KA(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=xh,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:i}){this.volumeMenuOpen=i}_handleLevelsMenuOpen({detail:i}){this.levelsMenuOpen=i}_handlePlaybackMenuToggle({detail:i}){this.playbackRateMenuOpen=i}_handleSettingsMenuToggle({detail:i}){this.settingsMenuOpen=i}hideMenus(){var i,t;(t=Array.from((i=this.shadowRoot)==null?void 0:i.querySelectorAll("vmp-menu, vmp-tooltip, vmp-volume-button")))==null||t.forEach(e=>{var r;(r=e.tippy)==null||r.hide()})}render(){var i,t,e,r,n,o,l,d,f,p,g,v,E;const A=((i=this.levels)==null?void 0:i.map((F,j)=>{const bt=Math.min(F.width,F.height);return{id:`level-${j.toString()}`,event:"level:click",label:`${bt}p`,value:{resolution:bt,level:j}}}))??[],T={title:"Quality",items:[...A.reverse(),{id:"level--1",event:"level:click",label:"Auto",value:{level:-1,resolution:"auto"}}]},w={id:"levels",label:"Quality",subItems:T},C=(t=T.items)==null?void 0:t.find(({value:F})=>F.level===this.level),D=["levels","playback-rate","captions","fullscreen"].filter(F=>{var j;return(j=this.controls)==null?void 0:j.includes(F)}),M={title:"Settings",items:[kA,wA,w,SA].filter(({id:F})=>D.includes(F)&&this.resizeHider.hiddenControls.includes(F))},U=(e=this.controls)==null?void 0:e.includes("progress"),x=(r=this.controls)==null?void 0:r.includes("navigation"),O=(n=this.controls)==null?void 0:n.includes("play"),K=(o=this.controls)==null?void 0:o.includes("volume"),B=(l=this.controls)==null?void 0:l.includes("current-time"),at=(d=this.controls)==null?void 0:d.includes("duration"),st=(f=this.controls)==null?void 0:f.includes("levels"),J=(p=this.controls)==null?void 0:p.includes("speed"),kt=(g=this.controls)==null?void 0:g.includes("captions"),ft=(v=this.controls)==null?void 0:v.includes("fullscreen"),wt=O||K||B||at||st||J||kt||ft,Pt=[`level-${(E=this.level)==null?void 0:E.toString()}`,`playback-rate-${this.playbackRate.toString()}`,this.captions&&"captions",this.fullscreen&&"fullscreen"].filter(Boolean);return Yt`
1071
+ `],cl([At({type:Number})],Un.prototype,"duration",2),cl([At({type:Number})],Un.prototype,"currentTime",2),cl([At({type:Array})],Un.prototype,"buffer",2),Un=cl([Fr("vmp-progress-scrubber")],Un);var rT=Object.defineProperty,iT=Object.getOwnPropertyDescriptor,Lr=(i,t,e,r)=>{for(var n=r>1?void 0:r?iT(t,e):t,o=i.length-1,l;o>=0;o--)(l=i[o])&&(n=(r?l(t,e,n):l(n))||n);return r&&n&&rT(t,e,n),n};let ur=class extends xe{constructor(){super(...arguments),this.resizeHider=new jA(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=xh,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:i}){this.volumeMenuOpen=i}_handleLevelsMenuOpen({detail:i}){this.levelsMenuOpen=i}_handlePlaybackMenuToggle({detail:i}){this.playbackRateMenuOpen=i}_handleSettingsMenuToggle({detail:i}){this.settingsMenuOpen=i}hideMenus(){var i,t;(t=Array.from((i=this.shadowRoot)==null?void 0:i.querySelectorAll("vmp-menu, vmp-tooltip, vmp-volume-button")))==null||t.forEach(e=>{var r;(r=e.tippy)==null||r.hide()})}render(){var i,t,e,r,n,o,l,d,f,p,g,v,E;const A=((i=this.levels)==null?void 0:i.map((F,j)=>{const bt=Math.min(F.width,F.height);return{id:`level-${j.toString()}`,event:"level:click",label:`${bt}p`,value:{resolution:bt,level:j}}}))??[],T={title:"Quality",items:[...A.reverse(),{id:"level--1",event:"level:click",label:"Auto",value:{level:-1,resolution:"auto"}}]},w={id:"levels",label:"Quality",subItems:T},C=(t=T.items)==null?void 0:t.find(({value:F})=>F.level===this.level),D=["levels","playback-rate","captions","fullscreen"].filter(F=>{var j;return(j=this.controls)==null?void 0:j.includes(F)}),M={title:"Settings",items:[TA,kA,w,wA].filter(({id:F})=>D.includes(F)&&this.resizeHider.hiddenControls.includes(F))},U=(e=this.controls)==null?void 0:e.includes("progress"),x=(r=this.controls)==null?void 0:r.includes("navigation"),O=(n=this.controls)==null?void 0:n.includes("play"),K=(o=this.controls)==null?void 0:o.includes("volume"),B=(l=this.controls)==null?void 0:l.includes("current-time"),at=(d=this.controls)==null?void 0:d.includes("duration"),st=(f=this.controls)==null?void 0:f.includes("levels"),J=(p=this.controls)==null?void 0:p.includes("speed"),kt=(g=this.controls)==null?void 0:g.includes("captions"),ft=(v=this.controls)==null?void 0:v.includes("fullscreen"),wt=O||K||B||at||st||J||kt||ft,Pt=[`level-${(E=this.level)==null?void 0:E.toString()}`,`playback-rate-${this.playbackRate.toString()}`,this.captions&&"captions",this.fullscreen&&"fullscreen"].filter(Boolean);return Yt`
1072
1072
  <div
1073
1073
  ${this.resizeHider.measure()}
1074
1074
  ${this.resizeHider.contain()}
@@ -1269,13 +1269,13 @@ ${t}`,t1=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),e1=Objec
1269
1269
  .hidden {
1270
1270
  display: none;
1271
1271
  }
1272
- `],Lr([At({type:Boolean})],ur.prototype,"playing",2),Lr([At({type:Number})],ur.prototype,"volume",2),Lr([At({type:Boolean})],ur.prototype,"muted",2),Lr([At({type:Number})],ur.prototype,"currentTime",2),Lr([At({type:Number})],ur.prototype,"duration",2),Lr([At({type:Number})],ur.prototype,"level",2),Lr([At({type:Number})],ur.prototype,"playbackRate",2),Lr([At({type:Array})],ur.prototype,"buffer",2),Lr([At({type:Array,attribute:!1})],ur.prototype,"levels",2),Lr([At({type:Boolean})],ur.prototype,"captions",2),Lr([At({type:Boolean})],ur.prototype,"fullscreen",2),Lr([At({type:Array})],ur.prototype,"controls",2),Lr([mr()],ur.prototype,"volumeMenuOpen",2),Lr([mr()],ur.prototype,"levelsMenuOpen",2),Lr([mr()],ur.prototype,"playbackRateMenuOpen",2),Lr([mr()],ur.prototype,"settingsMenuOpen",2),ur=Lr([Fr("vmp-player-controls")],ur);var nT=Object.defineProperty,aT=Object.getOwnPropertyDescriptor,oT=(i,t,e,r)=>{for(var n=r>1?void 0:r?aT(t,e):t,o=i.length-1,l;o>=0;o--)(l=i[o])&&(n=(r?l(t,e,n):l(n))||n);return r&&n&&nT(t,e,n),n};let Nh=class extends xe{render(){return Yt`<vmp-icon icon="loading"></vmp-icon>`}};Nh.styles=[xe.styles??[],cr`
1272
+ `],Lr([At({type:Boolean})],ur.prototype,"playing",2),Lr([At({type:Number})],ur.prototype,"volume",2),Lr([At({type:Boolean})],ur.prototype,"muted",2),Lr([At({type:Number})],ur.prototype,"currentTime",2),Lr([At({type:Number})],ur.prototype,"duration",2),Lr([At({type:Number})],ur.prototype,"level",2),Lr([At({type:Number})],ur.prototype,"playbackRate",2),Lr([At({type:Array})],ur.prototype,"buffer",2),Lr([At({type:Array,attribute:!1})],ur.prototype,"levels",2),Lr([At({type:Boolean})],ur.prototype,"captions",2),Lr([At({type:Boolean})],ur.prototype,"fullscreen",2),Lr([At({type:Array})],ur.prototype,"controls",2),Lr([mr()],ur.prototype,"volumeMenuOpen",2),Lr([mr()],ur.prototype,"levelsMenuOpen",2),Lr([mr()],ur.prototype,"playbackRateMenuOpen",2),Lr([mr()],ur.prototype,"settingsMenuOpen",2),ur=Lr([Fr("vmp-player-controls")],ur);var sT=Object.defineProperty,nT=Object.getOwnPropertyDescriptor,aT=(i,t,e,r)=>{for(var n=r>1?void 0:r?nT(t,e):t,o=i.length-1,l;o>=0;o--)(l=i[o])&&(n=(r?l(t,e,n):l(n))||n);return r&&n&&sT(t,e,n),n};let Nh=class extends xe{render(){return Yt`<vmp-icon icon="loading"></vmp-icon>`}};Nh.styles=[xe.styles??[],cr`
1273
1273
  :host {
1274
1274
  display: flex;
1275
1275
  align-items: center;
1276
1276
  justify-content: center;
1277
1277
  }
1278
- `],Nh=oT([Fr("vmp-loading-spinner")],Nh);var lT=Object.defineProperty,cT=Object.getOwnPropertyDescriptor,Kp=(i,t,e,r)=>{for(var n=r>1?void 0:r?cT(t,e):t,o=i.length-1,l;o>=0;o--)(l=i[o])&&(n=(r?l(t,e,n):l(n))||n);return r&&n&&lT(t,e,n),n};let hl=class extends xe{constructor(){super(...arguments),this.caption=""}render(){return Yt`
1278
+ `],Nh=aT([Fr("vmp-loading-spinner")],Nh);var oT=Object.defineProperty,lT=Object.getOwnPropertyDescriptor,Kp=(i,t,e,r)=>{for(var n=r>1?void 0:r?lT(t,e):t,o=i.length-1,l;o>=0;o--)(l=i[o])&&(n=(r?l(t,e,n):l(n))||n);return r&&n&&oT(t,e,n),n};let hl=class extends xe{constructor(){super(...arguments),this.caption=""}render(){return Yt`
1279
1279
  <div class="container">
1280
1280
  <vmp-text content=${this.caption} size="large"></vmp-text>
1281
1281
  </div>
@@ -1298,7 +1298,7 @@ ${t}`,t1=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),e1=Objec
1298
1298
  /* Line height controls the spacing between the cloned boxes so has to override the default */
1299
1299
  line-height: 2.2;
1300
1300
  }
1301
- `],Kp([At({type:String})],hl.prototype,"caption",2),hl=Kp([Fr("vmp-captions")],hl);var hT=Object.defineProperty,dT=Object.getOwnPropertyDescriptor,Dr=(i,t,e,r)=>{for(var n=r>1?void 0:r?dT(t,e):t,o=i.length-1,l;o>=0;o--)(l=i[o])&&(n=(r?l(t,e,n):l(n))||n);return r&&n&&hT(t,e,n),n};const uT=3e3;let yr=class extends xe{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=xh,this.showControls=!0,this._hasTouched=!1,this._playerControlsRef=wr()}_startHideControls(){clearTimeout(this._controlHideTimeout),this._controlHideTimeout=setTimeout(()=>{this.showControls=!1,this._hasTouched=!1},uT)}_immediateShowControls(){this.showControls=!0,clearTimeout(this._controlHideTimeout)}_immediateHideControls(){this.showControls=!1,this._hasTouched=!1,clearTimeout(this._controlHideTimeout)}willUpdate(i){var t;i.has("playing")&&this.playing&&this._startHideControls(),i.has("showControls")&&this.playing&&!this.showControls&&((t=this._playerControlsRef.value)==null||t.hideMenus())}render(){var i;const t=(i=this.controls)==null?void 0:i.includes("play-large"),e=this.playing&&!this.showControls,r=!!(t&&!this.playing);return Yt`
1301
+ `],Kp([At({type:String})],hl.prototype,"caption",2),hl=Kp([Fr("vmp-captions")],hl);var cT=Object.defineProperty,hT=Object.getOwnPropertyDescriptor,Dr=(i,t,e,r)=>{for(var n=r>1?void 0:r?hT(t,e):t,o=i.length-1,l;o>=0;o--)(l=i[o])&&(n=(r?l(t,e,n):l(n))||n);return r&&n&&cT(t,e,n),n};const dT=3e3;let yr=class extends xe{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=xh,this.showControls=!0,this._hasTouched=!1,this._playerControlsRef=wr()}_startHideControls(){clearTimeout(this._controlHideTimeout),this._controlHideTimeout=setTimeout(()=>{this.showControls=!1,this._hasTouched=!1},dT)}_immediateShowControls(){this.showControls=!0,clearTimeout(this._controlHideTimeout)}_immediateHideControls(){this.showControls=!1,this._hasTouched=!1,clearTimeout(this._controlHideTimeout)}willUpdate(i){var t;i.has("playing")&&this.playing&&this._startHideControls(),i.has("showControls")&&this.playing&&!this.showControls&&((t=this._playerControlsRef.value)==null||t.hideMenus())}render(){var i;const t=(i=this.controls)==null?void 0:i.includes("play-large"),e=this.playing&&!this.showControls,r=!!(t&&!this.playing);return Yt`
1302
1302
  <div
1303
1303
  class=${He({container:!0,hide:e})}
1304
1304
  @mousemove=${()=>{this._immediateShowControls(),this._startHideControls()}}
@@ -1416,7 +1416,7 @@ ${t}`,t1=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),e1=Objec
1416
1416
  vmp-captions.hiddenControls {
1417
1417
  transform: translateY(calc(var(--space-small) * -1));
1418
1418
  }
1419
- `],Dr([At({type:Boolean})],yr.prototype,"loading",2),Dr([At({type:Boolean})],yr.prototype,"playing",2),Dr([At({type:Number})],yr.prototype,"volume",2),Dr([At({type:Boolean})],yr.prototype,"muted",2),Dr([At({type:Number})],yr.prototype,"currentTime",2),Dr([At({type:Number})],yr.prototype,"duration",2),Dr([At({type:Array,attribute:!1})],yr.prototype,"levels",2),Dr([At({type:Number})],yr.prototype,"level",2),Dr([At({type:Number})],yr.prototype,"playbackRate",2),Dr([At({type:String})],yr.prototype,"caption",2),Dr([At({type:Array})],yr.prototype,"buffer",2),Dr([At({type:Boolean})],yr.prototype,"captions",2),Dr([At({type:Boolean})],yr.prototype,"fullscreen",2),Dr([At({type:Array})],yr.prototype,"controls",2),Dr([mr()],yr.prototype,"showControls",2),yr=Dr([Fr("vmp-player-overlay")],yr);var fT=Object.defineProperty,pT=Object.getOwnPropertyDescriptor,sr=(i,t,e,r)=>{for(var n=r>1?void 0:r?pT(t,e):t,o=i.length-1,l;o>=0;o--)(l=i[o])&&(n=(r?l(t,e,n):l(n))||n);return r&&n&&fT(t,e,n),n};const gT=1e3/60;let rr=class extends xe{constructor(){super(...arguments),this.burnCaptions=!1,this.debug=!1,this.propAspectRatio=0,this.preload="auto",this.autoplay=!1,this.loading=!1,this.compilation=tc,this._sceneController=new EA(this),this._drawController=new zy(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=wr(),this._canvasRef=wr(),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 i;(i=this.shadowRoot)!=null&&i.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,gT):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=(i=performance.now())=>{this.sceneConfig&&this.scenes.length>0&&(this._waiting=this._drawController.activeScenes.some(({video:t})=>{if(t){const{key:e}=t,r=this.videoState[e];return!r||!r.initialised||r.waiting||t.node.readyState<3}}),this.waiting?(this._lastTimestamp=null,this._lastWaiting||this.dispatchEvent(new CustomEvent("waiting"))):this._lastWaiting&&this.dispatchEvent(new CustomEvent("playing")),i-(this._lastTimestamp??0)>1e3/this.sceneConfig.frameRate&&(this._drawController.currentTime=this._drawController.currentTime+(i-(this._lastTimestamp??i))/1e3*this.playbackRate,this._lastTimestamp=i),this._lastWaiting=this._waiting,this._drawController.currentTime>=this.duration&&(this.pause(),this.dispatchEvent(new CustomEvent("ended")))),this.paused||this._loop()},this._handleError=i=>{this._errors=[...this.errors,i.error],i.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(i=>{const t=setInterval(()=>{this.errors.find(e=>e.fatal)&&i(!1),!this.loading&&!this.processing&&this.scenes.length>0&&i(!0)},500);setTimeout(()=>{clearInterval(t),i(!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 i;return((i=this._sceneController.scenes)==null?void 0:i.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((i,{video:t,start:e,duration:r})=>{const n=(t==null?void 0:t.key)??`${e}-${r}`;return i[n]=this.videoState[n],i},{})}set paused(i){i!==this._paused&&(this._paused=i,this.requestUpdate(),this.dispatchEvent(new CustomEvent(i?"pause":"play")))}get paused(){return this._paused}set playbackRate(i){i!==this._playbackRate&&(this._playbackRate=i,this.scenes.forEach(({video:t})=>{t&&(t.node.playbackRate=i)}),this.requestUpdate(),this.dispatchEvent(new CustomEvent("ratechange",{detail:i})))}get playbackRate(){return this._playbackRate}set volume(i){const t=Math.min(1,Math.max(0,i));t!==this._volume&&(this.scenes.forEach(({video:e})=>{e&&(e.node.volume=t)}),localStorage.setItem("vmp-player-volume",t.toString()),this._volume=t,t>0&&(this.muted=!1),this.requestUpdate(),this.dispatchEvent(new CustomEvent("volumechange",{detail:i})))}get volume(){return this._volume??(this._volume=parseFloat(localStorage.getItem("vmp-player-volume")??"1"))}set muted(i){this.scenes.forEach(({video:t})=>{t&&(t.node.muted=i)}),i!==this._muted&&(this._muted=i,localStorage.setItem("vmp-player-muted",i.toString()),this.requestUpdate(),this.dispatchEvent(new CustomEvent("volumechange",{detail:i?0:this.volume})))}get muted(){return this._muted??(this._muted=this.autoplay||localStorage.getItem("vmp-player-muted")==="true")}set videoResolution(i){i!==this._videoResolution&&(this._videoResolution=i,this.scenes.forEach(({video:t})=>{if(t!=null&&t.hls){const e=t.hls.levels.findIndex(r=>Math.min(r.height,r.width)===i);t.hls.currentLevel=e??-1}}),this.requestUpdate())}get videoResolution(){return this._videoResolution}set currentTime(i){i!==this._drawController.currentTime&&(this._drawController.currentTime=i,this._sceneController.setVideosCurrentTime(i))}get currentTime(){return this._drawController.currentTime}reset(i=0,t=!1){this._lastTimestamp=null,this._drawController.currentTime=i,this._sceneController.setVideosCurrentTime(i),t?this.play():this.pause()}clear(){this._drawController.clear()}play(){this.paused=!1,this._lastTimestamp=null,this.duration>0&&this._drawController.currentTime>=this.duration&&this.reset(0,!0),this._loop()}pause(){this._endLoop(),this.paused=!0,this.scenes.forEach(({video:i})=>{i&&i.node.pause()})}draw(i){return this._drawController.draw(i)}setScene(i){var t,e;if((t=this._sceneController)!=null&&t.scenes){const r=(e=this.scenes)==null?void 0:e[i];if(!r){const n=new Ni(`No scene at index: ${i}`);return this.dispatchEvent(new ErrorEvent("error",{composed:!0,bubbles:!0,error:n,message:n.message}))}this.reset(r.start+this._sceneController.scenes.transitionDuration,!this.paused)}}toggleFullscreen(i){i??this.fullscreen?TA():this._playerRef.value&&AA(this._playerRef.value)}connectedCallback(){var i;super.connectedCallback(),this.addEventListener("error",this._handleError),document.addEventListener("fullscreenchange",this._handleFullscreenChange),document.addEventListener("visibilitychange",this._handleVisibilityChange),(i=this.shadowRoot)!=null&&i.host&&(this._observer=new ResizeObserver(this._handleContainerResize),this._observer.observe(this.shadowRoot.host))}willUpdate(){this.propAspectRatio&&(this._aspectRatio=this.propAspectRatio)}updated(i){i.has("propAspectRatio")&&!this.propAspectRatio&&this._handleContainerResize(),this.autoplay&&!this.processing&&!this._sceneController.hasPlayed&&i.has("_processing")&&this.play()}disconnectedCallback(){var i;super.disconnectedCallback(),(i=this._observer)==null||i.disconnect(),document.removeEventListener("fullscreenchange",this._handleFullscreenChange),document.removeEventListener("visibilitychange",this._handleVisibilityChange)}_renderStyles(){return this.propAspectRatio?typeof this.propAspectRatio=="number"?Yt`
1419
+ `],Dr([At({type:Boolean})],yr.prototype,"loading",2),Dr([At({type:Boolean})],yr.prototype,"playing",2),Dr([At({type:Number})],yr.prototype,"volume",2),Dr([At({type:Boolean})],yr.prototype,"muted",2),Dr([At({type:Number})],yr.prototype,"currentTime",2),Dr([At({type:Number})],yr.prototype,"duration",2),Dr([At({type:Array,attribute:!1})],yr.prototype,"levels",2),Dr([At({type:Number})],yr.prototype,"level",2),Dr([At({type:Number})],yr.prototype,"playbackRate",2),Dr([At({type:String})],yr.prototype,"caption",2),Dr([At({type:Array})],yr.prototype,"buffer",2),Dr([At({type:Boolean})],yr.prototype,"captions",2),Dr([At({type:Boolean})],yr.prototype,"fullscreen",2),Dr([At({type:Array})],yr.prototype,"controls",2),Dr([mr()],yr.prototype,"showControls",2),yr=Dr([Fr("vmp-player-overlay")],yr);var uT=Object.defineProperty,fT=Object.getOwnPropertyDescriptor,sr=(i,t,e,r)=>{for(var n=r>1?void 0:r?fT(t,e):t,o=i.length-1,l;o>=0;o--)(l=i[o])&&(n=(r?l(t,e,n):l(n))||n);return r&&n&&uT(t,e,n),n};const pT=1e3/60;let rr=class extends xe{constructor(){super(...arguments),this.burnCaptions=!1,this.debug=!1,this.propAspectRatio=0,this.preload="auto",this.autoplay=!1,this.loading=!1,this.compilation=tc,this._sceneController=new bA(this),this._drawController=new Ky(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=wr(),this._canvasRef=wr(),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 i;(i=this.shadowRoot)!=null&&i.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,pT):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=(i=performance.now())=>{this.sceneConfig&&this.scenes.length>0&&(this._waiting=this._drawController.activeScenes.some(({video:t})=>{if(t){const{key:e}=t,r=this.videoState[e];return!r||!r.initialised||r.waiting||t.node.readyState<3}}),this.waiting?(this._lastTimestamp=null,this._lastWaiting||this.dispatchEvent(new CustomEvent("waiting"))):this._lastWaiting&&this.dispatchEvent(new CustomEvent("playing")),i-(this._lastTimestamp??0)>1e3/this.sceneConfig.frameRate&&(this._drawController.currentTime=this._drawController.currentTime+(i-(this._lastTimestamp??i))/1e3*this.playbackRate,this._lastTimestamp=i),this._lastWaiting=this._waiting,this._drawController.currentTime>=this.duration&&(this.pause(),this.dispatchEvent(new CustomEvent("ended")))),this.paused||this._loop()},this._handleError=i=>{this._errors=[...this.errors,i.error],i.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(i=>{const t=setInterval(()=>{this.errors.find(e=>e.fatal)&&i(!1),!this.loading&&!this.processing&&this.scenes.length>0&&i(!0)},500);setTimeout(()=>{clearInterval(t),i(!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 i;return((i=this._sceneController.scenes)==null?void 0:i.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((i,{video:t,start:e,duration:r})=>{const n=(t==null?void 0:t.key)??`${e}-${r}`;return i[n]=this.videoState[n],i},{})}set paused(i){i!==this._paused&&(this._paused=i,this.requestUpdate(),this.dispatchEvent(new CustomEvent(i?"pause":"play")))}get paused(){return this._paused}set playbackRate(i){i!==this._playbackRate&&(this._playbackRate=i,this.scenes.forEach(({video:t})=>{t&&(t.node.playbackRate=i)}),this.requestUpdate(),this.dispatchEvent(new CustomEvent("ratechange",{detail:i})))}get playbackRate(){return this._playbackRate}set volume(i){const t=Math.min(1,Math.max(0,i));t!==this._volume&&(this.scenes.forEach(({video:e})=>{e&&(e.node.volume=t)}),localStorage.setItem("vmp-player-volume",t.toString()),this._volume=t,t>0&&(this.muted=!1),this.requestUpdate(),this.dispatchEvent(new CustomEvent("volumechange",{detail:i})))}get volume(){return this._volume??(this._volume=parseFloat(localStorage.getItem("vmp-player-volume")??"1"))}set muted(i){this.scenes.forEach(({video:t})=>{t&&(t.node.muted=i)}),i!==this._muted&&(this._muted=i,localStorage.setItem("vmp-player-muted",i.toString()),this.requestUpdate(),this.dispatchEvent(new CustomEvent("volumechange",{detail:i?0:this.volume})))}get muted(){return this._muted??(this._muted=this.autoplay||localStorage.getItem("vmp-player-muted")==="true")}set videoResolution(i){i!==this._videoResolution&&(this._videoResolution=i,this.scenes.forEach(({video:t})=>{if(t!=null&&t.hls){const e=t.hls.levels.findIndex(r=>Math.min(r.height,r.width)===i);t.hls.currentLevel=e??-1}}),this.requestUpdate())}get videoResolution(){return this._videoResolution}set currentTime(i){i!==this._drawController.currentTime&&(this._drawController.currentTime=i,this._sceneController.setVideosCurrentTime(i))}get currentTime(){return this._drawController.currentTime}reset(i=0,t=!1){this._lastTimestamp=null,this._drawController.currentTime=i,this._sceneController.setVideosCurrentTime(i),t?this.play():this.pause()}clear(){this._drawController.clear()}play(){this.paused=!1,this._lastTimestamp=null,this.duration>0&&this._drawController.currentTime>=this.duration&&this.reset(0,!0),this._loop()}pause(){this._endLoop(),this.paused=!0,this.scenes.forEach(({video:i})=>{i&&i.node.pause()})}draw(i){return this._drawController.draw(i)}setScene(i){var t,e;if((t=this._sceneController)!=null&&t.scenes){const r=(e=this.scenes)==null?void 0:e[i];if(!r){const n=new Ni(`No scene at index: ${i}`);return this.dispatchEvent(new ErrorEvent("error",{composed:!0,bubbles:!0,error:n,message:n.message}))}this.reset(r.start+this._sceneController.scenes.transitionDuration,!this.paused)}}toggleFullscreen(i){i??this.fullscreen?AA():this._playerRef.value&&EA(this._playerRef.value)}connectedCallback(){var i;super.connectedCallback(),this.addEventListener("error",this._handleError),document.addEventListener("fullscreenchange",this._handleFullscreenChange),document.addEventListener("visibilitychange",this._handleVisibilityChange),(i=this.shadowRoot)!=null&&i.host&&(this._observer=new ResizeObserver(this._handleContainerResize),this._observer.observe(this.shadowRoot.host))}willUpdate(){this.propAspectRatio&&(this._aspectRatio=this.propAspectRatio)}updated(i){i.has("propAspectRatio")&&!this.propAspectRatio&&this._handleContainerResize(),this.autoplay&&!this.processing&&!this._sceneController.hasPlayed&&i.has("_processing")&&this.play()}disconnectedCallback(){var i;super.disconnectedCallback(),(i=this._observer)==null||i.disconnect(),document.removeEventListener("fullscreenchange",this._handleFullscreenChange),document.removeEventListener("visibilitychange",this._handleVisibilityChange)}_renderStyles(){return this.propAspectRatio?typeof this.propAspectRatio=="number"?Yt`
1420
1420
  <style>
1421
1421
  :host {
1422
1422
  aspect-ratio: ${this.propAspectRatio};
@@ -1437,7 +1437,7 @@ ${t}`,t1=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),e1=Objec
1437
1437
  <vmp-text semibold content="An error has occurred when attempting to play this video."></vmp-text>
1438
1438
  <vmp-text semibold content="Please try again later."></vmp-text>
1439
1439
  </div>
1440
- </div>`}render(){var i,t,e,r,n,o;const l=this.loading||this.processing||!this.scenes||this.duration<=0,{height:d,width:f}=ec({resolution:((i=this.sceneConfig)==null?void 0:i.resolution)??720,aspectRatio:this.aspectRatio}),p=Object.keys(this.sceneVideoState).reduce((M,U)=>M.concat(this.sceneVideoState[U].buffered??[]),[]),g=l?[]:(t=this.controls??xh)==null?void 0:t.filter(M=>!(M==="fullscreen"&&yA()||M==="navigation"&&(!this.scenes||this.scenes.length<=1))),v=!(g!=null&&g.includes("preview")),E=(((e=this.scenes)==null?void 0:e.length)??0)-1,A=((r=this.scenes)==null?void 0:r.findIndex(M=>M===this._drawController.activeScenes[0]))??0,T=(o=(n=this._drawController.activeScenes[0])==null?void 0:n.video)==null?void 0:o.hls,w=this.loading||this.waiting||this.processing,C=!this.src&&!this.data,D=!!this.errors.find(M=>M.fatal);return Yt`
1440
+ </div>`}render(){var i,t,e,r,n,o;const l=this.loading||this.processing||!this.scenes||this.duration<=0,{height:d,width:f}=ec({resolution:((i=this.sceneConfig)==null?void 0:i.resolution)??720,aspectRatio:this.aspectRatio}),p=Object.keys(this.sceneVideoState).reduce((M,U)=>M.concat(this.sceneVideoState[U].buffered??[]),[]),g=l?[]:(t=this.controls??xh)==null?void 0:t.filter(M=>!(M==="fullscreen"&&vA()||M==="navigation"&&(!this.scenes||this.scenes.length<=1))),v=!(g!=null&&g.includes("preview")),E=(((e=this.scenes)==null?void 0:e.length)??0)-1,A=((r=this.scenes)==null?void 0:r.findIndex(M=>M===this._drawController.activeScenes[0]))??0,T=(o=(n=this._drawController.activeScenes[0])==null?void 0:n.video)==null?void 0:o.hls,w=this.loading||this.waiting||this.processing,C=!this.src&&!this.data,D=!!this.errors.find(M=>M.fatal);return Yt`
1441
1441
  ${this._renderStyles()}
1442
1442
  <div
1443
1443
  ${Sr(this._playerRef)}
@@ -1551,7 +1551,7 @@ ${t}`,t1=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),e1=Objec
1551
1551
  top: 0;
1552
1552
  left: 0;
1553
1553
  }
1554
- `],sr([At({type:Object})],rr.prototype,"data",2),sr([At({type:Object})],rr.prototype,"template",2),sr([At({type:Boolean})],rr.prototype,"burnCaptions",2),sr([At({type:Boolean})],rr.prototype,"debug",2),sr([At({type:String})],rr.prototype,"src",2),sr([At({type:String})],rr.prototype,"track",2),sr([At({type:Number,attribute:"aspectratio"})],rr.prototype,"propAspectRatio",2),sr([At({type:String})],rr.prototype,"preload",2),sr([At({type:Boolean})],rr.prototype,"autoplay",2),sr([At({type:Boolean})],rr.prototype,"loading",2),sr([At({type:Array})],rr.prototype,"controls",2),sr([At({attribute:!1})],rr.prototype,"compilation",2),sr([mr()],rr.prototype,"_pageHidden",2),sr([mr()],rr.prototype,"_aspectRatio",2),sr([mr()],rr.prototype,"_processing",2),sr([mr()],rr.prototype,"_waiting",2),sr([mr()],rr.prototype,"_errors",2),sr([mr()],rr.prototype,"_seeking",2),sr([mr()],rr.prototype,"_captions",2),sr([mr()],rr.prototype,"_fullscreen",2),rr=sr([Fr("vmp-media-player")],rr);var mT=Object.defineProperty,vT=Object.getOwnPropertyDescriptor,Ur=(i,t,e,r)=>{for(var n=r>1?void 0:r?vT(t,e):t,o=i.length-1,l;o>=0;o--)(l=i[o])&&(n=(r?l(t,e,n):l(n))||n);return r&&n&&mT(t,e,n),n};ae.PlayerEmbed=class extends fv(ts){constructor(){super(...arguments),this.env="prod",this.apiKey="",this.disableTracking=!1,this.trackingSource="embedded_player",this.preload="auto",this.autoplay=!1,this.aspectRatio=0,this.eventController=new dm(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 $m(this),this._trackingController=new uv(this)}get fetching(){return this._fetcherController.fetching}_renderStyles(){return this.aspectRatio?typeof this.aspectRatio=="number"?Yt`
1554
+ `],sr([At({type:Object})],rr.prototype,"data",2),sr([At({type:Object})],rr.prototype,"template",2),sr([At({type:Boolean})],rr.prototype,"burnCaptions",2),sr([At({type:Boolean})],rr.prototype,"debug",2),sr([At({type:String})],rr.prototype,"src",2),sr([At({type:String})],rr.prototype,"track",2),sr([At({type:Number,attribute:"aspectratio"})],rr.prototype,"propAspectRatio",2),sr([At({type:String})],rr.prototype,"preload",2),sr([At({type:Boolean})],rr.prototype,"autoplay",2),sr([At({type:Boolean})],rr.prototype,"loading",2),sr([At({type:Array})],rr.prototype,"controls",2),sr([At({attribute:!1})],rr.prototype,"compilation",2),sr([mr()],rr.prototype,"_pageHidden",2),sr([mr()],rr.prototype,"_aspectRatio",2),sr([mr()],rr.prototype,"_processing",2),sr([mr()],rr.prototype,"_waiting",2),sr([mr()],rr.prototype,"_errors",2),sr([mr()],rr.prototype,"_seeking",2),sr([mr()],rr.prototype,"_captions",2),sr([mr()],rr.prototype,"_fullscreen",2),rr=sr([Fr("vmp-media-player")],rr);var gT=Object.defineProperty,mT=Object.getOwnPropertyDescriptor,Ur=(i,t,e,r)=>{for(var n=r>1?void 0:r?mT(t,e):t,o=i.length-1,l;o>=0;o--)(l=i[o])&&(n=(r?l(t,e,n):l(n))||n);return r&&n&&gT(t,e,n),n};ae.PlayerEmbed=class extends ts{constructor(){super(...arguments),this.env="prod",this.apiKey="",this.disableTracking=!1,this.trackingSource="embedded_player",this.preload="auto",this.autoplay=!1,this.aspectRatio=0,this.eventController=new dm(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 $m(this),this._trackingController=new uv(this),this._mediaPlayerRef=wr()}get fetching(){return this._fetcherController.fetching}get waiting(){var t;return(t=this._mediaPlayerRef.value)==null?void 0:t.waiting}get initialised(){var t;return(t=this._mediaPlayerRef.value)==null?void 0:t.initialised}get seeking(){var t;return(t=this._mediaPlayerRef.value)==null?void 0:t.seeking}get paused(){var t;return(t=this._mediaPlayerRef.value)==null?void 0:t.paused}get captions(){var t;return(t=this._mediaPlayerRef.value)==null?void 0:t.captions}get fullscreen(){var t;return(t=this._mediaPlayerRef.value)==null?void 0:t.fullscreen}get duration(){var t;return(t=this._mediaPlayerRef.value)==null?void 0:t.duration}set currentTime(t){this._mediaPlayerRef.value&&(this._mediaPlayerRef.value.currentTime=t)}get currentTime(){var t;return((t=this._mediaPlayerRef.value)==null?void 0:t.currentTime)??0}set playbackRate(t){this._mediaPlayerRef.value&&(this._mediaPlayerRef.value.playbackRate=t)}get playbackRate(){var t;return((t=this._mediaPlayerRef.value)==null?void 0:t.playbackRate)??1}set volume(t){this._mediaPlayerRef.value&&(this._mediaPlayerRef.value.volume=t)}get volume(){var t;return((t=this._mediaPlayerRef.value)==null?void 0:t.volume)??1}set muted(t){this._mediaPlayerRef.value&&(this._mediaPlayerRef.value.muted=t)}get muted(){var t;return((t=this._mediaPlayerRef.value)==null?void 0:t.muted)??!1}get scene(){var t;return((t=this._mediaPlayerRef.value)==null?void 0:t.scene)??null}get scenes(){var t;return((t=this._mediaPlayerRef.value)==null?void 0:t.scenes)??[]}get sceneConfig(){var t;return((t=this._mediaPlayerRef.value)==null?void 0:t.sceneConfig)??null}get videoState(){var t;return(t=this._mediaPlayerRef.value)==null?void 0:t.videoState}get mediaPlayer(){return this._mediaPlayerRef.value}play(){var t;(t=this._mediaPlayerRef.value)==null||t.play()}pause(){var t;(t=this._mediaPlayerRef.value)==null||t.pause()}reset(t=0,e=!1){var r;(r=this._mediaPlayerRef.value)==null||r.reset(t,e)}setScene(t){var e;(e=this._mediaPlayerRef.value)==null||e.setScene(t)}_renderStyles(){return this.aspectRatio?typeof this.aspectRatio=="number"?Yt`
1555
1555
  <style>
1556
1556
  :host {
1557
1557
  aspect-ratio: ${this.aspectRatio};
@@ -1581,12 +1581,12 @@ ${t}`,t1=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),e1=Objec
1581
1581
  :host {
1582
1582
  display: flex;
1583
1583
  }
1584
- `],Ur([At({type:Object})],ae.PlayerEmbed.prototype,"data",2),Ur([At({type:String})],ae.PlayerEmbed.prototype,"vouchId",2),Ur([At({type:String})],ae.PlayerEmbed.prototype,"templateId",2),Ur([At({type:Array})],ae.PlayerEmbed.prototype,"questions",2),Ur([At({type:String})],ae.PlayerEmbed.prototype,"env",2),Ur([At({type:String})],ae.PlayerEmbed.prototype,"apiKey",2),Ur([At({type:Boolean})],ae.PlayerEmbed.prototype,"disableTracking",2),Ur([At({type:String})],ae.PlayerEmbed.prototype,"trackingSource",2),Ur([At({type:Array})],ae.PlayerEmbed.prototype,"controls",2),Ur([At({type:String})],ae.PlayerEmbed.prototype,"preload",2),Ur([At({type:Boolean})],ae.PlayerEmbed.prototype,"autoplay",2),Ur([At({type:Number})],ae.PlayerEmbed.prototype,"aspectRatio",2),Ur([mr()],ae.PlayerEmbed.prototype,"vouch",2),Ur([mr()],ae.PlayerEmbed.prototype,"template",2),ae.PlayerEmbed=Ur([ao("vouch-embed-player")],ae.PlayerEmbed);function dl(i,t,e,r=20,n=0){let o=[];if(n>=r)return o;const l=f=>{const p=f.assignedNodes().filter(g=>g.nodeType===1);return p.length>0?dl(p[0].parentElement,t,e,r,n+1):[]},d=Array.from(i.children||[]);for(const f of d)t(f)||(e(f)&&o.push(f),f.shadowRoot!=null?o.push(...dl(f.shadowRoot,t,e,r,n+1)):f.tagName==="SLOT"?o.push(...l(f)):o.push(...dl(f,t,e,r,n+1)));return o}function zp(i){return i.hasAttribute("hidden")||i.hasAttribute("aria-hidden")&&i.getAttribute("aria-hidden")!=="false"||i.style.display==="none"||i.style.opacity==="0"||i.style.visibility==="hidden"||i.style.visibility==="collapse"}function yT(i){return i.hasAttribute("disabled")||i.hasAttribute("aria-disabled")&&i.getAttribute("aria-disabled")!=="false"}function bT(i){return i.getAttribute("tabindex")==="-1"||zp(i)||yT(i)?!1:i.hasAttribute("tabindex")||(i instanceof HTMLAnchorElement||i instanceof HTMLAreaElement)&&i.hasAttribute("href")||i instanceof HTMLButtonElement||i instanceof HTMLInputElement||i instanceof HTMLTextAreaElement||i instanceof HTMLSelectElement||i instanceof HTMLIFrameElement}const Fh=new Map;function ET(i,t,e){const r=Fh.get(e);r!=null&&window.clearTimeout(r),Fh.set(e,window.setTimeout(()=>{i(),Fh.delete(e)},t))}const Yp=document.createElement("template");Yp.innerHTML=`
1584
+ `],Ur([At({type:Object})],ae.PlayerEmbed.prototype,"data",2),Ur([At({type:String})],ae.PlayerEmbed.prototype,"vouchId",2),Ur([At({type:String})],ae.PlayerEmbed.prototype,"templateId",2),Ur([At({type:Array})],ae.PlayerEmbed.prototype,"questions",2),Ur([At({type:String})],ae.PlayerEmbed.prototype,"env",2),Ur([At({type:String})],ae.PlayerEmbed.prototype,"apiKey",2),Ur([At({type:Boolean})],ae.PlayerEmbed.prototype,"disableTracking",2),Ur([At({type:String})],ae.PlayerEmbed.prototype,"trackingSource",2),Ur([At({type:Array})],ae.PlayerEmbed.prototype,"controls",2),Ur([At({type:String})],ae.PlayerEmbed.prototype,"preload",2),Ur([At({type:Boolean})],ae.PlayerEmbed.prototype,"autoplay",2),Ur([At({type:Number})],ae.PlayerEmbed.prototype,"aspectRatio",2),Ur([mr()],ae.PlayerEmbed.prototype,"vouch",2),Ur([mr()],ae.PlayerEmbed.prototype,"template",2),ae.PlayerEmbed=Ur([ao("vouch-embed-player")],ae.PlayerEmbed);function dl(i,t,e,r=20,n=0){let o=[];if(n>=r)return o;const l=f=>{const p=f.assignedNodes().filter(g=>g.nodeType===1);return p.length>0?dl(p[0].parentElement,t,e,r,n+1):[]},d=Array.from(i.children||[]);for(const f of d)t(f)||(e(f)&&o.push(f),f.shadowRoot!=null?o.push(...dl(f.shadowRoot,t,e,r,n+1)):f.tagName==="SLOT"?o.push(...l(f)):o.push(...dl(f,t,e,r,n+1)));return o}function zp(i){return i.hasAttribute("hidden")||i.hasAttribute("aria-hidden")&&i.getAttribute("aria-hidden")!=="false"||i.style.display==="none"||i.style.opacity==="0"||i.style.visibility==="hidden"||i.style.visibility==="collapse"}function vT(i){return i.hasAttribute("disabled")||i.hasAttribute("aria-disabled")&&i.getAttribute("aria-disabled")!=="false"}function yT(i){return i.getAttribute("tabindex")==="-1"||zp(i)||vT(i)?!1:i.hasAttribute("tabindex")||(i instanceof HTMLAnchorElement||i instanceof HTMLAreaElement)&&i.hasAttribute("href")||i instanceof HTMLButtonElement||i instanceof HTMLInputElement||i instanceof HTMLTextAreaElement||i instanceof HTMLSelectElement||i instanceof HTMLIFrameElement}const Fh=new Map;function bT(i,t,e){const r=Fh.get(e);r!=null&&window.clearTimeout(r),Fh.set(e,window.setTimeout(()=>{i(),Fh.delete(e)},t))}const Yp=document.createElement("template");Yp.innerHTML=`
1585
1585
  <div id="start"></div>
1586
1586
  <div id="backup"></div>
1587
1587
  <slot></slot>
1588
1588
  <div id="end"></div>
1589
- `;class AT extends HTMLElement{constructor(){super(),this.debounceId=Math.random().toString(),this._focused=!1;const t=this.attachShadow({mode:"open"});t.appendChild(Yp.content.cloneNode(!0)),this.$backup=t.querySelector("#backup"),this.$start=t.querySelector("#start"),this.$end=t.querySelector("#end"),this.focusLastElement=this.focusLastElement.bind(this),this.focusFirstElement=this.focusFirstElement.bind(this),this.onFocusIn=this.onFocusIn.bind(this),this.onFocusOut=this.onFocusOut.bind(this)}static get observedAttributes(){return["inactive"]}get inactive(){return this.hasAttribute("inactive")}set inactive(t){t?this.setAttribute("inactive",""):this.removeAttribute("inactive")}get focused(){return this._focused}connectedCallback(){this.$start.addEventListener("focus",this.focusLastElement),this.$end.addEventListener("focus",this.focusFirstElement),this.addEventListener("focusin",this.onFocusIn),this.addEventListener("focusout",this.onFocusOut),this.render()}disconnectedCallback(){this.$start.removeEventListener("focus",this.focusLastElement),this.$end.removeEventListener("focus",this.focusFirstElement),this.removeEventListener("focusin",this.onFocusIn),this.removeEventListener("focusout",this.onFocusOut)}attributeChangedCallback(){this.render()}focusFirstElement(){this.trapFocus()}focusLastElement(){this.trapFocus(!0)}getFocusableElements(){return dl(this,zp,bT)}trapFocus(t){if(this.inactive)return;let e=this.getFocusableElements();e.length>0?(t?e[e.length-1].focus():e[0].focus(),this.$backup.setAttribute("tabindex","-1")):(this.$backup.setAttribute("tabindex","0"),this.$backup.focus())}onFocusIn(){this.updateFocused(!0)}onFocusOut(){this.updateFocused(!1)}updateFocused(t){ET(()=>{this.focused!==t&&(this._focused=t,this.render())},0,this.debounceId)}render(){this.$start.setAttribute("tabindex",!this.focused||this.inactive?"-1":"0"),this.$end.setAttribute("tabindex",!this.focused||this.inactive?"-1":"0"),this.focused?this.setAttribute("focused",""):this.removeAttribute("focused")}}window.customElements.define("focus-trap",AT);var TT=Object.defineProperty,kT=Object.getOwnPropertyDescriptor,Uh=(i,t,e,r)=>{for(var n=r>1?void 0:r?kT(t,e):t,o=i.length-1,l;o>=0;o--)(l=i[o])&&(n=(r?l(t,e,n):l(n))||n);return r&&n&&TT(t,e,n),n};let Wa=class extends ts{constructor(){super(...arguments),this.open=!1,this.aspectRatio=0}render(){return Yt`
1589
+ `;class ET extends HTMLElement{constructor(){super(),this.debounceId=Math.random().toString(),this._focused=!1;const t=this.attachShadow({mode:"open"});t.appendChild(Yp.content.cloneNode(!0)),this.$backup=t.querySelector("#backup"),this.$start=t.querySelector("#start"),this.$end=t.querySelector("#end"),this.focusLastElement=this.focusLastElement.bind(this),this.focusFirstElement=this.focusFirstElement.bind(this),this.onFocusIn=this.onFocusIn.bind(this),this.onFocusOut=this.onFocusOut.bind(this)}static get observedAttributes(){return["inactive"]}get inactive(){return this.hasAttribute("inactive")}set inactive(t){t?this.setAttribute("inactive",""):this.removeAttribute("inactive")}get focused(){return this._focused}connectedCallback(){this.$start.addEventListener("focus",this.focusLastElement),this.$end.addEventListener("focus",this.focusFirstElement),this.addEventListener("focusin",this.onFocusIn),this.addEventListener("focusout",this.onFocusOut),this.render()}disconnectedCallback(){this.$start.removeEventListener("focus",this.focusLastElement),this.$end.removeEventListener("focus",this.focusFirstElement),this.removeEventListener("focusin",this.onFocusIn),this.removeEventListener("focusout",this.onFocusOut)}attributeChangedCallback(){this.render()}focusFirstElement(){this.trapFocus()}focusLastElement(){this.trapFocus(!0)}getFocusableElements(){return dl(this,zp,yT)}trapFocus(t){if(this.inactive)return;let e=this.getFocusableElements();e.length>0?(t?e[e.length-1].focus():e[0].focus(),this.$backup.setAttribute("tabindex","-1")):(this.$backup.setAttribute("tabindex","0"),this.$backup.focus())}onFocusIn(){this.updateFocused(!0)}onFocusOut(){this.updateFocused(!1)}updateFocused(t){bT(()=>{this.focused!==t&&(this._focused=t,this.render())},0,this.debounceId)}render(){this.$start.setAttribute("tabindex",!this.focused||this.inactive?"-1":"0"),this.$end.setAttribute("tabindex",!this.focused||this.inactive?"-1":"0"),this.focused?this.setAttribute("focused",""):this.removeAttribute("focused")}}window.customElements.define("focus-trap",ET);var AT=Object.defineProperty,TT=Object.getOwnPropertyDescriptor,Uh=(i,t,e,r)=>{for(var n=r>1?void 0:r?TT(t,e):t,o=i.length-1,l;o>=0;o--)(l=i[o])&&(n=(r?l(t,e,n):l(n))||n);return r&&n&&AT(t,e,n),n};let Wa=class extends ts{constructor(){super(...arguments),this.open=!1,this.aspectRatio=0}render(){return Yt`
1590
1590
  <div
1591
1591
  class=${He({container:!0,hidden:!this.open})}
1592
1592
  >
@@ -1673,7 +1673,7 @@ ${t}`,t1=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),e1=Objec
1673
1673
  right: 0;
1674
1674
  margin: 10px;
1675
1675
  }
1676
- `],Uh([At({type:Boolean})],Wa.prototype,"open",2),Uh([At({type:Number})],Wa.prototype,"aspectRatio",2),Wa=Uh([ao("vouch-embed-dialog-overlay")],Wa);var wT=Object.defineProperty,ST=Object.getOwnPropertyDescriptor,ni=(i,t,e,r)=>{for(var n=r>1?void 0:r?ST(t,e):t,o=i.length-1,l;o>=0;o--)(l=i[o])&&(n=(r?l(t,e,n):l(n))||n);return r&&n&&wT(t,e,n),n};let Qr=class extends ts{constructor(){super(...arguments),this.env="prod",this.apiKey="",this.disableTracking=!1,this.trackingSource="embedded_player",this.preload="none",this.disableAutoplay=!1,this.aspectRatio=0,this._mediaPlayerRef=wr(),this.open=!1,this._handleToggle=({detail:i})=>{var t,e,r;this.id===i&&(this.open=!this.open,this.open?!this.disableAutoplay&&((t=this._mediaPlayerRef)!=null&&t.value)&&(this._mediaPlayerRef.value.muted=!1,this._mediaPlayerRef.value.play()):(r=(e=this._mediaPlayerRef)==null?void 0:e.value)==null||r.pause())},this._handleClose=()=>{var i,t;this.open=!1,(t=(i=this._mediaPlayerRef)==null?void 0:i.value)==null||t.pause()},this._handleDocumentKeyUp=i=>{i.key==="Escape"&&this._handleClose()}}connectedCallback(){super.connectedCallback(),document.addEventListener("dialogembed:click",this._handleToggle),document.addEventListener("keyup",this._handleDocumentKeyUp),document.addEventListener("close:click",this._handleClose),document.addEventListener("overlay:click",this._handleClose)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("dialogembed:click",this._handleToggle),document.removeEventListener("keyup",this._handleDocumentKeyUp),document.removeEventListener("close:click",this._handleClose),document.removeEventListener("overlay:click",this._handleClose)}createRenderRoot(){const i=document.createElement("div");return document.body.appendChild(i),i}render(){return Yt`
1676
+ `],Uh([At({type:Boolean})],Wa.prototype,"open",2),Uh([At({type:Number})],Wa.prototype,"aspectRatio",2),Wa=Uh([ao("vouch-embed-dialog-overlay")],Wa);var kT=Object.defineProperty,wT=Object.getOwnPropertyDescriptor,ni=(i,t,e,r)=>{for(var n=r>1?void 0:r?wT(t,e):t,o=i.length-1,l;o>=0;o--)(l=i[o])&&(n=(r?l(t,e,n):l(n))||n);return r&&n&&kT(t,e,n),n};let Qr=class extends ts{constructor(){super(...arguments),this.env="prod",this.apiKey="",this.disableTracking=!1,this.trackingSource="embedded_player",this.preload="none",this.disableAutoplay=!1,this.aspectRatio=0,this._mediaPlayerRef=wr(),this.open=!1,this._handleToggle=({detail:i})=>{var t,e,r;this.id===i&&(this.open=!this.open,this.open?!this.disableAutoplay&&((t=this._mediaPlayerRef)!=null&&t.value)&&(this._mediaPlayerRef.value.muted=!1,this._mediaPlayerRef.value.play()):(r=(e=this._mediaPlayerRef)==null?void 0:e.value)==null||r.pause())},this._handleClose=()=>{var i,t;this.open=!1,(t=(i=this._mediaPlayerRef)==null?void 0:i.value)==null||t.pause()},this._handleDocumentKeyUp=i=>{i.key==="Escape"&&this._handleClose()}}connectedCallback(){super.connectedCallback(),document.addEventListener("dialogembed:click",this._handleToggle),document.addEventListener("keyup",this._handleDocumentKeyUp),document.addEventListener("close:click",this._handleClose),document.addEventListener("overlay:click",this._handleClose)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("dialogembed:click",this._handleToggle),document.removeEventListener("keyup",this._handleDocumentKeyUp),document.removeEventListener("close:click",this._handleClose),document.removeEventListener("overlay:click",this._handleClose)}createRenderRoot(){const i=document.createElement("div");return document.body.appendChild(i),i}render(){return Yt`
1677
1677
  <vouch-embed-dialog-overlay ?open=${this.open} aspectRatio=${this.aspectRatio}>
1678
1678
  <vouch-embed-player
1679
1679
  ${Sr(this._mediaPlayerRef)}
@@ -1691,7 +1691,7 @@ ${t}`,t1=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),e1=Objec
1691
1691
  aspectRatio=${this.aspectRatio}
1692
1692
  ></vouch-embed-player>
1693
1693
  </vouch-embed-dialog-overlay>
1694
- `}};ni([At({type:String})],Qr.prototype,"vouchId",2),ni([At({type:String})],Qr.prototype,"templateId",2),ni([At({type:Array})],Qr.prototype,"questions",2),ni([At({type:String})],Qr.prototype,"env",2),ni([At({type:String})],Qr.prototype,"apiKey",2),ni([At({type:Boolean})],Qr.prototype,"disableTracking",2),ni([At({type:String})],Qr.prototype,"trackingSource",2),ni([At({type:Array})],Qr.prototype,"controls",2),ni([At({type:String})],Qr.prototype,"preload",2),ni([At({type:Boolean})],Qr.prototype,"disableAutoplay",2),ni([At({type:Number})],Qr.prototype,"aspectRatio",2),ni([mr()],Qr.prototype,"open",2),Qr=ni([ao("vouch-embed-dialog-portal")],Qr);var RT=Object.defineProperty,_T=Object.getOwnPropertyDescriptor,mi=(i,t,e,r)=>{for(var n=r>1?void 0:r?_T(t,e):t,o=i.length-1,l;o>=0;o--)(l=i[o])&&(n=(r?l(t,e,n):l(n))||n);return r&&n&&RT(t,e,n),n};ae.DialogEmbed=class extends ts{constructor(){super(...arguments),this.env="prod",this.apiKey="",this.disableTracking=!1,this.trackingSource="embedded_player",this.preload="none",this.disableAutoplay=!1,this.aspectRatio=0,this._id=ks(),this._handleRootClick=()=>{this.dispatchEvent(new CustomEvent("dialogembed:click",{detail:this._id,bubbles:!0,composed:!0}))}}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this._handleRootClick)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("click",this._handleRootClick)}render(){return Yt`
1694
+ `}};ni([At({type:String})],Qr.prototype,"vouchId",2),ni([At({type:String})],Qr.prototype,"templateId",2),ni([At({type:Array})],Qr.prototype,"questions",2),ni([At({type:String})],Qr.prototype,"env",2),ni([At({type:String})],Qr.prototype,"apiKey",2),ni([At({type:Boolean})],Qr.prototype,"disableTracking",2),ni([At({type:String})],Qr.prototype,"trackingSource",2),ni([At({type:Array})],Qr.prototype,"controls",2),ni([At({type:String})],Qr.prototype,"preload",2),ni([At({type:Boolean})],Qr.prototype,"disableAutoplay",2),ni([At({type:Number})],Qr.prototype,"aspectRatio",2),ni([mr()],Qr.prototype,"open",2),Qr=ni([ao("vouch-embed-dialog-portal")],Qr);var ST=Object.defineProperty,RT=Object.getOwnPropertyDescriptor,mi=(i,t,e,r)=>{for(var n=r>1?void 0:r?RT(t,e):t,o=i.length-1,l;o>=0;o--)(l=i[o])&&(n=(r?l(t,e,n):l(n))||n);return r&&n&&ST(t,e,n),n};ae.DialogEmbed=class extends ts{constructor(){super(...arguments),this.env="prod",this.apiKey="",this.disableTracking=!1,this.trackingSource="embedded_player",this.preload="none",this.disableAutoplay=!1,this.aspectRatio=0,this._id=ks(),this._handleRootClick=()=>{this.dispatchEvent(new CustomEvent("dialogembed:click",{detail:this._id,bubbles:!0,composed:!0}))}}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this._handleRootClick)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("click",this._handleRootClick)}render(){return Yt`
1695
1695
  <slot>
1696
1696
  <vmp-button size="large">Play</vmp-button>
1697
1697
  </slot>
@@ -1719,5 +1719,5 @@ ${t}`,t1=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),e1=Objec
1719
1719
  width: fit-content;
1720
1720
  height: fit-content;
1721
1721
  }
1722
- `],mi([At({type:String})],ae.DialogEmbed.prototype,"vouchId",2),mi([At({type:String})],ae.DialogEmbed.prototype,"templateId",2),mi([At({type:Array})],ae.DialogEmbed.prototype,"questions",2),mi([At({type:String})],ae.DialogEmbed.prototype,"env",2),mi([At({type:String})],ae.DialogEmbed.prototype,"apiKey",2),mi([At({type:Boolean})],ae.DialogEmbed.prototype,"disableTracking",2),mi([At({type:String})],ae.DialogEmbed.prototype,"trackingSource",2),mi([At({type:Array})],ae.DialogEmbed.prototype,"controls",2),mi([At({type:String})],ae.DialogEmbed.prototype,"preload",2),mi([At({type:Boolean})],ae.DialogEmbed.prototype,"disableAutoplay",2),mi([At({type:Number})],ae.DialogEmbed.prototype,"aspectRatio",2),ae.DialogEmbed=mi([ao("vouch-embed-dialog")],ae.DialogEmbed);function Hi(i){if(typeof i!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(i))}function Xp(i,t){for(var e="",r=0,n=-1,o=0,l,d=0;d<=i.length;++d){if(d<i.length)l=i.charCodeAt(d);else{if(l===47)break;l=47}if(l===47){if(!(n===d-1||o===1))if(n!==d-1&&o===2){if(e.length<2||r!==2||e.charCodeAt(e.length-1)!==46||e.charCodeAt(e.length-2)!==46){if(e.length>2){var f=e.lastIndexOf("/");if(f!==e.length-1){f===-1?(e="",r=0):(e=e.slice(0,f),r=e.length-1-e.lastIndexOf("/")),n=d,o=0;continue}}else if(e.length===2||e.length===1){e="",r=0,n=d,o=0;continue}}t&&(e.length>0?e+="/..":e="..",r=2)}else e.length>0?e+="/"+i.slice(n+1,d):e=i.slice(n+1,d),r=d-n-1;n=d,o=0}else l===46&&o!==-1?++o:o=-1}return e}function LT(i,t){var e=t.dir||t.root,r=t.base||(t.name||"")+(t.ext||"");return e?e===t.root?e+r:e+i+r:r}var Bn={resolve:function(){for(var t="",e=!1,r,n=arguments.length-1;n>=-1&&!e;n--){var o;n>=0?o=arguments[n]:(r===void 0&&(r=process.cwd()),o=r),Hi(o),o.length!==0&&(t=o+"/"+t,e=o.charCodeAt(0)===47)}return t=Xp(t,!e),e?t.length>0?"/"+t:"/":t.length>0?t:"."},normalize:function(t){if(Hi(t),t.length===0)return".";var e=t.charCodeAt(0)===47,r=t.charCodeAt(t.length-1)===47;return t=Xp(t,!e),t.length===0&&!e&&(t="."),t.length>0&&r&&(t+="/"),e?"/"+t:t},isAbsolute:function(t){return Hi(t),t.length>0&&t.charCodeAt(0)===47},join:function(){if(arguments.length===0)return".";for(var t,e=0;e<arguments.length;++e){var r=arguments[e];Hi(r),r.length>0&&(t===void 0?t=r:t+="/"+r)}return t===void 0?".":Bn.normalize(t)},relative:function(t,e){if(Hi(t),Hi(e),t===e||(t=Bn.resolve(t),e=Bn.resolve(e),t===e))return"";for(var r=1;r<t.length&&t.charCodeAt(r)===47;++r);for(var n=t.length,o=n-r,l=1;l<e.length&&e.charCodeAt(l)===47;++l);for(var d=e.length,f=d-l,p=o<f?o:f,g=-1,v=0;v<=p;++v){if(v===p){if(f>p){if(e.charCodeAt(l+v)===47)return e.slice(l+v+1);if(v===0)return e.slice(l+v)}else o>p&&(t.charCodeAt(r+v)===47?g=v:v===0&&(g=0));break}var E=t.charCodeAt(r+v),A=e.charCodeAt(l+v);if(E!==A)break;E===47&&(g=v)}var T="";for(v=r+g+1;v<=n;++v)(v===n||t.charCodeAt(v)===47)&&(T.length===0?T+="..":T+="/..");return T.length>0?T+e.slice(l+g):(l+=g,e.charCodeAt(l)===47&&++l,e.slice(l))},_makeLong:function(t){return t},dirname:function(t){if(Hi(t),t.length===0)return".";for(var e=t.charCodeAt(0),r=e===47,n=-1,o=!0,l=t.length-1;l>=1;--l)if(e=t.charCodeAt(l),e===47){if(!o){n=l;break}}else o=!1;return n===-1?r?"/":".":r&&n===1?"//":t.slice(0,n)},basename:function(t,e){if(e!==void 0&&typeof e!="string")throw new TypeError('"ext" argument must be a string');Hi(t);var r=0,n=-1,o=!0,l;if(e!==void 0&&e.length>0&&e.length<=t.length){if(e.length===t.length&&e===t)return"";var d=e.length-1,f=-1;for(l=t.length-1;l>=0;--l){var p=t.charCodeAt(l);if(p===47){if(!o){r=l+1;break}}else f===-1&&(o=!1,f=l+1),d>=0&&(p===e.charCodeAt(d)?--d===-1&&(n=l):(d=-1,n=f))}return r===n?n=f:n===-1&&(n=t.length),t.slice(r,n)}else{for(l=t.length-1;l>=0;--l)if(t.charCodeAt(l)===47){if(!o){r=l+1;break}}else n===-1&&(o=!1,n=l+1);return n===-1?"":t.slice(r,n)}},extname:function(t){Hi(t);for(var e=-1,r=0,n=-1,o=!0,l=0,d=t.length-1;d>=0;--d){var f=t.charCodeAt(d);if(f===47){if(!o){r=d+1;break}continue}n===-1&&(o=!1,n=d+1),f===46?e===-1?e=d:l!==1&&(l=1):e!==-1&&(l=-1)}return e===-1||n===-1||l===0||l===1&&e===n-1&&e===r+1?"":t.slice(e,n)},format:function(t){if(t===null||typeof t!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof t);return LT("/",t)},parse:function(t){Hi(t);var e={root:"",dir:"",base:"",ext:"",name:""};if(t.length===0)return e;var r=t.charCodeAt(0),n=r===47,o;n?(e.root="/",o=1):o=0;for(var l=-1,d=0,f=-1,p=!0,g=t.length-1,v=0;g>=o;--g){if(r=t.charCodeAt(g),r===47){if(!p){d=g+1;break}continue}f===-1&&(p=!1,f=g+1),r===46?l===-1?l=g:v!==1&&(v=1):l!==-1&&(v=-1)}return l===-1||f===-1||v===0||v===1&&l===f-1&&l===d+1?f!==-1&&(d===0&&n?e.base=e.name=t.slice(1,f):e.base=e.name=t.slice(d,f)):(d===0&&n?(e.name=t.slice(1,l),e.base=t.slice(1,f)):(e.name=t.slice(d,l),e.base=t.slice(d,f)),e.ext=t.slice(l,f)),d>0?e.dir=t.slice(0,d-1):n&&(e.dir="/"),e},sep:"/",delimiter:":",win32:null,posix:null};Bn.posix=Bn;var CT=Bn;const{basename:Zp,extname:IT}=CT;class xT{constructor(){let t=(()=>typeof fo>"u")(),e="image/png",r="image/jpeg",n="image/jpeg",o="image/webp",l="application/pdf",d="image/svg+xml";Object.assign(this,{toMime:this.toMime.bind(this),fromMime:this.fromMime.bind(this),expected:t?'"png", "jpg", or "webp"':'"png", "jpg", "pdf", or "svg"',formats:t?{png:e,jpg:r,jpeg:n,webp:o}:{png:e,jpg:r,jpeg:n,pdf:l,svg:d},mimes:t?{[e]:"png",[r]:"jpg",[o]:"webp"}:{[e]:"png",[r]:"jpg",[l]:"pdf",[d]:"svg"}})}toMime(t){return this.formats[(t||"").replace(/^\./,"").toLowerCase()]}fromMime(t){return this.mimes[t]}}function DT(i,{filename:t="",extension:e="",format:w,page:n,quality:o,matte:l,density:d,outline:f,archive:A}={}){var{fromMime:g,toMime:v,expected:E}=new xT,A=A||"canvas",T=w||e.replace(/@\d+x$/i,"")||IT(t),w=g(v(T)||T),C=v(w),D=i.length;if(!T)throw new Error("Cannot determine image format (use a filename extension or 'format' argument)");if(!w)throw new Error(`Unsupported file format "${T}" (expected ${E})`);if(!D)throw new RangeError("Canvas has no associated contexts (try calling getContext or newPage first)");let M,U,x=t.replace(/{(\d*)}/g,(K,B)=>(U=!0,B=parseInt(B,10),M=isFinite(B)?B:isFinite(M)?M:-1,"{}")),O=n>0?n-1:n<0?D+n:void 0;if(isFinite(O)&&O<0||O>=D)throw new RangeError(D==1?`Canvas only has a ‘page 1’ (${O} is out of bounds)`:`Canvas has pages 1–${D} (${O} is out of bounds)`);if(i=isFinite(O)?[i[O]]:U||w=="pdf"?i:i.slice(-1),o===void 0)o=.92;else if(typeof o!="number"||!isFinite(o)||o<0||o>1)throw new TypeError("The quality option must be an number in the 0.0–1.0 range");if(d===void 0){let K=(e||Zp(t,T)).match(/@(\d+)x$/i);d=K?parseInt(K[1],10):1}else if(typeof d!="number"||!Number.isInteger(d)||d<1)throw new TypeError("The density option must be a non-negative integer");return f===void 0?f=!0:w=="svg"&&(f=!!f),{filename:t,pattern:x,format:w,mime:C,pages:i,padding:M,quality:o,matte:l,density:d,outline:f,archive:A}}class ul{static for(t){return new ul().append(t).get()}constructor(){this.crc=-1}get(){return~this.crc}append(t){for(var e=this.crc|0,r=this.table,n=0,o=t.length|0;n<o;n++)e=e>>>8^r[(e^t[n])&255];return this.crc=e,this}}ul.prototype.table=(()=>{var i,t,e,r=[];for(i=0;i<256;i++){for(e=i,t=0;t<8;t++)e=e&1?e>>>1^3988292384:e>>>1;r[i]=e}return r})();function Bh(i){let t=new Uint8Array(i),e=new DataView(t.buffer),r={array:t,view:e,size:i,set8(n,o){return e.setUint8(n,o),r},set16(n,o){return e.setUint16(n,o,!0),r},set32(n,o){return e.setUint32(n,o,!0),r},bytes(n,o){return t.set(o,n),r}};return r}const fl=class fl{constructor(t){let e=new Date;Object.assign(this,{directory:t,offset:0,files:[],time:(e.getHours()<<6|e.getMinutes())<<5|e.getSeconds()/2,date:(e.getFullYear()-1980<<4|e.getMonth()+1)<<5|e.getDate()}),this.add(t)}async add(t,e){let r=!e,n=fl.encoder.encode(`${this.directory}/${r?"":t}`),o=new Uint8Array(r?0:await e.arrayBuffer()),l=30+n.length,d=l+o.length,f=16,{offset:p}=this,g=Bh(26).set32(0,134742036).set16(6,this.time).set16(8,this.date).set32(10,ul.for(o)).set32(14,o.length).set32(18,o.length).set16(22,n.length);p+=l;let v=Bh(l+o.length+f).set32(0,67324752).bytes(4,g.array).bytes(30,n).bytes(l,o);p+=o.length,v.set32(d,134695760).bytes(d+4,g.array.slice(10,22)),p+=f,this.files.push({offset:p,folder:r,name:n,header:g,payload:v}),this.offset=p}toBuffer(){let t=this.files.reduce((v,{name:E})=>46+E.length+v,0),e=Bh(t+22),r=0;for(var{offset:n,name:o,header:l,folder:d}of this.files)e.set32(r,33639248).set16(r+4,20).bytes(r+6,l.array).set8(r+38,d?16:0).set32(r+42,n).bytes(r+46,o),r+=46+o.length;e.set32(r,101010256).set16(r+8,this.files.length).set16(r+10,this.files.length).set32(r+12,t).set32(r+16,this.offset);let f=new Uint8Array(this.offset+e.size),p=0;for(var{payload:g}of this.files)f.set(g.array,p),p+=g.size;return f.set(e.array,p),f}get blob(){return new Blob([this.toBuffer()],{type:"application/zip"})}};bg(fl,"encoder",new TextEncoder);let Gh=fl;const Hh=(i,t,e,r)=>{if(r){let{width:n,height:o}=i,l=Object.assign(document.createElement("canvas"),{width:n,height:o}),d=l.getContext("2d");d.fillStyle=r,d.fillRect(0,0,n,o),d.drawImage(i,0,0),i=l}return new Promise((n,o)=>i.toBlob(n,t,e))},PT=(...i)=>Hh(...i).then(t=>t.arrayBuffer()),OT=async(i,t,e,r,n)=>{qp(n,await Hh(i,t,e,r))},$T=async(i,t,e,r,n,o,l)=>{let d=g=>o.replace("{}",String(g+1).padStart(l,"0")),f=Zp(n,".zip")||"archive",p=new Gh(f);await Promise.all(i.map(async(g,v)=>{let E=d(v);await p.add(E,await Hh(g,t,e,r))})),qp(`${f}.zip`,p.blob)},qp=(i,t)=>{const e=window.URL.createObjectURL(t),r=document.createElement("a");r.style.display="none",r.href=e,r.setAttribute("download",i),typeof r.download>"u"&&r.setAttribute("target","_blank"),document.body.appendChild(r),r.click(),document.body.removeChild(r),setTimeout(()=>window.URL.revokeObjectURL(e),100)};var MT={asBuffer:PT,asDownload:OT,asZipDownload:$T,atScale:(i,t,e)=>i.map(r=>{if(t==1&&!e)return r.canvas;let n=document.createElement("canvas"),o=n.getContext("2d"),l=r.canvas?r.canvas:r;return n.width=l.width*t,n.height=l.height*t,e&&(o.fillStyle=e,o.fillRect(0,0,n.width,n.height)),o.scale(t,t),o.drawImage(l,0,0),n}),options:DT};const{asBuffer:Vh,asDownload:NT,asZipDownload:FT,atScale:Wh,options:jh}=MT,Qp=Symbol.for("toDataURL"),UT=i=>{let t=Object.assign(new Jp,{crossOrigin:"Anonymous",src:i});return t.decode().then(()=>t)};class BT{constructor(t,e){let r=document.createElement("canvas"),n=[];Object.defineProperty(r,"async",{value:!0,writable:!1,enumerable:!0});for(var[o,l]of Object.entries({png:()=>Vh(r,"image/png"),jpg:()=>Vh(r,"image/jpeg"),pages:()=>n.concat(r).map(d=>d.getContext("2d"))}))Object.defineProperty(r,o,{get:l});return Object.assign(r,{width:t,height:e,newPage(...d){var{width:p,height:g}=r,f=Object.assign(document.createElement("canvas"),{width:p,height:g});f.getContext("2d").drawImage(r,0,0),n.push(f);var[p,g]=d.length?d:[p,g];return Object.assign(r,{width:p,height:g}).getContext("2d")},saveAs(d,f){f=typeof f=="number"?{quality:f}:f;let p=jh(this.pages,{filename:d,...f}),{pattern:g,padding:v,mime:E,quality:A,matte:T,density:w,archive:C}=p,D=Wh(p.pages,w);return v==null?NT(D[0],E,A,T,d):FT(D,E,A,T,C,g,v)},toBuffer(d="png",f={}){f=typeof f=="number"?{quality:f}:f;let p=jh(this.pages,{extension:d,...f}),{mime:g,quality:v,matte:E,pages:A,density:T}=p,w=Wh(A,T,E)[0];return Vh(w,g,v,E)},[Qp]:r.toDataURL.bind(r),toDataURL(d="png",f={}){f=typeof f=="number"?{quality:f}:f;let p=jh(this.pages,{extension:d,...f}),{mime:g,quality:v,matte:E,pages:A,density:T}=p,w=Wh(A,T,E)[0],C=w[w===r?Qp:"toDataURL"](g,v);return Promise.resolve(C)}})}}const{CanvasRenderingContext2D:GT,CanvasGradient:HT,CanvasPattern:VT,Image:Jp,ImageData:WT,Path2D:jT,DOMMatrix:KT,DOMRect:zT,DOMPoint:YT}=window;var t2={Canvas:BT,loadImage:UT,CanvasRenderingContext2D:GT,CanvasGradient:HT,CanvasPattern:VT,Image:Jp,ImageData:WT,Path2D:jT,DOMMatrix:KT,DOMRect:zT,DOMPoint:YT};const e2=Qi({__proto__:null,default:ql(t2)},[t2]);return Object.defineProperty(ae,Symbol.toStringTag,{value:"Module"}),ae}({});
1722
+ `],mi([At({type:String})],ae.DialogEmbed.prototype,"vouchId",2),mi([At({type:String})],ae.DialogEmbed.prototype,"templateId",2),mi([At({type:Array})],ae.DialogEmbed.prototype,"questions",2),mi([At({type:String})],ae.DialogEmbed.prototype,"env",2),mi([At({type:String})],ae.DialogEmbed.prototype,"apiKey",2),mi([At({type:Boolean})],ae.DialogEmbed.prototype,"disableTracking",2),mi([At({type:String})],ae.DialogEmbed.prototype,"trackingSource",2),mi([At({type:Array})],ae.DialogEmbed.prototype,"controls",2),mi([At({type:String})],ae.DialogEmbed.prototype,"preload",2),mi([At({type:Boolean})],ae.DialogEmbed.prototype,"disableAutoplay",2),mi([At({type:Number})],ae.DialogEmbed.prototype,"aspectRatio",2),ae.DialogEmbed=mi([ao("vouch-embed-dialog")],ae.DialogEmbed);function Hi(i){if(typeof i!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(i))}function Xp(i,t){for(var e="",r=0,n=-1,o=0,l,d=0;d<=i.length;++d){if(d<i.length)l=i.charCodeAt(d);else{if(l===47)break;l=47}if(l===47){if(!(n===d-1||o===1))if(n!==d-1&&o===2){if(e.length<2||r!==2||e.charCodeAt(e.length-1)!==46||e.charCodeAt(e.length-2)!==46){if(e.length>2){var f=e.lastIndexOf("/");if(f!==e.length-1){f===-1?(e="",r=0):(e=e.slice(0,f),r=e.length-1-e.lastIndexOf("/")),n=d,o=0;continue}}else if(e.length===2||e.length===1){e="",r=0,n=d,o=0;continue}}t&&(e.length>0?e+="/..":e="..",r=2)}else e.length>0?e+="/"+i.slice(n+1,d):e=i.slice(n+1,d),r=d-n-1;n=d,o=0}else l===46&&o!==-1?++o:o=-1}return e}function _T(i,t){var e=t.dir||t.root,r=t.base||(t.name||"")+(t.ext||"");return e?e===t.root?e+r:e+i+r:r}var Bn={resolve:function(){for(var t="",e=!1,r,n=arguments.length-1;n>=-1&&!e;n--){var o;n>=0?o=arguments[n]:(r===void 0&&(r=process.cwd()),o=r),Hi(o),o.length!==0&&(t=o+"/"+t,e=o.charCodeAt(0)===47)}return t=Xp(t,!e),e?t.length>0?"/"+t:"/":t.length>0?t:"."},normalize:function(t){if(Hi(t),t.length===0)return".";var e=t.charCodeAt(0)===47,r=t.charCodeAt(t.length-1)===47;return t=Xp(t,!e),t.length===0&&!e&&(t="."),t.length>0&&r&&(t+="/"),e?"/"+t:t},isAbsolute:function(t){return Hi(t),t.length>0&&t.charCodeAt(0)===47},join:function(){if(arguments.length===0)return".";for(var t,e=0;e<arguments.length;++e){var r=arguments[e];Hi(r),r.length>0&&(t===void 0?t=r:t+="/"+r)}return t===void 0?".":Bn.normalize(t)},relative:function(t,e){if(Hi(t),Hi(e),t===e||(t=Bn.resolve(t),e=Bn.resolve(e),t===e))return"";for(var r=1;r<t.length&&t.charCodeAt(r)===47;++r);for(var n=t.length,o=n-r,l=1;l<e.length&&e.charCodeAt(l)===47;++l);for(var d=e.length,f=d-l,p=o<f?o:f,g=-1,v=0;v<=p;++v){if(v===p){if(f>p){if(e.charCodeAt(l+v)===47)return e.slice(l+v+1);if(v===0)return e.slice(l+v)}else o>p&&(t.charCodeAt(r+v)===47?g=v:v===0&&(g=0));break}var E=t.charCodeAt(r+v),A=e.charCodeAt(l+v);if(E!==A)break;E===47&&(g=v)}var T="";for(v=r+g+1;v<=n;++v)(v===n||t.charCodeAt(v)===47)&&(T.length===0?T+="..":T+="/..");return T.length>0?T+e.slice(l+g):(l+=g,e.charCodeAt(l)===47&&++l,e.slice(l))},_makeLong:function(t){return t},dirname:function(t){if(Hi(t),t.length===0)return".";for(var e=t.charCodeAt(0),r=e===47,n=-1,o=!0,l=t.length-1;l>=1;--l)if(e=t.charCodeAt(l),e===47){if(!o){n=l;break}}else o=!1;return n===-1?r?"/":".":r&&n===1?"//":t.slice(0,n)},basename:function(t,e){if(e!==void 0&&typeof e!="string")throw new TypeError('"ext" argument must be a string');Hi(t);var r=0,n=-1,o=!0,l;if(e!==void 0&&e.length>0&&e.length<=t.length){if(e.length===t.length&&e===t)return"";var d=e.length-1,f=-1;for(l=t.length-1;l>=0;--l){var p=t.charCodeAt(l);if(p===47){if(!o){r=l+1;break}}else f===-1&&(o=!1,f=l+1),d>=0&&(p===e.charCodeAt(d)?--d===-1&&(n=l):(d=-1,n=f))}return r===n?n=f:n===-1&&(n=t.length),t.slice(r,n)}else{for(l=t.length-1;l>=0;--l)if(t.charCodeAt(l)===47){if(!o){r=l+1;break}}else n===-1&&(o=!1,n=l+1);return n===-1?"":t.slice(r,n)}},extname:function(t){Hi(t);for(var e=-1,r=0,n=-1,o=!0,l=0,d=t.length-1;d>=0;--d){var f=t.charCodeAt(d);if(f===47){if(!o){r=d+1;break}continue}n===-1&&(o=!1,n=d+1),f===46?e===-1?e=d:l!==1&&(l=1):e!==-1&&(l=-1)}return e===-1||n===-1||l===0||l===1&&e===n-1&&e===r+1?"":t.slice(e,n)},format:function(t){if(t===null||typeof t!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof t);return _T("/",t)},parse:function(t){Hi(t);var e={root:"",dir:"",base:"",ext:"",name:""};if(t.length===0)return e;var r=t.charCodeAt(0),n=r===47,o;n?(e.root="/",o=1):o=0;for(var l=-1,d=0,f=-1,p=!0,g=t.length-1,v=0;g>=o;--g){if(r=t.charCodeAt(g),r===47){if(!p){d=g+1;break}continue}f===-1&&(p=!1,f=g+1),r===46?l===-1?l=g:v!==1&&(v=1):l!==-1&&(v=-1)}return l===-1||f===-1||v===0||v===1&&l===f-1&&l===d+1?f!==-1&&(d===0&&n?e.base=e.name=t.slice(1,f):e.base=e.name=t.slice(d,f)):(d===0&&n?(e.name=t.slice(1,l),e.base=t.slice(1,f)):(e.name=t.slice(d,l),e.base=t.slice(d,f)),e.ext=t.slice(l,f)),d>0?e.dir=t.slice(0,d-1):n&&(e.dir="/"),e},sep:"/",delimiter:":",win32:null,posix:null};Bn.posix=Bn;var LT=Bn;const{basename:Zp,extname:CT}=LT;class IT{constructor(){let t=(()=>typeof fo>"u")(),e="image/png",r="image/jpeg",n="image/jpeg",o="image/webp",l="application/pdf",d="image/svg+xml";Object.assign(this,{toMime:this.toMime.bind(this),fromMime:this.fromMime.bind(this),expected:t?'"png", "jpg", or "webp"':'"png", "jpg", "pdf", or "svg"',formats:t?{png:e,jpg:r,jpeg:n,webp:o}:{png:e,jpg:r,jpeg:n,pdf:l,svg:d},mimes:t?{[e]:"png",[r]:"jpg",[o]:"webp"}:{[e]:"png",[r]:"jpg",[l]:"pdf",[d]:"svg"}})}toMime(t){return this.formats[(t||"").replace(/^\./,"").toLowerCase()]}fromMime(t){return this.mimes[t]}}function xT(i,{filename:t="",extension:e="",format:w,page:n,quality:o,matte:l,density:d,outline:f,archive:A}={}){var{fromMime:g,toMime:v,expected:E}=new IT,A=A||"canvas",T=w||e.replace(/@\d+x$/i,"")||CT(t),w=g(v(T)||T),C=v(w),D=i.length;if(!T)throw new Error("Cannot determine image format (use a filename extension or 'format' argument)");if(!w)throw new Error(`Unsupported file format "${T}" (expected ${E})`);if(!D)throw new RangeError("Canvas has no associated contexts (try calling getContext or newPage first)");let M,U,x=t.replace(/{(\d*)}/g,(K,B)=>(U=!0,B=parseInt(B,10),M=isFinite(B)?B:isFinite(M)?M:-1,"{}")),O=n>0?n-1:n<0?D+n:void 0;if(isFinite(O)&&O<0||O>=D)throw new RangeError(D==1?`Canvas only has a ‘page 1’ (${O} is out of bounds)`:`Canvas has pages 1–${D} (${O} is out of bounds)`);if(i=isFinite(O)?[i[O]]:U||w=="pdf"?i:i.slice(-1),o===void 0)o=.92;else if(typeof o!="number"||!isFinite(o)||o<0||o>1)throw new TypeError("The quality option must be an number in the 0.0–1.0 range");if(d===void 0){let K=(e||Zp(t,T)).match(/@(\d+)x$/i);d=K?parseInt(K[1],10):1}else if(typeof d!="number"||!Number.isInteger(d)||d<1)throw new TypeError("The density option must be a non-negative integer");return f===void 0?f=!0:w=="svg"&&(f=!!f),{filename:t,pattern:x,format:w,mime:C,pages:i,padding:M,quality:o,matte:l,density:d,outline:f,archive:A}}class ul{static for(t){return new ul().append(t).get()}constructor(){this.crc=-1}get(){return~this.crc}append(t){for(var e=this.crc|0,r=this.table,n=0,o=t.length|0;n<o;n++)e=e>>>8^r[(e^t[n])&255];return this.crc=e,this}}ul.prototype.table=(()=>{var i,t,e,r=[];for(i=0;i<256;i++){for(e=i,t=0;t<8;t++)e=e&1?e>>>1^3988292384:e>>>1;r[i]=e}return r})();function Bh(i){let t=new Uint8Array(i),e=new DataView(t.buffer),r={array:t,view:e,size:i,set8(n,o){return e.setUint8(n,o),r},set16(n,o){return e.setUint16(n,o,!0),r},set32(n,o){return e.setUint32(n,o,!0),r},bytes(n,o){return t.set(o,n),r}};return r}const fl=class fl{constructor(t){let e=new Date;Object.assign(this,{directory:t,offset:0,files:[],time:(e.getHours()<<6|e.getMinutes())<<5|e.getSeconds()/2,date:(e.getFullYear()-1980<<4|e.getMonth()+1)<<5|e.getDate()}),this.add(t)}async add(t,e){let r=!e,n=fl.encoder.encode(`${this.directory}/${r?"":t}`),o=new Uint8Array(r?0:await e.arrayBuffer()),l=30+n.length,d=l+o.length,f=16,{offset:p}=this,g=Bh(26).set32(0,134742036).set16(6,this.time).set16(8,this.date).set32(10,ul.for(o)).set32(14,o.length).set32(18,o.length).set16(22,n.length);p+=l;let v=Bh(l+o.length+f).set32(0,67324752).bytes(4,g.array).bytes(30,n).bytes(l,o);p+=o.length,v.set32(d,134695760).bytes(d+4,g.array.slice(10,22)),p+=f,this.files.push({offset:p,folder:r,name:n,header:g,payload:v}),this.offset=p}toBuffer(){let t=this.files.reduce((v,{name:E})=>46+E.length+v,0),e=Bh(t+22),r=0;for(var{offset:n,name:o,header:l,folder:d}of this.files)e.set32(r,33639248).set16(r+4,20).bytes(r+6,l.array).set8(r+38,d?16:0).set32(r+42,n).bytes(r+46,o),r+=46+o.length;e.set32(r,101010256).set16(r+8,this.files.length).set16(r+10,this.files.length).set32(r+12,t).set32(r+16,this.offset);let f=new Uint8Array(this.offset+e.size),p=0;for(var{payload:g}of this.files)f.set(g.array,p),p+=g.size;return f.set(e.array,p),f}get blob(){return new Blob([this.toBuffer()],{type:"application/zip"})}};bg(fl,"encoder",new TextEncoder);let Gh=fl;const Hh=(i,t,e,r)=>{if(r){let{width:n,height:o}=i,l=Object.assign(document.createElement("canvas"),{width:n,height:o}),d=l.getContext("2d");d.fillStyle=r,d.fillRect(0,0,n,o),d.drawImage(i,0,0),i=l}return new Promise((n,o)=>i.toBlob(n,t,e))},DT=(...i)=>Hh(...i).then(t=>t.arrayBuffer()),PT=async(i,t,e,r,n)=>{qp(n,await Hh(i,t,e,r))},OT=async(i,t,e,r,n,o,l)=>{let d=g=>o.replace("{}",String(g+1).padStart(l,"0")),f=Zp(n,".zip")||"archive",p=new Gh(f);await Promise.all(i.map(async(g,v)=>{let E=d(v);await p.add(E,await Hh(g,t,e,r))})),qp(`${f}.zip`,p.blob)},qp=(i,t)=>{const e=window.URL.createObjectURL(t),r=document.createElement("a");r.style.display="none",r.href=e,r.setAttribute("download",i),typeof r.download>"u"&&r.setAttribute("target","_blank"),document.body.appendChild(r),r.click(),document.body.removeChild(r),setTimeout(()=>window.URL.revokeObjectURL(e),100)};var $T={asBuffer:DT,asDownload:PT,asZipDownload:OT,atScale:(i,t,e)=>i.map(r=>{if(t==1&&!e)return r.canvas;let n=document.createElement("canvas"),o=n.getContext("2d"),l=r.canvas?r.canvas:r;return n.width=l.width*t,n.height=l.height*t,e&&(o.fillStyle=e,o.fillRect(0,0,n.width,n.height)),o.scale(t,t),o.drawImage(l,0,0),n}),options:xT};const{asBuffer:Vh,asDownload:MT,asZipDownload:NT,atScale:Wh,options:jh}=$T,Qp=Symbol.for("toDataURL"),FT=i=>{let t=Object.assign(new Jp,{crossOrigin:"Anonymous",src:i});return t.decode().then(()=>t)};class UT{constructor(t,e){let r=document.createElement("canvas"),n=[];Object.defineProperty(r,"async",{value:!0,writable:!1,enumerable:!0});for(var[o,l]of Object.entries({png:()=>Vh(r,"image/png"),jpg:()=>Vh(r,"image/jpeg"),pages:()=>n.concat(r).map(d=>d.getContext("2d"))}))Object.defineProperty(r,o,{get:l});return Object.assign(r,{width:t,height:e,newPage(...d){var{width:p,height:g}=r,f=Object.assign(document.createElement("canvas"),{width:p,height:g});f.getContext("2d").drawImage(r,0,0),n.push(f);var[p,g]=d.length?d:[p,g];return Object.assign(r,{width:p,height:g}).getContext("2d")},saveAs(d,f){f=typeof f=="number"?{quality:f}:f;let p=jh(this.pages,{filename:d,...f}),{pattern:g,padding:v,mime:E,quality:A,matte:T,density:w,archive:C}=p,D=Wh(p.pages,w);return v==null?MT(D[0],E,A,T,d):NT(D,E,A,T,C,g,v)},toBuffer(d="png",f={}){f=typeof f=="number"?{quality:f}:f;let p=jh(this.pages,{extension:d,...f}),{mime:g,quality:v,matte:E,pages:A,density:T}=p,w=Wh(A,T,E)[0];return Vh(w,g,v,E)},[Qp]:r.toDataURL.bind(r),toDataURL(d="png",f={}){f=typeof f=="number"?{quality:f}:f;let p=jh(this.pages,{extension:d,...f}),{mime:g,quality:v,matte:E,pages:A,density:T}=p,w=Wh(A,T,E)[0],C=w[w===r?Qp:"toDataURL"](g,v);return Promise.resolve(C)}})}}const{CanvasRenderingContext2D:BT,CanvasGradient:GT,CanvasPattern:HT,Image:Jp,ImageData:VT,Path2D:WT,DOMMatrix:jT,DOMRect:KT,DOMPoint:zT}=window;var t2={Canvas:UT,loadImage:FT,CanvasRenderingContext2D:BT,CanvasGradient:GT,CanvasPattern:HT,Image:Jp,ImageData:VT,Path2D:WT,DOMMatrix:jT,DOMRect:KT,DOMPoint:zT};const e2=Qi({__proto__:null,default:ql(t2)},[t2]);return Object.defineProperty(ae,Symbol.toStringTag,{value:"Module"}),ae}({});
1723
1723
  //# sourceMappingURL=embeds.iife.js.map