@namiml/web-sdk 3.4.4-dev.202607010221 → 3.4.4-dev.202607011943
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/nami-web.cjs +20 -20
- package/dist/nami-web.mjs +20 -20
- package/dist/nami-web.umd.js +33 -33
- package/package.json +2 -2
package/dist/nami-web.cjs
CHANGED
|
@@ -459,7 +459,7 @@
|
|
|
459
459
|
`),e,e,e,function(e){return Qd[e]||Qd.CheckCircleOutlined}(e))}},{key:"render",value:function(){return this.renderSvgIcon(this.shouldRenderCurrentIcon()?this.component.name:this.previousSymbolName)}}])}();Ae([ot({type:Object})],$k.prototype,"component",void 0),Ae([ot({type:Boolean})],$k.prototype,"inFocusedState",void 0),Ae([ot({type:Number})],$k.prototype,"scaleFactor",void 0),$k=Ae([Fe("nami-symbol")],$k);var Nk=function(){function e(){var t;return u(this,e),(t=s(this,e,arguments)).inFocusedState=!1,t.scaleFactor=1,t}return y(e,bs),m(e,[{key:"styles",value:function(){var e=this.component,i=this.scaleFactor,n=this.inFocusedState,a=e.hidden,r=e.fontSize,o=e.alignment,s=e.strikethrough,u=e.spacing;return t.unsafeCSS(`\n :host {\n line-height: ${Rk(r,i)}px;\n display: ${a?"none":"grid"};\n overflow-wrap: anywhere;\n width: fit-content;\n ${Rs(e,n)}\n ${Fk(e,n)}\n font-size: ${(null!=r?r:_k)*i}px;\n text-align: ${o||"center"};\n ${Gs("string"!=typeof s&&s)}\n ${Vs(e.fontName)}\n ${Ks(e,i,n)}\n ${Lk(e)}\n ${Fs(e)}\n ${function({alignment:e,horizontalAlignment:t}){return Ss("justify-content",t&&ws[t]?ws[t]:e&&ws[e]?ws[e]:"center")}(e)}\n }\n :host > :not(:first-child) {\n margin-top: ${u||0}px;\n }\n .anticon {\n text-rendering: optimizelegibility;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n color: inherit;\n display: inline-block;\n font-style: normal;\n line-height: 0;\n text-align: center;\n text-transform: none;\n vertical-align: -.125em;\n }\n .anticon svg {\n display: inline-block;\n line-height: 1;\n }\n\n :host .bullet-text-wrapper {\n line-height: ${Rk(r,i)}px;\n display: inline;\n overflow-wrap: anywhere;\n width: fit-content;\n ${Rs(e,n)}\n ${Fk(e,n)}\n font-size: ${(null!=r?r:_k)*i}px;\n text-align: ${o||"center"};\n ${Gs("string"!=typeof s&&s)}\n ${Vs(e.fontName)}\n }\n ${Lk(e,":host .bullet-text-wrapper")}\n :host .bullet-text-wrapper p {\n margin: 0;\n line-height: ${Rk(r,i)}px;\n }\n `)}},{key:"render",value:function(){var e=this.component,i=e.fontColor,n=e.fontSize,a=e.activeFontColor,r=e.bulletComponent,o=e.texts,s=e.spacing,u=r?v({fontColor:i,fontSize:n,activeFontColor:a,spacing:s},r):null;if(!Array.isArray(o))return t.html(Mk||(Mk=Ik``));var l=o.map(e=>e?t.html(Ak||(Ak=Ik`<nami-text-list-item-wrapper .component=${0} .scaleFactor=${0}>
|
|
460
460
|
${0}
|
|
461
461
|
<div class="bullet-text-wrapper" .innerHTML="${0}"></div>
|
|
462
|
-
</nami-text-list-item-wrapper>`),this.component,this.scaleFactor,u&&t.html(Dk||(Dk=Ik`<nami-symbol .component=${0} .scaleFactor=${0}></nami-symbol>`),u,this.scaleFactor),ql(e)):null);return t.html(xk||(xk=Ik`${0}`),l)}}])}();Ae([ot({type:Object})],Nk.prototype,"component",void 0),Ae([ot({type:Boolean})],Nk.prototype,"inFocusedState",void 0),Ae([ot({type:Number})],Nk.prototype,"scaleFactor",void 0),Nk=Ae([Fe("nami-text-list")],Nk);(()=>{var e,t=!0;try{new RegExp("","u"),new RegExp("😀","u"),new RegExp("\\p{P}","u")}catch(e){t=!1}if(!t){var i=null===(e=ql.Lexer)||void 0===e?void 0:e.rules,n=null==i?void 0:i.inline;n&&Object.values(n).forEach(e=>{e&&Object.keys(e).forEach(t=>{e[t]=(e=>{if(!(e instanceof RegExp))return e;if(!/\\p\{/.test(e.source))return e;var t="!\"#$%&'()*+,\\-./:;<=>?@[\\\\]^_`{|}~",i=e.source.replace(/\\p\{P\}\\p\{S\}/g,t).replace(/\\p\{P\}/g,t).replace(/\\p\{S\}/g,t),n=e.flags.replace(/u/g,"");return new RegExp(i,n)})(e[t])})})}})();var jk=function(){function e(){var t;return u(this,e),(t=s(this,e)).inFocusedState=!1,t.scaleFactor=1,t.handleFocusIn=()=>t.setFocusState(!0),t.handleFocusOut=e=>{var i,n,a=null!==(i=e.relatedTarget)&&void 0!==i?i:null;if(!a)return t.setFocusState(!1);a===t||null!==(n=t.shadowRoot)&&void 0!==n&&n.contains(a)||t.setFocusState(!1)},t.handleFocusChanged=e=>{var i=e.detail;t.setFocusState(!0===(null==i?void 0:i.inFocusedState))},t.addEventListener("focusin",t.handleFocusIn),t.addEventListener("focusout",t.handleFocusOut),t.addEventListener("focus-changed",t.handleFocusChanged),t}return y(e,bs),m(e,[{key:"disconnectedCallback",value:function(){M(e,"disconnectedCallback",this)([]),this.removeEventListener("focusin",this.handleFocusIn),this.removeEventListener("focusout",this.handleFocusOut),this.removeEventListener("focus-changed",this.handleFocusChanged)}},{key:"styles",value:function(){var e=this.component,i=this.scaleFactor,n=this.minSDKVersion,a=e.backgroundBlur,r="vertical"===e.direction,o=r?"width":"height",s=r?"margin-top":"margin-left",u=e.fillImage?t.unsafeCSS(`\n line-height: 1.5715;\n background-image: url(${e.fillImage});\n background-position: center;\n background-repeat: no-repeat;\n background-size: cover;\n height: 100%;\n width: 100%;\n `):t.unsafeCSS(Rs(e,!1));return t.unsafeCSS(`\n :host {\n box-sizing: border-box;\n display: ${e.hidden?"none":"flex"};\n ${a?`backdrop-filter: blur(${a}px);`:""}\n ${u};\n ${Ys(e.position)}\n ${Fs(e)}\n ${Ks(e,i,!1)}\n }\n :host(:focus),\n :host(.nami-focus-within){\n ${Rs(e,!0)}\n ${Ks(e,i,!0)}\n }\n :host(:focus-visible){\n ${Zs(e)}\n }\n :host > * {\n ${Ws(n,o)}\n }\n :host > *:not(:first-child) {\n ${s}: ${e.spacing?e.spacing*i:0}px;\n }\n `)}},{key:"render",value:function(){var e;return(null!==(e=this.component.components)&&void 0!==e?e:[]).map(e=>Iu(this.contextProvider,e,this.scaleFactor,void 0,this.minSDKVersion))}},{key:"setFocusState",value:function(e){this.inFocusedState!==e&&(this.inFocusedState=e,this.classList.toggle("nami-focus-within",e),this.toggleAttribute("data-nami-focused",e))}}])}();function Bk(e,t){return e===t||e!=e&&t!=t}function zk(e,t){for(var i=e.length;i--;)if(Bk(e[i][0],t))return i;return-1}Ae([ot({type:Object})],jk.prototype,"component",void 0),Ae([ot({type:Boolean})],jk.prototype,"inFocusedState",void 0),Ae([ot({type:Number})],jk.prototype,"scaleFactor",void 0),Ae([ot({type:Object})],jk.prototype,"minSDKVersion",void 0),jk=Ae([Fe("nami-container")],jk);var Uk=Array.prototype.splice;function Hk(e){var t=-1,i=null==e?0:e.length;for(this.clear();++t<i;){var n=e[t];this.set(n[0],n[1])}}function Gk(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}Hk.prototype.clear=function(){this.__data__=[],this.size=0},Hk.prototype.delete=function(e){var t=this.__data__,i=zk(t,e);return!(i<0)&&(i==t.length-1?t.pop():Uk.call(t,i,1),--this.size,!0)},Hk.prototype.get=function(e){var t=this.__data__,i=zk(t,e);return i<0?void 0:t[i][1]},Hk.prototype.has=function(e){return zk(this.__data__,e)>-1},Hk.prototype.set=function(e,t){var i=this.__data__,n=zk(i,e);return n<0?(++this.size,i.push([e,t])):i[n][1]=t,this};function Vk(e){if(!Gk(e))return!1;var t=Oi(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}var Kk,Xk=Ai["__core-js_shared__"],Yk=(Kk=/[^.]+$/.exec(Xk&&Xk.keys&&Xk.keys.IE_PROTO||""))?"Symbol(src)_1."+Kk:"";var qk=Function.prototype.toString;function Jk(e){if(null!=e){try{return qk.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var Qk=/^\[object .+?Constructor\]$/,Zk=Function.prototype,eS=Object.prototype,tS=Zk.toString,iS=eS.hasOwnProperty,nS=RegExp("^"+tS.call(iS).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function aS(e){return!(!Gk(e)||(t=e,Yk&&Yk in t))&&(Vk(e)?nS:Qk).test(Jk(e));var t}function rS(e,t){var i=function(e,t){return null==e?void 0:e[t]}(e,t);return aS(i)?i:void 0}var oS=rS(Ai,"Map"),sS=rS(Object,"create");var uS=Object.prototype.hasOwnProperty;var lS=Object.prototype.hasOwnProperty;function dS(e){var t=-1,i=null==e?0:e.length;for(this.clear();++t<i;){var n=e[t];this.set(n[0],n[1])}}function hS(e,t){var i,n,a=e.__data__;return("string"==(n=typeof(i=t))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==i:null===i)?a["string"==typeof t?"string":"hash"]:a.map}function cS(e){var t=-1,i=null==e?0:e.length;for(this.clear();++t<i;){var n=e[t];this.set(n[0],n[1])}}dS.prototype.clear=function(){this.__data__=sS?sS(null):{},this.size=0},dS.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},dS.prototype.get=function(e){var t=this.__data__;if(sS){var i=t[e];return"__lodash_hash_undefined__"===i?void 0:i}return uS.call(t,e)?t[e]:void 0},dS.prototype.has=function(e){var t=this.__data__;return sS?void 0!==t[e]:lS.call(t,e)},dS.prototype.set=function(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=sS&&void 0===t?"__lodash_hash_undefined__":t,this},cS.prototype.clear=function(){this.size=0,this.__data__={hash:new dS,map:new(oS||Hk),string:new dS}},cS.prototype.delete=function(e){var t=hS(this,e).delete(e);return this.size-=t?1:0,t},cS.prototype.get=function(e){return hS(this,e).get(e)},cS.prototype.has=function(e){return hS(this,e).has(e)},cS.prototype.set=function(e,t){var i=hS(this,e),n=i.size;return i.set(e,t),this.size+=i.size==n?0:1,this};function mS(e){var t=this.__data__=new Hk(e);this.size=t.size}mS.prototype.clear=function(){this.__data__=new Hk,this.size=0},mS.prototype.delete=function(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i},mS.prototype.get=function(e){return this.__data__.get(e)},mS.prototype.has=function(e){return this.__data__.has(e)},mS.prototype.set=function(e,t){var i=this.__data__;if(i instanceof Hk){var n=i.__data__;if(!oS||n.length<199)return n.push([e,t]),this.size=++i.size,this;i=this.__data__=new cS(n)}return i.set(e,t),this.size=i.size,this};function fS(e){var t=-1,i=null==e?0:e.length;for(this.__data__=new cS;++t<i;)this.add(e[t])}function vS(e,t){for(var i=-1,n=null==e?0:e.length;++i<n;)if(t(e[i],i,e))return!0;return!1}fS.prototype.add=fS.prototype.push=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this},fS.prototype.has=function(e){return this.__data__.has(e)};function pS(e,t,i,n,a,r){var o=1&i,s=e.length,u=t.length;if(s!=u&&!(o&&u>s))return!1;var l=r.get(e),d=r.get(t);if(l&&d)return l==t&&d==e;var h=-1,c=!0,m=2&i?new fS:void 0;for(r.set(e,t),r.set(t,e);++h<s;){var f=e[h],v=t[h];if(n)var p=o?n(v,f,h,t,e,r):n(f,v,h,e,t,r);if(void 0!==p){if(p)continue;c=!1;break}if(m){if(!vS(t,function(e,t){if(o=t,!m.has(o)&&(f===e||a(f,e,i,n,r)))return m.push(t);var o})){c=!1;break}}else if(f!==v&&!a(f,v,i,n,r)){c=!1;break}}return r.delete(e),r.delete(t),c}var gS=Ai.Uint8Array;function yS(e){var t=-1,i=Array(e.size);return e.forEach(function(e,n){i[++t]=[n,e]}),i}function bS(e){var t=-1,i=Array(e.size);return e.forEach(function(e){i[++t]=e}),i}var wS=Di?Di.prototype:void 0,kS=wS?wS.valueOf:void 0;var SS=Object.prototype.propertyIsEnumerable,ES=Object.getOwnPropertySymbols,TS=ES?function(e){return null==e?[]:(e=Object(e),function(e,t){for(var i=-1,n=null==e?0:e.length,a=0,r=[];++i<n;){var o=e[i];t(o,i,e)&&(r[a++]=o)}return r}(ES(e),function(t){return SS.call(e,t)}))}:function(){return[]};function PS(e){return Wi(e)&&"[object Arguments]"==Oi(e)}var MS=Object.prototype,AS=MS.hasOwnProperty,DS=MS.propertyIsEnumerable,xS=PS(function(){return arguments}())?PS:function(e){return Wi(e)&&AS.call(e,"callee")&&!DS.call(e,"callee")};var CS="object"==typeof exports&&exports&&!exports.nodeType&&exports,IS=CS&&"object"==typeof module&&module&&!module.nodeType&&module,LS=IS&&IS.exports===CS?Ai.Buffer:void 0,_S=(LS?LS.isBuffer:void 0)||function(){return!1},RS=/^(?:0|[1-9]\d*)$/;function FS(e,t){var i=typeof e;return!!(t=t??9007199254740991)&&("number"==i||"symbol"!=i&&RS.test(e))&&e>-1&&e%1==0&&e<t}function OS(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}var WS={};WS["[object Float32Array]"]=WS["[object Float64Array]"]=WS["[object Int8Array]"]=WS["[object Int16Array]"]=WS["[object Int32Array]"]=WS["[object Uint8Array]"]=WS["[object Uint8ClampedArray]"]=WS["[object Uint16Array]"]=WS["[object Uint32Array]"]=!0,WS["[object Arguments]"]=WS["[object Array]"]=WS["[object ArrayBuffer]"]=WS["[object Boolean]"]=WS["[object DataView]"]=WS["[object Date]"]=WS["[object Error]"]=WS["[object Function]"]=WS["[object Map]"]=WS["[object Number]"]=WS["[object Object]"]=WS["[object RegExp]"]=WS["[object Set]"]=WS["[object String]"]=WS["[object WeakMap]"]=!1;var $S,NS="object"==typeof exports&&exports&&!exports.nodeType&&exports,jS=NS&&"object"==typeof module&&module&&!module.nodeType&&module,BS=jS&&jS.exports===NS&&Pi.process,zS=function(){try{var e=jS&&jS.require&&jS.require("util").types;return e||BS&&BS.binding&&BS.binding("util")}catch(e){}}(),US=zS&&zS.isTypedArray,HS=US?($S=US,function(e){return $S(e)}):function(e){return Wi(e)&&OS(e.length)&&!!WS[Oi(e)]},GS=Object.prototype.hasOwnProperty;function VS(e,t){var i=xi(e),n=!i&&xS(e),a=!i&&!n&&_S(e),r=!i&&!n&&!a&&HS(e),o=i||n||a||r,s=o?function(e,t){for(var i=-1,n=Array(e);++i<e;)n[i]=t(i);return n}(e.length,String):[],u=s.length;for(var l in e)!GS.call(e,l)||o&&("length"==l||a&&("offset"==l||"parent"==l)||r&&("buffer"==l||"byteLength"==l||"byteOffset"==l)||FS(l,u))||s.push(l);return s}var KS=Object.prototype;var XS=function(e,t){return function(i){return e(t(i))}}(Object.keys,Object),YS=Object.prototype.hasOwnProperty;function qS(e){if(i=(t=e)&&t.constructor,t!==("function"==typeof i&&i.prototype||KS))return XS(e);var t,i,n=[];for(var a in Object(e))YS.call(e,a)&&"constructor"!=a&&n.push(a);return n}function JS(e){return null!=(t=e)&&OS(t.length)&&!Vk(t)?VS(e):qS(e);var t}function QS(e){return function(e,t,i){var n=t(e);return xi(e)?n:function(e,t){for(var i=-1,n=t.length,a=e.length;++i<n;)e[a+i]=t[i];return e}(n,i(e))}(e,JS,TS)}var ZS=Object.prototype.hasOwnProperty;var eE=rS(Ai,"DataView"),tE=rS(Ai,"Promise"),iE=rS(Ai,"Set"),nE=rS(Ai,"WeakMap"),aE="[object Map]",rE="[object Promise]",oE="[object Set]",sE="[object WeakMap]",uE="[object DataView]",lE=Jk(eE),dE=Jk(oS),hE=Jk(tE),cE=Jk(iE),mE=Jk(nE),fE=Oi;(eE&&fE(new eE(new ArrayBuffer(1)))!=uE||oS&&fE(new oS)!=aE||tE&&fE(tE.resolve())!=rE||iE&&fE(new iE)!=oE||nE&&fE(new nE)!=sE)&&(fE=function(e){var t=Oi(e),i="[object Object]"==t?e.constructor:void 0,n=i?Jk(i):"";if(n)switch(n){case lE:return uE;case dE:return aE;case hE:return rE;case cE:return oE;case mE:return sE}return t});var vE="[object Arguments]",pE="[object Array]",gE="[object Object]",yE=Object.prototype.hasOwnProperty;function bE(e,t,i,n,a,r){var o=xi(e),s=xi(t),u=o?pE:fE(e),l=s?pE:fE(t),d=(u=u==vE?gE:u)==gE,h=(l=l==vE?gE:l)==gE,c=u==l;if(c&&_S(e)){if(!_S(t))return!1;o=!0,d=!1}if(c&&!d)return r||(r=new mS),o||HS(e)?pS(e,t,i,n,a,r):function(e,t,i,n,a,r,o){switch(i){case"[object DataView]":if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case"[object ArrayBuffer]":return!(e.byteLength!=t.byteLength||!r(new gS(e),new gS(t)));case"[object Boolean]":case"[object Date]":case"[object Number]":return Bk(+e,+t);case"[object Error]":return e.name==t.name&&e.message==t.message;case"[object RegExp]":case"[object String]":return e==t+"";case"[object Map]":var s=yS;case"[object Set]":var u=1&n;if(s||(s=bS),e.size!=t.size&&!u)return!1;var l=o.get(e);if(l)return l==t;n|=2,o.set(e,t);var d=pS(s(e),s(t),n,a,r,o);return o.delete(e),d;case"[object Symbol]":if(kS)return kS.call(e)==kS.call(t)}return!1}(e,t,u,i,n,a,r);if(!(1&i)){var m=d&&yE.call(e,"__wrapped__"),f=h&&yE.call(t,"__wrapped__");if(m||f){var v=m?e.value():e,p=f?t.value():t;return r||(r=new mS),a(v,p,i,n,r)}}return!!c&&(r||(r=new mS),function(e,t,i,n,a,r){var o=1&i,s=QS(e),u=s.length;if(u!=QS(t).length&&!o)return!1;for(var l=u;l--;){var d=s[l];if(!(o?d in t:ZS.call(t,d)))return!1}var h=r.get(e),c=r.get(t);if(h&&c)return h==t&&c==e;var m=!0;r.set(e,t),r.set(t,e);for(var f=o;++l<u;){var v=e[d=s[l]],p=t[d];if(n)var g=o?n(p,v,d,t,e,r):n(v,p,d,e,t,r);if(!(void 0===g?v===p||a(v,p,i,n,r):g)){m=!1;break}f||(f="constructor"==d)}if(m&&!f){var y=e.constructor,b=t.constructor;y==b||!("constructor"in e)||!("constructor"in t)||"function"==typeof y&&y instanceof y&&"function"==typeof b&&b instanceof b||(m=!1)}return r.delete(e),r.delete(t),m}(e,t,i,n,a,r))}function wE(e,t,i,n,a){return e===t||(null==e||null==t||!Wi(e)&&!Wi(t)?e!=e&&t!=t:bE(e,t,i,n,wE,a))}function kE(e,t){return wE(e,t)}var SE=function(){function e(){var t;return u(this,e),(t=s(this,e,arguments)).inFocusedState=!1,t.scaleFactor=1,t}return y(e,bs),m(e,[{key:"styles",value:function(){var e=this.component.backgroundBlur,i="vertical"===this.component.direction,n=i?"width":"height",a=i?"margin-top":"margin-left",r=this.component.fillImage?t.unsafeCSS(`\n line-height: 1.5715;\n background-image: url(${this.component.fillImage});\n background-size: cover;\n background-position: center;\n background-repeat: no-repeat;\n height: 100%;\n width: 100%;\n `):t.unsafeCSS(Rs(this.component,!1));return t.unsafeCSS(`\n :host {\n opacity: 0;\n display: ${this.component.hidden?"none":"flex"};\n ${r};\n ${e?`backdrop-filter: blur(${e}px);`:""}\n ${Ys(this.component.position)}\n ${Fs(this.component)}\n ${Ks(this.component,this.scaleFactor,!1)}\n transition: transform .5s ease-in;\n }\n :host > *:not(:first-child) {\n ${a}: ${this.component.spacing?this.component.spacing*this.scaleFactor:0}px;\n }\n :host(:focus){\n ${Rs(this.component,!0)}\n ${Ks(this.component,this.scaleFactor,!0)}\n }\n :host(:focus-visible){\n ${Zs(this.component)}\n }\n :host > * {\n ${n}: 100%;\n }\n :host(.fade-in){\n opacity: 1;\n animation: fadeIn 0.5s ease-in\n }\n @keyframes fadeIn {\n 0% { opacity: 0; }\n 100% { opacity: 1; }\n }\n `)}},{key:"updated",value:function(){var e=this.contextProvider.state.currentGroupId;kE(e,this.currentGroupId)||(this.classList.remove("fade-in"),setTimeout(()=>this.classList.add("fade-in"),100),this.currentGroupId=e)}},{key:"render",value:function(){var e,t,i=this.contextProvider.state,n=i.mediaList,a=i.currentGroupId,r=i.selectedPaywall,o=i.formFactor,s=Nn(this.contextProvider.productDetails,null!==(e=null==r?void 0:r.sku_menus)&&void 0!==e?e:[],(null===(t=this.component)||void 0===t?void 0:t.subsetGroup)||a);return Vn(this.contextProvider,s,this.component,n).map(([e,t])=>(this.inFocusedState="television"==o?e:this.inFocusedState,t.map(e=>Iu(this.contextProvider,e,this.scaleFactor,this.inFocusedState,this.minSDKVersion))))}}])}();Ae([ot({type:Object})],SE.prototype,"component",void 0),Ae([ot({type:Boolean})],SE.prototype,"inFocusedState",void 0),Ae([ot({type:Number})],SE.prototype,"scaleFactor",void 0),Ae([ot({type:Object})],SE.prototype,"minSDKVersion",void 0),SE=Ae([Fe("nami-product-container")],SE);var EE,TE,PE=e=>e,ME=function(){function e(){var t;return u(this,e),(t=s(this,e,arguments)).inFocusedState=!1,t.scaleFactor=1,t}return y(e,bs),m(e,[{key:"styles",value:function(){var e,i=this.component,n=i.imageCropping,a=i.alignment,r=i.height,o=i.width,s=i.rightMargin,u=i.spacing,l=i.hidden,d=i.blur,h="fit"===n,c=this.contextConsumer.state.formFactor,m=Cs(null!=r?r:"100%",this.scaleFactor),f=Cs(null!==(e="fitContent"==o?r:o)&&void 0!==e?e:"100%",this.scaleFactor),v="string"==typeof r&&r.includes("%")||void 0===r,p="phone"===c&&v?"max-height":"height";return t.unsafeCSS(`\n :host {\n display: ${"television"===c?"flex":"inline-block"};\n ${l?"display:none;":""}\n position: relative;\n ${p}: ${m};\n width: ${f};\n }\n :host img {\n transition: all 0.3s;\n /* Don't ride the host's text baseline: a strut taller than a small image\n (dots, inline logos) pushes it below the host box. Keep the inline line\n box itself, though — percent-height hosts on phone size from it. */\n vertical-align: top;\n object-fit: ${h?"contain":"cover"};\n object-position: ${a} center;\n ${p}: ${m};\n width: ${f};\n margin-right: ${s||u||0}px;\n ${d?`filter: blur(${d}px);`:""}\n flex-shrink: ${"number"==typeof o?0:1};\n }\n `)}},{key:"render",value:function(){var e,i=this.component,n=i.url,a=i.alt,r=i.title,o=i.focusedBorderColor,s=i.focusedFillColor,u=i.fillColor;return n?(!o&&na(u,s)||(this.tabIndex=0),this.ariaLabel=null!==(e=null!=a?a:r)&&void 0!==e?e:"",t.html(EE||(EE=PE`<img src="${0}" alt="${0}" />`),n,this.ariaLabel)):(this.tabIndex=-1,this.ariaLabel=null,t.html(TE||(TE=PE``)))}}])}();Ae([ot({type:Object})],ME.prototype,"component",void 0),Ae([ot({type:Boolean})],ME.prototype,"inFocusedState",void 0),Ae([ot({type:Number})],ME.prototype,"scaleFactor",void 0),ME=Ae([Fe("nami-image")],ME);var AE=function(){function e(){var t;return u(this,e),(t=s(this,e,arguments)).fullscreen=!1,t.inFocusedState=!1,t.scaleFactor=1,t}return y(e,bs),m(e,[{key:"connectedCallback",value:function(){M(e,"connectedCallback",this)([]),!!document.querySelector("nami-paywall.nami-half-sheet-mode, nami-paywall.nami-modal-mode")||(document.body.style.background=this.component.fillColor||"transparent")}},{key:"styles",value:function(){var e;if(!this.contextConsumer||!this.component)return t.unsafeCSS("");var i=this.component,n=this.scaleFactor,a=this.contextConsumer.state.formFactor,r=i.backgroundBlur,o="vertical"===i.direction?"margin-top":"margin-left";return t.unsafeCSS(`\n :host {\n max-height: ${"television"===a?"100vh":""};\n display: ${i.hidden?"none":"flex"};\n flex-direction: column;\n overflow: hidden;\n ${Os(i)}\n position: var(--nami-bg-position, fixed);\n width: 100%;\n bottom: 0px;\n background-repeat: no-repeat;\n background-size: cover;\n background-position: center;\n z-index: ${null!==(e=i.zIndex)&&void 0!==e?e:1};\n top: 0px;\n ${r?`backdrop-filter: blur(${r}px);`:""}\n ${Rs(i,!1)}\n transition: all 0.3s;\n ${Ns(i,n)}\n }\n :host(:focus){\n ${Rs(i,!0)}\n }\n :host > *:not(:first-child) {\n ${o}: ${i.spacing?i.spacing*n:0}px;\n }\n `)}},{key:"updated",value:function(){}},{key:"render",value:function(){var e;return(null!==(e=this.component.components)&&void 0!==e?e:[]).map(e=>Iu(this.contextProvider,e,this.scaleFactor,void 0,this.minSDKVersion))}}])}();Ae([ot({type:Object})],AE.prototype,"component",void 0),Ae([ot({type:Boolean})],AE.prototype,"fullscreen",void 0),Ae([ot({type:Boolean})],AE.prototype,"inFocusedState",void 0),Ae([ot({type:Number})],AE.prototype,"scaleFactor",void 0),Ae([ot({type:Object})],AE.prototype,"minSDKVersion",void 0),AE=Ae([Fe("nami-background-container")],AE);var DE,xE=e=>e,CE=function(){function e(){var t;return u(this,e),(t=s(this,e,arguments)).zIndex=2,t.inFocusedState=!1,t.scaleFactor=1,t}return y(e,bs),m(e,[{key:"styles",value:function(){var e,i,n=this.contextConsumer,a=this.component,r=this.zIndex,o=this.scaleFactor;if(!n)return t.css(DE||(DE=xE``));var s=n.state.formFactor,u=a.backgroundBlur,l="phone"!==s?"width: 100%;":"",d=null!==(e=a.width)&&void 0!==e?e:a.fixedWidth,h=null!==(i=a.height)&&void 0!==i?i:a.fixedHeight,c="phone"===s?`max-width:100%;\n ${void 0!==d?`width: ${Cs(d,o)};`:""}\n ${void 0!==h?`height: ${Cs(h,o)};`:""}`:zs(a,o),m="vertical"===a.direction?"margin-top":"margin-left";return t.unsafeCSS(`\n :host {\n box-sizing: border-box;\n display: ${a.hidden?"none":"flex"};\n position: relative;\n flex: 1;\n min-height: 0;\n ${Fs(a)}\n ${c}\n ${l}\n ${function(e){var t,i,n=e.verticalAlignment,a=e.horizontalAlignment,r=e.direction,o=n?ws[n]:void 0,s=a?ws[a]:void 0;return"vertical"===r?(t=null!=s?s:"center",i=null!=o?o:"start"):(t=null!=o?o:"center",i=null!=s?s:"start"),`${Ss("align-items",t)}${Ss("justify-content",i)}`}(a)}\n ${u?`backdrop-filter: blur(${u}px);`:""}\n z-index: ${r};\n transition: all 0.3s;\n overflow-y: ${"television"===s?"hidden":"scroll"};\n overflow-x: hidden;\n scrollbar-width: none;\n ::-webkit-scrollbar {\n display: none;\n }\n -ms-overflow-style: none; /* IE and Edge */\n scrollbar-width: none; /* Firefox */\n ${Ns(a,o)}\n /* The footer is position:absolute over this container; inset the\n scroll end by its measured height (--nami-footer-height, set by\n the paywall screen) so bottom content is not hidden behind it. */\n padding-bottom: calc(${xs(o,a.bottomPadding)}px + var(--nami-footer-height, 0px));\n ${Rs(a,!1)}\n }\n :host::-webkit-scrollbar {\n display: none;\n }\n :host(:focus){\n ${Rs(a,!0)}\n }\n :host > * {\n width: 100%;\n }\n :host > *:not(:first-child) {\n ${m}: ${a.spacing?a.spacing*o:0}px;\n }\n `)}},{key:"firstUpdated",value:function(){var e=new CustomEvent("child-spacing",{detail:{spacing:this.component.spacing},bubbles:!0,composed:!0});this.dispatchEvent(e)}},{key:"render",value:function(){var e;return(null===(e=this.component.components)||void 0===e?void 0:e.map(e=>Iu(this.contextProvider,e,this.scaleFactor,this.inFocusedState,this.minSDKVersion)))||[]}}])}();Ae([ot({type:Object})],CE.prototype,"component",void 0),Ae([ot({type:Number})],CE.prototype,"zIndex",void 0),Ae([ot({type:Boolean})],CE.prototype,"inFocusedState",void 0),Ae([ot({type:Number})],CE.prototype,"scaleFactor",void 0),Ae([ot({type:Object})],CE.prototype,"minSDKVersion",void 0),CE=Ae([Fe("nami-content-container")],CE);var IE,LE=e=>e,_E=function(){function e(){var t;return u(this,e),(t=s(this,e)).inFocusedState=!1,t.scaleFactor=1,t._handleClick=e=>{e.preventDefault(),Ao({contextProvider:t.contextProvider,onTap:t.component.onTap})},t.addEventListener("click",t._handleClick),t}return y(e,bs),m(e,[{key:"styles",value:function(){var e,i,n=qs("active",this.component.components[0]),a=qs("inactive",this.component.components[0]);return t.unsafeCSS(`\n :host {\n box-sizing: border-box;\n -webkit-tap-highlight-color: transparent;\n cursor: pointer;\n display: flex;\n flex: 0 0 auto;\n position: relative;\n ${Fs(this.component)}\n ${Rs(this.component,!1)}\n ${Ks(this.component,this.scaleFactor,!1)}\n ${this.component.hidden?"display:none;":""}\n }\n :host(:focus){\n ${Rs(this.component,!0)}\n ${Ks(this.component,this.scaleFactor,!0)}\n }\n :host(:focus-visible){\n ${Zs(this.component)}\n }\n .toggle{\n ${e=this.component,i=this.scaleFactor,`\n position: absolute;\n top: ${xs(i,e.topPadding)}px;\n bottom: ${xs(i,e.bottomPadding)}px;\n width: calc(50% - ${xs(i,e.leftPadding)/2}px) !important;\n `}\n transition: transform .5s cubic-bezier(.77, 0, .175, 1);\n ${Js(a,this.scaleFactor,!1)}\n }\n\n :host(:focus) .toggle{\n ${Js(n,this.scaleFactor,!0)}\n }\n \n nami-segment-picker-item:nth-of-type(1).active~.toggle {\n transform: translateX(0%);\n left: ${this.component.leftPadding?Number(this.component.leftPadding)*this.scaleFactor:0}px;\n ${Rs(n,!0)}\n ${Qs(n,this.scaleFactor)}\n }\n\n nami-segment-picker-item:nth-of-type(2).active~.toggle {\n transform: translateX(100%);\n right: ${this.component.rightPadding?Number(this.component.rightPadding)*this.scaleFactor:0}px;\n ${Rs(n,!0)}\n ${Qs(n,this.scaleFactor)}\n `)}},{key:"render",value:function(){this.role="tablist";var e=this.component.components.map(e=>Iu(this.contextProvider,e,this.scaleFactor,this.inFocusedState,this.minSDKVersion));return t.html(IE||(IE=LE`${0}<div class="toggle"></div>`),e)}}])}();Ae([ot({type:Object})],_E.prototype,"component",void 0),Ae([ot({type:Boolean})],_E.prototype,"inFocusedState",void 0),Ae([ot({type:Number})],_E.prototype,"scaleFactor",void 0),Ae([ot({type:Object})],_E.prototype,"minSDKVersion",void 0),_E=Ae([Fe("nami-segment-picker")],_E);var RE,FE=e=>e,OE=function(){function e(){var t;return u(this,e),(t=s(this,e,arguments)).inFocusedState=!1,t.scaleFactor=1,t._handleFocus=()=>{t.inFocusedState=!0},t._handleKeyDown=e=>{"Enter"!==e.key&&" "!==e.key&&142!==e.keyCode&&195!==e.keyCode||t._handleClick()},t._handleClick=()=>{t._updateFormState(),t.requestUpdate("component")},t._handleHover=()=>{t.inFocusedState=!0},t}return y(e,bs),m(e,[{key:"connectedCallback",value:function(){M(e,"connectedCallback",this)([]),this._isActive=!!this.component.checked,this.classList.toggle("active",this._isActive),this.component.formId&&this._updateFormState(),this.addEventListener("click",this._handleClick),this.addEventListener("mouseover",this._handleHover),this.addEventListener("keydown",this._handleKeyDown),this.addEventListener("focus",this._handleFocus)}},{key:"disconnectedCallback",value:function(){M(e,"disconnectedCallback",this)([]),this.removeEventListener("click",this._handleClick),this.removeEventListener("mouseover",this._handleHover),this.removeEventListener("keydown",this._handleKeyDown),this.removeEventListener("focus",this._handleFocus)}},{key:"_getParentPicker",value:function(){var e=this.getRootNode();return e instanceof ShadowRoot?e.host:null}},{key:"_getParentFormId",value:function(){var e;return null===(e=this._getParentPicker())||void 0===e?void 0:e.component.formId}},{key:"_updateFormState",value:function(){if(this.contextProvider)if(this.component.formId){var e=this._getParentFormId();e&&this.contextProvider.setFormState(e,this.component.formId)}else this.component.id&&this.contextProvider.setCurrentGroupData(this.component.id,this.component.text||"")}},{key:"updated",value:function(e){var t;if(e.has("component")&&this.contextProvider){var i=null!==(t=e.get("component"))&&void 0!==t?t:this.component;if(i.formId){var n=this._getParentFormId();n&&this.contextProvider.state.formStates[n]&&(this._isActive=this.contextProvider.state.formStates[n]===i.formId)}else this._isActive=kE(i.id,this.contextProvider.state.currentGroupId);if(this.classList.toggle("active",this._isActive),this._isActive){var a=this.getRootNode();if(a instanceof ShadowRoot)a.querySelectorAll("nami-segment-picker-item").forEach(e=>{e!==this&&e.requestUpdate("component",e)})}}}},{key:"styles",value:function(){var e,i,n=qs("active",this.component),a=qs("inactive",this.component);return t.unsafeCSS(`\n :host {\n box-sizing: border-box;\n display: ${this.component.hidden?"none":"inline-flex"};\n position: relative;\n ${Js(v({},a,this.component),this.scaleFactor,this.inFocusedState)}\n ${Hs(null!==(e=this.component.inactiveDropShadow)&&void 0!==e?e:this.component.dropShadow)}\n }\n\n :host > * {\n cursor: pointer;\n }\n\n :host(.active) {\n z-index: 1 !important;\n ${Qs(v({},n,this.component),this.scaleFactor)}\n ${Hs(null!==(i=this.component.activeDropShadow)&&void 0!==i?i:this.component.dropShadow)}\n }\n\n input {\n visibility: hidden;\n position: absolute;\n top: 0;\n }\n `)}},{key:"render",value:function(){return this.tabIndex=0,this.role="tab",this.ariaSelected=`${this._isActive}`,this.ariaLabel=this.component.text||"",t.html(RE||(RE=FE`<input type="radio"
|
|
462
|
+
</nami-text-list-item-wrapper>`),this.component,this.scaleFactor,u&&t.html(Dk||(Dk=Ik`<nami-symbol .component=${0} .scaleFactor=${0}></nami-symbol>`),u,this.scaleFactor),ql(e)):null);return t.html(xk||(xk=Ik`${0}`),l)}}])}();Ae([ot({type:Object})],Nk.prototype,"component",void 0),Ae([ot({type:Boolean})],Nk.prototype,"inFocusedState",void 0),Ae([ot({type:Number})],Nk.prototype,"scaleFactor",void 0),Nk=Ae([Fe("nami-text-list")],Nk);(()=>{var e,t=!0;try{new RegExp("","u"),new RegExp("😀","u"),new RegExp("\\p{P}","u")}catch(e){t=!1}if(!t){var i=null===(e=ql.Lexer)||void 0===e?void 0:e.rules,n=null==i?void 0:i.inline;n&&Object.values(n).forEach(e=>{e&&Object.keys(e).forEach(t=>{e[t]=(e=>{if(!(e instanceof RegExp))return e;if(!/\\p\{/.test(e.source))return e;var t="!\"#$%&'()*+,\\-./:;<=>?@[\\\\]^_`{|}~",i=e.source.replace(/\\p\{P\}\\p\{S\}/g,t).replace(/\\p\{P\}/g,t).replace(/\\p\{S\}/g,t),n=e.flags.replace(/u/g,"");return new RegExp(i,n)})(e[t])})})}})();var jk=function(){function e(){var t;return u(this,e),(t=s(this,e)).inFocusedState=!1,t.scaleFactor=1,t.handleFocusIn=()=>t.setFocusState(!0),t.handleFocusOut=e=>{var i,n,a=null!==(i=e.relatedTarget)&&void 0!==i?i:null;if(!a)return t.setFocusState(!1);a===t||null!==(n=t.shadowRoot)&&void 0!==n&&n.contains(a)||t.setFocusState(!1)},t.handleFocusChanged=e=>{var i=e.detail;t.setFocusState(!0===(null==i?void 0:i.inFocusedState))},t.addEventListener("focusin",t.handleFocusIn),t.addEventListener("focusout",t.handleFocusOut),t.addEventListener("focus-changed",t.handleFocusChanged),t}return y(e,bs),m(e,[{key:"disconnectedCallback",value:function(){M(e,"disconnectedCallback",this)([]),this.removeEventListener("focusin",this.handleFocusIn),this.removeEventListener("focusout",this.handleFocusOut),this.removeEventListener("focus-changed",this.handleFocusChanged)}},{key:"styles",value:function(){var e=this.component,i=this.scaleFactor,n=this.minSDKVersion,a=e.backgroundBlur,r="vertical"===e.direction,o=r?"width":"height",s=r?"margin-top":"margin-left",u=e.fillImage?t.unsafeCSS(`\n line-height: 1.5715;\n background-image: url(${e.fillImage});\n background-position: center;\n background-repeat: no-repeat;\n background-size: cover;\n height: 100%;\n width: 100%;\n `):t.unsafeCSS(Rs(e,!1)),l=Boolean(e.fillColor||e.fillImage),d=e.roundBorders,h=Array.isArray(d)&&d.length>0&&d.length<4,c=l&&h?"overflow: hidden;":"";return t.unsafeCSS(`\n :host {\n box-sizing: border-box;\n display: ${e.hidden?"none":"flex"};\n ${a?`backdrop-filter: blur(${a}px);`:""}\n ${u};\n ${c}\n ${Ys(e.position)}\n ${Fs(e)}\n ${Ks(e,i,!1)}\n }\n :host(:focus),\n :host(.nami-focus-within){\n ${Rs(e,!0)}\n ${Ks(e,i,!0)}\n }\n :host(:focus-visible){\n ${Zs(e)}\n }\n :host > * {\n ${Ws(n,o)}\n }\n :host > *:not(:first-child) {\n ${s}: ${e.spacing?e.spacing*i:0}px;\n }\n `)}},{key:"render",value:function(){var e;return(null!==(e=this.component.components)&&void 0!==e?e:[]).map(e=>Iu(this.contextProvider,e,this.scaleFactor,void 0,this.minSDKVersion))}},{key:"setFocusState",value:function(e){this.inFocusedState!==e&&(this.inFocusedState=e,this.classList.toggle("nami-focus-within",e),this.toggleAttribute("data-nami-focused",e))}}])}();function Bk(e,t){return e===t||e!=e&&t!=t}function zk(e,t){for(var i=e.length;i--;)if(Bk(e[i][0],t))return i;return-1}Ae([ot({type:Object})],jk.prototype,"component",void 0),Ae([ot({type:Boolean})],jk.prototype,"inFocusedState",void 0),Ae([ot({type:Number})],jk.prototype,"scaleFactor",void 0),Ae([ot({type:Object})],jk.prototype,"minSDKVersion",void 0),jk=Ae([Fe("nami-container")],jk);var Uk=Array.prototype.splice;function Hk(e){var t=-1,i=null==e?0:e.length;for(this.clear();++t<i;){var n=e[t];this.set(n[0],n[1])}}function Gk(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}Hk.prototype.clear=function(){this.__data__=[],this.size=0},Hk.prototype.delete=function(e){var t=this.__data__,i=zk(t,e);return!(i<0)&&(i==t.length-1?t.pop():Uk.call(t,i,1),--this.size,!0)},Hk.prototype.get=function(e){var t=this.__data__,i=zk(t,e);return i<0?void 0:t[i][1]},Hk.prototype.has=function(e){return zk(this.__data__,e)>-1},Hk.prototype.set=function(e,t){var i=this.__data__,n=zk(i,e);return n<0?(++this.size,i.push([e,t])):i[n][1]=t,this};function Vk(e){if(!Gk(e))return!1;var t=Oi(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}var Kk,Xk=Ai["__core-js_shared__"],Yk=(Kk=/[^.]+$/.exec(Xk&&Xk.keys&&Xk.keys.IE_PROTO||""))?"Symbol(src)_1."+Kk:"";var qk=Function.prototype.toString;function Jk(e){if(null!=e){try{return qk.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var Qk=/^\[object .+?Constructor\]$/,Zk=Function.prototype,eS=Object.prototype,tS=Zk.toString,iS=eS.hasOwnProperty,nS=RegExp("^"+tS.call(iS).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function aS(e){return!(!Gk(e)||(t=e,Yk&&Yk in t))&&(Vk(e)?nS:Qk).test(Jk(e));var t}function rS(e,t){var i=function(e,t){return null==e?void 0:e[t]}(e,t);return aS(i)?i:void 0}var oS=rS(Ai,"Map"),sS=rS(Object,"create");var uS=Object.prototype.hasOwnProperty;var lS=Object.prototype.hasOwnProperty;function dS(e){var t=-1,i=null==e?0:e.length;for(this.clear();++t<i;){var n=e[t];this.set(n[0],n[1])}}function hS(e,t){var i,n,a=e.__data__;return("string"==(n=typeof(i=t))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==i:null===i)?a["string"==typeof t?"string":"hash"]:a.map}function cS(e){var t=-1,i=null==e?0:e.length;for(this.clear();++t<i;){var n=e[t];this.set(n[0],n[1])}}dS.prototype.clear=function(){this.__data__=sS?sS(null):{},this.size=0},dS.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},dS.prototype.get=function(e){var t=this.__data__;if(sS){var i=t[e];return"__lodash_hash_undefined__"===i?void 0:i}return uS.call(t,e)?t[e]:void 0},dS.prototype.has=function(e){var t=this.__data__;return sS?void 0!==t[e]:lS.call(t,e)},dS.prototype.set=function(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=sS&&void 0===t?"__lodash_hash_undefined__":t,this},cS.prototype.clear=function(){this.size=0,this.__data__={hash:new dS,map:new(oS||Hk),string:new dS}},cS.prototype.delete=function(e){var t=hS(this,e).delete(e);return this.size-=t?1:0,t},cS.prototype.get=function(e){return hS(this,e).get(e)},cS.prototype.has=function(e){return hS(this,e).has(e)},cS.prototype.set=function(e,t){var i=hS(this,e),n=i.size;return i.set(e,t),this.size+=i.size==n?0:1,this};function mS(e){var t=this.__data__=new Hk(e);this.size=t.size}mS.prototype.clear=function(){this.__data__=new Hk,this.size=0},mS.prototype.delete=function(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i},mS.prototype.get=function(e){return this.__data__.get(e)},mS.prototype.has=function(e){return this.__data__.has(e)},mS.prototype.set=function(e,t){var i=this.__data__;if(i instanceof Hk){var n=i.__data__;if(!oS||n.length<199)return n.push([e,t]),this.size=++i.size,this;i=this.__data__=new cS(n)}return i.set(e,t),this.size=i.size,this};function fS(e){var t=-1,i=null==e?0:e.length;for(this.__data__=new cS;++t<i;)this.add(e[t])}function vS(e,t){for(var i=-1,n=null==e?0:e.length;++i<n;)if(t(e[i],i,e))return!0;return!1}fS.prototype.add=fS.prototype.push=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this},fS.prototype.has=function(e){return this.__data__.has(e)};function pS(e,t,i,n,a,r){var o=1&i,s=e.length,u=t.length;if(s!=u&&!(o&&u>s))return!1;var l=r.get(e),d=r.get(t);if(l&&d)return l==t&&d==e;var h=-1,c=!0,m=2&i?new fS:void 0;for(r.set(e,t),r.set(t,e);++h<s;){var f=e[h],v=t[h];if(n)var p=o?n(v,f,h,t,e,r):n(f,v,h,e,t,r);if(void 0!==p){if(p)continue;c=!1;break}if(m){if(!vS(t,function(e,t){if(o=t,!m.has(o)&&(f===e||a(f,e,i,n,r)))return m.push(t);var o})){c=!1;break}}else if(f!==v&&!a(f,v,i,n,r)){c=!1;break}}return r.delete(e),r.delete(t),c}var gS=Ai.Uint8Array;function yS(e){var t=-1,i=Array(e.size);return e.forEach(function(e,n){i[++t]=[n,e]}),i}function bS(e){var t=-1,i=Array(e.size);return e.forEach(function(e){i[++t]=e}),i}var wS=Di?Di.prototype:void 0,kS=wS?wS.valueOf:void 0;var SS=Object.prototype.propertyIsEnumerable,ES=Object.getOwnPropertySymbols,TS=ES?function(e){return null==e?[]:(e=Object(e),function(e,t){for(var i=-1,n=null==e?0:e.length,a=0,r=[];++i<n;){var o=e[i];t(o,i,e)&&(r[a++]=o)}return r}(ES(e),function(t){return SS.call(e,t)}))}:function(){return[]};function PS(e){return Wi(e)&&"[object Arguments]"==Oi(e)}var MS=Object.prototype,AS=MS.hasOwnProperty,DS=MS.propertyIsEnumerable,xS=PS(function(){return arguments}())?PS:function(e){return Wi(e)&&AS.call(e,"callee")&&!DS.call(e,"callee")};var CS="object"==typeof exports&&exports&&!exports.nodeType&&exports,IS=CS&&"object"==typeof module&&module&&!module.nodeType&&module,LS=IS&&IS.exports===CS?Ai.Buffer:void 0,_S=(LS?LS.isBuffer:void 0)||function(){return!1},RS=/^(?:0|[1-9]\d*)$/;function FS(e,t){var i=typeof e;return!!(t=t??9007199254740991)&&("number"==i||"symbol"!=i&&RS.test(e))&&e>-1&&e%1==0&&e<t}function OS(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}var WS={};WS["[object Float32Array]"]=WS["[object Float64Array]"]=WS["[object Int8Array]"]=WS["[object Int16Array]"]=WS["[object Int32Array]"]=WS["[object Uint8Array]"]=WS["[object Uint8ClampedArray]"]=WS["[object Uint16Array]"]=WS["[object Uint32Array]"]=!0,WS["[object Arguments]"]=WS["[object Array]"]=WS["[object ArrayBuffer]"]=WS["[object Boolean]"]=WS["[object DataView]"]=WS["[object Date]"]=WS["[object Error]"]=WS["[object Function]"]=WS["[object Map]"]=WS["[object Number]"]=WS["[object Object]"]=WS["[object RegExp]"]=WS["[object Set]"]=WS["[object String]"]=WS["[object WeakMap]"]=!1;var $S,NS="object"==typeof exports&&exports&&!exports.nodeType&&exports,jS=NS&&"object"==typeof module&&module&&!module.nodeType&&module,BS=jS&&jS.exports===NS&&Pi.process,zS=function(){try{var e=jS&&jS.require&&jS.require("util").types;return e||BS&&BS.binding&&BS.binding("util")}catch(e){}}(),US=zS&&zS.isTypedArray,HS=US?($S=US,function(e){return $S(e)}):function(e){return Wi(e)&&OS(e.length)&&!!WS[Oi(e)]},GS=Object.prototype.hasOwnProperty;function VS(e,t){var i=xi(e),n=!i&&xS(e),a=!i&&!n&&_S(e),r=!i&&!n&&!a&&HS(e),o=i||n||a||r,s=o?function(e,t){for(var i=-1,n=Array(e);++i<e;)n[i]=t(i);return n}(e.length,String):[],u=s.length;for(var l in e)!GS.call(e,l)||o&&("length"==l||a&&("offset"==l||"parent"==l)||r&&("buffer"==l||"byteLength"==l||"byteOffset"==l)||FS(l,u))||s.push(l);return s}var KS=Object.prototype;var XS=function(e,t){return function(i){return e(t(i))}}(Object.keys,Object),YS=Object.prototype.hasOwnProperty;function qS(e){if(i=(t=e)&&t.constructor,t!==("function"==typeof i&&i.prototype||KS))return XS(e);var t,i,n=[];for(var a in Object(e))YS.call(e,a)&&"constructor"!=a&&n.push(a);return n}function JS(e){return null!=(t=e)&&OS(t.length)&&!Vk(t)?VS(e):qS(e);var t}function QS(e){return function(e,t,i){var n=t(e);return xi(e)?n:function(e,t){for(var i=-1,n=t.length,a=e.length;++i<n;)e[a+i]=t[i];return e}(n,i(e))}(e,JS,TS)}var ZS=Object.prototype.hasOwnProperty;var eE=rS(Ai,"DataView"),tE=rS(Ai,"Promise"),iE=rS(Ai,"Set"),nE=rS(Ai,"WeakMap"),aE="[object Map]",rE="[object Promise]",oE="[object Set]",sE="[object WeakMap]",uE="[object DataView]",lE=Jk(eE),dE=Jk(oS),hE=Jk(tE),cE=Jk(iE),mE=Jk(nE),fE=Oi;(eE&&fE(new eE(new ArrayBuffer(1)))!=uE||oS&&fE(new oS)!=aE||tE&&fE(tE.resolve())!=rE||iE&&fE(new iE)!=oE||nE&&fE(new nE)!=sE)&&(fE=function(e){var t=Oi(e),i="[object Object]"==t?e.constructor:void 0,n=i?Jk(i):"";if(n)switch(n){case lE:return uE;case dE:return aE;case hE:return rE;case cE:return oE;case mE:return sE}return t});var vE="[object Arguments]",pE="[object Array]",gE="[object Object]",yE=Object.prototype.hasOwnProperty;function bE(e,t,i,n,a,r){var o=xi(e),s=xi(t),u=o?pE:fE(e),l=s?pE:fE(t),d=(u=u==vE?gE:u)==gE,h=(l=l==vE?gE:l)==gE,c=u==l;if(c&&_S(e)){if(!_S(t))return!1;o=!0,d=!1}if(c&&!d)return r||(r=new mS),o||HS(e)?pS(e,t,i,n,a,r):function(e,t,i,n,a,r,o){switch(i){case"[object DataView]":if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case"[object ArrayBuffer]":return!(e.byteLength!=t.byteLength||!r(new gS(e),new gS(t)));case"[object Boolean]":case"[object Date]":case"[object Number]":return Bk(+e,+t);case"[object Error]":return e.name==t.name&&e.message==t.message;case"[object RegExp]":case"[object String]":return e==t+"";case"[object Map]":var s=yS;case"[object Set]":var u=1&n;if(s||(s=bS),e.size!=t.size&&!u)return!1;var l=o.get(e);if(l)return l==t;n|=2,o.set(e,t);var d=pS(s(e),s(t),n,a,r,o);return o.delete(e),d;case"[object Symbol]":if(kS)return kS.call(e)==kS.call(t)}return!1}(e,t,u,i,n,a,r);if(!(1&i)){var m=d&&yE.call(e,"__wrapped__"),f=h&&yE.call(t,"__wrapped__");if(m||f){var v=m?e.value():e,p=f?t.value():t;return r||(r=new mS),a(v,p,i,n,r)}}return!!c&&(r||(r=new mS),function(e,t,i,n,a,r){var o=1&i,s=QS(e),u=s.length;if(u!=QS(t).length&&!o)return!1;for(var l=u;l--;){var d=s[l];if(!(o?d in t:ZS.call(t,d)))return!1}var h=r.get(e),c=r.get(t);if(h&&c)return h==t&&c==e;var m=!0;r.set(e,t),r.set(t,e);for(var f=o;++l<u;){var v=e[d=s[l]],p=t[d];if(n)var g=o?n(p,v,d,t,e,r):n(v,p,d,e,t,r);if(!(void 0===g?v===p||a(v,p,i,n,r):g)){m=!1;break}f||(f="constructor"==d)}if(m&&!f){var y=e.constructor,b=t.constructor;y==b||!("constructor"in e)||!("constructor"in t)||"function"==typeof y&&y instanceof y&&"function"==typeof b&&b instanceof b||(m=!1)}return r.delete(e),r.delete(t),m}(e,t,i,n,a,r))}function wE(e,t,i,n,a){return e===t||(null==e||null==t||!Wi(e)&&!Wi(t)?e!=e&&t!=t:bE(e,t,i,n,wE,a))}function kE(e,t){return wE(e,t)}var SE=function(){function e(){var t;return u(this,e),(t=s(this,e,arguments)).inFocusedState=!1,t.scaleFactor=1,t}return y(e,bs),m(e,[{key:"styles",value:function(){var e=this.component.backgroundBlur,i="vertical"===this.component.direction,n=i?"width":"height",a=i?"margin-top":"margin-left",r=this.component.fillImage?t.unsafeCSS(`\n line-height: 1.5715;\n background-image: url(${this.component.fillImage});\n background-size: cover;\n background-position: center;\n background-repeat: no-repeat;\n height: 100%;\n width: 100%;\n `):t.unsafeCSS(Rs(this.component,!1));return t.unsafeCSS(`\n :host {\n opacity: 0;\n display: ${this.component.hidden?"none":"flex"};\n ${r};\n ${e?`backdrop-filter: blur(${e}px);`:""}\n ${Ys(this.component.position)}\n ${Fs(this.component)}\n ${Ks(this.component,this.scaleFactor,!1)}\n transition: transform .5s ease-in;\n }\n :host > *:not(:first-child) {\n ${a}: ${this.component.spacing?this.component.spacing*this.scaleFactor:0}px;\n }\n :host(:focus){\n ${Rs(this.component,!0)}\n ${Ks(this.component,this.scaleFactor,!0)}\n }\n :host(:focus-visible){\n ${Zs(this.component)}\n }\n :host > * {\n ${n}: 100%;\n }\n :host(.fade-in){\n opacity: 1;\n animation: fadeIn 0.5s ease-in\n }\n @keyframes fadeIn {\n 0% { opacity: 0; }\n 100% { opacity: 1; }\n }\n `)}},{key:"updated",value:function(){var e=this.contextProvider.state.currentGroupId;kE(e,this.currentGroupId)||(this.classList.remove("fade-in"),setTimeout(()=>this.classList.add("fade-in"),100),this.currentGroupId=e)}},{key:"render",value:function(){var e,t,i=this.contextProvider.state,n=i.mediaList,a=i.currentGroupId,r=i.selectedPaywall,o=i.formFactor,s=Nn(this.contextProvider.productDetails,null!==(e=null==r?void 0:r.sku_menus)&&void 0!==e?e:[],(null===(t=this.component)||void 0===t?void 0:t.subsetGroup)||a);return Vn(this.contextProvider,s,this.component,n).map(([e,t])=>(this.inFocusedState="television"==o?e:this.inFocusedState,t.map(e=>Iu(this.contextProvider,e,this.scaleFactor,this.inFocusedState,this.minSDKVersion))))}}])}();Ae([ot({type:Object})],SE.prototype,"component",void 0),Ae([ot({type:Boolean})],SE.prototype,"inFocusedState",void 0),Ae([ot({type:Number})],SE.prototype,"scaleFactor",void 0),Ae([ot({type:Object})],SE.prototype,"minSDKVersion",void 0),SE=Ae([Fe("nami-product-container")],SE);var EE,TE,PE=e=>e;function ME(e){if("number"==typeof e)return 0!==e;if("string"==typeof e){var t=parseFloat(e);return!isNaN(t)&&0!==t}return!1}var AE=function(){function e(){var t;return u(this,e),(t=s(this,e,arguments)).inFocusedState=!1,t.scaleFactor=1,t}return y(e,bs),m(e,[{key:"styles",value:function(){var e,i=this.component,n=i.imageCropping,a=i.alignment,r=i.height,o=i.width,s=i.rightMargin,u=i.spacing,l=i.hidden,d=i.blur,h="fit"===n,c=this.contextConsumer.state.formFactor,m=Cs(null!=r?r:"100%",this.scaleFactor),f=Cs(null!==(e="fitContent"==o?r:o)&&void 0!==e?e:"100%",this.scaleFactor),v="string"==typeof r&&r.includes("%")||void 0===r,p="phone"===c&&v?"max-height":"height",g=ME(this.component.moveX)||ME(this.component.moveY);return t.unsafeCSS(`\n :host {\n display: ${"television"===c?"flex":"inline-block"};\n ${l?"display:none;":""}\n position: relative;\n ${g?js(this.component):""}\n ${p}: ${m};\n width: ${f};\n }\n :host img {\n transition: all 0.3s;\n /* Don't ride the host's text baseline: a strut taller than a small image\n (dots, inline logos) pushes it below the host box. Keep the inline line\n box itself, though — percent-height hosts on phone size from it. */\n vertical-align: top;\n object-fit: ${h?"contain":"cover"};\n object-position: ${a} center;\n ${p}: ${m};\n width: ${f};\n margin-right: ${s||u||0}px;\n ${d?`filter: blur(${d}px);`:""}\n flex-shrink: ${"number"==typeof o?0:1};\n }\n `)}},{key:"render",value:function(){var e,i=this.component,n=i.url,a=i.alt,r=i.title,o=i.focusedBorderColor,s=i.focusedFillColor,u=i.fillColor;return n?(!o&&na(u,s)||(this.tabIndex=0),this.ariaLabel=null!==(e=null!=a?a:r)&&void 0!==e?e:"",t.html(EE||(EE=PE`<img src="${0}" alt="${0}" />`),n,this.ariaLabel)):(this.tabIndex=-1,this.ariaLabel=null,t.html(TE||(TE=PE``)))}}])}();Ae([ot({type:Object})],AE.prototype,"component",void 0),Ae([ot({type:Boolean})],AE.prototype,"inFocusedState",void 0),Ae([ot({type:Number})],AE.prototype,"scaleFactor",void 0),AE=Ae([Fe("nami-image")],AE);var DE=function(){function e(){var t;return u(this,e),(t=s(this,e,arguments)).fullscreen=!1,t.inFocusedState=!1,t.scaleFactor=1,t}return y(e,bs),m(e,[{key:"connectedCallback",value:function(){M(e,"connectedCallback",this)([]),!!document.querySelector("nami-paywall.nami-half-sheet-mode, nami-paywall.nami-modal-mode")||(document.body.style.background=this.component.fillColor||"transparent")}},{key:"styles",value:function(){var e;if(!this.contextConsumer||!this.component)return t.unsafeCSS("");var i=this.component,n=this.scaleFactor,a=this.contextConsumer.state.formFactor,r=i.backgroundBlur,o="vertical"===i.direction?"margin-top":"margin-left";return t.unsafeCSS(`\n :host {\n max-height: ${"television"===a?"100vh":""};\n display: ${i.hidden?"none":"flex"};\n flex-direction: column;\n overflow: hidden;\n ${Os(i)}\n position: var(--nami-bg-position, fixed);\n width: 100%;\n bottom: 0px;\n background-repeat: no-repeat;\n background-size: cover;\n background-position: center;\n z-index: ${null!==(e=i.zIndex)&&void 0!==e?e:1};\n top: 0px;\n ${r?`backdrop-filter: blur(${r}px);`:""}\n ${Rs(i,!1)}\n transition: all 0.3s;\n ${Ns(i,n)}\n }\n :host(:focus){\n ${Rs(i,!0)}\n }\n :host > *:not(:first-child) {\n ${o}: ${i.spacing?i.spacing*n:0}px;\n }\n `)}},{key:"updated",value:function(){}},{key:"render",value:function(){var e;return(null!==(e=this.component.components)&&void 0!==e?e:[]).map(e=>Iu(this.contextProvider,e,this.scaleFactor,void 0,this.minSDKVersion))}}])}();Ae([ot({type:Object})],DE.prototype,"component",void 0),Ae([ot({type:Boolean})],DE.prototype,"fullscreen",void 0),Ae([ot({type:Boolean})],DE.prototype,"inFocusedState",void 0),Ae([ot({type:Number})],DE.prototype,"scaleFactor",void 0),Ae([ot({type:Object})],DE.prototype,"minSDKVersion",void 0),DE=Ae([Fe("nami-background-container")],DE);var xE,CE=e=>e,IE=function(){function e(){var t;return u(this,e),(t=s(this,e,arguments)).zIndex=2,t.inFocusedState=!1,t.scaleFactor=1,t}return y(e,bs),m(e,[{key:"styles",value:function(){var e,i,n=this.contextConsumer,a=this.component,r=this.zIndex,o=this.scaleFactor;if(!n)return t.css(xE||(xE=CE``));var s=n.state.formFactor,u=a.backgroundBlur,l="phone"!==s?"width: 100%;":"",d=null!==(e=a.width)&&void 0!==e?e:a.fixedWidth,h=null!==(i=a.height)&&void 0!==i?i:a.fixedHeight,c="phone"===s?`max-width:100%;\n ${void 0!==d?`width: ${Cs(d,o)};`:""}\n ${void 0!==h?`height: ${Cs(h,o)};`:""}`:zs(a,o),m="vertical"===a.direction?"margin-top":"margin-left";return t.unsafeCSS(`\n :host {\n box-sizing: border-box;\n display: ${a.hidden?"none":"flex"};\n position: relative;\n flex: 1;\n min-height: 0;\n ${Fs(a)}\n ${c}\n ${l}\n ${function(e){var t,i,n=e.verticalAlignment,a=e.horizontalAlignment,r=e.direction,o=n?ws[n]:void 0,s=a?ws[a]:void 0;return"vertical"===r?(t=null!=s?s:"center",i=null!=o?o:"start"):(t=null!=o?o:"center",i=null!=s?s:"start"),`${Ss("align-items",t)}${Ss("justify-content",i)}`}(a)}\n ${u?`backdrop-filter: blur(${u}px);`:""}\n z-index: ${r};\n transition: all 0.3s;\n overflow-y: ${"television"===s?"hidden":"scroll"};\n overflow-x: hidden;\n scrollbar-width: none;\n ::-webkit-scrollbar {\n display: none;\n }\n -ms-overflow-style: none; /* IE and Edge */\n scrollbar-width: none; /* Firefox */\n ${Ns(a,o)}\n /* The footer is position:absolute over this container; inset the\n scroll end by its measured height (--nami-footer-height, set by\n the paywall screen) so bottom content is not hidden behind it. */\n padding-bottom: calc(${xs(o,a.bottomPadding)}px + var(--nami-footer-height, 0px));\n ${Rs(a,!1)}\n }\n :host::-webkit-scrollbar {\n display: none;\n }\n :host(:focus){\n ${Rs(a,!0)}\n }\n :host > * {\n width: 100%;\n }\n :host > *:not(:first-child) {\n ${m}: ${a.spacing?a.spacing*o:0}px;\n }\n `)}},{key:"firstUpdated",value:function(){var e=new CustomEvent("child-spacing",{detail:{spacing:this.component.spacing},bubbles:!0,composed:!0});this.dispatchEvent(e)}},{key:"render",value:function(){var e;return(null===(e=this.component.components)||void 0===e?void 0:e.map(e=>Iu(this.contextProvider,e,this.scaleFactor,this.inFocusedState,this.minSDKVersion)))||[]}}])}();Ae([ot({type:Object})],IE.prototype,"component",void 0),Ae([ot({type:Number})],IE.prototype,"zIndex",void 0),Ae([ot({type:Boolean})],IE.prototype,"inFocusedState",void 0),Ae([ot({type:Number})],IE.prototype,"scaleFactor",void 0),Ae([ot({type:Object})],IE.prototype,"minSDKVersion",void 0),IE=Ae([Fe("nami-content-container")],IE);var LE,_E=e=>e,RE=function(){function e(){var t;return u(this,e),(t=s(this,e)).inFocusedState=!1,t.scaleFactor=1,t._handleClick=e=>{e.preventDefault(),Ao({contextProvider:t.contextProvider,onTap:t.component.onTap})},t.addEventListener("click",t._handleClick),t}return y(e,bs),m(e,[{key:"styles",value:function(){var e,i,n=qs("active",this.component.components[0]),a=qs("inactive",this.component.components[0]);return t.unsafeCSS(`\n :host {\n box-sizing: border-box;\n -webkit-tap-highlight-color: transparent;\n cursor: pointer;\n display: flex;\n flex: 0 0 auto;\n position: relative;\n ${Fs(this.component)}\n ${Rs(this.component,!1)}\n ${Ks(this.component,this.scaleFactor,!1)}\n ${this.component.hidden?"display:none;":""}\n }\n :host(:focus){\n ${Rs(this.component,!0)}\n ${Ks(this.component,this.scaleFactor,!0)}\n }\n :host(:focus-visible){\n ${Zs(this.component)}\n }\n .toggle{\n ${e=this.component,i=this.scaleFactor,`\n position: absolute;\n top: ${xs(i,e.topPadding)}px;\n bottom: ${xs(i,e.bottomPadding)}px;\n width: calc(50% - ${xs(i,e.leftPadding)/2}px) !important;\n `}\n transition: transform .5s cubic-bezier(.77, 0, .175, 1);\n ${Js(a,this.scaleFactor,!1)}\n }\n\n :host(:focus) .toggle{\n ${Js(n,this.scaleFactor,!0)}\n }\n \n nami-segment-picker-item:nth-of-type(1).active~.toggle {\n transform: translateX(0%);\n left: ${this.component.leftPadding?Number(this.component.leftPadding)*this.scaleFactor:0}px;\n ${Rs(n,!0)}\n ${Qs(n,this.scaleFactor)}\n }\n\n nami-segment-picker-item:nth-of-type(2).active~.toggle {\n transform: translateX(100%);\n right: ${this.component.rightPadding?Number(this.component.rightPadding)*this.scaleFactor:0}px;\n ${Rs(n,!0)}\n ${Qs(n,this.scaleFactor)}\n `)}},{key:"render",value:function(){this.role="tablist";var e=this.component.components.map(e=>Iu(this.contextProvider,e,this.scaleFactor,this.inFocusedState,this.minSDKVersion));return t.html(LE||(LE=_E`${0}<div class="toggle"></div>`),e)}}])}();Ae([ot({type:Object})],RE.prototype,"component",void 0),Ae([ot({type:Boolean})],RE.prototype,"inFocusedState",void 0),Ae([ot({type:Number})],RE.prototype,"scaleFactor",void 0),Ae([ot({type:Object})],RE.prototype,"minSDKVersion",void 0),RE=Ae([Fe("nami-segment-picker")],RE);var FE,OE=e=>e,WE=function(){function e(){var t;return u(this,e),(t=s(this,e,arguments)).inFocusedState=!1,t.scaleFactor=1,t._handleFocus=()=>{t.inFocusedState=!0},t._handleKeyDown=e=>{"Enter"!==e.key&&" "!==e.key&&142!==e.keyCode&&195!==e.keyCode||t._handleClick()},t._handleClick=()=>{t._updateFormState(),t.requestUpdate("component")},t._handleHover=()=>{t.inFocusedState=!0},t}return y(e,bs),m(e,[{key:"connectedCallback",value:function(){M(e,"connectedCallback",this)([]),this._isActive=!!this.component.checked,this.classList.toggle("active",this._isActive),this.component.formId&&this._updateFormState(),this.addEventListener("click",this._handleClick),this.addEventListener("mouseover",this._handleHover),this.addEventListener("keydown",this._handleKeyDown),this.addEventListener("focus",this._handleFocus)}},{key:"disconnectedCallback",value:function(){M(e,"disconnectedCallback",this)([]),this.removeEventListener("click",this._handleClick),this.removeEventListener("mouseover",this._handleHover),this.removeEventListener("keydown",this._handleKeyDown),this.removeEventListener("focus",this._handleFocus)}},{key:"_getParentPicker",value:function(){var e=this.getRootNode();return e instanceof ShadowRoot?e.host:null}},{key:"_getParentFormId",value:function(){var e;return null===(e=this._getParentPicker())||void 0===e?void 0:e.component.formId}},{key:"_updateFormState",value:function(){if(this.contextProvider)if(this.component.formId){var e=this._getParentFormId();e&&this.contextProvider.setFormState(e,this.component.formId)}else this.component.id&&this.contextProvider.setCurrentGroupData(this.component.id,this.component.text||"")}},{key:"updated",value:function(e){var t;if(e.has("component")&&this.contextProvider){var i=null!==(t=e.get("component"))&&void 0!==t?t:this.component;if(i.formId){var n=this._getParentFormId();n&&this.contextProvider.state.formStates[n]&&(this._isActive=this.contextProvider.state.formStates[n]===i.formId)}else this._isActive=kE(i.id,this.contextProvider.state.currentGroupId);if(this.classList.toggle("active",this._isActive),this._isActive){var a=this.getRootNode();if(a instanceof ShadowRoot)a.querySelectorAll("nami-segment-picker-item").forEach(e=>{e!==this&&e.requestUpdate("component",e)})}}}},{key:"styles",value:function(){var e,i,n=qs("active",this.component),a=qs("inactive",this.component);return t.unsafeCSS(`\n :host {\n box-sizing: border-box;\n display: ${this.component.hidden?"none":"inline-flex"};\n position: relative;\n ${Js(v({},a,this.component),this.scaleFactor,this.inFocusedState)}\n ${Hs(null!==(e=this.component.inactiveDropShadow)&&void 0!==e?e:this.component.dropShadow)}\n }\n\n :host > * {\n cursor: pointer;\n }\n\n :host(.active) {\n z-index: 1 !important;\n ${Qs(v({},n,this.component),this.scaleFactor)}\n ${Hs(null!==(i=this.component.activeDropShadow)&&void 0!==i?i:this.component.dropShadow)}\n }\n\n input {\n visibility: hidden;\n position: absolute;\n top: 0;\n }\n `)}},{key:"render",value:function(){return this.tabIndex=0,this.role="tab",this.ariaSelected=`${this._isActive}`,this.ariaLabel=this.component.text||"",t.html(FE||(FE=OE`<input type="radio"
|
|
463
463
|
autocomplete="off"
|
|
464
464
|
id="${0}"
|
|
465
465
|
name="${0}"
|
|
@@ -467,7 +467,7 @@
|
|
|
467
467
|
checked="${0}"
|
|
468
468
|
|
|
469
469
|
/>
|
|
470
|
-
<label for="${0}">${0}</label>`),this.component.text,this.component.text,this.component.text,this._isActive,this.component.text,this.component.text)}}])}();Ae([ot({type:Object})],OE.prototype,"component",void 0),Ae([ot({type:Boolean})],OE.prototype,"inFocusedState",void 0),Ae([ot({type:Number})],OE.prototype,"scaleFactor",void 0),Ae([st()],OE.prototype,"_isActive",void 0),OE=Ae([Fe("nami-segment-picker-item")],OE);var WE=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},$E=Number.isSafeInteger||function(e){return"number"==typeof e&&Math.abs(e)<=NE},NE=Number.MAX_SAFE_INTEGER||9007199254740991,jE=function(e){return e.NETWORK_ERROR="networkError",e.MEDIA_ERROR="mediaError",e.KEY_SYSTEM_ERROR="keySystemError",e.MUX_ERROR="muxError",e.OTHER_ERROR="otherError",e}({}),BE=function(e){return e.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",e.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",e.KEY_SYSTEM_NO_SESSION="keySystemNoSession",e.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",e.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",e.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",e.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",e.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",e.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR="keySystemDestroyMediaKeysError",e.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR="keySystemDestroyCloseSessionError",e.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR="keySystemDestroyRemoveSessionError",e.MANIFEST_LOAD_ERROR="manifestLoadError",e.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",e.MANIFEST_PARSING_ERROR="manifestParsingError",e.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",e.LEVEL_EMPTY_ERROR="levelEmptyError",e.LEVEL_LOAD_ERROR="levelLoadError",e.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",e.LEVEL_PARSING_ERROR="levelParsingError",e.LEVEL_SWITCH_ERROR="levelSwitchError",e.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",e.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",e.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",e.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",e.FRAG_LOAD_ERROR="fragLoadError",e.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",e.FRAG_DECRYPT_ERROR="fragDecryptError",e.FRAG_PARSING_ERROR="fragParsingError",e.FRAG_GAP="fragGap",e.REMUX_ALLOC_ERROR="remuxAllocError",e.KEY_LOAD_ERROR="keyLoadError",e.KEY_LOAD_TIMEOUT="keyLoadTimeOut",e.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",e.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",e.BUFFER_APPEND_ERROR="bufferAppendError",e.BUFFER_APPENDING_ERROR="bufferAppendingError",e.BUFFER_STALLED_ERROR="bufferStalledError",e.BUFFER_FULL_ERROR="bufferFullError",e.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",e.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",e.ASSET_LIST_LOAD_ERROR="assetListLoadError",e.ASSET_LIST_LOAD_TIMEOUT="assetListLoadTimeout",e.ASSET_LIST_PARSING_ERROR="assetListParsingError",e.INTERSTITIAL_ASSET_ITEM_ERROR="interstitialAssetItemError",e.INTERNAL_EXCEPTION="internalException",e.INTERNAL_ABORTED="aborted",e.ATTACH_MEDIA_ERROR="attachMediaError",e.UNKNOWN="unknown",e}({}),zE=function(e){return e.MEDIA_ATTACHING="hlsMediaAttaching",e.MEDIA_ATTACHED="hlsMediaAttached",e.MEDIA_DETACHING="hlsMediaDetaching",e.MEDIA_DETACHED="hlsMediaDetached",e.MEDIA_ENDED="hlsMediaEnded",e.STALL_RESOLVED="hlsStallResolved",e.BUFFER_RESET="hlsBufferReset",e.BUFFER_CODECS="hlsBufferCodecs",e.BUFFER_CREATED="hlsBufferCreated",e.BUFFER_APPENDING="hlsBufferAppending",e.BUFFER_APPENDED="hlsBufferAppended",e.BUFFER_EOS="hlsBufferEos",e.BUFFERED_TO_END="hlsBufferedToEnd",e.BUFFER_FLUSHING="hlsBufferFlushing",e.BUFFER_FLUSHED="hlsBufferFlushed",e.MANIFEST_LOADING="hlsManifestLoading",e.MANIFEST_LOADED="hlsManifestLoaded",e.MANIFEST_PARSED="hlsManifestParsed",e.LEVEL_SWITCHING="hlsLevelSwitching",e.LEVEL_SWITCHED="hlsLevelSwitched",e.LEVEL_LOADING="hlsLevelLoading",e.LEVEL_LOADED="hlsLevelLoaded",e.LEVEL_UPDATED="hlsLevelUpdated",e.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",e.LEVELS_UPDATED="hlsLevelsUpdated",e.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",e.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",e.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",e.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",e.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",e.AUDIO_TRACK_UPDATED="hlsAudioTrackUpdated",e.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",e.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",e.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",e.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",e.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",e.SUBTITLE_TRACK_UPDATED="hlsSubtitleTrackUpdated",e.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",e.CUES_PARSED="hlsCuesParsed",e.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",e.INIT_PTS_FOUND="hlsInitPtsFound",e.FRAG_LOADING="hlsFragLoading",e.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",e.FRAG_LOADED="hlsFragLoaded",e.FRAG_DECRYPTED="hlsFragDecrypted",e.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",e.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",e.FRAG_PARSING_METADATA="hlsFragParsingMetadata",e.FRAG_PARSED="hlsFragParsed",e.FRAG_BUFFERED="hlsFragBuffered",e.FRAG_CHANGED="hlsFragChanged",e.FPS_DROP="hlsFpsDrop",e.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",e.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",e.ERROR="hlsError",e.DESTROYING="hlsDestroying",e.KEY_LOADING="hlsKeyLoading",e.KEY_LOADED="hlsKeyLoaded",e.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",e.BACK_BUFFER_REACHED="hlsBackBufferReached",e.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",e.ASSET_LIST_LOADING="hlsAssetListLoading",e.ASSET_LIST_LOADED="hlsAssetListLoaded",e.INTERSTITIALS_UPDATED="hlsInterstitialsUpdated",e.INTERSTITIALS_BUFFERED_TO_BOUNDARY="hlsInterstitialsBufferedToBoundary",e.INTERSTITIAL_ASSET_PLAYER_CREATED="hlsInterstitialAssetPlayerCreated",e.INTERSTITIAL_STARTED="hlsInterstitialStarted",e.INTERSTITIAL_ASSET_STARTED="hlsInterstitialAssetStarted",e.INTERSTITIAL_ASSET_ENDED="hlsInterstitialAssetEnded",e.INTERSTITIAL_ASSET_ERROR="hlsInterstitialAssetError",e.INTERSTITIAL_ENDED="hlsInterstitialEnded",e.INTERSTITIALS_PRIMARY_RESUMED="hlsInterstitialsPrimaryResumed",e.PLAYOUT_LIMIT_REACHED="hlsPlayoutLimitReached",e.EVENT_CUE_ENTER="hlsEventCueEnter",e}({}),UE="manifest",HE="level",GE="audioTrack",VE="subtitleTrack",KE="main",XE="audio",YE="subtitle",qE=function(){return m(function e(t,i=0,n=0){u(this,e),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_=i,this.totalWeight_=n},[{key:"sample",value:function(e,t){var i=Math.pow(this.alpha_,e);this.estimate_=t*(1-i)+i*this.estimate_,this.totalWeight_+=e}},{key:"getTotalWeight",value:function(){return this.totalWeight_}},{key:"getEstimate",value:function(){if(this.alpha_){var e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}}])}(),JE=function(){return m(function e(t,i,n,a=100){u(this,e),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_=n,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new qE(t),this.fast_=new qE(i),this.defaultTTFB_=a,this.ttfb_=new qE(t)},[{key:"update",value:function(e,t){var i=this.slow_,n=this.fast_,a=this.ttfb_;i.halfLife!==e&&(this.slow_=new qE(e,i.getEstimate(),i.getTotalWeight())),n.halfLife!==t&&(this.fast_=new qE(t,n.getEstimate(),n.getTotalWeight())),a.halfLife!==e&&(this.ttfb_=new qE(e,a.getEstimate(),a.getTotalWeight()))}},{key:"sample",value:function(e,t){var i=(e=Math.max(e,this.minDelayMs_))/1e3,n=8*t/i;this.fast_.sample(i,n),this.slow_.sample(i,n)}},{key:"sampleTTFB",value:function(e){var t=e/1e3,i=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(i,Math.max(e,5))}},{key:"canEstimate",value:function(){return this.fast_.getTotalWeight()>=this.minWeight_}},{key:"getEstimate",value:function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}},{key:"getEstimateTTFB",value:function(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}},{key:"defaultEstimate",get:function(){return this.defaultEstimate_}},{key:"destroy",value:function(){}}])}();function QE(e,t,i){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var n=i.call(e,t);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function ZE(){return ZE=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var n in i)({}).hasOwnProperty.call(i,n)&&(e[n]=i[n])}return e},ZE.apply(null,arguments)}function eT(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),i.push.apply(i,n)}return i}function tT(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?eT(Object(i),!0).forEach(function(t){QE(e,t,i[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):eT(Object(i)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})}return e}var iT=m(function e(t,i){u(this,e),this.trace=void 0,this.debug=void 0,this.log=void 0,this.warn=void 0,this.info=void 0,this.error=void 0;var n=`[${t}]:`;this.trace=nT,this.debug=i.debug.bind(null,n),this.log=i.log.bind(null,n),this.warn=i.warn.bind(null,n),this.info=i.info.bind(null,n),this.error=i.error.bind(null,n)}),nT=function(){},aT={trace:nT,debug:nT,log:nT,warn:nT,info:nT,error:nT};function rT(){return ZE({},aT)}function oT(e,t,i){return t[e]?t[e].bind(t):function(e,t){var i=self.console[e];return i?i.bind(self.console,`${t?"["+t+"] ":""}[${e}] >`):nT}(e,i)}var sT=rT();var uT=sT;function lT(e=!0){if("undefined"!=typeof self)return(e||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function dT(e,t){var i=Object.keys(e),n=Object.keys(t),a=i.length,r=n.length;return!a||!r||a===r&&!i.some(e=>-1===n.indexOf(e))}function hT(e,t=!1){if("undefined"!=typeof TextDecoder){var i=new TextDecoder("utf-8").decode(e);if(t){var n=i.indexOf("\0");return-1!==n?i.substring(0,n):i}return i.replace(/\0/g,"")}for(var a,r,o,s=e.length,u="",l=0;l<s;){if(0===(a=e[l++])&&t)return u;if(0!==a&&3!==a)switch(a>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:u+=String.fromCharCode(a);break;case 12:case 13:r=e[l++],u+=String.fromCharCode((31&a)<<6|63&r);break;case 14:r=e[l++],o=e[l++],u+=String.fromCharCode((15&a)<<12|(63&r)<<6|63&o)}}return u}function cT(e){for(var t="",i=0;i<e.length;i++){var n=e[i].toString(16);n.length<2&&(n="0"+n),t+=n}return t}function mT(e){return Uint8Array.from(e.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}function fT(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var vT,pT={exports:{}};var gT,yT,bT,wT,kT,ST=vT?pT.exports:(vT=1,gT=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,yT=/^(?=([^\/?#]*))\1([^]*)$/,bT=/(?:\/|^)\.(?=\/)/g,wT=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,pT.exports=kT={buildAbsoluteURL:function(e,t,i){if(i=i||{},e=e.trim(),!(t=t.trim())){if(!i.alwaysNormalize)return e;var n=kT.parseURL(e);if(!n)throw new Error("Error trying to parse base URL.");return n.path=kT.normalizePath(n.path),kT.buildURLFromParts(n)}var a=kT.parseURL(t);if(!a)throw new Error("Error trying to parse relative URL.");if(a.scheme)return i.alwaysNormalize?(a.path=kT.normalizePath(a.path),kT.buildURLFromParts(a)):t;var r=kT.parseURL(e);if(!r)throw new Error("Error trying to parse base URL.");if(!r.netLoc&&r.path&&"/"!==r.path[0]){var o=yT.exec(r.path);r.netLoc=o[1],r.path=o[2]}r.netLoc&&!r.path&&(r.path="/");var s={scheme:r.scheme,netLoc:a.netLoc,path:null,params:a.params,query:a.query,fragment:a.fragment};if(!a.netLoc&&(s.netLoc=r.netLoc,"/"!==a.path[0]))if(a.path){var u=r.path,l=u.substring(0,u.lastIndexOf("/")+1)+a.path;s.path=kT.normalizePath(l)}else s.path=r.path,a.params||(s.params=r.params,a.query||(s.query=r.query));return null===s.path&&(s.path=i.alwaysNormalize?kT.normalizePath(a.path):a.path),kT.buildURLFromParts(s)},parseURL:function(e){var t=gT.exec(e);return t?{scheme:t[1]||"",netLoc:t[2]||"",path:t[3]||"",params:t[4]||"",query:t[5]||"",fragment:t[6]||""}:null},normalizePath:function(e){for(e=e.split("").reverse().join("").replace(bT,"");e.length!==(e=e.replace(wT,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}}),ET=m(function e(){u(this,e),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}}),TT="audio",PT="video",MT="audiovideo",AT=function(){return m(function e(t){u(this,e),this._byteRange=null,this._url=null,this._stats=null,this._streams=null,this.base=void 0,this.relurl=void 0,"string"==typeof t&&(t={url:t}),this.base=t,function(e,t){var i=IT(e,t);i&&(i.enumerable=!0,Object.defineProperty(e,t,i))}(this,"stats")},[{key:"setByteRange",value:function(e,t){var i,n=e.split("@",2);i=1===n.length?(null==t?void 0:t.byteRangeEndOffset)||0:parseInt(n[1]),this._byteRange=[i,parseInt(n[0])+i]}},{key:"baseurl",get:function(){return this.base.url}},{key:"byteRange",get:function(){return null===this._byteRange?[]:this._byteRange}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"elementaryStreams",get:function(){return null===this._streams&&(this._streams={[TT]:null,[PT]:null,[MT]:null}),this._streams},set:function(e){this._streams=e}},{key:"hasStats",get:function(){return null!==this._stats}},{key:"hasStreams",get:function(){return null!==this._streams}},{key:"stats",get:function(){return null===this._stats&&(this._stats=new ET),this._stats},set:function(e){this._stats=e}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=ST.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(e){this._url=e}},{key:"clearElementaryStreamInfo",value:function(){var e=this.elementaryStreams;e[TT]=null,e[PT]=null,e[MT]=null}}])}();function DT(e){return"initSegment"!==e.sn}var xT=function(){function e(t,i){var n;return u(this,e),(n=s(this,e,[i]))._decryptdata=null,n._programDateTime=null,n._ref=null,n._bitrate=void 0,n.rawProgramDateTime=null,n.tagList=[],n.duration=0,n.sn=0,n.levelkeys=void 0,n.type=void 0,n.loader=null,n.keyLoader=null,n.level=-1,n.cc=0,n.startPTS=void 0,n.endPTS=void 0,n.startDTS=void 0,n.endDTS=void 0,n.start=0,n.playlistOffset=0,n.deltaPTS=void 0,n.maxStartPTS=void 0,n.minEndPTS=void 0,n.data=void 0,n.bitrateTest=!1,n.title=null,n.initSegment=null,n.endList=void 0,n.gap=void 0,n.urlId=0,n.type=t,n}return y(e,AT),m(e,[{key:"byteLength",get:function(){if(this.hasStats){var e=this.stats.total;if(e)return e}if(this.byteRange.length){var t=this.byteRange[0],i=this.byteRange[1];if(WE(t)&&WE(i))return i-t}return null}},{key:"bitrate",get:function(){return this.byteLength?8*this.byteLength/this.duration:this._bitrate?this._bitrate:null},set:function(e){this._bitrate=e}},{key:"decryptdata",get:function(){var e,t=this.levelkeys;if(!t||t.NONE)return null;if(t.identity)this._decryptdata||(this._decryptdata=t.identity.getDecryptData(this.sn));else if(null==(e=this._decryptdata)||!e.keyId){var i=Object.keys(t);if(1===i.length){var n=this._decryptdata=t[i[0]]||null;n&&(this._decryptdata=n.getDecryptData(this.sn,t))}}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(null===this.programDateTime)return null;var e=WE(this.duration)?this.duration:0;return this.programDateTime+1e3*e}},{key:"encrypted",get:function(){var e;if(null!=(e=this._decryptdata)&&e.encrypted)return!0;if(this.levelkeys){var t,i=Object.keys(this.levelkeys),n=i.length;if(n>1||1===n&&null!=(t=this.levelkeys[i[0]])&&t.encrypted)return!0}return!1}},{key:"programDateTime",get:function(){return null===this._programDateTime&&this.rawProgramDateTime&&(this.programDateTime=Date.parse(this.rawProgramDateTime)),this._programDateTime},set:function(e){WE(e)?this._programDateTime=e:this._programDateTime=this.rawProgramDateTime=null}},{key:"ref",get:function(){return DT(this)?(this._ref||(this._ref={base:this.base,start:this.start,duration:this.duration,sn:this.sn,programDateTime:this.programDateTime}),this._ref):null}},{key:"addStart",value:function(e){this.setStart(this.start+e)}},{key:"setStart",value:function(e){this.start=e,this._ref&&(this._ref.start=e)}},{key:"setDuration",value:function(e){this.duration=e,this._ref&&(this._ref.duration=e)}},{key:"setKeyFormat",value:function(e){var t=this.levelkeys;if(t){var i,n=t[e];!n||null!=(i=this._decryptdata)&&i.keyId||(this._decryptdata=n.getDecryptData(this.sn,t))}}},{key:"abortRequests",value:function(){var e,t;null==(e=this.loader)||e.abort(),null==(t=this.keyLoader)||t.abort()}},{key:"setElementaryStreamInfo",value:function(e,t,i,n,a,r=!1){var o=this.elementaryStreams,s=o[e];s?(s.startPTS=Math.min(s.startPTS,t),s.endPTS=Math.max(s.endPTS,i),s.startDTS=Math.min(s.startDTS,n),s.endDTS=Math.max(s.endDTS,a)):o[e]={startPTS:t,endPTS:i,startDTS:n,endDTS:a,partial:r}}}])}(),CT=function(){function e(t,i,n,a,r){var o;u(this,e),(o=s(this,e,[n])).fragOffset=0,o.duration=0,o.gap=!1,o.independent=!1,o.relurl=void 0,o.fragment=void 0,o.index=void 0,o.duration=t.decimalFloatingPoint("DURATION"),o.gap=t.bool("GAP"),o.independent=t.bool("INDEPENDENT"),o.relurl=t.enumeratedString("URI"),o.fragment=i,o.index=a;var l=t.enumeratedString("BYTERANGE");return l&&o.setByteRange(l,r),r&&(o.fragOffset=r.fragOffset+r.duration),o}return y(e,AT),m(e,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var e=this.elementaryStreams;return!!(e.audio||e.video||e.audiovideo)}}])}();function IT(e,t){var i=Object.getPrototypeOf(e);if(i){var n=Object.getOwnPropertyDescriptor(i,t);return n||IT(i,t)}}var LT=Math.pow(2,32)-1,_T=[].push,RT={video:1,audio:2,id3:3,text:4};function FT(e){return String.fromCharCode.apply(null,e)}function OT(e,t){var i=e[t]<<8|e[t+1];return i<0?65536+i:i}function WT(e,t){var i=NT(e,t);return i<0?4294967296+i:i}function $T(e,t){var i=WT(e,t);return i*=Math.pow(2,32),i+=WT(e,t+4)}function NT(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function jT(e,t){var i=[];if(!t.length)return i;for(var n=e.byteLength,a=0;a<n;){var r=WT(e,a),o=r>1?a+r:n;if(FT(e.subarray(a+4,a+8))===t[0])if(1===t.length)i.push(e.subarray(a+8,o));else{var s=jT(e.subarray(a+8,o),t.slice(1));s.length&&_T.apply(i,s)}a=o}return i}function BT(e){var t=[],i=e[0],n=8,a=WT(e,n);n+=4;var r=0,o=0;0===i?(r=WT(e,n),o=WT(e,n+4),n+=8):(r=$T(e,n),o=$T(e,n+8),n+=16),n+=2;var s=e.length+o,u=OT(e,n);n+=2;for(var l=0;l<u;l++){var d=n,h=WT(e,d);d+=4;var c=2147483647&h;if(1===(2147483648&h)>>>31)return uT.warn("SIDX has hierarchical references (not supported)"),null;var m=WT(e,d);d+=4,t.push({referenceSize:c,subsegmentDuration:m,info:{duration:m/a,start:s,end:s+c-1}}),s+=c,n=d+=4}return{earliestPresentationTime:r,timescale:a,version:i,referencesCount:u,references:t}}function zT(e){for(var t=[],i=jT(e,["moov","trak"]),n=0;n<i.length;n++){var a=i[n],r=jT(a,["tkhd"])[0];if(r){var o=r[0],s=WT(r,0===o?12:20),u=jT(a,["mdia","mdhd"])[0];if(u){var l=WT(u,0===(o=u[0])?12:20),d=jT(a,["mdia","hdlr"])[0];if(d){var h=FT(d.subarray(8,12)),c={soun:TT,vide:PT}[h],m=UT(jT(a,["mdia","minf","stbl","stsd"])[0]);c?(t[s]={timescale:l,type:c,stsd:m},t[c]=tT({timescale:l,id:s},m)):t[s]={timescale:l,type:h,stsd:m}}}}}return jT(e,["moov","mvex","trex"]).forEach(e=>{var i=WT(e,4),n=t[i];n&&(n.default={duration:WT(e,12),flags:WT(e,20)})}),t}function UT(e){var t,i=e.subarray(8),n=i.subarray(86),a=FT(i.subarray(4,8)),r=a,o="enca"===a||"encv"===a;if(o){var s=jT(i,[a])[0];jT(s.subarray("enca"===a?28:78),["sinf"]).forEach(e=>{var t=jT(e,["schm"])[0];if(t){var i=FT(t.subarray(4,8));if("cbcs"===i||"cenc"===i){var n=jT(e,["frma"])[0];n&&(r=FT(n))}}})}var u=r;switch(r){case"avc1":case"avc2":case"avc3":case"avc4":var l=jT(n,["avcC"])[0];l&&l.length>3&&(r+="."+VT(l[1])+VT(l[2])+VT(l[3]),t=HT("avc1"===u?"dva1":"dvav",n));break;case"mp4a":var d=jT(i,[a])[0],h=jT(d.subarray(28),["esds"])[0];if(h&&h.length>7){var c=4;if(3!==h[c++])break;c=GT(h,c),c+=2;var m=h[c++];if(128&m&&(c+=2),64&m&&(c+=h[c++]),4!==h[c++])break;c=GT(h,c);var f=h[c++];if(64!==f)break;if(r+="."+VT(f),c+=12,5!==h[c++])break;c=GT(h,c);var v=h[c++],p=(248&v)>>3;31===p&&(p+=1+((7&v)<<3)+((224&h[c])>>5)),r+="."+p}break;case"hvc1":case"hev1":var g=jT(n,["hvcC"])[0];if(g&&g.length>12){var y=g[1],b=["","A","B","C"][y>>6],w=31&y,k=WT(g,2),S=(32&y)>>5?"H":"L",E=g[12],T=g.subarray(6,12);r+="."+b+w,r+="."+function(e){for(var t=0,i=0;i<32;i++)t|=(e>>i&1)<<31-i;return t>>>0}(k).toString(16).toUpperCase(),r+="."+S+E;for(var P="",M=T.length;M--;){var A=T[M];if(A||P)P="."+A.toString(16).toUpperCase()+P}r+=P}t=HT("hev1"==u?"dvhe":"dvh1",n);break;case"dvh1":case"dvhe":case"dvav":case"dva1":case"dav1":r=HT(r,n)||r;break;case"vp09":var D=jT(n,["vpcC"])[0];if(D&&D.length>6){var x=D[4],C=D[5],I=D[6]>>4&15;r+="."+KT(x)+"."+KT(C)+"."+KT(I)}break;case"av01":var L=jT(n,["av1C"])[0];if(L&&L.length>2){var _=L[1]>>>5,R=31&L[1],F=L[2]>>>7?"H":"M",O=(64&L[2])>>6,W=(32&L[2])>>5,$=2===_&&O?W?12:10:O?10:8,N=(16&L[2])>>4,j=(8&L[2])>>3,B=(4&L[2])>>2,z=3&L[2];r+="."+_+"."+KT(R)+F+"."+KT($)+"."+N+"."+j+B+z+"."+KT(1)+"."+KT(1)+"."+KT(1)+".0",t=HT("dav1",n)}}return{codec:r,encrypted:o,supplemental:t}}function HT(e,t){var i=jT(t,["dvvC"]),n=i.length?i[0]:jT(t,["dvcC"])[0];if(n){var a=n[2]>>1&127,r=n[2]<<5&32|n[3]>>3&31;return e+"."+KT(a)+"."+KT(r)}}function GT(e,t){for(var i=t+5;128&e[t++]&&t<i;);return t}function VT(e){return("0"+e.toString(16).toUpperCase()).slice(-2)}function KT(e){return(e<10?"0":"")+e}function XT(e,t){jT(e,["moov","trak"]).forEach(e=>{var i=jT(e,["mdia","minf","stbl","stsd"])[0];if(i){var n=i.subarray(8),a=jT(n,["enca"]),r=a.length>0;r||(a=jT(n,["encv"])),a.forEach(e=>{jT(r?e.subarray(28):e.subarray(78),["sinf"]).forEach(e=>{var i=YT(e);i&&t(i,r)})})}})}function YT(e){var t=jT(e,["schm"])[0];if(t){var i=FT(t.subarray(4,8));if("cbcs"===i||"cenc"===i){var n=jT(e,["schi","tenc"])[0];if(n)return n}}}function qT(e,t){var i=new Uint8Array(e.length+t.length);return i.set(e),i.set(t,e.length),i}function JT(e,t){var i=[],n=t.samples,a=t.timescale,r=t.id,o=!1;return jT(n,["moof"]).map(s=>{var u=s.byteOffset-8;jT(s,["traf"]).map(s=>{var l=jT(s,["tfdt"]).map(e=>{var t=e[0],i=WT(e,4);return 1===t&&(i*=Math.pow(2,32),i+=WT(e,8)),i/a})[0];return void 0!==l&&(e=l),jT(s,["tfhd"]).map(l=>{var d=WT(l,4),h=16777215&WT(l,0),c=0,m=!!(16&h),f=0,v=!!(32&h),p=8;d===r&&(!!(1&h)&&(p+=8),!!(2&h)&&(p+=4),!!(8&h)&&(c=WT(l,p),p+=4),m&&(f=WT(l,p),p+=4),v&&(p+=4),"video"===t.type&&(o=QT(t.codec)),jT(s,["trun"]).map(r=>{var s=r[0],l=16777215&WT(r,0),d=!!(1&l),h=0,m=!!(4&l),v=!!(256&l),p=0,g=!!(512&l),y=0,b=!!(1024&l),w=!!(2048&l),k=0,S=WT(r,4),E=8;d&&(h=WT(r,E),E+=4),m&&(E+=4);for(var T=h+u,P=0;P<S;P++){if(v?(p=WT(r,E),E+=4):p=c,g?(y=WT(r,E),E+=4):y=f,b&&(E+=4),w&&(k=0===s?WT(r,E):NT(r,E),E+=4),t.type===PT)for(var M=0;M<y;){var A=WT(n,T);if(ZT(o,n[T+=4]))eP(n.subarray(T,T+A),o?2:1,e+k/a,i);T+=A,M+=A+4}e+=p/a}}))})})}),i}function QT(e){if(!e)return!1;var t=e.substring(0,4);return"hvc1"===t||"hev1"===t||"dvh1"===t||"dvhe"===t}function ZT(e,t){if(e){var i=t>>1&63;return 39===i||40===i}return 6===(31&t)}function eP(e,t,i,n){var a=tP(e),r=0;r+=t;for(var o=0,s=0,u=0;r<a.length;){o=0;do{if(r>=a.length)break;o+=u=a[r++]}while(255===u);s=0;do{if(r>=a.length)break;s+=u=a[r++]}while(255===u);var l=a.length-r,d=r;if(s<l)r+=s;else if(s>l){uT.error(`Malformed SEI payload. ${s} is too small, only ${l} bytes left to parse.`);break}if(4===o){if(181===a[d++]){var h=OT(a,d);if(d+=2,49===h){var c=WT(a,d);if(d+=4,1195456820===c){var m=a[d++];if(3===m){var f=a[d++],v=64&f,p=v?2+3*(31&f):0,g=new Uint8Array(p);if(v){g[0]=f;for(var y=1;y<p;y++)g[y]=a[d++]}n.push({type:m,payloadType:o,pts:i,bytes:g})}}}}}else if(5===o&&s>16){for(var b=[],w=0;w<16;w++){var k=a[d++].toString(16);b.push(1==k.length?"0"+k:k),3!==w&&5!==w&&7!==w&&9!==w||b.push("-")}for(var S=s-16,E=new Uint8Array(S),T=0;T<S;T++)E[T]=a[d++];n.push({payloadType:o,pts:i,uuid:b.join(""),userData:hT(E),userDataBytes:E})}}}function tP(e){for(var t=e.byteLength,i=[],n=1;n<t-2;)0===e[n]&&0===e[n+1]&&3===e[n+2]?(i.push(n+2),n+=2):n++;if(0===i.length)return e;var a=t-i.length,r=new Uint8Array(a),o=0;for(n=0;n<a;o++,n++)o===i[0]&&(o++,i.shift()),r[n]=e[o];return r}function iP(e,t,i){if(16!==e.byteLength)throw new RangeError("Invalid system id");var n,a;n=new Uint8Array,a=new Uint8Array;var r=new Uint8Array(4);return i.byteLength>0&&new DataView(r.buffer).setUint32(0,i.byteLength,!1),function(e,...t){for(var i=t.length,n=8,a=i;a--;)n+=t[a].byteLength;var r=new Uint8Array(n);for(r[0]=n>>24&255,r[1]=n>>16&255,r[2]=n>>8&255,r[3]=255&n,r.set(e,4),a=0,n=8;a<i;a++)r.set(t[a],n),n+=t[a].byteLength;return r}([112,115,115,104],new Uint8Array([0,0,0,0]),e,a,n,r,i)}function nP(e){var t=e.getUint32(0),i=e.byteOffset,n=e.byteLength;if(n<t)return{offset:i,size:n};if(1886614376!==e.getUint32(4))return{offset:i,size:t};var a=e.getUint32(8)>>>24;if(0!==a&&1!==a)return{offset:i,size:t};var r=e.buffer,o=cT(new Uint8Array(r,i+12,16)),s=null,u=0;if(0===a)u=28;else{var l=e.getUint32(28);if(!l||n<32+16*l)return{offset:i,size:t};s=[];for(var d=0;d<l;d++)s.push(new Uint8Array(r,i+32+16*d,16));u=32+16*l}if(!u)return{offset:i,size:t};var h=e.getUint32(u);return t-32<h?{offset:i,size:t}:{version:a,systemId:o,kids:s,data:new Uint8Array(r,i+u+4,h),offset:i,size:t}}var aP=()=>/\(Windows.+Firefox\//i.test(navigator.userAgent),rP={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,dav1:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv60:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1}};function oP(e,t){var i=rP[t];return!!i&&!!i[e.slice(0,4)]}function sP(e,t,i=!0){return!e.split(",").some(e=>!uP(e,t,i))}function uP(e,t,i=!0){var n,a=lT(i);return null!=(n=null==a?void 0:a.isTypeSupported(lP(e,t)))&&n}function lP(e,t){return`${t}/mp4;codecs=${e}`}function dP(e){if(e){var t=e.substring(0,4);return rP.video[t]}return 2}function hP(e){var t=aP();return e.split(",").reduce((e,i)=>{var n=t&&QT(i)?9:rP.video[i];return n?(2*n+e)/(e?3:2):(rP.audio[i]+e)/(e?2:1)},0)}var cP={};var mP=/flac|opus|mp4a\.40\.34/i;function fP(e,t=!0){return e.replace(mP,e=>function(e,t=!0){if(cP[e])return cP[e];for(var i={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"],"mp4a.40.34":["mp3"]}[e],n=0;n<i.length;n++){var a;if(uP(i[n],"audio",t))return cP[e]=i[n],i[n];if("mp3"===i[n]&&null!=(a=lT(t))&&a.isTypeSupported("audio/mpeg"))return""}return e}(e.toLowerCase(),t))}function vP(e,t){if(e&&(e.length>4||-1!==["ac-3","ec-3","alac","fLaC","Opus"].indexOf(e))&&(pP(e,"audio")||pP(e,"video")))return e;if(t){var i=t.split(",");if(i.length>1){if(e)for(var n=i.length;n--;)if(i[n].substring(0,4)===e.substring(0,4))return i[n];return i[0]}}return t||e}function pP(e,t){return oP(e,t)&&uP(e,t)}function gP(e){if(e.startsWith("av01.")){for(var t=e.split("."),i=["0","111","01","01","01","0"],n=t.length;n>4&&n<10;n++)t[n]=i[n-4];return t.join(".")}return e}function yP(e){var t=lT(e)||{isTypeSupported:()=>!1};return{mpeg:t.isTypeSupported("audio/mpeg"),mp3:t.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:t.isTypeSupported('audio/mp4; codecs="ac-3"')}}function bP(e){return e.replace(/^.+codecs=["']?([^"']+).*$/,"$1")}var wP={supported:!1,smooth:!1,powerEfficient:!1},kP={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]};function SP(e,t){return{supported:!1,configurations:t,decodingInfoResults:[wP],error:e}}function EP(e,t,i,n={}){var a=e.videoCodec;if(!a&&!e.audioCodec||!i)return Promise.resolve(kP);for(var r=[],o=function(e){var t,i=null==(t=e.videoCodec)?void 0:t.split(","),n=PP(e),a=e.width||640,r=e.height||480,o=e.frameRate||30,s=e.videoRange.toLowerCase();return i?i.map(e=>{var t={contentType:lP(gP(e),"video"),width:a,height:r,bitrate:n,framerate:o};return"sdr"!==s&&(t.transferFunction=s),t}):[]}(e),s=o.length,u=function(e,t,i){var n,a=null==(n=e.audioCodec)?void 0:n.split(","),r=PP(e);if(a&&e.audioGroups)return e.audioGroups.reduce((e,n)=>{var o,s=n?null==(o=t.groups[n])?void 0:o.tracks:null;return s?s.reduce((e,t)=>{if(t.groupId===n){var o=parseFloat(t.channels||"");a.forEach(t=>{var n={contentType:lP(t,"audio"),bitrate:i?TP(t,r):r};o&&(n.channels=""+o),e.push(n)})}return e},e):e},[]);return[]}(e,t,s>0),l=u.length,d=s||1*l||1;d--;){var h={type:"media-source"};if(s&&(h.video=o[d%s]),l){h.audio=u[d%l];var c=h.audio.bitrate;h.video&&c&&(h.video.bitrate-=c)}r.push(h)}if(a){var m=navigator.userAgent;if(a.split(",").some(e=>QT(e))&&aP())return Promise.resolve(SP(new Error(`Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent string: (${m})`),r))}return Promise.all(r.map(e=>{var t=function(e){var t="",i=e.audio,n=e.video;if(n){t+=`${bP(n.contentType)}_r${n.height}x${n.width}f${Math.ceil(n.framerate)}${n.transferFunction||"sd"}_${Math.ceil(n.bitrate/1e5)}`}if(i){t+=`${n?"_":""}${bP(i.contentType)}_c${i.channels}`}return t}(e);return n[t]||(n[t]=i.decodingInfo(e))})).then(e=>({supported:!e.some(e=>!e.supported),configurations:r,decodingInfoResults:e})).catch(e=>({supported:!1,configurations:r,decodingInfoResults:[],error:e}))}function TP(e,t){if(t<=1)return 1;var i=128e3;return"ec-3"===e?i=768e3:"ac-3"===e&&(i=64e4),Math.min(t/2,i)}function PP(e){return 1e3*Math.ceil(Math.max(.9*e.bitrate,e.averageBitrate)/1e3)||1}var MP=["NONE","TYPE-0","TYPE-1",null];var AP=["SDR","PQ","HLG"];var DP="",xP="YES",CP="v2";function IP(e){var t=e.canSkipUntil,i=e.canSkipDateRanges,n=e.age;return t&&n<t/2?i?CP:xP:DP}var LP=function(){return m(function e(t,i,n){u(this,e),this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=t,this.part=i,this.skip=n},[{key:"addDirectives",value:function(e){var t=new self.URL(e);return void 0!==this.msn&&t.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href}}])}(),_P=function(){return m(function e(t){if(u(this,e),this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.supplemental=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=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.frameRate=t.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=t.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=t.audioCodec,this.videoCodec=t.videoCodec,this.codecSet=[t.videoCodec,t.audioCodec].filter(e=>!!e).map(e=>e.substring(0,4)).join(","),"supplemental"in t){var i;this.supplemental=t.supplemental;var n=null==(i=t.supplemental)?void 0:i.videoCodec;n&&n!==t.videoCodec&&(this.codecSet+=`,${n.substring(0,4)}`)}this.addGroupId("audio",t.attrs.AUDIO),this.addGroupId("text",t.attrs.SUBTITLES)},[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"averageBitrate",get:function(){return this._avgBitrate||this.realBitrate||this.bitrate}},{key:"attrs",get:function(){return this._attrs[0]}},{key:"codecs",get:function(){return this.attrs.CODECS||""}},{key:"pathwayId",get:function(){return this.attrs["PATHWAY-ID"]||"."}},{key:"videoRange",get:function(){return this.attrs["VIDEO-RANGE"]||"SDR"}},{key:"score",get:function(){return this.attrs.optionalFloat("SCORE",0)}},{key:"uri",get:function(){return this.url[0]||""}},{key:"hasAudioGroup",value:function(e){return RP(this._audioGroups,e)}},{key:"hasSubtitleGroup",value:function(e){return RP(this._subtitleGroups,e)}},{key:"audioGroups",get:function(){return this._audioGroups}},{key:"subtitleGroups",get:function(){return this._subtitleGroups}},{key:"addGroupId",value:function(e,t){if(t)if("audio"===e){var i=this._audioGroups;i||(i=this._audioGroups=[]),-1===i.indexOf(t)&&i.push(t)}else if("text"===e){var n=this._subtitleGroups;n||(n=this._subtitleGroups=[]),-1===n.indexOf(t)&&n.push(t)}}},{key:"urlId",get:function(){return 0},set:function(e){}},{key:"audioGroupIds",get:function(){return this.audioGroups?[this.audioGroupId]:void 0}},{key:"textGroupIds",get:function(){return this.subtitleGroups?[this.textGroupId]:void 0}},{key:"audioGroupId",get:function(){var e;return null==(e=this.audioGroups)?void 0:e[0]}},{key:"textGroupId",get:function(){var e;return null==(e=this.subtitleGroups)?void 0:e[0]}},{key:"addFallback",value:function(){}}])}();function RP(e,t){return!(!t||!e)&&-1!==e.indexOf(t)}function FP(e,t){var i=!1,n=[];if(e&&(i="SDR"!==e,n=[e]),t){var a="SDR"!==(n=t.allowedVideoRanges||AP.slice(0)).join("")&&!t.videoCodec;(i=void 0!==t.preferHDR?t.preferHDR:a&&function(){if("function"==typeof matchMedia){var e=matchMedia("(dynamic-range: high)"),t=matchMedia("bad query");if(e.media!==t.media)return!0===e.matches}return!1}())||(n=["SDR"])}return{preferHDR:i,allowedVideoRanges:n}}var OP=(e,t)=>JSON.stringify(e,(e=>{var t=new WeakSet;return(i,n)=>{if(e&&(n=e(i,n)),"object"==typeof n&&null!==n){if(t.has(n))return;t.add(n)}return n}})(t));function WP(e,t){uT.log(`[abr] start candidates with "${e}" ignored because ${t}`)}function $P(e){return e.reduce((e,t)=>{var i=e.groups[t.groupId];i||(i=e.groups[t.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),i.tracks.push(t);var n=t.channels||"2";return i.channels[n]=(i.channels[n]||0)+1,i.hasDefault=i.hasDefault||t.default,i.hasAutoSelect=i.hasAutoSelect||t.autoselect,i.hasDefault&&(e.hasDefaultAudio=!0),i.hasAutoSelect&&(e.hasAutoSelectAudio=!0),e},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function NP(e){return e?{lang:e.lang,assocLang:e.assocLang,characteristics:e.characteristics,channels:e.channels,audioCodec:e.audioCodec}:e}function jP(e,t,i){if("attrs"in e){var n=t.indexOf(e);if(-1!==n)return n}for(var a=0;a<t.length;a++){if(BP(e,t[a],i))return a}return-1}function BP(e,t,i){var n=e.groupId,a=e.name,r=e.lang,o=e.assocLang,s=e.default,u=e.forced;return(void 0===n||t.groupId===n)&&(void 0===a||t.name===a)&&(void 0===r||function(e,t="--"){if(e.length===t.length)return e===t;return e.startsWith(t)||t.startsWith(e)}(r,t.lang))&&(void 0===r||t.assocLang===o)&&(void 0===s||t.default===s)&&(void 0===u||t.forced===u)&&(!("characteristics"in e)||function(e,t=""){var i=e.split(","),n=t.split(",");return i.length===n.length&&!i.some(e=>-1===n.indexOf(e))}(e.characteristics||"",t.characteristics))&&(void 0===i||i(e,t))}function zP(e,t){var i=e.audioCodec,n=e.channels;return!(void 0!==i&&(t.audioCodec||"").substring(0,4)!==i.substring(0,4)||void 0!==n&&n!==(t.channels||"2"))}function UP(e,t,i){for(var n=t;n>-1;n--)if(i(e[n]))return n;for(var a=t+1;a<e.length;a++)if(i(e[a]))return a;return-1}function HP(e,t){var i;return!!e&&e!==(null==(i=t.loadLevelObj)?void 0:i.uri)}var GP=function(){function e(t){var i;return u(this,e),(i=s(this,e,["abr",t.logger])).hls=void 0,i.lastLevelLoadSec=0,i.lastLoadedFragLevel=-1,i.firstSelection=-1,i._nextAutoLevel=-1,i.nextAutoLevelKey="",i.audioTracksByGroup=null,i.codecTiers=null,i.timer=-1,i.fragCurrent=null,i.partCurrent=null,i.bitrateTestDelay=0,i.rebufferNotice=-1,i.supportedCache={},i.bwEstimator=void 0,i._abandonRulesCheck=e=>{var t,n=i,a=n.fragCurrent,r=n.partCurrent,o=n.hls,s=o.autoLevelEnabled,u=o.media;if(a&&u){var l=performance.now(),d=r?r.stats:a.stats,h=r?r.duration:a.duration,c=l-d.loading.start,m=o.minAutoLevel,f=a.level,v=i._nextAutoLevel;if(d.aborted||d.loaded&&d.loaded===d.total||f<=m)return i.clearTimer(),void(i._nextAutoLevel=-1);if(s){var p=v>-1&&v!==f,g=!!e||p;if(g||!u.paused&&u.playbackRate&&u.readyState){var y=o.mainForwardBufferInfo;if(g||null!==y){var b=i.bwEstimator.getEstimateTTFB(),w=Math.abs(u.playbackRate);if(!(c<=Math.max(b,h/(2*w)*1e3))){var k=y?y.len/w:0,S=d.loading.first?d.loading.first-d.loading.start:-1,E=d.loaded&&S>-1,T=i.getBwEstimate(),P=o.levels,M=P[f],A=Math.max(d.loaded,Math.round(h*(a.bitrate||M.averageBitrate)/8)),D=E?c-S:c;D<1&&E&&(D=Math.min(c,8*d.loaded/T));var x=E?1e3*d.loaded/D:0,C=b/1e3,I=x?(A-d.loaded)/x:8*A/T+C;if(!(I<=k)){var L,_=x?8*x:T,R=!0===(null==(t=(null==e?void 0:e.details)||i.hls.latestLevelDetails)?void 0:t.live),F=i.hls.config.abrBandWidthUpFactor,O=Number.POSITIVE_INFINITY;for(L=f-1;L>m;L--){var W=P[L].maxBitrate,$=!P[L].details||R;if((O=i.getTimeToLoadFrag(C,_,h*W,$))<Math.min(k,h+C))break}if(!(O>=I||O>10*h)){E?i.bwEstimator.sample(c-Math.min(b,S),d.loaded):i.bwEstimator.sampleTTFB(c);var N=P[L].maxBitrate;i.getBwEstimate()*F>N&&i.resetEstimator(N);var j=i.findBestLevel(N,m,L,0,k,1,1);j>-1&&(L=j),i.warn(`Fragment ${a.sn}${r?" part "+r.index:""} of level ${f} is loading too slowly;\n Fragment duration: ${a.duration.toFixed(3)}\n Time to underbuffer: ${k.toFixed(3)} s\n Estimated load time for current fragment: ${I.toFixed(3)} s\n Estimated load time for down switch fragment: ${O.toFixed(3)} s\n TTFB estimate: ${0|S} ms\n Current BW estimate: ${WE(T)?0|T:"Unknown"} bps\n New BW estimate: ${0|i.getBwEstimate()} bps\n Switching to level ${L} @ ${0|N} bps`),o.nextLoadLevel=o.nextAutoLevel=L,i.clearTimer();var B=()=>{if(i.clearTimer(),i.fragCurrent===a&&i.hls.loadLevel===L&&L>0){var e=i.getStarvationDelay();if(i.warn(`Aborting inflight request ${L>0?"and switching down":""}\n Fragment duration: ${a.duration.toFixed(3)} s\n Time to underbuffer: ${e.toFixed(3)} s`),a.abortRequests(),i.fragCurrent=i.partCurrent=null,L>m){var t=i.findBestLevel(i.hls.levels[m].bitrate,m,L,0,e,1,1);-1===t&&(t=m),i.hls.nextLoadLevel=i.hls.nextAutoLevel=t,i.resetEstimator(i.hls.levels[t].bitrate)}}};p||I>2*O?B():i.timer=self.setInterval(B,1e3*O),o.trigger(zE.FRAG_LOAD_EMERGENCY_ABORTED,{frag:a,part:r,stats:d})}}}}}}}},i.hls=t,i.bwEstimator=i.initEstimator(),i.registerListeners(),i}return y(e,iT),m(e,[{key:"resetEstimator",value:function(e){e&&(this.log(`setting initial bwe to ${e}`),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()}},{key:"initEstimator",value:function(){var e=this.hls.config;return new JE(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}},{key:"registerListeners",value:function(){var e=this.hls;e.on(zE.MANIFEST_LOADING,this.onManifestLoading,this),e.on(zE.FRAG_LOADING,this.onFragLoading,this),e.on(zE.FRAG_LOADED,this.onFragLoaded,this),e.on(zE.FRAG_BUFFERED,this.onFragBuffered,this),e.on(zE.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(zE.LEVEL_LOADED,this.onLevelLoaded,this),e.on(zE.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(zE.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(zE.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(zE.MANIFEST_LOADING,this.onManifestLoading,this),e.off(zE.FRAG_LOADING,this.onFragLoading,this),e.off(zE.FRAG_LOADED,this.onFragLoaded,this),e.off(zE.FRAG_BUFFERED,this.onFragBuffered,this),e.off(zE.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(zE.LEVEL_LOADED,this.onLevelLoaded,this),e.off(zE.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(zE.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(zE.ERROR,this.onError,this))}},{key:"destroy",value:function(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=this.supportedCache=null,this.fragCurrent=this.partCurrent=null}},{key:"onManifestLoading",value:function(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.supportedCache={},this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()}},{key:"onLevelsUpdated",value:function(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null}},{key:"onMaxAutoLevelUpdated",value:function(){this.firstSelection=-1,this.nextAutoLevelKey=""}},{key:"onFragLoading",value:function(e,t){var i=t.frag;if(!this.ignoreFragment(i)){var n;if(!i.bitrateTest)this.fragCurrent=i,this.partCurrent=null!=(n=t.part)?n:null;this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100)}}},{key:"onLevelSwitching",value:function(e,t){this.clearTimer()}},{key:"onError",value:function(e,t){if(!t.fatal)switch(t.details){case BE.BUFFER_ADD_CODEC_ERROR:case BE.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case BE.FRAG_LOAD_TIMEOUT:var i=t.frag,n=this.fragCurrent,a=this.partCurrent;if(i&&n&&i.sn===n.sn&&i.level===n.level){var r=performance.now(),o=a?a.stats:i.stats,s=r-o.loading.start,u=o.loading.first?o.loading.first-o.loading.start:-1;if(o.loaded&&u>-1){var l=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(s-Math.min(l,u),o.loaded)}else this.bwEstimator.sampleTTFB(s)}}}},{key:"getTimeToLoadFrag",value:function(e,t,i,n){return e+i/t+(n?e+this.lastLevelLoadSec:0)}},{key:"onLevelLoaded",value:function(e,t){var i=this.hls.config,n=t.stats.loading,a=n.end-n.first;WE(a)&&(this.lastLevelLoadSec=a/1e3),t.details.live?this.bwEstimator.update(i.abrEwmaSlowLive,i.abrEwmaFastLive):this.bwEstimator.update(i.abrEwmaSlowVoD,i.abrEwmaFastVoD),this.timer>-1&&this._abandonRulesCheck(t.levelInfo)}},{key:"onFragLoaded",value:function(e,{frag:t,part:i}){var n=i?i.stats:t.stats;if(t.type===KE&&this.bwEstimator.sampleTTFB(n.loading.first-n.loading.start),!this.ignoreFragment(t)){if(this.clearTimer(),t.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){var a=i?i.duration:t.duration,r=this.hls.levels[t.level],o=(r.loaded?r.loaded.bytes:0)+n.loaded,s=(r.loaded?r.loaded.duration:0)+a;r.loaded={bytes:o,duration:s},r.realBitrate=Math.round(8*o/s)}if(t.bitrateTest){var u={stats:n,frag:t,part:i,id:t.type};this.onFragBuffered(zE.FRAG_BUFFERED,u),t.bitrateTest=!1}else this.lastLoadedFragLevel=t.level}}},{key:"onFragBuffered",value:function(e,t){var i=t.frag,n=t.part,a=null!=n&&n.stats.loaded?n.stats:i.stats;if(!a.aborted&&!this.ignoreFragment(i)){var r=a.parsing.end-a.loading.start-Math.min(a.loading.first-a.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(r,a.loaded),a.bwEstimate=this.getBwEstimate(),i.bitrateTest?this.bitrateTestDelay=r/1e3:this.bitrateTestDelay=0}}},{key:"ignoreFragment",value:function(e){return e.type!==KE||"initSegment"===e.sn}},{key:"clearTimer",value:function(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)}},{key:"firstAutoLevel",get:function(){var e=this.hls,t=e.maxAutoLevel,i=e.minAutoLevel,n=this.getBwEstimate(),a=this.hls.config.maxStarvationDelay,r=this.findBestLevel(n,i,t,0,a,1,1);if(r>-1)return r;var o=this.hls.firstLevel,s=Math.min(Math.max(o,i),t);return this.warn(`Could not find best starting auto level. Defaulting to first in playlist ${o} clamped to ${s}`),s}},{key:"forcedAutoLevel",get:function(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}},{key:"nextAutoLevel",get:function(){var e=this.forcedAutoLevel,t=this.bwEstimator.canEstimate(),i=this.lastLoadedFragLevel>-1;if(!(-1===e||t&&i&&this.nextAutoLevelKey!==this.getAutoLevelKey()))return e;var n=t&&i?this.getNextABRAutoLevel():this.firstAutoLevel;if(-1!==e){var a=this.hls.levels;if(a.length>Math.max(e,n)&&a[e].loadError<=a[n].loadError)return e}return this._nextAutoLevel=n,this.nextAutoLevelKey=this.getAutoLevelKey(),n},set:function(e){var t=this.deriveNextAutoLevel(e);this._nextAutoLevel!==t&&(this.nextAutoLevelKey="",this._nextAutoLevel=t)}},{key:"getAutoLevelKey",value:function(){return`${this.getBwEstimate()}_${this.getStarvationDelay().toFixed(2)}`}},{key:"getNextABRAutoLevel",value:function(){var e=this.fragCurrent,t=this.partCurrent,i=this.hls;if(i.levels.length<=1)return i.loadLevel;var n=i.maxAutoLevel,a=i.config,r=i.minAutoLevel,o=t?t.duration:e?e.duration:0,s=this.getBwEstimate(),u=this.getStarvationDelay(),l=a.abrBandWidthFactor,d=a.abrBandWidthUpFactor;if(u){var h=this.findBestLevel(s,r,n,u,0,l,d);if(h>=0)return this.rebufferNotice=-1,h}var c=o?Math.min(o,a.maxStarvationDelay):a.maxStarvationDelay;if(!u){var m=this.bitrateTestDelay;if(m)c=(o?Math.min(o,a.maxLoadingDelay):a.maxLoadingDelay)-m,this.info(`bitrate test took ${Math.round(1e3*m)}ms, set first fragment max fetchDuration to ${Math.round(1e3*c)} ms`),l=d=1}var f=this.findBestLevel(s,r,n,u,c,l,d);if(this.rebufferNotice!==f&&(this.rebufferNotice=f,this.info(`${u?"rebuffering expected":"buffer is empty"}, optimal quality level ${f}`)),f>-1)return f;var v=i.levels[r],p=i.loadLevelObj;return p&&(null==v?void 0:v.bitrate)<p.bitrate?r:i.loadLevel}},{key:"getStarvationDelay",value:function(){var e=this.hls,t=e.media;if(!t)return 1/0;var i=t&&0!==t.playbackRate?Math.abs(t.playbackRate):1,n=e.mainForwardBufferInfo;return(n?n.len:0)/i}},{key:"getBwEstimate",value:function(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate}},{key:"findBestLevel",value:function(e,t,i,n,a,r,o){var s,u=this,l=n+a,d=this.lastLoadedFragLevel,h=-1===d?this.hls.firstLevel:d,c=this.fragCurrent,m=this.partCurrent,f=this.hls,v=f.levels,p=f.allAudioTracks,g=f.loadLevel,y=f.config;if(1===v.length)return 0;var b,w=v[h],k=!(null==(s=this.hls.latestLevelDetails)||!s.live),S=-1===g||-1===d,E="SDR",T=(null==w?void 0:w.frameRate)||0,P=y.audioPreference,M=y.videoPreference,A=this.audioTracksByGroup||(this.audioTracksByGroup=$P(p)),D=-1;if(S){if(-1!==this.firstSelection)return this.firstSelection;var x=this.codecTiers||(this.codecTiers=function(e,t,i,n){return e.slice(i,n+1).reduce((e,i,n)=>{if(!i.codecSet)return e;var a=i.audioGroups,r=e[i.codecSet];r||(e[i.codecSet]=r={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,minIndex:n,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!a,fragmentError:0}),r.minBitrate=Math.min(r.minBitrate,i.bitrate);var o=Math.min(i.height,i.width);return r.minHeight=Math.min(r.minHeight,o),r.minFramerate=Math.min(r.minFramerate,i.frameRate),r.minIndex=Math.min(r.minIndex,n),r.maxScore=Math.max(r.maxScore,i.score),r.fragmentError+=i.fragmentError,r.videoRanges[i.videoRange]=(r.videoRanges[i.videoRange]||0)+1,a&&a.forEach(e=>{if(e){var i=t.groups[e];i&&(r.hasDefaultAudio=r.hasDefaultAudio||t.hasDefaultAudio?i.hasDefault:i.hasAutoSelect||!t.hasDefaultAudio&&!t.hasAutoSelectAudio,Object.keys(i.channels).forEach(e=>{r.channels[e]=(r.channels[e]||0)+i.channels[e]}))}}),e},{})}(v,A,t,i)),C=function(e,t,i,n,a){for(var r=Object.keys(e),o=null==n?void 0:n.channels,s=null==n?void 0:n.audioCodec,u=null==a?void 0:a.videoCodec,l=o&&2===parseInt(o),d=!1,h=!1,c=1/0,m=1/0,f=1/0,v=1/0,p=0,g=[],y=FP(t,a),b=y.preferHDR,w=y.allowedVideoRanges,k=function(){var t=e[r[S]];d||(d=t.channels[2]>0),c=Math.min(c,t.minHeight),m=Math.min(m,t.minFramerate),f=Math.min(f,t.minBitrate),w.filter(e=>t.videoRanges[e]>0).length>0&&(h=!0)},S=r.length;S--;)k();c=WE(c)?c:0,m=WE(m)?m:0;var E=Math.max(1080,c),T=Math.max(30,m);f=WE(f)?f:i,i=Math.max(f,i),h||(t=void 0);var P=r.length>1;return{codecSet:r.reduce((t,n)=>{var a=e[n];if(n===t)return t;if(g=h?w.filter(e=>a.videoRanges[e]>0):[],P){if(a.minBitrate>i)return WP(n,`min bitrate of ${a.minBitrate} > current estimate of ${i}`),t;if(!a.hasDefaultAudio)return WP(n,"no renditions with default or auto-select sound found"),t;if(s&&n.indexOf(s.substring(0,4))%5!=0)return WP(n,`audio codec preference "${s}" not found`),t;if(o&&!l){if(!a.channels[o])return WP(n,`no renditions with ${o} channel sound found (channels options: ${Object.keys(a.channels)})`),t}else if((!s||l)&&d&&0===a.channels[2])return WP(n,"no renditions with stereo sound found"),t;if(a.minHeight>E)return WP(n,`min resolution of ${a.minHeight} > maximum of ${E}`),t;if(a.minFramerate>T)return WP(n,`min framerate of ${a.minFramerate} > maximum of ${T}`),t;if(!g.some(e=>a.videoRanges[e]>0))return WP(n,`no variants with VIDEO-RANGE of ${OP(g)} found`),t;if(u&&n.indexOf(u.substring(0,4))%5!=0)return WP(n,`video codec preference "${u}" not found`),t;if(a.maxScore<p)return WP(n,`max score of ${a.maxScore} < selected max of ${p}`),t}return t&&(hP(n)>=hP(t)||a.fragmentError>e[t].fragmentError)?t:(v=a.minIndex,p=a.maxScore,n)},void 0),videoRanges:g,preferHDR:b,minFramerate:m,minBitrate:f,minIndex:v}}(x,E,e,P,M),I=C.codecSet,L=C.videoRanges,_=C.minFramerate,R=C.minBitrate,F=C.minIndex,O=C.preferHDR;D=F,b=I,E=O?L[L.length-1]:L[0],T=_,e=Math.max(e,R),this.log(`picked start tier ${OP(C)}`)}else b=null==w?void 0:w.codecSet,E=null==w?void 0:w.videoRange;for(var W,$,N=m?m.duration:c?c.duration:0,j=this.bwEstimator.getEstimateTTFB()/1e3,B=[],z=function(){var t=v[U],s=U>h;if(!t)return 0;if(y.useMediaCapabilities&&!t.supportedResult&&!t.supportedPromise){var c=navigator.mediaCapabilities;"function"==typeof(null==c?void 0:c.decodingInfo)&&function(e,t,i,n,a,r){var o=e.videoCodec,s=e.audioCodec?e.audioGroups:null,u=null==r?void 0:r.audioCodec,l=null==r?void 0:r.channels,d=l?parseInt(l):u?1/0:2,h=null;if(null!=s&&s.length)try{h=1===s.length&&s[0]?t.groups[s[0]].channels:s.reduce((e,i)=>{if(i){var n=t.groups[i];if(!n)throw new Error(`Audio track group ${i} not found`);Object.keys(n.channels).forEach(t=>{e[t]=(e[t]||0)+n.channels[t]})}return e},{2:0})}catch(e){return!0}return void 0!==o&&(o.split(",").some(e=>QT(e))||e.width>1920&&e.height>1088||e.height>1920&&e.width>1088||e.frameRate>Math.max(n,30)||"SDR"!==e.videoRange&&e.videoRange!==i||e.bitrate>Math.max(a,8e6))||!!h&&WE(d)&&Object.keys(h).some(e=>parseInt(e)>d)}(t,A,E,T,e,P)?(t.supportedPromise=EP(t,A,c,u.supportedCache),t.supportedPromise.then(e=>{if(u.hls){t.supportedResult=e;var i=u.hls.levels,n=i.indexOf(t);e.error?u.warn(`MediaCapabilities decodingInfo error: "${e.error}" for level ${n} ${OP(e)}`):e.supported?e.decodingInfoResults.some(e=>!1===e.smooth||!1===e.powerEfficient)&&u.log(`MediaCapabilities decodingInfo for level ${n} not smooth or powerEfficient: ${OP(e)}`):(u.warn(`Unsupported MediaCapabilities decodingInfo result for level ${n} ${OP(e)}`),n>-1&&i.length>1&&(u.log(`Removing unsupported level ${n}`),u.hls.removeLevel(n),-1===u.hls.loadLevel&&(u.hls.nextLoadLevel=0)))}}).catch(e=>{u.warn(`Error handling MediaCapabilities decodingInfo: ${e}`)})):t.supportedResult=kP}if((b&&t.codecSet!==b||E&&t.videoRange!==E||s&&T>t.frameRate||!s&&T>0&&T<t.frameRate||null!=(W=t.supportedResult)&&null!=(W=W.decodingInfoResults)&&W.some(e=>!1===e.smooth))&&(!S||U!==D))return B.push(U),0;var f,p=t.details,w=(m?null==p?void 0:p.partTarget:null==p?void 0:p.averagetargetduration)||N;f=s?o*e:r*e;var M=N&&n>=2*N&&0===a?t.averageBitrate:t.maxBitrate,x=u.getTimeToLoadFrag(j,f,M*w,void 0===p);if(f>=M&&(U===d||0===t.loadError&&0===t.fragmentError)&&(x<=j||!WE(x)||k&&!u.bitrateTestDelay||x<l)){var C=u.forcedAutoLevel;return U===g||-1!==C&&C===g||(B.length&&u.trace(`Skipped level(s) ${B.join(",")} of ${i} max with CODECS and VIDEO-RANGE:"${v[B[0]].codecs}" ${v[B[0]].videoRange}; not compatible with "${b}" ${E}`),u.info(`switch candidate:${h}->${U} adjustedbw(${Math.round(f)})-bitrate=${Math.round(f-M)} ttfb:${j.toFixed(1)} avgDuration:${w.toFixed(1)} maxFetchDuration:${l.toFixed(1)} fetchDuration:${x.toFixed(1)} firstSelection:${S} codecSet:${t.codecSet} videoRange:${t.videoRange} hls.loadLevel:${g}`)),S&&(u.firstSelection=U),{v:U}}},U=i;U>=t;U--)if(0!==($=z())&&$)return $.v;return-1}},{key:"deriveNextAutoLevel",value:function(e){var t=this.hls,i=t.maxAutoLevel,n=t.minAutoLevel;return Math.min(Math.max(e,n),i)}}])}(),VP=function(e,t){for(var i=0,n=e.length-1,a=null,r=null;i<=n;){var o=t(r=e[a=(i+n)/2|0]);if(o>0)i=a+1;else{if(!(o<0))return r;n=a-1}}return null};function KP(e,t,i=0,n=0,a=.005){var r=null;if(e){r=t[1+e.sn-t[0].sn]||null;var o=e.endDTS-i;o>0&&o<15e-7&&(i+=15e-7),r&&e.level!==r.level&&r.end<=e.end&&(r=t[2+e.sn-t[0].sn]||null)}else 0===i&&0===t[0].start&&(r=t[0]);if(r&&((!e||e.level===r.level)&&0===XP(i,n,r)||function(e,t,i){if(t&&0===t.start&&t.level<e.level&&(t.endPTS||0)>0){var n=t.tagList.reduce((e,t)=>("INF"===t[0]&&(e+=parseFloat(t[1])),e),i);return e.start<=n}return!1}(r,e,Math.min(a,n))))return r;var s=VP(t,XP.bind(null,i,n));return!s||s===e&&r?r:s}function XP(e=0,t=0,i){if(i.start<=e&&i.start+i.duration>e)return 0;var n=Math.min(t,i.duration+(i.deltaPTS?i.deltaPTS:0));return i.start+i.duration-n<=e?1:i.start-n>e&&i.start?-1:0}function YP(e,t,i){var n=1e3*Math.min(t,i.duration+(i.deltaPTS?i.deltaPTS:0));return(i.endProgramDateTime||0)-n>e}function qP(e,t,i){if(e&&e.startCC<=t&&e.endCC>=t){var n,a=e.fragments,r=e.fragmentHint;return r&&(a=a.concat(r)),VP(a,e=>e.cc<t?1:e.cc>t?-1:(n=e,e.end<=i?1:e.start>i?-1:0)),n||null}return null}function JP(e){switch(e.details){case BE.FRAG_LOAD_TIMEOUT:case BE.KEY_LOAD_TIMEOUT:case BE.LEVEL_LOAD_TIMEOUT:case BE.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function QP(e){return e.details.startsWith("key")}function ZP(e){return QP(e)&&!!e.frag&&!e.frag.decryptdata}function eM(e,t){var i=JP(t);return e.default[(i?"timeout":"error")+"Retry"]}function tM(e,t){var i="linear"===e.backoff?1:Math.pow(2,t);return Math.min(i*e.retryDelayMs,e.maxRetryDelayMs)}function iM(e){return tT(tT({},e),{errorRetry:null,timeoutRetry:null})}function nM(e,t,i,n){if(!e)return!1;var a=null==n?void 0:n.code,r=t<e.maxNumRetry&&(function(e){return aM(e)||!!e&&(e<400||e>499)}(a)||!!i);return e.shouldRetry?e.shouldRetry(e,t,i,n,r):r}function aM(e){return 0===e&&!1===navigator.onLine}var rM=0,oM=2,sM=3,uM=5,lM=0,dM=1,hM=2,cM=4,mM=function(){function e(t){var i;return u(this,e),(i=s(this,e,["error-controller",t.logger])).hls=void 0,i.playlistError=0,i.hls=t,i.registerListeners(),i}return y(e,iT),m(e,[{key:"registerListeners",value:function(){var e=this.hls;e.on(zE.ERROR,this.onError,this),e.on(zE.MANIFEST_LOADING,this.onManifestLoading,this),e.on(zE.LEVEL_UPDATED,this.onLevelUpdated,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(zE.ERROR,this.onError,this),e.off(zE.ERROR,this.onErrorOut,this),e.off(zE.MANIFEST_LOADING,this.onManifestLoading,this),e.off(zE.LEVEL_UPDATED,this.onLevelUpdated,this))}},{key:"destroy",value:function(){this.unregisterListeners(),this.hls=null}},{key:"startLoad",value:function(e){}},{key:"stopLoad",value:function(){this.playlistError=0}},{key:"getVariantLevelIndex",value:function(e){return(null==e?void 0:e.type)===KE?e.level:this.getVariantIndex()}},{key:"getVariantIndex",value:function(){var e,t=this.hls,i=t.currentLevel;return null!=(e=t.loadLevelObj)&&e.details||-1===i?t.loadLevel:i}},{key:"variantHasKey",value:function(e,t){if(e){var i;if(null!=(i=e.details)&&i.hasKey(t))return!0;var n=e.audioGroups;if(n)return this.hls.allAudioTracks.filter(e=>n.indexOf(e.groupId)>=0).some(e=>{var i;return null==(i=e.details)?void 0:i.hasKey(t)})}return!1}},{key:"onManifestLoading",value:function(){this.playlistError=0}},{key:"onLevelUpdated",value:function(){this.playlistError=0}},{key:"onError",value:function(e,t){var i;if(!t.fatal){var n=this.hls,a=t.context;switch(t.details){case BE.FRAG_LOAD_ERROR:case BE.FRAG_LOAD_TIMEOUT:case BE.KEY_LOAD_ERROR:case BE.KEY_LOAD_TIMEOUT:return void(t.errorAction=this.getFragRetryOrSwitchAction(t));case BE.FRAG_PARSING_ERROR:if(null!=(i=t.frag)&&i.gap)return void(t.errorAction=fM());case BE.FRAG_GAP:case BE.FRAG_DECRYPT_ERROR:return t.errorAction=this.getFragRetryOrSwitchAction(t),void(t.errorAction.action=oM);case BE.LEVEL_EMPTY_ERROR:case BE.LEVEL_PARSING_ERROR:var r,o=t.parent===KE?t.level:n.loadLevel;return void(t.details===BE.LEVEL_EMPTY_ERROR&&null!=(r=t.context)&&null!=(r=r.levelDetails)&&r.live?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,o):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,o)));case BE.LEVEL_LOAD_ERROR:case BE.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==a?void 0:a.level)&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,a.level)));case BE.AUDIO_TRACK_LOAD_ERROR:case BE.AUDIO_TRACK_LOAD_TIMEOUT:case BE.SUBTITLE_LOAD_ERROR:case BE.SUBTITLE_TRACK_LOAD_TIMEOUT:if(a){var s=n.loadLevelObj;if(s&&(a.type===GE&&s.hasAudioGroup(a.groupId)||a.type===VE&&s.hasSubtitleGroup(a.groupId)))return t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.loadLevel),t.errorAction.action=oM,void(t.errorAction.flags=dM)}return;case BE.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:return void(t.errorAction={action:oM,flags:hM});case BE.KEY_SYSTEM_SESSION_UPDATE_FAILED:case BE.KEY_SYSTEM_STATUS_INTERNAL_ERROR:case BE.KEY_SYSTEM_NO_SESSION:return void(t.errorAction={action:oM,flags:cM});case BE.BUFFER_ADD_CODEC_ERROR:case BE.REMUX_ALLOC_ERROR:case BE.BUFFER_APPEND_ERROR:var u;if(!t.errorAction)t.errorAction=this.getLevelSwitchAction(t,null!=(u=t.level)?u:n.loadLevel);return;case BE.INTERNAL_EXCEPTION:case BE.BUFFER_APPENDING_ERROR:case BE.BUFFER_FULL_ERROR:case BE.LEVEL_SWITCH_ERROR:case BE.BUFFER_STALLED_ERROR:case BE.BUFFER_SEEK_OVER_HOLE:case BE.BUFFER_NUDGE_ON_STALL:return void(t.errorAction=fM())}t.type===jE.KEY_SYSTEM_ERROR&&(t.levelRetry=!1,t.errorAction=fM())}}},{key:"getPlaylistRetryOrSwitchAction",value:function(e,t){var i=eM(this.hls.config.playlistLoadPolicy,e),n=this.playlistError++;if(nM(i,n,JP(e),e.response))return{action:uM,flags:lM,retryConfig:i,retryCount:n};var a=this.getLevelSwitchAction(e,t);return i&&(a.retryConfig=i,a.retryCount=n),a}},{key:"getFragRetryOrSwitchAction",value:function(e){var t=this.hls,i=this.getVariantLevelIndex(e.frag),n=t.levels[i],a=t.config,r=a.fragLoadPolicy,o=a.keyLoadPolicy,s=eM(QP(e)?o:r,e),u=t.levels.reduce((e,t)=>e+t.fragmentError,0);if(n&&(e.details!==BE.FRAG_GAP&&n.fragmentError++,!ZP(e)&&nM(s,u,JP(e),e.response)))return{action:uM,flags:lM,retryConfig:s,retryCount:u};var l=this.getLevelSwitchAction(e,i);return s&&(l.retryConfig=s,l.retryCount=u),l}},{key:"getLevelSwitchAction",value:function(e,t){var i=this.hls;null==t&&(t=i.loadLevel);var n=this.hls.levels[t];if(n){var a,r,o=e.details;n.loadError++,o===BE.BUFFER_APPEND_ERROR&&n.fragmentError++;var s=-1,u=i.levels,l=i.loadLevel,d=i.minAutoLevel,h=i.maxAutoLevel;i.autoLevelEnabled||i.config.preserveManualLevelOnError||(i.loadLevel=-1);for(var c,m,f,v=null==(a=e.frag)?void 0:a.type,p=(v===XE&&o===BE.FRAG_PARSING_ERROR||"audio"===e.sourceBufferName&&(o===BE.BUFFER_ADD_CODEC_ERROR||o===BE.BUFFER_APPEND_ERROR))&&u.some(({audioCodec:e})=>n.audioCodec!==e),g="video"===e.sourceBufferName&&(o===BE.BUFFER_ADD_CODEC_ERROR||o===BE.BUFFER_APPEND_ERROR)&&u.some(({codecSet:e,audioCodec:t})=>n.codecSet!==e&&n.audioCodec===t),y=null!=(r=e.context)?r:{},b=y.type,w=y.groupId,k=function(){var t=(S+l)%u.length;if(t!==l&&t>=d&&t<=h&&0===u[t].loadError){var i=u[t];if(o===BE.FRAG_GAP&&v===KE&&e.frag){var a=u[t].details;if(a){var r=KP(e.frag,a.fragments,e.frag.start);if(null!=r&&r.gap)return 0}}else{if(b===GE&&i.hasAudioGroup(w)||b===VE&&i.hasSubtitleGroup(w))return 0;if(v===XE&&null!=(c=n.audioGroups)&&c.some(e=>i.hasAudioGroup(e))||v===YE&&null!=(m=n.subtitleGroups)&&m.some(e=>i.hasSubtitleGroup(e))||p&&n.audioCodec===i.audioCodec||g&&n.codecSet===i.codecSet||!p&&n.codecSet!==i.codecSet)return 0}return s=t,1}},S=u.length;S--&&(0===(f=k())||1!==f););if(s>-1&&i.loadLevel!==s)return e.levelRetry=!0,this.playlistError=0,{action:oM,flags:lM,nextAutoLevel:s}}return{action:oM,flags:dM}}},{key:"onErrorOut",value:function(e,t){var i;switch(null==(i=t.errorAction)?void 0:i.action){case rM:break;case oM:this.sendAlternateToPenaltyBox(t),t.errorAction.resolved||t.details===BE.FRAG_GAP?/MediaSource readyState: ended/.test(t.error.message)&&(this.warn(`MediaSource ended after "${t.sourceBufferName}" sourceBuffer append error. Attempting to recover from media error.`),this.hls.recoverMediaError()):t.fatal=!0}t.fatal&&this.hls.stopLoad()}},{key:"sendAlternateToPenaltyBox",value:function(e){var t=this.hls,i=e.errorAction;if(i){var n=i.flags,a=i.nextAutoLevel;switch(n){case lM:this.switchLevel(e,a);break;case hM:var r=this.getVariantLevelIndex(e.frag),o=t.levels[r],s=null==o?void 0:o.attrs["HDCP-LEVEL"];if(i.hdcpLevel=s,"NONE"===s)this.warn("HDCP policy resticted output with HDCP-LEVEL=NONE");else if(s){t.maxHdcpLevel=MP[MP.indexOf(s)-1],i.resolved=!0,this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}case cM:var u=e.decryptdata;if(u){for(var l=this.hls.levels,d=l.length,h=d;h--;){var c,m;if(this.variantHasKey(l[h],u))this.log(`Banned key found in level ${h} (${l[h].bitrate}bps) or audio group "${null==(c=l[h].audioGroups)?void 0:c.join(",")}" (${null==(m=e.frag)?void 0:m.type} fragment) ${cT(u.keyId||[])}`),l[h].fragmentError++,l[h].loadError++,this.log(`Removing level ${h} with key error (${e.error})`),this.hls.removeLevel(h)}var f=e.frag;if(this.hls.levels.length<d)i.resolved=!0;else if(f&&f.type!==KE){var v=f.decryptdata;v&&!u.matches(v)&&(i.resolved=!0)}}}i.resolved||this.switchLevel(e,a)}}},{key:"switchLevel",value:function(e,t){if(void 0!==t&&e.errorAction&&(this.warn(`switching to level ${t} after ${e.details}`),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel,e.details===BE.BUFFER_ADD_CODEC_ERROR&&e.mimeType&&"audiovideo"!==e.sourceBufferName))for(var i=bP(e.mimeType),n=this.hls.levels,a=n.length;a--;)n[a][`${e.sourceBufferName}Codec`]===i&&(this.log(`Removing level ${a} for ${e.details} ("${i}" not supported)`),this.hls.removeLevel(a))}}])}();function fM(e){var t={action:rM,flags:lM};return e&&(t.resolved=!0),t}var vM="NOT_LOADED",pM="APPENDING",gM="PARTIAL",yM="OK",bM=function(){return m(function e(t){u(this,e),this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=t,this._registerListeners()},[{key:"_registerListeners",value:function(){var e=this.hls;e&&(e.on(zE.MANIFEST_LOADING,this.onManifestLoading,this),e.on(zE.BUFFER_APPENDED,this.onBufferAppended,this),e.on(zE.FRAG_BUFFERED,this.onFragBuffered,this),e.on(zE.FRAG_LOADED,this.onFragLoaded,this))}},{key:"_unregisterListeners",value:function(){var e=this.hls;e&&(e.off(zE.MANIFEST_LOADING,this.onManifestLoading,this),e.off(zE.BUFFER_APPENDED,this.onBufferAppended,this),e.off(zE.FRAG_BUFFERED,this.onFragBuffered,this),e.off(zE.FRAG_LOADED,this.onFragLoaded,this))}},{key:"destroy",value:function(){this._unregisterListeners(),this.hls=this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}},{key:"getAppendedFrag",value:function(e,t){var i=this.activePartLists[t];if(i)for(var n=i.length;n--;){var a=i[n];if(!a)break;if(a.start<=e&&e<=a.end&&a.loaded)return a}return this.getBufferedFrag(e,t)}},{key:"getBufferedFrag",value:function(e,t){return this.getFragAtPos(e,t,!0)}},{key:"getFragAtPos",value:function(e,t,i){for(var n=this.fragments,a=Object.keys(n),r=a.length;r--;){var o=n[a[r]];if((null==o?void 0:o.body.type)===t&&(!i||o.buffered)){var s=o.body;if(s.start<=e&&e<=s.end)return s}}return null}},{key:"detectEvictedFragments",value:function(e,t,i,n,a){this.timeRanges&&(this.timeRanges[e]=t);var r=(null==n?void 0:n.fragment.sn)||-1;Object.keys(this.fragments).forEach(n=>{var o=this.fragments[n];if(o&&!(r>=o.body.sn))if(o.buffered||o.loaded&&!a){var s=o.range[e];s&&(0!==s.time.length?s.time.some(e=>{var i=!this.isTimeBuffered(e.startPTS,e.endPTS,t);return i&&this.removeFragment(o.body),i}):this.removeFragment(o.body))}else o.body.type===i&&this.removeFragment(o.body)})}},{key:"detectPartialFragments",value:function(e){var t=this.timeRanges;if(t&&"initSegment"!==e.frag.sn){var i=e.frag,n=kM(i),a=this.fragments[n];if(!(!a||a.buffered&&i.gap)){var r=!i.relurl;Object.keys(t).forEach(n=>{var o=i.elementaryStreams[n];if(o){var s=t[n],u=r||!0===o.partial;a.range[n]=this.getBufferedTimes(i,e.part,u,s)}}),a.loaded=null,Object.keys(a.range).length?(this.bufferedEnd(a,i),wM(a)||this.removeParts(i.sn-1,i.type)):this.removeFragment(a.body)}}}},{key:"bufferedEnd",value:function(e,t){e.buffered=!0,(e.body.endList=t.endList||e.body.endList)&&(this.endListFragments[e.body.type]=e)}},{key:"removeParts",value:function(e,t){var i=this.activePartLists[t];i&&(this.activePartLists[t]=SM(i,t=>t.fragment.sn>=e))}},{key:"fragBuffered",value:function(e,t){var i=kM(e),n=this.fragments[i];!n&&t&&(n=this.fragments[i]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),n&&(n.loaded=null,this.bufferedEnd(n,e))}},{key:"getBufferedTimes",value:function(e,t,i,n){for(var a={time:[],partial:i},r=e.start,o=e.end,s=e.minEndPTS||o,u=e.maxStartPTS||r,l=0;l<n.length;l++){var d=n.start(l)-this.bufferPadding,h=n.end(l)+this.bufferPadding;if(u>=d&&s<=h){a.time.push({startPTS:Math.max(r,n.start(l)),endPTS:Math.min(o,n.end(l))});break}if(r<h&&o>d){var c=Math.max(r,n.start(l)),m=Math.min(o,n.end(l));m>c&&(a.partial=!0,a.time.push({startPTS:c,endPTS:m}))}else if(o<=d)break}return a}},{key:"getPartialFragment",value:function(e){var t,i,n,a=null,r=0,o=this.bufferPadding,s=this.fragments;return Object.keys(s).forEach(u=>{var l=s[u];l&&wM(l)&&(i=l.body.start-o,n=l.body.end+o,e>=i&&e<=n&&(t=Math.min(e-i,n-e),r<=t&&(a=l.body,r=t)))}),a}},{key:"isEndListAppended",value:function(e){var t=this.endListFragments[e];return void 0!==t&&(t.buffered||wM(t))}},{key:"getState",value:function(e){var t=kM(e),i=this.fragments[t];return i?i.buffered?wM(i)?gM:yM:pM:vM}},{key:"isTimeBuffered",value:function(e,t,i){for(var n,a,r=0;r<i.length;r++){if(n=i.start(r)-this.bufferPadding,a=i.end(r)+this.bufferPadding,e>=n&&t<=a)return!0;if(t<=n)return!1}return!1}},{key:"onManifestLoading",value:function(){this.removeAllFragments()}},{key:"onFragLoaded",value:function(e,t){if("initSegment"!==t.frag.sn&&!t.frag.bitrateTest){var i=t.frag,n=t.part?null:t,a=kM(i);this.fragments[a]={body:i,appendedPTS:null,loaded:n,buffered:!1,range:Object.create(null)}}}},{key:"onBufferAppended",value:function(e,t){var i=t.frag,n=t.part,a=t.timeRanges,r=t.type;if("initSegment"!==i.sn){var o=i.type;if(n){var s=this.activePartLists[o];s||(this.activePartLists[o]=s=[]),s.push(n)}this.timeRanges=a;var u=a[r];this.detectEvictedFragments(r,u,o,n)}}},{key:"onFragBuffered",value:function(e,t){this.detectPartialFragments(t)}},{key:"hasFragment",value:function(e){var t=kM(e);return!!this.fragments[t]}},{key:"hasFragments",value:function(e){var t=this.fragments,i=Object.keys(t);if(!e)return i.length>0;for(var n=i.length;n--;){var a=t[i[n]];if((null==a?void 0:a.body.type)===e)return!0}return!1}},{key:"hasParts",value:function(e){var t;return!(null==(t=this.activePartLists[e])||!t.length)}},{key:"removeFragmentsInRange",value:function(e,t,i,n,a){n&&!this.hasGaps||Object.keys(this.fragments).forEach(r=>{var o=this.fragments[r];if(o){var s=o.body;s.type!==i||n&&!s.gap||s.start<t&&s.end>e&&(o.buffered||a)&&this.removeFragment(s)}})}},{key:"removeFragment",value:function(e){var t=kM(e);e.clearElementaryStreamInfo();var i=this.activePartLists[e.type];if(i){var n=e.sn;this.activePartLists[e.type]=SM(i,e=>e.fragment.sn!==n)}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}},{key:"removeAllFragments",value:function(){var e;this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1;var t=null==(e=this.hls)||null==(e=e.latestLevelDetails)?void 0:e.partList;t&&t.forEach(e=>e.clearElementaryStreamInfo())}}])}();function wM(e){var t,i,n;return e.buffered&&!!(e.body.gap||null!=(t=e.range.video)&&t.partial||null!=(i=e.range.audio)&&i.partial||null!=(n=e.range.audiovideo)&&n.partial)}function kM(e){return`${e.type}_${e.level}_${e.sn}`}function SM(e,t){return e.filter(e=>{var i=t(e);return i||e.clearElementaryStreamInfo(),i})}var EM=0,TM=1,PM=function(){return m(function e(t,i,n){u(this,e),this.subtle=void 0,this.aesIV=void 0,this.aesMode=void 0,this.subtle=t,this.aesIV=i,this.aesMode=n},[{key:"decrypt",value:function(e,t){switch(this.aesMode){case EM:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e);case TM:return this.subtle.decrypt({name:"AES-CTR",counter:this.aesIV,length:64},t,e);default:throw new Error(`[AESCrypto] invalid aes mode ${this.aesMode}`)}}}])}();var MM=function(){return m(function e(){u(this,e),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()},[{key:"uint8ArrayToUint32Array_",value:function(e){for(var t=new DataView(e),i=new Uint32Array(4),n=0;n<4;n++)i[n]=t.getUint32(4*n);return i}},{key:"initTable",value:function(){var e=this.sBox,t=this.invSBox,i=this.subMix,n=i[0],a=i[1],r=i[2],o=i[3],s=this.invSubMix,u=s[0],l=s[1],d=s[2],h=s[3],c=new Uint32Array(256),m=0,f=0,v=0;for(v=0;v<256;v++)c[v]=v<128?v<<1:v<<1^283;for(v=0;v<256;v++){var p=f^f<<1^f<<2^f<<3^f<<4;p=p>>>8^255&p^99,e[m]=p,t[p]=m;var g=c[m],y=c[g],b=c[y],w=257*c[p]^16843008*p;n[m]=w<<24|w>>>8,a[m]=w<<16|w>>>16,r[m]=w<<8|w>>>24,o[m]=w,w=16843009*b^65537*y^257*g^16843008*m,u[p]=w<<24|w>>>8,l[p]=w<<16|w>>>16,d[p]=w<<8|w>>>24,h[p]=w,m?(m=g^c[c[c[b^g]]],f^=c[c[f]]):m=f=1}}},{key:"expandKey",value:function(e){for(var t=this.uint8ArrayToUint32Array_(e),i=!0,n=0;n<t.length&&i;)i=t[n]===this.key[n],n++;if(!i){this.key=t;var a=this.keySize=t.length;if(4!==a&&6!==a&&8!==a)throw new Error("Invalid aes key size="+a);var r,o,s,u,l=this.ksRows=4*(a+6+1),d=this.keySchedule=new Uint32Array(l),h=this.invKeySchedule=new Uint32Array(l),c=this.sBox,m=this.rcon,f=this.invSubMix,v=f[0],p=f[1],g=f[2],y=f[3];for(r=0;r<l;r++)r<a?s=d[r]=t[r]:(u=s,r%a===0?(u=c[(u=u<<8|u>>>24)>>>24]<<24|c[u>>>16&255]<<16|c[u>>>8&255]<<8|c[255&u],u^=m[r/a|0]<<24):a>6&&r%a===4&&(u=c[u>>>24]<<24|c[u>>>16&255]<<16|c[u>>>8&255]<<8|c[255&u]),d[r]=s=(d[r-a]^u)>>>0);for(o=0;o<l;o++)r=l-o,u=3&o?d[r]:d[r-4],h[o]=o<4||r<=4?u:v[c[u>>>24]]^p[c[u>>>16&255]]^g[c[u>>>8&255]]^y[c[255&u]],h[o]=h[o]>>>0}}},{key:"networkToHostOrderSwap",value:function(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24}},{key:"decrypt",value:function(e,t,i){for(var n,a,r,o,s,u,l,d,h,c,m,f,v,p,g=this.keySize+6,y=this.invKeySchedule,b=this.invSBox,w=this.invSubMix,k=w[0],S=w[1],E=w[2],T=w[3],P=this.uint8ArrayToUint32Array_(i),M=P[0],A=P[1],D=P[2],x=P[3],C=new Int32Array(e),I=new Int32Array(C.length),L=this.networkToHostOrderSwap;t<C.length;){for(h=L(C[t]),c=L(C[t+1]),m=L(C[t+2]),f=L(C[t+3]),s=h^y[0],u=f^y[1],l=m^y[2],d=c^y[3],v=4,p=1;p<g;p++)n=k[s>>>24]^S[u>>16&255]^E[l>>8&255]^T[255&d]^y[v],a=k[u>>>24]^S[l>>16&255]^E[d>>8&255]^T[255&s]^y[v+1],r=k[l>>>24]^S[d>>16&255]^E[s>>8&255]^T[255&u]^y[v+2],o=k[d>>>24]^S[s>>16&255]^E[u>>8&255]^T[255&l]^y[v+3],s=n,u=a,l=r,d=o,v+=4;n=b[s>>>24]<<24^b[u>>16&255]<<16^b[l>>8&255]<<8^b[255&d]^y[v],a=b[u>>>24]<<24^b[l>>16&255]<<16^b[d>>8&255]<<8^b[255&s]^y[v+1],r=b[l>>>24]<<24^b[d>>16&255]<<16^b[s>>8&255]<<8^b[255&u]^y[v+2],o=b[d>>>24]<<24^b[s>>16&255]<<16^b[u>>8&255]<<8^b[255&l]^y[v+3],I[t]=L(n^M),I[t+1]=L(o^A),I[t+2]=L(r^D),I[t+3]=L(a^x),M=h,A=c,D=m,x=f,t+=4}return I.buffer}}])}(),AM=function(){return m(function e(t,i,n){u(this,e),this.subtle=void 0,this.key=void 0,this.aesMode=void 0,this.subtle=t,this.key=i,this.aesMode=n},[{key:"expandKey",value:function(){var e=function(e){switch(e){case EM:return"AES-CBC";case TM:return"AES-CTR";default:throw new Error(`[FastAESKey] invalid aes mode ${e}`)}}(this.aesMode);return this.subtle.importKey("raw",this.key,{name:e},!1,["encrypt","decrypt"])}}])}();var DM=function(){return m(function e(t,{removePKCS7Padding:i=!0}={}){if(u(this,e),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.enableSoftwareAES=void 0,this.enableSoftwareAES=t.enableSoftwareAES,this.removePKCS7Padding=i,i)try{var n=self.crypto;n&&(this.subtle=n.subtle||n.webkitSubtle)}catch(e){}this.useSoftware=!this.subtle},[{key:"destroy",value:function(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}},{key:"isSync",value:function(){return this.useSoftware}},{key:"flush",value:function(){var e=this.currentResult,t=this.remainderData;if(!e||t)return this.reset(),null;var i,n,a,r=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?(n=(i=r).byteLength,(a=n&&new DataView(i.buffer).getUint8(n-1))?i.slice(0,n-a):i):r}},{key:"reset",value:function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}},{key:"decrypt",value:function(e,t,i,n){return this.useSoftware?new Promise((a,r)=>{var o=ArrayBuffer.isView(e)?e:new Uint8Array(e);this.softwareDecrypt(o,t,i,n);var s=this.flush();s?a(s.buffer):r(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,i,n)}},{key:"softwareDecrypt",value:function(e,t,i,n){var a=this.currentIV,r=this.currentResult,o=this.remainderData;if(n!==EM||16!==t.byteLength)return uT.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;this.logOnce("JS AES decrypt"),o&&(e=qT(o,e),this.remainderData=null);var s=this.getValidChunk(e);if(!s.length)return null;a&&(i=a);var u=this.softwareDecrypter;u||(u=this.softwareDecrypter=new MM),u.expandKey(t);var l=r;return this.currentResult=u.decrypt(s.buffer,0,i),this.currentIV=s.slice(-16).buffer,l||null}},{key:"webCryptoDecrypt",value:function(e,t,i,n){if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,t,i,n));this.key=t,this.fastAesKey=new AM(this.subtle,t,n)}return this.fastAesKey.expandKey().then(t=>this.subtle?(this.logOnce("WebCrypto AES decrypt"),new PM(this.subtle,new Uint8Array(i),n).decrypt(e.buffer,t)):Promise.reject(new Error("web crypto not initialized"))).catch(a=>(uT.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${a.name}: ${a.message}`),this.onWebCryptoError(e,t,i,n)))}},{key:"onWebCryptoError",value:function(e,t,i,n){var a=this.enableSoftwareAES;if(a){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,i,n);var r=this.flush();if(r)return r.buffer}throw new Error("WebCrypto"+(a?" and softwareDecrypt":"")+": failed to decrypt data")}},{key:"getValidChunk",value:function(e){var t=e,i=e.length-e.length%16;return i!==e.length&&(t=e.slice(0,i),this.remainderData=e.slice(i)),t}},{key:"logOnce",value:function(e){this.logEnabled&&(uT.log(`[decrypter]: ${e}`),this.logEnabled=!1)}}])}(),xM=Math.pow(2,17),CM=function(){return m(function e(t){u(this,e),this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=t},[{key:"destroy",value:function(){this.loader&&(this.loader.destroy(),this.loader=null)}},{key:"abort",value:function(){this.loader&&this.loader.abort()}},{key:"load",value:function(e,t){var i=e.url;if(!i)return Promise.reject(new _M({type:jE.NETWORK_ERROR,details:BE.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error("Fragment does not have a "+(i?"part list":"url")),networkDetails:null}));this.abort();var n=this.config,a=n.fLoader,r=n.loader;return new Promise((o,s)=>{if(this.loader&&this.loader.destroy(),e.gap){if(e.tagList.some(e=>"GAP"===e[0]))return void s(LM(e));e.gap=!1}var u=this.loader=a?new a(n):new r(n),l=IM(e);e.loader=u;var d=iM(n.fragLoadPolicy.default),h={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===e.sn?1/0:xM};e.stats=u.stats;var c={onSuccess:(t,i,n,a)=>{this.resetLoader(e,u);var r=t.data;n.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(r.slice(0,16)),r=r.slice(16)),o({frag:e,part:null,payload:r,networkDetails:a})},onError:(t,n,a,r)=>{this.resetLoader(e,u),s(new _M({type:jE.NETWORK_ERROR,details:BE.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:tT({url:i,data:void 0},t),error:new Error(`HTTP Error ${t.code} ${t.text}`),networkDetails:a,stats:r}))},onAbort:(t,i,n)=>{this.resetLoader(e,u),s(new _M({type:jE.NETWORK_ERROR,details:BE.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:n,stats:t}))},onTimeout:(t,i,n)=>{this.resetLoader(e,u),s(new _M({type:jE.NETWORK_ERROR,details:BE.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:n,stats:t}))}};t&&(c.onProgress=(i,n,a,r)=>t({frag:e,part:null,payload:a,networkDetails:r})),u.load(l,h,c)})}},{key:"loadPart",value:function(e,t,i){this.abort();var n=this.config,a=n.fLoader,r=n.loader;return new Promise((o,s)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap)s(LM(e,t));else{var u=this.loader=a?new a(n):new r(n),l=IM(e,t);e.loader=u;var d=iM(n.fragLoadPolicy.default),h={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:xM};t.stats=u.stats,u.load(l,h,{onSuccess:(n,a,r,s)=>{this.resetLoader(e,u),this.updateStatsFromPart(e,t);var l={frag:e,part:t,payload:n.data,networkDetails:s};i(l),o(l)},onError:(i,n,a,r)=>{this.resetLoader(e,u),s(new _M({type:jE.NETWORK_ERROR,details:BE.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:tT({url:l.url,data:void 0},i),error:new Error(`HTTP Error ${i.code} ${i.text}`),networkDetails:a,stats:r}))},onAbort:(i,n,a)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,u),s(new _M({type:jE.NETWORK_ERROR,details:BE.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:a,stats:i}))},onTimeout:(i,n,a)=>{this.resetLoader(e,u),s(new _M({type:jE.NETWORK_ERROR,details:BE.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:a,stats:i}))}})}})}},{key:"updateStatsFromPart",value:function(e,t){var i=e.stats,n=t.stats,a=n.total;if(i.loaded+=n.loaded,a){var r=Math.round(e.duration/t.duration),o=Math.min(Math.round(i.loaded/a),r),s=(r-o)*Math.round(i.loaded/o);i.total=i.loaded+s}else i.total=Math.max(i.loaded,i.total);var u=i.loading,l=n.loading;u.start?u.first+=l.first-l.start:(u.start=l.start,u.first=l.first),u.end=l.end}},{key:"resetLoader",value:function(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}}])}();function IM(e,t=null){var i,n=t||e,a={frag:e,part:t,responseType:"arraybuffer",url:n.url,headers:{},rangeStart:0,rangeEnd:0},r=n.byteRangeStartOffset,o=n.byteRangeEndOffset;if(WE(r)&&WE(o)){var s,u=r,l=o;if("initSegment"===e.sn&&("AES-128"===(i=null==(s=e.decryptdata)?void 0:s.method)||"AES-256"===i)){var d=o-r;d%16&&(l=o+(16-d%16)),0!==r&&(a.resetIV=!0,u=r-16)}a.rangeStart=u,a.rangeEnd=l}return a}function LM(e,t){var i=new Error(`GAP ${e.gap?"tag":"attribute"} found`),n={type:jE.MEDIA_ERROR,details:BE.FRAG_GAP,fatal:!1,frag:e,error:i,networkDetails:null};return t&&(n.part=t),(t||e).stats.aborted=!0,new _M(n)}var _M=function(){function e(t){var i;return u(this,e),(i=s(this,e,[t.error.message])).data=void 0,i.data=t,i}return y(e,D(Error)),m(e)}(),RM=function(){function e(t,i){var n;return u(this,e),(n=s(this,e,[t,i]))._boundTick=void 0,n._tickTimer=null,n._tickInterval=null,n._tickCallCount=0,n._boundTick=n.tick.bind(n),n}return y(e,iT),m(e,[{key:"destroy",value:function(){this.onHandlerDestroying(),this.onHandlerDestroyed()}},{key:"onHandlerDestroying",value:function(){this.clearNextTick(),this.clearInterval()}},{key:"onHandlerDestroyed",value:function(){}},{key:"hasInterval",value:function(){return!!this._tickInterval}},{key:"hasNextTick",value:function(){return!!this._tickTimer}},{key:"setInterval",value:function(e){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)}},{key:"clearInterval",value:function(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)}},{key:"clearNextTick",value:function(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)}},{key:"tick",value:function(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}},{key:"tickImmediate",value:function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}},{key:"doTick",value:function(){}}])}(),FM=m(function e(t,i,n,a=0,r=-1,o=!1){u(this,e),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={start:0,executeStart:0,executeEnd:0,end:0},this.buffering={audio:{start:0,executeStart:0,executeEnd:0,end:0},video:{start:0,executeStart:0,executeEnd:0,end:0},audiovideo:{start:0,executeStart:0,executeEnd:0,end:0}},this.level=t,this.sn=i,this.id=n,this.size=a,this.part=r,this.partial=o});var OM={length:0,start:()=>0,end:()=>0},WM=function(){function e(){u(this,e)}return m(e,null,[{key:"isBuffered",value:function(t,i){if(t)for(var n=e.getBuffered(t),a=n.length;a--;)if(i>=n.start(a)&&i<=n.end(a))return!0;return!1}},{key:"bufferedRanges",value:function(t){if(t){var i=e.getBuffered(t);return e.timeRangesToArray(i)}return[]}},{key:"timeRangesToArray",value:function(e){for(var t=[],i=0;i<e.length;i++)t.push({start:e.start(i),end:e.end(i)});return t}},{key:"bufferInfo",value:function(t,i,n){if(t){var a=e.bufferedRanges(t);if(a.length)return e.bufferedInfo(a,i,n)}return{len:0,start:i,end:i,bufferedIndex:-1}}},{key:"bufferedInfo",value:function(e,t,i){t=Math.max(0,t),e.length>1&&e.sort((e,t)=>e.start-t.start||t.end-e.end);var n=-1,a=[];if(i)for(var r=0;r<e.length;r++){t>=e[r].start&&t<=e[r].end&&(n=r);var o=a.length;if(o){var s=a[o-1].end;e[r].start-s<i?e[r].end>s&&(a[o-1].end=e[r].end):a.push(e[r])}else a.push(e[r])}else a=e;for(var u,l=0,d=t,h=t,c=0;c<a.length;c++){var m=a[c].start,f=a[c].end;if(-1===n&&t>=m&&t<=f&&(n=c),t+i>=m&&t<f)d=m,l=(h=f)-t;else if(t+i<m){u=m;break}}return{len:l,start:d||0,end:h||0,nextStart:u,buffered:e,bufferedIndex:n}}},{key:"getBuffered",value:function(e){try{return e.buffered||OM}catch(e){return uT.log("failed to get media.buffered",e),OM}}}])}(),$M=/\{\$([a-zA-Z0-9-_]+)\}/g;function NM(e){return $M.test(e)}function jM(e,t){if(null!==e.variableList||e.hasVariableRefs){var i=e.variableList;return t.replace($M,t=>{var n=t.substring(2,t.length-1),a=null==i?void 0:i[n];return void 0===a?(e.playlistParsingError||(e.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${n}"`)),t):a})}return t}function BM(e,t,i){var n,a,r=e.variableList;if(r||(e.variableList=r={}),"QUERYPARAM"in t){n=t.QUERYPARAM;try{var o=new self.URL(i).searchParams;if(!o.has(n))throw new Error(`"${n}" does not match any query parameter in URI: "${i}"`);a=o.get(n)}catch(t){e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${t.message}`))}}else n=t.NAME,a=t.VALUE;n in r?e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${n}"`)):r[n]=a||""}function zM(e,t,i){var n=t.IMPORT;if(i&&n in i){var a=e.variableList;a||(e.variableList=a={}),a[n]=i[n]}else e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${n}"`))}var UM=/^(\d+)x(\d+)$/,HM=/(.+?)=(".*?"|.*?)(?:,|$)/g,GM=function(){return m(function e(t,i){u(this,e),"string"==typeof t&&(t=e.parseAttrList(t,i)),ZE(this,t)},[{key:"clientAttrs",get:function(){return Object.keys(this).filter(e=>"X-"===e.substring(0,2))}},{key:"decimalInteger",value:function(e){var t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t}},{key:"hexadecimalInteger",value:function(e){if(this[e]){var t=(this[e]||"0x").slice(2);t=(1&t.length?"0":"")+t;for(var i=new Uint8Array(t.length/2),n=0;n<t.length/2;n++)i[n]=parseInt(t.slice(2*n,2*n+2),16);return i}return null}},{key:"hexadecimalIntegerAsNumber",value:function(e){var t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t}},{key:"decimalFloatingPoint",value:function(e){return parseFloat(this[e])}},{key:"optionalFloat",value:function(e,t){var i=this[e];return i?parseFloat(i):t}},{key:"enumeratedString",value:function(e){return this[e]}},{key:"enumeratedStringList",value:function(e,t){var i=this[e];return(i?i.split(/[ ,]+/):[]).reduce((e,t)=>(e[t.toLowerCase()]=!0,e),t)}},{key:"bool",value:function(e){return"YES"===this[e]}},{key:"decimalResolution",value:function(e){var t=UM.exec(this[e]);if(null!==t)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}}],[{key:"parseAttrList",value:function(e,t){var i,n={};for(HM.lastIndex=0;null!==(i=HM.exec(e));){var a=i[1].trim(),r=i[2],o=0===r.indexOf('"')&&r.lastIndexOf('"')===r.length-1,s=!1;if(o)r=r.slice(1,-1);else switch(a){case"IV":case"SCTE35-CMD":case"SCTE35-IN":case"SCTE35-OUT":s=!0}if(t&&(o||s))r=jM(t,r);else if(!s&&!o)switch(a){case"CLOSED-CAPTIONS":if("NONE"===r)break;case"ALLOWED-CPC":case"CLASS":case"ASSOC-LANGUAGE":case"AUDIO":case"BYTERANGE":case"CHANNELS":case"CHARACTERISTICS":case"CODECS":case"DATA-ID":case"END-DATE":case"GROUP-ID":case"ID":case"IMPORT":case"INSTREAM-ID":case"KEYFORMAT":case"KEYFORMATVERSIONS":case"LANGUAGE":case"NAME":case"PATHWAY-ID":case"QUERYPARAM":case"RECENTLY-REMOVED-DATERANGES":case"SERVER-URI":case"STABLE-RENDITION-ID":case"STABLE-VARIANT-ID":case"START-DATE":case"SUBTITLES":case"SUPPLEMENTAL-CODECS":case"URI":case"VALUE":case"VIDEO":case"X-ASSET-LIST":case"X-ASSET-URI":uT.warn(`${e}: attribute ${a} is missing quotes`)}n[a]=r}return n}}])}();function VM(e){return"ID"!==e&&"CLASS"!==e&&"CUE"!==e&&"START-DATE"!==e&&"DURATION"!==e&&"END-DATE"!==e&&"END-ON-NEXT"!==e}function KM(e){return"SCTE35-OUT"===e||"SCTE35-IN"===e||"SCTE35-CMD"===e}var XM=function(){return m(function e(t,i,n=0){var a;if(u(this,e),this.attr=void 0,this.tagAnchor=void 0,this.tagOrder=void 0,this._startDate=void 0,this._endDate=void 0,this._dateAtEnd=void 0,this._cue=void 0,this._badValueForSameId=void 0,this.tagAnchor=(null==i?void 0:i.tagAnchor)||null,this.tagOrder=null!=(a=null==i?void 0:i.tagOrder)?a:n,i){var r=i.attr;for(var o in r)if(Object.prototype.hasOwnProperty.call(t,o)&&t[o]!==r[o]){uT.warn(`DATERANGE tag attribute: "${o}" does not match for tags with ID: "${t.ID}"`),this._badValueForSameId=o;break}t=ZE(new GM({}),r,t)}if(this.attr=t,i?(this._startDate=i._startDate,this._cue=i._cue,this._endDate=i._endDate,this._dateAtEnd=i._dateAtEnd):this._startDate=new Date(t["START-DATE"]),"END-DATE"in this.attr){var s=(null==i?void 0:i.endDate)||new Date(this.attr["END-DATE"]);WE(s.getTime())&&(this._endDate=s)}},[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"cue",get:function(){var e=this._cue;return void 0===e?this._cue=this.attr.enumeratedStringList(this.attr.CUE?"CUE":"X-CUE",{pre:!1,post:!1,once:!1}):e}},{key:"startTime",get:function(){var e=this.tagAnchor;return null===e||null===e.programDateTime?(uT.warn(`Expected tagAnchor Fragment with PDT set for DateRange "${this.id}": ${e}`),NaN):e.start+(this.startDate.getTime()-e.programDateTime)/1e3}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){var e=this._endDate||this._dateAtEnd;if(e)return e;var t=this.duration;return null!==t?this._dateAtEnd=new Date(this._startDate.getTime()+1e3*t):null}},{key:"duration",get:function(){if("DURATION"in this.attr){var e=this.attr.decimalFloatingPoint("DURATION");if(WE(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}},{key:"endOnNext",get:function(){return this.attr.bool("END-ON-NEXT")}},{key:"isInterstitial",get:function(){return"com.apple.hls.interstitial"===this.class}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&WE(this.startDate.getTime())&&(null===this.duration||this.duration>=0)&&(!this.endOnNext||!!this.class)&&(!this.attr.CUE||!this.cue.pre&&!this.cue.post||this.cue.pre!==this.cue.post)&&(!this.isInterstitial||"X-ASSET-URI"in this.attr||"X-ASSET-LIST"in this.attr)}}])}(),YM=function(){return m(function e(t){u(this,e),this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.dateRangeTagCount=0,this.live=!0,this.requestScheduled=-1,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!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.appliedTimelineOffset=void 0,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=t},[{key:"reloaded",value:function(e){if(!e)return this.advanced=!0,void(this.updated=!0);var t=this.lastPartSn-e.lastPartSn,i=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!i||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||0===t&&i>0,this.updated||this.advanced?this.misses=Math.floor(.6*e.misses):this.misses=e.misses+1}},{key:"hasKey",value:function(e){return this.encryptedFragments.some(t=>{var i=t.decryptdata;return i||(t.setKeyFormat(e.keyFormat),i=t.decryptdata),!!i&&e.matches(i)})}},{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&WE(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||10}},{key:"drift",get:function(){var e=this.driftEndTime-this.driftStartTime;return e>0?1e3*(this.driftEnd-this.driftStart)/e:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){return this.fragments.length?this.fragments[this.fragments.length-1].end:0}},{key:"fragmentStart",get:function(){return this.fragments.length?this.fragments[0].start:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].index:-1}},{key:"maxPartIndex",get:function(){var e=this.partList;if(e){var t=this.lastPartIndex;if(-1!==t){for(var i=e.length;i--;)if(e[i].index>t)return e[i].index;return t}}return 0}},{key:"lastPartSn",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}},{key:"expired",get:function(){if(this.live&&this.age&&this.misses<3){var e=this.partEnd-this.fragmentStart;return this.age>Math.max(e,this.totalduration)+this.levelTargetDuration}return!1}}])}();function qM(e,t){return e.length===t.length&&!e.some((e,i)=>e!==t[i])}function JM(e,t){return!e&&!t||!(!e||!t)&&qM(e,t)}function QM(e){return"AES-128"===e||"AES-256"===e||"AES-256-CTR"===e}function ZM(e){switch(e){case"AES-128":case"AES-256":return EM;case"AES-256-CTR":return TM;default:throw new Error(`invalid full segment method ${e}`)}}function eA(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0))}function tA(e){return Uint8Array.from(unescape(encodeURIComponent(e)),e=>e.charCodeAt(0))}function iA(e){var t=function(e,t,i){var n=e[t];e[t]=e[i],e[i]=n};t(e,0,3),t(e,1,2),t(e,4,5),t(e,6,7)}function nA(e){var t,i,n=e.split(":"),a=null;if("data"===n[0]&&2===n.length){var r=n[1].split(";"),o=r[r.length-1].split(",");if(2===o.length){var s="base64"===o[0],u=o[1];s?(r.splice(-1,1),a=eA(u)):(t=tA(u).subarray(0,16),(i=new Uint8Array(16)).set(t,16-t.length),a=i)}}return a}var aA="undefined"!=typeof self?self:void 0,rA={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},oA="org.w3.clearkey",sA="com.apple.streamingkeydelivery",uA="com.microsoft.playready",lA="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function dA(e){switch(e){case sA:return rA.FAIRPLAY;case uA:return rA.PLAYREADY;case lA:return rA.WIDEVINE;case oA:return rA.CLEARKEY}}function hA(e){switch(e){case rA.FAIRPLAY:return sA;case rA.PLAYREADY:return uA;case rA.WIDEVINE:return lA;case rA.CLEARKEY:return oA}}function cA(e){var t=e.drmSystems,i=e.widevineLicenseUrl,n=t?[rA.FAIRPLAY,rA.WIDEVINE,rA.PLAYREADY,rA.CLEARKEY].filter(e=>!!t[e]):[];return!n[rA.WIDEVINE]&&i&&n.push(rA.WIDEVINE),n}var mA,fA=null!=aA&&null!=(mA=aA.navigator)&&mA.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;function vA(e){var t=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2),i=String.fromCharCode.apply(null,Array.from(t)),n=i.substring(i.indexOf("<"),i.length),a=(new DOMParser).parseFromString(n,"text/xml").getElementsByTagName("KID")[0];if(a){var r=a.childNodes[0]?a.childNodes[0].nodeValue:a.getAttribute("VALUE");if(r){var o=eA(r).subarray(0,16);return iA(o),o}}return null}var pA={},gA=function(){function e(t,i,n,a=[1],r=null,o){u(this,e),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=i,this.keyFormat=n,this.keyFormatVersions=a,this.iv=r,this.encrypted=!!t&&"NONE"!==t,this.isCommonEncryption=this.encrypted&&!QM(t),null!=o&&o.startsWith("0x")&&(this.keyId=new Uint8Array(mT(o)))}return m(e,[{key:"matches",value:function(e){return e.uri===this.uri&&e.method===this.method&&e.encrypted===this.encrypted&&e.keyFormat===this.keyFormat&&qM(e.keyFormatVersions,this.keyFormatVersions)&&JM(e.iv,this.iv)&&JM(e.keyId,this.keyId)}},{key:"isSupported",value:function(){if(this.method){if(QM(this.method)||"NONE"===this.method)return!0;if("identity"===this.keyFormat)return"SAMPLE-AES"===this.method;switch(this.keyFormat){case sA:case lA:case uA:case oA:return-1!==["SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)}}return!1}},{key:"getDecryptData",value:function(t,i){if(!this.encrypted||!this.uri)return null;if(QM(this.method)){var n=this.iv;return n||("number"!=typeof t&&(uT.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),t=0),n=function(e){for(var t=new Uint8Array(16),i=12;i<16;i++)t[i]=e>>8*(15-i)&255;return t}(t)),new e(this.method,this.uri,"identity",this.keyFormatVersions,n)}if(this.keyId){var a=pA[this.uri];if(a&&!qM(this.keyId,a)&&e.setKeyIdForUri(this.uri,this.keyId),this.pssh)return this}var r,o=nA(this.uri);if(o)switch(this.keyFormat){case lA:if(this.pssh=o,!this.keyId){var s=function(e){var t=[];if(e instanceof ArrayBuffer)for(var i=e.byteLength,n=0;n+32<i;){var a=nP(new DataView(e,n));t.push(a),n+=a.size}return t}(o.buffer);if(s.length){var u,l=s[0];this.keyId=null!=(u=l.kids)&&u.length?l.kids[0]:null}}this.keyId||(this.keyId=yA(i));break;case uA:var d=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=iP(d,0,o),this.keyId=vA(o);break;default:var h=o.subarray(0,16);if(16!==h.length){var c=new Uint8Array(16);c.set(h,16-h.length),h=c}this.keyId=h}this.keyId&&16===this.keyId.byteLength||(r=function(e){var t=null==e?void 0:e[lA];if(t)return t.keyId;return null}(i),r||(r=yA(i))||(r=pA[this.uri]),r&&(this.keyId=r,e.setKeyIdForUri(this.uri,r)));return this}}],[{key:"clearKeyUriToKeyIdMap",value:function(){pA={}}},{key:"setKeyIdForUri",value:function(e,t){pA[e]=t}},{key:"addKeyIdForUri",value:function(e){var t=Object.keys(pA).length%Number.MAX_SAFE_INTEGER,i=new Uint8Array(16);return new DataView(i.buffer,12,4).setUint32(0,t),pA[e]=i,i}}])}();function yA(e){var t=null==e?void 0:e[uA];if(t){var i=nA(t.uri);if(i)return vA(i)}return null}var bA=/#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,wA=/#EXT-X-MEDIA:(.*)/g,kA=/^#EXT(?:INF|-X-TARGETDURATION):/m,SA=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#.*/.source].join("|"),"g"),EA=new RegExp([/#EXT-X-(PROGRAM-DATE-TIME|BYTERANGE|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|INDEPENDENT-SEGMENTS)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),TA=function(){function e(){u(this,e)}return m(e,null,[{key:"findGroup",value:function(e,t){for(var i=0;i<e.length;i++){var n=e[i];if(n.id===t)return n}}},{key:"resolve",value:function(e,t){return ST.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}},{key:"isMediaPlaylist",value:function(e){return kA.test(e)}},{key:"parseMasterPlaylist",value:function(t,i){var n,a={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:NM(t)},r=[];if(bA.lastIndex=0,!t.startsWith("#EXTM3U"))return a.playlistParsingError=new Error("no EXTM3U delimiter"),a;for(;null!=(n=bA.exec(t));)if(n[1]){var o,s=new GM(n[1],a),u=jM(a,n[2]),l={attrs:s,bitrate:s.decimalInteger("BANDWIDTH")||s.decimalInteger("AVERAGE-BANDWIDTH"),name:s.NAME,url:e.resolve(u,i)},d=s.decimalResolution("RESOLUTION");d&&(l.width=d.width,l.height=d.height),xA(s.CODECS,l);var h=s["SUPPLEMENTAL-CODECS"];h&&(l.supplemental={},xA(h,l.supplemental)),null!=(o=l.unknownCodecs)&&o.length||r.push(l),a.levels.push(l)}else if(n[3]){var c=n[3],m=n[4];switch(c){case"SESSION-DATA":var f=new GM(m,a),v=f["DATA-ID"];v&&(null===a.sessionData&&(a.sessionData={}),a.sessionData[v]=f);break;case"SESSION-KEY":var p=AA(m,i,a);p.encrypted&&p.isSupported()?(null===a.sessionKeys&&(a.sessionKeys=[]),a.sessionKeys.push(p)):uT.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${m}"`);break;case"DEFINE":BM(a,new GM(m,a),i);break;case"CONTENT-STEERING":var g=new GM(m,a);a.contentSteering={uri:e.resolve(g["SERVER-URI"],i),pathwayId:g["PATHWAY-ID"]||"."};break;case"START":a.startTimeOffset=DA(m)}}var y=r.length>0&&r.length<a.levels.length;return a.levels=y?r:a.levels,0===a.levels.length&&(a.playlistParsingError=new Error("no levels found in manifest")),a}},{key:"parseMasterPlaylistMedia",value:function(t,i,n){var a,r={},o=n.levels,s={AUDIO:o.map(e=>({id:e.attrs.AUDIO,audioCodec:e.audioCodec})),SUBTITLES:o.map(e=>({id:e.attrs.SUBTITLES,textCodec:e.textCodec})),"CLOSED-CAPTIONS":[]},u=0;for(wA.lastIndex=0;null!==(a=wA.exec(t));){var l=new GM(a[1],n),d=l.TYPE;if(d){var h=s[d],c=r[d]||[];r[d]=c;var m=l.LANGUAGE,f=l["ASSOC-LANGUAGE"],v=l.CHANNELS,p=l.CHARACTERISTICS,g=l["INSTREAM-ID"],y={attrs:l,bitrate:0,id:u++,groupId:l["GROUP-ID"]||"",name:l.NAME||m||"",type:d,default:l.bool("DEFAULT"),autoselect:l.bool("AUTOSELECT"),forced:l.bool("FORCED"),lang:m,url:l.URI?e.resolve(l.URI,i):""};if(f&&(y.assocLang=f),v&&(y.channels=v),p&&(y.characteristics=p),g&&(y.instreamId=g),null!=h&&h.length){var b=e.findGroup(h,y.groupId)||h[0];CA(y,b,"audioCodec"),CA(y,b,"textCodec")}c.push(y)}}return r}},{key:"parseLevelPlaylist",value:function(e,t,i,n,a,r){var o,s,u,l,d,h={url:t},c=new YM(t),m=c.fragments,f=[],v=null,p=0,g=0,y=0,b=0,w=0,k=null,S=new xT(n,h),E=-1,T=!1,P=null;if(SA.lastIndex=0,c.m3u8=e,c.hasVariableRefs=NM(e),"#EXTM3U"!==(null==(o=SA.exec(e))?void 0:o[0]))return c.playlistParsingError=new Error("Missing format identifier #EXTM3U"),c;for(;null!==(s=SA.exec(e));){T&&(T=!1,(S=new xT(n,h)).playlistOffset=y,S.setStart(y),S.sn=p,S.cc=b,w&&(S.bitrate=w),S.level=i,v&&(S.initSegment=v,v.rawProgramDateTime&&(S.rawProgramDateTime=v.rawProgramDateTime,v.rawProgramDateTime=null),P&&(S.setByteRange(P),P=null)));var M=s[1];if(M){S.duration=parseFloat(M);var A=(" "+s[2]).slice(1);S.title=A||null,S.tagList.push(A?["INF",M,A]:["INF",M])}else if(s[3]){if(WE(S.duration)){S.playlistOffset=y,S.setStart(y),l&&_A(S,l,c),S.sn=p,S.level=i,S.cc=b,m.push(S);var D=(" "+s[3]).slice(1);S.relurl=jM(c,D),IA(S,k,f),k=S,y+=S.duration,p++,g=0,T=!0}}else{if(!(s=s[0].match(EA))){uT.warn("No matches on slow regex match for level playlist!");continue}for(u=1;u<s.length&&void 0===s[u];u++);var x=(" "+s[u]).slice(1),C=(" "+s[u+1]).slice(1),I=s[u+2]?(" "+s[u+2]).slice(1):null;switch(x){case"BYTERANGE":k?S.setByteRange(C,k):S.setByteRange(C);break;case"PROGRAM-DATE-TIME":S.rawProgramDateTime=C,S.tagList.push(["PROGRAM-DATE-TIME",C]),-1===E&&(E=m.length);break;case"PLAYLIST-TYPE":c.type&&RA(c,x,s),c.type=C.toUpperCase();break;case"MEDIA-SEQUENCE":0!==c.startSN?RA(c,x,s):m.length>0&&FA(c,x,s),p=c.startSN=parseInt(C);break;case"SKIP":c.skippedSegments&&RA(c,x,s);var L=new GM(C,c),_=L.decimalInteger("SKIPPED-SEGMENTS");if(WE(_)){c.skippedSegments+=_;for(var R=_;R--;)m.push(null);p+=_}var F=L.enumeratedString("RECENTLY-REMOVED-DATERANGES");F&&(c.recentlyRemovedDateranges=(c.recentlyRemovedDateranges||[]).concat(F.split("\t")));break;case"TARGETDURATION":0!==c.targetduration&&RA(c,x,s),c.targetduration=Math.max(parseInt(C),1);break;case"VERSION":null!==c.version&&RA(c,x,s),c.version=parseInt(C);break;case"INDEPENDENT-SEGMENTS":break;case"ENDLIST":c.live||RA(c,x,s),c.live=!1;break;case"#":(C||I)&&S.tagList.push(I?[C,I]:[C]);break;case"DISCONTINUITY":b++,S.tagList.push(["DIS"]);break;case"GAP":S.gap=!0,S.tagList.push([x]);break;case"BITRATE":S.tagList.push([x,C]),w=1e3*parseInt(C),WE(w)?S.bitrate=w:w=0;break;case"DATERANGE":var O=new GM(C,c),W=new XM(O,c.dateRanges[O.ID],c.dateRangeTagCount);c.dateRangeTagCount++,W.isValid||c.skippedSegments?c.dateRanges[W.id]=W:uT.warn(`Ignoring invalid DATERANGE tag: "${C}"`),S.tagList.push(["EXT-X-DATERANGE",C]);break;case"DEFINE":var $=new GM(C,c);"IMPORT"in $?zM(c,$,r):BM(c,$,t);break;case"DISCONTINUITY-SEQUENCE":0!==c.startCC?RA(c,x,s):m.length>0&&FA(c,x,s),c.startCC=b=parseInt(C);break;case"KEY":var N=AA(C,t,c);if(N.isSupported()){if("NONE"===N.method){l=void 0;break}l||(l={});var j=l[N.keyFormat];null!=j&&j.matches(N)||(j&&(l=ZE({},l)),l[N.keyFormat]=N)}else uT.warn(`[Keys] Ignoring unsupported EXT-X-KEY tag: "${C}"`);break;case"START":c.startTimeOffset=DA(C);break;case"MAP":var B=new GM(C,c);if(S.duration){var z=new xT(n,h);LA(z,B,i,l),v=z,S.initSegment=v,v.rawProgramDateTime&&!S.rawProgramDateTime&&(S.rawProgramDateTime=v.rawProgramDateTime)}else{var U=S.byteRangeEndOffset;if(U){var H=S.byteRangeStartOffset;P=`${U-H}@${H}`}else P=null;LA(S,B,i,l),v=S,T=!0}v.cc=b;break;case"SERVER-CONTROL":d&&RA(c,x,s),d=new GM(C),c.canBlockReload=d.bool("CAN-BLOCK-RELOAD"),c.canSkipUntil=d.optionalFloat("CAN-SKIP-UNTIL",0),c.canSkipDateRanges=c.canSkipUntil>0&&d.bool("CAN-SKIP-DATERANGES"),c.partHoldBack=d.optionalFloat("PART-HOLD-BACK",0),c.holdBack=d.optionalFloat("HOLD-BACK",0);break;case"PART-INF":c.partTarget&&RA(c,x,s);var G=new GM(C);c.partTarget=G.decimalFloatingPoint("PART-TARGET");break;case"PART":var V=c.partList;V||(V=c.partList=[]);var K=g>0?V[V.length-1]:void 0,X=g++,Y=new GM(C,c),q=new CT(Y,S,h,X,K);V.push(q),S.duration+=q.duration;break;case"PRELOAD-HINT":var J=new GM(C,c);c.preloadHint=J;break;case"RENDITION-REPORT":var Q=new GM(C,c);c.renditionReports=c.renditionReports||[],c.renditionReports.push(Q);break;default:uT.warn(`line parsed but not handled: ${s}`)}}}k&&!k.relurl?(m.pop(),y-=k.duration,c.partList&&(c.fragmentHint=k)):c.partList&&(IA(S,k,f),S.cc=b,c.fragmentHint=S,l&&_A(S,l,c)),c.targetduration||(c.playlistParsingError=new Error("Missing Target Duration"));var Z=m.length,ee=m[0],te=m[Z-1];if((y+=c.skippedSegments*c.targetduration)>0&&Z&&te){c.averagetargetduration=y/Z;var ie=te.sn;c.endSN="initSegment"!==ie?ie:0,c.live||(te.endList=!0),E>0&&(!function(e,t){for(var i=e[t],n=t;n--;){var a=e[n];if(!a)return;a.programDateTime=i.programDateTime-1e3*a.duration,i=a}}(m,E),ee&&f.unshift(ee))}return c.fragmentHint&&(y+=c.fragmentHint.duration),c.totalduration=y,f.length&&c.dateRangeTagCount&&ee&&PA(f,c),c.endCC=b,c}}])}();function PA(e,t){var i=e.length;if(!i){if(!t.hasProgramDateTime)return;var n=t.fragments[t.fragments.length-1];e.push(n),i++}for(var a=e[i-1],r=t.live?1/0:t.totalduration,o=Object.keys(t.dateRanges),s=o.length;s--;){var u=t.dateRanges[o[s]],l=u.startDate.getTime();u.tagAnchor=a.ref;for(var d=i;d--;){var h;if((null==(h=e[d])?void 0:h.sn)<t.startSN)break;var c=MA(t,l,e,d,r);if(-1!==c){u.tagAnchor=t.fragments[c].ref;break}}}}function MA(e,t,i,n,a){var r=i[n];if(r){var o,s=r.programDateTime;if(t>=s||0===n)if(t<=s+1e3*(((null==(o=i[n+1])?void 0:o.start)||a)-r.start)){var u=i[n].sn-e.startSN;if(u<0)return-1;var l=e.fragments;if(l.length>i.length)for(var d=(i[n+1]||l[l.length-1]).sn-e.startSN;d>u;d--){var h=l[d].programDateTime;if(t>=h&&t<h+1e3*l[d].duration)return d}return u}}return-1}function AA(e,t,i){var n,a,r=new GM(e,i),o=null!=(n=r.METHOD)?n:"",s=r.URI,u=r.hexadecimalInteger("IV"),l=r.KEYFORMATVERSIONS,d=null!=(a=r.KEYFORMAT)?a:"identity";s&&r.IV&&!u&&uT.error(`Invalid IV: ${r.IV}`);var h=s?TA.resolve(s,t):"",c=(l||"1").split("/").map(Number).filter(Number.isFinite);return new gA(o,h,d,c,u,r.KEYID)}function DA(e){var t=new GM(e).decimalFloatingPoint("TIME-OFFSET");return WE(t)?t:null}function xA(e,t){var i=(e||"").split(/[ ,]+/).filter(e=>e);["video","audio","text"].forEach(e=>{var n=i.filter(t=>oP(t,e));n.length&&(t[`${e}Codec`]=n.map(e=>e.split("/")[0]).join(","),i=i.filter(e=>-1===n.indexOf(e)))}),t.unknownCodecs=i}function CA(e,t,i){var n=t[i];n&&(e[i]=n)}function IA(e,t,i){e.rawProgramDateTime?i.push(e):null!=t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime)}function LA(e,t,i,n){e.relurl=t.URI,t.BYTERANGE&&e.setByteRange(t.BYTERANGE),e.level=i,e.sn="initSegment",n&&(e.levelkeys=n),e.initSegment=null}function _A(e,t,i){e.levelkeys=t;var n=i.encryptedFragments;n.length&&n[n.length-1].levelkeys===t||!Object.keys(t).some(e=>t[e].isCommonEncryption)||n.push(e)}function RA(e,t,i){e.playlistParsingError=new Error(`#EXT-X-${t} must not appear more than once (${i[0]})`)}function FA(e,t,i){e.playlistParsingError=new Error(`#EXT-X-${t} must appear before the first Media Segment (${i[0]})`)}function OA(e,t){var i=t.startPTS;if(WE(i)){var n,a=0;t.sn>e.sn?(a=i-e.start,n=e):(a=e.start-i,n=t),n.duration!==a&&n.setDuration(a)}else if(t.sn>e.sn){e.cc===t.cc&&e.minEndPTS?t.setStart(e.start+(e.minEndPTS-e.start)):t.setStart(e.start+e.duration)}else t.setStart(Math.max(e.start-t.duration,0))}function WA(e,t,i,n,a,r,o){n-i<=0&&(o.warn("Fragment should have a positive duration",t),n=i+t.duration,r=a+t.duration);var s=i,u=n,l=t.startPTS,d=t.endPTS;if(WE(l)){var h=Math.abs(l-i);e&&h>e.totalduration?o.warn(`media timestamps and playlist times differ by ${h}s for level ${t.level} ${e.url}`):WE(t.deltaPTS)?t.deltaPTS=Math.max(h,t.deltaPTS):t.deltaPTS=h,s=Math.max(i,l),i=Math.min(i,l),a=void 0!==t.startDTS?Math.min(a,t.startDTS):a,u=Math.min(n,d),n=Math.max(n,d),r=void 0!==t.endDTS?Math.max(r,t.endDTS):r}var c=i-t.start;0!==t.start&&t.setStart(i),t.setDuration(n-t.start),t.startPTS=i,t.maxStartPTS=s,t.startDTS=a,t.endPTS=n,t.minEndPTS=u,t.endDTS=r;var m,f=t.sn;if(!e||f<e.startSN||f>e.endSN)return 0;var v=f-e.startSN,p=e.fragments;for(p[v]=t,m=v;m>0;m--)OA(p[m],p[m-1]);for(m=v;m<p.length-1;m++)OA(p[m],p[m+1]);return e.fragmentHint&&OA(p[p.length-1],e.fragmentHint),e.PTSKnown=e.alignedSliding=!0,c}function $A(e,t,i){if(e!==t){for(var n,a=null,r=e.fragments,o=r.length-1;o>=0;o--){var s=r[o].initSegment;if(s){a=s;break}}e.fragmentHint&&delete e.fragmentHint.endPTS,function(e,t,i){for(var n=t.skippedSegments,a=Math.max(e.startSN,t.startSN)-t.startSN,r=(e.fragmentHint?1:0)+(n?t.endSN:Math.min(e.endSN,t.endSN))-t.startSN,o=t.startSN-e.startSN,s=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,u=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,l=a;l<=r;l++){var d=u[o+l],h=s[l];if(n&&!h&&d&&(h=t.fragments[l]=d),d&&h){i(d,h,l,s);var c=d.relurl,m=h.relurl;if(c&&KA(c,m))return void(t.playlistParsingError=NA(`media sequence mismatch ${h.sn}:`,e,t,d,h));if(d.cc!==h.cc)return void(t.playlistParsingError=NA(`discontinuity sequence mismatch (${d.cc}!=${h.cc})`,e,t,d,h))}}}(e,t,(e,i,r,o)=>{if((!t.startCC||t.skippedSegments)&&i.cc!==e.cc){for(var s=e.cc-i.cc,u=r;u<o.length;u++)o[u].cc+=s;t.endCC=o[o.length-1].cc}WE(e.startPTS)&&WE(e.endPTS)&&(i.setStart(i.startPTS=e.startPTS),i.startDTS=e.startDTS,i.maxStartPTS=e.maxStartPTS,i.endPTS=e.endPTS,i.endDTS=e.endDTS,i.minEndPTS=e.minEndPTS,i.setDuration(e.endPTS-e.startPTS),i.duration&&(n=i),t.PTSKnown=t.alignedSliding=!0),e.hasStreams&&(i.elementaryStreams=e.elementaryStreams),i.loader=e.loader,e.hasStats&&(i.stats=e.stats),e.initSegment&&(i.initSegment=e.initSegment,a=e.initSegment)});var u=t.fragments,l=t.fragmentHint?u.concat(t.fragmentHint):u;if(a&&l.forEach(e=>{var t;!e||e.initSegment&&e.initSegment.relurl!==(null==(t=a)?void 0:t.relurl)||(e.initSegment=a)}),t.skippedSegments){if(t.deltaUpdateFailed=u.some(e=>!e),t.deltaUpdateFailed){i.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var d=t.skippedSegments;d--;)u.shift();t.startSN=u[0].sn}else{t.canSkipDateRanges&&(t.dateRanges=function(e,t,i){var n=t.dateRanges,a=t.recentlyRemovedDateranges,r=ZE({},e);a&&a.forEach(e=>{delete r[e]});var o=Object.keys(r).length;if(!o)return n;return Object.keys(n).forEach(e=>{var t=r[e],a=new XM(n[e].attr,t);a.isValid?(r[e]=a,t||(a.tagOrder+=o)):i.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${OP(n[e].attr)}"`)}),r}(e.dateRanges,t,i));var h=e.fragments.filter(e=>e.rawProgramDateTime);if(e.hasProgramDateTime&&!t.hasProgramDateTime)for(var c=1;c<l.length;c++)null===l[c].programDateTime&&IA(l[c],l[c-1],h);PA(h,t)}t.endCC=u[u.length-1].cc}if(!t.startCC){var m,f=UA(e,t.startSN-1);t.startCC=null!=(m=null==f?void 0:f.cc)?m:u[0].cc}!function(e,t,i){if(e&&t)for(var n=0,a=0,r=e.length;a<=r;a++){var o=e[a],s=t[a+n];o&&s&&o.index===s.index&&o.fragment.sn===s.fragment.sn?i(o,s):n--}}(e.partList,t.partList,(e,t)=>{t.elementaryStreams=e.elementaryStreams,t.stats=e.stats}),n?WA(t,n,n.startPTS,n.endPTS,n.startDTS,n.endDTS,i):jA(e,t),u.length&&(t.totalduration=t.edge-u[0].start),t.driftStartTime=e.driftStartTime,t.driftStart=e.driftStart;var v=t.advancedDateTime;if(t.advanced&&v){var p=t.edge;t.driftStart||(t.driftStartTime=v,t.driftStart=p),t.driftEndTime=v,t.driftEnd=p}else t.driftEndTime=e.driftEndTime,t.driftEnd=e.driftEnd,t.advancedDateTime=e.advancedDateTime;-1===t.requestScheduled&&(t.requestScheduled=e.requestScheduled)}}function NA(e,t,i,n,a){return new Error(`${e} ${a.url}\nPlaylist starting @${t.startSN}\n${t.m3u8}\n\nPlaylist starting @${i.startSN}\n${i.m3u8}`)}function jA(e,t,i=!0){var n=t.startSN+t.skippedSegments-e.startSN,a=e.fragments,r=n>=0,o=0;if(r&&n<a.length)o=a[n].start;else if(r&&t.startSN===e.endSN+1)o=e.fragmentEnd;else if(r&&i)o=e.fragmentStart+n*t.levelTargetDuration;else{if(t.skippedSegments||0!==t.fragmentStart)return;o=e.fragmentStart}BA(t,o)}function BA(e,t){if(t){for(var i=e.fragments,n=e.skippedSegments;n<i.length;n++)i[n].addStart(t);e.fragmentHint&&e.fragmentHint.addStart(t)}}function zA(e,t=1/0){var i=1e3*e.targetduration;if(e.updated){var n=e.fragments;if(n.length&&4*i>t){var a=1e3*n[n.length-1].duration;a<i&&(i=a)}}else i/=2;return Math.round(i)}function UA(e,t,i){if(!e)return null;var n=e.fragments[t-e.startSN];return n||((n=e.fragmentHint)&&n.sn===t?n:t<e.startSN&&i&&i.sn===t?i:null)}function HA(e,t,i){return e?GA(e.partList,t,i):null}function GA(e,t,i){if(e)for(var n=e.length;n--;){var a=e[n];if(a.index===i&&a.fragment.sn===t)return a}return null}function VA(e){e.forEach((e,t)=>{var i;null==(i=e.details)||i.fragments.forEach(e=>{e.level=t,e.initSegment&&(e.initSegment.level=t)})})}function KA(e,t){return!(e===t||!t)&&XA(e)!==XA(t)}function XA(e){return e.replace(/\?[^?]*$/,"")}function YA(e,t){for(var i=0,n=e.length;i<n;i++){var a;if((null==(a=e[i])?void 0:a.cc)===t)return e[i]}return null}function qA(e,t){var i=e.start+t;e.startPTS=i,e.setStart(i),e.endPTS=i+e.duration}function JA(e,t){for(var i=t.fragments,n=0,a=i.length;n<a;n++)qA(i[n],e);t.fragmentHint&&qA(t.fragmentHint,e),t.alignedSliding=!0}function QA(e,t){if(function(e,t){return!!(e&&t.startCC<e.endCC&&t.endCC>e.startCC)}(t,e)){var i=Math.min(t.endCC,e.endCC),n=YA(t.fragments,i),a=YA(e.fragments,i);if(n&&a)uT.log(`Aligning playlist at start of dicontinuity sequence ${i}`),JA(n.start-a.start,e)}}function ZA(e,t){if(e.hasProgramDateTime&&t.hasProgramDateTime){var i=e.fragments,n=t.fragments;if(i.length&&n.length){var a,r,o=Math.min(t.endCC,e.endCC);t.startCC<o&&e.startCC<o&&(a=YA(n,o),r=YA(i,o)),a&&r||(r=YA(i,(a=n[Math.floor(n.length/2)]).cc)||i[Math.floor(i.length/2)]);var s=a.programDateTime,u=r.programDateTime;if(s&&u)JA((u-s)/1e3-(r.start-a.start),e)}}}function eD(e,t,i){tD(e,t,i),e.addEventListener(t,i)}function tD(e,t,i){e.removeEventListener(t,i)}var iD=function(e){for(var t="",i=e.length,n=0;n<i;n++)t+=`[${e.start(n).toFixed(3)}-${e.end(n).toFixed(3)}]`;return t},nD="STOPPED",aD="IDLE",rD="KEY_LOADING",oD="FRAG_LOADING",sD="FRAG_LOADING_WAITING_RETRY",uD="WAITING_TRACK",lD="PARSING",dD="PARSED",hD="ENDED",cD="ERROR",mD="WAITING_INIT_PTS",fD="WAITING_LEVEL",vD=function(){function e(t,i,n,a,r){var o;return u(this,e),(o=s(this,e,[a,t.logger])).hls=void 0,o.fragPrevious=null,o.fragCurrent=null,o.fragmentTracker=void 0,o.transmuxer=null,o._state=nD,o.playlistType=void 0,o.media=null,o.mediaBuffer=null,o.config=void 0,o.bitrateTest=!1,o.lastCurrentTime=0,o.nextLoadPosition=0,o.startPosition=0,o.startTimeOffset=null,o.retryDate=0,o.levels=null,o.fragmentLoader=void 0,o.keyLoader=void 0,o.levelLastLoaded=null,o.startFragRequested=!1,o.decrypter=void 0,o.initPTS=[],o.buffering=!0,o.loadingParts=!1,o.loopSn=void 0,o.onMediaSeeking=()=>{var e=o,t=e.config,i=e.fragCurrent,n=e.media,a=e.mediaBuffer,r=e.state,s=n?n.currentTime:0,u=WM.bufferInfo(a||n,s,t.maxBufferHole),l=!u.len;if(o.log(`Media seeking to ${WE(s)?s.toFixed(3):s}, state: ${r}, ${l?"out of":"in"} buffer`),o.state===hD)o.resetLoadingState();else if(i){var d=t.maxFragLookUpTolerance,h=i.start-d,c=i.start+i.duration+d;if(l||c<u.start||h>u.end){var m=s>c;(s<h||m)&&(m&&i.loader&&(o.log(`Cancelling fragment load for seek (sn: ${i.sn})`),i.abortRequests(),o.resetLoadingState()),o.fragPrevious=null)}}if(n&&(o.fragmentTracker.removeFragmentsInRange(s,1/0,o.playlistType,!0),s>o.lastCurrentTime&&(o.lastCurrentTime=s),!o.loadingParts)){var f=Math.max(u.end,s),v=o.shouldLoadParts(o.getLevelDetails(),f);v&&(o.log(`LL-Part loading ON after seeking to ${s.toFixed(2)} with buffer @${f.toFixed(2)}`),o.loadingParts=v)}o.hls.hasEnoughToStart||(o.log(`Setting ${l?"startPosition":"nextLoadPosition"} to ${s} for seek without enough to start`),o.nextLoadPosition=s,l&&(o.startPosition=s)),l&&o.state===aD&&o.tickImmediate()},o.onMediaEnded=()=>{o.log("setting startPosition to 0 because media ended"),o.startPosition=o.lastCurrentTime=0},o.playlistType=r,o.hls=t,o.fragmentLoader=new CM(t.config),o.keyLoader=n,o.fragmentTracker=i,o.config=t.config,o.decrypter=new DM(t.config),o}return y(e,RM),m(e,[{key:"registerListeners",value:function(){var e=this.hls;e.on(zE.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(zE.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(zE.MANIFEST_LOADING,this.onManifestLoading,this),e.on(zE.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(zE.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(zE.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(zE.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(zE.MANIFEST_LOADING,this.onManifestLoading,this),e.off(zE.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(zE.ERROR,this.onError,this)}},{key:"doTick",value:function(){this.onTickEnd()}},{key:"onTickEnd",value:function(){}},{key:"startLoad",value:function(e){}},{key:"stopLoad",value:function(){if(this.state!==nD){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);var e=this.fragCurrent;null!=e&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=nD}}},{key:"startPositionValue",get:function(){var e=this.nextLoadPosition,t=this.startPosition;return-1===t&&e?e:t}},{key:"bufferingEnabled",get:function(){return this.buffering}},{key:"pauseBuffering",value:function(){this.buffering=!1}},{key:"resumeBuffering",value:function(){this.buffering=!0}},{key:"inFlightFrag",get:function(){return{frag:this.fragCurrent,state:this.state}}},{key:"_streamEnded",value:function(e,t){if(t.live||!this.media)return!1;var i=e.end||0,n=this.config.timelineOffset||0;if(i<=n)return!1;var a=e.buffered;this.config.maxBufferHole&&a&&a.length>1&&(e=WM.bufferedInfo(a,e.start,0));var r=e.nextStart;if(r&&r>n&&r<t.edge)return!1;if(this.media.currentTime<e.start)return!1;var o=t.partList;if(null!=o&&o.length){var s=o[o.length-1];return WM.isBuffered(this.media,s.start+s.duration/2)}var u=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(u)}},{key:"getLevelDetails",value:function(){if(this.levels&&null!==this.levelLastLoaded)return this.levelLastLoaded.details}},{key:"timelineOffset",get:function(){var e,t=this.config.timelineOffset;return t?(null==(e=this.getLevelDetails())?void 0:e.appliedTimelineOffset)||t:0}},{key:"onMediaAttached",value:function(e,t){var i=this.media=this.mediaBuffer=t.media;eD(i,"seeking",this.onMediaSeeking),eD(i,"ended",this.onMediaEnded);var n=this.config;this.levels&&n.autoStartLoad&&this.state===nD&&this.startLoad(n.startPosition)}},{key:"onMediaDetaching",value:function(e,t){var i=!!t.transferMedia,n=this.media;if(null!==n){if(n.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),tD(n,"seeking",this.onMediaSeeking),tD(n,"ended",this.onMediaEnded),this.keyLoader&&!i&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loopSn=void 0,i)return this.resetLoadingState(),void this.resetTransmuxer();this.loadingParts=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}}},{key:"onManifestLoading",value:function(){this.initPTS=[],this.levels=this.levelLastLoaded=this.fragCurrent=null,this.lastCurrentTime=this.startPosition=0,this.startFragRequested=!1}},{key:"onError",value:function(e,t){}},{key:"onManifestLoaded",value:function(e,t){this.startTimeOffset=t.startTimeOffset}},{key:"onHandlerDestroying",value:function(){this.stopLoad(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),M(e,"onHandlerDestroying",this)([]),this.hls=this.onMediaSeeking=this.onMediaEnded=null}},{key:"onHandlerDestroyed",value:function(){this.state=nD,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,M(e,"onHandlerDestroyed",this)([])}},{key:"loadFragment",value:function(e,t,i){this.startFragRequested=!0,this._loadFragForPlayback(e,t,i)}},{key:"_loadFragForPlayback",value:function(e,t,i){this._doFragLoad(e,t,i,e=>{var t=e.frag;if(this.fragContextChanged(t))return this.warn(`${t.type} sn: ${t.sn}${e.part?" part: "+e.part.index:""} of ${this.fragInfo(t,!1,e.part)}) was dropped during download.`),void this.fragmentTracker.removeFragment(t);t.stats.chunkCount++,this._handleFragmentLoadProgress(e)}).then(e=>{if(e){var t=this.state,i=e.frag;this.fragContextChanged(i)?(t===oD||!this.fragCurrent&&t===lD)&&(this.fragmentTracker.removeFragment(i),this.state=aD):("payload"in e&&(this.log(`Loaded ${i.type} sn: ${i.sn} of ${this.playlistLabel()} ${i.level}`),this.hls.trigger(zE.FRAG_LOADED,e)),this._handleFragmentLoadComplete(e))}}).catch(t=>{this.state!==nD&&this.state!==cD&&(this.warn(`Frag error: ${(null==t?void 0:t.message)||t}`),this.resetFragmentLoading(e))})}},{key:"clearTrackerIfNeeded",value:function(e){var t,i=this.fragmentTracker;if(i.getState(e)===pM){var n=e.type,a=this.getFwdBufferInfo(this.mediaBuffer,n),r=Math.max(e.duration,a?a.len:this.config.maxBufferLength),o=this.backtrackFragment;(1===(o?e.sn-o.sn:0)||this.reduceMaxBufferLength(r,e.duration))&&i.removeFragment(e)}else 0===(null==(t=this.mediaBuffer)?void 0:t.buffered.length)?i.removeAllFragments():i.hasParts(e.type)&&(i.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),i.getState(e)===gM&&i.removeFragment(e))}},{key:"checkLiveUpdate",value:function(e){if(e.updated&&!e.live){var t=e.fragments[e.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type})}e.fragments[0]||(e.deltaUpdateFailed=!0)}},{key:"waitForLive",value:function(e){var t=e.details;return(null==t?void 0:t.live)&&"EVENT"!==t.type&&(this.levelLastLoaded!==e||t.expired)}},{key:"flushMainBuffer",value:function(e,t,i=null){if(e-t){var n={startOffset:e,endOffset:t,type:i};this.hls.trigger(zE.BUFFER_FLUSHING,n)}}},{key:"_loadInitSegment",value:function(e,t){this._doFragLoad(e,t).then(e=>{var t=null==e?void 0:e.frag;if(!t||this.fragContextChanged(t)||!this.levels)throw new Error("init load aborted");return e}).then(e=>{var t=this.hls,i=e.frag,n=e.payload,a=i.decryptdata;if(n&&n.byteLength>0&&null!=a&&a.key&&a.iv&&QM(a.method)){var r=self.performance.now();return this.decrypter.decrypt(new Uint8Array(n),a.key.buffer,a.iv.buffer,ZM(a.method)).catch(e=>{throw t.trigger(zE.ERROR,{type:jE.MEDIA_ERROR,details:BE.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:i}),e}).then(n=>{var a=self.performance.now();return t.trigger(zE.FRAG_DECRYPTED,{frag:i,payload:n,stats:{tstart:r,tdecrypt:a}}),e.payload=n,this.completeInitSegmentLoad(e)})}return this.completeInitSegmentLoad(e)}).catch(t=>{this.state!==nD&&this.state!==cD&&(this.warn(t),this.resetFragmentLoading(e))})}},{key:"completeInitSegmentLoad",value:function(e){if(!this.levels)throw new Error("init load aborted, missing levels");var t=e.frag.stats;this.state!==nD&&(this.state=aD),e.frag.data=new Uint8Array(e.payload),t.parsing.start=t.buffering.start=self.performance.now(),t.parsing.end=t.buffering.end=self.performance.now(),this.tick()}},{key:"unhandledEncryptionError",value:function(e,t){var i,n,a=e.tracks;if(a&&!t.encrypted&&(null!=(i=a.audio)&&i.encrypted||null!=(n=a.video)&&n.encrypted)&&(!this.config.emeEnabled||!this.keyLoader.emeController)){var r=this.media,o=new Error(`Encrypted track with no key in ${this.fragInfo(t)} (media ${r?"attached mediaKeys: "+r.mediaKeys:"detached"})`);return this.warn(o.message),!r||r.mediaKeys?!1:(this.hls.trigger(zE.ERROR,{type:jE.KEY_SYSTEM_ERROR,details:BE.KEY_SYSTEM_NO_KEYS,fatal:!1,error:o,frag:t}),this.resetTransmuxer(),!0)}return!1}},{key:"fragContextChanged",value:function(e){var t=this.fragCurrent;return!e||!t||e.sn!==t.sn||e.level!==t.level}},{key:"fragBufferedComplete",value:function(e,t){var i=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log(`Buffered ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,!1,t)} > buffer:${i?iD(WM.getBuffered(i)):"(detached)"})`),DT(e)){var n;if(e.type!==YE){var a=e.elementaryStreams;if(!Object.keys(a).some(e=>!!a[e]))return void(this.state=aD)}var r=null==(n=this.levels)?void 0:n[e.level];null!=r&&r.fragmentError&&(this.log(`Resetting level fragment error count of ${r.fragmentError} on frag buffered`),r.fragmentError=0)}this.state=aD}},{key:"_handleFragmentLoadComplete",value:function(e){var t=this.transmuxer;if(t){var i=e.frag,n=e.part,a=e.partsLoaded,r=!a||0===a.length||a.some(e=>!e),o=new FM(i.level,i.sn,i.stats.chunkCount+1,0,n?n.index:-1,!r);t.flush(o)}}},{key:"_handleFragmentLoadProgress",value:function(e){}},{key:"_doFragLoad",value:function(e,t,i=null,n){var a;this.fragCurrent=e;var r=t.details;if(!this.levels||!r)throw new Error(`frag load aborted, missing level${r?"":" detail"}s`);var o=null;if(!e.encrypted||null!=(a=e.decryptdata)&&a.key)e.encrypted||(o=this.keyLoader.loadClear(e,r.encryptedFragments,this.startFragRequested))&&this.log("[eme] blocking frag load until media-keys acquired");else if(this.log(`Loading key for ${e.sn} of [${r.startSN}-${r.endSN}], ${this.playlistLabel()} ${e.level}`),this.state=rD,this.fragCurrent=e,o=this.keyLoader.load(e).then(e=>{if(!this.fragContextChanged(e.frag))return this.hls.trigger(zE.KEY_LOADED,e),this.state===rD&&(this.state=aD),e}),this.hls.trigger(zE.KEY_LOADING,{frag:e}),null===this.fragCurrent)return this.log("context changed in KEY_LOADING"),Promise.resolve(null);var s,u=this.fragPrevious;if(DT(e)&&(!u||e.sn!==u.sn)){var l=this.shouldLoadParts(t.details,e.end);l!==this.loadingParts&&(this.log(`LL-Part loading ${l?"ON":"OFF"} loading sn ${null==u?void 0:u.sn}->${e.sn}`),this.loadingParts=l)}if(i=Math.max(e.start,i||0),this.loadingParts&&DT(e)){var d=r.partList;if(d&&n){i>r.fragmentEnd&&r.fragmentHint&&(e=r.fragmentHint);var h=this.getNextPart(d,e,i);if(h>-1){var c,m=d[h];return e=this.fragCurrent=m.fragment,this.log(`Loading ${e.type} sn: ${e.sn} part: ${m.index} (${h}/${d.length-1}) of ${this.fragInfo(e,!1,m)}) cc: ${e.cc} [${r.startSN}-${r.endSN}], target: ${parseFloat(i.toFixed(3))}`),this.nextLoadPosition=m.start+m.duration,this.state=oD,c=o?o.then(i=>!i||this.fragContextChanged(i.frag)?null:this.doFragPartsLoad(e,m,t,n)).catch(e=>this.handleFragLoadError(e)):this.doFragPartsLoad(e,m,t,n).catch(e=>this.handleFragLoadError(e)),this.hls.trigger(zE.FRAG_LOADING,{frag:e,part:m,targetBufferTime:i}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):c}if(!e.url||this.loadedEndOfParts(d,i))return Promise.resolve(null)}}if(DT(e)&&this.loadingParts)this.log(`LL-Part loading OFF after next part miss @${i.toFixed(2)} Check buffer at sn: ${e.sn} loaded parts: ${null==(s=r.partList)?void 0:s.filter(e=>e.loaded).map(e=>`[${e.start}-${e.end}]`)}`),this.loadingParts=!1;else if(!e.url)return Promise.resolve(null);this.log(`Loading ${e.type} sn: ${e.sn} of ${this.fragInfo(e,!1)}) cc: ${e.cc} ${"["+r.startSN+"-"+r.endSN+"]"}, target: ${parseFloat(i.toFixed(3))}`),WE(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=oD;var f,v=this.config.progressive&&e.type!==YE;return f=v&&o?o.then(t=>!t||this.fragContextChanged(t.frag)?null:this.fragmentLoader.load(e,n)).catch(e=>this.handleFragLoadError(e)):Promise.all([this.fragmentLoader.load(e,v?n:void 0),o]).then(([e])=>(!v&&n&&n(e),e)).catch(e=>this.handleFragLoadError(e)),this.hls.trigger(zE.FRAG_LOADING,{frag:e,targetBufferTime:i}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):f}},{key:"doFragPartsLoad",value:function(e,t,i,n){return new Promise((a,r)=>{var o,s=[],u=null==(o=i.details)?void 0:o.partList,l=t=>{this.fragmentLoader.loadPart(e,t,n).then(n=>{s[t.index]=n;var r=n.part;this.hls.trigger(zE.FRAG_LOADED,n);var o=HA(i.details,e.sn,t.index+1)||GA(u,e.sn,t.index+1);if(!o)return a({frag:e,part:r,partsLoaded:s});l(o)}).catch(r)};l(t)})}},{key:"handleFragLoadError",value:function(e){if("data"in e){var t=e.data;t.frag&&t.details===BE.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):t.frag&&t.type===jE.KEY_SYSTEM_ERROR?(t.frag.abortRequests(),this.resetStartWhenNotLoaded(),this.resetFragmentLoading(t.frag)):this.hls.trigger(zE.ERROR,t)}else this.hls.trigger(zE.ERROR,{type:jE.OTHER_ERROR,details:BE.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}},{key:"_handleTransmuxerFlush",value:function(e){var t=this.getCurrentContext(e);if(t&&this.state===lD){var i=t.frag,n=t.part,a=t.level,r=self.performance.now();i.stats.parsing.end=r,n&&(n.stats.parsing.end=r);var o=this.getLevelDetails(),s=o&&i.sn>o.endSN||this.shouldLoadParts(o,i.end);s!==this.loadingParts&&(this.log(`LL-Part loading ${s?"ON":"OFF"} after parsing segment ending @${i.end.toFixed(2)}`),this.loadingParts=s),this.updateLevelTiming(i,n,a,e.partial)}else this.fragCurrent||this.state===nD||this.state===cD||(this.state=aD)}},{key:"shouldLoadParts",value:function(e,t){if(this.config.lowLatencyMode){if(!e)return this.loadingParts;if(e.partList){var i,n,a=e.partList[0];if(a.fragment.type===YE)return!1;if(t>=a.end+((null==(i=e.fragmentHint)?void 0:i.duration)||0))if((this.hls.hasEnoughToStart?(null==(n=this.media)?void 0:n.currentTime)||this.lastCurrentTime:this.getLoadPosition())>a.start-a.fragment.duration)return!0}}return!1}},{key:"getCurrentContext",value:function(e){var t=this.levels,i=this.fragCurrent,n=e.level,a=e.sn,r=e.part;if(null==t||!t[n])return this.warn(`Levels object was unset while buffering fragment ${a} of ${this.playlistLabel()} ${n}. The current chunk will not be buffered.`),null;var o=t[n],s=o.details,u=r>-1?HA(s,a,r):null,l=u?u.fragment:UA(s,a,i);return l?(i&&i!==l&&(l.stats=i.stats),{frag:l,part:u,level:o}):null}},{key:"bufferFragmentData",value:function(e,t,i,n,a){if(this.state===lD){var r=e.data1,o=e.data2,s=r;if(o&&(s=qT(r,o)),s.length){var u=this.initPTS[t.cc],l=u?-u.baseTime/u.timescale:void 0,d={type:e.type,frag:t,part:i,chunkMeta:n,offset:l,parent:t.type,data:s};if(this.hls.trigger(zE.BUFFER_APPENDING,d),e.dropped&&e.independent&&!i){if(a)return;this.flushBufferGap(t)}}}}},{key:"flushBufferGap",value:function(e){var t=this.media;if(t)if(WM.isBuffered(t,t.currentTime)){var i=t.currentTime,n=WM.bufferInfo(t,i,0),a=e.duration,r=Math.min(2*this.config.maxFragLookUpTolerance,.25*a),o=Math.max(Math.min(e.start-r,n.end-r),i+r);e.start-o>r&&this.flushMainBuffer(o,e.start)}else this.flushMainBuffer(0,e.start)}},{key:"getFwdBufferInfo",value:function(e,t){var i,n=this.getLoadPosition();if(!WE(n))return null;var a=this.lastCurrentTime>n||null!=(i=this.media)&&i.paused?0:this.config.maxBufferHole;return this.getFwdBufferInfoAtPos(e,n,t,a)}},{key:"getFwdBufferInfoAtPos",value:function(e,t,i,n){var a=WM.bufferInfo(e,t,n);if(0===a.len&&void 0!==a.nextStart){var r=this.fragmentTracker.getBufferedFrag(t,i);if(r&&(a.nextStart<=r.end||r.gap)){var o=Math.max(Math.min(a.nextStart,r.end)-t,n);return WM.bufferInfo(e,t,o)}}return a}},{key:"getMaxBufferLength",value:function(e){var t,i=this.config;return t=e?Math.max(8*i.maxBufferSize/e,i.maxBufferLength):i.maxBufferLength,Math.min(t,i.maxMaxBufferLength)}},{key:"exceedsMaxBuffer",value:function(e,t,i){var n=e.nextStart;if(n&&i.start>n){var a=e.buffered;if(a){for(var r=e.len,o=e.bufferedIndex,s=a.length-1;s>o;s--)a[s].start<i.start&&(r+=a[s].end-a[s].start);return r>=t}}return!1}},{key:"reduceMaxBufferLength",value:function(e,t){var i=this.config,n=Math.max(Math.min(e-t,i.maxBufferLength),t),a=Math.max(e-3*t,i.maxMaxBufferLength/2,n);return a>=n&&(i.maxMaxBufferLength=a,this.warn(`Reduce max buffer length to ${a}s`),!0)}},{key:"getAppendedFrag",value:function(e,t=KE){var i=this.fragmentTracker?this.fragmentTracker.getAppendedFrag(e,t):null;return i&&"fragment"in i?i.fragment:i}},{key:"getNextFragment",value:function(e,t){var i=t.fragments,n=i.length;if(!n)return null;var a=this.config,r=t.fragmentStart,o=a.lowLatencyMode&&!!t.partList,s=null;if(t.live){var u=a.initialLiveManifestSize;if(n<u)return this.warn(`Not enough fragments to start playback (have: ${n}, need: ${u})`),null;if(!t.PTSKnown&&!this.startFragRequested&&-1===this.startPosition||e<r){var l;o&&!this.loadingParts&&(this.log("LL-Part loading ON for initial live fragment"),this.loadingParts=!0),s=this.getInitialLiveFragment(t);var d,h,c=this.config.startPosition,m=this.hls.startPosition,f=this.hls.liveSyncPosition,v=(null==(l=s)?void 0:l.start)||0;-1!==m&&m>=r?(d=m,h=m===c?"config":"next load start"):null!==f?(d=f,h="live edge"):(d=e,h="buffer pos"),d<v&&(d=v,h="live frag start"),d<r&&(d=r,h="playlist start"),this.startPosition==d&&this.nextLoadPosition==d||(this.log(`Setting startPosition to ${d.toFixed(3)} ${-1===m?"":`(from ${c}) `}based on ${h}. live edge: ${f} live frag start: ${v.toFixed(3)} playlist start: ${r.toFixed(3)} buffer pos: ${e}`),this.startPosition=this.nextLoadPosition=d)}}else e<=r&&(s=i[0]);if(!s){var p=this.loadingParts?t.partEnd:t.fragmentEnd;s=this.getFragmentAtPosition(e,p,t)}var g=this.filterReplacedPrimary(s,t);if(!g&&s){var y=s.sn-t.startSN;g=this.filterReplacedPrimary(i[y+1]||null,t)}return this.mapToInitFragWhenRequired(g)}},{key:"isLoopLoading",value:function(e,t){if(this.nextLoadPosition<=t)return!1;var i=this.fragmentTracker.getState(e);return i===yM||i===gM&&!!e.gap}},{key:"getNextFragmentLoopLoading",value:function(e,t,i,n,a){var r=null;if(e.gap&&(r=this.getNextFragment(this.nextLoadPosition,t))&&!r.gap&&i.nextStart){var o=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,i.nextStart,n,0);if(null!==o&&i.len+o.len>=a){var s=r.sn;return this.loopSn!==s&&(this.log(`buffer full after gaps in "${n}" playlist starting at sn: ${s}`),this.loopSn=s),null}}return this.loopSn=void 0,r}},{key:"primaryPrefetch",get:function(){var e;if(pD(this.config)&&(null==(e=this.hls.interstitialsManager)||null==(e=e.playingItem)?void 0:e.event))return!0;return!1}},{key:"filterReplacedPrimary",value:function(e,t){if(!e)return e;if(pD(this.config)&&e.type!==YE){var i=this.hls.interstitialsManager,n=null==i?void 0:i.bufferingItem;if(n){var a=n.event;if(a){if(a.appendInPlace||Math.abs(e.start-n.start)>1||0===n.start)return null}else{if(e.end<=n.start&&!1===(null==t?void 0:t.live))return null;if(e.start>n.end&&n.nextEvent&&(n.nextEvent.appendInPlace||e.start-n.end>1))return null}}var r=null==i?void 0:i.playerQueue;if(r)for(var o=r.length;o--;){var s=r[o].interstitial;if(s.appendInPlace&&e.start>=s.startTime&&e.end<=s.resumeTime)return null}}return e}},{key:"mapToInitFragWhenRequired",value:function(e){return null==e||!e.initSegment||e.initSegment.data||this.bitrateTest?e:e.initSegment}},{key:"getNextPart",value:function(e,t,i){for(var n=-1,a=!1,r=!0,o=0,s=e.length;o<s;o++){var u=e[o];if(r=r&&!u.independent,n>-1&&i<u.start)break;var l=u.loaded;l?n=-1:(a||(u.independent||r)&&u.fragment===t)&&(u.fragment!==t&&this.warn(`Need buffer at ${i} but next unloaded part starts at ${u.start}`),n=o),a=l}return n}},{key:"loadedEndOfParts",value:function(e,t){for(var i,n=e.length;n--;){if(!(i=e[n]).loaded)return!1;if(t>i.start)return!0}return!1}},{key:"getInitialLiveFragment",value:function(e){var t=e.fragments,i=this.fragPrevious,n=null;if(i){if(e.hasProgramDateTime&&(n=function(e,t,i){if(null===t||!Array.isArray(e)||!e.length||!WE(t))return null;if(t<(e[0].programDateTime||0))return null;if(t>=(e[e.length-1].endProgramDateTime||0))return null;for(var n=0;n<e.length;++n){var a=e[n];if(YP(t,i,a))return a}return null}(t,i.endProgramDateTime,this.config.maxFragLookUpTolerance),n&&this.log(`Live playlist, switching playlist, load frag with same PDT: ${i.programDateTime}`)),!n){var a=i.sn+1;if(a>=e.startSN&&a<=e.endSN){var r=t[a-e.startSN];i.cc===r.cc&&(n=r,this.log(`Live playlist, switching playlist, load frag with next SN: ${n.sn}`))}n||(n=qP(e,i.cc,i.end))&&this.log(`Live playlist, switching playlist, load frag with same CC: ${n.sn}`)}}else{var o=this.hls.liveSyncPosition;null!==o&&(n=this.getFragmentAtPosition(o,this.bitrateTest?e.fragmentEnd:e.edge,e))}return n}},{key:"getFragmentAtPosition",value:function(e,t,i){var n,a,r=this.config,o=this.fragPrevious,s=i.fragments,u=i.endSN,l=i.fragmentHint,d=r.maxFragLookUpTolerance,h=i.partList,c=!!(this.loadingParts&&null!=h&&h.length&&l);(c&&!this.bitrateTest&&h[h.length-1].fragment.sn===l.sn&&(s=s.concat(l),u=l.sn),e<t)?n=KP(o,s,e,e<this.lastCurrentTime||e>t-d||null!=(a=this.media)&&a.paused||!this.startFragRequested?0:d):n=s[s.length-1];if(n){var m=n.sn-i.startSN,f=this.fragmentTracker.getState(n);if((f===yM||f===gM&&n.gap)&&(o=n),o&&n.sn===o.sn&&(!c||h[0].fragment.sn>n.sn||!i.live))if(n.level===o.level){var v=s[m+1];n=n.sn<u&&this.fragmentTracker.getState(v)!==yM?v:null}}return n}},{key:"alignPlaylists",value:function(e,t,i){var n=e.fragments.length;if(!n)return this.warn("No fragments in live playlist"),0;var a=e.fragmentStart,r=!t,o=e.alignedSliding&&WE(a);if(r||!o&&!a){!function(e,t){e&&(QA(t,e),t.alignedSliding||ZA(t,e),t.alignedSliding||t.skippedSegments||jA(e,t,!1))}(i,e);var s=e.fragmentStart;return this.log(`Live playlist sliding: ${s.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${e.startSN} fragments: ${n}`),s}return a}},{key:"waitForCdnTuneIn",value:function(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,3*e.partTarget)}},{key:"setStartPosition",value:function(e,t){var i=this.startPosition;i<t&&(i=-1);var n=this.timelineOffset;if(-1===i){var a=null!==this.startTimeOffset,r=a?this.startTimeOffset:e.startTimeOffset;null!==r&&WE(r)?(i=t+r,r<0&&(i+=e.edge),i=Math.min(Math.max(t,i),t+e.totalduration),this.log(`Setting startPosition to ${i} for start time offset ${r} found in ${a?"multivariant":"media"} playlist`),this.startPosition=i):e.live?(i=this.hls.liveSyncPosition||t,this.log(`Setting startPosition to -1 to start at live edge ${i}`),this.startPosition=-1):(this.log("setting startPosition to 0 by default"),this.startPosition=i=0),this.lastCurrentTime=i+n}this.nextLoadPosition=i+n}},{key:"getLoadPosition",value:function(){var e,t=this.media,i=0;return null!=(e=this.hls)&&e.hasEnoughToStart&&t?i=t.currentTime:this.nextLoadPosition>=0&&(i=this.nextLoadPosition),i}},{key:"handleFragLoadAborted",value:function(e,t){this.transmuxer&&e.type===this.playlistType&&DT(e)&&e.stats.aborted&&(this.log(`Fragment ${e.sn}${t?" part "+t.index:""} of ${this.playlistLabel()} ${e.level} was aborted`),this.resetFragmentLoading(e))}},{key:"resetFragmentLoading",value:function(e){this.fragCurrent&&(this.fragContextChanged(e)||this.state===sD)||(this.state=aD)}},{key:"onFragmentOrKeyLoadError",value:function(e,t){var i;if(t.chunkMeta&&!t.frag){var n=this.getCurrentContext(t.chunkMeta);n&&(t.frag=n.frag)}var a=t.frag;if(a&&a.type===e&&this.levels)if(this.fragContextChanged(a)){var r;this.warn(`Frag load error must match current frag to retry ${a.url} > ${null==(r=this.fragCurrent)?void 0:r.url}`)}else{var o=t.details===BE.FRAG_GAP;o&&this.fragmentTracker.fragBuffered(a,!0);var s=t.errorAction;if(s){var u=s.action,l=s.flags,d=s.retryCount,h=void 0===d?0:d,c=s.retryConfig,m=!!c,f=m&&u===uM,v=m&&!s.resolved&&l===dM,p=null==(i=this.hls.latestLevelDetails)?void 0:i.live;if(!f&&v&&DT(a)&&!a.endList&&p&&!ZP(t))this.resetFragmentErrors(e),this.treatAsGap(a),s.resolved=!0;else if((f||v)&&h<c.maxNumRetry){var g,y=aM(null==(g=t.response)?void 0:g.code),b=tM(c,h);if(this.resetStartWhenNotLoaded(),this.retryDate=self.performance.now()+b,this.state=sD,s.resolved=!0,y)return this.log("Waiting for connection (offline)"),this.retryDate=1/0,void(t.reason="offline");this.warn(`Fragment ${a.sn} of ${e} ${a.level} errored with ${t.details}, retrying loading ${h+1}/${c.maxNumRetry} in ${b}ms`)}else if(c){if(this.resetFragmentErrors(e),!(h<c.maxNumRetry))return void this.warn(`${t.details} reached or exceeded max retry (${h})`);o||u===sM||(s.resolved=!0)}else this.state=u===oM?fD:cD;this.tickImmediate()}else this.state=cD}}},{key:"checkRetryDate",value:function(){var e=self.performance.now(),t=this.retryDate,i=t===1/0;(!t||e>=t||i&&!aM(0))&&(i&&this.log("Connection restored (online)"),this.resetStartWhenNotLoaded(),this.state=aD)}},{key:"reduceLengthAndFlushBuffer",value:function(e){if(this.state===lD||this.state===dD){var t=e.frag,i=e.parent,n=this.getFwdBufferInfo(this.mediaBuffer,i),a=n&&n.len>.5;a&&this.reduceMaxBufferLength(n.len,(null==t?void 0:t.duration)||10);var r=!a;return r&&this.warn(`Buffer full error while media.currentTime (${this.getLoadPosition()}) is not buffered, flush ${i} buffer`),t&&(this.fragmentTracker.removeFragment(t),this.nextLoadPosition=t.start),this.resetLoadingState(),r}return!1}},{key:"resetFragmentErrors",value:function(e){e===XE&&(this.fragCurrent=null),this.hls.hasEnoughToStart||(this.startFragRequested=!1),this.state!==nD&&(this.state=aD)}},{key:"afterBufferFlushed",value:function(e,t,i){if(e){var n=WM.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,n,i),this.state===hD&&this.resetLoadingState()}}},{key:"resetLoadingState",value:function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==nD&&(this.state=aD)}},{key:"resetStartWhenNotLoaded",value:function(){if(!this.hls.hasEnoughToStart){this.startFragRequested=!1;var e=this.levelLastLoaded,t=e?e.details:null;null!=t&&t.live?(this.log("resetting startPosition for live start"),this.startPosition=-1,this.setStartPosition(t,t.fragmentStart),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}},{key:"resetWhenMissingContext",value:function(e){this.log(`Loading context changed while buffering sn ${e.sn} of ${this.playlistLabel()} ${-1===e.level?"<removed>":e.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(),this.resetLoadingState()}},{key:"removeUnbufferedFrags",value:function(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}},{key:"updateLevelTiming",value:function(e,t,i,n){var a=i.details;if(a){if(!Object.keys(e.elementaryStreams).reduce((t,r)=>{var o=e.elementaryStreams[r];if(o){var s=o.endPTS-o.startPTS;if(s<=0)return this.warn(`Could not parse fragment ${e.sn} ${r} duration reliably (${s})`),t||!1;var u=n?0:WA(a,e,o.startPTS,o.endPTS,o.startDTS,o.endDTS,this);return this.hls.trigger(zE.LEVEL_PTS_UPDATED,{details:a,level:i,drift:u,type:r,frag:e,start:o.startPTS,end:o.endPTS}),!0}return t},!1)){var r,o=null===(null==(r=this.transmuxer)?void 0:r.error);if((0===i.fragmentError||o&&(i.fragmentError<2||e.endList))&&this.treatAsGap(e,i),o){var s=new Error(`Found no media in fragment ${e.sn} of ${this.playlistLabel()} ${e.level} resetting transmuxer to fallback to playlist timing`);if(this.warn(s.message),this.hls.trigger(zE.ERROR,{type:jE.MEDIA_ERROR,details:BE.FRAG_PARSING_ERROR,fatal:!1,error:s,frag:e,reason:`Found no media in msn ${e.sn} of ${this.playlistLabel()} "${i.url}"`}),!this.hls)return;this.resetTransmuxer()}}this.state=dD,this.log(`Parsed ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,!1,t)})`),this.hls.trigger(zE.FRAG_PARSED,{frag:e,part:t})}else this.warn("level.details undefined")}},{key:"playlistLabel",value:function(){return this.playlistType===KE?"level":"track"}},{key:"fragInfo",value:function(e,t=!0,i){var n,a;return`${this.playlistLabel()} ${e.level} (${i?"part":"frag"}:[${(null!=(n=t&&!i?e.startPTS:(i||e).start)?n:NaN).toFixed(3)}-${(null!=(a=t&&!i?e.endPTS:(i||e).end)?a:NaN).toFixed(3)}]${i&&"main"===e.type?"INDEPENDENT="+(i.independent?"YES":"NO"):""}`}},{key:"treatAsGap",value:function(e,t){t&&t.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)}},{key:"resetTransmuxer",value:function(){var e;null==(e=this.transmuxer)||e.reset()}},{key:"recoverWorkerError",value:function(e){"demuxerWorker"===e.event&&(this.fragmentTracker.removeAllFragments(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),this.resetStartWhenNotLoaded(),this.resetLoadingState())}},{key:"state",get:function(){return this._state},set:function(e){var t=this._state;t!==e&&(this._state=e,this.log(`${t}->${e}`))}}])}();function pD(e){return!!e.interstitialsController&&!1!==e.enableInterstitialPlayback}var gD=function(){return m(function e(){u(this,e),this.chunks=[],this.dataLength=0},[{key:"push",value:function(e){this.chunks.push(e),this.dataLength+=e.length}},{key:"flush",value:function(){var e,t=this.chunks,i=this.dataLength;return t.length?(e=1===t.length?t[0]:function(e,t){for(var i=new Uint8Array(t),n=0,a=0;a<e.length;a++){var r=e[a];i.set(r,n),n+=r.length}return i}(t,i),this.reset(),e):new Uint8Array(0)}},{key:"reset",value:function(){this.chunks.length=0,this.dataLength=0}}])}();var yD,bD={exports:{}};var wD=(yD||(yD=1,function(e){var t=Object.prototype.hasOwnProperty,i="~";function n(){}function a(e,t,i){this.fn=e,this.context=t,this.once=i||!1}function r(e,t,n,r,o){if("function"!=typeof n)throw new TypeError("The listener must be a function");var s=new a(n,r||e,o),u=i?i+t:t;return e._events[u]?e._events[u].fn?e._events[u]=[e._events[u],s]:e._events[u].push(s):(e._events[u]=s,e._eventsCount++),e}function o(e,t){0===--e._eventsCount?e._events=new n:delete e._events[t]}function s(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(i=!1)),s.prototype.eventNames=function(){var e,n,a=[];if(0===this._eventsCount)return a;for(n in e=this._events)t.call(e,n)&&a.push(i?n.slice(1):n);return Object.getOwnPropertySymbols?a.concat(Object.getOwnPropertySymbols(e)):a},s.prototype.listeners=function(e){var t=i?i+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var a=0,r=n.length,o=new Array(r);a<r;a++)o[a]=n[a].fn;return o},s.prototype.listenerCount=function(e){var t=i?i+e:e,n=this._events[t];return n?n.fn?1:n.length:0},s.prototype.emit=function(e,t,n,a,r,o){var s=i?i+e:e;if(!this._events[s])return!1;var u,l,d=this._events[s],h=arguments.length;if(d.fn){switch(d.once&&this.removeListener(e,d.fn,void 0,!0),h){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,t),!0;case 3:return d.fn.call(d.context,t,n),!0;case 4:return d.fn.call(d.context,t,n,a),!0;case 5:return d.fn.call(d.context,t,n,a,r),!0;case 6:return d.fn.call(d.context,t,n,a,r,o),!0}for(l=1,u=new Array(h-1);l<h;l++)u[l-1]=arguments[l];d.fn.apply(d.context,u)}else{var c,m=d.length;for(l=0;l<m;l++)switch(d[l].once&&this.removeListener(e,d[l].fn,void 0,!0),h){case 1:d[l].fn.call(d[l].context);break;case 2:d[l].fn.call(d[l].context,t);break;case 3:d[l].fn.call(d[l].context,t,n);break;case 4:d[l].fn.call(d[l].context,t,n,a);break;default:if(!u)for(c=1,u=new Array(h-1);c<h;c++)u[c-1]=arguments[c];d[l].fn.apply(d[l].context,u)}}return!0},s.prototype.on=function(e,t,i){return r(this,e,t,i,!1)},s.prototype.once=function(e,t,i){return r(this,e,t,i,!0)},s.prototype.removeListener=function(e,t,n,a){var r=i?i+e:e;if(!this._events[r])return this;if(!t)return o(this,r),this;var s=this._events[r];if(s.fn)s.fn!==t||a&&!s.once||n&&s.context!==n||o(this,r);else{for(var u=0,l=[],d=s.length;u<d;u++)(s[u].fn!==t||a&&!s[u].once||n&&s[u].context!==n)&&l.push(s[u]);l.length?this._events[r]=1===l.length?l[0]:l:o(this,r)}return this},s.prototype.removeAllListeners=function(e){var t;return e?(t=i?i+e:e,this._events[t]&&o(this,t)):(this._events=new n,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=i,s.EventEmitter=s,e.exports=s}(bD)),bD.exports),kD=fT(wD),SD="1.6.16",ED={};function TD(e,t){return t+10<=e.length&&51===e[t]&&68===e[t+1]&&73===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128}function PD(e,t){return t+10<=e.length&&73===e[t]&&68===e[t+1]&&51===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128}function MD(e,t){var i=0;return i=(127&e[t])<<21,i|=(127&e[t+1])<<14,i|=(127&e[t+2])<<7,i|=127&e[t+3]}function AD(e,t){for(var i=t,n=0;PD(e,t);){n+=10,n+=MD(e,t+6),TD(e,t+10)&&(n+=10),t+=n}if(n>0)return e.subarray(i,i+n)}function DD(e,t){return 255===e[t]&&240==(246&e[t+1])}function xD(e,t){return 1&e[t+1]?7:9}function CD(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function ID(e,t){return t+1<e.length&&DD(e,t)}function LD(e,t){if(ID(e,t)){var i=xD(e,t);if(t+i>=e.length)return!1;var n=CD(e,t);if(n<=i)return!1;var a=t+n;return a===e.length||ID(e,a)}return!1}function _D(e,t,i,n,a){if(!e.samplerate){var r=function(e,t,i,n){var a=t[i+2],r=a>>2&15;if(!(r>12)){var o=1+(a>>6&3),s=t[i+3]>>6&3|(1&a)<<2,u="mp4a.40."+o,l=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350][r],d=r;5!==o&&29!==o||(d-=3);var h=[o<<3|(14&d)>>1,(1&d)<<7|s<<3];return uT.log(`manifest codec:${n}, parsed codec:${u}, channels:${s}, rate:${l} (ADTS object type:${o} sampling index:${r})`),{config:h,samplerate:l,channelCount:s,codec:u,parsedCodec:u,manifestCodec:n}}var c=new Error(`invalid ADTS sampling index:${r}`);e.emit(zE.ERROR,zE.ERROR,{type:jE.MEDIA_ERROR,details:BE.FRAG_PARSING_ERROR,fatal:!0,error:c,reason:c.message})}(t,i,n,a);if(!r)return;ZE(e,r)}}function RD(e){return 9216e4/e}function FD(e,t,i,n,a){var r,o=n+a*RD(e.samplerate),s=function(e,t){var i=xD(e,t);if(t+i<=e.length){var n=CD(e,t)-i;if(n>0)return{headerLength:i,frameLength:n}}}(t,i);if(s){var u=s.frameLength,l=s.headerLength,d=l+u,h=Math.max(0,i+d-t.length);h?(r=new Uint8Array(d-l)).set(t.subarray(i+l,t.length),0):r=t.subarray(i+l,i+d);var c={unit:r,pts:o};return h||e.samples.push(c),{sample:c,length:d,missing:h}}var m=t.length-i;return(r=new Uint8Array(m)).set(t.subarray(i,t.length),0),{sample:{unit:r,pts:o},length:m,missing:-1}}function OD(e,t){return PD(e,t)&&MD(e,t+6)+10<=e.length-t}function WD(e,t=0,i=1/0){return function(e,t,i,n){var a=function(e){return e instanceof ArrayBuffer?e:e.buffer}(e),r=1;"BYTES_PER_ELEMENT"in n&&(r=n.BYTES_PER_ELEMENT);var o=(h=e,h&&h.buffer instanceof ArrayBuffer&&void 0!==h.byteLength&&void 0!==h.byteOffset?e.byteOffset:0),s=(o+e.byteLength)/r,u=(o+t)/r,l=Math.floor(Math.max(0,Math.min(u,s))),d=Math.floor(Math.min(l+Math.max(i,0),s));var h;return new n(a,l,d-l)}(e,t,i,Uint8Array)}function $D(e){var t={key:e.type,description:"",data:"",mimeType:null,pictureType:null};if(!(e.size<2))if(3===e.data[0]){var i=e.data.subarray(1).indexOf(0);if(-1!==i){var n=hT(WD(e.data,1,i)),a=e.data[2+i],r=e.data.subarray(3+i).indexOf(0);if(-1!==r){var o,s=hT(WD(e.data,3+i,r));return o="--\x3e"===n?hT(WD(e.data,4+i+r)):function(e){return e instanceof ArrayBuffer?e:0==e.byteOffset&&e.byteLength==e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer}(e.data.subarray(4+i+r)),t.mimeType=n,t.pictureType=a,t.description=s,t.data=o,t}}}else console.log("Ignore frame with unrecognized character encoding")}function ND(e){return"PRIV"===e.type?function(e){if(!(e.size<2)){var t=hT(e.data,!0),i=new Uint8Array(e.data.subarray(t.length+1));return{key:e.type,info:t,data:i.buffer}}}(e):"W"===e.type[0]?function(e){if("WXXX"===e.type){if(e.size<2)return;var t=1,i=hT(e.data.subarray(t),!0);t+=i.length+1;var n=hT(e.data.subarray(t));return{key:e.type,info:i,data:n}}var a=hT(e.data);return{key:e.type,info:"",data:a}}(e):"APIC"===e.type?$D(e):function(e){if(!(e.size<2)){if("TXXX"===e.type){var t=1,i=hT(e.data.subarray(t),!0);t+=i.length+1;var n=hT(e.data.subarray(t));return{key:e.type,info:i,data:n}}var a=hT(e.data.subarray(1));return{key:e.type,info:"",data:a}}}(e)}function jD(e){var t=String.fromCharCode(e[0],e[1],e[2],e[3]),i=MD(e,4);return{type:t,size:i,data:e.subarray(10,10+i)}}function BD(e){for(var t=0,i=[];PD(e,t);){var n=MD(e,t+6);e[t+5]>>6&1&&(t+=10);for(var a=(t+=10)+n;t+10<a;){var r=jD(e.subarray(t)),o=ND(r);o&&i.push(o),t+=r.size+10}TD(e,t)&&(t+=10)}return i}function zD(e){return e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info}function UD(e){if(8===e.data.byteLength){var t=new Uint8Array(e.data),i=1&t[3],n=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return n/=45,i&&(n+=47721858.84),Math.round(n)}}function HD(e){for(var t=BD(e),i=0;i<t.length;i++){var n=t[i];if(zD(n))return UD(n)}}var GD=function(e){return e.audioId3="org.id3",e.dateRange="com.apple.quicktime.HLS",e.emsg="https://aomedia.org/emsg/ID3",e.misbklv="urn:misb:KLV:bin:1910.1",e}({});function VD(e="",t=9e4){return{type:e,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}var KD=function(){return m(function e(){u(this,e),this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null},[{key:"resetInitSegment",value:function(e,t,i,n){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}},{key:"resetTimeStamp",value:function(e){this.initPTS=e,this.resetContiguity()}},{key:"resetContiguity",value:function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}},{key:"canParse",value:function(e,t){return!1}},{key:"appendFrame",value:function(e,t,i){}},{key:"demux",value:function(e,t){this.cachedData&&(e=qT(this.cachedData,e),this.cachedData=null);var i,n=AD(e,0),a=n?n.length:0,r=this._audioTrack,o=this._id3Track,s=n?HD(n):void 0,u=e.length;for((null===this.basePTS||0===this.frameIndex&&WE(s))&&(this.basePTS=XD(s,t,this.initPTS),this.lastPTS=this.basePTS),null===this.lastPTS&&(this.lastPTS=this.basePTS),n&&n.length>0&&o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:n,type:GD.audioId3,duration:Number.POSITIVE_INFINITY});a<u;){if(this.canParse(e,a)){var l=this.appendFrame(r,e,a);l?(this.frameIndex++,this.lastPTS=l.sample.pts,i=a+=l.length):a=u}else OD(e,a)?(n=AD(e,a),o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:n,type:GD.audioId3,duration:Number.POSITIVE_INFINITY}),i=a+=n.length):a++;if(a===u&&i!==u){var d=e.slice(i);this.cachedData?this.cachedData=qT(this.cachedData,d):this.cachedData=d}}return{audioTrack:r,videoTrack:VD(),id3Track:o,textTrack:VD()}}},{key:"demuxSampleAes",value:function(e,t,i){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}},{key:"flush",value:function(e){var t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:VD(),id3Track:this._id3Track,textTrack:VD()}}},{key:"destroy",value:function(){this.cachedData=null,this._audioTrack=this._id3Track=void 0}}])}(),XD=(e,t,i)=>WE(e)?90*e:9e4*t+(i?9e4*i.baseTime/i.timescale:0),YD=null,qD=[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],JD=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],QD=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],ZD=[0,1,1,4];function ex(e,t,i,n,a){if(!(i+24>t.length)){var r=tx(t,i);if(r&&i+r.frameLength<=t.length){var o=n+a*(9e4*r.samplesPerFrame/r.sampleRate),s={unit:t.subarray(i,i+r.frameLength),pts:o,dts:o};return e.config=[],e.channelCount=r.channelCount,e.samplerate=r.sampleRate,e.samples.push(s),{sample:s,length:r.frameLength,missing:0}}}}function tx(e,t){var i=e[t+1]>>3&3,n=e[t+1]>>1&3,a=e[t+2]>>4&15,r=e[t+2]>>2&3;if(1!==i&&0!==a&&15!==a&&3!==r){var o=e[t+2]>>1&1,s=e[t+3]>>6,u=1e3*qD[14*(3===i?3-n:3===n?3:4)+a-1],l=JD[3*(3===i?0:2===i?1:2)+r],d=3===s?1:2,h=QD[i][n],c=ZD[n],m=8*h*c,f=Math.floor(h*u/l+o)*c;if(null===YD){var v=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);YD=v?parseInt(v[1]):0}return!!YD&&YD<=87&&2===n&&u>=224e3&&0===s&&(e[t+3]=128|e[t+3]),{sampleRate:l,channelCount:d,frameLength:f,samplesPerFrame:m}}}function ix(e,t){return!(255!==e[t]||224&~e[t+1]||!(6&e[t+1]))}function nx(e,t){return t+1<e.length&&ix(e,t)}function ax(e,t){if(t+1<e.length&&ix(e,t)){var i=tx(e,t),n=4;null!=i&&i.frameLength&&(n=i.frameLength);var a=t+n;return a===e.length||nx(e,a)}return!1}var rx=function(){function e(t,i){var n;return u(this,e),(n=s(this,e)).observer=void 0,n.config=void 0,n.observer=t,n.config=i,n}return y(e,KD),m(e,[{key:"resetInitSegment",value:function(t,i,n,a){M(e,"resetInitSegment",this)([t,i,n,a]),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:i,duration:a,inputTimeScale:9e4,dropped:0}}},{key:"canParse",value:function(e,t){return function(e,t){return function(e,t){return t+5<e.length}(e,t)&&DD(e,t)&&CD(e,t)<=e.length-t}(e,t)}},{key:"appendFrame",value:function(e,t,i){_D(e,this.observer,t,i,e.manifestCodec);var n=FD(e,t,i,this.basePTS,this.frameIndex);if(n&&0===n.missing)return n}}],[{key:"probe",value:function(e,t){if(!e)return!1;var i=AD(e,0),n=(null==i?void 0:i.length)||0;if(ax(e,n))return!1;for(var a=e.length;n<a;n++)if(LD(e,n))return t.log("ADTS sync word found !"),!0;return!1}}])}(),ox=(e,t)=>{var i=0,n=5;t+=n;for(var a=new Uint32Array(1),r=new Uint32Array(1),o=new Uint8Array(1);n>0;){o[0]=e[t];var s=Math.min(n,8),u=8-s;r[0]=4278190080>>>24+u<<u,a[0]=(o[0]&r[0])>>u,i=i?i<<s|a[0]:a[0],t+=1,n-=s}return i},sx=function(){function e(t){var i;return u(this,e),(i=s(this,e)).observer=void 0,i.observer=t,i}return y(e,KD),m(e,[{key:"resetInitSegment",value:function(t,i,n,a){M(e,"resetInitSegment",this)([t,i,n,a]),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:i,duration:a,inputTimeScale:9e4,dropped:0}}},{key:"canParse",value:function(e,t){return t+64<e.length}},{key:"appendFrame",value:function(e,t,i){var n=ux(e,t,i,this.basePTS,this.frameIndex);if(-1!==n)return{sample:e.samples[e.samples.length-1],length:n,missing:0}}}],[{key:"probe",value:function(e){if(!e)return!1;var t=AD(e,0);if(!t)return!1;var i=t.length;return 11===e[i]&&119===e[i+1]&&void 0!==HD(t)&&ox(e,i)<16}}])}();function ux(e,t,i,n,a){if(i+8>t.length)return-1;if(11!==t[i]||119!==t[i+1])return-1;var r=t[i+4]>>6;if(r>=3)return-1;var o=[48e3,44100,32e3][r],s=63&t[i+4],u=2*[64,69,96,64,70,96,80,87,120,80,88,120,96,104,144,96,105,144,112,121,168,112,122,168,128,139,192,128,140,192,160,174,240,160,175,240,192,208,288,192,209,288,224,243,336,224,244,336,256,278,384,256,279,384,320,348,480,320,349,480,384,417,576,384,418,576,448,487,672,448,488,672,512,557,768,512,558,768,640,696,960,640,697,960,768,835,1152,768,836,1152,896,975,1344,896,976,1344,1024,1114,1536,1024,1115,1536,1152,1253,1728,1152,1254,1728,1280,1393,1920,1280,1394,1920][3*s+r];if(i+u>t.length)return-1;var l=t[i+6]>>5,d=0;2===l?d+=2:(1&l&&1!==l&&(d+=2),4&l&&(d+=2));var h=(t[i+6]<<8|t[i+7])>>12-d&1,c=[2,1,2,3,3,4,4,5][l]+h,m=t[i+5]>>3,f=7&t[i+5],v=new Uint8Array([r<<6|m<<1|f>>2,(3&f)<<6|l<<3|h<<2|s>>4,s<<4&224]),p=n+a*(1536/o*9e4),g=t.subarray(i,i+u);return e.config=v,e.channelCount=c,e.samplerate=o,e.samples.push({unit:g,pts:p}),u}var lx=function(){function e(){return u(this,e),s(this,e,arguments)}return y(e,KD),m(e,[{key:"resetInitSegment",value:function(t,i,n,a){M(e,"resetInitSegment",this)([t,i,n,a]),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:i,duration:a,inputTimeScale:9e4,dropped:0}}},{key:"canParse",value:function(e,t){return function(e,t){return ix(e,t)&&4<=e.length-t}(e,t)}},{key:"appendFrame",value:function(e,t,i){if(null!==this.basePTS)return ex(e,t,i,this.basePTS,this.frameIndex)}}],[{key:"probe",value:function(e){if(!e)return!1;var t=AD(e,0),i=(null==t?void 0:t.length)||0;if(t&&11===e[i]&&119===e[i+1]&&void 0!==HD(t)&&ox(e,i)<=16)return!1;for(var n=e.length;i<n;i++)if(ax(e,i))return uT.log("MPEG Audio sync word found !"),!0;return!1}}])}(),dx=/\/emsg[-/]ID3/i,hx=function(){return m(function e(t,i){u(this,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=i},[{key:"resetTimeStamp",value:function(){}},{key:"resetInitSegment",value:function(e,t,i,n){var a=this.videoTrack=VD("video",1),r=this.audioTrack=VD("audio",1),o=this.txtTrack=VD("text",1);if(this.id3Track=VD("id3",1),this.timeOffset=0,null!=e&&e.byteLength){var s=zT(e);if(s.video){var u=s.video,l=u.id,d=u.timescale,h=u.codec,c=u.supplemental;a.id=l,a.timescale=o.timescale=d,a.codec=h,a.supplemental=c}if(s.audio){var m=s.audio,f=m.id,v=m.timescale,p=m.codec;r.id=f,r.timescale=v,r.codec=p}o.id=RT.text,a.sampleDuration=0,a.duration=r.duration=n}}},{key:"resetContiguity",value:function(){this.remainderData=null}},{key:"demux",value:function(e,t){this.timeOffset=t;var i=e,n=this.videoTrack,a=this.txtTrack;if(this.config.progressive){this.remainderData&&(i=qT(this.remainderData,e));var r=function(e){var t={valid:null,remainder:null},i=jT(e,["moof"]);if(i.length<2)return t.remainder=e,t;var n=i[i.length-1];return t.valid=e.slice(0,n.byteOffset-8),t.remainder=e.slice(n.byteOffset-8),t}(i);this.remainderData=r.remainder,n.samples=r.valid||new Uint8Array}else n.samples=i;var o=this.extractID3Track(n,t);return a.samples=JT(t,n),{videoTrack:n,audioTrack:this.audioTrack,id3Track:o,textTrack:this.txtTrack}}},{key:"flush",value:function(){var e=this.timeOffset,t=this.videoTrack,i=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;var n=this.extractID3Track(t,this.timeOffset);return i.samples=JT(e,t),{videoTrack:t,audioTrack:VD(),id3Track:n,textTrack:VD()}}},{key:"extractID3Track",value:function(e,t){var i=this.id3Track;if(e.samples.length){var n=jT(e.samples,["emsg"]);n&&n.forEach(e=>{var n=function(e){var t=e[0],i="",n="",a=0,r=0,o=0,s=0,u=0,l=0;if(0===t){for(;"\0"!==FT(e.subarray(l,l+1));)i+=FT(e.subarray(l,l+1)),l+=1;for(i+=FT(e.subarray(l,l+1)),l+=1;"\0"!==FT(e.subarray(l,l+1));)n+=FT(e.subarray(l,l+1)),l+=1;n+=FT(e.subarray(l,l+1)),l+=1,a=WT(e,12),r=WT(e,16),s=WT(e,20),u=WT(e,24),l=28}else if(1===t){a=WT(e,l+=4);var d=WT(e,l+=4),h=WT(e,l+=4);for(l+=4,$E(o=2**32*d+h)||(o=Number.MAX_SAFE_INTEGER,uT.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),s=WT(e,l),u=WT(e,l+=4),l+=4;"\0"!==FT(e.subarray(l,l+1));)i+=FT(e.subarray(l,l+1)),l+=1;for(i+=FT(e.subarray(l,l+1)),l+=1;"\0"!==FT(e.subarray(l,l+1));)n+=FT(e.subarray(l,l+1)),l+=1;n+=FT(e.subarray(l,l+1)),l+=1}return{schemeIdUri:i,value:n,timeScale:a,presentationTime:o,presentationTimeDelta:r,eventDuration:s,id:u,payload:e.subarray(l,e.byteLength)}}(e);if(dx.test(n.schemeIdUri)){var a=cx(n,t),r=4294967295===n.eventDuration?Number.POSITIVE_INFINITY:n.eventDuration/n.timeScale;r<=.001&&(r=Number.POSITIVE_INFINITY);var o=n.payload;i.samples.push({data:o,len:o.byteLength,dts:a,pts:a,type:GD.emsg,duration:r})}else if(this.config.enableEmsgKLVMetadata&&n.schemeIdUri.startsWith("urn:misb:KLV:bin:1910.1")){var s=cx(n,t);i.samples.push({data:n.payload,len:n.payload.byteLength,dts:s,pts:s,type:GD.misbklv,duration:Number.POSITIVE_INFINITY})}})}return i}},{key:"demuxSampleAes",value:function(e,t,i){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}},{key:"destroy",value:function(){this.config=null,this.remainderData=null,this.videoTrack=this.audioTrack=this.id3Track=this.txtTrack=void 0}}],[{key:"probe",value:function(e){return function(e){for(var t=e.byteLength,i=0;i<t;){var n=WT(e,i);if(n>8&&109===e[i+4]&&111===e[i+5]&&111===e[i+6]&&102===e[i+7])return!0;i=n>1?i+n:t}return!1}(e)}}])}();function cx(e,t){return WE(e.presentationTime)?e.presentationTime/e.timeScale:t+e.presentationTimeDelta/e.timeScale}var mx=function(){return m(function e(t,i,n){u(this,e),this.keyData=void 0,this.decrypter=void 0,this.keyData=n,this.decrypter=new DM(i,{removePKCS7Padding:!1})},[{key:"decryptBuffer",value:function(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer,EM)}},{key:"decryptAacSample",value:function(e,t,i){var n=e[t].unit;if(!(n.length<=16)){var a=n.subarray(16,n.length-n.length%16),r=a.buffer.slice(a.byteOffset,a.byteOffset+a.length);this.decryptBuffer(r).then(a=>{var r=new Uint8Array(a);n.set(r,16),this.decrypter.isSync()||this.decryptAacSamples(e,t+1,i)}).catch(i)}}},{key:"decryptAacSamples",value:function(e,t,i){for(;;t++){if(t>=e.length)return void i();if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,i),!this.decrypter.isSync()))return}}},{key:"getAvcEncryptedData",value:function(e){for(var t=16*Math.floor((e.length-48)/160)+16,i=new Int8Array(t),n=0,a=32;a<e.length-16;a+=160,n+=16)i.set(e.subarray(a,a+16),n);return i}},{key:"getAvcDecryptedUnit",value:function(e,t){for(var i=new Uint8Array(t),n=0,a=32;a<e.length-16;a+=160,n+=16)e.set(i.subarray(n,n+16),a);return e}},{key:"decryptAvcSample",value:function(e,t,i,n,a){var r=tP(a.data),o=this.getAvcEncryptedData(r);this.decryptBuffer(o.buffer).then(o=>{a.data=this.getAvcDecryptedUnit(r,o),this.decrypter.isSync()||this.decryptAvcSamples(e,t,i+1,n)}).catch(n)}},{key:"decryptAvcSamples",value:function(e,t,i,n){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,i=0){if(t>=e.length)return void n();for(var a=e[t].units;!(i>=a.length);i++){var r=a[i];if(!(r.data.length<=48||1!==r.type&&5!==r.type||(this.decryptAvcSample(e,t,i,n,r),this.decrypter.isSync())))return}}}}])}(),fx=function(){return m(function e(){u(this,e),this.VideoSample=null},[{key:"createVideoSample",value:function(e,t,i){return{key:e,frame:!1,pts:t,dts:i,units:[],length:0}}},{key:"getLastNalUnit",value:function(e){var t,i,n=this.VideoSample;if(n&&0!==n.units.length||(n=e[e.length-1]),null!=(t=n)&&t.units){var a=n.units;i=a[a.length-1]}return i}},{key:"pushAccessUnit",value:function(e,t){if(e.units.length&&e.frame){if(void 0===e.pts){var i=t.samples,n=i.length;if(!n)return void t.dropped++;var a=i[n-1];e.pts=a.pts,e.dts=a.dts}t.samples.push(e)}}},{key:"parseNALu",value:function(e,t,i){var n,a,r=t.byteLength,o=e.naluState||0,s=o,u=[],l=0,d=-1,h=0;for(-1===o&&(d=0,h=this.getNALuType(t,0),o=0,l=1);l<r;)if(n=t[l++],o)if(1!==o)if(n)if(1===n){if(a=l-o-1,d>=0){var c={data:t.subarray(d,a),type:h};u.push(c)}else{var m=this.getLastNalUnit(e.samples);m&&(s&&l<=4-s&&m.state&&(m.data=m.data.subarray(0,m.data.byteLength-s)),a>0&&(m.data=qT(m.data,t.subarray(0,a)),m.state=0))}l<r?(d=l,h=this.getNALuType(t,l),o=0):o=-1}else o=0;else o=3;else o=n?0:2;else o=n?0:1;if(d>=0&&o>=0){var f={data:t.subarray(d,r),type:h,state:o};u.push(f)}if(0===u.length){var v=this.getLastNalUnit(e.samples);v&&(v.data=qT(v.data,t))}return e.naluState=o,u}}])}(),vx=function(){return m(function e(t){u(this,e),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},[{key:"loadWord",value:function(){var e=this.data,t=this.bytesAvailable,i=e.byteLength-t,n=new Uint8Array(4),a=Math.min(4,t);if(0===a)throw new Error("no bytes available");n.set(e.subarray(i,i+a)),this.word=new DataView(n.buffer).getUint32(0),this.bitsAvailable=8*a,this.bytesAvailable-=a}},{key:"skipBits",value:function(e){var t;e=Math.min(e,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,e-=(t=e>>3)<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}},{key:"readBits",value:function(e){var t=Math.min(this.bitsAvailable,e),i=this.word>>>32-t;if(e>32&&uT.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return(t=e-t)>0&&this.bitsAvailable?i<<t|this.readBits(t):i}},{key:"skipLZ",value:function(){var e;for(e=0;e<this.bitsAvailable;++e)if(this.word&2147483648>>>e)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}},{key:"skipUEG",value:function(){this.skipBits(1+this.skipLZ())}},{key:"skipEG",value:function(){this.skipBits(1+this.skipLZ())}},{key:"readUEG",value:function(){var e=this.skipLZ();return this.readBits(e+1)-1}},{key:"readEG",value:function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}},{key:"readBoolean",value:function(){return 1===this.readBits(1)}},{key:"readUByte",value:function(){return this.readBits(8)}},{key:"readUShort",value:function(){return this.readBits(16)}},{key:"readUInt",value:function(){return this.readBits(32)}}])}(),px=function(){function e(){return u(this,e),s(this,e,arguments)}return y(e,fx),m(e,[{key:"parsePES",value:function(e,t,i,n){var a,r=this.parseNALu(e,i.data,n),o=this.VideoSample,s=!1;i.data=null,o&&r.length&&!e.audFound&&(this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts)),r.forEach(n=>{var r,u;switch(n.type){case 1:var l=!1;a=!0;var d,h=n.data;if(s&&h.length>4){var c=this.readSliceType(h);2!==c&&4!==c&&7!==c&&9!==c||(l=!0)}if(l)null!=(d=o)&&d.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null);o||(o=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),o.frame=!0,o.key=l;break;case 5:a=!0,null!=(r=o)&&r.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null),o||(o=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),o.key=!0,o.frame=!0;break;case 6:a=!0,eP(n.data,1,i.pts,t.samples);break;case 7:var m,f;a=!0,s=!0;var v=n.data,p=this.readSPS(v);if(!e.sps||e.width!==p.width||e.height!==p.height||(null==(m=e.pixelRatio)?void 0:m[0])!==p.pixelRatio[0]||(null==(f=e.pixelRatio)?void 0:f[1])!==p.pixelRatio[1]){e.width=p.width,e.height=p.height,e.pixelRatio=p.pixelRatio,e.sps=[v];for(var g=v.subarray(1,4),y="avc1.",b=0;b<3;b++){var w=g[b].toString(16);w.length<2&&(w="0"+w),y+=w}e.codec=y}break;case 8:a=!0,e.pps=[n.data];break;case 9:a=!0,e.audFound=!0,null!=(u=o)&&u.frame&&(this.pushAccessUnit(o,e),o=null),o||(o=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts));break;case 12:a=!0;break;default:a=!1}o&&a&&o.units.push(n)}),n&&o&&(this.pushAccessUnit(o,e),this.VideoSample=null)}},{key:"getNALuType",value:function(e,t){return 31&e[t]}},{key:"readSliceType",value:function(e){var t=new vx(e);return t.readUByte(),t.readUEG(),t.readUEG()}},{key:"skipScalingList",value:function(e,t){for(var i=8,n=8,a=0;a<e;a++)0!==n&&(n=(i+t.readEG()+256)%256),i=0===n?i:n}},{key:"readSPS",value:function(e){var t,i,n,a=new vx(e),r=0,o=0,s=0,u=0,l=a.readUByte.bind(a),d=a.readBits.bind(a),h=a.readUEG.bind(a),c=a.readBoolean.bind(a),m=a.skipBits.bind(a),f=a.skipEG.bind(a),v=a.skipUEG.bind(a),p=this.skipScalingList.bind(this);l();var g=l();if(d(5),m(3),l(),v(),100===g||110===g||122===g||244===g||44===g||83===g||86===g||118===g||128===g){var y=h();if(3===y&&m(1),v(),v(),m(1),c())for(i=3!==y?8:12,n=0;n<i;n++)c()&&p(n<6?16:64,a)}v();var b=h();if(0===b)h();else if(1===b)for(m(1),f(),f(),t=h(),n=0;n<t;n++)f();v(),m(1);var w=h(),k=h(),S=d(1);0===S&&m(1),m(1),c()&&(r=h(),o=h(),s=h(),u=h());var E=[1,1];if(c()&&c())switch(l()){case 1:E=[1,1];break;case 2:E=[12,11];break;case 3:E=[10,11];break;case 4:E=[16,11];break;case 5:E=[40,33];break;case 6:E=[24,11];break;case 7:E=[20,11];break;case 8:E=[32,11];break;case 9:E=[80,33];break;case 10:E=[18,11];break;case 11:E=[15,11];break;case 12:E=[64,33];break;case 13:E=[160,99];break;case 14:E=[4,3];break;case 15:E=[3,2];break;case 16:E=[2,1];break;case 255:E=[l()<<8|l(),l()<<8|l()]}return{width:Math.ceil(16*(w+1)-2*r-2*o),height:(2-S)*(k+1)*16-(S?2:4)*(s+u),pixelRatio:E}}}])}(),gx=function(){function e(...t){var i;return u(this,e),(i=s(this,e,[...t])).initVPS=null,i}return y(e,fx),m(e,[{key:"parsePES",value:function(e,t,i,n){var a,r=this.parseNALu(e,i.data,n),o=this.VideoSample,s=!1;i.data=null,o&&r.length&&!e.audFound&&(this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts)),r.forEach(n=>{var r,u;switch(n.type){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:o||(o=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts)),o.frame=!0,a=!0;break;case 16:case 17:case 18:case 21:var l;if(a=!0,s)null!=(l=o)&&l.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null);o||(o=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),o.key=!0,o.frame=!0;break;case 19:case 20:a=!0,null!=(r=o)&&r.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null),o||(o=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),o.key=!0,o.frame=!0;break;case 39:a=!0,eP(n.data,2,i.pts,t.samples);break;case 32:a=!0,e.vps||("object"!=typeof e.params&&(e.params={}),e.params=ZE(e.params,this.readVPS(n.data)),this.initVPS=n.data),e.vps=[n.data];break;case 33:if(a=!0,s=!0,void 0===e.vps||e.vps[0]===this.initVPS||void 0===e.sps||this.matchSPS(e.sps[0],n.data)||(this.initVPS=e.vps[0],e.sps=e.pps=void 0),!e.sps){var d=this.readSPS(n.data);for(var h in e.width=d.width,e.height=d.height,e.pixelRatio=d.pixelRatio,e.codec=d.codecString,e.sps=[],"object"!=typeof e.params&&(e.params={}),d.params)e.params[h]=d.params[h]}this.pushParameterSet(e.sps,n.data,e.vps),o||(o=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),o.key=!0;break;case 34:if(a=!0,"object"==typeof e.params){if(!e.pps){e.pps=[];var c=this.readPPS(n.data);for(var m in c)e.params[m]=c[m]}this.pushParameterSet(e.pps,n.data,e.vps)}break;case 35:a=!0,e.audFound=!0,null!=(u=o)&&u.frame&&(this.pushAccessUnit(o,e),o=null),o||(o=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts));break;default:a=!1}o&&a&&o.units.push(n)}),n&&o&&(this.pushAccessUnit(o,e),this.VideoSample=null)}},{key:"pushParameterSet",value:function(e,t,i){(i&&i[0]===this.initVPS||!i&&!e.length)&&e.push(t)}},{key:"getNALuType",value:function(e,t){return(126&e[t])>>>1}},{key:"ebsp2rbsp",value:function(e){for(var t=new Uint8Array(e.byteLength),i=0,n=0;n<e.byteLength;n++)n>=2&&3===e[n]&&0===e[n-1]&&0===e[n-2]||(t[i]=e[n],i++);return new Uint8Array(t.buffer,0,i)}},{key:"pushAccessUnit",value:function(t,i){M(e,"pushAccessUnit",this)([t,i]),this.initVPS&&(this.initVPS=null)}},{key:"readVPS",value:function(e){var t=new vx(e);return t.readUByte(),t.readUByte(),t.readBits(4),t.skipBits(2),t.readBits(6),{numTemporalLayers:t.readBits(3)+1,temporalIdNested:t.readBoolean()}}},{key:"readSPS",value:function(e){var t=new vx(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.readBits(4);var i=t.readBits(3);t.readBoolean();for(var n=t.readBits(2),a=t.readBoolean(),r=t.readBits(5),o=t.readUByte(),s=t.readUByte(),u=t.readUByte(),l=t.readUByte(),d=t.readUByte(),h=t.readUByte(),c=t.readUByte(),m=t.readUByte(),f=t.readUByte(),v=t.readUByte(),p=t.readUByte(),g=[],y=[],b=0;b<i;b++)g.push(t.readBoolean()),y.push(t.readBoolean());if(i>0)for(var w=i;w<8;w++)t.readBits(2);for(var k=0;k<i;k++)g[k]&&(t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte()),y[k]&&t.readUByte();t.readUEG();var S=t.readUEG();3==S&&t.skipBits(1);var E=t.readUEG(),T=t.readUEG(),P=t.readBoolean(),M=0,A=0,D=0,x=0;P&&(M+=t.readUEG(),A+=t.readUEG(),D+=t.readUEG(),x+=t.readUEG());for(var C=t.readUEG(),I=t.readUEG(),L=t.readUEG(),_=t.readBoolean()?0:i;_<=i;_++)t.skipUEG(),t.skipUEG(),t.skipUEG();if((t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.readBoolean())&&t.readBoolean())for(var R=0;R<4;R++)for(var F=0;F<(3===R?2:6);F++){if(t.readBoolean()){var O=Math.min(64,1<<4+(R<<1));R>1&&t.readEG();for(var W=0;W<O;W++)t.readEG()}else t.readUEG()}t.readBoolean(),t.readBoolean(),t.readBoolean()&&(t.readUByte(),t.skipUEG(),t.skipUEG(),t.readBoolean());for(var $=t.readUEG(),N=0,j=0;j<$;j++){var B=!1;if(0!==j&&(B=t.readBoolean()),B){j===$&&t.readUEG(),t.readBoolean(),t.readUEG();for(var z=0,U=0;U<=N;U++){var H=t.readBoolean(),G=!1;H||(G=t.readBoolean()),(H||G)&&z++}N=z}else{var V=t.readUEG(),K=t.readUEG();N=V+K;for(var X=0;X<V;X++)t.readUEG(),t.readBoolean();for(var Y=0;Y<K;Y++)t.readUEG(),t.readBoolean()}}if(t.readBoolean())for(var q=t.readUEG(),J=0;J<q;J++){for(var Q=0;Q<L+4;Q++)t.readBits(1);t.readBits(1)}var Z=0,ee=1,te=1,ie=!0,ne=1,ae=0;t.readBoolean(),t.readBoolean();if(t.readBoolean()){if(t.readBoolean()){var re=t.readUByte();re>0&&re<16?(ee=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2][re-1],te=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1][re-1]):255===re&&(ee=t.readBits(16),te=t.readBits(16))}if(t.readBoolean()&&t.readBoolean(),t.readBoolean())t.readBits(3),t.readBoolean(),t.readBoolean()&&(t.readUByte(),t.readUByte(),t.readUByte());if(t.readBoolean()&&(t.readUEG(),t.readUEG()),t.readBoolean(),t.readBoolean(),t.readBoolean(),t.readBoolean()&&(t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG()),t.readBoolean())if(ne=t.readBits(32),ae=t.readBits(32),t.readBoolean()&&t.readUEG(),t.readBoolean()){var oe=t.readBoolean(),se=t.readBoolean(),ue=!1;(oe||se)&&((ue=t.readBoolean())&&(t.readUByte(),t.readBits(5),t.readBoolean(),t.readBits(5)),t.readBits(4),t.readBits(4),ue&&t.readBits(4),t.readBits(5),t.readBits(5),t.readBits(5));for(var le=0;le<=i;le++){var de=!1;(ie=t.readBoolean())||t.readBoolean()?t.readEG():de=t.readBoolean();var he=de?1:t.readUEG()+1;if(oe)for(var ce=0;ce<he;ce++)t.readUEG(),t.readUEG(),ue&&(t.readUEG(),t.readUEG()),t.skipBits(1);if(se)for(var me=0;me<he;me++)t.readUEG(),t.readUEG(),ue&&(t.readUEG(),t.readUEG()),t.skipBits(1)}}t.readBoolean()&&(t.readBoolean(),t.readBoolean(),t.readBoolean(),Z=t.readUEG())}var fe=E,ve=T;if(P){var pe=1,ge=1;1===S?pe=ge=2:2==S&&(pe=2),fe=E-pe*A-pe*M,ve=T-ge*x-ge*D}for(var ye=n?["A","B","C"][n]:"",be=o<<24|s<<16|u<<8|l,we=0,ke=0;ke<32;ke++)we=(we|(be>>ke&1)<<31-ke)>>>0;var Se=we.toString(16);return 1===r&&"2"===Se&&(Se="6"),{codecString:`hvc1.${ye}${r}.${Se}.${a?"H":"L"}${p}.B0`,params:{general_tier_flag:a,general_profile_idc:r,general_profile_space:n,general_profile_compatibility_flags:[o,s,u,l],general_constraint_indicator_flags:[d,h,c,m,f,v],general_level_idc:p,bit_depth:C+8,bit_depth_luma_minus8:C,bit_depth_chroma_minus8:I,min_spatial_segmentation_idc:Z,chroma_format_idc:S,frame_rate:{fixed:ie,fps:ae/ne}},width:fe,height:ve,pixelRatio:[ee,te]}}},{key:"readPPS",value:function(e){var t=new vx(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.skipUEG(),t.skipUEG(),t.skipBits(2),t.skipBits(3),t.skipBits(2),t.skipUEG(),t.skipUEG(),t.skipEG(),t.skipBits(2),t.readBoolean()&&t.skipUEG(),t.skipEG(),t.skipEG(),t.skipBits(4);var i=t.readBoolean(),n=t.readBoolean(),a=1;return n&&i?a=0:n?a=3:i&&(a=2),{parallelismType:a}}},{key:"matchSPS",value:function(e,t){return String.fromCharCode.apply(null,e).substr(3)===String.fromCharCode.apply(null,t).substr(3)}}])}(),yx=188,bx=function(){function e(t,i,n,a){u(this,e),this.logger=void 0,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._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=t,this.config=i,this.typeSupported=n,this.logger=a,this.videoParser=null}return m(e,[{key:"resetInitSegment",value:function(t,i,n,a){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=e.createTrack("video"),this._videoTrack.duration=a,this._audioTrack=e.createTrack("audio",a),this._id3Track=e.createTrack("id3"),this._txtTrack=e.createTrack("text"),this._audioTrack.segmentCodec="aac",this.videoParser=null,this.aacOverFlow=null,this.remainderData=null,this.audioCodec=i,this.videoCodec=n}},{key:"resetTimeStamp",value:function(){}},{key:"resetContiguity",value:function(){var e=this._audioTrack,t=this._videoTrack,i=this._id3Track;e&&(e.pesData=null),t&&(t.pesData=null),i&&(i.pesData=null),this.aacOverFlow=null,this.remainderData=null}},{key:"demux",value:function(t,i,n=!1,a=!1){var r;n||(this.sampleAes=null);var o=this._videoTrack,s=this._audioTrack,u=this._id3Track,l=this._txtTrack,d=o.pid,h=o.pesData,c=s.pid,m=u.pid,f=s.pesData,v=u.pesData,p=null,g=this.pmtParsed,y=this._pmtId,b=t.length;if(this.remainderData&&(b=(t=qT(this.remainderData,t)).length,this.remainderData=null),b<yx&&!a)return this.remainderData=t,{audioTrack:s,videoTrack:o,id3Track:u,textTrack:l};var w=Math.max(0,e.syncOffset(t));(b-=(b-w)%yx)<t.byteLength&&!a&&(this.remainderData=new Uint8Array(t.buffer,b,t.buffer.byteLength-b));for(var k=0,S=w;S<b;S+=yx)if(71===t[S]){var E=!!(64&t[S+1]),T=wx(t,S),P=void 0;if((48&t[S+3])>>4>1){if((P=S+5+t[S+4])===S+yx)continue}else P=S+4;switch(T){case d:E&&(h&&(r=Px(h,this.logger))&&(this.readyVideoParser(o.segmentCodec),null!==this.videoParser&&this.videoParser.parsePES(o,l,r,!1)),h={data:[],size:0}),h&&(h.data.push(t.subarray(P,S+yx)),h.size+=S+yx-P);break;case c:if(E){if(f&&(r=Px(f,this.logger)))switch(s.segmentCodec){case"aac":this.parseAACPES(s,r);break;case"mp3":this.parseMPEGPES(s,r);break;case"ac3":this.parseAC3PES(s,r)}f={data:[],size:0}}f&&(f.data.push(t.subarray(P,S+yx)),f.size+=S+yx-P);break;case m:E&&(v&&(r=Px(v,this.logger))&&this.parseID3PES(u,r),v={data:[],size:0}),v&&(v.data.push(t.subarray(P,S+yx)),v.size+=S+yx-P);break;case 0:E&&(P+=t[P]+1),y=this._pmtId=kx(t,P);break;case y:E&&(P+=t[P]+1);var M=Sx(t,P,this.typeSupported,n,this.observer,this.logger);(d=M.videoPid)>0&&(o.pid=d,o.segmentCodec=M.segmentVideoCodec),(c=M.audioPid)>0&&(s.pid=c,s.segmentCodec=M.segmentAudioCodec),(m=M.id3Pid)>0&&(u.pid=m),null===p||g||(this.logger.warn(`MPEG-TS PMT found at ${S} after unknown PID '${p}'. Backtracking to sync byte @${w} to parse all TS packets.`),p=null,S=w-188),g=this.pmtParsed=!0;break;case 17:case 8191:break;default:p=T}}else k++;k>0&&Ex(this.observer,new Error(`Found ${k} TS packet/s that do not start with 0x47`),void 0,this.logger),o.pesData=h,s.pesData=f,u.pesData=v;var A={audioTrack:s,videoTrack:o,id3Track:u,textTrack:l};return a&&this.extractRemainingSamples(A),A}},{key:"flush",value:function(){var e,t=this.remainderData;return this.remainderData=null,e=t?this.demux(t,-1,!1,!0):{videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(e),this.sampleAes?this.decrypt(e,this.sampleAes):e}},{key:"extractRemainingSamples",value:function(e){var t,i=e.audioTrack,n=e.videoTrack,a=e.id3Track,r=e.textTrack,o=n.pesData,s=i.pesData,u=a.pesData;if(o&&(t=Px(o,this.logger))?(this.readyVideoParser(n.segmentCodec),null!==this.videoParser&&(this.videoParser.parsePES(n,r,t,!0),n.pesData=null)):n.pesData=o,s&&(t=Px(s,this.logger))){switch(i.segmentCodec){case"aac":this.parseAACPES(i,t);break;case"mp3":this.parseMPEGPES(i,t);break;case"ac3":this.parseAC3PES(i,t)}i.pesData=null}else null!=s&&s.size&&this.logger.log("last AAC PES packet truncated,might overlap between fragments"),i.pesData=s;u&&(t=Px(u,this.logger))?(this.parseID3PES(a,t),a.pesData=null):a.pesData=u}},{key:"demuxSampleAes",value:function(e,t,i){var n=this.demux(e,i,!0,!this.config.progressive),a=this.sampleAes=new mx(this.observer,this.config,t);return this.decrypt(n,a)}},{key:"readyVideoParser",value:function(e){null===this.videoParser&&("avc"===e?this.videoParser=new px:"hevc"===e&&(this.videoParser=new gx))}},{key:"decrypt",value:function(e,t){return new Promise(i=>{var n=e.audioTrack,a=e.videoTrack;n.samples&&"aac"===n.segmentCodec?t.decryptAacSamples(n.samples,0,()=>{a.samples?t.decryptAvcSamples(a.samples,0,0,()=>{i(e)}):i(e)}):a.samples&&t.decryptAvcSamples(a.samples,0,0,()=>{i(e)})})}},{key:"destroy",value:function(){this.observer&&this.observer.removeAllListeners(),this.config=this.logger=this.observer=null,this.aacOverFlow=this.videoParser=this.remainderData=this.sampleAes=null,this._videoTrack=this._audioTrack=this._id3Track=this._txtTrack=void 0}},{key:"parseAACPES",value:function(e,t){var i,n,a,r=0,o=this.aacOverFlow,s=t.data;if(o){this.aacOverFlow=null;var u=o.missing,l=o.sample.unit.byteLength;if(-1===u)s=qT(o.sample.unit,s);else{var d=l-u;o.sample.unit.set(s.subarray(0,u),d),e.samples.push(o.sample),r=o.missing}}for(i=r,n=s.length;i<n-1&&!ID(s,i);i++);if(i!==r){var h,c=i<n-1;if(h=c?`AAC PES did not start with ADTS header,offset:${i}`:"No ADTS header found in AAC PES",Ex(this.observer,new Error(h),c,this.logger),!c)return}if(_D(e,this.observer,s,i,this.audioCodec),void 0!==t.pts)a=t.pts;else{if(!o)return void this.logger.warn("[tsdemuxer]: AAC PES unknown PTS");var m=RD(e.samplerate);a=o.sample.pts+m}for(var f,v=0;i<n;){if(i+=(f=FD(e,s,i,a,v)).length,f.missing){this.aacOverFlow=f;break}for(v++;i<n-1&&!ID(s,i);i++);}}},{key:"parseMPEGPES",value:function(e,t){var i=t.data,n=i.length,a=0,r=0,o=t.pts;if(void 0!==o)for(;r<n;)if(nx(i,r)){var s=ex(e,i,r,o,a);if(!s)break;r+=s.length,a++}else r++;else this.logger.warn("[tsdemuxer]: MPEG PES unknown PTS")}},{key:"parseAC3PES",value:function(e,t){var i=t.data,n=t.pts;if(void 0!==n)for(var a,r=i.length,o=0,s=0;s<r&&(a=ux(e,i,s,n,o++))>0;)s+=a;else this.logger.warn("[tsdemuxer]: AC3 PES unknown PTS")}},{key:"parseID3PES",value:function(e,t){if(void 0!==t.pts){var i=ZE({},t,{type:this._videoTrack?GD.emsg:GD.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(i)}else this.logger.warn("[tsdemuxer]: ID3 PES unknown PTS")}}],[{key:"probe",value:function(t,i){var n=e.syncOffset(t);return n>0&&i.warn(`MPEG2-TS detected but first sync word found @ offset ${n}`),-1!==n}},{key:"syncOffset",value:function(e){for(var t=e.length,i=Math.min(940,t-yx)+1,n=0;n<i;){for(var a=!1,r=-1,o=0,s=n;s<t;s+=yx){if(71!==e[s]||t-s!==yx&&71!==e[s+yx]){if(o)return-1;break}if(o++,-1===r&&0!==(r=s)&&(i=Math.min(r+18612,e.length-yx)+1),a||(a=0===wx(e,s)),a&&o>1&&(0===r&&o>2||s+yx>i))return r}n++}return-1}},{key:"createTrack",value:function(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:RT[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===e?t:void 0}}}])}();function wx(e,t){return((31&e[t+1])<<8)+e[t+2]}function kx(e,t){return(31&e[t+10])<<8|e[t+11]}function Sx(e,t,i,n,a,r){var o={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},s=t+3+((15&e[t+1])<<8|e[t+2])-4;for(t+=12+((15&e[t+10])<<8|e[t+11]);t<s;){var u=wx(e,t),l=(15&e[t+3])<<8|e[t+4];switch(e[t]){case 207:if(!n){Tx("ADTS AAC",r);break}case 15:-1===o.audioPid&&(o.audioPid=u);break;case 21:-1===o.id3Pid&&(o.id3Pid=u);break;case 219:if(!n){Tx("H.264",r);break}case 27:-1===o.videoPid&&(o.videoPid=u);break;case 3:case 4:i.mpeg||i.mp3?-1===o.audioPid&&(o.audioPid=u,o.segmentAudioCodec="mp3"):r.log("MPEG audio found, not supported in this browser");break;case 193:if(!n){Tx("AC-3",r);break}case 129:i.ac3?-1===o.audioPid&&(o.audioPid=u,o.segmentAudioCodec="ac3"):r.log("AC-3 audio found, not supported in this browser");break;case 6:if(-1===o.audioPid&&l>0)for(var d=t+5,h=l;h>2;){if(106===e[d])!0!==i.ac3?r.log("AC-3 audio found, not supported in this browser for now"):(o.audioPid=u,o.segmentAudioCodec="ac3");var c=e[d+1]+2;d+=c,h-=c}break;case 194:case 135:return Ex(a,new Error("Unsupported EC-3 in M2TS found"),void 0,r),o;case 36:-1===o.videoPid&&(o.videoPid=u,o.segmentVideoCodec="hevc",r.log("HEVC in M2TS found"))}t+=l+5}return o}function Ex(e,t,i,n){n.warn(`parsing error: ${t.message}`),e.emit(zE.ERROR,zE.ERROR,{type:jE.MEDIA_ERROR,details:BE.FRAG_PARSING_ERROR,fatal:!1,levelRetry:i,error:t,reason:t.message})}function Tx(e,t){t.log(`${e} with AES-128-CBC encryption found in unencrypted stream`)}function Px(e,t){var i,n,a,r,o,s=0,u=e.data;if(!e||0===e.size)return null;for(;u[0].length<19&&u.length>1;)u[0]=qT(u[0],u[1]),u.splice(1,1);if(1===((i=u[0])[0]<<16)+(i[1]<<8)+i[2]){if((n=(i[4]<<8)+i[5])&&n>e.size-6)return null;var l=i[7];192&l&&(r=536870912*(14&i[9])+4194304*(255&i[10])+16384*(254&i[11])+128*(255&i[12])+(254&i[13])/2,64&l?r-(o=536870912*(14&i[14])+4194304*(255&i[15])+16384*(254&i[16])+128*(255&i[17])+(254&i[18])/2)>54e5&&(t.warn(`${Math.round((r-o)/9e4)}s delta between PTS and DTS, align them`),r=o):o=r);var d=(a=i[8])+9;if(e.size<=d)return null;e.size-=d;for(var h=new Uint8Array(e.size),c=0,m=u.length;c<m;c++){var f=(i=u[c]).byteLength;if(d){if(d>f){d-=f;continue}i=i.subarray(d),f-=d,d=0}h.set(i,s),s+=f}return n&&(n-=a+3),{data:h,pts:r,dts:o,len:n}}return null}var Mx=function(){return m(function e(){u(this,e)},null,[{key:"getSilentFrame",value:function(e,t){if("mp4a.40.2"===e){if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===t)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(6===t)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])}else{if(1===t)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(2===t)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(3===t)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])}}}])}(),Ax=Math.pow(2,32)-1,Dx=function(){function e(){u(this,e)}return m(e,null,[{key:"init",value:function(){var t;for(t in e.types={avc1:[],avcC:[],hvc1:[],hvcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],dac3:[],"ac-3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},e.types)e.types.hasOwnProperty(t)&&(e.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);var i=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]),n=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]);e.HDLR_TYPES={video:i,audio:n};var a=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),r=new Uint8Array([0,0,0,0,0,0,0,0]);e.STTS=e.STSC=e.STCO=r,e.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),e.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),e.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),e.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var o=new Uint8Array([105,115,111,109]),s=new Uint8Array([97,118,99,49]),u=new Uint8Array([0,0,0,1]);e.FTYP=e.box(e.types.ftyp,o,u,o,s),e.DINF=e.box(e.types.dinf,e.box(e.types.dref,a))}},{key:"box",value:function(e,...t){for(var i=8,n=t.length,a=n;n--;)i+=t[n].byteLength;var r=new Uint8Array(i);for(r[0]=i>>24&255,r[1]=i>>16&255,r[2]=i>>8&255,r[3]=255&i,r.set(e,4),n=0,i=8;n<a;n++)r.set(t[n],i),i+=t[n].byteLength;return r}},{key:"hdlr",value:function(t){return e.box(e.types.hdlr,e.HDLR_TYPES[t])}},{key:"mdat",value:function(t){return e.box(e.types.mdat,t)}},{key:"mdhd",value:function(t,i){i*=t;var n=Math.floor(i/(Ax+1)),a=Math.floor(i%(Ax+1));return e.box(e.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,255&t,n>>24,n>>16&255,n>>8&255,255&n,a>>24,a>>16&255,a>>8&255,255&a,85,196,0,0]))}},{key:"mdia",value:function(t){return e.box(e.types.mdia,e.mdhd(t.timescale||0,t.duration||0),e.hdlr(t.type),e.minf(t))}},{key:"mfhd",value:function(t){return e.box(e.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))}},{key:"minf",value:function(t){return"audio"===t.type?e.box(e.types.minf,e.box(e.types.smhd,e.SMHD),e.DINF,e.stbl(t)):e.box(e.types.minf,e.box(e.types.vmhd,e.VMHD),e.DINF,e.stbl(t))}},{key:"moof",value:function(t,i,n){return e.box(e.types.moof,e.mfhd(t),e.traf(n,i))}},{key:"moov",value:function(t){for(var i=t.length,n=[];i--;)n[i]=e.trak(t[i]);return e.box.apply(null,[e.types.moov,e.mvhd(t[0].timescale||0,t[0].duration||0)].concat(n).concat(e.mvex(t)))}},{key:"mvex",value:function(t){for(var i=t.length,n=[];i--;)n[i]=e.trex(t[i]);return e.box.apply(null,[e.types.mvex,...n])}},{key:"mvhd",value:function(t,i){i*=t;var n=Math.floor(i/(Ax+1)),a=Math.floor(i%(Ax+1)),r=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,255&t,n>>24,n>>16&255,n>>8&255,255&n,a>>24,a>>16&255,a>>8&255,255&a,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 e.box(e.types.mvhd,r)}},{key:"sdtp",value:function(t){var i,n,a=t.samples||[],r=new Uint8Array(4+a.length);for(i=0;i<a.length;i++)n=a[i].flags,r[i+4]=n.dependsOn<<4|n.isDependedOn<<2|n.hasRedundancy;return e.box(e.types.sdtp,r)}},{key:"stbl",value:function(t){return e.box(e.types.stbl,e.stsd(t),e.box(e.types.stts,e.STTS),e.box(e.types.stsc,e.STSC),e.box(e.types.stsz,e.STSZ),e.box(e.types.stco,e.STCO))}},{key:"avc1",value:function(t){var i,n,a,r=[],o=[];for(i=0;i<t.sps.length;i++)a=(n=t.sps[i]).byteLength,r.push(a>>>8&255),r.push(255&a),r=r.concat(Array.prototype.slice.call(n));for(i=0;i<t.pps.length;i++)a=(n=t.pps[i]).byteLength,o.push(a>>>8&255),o.push(255&a),o=o.concat(Array.prototype.slice.call(n));var s=e.box(e.types.avcC,new Uint8Array([1,r[3],r[4],r[5],255,224|t.sps.length].concat(r).concat([t.pps.length]).concat(o))),u=t.width,l=t.height,d=t.pixelRatio[0],h=t.pixelRatio[1];return e.box(e.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,u>>8&255,255&u,l>>8&255,255&l,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]),s,e.box(e.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),e.box(e.types.pasp,new Uint8Array([d>>24,d>>16&255,d>>8&255,255&d,h>>24,h>>16&255,h>>8&255,255&h])))}},{key:"esds",value:function(e){var t=e.config;return new Uint8Array([0,0,0,0,3,25,0,1,0,4,17,64,21,0,0,0,0,0,0,0,0,0,0,0,5,2,...t,6,1,2])}},{key:"audioStsd",value:function(e){var t=e.samplerate||0;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount||0,0,16,0,0,0,0,t>>8&255,255&t,0,0])}},{key:"mp4a",value:function(t){return e.box(e.types.mp4a,e.audioStsd(t),e.box(e.types.esds,e.esds(t)))}},{key:"mp3",value:function(t){return e.box(e.types[".mp3"],e.audioStsd(t))}},{key:"ac3",value:function(t){return e.box(e.types["ac-3"],e.audioStsd(t),e.box(e.types.dac3,t.config))}},{key:"stsd",value:function(t){var i=t.segmentCodec;if("audio"===t.type){if("aac"===i)return e.box(e.types.stsd,e.STSD,e.mp4a(t));if("ac3"===i&&t.config)return e.box(e.types.stsd,e.STSD,e.ac3(t));if("mp3"===i&&"mp3"===t.codec)return e.box(e.types.stsd,e.STSD,e.mp3(t))}else{if(!t.pps||!t.sps)throw new Error("video track missing pps or sps");if("avc"===i)return e.box(e.types.stsd,e.STSD,e.avc1(t));if("hevc"===i&&t.vps)return e.box(e.types.stsd,e.STSD,e.hvc1(t))}throw new Error(`unsupported ${t.type} segment codec (${i}/${t.codec})`)}},{key:"tkhd",value:function(t){var i=t.id,n=(t.duration||0)*(t.timescale||0),a=t.width||0,r=t.height||0,o=Math.floor(n/(Ax+1)),s=Math.floor(n%(Ax+1));return e.box(e.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,i>>24&255,i>>16&255,i>>8&255,255&i,0,0,0,0,o>>24,o>>16&255,o>>8&255,255&o,s>>24,s>>16&255,s>>8&255,255&s,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,a>>8&255,255&a,0,0,r>>8&255,255&r,0,0]))}},{key:"traf",value:function(t,i){var n=e.sdtp(t),a=t.id,r=Math.floor(i/(Ax+1)),o=Math.floor(i%(Ax+1));return e.box(e.types.traf,e.box(e.types.tfhd,new Uint8Array([0,0,0,0,a>>24,a>>16&255,a>>8&255,255&a])),e.box(e.types.tfdt,new Uint8Array([1,0,0,0,r>>24,r>>16&255,r>>8&255,255&r,o>>24,o>>16&255,o>>8&255,255&o])),e.trun(t,n.length+16+20+8+16+8+8),n)}},{key:"trak",value:function(t){return t.duration=t.duration||4294967295,e.box(e.types.trak,e.tkhd(t),e.mdia(t))}},{key:"trex",value:function(t){var i=t.id;return e.box(e.types.trex,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}},{key:"trun",value:function(t,i){var n,a,r,o,s,u,l=t.samples||[],d=l.length,h=12+16*d,c=new Uint8Array(h);for(i+=8+h,c.set(["video"===t.type?1:0,0,15,1,d>>>24&255,d>>>16&255,d>>>8&255,255&d,i>>>24&255,i>>>16&255,i>>>8&255,255&i],0),n=0;n<d;n++)r=(a=l[n]).duration,o=a.size,s=a.flags,u=a.cts,c.set([r>>>24&255,r>>>16&255,r>>>8&255,255&r,o>>>24&255,o>>>16&255,o>>>8&255,255&o,s.isLeading<<2|s.dependsOn,s.isDependedOn<<6|s.hasRedundancy<<4|s.paddingValue<<1|s.isNonSync,61440&s.degradPrio,15&s.degradPrio,u>>>24&255,u>>>16&255,u>>>8&255,255&u],12+16*n);return e.box(e.types.trun,c)}},{key:"initSegment",value:function(t){e.types||e.init();var i=e.moov(t);return qT(e.FTYP,i)}},{key:"hvc1",value:function(t){for(var i=t.params,n=[t.vps,t.sps,t.pps],a=new Uint8Array([1,i.general_profile_space<<6|(i.general_tier_flag?32:0)|i.general_profile_idc,i.general_profile_compatibility_flags[0],i.general_profile_compatibility_flags[1],i.general_profile_compatibility_flags[2],i.general_profile_compatibility_flags[3],i.general_constraint_indicator_flags[0],i.general_constraint_indicator_flags[1],i.general_constraint_indicator_flags[2],i.general_constraint_indicator_flags[3],i.general_constraint_indicator_flags[4],i.general_constraint_indicator_flags[5],i.general_level_idc,240|i.min_spatial_segmentation_idc>>8,255&i.min_spatial_segmentation_idc,252|i.parallelismType,252|i.chroma_format_idc,248|i.bit_depth_luma_minus8,248|i.bit_depth_chroma_minus8,0,parseInt(i.frame_rate.fps),3|i.temporal_id_nested<<2|i.num_temporal_layers<<3|(i.frame_rate.fixed?64:0),n.length]),r=a.length,o=0;o<n.length;o+=1){r+=3;for(var s=0;s<n[o].length;s+=1)r+=2+n[o][s].length}var u=new Uint8Array(r);u.set(a,0),r=a.length;for(var l=n.length-1,d=0;d<n.length;d+=1){u.set(new Uint8Array([32+d|(d===l?128:0),0,n[d].length]),r),r+=3;for(var h=0;h<n[d].length;h+=1)u.set(new Uint8Array([n[d][h].length>>8,255&n[d][h].length]),r),r+=2,u.set(n[d][h],r),r+=n[d][h].length}var c=e.box(e.types.hvcC,u),m=t.width,f=t.height,v=t.pixelRatio[0],p=t.pixelRatio[1];return e.box(e.types.hvc1,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,m>>8&255,255&m,f>>8&255,255&f,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]),c,e.box(e.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),e.box(e.types.pasp,new Uint8Array([v>>24,v>>16&255,v>>8&255,255&v,p>>24,p>>16&255,p>>8&255,255&p])))}}])}();Dx.types=void 0,Dx.HDLR_TYPES=void 0,Dx.STTS=void 0,Dx.STSC=void 0,Dx.STCO=void 0,Dx.STSZ=void 0,Dx.VMHD=void 0,Dx.SMHD=void 0,Dx.STSD=void 0,Dx.FTYP=void 0,Dx.DINF=void 0;function xx(e,t,i=1,n=!1){var a=e*t*i;return n?Math.round(a):a}function Cx(e,t=!1){return xx(e,1e3,1/9e4,t)}function Ix(e){var t=e.baseTime,i=e.timescale;return`${t/i} (${t}/${i}) trackId: ${e.trackId}`}var Lx=null,_x=null;function Rx(e,t,i,n){return{duration:t,size:i,cts:n,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:e?2:1,isNonSync:e?0:1}}}var Fx=function(){function e(t,i,n,a){var r;if(u(this,e),(r=s(this,e,["mp4-remuxer",a])).observer=void 0,r.config=void 0,r.typeSupported=void 0,r.ISGenerated=!1,r._initPTS=null,r._initDTS=null,r.nextVideoTs=null,r.nextAudioTs=null,r.videoSampleDuration=null,r.isAudioContiguous=!1,r.isVideoContiguous=!1,r.videoTrackConfig=void 0,r.observer=t,r.config=i,r.typeSupported=n,r.ISGenerated=!1,null===Lx){var o=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Lx=o?parseInt(o[1]):0}if(null===_x){var l=navigator.userAgent.match(/Safari\/(\d+)/i);_x=l?parseInt(l[1]):0}return r}return y(e,iT),m(e,[{key:"destroy",value:function(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null}},{key:"resetTimeStamp",value:function(e){var t=this._initPTS;t&&e&&e.trackId===t.trackId&&e.baseTime===t.baseTime&&e.timescale===t.timescale||this.log(`Reset initPTS: ${t?Ix(t):t} > ${e?Ix(e):e}`),this._initPTS=this._initDTS=e}},{key:"resetNextTimestamp",value:function(){this.log("reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}},{key:"resetInitSegment",value:function(){this.log("ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0}},{key:"getVideoStartPts",value:function(e){var t=!1,i=e[0].pts,n=e.reduce((e,n)=>{var a=n.pts,r=a-e;return r<-4294967296&&(t=!0,r=(a=Ox(a,i))-e),r>0?e:a},i);return t&&this.debug("PTS rollover detected"),n}},{key:"remux",value:function(e,t,i,n,a,r,o,s){var u,l,d,h,c,m,f=a,v=a,p=e.pid>-1,g=t.pid>-1,y=t.samples.length,b=e.samples.length>0,w=o&&y>0||y>1;if((!p||b)&&(!g||w)||this.ISGenerated||o){if(this.ISGenerated){var k,S,E,T,P=this.videoTrackConfig;(P&&(t.width!==P.width||t.height!==P.height||(null==(k=t.pixelRatio)?void 0:k[0])!==(null==(S=P.pixelRatio)?void 0:S[0])||(null==(E=t.pixelRatio)?void 0:E[1])!==(null==(T=P.pixelRatio)?void 0:T[1]))||!P&&w||null===this.nextAudioTs&&b)&&this.resetInitSegment()}this.ISGenerated||(d=this.generateIS(e,t,a,r));var M,A=this.isVideoContiguous,D=-1;if(w&&(D=function(e){for(var t=0;t<e.length;t++)if(e[t].key)return t;return-1}(t.samples),!A&&this.config.forceKeyFrameOnDiscontinuity))if(m=!0,D>0){this.warn(`Dropped ${D} out of ${y} video samples due to a missing keyframe`);var x=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(D),t.dropped+=D,M=v+=(t.samples[0].pts-x)/t.inputTimeScale}else-1===D&&(this.warn(`No keyframe found out of ${y} video samples`),m=!1);if(this.ISGenerated){if(b&&w){var C=this.getVideoStartPts(t.samples),I=(Ox(e.samples[0].pts,C)-C)/t.inputTimeScale;f+=Math.max(0,I),v+=Math.max(0,-I)}if(b){if(e.samplerate||(this.warn("regenerate InitSegment as audio detected"),d=this.generateIS(e,t,a,r)),l=this.remuxAudio(e,f,this.isAudioContiguous,r,g||w||s===XE?v:void 0),w){var L=l?l.endPTS-l.startPTS:0;t.inputTimeScale||(this.warn("regenerate InitSegment as video detected"),d=this.generateIS(e,t,a,r)),u=this.remuxVideo(t,v,A,L)}}else w&&(u=this.remuxVideo(t,v,A,0));u&&(u.firstKeyFrame=D,u.independent=-1!==D,u.firstKeyFramePTS=M)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(i.samples.length&&(c=Wx(i,a,this._initPTS,this._initDTS)),n.samples.length&&(h=$x(n,a,this._initPTS))),{audio:l,video:u,initSegment:d,independent:m,text:h,id3:c}}},{key:"computeInitPts",value:function(e,t,i,n){var a=Math.round(i*t),r=Ox(e,a);if(r<a+t)for(this.log(`Adjusting PTS for rollover in timeline near ${(a-r)/t} ${n}`);r<a+t;)r+=8589934592;return r-a}},{key:"generateIS",value:function(e,t,i,n){var a,r,o,s=e.samples,u=t.samples,l=this.typeSupported,d={},h=this._initPTS,c=!h||n,m="audio/mp4",f=-1;if(c&&(a=r=1/0),e.config&&s.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":l.mpeg?(m="audio/mpeg",e.codec=""):l.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3"}d.audio={id:"audio",container:m,codec:e.codec,initSegment:"mp3"===e.segmentCodec&&l.mpeg?new Uint8Array(0):Dx.initSegment([e]),metadata:{channelCount:e.channelCount}},c&&(f=e.id,o=e.inputTimeScale,h&&o===h.timescale?c=!1:a=r=this.computeInitPts(s[0].pts,o,i,"audio"))}if(t.sps&&t.pps&&u.length){if(t.timescale=t.inputTimeScale,d.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:Dx.initSegment([t]),metadata:{width:t.width,height:t.height}},c)if(f=t.id,o=t.inputTimeScale,h&&o===h.timescale)c=!1;else{var v=this.getVideoStartPts(u),p=Ox(u[0].dts,v),g=this.computeInitPts(p,o,i,"video"),y=this.computeInitPts(v,o,i,"video");r=Math.min(r,g),a=Math.min(a,y)}this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(d).length)return this.ISGenerated=!0,c?(h&&this.warn(`Timestamps at playlist time: ${n?"":"~"}${i} ${a/o} != initPTS: ${h.baseTime/h.timescale} (${h.baseTime}/${h.timescale}) trackId: ${h.trackId}`),this.log(`Found initPTS at playlist time: ${i} offset: ${a/o} (${a}/${o}) trackId: ${f}`),this._initPTS={baseTime:a,timescale:o,trackId:f},this._initDTS={baseTime:r,timescale:o,trackId:f}):a=o=void 0,{tracks:d,initPTS:a,timescale:o,trackId:f}}},{key:"remuxVideo",value:function(e,t,i,n){var a,r,o=e.inputTimeScale,s=e.samples,u=[],l=s.length,d=this._initPTS,h=d.baseTime*o/d.timescale,c=this.nextVideoTs,m=8,f=this.videoSampleDuration,v=Number.POSITIVE_INFINITY,p=Number.NEGATIVE_INFINITY,g=!1;if(!i||null===c){var y=h+t*o,b=s[0].pts-Ox(s[0].dts,s[0].pts);Lx&&null!==c&&Math.abs(y-b-(c+h))<15e3?i=!0:c=y-b-h}for(var w=c+h,k=0;k<l;k++){var S=s[k];S.pts=Ox(S.pts,w),S.dts=Ox(S.dts,w),S.dts<s[k>0?k-1:k].dts&&(g=!0)}g&&s.sort(function(e,t){var i=e.dts-t.dts,n=e.pts-t.pts;return i||n}),a=s[0].dts;var E=(r=s[s.length-1].dts)-a,T=E?Math.round(E/(l-1)):f||e.inputTimeScale/30;if(i){var P=a-w,M=P>T,A=P<-1;if((M||A)&&(M?this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${Cx(P,!0)} ms (${P}dts) hole between fragments detected at ${t.toFixed(3)}`):this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${Cx(-P,!0)} ms (${P}dts) overlapping between fragments detected at ${t.toFixed(3)}`),!A||w>=s[0].pts||Lx)){a=w;var D=s[0].pts-P;if(M)s[0].dts=a,s[0].pts=D;else for(var x=!0,C=0;C<s.length&&!(s[C].dts>D&&x);C++){var I=s[C].pts;if(s[C].dts-=P,s[C].pts-=P,C<s.length-1){var L=s[C+1].pts;x=L<=s[C].pts==L<=I}}this.log(`Video: Initial PTS/DTS adjusted: ${Cx(D,!0)}/${Cx(a,!0)}, delta: ${Cx(P,!0)} ms`)}}for(var _=0,R=0,F=a=Math.max(0,a),O=0;O<l;O++){for(var W=s[O],$=W.units,N=$.length,j=0,B=0;B<N;B++)j+=$[B].data.length;R+=j,_+=N,W.length=j,W.dts<F?(W.dts=F,F+=T/4|0||1):F=W.dts,v=Math.min(W.pts,v),p=Math.max(W.pts,p)}r=s[l-1].dts;var z,U=R+4*_+8;try{z=new Uint8Array(U)}catch(e){return void this.observer.emit(zE.ERROR,zE.ERROR,{type:jE.MUX_ERROR,details:BE.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:U,reason:`fail allocating video mdat ${U}`})}var H=new DataView(z.buffer);H.setUint32(0,U),z.set(Dx.types.mdat,4);for(var G=!1,V=Number.POSITIVE_INFINITY,K=Number.POSITIVE_INFINITY,X=Number.NEGATIVE_INFINITY,Y=Number.NEGATIVE_INFINITY,q=0;q<l;q++){for(var J=s[q],Q=J.units,Z=0,ee=0,te=Q.length;ee<te;ee++){var ie=Q[ee],ne=ie.data,ae=ie.data.byteLength;H.setUint32(m,ae),m+=4,z.set(ne,m),m+=ae,Z+=4+ae}var re=void 0;if(q<l-1)f=s[q+1].dts-J.dts,re=s[q+1].pts-J.pts;else{var oe=this.config,se=q>0?J.dts-s[q-1].dts:T;if(re=q>0?J.pts-s[q-1].pts:T,oe.stretchShortVideoTrack&&null!==this.nextAudioTs){var ue=Math.floor(oe.maxBufferHole*o),le=(n?v+n*o:this.nextAudioTs+h)-J.pts;le>ue?((f=le-se)<0?f=se:G=!0,this.log(`It is approximately ${le/90} ms to the next segment; using duration ${f/90} ms for the last video frame.`)):f=se}else f=se}var de=Math.round(J.pts-J.dts);V=Math.min(V,f),X=Math.max(X,f),K=Math.min(K,re),Y=Math.max(Y,re),u.push(Rx(J.key,f,Z,de))}if(u.length)if(Lx){if(Lx<70){var he=u[0].flags;he.dependsOn=2,he.isNonSync=0}}else if(_x&&Y-K<X-V&&T/X<.025&&0===u[0].cts){this.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var ce=a,me=0,fe=u.length;me<fe;me++){var ve=ce+u[me].duration,pe=ce+u[me].cts;if(me<fe-1){var ge=ve+u[me+1].cts;u[me].duration=ge-pe}else u[me].duration=me?u[me-1].duration:T;u[me].cts=0,ce=ve}}var ye=r+(f=G||!f?T:f);this.nextVideoTs=c=ye-h,this.videoSampleDuration=f,this.isVideoContiguous=!0;var be={data1:Dx.moof(e.sequenceNumber++,a,ZE(e,{samples:u})),data2:z,startPTS:(v-h)/o,endPTS:(p+f-h)/o,startDTS:(a-h)/o,endDTS:c/o,type:"video",hasAudio:!1,hasVideo:!0,nb:u.length,dropped:e.dropped};return e.samples=[],e.dropped=0,be}},{key:"getSamplesPerFrame",value:function(e){switch(e.segmentCodec){case"mp3":return 1152;case"ac3":return 1536;default:return 1024}}},{key:"remuxAudio",value:function(e,t,i,n,a){var r=e.inputTimeScale,o=r/(e.samplerate?e.samplerate:r),s=this.getSamplesPerFrame(e),u=s*o,l=this._initPTS,d="mp3"===e.segmentCodec&&this.typeSupported.mpeg,h=[],c=void 0!==a,m=e.samples,f=d?0:8,v=this.nextAudioTs||-1,p=l.baseTime*r/l.timescale,g=p+t*r;if(this.isAudioContiguous=i=i||m.length&&v>0&&(n&&Math.abs(g-(v+p))<9e3||Math.abs(Ox(m[0].pts,g)-(v+p))<20*u),m.forEach(function(e){e.pts=Ox(e.pts,g)}),!i||v<0){var y=m.length;if(m=m.filter(e=>e.pts>=0),y!==m.length&&this.warn(`Removed ${m.length-y} of ${y} samples (initPTS ${p} / ${r})`),!m.length)return;v=0===a?0:n&&!c?Math.max(0,g-p):m[0].pts-p}if("aac"===e.segmentCodec)for(var b=this.config.maxAudioFramesDrift,w=0,k=v+p;w<m.length;w++){var S=m[w],E=S.pts,T=E-k,P=Math.abs(1e3*T/r);if(T<=-b*u&&c)0===w&&(this.warn(`Audio frame @ ${(E/r).toFixed(3)}s overlaps marker by ${Math.round(1e3*T/r)} ms.`),this.nextAudioTs=v=E-p,k=E);else if(T>=b*u&&P<1e4&&c){var M=Math.round(T/u);for(k=E-M*u;k<0&&M&&u;)M--,k+=u;0===w&&(this.nextAudioTs=v=k-p),this.warn(`Injecting ${M} audio frames @ ${((k-p)/r).toFixed(3)}s due to ${Math.round(1e3*T/r)} ms gap.`);for(var A=0;A<M;A++){var D=Mx.getSilentFrame(e.parsedCodec||e.manifestCodec||e.codec,e.channelCount);D||(this.log("Unable to get silent frame for given audio codec; duplicating last frame instead."),D=S.unit.subarray()),m.splice(w,0,{unit:D,pts:k}),k+=u,w++}}S.pts=k,k+=u}for(var x,C=null,I=null,L=0,_=m.length;_--;)L+=m[_].unit.byteLength;for(var R=0,F=m.length;R<F;R++){var O=m[R],W=O.unit,$=O.pts;if(null!==I){h[R-1].duration=Math.round(($-I)/o)}else{if(i&&"aac"===e.segmentCodec&&($=v+p),C=$,!(L>0))return;L+=f;try{x=new Uint8Array(L)}catch(e){return void this.observer.emit(zE.ERROR,zE.ERROR,{type:jE.MUX_ERROR,details:BE.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:L,reason:`fail allocating audio mdat ${L}`})}d||(new DataView(x.buffer).setUint32(0,L),x.set(Dx.types.mdat,4))}x.set(W,f);var N=W.byteLength;f+=N,h.push(Rx(!0,s,N,0)),I=$}var j=h.length;if(j){var B=h[h.length-1];v=I-p,this.nextAudioTs=v+o*B.duration;var z=d?new Uint8Array(0):Dx.moof(e.sequenceNumber++,C/o,ZE({},e,{samples:h}));e.samples=[];var U=(C-p)/r,H=this.nextAudioTs/r,G={data1:z,data2:x,startPTS:U,endPTS:H,startDTS:U,endDTS:H,type:"audio",hasAudio:!0,hasVideo:!1,nb:j};return this.isAudioContiguous=!0,G}}}])}();function Ox(e,t){var i;if(null===t)return e;for(i=t<e?-8589934592:8589934592;Math.abs(e-t)>4294967296;)e+=i;return e}function Wx(e,t,i,n){var a=e.samples.length;if(a){for(var r=e.inputTimeScale,o=0;o<a;o++){var s=e.samples[o];s.pts=Ox(s.pts-i.baseTime*r/i.timescale,t*r)/r,s.dts=Ox(s.dts-n.baseTime*r/n.timescale,t*r)/r}var u=e.samples;return e.samples=[],{samples:u}}}function $x(e,t,i){var n=e.samples.length;if(n){for(var a=e.inputTimeScale,r=0;r<n;r++){var o=e.samples[r];o.pts=Ox(o.pts-i.baseTime*a/i.timescale,t*a)/a}e.samples.sort((e,t)=>e.pts-t.pts);var s=e.samples;return e.samples=[],{samples:s}}}var Nx,jx=function(){function e(t,i,n,a){var r;return u(this,e),(r=s(this,e,["passthrough-remuxer",a])).emitInitSegment=!1,r.audioCodec=void 0,r.videoCodec=void 0,r.initData=void 0,r.initPTS=null,r.initTracks=void 0,r.lastEndTime=null,r.isVideoContiguous=!1,r}return y(e,iT),m(e,[{key:"destroy",value:function(){}},{key:"resetTimeStamp",value:function(e){this.lastEndTime=null;var t=this.initPTS;t&&e&&t.baseTime===e.baseTime&&t.timescale===e.timescale||(this.initPTS=e)}},{key:"resetNextTimestamp",value:function(){this.isVideoContiguous=!1,this.lastEndTime=null}},{key:"resetInitSegment",value:function(e,t,i,n){this.audioCodec=t,this.videoCodec=i,this.generateInitSegment(e,n),this.emitInitSegment=!0}},{key:"generateInitSegment",value:function(e,t){var i=this.audioCodec,n=this.videoCodec;if(null==e||!e.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var a=this.initData=zT(e),r=a.audio,o=a.video;if(t)!function(e,t){if(e&&t){var i=t.keyId;i&&t.isCommonEncryption&&XT(e,(e,t)=>{var n=e.subarray(8,24);n.some(e=>0!==e)||(uT.log(`[eme] Patching keyId in 'enc${t?"a":"v"}>sinf>>tenc' box: ${cT(n)} -> ${cT(i)}`),e.set(i,8))})}}(e,t);else{var s=r||o;null!=s&&s.encrypted&&this.warn(`Init segment with encrypted track with has no key ("${s.codec}")!`)}r&&(i=zx(r,TT,this)),o&&(n=zx(o,PT,this));var u={};r&&o?u.audiovideo={container:"video/mp4",codec:i+","+n,supplemental:o.supplemental,encrypted:o.encrypted,initSegment:e,id:"main"}:r?u.audio={container:"audio/mp4",codec:i,encrypted:r.encrypted,initSegment:e,id:"audio"}:o?u.video={container:"video/mp4",codec:n,supplemental:o.supplemental,encrypted:o.encrypted,initSegment:e,id:"main"}:this.warn("initSegment does not contain moov or trak boxes."),this.initTracks=u}},{key:"remux",value:function(e,t,i,n,a,r){var o,s,u=this.initPTS,l=this.lastEndTime,d={audio:void 0,video:void 0,text:n,id3:i,initSegment:void 0};WE(l)||(l=this.lastEndTime=a||0);var h=t.samples;if(!h.length)return d;var c={initPTS:void 0,timescale:void 0,trackId:void 0},m=this.initData;if(null!=(o=m)&&o.length||(this.generateInitSegment(h),m=this.initData),null==(s=m)||!s.length)return this.warn("Failed to generate initSegment."),d;this.emitInitSegment&&(c.tracks=this.initTracks,this.emitInitSegment=!1);var f=function(e,t,i){for(var n={},a=jT(e,["moof","traf"]),r=0;r<a.length;r++){var o=a[r],s=jT(o,["tfhd"])[0],u=WT(s,4),l=t[u];if(l){n[u]||(n[u]={start:NaN,duration:0,sampleCount:0,timescale:l.timescale,type:l.type});var d=n[u],h=jT(o,["tfdt"])[0];if(h){var c=h[0],m=WT(h,4);1===c&&(m===LT?i.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"):(m*=LT+1,m+=WT(h,8))),WE(m)&&(!WE(d.start)||m<d.start)&&(d.start=m)}var f=l.default,v=WT(s,0)|(null==f?void 0:f.flags),p=(null==f?void 0:f.duration)||0;8&v&&(p=WT(s,2&v?12:8));for(var g=jT(o,["trun"]),y=d.start||0,b=0,w=p,k=0;k<g.length;k++){var S=g[k],E=WT(S,4),T=d.sampleCount;d.sampleCount+=E;var P=1&S[3],M=4&S[3],A=1&S[2],D=2&S[2],x=4&S[2],C=8&S[2],I=8,L=E;for(P&&(I+=4),M&&E&&(1&S[I+1]||void 0!==d.keyFrameIndex||(d.keyFrameIndex=T),I+=4,A?(w=WT(S,I),I+=4):w=p,D&&(I+=4),C&&(I+=4),y+=w,b+=w,L--);L--;)A?(w=WT(S,I),I+=4):w=p,D&&(I+=4),x&&(1&S[I+1]||void 0===d.keyFrameIndex&&(d.keyFrameIndex=d.sampleCount-(L+1),d.keyFrameStart=y),I+=4),C&&(I+=4),y+=w,b+=w;!b&&p&&(b+=p*E)}d.duration+=b}}if(!Object.keys(n).some(e=>n[e].duration)){for(var _=1/0,R=0,F=jT(e,["sidx"]),O=0;O<F.length;O++){var W=BT(F[O]);if(null!=W&&W.references){_=Math.min(_,W.earliestPresentationTime/W.timescale);var $=W.references.reduce((e,t)=>e+t.info.duration||0,0);R=Math.max(R,$+W.earliestPresentationTime/W.timescale)}}R&&WE(R)&&Object.keys(n).forEach(e=>{n[e].duration||(n[e].duration=R*n[e].timescale-n[e].start)})}return n}(h,m,this),v=m.audio?f[m.audio.id]:null,p=m.video?f[m.video.id]:null,g=Bx(p,1/0),y=Bx(v,1/0),b=Bx(p,0,!0),w=Bx(v,0,!0),k=a,S=0,E=v&&(!p||!u&&y<g||u&&u.trackId===m.audio.id),T=E?v:p;if(T){var P=T.timescale,M=T.start-a*P,A=E?m.audio.id:m.video.id;k=T.start/P,S=E?w-y:b-g,!r&&u||!function(e,t,i,n){if(null===e)return!0;var a=Math.max(n,1),r=t-e.baseTime/e.timescale;return Math.abs(r-i)>a}(u,k,a,S)&&P===u.timescale||(u&&this.warn(`Timestamps at playlist time: ${r?"":"~"}${a} ${M/P} != initPTS: ${u.baseTime/u.timescale} (${u.baseTime}/${u.timescale}) trackId: ${u.trackId}`),this.log(`Found initPTS at playlist time: ${a} offset: ${k-a} (${M}/${P}) trackId: ${A}`),u=null,c.initPTS=M,c.timescale=P,c.trackId=A)}else this.warn(`No audio or video samples found for initPTS at playlist time: ${a}`);u?(c.initPTS=u.baseTime,c.timescale=u.timescale,c.trackId=u.trackId):(c.timescale&&void 0!==c.trackId&&void 0!==c.initPTS||(this.warn("Could not set initPTS"),c.initPTS=k,c.timescale=1,c.trackId=-1),this.initPTS=u={baseTime:c.initPTS,timescale:c.timescale,trackId:c.trackId});var D=k-u.baseTime/u.timescale,x=D+S;S>0?this.lastEndTime=x:(this.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var C=!!m.audio,I=!!m.video,L="";C&&(L+="audio"),I&&(L+="video");var _={data1:h,startPTS:D,startDTS:D,endPTS:x,endDTS:x,type:L,hasAudio:C,hasVideo:I,nb:1,dropped:0,encrypted:!!m.audio&&m.audio.encrypted||!!m.video&&m.video.encrypted};d.audio=C&&!I?_:void 0,d.video=I?_:void 0;var R=null==p?void 0:p.sampleCount;if(R){var F=p.keyFrameIndex,O=-1!==F;_.nb=R,_.dropped=0===F||this.isVideoContiguous?0:O?F:R,_.independent=O,_.firstKeyFrame=F,O&&p.keyFrameStart&&(_.firstKeyFramePTS=(p.keyFrameStart-u.baseTime)/u.timescale),this.isVideoContiguous||(d.independent=O),this.isVideoContiguous||(this.isVideoContiguous=O),_.dropped&&this.warn(`fmp4 does not start with IDR: firstIDR ${F}/${R} dropped: ${_.dropped} start: ${_.firstKeyFramePTS||"NA"}`)}return d.initSegment=c,d.id3=Wx(i,a,u,u),n.samples.length&&(d.text=$x(n,a,u)),d}}])}();function Bx(e,t,i=!1){return void 0!==(null==e?void 0:e.start)?(e.start+(i?e.duration:0))/e.timescale:t}function zx(e,t,i){var n=e.codec;if(n&&n.length>4)return n;if(t===TT){if("ec-3"===n||"ac-3"===n||"alac"===n)return n;if("fLaC"===n||"Opus"===n){return fP(n,!1)}return i.warn(`Unhandled audio codec "${n}" in mp4 MAP`),n||"mp4a"}return i.warn(`Unhandled video codec "${n}" in mp4 MAP`),n||"avc1"}try{Nx=self.performance.now.bind(self.performance)}catch(e){Nx=Date.now}var Ux=[{demux:hx,remux:jx},{demux:bx,remux:Fx},{demux:rx,remux:Fx},{demux:lx,remux:Fx}];Ux.splice(2,0,{demux:sx,remux:Fx});var Hx=function(){return m(function e(t,i,n,a,r,o){u(this,e),this.asyncResult=!1,this.logger=void 0,this.observer=void 0,this.typeSupported=void 0,this.config=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=i,this.config=n,this.id=r,this.logger=o},[{key:"configure",value:function(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}},{key:"push",value:function(e,t,i,n){var a=i.transmuxing;a.executeStart=Nx();var r=new Uint8Array(e),o=this.currentTransmuxState,s=this.transmuxConfig;n&&(this.currentTransmuxState=n);var u=n||o,l=u.contiguous,d=u.discontinuity,h=u.trackSwitch,c=u.accurateTimeOffset,m=u.timeOffset,f=u.initSegmentChange,v=s.audioCodec,p=s.videoCodec,g=s.defaultInitPts,y=s.duration,b=s.initSegmentData,w=function(e,t){var i=null;e.byteLength>0&&null!=(null==t?void 0:t.key)&&null!==t.iv&&null!=t.method&&(i=t);return i}(r,t);if(w&&QM(w.method)){var k=this.getDecrypter(),S=ZM(w.method);if(!k.isSync())return this.asyncResult=!0,this.decryptionPromise=k.webCryptoDecrypt(r,w.key.buffer,w.iv.buffer,S).then(e=>{var t=this.push(e,null,i);return this.decryptionPromise=null,t}),this.decryptionPromise;var E=k.softwareDecrypt(r,w.key.buffer,w.iv.buffer,S);if(i.part>-1){var T=k.flush();E=T?T.buffer:T}if(!E)return a.executeEnd=Nx(),Gx(i);r=new Uint8Array(E)}var P=this.needsProbing(d,h);if(P){var M=this.configureTransmuxer(r);if(M)return this.logger.warn(`[transmuxer] ${M.message}`),this.observer.emit(zE.ERROR,zE.ERROR,{type:jE.MEDIA_ERROR,details:BE.FRAG_PARSING_ERROR,fatal:!1,error:M,reason:M.message}),a.executeEnd=Nx(),Gx(i)}(d||h||f||P)&&this.resetInitSegment(b,v,p,y,t),(d||f||P)&&this.resetInitialTimestamp(g),l||this.resetContiguity();var A=this.transmux(r,w,m,c,i);this.asyncResult=Vx(A);var D=this.currentTransmuxState;return D.contiguous=!0,D.discontinuity=!1,D.trackSwitch=!1,a.executeEnd=Nx(),A}},{key:"flush",value:function(e){var t=e.transmuxing;t.executeStart=Nx();var i=this.decrypter,n=this.currentTransmuxState,a=this.decryptionPromise;if(a)return this.asyncResult=!0,a.then(()=>this.flush(e));var r=[],o=n.timeOffset;if(i){var s=i.flush();s&&r.push(this.push(s.buffer,null,e))}var u=this.demuxer,l=this.remuxer;if(!u||!l){t.executeEnd=Nx();var d=[Gx(e)];return this.asyncResult?Promise.resolve(d):d}var h=u.flush(o);return Vx(h)?(this.asyncResult=!0,h.then(t=>(this.flushRemux(r,t,e),r))):(this.flushRemux(r,h,e),this.asyncResult?Promise.resolve(r):r)}},{key:"flushRemux",value:function(e,t,i){var n=t.audioTrack,a=t.videoTrack,r=t.id3Track,o=t.textTrack,s=this.currentTransmuxState,u=s.accurateTimeOffset,l=s.timeOffset;this.logger.log(`[transmuxer.ts]: Flushed ${this.id} sn: ${i.sn}${i.part>-1?" part: "+i.part:""} of ${this.id===KE?"level":"track"} ${i.level}`);var d=this.remuxer.remux(n,a,r,o,l,u,!0,this.id);e.push({remuxResult:d,chunkMeta:i}),i.transmuxing.executeEnd=Nx()}},{key:"resetInitialTimestamp",value:function(e){var t=this.demuxer,i=this.remuxer;t&&i&&(t.resetTimeStamp(e),i.resetTimeStamp(e))}},{key:"resetContiguity",value:function(){var e=this.demuxer,t=this.remuxer;e&&t&&(e.resetContiguity(),t.resetNextTimestamp())}},{key:"resetInitSegment",value:function(e,t,i,n,a){var r=this.demuxer,o=this.remuxer;r&&o&&(r.resetInitSegment(e,t,i,n),o.resetInitSegment(e,t,i,a))}},{key:"destroy",value:function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}},{key:"transmux",value:function(e,t,i,n,a){return t&&"SAMPLE-AES"===t.method?this.transmuxSampleAes(e,t,i,n,a):this.transmuxUnencrypted(e,i,n,a)}},{key:"transmuxUnencrypted",value:function(e,t,i,n){var a=this.demuxer.demux(e,t,!1,!this.config.progressive),r=a.audioTrack,o=a.videoTrack,s=a.id3Track,u=a.textTrack;return{remuxResult:this.remuxer.remux(r,o,s,u,t,i,!1,this.id),chunkMeta:n}}},{key:"transmuxSampleAes",value:function(e,t,i,n,a){return this.demuxer.demuxSampleAes(e,t,i).then(e=>({remuxResult:this.remuxer.remux(e.audioTrack,e.videoTrack,e.id3Track,e.textTrack,i,n,!1,this.id),chunkMeta:a}))}},{key:"configureTransmuxer",value:function(e){for(var t,i=this.config,n=this.observer,a=this.typeSupported,r=0,o=Ux.length;r<o;r++){var s;if(null!=(s=Ux[r].demux)&&s.probe(e,this.logger)){t=Ux[r];break}}if(!t)return new Error("Failed to find demuxer by probing fragment data");var u=this.demuxer,l=this.remuxer,d=t.remux,h=t.demux;l&&l instanceof d||(this.remuxer=new d(n,i,a,this.logger)),u&&u instanceof h||(this.demuxer=new h(n,i,a,this.logger),this.probe=h.probe)}},{key:"needsProbing",value:function(e,t){return!this.demuxer||!this.remuxer||e||t}},{key:"getDecrypter",value:function(){var e=this.decrypter;return e||(e=this.decrypter=new DM(this.config)),e}}])}();var Gx=e=>({remuxResult:{},chunkMeta:e});function Vx(e){return"then"in e&&e.then instanceof Function}var Kx=m(function e(t,i,n,a,r){u(this,e),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=i,this.initSegmentData=n,this.duration=a,this.defaultInitPts=r||null}),Xx=m(function e(t,i,n,a,r,o){u(this,e),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=i,this.accurateTimeOffset=n,this.trackSwitch=a,this.timeOffset=r,this.initSegmentChange=o}),Yx=0,qx=function(){return m(function e(t,i,n,a){u(this,e),this.error=null,this.hls=void 0,this.id=void 0,this.instanceNo=Yx++,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.onWorkerMessage=e=>{var t=e.data,i=this.hls;if(i&&null!=t&&t.event&&t.instanceNo===this.instanceNo)switch(t.event){case"init":var n,a=null==(n=this.workerContext)?void 0:n.objectURL;a&&self.URL.revokeObjectURL(a);break;case"transmuxComplete":this.handleTransmuxComplete(t.data);break;case"flush":this.onFlush(t.data);break;case"workerLog":i.logger[t.data.logType]&&i.logger[t.data.logType](t.data.message);break;default:t.data=t.data||{},t.data.frag=this.frag,t.data.part=this.part,t.data.id=this.id,i.trigger(t.event,t.data)}},this.onWorkerError=e=>{if(this.hls){var t=new Error(`${e.message} (${e.filename}:${e.lineno})`);this.hls.config.enableWorker=!1,this.hls.logger.warn(`Error in "${this.id}" Web Worker, fallback to inline`),this.hls.trigger(zE.ERROR,{type:jE.OTHER_ERROR,details:BE.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:t})}};var r=t.config;this.hls=t,this.id=i,this.useWorker=!!r.enableWorker,this.onTransmuxComplete=n,this.onFlush=a;var o=(e,t)=>{(t=t||{}).frag=this.frag||void 0,e===zE.ERROR&&(t.parent=this.id,t.part=this.part,this.error=t.error),this.hls.trigger(e,t)};this.observer=new kD,this.observer.on(zE.FRAG_DECRYPTED,o),this.observer.on(zE.ERROR,o);var s=yP(r.preferManagedMediaSource);if(this.useWorker&&"undefined"!=typeof Worker){var l=this.hls.logger;if(r.workerPath||"function"==typeof __HLS_WORKER_BUNDLE__){try{r.workerPath?(l.log(`loading Web Worker ${r.workerPath} for "${i}"`),this.workerContext=function(e){var t=ED[e];if(t)return t.clientCount++,t;var i=new self.URL(e,self.location.href).href,n={worker:new self.Worker(i),scriptURL:i,clientCount:1};return ED[e]=n,n}(r.workerPath)):(l.log(`injecting Web Worker for "${i}"`),this.workerContext=function(){var e=ED[SD];if(e)return e.clientCount++,e;var t=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),i=self.URL.createObjectURL(t),n={worker:new self.Worker(i),objectURL:i,clientCount:1};return ED[SD]=n,n}());var d=this.workerContext.worker;d.addEventListener("message",this.onWorkerMessage),d.addEventListener("error",this.onWorkerError),d.postMessage({instanceNo:this.instanceNo,cmd:"init",typeSupported:s,id:i,config:OP(r)})}catch(e){l.warn(`Error setting up "${i}" Web Worker, fallback to inline`,e),this.terminateWorker(),this.error=null,this.transmuxer=new Hx(this.observer,s,r,"",i,t.logger)}return}}this.transmuxer=new Hx(this.observer,s,r,"",i,t.logger)},[{key:"reset",value:function(){if(this.frag=null,this.part=null,this.workerContext){var e=this.instanceNo;this.instanceNo=Yx++;var t=this.hls.config,i=yP(t.preferManagedMediaSource);this.workerContext.worker.postMessage({instanceNo:this.instanceNo,cmd:"reset",resetNo:e,typeSupported:i,id:this.id,config:OP(t)})}}},{key:"terminateWorker",value:function(){if(this.workerContext){var e=this.workerContext.worker;this.workerContext=null,e.removeEventListener("message",this.onWorkerMessage),e.removeEventListener("error",this.onWorkerError),function(e){var t=ED[e||SD];if(t&&1===t.clientCount--){var i=t.worker,n=t.objectURL;delete ED[e||SD],n&&self.URL.revokeObjectURL(n),i.terminate()}}(this.hls.config.workerPath)}}},{key:"destroy",value:function(){if(this.workerContext)this.terminateWorker(),this.onWorkerMessage=this.onWorkerError=null;else{var e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}var t=this.observer;t&&t.removeAllListeners(),this.frag=null,this.part=null,this.observer=null,this.hls=null}},{key:"push",value:function(e,t,i,n,a,r,o,s,u,l){var d,h;u.transmuxing.start=self.performance.now();var c=this.instanceNo,m=this.transmuxer,f=r?r.start:a.start,v=a.decryptdata,p=this.frag,g=!(p&&a.cc===p.cc),y=!(p&&u.level===p.level),b=p?u.sn-p.sn:-1,w=this.part?u.part-this.part.index:-1,k=0===b&&u.id>1&&u.id===(null==p?void 0:p.stats.chunkCount),S=!y&&(1===b||0===b&&(1===w||k&&w<=0)),E=self.performance.now();(y||b||0===a.stats.parsing.start)&&(a.stats.parsing.start=E),!r||!w&&S||(r.stats.parsing.start=E);var T=!(p&&(null==(d=a.initSegment)?void 0:d.url)===(null==(h=p.initSegment)?void 0:h.url)),P=new Xx(g,S,s,y,f,T);if(!S||g||T){this.hls.logger.log(`[transmuxer-interface]: Starting new transmux session for ${a.type} sn: ${u.sn}${u.part>-1?" part: "+u.part:""} ${this.id===KE?"level":"track"}: ${u.level} id: ${u.id}\n discontinuity: ${g}\n trackSwitch: ${y}\n contiguous: ${S}\n accurateTimeOffset: ${s}\n timeOffset: ${f}\n initSegmentChange: ${T}`);var M=new Kx(i,n,t,o,l);this.configureTransmuxer(M)}if(this.frag=a,this.part=r,this.workerContext)this.workerContext.worker.postMessage({instanceNo:c,cmd:"demux",data:e,decryptdata:v,chunkMeta:u,state:P},e instanceof ArrayBuffer?[e]:[]);else if(m){var A=m.push(e,v,u,P);Vx(A)?A.then(e=>{this.handleTransmuxComplete(e)}).catch(e=>{this.transmuxerError(e,u,"transmuxer-interface push error")}):this.handleTransmuxComplete(A)}}},{key:"flush",value:function(e){e.transmuxing.start=self.performance.now();var t=this.instanceNo,i=this.transmuxer;if(this.workerContext)this.workerContext.worker.postMessage({instanceNo:t,cmd:"flush",chunkMeta:e});else if(i){var n=i.flush(e);Vx(n)?n.then(t=>{this.handleFlushResult(t,e)}).catch(t=>{this.transmuxerError(t,e,"transmuxer-interface flush error")}):this.handleFlushResult(n,e)}}},{key:"transmuxerError",value:function(e,t,i){this.hls&&(this.error=e,this.hls.trigger(zE.ERROR,{type:jE.MEDIA_ERROR,details:BE.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,part:this.part||void 0,fatal:!1,error:e,err:e,reason:i}))}},{key:"handleFlushResult",value:function(e,t){e.forEach(e=>{this.handleTransmuxComplete(e)}),this.onFlush(t)}},{key:"configureTransmuxer",value:function(e){var t=this.instanceNo,i=this.transmuxer;this.workerContext?this.workerContext.worker.postMessage({instanceNo:t,cmd:"configure",config:e}):i&&i.configure(e)}},{key:"handleTransmuxComplete",value:function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}}])}(),Jx=function(){function e(t,i,n){var a;return u(this,e),(a=s(this,e,[t,i,n,"audio-stream-controller",XE])).mainAnchor=null,a.mainFragLoading=null,a.audioOnly=!1,a.bufferedTrack=null,a.switchingTrack=null,a.trackId=-1,a.waitingData=null,a.mainDetails=null,a.flushing=!1,a.bufferFlushed=!1,a.cachedTrackLoadedData=null,a.registerListeners(),a}return y(e,vD),m(e,[{key:"onHandlerDestroying",value:function(){this.unregisterListeners(),M(e,"onHandlerDestroying",this)([]),this.resetItem()}},{key:"resetItem",value:function(){this.mainDetails=this.mainAnchor=this.mainFragLoading=this.bufferedTrack=this.switchingTrack=this.waitingData=this.cachedTrackLoadedData=null}},{key:"registerListeners",value:function(){M(e,"registerListeners",this)([]);var t=this.hls;t.on(zE.LEVEL_LOADED,this.onLevelLoaded,this),t.on(zE.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.on(zE.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(zE.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(zE.BUFFER_RESET,this.onBufferReset,this),t.on(zE.BUFFER_CREATED,this.onBufferCreated,this),t.on(zE.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(zE.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(zE.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(zE.FRAG_LOADING,this.onFragLoading,this),t.on(zE.FRAG_BUFFERED,this.onFragBuffered,this)}},{key:"unregisterListeners",value:function(){var t=this.hls;t&&(M(e,"unregisterListeners",this)([]),t.off(zE.LEVEL_LOADED,this.onLevelLoaded,this),t.off(zE.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.off(zE.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(zE.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(zE.BUFFER_RESET,this.onBufferReset,this),t.off(zE.BUFFER_CREATED,this.onBufferCreated,this),t.off(zE.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(zE.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(zE.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(zE.FRAG_LOADING,this.onFragLoading,this),t.off(zE.FRAG_BUFFERED,this.onFragBuffered,this))}},{key:"onInitPtsFound",value:function(e,{frag:t,id:i,initPTS:n,timescale:a,trackId:r}){if(i===KE){var o=t.cc,s=this.fragCurrent;if(this.initPTS[o]={baseTime:n,timescale:a,trackId:r},this.log(`InitPTS for cc: ${o} found from main: ${n/a} (${n}/${a}) trackId: ${r}`),this.mainAnchor=t,this.state===mD){var u=this.waitingData;(!u&&!this.loadingParts||u&&u.frag.cc!==o)&&this.syncWithAnchor(t,null==u?void 0:u.frag)}else!this.hls.hasEnoughToStart&&s&&s.cc!==o?(s.abortRequests(),this.syncWithAnchor(t,s)):this.state===aD&&this.tick()}}},{key:"getLoadPosition",value:function(){return!this.startFragRequested&&this.nextLoadPosition>=0?this.nextLoadPosition:M(e,"getLoadPosition",this)([])}},{key:"syncWithAnchor",value:function(e,t){var i,n=(null==(i=this.mainFragLoading)?void 0:i.frag)||null;if(!t||(null==n?void 0:n.cc)!==t.cc){var a=(n||e).cc,r=qP(this.getLevelDetails(),a,this.getLoadPosition());r&&(this.log(`Syncing with main frag at ${r.start} cc ${r.cc}`),this.startFragRequested=!1,this.nextLoadPosition=r.start,this.resetLoadingState(),this.state===aD&&this.doTickIdle())}}},{key:"startLoad",value:function(e,t){if(!this.levels)return this.startPosition=e,void(this.state=nD);var i=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),i>0&&-1===e?(this.log(`Override startPosition with lastCurrentTime @${i.toFixed(3)}`),e=i,this.state=aD):this.state=uD,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}},{key:"doTick",value:function(){switch(this.state){case aD:this.doTickIdle();break;case uD:var t=this.levels,i=this.trackId,n=null==t?void 0:t[i],a=null==n?void 0:n.details;if(a&&!this.waitForLive(n)){if(this.waitForCdnTuneIn(a))break;this.state=mD}break;case sD:this.checkRetryDate();break;case mD:var r=this.waitingData;if(r){var o=r.frag,s=r.part,u=r.cache,l=r.complete,d=this.mainAnchor;if(void 0!==this.initPTS[o.cc]){this.waitingData=null,this.state=oD;var h={frag:o,part:s,payload:u.flush().buffer,networkDetails:null};this._handleFragmentLoadProgress(h),l&&M(e,"_handleFragmentLoadComplete",this)([h])}else d&&d.cc!==r.frag.cc&&this.syncWithAnchor(d,r.frag)}else this.state=aD}this.onTickEnd()}},{key:"resetLoadingState",value:function(){var t=this.waitingData;t&&(this.fragmentTracker.removeFragment(t.frag),this.waitingData=null),M(e,"resetLoadingState",this)([])}},{key:"onTickEnd",value:function(){var e=this.media;null!=e&&e.readyState&&(this.lastCurrentTime=e.currentTime)}},{key:"doTickIdle",value:function(){var e,t=this.hls,i=this.levels,n=this.media,a=this.trackId,r=t.config;if(this.buffering&&(n||this.primaryPrefetch||!this.startFragRequested&&r.startFragPrefetch)&&null!=i&&i[a]){var o=i[a],s=o.details;if(!s||this.waitForLive(o)||this.waitForCdnTuneIn(s))return this.state=uD,void(this.startFragRequested=!1);var u=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&u&&(this.bufferFlushed=!1,this.afterBufferFlushed(u,TT,XE));var l=this.getFwdBufferInfo(u,XE);if(null!==l){if(!this.switchingTrack&&this._streamEnded(l,s))return t.trigger(zE.BUFFER_EOS,{type:"audio"}),void(this.state=hD);var d=l.len,h=t.maxBufferLength,c=s.fragments,m=c[0].start,f=this.getLoadPosition(),v=this.flushing?f:l.end;if(this.switchingTrack&&n){var p=f;s.PTSKnown&&p<m&&(l.end>m||l.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),n.currentTime=m+.05)}if(!(d>=h&&!this.switchingTrack&&v<c[c.length-1].start)){var g=this.getNextFragment(v,s);if(g&&this.isLoopLoading(g,v)&&(g=this.getNextFragmentLoopLoading(g,s,l,KE,h)),g){if(!this.exceedsMaxBuffer(l,h,g)){var y=(null==(e=this.mainFragLoading)?void 0:e.frag)||null;if(!this.audioOnly&&this.startFragRequested&&y&&DT(g)&&!g.endList&&(!s.live||!this.loadingParts&&v<this.hls.liveSyncPosition)&&(this.fragmentTracker.getState(y)===yM&&(this.mainFragLoading=y=null),y&&DT(y))){if(g.start>y.end){var b=this.fragmentTracker.getFragAtPos(v,KE);b&&b.end>y.end&&(y=b,this.mainFragLoading={frag:b,targetBufferTime:null})}if(g.start>y.end)return}this.loadFragment(g,o,v)}}else this.bufferFlushed=!0}}}}},{key:"onMediaDetaching",value:function(t,i){this.bufferFlushed=this.flushing=!1,M(e,"onMediaDetaching",this)([t,i])}},{key:"onAudioTracksUpdated",value:function(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map(e=>new _P(e))}},{key:"onAudioTrackSwitching",value:function(e,t){var i=!!t.url;this.trackId=t.id;var n=this.fragCurrent;n&&(n.abortRequests(),this.removeUnbufferedFrags(n.start)),this.resetLoadingState(),i?(this.switchingTrack=t,this.flushAudioIfNeeded(t),this.state!==nD&&(this.setInterval(100),this.state=aD,this.tick())):(this.resetTransmuxer(),this.switchingTrack=null,this.bufferedTrack=t,this.clearInterval())}},{key:"onManifestLoading",value:function(){M(e,"onManifestLoading",this)([]),this.bufferFlushed=this.flushing=this.audioOnly=!1,this.resetItem(),this.trackId=-1}},{key:"onLevelLoaded",value:function(e,t){this.mainDetails=t.details;var i=this.cachedTrackLoadedData;i&&(this.cachedTrackLoadedData=null,this.onAudioTrackLoaded(zE.AUDIO_TRACK_LOADED,i))}},{key:"onAudioTrackLoaded",value:function(e,t){var i,n=this.levels,a=t.details,r=t.id,o=t.groupId,s=t.track;if(n){var u=this.mainDetails;if(!u||a.endCC>u.endCC||u.expired)return this.cachedTrackLoadedData=t,void(this.state!==nD&&(this.state=uD));this.cachedTrackLoadedData=null,this.log(`Audio track ${r} "${s.name}" of "${o}" loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""},duration:${a.totalduration}`);var l=n[r],d=0;if(a.live||null!=(i=l.details)&&i.live){if(this.checkLiveUpdate(a),a.deltaUpdateFailed)return;var h;if(l.details)d=this.alignPlaylists(a,l.details,null==(h=this.levelLastLoaded)?void 0:h.details);a.alignedSliding||(QA(a,u),a.alignedSliding||ZA(a,u),d=a.fragmentStart)}l.details=a,this.levelLastLoaded=l,this.startFragRequested||this.setStartPosition(u,d),this.hls.trigger(zE.AUDIO_TRACK_UPDATED,{details:a,id:r,groupId:t.groupId}),this.state!==uD||this.waitForCdnTuneIn(a)||(this.state=aD),this.tick()}else this.warn(`Audio tracks reset while loading track ${r} "${s.name}" of "${o}"`)}},{key:"_handleFragmentLoadProgress",value:function(e){var t,i=e.frag,n=e.part,a=e.payload,r=this.config,o=this.trackId,s=this.levels;if(s){var u=s[o];if(u){var l=u.details;if(!l)return this.warn("Audio track details undefined on fragment load progress"),void this.removeUnbufferedFrags(i.start);var d=r.defaultAudioCodec||u.audioCodec||"mp4a.40.2",h=this.transmuxer;h||(h=this.transmuxer=new qx(this.hls,XE,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var c=this.initPTS[i.cc],m=null==(t=i.initSegment)?void 0:t.data;if(void 0!==c){var f=n?n.index:-1,v=-1!==f,p=new FM(i.level,i.sn,i.stats.chunkCount,a.byteLength,f,v);h.push(a,m,d,"",i,n,l.totalduration,!1,p,c)}else{this.log(`Unknown video PTS for cc ${i.cc}, waiting for video PTS before demuxing audio frag ${i.sn} of [${l.startSN} ,${l.endSN}],track ${o}`),(this.waitingData=this.waitingData||{frag:i,part:n,cache:new gD,complete:!1}).cache.push(new Uint8Array(a)),this.state!==nD&&(this.state=mD)}}else this.warn("Audio track is undefined on fragment load progress")}else this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`)}},{key:"_handleFragmentLoadComplete",value:function(t){this.waitingData?this.waitingData.complete=!0:M(e,"_handleFragmentLoadComplete",this)([t])}},{key:"onBufferReset",value:function(){this.mediaBuffer=null}},{key:"onBufferCreated",value:function(e,t){this.bufferFlushed=this.flushing=!1;var i=t.tracks.audio;i&&(this.mediaBuffer=i.buffer||null)}},{key:"onFragLoading",value:function(e,t){!this.audioOnly&&t.frag.type===KE&&DT(t.frag)&&(this.mainFragLoading=t,this.state===aD&&this.tick())}},{key:"onFragBuffered",value:function(e,t){var i=t.frag,n=t.part;if(i.type===XE)if(this.fragContextChanged(i))this.warn(`Fragment ${i.sn}${n?" p: "+n.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);else{if(DT(i)){this.fragPrevious=i;var a=this.switchingTrack;a&&(this.bufferedTrack=a,this.switchingTrack=null,this.hls.trigger(zE.AUDIO_TRACK_SWITCHED,tT({},a)))}this.fragBufferedComplete(i,n),this.media&&this.tick()}else this.audioOnly||i.type!==KE||i.elementaryStreams.video||i.elementaryStreams.audiovideo||(this.audioOnly=!0,this.mainFragLoading=null)}},{key:"onError",value:function(t,i){var n;if(i.fatal)this.state=cD;else switch(i.details){case BE.FRAG_GAP:case BE.FRAG_PARSING_ERROR:case BE.FRAG_DECRYPT_ERROR:case BE.FRAG_LOAD_ERROR:case BE.FRAG_LOAD_TIMEOUT:case BE.KEY_LOAD_ERROR:case BE.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(XE,i);break;case BE.AUDIO_TRACK_LOAD_ERROR:case BE.AUDIO_TRACK_LOAD_TIMEOUT:case BE.LEVEL_PARSING_ERROR:i.levelRetry||this.state!==uD||(null==(n=i.context)?void 0:n.type)!==GE||(this.state=aD);break;case BE.BUFFER_ADD_CODEC_ERROR:case BE.BUFFER_APPEND_ERROR:if("audio"!==i.parent)return;this.reduceLengthAndFlushBuffer(i)||this.resetLoadingState();break;case BE.BUFFER_FULL_ERROR:if("audio"!==i.parent)return;this.reduceLengthAndFlushBuffer(i)&&(this.bufferedTrack=null,M(e,"flushMainBuffer",this)([0,Number.POSITIVE_INFINITY,"audio"]));break;case BE.INTERNAL_EXCEPTION:this.recoverWorkerError(i)}}},{key:"onBufferFlushing",value:function(e,{type:t}){t!==PT&&(this.flushing=!0)}},{key:"onBufferFlushed",value:function(e,{type:t}){if(t!==PT){this.flushing=!1,this.bufferFlushed=!0,this.state===hD&&(this.state=aD);var i=this.mediaBuffer||this.media;i&&(this.afterBufferFlushed(i,t,XE),this.tick())}}},{key:"_handleTransmuxComplete",value:function(e){var t,i="audio",n=this.hls,a=e.remuxResult,r=e.chunkMeta,o=this.getCurrentContext(r);if(o){var s=o.frag,u=o.part,l=o.level,d=l.details,h=a.audio,c=a.text,m=a.id3,f=a.initSegment;if(!this.fragContextChanged(s)&&d){if(this.state=lD,this.switchingTrack&&h&&this.completeAudioSwitch(this.switchingTrack),null!=f&&f.tracks){var v=s.initSegment||s;if(this.unhandledEncryptionError(f,s))return;this._bufferInitSegment(l,f.tracks,v,r),n.trigger(zE.FRAG_PARSING_INIT_SEGMENT,{frag:v,id:i,tracks:f.tracks})}if(h){var p=h.startPTS,g=h.endPTS,y=h.startDTS,b=h.endDTS;u&&(u.elementaryStreams[TT]={startPTS:p,endPTS:g,startDTS:y,endDTS:b}),s.setElementaryStreamInfo(TT,p,g,y,b),this.bufferFragmentData(h,s,u,r)}if(null!=m&&null!=(t=m.samples)&&t.length){var w=ZE({id:i,frag:s,details:d},m);n.trigger(zE.FRAG_PARSING_METADATA,w)}if(c){var k=ZE({id:i,frag:s,details:d},c);n.trigger(zE.FRAG_PARSING_USERDATA,k)}}else this.fragmentTracker.removeFragment(s)}else this.resetWhenMissingContext(r)}},{key:"_bufferInitSegment",value:function(e,t,i,n){if(this.state===lD&&(t.video&&delete t.video,t.audiovideo&&delete t.audiovideo,t.audio)){var a=t.audio;a.id=XE;var r=e.audioCodec;this.log(`Init audio buffer, container:${a.container}, codecs[level/parsed]=[${r}/${a.codec}]`),r&&1===r.split(",").length&&(a.levelCodec=r),this.hls.trigger(zE.BUFFER_CODECS,t);var o=a.initSegment;if(null!=o&&o.byteLength){var s={type:"audio",frag:i,part:null,chunkMeta:n,parent:i.type,data:o};this.hls.trigger(zE.BUFFER_APPENDING,s)}this.tickImmediate()}}},{key:"loadFragment",value:function(t,i,n){var a,r=this.fragmentTracker.getState(t);if(this.switchingTrack||r===vM||r===gM)if(DT(t))if(null!=(a=i.details)&&a.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=mD;var o=this.mainDetails;o&&o.fragmentStart!==i.details.fragmentStart&&ZA(i.details,o)}else M(e,"loadFragment",this)([t,i,n]);else this._loadInitSegment(t,i);else this.clearTrackerIfNeeded(t)}},{key:"flushAudioIfNeeded",value:function(t){if(this.media&&this.bufferedTrack){var i=this.bufferedTrack;BP({name:i.name,lang:i.lang,assocLang:i.assocLang,characteristics:i.characteristics,audioCodec:i.audioCodec,channels:i.channels},t,zP)||(HP(t.url,this.hls)?(this.log("Switching audio track : flushing all audio"),M(e,"flushMainBuffer",this)([0,Number.POSITIVE_INFINITY,"audio"]),this.bufferedTrack=null):this.bufferedTrack=t)}}},{key:"completeAudioSwitch",value:function(e){var t=this.hls;this.flushAudioIfNeeded(e),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(zE.AUDIO_TRACK_SWITCHED,tT({},e))}}])}(),Qx=function(){function e(t,i){var n;return u(this,e),(n=s(this,e,[i,t.logger])).hls=void 0,n.canLoad=!1,n.timer=-1,n.hls=t,n}return y(e,iT),m(e,[{key:"destroy",value:function(){this.clearTimer(),this.hls=this.log=this.warn=null}},{key:"clearTimer",value:function(){-1!==this.timer&&(self.clearTimeout(this.timer),this.timer=-1)}},{key:"startLoad",value:function(){this.canLoad=!0,this.loadPlaylist()}},{key:"stopLoad",value:function(){this.canLoad=!1,this.clearTimer()}},{key:"switchParams",value:function(e,t,i){var n=null==t?void 0:t.renditionReports;if(n){for(var a=-1,r=0;r<n.length;r++){var o=n[r],s=void 0;try{s=new self.URL(o.URI,t.url).href}catch(e){this.warn(`Could not construct new URL for Rendition Report: ${e}`),s=o.URI||""}if(s===e){a=r;break}s===e.substring(0,s.length)&&(a=r)}if(-1!==a){var u=n[a],l=parseInt(u["LAST-MSN"])||t.lastPartSn,d=parseInt(u["LAST-PART"])||t.lastPartIndex;if(this.hls.config.lowLatencyMode){var h=Math.min(t.age-t.partTarget,t.targetduration);d>=0&&h>t.partTarget&&(d+=1)}var c=i&&IP(i);return new LP(l,d>=0?d:void 0,c)}}}},{key:"loadPlaylist",value:function(e){this.clearTimer()}},{key:"loadingPlaylist",value:function(e,t){this.clearTimer()}},{key:"shouldLoadPlaylist",value:function(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}},{key:"getUrlWithDirectives",value:function(e,t){if(t)try{return t.addDirectives(e)}catch(e){this.warn(`Could not construct new URL with HLS Delivery Directives: ${e}`)}return e}},{key:"playlistLoaded",value:function(e,t,i){var n=t.details,a=t.stats,r=self.performance.now(),o=a.loading.first?Math.max(0,r-a.loading.first):0;n.advancedDateTime=Date.now()-o;var s=this.hls.config.timelineOffset;if(s!==n.appliedTimelineOffset){var u=Math.max(s||0,0);n.appliedTimelineOffset=u,n.fragments.forEach(e=>{e.setStart(e.playlistOffset+u)})}if(n.live||null!=i&&i.live){var l="levelInfo"in t?t.levelInfo:t.track;if(n.reloaded(i),i&&n.fragments.length>0){$A(i,n,this);var d=n.playlistParsingError;if(d){this.warn(d);var h=this.hls;if(!h.config.ignorePlaylistParsingErrors){var c,m=t.networkDetails;return void h.trigger(zE.ERROR,{type:jE.NETWORK_ERROR,details:BE.LEVEL_PARSING_ERROR,fatal:!1,url:n.url,error:d,reason:d.message,level:t.level||void 0,parent:null==(c=n.fragments[0])?void 0:c.type,networkDetails:m,stats:a})}n.playlistParsingError=null}}-1===n.requestScheduled&&(n.requestScheduled=a.loading.start);var f,v=this.hls.mainForwardBufferInfo,p=v?v.end-v.len:0,g=zA(n,1e3*(n.edge-p));if(n.requestScheduled+g<r?n.requestScheduled=r:n.requestScheduled+=g,this.log(`live playlist ${e} ${n.advanced?"REFRESHED "+n.lastPartSn+"-"+n.lastPartIndex:n.updated?"UPDATED":"MISSED"}`),!this.canLoad||!n.live)return;var y=void 0,b=void 0;if(n.canBlockReload&&n.endSN&&n.advanced){var w=this.hls.config.lowLatencyMode,k=n.lastPartSn,S=n.endSN,E=n.lastPartIndex,T=k===S;-1!==E?T?(y=S+1,b=w?0:E):(y=k,b=w?E+1:n.maxPartIndex):y=S+1;var P=n.age,M=P+n.ageHeader,A=Math.min(M-n.partTarget,1.5*n.targetduration);if(A>0){if(M>3*n.targetduration)this.log(`Playlist last advanced ${P.toFixed(2)}s ago. Omitting segment and part directives.`),y=void 0,b=void 0;else if(null!=i&&i.tuneInGoal&&M-n.partTarget>i.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${i.tuneInGoal} to: ${A} with playlist age: ${n.age}`),A=0;else{var D=Math.floor(A/n.targetduration);if(y+=D,void 0!==b)b+=Math.round(A%n.targetduration/n.partTarget);this.log(`CDN Tune-in age: ${n.ageHeader}s last advanced ${P.toFixed(2)}s goal: ${A} skip sn ${D} to part ${b}`)}n.tuneInGoal=A}if(f=this.getDeliveryDirectives(n,t.deliveryDirectives,y,b),w||!T)return n.requestScheduled=r,void this.loadingPlaylist(l,f)}else(n.canBlockReload||n.canSkipUntil)&&(f=this.getDeliveryDirectives(n,t.deliveryDirectives,y,b));f&&void 0!==y&&n.canBlockReload&&(n.requestScheduled=a.loading.first+Math.max(g-2*o,g/2)),this.scheduleLoading(l,f,n)}else this.clearTimer()}},{key:"scheduleLoading",value:function(e,t,i){var n=i||e.details;if(n){var a=self.performance.now(),r=n.requestScheduled;if(a>=r)this.loadingPlaylist(e,t);else{var o=r-a;this.log(`reload live playlist ${e.name||e.bitrate+"bps"} in ${Math.round(o)} ms`),this.clearTimer(),this.timer=self.setTimeout(()=>this.loadingPlaylist(e,t),o)}}else this.loadingPlaylist(e,t)}},{key:"getDeliveryDirectives",value:function(e,t,i,n){var a=IP(e);return null!=t&&t.skip&&e.deltaUpdateFailed&&(i=t.msn,n=t.part,a=DP),new LP(i,n,a)}},{key:"checkRetry",value:function(e){var t=e.details,i=JP(e),n=e.errorAction,a=n||{},r=a.action,o=a.retryCount,s=void 0===o?0:o,u=a.retryConfig,l=!!n&&!!u&&(r===uM||!n.resolved&&r===oM);if(l){var d;if(s>=u.maxNumRetry)return!1;if(i&&null!=(d=e.context)&&d.deliveryDirectives)this.warn(`Retrying playlist loading ${s+1}/${u.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{var h=tM(u,s);this.clearTimer(),this.timer=self.setTimeout(()=>this.loadPlaylist(),h),this.warn(`Retrying playlist loading ${s+1}/${u.maxNumRetry} after "${t}" in ${h}ms`)}e.levelRetry=!0,n.resolved=!0}return l}}])}();function Zx(e,t){if(e.length!==t.length)return!1;for(var i=0;i<e.length;i++)if(!eC(e[i].attrs,t[i].attrs))return!1;return!0}function eC(e,t,i){var n=e["STABLE-RENDITION-ID"];return n&&!i?n===t["STABLE-RENDITION-ID"]:!(i||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).some(i=>e[i]!==t[i])}function tC(e,t){return t.label.toLowerCase()===e.name.toLowerCase()&&(!t.language||t.language.toLowerCase()===(e.lang||"").toLowerCase())}var iC=function(){function e(t){var i;return u(this,e),(i=s(this,e,[t,"audio-track-controller"])).tracks=[],i.groupIds=null,i.tracksInGroup=[],i.trackId=-1,i.currentTrack=null,i.selectDefaultTrack=!0,i.registerListeners(),i}return y(e,Qx),m(e,[{key:"registerListeners",value:function(){var e=this.hls;e.on(zE.MANIFEST_LOADING,this.onManifestLoading,this),e.on(zE.MANIFEST_PARSED,this.onManifestParsed,this),e.on(zE.LEVEL_LOADING,this.onLevelLoading,this),e.on(zE.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(zE.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(zE.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(zE.MANIFEST_LOADING,this.onManifestLoading,this),e.off(zE.MANIFEST_PARSED,this.onManifestParsed,this),e.off(zE.LEVEL_LOADING,this.onLevelLoading,this),e.off(zE.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(zE.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(zE.ERROR,this.onError,this)}},{key:"destroy",value:function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,M(e,"destroy",this)([])}},{key:"onManifestLoading",value:function(){this.tracks=[],this.tracksInGroup=[],this.groupIds=null,this.currentTrack=null,this.trackId=-1,this.selectDefaultTrack=!0}},{key:"onManifestParsed",value:function(e,t){this.tracks=t.audioTracks||[]}},{key:"onAudioTrackLoaded",value:function(e,t){var i=t.id,n=t.groupId,a=t.details,r=this.tracksInGroup[i];if(r&&r.groupId===n){var o=r.details;r.details=t.details,this.log(`Audio track ${i} "${r.name}" lang:${r.lang} group:${n} loaded [${a.startSN}-${a.endSN}]`),i===this.trackId&&this.playlistLoaded(i,t,o)}else this.warn(`Audio track with id:${i} and group:${n} not found in active group ${null==r?void 0:r.groupId}`)}},{key:"onLevelLoading",value:function(e,t){this.switchLevel(t.level)}},{key:"onLevelSwitching",value:function(e,t){this.switchLevel(t.level)}},{key:"switchLevel",value:function(e){var t=this.hls.levels[e];if(t){var i=t.audioGroups||null,n=this.groupIds,a=this.currentTrack;if(!i||(null==n?void 0:n.length)!==(null==i?void 0:i.length)||null!=i&&i.some(e=>-1===(null==n?void 0:n.indexOf(e)))){this.groupIds=i,this.trackId=-1,this.currentTrack=null;var r=this.tracks.filter(e=>!i||-1!==i.indexOf(e.groupId));if(r.length)this.selectDefaultTrack&&!r.some(e=>e.default)&&(this.selectDefaultTrack=!1),r.forEach((e,t)=>{e.id=t});else if(!a&&!this.tracksInGroup.length)return;this.tracksInGroup=r;var o=this.hls.config.audioPreference;if(!a&&o){var s=jP(o,r,zP);if(s>-1)a=r[s];else{var u=jP(o,this.tracks);a=this.tracks[u]}}var l=this.findTrackId(a);-1===l&&a&&(l=this.findTrackId(null));var d={audioTracks:r};this.log(`Updating audio tracks, ${r.length} track(s) found in group(s): ${null==i?void 0:i.join(",")}`),this.hls.trigger(zE.AUDIO_TRACKS_UPDATED,d);var h=this.trackId;if(-1!==l&&-1===h)this.setAudioTrack(l);else if(r.length&&-1===h){var c,m=new Error(`No audio track selected for current audio group-ID(s): ${null==(c=this.groupIds)?void 0:c.join(",")} track count: ${r.length}`);this.warn(m.message),this.hls.trigger(zE.ERROR,{type:jE.MEDIA_ERROR,details:BE.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:m})}}}}},{key:"onError",value:function(e,t){!t.fatal&&t.context&&(t.context.type!==GE||t.context.id!==this.trackId||this.groupIds&&-1===this.groupIds.indexOf(t.context.groupId)||this.checkRetry(t))}},{key:"allAudioTracks",get:function(){return this.tracks}},{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}},{key:"setAudioOption",value:function(e){var t=this.hls;if(t.config.audioPreference=e,e){var i=this.allAudioTracks;if(this.selectDefaultTrack=!1,i.length){var n=this.currentTrack;if(n&&BP(e,n,zP))return n;var a=jP(e,this.tracksInGroup,zP);if(a>-1){var r=this.tracksInGroup[a];return this.setAudioTrack(a),r}if(n){var o=t.loadLevel;-1===o&&(o=t.firstAutoLevel);var s=function(e,t,i,n,a){var r=t[n],o=t.reduce((e,t,i)=>{var n=t.uri;return(e[n]||(e[n]=[])).push(i),e},{})[r.uri];o.length>1&&(n=Math.max.apply(Math,o));var s=r.videoRange,u=r.frameRate,l=r.codecSet.substring(0,4),d=UP(t,n,t=>{if(t.videoRange!==s||t.frameRate!==u||t.codecSet.substring(0,4)!==l)return!1;var n=t.audioGroups,r=i.filter(e=>!n||-1!==n.indexOf(e.groupId));return jP(e,r,a)>-1});return d>-1?d:UP(t,n,t=>{var n=t.audioGroups,r=i.filter(e=>!n||-1!==n.indexOf(e.groupId));return jP(e,r,a)>-1})}(e,t.levels,i,o,zP);if(-1===s)return null;t.nextLoadLevel=s}if(e.channels||e.audioCodec){var u=jP(e,i);if(u>-1)return i[u]}}}return null}},{key:"setAudioTrack",value:function(e){var t=this.tracksInGroup;if(e<0||e>=t.length)this.warn(`Invalid audio track id: ${e}`);else{this.selectDefaultTrack=!1;var i=this.currentTrack,n=t[e],a=n.details&&!n.details.live;if(!(e===this.trackId&&n===i&&a||(this.log(`Switching to audio-track ${e} "${n.name}" lang:${n.lang} group:${n.groupId} channels:${n.channels}`),this.trackId=e,this.currentTrack=n,this.hls.trigger(zE.AUDIO_TRACK_SWITCHING,tT({},n)),a))){var r=this.switchParams(n.url,null==i?void 0:i.details,n.details);this.loadPlaylist(r)}}}},{key:"findTrackId",value:function(e){for(var t=this.tracksInGroup,i=0;i<t.length;i++){var n=t[i];if((!this.selectDefaultTrack||n.default)&&(!e||BP(e,n,zP)))return i}if(e){for(var a=e.name,r=e.lang,o=e.assocLang,s=e.characteristics,u=e.audioCodec,l=e.channels,d=0;d<t.length;d++){if(BP({name:a,lang:r,assocLang:o,characteristics:s,audioCodec:u,channels:l},t[d],zP))return d}for(var h=0;h<t.length;h++){var c=t[h];if(eC(e.attrs,c.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return h}for(var m=0;m<t.length;m++){var f=t[m];if(eC(e.attrs,f.attrs,["LANGUAGE"]))return m}}return-1}},{key:"loadPlaylist",value:function(t){M(e,"loadPlaylist",this)([]);var i=this.currentTrack;this.shouldLoadPlaylist(i)&&HP(i.url,this.hls)&&this.scheduleLoading(i,t)}},{key:"loadingPlaylist",value:function(t,i){M(e,"loadingPlaylist",this)([t,i]);var n=t.id,a=t.groupId,r=this.getUrlWithDirectives(t.url,i),o=t.details,s=null==o?void 0:o.age;this.log(`Loading audio-track ${n} "${t.name}" lang:${t.lang} group:${a}${void 0!==(null==i?void 0:i.msn)?" at sn "+i.msn+" part "+i.part:""}${s&&o.live?" age "+s.toFixed(1)+(o.type&&" "+o.type||""):""} ${r}`),this.hls.trigger(zE.AUDIO_TRACK_LOADING,{url:r,id:n,groupId:a,deliveryDirectives:i||null,track:t})}}])}(),nC=function(){return m(function e(t){u(this,e),this.tracks=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.tracks=t},[{key:"destroy",value:function(){this.tracks=this.queues=null}},{key:"append",value:function(e,t,i){if(null!==this.queues&&null!==this.tracks){var n=this.queues[t];n.push(e),1!==n.length||i||this.executeNext(t)}}},{key:"appendBlocker",value:function(e){return new Promise(t=>{var i={label:"async-blocker",execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};this.append(i,e)})}},{key:"prependBlocker",value:function(e){return new Promise(t=>{if(this.queues){var i={label:"async-blocker-prepend",execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};this.queues[e].unshift(i)}})}},{key:"removeBlockers",value:function(){null!==this.queues&&[this.queues.video,this.queues.audio,this.queues.audiovideo].forEach(e=>{var t,i=null==(t=e[0])?void 0:t.label;"async-blocker"!==i&&"async-blocker-prepend"!==i||(e[0].execute(),e.splice(0,1))})}},{key:"unblockAudio",value:function(e){null!==this.queues&&(this.queues.audio[0]===e&&this.shiftAndExecuteNext("audio"))}},{key:"executeNext",value:function(e){if(null!==this.queues&&null!==this.tracks){var t=this.queues[e];if(t.length){var i=t[0];try{i.execute()}catch(t){var n;if(i.onError(t),null===this.queues||null===this.tracks)return;var a=null==(n=this.tracks[e])?void 0:n.buffer;null!=a&&a.updating||this.shiftAndExecuteNext(e)}}}}},{key:"shiftAndExecuteNext",value:function(e){null!==this.queues&&(this.queues[e].shift(),this.executeNext(e))}},{key:"current",value:function(e){var t;return(null==(t=this.queues)?void 0:t[e][0])||null}},{key:"toString",value:function(){var e=this.queues,t=this.tracks;return null===e||null===t?"<destroyed>":`\n${this.list("video")}\n${this.list("audio")}\n${this.list("audiovideo")}}`}},{key:"list",value:function(e){var t,i;return null!=(t=this.queues)&&t[e]||null!=(i=this.tracks)&&i[e]?`${e}: (${this.listSbInfo(e)}) ${this.listOps(e)}`:""}},{key:"listSbInfo",value:function(e){var t,i=null==(t=this.tracks)?void 0:t[e],n=null==i?void 0:i.buffer;return n?`SourceBuffer${n.updating?" updating":""}${i.ended?" ended":""}${i.ending?" ending":""}`:"none"}},{key:"listOps",value:function(e){var t;return(null==(t=this.queues)?void 0:t[e].map(e=>e.label).join(", "))||""}}])}(),aC=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,rC="HlsJsTrackRemovedError",oC=function(){function e(t){var i;return u(this,e),(i=s(this,e,[t])).name=rC,i}return y(e,D(Error)),m(e)}(),sC=function(){function e(t,i){var n,a;return u(this,e),(n=s(this,e,["buffer-controller",t.logger])).hls=void 0,n.fragmentTracker=void 0,n.details=null,n._objectUrl=null,n.operationQueue=null,n.bufferCodecEventsTotal=0,n.media=null,n.mediaSource=null,n.lastMpegAudioChunk=null,n.blockedAudioAppend=null,n.lastVideoAppendEnd=0,n.appendSource=void 0,n.transferData=void 0,n.overrides=void 0,n.appendErrors={audio:0,video:0,audiovideo:0},n.tracks={},n.sourceBuffers=[[null,null],[null,null]],n._onEndStreaming=e=>{var t;n.hls&&"open"===(null==(t=n.mediaSource)?void 0:t.readyState)&&n.hls.pauseBuffering()},n._onStartStreaming=e=>{n.hls&&n.hls.resumeBuffering()},n._onMediaSourceOpen=e=>{var t=n,i=t.media,a=t.mediaSource;e&&n.log("Media source opened"),i&&a&&(a.removeEventListener("sourceopen",n._onMediaSourceOpen),i.removeEventListener("emptied",n._onMediaEmptied),n.updateDuration(),n.hls.trigger(zE.MEDIA_ATTACHED,{media:i,mediaSource:a}),null!==n.mediaSource&&n.checkPendingTracks())},n._onMediaSourceClose=()=>{n.log("Media source closed")},n._onMediaSourceEnded=()=>{n.log("Media source ended")},n._onMediaEmptied=()=>{var e=n,t=e.mediaSrc,i=e._objectUrl;t!==i&&n.error(`Media element src was set while attaching MediaSource (${i} > ${t})`)},n.hls=t,n.fragmentTracker=i,n.appendSource=(a=lT(t.config.preferManagedMediaSource),"undefined"!=typeof self&&a===self.ManagedMediaSource),n.initTracks(),n.registerListeners(),n}return y(e,iT),m(e,[{key:"hasSourceTypes",value:function(){return Object.keys(this.tracks).length>0}},{key:"destroy",value:function(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.transferData=this.overrides=void 0,this.operationQueue&&(this.operationQueue.destroy(),this.operationQueue=null),this.hls=this.fragmentTracker=null,this._onMediaSourceOpen=this._onMediaSourceClose=null,this._onMediaSourceEnded=null,this._onStartStreaming=this._onEndStreaming=null}},{key:"registerListeners",value:function(){var e=this.hls;e.on(zE.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(zE.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(zE.MANIFEST_LOADING,this.onManifestLoading,this),e.on(zE.MANIFEST_PARSED,this.onManifestParsed,this),e.on(zE.BUFFER_RESET,this.onBufferReset,this),e.on(zE.BUFFER_APPENDING,this.onBufferAppending,this),e.on(zE.BUFFER_CODECS,this.onBufferCodecs,this),e.on(zE.BUFFER_EOS,this.onBufferEos,this),e.on(zE.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(zE.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(zE.FRAG_PARSED,this.onFragParsed,this),e.on(zE.FRAG_CHANGED,this.onFragChanged,this),e.on(zE.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(zE.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(zE.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(zE.MANIFEST_LOADING,this.onManifestLoading,this),e.off(zE.MANIFEST_PARSED,this.onManifestParsed,this),e.off(zE.BUFFER_RESET,this.onBufferReset,this),e.off(zE.BUFFER_APPENDING,this.onBufferAppending,this),e.off(zE.BUFFER_CODECS,this.onBufferCodecs,this),e.off(zE.BUFFER_EOS,this.onBufferEos,this),e.off(zE.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(zE.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(zE.FRAG_PARSED,this.onFragParsed,this),e.off(zE.FRAG_CHANGED,this.onFragChanged,this),e.off(zE.ERROR,this.onError,this)}},{key:"transferMedia",value:function(){var e=this.media,t=this.mediaSource;if(!e)return null;var i={};if(this.operationQueue){var n=this.isUpdating();n||this.operationQueue.removeBlockers();var a=this.isQueued();(n||a)&&this.warn(`Transfering MediaSource with${a?" operations in queue":""}${n?" updating SourceBuffer(s)":""} ${this.operationQueue}`),this.operationQueue.destroy()}var r=this.transferData;return!this.sourceBufferCount&&r&&r.mediaSource===t?ZE(i,r.tracks):this.sourceBuffers.forEach(e=>{var t=e[0];t&&(i[t]=ZE({},this.tracks[t]),this.removeBuffer(t)),e[0]=e[1]=null}),{media:e,mediaSource:t,tracks:i}}},{key:"initTracks",value:function(){this.sourceBuffers=[[null,null],[null,null]],this.tracks={},this.resetQueue(),this.resetAppendErrors(),this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.lastVideoAppendEnd=0}},{key:"onManifestLoading",value:function(){this.bufferCodecEventsTotal=0,this.details=null}},{key:"onManifestParsed",value:function(e,t){var i,n=2;(t.audio&&!t.video||!t.altAudio)&&(n=1),this.bufferCodecEventsTotal=n,this.log(`${n} bufferCodec event(s) expected.`),null!=(i=this.transferData)&&i.mediaSource&&this.sourceBufferCount&&n&&this.bufferCreated()}},{key:"onMediaAttaching",value:function(e,t){var i=this.media=t.media;this.transferData=this.overrides=void 0;var n=lT(this.appendSource);if(n){var a=!!t.mediaSource;(a||t.overrides)&&(this.transferData=t,this.overrides=t.overrides);var r=this.mediaSource=t.mediaSource||new n;if(this.assignMediaSource(r),a)this._objectUrl=i.src,this.attachTransferred();else{var o=this._objectUrl=self.URL.createObjectURL(r);if(this.appendSource)try{i.removeAttribute("src");var s=self.ManagedMediaSource;i.disableRemotePlayback=i.disableRemotePlayback||s&&r instanceof s,uC(i),function(e,t){var i=self.document.createElement("source");i.type="video/mp4",i.src=t,e.appendChild(i)}(i,o),i.load()}catch(e){i.src=o}else i.src=o}i.addEventListener("emptied",this._onMediaEmptied)}}},{key:"assignMediaSource",value:function(e){var t,i;this.log(`${(null==(t=this.transferData)?void 0:t.mediaSource)===e?"transferred":"created"} media source: ${null==(i=e.constructor)?void 0:i.name}`),e.addEventListener("sourceopen",this._onMediaSourceOpen),e.addEventListener("sourceended",this._onMediaSourceEnded),e.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(e.addEventListener("startstreaming",this._onStartStreaming),e.addEventListener("endstreaming",this._onEndStreaming))}},{key:"attachTransferred",value:function(){var e=this.media,t=this.transferData;if(t&&e){var i=this.tracks,n=t.tracks,a=n?Object.keys(n):null,r=a?a.length:0,o=()=>{Promise.resolve().then(()=>{this.media&&this.mediaSourceOpenOrEnded&&this._onMediaSourceOpen()})};if(n&&a&&r){if(!this.tracksReady)return this.hls.config.startFragPrefetch=!0,void this.log("attachTransferred: waiting for SourceBuffer track info");if(this.log(`attachTransferred: (bufferCodecEventsTotal ${this.bufferCodecEventsTotal})\nrequired tracks: ${OP(i,(e,t)=>"initSegment"===e?void 0:t)};\ntransfer tracks: ${OP(n,(e,t)=>"initSegment"===e?void 0:t)}}`),!dT(n,i)){t.mediaSource=null,t.tracks=void 0;var s=e.currentTime,u=this.details,l=Math.max(s,(null==u?void 0:u.fragments[0].start)||0);return l-s>1?void this.log(`attachTransferred: waiting for playback to reach new tracks start time ${s} -> ${l}`):(this.warn(`attachTransferred: resetting MediaSource for incompatible tracks ("${Object.keys(n)}"->"${Object.keys(i)}") start time: ${l} currentTime: ${s}`),this.onMediaDetaching(zE.MEDIA_DETACHING,{}),this.onMediaAttaching(zE.MEDIA_ATTACHING,t),void(e.currentTime=l))}this.transferData=void 0,a.forEach(e=>{var t=e,i=n[t];if(i){var a=i.buffer;if(a){var r=this.fragmentTracker,o=i.id;if(r.hasFragments(o)||r.hasParts(o)){var s=WM.getBuffered(a);r.detectEvictedFragments(t,s,o,null,!0)}var u=lC(t),l=[t,a];this.sourceBuffers[u]=l,a.updating&&this.operationQueue&&this.operationQueue.prependBlocker(t),this.trackSourceBuffer(t,i)}}}),o(),this.bufferCreated()}else this.log("attachTransferred: MediaSource w/o SourceBuffers"),o()}}},{key:"mediaSourceOpenOrEnded",get:function(){var e,t=null==(e=this.mediaSource)?void 0:e.readyState;return"open"===t||"ended"===t}},{key:"onMediaDetaching",value:function(e,t){var i=!!t.transferMedia;this.transferData=this.overrides=void 0;var n=this.media,a=this.mediaSource,r=this._objectUrl;if(a){if(this.log("media source "+(i?"transferring":"detaching")),i)this.sourceBuffers.forEach(([e])=>{e&&this.removeBuffer(e)}),this.resetQueue();else{if(this.mediaSourceOpenOrEnded){var o="open"===a.readyState;try{for(var s=a.sourceBuffers,u=s.length;u--;)o&&s[u].abort(),a.removeSourceBuffer(s[u]);o&&a.endOfStream()}catch(e){this.warn(`onMediaDetaching: ${e.message} while calling endOfStream`)}}this.sourceBufferCount&&this.onBufferReset()}a.removeEventListener("sourceopen",this._onMediaSourceOpen),a.removeEventListener("sourceended",this._onMediaSourceEnded),a.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(a.removeEventListener("startstreaming",this._onStartStreaming),a.removeEventListener("endstreaming",this._onEndStreaming)),this.mediaSource=null,this._objectUrl=null}n&&(n.removeEventListener("emptied",this._onMediaEmptied),i||(r&&self.URL.revokeObjectURL(r),this.mediaSrc===r?(n.removeAttribute("src"),this.appendSource&&uC(n),n.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.media=null),this.hls.trigger(zE.MEDIA_DETACHED,t)}},{key:"onBufferReset",value:function(){this.sourceBuffers.forEach(([e])=>{e&&this.resetBuffer(e)}),this.initTracks()}},{key:"resetBuffer",value:function(e){var t,i=null==(t=this.tracks[e])?void 0:t.buffer;if(this.removeBuffer(e),i)try{var n;null!=(n=this.mediaSource)&&n.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(i)}catch(t){this.warn(`onBufferReset ${e}`,t)}delete this.tracks[e]}},{key:"removeBuffer",value:function(e){this.removeBufferListeners(e),this.sourceBuffers[lC(e)]=[null,null];var t=this.tracks[e];t&&(t.buffer=void 0)}},{key:"resetQueue",value:function(){this.operationQueue&&this.operationQueue.destroy(),this.operationQueue=new nC(this.tracks)}},{key:"onBufferCodecs",value:function(e,t){var i,n=this.tracks,a=Object.keys(t);this.log(`BUFFER_CODECS: "${a}" (current SB count ${this.sourceBufferCount})`);var r="audiovideo"in t&&(n.audio||n.video)||n.audiovideo&&("audio"in t||"video"in t),o=!r&&this.sourceBufferCount&&this.media&&a.some(e=>!n[e]);r||o?this.warn(`Unsupported transition between "${Object.keys(n)}" and "${a}" SourceBuffers`):(a.forEach(e=>{var i,a,r=t[e],o=r.id,s=r.codec,u=r.levelCodec,l=r.container,d=r.metadata,h=r.supplemental,c=n[e],m=null==(i=this.transferData)||null==(i=i.tracks)?void 0:i[e],f=null!=m&&m.buffer?m:c,v=(null==f?void 0:f.pendingCodec)||(null==f?void 0:f.codec),p=null==f?void 0:f.levelCodec;c||(c=n[e]={buffer:void 0,listeners:[],codec:s,supplemental:h,container:l,levelCodec:u,metadata:d,id:o});var g=vP(v,p),y=null==g?void 0:g.replace(aC,"$1"),b=vP(s,u),w=null==(a=b)?void 0:a.replace(aC,"$1");b&&g&&y!==w&&("audio"===e.slice(0,5)&&(b=fP(b,this.appendSource)),this.log(`switching codec ${v} to ${b}`),b!==(c.pendingCodec||c.codec)&&(c.pendingCodec=b),c.container=l,this.appendChangeType(e,l,b))}),(this.tracksReady||this.sourceBufferCount)&&(t.tracks=this.sourceBufferTracks),this.sourceBufferCount||(this.bufferCodecEventsTotal>1&&!this.tracks.video&&!t.video&&"main"===(null==(i=t.audio)?void 0:i.id)&&(this.log("Main audio-only"),this.bufferCodecEventsTotal=1),this.mediaSourceOpenOrEnded&&this.checkPendingTracks()))}},{key:"sourceBufferTracks",get:function(){return Object.keys(this.tracks).reduce((e,t)=>{var i=this.tracks[t];return e[t]={id:i.id,container:i.container,codec:i.codec,levelCodec:i.levelCodec},e},{})}},{key:"appendChangeType",value:function(e,t,i){var n=`${t};codecs=${i}`,a={label:`change-type=${n}`,execute:()=>{var a=this.tracks[e];if(a){var r=a.buffer;null!=r&&r.changeType&&(this.log(`changing ${e} sourceBuffer type to ${n}`),r.changeType(n),a.codec=i,a.container=t)}this.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:t=>{this.warn(`Failed to change ${e} SourceBuffer type`,t)}};this.append(a,e,this.isPending(this.tracks[e]))}},{key:"blockAudio",value:function(e){var t,i=e.start,n=i+.05*e.duration;if(!(!0===(null==(t=this.fragmentTracker.getAppendedFrag(i,KE))?void 0:t.gap))){var a={label:"block-audio",execute:()=>{var e,t=this.tracks.video;(this.lastVideoAppendEnd>n||null!=t&&t.buffer&&WM.isBuffered(t.buffer,n)||!0===(null==(e=this.fragmentTracker.getAppendedFrag(n,KE))?void 0:e.gap))&&(this.blockedAudioAppend=null,this.shiftAndExecuteNext("audio"))},onStart:()=>{},onComplete:()=>{},onError:e=>{this.warn("Error executing block-audio operation",e)}};this.blockedAudioAppend={op:a,frag:e},this.append(a,"audio",!0)}}},{key:"unblockAudio",value:function(){var e=this.blockedAudioAppend,t=this.operationQueue;e&&t&&(this.blockedAudioAppend=null,t.unblockAudio(e.op))}},{key:"onBufferAppending",value:function(e,t){var i=this.tracks,n=t.data,a=t.type,r=t.parent,o=t.frag,s=t.part,u=t.chunkMeta,l=t.offset,d=u.buffering[a],h=o.sn,c=o.cc,m=self.performance.now();d.start=m;var f=o.stats.buffering,v=s?s.stats.buffering:null;0===f.start&&(f.start=m),v&&0===v.start&&(v.start=m);var p=i.audio,g=!1;"audio"===a&&"audio/mpeg"===(null==p?void 0:p.container)&&(g=!this.lastMpegAudioChunk||1===u.id||this.lastMpegAudioChunk.sn!==u.sn,this.lastMpegAudioChunk=u);var y=i.video,b=null==y?void 0:y.buffer;if(b&&"initSegment"!==h){var w=s||o,k=this.blockedAudioAppend;if("audio"!==a||"main"===r||this.blockedAudioAppend||y.ending||y.ended){if("video"===a){var S=w.end;if(k){var E=k.frag.start;(S>E||S<this.lastVideoAppendEnd||WM.isBuffered(b,E))&&this.unblockAudio()}this.lastVideoAppendEnd=S}}else{var T=w.start+.05*w.duration,P=b.buffered,M=this.currentOp("video");P.length||M?!M&&!WM.isBuffered(b,T)&&this.lastVideoAppendEnd<T&&this.blockAudio(w):this.blockAudio(w)}}var A=(s||o).start,D={label:`append-${a}`,execute:()=>{var e;d.executeStart=self.performance.now();var t=null==(e=this.tracks[a])?void 0:e.buffer;t&&(g?this.updateTimestampOffset(t,A,.1,a,h,c):void 0!==l&&WE(l)&&this.updateTimestampOffset(t,l,1e-6,a,h,c)),this.appendExecutor(n,a)},onStart:()=>{},onComplete:()=>{var e=self.performance.now();d.executeEnd=d.end=e,0===f.first&&(f.first=e),v&&0===v.first&&(v.first=e);var t={};this.sourceBuffers.forEach(([e,i])=>{e&&(t[e]=WM.getBuffered(i))}),this.appendErrors[a]=0,"audio"===a||"video"===a?this.appendErrors.audiovideo=0:(this.appendErrors.audio=0,this.appendErrors.video=0),this.hls.trigger(zE.BUFFER_APPENDED,{type:a,frag:o,part:s,chunkMeta:u,parent:o.type,timeRanges:t})},onError:e=>{var t,i={type:jE.MEDIA_ERROR,parent:o.type,details:BE.BUFFER_APPEND_ERROR,sourceBufferName:a,frag:o,part:s,chunkMeta:u,error:e,err:e,fatal:!1},n=null==(t=this.media)?void 0:t.error;if(e.code===DOMException.QUOTA_EXCEEDED_ERR||"QuotaExceededError"==e.name||"quota"in e)i.details=BE.BUFFER_FULL_ERROR;else if(e.code===DOMException.INVALID_STATE_ERR&&this.mediaSourceOpenOrEnded&&!n)i.errorAction=fM(!0);else if(e.name===rC&&0===this.sourceBufferCount)i.errorAction=fM(!0);else{var r=++this.appendErrors[a];this.warn(`Failed ${r}/${this.hls.config.appendErrorMaxRetry} times to append segment in "${a}" sourceBuffer (${n||"no media error"})`),(r>=this.hls.config.appendErrorMaxRetry||n)&&(i.fatal=!0)}this.hls.trigger(zE.ERROR,i)}};this.log(`queuing "${a}" append sn: ${h}${s?" p: "+s.index:""} of ${o.type===KE?"level":"track"} ${o.level} cc: ${c}`),this.append(D,a,this.isPending(this.tracks[a]))}},{key:"getFlushOp",value:function(e,t,i){return this.log(`queuing "${e}" remove ${t}-${i}`),{label:"remove",execute:()=>{this.removeExecutor(e,t,i)},onStart:()=>{},onComplete:()=>{this.hls.trigger(zE.BUFFER_FLUSHED,{type:e})},onError:n=>{this.warn(`Failed to remove ${t}-${i} from "${e}" SourceBuffer`,n)}}}},{key:"onBufferFlushing",value:function(e,t){var i=t.type,n=t.startOffset,a=t.endOffset;i?this.append(this.getFlushOp(i,n,a),i):this.sourceBuffers.forEach(([e])=>{e&&this.append(this.getFlushOp(e,n,a),e)})}},{key:"onFragParsed",value:function(e,t){var i=t.frag,n=t.part,a=[],r=n?n.elementaryStreams:i.elementaryStreams;r[MT]?a.push("audiovideo"):(r[TT]&&a.push("audio"),r[PT]&&a.push("video"));0===a.length&&this.warn(`Fragments must have at least one ElementaryStreamType set. type: ${i.type} level: ${i.level} sn: ${i.sn}`),this.blockBuffers(()=>{var e=self.performance.now();i.stats.buffering.end=e,n&&(n.stats.buffering.end=e);var t=n?n.stats:i.stats;this.hls.trigger(zE.FRAG_BUFFERED,{frag:i,part:n,stats:t,id:i.type})},a).catch(e=>{this.warn(`Fragment buffered callback ${e}`),this.stepOperationQueue(this.sourceBufferTypes)})}},{key:"onFragChanged",value:function(e,t){this.trimBuffers()}},{key:"bufferedToEnd",get:function(){return this.sourceBufferCount>0&&!this.sourceBuffers.some(([e])=>{if(e){var t=this.tracks[e];if(t)return!t.ended||t.ending}return!1})}},{key:"onBufferEos",value:function(e,t){var i;this.sourceBuffers.forEach(([e])=>{if(e){var i=this.tracks[e];t.type&&t.type!==e||(i.ending=!0,i.ended||(i.ended=!0,this.log(`${e} buffer reached EOS`)))}});var n=!1!==(null==(i=this.overrides)?void 0:i.endOfStream);this.sourceBufferCount>0&&!this.sourceBuffers.some(([e])=>{var t;return e&&!(null!=(t=this.tracks[e])&&t.ended)})?n?(this.log("Queueing EOS"),this.blockUntilOpen(()=>{this.tracksEnded();var e=this.mediaSource;e&&"open"===e.readyState?(this.log("Calling mediaSource.endOfStream()"),e.endOfStream(),this.hls.trigger(zE.BUFFERED_TO_END,void 0)):e&&this.log(`Could not call mediaSource.endOfStream(). mediaSource.readyState: ${e.readyState}`)})):(this.tracksEnded(),this.hls.trigger(zE.BUFFERED_TO_END,void 0)):"video"===t.type&&this.unblockAudio()}},{key:"tracksEnded",value:function(){this.sourceBuffers.forEach(([e])=>{if(null!==e){var t=this.tracks[e];t&&(t.ending=!1)}})}},{key:"onLevelUpdated",value:function(e,{details:t}){t.fragments.length&&(this.details=t,this.updateDuration())}},{key:"updateDuration",value:function(){this.blockUntilOpen(()=>{var e=this.getDurationAndRange();e&&this.updateMediaSource(e)})}},{key:"onError",value:function(e,t){if(t.details===BE.BUFFER_APPEND_ERROR&&t.frag){var i,n=null==(i=t.errorAction)?void 0:i.nextAutoLevel;WE(n)&&n!==t.frag.level&&this.resetAppendErrors()}}},{key:"resetAppendErrors",value:function(){this.appendErrors={audio:0,video:0,audiovideo:0}}},{key:"trimBuffers",value:function(){var e=this.hls,t=this.details,i=this.media;if(i&&null!==t&&this.sourceBufferCount){var n=e.config,a=i.currentTime,r=t.levelTargetDuration,o=t.live&&null!==n.liveBackBufferLength?n.liveBackBufferLength:n.backBufferLength;if(WE(o)&&o>=0){var s=Math.max(o,r),u=Math.floor(a/r)*r-s;this.flushBackBuffer(a,r,u)}var l=n.frontBufferFlushThreshold;if(WE(l)&&l>0){var d=Math.max(n.maxBufferLength,l),h=Math.max(d,r),c=Math.floor(a/r)*r+h;this.flushFrontBuffer(a,r,c)}}}},{key:"flushBackBuffer",value:function(e,t,i){this.sourceBuffers.forEach(([e,t])=>{if(t){var n=WM.getBuffered(t);if(n.length>0&&i>n.start(0)){var a;this.hls.trigger(zE.BACK_BUFFER_REACHED,{bufferEnd:i});var r=this.tracks[e];if(null!=(a=this.details)&&a.live)this.hls.trigger(zE.LIVE_BACK_BUFFER_REACHED,{bufferEnd:i});else if(null!=r&&r.ended)return void this.log(`Cannot flush ${e} back buffer while SourceBuffer is in ended state`);this.hls.trigger(zE.BUFFER_FLUSHING,{startOffset:0,endOffset:i,type:e})}}})}},{key:"flushFrontBuffer",value:function(e,t,i){this.sourceBuffers.forEach(([t,n])=>{if(n){var a=WM.getBuffered(n),r=a.length;if(r<2)return;var o=a.start(r-1),s=a.end(r-1);if(i>o||e>=o&&e<=s)return;this.hls.trigger(zE.BUFFER_FLUSHING,{startOffset:o,endOffset:1/0,type:t})}})}},{key:"getDurationAndRange",value:function(){var e,t=this.details,i=this.mediaSource;if(!t||!this.media||"open"!==(null==i?void 0:i.readyState))return null;var n=t.edge;if(t.live&&this.hls.config.liveDurationInfinity){if(t.fragments.length&&i.setLiveSeekableRange){var a=Math.max(0,t.fragmentStart);return{duration:1/0,start:a,end:Math.max(a,n)}}return{duration:1/0}}var r=null==(e=this.overrides)?void 0:e.duration;if(r)return WE(r)?{duration:r}:null;var o=this.media.duration;return n>(WE(i.duration)?i.duration:0)&&n>o||!WE(o)?{duration:n}:null}},{key:"updateMediaSource",value:function({duration:e,start:t,end:i}){var n=this.mediaSource;this.media&&n&&"open"===n.readyState&&(n.duration!==e&&(WE(e)&&this.log(`Updating MediaSource duration to ${e.toFixed(3)}`),n.duration=e),void 0!==t&&void 0!==i&&(this.log(`MediaSource duration is set to ${n.duration}. Setting seekable range to ${t}-${i}.`),n.setLiveSeekableRange(t,i)))}},{key:"tracksReady",get:function(){var e=this.pendingTrackCount;return e>0&&(e>=this.bufferCodecEventsTotal||this.isPending(this.tracks.audiovideo))}},{key:"checkPendingTracks",value:function(){var e=this.bufferCodecEventsTotal,t=this.pendingTrackCount,i=this.tracks;if(this.log(`checkPendingTracks (pending: ${t} codec events expected: ${e}) ${OP(i)}`),this.tracksReady){var n,a=null==(n=this.transferData)?void 0:n.tracks;a&&Object.keys(a).length?this.attachTransferred():this.createSourceBuffers()}}},{key:"bufferCreated",value:function(){if(this.sourceBufferCount){var e={};this.sourceBuffers.forEach(([t,i])=>{if(t){var n=this.tracks[t];e[t]={buffer:i,container:n.container,codec:n.codec,supplemental:n.supplemental,levelCodec:n.levelCodec,id:n.id,metadata:n.metadata}}}),this.hls.trigger(zE.BUFFER_CREATED,{tracks:e}),this.log(`SourceBuffers created. Running queue: ${this.operationQueue}`),this.sourceBuffers.forEach(([e])=>{this.executeNext(e)})}else{var t=new Error("could not create source buffer for media codec(s)");this.hls.trigger(zE.ERROR,{type:jE.MEDIA_ERROR,details:BE.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:t,reason:t.message})}}},{key:"createSourceBuffers",value:function(){var e=this.tracks,t=this.sourceBuffers,i=this.mediaSource;if(!i)throw new Error("createSourceBuffers called when mediaSource was null");for(var n in e){var a=n,r=e[a];if(this.isPending(r)){var o=this.getTrackCodec(r,a),s=`${r.container};codecs=${o}`;r.codec=o,this.log(`creating sourceBuffer(${s})${this.currentOp(a)?" Queued":""} ${OP(r)}`);try{var u=i.addSourceBuffer(s),l=lC(a),d=[a,u];t[l]=d,r.buffer=u}catch(e){var h;return this.error(`error while trying to add sourceBuffer: ${e.message}`),this.shiftAndExecuteNext(a),null==(h=this.operationQueue)||h.removeBlockers(),delete this.tracks[a],void this.hls.trigger(zE.ERROR,{type:jE.MEDIA_ERROR,details:BE.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:e,sourceBufferName:a,mimeType:s,parent:r.id})}this.trackSourceBuffer(a,r)}}this.bufferCreated()}},{key:"getTrackCodec",value:function(e,t){var i=e.supplemental,n=e.codec;i&&("video"===t||"audiovideo"===t)&&sP(i,"video")&&(n=function(e,t){var i=[];if(e)for(var n=e.split(","),a=0;a<n.length;a++)oP(n[a],"video")||i.push(n[a]);return t&&i.push(t),i.join(",")}(n,i));var a=vP(n,e.levelCodec);return a?"audio"===t.slice(0,5)?fP(a,this.appendSource):a:""}},{key:"trackSourceBuffer",value:function(e,t){var i=t.buffer;if(i){var n=this.getTrackCodec(t,e);this.tracks[e]={buffer:i,codec:n,container:t.container,levelCodec:t.levelCodec,supplemental:t.supplemental,metadata:t.metadata,id:t.id,listeners:[]},this.removeBufferListeners(e),this.addBufferListener(e,"updatestart",this.onSBUpdateStart),this.addBufferListener(e,"updateend",this.onSBUpdateEnd),this.addBufferListener(e,"error",this.onSBUpdateError),this.appendSource&&this.addBufferListener(e,"bufferedchange",(e,t)=>{var i=t.removedRanges;null!=i&&i.length&&this.hls.trigger(zE.BUFFER_FLUSHED,{type:e})})}}},{key:"mediaSrc",get:function(){var e,t,i=(null==(e=this.media)||null==(t=e.querySelector)?void 0:t.call(e,"source"))||this.media;return null==i?void 0:i.src}},{key:"onSBUpdateStart",value:function(e){var t=this.currentOp(e);t&&t.onStart()}},{key:"onSBUpdateEnd",value:function(e){var t;if("closed"!==(null==(t=this.mediaSource)?void 0:t.readyState)){var i=this.currentOp(e);i&&(i.onComplete(),this.shiftAndExecuteNext(e))}else this.resetBuffer(e)}},{key:"onSBUpdateError",value:function(e,t){var i,n=new Error(`${e} SourceBuffer error. MediaSource readyState: ${null==(i=this.mediaSource)?void 0:i.readyState}`);this.error(`${n}`,t),this.hls.trigger(zE.ERROR,{type:jE.MEDIA_ERROR,details:BE.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:n,fatal:!1});var a=this.currentOp(e);a&&a.onError(n)}},{key:"updateTimestampOffset",value:function(e,t,i,n,a,r){var o=t-e.timestampOffset;Math.abs(o)>=i&&(this.log(`Updating ${n} SourceBuffer timestampOffset to ${t} (sn: ${a} cc: ${r})`),e.timestampOffset=t)}},{key:"removeExecutor",value:function(e,t,i){var n=this.media,a=this.mediaSource,r=this.tracks[e],o=null==r?void 0:r.buffer;if(!n||!a||!o)return this.warn(`Attempting to remove from the ${e} SourceBuffer, but it does not exist`),void this.shiftAndExecuteNext(e);var s=WE(n.duration)?n.duration:1/0,u=WE(a.duration)?a.duration:1/0,l=Math.max(0,t),d=Math.min(i,s,u);d>l&&(!r.ending||r.ended)?(r.ended=!1,this.log(`Removing [${l},${d}] from the ${e} SourceBuffer`),o.remove(l,d)):this.shiftAndExecuteNext(e)}},{key:"appendExecutor",value:function(e,t){var i=this.tracks[t],n=null==i?void 0:i.buffer;if(!n)throw new oC(`Attempting to append to the ${t} SourceBuffer, but it does not exist`);i.ending=!1,i.ended=!1,n.appendBuffer(e)}},{key:"blockUntilOpen",value:function(e){if(this.isUpdating()||this.isQueued())this.blockBuffers(e).catch(e=>{this.warn(`SourceBuffer blocked callback ${e}`),this.stepOperationQueue(this.sourceBufferTypes)});else try{e()}catch(e){this.warn(`Callback run without blocking ${this.operationQueue} ${e}`)}}},{key:"isUpdating",value:function(){return this.sourceBuffers.some(([e,t])=>e&&t.updating)}},{key:"isQueued",value:function(){return this.sourceBuffers.some(([e])=>e&&!!this.currentOp(e))}},{key:"isPending",value:function(e){return!!e&&!e.buffer}},{key:"blockBuffers",value:function(e,t=this.sourceBufferTypes){if(!t.length)return this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);var i=this.operationQueue,n=t.map(e=>this.appendBlocker(e));return t.length>1&&!!this.blockedAudioAppend&&this.unblockAudio(),Promise.all(n).then(t=>{i===this.operationQueue&&(e(),this.stepOperationQueue(this.sourceBufferTypes))})}},{key:"stepOperationQueue",value:function(e){e.forEach(e=>{var t,i=null==(t=this.tracks[e])?void 0:t.buffer;i&&!i.updating&&this.shiftAndExecuteNext(e)})}},{key:"append",value:function(e,t,i){this.operationQueue&&this.operationQueue.append(e,t,i)}},{key:"appendBlocker",value:function(e){if(this.operationQueue)return this.operationQueue.appendBlocker(e)}},{key:"currentOp",value:function(e){return this.operationQueue?this.operationQueue.current(e):null}},{key:"executeNext",value:function(e){e&&this.operationQueue&&this.operationQueue.executeNext(e)}},{key:"shiftAndExecuteNext",value:function(e){this.operationQueue&&this.operationQueue.shiftAndExecuteNext(e)}},{key:"pendingTrackCount",get:function(){return Object.keys(this.tracks).reduce((e,t)=>e+(this.isPending(this.tracks[t])?1:0),0)}},{key:"sourceBufferCount",get:function(){return this.sourceBuffers.reduce((e,[t])=>e+(t?1:0),0)}},{key:"sourceBufferTypes",get:function(){return this.sourceBuffers.map(([e])=>e).filter(e=>!!e)}},{key:"addBufferListener",value:function(e,t,i){var n=this.tracks[e];if(n){var a=n.buffer;if(a){var r=i.bind(this,e);n.listeners.push({event:t,listener:r}),a.addEventListener(t,r)}}}},{key:"removeBufferListeners",value:function(e){var t=this.tracks[e];if(t){var i=t.buffer;i&&(t.listeners.forEach(e=>{i.removeEventListener(e.event,e.listener)}),t.listeners.length=0)}}}])}();function uC(e){var t=e.querySelectorAll("source");[].slice.call(t).forEach(t=>{e.removeChild(t)})}function lC(e){return"audio"===e?1:0}var dC=function(){function e(t){u(this,e),this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=t,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}return m(e,[{key:"setStreamController",value:function(e){this.streamController=e}},{key:"destroy",value:function(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}},{key:"registerListeners",value:function(){var e=this.hls;e.on(zE.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(zE.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(zE.MANIFEST_PARSED,this.onManifestParsed,this),e.on(zE.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(zE.BUFFER_CODECS,this.onBufferCodecs,this),e.on(zE.MEDIA_DETACHING,this.onMediaDetaching,this)}},{key:"unregisterListener",value:function(){var e=this.hls;e.off(zE.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(zE.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(zE.MANIFEST_PARSED,this.onManifestParsed,this),e.off(zE.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(zE.BUFFER_CODECS,this.onBufferCodecs,this),e.off(zE.MEDIA_DETACHING,this.onMediaDetaching,this)}},{key:"onFpsDropLevelCapping",value:function(e,t){var i=this.hls.levels[t.droppedLevel];this.isLevelAllowed(i)&&this.restrictedLevels.push({bitrate:i.bitrate,height:i.height,width:i.width})}},{key:"onMediaAttaching",value:function(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()}},{key:"onManifestParsed",value:function(e,t){var i=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,i.config.capLevelToPlayerSize&&t.video&&this.startCapping()}},{key:"onLevelsUpdated",value:function(e,t){this.timer&&WE(this.autoLevelCapping)&&this.detectPlayerSize()}},{key:"onBufferCodecs",value:function(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()}},{key:"onMediaDetaching",value:function(){this.stopCapping(),this.media=null}},{key:"detectPlayerSize",value:function(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0)return void(this.clientRect=null);var e=this.hls.levels;if(e.length){var t=this.hls,i=this.getMaxLevel(e.length-1);i!==this.autoLevelCapping&&t.logger.log(`Setting autoLevelCapping to ${i}: ${e[i].height}p@${e[i].bitrate} for media ${this.mediaWidth}x${this.mediaHeight}`),t.autoLevelCapping=i,t.autoLevelEnabled&&t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}}},{key:"getMaxLevel",value:function(t){var i=this.hls.levels;if(!i.length)return-1;var n=i.filter((e,i)=>this.isLevelAllowed(e)&&i<=t);return this.clientRect=null,e.getMaxLevelByMediaSize(n,this.mediaWidth,this.mediaHeight)}},{key:"startCapping",value:function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())}},{key:"stopCapping",value:function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)}},{key:"getDimensions",value:function(){if(this.clientRect)return this.clientRect;var e=this.media,t={width:0,height:0};if(e){var i=e.getBoundingClientRect();t.width=i.width,t.height=i.height,t.width||t.height||(t.width=i.right-i.left||e.width||0,t.height=i.bottom-i.top||e.height||0)}return this.clientRect=t,t}},{key:"mediaWidth",get:function(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function(){var e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch(e){}return Math.min(e,this.hls.config.maxDevicePixelRatio)}},{key:"isLevelAllowed",value:function(e){return!this.restrictedLevels.some(t=>e.bitrate===t.bitrate&&e.width===t.width&&e.height===t.height)}}],[{key:"getMaxLevelByMediaSize",value:function(e,t,i){if(null==e||!e.length)return-1;for(var n=(e,t)=>!t||(e.width!==t.width||e.height!==t.height),a=e.length-1,r=Math.max(t,i),o=0;o<e.length;o+=1){var s=e[o];if((s.width>=r||s.height>=r)&&n(s,e[o+1])){a=o;break}}return a}}])}(),hC={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"},cC={HLS:"h"},mC=m(function e(t,i){u(this,e),Array.isArray(t)&&(t=t.map(t=>t instanceof e?t:new e(t))),this.value=t,this.params=i});function fC(e,t,i,n){return new Error(`failed to ${e} "${a=t,Array.isArray(a)?JSON.stringify(a):a instanceof Map?"Map{}":a instanceof Set?"Set{}":"object"==typeof a?JSON.stringify(a):String(a)}" as ${i}`,{cause:n});var a}function vC(e,t,i){return fC("serialize",e,t,i)}var pC=m(function e(t){u(this,e),this.description=t}),gC="Bare Item";function yC(e){if(!1===ArrayBuffer.isView(e))throw vC(e,"Byte Sequence");return`:${t=e,btoa(String.fromCharCode(...t))}:`;var t}function bC(e){if(function(e){return e<-999999999999999||999999999999999<e}(e))throw vC(e,"Integer");return e.toString()}function wC(e,t){if(e<0)return-wC(-e,t);var i=Math.pow(10,t);if(Math.abs(e*i%1-.5)<Number.EPSILON){var n=Math.floor(e*i);return(n%2==0?n:n+1)/i}return Math.round(e*i)/i}function kC(e){var t=wC(e,3);if(Math.floor(Math.abs(t)).toString().length>12)throw vC(e,"Decimal");var i=t.toString();return i.includes(".")?i:`${i}.0`}var SC=/[\x00-\x1f\x7f]+/;function EC(e){var t,i=(t=e).description||t.toString().slice(7,-1);if(!1===/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(i))throw vC(i,"Token");return i}function TC(e){switch(typeof e){case"number":if(!WE(e))throw vC(e,gC);return Number.isInteger(e)?bC(e):kC(e);case"string":return function(e){if(SC.test(e))throw vC(e,"String");return`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}(e);case"symbol":return EC(e);case"boolean":return function(e){if("boolean"!=typeof e)throw vC(e,"Boolean");return e?"?1":"?0"}(e);case"object":if(e instanceof Date)return function(e){return`@${bC(e.getTime()/1e3)}`}(e);if(e instanceof Uint8Array)return yC(e);if(e instanceof pC)return EC(e);default:throw vC(e,gC)}}function PC(e){if(!1===/^[a-z*][a-z0-9\-_.*]*$/.test(e))throw vC(e,"Key");return e}function MC(e){return null==e?"":Object.entries(e).map(([e,t])=>!0===t?`;${PC(e)}`:`;${PC(e)}=${TC(t)}`).join("")}function AC(e){return e instanceof mC?`${TC(e.value)}${MC(e.params)}`:TC(e)}function DC(e,t={whitespace:!0}){if("object"!=typeof e||null==e)throw vC(e,"Dict");var i=e instanceof Map?e.entries():Object.entries(e),n=(null==t?void 0:t.whitespace)?" ":"";return Array.from(i).map(([e,t])=>{t instanceof mC==!1&&(t=new mC(t));var i,n=PC(e);return!0===t.value?n+=MC(t.params):(n+="=",Array.isArray(t.value)?n+=`(${(i=t).value.map(AC).join(" ")})${MC(i.params)}`:n+=AC(t)),n}).join(`,${n}`)}function xC(e,t){return DC(e,t)}var CC="CMCD-Object",IC="CMCD-Request",LC="CMCD-Session",_C="CMCD-Status",RC={br:CC,ab:CC,d:CC,ot:CC,tb:CC,tpb:CC,lb:CC,tab:CC,lab:CC,url:CC,pb:IC,bl:IC,tbl:IC,dl:IC,ltc:IC,mtp:IC,nor:IC,nrr:IC,rc:IC,sn:IC,sta:IC,su:IC,ttfb:IC,ttfbb:IC,ttlb:IC,cmsdd:IC,cmsds:IC,smrt:IC,df:IC,cs:IC,ts:IC,cid:LC,pr:LC,sf:LC,sid:LC,st:LC,v:LC,msd:LC,bs:_C,bsd:_C,cdn:_C,rtp:_C,bg:_C,pt:_C,ec:_C,e:_C},FC=IC;function OC(e,t){var i={};if(!e)return i;var n,a=Object.keys(e),r=t?(n=t,Object.keys(n).reduce((e,t)=>{var i;return null===(i=n[t])||void 0===i||i.forEach(i=>e[i]=t),e},{})):{};return a.reduce((t,i)=>{var n,a=RC[i]||r[i]||FC;return(null!==(n=t[a])&&void 0!==n?n:t[a]={})[i]=e[i],t},i)}var WC="event";var $C=e=>Math.round(e),NC=(e,t)=>Array.isArray(e)?e.map(e=>NC(e,t)):e instanceof mC&&"string"==typeof e.value?new mC(NC(e.value,t),e.params):(t.baseUrl&&(e=function(e,t){var i=new URL(e),n=new URL(t);if(i.origin!==n.origin)return e;for(var a=i.pathname.split("/").slice(1),r=n.pathname.split("/").slice(1,-1);a[0]===r[0];)a.shift(),r.shift();for(;r.length;)r.shift(),a.unshift("..");return a.join("/")+i.search+i.hash}(e,t.baseUrl)),1===t.version?encodeURIComponent(e):e),jC=e=>100*$C(e/100),BC={br:$C,d:$C,bl:jC,dl:jC,mtp:jC,nor:(e,t)=>{var i=e;return t.version>=2&&(e instanceof mC&&"string"==typeof e.value?i=new mC([e]):"string"==typeof e&&(i=[e])),NC(i,t)},rtp:jC,tb:$C},zC="request",UC="response",HC=["ab","bg","bl","br","bs","bsd","cdn","cid","cs","df","ec","lab","lb","ltc","msd","mtp","pb","pr","pt","sf","sid","sn","st","sta","tab","tb","tbl","tpb","ts","v"],GC=["e"],VC=/^[a-zA-Z0-9-.]+-[a-zA-Z0-9-.]+$/;function KC(e){return VC.test(e)}var XC=["d","dl","nor","ot","rtp","su"];var YC=["cmsdd","cmsds","rc","smrt","ttfb","ttfbb","ttlb","url"];var qC=["bl","br","bs","cid","d","dl","mtp","nor","nrr","ot","pr","rtp","sf","sid","st","su","tb","v"];function JC(e){return qC.includes(e)||KC(e)}var QC={[UC]:function(e){return HC.includes(e)||XC.includes(e)||YC.includes(e)||KC(e)},[WC]:function(e){return HC.includes(e)||GC.includes(e)||KC(e)},[zC]:function(e){return HC.includes(e)||XC.includes(e)||KC(e)}};function ZC(e,t={}){var i={};if(null==e||"object"!=typeof e)return i;var n=t.version||e.v||1,a=t.reportingMode||zC,r=1===n?JC:QC[a],o=Object.keys(e).filter(r),s=t.filter;"function"==typeof s&&(o=o.filter(s));var u=a===UC||a===WC;u&&!o.includes("ts")&&o.push("ts"),n>1&&!o.includes("v")&&o.push("v");var l=ZE({},BC,t.formatters),d={version:n,reportingMode:a,baseUrl:t.baseUrl};return o.sort().forEach(t=>{var a=e[t],r=l[t];if("function"==typeof r&&(a=r(a,d)),"v"===t){if(1===n)return;a=n}"pr"==t&&1===a||(u&&"ts"===t&&!WE(a)&&(a=Date.now()),function(e){return"number"==typeof e?WE(e):null!=e&&""!==e&&!1!==e}(a)&&(function(e){return["ot","sf","st","e","sta"].includes(e)}(t)&&"string"==typeof a&&(a=new pC(a)),i[t]=a))}),i}function eI(e,t,i){return ZE(e,function(e,t={}){var i={};if(!e)return i;var n=OC(ZC(e,t),null==t?void 0:t.customHeaderMap);return Object.entries(n).reduce((e,[t,i])=>{var n=xC(i,{whitespace:!1});return n&&(e[t]=n),e},i)}(t,i))}function tI(e,t={}){if(!e)return"";var i=function(e,t={}){return e?xC(ZC(e,t),{whitespace:!1}):""}(e,t);return encodeURIComponent(i)}var iI=/CMCD=[^&#]+/;function nI(e,t,i){var n=function(e,t={}){return e?`CMCD=${tI(e,t)}`:""}(t,i);if(!n)return e;if(iI.test(e))return e.replace(iI,n);var a=e.includes("?")?"&":"?";return`${e}${a}${n}`}var aI=function(){return m(function e(t){u(this,e),this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.includeKeys=void 0,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=e=>{try{this.apply(e,{ot:hC.MANIFEST,su:!this.initialized})}catch(e){this.hls.logger.warn("Could not generate manifest CMCD data.",e)}},this.applyFragmentData=e=>{try{var t=e.frag,i=e.part,n=this.hls.levels[t.level],a=this.getObjectType(t),r={d:1e3*(i||t).duration,ot:a};a!==hC.VIDEO&&a!==hC.AUDIO&&a!=hC.MUXED||(r.br=n.bitrate/1e3,r.tb=this.getTopBandwidth(a)/1e3,r.bl=this.getBufferLength(a));var o=i?this.getNextPart(i):this.getNextFrag(t);null!=o&&o.url&&o.url!==t.url&&(r.nor=o.url),this.apply(e,r)}catch(e){this.hls.logger.warn("Could not generate segment CMCD data.",e)}},this.hls=t;var i=this.config=t.config,n=i.cmcd;null!=n&&(i.pLoader=this.createPlaylistLoader(),i.fLoader=this.createFragmentLoader(),this.sid=n.sessionId||t.sessionId,this.cid=n.contentId,this.useHeaders=!0===n.useHeaders,this.includeKeys=n.includeKeys,this.registerListeners())},[{key:"registerListeners",value:function(){var e=this.hls;e.on(zE.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(zE.MEDIA_DETACHED,this.onMediaDetached,this),e.on(zE.BUFFER_CREATED,this.onBufferCreated,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(zE.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(zE.MEDIA_DETACHED,this.onMediaDetached,this),e.off(zE.BUFFER_CREATED,this.onBufferCreated,this)}},{key:"destroy",value:function(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null,this.onWaiting=this.onPlaying=this.media=null}},{key:"onMediaAttached",value:function(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}},{key:"onMediaDetached",value:function(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}},{key:"onBufferCreated",value:function(e,t){var i,n;this.audioBuffer=null==(i=t.tracks.audio)?void 0:i.buffer,this.videoBuffer=null==(n=t.tracks.video)?void 0:n.buffer}},{key:"createData",value:function(){var e;return{v:1,sf:cC.HLS,sid:this.sid,cid:this.cid,pr:null==(e=this.media)?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}},{key:"apply",value:function(e,t={}){ZE(t,this.createData());var i=t.ot===hC.INIT||t.ot===hC.VIDEO||t.ot===hC.MUXED;this.starved&&i&&(t.bs=!0,t.su=!0,this.starved=!1),null==t.su&&(t.su=this.buffering);var n=this.includeKeys;n&&(t=Object.keys(t).reduce((e,i)=>(n.includes(i)&&(e[i]=t[i]),e),{}));var a={baseUrl:e.url};this.useHeaders?(e.headers||(e.headers={}),eI(e.headers,t,a)):e.url=nI(e.url,t,a)}},{key:"getNextFrag",value:function(e){var t,i=null==(t=this.hls.levels[e.level])?void 0:t.details;if(i){var n=e.sn-i.startSN;return i.fragments[n+1]}}},{key:"getNextPart",value:function(e){var t,i=e.index,n=e.fragment,a=null==(t=this.hls.levels[n.level])||null==(t=t.details)?void 0:t.partList;if(a)for(var r=n.sn,o=a.length-1;o>=0;o--){var s=a[o];if(s.index===i&&s.fragment.sn===r)return a[o+1]}}},{key:"getObjectType",value:function(e){var t=e.type;return"subtitle"===t?hC.TIMED_TEXT:"initSegment"===e.sn?hC.INIT:"audio"===t?hC.AUDIO:"main"===t?this.hls.audioTracks.length?hC.VIDEO:hC.MUXED:void 0}},{key:"getTopBandwidth",value:function(e){var t,i=0,n=this.hls;if(e===hC.AUDIO)t=n.audioTracks;else{var a=n.maxAutoLevel,r=a>-1?a+1:n.levels.length;t=n.levels.slice(0,r)}return t.forEach(e=>{e.bitrate>i&&(i=e.bitrate)}),i>0?i:NaN}},{key:"getBufferLength",value:function(e){var t=this.media,i=e===hC.AUDIO?this.audioBuffer:this.videoBuffer;return i&&t?1e3*WM.bufferInfo(i,t.currentTime,this.config.maxBufferHole).len:NaN}},{key:"createPlaylistLoader",value:function(){var e=this.config.pLoader,t=this.applyPlaylistData,i=e||this.config.loader;return function(){return m(function e(t){u(this,e),this.loader=void 0,this.loader=new i(t)},[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}},{key:"destroy",value:function(){this.loader.destroy()}},{key:"abort",value:function(){this.loader.abort()}},{key:"load",value:function(e,i,n){t(e),this.loader.load(e,i,n)}}])}()}},{key:"createFragmentLoader",value:function(){var e=this.config.fLoader,t=this.applyFragmentData,i=e||this.config.loader;return function(){return m(function e(t){u(this,e),this.loader=void 0,this.loader=new i(t)},[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}},{key:"destroy",value:function(){this.loader.destroy()}},{key:"abort",value:function(){this.loader.abort()}},{key:"load",value:function(e,i,n){t(e),this.loader.load(e,i,n)}}])}()}}])}(),rI=function(){function e(t){var i;return u(this,e),(i=s(this,e,["content-steering",t.logger])).hls=void 0,i.loader=null,i.uri=null,i.pathwayId=".",i._pathwayPriority=null,i.timeToLoad=300,i.reloadTimer=-1,i.updated=0,i.started=!1,i.enabled=!0,i.levels=null,i.audioTracks=null,i.subtitleTracks=null,i.penalizedPathways={},i.hls=t,i.registerListeners(),i}return y(e,iT),m(e,[{key:"registerListeners",value:function(){var e=this.hls;e.on(zE.MANIFEST_LOADING,this.onManifestLoading,this),e.on(zE.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(zE.MANIFEST_PARSED,this.onManifestParsed,this),e.on(zE.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(zE.MANIFEST_LOADING,this.onManifestLoading,this),e.off(zE.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(zE.MANIFEST_PARSED,this.onManifestParsed,this),e.off(zE.ERROR,this.onError,this))}},{key:"pathways",value:function(){return(this.levels||[]).reduce((e,t)=>(-1===e.indexOf(t.pathwayId)&&e.push(t.pathwayId),e),[])}},{key:"pathwayPriority",get:function(){return this._pathwayPriority},set:function(e){this.updatePathwayPriority(e)}},{key:"startLoad",value:function(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){var e=1e3*this.timeToLoad-(performance.now()-this.updated);if(e>0)return void this.scheduleRefresh(this.uri,e)}this.loadSteeringManifest(this.uri)}}},{key:"stopLoad",value:function(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()}},{key:"clearTimeout",value:function(){-1!==this.reloadTimer&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)}},{key:"destroy",value:function(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}},{key:"removeLevel",value:function(e){var t=this.levels;t&&(this.levels=t.filter(t=>t!==e))}},{key:"onManifestLoading",value:function(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}},{key:"onManifestLoaded",value:function(e,t){var i=t.contentSteering;null!==i&&(this.pathwayId=i.pathwayId,this.uri=i.uri,this.started&&this.startLoad())}},{key:"onManifestParsed",value:function(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}},{key:"onError",value:function(e,t){var i=t.errorAction;if((null==i?void 0:i.action)===oM&&i.flags===dM){var n=this.levels,a=this._pathwayPriority,r=this.pathwayId;if(t.context){var o=t.context,s=o.groupId,u=o.pathwayId,l=o.type;s&&n?r=this.getPathwayForGroupId(s,l,r):u&&(r=u)}r in this.penalizedPathways||(this.penalizedPathways[r]=performance.now()),!a&&n&&(a=this.pathways()),a&&a.length>1&&(this.updatePathwayPriority(a),i.resolved=this.pathwayId!==r),t.details!==BE.BUFFER_APPEND_ERROR||t.fatal?i.resolved||this.warn(`Could not resolve ${t.details} ("${t.error.message}") with content-steering for Pathway: ${r} levels: ${n?n.length:n} priorities: ${OP(a)} penalized: ${OP(this.penalizedPathways)}`):i.resolved=!0}}},{key:"filterParsedLevels",value:function(e){this.levels=e;var t=this.getLevelsForPathway(this.pathwayId);if(0===t.length){var i=e[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${i}"`),t=this.getLevelsForPathway(i),this.pathwayId=i}return t.length!==e.length&&this.log(`Found ${t.length}/${e.length} levels in Pathway "${this.pathwayId}"`),t}},{key:"getLevelsForPathway",value:function(e){return null===this.levels?[]:this.levels.filter(t=>e===t.pathwayId)}},{key:"updatePathwayPriority",value:function(e){var t;this._pathwayPriority=e;var i=this.penalizedPathways,n=performance.now();Object.keys(i).forEach(e=>{n-i[e]>3e5&&delete i[e]});for(var a=0;a<e.length;a++){var r=e[a];if(!(r in i)){if(r===this.pathwayId)return;var o=this.hls.nextLoadLevel,s=this.hls.levels[o];if((t=this.getLevelsForPathway(r)).length>0){this.log(`Setting Pathway to "${r}"`),this.pathwayId=r,VA(t),this.hls.trigger(zE.LEVELS_UPDATED,{levels:t});var u=this.hls.levels[o];s&&u&&this.levels&&(u.attrs["STABLE-VARIANT-ID"]!==s.attrs["STABLE-VARIANT-ID"]&&u.bitrate!==s.bitrate&&this.log(`Unstable Pathways change from bitrate ${s.bitrate} to ${u.bitrate}`),this.hls.nextLoadLevel=o);break}}}}},{key:"getPathwayForGroupId",value:function(e,t,i){for(var n=this.getLevelsForPathway(i).concat(this.levels||[]),a=0;a<n.length;a++)if(t===GE&&n[a].hasAudioGroup(e)||t===VE&&n[a].hasSubtitleGroup(e))return n[a].pathwayId;return i}},{key:"clonePathways",value:function(e){var t=this.levels;if(t){var i={},n={};e.forEach(e=>{var a=e.ID,r=e["BASE-ID"],o=e["URI-REPLACEMENT"];if(!t.some(e=>e.pathwayId===a)){var s=this.getLevelsForPathway(r).map(e=>{var t=new GM(e.attrs);t["PATHWAY-ID"]=a;var r=t.AUDIO&&`${t.AUDIO}_clone_${a}`,s=t.SUBTITLES&&`${t.SUBTITLES}_clone_${a}`;r&&(i[t.AUDIO]=r,t.AUDIO=r),s&&(n[t.SUBTITLES]=s,t.SUBTITLES=s);var u=sI(e.uri,t["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",o),l=new _P({attrs:t,audioCodec:e.audioCodec,bitrate:e.bitrate,height:e.height,name:e.name,url:u,videoCodec:e.videoCodec,width:e.width});if(e.audioGroups)for(var d=1;d<e.audioGroups.length;d++)l.addGroupId("audio",`${e.audioGroups[d]}_clone_${a}`);if(e.subtitleGroups)for(var h=1;h<e.subtitleGroups.length;h++)l.addGroupId("text",`${e.subtitleGroups[h]}_clone_${a}`);return l});t.push(...s),oI(this.audioTracks,i,o,a),oI(this.subtitleTracks,n,o,a)}})}}},{key:"loadSteeringManifest",value:function(e){var t,i=this.hls.config,n=i.loader;this.loader&&this.loader.destroy(),this.loader=new n(i);try{t=new self.URL(e)}catch(t){return this.enabled=!1,void this.log(`Failed to parse Steering Manifest URI: ${e}`)}if("data:"!==t.protocol){var a=0|(this.hls.bandwidthEstimate||i.abrEwmaDefaultEstimate);t.searchParams.set("_HLS_pathway",this.pathwayId),t.searchParams.set("_HLS_throughput",""+a)}var r={responseType:"json",url:t.href},o=i.steeringManifestLoadPolicy.default,s=o.errorRetry||o.timeoutRetry||{},u={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:s.maxNumRetry||0,retryDelay:s.retryDelayMs||0,maxRetryDelay:s.maxRetryDelayMs||0},l={onSuccess:(e,i,n,a)=>{this.log(`Loaded steering manifest: "${t}"`);var r=e.data;if(1===(null==r?void 0:r.VERSION)){this.updated=performance.now(),this.timeToLoad=r.TTL;var o=r["RELOAD-URI"],s=r["PATHWAY-CLONES"],u=r["PATHWAY-PRIORITY"];if(o)try{this.uri=new self.URL(o,t).href}catch(e){return this.enabled=!1,void this.log(`Failed to parse Steering Manifest RELOAD-URI: ${o}`)}this.scheduleRefresh(this.uri||n.url),s&&this.clonePathways(s);var l={steeringManifest:r,url:t.toString()};this.hls.trigger(zE.STEERING_MANIFEST_LOADED,l),u&&this.updatePathwayPriority(u)}else this.log(`Steering VERSION ${r.VERSION} not supported!`)},onError:(e,t,i,n)=>{if(this.log(`Error loading steering manifest: ${e.code} ${e.text} (${t.url})`),this.stopLoad(),410===e.code)return this.enabled=!1,void this.log(`Steering manifest ${t.url} no longer available`);var a=1e3*this.timeToLoad;if(429!==e.code)this.scheduleRefresh(this.uri||t.url,a);else{var r=this.loader;if("function"==typeof(null==r?void 0:r.getResponseHeader)){var o=r.getResponseHeader("Retry-After");o&&(a=1e3*parseFloat(o))}this.log(`Steering manifest ${t.url} rate limited`)}},onTimeout:(e,t,i)=>{this.log(`Timeout loading steering manifest (${t.url})`),this.scheduleRefresh(this.uri||t.url)}};this.log(`Requesting steering manifest: ${t}`),this.loader.load(r,u,l)}},{key:"scheduleRefresh",value:function(e,t=1e3*this.timeToLoad){this.clearTimeout(),this.reloadTimer=self.setTimeout(()=>{var t,i=null==(t=this.hls)?void 0:t.media;!i||i.ended?this.scheduleRefresh(e,1e3*this.timeToLoad):this.loadSteeringManifest(e)},t)}}])}();function oI(e,t,i,n){e&&Object.keys(t).forEach(a=>{var r=e.filter(e=>e.groupId===a).map(e=>{var r=ZE({},e);return r.details=void 0,r.attrs=new GM(r.attrs),r.url=r.attrs.URI=sI(e.url,e.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",i),r.groupId=r.attrs["GROUP-ID"]=t[a],r.attrs["PATHWAY-ID"]=n,r});e.push(...r)})}function sI(e,t,i,n){var a,r=n.HOST,o=n.PARAMS,s=n[i];t&&(a=null==s?void 0:s[t])&&(e=a);var u=new self.URL(e);return r&&!a&&(u.host=r),o&&Object.keys(o).sort().forEach(e=>{e&&u.searchParams.set(e,o[e])}),u.href}var uI=function(){function e(t){var i;return u(this,e),(i=s(this,e,["eme",t.logger])).hls=void 0,i.config=void 0,i.media=null,i.mediaResolved=void 0,i.keyFormatPromise=null,i.keySystemAccessPromises={},i._requestLicenseFailureCount=0,i.mediaKeySessions=[],i.keyIdToKeySessionPromise={},i.mediaKeys=null,i.setMediaKeysQueue=e.CDMCleanupPromise?[e.CDMCleanupPromise]:[],i.bannedKeyIds={},i.onMediaEncrypted=e=>{var t=e.initDataType,n=e.initData,a=`"${e.type}" event: init data type: "${t}"`;if(i.debug(a),null!==n){if(!i.keyFormatPromise){var r=Object.keys(i.keySystemAccessPromises);r.length||(r=cA(i.config));var o=r.map(hA).filter(e=>!!e);i.keyFormatPromise=i.getKeyFormatPromise(o)}i.keyFormatPromise.then(r=>{var o=dA(r);if("sinf"===t&&o===rA.FAIRPLAY){var s;try{var u=FT(new Uint8Array(n)),l=YT(eA(JSON.parse(u).sinf));if(!l)throw new Error("'schm' box missing or not cbcs/cenc with schi > tenc");s=new Uint8Array(l.subarray(8,24))}catch(e){return void i.warn(`${a} Failed to parse sinf: ${e}`)}for(var d,h=cT(s),c=i,m=c.keyIdToKeySessionPromise,f=c.mediaKeySessions,v=m[h],p=function(){var e=f[g],a=e.decryptdata;if(!a.keyId)return 0;var r=cT(a.keyId);return qM(s,a.keyId)||-1!==a.uri.replace(/-/g,"").indexOf(h)?(v=m[r])?(a.pssh||(delete m[r],a.pssh=new Uint8Array(n),a.keyId=s,(v=m[h]=v.then(()=>i.generateRequestWithPreferredKeySession(e,t,n,"encrypted-event-key-match"))).catch(e=>i.handleError(e))),1):0:void 0},g=0;g<f.length&&(0===(d=p())||1!==d);g++);v||i.handleError(new Error(`Key ID ${h} not encountered in playlist. Key-system sessions ${f.length}.`))}else i.log(`Ignoring "${e.type}" event with init data type: "${t}" for selected key-system ${o}`)}).catch(e=>i.handleError(e))}},i.onWaitingForKey=e=>{i.log(`"${e.type}" event`)},i.hls=t,i.config=t.config,i.registerListeners(),i}return y(e,iT),m(e,[{key:"destroy",value:function(){this.onDestroying(),this.onMediaDetached();var e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.config=this.keyIdToKeySessionPromise=null,this.onMediaEncrypted=this.onWaitingForKey=null}},{key:"registerListeners",value:function(){this.hls.on(zE.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(zE.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(zE.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(zE.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.on(zE.DESTROYING,this.onDestroying,this)}},{key:"unregisterListeners",value:function(){this.hls.off(zE.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(zE.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(zE.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(zE.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.off(zE.DESTROYING,this.onDestroying,this)}},{key:"getLicenseServerUrl",value:function(e){var t=this.config,i=t.drmSystems,n=t.widevineLicenseUrl,a=null==i?void 0:i[e];return a?a.licenseUrl:e===rA.WIDEVINE&&n?n:void 0}},{key:"getLicenseServerUrlOrThrow",value:function(e){var t=this.getLicenseServerUrl(e);if(void 0===t)throw new Error(`no license server URL configured for key-system "${e}"`);return t}},{key:"getServerCertificateUrl",value:function(e){var t=this.config.drmSystems,i=null==t?void 0:t[e];if(i)return i.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`)}},{key:"attemptKeySystemAccess",value:function(e){var t=this.hls.levels,i=(e,t,i)=>!!e&&i.indexOf(e)===t,n=t.map(e=>e.audioCodec).filter(i),a=t.map(e=>e.videoCodec).filter(i);return n.length+a.length===0&&a.push("avc1.42e01e"),new Promise((t,i)=>{var r=e=>{var o=e.shift();this.getMediaKeysPromise(o,n,a).then(e=>t({keySystem:o,mediaKeys:e})).catch(t=>{e.length?r(e):i(t instanceof hI?t:new hI({type:jE.KEY_SYSTEM_ERROR,details:BE.KEY_SYSTEM_NO_ACCESS,error:t,fatal:!0},t.message))})};r(e)})}},{key:"requestMediaKeySystemAccess",value:function(e,t){var i=this.config.requestMediaKeySystemAccessFunc;if("function"!=typeof i){var n=`Configured requestMediaKeySystemAccess is not a function ${i}`;return null===fA&&"http:"===self.location.protocol&&(n=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(n))}return i(e,t)}},{key:"getMediaKeysPromise",value:function(e,t,i){var n,a=function(e,t,i,n){var a;switch(e){case rA.FAIRPLAY:a=["cenc","sinf"];break;case rA.WIDEVINE:case rA.PLAYREADY:a=["cenc"];break;case rA.CLEARKEY:a=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${e}`)}return function(e,t,i,n){return[{initDataTypes:e,persistentState:n.persistentState||"optional",distinctiveIdentifier:n.distinctiveIdentifier||"optional",sessionTypes:n.sessionTypes||[n.sessionType||"temporary"],audioCapabilities:t.map(e=>({contentType:`audio/mp4; codecs=${e}`,robustness:n.audioRobustness||"",encryptionScheme:n.audioEncryptionScheme||null})),videoCapabilities:i.map(e=>({contentType:`video/mp4; codecs=${e}`,robustness:n.videoRobustness||"",encryptionScheme:n.videoEncryptionScheme||null}))}]}(a,t,i,n)}(e,t,i,this.config.drmSystemOptions||{}),r=this.keySystemAccessPromises[e],o=null==(n=r)?void 0:n.keySystemAccess;if(!o){this.log(`Requesting encrypted media "${e}" key-system access with config: ${OP(a)}`),o=this.requestMediaKeySystemAccess(e,a);var s=r=this.keySystemAccessPromises[e]={keySystemAccess:o};return o.catch(t=>{this.log(`Failed to obtain access to key-system "${e}": ${t}`)}),o.then(t=>{this.log(`Access for key-system "${t.keySystem}" obtained`);var i=this.fetchServerCertificate(e);this.log(`Create media-keys for "${e}"`);var n=s.mediaKeys=t.createMediaKeys().then(t=>(this.log(`Media-keys created for "${e}"`),s.hasMediaKeys=!0,i.then(i=>i?this.setMediaKeysServerCertificate(t,e,i):t)));return n.catch(t=>{this.error(`Failed to create media-keys for "${e}"}: ${t}`)}),n})}return o.then(()=>r.mediaKeys)}},{key:"createMediaKeySessionContext",value:function({decryptdata:e,keySystem:t,mediaKeys:i}){this.log(`Creating key-system session "${t}" keyId: ${cT(e.keyId||[])} keyUri: ${e.uri}`);var n=i.createSession(),a={decryptdata:e,keySystem:t,mediaKeys:i,mediaKeysSession:n,keyStatus:"status-pending"};return this.mediaKeySessions.push(a),a}},{key:"renewKeySession",value:function(e){var t=e.decryptdata;if(t.pssh){var i=this.createMediaKeySessionContext(e),n=lI(t);this.keyIdToKeySessionPromise[n]=this.generateRequestWithPreferredKeySession(i,"cenc",t.pssh.buffer,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)}},{key:"updateKeySession",value:function(e,t){var i=e.mediaKeysSession;return this.log(`Updating key-session "${i.sessionId}" for keyId ${cT(e.decryptdata.keyId||[])}\n } (data length: ${t.byteLength})`),i.update(t)}},{key:"getSelectedKeySystemFormats",value:function(){return Object.keys(this.keySystemAccessPromises).map(e=>({keySystem:e,hasMediaKeys:this.keySystemAccessPromises[e].hasMediaKeys})).filter(({hasMediaKeys:e})=>!!e).map(({keySystem:e})=>hA(e)).filter(e=>!!e)}},{key:"getKeySystemAccess",value:function(e){return this.getKeySystemSelectionPromise(e).then(({keySystem:e,mediaKeys:t})=>this.attemptSetMediaKeys(e,t))}},{key:"selectKeySystem",value:function(e){return new Promise((t,i)=>{this.getKeySystemSelectionPromise(e).then(({keySystem:e})=>{var n=hA(e);n?t(n):i(new Error(`Unable to find format for key-system "${e}"`))}).catch(i)})}},{key:"selectKeySystemFormat",value:function(e){var t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${e.sn} ${e.type}: ${e.level}) key formats ${t.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise}},{key:"getKeyFormatPromise",value:function(e){var t=cA(this.config),i=e.map(dA).filter(e=>!!e&&-1!==t.indexOf(e));return this.selectKeySystem(i)}},{key:"getKeyStatus",value:function(e){for(var t=this.mediaKeySessions,i=0;i<t.length;i++){var n=dI(e,t[i]);if(n)return n}}},{key:"loadKey",value:function(e){var t=e.keyInfo.decryptdata,i=lI(t),n=this.bannedKeyIds[i];if(n||"internal-error"===this.getKeyStatus(t)){var a=cI(n||"internal-error",t);return this.handleError(a,e.frag),Promise.reject(a)}var r=`(keyId: ${i} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${r}`);var o=this.keyIdToKeySessionPromise[i];if(!o){var s=this.getKeySystemForKeyPromise(t).then(({keySystem:i,mediaKeys:n})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${r}`),this.attemptSetMediaKeys(i,n).then(()=>(this.throwIfDestroyed(),this.createMediaKeySessionContext({keySystem:i,mediaKeys:n,decryptdata:t}))))).then(e=>{var i=t.pssh?t.pssh.buffer:null;return this.generateRequestWithPreferredKeySession(e,"cenc",i,"playlist-key")});return s.catch(t=>this.handleError(t,e.frag)),this.keyIdToKeySessionPromise[i]=s,s}return o.catch(i=>{if(i instanceof hI){var n=tT({},i.data);"internal-error"===this.getKeyStatus(t)&&(n.decryptdata=t);var a=new hI(n,i.message);this.handleError(a,e.frag)}}),o}},{key:"throwIfDestroyed",value:function(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}},{key:"handleError",value:function(e,t){if(this.hls)if(e instanceof hI){t&&(e.data.frag=t);var i=e.data.decryptdata;this.error(`${e.message}${i?` (${cT(i.keyId||[])})`:""}`),this.hls.trigger(zE.ERROR,e.data)}else this.error(e.message),this.hls.trigger(zE.ERROR,{type:jE.KEY_SYSTEM_ERROR,details:BE.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0})}},{key:"getKeySystemForKeyPromise",value:function(e){var t=lI(e),i=this.keyIdToKeySessionPromise[t];if(!i){var n=dA(e.keyFormat),a=n?[n]:cA(this.config);return this.attemptKeySystemAccess(a)}return i}},{key:"getKeySystemSelectionPromise",value:function(e){if(e.length||(e=cA(this.config)),0===e.length)throw new hI({type:jE.KEY_SYSTEM_ERROR,details:BE.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${OP({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}},{key:"attemptSetMediaKeys",value:function(e,t){if(this.mediaResolved=void 0,this.mediaKeys===t)return Promise.resolve();var i=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);var n=Promise.all(i).then(()=>this.media?this.media.setMediaKeys(t):new Promise((e,i)=>{this.mediaResolved=()=>{if(this.mediaResolved=void 0,!this.media)return i(new Error("Attempted to set mediaKeys without media element attached"));this.mediaKeys=t,this.media.setMediaKeys(t).then(e).catch(i)}}));return this.mediaKeys=t,this.setMediaKeysQueue.push(n),n.then(()=>{this.log(`Media-keys set for "${e}"`),i.push(n),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(e=>-1===i.indexOf(e))})}},{key:"generateRequestWithPreferredKeySession",value:function(e,t,i,n){var a,r=null==(a=this.config.drmSystems)||null==(a=a[e.keySystem])?void 0:a.generateRequest;if(r)try{var o=r.call(this.hls,t,i,e);if(!o)throw new Error("Invalid response from configured generateRequest filter");t=o.initDataType,i=o.initData?o.initData:null,e.decryptdata.pssh=i?new Uint8Array(i):null}catch(e){if(this.warn(e.message),this.hls&&this.hls.config.debug)throw e}if(null===i)return this.log(`Skipping key-session request for "${n}" (no initData)`),Promise.resolve(e);var s=lI(e.decryptdata),u=e.decryptdata.uri;this.log(`Generating key-session request for "${n}" keyId: ${s} URI: ${u} (init data type: ${t} length: ${i.byteLength})`);var l=new kD,d=e._onmessage=t=>{var i=e.mediaKeysSession;if(i){var n=t.messageType,a=t.message;this.log(`"${n}" message event for session "${i.sessionId}" message size: ${a.byteLength}`),"license-request"===n||"license-renewal"===n?this.renewLicense(e,a).catch(e=>{l.eventNames().length?l.emit("error",e):this.handleError(e)}):"license-release"===n?e.keySystem===rA.FAIRPLAY&&this.updateKeySession(e,tA("acknowledged")).then(()=>this.removeSession(e)).catch(e=>this.handleError(e)):this.warn(`unhandled media key message type "${n}"`)}else l.emit("error",new Error("invalid state"))},h=(e,t)=>{var i;t.keyStatus=e,e.startsWith("usable")?l.emit("resolved"):"internal-error"===e||"output-restricted"===e||"output-downscaled"===e?i=cI(e,t.decryptdata):"expired"===e?i=new Error(`key expired (keyId: ${s})`):"released"===e?i=new Error("key released"):"status-pending"===e||this.warn(`unhandled key status change "${e}" (keyId: ${s})`),i&&(l.eventNames().length?l.emit("error",i):this.handleError(i))},c=e._onkeystatuseschange=t=>{if(e.mediaKeysSession){var i=this.getKeyStatuses(e);if(Object.keys(i).some(e=>"status-pending"!==i[e])){if("expired"===i[s])return this.log(`Expired key ${OP(i)} in key-session "${e.mediaKeysSession.sessionId}"`),void this.renewKeySession(e);var n=i[s];if(n)h(n,e);else{var a;e.keyStatusTimeouts||(e.keyStatusTimeouts={}),(a=e.keyStatusTimeouts)[s]||(a[s]=self.setTimeout(()=>{if(e.mediaKeysSession&&this.mediaKeys){var t=this.getKeyStatus(e.decryptdata);if(t&&"status-pending"!==t)return this.log(`No status for keyId ${s} in key-session "${e.mediaKeysSession.sessionId}". Using session key-status ${t} from other session.`),h(t,e);this.log(`key status for ${s} in key-session "${e.mediaKeysSession.sessionId}" timed out after 1000ms`),h(n="internal-error",e)}},1e3)),this.log(`No status for keyId ${s} (${OP(i)}).`)}}}else l.emit("error",new Error("invalid state"))};eD(e.mediaKeysSession,"message",d),eD(e.mediaKeysSession,"keystatuseschange",c);var m=new Promise((e,t)=>{l.on("error",t),l.on("resolved",e)});return e.mediaKeysSession.generateRequest(t,i).then(()=>{this.log(`Request generated for key-session "${e.mediaKeysSession.sessionId}" keyId: ${s} URI: ${u}`)}).catch(t=>{throw new hI({type:jE.KEY_SYSTEM_ERROR,details:BE.KEY_SYSTEM_NO_SESSION,error:t,decryptdata:e.decryptdata,fatal:!1},`Error generating key-session request: ${t}`)}).then(()=>m).catch(t=>(l.removeAllListeners(),this.removeSession(e).then(()=>{throw t}))).then(()=>(l.removeAllListeners(),e))}},{key:"getKeyStatuses",value:function(e){var t={};return e.mediaKeysSession.keyStatuses.forEach((i,n)=>{if("string"==typeof n&&"object"==typeof i){var a=n;n=i,i=a}var r="buffer"in n?new Uint8Array(n.buffer,n.byteOffset,n.byteLength):new Uint8Array(n);if(e.keySystem===rA.PLAYREADY&&16===r.length){var o=cT(r);t[o]=i,iA(r)}var s=cT(r);"internal-error"===i&&(this.bannedKeyIds[s]=i),this.log(`key status change "${i}" for keyStatuses keyId: ${s} key-session "${e.mediaKeysSession.sessionId}"`),t[s]=i}),t}},{key:"fetchServerCertificate",value:function(e){var t=this.config,i=new(0,t.loader)(t),n=this.getServerCertificateUrl(e);return n?(this.log(`Fetching server certificate for "${e}"`),new Promise((a,r)=>{var o={responseType:"arraybuffer",url:n},s=t.certLoadPolicy.default,u={loadPolicy:s,timeout:s.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},l={onSuccess:(e,t,i,n)=>{a(e.data)},onError:(t,i,a,s)=>{r(new hI({type:jE.KEY_SYSTEM_ERROR,details:BE.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:a,response:tT({url:o.url,data:void 0},t)},`"${e}" certificate request failed (${n}). Status: ${t.code} (${t.text})`))},onTimeout:(t,i,a)=>{r(new hI({type:jE.KEY_SYSTEM_ERROR,details:BE.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:a,response:{url:o.url,data:void 0}},`"${e}" certificate request timed out (${n})`))},onAbort:(e,t,i)=>{r(new Error("aborted"))}};i.load(o,u,l)})):Promise.resolve()}},{key:"setMediaKeysServerCertificate",value:function(e,t,i){return new Promise((n,a)=>{e.setServerCertificate(i).then(a=>{this.log(`setServerCertificate ${a?"success":"not supported by CDM"} (${i.byteLength}) on "${t}"`),n(e)}).catch(e=>{a(new hI({type:jE.KEY_SYSTEM_ERROR,details:BE.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:e,fatal:!0},e.message))})})}},{key:"renewLicense",value:function(e,t){return this.requestLicense(e,new Uint8Array(t)).then(t=>this.updateKeySession(e,new Uint8Array(t)).catch(t=>{throw new hI({type:jE.KEY_SYSTEM_ERROR,details:BE.KEY_SYSTEM_SESSION_UPDATE_FAILED,decryptdata:e.decryptdata,error:t,fatal:!1},t.message)}))}},{key:"unpackPlayReadyKeyMessage",value:function(e,t){var i=String.fromCharCode.apply(null,new Uint16Array(t.buffer));if(!i.includes("PlayReadyKeyMessage"))return e.setRequestHeader("Content-Type","text/xml; charset=utf-8"),t;var n=(new DOMParser).parseFromString(i,"application/xml"),a=n.querySelectorAll("HttpHeader");if(a.length>0)for(var r,o=0,s=a.length;o<s;o++){var u,l,d=null==(u=(r=a[o]).querySelector("name"))?void 0:u.textContent,h=null==(l=r.querySelector("value"))?void 0:l.textContent;d&&h&&e.setRequestHeader(d,h)}var c=n.querySelector("Challenge"),m=null==c?void 0:c.textContent;if(!m)throw new Error("Cannot find <Challenge> in key message");return tA(atob(m))}},{key:"setupLicenseXHR",value:function(e,t,i,n){var a=this.config.licenseXhrSetup;return a?Promise.resolve().then(()=>{if(!i.decryptdata)throw new Error("Key removed");return a.call(this.hls,e,t,i,n)}).catch(r=>{if(!i.decryptdata)throw r;return e.open("POST",t,!0),a.call(this.hls,e,t,i,n)}).then(i=>(e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:i||n})):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:n}))}},{key:"requestLicense",value:function(e,t){var i=this.config.keyLoadPolicy.default;return new Promise((n,a)=>{var r=this.getLicenseServerUrlOrThrow(e.keySystem);this.log(`Sending license request to URL: ${r}`);var o=new XMLHttpRequest;o.responseType="arraybuffer",o.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return a(new Error("invalid state"));if(4===o.readyState)if(200===o.status){this._requestLicenseFailureCount=0;var s=o.response;this.log(`License received ${s instanceof ArrayBuffer?s.byteLength:s}`);var u=this.config.licenseResponseCallback;if(u)try{s=u.call(this.hls,o,r,e)}catch(e){this.error(e)}n(s)}else{var l=i.errorRetry,d=l?l.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>d||o.status>=400&&o.status<500)a(new hI({type:jE.KEY_SYSTEM_ERROR,details:BE.KEY_SYSTEM_LICENSE_REQUEST_FAILED,decryptdata:e.decryptdata,fatal:!0,networkDetails:o,response:{url:r,data:void 0,code:o.status,text:o.statusText}},`License Request XHR failed (${r}). Status: ${o.status} (${o.statusText})`));else{var h=d-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${h} attempts left`),this.requestLicense(e,t).then(n,a)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=o,this.setupLicenseXHR(o,r,e,t).then(({xhr:t,licenseChallenge:i})=>{e.keySystem==rA.PLAYREADY&&(i=this.unpackPlayReadyKeyMessage(t,i)),t.send(i)}).catch(a)})}},{key:"onDestroying",value:function(){this.unregisterListeners(),this._clear()}},{key:"onMediaAttached",value:function(e,t){if(this.config.emeEnabled){var i=t.media;this.media=i,eD(i,"encrypted",this.onMediaEncrypted),eD(i,"waitingforkey",this.onWaitingForKey);var n=this.mediaResolved;n?n():this.mediaKeys=i.mediaKeys}}},{key:"onMediaDetached",value:function(){var e=this.media;e&&(tD(e,"encrypted",this.onMediaEncrypted),tD(e,"waitingforkey",this.onWaitingForKey),this.media=null,this.mediaKeys=null)}},{key:"_clear",value:function(){var t;this._requestLicenseFailureCount=0,this.keyIdToKeySessionPromise={},this.bannedKeyIds={};var i=this.mediaResolved;if(i&&i(),this.mediaKeys||this.mediaKeySessions.length){var n=this.media,a=this.mediaKeySessions.slice();this.mediaKeySessions=[],this.mediaKeys=null,gA.clearKeyUriToKeyIdMap();var r=a.length;e.CDMCleanupPromise=Promise.all(a.map(e=>this.removeSession(e)).concat((null==n||null==(t=n.setMediaKeys(null))?void 0:t.catch(e=>{this.log(`Could not clear media keys: ${e}`),this.hls&&this.hls.trigger(zE.ERROR,{type:jE.OTHER_ERROR,details:BE.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR,fatal:!1,error:new Error(`Could not clear media keys: ${e}`)})}))||Promise.resolve())).catch(e=>{this.log(`Could not close sessions and clear media keys: ${e}`),this.hls&&this.hls.trigger(zE.ERROR,{type:jE.OTHER_ERROR,details:BE.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close sessions and clear media keys: ${e}`)})}).then(()=>{r&&this.log("finished closing key sessions and clearing media keys")})}}},{key:"onManifestLoading",value:function(){this._clear()}},{key:"onManifestLoaded",value:function(e,{sessionKeys:t}){if(t&&this.config.emeEnabled&&!this.keyFormatPromise){var i=t.reduce((e,t)=>(-1===e.indexOf(t.keyFormat)&&e.push(t.keyFormat),e),[]);this.log(`Selecting key-system from session-keys ${i.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(i)}}},{key:"removeSession",value:function(e){var t=e.mediaKeysSession,i=e.licenseXhr,n=e.decryptdata;if(t){this.log(`Remove licenses and keys and close session "${t.sessionId}" keyId: ${cT((null==n?void 0:n.keyId)||[])}`),e._onmessage&&(t.removeEventListener("message",e._onmessage),e._onmessage=void 0),e._onkeystatuseschange&&(t.removeEventListener("keystatuseschange",e._onkeystatuseschange),e._onkeystatuseschange=void 0),i&&i.readyState!==XMLHttpRequest.DONE&&i.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;var a=this.mediaKeySessions.indexOf(e);a>-1&&this.mediaKeySessions.splice(a,1);var r=e.keyStatusTimeouts;r&&Object.keys(r).forEach(e=>self.clearTimeout(r[e]));var o=function(e){var t;return!(!e||"persistent-license"!==e.sessionType&&(null==(t=e.sessionTypes)||!t.some(e=>"persistent-license"===e)))}(this.config.drmSystemOptions)?new Promise((e,i)=>{self.setTimeout(()=>i(new Error("MediaKeySession.remove() timeout")),8e3),t.remove().then(e).catch(i)}):Promise.resolve();return o.catch(e=>{this.log(`Could not remove session: ${e}`),this.hls&&this.hls.trigger(zE.ERROR,{type:jE.OTHER_ERROR,details:BE.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR,fatal:!1,error:new Error(`Could not remove session: ${e}`)})}).then(()=>t.close()).catch(e=>{this.log(`Could not close session: ${e}`),this.hls&&this.hls.trigger(zE.ERROR,{type:jE.OTHER_ERROR,details:BE.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close session: ${e}`)})})}return Promise.resolve()}}])}();function lI(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(null===e.keyId)throw new Error("keyId is null");return cT(e.keyId)}function dI(e,t){return e.keyId&&t.mediaKeysSession.keyStatuses.has(e.keyId)?t.mediaKeysSession.keyStatuses.get(e.keyId):e.matches(t.decryptdata)?t.keyStatus:void 0}uI.CDMCleanupPromise=void 0;var hI=function(){function e(t,i){var n;return u(this,e),(n=s(this,e,[i])).data=void 0,t.error||(t.error=new Error(i)),n.data=t,t.err=t.error,n}return y(e,D(Error)),m(e)}();function cI(e,t){var i="output-restricted"===e,n=i?BE.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:BE.KEY_SYSTEM_STATUS_INTERNAL_ERROR;return new hI({type:jE.KEY_SYSTEM_ERROR,details:n,fatal:!1,decryptdata:t},i?"HDCP level output restricted":`key status changed to "${e}"`)}var mI=function(){return m(function e(t){u(this,e),this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=t,this.registerListeners()},[{key:"setStreamController",value:function(e){this.streamController=e}},{key:"registerListeners",value:function(){this.hls.on(zE.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.on(zE.MEDIA_DETACHING,this.onMediaDetaching,this)}},{key:"unregisterListeners",value:function(){this.hls.off(zE.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off(zE.MEDIA_DETACHING,this.onMediaDetaching,this)}},{key:"destroy",value:function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}},{key:"onMediaAttaching",value:function(e,t){var i=this.hls.config;if(i.capLevelOnFPSDrop){var n=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=n,n&&"function"==typeof n.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),i.fpsDroppedMonitoringPeriod)}}},{key:"onMediaDetaching",value:function(){this.media=null}},{key:"checkFPS",value:function(e,t,i){var n=performance.now();if(t){if(this.lastTime){var a=n-this.lastTime,r=i-this.lastDroppedFrames,o=t-this.lastDecodedFrames,s=1e3*r/a,u=this.hls;if(u.trigger(zE.FPS_DROP,{currentDropped:r,currentDecoded:o,totalDroppedFrames:i}),s>0&&r>u.config.fpsDroppedMonitoringThreshold*o){var l=u.currentLevel;u.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+l),l>0&&(-1===u.autoLevelCapping||u.autoLevelCapping>=l)&&(l-=1,u.trigger(zE.FPS_DROP_LEVEL_CAPPING,{level:l,droppedLevel:u.currentLevel}),u.autoLevelCapping=l,this.streamController.nextLevelSwitch())}}this.lastTime=n,this.lastDroppedFrames=i,this.lastDecodedFrames=t}}},{key:"checkFPSInterval",value:function(){var e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){var t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}}])}();function fI(e,t){var i;try{i=new Event("addtrack")}catch(e){(i=document.createEvent("Event")).initEvent("addtrack",!1,!1)}i.track=e,t.dispatchEvent(i)}function vI(e,t){var i=e.mode;if("disabled"===i&&(e.mode="hidden"),e.cues&&!e.cues.getCueById(t.id))try{if(e.addCue(t),!e.cues.getCueById(t.id))throw new Error(`addCue is failed for: ${t}`)}catch(i){uT.debug(`[texttrack-utils]: ${i}`);try{var n=new self.TextTrackCue(t.startTime,t.endTime,t.text);n.id=t.id,e.addCue(n)}catch(e){uT.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${e}`)}}"disabled"===i&&(e.mode=i)}function pI(e,t){var i=e.mode;if("disabled"===i&&(e.mode="hidden"),e.cues)for(var n=e.cues.length;n--;)t&&e.cues[n].removeEventListener("enter",t),e.removeCue(e.cues[n]);"disabled"===i&&(e.mode=i)}function gI(e,t,i,n){var a=e.mode;if("disabled"===a&&(e.mode="hidden"),e.cues&&e.cues.length>0)for(var r=function(e,t,i){var n=[],a=function(e,t){if(t<=e[0].startTime)return 0;var i=e.length-1;if(t>e[i].endTime)return-1;var n,a=0,r=i;for(;a<=r;)if(t<e[n=Math.floor((r+a)/2)].startTime)r=n-1;else{if(!(t>e[n].startTime&&a<i))return n;a=n+1}return e[a].startTime-t<t-e[r].startTime?a:r}(e,t);if(a>-1)for(var r=a,o=e.length;r<o;r++){var s=e[r];if(s.startTime>=t&&s.endTime<=i)n.push(s);else if(s.startTime>i)return n}return n}(e.cues,t,i),o=0;o<r.length;o++)n&&!n(r[o])||e.removeCue(r[o]);"disabled"===a&&(e.mode=a)}function yI(e){for(var t=[],i=0;i<e.length;i++){var n=e[i];"subtitles"!==n.kind&&"captions"!==n.kind||!n.label||t.push(e[i])}return t}var bI=function(){function e(t){var i;return u(this,e),(i=s(this,e,[t,"subtitle-track-controller"])).media=null,i.tracks=[],i.groupIds=null,i.tracksInGroup=[],i.trackId=-1,i.currentTrack=null,i.selectDefaultTrack=!0,i.queuedDefaultTrack=-1,i.useTextTrackPolling=!1,i.subtitlePollingInterval=-1,i._subtitleDisplay=!0,i.asyncPollTrackChange=()=>i.pollTrackChange(0),i.onTextTracksChanged=()=>{if(i.useTextTrackPolling||self.clearInterval(i.subtitlePollingInterval),i.media&&i.hls.config.renderTextTracksNatively){for(var e=null,t=yI(i.media.textTracks),n=0;n<t.length;n++)if("hidden"===t[n].mode)e=t[n];else if("showing"===t[n].mode){e=t[n];break}var a=i.findTrackForTextTrack(e);i.subtitleTrack!==a&&i.setSubtitleTrack(a)}},i.registerListeners(),i}return y(e,Qx),m(e,[{key:"destroy",value:function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,this.onTextTracksChanged=this.asyncPollTrackChange=null,M(e,"destroy",this)([])}},{key:"subtitleDisplay",get:function(){return this._subtitleDisplay},set:function(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes()}},{key:"registerListeners",value:function(){var e=this.hls;e.on(zE.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(zE.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(zE.MANIFEST_LOADING,this.onManifestLoading,this),e.on(zE.MANIFEST_PARSED,this.onManifestParsed,this),e.on(zE.LEVEL_LOADING,this.onLevelLoading,this),e.on(zE.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(zE.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(zE.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(zE.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(zE.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(zE.MANIFEST_LOADING,this.onManifestLoading,this),e.off(zE.MANIFEST_PARSED,this.onManifestParsed,this),e.off(zE.LEVEL_LOADING,this.onLevelLoading,this),e.off(zE.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(zE.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(zE.ERROR,this.onError,this)}},{key:"onMediaAttached",value:function(e,t){this.media=t.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))}},{key:"pollTrackChange",value:function(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.onTextTracksChanged,e)}},{key:"onMediaDetaching",value:function(e,t){var i=this.media;if(i){var n=!!t.transferMedia;if(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||i.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),this.subtitleTrack=-1,this.media=null,!n)yI(i.textTracks).forEach(e=>{pI(e)})}}},{key:"onManifestLoading",value:function(){this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}},{key:"onManifestParsed",value:function(e,t){this.tracks=t.subtitleTracks}},{key:"onSubtitleTrackLoaded",value:function(e,t){var i=t.id,n=t.groupId,a=t.details,r=this.tracksInGroup[i];if(r&&r.groupId===n){var o=r.details;r.details=t.details,this.log(`Subtitle track ${i} "${r.name}" lang:${r.lang} group:${n} loaded [${a.startSN}-${a.endSN}]`),i===this.trackId&&this.playlistLoaded(i,t,o)}else this.warn(`Subtitle track with id:${i} and group:${n} not found in active group ${null==r?void 0:r.groupId}`)}},{key:"onLevelLoading",value:function(e,t){this.switchLevel(t.level)}},{key:"onLevelSwitching",value:function(e,t){this.switchLevel(t.level)}},{key:"switchLevel",value:function(e){var t=this.hls.levels[e];if(t){var i=t.subtitleGroups||null,n=this.groupIds,a=this.currentTrack;if(!i||(null==n?void 0:n.length)!==(null==i?void 0:i.length)||null!=i&&i.some(e=>-1===(null==n?void 0:n.indexOf(e)))){this.groupIds=i,this.trackId=-1,this.currentTrack=null;var r=this.tracks.filter(e=>!i||-1!==i.indexOf(e.groupId));if(r.length)this.selectDefaultTrack&&!r.some(e=>e.default)&&(this.selectDefaultTrack=!1),r.forEach((e,t)=>{e.id=t});else if(!a&&!this.tracksInGroup.length)return;this.tracksInGroup=r;var o=this.hls.config.subtitlePreference;if(!a&&o){this.selectDefaultTrack=!1;var s=jP(o,r);if(s>-1)a=r[s];else{var u=jP(o,this.tracks);a=this.tracks[u]}}var l=this.findTrackId(a);-1===l&&a&&(l=this.findTrackId(null));var d={subtitleTracks:r};this.log(`Updating subtitle tracks, ${r.length} track(s) found in "${null==i?void 0:i.join(",")}" group-id`),this.hls.trigger(zE.SUBTITLE_TRACKS_UPDATED,d),-1!==l&&-1===this.trackId&&this.setSubtitleTrack(l)}}}},{key:"findTrackId",value:function(e){for(var t=this.tracksInGroup,i=this.selectDefaultTrack,n=0;n<t.length;n++){var a=t[n];if((!i||a.default)&&(i||e)&&(!e||BP(a,e)))return n}if(e){for(var r=0;r<t.length;r++){var o=t[r];if(eC(e.attrs,o.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return r}for(var s=0;s<t.length;s++){var u=t[s];if(eC(e.attrs,u.attrs,["LANGUAGE"]))return s}}return-1}},{key:"findTrackForTextTrack",value:function(e){if(e)for(var t=this.tracksInGroup,i=0;i<t.length;i++){if(tC(t[i],e))return i}return-1}},{key:"onError",value:function(e,t){!t.fatal&&t.context&&(t.context.type!==VE||t.context.id!==this.trackId||this.groupIds&&-1===this.groupIds.indexOf(t.context.groupId)||this.checkRetry(t))}},{key:"allSubtitleTracks",get:function(){return this.tracks}},{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(e){this.selectDefaultTrack=!1,this.setSubtitleTrack(e)}},{key:"setSubtitleOption",value:function(e){if(this.hls.config.subtitlePreference=e,e){if(-1===e.id)return this.setSubtitleTrack(-1),null;var t=this.allSubtitleTracks;if(this.selectDefaultTrack=!1,t.length){var i=this.currentTrack;if(i&&BP(e,i))return i;var n=jP(e,this.tracksInGroup);if(n>-1){var a=this.tracksInGroup[n];return this.setSubtitleTrack(n),a}if(i)return null;var r=jP(e,t);if(r>-1)return t[r]}}return null}},{key:"loadPlaylist",value:function(t){M(e,"loadPlaylist",this)([]),this.shouldLoadPlaylist(this.currentTrack)&&this.scheduleLoading(this.currentTrack,t)}},{key:"loadingPlaylist",value:function(t,i){M(e,"loadingPlaylist",this)([t,i]);var n=t.id,a=t.groupId,r=this.getUrlWithDirectives(t.url,i),o=t.details,s=null==o?void 0:o.age;this.log(`Loading subtitle ${n} "${t.name}" lang:${t.lang} group:${a}${void 0!==(null==i?void 0:i.msn)?" at sn "+i.msn+" part "+i.part:""}${s&&o.live?" age "+s.toFixed(1)+(o.type&&" "+o.type||""):""} ${r}`),this.hls.trigger(zE.SUBTITLE_TRACK_LOADING,{url:r,id:n,groupId:a,deliveryDirectives:i||null,track:t})}},{key:"toggleTrackModes",value:function(){var e=this.media;if(e){var t,i=yI(e.textTracks),n=this.currentTrack;if(n&&((t=i.filter(e=>tC(n,e))[0])||this.warn(`Unable to find subtitle TextTrack with name "${n.name}" and language "${n.lang}"`)),[].slice.call(i).forEach(e=>{"disabled"!==e.mode&&e!==t&&(e.mode="disabled")}),t){var a=this.subtitleDisplay?"showing":"hidden";t.mode!==a&&(t.mode=a)}}}},{key:"setSubtitleTrack",value:function(e){var t=this.tracksInGroup;if(this.media)if(e<-1||e>=t.length||!WE(e))this.warn(`Invalid subtitle track id: ${e}`);else{this.selectDefaultTrack=!1;var i=this.currentTrack,n=t[e]||null;if(this.trackId=e,this.currentTrack=n,this.toggleTrackModes(),n){var a=!!n.details&&!n.details.live;if(e!==this.trackId||n!==i||!a){this.log(`Switching to subtitle-track ${e}`+(n?` "${n.name}" lang:${n.lang} group:${n.groupId}`:""));var r=n.id,o=n.groupId,s=void 0===o?"":o,u=n.name,l=n.type,d=n.url;this.hls.trigger(zE.SUBTITLE_TRACK_SWITCH,{id:r,groupId:s,name:u,type:l,url:d});var h=this.switchParams(n.url,null==i?void 0:i.details,n.details);this.loadPlaylist(h)}}else this.hls.trigger(zE.SUBTITLE_TRACK_SWITCH,{id:e})}else this.queuedDefaultTrack=e}}])}();function wI(e){for(var t=5381,i=e.length;i;)t=33*t^e.charCodeAt(--i);return(t>>>0).toString()}var kI=.025,SI=function(e){return e[e.Point=0]="Point",e[e.Range=1]="Range",e}({});function EI(e,t,i){return`${e.identifier}-${i+1}-${wI(t)}`}var TI=function(){return m(function e(t,i){u(this,e),this.base=void 0,this._duration=null,this._timelineStart=null,this.appendInPlaceDisabled=void 0,this.appendInPlaceStarted=void 0,this.dateRange=void 0,this.hasPlayed=!1,this.cumulativeDuration=0,this.resumeOffset=NaN,this.playoutLimit=NaN,this.restrictions={skip:!1,jump:!1},this.snapOptions={out:!1,in:!1},this.assetList=[],this.assetListLoader=void 0,this.assetListResponse=null,this.resumeAnchor=void 0,this.error=void 0,this.resetOnResume=void 0,this.base=i,this.dateRange=t,this.setDateRange(t)},[{key:"setDateRange",value:function(e){this.dateRange=e,this.resumeOffset=e.attr.optionalFloat("X-RESUME-OFFSET",this.resumeOffset),this.playoutLimit=e.attr.optionalFloat("X-PLAYOUT-LIMIT",this.playoutLimit),this.restrictions=e.attr.enumeratedStringList("X-RESTRICT",this.restrictions),this.snapOptions=e.attr.enumeratedStringList("X-SNAP",this.snapOptions)}},{key:"reset",value:function(){var e;this.appendInPlaceStarted=!1,null==(e=this.assetListLoader)||e.destroy(),this.assetListLoader=void 0,this.supplementsPrimary||(this.assetListResponse=null,this.assetList=[],this._duration=null)}},{key:"isAssetPastPlayoutLimit",value:function(e){var t;if(e>0&&e>=this.assetList.length)return!0;var i=this.playoutLimit;return!(e<=0||isNaN(i))&&(0===i||((null==(t=this.assetList[e])?void 0:t.startOffset)||0)>i)}},{key:"findAssetIndex",value:function(e){return this.assetList.indexOf(e)}},{key:"identifier",get:function(){return this.dateRange.id}},{key:"startDate",get:function(){return this.dateRange.startDate}},{key:"startTime",get:function(){var e=this.dateRange.startTime;if(this.snapOptions.out){var t=this.dateRange.tagAnchor;if(t)return PI(e,t)}return e}},{key:"startOffset",get:function(){return this.cue.pre?0:this.startTime}},{key:"startIsAligned",get:function(){if(0===this.startTime||this.snapOptions.out)return!0;var e=this.dateRange.tagAnchor;if(e){var t=this.dateRange.startTime;return t-PI(t,e)<.1}return!1}},{key:"resumptionOffset",get:function(){var e=this.resumeOffset,t=WE(e)?e:this.duration;return this.cumulativeDuration+t}},{key:"resumeTime",get:function(){var e=this.startOffset+this.resumptionOffset;if(this.snapOptions.in){var t=this.resumeAnchor;if(t)return PI(e,t)}return e}},{key:"appendInPlace",get:function(){return!!this.appendInPlaceStarted||!this.appendInPlaceDisabled&&!(this.cue.once||this.cue.pre||!this.startIsAligned||!(isNaN(this.playoutLimit)&&isNaN(this.resumeOffset)||this.resumeOffset&&this.duration&&Math.abs(this.resumeOffset-this.duration)<kI))},set:function(e){this.appendInPlaceStarted?this.resetOnResume=!e:this.appendInPlaceDisabled=!e}},{key:"timelineStart",get:function(){return null!==this._timelineStart?this._timelineStart:this.startTime},set:function(e){this._timelineStart=e}},{key:"duration",get:function(){var e,t=this.playoutLimit;return e=null!==this._duration?this._duration:this.dateRange.duration?this.dateRange.duration:this.dateRange.plannedDuration||0,!isNaN(t)&&t<e&&(e=t),e},set:function(e){this._duration=e}},{key:"cue",get:function(){return this.dateRange.cue}},{key:"timelineOccupancy",get:function(){return"RANGE"===this.dateRange.attr["X-TIMELINE-OCCUPIES"]?SI.Range:SI.Point}},{key:"supplementsPrimary",get:function(){return"PRIMARY"===this.dateRange.attr["X-TIMELINE-STYLE"]}},{key:"contentMayVary",get:function(){return"NO"!==this.dateRange.attr["X-CONTENT-MAY-VARY"]}},{key:"assetUrl",get:function(){return this.dateRange.attr["X-ASSET-URI"]}},{key:"assetListUrl",get:function(){return this.dateRange.attr["X-ASSET-LIST"]}},{key:"baseUrl",get:function(){return this.base.url}},{key:"assetListLoaded",get:function(){return this.assetList.length>0||null!==this.assetListResponse}},{key:"toString",value:function(){return`["${(e=this).identifier}" ${e.cue.pre?"<pre>":e.cue.post?"<post>":""}${e.timelineStart.toFixed(2)}-${e.resumeTime.toFixed(2)}]`;var e}}])}();function PI(e,t){return e-t.start<t.duration/2&&!(Math.abs(e-(t.start+t.duration))<kI)?t.start:t.start+t.duration}function MI(e,t,i){var n=new self.URL(e,i);return"data:"!==n.protocol&&n.searchParams.set("_HLS_primary_id",t),n}function AI(e,t){for(;null!=(i=e.assetList[++t])&&i.error;)var i;return t}function DI(e){var t=e.timelineStart,i=e.duration||0;return`["${e.identifier}" ${t.toFixed(2)}-${(t+i).toFixed(2)}]`}var xI=function(){return m(function e(t,i,n,a){u(this,e),this.hls=void 0,this.interstitial=void 0,this.assetItem=void 0,this.tracks=null,this.hasDetails=!1,this.mediaAttached=null,this._currentTime=void 0,this._bufferedEosTime=void 0,this.checkPlayout=()=>{this.reachedPlayout(this.currentTime)&&this.hls&&this.hls.trigger(zE.PLAYOUT_LIMIT_REACHED,{})};var r=this.hls=new t(i);this.interstitial=n,this.assetItem=a;var o=()=>{this.hasDetails=!0};r.once(zE.LEVEL_LOADED,o),r.once(zE.AUDIO_TRACK_LOADED,o),r.once(zE.SUBTITLE_TRACK_LOADED,o),r.on(zE.MEDIA_ATTACHING,(e,{media:t})=>{this.removeMediaListeners(),this.mediaAttached=t,this.interstitial.playoutLimit&&(t.addEventListener("timeupdate",this.checkPlayout),this.appendInPlace&&r.on(zE.BUFFER_APPENDED,()=>{var e=this.bufferedEnd;this.reachedPlayout(e)&&(this._bufferedEosTime=e,r.trigger(zE.BUFFERED_TO_END,void 0))}))})},[{key:"appendInPlace",get:function(){return this.interstitial.appendInPlace}},{key:"loadSource",value:function(){var e=this.hls;if(e)if(e.url)e.levels.length&&!e.started&&e.startLoad(-1,!0);else{var t=this.assetItem.uri;try{t=MI(t,e.config.primarySessionId||"").href}catch(e){}e.loadSource(t)}}},{key:"bufferedInPlaceToEnd",value:function(e){var t;if(!this.appendInPlace)return!1;if(null!=(t=this.hls)&&t.bufferedToEnd)return!0;if(!e)return!1;var i=Math.min(this._bufferedEosTime||1/0,this.duration),n=this.timelineOffset,a=WM.bufferInfo(e,n,0);return this.getAssetTime(a.end)>=i-.02}},{key:"reachedPlayout",value:function(e){var t=this.interstitial.playoutLimit;return this.startOffset+e>=t}},{key:"destroyed",get:function(){var e;return!(null!=(e=this.hls)&&e.userConfig)}},{key:"assetId",get:function(){return this.assetItem.identifier}},{key:"interstitialId",get:function(){return this.assetItem.parentIdentifier}},{key:"media",get:function(){var e;return(null==(e=this.hls)?void 0:e.media)||null}},{key:"bufferedEnd",get:function(){var e=this.media||this.mediaAttached;if(!e)return this._bufferedEosTime?this._bufferedEosTime:this.currentTime;var t=WM.bufferInfo(e,e.currentTime,.001);return this.getAssetTime(t.end)}},{key:"currentTime",get:function(){var e=this.media||this.mediaAttached;return e?this.getAssetTime(e.currentTime):this._currentTime||0}},{key:"duration",get:function(){var e=this.assetItem.duration;if(!e)return 0;var t=this.interstitial.playoutLimit;if(t){var i=t-this.startOffset;if(i>0&&i<e)return i}return e}},{key:"remaining",get:function(){var e=this.duration;return e?Math.max(0,e-this.currentTime):0}},{key:"startOffset",get:function(){return this.assetItem.startOffset}},{key:"timelineOffset",get:function(){var e;return(null==(e=this.hls)?void 0:e.config.timelineOffset)||0},set:function(e){var t=this.timelineOffset;if(e!==t){var i=e-t;if(Math.abs(i)>1/9e4&&this.hls){if(this.hasDetails)throw new Error("Cannot set timelineOffset after playlists are loaded");this.hls.config.timelineOffset=e}}}},{key:"getAssetTime",value:function(e){var t=this.timelineOffset,i=this.duration;return Math.min(Math.max(0,e-t),i)}},{key:"removeMediaListeners",value:function(){var e=this.mediaAttached;e&&(this._currentTime=e.currentTime,this.bufferSnapShot(),e.removeEventListener("timeupdate",this.checkPlayout))}},{key:"bufferSnapShot",value:function(){var e;this.mediaAttached&&(null!=(e=this.hls)&&e.bufferedToEnd&&(this._bufferedEosTime=this.bufferedEnd))}},{key:"destroy",value:function(){this.removeMediaListeners(),this.hls&&this.hls.destroy(),this.hls=null,this.tracks=this.mediaAttached=this.checkPlayout=null}},{key:"attachMedia",value:function(e){var t;this.loadSource(),null==(t=this.hls)||t.attachMedia(e)}},{key:"detachMedia",value:function(){var e;this.removeMediaListeners(),this.mediaAttached=null,null==(e=this.hls)||e.detachMedia()}},{key:"resumeBuffering",value:function(){var e;null==(e=this.hls)||e.resumeBuffering()}},{key:"pauseBuffering",value:function(){var e;null==(e=this.hls)||e.pauseBuffering()}},{key:"transferMedia",value:function(){var e;return this.bufferSnapShot(),(null==(e=this.hls)?void 0:e.transferMedia())||null}},{key:"resetDetails",value:function(){var e=this.hls;if(e&&this.hasDetails){e.stopLoad();var t=e=>delete e.details;e.levels.forEach(t),e.allAudioTracks.forEach(t),e.allSubtitleTracks.forEach(t),this.hasDetails=!1}}},{key:"on",value:function(e,t,i){var n;null==(n=this.hls)||n.on(e,t)}},{key:"once",value:function(e,t,i){var n;null==(n=this.hls)||n.once(e,t)}},{key:"off",value:function(e,t,i){var n;null==(n=this.hls)||n.off(e,t)}},{key:"toString",value:function(){var e;return`HlsAssetPlayer: ${DI(this.assetItem)} ${null==(e=this.hls)?void 0:e.sessionId} ${this.appendInPlace?"append-in-place":""}`}}])}(),CI=function(){function e(t,i){var n;return u(this,e),(n=s(this,e,["interstitials-sched",i])).onScheduleUpdate=void 0,n.eventMap={},n.events=null,n.items=null,n.durations={primary:0,playout:0,integrated:0},n.onScheduleUpdate=t,n}return y(e,iT),m(e,[{key:"destroy",value:function(){this.reset(),this.onScheduleUpdate=null}},{key:"reset",value:function(){this.eventMap={},this.setDurations(0,0,0),this.events&&this.events.forEach(e=>e.reset()),this.events=this.items=null}},{key:"resetErrorsInRange",value:function(e,t){return this.events?this.events.reduce((i,n)=>e<=n.startOffset&&t>n.startOffset?(delete n.error,i+1):i,0):0}},{key:"duration",get:function(){var e=this.items;return e?e[e.length-1].end:0}},{key:"length",get:function(){return this.items?this.items.length:0}},{key:"getEvent",value:function(e){return e&&this.eventMap[e]||null}},{key:"hasEvent",value:function(e){return e in this.eventMap}},{key:"findItemIndex",value:function(e,t){if(e.event)return this.findEventIndex(e.event.identifier);var i=-1;e.nextEvent?i=this.findEventIndex(e.nextEvent.identifier)-1:e.previousEvent&&(i=this.findEventIndex(e.previousEvent.identifier)+1);var n=this.items;if(n)for(n[i]||(void 0===t&&(t=e.start),i=this.findItemIndexAtTime(t));i>=0&&null!=(a=n[i])&&a.event;){var a;i--}return i}},{key:"findItemIndexAtTime",value:function(e,t){var i=this.items;if(i)for(var n=0;n<i.length;n++){var a=i[n];if(t&&"primary"!==t&&(a=a[t]),e===a.start||e>a.start&&e<a.end)return n}return-1}},{key:"findJumpRestrictedIndex",value:function(e,t){var i=this.items;if(i)for(var n=e;n<=t&&i[n];n++){var a=i[n].event;if(null!=a&&a.restrictions.jump&&!a.appendInPlace)return n}return-1}},{key:"findEventIndex",value:function(e){var t=this.items;if(t)for(var i=t.length;i--;){var n;if((null==(n=t[i].event)?void 0:n.identifier)===e)return i}return-1}},{key:"findAssetIndex",value:function(e,t){var i=e.assetList,n=i.length;if(n>1)for(var a=0;a<n;a++){var r=i[a];if(!r.error){var o=r.timelineStart;if(t===o||t>o&&(t<o+(r.duration||0)||a===n-1))return a}}return 0}},{key:"assetIdAtEnd",get:function(){var e,t=null==(e=this.items)||null==(e=e[this.length-1])?void 0:e.event;if(t){var i=t.assetList,n=i[i.length-1];if(n)return n.identifier}return null}},{key:"parseInterstitialDateRanges",value:function(e,t){var i=e.main.details,n=i.dateRanges,a=this.events,r=this.parseDateRanges(n,{url:i.url},t),o=Object.keys(n),s=a?a.filter(e=>!o.includes(e.identifier)):[];r.length&&r.sort((e,t)=>{var i=e.cue.pre,n=e.cue.post,a=t.cue.pre,r=t.cue.post;if(i&&!a)return-1;if(a&&!i)return 1;if(n&&!r)return 1;if(r&&!n)return-1;if(!(i||a||n||r)){var o=e.startTime,s=t.startTime;if(o!==s)return o-s}return e.dateRange.tagOrder-t.dateRange.tagOrder}),this.events=r,s.forEach(e=>{this.removeEvent(e)}),this.updateSchedule(e,s)}},{key:"updateSchedule",value:function(e,t=[],i=!1){var n=this.events||[];if(n.length||t.length||this.length<2){var a=this.items,r=this.parseSchedule(n,e),o=i||t.length||(null==a?void 0:a.length)!==r.length||r.some((e,t)=>Math.abs(e.playout.start-a[t].playout.start)>.005||Math.abs(e.playout.end-a[t].playout.end)>.005);o&&(this.items=r,this.onScheduleUpdate(t,a))}}},{key:"parseDateRanges",value:function(e,t,i){for(var n=[],a=Object.keys(e),r=0;r<a.length;r++){var o=a[r],s=e[o];if(s.isInterstitial){var u=this.eventMap[o];u?u.setDateRange(s):(u=new TI(s,t),this.eventMap[o]=u,!1===i&&(u.appendInPlace=i)),n.push(u)}}return n}},{key:"parseSchedule",value:function(e,t){var i=[],n=t.main.details,a=n.live?1/0:n.edge,r=0;if((e=e.filter(e=>!(e.error||e.cue.once&&e.hasPlayed))).length){this.resolveOffsets(e,t);var o=0,s=0;if(e.forEach((t,n)=>{var u=t.cue.pre,l=t.cue.post,d=e[n-1]||null,h=t.appendInPlace,c=l?a:t.startOffset,m=t.duration,f=t.timelineOccupancy===SI.Range?m:0,v=t.resumptionOffset,p=(null==d?void 0:d.startTime)===c,g=c+t.cumulativeDuration,y=h?g+m:c+v;if(u||!l&&c<=0){var b=s;s+=f,t.timelineStart=g;var w=r;r+=m,i.push({event:t,start:g,end:y,playout:{start:w,end:r},integrated:{start:b,end:s}})}else{if(!(c<=a))return;if(!p){var k=c-o;if(k>.033){var S=o,E=s;s+=k;var T=r;r+=k;var P={previousEvent:e[n-1]||null,nextEvent:t,start:S,end:S+k,playout:{start:T,end:r},integrated:{start:E,end:s}};i.push(P)}else k>0&&d&&(d.cumulativeDuration+=k,i[i.length-1].end=c)}l&&(y=g),t.timelineStart=g;var M=s;s+=f;var A=r;r+=m,i.push({event:t,start:g,end:y,playout:{start:A,end:r},integrated:{start:M,end:s}})}var D=t.resumeTime;o=l||D>a?a:D}),o<a){var u,l=o,d=s,h=a-o;s+=h;var c=r;r+=h,i.push({previousEvent:(null==(u=i[i.length-1])?void 0:u.event)||null,nextEvent:null,start:o,end:l+h,playout:{start:c,end:r},integrated:{start:d,end:s}})}this.setDurations(a,r,s)}else{i.push({previousEvent:null,nextEvent:null,start:0,end:a,playout:{start:0,end:a},integrated:{start:0,end:a}}),this.setDurations(a,a,a)}return i}},{key:"setDurations",value:function(e,t,i){this.durations={primary:e,playout:t,integrated:i}}},{key:"resolveOffsets",value:function(e,t){var i=t.main.details,n=i.live?1/0:i.edge,a=0,r=-1;e.forEach((o,s)=>{var u=o.cue.pre,l=o.cue.post,d=u?0:l?n:o.startTime;(this.updateAssetDurations(o),r===d?o.cumulativeDuration=a:(a=0,r=d),!l&&o.snapOptions.in&&(o.resumeAnchor=KP(null,i.fragments,o.startOffset+o.resumptionOffset,0,0)||void 0),o.appendInPlace&&!o.appendInPlaceStarted)&&(this.primaryCanResumeInPlaceAt(o,t)||(o.appendInPlace=!1));!o.appendInPlace&&s+1<e.length&&(e[s+1].startTime-e[s].resumeTime<.033&&(e[s+1].appendInPlace=!1,e[s+1].appendInPlace&&this.warn(`Could not change append strategy for abutting event ${o}`)));var h=WE(o.resumeOffset)?o.resumeOffset:o.duration;a+=h})}},{key:"primaryCanResumeInPlaceAt",value:function(e,t){var i=e.resumeTime,n=e.startTime+e.resumptionOffset;return Math.abs(i-n)>kI?(this.log(`"${e.identifier}" resumption ${i} not aligned with estimated timeline end ${n}`),!1):!Object.keys(t).some(n=>{var a=t[n].details,r=a.edge;if(i>=r)return this.log(`"${e.identifier}" resumption ${i} past ${n} playlist end ${r}`),!1;var o=KP(null,a.fragments,i);if(!o)return this.log(`"${e.identifier}" resumption ${i} does not align with any fragments in ${n} playlist (${a.fragStart}-${a.fragmentEnd})`),!0;var s="audio"===n?.175:0;return!(Math.abs(o.start-i)<kI+s||Math.abs(o.end-i)<kI+s)&&(this.log(`"${e.identifier}" resumption ${i} not aligned with ${n} fragment bounds (${o.start}-${o.end} sn: ${o.sn} cc: ${o.cc})`),!0)})}},{key:"updateAssetDurations",value:function(e){if(e.assetListLoaded){for(var t=e.timelineStart,i=0,n=!1,a=!1,r=0;r<e.assetList.length;r++){var o=e.assetList[r],s=t+i;o.startOffset=i,o.timelineStart=s,n||(n=null===o.duration),a||(a=!!o.error),i+=o.error?0:o.duration||0}e.duration=n&&!a?Math.max(i,e.duration):i}}},{key:"removeEvent",value:function(e){e.reset(),delete this.eventMap[e.identifier]}}])}();function II(e){return`[${e.event?'"'+e.event.identifier+'"':"primary"}: ${e.start.toFixed(2)}-${e.end.toFixed(2)}]`}var LI=function(){return m(function e(t){u(this,e),this.hls=void 0,this.hls=t},[{key:"destroy",value:function(){this.hls=null}},{key:"loadAssetList",value:function(e,t){var i,n=e.assetListUrl;try{i=MI(n,this.hls.sessionId,e.baseUrl)}catch(t){var a=this.assignAssetListError(e,BE.ASSET_LIST_LOAD_ERROR,t,n);return void this.hls.trigger(zE.ERROR,a)}t&&"data:"!==i.protocol&&i.searchParams.set("_HLS_start_offset",""+t);var r=this.hls.config,o=new(0,r.loader)(r),s={responseType:"json",url:i.href},u=r.interstitialAssetListLoadPolicy.default,l={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},d={onSuccess:(t,i,n,a)=>{var r=t.data,o=null==r?void 0:r.ASSETS;if(Array.isArray(o))e.assetListResponse=r,this.hls.trigger(zE.ASSET_LIST_LOADED,{event:e,assetListResponse:r,networkDetails:a});else{var s=this.assignAssetListError(e,BE.ASSET_LIST_PARSING_ERROR,new Error("Invalid interstitial asset list"),n.url,i,a);this.hls.trigger(zE.ERROR,s)}},onError:(t,i,n,a)=>{var r=this.assignAssetListError(e,BE.ASSET_LIST_LOAD_ERROR,new Error(`Error loading X-ASSET-LIST: HTTP status ${t.code} ${t.text} (${i.url})`),i.url,a,n);this.hls.trigger(zE.ERROR,r)},onTimeout:(t,i,n)=>{var a=this.assignAssetListError(e,BE.ASSET_LIST_LOAD_TIMEOUT,new Error(`Timeout loading X-ASSET-LIST (${i.url})`),i.url,t,n);this.hls.trigger(zE.ERROR,a)}};return o.load(s,l,d),this.hls.trigger(zE.ASSET_LIST_LOADING,{event:e}),o}},{key:"assignAssetListError",value:function(e,t,i,n,a,r){return e.error=i,{type:jE.NETWORK_ERROR,details:t,fatal:!1,interstitial:e,url:n,error:i,networkDetails:r,stats:a}}}])}();function _I(e){var t;null==e||null==(t=e.play())||t.catch(()=>{})}function RI(e,t){return`[${e}] Advancing timeline position to ${t}`}var FI=function(){function e(t,i){var n;return u(this,e),(n=s(this,e,["interstitials",t.logger])).HlsPlayerClass=void 0,n.hls=void 0,n.assetListLoader=void 0,n.mediaSelection=null,n.altSelection=null,n.media=null,n.detachedData=null,n.requiredTracks=null,n.manager=null,n.playerQueue=[],n.bufferedPos=-1,n.timelinePos=-1,n.schedule=void 0,n.playingItem=null,n.bufferingItem=null,n.waitingItem=null,n.endedItem=null,n.playingAsset=null,n.endedAsset=null,n.bufferingAsset=null,n.shouldPlay=!1,n.onPlay=()=>{n.shouldPlay=!0},n.onPause=()=>{n.shouldPlay=!1},n.onSeeking=()=>{var e=n.currentTime;if(void 0!==e&&!n.playbackDisabled&&n.schedule){var t=e-n.timelinePos;if(!(Math.abs(t)<1/7056e5)){var i=t<=-.01;-1!==n.timelinePos||n.effectivePlayingItem||n.checkStart(),n.timelinePos=e,n.bufferedPos=e;var a=n.playingItem;if(a){if(i)n.schedule.resetErrorsInRange(e,e-t)&&n.updateSchedule(!0);if(n.checkBuffer(),i&&e<a.start||e>=a.end){var r,o=n.findItemIndex(a),s=n.schedule.findItemIndexAtTime(e);if(-1===s&&(s=o+(i?-1:1),n.log(`seeked ${i?"back ":""}to position not covered by schedule ${e} (resolving from ${o} to ${s})`)),!n.isInterstitial(a)&&null!=(r=n.media)&&r.paused&&(n.shouldPlay=!1),!i&&s>o){var u=n.schedule.findJumpRestrictedIndex(o+1,s);if(u>o)return void n.setSchedulePosition(u)}n.setSchedulePosition(s)}else{var l=n.playingAsset;if(l){var d,h=l.timelineStart,c=l.duration||0;if(i&&e<h||e>=h+c)null!=(d=a.event)&&d.appendInPlace&&(n.clearAssetPlayers(a.event,a),n.flushFrontBuffer(e)),n.setScheduleToAssetAtTime(e,l)}else if(n.playingLastItem&&n.isInterstitial(a)){var m=a.event.assetList[0];m&&(n.endedItem=n.playingItem,n.playingItem=null,n.setScheduleToAssetAtTime(e,m))}}}else n.checkBuffer()}}},n.onTimeupdate=()=>{var e=n.currentTime;if(void 0!==e&&!n.playbackDisabled&&(-1!==n.timelinePos||n.effectivePlayingItem||n.checkStart(),e>n.timelinePos)){n.timelinePos=e,e>n.bufferedPos&&n.checkBuffer();var t=n.playingItem;if(t&&!n.playingLastItem){if(e>=t.end){n.timelinePos=t.end;var i=n.findItemIndex(t);n.setSchedulePosition(i+1)}var a=n.playingAsset;if(a)e>=a.timelineStart+(a.duration||0)&&n.setScheduleToAssetAtTime(e,a)}}},n.onScheduleUpdate=(e,t)=>{var i=n.schedule;if(i){var a=n.playingItem,r=i.events||[],o=i.items||[],s=i.durations,u=e.map(e=>e.identifier),l=!(!r.length&&!u.length);(l||t)&&n.log(`INTERSTITIALS_UPDATED (${r.length}): ${r}\nSchedule: ${o.map(e=>II(e))} pos: ${n.timelinePos}`),u.length&&n.log(`Removed events ${u}`);var d=null,h=null;a&&(d=n.updateItem(a,n.timelinePos),n.itemsMatch(a,d)?n.playingItem=d:n.waitingItem=n.endedItem=null),n.waitingItem=n.updateItem(n.waitingItem),n.endedItem=n.updateItem(n.endedItem);var c=n.bufferingItem;if(c&&(h=n.updateItem(c,n.bufferedPos),n.itemsMatch(c,h)?n.bufferingItem=h:c.event&&(n.bufferingItem=n.playingItem,n.clearInterstitial(c.event,null))),e.forEach(e=>{e.assetList.forEach(e=>{n.clearAssetPlayer(e.identifier,null)})}),n.playerQueue.forEach(e=>{if(e.interstitial.appendInPlace){var t=e.assetItem.timelineStart,i=e.timelineOffset-t;if(i)try{e.timelineOffset=t}catch(a){Math.abs(i)>kI&&n.warn(`${a} ("${e.assetId}" ${e.timelineOffset}->${t})`)}}}),l||t){if(n.hls.trigger(zE.INTERSTITIALS_UPDATED,{events:r.slice(0),schedule:o.slice(0),durations:s,removedIds:u}),n.isInterstitial(a)&&u.includes(a.event.identifier))return n.warn(`Interstitial "${a.event.identifier}" removed while playing`),void n.primaryFallback(a.event);a&&n.trimInPlace(d,a),c&&h!==d&&n.trimInPlace(h,c),n.checkBuffer()}}},n.hls=t,n.HlsPlayerClass=i,n.assetListLoader=new LI(t),n.schedule=new CI(n.onScheduleUpdate,t.logger),n.registerListeners(),n}return y(e,iT),m(e,[{key:"registerListeners",value:function(){var e=this.hls;e&&(e.on(zE.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(zE.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(zE.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(zE.MANIFEST_LOADING,this.onManifestLoading,this),e.on(zE.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(zE.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(zE.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.on(zE.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(zE.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.on(zE.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.on(zE.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.on(zE.BUFFER_APPENDED,this.onBufferAppended,this),e.on(zE.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(zE.BUFFERED_TO_END,this.onBufferedToEnd,this),e.on(zE.MEDIA_ENDED,this.onMediaEnded,this),e.on(zE.ERROR,this.onError,this),e.on(zE.DESTROYING,this.onDestroying,this))}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(zE.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(zE.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(zE.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(zE.MANIFEST_LOADING,this.onManifestLoading,this),e.off(zE.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(zE.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(zE.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.off(zE.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(zE.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.off(zE.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.off(zE.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.off(zE.BUFFER_CODECS,this.onBufferCodecs,this),e.off(zE.BUFFER_APPENDED,this.onBufferAppended,this),e.off(zE.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(zE.BUFFERED_TO_END,this.onBufferedToEnd,this),e.off(zE.MEDIA_ENDED,this.onMediaEnded,this),e.off(zE.ERROR,this.onError,this),e.off(zE.DESTROYING,this.onDestroying,this))}},{key:"startLoad",value:function(){this.resumeBuffering()}},{key:"stopLoad",value:function(){this.pauseBuffering()}},{key:"resumeBuffering",value:function(){var e;null==(e=this.getBufferingPlayer())||e.resumeBuffering()}},{key:"pauseBuffering",value:function(){var e;null==(e=this.getBufferingPlayer())||e.pauseBuffering()}},{key:"destroy",value:function(){this.unregisterListeners(),this.stopLoad(),this.assetListLoader&&this.assetListLoader.destroy(),this.emptyPlayerQueue(),this.clearScheduleState(),this.schedule&&this.schedule.destroy(),this.media=this.detachedData=this.mediaSelection=this.requiredTracks=this.altSelection=this.schedule=this.manager=null,this.hls=this.HlsPlayerClass=this.log=null,this.assetListLoader=null,this.onPlay=this.onPause=this.onSeeking=this.onTimeupdate=null,this.onScheduleUpdate=null}},{key:"onDestroying",value:function(){var e=this.primaryMedia||this.media;e&&this.removeMediaListeners(e)}},{key:"removeMediaListeners",value:function(e){tD(e,"play",this.onPlay),tD(e,"pause",this.onPause),tD(e,"seeking",this.onSeeking),tD(e,"timeupdate",this.onTimeupdate)}},{key:"onMediaAttaching",value:function(e,t){var i=this.media=t.media;eD(i,"seeking",this.onSeeking),eD(i,"timeupdate",this.onTimeupdate),eD(i,"play",this.onPlay),eD(i,"pause",this.onPause)}},{key:"onMediaAttached",value:function(e,t){var i=this.effectivePlayingItem,n=this.detachedData;if(this.detachedData=null,null===i)this.checkStart();else if(!n){this.clearScheduleState();var a=this.findItemIndex(i);this.setSchedulePosition(a)}}},{key:"clearScheduleState",value:function(){this.log("clear schedule state"),this.playingItem=this.bufferingItem=this.waitingItem=this.endedItem=this.playingAsset=this.endedAsset=this.bufferingAsset=null}},{key:"onMediaDetaching",value:function(e,t){var i=!!t.transferMedia,n=this.media;if(this.media=null,!i&&(n&&this.removeMediaListeners(n),this.detachedData)){var a=this.getBufferingPlayer();a&&(this.log(`Removing schedule state for detachedData and ${a}`),this.playingAsset=this.endedAsset=this.bufferingAsset=this.bufferingItem=this.waitingItem=this.detachedData=null,a.detachMedia()),this.shouldPlay=!1}}},{key:"interstitialsManager",get:function(){if(!this.hls)return null;if(this.manager)return this.manager;var e=this,t=()=>e.bufferingItem||e.waitingItem,i=t=>t?e.getAssetPlayer(t.identifier):t,n=(t,n,r,o,s)=>{if(t){var u=t[n].start,l=t.event;if(l){if("playout"===n||l.timelineOccupancy!==SI.Point){var d=i(r);(null==d?void 0:d.interstitial)===l&&(u+=d.assetItem.startOffset+d[s])}}else u+=("bufferedPos"===o?a():e[o])-t.start;return u}return 0},a=()=>{var t=e.bufferedPos;return t===Number.MAX_VALUE?r("primary"):Math.max(t,0)},r=t=>{var i,n;return null!=(i=e.primaryDetails)&&i.live?e.primaryDetails.edge:(null==(n=e.schedule)?void 0:n.durations[t])||0},o=(t,a)=>{var r,o,s=e.effectivePlayingItem;if((null==s||null==(r=s.event)||!r.restrictions.skip)&&e.schedule){e.log(`seek to ${t} "${a}"`);var u=e.effectivePlayingItem,l=e.schedule.findItemIndexAtTime(t,a),d=null==(o=e.schedule.items)?void 0:o[l],h=e.getBufferingPlayer(),c=null==h?void 0:h.interstitial,m=null==c?void 0:c.appendInPlace,f=u&&e.itemsMatch(u,d);if(u&&(m||f)){var v=i(e.playingAsset),p=(null==v?void 0:v.media)||e.primaryMedia;if(p){var g="primary"===a?p.currentTime:n(u,a,e.playingAsset,"timelinePos","currentTime"),y=t-g,b=(m?g:p.currentTime)+y;if(b>=0&&(!v||m||b<=v.duration))return void(p.currentTime=b)}}if(d){var w=t;if("primary"!==a){var k=t-d[a].start;w=d.start+k}var S=!e.isInterstitial(d);if(e.isInterstitial(u)&&!u.event.appendInPlace||!S&&!d.event.appendInPlace){if(u){var E=e.findItemIndex(u);if(l>E){var T=e.schedule.findJumpRestrictedIndex(E+1,l);if(T>E)return void e.setSchedulePosition(T)}var P=0;if(S)e.timelinePos=w,e.checkBuffer();else for(var M=d.event.assetList,A=t-(d[a]||d).start,D=M.length;D--;){var x=M[D];if(x.duration&&A>=x.startOffset&&A<x.startOffset+x.duration){P=D;break}}e.setSchedulePosition(l,P)}}else{var C=e.media||(m?null==h?void 0:h.media:null);C&&(C.currentTime=w)}}}},s=()=>{var i=e.effectivePlayingItem;if(e.isInterstitial(i))return i;var n=t();return e.isInterstitial(n)?n:null},u={get bufferedEnd(){var i,a=t(),r=e.bufferingItem;return r&&r===a&&(n(r,"playout",e.bufferingAsset,"bufferedPos","bufferedEnd")-r.playout.start||(null==(i=e.bufferingAsset)?void 0:i.startOffset))||0},get currentTime(){var t=s(),i=e.effectivePlayingItem;return i&&i===t?n(i,"playout",e.effectivePlayingAsset,"timelinePos","currentTime")-i.playout.start:0},set currentTime(t){var i=s(),n=e.effectivePlayingItem;n&&n===i&&o(t+n.playout.start,"playout")},get duration(){var e=s();return e?e.playout.end-e.playout.start:0},get assetPlayers(){var t,i=null==(t=s())?void 0:t.event.assetList;return i?i.map(t=>e.getAssetPlayer(t.identifier)):[]},get playingIndex(){var t,i=null==(t=s())?void 0:t.event;return i&&e.effectivePlayingAsset?i.findAssetIndex(e.effectivePlayingAsset):-1},get scheduleItem(){return s()}};return this.manager={get events(){var t;return(null==(t=e.schedule)||null==(t=t.events)?void 0:t.slice(0))||[]},get schedule(){var t;return(null==(t=e.schedule)||null==(t=t.items)?void 0:t.slice(0))||[]},get interstitialPlayer(){return s()?u:null},get playerQueue(){return e.playerQueue.slice(0)},get bufferingAsset(){return e.bufferingAsset},get bufferingItem(){return t()},get bufferingIndex(){var i=t();return e.findItemIndex(i)},get playingAsset(){return e.effectivePlayingAsset},get playingItem(){return e.effectivePlayingItem},get playingIndex(){var t=e.effectivePlayingItem;return e.findItemIndex(t)},primary:{get bufferedEnd(){return a()},get currentTime(){var t=e.timelinePos;return t>0?t:0},set currentTime(e){o(e,"primary")},get duration(){return r("primary")},get seekableStart(){var t;return(null==(t=e.primaryDetails)?void 0:t.fragmentStart)||0}},integrated:{get bufferedEnd(){return n(t(),"integrated",e.bufferingAsset,"bufferedPos","bufferedEnd")},get currentTime(){return n(e.effectivePlayingItem,"integrated",e.effectivePlayingAsset,"timelinePos","currentTime")},set currentTime(e){o(e,"integrated")},get duration(){return r("integrated")},get seekableStart(){var t;return((t,i)=>{var n;if(0!==t&&"primary"!==i&&null!=(n=e.schedule)&&n.length){var a,r=e.schedule.findItemIndexAtTime(t),o=null==(a=e.schedule.items)?void 0:a[r];if(o)return t+(o[i].start-o.start)}return t})((null==(t=e.primaryDetails)?void 0:t.fragmentStart)||0,"integrated")}},skip:()=>{var t=e.effectivePlayingItem,i=null==t?void 0:t.event;if(i&&!i.restrictions.skip){var n=e.findItemIndex(t);if(i.appendInPlace){var a=t.playout.start+t.event.duration;o(a+.001,"playout")}else e.advanceAfterAssetEnded(i,n,1/0)}}}}},{key:"effectivePlayingItem",get:function(){return this.waitingItem||this.playingItem||this.endedItem}},{key:"effectivePlayingAsset",get:function(){return this.playingAsset||this.endedAsset}},{key:"playingLastItem",get:function(){var e,t=this.playingItem,i=null==(e=this.schedule)?void 0:e.items;return!!(this.playbackStarted&&t&&i)&&this.findItemIndex(t)===i.length-1}},{key:"playbackStarted",get:function(){return null!==this.effectivePlayingItem}},{key:"currentTime",get:function(){var e,t;if(null!==this.mediaSelection){var i=this.waitingItem||this.playingItem;if(!this.isInterstitial(i)||i.event.appendInPlace){var n=this.media;!n&&null!=(e=this.bufferingItem)&&null!=(e=e.event)&&e.appendInPlace&&(n=this.primaryMedia);var a=null==(t=n)?void 0:t.currentTime;if(void 0!==a&&WE(a))return a}}}},{key:"primaryMedia",get:function(){var e;return this.media||(null==(e=this.detachedData)?void 0:e.media)||null}},{key:"isInterstitial",value:function(e){return!(null==e||!e.event)}},{key:"retreiveMediaSource",value:function(e,t){var i=this.getAssetPlayer(e);i&&this.transferMediaFromPlayer(i,t)}},{key:"transferMediaFromPlayer",value:function(e,t){var i=e.interstitial.appendInPlace,n=e.media;if(i&&n===this.primaryMedia){if(this.bufferingAsset=null,(!t||this.isInterstitial(t)&&!t.event.appendInPlace)&&t&&n)return void(this.detachedData={media:n});var a=e.transferMedia();this.log(`transfer MediaSource from ${e} ${OP(a)}`),this.detachedData=a}else t&&n&&(this.shouldPlay||(this.shouldPlay=!n.paused))}},{key:"transferMediaTo",value:function(e,t){var i,n;if(e.media!==t){var a,r=null,o=this.hls,s=e!==o,u=s&&e.interstitial.appendInPlace,l=null==(i=this.detachedData)?void 0:i.mediaSource;if(o.media)u&&(r=o.transferMedia(),this.detachedData=r),a="Primary";else if(l){var d=this.getBufferingPlayer();d?(r=d.transferMedia(),a=`${d}`):a="detached MediaSource"}else a="detached media";if(!r)if(l)r=this.detachedData,this.log(`using detachedData: MediaSource ${OP(r)}`);else if(!this.detachedData||o.media===t){var h=this.playerQueue;h.length>1&&h.forEach(e=>{if(s&&e.interstitial.appendInPlace!==u){var t=e.interstitial;this.clearInterstitial(e.interstitial,null),t.appendInPlace=!1,t.appendInPlace&&this.warn(`Could not change append strategy for queued assets ${t}`)}}),this.hls.detachMedia(),this.detachedData={media:t}}var c=r&&"mediaSource"in r&&"closed"!==(null==(n=r.mediaSource)?void 0:n.readyState),m=c&&r?r:t;this.log(`${c?"transfering MediaSource":"attaching media"} to ${s?e:"Primary"} from ${a} (media.currentTime: ${t.currentTime})`);var f=this.schedule;if(m===r&&f){var v=s&&e.assetId===f.assetIdAtEnd;m.overrides={duration:f.duration,endOfStream:!s||v,cueRemoval:!s}}e.attachMedia(m)}}},{key:"onInterstitialCueEnter",value:function(){this.onTimeupdate()}},{key:"checkStart",value:function(){var e=this.schedule,t=null==e?void 0:e.events;if(t&&!this.playbackDisabled&&this.media){-1===this.bufferedPos&&(this.bufferedPos=0);var i=this.timelinePos,n=this.effectivePlayingItem;if(-1===i){var a=this.hls.startPosition;if(this.timelinePos=a,0===t.length)this.setSchedulePosition(0);else if(t[0].cue.pre){this.log(RI("checkStart (preroll)",a));var r=e.findEventIndex(t[0].identifier);this.setSchedulePosition(r)}else if(a>=0||!this.primaryLive){this.log(RI("checkStart",a));var o=this.timelinePos=a>0?a:0,s=e.findItemIndexAtTime(o);this.setSchedulePosition(s)}else 0===this.hls.liveSyncPosition?this.setSchedulePosition(0):this.log("[checkStart] waiting for live start")}else if(n&&!this.playingItem){this.log(RI("checkStart (playing item)",n.start));var u=e.findItemIndex(n);this.setSchedulePosition(u)}}}},{key:"advanceAssetBuffering",value:function(e,t){var i=e.event,n=i.findAssetIndex(t),a=AI(i,n);if(i.isAssetPastPlayoutLimit(a)){if(this.schedule){var r,o=null==(r=this.schedule.items)?void 0:r[this.findItemIndex(e)+1];o&&this.bufferedToItem(o)}}else this.bufferedToEvent(e,a)}},{key:"advanceAfterAssetEnded",value:function(e,t,i){var n=AI(e,i);if(e.isAssetPastPlayoutLimit(n)){if(this.schedule){var a=this.schedule.items;if(a){var r=t+1;if(r>=a.length)return void this.setSchedulePosition(-1);var o=e.resumeTime;this.timelinePos<o&&(this.log(RI("advanceAfterAssetEnded",o)),this.timelinePos=o,e.appendInPlace&&this.advanceInPlace(o),this.checkBuffer(this.bufferedPos<o)),this.setSchedulePosition(r)}}}else{if(e.appendInPlace){var s=e.assetList[n];s&&this.advanceInPlace(s.timelineStart)}this.setSchedulePosition(t,n)}}},{key:"setScheduleToAssetAtTime",value:function(e,t){var i=this.schedule;if(i){var n=t.parentIdentifier,a=i.getEvent(n);if(a){var r=i.findEventIndex(n),o=i.findAssetIndex(a,e);this.advanceAfterAssetEnded(a,r,o-1)}}}},{key:"setSchedulePosition",value:function(e,t){var i,n=null==(i=this.schedule)?void 0:i.items;if(n&&!this.playbackDisabled){var a=e>=0?n[e]:null;this.log(`setSchedulePosition ${e}, ${t} (${a?II(a):a}) pos: ${this.timelinePos}`);var r=this.waitingItem||this.playingItem,o=this.playingLastItem;if(this.isInterstitial(r)){var s=r.event,u=this.playingAsset,l=null==u?void 0:u.identifier,d=l?this.getAssetPlayer(l):null;if(d&&l&&(!this.eventItemsMatch(r,a)||void 0!==t&&l!==s.assetList[t].identifier)){var h,c=s.findAssetIndex(u);if(this.log(`INTERSTITIAL_ASSET_ENDED ${c+1}/${s.assetList.length} ${DI(u)}`),this.endedAsset=u,this.playingAsset=null,this.hls.trigger(zE.INTERSTITIAL_ASSET_ENDED,{asset:u,assetListIndex:c,event:s,schedule:n.slice(0),scheduleIndex:e,player:d}),r!==this.playingItem)return void(this.itemsMatch(r,this.playingItem)&&!this.playingAsset&&this.advanceAfterAssetEnded(s,this.findItemIndex(this.playingItem),c));this.retreiveMediaSource(l,a),!d.media||null!=(h=this.detachedData)&&h.mediaSource||d.detachMedia()}if(!this.eventItemsMatch(r,a)&&(this.endedItem=r,this.playingItem=null,this.log(`INTERSTITIAL_ENDED ${s} ${II(r)}`),s.hasPlayed=!0,this.hls.trigger(zE.INTERSTITIAL_ENDED,{event:s,schedule:n.slice(0),scheduleIndex:e}),s.cue.once)){var m;this.updateSchedule();var f=null==(m=this.schedule)?void 0:m.items;if(a&&f){var v=this.findItemIndex(a);this.advanceSchedule(v,f,t,r,o)}return}}this.advanceSchedule(e,n,t,r,o)}}},{key:"advanceSchedule",value:function(e,t,i,n,a){var r=this.schedule;if(r){var o=t[e]||null,s=this.primaryMedia,u=this.playerQueue;if(u.length&&u.forEach(t=>{var i=t.interstitial,n=r.findEventIndex(i.identifier);(n<e||n>e+1)&&this.clearInterstitial(i,o)}),this.isInterstitial(o)){this.timelinePos=Math.min(Math.max(this.timelinePos,o.start),o.end);var l=o.event;if(void 0===i){var d=AI(l,(i=r.findAssetIndex(l,this.timelinePos))-1);if(l.isAssetPastPlayoutLimit(d)||l.appendInPlace&&this.timelinePos===o.end)return void this.advanceAfterAssetEnded(l,e,i);i=d}var h=this.waitingItem;this.assetsBuffered(o,s)||this.setBufferingItem(o);var c=this.preloadAssets(l,i);if(this.eventItemsMatch(o,h||n)||(this.waitingItem=o,this.log(`INTERSTITIAL_STARTED ${II(o)} ${l.appendInPlace?"append in place":""}`),this.hls.trigger(zE.INTERSTITIAL_STARTED,{event:l,schedule:t.slice(0),scheduleIndex:e})),!l.assetListLoaded)return void this.log(`Waiting for ASSET-LIST to complete loading ${l}`);if(l.assetListLoader&&(l.assetListLoader.destroy(),l.assetListLoader=void 0),!s)return void this.log(`Waiting for attachMedia to start Interstitial ${l}`);this.waitingItem=this.endedItem=null,this.playingItem=o;var m=l.assetList[i];if(!m)return void this.advanceAfterAssetEnded(l,e,i||0);if(c||(c=this.getAssetPlayer(m.identifier)),null===c||c.destroyed){var f=l.assetList.length;this.warn(`asset ${i+1}/${f} player destroyed ${l}`),(c=this.createAssetPlayer(l,m,i)).loadSource()}if(!this.eventItemsMatch(o,this.bufferingItem)&&l.appendInPlace&&this.isAssetBuffered(m))return;this.startAssetPlayer(c,i,t,e,s),this.shouldPlay&&_I(c.media)}else o?(this.resumePrimary(o,e,n),this.shouldPlay&&_I(this.hls.media)):a&&this.isInterstitial(n)&&(this.endedItem=null,this.playingItem=n,n.event.appendInPlace||this.attachPrimary(r.durations.primary,null))}}},{key:"playbackDisabled",get:function(){return!1===this.hls.config.enableInterstitialPlayback}},{key:"primaryDetails",get:function(){var e;return null==(e=this.mediaSelection)?void 0:e.main.details}},{key:"primaryLive",get:function(){var e;return!(null==(e=this.primaryDetails)||!e.live)}},{key:"resumePrimary",value:function(e,t,i){var n,a;if(this.playingItem=e,this.playingAsset=this.endedAsset=null,this.waitingItem=this.endedItem=null,this.bufferedToItem(e),this.log(`resuming ${II(e)}`),null==(n=this.detachedData)||!n.mediaSource){var r=this.timelinePos;(r<e.start||r>=e.end)&&(r=this.getPrimaryResumption(e,t),this.log(RI("resumePrimary",r)),this.timelinePos=r),this.attachPrimary(r,e)}if(i){var o=null==(a=this.schedule)?void 0:a.items;o&&(this.log(`INTERSTITIALS_PRIMARY_RESUMED ${II(e)}`),this.hls.trigger(zE.INTERSTITIALS_PRIMARY_RESUMED,{schedule:o.slice(0),scheduleIndex:t}),this.checkBuffer())}}},{key:"getPrimaryResumption",value:function(e,t){var i=e.start;if(this.primaryLive){var n=this.primaryDetails;if(0===t)return this.hls.startPosition;if(n&&(i<n.fragmentStart||i>n.edge))return this.hls.liveSyncPosition||-1}return i}},{key:"isAssetBuffered",value:function(e){var t=this.getAssetPlayer(e.identifier);return null!=t&&t.hls?t.hls.bufferedToEnd:WM.bufferInfo(this.primaryMedia,this.timelinePos,0).end+1>=e.timelineStart+(e.duration||0)}},{key:"attachPrimary",value:function(e,t,i){t?this.setBufferingItem(t):this.bufferingItem=this.playingItem,this.bufferingAsset=null;var n=this.primaryMedia;if(n){var a=this.hls;a.media?this.checkBuffer():(this.transferMediaTo(a,n),i&&this.startLoadingPrimaryAt(e,i)),i||(this.log(RI("attachPrimary",e)),this.timelinePos=e,this.startLoadingPrimaryAt(e,i))}}},{key:"startLoadingPrimaryAt",value:function(e,t){var i,n=this.hls;!n.loadingEnabled||!n.media||Math.abs(((null==(i=n.mainForwardBufferInfo)?void 0:i.start)||n.media.currentTime)-e)>.5?n.startLoad(e,t):n.bufferingEnabled||n.resumeBuffering()}},{key:"onManifestLoading",value:function(){var e;this.stopLoad(),null==(e=this.schedule)||e.reset(),this.emptyPlayerQueue(),this.clearScheduleState(),this.shouldPlay=!1,this.bufferedPos=this.timelinePos=-1,this.mediaSelection=this.altSelection=this.manager=this.requiredTracks=null,this.hls.off(zE.BUFFER_CODECS,this.onBufferCodecs,this),this.hls.on(zE.BUFFER_CODECS,this.onBufferCodecs,this)}},{key:"onLevelUpdated",value:function(e,t){if(-1!==t.level&&this.schedule){var i=this.hls.levels[t.level];if(i.details){var n=tT(tT({},this.mediaSelection||this.altSelection),{},{main:i});this.mediaSelection=n,this.schedule.parseInterstitialDateRanges(n,this.hls.config.interstitialAppendInPlace),!this.effectivePlayingItem&&this.schedule.items&&this.checkStart()}}}},{key:"onAudioTrackUpdated",value:function(e,t){var i=this.hls.audioTracks[t.id],n=this.mediaSelection;if(n){var a=tT(tT({},n),{},{audio:i});this.mediaSelection=a}else this.altSelection=tT(tT({},this.altSelection),{},{audio:i})}},{key:"onSubtitleTrackUpdated",value:function(e,t){var i=this.hls.subtitleTracks[t.id],n=this.mediaSelection;if(n){var a=tT(tT({},n),{},{subtitles:i});this.mediaSelection=a}else this.altSelection=tT(tT({},this.altSelection),{},{subtitles:i})}},{key:"onAudioTrackSwitching",value:function(e,t){var i=NP(t);this.playerQueue.forEach(({hls:e})=>e&&(e.setAudioOption(t)||e.setAudioOption(i)))}},{key:"onSubtitleTrackSwitch",value:function(e,t){var i=NP(t);this.playerQueue.forEach(({hls:e})=>e&&(e.setSubtitleOption(t)||-1!==t.id&&e.setSubtitleOption(i)))}},{key:"onBufferCodecs",value:function(e,t){var i=t.tracks;i&&(this.requiredTracks=i)}},{key:"onBufferAppended",value:function(e,t){this.checkBuffer()}},{key:"onBufferFlushed",value:function(e,t){var i=this.playingItem;if(i&&!this.itemsMatch(i,this.bufferingItem)&&!this.isInterstitial(i)){var n=this.timelinePos;this.bufferedPos=n,this.checkBuffer()}}},{key:"onBufferedToEnd",value:function(e){if(this.schedule){var t=this.schedule.events;if(this.bufferedPos<Number.MAX_VALUE&&t){for(var i=0;i<t.length;i++){var n=t[i];if(n.cue.post){var a,r=this.schedule.findEventIndex(n.identifier),o=null==(a=this.schedule.items)?void 0:a[r];this.isInterstitial(o)&&this.eventItemsMatch(o,this.bufferingItem)&&this.bufferedToItem(o,0);break}}this.bufferedPos=Number.MAX_VALUE}}}},{key:"onMediaEnded",value:function(e){var t=this.playingItem;if(!this.playingLastItem&&t){var i=this.findItemIndex(t);this.setSchedulePosition(i+1)}else this.shouldPlay=!1}},{key:"updateItem",value:function(e,t){var i,n=null==(i=this.schedule)?void 0:i.items;return e&&n&&n[this.findItemIndex(e,t)]||null}},{key:"trimInPlace",value:function(e,t){if(this.isInterstitial(e)&&e.event.appendInPlace&&t.end-e.end>.25){e.event.assetList.forEach((t,i)=>{e.event.isAssetPastPlayoutLimit(i)&&this.clearAssetPlayer(t.identifier,null)});var i=e.end+.25,n=WM.bufferInfo(this.primaryMedia,i,0);if(n.end>i||(n.nextStart||0)>i){this.log(`trim buffered interstitial ${II(e)} (was ${II(t)})`);this.attachPrimary(i,null,!0),this.flushFrontBuffer(i)}}}},{key:"itemsMatch",value:function(e,t){return!!t&&(e===t||e.event&&t.event&&this.eventItemsMatch(e,t)||!e.event&&!t.event&&this.findItemIndex(e)===this.findItemIndex(t))}},{key:"eventItemsMatch",value:function(e,t){var i;return!!t&&(e===t||e.event.identifier===(null==(i=t.event)?void 0:i.identifier))}},{key:"findItemIndex",value:function(e,t){return e&&this.schedule?this.schedule.findItemIndex(e,t):-1}},{key:"updateSchedule",value:function(e=!1){var t,i=this.mediaSelection;i&&(null==(t=this.schedule)||t.updateSchedule(i,[],e))}},{key:"checkBuffer",value:function(e){var t,i=null==(t=this.schedule)?void 0:t.items;if(i){var n=WM.bufferInfo(this.primaryMedia,this.timelinePos,0);e&&(this.bufferedPos=this.timelinePos),e||(e=n.len<1),this.updateBufferedPos(n.end,i,e)}}},{key:"updateBufferedPos",value:function(e,t,i){var n=this.schedule,a=this.bufferingItem;if(!(this.bufferedPos>e)&&n)if(1===t.length&&this.itemsMatch(t[0],a))this.bufferedPos=e;else{var r=this.playingItem,o=this.findItemIndex(r),s=n.findItemIndexAtTime(e);if(this.bufferedPos<e){var u,l=this.findItemIndex(a),d=Math.min(l+1,t.length-1),h=t[d];if((-1===s&&a&&e>=a.end||null!=(u=h.event)&&u.appendInPlace&&e+.01>=h.start)&&(s=d),this.isInterstitial(a)){var c=a.event;if(d-o>1&&!1===c.appendInPlace)return;if(0===c.assetList.length&&c.assetListLoader)return}if(this.bufferedPos=e,s>l&&s>o)this.bufferedToItem(h);else{var m=this.primaryDetails;this.primaryLive&&m&&e>m.edge-m.targetduration&&h.start<m.edge+this.hls.config.interstitialLiveLookAhead&&this.isInterstitial(h)&&this.preloadAssets(h.event,0)}}else i&&r&&!this.itemsMatch(r,a)&&(s===o?this.bufferedToItem(r):s===o+1&&this.bufferedToItem(t[s]))}}},{key:"assetsBuffered",value:function(e,t){return 0!==e.event.assetList.length&&!e.event.assetList.some(e=>{var i=this.getAssetPlayer(e.identifier);return!(null!=i&&i.bufferedInPlaceToEnd(t))})}},{key:"setBufferingItem",value:function(e){var t=this.bufferingItem,i=this.schedule;if(!this.itemsMatch(e,t)&&i){var n=i.items,a=i.events;if(!n||!a)return t;var r=this.isInterstitial(e),o=this.getBufferingPlayer();this.bufferingItem=e,this.bufferedPos=Math.max(e.start,Math.min(e.end,this.timelinePos));var s=o?o.remaining:t?t.end-this.timelinePos:0;if(this.log(`INTERSTITIALS_BUFFERED_TO_BOUNDARY ${II(e)}`+(t?` (${s.toFixed(2)} remaining)`:"")),!this.playbackDisabled)if(r){var u=i.findAssetIndex(e.event,this.bufferedPos);e.event.assetList.forEach((e,t)=>{var i=this.getAssetPlayer(e.identifier);i&&(t===u&&i.loadSource(),i.resumeBuffering())})}else this.hls.resumeBuffering(),this.playerQueue.forEach(e=>e.pauseBuffering());this.hls.trigger(zE.INTERSTITIALS_BUFFERED_TO_BOUNDARY,{events:a.slice(0),schedule:n.slice(0),bufferingIndex:this.findItemIndex(e),playingIndex:this.findItemIndex(this.playingItem)})}else this.bufferingItem!==e&&(this.bufferingItem=e);return t}},{key:"bufferedToItem",value:function(e,t=0){var i=this.setBufferingItem(e);if(!this.playbackDisabled)if(this.isInterstitial(e))this.bufferedToEvent(e,t);else if(null!==i){this.bufferingAsset=null;var n=this.detachedData;if(n)if(n.mediaSource){this.attachPrimary(e.start,e,!0)}else this.preloadPrimary(e);else this.preloadPrimary(e)}}},{key:"preloadPrimary",value:function(e){var t=this.findItemIndex(e),i=this.getPrimaryResumption(e,t);this.startLoadingPrimaryAt(i)}},{key:"bufferedToEvent",value:function(e,t){var i=e.event,n=0===i.assetList.length&&!i.assetListLoader,a=i.cue.once;if(n||!a){var r=this.preloadAssets(i,t);if(null!=r&&r.interstitial.appendInPlace){var o=this.primaryMedia;o&&this.bufferAssetPlayer(r,o)}}}},{key:"preloadAssets",value:function(e,t){var i=e.assetUrl,n=e.assetList.length,a=0===n&&!e.assetListLoader,r=e.cue.once;if(a){var o,s=e.timelineStart;if(e.appendInPlace){var u,l=this.playingItem;this.isInterstitial(l)||(null==l||null==(u=l.nextEvent)?void 0:u.identifier)!==e.identifier||this.flushFrontBuffer(s+.25)}var d=0;if(!this.playingItem&&this.primaryLive&&-1===(d=this.hls.startPosition)&&(d=this.hls.liveSyncPosition||0),d&&!e.cue.pre&&!e.cue.post){var h=d-s;h>0&&(o=Math.round(1e3*h)/1e3)}if(this.log(`Load interstitial asset ${t+1}/${i?1:n} ${e}${o?` live-start: ${d} start-offset: ${o}`:""}`),i)return this.createAsset(e,0,0,s,e.duration,i);var c=this.assetListLoader.loadAssetList(e,o);c&&(e.assetListLoader=c)}else if(!r&&n){for(var m=t;m<n;m++){var f=e.assetList[m],v=this.getAssetPlayerQueueIndex(f.identifier);-1!==v&&!this.playerQueue[v].destroyed||f.error||this.createAssetPlayer(e,f,m)}var p=e.assetList[t];if(p){var g=this.getAssetPlayer(p.identifier);return g&&g.loadSource(),g}}return null}},{key:"flushFrontBuffer",value:function(e){var t=this.requiredTracks;t&&(this.log(`Removing front buffer starting at ${e}`),Object.keys(t).forEach(t=>{this.hls.trigger(zE.BUFFER_FLUSHING,{startOffset:e,endOffset:1/0,type:t})}))}},{key:"getAssetPlayerQueueIndex",value:function(e){for(var t=this.playerQueue,i=0;i<t.length;i++)if(e===t[i].assetId)return i;return-1}},{key:"getAssetPlayer",value:function(e){var t=this.getAssetPlayerQueueIndex(e);return this.playerQueue[t]||null}},{key:"getBufferingPlayer",value:function(){var e=this.playerQueue,t=this.primaryMedia;if(t)for(var i=0;i<e.length;i++)if(e[i].media===t)return e[i];return null}},{key:"createAsset",value:function(e,t,i,n,a,r){var o={parentIdentifier:e.identifier,identifier:EI(e,r,t),duration:a,startOffset:i,timelineStart:n,uri:r};return this.createAssetPlayer(e,o,t)}},{key:"createAssetPlayer",value:function(e,t,i){var n=this.hls,a=n.userConfig,r=a.videoPreference,o=n.loadLevelObj||n.levels[n.currentLevel];(r||o)&&(r=ZE({},r),o.videoCodec&&(r.videoCodec=o.videoCodec),o.videoRange&&(r.allowedVideoRanges=[o.videoRange]));var s=n.audioTracks[n.audioTrack],u=n.subtitleTracks[n.subtitleTrack],l=0;if(this.primaryLive||e.appendInPlace){var d=this.timelinePos-t.timelineStart;if(d>1){var h=t.duration;h&&d<h&&(l=d)}}var c=t.identifier,m=tT(tT({},a),{},{maxMaxBufferLength:Math.min(180,n.config.maxMaxBufferLength),autoStartLoad:!0,startFragPrefetch:!0,primarySessionId:n.sessionId,assetPlayerId:c,abrEwmaDefaultEstimate:n.bandwidthEstimate,interstitialsController:void 0,startPosition:l,liveDurationInfinity:!1,testBandwidth:!1,videoPreference:r,audioPreference:s||a.audioPreference,subtitlePreference:u||a.subtitlePreference});e.appendInPlace&&(e.appendInPlaceStarted=!0,t.timelineStart&&(m.timelineOffset=t.timelineStart));var f=m.cmcd;null!=f&&f.sessionId&&f.contentId&&(m.cmcd=ZE({},f,{contentId:wI(t.uri)})),this.getAssetPlayer(c)&&this.warn(`Duplicate date range identifier ${e} and asset ${c}`);var v=new xI(this.HlsPlayerClass,m,e,t);this.playerQueue.push(v),e.assetList[i]=t;var p=!0,g=n=>{if(n.live){var a,r=new Error(`Interstitials MUST be VOD assets ${e}`),o={fatal:!0,type:jE.OTHER_ERROR,details:BE.INTERSTITIAL_ASSET_ITEM_ERROR,error:r},s=(null==(a=this.schedule)?void 0:a.findEventIndex(e.identifier))||-1;this.handleAssetItemError(o,e,s,i,r.message)}else{var u=n.edge-n.fragmentStart,l=t.duration;(p||null===l||u>l)&&(p=!1,this.log(`Interstitial asset "${c}" duration change ${l} > ${u}`),t.duration=u,this.updateSchedule())}};v.on(zE.LEVEL_UPDATED,(e,{details:t})=>g(t)),v.on(zE.LEVEL_PTS_UPDATED,(e,{details:t})=>g(t)),v.on(zE.EVENT_CUE_ENTER,()=>this.onInterstitialCueEnter());var y=(e,t)=>{var i=this.getAssetPlayer(c);if(i&&t.tracks){i.off(zE.BUFFER_CODECS,y),i.tracks=t.tracks;var n=this.primaryMedia;this.bufferingAsset===i.assetItem&&n&&!i.media&&this.bufferAssetPlayer(i,n)}};v.on(zE.BUFFER_CODECS,y);v.on(zE.BUFFERED_TO_END,()=>{var i,n=this.getAssetPlayer(c);if(this.log(`buffered to end of asset ${n}`),n&&this.schedule){var a=this.schedule.findEventIndex(e.identifier),r=null==(i=this.schedule.items)?void 0:i[a];this.isInterstitial(r)&&this.advanceAssetBuffering(r,t)}});var b=t=>()=>{if(this.getAssetPlayer(c)&&this.schedule){this.shouldPlay=!0;var i=this.schedule.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,i,t)}};return v.once(zE.MEDIA_ENDED,b(i)),v.once(zE.PLAYOUT_LIMIT_REACHED,b(1/0)),v.on(zE.ERROR,(t,n)=>{if(this.schedule){var a=this.getAssetPlayer(c);if(n.details===BE.BUFFER_STALLED_ERROR)return null!=a&&a.appendInPlace?void this.handleInPlaceStall(e):(this.onTimeupdate(),void this.checkBuffer(!0));this.handleAssetItemError(n,e,this.schedule.findEventIndex(e.identifier),i,`Asset player error ${n.error} ${e}`)}}),v.on(zE.DESTROYING,()=>{if(this.getAssetPlayer(c)&&this.schedule){var t=new Error(`Asset player destroyed unexpectedly ${c}`),n={fatal:!0,type:jE.OTHER_ERROR,details:BE.INTERSTITIAL_ASSET_ITEM_ERROR,error:t};this.handleAssetItemError(n,e,this.schedule.findEventIndex(e.identifier),i,t.message)}}),this.log(`INTERSTITIAL_ASSET_PLAYER_CREATED ${DI(t)}`),this.hls.trigger(zE.INTERSTITIAL_ASSET_PLAYER_CREATED,{asset:t,assetListIndex:i,event:e,player:v}),v}},{key:"clearInterstitial",value:function(e,t){this.clearAssetPlayers(e,t),e.reset()}},{key:"clearAssetPlayers",value:function(e,t){e.assetList.forEach(e=>{this.clearAssetPlayer(e.identifier,t)})}},{key:"resetAssetPlayer",value:function(e){var t=this.getAssetPlayerQueueIndex(e);if(-1!==t){this.log(`reset asset player "${e}" after error`);var i=this.playerQueue[t];this.transferMediaFromPlayer(i,null),i.resetDetails()}}},{key:"clearAssetPlayer",value:function(e,t){var i=this.getAssetPlayerQueueIndex(e);if(-1!==i){var n=this.playerQueue[i];this.log(`clear ${n} toSegment: ${t?II(t):t}`),this.transferMediaFromPlayer(n,t),this.playerQueue.splice(i,1),n.destroy()}}},{key:"emptyPlayerQueue",value:function(){for(var e;e=this.playerQueue.pop();)e.destroy();this.playerQueue=[]}},{key:"startAssetPlayer",value:function(e,t,i,n,a){var r=e.interstitial,o=e.assetItem,s=e.assetId,u=r.assetList.length,l=this.playingAsset;this.endedAsset=null,this.playingAsset=o,l&&l.identifier===s||(l&&(this.clearAssetPlayer(l.identifier,i[n]),delete l.error),this.log(`INTERSTITIAL_ASSET_STARTED ${t+1}/${u} ${DI(o)}`),this.hls.trigger(zE.INTERSTITIAL_ASSET_STARTED,{asset:o,assetListIndex:t,event:r,schedule:i.slice(0),scheduleIndex:n,player:e})),this.bufferAssetPlayer(e,a)}},{key:"bufferAssetPlayer",value:function(e,t){var i,n;if(this.schedule){var a=e.interstitial,r=e.assetItem,o=this.schedule.findEventIndex(a.identifier),s=null==(i=this.schedule.items)?void 0:i[o];if(s){e.loadSource(),this.setBufferingItem(s),this.bufferingAsset=r;var u=this.getBufferingPlayer();if(u!==e){var l=a.appendInPlace;if(!l||!1!==(null==u?void 0:u.interstitial.appendInPlace)){var d=(null==u?void 0:u.tracks)||(null==(n=this.detachedData)?void 0:n.tracks)||this.requiredTracks;if(l&&r!==this.playingAsset){if(!e.tracks)return void this.log(`Waiting for track info before buffering ${e}`);if(d&&!dT(d,e.tracks)){var h=new Error(`Asset ${DI(r)} SourceBuffer tracks ('${Object.keys(e.tracks)}') are not compatible with primary content tracks ('${Object.keys(d)}')`),c={fatal:!0,type:jE.OTHER_ERROR,details:BE.INTERSTITIAL_ASSET_ITEM_ERROR,error:h},m=a.findAssetIndex(r);return void this.handleAssetItemError(c,a,o,m,h.message)}}this.transferMediaTo(e,t)}}}}}},{key:"handleInPlaceStall",value:function(e){var t=this.schedule,i=this.primaryMedia;if(t&&i){var n=i.currentTime,a=t.findAssetIndex(e,n),r=e.assetList[a];if(r){var o=this.getAssetPlayer(r.identifier);if(o){var s=o.currentTime||n-r.timelineStart,u=o.duration-s;if(this.warn(`Stalled at ${s} of ${s+u} in ${o} ${e} (media.currentTime: ${n})`),s&&(u/i.playbackRate<.5||o.bufferedInPlaceToEnd(i))&&o.hls){var l=t.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,l,a)}}}}}},{key:"advanceInPlace",value:function(e){var t=this.primaryMedia;t&&t.currentTime<e&&(t.currentTime=e)}},{key:"handleAssetItemError",value:function(e,t,i,n,a){if(e.details!==BE.BUFFER_STALLED_ERROR){var r=t.assetList[n]||null;if(this.warn(`INTERSTITIAL_ASSET_ERROR ${r?DI(r):r} ${e.error}`),this.schedule){var o=(null==r?void 0:r.identifier)||"",s=this.getAssetPlayerQueueIndex(o),u=this.playerQueue[s]||null,l=this.schedule.items,d=ZE({},e,{fatal:!1,errorAction:fM(!0),asset:r,assetListIndex:n,event:t,schedule:l,scheduleIndex:i,player:u});if(this.hls.trigger(zE.INTERSTITIAL_ASSET_ERROR,d),e.fatal){var h=this.playingAsset,c=this.bufferingAsset,m=new Error(a);if(r&&(this.clearAssetPlayer(o,null),r.error=m),t.assetList.some(e=>!e.error))for(var f=n;f<t.assetList.length;f++)this.resetAssetPlayer(t.assetList[f].identifier);else t.error=m;this.updateSchedule(!0),t.error?this.primaryFallback(t):h&&h.identifier===o?this.advanceAfterAssetEnded(t,i,n):c&&c.identifier===o&&this.isInterstitial(this.bufferingItem)&&this.advanceAssetBuffering(this.bufferingItem,c)}}}}},{key:"primaryFallback",value:function(e){var t=e.timelineStart,i=this.effectivePlayingItem,n=this.timelinePos;if(i){this.log(`Fallback to primary from event "${e.identifier}" start: ${t} pos: ${n} playing: ${II(i)} error: ${e.error}`),-1===n&&(n=this.hls.startPosition);var a=this.updateItem(i,n);this.itemsMatch(i,a)&&this.clearInterstitial(e,null),e.appendInPlace&&(this.attachPrimary(t,null),this.flushFrontBuffer(t))}else if(-1===n)return void this.checkStart();if(this.schedule){var r=this.schedule.findItemIndexAtTime(n);this.setSchedulePosition(r)}}},{key:"onAssetListLoaded",value:function(e,t){var i,n,a=t.event,r=a.identifier,o=t.assetListResponse.ASSETS;if(null!=(i=this.schedule)&&i.hasEvent(r)){var s=a.timelineStart,u=a.duration,l=0;o.forEach((e,t)=>{var i=parseFloat(e.DURATION);this.createAsset(a,t,l,s+l,i,e.URI),l+=i}),a.duration=l,this.log(`Loaded asset-list with duration: ${l} (was: ${u}) ${a}`);var d=this.waitingItem,h=(null==d?void 0:d.event.identifier)===r;this.updateSchedule();var c=null==(n=this.bufferingItem)?void 0:n.event;if(h){var m,f=this.schedule.findEventIndex(r),v=null==(m=this.schedule.items)?void 0:m[f];if(v){if(!this.playingItem&&this.timelinePos>v.end)if(this.schedule.findItemIndexAtTime(this.timelinePos)!==f)return a.error=new Error(`Interstitial ${o.length?"no longer within playback range":"asset-list is empty"} ${this.timelinePos} ${a}`),this.log(a.error.message),this.updateSchedule(!0),void this.primaryFallback(a);this.setBufferingItem(v)}this.setSchedulePosition(f)}else if((null==c?void 0:c.identifier)===r){var p=a.assetList[0];if(p){var g=this.getAssetPlayer(p.identifier);if(c.appendInPlace){var y=this.primaryMedia;g&&y&&this.bufferAssetPlayer(g,y)}else g&&g.loadSource()}}}}},{key:"onError",value:function(e,t){if(this.schedule)switch(t.details){case BE.ASSET_LIST_PARSING_ERROR:case BE.ASSET_LIST_LOAD_ERROR:case BE.ASSET_LIST_LOAD_TIMEOUT:var i=t.interstitial;i&&(this.updateSchedule(!0),this.primaryFallback(i));break;case BE.BUFFER_STALLED_ERROR:var n=this.endedItem||this.waitingItem||this.playingItem;if(this.isInterstitial(n)&&n.event.appendInPlace)return void this.handleInPlaceStall(n.event);this.log(`Primary player stall @${this.timelinePos} bufferedPos: ${this.bufferedPos}`),this.onTimeupdate(),this.checkBuffer(!0)}}}])}(),OI=function(){function e(t,i,n){var a;return u(this,e),(a=s(this,e,[t,i,n,"subtitle-stream-controller",YE])).currentTrackId=-1,a.tracksBuffered=[],a.mainDetails=null,a.registerListeners(),a}return y(e,vD),m(e,[{key:"onHandlerDestroying",value:function(){this.unregisterListeners(),M(e,"onHandlerDestroying",this)([]),this.mainDetails=null}},{key:"registerListeners",value:function(){M(e,"registerListeners",this)([]);var t=this.hls;t.on(zE.LEVEL_LOADED,this.onLevelLoaded,this),t.on(zE.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(zE.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.on(zE.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(zE.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.on(zE.BUFFER_FLUSHING,this.onBufferFlushing,this)}},{key:"unregisterListeners",value:function(){M(e,"unregisterListeners",this)([]);var t=this.hls;t.off(zE.LEVEL_LOADED,this.onLevelLoaded,this),t.off(zE.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(zE.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.off(zE.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(zE.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.off(zE.BUFFER_FLUSHING,this.onBufferFlushing,this)}},{key:"startLoad",value:function(e,t){this.stopLoad(),this.state=aD,this.setInterval(500),this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}},{key:"onManifestLoading",value:function(){M(e,"onManifestLoading",this)([]),this.mainDetails=null}},{key:"onMediaDetaching",value:function(t,i){this.tracksBuffered=[],M(e,"onMediaDetaching",this)([t,i])}},{key:"onLevelLoaded",value:function(e,t){this.mainDetails=t.details}},{key:"onSubtitleFragProcessed",value:function(e,t){var i=t.frag,n=t.success;if(this.fragContextChanged(i)||(DT(i)&&(this.fragPrevious=i),this.state=aD),n){var a=this.tracksBuffered[this.currentTrackId];if(a){for(var r,o=i.start,s=0;s<a.length;s++)if(o>=a[s].start&&o<=a[s].end){r=a[s];break}var u=i.start+i.duration;r?r.end=u:(r={start:o,end:u},a.push(r)),this.fragmentTracker.fragBuffered(i),this.fragBufferedComplete(i,null),this.media&&this.tick()}}}},{key:"onBufferFlushing",value:function(e,t){var i=t.startOffset,n=t.endOffset;if(0===i&&n!==Number.POSITIVE_INFINITY){var a=n-1;if(a<=0)return;t.endOffsetSubtitles=Math.max(0,a),this.tracksBuffered.forEach(e=>{for(var t=0;t<e.length;)if(e[t].end<=a)e.shift();else{if(!(e[t].start<a))break;e[t].start=a,t++}}),this.fragmentTracker.removeFragmentsInRange(i,a,YE)}}},{key:"onError",value:function(e,t){var i=t.frag;(null==i?void 0:i.type)===YE&&(t.details===BE.FRAG_GAP&&this.fragmentTracker.fragBuffered(i,!0),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==nD&&(this.state=aD))}},{key:"onSubtitleTracksUpdated",value:function(e,{subtitleTracks:t}){this.levels&&Zx(this.levels,t)?this.levels=t.map(e=>new _P(e)):(this.tracksBuffered=[],this.levels=t.map(e=>{var t=new _P(e);return this.tracksBuffered[t.id]=[],t}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,YE),this.fragPrevious=null,this.mediaBuffer=null)}},{key:"onSubtitleTrackSwitch",value:function(e,t){var i;if(this.currentTrackId=t.id,null!=(i=this.levels)&&i.length&&-1!==this.currentTrackId){var n=this.levels[this.currentTrackId];null!=n&&n.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,n&&this.state!==nD&&this.setInterval(500)}else this.clearInterval()}},{key:"onSubtitleTrackLoaded",value:function(e,t){var i,n=this.currentTrackId,a=this.levels,r=t.details,o=t.id;if(a){var s=a[o];if(!(o>=a.length)&&s){this.log(`Subtitle track ${o} loaded [${r.startSN},${r.endSN}]${r.lastPartSn?`[part-${r.lastPartSn}-${r.lastPartIndex}]`:""},duration:${r.totalduration}`),this.mediaBuffer=this.mediaBufferTimeRanges;var u=0;if(r.live||null!=(i=s.details)&&i.live){if(r.deltaUpdateFailed)return;var l=this.mainDetails;if(!l)return void(this.startFragRequested=!1);var d,h=l.fragments[0];if(s.details)0===(u=this.alignPlaylists(r,s.details,null==(d=this.levelLastLoaded)?void 0:d.details))&&h&&BA(r,u=h.start);else r.hasProgramDateTime&&l.hasProgramDateTime?(ZA(r,l),u=r.fragmentStart):h&&BA(r,u=h.start);l&&!this.startFragRequested&&this.setStartPosition(l,u)}if(s.details=r,this.levelLastLoaded=s,o===n)if(this.hls.trigger(zE.SUBTITLE_TRACK_UPDATED,{details:r,id:o,groupId:t.groupId}),this.tick(),r.live&&!this.fragCurrent&&this.media&&this.state===aD)KP(null,r.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),s.details=void 0)}}else this.warn(`Subtitle tracks were reset while loading level ${o}`)}},{key:"_handleFragmentLoadComplete",value:function(e){var t=e.frag,i=e.payload,n=t.decryptdata,a=this.hls;if(!this.fragContextChanged(t)&&i&&i.byteLength>0&&null!=n&&n.key&&n.iv&&QM(n.method)){var r=performance.now();this.decrypter.decrypt(new Uint8Array(i),n.key.buffer,n.iv.buffer,ZM(n.method)).catch(e=>{throw a.trigger(zE.ERROR,{type:jE.MEDIA_ERROR,details:BE.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:t}),e}).then(e=>{var i=performance.now();a.trigger(zE.FRAG_DECRYPTED,{frag:t,payload:e,stats:{tstart:r,tdecrypt:i}})}).catch(e=>{this.warn(`${e.name}: ${e.message}`),this.state=aD})}}},{key:"doTick",value:function(){if(this.media){if(this.state===aD){var e=this.currentTrackId,t=this.levels,i=null==t?void 0:t[e];if(!i||!t.length||!i.details)return;if(this.waitForLive(i))return;var n=this.config,a=this.getLoadPosition(),r=WM.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],a,n.maxBufferHole),o=r.end,s=r.len,u=i.details;if(s>this.hls.maxBufferLength+u.levelTargetDuration)return;var l=u.fragments,d=l.length,h=u.edge,c=null,m=this.fragPrevious;if(o<h){var f=n.maxFragLookUpTolerance,v=o>h-f?0:f;!(c=KP(m,l,Math.max(l[0].start,o),v))&&m&&m.start<l[0].start&&(c=l[0])}else c=l[d-1];if(!(c=this.filterReplacedPrimary(c,i.details)))return;var p=l[c.sn-u.startSN-1];if(p&&p.cc===c.cc&&this.fragmentTracker.getState(p)===vM&&(c=p),this.fragmentTracker.getState(c)===vM){var g=this.mapToInitFragWhenRequired(c);g&&this.loadFragment(g,i,o)}}}else this.state=aD}},{key:"loadFragment",value:function(t,i,n){DT(t)?M(e,"loadFragment",this)([t,i,n]):this._loadInitSegment(t,i)}},{key:"mediaBufferTimeRanges",get:function(){return new WI(this.tracksBuffered[this.currentTrackId]||[])}}])}(),WI=m(function e(t){u(this,e),this.buffered=void 0;var i=(e,i,n)=>{if((i>>>=0)>n-1)throw new DOMException(`Failed to execute '${e}' on 'TimeRanges': The index provided (${i}) is greater than the maximum bound (${n})`);return t[i][e]};this.buffered={get length(){return t.length},end:e=>i("end",e,t.length),start:e=>i("start",e,t.length)}}),$I={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},NI=e=>String.fromCharCode($I[e]||e),jI=15,BI=100,zI={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},UI={17:2,18:4,21:6,22:8,23:10,19:13,20:15},HI={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},GI={25:2,26:4,29:6,30:8,31:10,27:13,28:15},VI=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],KI=function(){return m(function e(){u(this,e),this.time=null,this.verboseLevel=0},[{key:"log",value:function(e,t){if(this.verboseLevel>=e){var i="function"==typeof t?t():t;uT.log(`${this.time} [${e}] ${i}`)}}}])}(),XI=function(e){for(var t=[],i=0;i<e.length;i++)t.push(e[i].toString(16));return t},YI=function(){return m(function e(){u(this,e),this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},[{key:"reset",value:function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}},{key:"setStyles",value:function(e){for(var t=["foreground","underline","italics","background","flash"],i=0;i<t.length;i++){var n=t[i];e.hasOwnProperty(n)&&(this[n]=e[n])}}},{key:"isDefault",value:function(){return"white"===this.foreground&&!this.underline&&!this.italics&&"black"===this.background&&!this.flash}},{key:"equals",value:function(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash}},{key:"copy",value:function(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash}},{key:"toString",value:function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}}])}(),qI=function(){return m(function e(){u(this,e),this.uchar=" ",this.penState=new YI},[{key:"reset",value:function(){this.uchar=" ",this.penState.reset()}},{key:"setChar",value:function(e,t){this.uchar=e,this.penState.copy(t)}},{key:"setPenState",value:function(e){this.penState.copy(e)}},{key:"equals",value:function(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)}},{key:"copy",value:function(e){this.uchar=e.uchar,this.penState.copy(e.penState)}},{key:"isEmpty",value:function(){return" "===this.uchar&&this.penState.isDefault()}}])}(),JI=function(){return m(function e(t){u(this,e),this.chars=[],this.pos=0,this.currPenState=new YI,this.cueStartTime=null,this.logger=void 0;for(var i=0;i<BI;i++)this.chars.push(new qI);this.logger=t},[{key:"equals",value:function(e){for(var t=0;t<BI;t++)if(!this.chars[t].equals(e.chars[t]))return!1;return!0}},{key:"copy",value:function(e){for(var t=0;t<BI;t++)this.chars[t].copy(e.chars[t])}},{key:"isEmpty",value:function(){for(var e=!0,t=0;t<BI;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e}},{key:"setCursor",value:function(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>BI&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=BI)}},{key:"moveCursor",value:function(e){var t=this.pos+e;if(e>1)for(var i=this.pos+1;i<t+1;i++)this.chars[i].setPenState(this.currPenState);this.setCursor(t)}},{key:"backSpace",value:function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}},{key:"insertChar",value:function(e){e>=144&&this.backSpace();var t=NI(e);this.pos>=BI?this.logger.log(0,()=>"Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!"):(this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1))}},{key:"clearFromPos",value:function(e){var t;for(t=e;t<BI;t++)this.chars[t].reset()}},{key:"clear",value:function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}},{key:"clearToEndOfRow",value:function(){this.clearFromPos(this.pos)}},{key:"getTextString",value:function(){for(var e=[],t=!0,i=0;i<BI;i++){var n=this.chars[i].uchar;" "!==n&&(t=!1),e.push(n)}return t?"":e.join("")}},{key:"setPenStyles",value:function(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)}}])}(),QI=function(){return m(function e(t){u(this,e),this.rows=[],this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(var i=0;i<jI;i++)this.rows.push(new JI(t));this.logger=t},[{key:"reset",value:function(){for(var e=0;e<jI;e++)this.rows[e].clear();this.currRow=14}},{key:"equals",value:function(e){for(var t=!0,i=0;i<jI;i++)if(!this.rows[i].equals(e.rows[i])){t=!1;break}return t}},{key:"copy",value:function(e){for(var t=0;t<jI;t++)this.rows[t].copy(e.rows[t])}},{key:"isEmpty",value:function(){for(var e=!0,t=0;t<jI;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e}},{key:"backSpace",value:function(){this.rows[this.currRow].backSpace()}},{key:"clearToEndOfRow",value:function(){this.rows[this.currRow].clearToEndOfRow()}},{key:"insertChar",value:function(e){this.rows[this.currRow].insertChar(e)}},{key:"setPen",value:function(e){this.rows[this.currRow].setPenStyles(e)}},{key:"moveCursor",value:function(e){this.rows[this.currRow].moveCursor(e)}},{key:"setCursor",value:function(e){this.logger.log(2,"setCursor: "+e),this.rows[this.currRow].setCursor(e)}},{key:"setPAC",value:function(e){this.logger.log(2,()=>"pacData = "+OP(e));var t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(var i=0;i<jI;i++)this.rows[i].clear();var n=this.currRow+1-this.nrRollUpRows,a=this.lastOutputScreen;if(a){var r=a.rows[n].cueStartTime,o=this.logger.time;if(null!==r&&null!==o&&r<o)for(var s=0;s<this.nrRollUpRows;s++)this.rows[t-this.nrRollUpRows+s+1].copy(a.rows[n+s])}}this.currRow=t;var u=this.rows[this.currRow];if(null!==e.indent){var l=e.indent,d=Math.max(l-1,0);u.setCursor(e.indent),e.color=u.chars[d].penState.foreground}var h={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(h)}},{key:"setBkgData",value:function(e){this.logger.log(2,()=>"bkgData = "+OP(e)),this.backSpace(),this.setPen(e),this.insertChar(32)}},{key:"setRollUpRows",value:function(e){this.nrRollUpRows=e}},{key:"rollUp",value:function(){if(null!==this.nrRollUpRows){this.logger.log(1,()=>this.getDisplayText());var e=this.currRow+1-this.nrRollUpRows,t=this.rows.splice(e,1)[0];t.clear(),this.rows.splice(this.currRow,0,t),this.logger.log(2,"Rolling up")}else this.logger.log(3,"roll_up but nrRollUpRows not set yet")}},{key:"getDisplayText",value:function(e){e=e||!1;for(var t=[],i="",n=-1,a=0;a<jI;a++){var r=this.rows[a].getTextString();r&&(n=a+1,e?t.push("Row "+n+": '"+r+"'"):t.push(r.trim()))}return t.length>0&&(i=e?"["+t.join(" | ")+"]":t.join("\n")),i}},{key:"getTextAndFormat",value:function(){return this.rows}}])}(),ZI=function(){return m(function e(t,i,n){u(this,e),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=i,this.mode=null,this.verbose=0,this.displayedMemory=new QI(n),this.nonDisplayedMemory=new QI(n),this.lastOutputScreen=new QI(n),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=n},[{key:"reset",value:function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}},{key:"getHandler",value:function(){return this.outputFilter}},{key:"setHandler",value:function(e){this.outputFilter=e}},{key:"setPAC",value:function(e){this.writeScreen.setPAC(e)}},{key:"setBkgData",value:function(e){this.writeScreen.setBkgData(e)}},{key:"setMode",value:function(e){e!==this.mode&&(this.mode=e,this.logger.log(2,()=>"MODE="+e),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)}},{key:"insertChars",value:function(e){for(var t=0;t<e.length;t++)this.writeScreen.insertChar(e[t]);var i=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,()=>i+": "+this.writeScreen.getDisplayText(!0)),"MODE_PAINT-ON"!==this.mode&&"MODE_ROLL-UP"!==this.mode||(this.logger.log(1,()=>"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())}},{key:"ccRCL",value:function(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}},{key:"ccBS",value:function(){this.logger.log(2,"BS - BackSpace"),"MODE_TEXT"!==this.mode&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}},{key:"ccAOF",value:function(){}},{key:"ccAON",value:function(){}},{key:"ccDER",value:function(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}},{key:"ccRU",value:function(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)}},{key:"ccFON",value:function(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}},{key:"ccRDC",value:function(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}},{key:"ccTR",value:function(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}},{key:"ccRTD",value:function(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}},{key:"ccEDM",value:function(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}},{key:"ccCR",value:function(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}},{key:"ccENM",value:function(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}},{key:"ccEOC",value:function(){if(this.logger.log(2,"EOC - End Of Caption"),"MODE_POP-ON"===this.mode){var e=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,()=>"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)}},{key:"ccTO",value:function(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)}},{key:"ccMIDROW",value:function(e){var t={flash:!1};if(t.underline=e%2==1,t.italics=e>=46,t.italics)t.foreground="white";else{var i=Math.floor(e/2)-16;t.foreground=["white","green","blue","cyan","red","yellow","magenta"][i]}this.logger.log(2,"MIDROW: "+OP(t)),this.writeScreen.setPen(t)}},{key:"outputDataUpdate",value:function(e=!1){var t=this.logger.time;null!==t&&this.outputFilter&&(null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t):this.cueStartTime=t,this.lastOutputScreen.copy(this.displayedMemory))}},{key:"cueSplitAtTime",value:function(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))}}])}(),eL=function(){return m(function e(t,i,n){u(this,e),this.channels=void 0,this.currentChannel=0,this.cmdHistory={a:null,b:null},this.logger=void 0;var a=this.logger=new KI;this.channels=[null,new ZI(t,i,a),new ZI(t+1,n,a)]},[{key:"getHandler",value:function(e){return this.channels[e].getHandler()}},{key:"setHandler",value:function(e,t){this.channels[e].setHandler(t)}},{key:"addData",value:function(e,t){var i=this;this.logger.time=e;for(var n=function(e){var n=127&t[e],a=127&t[e+1],r=!1,o=null;if(0===n&&0===a)return 0;i.logger.log(3,()=>"["+XI([t[e],t[e+1]])+"] -> ("+XI([n,a])+")");var s=i.cmdHistory;if(n>=16&&n<=31){if(function(e,t,i){return i.a===e&&i.b===t}(n,a,s))return tL(null,null,s),i.logger.log(3,()=>"Repeated command ("+XI([n,a])+") is dropped"),0;tL(n,a,i.cmdHistory),(r=i.parseCmd(n,a))||(r=i.parseMidrow(n,a)),r||(r=i.parsePAC(n,a)),r||(r=i.parseBackgroundAttributes(n,a))}else tL(null,null,s);if(!r&&(o=i.parseChars(n,a))){var u=i.currentChannel;if(u&&u>0)i.channels[u].insertChars(o);else i.logger.log(2,"No channel found yet. TEXT-MODE?")}r||o||i.logger.log(2,()=>"Couldn't parse cleaned data "+XI([n,a])+" orig: "+XI([t[e],t[e+1]]))},a=0;a<t.length;a+=2)n(a)}},{key:"parseCmd",value:function(e,t){if(!((20===e||28===e||21===e||29===e)&&t>=32&&t<=47)&&!((23===e||31===e)&&t>=33&&t<=35))return!1;var i=20===e||21===e||23===e?1:2,n=this.channels[i];return 20===e||21===e||28===e||29===e?32===t?n.ccRCL():33===t?n.ccBS():34===t?n.ccAOF():35===t?n.ccAON():36===t?n.ccDER():37===t?n.ccRU(2):38===t?n.ccRU(3):39===t?n.ccRU(4):40===t?n.ccFON():41===t?n.ccRDC():42===t?n.ccTR():43===t?n.ccRTD():44===t?n.ccEDM():45===t?n.ccCR():46===t?n.ccENM():47===t&&n.ccEOC():n.ccTO(t-32),this.currentChannel=i,!0}},{key:"parseMidrow",value:function(e,t){var i=0;if((17===e||25===e)&&t>=32&&t<=47){if((i=17===e?1:2)!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;var n=this.channels[i];return!!n&&(n.ccMIDROW(t),this.logger.log(3,()=>"MIDROW ("+XI([e,t])+")"),!0)}return!1}},{key:"parsePAC",value:function(e,t){var i;if(!((e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127)&&!((16===e||24===e)&&t>=64&&t<=95))return!1;var n=e<=23?1:2;i=t>=64&&t<=95?1===n?zI[e]:HI[e]:1===n?UI[e]:GI[e];var a=this.channels[n];return!!a&&(a.setPAC(this.interpretPAC(i,t)),this.currentChannel=n,!0)}},{key:"interpretPAC",value:function(e,t){var i,n={color:null,italics:!1,indent:null,underline:!1,row:e};return i=t>95?t-96:t-64,n.underline=!(1&~i),i<=13?n.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(i/2)]:i<=15?(n.italics=!0,n.color="white"):n.indent=4*Math.floor((i-16)/2),n}},{key:"parseChars",value:function(e,t){var i,n,a=null,r=null;(e>=25?(i=2,r=e-8):(i=1,r=e),r>=17&&r<=19)?(n=17===r?t+80:18===r?t+112:t+144,this.logger.log(2,()=>"Special char '"+NI(n)+"' in channel "+i),a=[n]):e>=32&&e<=127&&(a=0===t?[e]:[e,t]);return a&&this.logger.log(3,()=>"Char codes = "+XI(a).join(",")),a}},{key:"parseBackgroundAttributes",value:function(e,t){var i;if(!((16===e||24===e)&&t>=32&&t<=47)&&!((23===e||31===e)&&t>=45&&t<=47))return!1;var n={};16===e||24===e?(i=Math.floor((t-32)/2),n.background=VI[i],t%2==1&&(n.background=n.background+"_semi")):45===t?n.background="transparent":(n.foreground="black",47===t&&(n.underline=!0));var a=e<=23?1:2;return this.channels[a].setBkgData(n),!0}},{key:"reset",value:function(){for(var e=0;e<Object.keys(this.channels).length;e++){var t=this.channels[e];t&&t.reset()}tL(null,null,this.cmdHistory)}},{key:"cueSplitAtTime",value:function(e){for(var t=0;t<this.channels.length;t++){var i=this.channels[t];i&&i.cueSplitAtTime(e)}}}])}();function tL(e,t,i){i.a=e,i.b=t}var iL=function(){if(null!=aA&&aA.VTTCue)return self.VTTCue;var e=["","lr","rl"],t=["start","middle","end","left","right"];function i(e,t){if("string"!=typeof t)return!1;if(!Array.isArray(e))return!1;var i=t.toLowerCase();return!!~e.indexOf(i)&&i}function n(e){return i(t,e)}function a(e,...t){for(var i=1;i<arguments.length;i++){var n=arguments[i];for(var a in n)e[a]=n[a]}return e}function r(t,r,o){var s=this,u={enumerable:!0};s.hasBeenReset=!1;var l="",d=!1,h=t,c=r,m=o,f=null,v="",p=!0,g="auto",y="start",b=50,w="middle",k=50,S="middle";Object.defineProperty(s,"id",a({},u,{get:function(){return l},set:function(e){l=""+e}})),Object.defineProperty(s,"pauseOnExit",a({},u,{get:function(){return d},set:function(e){d=!!e}})),Object.defineProperty(s,"startTime",a({},u,{get:function(){return h},set:function(e){if("number"!=typeof e)throw new TypeError("Start time must be set to a number.");h=e,this.hasBeenReset=!0}})),Object.defineProperty(s,"endTime",a({},u,{get:function(){return c},set:function(e){if("number"!=typeof e)throw new TypeError("End time must be set to a number.");c=e,this.hasBeenReset=!0}})),Object.defineProperty(s,"text",a({},u,{get:function(){return m},set:function(e){m=""+e,this.hasBeenReset=!0}})),Object.defineProperty(s,"region",a({},u,{get:function(){return f},set:function(e){f=e,this.hasBeenReset=!0}})),Object.defineProperty(s,"vertical",a({},u,{get:function(){return v},set:function(t){var n=function(t){return i(e,t)}(t);if(!1===n)throw new SyntaxError("An invalid or illegal string was specified.");v=n,this.hasBeenReset=!0}})),Object.defineProperty(s,"snapToLines",a({},u,{get:function(){return p},set:function(e){p=!!e,this.hasBeenReset=!0}})),Object.defineProperty(s,"line",a({},u,{get:function(){return g},set:function(e){if("number"!=typeof e&&"auto"!==e)throw new SyntaxError("An invalid number or illegal string was specified.");g=e,this.hasBeenReset=!0}})),Object.defineProperty(s,"lineAlign",a({},u,{get:function(){return y},set:function(e){var t=n(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");y=t,this.hasBeenReset=!0}})),Object.defineProperty(s,"position",a({},u,{get:function(){return b},set:function(e){if(e<0||e>100)throw new Error("Position must be between 0 and 100.");b=e,this.hasBeenReset=!0}})),Object.defineProperty(s,"positionAlign",a({},u,{get:function(){return w},set:function(e){var t=n(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");w=t,this.hasBeenReset=!0}})),Object.defineProperty(s,"size",a({},u,{get:function(){return k},set:function(e){if(e<0||e>100)throw new Error("Size must be between 0 and 100.");k=e,this.hasBeenReset=!0}})),Object.defineProperty(s,"align",a({},u,{get:function(){return S},set:function(e){var t=n(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");S=t,this.hasBeenReset=!0}})),s.displayState=void 0}return r.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},r}(),nL=function(){return m(function e(){u(this,e)},[{key:"decode",value:function(e,t){if(!e)return"";if("string"!=typeof e)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}])}();function aL(e){function t(e,t,i,n){return 3600*(0|e)+60*(0|t)+(0|i)+parseFloat(n||0)}var i=e.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return i?parseFloat(i[2])>59?t(i[2],i[3],0,i[4]):t(i[1],i[2],i[3],i[4]):null}var rL=function(){return m(function e(){u(this,e),this.values=Object.create(null)},[{key:"set",value:function(e,t){this.get(e)||""===t||(this.values[e]=t)}},{key:"get",value:function(e,t,i){return i?this.has(e)?this.values[e]:t[i]:this.has(e)?this.values[e]:t}},{key:"has",value:function(e){return e in this.values}},{key:"alt",value:function(e,t,i){for(var n=0;n<i.length;++n)if(t===i[n]){this.set(e,t);break}}},{key:"integer",value:function(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))}},{key:"percent",value:function(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){var i=parseFloat(t);if(i>=0&&i<=100)return this.set(e,i),!0}return!1}}])}();function oL(e,t,i,n){var a=n?e.split(n):[e];for(var r in a)if("string"==typeof a[r]){var o=a[r].split(i);if(2===o.length)t(o[0],o[1])}}var sL=new iL(0,0,""),uL="middle"===sL.align?"middle":"center";function lL(e,t,i){var n=e;function a(){var t=aL(e);if(null===t)throw new Error("Malformed timestamp: "+n);return e=e.replace(/^[^\sa-zA-Z-]+/,""),t}function r(){e=e.replace(/^\s+/,"")}if(r(),t.startTime=a(),r(),"--\x3e"!==e.slice(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+n);e=e.slice(3),r(),t.endTime=a(),r(),function(e,t){var n=new rL;oL(e,function(e,t){var a;switch(e){case"region":for(var r=i.length-1;r>=0;r--)if(i[r].id===t){n.set(e,i[r].region);break}break;case"vertical":n.alt(e,t,["rl","lr"]);break;case"line":a=t.split(","),n.integer(e,a[0]),n.percent(e,a[0])&&n.set("snapToLines",!1),n.alt(e,a[0],["auto"]),2===a.length&&n.alt("lineAlign",a[1],["start",uL,"end"]);break;case"position":a=t.split(","),n.percent(e,a[0]),2===a.length&&n.alt("positionAlign",a[1],["start",uL,"end","line-left","line-right","auto"]);break;case"size":n.percent(e,t);break;case"align":n.alt(e,t,["start",uL,"end","left","right"])}},/:/,/\s/),t.region=n.get("region",null),t.vertical=n.get("vertical","");var a=n.get("line","auto");"auto"===a&&-1===sL.line&&(a=-1),t.line=a,t.lineAlign=n.get("lineAlign","start"),t.snapToLines=n.get("snapToLines",!0),t.size=n.get("size",100),t.align=n.get("align",uL);var r=n.get("position","auto");"auto"===r&&50===sL.position&&(r="start"===t.align||"left"===t.align?0:"end"===t.align||"right"===t.align?100:50),t.position=r}(e,t)}function dL(e){return e.replace(/<br(?: \/)?>/gi,"\n")}var hL=function(){return m(function e(){u(this,e),this.state="INITIAL",this.buffer="",this.decoder=new nL,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0},[{key:"parse",value:function(e){var t=this;function i(){var e=t.buffer,i=0;for(e=dL(e);i<e.length&&"\r"!==e[i]&&"\n"!==e[i];)++i;var n=e.slice(0,i);return"\r"===e[i]&&++i,"\n"===e[i]&&++i,t.buffer=e.slice(i),n}function n(e){oL(e,function(e,t){},/:/)}e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));try{var a="";if("INITIAL"===t.state){if(!/\r\n|\n/.test(t.buffer))return this;var r=(a=i()).match(/^()?WEBVTT([ \t].*)?$/);if(null==r||!r[0])throw new Error("Malformed WebVTT signature.");t.state="HEADER"}for(var o=!1;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(o?o=!1:a=i(),t.state){case"HEADER":/:/.test(a)?n(a):a||(t.state="ID");continue;case"NOTE":a||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(a)){t.state="NOTE";break}if(!a)continue;if(t.cue=new iL(0,0,""),t.state="CUE",-1===a.indexOf("--\x3e")){t.cue.id=a;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{lL(a,t.cue,t.regionList)}catch(e){t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":var s=-1!==a.indexOf("--\x3e");if(!a||s&&(o=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(null===t.cue)continue;t.cue.text&&(t.cue.text+="\n"),t.cue.text+=a;continue;case"BADCUE":a||(t.state="ID")}}}catch(e){"CUETEXT"===t.state&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state="INITIAL"===t.state?"BADWEBVTT":"BADCUE"}return this}},{key:"flush",value:function(){var e=this;try{if((e.cue||"HEADER"===e.state)&&(e.buffer+="\n\n",e.parse()),"INITIAL"===e.state||"BADWEBVTT"===e.state)throw new Error("Malformed WebVTT signature.")}catch(t){e.onparsingerror&&e.onparsingerror(t)}return e.onflush&&e.onflush(),this}}])}(),cL=/\r\n|\n\r|\n|\r/g,mL=function(e,t,i=0){return e.slice(i,i+t.length)===t};function fL(e,t,i){return wI(e.toString())+wI(t.toString())+wI(i)}function vL(e,t,i,n,a,r,o){var s,u=new hL,l=hT(new Uint8Array(e)).trim().replace(cL,"\n").split("\n"),d=[],h=t?function(e,t=1){return xx(e,9e4,1/t)}(t.baseTime,t.timescale):0,c="00:00.000",m=0,f=0,v=!0;u.oncue=function(e){var r=i[n],o=i.ccOffset,u=(m-h)/9e4;if(null!=r&&r.new&&(void 0!==f?o=i.ccOffset=r.start:function(e,t,i){var n=e[t],a=e[n.prevCC];if(!a||!a.new&&n.new)return e.ccOffset=e.presentationOffset=n.start,void(n.new=!1);for(;null!=(r=a)&&r.new;){var r;e.ccOffset+=n.start-a.start,n.new=!1,a=e[(n=a).prevCC]}e.presentationOffset=i}(i,n,u)),u){if(!t)return void(s=new Error("Missing initPTS for VTT MPEGTS"));o=u-i.presentationOffset}var l=e.endTime-e.startTime,c=Ox(9e4*(e.startTime+o-f),9e4*a)/9e4;e.startTime=Math.max(c,0),e.endTime=Math.max(c+l,0);var v=e.text.trim();e.text=decodeURIComponent(encodeURIComponent(v)),e.id||(e.id=fL(e.startTime,e.endTime,v)),e.endTime>0&&d.push(e)},u.onparsingerror=function(e){s=e},u.onflush=function(){s?o(s):r(d)},l.forEach(e=>{if(v){if(mL(e,"X-TIMESTAMP-MAP=")){v=!1,e.slice(16).split(",").forEach(e=>{mL(e,"LOCAL:")?c=e.slice(6):mL(e,"MPEGTS:")&&(m=parseInt(e.slice(7)))});try{f=function(e){var t=parseInt(e.slice(-3)),i=parseInt(e.slice(-6,-4)),n=parseInt(e.slice(-9,-7)),a=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!(WE(t)&&WE(i)&&WE(n)&&WE(a)))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*i,t+=6e4*n,t+36e5*a}(c)/1e3}catch(e){s=e}return}""===e&&(v=!1)}u.parse(e+"\n")}),u.flush()}var pL="stpp.ttml.im1t",gL=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,yL=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,bL={left:"start",center:"center",right:"end",start:"start",end:"end"};function wL(e,t,i,n){var a=jT(new Uint8Array(e),["mdat"]);if(0!==a.length){var r=a.map(e=>hT(e)),o=function(e,t,i=1,n=!1){return xx(e,t,1/i,n)}(t.baseTime,1,t.timescale);try{r.forEach(e=>i(function(e,t){var i=(new DOMParser).parseFromString(e,"text/xml"),n=i.getElementsByTagName("tt")[0];if(!n)throw new Error("Invalid ttml");var a={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},r=Object.keys(a).reduce((e,t)=>(e[t]=n.getAttribute(`ttp:${t}`)||a[t],e),{}),o="preserve"!==n.getAttribute("xml:space"),s=SL(kL(n,"styling","style")),u=SL(kL(n,"layout","region")),l=kL(n,"body","[begin]");return[].map.call(l,e=>{var i=EL(e,o);if(!i||!e.hasAttribute("begin"))return null;var n=ML(e.getAttribute("begin"),r),a=ML(e.getAttribute("dur"),r),l=ML(e.getAttribute("end"),r);if(null===n)throw PL(e);if(null===l){if(null===a)throw PL(e);l=n+a}var d=new iL(n-t,l-t,i);d.id=fL(d.startTime,d.endTime,d.text);var h=function(e,t,i){var n="http://www.w3.org/ns/ttml#styling",a=null,r=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],o=null!=e&&e.hasAttribute("style")?e.getAttribute("style"):null;o&&i.hasOwnProperty(o)&&(a=i[o]);return r.reduce((i,r)=>{var o=TL(t,n,r)||TL(e,n,r)||TL(a,n,r);return o&&(i[r]=o),i},{})}(u[e.getAttribute("region")],s[e.getAttribute("style")],s),c=h.textAlign;if(c){var m=bL[c];m&&(d.lineAlign=m),d.align=c}return ZE(d,h),d}).filter(e=>null!==e)}(e,o)))}catch(e){n(e)}}else n(new Error("Could not parse IMSC1 mdat"))}function kL(e,t,i){var n=e.getElementsByTagName(t)[0];return n?[].slice.call(n.querySelectorAll(i)):[]}function SL(e){return e.reduce((e,t)=>{var i=t.getAttribute("xml:id");return i&&(e[i]=t),e},{})}function EL(e,t){return[].slice.call(e.childNodes).reduce((e,i,n)=>{var a;return"br"===i.nodeName&&n?e+"\n":null!=(a=i.childNodes)&&a.length?EL(i,t):t?e+i.textContent.trim().replace(/\s+/g," "):e+i.textContent},"")}function TL(e,t,i){return e&&e.hasAttributeNS(t,i)?e.getAttributeNS(t,i):null}function PL(e){return new Error(`Could not parse ttml timestamp ${e}`)}function ML(e,t){if(!e)return null;var i=aL(e);return null===i&&(gL.test(e)?i=function(e,t){var i=gL.exec(e),n=(0|i[4])+(0|i[5])/t.subFrameRate;return 3600*(0|i[1])+60*(0|i[2])+(0|i[3])+n/t.frameRate}(e,t):yL.test(e)&&(i=function(e,t){var i=yL.exec(e),n=Number(i[1]);switch(i[2]){case"h":return 3600*n;case"m":return 60*n;case"ms":return 1e3*n;case"f":return n/t.frameRate;case"t":return n/t.tickRate}return n}(e,t))),i}var AL=function(){return m(function e(t,i){u(this,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=i},[{key:"dispatchCue",value:function(){null!==this.startTime&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}},{key:"newCue",value:function(e,t,i){(null===this.startTime||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=i,this.timelineController.createCaptionsTrack(this.trackName)}},{key:"reset",value:function(){this.cueRanges=[],this.startTime=null}}])}(),DL=function(){return m(function e(t){u(this,e),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.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},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}},t.on(zE.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(zE.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(zE.MANIFEST_LOADING,this.onManifestLoading,this),t.on(zE.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(zE.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(zE.FRAG_LOADING,this.onFragLoading,this),t.on(zE.FRAG_LOADED,this.onFragLoaded,this),t.on(zE.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.on(zE.FRAG_DECRYPTED,this.onFragDecrypted,this),t.on(zE.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(zE.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.on(zE.BUFFER_FLUSHING,this.onBufferFlushing,this)},[{key:"destroy",value:function(){var e=this.hls;e.off(zE.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(zE.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(zE.MANIFEST_LOADING,this.onManifestLoading,this),e.off(zE.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(zE.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(zE.FRAG_LOADING,this.onFragLoading,this),e.off(zE.FRAG_LOADED,this.onFragLoaded,this),e.off(zE.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(zE.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(zE.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(zE.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(zE.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.media=null,this.cea608Parser1=this.cea608Parser2=void 0}},{key:"initCea608Parsers",value:function(){var e=new AL(this,"textTrack1"),t=new AL(this,"textTrack2"),i=new AL(this,"textTrack3"),n=new AL(this,"textTrack4");this.cea608Parser1=new eL(1,e,t),this.cea608Parser2=new eL(3,i,n)}},{key:"addCues",value:function(e,t,i,n,a){for(var r=!1,o=a.length;o--;){var s=a[o],u=IL(s[0],s[1],t,i);if(u>=0&&(s[0]=Math.min(s[0],t),s[1]=Math.max(s[1],i),r=!0,u/(i-t)>.5))return}if(r||a.push([t,i]),this.config.renderTextTracksNatively){var l=this.captionsTracks[e];this.Cues.newCue(l,t,i,n)}else{var d=this.Cues.newCue(null,t,i,n);this.hls.trigger(zE.CUES_PARSED,{type:"captions",cues:d,track:e})}}},{key:"onInitPtsFound",value:function(e,{frag:t,id:i,initPTS:n,timescale:a,trackId:r}){var o=this.unparsedVttFrags;i===KE&&(this.initPTS[t.cc]={baseTime:n,timescale:a,trackId:r}),o.length&&(this.unparsedVttFrags=[],o.forEach(e=>{this.initPTS[e.frag.cc]?this.onFragLoaded(zE.FRAG_LOADED,e):this.hls.trigger(zE.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e.frag,error:new Error("Subtitle discontinuity domain does not match main")})}))}},{key:"getExistingTrack",value:function(e,t){var i=this.media;if(i)for(var n=0;n<i.textTracks.length;n++){var a=i.textTracks[n];if(CL(a,{name:e,lang:t,characteristics:"transcribes-spoken-dialog,describes-music-and-sound"}))return a}return null}},{key:"createCaptionsTrack",value:function(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}},{key:"createNativeTrack",value:function(e){if(!this.captionsTracks[e]){var t=this.captionsProperties,i=this.captionsTracks,n=this.media,a=t[e],r=a.label,o=a.languageCode,s=this.getExistingTrack(r,o);if(s)i[e]=s,pI(i[e]),fI(i[e],n);else{var u=this.createTextTrack("captions",r,o);u&&(u[e]=!0,i[e]=u)}}}},{key:"createNonNativeTrack",value:function(e){if(!this.nonNativeCaptionsTracks[e]){var t=this.captionsProperties[e];if(t){var i={_id:e,label:t.label,kind:"captions",default:!!t.media&&!!t.media.default,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=i,this.hls.trigger(zE.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[i]})}}}},{key:"createTextTrack",value:function(e,t,i){var n=this.media;if(n)return n.addTextTrack(e,t,i)}},{key:"onMediaAttaching",value:function(e,t){this.media=t.media,t.mediaSource||this._cleanTracks()}},{key:"onMediaDetaching",value:function(e,t){var i=!!t.transferMedia;if(this.media=null,!i){var n=this.captionsTracks;Object.keys(n).forEach(e=>{pI(n[e]),delete n[e]}),this.nonNativeCaptionsTracks={}}}},{key:"onManifestLoading",value:function(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}},{key:"_cleanTracks",value:function(){var e=this.media;if(e){var t=e.textTracks;if(t)for(var i=0;i<t.length;i++)pI(t[i])}}},{key:"onSubtitleTracksUpdated",value:function(e,t){var i=t.subtitleTracks||[],n=i.some(e=>e.textCodec===pL);if(this.config.enableWebVTT||n&&this.config.enableIMSC1){if(Zx(this.tracks,i))return void(this.tracks=i);if(this.textTracks=[],this.tracks=i,this.config.renderTextTracksNatively){var a=this.media,r=a?yI(a.textTracks):null;if(this.tracks.forEach((e,t)=>{var i;if(r){for(var n=null,a=0;a<r.length;a++)if(r[a]&&CL(r[a],e)){n=r[a],r[a]=null;break}n&&(i=n)}if(i)pI(i);else{var o=xL(e);(i=this.createTextTrack(o,e.name,e.lang))&&(i.mode="disabled")}i&&this.textTracks.push(i)}),null!=r&&r.length){var o=r.filter(e=>null!==e).map(e=>e.label);o.length&&this.hls.logger.warn(`Media element contains unused subtitle tracks: ${o.join(", ")}. Replace media element for each source to clear TextTracks and captions menu.`)}}else if(this.tracks.length){var s=this.tracks.map(e=>({label:e.name,kind:e.type.toLowerCase(),default:e.default,subtitleTrack:e}));this.hls.trigger(zE.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:s})}}}},{key:"onManifestLoaded",value:function(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(e=>{var t=/(?:CC|SERVICE)([1-4])/.exec(e.instreamId);if(t){var i=`textTrack${t[1]}`,n=this.captionsProperties[i];n&&(n.label=e.name,e.lang&&(n.languageCode=e.lang),n.media=e)}})}},{key:"closedCaptionsForLevel",value:function(e){var t=this.hls.levels[e.level];return null==t?void 0:t.attrs["CLOSED-CAPTIONS"]}},{key:"onFragLoading",value:function(e,t){if(this.enabled&&t.frag.type===KE){var i,n,a=this.cea608Parser1,r=this.cea608Parser2,o=this.lastSn,s=t.frag,u=s.cc,l=s.sn,d=null!=(i=null==(n=t.part)?void 0:n.index)?i:-1;a&&r&&(l!==o+1||l===o&&d!==this.lastPartIndex+1||u!==this.lastCc)&&(a.reset(),r.reset()),this.lastCc=u,this.lastSn=l,this.lastPartIndex=d}}},{key:"onFragLoaded",value:function(e,t){var i=t.frag,n=t.payload;if(i.type===YE)if(n.byteLength){var a=i.decryptdata,r="stats"in t;if(null==a||!a.encrypted||r){var o=this.tracks[i.level],s=this.vttCCs;s[i.cc]||(s[i.cc]={start:i.start,prevCC:this.prevCC,new:!0},this.prevCC=i.cc),o&&o.textCodec===pL?this._parseIMSC1(i,n):this._parseVTTs(t)}}else this.hls.trigger(zE.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Empty subtitle payload")})}},{key:"_parseIMSC1",value:function(e,t){var i=this.hls;wL(t,this.initPTS[e.cc],t=>{this._appendCues(t,e.level),i.trigger(zE.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},t=>{i.logger.log(`Failed to parse IMSC1: ${t}`),i.trigger(zE.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:t})})}},{key:"_parseVTTs",value:function(e){var t,i=e.frag,n=e.payload,a=this.initPTS,r=this.unparsedVttFrags,o=a.length-1;if(a[i.cc]||-1!==o){var s=this.hls;vL(null!=(t=i.initSegment)&&t.data?qT(i.initSegment.data,new Uint8Array(n)).buffer:n,this.initPTS[i.cc],this.vttCCs,i.cc,i.start,e=>{this._appendCues(e,i.level),s.trigger(zE.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:i})},t=>{var a="Missing initPTS for VTT MPEGTS"===t.message;a?r.push(e):this._fallbackToIMSC1(i,n),s.logger.log(`Failed to parse VTT cue: ${t}`),a&&o>i.cc||s.trigger(zE.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:t})})}else r.push(e)}},{key:"_fallbackToIMSC1",value:function(e,t){var i=this.tracks[e.level];i.textCodec||wL(t,this.initPTS[e.cc],()=>{i.textCodec=pL,this._parseIMSC1(e,t)},()=>{i.textCodec="wvtt"})}},{key:"_appendCues",value:function(e,t){var i=this.hls;if(this.config.renderTextTracksNatively){var n=this.textTracks[t];if(!n||"disabled"===n.mode)return;e.forEach(e=>vI(n,e))}else{var a=this.tracks[t];if(!a)return;var r=a.default?"default":"subtitles"+t;i.trigger(zE.CUES_PARSED,{type:"subtitles",cues:e,track:r})}}},{key:"onFragDecrypted",value:function(e,t){t.frag.type===YE&&this.onFragLoaded(zE.FRAG_LOADED,t)}},{key:"onSubtitleTracksCleared",value:function(){this.tracks=[],this.captionsTracks={}}},{key:"onFragParsingUserdata",value:function(e,t){if(this.enabled&&this.config.enableCEA708Captions){var i=t.frag,n=t.samples;if(i.type!==KE||"NONE"!==this.closedCaptionsForLevel(i))for(var a=0;a<n.length;a++){var r=n[a].bytes;if(r){this.cea608Parser1||this.initCea608Parsers();var o=this.extractCea608Data(r);this.cea608Parser1.addData(n[a].pts,o[0]),this.cea608Parser2.addData(n[a].pts,o[1])}}}}},{key:"onBufferFlushing",value:function(e,{startOffset:t,endOffset:i,endOffsetSubtitles:n,type:a}){var r=this.media;if(r&&!(r.currentTime<i)){if(!a||"video"===a){var o=this.captionsTracks;Object.keys(o).forEach(e=>gI(o[e],t,i))}if(this.config.renderTextTracksNatively&&0===t&&void 0!==n){var s=this.textTracks;Object.keys(s).forEach(e=>gI(s[e],t,n))}}}},{key:"extractCea608Data",value:function(e){for(var t=[[],[]],i=31&e[0],n=2,a=0;a<i;a++){var r=e[n++],o=127&e[n++],s=127&e[n++];if(0!==o||0!==s)if(!!(4&r)){var u=3&r;0!==u&&1!==u||(t[u].push(o),t[u].push(s))}}return t}}])}();function xL(e){return e.characteristics&&/transcribes-spoken-dialog/gi.test(e.characteristics)&&/describes-music-and-sound/gi.test(e.characteristics)?"captions":"subtitles"}function CL(e,t){return!!e&&e.kind===xL(t)&&tC(t,e)}function IL(e,t,i,n){return Math.min(t,n)-Math.max(e,i)}var LL=/\s/,_L={newCue(e,t,i,n){for(var a,r,o,s,u,l=[],d=self.VTTCue||self.TextTrackCue,h=0;h<n.rows.length;h++)if(o=!0,s=0,u="",!(a=n.rows[h]).isEmpty()){for(var c,m=0;m<a.chars.length;m++)LL.test(a.chars[m].uchar)&&o?s++:(u+=a.chars[m].uchar,o=!1);a.cueStartTime=t,t===i&&(i+=1e-4),s>=16?s--:s++;var f=dL(u.trim()),v=fL(t,i,f);null!=e&&null!=(c=e.cues)&&c.getCueById(v)||((r=new d(t,i,f)).id=v,r.line=h+1,r.align="left",r.position=10+Math.min(80,10*Math.floor(8*s/32)),l.push(r))}return e&&l.length&&(l.sort((e,t)=>"auto"===e.line||"auto"===t.line?0:e.line>8&&t.line>8?t.line-e.line:e.line-t.line),l.forEach(t=>vI(e,t))),l}};var RL=/(\d+)-(\d+)\/(\d+)/,FL=function(){return m(function e(t){u(this,e),this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=null,this.response=null,this.controller=void 0,this.context=null,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=t.fetchSetup||OL,this.controller=new self.AbortController,this.stats=new ET},[{key:"destroy",value:function(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null}},{key:"abortInternal",value:function(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())}},{key:"abort",value:function(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}},{key:"load",value:function(e,t,i){var n=this.stats;if(n.loading.start)throw new Error("Loader can only be used once.");n.loading.start=self.performance.now();var a=function(e,t){var i={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(ZE({},e.headers))};e.rangeEnd&&i.headers.set("Range","bytes="+e.rangeStart+"-"+String(e.rangeEnd-1));return i}(e,this.controller.signal),r="arraybuffer"===e.responseType,o=r?"byteLength":"length",s=t.loadPolicy,u=s.maxTimeToFirstByteMs,l=s.maxLoadTimeMs;this.context=e,this.config=t,this.callbacks=i,this.request=this.fetchSetup(e,a),self.clearTimeout(this.requestTimeout),t.timeout=u&&WE(u)?u:l,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(n,e,this.response))},t.timeout),(Vx(this.request)?this.request.then(self.fetch):self.fetch(this.request)).then(i=>{var a;this.response=this.loader=i;var o=Math.max(self.performance.now(),n.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=l,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(n,e,this.response))},l-(o-n.loading.start)),!i.ok){var s=i.status,u=i.statusText;throw new WL(u||"fetch, bad network response",s,i)}n.loading.first=o,n.total=function(e){var t=e.get("Content-Range");if(t){var i=function(e){var t=RL.exec(e);if(t)return parseInt(t[2])-parseInt(t[1])+1}(t);if(WE(i))return i}var n=e.get("Content-Length");if(n)return parseInt(n)}(i.headers)||n.total;var d=null==(a=this.callbacks)?void 0:a.onProgress;return d&&WE(t.highWaterMark)?this.loadProgressively(i,n,e,t.highWaterMark,d):r?i.arrayBuffer():"json"===e.responseType?i.json():i.text()}).then(i=>{var a,r,s=this.response;if(!s)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),n.loading.end=Math.max(self.performance.now(),n.loading.first);var u=i[o];u&&(n.loaded=n.total=u);var l={url:s.url,data:i,code:s.status},d=null==(a=this.callbacks)?void 0:a.onProgress;d&&!WE(t.highWaterMark)&&d(n,e,i,s),null==(r=this.callbacks)||r.onSuccess(l,n,e,s)}).catch(t=>{var i;if(self.clearTimeout(this.requestTimeout),!n.aborted){var a=t&&t.code||0,r=t?t.message:null;null==(i=this.callbacks)||i.onError({code:a,text:r},e,t?t.details:null,n)}})}},{key:"getCacheAge",value:function(){var e=null;if(this.response){var t=this.response.headers.get("age");e=t?parseFloat(t):null}return e}},{key:"getResponseHeader",value:function(e){return this.response?this.response.headers.get(e):null}},{key:"loadProgressively",value:function(e,t,i,n=0,a){var r=new gD,o=e.body.getReader(),s=()=>o.read().then(o=>{if(o.done)return r.dataLength&&a(t,i,r.flush().buffer,e),Promise.resolve(new ArrayBuffer(0));var u=o.value,l=u.length;return t.loaded+=l,l<n||r.dataLength?(r.push(u),r.dataLength>=n&&a(t,i,r.flush().buffer,e)):a(t,i,u.buffer,e),s()}).catch(()=>Promise.reject());return s()}}])}();function OL(e,t){return new self.Request(e.url,t)}var WL=function(){function e(t,i,n){var a;return u(this,e),(a=s(this,e,[t])).code=void 0,a.details=void 0,a.code=i,a.details=n,a}return y(e,D(Error)),m(e)}(),$L=/^age:\s*[\d.]+\s*$/im,NL=function(){return m(function e(t){u(this,e),this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=null,this.loader=null,this.stats=void 0,this.xhrSetup=t&&t.xhrSetup||null,this.stats=new ET,this.retryDelay=0},[{key:"destroy",value:function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null}},{key:"abortInternal",value:function(){var e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,4!==e.readyState&&(this.stats.aborted=!0,e.abort()))}},{key:"abort",value:function(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}},{key:"load",value:function(e,t,i){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=i,this.loadInternal()}},{key:"loadInternal",value:function(){var e=this.config,t=this.context;if(e&&t){var i=this.loader=new self.XMLHttpRequest,n=this.stats;n.loading.first=0,n.loaded=0,n.aborted=!1;var a=this.xhrSetup;a?Promise.resolve().then(()=>{if(this.loader===i&&!this.stats.aborted)return a(i,t.url)}).catch(e=>{if(this.loader===i&&!this.stats.aborted)return i.open("GET",t.url,!0),a(i,t.url)}).then(()=>{this.loader!==i||this.stats.aborted||this.openAndSendXhr(i,t,e)}).catch(e=>{var a;null==(a=this.callbacks)||a.onError({code:i.status,text:e.message},t,i,n)}):this.openAndSendXhr(i,t,e)}}},{key:"openAndSendXhr",value:function(e,t,i){e.readyState||e.open("GET",t.url,!0);var n=t.headers,a=i.loadPolicy,r=a.maxTimeToFirstByteMs,o=a.maxLoadTimeMs;if(n)for(var s in n)e.setRequestHeader(s,n[s]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),i.timeout=r&&WE(r)?r:o,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.timeout),e.send()}},{key:"readystatechange",value:function(){var e=this.context,t=this.loader,i=this.stats;if(e&&t){var n=t.readyState,a=this.config;if(!i.aborted&&n>=2&&(0===i.loading.first&&(i.loading.first=Math.max(self.performance.now(),i.loading.start),a.timeout!==a.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),a.timeout=a.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),a.loadPolicy.maxLoadTimeMs-(i.loading.first-i.loading.start)))),4===n)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;var r=t.status,o="text"===t.responseType?t.responseText:null;if(r>=200&&r<300){var s=null!=o?o:t.response;if(null!=s){var u,l;i.loading.end=Math.max(self.performance.now(),i.loading.first);var d="arraybuffer"===t.responseType?s.byteLength:s.length;i.loaded=i.total=d,i.bwEstimate=8e3*i.total/(i.loading.end-i.loading.first);var h=null==(u=this.callbacks)?void 0:u.onProgress;h&&h(i,e,s,t);var c={url:t.responseURL,data:s,code:r};return void(null==(l=this.callbacks)||l.onSuccess(c,i,e,t))}}var m,f=a.loadPolicy.errorRetry;if(nM(f,i.retry,!1,{url:e.url,data:void 0,code:r}))this.retry(f);else uT.error(`${r} while loading ${e.url}`),null==(m=this.callbacks)||m.onError({code:r,text:t.statusText},e,t,i)}}}},{key:"loadtimeout",value:function(){if(this.config){var e=this.config.loadPolicy.timeoutRetry;if(nM(e,this.stats.retry,!0))this.retry(e);else{var t;uT.warn(`timeout while loading ${null==(t=this.context)?void 0:t.url}`);var i=this.callbacks;i&&(this.abortInternal(),i.onTimeout(this.stats,this.context,this.loader))}}}},{key:"retry",value:function(e){var t=this.context,i=this.stats;this.retryDelay=tM(e,i.retry),i.retry++,uT.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${null==t?void 0:t.url}, retrying ${i.retry}/${e.maxNumRetry} in ${this.retryDelay}ms`),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)}},{key:"loadprogress",value:function(e){var t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)}},{key:"getCacheAge",value:function(){var e=null;if(this.loader&&$L.test(this.loader.getAllResponseHeaders())){var t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e}},{key:"getResponseHeader",value:function(e){return this.loader&&new RegExp(`^${e}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}}])}(),jL=tT(tT({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,maxDevicePixelRatio:Number.POSITIVE_INFINITY,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,startOnSegmentBoundary:!1,maxBufferSize:6e7,maxFragLookUpTolerance:.25,maxBufferHole:.1,detectStallWithCurrentTimeMs:1250,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,nudgeOnVideoHole:!0,liveSyncMode:"edge",liveSyncDurationCount:3,liveSyncOnStallIncrease:1,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,ignorePlaylistParsingErrors:!1,loader:NL,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:GP,bufferController:sC,capLevelController:dC,errorController:mM,fpsController:mI,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:fA,requireKeySystemAccessOnStart:!1,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableEmsgKLVMetadata:!1,enableID3MetadataCues:!0,enableInterstitialPlayback:!0,interstitialAppendInPlace:!0,interstitialLiveLookAhead:10,useMediaCapabilities:!0,preserveManualLevelOnError:!1,certLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null}},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}}},interstitialAssetListLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:3e4,timeoutRetry:{maxNumRetry:0,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:0,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},{cueHandler:_L,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:OI,subtitleTrackController:bI,timelineController:DL,audioStreamController:Jx,audioTrackController:iC,emeController:uI,cmcdController:aI,contentSteeringController:rI,interstitialsController:FI});function BL(e){return e&&"object"==typeof e?Array.isArray(e)?e.map(BL):Object.keys(e).reduce((t,i)=>(t[i]=BL(e[i]),t),{}):e}function zL(e,t){var i=e.loader;i!==FL&&i!==NL?(t.log("[config]: Custom loader detected, cannot enable progressive streaming"),e.progressive=!1):function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(e){}return!1}()&&(e.loader=FL,e.progressive=!0,e.enableSoftwareAES=!0,t.log("[config]: Progressive streaming enabled, using FetchLoader"))}var UL=function(){function e(t,i){var n;return u(this,e),(n=s(this,e,["gap-controller",t.logger])).hls=void 0,n.fragmentTracker=void 0,n.media=null,n.mediaSource=void 0,n.nudgeRetry=0,n.stallReported=!1,n.stalled=null,n.moved=!1,n.seeking=!1,n.buffered={},n.lastCurrentTime=0,n.ended=0,n.waiting=0,n.onMediaPlaying=()=>{n.ended=0,n.waiting=0},n.onMediaWaiting=()=>{var e;null!=(e=n.media)&&e.seeking||(n.waiting=self.performance.now(),n.tick())},n.onMediaEnded=()=>{var e;n.hls&&(n.ended=(null==(e=n.media)?void 0:e.currentTime)||1,n.hls.trigger(zE.MEDIA_ENDED,{stalled:!1}))},n.hls=t,n.fragmentTracker=i,n.registerListeners(),n}return y(e,RM),m(e,[{key:"registerListeners",value:function(){var e=this.hls;e&&(e.on(zE.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(zE.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(zE.BUFFER_APPENDED,this.onBufferAppended,this))}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(zE.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(zE.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(zE.BUFFER_APPENDED,this.onBufferAppended,this))}},{key:"destroy",value:function(){M(e,"destroy",this)([]),this.unregisterListeners(),this.media=this.hls=this.fragmentTracker=null,this.mediaSource=void 0}},{key:"onMediaAttached",value:function(e,t){this.setInterval(100),this.mediaSource=t.mediaSource;var i=this.media=t.media;eD(i,"playing",this.onMediaPlaying),eD(i,"waiting",this.onMediaWaiting),eD(i,"ended",this.onMediaEnded)}},{key:"onMediaDetaching",value:function(e,t){this.clearInterval();var i=this.media;i&&(tD(i,"playing",this.onMediaPlaying),tD(i,"waiting",this.onMediaWaiting),tD(i,"ended",this.onMediaEnded),this.media=null),this.mediaSource=void 0}},{key:"onBufferAppended",value:function(e,t){this.buffered=t.timeRanges}},{key:"hasBuffered",get:function(){return Object.keys(this.buffered).length>0}},{key:"tick",value:function(){var e;if(null!=(e=this.media)&&e.readyState&&this.hasBuffered){var t=this.media.currentTime;this.poll(t,this.lastCurrentTime),this.lastCurrentTime=t}}},{key:"poll",value:function(e,t){var i,n,a=null==(i=this.hls)?void 0:i.config;if(a){var r=this.media;if(r){var o=r.seeking,s=this.seeking&&!o,u=!this.seeking&&o,l=r.paused&&!o||r.ended||0===r.playbackRate;if(this.seeking=o,e!==t)return t&&(this.ended=0),this.moved=!0,o||(this.nudgeRetry=0,a.nudgeOnVideoHole&&!l&&e>t&&this.nudgeOnVideoHole(e,t)),void(0===this.waiting&&this.stallResolved(e));if(u||s)s&&this.stallResolved(e);else{if(l)return this.nudgeRetry=0,this.stallResolved(e),void(!this.ended&&r.ended&&this.hls&&(this.ended=e||1,this.hls.trigger(zE.MEDIA_ENDED,{stalled:!1})));if(WM.getBuffered(r).length){var d=WM.bufferInfo(r,e,0),h=d.nextStart||0,c=this.fragmentTracker;if(o&&c&&this.hls){var m=HL(this.hls.inFlightFragments,e),f=d.len>2,v=!h||m||h-e>2&&!c.getPartialFragment(e);if(f||v)return;this.moved=!1}var p=null==(n=this.hls)?void 0:n.latestLevelDetails;if(!this.moved&&null!==this.stalled&&c){if(!(d.len>0)&&!h)return;var g=Math.max(h,d.start||0)-e,y=!(null==p||!p.live)?2*p.targetduration:2,b=VL(e,c);if(g>0&&(g<=y||b))return void(r.paused||this._trySkipBufferHole(b))}var w=a.detectStallWithCurrentTimeMs,k=self.performance.now(),S=this.waiting,E=this.stalled;if(null===E){if(!(S>0&&k-S<w))return void(this.stalled=k);E=this.stalled=S}var T=k-E;if(!o&&(T>=w||S)&&this.hls){var P;if("ended"===(null==(P=this.mediaSource)?void 0:P.readyState)&&(null==p||!p.live)&&Math.abs(e-((null==p?void 0:p.edge)||0))<1){if(this.ended)return;return this.ended=e||1,void this.hls.trigger(zE.MEDIA_ENDED,{stalled:!0})}if(this._reportStall(d),!this.media||!this.hls)return}var M=WM.bufferInfo(r,e,a.maxBufferHole);this._tryFixBufferStall(M,T,e)}else this.nudgeRetry=0}}}}},{key:"stallResolved",value:function(e){var t=this.stalled;if(t&&this.hls&&(this.stalled=null,this.stallReported)){var i=self.performance.now()-t;this.log(`playback not stuck anymore @${e}, after ${Math.round(i)}ms`),this.stallReported=!1,this.waiting=0,this.hls.trigger(zE.STALL_RESOLVED,{})}}},{key:"nudgeOnVideoHole",value:function(e,t){var i,n=this.buffered.video;if(this.hls&&this.media&&this.fragmentTracker&&null!=(i=this.buffered.audio)&&i.length&&n&&n.length>1&&e>n.end(0)){var a=WM.bufferedInfo(WM.timeRangesToArray(this.buffered.audio),e,0);if(a.len>1&&t>=a.start){var r=WM.timeRangesToArray(n),o=WM.bufferedInfo(r,t,0).bufferedIndex;if(o>-1&&o<r.length-1){var s=WM.bufferedInfo(r,e,0).bufferedIndex,u=r[o].end,l=r[o+1].start;if((-1===s||s>o)&&l-u<1&&e-u<2){var d=new Error(`nudging playhead to flush pipeline after video hole. currentTime: ${e} hole: ${u} -> ${l} buffered index: ${s}`);this.warn(d.message),this.media.currentTime+=1e-6;var h=VL(e,this.fragmentTracker);h&&"fragment"in h?h=h.fragment:h||(h=void 0);var c=WM.bufferInfo(this.media,e,0);this.hls.trigger(zE.ERROR,{type:jE.MEDIA_ERROR,details:BE.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:d,reason:d.message,frag:h,buffer:c.len,bufferInfo:c})}}}}}},{key:"_tryFixBufferStall",value:function(e,t,i){var n,a,r=this.fragmentTracker,o=this.media,s=null==(n=this.hls)?void 0:n.config;if(o&&r&&s){var u=null==(a=this.hls)?void 0:a.latestLevelDetails,l=VL(i,r);if(l||null!=u&&u.live&&i<u.fragmentStart)if(this._trySkipBufferHole(l)||!this.media)return;var d=e.buffered,h=this.adjacentTraversal(e,i);(d&&d.length>1&&e.len>s.maxBufferHole||e.nextStart&&(e.nextStart-i<s.maxBufferHole||h))&&(t>1e3*s.highBufferWatchdogPeriod||this.waiting)&&(this.warn("Trying to nudge playhead over buffer-hole"),this._tryNudgeBuffer(e))}}},{key:"adjacentTraversal",value:function(e,t){var i=this.fragmentTracker,n=e.nextStart;if(i&&n){var a=i.getFragAtPos(t,KE),r=i.getFragAtPos(n,KE);if(a&&r)return r.sn-a.sn<2}return!1}},{key:"_reportStall",value:function(e){var t=this.hls,i=this.media,n=this.stallReported,a=this.stalled;if(!n&&null!==a&&i&&t){this.stallReported=!0;var r=new Error(`Playback stalling at @${i.currentTime} due to low buffer (${OP(e)})`);this.warn(r.message),t.trigger(zE.ERROR,{type:jE.MEDIA_ERROR,details:BE.BUFFER_STALLED_ERROR,fatal:!1,error:r,buffer:e.len,bufferInfo:e,stalled:{start:a}})}}},{key:"_trySkipBufferHole",value:function(e){var t,i=this.fragmentTracker,n=this.media,a=null==(t=this.hls)?void 0:t.config;if(!n||!i||!a)return 0;var r=n.currentTime,o=WM.bufferInfo(n,r,0),s=r<o.start?o.start:o.nextStart;if(s&&this.hls){var u=o.len<=a.maxBufferHole,l=o.len>0&&o.len<1&&n.readyState<3,d=s-r;if(d>0&&(u||l)){if(d>a.maxBufferHole){var h=!1;if(0===r){var c=i.getAppendedFrag(0,KE);c&&s<c.end&&(h=!0)}if(!h&&e){var m;if(null==(m=this.hls.loadLevelObj)||!m.details)return 0;if(HL(this.hls.inFlightFragments,s))return 0;for(var f=!1,v=e.end;v<s;){var p=VL(v,i);if(!p){f=!0;break}v+=p.duration}if(f)return 0}}var g=Math.max(s+.05,r+.1);if(this.warn(`skipping hole, adjusting currentTime from ${r} to ${g}`),this.moved=!0,n.currentTime=g,null==e||!e.gap){var y=new Error(`fragment loaded with buffer holes, seeking from ${r} to ${g}`),b={type:jE.MEDIA_ERROR,details:BE.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:y,reason:y.message,buffer:o.len,bufferInfo:o};e&&("fragment"in e?b.part=e:b.frag=e),this.hls.trigger(zE.ERROR,b)}return g}}return 0}},{key:"_tryNudgeBuffer",value:function(e){var t=this.hls,i=this.media,n=this.nudgeRetry,a=null==t?void 0:t.config;if(!i||!a)return 0;var r=i.currentTime;if(this.nudgeRetry++,n<a.nudgeMaxRetry){var o=r+(n+1)*a.nudgeOffset,s=new Error(`Nudging 'currentTime' from ${r} to ${o}`);this.warn(s.message),i.currentTime=o,t.trigger(zE.ERROR,{type:jE.MEDIA_ERROR,details:BE.BUFFER_NUDGE_ON_STALL,error:s,fatal:!1,buffer:e.len,bufferInfo:e})}else{var u=new Error(`Playhead still not moving while enough data buffered @${r} after ${a.nudgeMaxRetry} nudges`);this.error(u.message),t.trigger(zE.ERROR,{type:jE.MEDIA_ERROR,details:BE.BUFFER_STALLED_ERROR,error:u,fatal:!0,buffer:e.len,bufferInfo:e})}}}])}();function HL(e,t){var i=GL(e.main);if(i&&i.start<=t)return i;var n=GL(e.audio);return n&&n.start<=t?n:null}function GL(e){if(!e)return null;switch(e.state){case aD:case nD:case hD:case cD:return null}return e.frag}function VL(e,t){return t.getAppendedFrag(e,KE)||t.getPartialFragment(e)}function KL(){if("undefined"!=typeof self)return self.VTTCue||self.TextTrackCue}function XL(e,t,i,n,a){var r=new e(t,i,"");try{r.value=n,a&&(r.type=a)}catch(o){r=new e(t,i,OP(a?tT({type:a},n):n))}return r}var YL=(()=>{var e=KL();try{e&&new e(0,Number.POSITIVE_INFINITY,"")}catch(e){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})(),qL=function(){return m(function e(t){u(this,e),this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.removeCues=!0,this.assetCue=void 0,this.onEventCueEnter=()=>{this.hls&&this.hls.trigger(zE.EVENT_CUE_ENTER,{})},this.hls=t,this._registerListeners()},[{key:"destroy",value:function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=this.onEventCueEnter=null}},{key:"_registerListeners",value:function(){var e=this.hls;e&&(e.on(zE.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(zE.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(zE.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(zE.MANIFEST_LOADING,this.onManifestLoading,this),e.on(zE.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(zE.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(zE.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(zE.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}},{key:"_unregisterListeners",value:function(){var e=this.hls;e&&(e.off(zE.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(zE.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(zE.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(zE.MANIFEST_LOADING,this.onManifestLoading,this),e.off(zE.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(zE.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(zE.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(zE.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}},{key:"onMediaAttaching",value:function(e,t){var i;this.media=t.media,!1===(null==(i=t.overrides)?void 0:i.cueRemoval)&&(this.removeCues=!1)}},{key:"onMediaAttached",value:function(){var e,t=null==(e=this.hls)?void 0:e.latestLevelDetails;t&&this.updateDateRangeCues(t)}},{key:"onMediaDetaching",value:function(e,t){this.media=null,!!t.transferMedia||(this.id3Track&&(this.removeCues&&pI(this.id3Track,this.onEventCueEnter),this.id3Track=null),this.dateRangeCuesAppended={})}},{key:"onManifestLoading",value:function(){this.dateRangeCuesAppended={}}},{key:"createTrack",value:function(e){var t=this.getID3Track(e.textTracks);return t.mode="hidden",t}},{key:"getID3Track",value:function(e){if(this.media){for(var t=0;t<e.length;t++){var i=e[t];if("metadata"===i.kind&&"id3"===i.label)return fI(i,this.media),i}return this.media.addTextTrack("metadata","id3")}}},{key:"onFragParsingMetadata",value:function(e,t){if(this.media&&this.hls){var i=this.hls.config,n=i.enableEmsgMetadataCues,a=i.enableID3MetadataCues;if(n||a){var r=t.samples;this.id3Track||(this.id3Track=this.createTrack(this.media));var o=KL();if(o)for(var s=0;s<r.length;s++){var u=r[s].type;if((u!==GD.emsg||n)&&a){var l=BD(r[s].data),d=r[s].pts,h=d+r[s].duration;h>YL&&(h=YL),h-d<=0&&(h=d+.25);for(var c=0;c<l.length;c++){var m=l[c];if(!zD(m)){this.updateId3CueEnds(d,u);var f=XL(o,d,h,m,u);f&&this.id3Track.addCue(f)}}}}}}}},{key:"updateId3CueEnds",value:function(e,t){var i,n=null==(i=this.id3Track)?void 0:i.cues;if(n)for(var a=n.length;a--;){var r=n[a];r.type===t&&r.startTime<e&&r.endTime===YL&&(r.endTime=e)}}},{key:"onBufferFlushing",value:function(e,{startOffset:t,endOffset:i,type:n}){var a=this.id3Track,r=this.hls;if(r){var o=r.config,s=o.enableEmsgMetadataCues,u=o.enableID3MetadataCues;if(a&&(s||u))gI(a,t,i,"audio"===n?e=>e.type===GD.audioId3&&u:"video"===n?e=>e.type===GD.emsg&&s:e=>e.type===GD.audioId3&&u||e.type===GD.emsg&&s)}}},{key:"onLevelUpdated",value:function(e,{details:t}){this.updateDateRangeCues(t,!0)}},{key:"onLevelPtsUpdated",value:function(e,t){Math.abs(t.drift)>.01&&this.updateDateRangeCues(t.details)}},{key:"updateDateRangeCues",value:function(e,t){var i=this;if(this.hls&&this.media){var n=this.hls.config,a=n.assetPlayerId,r=n.timelineOffset,o=n.enableDateRangeMetadataCues,s=n.interstitialsController;if(o){var u=KL();if(a&&r&&!s){var l=e.fragmentStart,d=e.fragmentEnd,h=this.assetCue;h?(h.startTime=l,h.endTime=d):u&&(h=this.assetCue=XL(u,l,d,{assetPlayerId:this.hls.config.assetPlayerId},"hlsjs.interstitial.asset"))&&(h.id=a,this.id3Track||(this.id3Track=this.createTrack(this.media)),this.id3Track.addCue(h),h.addEventListener("enter",this.onEventCueEnter))}if(e.hasProgramDateTime){var c,m=this.id3Track,f=e.dateRanges,v=Object.keys(f),p=this.dateRangeCuesAppended;if(m&&t)if(null!=(c=m.cues)&&c.length)for(var g,y=Object.keys(p).filter(e=>!v.includes(e)),b=function(){var e=y[w],t=null==(g=p[e])?void 0:g.cues;delete p[e],t&&Object.keys(t).forEach(e=>{var n=t[e];if(n){n.removeEventListener("enter",i.onEventCueEnter);try{m.removeCue(n)}catch(e){}}})},w=y.length;w--;)b();else p=this.dateRangeCuesAppended={};var k=e.fragments[e.fragments.length-1];if(0!==v.length&&WE(null==k?void 0:k.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var S=function(){var e=v[E],t=f[e],n=t.startTime,a=p[e],r=(null==a?void 0:a.cues)||{},o=(null==a?void 0:a.durationKnown)||!1,l=YL,d=t.duration;if(t.endDate&&null!==d)l=n+d,o=!0;else if(t.endOnNext&&!o){var h=v.reduce((e,i)=>{if(i!==t.id){var n=f[i];if(n.class===t.class&&n.startDate>t.startDate&&(!e||t.startDate<e.startDate))return n}return e},null);h&&(l=h.startTime,o=!0)}for(var c=Object.keys(t.attr),m=0;m<c.length;m++){var g=c[m];if(VM(g)){var y=r[g];if(y)!o||null!=a&&a.durationKnown?Math.abs(y.startTime-n)>.01&&(y.startTime=n,y.endTime=l):y.endTime=l;else if(u){var b=t.attr[g];KM(g)&&(b=mT(b));var w=XL(u,n,l,{key:g,data:b},GD.dateRange);w&&(w.id=e,i.id3Track.addCue(w),r[g]=w,s&&("X-ASSET-LIST"!==g&&"X-ASSET-URL"!==g||w.addEventListener("enter",i.onEventCueEnter)))}}}p[e]={cues:r,dateRange:t,durationKnown:o}},E=0;E<v.length;E++)S()}}}}}}])}(),JL=function(){return m(function e(t){u(this,e),this.hls=void 0,this.config=void 0,this.media=null,this.currentTime=0,this.stallCount=0,this._latency=null,this._targetLatencyUpdated=!1,this.onTimeupdate=()=>{var e=this.media,t=this.levelDetails;if(e&&t){this.currentTime=e.currentTime;var i=this.computeLatency();if(null!==i){this._latency=i;var n=this.config,a=n.lowLatencyMode,r=n.maxLiveSyncPlaybackRate;if(a&&1!==r&&t.live){var o=this.targetLatency;if(null!==o){var s=i-o;if(s<Math.min(this.maxLatency,o+t.targetduration)&&s>.05&&this.forwardBufferLength>1){var u=Math.min(2,Math.max(1,r)),l=Math.round(2/(1+Math.exp(-.75*s-this.edgeStalled))*20)/20,d=Math.min(u,Math.max(1,l));this.changeMediaPlaybackRate(e,d)}else 1!==e.playbackRate&&0!==e.playbackRate&&this.changeMediaPlaybackRate(e,1)}}}}},this.hls=t,this.config=t.config,this.registerListeners()},[{key:"levelDetails",get:function(){var e;return(null==(e=this.hls)?void 0:e.latestLevelDetails)||null}},{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var e=this.config;if(void 0!==e.liveMaxLatencyDuration)return e.liveMaxLatencyDuration;var t=this.levelDetails;return t?e.liveMaxLatencyDurationCount*t.targetduration:0}},{key:"targetLatency",get:function(){var e=this.levelDetails;if(null===e||null===this.hls)return null;var t=e.holdBack,i=e.partHoldBack,n=e.targetduration,a=this.config,r=a.liveSyncDuration,o=a.liveSyncDurationCount,s=a.lowLatencyMode,u=this.hls.userConfig,l=s&&i||t;(this._targetLatencyUpdated||u.liveSyncDuration||u.liveSyncDurationCount||0===l)&&(l=void 0!==r?r:o*n);var d=n;return l+Math.min(this.stallCount*this.config.liveSyncOnStallIncrease,d)},set:function(e){this.stallCount=0,this.config.liveSyncDuration=e,this._targetLatencyUpdated=!0}},{key:"liveSyncPosition",get:function(){var e=this.estimateLiveEdge(),t=this.targetLatency;if(null===e||null===t)return null;var i=this.levelDetails;if(null===i)return null;var n=i.edge,a=e-t-this.edgeStalled,r=n-i.totalduration,o=n-(this.config.lowLatencyMode&&i.partTarget||i.targetduration);return Math.min(Math.max(r,a),o)}},{key:"drift",get:function(){var e=this.levelDetails;return null===e?1:e.drift}},{key:"edgeStalled",get:function(){var e=this.levelDetails;if(null===e)return 0;var t=3*(this.config.lowLatencyMode&&e.partTarget||e.targetduration);return Math.max(e.age-t,0)}},{key:"forwardBufferLength",get:function(){var e=this.media,t=this.levelDetails;if(!e||!t)return 0;var i=e.buffered.length;return(i?e.buffered.end(i-1):t.edge)-this.currentTime}},{key:"destroy",value:function(){this.unregisterListeners(),this.onMediaDetaching(),this.hls=null}},{key:"registerListeners",value:function(){var e=this.hls;e&&(e.on(zE.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(zE.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(zE.MANIFEST_LOADING,this.onManifestLoading,this),e.on(zE.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(zE.ERROR,this.onError,this))}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(zE.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(zE.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(zE.MANIFEST_LOADING,this.onManifestLoading,this),e.off(zE.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(zE.ERROR,this.onError,this))}},{key:"onMediaAttached",value:function(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.onTimeupdate)}},{key:"onMediaDetaching",value:function(){this.media&&(this.media.removeEventListener("timeupdate",this.onTimeupdate),this.media=null)}},{key:"onManifestLoading",value:function(){this._latency=null,this.stallCount=0}},{key:"onLevelUpdated",value:function(e,{details:t}){t.advanced&&this.onTimeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.onTimeupdate)}},{key:"onError",value:function(e,t){var i;t.details===BE.BUFFER_STALLED_ERROR&&(this.stallCount++,this.hls&&null!=(i=this.levelDetails)&&i.live&&this.hls.logger.warn("[latency-controller]: Stall detected, adjusting target latency"))}},{key:"changeMediaPlaybackRate",value:function(e,t){var i,n;e.playbackRate!==t&&(null==(i=this.hls)||i.logger.debug(`[latency-controller]: latency=${this.latency.toFixed(3)}, targetLatency=${null==(n=this.targetLatency)?void 0:n.toFixed(3)}, forwardBufferLength=${this.forwardBufferLength.toFixed(3)}: adjusting playback rate from ${e.playbackRate} to ${t}`),e.playbackRate=t)}},{key:"estimateLiveEdge",value:function(){var e=this.levelDetails;return null===e?null:e.edge+e.age}},{key:"computeLatency",value:function(){var e=this.estimateLiveEdge();return null===e?null:e-this.currentTime}}])}(),QL=function(){function e(t,i){var n;return u(this,e),(n=s(this,e,[t,"level-controller"]))._levels=[],n._firstLevel=-1,n._maxAutoLevel=-1,n._startLevel=void 0,n.currentLevel=null,n.currentLevelIndex=-1,n.manualLevelIndex=-1,n.steering=void 0,n.onParsedComplete=void 0,n.steering=i,n._registerListeners(),n}return y(e,Qx),m(e,[{key:"_registerListeners",value:function(){var e=this.hls;e.on(zE.MANIFEST_LOADING,this.onManifestLoading,this),e.on(zE.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(zE.LEVEL_LOADED,this.onLevelLoaded,this),e.on(zE.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(zE.FRAG_BUFFERED,this.onFragBuffered,this),e.on(zE.ERROR,this.onError,this)}},{key:"_unregisterListeners",value:function(){var e=this.hls;e.off(zE.MANIFEST_LOADING,this.onManifestLoading,this),e.off(zE.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(zE.LEVEL_LOADED,this.onLevelLoaded,this),e.off(zE.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(zE.FRAG_BUFFERED,this.onFragBuffered,this),e.off(zE.ERROR,this.onError,this)}},{key:"destroy",value:function(){this._unregisterListeners(),this.steering=null,this.resetLevels(),M(e,"destroy",this)([])}},{key:"stopLoad",value:function(){this._levels.forEach(e=>{e.loadError=0,e.fragmentError=0}),M(e,"stopLoad",this)([])}},{key:"resetLevels",value:function(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1}},{key:"onManifestLoading",value:function(e,t){this.resetLevels()}},{key:"onManifestLoaded",value:function(e,t){var i=this.hls.config.preferManagedMediaSource,n=[],a={},r={},o=!1,s=!1,u=!1;t.levels.forEach(e=>{var t=e.attrs,l=e.audioCodec,d=e.videoCodec;l&&(e.audioCodec=l=fP(l,i)||void 0),d&&(d=e.videoCodec=function(e){for(var t=e.split(","),i=0;i<t.length;i++){var n=t[i].split(".");n.length>2&&"avc1"===n[0]&&(t[i]=`avc1.${parseInt(n[1]).toString(16)}${("000"+parseInt(n[2]).toString(16)).slice(-4)}`)}return t.join(",")}(d));var h=e.width,c=e.height,m=e.unknownCodecs,f=(null==m?void 0:m.length)||0;if(o||(o=!(!h||!c)),s||(s=!!d),u||(u=!!l),f||l&&!this.isAudioSupported(l)||d&&!this.isVideoSupported(d))this.log(`Some or all CODECS not supported "${t.CODECS}"`);else{var v=t.CODECS,p=t["FRAME-RATE"],g=t["HDCP-LEVEL"],y=t["PATHWAY-ID"],b=t.RESOLUTION,w=t["VIDEO-RANGE"],k=`${`${y||"."}-`}${e.bitrate}-${b}-${p}-${v}-${w}-${g}`;if(a[k])if(a[k].uri===e.url||e.attrs["PATHWAY-ID"])a[k].addGroupId("audio",t.AUDIO),a[k].addGroupId("text",t.SUBTITLES);else{var S=r[k]+=1;e.attrs["PATHWAY-ID"]=new Array(S+1).join(".");var E=this.createLevel(e);a[k]=E,n.push(E)}else{var T=this.createLevel(e);a[k]=T,r[k]=1,n.push(T)}}}),this.filterAndSortMediaOptions(n,t,o,s,u)}},{key:"createLevel",value:function(e){var t=new _P(e),i=e.supplemental;if(null!=i&&i.videoCodec&&!this.isVideoSupported(i.videoCodec)){var n=new Error(`SUPPLEMENTAL-CODECS not supported "${i.videoCodec}"`);this.log(n.message),t.supportedResult=SP(n,[])}return t}},{key:"isAudioSupported",value:function(e){return sP(e,"audio",this.hls.config.preferManagedMediaSource)}},{key:"isVideoSupported",value:function(e){return sP(e,"video",this.hls.config.preferManagedMediaSource)}},{key:"filterAndSortMediaOptions",value:function(e,t,i,n,a){var r,o=[],s=[],u=e,l=(null==(r=t.stats)?void 0:r.parsing)||{};if((i||n)&&a&&(u=u.filter(({videoCodec:e,videoRange:t,width:i,height:n})=>{return(!!e||!(!i||!n))&&(!!(a=t)&&AP.indexOf(a)>-1);var a})),0===u.length)return Promise.resolve().then(()=>{if(this.hls){var e="no level with compatible codecs found in manifest",i=e;t.levels.length&&(i=`one or more CODECS in variant not supported: ${OP(t.levels.map(e=>e.attrs.CODECS).filter((e,t,i)=>i.indexOf(e)===t))}`,this.warn(i),e+=` (${i})`);var n=new Error(e);this.hls.trigger(zE.ERROR,{type:jE.MEDIA_ERROR,details:BE.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:n,reason:i})}}),void(l.end=performance.now());t.audioTracks&&ZL(o=t.audioTracks.filter(e=>!e.audioCodec||this.isAudioSupported(e.audioCodec))),t.subtitles&&ZL(s=t.subtitles);var d=u.slice(0);u.sort((e,t)=>{if(e.attrs["HDCP-LEVEL"]!==t.attrs["HDCP-LEVEL"])return(e.attrs["HDCP-LEVEL"]||"")>(t.attrs["HDCP-LEVEL"]||"")?1:-1;if(i&&e.height!==t.height)return e.height-t.height;if(e.frameRate!==t.frameRate)return e.frameRate-t.frameRate;if(e.videoRange!==t.videoRange)return AP.indexOf(e.videoRange)-AP.indexOf(t.videoRange);if(e.videoCodec!==t.videoCodec){var n=dP(e.videoCodec),a=dP(t.videoCodec);if(n!==a)return a-n}if(e.uri===t.uri&&e.codecSet!==t.codecSet){var r=hP(e.codecSet),o=hP(t.codecSet);if(r!==o)return o-r}return e.averageBitrate!==t.averageBitrate?e.averageBitrate-t.averageBitrate:0});var h=d[0];if(this.steering&&(u=this.steering.filterParsedLevels(u)).length!==d.length)for(var c=0;c<d.length;c++)if(d[c].pathwayId===u[0].pathwayId){h=d[c];break}this._levels=u;for(var m=0;m<u.length;m++)if(u[m]===h){var f;this._firstLevel=m;var v=h.bitrate,p=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${u.length} level(s) found, first bitrate: ${v}`),void 0===(null==(f=this.hls.userConfig)?void 0:f.abrEwmaDefaultEstimate)){var g=Math.min(v,this.hls.config.abrEwmaDefaultEstimateMax);g>p&&p===this.hls.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=g)}break}var y=a&&!n,b=this.hls.config,w=!(!b.audioStreamController||!b.audioTrackController),k={levels:u,audioTracks:o,subtitleTracks:s,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:a,video:n,altAudio:w&&!y&&o.some(e=>!!e.url)};l.end=performance.now(),this.hls.trigger(zE.MANIFEST_PARSED,k)}},{key:"levels",get:function(){return 0===this._levels.length?null:this._levels}},{key:"loadLevelObj",get:function(){return this.currentLevel}},{key:"level",get:function(){return this.currentLevelIndex},set:function(e){var t=this._levels;if(0!==t.length){if(e<0||e>=t.length){var i=new Error("invalid level idx"),n=e<0;if(this.hls.trigger(zE.ERROR,{type:jE.OTHER_ERROR,details:BE.LEVEL_SWITCH_ERROR,level:e,fatal:n,error:i,reason:i.message}),n)return;e=Math.min(e,t.length-1)}var a=this.currentLevelIndex,r=this.currentLevel,o=r?r.attrs["PATHWAY-ID"]:void 0,s=t[e],u=s.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=s,a!==e||!r||o!==u){this.log(`Switching to level ${e} (${s.height?s.height+"p ":""}${s.videoRange?s.videoRange+" ":""}${s.codecSet?s.codecSet+" ":""}@${s.bitrate})${u?" with Pathway "+u:""} from level ${a}${o?" with Pathway "+o:""}`);var l={level:e,attrs:s.attrs,details:s.details,bitrate:s.bitrate,averageBitrate:s.averageBitrate,maxBitrate:s.maxBitrate,realBitrate:s.realBitrate,width:s.width,height:s.height,codecSet:s.codecSet,audioCodec:s.audioCodec,videoCodec:s.videoCodec,audioGroups:s.audioGroups,subtitleGroups:s.subtitleGroups,loaded:s.loaded,loadError:s.loadError,fragmentError:s.fragmentError,name:s.name,id:s.id,uri:s.uri,url:s.url,urlId:0,audioGroupIds:s.audioGroupIds,textGroupIds:s.textGroupIds};this.hls.trigger(zE.LEVEL_SWITCHING,l);var d=s.details;if(!d||d.live){var h=this.switchParams(s.uri,null==r?void 0:r.details,d);this.loadPlaylist(h)}}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(e){this.manualLevelIndex=e,void 0===this._startLevel&&(this._startLevel=e),-1!==e&&(this.level=e)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(e){this._firstLevel=e}},{key:"startLevel",get:function(){if(void 0===this._startLevel){var e=this.hls.config.startLevel;return void 0!==e?e:this.hls.firstAutoLevel}return this._startLevel},set:function(e){this._startLevel=e}},{key:"pathways",get:function(){return this.steering?this.steering.pathways():[]}},{key:"pathwayPriority",get:function(){return this.steering?this.steering.pathwayPriority:null},set:function(e){if(this.steering){var t=this.steering.pathways(),i=e.filter(e=>-1!==t.indexOf(e));if(e.length<1)return void this.warn(`pathwayPriority ${e} should contain at least one pathway from list: ${t}`);this.steering.pathwayPriority=i}}},{key:"onError",value:function(e,t){!t.fatal&&t.context&&t.context.type===HE&&t.context.level===this.level&&this.checkRetry(t)}},{key:"onFragBuffered",value:function(e,{frag:t}){if(void 0!==t&&t.type===KE){var i=t.elementaryStreams;if(!Object.keys(i).some(e=>!!i[e]))return;var n=this._levels[t.level];null!=n&&n.loadError&&(this.log(`Resetting level error count of ${n.loadError} on frag buffered`),n.loadError=0)}}},{key:"onLevelLoaded",value:function(e,t){var i,n,a=t.level,r=t.details,o=t.levelInfo;if(!o)return this.warn(`Invalid level index ${a}`),void(null!=(n=t.deliveryDirectives)&&n.skip&&(r.deltaUpdateFailed=!0));if(o===this.currentLevel||t.withoutMultiVariant){0===o.fragmentError&&(o.loadError=0);var s=o.details;s===t.details&&s.advanced&&(s=void 0),this.playlistLoaded(a,t,s)}else null!=(i=t.deliveryDirectives)&&i.skip&&(r.deltaUpdateFailed=!0)}},{key:"loadPlaylist",value:function(t){M(e,"loadPlaylist",this)([]),this.shouldLoadPlaylist(this.currentLevel)&&this.scheduleLoading(this.currentLevel,t)}},{key:"loadingPlaylist",value:function(t,i){M(e,"loadingPlaylist",this)([t,i]);var n=this.getUrlWithDirectives(t.uri,i),a=this.currentLevelIndex,r=t.attrs["PATHWAY-ID"],o=t.details,s=null==o?void 0:o.age;this.log(`Loading level index ${a}${void 0!==(null==i?void 0:i.msn)?" at sn "+i.msn+" part "+i.part:""}${r?" Pathway "+r:""}${s&&o.live?" age "+s.toFixed(1)+(o.type&&" "+o.type||""):""} ${n}`),this.hls.trigger(zE.LEVEL_LOADING,{url:n,level:a,levelInfo:t,pathwayId:t.attrs["PATHWAY-ID"],id:0,deliveryDirectives:i||null})}},{key:"nextLoadLevel",get:function(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(e){this.level=e,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=e)}},{key:"removeLevel",value:function(e){var t;if(1!==this._levels.length){var i=this._levels.filter((t,i)=>i!==e||(this.steering&&this.steering.removeLevel(t),t===this.currentLevel&&(this.currentLevel=null,this.currentLevelIndex=-1,t.details&&t.details.fragments.forEach(e=>e.level=-1)),!1));VA(i),this._levels=i,this.currentLevelIndex>-1&&null!=(t=this.currentLevel)&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.manualLevelIndex>-1&&(this.manualLevelIndex=this.currentLevelIndex);var n=i.length-1;this._firstLevel=Math.min(this._firstLevel,n),this._startLevel&&(this._startLevel=Math.min(this._startLevel,n)),this.hls.trigger(zE.LEVELS_UPDATED,{levels:i})}}},{key:"onLevelsUpdated",value:function(e,{levels:t}){this._levels=t}},{key:"checkMaxAutoUpdated",value:function(){var e=this.hls,t=e.autoLevelCapping,i=e.maxAutoLevel,n=e.maxHdcpLevel;this._maxAutoLevel!==i&&(this._maxAutoLevel=i,this.hls.trigger(zE.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:t,levels:this.levels,maxAutoLevel:i,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:n}))}}])}();function ZL(e){var t={};e.forEach(e=>{var i=e.groupId||"";e.id=t[i]=t[i]||0,t[i]++})}function e_(){return self.SourceBuffer||self.WebKitSourceBuffer}function t_(){if(!lT())return!1;var e=e_();return!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove}var i_=function(){function e(t,i,n){var a;return u(this,e),(a=s(this,e,[t,i,n,"stream-controller",KE])).audioCodecSwap=!1,a.level=-1,a._forceStartLoad=!1,a._hasEnoughToStart=!1,a.altAudio=0,a.audioOnly=!1,a.fragPlaying=null,a.fragLastKbps=0,a.couldBacktrack=!1,a.backtrackFragment=null,a.audioCodecSwitch=!1,a.videoBuffer=null,a.onMediaPlaying=()=>{a.tick()},a.onMediaSeeked=()=>{var e=a.media,t=e?e.currentTime:null;if(null!==t&&WE(t)&&(a.log(`Media seeked to ${t.toFixed(3)}`),a.getBufferedFrag(t))){var i=a.getFwdBufferInfoAtPos(e,t,KE,0);null!==i&&0!==i.len?a.tick():a.warn(`Main forward buffer length at ${t} on "seeked" event ${i?i.len:"empty"})`)}},a.registerListeners(),a}return y(e,vD),m(e,[{key:"registerListeners",value:function(){M(e,"registerListeners",this)([]);var t=this.hls;t.on(zE.MANIFEST_PARSED,this.onManifestParsed,this),t.on(zE.LEVEL_LOADING,this.onLevelLoading,this),t.on(zE.LEVEL_LOADED,this.onLevelLoaded,this),t.on(zE.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.on(zE.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(zE.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(zE.BUFFER_CREATED,this.onBufferCreated,this),t.on(zE.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(zE.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(zE.FRAG_BUFFERED,this.onFragBuffered,this)}},{key:"unregisterListeners",value:function(){M(e,"unregisterListeners",this)([]);var t=this.hls;t.off(zE.MANIFEST_PARSED,this.onManifestParsed,this),t.off(zE.LEVEL_LOADED,this.onLevelLoaded,this),t.off(zE.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.off(zE.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(zE.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(zE.BUFFER_CREATED,this.onBufferCreated,this),t.off(zE.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(zE.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(zE.FRAG_BUFFERED,this.onFragBuffered,this)}},{key:"onHandlerDestroying",value:function(){this.onMediaPlaying=this.onMediaSeeked=null,this.unregisterListeners(),M(e,"onHandlerDestroying",this)([])}},{key:"startLoad",value:function(e,t){if(this.levels){var i=this.lastCurrentTime,n=this.hls;if(this.stopLoad(),this.setInterval(100),this.level=-1,!this.startFragRequested){var a=n.startLevel;-1===a&&(n.config.testBandwidth&&this.levels.length>1?(a=0,this.bitrateTest=!0):a=n.firstAutoLevel),n.nextLoadLevel=a,this.level=n.loadLevel,this._hasEnoughToStart=!!t}i>0&&-1===e&&!t&&(this.log(`Override startPosition with lastCurrentTime @${i.toFixed(3)}`),e=i),this.state=aD,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}else this._forceStartLoad=!0,this.state=nD}},{key:"stopLoad",value:function(){this._forceStartLoad=!1,M(e,"stopLoad",this)([])}},{key:"doTick",value:function(){switch(this.state){case fD:var e=this.levels,t=this.level,i=null==e?void 0:e[t],n=null==i?void 0:i.details;if(n&&(!n.live||this.levelLastLoaded===i&&!this.waitForLive(i))){if(this.waitForCdnTuneIn(n))break;this.state=aD;break}if(this.hls.nextLoadLevel!==this.level){this.state=aD;break}break;case sD:this.checkRetryDate()}this.state===aD&&this.doTickIdle(),this.onTickEnd()}},{key:"onTickEnd",value:function(){var t;M(e,"onTickEnd",this)([]),null!=(t=this.media)&&t.readyState&&!1===this.media.seeking&&(this.lastCurrentTime=this.media.currentTime),this.checkFragmentChanged()}},{key:"doTickIdle",value:function(){var e=this.hls,t=this.levelLastLoaded,i=this.levels,n=this.media;if(null!==t&&(n||this.primaryPrefetch||!this.startFragRequested&&e.config.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)){var a=this.buffering?e.nextLoadLevel:e.loadLevel;if(null!=i&&i[a]){var r=i[a],o=this.getMainFwdBufferInfo();if(null!==o){var s=this.getLevelDetails();if(s&&this._streamEnded(o,s)){var u={};return 2===this.altAudio&&(u.type="video"),this.hls.trigger(zE.BUFFER_EOS,u),void(this.state=hD)}if(this.buffering){e.loadLevel!==a&&-1===e.manualLevel&&this.log(`Adapting to level ${a} from level ${this.level}`),this.level=e.nextLoadLevel=a;var l=r.details;if(!l||this.state===fD||this.waitForLive(r))return this.level=a,this.state=fD,void(this.startFragRequested=!1);var d=o.len,h=this.getMaxBufferLength(r.maxBitrate);if(!(d>=h)){this.backtrackFragment&&this.backtrackFragment.start>o.end&&(this.backtrackFragment=null);var c=this.backtrackFragment?this.backtrackFragment.start:o.end,m=this.getNextFragment(c,l);if(this.couldBacktrack&&!this.fragPrevious&&m&&DT(m)&&this.fragmentTracker.getState(m)!==yM){var f,v=(null!=(f=this.backtrackFragment)?f:m).sn-l.startSN,p=l.fragments[v-1];p&&m.cc===p.cc&&(m=p,this.fragmentTracker.removeFragment(p))}else this.backtrackFragment&&o.len&&(this.backtrackFragment=null);if(m&&this.isLoopLoading(m,c)){if(!m.gap){var g=this.audioOnly&&!this.altAudio?TT:PT,y=(g===PT?this.videoBuffer:this.mediaBuffer)||this.media;y&&this.afterBufferFlushed(y,g,KE)}m=this.getNextFragmentLoopLoading(m,l,o,KE,h)}m&&(this.exceedsMaxBuffer(o,h,m)||(!m.initSegment||m.initSegment.data||this.bitrateTest||(m=m.initSegment),this.loadFragment(m,r,c)))}}}}}}},{key:"loadFragment",value:function(t,i,n){var a=this.fragmentTracker.getState(t);a===vM||a===gM?DT(t)?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,i)):M(e,"loadFragment",this)([t,i,n]):this._loadInitSegment(t,i):this.clearTrackerIfNeeded(t)}},{key:"getBufferedFrag",value:function(e){return this.fragmentTracker.getBufferedFrag(e,KE)}},{key:"followingBufferedFrag",value:function(e){return e?this.getBufferedFrag(e.end+.5):null}},{key:"immediateLevelSwitch",value:function(){var t;(this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY),0!==this.altAudio)&&(((null==(t=this.getLevelDetails())?void 0:t.fragmentStart)||0)>this.lastCurrentTime&&M(e,"flushMainBuffer",this)([0,Number.POSITIVE_INFINITY,"audio"]))}},{key:"nextLevelSwitch",value:function(){var e=this.levels,t=this.media;if(null!=t&&t.readyState){var i,n=this.getAppendedFrag(t.currentTime);n&&n.start>1&&this.flushMainBuffer(0,n.start-1);var a=this.getLevelDetails();if(null!=a&&a.live){var r=this.getMainFwdBufferInfo();if(!r||r.len<2*a.targetduration)return}if(!t.paused&&e){var o=e[this.hls.nextLoadLevel],s=this.fragLastKbps;i=s&&this.fragCurrent?this.fragCurrent.duration*o.maxBitrate/(1e3*s)+1:0}else i=0;var u=this.getBufferedFrag(t.currentTime+i);if(u){var l=this.followingBufferedFrag(u);if(l){this.abortCurrentFrag();var d=l.maxStartPTS?l.maxStartPTS:l.start,h=l.duration,c=Math.max(u.end,d+Math.min(Math.max(h-this.config.maxFragLookUpTolerance,h*(this.couldBacktrack?.5:.125)),h*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(c,Number.POSITIVE_INFINITY)}}}}},{key:"abortCurrentFrag",value:function(){var e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case rD:case oD:case sD:case lD:case dD:this.state=aD}this.nextLoadPosition=this.getLoadPosition()}},{key:"flushMainBuffer",value:function(t,i){M(e,"flushMainBuffer",this)([t,i,2===this.altAudio?"video":null])}},{key:"onMediaAttached",value:function(t,i){M(e,"onMediaAttached",this)([t,i]);var n=i.media;eD(n,"playing",this.onMediaPlaying),eD(n,"seeked",this.onMediaSeeked)}},{key:"onMediaDetaching",value:function(t,i){var n=this.media;n&&(tD(n,"playing",this.onMediaPlaying),tD(n,"seeked",this.onMediaSeeked)),this.videoBuffer=null,this.fragPlaying=null,M(e,"onMediaDetaching",this)([t,i]),!!i.transferMedia||(this._hasEnoughToStart=!1)}},{key:"onManifestLoading",value:function(){M(e,"onManifestLoading",this)([]),this.log("Trigger BUFFER_RESET"),this.hls.trigger(zE.BUFFER_RESET,void 0),this.couldBacktrack=!1,this.fragLastKbps=0,this.fragPlaying=this.backtrackFragment=null,this.altAudio=0,this.audioOnly=!1}},{key:"onManifestParsed",value:function(e,t){for(var i,n,a=!1,r=!1,o=0;o<t.levels.length;o++){var s=t.levels[o].audioCodec;s&&(a=a||-1!==s.indexOf("mp4a.40.2"),r=r||-1!==s.indexOf("mp4a.40.5"))}this.audioCodecSwitch=a&&r&&!("function"==typeof(null==(n=e_())||null==(i=n.prototype)?void 0:i.changeType)),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1}},{key:"onLevelLoading",value:function(e,t){if(this.levels&&this.state===aD){var i=t.levelInfo;(!i.details||i.details.live&&(this.levelLastLoaded!==i||i.details.expired)||this.waitForCdnTuneIn(i.details))&&(this.state=fD)}}},{key:"onLevelLoaded",value:function(e,t){var i,n=this.levels,a=this.startFragRequested,r=t.level,o=t.details,s=o.totalduration;if(n){this.log(`Level ${r} loaded [${o.startSN},${o.endSN}]${o.lastPartSn?`[part-${o.lastPartSn}-${o.lastPartIndex}]`:""}, cc [${o.startCC}, ${o.endCC}] duration:${s}`);var u=t.levelInfo,l=this.fragCurrent;!l||this.state!==oD&&this.state!==sD||l.level!==t.level&&l.loader&&this.abortCurrentFrag();var d=0;if(o.live||null!=(i=u.details)&&i.live){var h;if(this.checkLiveUpdate(o),o.deltaUpdateFailed)return;d=this.alignPlaylists(o,u.details,null==(h=this.levelLastLoaded)?void 0:h.details)}if(u.details=o,this.levelLastLoaded=u,a||this.setStartPosition(o,d),this.hls.trigger(zE.LEVEL_UPDATED,{details:o,level:r}),this.state===fD){if(this.waitForCdnTuneIn(o))return;this.state=aD}a&&o.live&&this.synchronizeToLiveEdge(o),this.tick()}else this.warn(`Levels were reset while loading level ${r}`)}},{key:"synchronizeToLiveEdge",value:function(e){var t=this.config,i=this.media;if(i){var n=this.hls.liveSyncPosition,a=this.getLoadPosition(),r=e.fragmentStart,o=e.edge,s=a>=r-t.maxFragLookUpTolerance&&a<=o;if(null!==n&&i.duration>n&&(a<n||!s)){var u=void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;if((!s&&i.readyState<4||a<o-u)&&(this._hasEnoughToStart||(this.nextLoadPosition=n),i.readyState))if(this.warn(`Playback: ${a.toFixed(3)} is located too far from the end of live sliding playlist: ${o}, reset currentTime to : ${n.toFixed(3)}`),"buffered"===this.config.liveSyncMode){var l,d=WM.bufferInfo(i,n,0);if(null==(l=d.buffered)||!l.length)return void(i.currentTime=n);if(d.start<=a)return void(i.currentTime=n);var h=WM.bufferedInfo(d.buffered,a,0).nextStart;h&&(i.currentTime=h)}else i.currentTime=n}}}},{key:"_handleFragmentLoadProgress",value:function(e){var t,i=e.frag,n=e.part,a=e.payload,r=this.levels;if(r){var o=r[i.level];if(o){var s=o.details;if(!s)return this.warn(`Dropping fragment ${i.sn} of level ${i.level} after level details were reset`),void this.fragmentTracker.removeFragment(i);var u=o.videoCodec,l=s.PTSKnown||!s.live,d=null==(t=i.initSegment)?void 0:t.data,h=this._getAudioCodec(o),c=this.transmuxer=this.transmuxer||new qx(this.hls,KE,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),m=n?n.index:-1,f=-1!==m,v=new FM(i.level,i.sn,i.stats.chunkCount,a.byteLength,m,f),p=this.initPTS[i.cc];c.push(a,d,h,u,i,n,s.totalduration,l,v,p)}else this.warn(`Level ${i.level} not found on progress`)}else this.warn(`Levels were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`)}},{key:"onAudioTrackSwitching",value:function(e,t){var i=this.hls,n=0!==this.altAudio;if(HP(t.url,i))this.altAudio=1;else{if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var a=this.fragCurrent;a&&(this.log("Switching to main audio track, cancel main fragment load"),a.abortRequests(),this.fragmentTracker.removeFragment(a)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();if(n)return this.altAudio=0,this.fragmentTracker.removeAllFragments(),i.once(zE.BUFFER_FLUSHED,()=>{this.hls&&this.hls.trigger(zE.AUDIO_TRACK_SWITCHED,t)}),void i.trigger(zE.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null});i.trigger(zE.AUDIO_TRACK_SWITCHED,t)}}},{key:"onAudioTrackSwitched",value:function(e,t){var i=HP(t.url,this.hls);if(i){var n=this.videoBuffer;n&&this.mediaBuffer!==n&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=n)}this.altAudio=i?2:0,this.tick()}},{key:"onBufferCreated",value:function(e,t){var i,n,a=t.tracks,r=!1;for(var o in a){var s=a[o];if("main"===s.id){if(n=o,i=s,"video"===o){var u=a[o];u&&(this.videoBuffer=u.buffer)}}else r=!0}r&&i?(this.log(`Alternate track found, use ${n}.buffered to schedule main fragment loading`),this.mediaBuffer=i.buffer):this.mediaBuffer=this.media}},{key:"onFragBuffered",value:function(e,t){var i=t.frag,n=t.part,a=i.type===KE;if(a){if(this.fragContextChanged(i))return this.warn(`Fragment ${i.sn}${n?" p: "+n.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}`),void(this.state===dD&&(this.state=aD));var r=n?n.stats:i.stats;this.fragLastKbps=Math.round(8*r.total/(r.buffering.end-r.loading.first)),DT(i)&&(this.fragPrevious=i),this.fragBufferedComplete(i,n)}var o=this.media;o&&(!this._hasEnoughToStart&&WM.getBuffered(o).length&&(this._hasEnoughToStart=!0,this.seekToStartPos()),a&&this.tick())}},{key:"hasEnoughToStart",get:function(){return this._hasEnoughToStart}},{key:"onError",value:function(e,t){var i;if(t.fatal)this.state=cD;else switch(t.details){case BE.FRAG_GAP:case BE.FRAG_PARSING_ERROR:case BE.FRAG_DECRYPT_ERROR:case BE.FRAG_LOAD_ERROR:case BE.FRAG_LOAD_TIMEOUT:case BE.KEY_LOAD_ERROR:case BE.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(KE,t);break;case BE.LEVEL_LOAD_ERROR:case BE.LEVEL_LOAD_TIMEOUT:case BE.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==fD||(null==(i=t.context)?void 0:i.type)!==HE||(this.state=aD);break;case BE.BUFFER_ADD_CODEC_ERROR:case BE.BUFFER_APPEND_ERROR:if("main"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)&&this.resetLoadingState();break;case BE.BUFFER_FULL_ERROR:if("main"!==t.parent)return;if(this.reduceLengthAndFlushBuffer(t))!this.config.interstitialsController&&this.config.assetPlayerId?this._hasEnoughToStart=!0:this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case BE.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}},{key:"onFragLoadEmergencyAborted",value:function(){this.state=aD,this._hasEnoughToStart||(this.startFragRequested=!1,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate()}},{key:"onBufferFlushed",value:function(e,{type:t}){if(t!==TT||!this.altAudio){var i=(t===PT?this.videoBuffer:this.mediaBuffer)||this.media;i&&(this.afterBufferFlushed(i,t,KE),this.tick())}}},{key:"onLevelsUpdated",value:function(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level,-1===this.level&&this.resetWhenMissingContext(this.fragCurrent)),this.levels=t.levels}},{key:"swapAudioCodec",value:function(){this.audioCodecSwap=!this.audioCodecSwap}},{key:"seekToStartPos",value:function(){var e=this.media;if(e){var t=e.currentTime,i=this.startPosition;if(i>=0&&t<i){if(e.seeking)return void this.log(`could not seek to ${i}, already seeking at ${t}`);var n=this.timelineOffset;n&&i&&(i+=n);var a=this.getLevelDetails(),r=WM.getBuffered(e),o=r.length?r.start(0):0,s=o-i,u=Math.max(this.config.maxBufferHole,this.config.maxFragLookUpTolerance);(this.config.startOnSegmentBoundary||s>0&&(s<u||this.loadingParts&&s<2*((null==a?void 0:a.partTarget)||0)))&&(this.log(`adjusting start position by ${s} to match buffer start`),i+=s,this.startPosition=i),t<i&&(this.log(`seek to target start position ${i} from current time ${t} buffer start ${o}`),e.currentTime=i)}}}},{key:"_getAudioCodec",value:function(e){var t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t=-1!==t.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),t}},{key:"_loadBitrateTestFrag",value:function(e,t){e.bitrateTest=!0,this._doFragLoad(e,t).then(e=>{var i=this.hls,n=null==e?void 0:e.frag;if(n&&!this.fragContextChanged(n)){t.fragmentError=0,this.state=aD,this.startFragRequested=!1,this.bitrateTest=!1;var a=n.stats;a.parsing.start=a.parsing.end=a.buffering.start=a.buffering.end=self.performance.now(),i.trigger(zE.FRAG_LOADED,e),n.bitrateTest=!1}}).catch(t=>{this.state!==nD&&this.state!==cD&&(this.warn(t),this.resetFragmentLoading(e))})}},{key:"_handleTransmuxComplete",value:function(e){var t=this.playlistType,i=this.hls,n=e.remuxResult,a=e.chunkMeta,r=this.getCurrentContext(a);if(r){var o=r.frag,s=r.part,u=r.level,l=n.video,d=n.text,h=n.id3,c=n.initSegment,m=u.details,f=this.altAudio?void 0:n.audio;if(this.fragContextChanged(o))this.fragmentTracker.removeFragment(o);else{if(this.state=lD,c){var v=c.tracks;if(v){var p=o.initSegment||o;if(this.unhandledEncryptionError(c,o))return;this._bufferInitSegment(u,v,p,a),i.trigger(zE.FRAG_PARSING_INIT_SEGMENT,{frag:p,id:t,tracks:v})}var g=c.initPTS,y=c.timescale,b=this.initPTS[o.cc];if(WE(g)&&(!b||b.baseTime!==g||b.timescale!==y)){var w=c.trackId;this.initPTS[o.cc]={baseTime:g,timescale:y,trackId:w},i.trigger(zE.INIT_PTS_FOUND,{frag:o,id:t,initPTS:g,timescale:y,trackId:w})}}if(l&&m){f&&"audiovideo"===l.type&&this.logMuxedErr(o);var k=m.fragments[o.sn-1-m.startSN],S=o.sn===m.startSN,E=!k||o.cc>k.cc;if(!1!==n.independent){var T=l.startPTS,P=l.endPTS,M=l.startDTS,A=l.endDTS;if(s)s.elementaryStreams[l.type]={startPTS:T,endPTS:P,startDTS:M,endDTS:A};else if(l.firstKeyFrame&&l.independent&&1===a.id&&!E&&(this.couldBacktrack=!0),l.dropped&&l.independent){var D=this.getMainFwdBufferInfo(),x=(D?D.end:this.getLoadPosition())+this.config.maxBufferHole,C=l.firstKeyFramePTS?l.firstKeyFramePTS:T;if(!S&&x<C-this.config.maxBufferHole&&!E)return void this.backtrack(o);E&&(o.gap=!0),o.setElementaryStreamInfo(l.type,o.start,P,o.start,A,!0)}else S&&T-(m.appliedTimelineOffset||0)>2&&(o.gap=!0);o.setElementaryStreamInfo(l.type,T,P,M,A),this.backtrackFragment&&(this.backtrackFragment=o),this.bufferFragmentData(l,o,s,a,S||E)}else{if(!S&&!E)return void this.backtrack(o);o.gap=!0}}if(f){var I=f.startPTS,L=f.endPTS,_=f.startDTS,R=f.endDTS;s&&(s.elementaryStreams[TT]={startPTS:I,endPTS:L,startDTS:_,endDTS:R}),o.setElementaryStreamInfo(TT,I,L,_,R),this.bufferFragmentData(f,o,s,a)}if(m&&null!=h&&h.samples.length){var F={id:t,frag:o,details:m,samples:h.samples};i.trigger(zE.FRAG_PARSING_METADATA,F)}if(m&&d){var O={id:t,frag:o,details:m,samples:d.samples};i.trigger(zE.FRAG_PARSING_USERDATA,O)}}}else this.resetWhenMissingContext(a)}},{key:"logMuxedErr",value:function(e){this.warn(`${DT(e)?"Media":"Init"} segment with muxed audiovideo where only video expected: ${e.url}`)}},{key:"_bufferInitSegment",value:function(e,t,i,n){if(this.state===lD){this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&(delete t.audio,t.audiovideo&&this.logMuxedErr(i));var a=t.audio,r=t.video,o=t.audiovideo;if(a){var s=e.audioCodec,u=vP(a.codec,s);"mp4a"===u&&(u="mp4a.40.5");var l=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){u&&(u=-1!==u.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5");var d=a.metadata;d&&"channelCount"in d&&1!==(d.channelCount||1)&&-1===l.indexOf("firefox")&&(u="mp4a.40.5")}u&&-1!==u.indexOf("mp4a.40.5")&&-1!==l.indexOf("android")&&"audio/mpeg"!==a.container&&(u="mp4a.40.2",this.log(`Android: force audio codec to ${u}`)),s&&s!==u&&this.log(`Swapping manifest audio codec "${s}" for "${u}"`),a.levelCodec=u,a.id=KE,this.log(`Init audio buffer, container:${a.container}, codecs[selected/level/parsed]=[${u||""}/${s||""}/${a.codec}]`),delete t.audiovideo}if(r){r.levelCodec=e.videoCodec,r.id=KE;var h=r.codec;if(4===(null==h?void 0:h.length))switch(h){case"hvc1":case"hev1":r.codec="hvc1.1.6.L120.90";break;case"av01":r.codec="av01.0.04M.08";break;case"avc1":r.codec="avc1.42e01e"}this.log(`Init video buffer, container:${r.container}, codecs[level/parsed]=[${e.videoCodec||""}/${h}]${r.codec!==h?" parsed-corrected="+r.codec:""}${r.supplemental?" supplemental="+r.supplemental:""}`),delete t.audiovideo}o&&(this.log(`Init audiovideo buffer, container:${o.container}, codecs[level/parsed]=[${e.codecs}/${o.codec}]`),delete t.video,delete t.audio);var c=Object.keys(t);if(c.length){if(this.hls.trigger(zE.BUFFER_CODECS,t),!this.hls)return;c.forEach(e=>{var a=t[e].initSegment;null!=a&&a.byteLength&&this.hls.trigger(zE.BUFFER_APPENDING,{type:e,data:a,frag:i,part:null,chunkMeta:n,parent:i.type})})}this.tickImmediate()}}},{key:"getMainFwdBufferInfo",value:function(){var e=this.mediaBuffer&&2===this.altAudio?this.mediaBuffer:this.media;return this.getFwdBufferInfo(e,KE)}},{key:"maxBufferLength",get:function(){var e=this.levels,t=this.level,i=null==e?void 0:e[t];return i?this.getMaxBufferLength(i.maxBitrate):this.config.maxBufferLength}},{key:"backtrack",value:function(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=aD}},{key:"checkFragmentChanged",value:function(){var e=this.media,t=null;if(e&&e.readyState>1&&!1===e.seeking){var i=e.currentTime;if(WM.isBuffered(e,i)?t=this.getAppendedFrag(i):WM.isBuffered(e,i+.1)&&(t=this.getAppendedFrag(i+.1)),t){this.backtrackFragment=null;var n=this.fragPlaying,a=t.level;n&&t.sn===n.sn&&n.level===a||(this.fragPlaying=t,this.hls.trigger(zE.FRAG_CHANGED,{frag:t}),n&&n.level===a||this.hls.trigger(zE.LEVEL_SWITCHED,{level:a}))}}}},{key:"nextLevel",get:function(){var e=this.nextBufferedFrag;return e?e.level:-1}},{key:"currentFrag",get:function(){var e;if(this.fragPlaying)return this.fragPlaying;var t=(null==(e=this.media)?void 0:e.currentTime)||this.lastCurrentTime;return WE(t)?this.getAppendedFrag(t):null}},{key:"currentProgramDateTime",get:function(){var e,t=(null==(e=this.media)?void 0:e.currentTime)||this.lastCurrentTime;if(WE(t)){var i=this.getLevelDetails(),n=this.currentFrag||(i?KP(null,i.fragments,t):null);if(n){var a=n.programDateTime;if(null!==a){var r=a+1e3*(t-n.start);return new Date(r)}}}return null}},{key:"currentLevel",get:function(){var e=this.currentFrag;return e?e.level:-1}},{key:"nextBufferedFrag",get:function(){var e=this.currentFrag;return e?this.followingBufferedFrag(e):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}])}(),n_=function(){function e(t,i){var n;return u(this,e),(n=s(this,e,["key-loader",i])).config=void 0,n.keyIdToKeyInfo={},n.emeController=null,n.config=t,n}return y(e,iT),m(e,[{key:"abort",value:function(e){for(var t in this.keyIdToKeyInfo){var i=this.keyIdToKeyInfo[t].loader;if(i){var n;if(e&&e!==(null==(n=i.context)?void 0:n.frag.type))return;i.abort()}}}},{key:"detach",value:function(){for(var e in this.keyIdToKeyInfo){var t=this.keyIdToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyIdToKeyInfo[e]}}},{key:"destroy",value:function(){for(var e in this.detach(),this.keyIdToKeyInfo){var t=this.keyIdToKeyInfo[e].loader;t&&t.destroy()}this.keyIdToKeyInfo={}}},{key:"createKeyLoadError",value:function(e,t=BE.KEY_LOAD_ERROR,i,n,a){return new _M({type:jE.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:a,error:i,networkDetails:n})}},{key:"loadClear",value:function(e,t,i){var n=this;if(this.emeController&&this.config.emeEnabled&&!this.emeController.getSelectedKeySystemFormats().length){if(t.length)for(var a,r=function(){var a=t[o];if(e.cc<=a.cc&&(!DT(e)||!DT(a)||e.sn<a.sn)||!i&&o==s-1)return{v:n.emeController.selectKeySystemFormat(a).then(e=>{if(n.emeController){a.setKeyFormat(e);var t=dA(e);return t?n.emeController.getKeySystemAccess([t]):void 0}})}},o=0,s=t.length;o<s;o++)if(a=r())return a.v;if(this.config.requireKeySystemAccessOnStart){var u=cA(this.config);if(u.length)return this.emeController.getKeySystemAccess(u)}}return null}},{key:"load",value:function(e){return!e.decryptdata&&e.encrypted&&this.emeController&&this.config.emeEnabled?this.emeController.selectKeySystemFormat(e).then(t=>this.loadInternal(e,t)):this.loadInternal(e)}},{key:"loadInternal",value:function(e,t){var i,n;t&&e.setKeyFormat(t);var a=e.decryptdata;if(!a){var r=new Error(t?`Expected frag.decryptdata to be defined after setting format ${t}`:`Missing decryption data on fragment in onKeyLoading (emeEnabled with controller: ${this.emeController&&this.config.emeEnabled})`);return Promise.reject(this.createKeyLoadError(e,BE.KEY_LOAD_ERROR,r))}var o=a.uri;if(!o)return Promise.reject(this.createKeyLoadError(e,BE.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${o}"`)));var s=a_(a),u=this.keyIdToKeyInfo[s];if(null!=(i=u)&&i.decryptdata.key)return a.key=u.decryptdata.key,Promise.resolve({frag:e,keyInfo:u});if(this.emeController&&null!=(n=u)&&n.keyLoadPromise)switch(this.emeController.getKeyStatus(u.decryptdata)){case"usable":case"usable-in-future":return u.keyLoadPromise.then(t=>{var i=t.keyInfo;return a.key=i.decryptdata.key,{frag:e,keyInfo:i}})}switch(this.log(`${this.keyIdToKeyInfo[s]?"Rel":"L"}oading${a.keyId?" keyId: "+cT(a.keyId):""} URI: ${a.uri} from ${e.type} ${e.level}`),u=this.keyIdToKeyInfo[s]={decryptdata:a,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},a.method){case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return"identity"===a.keyFormat?this.loadKeyHTTP(u,e):this.loadKeyEME(u,e);case"AES-128":case"AES-256":case"AES-256-CTR":return this.loadKeyHTTP(u,e);default:return Promise.reject(this.createKeyLoadError(e,BE.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${a.method}"`)))}}},{key:"loadKeyEME",value:function(e,t){var i={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){var n;if(!e.decryptdata.keyId&&null!=(n=t.initSegment)&&n.data){var a=function(e){var t=[];return XT(e,e=>t.push(e.subarray(8,24))),t}(t.initSegment.data);if(a.length){var r=a[0];r.some(e=>0!==e)?(this.log(`Using keyId found in init segment ${cT(r)}`),gA.setKeyIdForUri(e.decryptdata.uri,r)):(r=gA.addKeyIdForUri(e.decryptdata.uri),this.log(`Generating keyId to patch media ${cT(r)}`)),e.decryptdata.keyId=r}}if(!e.decryptdata.keyId&&!DT(t))return Promise.resolve(i);var o=this.emeController.loadKey(i);return(e.keyLoadPromise=o.then(t=>(e.mediaKeySessionContext=t,i))).catch(i=>{throw e.keyLoadPromise=null,"data"in i&&(i.data.frag=t),i})}return Promise.resolve(i)}},{key:"loadKeyHTTP",value:function(e,t){var i=this.config,n=new(0,i.loader)(i);return t.keyLoader=e.loader=n,e.keyLoadPromise=new Promise((a,r)=>{var o={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},s=i.keyLoadPolicy.default,u={loadPolicy:s,timeout:s.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},l={onSuccess:(e,t,i,n)=>{var o=i.frag,s=i.keyInfo,u=a_(s.decryptdata);if(!o.decryptdata||s!==this.keyIdToKeyInfo[u])return r(this.createKeyLoadError(o,BE.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),n));s.decryptdata.key=o.decryptdata.key=new Uint8Array(e.data),o.keyLoader=null,s.loader=null,a({frag:o,keyInfo:s})},onError:(e,i,n,a)=>{this.resetLoader(i),r(this.createKeyLoadError(t,BE.KEY_LOAD_ERROR,new Error(`HTTP Error ${e.code} loading key ${e.text}`),n,tT({url:o.url,data:void 0},e)))},onTimeout:(e,i,n)=>{this.resetLoader(i),r(this.createKeyLoadError(t,BE.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),n))},onAbort:(e,i,n)=>{this.resetLoader(i),r(this.createKeyLoadError(t,BE.INTERNAL_ABORTED,new Error("key loading aborted"),n))}};n.load(o,u,l)})}},{key:"resetLoader",value:function(e){var t=e.frag,i=e.keyInfo,n=e.url,a=i.loader;t.keyLoader===a&&(t.keyLoader=null,i.loader=null);var r=a_(i.decryptdata)||n;delete this.keyIdToKeyInfo[r],a&&a.destroy()}}])}();function a_(e){if(e.keyFormat!==sA){var t=e.keyId;if(t)return cT(t)}return e.uri}function r_(e){switch(e.type){case GE:return XE;case VE:return YE;default:return KE}}function o_(e,t){var i=e.url;return void 0!==i&&0!==i.indexOf("data:")||(i=t.url),i}var s_=function(){return m(function e(t){u(this,e),this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.onManifestLoaded=this.checkAutostartLoad,this.hls=t,this.registerListeners()},[{key:"startLoad",value:function(e){}},{key:"stopLoad",value:function(){this.destroyInternalLoaders()}},{key:"registerListeners",value:function(){var e=this.hls;e.on(zE.MANIFEST_LOADING,this.onManifestLoading,this),e.on(zE.LEVEL_LOADING,this.onLevelLoading,this),e.on(zE.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(zE.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.on(zE.LEVELS_UPDATED,this.onLevelsUpdated,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(zE.MANIFEST_LOADING,this.onManifestLoading,this),e.off(zE.LEVEL_LOADING,this.onLevelLoading,this),e.off(zE.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(zE.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.off(zE.LEVELS_UPDATED,this.onLevelsUpdated,this)}},{key:"createInternalLoader",value:function(e){var t=this.hls.config,i=t.pLoader,n=t.loader,a=new(i||n)(t);return this.loaders[e.type]=a,a}},{key:"getInternalLoader",value:function(e){return this.loaders[e.type]}},{key:"resetInternalLoader",value:function(e){this.loaders[e]&&delete this.loaders[e]}},{key:"destroyInternalLoaders",value:function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}}},{key:"destroy",value:function(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}},{key:"onManifestLoading",value:function(e,t){var i=t.url;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:UE,url:i,deliveryDirectives:null,levelOrTrack:null})}},{key:"onLevelLoading",value:function(e,t){var i=t.id,n=t.level,a=t.pathwayId,r=t.url,o=t.deliveryDirectives,s=t.levelInfo;this.load({id:i,level:n,pathwayId:a,responseType:"text",type:HE,url:r,deliveryDirectives:o,levelOrTrack:s})}},{key:"onAudioTrackLoading",value:function(e,t){var i=t.id,n=t.groupId,a=t.url,r=t.deliveryDirectives,o=t.track;this.load({id:i,groupId:n,level:null,responseType:"text",type:GE,url:a,deliveryDirectives:r,levelOrTrack:o})}},{key:"onSubtitleTrackLoading",value:function(e,t){var i=t.id,n=t.groupId,a=t.url,r=t.deliveryDirectives,o=t.track;this.load({id:i,groupId:n,level:null,responseType:"text",type:VE,url:a,deliveryDirectives:r,levelOrTrack:o})}},{key:"onLevelsUpdated",value:function(e,t){var i=this.loaders[HE];if(i){var n=i.context;n&&!t.levels.some(e=>e===n.levelOrTrack)&&(i.abort(),delete this.loaders[HE])}}},{key:"load",value:function(e){var t,i,n,a=this.hls.config,r=this.getInternalLoader(e);if(r){var o=this.hls.logger,s=r.context;if(s&&s.levelOrTrack===e.levelOrTrack&&(s.url===e.url||s.deliveryDirectives&&!e.deliveryDirectives))return void(s.url===e.url?o.log(`[playlist-loader]: ignore ${e.url} ongoing request`):o.log(`[playlist-loader]: ignore ${e.url} in favor of ${s.url}`));o.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),r.abort()}if((i=e.type===UE?a.manifestLoadPolicy.default:ZE({},a.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),r=this.createInternalLoader(e),WE(null==(t=e.deliveryDirectives)?void 0:t.part))&&(e.type===HE&&null!==e.level?n=this.hls.levels[e.level].details:e.type===GE&&null!==e.id?n=this.hls.audioTracks[e.id].details:e.type===VE&&null!==e.id&&(n=this.hls.subtitleTracks[e.id].details),n)){var u=n.partTarget,l=n.targetduration;if(u&&l){var d=1e3*Math.max(3*u,.8*l);i=ZE({},i,{maxTimeToFirstByteMs:Math.min(d,i.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(d,i.maxTimeToFirstByteMs)})}}var h=i.errorRetry||i.timeoutRetry||{},c={loadPolicy:i,timeout:i.maxLoadTimeMs,maxRetry:h.maxNumRetry||0,retryDelay:h.retryDelayMs||0,maxRetryDelay:h.maxRetryDelayMs||0},m={onSuccess:(e,t,i,n)=>{var a=this.getInternalLoader(i);this.resetInternalLoader(i.type);var r=e.data;t.parsing.start=performance.now(),TA.isMediaPlaylist(r)||i.type!==UE?this.handleTrackOrLevelPlaylist(e,t,i,n||null,a):this.handleMasterPlaylist(e,t,i,n)},onError:(e,t,i,n)=>{this.handleNetworkError(t,i,!1,e,n)},onTimeout:(e,t,i)=>{this.handleNetworkError(t,i,!0,void 0,e)}};r.load(e,c,m)}},{key:"checkAutostartLoad",value:function(){if(this.hls){var e=this.hls,t=e.config,i=t.autoStartLoad,n=t.startPosition,a=e.forceStartLoad;(i||a)&&(this.hls.logger.log(`${i?"auto":"force"} startLoad with configured startPosition ${n}`),this.hls.startLoad(n))}}},{key:"handleMasterPlaylist",value:function(e,t,i,n){var a=this.hls,r=e.data,o=o_(e,i),s=TA.parseMasterPlaylist(r,o);if(s.playlistParsingError)return t.parsing.end=performance.now(),void this.handleManifestParsingError(e,i,s.playlistParsingError,n,t);var u=s.contentSteering,l=s.levels,d=s.sessionData,h=s.sessionKeys,c=s.startTimeOffset,m=s.variableList;this.variableList=m,l.forEach(e=>{var t=e.unknownCodecs;if(t)for(var i=this.hls.config.preferManagedMediaSource,n=e.audioCodec,a=e.videoCodec,r=t.length;r--;){var o=t[r];sP(o,"audio",i)?(e.audioCodec=n=n?`${n},${o}`:o,rP.audio[n.substring(0,4)]=2,t.splice(r,1)):sP(o,"video",i)&&(e.videoCodec=a=a?`${a},${o}`:o,rP.video[a.substring(0,4)]=2,t.splice(r,1))}});var f=TA.parseMasterPlaylistMedia(r,o,s),v=f.AUDIO,p=void 0===v?[]:v,g=f.SUBTITLES,y=f["CLOSED-CAPTIONS"];p.length&&(p.some(e=>!e.url)||!l[0].audioCodec||l[0].attrs.AUDIO||(this.hls.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),p.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new GM({}),bitrate:0,url:""})));a.trigger(zE.MANIFEST_LOADED,{levels:l,audioTracks:p,subtitles:g,captions:y,contentSteering:u,url:o,stats:t,networkDetails:n,sessionData:d,sessionKeys:h,startTimeOffset:c,variableList:m})}},{key:"handleTrackOrLevelPlaylist",value:function(e,t,i,n,a){var r=this.hls,o=i.id,s=i.level,u=i.type,l=o_(e,i),d=WE(s)?s:WE(o)?o:0,h=r_(i),c=TA.parseLevelPlaylist(e.data,l,d,h,0,this.variableList);if(u===UE){var m={attrs:new GM({}),bitrate:0,details:c,name:"",url:l};c.requestScheduled=t.loading.start+zA(c,0),r.trigger(zE.MANIFEST_LOADED,{levels:[m],audioTracks:[],url:l,stats:t,networkDetails:n,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),i.levelDetails=c,this.handlePlaylistLoaded(c,e,t,i,n,a)}},{key:"handleManifestParsingError",value:function(e,t,i,n,a){this.hls.trigger(zE.ERROR,{type:jE.NETWORK_ERROR,details:BE.MANIFEST_PARSING_ERROR,fatal:t.type===UE,url:e.url,err:i,error:i,reason:i.message,response:e,context:t,networkDetails:n,stats:a})}},{key:"handleNetworkError",value:function(e,t,i=!1,n,a){var r=`A network ${i?"timeout":"error"+(n?" (status "+n.code+")":"")} occurred while loading ${e.type}`;e.type===HE?r+=`: ${e.level} id: ${e.id}`:e.type!==GE&&e.type!==VE||(r+=` id: ${e.id} group-id: "${e.groupId}"`);var o=new Error(r);this.hls.logger.warn(`[playlist-loader]: ${r}`);var s=BE.UNKNOWN,u=!1,l=this.getInternalLoader(e);switch(e.type){case UE:s=i?BE.MANIFEST_LOAD_TIMEOUT:BE.MANIFEST_LOAD_ERROR,u=!0;break;case HE:s=i?BE.LEVEL_LOAD_TIMEOUT:BE.LEVEL_LOAD_ERROR,u=!1;break;case GE:s=i?BE.AUDIO_TRACK_LOAD_TIMEOUT:BE.AUDIO_TRACK_LOAD_ERROR,u=!1;break;case VE:s=i?BE.SUBTITLE_TRACK_LOAD_TIMEOUT:BE.SUBTITLE_LOAD_ERROR,u=!1}l&&this.resetInternalLoader(e.type);var d={type:jE.NETWORK_ERROR,details:s,fatal:u,url:e.url,loader:l,context:e,error:o,networkDetails:t,stats:a};if(n){var h=(null==t?void 0:t.url)||e.url;d.response=tT({url:h,data:void 0},n)}this.hls.trigger(zE.ERROR,d)}},{key:"handlePlaylistLoaded",value:function(e,t,i,n,a,r){var o=this.hls,s=n.type,u=n.level,l=n.levelOrTrack,d=n.id,h=n.groupId,c=n.deliveryDirectives,m=o_(t,n),f=r_(n),v="number"==typeof n.level&&f===KE?u:void 0,p=e.playlistParsingError;if(p){if(this.hls.logger.warn(`${p} ${e.url}`),!o.config.ignorePlaylistParsingErrors)return void o.trigger(zE.ERROR,{type:jE.NETWORK_ERROR,details:BE.LEVEL_PARSING_ERROR,fatal:!1,url:m,error:p,reason:p.message,response:t,context:n,level:v,parent:f,networkDetails:a,stats:i});e.playlistParsingError=null}if(e.fragments.length)switch(e.live&&r&&(r.getCacheAge&&(e.ageHeader=r.getCacheAge()||0),r.getCacheAge&&!isNaN(e.ageHeader)||(e.ageHeader=0)),s){case UE:case HE:if(v)if(l){if(l!==o.levels[v]){var g=o.levels.indexOf(l);g>-1&&(v=g)}}else v=0;o.trigger(zE.LEVEL_LOADED,{details:e,levelInfo:l||o.levels[0],level:v||0,id:d||0,stats:i,networkDetails:a,deliveryDirectives:c,withoutMultiVariant:s===UE});break;case GE:o.trigger(zE.AUDIO_TRACK_LOADED,{details:e,track:l,id:d||0,groupId:h||"",stats:i,networkDetails:a,deliveryDirectives:c});break;case VE:o.trigger(zE.SUBTITLE_TRACK_LOADED,{details:e,track:l,id:d||0,groupId:h||"",stats:i,networkDetails:a,deliveryDirectives:c})}else{var y=e.playlistParsingError=new Error("No Segments found in Playlist");o.trigger(zE.ERROR,{type:jE.NETWORK_ERROR,details:BE.LEVEL_EMPTY_ERROR,fatal:!1,url:m,error:y,reason:y.message,response:t,context:n,level:v,parent:f,networkDetails:a,stats:i})}}}])}(),u_=function(){function e(t={}){u(this,e),this.config=void 0,this.userConfig=void 0,this.logger=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new kD,this._autoLevelCapping=-1,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.audioStreamController=void 0,this.subtititleStreamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.interstitialsController=void 0,this.gapController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this._url=null,this._sessionId=void 0,this.triggeringException=void 0,this.started=!1;var i=this.logger=function(e,t,i){var n=rT();if("object"==typeof console&&!0===e||"object"==typeof e){var a=["debug","log","info","warn","error"];a.forEach(t=>{n[t]=oT(t,e,i)});try{n.log(`Debug logs enabled for "${t}" in hls.js version 1.6.16`)}catch(e){return rT()}a.forEach(t=>{sT[t]=oT(t,e)})}else ZE(sT,n);return n}(t.debug||!1,"Hls instance",t.assetPlayerId),n=this.config=function(e,t,i){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(void 0!==t.liveMaxLatencyDurationCount&&(void 0===t.liveSyncDurationCount||t.liveMaxLatencyDurationCount<=t.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==t.liveMaxLatencyDuration&&(void 0===t.liveSyncDuration||t.liveMaxLatencyDuration<=t.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');var n=BL(e),a=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach(e=>{var r=`${"level"===e?"playlist":e}LoadPolicy`,o=void 0===t[r],s=[];a.forEach(i=>{var a=`${e}Loading${i}`,u=t[a];if(void 0!==u&&o){s.push(a);var l=n[r].default;switch(t[r]={default:l},i){case"TimeOut":l.maxLoadTimeMs=u,l.maxTimeToFirstByteMs=u;break;case"MaxRetry":l.errorRetry.maxNumRetry=u,l.timeoutRetry.maxNumRetry=u;break;case"RetryDelay":l.errorRetry.retryDelayMs=u,l.timeoutRetry.retryDelayMs=u;break;case"MaxRetryTimeout":l.errorRetry.maxRetryDelayMs=u,l.timeoutRetry.maxRetryDelayMs=u}}}),s.length&&i.warn(`hls.js config: "${s.join('", "')}" setting(s) are deprecated, use "${r}": ${OP(t[r])}`)}),tT(tT({},n),t)}(e.DefaultConfig,t,i);this.userConfig=t,n.progressive&&zL(n,i);var a=n.abrController,r=n.bufferController,o=n.capLevelController,s=n.errorController,l=n.fpsController,d=new s(this),h=this.abrController=new a(this),c=new bM(this),m=n.interstitialsController,f=m?this.interstitialsController=new m(this,e):null,v=this.bufferController=new r(this,c),p=this.capLevelController=new o(this),g=new l(this),y=new s_(this),b=n.contentSteeringController,w=b?new b(this):null,k=this.levelController=new QL(this,w),S=new qL(this),E=new n_(this.config,this.logger),T=this.streamController=new i_(this,c,E),P=this.gapController=new UL(this,c);p.setStreamController(T),g.setStreamController(T);var M=[y,k,T];f&&M.splice(1,0,f),w&&M.splice(1,0,w),this.networkControllers=M;var A=[h,v,P,p,g,S,c];this.audioTrackController=this.createController(n.audioTrackController,M);var D=n.audioStreamController;D&&M.push(this.audioStreamController=new D(this,c,E)),this.subtitleTrackController=this.createController(n.subtitleTrackController,M);var x=n.subtitleStreamController;x&&M.push(this.subtititleStreamController=new x(this,c,E)),this.createController(n.timelineController,A),E.emeController=this.emeController=this.createController(n.emeController,A),this.cmcdController=this.createController(n.cmcdController,A),this.latencyController=this.createController(JL,A),this.coreComponents=A,M.push(d);var C=d.onErrorOut;"function"==typeof C&&this.on(zE.ERROR,C,d),this.on(zE.MANIFEST_LOADED,y.onManifestLoaded,y)}return m(e,[{key:"createController",value:function(e,t){if(e){var i=new e(this);return t&&t.push(i),i}return null}},{key:"on",value:function(e,t,i=this){this._emitter.on(e,t,i)}},{key:"once",value:function(e,t,i=this){this._emitter.once(e,t,i)}},{key:"removeAllListeners",value:function(e){this._emitter.removeAllListeners(e)}},{key:"off",value:function(e,t,i=this,n){this._emitter.off(e,t,i,n)}},{key:"listeners",value:function(e){return this._emitter.listeners(e)}},{key:"emit",value:function(e,t,i){return this._emitter.emit(e,t,i)}},{key:"trigger",value:function(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(t){if(this.logger.error("An internal error happened while handling event "+e+'. Error message: "'+t.message+'". Here is a stacktrace:',t),!this.triggeringException){this.triggeringException=!0;var i=e===zE.ERROR;this.trigger(zE.ERROR,{type:jE.OTHER_ERROR,details:BE.INTERNAL_EXCEPTION,fatal:i,event:e,error:t}),this.triggeringException=!1}}return!1}},{key:"listenerCount",value:function(e){return this._emitter.listenerCount(e)}},{key:"destroy",value:function(){this.logger.log("destroy"),this.trigger(zE.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;var e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null}},{key:"attachMedia",value:function(e){if(!e||"media"in e&&!e.media){var t=new Error(`attachMedia failed: invalid argument (${e})`);this.trigger(zE.ERROR,{type:jE.OTHER_ERROR,details:BE.ATTACH_MEDIA_ERROR,fatal:!0,error:t})}else{this.logger.log("attachMedia"),this._media&&(this.logger.warn("media must be detached before attaching"),this.detachMedia());var i="media"in e,n=i?e.media:e,a=i?e:{media:n};this._media=n,this.trigger(zE.MEDIA_ATTACHING,a)}}},{key:"detachMedia",value:function(){this.logger.log("detachMedia"),this.trigger(zE.MEDIA_DETACHING,{}),this._media=null}},{key:"transferMedia",value:function(){this._media=null;var e=this.bufferController.transferMedia();return this.trigger(zE.MEDIA_DETACHING,{transferMedia:e}),e}},{key:"loadSource",value:function(e){this.stopLoad();var t=this.media,i=this._url,n=this._url=ST.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.logger.log(`loadSource:${n}`),t&&i&&(i!==n||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(zE.MANIFEST_LOADING,{url:e})}},{key:"url",get:function(){return this._url}},{key:"hasEnoughToStart",get:function(){return this.streamController.hasEnoughToStart}},{key:"startPosition",get:function(){return this.streamController.startPositionValue}},{key:"startLoad",value:function(e=-1,t){this.logger.log(`startLoad(${e+(t?", <skip seek to start>":"")})`),this.started=!0,this.resumeBuffering();for(var i=0;i<this.networkControllers.length&&(this.networkControllers[i].startLoad(e,t),this.started&&this.networkControllers);i++);}},{key:"stopLoad",value:function(){this.logger.log("stopLoad"),this.started=!1;for(var e=0;e<this.networkControllers.length&&(this.networkControllers[e].stopLoad(),!this.started&&this.networkControllers);e++);}},{key:"loadingEnabled",get:function(){return this.started}},{key:"bufferingEnabled",get:function(){return this.streamController.bufferingEnabled}},{key:"resumeBuffering",value:function(){this.bufferingEnabled||(this.logger.log("resume buffering"),this.networkControllers.forEach(e=>{e.resumeBuffering&&e.resumeBuffering()}))}},{key:"pauseBuffering",value:function(){this.bufferingEnabled&&(this.logger.log("pause buffering"),this.networkControllers.forEach(e=>{e.pauseBuffering&&e.pauseBuffering()}))}},{key:"inFlightFragments",get:function(){var e={[KE]:this.streamController.inFlightFrag};return this.audioStreamController&&(e[XE]=this.audioStreamController.inFlightFrag),this.subtititleStreamController&&(e[YE]=this.subtititleStreamController.inFlightFrag),e}},{key:"swapAudioCodec",value:function(){this.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()}},{key:"recoverMediaError",value:function(){this.logger.log("recoverMediaError");var e=this._media,t=null==e?void 0:e.currentTime;this.detachMedia(),e&&(this.attachMedia(e),t&&this.startLoad(t))}},{key:"removeLevel",value:function(e){this.levelController.removeLevel(e)}},{key:"sessionId",get:function(){var e=this._sessionId;return e||(e=this._sessionId=function(){try{return crypto.randomUUID()}catch(a){try{var e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}catch(e){var i=(new Date).getTime(),n="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{var t=(i+16*Math.random())%16|0;return i=Math.floor(i/16),("x"==e?t:3&t|8).toString(16)});return n}}}()),e}},{key:"levels",get:function(){var e=this.levelController.levels;return e||[]}},{key:"latestLevelDetails",get:function(){return this.streamController.getLevelDetails()||null}},{key:"loadLevelObj",get:function(){return this.levelController.loadLevelObj}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(e){this.logger.log(`set currentLevel:${e}`),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(e){this.logger.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(e){this.logger.log(`set loadLevel:${e}`),this.levelController.manualLevel=e}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(e){this.levelController.nextLoadLevel=e}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(e){this.logger.log(`set firstLevel:${e}`),this.levelController.firstLevel=e}},{key:"startLevel",get:function(){var e=this.levelController.startLevel;return-1===e&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e},set:function(e){this.logger.log(`set startLevel:${e}`),-1!==e&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(e){var t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(e){this._autoLevelCapping!==e&&(this.logger.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}},{key:"bandwidthEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimate():NaN},set:function(e){this.abrController.resetEstimator(e)}},{key:"abrEwmaDefaultEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.defaultEstimate:NaN}},{key:"ttfbEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimateTTFB():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(e){(function(e){return MP.indexOf(e)>-1})(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}},{key:"autoLevelEnabled",get:function(){return-1===this.levelController.manualLevel}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var e=this.levels,t=this.config.minAutoBitrate;if(!e)return 0;for(var i=e.length,n=0;n<i;n++)if(e[n].maxBitrate>=t)return n;return 0}},{key:"maxAutoLevel",get:function(){var e,t=this.levels,i=this.autoLevelCapping,n=this.maxHdcpLevel;if(e=-1===i&&null!=t&&t.length?t.length-1:i,n)for(var a=e;a--;){var r=t[a].attrs["HDCP-LEVEL"];if(r&&r<=n)return a}return e}},{key:"firstAutoLevel",get:function(){return this.abrController.firstAutoLevel}},{key:"nextAutoLevel",get:function(){return this.abrController.nextAutoLevel},set:function(e){this.abrController.nextAutoLevel=e}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"maxBufferLength",get:function(){return this.streamController.maxBufferLength}},{key:"setAudioOption",value:function(e){var t;return(null==(t=this.audioTrackController)?void 0:t.setAudioOption(e))||null}},{key:"setSubtitleOption",value:function(e){var t;return(null==(t=this.subtitleTrackController)?void 0:t.setSubtitleOption(e))||null}},{key:"allAudioTracks",get:function(){var e=this.audioTrackController;return e?e.allAudioTracks:[]}},{key:"audioTracks",get:function(){var e=this.audioTrackController;return e?e.audioTracks:[]}},{key:"audioTrack",get:function(){var e=this.audioTrackController;return e?e.audioTrack:-1},set:function(e){var t=this.audioTrackController;t&&(t.audioTrack=e)}},{key:"allSubtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}},{key:"subtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTrack:-1},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var e=this.subtitleTrackController;return!!e&&e.subtitleDisplay},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(e){this.config.lowLatencyMode=e}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency},set:function(e){this.latencyController.targetLatency=e}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}},{key:"pathways",get:function(){return this.levelController.pathways}},{key:"pathwayPriority",get:function(){return this.levelController.pathwayPriority},set:function(e){this.levelController.pathwayPriority=e}},{key:"bufferedToEnd",get:function(){var e;return!(null==(e=this.bufferController)||!e.bufferedToEnd)}},{key:"interstitialsManager",get:function(){var e;return(null==(e=this.interstitialsController)?void 0:e.interstitialsManager)||null}},{key:"getMediaDecodingInfo",value:function(e,t=this.allAudioTracks){return EP(e,$P(t),navigator.mediaCapabilities)}}],[{key:"version",get:function(){return SD}},{key:"isMSESupported",value:function(){return t_()}},{key:"isSupported",value:function(){return function(){if(!t_())return!1;var e=lT();return"function"==typeof(null==e?void 0:e.isTypeSupported)&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(t=>e.isTypeSupported(lP(t,"video")))||["mp4a.40.2","fLaC"].some(t=>e.isTypeSupported(lP(t,"audio"))))}()}},{key:"getMediaSource",value:function(){return lT()}},{key:"Events",get:function(){return zE}},{key:"MetadataSchema",get:function(){return GD}},{key:"ErrorTypes",get:function(){return jE}},{key:"ErrorDetails",get:function(){return BE}},{key:"DefaultConfig",get:function(){return e.defaultConfig?e.defaultConfig:jL},set:function(t){e.defaultConfig=t}}])}();u_.defaultConfig=void 0;var l_,d_=e=>e,h_=function(){function i(){var e;return u(this,i),(e=s(this,i,arguments)).inFocusedState=!1,e.scaleFactor=1,e.bgVideo=!1,e}return y(i,bs),m(i,[{key:"disconnectedCallback",value:function(){M(i,"disconnectedCallback",this)([]),Mo.instance&&(Mo.instance.removeVideoEvents(),Mo.instance=null)}},{key:"styles",value:function(){var e,i,n=this.component,a=n.url,r=n.imageCropping,o=n.alignment,s=n.rightMargin,u=n.spacing,l="fit"===r,d=null!==(e=null===(i=this.getRootNode().host)||void 0===i?void 0:i.tagName.toLowerCase())&&void 0!==e?e:"";this.bgVideo=d.includes("background");var h=l?"":t.unsafeCSS(` position: ${this.bgVideo?"fixed":"relative"};\n right: 0;\n top: 0;\n min-width: 100%;\n `);return t.unsafeCSS(`\n :host {\n box-sizing: border-box;\n display: flex;\n transition: all 0.3s;\n background-image: url(${a});\n background-size: ${l?"contain":"cover"};\n background-position: ${o||""} center;\n background-repeat: no-repeat;\n ${zs(this.component,this.scaleFactor)};\n margin-right: ${s||u||0}px;\n ${Ks(this.component,this.scaleFactor,!1)}\n ${this.component.hidden?"display:none;":""}\n ${h}\n }\n :host(:focus) {\n ${Ks(this.component,this.scaleFactor,!0)}\n }\n :host(:focus-visible){\n ${Zs(this.component)}\n }\n #nami-video {\n ${zs(this.component,this.scaleFactor)};\n object-fit: ${l?"contain":"cover"};\n }\n `)}},{key:"loadMediaSrc",value:function(t){var i=this.component.url;if(i&&!i.includes(e.SMART_TEXT_PATTERN)&&t.src!==i)if(!i.includes("m3u8")||t.canPlayType("application/vnd.apple.mpegurl"))t.src=i;else if(u_.isSupported()){var n=new u_;n.loadSource(i),n.attachMedia(t)}}},{key:"updated",value:function(){var e,t;Object.keys(this.component).forEach(e=>{this.component[e]=qn(this.contextProvider,this.component[e])});var i=this.component,n=i.id,a=i.title,r=i.autoplayVideo,o=i.mute,s=i.loopVideo,u=i.controlsType,l=i.fallbackImage,d=null===(e=this.shadowRoot)||void 0===e?void 0:e.getElementById("nami-video");d&&(d.autoplay=null!=r&&r,d.loop=null!=s&&s,d.muted=null!=o&&o,d.controls="none"!==u,d.poster=null!=l?l:"",d.playsInline=null!=r?r:this.bgVideo,this.loadMediaSrc(d),null===(t=Mo.instance)||void 0===t||t.removeVideoEvents(),Mo.instance=new Mo(this.contextProvider,d,a,n))}},{key:"render",value:function(){var e,i=this.component,n=i.focusedBorderColor,a=i.focusedFillColor,r=i.fillColor,o=i.screenreaderText,s=i.title;return this.ariaLabel=null!==(e=null!=o?o:s)&&void 0!==e?e:"",!n&&na(r,a)||(this.tabIndex=0),t.html(l_||(l_=d_`<video id="nami-video" preload="auto"></video>`))}}])}();Ae([ot({type:Object})],h_.prototype,"component",void 0),Ae([ot({type:Boolean})],h_.prototype,"inFocusedState",void 0),Ae([ot({type:Number})],h_.prototype,"scaleFactor",void 0),h_=Ae([Fe("nami-video")],h_);var c_,m_=e=>e,f_=function(){function e(){var t;return u(this,e),(t=s(this,e,arguments)).inFocusedState=!1,t.height=0,t.scaleFactor=1,t.isCollapsed=!0,t._handleClick=()=>{var e,i;t.isCollapsed=!t.isCollapsed,t.contextProvider.setOpenHeaderIds(t.component.id||"",t.component.sku),t.height=(null===(e=t.shadowRoot)||void 0===e||null===(e=e.getElementById("collapse"))||void 0===e?void 0:e.scrollHeight)||0,null===(i=t.shadowRoot)||void 0===i||null===(i=i.getElementById("collapse"))||void 0===i||i.classList.toggle("hidden")},t}return y(e,bs),m(e,[{key:"styles",value:function(){var e=this.component,i=this.height,n=this.scaleFactor,a=e.backgroundBlur,r="vertical"===e.direction?"margin-top":"margin-left";return t.unsafeCSS(`\n :host {\n display: ${e.hidden?"none":"flex"};\n ${a?`backdrop-filter: blur(${a}px);`:""}\n ${Rs(e,!1)};\n ${Fs(this.component)}\n ${Ks(e,n,!1)}\n cursor: pointer;\n }\n :host > *:not(:first-child) {\n ${r}: ${e.spacing?e.spacing*n:0}px;\n }\n :host(:focus){\n ${Rs(e,!0)}\n ${Ks(e,n,!0)}\n }\n :host(:focus-visible){\n ${Zs(e)}\n }\n #collapse.hidden{\n max-height: 0;\n opacity: 0;\n overflow: hidden;\n padding: 0;\n margin: 0;\n }\n #collapse {\n ${zs(e,n)}\n max-height: ${i}px;\n opacity: 1;\n transition: all linear 0.5s;\n overflow: hidden;\n }\n #collapse-btn{\n background: transparent;\n border: none;\n width: 100%;\n }\n `)}},{key:"render",value:function(){var e=this.component,i=e.components,n=e.collapseHeader,a=e.focusedBorderColor,r=e.focusedFillColor,o=e.fillColor;!a&&na(o,r)||(this.tabIndex=0);var s=i.map(e=>Iu(this.contextProvider,e,this.scaleFactor,this.inFocusedState,this.minSDKVersion));return t.html(c_||(c_=m_`
|
|
470
|
+
<label for="${0}">${0}</label>`),this.component.text,this.component.text,this.component.text,this._isActive,this.component.text,this.component.text)}}])}();Ae([ot({type:Object})],WE.prototype,"component",void 0),Ae([ot({type:Boolean})],WE.prototype,"inFocusedState",void 0),Ae([ot({type:Number})],WE.prototype,"scaleFactor",void 0),Ae([st()],WE.prototype,"_isActive",void 0),WE=Ae([Fe("nami-segment-picker-item")],WE);var $E=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},NE=Number.isSafeInteger||function(e){return"number"==typeof e&&Math.abs(e)<=jE},jE=Number.MAX_SAFE_INTEGER||9007199254740991,BE=function(e){return e.NETWORK_ERROR="networkError",e.MEDIA_ERROR="mediaError",e.KEY_SYSTEM_ERROR="keySystemError",e.MUX_ERROR="muxError",e.OTHER_ERROR="otherError",e}({}),zE=function(e){return e.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",e.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",e.KEY_SYSTEM_NO_SESSION="keySystemNoSession",e.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",e.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",e.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",e.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",e.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",e.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR="keySystemDestroyMediaKeysError",e.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR="keySystemDestroyCloseSessionError",e.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR="keySystemDestroyRemoveSessionError",e.MANIFEST_LOAD_ERROR="manifestLoadError",e.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",e.MANIFEST_PARSING_ERROR="manifestParsingError",e.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",e.LEVEL_EMPTY_ERROR="levelEmptyError",e.LEVEL_LOAD_ERROR="levelLoadError",e.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",e.LEVEL_PARSING_ERROR="levelParsingError",e.LEVEL_SWITCH_ERROR="levelSwitchError",e.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",e.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",e.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",e.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",e.FRAG_LOAD_ERROR="fragLoadError",e.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",e.FRAG_DECRYPT_ERROR="fragDecryptError",e.FRAG_PARSING_ERROR="fragParsingError",e.FRAG_GAP="fragGap",e.REMUX_ALLOC_ERROR="remuxAllocError",e.KEY_LOAD_ERROR="keyLoadError",e.KEY_LOAD_TIMEOUT="keyLoadTimeOut",e.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",e.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",e.BUFFER_APPEND_ERROR="bufferAppendError",e.BUFFER_APPENDING_ERROR="bufferAppendingError",e.BUFFER_STALLED_ERROR="bufferStalledError",e.BUFFER_FULL_ERROR="bufferFullError",e.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",e.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",e.ASSET_LIST_LOAD_ERROR="assetListLoadError",e.ASSET_LIST_LOAD_TIMEOUT="assetListLoadTimeout",e.ASSET_LIST_PARSING_ERROR="assetListParsingError",e.INTERSTITIAL_ASSET_ITEM_ERROR="interstitialAssetItemError",e.INTERNAL_EXCEPTION="internalException",e.INTERNAL_ABORTED="aborted",e.ATTACH_MEDIA_ERROR="attachMediaError",e.UNKNOWN="unknown",e}({}),UE=function(e){return e.MEDIA_ATTACHING="hlsMediaAttaching",e.MEDIA_ATTACHED="hlsMediaAttached",e.MEDIA_DETACHING="hlsMediaDetaching",e.MEDIA_DETACHED="hlsMediaDetached",e.MEDIA_ENDED="hlsMediaEnded",e.STALL_RESOLVED="hlsStallResolved",e.BUFFER_RESET="hlsBufferReset",e.BUFFER_CODECS="hlsBufferCodecs",e.BUFFER_CREATED="hlsBufferCreated",e.BUFFER_APPENDING="hlsBufferAppending",e.BUFFER_APPENDED="hlsBufferAppended",e.BUFFER_EOS="hlsBufferEos",e.BUFFERED_TO_END="hlsBufferedToEnd",e.BUFFER_FLUSHING="hlsBufferFlushing",e.BUFFER_FLUSHED="hlsBufferFlushed",e.MANIFEST_LOADING="hlsManifestLoading",e.MANIFEST_LOADED="hlsManifestLoaded",e.MANIFEST_PARSED="hlsManifestParsed",e.LEVEL_SWITCHING="hlsLevelSwitching",e.LEVEL_SWITCHED="hlsLevelSwitched",e.LEVEL_LOADING="hlsLevelLoading",e.LEVEL_LOADED="hlsLevelLoaded",e.LEVEL_UPDATED="hlsLevelUpdated",e.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",e.LEVELS_UPDATED="hlsLevelsUpdated",e.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",e.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",e.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",e.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",e.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",e.AUDIO_TRACK_UPDATED="hlsAudioTrackUpdated",e.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",e.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",e.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",e.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",e.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",e.SUBTITLE_TRACK_UPDATED="hlsSubtitleTrackUpdated",e.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",e.CUES_PARSED="hlsCuesParsed",e.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",e.INIT_PTS_FOUND="hlsInitPtsFound",e.FRAG_LOADING="hlsFragLoading",e.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",e.FRAG_LOADED="hlsFragLoaded",e.FRAG_DECRYPTED="hlsFragDecrypted",e.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",e.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",e.FRAG_PARSING_METADATA="hlsFragParsingMetadata",e.FRAG_PARSED="hlsFragParsed",e.FRAG_BUFFERED="hlsFragBuffered",e.FRAG_CHANGED="hlsFragChanged",e.FPS_DROP="hlsFpsDrop",e.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",e.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",e.ERROR="hlsError",e.DESTROYING="hlsDestroying",e.KEY_LOADING="hlsKeyLoading",e.KEY_LOADED="hlsKeyLoaded",e.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",e.BACK_BUFFER_REACHED="hlsBackBufferReached",e.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",e.ASSET_LIST_LOADING="hlsAssetListLoading",e.ASSET_LIST_LOADED="hlsAssetListLoaded",e.INTERSTITIALS_UPDATED="hlsInterstitialsUpdated",e.INTERSTITIALS_BUFFERED_TO_BOUNDARY="hlsInterstitialsBufferedToBoundary",e.INTERSTITIAL_ASSET_PLAYER_CREATED="hlsInterstitialAssetPlayerCreated",e.INTERSTITIAL_STARTED="hlsInterstitialStarted",e.INTERSTITIAL_ASSET_STARTED="hlsInterstitialAssetStarted",e.INTERSTITIAL_ASSET_ENDED="hlsInterstitialAssetEnded",e.INTERSTITIAL_ASSET_ERROR="hlsInterstitialAssetError",e.INTERSTITIAL_ENDED="hlsInterstitialEnded",e.INTERSTITIALS_PRIMARY_RESUMED="hlsInterstitialsPrimaryResumed",e.PLAYOUT_LIMIT_REACHED="hlsPlayoutLimitReached",e.EVENT_CUE_ENTER="hlsEventCueEnter",e}({}),HE="manifest",GE="level",VE="audioTrack",KE="subtitleTrack",XE="main",YE="audio",qE="subtitle",JE=function(){return m(function e(t,i=0,n=0){u(this,e),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_=i,this.totalWeight_=n},[{key:"sample",value:function(e,t){var i=Math.pow(this.alpha_,e);this.estimate_=t*(1-i)+i*this.estimate_,this.totalWeight_+=e}},{key:"getTotalWeight",value:function(){return this.totalWeight_}},{key:"getEstimate",value:function(){if(this.alpha_){var e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}}])}(),QE=function(){return m(function e(t,i,n,a=100){u(this,e),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_=n,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new JE(t),this.fast_=new JE(i),this.defaultTTFB_=a,this.ttfb_=new JE(t)},[{key:"update",value:function(e,t){var i=this.slow_,n=this.fast_,a=this.ttfb_;i.halfLife!==e&&(this.slow_=new JE(e,i.getEstimate(),i.getTotalWeight())),n.halfLife!==t&&(this.fast_=new JE(t,n.getEstimate(),n.getTotalWeight())),a.halfLife!==e&&(this.ttfb_=new JE(e,a.getEstimate(),a.getTotalWeight()))}},{key:"sample",value:function(e,t){var i=(e=Math.max(e,this.minDelayMs_))/1e3,n=8*t/i;this.fast_.sample(i,n),this.slow_.sample(i,n)}},{key:"sampleTTFB",value:function(e){var t=e/1e3,i=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(i,Math.max(e,5))}},{key:"canEstimate",value:function(){return this.fast_.getTotalWeight()>=this.minWeight_}},{key:"getEstimate",value:function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}},{key:"getEstimateTTFB",value:function(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}},{key:"defaultEstimate",get:function(){return this.defaultEstimate_}},{key:"destroy",value:function(){}}])}();function ZE(e,t,i){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var n=i.call(e,t);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function eT(){return eT=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var n in i)({}).hasOwnProperty.call(i,n)&&(e[n]=i[n])}return e},eT.apply(null,arguments)}function tT(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),i.push.apply(i,n)}return i}function iT(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?tT(Object(i),!0).forEach(function(t){ZE(e,t,i[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):tT(Object(i)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})}return e}var nT=m(function e(t,i){u(this,e),this.trace=void 0,this.debug=void 0,this.log=void 0,this.warn=void 0,this.info=void 0,this.error=void 0;var n=`[${t}]:`;this.trace=aT,this.debug=i.debug.bind(null,n),this.log=i.log.bind(null,n),this.warn=i.warn.bind(null,n),this.info=i.info.bind(null,n),this.error=i.error.bind(null,n)}),aT=function(){},rT={trace:aT,debug:aT,log:aT,warn:aT,info:aT,error:aT};function oT(){return eT({},rT)}function sT(e,t,i){return t[e]?t[e].bind(t):function(e,t){var i=self.console[e];return i?i.bind(self.console,`${t?"["+t+"] ":""}[${e}] >`):aT}(e,i)}var uT=oT();var lT=uT;function dT(e=!0){if("undefined"!=typeof self)return(e||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function hT(e,t){var i=Object.keys(e),n=Object.keys(t),a=i.length,r=n.length;return!a||!r||a===r&&!i.some(e=>-1===n.indexOf(e))}function cT(e,t=!1){if("undefined"!=typeof TextDecoder){var i=new TextDecoder("utf-8").decode(e);if(t){var n=i.indexOf("\0");return-1!==n?i.substring(0,n):i}return i.replace(/\0/g,"")}for(var a,r,o,s=e.length,u="",l=0;l<s;){if(0===(a=e[l++])&&t)return u;if(0!==a&&3!==a)switch(a>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:u+=String.fromCharCode(a);break;case 12:case 13:r=e[l++],u+=String.fromCharCode((31&a)<<6|63&r);break;case 14:r=e[l++],o=e[l++],u+=String.fromCharCode((15&a)<<12|(63&r)<<6|63&o)}}return u}function mT(e){for(var t="",i=0;i<e.length;i++){var n=e[i].toString(16);n.length<2&&(n="0"+n),t+=n}return t}function fT(e){return Uint8Array.from(e.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}function vT(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var pT,gT={exports:{}};var yT,bT,wT,kT,ST,ET=pT?gT.exports:(pT=1,yT=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,bT=/^(?=([^\/?#]*))\1([^]*)$/,wT=/(?:\/|^)\.(?=\/)/g,kT=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,gT.exports=ST={buildAbsoluteURL:function(e,t,i){if(i=i||{},e=e.trim(),!(t=t.trim())){if(!i.alwaysNormalize)return e;var n=ST.parseURL(e);if(!n)throw new Error("Error trying to parse base URL.");return n.path=ST.normalizePath(n.path),ST.buildURLFromParts(n)}var a=ST.parseURL(t);if(!a)throw new Error("Error trying to parse relative URL.");if(a.scheme)return i.alwaysNormalize?(a.path=ST.normalizePath(a.path),ST.buildURLFromParts(a)):t;var r=ST.parseURL(e);if(!r)throw new Error("Error trying to parse base URL.");if(!r.netLoc&&r.path&&"/"!==r.path[0]){var o=bT.exec(r.path);r.netLoc=o[1],r.path=o[2]}r.netLoc&&!r.path&&(r.path="/");var s={scheme:r.scheme,netLoc:a.netLoc,path:null,params:a.params,query:a.query,fragment:a.fragment};if(!a.netLoc&&(s.netLoc=r.netLoc,"/"!==a.path[0]))if(a.path){var u=r.path,l=u.substring(0,u.lastIndexOf("/")+1)+a.path;s.path=ST.normalizePath(l)}else s.path=r.path,a.params||(s.params=r.params,a.query||(s.query=r.query));return null===s.path&&(s.path=i.alwaysNormalize?ST.normalizePath(a.path):a.path),ST.buildURLFromParts(s)},parseURL:function(e){var t=yT.exec(e);return t?{scheme:t[1]||"",netLoc:t[2]||"",path:t[3]||"",params:t[4]||"",query:t[5]||"",fragment:t[6]||""}:null},normalizePath:function(e){for(e=e.split("").reverse().join("").replace(wT,"");e.length!==(e=e.replace(kT,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}}),TT=m(function e(){u(this,e),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}}),PT="audio",MT="video",AT="audiovideo",DT=function(){return m(function e(t){u(this,e),this._byteRange=null,this._url=null,this._stats=null,this._streams=null,this.base=void 0,this.relurl=void 0,"string"==typeof t&&(t={url:t}),this.base=t,function(e,t){var i=LT(e,t);i&&(i.enumerable=!0,Object.defineProperty(e,t,i))}(this,"stats")},[{key:"setByteRange",value:function(e,t){var i,n=e.split("@",2);i=1===n.length?(null==t?void 0:t.byteRangeEndOffset)||0:parseInt(n[1]),this._byteRange=[i,parseInt(n[0])+i]}},{key:"baseurl",get:function(){return this.base.url}},{key:"byteRange",get:function(){return null===this._byteRange?[]:this._byteRange}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"elementaryStreams",get:function(){return null===this._streams&&(this._streams={[PT]:null,[MT]:null,[AT]:null}),this._streams},set:function(e){this._streams=e}},{key:"hasStats",get:function(){return null!==this._stats}},{key:"hasStreams",get:function(){return null!==this._streams}},{key:"stats",get:function(){return null===this._stats&&(this._stats=new TT),this._stats},set:function(e){this._stats=e}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=ET.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(e){this._url=e}},{key:"clearElementaryStreamInfo",value:function(){var e=this.elementaryStreams;e[PT]=null,e[MT]=null,e[AT]=null}}])}();function xT(e){return"initSegment"!==e.sn}var CT=function(){function e(t,i){var n;return u(this,e),(n=s(this,e,[i]))._decryptdata=null,n._programDateTime=null,n._ref=null,n._bitrate=void 0,n.rawProgramDateTime=null,n.tagList=[],n.duration=0,n.sn=0,n.levelkeys=void 0,n.type=void 0,n.loader=null,n.keyLoader=null,n.level=-1,n.cc=0,n.startPTS=void 0,n.endPTS=void 0,n.startDTS=void 0,n.endDTS=void 0,n.start=0,n.playlistOffset=0,n.deltaPTS=void 0,n.maxStartPTS=void 0,n.minEndPTS=void 0,n.data=void 0,n.bitrateTest=!1,n.title=null,n.initSegment=null,n.endList=void 0,n.gap=void 0,n.urlId=0,n.type=t,n}return y(e,DT),m(e,[{key:"byteLength",get:function(){if(this.hasStats){var e=this.stats.total;if(e)return e}if(this.byteRange.length){var t=this.byteRange[0],i=this.byteRange[1];if($E(t)&&$E(i))return i-t}return null}},{key:"bitrate",get:function(){return this.byteLength?8*this.byteLength/this.duration:this._bitrate?this._bitrate:null},set:function(e){this._bitrate=e}},{key:"decryptdata",get:function(){var e,t=this.levelkeys;if(!t||t.NONE)return null;if(t.identity)this._decryptdata||(this._decryptdata=t.identity.getDecryptData(this.sn));else if(null==(e=this._decryptdata)||!e.keyId){var i=Object.keys(t);if(1===i.length){var n=this._decryptdata=t[i[0]]||null;n&&(this._decryptdata=n.getDecryptData(this.sn,t))}}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(null===this.programDateTime)return null;var e=$E(this.duration)?this.duration:0;return this.programDateTime+1e3*e}},{key:"encrypted",get:function(){var e;if(null!=(e=this._decryptdata)&&e.encrypted)return!0;if(this.levelkeys){var t,i=Object.keys(this.levelkeys),n=i.length;if(n>1||1===n&&null!=(t=this.levelkeys[i[0]])&&t.encrypted)return!0}return!1}},{key:"programDateTime",get:function(){return null===this._programDateTime&&this.rawProgramDateTime&&(this.programDateTime=Date.parse(this.rawProgramDateTime)),this._programDateTime},set:function(e){$E(e)?this._programDateTime=e:this._programDateTime=this.rawProgramDateTime=null}},{key:"ref",get:function(){return xT(this)?(this._ref||(this._ref={base:this.base,start:this.start,duration:this.duration,sn:this.sn,programDateTime:this.programDateTime}),this._ref):null}},{key:"addStart",value:function(e){this.setStart(this.start+e)}},{key:"setStart",value:function(e){this.start=e,this._ref&&(this._ref.start=e)}},{key:"setDuration",value:function(e){this.duration=e,this._ref&&(this._ref.duration=e)}},{key:"setKeyFormat",value:function(e){var t=this.levelkeys;if(t){var i,n=t[e];!n||null!=(i=this._decryptdata)&&i.keyId||(this._decryptdata=n.getDecryptData(this.sn,t))}}},{key:"abortRequests",value:function(){var e,t;null==(e=this.loader)||e.abort(),null==(t=this.keyLoader)||t.abort()}},{key:"setElementaryStreamInfo",value:function(e,t,i,n,a,r=!1){var o=this.elementaryStreams,s=o[e];s?(s.startPTS=Math.min(s.startPTS,t),s.endPTS=Math.max(s.endPTS,i),s.startDTS=Math.min(s.startDTS,n),s.endDTS=Math.max(s.endDTS,a)):o[e]={startPTS:t,endPTS:i,startDTS:n,endDTS:a,partial:r}}}])}(),IT=function(){function e(t,i,n,a,r){var o;u(this,e),(o=s(this,e,[n])).fragOffset=0,o.duration=0,o.gap=!1,o.independent=!1,o.relurl=void 0,o.fragment=void 0,o.index=void 0,o.duration=t.decimalFloatingPoint("DURATION"),o.gap=t.bool("GAP"),o.independent=t.bool("INDEPENDENT"),o.relurl=t.enumeratedString("URI"),o.fragment=i,o.index=a;var l=t.enumeratedString("BYTERANGE");return l&&o.setByteRange(l,r),r&&(o.fragOffset=r.fragOffset+r.duration),o}return y(e,DT),m(e,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var e=this.elementaryStreams;return!!(e.audio||e.video||e.audiovideo)}}])}();function LT(e,t){var i=Object.getPrototypeOf(e);if(i){var n=Object.getOwnPropertyDescriptor(i,t);return n||LT(i,t)}}var _T=Math.pow(2,32)-1,RT=[].push,FT={video:1,audio:2,id3:3,text:4};function OT(e){return String.fromCharCode.apply(null,e)}function WT(e,t){var i=e[t]<<8|e[t+1];return i<0?65536+i:i}function $T(e,t){var i=jT(e,t);return i<0?4294967296+i:i}function NT(e,t){var i=$T(e,t);return i*=Math.pow(2,32),i+=$T(e,t+4)}function jT(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function BT(e,t){var i=[];if(!t.length)return i;for(var n=e.byteLength,a=0;a<n;){var r=$T(e,a),o=r>1?a+r:n;if(OT(e.subarray(a+4,a+8))===t[0])if(1===t.length)i.push(e.subarray(a+8,o));else{var s=BT(e.subarray(a+8,o),t.slice(1));s.length&&RT.apply(i,s)}a=o}return i}function zT(e){var t=[],i=e[0],n=8,a=$T(e,n);n+=4;var r=0,o=0;0===i?(r=$T(e,n),o=$T(e,n+4),n+=8):(r=NT(e,n),o=NT(e,n+8),n+=16),n+=2;var s=e.length+o,u=WT(e,n);n+=2;for(var l=0;l<u;l++){var d=n,h=$T(e,d);d+=4;var c=2147483647&h;if(1===(2147483648&h)>>>31)return lT.warn("SIDX has hierarchical references (not supported)"),null;var m=$T(e,d);d+=4,t.push({referenceSize:c,subsegmentDuration:m,info:{duration:m/a,start:s,end:s+c-1}}),s+=c,n=d+=4}return{earliestPresentationTime:r,timescale:a,version:i,referencesCount:u,references:t}}function UT(e){for(var t=[],i=BT(e,["moov","trak"]),n=0;n<i.length;n++){var a=i[n],r=BT(a,["tkhd"])[0];if(r){var o=r[0],s=$T(r,0===o?12:20),u=BT(a,["mdia","mdhd"])[0];if(u){var l=$T(u,0===(o=u[0])?12:20),d=BT(a,["mdia","hdlr"])[0];if(d){var h=OT(d.subarray(8,12)),c={soun:PT,vide:MT}[h],m=HT(BT(a,["mdia","minf","stbl","stsd"])[0]);c?(t[s]={timescale:l,type:c,stsd:m},t[c]=iT({timescale:l,id:s},m)):t[s]={timescale:l,type:h,stsd:m}}}}}return BT(e,["moov","mvex","trex"]).forEach(e=>{var i=$T(e,4),n=t[i];n&&(n.default={duration:$T(e,12),flags:$T(e,20)})}),t}function HT(e){var t,i=e.subarray(8),n=i.subarray(86),a=OT(i.subarray(4,8)),r=a,o="enca"===a||"encv"===a;if(o){var s=BT(i,[a])[0];BT(s.subarray("enca"===a?28:78),["sinf"]).forEach(e=>{var t=BT(e,["schm"])[0];if(t){var i=OT(t.subarray(4,8));if("cbcs"===i||"cenc"===i){var n=BT(e,["frma"])[0];n&&(r=OT(n))}}})}var u=r;switch(r){case"avc1":case"avc2":case"avc3":case"avc4":var l=BT(n,["avcC"])[0];l&&l.length>3&&(r+="."+KT(l[1])+KT(l[2])+KT(l[3]),t=GT("avc1"===u?"dva1":"dvav",n));break;case"mp4a":var d=BT(i,[a])[0],h=BT(d.subarray(28),["esds"])[0];if(h&&h.length>7){var c=4;if(3!==h[c++])break;c=VT(h,c),c+=2;var m=h[c++];if(128&m&&(c+=2),64&m&&(c+=h[c++]),4!==h[c++])break;c=VT(h,c);var f=h[c++];if(64!==f)break;if(r+="."+KT(f),c+=12,5!==h[c++])break;c=VT(h,c);var v=h[c++],p=(248&v)>>3;31===p&&(p+=1+((7&v)<<3)+((224&h[c])>>5)),r+="."+p}break;case"hvc1":case"hev1":var g=BT(n,["hvcC"])[0];if(g&&g.length>12){var y=g[1],b=["","A","B","C"][y>>6],w=31&y,k=$T(g,2),S=(32&y)>>5?"H":"L",E=g[12],T=g.subarray(6,12);r+="."+b+w,r+="."+function(e){for(var t=0,i=0;i<32;i++)t|=(e>>i&1)<<31-i;return t>>>0}(k).toString(16).toUpperCase(),r+="."+S+E;for(var P="",M=T.length;M--;){var A=T[M];if(A||P)P="."+A.toString(16).toUpperCase()+P}r+=P}t=GT("hev1"==u?"dvhe":"dvh1",n);break;case"dvh1":case"dvhe":case"dvav":case"dva1":case"dav1":r=GT(r,n)||r;break;case"vp09":var D=BT(n,["vpcC"])[0];if(D&&D.length>6){var x=D[4],C=D[5],I=D[6]>>4&15;r+="."+XT(x)+"."+XT(C)+"."+XT(I)}break;case"av01":var L=BT(n,["av1C"])[0];if(L&&L.length>2){var _=L[1]>>>5,R=31&L[1],F=L[2]>>>7?"H":"M",O=(64&L[2])>>6,W=(32&L[2])>>5,$=2===_&&O?W?12:10:O?10:8,N=(16&L[2])>>4,j=(8&L[2])>>3,B=(4&L[2])>>2,z=3&L[2];r+="."+_+"."+XT(R)+F+"."+XT($)+"."+N+"."+j+B+z+"."+XT(1)+"."+XT(1)+"."+XT(1)+".0",t=GT("dav1",n)}}return{codec:r,encrypted:o,supplemental:t}}function GT(e,t){var i=BT(t,["dvvC"]),n=i.length?i[0]:BT(t,["dvcC"])[0];if(n){var a=n[2]>>1&127,r=n[2]<<5&32|n[3]>>3&31;return e+"."+XT(a)+"."+XT(r)}}function VT(e,t){for(var i=t+5;128&e[t++]&&t<i;);return t}function KT(e){return("0"+e.toString(16).toUpperCase()).slice(-2)}function XT(e){return(e<10?"0":"")+e}function YT(e,t){BT(e,["moov","trak"]).forEach(e=>{var i=BT(e,["mdia","minf","stbl","stsd"])[0];if(i){var n=i.subarray(8),a=BT(n,["enca"]),r=a.length>0;r||(a=BT(n,["encv"])),a.forEach(e=>{BT(r?e.subarray(28):e.subarray(78),["sinf"]).forEach(e=>{var i=qT(e);i&&t(i,r)})})}})}function qT(e){var t=BT(e,["schm"])[0];if(t){var i=OT(t.subarray(4,8));if("cbcs"===i||"cenc"===i){var n=BT(e,["schi","tenc"])[0];if(n)return n}}}function JT(e,t){var i=new Uint8Array(e.length+t.length);return i.set(e),i.set(t,e.length),i}function QT(e,t){var i=[],n=t.samples,a=t.timescale,r=t.id,o=!1;return BT(n,["moof"]).map(s=>{var u=s.byteOffset-8;BT(s,["traf"]).map(s=>{var l=BT(s,["tfdt"]).map(e=>{var t=e[0],i=$T(e,4);return 1===t&&(i*=Math.pow(2,32),i+=$T(e,8)),i/a})[0];return void 0!==l&&(e=l),BT(s,["tfhd"]).map(l=>{var d=$T(l,4),h=16777215&$T(l,0),c=0,m=!!(16&h),f=0,v=!!(32&h),p=8;d===r&&(!!(1&h)&&(p+=8),!!(2&h)&&(p+=4),!!(8&h)&&(c=$T(l,p),p+=4),m&&(f=$T(l,p),p+=4),v&&(p+=4),"video"===t.type&&(o=ZT(t.codec)),BT(s,["trun"]).map(r=>{var s=r[0],l=16777215&$T(r,0),d=!!(1&l),h=0,m=!!(4&l),v=!!(256&l),p=0,g=!!(512&l),y=0,b=!!(1024&l),w=!!(2048&l),k=0,S=$T(r,4),E=8;d&&(h=$T(r,E),E+=4),m&&(E+=4);for(var T=h+u,P=0;P<S;P++){if(v?(p=$T(r,E),E+=4):p=c,g?(y=$T(r,E),E+=4):y=f,b&&(E+=4),w&&(k=0===s?$T(r,E):jT(r,E),E+=4),t.type===MT)for(var M=0;M<y;){var A=$T(n,T);if(eP(o,n[T+=4]))tP(n.subarray(T,T+A),o?2:1,e+k/a,i);T+=A,M+=A+4}e+=p/a}}))})})}),i}function ZT(e){if(!e)return!1;var t=e.substring(0,4);return"hvc1"===t||"hev1"===t||"dvh1"===t||"dvhe"===t}function eP(e,t){if(e){var i=t>>1&63;return 39===i||40===i}return 6===(31&t)}function tP(e,t,i,n){var a=iP(e),r=0;r+=t;for(var o=0,s=0,u=0;r<a.length;){o=0;do{if(r>=a.length)break;o+=u=a[r++]}while(255===u);s=0;do{if(r>=a.length)break;s+=u=a[r++]}while(255===u);var l=a.length-r,d=r;if(s<l)r+=s;else if(s>l){lT.error(`Malformed SEI payload. ${s} is too small, only ${l} bytes left to parse.`);break}if(4===o){if(181===a[d++]){var h=WT(a,d);if(d+=2,49===h){var c=$T(a,d);if(d+=4,1195456820===c){var m=a[d++];if(3===m){var f=a[d++],v=64&f,p=v?2+3*(31&f):0,g=new Uint8Array(p);if(v){g[0]=f;for(var y=1;y<p;y++)g[y]=a[d++]}n.push({type:m,payloadType:o,pts:i,bytes:g})}}}}}else if(5===o&&s>16){for(var b=[],w=0;w<16;w++){var k=a[d++].toString(16);b.push(1==k.length?"0"+k:k),3!==w&&5!==w&&7!==w&&9!==w||b.push("-")}for(var S=s-16,E=new Uint8Array(S),T=0;T<S;T++)E[T]=a[d++];n.push({payloadType:o,pts:i,uuid:b.join(""),userData:cT(E),userDataBytes:E})}}}function iP(e){for(var t=e.byteLength,i=[],n=1;n<t-2;)0===e[n]&&0===e[n+1]&&3===e[n+2]?(i.push(n+2),n+=2):n++;if(0===i.length)return e;var a=t-i.length,r=new Uint8Array(a),o=0;for(n=0;n<a;o++,n++)o===i[0]&&(o++,i.shift()),r[n]=e[o];return r}function nP(e,t,i){if(16!==e.byteLength)throw new RangeError("Invalid system id");var n,a;n=new Uint8Array,a=new Uint8Array;var r=new Uint8Array(4);return i.byteLength>0&&new DataView(r.buffer).setUint32(0,i.byteLength,!1),function(e,...t){for(var i=t.length,n=8,a=i;a--;)n+=t[a].byteLength;var r=new Uint8Array(n);for(r[0]=n>>24&255,r[1]=n>>16&255,r[2]=n>>8&255,r[3]=255&n,r.set(e,4),a=0,n=8;a<i;a++)r.set(t[a],n),n+=t[a].byteLength;return r}([112,115,115,104],new Uint8Array([0,0,0,0]),e,a,n,r,i)}function aP(e){var t=e.getUint32(0),i=e.byteOffset,n=e.byteLength;if(n<t)return{offset:i,size:n};if(1886614376!==e.getUint32(4))return{offset:i,size:t};var a=e.getUint32(8)>>>24;if(0!==a&&1!==a)return{offset:i,size:t};var r=e.buffer,o=mT(new Uint8Array(r,i+12,16)),s=null,u=0;if(0===a)u=28;else{var l=e.getUint32(28);if(!l||n<32+16*l)return{offset:i,size:t};s=[];for(var d=0;d<l;d++)s.push(new Uint8Array(r,i+32+16*d,16));u=32+16*l}if(!u)return{offset:i,size:t};var h=e.getUint32(u);return t-32<h?{offset:i,size:t}:{version:a,systemId:o,kids:s,data:new Uint8Array(r,i+u+4,h),offset:i,size:t}}var rP=()=>/\(Windows.+Firefox\//i.test(navigator.userAgent),oP={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,dav1:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv60:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1}};function sP(e,t){var i=oP[t];return!!i&&!!i[e.slice(0,4)]}function uP(e,t,i=!0){return!e.split(",").some(e=>!lP(e,t,i))}function lP(e,t,i=!0){var n,a=dT(i);return null!=(n=null==a?void 0:a.isTypeSupported(dP(e,t)))&&n}function dP(e,t){return`${t}/mp4;codecs=${e}`}function hP(e){if(e){var t=e.substring(0,4);return oP.video[t]}return 2}function cP(e){var t=rP();return e.split(",").reduce((e,i)=>{var n=t&&ZT(i)?9:oP.video[i];return n?(2*n+e)/(e?3:2):(oP.audio[i]+e)/(e?2:1)},0)}var mP={};var fP=/flac|opus|mp4a\.40\.34/i;function vP(e,t=!0){return e.replace(fP,e=>function(e,t=!0){if(mP[e])return mP[e];for(var i={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"],"mp4a.40.34":["mp3"]}[e],n=0;n<i.length;n++){var a;if(lP(i[n],"audio",t))return mP[e]=i[n],i[n];if("mp3"===i[n]&&null!=(a=dT(t))&&a.isTypeSupported("audio/mpeg"))return""}return e}(e.toLowerCase(),t))}function pP(e,t){if(e&&(e.length>4||-1!==["ac-3","ec-3","alac","fLaC","Opus"].indexOf(e))&&(gP(e,"audio")||gP(e,"video")))return e;if(t){var i=t.split(",");if(i.length>1){if(e)for(var n=i.length;n--;)if(i[n].substring(0,4)===e.substring(0,4))return i[n];return i[0]}}return t||e}function gP(e,t){return sP(e,t)&&lP(e,t)}function yP(e){if(e.startsWith("av01.")){for(var t=e.split("."),i=["0","111","01","01","01","0"],n=t.length;n>4&&n<10;n++)t[n]=i[n-4];return t.join(".")}return e}function bP(e){var t=dT(e)||{isTypeSupported:()=>!1};return{mpeg:t.isTypeSupported("audio/mpeg"),mp3:t.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:t.isTypeSupported('audio/mp4; codecs="ac-3"')}}function wP(e){return e.replace(/^.+codecs=["']?([^"']+).*$/,"$1")}var kP={supported:!1,smooth:!1,powerEfficient:!1},SP={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]};function EP(e,t){return{supported:!1,configurations:t,decodingInfoResults:[kP],error:e}}function TP(e,t,i,n={}){var a=e.videoCodec;if(!a&&!e.audioCodec||!i)return Promise.resolve(SP);for(var r=[],o=function(e){var t,i=null==(t=e.videoCodec)?void 0:t.split(","),n=MP(e),a=e.width||640,r=e.height||480,o=e.frameRate||30,s=e.videoRange.toLowerCase();return i?i.map(e=>{var t={contentType:dP(yP(e),"video"),width:a,height:r,bitrate:n,framerate:o};return"sdr"!==s&&(t.transferFunction=s),t}):[]}(e),s=o.length,u=function(e,t,i){var n,a=null==(n=e.audioCodec)?void 0:n.split(","),r=MP(e);if(a&&e.audioGroups)return e.audioGroups.reduce((e,n)=>{var o,s=n?null==(o=t.groups[n])?void 0:o.tracks:null;return s?s.reduce((e,t)=>{if(t.groupId===n){var o=parseFloat(t.channels||"");a.forEach(t=>{var n={contentType:dP(t,"audio"),bitrate:i?PP(t,r):r};o&&(n.channels=""+o),e.push(n)})}return e},e):e},[]);return[]}(e,t,s>0),l=u.length,d=s||1*l||1;d--;){var h={type:"media-source"};if(s&&(h.video=o[d%s]),l){h.audio=u[d%l];var c=h.audio.bitrate;h.video&&c&&(h.video.bitrate-=c)}r.push(h)}if(a){var m=navigator.userAgent;if(a.split(",").some(e=>ZT(e))&&rP())return Promise.resolve(EP(new Error(`Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent string: (${m})`),r))}return Promise.all(r.map(e=>{var t=function(e){var t="",i=e.audio,n=e.video;if(n){t+=`${wP(n.contentType)}_r${n.height}x${n.width}f${Math.ceil(n.framerate)}${n.transferFunction||"sd"}_${Math.ceil(n.bitrate/1e5)}`}if(i){t+=`${n?"_":""}${wP(i.contentType)}_c${i.channels}`}return t}(e);return n[t]||(n[t]=i.decodingInfo(e))})).then(e=>({supported:!e.some(e=>!e.supported),configurations:r,decodingInfoResults:e})).catch(e=>({supported:!1,configurations:r,decodingInfoResults:[],error:e}))}function PP(e,t){if(t<=1)return 1;var i=128e3;return"ec-3"===e?i=768e3:"ac-3"===e&&(i=64e4),Math.min(t/2,i)}function MP(e){return 1e3*Math.ceil(Math.max(.9*e.bitrate,e.averageBitrate)/1e3)||1}var AP=["NONE","TYPE-0","TYPE-1",null];var DP=["SDR","PQ","HLG"];var xP="",CP="YES",IP="v2";function LP(e){var t=e.canSkipUntil,i=e.canSkipDateRanges,n=e.age;return t&&n<t/2?i?IP:CP:xP}var _P=function(){return m(function e(t,i,n){u(this,e),this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=t,this.part=i,this.skip=n},[{key:"addDirectives",value:function(e){var t=new self.URL(e);return void 0!==this.msn&&t.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href}}])}(),RP=function(){return m(function e(t){if(u(this,e),this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.supplemental=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=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.frameRate=t.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=t.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=t.audioCodec,this.videoCodec=t.videoCodec,this.codecSet=[t.videoCodec,t.audioCodec].filter(e=>!!e).map(e=>e.substring(0,4)).join(","),"supplemental"in t){var i;this.supplemental=t.supplemental;var n=null==(i=t.supplemental)?void 0:i.videoCodec;n&&n!==t.videoCodec&&(this.codecSet+=`,${n.substring(0,4)}`)}this.addGroupId("audio",t.attrs.AUDIO),this.addGroupId("text",t.attrs.SUBTITLES)},[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"averageBitrate",get:function(){return this._avgBitrate||this.realBitrate||this.bitrate}},{key:"attrs",get:function(){return this._attrs[0]}},{key:"codecs",get:function(){return this.attrs.CODECS||""}},{key:"pathwayId",get:function(){return this.attrs["PATHWAY-ID"]||"."}},{key:"videoRange",get:function(){return this.attrs["VIDEO-RANGE"]||"SDR"}},{key:"score",get:function(){return this.attrs.optionalFloat("SCORE",0)}},{key:"uri",get:function(){return this.url[0]||""}},{key:"hasAudioGroup",value:function(e){return FP(this._audioGroups,e)}},{key:"hasSubtitleGroup",value:function(e){return FP(this._subtitleGroups,e)}},{key:"audioGroups",get:function(){return this._audioGroups}},{key:"subtitleGroups",get:function(){return this._subtitleGroups}},{key:"addGroupId",value:function(e,t){if(t)if("audio"===e){var i=this._audioGroups;i||(i=this._audioGroups=[]),-1===i.indexOf(t)&&i.push(t)}else if("text"===e){var n=this._subtitleGroups;n||(n=this._subtitleGroups=[]),-1===n.indexOf(t)&&n.push(t)}}},{key:"urlId",get:function(){return 0},set:function(e){}},{key:"audioGroupIds",get:function(){return this.audioGroups?[this.audioGroupId]:void 0}},{key:"textGroupIds",get:function(){return this.subtitleGroups?[this.textGroupId]:void 0}},{key:"audioGroupId",get:function(){var e;return null==(e=this.audioGroups)?void 0:e[0]}},{key:"textGroupId",get:function(){var e;return null==(e=this.subtitleGroups)?void 0:e[0]}},{key:"addFallback",value:function(){}}])}();function FP(e,t){return!(!t||!e)&&-1!==e.indexOf(t)}function OP(e,t){var i=!1,n=[];if(e&&(i="SDR"!==e,n=[e]),t){var a="SDR"!==(n=t.allowedVideoRanges||DP.slice(0)).join("")&&!t.videoCodec;(i=void 0!==t.preferHDR?t.preferHDR:a&&function(){if("function"==typeof matchMedia){var e=matchMedia("(dynamic-range: high)"),t=matchMedia("bad query");if(e.media!==t.media)return!0===e.matches}return!1}())||(n=["SDR"])}return{preferHDR:i,allowedVideoRanges:n}}var WP=(e,t)=>JSON.stringify(e,(e=>{var t=new WeakSet;return(i,n)=>{if(e&&(n=e(i,n)),"object"==typeof n&&null!==n){if(t.has(n))return;t.add(n)}return n}})(t));function $P(e,t){lT.log(`[abr] start candidates with "${e}" ignored because ${t}`)}function NP(e){return e.reduce((e,t)=>{var i=e.groups[t.groupId];i||(i=e.groups[t.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),i.tracks.push(t);var n=t.channels||"2";return i.channels[n]=(i.channels[n]||0)+1,i.hasDefault=i.hasDefault||t.default,i.hasAutoSelect=i.hasAutoSelect||t.autoselect,i.hasDefault&&(e.hasDefaultAudio=!0),i.hasAutoSelect&&(e.hasAutoSelectAudio=!0),e},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function jP(e){return e?{lang:e.lang,assocLang:e.assocLang,characteristics:e.characteristics,channels:e.channels,audioCodec:e.audioCodec}:e}function BP(e,t,i){if("attrs"in e){var n=t.indexOf(e);if(-1!==n)return n}for(var a=0;a<t.length;a++){if(zP(e,t[a],i))return a}return-1}function zP(e,t,i){var n=e.groupId,a=e.name,r=e.lang,o=e.assocLang,s=e.default,u=e.forced;return(void 0===n||t.groupId===n)&&(void 0===a||t.name===a)&&(void 0===r||function(e,t="--"){if(e.length===t.length)return e===t;return e.startsWith(t)||t.startsWith(e)}(r,t.lang))&&(void 0===r||t.assocLang===o)&&(void 0===s||t.default===s)&&(void 0===u||t.forced===u)&&(!("characteristics"in e)||function(e,t=""){var i=e.split(","),n=t.split(",");return i.length===n.length&&!i.some(e=>-1===n.indexOf(e))}(e.characteristics||"",t.characteristics))&&(void 0===i||i(e,t))}function UP(e,t){var i=e.audioCodec,n=e.channels;return!(void 0!==i&&(t.audioCodec||"").substring(0,4)!==i.substring(0,4)||void 0!==n&&n!==(t.channels||"2"))}function HP(e,t,i){for(var n=t;n>-1;n--)if(i(e[n]))return n;for(var a=t+1;a<e.length;a++)if(i(e[a]))return a;return-1}function GP(e,t){var i;return!!e&&e!==(null==(i=t.loadLevelObj)?void 0:i.uri)}var VP=function(){function e(t){var i;return u(this,e),(i=s(this,e,["abr",t.logger])).hls=void 0,i.lastLevelLoadSec=0,i.lastLoadedFragLevel=-1,i.firstSelection=-1,i._nextAutoLevel=-1,i.nextAutoLevelKey="",i.audioTracksByGroup=null,i.codecTiers=null,i.timer=-1,i.fragCurrent=null,i.partCurrent=null,i.bitrateTestDelay=0,i.rebufferNotice=-1,i.supportedCache={},i.bwEstimator=void 0,i._abandonRulesCheck=e=>{var t,n=i,a=n.fragCurrent,r=n.partCurrent,o=n.hls,s=o.autoLevelEnabled,u=o.media;if(a&&u){var l=performance.now(),d=r?r.stats:a.stats,h=r?r.duration:a.duration,c=l-d.loading.start,m=o.minAutoLevel,f=a.level,v=i._nextAutoLevel;if(d.aborted||d.loaded&&d.loaded===d.total||f<=m)return i.clearTimer(),void(i._nextAutoLevel=-1);if(s){var p=v>-1&&v!==f,g=!!e||p;if(g||!u.paused&&u.playbackRate&&u.readyState){var y=o.mainForwardBufferInfo;if(g||null!==y){var b=i.bwEstimator.getEstimateTTFB(),w=Math.abs(u.playbackRate);if(!(c<=Math.max(b,h/(2*w)*1e3))){var k=y?y.len/w:0,S=d.loading.first?d.loading.first-d.loading.start:-1,E=d.loaded&&S>-1,T=i.getBwEstimate(),P=o.levels,M=P[f],A=Math.max(d.loaded,Math.round(h*(a.bitrate||M.averageBitrate)/8)),D=E?c-S:c;D<1&&E&&(D=Math.min(c,8*d.loaded/T));var x=E?1e3*d.loaded/D:0,C=b/1e3,I=x?(A-d.loaded)/x:8*A/T+C;if(!(I<=k)){var L,_=x?8*x:T,R=!0===(null==(t=(null==e?void 0:e.details)||i.hls.latestLevelDetails)?void 0:t.live),F=i.hls.config.abrBandWidthUpFactor,O=Number.POSITIVE_INFINITY;for(L=f-1;L>m;L--){var W=P[L].maxBitrate,$=!P[L].details||R;if((O=i.getTimeToLoadFrag(C,_,h*W,$))<Math.min(k,h+C))break}if(!(O>=I||O>10*h)){E?i.bwEstimator.sample(c-Math.min(b,S),d.loaded):i.bwEstimator.sampleTTFB(c);var N=P[L].maxBitrate;i.getBwEstimate()*F>N&&i.resetEstimator(N);var j=i.findBestLevel(N,m,L,0,k,1,1);j>-1&&(L=j),i.warn(`Fragment ${a.sn}${r?" part "+r.index:""} of level ${f} is loading too slowly;\n Fragment duration: ${a.duration.toFixed(3)}\n Time to underbuffer: ${k.toFixed(3)} s\n Estimated load time for current fragment: ${I.toFixed(3)} s\n Estimated load time for down switch fragment: ${O.toFixed(3)} s\n TTFB estimate: ${0|S} ms\n Current BW estimate: ${$E(T)?0|T:"Unknown"} bps\n New BW estimate: ${0|i.getBwEstimate()} bps\n Switching to level ${L} @ ${0|N} bps`),o.nextLoadLevel=o.nextAutoLevel=L,i.clearTimer();var B=()=>{if(i.clearTimer(),i.fragCurrent===a&&i.hls.loadLevel===L&&L>0){var e=i.getStarvationDelay();if(i.warn(`Aborting inflight request ${L>0?"and switching down":""}\n Fragment duration: ${a.duration.toFixed(3)} s\n Time to underbuffer: ${e.toFixed(3)} s`),a.abortRequests(),i.fragCurrent=i.partCurrent=null,L>m){var t=i.findBestLevel(i.hls.levels[m].bitrate,m,L,0,e,1,1);-1===t&&(t=m),i.hls.nextLoadLevel=i.hls.nextAutoLevel=t,i.resetEstimator(i.hls.levels[t].bitrate)}}};p||I>2*O?B():i.timer=self.setInterval(B,1e3*O),o.trigger(UE.FRAG_LOAD_EMERGENCY_ABORTED,{frag:a,part:r,stats:d})}}}}}}}},i.hls=t,i.bwEstimator=i.initEstimator(),i.registerListeners(),i}return y(e,nT),m(e,[{key:"resetEstimator",value:function(e){e&&(this.log(`setting initial bwe to ${e}`),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()}},{key:"initEstimator",value:function(){var e=this.hls.config;return new QE(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}},{key:"registerListeners",value:function(){var e=this.hls;e.on(UE.MANIFEST_LOADING,this.onManifestLoading,this),e.on(UE.FRAG_LOADING,this.onFragLoading,this),e.on(UE.FRAG_LOADED,this.onFragLoaded,this),e.on(UE.FRAG_BUFFERED,this.onFragBuffered,this),e.on(UE.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(UE.LEVEL_LOADED,this.onLevelLoaded,this),e.on(UE.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(UE.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(UE.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(UE.MANIFEST_LOADING,this.onManifestLoading,this),e.off(UE.FRAG_LOADING,this.onFragLoading,this),e.off(UE.FRAG_LOADED,this.onFragLoaded,this),e.off(UE.FRAG_BUFFERED,this.onFragBuffered,this),e.off(UE.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(UE.LEVEL_LOADED,this.onLevelLoaded,this),e.off(UE.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(UE.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(UE.ERROR,this.onError,this))}},{key:"destroy",value:function(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=this.supportedCache=null,this.fragCurrent=this.partCurrent=null}},{key:"onManifestLoading",value:function(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.supportedCache={},this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()}},{key:"onLevelsUpdated",value:function(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null}},{key:"onMaxAutoLevelUpdated",value:function(){this.firstSelection=-1,this.nextAutoLevelKey=""}},{key:"onFragLoading",value:function(e,t){var i=t.frag;if(!this.ignoreFragment(i)){var n;if(!i.bitrateTest)this.fragCurrent=i,this.partCurrent=null!=(n=t.part)?n:null;this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100)}}},{key:"onLevelSwitching",value:function(e,t){this.clearTimer()}},{key:"onError",value:function(e,t){if(!t.fatal)switch(t.details){case zE.BUFFER_ADD_CODEC_ERROR:case zE.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case zE.FRAG_LOAD_TIMEOUT:var i=t.frag,n=this.fragCurrent,a=this.partCurrent;if(i&&n&&i.sn===n.sn&&i.level===n.level){var r=performance.now(),o=a?a.stats:i.stats,s=r-o.loading.start,u=o.loading.first?o.loading.first-o.loading.start:-1;if(o.loaded&&u>-1){var l=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(s-Math.min(l,u),o.loaded)}else this.bwEstimator.sampleTTFB(s)}}}},{key:"getTimeToLoadFrag",value:function(e,t,i,n){return e+i/t+(n?e+this.lastLevelLoadSec:0)}},{key:"onLevelLoaded",value:function(e,t){var i=this.hls.config,n=t.stats.loading,a=n.end-n.first;$E(a)&&(this.lastLevelLoadSec=a/1e3),t.details.live?this.bwEstimator.update(i.abrEwmaSlowLive,i.abrEwmaFastLive):this.bwEstimator.update(i.abrEwmaSlowVoD,i.abrEwmaFastVoD),this.timer>-1&&this._abandonRulesCheck(t.levelInfo)}},{key:"onFragLoaded",value:function(e,{frag:t,part:i}){var n=i?i.stats:t.stats;if(t.type===XE&&this.bwEstimator.sampleTTFB(n.loading.first-n.loading.start),!this.ignoreFragment(t)){if(this.clearTimer(),t.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){var a=i?i.duration:t.duration,r=this.hls.levels[t.level],o=(r.loaded?r.loaded.bytes:0)+n.loaded,s=(r.loaded?r.loaded.duration:0)+a;r.loaded={bytes:o,duration:s},r.realBitrate=Math.round(8*o/s)}if(t.bitrateTest){var u={stats:n,frag:t,part:i,id:t.type};this.onFragBuffered(UE.FRAG_BUFFERED,u),t.bitrateTest=!1}else this.lastLoadedFragLevel=t.level}}},{key:"onFragBuffered",value:function(e,t){var i=t.frag,n=t.part,a=null!=n&&n.stats.loaded?n.stats:i.stats;if(!a.aborted&&!this.ignoreFragment(i)){var r=a.parsing.end-a.loading.start-Math.min(a.loading.first-a.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(r,a.loaded),a.bwEstimate=this.getBwEstimate(),i.bitrateTest?this.bitrateTestDelay=r/1e3:this.bitrateTestDelay=0}}},{key:"ignoreFragment",value:function(e){return e.type!==XE||"initSegment"===e.sn}},{key:"clearTimer",value:function(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)}},{key:"firstAutoLevel",get:function(){var e=this.hls,t=e.maxAutoLevel,i=e.minAutoLevel,n=this.getBwEstimate(),a=this.hls.config.maxStarvationDelay,r=this.findBestLevel(n,i,t,0,a,1,1);if(r>-1)return r;var o=this.hls.firstLevel,s=Math.min(Math.max(o,i),t);return this.warn(`Could not find best starting auto level. Defaulting to first in playlist ${o} clamped to ${s}`),s}},{key:"forcedAutoLevel",get:function(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}},{key:"nextAutoLevel",get:function(){var e=this.forcedAutoLevel,t=this.bwEstimator.canEstimate(),i=this.lastLoadedFragLevel>-1;if(!(-1===e||t&&i&&this.nextAutoLevelKey!==this.getAutoLevelKey()))return e;var n=t&&i?this.getNextABRAutoLevel():this.firstAutoLevel;if(-1!==e){var a=this.hls.levels;if(a.length>Math.max(e,n)&&a[e].loadError<=a[n].loadError)return e}return this._nextAutoLevel=n,this.nextAutoLevelKey=this.getAutoLevelKey(),n},set:function(e){var t=this.deriveNextAutoLevel(e);this._nextAutoLevel!==t&&(this.nextAutoLevelKey="",this._nextAutoLevel=t)}},{key:"getAutoLevelKey",value:function(){return`${this.getBwEstimate()}_${this.getStarvationDelay().toFixed(2)}`}},{key:"getNextABRAutoLevel",value:function(){var e=this.fragCurrent,t=this.partCurrent,i=this.hls;if(i.levels.length<=1)return i.loadLevel;var n=i.maxAutoLevel,a=i.config,r=i.minAutoLevel,o=t?t.duration:e?e.duration:0,s=this.getBwEstimate(),u=this.getStarvationDelay(),l=a.abrBandWidthFactor,d=a.abrBandWidthUpFactor;if(u){var h=this.findBestLevel(s,r,n,u,0,l,d);if(h>=0)return this.rebufferNotice=-1,h}var c=o?Math.min(o,a.maxStarvationDelay):a.maxStarvationDelay;if(!u){var m=this.bitrateTestDelay;if(m)c=(o?Math.min(o,a.maxLoadingDelay):a.maxLoadingDelay)-m,this.info(`bitrate test took ${Math.round(1e3*m)}ms, set first fragment max fetchDuration to ${Math.round(1e3*c)} ms`),l=d=1}var f=this.findBestLevel(s,r,n,u,c,l,d);if(this.rebufferNotice!==f&&(this.rebufferNotice=f,this.info(`${u?"rebuffering expected":"buffer is empty"}, optimal quality level ${f}`)),f>-1)return f;var v=i.levels[r],p=i.loadLevelObj;return p&&(null==v?void 0:v.bitrate)<p.bitrate?r:i.loadLevel}},{key:"getStarvationDelay",value:function(){var e=this.hls,t=e.media;if(!t)return 1/0;var i=t&&0!==t.playbackRate?Math.abs(t.playbackRate):1,n=e.mainForwardBufferInfo;return(n?n.len:0)/i}},{key:"getBwEstimate",value:function(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate}},{key:"findBestLevel",value:function(e,t,i,n,a,r,o){var s,u=this,l=n+a,d=this.lastLoadedFragLevel,h=-1===d?this.hls.firstLevel:d,c=this.fragCurrent,m=this.partCurrent,f=this.hls,v=f.levels,p=f.allAudioTracks,g=f.loadLevel,y=f.config;if(1===v.length)return 0;var b,w=v[h],k=!(null==(s=this.hls.latestLevelDetails)||!s.live),S=-1===g||-1===d,E="SDR",T=(null==w?void 0:w.frameRate)||0,P=y.audioPreference,M=y.videoPreference,A=this.audioTracksByGroup||(this.audioTracksByGroup=NP(p)),D=-1;if(S){if(-1!==this.firstSelection)return this.firstSelection;var x=this.codecTiers||(this.codecTiers=function(e,t,i,n){return e.slice(i,n+1).reduce((e,i,n)=>{if(!i.codecSet)return e;var a=i.audioGroups,r=e[i.codecSet];r||(e[i.codecSet]=r={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,minIndex:n,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!a,fragmentError:0}),r.minBitrate=Math.min(r.minBitrate,i.bitrate);var o=Math.min(i.height,i.width);return r.minHeight=Math.min(r.minHeight,o),r.minFramerate=Math.min(r.minFramerate,i.frameRate),r.minIndex=Math.min(r.minIndex,n),r.maxScore=Math.max(r.maxScore,i.score),r.fragmentError+=i.fragmentError,r.videoRanges[i.videoRange]=(r.videoRanges[i.videoRange]||0)+1,a&&a.forEach(e=>{if(e){var i=t.groups[e];i&&(r.hasDefaultAudio=r.hasDefaultAudio||t.hasDefaultAudio?i.hasDefault:i.hasAutoSelect||!t.hasDefaultAudio&&!t.hasAutoSelectAudio,Object.keys(i.channels).forEach(e=>{r.channels[e]=(r.channels[e]||0)+i.channels[e]}))}}),e},{})}(v,A,t,i)),C=function(e,t,i,n,a){for(var r=Object.keys(e),o=null==n?void 0:n.channels,s=null==n?void 0:n.audioCodec,u=null==a?void 0:a.videoCodec,l=o&&2===parseInt(o),d=!1,h=!1,c=1/0,m=1/0,f=1/0,v=1/0,p=0,g=[],y=OP(t,a),b=y.preferHDR,w=y.allowedVideoRanges,k=function(){var t=e[r[S]];d||(d=t.channels[2]>0),c=Math.min(c,t.minHeight),m=Math.min(m,t.minFramerate),f=Math.min(f,t.minBitrate),w.filter(e=>t.videoRanges[e]>0).length>0&&(h=!0)},S=r.length;S--;)k();c=$E(c)?c:0,m=$E(m)?m:0;var E=Math.max(1080,c),T=Math.max(30,m);f=$E(f)?f:i,i=Math.max(f,i),h||(t=void 0);var P=r.length>1;return{codecSet:r.reduce((t,n)=>{var a=e[n];if(n===t)return t;if(g=h?w.filter(e=>a.videoRanges[e]>0):[],P){if(a.minBitrate>i)return $P(n,`min bitrate of ${a.minBitrate} > current estimate of ${i}`),t;if(!a.hasDefaultAudio)return $P(n,"no renditions with default or auto-select sound found"),t;if(s&&n.indexOf(s.substring(0,4))%5!=0)return $P(n,`audio codec preference "${s}" not found`),t;if(o&&!l){if(!a.channels[o])return $P(n,`no renditions with ${o} channel sound found (channels options: ${Object.keys(a.channels)})`),t}else if((!s||l)&&d&&0===a.channels[2])return $P(n,"no renditions with stereo sound found"),t;if(a.minHeight>E)return $P(n,`min resolution of ${a.minHeight} > maximum of ${E}`),t;if(a.minFramerate>T)return $P(n,`min framerate of ${a.minFramerate} > maximum of ${T}`),t;if(!g.some(e=>a.videoRanges[e]>0))return $P(n,`no variants with VIDEO-RANGE of ${WP(g)} found`),t;if(u&&n.indexOf(u.substring(0,4))%5!=0)return $P(n,`video codec preference "${u}" not found`),t;if(a.maxScore<p)return $P(n,`max score of ${a.maxScore} < selected max of ${p}`),t}return t&&(cP(n)>=cP(t)||a.fragmentError>e[t].fragmentError)?t:(v=a.minIndex,p=a.maxScore,n)},void 0),videoRanges:g,preferHDR:b,minFramerate:m,minBitrate:f,minIndex:v}}(x,E,e,P,M),I=C.codecSet,L=C.videoRanges,_=C.minFramerate,R=C.minBitrate,F=C.minIndex,O=C.preferHDR;D=F,b=I,E=O?L[L.length-1]:L[0],T=_,e=Math.max(e,R),this.log(`picked start tier ${WP(C)}`)}else b=null==w?void 0:w.codecSet,E=null==w?void 0:w.videoRange;for(var W,$,N=m?m.duration:c?c.duration:0,j=this.bwEstimator.getEstimateTTFB()/1e3,B=[],z=function(){var t=v[U],s=U>h;if(!t)return 0;if(y.useMediaCapabilities&&!t.supportedResult&&!t.supportedPromise){var c=navigator.mediaCapabilities;"function"==typeof(null==c?void 0:c.decodingInfo)&&function(e,t,i,n,a,r){var o=e.videoCodec,s=e.audioCodec?e.audioGroups:null,u=null==r?void 0:r.audioCodec,l=null==r?void 0:r.channels,d=l?parseInt(l):u?1/0:2,h=null;if(null!=s&&s.length)try{h=1===s.length&&s[0]?t.groups[s[0]].channels:s.reduce((e,i)=>{if(i){var n=t.groups[i];if(!n)throw new Error(`Audio track group ${i} not found`);Object.keys(n.channels).forEach(t=>{e[t]=(e[t]||0)+n.channels[t]})}return e},{2:0})}catch(e){return!0}return void 0!==o&&(o.split(",").some(e=>ZT(e))||e.width>1920&&e.height>1088||e.height>1920&&e.width>1088||e.frameRate>Math.max(n,30)||"SDR"!==e.videoRange&&e.videoRange!==i||e.bitrate>Math.max(a,8e6))||!!h&&$E(d)&&Object.keys(h).some(e=>parseInt(e)>d)}(t,A,E,T,e,P)?(t.supportedPromise=TP(t,A,c,u.supportedCache),t.supportedPromise.then(e=>{if(u.hls){t.supportedResult=e;var i=u.hls.levels,n=i.indexOf(t);e.error?u.warn(`MediaCapabilities decodingInfo error: "${e.error}" for level ${n} ${WP(e)}`):e.supported?e.decodingInfoResults.some(e=>!1===e.smooth||!1===e.powerEfficient)&&u.log(`MediaCapabilities decodingInfo for level ${n} not smooth or powerEfficient: ${WP(e)}`):(u.warn(`Unsupported MediaCapabilities decodingInfo result for level ${n} ${WP(e)}`),n>-1&&i.length>1&&(u.log(`Removing unsupported level ${n}`),u.hls.removeLevel(n),-1===u.hls.loadLevel&&(u.hls.nextLoadLevel=0)))}}).catch(e=>{u.warn(`Error handling MediaCapabilities decodingInfo: ${e}`)})):t.supportedResult=SP}if((b&&t.codecSet!==b||E&&t.videoRange!==E||s&&T>t.frameRate||!s&&T>0&&T<t.frameRate||null!=(W=t.supportedResult)&&null!=(W=W.decodingInfoResults)&&W.some(e=>!1===e.smooth))&&(!S||U!==D))return B.push(U),0;var f,p=t.details,w=(m?null==p?void 0:p.partTarget:null==p?void 0:p.averagetargetduration)||N;f=s?o*e:r*e;var M=N&&n>=2*N&&0===a?t.averageBitrate:t.maxBitrate,x=u.getTimeToLoadFrag(j,f,M*w,void 0===p);if(f>=M&&(U===d||0===t.loadError&&0===t.fragmentError)&&(x<=j||!$E(x)||k&&!u.bitrateTestDelay||x<l)){var C=u.forcedAutoLevel;return U===g||-1!==C&&C===g||(B.length&&u.trace(`Skipped level(s) ${B.join(",")} of ${i} max with CODECS and VIDEO-RANGE:"${v[B[0]].codecs}" ${v[B[0]].videoRange}; not compatible with "${b}" ${E}`),u.info(`switch candidate:${h}->${U} adjustedbw(${Math.round(f)})-bitrate=${Math.round(f-M)} ttfb:${j.toFixed(1)} avgDuration:${w.toFixed(1)} maxFetchDuration:${l.toFixed(1)} fetchDuration:${x.toFixed(1)} firstSelection:${S} codecSet:${t.codecSet} videoRange:${t.videoRange} hls.loadLevel:${g}`)),S&&(u.firstSelection=U),{v:U}}},U=i;U>=t;U--)if(0!==($=z())&&$)return $.v;return-1}},{key:"deriveNextAutoLevel",value:function(e){var t=this.hls,i=t.maxAutoLevel,n=t.minAutoLevel;return Math.min(Math.max(e,n),i)}}])}(),KP=function(e,t){for(var i=0,n=e.length-1,a=null,r=null;i<=n;){var o=t(r=e[a=(i+n)/2|0]);if(o>0)i=a+1;else{if(!(o<0))return r;n=a-1}}return null};function XP(e,t,i=0,n=0,a=.005){var r=null;if(e){r=t[1+e.sn-t[0].sn]||null;var o=e.endDTS-i;o>0&&o<15e-7&&(i+=15e-7),r&&e.level!==r.level&&r.end<=e.end&&(r=t[2+e.sn-t[0].sn]||null)}else 0===i&&0===t[0].start&&(r=t[0]);if(r&&((!e||e.level===r.level)&&0===YP(i,n,r)||function(e,t,i){if(t&&0===t.start&&t.level<e.level&&(t.endPTS||0)>0){var n=t.tagList.reduce((e,t)=>("INF"===t[0]&&(e+=parseFloat(t[1])),e),i);return e.start<=n}return!1}(r,e,Math.min(a,n))))return r;var s=KP(t,YP.bind(null,i,n));return!s||s===e&&r?r:s}function YP(e=0,t=0,i){if(i.start<=e&&i.start+i.duration>e)return 0;var n=Math.min(t,i.duration+(i.deltaPTS?i.deltaPTS:0));return i.start+i.duration-n<=e?1:i.start-n>e&&i.start?-1:0}function qP(e,t,i){var n=1e3*Math.min(t,i.duration+(i.deltaPTS?i.deltaPTS:0));return(i.endProgramDateTime||0)-n>e}function JP(e,t,i){if(e&&e.startCC<=t&&e.endCC>=t){var n,a=e.fragments,r=e.fragmentHint;return r&&(a=a.concat(r)),KP(a,e=>e.cc<t?1:e.cc>t?-1:(n=e,e.end<=i?1:e.start>i?-1:0)),n||null}return null}function QP(e){switch(e.details){case zE.FRAG_LOAD_TIMEOUT:case zE.KEY_LOAD_TIMEOUT:case zE.LEVEL_LOAD_TIMEOUT:case zE.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function ZP(e){return e.details.startsWith("key")}function eM(e){return ZP(e)&&!!e.frag&&!e.frag.decryptdata}function tM(e,t){var i=QP(t);return e.default[(i?"timeout":"error")+"Retry"]}function iM(e,t){var i="linear"===e.backoff?1:Math.pow(2,t);return Math.min(i*e.retryDelayMs,e.maxRetryDelayMs)}function nM(e){return iT(iT({},e),{errorRetry:null,timeoutRetry:null})}function aM(e,t,i,n){if(!e)return!1;var a=null==n?void 0:n.code,r=t<e.maxNumRetry&&(function(e){return rM(e)||!!e&&(e<400||e>499)}(a)||!!i);return e.shouldRetry?e.shouldRetry(e,t,i,n,r):r}function rM(e){return 0===e&&!1===navigator.onLine}var oM=0,sM=2,uM=3,lM=5,dM=0,hM=1,cM=2,mM=4,fM=function(){function e(t){var i;return u(this,e),(i=s(this,e,["error-controller",t.logger])).hls=void 0,i.playlistError=0,i.hls=t,i.registerListeners(),i}return y(e,nT),m(e,[{key:"registerListeners",value:function(){var e=this.hls;e.on(UE.ERROR,this.onError,this),e.on(UE.MANIFEST_LOADING,this.onManifestLoading,this),e.on(UE.LEVEL_UPDATED,this.onLevelUpdated,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(UE.ERROR,this.onError,this),e.off(UE.ERROR,this.onErrorOut,this),e.off(UE.MANIFEST_LOADING,this.onManifestLoading,this),e.off(UE.LEVEL_UPDATED,this.onLevelUpdated,this))}},{key:"destroy",value:function(){this.unregisterListeners(),this.hls=null}},{key:"startLoad",value:function(e){}},{key:"stopLoad",value:function(){this.playlistError=0}},{key:"getVariantLevelIndex",value:function(e){return(null==e?void 0:e.type)===XE?e.level:this.getVariantIndex()}},{key:"getVariantIndex",value:function(){var e,t=this.hls,i=t.currentLevel;return null!=(e=t.loadLevelObj)&&e.details||-1===i?t.loadLevel:i}},{key:"variantHasKey",value:function(e,t){if(e){var i;if(null!=(i=e.details)&&i.hasKey(t))return!0;var n=e.audioGroups;if(n)return this.hls.allAudioTracks.filter(e=>n.indexOf(e.groupId)>=0).some(e=>{var i;return null==(i=e.details)?void 0:i.hasKey(t)})}return!1}},{key:"onManifestLoading",value:function(){this.playlistError=0}},{key:"onLevelUpdated",value:function(){this.playlistError=0}},{key:"onError",value:function(e,t){var i;if(!t.fatal){var n=this.hls,a=t.context;switch(t.details){case zE.FRAG_LOAD_ERROR:case zE.FRAG_LOAD_TIMEOUT:case zE.KEY_LOAD_ERROR:case zE.KEY_LOAD_TIMEOUT:return void(t.errorAction=this.getFragRetryOrSwitchAction(t));case zE.FRAG_PARSING_ERROR:if(null!=(i=t.frag)&&i.gap)return void(t.errorAction=vM());case zE.FRAG_GAP:case zE.FRAG_DECRYPT_ERROR:return t.errorAction=this.getFragRetryOrSwitchAction(t),void(t.errorAction.action=sM);case zE.LEVEL_EMPTY_ERROR:case zE.LEVEL_PARSING_ERROR:var r,o=t.parent===XE?t.level:n.loadLevel;return void(t.details===zE.LEVEL_EMPTY_ERROR&&null!=(r=t.context)&&null!=(r=r.levelDetails)&&r.live?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,o):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,o)));case zE.LEVEL_LOAD_ERROR:case zE.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==a?void 0:a.level)&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,a.level)));case zE.AUDIO_TRACK_LOAD_ERROR:case zE.AUDIO_TRACK_LOAD_TIMEOUT:case zE.SUBTITLE_LOAD_ERROR:case zE.SUBTITLE_TRACK_LOAD_TIMEOUT:if(a){var s=n.loadLevelObj;if(s&&(a.type===VE&&s.hasAudioGroup(a.groupId)||a.type===KE&&s.hasSubtitleGroup(a.groupId)))return t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.loadLevel),t.errorAction.action=sM,void(t.errorAction.flags=hM)}return;case zE.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:return void(t.errorAction={action:sM,flags:cM});case zE.KEY_SYSTEM_SESSION_UPDATE_FAILED:case zE.KEY_SYSTEM_STATUS_INTERNAL_ERROR:case zE.KEY_SYSTEM_NO_SESSION:return void(t.errorAction={action:sM,flags:mM});case zE.BUFFER_ADD_CODEC_ERROR:case zE.REMUX_ALLOC_ERROR:case zE.BUFFER_APPEND_ERROR:var u;if(!t.errorAction)t.errorAction=this.getLevelSwitchAction(t,null!=(u=t.level)?u:n.loadLevel);return;case zE.INTERNAL_EXCEPTION:case zE.BUFFER_APPENDING_ERROR:case zE.BUFFER_FULL_ERROR:case zE.LEVEL_SWITCH_ERROR:case zE.BUFFER_STALLED_ERROR:case zE.BUFFER_SEEK_OVER_HOLE:case zE.BUFFER_NUDGE_ON_STALL:return void(t.errorAction=vM())}t.type===BE.KEY_SYSTEM_ERROR&&(t.levelRetry=!1,t.errorAction=vM())}}},{key:"getPlaylistRetryOrSwitchAction",value:function(e,t){var i=tM(this.hls.config.playlistLoadPolicy,e),n=this.playlistError++;if(aM(i,n,QP(e),e.response))return{action:lM,flags:dM,retryConfig:i,retryCount:n};var a=this.getLevelSwitchAction(e,t);return i&&(a.retryConfig=i,a.retryCount=n),a}},{key:"getFragRetryOrSwitchAction",value:function(e){var t=this.hls,i=this.getVariantLevelIndex(e.frag),n=t.levels[i],a=t.config,r=a.fragLoadPolicy,o=a.keyLoadPolicy,s=tM(ZP(e)?o:r,e),u=t.levels.reduce((e,t)=>e+t.fragmentError,0);if(n&&(e.details!==zE.FRAG_GAP&&n.fragmentError++,!eM(e)&&aM(s,u,QP(e),e.response)))return{action:lM,flags:dM,retryConfig:s,retryCount:u};var l=this.getLevelSwitchAction(e,i);return s&&(l.retryConfig=s,l.retryCount=u),l}},{key:"getLevelSwitchAction",value:function(e,t){var i=this.hls;null==t&&(t=i.loadLevel);var n=this.hls.levels[t];if(n){var a,r,o=e.details;n.loadError++,o===zE.BUFFER_APPEND_ERROR&&n.fragmentError++;var s=-1,u=i.levels,l=i.loadLevel,d=i.minAutoLevel,h=i.maxAutoLevel;i.autoLevelEnabled||i.config.preserveManualLevelOnError||(i.loadLevel=-1);for(var c,m,f,v=null==(a=e.frag)?void 0:a.type,p=(v===YE&&o===zE.FRAG_PARSING_ERROR||"audio"===e.sourceBufferName&&(o===zE.BUFFER_ADD_CODEC_ERROR||o===zE.BUFFER_APPEND_ERROR))&&u.some(({audioCodec:e})=>n.audioCodec!==e),g="video"===e.sourceBufferName&&(o===zE.BUFFER_ADD_CODEC_ERROR||o===zE.BUFFER_APPEND_ERROR)&&u.some(({codecSet:e,audioCodec:t})=>n.codecSet!==e&&n.audioCodec===t),y=null!=(r=e.context)?r:{},b=y.type,w=y.groupId,k=function(){var t=(S+l)%u.length;if(t!==l&&t>=d&&t<=h&&0===u[t].loadError){var i=u[t];if(o===zE.FRAG_GAP&&v===XE&&e.frag){var a=u[t].details;if(a){var r=XP(e.frag,a.fragments,e.frag.start);if(null!=r&&r.gap)return 0}}else{if(b===VE&&i.hasAudioGroup(w)||b===KE&&i.hasSubtitleGroup(w))return 0;if(v===YE&&null!=(c=n.audioGroups)&&c.some(e=>i.hasAudioGroup(e))||v===qE&&null!=(m=n.subtitleGroups)&&m.some(e=>i.hasSubtitleGroup(e))||p&&n.audioCodec===i.audioCodec||g&&n.codecSet===i.codecSet||!p&&n.codecSet!==i.codecSet)return 0}return s=t,1}},S=u.length;S--&&(0===(f=k())||1!==f););if(s>-1&&i.loadLevel!==s)return e.levelRetry=!0,this.playlistError=0,{action:sM,flags:dM,nextAutoLevel:s}}return{action:sM,flags:hM}}},{key:"onErrorOut",value:function(e,t){var i;switch(null==(i=t.errorAction)?void 0:i.action){case oM:break;case sM:this.sendAlternateToPenaltyBox(t),t.errorAction.resolved||t.details===zE.FRAG_GAP?/MediaSource readyState: ended/.test(t.error.message)&&(this.warn(`MediaSource ended after "${t.sourceBufferName}" sourceBuffer append error. Attempting to recover from media error.`),this.hls.recoverMediaError()):t.fatal=!0}t.fatal&&this.hls.stopLoad()}},{key:"sendAlternateToPenaltyBox",value:function(e){var t=this.hls,i=e.errorAction;if(i){var n=i.flags,a=i.nextAutoLevel;switch(n){case dM:this.switchLevel(e,a);break;case cM:var r=this.getVariantLevelIndex(e.frag),o=t.levels[r],s=null==o?void 0:o.attrs["HDCP-LEVEL"];if(i.hdcpLevel=s,"NONE"===s)this.warn("HDCP policy resticted output with HDCP-LEVEL=NONE");else if(s){t.maxHdcpLevel=AP[AP.indexOf(s)-1],i.resolved=!0,this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}case mM:var u=e.decryptdata;if(u){for(var l=this.hls.levels,d=l.length,h=d;h--;){var c,m;if(this.variantHasKey(l[h],u))this.log(`Banned key found in level ${h} (${l[h].bitrate}bps) or audio group "${null==(c=l[h].audioGroups)?void 0:c.join(",")}" (${null==(m=e.frag)?void 0:m.type} fragment) ${mT(u.keyId||[])}`),l[h].fragmentError++,l[h].loadError++,this.log(`Removing level ${h} with key error (${e.error})`),this.hls.removeLevel(h)}var f=e.frag;if(this.hls.levels.length<d)i.resolved=!0;else if(f&&f.type!==XE){var v=f.decryptdata;v&&!u.matches(v)&&(i.resolved=!0)}}}i.resolved||this.switchLevel(e,a)}}},{key:"switchLevel",value:function(e,t){if(void 0!==t&&e.errorAction&&(this.warn(`switching to level ${t} after ${e.details}`),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel,e.details===zE.BUFFER_ADD_CODEC_ERROR&&e.mimeType&&"audiovideo"!==e.sourceBufferName))for(var i=wP(e.mimeType),n=this.hls.levels,a=n.length;a--;)n[a][`${e.sourceBufferName}Codec`]===i&&(this.log(`Removing level ${a} for ${e.details} ("${i}" not supported)`),this.hls.removeLevel(a))}}])}();function vM(e){var t={action:oM,flags:dM};return e&&(t.resolved=!0),t}var pM="NOT_LOADED",gM="APPENDING",yM="PARTIAL",bM="OK",wM=function(){return m(function e(t){u(this,e),this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=t,this._registerListeners()},[{key:"_registerListeners",value:function(){var e=this.hls;e&&(e.on(UE.MANIFEST_LOADING,this.onManifestLoading,this),e.on(UE.BUFFER_APPENDED,this.onBufferAppended,this),e.on(UE.FRAG_BUFFERED,this.onFragBuffered,this),e.on(UE.FRAG_LOADED,this.onFragLoaded,this))}},{key:"_unregisterListeners",value:function(){var e=this.hls;e&&(e.off(UE.MANIFEST_LOADING,this.onManifestLoading,this),e.off(UE.BUFFER_APPENDED,this.onBufferAppended,this),e.off(UE.FRAG_BUFFERED,this.onFragBuffered,this),e.off(UE.FRAG_LOADED,this.onFragLoaded,this))}},{key:"destroy",value:function(){this._unregisterListeners(),this.hls=this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}},{key:"getAppendedFrag",value:function(e,t){var i=this.activePartLists[t];if(i)for(var n=i.length;n--;){var a=i[n];if(!a)break;if(a.start<=e&&e<=a.end&&a.loaded)return a}return this.getBufferedFrag(e,t)}},{key:"getBufferedFrag",value:function(e,t){return this.getFragAtPos(e,t,!0)}},{key:"getFragAtPos",value:function(e,t,i){for(var n=this.fragments,a=Object.keys(n),r=a.length;r--;){var o=n[a[r]];if((null==o?void 0:o.body.type)===t&&(!i||o.buffered)){var s=o.body;if(s.start<=e&&e<=s.end)return s}}return null}},{key:"detectEvictedFragments",value:function(e,t,i,n,a){this.timeRanges&&(this.timeRanges[e]=t);var r=(null==n?void 0:n.fragment.sn)||-1;Object.keys(this.fragments).forEach(n=>{var o=this.fragments[n];if(o&&!(r>=o.body.sn))if(o.buffered||o.loaded&&!a){var s=o.range[e];s&&(0!==s.time.length?s.time.some(e=>{var i=!this.isTimeBuffered(e.startPTS,e.endPTS,t);return i&&this.removeFragment(o.body),i}):this.removeFragment(o.body))}else o.body.type===i&&this.removeFragment(o.body)})}},{key:"detectPartialFragments",value:function(e){var t=this.timeRanges;if(t&&"initSegment"!==e.frag.sn){var i=e.frag,n=SM(i),a=this.fragments[n];if(!(!a||a.buffered&&i.gap)){var r=!i.relurl;Object.keys(t).forEach(n=>{var o=i.elementaryStreams[n];if(o){var s=t[n],u=r||!0===o.partial;a.range[n]=this.getBufferedTimes(i,e.part,u,s)}}),a.loaded=null,Object.keys(a.range).length?(this.bufferedEnd(a,i),kM(a)||this.removeParts(i.sn-1,i.type)):this.removeFragment(a.body)}}}},{key:"bufferedEnd",value:function(e,t){e.buffered=!0,(e.body.endList=t.endList||e.body.endList)&&(this.endListFragments[e.body.type]=e)}},{key:"removeParts",value:function(e,t){var i=this.activePartLists[t];i&&(this.activePartLists[t]=EM(i,t=>t.fragment.sn>=e))}},{key:"fragBuffered",value:function(e,t){var i=SM(e),n=this.fragments[i];!n&&t&&(n=this.fragments[i]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),n&&(n.loaded=null,this.bufferedEnd(n,e))}},{key:"getBufferedTimes",value:function(e,t,i,n){for(var a={time:[],partial:i},r=e.start,o=e.end,s=e.minEndPTS||o,u=e.maxStartPTS||r,l=0;l<n.length;l++){var d=n.start(l)-this.bufferPadding,h=n.end(l)+this.bufferPadding;if(u>=d&&s<=h){a.time.push({startPTS:Math.max(r,n.start(l)),endPTS:Math.min(o,n.end(l))});break}if(r<h&&o>d){var c=Math.max(r,n.start(l)),m=Math.min(o,n.end(l));m>c&&(a.partial=!0,a.time.push({startPTS:c,endPTS:m}))}else if(o<=d)break}return a}},{key:"getPartialFragment",value:function(e){var t,i,n,a=null,r=0,o=this.bufferPadding,s=this.fragments;return Object.keys(s).forEach(u=>{var l=s[u];l&&kM(l)&&(i=l.body.start-o,n=l.body.end+o,e>=i&&e<=n&&(t=Math.min(e-i,n-e),r<=t&&(a=l.body,r=t)))}),a}},{key:"isEndListAppended",value:function(e){var t=this.endListFragments[e];return void 0!==t&&(t.buffered||kM(t))}},{key:"getState",value:function(e){var t=SM(e),i=this.fragments[t];return i?i.buffered?kM(i)?yM:bM:gM:pM}},{key:"isTimeBuffered",value:function(e,t,i){for(var n,a,r=0;r<i.length;r++){if(n=i.start(r)-this.bufferPadding,a=i.end(r)+this.bufferPadding,e>=n&&t<=a)return!0;if(t<=n)return!1}return!1}},{key:"onManifestLoading",value:function(){this.removeAllFragments()}},{key:"onFragLoaded",value:function(e,t){if("initSegment"!==t.frag.sn&&!t.frag.bitrateTest){var i=t.frag,n=t.part?null:t,a=SM(i);this.fragments[a]={body:i,appendedPTS:null,loaded:n,buffered:!1,range:Object.create(null)}}}},{key:"onBufferAppended",value:function(e,t){var i=t.frag,n=t.part,a=t.timeRanges,r=t.type;if("initSegment"!==i.sn){var o=i.type;if(n){var s=this.activePartLists[o];s||(this.activePartLists[o]=s=[]),s.push(n)}this.timeRanges=a;var u=a[r];this.detectEvictedFragments(r,u,o,n)}}},{key:"onFragBuffered",value:function(e,t){this.detectPartialFragments(t)}},{key:"hasFragment",value:function(e){var t=SM(e);return!!this.fragments[t]}},{key:"hasFragments",value:function(e){var t=this.fragments,i=Object.keys(t);if(!e)return i.length>0;for(var n=i.length;n--;){var a=t[i[n]];if((null==a?void 0:a.body.type)===e)return!0}return!1}},{key:"hasParts",value:function(e){var t;return!(null==(t=this.activePartLists[e])||!t.length)}},{key:"removeFragmentsInRange",value:function(e,t,i,n,a){n&&!this.hasGaps||Object.keys(this.fragments).forEach(r=>{var o=this.fragments[r];if(o){var s=o.body;s.type!==i||n&&!s.gap||s.start<t&&s.end>e&&(o.buffered||a)&&this.removeFragment(s)}})}},{key:"removeFragment",value:function(e){var t=SM(e);e.clearElementaryStreamInfo();var i=this.activePartLists[e.type];if(i){var n=e.sn;this.activePartLists[e.type]=EM(i,e=>e.fragment.sn!==n)}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}},{key:"removeAllFragments",value:function(){var e;this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1;var t=null==(e=this.hls)||null==(e=e.latestLevelDetails)?void 0:e.partList;t&&t.forEach(e=>e.clearElementaryStreamInfo())}}])}();function kM(e){var t,i,n;return e.buffered&&!!(e.body.gap||null!=(t=e.range.video)&&t.partial||null!=(i=e.range.audio)&&i.partial||null!=(n=e.range.audiovideo)&&n.partial)}function SM(e){return`${e.type}_${e.level}_${e.sn}`}function EM(e,t){return e.filter(e=>{var i=t(e);return i||e.clearElementaryStreamInfo(),i})}var TM=0,PM=1,MM=function(){return m(function e(t,i,n){u(this,e),this.subtle=void 0,this.aesIV=void 0,this.aesMode=void 0,this.subtle=t,this.aesIV=i,this.aesMode=n},[{key:"decrypt",value:function(e,t){switch(this.aesMode){case TM:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e);case PM:return this.subtle.decrypt({name:"AES-CTR",counter:this.aesIV,length:64},t,e);default:throw new Error(`[AESCrypto] invalid aes mode ${this.aesMode}`)}}}])}();var AM=function(){return m(function e(){u(this,e),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()},[{key:"uint8ArrayToUint32Array_",value:function(e){for(var t=new DataView(e),i=new Uint32Array(4),n=0;n<4;n++)i[n]=t.getUint32(4*n);return i}},{key:"initTable",value:function(){var e=this.sBox,t=this.invSBox,i=this.subMix,n=i[0],a=i[1],r=i[2],o=i[3],s=this.invSubMix,u=s[0],l=s[1],d=s[2],h=s[3],c=new Uint32Array(256),m=0,f=0,v=0;for(v=0;v<256;v++)c[v]=v<128?v<<1:v<<1^283;for(v=0;v<256;v++){var p=f^f<<1^f<<2^f<<3^f<<4;p=p>>>8^255&p^99,e[m]=p,t[p]=m;var g=c[m],y=c[g],b=c[y],w=257*c[p]^16843008*p;n[m]=w<<24|w>>>8,a[m]=w<<16|w>>>16,r[m]=w<<8|w>>>24,o[m]=w,w=16843009*b^65537*y^257*g^16843008*m,u[p]=w<<24|w>>>8,l[p]=w<<16|w>>>16,d[p]=w<<8|w>>>24,h[p]=w,m?(m=g^c[c[c[b^g]]],f^=c[c[f]]):m=f=1}}},{key:"expandKey",value:function(e){for(var t=this.uint8ArrayToUint32Array_(e),i=!0,n=0;n<t.length&&i;)i=t[n]===this.key[n],n++;if(!i){this.key=t;var a=this.keySize=t.length;if(4!==a&&6!==a&&8!==a)throw new Error("Invalid aes key size="+a);var r,o,s,u,l=this.ksRows=4*(a+6+1),d=this.keySchedule=new Uint32Array(l),h=this.invKeySchedule=new Uint32Array(l),c=this.sBox,m=this.rcon,f=this.invSubMix,v=f[0],p=f[1],g=f[2],y=f[3];for(r=0;r<l;r++)r<a?s=d[r]=t[r]:(u=s,r%a===0?(u=c[(u=u<<8|u>>>24)>>>24]<<24|c[u>>>16&255]<<16|c[u>>>8&255]<<8|c[255&u],u^=m[r/a|0]<<24):a>6&&r%a===4&&(u=c[u>>>24]<<24|c[u>>>16&255]<<16|c[u>>>8&255]<<8|c[255&u]),d[r]=s=(d[r-a]^u)>>>0);for(o=0;o<l;o++)r=l-o,u=3&o?d[r]:d[r-4],h[o]=o<4||r<=4?u:v[c[u>>>24]]^p[c[u>>>16&255]]^g[c[u>>>8&255]]^y[c[255&u]],h[o]=h[o]>>>0}}},{key:"networkToHostOrderSwap",value:function(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24}},{key:"decrypt",value:function(e,t,i){for(var n,a,r,o,s,u,l,d,h,c,m,f,v,p,g=this.keySize+6,y=this.invKeySchedule,b=this.invSBox,w=this.invSubMix,k=w[0],S=w[1],E=w[2],T=w[3],P=this.uint8ArrayToUint32Array_(i),M=P[0],A=P[1],D=P[2],x=P[3],C=new Int32Array(e),I=new Int32Array(C.length),L=this.networkToHostOrderSwap;t<C.length;){for(h=L(C[t]),c=L(C[t+1]),m=L(C[t+2]),f=L(C[t+3]),s=h^y[0],u=f^y[1],l=m^y[2],d=c^y[3],v=4,p=1;p<g;p++)n=k[s>>>24]^S[u>>16&255]^E[l>>8&255]^T[255&d]^y[v],a=k[u>>>24]^S[l>>16&255]^E[d>>8&255]^T[255&s]^y[v+1],r=k[l>>>24]^S[d>>16&255]^E[s>>8&255]^T[255&u]^y[v+2],o=k[d>>>24]^S[s>>16&255]^E[u>>8&255]^T[255&l]^y[v+3],s=n,u=a,l=r,d=o,v+=4;n=b[s>>>24]<<24^b[u>>16&255]<<16^b[l>>8&255]<<8^b[255&d]^y[v],a=b[u>>>24]<<24^b[l>>16&255]<<16^b[d>>8&255]<<8^b[255&s]^y[v+1],r=b[l>>>24]<<24^b[d>>16&255]<<16^b[s>>8&255]<<8^b[255&u]^y[v+2],o=b[d>>>24]<<24^b[s>>16&255]<<16^b[u>>8&255]<<8^b[255&l]^y[v+3],I[t]=L(n^M),I[t+1]=L(o^A),I[t+2]=L(r^D),I[t+3]=L(a^x),M=h,A=c,D=m,x=f,t+=4}return I.buffer}}])}(),DM=function(){return m(function e(t,i,n){u(this,e),this.subtle=void 0,this.key=void 0,this.aesMode=void 0,this.subtle=t,this.key=i,this.aesMode=n},[{key:"expandKey",value:function(){var e=function(e){switch(e){case TM:return"AES-CBC";case PM:return"AES-CTR";default:throw new Error(`[FastAESKey] invalid aes mode ${e}`)}}(this.aesMode);return this.subtle.importKey("raw",this.key,{name:e},!1,["encrypt","decrypt"])}}])}();var xM=function(){return m(function e(t,{removePKCS7Padding:i=!0}={}){if(u(this,e),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.enableSoftwareAES=void 0,this.enableSoftwareAES=t.enableSoftwareAES,this.removePKCS7Padding=i,i)try{var n=self.crypto;n&&(this.subtle=n.subtle||n.webkitSubtle)}catch(e){}this.useSoftware=!this.subtle},[{key:"destroy",value:function(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}},{key:"isSync",value:function(){return this.useSoftware}},{key:"flush",value:function(){var e=this.currentResult,t=this.remainderData;if(!e||t)return this.reset(),null;var i,n,a,r=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?(n=(i=r).byteLength,(a=n&&new DataView(i.buffer).getUint8(n-1))?i.slice(0,n-a):i):r}},{key:"reset",value:function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}},{key:"decrypt",value:function(e,t,i,n){return this.useSoftware?new Promise((a,r)=>{var o=ArrayBuffer.isView(e)?e:new Uint8Array(e);this.softwareDecrypt(o,t,i,n);var s=this.flush();s?a(s.buffer):r(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,i,n)}},{key:"softwareDecrypt",value:function(e,t,i,n){var a=this.currentIV,r=this.currentResult,o=this.remainderData;if(n!==TM||16!==t.byteLength)return lT.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;this.logOnce("JS AES decrypt"),o&&(e=JT(o,e),this.remainderData=null);var s=this.getValidChunk(e);if(!s.length)return null;a&&(i=a);var u=this.softwareDecrypter;u||(u=this.softwareDecrypter=new AM),u.expandKey(t);var l=r;return this.currentResult=u.decrypt(s.buffer,0,i),this.currentIV=s.slice(-16).buffer,l||null}},{key:"webCryptoDecrypt",value:function(e,t,i,n){if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,t,i,n));this.key=t,this.fastAesKey=new DM(this.subtle,t,n)}return this.fastAesKey.expandKey().then(t=>this.subtle?(this.logOnce("WebCrypto AES decrypt"),new MM(this.subtle,new Uint8Array(i),n).decrypt(e.buffer,t)):Promise.reject(new Error("web crypto not initialized"))).catch(a=>(lT.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${a.name}: ${a.message}`),this.onWebCryptoError(e,t,i,n)))}},{key:"onWebCryptoError",value:function(e,t,i,n){var a=this.enableSoftwareAES;if(a){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,i,n);var r=this.flush();if(r)return r.buffer}throw new Error("WebCrypto"+(a?" and softwareDecrypt":"")+": failed to decrypt data")}},{key:"getValidChunk",value:function(e){var t=e,i=e.length-e.length%16;return i!==e.length&&(t=e.slice(0,i),this.remainderData=e.slice(i)),t}},{key:"logOnce",value:function(e){this.logEnabled&&(lT.log(`[decrypter]: ${e}`),this.logEnabled=!1)}}])}(),CM=Math.pow(2,17),IM=function(){return m(function e(t){u(this,e),this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=t},[{key:"destroy",value:function(){this.loader&&(this.loader.destroy(),this.loader=null)}},{key:"abort",value:function(){this.loader&&this.loader.abort()}},{key:"load",value:function(e,t){var i=e.url;if(!i)return Promise.reject(new RM({type:BE.NETWORK_ERROR,details:zE.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error("Fragment does not have a "+(i?"part list":"url")),networkDetails:null}));this.abort();var n=this.config,a=n.fLoader,r=n.loader;return new Promise((o,s)=>{if(this.loader&&this.loader.destroy(),e.gap){if(e.tagList.some(e=>"GAP"===e[0]))return void s(_M(e));e.gap=!1}var u=this.loader=a?new a(n):new r(n),l=LM(e);e.loader=u;var d=nM(n.fragLoadPolicy.default),h={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===e.sn?1/0:CM};e.stats=u.stats;var c={onSuccess:(t,i,n,a)=>{this.resetLoader(e,u);var r=t.data;n.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(r.slice(0,16)),r=r.slice(16)),o({frag:e,part:null,payload:r,networkDetails:a})},onError:(t,n,a,r)=>{this.resetLoader(e,u),s(new RM({type:BE.NETWORK_ERROR,details:zE.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:iT({url:i,data:void 0},t),error:new Error(`HTTP Error ${t.code} ${t.text}`),networkDetails:a,stats:r}))},onAbort:(t,i,n)=>{this.resetLoader(e,u),s(new RM({type:BE.NETWORK_ERROR,details:zE.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:n,stats:t}))},onTimeout:(t,i,n)=>{this.resetLoader(e,u),s(new RM({type:BE.NETWORK_ERROR,details:zE.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:n,stats:t}))}};t&&(c.onProgress=(i,n,a,r)=>t({frag:e,part:null,payload:a,networkDetails:r})),u.load(l,h,c)})}},{key:"loadPart",value:function(e,t,i){this.abort();var n=this.config,a=n.fLoader,r=n.loader;return new Promise((o,s)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap)s(_M(e,t));else{var u=this.loader=a?new a(n):new r(n),l=LM(e,t);e.loader=u;var d=nM(n.fragLoadPolicy.default),h={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:CM};t.stats=u.stats,u.load(l,h,{onSuccess:(n,a,r,s)=>{this.resetLoader(e,u),this.updateStatsFromPart(e,t);var l={frag:e,part:t,payload:n.data,networkDetails:s};i(l),o(l)},onError:(i,n,a,r)=>{this.resetLoader(e,u),s(new RM({type:BE.NETWORK_ERROR,details:zE.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:iT({url:l.url,data:void 0},i),error:new Error(`HTTP Error ${i.code} ${i.text}`),networkDetails:a,stats:r}))},onAbort:(i,n,a)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,u),s(new RM({type:BE.NETWORK_ERROR,details:zE.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:a,stats:i}))},onTimeout:(i,n,a)=>{this.resetLoader(e,u),s(new RM({type:BE.NETWORK_ERROR,details:zE.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:a,stats:i}))}})}})}},{key:"updateStatsFromPart",value:function(e,t){var i=e.stats,n=t.stats,a=n.total;if(i.loaded+=n.loaded,a){var r=Math.round(e.duration/t.duration),o=Math.min(Math.round(i.loaded/a),r),s=(r-o)*Math.round(i.loaded/o);i.total=i.loaded+s}else i.total=Math.max(i.loaded,i.total);var u=i.loading,l=n.loading;u.start?u.first+=l.first-l.start:(u.start=l.start,u.first=l.first),u.end=l.end}},{key:"resetLoader",value:function(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}}])}();function LM(e,t=null){var i,n=t||e,a={frag:e,part:t,responseType:"arraybuffer",url:n.url,headers:{},rangeStart:0,rangeEnd:0},r=n.byteRangeStartOffset,o=n.byteRangeEndOffset;if($E(r)&&$E(o)){var s,u=r,l=o;if("initSegment"===e.sn&&("AES-128"===(i=null==(s=e.decryptdata)?void 0:s.method)||"AES-256"===i)){var d=o-r;d%16&&(l=o+(16-d%16)),0!==r&&(a.resetIV=!0,u=r-16)}a.rangeStart=u,a.rangeEnd=l}return a}function _M(e,t){var i=new Error(`GAP ${e.gap?"tag":"attribute"} found`),n={type:BE.MEDIA_ERROR,details:zE.FRAG_GAP,fatal:!1,frag:e,error:i,networkDetails:null};return t&&(n.part=t),(t||e).stats.aborted=!0,new RM(n)}var RM=function(){function e(t){var i;return u(this,e),(i=s(this,e,[t.error.message])).data=void 0,i.data=t,i}return y(e,D(Error)),m(e)}(),FM=function(){function e(t,i){var n;return u(this,e),(n=s(this,e,[t,i]))._boundTick=void 0,n._tickTimer=null,n._tickInterval=null,n._tickCallCount=0,n._boundTick=n.tick.bind(n),n}return y(e,nT),m(e,[{key:"destroy",value:function(){this.onHandlerDestroying(),this.onHandlerDestroyed()}},{key:"onHandlerDestroying",value:function(){this.clearNextTick(),this.clearInterval()}},{key:"onHandlerDestroyed",value:function(){}},{key:"hasInterval",value:function(){return!!this._tickInterval}},{key:"hasNextTick",value:function(){return!!this._tickTimer}},{key:"setInterval",value:function(e){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)}},{key:"clearInterval",value:function(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)}},{key:"clearNextTick",value:function(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)}},{key:"tick",value:function(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}},{key:"tickImmediate",value:function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}},{key:"doTick",value:function(){}}])}(),OM=m(function e(t,i,n,a=0,r=-1,o=!1){u(this,e),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={start:0,executeStart:0,executeEnd:0,end:0},this.buffering={audio:{start:0,executeStart:0,executeEnd:0,end:0},video:{start:0,executeStart:0,executeEnd:0,end:0},audiovideo:{start:0,executeStart:0,executeEnd:0,end:0}},this.level=t,this.sn=i,this.id=n,this.size=a,this.part=r,this.partial=o});var WM={length:0,start:()=>0,end:()=>0},$M=function(){function e(){u(this,e)}return m(e,null,[{key:"isBuffered",value:function(t,i){if(t)for(var n=e.getBuffered(t),a=n.length;a--;)if(i>=n.start(a)&&i<=n.end(a))return!0;return!1}},{key:"bufferedRanges",value:function(t){if(t){var i=e.getBuffered(t);return e.timeRangesToArray(i)}return[]}},{key:"timeRangesToArray",value:function(e){for(var t=[],i=0;i<e.length;i++)t.push({start:e.start(i),end:e.end(i)});return t}},{key:"bufferInfo",value:function(t,i,n){if(t){var a=e.bufferedRanges(t);if(a.length)return e.bufferedInfo(a,i,n)}return{len:0,start:i,end:i,bufferedIndex:-1}}},{key:"bufferedInfo",value:function(e,t,i){t=Math.max(0,t),e.length>1&&e.sort((e,t)=>e.start-t.start||t.end-e.end);var n=-1,a=[];if(i)for(var r=0;r<e.length;r++){t>=e[r].start&&t<=e[r].end&&(n=r);var o=a.length;if(o){var s=a[o-1].end;e[r].start-s<i?e[r].end>s&&(a[o-1].end=e[r].end):a.push(e[r])}else a.push(e[r])}else a=e;for(var u,l=0,d=t,h=t,c=0;c<a.length;c++){var m=a[c].start,f=a[c].end;if(-1===n&&t>=m&&t<=f&&(n=c),t+i>=m&&t<f)d=m,l=(h=f)-t;else if(t+i<m){u=m;break}}return{len:l,start:d||0,end:h||0,nextStart:u,buffered:e,bufferedIndex:n}}},{key:"getBuffered",value:function(e){try{return e.buffered||WM}catch(e){return lT.log("failed to get media.buffered",e),WM}}}])}(),NM=/\{\$([a-zA-Z0-9-_]+)\}/g;function jM(e){return NM.test(e)}function BM(e,t){if(null!==e.variableList||e.hasVariableRefs){var i=e.variableList;return t.replace(NM,t=>{var n=t.substring(2,t.length-1),a=null==i?void 0:i[n];return void 0===a?(e.playlistParsingError||(e.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${n}"`)),t):a})}return t}function zM(e,t,i){var n,a,r=e.variableList;if(r||(e.variableList=r={}),"QUERYPARAM"in t){n=t.QUERYPARAM;try{var o=new self.URL(i).searchParams;if(!o.has(n))throw new Error(`"${n}" does not match any query parameter in URI: "${i}"`);a=o.get(n)}catch(t){e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${t.message}`))}}else n=t.NAME,a=t.VALUE;n in r?e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${n}"`)):r[n]=a||""}function UM(e,t,i){var n=t.IMPORT;if(i&&n in i){var a=e.variableList;a||(e.variableList=a={}),a[n]=i[n]}else e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${n}"`))}var HM=/^(\d+)x(\d+)$/,GM=/(.+?)=(".*?"|.*?)(?:,|$)/g,VM=function(){return m(function e(t,i){u(this,e),"string"==typeof t&&(t=e.parseAttrList(t,i)),eT(this,t)},[{key:"clientAttrs",get:function(){return Object.keys(this).filter(e=>"X-"===e.substring(0,2))}},{key:"decimalInteger",value:function(e){var t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t}},{key:"hexadecimalInteger",value:function(e){if(this[e]){var t=(this[e]||"0x").slice(2);t=(1&t.length?"0":"")+t;for(var i=new Uint8Array(t.length/2),n=0;n<t.length/2;n++)i[n]=parseInt(t.slice(2*n,2*n+2),16);return i}return null}},{key:"hexadecimalIntegerAsNumber",value:function(e){var t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t}},{key:"decimalFloatingPoint",value:function(e){return parseFloat(this[e])}},{key:"optionalFloat",value:function(e,t){var i=this[e];return i?parseFloat(i):t}},{key:"enumeratedString",value:function(e){return this[e]}},{key:"enumeratedStringList",value:function(e,t){var i=this[e];return(i?i.split(/[ ,]+/):[]).reduce((e,t)=>(e[t.toLowerCase()]=!0,e),t)}},{key:"bool",value:function(e){return"YES"===this[e]}},{key:"decimalResolution",value:function(e){var t=HM.exec(this[e]);if(null!==t)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}}],[{key:"parseAttrList",value:function(e,t){var i,n={};for(GM.lastIndex=0;null!==(i=GM.exec(e));){var a=i[1].trim(),r=i[2],o=0===r.indexOf('"')&&r.lastIndexOf('"')===r.length-1,s=!1;if(o)r=r.slice(1,-1);else switch(a){case"IV":case"SCTE35-CMD":case"SCTE35-IN":case"SCTE35-OUT":s=!0}if(t&&(o||s))r=BM(t,r);else if(!s&&!o)switch(a){case"CLOSED-CAPTIONS":if("NONE"===r)break;case"ALLOWED-CPC":case"CLASS":case"ASSOC-LANGUAGE":case"AUDIO":case"BYTERANGE":case"CHANNELS":case"CHARACTERISTICS":case"CODECS":case"DATA-ID":case"END-DATE":case"GROUP-ID":case"ID":case"IMPORT":case"INSTREAM-ID":case"KEYFORMAT":case"KEYFORMATVERSIONS":case"LANGUAGE":case"NAME":case"PATHWAY-ID":case"QUERYPARAM":case"RECENTLY-REMOVED-DATERANGES":case"SERVER-URI":case"STABLE-RENDITION-ID":case"STABLE-VARIANT-ID":case"START-DATE":case"SUBTITLES":case"SUPPLEMENTAL-CODECS":case"URI":case"VALUE":case"VIDEO":case"X-ASSET-LIST":case"X-ASSET-URI":lT.warn(`${e}: attribute ${a} is missing quotes`)}n[a]=r}return n}}])}();function KM(e){return"ID"!==e&&"CLASS"!==e&&"CUE"!==e&&"START-DATE"!==e&&"DURATION"!==e&&"END-DATE"!==e&&"END-ON-NEXT"!==e}function XM(e){return"SCTE35-OUT"===e||"SCTE35-IN"===e||"SCTE35-CMD"===e}var YM=function(){return m(function e(t,i,n=0){var a;if(u(this,e),this.attr=void 0,this.tagAnchor=void 0,this.tagOrder=void 0,this._startDate=void 0,this._endDate=void 0,this._dateAtEnd=void 0,this._cue=void 0,this._badValueForSameId=void 0,this.tagAnchor=(null==i?void 0:i.tagAnchor)||null,this.tagOrder=null!=(a=null==i?void 0:i.tagOrder)?a:n,i){var r=i.attr;for(var o in r)if(Object.prototype.hasOwnProperty.call(t,o)&&t[o]!==r[o]){lT.warn(`DATERANGE tag attribute: "${o}" does not match for tags with ID: "${t.ID}"`),this._badValueForSameId=o;break}t=eT(new VM({}),r,t)}if(this.attr=t,i?(this._startDate=i._startDate,this._cue=i._cue,this._endDate=i._endDate,this._dateAtEnd=i._dateAtEnd):this._startDate=new Date(t["START-DATE"]),"END-DATE"in this.attr){var s=(null==i?void 0:i.endDate)||new Date(this.attr["END-DATE"]);$E(s.getTime())&&(this._endDate=s)}},[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"cue",get:function(){var e=this._cue;return void 0===e?this._cue=this.attr.enumeratedStringList(this.attr.CUE?"CUE":"X-CUE",{pre:!1,post:!1,once:!1}):e}},{key:"startTime",get:function(){var e=this.tagAnchor;return null===e||null===e.programDateTime?(lT.warn(`Expected tagAnchor Fragment with PDT set for DateRange "${this.id}": ${e}`),NaN):e.start+(this.startDate.getTime()-e.programDateTime)/1e3}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){var e=this._endDate||this._dateAtEnd;if(e)return e;var t=this.duration;return null!==t?this._dateAtEnd=new Date(this._startDate.getTime()+1e3*t):null}},{key:"duration",get:function(){if("DURATION"in this.attr){var e=this.attr.decimalFloatingPoint("DURATION");if($E(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}},{key:"endOnNext",get:function(){return this.attr.bool("END-ON-NEXT")}},{key:"isInterstitial",get:function(){return"com.apple.hls.interstitial"===this.class}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&$E(this.startDate.getTime())&&(null===this.duration||this.duration>=0)&&(!this.endOnNext||!!this.class)&&(!this.attr.CUE||!this.cue.pre&&!this.cue.post||this.cue.pre!==this.cue.post)&&(!this.isInterstitial||"X-ASSET-URI"in this.attr||"X-ASSET-LIST"in this.attr)}}])}(),qM=function(){return m(function e(t){u(this,e),this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.dateRangeTagCount=0,this.live=!0,this.requestScheduled=-1,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!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.appliedTimelineOffset=void 0,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=t},[{key:"reloaded",value:function(e){if(!e)return this.advanced=!0,void(this.updated=!0);var t=this.lastPartSn-e.lastPartSn,i=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!i||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||0===t&&i>0,this.updated||this.advanced?this.misses=Math.floor(.6*e.misses):this.misses=e.misses+1}},{key:"hasKey",value:function(e){return this.encryptedFragments.some(t=>{var i=t.decryptdata;return i||(t.setKeyFormat(e.keyFormat),i=t.decryptdata),!!i&&e.matches(i)})}},{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&$E(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||10}},{key:"drift",get:function(){var e=this.driftEndTime-this.driftStartTime;return e>0?1e3*(this.driftEnd-this.driftStart)/e:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){return this.fragments.length?this.fragments[this.fragments.length-1].end:0}},{key:"fragmentStart",get:function(){return this.fragments.length?this.fragments[0].start:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].index:-1}},{key:"maxPartIndex",get:function(){var e=this.partList;if(e){var t=this.lastPartIndex;if(-1!==t){for(var i=e.length;i--;)if(e[i].index>t)return e[i].index;return t}}return 0}},{key:"lastPartSn",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}},{key:"expired",get:function(){if(this.live&&this.age&&this.misses<3){var e=this.partEnd-this.fragmentStart;return this.age>Math.max(e,this.totalduration)+this.levelTargetDuration}return!1}}])}();function JM(e,t){return e.length===t.length&&!e.some((e,i)=>e!==t[i])}function QM(e,t){return!e&&!t||!(!e||!t)&&JM(e,t)}function ZM(e){return"AES-128"===e||"AES-256"===e||"AES-256-CTR"===e}function eA(e){switch(e){case"AES-128":case"AES-256":return TM;case"AES-256-CTR":return PM;default:throw new Error(`invalid full segment method ${e}`)}}function tA(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0))}function iA(e){return Uint8Array.from(unescape(encodeURIComponent(e)),e=>e.charCodeAt(0))}function nA(e){var t=function(e,t,i){var n=e[t];e[t]=e[i],e[i]=n};t(e,0,3),t(e,1,2),t(e,4,5),t(e,6,7)}function aA(e){var t,i,n=e.split(":"),a=null;if("data"===n[0]&&2===n.length){var r=n[1].split(";"),o=r[r.length-1].split(",");if(2===o.length){var s="base64"===o[0],u=o[1];s?(r.splice(-1,1),a=tA(u)):(t=iA(u).subarray(0,16),(i=new Uint8Array(16)).set(t,16-t.length),a=i)}}return a}var rA="undefined"!=typeof self?self:void 0,oA={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},sA="org.w3.clearkey",uA="com.apple.streamingkeydelivery",lA="com.microsoft.playready",dA="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function hA(e){switch(e){case uA:return oA.FAIRPLAY;case lA:return oA.PLAYREADY;case dA:return oA.WIDEVINE;case sA:return oA.CLEARKEY}}function cA(e){switch(e){case oA.FAIRPLAY:return uA;case oA.PLAYREADY:return lA;case oA.WIDEVINE:return dA;case oA.CLEARKEY:return sA}}function mA(e){var t=e.drmSystems,i=e.widevineLicenseUrl,n=t?[oA.FAIRPLAY,oA.WIDEVINE,oA.PLAYREADY,oA.CLEARKEY].filter(e=>!!t[e]):[];return!n[oA.WIDEVINE]&&i&&n.push(oA.WIDEVINE),n}var fA,vA=null!=rA&&null!=(fA=rA.navigator)&&fA.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;function pA(e){var t=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2),i=String.fromCharCode.apply(null,Array.from(t)),n=i.substring(i.indexOf("<"),i.length),a=(new DOMParser).parseFromString(n,"text/xml").getElementsByTagName("KID")[0];if(a){var r=a.childNodes[0]?a.childNodes[0].nodeValue:a.getAttribute("VALUE");if(r){var o=tA(r).subarray(0,16);return nA(o),o}}return null}var gA={},yA=function(){function e(t,i,n,a=[1],r=null,o){u(this,e),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=i,this.keyFormat=n,this.keyFormatVersions=a,this.iv=r,this.encrypted=!!t&&"NONE"!==t,this.isCommonEncryption=this.encrypted&&!ZM(t),null!=o&&o.startsWith("0x")&&(this.keyId=new Uint8Array(fT(o)))}return m(e,[{key:"matches",value:function(e){return e.uri===this.uri&&e.method===this.method&&e.encrypted===this.encrypted&&e.keyFormat===this.keyFormat&&JM(e.keyFormatVersions,this.keyFormatVersions)&&QM(e.iv,this.iv)&&QM(e.keyId,this.keyId)}},{key:"isSupported",value:function(){if(this.method){if(ZM(this.method)||"NONE"===this.method)return!0;if("identity"===this.keyFormat)return"SAMPLE-AES"===this.method;switch(this.keyFormat){case uA:case dA:case lA:case sA:return-1!==["SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)}}return!1}},{key:"getDecryptData",value:function(t,i){if(!this.encrypted||!this.uri)return null;if(ZM(this.method)){var n=this.iv;return n||("number"!=typeof t&&(lT.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),t=0),n=function(e){for(var t=new Uint8Array(16),i=12;i<16;i++)t[i]=e>>8*(15-i)&255;return t}(t)),new e(this.method,this.uri,"identity",this.keyFormatVersions,n)}if(this.keyId){var a=gA[this.uri];if(a&&!JM(this.keyId,a)&&e.setKeyIdForUri(this.uri,this.keyId),this.pssh)return this}var r,o=aA(this.uri);if(o)switch(this.keyFormat){case dA:if(this.pssh=o,!this.keyId){var s=function(e){var t=[];if(e instanceof ArrayBuffer)for(var i=e.byteLength,n=0;n+32<i;){var a=aP(new DataView(e,n));t.push(a),n+=a.size}return t}(o.buffer);if(s.length){var u,l=s[0];this.keyId=null!=(u=l.kids)&&u.length?l.kids[0]:null}}this.keyId||(this.keyId=bA(i));break;case lA:var d=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=nP(d,0,o),this.keyId=pA(o);break;default:var h=o.subarray(0,16);if(16!==h.length){var c=new Uint8Array(16);c.set(h,16-h.length),h=c}this.keyId=h}this.keyId&&16===this.keyId.byteLength||(r=function(e){var t=null==e?void 0:e[dA];if(t)return t.keyId;return null}(i),r||(r=bA(i))||(r=gA[this.uri]),r&&(this.keyId=r,e.setKeyIdForUri(this.uri,r)));return this}}],[{key:"clearKeyUriToKeyIdMap",value:function(){gA={}}},{key:"setKeyIdForUri",value:function(e,t){gA[e]=t}},{key:"addKeyIdForUri",value:function(e){var t=Object.keys(gA).length%Number.MAX_SAFE_INTEGER,i=new Uint8Array(16);return new DataView(i.buffer,12,4).setUint32(0,t),gA[e]=i,i}}])}();function bA(e){var t=null==e?void 0:e[lA];if(t){var i=aA(t.uri);if(i)return pA(i)}return null}var wA=/#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,kA=/#EXT-X-MEDIA:(.*)/g,SA=/^#EXT(?:INF|-X-TARGETDURATION):/m,EA=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#.*/.source].join("|"),"g"),TA=new RegExp([/#EXT-X-(PROGRAM-DATE-TIME|BYTERANGE|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|INDEPENDENT-SEGMENTS)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),PA=function(){function e(){u(this,e)}return m(e,null,[{key:"findGroup",value:function(e,t){for(var i=0;i<e.length;i++){var n=e[i];if(n.id===t)return n}}},{key:"resolve",value:function(e,t){return ET.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}},{key:"isMediaPlaylist",value:function(e){return SA.test(e)}},{key:"parseMasterPlaylist",value:function(t,i){var n,a={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:jM(t)},r=[];if(wA.lastIndex=0,!t.startsWith("#EXTM3U"))return a.playlistParsingError=new Error("no EXTM3U delimiter"),a;for(;null!=(n=wA.exec(t));)if(n[1]){var o,s=new VM(n[1],a),u=BM(a,n[2]),l={attrs:s,bitrate:s.decimalInteger("BANDWIDTH")||s.decimalInteger("AVERAGE-BANDWIDTH"),name:s.NAME,url:e.resolve(u,i)},d=s.decimalResolution("RESOLUTION");d&&(l.width=d.width,l.height=d.height),CA(s.CODECS,l);var h=s["SUPPLEMENTAL-CODECS"];h&&(l.supplemental={},CA(h,l.supplemental)),null!=(o=l.unknownCodecs)&&o.length||r.push(l),a.levels.push(l)}else if(n[3]){var c=n[3],m=n[4];switch(c){case"SESSION-DATA":var f=new VM(m,a),v=f["DATA-ID"];v&&(null===a.sessionData&&(a.sessionData={}),a.sessionData[v]=f);break;case"SESSION-KEY":var p=DA(m,i,a);p.encrypted&&p.isSupported()?(null===a.sessionKeys&&(a.sessionKeys=[]),a.sessionKeys.push(p)):lT.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${m}"`);break;case"DEFINE":zM(a,new VM(m,a),i);break;case"CONTENT-STEERING":var g=new VM(m,a);a.contentSteering={uri:e.resolve(g["SERVER-URI"],i),pathwayId:g["PATHWAY-ID"]||"."};break;case"START":a.startTimeOffset=xA(m)}}var y=r.length>0&&r.length<a.levels.length;return a.levels=y?r:a.levels,0===a.levels.length&&(a.playlistParsingError=new Error("no levels found in manifest")),a}},{key:"parseMasterPlaylistMedia",value:function(t,i,n){var a,r={},o=n.levels,s={AUDIO:o.map(e=>({id:e.attrs.AUDIO,audioCodec:e.audioCodec})),SUBTITLES:o.map(e=>({id:e.attrs.SUBTITLES,textCodec:e.textCodec})),"CLOSED-CAPTIONS":[]},u=0;for(kA.lastIndex=0;null!==(a=kA.exec(t));){var l=new VM(a[1],n),d=l.TYPE;if(d){var h=s[d],c=r[d]||[];r[d]=c;var m=l.LANGUAGE,f=l["ASSOC-LANGUAGE"],v=l.CHANNELS,p=l.CHARACTERISTICS,g=l["INSTREAM-ID"],y={attrs:l,bitrate:0,id:u++,groupId:l["GROUP-ID"]||"",name:l.NAME||m||"",type:d,default:l.bool("DEFAULT"),autoselect:l.bool("AUTOSELECT"),forced:l.bool("FORCED"),lang:m,url:l.URI?e.resolve(l.URI,i):""};if(f&&(y.assocLang=f),v&&(y.channels=v),p&&(y.characteristics=p),g&&(y.instreamId=g),null!=h&&h.length){var b=e.findGroup(h,y.groupId)||h[0];IA(y,b,"audioCodec"),IA(y,b,"textCodec")}c.push(y)}}return r}},{key:"parseLevelPlaylist",value:function(e,t,i,n,a,r){var o,s,u,l,d,h={url:t},c=new qM(t),m=c.fragments,f=[],v=null,p=0,g=0,y=0,b=0,w=0,k=null,S=new CT(n,h),E=-1,T=!1,P=null;if(EA.lastIndex=0,c.m3u8=e,c.hasVariableRefs=jM(e),"#EXTM3U"!==(null==(o=EA.exec(e))?void 0:o[0]))return c.playlistParsingError=new Error("Missing format identifier #EXTM3U"),c;for(;null!==(s=EA.exec(e));){T&&(T=!1,(S=new CT(n,h)).playlistOffset=y,S.setStart(y),S.sn=p,S.cc=b,w&&(S.bitrate=w),S.level=i,v&&(S.initSegment=v,v.rawProgramDateTime&&(S.rawProgramDateTime=v.rawProgramDateTime,v.rawProgramDateTime=null),P&&(S.setByteRange(P),P=null)));var M=s[1];if(M){S.duration=parseFloat(M);var A=(" "+s[2]).slice(1);S.title=A||null,S.tagList.push(A?["INF",M,A]:["INF",M])}else if(s[3]){if($E(S.duration)){S.playlistOffset=y,S.setStart(y),l&&RA(S,l,c),S.sn=p,S.level=i,S.cc=b,m.push(S);var D=(" "+s[3]).slice(1);S.relurl=BM(c,D),LA(S,k,f),k=S,y+=S.duration,p++,g=0,T=!0}}else{if(!(s=s[0].match(TA))){lT.warn("No matches on slow regex match for level playlist!");continue}for(u=1;u<s.length&&void 0===s[u];u++);var x=(" "+s[u]).slice(1),C=(" "+s[u+1]).slice(1),I=s[u+2]?(" "+s[u+2]).slice(1):null;switch(x){case"BYTERANGE":k?S.setByteRange(C,k):S.setByteRange(C);break;case"PROGRAM-DATE-TIME":S.rawProgramDateTime=C,S.tagList.push(["PROGRAM-DATE-TIME",C]),-1===E&&(E=m.length);break;case"PLAYLIST-TYPE":c.type&&FA(c,x,s),c.type=C.toUpperCase();break;case"MEDIA-SEQUENCE":0!==c.startSN?FA(c,x,s):m.length>0&&OA(c,x,s),p=c.startSN=parseInt(C);break;case"SKIP":c.skippedSegments&&FA(c,x,s);var L=new VM(C,c),_=L.decimalInteger("SKIPPED-SEGMENTS");if($E(_)){c.skippedSegments+=_;for(var R=_;R--;)m.push(null);p+=_}var F=L.enumeratedString("RECENTLY-REMOVED-DATERANGES");F&&(c.recentlyRemovedDateranges=(c.recentlyRemovedDateranges||[]).concat(F.split("\t")));break;case"TARGETDURATION":0!==c.targetduration&&FA(c,x,s),c.targetduration=Math.max(parseInt(C),1);break;case"VERSION":null!==c.version&&FA(c,x,s),c.version=parseInt(C);break;case"INDEPENDENT-SEGMENTS":break;case"ENDLIST":c.live||FA(c,x,s),c.live=!1;break;case"#":(C||I)&&S.tagList.push(I?[C,I]:[C]);break;case"DISCONTINUITY":b++,S.tagList.push(["DIS"]);break;case"GAP":S.gap=!0,S.tagList.push([x]);break;case"BITRATE":S.tagList.push([x,C]),w=1e3*parseInt(C),$E(w)?S.bitrate=w:w=0;break;case"DATERANGE":var O=new VM(C,c),W=new YM(O,c.dateRanges[O.ID],c.dateRangeTagCount);c.dateRangeTagCount++,W.isValid||c.skippedSegments?c.dateRanges[W.id]=W:lT.warn(`Ignoring invalid DATERANGE tag: "${C}"`),S.tagList.push(["EXT-X-DATERANGE",C]);break;case"DEFINE":var $=new VM(C,c);"IMPORT"in $?UM(c,$,r):zM(c,$,t);break;case"DISCONTINUITY-SEQUENCE":0!==c.startCC?FA(c,x,s):m.length>0&&OA(c,x,s),c.startCC=b=parseInt(C);break;case"KEY":var N=DA(C,t,c);if(N.isSupported()){if("NONE"===N.method){l=void 0;break}l||(l={});var j=l[N.keyFormat];null!=j&&j.matches(N)||(j&&(l=eT({},l)),l[N.keyFormat]=N)}else lT.warn(`[Keys] Ignoring unsupported EXT-X-KEY tag: "${C}"`);break;case"START":c.startTimeOffset=xA(C);break;case"MAP":var B=new VM(C,c);if(S.duration){var z=new CT(n,h);_A(z,B,i,l),v=z,S.initSegment=v,v.rawProgramDateTime&&!S.rawProgramDateTime&&(S.rawProgramDateTime=v.rawProgramDateTime)}else{var U=S.byteRangeEndOffset;if(U){var H=S.byteRangeStartOffset;P=`${U-H}@${H}`}else P=null;_A(S,B,i,l),v=S,T=!0}v.cc=b;break;case"SERVER-CONTROL":d&&FA(c,x,s),d=new VM(C),c.canBlockReload=d.bool("CAN-BLOCK-RELOAD"),c.canSkipUntil=d.optionalFloat("CAN-SKIP-UNTIL",0),c.canSkipDateRanges=c.canSkipUntil>0&&d.bool("CAN-SKIP-DATERANGES"),c.partHoldBack=d.optionalFloat("PART-HOLD-BACK",0),c.holdBack=d.optionalFloat("HOLD-BACK",0);break;case"PART-INF":c.partTarget&&FA(c,x,s);var G=new VM(C);c.partTarget=G.decimalFloatingPoint("PART-TARGET");break;case"PART":var V=c.partList;V||(V=c.partList=[]);var K=g>0?V[V.length-1]:void 0,X=g++,Y=new VM(C,c),q=new IT(Y,S,h,X,K);V.push(q),S.duration+=q.duration;break;case"PRELOAD-HINT":var J=new VM(C,c);c.preloadHint=J;break;case"RENDITION-REPORT":var Q=new VM(C,c);c.renditionReports=c.renditionReports||[],c.renditionReports.push(Q);break;default:lT.warn(`line parsed but not handled: ${s}`)}}}k&&!k.relurl?(m.pop(),y-=k.duration,c.partList&&(c.fragmentHint=k)):c.partList&&(LA(S,k,f),S.cc=b,c.fragmentHint=S,l&&RA(S,l,c)),c.targetduration||(c.playlistParsingError=new Error("Missing Target Duration"));var Z=m.length,ee=m[0],te=m[Z-1];if((y+=c.skippedSegments*c.targetduration)>0&&Z&&te){c.averagetargetduration=y/Z;var ie=te.sn;c.endSN="initSegment"!==ie?ie:0,c.live||(te.endList=!0),E>0&&(!function(e,t){for(var i=e[t],n=t;n--;){var a=e[n];if(!a)return;a.programDateTime=i.programDateTime-1e3*a.duration,i=a}}(m,E),ee&&f.unshift(ee))}return c.fragmentHint&&(y+=c.fragmentHint.duration),c.totalduration=y,f.length&&c.dateRangeTagCount&&ee&&MA(f,c),c.endCC=b,c}}])}();function MA(e,t){var i=e.length;if(!i){if(!t.hasProgramDateTime)return;var n=t.fragments[t.fragments.length-1];e.push(n),i++}for(var a=e[i-1],r=t.live?1/0:t.totalduration,o=Object.keys(t.dateRanges),s=o.length;s--;){var u=t.dateRanges[o[s]],l=u.startDate.getTime();u.tagAnchor=a.ref;for(var d=i;d--;){var h;if((null==(h=e[d])?void 0:h.sn)<t.startSN)break;var c=AA(t,l,e,d,r);if(-1!==c){u.tagAnchor=t.fragments[c].ref;break}}}}function AA(e,t,i,n,a){var r=i[n];if(r){var o,s=r.programDateTime;if(t>=s||0===n)if(t<=s+1e3*(((null==(o=i[n+1])?void 0:o.start)||a)-r.start)){var u=i[n].sn-e.startSN;if(u<0)return-1;var l=e.fragments;if(l.length>i.length)for(var d=(i[n+1]||l[l.length-1]).sn-e.startSN;d>u;d--){var h=l[d].programDateTime;if(t>=h&&t<h+1e3*l[d].duration)return d}return u}}return-1}function DA(e,t,i){var n,a,r=new VM(e,i),o=null!=(n=r.METHOD)?n:"",s=r.URI,u=r.hexadecimalInteger("IV"),l=r.KEYFORMATVERSIONS,d=null!=(a=r.KEYFORMAT)?a:"identity";s&&r.IV&&!u&&lT.error(`Invalid IV: ${r.IV}`);var h=s?PA.resolve(s,t):"",c=(l||"1").split("/").map(Number).filter(Number.isFinite);return new yA(o,h,d,c,u,r.KEYID)}function xA(e){var t=new VM(e).decimalFloatingPoint("TIME-OFFSET");return $E(t)?t:null}function CA(e,t){var i=(e||"").split(/[ ,]+/).filter(e=>e);["video","audio","text"].forEach(e=>{var n=i.filter(t=>sP(t,e));n.length&&(t[`${e}Codec`]=n.map(e=>e.split("/")[0]).join(","),i=i.filter(e=>-1===n.indexOf(e)))}),t.unknownCodecs=i}function IA(e,t,i){var n=t[i];n&&(e[i]=n)}function LA(e,t,i){e.rawProgramDateTime?i.push(e):null!=t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime)}function _A(e,t,i,n){e.relurl=t.URI,t.BYTERANGE&&e.setByteRange(t.BYTERANGE),e.level=i,e.sn="initSegment",n&&(e.levelkeys=n),e.initSegment=null}function RA(e,t,i){e.levelkeys=t;var n=i.encryptedFragments;n.length&&n[n.length-1].levelkeys===t||!Object.keys(t).some(e=>t[e].isCommonEncryption)||n.push(e)}function FA(e,t,i){e.playlistParsingError=new Error(`#EXT-X-${t} must not appear more than once (${i[0]})`)}function OA(e,t,i){e.playlistParsingError=new Error(`#EXT-X-${t} must appear before the first Media Segment (${i[0]})`)}function WA(e,t){var i=t.startPTS;if($E(i)){var n,a=0;t.sn>e.sn?(a=i-e.start,n=e):(a=e.start-i,n=t),n.duration!==a&&n.setDuration(a)}else if(t.sn>e.sn){e.cc===t.cc&&e.minEndPTS?t.setStart(e.start+(e.minEndPTS-e.start)):t.setStart(e.start+e.duration)}else t.setStart(Math.max(e.start-t.duration,0))}function $A(e,t,i,n,a,r,o){n-i<=0&&(o.warn("Fragment should have a positive duration",t),n=i+t.duration,r=a+t.duration);var s=i,u=n,l=t.startPTS,d=t.endPTS;if($E(l)){var h=Math.abs(l-i);e&&h>e.totalduration?o.warn(`media timestamps and playlist times differ by ${h}s for level ${t.level} ${e.url}`):$E(t.deltaPTS)?t.deltaPTS=Math.max(h,t.deltaPTS):t.deltaPTS=h,s=Math.max(i,l),i=Math.min(i,l),a=void 0!==t.startDTS?Math.min(a,t.startDTS):a,u=Math.min(n,d),n=Math.max(n,d),r=void 0!==t.endDTS?Math.max(r,t.endDTS):r}var c=i-t.start;0!==t.start&&t.setStart(i),t.setDuration(n-t.start),t.startPTS=i,t.maxStartPTS=s,t.startDTS=a,t.endPTS=n,t.minEndPTS=u,t.endDTS=r;var m,f=t.sn;if(!e||f<e.startSN||f>e.endSN)return 0;var v=f-e.startSN,p=e.fragments;for(p[v]=t,m=v;m>0;m--)WA(p[m],p[m-1]);for(m=v;m<p.length-1;m++)WA(p[m],p[m+1]);return e.fragmentHint&&WA(p[p.length-1],e.fragmentHint),e.PTSKnown=e.alignedSliding=!0,c}function NA(e,t,i){if(e!==t){for(var n,a=null,r=e.fragments,o=r.length-1;o>=0;o--){var s=r[o].initSegment;if(s){a=s;break}}e.fragmentHint&&delete e.fragmentHint.endPTS,function(e,t,i){for(var n=t.skippedSegments,a=Math.max(e.startSN,t.startSN)-t.startSN,r=(e.fragmentHint?1:0)+(n?t.endSN:Math.min(e.endSN,t.endSN))-t.startSN,o=t.startSN-e.startSN,s=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,u=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,l=a;l<=r;l++){var d=u[o+l],h=s[l];if(n&&!h&&d&&(h=t.fragments[l]=d),d&&h){i(d,h,l,s);var c=d.relurl,m=h.relurl;if(c&&XA(c,m))return void(t.playlistParsingError=jA(`media sequence mismatch ${h.sn}:`,e,t,d,h));if(d.cc!==h.cc)return void(t.playlistParsingError=jA(`discontinuity sequence mismatch (${d.cc}!=${h.cc})`,e,t,d,h))}}}(e,t,(e,i,r,o)=>{if((!t.startCC||t.skippedSegments)&&i.cc!==e.cc){for(var s=e.cc-i.cc,u=r;u<o.length;u++)o[u].cc+=s;t.endCC=o[o.length-1].cc}$E(e.startPTS)&&$E(e.endPTS)&&(i.setStart(i.startPTS=e.startPTS),i.startDTS=e.startDTS,i.maxStartPTS=e.maxStartPTS,i.endPTS=e.endPTS,i.endDTS=e.endDTS,i.minEndPTS=e.minEndPTS,i.setDuration(e.endPTS-e.startPTS),i.duration&&(n=i),t.PTSKnown=t.alignedSliding=!0),e.hasStreams&&(i.elementaryStreams=e.elementaryStreams),i.loader=e.loader,e.hasStats&&(i.stats=e.stats),e.initSegment&&(i.initSegment=e.initSegment,a=e.initSegment)});var u=t.fragments,l=t.fragmentHint?u.concat(t.fragmentHint):u;if(a&&l.forEach(e=>{var t;!e||e.initSegment&&e.initSegment.relurl!==(null==(t=a)?void 0:t.relurl)||(e.initSegment=a)}),t.skippedSegments){if(t.deltaUpdateFailed=u.some(e=>!e),t.deltaUpdateFailed){i.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var d=t.skippedSegments;d--;)u.shift();t.startSN=u[0].sn}else{t.canSkipDateRanges&&(t.dateRanges=function(e,t,i){var n=t.dateRanges,a=t.recentlyRemovedDateranges,r=eT({},e);a&&a.forEach(e=>{delete r[e]});var o=Object.keys(r).length;if(!o)return n;return Object.keys(n).forEach(e=>{var t=r[e],a=new YM(n[e].attr,t);a.isValid?(r[e]=a,t||(a.tagOrder+=o)):i.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${WP(n[e].attr)}"`)}),r}(e.dateRanges,t,i));var h=e.fragments.filter(e=>e.rawProgramDateTime);if(e.hasProgramDateTime&&!t.hasProgramDateTime)for(var c=1;c<l.length;c++)null===l[c].programDateTime&&LA(l[c],l[c-1],h);MA(h,t)}t.endCC=u[u.length-1].cc}if(!t.startCC){var m,f=HA(e,t.startSN-1);t.startCC=null!=(m=null==f?void 0:f.cc)?m:u[0].cc}!function(e,t,i){if(e&&t)for(var n=0,a=0,r=e.length;a<=r;a++){var o=e[a],s=t[a+n];o&&s&&o.index===s.index&&o.fragment.sn===s.fragment.sn?i(o,s):n--}}(e.partList,t.partList,(e,t)=>{t.elementaryStreams=e.elementaryStreams,t.stats=e.stats}),n?$A(t,n,n.startPTS,n.endPTS,n.startDTS,n.endDTS,i):BA(e,t),u.length&&(t.totalduration=t.edge-u[0].start),t.driftStartTime=e.driftStartTime,t.driftStart=e.driftStart;var v=t.advancedDateTime;if(t.advanced&&v){var p=t.edge;t.driftStart||(t.driftStartTime=v,t.driftStart=p),t.driftEndTime=v,t.driftEnd=p}else t.driftEndTime=e.driftEndTime,t.driftEnd=e.driftEnd,t.advancedDateTime=e.advancedDateTime;-1===t.requestScheduled&&(t.requestScheduled=e.requestScheduled)}}function jA(e,t,i,n,a){return new Error(`${e} ${a.url}\nPlaylist starting @${t.startSN}\n${t.m3u8}\n\nPlaylist starting @${i.startSN}\n${i.m3u8}`)}function BA(e,t,i=!0){var n=t.startSN+t.skippedSegments-e.startSN,a=e.fragments,r=n>=0,o=0;if(r&&n<a.length)o=a[n].start;else if(r&&t.startSN===e.endSN+1)o=e.fragmentEnd;else if(r&&i)o=e.fragmentStart+n*t.levelTargetDuration;else{if(t.skippedSegments||0!==t.fragmentStart)return;o=e.fragmentStart}zA(t,o)}function zA(e,t){if(t){for(var i=e.fragments,n=e.skippedSegments;n<i.length;n++)i[n].addStart(t);e.fragmentHint&&e.fragmentHint.addStart(t)}}function UA(e,t=1/0){var i=1e3*e.targetduration;if(e.updated){var n=e.fragments;if(n.length&&4*i>t){var a=1e3*n[n.length-1].duration;a<i&&(i=a)}}else i/=2;return Math.round(i)}function HA(e,t,i){if(!e)return null;var n=e.fragments[t-e.startSN];return n||((n=e.fragmentHint)&&n.sn===t?n:t<e.startSN&&i&&i.sn===t?i:null)}function GA(e,t,i){return e?VA(e.partList,t,i):null}function VA(e,t,i){if(e)for(var n=e.length;n--;){var a=e[n];if(a.index===i&&a.fragment.sn===t)return a}return null}function KA(e){e.forEach((e,t)=>{var i;null==(i=e.details)||i.fragments.forEach(e=>{e.level=t,e.initSegment&&(e.initSegment.level=t)})})}function XA(e,t){return!(e===t||!t)&&YA(e)!==YA(t)}function YA(e){return e.replace(/\?[^?]*$/,"")}function qA(e,t){for(var i=0,n=e.length;i<n;i++){var a;if((null==(a=e[i])?void 0:a.cc)===t)return e[i]}return null}function JA(e,t){var i=e.start+t;e.startPTS=i,e.setStart(i),e.endPTS=i+e.duration}function QA(e,t){for(var i=t.fragments,n=0,a=i.length;n<a;n++)JA(i[n],e);t.fragmentHint&&JA(t.fragmentHint,e),t.alignedSliding=!0}function ZA(e,t){if(function(e,t){return!!(e&&t.startCC<e.endCC&&t.endCC>e.startCC)}(t,e)){var i=Math.min(t.endCC,e.endCC),n=qA(t.fragments,i),a=qA(e.fragments,i);if(n&&a)lT.log(`Aligning playlist at start of dicontinuity sequence ${i}`),QA(n.start-a.start,e)}}function eD(e,t){if(e.hasProgramDateTime&&t.hasProgramDateTime){var i=e.fragments,n=t.fragments;if(i.length&&n.length){var a,r,o=Math.min(t.endCC,e.endCC);t.startCC<o&&e.startCC<o&&(a=qA(n,o),r=qA(i,o)),a&&r||(r=qA(i,(a=n[Math.floor(n.length/2)]).cc)||i[Math.floor(i.length/2)]);var s=a.programDateTime,u=r.programDateTime;if(s&&u)QA((u-s)/1e3-(r.start-a.start),e)}}}function tD(e,t,i){iD(e,t,i),e.addEventListener(t,i)}function iD(e,t,i){e.removeEventListener(t,i)}var nD=function(e){for(var t="",i=e.length,n=0;n<i;n++)t+=`[${e.start(n).toFixed(3)}-${e.end(n).toFixed(3)}]`;return t},aD="STOPPED",rD="IDLE",oD="KEY_LOADING",sD="FRAG_LOADING",uD="FRAG_LOADING_WAITING_RETRY",lD="WAITING_TRACK",dD="PARSING",hD="PARSED",cD="ENDED",mD="ERROR",fD="WAITING_INIT_PTS",vD="WAITING_LEVEL",pD=function(){function e(t,i,n,a,r){var o;return u(this,e),(o=s(this,e,[a,t.logger])).hls=void 0,o.fragPrevious=null,o.fragCurrent=null,o.fragmentTracker=void 0,o.transmuxer=null,o._state=aD,o.playlistType=void 0,o.media=null,o.mediaBuffer=null,o.config=void 0,o.bitrateTest=!1,o.lastCurrentTime=0,o.nextLoadPosition=0,o.startPosition=0,o.startTimeOffset=null,o.retryDate=0,o.levels=null,o.fragmentLoader=void 0,o.keyLoader=void 0,o.levelLastLoaded=null,o.startFragRequested=!1,o.decrypter=void 0,o.initPTS=[],o.buffering=!0,o.loadingParts=!1,o.loopSn=void 0,o.onMediaSeeking=()=>{var e=o,t=e.config,i=e.fragCurrent,n=e.media,a=e.mediaBuffer,r=e.state,s=n?n.currentTime:0,u=$M.bufferInfo(a||n,s,t.maxBufferHole),l=!u.len;if(o.log(`Media seeking to ${$E(s)?s.toFixed(3):s}, state: ${r}, ${l?"out of":"in"} buffer`),o.state===cD)o.resetLoadingState();else if(i){var d=t.maxFragLookUpTolerance,h=i.start-d,c=i.start+i.duration+d;if(l||c<u.start||h>u.end){var m=s>c;(s<h||m)&&(m&&i.loader&&(o.log(`Cancelling fragment load for seek (sn: ${i.sn})`),i.abortRequests(),o.resetLoadingState()),o.fragPrevious=null)}}if(n&&(o.fragmentTracker.removeFragmentsInRange(s,1/0,o.playlistType,!0),s>o.lastCurrentTime&&(o.lastCurrentTime=s),!o.loadingParts)){var f=Math.max(u.end,s),v=o.shouldLoadParts(o.getLevelDetails(),f);v&&(o.log(`LL-Part loading ON after seeking to ${s.toFixed(2)} with buffer @${f.toFixed(2)}`),o.loadingParts=v)}o.hls.hasEnoughToStart||(o.log(`Setting ${l?"startPosition":"nextLoadPosition"} to ${s} for seek without enough to start`),o.nextLoadPosition=s,l&&(o.startPosition=s)),l&&o.state===rD&&o.tickImmediate()},o.onMediaEnded=()=>{o.log("setting startPosition to 0 because media ended"),o.startPosition=o.lastCurrentTime=0},o.playlistType=r,o.hls=t,o.fragmentLoader=new IM(t.config),o.keyLoader=n,o.fragmentTracker=i,o.config=t.config,o.decrypter=new xM(t.config),o}return y(e,FM),m(e,[{key:"registerListeners",value:function(){var e=this.hls;e.on(UE.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(UE.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(UE.MANIFEST_LOADING,this.onManifestLoading,this),e.on(UE.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(UE.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(UE.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(UE.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(UE.MANIFEST_LOADING,this.onManifestLoading,this),e.off(UE.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(UE.ERROR,this.onError,this)}},{key:"doTick",value:function(){this.onTickEnd()}},{key:"onTickEnd",value:function(){}},{key:"startLoad",value:function(e){}},{key:"stopLoad",value:function(){if(this.state!==aD){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);var e=this.fragCurrent;null!=e&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=aD}}},{key:"startPositionValue",get:function(){var e=this.nextLoadPosition,t=this.startPosition;return-1===t&&e?e:t}},{key:"bufferingEnabled",get:function(){return this.buffering}},{key:"pauseBuffering",value:function(){this.buffering=!1}},{key:"resumeBuffering",value:function(){this.buffering=!0}},{key:"inFlightFrag",get:function(){return{frag:this.fragCurrent,state:this.state}}},{key:"_streamEnded",value:function(e,t){if(t.live||!this.media)return!1;var i=e.end||0,n=this.config.timelineOffset||0;if(i<=n)return!1;var a=e.buffered;this.config.maxBufferHole&&a&&a.length>1&&(e=$M.bufferedInfo(a,e.start,0));var r=e.nextStart;if(r&&r>n&&r<t.edge)return!1;if(this.media.currentTime<e.start)return!1;var o=t.partList;if(null!=o&&o.length){var s=o[o.length-1];return $M.isBuffered(this.media,s.start+s.duration/2)}var u=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(u)}},{key:"getLevelDetails",value:function(){if(this.levels&&null!==this.levelLastLoaded)return this.levelLastLoaded.details}},{key:"timelineOffset",get:function(){var e,t=this.config.timelineOffset;return t?(null==(e=this.getLevelDetails())?void 0:e.appliedTimelineOffset)||t:0}},{key:"onMediaAttached",value:function(e,t){var i=this.media=this.mediaBuffer=t.media;tD(i,"seeking",this.onMediaSeeking),tD(i,"ended",this.onMediaEnded);var n=this.config;this.levels&&n.autoStartLoad&&this.state===aD&&this.startLoad(n.startPosition)}},{key:"onMediaDetaching",value:function(e,t){var i=!!t.transferMedia,n=this.media;if(null!==n){if(n.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),iD(n,"seeking",this.onMediaSeeking),iD(n,"ended",this.onMediaEnded),this.keyLoader&&!i&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loopSn=void 0,i)return this.resetLoadingState(),void this.resetTransmuxer();this.loadingParts=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}}},{key:"onManifestLoading",value:function(){this.initPTS=[],this.levels=this.levelLastLoaded=this.fragCurrent=null,this.lastCurrentTime=this.startPosition=0,this.startFragRequested=!1}},{key:"onError",value:function(e,t){}},{key:"onManifestLoaded",value:function(e,t){this.startTimeOffset=t.startTimeOffset}},{key:"onHandlerDestroying",value:function(){this.stopLoad(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),M(e,"onHandlerDestroying",this)([]),this.hls=this.onMediaSeeking=this.onMediaEnded=null}},{key:"onHandlerDestroyed",value:function(){this.state=aD,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,M(e,"onHandlerDestroyed",this)([])}},{key:"loadFragment",value:function(e,t,i){this.startFragRequested=!0,this._loadFragForPlayback(e,t,i)}},{key:"_loadFragForPlayback",value:function(e,t,i){this._doFragLoad(e,t,i,e=>{var t=e.frag;if(this.fragContextChanged(t))return this.warn(`${t.type} sn: ${t.sn}${e.part?" part: "+e.part.index:""} of ${this.fragInfo(t,!1,e.part)}) was dropped during download.`),void this.fragmentTracker.removeFragment(t);t.stats.chunkCount++,this._handleFragmentLoadProgress(e)}).then(e=>{if(e){var t=this.state,i=e.frag;this.fragContextChanged(i)?(t===sD||!this.fragCurrent&&t===dD)&&(this.fragmentTracker.removeFragment(i),this.state=rD):("payload"in e&&(this.log(`Loaded ${i.type} sn: ${i.sn} of ${this.playlistLabel()} ${i.level}`),this.hls.trigger(UE.FRAG_LOADED,e)),this._handleFragmentLoadComplete(e))}}).catch(t=>{this.state!==aD&&this.state!==mD&&(this.warn(`Frag error: ${(null==t?void 0:t.message)||t}`),this.resetFragmentLoading(e))})}},{key:"clearTrackerIfNeeded",value:function(e){var t,i=this.fragmentTracker;if(i.getState(e)===gM){var n=e.type,a=this.getFwdBufferInfo(this.mediaBuffer,n),r=Math.max(e.duration,a?a.len:this.config.maxBufferLength),o=this.backtrackFragment;(1===(o?e.sn-o.sn:0)||this.reduceMaxBufferLength(r,e.duration))&&i.removeFragment(e)}else 0===(null==(t=this.mediaBuffer)?void 0:t.buffered.length)?i.removeAllFragments():i.hasParts(e.type)&&(i.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),i.getState(e)===yM&&i.removeFragment(e))}},{key:"checkLiveUpdate",value:function(e){if(e.updated&&!e.live){var t=e.fragments[e.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type})}e.fragments[0]||(e.deltaUpdateFailed=!0)}},{key:"waitForLive",value:function(e){var t=e.details;return(null==t?void 0:t.live)&&"EVENT"!==t.type&&(this.levelLastLoaded!==e||t.expired)}},{key:"flushMainBuffer",value:function(e,t,i=null){if(e-t){var n={startOffset:e,endOffset:t,type:i};this.hls.trigger(UE.BUFFER_FLUSHING,n)}}},{key:"_loadInitSegment",value:function(e,t){this._doFragLoad(e,t).then(e=>{var t=null==e?void 0:e.frag;if(!t||this.fragContextChanged(t)||!this.levels)throw new Error("init load aborted");return e}).then(e=>{var t=this.hls,i=e.frag,n=e.payload,a=i.decryptdata;if(n&&n.byteLength>0&&null!=a&&a.key&&a.iv&&ZM(a.method)){var r=self.performance.now();return this.decrypter.decrypt(new Uint8Array(n),a.key.buffer,a.iv.buffer,eA(a.method)).catch(e=>{throw t.trigger(UE.ERROR,{type:BE.MEDIA_ERROR,details:zE.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:i}),e}).then(n=>{var a=self.performance.now();return t.trigger(UE.FRAG_DECRYPTED,{frag:i,payload:n,stats:{tstart:r,tdecrypt:a}}),e.payload=n,this.completeInitSegmentLoad(e)})}return this.completeInitSegmentLoad(e)}).catch(t=>{this.state!==aD&&this.state!==mD&&(this.warn(t),this.resetFragmentLoading(e))})}},{key:"completeInitSegmentLoad",value:function(e){if(!this.levels)throw new Error("init load aborted, missing levels");var t=e.frag.stats;this.state!==aD&&(this.state=rD),e.frag.data=new Uint8Array(e.payload),t.parsing.start=t.buffering.start=self.performance.now(),t.parsing.end=t.buffering.end=self.performance.now(),this.tick()}},{key:"unhandledEncryptionError",value:function(e,t){var i,n,a=e.tracks;if(a&&!t.encrypted&&(null!=(i=a.audio)&&i.encrypted||null!=(n=a.video)&&n.encrypted)&&(!this.config.emeEnabled||!this.keyLoader.emeController)){var r=this.media,o=new Error(`Encrypted track with no key in ${this.fragInfo(t)} (media ${r?"attached mediaKeys: "+r.mediaKeys:"detached"})`);return this.warn(o.message),!r||r.mediaKeys?!1:(this.hls.trigger(UE.ERROR,{type:BE.KEY_SYSTEM_ERROR,details:zE.KEY_SYSTEM_NO_KEYS,fatal:!1,error:o,frag:t}),this.resetTransmuxer(),!0)}return!1}},{key:"fragContextChanged",value:function(e){var t=this.fragCurrent;return!e||!t||e.sn!==t.sn||e.level!==t.level}},{key:"fragBufferedComplete",value:function(e,t){var i=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log(`Buffered ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,!1,t)} > buffer:${i?nD($M.getBuffered(i)):"(detached)"})`),xT(e)){var n;if(e.type!==qE){var a=e.elementaryStreams;if(!Object.keys(a).some(e=>!!a[e]))return void(this.state=rD)}var r=null==(n=this.levels)?void 0:n[e.level];null!=r&&r.fragmentError&&(this.log(`Resetting level fragment error count of ${r.fragmentError} on frag buffered`),r.fragmentError=0)}this.state=rD}},{key:"_handleFragmentLoadComplete",value:function(e){var t=this.transmuxer;if(t){var i=e.frag,n=e.part,a=e.partsLoaded,r=!a||0===a.length||a.some(e=>!e),o=new OM(i.level,i.sn,i.stats.chunkCount+1,0,n?n.index:-1,!r);t.flush(o)}}},{key:"_handleFragmentLoadProgress",value:function(e){}},{key:"_doFragLoad",value:function(e,t,i=null,n){var a;this.fragCurrent=e;var r=t.details;if(!this.levels||!r)throw new Error(`frag load aborted, missing level${r?"":" detail"}s`);var o=null;if(!e.encrypted||null!=(a=e.decryptdata)&&a.key)e.encrypted||(o=this.keyLoader.loadClear(e,r.encryptedFragments,this.startFragRequested))&&this.log("[eme] blocking frag load until media-keys acquired");else if(this.log(`Loading key for ${e.sn} of [${r.startSN}-${r.endSN}], ${this.playlistLabel()} ${e.level}`),this.state=oD,this.fragCurrent=e,o=this.keyLoader.load(e).then(e=>{if(!this.fragContextChanged(e.frag))return this.hls.trigger(UE.KEY_LOADED,e),this.state===oD&&(this.state=rD),e}),this.hls.trigger(UE.KEY_LOADING,{frag:e}),null===this.fragCurrent)return this.log("context changed in KEY_LOADING"),Promise.resolve(null);var s,u=this.fragPrevious;if(xT(e)&&(!u||e.sn!==u.sn)){var l=this.shouldLoadParts(t.details,e.end);l!==this.loadingParts&&(this.log(`LL-Part loading ${l?"ON":"OFF"} loading sn ${null==u?void 0:u.sn}->${e.sn}`),this.loadingParts=l)}if(i=Math.max(e.start,i||0),this.loadingParts&&xT(e)){var d=r.partList;if(d&&n){i>r.fragmentEnd&&r.fragmentHint&&(e=r.fragmentHint);var h=this.getNextPart(d,e,i);if(h>-1){var c,m=d[h];return e=this.fragCurrent=m.fragment,this.log(`Loading ${e.type} sn: ${e.sn} part: ${m.index} (${h}/${d.length-1}) of ${this.fragInfo(e,!1,m)}) cc: ${e.cc} [${r.startSN}-${r.endSN}], target: ${parseFloat(i.toFixed(3))}`),this.nextLoadPosition=m.start+m.duration,this.state=sD,c=o?o.then(i=>!i||this.fragContextChanged(i.frag)?null:this.doFragPartsLoad(e,m,t,n)).catch(e=>this.handleFragLoadError(e)):this.doFragPartsLoad(e,m,t,n).catch(e=>this.handleFragLoadError(e)),this.hls.trigger(UE.FRAG_LOADING,{frag:e,part:m,targetBufferTime:i}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):c}if(!e.url||this.loadedEndOfParts(d,i))return Promise.resolve(null)}}if(xT(e)&&this.loadingParts)this.log(`LL-Part loading OFF after next part miss @${i.toFixed(2)} Check buffer at sn: ${e.sn} loaded parts: ${null==(s=r.partList)?void 0:s.filter(e=>e.loaded).map(e=>`[${e.start}-${e.end}]`)}`),this.loadingParts=!1;else if(!e.url)return Promise.resolve(null);this.log(`Loading ${e.type} sn: ${e.sn} of ${this.fragInfo(e,!1)}) cc: ${e.cc} ${"["+r.startSN+"-"+r.endSN+"]"}, target: ${parseFloat(i.toFixed(3))}`),$E(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=sD;var f,v=this.config.progressive&&e.type!==qE;return f=v&&o?o.then(t=>!t||this.fragContextChanged(t.frag)?null:this.fragmentLoader.load(e,n)).catch(e=>this.handleFragLoadError(e)):Promise.all([this.fragmentLoader.load(e,v?n:void 0),o]).then(([e])=>(!v&&n&&n(e),e)).catch(e=>this.handleFragLoadError(e)),this.hls.trigger(UE.FRAG_LOADING,{frag:e,targetBufferTime:i}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):f}},{key:"doFragPartsLoad",value:function(e,t,i,n){return new Promise((a,r)=>{var o,s=[],u=null==(o=i.details)?void 0:o.partList,l=t=>{this.fragmentLoader.loadPart(e,t,n).then(n=>{s[t.index]=n;var r=n.part;this.hls.trigger(UE.FRAG_LOADED,n);var o=GA(i.details,e.sn,t.index+1)||VA(u,e.sn,t.index+1);if(!o)return a({frag:e,part:r,partsLoaded:s});l(o)}).catch(r)};l(t)})}},{key:"handleFragLoadError",value:function(e){if("data"in e){var t=e.data;t.frag&&t.details===zE.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):t.frag&&t.type===BE.KEY_SYSTEM_ERROR?(t.frag.abortRequests(),this.resetStartWhenNotLoaded(),this.resetFragmentLoading(t.frag)):this.hls.trigger(UE.ERROR,t)}else this.hls.trigger(UE.ERROR,{type:BE.OTHER_ERROR,details:zE.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}},{key:"_handleTransmuxerFlush",value:function(e){var t=this.getCurrentContext(e);if(t&&this.state===dD){var i=t.frag,n=t.part,a=t.level,r=self.performance.now();i.stats.parsing.end=r,n&&(n.stats.parsing.end=r);var o=this.getLevelDetails(),s=o&&i.sn>o.endSN||this.shouldLoadParts(o,i.end);s!==this.loadingParts&&(this.log(`LL-Part loading ${s?"ON":"OFF"} after parsing segment ending @${i.end.toFixed(2)}`),this.loadingParts=s),this.updateLevelTiming(i,n,a,e.partial)}else this.fragCurrent||this.state===aD||this.state===mD||(this.state=rD)}},{key:"shouldLoadParts",value:function(e,t){if(this.config.lowLatencyMode){if(!e)return this.loadingParts;if(e.partList){var i,n,a=e.partList[0];if(a.fragment.type===qE)return!1;if(t>=a.end+((null==(i=e.fragmentHint)?void 0:i.duration)||0))if((this.hls.hasEnoughToStart?(null==(n=this.media)?void 0:n.currentTime)||this.lastCurrentTime:this.getLoadPosition())>a.start-a.fragment.duration)return!0}}return!1}},{key:"getCurrentContext",value:function(e){var t=this.levels,i=this.fragCurrent,n=e.level,a=e.sn,r=e.part;if(null==t||!t[n])return this.warn(`Levels object was unset while buffering fragment ${a} of ${this.playlistLabel()} ${n}. The current chunk will not be buffered.`),null;var o=t[n],s=o.details,u=r>-1?GA(s,a,r):null,l=u?u.fragment:HA(s,a,i);return l?(i&&i!==l&&(l.stats=i.stats),{frag:l,part:u,level:o}):null}},{key:"bufferFragmentData",value:function(e,t,i,n,a){if(this.state===dD){var r=e.data1,o=e.data2,s=r;if(o&&(s=JT(r,o)),s.length){var u=this.initPTS[t.cc],l=u?-u.baseTime/u.timescale:void 0,d={type:e.type,frag:t,part:i,chunkMeta:n,offset:l,parent:t.type,data:s};if(this.hls.trigger(UE.BUFFER_APPENDING,d),e.dropped&&e.independent&&!i){if(a)return;this.flushBufferGap(t)}}}}},{key:"flushBufferGap",value:function(e){var t=this.media;if(t)if($M.isBuffered(t,t.currentTime)){var i=t.currentTime,n=$M.bufferInfo(t,i,0),a=e.duration,r=Math.min(2*this.config.maxFragLookUpTolerance,.25*a),o=Math.max(Math.min(e.start-r,n.end-r),i+r);e.start-o>r&&this.flushMainBuffer(o,e.start)}else this.flushMainBuffer(0,e.start)}},{key:"getFwdBufferInfo",value:function(e,t){var i,n=this.getLoadPosition();if(!$E(n))return null;var a=this.lastCurrentTime>n||null!=(i=this.media)&&i.paused?0:this.config.maxBufferHole;return this.getFwdBufferInfoAtPos(e,n,t,a)}},{key:"getFwdBufferInfoAtPos",value:function(e,t,i,n){var a=$M.bufferInfo(e,t,n);if(0===a.len&&void 0!==a.nextStart){var r=this.fragmentTracker.getBufferedFrag(t,i);if(r&&(a.nextStart<=r.end||r.gap)){var o=Math.max(Math.min(a.nextStart,r.end)-t,n);return $M.bufferInfo(e,t,o)}}return a}},{key:"getMaxBufferLength",value:function(e){var t,i=this.config;return t=e?Math.max(8*i.maxBufferSize/e,i.maxBufferLength):i.maxBufferLength,Math.min(t,i.maxMaxBufferLength)}},{key:"exceedsMaxBuffer",value:function(e,t,i){var n=e.nextStart;if(n&&i.start>n){var a=e.buffered;if(a){for(var r=e.len,o=e.bufferedIndex,s=a.length-1;s>o;s--)a[s].start<i.start&&(r+=a[s].end-a[s].start);return r>=t}}return!1}},{key:"reduceMaxBufferLength",value:function(e,t){var i=this.config,n=Math.max(Math.min(e-t,i.maxBufferLength),t),a=Math.max(e-3*t,i.maxMaxBufferLength/2,n);return a>=n&&(i.maxMaxBufferLength=a,this.warn(`Reduce max buffer length to ${a}s`),!0)}},{key:"getAppendedFrag",value:function(e,t=XE){var i=this.fragmentTracker?this.fragmentTracker.getAppendedFrag(e,t):null;return i&&"fragment"in i?i.fragment:i}},{key:"getNextFragment",value:function(e,t){var i=t.fragments,n=i.length;if(!n)return null;var a=this.config,r=t.fragmentStart,o=a.lowLatencyMode&&!!t.partList,s=null;if(t.live){var u=a.initialLiveManifestSize;if(n<u)return this.warn(`Not enough fragments to start playback (have: ${n}, need: ${u})`),null;if(!t.PTSKnown&&!this.startFragRequested&&-1===this.startPosition||e<r){var l;o&&!this.loadingParts&&(this.log("LL-Part loading ON for initial live fragment"),this.loadingParts=!0),s=this.getInitialLiveFragment(t);var d,h,c=this.config.startPosition,m=this.hls.startPosition,f=this.hls.liveSyncPosition,v=(null==(l=s)?void 0:l.start)||0;-1!==m&&m>=r?(d=m,h=m===c?"config":"next load start"):null!==f?(d=f,h="live edge"):(d=e,h="buffer pos"),d<v&&(d=v,h="live frag start"),d<r&&(d=r,h="playlist start"),this.startPosition==d&&this.nextLoadPosition==d||(this.log(`Setting startPosition to ${d.toFixed(3)} ${-1===m?"":`(from ${c}) `}based on ${h}. live edge: ${f} live frag start: ${v.toFixed(3)} playlist start: ${r.toFixed(3)} buffer pos: ${e}`),this.startPosition=this.nextLoadPosition=d)}}else e<=r&&(s=i[0]);if(!s){var p=this.loadingParts?t.partEnd:t.fragmentEnd;s=this.getFragmentAtPosition(e,p,t)}var g=this.filterReplacedPrimary(s,t);if(!g&&s){var y=s.sn-t.startSN;g=this.filterReplacedPrimary(i[y+1]||null,t)}return this.mapToInitFragWhenRequired(g)}},{key:"isLoopLoading",value:function(e,t){if(this.nextLoadPosition<=t)return!1;var i=this.fragmentTracker.getState(e);return i===bM||i===yM&&!!e.gap}},{key:"getNextFragmentLoopLoading",value:function(e,t,i,n,a){var r=null;if(e.gap&&(r=this.getNextFragment(this.nextLoadPosition,t))&&!r.gap&&i.nextStart){var o=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,i.nextStart,n,0);if(null!==o&&i.len+o.len>=a){var s=r.sn;return this.loopSn!==s&&(this.log(`buffer full after gaps in "${n}" playlist starting at sn: ${s}`),this.loopSn=s),null}}return this.loopSn=void 0,r}},{key:"primaryPrefetch",get:function(){var e;if(gD(this.config)&&(null==(e=this.hls.interstitialsManager)||null==(e=e.playingItem)?void 0:e.event))return!0;return!1}},{key:"filterReplacedPrimary",value:function(e,t){if(!e)return e;if(gD(this.config)&&e.type!==qE){var i=this.hls.interstitialsManager,n=null==i?void 0:i.bufferingItem;if(n){var a=n.event;if(a){if(a.appendInPlace||Math.abs(e.start-n.start)>1||0===n.start)return null}else{if(e.end<=n.start&&!1===(null==t?void 0:t.live))return null;if(e.start>n.end&&n.nextEvent&&(n.nextEvent.appendInPlace||e.start-n.end>1))return null}}var r=null==i?void 0:i.playerQueue;if(r)for(var o=r.length;o--;){var s=r[o].interstitial;if(s.appendInPlace&&e.start>=s.startTime&&e.end<=s.resumeTime)return null}}return e}},{key:"mapToInitFragWhenRequired",value:function(e){return null==e||!e.initSegment||e.initSegment.data||this.bitrateTest?e:e.initSegment}},{key:"getNextPart",value:function(e,t,i){for(var n=-1,a=!1,r=!0,o=0,s=e.length;o<s;o++){var u=e[o];if(r=r&&!u.independent,n>-1&&i<u.start)break;var l=u.loaded;l?n=-1:(a||(u.independent||r)&&u.fragment===t)&&(u.fragment!==t&&this.warn(`Need buffer at ${i} but next unloaded part starts at ${u.start}`),n=o),a=l}return n}},{key:"loadedEndOfParts",value:function(e,t){for(var i,n=e.length;n--;){if(!(i=e[n]).loaded)return!1;if(t>i.start)return!0}return!1}},{key:"getInitialLiveFragment",value:function(e){var t=e.fragments,i=this.fragPrevious,n=null;if(i){if(e.hasProgramDateTime&&(n=function(e,t,i){if(null===t||!Array.isArray(e)||!e.length||!$E(t))return null;if(t<(e[0].programDateTime||0))return null;if(t>=(e[e.length-1].endProgramDateTime||0))return null;for(var n=0;n<e.length;++n){var a=e[n];if(qP(t,i,a))return a}return null}(t,i.endProgramDateTime,this.config.maxFragLookUpTolerance),n&&this.log(`Live playlist, switching playlist, load frag with same PDT: ${i.programDateTime}`)),!n){var a=i.sn+1;if(a>=e.startSN&&a<=e.endSN){var r=t[a-e.startSN];i.cc===r.cc&&(n=r,this.log(`Live playlist, switching playlist, load frag with next SN: ${n.sn}`))}n||(n=JP(e,i.cc,i.end))&&this.log(`Live playlist, switching playlist, load frag with same CC: ${n.sn}`)}}else{var o=this.hls.liveSyncPosition;null!==o&&(n=this.getFragmentAtPosition(o,this.bitrateTest?e.fragmentEnd:e.edge,e))}return n}},{key:"getFragmentAtPosition",value:function(e,t,i){var n,a,r=this.config,o=this.fragPrevious,s=i.fragments,u=i.endSN,l=i.fragmentHint,d=r.maxFragLookUpTolerance,h=i.partList,c=!!(this.loadingParts&&null!=h&&h.length&&l);(c&&!this.bitrateTest&&h[h.length-1].fragment.sn===l.sn&&(s=s.concat(l),u=l.sn),e<t)?n=XP(o,s,e,e<this.lastCurrentTime||e>t-d||null!=(a=this.media)&&a.paused||!this.startFragRequested?0:d):n=s[s.length-1];if(n){var m=n.sn-i.startSN,f=this.fragmentTracker.getState(n);if((f===bM||f===yM&&n.gap)&&(o=n),o&&n.sn===o.sn&&(!c||h[0].fragment.sn>n.sn||!i.live))if(n.level===o.level){var v=s[m+1];n=n.sn<u&&this.fragmentTracker.getState(v)!==bM?v:null}}return n}},{key:"alignPlaylists",value:function(e,t,i){var n=e.fragments.length;if(!n)return this.warn("No fragments in live playlist"),0;var a=e.fragmentStart,r=!t,o=e.alignedSliding&&$E(a);if(r||!o&&!a){!function(e,t){e&&(ZA(t,e),t.alignedSliding||eD(t,e),t.alignedSliding||t.skippedSegments||BA(e,t,!1))}(i,e);var s=e.fragmentStart;return this.log(`Live playlist sliding: ${s.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${e.startSN} fragments: ${n}`),s}return a}},{key:"waitForCdnTuneIn",value:function(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,3*e.partTarget)}},{key:"setStartPosition",value:function(e,t){var i=this.startPosition;i<t&&(i=-1);var n=this.timelineOffset;if(-1===i){var a=null!==this.startTimeOffset,r=a?this.startTimeOffset:e.startTimeOffset;null!==r&&$E(r)?(i=t+r,r<0&&(i+=e.edge),i=Math.min(Math.max(t,i),t+e.totalduration),this.log(`Setting startPosition to ${i} for start time offset ${r} found in ${a?"multivariant":"media"} playlist`),this.startPosition=i):e.live?(i=this.hls.liveSyncPosition||t,this.log(`Setting startPosition to -1 to start at live edge ${i}`),this.startPosition=-1):(this.log("setting startPosition to 0 by default"),this.startPosition=i=0),this.lastCurrentTime=i+n}this.nextLoadPosition=i+n}},{key:"getLoadPosition",value:function(){var e,t=this.media,i=0;return null!=(e=this.hls)&&e.hasEnoughToStart&&t?i=t.currentTime:this.nextLoadPosition>=0&&(i=this.nextLoadPosition),i}},{key:"handleFragLoadAborted",value:function(e,t){this.transmuxer&&e.type===this.playlistType&&xT(e)&&e.stats.aborted&&(this.log(`Fragment ${e.sn}${t?" part "+t.index:""} of ${this.playlistLabel()} ${e.level} was aborted`),this.resetFragmentLoading(e))}},{key:"resetFragmentLoading",value:function(e){this.fragCurrent&&(this.fragContextChanged(e)||this.state===uD)||(this.state=rD)}},{key:"onFragmentOrKeyLoadError",value:function(e,t){var i;if(t.chunkMeta&&!t.frag){var n=this.getCurrentContext(t.chunkMeta);n&&(t.frag=n.frag)}var a=t.frag;if(a&&a.type===e&&this.levels)if(this.fragContextChanged(a)){var r;this.warn(`Frag load error must match current frag to retry ${a.url} > ${null==(r=this.fragCurrent)?void 0:r.url}`)}else{var o=t.details===zE.FRAG_GAP;o&&this.fragmentTracker.fragBuffered(a,!0);var s=t.errorAction;if(s){var u=s.action,l=s.flags,d=s.retryCount,h=void 0===d?0:d,c=s.retryConfig,m=!!c,f=m&&u===lM,v=m&&!s.resolved&&l===hM,p=null==(i=this.hls.latestLevelDetails)?void 0:i.live;if(!f&&v&&xT(a)&&!a.endList&&p&&!eM(t))this.resetFragmentErrors(e),this.treatAsGap(a),s.resolved=!0;else if((f||v)&&h<c.maxNumRetry){var g,y=rM(null==(g=t.response)?void 0:g.code),b=iM(c,h);if(this.resetStartWhenNotLoaded(),this.retryDate=self.performance.now()+b,this.state=uD,s.resolved=!0,y)return this.log("Waiting for connection (offline)"),this.retryDate=1/0,void(t.reason="offline");this.warn(`Fragment ${a.sn} of ${e} ${a.level} errored with ${t.details}, retrying loading ${h+1}/${c.maxNumRetry} in ${b}ms`)}else if(c){if(this.resetFragmentErrors(e),!(h<c.maxNumRetry))return void this.warn(`${t.details} reached or exceeded max retry (${h})`);o||u===uM||(s.resolved=!0)}else this.state=u===sM?vD:mD;this.tickImmediate()}else this.state=mD}}},{key:"checkRetryDate",value:function(){var e=self.performance.now(),t=this.retryDate,i=t===1/0;(!t||e>=t||i&&!rM(0))&&(i&&this.log("Connection restored (online)"),this.resetStartWhenNotLoaded(),this.state=rD)}},{key:"reduceLengthAndFlushBuffer",value:function(e){if(this.state===dD||this.state===hD){var t=e.frag,i=e.parent,n=this.getFwdBufferInfo(this.mediaBuffer,i),a=n&&n.len>.5;a&&this.reduceMaxBufferLength(n.len,(null==t?void 0:t.duration)||10);var r=!a;return r&&this.warn(`Buffer full error while media.currentTime (${this.getLoadPosition()}) is not buffered, flush ${i} buffer`),t&&(this.fragmentTracker.removeFragment(t),this.nextLoadPosition=t.start),this.resetLoadingState(),r}return!1}},{key:"resetFragmentErrors",value:function(e){e===YE&&(this.fragCurrent=null),this.hls.hasEnoughToStart||(this.startFragRequested=!1),this.state!==aD&&(this.state=rD)}},{key:"afterBufferFlushed",value:function(e,t,i){if(e){var n=$M.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,n,i),this.state===cD&&this.resetLoadingState()}}},{key:"resetLoadingState",value:function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==aD&&(this.state=rD)}},{key:"resetStartWhenNotLoaded",value:function(){if(!this.hls.hasEnoughToStart){this.startFragRequested=!1;var e=this.levelLastLoaded,t=e?e.details:null;null!=t&&t.live?(this.log("resetting startPosition for live start"),this.startPosition=-1,this.setStartPosition(t,t.fragmentStart),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}},{key:"resetWhenMissingContext",value:function(e){this.log(`Loading context changed while buffering sn ${e.sn} of ${this.playlistLabel()} ${-1===e.level?"<removed>":e.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(),this.resetLoadingState()}},{key:"removeUnbufferedFrags",value:function(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}},{key:"updateLevelTiming",value:function(e,t,i,n){var a=i.details;if(a){if(!Object.keys(e.elementaryStreams).reduce((t,r)=>{var o=e.elementaryStreams[r];if(o){var s=o.endPTS-o.startPTS;if(s<=0)return this.warn(`Could not parse fragment ${e.sn} ${r} duration reliably (${s})`),t||!1;var u=n?0:$A(a,e,o.startPTS,o.endPTS,o.startDTS,o.endDTS,this);return this.hls.trigger(UE.LEVEL_PTS_UPDATED,{details:a,level:i,drift:u,type:r,frag:e,start:o.startPTS,end:o.endPTS}),!0}return t},!1)){var r,o=null===(null==(r=this.transmuxer)?void 0:r.error);if((0===i.fragmentError||o&&(i.fragmentError<2||e.endList))&&this.treatAsGap(e,i),o){var s=new Error(`Found no media in fragment ${e.sn} of ${this.playlistLabel()} ${e.level} resetting transmuxer to fallback to playlist timing`);if(this.warn(s.message),this.hls.trigger(UE.ERROR,{type:BE.MEDIA_ERROR,details:zE.FRAG_PARSING_ERROR,fatal:!1,error:s,frag:e,reason:`Found no media in msn ${e.sn} of ${this.playlistLabel()} "${i.url}"`}),!this.hls)return;this.resetTransmuxer()}}this.state=hD,this.log(`Parsed ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,!1,t)})`),this.hls.trigger(UE.FRAG_PARSED,{frag:e,part:t})}else this.warn("level.details undefined")}},{key:"playlistLabel",value:function(){return this.playlistType===XE?"level":"track"}},{key:"fragInfo",value:function(e,t=!0,i){var n,a;return`${this.playlistLabel()} ${e.level} (${i?"part":"frag"}:[${(null!=(n=t&&!i?e.startPTS:(i||e).start)?n:NaN).toFixed(3)}-${(null!=(a=t&&!i?e.endPTS:(i||e).end)?a:NaN).toFixed(3)}]${i&&"main"===e.type?"INDEPENDENT="+(i.independent?"YES":"NO"):""}`}},{key:"treatAsGap",value:function(e,t){t&&t.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)}},{key:"resetTransmuxer",value:function(){var e;null==(e=this.transmuxer)||e.reset()}},{key:"recoverWorkerError",value:function(e){"demuxerWorker"===e.event&&(this.fragmentTracker.removeAllFragments(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),this.resetStartWhenNotLoaded(),this.resetLoadingState())}},{key:"state",get:function(){return this._state},set:function(e){var t=this._state;t!==e&&(this._state=e,this.log(`${t}->${e}`))}}])}();function gD(e){return!!e.interstitialsController&&!1!==e.enableInterstitialPlayback}var yD=function(){return m(function e(){u(this,e),this.chunks=[],this.dataLength=0},[{key:"push",value:function(e){this.chunks.push(e),this.dataLength+=e.length}},{key:"flush",value:function(){var e,t=this.chunks,i=this.dataLength;return t.length?(e=1===t.length?t[0]:function(e,t){for(var i=new Uint8Array(t),n=0,a=0;a<e.length;a++){var r=e[a];i.set(r,n),n+=r.length}return i}(t,i),this.reset(),e):new Uint8Array(0)}},{key:"reset",value:function(){this.chunks.length=0,this.dataLength=0}}])}();var bD,wD={exports:{}};var kD=(bD||(bD=1,function(e){var t=Object.prototype.hasOwnProperty,i="~";function n(){}function a(e,t,i){this.fn=e,this.context=t,this.once=i||!1}function r(e,t,n,r,o){if("function"!=typeof n)throw new TypeError("The listener must be a function");var s=new a(n,r||e,o),u=i?i+t:t;return e._events[u]?e._events[u].fn?e._events[u]=[e._events[u],s]:e._events[u].push(s):(e._events[u]=s,e._eventsCount++),e}function o(e,t){0===--e._eventsCount?e._events=new n:delete e._events[t]}function s(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(i=!1)),s.prototype.eventNames=function(){var e,n,a=[];if(0===this._eventsCount)return a;for(n in e=this._events)t.call(e,n)&&a.push(i?n.slice(1):n);return Object.getOwnPropertySymbols?a.concat(Object.getOwnPropertySymbols(e)):a},s.prototype.listeners=function(e){var t=i?i+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var a=0,r=n.length,o=new Array(r);a<r;a++)o[a]=n[a].fn;return o},s.prototype.listenerCount=function(e){var t=i?i+e:e,n=this._events[t];return n?n.fn?1:n.length:0},s.prototype.emit=function(e,t,n,a,r,o){var s=i?i+e:e;if(!this._events[s])return!1;var u,l,d=this._events[s],h=arguments.length;if(d.fn){switch(d.once&&this.removeListener(e,d.fn,void 0,!0),h){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,t),!0;case 3:return d.fn.call(d.context,t,n),!0;case 4:return d.fn.call(d.context,t,n,a),!0;case 5:return d.fn.call(d.context,t,n,a,r),!0;case 6:return d.fn.call(d.context,t,n,a,r,o),!0}for(l=1,u=new Array(h-1);l<h;l++)u[l-1]=arguments[l];d.fn.apply(d.context,u)}else{var c,m=d.length;for(l=0;l<m;l++)switch(d[l].once&&this.removeListener(e,d[l].fn,void 0,!0),h){case 1:d[l].fn.call(d[l].context);break;case 2:d[l].fn.call(d[l].context,t);break;case 3:d[l].fn.call(d[l].context,t,n);break;case 4:d[l].fn.call(d[l].context,t,n,a);break;default:if(!u)for(c=1,u=new Array(h-1);c<h;c++)u[c-1]=arguments[c];d[l].fn.apply(d[l].context,u)}}return!0},s.prototype.on=function(e,t,i){return r(this,e,t,i,!1)},s.prototype.once=function(e,t,i){return r(this,e,t,i,!0)},s.prototype.removeListener=function(e,t,n,a){var r=i?i+e:e;if(!this._events[r])return this;if(!t)return o(this,r),this;var s=this._events[r];if(s.fn)s.fn!==t||a&&!s.once||n&&s.context!==n||o(this,r);else{for(var u=0,l=[],d=s.length;u<d;u++)(s[u].fn!==t||a&&!s[u].once||n&&s[u].context!==n)&&l.push(s[u]);l.length?this._events[r]=1===l.length?l[0]:l:o(this,r)}return this},s.prototype.removeAllListeners=function(e){var t;return e?(t=i?i+e:e,this._events[t]&&o(this,t)):(this._events=new n,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=i,s.EventEmitter=s,e.exports=s}(wD)),wD.exports),SD=vT(kD),ED="1.6.16",TD={};function PD(e,t){return t+10<=e.length&&51===e[t]&&68===e[t+1]&&73===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128}function MD(e,t){return t+10<=e.length&&73===e[t]&&68===e[t+1]&&51===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128}function AD(e,t){var i=0;return i=(127&e[t])<<21,i|=(127&e[t+1])<<14,i|=(127&e[t+2])<<7,i|=127&e[t+3]}function DD(e,t){for(var i=t,n=0;MD(e,t);){n+=10,n+=AD(e,t+6),PD(e,t+10)&&(n+=10),t+=n}if(n>0)return e.subarray(i,i+n)}function xD(e,t){return 255===e[t]&&240==(246&e[t+1])}function CD(e,t){return 1&e[t+1]?7:9}function ID(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function LD(e,t){return t+1<e.length&&xD(e,t)}function _D(e,t){if(LD(e,t)){var i=CD(e,t);if(t+i>=e.length)return!1;var n=ID(e,t);if(n<=i)return!1;var a=t+n;return a===e.length||LD(e,a)}return!1}function RD(e,t,i,n,a){if(!e.samplerate){var r=function(e,t,i,n){var a=t[i+2],r=a>>2&15;if(!(r>12)){var o=1+(a>>6&3),s=t[i+3]>>6&3|(1&a)<<2,u="mp4a.40."+o,l=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350][r],d=r;5!==o&&29!==o||(d-=3);var h=[o<<3|(14&d)>>1,(1&d)<<7|s<<3];return lT.log(`manifest codec:${n}, parsed codec:${u}, channels:${s}, rate:${l} (ADTS object type:${o} sampling index:${r})`),{config:h,samplerate:l,channelCount:s,codec:u,parsedCodec:u,manifestCodec:n}}var c=new Error(`invalid ADTS sampling index:${r}`);e.emit(UE.ERROR,UE.ERROR,{type:BE.MEDIA_ERROR,details:zE.FRAG_PARSING_ERROR,fatal:!0,error:c,reason:c.message})}(t,i,n,a);if(!r)return;eT(e,r)}}function FD(e){return 9216e4/e}function OD(e,t,i,n,a){var r,o=n+a*FD(e.samplerate),s=function(e,t){var i=CD(e,t);if(t+i<=e.length){var n=ID(e,t)-i;if(n>0)return{headerLength:i,frameLength:n}}}(t,i);if(s){var u=s.frameLength,l=s.headerLength,d=l+u,h=Math.max(0,i+d-t.length);h?(r=new Uint8Array(d-l)).set(t.subarray(i+l,t.length),0):r=t.subarray(i+l,i+d);var c={unit:r,pts:o};return h||e.samples.push(c),{sample:c,length:d,missing:h}}var m=t.length-i;return(r=new Uint8Array(m)).set(t.subarray(i,t.length),0),{sample:{unit:r,pts:o},length:m,missing:-1}}function WD(e,t){return MD(e,t)&&AD(e,t+6)+10<=e.length-t}function $D(e,t=0,i=1/0){return function(e,t,i,n){var a=function(e){return e instanceof ArrayBuffer?e:e.buffer}(e),r=1;"BYTES_PER_ELEMENT"in n&&(r=n.BYTES_PER_ELEMENT);var o=(h=e,h&&h.buffer instanceof ArrayBuffer&&void 0!==h.byteLength&&void 0!==h.byteOffset?e.byteOffset:0),s=(o+e.byteLength)/r,u=(o+t)/r,l=Math.floor(Math.max(0,Math.min(u,s))),d=Math.floor(Math.min(l+Math.max(i,0),s));var h;return new n(a,l,d-l)}(e,t,i,Uint8Array)}function ND(e){var t={key:e.type,description:"",data:"",mimeType:null,pictureType:null};if(!(e.size<2))if(3===e.data[0]){var i=e.data.subarray(1).indexOf(0);if(-1!==i){var n=cT($D(e.data,1,i)),a=e.data[2+i],r=e.data.subarray(3+i).indexOf(0);if(-1!==r){var o,s=cT($D(e.data,3+i,r));return o="--\x3e"===n?cT($D(e.data,4+i+r)):function(e){return e instanceof ArrayBuffer?e:0==e.byteOffset&&e.byteLength==e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer}(e.data.subarray(4+i+r)),t.mimeType=n,t.pictureType=a,t.description=s,t.data=o,t}}}else console.log("Ignore frame with unrecognized character encoding")}function jD(e){return"PRIV"===e.type?function(e){if(!(e.size<2)){var t=cT(e.data,!0),i=new Uint8Array(e.data.subarray(t.length+1));return{key:e.type,info:t,data:i.buffer}}}(e):"W"===e.type[0]?function(e){if("WXXX"===e.type){if(e.size<2)return;var t=1,i=cT(e.data.subarray(t),!0);t+=i.length+1;var n=cT(e.data.subarray(t));return{key:e.type,info:i,data:n}}var a=cT(e.data);return{key:e.type,info:"",data:a}}(e):"APIC"===e.type?ND(e):function(e){if(!(e.size<2)){if("TXXX"===e.type){var t=1,i=cT(e.data.subarray(t),!0);t+=i.length+1;var n=cT(e.data.subarray(t));return{key:e.type,info:i,data:n}}var a=cT(e.data.subarray(1));return{key:e.type,info:"",data:a}}}(e)}function BD(e){var t=String.fromCharCode(e[0],e[1],e[2],e[3]),i=AD(e,4);return{type:t,size:i,data:e.subarray(10,10+i)}}function zD(e){for(var t=0,i=[];MD(e,t);){var n=AD(e,t+6);e[t+5]>>6&1&&(t+=10);for(var a=(t+=10)+n;t+10<a;){var r=BD(e.subarray(t)),o=jD(r);o&&i.push(o),t+=r.size+10}PD(e,t)&&(t+=10)}return i}function UD(e){return e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info}function HD(e){if(8===e.data.byteLength){var t=new Uint8Array(e.data),i=1&t[3],n=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return n/=45,i&&(n+=47721858.84),Math.round(n)}}function GD(e){for(var t=zD(e),i=0;i<t.length;i++){var n=t[i];if(UD(n))return HD(n)}}var VD=function(e){return e.audioId3="org.id3",e.dateRange="com.apple.quicktime.HLS",e.emsg="https://aomedia.org/emsg/ID3",e.misbklv="urn:misb:KLV:bin:1910.1",e}({});function KD(e="",t=9e4){return{type:e,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}var XD=function(){return m(function e(){u(this,e),this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null},[{key:"resetInitSegment",value:function(e,t,i,n){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}},{key:"resetTimeStamp",value:function(e){this.initPTS=e,this.resetContiguity()}},{key:"resetContiguity",value:function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}},{key:"canParse",value:function(e,t){return!1}},{key:"appendFrame",value:function(e,t,i){}},{key:"demux",value:function(e,t){this.cachedData&&(e=JT(this.cachedData,e),this.cachedData=null);var i,n=DD(e,0),a=n?n.length:0,r=this._audioTrack,o=this._id3Track,s=n?GD(n):void 0,u=e.length;for((null===this.basePTS||0===this.frameIndex&&$E(s))&&(this.basePTS=YD(s,t,this.initPTS),this.lastPTS=this.basePTS),null===this.lastPTS&&(this.lastPTS=this.basePTS),n&&n.length>0&&o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:n,type:VD.audioId3,duration:Number.POSITIVE_INFINITY});a<u;){if(this.canParse(e,a)){var l=this.appendFrame(r,e,a);l?(this.frameIndex++,this.lastPTS=l.sample.pts,i=a+=l.length):a=u}else WD(e,a)?(n=DD(e,a),o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:n,type:VD.audioId3,duration:Number.POSITIVE_INFINITY}),i=a+=n.length):a++;if(a===u&&i!==u){var d=e.slice(i);this.cachedData?this.cachedData=JT(this.cachedData,d):this.cachedData=d}}return{audioTrack:r,videoTrack:KD(),id3Track:o,textTrack:KD()}}},{key:"demuxSampleAes",value:function(e,t,i){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}},{key:"flush",value:function(e){var t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:KD(),id3Track:this._id3Track,textTrack:KD()}}},{key:"destroy",value:function(){this.cachedData=null,this._audioTrack=this._id3Track=void 0}}])}(),YD=(e,t,i)=>$E(e)?90*e:9e4*t+(i?9e4*i.baseTime/i.timescale:0),qD=null,JD=[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],QD=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],ZD=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],ex=[0,1,1,4];function tx(e,t,i,n,a){if(!(i+24>t.length)){var r=ix(t,i);if(r&&i+r.frameLength<=t.length){var o=n+a*(9e4*r.samplesPerFrame/r.sampleRate),s={unit:t.subarray(i,i+r.frameLength),pts:o,dts:o};return e.config=[],e.channelCount=r.channelCount,e.samplerate=r.sampleRate,e.samples.push(s),{sample:s,length:r.frameLength,missing:0}}}}function ix(e,t){var i=e[t+1]>>3&3,n=e[t+1]>>1&3,a=e[t+2]>>4&15,r=e[t+2]>>2&3;if(1!==i&&0!==a&&15!==a&&3!==r){var o=e[t+2]>>1&1,s=e[t+3]>>6,u=1e3*JD[14*(3===i?3-n:3===n?3:4)+a-1],l=QD[3*(3===i?0:2===i?1:2)+r],d=3===s?1:2,h=ZD[i][n],c=ex[n],m=8*h*c,f=Math.floor(h*u/l+o)*c;if(null===qD){var v=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);qD=v?parseInt(v[1]):0}return!!qD&&qD<=87&&2===n&&u>=224e3&&0===s&&(e[t+3]=128|e[t+3]),{sampleRate:l,channelCount:d,frameLength:f,samplesPerFrame:m}}}function nx(e,t){return!(255!==e[t]||224&~e[t+1]||!(6&e[t+1]))}function ax(e,t){return t+1<e.length&&nx(e,t)}function rx(e,t){if(t+1<e.length&&nx(e,t)){var i=ix(e,t),n=4;null!=i&&i.frameLength&&(n=i.frameLength);var a=t+n;return a===e.length||ax(e,a)}return!1}var ox=function(){function e(t,i){var n;return u(this,e),(n=s(this,e)).observer=void 0,n.config=void 0,n.observer=t,n.config=i,n}return y(e,XD),m(e,[{key:"resetInitSegment",value:function(t,i,n,a){M(e,"resetInitSegment",this)([t,i,n,a]),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:i,duration:a,inputTimeScale:9e4,dropped:0}}},{key:"canParse",value:function(e,t){return function(e,t){return function(e,t){return t+5<e.length}(e,t)&&xD(e,t)&&ID(e,t)<=e.length-t}(e,t)}},{key:"appendFrame",value:function(e,t,i){RD(e,this.observer,t,i,e.manifestCodec);var n=OD(e,t,i,this.basePTS,this.frameIndex);if(n&&0===n.missing)return n}}],[{key:"probe",value:function(e,t){if(!e)return!1;var i=DD(e,0),n=(null==i?void 0:i.length)||0;if(rx(e,n))return!1;for(var a=e.length;n<a;n++)if(_D(e,n))return t.log("ADTS sync word found !"),!0;return!1}}])}(),sx=(e,t)=>{var i=0,n=5;t+=n;for(var a=new Uint32Array(1),r=new Uint32Array(1),o=new Uint8Array(1);n>0;){o[0]=e[t];var s=Math.min(n,8),u=8-s;r[0]=4278190080>>>24+u<<u,a[0]=(o[0]&r[0])>>u,i=i?i<<s|a[0]:a[0],t+=1,n-=s}return i},ux=function(){function e(t){var i;return u(this,e),(i=s(this,e)).observer=void 0,i.observer=t,i}return y(e,XD),m(e,[{key:"resetInitSegment",value:function(t,i,n,a){M(e,"resetInitSegment",this)([t,i,n,a]),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:i,duration:a,inputTimeScale:9e4,dropped:0}}},{key:"canParse",value:function(e,t){return t+64<e.length}},{key:"appendFrame",value:function(e,t,i){var n=lx(e,t,i,this.basePTS,this.frameIndex);if(-1!==n)return{sample:e.samples[e.samples.length-1],length:n,missing:0}}}],[{key:"probe",value:function(e){if(!e)return!1;var t=DD(e,0);if(!t)return!1;var i=t.length;return 11===e[i]&&119===e[i+1]&&void 0!==GD(t)&&sx(e,i)<16}}])}();function lx(e,t,i,n,a){if(i+8>t.length)return-1;if(11!==t[i]||119!==t[i+1])return-1;var r=t[i+4]>>6;if(r>=3)return-1;var o=[48e3,44100,32e3][r],s=63&t[i+4],u=2*[64,69,96,64,70,96,80,87,120,80,88,120,96,104,144,96,105,144,112,121,168,112,122,168,128,139,192,128,140,192,160,174,240,160,175,240,192,208,288,192,209,288,224,243,336,224,244,336,256,278,384,256,279,384,320,348,480,320,349,480,384,417,576,384,418,576,448,487,672,448,488,672,512,557,768,512,558,768,640,696,960,640,697,960,768,835,1152,768,836,1152,896,975,1344,896,976,1344,1024,1114,1536,1024,1115,1536,1152,1253,1728,1152,1254,1728,1280,1393,1920,1280,1394,1920][3*s+r];if(i+u>t.length)return-1;var l=t[i+6]>>5,d=0;2===l?d+=2:(1&l&&1!==l&&(d+=2),4&l&&(d+=2));var h=(t[i+6]<<8|t[i+7])>>12-d&1,c=[2,1,2,3,3,4,4,5][l]+h,m=t[i+5]>>3,f=7&t[i+5],v=new Uint8Array([r<<6|m<<1|f>>2,(3&f)<<6|l<<3|h<<2|s>>4,s<<4&224]),p=n+a*(1536/o*9e4),g=t.subarray(i,i+u);return e.config=v,e.channelCount=c,e.samplerate=o,e.samples.push({unit:g,pts:p}),u}var dx=function(){function e(){return u(this,e),s(this,e,arguments)}return y(e,XD),m(e,[{key:"resetInitSegment",value:function(t,i,n,a){M(e,"resetInitSegment",this)([t,i,n,a]),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:i,duration:a,inputTimeScale:9e4,dropped:0}}},{key:"canParse",value:function(e,t){return function(e,t){return nx(e,t)&&4<=e.length-t}(e,t)}},{key:"appendFrame",value:function(e,t,i){if(null!==this.basePTS)return tx(e,t,i,this.basePTS,this.frameIndex)}}],[{key:"probe",value:function(e){if(!e)return!1;var t=DD(e,0),i=(null==t?void 0:t.length)||0;if(t&&11===e[i]&&119===e[i+1]&&void 0!==GD(t)&&sx(e,i)<=16)return!1;for(var n=e.length;i<n;i++)if(rx(e,i))return lT.log("MPEG Audio sync word found !"),!0;return!1}}])}(),hx=/\/emsg[-/]ID3/i,cx=function(){return m(function e(t,i){u(this,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=i},[{key:"resetTimeStamp",value:function(){}},{key:"resetInitSegment",value:function(e,t,i,n){var a=this.videoTrack=KD("video",1),r=this.audioTrack=KD("audio",1),o=this.txtTrack=KD("text",1);if(this.id3Track=KD("id3",1),this.timeOffset=0,null!=e&&e.byteLength){var s=UT(e);if(s.video){var u=s.video,l=u.id,d=u.timescale,h=u.codec,c=u.supplemental;a.id=l,a.timescale=o.timescale=d,a.codec=h,a.supplemental=c}if(s.audio){var m=s.audio,f=m.id,v=m.timescale,p=m.codec;r.id=f,r.timescale=v,r.codec=p}o.id=FT.text,a.sampleDuration=0,a.duration=r.duration=n}}},{key:"resetContiguity",value:function(){this.remainderData=null}},{key:"demux",value:function(e,t){this.timeOffset=t;var i=e,n=this.videoTrack,a=this.txtTrack;if(this.config.progressive){this.remainderData&&(i=JT(this.remainderData,e));var r=function(e){var t={valid:null,remainder:null},i=BT(e,["moof"]);if(i.length<2)return t.remainder=e,t;var n=i[i.length-1];return t.valid=e.slice(0,n.byteOffset-8),t.remainder=e.slice(n.byteOffset-8),t}(i);this.remainderData=r.remainder,n.samples=r.valid||new Uint8Array}else n.samples=i;var o=this.extractID3Track(n,t);return a.samples=QT(t,n),{videoTrack:n,audioTrack:this.audioTrack,id3Track:o,textTrack:this.txtTrack}}},{key:"flush",value:function(){var e=this.timeOffset,t=this.videoTrack,i=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;var n=this.extractID3Track(t,this.timeOffset);return i.samples=QT(e,t),{videoTrack:t,audioTrack:KD(),id3Track:n,textTrack:KD()}}},{key:"extractID3Track",value:function(e,t){var i=this.id3Track;if(e.samples.length){var n=BT(e.samples,["emsg"]);n&&n.forEach(e=>{var n=function(e){var t=e[0],i="",n="",a=0,r=0,o=0,s=0,u=0,l=0;if(0===t){for(;"\0"!==OT(e.subarray(l,l+1));)i+=OT(e.subarray(l,l+1)),l+=1;for(i+=OT(e.subarray(l,l+1)),l+=1;"\0"!==OT(e.subarray(l,l+1));)n+=OT(e.subarray(l,l+1)),l+=1;n+=OT(e.subarray(l,l+1)),l+=1,a=$T(e,12),r=$T(e,16),s=$T(e,20),u=$T(e,24),l=28}else if(1===t){a=$T(e,l+=4);var d=$T(e,l+=4),h=$T(e,l+=4);for(l+=4,NE(o=2**32*d+h)||(o=Number.MAX_SAFE_INTEGER,lT.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),s=$T(e,l),u=$T(e,l+=4),l+=4;"\0"!==OT(e.subarray(l,l+1));)i+=OT(e.subarray(l,l+1)),l+=1;for(i+=OT(e.subarray(l,l+1)),l+=1;"\0"!==OT(e.subarray(l,l+1));)n+=OT(e.subarray(l,l+1)),l+=1;n+=OT(e.subarray(l,l+1)),l+=1}return{schemeIdUri:i,value:n,timeScale:a,presentationTime:o,presentationTimeDelta:r,eventDuration:s,id:u,payload:e.subarray(l,e.byteLength)}}(e);if(hx.test(n.schemeIdUri)){var a=mx(n,t),r=4294967295===n.eventDuration?Number.POSITIVE_INFINITY:n.eventDuration/n.timeScale;r<=.001&&(r=Number.POSITIVE_INFINITY);var o=n.payload;i.samples.push({data:o,len:o.byteLength,dts:a,pts:a,type:VD.emsg,duration:r})}else if(this.config.enableEmsgKLVMetadata&&n.schemeIdUri.startsWith("urn:misb:KLV:bin:1910.1")){var s=mx(n,t);i.samples.push({data:n.payload,len:n.payload.byteLength,dts:s,pts:s,type:VD.misbklv,duration:Number.POSITIVE_INFINITY})}})}return i}},{key:"demuxSampleAes",value:function(e,t,i){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}},{key:"destroy",value:function(){this.config=null,this.remainderData=null,this.videoTrack=this.audioTrack=this.id3Track=this.txtTrack=void 0}}],[{key:"probe",value:function(e){return function(e){for(var t=e.byteLength,i=0;i<t;){var n=$T(e,i);if(n>8&&109===e[i+4]&&111===e[i+5]&&111===e[i+6]&&102===e[i+7])return!0;i=n>1?i+n:t}return!1}(e)}}])}();function mx(e,t){return $E(e.presentationTime)?e.presentationTime/e.timeScale:t+e.presentationTimeDelta/e.timeScale}var fx=function(){return m(function e(t,i,n){u(this,e),this.keyData=void 0,this.decrypter=void 0,this.keyData=n,this.decrypter=new xM(i,{removePKCS7Padding:!1})},[{key:"decryptBuffer",value:function(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer,TM)}},{key:"decryptAacSample",value:function(e,t,i){var n=e[t].unit;if(!(n.length<=16)){var a=n.subarray(16,n.length-n.length%16),r=a.buffer.slice(a.byteOffset,a.byteOffset+a.length);this.decryptBuffer(r).then(a=>{var r=new Uint8Array(a);n.set(r,16),this.decrypter.isSync()||this.decryptAacSamples(e,t+1,i)}).catch(i)}}},{key:"decryptAacSamples",value:function(e,t,i){for(;;t++){if(t>=e.length)return void i();if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,i),!this.decrypter.isSync()))return}}},{key:"getAvcEncryptedData",value:function(e){for(var t=16*Math.floor((e.length-48)/160)+16,i=new Int8Array(t),n=0,a=32;a<e.length-16;a+=160,n+=16)i.set(e.subarray(a,a+16),n);return i}},{key:"getAvcDecryptedUnit",value:function(e,t){for(var i=new Uint8Array(t),n=0,a=32;a<e.length-16;a+=160,n+=16)e.set(i.subarray(n,n+16),a);return e}},{key:"decryptAvcSample",value:function(e,t,i,n,a){var r=iP(a.data),o=this.getAvcEncryptedData(r);this.decryptBuffer(o.buffer).then(o=>{a.data=this.getAvcDecryptedUnit(r,o),this.decrypter.isSync()||this.decryptAvcSamples(e,t,i+1,n)}).catch(n)}},{key:"decryptAvcSamples",value:function(e,t,i,n){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,i=0){if(t>=e.length)return void n();for(var a=e[t].units;!(i>=a.length);i++){var r=a[i];if(!(r.data.length<=48||1!==r.type&&5!==r.type||(this.decryptAvcSample(e,t,i,n,r),this.decrypter.isSync())))return}}}}])}(),vx=function(){return m(function e(){u(this,e),this.VideoSample=null},[{key:"createVideoSample",value:function(e,t,i){return{key:e,frame:!1,pts:t,dts:i,units:[],length:0}}},{key:"getLastNalUnit",value:function(e){var t,i,n=this.VideoSample;if(n&&0!==n.units.length||(n=e[e.length-1]),null!=(t=n)&&t.units){var a=n.units;i=a[a.length-1]}return i}},{key:"pushAccessUnit",value:function(e,t){if(e.units.length&&e.frame){if(void 0===e.pts){var i=t.samples,n=i.length;if(!n)return void t.dropped++;var a=i[n-1];e.pts=a.pts,e.dts=a.dts}t.samples.push(e)}}},{key:"parseNALu",value:function(e,t,i){var n,a,r=t.byteLength,o=e.naluState||0,s=o,u=[],l=0,d=-1,h=0;for(-1===o&&(d=0,h=this.getNALuType(t,0),o=0,l=1);l<r;)if(n=t[l++],o)if(1!==o)if(n)if(1===n){if(a=l-o-1,d>=0){var c={data:t.subarray(d,a),type:h};u.push(c)}else{var m=this.getLastNalUnit(e.samples);m&&(s&&l<=4-s&&m.state&&(m.data=m.data.subarray(0,m.data.byteLength-s)),a>0&&(m.data=JT(m.data,t.subarray(0,a)),m.state=0))}l<r?(d=l,h=this.getNALuType(t,l),o=0):o=-1}else o=0;else o=3;else o=n?0:2;else o=n?0:1;if(d>=0&&o>=0){var f={data:t.subarray(d,r),type:h,state:o};u.push(f)}if(0===u.length){var v=this.getLastNalUnit(e.samples);v&&(v.data=JT(v.data,t))}return e.naluState=o,u}}])}(),px=function(){return m(function e(t){u(this,e),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},[{key:"loadWord",value:function(){var e=this.data,t=this.bytesAvailable,i=e.byteLength-t,n=new Uint8Array(4),a=Math.min(4,t);if(0===a)throw new Error("no bytes available");n.set(e.subarray(i,i+a)),this.word=new DataView(n.buffer).getUint32(0),this.bitsAvailable=8*a,this.bytesAvailable-=a}},{key:"skipBits",value:function(e){var t;e=Math.min(e,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,e-=(t=e>>3)<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}},{key:"readBits",value:function(e){var t=Math.min(this.bitsAvailable,e),i=this.word>>>32-t;if(e>32&&lT.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return(t=e-t)>0&&this.bitsAvailable?i<<t|this.readBits(t):i}},{key:"skipLZ",value:function(){var e;for(e=0;e<this.bitsAvailable;++e)if(this.word&2147483648>>>e)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}},{key:"skipUEG",value:function(){this.skipBits(1+this.skipLZ())}},{key:"skipEG",value:function(){this.skipBits(1+this.skipLZ())}},{key:"readUEG",value:function(){var e=this.skipLZ();return this.readBits(e+1)-1}},{key:"readEG",value:function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}},{key:"readBoolean",value:function(){return 1===this.readBits(1)}},{key:"readUByte",value:function(){return this.readBits(8)}},{key:"readUShort",value:function(){return this.readBits(16)}},{key:"readUInt",value:function(){return this.readBits(32)}}])}(),gx=function(){function e(){return u(this,e),s(this,e,arguments)}return y(e,vx),m(e,[{key:"parsePES",value:function(e,t,i,n){var a,r=this.parseNALu(e,i.data,n),o=this.VideoSample,s=!1;i.data=null,o&&r.length&&!e.audFound&&(this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts)),r.forEach(n=>{var r,u;switch(n.type){case 1:var l=!1;a=!0;var d,h=n.data;if(s&&h.length>4){var c=this.readSliceType(h);2!==c&&4!==c&&7!==c&&9!==c||(l=!0)}if(l)null!=(d=o)&&d.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null);o||(o=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),o.frame=!0,o.key=l;break;case 5:a=!0,null!=(r=o)&&r.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null),o||(o=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),o.key=!0,o.frame=!0;break;case 6:a=!0,tP(n.data,1,i.pts,t.samples);break;case 7:var m,f;a=!0,s=!0;var v=n.data,p=this.readSPS(v);if(!e.sps||e.width!==p.width||e.height!==p.height||(null==(m=e.pixelRatio)?void 0:m[0])!==p.pixelRatio[0]||(null==(f=e.pixelRatio)?void 0:f[1])!==p.pixelRatio[1]){e.width=p.width,e.height=p.height,e.pixelRatio=p.pixelRatio,e.sps=[v];for(var g=v.subarray(1,4),y="avc1.",b=0;b<3;b++){var w=g[b].toString(16);w.length<2&&(w="0"+w),y+=w}e.codec=y}break;case 8:a=!0,e.pps=[n.data];break;case 9:a=!0,e.audFound=!0,null!=(u=o)&&u.frame&&(this.pushAccessUnit(o,e),o=null),o||(o=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts));break;case 12:a=!0;break;default:a=!1}o&&a&&o.units.push(n)}),n&&o&&(this.pushAccessUnit(o,e),this.VideoSample=null)}},{key:"getNALuType",value:function(e,t){return 31&e[t]}},{key:"readSliceType",value:function(e){var t=new px(e);return t.readUByte(),t.readUEG(),t.readUEG()}},{key:"skipScalingList",value:function(e,t){for(var i=8,n=8,a=0;a<e;a++)0!==n&&(n=(i+t.readEG()+256)%256),i=0===n?i:n}},{key:"readSPS",value:function(e){var t,i,n,a=new px(e),r=0,o=0,s=0,u=0,l=a.readUByte.bind(a),d=a.readBits.bind(a),h=a.readUEG.bind(a),c=a.readBoolean.bind(a),m=a.skipBits.bind(a),f=a.skipEG.bind(a),v=a.skipUEG.bind(a),p=this.skipScalingList.bind(this);l();var g=l();if(d(5),m(3),l(),v(),100===g||110===g||122===g||244===g||44===g||83===g||86===g||118===g||128===g){var y=h();if(3===y&&m(1),v(),v(),m(1),c())for(i=3!==y?8:12,n=0;n<i;n++)c()&&p(n<6?16:64,a)}v();var b=h();if(0===b)h();else if(1===b)for(m(1),f(),f(),t=h(),n=0;n<t;n++)f();v(),m(1);var w=h(),k=h(),S=d(1);0===S&&m(1),m(1),c()&&(r=h(),o=h(),s=h(),u=h());var E=[1,1];if(c()&&c())switch(l()){case 1:E=[1,1];break;case 2:E=[12,11];break;case 3:E=[10,11];break;case 4:E=[16,11];break;case 5:E=[40,33];break;case 6:E=[24,11];break;case 7:E=[20,11];break;case 8:E=[32,11];break;case 9:E=[80,33];break;case 10:E=[18,11];break;case 11:E=[15,11];break;case 12:E=[64,33];break;case 13:E=[160,99];break;case 14:E=[4,3];break;case 15:E=[3,2];break;case 16:E=[2,1];break;case 255:E=[l()<<8|l(),l()<<8|l()]}return{width:Math.ceil(16*(w+1)-2*r-2*o),height:(2-S)*(k+1)*16-(S?2:4)*(s+u),pixelRatio:E}}}])}(),yx=function(){function e(...t){var i;return u(this,e),(i=s(this,e,[...t])).initVPS=null,i}return y(e,vx),m(e,[{key:"parsePES",value:function(e,t,i,n){var a,r=this.parseNALu(e,i.data,n),o=this.VideoSample,s=!1;i.data=null,o&&r.length&&!e.audFound&&(this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts)),r.forEach(n=>{var r,u;switch(n.type){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:o||(o=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts)),o.frame=!0,a=!0;break;case 16:case 17:case 18:case 21:var l;if(a=!0,s)null!=(l=o)&&l.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null);o||(o=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),o.key=!0,o.frame=!0;break;case 19:case 20:a=!0,null!=(r=o)&&r.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null),o||(o=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),o.key=!0,o.frame=!0;break;case 39:a=!0,tP(n.data,2,i.pts,t.samples);break;case 32:a=!0,e.vps||("object"!=typeof e.params&&(e.params={}),e.params=eT(e.params,this.readVPS(n.data)),this.initVPS=n.data),e.vps=[n.data];break;case 33:if(a=!0,s=!0,void 0===e.vps||e.vps[0]===this.initVPS||void 0===e.sps||this.matchSPS(e.sps[0],n.data)||(this.initVPS=e.vps[0],e.sps=e.pps=void 0),!e.sps){var d=this.readSPS(n.data);for(var h in e.width=d.width,e.height=d.height,e.pixelRatio=d.pixelRatio,e.codec=d.codecString,e.sps=[],"object"!=typeof e.params&&(e.params={}),d.params)e.params[h]=d.params[h]}this.pushParameterSet(e.sps,n.data,e.vps),o||(o=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),o.key=!0;break;case 34:if(a=!0,"object"==typeof e.params){if(!e.pps){e.pps=[];var c=this.readPPS(n.data);for(var m in c)e.params[m]=c[m]}this.pushParameterSet(e.pps,n.data,e.vps)}break;case 35:a=!0,e.audFound=!0,null!=(u=o)&&u.frame&&(this.pushAccessUnit(o,e),o=null),o||(o=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts));break;default:a=!1}o&&a&&o.units.push(n)}),n&&o&&(this.pushAccessUnit(o,e),this.VideoSample=null)}},{key:"pushParameterSet",value:function(e,t,i){(i&&i[0]===this.initVPS||!i&&!e.length)&&e.push(t)}},{key:"getNALuType",value:function(e,t){return(126&e[t])>>>1}},{key:"ebsp2rbsp",value:function(e){for(var t=new Uint8Array(e.byteLength),i=0,n=0;n<e.byteLength;n++)n>=2&&3===e[n]&&0===e[n-1]&&0===e[n-2]||(t[i]=e[n],i++);return new Uint8Array(t.buffer,0,i)}},{key:"pushAccessUnit",value:function(t,i){M(e,"pushAccessUnit",this)([t,i]),this.initVPS&&(this.initVPS=null)}},{key:"readVPS",value:function(e){var t=new px(e);return t.readUByte(),t.readUByte(),t.readBits(4),t.skipBits(2),t.readBits(6),{numTemporalLayers:t.readBits(3)+1,temporalIdNested:t.readBoolean()}}},{key:"readSPS",value:function(e){var t=new px(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.readBits(4);var i=t.readBits(3);t.readBoolean();for(var n=t.readBits(2),a=t.readBoolean(),r=t.readBits(5),o=t.readUByte(),s=t.readUByte(),u=t.readUByte(),l=t.readUByte(),d=t.readUByte(),h=t.readUByte(),c=t.readUByte(),m=t.readUByte(),f=t.readUByte(),v=t.readUByte(),p=t.readUByte(),g=[],y=[],b=0;b<i;b++)g.push(t.readBoolean()),y.push(t.readBoolean());if(i>0)for(var w=i;w<8;w++)t.readBits(2);for(var k=0;k<i;k++)g[k]&&(t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte()),y[k]&&t.readUByte();t.readUEG();var S=t.readUEG();3==S&&t.skipBits(1);var E=t.readUEG(),T=t.readUEG(),P=t.readBoolean(),M=0,A=0,D=0,x=0;P&&(M+=t.readUEG(),A+=t.readUEG(),D+=t.readUEG(),x+=t.readUEG());for(var C=t.readUEG(),I=t.readUEG(),L=t.readUEG(),_=t.readBoolean()?0:i;_<=i;_++)t.skipUEG(),t.skipUEG(),t.skipUEG();if((t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.readBoolean())&&t.readBoolean())for(var R=0;R<4;R++)for(var F=0;F<(3===R?2:6);F++){if(t.readBoolean()){var O=Math.min(64,1<<4+(R<<1));R>1&&t.readEG();for(var W=0;W<O;W++)t.readEG()}else t.readUEG()}t.readBoolean(),t.readBoolean(),t.readBoolean()&&(t.readUByte(),t.skipUEG(),t.skipUEG(),t.readBoolean());for(var $=t.readUEG(),N=0,j=0;j<$;j++){var B=!1;if(0!==j&&(B=t.readBoolean()),B){j===$&&t.readUEG(),t.readBoolean(),t.readUEG();for(var z=0,U=0;U<=N;U++){var H=t.readBoolean(),G=!1;H||(G=t.readBoolean()),(H||G)&&z++}N=z}else{var V=t.readUEG(),K=t.readUEG();N=V+K;for(var X=0;X<V;X++)t.readUEG(),t.readBoolean();for(var Y=0;Y<K;Y++)t.readUEG(),t.readBoolean()}}if(t.readBoolean())for(var q=t.readUEG(),J=0;J<q;J++){for(var Q=0;Q<L+4;Q++)t.readBits(1);t.readBits(1)}var Z=0,ee=1,te=1,ie=!0,ne=1,ae=0;t.readBoolean(),t.readBoolean();if(t.readBoolean()){if(t.readBoolean()){var re=t.readUByte();re>0&&re<16?(ee=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2][re-1],te=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1][re-1]):255===re&&(ee=t.readBits(16),te=t.readBits(16))}if(t.readBoolean()&&t.readBoolean(),t.readBoolean())t.readBits(3),t.readBoolean(),t.readBoolean()&&(t.readUByte(),t.readUByte(),t.readUByte());if(t.readBoolean()&&(t.readUEG(),t.readUEG()),t.readBoolean(),t.readBoolean(),t.readBoolean(),t.readBoolean()&&(t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG()),t.readBoolean())if(ne=t.readBits(32),ae=t.readBits(32),t.readBoolean()&&t.readUEG(),t.readBoolean()){var oe=t.readBoolean(),se=t.readBoolean(),ue=!1;(oe||se)&&((ue=t.readBoolean())&&(t.readUByte(),t.readBits(5),t.readBoolean(),t.readBits(5)),t.readBits(4),t.readBits(4),ue&&t.readBits(4),t.readBits(5),t.readBits(5),t.readBits(5));for(var le=0;le<=i;le++){var de=!1;(ie=t.readBoolean())||t.readBoolean()?t.readEG():de=t.readBoolean();var he=de?1:t.readUEG()+1;if(oe)for(var ce=0;ce<he;ce++)t.readUEG(),t.readUEG(),ue&&(t.readUEG(),t.readUEG()),t.skipBits(1);if(se)for(var me=0;me<he;me++)t.readUEG(),t.readUEG(),ue&&(t.readUEG(),t.readUEG()),t.skipBits(1)}}t.readBoolean()&&(t.readBoolean(),t.readBoolean(),t.readBoolean(),Z=t.readUEG())}var fe=E,ve=T;if(P){var pe=1,ge=1;1===S?pe=ge=2:2==S&&(pe=2),fe=E-pe*A-pe*M,ve=T-ge*x-ge*D}for(var ye=n?["A","B","C"][n]:"",be=o<<24|s<<16|u<<8|l,we=0,ke=0;ke<32;ke++)we=(we|(be>>ke&1)<<31-ke)>>>0;var Se=we.toString(16);return 1===r&&"2"===Se&&(Se="6"),{codecString:`hvc1.${ye}${r}.${Se}.${a?"H":"L"}${p}.B0`,params:{general_tier_flag:a,general_profile_idc:r,general_profile_space:n,general_profile_compatibility_flags:[o,s,u,l],general_constraint_indicator_flags:[d,h,c,m,f,v],general_level_idc:p,bit_depth:C+8,bit_depth_luma_minus8:C,bit_depth_chroma_minus8:I,min_spatial_segmentation_idc:Z,chroma_format_idc:S,frame_rate:{fixed:ie,fps:ae/ne}},width:fe,height:ve,pixelRatio:[ee,te]}}},{key:"readPPS",value:function(e){var t=new px(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.skipUEG(),t.skipUEG(),t.skipBits(2),t.skipBits(3),t.skipBits(2),t.skipUEG(),t.skipUEG(),t.skipEG(),t.skipBits(2),t.readBoolean()&&t.skipUEG(),t.skipEG(),t.skipEG(),t.skipBits(4);var i=t.readBoolean(),n=t.readBoolean(),a=1;return n&&i?a=0:n?a=3:i&&(a=2),{parallelismType:a}}},{key:"matchSPS",value:function(e,t){return String.fromCharCode.apply(null,e).substr(3)===String.fromCharCode.apply(null,t).substr(3)}}])}(),bx=188,wx=function(){function e(t,i,n,a){u(this,e),this.logger=void 0,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._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=t,this.config=i,this.typeSupported=n,this.logger=a,this.videoParser=null}return m(e,[{key:"resetInitSegment",value:function(t,i,n,a){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=e.createTrack("video"),this._videoTrack.duration=a,this._audioTrack=e.createTrack("audio",a),this._id3Track=e.createTrack("id3"),this._txtTrack=e.createTrack("text"),this._audioTrack.segmentCodec="aac",this.videoParser=null,this.aacOverFlow=null,this.remainderData=null,this.audioCodec=i,this.videoCodec=n}},{key:"resetTimeStamp",value:function(){}},{key:"resetContiguity",value:function(){var e=this._audioTrack,t=this._videoTrack,i=this._id3Track;e&&(e.pesData=null),t&&(t.pesData=null),i&&(i.pesData=null),this.aacOverFlow=null,this.remainderData=null}},{key:"demux",value:function(t,i,n=!1,a=!1){var r;n||(this.sampleAes=null);var o=this._videoTrack,s=this._audioTrack,u=this._id3Track,l=this._txtTrack,d=o.pid,h=o.pesData,c=s.pid,m=u.pid,f=s.pesData,v=u.pesData,p=null,g=this.pmtParsed,y=this._pmtId,b=t.length;if(this.remainderData&&(b=(t=JT(this.remainderData,t)).length,this.remainderData=null),b<bx&&!a)return this.remainderData=t,{audioTrack:s,videoTrack:o,id3Track:u,textTrack:l};var w=Math.max(0,e.syncOffset(t));(b-=(b-w)%bx)<t.byteLength&&!a&&(this.remainderData=new Uint8Array(t.buffer,b,t.buffer.byteLength-b));for(var k=0,S=w;S<b;S+=bx)if(71===t[S]){var E=!!(64&t[S+1]),T=kx(t,S),P=void 0;if((48&t[S+3])>>4>1){if((P=S+5+t[S+4])===S+bx)continue}else P=S+4;switch(T){case d:E&&(h&&(r=Mx(h,this.logger))&&(this.readyVideoParser(o.segmentCodec),null!==this.videoParser&&this.videoParser.parsePES(o,l,r,!1)),h={data:[],size:0}),h&&(h.data.push(t.subarray(P,S+bx)),h.size+=S+bx-P);break;case c:if(E){if(f&&(r=Mx(f,this.logger)))switch(s.segmentCodec){case"aac":this.parseAACPES(s,r);break;case"mp3":this.parseMPEGPES(s,r);break;case"ac3":this.parseAC3PES(s,r)}f={data:[],size:0}}f&&(f.data.push(t.subarray(P,S+bx)),f.size+=S+bx-P);break;case m:E&&(v&&(r=Mx(v,this.logger))&&this.parseID3PES(u,r),v={data:[],size:0}),v&&(v.data.push(t.subarray(P,S+bx)),v.size+=S+bx-P);break;case 0:E&&(P+=t[P]+1),y=this._pmtId=Sx(t,P);break;case y:E&&(P+=t[P]+1);var M=Ex(t,P,this.typeSupported,n,this.observer,this.logger);(d=M.videoPid)>0&&(o.pid=d,o.segmentCodec=M.segmentVideoCodec),(c=M.audioPid)>0&&(s.pid=c,s.segmentCodec=M.segmentAudioCodec),(m=M.id3Pid)>0&&(u.pid=m),null===p||g||(this.logger.warn(`MPEG-TS PMT found at ${S} after unknown PID '${p}'. Backtracking to sync byte @${w} to parse all TS packets.`),p=null,S=w-188),g=this.pmtParsed=!0;break;case 17:case 8191:break;default:p=T}}else k++;k>0&&Tx(this.observer,new Error(`Found ${k} TS packet/s that do not start with 0x47`),void 0,this.logger),o.pesData=h,s.pesData=f,u.pesData=v;var A={audioTrack:s,videoTrack:o,id3Track:u,textTrack:l};return a&&this.extractRemainingSamples(A),A}},{key:"flush",value:function(){var e,t=this.remainderData;return this.remainderData=null,e=t?this.demux(t,-1,!1,!0):{videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(e),this.sampleAes?this.decrypt(e,this.sampleAes):e}},{key:"extractRemainingSamples",value:function(e){var t,i=e.audioTrack,n=e.videoTrack,a=e.id3Track,r=e.textTrack,o=n.pesData,s=i.pesData,u=a.pesData;if(o&&(t=Mx(o,this.logger))?(this.readyVideoParser(n.segmentCodec),null!==this.videoParser&&(this.videoParser.parsePES(n,r,t,!0),n.pesData=null)):n.pesData=o,s&&(t=Mx(s,this.logger))){switch(i.segmentCodec){case"aac":this.parseAACPES(i,t);break;case"mp3":this.parseMPEGPES(i,t);break;case"ac3":this.parseAC3PES(i,t)}i.pesData=null}else null!=s&&s.size&&this.logger.log("last AAC PES packet truncated,might overlap between fragments"),i.pesData=s;u&&(t=Mx(u,this.logger))?(this.parseID3PES(a,t),a.pesData=null):a.pesData=u}},{key:"demuxSampleAes",value:function(e,t,i){var n=this.demux(e,i,!0,!this.config.progressive),a=this.sampleAes=new fx(this.observer,this.config,t);return this.decrypt(n,a)}},{key:"readyVideoParser",value:function(e){null===this.videoParser&&("avc"===e?this.videoParser=new gx:"hevc"===e&&(this.videoParser=new yx))}},{key:"decrypt",value:function(e,t){return new Promise(i=>{var n=e.audioTrack,a=e.videoTrack;n.samples&&"aac"===n.segmentCodec?t.decryptAacSamples(n.samples,0,()=>{a.samples?t.decryptAvcSamples(a.samples,0,0,()=>{i(e)}):i(e)}):a.samples&&t.decryptAvcSamples(a.samples,0,0,()=>{i(e)})})}},{key:"destroy",value:function(){this.observer&&this.observer.removeAllListeners(),this.config=this.logger=this.observer=null,this.aacOverFlow=this.videoParser=this.remainderData=this.sampleAes=null,this._videoTrack=this._audioTrack=this._id3Track=this._txtTrack=void 0}},{key:"parseAACPES",value:function(e,t){var i,n,a,r=0,o=this.aacOverFlow,s=t.data;if(o){this.aacOverFlow=null;var u=o.missing,l=o.sample.unit.byteLength;if(-1===u)s=JT(o.sample.unit,s);else{var d=l-u;o.sample.unit.set(s.subarray(0,u),d),e.samples.push(o.sample),r=o.missing}}for(i=r,n=s.length;i<n-1&&!LD(s,i);i++);if(i!==r){var h,c=i<n-1;if(h=c?`AAC PES did not start with ADTS header,offset:${i}`:"No ADTS header found in AAC PES",Tx(this.observer,new Error(h),c,this.logger),!c)return}if(RD(e,this.observer,s,i,this.audioCodec),void 0!==t.pts)a=t.pts;else{if(!o)return void this.logger.warn("[tsdemuxer]: AAC PES unknown PTS");var m=FD(e.samplerate);a=o.sample.pts+m}for(var f,v=0;i<n;){if(i+=(f=OD(e,s,i,a,v)).length,f.missing){this.aacOverFlow=f;break}for(v++;i<n-1&&!LD(s,i);i++);}}},{key:"parseMPEGPES",value:function(e,t){var i=t.data,n=i.length,a=0,r=0,o=t.pts;if(void 0!==o)for(;r<n;)if(ax(i,r)){var s=tx(e,i,r,o,a);if(!s)break;r+=s.length,a++}else r++;else this.logger.warn("[tsdemuxer]: MPEG PES unknown PTS")}},{key:"parseAC3PES",value:function(e,t){var i=t.data,n=t.pts;if(void 0!==n)for(var a,r=i.length,o=0,s=0;s<r&&(a=lx(e,i,s,n,o++))>0;)s+=a;else this.logger.warn("[tsdemuxer]: AC3 PES unknown PTS")}},{key:"parseID3PES",value:function(e,t){if(void 0!==t.pts){var i=eT({},t,{type:this._videoTrack?VD.emsg:VD.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(i)}else this.logger.warn("[tsdemuxer]: ID3 PES unknown PTS")}}],[{key:"probe",value:function(t,i){var n=e.syncOffset(t);return n>0&&i.warn(`MPEG2-TS detected but first sync word found @ offset ${n}`),-1!==n}},{key:"syncOffset",value:function(e){for(var t=e.length,i=Math.min(940,t-bx)+1,n=0;n<i;){for(var a=!1,r=-1,o=0,s=n;s<t;s+=bx){if(71!==e[s]||t-s!==bx&&71!==e[s+bx]){if(o)return-1;break}if(o++,-1===r&&0!==(r=s)&&(i=Math.min(r+18612,e.length-bx)+1),a||(a=0===kx(e,s)),a&&o>1&&(0===r&&o>2||s+bx>i))return r}n++}return-1}},{key:"createTrack",value:function(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:FT[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===e?t:void 0}}}])}();function kx(e,t){return((31&e[t+1])<<8)+e[t+2]}function Sx(e,t){return(31&e[t+10])<<8|e[t+11]}function Ex(e,t,i,n,a,r){var o={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},s=t+3+((15&e[t+1])<<8|e[t+2])-4;for(t+=12+((15&e[t+10])<<8|e[t+11]);t<s;){var u=kx(e,t),l=(15&e[t+3])<<8|e[t+4];switch(e[t]){case 207:if(!n){Px("ADTS AAC",r);break}case 15:-1===o.audioPid&&(o.audioPid=u);break;case 21:-1===o.id3Pid&&(o.id3Pid=u);break;case 219:if(!n){Px("H.264",r);break}case 27:-1===o.videoPid&&(o.videoPid=u);break;case 3:case 4:i.mpeg||i.mp3?-1===o.audioPid&&(o.audioPid=u,o.segmentAudioCodec="mp3"):r.log("MPEG audio found, not supported in this browser");break;case 193:if(!n){Px("AC-3",r);break}case 129:i.ac3?-1===o.audioPid&&(o.audioPid=u,o.segmentAudioCodec="ac3"):r.log("AC-3 audio found, not supported in this browser");break;case 6:if(-1===o.audioPid&&l>0)for(var d=t+5,h=l;h>2;){if(106===e[d])!0!==i.ac3?r.log("AC-3 audio found, not supported in this browser for now"):(o.audioPid=u,o.segmentAudioCodec="ac3");var c=e[d+1]+2;d+=c,h-=c}break;case 194:case 135:return Tx(a,new Error("Unsupported EC-3 in M2TS found"),void 0,r),o;case 36:-1===o.videoPid&&(o.videoPid=u,o.segmentVideoCodec="hevc",r.log("HEVC in M2TS found"))}t+=l+5}return o}function Tx(e,t,i,n){n.warn(`parsing error: ${t.message}`),e.emit(UE.ERROR,UE.ERROR,{type:BE.MEDIA_ERROR,details:zE.FRAG_PARSING_ERROR,fatal:!1,levelRetry:i,error:t,reason:t.message})}function Px(e,t){t.log(`${e} with AES-128-CBC encryption found in unencrypted stream`)}function Mx(e,t){var i,n,a,r,o,s=0,u=e.data;if(!e||0===e.size)return null;for(;u[0].length<19&&u.length>1;)u[0]=JT(u[0],u[1]),u.splice(1,1);if(1===((i=u[0])[0]<<16)+(i[1]<<8)+i[2]){if((n=(i[4]<<8)+i[5])&&n>e.size-6)return null;var l=i[7];192&l&&(r=536870912*(14&i[9])+4194304*(255&i[10])+16384*(254&i[11])+128*(255&i[12])+(254&i[13])/2,64&l?r-(o=536870912*(14&i[14])+4194304*(255&i[15])+16384*(254&i[16])+128*(255&i[17])+(254&i[18])/2)>54e5&&(t.warn(`${Math.round((r-o)/9e4)}s delta between PTS and DTS, align them`),r=o):o=r);var d=(a=i[8])+9;if(e.size<=d)return null;e.size-=d;for(var h=new Uint8Array(e.size),c=0,m=u.length;c<m;c++){var f=(i=u[c]).byteLength;if(d){if(d>f){d-=f;continue}i=i.subarray(d),f-=d,d=0}h.set(i,s),s+=f}return n&&(n-=a+3),{data:h,pts:r,dts:o,len:n}}return null}var Ax=function(){return m(function e(){u(this,e)},null,[{key:"getSilentFrame",value:function(e,t){if("mp4a.40.2"===e){if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===t)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(6===t)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])}else{if(1===t)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(2===t)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(3===t)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])}}}])}(),Dx=Math.pow(2,32)-1,xx=function(){function e(){u(this,e)}return m(e,null,[{key:"init",value:function(){var t;for(t in e.types={avc1:[],avcC:[],hvc1:[],hvcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],dac3:[],"ac-3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},e.types)e.types.hasOwnProperty(t)&&(e.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);var i=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]),n=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]);e.HDLR_TYPES={video:i,audio:n};var a=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),r=new Uint8Array([0,0,0,0,0,0,0,0]);e.STTS=e.STSC=e.STCO=r,e.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),e.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),e.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),e.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var o=new Uint8Array([105,115,111,109]),s=new Uint8Array([97,118,99,49]),u=new Uint8Array([0,0,0,1]);e.FTYP=e.box(e.types.ftyp,o,u,o,s),e.DINF=e.box(e.types.dinf,e.box(e.types.dref,a))}},{key:"box",value:function(e,...t){for(var i=8,n=t.length,a=n;n--;)i+=t[n].byteLength;var r=new Uint8Array(i);for(r[0]=i>>24&255,r[1]=i>>16&255,r[2]=i>>8&255,r[3]=255&i,r.set(e,4),n=0,i=8;n<a;n++)r.set(t[n],i),i+=t[n].byteLength;return r}},{key:"hdlr",value:function(t){return e.box(e.types.hdlr,e.HDLR_TYPES[t])}},{key:"mdat",value:function(t){return e.box(e.types.mdat,t)}},{key:"mdhd",value:function(t,i){i*=t;var n=Math.floor(i/(Dx+1)),a=Math.floor(i%(Dx+1));return e.box(e.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,255&t,n>>24,n>>16&255,n>>8&255,255&n,a>>24,a>>16&255,a>>8&255,255&a,85,196,0,0]))}},{key:"mdia",value:function(t){return e.box(e.types.mdia,e.mdhd(t.timescale||0,t.duration||0),e.hdlr(t.type),e.minf(t))}},{key:"mfhd",value:function(t){return e.box(e.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))}},{key:"minf",value:function(t){return"audio"===t.type?e.box(e.types.minf,e.box(e.types.smhd,e.SMHD),e.DINF,e.stbl(t)):e.box(e.types.minf,e.box(e.types.vmhd,e.VMHD),e.DINF,e.stbl(t))}},{key:"moof",value:function(t,i,n){return e.box(e.types.moof,e.mfhd(t),e.traf(n,i))}},{key:"moov",value:function(t){for(var i=t.length,n=[];i--;)n[i]=e.trak(t[i]);return e.box.apply(null,[e.types.moov,e.mvhd(t[0].timescale||0,t[0].duration||0)].concat(n).concat(e.mvex(t)))}},{key:"mvex",value:function(t){for(var i=t.length,n=[];i--;)n[i]=e.trex(t[i]);return e.box.apply(null,[e.types.mvex,...n])}},{key:"mvhd",value:function(t,i){i*=t;var n=Math.floor(i/(Dx+1)),a=Math.floor(i%(Dx+1)),r=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,255&t,n>>24,n>>16&255,n>>8&255,255&n,a>>24,a>>16&255,a>>8&255,255&a,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 e.box(e.types.mvhd,r)}},{key:"sdtp",value:function(t){var i,n,a=t.samples||[],r=new Uint8Array(4+a.length);for(i=0;i<a.length;i++)n=a[i].flags,r[i+4]=n.dependsOn<<4|n.isDependedOn<<2|n.hasRedundancy;return e.box(e.types.sdtp,r)}},{key:"stbl",value:function(t){return e.box(e.types.stbl,e.stsd(t),e.box(e.types.stts,e.STTS),e.box(e.types.stsc,e.STSC),e.box(e.types.stsz,e.STSZ),e.box(e.types.stco,e.STCO))}},{key:"avc1",value:function(t){var i,n,a,r=[],o=[];for(i=0;i<t.sps.length;i++)a=(n=t.sps[i]).byteLength,r.push(a>>>8&255),r.push(255&a),r=r.concat(Array.prototype.slice.call(n));for(i=0;i<t.pps.length;i++)a=(n=t.pps[i]).byteLength,o.push(a>>>8&255),o.push(255&a),o=o.concat(Array.prototype.slice.call(n));var s=e.box(e.types.avcC,new Uint8Array([1,r[3],r[4],r[5],255,224|t.sps.length].concat(r).concat([t.pps.length]).concat(o))),u=t.width,l=t.height,d=t.pixelRatio[0],h=t.pixelRatio[1];return e.box(e.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,u>>8&255,255&u,l>>8&255,255&l,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]),s,e.box(e.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),e.box(e.types.pasp,new Uint8Array([d>>24,d>>16&255,d>>8&255,255&d,h>>24,h>>16&255,h>>8&255,255&h])))}},{key:"esds",value:function(e){var t=e.config;return new Uint8Array([0,0,0,0,3,25,0,1,0,4,17,64,21,0,0,0,0,0,0,0,0,0,0,0,5,2,...t,6,1,2])}},{key:"audioStsd",value:function(e){var t=e.samplerate||0;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount||0,0,16,0,0,0,0,t>>8&255,255&t,0,0])}},{key:"mp4a",value:function(t){return e.box(e.types.mp4a,e.audioStsd(t),e.box(e.types.esds,e.esds(t)))}},{key:"mp3",value:function(t){return e.box(e.types[".mp3"],e.audioStsd(t))}},{key:"ac3",value:function(t){return e.box(e.types["ac-3"],e.audioStsd(t),e.box(e.types.dac3,t.config))}},{key:"stsd",value:function(t){var i=t.segmentCodec;if("audio"===t.type){if("aac"===i)return e.box(e.types.stsd,e.STSD,e.mp4a(t));if("ac3"===i&&t.config)return e.box(e.types.stsd,e.STSD,e.ac3(t));if("mp3"===i&&"mp3"===t.codec)return e.box(e.types.stsd,e.STSD,e.mp3(t))}else{if(!t.pps||!t.sps)throw new Error("video track missing pps or sps");if("avc"===i)return e.box(e.types.stsd,e.STSD,e.avc1(t));if("hevc"===i&&t.vps)return e.box(e.types.stsd,e.STSD,e.hvc1(t))}throw new Error(`unsupported ${t.type} segment codec (${i}/${t.codec})`)}},{key:"tkhd",value:function(t){var i=t.id,n=(t.duration||0)*(t.timescale||0),a=t.width||0,r=t.height||0,o=Math.floor(n/(Dx+1)),s=Math.floor(n%(Dx+1));return e.box(e.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,i>>24&255,i>>16&255,i>>8&255,255&i,0,0,0,0,o>>24,o>>16&255,o>>8&255,255&o,s>>24,s>>16&255,s>>8&255,255&s,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,a>>8&255,255&a,0,0,r>>8&255,255&r,0,0]))}},{key:"traf",value:function(t,i){var n=e.sdtp(t),a=t.id,r=Math.floor(i/(Dx+1)),o=Math.floor(i%(Dx+1));return e.box(e.types.traf,e.box(e.types.tfhd,new Uint8Array([0,0,0,0,a>>24,a>>16&255,a>>8&255,255&a])),e.box(e.types.tfdt,new Uint8Array([1,0,0,0,r>>24,r>>16&255,r>>8&255,255&r,o>>24,o>>16&255,o>>8&255,255&o])),e.trun(t,n.length+16+20+8+16+8+8),n)}},{key:"trak",value:function(t){return t.duration=t.duration||4294967295,e.box(e.types.trak,e.tkhd(t),e.mdia(t))}},{key:"trex",value:function(t){var i=t.id;return e.box(e.types.trex,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}},{key:"trun",value:function(t,i){var n,a,r,o,s,u,l=t.samples||[],d=l.length,h=12+16*d,c=new Uint8Array(h);for(i+=8+h,c.set(["video"===t.type?1:0,0,15,1,d>>>24&255,d>>>16&255,d>>>8&255,255&d,i>>>24&255,i>>>16&255,i>>>8&255,255&i],0),n=0;n<d;n++)r=(a=l[n]).duration,o=a.size,s=a.flags,u=a.cts,c.set([r>>>24&255,r>>>16&255,r>>>8&255,255&r,o>>>24&255,o>>>16&255,o>>>8&255,255&o,s.isLeading<<2|s.dependsOn,s.isDependedOn<<6|s.hasRedundancy<<4|s.paddingValue<<1|s.isNonSync,61440&s.degradPrio,15&s.degradPrio,u>>>24&255,u>>>16&255,u>>>8&255,255&u],12+16*n);return e.box(e.types.trun,c)}},{key:"initSegment",value:function(t){e.types||e.init();var i=e.moov(t);return JT(e.FTYP,i)}},{key:"hvc1",value:function(t){for(var i=t.params,n=[t.vps,t.sps,t.pps],a=new Uint8Array([1,i.general_profile_space<<6|(i.general_tier_flag?32:0)|i.general_profile_idc,i.general_profile_compatibility_flags[0],i.general_profile_compatibility_flags[1],i.general_profile_compatibility_flags[2],i.general_profile_compatibility_flags[3],i.general_constraint_indicator_flags[0],i.general_constraint_indicator_flags[1],i.general_constraint_indicator_flags[2],i.general_constraint_indicator_flags[3],i.general_constraint_indicator_flags[4],i.general_constraint_indicator_flags[5],i.general_level_idc,240|i.min_spatial_segmentation_idc>>8,255&i.min_spatial_segmentation_idc,252|i.parallelismType,252|i.chroma_format_idc,248|i.bit_depth_luma_minus8,248|i.bit_depth_chroma_minus8,0,parseInt(i.frame_rate.fps),3|i.temporal_id_nested<<2|i.num_temporal_layers<<3|(i.frame_rate.fixed?64:0),n.length]),r=a.length,o=0;o<n.length;o+=1){r+=3;for(var s=0;s<n[o].length;s+=1)r+=2+n[o][s].length}var u=new Uint8Array(r);u.set(a,0),r=a.length;for(var l=n.length-1,d=0;d<n.length;d+=1){u.set(new Uint8Array([32+d|(d===l?128:0),0,n[d].length]),r),r+=3;for(var h=0;h<n[d].length;h+=1)u.set(new Uint8Array([n[d][h].length>>8,255&n[d][h].length]),r),r+=2,u.set(n[d][h],r),r+=n[d][h].length}var c=e.box(e.types.hvcC,u),m=t.width,f=t.height,v=t.pixelRatio[0],p=t.pixelRatio[1];return e.box(e.types.hvc1,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,m>>8&255,255&m,f>>8&255,255&f,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]),c,e.box(e.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),e.box(e.types.pasp,new Uint8Array([v>>24,v>>16&255,v>>8&255,255&v,p>>24,p>>16&255,p>>8&255,255&p])))}}])}();xx.types=void 0,xx.HDLR_TYPES=void 0,xx.STTS=void 0,xx.STSC=void 0,xx.STCO=void 0,xx.STSZ=void 0,xx.VMHD=void 0,xx.SMHD=void 0,xx.STSD=void 0,xx.FTYP=void 0,xx.DINF=void 0;function Cx(e,t,i=1,n=!1){var a=e*t*i;return n?Math.round(a):a}function Ix(e,t=!1){return Cx(e,1e3,1/9e4,t)}function Lx(e){var t=e.baseTime,i=e.timescale;return`${t/i} (${t}/${i}) trackId: ${e.trackId}`}var _x=null,Rx=null;function Fx(e,t,i,n){return{duration:t,size:i,cts:n,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:e?2:1,isNonSync:e?0:1}}}var Ox=function(){function e(t,i,n,a){var r;if(u(this,e),(r=s(this,e,["mp4-remuxer",a])).observer=void 0,r.config=void 0,r.typeSupported=void 0,r.ISGenerated=!1,r._initPTS=null,r._initDTS=null,r.nextVideoTs=null,r.nextAudioTs=null,r.videoSampleDuration=null,r.isAudioContiguous=!1,r.isVideoContiguous=!1,r.videoTrackConfig=void 0,r.observer=t,r.config=i,r.typeSupported=n,r.ISGenerated=!1,null===_x){var o=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);_x=o?parseInt(o[1]):0}if(null===Rx){var l=navigator.userAgent.match(/Safari\/(\d+)/i);Rx=l?parseInt(l[1]):0}return r}return y(e,nT),m(e,[{key:"destroy",value:function(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null}},{key:"resetTimeStamp",value:function(e){var t=this._initPTS;t&&e&&e.trackId===t.trackId&&e.baseTime===t.baseTime&&e.timescale===t.timescale||this.log(`Reset initPTS: ${t?Lx(t):t} > ${e?Lx(e):e}`),this._initPTS=this._initDTS=e}},{key:"resetNextTimestamp",value:function(){this.log("reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}},{key:"resetInitSegment",value:function(){this.log("ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0}},{key:"getVideoStartPts",value:function(e){var t=!1,i=e[0].pts,n=e.reduce((e,n)=>{var a=n.pts,r=a-e;return r<-4294967296&&(t=!0,r=(a=Wx(a,i))-e),r>0?e:a},i);return t&&this.debug("PTS rollover detected"),n}},{key:"remux",value:function(e,t,i,n,a,r,o,s){var u,l,d,h,c,m,f=a,v=a,p=e.pid>-1,g=t.pid>-1,y=t.samples.length,b=e.samples.length>0,w=o&&y>0||y>1;if((!p||b)&&(!g||w)||this.ISGenerated||o){if(this.ISGenerated){var k,S,E,T,P=this.videoTrackConfig;(P&&(t.width!==P.width||t.height!==P.height||(null==(k=t.pixelRatio)?void 0:k[0])!==(null==(S=P.pixelRatio)?void 0:S[0])||(null==(E=t.pixelRatio)?void 0:E[1])!==(null==(T=P.pixelRatio)?void 0:T[1]))||!P&&w||null===this.nextAudioTs&&b)&&this.resetInitSegment()}this.ISGenerated||(d=this.generateIS(e,t,a,r));var M,A=this.isVideoContiguous,D=-1;if(w&&(D=function(e){for(var t=0;t<e.length;t++)if(e[t].key)return t;return-1}(t.samples),!A&&this.config.forceKeyFrameOnDiscontinuity))if(m=!0,D>0){this.warn(`Dropped ${D} out of ${y} video samples due to a missing keyframe`);var x=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(D),t.dropped+=D,M=v+=(t.samples[0].pts-x)/t.inputTimeScale}else-1===D&&(this.warn(`No keyframe found out of ${y} video samples`),m=!1);if(this.ISGenerated){if(b&&w){var C=this.getVideoStartPts(t.samples),I=(Wx(e.samples[0].pts,C)-C)/t.inputTimeScale;f+=Math.max(0,I),v+=Math.max(0,-I)}if(b){if(e.samplerate||(this.warn("regenerate InitSegment as audio detected"),d=this.generateIS(e,t,a,r)),l=this.remuxAudio(e,f,this.isAudioContiguous,r,g||w||s===YE?v:void 0),w){var L=l?l.endPTS-l.startPTS:0;t.inputTimeScale||(this.warn("regenerate InitSegment as video detected"),d=this.generateIS(e,t,a,r)),u=this.remuxVideo(t,v,A,L)}}else w&&(u=this.remuxVideo(t,v,A,0));u&&(u.firstKeyFrame=D,u.independent=-1!==D,u.firstKeyFramePTS=M)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(i.samples.length&&(c=$x(i,a,this._initPTS,this._initDTS)),n.samples.length&&(h=Nx(n,a,this._initPTS))),{audio:l,video:u,initSegment:d,independent:m,text:h,id3:c}}},{key:"computeInitPts",value:function(e,t,i,n){var a=Math.round(i*t),r=Wx(e,a);if(r<a+t)for(this.log(`Adjusting PTS for rollover in timeline near ${(a-r)/t} ${n}`);r<a+t;)r+=8589934592;return r-a}},{key:"generateIS",value:function(e,t,i,n){var a,r,o,s=e.samples,u=t.samples,l=this.typeSupported,d={},h=this._initPTS,c=!h||n,m="audio/mp4",f=-1;if(c&&(a=r=1/0),e.config&&s.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":l.mpeg?(m="audio/mpeg",e.codec=""):l.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3"}d.audio={id:"audio",container:m,codec:e.codec,initSegment:"mp3"===e.segmentCodec&&l.mpeg?new Uint8Array(0):xx.initSegment([e]),metadata:{channelCount:e.channelCount}},c&&(f=e.id,o=e.inputTimeScale,h&&o===h.timescale?c=!1:a=r=this.computeInitPts(s[0].pts,o,i,"audio"))}if(t.sps&&t.pps&&u.length){if(t.timescale=t.inputTimeScale,d.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:xx.initSegment([t]),metadata:{width:t.width,height:t.height}},c)if(f=t.id,o=t.inputTimeScale,h&&o===h.timescale)c=!1;else{var v=this.getVideoStartPts(u),p=Wx(u[0].dts,v),g=this.computeInitPts(p,o,i,"video"),y=this.computeInitPts(v,o,i,"video");r=Math.min(r,g),a=Math.min(a,y)}this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(d).length)return this.ISGenerated=!0,c?(h&&this.warn(`Timestamps at playlist time: ${n?"":"~"}${i} ${a/o} != initPTS: ${h.baseTime/h.timescale} (${h.baseTime}/${h.timescale}) trackId: ${h.trackId}`),this.log(`Found initPTS at playlist time: ${i} offset: ${a/o} (${a}/${o}) trackId: ${f}`),this._initPTS={baseTime:a,timescale:o,trackId:f},this._initDTS={baseTime:r,timescale:o,trackId:f}):a=o=void 0,{tracks:d,initPTS:a,timescale:o,trackId:f}}},{key:"remuxVideo",value:function(e,t,i,n){var a,r,o=e.inputTimeScale,s=e.samples,u=[],l=s.length,d=this._initPTS,h=d.baseTime*o/d.timescale,c=this.nextVideoTs,m=8,f=this.videoSampleDuration,v=Number.POSITIVE_INFINITY,p=Number.NEGATIVE_INFINITY,g=!1;if(!i||null===c){var y=h+t*o,b=s[0].pts-Wx(s[0].dts,s[0].pts);_x&&null!==c&&Math.abs(y-b-(c+h))<15e3?i=!0:c=y-b-h}for(var w=c+h,k=0;k<l;k++){var S=s[k];S.pts=Wx(S.pts,w),S.dts=Wx(S.dts,w),S.dts<s[k>0?k-1:k].dts&&(g=!0)}g&&s.sort(function(e,t){var i=e.dts-t.dts,n=e.pts-t.pts;return i||n}),a=s[0].dts;var E=(r=s[s.length-1].dts)-a,T=E?Math.round(E/(l-1)):f||e.inputTimeScale/30;if(i){var P=a-w,M=P>T,A=P<-1;if((M||A)&&(M?this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${Ix(P,!0)} ms (${P}dts) hole between fragments detected at ${t.toFixed(3)}`):this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${Ix(-P,!0)} ms (${P}dts) overlapping between fragments detected at ${t.toFixed(3)}`),!A||w>=s[0].pts||_x)){a=w;var D=s[0].pts-P;if(M)s[0].dts=a,s[0].pts=D;else for(var x=!0,C=0;C<s.length&&!(s[C].dts>D&&x);C++){var I=s[C].pts;if(s[C].dts-=P,s[C].pts-=P,C<s.length-1){var L=s[C+1].pts;x=L<=s[C].pts==L<=I}}this.log(`Video: Initial PTS/DTS adjusted: ${Ix(D,!0)}/${Ix(a,!0)}, delta: ${Ix(P,!0)} ms`)}}for(var _=0,R=0,F=a=Math.max(0,a),O=0;O<l;O++){for(var W=s[O],$=W.units,N=$.length,j=0,B=0;B<N;B++)j+=$[B].data.length;R+=j,_+=N,W.length=j,W.dts<F?(W.dts=F,F+=T/4|0||1):F=W.dts,v=Math.min(W.pts,v),p=Math.max(W.pts,p)}r=s[l-1].dts;var z,U=R+4*_+8;try{z=new Uint8Array(U)}catch(e){return void this.observer.emit(UE.ERROR,UE.ERROR,{type:BE.MUX_ERROR,details:zE.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:U,reason:`fail allocating video mdat ${U}`})}var H=new DataView(z.buffer);H.setUint32(0,U),z.set(xx.types.mdat,4);for(var G=!1,V=Number.POSITIVE_INFINITY,K=Number.POSITIVE_INFINITY,X=Number.NEGATIVE_INFINITY,Y=Number.NEGATIVE_INFINITY,q=0;q<l;q++){for(var J=s[q],Q=J.units,Z=0,ee=0,te=Q.length;ee<te;ee++){var ie=Q[ee],ne=ie.data,ae=ie.data.byteLength;H.setUint32(m,ae),m+=4,z.set(ne,m),m+=ae,Z+=4+ae}var re=void 0;if(q<l-1)f=s[q+1].dts-J.dts,re=s[q+1].pts-J.pts;else{var oe=this.config,se=q>0?J.dts-s[q-1].dts:T;if(re=q>0?J.pts-s[q-1].pts:T,oe.stretchShortVideoTrack&&null!==this.nextAudioTs){var ue=Math.floor(oe.maxBufferHole*o),le=(n?v+n*o:this.nextAudioTs+h)-J.pts;le>ue?((f=le-se)<0?f=se:G=!0,this.log(`It is approximately ${le/90} ms to the next segment; using duration ${f/90} ms for the last video frame.`)):f=se}else f=se}var de=Math.round(J.pts-J.dts);V=Math.min(V,f),X=Math.max(X,f),K=Math.min(K,re),Y=Math.max(Y,re),u.push(Fx(J.key,f,Z,de))}if(u.length)if(_x){if(_x<70){var he=u[0].flags;he.dependsOn=2,he.isNonSync=0}}else if(Rx&&Y-K<X-V&&T/X<.025&&0===u[0].cts){this.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var ce=a,me=0,fe=u.length;me<fe;me++){var ve=ce+u[me].duration,pe=ce+u[me].cts;if(me<fe-1){var ge=ve+u[me+1].cts;u[me].duration=ge-pe}else u[me].duration=me?u[me-1].duration:T;u[me].cts=0,ce=ve}}var ye=r+(f=G||!f?T:f);this.nextVideoTs=c=ye-h,this.videoSampleDuration=f,this.isVideoContiguous=!0;var be={data1:xx.moof(e.sequenceNumber++,a,eT(e,{samples:u})),data2:z,startPTS:(v-h)/o,endPTS:(p+f-h)/o,startDTS:(a-h)/o,endDTS:c/o,type:"video",hasAudio:!1,hasVideo:!0,nb:u.length,dropped:e.dropped};return e.samples=[],e.dropped=0,be}},{key:"getSamplesPerFrame",value:function(e){switch(e.segmentCodec){case"mp3":return 1152;case"ac3":return 1536;default:return 1024}}},{key:"remuxAudio",value:function(e,t,i,n,a){var r=e.inputTimeScale,o=r/(e.samplerate?e.samplerate:r),s=this.getSamplesPerFrame(e),u=s*o,l=this._initPTS,d="mp3"===e.segmentCodec&&this.typeSupported.mpeg,h=[],c=void 0!==a,m=e.samples,f=d?0:8,v=this.nextAudioTs||-1,p=l.baseTime*r/l.timescale,g=p+t*r;if(this.isAudioContiguous=i=i||m.length&&v>0&&(n&&Math.abs(g-(v+p))<9e3||Math.abs(Wx(m[0].pts,g)-(v+p))<20*u),m.forEach(function(e){e.pts=Wx(e.pts,g)}),!i||v<0){var y=m.length;if(m=m.filter(e=>e.pts>=0),y!==m.length&&this.warn(`Removed ${m.length-y} of ${y} samples (initPTS ${p} / ${r})`),!m.length)return;v=0===a?0:n&&!c?Math.max(0,g-p):m[0].pts-p}if("aac"===e.segmentCodec)for(var b=this.config.maxAudioFramesDrift,w=0,k=v+p;w<m.length;w++){var S=m[w],E=S.pts,T=E-k,P=Math.abs(1e3*T/r);if(T<=-b*u&&c)0===w&&(this.warn(`Audio frame @ ${(E/r).toFixed(3)}s overlaps marker by ${Math.round(1e3*T/r)} ms.`),this.nextAudioTs=v=E-p,k=E);else if(T>=b*u&&P<1e4&&c){var M=Math.round(T/u);for(k=E-M*u;k<0&&M&&u;)M--,k+=u;0===w&&(this.nextAudioTs=v=k-p),this.warn(`Injecting ${M} audio frames @ ${((k-p)/r).toFixed(3)}s due to ${Math.round(1e3*T/r)} ms gap.`);for(var A=0;A<M;A++){var D=Ax.getSilentFrame(e.parsedCodec||e.manifestCodec||e.codec,e.channelCount);D||(this.log("Unable to get silent frame for given audio codec; duplicating last frame instead."),D=S.unit.subarray()),m.splice(w,0,{unit:D,pts:k}),k+=u,w++}}S.pts=k,k+=u}for(var x,C=null,I=null,L=0,_=m.length;_--;)L+=m[_].unit.byteLength;for(var R=0,F=m.length;R<F;R++){var O=m[R],W=O.unit,$=O.pts;if(null!==I){h[R-1].duration=Math.round(($-I)/o)}else{if(i&&"aac"===e.segmentCodec&&($=v+p),C=$,!(L>0))return;L+=f;try{x=new Uint8Array(L)}catch(e){return void this.observer.emit(UE.ERROR,UE.ERROR,{type:BE.MUX_ERROR,details:zE.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:L,reason:`fail allocating audio mdat ${L}`})}d||(new DataView(x.buffer).setUint32(0,L),x.set(xx.types.mdat,4))}x.set(W,f);var N=W.byteLength;f+=N,h.push(Fx(!0,s,N,0)),I=$}var j=h.length;if(j){var B=h[h.length-1];v=I-p,this.nextAudioTs=v+o*B.duration;var z=d?new Uint8Array(0):xx.moof(e.sequenceNumber++,C/o,eT({},e,{samples:h}));e.samples=[];var U=(C-p)/r,H=this.nextAudioTs/r,G={data1:z,data2:x,startPTS:U,endPTS:H,startDTS:U,endDTS:H,type:"audio",hasAudio:!0,hasVideo:!1,nb:j};return this.isAudioContiguous=!0,G}}}])}();function Wx(e,t){var i;if(null===t)return e;for(i=t<e?-8589934592:8589934592;Math.abs(e-t)>4294967296;)e+=i;return e}function $x(e,t,i,n){var a=e.samples.length;if(a){for(var r=e.inputTimeScale,o=0;o<a;o++){var s=e.samples[o];s.pts=Wx(s.pts-i.baseTime*r/i.timescale,t*r)/r,s.dts=Wx(s.dts-n.baseTime*r/n.timescale,t*r)/r}var u=e.samples;return e.samples=[],{samples:u}}}function Nx(e,t,i){var n=e.samples.length;if(n){for(var a=e.inputTimeScale,r=0;r<n;r++){var o=e.samples[r];o.pts=Wx(o.pts-i.baseTime*a/i.timescale,t*a)/a}e.samples.sort((e,t)=>e.pts-t.pts);var s=e.samples;return e.samples=[],{samples:s}}}var jx,Bx=function(){function e(t,i,n,a){var r;return u(this,e),(r=s(this,e,["passthrough-remuxer",a])).emitInitSegment=!1,r.audioCodec=void 0,r.videoCodec=void 0,r.initData=void 0,r.initPTS=null,r.initTracks=void 0,r.lastEndTime=null,r.isVideoContiguous=!1,r}return y(e,nT),m(e,[{key:"destroy",value:function(){}},{key:"resetTimeStamp",value:function(e){this.lastEndTime=null;var t=this.initPTS;t&&e&&t.baseTime===e.baseTime&&t.timescale===e.timescale||(this.initPTS=e)}},{key:"resetNextTimestamp",value:function(){this.isVideoContiguous=!1,this.lastEndTime=null}},{key:"resetInitSegment",value:function(e,t,i,n){this.audioCodec=t,this.videoCodec=i,this.generateInitSegment(e,n),this.emitInitSegment=!0}},{key:"generateInitSegment",value:function(e,t){var i=this.audioCodec,n=this.videoCodec;if(null==e||!e.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var a=this.initData=UT(e),r=a.audio,o=a.video;if(t)!function(e,t){if(e&&t){var i=t.keyId;i&&t.isCommonEncryption&&YT(e,(e,t)=>{var n=e.subarray(8,24);n.some(e=>0!==e)||(lT.log(`[eme] Patching keyId in 'enc${t?"a":"v"}>sinf>>tenc' box: ${mT(n)} -> ${mT(i)}`),e.set(i,8))})}}(e,t);else{var s=r||o;null!=s&&s.encrypted&&this.warn(`Init segment with encrypted track with has no key ("${s.codec}")!`)}r&&(i=Ux(r,PT,this)),o&&(n=Ux(o,MT,this));var u={};r&&o?u.audiovideo={container:"video/mp4",codec:i+","+n,supplemental:o.supplemental,encrypted:o.encrypted,initSegment:e,id:"main"}:r?u.audio={container:"audio/mp4",codec:i,encrypted:r.encrypted,initSegment:e,id:"audio"}:o?u.video={container:"video/mp4",codec:n,supplemental:o.supplemental,encrypted:o.encrypted,initSegment:e,id:"main"}:this.warn("initSegment does not contain moov or trak boxes."),this.initTracks=u}},{key:"remux",value:function(e,t,i,n,a,r){var o,s,u=this.initPTS,l=this.lastEndTime,d={audio:void 0,video:void 0,text:n,id3:i,initSegment:void 0};$E(l)||(l=this.lastEndTime=a||0);var h=t.samples;if(!h.length)return d;var c={initPTS:void 0,timescale:void 0,trackId:void 0},m=this.initData;if(null!=(o=m)&&o.length||(this.generateInitSegment(h),m=this.initData),null==(s=m)||!s.length)return this.warn("Failed to generate initSegment."),d;this.emitInitSegment&&(c.tracks=this.initTracks,this.emitInitSegment=!1);var f=function(e,t,i){for(var n={},a=BT(e,["moof","traf"]),r=0;r<a.length;r++){var o=a[r],s=BT(o,["tfhd"])[0],u=$T(s,4),l=t[u];if(l){n[u]||(n[u]={start:NaN,duration:0,sampleCount:0,timescale:l.timescale,type:l.type});var d=n[u],h=BT(o,["tfdt"])[0];if(h){var c=h[0],m=$T(h,4);1===c&&(m===_T?i.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"):(m*=_T+1,m+=$T(h,8))),$E(m)&&(!$E(d.start)||m<d.start)&&(d.start=m)}var f=l.default,v=$T(s,0)|(null==f?void 0:f.flags),p=(null==f?void 0:f.duration)||0;8&v&&(p=$T(s,2&v?12:8));for(var g=BT(o,["trun"]),y=d.start||0,b=0,w=p,k=0;k<g.length;k++){var S=g[k],E=$T(S,4),T=d.sampleCount;d.sampleCount+=E;var P=1&S[3],M=4&S[3],A=1&S[2],D=2&S[2],x=4&S[2],C=8&S[2],I=8,L=E;for(P&&(I+=4),M&&E&&(1&S[I+1]||void 0!==d.keyFrameIndex||(d.keyFrameIndex=T),I+=4,A?(w=$T(S,I),I+=4):w=p,D&&(I+=4),C&&(I+=4),y+=w,b+=w,L--);L--;)A?(w=$T(S,I),I+=4):w=p,D&&(I+=4),x&&(1&S[I+1]||void 0===d.keyFrameIndex&&(d.keyFrameIndex=d.sampleCount-(L+1),d.keyFrameStart=y),I+=4),C&&(I+=4),y+=w,b+=w;!b&&p&&(b+=p*E)}d.duration+=b}}if(!Object.keys(n).some(e=>n[e].duration)){for(var _=1/0,R=0,F=BT(e,["sidx"]),O=0;O<F.length;O++){var W=zT(F[O]);if(null!=W&&W.references){_=Math.min(_,W.earliestPresentationTime/W.timescale);var $=W.references.reduce((e,t)=>e+t.info.duration||0,0);R=Math.max(R,$+W.earliestPresentationTime/W.timescale)}}R&&$E(R)&&Object.keys(n).forEach(e=>{n[e].duration||(n[e].duration=R*n[e].timescale-n[e].start)})}return n}(h,m,this),v=m.audio?f[m.audio.id]:null,p=m.video?f[m.video.id]:null,g=zx(p,1/0),y=zx(v,1/0),b=zx(p,0,!0),w=zx(v,0,!0),k=a,S=0,E=v&&(!p||!u&&y<g||u&&u.trackId===m.audio.id),T=E?v:p;if(T){var P=T.timescale,M=T.start-a*P,A=E?m.audio.id:m.video.id;k=T.start/P,S=E?w-y:b-g,!r&&u||!function(e,t,i,n){if(null===e)return!0;var a=Math.max(n,1),r=t-e.baseTime/e.timescale;return Math.abs(r-i)>a}(u,k,a,S)&&P===u.timescale||(u&&this.warn(`Timestamps at playlist time: ${r?"":"~"}${a} ${M/P} != initPTS: ${u.baseTime/u.timescale} (${u.baseTime}/${u.timescale}) trackId: ${u.trackId}`),this.log(`Found initPTS at playlist time: ${a} offset: ${k-a} (${M}/${P}) trackId: ${A}`),u=null,c.initPTS=M,c.timescale=P,c.trackId=A)}else this.warn(`No audio or video samples found for initPTS at playlist time: ${a}`);u?(c.initPTS=u.baseTime,c.timescale=u.timescale,c.trackId=u.trackId):(c.timescale&&void 0!==c.trackId&&void 0!==c.initPTS||(this.warn("Could not set initPTS"),c.initPTS=k,c.timescale=1,c.trackId=-1),this.initPTS=u={baseTime:c.initPTS,timescale:c.timescale,trackId:c.trackId});var D=k-u.baseTime/u.timescale,x=D+S;S>0?this.lastEndTime=x:(this.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var C=!!m.audio,I=!!m.video,L="";C&&(L+="audio"),I&&(L+="video");var _={data1:h,startPTS:D,startDTS:D,endPTS:x,endDTS:x,type:L,hasAudio:C,hasVideo:I,nb:1,dropped:0,encrypted:!!m.audio&&m.audio.encrypted||!!m.video&&m.video.encrypted};d.audio=C&&!I?_:void 0,d.video=I?_:void 0;var R=null==p?void 0:p.sampleCount;if(R){var F=p.keyFrameIndex,O=-1!==F;_.nb=R,_.dropped=0===F||this.isVideoContiguous?0:O?F:R,_.independent=O,_.firstKeyFrame=F,O&&p.keyFrameStart&&(_.firstKeyFramePTS=(p.keyFrameStart-u.baseTime)/u.timescale),this.isVideoContiguous||(d.independent=O),this.isVideoContiguous||(this.isVideoContiguous=O),_.dropped&&this.warn(`fmp4 does not start with IDR: firstIDR ${F}/${R} dropped: ${_.dropped} start: ${_.firstKeyFramePTS||"NA"}`)}return d.initSegment=c,d.id3=$x(i,a,u,u),n.samples.length&&(d.text=Nx(n,a,u)),d}}])}();function zx(e,t,i=!1){return void 0!==(null==e?void 0:e.start)?(e.start+(i?e.duration:0))/e.timescale:t}function Ux(e,t,i){var n=e.codec;if(n&&n.length>4)return n;if(t===PT){if("ec-3"===n||"ac-3"===n||"alac"===n)return n;if("fLaC"===n||"Opus"===n){return vP(n,!1)}return i.warn(`Unhandled audio codec "${n}" in mp4 MAP`),n||"mp4a"}return i.warn(`Unhandled video codec "${n}" in mp4 MAP`),n||"avc1"}try{jx=self.performance.now.bind(self.performance)}catch(e){jx=Date.now}var Hx=[{demux:cx,remux:Bx},{demux:wx,remux:Ox},{demux:ox,remux:Ox},{demux:dx,remux:Ox}];Hx.splice(2,0,{demux:ux,remux:Ox});var Gx=function(){return m(function e(t,i,n,a,r,o){u(this,e),this.asyncResult=!1,this.logger=void 0,this.observer=void 0,this.typeSupported=void 0,this.config=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=i,this.config=n,this.id=r,this.logger=o},[{key:"configure",value:function(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}},{key:"push",value:function(e,t,i,n){var a=i.transmuxing;a.executeStart=jx();var r=new Uint8Array(e),o=this.currentTransmuxState,s=this.transmuxConfig;n&&(this.currentTransmuxState=n);var u=n||o,l=u.contiguous,d=u.discontinuity,h=u.trackSwitch,c=u.accurateTimeOffset,m=u.timeOffset,f=u.initSegmentChange,v=s.audioCodec,p=s.videoCodec,g=s.defaultInitPts,y=s.duration,b=s.initSegmentData,w=function(e,t){var i=null;e.byteLength>0&&null!=(null==t?void 0:t.key)&&null!==t.iv&&null!=t.method&&(i=t);return i}(r,t);if(w&&ZM(w.method)){var k=this.getDecrypter(),S=eA(w.method);if(!k.isSync())return this.asyncResult=!0,this.decryptionPromise=k.webCryptoDecrypt(r,w.key.buffer,w.iv.buffer,S).then(e=>{var t=this.push(e,null,i);return this.decryptionPromise=null,t}),this.decryptionPromise;var E=k.softwareDecrypt(r,w.key.buffer,w.iv.buffer,S);if(i.part>-1){var T=k.flush();E=T?T.buffer:T}if(!E)return a.executeEnd=jx(),Vx(i);r=new Uint8Array(E)}var P=this.needsProbing(d,h);if(P){var M=this.configureTransmuxer(r);if(M)return this.logger.warn(`[transmuxer] ${M.message}`),this.observer.emit(UE.ERROR,UE.ERROR,{type:BE.MEDIA_ERROR,details:zE.FRAG_PARSING_ERROR,fatal:!1,error:M,reason:M.message}),a.executeEnd=jx(),Vx(i)}(d||h||f||P)&&this.resetInitSegment(b,v,p,y,t),(d||f||P)&&this.resetInitialTimestamp(g),l||this.resetContiguity();var A=this.transmux(r,w,m,c,i);this.asyncResult=Kx(A);var D=this.currentTransmuxState;return D.contiguous=!0,D.discontinuity=!1,D.trackSwitch=!1,a.executeEnd=jx(),A}},{key:"flush",value:function(e){var t=e.transmuxing;t.executeStart=jx();var i=this.decrypter,n=this.currentTransmuxState,a=this.decryptionPromise;if(a)return this.asyncResult=!0,a.then(()=>this.flush(e));var r=[],o=n.timeOffset;if(i){var s=i.flush();s&&r.push(this.push(s.buffer,null,e))}var u=this.demuxer,l=this.remuxer;if(!u||!l){t.executeEnd=jx();var d=[Vx(e)];return this.asyncResult?Promise.resolve(d):d}var h=u.flush(o);return Kx(h)?(this.asyncResult=!0,h.then(t=>(this.flushRemux(r,t,e),r))):(this.flushRemux(r,h,e),this.asyncResult?Promise.resolve(r):r)}},{key:"flushRemux",value:function(e,t,i){var n=t.audioTrack,a=t.videoTrack,r=t.id3Track,o=t.textTrack,s=this.currentTransmuxState,u=s.accurateTimeOffset,l=s.timeOffset;this.logger.log(`[transmuxer.ts]: Flushed ${this.id} sn: ${i.sn}${i.part>-1?" part: "+i.part:""} of ${this.id===XE?"level":"track"} ${i.level}`);var d=this.remuxer.remux(n,a,r,o,l,u,!0,this.id);e.push({remuxResult:d,chunkMeta:i}),i.transmuxing.executeEnd=jx()}},{key:"resetInitialTimestamp",value:function(e){var t=this.demuxer,i=this.remuxer;t&&i&&(t.resetTimeStamp(e),i.resetTimeStamp(e))}},{key:"resetContiguity",value:function(){var e=this.demuxer,t=this.remuxer;e&&t&&(e.resetContiguity(),t.resetNextTimestamp())}},{key:"resetInitSegment",value:function(e,t,i,n,a){var r=this.demuxer,o=this.remuxer;r&&o&&(r.resetInitSegment(e,t,i,n),o.resetInitSegment(e,t,i,a))}},{key:"destroy",value:function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}},{key:"transmux",value:function(e,t,i,n,a){return t&&"SAMPLE-AES"===t.method?this.transmuxSampleAes(e,t,i,n,a):this.transmuxUnencrypted(e,i,n,a)}},{key:"transmuxUnencrypted",value:function(e,t,i,n){var a=this.demuxer.demux(e,t,!1,!this.config.progressive),r=a.audioTrack,o=a.videoTrack,s=a.id3Track,u=a.textTrack;return{remuxResult:this.remuxer.remux(r,o,s,u,t,i,!1,this.id),chunkMeta:n}}},{key:"transmuxSampleAes",value:function(e,t,i,n,a){return this.demuxer.demuxSampleAes(e,t,i).then(e=>({remuxResult:this.remuxer.remux(e.audioTrack,e.videoTrack,e.id3Track,e.textTrack,i,n,!1,this.id),chunkMeta:a}))}},{key:"configureTransmuxer",value:function(e){for(var t,i=this.config,n=this.observer,a=this.typeSupported,r=0,o=Hx.length;r<o;r++){var s;if(null!=(s=Hx[r].demux)&&s.probe(e,this.logger)){t=Hx[r];break}}if(!t)return new Error("Failed to find demuxer by probing fragment data");var u=this.demuxer,l=this.remuxer,d=t.remux,h=t.demux;l&&l instanceof d||(this.remuxer=new d(n,i,a,this.logger)),u&&u instanceof h||(this.demuxer=new h(n,i,a,this.logger),this.probe=h.probe)}},{key:"needsProbing",value:function(e,t){return!this.demuxer||!this.remuxer||e||t}},{key:"getDecrypter",value:function(){var e=this.decrypter;return e||(e=this.decrypter=new xM(this.config)),e}}])}();var Vx=e=>({remuxResult:{},chunkMeta:e});function Kx(e){return"then"in e&&e.then instanceof Function}var Xx=m(function e(t,i,n,a,r){u(this,e),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=i,this.initSegmentData=n,this.duration=a,this.defaultInitPts=r||null}),Yx=m(function e(t,i,n,a,r,o){u(this,e),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=i,this.accurateTimeOffset=n,this.trackSwitch=a,this.timeOffset=r,this.initSegmentChange=o}),qx=0,Jx=function(){return m(function e(t,i,n,a){u(this,e),this.error=null,this.hls=void 0,this.id=void 0,this.instanceNo=qx++,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.onWorkerMessage=e=>{var t=e.data,i=this.hls;if(i&&null!=t&&t.event&&t.instanceNo===this.instanceNo)switch(t.event){case"init":var n,a=null==(n=this.workerContext)?void 0:n.objectURL;a&&self.URL.revokeObjectURL(a);break;case"transmuxComplete":this.handleTransmuxComplete(t.data);break;case"flush":this.onFlush(t.data);break;case"workerLog":i.logger[t.data.logType]&&i.logger[t.data.logType](t.data.message);break;default:t.data=t.data||{},t.data.frag=this.frag,t.data.part=this.part,t.data.id=this.id,i.trigger(t.event,t.data)}},this.onWorkerError=e=>{if(this.hls){var t=new Error(`${e.message} (${e.filename}:${e.lineno})`);this.hls.config.enableWorker=!1,this.hls.logger.warn(`Error in "${this.id}" Web Worker, fallback to inline`),this.hls.trigger(UE.ERROR,{type:BE.OTHER_ERROR,details:zE.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:t})}};var r=t.config;this.hls=t,this.id=i,this.useWorker=!!r.enableWorker,this.onTransmuxComplete=n,this.onFlush=a;var o=(e,t)=>{(t=t||{}).frag=this.frag||void 0,e===UE.ERROR&&(t.parent=this.id,t.part=this.part,this.error=t.error),this.hls.trigger(e,t)};this.observer=new SD,this.observer.on(UE.FRAG_DECRYPTED,o),this.observer.on(UE.ERROR,o);var s=bP(r.preferManagedMediaSource);if(this.useWorker&&"undefined"!=typeof Worker){var l=this.hls.logger;if(r.workerPath||"function"==typeof __HLS_WORKER_BUNDLE__){try{r.workerPath?(l.log(`loading Web Worker ${r.workerPath} for "${i}"`),this.workerContext=function(e){var t=TD[e];if(t)return t.clientCount++,t;var i=new self.URL(e,self.location.href).href,n={worker:new self.Worker(i),scriptURL:i,clientCount:1};return TD[e]=n,n}(r.workerPath)):(l.log(`injecting Web Worker for "${i}"`),this.workerContext=function(){var e=TD[ED];if(e)return e.clientCount++,e;var t=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),i=self.URL.createObjectURL(t),n={worker:new self.Worker(i),objectURL:i,clientCount:1};return TD[ED]=n,n}());var d=this.workerContext.worker;d.addEventListener("message",this.onWorkerMessage),d.addEventListener("error",this.onWorkerError),d.postMessage({instanceNo:this.instanceNo,cmd:"init",typeSupported:s,id:i,config:WP(r)})}catch(e){l.warn(`Error setting up "${i}" Web Worker, fallback to inline`,e),this.terminateWorker(),this.error=null,this.transmuxer=new Gx(this.observer,s,r,"",i,t.logger)}return}}this.transmuxer=new Gx(this.observer,s,r,"",i,t.logger)},[{key:"reset",value:function(){if(this.frag=null,this.part=null,this.workerContext){var e=this.instanceNo;this.instanceNo=qx++;var t=this.hls.config,i=bP(t.preferManagedMediaSource);this.workerContext.worker.postMessage({instanceNo:this.instanceNo,cmd:"reset",resetNo:e,typeSupported:i,id:this.id,config:WP(t)})}}},{key:"terminateWorker",value:function(){if(this.workerContext){var e=this.workerContext.worker;this.workerContext=null,e.removeEventListener("message",this.onWorkerMessage),e.removeEventListener("error",this.onWorkerError),function(e){var t=TD[e||ED];if(t&&1===t.clientCount--){var i=t.worker,n=t.objectURL;delete TD[e||ED],n&&self.URL.revokeObjectURL(n),i.terminate()}}(this.hls.config.workerPath)}}},{key:"destroy",value:function(){if(this.workerContext)this.terminateWorker(),this.onWorkerMessage=this.onWorkerError=null;else{var e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}var t=this.observer;t&&t.removeAllListeners(),this.frag=null,this.part=null,this.observer=null,this.hls=null}},{key:"push",value:function(e,t,i,n,a,r,o,s,u,l){var d,h;u.transmuxing.start=self.performance.now();var c=this.instanceNo,m=this.transmuxer,f=r?r.start:a.start,v=a.decryptdata,p=this.frag,g=!(p&&a.cc===p.cc),y=!(p&&u.level===p.level),b=p?u.sn-p.sn:-1,w=this.part?u.part-this.part.index:-1,k=0===b&&u.id>1&&u.id===(null==p?void 0:p.stats.chunkCount),S=!y&&(1===b||0===b&&(1===w||k&&w<=0)),E=self.performance.now();(y||b||0===a.stats.parsing.start)&&(a.stats.parsing.start=E),!r||!w&&S||(r.stats.parsing.start=E);var T=!(p&&(null==(d=a.initSegment)?void 0:d.url)===(null==(h=p.initSegment)?void 0:h.url)),P=new Yx(g,S,s,y,f,T);if(!S||g||T){this.hls.logger.log(`[transmuxer-interface]: Starting new transmux session for ${a.type} sn: ${u.sn}${u.part>-1?" part: "+u.part:""} ${this.id===XE?"level":"track"}: ${u.level} id: ${u.id}\n discontinuity: ${g}\n trackSwitch: ${y}\n contiguous: ${S}\n accurateTimeOffset: ${s}\n timeOffset: ${f}\n initSegmentChange: ${T}`);var M=new Xx(i,n,t,o,l);this.configureTransmuxer(M)}if(this.frag=a,this.part=r,this.workerContext)this.workerContext.worker.postMessage({instanceNo:c,cmd:"demux",data:e,decryptdata:v,chunkMeta:u,state:P},e instanceof ArrayBuffer?[e]:[]);else if(m){var A=m.push(e,v,u,P);Kx(A)?A.then(e=>{this.handleTransmuxComplete(e)}).catch(e=>{this.transmuxerError(e,u,"transmuxer-interface push error")}):this.handleTransmuxComplete(A)}}},{key:"flush",value:function(e){e.transmuxing.start=self.performance.now();var t=this.instanceNo,i=this.transmuxer;if(this.workerContext)this.workerContext.worker.postMessage({instanceNo:t,cmd:"flush",chunkMeta:e});else if(i){var n=i.flush(e);Kx(n)?n.then(t=>{this.handleFlushResult(t,e)}).catch(t=>{this.transmuxerError(t,e,"transmuxer-interface flush error")}):this.handleFlushResult(n,e)}}},{key:"transmuxerError",value:function(e,t,i){this.hls&&(this.error=e,this.hls.trigger(UE.ERROR,{type:BE.MEDIA_ERROR,details:zE.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,part:this.part||void 0,fatal:!1,error:e,err:e,reason:i}))}},{key:"handleFlushResult",value:function(e,t){e.forEach(e=>{this.handleTransmuxComplete(e)}),this.onFlush(t)}},{key:"configureTransmuxer",value:function(e){var t=this.instanceNo,i=this.transmuxer;this.workerContext?this.workerContext.worker.postMessage({instanceNo:t,cmd:"configure",config:e}):i&&i.configure(e)}},{key:"handleTransmuxComplete",value:function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}}])}(),Qx=function(){function e(t,i,n){var a;return u(this,e),(a=s(this,e,[t,i,n,"audio-stream-controller",YE])).mainAnchor=null,a.mainFragLoading=null,a.audioOnly=!1,a.bufferedTrack=null,a.switchingTrack=null,a.trackId=-1,a.waitingData=null,a.mainDetails=null,a.flushing=!1,a.bufferFlushed=!1,a.cachedTrackLoadedData=null,a.registerListeners(),a}return y(e,pD),m(e,[{key:"onHandlerDestroying",value:function(){this.unregisterListeners(),M(e,"onHandlerDestroying",this)([]),this.resetItem()}},{key:"resetItem",value:function(){this.mainDetails=this.mainAnchor=this.mainFragLoading=this.bufferedTrack=this.switchingTrack=this.waitingData=this.cachedTrackLoadedData=null}},{key:"registerListeners",value:function(){M(e,"registerListeners",this)([]);var t=this.hls;t.on(UE.LEVEL_LOADED,this.onLevelLoaded,this),t.on(UE.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.on(UE.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(UE.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(UE.BUFFER_RESET,this.onBufferReset,this),t.on(UE.BUFFER_CREATED,this.onBufferCreated,this),t.on(UE.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(UE.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(UE.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(UE.FRAG_LOADING,this.onFragLoading,this),t.on(UE.FRAG_BUFFERED,this.onFragBuffered,this)}},{key:"unregisterListeners",value:function(){var t=this.hls;t&&(M(e,"unregisterListeners",this)([]),t.off(UE.LEVEL_LOADED,this.onLevelLoaded,this),t.off(UE.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.off(UE.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(UE.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(UE.BUFFER_RESET,this.onBufferReset,this),t.off(UE.BUFFER_CREATED,this.onBufferCreated,this),t.off(UE.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(UE.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(UE.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(UE.FRAG_LOADING,this.onFragLoading,this),t.off(UE.FRAG_BUFFERED,this.onFragBuffered,this))}},{key:"onInitPtsFound",value:function(e,{frag:t,id:i,initPTS:n,timescale:a,trackId:r}){if(i===XE){var o=t.cc,s=this.fragCurrent;if(this.initPTS[o]={baseTime:n,timescale:a,trackId:r},this.log(`InitPTS for cc: ${o} found from main: ${n/a} (${n}/${a}) trackId: ${r}`),this.mainAnchor=t,this.state===fD){var u=this.waitingData;(!u&&!this.loadingParts||u&&u.frag.cc!==o)&&this.syncWithAnchor(t,null==u?void 0:u.frag)}else!this.hls.hasEnoughToStart&&s&&s.cc!==o?(s.abortRequests(),this.syncWithAnchor(t,s)):this.state===rD&&this.tick()}}},{key:"getLoadPosition",value:function(){return!this.startFragRequested&&this.nextLoadPosition>=0?this.nextLoadPosition:M(e,"getLoadPosition",this)([])}},{key:"syncWithAnchor",value:function(e,t){var i,n=(null==(i=this.mainFragLoading)?void 0:i.frag)||null;if(!t||(null==n?void 0:n.cc)!==t.cc){var a=(n||e).cc,r=JP(this.getLevelDetails(),a,this.getLoadPosition());r&&(this.log(`Syncing with main frag at ${r.start} cc ${r.cc}`),this.startFragRequested=!1,this.nextLoadPosition=r.start,this.resetLoadingState(),this.state===rD&&this.doTickIdle())}}},{key:"startLoad",value:function(e,t){if(!this.levels)return this.startPosition=e,void(this.state=aD);var i=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),i>0&&-1===e?(this.log(`Override startPosition with lastCurrentTime @${i.toFixed(3)}`),e=i,this.state=rD):this.state=lD,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}},{key:"doTick",value:function(){switch(this.state){case rD:this.doTickIdle();break;case lD:var t=this.levels,i=this.trackId,n=null==t?void 0:t[i],a=null==n?void 0:n.details;if(a&&!this.waitForLive(n)){if(this.waitForCdnTuneIn(a))break;this.state=fD}break;case uD:this.checkRetryDate();break;case fD:var r=this.waitingData;if(r){var o=r.frag,s=r.part,u=r.cache,l=r.complete,d=this.mainAnchor;if(void 0!==this.initPTS[o.cc]){this.waitingData=null,this.state=sD;var h={frag:o,part:s,payload:u.flush().buffer,networkDetails:null};this._handleFragmentLoadProgress(h),l&&M(e,"_handleFragmentLoadComplete",this)([h])}else d&&d.cc!==r.frag.cc&&this.syncWithAnchor(d,r.frag)}else this.state=rD}this.onTickEnd()}},{key:"resetLoadingState",value:function(){var t=this.waitingData;t&&(this.fragmentTracker.removeFragment(t.frag),this.waitingData=null),M(e,"resetLoadingState",this)([])}},{key:"onTickEnd",value:function(){var e=this.media;null!=e&&e.readyState&&(this.lastCurrentTime=e.currentTime)}},{key:"doTickIdle",value:function(){var e,t=this.hls,i=this.levels,n=this.media,a=this.trackId,r=t.config;if(this.buffering&&(n||this.primaryPrefetch||!this.startFragRequested&&r.startFragPrefetch)&&null!=i&&i[a]){var o=i[a],s=o.details;if(!s||this.waitForLive(o)||this.waitForCdnTuneIn(s))return this.state=lD,void(this.startFragRequested=!1);var u=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&u&&(this.bufferFlushed=!1,this.afterBufferFlushed(u,PT,YE));var l=this.getFwdBufferInfo(u,YE);if(null!==l){if(!this.switchingTrack&&this._streamEnded(l,s))return t.trigger(UE.BUFFER_EOS,{type:"audio"}),void(this.state=cD);var d=l.len,h=t.maxBufferLength,c=s.fragments,m=c[0].start,f=this.getLoadPosition(),v=this.flushing?f:l.end;if(this.switchingTrack&&n){var p=f;s.PTSKnown&&p<m&&(l.end>m||l.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),n.currentTime=m+.05)}if(!(d>=h&&!this.switchingTrack&&v<c[c.length-1].start)){var g=this.getNextFragment(v,s);if(g&&this.isLoopLoading(g,v)&&(g=this.getNextFragmentLoopLoading(g,s,l,XE,h)),g){if(!this.exceedsMaxBuffer(l,h,g)){var y=(null==(e=this.mainFragLoading)?void 0:e.frag)||null;if(!this.audioOnly&&this.startFragRequested&&y&&xT(g)&&!g.endList&&(!s.live||!this.loadingParts&&v<this.hls.liveSyncPosition)&&(this.fragmentTracker.getState(y)===bM&&(this.mainFragLoading=y=null),y&&xT(y))){if(g.start>y.end){var b=this.fragmentTracker.getFragAtPos(v,XE);b&&b.end>y.end&&(y=b,this.mainFragLoading={frag:b,targetBufferTime:null})}if(g.start>y.end)return}this.loadFragment(g,o,v)}}else this.bufferFlushed=!0}}}}},{key:"onMediaDetaching",value:function(t,i){this.bufferFlushed=this.flushing=!1,M(e,"onMediaDetaching",this)([t,i])}},{key:"onAudioTracksUpdated",value:function(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map(e=>new RP(e))}},{key:"onAudioTrackSwitching",value:function(e,t){var i=!!t.url;this.trackId=t.id;var n=this.fragCurrent;n&&(n.abortRequests(),this.removeUnbufferedFrags(n.start)),this.resetLoadingState(),i?(this.switchingTrack=t,this.flushAudioIfNeeded(t),this.state!==aD&&(this.setInterval(100),this.state=rD,this.tick())):(this.resetTransmuxer(),this.switchingTrack=null,this.bufferedTrack=t,this.clearInterval())}},{key:"onManifestLoading",value:function(){M(e,"onManifestLoading",this)([]),this.bufferFlushed=this.flushing=this.audioOnly=!1,this.resetItem(),this.trackId=-1}},{key:"onLevelLoaded",value:function(e,t){this.mainDetails=t.details;var i=this.cachedTrackLoadedData;i&&(this.cachedTrackLoadedData=null,this.onAudioTrackLoaded(UE.AUDIO_TRACK_LOADED,i))}},{key:"onAudioTrackLoaded",value:function(e,t){var i,n=this.levels,a=t.details,r=t.id,o=t.groupId,s=t.track;if(n){var u=this.mainDetails;if(!u||a.endCC>u.endCC||u.expired)return this.cachedTrackLoadedData=t,void(this.state!==aD&&(this.state=lD));this.cachedTrackLoadedData=null,this.log(`Audio track ${r} "${s.name}" of "${o}" loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""},duration:${a.totalduration}`);var l=n[r],d=0;if(a.live||null!=(i=l.details)&&i.live){if(this.checkLiveUpdate(a),a.deltaUpdateFailed)return;var h;if(l.details)d=this.alignPlaylists(a,l.details,null==(h=this.levelLastLoaded)?void 0:h.details);a.alignedSliding||(ZA(a,u),a.alignedSliding||eD(a,u),d=a.fragmentStart)}l.details=a,this.levelLastLoaded=l,this.startFragRequested||this.setStartPosition(u,d),this.hls.trigger(UE.AUDIO_TRACK_UPDATED,{details:a,id:r,groupId:t.groupId}),this.state!==lD||this.waitForCdnTuneIn(a)||(this.state=rD),this.tick()}else this.warn(`Audio tracks reset while loading track ${r} "${s.name}" of "${o}"`)}},{key:"_handleFragmentLoadProgress",value:function(e){var t,i=e.frag,n=e.part,a=e.payload,r=this.config,o=this.trackId,s=this.levels;if(s){var u=s[o];if(u){var l=u.details;if(!l)return this.warn("Audio track details undefined on fragment load progress"),void this.removeUnbufferedFrags(i.start);var d=r.defaultAudioCodec||u.audioCodec||"mp4a.40.2",h=this.transmuxer;h||(h=this.transmuxer=new Jx(this.hls,YE,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var c=this.initPTS[i.cc],m=null==(t=i.initSegment)?void 0:t.data;if(void 0!==c){var f=n?n.index:-1,v=-1!==f,p=new OM(i.level,i.sn,i.stats.chunkCount,a.byteLength,f,v);h.push(a,m,d,"",i,n,l.totalduration,!1,p,c)}else{this.log(`Unknown video PTS for cc ${i.cc}, waiting for video PTS before demuxing audio frag ${i.sn} of [${l.startSN} ,${l.endSN}],track ${o}`),(this.waitingData=this.waitingData||{frag:i,part:n,cache:new yD,complete:!1}).cache.push(new Uint8Array(a)),this.state!==aD&&(this.state=fD)}}else this.warn("Audio track is undefined on fragment load progress")}else this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`)}},{key:"_handleFragmentLoadComplete",value:function(t){this.waitingData?this.waitingData.complete=!0:M(e,"_handleFragmentLoadComplete",this)([t])}},{key:"onBufferReset",value:function(){this.mediaBuffer=null}},{key:"onBufferCreated",value:function(e,t){this.bufferFlushed=this.flushing=!1;var i=t.tracks.audio;i&&(this.mediaBuffer=i.buffer||null)}},{key:"onFragLoading",value:function(e,t){!this.audioOnly&&t.frag.type===XE&&xT(t.frag)&&(this.mainFragLoading=t,this.state===rD&&this.tick())}},{key:"onFragBuffered",value:function(e,t){var i=t.frag,n=t.part;if(i.type===YE)if(this.fragContextChanged(i))this.warn(`Fragment ${i.sn}${n?" p: "+n.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);else{if(xT(i)){this.fragPrevious=i;var a=this.switchingTrack;a&&(this.bufferedTrack=a,this.switchingTrack=null,this.hls.trigger(UE.AUDIO_TRACK_SWITCHED,iT({},a)))}this.fragBufferedComplete(i,n),this.media&&this.tick()}else this.audioOnly||i.type!==XE||i.elementaryStreams.video||i.elementaryStreams.audiovideo||(this.audioOnly=!0,this.mainFragLoading=null)}},{key:"onError",value:function(t,i){var n;if(i.fatal)this.state=mD;else switch(i.details){case zE.FRAG_GAP:case zE.FRAG_PARSING_ERROR:case zE.FRAG_DECRYPT_ERROR:case zE.FRAG_LOAD_ERROR:case zE.FRAG_LOAD_TIMEOUT:case zE.KEY_LOAD_ERROR:case zE.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(YE,i);break;case zE.AUDIO_TRACK_LOAD_ERROR:case zE.AUDIO_TRACK_LOAD_TIMEOUT:case zE.LEVEL_PARSING_ERROR:i.levelRetry||this.state!==lD||(null==(n=i.context)?void 0:n.type)!==VE||(this.state=rD);break;case zE.BUFFER_ADD_CODEC_ERROR:case zE.BUFFER_APPEND_ERROR:if("audio"!==i.parent)return;this.reduceLengthAndFlushBuffer(i)||this.resetLoadingState();break;case zE.BUFFER_FULL_ERROR:if("audio"!==i.parent)return;this.reduceLengthAndFlushBuffer(i)&&(this.bufferedTrack=null,M(e,"flushMainBuffer",this)([0,Number.POSITIVE_INFINITY,"audio"]));break;case zE.INTERNAL_EXCEPTION:this.recoverWorkerError(i)}}},{key:"onBufferFlushing",value:function(e,{type:t}){t!==MT&&(this.flushing=!0)}},{key:"onBufferFlushed",value:function(e,{type:t}){if(t!==MT){this.flushing=!1,this.bufferFlushed=!0,this.state===cD&&(this.state=rD);var i=this.mediaBuffer||this.media;i&&(this.afterBufferFlushed(i,t,YE),this.tick())}}},{key:"_handleTransmuxComplete",value:function(e){var t,i="audio",n=this.hls,a=e.remuxResult,r=e.chunkMeta,o=this.getCurrentContext(r);if(o){var s=o.frag,u=o.part,l=o.level,d=l.details,h=a.audio,c=a.text,m=a.id3,f=a.initSegment;if(!this.fragContextChanged(s)&&d){if(this.state=dD,this.switchingTrack&&h&&this.completeAudioSwitch(this.switchingTrack),null!=f&&f.tracks){var v=s.initSegment||s;if(this.unhandledEncryptionError(f,s))return;this._bufferInitSegment(l,f.tracks,v,r),n.trigger(UE.FRAG_PARSING_INIT_SEGMENT,{frag:v,id:i,tracks:f.tracks})}if(h){var p=h.startPTS,g=h.endPTS,y=h.startDTS,b=h.endDTS;u&&(u.elementaryStreams[PT]={startPTS:p,endPTS:g,startDTS:y,endDTS:b}),s.setElementaryStreamInfo(PT,p,g,y,b),this.bufferFragmentData(h,s,u,r)}if(null!=m&&null!=(t=m.samples)&&t.length){var w=eT({id:i,frag:s,details:d},m);n.trigger(UE.FRAG_PARSING_METADATA,w)}if(c){var k=eT({id:i,frag:s,details:d},c);n.trigger(UE.FRAG_PARSING_USERDATA,k)}}else this.fragmentTracker.removeFragment(s)}else this.resetWhenMissingContext(r)}},{key:"_bufferInitSegment",value:function(e,t,i,n){if(this.state===dD&&(t.video&&delete t.video,t.audiovideo&&delete t.audiovideo,t.audio)){var a=t.audio;a.id=YE;var r=e.audioCodec;this.log(`Init audio buffer, container:${a.container}, codecs[level/parsed]=[${r}/${a.codec}]`),r&&1===r.split(",").length&&(a.levelCodec=r),this.hls.trigger(UE.BUFFER_CODECS,t);var o=a.initSegment;if(null!=o&&o.byteLength){var s={type:"audio",frag:i,part:null,chunkMeta:n,parent:i.type,data:o};this.hls.trigger(UE.BUFFER_APPENDING,s)}this.tickImmediate()}}},{key:"loadFragment",value:function(t,i,n){var a,r=this.fragmentTracker.getState(t);if(this.switchingTrack||r===pM||r===yM)if(xT(t))if(null!=(a=i.details)&&a.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=fD;var o=this.mainDetails;o&&o.fragmentStart!==i.details.fragmentStart&&eD(i.details,o)}else M(e,"loadFragment",this)([t,i,n]);else this._loadInitSegment(t,i);else this.clearTrackerIfNeeded(t)}},{key:"flushAudioIfNeeded",value:function(t){if(this.media&&this.bufferedTrack){var i=this.bufferedTrack;zP({name:i.name,lang:i.lang,assocLang:i.assocLang,characteristics:i.characteristics,audioCodec:i.audioCodec,channels:i.channels},t,UP)||(GP(t.url,this.hls)?(this.log("Switching audio track : flushing all audio"),M(e,"flushMainBuffer",this)([0,Number.POSITIVE_INFINITY,"audio"]),this.bufferedTrack=null):this.bufferedTrack=t)}}},{key:"completeAudioSwitch",value:function(e){var t=this.hls;this.flushAudioIfNeeded(e),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(UE.AUDIO_TRACK_SWITCHED,iT({},e))}}])}(),Zx=function(){function e(t,i){var n;return u(this,e),(n=s(this,e,[i,t.logger])).hls=void 0,n.canLoad=!1,n.timer=-1,n.hls=t,n}return y(e,nT),m(e,[{key:"destroy",value:function(){this.clearTimer(),this.hls=this.log=this.warn=null}},{key:"clearTimer",value:function(){-1!==this.timer&&(self.clearTimeout(this.timer),this.timer=-1)}},{key:"startLoad",value:function(){this.canLoad=!0,this.loadPlaylist()}},{key:"stopLoad",value:function(){this.canLoad=!1,this.clearTimer()}},{key:"switchParams",value:function(e,t,i){var n=null==t?void 0:t.renditionReports;if(n){for(var a=-1,r=0;r<n.length;r++){var o=n[r],s=void 0;try{s=new self.URL(o.URI,t.url).href}catch(e){this.warn(`Could not construct new URL for Rendition Report: ${e}`),s=o.URI||""}if(s===e){a=r;break}s===e.substring(0,s.length)&&(a=r)}if(-1!==a){var u=n[a],l=parseInt(u["LAST-MSN"])||t.lastPartSn,d=parseInt(u["LAST-PART"])||t.lastPartIndex;if(this.hls.config.lowLatencyMode){var h=Math.min(t.age-t.partTarget,t.targetduration);d>=0&&h>t.partTarget&&(d+=1)}var c=i&&LP(i);return new _P(l,d>=0?d:void 0,c)}}}},{key:"loadPlaylist",value:function(e){this.clearTimer()}},{key:"loadingPlaylist",value:function(e,t){this.clearTimer()}},{key:"shouldLoadPlaylist",value:function(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}},{key:"getUrlWithDirectives",value:function(e,t){if(t)try{return t.addDirectives(e)}catch(e){this.warn(`Could not construct new URL with HLS Delivery Directives: ${e}`)}return e}},{key:"playlistLoaded",value:function(e,t,i){var n=t.details,a=t.stats,r=self.performance.now(),o=a.loading.first?Math.max(0,r-a.loading.first):0;n.advancedDateTime=Date.now()-o;var s=this.hls.config.timelineOffset;if(s!==n.appliedTimelineOffset){var u=Math.max(s||0,0);n.appliedTimelineOffset=u,n.fragments.forEach(e=>{e.setStart(e.playlistOffset+u)})}if(n.live||null!=i&&i.live){var l="levelInfo"in t?t.levelInfo:t.track;if(n.reloaded(i),i&&n.fragments.length>0){NA(i,n,this);var d=n.playlistParsingError;if(d){this.warn(d);var h=this.hls;if(!h.config.ignorePlaylistParsingErrors){var c,m=t.networkDetails;return void h.trigger(UE.ERROR,{type:BE.NETWORK_ERROR,details:zE.LEVEL_PARSING_ERROR,fatal:!1,url:n.url,error:d,reason:d.message,level:t.level||void 0,parent:null==(c=n.fragments[0])?void 0:c.type,networkDetails:m,stats:a})}n.playlistParsingError=null}}-1===n.requestScheduled&&(n.requestScheduled=a.loading.start);var f,v=this.hls.mainForwardBufferInfo,p=v?v.end-v.len:0,g=UA(n,1e3*(n.edge-p));if(n.requestScheduled+g<r?n.requestScheduled=r:n.requestScheduled+=g,this.log(`live playlist ${e} ${n.advanced?"REFRESHED "+n.lastPartSn+"-"+n.lastPartIndex:n.updated?"UPDATED":"MISSED"}`),!this.canLoad||!n.live)return;var y=void 0,b=void 0;if(n.canBlockReload&&n.endSN&&n.advanced){var w=this.hls.config.lowLatencyMode,k=n.lastPartSn,S=n.endSN,E=n.lastPartIndex,T=k===S;-1!==E?T?(y=S+1,b=w?0:E):(y=k,b=w?E+1:n.maxPartIndex):y=S+1;var P=n.age,M=P+n.ageHeader,A=Math.min(M-n.partTarget,1.5*n.targetduration);if(A>0){if(M>3*n.targetduration)this.log(`Playlist last advanced ${P.toFixed(2)}s ago. Omitting segment and part directives.`),y=void 0,b=void 0;else if(null!=i&&i.tuneInGoal&&M-n.partTarget>i.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${i.tuneInGoal} to: ${A} with playlist age: ${n.age}`),A=0;else{var D=Math.floor(A/n.targetduration);if(y+=D,void 0!==b)b+=Math.round(A%n.targetduration/n.partTarget);this.log(`CDN Tune-in age: ${n.ageHeader}s last advanced ${P.toFixed(2)}s goal: ${A} skip sn ${D} to part ${b}`)}n.tuneInGoal=A}if(f=this.getDeliveryDirectives(n,t.deliveryDirectives,y,b),w||!T)return n.requestScheduled=r,void this.loadingPlaylist(l,f)}else(n.canBlockReload||n.canSkipUntil)&&(f=this.getDeliveryDirectives(n,t.deliveryDirectives,y,b));f&&void 0!==y&&n.canBlockReload&&(n.requestScheduled=a.loading.first+Math.max(g-2*o,g/2)),this.scheduleLoading(l,f,n)}else this.clearTimer()}},{key:"scheduleLoading",value:function(e,t,i){var n=i||e.details;if(n){var a=self.performance.now(),r=n.requestScheduled;if(a>=r)this.loadingPlaylist(e,t);else{var o=r-a;this.log(`reload live playlist ${e.name||e.bitrate+"bps"} in ${Math.round(o)} ms`),this.clearTimer(),this.timer=self.setTimeout(()=>this.loadingPlaylist(e,t),o)}}else this.loadingPlaylist(e,t)}},{key:"getDeliveryDirectives",value:function(e,t,i,n){var a=LP(e);return null!=t&&t.skip&&e.deltaUpdateFailed&&(i=t.msn,n=t.part,a=xP),new _P(i,n,a)}},{key:"checkRetry",value:function(e){var t=e.details,i=QP(e),n=e.errorAction,a=n||{},r=a.action,o=a.retryCount,s=void 0===o?0:o,u=a.retryConfig,l=!!n&&!!u&&(r===lM||!n.resolved&&r===sM);if(l){var d;if(s>=u.maxNumRetry)return!1;if(i&&null!=(d=e.context)&&d.deliveryDirectives)this.warn(`Retrying playlist loading ${s+1}/${u.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{var h=iM(u,s);this.clearTimer(),this.timer=self.setTimeout(()=>this.loadPlaylist(),h),this.warn(`Retrying playlist loading ${s+1}/${u.maxNumRetry} after "${t}" in ${h}ms`)}e.levelRetry=!0,n.resolved=!0}return l}}])}();function eC(e,t){if(e.length!==t.length)return!1;for(var i=0;i<e.length;i++)if(!tC(e[i].attrs,t[i].attrs))return!1;return!0}function tC(e,t,i){var n=e["STABLE-RENDITION-ID"];return n&&!i?n===t["STABLE-RENDITION-ID"]:!(i||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).some(i=>e[i]!==t[i])}function iC(e,t){return t.label.toLowerCase()===e.name.toLowerCase()&&(!t.language||t.language.toLowerCase()===(e.lang||"").toLowerCase())}var nC=function(){function e(t){var i;return u(this,e),(i=s(this,e,[t,"audio-track-controller"])).tracks=[],i.groupIds=null,i.tracksInGroup=[],i.trackId=-1,i.currentTrack=null,i.selectDefaultTrack=!0,i.registerListeners(),i}return y(e,Zx),m(e,[{key:"registerListeners",value:function(){var e=this.hls;e.on(UE.MANIFEST_LOADING,this.onManifestLoading,this),e.on(UE.MANIFEST_PARSED,this.onManifestParsed,this),e.on(UE.LEVEL_LOADING,this.onLevelLoading,this),e.on(UE.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(UE.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(UE.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(UE.MANIFEST_LOADING,this.onManifestLoading,this),e.off(UE.MANIFEST_PARSED,this.onManifestParsed,this),e.off(UE.LEVEL_LOADING,this.onLevelLoading,this),e.off(UE.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(UE.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(UE.ERROR,this.onError,this)}},{key:"destroy",value:function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,M(e,"destroy",this)([])}},{key:"onManifestLoading",value:function(){this.tracks=[],this.tracksInGroup=[],this.groupIds=null,this.currentTrack=null,this.trackId=-1,this.selectDefaultTrack=!0}},{key:"onManifestParsed",value:function(e,t){this.tracks=t.audioTracks||[]}},{key:"onAudioTrackLoaded",value:function(e,t){var i=t.id,n=t.groupId,a=t.details,r=this.tracksInGroup[i];if(r&&r.groupId===n){var o=r.details;r.details=t.details,this.log(`Audio track ${i} "${r.name}" lang:${r.lang} group:${n} loaded [${a.startSN}-${a.endSN}]`),i===this.trackId&&this.playlistLoaded(i,t,o)}else this.warn(`Audio track with id:${i} and group:${n} not found in active group ${null==r?void 0:r.groupId}`)}},{key:"onLevelLoading",value:function(e,t){this.switchLevel(t.level)}},{key:"onLevelSwitching",value:function(e,t){this.switchLevel(t.level)}},{key:"switchLevel",value:function(e){var t=this.hls.levels[e];if(t){var i=t.audioGroups||null,n=this.groupIds,a=this.currentTrack;if(!i||(null==n?void 0:n.length)!==(null==i?void 0:i.length)||null!=i&&i.some(e=>-1===(null==n?void 0:n.indexOf(e)))){this.groupIds=i,this.trackId=-1,this.currentTrack=null;var r=this.tracks.filter(e=>!i||-1!==i.indexOf(e.groupId));if(r.length)this.selectDefaultTrack&&!r.some(e=>e.default)&&(this.selectDefaultTrack=!1),r.forEach((e,t)=>{e.id=t});else if(!a&&!this.tracksInGroup.length)return;this.tracksInGroup=r;var o=this.hls.config.audioPreference;if(!a&&o){var s=BP(o,r,UP);if(s>-1)a=r[s];else{var u=BP(o,this.tracks);a=this.tracks[u]}}var l=this.findTrackId(a);-1===l&&a&&(l=this.findTrackId(null));var d={audioTracks:r};this.log(`Updating audio tracks, ${r.length} track(s) found in group(s): ${null==i?void 0:i.join(",")}`),this.hls.trigger(UE.AUDIO_TRACKS_UPDATED,d);var h=this.trackId;if(-1!==l&&-1===h)this.setAudioTrack(l);else if(r.length&&-1===h){var c,m=new Error(`No audio track selected for current audio group-ID(s): ${null==(c=this.groupIds)?void 0:c.join(",")} track count: ${r.length}`);this.warn(m.message),this.hls.trigger(UE.ERROR,{type:BE.MEDIA_ERROR,details:zE.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:m})}}}}},{key:"onError",value:function(e,t){!t.fatal&&t.context&&(t.context.type!==VE||t.context.id!==this.trackId||this.groupIds&&-1===this.groupIds.indexOf(t.context.groupId)||this.checkRetry(t))}},{key:"allAudioTracks",get:function(){return this.tracks}},{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}},{key:"setAudioOption",value:function(e){var t=this.hls;if(t.config.audioPreference=e,e){var i=this.allAudioTracks;if(this.selectDefaultTrack=!1,i.length){var n=this.currentTrack;if(n&&zP(e,n,UP))return n;var a=BP(e,this.tracksInGroup,UP);if(a>-1){var r=this.tracksInGroup[a];return this.setAudioTrack(a),r}if(n){var o=t.loadLevel;-1===o&&(o=t.firstAutoLevel);var s=function(e,t,i,n,a){var r=t[n],o=t.reduce((e,t,i)=>{var n=t.uri;return(e[n]||(e[n]=[])).push(i),e},{})[r.uri];o.length>1&&(n=Math.max.apply(Math,o));var s=r.videoRange,u=r.frameRate,l=r.codecSet.substring(0,4),d=HP(t,n,t=>{if(t.videoRange!==s||t.frameRate!==u||t.codecSet.substring(0,4)!==l)return!1;var n=t.audioGroups,r=i.filter(e=>!n||-1!==n.indexOf(e.groupId));return BP(e,r,a)>-1});return d>-1?d:HP(t,n,t=>{var n=t.audioGroups,r=i.filter(e=>!n||-1!==n.indexOf(e.groupId));return BP(e,r,a)>-1})}(e,t.levels,i,o,UP);if(-1===s)return null;t.nextLoadLevel=s}if(e.channels||e.audioCodec){var u=BP(e,i);if(u>-1)return i[u]}}}return null}},{key:"setAudioTrack",value:function(e){var t=this.tracksInGroup;if(e<0||e>=t.length)this.warn(`Invalid audio track id: ${e}`);else{this.selectDefaultTrack=!1;var i=this.currentTrack,n=t[e],a=n.details&&!n.details.live;if(!(e===this.trackId&&n===i&&a||(this.log(`Switching to audio-track ${e} "${n.name}" lang:${n.lang} group:${n.groupId} channels:${n.channels}`),this.trackId=e,this.currentTrack=n,this.hls.trigger(UE.AUDIO_TRACK_SWITCHING,iT({},n)),a))){var r=this.switchParams(n.url,null==i?void 0:i.details,n.details);this.loadPlaylist(r)}}}},{key:"findTrackId",value:function(e){for(var t=this.tracksInGroup,i=0;i<t.length;i++){var n=t[i];if((!this.selectDefaultTrack||n.default)&&(!e||zP(e,n,UP)))return i}if(e){for(var a=e.name,r=e.lang,o=e.assocLang,s=e.characteristics,u=e.audioCodec,l=e.channels,d=0;d<t.length;d++){if(zP({name:a,lang:r,assocLang:o,characteristics:s,audioCodec:u,channels:l},t[d],UP))return d}for(var h=0;h<t.length;h++){var c=t[h];if(tC(e.attrs,c.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return h}for(var m=0;m<t.length;m++){var f=t[m];if(tC(e.attrs,f.attrs,["LANGUAGE"]))return m}}return-1}},{key:"loadPlaylist",value:function(t){M(e,"loadPlaylist",this)([]);var i=this.currentTrack;this.shouldLoadPlaylist(i)&&GP(i.url,this.hls)&&this.scheduleLoading(i,t)}},{key:"loadingPlaylist",value:function(t,i){M(e,"loadingPlaylist",this)([t,i]);var n=t.id,a=t.groupId,r=this.getUrlWithDirectives(t.url,i),o=t.details,s=null==o?void 0:o.age;this.log(`Loading audio-track ${n} "${t.name}" lang:${t.lang} group:${a}${void 0!==(null==i?void 0:i.msn)?" at sn "+i.msn+" part "+i.part:""}${s&&o.live?" age "+s.toFixed(1)+(o.type&&" "+o.type||""):""} ${r}`),this.hls.trigger(UE.AUDIO_TRACK_LOADING,{url:r,id:n,groupId:a,deliveryDirectives:i||null,track:t})}}])}(),aC=function(){return m(function e(t){u(this,e),this.tracks=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.tracks=t},[{key:"destroy",value:function(){this.tracks=this.queues=null}},{key:"append",value:function(e,t,i){if(null!==this.queues&&null!==this.tracks){var n=this.queues[t];n.push(e),1!==n.length||i||this.executeNext(t)}}},{key:"appendBlocker",value:function(e){return new Promise(t=>{var i={label:"async-blocker",execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};this.append(i,e)})}},{key:"prependBlocker",value:function(e){return new Promise(t=>{if(this.queues){var i={label:"async-blocker-prepend",execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};this.queues[e].unshift(i)}})}},{key:"removeBlockers",value:function(){null!==this.queues&&[this.queues.video,this.queues.audio,this.queues.audiovideo].forEach(e=>{var t,i=null==(t=e[0])?void 0:t.label;"async-blocker"!==i&&"async-blocker-prepend"!==i||(e[0].execute(),e.splice(0,1))})}},{key:"unblockAudio",value:function(e){null!==this.queues&&(this.queues.audio[0]===e&&this.shiftAndExecuteNext("audio"))}},{key:"executeNext",value:function(e){if(null!==this.queues&&null!==this.tracks){var t=this.queues[e];if(t.length){var i=t[0];try{i.execute()}catch(t){var n;if(i.onError(t),null===this.queues||null===this.tracks)return;var a=null==(n=this.tracks[e])?void 0:n.buffer;null!=a&&a.updating||this.shiftAndExecuteNext(e)}}}}},{key:"shiftAndExecuteNext",value:function(e){null!==this.queues&&(this.queues[e].shift(),this.executeNext(e))}},{key:"current",value:function(e){var t;return(null==(t=this.queues)?void 0:t[e][0])||null}},{key:"toString",value:function(){var e=this.queues,t=this.tracks;return null===e||null===t?"<destroyed>":`\n${this.list("video")}\n${this.list("audio")}\n${this.list("audiovideo")}}`}},{key:"list",value:function(e){var t,i;return null!=(t=this.queues)&&t[e]||null!=(i=this.tracks)&&i[e]?`${e}: (${this.listSbInfo(e)}) ${this.listOps(e)}`:""}},{key:"listSbInfo",value:function(e){var t,i=null==(t=this.tracks)?void 0:t[e],n=null==i?void 0:i.buffer;return n?`SourceBuffer${n.updating?" updating":""}${i.ended?" ended":""}${i.ending?" ending":""}`:"none"}},{key:"listOps",value:function(e){var t;return(null==(t=this.queues)?void 0:t[e].map(e=>e.label).join(", "))||""}}])}(),rC=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,oC="HlsJsTrackRemovedError",sC=function(){function e(t){var i;return u(this,e),(i=s(this,e,[t])).name=oC,i}return y(e,D(Error)),m(e)}(),uC=function(){function e(t,i){var n,a;return u(this,e),(n=s(this,e,["buffer-controller",t.logger])).hls=void 0,n.fragmentTracker=void 0,n.details=null,n._objectUrl=null,n.operationQueue=null,n.bufferCodecEventsTotal=0,n.media=null,n.mediaSource=null,n.lastMpegAudioChunk=null,n.blockedAudioAppend=null,n.lastVideoAppendEnd=0,n.appendSource=void 0,n.transferData=void 0,n.overrides=void 0,n.appendErrors={audio:0,video:0,audiovideo:0},n.tracks={},n.sourceBuffers=[[null,null],[null,null]],n._onEndStreaming=e=>{var t;n.hls&&"open"===(null==(t=n.mediaSource)?void 0:t.readyState)&&n.hls.pauseBuffering()},n._onStartStreaming=e=>{n.hls&&n.hls.resumeBuffering()},n._onMediaSourceOpen=e=>{var t=n,i=t.media,a=t.mediaSource;e&&n.log("Media source opened"),i&&a&&(a.removeEventListener("sourceopen",n._onMediaSourceOpen),i.removeEventListener("emptied",n._onMediaEmptied),n.updateDuration(),n.hls.trigger(UE.MEDIA_ATTACHED,{media:i,mediaSource:a}),null!==n.mediaSource&&n.checkPendingTracks())},n._onMediaSourceClose=()=>{n.log("Media source closed")},n._onMediaSourceEnded=()=>{n.log("Media source ended")},n._onMediaEmptied=()=>{var e=n,t=e.mediaSrc,i=e._objectUrl;t!==i&&n.error(`Media element src was set while attaching MediaSource (${i} > ${t})`)},n.hls=t,n.fragmentTracker=i,n.appendSource=(a=dT(t.config.preferManagedMediaSource),"undefined"!=typeof self&&a===self.ManagedMediaSource),n.initTracks(),n.registerListeners(),n}return y(e,nT),m(e,[{key:"hasSourceTypes",value:function(){return Object.keys(this.tracks).length>0}},{key:"destroy",value:function(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.transferData=this.overrides=void 0,this.operationQueue&&(this.operationQueue.destroy(),this.operationQueue=null),this.hls=this.fragmentTracker=null,this._onMediaSourceOpen=this._onMediaSourceClose=null,this._onMediaSourceEnded=null,this._onStartStreaming=this._onEndStreaming=null}},{key:"registerListeners",value:function(){var e=this.hls;e.on(UE.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(UE.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(UE.MANIFEST_LOADING,this.onManifestLoading,this),e.on(UE.MANIFEST_PARSED,this.onManifestParsed,this),e.on(UE.BUFFER_RESET,this.onBufferReset,this),e.on(UE.BUFFER_APPENDING,this.onBufferAppending,this),e.on(UE.BUFFER_CODECS,this.onBufferCodecs,this),e.on(UE.BUFFER_EOS,this.onBufferEos,this),e.on(UE.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(UE.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(UE.FRAG_PARSED,this.onFragParsed,this),e.on(UE.FRAG_CHANGED,this.onFragChanged,this),e.on(UE.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(UE.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(UE.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(UE.MANIFEST_LOADING,this.onManifestLoading,this),e.off(UE.MANIFEST_PARSED,this.onManifestParsed,this),e.off(UE.BUFFER_RESET,this.onBufferReset,this),e.off(UE.BUFFER_APPENDING,this.onBufferAppending,this),e.off(UE.BUFFER_CODECS,this.onBufferCodecs,this),e.off(UE.BUFFER_EOS,this.onBufferEos,this),e.off(UE.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(UE.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(UE.FRAG_PARSED,this.onFragParsed,this),e.off(UE.FRAG_CHANGED,this.onFragChanged,this),e.off(UE.ERROR,this.onError,this)}},{key:"transferMedia",value:function(){var e=this.media,t=this.mediaSource;if(!e)return null;var i={};if(this.operationQueue){var n=this.isUpdating();n||this.operationQueue.removeBlockers();var a=this.isQueued();(n||a)&&this.warn(`Transfering MediaSource with${a?" operations in queue":""}${n?" updating SourceBuffer(s)":""} ${this.operationQueue}`),this.operationQueue.destroy()}var r=this.transferData;return!this.sourceBufferCount&&r&&r.mediaSource===t?eT(i,r.tracks):this.sourceBuffers.forEach(e=>{var t=e[0];t&&(i[t]=eT({},this.tracks[t]),this.removeBuffer(t)),e[0]=e[1]=null}),{media:e,mediaSource:t,tracks:i}}},{key:"initTracks",value:function(){this.sourceBuffers=[[null,null],[null,null]],this.tracks={},this.resetQueue(),this.resetAppendErrors(),this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.lastVideoAppendEnd=0}},{key:"onManifestLoading",value:function(){this.bufferCodecEventsTotal=0,this.details=null}},{key:"onManifestParsed",value:function(e,t){var i,n=2;(t.audio&&!t.video||!t.altAudio)&&(n=1),this.bufferCodecEventsTotal=n,this.log(`${n} bufferCodec event(s) expected.`),null!=(i=this.transferData)&&i.mediaSource&&this.sourceBufferCount&&n&&this.bufferCreated()}},{key:"onMediaAttaching",value:function(e,t){var i=this.media=t.media;this.transferData=this.overrides=void 0;var n=dT(this.appendSource);if(n){var a=!!t.mediaSource;(a||t.overrides)&&(this.transferData=t,this.overrides=t.overrides);var r=this.mediaSource=t.mediaSource||new n;if(this.assignMediaSource(r),a)this._objectUrl=i.src,this.attachTransferred();else{var o=this._objectUrl=self.URL.createObjectURL(r);if(this.appendSource)try{i.removeAttribute("src");var s=self.ManagedMediaSource;i.disableRemotePlayback=i.disableRemotePlayback||s&&r instanceof s,lC(i),function(e,t){var i=self.document.createElement("source");i.type="video/mp4",i.src=t,e.appendChild(i)}(i,o),i.load()}catch(e){i.src=o}else i.src=o}i.addEventListener("emptied",this._onMediaEmptied)}}},{key:"assignMediaSource",value:function(e){var t,i;this.log(`${(null==(t=this.transferData)?void 0:t.mediaSource)===e?"transferred":"created"} media source: ${null==(i=e.constructor)?void 0:i.name}`),e.addEventListener("sourceopen",this._onMediaSourceOpen),e.addEventListener("sourceended",this._onMediaSourceEnded),e.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(e.addEventListener("startstreaming",this._onStartStreaming),e.addEventListener("endstreaming",this._onEndStreaming))}},{key:"attachTransferred",value:function(){var e=this.media,t=this.transferData;if(t&&e){var i=this.tracks,n=t.tracks,a=n?Object.keys(n):null,r=a?a.length:0,o=()=>{Promise.resolve().then(()=>{this.media&&this.mediaSourceOpenOrEnded&&this._onMediaSourceOpen()})};if(n&&a&&r){if(!this.tracksReady)return this.hls.config.startFragPrefetch=!0,void this.log("attachTransferred: waiting for SourceBuffer track info");if(this.log(`attachTransferred: (bufferCodecEventsTotal ${this.bufferCodecEventsTotal})\nrequired tracks: ${WP(i,(e,t)=>"initSegment"===e?void 0:t)};\ntransfer tracks: ${WP(n,(e,t)=>"initSegment"===e?void 0:t)}}`),!hT(n,i)){t.mediaSource=null,t.tracks=void 0;var s=e.currentTime,u=this.details,l=Math.max(s,(null==u?void 0:u.fragments[0].start)||0);return l-s>1?void this.log(`attachTransferred: waiting for playback to reach new tracks start time ${s} -> ${l}`):(this.warn(`attachTransferred: resetting MediaSource for incompatible tracks ("${Object.keys(n)}"->"${Object.keys(i)}") start time: ${l} currentTime: ${s}`),this.onMediaDetaching(UE.MEDIA_DETACHING,{}),this.onMediaAttaching(UE.MEDIA_ATTACHING,t),void(e.currentTime=l))}this.transferData=void 0,a.forEach(e=>{var t=e,i=n[t];if(i){var a=i.buffer;if(a){var r=this.fragmentTracker,o=i.id;if(r.hasFragments(o)||r.hasParts(o)){var s=$M.getBuffered(a);r.detectEvictedFragments(t,s,o,null,!0)}var u=dC(t),l=[t,a];this.sourceBuffers[u]=l,a.updating&&this.operationQueue&&this.operationQueue.prependBlocker(t),this.trackSourceBuffer(t,i)}}}),o(),this.bufferCreated()}else this.log("attachTransferred: MediaSource w/o SourceBuffers"),o()}}},{key:"mediaSourceOpenOrEnded",get:function(){var e,t=null==(e=this.mediaSource)?void 0:e.readyState;return"open"===t||"ended"===t}},{key:"onMediaDetaching",value:function(e,t){var i=!!t.transferMedia;this.transferData=this.overrides=void 0;var n=this.media,a=this.mediaSource,r=this._objectUrl;if(a){if(this.log("media source "+(i?"transferring":"detaching")),i)this.sourceBuffers.forEach(([e])=>{e&&this.removeBuffer(e)}),this.resetQueue();else{if(this.mediaSourceOpenOrEnded){var o="open"===a.readyState;try{for(var s=a.sourceBuffers,u=s.length;u--;)o&&s[u].abort(),a.removeSourceBuffer(s[u]);o&&a.endOfStream()}catch(e){this.warn(`onMediaDetaching: ${e.message} while calling endOfStream`)}}this.sourceBufferCount&&this.onBufferReset()}a.removeEventListener("sourceopen",this._onMediaSourceOpen),a.removeEventListener("sourceended",this._onMediaSourceEnded),a.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(a.removeEventListener("startstreaming",this._onStartStreaming),a.removeEventListener("endstreaming",this._onEndStreaming)),this.mediaSource=null,this._objectUrl=null}n&&(n.removeEventListener("emptied",this._onMediaEmptied),i||(r&&self.URL.revokeObjectURL(r),this.mediaSrc===r?(n.removeAttribute("src"),this.appendSource&&lC(n),n.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.media=null),this.hls.trigger(UE.MEDIA_DETACHED,t)}},{key:"onBufferReset",value:function(){this.sourceBuffers.forEach(([e])=>{e&&this.resetBuffer(e)}),this.initTracks()}},{key:"resetBuffer",value:function(e){var t,i=null==(t=this.tracks[e])?void 0:t.buffer;if(this.removeBuffer(e),i)try{var n;null!=(n=this.mediaSource)&&n.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(i)}catch(t){this.warn(`onBufferReset ${e}`,t)}delete this.tracks[e]}},{key:"removeBuffer",value:function(e){this.removeBufferListeners(e),this.sourceBuffers[dC(e)]=[null,null];var t=this.tracks[e];t&&(t.buffer=void 0)}},{key:"resetQueue",value:function(){this.operationQueue&&this.operationQueue.destroy(),this.operationQueue=new aC(this.tracks)}},{key:"onBufferCodecs",value:function(e,t){var i,n=this.tracks,a=Object.keys(t);this.log(`BUFFER_CODECS: "${a}" (current SB count ${this.sourceBufferCount})`);var r="audiovideo"in t&&(n.audio||n.video)||n.audiovideo&&("audio"in t||"video"in t),o=!r&&this.sourceBufferCount&&this.media&&a.some(e=>!n[e]);r||o?this.warn(`Unsupported transition between "${Object.keys(n)}" and "${a}" SourceBuffers`):(a.forEach(e=>{var i,a,r=t[e],o=r.id,s=r.codec,u=r.levelCodec,l=r.container,d=r.metadata,h=r.supplemental,c=n[e],m=null==(i=this.transferData)||null==(i=i.tracks)?void 0:i[e],f=null!=m&&m.buffer?m:c,v=(null==f?void 0:f.pendingCodec)||(null==f?void 0:f.codec),p=null==f?void 0:f.levelCodec;c||(c=n[e]={buffer:void 0,listeners:[],codec:s,supplemental:h,container:l,levelCodec:u,metadata:d,id:o});var g=pP(v,p),y=null==g?void 0:g.replace(rC,"$1"),b=pP(s,u),w=null==(a=b)?void 0:a.replace(rC,"$1");b&&g&&y!==w&&("audio"===e.slice(0,5)&&(b=vP(b,this.appendSource)),this.log(`switching codec ${v} to ${b}`),b!==(c.pendingCodec||c.codec)&&(c.pendingCodec=b),c.container=l,this.appendChangeType(e,l,b))}),(this.tracksReady||this.sourceBufferCount)&&(t.tracks=this.sourceBufferTracks),this.sourceBufferCount||(this.bufferCodecEventsTotal>1&&!this.tracks.video&&!t.video&&"main"===(null==(i=t.audio)?void 0:i.id)&&(this.log("Main audio-only"),this.bufferCodecEventsTotal=1),this.mediaSourceOpenOrEnded&&this.checkPendingTracks()))}},{key:"sourceBufferTracks",get:function(){return Object.keys(this.tracks).reduce((e,t)=>{var i=this.tracks[t];return e[t]={id:i.id,container:i.container,codec:i.codec,levelCodec:i.levelCodec},e},{})}},{key:"appendChangeType",value:function(e,t,i){var n=`${t};codecs=${i}`,a={label:`change-type=${n}`,execute:()=>{var a=this.tracks[e];if(a){var r=a.buffer;null!=r&&r.changeType&&(this.log(`changing ${e} sourceBuffer type to ${n}`),r.changeType(n),a.codec=i,a.container=t)}this.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:t=>{this.warn(`Failed to change ${e} SourceBuffer type`,t)}};this.append(a,e,this.isPending(this.tracks[e]))}},{key:"blockAudio",value:function(e){var t,i=e.start,n=i+.05*e.duration;if(!(!0===(null==(t=this.fragmentTracker.getAppendedFrag(i,XE))?void 0:t.gap))){var a={label:"block-audio",execute:()=>{var e,t=this.tracks.video;(this.lastVideoAppendEnd>n||null!=t&&t.buffer&&$M.isBuffered(t.buffer,n)||!0===(null==(e=this.fragmentTracker.getAppendedFrag(n,XE))?void 0:e.gap))&&(this.blockedAudioAppend=null,this.shiftAndExecuteNext("audio"))},onStart:()=>{},onComplete:()=>{},onError:e=>{this.warn("Error executing block-audio operation",e)}};this.blockedAudioAppend={op:a,frag:e},this.append(a,"audio",!0)}}},{key:"unblockAudio",value:function(){var e=this.blockedAudioAppend,t=this.operationQueue;e&&t&&(this.blockedAudioAppend=null,t.unblockAudio(e.op))}},{key:"onBufferAppending",value:function(e,t){var i=this.tracks,n=t.data,a=t.type,r=t.parent,o=t.frag,s=t.part,u=t.chunkMeta,l=t.offset,d=u.buffering[a],h=o.sn,c=o.cc,m=self.performance.now();d.start=m;var f=o.stats.buffering,v=s?s.stats.buffering:null;0===f.start&&(f.start=m),v&&0===v.start&&(v.start=m);var p=i.audio,g=!1;"audio"===a&&"audio/mpeg"===(null==p?void 0:p.container)&&(g=!this.lastMpegAudioChunk||1===u.id||this.lastMpegAudioChunk.sn!==u.sn,this.lastMpegAudioChunk=u);var y=i.video,b=null==y?void 0:y.buffer;if(b&&"initSegment"!==h){var w=s||o,k=this.blockedAudioAppend;if("audio"!==a||"main"===r||this.blockedAudioAppend||y.ending||y.ended){if("video"===a){var S=w.end;if(k){var E=k.frag.start;(S>E||S<this.lastVideoAppendEnd||$M.isBuffered(b,E))&&this.unblockAudio()}this.lastVideoAppendEnd=S}}else{var T=w.start+.05*w.duration,P=b.buffered,M=this.currentOp("video");P.length||M?!M&&!$M.isBuffered(b,T)&&this.lastVideoAppendEnd<T&&this.blockAudio(w):this.blockAudio(w)}}var A=(s||o).start,D={label:`append-${a}`,execute:()=>{var e;d.executeStart=self.performance.now();var t=null==(e=this.tracks[a])?void 0:e.buffer;t&&(g?this.updateTimestampOffset(t,A,.1,a,h,c):void 0!==l&&$E(l)&&this.updateTimestampOffset(t,l,1e-6,a,h,c)),this.appendExecutor(n,a)},onStart:()=>{},onComplete:()=>{var e=self.performance.now();d.executeEnd=d.end=e,0===f.first&&(f.first=e),v&&0===v.first&&(v.first=e);var t={};this.sourceBuffers.forEach(([e,i])=>{e&&(t[e]=$M.getBuffered(i))}),this.appendErrors[a]=0,"audio"===a||"video"===a?this.appendErrors.audiovideo=0:(this.appendErrors.audio=0,this.appendErrors.video=0),this.hls.trigger(UE.BUFFER_APPENDED,{type:a,frag:o,part:s,chunkMeta:u,parent:o.type,timeRanges:t})},onError:e=>{var t,i={type:BE.MEDIA_ERROR,parent:o.type,details:zE.BUFFER_APPEND_ERROR,sourceBufferName:a,frag:o,part:s,chunkMeta:u,error:e,err:e,fatal:!1},n=null==(t=this.media)?void 0:t.error;if(e.code===DOMException.QUOTA_EXCEEDED_ERR||"QuotaExceededError"==e.name||"quota"in e)i.details=zE.BUFFER_FULL_ERROR;else if(e.code===DOMException.INVALID_STATE_ERR&&this.mediaSourceOpenOrEnded&&!n)i.errorAction=vM(!0);else if(e.name===oC&&0===this.sourceBufferCount)i.errorAction=vM(!0);else{var r=++this.appendErrors[a];this.warn(`Failed ${r}/${this.hls.config.appendErrorMaxRetry} times to append segment in "${a}" sourceBuffer (${n||"no media error"})`),(r>=this.hls.config.appendErrorMaxRetry||n)&&(i.fatal=!0)}this.hls.trigger(UE.ERROR,i)}};this.log(`queuing "${a}" append sn: ${h}${s?" p: "+s.index:""} of ${o.type===XE?"level":"track"} ${o.level} cc: ${c}`),this.append(D,a,this.isPending(this.tracks[a]))}},{key:"getFlushOp",value:function(e,t,i){return this.log(`queuing "${e}" remove ${t}-${i}`),{label:"remove",execute:()=>{this.removeExecutor(e,t,i)},onStart:()=>{},onComplete:()=>{this.hls.trigger(UE.BUFFER_FLUSHED,{type:e})},onError:n=>{this.warn(`Failed to remove ${t}-${i} from "${e}" SourceBuffer`,n)}}}},{key:"onBufferFlushing",value:function(e,t){var i=t.type,n=t.startOffset,a=t.endOffset;i?this.append(this.getFlushOp(i,n,a),i):this.sourceBuffers.forEach(([e])=>{e&&this.append(this.getFlushOp(e,n,a),e)})}},{key:"onFragParsed",value:function(e,t){var i=t.frag,n=t.part,a=[],r=n?n.elementaryStreams:i.elementaryStreams;r[AT]?a.push("audiovideo"):(r[PT]&&a.push("audio"),r[MT]&&a.push("video"));0===a.length&&this.warn(`Fragments must have at least one ElementaryStreamType set. type: ${i.type} level: ${i.level} sn: ${i.sn}`),this.blockBuffers(()=>{var e=self.performance.now();i.stats.buffering.end=e,n&&(n.stats.buffering.end=e);var t=n?n.stats:i.stats;this.hls.trigger(UE.FRAG_BUFFERED,{frag:i,part:n,stats:t,id:i.type})},a).catch(e=>{this.warn(`Fragment buffered callback ${e}`),this.stepOperationQueue(this.sourceBufferTypes)})}},{key:"onFragChanged",value:function(e,t){this.trimBuffers()}},{key:"bufferedToEnd",get:function(){return this.sourceBufferCount>0&&!this.sourceBuffers.some(([e])=>{if(e){var t=this.tracks[e];if(t)return!t.ended||t.ending}return!1})}},{key:"onBufferEos",value:function(e,t){var i;this.sourceBuffers.forEach(([e])=>{if(e){var i=this.tracks[e];t.type&&t.type!==e||(i.ending=!0,i.ended||(i.ended=!0,this.log(`${e} buffer reached EOS`)))}});var n=!1!==(null==(i=this.overrides)?void 0:i.endOfStream);this.sourceBufferCount>0&&!this.sourceBuffers.some(([e])=>{var t;return e&&!(null!=(t=this.tracks[e])&&t.ended)})?n?(this.log("Queueing EOS"),this.blockUntilOpen(()=>{this.tracksEnded();var e=this.mediaSource;e&&"open"===e.readyState?(this.log("Calling mediaSource.endOfStream()"),e.endOfStream(),this.hls.trigger(UE.BUFFERED_TO_END,void 0)):e&&this.log(`Could not call mediaSource.endOfStream(). mediaSource.readyState: ${e.readyState}`)})):(this.tracksEnded(),this.hls.trigger(UE.BUFFERED_TO_END,void 0)):"video"===t.type&&this.unblockAudio()}},{key:"tracksEnded",value:function(){this.sourceBuffers.forEach(([e])=>{if(null!==e){var t=this.tracks[e];t&&(t.ending=!1)}})}},{key:"onLevelUpdated",value:function(e,{details:t}){t.fragments.length&&(this.details=t,this.updateDuration())}},{key:"updateDuration",value:function(){this.blockUntilOpen(()=>{var e=this.getDurationAndRange();e&&this.updateMediaSource(e)})}},{key:"onError",value:function(e,t){if(t.details===zE.BUFFER_APPEND_ERROR&&t.frag){var i,n=null==(i=t.errorAction)?void 0:i.nextAutoLevel;$E(n)&&n!==t.frag.level&&this.resetAppendErrors()}}},{key:"resetAppendErrors",value:function(){this.appendErrors={audio:0,video:0,audiovideo:0}}},{key:"trimBuffers",value:function(){var e=this.hls,t=this.details,i=this.media;if(i&&null!==t&&this.sourceBufferCount){var n=e.config,a=i.currentTime,r=t.levelTargetDuration,o=t.live&&null!==n.liveBackBufferLength?n.liveBackBufferLength:n.backBufferLength;if($E(o)&&o>=0){var s=Math.max(o,r),u=Math.floor(a/r)*r-s;this.flushBackBuffer(a,r,u)}var l=n.frontBufferFlushThreshold;if($E(l)&&l>0){var d=Math.max(n.maxBufferLength,l),h=Math.max(d,r),c=Math.floor(a/r)*r+h;this.flushFrontBuffer(a,r,c)}}}},{key:"flushBackBuffer",value:function(e,t,i){this.sourceBuffers.forEach(([e,t])=>{if(t){var n=$M.getBuffered(t);if(n.length>0&&i>n.start(0)){var a;this.hls.trigger(UE.BACK_BUFFER_REACHED,{bufferEnd:i});var r=this.tracks[e];if(null!=(a=this.details)&&a.live)this.hls.trigger(UE.LIVE_BACK_BUFFER_REACHED,{bufferEnd:i});else if(null!=r&&r.ended)return void this.log(`Cannot flush ${e} back buffer while SourceBuffer is in ended state`);this.hls.trigger(UE.BUFFER_FLUSHING,{startOffset:0,endOffset:i,type:e})}}})}},{key:"flushFrontBuffer",value:function(e,t,i){this.sourceBuffers.forEach(([t,n])=>{if(n){var a=$M.getBuffered(n),r=a.length;if(r<2)return;var o=a.start(r-1),s=a.end(r-1);if(i>o||e>=o&&e<=s)return;this.hls.trigger(UE.BUFFER_FLUSHING,{startOffset:o,endOffset:1/0,type:t})}})}},{key:"getDurationAndRange",value:function(){var e,t=this.details,i=this.mediaSource;if(!t||!this.media||"open"!==(null==i?void 0:i.readyState))return null;var n=t.edge;if(t.live&&this.hls.config.liveDurationInfinity){if(t.fragments.length&&i.setLiveSeekableRange){var a=Math.max(0,t.fragmentStart);return{duration:1/0,start:a,end:Math.max(a,n)}}return{duration:1/0}}var r=null==(e=this.overrides)?void 0:e.duration;if(r)return $E(r)?{duration:r}:null;var o=this.media.duration;return n>($E(i.duration)?i.duration:0)&&n>o||!$E(o)?{duration:n}:null}},{key:"updateMediaSource",value:function({duration:e,start:t,end:i}){var n=this.mediaSource;this.media&&n&&"open"===n.readyState&&(n.duration!==e&&($E(e)&&this.log(`Updating MediaSource duration to ${e.toFixed(3)}`),n.duration=e),void 0!==t&&void 0!==i&&(this.log(`MediaSource duration is set to ${n.duration}. Setting seekable range to ${t}-${i}.`),n.setLiveSeekableRange(t,i)))}},{key:"tracksReady",get:function(){var e=this.pendingTrackCount;return e>0&&(e>=this.bufferCodecEventsTotal||this.isPending(this.tracks.audiovideo))}},{key:"checkPendingTracks",value:function(){var e=this.bufferCodecEventsTotal,t=this.pendingTrackCount,i=this.tracks;if(this.log(`checkPendingTracks (pending: ${t} codec events expected: ${e}) ${WP(i)}`),this.tracksReady){var n,a=null==(n=this.transferData)?void 0:n.tracks;a&&Object.keys(a).length?this.attachTransferred():this.createSourceBuffers()}}},{key:"bufferCreated",value:function(){if(this.sourceBufferCount){var e={};this.sourceBuffers.forEach(([t,i])=>{if(t){var n=this.tracks[t];e[t]={buffer:i,container:n.container,codec:n.codec,supplemental:n.supplemental,levelCodec:n.levelCodec,id:n.id,metadata:n.metadata}}}),this.hls.trigger(UE.BUFFER_CREATED,{tracks:e}),this.log(`SourceBuffers created. Running queue: ${this.operationQueue}`),this.sourceBuffers.forEach(([e])=>{this.executeNext(e)})}else{var t=new Error("could not create source buffer for media codec(s)");this.hls.trigger(UE.ERROR,{type:BE.MEDIA_ERROR,details:zE.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:t,reason:t.message})}}},{key:"createSourceBuffers",value:function(){var e=this.tracks,t=this.sourceBuffers,i=this.mediaSource;if(!i)throw new Error("createSourceBuffers called when mediaSource was null");for(var n in e){var a=n,r=e[a];if(this.isPending(r)){var o=this.getTrackCodec(r,a),s=`${r.container};codecs=${o}`;r.codec=o,this.log(`creating sourceBuffer(${s})${this.currentOp(a)?" Queued":""} ${WP(r)}`);try{var u=i.addSourceBuffer(s),l=dC(a),d=[a,u];t[l]=d,r.buffer=u}catch(e){var h;return this.error(`error while trying to add sourceBuffer: ${e.message}`),this.shiftAndExecuteNext(a),null==(h=this.operationQueue)||h.removeBlockers(),delete this.tracks[a],void this.hls.trigger(UE.ERROR,{type:BE.MEDIA_ERROR,details:zE.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:e,sourceBufferName:a,mimeType:s,parent:r.id})}this.trackSourceBuffer(a,r)}}this.bufferCreated()}},{key:"getTrackCodec",value:function(e,t){var i=e.supplemental,n=e.codec;i&&("video"===t||"audiovideo"===t)&&uP(i,"video")&&(n=function(e,t){var i=[];if(e)for(var n=e.split(","),a=0;a<n.length;a++)sP(n[a],"video")||i.push(n[a]);return t&&i.push(t),i.join(",")}(n,i));var a=pP(n,e.levelCodec);return a?"audio"===t.slice(0,5)?vP(a,this.appendSource):a:""}},{key:"trackSourceBuffer",value:function(e,t){var i=t.buffer;if(i){var n=this.getTrackCodec(t,e);this.tracks[e]={buffer:i,codec:n,container:t.container,levelCodec:t.levelCodec,supplemental:t.supplemental,metadata:t.metadata,id:t.id,listeners:[]},this.removeBufferListeners(e),this.addBufferListener(e,"updatestart",this.onSBUpdateStart),this.addBufferListener(e,"updateend",this.onSBUpdateEnd),this.addBufferListener(e,"error",this.onSBUpdateError),this.appendSource&&this.addBufferListener(e,"bufferedchange",(e,t)=>{var i=t.removedRanges;null!=i&&i.length&&this.hls.trigger(UE.BUFFER_FLUSHED,{type:e})})}}},{key:"mediaSrc",get:function(){var e,t,i=(null==(e=this.media)||null==(t=e.querySelector)?void 0:t.call(e,"source"))||this.media;return null==i?void 0:i.src}},{key:"onSBUpdateStart",value:function(e){var t=this.currentOp(e);t&&t.onStart()}},{key:"onSBUpdateEnd",value:function(e){var t;if("closed"!==(null==(t=this.mediaSource)?void 0:t.readyState)){var i=this.currentOp(e);i&&(i.onComplete(),this.shiftAndExecuteNext(e))}else this.resetBuffer(e)}},{key:"onSBUpdateError",value:function(e,t){var i,n=new Error(`${e} SourceBuffer error. MediaSource readyState: ${null==(i=this.mediaSource)?void 0:i.readyState}`);this.error(`${n}`,t),this.hls.trigger(UE.ERROR,{type:BE.MEDIA_ERROR,details:zE.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:n,fatal:!1});var a=this.currentOp(e);a&&a.onError(n)}},{key:"updateTimestampOffset",value:function(e,t,i,n,a,r){var o=t-e.timestampOffset;Math.abs(o)>=i&&(this.log(`Updating ${n} SourceBuffer timestampOffset to ${t} (sn: ${a} cc: ${r})`),e.timestampOffset=t)}},{key:"removeExecutor",value:function(e,t,i){var n=this.media,a=this.mediaSource,r=this.tracks[e],o=null==r?void 0:r.buffer;if(!n||!a||!o)return this.warn(`Attempting to remove from the ${e} SourceBuffer, but it does not exist`),void this.shiftAndExecuteNext(e);var s=$E(n.duration)?n.duration:1/0,u=$E(a.duration)?a.duration:1/0,l=Math.max(0,t),d=Math.min(i,s,u);d>l&&(!r.ending||r.ended)?(r.ended=!1,this.log(`Removing [${l},${d}] from the ${e} SourceBuffer`),o.remove(l,d)):this.shiftAndExecuteNext(e)}},{key:"appendExecutor",value:function(e,t){var i=this.tracks[t],n=null==i?void 0:i.buffer;if(!n)throw new sC(`Attempting to append to the ${t} SourceBuffer, but it does not exist`);i.ending=!1,i.ended=!1,n.appendBuffer(e)}},{key:"blockUntilOpen",value:function(e){if(this.isUpdating()||this.isQueued())this.blockBuffers(e).catch(e=>{this.warn(`SourceBuffer blocked callback ${e}`),this.stepOperationQueue(this.sourceBufferTypes)});else try{e()}catch(e){this.warn(`Callback run without blocking ${this.operationQueue} ${e}`)}}},{key:"isUpdating",value:function(){return this.sourceBuffers.some(([e,t])=>e&&t.updating)}},{key:"isQueued",value:function(){return this.sourceBuffers.some(([e])=>e&&!!this.currentOp(e))}},{key:"isPending",value:function(e){return!!e&&!e.buffer}},{key:"blockBuffers",value:function(e,t=this.sourceBufferTypes){if(!t.length)return this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);var i=this.operationQueue,n=t.map(e=>this.appendBlocker(e));return t.length>1&&!!this.blockedAudioAppend&&this.unblockAudio(),Promise.all(n).then(t=>{i===this.operationQueue&&(e(),this.stepOperationQueue(this.sourceBufferTypes))})}},{key:"stepOperationQueue",value:function(e){e.forEach(e=>{var t,i=null==(t=this.tracks[e])?void 0:t.buffer;i&&!i.updating&&this.shiftAndExecuteNext(e)})}},{key:"append",value:function(e,t,i){this.operationQueue&&this.operationQueue.append(e,t,i)}},{key:"appendBlocker",value:function(e){if(this.operationQueue)return this.operationQueue.appendBlocker(e)}},{key:"currentOp",value:function(e){return this.operationQueue?this.operationQueue.current(e):null}},{key:"executeNext",value:function(e){e&&this.operationQueue&&this.operationQueue.executeNext(e)}},{key:"shiftAndExecuteNext",value:function(e){this.operationQueue&&this.operationQueue.shiftAndExecuteNext(e)}},{key:"pendingTrackCount",get:function(){return Object.keys(this.tracks).reduce((e,t)=>e+(this.isPending(this.tracks[t])?1:0),0)}},{key:"sourceBufferCount",get:function(){return this.sourceBuffers.reduce((e,[t])=>e+(t?1:0),0)}},{key:"sourceBufferTypes",get:function(){return this.sourceBuffers.map(([e])=>e).filter(e=>!!e)}},{key:"addBufferListener",value:function(e,t,i){var n=this.tracks[e];if(n){var a=n.buffer;if(a){var r=i.bind(this,e);n.listeners.push({event:t,listener:r}),a.addEventListener(t,r)}}}},{key:"removeBufferListeners",value:function(e){var t=this.tracks[e];if(t){var i=t.buffer;i&&(t.listeners.forEach(e=>{i.removeEventListener(e.event,e.listener)}),t.listeners.length=0)}}}])}();function lC(e){var t=e.querySelectorAll("source");[].slice.call(t).forEach(t=>{e.removeChild(t)})}function dC(e){return"audio"===e?1:0}var hC=function(){function e(t){u(this,e),this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=t,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}return m(e,[{key:"setStreamController",value:function(e){this.streamController=e}},{key:"destroy",value:function(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}},{key:"registerListeners",value:function(){var e=this.hls;e.on(UE.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(UE.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(UE.MANIFEST_PARSED,this.onManifestParsed,this),e.on(UE.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(UE.BUFFER_CODECS,this.onBufferCodecs,this),e.on(UE.MEDIA_DETACHING,this.onMediaDetaching,this)}},{key:"unregisterListener",value:function(){var e=this.hls;e.off(UE.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(UE.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(UE.MANIFEST_PARSED,this.onManifestParsed,this),e.off(UE.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(UE.BUFFER_CODECS,this.onBufferCodecs,this),e.off(UE.MEDIA_DETACHING,this.onMediaDetaching,this)}},{key:"onFpsDropLevelCapping",value:function(e,t){var i=this.hls.levels[t.droppedLevel];this.isLevelAllowed(i)&&this.restrictedLevels.push({bitrate:i.bitrate,height:i.height,width:i.width})}},{key:"onMediaAttaching",value:function(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()}},{key:"onManifestParsed",value:function(e,t){var i=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,i.config.capLevelToPlayerSize&&t.video&&this.startCapping()}},{key:"onLevelsUpdated",value:function(e,t){this.timer&&$E(this.autoLevelCapping)&&this.detectPlayerSize()}},{key:"onBufferCodecs",value:function(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()}},{key:"onMediaDetaching",value:function(){this.stopCapping(),this.media=null}},{key:"detectPlayerSize",value:function(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0)return void(this.clientRect=null);var e=this.hls.levels;if(e.length){var t=this.hls,i=this.getMaxLevel(e.length-1);i!==this.autoLevelCapping&&t.logger.log(`Setting autoLevelCapping to ${i}: ${e[i].height}p@${e[i].bitrate} for media ${this.mediaWidth}x${this.mediaHeight}`),t.autoLevelCapping=i,t.autoLevelEnabled&&t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}}},{key:"getMaxLevel",value:function(t){var i=this.hls.levels;if(!i.length)return-1;var n=i.filter((e,i)=>this.isLevelAllowed(e)&&i<=t);return this.clientRect=null,e.getMaxLevelByMediaSize(n,this.mediaWidth,this.mediaHeight)}},{key:"startCapping",value:function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())}},{key:"stopCapping",value:function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)}},{key:"getDimensions",value:function(){if(this.clientRect)return this.clientRect;var e=this.media,t={width:0,height:0};if(e){var i=e.getBoundingClientRect();t.width=i.width,t.height=i.height,t.width||t.height||(t.width=i.right-i.left||e.width||0,t.height=i.bottom-i.top||e.height||0)}return this.clientRect=t,t}},{key:"mediaWidth",get:function(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function(){var e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch(e){}return Math.min(e,this.hls.config.maxDevicePixelRatio)}},{key:"isLevelAllowed",value:function(e){return!this.restrictedLevels.some(t=>e.bitrate===t.bitrate&&e.width===t.width&&e.height===t.height)}}],[{key:"getMaxLevelByMediaSize",value:function(e,t,i){if(null==e||!e.length)return-1;for(var n=(e,t)=>!t||(e.width!==t.width||e.height!==t.height),a=e.length-1,r=Math.max(t,i),o=0;o<e.length;o+=1){var s=e[o];if((s.width>=r||s.height>=r)&&n(s,e[o+1])){a=o;break}}return a}}])}(),cC={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"},mC={HLS:"h"},fC=m(function e(t,i){u(this,e),Array.isArray(t)&&(t=t.map(t=>t instanceof e?t:new e(t))),this.value=t,this.params=i});function vC(e,t,i,n){return new Error(`failed to ${e} "${a=t,Array.isArray(a)?JSON.stringify(a):a instanceof Map?"Map{}":a instanceof Set?"Set{}":"object"==typeof a?JSON.stringify(a):String(a)}" as ${i}`,{cause:n});var a}function pC(e,t,i){return vC("serialize",e,t,i)}var gC=m(function e(t){u(this,e),this.description=t}),yC="Bare Item";function bC(e){if(!1===ArrayBuffer.isView(e))throw pC(e,"Byte Sequence");return`:${t=e,btoa(String.fromCharCode(...t))}:`;var t}function wC(e){if(function(e){return e<-999999999999999||999999999999999<e}(e))throw pC(e,"Integer");return e.toString()}function kC(e,t){if(e<0)return-kC(-e,t);var i=Math.pow(10,t);if(Math.abs(e*i%1-.5)<Number.EPSILON){var n=Math.floor(e*i);return(n%2==0?n:n+1)/i}return Math.round(e*i)/i}function SC(e){var t=kC(e,3);if(Math.floor(Math.abs(t)).toString().length>12)throw pC(e,"Decimal");var i=t.toString();return i.includes(".")?i:`${i}.0`}var EC=/[\x00-\x1f\x7f]+/;function TC(e){var t,i=(t=e).description||t.toString().slice(7,-1);if(!1===/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(i))throw pC(i,"Token");return i}function PC(e){switch(typeof e){case"number":if(!$E(e))throw pC(e,yC);return Number.isInteger(e)?wC(e):SC(e);case"string":return function(e){if(EC.test(e))throw pC(e,"String");return`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}(e);case"symbol":return TC(e);case"boolean":return function(e){if("boolean"!=typeof e)throw pC(e,"Boolean");return e?"?1":"?0"}(e);case"object":if(e instanceof Date)return function(e){return`@${wC(e.getTime()/1e3)}`}(e);if(e instanceof Uint8Array)return bC(e);if(e instanceof gC)return TC(e);default:throw pC(e,yC)}}function MC(e){if(!1===/^[a-z*][a-z0-9\-_.*]*$/.test(e))throw pC(e,"Key");return e}function AC(e){return null==e?"":Object.entries(e).map(([e,t])=>!0===t?`;${MC(e)}`:`;${MC(e)}=${PC(t)}`).join("")}function DC(e){return e instanceof fC?`${PC(e.value)}${AC(e.params)}`:PC(e)}function xC(e,t={whitespace:!0}){if("object"!=typeof e||null==e)throw pC(e,"Dict");var i=e instanceof Map?e.entries():Object.entries(e),n=(null==t?void 0:t.whitespace)?" ":"";return Array.from(i).map(([e,t])=>{t instanceof fC==!1&&(t=new fC(t));var i,n=MC(e);return!0===t.value?n+=AC(t.params):(n+="=",Array.isArray(t.value)?n+=`(${(i=t).value.map(DC).join(" ")})${AC(i.params)}`:n+=DC(t)),n}).join(`,${n}`)}function CC(e,t){return xC(e,t)}var IC="CMCD-Object",LC="CMCD-Request",_C="CMCD-Session",RC="CMCD-Status",FC={br:IC,ab:IC,d:IC,ot:IC,tb:IC,tpb:IC,lb:IC,tab:IC,lab:IC,url:IC,pb:LC,bl:LC,tbl:LC,dl:LC,ltc:LC,mtp:LC,nor:LC,nrr:LC,rc:LC,sn:LC,sta:LC,su:LC,ttfb:LC,ttfbb:LC,ttlb:LC,cmsdd:LC,cmsds:LC,smrt:LC,df:LC,cs:LC,ts:LC,cid:_C,pr:_C,sf:_C,sid:_C,st:_C,v:_C,msd:_C,bs:RC,bsd:RC,cdn:RC,rtp:RC,bg:RC,pt:RC,ec:RC,e:RC},OC=LC;function WC(e,t){var i={};if(!e)return i;var n,a=Object.keys(e),r=t?(n=t,Object.keys(n).reduce((e,t)=>{var i;return null===(i=n[t])||void 0===i||i.forEach(i=>e[i]=t),e},{})):{};return a.reduce((t,i)=>{var n,a=FC[i]||r[i]||OC;return(null!==(n=t[a])&&void 0!==n?n:t[a]={})[i]=e[i],t},i)}var $C="event";var NC=e=>Math.round(e),jC=(e,t)=>Array.isArray(e)?e.map(e=>jC(e,t)):e instanceof fC&&"string"==typeof e.value?new fC(jC(e.value,t),e.params):(t.baseUrl&&(e=function(e,t){var i=new URL(e),n=new URL(t);if(i.origin!==n.origin)return e;for(var a=i.pathname.split("/").slice(1),r=n.pathname.split("/").slice(1,-1);a[0]===r[0];)a.shift(),r.shift();for(;r.length;)r.shift(),a.unshift("..");return a.join("/")+i.search+i.hash}(e,t.baseUrl)),1===t.version?encodeURIComponent(e):e),BC=e=>100*NC(e/100),zC={br:NC,d:NC,bl:BC,dl:BC,mtp:BC,nor:(e,t)=>{var i=e;return t.version>=2&&(e instanceof fC&&"string"==typeof e.value?i=new fC([e]):"string"==typeof e&&(i=[e])),jC(i,t)},rtp:BC,tb:NC},UC="request",HC="response",GC=["ab","bg","bl","br","bs","bsd","cdn","cid","cs","df","ec","lab","lb","ltc","msd","mtp","pb","pr","pt","sf","sid","sn","st","sta","tab","tb","tbl","tpb","ts","v"],VC=["e"],KC=/^[a-zA-Z0-9-.]+-[a-zA-Z0-9-.]+$/;function XC(e){return KC.test(e)}var YC=["d","dl","nor","ot","rtp","su"];var qC=["cmsdd","cmsds","rc","smrt","ttfb","ttfbb","ttlb","url"];var JC=["bl","br","bs","cid","d","dl","mtp","nor","nrr","ot","pr","rtp","sf","sid","st","su","tb","v"];function QC(e){return JC.includes(e)||XC(e)}var ZC={[HC]:function(e){return GC.includes(e)||YC.includes(e)||qC.includes(e)||XC(e)},[$C]:function(e){return GC.includes(e)||VC.includes(e)||XC(e)},[UC]:function(e){return GC.includes(e)||YC.includes(e)||XC(e)}};function eI(e,t={}){var i={};if(null==e||"object"!=typeof e)return i;var n=t.version||e.v||1,a=t.reportingMode||UC,r=1===n?QC:ZC[a],o=Object.keys(e).filter(r),s=t.filter;"function"==typeof s&&(o=o.filter(s));var u=a===HC||a===$C;u&&!o.includes("ts")&&o.push("ts"),n>1&&!o.includes("v")&&o.push("v");var l=eT({},zC,t.formatters),d={version:n,reportingMode:a,baseUrl:t.baseUrl};return o.sort().forEach(t=>{var a=e[t],r=l[t];if("function"==typeof r&&(a=r(a,d)),"v"===t){if(1===n)return;a=n}"pr"==t&&1===a||(u&&"ts"===t&&!$E(a)&&(a=Date.now()),function(e){return"number"==typeof e?$E(e):null!=e&&""!==e&&!1!==e}(a)&&(function(e){return["ot","sf","st","e","sta"].includes(e)}(t)&&"string"==typeof a&&(a=new gC(a)),i[t]=a))}),i}function tI(e,t,i){return eT(e,function(e,t={}){var i={};if(!e)return i;var n=WC(eI(e,t),null==t?void 0:t.customHeaderMap);return Object.entries(n).reduce((e,[t,i])=>{var n=CC(i,{whitespace:!1});return n&&(e[t]=n),e},i)}(t,i))}function iI(e,t={}){if(!e)return"";var i=function(e,t={}){return e?CC(eI(e,t),{whitespace:!1}):""}(e,t);return encodeURIComponent(i)}var nI=/CMCD=[^&#]+/;function aI(e,t,i){var n=function(e,t={}){return e?`CMCD=${iI(e,t)}`:""}(t,i);if(!n)return e;if(nI.test(e))return e.replace(nI,n);var a=e.includes("?")?"&":"?";return`${e}${a}${n}`}var rI=function(){return m(function e(t){u(this,e),this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.includeKeys=void 0,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=e=>{try{this.apply(e,{ot:cC.MANIFEST,su:!this.initialized})}catch(e){this.hls.logger.warn("Could not generate manifest CMCD data.",e)}},this.applyFragmentData=e=>{try{var t=e.frag,i=e.part,n=this.hls.levels[t.level],a=this.getObjectType(t),r={d:1e3*(i||t).duration,ot:a};a!==cC.VIDEO&&a!==cC.AUDIO&&a!=cC.MUXED||(r.br=n.bitrate/1e3,r.tb=this.getTopBandwidth(a)/1e3,r.bl=this.getBufferLength(a));var o=i?this.getNextPart(i):this.getNextFrag(t);null!=o&&o.url&&o.url!==t.url&&(r.nor=o.url),this.apply(e,r)}catch(e){this.hls.logger.warn("Could not generate segment CMCD data.",e)}},this.hls=t;var i=this.config=t.config,n=i.cmcd;null!=n&&(i.pLoader=this.createPlaylistLoader(),i.fLoader=this.createFragmentLoader(),this.sid=n.sessionId||t.sessionId,this.cid=n.contentId,this.useHeaders=!0===n.useHeaders,this.includeKeys=n.includeKeys,this.registerListeners())},[{key:"registerListeners",value:function(){var e=this.hls;e.on(UE.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(UE.MEDIA_DETACHED,this.onMediaDetached,this),e.on(UE.BUFFER_CREATED,this.onBufferCreated,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(UE.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(UE.MEDIA_DETACHED,this.onMediaDetached,this),e.off(UE.BUFFER_CREATED,this.onBufferCreated,this)}},{key:"destroy",value:function(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null,this.onWaiting=this.onPlaying=this.media=null}},{key:"onMediaAttached",value:function(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}},{key:"onMediaDetached",value:function(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}},{key:"onBufferCreated",value:function(e,t){var i,n;this.audioBuffer=null==(i=t.tracks.audio)?void 0:i.buffer,this.videoBuffer=null==(n=t.tracks.video)?void 0:n.buffer}},{key:"createData",value:function(){var e;return{v:1,sf:mC.HLS,sid:this.sid,cid:this.cid,pr:null==(e=this.media)?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}},{key:"apply",value:function(e,t={}){eT(t,this.createData());var i=t.ot===cC.INIT||t.ot===cC.VIDEO||t.ot===cC.MUXED;this.starved&&i&&(t.bs=!0,t.su=!0,this.starved=!1),null==t.su&&(t.su=this.buffering);var n=this.includeKeys;n&&(t=Object.keys(t).reduce((e,i)=>(n.includes(i)&&(e[i]=t[i]),e),{}));var a={baseUrl:e.url};this.useHeaders?(e.headers||(e.headers={}),tI(e.headers,t,a)):e.url=aI(e.url,t,a)}},{key:"getNextFrag",value:function(e){var t,i=null==(t=this.hls.levels[e.level])?void 0:t.details;if(i){var n=e.sn-i.startSN;return i.fragments[n+1]}}},{key:"getNextPart",value:function(e){var t,i=e.index,n=e.fragment,a=null==(t=this.hls.levels[n.level])||null==(t=t.details)?void 0:t.partList;if(a)for(var r=n.sn,o=a.length-1;o>=0;o--){var s=a[o];if(s.index===i&&s.fragment.sn===r)return a[o+1]}}},{key:"getObjectType",value:function(e){var t=e.type;return"subtitle"===t?cC.TIMED_TEXT:"initSegment"===e.sn?cC.INIT:"audio"===t?cC.AUDIO:"main"===t?this.hls.audioTracks.length?cC.VIDEO:cC.MUXED:void 0}},{key:"getTopBandwidth",value:function(e){var t,i=0,n=this.hls;if(e===cC.AUDIO)t=n.audioTracks;else{var a=n.maxAutoLevel,r=a>-1?a+1:n.levels.length;t=n.levels.slice(0,r)}return t.forEach(e=>{e.bitrate>i&&(i=e.bitrate)}),i>0?i:NaN}},{key:"getBufferLength",value:function(e){var t=this.media,i=e===cC.AUDIO?this.audioBuffer:this.videoBuffer;return i&&t?1e3*$M.bufferInfo(i,t.currentTime,this.config.maxBufferHole).len:NaN}},{key:"createPlaylistLoader",value:function(){var e=this.config.pLoader,t=this.applyPlaylistData,i=e||this.config.loader;return function(){return m(function e(t){u(this,e),this.loader=void 0,this.loader=new i(t)},[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}},{key:"destroy",value:function(){this.loader.destroy()}},{key:"abort",value:function(){this.loader.abort()}},{key:"load",value:function(e,i,n){t(e),this.loader.load(e,i,n)}}])}()}},{key:"createFragmentLoader",value:function(){var e=this.config.fLoader,t=this.applyFragmentData,i=e||this.config.loader;return function(){return m(function e(t){u(this,e),this.loader=void 0,this.loader=new i(t)},[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}},{key:"destroy",value:function(){this.loader.destroy()}},{key:"abort",value:function(){this.loader.abort()}},{key:"load",value:function(e,i,n){t(e),this.loader.load(e,i,n)}}])}()}}])}(),oI=function(){function e(t){var i;return u(this,e),(i=s(this,e,["content-steering",t.logger])).hls=void 0,i.loader=null,i.uri=null,i.pathwayId=".",i._pathwayPriority=null,i.timeToLoad=300,i.reloadTimer=-1,i.updated=0,i.started=!1,i.enabled=!0,i.levels=null,i.audioTracks=null,i.subtitleTracks=null,i.penalizedPathways={},i.hls=t,i.registerListeners(),i}return y(e,nT),m(e,[{key:"registerListeners",value:function(){var e=this.hls;e.on(UE.MANIFEST_LOADING,this.onManifestLoading,this),e.on(UE.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(UE.MANIFEST_PARSED,this.onManifestParsed,this),e.on(UE.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(UE.MANIFEST_LOADING,this.onManifestLoading,this),e.off(UE.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(UE.MANIFEST_PARSED,this.onManifestParsed,this),e.off(UE.ERROR,this.onError,this))}},{key:"pathways",value:function(){return(this.levels||[]).reduce((e,t)=>(-1===e.indexOf(t.pathwayId)&&e.push(t.pathwayId),e),[])}},{key:"pathwayPriority",get:function(){return this._pathwayPriority},set:function(e){this.updatePathwayPriority(e)}},{key:"startLoad",value:function(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){var e=1e3*this.timeToLoad-(performance.now()-this.updated);if(e>0)return void this.scheduleRefresh(this.uri,e)}this.loadSteeringManifest(this.uri)}}},{key:"stopLoad",value:function(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()}},{key:"clearTimeout",value:function(){-1!==this.reloadTimer&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)}},{key:"destroy",value:function(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}},{key:"removeLevel",value:function(e){var t=this.levels;t&&(this.levels=t.filter(t=>t!==e))}},{key:"onManifestLoading",value:function(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}},{key:"onManifestLoaded",value:function(e,t){var i=t.contentSteering;null!==i&&(this.pathwayId=i.pathwayId,this.uri=i.uri,this.started&&this.startLoad())}},{key:"onManifestParsed",value:function(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}},{key:"onError",value:function(e,t){var i=t.errorAction;if((null==i?void 0:i.action)===sM&&i.flags===hM){var n=this.levels,a=this._pathwayPriority,r=this.pathwayId;if(t.context){var o=t.context,s=o.groupId,u=o.pathwayId,l=o.type;s&&n?r=this.getPathwayForGroupId(s,l,r):u&&(r=u)}r in this.penalizedPathways||(this.penalizedPathways[r]=performance.now()),!a&&n&&(a=this.pathways()),a&&a.length>1&&(this.updatePathwayPriority(a),i.resolved=this.pathwayId!==r),t.details!==zE.BUFFER_APPEND_ERROR||t.fatal?i.resolved||this.warn(`Could not resolve ${t.details} ("${t.error.message}") with content-steering for Pathway: ${r} levels: ${n?n.length:n} priorities: ${WP(a)} penalized: ${WP(this.penalizedPathways)}`):i.resolved=!0}}},{key:"filterParsedLevels",value:function(e){this.levels=e;var t=this.getLevelsForPathway(this.pathwayId);if(0===t.length){var i=e[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${i}"`),t=this.getLevelsForPathway(i),this.pathwayId=i}return t.length!==e.length&&this.log(`Found ${t.length}/${e.length} levels in Pathway "${this.pathwayId}"`),t}},{key:"getLevelsForPathway",value:function(e){return null===this.levels?[]:this.levels.filter(t=>e===t.pathwayId)}},{key:"updatePathwayPriority",value:function(e){var t;this._pathwayPriority=e;var i=this.penalizedPathways,n=performance.now();Object.keys(i).forEach(e=>{n-i[e]>3e5&&delete i[e]});for(var a=0;a<e.length;a++){var r=e[a];if(!(r in i)){if(r===this.pathwayId)return;var o=this.hls.nextLoadLevel,s=this.hls.levels[o];if((t=this.getLevelsForPathway(r)).length>0){this.log(`Setting Pathway to "${r}"`),this.pathwayId=r,KA(t),this.hls.trigger(UE.LEVELS_UPDATED,{levels:t});var u=this.hls.levels[o];s&&u&&this.levels&&(u.attrs["STABLE-VARIANT-ID"]!==s.attrs["STABLE-VARIANT-ID"]&&u.bitrate!==s.bitrate&&this.log(`Unstable Pathways change from bitrate ${s.bitrate} to ${u.bitrate}`),this.hls.nextLoadLevel=o);break}}}}},{key:"getPathwayForGroupId",value:function(e,t,i){for(var n=this.getLevelsForPathway(i).concat(this.levels||[]),a=0;a<n.length;a++)if(t===VE&&n[a].hasAudioGroup(e)||t===KE&&n[a].hasSubtitleGroup(e))return n[a].pathwayId;return i}},{key:"clonePathways",value:function(e){var t=this.levels;if(t){var i={},n={};e.forEach(e=>{var a=e.ID,r=e["BASE-ID"],o=e["URI-REPLACEMENT"];if(!t.some(e=>e.pathwayId===a)){var s=this.getLevelsForPathway(r).map(e=>{var t=new VM(e.attrs);t["PATHWAY-ID"]=a;var r=t.AUDIO&&`${t.AUDIO}_clone_${a}`,s=t.SUBTITLES&&`${t.SUBTITLES}_clone_${a}`;r&&(i[t.AUDIO]=r,t.AUDIO=r),s&&(n[t.SUBTITLES]=s,t.SUBTITLES=s);var u=uI(e.uri,t["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",o),l=new RP({attrs:t,audioCodec:e.audioCodec,bitrate:e.bitrate,height:e.height,name:e.name,url:u,videoCodec:e.videoCodec,width:e.width});if(e.audioGroups)for(var d=1;d<e.audioGroups.length;d++)l.addGroupId("audio",`${e.audioGroups[d]}_clone_${a}`);if(e.subtitleGroups)for(var h=1;h<e.subtitleGroups.length;h++)l.addGroupId("text",`${e.subtitleGroups[h]}_clone_${a}`);return l});t.push(...s),sI(this.audioTracks,i,o,a),sI(this.subtitleTracks,n,o,a)}})}}},{key:"loadSteeringManifest",value:function(e){var t,i=this.hls.config,n=i.loader;this.loader&&this.loader.destroy(),this.loader=new n(i);try{t=new self.URL(e)}catch(t){return this.enabled=!1,void this.log(`Failed to parse Steering Manifest URI: ${e}`)}if("data:"!==t.protocol){var a=0|(this.hls.bandwidthEstimate||i.abrEwmaDefaultEstimate);t.searchParams.set("_HLS_pathway",this.pathwayId),t.searchParams.set("_HLS_throughput",""+a)}var r={responseType:"json",url:t.href},o=i.steeringManifestLoadPolicy.default,s=o.errorRetry||o.timeoutRetry||{},u={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:s.maxNumRetry||0,retryDelay:s.retryDelayMs||0,maxRetryDelay:s.maxRetryDelayMs||0},l={onSuccess:(e,i,n,a)=>{this.log(`Loaded steering manifest: "${t}"`);var r=e.data;if(1===(null==r?void 0:r.VERSION)){this.updated=performance.now(),this.timeToLoad=r.TTL;var o=r["RELOAD-URI"],s=r["PATHWAY-CLONES"],u=r["PATHWAY-PRIORITY"];if(o)try{this.uri=new self.URL(o,t).href}catch(e){return this.enabled=!1,void this.log(`Failed to parse Steering Manifest RELOAD-URI: ${o}`)}this.scheduleRefresh(this.uri||n.url),s&&this.clonePathways(s);var l={steeringManifest:r,url:t.toString()};this.hls.trigger(UE.STEERING_MANIFEST_LOADED,l),u&&this.updatePathwayPriority(u)}else this.log(`Steering VERSION ${r.VERSION} not supported!`)},onError:(e,t,i,n)=>{if(this.log(`Error loading steering manifest: ${e.code} ${e.text} (${t.url})`),this.stopLoad(),410===e.code)return this.enabled=!1,void this.log(`Steering manifest ${t.url} no longer available`);var a=1e3*this.timeToLoad;if(429!==e.code)this.scheduleRefresh(this.uri||t.url,a);else{var r=this.loader;if("function"==typeof(null==r?void 0:r.getResponseHeader)){var o=r.getResponseHeader("Retry-After");o&&(a=1e3*parseFloat(o))}this.log(`Steering manifest ${t.url} rate limited`)}},onTimeout:(e,t,i)=>{this.log(`Timeout loading steering manifest (${t.url})`),this.scheduleRefresh(this.uri||t.url)}};this.log(`Requesting steering manifest: ${t}`),this.loader.load(r,u,l)}},{key:"scheduleRefresh",value:function(e,t=1e3*this.timeToLoad){this.clearTimeout(),this.reloadTimer=self.setTimeout(()=>{var t,i=null==(t=this.hls)?void 0:t.media;!i||i.ended?this.scheduleRefresh(e,1e3*this.timeToLoad):this.loadSteeringManifest(e)},t)}}])}();function sI(e,t,i,n){e&&Object.keys(t).forEach(a=>{var r=e.filter(e=>e.groupId===a).map(e=>{var r=eT({},e);return r.details=void 0,r.attrs=new VM(r.attrs),r.url=r.attrs.URI=uI(e.url,e.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",i),r.groupId=r.attrs["GROUP-ID"]=t[a],r.attrs["PATHWAY-ID"]=n,r});e.push(...r)})}function uI(e,t,i,n){var a,r=n.HOST,o=n.PARAMS,s=n[i];t&&(a=null==s?void 0:s[t])&&(e=a);var u=new self.URL(e);return r&&!a&&(u.host=r),o&&Object.keys(o).sort().forEach(e=>{e&&u.searchParams.set(e,o[e])}),u.href}var lI=function(){function e(t){var i;return u(this,e),(i=s(this,e,["eme",t.logger])).hls=void 0,i.config=void 0,i.media=null,i.mediaResolved=void 0,i.keyFormatPromise=null,i.keySystemAccessPromises={},i._requestLicenseFailureCount=0,i.mediaKeySessions=[],i.keyIdToKeySessionPromise={},i.mediaKeys=null,i.setMediaKeysQueue=e.CDMCleanupPromise?[e.CDMCleanupPromise]:[],i.bannedKeyIds={},i.onMediaEncrypted=e=>{var t=e.initDataType,n=e.initData,a=`"${e.type}" event: init data type: "${t}"`;if(i.debug(a),null!==n){if(!i.keyFormatPromise){var r=Object.keys(i.keySystemAccessPromises);r.length||(r=mA(i.config));var o=r.map(cA).filter(e=>!!e);i.keyFormatPromise=i.getKeyFormatPromise(o)}i.keyFormatPromise.then(r=>{var o=hA(r);if("sinf"===t&&o===oA.FAIRPLAY){var s;try{var u=OT(new Uint8Array(n)),l=qT(tA(JSON.parse(u).sinf));if(!l)throw new Error("'schm' box missing or not cbcs/cenc with schi > tenc");s=new Uint8Array(l.subarray(8,24))}catch(e){return void i.warn(`${a} Failed to parse sinf: ${e}`)}for(var d,h=mT(s),c=i,m=c.keyIdToKeySessionPromise,f=c.mediaKeySessions,v=m[h],p=function(){var e=f[g],a=e.decryptdata;if(!a.keyId)return 0;var r=mT(a.keyId);return JM(s,a.keyId)||-1!==a.uri.replace(/-/g,"").indexOf(h)?(v=m[r])?(a.pssh||(delete m[r],a.pssh=new Uint8Array(n),a.keyId=s,(v=m[h]=v.then(()=>i.generateRequestWithPreferredKeySession(e,t,n,"encrypted-event-key-match"))).catch(e=>i.handleError(e))),1):0:void 0},g=0;g<f.length&&(0===(d=p())||1!==d);g++);v||i.handleError(new Error(`Key ID ${h} not encountered in playlist. Key-system sessions ${f.length}.`))}else i.log(`Ignoring "${e.type}" event with init data type: "${t}" for selected key-system ${o}`)}).catch(e=>i.handleError(e))}},i.onWaitingForKey=e=>{i.log(`"${e.type}" event`)},i.hls=t,i.config=t.config,i.registerListeners(),i}return y(e,nT),m(e,[{key:"destroy",value:function(){this.onDestroying(),this.onMediaDetached();var e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.config=this.keyIdToKeySessionPromise=null,this.onMediaEncrypted=this.onWaitingForKey=null}},{key:"registerListeners",value:function(){this.hls.on(UE.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(UE.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(UE.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(UE.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.on(UE.DESTROYING,this.onDestroying,this)}},{key:"unregisterListeners",value:function(){this.hls.off(UE.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(UE.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(UE.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(UE.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.off(UE.DESTROYING,this.onDestroying,this)}},{key:"getLicenseServerUrl",value:function(e){var t=this.config,i=t.drmSystems,n=t.widevineLicenseUrl,a=null==i?void 0:i[e];return a?a.licenseUrl:e===oA.WIDEVINE&&n?n:void 0}},{key:"getLicenseServerUrlOrThrow",value:function(e){var t=this.getLicenseServerUrl(e);if(void 0===t)throw new Error(`no license server URL configured for key-system "${e}"`);return t}},{key:"getServerCertificateUrl",value:function(e){var t=this.config.drmSystems,i=null==t?void 0:t[e];if(i)return i.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`)}},{key:"attemptKeySystemAccess",value:function(e){var t=this.hls.levels,i=(e,t,i)=>!!e&&i.indexOf(e)===t,n=t.map(e=>e.audioCodec).filter(i),a=t.map(e=>e.videoCodec).filter(i);return n.length+a.length===0&&a.push("avc1.42e01e"),new Promise((t,i)=>{var r=e=>{var o=e.shift();this.getMediaKeysPromise(o,n,a).then(e=>t({keySystem:o,mediaKeys:e})).catch(t=>{e.length?r(e):i(t instanceof cI?t:new cI({type:BE.KEY_SYSTEM_ERROR,details:zE.KEY_SYSTEM_NO_ACCESS,error:t,fatal:!0},t.message))})};r(e)})}},{key:"requestMediaKeySystemAccess",value:function(e,t){var i=this.config.requestMediaKeySystemAccessFunc;if("function"!=typeof i){var n=`Configured requestMediaKeySystemAccess is not a function ${i}`;return null===vA&&"http:"===self.location.protocol&&(n=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(n))}return i(e,t)}},{key:"getMediaKeysPromise",value:function(e,t,i){var n,a=function(e,t,i,n){var a;switch(e){case oA.FAIRPLAY:a=["cenc","sinf"];break;case oA.WIDEVINE:case oA.PLAYREADY:a=["cenc"];break;case oA.CLEARKEY:a=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${e}`)}return function(e,t,i,n){return[{initDataTypes:e,persistentState:n.persistentState||"optional",distinctiveIdentifier:n.distinctiveIdentifier||"optional",sessionTypes:n.sessionTypes||[n.sessionType||"temporary"],audioCapabilities:t.map(e=>({contentType:`audio/mp4; codecs=${e}`,robustness:n.audioRobustness||"",encryptionScheme:n.audioEncryptionScheme||null})),videoCapabilities:i.map(e=>({contentType:`video/mp4; codecs=${e}`,robustness:n.videoRobustness||"",encryptionScheme:n.videoEncryptionScheme||null}))}]}(a,t,i,n)}(e,t,i,this.config.drmSystemOptions||{}),r=this.keySystemAccessPromises[e],o=null==(n=r)?void 0:n.keySystemAccess;if(!o){this.log(`Requesting encrypted media "${e}" key-system access with config: ${WP(a)}`),o=this.requestMediaKeySystemAccess(e,a);var s=r=this.keySystemAccessPromises[e]={keySystemAccess:o};return o.catch(t=>{this.log(`Failed to obtain access to key-system "${e}": ${t}`)}),o.then(t=>{this.log(`Access for key-system "${t.keySystem}" obtained`);var i=this.fetchServerCertificate(e);this.log(`Create media-keys for "${e}"`);var n=s.mediaKeys=t.createMediaKeys().then(t=>(this.log(`Media-keys created for "${e}"`),s.hasMediaKeys=!0,i.then(i=>i?this.setMediaKeysServerCertificate(t,e,i):t)));return n.catch(t=>{this.error(`Failed to create media-keys for "${e}"}: ${t}`)}),n})}return o.then(()=>r.mediaKeys)}},{key:"createMediaKeySessionContext",value:function({decryptdata:e,keySystem:t,mediaKeys:i}){this.log(`Creating key-system session "${t}" keyId: ${mT(e.keyId||[])} keyUri: ${e.uri}`);var n=i.createSession(),a={decryptdata:e,keySystem:t,mediaKeys:i,mediaKeysSession:n,keyStatus:"status-pending"};return this.mediaKeySessions.push(a),a}},{key:"renewKeySession",value:function(e){var t=e.decryptdata;if(t.pssh){var i=this.createMediaKeySessionContext(e),n=dI(t);this.keyIdToKeySessionPromise[n]=this.generateRequestWithPreferredKeySession(i,"cenc",t.pssh.buffer,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)}},{key:"updateKeySession",value:function(e,t){var i=e.mediaKeysSession;return this.log(`Updating key-session "${i.sessionId}" for keyId ${mT(e.decryptdata.keyId||[])}\n } (data length: ${t.byteLength})`),i.update(t)}},{key:"getSelectedKeySystemFormats",value:function(){return Object.keys(this.keySystemAccessPromises).map(e=>({keySystem:e,hasMediaKeys:this.keySystemAccessPromises[e].hasMediaKeys})).filter(({hasMediaKeys:e})=>!!e).map(({keySystem:e})=>cA(e)).filter(e=>!!e)}},{key:"getKeySystemAccess",value:function(e){return this.getKeySystemSelectionPromise(e).then(({keySystem:e,mediaKeys:t})=>this.attemptSetMediaKeys(e,t))}},{key:"selectKeySystem",value:function(e){return new Promise((t,i)=>{this.getKeySystemSelectionPromise(e).then(({keySystem:e})=>{var n=cA(e);n?t(n):i(new Error(`Unable to find format for key-system "${e}"`))}).catch(i)})}},{key:"selectKeySystemFormat",value:function(e){var t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${e.sn} ${e.type}: ${e.level}) key formats ${t.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise}},{key:"getKeyFormatPromise",value:function(e){var t=mA(this.config),i=e.map(hA).filter(e=>!!e&&-1!==t.indexOf(e));return this.selectKeySystem(i)}},{key:"getKeyStatus",value:function(e){for(var t=this.mediaKeySessions,i=0;i<t.length;i++){var n=hI(e,t[i]);if(n)return n}}},{key:"loadKey",value:function(e){var t=e.keyInfo.decryptdata,i=dI(t),n=this.bannedKeyIds[i];if(n||"internal-error"===this.getKeyStatus(t)){var a=mI(n||"internal-error",t);return this.handleError(a,e.frag),Promise.reject(a)}var r=`(keyId: ${i} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${r}`);var o=this.keyIdToKeySessionPromise[i];if(!o){var s=this.getKeySystemForKeyPromise(t).then(({keySystem:i,mediaKeys:n})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${r}`),this.attemptSetMediaKeys(i,n).then(()=>(this.throwIfDestroyed(),this.createMediaKeySessionContext({keySystem:i,mediaKeys:n,decryptdata:t}))))).then(e=>{var i=t.pssh?t.pssh.buffer:null;return this.generateRequestWithPreferredKeySession(e,"cenc",i,"playlist-key")});return s.catch(t=>this.handleError(t,e.frag)),this.keyIdToKeySessionPromise[i]=s,s}return o.catch(i=>{if(i instanceof cI){var n=iT({},i.data);"internal-error"===this.getKeyStatus(t)&&(n.decryptdata=t);var a=new cI(n,i.message);this.handleError(a,e.frag)}}),o}},{key:"throwIfDestroyed",value:function(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}},{key:"handleError",value:function(e,t){if(this.hls)if(e instanceof cI){t&&(e.data.frag=t);var i=e.data.decryptdata;this.error(`${e.message}${i?` (${mT(i.keyId||[])})`:""}`),this.hls.trigger(UE.ERROR,e.data)}else this.error(e.message),this.hls.trigger(UE.ERROR,{type:BE.KEY_SYSTEM_ERROR,details:zE.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0})}},{key:"getKeySystemForKeyPromise",value:function(e){var t=dI(e),i=this.keyIdToKeySessionPromise[t];if(!i){var n=hA(e.keyFormat),a=n?[n]:mA(this.config);return this.attemptKeySystemAccess(a)}return i}},{key:"getKeySystemSelectionPromise",value:function(e){if(e.length||(e=mA(this.config)),0===e.length)throw new cI({type:BE.KEY_SYSTEM_ERROR,details:zE.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${WP({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}},{key:"attemptSetMediaKeys",value:function(e,t){if(this.mediaResolved=void 0,this.mediaKeys===t)return Promise.resolve();var i=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);var n=Promise.all(i).then(()=>this.media?this.media.setMediaKeys(t):new Promise((e,i)=>{this.mediaResolved=()=>{if(this.mediaResolved=void 0,!this.media)return i(new Error("Attempted to set mediaKeys without media element attached"));this.mediaKeys=t,this.media.setMediaKeys(t).then(e).catch(i)}}));return this.mediaKeys=t,this.setMediaKeysQueue.push(n),n.then(()=>{this.log(`Media-keys set for "${e}"`),i.push(n),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(e=>-1===i.indexOf(e))})}},{key:"generateRequestWithPreferredKeySession",value:function(e,t,i,n){var a,r=null==(a=this.config.drmSystems)||null==(a=a[e.keySystem])?void 0:a.generateRequest;if(r)try{var o=r.call(this.hls,t,i,e);if(!o)throw new Error("Invalid response from configured generateRequest filter");t=o.initDataType,i=o.initData?o.initData:null,e.decryptdata.pssh=i?new Uint8Array(i):null}catch(e){if(this.warn(e.message),this.hls&&this.hls.config.debug)throw e}if(null===i)return this.log(`Skipping key-session request for "${n}" (no initData)`),Promise.resolve(e);var s=dI(e.decryptdata),u=e.decryptdata.uri;this.log(`Generating key-session request for "${n}" keyId: ${s} URI: ${u} (init data type: ${t} length: ${i.byteLength})`);var l=new SD,d=e._onmessage=t=>{var i=e.mediaKeysSession;if(i){var n=t.messageType,a=t.message;this.log(`"${n}" message event for session "${i.sessionId}" message size: ${a.byteLength}`),"license-request"===n||"license-renewal"===n?this.renewLicense(e,a).catch(e=>{l.eventNames().length?l.emit("error",e):this.handleError(e)}):"license-release"===n?e.keySystem===oA.FAIRPLAY&&this.updateKeySession(e,iA("acknowledged")).then(()=>this.removeSession(e)).catch(e=>this.handleError(e)):this.warn(`unhandled media key message type "${n}"`)}else l.emit("error",new Error("invalid state"))},h=(e,t)=>{var i;t.keyStatus=e,e.startsWith("usable")?l.emit("resolved"):"internal-error"===e||"output-restricted"===e||"output-downscaled"===e?i=mI(e,t.decryptdata):"expired"===e?i=new Error(`key expired (keyId: ${s})`):"released"===e?i=new Error("key released"):"status-pending"===e||this.warn(`unhandled key status change "${e}" (keyId: ${s})`),i&&(l.eventNames().length?l.emit("error",i):this.handleError(i))},c=e._onkeystatuseschange=t=>{if(e.mediaKeysSession){var i=this.getKeyStatuses(e);if(Object.keys(i).some(e=>"status-pending"!==i[e])){if("expired"===i[s])return this.log(`Expired key ${WP(i)} in key-session "${e.mediaKeysSession.sessionId}"`),void this.renewKeySession(e);var n=i[s];if(n)h(n,e);else{var a;e.keyStatusTimeouts||(e.keyStatusTimeouts={}),(a=e.keyStatusTimeouts)[s]||(a[s]=self.setTimeout(()=>{if(e.mediaKeysSession&&this.mediaKeys){var t=this.getKeyStatus(e.decryptdata);if(t&&"status-pending"!==t)return this.log(`No status for keyId ${s} in key-session "${e.mediaKeysSession.sessionId}". Using session key-status ${t} from other session.`),h(t,e);this.log(`key status for ${s} in key-session "${e.mediaKeysSession.sessionId}" timed out after 1000ms`),h(n="internal-error",e)}},1e3)),this.log(`No status for keyId ${s} (${WP(i)}).`)}}}else l.emit("error",new Error("invalid state"))};tD(e.mediaKeysSession,"message",d),tD(e.mediaKeysSession,"keystatuseschange",c);var m=new Promise((e,t)=>{l.on("error",t),l.on("resolved",e)});return e.mediaKeysSession.generateRequest(t,i).then(()=>{this.log(`Request generated for key-session "${e.mediaKeysSession.sessionId}" keyId: ${s} URI: ${u}`)}).catch(t=>{throw new cI({type:BE.KEY_SYSTEM_ERROR,details:zE.KEY_SYSTEM_NO_SESSION,error:t,decryptdata:e.decryptdata,fatal:!1},`Error generating key-session request: ${t}`)}).then(()=>m).catch(t=>(l.removeAllListeners(),this.removeSession(e).then(()=>{throw t}))).then(()=>(l.removeAllListeners(),e))}},{key:"getKeyStatuses",value:function(e){var t={};return e.mediaKeysSession.keyStatuses.forEach((i,n)=>{if("string"==typeof n&&"object"==typeof i){var a=n;n=i,i=a}var r="buffer"in n?new Uint8Array(n.buffer,n.byteOffset,n.byteLength):new Uint8Array(n);if(e.keySystem===oA.PLAYREADY&&16===r.length){var o=mT(r);t[o]=i,nA(r)}var s=mT(r);"internal-error"===i&&(this.bannedKeyIds[s]=i),this.log(`key status change "${i}" for keyStatuses keyId: ${s} key-session "${e.mediaKeysSession.sessionId}"`),t[s]=i}),t}},{key:"fetchServerCertificate",value:function(e){var t=this.config,i=new(0,t.loader)(t),n=this.getServerCertificateUrl(e);return n?(this.log(`Fetching server certificate for "${e}"`),new Promise((a,r)=>{var o={responseType:"arraybuffer",url:n},s=t.certLoadPolicy.default,u={loadPolicy:s,timeout:s.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},l={onSuccess:(e,t,i,n)=>{a(e.data)},onError:(t,i,a,s)=>{r(new cI({type:BE.KEY_SYSTEM_ERROR,details:zE.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:a,response:iT({url:o.url,data:void 0},t)},`"${e}" certificate request failed (${n}). Status: ${t.code} (${t.text})`))},onTimeout:(t,i,a)=>{r(new cI({type:BE.KEY_SYSTEM_ERROR,details:zE.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:a,response:{url:o.url,data:void 0}},`"${e}" certificate request timed out (${n})`))},onAbort:(e,t,i)=>{r(new Error("aborted"))}};i.load(o,u,l)})):Promise.resolve()}},{key:"setMediaKeysServerCertificate",value:function(e,t,i){return new Promise((n,a)=>{e.setServerCertificate(i).then(a=>{this.log(`setServerCertificate ${a?"success":"not supported by CDM"} (${i.byteLength}) on "${t}"`),n(e)}).catch(e=>{a(new cI({type:BE.KEY_SYSTEM_ERROR,details:zE.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:e,fatal:!0},e.message))})})}},{key:"renewLicense",value:function(e,t){return this.requestLicense(e,new Uint8Array(t)).then(t=>this.updateKeySession(e,new Uint8Array(t)).catch(t=>{throw new cI({type:BE.KEY_SYSTEM_ERROR,details:zE.KEY_SYSTEM_SESSION_UPDATE_FAILED,decryptdata:e.decryptdata,error:t,fatal:!1},t.message)}))}},{key:"unpackPlayReadyKeyMessage",value:function(e,t){var i=String.fromCharCode.apply(null,new Uint16Array(t.buffer));if(!i.includes("PlayReadyKeyMessage"))return e.setRequestHeader("Content-Type","text/xml; charset=utf-8"),t;var n=(new DOMParser).parseFromString(i,"application/xml"),a=n.querySelectorAll("HttpHeader");if(a.length>0)for(var r,o=0,s=a.length;o<s;o++){var u,l,d=null==(u=(r=a[o]).querySelector("name"))?void 0:u.textContent,h=null==(l=r.querySelector("value"))?void 0:l.textContent;d&&h&&e.setRequestHeader(d,h)}var c=n.querySelector("Challenge"),m=null==c?void 0:c.textContent;if(!m)throw new Error("Cannot find <Challenge> in key message");return iA(atob(m))}},{key:"setupLicenseXHR",value:function(e,t,i,n){var a=this.config.licenseXhrSetup;return a?Promise.resolve().then(()=>{if(!i.decryptdata)throw new Error("Key removed");return a.call(this.hls,e,t,i,n)}).catch(r=>{if(!i.decryptdata)throw r;return e.open("POST",t,!0),a.call(this.hls,e,t,i,n)}).then(i=>(e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:i||n})):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:n}))}},{key:"requestLicense",value:function(e,t){var i=this.config.keyLoadPolicy.default;return new Promise((n,a)=>{var r=this.getLicenseServerUrlOrThrow(e.keySystem);this.log(`Sending license request to URL: ${r}`);var o=new XMLHttpRequest;o.responseType="arraybuffer",o.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return a(new Error("invalid state"));if(4===o.readyState)if(200===o.status){this._requestLicenseFailureCount=0;var s=o.response;this.log(`License received ${s instanceof ArrayBuffer?s.byteLength:s}`);var u=this.config.licenseResponseCallback;if(u)try{s=u.call(this.hls,o,r,e)}catch(e){this.error(e)}n(s)}else{var l=i.errorRetry,d=l?l.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>d||o.status>=400&&o.status<500)a(new cI({type:BE.KEY_SYSTEM_ERROR,details:zE.KEY_SYSTEM_LICENSE_REQUEST_FAILED,decryptdata:e.decryptdata,fatal:!0,networkDetails:o,response:{url:r,data:void 0,code:o.status,text:o.statusText}},`License Request XHR failed (${r}). Status: ${o.status} (${o.statusText})`));else{var h=d-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${h} attempts left`),this.requestLicense(e,t).then(n,a)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=o,this.setupLicenseXHR(o,r,e,t).then(({xhr:t,licenseChallenge:i})=>{e.keySystem==oA.PLAYREADY&&(i=this.unpackPlayReadyKeyMessage(t,i)),t.send(i)}).catch(a)})}},{key:"onDestroying",value:function(){this.unregisterListeners(),this._clear()}},{key:"onMediaAttached",value:function(e,t){if(this.config.emeEnabled){var i=t.media;this.media=i,tD(i,"encrypted",this.onMediaEncrypted),tD(i,"waitingforkey",this.onWaitingForKey);var n=this.mediaResolved;n?n():this.mediaKeys=i.mediaKeys}}},{key:"onMediaDetached",value:function(){var e=this.media;e&&(iD(e,"encrypted",this.onMediaEncrypted),iD(e,"waitingforkey",this.onWaitingForKey),this.media=null,this.mediaKeys=null)}},{key:"_clear",value:function(){var t;this._requestLicenseFailureCount=0,this.keyIdToKeySessionPromise={},this.bannedKeyIds={};var i=this.mediaResolved;if(i&&i(),this.mediaKeys||this.mediaKeySessions.length){var n=this.media,a=this.mediaKeySessions.slice();this.mediaKeySessions=[],this.mediaKeys=null,yA.clearKeyUriToKeyIdMap();var r=a.length;e.CDMCleanupPromise=Promise.all(a.map(e=>this.removeSession(e)).concat((null==n||null==(t=n.setMediaKeys(null))?void 0:t.catch(e=>{this.log(`Could not clear media keys: ${e}`),this.hls&&this.hls.trigger(UE.ERROR,{type:BE.OTHER_ERROR,details:zE.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR,fatal:!1,error:new Error(`Could not clear media keys: ${e}`)})}))||Promise.resolve())).catch(e=>{this.log(`Could not close sessions and clear media keys: ${e}`),this.hls&&this.hls.trigger(UE.ERROR,{type:BE.OTHER_ERROR,details:zE.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close sessions and clear media keys: ${e}`)})}).then(()=>{r&&this.log("finished closing key sessions and clearing media keys")})}}},{key:"onManifestLoading",value:function(){this._clear()}},{key:"onManifestLoaded",value:function(e,{sessionKeys:t}){if(t&&this.config.emeEnabled&&!this.keyFormatPromise){var i=t.reduce((e,t)=>(-1===e.indexOf(t.keyFormat)&&e.push(t.keyFormat),e),[]);this.log(`Selecting key-system from session-keys ${i.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(i)}}},{key:"removeSession",value:function(e){var t=e.mediaKeysSession,i=e.licenseXhr,n=e.decryptdata;if(t){this.log(`Remove licenses and keys and close session "${t.sessionId}" keyId: ${mT((null==n?void 0:n.keyId)||[])}`),e._onmessage&&(t.removeEventListener("message",e._onmessage),e._onmessage=void 0),e._onkeystatuseschange&&(t.removeEventListener("keystatuseschange",e._onkeystatuseschange),e._onkeystatuseschange=void 0),i&&i.readyState!==XMLHttpRequest.DONE&&i.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;var a=this.mediaKeySessions.indexOf(e);a>-1&&this.mediaKeySessions.splice(a,1);var r=e.keyStatusTimeouts;r&&Object.keys(r).forEach(e=>self.clearTimeout(r[e]));var o=function(e){var t;return!(!e||"persistent-license"!==e.sessionType&&(null==(t=e.sessionTypes)||!t.some(e=>"persistent-license"===e)))}(this.config.drmSystemOptions)?new Promise((e,i)=>{self.setTimeout(()=>i(new Error("MediaKeySession.remove() timeout")),8e3),t.remove().then(e).catch(i)}):Promise.resolve();return o.catch(e=>{this.log(`Could not remove session: ${e}`),this.hls&&this.hls.trigger(UE.ERROR,{type:BE.OTHER_ERROR,details:zE.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR,fatal:!1,error:new Error(`Could not remove session: ${e}`)})}).then(()=>t.close()).catch(e=>{this.log(`Could not close session: ${e}`),this.hls&&this.hls.trigger(UE.ERROR,{type:BE.OTHER_ERROR,details:zE.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close session: ${e}`)})})}return Promise.resolve()}}])}();function dI(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(null===e.keyId)throw new Error("keyId is null");return mT(e.keyId)}function hI(e,t){return e.keyId&&t.mediaKeysSession.keyStatuses.has(e.keyId)?t.mediaKeysSession.keyStatuses.get(e.keyId):e.matches(t.decryptdata)?t.keyStatus:void 0}lI.CDMCleanupPromise=void 0;var cI=function(){function e(t,i){var n;return u(this,e),(n=s(this,e,[i])).data=void 0,t.error||(t.error=new Error(i)),n.data=t,t.err=t.error,n}return y(e,D(Error)),m(e)}();function mI(e,t){var i="output-restricted"===e,n=i?zE.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:zE.KEY_SYSTEM_STATUS_INTERNAL_ERROR;return new cI({type:BE.KEY_SYSTEM_ERROR,details:n,fatal:!1,decryptdata:t},i?"HDCP level output restricted":`key status changed to "${e}"`)}var fI=function(){return m(function e(t){u(this,e),this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=t,this.registerListeners()},[{key:"setStreamController",value:function(e){this.streamController=e}},{key:"registerListeners",value:function(){this.hls.on(UE.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.on(UE.MEDIA_DETACHING,this.onMediaDetaching,this)}},{key:"unregisterListeners",value:function(){this.hls.off(UE.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off(UE.MEDIA_DETACHING,this.onMediaDetaching,this)}},{key:"destroy",value:function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}},{key:"onMediaAttaching",value:function(e,t){var i=this.hls.config;if(i.capLevelOnFPSDrop){var n=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=n,n&&"function"==typeof n.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),i.fpsDroppedMonitoringPeriod)}}},{key:"onMediaDetaching",value:function(){this.media=null}},{key:"checkFPS",value:function(e,t,i){var n=performance.now();if(t){if(this.lastTime){var a=n-this.lastTime,r=i-this.lastDroppedFrames,o=t-this.lastDecodedFrames,s=1e3*r/a,u=this.hls;if(u.trigger(UE.FPS_DROP,{currentDropped:r,currentDecoded:o,totalDroppedFrames:i}),s>0&&r>u.config.fpsDroppedMonitoringThreshold*o){var l=u.currentLevel;u.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+l),l>0&&(-1===u.autoLevelCapping||u.autoLevelCapping>=l)&&(l-=1,u.trigger(UE.FPS_DROP_LEVEL_CAPPING,{level:l,droppedLevel:u.currentLevel}),u.autoLevelCapping=l,this.streamController.nextLevelSwitch())}}this.lastTime=n,this.lastDroppedFrames=i,this.lastDecodedFrames=t}}},{key:"checkFPSInterval",value:function(){var e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){var t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}}])}();function vI(e,t){var i;try{i=new Event("addtrack")}catch(e){(i=document.createEvent("Event")).initEvent("addtrack",!1,!1)}i.track=e,t.dispatchEvent(i)}function pI(e,t){var i=e.mode;if("disabled"===i&&(e.mode="hidden"),e.cues&&!e.cues.getCueById(t.id))try{if(e.addCue(t),!e.cues.getCueById(t.id))throw new Error(`addCue is failed for: ${t}`)}catch(i){lT.debug(`[texttrack-utils]: ${i}`);try{var n=new self.TextTrackCue(t.startTime,t.endTime,t.text);n.id=t.id,e.addCue(n)}catch(e){lT.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${e}`)}}"disabled"===i&&(e.mode=i)}function gI(e,t){var i=e.mode;if("disabled"===i&&(e.mode="hidden"),e.cues)for(var n=e.cues.length;n--;)t&&e.cues[n].removeEventListener("enter",t),e.removeCue(e.cues[n]);"disabled"===i&&(e.mode=i)}function yI(e,t,i,n){var a=e.mode;if("disabled"===a&&(e.mode="hidden"),e.cues&&e.cues.length>0)for(var r=function(e,t,i){var n=[],a=function(e,t){if(t<=e[0].startTime)return 0;var i=e.length-1;if(t>e[i].endTime)return-1;var n,a=0,r=i;for(;a<=r;)if(t<e[n=Math.floor((r+a)/2)].startTime)r=n-1;else{if(!(t>e[n].startTime&&a<i))return n;a=n+1}return e[a].startTime-t<t-e[r].startTime?a:r}(e,t);if(a>-1)for(var r=a,o=e.length;r<o;r++){var s=e[r];if(s.startTime>=t&&s.endTime<=i)n.push(s);else if(s.startTime>i)return n}return n}(e.cues,t,i),o=0;o<r.length;o++)n&&!n(r[o])||e.removeCue(r[o]);"disabled"===a&&(e.mode=a)}function bI(e){for(var t=[],i=0;i<e.length;i++){var n=e[i];"subtitles"!==n.kind&&"captions"!==n.kind||!n.label||t.push(e[i])}return t}var wI=function(){function e(t){var i;return u(this,e),(i=s(this,e,[t,"subtitle-track-controller"])).media=null,i.tracks=[],i.groupIds=null,i.tracksInGroup=[],i.trackId=-1,i.currentTrack=null,i.selectDefaultTrack=!0,i.queuedDefaultTrack=-1,i.useTextTrackPolling=!1,i.subtitlePollingInterval=-1,i._subtitleDisplay=!0,i.asyncPollTrackChange=()=>i.pollTrackChange(0),i.onTextTracksChanged=()=>{if(i.useTextTrackPolling||self.clearInterval(i.subtitlePollingInterval),i.media&&i.hls.config.renderTextTracksNatively){for(var e=null,t=bI(i.media.textTracks),n=0;n<t.length;n++)if("hidden"===t[n].mode)e=t[n];else if("showing"===t[n].mode){e=t[n];break}var a=i.findTrackForTextTrack(e);i.subtitleTrack!==a&&i.setSubtitleTrack(a)}},i.registerListeners(),i}return y(e,Zx),m(e,[{key:"destroy",value:function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,this.onTextTracksChanged=this.asyncPollTrackChange=null,M(e,"destroy",this)([])}},{key:"subtitleDisplay",get:function(){return this._subtitleDisplay},set:function(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes()}},{key:"registerListeners",value:function(){var e=this.hls;e.on(UE.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(UE.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(UE.MANIFEST_LOADING,this.onManifestLoading,this),e.on(UE.MANIFEST_PARSED,this.onManifestParsed,this),e.on(UE.LEVEL_LOADING,this.onLevelLoading,this),e.on(UE.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(UE.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(UE.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(UE.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(UE.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(UE.MANIFEST_LOADING,this.onManifestLoading,this),e.off(UE.MANIFEST_PARSED,this.onManifestParsed,this),e.off(UE.LEVEL_LOADING,this.onLevelLoading,this),e.off(UE.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(UE.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(UE.ERROR,this.onError,this)}},{key:"onMediaAttached",value:function(e,t){this.media=t.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))}},{key:"pollTrackChange",value:function(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.onTextTracksChanged,e)}},{key:"onMediaDetaching",value:function(e,t){var i=this.media;if(i){var n=!!t.transferMedia;if(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||i.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),this.subtitleTrack=-1,this.media=null,!n)bI(i.textTracks).forEach(e=>{gI(e)})}}},{key:"onManifestLoading",value:function(){this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}},{key:"onManifestParsed",value:function(e,t){this.tracks=t.subtitleTracks}},{key:"onSubtitleTrackLoaded",value:function(e,t){var i=t.id,n=t.groupId,a=t.details,r=this.tracksInGroup[i];if(r&&r.groupId===n){var o=r.details;r.details=t.details,this.log(`Subtitle track ${i} "${r.name}" lang:${r.lang} group:${n} loaded [${a.startSN}-${a.endSN}]`),i===this.trackId&&this.playlistLoaded(i,t,o)}else this.warn(`Subtitle track with id:${i} and group:${n} not found in active group ${null==r?void 0:r.groupId}`)}},{key:"onLevelLoading",value:function(e,t){this.switchLevel(t.level)}},{key:"onLevelSwitching",value:function(e,t){this.switchLevel(t.level)}},{key:"switchLevel",value:function(e){var t=this.hls.levels[e];if(t){var i=t.subtitleGroups||null,n=this.groupIds,a=this.currentTrack;if(!i||(null==n?void 0:n.length)!==(null==i?void 0:i.length)||null!=i&&i.some(e=>-1===(null==n?void 0:n.indexOf(e)))){this.groupIds=i,this.trackId=-1,this.currentTrack=null;var r=this.tracks.filter(e=>!i||-1!==i.indexOf(e.groupId));if(r.length)this.selectDefaultTrack&&!r.some(e=>e.default)&&(this.selectDefaultTrack=!1),r.forEach((e,t)=>{e.id=t});else if(!a&&!this.tracksInGroup.length)return;this.tracksInGroup=r;var o=this.hls.config.subtitlePreference;if(!a&&o){this.selectDefaultTrack=!1;var s=BP(o,r);if(s>-1)a=r[s];else{var u=BP(o,this.tracks);a=this.tracks[u]}}var l=this.findTrackId(a);-1===l&&a&&(l=this.findTrackId(null));var d={subtitleTracks:r};this.log(`Updating subtitle tracks, ${r.length} track(s) found in "${null==i?void 0:i.join(",")}" group-id`),this.hls.trigger(UE.SUBTITLE_TRACKS_UPDATED,d),-1!==l&&-1===this.trackId&&this.setSubtitleTrack(l)}}}},{key:"findTrackId",value:function(e){for(var t=this.tracksInGroup,i=this.selectDefaultTrack,n=0;n<t.length;n++){var a=t[n];if((!i||a.default)&&(i||e)&&(!e||zP(a,e)))return n}if(e){for(var r=0;r<t.length;r++){var o=t[r];if(tC(e.attrs,o.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return r}for(var s=0;s<t.length;s++){var u=t[s];if(tC(e.attrs,u.attrs,["LANGUAGE"]))return s}}return-1}},{key:"findTrackForTextTrack",value:function(e){if(e)for(var t=this.tracksInGroup,i=0;i<t.length;i++){if(iC(t[i],e))return i}return-1}},{key:"onError",value:function(e,t){!t.fatal&&t.context&&(t.context.type!==KE||t.context.id!==this.trackId||this.groupIds&&-1===this.groupIds.indexOf(t.context.groupId)||this.checkRetry(t))}},{key:"allSubtitleTracks",get:function(){return this.tracks}},{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(e){this.selectDefaultTrack=!1,this.setSubtitleTrack(e)}},{key:"setSubtitleOption",value:function(e){if(this.hls.config.subtitlePreference=e,e){if(-1===e.id)return this.setSubtitleTrack(-1),null;var t=this.allSubtitleTracks;if(this.selectDefaultTrack=!1,t.length){var i=this.currentTrack;if(i&&zP(e,i))return i;var n=BP(e,this.tracksInGroup);if(n>-1){var a=this.tracksInGroup[n];return this.setSubtitleTrack(n),a}if(i)return null;var r=BP(e,t);if(r>-1)return t[r]}}return null}},{key:"loadPlaylist",value:function(t){M(e,"loadPlaylist",this)([]),this.shouldLoadPlaylist(this.currentTrack)&&this.scheduleLoading(this.currentTrack,t)}},{key:"loadingPlaylist",value:function(t,i){M(e,"loadingPlaylist",this)([t,i]);var n=t.id,a=t.groupId,r=this.getUrlWithDirectives(t.url,i),o=t.details,s=null==o?void 0:o.age;this.log(`Loading subtitle ${n} "${t.name}" lang:${t.lang} group:${a}${void 0!==(null==i?void 0:i.msn)?" at sn "+i.msn+" part "+i.part:""}${s&&o.live?" age "+s.toFixed(1)+(o.type&&" "+o.type||""):""} ${r}`),this.hls.trigger(UE.SUBTITLE_TRACK_LOADING,{url:r,id:n,groupId:a,deliveryDirectives:i||null,track:t})}},{key:"toggleTrackModes",value:function(){var e=this.media;if(e){var t,i=bI(e.textTracks),n=this.currentTrack;if(n&&((t=i.filter(e=>iC(n,e))[0])||this.warn(`Unable to find subtitle TextTrack with name "${n.name}" and language "${n.lang}"`)),[].slice.call(i).forEach(e=>{"disabled"!==e.mode&&e!==t&&(e.mode="disabled")}),t){var a=this.subtitleDisplay?"showing":"hidden";t.mode!==a&&(t.mode=a)}}}},{key:"setSubtitleTrack",value:function(e){var t=this.tracksInGroup;if(this.media)if(e<-1||e>=t.length||!$E(e))this.warn(`Invalid subtitle track id: ${e}`);else{this.selectDefaultTrack=!1;var i=this.currentTrack,n=t[e]||null;if(this.trackId=e,this.currentTrack=n,this.toggleTrackModes(),n){var a=!!n.details&&!n.details.live;if(e!==this.trackId||n!==i||!a){this.log(`Switching to subtitle-track ${e}`+(n?` "${n.name}" lang:${n.lang} group:${n.groupId}`:""));var r=n.id,o=n.groupId,s=void 0===o?"":o,u=n.name,l=n.type,d=n.url;this.hls.trigger(UE.SUBTITLE_TRACK_SWITCH,{id:r,groupId:s,name:u,type:l,url:d});var h=this.switchParams(n.url,null==i?void 0:i.details,n.details);this.loadPlaylist(h)}}else this.hls.trigger(UE.SUBTITLE_TRACK_SWITCH,{id:e})}else this.queuedDefaultTrack=e}}])}();function kI(e){for(var t=5381,i=e.length;i;)t=33*t^e.charCodeAt(--i);return(t>>>0).toString()}var SI=.025,EI=function(e){return e[e.Point=0]="Point",e[e.Range=1]="Range",e}({});function TI(e,t,i){return`${e.identifier}-${i+1}-${kI(t)}`}var PI=function(){return m(function e(t,i){u(this,e),this.base=void 0,this._duration=null,this._timelineStart=null,this.appendInPlaceDisabled=void 0,this.appendInPlaceStarted=void 0,this.dateRange=void 0,this.hasPlayed=!1,this.cumulativeDuration=0,this.resumeOffset=NaN,this.playoutLimit=NaN,this.restrictions={skip:!1,jump:!1},this.snapOptions={out:!1,in:!1},this.assetList=[],this.assetListLoader=void 0,this.assetListResponse=null,this.resumeAnchor=void 0,this.error=void 0,this.resetOnResume=void 0,this.base=i,this.dateRange=t,this.setDateRange(t)},[{key:"setDateRange",value:function(e){this.dateRange=e,this.resumeOffset=e.attr.optionalFloat("X-RESUME-OFFSET",this.resumeOffset),this.playoutLimit=e.attr.optionalFloat("X-PLAYOUT-LIMIT",this.playoutLimit),this.restrictions=e.attr.enumeratedStringList("X-RESTRICT",this.restrictions),this.snapOptions=e.attr.enumeratedStringList("X-SNAP",this.snapOptions)}},{key:"reset",value:function(){var e;this.appendInPlaceStarted=!1,null==(e=this.assetListLoader)||e.destroy(),this.assetListLoader=void 0,this.supplementsPrimary||(this.assetListResponse=null,this.assetList=[],this._duration=null)}},{key:"isAssetPastPlayoutLimit",value:function(e){var t;if(e>0&&e>=this.assetList.length)return!0;var i=this.playoutLimit;return!(e<=0||isNaN(i))&&(0===i||((null==(t=this.assetList[e])?void 0:t.startOffset)||0)>i)}},{key:"findAssetIndex",value:function(e){return this.assetList.indexOf(e)}},{key:"identifier",get:function(){return this.dateRange.id}},{key:"startDate",get:function(){return this.dateRange.startDate}},{key:"startTime",get:function(){var e=this.dateRange.startTime;if(this.snapOptions.out){var t=this.dateRange.tagAnchor;if(t)return MI(e,t)}return e}},{key:"startOffset",get:function(){return this.cue.pre?0:this.startTime}},{key:"startIsAligned",get:function(){if(0===this.startTime||this.snapOptions.out)return!0;var e=this.dateRange.tagAnchor;if(e){var t=this.dateRange.startTime;return t-MI(t,e)<.1}return!1}},{key:"resumptionOffset",get:function(){var e=this.resumeOffset,t=$E(e)?e:this.duration;return this.cumulativeDuration+t}},{key:"resumeTime",get:function(){var e=this.startOffset+this.resumptionOffset;if(this.snapOptions.in){var t=this.resumeAnchor;if(t)return MI(e,t)}return e}},{key:"appendInPlace",get:function(){return!!this.appendInPlaceStarted||!this.appendInPlaceDisabled&&!(this.cue.once||this.cue.pre||!this.startIsAligned||!(isNaN(this.playoutLimit)&&isNaN(this.resumeOffset)||this.resumeOffset&&this.duration&&Math.abs(this.resumeOffset-this.duration)<SI))},set:function(e){this.appendInPlaceStarted?this.resetOnResume=!e:this.appendInPlaceDisabled=!e}},{key:"timelineStart",get:function(){return null!==this._timelineStart?this._timelineStart:this.startTime},set:function(e){this._timelineStart=e}},{key:"duration",get:function(){var e,t=this.playoutLimit;return e=null!==this._duration?this._duration:this.dateRange.duration?this.dateRange.duration:this.dateRange.plannedDuration||0,!isNaN(t)&&t<e&&(e=t),e},set:function(e){this._duration=e}},{key:"cue",get:function(){return this.dateRange.cue}},{key:"timelineOccupancy",get:function(){return"RANGE"===this.dateRange.attr["X-TIMELINE-OCCUPIES"]?EI.Range:EI.Point}},{key:"supplementsPrimary",get:function(){return"PRIMARY"===this.dateRange.attr["X-TIMELINE-STYLE"]}},{key:"contentMayVary",get:function(){return"NO"!==this.dateRange.attr["X-CONTENT-MAY-VARY"]}},{key:"assetUrl",get:function(){return this.dateRange.attr["X-ASSET-URI"]}},{key:"assetListUrl",get:function(){return this.dateRange.attr["X-ASSET-LIST"]}},{key:"baseUrl",get:function(){return this.base.url}},{key:"assetListLoaded",get:function(){return this.assetList.length>0||null!==this.assetListResponse}},{key:"toString",value:function(){return`["${(e=this).identifier}" ${e.cue.pre?"<pre>":e.cue.post?"<post>":""}${e.timelineStart.toFixed(2)}-${e.resumeTime.toFixed(2)}]`;var e}}])}();function MI(e,t){return e-t.start<t.duration/2&&!(Math.abs(e-(t.start+t.duration))<SI)?t.start:t.start+t.duration}function AI(e,t,i){var n=new self.URL(e,i);return"data:"!==n.protocol&&n.searchParams.set("_HLS_primary_id",t),n}function DI(e,t){for(;null!=(i=e.assetList[++t])&&i.error;)var i;return t}function xI(e){var t=e.timelineStart,i=e.duration||0;return`["${e.identifier}" ${t.toFixed(2)}-${(t+i).toFixed(2)}]`}var CI=function(){return m(function e(t,i,n,a){u(this,e),this.hls=void 0,this.interstitial=void 0,this.assetItem=void 0,this.tracks=null,this.hasDetails=!1,this.mediaAttached=null,this._currentTime=void 0,this._bufferedEosTime=void 0,this.checkPlayout=()=>{this.reachedPlayout(this.currentTime)&&this.hls&&this.hls.trigger(UE.PLAYOUT_LIMIT_REACHED,{})};var r=this.hls=new t(i);this.interstitial=n,this.assetItem=a;var o=()=>{this.hasDetails=!0};r.once(UE.LEVEL_LOADED,o),r.once(UE.AUDIO_TRACK_LOADED,o),r.once(UE.SUBTITLE_TRACK_LOADED,o),r.on(UE.MEDIA_ATTACHING,(e,{media:t})=>{this.removeMediaListeners(),this.mediaAttached=t,this.interstitial.playoutLimit&&(t.addEventListener("timeupdate",this.checkPlayout),this.appendInPlace&&r.on(UE.BUFFER_APPENDED,()=>{var e=this.bufferedEnd;this.reachedPlayout(e)&&(this._bufferedEosTime=e,r.trigger(UE.BUFFERED_TO_END,void 0))}))})},[{key:"appendInPlace",get:function(){return this.interstitial.appendInPlace}},{key:"loadSource",value:function(){var e=this.hls;if(e)if(e.url)e.levels.length&&!e.started&&e.startLoad(-1,!0);else{var t=this.assetItem.uri;try{t=AI(t,e.config.primarySessionId||"").href}catch(e){}e.loadSource(t)}}},{key:"bufferedInPlaceToEnd",value:function(e){var t;if(!this.appendInPlace)return!1;if(null!=(t=this.hls)&&t.bufferedToEnd)return!0;if(!e)return!1;var i=Math.min(this._bufferedEosTime||1/0,this.duration),n=this.timelineOffset,a=$M.bufferInfo(e,n,0);return this.getAssetTime(a.end)>=i-.02}},{key:"reachedPlayout",value:function(e){var t=this.interstitial.playoutLimit;return this.startOffset+e>=t}},{key:"destroyed",get:function(){var e;return!(null!=(e=this.hls)&&e.userConfig)}},{key:"assetId",get:function(){return this.assetItem.identifier}},{key:"interstitialId",get:function(){return this.assetItem.parentIdentifier}},{key:"media",get:function(){var e;return(null==(e=this.hls)?void 0:e.media)||null}},{key:"bufferedEnd",get:function(){var e=this.media||this.mediaAttached;if(!e)return this._bufferedEosTime?this._bufferedEosTime:this.currentTime;var t=$M.bufferInfo(e,e.currentTime,.001);return this.getAssetTime(t.end)}},{key:"currentTime",get:function(){var e=this.media||this.mediaAttached;return e?this.getAssetTime(e.currentTime):this._currentTime||0}},{key:"duration",get:function(){var e=this.assetItem.duration;if(!e)return 0;var t=this.interstitial.playoutLimit;if(t){var i=t-this.startOffset;if(i>0&&i<e)return i}return e}},{key:"remaining",get:function(){var e=this.duration;return e?Math.max(0,e-this.currentTime):0}},{key:"startOffset",get:function(){return this.assetItem.startOffset}},{key:"timelineOffset",get:function(){var e;return(null==(e=this.hls)?void 0:e.config.timelineOffset)||0},set:function(e){var t=this.timelineOffset;if(e!==t){var i=e-t;if(Math.abs(i)>1/9e4&&this.hls){if(this.hasDetails)throw new Error("Cannot set timelineOffset after playlists are loaded");this.hls.config.timelineOffset=e}}}},{key:"getAssetTime",value:function(e){var t=this.timelineOffset,i=this.duration;return Math.min(Math.max(0,e-t),i)}},{key:"removeMediaListeners",value:function(){var e=this.mediaAttached;e&&(this._currentTime=e.currentTime,this.bufferSnapShot(),e.removeEventListener("timeupdate",this.checkPlayout))}},{key:"bufferSnapShot",value:function(){var e;this.mediaAttached&&(null!=(e=this.hls)&&e.bufferedToEnd&&(this._bufferedEosTime=this.bufferedEnd))}},{key:"destroy",value:function(){this.removeMediaListeners(),this.hls&&this.hls.destroy(),this.hls=null,this.tracks=this.mediaAttached=this.checkPlayout=null}},{key:"attachMedia",value:function(e){var t;this.loadSource(),null==(t=this.hls)||t.attachMedia(e)}},{key:"detachMedia",value:function(){var e;this.removeMediaListeners(),this.mediaAttached=null,null==(e=this.hls)||e.detachMedia()}},{key:"resumeBuffering",value:function(){var e;null==(e=this.hls)||e.resumeBuffering()}},{key:"pauseBuffering",value:function(){var e;null==(e=this.hls)||e.pauseBuffering()}},{key:"transferMedia",value:function(){var e;return this.bufferSnapShot(),(null==(e=this.hls)?void 0:e.transferMedia())||null}},{key:"resetDetails",value:function(){var e=this.hls;if(e&&this.hasDetails){e.stopLoad();var t=e=>delete e.details;e.levels.forEach(t),e.allAudioTracks.forEach(t),e.allSubtitleTracks.forEach(t),this.hasDetails=!1}}},{key:"on",value:function(e,t,i){var n;null==(n=this.hls)||n.on(e,t)}},{key:"once",value:function(e,t,i){var n;null==(n=this.hls)||n.once(e,t)}},{key:"off",value:function(e,t,i){var n;null==(n=this.hls)||n.off(e,t)}},{key:"toString",value:function(){var e;return`HlsAssetPlayer: ${xI(this.assetItem)} ${null==(e=this.hls)?void 0:e.sessionId} ${this.appendInPlace?"append-in-place":""}`}}])}(),II=function(){function e(t,i){var n;return u(this,e),(n=s(this,e,["interstitials-sched",i])).onScheduleUpdate=void 0,n.eventMap={},n.events=null,n.items=null,n.durations={primary:0,playout:0,integrated:0},n.onScheduleUpdate=t,n}return y(e,nT),m(e,[{key:"destroy",value:function(){this.reset(),this.onScheduleUpdate=null}},{key:"reset",value:function(){this.eventMap={},this.setDurations(0,0,0),this.events&&this.events.forEach(e=>e.reset()),this.events=this.items=null}},{key:"resetErrorsInRange",value:function(e,t){return this.events?this.events.reduce((i,n)=>e<=n.startOffset&&t>n.startOffset?(delete n.error,i+1):i,0):0}},{key:"duration",get:function(){var e=this.items;return e?e[e.length-1].end:0}},{key:"length",get:function(){return this.items?this.items.length:0}},{key:"getEvent",value:function(e){return e&&this.eventMap[e]||null}},{key:"hasEvent",value:function(e){return e in this.eventMap}},{key:"findItemIndex",value:function(e,t){if(e.event)return this.findEventIndex(e.event.identifier);var i=-1;e.nextEvent?i=this.findEventIndex(e.nextEvent.identifier)-1:e.previousEvent&&(i=this.findEventIndex(e.previousEvent.identifier)+1);var n=this.items;if(n)for(n[i]||(void 0===t&&(t=e.start),i=this.findItemIndexAtTime(t));i>=0&&null!=(a=n[i])&&a.event;){var a;i--}return i}},{key:"findItemIndexAtTime",value:function(e,t){var i=this.items;if(i)for(var n=0;n<i.length;n++){var a=i[n];if(t&&"primary"!==t&&(a=a[t]),e===a.start||e>a.start&&e<a.end)return n}return-1}},{key:"findJumpRestrictedIndex",value:function(e,t){var i=this.items;if(i)for(var n=e;n<=t&&i[n];n++){var a=i[n].event;if(null!=a&&a.restrictions.jump&&!a.appendInPlace)return n}return-1}},{key:"findEventIndex",value:function(e){var t=this.items;if(t)for(var i=t.length;i--;){var n;if((null==(n=t[i].event)?void 0:n.identifier)===e)return i}return-1}},{key:"findAssetIndex",value:function(e,t){var i=e.assetList,n=i.length;if(n>1)for(var a=0;a<n;a++){var r=i[a];if(!r.error){var o=r.timelineStart;if(t===o||t>o&&(t<o+(r.duration||0)||a===n-1))return a}}return 0}},{key:"assetIdAtEnd",get:function(){var e,t=null==(e=this.items)||null==(e=e[this.length-1])?void 0:e.event;if(t){var i=t.assetList,n=i[i.length-1];if(n)return n.identifier}return null}},{key:"parseInterstitialDateRanges",value:function(e,t){var i=e.main.details,n=i.dateRanges,a=this.events,r=this.parseDateRanges(n,{url:i.url},t),o=Object.keys(n),s=a?a.filter(e=>!o.includes(e.identifier)):[];r.length&&r.sort((e,t)=>{var i=e.cue.pre,n=e.cue.post,a=t.cue.pre,r=t.cue.post;if(i&&!a)return-1;if(a&&!i)return 1;if(n&&!r)return 1;if(r&&!n)return-1;if(!(i||a||n||r)){var o=e.startTime,s=t.startTime;if(o!==s)return o-s}return e.dateRange.tagOrder-t.dateRange.tagOrder}),this.events=r,s.forEach(e=>{this.removeEvent(e)}),this.updateSchedule(e,s)}},{key:"updateSchedule",value:function(e,t=[],i=!1){var n=this.events||[];if(n.length||t.length||this.length<2){var a=this.items,r=this.parseSchedule(n,e),o=i||t.length||(null==a?void 0:a.length)!==r.length||r.some((e,t)=>Math.abs(e.playout.start-a[t].playout.start)>.005||Math.abs(e.playout.end-a[t].playout.end)>.005);o&&(this.items=r,this.onScheduleUpdate(t,a))}}},{key:"parseDateRanges",value:function(e,t,i){for(var n=[],a=Object.keys(e),r=0;r<a.length;r++){var o=a[r],s=e[o];if(s.isInterstitial){var u=this.eventMap[o];u?u.setDateRange(s):(u=new PI(s,t),this.eventMap[o]=u,!1===i&&(u.appendInPlace=i)),n.push(u)}}return n}},{key:"parseSchedule",value:function(e,t){var i=[],n=t.main.details,a=n.live?1/0:n.edge,r=0;if((e=e.filter(e=>!(e.error||e.cue.once&&e.hasPlayed))).length){this.resolveOffsets(e,t);var o=0,s=0;if(e.forEach((t,n)=>{var u=t.cue.pre,l=t.cue.post,d=e[n-1]||null,h=t.appendInPlace,c=l?a:t.startOffset,m=t.duration,f=t.timelineOccupancy===EI.Range?m:0,v=t.resumptionOffset,p=(null==d?void 0:d.startTime)===c,g=c+t.cumulativeDuration,y=h?g+m:c+v;if(u||!l&&c<=0){var b=s;s+=f,t.timelineStart=g;var w=r;r+=m,i.push({event:t,start:g,end:y,playout:{start:w,end:r},integrated:{start:b,end:s}})}else{if(!(c<=a))return;if(!p){var k=c-o;if(k>.033){var S=o,E=s;s+=k;var T=r;r+=k;var P={previousEvent:e[n-1]||null,nextEvent:t,start:S,end:S+k,playout:{start:T,end:r},integrated:{start:E,end:s}};i.push(P)}else k>0&&d&&(d.cumulativeDuration+=k,i[i.length-1].end=c)}l&&(y=g),t.timelineStart=g;var M=s;s+=f;var A=r;r+=m,i.push({event:t,start:g,end:y,playout:{start:A,end:r},integrated:{start:M,end:s}})}var D=t.resumeTime;o=l||D>a?a:D}),o<a){var u,l=o,d=s,h=a-o;s+=h;var c=r;r+=h,i.push({previousEvent:(null==(u=i[i.length-1])?void 0:u.event)||null,nextEvent:null,start:o,end:l+h,playout:{start:c,end:r},integrated:{start:d,end:s}})}this.setDurations(a,r,s)}else{i.push({previousEvent:null,nextEvent:null,start:0,end:a,playout:{start:0,end:a},integrated:{start:0,end:a}}),this.setDurations(a,a,a)}return i}},{key:"setDurations",value:function(e,t,i){this.durations={primary:e,playout:t,integrated:i}}},{key:"resolveOffsets",value:function(e,t){var i=t.main.details,n=i.live?1/0:i.edge,a=0,r=-1;e.forEach((o,s)=>{var u=o.cue.pre,l=o.cue.post,d=u?0:l?n:o.startTime;(this.updateAssetDurations(o),r===d?o.cumulativeDuration=a:(a=0,r=d),!l&&o.snapOptions.in&&(o.resumeAnchor=XP(null,i.fragments,o.startOffset+o.resumptionOffset,0,0)||void 0),o.appendInPlace&&!o.appendInPlaceStarted)&&(this.primaryCanResumeInPlaceAt(o,t)||(o.appendInPlace=!1));!o.appendInPlace&&s+1<e.length&&(e[s+1].startTime-e[s].resumeTime<.033&&(e[s+1].appendInPlace=!1,e[s+1].appendInPlace&&this.warn(`Could not change append strategy for abutting event ${o}`)));var h=$E(o.resumeOffset)?o.resumeOffset:o.duration;a+=h})}},{key:"primaryCanResumeInPlaceAt",value:function(e,t){var i=e.resumeTime,n=e.startTime+e.resumptionOffset;return Math.abs(i-n)>SI?(this.log(`"${e.identifier}" resumption ${i} not aligned with estimated timeline end ${n}`),!1):!Object.keys(t).some(n=>{var a=t[n].details,r=a.edge;if(i>=r)return this.log(`"${e.identifier}" resumption ${i} past ${n} playlist end ${r}`),!1;var o=XP(null,a.fragments,i);if(!o)return this.log(`"${e.identifier}" resumption ${i} does not align with any fragments in ${n} playlist (${a.fragStart}-${a.fragmentEnd})`),!0;var s="audio"===n?.175:0;return!(Math.abs(o.start-i)<SI+s||Math.abs(o.end-i)<SI+s)&&(this.log(`"${e.identifier}" resumption ${i} not aligned with ${n} fragment bounds (${o.start}-${o.end} sn: ${o.sn} cc: ${o.cc})`),!0)})}},{key:"updateAssetDurations",value:function(e){if(e.assetListLoaded){for(var t=e.timelineStart,i=0,n=!1,a=!1,r=0;r<e.assetList.length;r++){var o=e.assetList[r],s=t+i;o.startOffset=i,o.timelineStart=s,n||(n=null===o.duration),a||(a=!!o.error),i+=o.error?0:o.duration||0}e.duration=n&&!a?Math.max(i,e.duration):i}}},{key:"removeEvent",value:function(e){e.reset(),delete this.eventMap[e.identifier]}}])}();function LI(e){return`[${e.event?'"'+e.event.identifier+'"':"primary"}: ${e.start.toFixed(2)}-${e.end.toFixed(2)}]`}var _I=function(){return m(function e(t){u(this,e),this.hls=void 0,this.hls=t},[{key:"destroy",value:function(){this.hls=null}},{key:"loadAssetList",value:function(e,t){var i,n=e.assetListUrl;try{i=AI(n,this.hls.sessionId,e.baseUrl)}catch(t){var a=this.assignAssetListError(e,zE.ASSET_LIST_LOAD_ERROR,t,n);return void this.hls.trigger(UE.ERROR,a)}t&&"data:"!==i.protocol&&i.searchParams.set("_HLS_start_offset",""+t);var r=this.hls.config,o=new(0,r.loader)(r),s={responseType:"json",url:i.href},u=r.interstitialAssetListLoadPolicy.default,l={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},d={onSuccess:(t,i,n,a)=>{var r=t.data,o=null==r?void 0:r.ASSETS;if(Array.isArray(o))e.assetListResponse=r,this.hls.trigger(UE.ASSET_LIST_LOADED,{event:e,assetListResponse:r,networkDetails:a});else{var s=this.assignAssetListError(e,zE.ASSET_LIST_PARSING_ERROR,new Error("Invalid interstitial asset list"),n.url,i,a);this.hls.trigger(UE.ERROR,s)}},onError:(t,i,n,a)=>{var r=this.assignAssetListError(e,zE.ASSET_LIST_LOAD_ERROR,new Error(`Error loading X-ASSET-LIST: HTTP status ${t.code} ${t.text} (${i.url})`),i.url,a,n);this.hls.trigger(UE.ERROR,r)},onTimeout:(t,i,n)=>{var a=this.assignAssetListError(e,zE.ASSET_LIST_LOAD_TIMEOUT,new Error(`Timeout loading X-ASSET-LIST (${i.url})`),i.url,t,n);this.hls.trigger(UE.ERROR,a)}};return o.load(s,l,d),this.hls.trigger(UE.ASSET_LIST_LOADING,{event:e}),o}},{key:"assignAssetListError",value:function(e,t,i,n,a,r){return e.error=i,{type:BE.NETWORK_ERROR,details:t,fatal:!1,interstitial:e,url:n,error:i,networkDetails:r,stats:a}}}])}();function RI(e){var t;null==e||null==(t=e.play())||t.catch(()=>{})}function FI(e,t){return`[${e}] Advancing timeline position to ${t}`}var OI=function(){function e(t,i){var n;return u(this,e),(n=s(this,e,["interstitials",t.logger])).HlsPlayerClass=void 0,n.hls=void 0,n.assetListLoader=void 0,n.mediaSelection=null,n.altSelection=null,n.media=null,n.detachedData=null,n.requiredTracks=null,n.manager=null,n.playerQueue=[],n.bufferedPos=-1,n.timelinePos=-1,n.schedule=void 0,n.playingItem=null,n.bufferingItem=null,n.waitingItem=null,n.endedItem=null,n.playingAsset=null,n.endedAsset=null,n.bufferingAsset=null,n.shouldPlay=!1,n.onPlay=()=>{n.shouldPlay=!0},n.onPause=()=>{n.shouldPlay=!1},n.onSeeking=()=>{var e=n.currentTime;if(void 0!==e&&!n.playbackDisabled&&n.schedule){var t=e-n.timelinePos;if(!(Math.abs(t)<1/7056e5)){var i=t<=-.01;-1!==n.timelinePos||n.effectivePlayingItem||n.checkStart(),n.timelinePos=e,n.bufferedPos=e;var a=n.playingItem;if(a){if(i)n.schedule.resetErrorsInRange(e,e-t)&&n.updateSchedule(!0);if(n.checkBuffer(),i&&e<a.start||e>=a.end){var r,o=n.findItemIndex(a),s=n.schedule.findItemIndexAtTime(e);if(-1===s&&(s=o+(i?-1:1),n.log(`seeked ${i?"back ":""}to position not covered by schedule ${e} (resolving from ${o} to ${s})`)),!n.isInterstitial(a)&&null!=(r=n.media)&&r.paused&&(n.shouldPlay=!1),!i&&s>o){var u=n.schedule.findJumpRestrictedIndex(o+1,s);if(u>o)return void n.setSchedulePosition(u)}n.setSchedulePosition(s)}else{var l=n.playingAsset;if(l){var d,h=l.timelineStart,c=l.duration||0;if(i&&e<h||e>=h+c)null!=(d=a.event)&&d.appendInPlace&&(n.clearAssetPlayers(a.event,a),n.flushFrontBuffer(e)),n.setScheduleToAssetAtTime(e,l)}else if(n.playingLastItem&&n.isInterstitial(a)){var m=a.event.assetList[0];m&&(n.endedItem=n.playingItem,n.playingItem=null,n.setScheduleToAssetAtTime(e,m))}}}else n.checkBuffer()}}},n.onTimeupdate=()=>{var e=n.currentTime;if(void 0!==e&&!n.playbackDisabled&&(-1!==n.timelinePos||n.effectivePlayingItem||n.checkStart(),e>n.timelinePos)){n.timelinePos=e,e>n.bufferedPos&&n.checkBuffer();var t=n.playingItem;if(t&&!n.playingLastItem){if(e>=t.end){n.timelinePos=t.end;var i=n.findItemIndex(t);n.setSchedulePosition(i+1)}var a=n.playingAsset;if(a)e>=a.timelineStart+(a.duration||0)&&n.setScheduleToAssetAtTime(e,a)}}},n.onScheduleUpdate=(e,t)=>{var i=n.schedule;if(i){var a=n.playingItem,r=i.events||[],o=i.items||[],s=i.durations,u=e.map(e=>e.identifier),l=!(!r.length&&!u.length);(l||t)&&n.log(`INTERSTITIALS_UPDATED (${r.length}): ${r}\nSchedule: ${o.map(e=>LI(e))} pos: ${n.timelinePos}`),u.length&&n.log(`Removed events ${u}`);var d=null,h=null;a&&(d=n.updateItem(a,n.timelinePos),n.itemsMatch(a,d)?n.playingItem=d:n.waitingItem=n.endedItem=null),n.waitingItem=n.updateItem(n.waitingItem),n.endedItem=n.updateItem(n.endedItem);var c=n.bufferingItem;if(c&&(h=n.updateItem(c,n.bufferedPos),n.itemsMatch(c,h)?n.bufferingItem=h:c.event&&(n.bufferingItem=n.playingItem,n.clearInterstitial(c.event,null))),e.forEach(e=>{e.assetList.forEach(e=>{n.clearAssetPlayer(e.identifier,null)})}),n.playerQueue.forEach(e=>{if(e.interstitial.appendInPlace){var t=e.assetItem.timelineStart,i=e.timelineOffset-t;if(i)try{e.timelineOffset=t}catch(a){Math.abs(i)>SI&&n.warn(`${a} ("${e.assetId}" ${e.timelineOffset}->${t})`)}}}),l||t){if(n.hls.trigger(UE.INTERSTITIALS_UPDATED,{events:r.slice(0),schedule:o.slice(0),durations:s,removedIds:u}),n.isInterstitial(a)&&u.includes(a.event.identifier))return n.warn(`Interstitial "${a.event.identifier}" removed while playing`),void n.primaryFallback(a.event);a&&n.trimInPlace(d,a),c&&h!==d&&n.trimInPlace(h,c),n.checkBuffer()}}},n.hls=t,n.HlsPlayerClass=i,n.assetListLoader=new _I(t),n.schedule=new II(n.onScheduleUpdate,t.logger),n.registerListeners(),n}return y(e,nT),m(e,[{key:"registerListeners",value:function(){var e=this.hls;e&&(e.on(UE.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(UE.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(UE.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(UE.MANIFEST_LOADING,this.onManifestLoading,this),e.on(UE.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(UE.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(UE.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.on(UE.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(UE.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.on(UE.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.on(UE.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.on(UE.BUFFER_APPENDED,this.onBufferAppended,this),e.on(UE.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(UE.BUFFERED_TO_END,this.onBufferedToEnd,this),e.on(UE.MEDIA_ENDED,this.onMediaEnded,this),e.on(UE.ERROR,this.onError,this),e.on(UE.DESTROYING,this.onDestroying,this))}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(UE.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(UE.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(UE.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(UE.MANIFEST_LOADING,this.onManifestLoading,this),e.off(UE.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(UE.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(UE.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.off(UE.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(UE.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.off(UE.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.off(UE.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.off(UE.BUFFER_CODECS,this.onBufferCodecs,this),e.off(UE.BUFFER_APPENDED,this.onBufferAppended,this),e.off(UE.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(UE.BUFFERED_TO_END,this.onBufferedToEnd,this),e.off(UE.MEDIA_ENDED,this.onMediaEnded,this),e.off(UE.ERROR,this.onError,this),e.off(UE.DESTROYING,this.onDestroying,this))}},{key:"startLoad",value:function(){this.resumeBuffering()}},{key:"stopLoad",value:function(){this.pauseBuffering()}},{key:"resumeBuffering",value:function(){var e;null==(e=this.getBufferingPlayer())||e.resumeBuffering()}},{key:"pauseBuffering",value:function(){var e;null==(e=this.getBufferingPlayer())||e.pauseBuffering()}},{key:"destroy",value:function(){this.unregisterListeners(),this.stopLoad(),this.assetListLoader&&this.assetListLoader.destroy(),this.emptyPlayerQueue(),this.clearScheduleState(),this.schedule&&this.schedule.destroy(),this.media=this.detachedData=this.mediaSelection=this.requiredTracks=this.altSelection=this.schedule=this.manager=null,this.hls=this.HlsPlayerClass=this.log=null,this.assetListLoader=null,this.onPlay=this.onPause=this.onSeeking=this.onTimeupdate=null,this.onScheduleUpdate=null}},{key:"onDestroying",value:function(){var e=this.primaryMedia||this.media;e&&this.removeMediaListeners(e)}},{key:"removeMediaListeners",value:function(e){iD(e,"play",this.onPlay),iD(e,"pause",this.onPause),iD(e,"seeking",this.onSeeking),iD(e,"timeupdate",this.onTimeupdate)}},{key:"onMediaAttaching",value:function(e,t){var i=this.media=t.media;tD(i,"seeking",this.onSeeking),tD(i,"timeupdate",this.onTimeupdate),tD(i,"play",this.onPlay),tD(i,"pause",this.onPause)}},{key:"onMediaAttached",value:function(e,t){var i=this.effectivePlayingItem,n=this.detachedData;if(this.detachedData=null,null===i)this.checkStart();else if(!n){this.clearScheduleState();var a=this.findItemIndex(i);this.setSchedulePosition(a)}}},{key:"clearScheduleState",value:function(){this.log("clear schedule state"),this.playingItem=this.bufferingItem=this.waitingItem=this.endedItem=this.playingAsset=this.endedAsset=this.bufferingAsset=null}},{key:"onMediaDetaching",value:function(e,t){var i=!!t.transferMedia,n=this.media;if(this.media=null,!i&&(n&&this.removeMediaListeners(n),this.detachedData)){var a=this.getBufferingPlayer();a&&(this.log(`Removing schedule state for detachedData and ${a}`),this.playingAsset=this.endedAsset=this.bufferingAsset=this.bufferingItem=this.waitingItem=this.detachedData=null,a.detachMedia()),this.shouldPlay=!1}}},{key:"interstitialsManager",get:function(){if(!this.hls)return null;if(this.manager)return this.manager;var e=this,t=()=>e.bufferingItem||e.waitingItem,i=t=>t?e.getAssetPlayer(t.identifier):t,n=(t,n,r,o,s)=>{if(t){var u=t[n].start,l=t.event;if(l){if("playout"===n||l.timelineOccupancy!==EI.Point){var d=i(r);(null==d?void 0:d.interstitial)===l&&(u+=d.assetItem.startOffset+d[s])}}else u+=("bufferedPos"===o?a():e[o])-t.start;return u}return 0},a=()=>{var t=e.bufferedPos;return t===Number.MAX_VALUE?r("primary"):Math.max(t,0)},r=t=>{var i,n;return null!=(i=e.primaryDetails)&&i.live?e.primaryDetails.edge:(null==(n=e.schedule)?void 0:n.durations[t])||0},o=(t,a)=>{var r,o,s=e.effectivePlayingItem;if((null==s||null==(r=s.event)||!r.restrictions.skip)&&e.schedule){e.log(`seek to ${t} "${a}"`);var u=e.effectivePlayingItem,l=e.schedule.findItemIndexAtTime(t,a),d=null==(o=e.schedule.items)?void 0:o[l],h=e.getBufferingPlayer(),c=null==h?void 0:h.interstitial,m=null==c?void 0:c.appendInPlace,f=u&&e.itemsMatch(u,d);if(u&&(m||f)){var v=i(e.playingAsset),p=(null==v?void 0:v.media)||e.primaryMedia;if(p){var g="primary"===a?p.currentTime:n(u,a,e.playingAsset,"timelinePos","currentTime"),y=t-g,b=(m?g:p.currentTime)+y;if(b>=0&&(!v||m||b<=v.duration))return void(p.currentTime=b)}}if(d){var w=t;if("primary"!==a){var k=t-d[a].start;w=d.start+k}var S=!e.isInterstitial(d);if(e.isInterstitial(u)&&!u.event.appendInPlace||!S&&!d.event.appendInPlace){if(u){var E=e.findItemIndex(u);if(l>E){var T=e.schedule.findJumpRestrictedIndex(E+1,l);if(T>E)return void e.setSchedulePosition(T)}var P=0;if(S)e.timelinePos=w,e.checkBuffer();else for(var M=d.event.assetList,A=t-(d[a]||d).start,D=M.length;D--;){var x=M[D];if(x.duration&&A>=x.startOffset&&A<x.startOffset+x.duration){P=D;break}}e.setSchedulePosition(l,P)}}else{var C=e.media||(m?null==h?void 0:h.media:null);C&&(C.currentTime=w)}}}},s=()=>{var i=e.effectivePlayingItem;if(e.isInterstitial(i))return i;var n=t();return e.isInterstitial(n)?n:null},u={get bufferedEnd(){var i,a=t(),r=e.bufferingItem;return r&&r===a&&(n(r,"playout",e.bufferingAsset,"bufferedPos","bufferedEnd")-r.playout.start||(null==(i=e.bufferingAsset)?void 0:i.startOffset))||0},get currentTime(){var t=s(),i=e.effectivePlayingItem;return i&&i===t?n(i,"playout",e.effectivePlayingAsset,"timelinePos","currentTime")-i.playout.start:0},set currentTime(t){var i=s(),n=e.effectivePlayingItem;n&&n===i&&o(t+n.playout.start,"playout")},get duration(){var e=s();return e?e.playout.end-e.playout.start:0},get assetPlayers(){var t,i=null==(t=s())?void 0:t.event.assetList;return i?i.map(t=>e.getAssetPlayer(t.identifier)):[]},get playingIndex(){var t,i=null==(t=s())?void 0:t.event;return i&&e.effectivePlayingAsset?i.findAssetIndex(e.effectivePlayingAsset):-1},get scheduleItem(){return s()}};return this.manager={get events(){var t;return(null==(t=e.schedule)||null==(t=t.events)?void 0:t.slice(0))||[]},get schedule(){var t;return(null==(t=e.schedule)||null==(t=t.items)?void 0:t.slice(0))||[]},get interstitialPlayer(){return s()?u:null},get playerQueue(){return e.playerQueue.slice(0)},get bufferingAsset(){return e.bufferingAsset},get bufferingItem(){return t()},get bufferingIndex(){var i=t();return e.findItemIndex(i)},get playingAsset(){return e.effectivePlayingAsset},get playingItem(){return e.effectivePlayingItem},get playingIndex(){var t=e.effectivePlayingItem;return e.findItemIndex(t)},primary:{get bufferedEnd(){return a()},get currentTime(){var t=e.timelinePos;return t>0?t:0},set currentTime(e){o(e,"primary")},get duration(){return r("primary")},get seekableStart(){var t;return(null==(t=e.primaryDetails)?void 0:t.fragmentStart)||0}},integrated:{get bufferedEnd(){return n(t(),"integrated",e.bufferingAsset,"bufferedPos","bufferedEnd")},get currentTime(){return n(e.effectivePlayingItem,"integrated",e.effectivePlayingAsset,"timelinePos","currentTime")},set currentTime(e){o(e,"integrated")},get duration(){return r("integrated")},get seekableStart(){var t;return((t,i)=>{var n;if(0!==t&&"primary"!==i&&null!=(n=e.schedule)&&n.length){var a,r=e.schedule.findItemIndexAtTime(t),o=null==(a=e.schedule.items)?void 0:a[r];if(o)return t+(o[i].start-o.start)}return t})((null==(t=e.primaryDetails)?void 0:t.fragmentStart)||0,"integrated")}},skip:()=>{var t=e.effectivePlayingItem,i=null==t?void 0:t.event;if(i&&!i.restrictions.skip){var n=e.findItemIndex(t);if(i.appendInPlace){var a=t.playout.start+t.event.duration;o(a+.001,"playout")}else e.advanceAfterAssetEnded(i,n,1/0)}}}}},{key:"effectivePlayingItem",get:function(){return this.waitingItem||this.playingItem||this.endedItem}},{key:"effectivePlayingAsset",get:function(){return this.playingAsset||this.endedAsset}},{key:"playingLastItem",get:function(){var e,t=this.playingItem,i=null==(e=this.schedule)?void 0:e.items;return!!(this.playbackStarted&&t&&i)&&this.findItemIndex(t)===i.length-1}},{key:"playbackStarted",get:function(){return null!==this.effectivePlayingItem}},{key:"currentTime",get:function(){var e,t;if(null!==this.mediaSelection){var i=this.waitingItem||this.playingItem;if(!this.isInterstitial(i)||i.event.appendInPlace){var n=this.media;!n&&null!=(e=this.bufferingItem)&&null!=(e=e.event)&&e.appendInPlace&&(n=this.primaryMedia);var a=null==(t=n)?void 0:t.currentTime;if(void 0!==a&&$E(a))return a}}}},{key:"primaryMedia",get:function(){var e;return this.media||(null==(e=this.detachedData)?void 0:e.media)||null}},{key:"isInterstitial",value:function(e){return!(null==e||!e.event)}},{key:"retreiveMediaSource",value:function(e,t){var i=this.getAssetPlayer(e);i&&this.transferMediaFromPlayer(i,t)}},{key:"transferMediaFromPlayer",value:function(e,t){var i=e.interstitial.appendInPlace,n=e.media;if(i&&n===this.primaryMedia){if(this.bufferingAsset=null,(!t||this.isInterstitial(t)&&!t.event.appendInPlace)&&t&&n)return void(this.detachedData={media:n});var a=e.transferMedia();this.log(`transfer MediaSource from ${e} ${WP(a)}`),this.detachedData=a}else t&&n&&(this.shouldPlay||(this.shouldPlay=!n.paused))}},{key:"transferMediaTo",value:function(e,t){var i,n;if(e.media!==t){var a,r=null,o=this.hls,s=e!==o,u=s&&e.interstitial.appendInPlace,l=null==(i=this.detachedData)?void 0:i.mediaSource;if(o.media)u&&(r=o.transferMedia(),this.detachedData=r),a="Primary";else if(l){var d=this.getBufferingPlayer();d?(r=d.transferMedia(),a=`${d}`):a="detached MediaSource"}else a="detached media";if(!r)if(l)r=this.detachedData,this.log(`using detachedData: MediaSource ${WP(r)}`);else if(!this.detachedData||o.media===t){var h=this.playerQueue;h.length>1&&h.forEach(e=>{if(s&&e.interstitial.appendInPlace!==u){var t=e.interstitial;this.clearInterstitial(e.interstitial,null),t.appendInPlace=!1,t.appendInPlace&&this.warn(`Could not change append strategy for queued assets ${t}`)}}),this.hls.detachMedia(),this.detachedData={media:t}}var c=r&&"mediaSource"in r&&"closed"!==(null==(n=r.mediaSource)?void 0:n.readyState),m=c&&r?r:t;this.log(`${c?"transfering MediaSource":"attaching media"} to ${s?e:"Primary"} from ${a} (media.currentTime: ${t.currentTime})`);var f=this.schedule;if(m===r&&f){var v=s&&e.assetId===f.assetIdAtEnd;m.overrides={duration:f.duration,endOfStream:!s||v,cueRemoval:!s}}e.attachMedia(m)}}},{key:"onInterstitialCueEnter",value:function(){this.onTimeupdate()}},{key:"checkStart",value:function(){var e=this.schedule,t=null==e?void 0:e.events;if(t&&!this.playbackDisabled&&this.media){-1===this.bufferedPos&&(this.bufferedPos=0);var i=this.timelinePos,n=this.effectivePlayingItem;if(-1===i){var a=this.hls.startPosition;if(this.timelinePos=a,0===t.length)this.setSchedulePosition(0);else if(t[0].cue.pre){this.log(FI("checkStart (preroll)",a));var r=e.findEventIndex(t[0].identifier);this.setSchedulePosition(r)}else if(a>=0||!this.primaryLive){this.log(FI("checkStart",a));var o=this.timelinePos=a>0?a:0,s=e.findItemIndexAtTime(o);this.setSchedulePosition(s)}else 0===this.hls.liveSyncPosition?this.setSchedulePosition(0):this.log("[checkStart] waiting for live start")}else if(n&&!this.playingItem){this.log(FI("checkStart (playing item)",n.start));var u=e.findItemIndex(n);this.setSchedulePosition(u)}}}},{key:"advanceAssetBuffering",value:function(e,t){var i=e.event,n=i.findAssetIndex(t),a=DI(i,n);if(i.isAssetPastPlayoutLimit(a)){if(this.schedule){var r,o=null==(r=this.schedule.items)?void 0:r[this.findItemIndex(e)+1];o&&this.bufferedToItem(o)}}else this.bufferedToEvent(e,a)}},{key:"advanceAfterAssetEnded",value:function(e,t,i){var n=DI(e,i);if(e.isAssetPastPlayoutLimit(n)){if(this.schedule){var a=this.schedule.items;if(a){var r=t+1;if(r>=a.length)return void this.setSchedulePosition(-1);var o=e.resumeTime;this.timelinePos<o&&(this.log(FI("advanceAfterAssetEnded",o)),this.timelinePos=o,e.appendInPlace&&this.advanceInPlace(o),this.checkBuffer(this.bufferedPos<o)),this.setSchedulePosition(r)}}}else{if(e.appendInPlace){var s=e.assetList[n];s&&this.advanceInPlace(s.timelineStart)}this.setSchedulePosition(t,n)}}},{key:"setScheduleToAssetAtTime",value:function(e,t){var i=this.schedule;if(i){var n=t.parentIdentifier,a=i.getEvent(n);if(a){var r=i.findEventIndex(n),o=i.findAssetIndex(a,e);this.advanceAfterAssetEnded(a,r,o-1)}}}},{key:"setSchedulePosition",value:function(e,t){var i,n=null==(i=this.schedule)?void 0:i.items;if(n&&!this.playbackDisabled){var a=e>=0?n[e]:null;this.log(`setSchedulePosition ${e}, ${t} (${a?LI(a):a}) pos: ${this.timelinePos}`);var r=this.waitingItem||this.playingItem,o=this.playingLastItem;if(this.isInterstitial(r)){var s=r.event,u=this.playingAsset,l=null==u?void 0:u.identifier,d=l?this.getAssetPlayer(l):null;if(d&&l&&(!this.eventItemsMatch(r,a)||void 0!==t&&l!==s.assetList[t].identifier)){var h,c=s.findAssetIndex(u);if(this.log(`INTERSTITIAL_ASSET_ENDED ${c+1}/${s.assetList.length} ${xI(u)}`),this.endedAsset=u,this.playingAsset=null,this.hls.trigger(UE.INTERSTITIAL_ASSET_ENDED,{asset:u,assetListIndex:c,event:s,schedule:n.slice(0),scheduleIndex:e,player:d}),r!==this.playingItem)return void(this.itemsMatch(r,this.playingItem)&&!this.playingAsset&&this.advanceAfterAssetEnded(s,this.findItemIndex(this.playingItem),c));this.retreiveMediaSource(l,a),!d.media||null!=(h=this.detachedData)&&h.mediaSource||d.detachMedia()}if(!this.eventItemsMatch(r,a)&&(this.endedItem=r,this.playingItem=null,this.log(`INTERSTITIAL_ENDED ${s} ${LI(r)}`),s.hasPlayed=!0,this.hls.trigger(UE.INTERSTITIAL_ENDED,{event:s,schedule:n.slice(0),scheduleIndex:e}),s.cue.once)){var m;this.updateSchedule();var f=null==(m=this.schedule)?void 0:m.items;if(a&&f){var v=this.findItemIndex(a);this.advanceSchedule(v,f,t,r,o)}return}}this.advanceSchedule(e,n,t,r,o)}}},{key:"advanceSchedule",value:function(e,t,i,n,a){var r=this.schedule;if(r){var o=t[e]||null,s=this.primaryMedia,u=this.playerQueue;if(u.length&&u.forEach(t=>{var i=t.interstitial,n=r.findEventIndex(i.identifier);(n<e||n>e+1)&&this.clearInterstitial(i,o)}),this.isInterstitial(o)){this.timelinePos=Math.min(Math.max(this.timelinePos,o.start),o.end);var l=o.event;if(void 0===i){var d=DI(l,(i=r.findAssetIndex(l,this.timelinePos))-1);if(l.isAssetPastPlayoutLimit(d)||l.appendInPlace&&this.timelinePos===o.end)return void this.advanceAfterAssetEnded(l,e,i);i=d}var h=this.waitingItem;this.assetsBuffered(o,s)||this.setBufferingItem(o);var c=this.preloadAssets(l,i);if(this.eventItemsMatch(o,h||n)||(this.waitingItem=o,this.log(`INTERSTITIAL_STARTED ${LI(o)} ${l.appendInPlace?"append in place":""}`),this.hls.trigger(UE.INTERSTITIAL_STARTED,{event:l,schedule:t.slice(0),scheduleIndex:e})),!l.assetListLoaded)return void this.log(`Waiting for ASSET-LIST to complete loading ${l}`);if(l.assetListLoader&&(l.assetListLoader.destroy(),l.assetListLoader=void 0),!s)return void this.log(`Waiting for attachMedia to start Interstitial ${l}`);this.waitingItem=this.endedItem=null,this.playingItem=o;var m=l.assetList[i];if(!m)return void this.advanceAfterAssetEnded(l,e,i||0);if(c||(c=this.getAssetPlayer(m.identifier)),null===c||c.destroyed){var f=l.assetList.length;this.warn(`asset ${i+1}/${f} player destroyed ${l}`),(c=this.createAssetPlayer(l,m,i)).loadSource()}if(!this.eventItemsMatch(o,this.bufferingItem)&&l.appendInPlace&&this.isAssetBuffered(m))return;this.startAssetPlayer(c,i,t,e,s),this.shouldPlay&&RI(c.media)}else o?(this.resumePrimary(o,e,n),this.shouldPlay&&RI(this.hls.media)):a&&this.isInterstitial(n)&&(this.endedItem=null,this.playingItem=n,n.event.appendInPlace||this.attachPrimary(r.durations.primary,null))}}},{key:"playbackDisabled",get:function(){return!1===this.hls.config.enableInterstitialPlayback}},{key:"primaryDetails",get:function(){var e;return null==(e=this.mediaSelection)?void 0:e.main.details}},{key:"primaryLive",get:function(){var e;return!(null==(e=this.primaryDetails)||!e.live)}},{key:"resumePrimary",value:function(e,t,i){var n,a;if(this.playingItem=e,this.playingAsset=this.endedAsset=null,this.waitingItem=this.endedItem=null,this.bufferedToItem(e),this.log(`resuming ${LI(e)}`),null==(n=this.detachedData)||!n.mediaSource){var r=this.timelinePos;(r<e.start||r>=e.end)&&(r=this.getPrimaryResumption(e,t),this.log(FI("resumePrimary",r)),this.timelinePos=r),this.attachPrimary(r,e)}if(i){var o=null==(a=this.schedule)?void 0:a.items;o&&(this.log(`INTERSTITIALS_PRIMARY_RESUMED ${LI(e)}`),this.hls.trigger(UE.INTERSTITIALS_PRIMARY_RESUMED,{schedule:o.slice(0),scheduleIndex:t}),this.checkBuffer())}}},{key:"getPrimaryResumption",value:function(e,t){var i=e.start;if(this.primaryLive){var n=this.primaryDetails;if(0===t)return this.hls.startPosition;if(n&&(i<n.fragmentStart||i>n.edge))return this.hls.liveSyncPosition||-1}return i}},{key:"isAssetBuffered",value:function(e){var t=this.getAssetPlayer(e.identifier);return null!=t&&t.hls?t.hls.bufferedToEnd:$M.bufferInfo(this.primaryMedia,this.timelinePos,0).end+1>=e.timelineStart+(e.duration||0)}},{key:"attachPrimary",value:function(e,t,i){t?this.setBufferingItem(t):this.bufferingItem=this.playingItem,this.bufferingAsset=null;var n=this.primaryMedia;if(n){var a=this.hls;a.media?this.checkBuffer():(this.transferMediaTo(a,n),i&&this.startLoadingPrimaryAt(e,i)),i||(this.log(FI("attachPrimary",e)),this.timelinePos=e,this.startLoadingPrimaryAt(e,i))}}},{key:"startLoadingPrimaryAt",value:function(e,t){var i,n=this.hls;!n.loadingEnabled||!n.media||Math.abs(((null==(i=n.mainForwardBufferInfo)?void 0:i.start)||n.media.currentTime)-e)>.5?n.startLoad(e,t):n.bufferingEnabled||n.resumeBuffering()}},{key:"onManifestLoading",value:function(){var e;this.stopLoad(),null==(e=this.schedule)||e.reset(),this.emptyPlayerQueue(),this.clearScheduleState(),this.shouldPlay=!1,this.bufferedPos=this.timelinePos=-1,this.mediaSelection=this.altSelection=this.manager=this.requiredTracks=null,this.hls.off(UE.BUFFER_CODECS,this.onBufferCodecs,this),this.hls.on(UE.BUFFER_CODECS,this.onBufferCodecs,this)}},{key:"onLevelUpdated",value:function(e,t){if(-1!==t.level&&this.schedule){var i=this.hls.levels[t.level];if(i.details){var n=iT(iT({},this.mediaSelection||this.altSelection),{},{main:i});this.mediaSelection=n,this.schedule.parseInterstitialDateRanges(n,this.hls.config.interstitialAppendInPlace),!this.effectivePlayingItem&&this.schedule.items&&this.checkStart()}}}},{key:"onAudioTrackUpdated",value:function(e,t){var i=this.hls.audioTracks[t.id],n=this.mediaSelection;if(n){var a=iT(iT({},n),{},{audio:i});this.mediaSelection=a}else this.altSelection=iT(iT({},this.altSelection),{},{audio:i})}},{key:"onSubtitleTrackUpdated",value:function(e,t){var i=this.hls.subtitleTracks[t.id],n=this.mediaSelection;if(n){var a=iT(iT({},n),{},{subtitles:i});this.mediaSelection=a}else this.altSelection=iT(iT({},this.altSelection),{},{subtitles:i})}},{key:"onAudioTrackSwitching",value:function(e,t){var i=jP(t);this.playerQueue.forEach(({hls:e})=>e&&(e.setAudioOption(t)||e.setAudioOption(i)))}},{key:"onSubtitleTrackSwitch",value:function(e,t){var i=jP(t);this.playerQueue.forEach(({hls:e})=>e&&(e.setSubtitleOption(t)||-1!==t.id&&e.setSubtitleOption(i)))}},{key:"onBufferCodecs",value:function(e,t){var i=t.tracks;i&&(this.requiredTracks=i)}},{key:"onBufferAppended",value:function(e,t){this.checkBuffer()}},{key:"onBufferFlushed",value:function(e,t){var i=this.playingItem;if(i&&!this.itemsMatch(i,this.bufferingItem)&&!this.isInterstitial(i)){var n=this.timelinePos;this.bufferedPos=n,this.checkBuffer()}}},{key:"onBufferedToEnd",value:function(e){if(this.schedule){var t=this.schedule.events;if(this.bufferedPos<Number.MAX_VALUE&&t){for(var i=0;i<t.length;i++){var n=t[i];if(n.cue.post){var a,r=this.schedule.findEventIndex(n.identifier),o=null==(a=this.schedule.items)?void 0:a[r];this.isInterstitial(o)&&this.eventItemsMatch(o,this.bufferingItem)&&this.bufferedToItem(o,0);break}}this.bufferedPos=Number.MAX_VALUE}}}},{key:"onMediaEnded",value:function(e){var t=this.playingItem;if(!this.playingLastItem&&t){var i=this.findItemIndex(t);this.setSchedulePosition(i+1)}else this.shouldPlay=!1}},{key:"updateItem",value:function(e,t){var i,n=null==(i=this.schedule)?void 0:i.items;return e&&n&&n[this.findItemIndex(e,t)]||null}},{key:"trimInPlace",value:function(e,t){if(this.isInterstitial(e)&&e.event.appendInPlace&&t.end-e.end>.25){e.event.assetList.forEach((t,i)=>{e.event.isAssetPastPlayoutLimit(i)&&this.clearAssetPlayer(t.identifier,null)});var i=e.end+.25,n=$M.bufferInfo(this.primaryMedia,i,0);if(n.end>i||(n.nextStart||0)>i){this.log(`trim buffered interstitial ${LI(e)} (was ${LI(t)})`);this.attachPrimary(i,null,!0),this.flushFrontBuffer(i)}}}},{key:"itemsMatch",value:function(e,t){return!!t&&(e===t||e.event&&t.event&&this.eventItemsMatch(e,t)||!e.event&&!t.event&&this.findItemIndex(e)===this.findItemIndex(t))}},{key:"eventItemsMatch",value:function(e,t){var i;return!!t&&(e===t||e.event.identifier===(null==(i=t.event)?void 0:i.identifier))}},{key:"findItemIndex",value:function(e,t){return e&&this.schedule?this.schedule.findItemIndex(e,t):-1}},{key:"updateSchedule",value:function(e=!1){var t,i=this.mediaSelection;i&&(null==(t=this.schedule)||t.updateSchedule(i,[],e))}},{key:"checkBuffer",value:function(e){var t,i=null==(t=this.schedule)?void 0:t.items;if(i){var n=$M.bufferInfo(this.primaryMedia,this.timelinePos,0);e&&(this.bufferedPos=this.timelinePos),e||(e=n.len<1),this.updateBufferedPos(n.end,i,e)}}},{key:"updateBufferedPos",value:function(e,t,i){var n=this.schedule,a=this.bufferingItem;if(!(this.bufferedPos>e)&&n)if(1===t.length&&this.itemsMatch(t[0],a))this.bufferedPos=e;else{var r=this.playingItem,o=this.findItemIndex(r),s=n.findItemIndexAtTime(e);if(this.bufferedPos<e){var u,l=this.findItemIndex(a),d=Math.min(l+1,t.length-1),h=t[d];if((-1===s&&a&&e>=a.end||null!=(u=h.event)&&u.appendInPlace&&e+.01>=h.start)&&(s=d),this.isInterstitial(a)){var c=a.event;if(d-o>1&&!1===c.appendInPlace)return;if(0===c.assetList.length&&c.assetListLoader)return}if(this.bufferedPos=e,s>l&&s>o)this.bufferedToItem(h);else{var m=this.primaryDetails;this.primaryLive&&m&&e>m.edge-m.targetduration&&h.start<m.edge+this.hls.config.interstitialLiveLookAhead&&this.isInterstitial(h)&&this.preloadAssets(h.event,0)}}else i&&r&&!this.itemsMatch(r,a)&&(s===o?this.bufferedToItem(r):s===o+1&&this.bufferedToItem(t[s]))}}},{key:"assetsBuffered",value:function(e,t){return 0!==e.event.assetList.length&&!e.event.assetList.some(e=>{var i=this.getAssetPlayer(e.identifier);return!(null!=i&&i.bufferedInPlaceToEnd(t))})}},{key:"setBufferingItem",value:function(e){var t=this.bufferingItem,i=this.schedule;if(!this.itemsMatch(e,t)&&i){var n=i.items,a=i.events;if(!n||!a)return t;var r=this.isInterstitial(e),o=this.getBufferingPlayer();this.bufferingItem=e,this.bufferedPos=Math.max(e.start,Math.min(e.end,this.timelinePos));var s=o?o.remaining:t?t.end-this.timelinePos:0;if(this.log(`INTERSTITIALS_BUFFERED_TO_BOUNDARY ${LI(e)}`+(t?` (${s.toFixed(2)} remaining)`:"")),!this.playbackDisabled)if(r){var u=i.findAssetIndex(e.event,this.bufferedPos);e.event.assetList.forEach((e,t)=>{var i=this.getAssetPlayer(e.identifier);i&&(t===u&&i.loadSource(),i.resumeBuffering())})}else this.hls.resumeBuffering(),this.playerQueue.forEach(e=>e.pauseBuffering());this.hls.trigger(UE.INTERSTITIALS_BUFFERED_TO_BOUNDARY,{events:a.slice(0),schedule:n.slice(0),bufferingIndex:this.findItemIndex(e),playingIndex:this.findItemIndex(this.playingItem)})}else this.bufferingItem!==e&&(this.bufferingItem=e);return t}},{key:"bufferedToItem",value:function(e,t=0){var i=this.setBufferingItem(e);if(!this.playbackDisabled)if(this.isInterstitial(e))this.bufferedToEvent(e,t);else if(null!==i){this.bufferingAsset=null;var n=this.detachedData;if(n)if(n.mediaSource){this.attachPrimary(e.start,e,!0)}else this.preloadPrimary(e);else this.preloadPrimary(e)}}},{key:"preloadPrimary",value:function(e){var t=this.findItemIndex(e),i=this.getPrimaryResumption(e,t);this.startLoadingPrimaryAt(i)}},{key:"bufferedToEvent",value:function(e,t){var i=e.event,n=0===i.assetList.length&&!i.assetListLoader,a=i.cue.once;if(n||!a){var r=this.preloadAssets(i,t);if(null!=r&&r.interstitial.appendInPlace){var o=this.primaryMedia;o&&this.bufferAssetPlayer(r,o)}}}},{key:"preloadAssets",value:function(e,t){var i=e.assetUrl,n=e.assetList.length,a=0===n&&!e.assetListLoader,r=e.cue.once;if(a){var o,s=e.timelineStart;if(e.appendInPlace){var u,l=this.playingItem;this.isInterstitial(l)||(null==l||null==(u=l.nextEvent)?void 0:u.identifier)!==e.identifier||this.flushFrontBuffer(s+.25)}var d=0;if(!this.playingItem&&this.primaryLive&&-1===(d=this.hls.startPosition)&&(d=this.hls.liveSyncPosition||0),d&&!e.cue.pre&&!e.cue.post){var h=d-s;h>0&&(o=Math.round(1e3*h)/1e3)}if(this.log(`Load interstitial asset ${t+1}/${i?1:n} ${e}${o?` live-start: ${d} start-offset: ${o}`:""}`),i)return this.createAsset(e,0,0,s,e.duration,i);var c=this.assetListLoader.loadAssetList(e,o);c&&(e.assetListLoader=c)}else if(!r&&n){for(var m=t;m<n;m++){var f=e.assetList[m],v=this.getAssetPlayerQueueIndex(f.identifier);-1!==v&&!this.playerQueue[v].destroyed||f.error||this.createAssetPlayer(e,f,m)}var p=e.assetList[t];if(p){var g=this.getAssetPlayer(p.identifier);return g&&g.loadSource(),g}}return null}},{key:"flushFrontBuffer",value:function(e){var t=this.requiredTracks;t&&(this.log(`Removing front buffer starting at ${e}`),Object.keys(t).forEach(t=>{this.hls.trigger(UE.BUFFER_FLUSHING,{startOffset:e,endOffset:1/0,type:t})}))}},{key:"getAssetPlayerQueueIndex",value:function(e){for(var t=this.playerQueue,i=0;i<t.length;i++)if(e===t[i].assetId)return i;return-1}},{key:"getAssetPlayer",value:function(e){var t=this.getAssetPlayerQueueIndex(e);return this.playerQueue[t]||null}},{key:"getBufferingPlayer",value:function(){var e=this.playerQueue,t=this.primaryMedia;if(t)for(var i=0;i<e.length;i++)if(e[i].media===t)return e[i];return null}},{key:"createAsset",value:function(e,t,i,n,a,r){var o={parentIdentifier:e.identifier,identifier:TI(e,r,t),duration:a,startOffset:i,timelineStart:n,uri:r};return this.createAssetPlayer(e,o,t)}},{key:"createAssetPlayer",value:function(e,t,i){var n=this.hls,a=n.userConfig,r=a.videoPreference,o=n.loadLevelObj||n.levels[n.currentLevel];(r||o)&&(r=eT({},r),o.videoCodec&&(r.videoCodec=o.videoCodec),o.videoRange&&(r.allowedVideoRanges=[o.videoRange]));var s=n.audioTracks[n.audioTrack],u=n.subtitleTracks[n.subtitleTrack],l=0;if(this.primaryLive||e.appendInPlace){var d=this.timelinePos-t.timelineStart;if(d>1){var h=t.duration;h&&d<h&&(l=d)}}var c=t.identifier,m=iT(iT({},a),{},{maxMaxBufferLength:Math.min(180,n.config.maxMaxBufferLength),autoStartLoad:!0,startFragPrefetch:!0,primarySessionId:n.sessionId,assetPlayerId:c,abrEwmaDefaultEstimate:n.bandwidthEstimate,interstitialsController:void 0,startPosition:l,liveDurationInfinity:!1,testBandwidth:!1,videoPreference:r,audioPreference:s||a.audioPreference,subtitlePreference:u||a.subtitlePreference});e.appendInPlace&&(e.appendInPlaceStarted=!0,t.timelineStart&&(m.timelineOffset=t.timelineStart));var f=m.cmcd;null!=f&&f.sessionId&&f.contentId&&(m.cmcd=eT({},f,{contentId:kI(t.uri)})),this.getAssetPlayer(c)&&this.warn(`Duplicate date range identifier ${e} and asset ${c}`);var v=new CI(this.HlsPlayerClass,m,e,t);this.playerQueue.push(v),e.assetList[i]=t;var p=!0,g=n=>{if(n.live){var a,r=new Error(`Interstitials MUST be VOD assets ${e}`),o={fatal:!0,type:BE.OTHER_ERROR,details:zE.INTERSTITIAL_ASSET_ITEM_ERROR,error:r},s=(null==(a=this.schedule)?void 0:a.findEventIndex(e.identifier))||-1;this.handleAssetItemError(o,e,s,i,r.message)}else{var u=n.edge-n.fragmentStart,l=t.duration;(p||null===l||u>l)&&(p=!1,this.log(`Interstitial asset "${c}" duration change ${l} > ${u}`),t.duration=u,this.updateSchedule())}};v.on(UE.LEVEL_UPDATED,(e,{details:t})=>g(t)),v.on(UE.LEVEL_PTS_UPDATED,(e,{details:t})=>g(t)),v.on(UE.EVENT_CUE_ENTER,()=>this.onInterstitialCueEnter());var y=(e,t)=>{var i=this.getAssetPlayer(c);if(i&&t.tracks){i.off(UE.BUFFER_CODECS,y),i.tracks=t.tracks;var n=this.primaryMedia;this.bufferingAsset===i.assetItem&&n&&!i.media&&this.bufferAssetPlayer(i,n)}};v.on(UE.BUFFER_CODECS,y);v.on(UE.BUFFERED_TO_END,()=>{var i,n=this.getAssetPlayer(c);if(this.log(`buffered to end of asset ${n}`),n&&this.schedule){var a=this.schedule.findEventIndex(e.identifier),r=null==(i=this.schedule.items)?void 0:i[a];this.isInterstitial(r)&&this.advanceAssetBuffering(r,t)}});var b=t=>()=>{if(this.getAssetPlayer(c)&&this.schedule){this.shouldPlay=!0;var i=this.schedule.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,i,t)}};return v.once(UE.MEDIA_ENDED,b(i)),v.once(UE.PLAYOUT_LIMIT_REACHED,b(1/0)),v.on(UE.ERROR,(t,n)=>{if(this.schedule){var a=this.getAssetPlayer(c);if(n.details===zE.BUFFER_STALLED_ERROR)return null!=a&&a.appendInPlace?void this.handleInPlaceStall(e):(this.onTimeupdate(),void this.checkBuffer(!0));this.handleAssetItemError(n,e,this.schedule.findEventIndex(e.identifier),i,`Asset player error ${n.error} ${e}`)}}),v.on(UE.DESTROYING,()=>{if(this.getAssetPlayer(c)&&this.schedule){var t=new Error(`Asset player destroyed unexpectedly ${c}`),n={fatal:!0,type:BE.OTHER_ERROR,details:zE.INTERSTITIAL_ASSET_ITEM_ERROR,error:t};this.handleAssetItemError(n,e,this.schedule.findEventIndex(e.identifier),i,t.message)}}),this.log(`INTERSTITIAL_ASSET_PLAYER_CREATED ${xI(t)}`),this.hls.trigger(UE.INTERSTITIAL_ASSET_PLAYER_CREATED,{asset:t,assetListIndex:i,event:e,player:v}),v}},{key:"clearInterstitial",value:function(e,t){this.clearAssetPlayers(e,t),e.reset()}},{key:"clearAssetPlayers",value:function(e,t){e.assetList.forEach(e=>{this.clearAssetPlayer(e.identifier,t)})}},{key:"resetAssetPlayer",value:function(e){var t=this.getAssetPlayerQueueIndex(e);if(-1!==t){this.log(`reset asset player "${e}" after error`);var i=this.playerQueue[t];this.transferMediaFromPlayer(i,null),i.resetDetails()}}},{key:"clearAssetPlayer",value:function(e,t){var i=this.getAssetPlayerQueueIndex(e);if(-1!==i){var n=this.playerQueue[i];this.log(`clear ${n} toSegment: ${t?LI(t):t}`),this.transferMediaFromPlayer(n,t),this.playerQueue.splice(i,1),n.destroy()}}},{key:"emptyPlayerQueue",value:function(){for(var e;e=this.playerQueue.pop();)e.destroy();this.playerQueue=[]}},{key:"startAssetPlayer",value:function(e,t,i,n,a){var r=e.interstitial,o=e.assetItem,s=e.assetId,u=r.assetList.length,l=this.playingAsset;this.endedAsset=null,this.playingAsset=o,l&&l.identifier===s||(l&&(this.clearAssetPlayer(l.identifier,i[n]),delete l.error),this.log(`INTERSTITIAL_ASSET_STARTED ${t+1}/${u} ${xI(o)}`),this.hls.trigger(UE.INTERSTITIAL_ASSET_STARTED,{asset:o,assetListIndex:t,event:r,schedule:i.slice(0),scheduleIndex:n,player:e})),this.bufferAssetPlayer(e,a)}},{key:"bufferAssetPlayer",value:function(e,t){var i,n;if(this.schedule){var a=e.interstitial,r=e.assetItem,o=this.schedule.findEventIndex(a.identifier),s=null==(i=this.schedule.items)?void 0:i[o];if(s){e.loadSource(),this.setBufferingItem(s),this.bufferingAsset=r;var u=this.getBufferingPlayer();if(u!==e){var l=a.appendInPlace;if(!l||!1!==(null==u?void 0:u.interstitial.appendInPlace)){var d=(null==u?void 0:u.tracks)||(null==(n=this.detachedData)?void 0:n.tracks)||this.requiredTracks;if(l&&r!==this.playingAsset){if(!e.tracks)return void this.log(`Waiting for track info before buffering ${e}`);if(d&&!hT(d,e.tracks)){var h=new Error(`Asset ${xI(r)} SourceBuffer tracks ('${Object.keys(e.tracks)}') are not compatible with primary content tracks ('${Object.keys(d)}')`),c={fatal:!0,type:BE.OTHER_ERROR,details:zE.INTERSTITIAL_ASSET_ITEM_ERROR,error:h},m=a.findAssetIndex(r);return void this.handleAssetItemError(c,a,o,m,h.message)}}this.transferMediaTo(e,t)}}}}}},{key:"handleInPlaceStall",value:function(e){var t=this.schedule,i=this.primaryMedia;if(t&&i){var n=i.currentTime,a=t.findAssetIndex(e,n),r=e.assetList[a];if(r){var o=this.getAssetPlayer(r.identifier);if(o){var s=o.currentTime||n-r.timelineStart,u=o.duration-s;if(this.warn(`Stalled at ${s} of ${s+u} in ${o} ${e} (media.currentTime: ${n})`),s&&(u/i.playbackRate<.5||o.bufferedInPlaceToEnd(i))&&o.hls){var l=t.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,l,a)}}}}}},{key:"advanceInPlace",value:function(e){var t=this.primaryMedia;t&&t.currentTime<e&&(t.currentTime=e)}},{key:"handleAssetItemError",value:function(e,t,i,n,a){if(e.details!==zE.BUFFER_STALLED_ERROR){var r=t.assetList[n]||null;if(this.warn(`INTERSTITIAL_ASSET_ERROR ${r?xI(r):r} ${e.error}`),this.schedule){var o=(null==r?void 0:r.identifier)||"",s=this.getAssetPlayerQueueIndex(o),u=this.playerQueue[s]||null,l=this.schedule.items,d=eT({},e,{fatal:!1,errorAction:vM(!0),asset:r,assetListIndex:n,event:t,schedule:l,scheduleIndex:i,player:u});if(this.hls.trigger(UE.INTERSTITIAL_ASSET_ERROR,d),e.fatal){var h=this.playingAsset,c=this.bufferingAsset,m=new Error(a);if(r&&(this.clearAssetPlayer(o,null),r.error=m),t.assetList.some(e=>!e.error))for(var f=n;f<t.assetList.length;f++)this.resetAssetPlayer(t.assetList[f].identifier);else t.error=m;this.updateSchedule(!0),t.error?this.primaryFallback(t):h&&h.identifier===o?this.advanceAfterAssetEnded(t,i,n):c&&c.identifier===o&&this.isInterstitial(this.bufferingItem)&&this.advanceAssetBuffering(this.bufferingItem,c)}}}}},{key:"primaryFallback",value:function(e){var t=e.timelineStart,i=this.effectivePlayingItem,n=this.timelinePos;if(i){this.log(`Fallback to primary from event "${e.identifier}" start: ${t} pos: ${n} playing: ${LI(i)} error: ${e.error}`),-1===n&&(n=this.hls.startPosition);var a=this.updateItem(i,n);this.itemsMatch(i,a)&&this.clearInterstitial(e,null),e.appendInPlace&&(this.attachPrimary(t,null),this.flushFrontBuffer(t))}else if(-1===n)return void this.checkStart();if(this.schedule){var r=this.schedule.findItemIndexAtTime(n);this.setSchedulePosition(r)}}},{key:"onAssetListLoaded",value:function(e,t){var i,n,a=t.event,r=a.identifier,o=t.assetListResponse.ASSETS;if(null!=(i=this.schedule)&&i.hasEvent(r)){var s=a.timelineStart,u=a.duration,l=0;o.forEach((e,t)=>{var i=parseFloat(e.DURATION);this.createAsset(a,t,l,s+l,i,e.URI),l+=i}),a.duration=l,this.log(`Loaded asset-list with duration: ${l} (was: ${u}) ${a}`);var d=this.waitingItem,h=(null==d?void 0:d.event.identifier)===r;this.updateSchedule();var c=null==(n=this.bufferingItem)?void 0:n.event;if(h){var m,f=this.schedule.findEventIndex(r),v=null==(m=this.schedule.items)?void 0:m[f];if(v){if(!this.playingItem&&this.timelinePos>v.end)if(this.schedule.findItemIndexAtTime(this.timelinePos)!==f)return a.error=new Error(`Interstitial ${o.length?"no longer within playback range":"asset-list is empty"} ${this.timelinePos} ${a}`),this.log(a.error.message),this.updateSchedule(!0),void this.primaryFallback(a);this.setBufferingItem(v)}this.setSchedulePosition(f)}else if((null==c?void 0:c.identifier)===r){var p=a.assetList[0];if(p){var g=this.getAssetPlayer(p.identifier);if(c.appendInPlace){var y=this.primaryMedia;g&&y&&this.bufferAssetPlayer(g,y)}else g&&g.loadSource()}}}}},{key:"onError",value:function(e,t){if(this.schedule)switch(t.details){case zE.ASSET_LIST_PARSING_ERROR:case zE.ASSET_LIST_LOAD_ERROR:case zE.ASSET_LIST_LOAD_TIMEOUT:var i=t.interstitial;i&&(this.updateSchedule(!0),this.primaryFallback(i));break;case zE.BUFFER_STALLED_ERROR:var n=this.endedItem||this.waitingItem||this.playingItem;if(this.isInterstitial(n)&&n.event.appendInPlace)return void this.handleInPlaceStall(n.event);this.log(`Primary player stall @${this.timelinePos} bufferedPos: ${this.bufferedPos}`),this.onTimeupdate(),this.checkBuffer(!0)}}}])}(),WI=function(){function e(t,i,n){var a;return u(this,e),(a=s(this,e,[t,i,n,"subtitle-stream-controller",qE])).currentTrackId=-1,a.tracksBuffered=[],a.mainDetails=null,a.registerListeners(),a}return y(e,pD),m(e,[{key:"onHandlerDestroying",value:function(){this.unregisterListeners(),M(e,"onHandlerDestroying",this)([]),this.mainDetails=null}},{key:"registerListeners",value:function(){M(e,"registerListeners",this)([]);var t=this.hls;t.on(UE.LEVEL_LOADED,this.onLevelLoaded,this),t.on(UE.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(UE.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.on(UE.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(UE.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.on(UE.BUFFER_FLUSHING,this.onBufferFlushing,this)}},{key:"unregisterListeners",value:function(){M(e,"unregisterListeners",this)([]);var t=this.hls;t.off(UE.LEVEL_LOADED,this.onLevelLoaded,this),t.off(UE.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(UE.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.off(UE.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(UE.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.off(UE.BUFFER_FLUSHING,this.onBufferFlushing,this)}},{key:"startLoad",value:function(e,t){this.stopLoad(),this.state=rD,this.setInterval(500),this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}},{key:"onManifestLoading",value:function(){M(e,"onManifestLoading",this)([]),this.mainDetails=null}},{key:"onMediaDetaching",value:function(t,i){this.tracksBuffered=[],M(e,"onMediaDetaching",this)([t,i])}},{key:"onLevelLoaded",value:function(e,t){this.mainDetails=t.details}},{key:"onSubtitleFragProcessed",value:function(e,t){var i=t.frag,n=t.success;if(this.fragContextChanged(i)||(xT(i)&&(this.fragPrevious=i),this.state=rD),n){var a=this.tracksBuffered[this.currentTrackId];if(a){for(var r,o=i.start,s=0;s<a.length;s++)if(o>=a[s].start&&o<=a[s].end){r=a[s];break}var u=i.start+i.duration;r?r.end=u:(r={start:o,end:u},a.push(r)),this.fragmentTracker.fragBuffered(i),this.fragBufferedComplete(i,null),this.media&&this.tick()}}}},{key:"onBufferFlushing",value:function(e,t){var i=t.startOffset,n=t.endOffset;if(0===i&&n!==Number.POSITIVE_INFINITY){var a=n-1;if(a<=0)return;t.endOffsetSubtitles=Math.max(0,a),this.tracksBuffered.forEach(e=>{for(var t=0;t<e.length;)if(e[t].end<=a)e.shift();else{if(!(e[t].start<a))break;e[t].start=a,t++}}),this.fragmentTracker.removeFragmentsInRange(i,a,qE)}}},{key:"onError",value:function(e,t){var i=t.frag;(null==i?void 0:i.type)===qE&&(t.details===zE.FRAG_GAP&&this.fragmentTracker.fragBuffered(i,!0),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==aD&&(this.state=rD))}},{key:"onSubtitleTracksUpdated",value:function(e,{subtitleTracks:t}){this.levels&&eC(this.levels,t)?this.levels=t.map(e=>new RP(e)):(this.tracksBuffered=[],this.levels=t.map(e=>{var t=new RP(e);return this.tracksBuffered[t.id]=[],t}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,qE),this.fragPrevious=null,this.mediaBuffer=null)}},{key:"onSubtitleTrackSwitch",value:function(e,t){var i;if(this.currentTrackId=t.id,null!=(i=this.levels)&&i.length&&-1!==this.currentTrackId){var n=this.levels[this.currentTrackId];null!=n&&n.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,n&&this.state!==aD&&this.setInterval(500)}else this.clearInterval()}},{key:"onSubtitleTrackLoaded",value:function(e,t){var i,n=this.currentTrackId,a=this.levels,r=t.details,o=t.id;if(a){var s=a[o];if(!(o>=a.length)&&s){this.log(`Subtitle track ${o} loaded [${r.startSN},${r.endSN}]${r.lastPartSn?`[part-${r.lastPartSn}-${r.lastPartIndex}]`:""},duration:${r.totalduration}`),this.mediaBuffer=this.mediaBufferTimeRanges;var u=0;if(r.live||null!=(i=s.details)&&i.live){if(r.deltaUpdateFailed)return;var l=this.mainDetails;if(!l)return void(this.startFragRequested=!1);var d,h=l.fragments[0];if(s.details)0===(u=this.alignPlaylists(r,s.details,null==(d=this.levelLastLoaded)?void 0:d.details))&&h&&zA(r,u=h.start);else r.hasProgramDateTime&&l.hasProgramDateTime?(eD(r,l),u=r.fragmentStart):h&&zA(r,u=h.start);l&&!this.startFragRequested&&this.setStartPosition(l,u)}if(s.details=r,this.levelLastLoaded=s,o===n)if(this.hls.trigger(UE.SUBTITLE_TRACK_UPDATED,{details:r,id:o,groupId:t.groupId}),this.tick(),r.live&&!this.fragCurrent&&this.media&&this.state===rD)XP(null,r.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),s.details=void 0)}}else this.warn(`Subtitle tracks were reset while loading level ${o}`)}},{key:"_handleFragmentLoadComplete",value:function(e){var t=e.frag,i=e.payload,n=t.decryptdata,a=this.hls;if(!this.fragContextChanged(t)&&i&&i.byteLength>0&&null!=n&&n.key&&n.iv&&ZM(n.method)){var r=performance.now();this.decrypter.decrypt(new Uint8Array(i),n.key.buffer,n.iv.buffer,eA(n.method)).catch(e=>{throw a.trigger(UE.ERROR,{type:BE.MEDIA_ERROR,details:zE.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:t}),e}).then(e=>{var i=performance.now();a.trigger(UE.FRAG_DECRYPTED,{frag:t,payload:e,stats:{tstart:r,tdecrypt:i}})}).catch(e=>{this.warn(`${e.name}: ${e.message}`),this.state=rD})}}},{key:"doTick",value:function(){if(this.media){if(this.state===rD){var e=this.currentTrackId,t=this.levels,i=null==t?void 0:t[e];if(!i||!t.length||!i.details)return;if(this.waitForLive(i))return;var n=this.config,a=this.getLoadPosition(),r=$M.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],a,n.maxBufferHole),o=r.end,s=r.len,u=i.details;if(s>this.hls.maxBufferLength+u.levelTargetDuration)return;var l=u.fragments,d=l.length,h=u.edge,c=null,m=this.fragPrevious;if(o<h){var f=n.maxFragLookUpTolerance,v=o>h-f?0:f;!(c=XP(m,l,Math.max(l[0].start,o),v))&&m&&m.start<l[0].start&&(c=l[0])}else c=l[d-1];if(!(c=this.filterReplacedPrimary(c,i.details)))return;var p=l[c.sn-u.startSN-1];if(p&&p.cc===c.cc&&this.fragmentTracker.getState(p)===pM&&(c=p),this.fragmentTracker.getState(c)===pM){var g=this.mapToInitFragWhenRequired(c);g&&this.loadFragment(g,i,o)}}}else this.state=rD}},{key:"loadFragment",value:function(t,i,n){xT(t)?M(e,"loadFragment",this)([t,i,n]):this._loadInitSegment(t,i)}},{key:"mediaBufferTimeRanges",get:function(){return new $I(this.tracksBuffered[this.currentTrackId]||[])}}])}(),$I=m(function e(t){u(this,e),this.buffered=void 0;var i=(e,i,n)=>{if((i>>>=0)>n-1)throw new DOMException(`Failed to execute '${e}' on 'TimeRanges': The index provided (${i}) is greater than the maximum bound (${n})`);return t[i][e]};this.buffered={get length(){return t.length},end:e=>i("end",e,t.length),start:e=>i("start",e,t.length)}}),NI={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},jI=e=>String.fromCharCode(NI[e]||e),BI=15,zI=100,UI={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},HI={17:2,18:4,21:6,22:8,23:10,19:13,20:15},GI={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},VI={25:2,26:4,29:6,30:8,31:10,27:13,28:15},KI=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],XI=function(){return m(function e(){u(this,e),this.time=null,this.verboseLevel=0},[{key:"log",value:function(e,t){if(this.verboseLevel>=e){var i="function"==typeof t?t():t;lT.log(`${this.time} [${e}] ${i}`)}}}])}(),YI=function(e){for(var t=[],i=0;i<e.length;i++)t.push(e[i].toString(16));return t},qI=function(){return m(function e(){u(this,e),this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},[{key:"reset",value:function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}},{key:"setStyles",value:function(e){for(var t=["foreground","underline","italics","background","flash"],i=0;i<t.length;i++){var n=t[i];e.hasOwnProperty(n)&&(this[n]=e[n])}}},{key:"isDefault",value:function(){return"white"===this.foreground&&!this.underline&&!this.italics&&"black"===this.background&&!this.flash}},{key:"equals",value:function(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash}},{key:"copy",value:function(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash}},{key:"toString",value:function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}}])}(),JI=function(){return m(function e(){u(this,e),this.uchar=" ",this.penState=new qI},[{key:"reset",value:function(){this.uchar=" ",this.penState.reset()}},{key:"setChar",value:function(e,t){this.uchar=e,this.penState.copy(t)}},{key:"setPenState",value:function(e){this.penState.copy(e)}},{key:"equals",value:function(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)}},{key:"copy",value:function(e){this.uchar=e.uchar,this.penState.copy(e.penState)}},{key:"isEmpty",value:function(){return" "===this.uchar&&this.penState.isDefault()}}])}(),QI=function(){return m(function e(t){u(this,e),this.chars=[],this.pos=0,this.currPenState=new qI,this.cueStartTime=null,this.logger=void 0;for(var i=0;i<zI;i++)this.chars.push(new JI);this.logger=t},[{key:"equals",value:function(e){for(var t=0;t<zI;t++)if(!this.chars[t].equals(e.chars[t]))return!1;return!0}},{key:"copy",value:function(e){for(var t=0;t<zI;t++)this.chars[t].copy(e.chars[t])}},{key:"isEmpty",value:function(){for(var e=!0,t=0;t<zI;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e}},{key:"setCursor",value:function(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>zI&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=zI)}},{key:"moveCursor",value:function(e){var t=this.pos+e;if(e>1)for(var i=this.pos+1;i<t+1;i++)this.chars[i].setPenState(this.currPenState);this.setCursor(t)}},{key:"backSpace",value:function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}},{key:"insertChar",value:function(e){e>=144&&this.backSpace();var t=jI(e);this.pos>=zI?this.logger.log(0,()=>"Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!"):(this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1))}},{key:"clearFromPos",value:function(e){var t;for(t=e;t<zI;t++)this.chars[t].reset()}},{key:"clear",value:function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}},{key:"clearToEndOfRow",value:function(){this.clearFromPos(this.pos)}},{key:"getTextString",value:function(){for(var e=[],t=!0,i=0;i<zI;i++){var n=this.chars[i].uchar;" "!==n&&(t=!1),e.push(n)}return t?"":e.join("")}},{key:"setPenStyles",value:function(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)}}])}(),ZI=function(){return m(function e(t){u(this,e),this.rows=[],this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(var i=0;i<BI;i++)this.rows.push(new QI(t));this.logger=t},[{key:"reset",value:function(){for(var e=0;e<BI;e++)this.rows[e].clear();this.currRow=14}},{key:"equals",value:function(e){for(var t=!0,i=0;i<BI;i++)if(!this.rows[i].equals(e.rows[i])){t=!1;break}return t}},{key:"copy",value:function(e){for(var t=0;t<BI;t++)this.rows[t].copy(e.rows[t])}},{key:"isEmpty",value:function(){for(var e=!0,t=0;t<BI;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e}},{key:"backSpace",value:function(){this.rows[this.currRow].backSpace()}},{key:"clearToEndOfRow",value:function(){this.rows[this.currRow].clearToEndOfRow()}},{key:"insertChar",value:function(e){this.rows[this.currRow].insertChar(e)}},{key:"setPen",value:function(e){this.rows[this.currRow].setPenStyles(e)}},{key:"moveCursor",value:function(e){this.rows[this.currRow].moveCursor(e)}},{key:"setCursor",value:function(e){this.logger.log(2,"setCursor: "+e),this.rows[this.currRow].setCursor(e)}},{key:"setPAC",value:function(e){this.logger.log(2,()=>"pacData = "+WP(e));var t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(var i=0;i<BI;i++)this.rows[i].clear();var n=this.currRow+1-this.nrRollUpRows,a=this.lastOutputScreen;if(a){var r=a.rows[n].cueStartTime,o=this.logger.time;if(null!==r&&null!==o&&r<o)for(var s=0;s<this.nrRollUpRows;s++)this.rows[t-this.nrRollUpRows+s+1].copy(a.rows[n+s])}}this.currRow=t;var u=this.rows[this.currRow];if(null!==e.indent){var l=e.indent,d=Math.max(l-1,0);u.setCursor(e.indent),e.color=u.chars[d].penState.foreground}var h={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(h)}},{key:"setBkgData",value:function(e){this.logger.log(2,()=>"bkgData = "+WP(e)),this.backSpace(),this.setPen(e),this.insertChar(32)}},{key:"setRollUpRows",value:function(e){this.nrRollUpRows=e}},{key:"rollUp",value:function(){if(null!==this.nrRollUpRows){this.logger.log(1,()=>this.getDisplayText());var e=this.currRow+1-this.nrRollUpRows,t=this.rows.splice(e,1)[0];t.clear(),this.rows.splice(this.currRow,0,t),this.logger.log(2,"Rolling up")}else this.logger.log(3,"roll_up but nrRollUpRows not set yet")}},{key:"getDisplayText",value:function(e){e=e||!1;for(var t=[],i="",n=-1,a=0;a<BI;a++){var r=this.rows[a].getTextString();r&&(n=a+1,e?t.push("Row "+n+": '"+r+"'"):t.push(r.trim()))}return t.length>0&&(i=e?"["+t.join(" | ")+"]":t.join("\n")),i}},{key:"getTextAndFormat",value:function(){return this.rows}}])}(),eL=function(){return m(function e(t,i,n){u(this,e),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=i,this.mode=null,this.verbose=0,this.displayedMemory=new ZI(n),this.nonDisplayedMemory=new ZI(n),this.lastOutputScreen=new ZI(n),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=n},[{key:"reset",value:function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}},{key:"getHandler",value:function(){return this.outputFilter}},{key:"setHandler",value:function(e){this.outputFilter=e}},{key:"setPAC",value:function(e){this.writeScreen.setPAC(e)}},{key:"setBkgData",value:function(e){this.writeScreen.setBkgData(e)}},{key:"setMode",value:function(e){e!==this.mode&&(this.mode=e,this.logger.log(2,()=>"MODE="+e),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)}},{key:"insertChars",value:function(e){for(var t=0;t<e.length;t++)this.writeScreen.insertChar(e[t]);var i=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,()=>i+": "+this.writeScreen.getDisplayText(!0)),"MODE_PAINT-ON"!==this.mode&&"MODE_ROLL-UP"!==this.mode||(this.logger.log(1,()=>"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())}},{key:"ccRCL",value:function(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}},{key:"ccBS",value:function(){this.logger.log(2,"BS - BackSpace"),"MODE_TEXT"!==this.mode&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}},{key:"ccAOF",value:function(){}},{key:"ccAON",value:function(){}},{key:"ccDER",value:function(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}},{key:"ccRU",value:function(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)}},{key:"ccFON",value:function(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}},{key:"ccRDC",value:function(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}},{key:"ccTR",value:function(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}},{key:"ccRTD",value:function(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}},{key:"ccEDM",value:function(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}},{key:"ccCR",value:function(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}},{key:"ccENM",value:function(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}},{key:"ccEOC",value:function(){if(this.logger.log(2,"EOC - End Of Caption"),"MODE_POP-ON"===this.mode){var e=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,()=>"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)}},{key:"ccTO",value:function(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)}},{key:"ccMIDROW",value:function(e){var t={flash:!1};if(t.underline=e%2==1,t.italics=e>=46,t.italics)t.foreground="white";else{var i=Math.floor(e/2)-16;t.foreground=["white","green","blue","cyan","red","yellow","magenta"][i]}this.logger.log(2,"MIDROW: "+WP(t)),this.writeScreen.setPen(t)}},{key:"outputDataUpdate",value:function(e=!1){var t=this.logger.time;null!==t&&this.outputFilter&&(null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t):this.cueStartTime=t,this.lastOutputScreen.copy(this.displayedMemory))}},{key:"cueSplitAtTime",value:function(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))}}])}(),tL=function(){return m(function e(t,i,n){u(this,e),this.channels=void 0,this.currentChannel=0,this.cmdHistory={a:null,b:null},this.logger=void 0;var a=this.logger=new XI;this.channels=[null,new eL(t,i,a),new eL(t+1,n,a)]},[{key:"getHandler",value:function(e){return this.channels[e].getHandler()}},{key:"setHandler",value:function(e,t){this.channels[e].setHandler(t)}},{key:"addData",value:function(e,t){var i=this;this.logger.time=e;for(var n=function(e){var n=127&t[e],a=127&t[e+1],r=!1,o=null;if(0===n&&0===a)return 0;i.logger.log(3,()=>"["+YI([t[e],t[e+1]])+"] -> ("+YI([n,a])+")");var s=i.cmdHistory;if(n>=16&&n<=31){if(function(e,t,i){return i.a===e&&i.b===t}(n,a,s))return iL(null,null,s),i.logger.log(3,()=>"Repeated command ("+YI([n,a])+") is dropped"),0;iL(n,a,i.cmdHistory),(r=i.parseCmd(n,a))||(r=i.parseMidrow(n,a)),r||(r=i.parsePAC(n,a)),r||(r=i.parseBackgroundAttributes(n,a))}else iL(null,null,s);if(!r&&(o=i.parseChars(n,a))){var u=i.currentChannel;if(u&&u>0)i.channels[u].insertChars(o);else i.logger.log(2,"No channel found yet. TEXT-MODE?")}r||o||i.logger.log(2,()=>"Couldn't parse cleaned data "+YI([n,a])+" orig: "+YI([t[e],t[e+1]]))},a=0;a<t.length;a+=2)n(a)}},{key:"parseCmd",value:function(e,t){if(!((20===e||28===e||21===e||29===e)&&t>=32&&t<=47)&&!((23===e||31===e)&&t>=33&&t<=35))return!1;var i=20===e||21===e||23===e?1:2,n=this.channels[i];return 20===e||21===e||28===e||29===e?32===t?n.ccRCL():33===t?n.ccBS():34===t?n.ccAOF():35===t?n.ccAON():36===t?n.ccDER():37===t?n.ccRU(2):38===t?n.ccRU(3):39===t?n.ccRU(4):40===t?n.ccFON():41===t?n.ccRDC():42===t?n.ccTR():43===t?n.ccRTD():44===t?n.ccEDM():45===t?n.ccCR():46===t?n.ccENM():47===t&&n.ccEOC():n.ccTO(t-32),this.currentChannel=i,!0}},{key:"parseMidrow",value:function(e,t){var i=0;if((17===e||25===e)&&t>=32&&t<=47){if((i=17===e?1:2)!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;var n=this.channels[i];return!!n&&(n.ccMIDROW(t),this.logger.log(3,()=>"MIDROW ("+YI([e,t])+")"),!0)}return!1}},{key:"parsePAC",value:function(e,t){var i;if(!((e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127)&&!((16===e||24===e)&&t>=64&&t<=95))return!1;var n=e<=23?1:2;i=t>=64&&t<=95?1===n?UI[e]:GI[e]:1===n?HI[e]:VI[e];var a=this.channels[n];return!!a&&(a.setPAC(this.interpretPAC(i,t)),this.currentChannel=n,!0)}},{key:"interpretPAC",value:function(e,t){var i,n={color:null,italics:!1,indent:null,underline:!1,row:e};return i=t>95?t-96:t-64,n.underline=!(1&~i),i<=13?n.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(i/2)]:i<=15?(n.italics=!0,n.color="white"):n.indent=4*Math.floor((i-16)/2),n}},{key:"parseChars",value:function(e,t){var i,n,a=null,r=null;(e>=25?(i=2,r=e-8):(i=1,r=e),r>=17&&r<=19)?(n=17===r?t+80:18===r?t+112:t+144,this.logger.log(2,()=>"Special char '"+jI(n)+"' in channel "+i),a=[n]):e>=32&&e<=127&&(a=0===t?[e]:[e,t]);return a&&this.logger.log(3,()=>"Char codes = "+YI(a).join(",")),a}},{key:"parseBackgroundAttributes",value:function(e,t){var i;if(!((16===e||24===e)&&t>=32&&t<=47)&&!((23===e||31===e)&&t>=45&&t<=47))return!1;var n={};16===e||24===e?(i=Math.floor((t-32)/2),n.background=KI[i],t%2==1&&(n.background=n.background+"_semi")):45===t?n.background="transparent":(n.foreground="black",47===t&&(n.underline=!0));var a=e<=23?1:2;return this.channels[a].setBkgData(n),!0}},{key:"reset",value:function(){for(var e=0;e<Object.keys(this.channels).length;e++){var t=this.channels[e];t&&t.reset()}iL(null,null,this.cmdHistory)}},{key:"cueSplitAtTime",value:function(e){for(var t=0;t<this.channels.length;t++){var i=this.channels[t];i&&i.cueSplitAtTime(e)}}}])}();function iL(e,t,i){i.a=e,i.b=t}var nL=function(){if(null!=rA&&rA.VTTCue)return self.VTTCue;var e=["","lr","rl"],t=["start","middle","end","left","right"];function i(e,t){if("string"!=typeof t)return!1;if(!Array.isArray(e))return!1;var i=t.toLowerCase();return!!~e.indexOf(i)&&i}function n(e){return i(t,e)}function a(e,...t){for(var i=1;i<arguments.length;i++){var n=arguments[i];for(var a in n)e[a]=n[a]}return e}function r(t,r,o){var s=this,u={enumerable:!0};s.hasBeenReset=!1;var l="",d=!1,h=t,c=r,m=o,f=null,v="",p=!0,g="auto",y="start",b=50,w="middle",k=50,S="middle";Object.defineProperty(s,"id",a({},u,{get:function(){return l},set:function(e){l=""+e}})),Object.defineProperty(s,"pauseOnExit",a({},u,{get:function(){return d},set:function(e){d=!!e}})),Object.defineProperty(s,"startTime",a({},u,{get:function(){return h},set:function(e){if("number"!=typeof e)throw new TypeError("Start time must be set to a number.");h=e,this.hasBeenReset=!0}})),Object.defineProperty(s,"endTime",a({},u,{get:function(){return c},set:function(e){if("number"!=typeof e)throw new TypeError("End time must be set to a number.");c=e,this.hasBeenReset=!0}})),Object.defineProperty(s,"text",a({},u,{get:function(){return m},set:function(e){m=""+e,this.hasBeenReset=!0}})),Object.defineProperty(s,"region",a({},u,{get:function(){return f},set:function(e){f=e,this.hasBeenReset=!0}})),Object.defineProperty(s,"vertical",a({},u,{get:function(){return v},set:function(t){var n=function(t){return i(e,t)}(t);if(!1===n)throw new SyntaxError("An invalid or illegal string was specified.");v=n,this.hasBeenReset=!0}})),Object.defineProperty(s,"snapToLines",a({},u,{get:function(){return p},set:function(e){p=!!e,this.hasBeenReset=!0}})),Object.defineProperty(s,"line",a({},u,{get:function(){return g},set:function(e){if("number"!=typeof e&&"auto"!==e)throw new SyntaxError("An invalid number or illegal string was specified.");g=e,this.hasBeenReset=!0}})),Object.defineProperty(s,"lineAlign",a({},u,{get:function(){return y},set:function(e){var t=n(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");y=t,this.hasBeenReset=!0}})),Object.defineProperty(s,"position",a({},u,{get:function(){return b},set:function(e){if(e<0||e>100)throw new Error("Position must be between 0 and 100.");b=e,this.hasBeenReset=!0}})),Object.defineProperty(s,"positionAlign",a({},u,{get:function(){return w},set:function(e){var t=n(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");w=t,this.hasBeenReset=!0}})),Object.defineProperty(s,"size",a({},u,{get:function(){return k},set:function(e){if(e<0||e>100)throw new Error("Size must be between 0 and 100.");k=e,this.hasBeenReset=!0}})),Object.defineProperty(s,"align",a({},u,{get:function(){return S},set:function(e){var t=n(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");S=t,this.hasBeenReset=!0}})),s.displayState=void 0}return r.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},r}(),aL=function(){return m(function e(){u(this,e)},[{key:"decode",value:function(e,t){if(!e)return"";if("string"!=typeof e)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}])}();function rL(e){function t(e,t,i,n){return 3600*(0|e)+60*(0|t)+(0|i)+parseFloat(n||0)}var i=e.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return i?parseFloat(i[2])>59?t(i[2],i[3],0,i[4]):t(i[1],i[2],i[3],i[4]):null}var oL=function(){return m(function e(){u(this,e),this.values=Object.create(null)},[{key:"set",value:function(e,t){this.get(e)||""===t||(this.values[e]=t)}},{key:"get",value:function(e,t,i){return i?this.has(e)?this.values[e]:t[i]:this.has(e)?this.values[e]:t}},{key:"has",value:function(e){return e in this.values}},{key:"alt",value:function(e,t,i){for(var n=0;n<i.length;++n)if(t===i[n]){this.set(e,t);break}}},{key:"integer",value:function(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))}},{key:"percent",value:function(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){var i=parseFloat(t);if(i>=0&&i<=100)return this.set(e,i),!0}return!1}}])}();function sL(e,t,i,n){var a=n?e.split(n):[e];for(var r in a)if("string"==typeof a[r]){var o=a[r].split(i);if(2===o.length)t(o[0],o[1])}}var uL=new nL(0,0,""),lL="middle"===uL.align?"middle":"center";function dL(e,t,i){var n=e;function a(){var t=rL(e);if(null===t)throw new Error("Malformed timestamp: "+n);return e=e.replace(/^[^\sa-zA-Z-]+/,""),t}function r(){e=e.replace(/^\s+/,"")}if(r(),t.startTime=a(),r(),"--\x3e"!==e.slice(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+n);e=e.slice(3),r(),t.endTime=a(),r(),function(e,t){var n=new oL;sL(e,function(e,t){var a;switch(e){case"region":for(var r=i.length-1;r>=0;r--)if(i[r].id===t){n.set(e,i[r].region);break}break;case"vertical":n.alt(e,t,["rl","lr"]);break;case"line":a=t.split(","),n.integer(e,a[0]),n.percent(e,a[0])&&n.set("snapToLines",!1),n.alt(e,a[0],["auto"]),2===a.length&&n.alt("lineAlign",a[1],["start",lL,"end"]);break;case"position":a=t.split(","),n.percent(e,a[0]),2===a.length&&n.alt("positionAlign",a[1],["start",lL,"end","line-left","line-right","auto"]);break;case"size":n.percent(e,t);break;case"align":n.alt(e,t,["start",lL,"end","left","right"])}},/:/,/\s/),t.region=n.get("region",null),t.vertical=n.get("vertical","");var a=n.get("line","auto");"auto"===a&&-1===uL.line&&(a=-1),t.line=a,t.lineAlign=n.get("lineAlign","start"),t.snapToLines=n.get("snapToLines",!0),t.size=n.get("size",100),t.align=n.get("align",lL);var r=n.get("position","auto");"auto"===r&&50===uL.position&&(r="start"===t.align||"left"===t.align?0:"end"===t.align||"right"===t.align?100:50),t.position=r}(e,t)}function hL(e){return e.replace(/<br(?: \/)?>/gi,"\n")}var cL=function(){return m(function e(){u(this,e),this.state="INITIAL",this.buffer="",this.decoder=new aL,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0},[{key:"parse",value:function(e){var t=this;function i(){var e=t.buffer,i=0;for(e=hL(e);i<e.length&&"\r"!==e[i]&&"\n"!==e[i];)++i;var n=e.slice(0,i);return"\r"===e[i]&&++i,"\n"===e[i]&&++i,t.buffer=e.slice(i),n}function n(e){sL(e,function(e,t){},/:/)}e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));try{var a="";if("INITIAL"===t.state){if(!/\r\n|\n/.test(t.buffer))return this;var r=(a=i()).match(/^()?WEBVTT([ \t].*)?$/);if(null==r||!r[0])throw new Error("Malformed WebVTT signature.");t.state="HEADER"}for(var o=!1;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(o?o=!1:a=i(),t.state){case"HEADER":/:/.test(a)?n(a):a||(t.state="ID");continue;case"NOTE":a||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(a)){t.state="NOTE";break}if(!a)continue;if(t.cue=new nL(0,0,""),t.state="CUE",-1===a.indexOf("--\x3e")){t.cue.id=a;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{dL(a,t.cue,t.regionList)}catch(e){t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":var s=-1!==a.indexOf("--\x3e");if(!a||s&&(o=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(null===t.cue)continue;t.cue.text&&(t.cue.text+="\n"),t.cue.text+=a;continue;case"BADCUE":a||(t.state="ID")}}}catch(e){"CUETEXT"===t.state&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state="INITIAL"===t.state?"BADWEBVTT":"BADCUE"}return this}},{key:"flush",value:function(){var e=this;try{if((e.cue||"HEADER"===e.state)&&(e.buffer+="\n\n",e.parse()),"INITIAL"===e.state||"BADWEBVTT"===e.state)throw new Error("Malformed WebVTT signature.")}catch(t){e.onparsingerror&&e.onparsingerror(t)}return e.onflush&&e.onflush(),this}}])}(),mL=/\r\n|\n\r|\n|\r/g,fL=function(e,t,i=0){return e.slice(i,i+t.length)===t};function vL(e,t,i){return kI(e.toString())+kI(t.toString())+kI(i)}function pL(e,t,i,n,a,r,o){var s,u=new cL,l=cT(new Uint8Array(e)).trim().replace(mL,"\n").split("\n"),d=[],h=t?function(e,t=1){return Cx(e,9e4,1/t)}(t.baseTime,t.timescale):0,c="00:00.000",m=0,f=0,v=!0;u.oncue=function(e){var r=i[n],o=i.ccOffset,u=(m-h)/9e4;if(null!=r&&r.new&&(void 0!==f?o=i.ccOffset=r.start:function(e,t,i){var n=e[t],a=e[n.prevCC];if(!a||!a.new&&n.new)return e.ccOffset=e.presentationOffset=n.start,void(n.new=!1);for(;null!=(r=a)&&r.new;){var r;e.ccOffset+=n.start-a.start,n.new=!1,a=e[(n=a).prevCC]}e.presentationOffset=i}(i,n,u)),u){if(!t)return void(s=new Error("Missing initPTS for VTT MPEGTS"));o=u-i.presentationOffset}var l=e.endTime-e.startTime,c=Wx(9e4*(e.startTime+o-f),9e4*a)/9e4;e.startTime=Math.max(c,0),e.endTime=Math.max(c+l,0);var v=e.text.trim();e.text=decodeURIComponent(encodeURIComponent(v)),e.id||(e.id=vL(e.startTime,e.endTime,v)),e.endTime>0&&d.push(e)},u.onparsingerror=function(e){s=e},u.onflush=function(){s?o(s):r(d)},l.forEach(e=>{if(v){if(fL(e,"X-TIMESTAMP-MAP=")){v=!1,e.slice(16).split(",").forEach(e=>{fL(e,"LOCAL:")?c=e.slice(6):fL(e,"MPEGTS:")&&(m=parseInt(e.slice(7)))});try{f=function(e){var t=parseInt(e.slice(-3)),i=parseInt(e.slice(-6,-4)),n=parseInt(e.slice(-9,-7)),a=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!($E(t)&&$E(i)&&$E(n)&&$E(a)))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*i,t+=6e4*n,t+36e5*a}(c)/1e3}catch(e){s=e}return}""===e&&(v=!1)}u.parse(e+"\n")}),u.flush()}var gL="stpp.ttml.im1t",yL=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,bL=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,wL={left:"start",center:"center",right:"end",start:"start",end:"end"};function kL(e,t,i,n){var a=BT(new Uint8Array(e),["mdat"]);if(0!==a.length){var r=a.map(e=>cT(e)),o=function(e,t,i=1,n=!1){return Cx(e,t,1/i,n)}(t.baseTime,1,t.timescale);try{r.forEach(e=>i(function(e,t){var i=(new DOMParser).parseFromString(e,"text/xml"),n=i.getElementsByTagName("tt")[0];if(!n)throw new Error("Invalid ttml");var a={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},r=Object.keys(a).reduce((e,t)=>(e[t]=n.getAttribute(`ttp:${t}`)||a[t],e),{}),o="preserve"!==n.getAttribute("xml:space"),s=EL(SL(n,"styling","style")),u=EL(SL(n,"layout","region")),l=SL(n,"body","[begin]");return[].map.call(l,e=>{var i=TL(e,o);if(!i||!e.hasAttribute("begin"))return null;var n=AL(e.getAttribute("begin"),r),a=AL(e.getAttribute("dur"),r),l=AL(e.getAttribute("end"),r);if(null===n)throw ML(e);if(null===l){if(null===a)throw ML(e);l=n+a}var d=new nL(n-t,l-t,i);d.id=vL(d.startTime,d.endTime,d.text);var h=function(e,t,i){var n="http://www.w3.org/ns/ttml#styling",a=null,r=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],o=null!=e&&e.hasAttribute("style")?e.getAttribute("style"):null;o&&i.hasOwnProperty(o)&&(a=i[o]);return r.reduce((i,r)=>{var o=PL(t,n,r)||PL(e,n,r)||PL(a,n,r);return o&&(i[r]=o),i},{})}(u[e.getAttribute("region")],s[e.getAttribute("style")],s),c=h.textAlign;if(c){var m=wL[c];m&&(d.lineAlign=m),d.align=c}return eT(d,h),d}).filter(e=>null!==e)}(e,o)))}catch(e){n(e)}}else n(new Error("Could not parse IMSC1 mdat"))}function SL(e,t,i){var n=e.getElementsByTagName(t)[0];return n?[].slice.call(n.querySelectorAll(i)):[]}function EL(e){return e.reduce((e,t)=>{var i=t.getAttribute("xml:id");return i&&(e[i]=t),e},{})}function TL(e,t){return[].slice.call(e.childNodes).reduce((e,i,n)=>{var a;return"br"===i.nodeName&&n?e+"\n":null!=(a=i.childNodes)&&a.length?TL(i,t):t?e+i.textContent.trim().replace(/\s+/g," "):e+i.textContent},"")}function PL(e,t,i){return e&&e.hasAttributeNS(t,i)?e.getAttributeNS(t,i):null}function ML(e){return new Error(`Could not parse ttml timestamp ${e}`)}function AL(e,t){if(!e)return null;var i=rL(e);return null===i&&(yL.test(e)?i=function(e,t){var i=yL.exec(e),n=(0|i[4])+(0|i[5])/t.subFrameRate;return 3600*(0|i[1])+60*(0|i[2])+(0|i[3])+n/t.frameRate}(e,t):bL.test(e)&&(i=function(e,t){var i=bL.exec(e),n=Number(i[1]);switch(i[2]){case"h":return 3600*n;case"m":return 60*n;case"ms":return 1e3*n;case"f":return n/t.frameRate;case"t":return n/t.tickRate}return n}(e,t))),i}var DL=function(){return m(function e(t,i){u(this,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=i},[{key:"dispatchCue",value:function(){null!==this.startTime&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}},{key:"newCue",value:function(e,t,i){(null===this.startTime||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=i,this.timelineController.createCaptionsTrack(this.trackName)}},{key:"reset",value:function(){this.cueRanges=[],this.startTime=null}}])}(),xL=function(){return m(function e(t){u(this,e),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.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},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}},t.on(UE.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(UE.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(UE.MANIFEST_LOADING,this.onManifestLoading,this),t.on(UE.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(UE.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(UE.FRAG_LOADING,this.onFragLoading,this),t.on(UE.FRAG_LOADED,this.onFragLoaded,this),t.on(UE.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.on(UE.FRAG_DECRYPTED,this.onFragDecrypted,this),t.on(UE.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(UE.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.on(UE.BUFFER_FLUSHING,this.onBufferFlushing,this)},[{key:"destroy",value:function(){var e=this.hls;e.off(UE.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(UE.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(UE.MANIFEST_LOADING,this.onManifestLoading,this),e.off(UE.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(UE.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(UE.FRAG_LOADING,this.onFragLoading,this),e.off(UE.FRAG_LOADED,this.onFragLoaded,this),e.off(UE.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(UE.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(UE.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(UE.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(UE.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.media=null,this.cea608Parser1=this.cea608Parser2=void 0}},{key:"initCea608Parsers",value:function(){var e=new DL(this,"textTrack1"),t=new DL(this,"textTrack2"),i=new DL(this,"textTrack3"),n=new DL(this,"textTrack4");this.cea608Parser1=new tL(1,e,t),this.cea608Parser2=new tL(3,i,n)}},{key:"addCues",value:function(e,t,i,n,a){for(var r=!1,o=a.length;o--;){var s=a[o],u=LL(s[0],s[1],t,i);if(u>=0&&(s[0]=Math.min(s[0],t),s[1]=Math.max(s[1],i),r=!0,u/(i-t)>.5))return}if(r||a.push([t,i]),this.config.renderTextTracksNatively){var l=this.captionsTracks[e];this.Cues.newCue(l,t,i,n)}else{var d=this.Cues.newCue(null,t,i,n);this.hls.trigger(UE.CUES_PARSED,{type:"captions",cues:d,track:e})}}},{key:"onInitPtsFound",value:function(e,{frag:t,id:i,initPTS:n,timescale:a,trackId:r}){var o=this.unparsedVttFrags;i===XE&&(this.initPTS[t.cc]={baseTime:n,timescale:a,trackId:r}),o.length&&(this.unparsedVttFrags=[],o.forEach(e=>{this.initPTS[e.frag.cc]?this.onFragLoaded(UE.FRAG_LOADED,e):this.hls.trigger(UE.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e.frag,error:new Error("Subtitle discontinuity domain does not match main")})}))}},{key:"getExistingTrack",value:function(e,t){var i=this.media;if(i)for(var n=0;n<i.textTracks.length;n++){var a=i.textTracks[n];if(IL(a,{name:e,lang:t,characteristics:"transcribes-spoken-dialog,describes-music-and-sound"}))return a}return null}},{key:"createCaptionsTrack",value:function(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}},{key:"createNativeTrack",value:function(e){if(!this.captionsTracks[e]){var t=this.captionsProperties,i=this.captionsTracks,n=this.media,a=t[e],r=a.label,o=a.languageCode,s=this.getExistingTrack(r,o);if(s)i[e]=s,gI(i[e]),vI(i[e],n);else{var u=this.createTextTrack("captions",r,o);u&&(u[e]=!0,i[e]=u)}}}},{key:"createNonNativeTrack",value:function(e){if(!this.nonNativeCaptionsTracks[e]){var t=this.captionsProperties[e];if(t){var i={_id:e,label:t.label,kind:"captions",default:!!t.media&&!!t.media.default,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=i,this.hls.trigger(UE.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[i]})}}}},{key:"createTextTrack",value:function(e,t,i){var n=this.media;if(n)return n.addTextTrack(e,t,i)}},{key:"onMediaAttaching",value:function(e,t){this.media=t.media,t.mediaSource||this._cleanTracks()}},{key:"onMediaDetaching",value:function(e,t){var i=!!t.transferMedia;if(this.media=null,!i){var n=this.captionsTracks;Object.keys(n).forEach(e=>{gI(n[e]),delete n[e]}),this.nonNativeCaptionsTracks={}}}},{key:"onManifestLoading",value:function(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}},{key:"_cleanTracks",value:function(){var e=this.media;if(e){var t=e.textTracks;if(t)for(var i=0;i<t.length;i++)gI(t[i])}}},{key:"onSubtitleTracksUpdated",value:function(e,t){var i=t.subtitleTracks||[],n=i.some(e=>e.textCodec===gL);if(this.config.enableWebVTT||n&&this.config.enableIMSC1){if(eC(this.tracks,i))return void(this.tracks=i);if(this.textTracks=[],this.tracks=i,this.config.renderTextTracksNatively){var a=this.media,r=a?bI(a.textTracks):null;if(this.tracks.forEach((e,t)=>{var i;if(r){for(var n=null,a=0;a<r.length;a++)if(r[a]&&IL(r[a],e)){n=r[a],r[a]=null;break}n&&(i=n)}if(i)gI(i);else{var o=CL(e);(i=this.createTextTrack(o,e.name,e.lang))&&(i.mode="disabled")}i&&this.textTracks.push(i)}),null!=r&&r.length){var o=r.filter(e=>null!==e).map(e=>e.label);o.length&&this.hls.logger.warn(`Media element contains unused subtitle tracks: ${o.join(", ")}. Replace media element for each source to clear TextTracks and captions menu.`)}}else if(this.tracks.length){var s=this.tracks.map(e=>({label:e.name,kind:e.type.toLowerCase(),default:e.default,subtitleTrack:e}));this.hls.trigger(UE.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:s})}}}},{key:"onManifestLoaded",value:function(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(e=>{var t=/(?:CC|SERVICE)([1-4])/.exec(e.instreamId);if(t){var i=`textTrack${t[1]}`,n=this.captionsProperties[i];n&&(n.label=e.name,e.lang&&(n.languageCode=e.lang),n.media=e)}})}},{key:"closedCaptionsForLevel",value:function(e){var t=this.hls.levels[e.level];return null==t?void 0:t.attrs["CLOSED-CAPTIONS"]}},{key:"onFragLoading",value:function(e,t){if(this.enabled&&t.frag.type===XE){var i,n,a=this.cea608Parser1,r=this.cea608Parser2,o=this.lastSn,s=t.frag,u=s.cc,l=s.sn,d=null!=(i=null==(n=t.part)?void 0:n.index)?i:-1;a&&r&&(l!==o+1||l===o&&d!==this.lastPartIndex+1||u!==this.lastCc)&&(a.reset(),r.reset()),this.lastCc=u,this.lastSn=l,this.lastPartIndex=d}}},{key:"onFragLoaded",value:function(e,t){var i=t.frag,n=t.payload;if(i.type===qE)if(n.byteLength){var a=i.decryptdata,r="stats"in t;if(null==a||!a.encrypted||r){var o=this.tracks[i.level],s=this.vttCCs;s[i.cc]||(s[i.cc]={start:i.start,prevCC:this.prevCC,new:!0},this.prevCC=i.cc),o&&o.textCodec===gL?this._parseIMSC1(i,n):this._parseVTTs(t)}}else this.hls.trigger(UE.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Empty subtitle payload")})}},{key:"_parseIMSC1",value:function(e,t){var i=this.hls;kL(t,this.initPTS[e.cc],t=>{this._appendCues(t,e.level),i.trigger(UE.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},t=>{i.logger.log(`Failed to parse IMSC1: ${t}`),i.trigger(UE.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:t})})}},{key:"_parseVTTs",value:function(e){var t,i=e.frag,n=e.payload,a=this.initPTS,r=this.unparsedVttFrags,o=a.length-1;if(a[i.cc]||-1!==o){var s=this.hls;pL(null!=(t=i.initSegment)&&t.data?JT(i.initSegment.data,new Uint8Array(n)).buffer:n,this.initPTS[i.cc],this.vttCCs,i.cc,i.start,e=>{this._appendCues(e,i.level),s.trigger(UE.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:i})},t=>{var a="Missing initPTS for VTT MPEGTS"===t.message;a?r.push(e):this._fallbackToIMSC1(i,n),s.logger.log(`Failed to parse VTT cue: ${t}`),a&&o>i.cc||s.trigger(UE.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:t})})}else r.push(e)}},{key:"_fallbackToIMSC1",value:function(e,t){var i=this.tracks[e.level];i.textCodec||kL(t,this.initPTS[e.cc],()=>{i.textCodec=gL,this._parseIMSC1(e,t)},()=>{i.textCodec="wvtt"})}},{key:"_appendCues",value:function(e,t){var i=this.hls;if(this.config.renderTextTracksNatively){var n=this.textTracks[t];if(!n||"disabled"===n.mode)return;e.forEach(e=>pI(n,e))}else{var a=this.tracks[t];if(!a)return;var r=a.default?"default":"subtitles"+t;i.trigger(UE.CUES_PARSED,{type:"subtitles",cues:e,track:r})}}},{key:"onFragDecrypted",value:function(e,t){t.frag.type===qE&&this.onFragLoaded(UE.FRAG_LOADED,t)}},{key:"onSubtitleTracksCleared",value:function(){this.tracks=[],this.captionsTracks={}}},{key:"onFragParsingUserdata",value:function(e,t){if(this.enabled&&this.config.enableCEA708Captions){var i=t.frag,n=t.samples;if(i.type!==XE||"NONE"!==this.closedCaptionsForLevel(i))for(var a=0;a<n.length;a++){var r=n[a].bytes;if(r){this.cea608Parser1||this.initCea608Parsers();var o=this.extractCea608Data(r);this.cea608Parser1.addData(n[a].pts,o[0]),this.cea608Parser2.addData(n[a].pts,o[1])}}}}},{key:"onBufferFlushing",value:function(e,{startOffset:t,endOffset:i,endOffsetSubtitles:n,type:a}){var r=this.media;if(r&&!(r.currentTime<i)){if(!a||"video"===a){var o=this.captionsTracks;Object.keys(o).forEach(e=>yI(o[e],t,i))}if(this.config.renderTextTracksNatively&&0===t&&void 0!==n){var s=this.textTracks;Object.keys(s).forEach(e=>yI(s[e],t,n))}}}},{key:"extractCea608Data",value:function(e){for(var t=[[],[]],i=31&e[0],n=2,a=0;a<i;a++){var r=e[n++],o=127&e[n++],s=127&e[n++];if(0!==o||0!==s)if(!!(4&r)){var u=3&r;0!==u&&1!==u||(t[u].push(o),t[u].push(s))}}return t}}])}();function CL(e){return e.characteristics&&/transcribes-spoken-dialog/gi.test(e.characteristics)&&/describes-music-and-sound/gi.test(e.characteristics)?"captions":"subtitles"}function IL(e,t){return!!e&&e.kind===CL(t)&&iC(t,e)}function LL(e,t,i,n){return Math.min(t,n)-Math.max(e,i)}var _L=/\s/,RL={newCue(e,t,i,n){for(var a,r,o,s,u,l=[],d=self.VTTCue||self.TextTrackCue,h=0;h<n.rows.length;h++)if(o=!0,s=0,u="",!(a=n.rows[h]).isEmpty()){for(var c,m=0;m<a.chars.length;m++)_L.test(a.chars[m].uchar)&&o?s++:(u+=a.chars[m].uchar,o=!1);a.cueStartTime=t,t===i&&(i+=1e-4),s>=16?s--:s++;var f=hL(u.trim()),v=vL(t,i,f);null!=e&&null!=(c=e.cues)&&c.getCueById(v)||((r=new d(t,i,f)).id=v,r.line=h+1,r.align="left",r.position=10+Math.min(80,10*Math.floor(8*s/32)),l.push(r))}return e&&l.length&&(l.sort((e,t)=>"auto"===e.line||"auto"===t.line?0:e.line>8&&t.line>8?t.line-e.line:e.line-t.line),l.forEach(t=>pI(e,t))),l}};var FL=/(\d+)-(\d+)\/(\d+)/,OL=function(){return m(function e(t){u(this,e),this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=null,this.response=null,this.controller=void 0,this.context=null,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=t.fetchSetup||WL,this.controller=new self.AbortController,this.stats=new TT},[{key:"destroy",value:function(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null}},{key:"abortInternal",value:function(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())}},{key:"abort",value:function(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}},{key:"load",value:function(e,t,i){var n=this.stats;if(n.loading.start)throw new Error("Loader can only be used once.");n.loading.start=self.performance.now();var a=function(e,t){var i={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(eT({},e.headers))};e.rangeEnd&&i.headers.set("Range","bytes="+e.rangeStart+"-"+String(e.rangeEnd-1));return i}(e,this.controller.signal),r="arraybuffer"===e.responseType,o=r?"byteLength":"length",s=t.loadPolicy,u=s.maxTimeToFirstByteMs,l=s.maxLoadTimeMs;this.context=e,this.config=t,this.callbacks=i,this.request=this.fetchSetup(e,a),self.clearTimeout(this.requestTimeout),t.timeout=u&&$E(u)?u:l,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(n,e,this.response))},t.timeout),(Kx(this.request)?this.request.then(self.fetch):self.fetch(this.request)).then(i=>{var a;this.response=this.loader=i;var o=Math.max(self.performance.now(),n.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=l,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(n,e,this.response))},l-(o-n.loading.start)),!i.ok){var s=i.status,u=i.statusText;throw new $L(u||"fetch, bad network response",s,i)}n.loading.first=o,n.total=function(e){var t=e.get("Content-Range");if(t){var i=function(e){var t=FL.exec(e);if(t)return parseInt(t[2])-parseInt(t[1])+1}(t);if($E(i))return i}var n=e.get("Content-Length");if(n)return parseInt(n)}(i.headers)||n.total;var d=null==(a=this.callbacks)?void 0:a.onProgress;return d&&$E(t.highWaterMark)?this.loadProgressively(i,n,e,t.highWaterMark,d):r?i.arrayBuffer():"json"===e.responseType?i.json():i.text()}).then(i=>{var a,r,s=this.response;if(!s)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),n.loading.end=Math.max(self.performance.now(),n.loading.first);var u=i[o];u&&(n.loaded=n.total=u);var l={url:s.url,data:i,code:s.status},d=null==(a=this.callbacks)?void 0:a.onProgress;d&&!$E(t.highWaterMark)&&d(n,e,i,s),null==(r=this.callbacks)||r.onSuccess(l,n,e,s)}).catch(t=>{var i;if(self.clearTimeout(this.requestTimeout),!n.aborted){var a=t&&t.code||0,r=t?t.message:null;null==(i=this.callbacks)||i.onError({code:a,text:r},e,t?t.details:null,n)}})}},{key:"getCacheAge",value:function(){var e=null;if(this.response){var t=this.response.headers.get("age");e=t?parseFloat(t):null}return e}},{key:"getResponseHeader",value:function(e){return this.response?this.response.headers.get(e):null}},{key:"loadProgressively",value:function(e,t,i,n=0,a){var r=new yD,o=e.body.getReader(),s=()=>o.read().then(o=>{if(o.done)return r.dataLength&&a(t,i,r.flush().buffer,e),Promise.resolve(new ArrayBuffer(0));var u=o.value,l=u.length;return t.loaded+=l,l<n||r.dataLength?(r.push(u),r.dataLength>=n&&a(t,i,r.flush().buffer,e)):a(t,i,u.buffer,e),s()}).catch(()=>Promise.reject());return s()}}])}();function WL(e,t){return new self.Request(e.url,t)}var $L=function(){function e(t,i,n){var a;return u(this,e),(a=s(this,e,[t])).code=void 0,a.details=void 0,a.code=i,a.details=n,a}return y(e,D(Error)),m(e)}(),NL=/^age:\s*[\d.]+\s*$/im,jL=function(){return m(function e(t){u(this,e),this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=null,this.loader=null,this.stats=void 0,this.xhrSetup=t&&t.xhrSetup||null,this.stats=new TT,this.retryDelay=0},[{key:"destroy",value:function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null}},{key:"abortInternal",value:function(){var e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,4!==e.readyState&&(this.stats.aborted=!0,e.abort()))}},{key:"abort",value:function(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}},{key:"load",value:function(e,t,i){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=i,this.loadInternal()}},{key:"loadInternal",value:function(){var e=this.config,t=this.context;if(e&&t){var i=this.loader=new self.XMLHttpRequest,n=this.stats;n.loading.first=0,n.loaded=0,n.aborted=!1;var a=this.xhrSetup;a?Promise.resolve().then(()=>{if(this.loader===i&&!this.stats.aborted)return a(i,t.url)}).catch(e=>{if(this.loader===i&&!this.stats.aborted)return i.open("GET",t.url,!0),a(i,t.url)}).then(()=>{this.loader!==i||this.stats.aborted||this.openAndSendXhr(i,t,e)}).catch(e=>{var a;null==(a=this.callbacks)||a.onError({code:i.status,text:e.message},t,i,n)}):this.openAndSendXhr(i,t,e)}}},{key:"openAndSendXhr",value:function(e,t,i){e.readyState||e.open("GET",t.url,!0);var n=t.headers,a=i.loadPolicy,r=a.maxTimeToFirstByteMs,o=a.maxLoadTimeMs;if(n)for(var s in n)e.setRequestHeader(s,n[s]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),i.timeout=r&&$E(r)?r:o,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.timeout),e.send()}},{key:"readystatechange",value:function(){var e=this.context,t=this.loader,i=this.stats;if(e&&t){var n=t.readyState,a=this.config;if(!i.aborted&&n>=2&&(0===i.loading.first&&(i.loading.first=Math.max(self.performance.now(),i.loading.start),a.timeout!==a.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),a.timeout=a.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),a.loadPolicy.maxLoadTimeMs-(i.loading.first-i.loading.start)))),4===n)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;var r=t.status,o="text"===t.responseType?t.responseText:null;if(r>=200&&r<300){var s=null!=o?o:t.response;if(null!=s){var u,l;i.loading.end=Math.max(self.performance.now(),i.loading.first);var d="arraybuffer"===t.responseType?s.byteLength:s.length;i.loaded=i.total=d,i.bwEstimate=8e3*i.total/(i.loading.end-i.loading.first);var h=null==(u=this.callbacks)?void 0:u.onProgress;h&&h(i,e,s,t);var c={url:t.responseURL,data:s,code:r};return void(null==(l=this.callbacks)||l.onSuccess(c,i,e,t))}}var m,f=a.loadPolicy.errorRetry;if(aM(f,i.retry,!1,{url:e.url,data:void 0,code:r}))this.retry(f);else lT.error(`${r} while loading ${e.url}`),null==(m=this.callbacks)||m.onError({code:r,text:t.statusText},e,t,i)}}}},{key:"loadtimeout",value:function(){if(this.config){var e=this.config.loadPolicy.timeoutRetry;if(aM(e,this.stats.retry,!0))this.retry(e);else{var t;lT.warn(`timeout while loading ${null==(t=this.context)?void 0:t.url}`);var i=this.callbacks;i&&(this.abortInternal(),i.onTimeout(this.stats,this.context,this.loader))}}}},{key:"retry",value:function(e){var t=this.context,i=this.stats;this.retryDelay=iM(e,i.retry),i.retry++,lT.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${null==t?void 0:t.url}, retrying ${i.retry}/${e.maxNumRetry} in ${this.retryDelay}ms`),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)}},{key:"loadprogress",value:function(e){var t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)}},{key:"getCacheAge",value:function(){var e=null;if(this.loader&&NL.test(this.loader.getAllResponseHeaders())){var t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e}},{key:"getResponseHeader",value:function(e){return this.loader&&new RegExp(`^${e}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}}])}(),BL=iT(iT({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,maxDevicePixelRatio:Number.POSITIVE_INFINITY,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,startOnSegmentBoundary:!1,maxBufferSize:6e7,maxFragLookUpTolerance:.25,maxBufferHole:.1,detectStallWithCurrentTimeMs:1250,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,nudgeOnVideoHole:!0,liveSyncMode:"edge",liveSyncDurationCount:3,liveSyncOnStallIncrease:1,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,ignorePlaylistParsingErrors:!1,loader:jL,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:VP,bufferController:uC,capLevelController:hC,errorController:fM,fpsController:fI,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:vA,requireKeySystemAccessOnStart:!1,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableEmsgKLVMetadata:!1,enableID3MetadataCues:!0,enableInterstitialPlayback:!0,interstitialAppendInPlace:!0,interstitialLiveLookAhead:10,useMediaCapabilities:!0,preserveManualLevelOnError:!1,certLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null}},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}}},interstitialAssetListLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:3e4,timeoutRetry:{maxNumRetry:0,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:0,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},{cueHandler:RL,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:WI,subtitleTrackController:wI,timelineController:xL,audioStreamController:Qx,audioTrackController:nC,emeController:lI,cmcdController:rI,contentSteeringController:oI,interstitialsController:OI});function zL(e){return e&&"object"==typeof e?Array.isArray(e)?e.map(zL):Object.keys(e).reduce((t,i)=>(t[i]=zL(e[i]),t),{}):e}function UL(e,t){var i=e.loader;i!==OL&&i!==jL?(t.log("[config]: Custom loader detected, cannot enable progressive streaming"),e.progressive=!1):function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(e){}return!1}()&&(e.loader=OL,e.progressive=!0,e.enableSoftwareAES=!0,t.log("[config]: Progressive streaming enabled, using FetchLoader"))}var HL=function(){function e(t,i){var n;return u(this,e),(n=s(this,e,["gap-controller",t.logger])).hls=void 0,n.fragmentTracker=void 0,n.media=null,n.mediaSource=void 0,n.nudgeRetry=0,n.stallReported=!1,n.stalled=null,n.moved=!1,n.seeking=!1,n.buffered={},n.lastCurrentTime=0,n.ended=0,n.waiting=0,n.onMediaPlaying=()=>{n.ended=0,n.waiting=0},n.onMediaWaiting=()=>{var e;null!=(e=n.media)&&e.seeking||(n.waiting=self.performance.now(),n.tick())},n.onMediaEnded=()=>{var e;n.hls&&(n.ended=(null==(e=n.media)?void 0:e.currentTime)||1,n.hls.trigger(UE.MEDIA_ENDED,{stalled:!1}))},n.hls=t,n.fragmentTracker=i,n.registerListeners(),n}return y(e,FM),m(e,[{key:"registerListeners",value:function(){var e=this.hls;e&&(e.on(UE.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(UE.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(UE.BUFFER_APPENDED,this.onBufferAppended,this))}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(UE.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(UE.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(UE.BUFFER_APPENDED,this.onBufferAppended,this))}},{key:"destroy",value:function(){M(e,"destroy",this)([]),this.unregisterListeners(),this.media=this.hls=this.fragmentTracker=null,this.mediaSource=void 0}},{key:"onMediaAttached",value:function(e,t){this.setInterval(100),this.mediaSource=t.mediaSource;var i=this.media=t.media;tD(i,"playing",this.onMediaPlaying),tD(i,"waiting",this.onMediaWaiting),tD(i,"ended",this.onMediaEnded)}},{key:"onMediaDetaching",value:function(e,t){this.clearInterval();var i=this.media;i&&(iD(i,"playing",this.onMediaPlaying),iD(i,"waiting",this.onMediaWaiting),iD(i,"ended",this.onMediaEnded),this.media=null),this.mediaSource=void 0}},{key:"onBufferAppended",value:function(e,t){this.buffered=t.timeRanges}},{key:"hasBuffered",get:function(){return Object.keys(this.buffered).length>0}},{key:"tick",value:function(){var e;if(null!=(e=this.media)&&e.readyState&&this.hasBuffered){var t=this.media.currentTime;this.poll(t,this.lastCurrentTime),this.lastCurrentTime=t}}},{key:"poll",value:function(e,t){var i,n,a=null==(i=this.hls)?void 0:i.config;if(a){var r=this.media;if(r){var o=r.seeking,s=this.seeking&&!o,u=!this.seeking&&o,l=r.paused&&!o||r.ended||0===r.playbackRate;if(this.seeking=o,e!==t)return t&&(this.ended=0),this.moved=!0,o||(this.nudgeRetry=0,a.nudgeOnVideoHole&&!l&&e>t&&this.nudgeOnVideoHole(e,t)),void(0===this.waiting&&this.stallResolved(e));if(u||s)s&&this.stallResolved(e);else{if(l)return this.nudgeRetry=0,this.stallResolved(e),void(!this.ended&&r.ended&&this.hls&&(this.ended=e||1,this.hls.trigger(UE.MEDIA_ENDED,{stalled:!1})));if($M.getBuffered(r).length){var d=$M.bufferInfo(r,e,0),h=d.nextStart||0,c=this.fragmentTracker;if(o&&c&&this.hls){var m=GL(this.hls.inFlightFragments,e),f=d.len>2,v=!h||m||h-e>2&&!c.getPartialFragment(e);if(f||v)return;this.moved=!1}var p=null==(n=this.hls)?void 0:n.latestLevelDetails;if(!this.moved&&null!==this.stalled&&c){if(!(d.len>0)&&!h)return;var g=Math.max(h,d.start||0)-e,y=!(null==p||!p.live)?2*p.targetduration:2,b=KL(e,c);if(g>0&&(g<=y||b))return void(r.paused||this._trySkipBufferHole(b))}var w=a.detectStallWithCurrentTimeMs,k=self.performance.now(),S=this.waiting,E=this.stalled;if(null===E){if(!(S>0&&k-S<w))return void(this.stalled=k);E=this.stalled=S}var T=k-E;if(!o&&(T>=w||S)&&this.hls){var P;if("ended"===(null==(P=this.mediaSource)?void 0:P.readyState)&&(null==p||!p.live)&&Math.abs(e-((null==p?void 0:p.edge)||0))<1){if(this.ended)return;return this.ended=e||1,void this.hls.trigger(UE.MEDIA_ENDED,{stalled:!0})}if(this._reportStall(d),!this.media||!this.hls)return}var M=$M.bufferInfo(r,e,a.maxBufferHole);this._tryFixBufferStall(M,T,e)}else this.nudgeRetry=0}}}}},{key:"stallResolved",value:function(e){var t=this.stalled;if(t&&this.hls&&(this.stalled=null,this.stallReported)){var i=self.performance.now()-t;this.log(`playback not stuck anymore @${e}, after ${Math.round(i)}ms`),this.stallReported=!1,this.waiting=0,this.hls.trigger(UE.STALL_RESOLVED,{})}}},{key:"nudgeOnVideoHole",value:function(e,t){var i,n=this.buffered.video;if(this.hls&&this.media&&this.fragmentTracker&&null!=(i=this.buffered.audio)&&i.length&&n&&n.length>1&&e>n.end(0)){var a=$M.bufferedInfo($M.timeRangesToArray(this.buffered.audio),e,0);if(a.len>1&&t>=a.start){var r=$M.timeRangesToArray(n),o=$M.bufferedInfo(r,t,0).bufferedIndex;if(o>-1&&o<r.length-1){var s=$M.bufferedInfo(r,e,0).bufferedIndex,u=r[o].end,l=r[o+1].start;if((-1===s||s>o)&&l-u<1&&e-u<2){var d=new Error(`nudging playhead to flush pipeline after video hole. currentTime: ${e} hole: ${u} -> ${l} buffered index: ${s}`);this.warn(d.message),this.media.currentTime+=1e-6;var h=KL(e,this.fragmentTracker);h&&"fragment"in h?h=h.fragment:h||(h=void 0);var c=$M.bufferInfo(this.media,e,0);this.hls.trigger(UE.ERROR,{type:BE.MEDIA_ERROR,details:zE.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:d,reason:d.message,frag:h,buffer:c.len,bufferInfo:c})}}}}}},{key:"_tryFixBufferStall",value:function(e,t,i){var n,a,r=this.fragmentTracker,o=this.media,s=null==(n=this.hls)?void 0:n.config;if(o&&r&&s){var u=null==(a=this.hls)?void 0:a.latestLevelDetails,l=KL(i,r);if(l||null!=u&&u.live&&i<u.fragmentStart)if(this._trySkipBufferHole(l)||!this.media)return;var d=e.buffered,h=this.adjacentTraversal(e,i);(d&&d.length>1&&e.len>s.maxBufferHole||e.nextStart&&(e.nextStart-i<s.maxBufferHole||h))&&(t>1e3*s.highBufferWatchdogPeriod||this.waiting)&&(this.warn("Trying to nudge playhead over buffer-hole"),this._tryNudgeBuffer(e))}}},{key:"adjacentTraversal",value:function(e,t){var i=this.fragmentTracker,n=e.nextStart;if(i&&n){var a=i.getFragAtPos(t,XE),r=i.getFragAtPos(n,XE);if(a&&r)return r.sn-a.sn<2}return!1}},{key:"_reportStall",value:function(e){var t=this.hls,i=this.media,n=this.stallReported,a=this.stalled;if(!n&&null!==a&&i&&t){this.stallReported=!0;var r=new Error(`Playback stalling at @${i.currentTime} due to low buffer (${WP(e)})`);this.warn(r.message),t.trigger(UE.ERROR,{type:BE.MEDIA_ERROR,details:zE.BUFFER_STALLED_ERROR,fatal:!1,error:r,buffer:e.len,bufferInfo:e,stalled:{start:a}})}}},{key:"_trySkipBufferHole",value:function(e){var t,i=this.fragmentTracker,n=this.media,a=null==(t=this.hls)?void 0:t.config;if(!n||!i||!a)return 0;var r=n.currentTime,o=$M.bufferInfo(n,r,0),s=r<o.start?o.start:o.nextStart;if(s&&this.hls){var u=o.len<=a.maxBufferHole,l=o.len>0&&o.len<1&&n.readyState<3,d=s-r;if(d>0&&(u||l)){if(d>a.maxBufferHole){var h=!1;if(0===r){var c=i.getAppendedFrag(0,XE);c&&s<c.end&&(h=!0)}if(!h&&e){var m;if(null==(m=this.hls.loadLevelObj)||!m.details)return 0;if(GL(this.hls.inFlightFragments,s))return 0;for(var f=!1,v=e.end;v<s;){var p=KL(v,i);if(!p){f=!0;break}v+=p.duration}if(f)return 0}}var g=Math.max(s+.05,r+.1);if(this.warn(`skipping hole, adjusting currentTime from ${r} to ${g}`),this.moved=!0,n.currentTime=g,null==e||!e.gap){var y=new Error(`fragment loaded with buffer holes, seeking from ${r} to ${g}`),b={type:BE.MEDIA_ERROR,details:zE.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:y,reason:y.message,buffer:o.len,bufferInfo:o};e&&("fragment"in e?b.part=e:b.frag=e),this.hls.trigger(UE.ERROR,b)}return g}}return 0}},{key:"_tryNudgeBuffer",value:function(e){var t=this.hls,i=this.media,n=this.nudgeRetry,a=null==t?void 0:t.config;if(!i||!a)return 0;var r=i.currentTime;if(this.nudgeRetry++,n<a.nudgeMaxRetry){var o=r+(n+1)*a.nudgeOffset,s=new Error(`Nudging 'currentTime' from ${r} to ${o}`);this.warn(s.message),i.currentTime=o,t.trigger(UE.ERROR,{type:BE.MEDIA_ERROR,details:zE.BUFFER_NUDGE_ON_STALL,error:s,fatal:!1,buffer:e.len,bufferInfo:e})}else{var u=new Error(`Playhead still not moving while enough data buffered @${r} after ${a.nudgeMaxRetry} nudges`);this.error(u.message),t.trigger(UE.ERROR,{type:BE.MEDIA_ERROR,details:zE.BUFFER_STALLED_ERROR,error:u,fatal:!0,buffer:e.len,bufferInfo:e})}}}])}();function GL(e,t){var i=VL(e.main);if(i&&i.start<=t)return i;var n=VL(e.audio);return n&&n.start<=t?n:null}function VL(e){if(!e)return null;switch(e.state){case rD:case aD:case cD:case mD:return null}return e.frag}function KL(e,t){return t.getAppendedFrag(e,XE)||t.getPartialFragment(e)}function XL(){if("undefined"!=typeof self)return self.VTTCue||self.TextTrackCue}function YL(e,t,i,n,a){var r=new e(t,i,"");try{r.value=n,a&&(r.type=a)}catch(o){r=new e(t,i,WP(a?iT({type:a},n):n))}return r}var qL=(()=>{var e=XL();try{e&&new e(0,Number.POSITIVE_INFINITY,"")}catch(e){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})(),JL=function(){return m(function e(t){u(this,e),this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.removeCues=!0,this.assetCue=void 0,this.onEventCueEnter=()=>{this.hls&&this.hls.trigger(UE.EVENT_CUE_ENTER,{})},this.hls=t,this._registerListeners()},[{key:"destroy",value:function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=this.onEventCueEnter=null}},{key:"_registerListeners",value:function(){var e=this.hls;e&&(e.on(UE.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(UE.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(UE.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(UE.MANIFEST_LOADING,this.onManifestLoading,this),e.on(UE.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(UE.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(UE.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(UE.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}},{key:"_unregisterListeners",value:function(){var e=this.hls;e&&(e.off(UE.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(UE.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(UE.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(UE.MANIFEST_LOADING,this.onManifestLoading,this),e.off(UE.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(UE.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(UE.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(UE.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}},{key:"onMediaAttaching",value:function(e,t){var i;this.media=t.media,!1===(null==(i=t.overrides)?void 0:i.cueRemoval)&&(this.removeCues=!1)}},{key:"onMediaAttached",value:function(){var e,t=null==(e=this.hls)?void 0:e.latestLevelDetails;t&&this.updateDateRangeCues(t)}},{key:"onMediaDetaching",value:function(e,t){this.media=null,!!t.transferMedia||(this.id3Track&&(this.removeCues&&gI(this.id3Track,this.onEventCueEnter),this.id3Track=null),this.dateRangeCuesAppended={})}},{key:"onManifestLoading",value:function(){this.dateRangeCuesAppended={}}},{key:"createTrack",value:function(e){var t=this.getID3Track(e.textTracks);return t.mode="hidden",t}},{key:"getID3Track",value:function(e){if(this.media){for(var t=0;t<e.length;t++){var i=e[t];if("metadata"===i.kind&&"id3"===i.label)return vI(i,this.media),i}return this.media.addTextTrack("metadata","id3")}}},{key:"onFragParsingMetadata",value:function(e,t){if(this.media&&this.hls){var i=this.hls.config,n=i.enableEmsgMetadataCues,a=i.enableID3MetadataCues;if(n||a){var r=t.samples;this.id3Track||(this.id3Track=this.createTrack(this.media));var o=XL();if(o)for(var s=0;s<r.length;s++){var u=r[s].type;if((u!==VD.emsg||n)&&a){var l=zD(r[s].data),d=r[s].pts,h=d+r[s].duration;h>qL&&(h=qL),h-d<=0&&(h=d+.25);for(var c=0;c<l.length;c++){var m=l[c];if(!UD(m)){this.updateId3CueEnds(d,u);var f=YL(o,d,h,m,u);f&&this.id3Track.addCue(f)}}}}}}}},{key:"updateId3CueEnds",value:function(e,t){var i,n=null==(i=this.id3Track)?void 0:i.cues;if(n)for(var a=n.length;a--;){var r=n[a];r.type===t&&r.startTime<e&&r.endTime===qL&&(r.endTime=e)}}},{key:"onBufferFlushing",value:function(e,{startOffset:t,endOffset:i,type:n}){var a=this.id3Track,r=this.hls;if(r){var o=r.config,s=o.enableEmsgMetadataCues,u=o.enableID3MetadataCues;if(a&&(s||u))yI(a,t,i,"audio"===n?e=>e.type===VD.audioId3&&u:"video"===n?e=>e.type===VD.emsg&&s:e=>e.type===VD.audioId3&&u||e.type===VD.emsg&&s)}}},{key:"onLevelUpdated",value:function(e,{details:t}){this.updateDateRangeCues(t,!0)}},{key:"onLevelPtsUpdated",value:function(e,t){Math.abs(t.drift)>.01&&this.updateDateRangeCues(t.details)}},{key:"updateDateRangeCues",value:function(e,t){var i=this;if(this.hls&&this.media){var n=this.hls.config,a=n.assetPlayerId,r=n.timelineOffset,o=n.enableDateRangeMetadataCues,s=n.interstitialsController;if(o){var u=XL();if(a&&r&&!s){var l=e.fragmentStart,d=e.fragmentEnd,h=this.assetCue;h?(h.startTime=l,h.endTime=d):u&&(h=this.assetCue=YL(u,l,d,{assetPlayerId:this.hls.config.assetPlayerId},"hlsjs.interstitial.asset"))&&(h.id=a,this.id3Track||(this.id3Track=this.createTrack(this.media)),this.id3Track.addCue(h),h.addEventListener("enter",this.onEventCueEnter))}if(e.hasProgramDateTime){var c,m=this.id3Track,f=e.dateRanges,v=Object.keys(f),p=this.dateRangeCuesAppended;if(m&&t)if(null!=(c=m.cues)&&c.length)for(var g,y=Object.keys(p).filter(e=>!v.includes(e)),b=function(){var e=y[w],t=null==(g=p[e])?void 0:g.cues;delete p[e],t&&Object.keys(t).forEach(e=>{var n=t[e];if(n){n.removeEventListener("enter",i.onEventCueEnter);try{m.removeCue(n)}catch(e){}}})},w=y.length;w--;)b();else p=this.dateRangeCuesAppended={};var k=e.fragments[e.fragments.length-1];if(0!==v.length&&$E(null==k?void 0:k.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var S=function(){var e=v[E],t=f[e],n=t.startTime,a=p[e],r=(null==a?void 0:a.cues)||{},o=(null==a?void 0:a.durationKnown)||!1,l=qL,d=t.duration;if(t.endDate&&null!==d)l=n+d,o=!0;else if(t.endOnNext&&!o){var h=v.reduce((e,i)=>{if(i!==t.id){var n=f[i];if(n.class===t.class&&n.startDate>t.startDate&&(!e||t.startDate<e.startDate))return n}return e},null);h&&(l=h.startTime,o=!0)}for(var c=Object.keys(t.attr),m=0;m<c.length;m++){var g=c[m];if(KM(g)){var y=r[g];if(y)!o||null!=a&&a.durationKnown?Math.abs(y.startTime-n)>.01&&(y.startTime=n,y.endTime=l):y.endTime=l;else if(u){var b=t.attr[g];XM(g)&&(b=fT(b));var w=YL(u,n,l,{key:g,data:b},VD.dateRange);w&&(w.id=e,i.id3Track.addCue(w),r[g]=w,s&&("X-ASSET-LIST"!==g&&"X-ASSET-URL"!==g||w.addEventListener("enter",i.onEventCueEnter)))}}}p[e]={cues:r,dateRange:t,durationKnown:o}},E=0;E<v.length;E++)S()}}}}}}])}(),QL=function(){return m(function e(t){u(this,e),this.hls=void 0,this.config=void 0,this.media=null,this.currentTime=0,this.stallCount=0,this._latency=null,this._targetLatencyUpdated=!1,this.onTimeupdate=()=>{var e=this.media,t=this.levelDetails;if(e&&t){this.currentTime=e.currentTime;var i=this.computeLatency();if(null!==i){this._latency=i;var n=this.config,a=n.lowLatencyMode,r=n.maxLiveSyncPlaybackRate;if(a&&1!==r&&t.live){var o=this.targetLatency;if(null!==o){var s=i-o;if(s<Math.min(this.maxLatency,o+t.targetduration)&&s>.05&&this.forwardBufferLength>1){var u=Math.min(2,Math.max(1,r)),l=Math.round(2/(1+Math.exp(-.75*s-this.edgeStalled))*20)/20,d=Math.min(u,Math.max(1,l));this.changeMediaPlaybackRate(e,d)}else 1!==e.playbackRate&&0!==e.playbackRate&&this.changeMediaPlaybackRate(e,1)}}}}},this.hls=t,this.config=t.config,this.registerListeners()},[{key:"levelDetails",get:function(){var e;return(null==(e=this.hls)?void 0:e.latestLevelDetails)||null}},{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var e=this.config;if(void 0!==e.liveMaxLatencyDuration)return e.liveMaxLatencyDuration;var t=this.levelDetails;return t?e.liveMaxLatencyDurationCount*t.targetduration:0}},{key:"targetLatency",get:function(){var e=this.levelDetails;if(null===e||null===this.hls)return null;var t=e.holdBack,i=e.partHoldBack,n=e.targetduration,a=this.config,r=a.liveSyncDuration,o=a.liveSyncDurationCount,s=a.lowLatencyMode,u=this.hls.userConfig,l=s&&i||t;(this._targetLatencyUpdated||u.liveSyncDuration||u.liveSyncDurationCount||0===l)&&(l=void 0!==r?r:o*n);var d=n;return l+Math.min(this.stallCount*this.config.liveSyncOnStallIncrease,d)},set:function(e){this.stallCount=0,this.config.liveSyncDuration=e,this._targetLatencyUpdated=!0}},{key:"liveSyncPosition",get:function(){var e=this.estimateLiveEdge(),t=this.targetLatency;if(null===e||null===t)return null;var i=this.levelDetails;if(null===i)return null;var n=i.edge,a=e-t-this.edgeStalled,r=n-i.totalduration,o=n-(this.config.lowLatencyMode&&i.partTarget||i.targetduration);return Math.min(Math.max(r,a),o)}},{key:"drift",get:function(){var e=this.levelDetails;return null===e?1:e.drift}},{key:"edgeStalled",get:function(){var e=this.levelDetails;if(null===e)return 0;var t=3*(this.config.lowLatencyMode&&e.partTarget||e.targetduration);return Math.max(e.age-t,0)}},{key:"forwardBufferLength",get:function(){var e=this.media,t=this.levelDetails;if(!e||!t)return 0;var i=e.buffered.length;return(i?e.buffered.end(i-1):t.edge)-this.currentTime}},{key:"destroy",value:function(){this.unregisterListeners(),this.onMediaDetaching(),this.hls=null}},{key:"registerListeners",value:function(){var e=this.hls;e&&(e.on(UE.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(UE.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(UE.MANIFEST_LOADING,this.onManifestLoading,this),e.on(UE.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(UE.ERROR,this.onError,this))}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(UE.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(UE.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(UE.MANIFEST_LOADING,this.onManifestLoading,this),e.off(UE.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(UE.ERROR,this.onError,this))}},{key:"onMediaAttached",value:function(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.onTimeupdate)}},{key:"onMediaDetaching",value:function(){this.media&&(this.media.removeEventListener("timeupdate",this.onTimeupdate),this.media=null)}},{key:"onManifestLoading",value:function(){this._latency=null,this.stallCount=0}},{key:"onLevelUpdated",value:function(e,{details:t}){t.advanced&&this.onTimeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.onTimeupdate)}},{key:"onError",value:function(e,t){var i;t.details===zE.BUFFER_STALLED_ERROR&&(this.stallCount++,this.hls&&null!=(i=this.levelDetails)&&i.live&&this.hls.logger.warn("[latency-controller]: Stall detected, adjusting target latency"))}},{key:"changeMediaPlaybackRate",value:function(e,t){var i,n;e.playbackRate!==t&&(null==(i=this.hls)||i.logger.debug(`[latency-controller]: latency=${this.latency.toFixed(3)}, targetLatency=${null==(n=this.targetLatency)?void 0:n.toFixed(3)}, forwardBufferLength=${this.forwardBufferLength.toFixed(3)}: adjusting playback rate from ${e.playbackRate} to ${t}`),e.playbackRate=t)}},{key:"estimateLiveEdge",value:function(){var e=this.levelDetails;return null===e?null:e.edge+e.age}},{key:"computeLatency",value:function(){var e=this.estimateLiveEdge();return null===e?null:e-this.currentTime}}])}(),ZL=function(){function e(t,i){var n;return u(this,e),(n=s(this,e,[t,"level-controller"]))._levels=[],n._firstLevel=-1,n._maxAutoLevel=-1,n._startLevel=void 0,n.currentLevel=null,n.currentLevelIndex=-1,n.manualLevelIndex=-1,n.steering=void 0,n.onParsedComplete=void 0,n.steering=i,n._registerListeners(),n}return y(e,Zx),m(e,[{key:"_registerListeners",value:function(){var e=this.hls;e.on(UE.MANIFEST_LOADING,this.onManifestLoading,this),e.on(UE.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(UE.LEVEL_LOADED,this.onLevelLoaded,this),e.on(UE.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(UE.FRAG_BUFFERED,this.onFragBuffered,this),e.on(UE.ERROR,this.onError,this)}},{key:"_unregisterListeners",value:function(){var e=this.hls;e.off(UE.MANIFEST_LOADING,this.onManifestLoading,this),e.off(UE.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(UE.LEVEL_LOADED,this.onLevelLoaded,this),e.off(UE.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(UE.FRAG_BUFFERED,this.onFragBuffered,this),e.off(UE.ERROR,this.onError,this)}},{key:"destroy",value:function(){this._unregisterListeners(),this.steering=null,this.resetLevels(),M(e,"destroy",this)([])}},{key:"stopLoad",value:function(){this._levels.forEach(e=>{e.loadError=0,e.fragmentError=0}),M(e,"stopLoad",this)([])}},{key:"resetLevels",value:function(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1}},{key:"onManifestLoading",value:function(e,t){this.resetLevels()}},{key:"onManifestLoaded",value:function(e,t){var i=this.hls.config.preferManagedMediaSource,n=[],a={},r={},o=!1,s=!1,u=!1;t.levels.forEach(e=>{var t=e.attrs,l=e.audioCodec,d=e.videoCodec;l&&(e.audioCodec=l=vP(l,i)||void 0),d&&(d=e.videoCodec=function(e){for(var t=e.split(","),i=0;i<t.length;i++){var n=t[i].split(".");n.length>2&&"avc1"===n[0]&&(t[i]=`avc1.${parseInt(n[1]).toString(16)}${("000"+parseInt(n[2]).toString(16)).slice(-4)}`)}return t.join(",")}(d));var h=e.width,c=e.height,m=e.unknownCodecs,f=(null==m?void 0:m.length)||0;if(o||(o=!(!h||!c)),s||(s=!!d),u||(u=!!l),f||l&&!this.isAudioSupported(l)||d&&!this.isVideoSupported(d))this.log(`Some or all CODECS not supported "${t.CODECS}"`);else{var v=t.CODECS,p=t["FRAME-RATE"],g=t["HDCP-LEVEL"],y=t["PATHWAY-ID"],b=t.RESOLUTION,w=t["VIDEO-RANGE"],k=`${`${y||"."}-`}${e.bitrate}-${b}-${p}-${v}-${w}-${g}`;if(a[k])if(a[k].uri===e.url||e.attrs["PATHWAY-ID"])a[k].addGroupId("audio",t.AUDIO),a[k].addGroupId("text",t.SUBTITLES);else{var S=r[k]+=1;e.attrs["PATHWAY-ID"]=new Array(S+1).join(".");var E=this.createLevel(e);a[k]=E,n.push(E)}else{var T=this.createLevel(e);a[k]=T,r[k]=1,n.push(T)}}}),this.filterAndSortMediaOptions(n,t,o,s,u)}},{key:"createLevel",value:function(e){var t=new RP(e),i=e.supplemental;if(null!=i&&i.videoCodec&&!this.isVideoSupported(i.videoCodec)){var n=new Error(`SUPPLEMENTAL-CODECS not supported "${i.videoCodec}"`);this.log(n.message),t.supportedResult=EP(n,[])}return t}},{key:"isAudioSupported",value:function(e){return uP(e,"audio",this.hls.config.preferManagedMediaSource)}},{key:"isVideoSupported",value:function(e){return uP(e,"video",this.hls.config.preferManagedMediaSource)}},{key:"filterAndSortMediaOptions",value:function(e,t,i,n,a){var r,o=[],s=[],u=e,l=(null==(r=t.stats)?void 0:r.parsing)||{};if((i||n)&&a&&(u=u.filter(({videoCodec:e,videoRange:t,width:i,height:n})=>{return(!!e||!(!i||!n))&&(!!(a=t)&&DP.indexOf(a)>-1);var a})),0===u.length)return Promise.resolve().then(()=>{if(this.hls){var e="no level with compatible codecs found in manifest",i=e;t.levels.length&&(i=`one or more CODECS in variant not supported: ${WP(t.levels.map(e=>e.attrs.CODECS).filter((e,t,i)=>i.indexOf(e)===t))}`,this.warn(i),e+=` (${i})`);var n=new Error(e);this.hls.trigger(UE.ERROR,{type:BE.MEDIA_ERROR,details:zE.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:n,reason:i})}}),void(l.end=performance.now());t.audioTracks&&e_(o=t.audioTracks.filter(e=>!e.audioCodec||this.isAudioSupported(e.audioCodec))),t.subtitles&&e_(s=t.subtitles);var d=u.slice(0);u.sort((e,t)=>{if(e.attrs["HDCP-LEVEL"]!==t.attrs["HDCP-LEVEL"])return(e.attrs["HDCP-LEVEL"]||"")>(t.attrs["HDCP-LEVEL"]||"")?1:-1;if(i&&e.height!==t.height)return e.height-t.height;if(e.frameRate!==t.frameRate)return e.frameRate-t.frameRate;if(e.videoRange!==t.videoRange)return DP.indexOf(e.videoRange)-DP.indexOf(t.videoRange);if(e.videoCodec!==t.videoCodec){var n=hP(e.videoCodec),a=hP(t.videoCodec);if(n!==a)return a-n}if(e.uri===t.uri&&e.codecSet!==t.codecSet){var r=cP(e.codecSet),o=cP(t.codecSet);if(r!==o)return o-r}return e.averageBitrate!==t.averageBitrate?e.averageBitrate-t.averageBitrate:0});var h=d[0];if(this.steering&&(u=this.steering.filterParsedLevels(u)).length!==d.length)for(var c=0;c<d.length;c++)if(d[c].pathwayId===u[0].pathwayId){h=d[c];break}this._levels=u;for(var m=0;m<u.length;m++)if(u[m]===h){var f;this._firstLevel=m;var v=h.bitrate,p=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${u.length} level(s) found, first bitrate: ${v}`),void 0===(null==(f=this.hls.userConfig)?void 0:f.abrEwmaDefaultEstimate)){var g=Math.min(v,this.hls.config.abrEwmaDefaultEstimateMax);g>p&&p===this.hls.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=g)}break}var y=a&&!n,b=this.hls.config,w=!(!b.audioStreamController||!b.audioTrackController),k={levels:u,audioTracks:o,subtitleTracks:s,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:a,video:n,altAudio:w&&!y&&o.some(e=>!!e.url)};l.end=performance.now(),this.hls.trigger(UE.MANIFEST_PARSED,k)}},{key:"levels",get:function(){return 0===this._levels.length?null:this._levels}},{key:"loadLevelObj",get:function(){return this.currentLevel}},{key:"level",get:function(){return this.currentLevelIndex},set:function(e){var t=this._levels;if(0!==t.length){if(e<0||e>=t.length){var i=new Error("invalid level idx"),n=e<0;if(this.hls.trigger(UE.ERROR,{type:BE.OTHER_ERROR,details:zE.LEVEL_SWITCH_ERROR,level:e,fatal:n,error:i,reason:i.message}),n)return;e=Math.min(e,t.length-1)}var a=this.currentLevelIndex,r=this.currentLevel,o=r?r.attrs["PATHWAY-ID"]:void 0,s=t[e],u=s.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=s,a!==e||!r||o!==u){this.log(`Switching to level ${e} (${s.height?s.height+"p ":""}${s.videoRange?s.videoRange+" ":""}${s.codecSet?s.codecSet+" ":""}@${s.bitrate})${u?" with Pathway "+u:""} from level ${a}${o?" with Pathway "+o:""}`);var l={level:e,attrs:s.attrs,details:s.details,bitrate:s.bitrate,averageBitrate:s.averageBitrate,maxBitrate:s.maxBitrate,realBitrate:s.realBitrate,width:s.width,height:s.height,codecSet:s.codecSet,audioCodec:s.audioCodec,videoCodec:s.videoCodec,audioGroups:s.audioGroups,subtitleGroups:s.subtitleGroups,loaded:s.loaded,loadError:s.loadError,fragmentError:s.fragmentError,name:s.name,id:s.id,uri:s.uri,url:s.url,urlId:0,audioGroupIds:s.audioGroupIds,textGroupIds:s.textGroupIds};this.hls.trigger(UE.LEVEL_SWITCHING,l);var d=s.details;if(!d||d.live){var h=this.switchParams(s.uri,null==r?void 0:r.details,d);this.loadPlaylist(h)}}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(e){this.manualLevelIndex=e,void 0===this._startLevel&&(this._startLevel=e),-1!==e&&(this.level=e)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(e){this._firstLevel=e}},{key:"startLevel",get:function(){if(void 0===this._startLevel){var e=this.hls.config.startLevel;return void 0!==e?e:this.hls.firstAutoLevel}return this._startLevel},set:function(e){this._startLevel=e}},{key:"pathways",get:function(){return this.steering?this.steering.pathways():[]}},{key:"pathwayPriority",get:function(){return this.steering?this.steering.pathwayPriority:null},set:function(e){if(this.steering){var t=this.steering.pathways(),i=e.filter(e=>-1!==t.indexOf(e));if(e.length<1)return void this.warn(`pathwayPriority ${e} should contain at least one pathway from list: ${t}`);this.steering.pathwayPriority=i}}},{key:"onError",value:function(e,t){!t.fatal&&t.context&&t.context.type===GE&&t.context.level===this.level&&this.checkRetry(t)}},{key:"onFragBuffered",value:function(e,{frag:t}){if(void 0!==t&&t.type===XE){var i=t.elementaryStreams;if(!Object.keys(i).some(e=>!!i[e]))return;var n=this._levels[t.level];null!=n&&n.loadError&&(this.log(`Resetting level error count of ${n.loadError} on frag buffered`),n.loadError=0)}}},{key:"onLevelLoaded",value:function(e,t){var i,n,a=t.level,r=t.details,o=t.levelInfo;if(!o)return this.warn(`Invalid level index ${a}`),void(null!=(n=t.deliveryDirectives)&&n.skip&&(r.deltaUpdateFailed=!0));if(o===this.currentLevel||t.withoutMultiVariant){0===o.fragmentError&&(o.loadError=0);var s=o.details;s===t.details&&s.advanced&&(s=void 0),this.playlistLoaded(a,t,s)}else null!=(i=t.deliveryDirectives)&&i.skip&&(r.deltaUpdateFailed=!0)}},{key:"loadPlaylist",value:function(t){M(e,"loadPlaylist",this)([]),this.shouldLoadPlaylist(this.currentLevel)&&this.scheduleLoading(this.currentLevel,t)}},{key:"loadingPlaylist",value:function(t,i){M(e,"loadingPlaylist",this)([t,i]);var n=this.getUrlWithDirectives(t.uri,i),a=this.currentLevelIndex,r=t.attrs["PATHWAY-ID"],o=t.details,s=null==o?void 0:o.age;this.log(`Loading level index ${a}${void 0!==(null==i?void 0:i.msn)?" at sn "+i.msn+" part "+i.part:""}${r?" Pathway "+r:""}${s&&o.live?" age "+s.toFixed(1)+(o.type&&" "+o.type||""):""} ${n}`),this.hls.trigger(UE.LEVEL_LOADING,{url:n,level:a,levelInfo:t,pathwayId:t.attrs["PATHWAY-ID"],id:0,deliveryDirectives:i||null})}},{key:"nextLoadLevel",get:function(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(e){this.level=e,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=e)}},{key:"removeLevel",value:function(e){var t;if(1!==this._levels.length){var i=this._levels.filter((t,i)=>i!==e||(this.steering&&this.steering.removeLevel(t),t===this.currentLevel&&(this.currentLevel=null,this.currentLevelIndex=-1,t.details&&t.details.fragments.forEach(e=>e.level=-1)),!1));KA(i),this._levels=i,this.currentLevelIndex>-1&&null!=(t=this.currentLevel)&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.manualLevelIndex>-1&&(this.manualLevelIndex=this.currentLevelIndex);var n=i.length-1;this._firstLevel=Math.min(this._firstLevel,n),this._startLevel&&(this._startLevel=Math.min(this._startLevel,n)),this.hls.trigger(UE.LEVELS_UPDATED,{levels:i})}}},{key:"onLevelsUpdated",value:function(e,{levels:t}){this._levels=t}},{key:"checkMaxAutoUpdated",value:function(){var e=this.hls,t=e.autoLevelCapping,i=e.maxAutoLevel,n=e.maxHdcpLevel;this._maxAutoLevel!==i&&(this._maxAutoLevel=i,this.hls.trigger(UE.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:t,levels:this.levels,maxAutoLevel:i,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:n}))}}])}();function e_(e){var t={};e.forEach(e=>{var i=e.groupId||"";e.id=t[i]=t[i]||0,t[i]++})}function t_(){return self.SourceBuffer||self.WebKitSourceBuffer}function i_(){if(!dT())return!1;var e=t_();return!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove}var n_=function(){function e(t,i,n){var a;return u(this,e),(a=s(this,e,[t,i,n,"stream-controller",XE])).audioCodecSwap=!1,a.level=-1,a._forceStartLoad=!1,a._hasEnoughToStart=!1,a.altAudio=0,a.audioOnly=!1,a.fragPlaying=null,a.fragLastKbps=0,a.couldBacktrack=!1,a.backtrackFragment=null,a.audioCodecSwitch=!1,a.videoBuffer=null,a.onMediaPlaying=()=>{a.tick()},a.onMediaSeeked=()=>{var e=a.media,t=e?e.currentTime:null;if(null!==t&&$E(t)&&(a.log(`Media seeked to ${t.toFixed(3)}`),a.getBufferedFrag(t))){var i=a.getFwdBufferInfoAtPos(e,t,XE,0);null!==i&&0!==i.len?a.tick():a.warn(`Main forward buffer length at ${t} on "seeked" event ${i?i.len:"empty"})`)}},a.registerListeners(),a}return y(e,pD),m(e,[{key:"registerListeners",value:function(){M(e,"registerListeners",this)([]);var t=this.hls;t.on(UE.MANIFEST_PARSED,this.onManifestParsed,this),t.on(UE.LEVEL_LOADING,this.onLevelLoading,this),t.on(UE.LEVEL_LOADED,this.onLevelLoaded,this),t.on(UE.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.on(UE.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(UE.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(UE.BUFFER_CREATED,this.onBufferCreated,this),t.on(UE.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(UE.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(UE.FRAG_BUFFERED,this.onFragBuffered,this)}},{key:"unregisterListeners",value:function(){M(e,"unregisterListeners",this)([]);var t=this.hls;t.off(UE.MANIFEST_PARSED,this.onManifestParsed,this),t.off(UE.LEVEL_LOADED,this.onLevelLoaded,this),t.off(UE.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.off(UE.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(UE.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(UE.BUFFER_CREATED,this.onBufferCreated,this),t.off(UE.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(UE.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(UE.FRAG_BUFFERED,this.onFragBuffered,this)}},{key:"onHandlerDestroying",value:function(){this.onMediaPlaying=this.onMediaSeeked=null,this.unregisterListeners(),M(e,"onHandlerDestroying",this)([])}},{key:"startLoad",value:function(e,t){if(this.levels){var i=this.lastCurrentTime,n=this.hls;if(this.stopLoad(),this.setInterval(100),this.level=-1,!this.startFragRequested){var a=n.startLevel;-1===a&&(n.config.testBandwidth&&this.levels.length>1?(a=0,this.bitrateTest=!0):a=n.firstAutoLevel),n.nextLoadLevel=a,this.level=n.loadLevel,this._hasEnoughToStart=!!t}i>0&&-1===e&&!t&&(this.log(`Override startPosition with lastCurrentTime @${i.toFixed(3)}`),e=i),this.state=rD,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}else this._forceStartLoad=!0,this.state=aD}},{key:"stopLoad",value:function(){this._forceStartLoad=!1,M(e,"stopLoad",this)([])}},{key:"doTick",value:function(){switch(this.state){case vD:var e=this.levels,t=this.level,i=null==e?void 0:e[t],n=null==i?void 0:i.details;if(n&&(!n.live||this.levelLastLoaded===i&&!this.waitForLive(i))){if(this.waitForCdnTuneIn(n))break;this.state=rD;break}if(this.hls.nextLoadLevel!==this.level){this.state=rD;break}break;case uD:this.checkRetryDate()}this.state===rD&&this.doTickIdle(),this.onTickEnd()}},{key:"onTickEnd",value:function(){var t;M(e,"onTickEnd",this)([]),null!=(t=this.media)&&t.readyState&&!1===this.media.seeking&&(this.lastCurrentTime=this.media.currentTime),this.checkFragmentChanged()}},{key:"doTickIdle",value:function(){var e=this.hls,t=this.levelLastLoaded,i=this.levels,n=this.media;if(null!==t&&(n||this.primaryPrefetch||!this.startFragRequested&&e.config.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)){var a=this.buffering?e.nextLoadLevel:e.loadLevel;if(null!=i&&i[a]){var r=i[a],o=this.getMainFwdBufferInfo();if(null!==o){var s=this.getLevelDetails();if(s&&this._streamEnded(o,s)){var u={};return 2===this.altAudio&&(u.type="video"),this.hls.trigger(UE.BUFFER_EOS,u),void(this.state=cD)}if(this.buffering){e.loadLevel!==a&&-1===e.manualLevel&&this.log(`Adapting to level ${a} from level ${this.level}`),this.level=e.nextLoadLevel=a;var l=r.details;if(!l||this.state===vD||this.waitForLive(r))return this.level=a,this.state=vD,void(this.startFragRequested=!1);var d=o.len,h=this.getMaxBufferLength(r.maxBitrate);if(!(d>=h)){this.backtrackFragment&&this.backtrackFragment.start>o.end&&(this.backtrackFragment=null);var c=this.backtrackFragment?this.backtrackFragment.start:o.end,m=this.getNextFragment(c,l);if(this.couldBacktrack&&!this.fragPrevious&&m&&xT(m)&&this.fragmentTracker.getState(m)!==bM){var f,v=(null!=(f=this.backtrackFragment)?f:m).sn-l.startSN,p=l.fragments[v-1];p&&m.cc===p.cc&&(m=p,this.fragmentTracker.removeFragment(p))}else this.backtrackFragment&&o.len&&(this.backtrackFragment=null);if(m&&this.isLoopLoading(m,c)){if(!m.gap){var g=this.audioOnly&&!this.altAudio?PT:MT,y=(g===MT?this.videoBuffer:this.mediaBuffer)||this.media;y&&this.afterBufferFlushed(y,g,XE)}m=this.getNextFragmentLoopLoading(m,l,o,XE,h)}m&&(this.exceedsMaxBuffer(o,h,m)||(!m.initSegment||m.initSegment.data||this.bitrateTest||(m=m.initSegment),this.loadFragment(m,r,c)))}}}}}}},{key:"loadFragment",value:function(t,i,n){var a=this.fragmentTracker.getState(t);a===pM||a===yM?xT(t)?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,i)):M(e,"loadFragment",this)([t,i,n]):this._loadInitSegment(t,i):this.clearTrackerIfNeeded(t)}},{key:"getBufferedFrag",value:function(e){return this.fragmentTracker.getBufferedFrag(e,XE)}},{key:"followingBufferedFrag",value:function(e){return e?this.getBufferedFrag(e.end+.5):null}},{key:"immediateLevelSwitch",value:function(){var t;(this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY),0!==this.altAudio)&&(((null==(t=this.getLevelDetails())?void 0:t.fragmentStart)||0)>this.lastCurrentTime&&M(e,"flushMainBuffer",this)([0,Number.POSITIVE_INFINITY,"audio"]))}},{key:"nextLevelSwitch",value:function(){var e=this.levels,t=this.media;if(null!=t&&t.readyState){var i,n=this.getAppendedFrag(t.currentTime);n&&n.start>1&&this.flushMainBuffer(0,n.start-1);var a=this.getLevelDetails();if(null!=a&&a.live){var r=this.getMainFwdBufferInfo();if(!r||r.len<2*a.targetduration)return}if(!t.paused&&e){var o=e[this.hls.nextLoadLevel],s=this.fragLastKbps;i=s&&this.fragCurrent?this.fragCurrent.duration*o.maxBitrate/(1e3*s)+1:0}else i=0;var u=this.getBufferedFrag(t.currentTime+i);if(u){var l=this.followingBufferedFrag(u);if(l){this.abortCurrentFrag();var d=l.maxStartPTS?l.maxStartPTS:l.start,h=l.duration,c=Math.max(u.end,d+Math.min(Math.max(h-this.config.maxFragLookUpTolerance,h*(this.couldBacktrack?.5:.125)),h*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(c,Number.POSITIVE_INFINITY)}}}}},{key:"abortCurrentFrag",value:function(){var e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case oD:case sD:case uD:case dD:case hD:this.state=rD}this.nextLoadPosition=this.getLoadPosition()}},{key:"flushMainBuffer",value:function(t,i){M(e,"flushMainBuffer",this)([t,i,2===this.altAudio?"video":null])}},{key:"onMediaAttached",value:function(t,i){M(e,"onMediaAttached",this)([t,i]);var n=i.media;tD(n,"playing",this.onMediaPlaying),tD(n,"seeked",this.onMediaSeeked)}},{key:"onMediaDetaching",value:function(t,i){var n=this.media;n&&(iD(n,"playing",this.onMediaPlaying),iD(n,"seeked",this.onMediaSeeked)),this.videoBuffer=null,this.fragPlaying=null,M(e,"onMediaDetaching",this)([t,i]),!!i.transferMedia||(this._hasEnoughToStart=!1)}},{key:"onManifestLoading",value:function(){M(e,"onManifestLoading",this)([]),this.log("Trigger BUFFER_RESET"),this.hls.trigger(UE.BUFFER_RESET,void 0),this.couldBacktrack=!1,this.fragLastKbps=0,this.fragPlaying=this.backtrackFragment=null,this.altAudio=0,this.audioOnly=!1}},{key:"onManifestParsed",value:function(e,t){for(var i,n,a=!1,r=!1,o=0;o<t.levels.length;o++){var s=t.levels[o].audioCodec;s&&(a=a||-1!==s.indexOf("mp4a.40.2"),r=r||-1!==s.indexOf("mp4a.40.5"))}this.audioCodecSwitch=a&&r&&!("function"==typeof(null==(n=t_())||null==(i=n.prototype)?void 0:i.changeType)),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1}},{key:"onLevelLoading",value:function(e,t){if(this.levels&&this.state===rD){var i=t.levelInfo;(!i.details||i.details.live&&(this.levelLastLoaded!==i||i.details.expired)||this.waitForCdnTuneIn(i.details))&&(this.state=vD)}}},{key:"onLevelLoaded",value:function(e,t){var i,n=this.levels,a=this.startFragRequested,r=t.level,o=t.details,s=o.totalduration;if(n){this.log(`Level ${r} loaded [${o.startSN},${o.endSN}]${o.lastPartSn?`[part-${o.lastPartSn}-${o.lastPartIndex}]`:""}, cc [${o.startCC}, ${o.endCC}] duration:${s}`);var u=t.levelInfo,l=this.fragCurrent;!l||this.state!==sD&&this.state!==uD||l.level!==t.level&&l.loader&&this.abortCurrentFrag();var d=0;if(o.live||null!=(i=u.details)&&i.live){var h;if(this.checkLiveUpdate(o),o.deltaUpdateFailed)return;d=this.alignPlaylists(o,u.details,null==(h=this.levelLastLoaded)?void 0:h.details)}if(u.details=o,this.levelLastLoaded=u,a||this.setStartPosition(o,d),this.hls.trigger(UE.LEVEL_UPDATED,{details:o,level:r}),this.state===vD){if(this.waitForCdnTuneIn(o))return;this.state=rD}a&&o.live&&this.synchronizeToLiveEdge(o),this.tick()}else this.warn(`Levels were reset while loading level ${r}`)}},{key:"synchronizeToLiveEdge",value:function(e){var t=this.config,i=this.media;if(i){var n=this.hls.liveSyncPosition,a=this.getLoadPosition(),r=e.fragmentStart,o=e.edge,s=a>=r-t.maxFragLookUpTolerance&&a<=o;if(null!==n&&i.duration>n&&(a<n||!s)){var u=void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;if((!s&&i.readyState<4||a<o-u)&&(this._hasEnoughToStart||(this.nextLoadPosition=n),i.readyState))if(this.warn(`Playback: ${a.toFixed(3)} is located too far from the end of live sliding playlist: ${o}, reset currentTime to : ${n.toFixed(3)}`),"buffered"===this.config.liveSyncMode){var l,d=$M.bufferInfo(i,n,0);if(null==(l=d.buffered)||!l.length)return void(i.currentTime=n);if(d.start<=a)return void(i.currentTime=n);var h=$M.bufferedInfo(d.buffered,a,0).nextStart;h&&(i.currentTime=h)}else i.currentTime=n}}}},{key:"_handleFragmentLoadProgress",value:function(e){var t,i=e.frag,n=e.part,a=e.payload,r=this.levels;if(r){var o=r[i.level];if(o){var s=o.details;if(!s)return this.warn(`Dropping fragment ${i.sn} of level ${i.level} after level details were reset`),void this.fragmentTracker.removeFragment(i);var u=o.videoCodec,l=s.PTSKnown||!s.live,d=null==(t=i.initSegment)?void 0:t.data,h=this._getAudioCodec(o),c=this.transmuxer=this.transmuxer||new Jx(this.hls,XE,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),m=n?n.index:-1,f=-1!==m,v=new OM(i.level,i.sn,i.stats.chunkCount,a.byteLength,m,f),p=this.initPTS[i.cc];c.push(a,d,h,u,i,n,s.totalduration,l,v,p)}else this.warn(`Level ${i.level} not found on progress`)}else this.warn(`Levels were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`)}},{key:"onAudioTrackSwitching",value:function(e,t){var i=this.hls,n=0!==this.altAudio;if(GP(t.url,i))this.altAudio=1;else{if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var a=this.fragCurrent;a&&(this.log("Switching to main audio track, cancel main fragment load"),a.abortRequests(),this.fragmentTracker.removeFragment(a)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();if(n)return this.altAudio=0,this.fragmentTracker.removeAllFragments(),i.once(UE.BUFFER_FLUSHED,()=>{this.hls&&this.hls.trigger(UE.AUDIO_TRACK_SWITCHED,t)}),void i.trigger(UE.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null});i.trigger(UE.AUDIO_TRACK_SWITCHED,t)}}},{key:"onAudioTrackSwitched",value:function(e,t){var i=GP(t.url,this.hls);if(i){var n=this.videoBuffer;n&&this.mediaBuffer!==n&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=n)}this.altAudio=i?2:0,this.tick()}},{key:"onBufferCreated",value:function(e,t){var i,n,a=t.tracks,r=!1;for(var o in a){var s=a[o];if("main"===s.id){if(n=o,i=s,"video"===o){var u=a[o];u&&(this.videoBuffer=u.buffer)}}else r=!0}r&&i?(this.log(`Alternate track found, use ${n}.buffered to schedule main fragment loading`),this.mediaBuffer=i.buffer):this.mediaBuffer=this.media}},{key:"onFragBuffered",value:function(e,t){var i=t.frag,n=t.part,a=i.type===XE;if(a){if(this.fragContextChanged(i))return this.warn(`Fragment ${i.sn}${n?" p: "+n.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}`),void(this.state===hD&&(this.state=rD));var r=n?n.stats:i.stats;this.fragLastKbps=Math.round(8*r.total/(r.buffering.end-r.loading.first)),xT(i)&&(this.fragPrevious=i),this.fragBufferedComplete(i,n)}var o=this.media;o&&(!this._hasEnoughToStart&&$M.getBuffered(o).length&&(this._hasEnoughToStart=!0,this.seekToStartPos()),a&&this.tick())}},{key:"hasEnoughToStart",get:function(){return this._hasEnoughToStart}},{key:"onError",value:function(e,t){var i;if(t.fatal)this.state=mD;else switch(t.details){case zE.FRAG_GAP:case zE.FRAG_PARSING_ERROR:case zE.FRAG_DECRYPT_ERROR:case zE.FRAG_LOAD_ERROR:case zE.FRAG_LOAD_TIMEOUT:case zE.KEY_LOAD_ERROR:case zE.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(XE,t);break;case zE.LEVEL_LOAD_ERROR:case zE.LEVEL_LOAD_TIMEOUT:case zE.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==vD||(null==(i=t.context)?void 0:i.type)!==GE||(this.state=rD);break;case zE.BUFFER_ADD_CODEC_ERROR:case zE.BUFFER_APPEND_ERROR:if("main"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)&&this.resetLoadingState();break;case zE.BUFFER_FULL_ERROR:if("main"!==t.parent)return;if(this.reduceLengthAndFlushBuffer(t))!this.config.interstitialsController&&this.config.assetPlayerId?this._hasEnoughToStart=!0:this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case zE.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}},{key:"onFragLoadEmergencyAborted",value:function(){this.state=rD,this._hasEnoughToStart||(this.startFragRequested=!1,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate()}},{key:"onBufferFlushed",value:function(e,{type:t}){if(t!==PT||!this.altAudio){var i=(t===MT?this.videoBuffer:this.mediaBuffer)||this.media;i&&(this.afterBufferFlushed(i,t,XE),this.tick())}}},{key:"onLevelsUpdated",value:function(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level,-1===this.level&&this.resetWhenMissingContext(this.fragCurrent)),this.levels=t.levels}},{key:"swapAudioCodec",value:function(){this.audioCodecSwap=!this.audioCodecSwap}},{key:"seekToStartPos",value:function(){var e=this.media;if(e){var t=e.currentTime,i=this.startPosition;if(i>=0&&t<i){if(e.seeking)return void this.log(`could not seek to ${i}, already seeking at ${t}`);var n=this.timelineOffset;n&&i&&(i+=n);var a=this.getLevelDetails(),r=$M.getBuffered(e),o=r.length?r.start(0):0,s=o-i,u=Math.max(this.config.maxBufferHole,this.config.maxFragLookUpTolerance);(this.config.startOnSegmentBoundary||s>0&&(s<u||this.loadingParts&&s<2*((null==a?void 0:a.partTarget)||0)))&&(this.log(`adjusting start position by ${s} to match buffer start`),i+=s,this.startPosition=i),t<i&&(this.log(`seek to target start position ${i} from current time ${t} buffer start ${o}`),e.currentTime=i)}}}},{key:"_getAudioCodec",value:function(e){var t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t=-1!==t.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),t}},{key:"_loadBitrateTestFrag",value:function(e,t){e.bitrateTest=!0,this._doFragLoad(e,t).then(e=>{var i=this.hls,n=null==e?void 0:e.frag;if(n&&!this.fragContextChanged(n)){t.fragmentError=0,this.state=rD,this.startFragRequested=!1,this.bitrateTest=!1;var a=n.stats;a.parsing.start=a.parsing.end=a.buffering.start=a.buffering.end=self.performance.now(),i.trigger(UE.FRAG_LOADED,e),n.bitrateTest=!1}}).catch(t=>{this.state!==aD&&this.state!==mD&&(this.warn(t),this.resetFragmentLoading(e))})}},{key:"_handleTransmuxComplete",value:function(e){var t=this.playlistType,i=this.hls,n=e.remuxResult,a=e.chunkMeta,r=this.getCurrentContext(a);if(r){var o=r.frag,s=r.part,u=r.level,l=n.video,d=n.text,h=n.id3,c=n.initSegment,m=u.details,f=this.altAudio?void 0:n.audio;if(this.fragContextChanged(o))this.fragmentTracker.removeFragment(o);else{if(this.state=dD,c){var v=c.tracks;if(v){var p=o.initSegment||o;if(this.unhandledEncryptionError(c,o))return;this._bufferInitSegment(u,v,p,a),i.trigger(UE.FRAG_PARSING_INIT_SEGMENT,{frag:p,id:t,tracks:v})}var g=c.initPTS,y=c.timescale,b=this.initPTS[o.cc];if($E(g)&&(!b||b.baseTime!==g||b.timescale!==y)){var w=c.trackId;this.initPTS[o.cc]={baseTime:g,timescale:y,trackId:w},i.trigger(UE.INIT_PTS_FOUND,{frag:o,id:t,initPTS:g,timescale:y,trackId:w})}}if(l&&m){f&&"audiovideo"===l.type&&this.logMuxedErr(o);var k=m.fragments[o.sn-1-m.startSN],S=o.sn===m.startSN,E=!k||o.cc>k.cc;if(!1!==n.independent){var T=l.startPTS,P=l.endPTS,M=l.startDTS,A=l.endDTS;if(s)s.elementaryStreams[l.type]={startPTS:T,endPTS:P,startDTS:M,endDTS:A};else if(l.firstKeyFrame&&l.independent&&1===a.id&&!E&&(this.couldBacktrack=!0),l.dropped&&l.independent){var D=this.getMainFwdBufferInfo(),x=(D?D.end:this.getLoadPosition())+this.config.maxBufferHole,C=l.firstKeyFramePTS?l.firstKeyFramePTS:T;if(!S&&x<C-this.config.maxBufferHole&&!E)return void this.backtrack(o);E&&(o.gap=!0),o.setElementaryStreamInfo(l.type,o.start,P,o.start,A,!0)}else S&&T-(m.appliedTimelineOffset||0)>2&&(o.gap=!0);o.setElementaryStreamInfo(l.type,T,P,M,A),this.backtrackFragment&&(this.backtrackFragment=o),this.bufferFragmentData(l,o,s,a,S||E)}else{if(!S&&!E)return void this.backtrack(o);o.gap=!0}}if(f){var I=f.startPTS,L=f.endPTS,_=f.startDTS,R=f.endDTS;s&&(s.elementaryStreams[PT]={startPTS:I,endPTS:L,startDTS:_,endDTS:R}),o.setElementaryStreamInfo(PT,I,L,_,R),this.bufferFragmentData(f,o,s,a)}if(m&&null!=h&&h.samples.length){var F={id:t,frag:o,details:m,samples:h.samples};i.trigger(UE.FRAG_PARSING_METADATA,F)}if(m&&d){var O={id:t,frag:o,details:m,samples:d.samples};i.trigger(UE.FRAG_PARSING_USERDATA,O)}}}else this.resetWhenMissingContext(a)}},{key:"logMuxedErr",value:function(e){this.warn(`${xT(e)?"Media":"Init"} segment with muxed audiovideo where only video expected: ${e.url}`)}},{key:"_bufferInitSegment",value:function(e,t,i,n){if(this.state===dD){this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&(delete t.audio,t.audiovideo&&this.logMuxedErr(i));var a=t.audio,r=t.video,o=t.audiovideo;if(a){var s=e.audioCodec,u=pP(a.codec,s);"mp4a"===u&&(u="mp4a.40.5");var l=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){u&&(u=-1!==u.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5");var d=a.metadata;d&&"channelCount"in d&&1!==(d.channelCount||1)&&-1===l.indexOf("firefox")&&(u="mp4a.40.5")}u&&-1!==u.indexOf("mp4a.40.5")&&-1!==l.indexOf("android")&&"audio/mpeg"!==a.container&&(u="mp4a.40.2",this.log(`Android: force audio codec to ${u}`)),s&&s!==u&&this.log(`Swapping manifest audio codec "${s}" for "${u}"`),a.levelCodec=u,a.id=XE,this.log(`Init audio buffer, container:${a.container}, codecs[selected/level/parsed]=[${u||""}/${s||""}/${a.codec}]`),delete t.audiovideo}if(r){r.levelCodec=e.videoCodec,r.id=XE;var h=r.codec;if(4===(null==h?void 0:h.length))switch(h){case"hvc1":case"hev1":r.codec="hvc1.1.6.L120.90";break;case"av01":r.codec="av01.0.04M.08";break;case"avc1":r.codec="avc1.42e01e"}this.log(`Init video buffer, container:${r.container}, codecs[level/parsed]=[${e.videoCodec||""}/${h}]${r.codec!==h?" parsed-corrected="+r.codec:""}${r.supplemental?" supplemental="+r.supplemental:""}`),delete t.audiovideo}o&&(this.log(`Init audiovideo buffer, container:${o.container}, codecs[level/parsed]=[${e.codecs}/${o.codec}]`),delete t.video,delete t.audio);var c=Object.keys(t);if(c.length){if(this.hls.trigger(UE.BUFFER_CODECS,t),!this.hls)return;c.forEach(e=>{var a=t[e].initSegment;null!=a&&a.byteLength&&this.hls.trigger(UE.BUFFER_APPENDING,{type:e,data:a,frag:i,part:null,chunkMeta:n,parent:i.type})})}this.tickImmediate()}}},{key:"getMainFwdBufferInfo",value:function(){var e=this.mediaBuffer&&2===this.altAudio?this.mediaBuffer:this.media;return this.getFwdBufferInfo(e,XE)}},{key:"maxBufferLength",get:function(){var e=this.levels,t=this.level,i=null==e?void 0:e[t];return i?this.getMaxBufferLength(i.maxBitrate):this.config.maxBufferLength}},{key:"backtrack",value:function(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=rD}},{key:"checkFragmentChanged",value:function(){var e=this.media,t=null;if(e&&e.readyState>1&&!1===e.seeking){var i=e.currentTime;if($M.isBuffered(e,i)?t=this.getAppendedFrag(i):$M.isBuffered(e,i+.1)&&(t=this.getAppendedFrag(i+.1)),t){this.backtrackFragment=null;var n=this.fragPlaying,a=t.level;n&&t.sn===n.sn&&n.level===a||(this.fragPlaying=t,this.hls.trigger(UE.FRAG_CHANGED,{frag:t}),n&&n.level===a||this.hls.trigger(UE.LEVEL_SWITCHED,{level:a}))}}}},{key:"nextLevel",get:function(){var e=this.nextBufferedFrag;return e?e.level:-1}},{key:"currentFrag",get:function(){var e;if(this.fragPlaying)return this.fragPlaying;var t=(null==(e=this.media)?void 0:e.currentTime)||this.lastCurrentTime;return $E(t)?this.getAppendedFrag(t):null}},{key:"currentProgramDateTime",get:function(){var e,t=(null==(e=this.media)?void 0:e.currentTime)||this.lastCurrentTime;if($E(t)){var i=this.getLevelDetails(),n=this.currentFrag||(i?XP(null,i.fragments,t):null);if(n){var a=n.programDateTime;if(null!==a){var r=a+1e3*(t-n.start);return new Date(r)}}}return null}},{key:"currentLevel",get:function(){var e=this.currentFrag;return e?e.level:-1}},{key:"nextBufferedFrag",get:function(){var e=this.currentFrag;return e?this.followingBufferedFrag(e):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}])}(),a_=function(){function e(t,i){var n;return u(this,e),(n=s(this,e,["key-loader",i])).config=void 0,n.keyIdToKeyInfo={},n.emeController=null,n.config=t,n}return y(e,nT),m(e,[{key:"abort",value:function(e){for(var t in this.keyIdToKeyInfo){var i=this.keyIdToKeyInfo[t].loader;if(i){var n;if(e&&e!==(null==(n=i.context)?void 0:n.frag.type))return;i.abort()}}}},{key:"detach",value:function(){for(var e in this.keyIdToKeyInfo){var t=this.keyIdToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyIdToKeyInfo[e]}}},{key:"destroy",value:function(){for(var e in this.detach(),this.keyIdToKeyInfo){var t=this.keyIdToKeyInfo[e].loader;t&&t.destroy()}this.keyIdToKeyInfo={}}},{key:"createKeyLoadError",value:function(e,t=zE.KEY_LOAD_ERROR,i,n,a){return new RM({type:BE.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:a,error:i,networkDetails:n})}},{key:"loadClear",value:function(e,t,i){var n=this;if(this.emeController&&this.config.emeEnabled&&!this.emeController.getSelectedKeySystemFormats().length){if(t.length)for(var a,r=function(){var a=t[o];if(e.cc<=a.cc&&(!xT(e)||!xT(a)||e.sn<a.sn)||!i&&o==s-1)return{v:n.emeController.selectKeySystemFormat(a).then(e=>{if(n.emeController){a.setKeyFormat(e);var t=hA(e);return t?n.emeController.getKeySystemAccess([t]):void 0}})}},o=0,s=t.length;o<s;o++)if(a=r())return a.v;if(this.config.requireKeySystemAccessOnStart){var u=mA(this.config);if(u.length)return this.emeController.getKeySystemAccess(u)}}return null}},{key:"load",value:function(e){return!e.decryptdata&&e.encrypted&&this.emeController&&this.config.emeEnabled?this.emeController.selectKeySystemFormat(e).then(t=>this.loadInternal(e,t)):this.loadInternal(e)}},{key:"loadInternal",value:function(e,t){var i,n;t&&e.setKeyFormat(t);var a=e.decryptdata;if(!a){var r=new Error(t?`Expected frag.decryptdata to be defined after setting format ${t}`:`Missing decryption data on fragment in onKeyLoading (emeEnabled with controller: ${this.emeController&&this.config.emeEnabled})`);return Promise.reject(this.createKeyLoadError(e,zE.KEY_LOAD_ERROR,r))}var o=a.uri;if(!o)return Promise.reject(this.createKeyLoadError(e,zE.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${o}"`)));var s=r_(a),u=this.keyIdToKeyInfo[s];if(null!=(i=u)&&i.decryptdata.key)return a.key=u.decryptdata.key,Promise.resolve({frag:e,keyInfo:u});if(this.emeController&&null!=(n=u)&&n.keyLoadPromise)switch(this.emeController.getKeyStatus(u.decryptdata)){case"usable":case"usable-in-future":return u.keyLoadPromise.then(t=>{var i=t.keyInfo;return a.key=i.decryptdata.key,{frag:e,keyInfo:i}})}switch(this.log(`${this.keyIdToKeyInfo[s]?"Rel":"L"}oading${a.keyId?" keyId: "+mT(a.keyId):""} URI: ${a.uri} from ${e.type} ${e.level}`),u=this.keyIdToKeyInfo[s]={decryptdata:a,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},a.method){case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return"identity"===a.keyFormat?this.loadKeyHTTP(u,e):this.loadKeyEME(u,e);case"AES-128":case"AES-256":case"AES-256-CTR":return this.loadKeyHTTP(u,e);default:return Promise.reject(this.createKeyLoadError(e,zE.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${a.method}"`)))}}},{key:"loadKeyEME",value:function(e,t){var i={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){var n;if(!e.decryptdata.keyId&&null!=(n=t.initSegment)&&n.data){var a=function(e){var t=[];return YT(e,e=>t.push(e.subarray(8,24))),t}(t.initSegment.data);if(a.length){var r=a[0];r.some(e=>0!==e)?(this.log(`Using keyId found in init segment ${mT(r)}`),yA.setKeyIdForUri(e.decryptdata.uri,r)):(r=yA.addKeyIdForUri(e.decryptdata.uri),this.log(`Generating keyId to patch media ${mT(r)}`)),e.decryptdata.keyId=r}}if(!e.decryptdata.keyId&&!xT(t))return Promise.resolve(i);var o=this.emeController.loadKey(i);return(e.keyLoadPromise=o.then(t=>(e.mediaKeySessionContext=t,i))).catch(i=>{throw e.keyLoadPromise=null,"data"in i&&(i.data.frag=t),i})}return Promise.resolve(i)}},{key:"loadKeyHTTP",value:function(e,t){var i=this.config,n=new(0,i.loader)(i);return t.keyLoader=e.loader=n,e.keyLoadPromise=new Promise((a,r)=>{var o={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},s=i.keyLoadPolicy.default,u={loadPolicy:s,timeout:s.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},l={onSuccess:(e,t,i,n)=>{var o=i.frag,s=i.keyInfo,u=r_(s.decryptdata);if(!o.decryptdata||s!==this.keyIdToKeyInfo[u])return r(this.createKeyLoadError(o,zE.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),n));s.decryptdata.key=o.decryptdata.key=new Uint8Array(e.data),o.keyLoader=null,s.loader=null,a({frag:o,keyInfo:s})},onError:(e,i,n,a)=>{this.resetLoader(i),r(this.createKeyLoadError(t,zE.KEY_LOAD_ERROR,new Error(`HTTP Error ${e.code} loading key ${e.text}`),n,iT({url:o.url,data:void 0},e)))},onTimeout:(e,i,n)=>{this.resetLoader(i),r(this.createKeyLoadError(t,zE.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),n))},onAbort:(e,i,n)=>{this.resetLoader(i),r(this.createKeyLoadError(t,zE.INTERNAL_ABORTED,new Error("key loading aborted"),n))}};n.load(o,u,l)})}},{key:"resetLoader",value:function(e){var t=e.frag,i=e.keyInfo,n=e.url,a=i.loader;t.keyLoader===a&&(t.keyLoader=null,i.loader=null);var r=r_(i.decryptdata)||n;delete this.keyIdToKeyInfo[r],a&&a.destroy()}}])}();function r_(e){if(e.keyFormat!==uA){var t=e.keyId;if(t)return mT(t)}return e.uri}function o_(e){switch(e.type){case VE:return YE;case KE:return qE;default:return XE}}function s_(e,t){var i=e.url;return void 0!==i&&0!==i.indexOf("data:")||(i=t.url),i}var u_=function(){return m(function e(t){u(this,e),this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.onManifestLoaded=this.checkAutostartLoad,this.hls=t,this.registerListeners()},[{key:"startLoad",value:function(e){}},{key:"stopLoad",value:function(){this.destroyInternalLoaders()}},{key:"registerListeners",value:function(){var e=this.hls;e.on(UE.MANIFEST_LOADING,this.onManifestLoading,this),e.on(UE.LEVEL_LOADING,this.onLevelLoading,this),e.on(UE.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(UE.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.on(UE.LEVELS_UPDATED,this.onLevelsUpdated,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(UE.MANIFEST_LOADING,this.onManifestLoading,this),e.off(UE.LEVEL_LOADING,this.onLevelLoading,this),e.off(UE.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(UE.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.off(UE.LEVELS_UPDATED,this.onLevelsUpdated,this)}},{key:"createInternalLoader",value:function(e){var t=this.hls.config,i=t.pLoader,n=t.loader,a=new(i||n)(t);return this.loaders[e.type]=a,a}},{key:"getInternalLoader",value:function(e){return this.loaders[e.type]}},{key:"resetInternalLoader",value:function(e){this.loaders[e]&&delete this.loaders[e]}},{key:"destroyInternalLoaders",value:function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}}},{key:"destroy",value:function(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}},{key:"onManifestLoading",value:function(e,t){var i=t.url;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:HE,url:i,deliveryDirectives:null,levelOrTrack:null})}},{key:"onLevelLoading",value:function(e,t){var i=t.id,n=t.level,a=t.pathwayId,r=t.url,o=t.deliveryDirectives,s=t.levelInfo;this.load({id:i,level:n,pathwayId:a,responseType:"text",type:GE,url:r,deliveryDirectives:o,levelOrTrack:s})}},{key:"onAudioTrackLoading",value:function(e,t){var i=t.id,n=t.groupId,a=t.url,r=t.deliveryDirectives,o=t.track;this.load({id:i,groupId:n,level:null,responseType:"text",type:VE,url:a,deliveryDirectives:r,levelOrTrack:o})}},{key:"onSubtitleTrackLoading",value:function(e,t){var i=t.id,n=t.groupId,a=t.url,r=t.deliveryDirectives,o=t.track;this.load({id:i,groupId:n,level:null,responseType:"text",type:KE,url:a,deliveryDirectives:r,levelOrTrack:o})}},{key:"onLevelsUpdated",value:function(e,t){var i=this.loaders[GE];if(i){var n=i.context;n&&!t.levels.some(e=>e===n.levelOrTrack)&&(i.abort(),delete this.loaders[GE])}}},{key:"load",value:function(e){var t,i,n,a=this.hls.config,r=this.getInternalLoader(e);if(r){var o=this.hls.logger,s=r.context;if(s&&s.levelOrTrack===e.levelOrTrack&&(s.url===e.url||s.deliveryDirectives&&!e.deliveryDirectives))return void(s.url===e.url?o.log(`[playlist-loader]: ignore ${e.url} ongoing request`):o.log(`[playlist-loader]: ignore ${e.url} in favor of ${s.url}`));o.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),r.abort()}if((i=e.type===HE?a.manifestLoadPolicy.default:eT({},a.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),r=this.createInternalLoader(e),$E(null==(t=e.deliveryDirectives)?void 0:t.part))&&(e.type===GE&&null!==e.level?n=this.hls.levels[e.level].details:e.type===VE&&null!==e.id?n=this.hls.audioTracks[e.id].details:e.type===KE&&null!==e.id&&(n=this.hls.subtitleTracks[e.id].details),n)){var u=n.partTarget,l=n.targetduration;if(u&&l){var d=1e3*Math.max(3*u,.8*l);i=eT({},i,{maxTimeToFirstByteMs:Math.min(d,i.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(d,i.maxTimeToFirstByteMs)})}}var h=i.errorRetry||i.timeoutRetry||{},c={loadPolicy:i,timeout:i.maxLoadTimeMs,maxRetry:h.maxNumRetry||0,retryDelay:h.retryDelayMs||0,maxRetryDelay:h.maxRetryDelayMs||0},m={onSuccess:(e,t,i,n)=>{var a=this.getInternalLoader(i);this.resetInternalLoader(i.type);var r=e.data;t.parsing.start=performance.now(),PA.isMediaPlaylist(r)||i.type!==HE?this.handleTrackOrLevelPlaylist(e,t,i,n||null,a):this.handleMasterPlaylist(e,t,i,n)},onError:(e,t,i,n)=>{this.handleNetworkError(t,i,!1,e,n)},onTimeout:(e,t,i)=>{this.handleNetworkError(t,i,!0,void 0,e)}};r.load(e,c,m)}},{key:"checkAutostartLoad",value:function(){if(this.hls){var e=this.hls,t=e.config,i=t.autoStartLoad,n=t.startPosition,a=e.forceStartLoad;(i||a)&&(this.hls.logger.log(`${i?"auto":"force"} startLoad with configured startPosition ${n}`),this.hls.startLoad(n))}}},{key:"handleMasterPlaylist",value:function(e,t,i,n){var a=this.hls,r=e.data,o=s_(e,i),s=PA.parseMasterPlaylist(r,o);if(s.playlistParsingError)return t.parsing.end=performance.now(),void this.handleManifestParsingError(e,i,s.playlistParsingError,n,t);var u=s.contentSteering,l=s.levels,d=s.sessionData,h=s.sessionKeys,c=s.startTimeOffset,m=s.variableList;this.variableList=m,l.forEach(e=>{var t=e.unknownCodecs;if(t)for(var i=this.hls.config.preferManagedMediaSource,n=e.audioCodec,a=e.videoCodec,r=t.length;r--;){var o=t[r];uP(o,"audio",i)?(e.audioCodec=n=n?`${n},${o}`:o,oP.audio[n.substring(0,4)]=2,t.splice(r,1)):uP(o,"video",i)&&(e.videoCodec=a=a?`${a},${o}`:o,oP.video[a.substring(0,4)]=2,t.splice(r,1))}});var f=PA.parseMasterPlaylistMedia(r,o,s),v=f.AUDIO,p=void 0===v?[]:v,g=f.SUBTITLES,y=f["CLOSED-CAPTIONS"];p.length&&(p.some(e=>!e.url)||!l[0].audioCodec||l[0].attrs.AUDIO||(this.hls.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),p.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new VM({}),bitrate:0,url:""})));a.trigger(UE.MANIFEST_LOADED,{levels:l,audioTracks:p,subtitles:g,captions:y,contentSteering:u,url:o,stats:t,networkDetails:n,sessionData:d,sessionKeys:h,startTimeOffset:c,variableList:m})}},{key:"handleTrackOrLevelPlaylist",value:function(e,t,i,n,a){var r=this.hls,o=i.id,s=i.level,u=i.type,l=s_(e,i),d=$E(s)?s:$E(o)?o:0,h=o_(i),c=PA.parseLevelPlaylist(e.data,l,d,h,0,this.variableList);if(u===HE){var m={attrs:new VM({}),bitrate:0,details:c,name:"",url:l};c.requestScheduled=t.loading.start+UA(c,0),r.trigger(UE.MANIFEST_LOADED,{levels:[m],audioTracks:[],url:l,stats:t,networkDetails:n,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),i.levelDetails=c,this.handlePlaylistLoaded(c,e,t,i,n,a)}},{key:"handleManifestParsingError",value:function(e,t,i,n,a){this.hls.trigger(UE.ERROR,{type:BE.NETWORK_ERROR,details:zE.MANIFEST_PARSING_ERROR,fatal:t.type===HE,url:e.url,err:i,error:i,reason:i.message,response:e,context:t,networkDetails:n,stats:a})}},{key:"handleNetworkError",value:function(e,t,i=!1,n,a){var r=`A network ${i?"timeout":"error"+(n?" (status "+n.code+")":"")} occurred while loading ${e.type}`;e.type===GE?r+=`: ${e.level} id: ${e.id}`:e.type!==VE&&e.type!==KE||(r+=` id: ${e.id} group-id: "${e.groupId}"`);var o=new Error(r);this.hls.logger.warn(`[playlist-loader]: ${r}`);var s=zE.UNKNOWN,u=!1,l=this.getInternalLoader(e);switch(e.type){case HE:s=i?zE.MANIFEST_LOAD_TIMEOUT:zE.MANIFEST_LOAD_ERROR,u=!0;break;case GE:s=i?zE.LEVEL_LOAD_TIMEOUT:zE.LEVEL_LOAD_ERROR,u=!1;break;case VE:s=i?zE.AUDIO_TRACK_LOAD_TIMEOUT:zE.AUDIO_TRACK_LOAD_ERROR,u=!1;break;case KE:s=i?zE.SUBTITLE_TRACK_LOAD_TIMEOUT:zE.SUBTITLE_LOAD_ERROR,u=!1}l&&this.resetInternalLoader(e.type);var d={type:BE.NETWORK_ERROR,details:s,fatal:u,url:e.url,loader:l,context:e,error:o,networkDetails:t,stats:a};if(n){var h=(null==t?void 0:t.url)||e.url;d.response=iT({url:h,data:void 0},n)}this.hls.trigger(UE.ERROR,d)}},{key:"handlePlaylistLoaded",value:function(e,t,i,n,a,r){var o=this.hls,s=n.type,u=n.level,l=n.levelOrTrack,d=n.id,h=n.groupId,c=n.deliveryDirectives,m=s_(t,n),f=o_(n),v="number"==typeof n.level&&f===XE?u:void 0,p=e.playlistParsingError;if(p){if(this.hls.logger.warn(`${p} ${e.url}`),!o.config.ignorePlaylistParsingErrors)return void o.trigger(UE.ERROR,{type:BE.NETWORK_ERROR,details:zE.LEVEL_PARSING_ERROR,fatal:!1,url:m,error:p,reason:p.message,response:t,context:n,level:v,parent:f,networkDetails:a,stats:i});e.playlistParsingError=null}if(e.fragments.length)switch(e.live&&r&&(r.getCacheAge&&(e.ageHeader=r.getCacheAge()||0),r.getCacheAge&&!isNaN(e.ageHeader)||(e.ageHeader=0)),s){case HE:case GE:if(v)if(l){if(l!==o.levels[v]){var g=o.levels.indexOf(l);g>-1&&(v=g)}}else v=0;o.trigger(UE.LEVEL_LOADED,{details:e,levelInfo:l||o.levels[0],level:v||0,id:d||0,stats:i,networkDetails:a,deliveryDirectives:c,withoutMultiVariant:s===HE});break;case VE:o.trigger(UE.AUDIO_TRACK_LOADED,{details:e,track:l,id:d||0,groupId:h||"",stats:i,networkDetails:a,deliveryDirectives:c});break;case KE:o.trigger(UE.SUBTITLE_TRACK_LOADED,{details:e,track:l,id:d||0,groupId:h||"",stats:i,networkDetails:a,deliveryDirectives:c})}else{var y=e.playlistParsingError=new Error("No Segments found in Playlist");o.trigger(UE.ERROR,{type:BE.NETWORK_ERROR,details:zE.LEVEL_EMPTY_ERROR,fatal:!1,url:m,error:y,reason:y.message,response:t,context:n,level:v,parent:f,networkDetails:a,stats:i})}}}])}(),l_=function(){function e(t={}){u(this,e),this.config=void 0,this.userConfig=void 0,this.logger=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new SD,this._autoLevelCapping=-1,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.audioStreamController=void 0,this.subtititleStreamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.interstitialsController=void 0,this.gapController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this._url=null,this._sessionId=void 0,this.triggeringException=void 0,this.started=!1;var i=this.logger=function(e,t,i){var n=oT();if("object"==typeof console&&!0===e||"object"==typeof e){var a=["debug","log","info","warn","error"];a.forEach(t=>{n[t]=sT(t,e,i)});try{n.log(`Debug logs enabled for "${t}" in hls.js version 1.6.16`)}catch(e){return oT()}a.forEach(t=>{uT[t]=sT(t,e)})}else eT(uT,n);return n}(t.debug||!1,"Hls instance",t.assetPlayerId),n=this.config=function(e,t,i){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(void 0!==t.liveMaxLatencyDurationCount&&(void 0===t.liveSyncDurationCount||t.liveMaxLatencyDurationCount<=t.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==t.liveMaxLatencyDuration&&(void 0===t.liveSyncDuration||t.liveMaxLatencyDuration<=t.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');var n=zL(e),a=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach(e=>{var r=`${"level"===e?"playlist":e}LoadPolicy`,o=void 0===t[r],s=[];a.forEach(i=>{var a=`${e}Loading${i}`,u=t[a];if(void 0!==u&&o){s.push(a);var l=n[r].default;switch(t[r]={default:l},i){case"TimeOut":l.maxLoadTimeMs=u,l.maxTimeToFirstByteMs=u;break;case"MaxRetry":l.errorRetry.maxNumRetry=u,l.timeoutRetry.maxNumRetry=u;break;case"RetryDelay":l.errorRetry.retryDelayMs=u,l.timeoutRetry.retryDelayMs=u;break;case"MaxRetryTimeout":l.errorRetry.maxRetryDelayMs=u,l.timeoutRetry.maxRetryDelayMs=u}}}),s.length&&i.warn(`hls.js config: "${s.join('", "')}" setting(s) are deprecated, use "${r}": ${WP(t[r])}`)}),iT(iT({},n),t)}(e.DefaultConfig,t,i);this.userConfig=t,n.progressive&&UL(n,i);var a=n.abrController,r=n.bufferController,o=n.capLevelController,s=n.errorController,l=n.fpsController,d=new s(this),h=this.abrController=new a(this),c=new wM(this),m=n.interstitialsController,f=m?this.interstitialsController=new m(this,e):null,v=this.bufferController=new r(this,c),p=this.capLevelController=new o(this),g=new l(this),y=new u_(this),b=n.contentSteeringController,w=b?new b(this):null,k=this.levelController=new ZL(this,w),S=new JL(this),E=new a_(this.config,this.logger),T=this.streamController=new n_(this,c,E),P=this.gapController=new HL(this,c);p.setStreamController(T),g.setStreamController(T);var M=[y,k,T];f&&M.splice(1,0,f),w&&M.splice(1,0,w),this.networkControllers=M;var A=[h,v,P,p,g,S,c];this.audioTrackController=this.createController(n.audioTrackController,M);var D=n.audioStreamController;D&&M.push(this.audioStreamController=new D(this,c,E)),this.subtitleTrackController=this.createController(n.subtitleTrackController,M);var x=n.subtitleStreamController;x&&M.push(this.subtititleStreamController=new x(this,c,E)),this.createController(n.timelineController,A),E.emeController=this.emeController=this.createController(n.emeController,A),this.cmcdController=this.createController(n.cmcdController,A),this.latencyController=this.createController(QL,A),this.coreComponents=A,M.push(d);var C=d.onErrorOut;"function"==typeof C&&this.on(UE.ERROR,C,d),this.on(UE.MANIFEST_LOADED,y.onManifestLoaded,y)}return m(e,[{key:"createController",value:function(e,t){if(e){var i=new e(this);return t&&t.push(i),i}return null}},{key:"on",value:function(e,t,i=this){this._emitter.on(e,t,i)}},{key:"once",value:function(e,t,i=this){this._emitter.once(e,t,i)}},{key:"removeAllListeners",value:function(e){this._emitter.removeAllListeners(e)}},{key:"off",value:function(e,t,i=this,n){this._emitter.off(e,t,i,n)}},{key:"listeners",value:function(e){return this._emitter.listeners(e)}},{key:"emit",value:function(e,t,i){return this._emitter.emit(e,t,i)}},{key:"trigger",value:function(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(t){if(this.logger.error("An internal error happened while handling event "+e+'. Error message: "'+t.message+'". Here is a stacktrace:',t),!this.triggeringException){this.triggeringException=!0;var i=e===UE.ERROR;this.trigger(UE.ERROR,{type:BE.OTHER_ERROR,details:zE.INTERNAL_EXCEPTION,fatal:i,event:e,error:t}),this.triggeringException=!1}}return!1}},{key:"listenerCount",value:function(e){return this._emitter.listenerCount(e)}},{key:"destroy",value:function(){this.logger.log("destroy"),this.trigger(UE.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;var e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null}},{key:"attachMedia",value:function(e){if(!e||"media"in e&&!e.media){var t=new Error(`attachMedia failed: invalid argument (${e})`);this.trigger(UE.ERROR,{type:BE.OTHER_ERROR,details:zE.ATTACH_MEDIA_ERROR,fatal:!0,error:t})}else{this.logger.log("attachMedia"),this._media&&(this.logger.warn("media must be detached before attaching"),this.detachMedia());var i="media"in e,n=i?e.media:e,a=i?e:{media:n};this._media=n,this.trigger(UE.MEDIA_ATTACHING,a)}}},{key:"detachMedia",value:function(){this.logger.log("detachMedia"),this.trigger(UE.MEDIA_DETACHING,{}),this._media=null}},{key:"transferMedia",value:function(){this._media=null;var e=this.bufferController.transferMedia();return this.trigger(UE.MEDIA_DETACHING,{transferMedia:e}),e}},{key:"loadSource",value:function(e){this.stopLoad();var t=this.media,i=this._url,n=this._url=ET.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.logger.log(`loadSource:${n}`),t&&i&&(i!==n||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(UE.MANIFEST_LOADING,{url:e})}},{key:"url",get:function(){return this._url}},{key:"hasEnoughToStart",get:function(){return this.streamController.hasEnoughToStart}},{key:"startPosition",get:function(){return this.streamController.startPositionValue}},{key:"startLoad",value:function(e=-1,t){this.logger.log(`startLoad(${e+(t?", <skip seek to start>":"")})`),this.started=!0,this.resumeBuffering();for(var i=0;i<this.networkControllers.length&&(this.networkControllers[i].startLoad(e,t),this.started&&this.networkControllers);i++);}},{key:"stopLoad",value:function(){this.logger.log("stopLoad"),this.started=!1;for(var e=0;e<this.networkControllers.length&&(this.networkControllers[e].stopLoad(),!this.started&&this.networkControllers);e++);}},{key:"loadingEnabled",get:function(){return this.started}},{key:"bufferingEnabled",get:function(){return this.streamController.bufferingEnabled}},{key:"resumeBuffering",value:function(){this.bufferingEnabled||(this.logger.log("resume buffering"),this.networkControllers.forEach(e=>{e.resumeBuffering&&e.resumeBuffering()}))}},{key:"pauseBuffering",value:function(){this.bufferingEnabled&&(this.logger.log("pause buffering"),this.networkControllers.forEach(e=>{e.pauseBuffering&&e.pauseBuffering()}))}},{key:"inFlightFragments",get:function(){var e={[XE]:this.streamController.inFlightFrag};return this.audioStreamController&&(e[YE]=this.audioStreamController.inFlightFrag),this.subtititleStreamController&&(e[qE]=this.subtititleStreamController.inFlightFrag),e}},{key:"swapAudioCodec",value:function(){this.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()}},{key:"recoverMediaError",value:function(){this.logger.log("recoverMediaError");var e=this._media,t=null==e?void 0:e.currentTime;this.detachMedia(),e&&(this.attachMedia(e),t&&this.startLoad(t))}},{key:"removeLevel",value:function(e){this.levelController.removeLevel(e)}},{key:"sessionId",get:function(){var e=this._sessionId;return e||(e=this._sessionId=function(){try{return crypto.randomUUID()}catch(a){try{var e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}catch(e){var i=(new Date).getTime(),n="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{var t=(i+16*Math.random())%16|0;return i=Math.floor(i/16),("x"==e?t:3&t|8).toString(16)});return n}}}()),e}},{key:"levels",get:function(){var e=this.levelController.levels;return e||[]}},{key:"latestLevelDetails",get:function(){return this.streamController.getLevelDetails()||null}},{key:"loadLevelObj",get:function(){return this.levelController.loadLevelObj}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(e){this.logger.log(`set currentLevel:${e}`),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(e){this.logger.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(e){this.logger.log(`set loadLevel:${e}`),this.levelController.manualLevel=e}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(e){this.levelController.nextLoadLevel=e}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(e){this.logger.log(`set firstLevel:${e}`),this.levelController.firstLevel=e}},{key:"startLevel",get:function(){var e=this.levelController.startLevel;return-1===e&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e},set:function(e){this.logger.log(`set startLevel:${e}`),-1!==e&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(e){var t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(e){this._autoLevelCapping!==e&&(this.logger.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}},{key:"bandwidthEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimate():NaN},set:function(e){this.abrController.resetEstimator(e)}},{key:"abrEwmaDefaultEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.defaultEstimate:NaN}},{key:"ttfbEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimateTTFB():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(e){(function(e){return AP.indexOf(e)>-1})(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}},{key:"autoLevelEnabled",get:function(){return-1===this.levelController.manualLevel}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var e=this.levels,t=this.config.minAutoBitrate;if(!e)return 0;for(var i=e.length,n=0;n<i;n++)if(e[n].maxBitrate>=t)return n;return 0}},{key:"maxAutoLevel",get:function(){var e,t=this.levels,i=this.autoLevelCapping,n=this.maxHdcpLevel;if(e=-1===i&&null!=t&&t.length?t.length-1:i,n)for(var a=e;a--;){var r=t[a].attrs["HDCP-LEVEL"];if(r&&r<=n)return a}return e}},{key:"firstAutoLevel",get:function(){return this.abrController.firstAutoLevel}},{key:"nextAutoLevel",get:function(){return this.abrController.nextAutoLevel},set:function(e){this.abrController.nextAutoLevel=e}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"maxBufferLength",get:function(){return this.streamController.maxBufferLength}},{key:"setAudioOption",value:function(e){var t;return(null==(t=this.audioTrackController)?void 0:t.setAudioOption(e))||null}},{key:"setSubtitleOption",value:function(e){var t;return(null==(t=this.subtitleTrackController)?void 0:t.setSubtitleOption(e))||null}},{key:"allAudioTracks",get:function(){var e=this.audioTrackController;return e?e.allAudioTracks:[]}},{key:"audioTracks",get:function(){var e=this.audioTrackController;return e?e.audioTracks:[]}},{key:"audioTrack",get:function(){var e=this.audioTrackController;return e?e.audioTrack:-1},set:function(e){var t=this.audioTrackController;t&&(t.audioTrack=e)}},{key:"allSubtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}},{key:"subtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTrack:-1},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var e=this.subtitleTrackController;return!!e&&e.subtitleDisplay},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(e){this.config.lowLatencyMode=e}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency},set:function(e){this.latencyController.targetLatency=e}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}},{key:"pathways",get:function(){return this.levelController.pathways}},{key:"pathwayPriority",get:function(){return this.levelController.pathwayPriority},set:function(e){this.levelController.pathwayPriority=e}},{key:"bufferedToEnd",get:function(){var e;return!(null==(e=this.bufferController)||!e.bufferedToEnd)}},{key:"interstitialsManager",get:function(){var e;return(null==(e=this.interstitialsController)?void 0:e.interstitialsManager)||null}},{key:"getMediaDecodingInfo",value:function(e,t=this.allAudioTracks){return TP(e,NP(t),navigator.mediaCapabilities)}}],[{key:"version",get:function(){return ED}},{key:"isMSESupported",value:function(){return i_()}},{key:"isSupported",value:function(){return function(){if(!i_())return!1;var e=dT();return"function"==typeof(null==e?void 0:e.isTypeSupported)&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(t=>e.isTypeSupported(dP(t,"video")))||["mp4a.40.2","fLaC"].some(t=>e.isTypeSupported(dP(t,"audio"))))}()}},{key:"getMediaSource",value:function(){return dT()}},{key:"Events",get:function(){return UE}},{key:"MetadataSchema",get:function(){return VD}},{key:"ErrorTypes",get:function(){return BE}},{key:"ErrorDetails",get:function(){return zE}},{key:"DefaultConfig",get:function(){return e.defaultConfig?e.defaultConfig:BL},set:function(t){e.defaultConfig=t}}])}();l_.defaultConfig=void 0;var d_,h_=e=>e,c_=function(){function i(){var e;return u(this,i),(e=s(this,i,arguments)).inFocusedState=!1,e.scaleFactor=1,e.bgVideo=!1,e}return y(i,bs),m(i,[{key:"disconnectedCallback",value:function(){M(i,"disconnectedCallback",this)([]),Mo.instance&&(Mo.instance.removeVideoEvents(),Mo.instance=null)}},{key:"styles",value:function(){var e,i,n=this.component,a=n.url,r=n.imageCropping,o=n.alignment,s=n.rightMargin,u=n.spacing,l="fit"===r,d=null!==(e=null===(i=this.getRootNode().host)||void 0===i?void 0:i.tagName.toLowerCase())&&void 0!==e?e:"";this.bgVideo=d.includes("background");var h=l?"":t.unsafeCSS(` position: ${this.bgVideo?"fixed":"relative"};\n right: 0;\n top: 0;\n min-width: 100%;\n `);return t.unsafeCSS(`\n :host {\n box-sizing: border-box;\n display: flex;\n transition: all 0.3s;\n background-image: url(${a});\n background-size: ${l?"contain":"cover"};\n background-position: ${o||""} center;\n background-repeat: no-repeat;\n ${zs(this.component,this.scaleFactor)};\n margin-right: ${s||u||0}px;\n ${Ks(this.component,this.scaleFactor,!1)}\n ${this.component.hidden?"display:none;":""}\n ${h}\n }\n :host(:focus) {\n ${Ks(this.component,this.scaleFactor,!0)}\n }\n :host(:focus-visible){\n ${Zs(this.component)}\n }\n #nami-video {\n ${zs(this.component,this.scaleFactor)};\n object-fit: ${l?"contain":"cover"};\n }\n `)}},{key:"loadMediaSrc",value:function(t){var i=this.component.url;if(i&&!i.includes(e.SMART_TEXT_PATTERN)&&t.src!==i)if(!i.includes("m3u8")||t.canPlayType("application/vnd.apple.mpegurl"))t.src=i;else if(l_.isSupported()){var n=new l_;n.loadSource(i),n.attachMedia(t)}}},{key:"updated",value:function(){var e,t;Object.keys(this.component).forEach(e=>{this.component[e]=qn(this.contextProvider,this.component[e])});var i=this.component,n=i.id,a=i.title,r=i.autoplayVideo,o=i.mute,s=i.loopVideo,u=i.controlsType,l=i.fallbackImage,d=null===(e=this.shadowRoot)||void 0===e?void 0:e.getElementById("nami-video");d&&(d.autoplay=null!=r&&r,d.loop=null!=s&&s,d.muted=null!=o&&o,d.controls="none"!==u,d.poster=null!=l?l:"",d.playsInline=null!=r?r:this.bgVideo,this.loadMediaSrc(d),null===(t=Mo.instance)||void 0===t||t.removeVideoEvents(),Mo.instance=new Mo(this.contextProvider,d,a,n))}},{key:"render",value:function(){var e,i=this.component,n=i.focusedBorderColor,a=i.focusedFillColor,r=i.fillColor,o=i.screenreaderText,s=i.title;return this.ariaLabel=null!==(e=null!=o?o:s)&&void 0!==e?e:"",!n&&na(r,a)||(this.tabIndex=0),t.html(d_||(d_=h_`<video id="nami-video" preload="auto"></video>`))}}])}();Ae([ot({type:Object})],c_.prototype,"component",void 0),Ae([ot({type:Boolean})],c_.prototype,"inFocusedState",void 0),Ae([ot({type:Number})],c_.prototype,"scaleFactor",void 0),c_=Ae([Fe("nami-video")],c_);var m_,f_=e=>e,v_=function(){function e(){var t;return u(this,e),(t=s(this,e,arguments)).inFocusedState=!1,t.height=0,t.scaleFactor=1,t.isCollapsed=!0,t._handleClick=()=>{var e,i;t.isCollapsed=!t.isCollapsed,t.contextProvider.setOpenHeaderIds(t.component.id||"",t.component.sku),t.height=(null===(e=t.shadowRoot)||void 0===e||null===(e=e.getElementById("collapse"))||void 0===e?void 0:e.scrollHeight)||0,null===(i=t.shadowRoot)||void 0===i||null===(i=i.getElementById("collapse"))||void 0===i||i.classList.toggle("hidden")},t}return y(e,bs),m(e,[{key:"styles",value:function(){var e=this.component,i=this.height,n=this.scaleFactor,a=e.backgroundBlur,r="vertical"===e.direction?"margin-top":"margin-left";return t.unsafeCSS(`\n :host {\n display: ${e.hidden?"none":"flex"};\n ${a?`backdrop-filter: blur(${a}px);`:""}\n ${Rs(e,!1)};\n ${Fs(this.component)}\n ${Ks(e,n,!1)}\n cursor: pointer;\n }\n :host > *:not(:first-child) {\n ${r}: ${e.spacing?e.spacing*n:0}px;\n }\n :host(:focus){\n ${Rs(e,!0)}\n ${Ks(e,n,!0)}\n }\n :host(:focus-visible){\n ${Zs(e)}\n }\n #collapse.hidden{\n max-height: 0;\n opacity: 0;\n overflow: hidden;\n padding: 0;\n margin: 0;\n }\n #collapse {\n ${zs(e,n)}\n max-height: ${i}px;\n opacity: 1;\n transition: all linear 0.5s;\n overflow: hidden;\n }\n #collapse-btn{\n background: transparent;\n border: none;\n width: 100%;\n }\n `)}},{key:"render",value:function(){var e=this.component,i=e.components,n=e.collapseHeader,a=e.focusedBorderColor,r=e.focusedFillColor,o=e.fillColor;!a&&na(o,r)||(this.tabIndex=0);var s=i.map(e=>Iu(this.contextProvider,e,this.scaleFactor,this.inFocusedState,this.minSDKVersion));return t.html(m_||(m_=f_`
|
|
471
471
|
<button
|
|
472
472
|
id="collapse-btn"
|
|
473
473
|
aria-label="${0}"
|
|
@@ -485,18 +485,18 @@
|
|
|
485
485
|
>
|
|
486
486
|
${0}
|
|
487
487
|
</div>
|
|
488
|
-
`),this.isCollapsed?"Expand":"Collapse",!this.isCollapsed,this._handleClick,Iu(this.contextProvider,n,this.scaleFactor,this.inFocusedState,this.minSDKVersion),this.isCollapsed,this.isCollapsed?"-1":"0",s)}}])}();Ae([ot({type:Object})],
|
|
488
|
+
`),this.isCollapsed?"Expand":"Collapse",!this.isCollapsed,this._handleClick,Iu(this.contextProvider,n,this.scaleFactor,this.inFocusedState,this.minSDKVersion),this.isCollapsed,this.isCollapsed?"-1":"0",s)}}])}();Ae([ot({type:Object})],v_.prototype,"component",void 0),Ae([ot({type:Boolean})],v_.prototype,"inFocusedState",void 0),Ae([ot({type:Number})],v_.prototype,"height",void 0),Ae([ot({type:Number})],v_.prototype,"scaleFactor",void 0),Ae([ot({type:Object})],v_.prototype,"minSDKVersion",void 0),v_=Ae([Fe("nami-collapse-container")],v_);var p_,g_,y_,b_,w_,k_,S_,E_=e=>e,T_=function(){function i(){var e;return u(this,i),(e=s(this,i,arguments)).inFocusedState=!1,e.scaleFactor=1,e.timelineDots=[],e.railHeight=0,e.mouseDown=!1,e.startDragging=t=>{t.preventDefault(),e.mouseDown=!0,e.startX=t.pageX-e.offsetLeft},e.stopDragging=()=>{e.mouseDown=!1},e.move=t=>{t.preventDefault(),e.mouseDown&&(e.scrollLeft=e.scrollLeft-(t.pageX-e.offsetLeft-e.startX))},e._rowMouseDown=!1,e._rowStartX=0,e._rowStartDragging=t=>{t.preventDefault(),e._rowMouseDown=!0,e._rowStartX=t.pageX},e._rowStopDragging=()=>{e._rowMouseDown=!1},e._rowMove=t=>{(t.preventDefault(),e._rowMouseDown)&&(t.currentTarget.scrollLeft-=t.pageX-e._rowStartX,e._rowStartX=t.pageX)},e}return y(i,bs),m(i,[{key:"connectedCallback",value:function(){M(i,"connectedCallback",this)([]),this.addEventListener("mousemove",this.move,!1),this.addEventListener("mousedown",this.startDragging,!1),this.addEventListener("mouseup",this.stopDragging,!1),this.addEventListener("mouseleave",this.stopDragging,!1)}},{key:"disconnectedCallback",value:function(){var e;M(i,"disconnectedCallback",this)([]),this.removeEventListener("mousemove",this.move,!1),this.removeEventListener("mousedown",this.startDragging,!1),this.removeEventListener("mouseup",this.stopDragging,!1),this.removeEventListener("mouseleave",this.stopDragging,!1),null===(e=this.timelineResizeObserver)||void 0===e||e.disconnect()}},{key:"isGroupedHorizontal",value:function(){return"horizontal"===this.component.direction&&!!this.component.groupBy&&!!this.component.groupHeaderTemplate}},{key:"isTimelineActive",value:function(){return!!this.component.timeline&&aa(this.component.timeline).width>0&&"vertical"===this.component.direction&&!!this.component.groupBy&&!!this.component.groupHeaderTemplate&&"television"!==e.getDeviceFormFactor()}},{key:"styles",value:function(){var e="vertical"===this.component.direction,i=this.isGroupedHorizontal(),n=e?"margin-top":"margin-left",a=this.component.spacing?this.component.spacing*this.scaleFactor:0;if(this.isTimelineActive()){var r=aa(this.component.timeline),o=(r.width+r.railSpacing)*this.scaleFactor+xs(1,this.component.leftPadding);return t.unsafeCSS(`\n :host {\n display: ${this.component.hidden?"none":"grid"};\n position: relative;\n grid-auto-flow: row;\n grid-template-columns: minmax(0, 1fr);\n grid-gap: ${a}px;\n align-items: center;\n justify-items: stretch;\n overflow: visible;\n ${Rs(this.component,!1)}\n ${Xs(this.component,!1)}\n align-self: baseline;\n box-sizing: border-box;\n padding-left: ${o}px;\n }\n :host(:focus) {\n ${Rs(this.component,!0)}\n ${Xs(this.component,!0)}\n padding-left: ${o}px;\n }\n :host(:focus-visible) { ${Zs(this.component)} }\n .nami-group-header { width: 100%; }\n .nami-timeline-rail {\n position: absolute;\n top: 0; bottom: 0; left: 0;\n width: ${r.width*this.scaleFactor}px;\n pointer-events: none;\n }\n .nami-timeline-line, .nami-timeline-dot {\n position: absolute;\n box-sizing: border-box;\n }\n `)}return i?t.unsafeCSS(`\n :host {\n display: ${this.component.hidden?"none":"flex"};\n flex-direction: column;\n overflow: visible;\n ${Rs(this.component,!1)}\n ${Xs(this.component,!1)}\n align-self: baseline;\n }\n :host(:focus) {\n ${Rs(this.component,!0)}\n ${Xs(this.component,!0)}\n }\n :host(:focus-visible) {\n ${Zs(this.component)}\n }\n .nami-group-header {\n width: 100%;\n }\n .nami-group-items-row {\n display: flex;\n flex-direction: row;\n flex-wrap: nowrap;\n align-items: flex-start;\n overflow-x: auto;\n width: 100%;\n cursor: -webkit-grab;\n cursor: grab;\n gap: ${a}px;\n }\n .nami-group-items-row > * {\n flex: 0 0 auto;\n }\n `):t.unsafeCSS(`\n :host {\n display: ${this.component.hidden?"none":"flex"};\n flex-direction: ${e?"column":"row"};\n flex-wrap: ${e?"nowrap":"wrap"};\n overflow: auto;\n align-items: center;\n justify-content: center;\n ${Rs(this.component,!1)}\n ${Xs(this.component,!1)}\n align-self: baseline;\n cursor: -webkit-grab;\n cursor: grab;\n }\n :host(:focus){\n ${Rs(this.component,!0)}\n ${Xs(this.component,!0)}\n }\n :host(:focus-visible){\n ${Zs(this.component)}\n }\n @supports not (display: grid) {\n :host > *:not(:first-child) {\n ${n}: ${a}px;\n }\n }\n @supports (display: grid) {\n :host {\n display: ${this.component.hidden?"none":"grid"};\n grid-row-gap: ${a}px;\n grid-column-gap: ${a}px;\n grid-gap: ${a}px;\n grid-auto-flow: ${e?"row":"column"};\n ${e?"grid-template-columns: minmax(0, 1fr);":""}\n align-items: center;\n justify-items: center;\n place-items: center;\n }\n :host > * {\n margin: 0;\n }\n }\n `)}},{key:"render",value:function(){var e=this.component,i=e.focusedBorderColor,n=e.focusedFillColor,a=e.fillColor;!i&&na(a,n)||(this.tabIndex=0);var r,o,s=e=>Iu(this.contextProvider,e,this.scaleFactor,this.inFocusedState,this.minSDKVersion);if(this.isTimelineActive()){var u=aa(this.component.timeline),l=this.scaleFactor,d=Kn(this.contextProvider,this.component),h=new Map(d.map(e=>[e.key,ra(this.contextProvider,this.component.timeline,e.key)])),c=function(e){var t=e.lineTopOffset,i=e.railHeight-e.lineBottomOffset;if(i<=t)return[];for(var n,a=e.dots.map(t=>[t.centerY-t.size/2-e.dotLineSpacing,t.centerY+t.size/2+e.dotLineSpacing]).sort((e,t)=>e[0]-t[0]),r=[],o=t,s=f(a);!(n=s()).done;){var u=n.value,l=u[0],d=u[1];l>o&&r.push({top:o,height:l-o}),o=Math.max(o,d)}return i>o&&r.push({top:o,height:i-o}),r.filter(e=>e.height>0)}({railHeight:this.railHeight,lineTopOffset:u.lineTopOffset*l,lineBottomOffset:u.lineBottomOffset*l,dotLineSpacing:u.dotLineSpacing*l,dots:this.timelineDots.map(e=>{var t,i;return{centerY:e.centerY,size:(null!==(t=null===(i=h.get(e.key))||void 0===i?void 0:i.dotSize)&&void 0!==t?t:u.dotSize)*l}})}),m=u.width*l/2;return t.html(p_||(p_=E_`
|
|
489
489
|
<div class="nami-timeline-rail">
|
|
490
490
|
${0}
|
|
491
491
|
${0}
|
|
492
492
|
</div>
|
|
493
493
|
${0}
|
|
494
|
-
`),c.map(e=>t.html(
|
|
494
|
+
`),c.map(e=>t.html(g_||(g_=E_`
|
|
495
495
|
<div class="nami-timeline-line" style="left:${0}px;top:${0}px;width:${0}px;height:${0}px;background:${0};border-radius:${0}px;"></div>
|
|
496
|
-
`),m-u.lineWidth*l/2,e.top,u.lineWidth*l,e.height,u.lineColor,u.lineCornerRadius*l)),this.timelineDots.map(e=>{var i=h.get(e.key);if(!i)return null;var n=i.dotSize*l;return t.html(
|
|
496
|
+
`),m-u.lineWidth*l/2,e.top,u.lineWidth*l,e.height,u.lineColor,u.lineCornerRadius*l)),this.timelineDots.map(e=>{var i=h.get(e.key);if(!i)return null;var n=i.dotSize*l;return t.html(y_||(y_=E_`<div class="nami-timeline-dot" style="left:${0}px;top:${0}px;width:${0}px;height:${0}px;background:${0};border-radius:${0}px;${0}"></div>`),m-n/2,e.centerY-n/2,n,n,i.dotColor,i.dotCornerRadius*l,i.dotBorderWidth>0?`border:${i.dotBorderWidth*l}px solid ${i.dotBorderColor};`:"")}),d.map(e=>t.html(b_||(b_=E_`
|
|
497
497
|
${0}
|
|
498
498
|
${0}
|
|
499
|
-
`),e.header?t.html(
|
|
499
|
+
`),e.header?t.html(w_||(w_=E_`<div class="nami-group-header" data-group-key=${0}>${0}</div>`),e.key,e.header.map(s)):null,e.items.map(e=>e.map(s)))))}return this.isGroupedHorizontal()?Kn(this.contextProvider,this.component).map(e=>t.html(k_||(k_=E_`
|
|
500
500
|
${0}
|
|
501
501
|
<div
|
|
502
502
|
class="nami-group-items-row"
|
|
@@ -507,10 +507,10 @@
|
|
|
507
507
|
>
|
|
508
508
|
${0}
|
|
509
509
|
</div>
|
|
510
|
-
`),e.header?t.html(
|
|
510
|
+
`),e.header?t.html(S_||(S_=E_`<div class="nami-group-header">${0}</div>`),e.header.map(s)):null,this._rowStartDragging,this._rowMove,this._rowStopDragging,this._rowStopDragging,e.items.map(e=>e.map(s)))):(r=this.contextProvider,o=this.component,Kn(r,o).flatMap(e=>e.header?[e.header,...e.items]:e.items)).map(e=>e.map(e=>Iu(this.contextProvider,e,this.scaleFactor,this.inFocusedState,this.minSDKVersion)))}},{key:"updated",value:function(){this.isTimelineActive()&&this.measureTimeline()}},{key:"measureTimeline",value:function(){this.renderRoot.querySelector(".nami-timeline-rail")&&("undefined"==typeof ResizeObserver||this.timelineResizeObserver||(this.timelineResizeObserver=new ResizeObserver(()=>this.readTimelineGeometry()),this.timelineResizeObserver.observe(this),this.renderRoot.querySelectorAll(".nami-group-header").forEach(e=>{this.timelineResizeObserver.observe(e)})),this.readTimelineGeometry())}},{key:"readTimelineGeometry",value:function(){var e=this.renderRoot.querySelector(".nami-timeline-rail");if(e){var t=e.getBoundingClientRect(),i=Array.from(this.renderRoot.querySelectorAll(".nami-group-header")).map(e=>{var i,n=e.getBoundingClientRect();return{key:null!==(i=e.dataset.groupKey)&&void 0!==i?i:"",centerY:n.top+n.height/2-t.top}}),n=t.height,a=Math.abs(n-this.railHeight)>.5||i.length!==this.timelineDots.length||i.some((e,t)=>{var i;return e.key!==(null===(i=this.timelineDots[t])||void 0===i?void 0:i.key)||Math.abs(e.centerY-this.timelineDots[t].centerY)>.5});a&&(this.railHeight=n,this.timelineDots=i)}}}])}();Ae([ot({type:Object})],T_.prototype,"component",void 0),Ae([ot({type:Boolean})],T_.prototype,"inFocusedState",void 0),Ae([ot({type:Number})],T_.prototype,"scaleFactor",void 0),Ae([ot({type:Object})],T_.prototype,"minSDKVersion",void 0),Ae([st()],T_.prototype,"timelineDots",void 0),Ae([st()],T_.prototype,"railHeight",void 0),T_=Ae([Fe("nami-responsive-grid")],T_);var P_,M_,A_=e=>e,D_=function(){function e(){var t;return u(this,e),(t=s(this,e,arguments)).inFocusedState=!1,t.scaleFactor=1,t}return y(e,bs),m(e,[{key:"styles",value:function(){var e,i,n,a,r=Math.max(1,null!==(e=this.component.columns)&&void 0!==e?e:2),o=(null!==(i=this.component.columnSpacing)&&void 0!==i?i:0)*this.scaleFactor,s=(null!==(n=this.component.rowSpacing)&&void 0!==n?n:0)*this.scaleFactor,u=null!==(a=this.component.itemAlignment)&&void 0!==a?a:"start";return t.unsafeCSS(`\n :host {\n display: ${this.component.hidden?"none":"grid"};\n grid-template-columns: repeat(${r}, 1fr);\n column-gap: ${o}px;\n row-gap: ${s}px;\n justify-items: ${u};\n ${Rs(this.component,!1)}\n ${Xs(this.component,!1)}\n }\n .nami-group-header {\n grid-column: 1 / -1;\n justify-self: stretch;\n }\n :host(:focus) {\n ${Rs(this.component,!0)}\n ${Xs(this.component,!0)}\n }\n :host(:focus-visible) {\n ${Zs(this.component)}\n }\n `)}},{key:"render",value:function(){var e=this.component,i=e.focusedBorderColor,n=e.focusedFillColor,a=e.fillColor;!i&&na(a,n)||(this.tabIndex=0);var r=e=>Iu(this.contextProvider,e,this.scaleFactor,this.inFocusedState,this.minSDKVersion);return Kn(this.contextProvider,this.component).map(e=>t.html(P_||(P_=A_`
|
|
511
511
|
${0}
|
|
512
512
|
${0}
|
|
513
|
-
`),e.header?t.html(P_||(P_=M_`<div class="nami-group-header">${0}</div>`),e.header.map(r)):null,e.items.map(e=>e.map(r))))}}])}();function D_(e){return null!==e&&"object"==typeof e&&"constructor"in e&&e.constructor===Object}function x_(e={},t={}){var i=["__proto__","constructor","prototype"];Object.keys(t).filter(e=>i.indexOf(e)<0).forEach(i=>{void 0===e[i]?e[i]=t[i]:D_(t[i])&&D_(e[i])&&Object.keys(t[i]).length>0&&x_(e[i],t[i])})}Ae([ot({type:Object})],A_.prototype,"component",void 0),Ae([ot({type:Boolean})],A_.prototype,"inFocusedState",void 0),Ae([ot({type:Number})],A_.prototype,"scaleFactor",void 0),Ae([ot({type:Object})],A_.prototype,"minSDKVersion",void 0),A_=Ae([Fe("nami-repeating-grid")],A_);var C_={body:{},addEventListener(){},removeEventListener(){},activeElement:{blur(){},nodeName:""},querySelector:()=>null,querySelectorAll:()=>[],getElementById:()=>null,createEvent:()=>({initEvent(){}}),createElement:()=>({children:[],childNodes:[],style:{},setAttribute(){},getElementsByTagName:()=>[]}),createElementNS:()=>({}),importNode:()=>null,location:{hash:"",host:"",hostname:"",href:"",origin:"",pathname:"",protocol:"",search:""}};function I_(){var e="undefined"!=typeof document?document:{};return x_(e,C_),e}var L_,__,R_,F_={document:C_,navigator:{userAgent:""},location:{hash:"",host:"",hostname:"",href:"",origin:"",pathname:"",protocol:"",search:""},history:{replaceState(){},pushState(){},go(){},back(){}},CustomEvent:function(){return this},addEventListener(){},removeEventListener(){},getComputedStyle:()=>({getPropertyValue:()=>""}),Image(){},Date(){},screen:{},setTimeout(){},clearTimeout(){},matchMedia:()=>({}),requestAnimationFrame:e=>"undefined"==typeof setTimeout?(e(),null):setTimeout(e,0),cancelAnimationFrame(e){"undefined"!=typeof setTimeout&&clearTimeout(e)}};function O_(){var e="undefined"!=typeof window?window:{};return x_(e,F_),e}function W_(e,t=0){return setTimeout(e,t)}function $_(){return Date.now()}function N_(e,t="x"){var i,n,a,r=O_(),o=function(e){var t,i=O_();return i.getComputedStyle&&(t=i.getComputedStyle(e,null)),!t&&e.currentStyle&&(t=e.currentStyle),t||(t=e.style),t}(e);return r.WebKitCSSMatrix?((n=o.transform||o.webkitTransform).split(",").length>6&&(n=n.split(", ").map(e=>e.replace(",",".")).join(", ")),a=new r.WebKitCSSMatrix("none"===n?"":n)):i=(a=o.MozTransform||o.OTransform||o.MsTransform||o.msTransform||o.transform||o.getPropertyValue("transform").replace("translate(","matrix(1, 0, 0, 1,")).toString().split(","),"x"===t&&(n=r.WebKitCSSMatrix?a.m41:16===i.length?parseFloat(i[12]):parseFloat(i[4])),"y"===t&&(n=r.WebKitCSSMatrix?a.m42:16===i.length?parseFloat(i[13]):parseFloat(i[5])),n||0}function j_(e){return"object"==typeof e&&null!==e&&e.constructor&&"Object"===Object.prototype.toString.call(e).slice(8,-1)}function B_(e){return"undefined"!=typeof window&&void 0!==window.HTMLElement?e instanceof HTMLElement:e&&(1===e.nodeType||11===e.nodeType)}function z_(...e){for(var t=Object(e[0]),i=1;i<e.length;i+=1){var n=e[i];if(null!=n&&!B_(n))for(var a=Object.keys(Object(n)).filter(e=>"__proto__"!==e&&"constructor"!==e&&"prototype"!==e),r=0,o=a.length;r<o;r+=1){var s=a[r],u=Object.getOwnPropertyDescriptor(n,s);void 0!==u&&u.enumerable&&(j_(t[s])&&j_(n[s])?n[s].__swiper__?t[s]=n[s]:z_(t[s],n[s]):!j_(t[s])&&j_(n[s])?(t[s]={},n[s].__swiper__?t[s]=n[s]:z_(t[s],n[s])):t[s]=n[s])}}return t}function U_(e,t,i){e.style.setProperty(t,i)}function H_({swiper:e,targetPosition:t,side:i}){var n,a=O_(),r=-e.translate,o=null,s=e.params.speed;e.wrapperEl.style.scrollSnapType="none",a.cancelAnimationFrame(e.cssModeFrameID);var u=t>r?"next":"prev",l=(e,t)=>"next"===u&&e>=t||"prev"===u&&e<=t,d=()=>{n=(new Date).getTime(),null===o&&(o=n);var u=Math.max(Math.min((n-o)/s,1),0),h=.5-Math.cos(u*Math.PI)/2,c=r+h*(t-r);if(l(c,t)&&(c=t),e.wrapperEl.scrollTo({[i]:c}),l(c,t))return e.wrapperEl.style.overflow="hidden",e.wrapperEl.style.scrollSnapType="",setTimeout(()=>{e.wrapperEl.style.overflow="",e.wrapperEl.scrollTo({[i]:c})}),void a.cancelAnimationFrame(e.cssModeFrameID);e.cssModeFrameID=a.requestAnimationFrame(d)};d()}function G_(e){return e.querySelector(".swiper-slide-transform")||e.shadowRoot&&e.shadowRoot.querySelector(".swiper-slide-transform")||e}function V_(e,t=""){var i=O_(),n=[...e.children];return i.HTMLSlotElement&&e instanceof HTMLSlotElement&&n.push(...e.assignedElements()),t?n.filter(e=>e.matches(t)):n}function K_(e){try{return void console.warn(e)}catch(e){}}function X_(e,t=[]){var i=document.createElement(e);return i.classList.add(...Array.isArray(t)?t:function(e=""){return e.trim().split(" ").filter(e=>!!e.trim())}(t)),i}function Y_(e,t){return O_().getComputedStyle(e,null).getPropertyValue(t)}function q_(e){var t,i=e;if(i){for(t=0;null!==(i=i.previousSibling);)1===i.nodeType&&(t+=1);return t}}function J_(e,t){for(var i=[],n=e.parentElement;n;)t?n.matches(t)&&i.push(n):i.push(n),n=n.parentElement;return i}function Q_(e,t,i){var n=O_();return e["width"===t?"offsetWidth":"offsetHeight"]+parseFloat(n.getComputedStyle(e,null).getPropertyValue("width"===t?"margin-right":"margin-top"))+parseFloat(n.getComputedStyle(e,null).getPropertyValue("width"===t?"margin-left":"margin-bottom"))}function Z_(e){return(Array.isArray(e)?e:[e]).filter(e=>!!e)}function eR(e,t=""){"undefined"!=typeof trustedTypes?e.innerHTML=trustedTypes.createPolicy("html",{createHTML:e=>e}).createHTML(t):e.innerHTML=t}function tR(){return L_||(L_=function(){var e=O_(),t=I_();return{smoothScroll:t.documentElement&&t.documentElement.style&&"scrollBehavior"in t.documentElement.style,touch:!!("ontouchstart"in e||e.DocumentTouch&&t instanceof e.DocumentTouch)}}()),L_}function iR(e={}){return __||(__=function({userAgent:e}={}){var t=tR(),i=O_(),n=i.navigator.platform,a=e||i.navigator.userAgent,r={ios:!1,android:!1},o=i.screen.width,s=i.screen.height,u=a.match(/(Android);?[\s\/]+([\d.]+)?/),l=a.match(/(iPad)(?!\1).*OS\s([\d_]+)/),d=a.match(/(iPod)(.*OS\s([\d_]+))?/),h=!l&&a.match(/(iPhone\sOS|iOS)\s([\d_]+)/),c="Win32"===n,m="MacIntel"===n;return!l&&m&&t.touch&&["1024x1366","1366x1024","834x1194","1194x834","834x1112","1112x834","768x1024","1024x768","820x1180","1180x820","810x1080","1080x810"].indexOf(`${o}x${s}`)>=0&&((l=a.match(/(Version)\/([\d.]+)/))||(l=[0,1,"13_0_0"]),m=!1),u&&!c&&(r.os="android",r.android=!0),(l||h||d)&&(r.os="ios",r.ios=!0),r}(e)),__}function nR(){return R_||(R_=function(){var e=O_(),t=iR(),i=!1;function n(){var t=e.navigator.userAgent.toLowerCase();return t.indexOf("safari")>=0&&t.indexOf("chrome")<0&&t.indexOf("android")<0}if(n()){var a=String(e.navigator.userAgent);if(a.includes("Version/")){var r=a.split("Version/")[1].split(" ")[0].split(".").map(e=>Number(e)),o=r[0],s=r[1];i=o<16||16===o&&s<2}}var u=/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(e.navigator.userAgent),l=n();return{isSafari:i||l,needPerspectiveFix:i,need3dFix:l||u&&t.ios,isWebView:u}}()),R_}var aR={on(e,t,i){var n=this;if(!n.eventsListeners||n.destroyed)return n;if("function"!=typeof t)return n;var a=i?"unshift":"push";return e.split(" ").forEach(e=>{n.eventsListeners[e]||(n.eventsListeners[e]=[]),n.eventsListeners[e][a](t)}),n},once(e,t,i){var n=this;if(!n.eventsListeners||n.destroyed)return n;if("function"!=typeof t)return n;function a(...i){n.off(e,a),a.__emitterProxy&&delete a.__emitterProxy,t.apply(n,i)}return a.__emitterProxy=t,n.on(e,a,i)},onAny(e,t){var i=this;if(!i.eventsListeners||i.destroyed)return i;if("function"!=typeof e)return i;var n=t?"unshift":"push";return i.eventsAnyListeners.indexOf(e)<0&&i.eventsAnyListeners[n](e),i},offAny(e){var t=this;if(!t.eventsListeners||t.destroyed)return t;if(!t.eventsAnyListeners)return t;var i=t.eventsAnyListeners.indexOf(e);return i>=0&&t.eventsAnyListeners.splice(i,1),t},off(e,t){var i=this;return!i.eventsListeners||i.destroyed?i:i.eventsListeners?(e.split(" ").forEach(e=>{void 0===t?i.eventsListeners[e]=[]:i.eventsListeners[e]&&i.eventsListeners[e].forEach((n,a)=>{(n===t||n.__emitterProxy&&n.__emitterProxy===t)&&i.eventsListeners[e].splice(a,1)})}),i):i},emit(...e){var t,i,n,a=this;return!a.eventsListeners||a.destroyed?a:a.eventsListeners?("string"==typeof e[0]||Array.isArray(e[0])?(t=e[0],i=e.slice(1,e.length),n=a):(t=e[0].events,i=e[0].data,n=e[0].context||a),i.unshift(n),(Array.isArray(t)?t:t.split(" ")).forEach(e=>{a.eventsAnyListeners&&a.eventsAnyListeners.length&&a.eventsAnyListeners.forEach(t=>{t.apply(n,[e,...i])}),a.eventsListeners&&a.eventsListeners[e]&&a.eventsListeners[e].forEach(e=>{e.apply(n,i)})}),a):a}};var rR=(e,t,i)=>{t&&!e.classList.contains(i)?e.classList.add(i):!t&&e.classList.contains(i)&&e.classList.remove(i)};var oR=(e,t,i)=>{t&&!e.classList.contains(i)?e.classList.add(i):!t&&e.classList.contains(i)&&e.classList.remove(i)};var sR=(e,t)=>{if(e&&!e.destroyed&&e.params){var i=t.closest(e.isElement?"swiper-slide":`.${e.params.slideClass}`);if(i){var n=i.querySelector(`.${e.params.lazyPreloaderClass}`);!n&&e.isElement&&(i.shadowRoot?n=i.shadowRoot.querySelector(`.${e.params.lazyPreloaderClass}`):requestAnimationFrame(()=>{i.shadowRoot&&(n=i.shadowRoot.querySelector(`.${e.params.lazyPreloaderClass}`))&&!n.lazyPreloaderManaged&&n.remove()})),n&&!n.lazyPreloaderManaged&&n.remove()}}},uR=(e,t)=>{if(e.slides[t]){var i=e.slides[t].querySelector('[loading="lazy"]');i&&i.removeAttribute("loading")}},lR=e=>{if(e&&!e.destroyed&&e.params){var t=e.params.lazyPreloadPrevNext,i=e.slides.length;if(i&&t&&!(t<0)){t=Math.min(t,i);var n="auto"===e.params.slidesPerView?e.slidesPerViewDynamic():Math.ceil(e.params.slidesPerView),a=e.activeIndex;if(e.params.grid&&e.params.grid.rows>1){var r=a,o=[r-t];return o.push(...Array.from({length:t}).map((e,t)=>r+n+t)),void e.slides.forEach((t,i)=>{o.includes(t.column)&&uR(e,i)})}var s=a+n-1;if(e.params.rewind||e.params.loop)for(var u=a-t;u<=s+t;u+=1){var l=(u%i+i)%i;(l<a||l>s)&&uR(e,l)}else for(var d=Math.max(a-t,0);d<=Math.min(s+t,i-1);d+=1)d!==a&&(d>s||d<a)&&uR(e,d)}}};var dR={updateSize:function(){var e,t,i=this,n=i.el;e=void 0!==i.params.width&&null!==i.params.width?i.params.width:n.clientWidth,t=void 0!==i.params.height&&null!==i.params.height?i.params.height:n.clientHeight,0===e&&i.isHorizontal()||0===t&&i.isVertical()||(e=e-parseInt(Y_(n,"padding-left")||0,10)-parseInt(Y_(n,"padding-right")||0,10),t=t-parseInt(Y_(n,"padding-top")||0,10)-parseInt(Y_(n,"padding-bottom")||0,10),Number.isNaN(e)&&(e=0),Number.isNaN(t)&&(t=0),Object.assign(i,{width:e,height:t,size:i.isHorizontal()?e:t}))},updateSlides:function(){var e=this;function t(t,i){return parseFloat(t.getPropertyValue(e.getDirectionLabel(i))||0)}var i=e.params,n=e.wrapperEl,a=e.slidesEl,r=e.rtlTranslate,o=e.wrongRTL,s=e.virtual&&i.virtual.enabled,u=s?e.virtual.slides.length:e.slides.length,l=V_(a,`.${e.params.slideClass}, swiper-slide`),d=s?e.virtual.slides.length:l.length,h=[],c=[],m=[],f=i.slidesOffsetBefore;"function"==typeof f&&(f=i.slidesOffsetBefore.call(e));var v=i.slidesOffsetAfter;"function"==typeof v&&(v=i.slidesOffsetAfter.call(e));var p=e.snapGrid.length,g=e.slidesGrid.length,y=e.size-f-v,b=i.spaceBetween,w=-f,k=0,S=0;if(void 0!==y){"string"==typeof b&&b.indexOf("%")>=0?b=parseFloat(b.replace("%",""))/100*y:"string"==typeof b&&(b=parseFloat(b)),e.virtualSize=-b-f-v,l.forEach(e=>{r?e.style.marginLeft="":e.style.marginRight="",e.style.marginBottom="",e.style.marginTop=""}),i.centeredSlides&&i.cssMode&&(U_(n,"--swiper-centered-offset-before",""),U_(n,"--swiper-centered-offset-after","")),i.cssMode&&(U_(n,"--swiper-slides-offset-before",`${f}px`),U_(n,"--swiper-slides-offset-after",`${v}px`));var E,T=i.grid&&i.grid.rows>1&&e.grid;T?e.grid.initSlides(l):e.grid&&e.grid.unsetSlides();for(var P="auto"===i.slidesPerView&&i.breakpoints&&Object.keys(i.breakpoints).filter(e=>void 0!==i.breakpoints[e].slidesPerView).length>0,M=0;M<d;M+=1){E=0;var A=l[M];if(!A||(T&&e.grid.updateSlide(M,A,l),"none"!==Y_(A,"display"))){if(s&&"auto"===i.slidesPerView)i.virtual.slidesPerViewAutoSlideSize&&(E=i.virtual.slidesPerViewAutoSlideSize),E&&A&&(i.roundLengths&&(E=Math.floor(E)),A.style[e.getDirectionLabel("width")]=`${E}px`);else if("auto"===i.slidesPerView){P&&(A.style[e.getDirectionLabel("width")]="");var D=getComputedStyle(A),x=A.style.transform,C=A.style.webkitTransform;if(x&&(A.style.transform="none"),C&&(A.style.webkitTransform="none"),i.roundLengths)E=e.isHorizontal()?Q_(A,"width"):Q_(A,"height");else{var I=t(D,"width"),L=t(D,"padding-left"),_=t(D,"padding-right"),R=t(D,"margin-left"),F=t(D,"margin-right"),O=D.getPropertyValue("box-sizing");if(O&&"border-box"===O)E=I+R+F;else{var W=A.clientWidth;E=I+L+_+R+F+(A.offsetWidth-W)}}x&&(A.style.transform=x),C&&(A.style.webkitTransform=C),i.roundLengths&&(E=Math.floor(E))}else E=(y-(i.slidesPerView-1)*b)/i.slidesPerView,i.roundLengths&&(E=Math.floor(E)),A&&(A.style[e.getDirectionLabel("width")]=`${E}px`);A&&(A.swiperSlideSize=E),m.push(E),i.centeredSlides?(w=w+E/2+k/2+b,0===k&&0!==M&&(w=w-y/2-b),0===M&&(w=w-y/2-b),Math.abs(w)<.001&&(w=0),i.roundLengths&&(w=Math.floor(w)),S%i.slidesPerGroup===0&&h.push(w),c.push(w)):(i.roundLengths&&(w=Math.floor(w)),(S-Math.min(e.params.slidesPerGroupSkip,S))%e.params.slidesPerGroup===0&&h.push(w),c.push(w),w=w+E+b),e.virtualSize+=E+b,k=E,S+=1}}if(e.virtualSize=Math.max(e.virtualSize,y)+v,r&&o&&("slide"===i.effect||"coverflow"===i.effect)&&(n.style.width=`${e.virtualSize+b}px`),i.setWrapperSize&&(n.style[e.getDirectionLabel("width")]=`${e.virtualSize+b}px`),T&&e.grid.updateWrapperSize(E,h),!i.centeredSlides){var $="auto"!==i.slidesPerView&&i.slidesPerView%1!=0,N=i.snapToSlideEdge&&!i.loop&&("auto"===i.slidesPerView||$),j=h.length;if(N){var B;if("auto"===i.slidesPerView){B=1;for(var z=0,U=m.length-1;U>=0&&(z+=m[U]+(U<m.length-1?b:0))<=y;U-=1)B=m.length-U}else B=Math.floor(i.slidesPerView);j=Math.max(d-B,0)}for(var H=[],G=0;G<h.length;G+=1){var V=h[G];i.roundLengths&&(V=Math.floor(V)),N?G<=j&&H.push(V):h[G]<=e.virtualSize-y&&H.push(V)}h=H,Math.floor(e.virtualSize-y)-Math.floor(h[h.length-1])>1&&(N||h.push(e.virtualSize-y))}if(s&&i.loop){var K=m[0]+b;if(i.slidesPerGroup>1)for(var X=Math.ceil((e.virtual.slidesBefore+e.virtual.slidesAfter)/i.slidesPerGroup),Y=K*i.slidesPerGroup,q=0;q<X;q+=1)h.push(h[h.length-1]+Y);for(var J=0;J<e.virtual.slidesBefore+e.virtual.slidesAfter;J+=1)1===i.slidesPerGroup&&h.push(h[h.length-1]+K),c.push(c[c.length-1]+K),e.virtualSize+=K}if(0===h.length&&(h=[0]),0!==b){var Q=e.isHorizontal()&&r?"marginLeft":e.getDirectionLabel("marginRight");l.filter((e,t)=>!(i.cssMode&&!i.loop)||t!==l.length-1).forEach(e=>{e.style[Q]=`${b}px`})}if(i.centeredSlides&&i.centeredSlidesBounds){var Z=0;m.forEach(e=>{Z+=e+(b||0)});var ee=(Z-=b)>y?Z-y:0;h=h.map(e=>e<=0?-f:e>ee?ee+v:e)}if(i.centerInsufficientSlides){var te=0;if(m.forEach(e=>{te+=e+(b||0)}),(te-=b)<y){var ie=(y-te)/2;h.forEach((e,t)=>{h[t]=e-ie}),c.forEach((e,t)=>{c[t]=e+ie})}}if(Object.assign(e,{slides:l,snapGrid:h,slidesGrid:c,slidesSizesGrid:m}),i.centeredSlides&&i.cssMode&&!i.centeredSlidesBounds){U_(n,"--swiper-centered-offset-before",-h[0]+"px"),U_(n,"--swiper-centered-offset-after",e.size/2-m[m.length-1]/2+"px");var ne=-e.snapGrid[0],ae=-e.slidesGrid[0];e.snapGrid=e.snapGrid.map(e=>e+ne),e.slidesGrid=e.slidesGrid.map(e=>e+ae)}if(d!==u&&e.emit("slidesLengthChange"),h.length!==p&&(e.params.watchOverflow&&e.checkOverflow(),e.emit("snapGridLengthChange")),c.length!==g&&e.emit("slidesGridLengthChange"),i.watchSlidesProgress&&e.updateSlidesOffset(),e.emit("slidesUpdated"),!(s||i.cssMode||"slide"!==i.effect&&"fade"!==i.effect)){var re=`${i.containerModifierClass}backface-hidden`,oe=e.el.classList.contains(re);d<=i.maxBackfaceHiddenSlides?oe||e.el.classList.add(re):oe&&e.el.classList.remove(re)}}},updateAutoHeight:function(e){var t,i=this,n=[],a=i.virtual&&i.params.virtual.enabled,r=0;"number"==typeof e?i.setTransition(e):!0===e&&i.setTransition(i.params.speed);var o=e=>a?i.slides[i.getSlideIndexByData(e)]:i.slides[e];if("auto"!==i.params.slidesPerView&&i.params.slidesPerView>1)if(i.params.centeredSlides)(i.visibleSlides||[]).forEach(e=>{n.push(e)});else for(t=0;t<Math.ceil(i.params.slidesPerView);t+=1){var s=i.activeIndex+t;if(s>i.slides.length&&!a)break;n.push(o(s))}else n.push(o(i.activeIndex));for(t=0;t<n.length;t+=1)if(void 0!==n[t]){var u=n[t].offsetHeight;r=u>r?u:r}(r||0===r)&&(i.wrapperEl.style.height=`${r}px`)},updateSlidesOffset:function(){for(var e=this,t=e.slides,i=e.isElement?e.isHorizontal()?e.wrapperEl.offsetLeft:e.wrapperEl.offsetTop:0,n=0;n<t.length;n+=1)t[n].swiperSlideOffset=(e.isHorizontal()?t[n].offsetLeft:t[n].offsetTop)-i-e.cssOverflowAdjustment()},updateSlidesProgress:function(e=this&&this.translate||0){var t=this,i=t.params,n=t.slides,a=t.rtlTranslate,r=t.snapGrid;if(0!==n.length){void 0===n[0].swiperSlideOffset&&t.updateSlidesOffset();var o=-e;a&&(o=e),t.visibleSlidesIndexes=[],t.visibleSlides=[];var s=i.spaceBetween;"string"==typeof s&&s.indexOf("%")>=0?s=parseFloat(s.replace("%",""))/100*t.size:"string"==typeof s&&(s=parseFloat(s));for(var u=0;u<n.length;u+=1){var l=n[u],d=l.swiperSlideOffset;i.cssMode&&i.centeredSlides&&(d-=n[0].swiperSlideOffset);var h=(o+(i.centeredSlides?t.minTranslate():0)-d)/(l.swiperSlideSize+s),c=(o-r[0]+(i.centeredSlides?t.minTranslate():0)-d)/(l.swiperSlideSize+s),m=-(o-d),f=m+t.slidesSizesGrid[u],v=m>=0&&m<=t.size-t.slidesSizesGrid[u],p=m>=0&&m<t.size-1||f>1&&f<=t.size||m<=0&&f>=t.size;p&&(t.visibleSlides.push(l),t.visibleSlidesIndexes.push(u)),rR(l,p,i.slideVisibleClass),rR(l,v,i.slideFullyVisibleClass),l.progress=a?-h:h,l.originalProgress=a?-c:c}}},updateProgress:function(e){var t=this;if(void 0===e){var i=t.rtlTranslate?-1:1;e=t&&t.translate&&t.translate*i||0}var n=t.params,a=t.maxTranslate()-t.minTranslate(),r=t.progress,o=t.isBeginning,s=t.isEnd,u=t.progressLoop,l=o,d=s;if(0===a)r=0,o=!0,s=!0;else{r=(e-t.minTranslate())/a;var h=Math.abs(e-t.minTranslate())<1,c=Math.abs(e-t.maxTranslate())<1;o=h||r<=0,s=c||r>=1,h&&(r=0),c&&(r=1)}if(n.loop){var m=t.getSlideIndexByData(0),f=t.getSlideIndexByData(t.slides.length-1),v=t.slidesGrid[m],p=t.slidesGrid[f],g=t.slidesGrid[t.slidesGrid.length-1],y=Math.abs(e);(u=y>=v?(y-v)/g:(y+g-p)/g)>1&&(u-=1)}Object.assign(t,{progress:r,progressLoop:u,isBeginning:o,isEnd:s}),(n.watchSlidesProgress||n.centeredSlides&&n.autoHeight)&&t.updateSlidesProgress(e),o&&!l&&t.emit("reachBeginning toEdge"),s&&!d&&t.emit("reachEnd toEdge"),(l&&!o||d&&!s)&&t.emit("fromEdge"),t.emit("progress",r)},updateSlidesClasses:function(){var e,t,i,n=this,a=n.slides,r=n.params,o=n.slidesEl,s=n.activeIndex,u=n.virtual&&r.virtual.enabled,l=n.grid&&r.grid&&r.grid.rows>1,d=e=>V_(o,`.${r.slideClass}${e}, swiper-slide${e}`)[0];if(u)if(r.loop){var h=s-n.virtual.slidesBefore;h<0&&(h=n.virtual.slides.length+h),h>=n.virtual.slides.length&&(h-=n.virtual.slides.length),e=d(`[data-swiper-slide-index="${h}"]`)}else e=d(`[data-swiper-slide-index="${s}"]`);else l?(e=a.find(e=>e.column===s),i=a.find(e=>e.column===s+1),t=a.find(e=>e.column===s-1)):e=a[s];e&&(l||(i=function(e,t){for(var i=[];e.nextElementSibling;){var n=e.nextElementSibling;t?n.matches(t)&&i.push(n):i.push(n),e=n}return i}(e,`.${r.slideClass}, swiper-slide`)[0],r.loop&&!i&&(i=a[0]),t=function(e,t){for(var i=[];e.previousElementSibling;){var n=e.previousElementSibling;t?n.matches(t)&&i.push(n):i.push(n),e=n}return i}(e,`.${r.slideClass}, swiper-slide`)[0],r.loop&&0===!t&&(t=a[a.length-1]))),a.forEach(n=>{oR(n,n===e,r.slideActiveClass),oR(n,n===i,r.slideNextClass),oR(n,n===t,r.slidePrevClass)}),n.emitSlidesClasses()},updateActiveIndex:function(e){var t,i=this,n=i.rtlTranslate?i.translate:-i.translate,a=i.snapGrid,r=i.params,o=i.activeIndex,s=i.realIndex,u=i.snapIndex,l=e,d=e=>{var t=e-i.virtual.slidesBefore;return t<0&&(t=i.virtual.slides.length+t),t>=i.virtual.slides.length&&(t-=i.virtual.slides.length),t};if(void 0===l&&(l=function(e){for(var t,i=e.slidesGrid,n=e.params,a=e.rtlTranslate?e.translate:-e.translate,r=0;r<i.length;r+=1)void 0!==i[r+1]?a>=i[r]&&a<i[r+1]-(i[r+1]-i[r])/2?t=r:a>=i[r]&&a<i[r+1]&&(t=r+1):a>=i[r]&&(t=r);return n.normalizeSlideIndex&&(t<0||void 0===t)&&(t=0),t}(i)),a.indexOf(n)>=0)t=a.indexOf(n);else{var h=Math.min(r.slidesPerGroupSkip,l);t=h+Math.floor((l-h)/r.slidesPerGroup)}if(t>=a.length&&(t=a.length-1),l!==o||i.params.loop)if(l===o&&i.params.loop&&i.virtual&&i.params.virtual.enabled)i.realIndex=d(l);else{var c,m=i.grid&&r.grid&&r.grid.rows>1;if(i.virtual&&r.virtual.enabled)c=r.loop?d(l):l;else if(m){var f=i.slides.find(e=>e.column===l),v=parseInt(f.getAttribute("data-swiper-slide-index"),10);Number.isNaN(v)&&(v=Math.max(i.slides.indexOf(f),0)),c=Math.floor(v/r.grid.rows)}else if(i.slides[l]){var p=i.slides[l].getAttribute("data-swiper-slide-index");c=p?parseInt(p,10):l}else c=l;Object.assign(i,{previousSnapIndex:u,snapIndex:t,previousRealIndex:s,realIndex:c,previousIndex:o,activeIndex:l}),i.initialized&&lR(i),i.emit("activeIndexChange"),i.emit("snapIndexChange"),(i.initialized||i.params.runCallbacksOnInit)&&(s!==c&&i.emit("realIndexChange"),i.emit("slideChange"))}else t!==u&&(i.snapIndex=t,i.emit("snapIndexChange"))},updateClickedSlide:function(e,t){var i=this,n=i.params,a=e.closest(`.${n.slideClass}, swiper-slide`);!a&&i.isElement&&t&&t.length>1&&t.includes(e)&&[...t.slice(t.indexOf(e)+1,t.length)].forEach(e=>{!a&&e.matches&&e.matches(`.${n.slideClass}, swiper-slide`)&&(a=e)});var r,o=!1;if(a)for(var s=0;s<i.slides.length;s+=1)if(i.slides[s]===a){o=!0,r=s;break}if(!a||!o)return i.clickedSlide=void 0,void(i.clickedIndex=void 0);i.clickedSlide=a,i.virtual&&i.params.virtual.enabled?i.clickedIndex=parseInt(a.getAttribute("data-swiper-slide-index"),10):i.clickedIndex=r,n.slideToClickedSlide&&void 0!==i.clickedIndex&&i.clickedIndex!==i.activeIndex&&i.slideToClickedSlide()}};var hR={getTranslate:function(e=(this.isHorizontal()?"x":"y")){var t=this,i=t.params,n=t.rtlTranslate,a=t.translate,r=t.wrapperEl;if(i.virtualTranslate)return n?-a:a;if(i.cssMode)return a;var o=N_(r,e);return o+=t.cssOverflowAdjustment(),n&&(o=-o),o||0},setTranslate:function(e,t){var i=this,n=i.rtlTranslate,a=i.params,r=i.wrapperEl,o=i.progress,s=0,u=0;i.isHorizontal()?s=n?-e:e:u=e,a.roundLengths&&(s=Math.floor(s),u=Math.floor(u)),i.previousTranslate=i.translate,i.translate=i.isHorizontal()?s:u,a.cssMode?r[i.isHorizontal()?"scrollLeft":"scrollTop"]=i.isHorizontal()?-s:-u:a.virtualTranslate||(i.isHorizontal()?s-=i.cssOverflowAdjustment():u-=i.cssOverflowAdjustment(),r.style.transform=`translate3d(${s}px, ${u}px, 0px)`);var l=i.maxTranslate()-i.minTranslate();(0===l?0:(e-i.minTranslate())/l)!==o&&i.updateProgress(e),i.emit("setTranslate",i.translate,t)},minTranslate:function(){return-this.snapGrid[0]},maxTranslate:function(){return-this.snapGrid[this.snapGrid.length-1]},translateTo:function(e=0,t=this.params.speed,i=!0,n=!0,a){var r=this,o=r.params,s=r.wrapperEl;if(r.animating&&o.preventInteractionOnTransition)return!1;var u,l=r.minTranslate(),d=r.maxTranslate();if(u=n&&e>l?l:n&&e<d?d:e,r.updateProgress(u),o.cssMode){var h=r.isHorizontal();if(0===t)s[h?"scrollLeft":"scrollTop"]=-u;else{if(!r.support.smoothScroll)return H_({swiper:r,targetPosition:-u,side:h?"left":"top"}),!0;s.scrollTo({[h?"left":"top"]:-u,behavior:"smooth"})}return!0}return 0===t?(r.setTransition(0),r.setTranslate(u),i&&(r.emit("beforeTransitionStart",t,a),r.emit("transitionEnd"))):(r.setTransition(t),r.setTranslate(u),i&&(r.emit("beforeTransitionStart",t,a),r.emit("transitionStart")),r.animating||(r.animating=!0,r.onTranslateToWrapperTransitionEnd||(r.onTranslateToWrapperTransitionEnd=function(e){r&&!r.destroyed&&e.target===this&&(r.wrapperEl.removeEventListener("transitionend",r.onTranslateToWrapperTransitionEnd),r.onTranslateToWrapperTransitionEnd=null,delete r.onTranslateToWrapperTransitionEnd,r.animating=!1,i&&r.emit("transitionEnd"))}),r.wrapperEl.addEventListener("transitionend",r.onTranslateToWrapperTransitionEnd))),!0}};function cR({swiper:e,runCallbacks:t,direction:i,step:n}){var a=e.activeIndex,r=e.previousIndex,o=i;o||(o=a>r?"next":a<r?"prev":"reset"),e.emit(`transition${n}`),t&&"reset"===o?e.emit(`slideResetTransition${n}`):t&&a!==r&&(e.emit(`slideChangeTransition${n}`),"next"===o?e.emit(`slideNextTransition${n}`):e.emit(`slidePrevTransition${n}`))}var mR={slideTo:function(e=0,t,i=!0,n,a){"string"==typeof e&&(e=parseInt(e,10));var r=this,o=e;o<0&&(o=0);var s=r.params,u=r.snapGrid,l=r.slidesGrid,d=r.previousIndex,h=r.activeIndex,c=r.rtlTranslate,m=r.wrapperEl;if(!r.enabled&&!n&&!a||r.destroyed||r.animating&&s.preventInteractionOnTransition)return!1;void 0===t&&(t=r.params.speed);var f=Math.min(r.params.slidesPerGroupSkip,o),v=f+Math.floor((o-f)/r.params.slidesPerGroup);v>=u.length&&(v=u.length-1);var p,g=-u[v];if(s.normalizeSlideIndex)for(var y=0;y<l.length;y+=1){var b=-Math.floor(100*g),w=Math.floor(100*l[y]),k=Math.floor(100*l[y+1]);void 0!==l[y+1]?b>=w&&b<k-(k-w)/2?o=y:b>=w&&b<k&&(o=y+1):b>=w&&(o=y)}if(r.initialized&&o!==h){if(!r.allowSlideNext&&(c?g>r.translate&&g>r.minTranslate():g<r.translate&&g<r.minTranslate()))return!1;if(!r.allowSlidePrev&&g>r.translate&&g>r.maxTranslate()&&(h||0)!==o)return!1}o!==(d||0)&&i&&r.emit("beforeSlideChangeStart"),r.updateProgress(g),p=o>h?"next":o<h?"prev":"reset";var S=r.virtual&&r.params.virtual.enabled;if(!(S&&a)&&(c&&-g===r.translate||!c&&g===r.translate))return r.updateActiveIndex(o),s.autoHeight&&r.updateAutoHeight(),r.updateSlidesClasses(),"slide"!==s.effect&&r.setTranslate(g),"reset"!==p&&(r.transitionStart(i,p),r.transitionEnd(i,p)),!1;if(s.cssMode){var E=r.isHorizontal(),T=c?g:-g;if(0===t)S&&(r.wrapperEl.style.scrollSnapType="none",r._immediateVirtual=!0),S&&!r._cssModeVirtualInitialSet&&r.params.initialSlide>0?(r._cssModeVirtualInitialSet=!0,requestAnimationFrame(()=>{m[E?"scrollLeft":"scrollTop"]=T})):m[E?"scrollLeft":"scrollTop"]=T,S&&requestAnimationFrame(()=>{r.wrapperEl.style.scrollSnapType="",r._immediateVirtual=!1});else{if(!r.support.smoothScroll)return H_({swiper:r,targetPosition:T,side:E?"left":"top"}),!0;m.scrollTo({[E?"left":"top"]:T,behavior:"smooth"})}return!0}var P=nR().isSafari;return S&&!a&&P&&r.isElement&&r.virtual.update(!1,!1,o),r.setTransition(t),r.setTranslate(g),r.updateActiveIndex(o),r.updateSlidesClasses(),r.emit("beforeTransitionStart",t,n),r.transitionStart(i,p),0===t?r.transitionEnd(i,p):r.animating||(r.animating=!0,r.onSlideToWrapperTransitionEnd||(r.onSlideToWrapperTransitionEnd=function(e){r&&!r.destroyed&&e.target===this&&(r.wrapperEl.removeEventListener("transitionend",r.onSlideToWrapperTransitionEnd),r.onSlideToWrapperTransitionEnd=null,delete r.onSlideToWrapperTransitionEnd,r.transitionEnd(i,p))}),r.wrapperEl.addEventListener("transitionend",r.onSlideToWrapperTransitionEnd)),!0},slideToLoop:function(e=0,t,i=!0,n){"string"==typeof e&&(e=parseInt(e,10));var a=this;if(!a.destroyed){void 0===t&&(t=a.params.speed);var r=a.grid&&a.params.grid&&a.params.grid.rows>1,o=e;if(a.params.loop)if(a.virtual&&a.params.virtual.enabled)o+=a.virtual.slidesBefore;else{var s;if(r){var u=o*a.params.grid.rows;s=a.slides.find(e=>1*e.getAttribute("data-swiper-slide-index")===u).column}else s=a.getSlideIndexByData(o);var l=r?Math.ceil(a.slides.length/a.params.grid.rows):a.slides.length,d=a.params,h=d.centeredSlides,c=d.slidesOffsetBefore,m=d.slidesOffsetAfter,f=h||!!c||!!m,v=a.params.slidesPerView;"auto"===v?v=a.slidesPerViewDynamic():(v=Math.ceil(parseFloat(a.params.slidesPerView,10)),f&&v%2==0&&(v+=1));var p=l-s<v;if(f&&(p=p||s<Math.ceil(v/2)),n&&f&&"auto"!==a.params.slidesPerView&&!r&&(p=!1),p){var g=f?s<a.activeIndex?"prev":"next":s-a.activeIndex-1<a.params.slidesPerView?"next":"prev";a.loopFix({direction:g,slideTo:!0,activeSlideIndex:"next"===g?s+1:s-l+1,slideRealIndex:"next"===g?a.realIndex:void 0})}if(r){var y=o*a.params.grid.rows;o=a.slides.find(e=>1*e.getAttribute("data-swiper-slide-index")===y).column}else o=a.getSlideIndexByData(o)}return requestAnimationFrame(()=>{a.slideTo(o,t,i,n)}),a}},slideNext:function(e,t=!0,i){var n=this,a=n.enabled,r=n.params,o=n.animating;if(!a||n.destroyed)return n;void 0===e&&(e=n.params.speed);var s=r.slidesPerGroup;"auto"===r.slidesPerView&&1===r.slidesPerGroup&&r.slidesPerGroupAuto&&(s=Math.max(n.slidesPerViewDynamic("current",!0),1));var u=n.activeIndex<r.slidesPerGroupSkip?1:s,l=n.virtual&&r.virtual.enabled;if(r.loop){if(o&&!l&&r.loopPreventsSliding)return!1;if(n.loopFix({direction:"next"}),n._clientLeft=n.wrapperEl.clientLeft,n.activeIndex===n.slides.length-1&&r.cssMode)return requestAnimationFrame(()=>{n.slideTo(n.activeIndex+u,e,t,i)}),!0}return r.rewind&&n.isEnd?n.slideTo(0,e,t,i):n.slideTo(n.activeIndex+u,e,t,i)},slidePrev:function(e,t=!0,i){var n=this,a=n.params,r=n.snapGrid,o=n.slidesGrid,s=n.rtlTranslate,u=n.enabled,l=n.animating;if(!u||n.destroyed)return n;void 0===e&&(e=n.params.speed);var d=n.virtual&&a.virtual.enabled;if(a.loop){if(l&&!d&&a.loopPreventsSliding)return!1;n.loopFix({direction:"prev"}),n._clientLeft=n.wrapperEl.clientLeft}function h(e){return e<0?-Math.floor(Math.abs(e)):Math.floor(e)}var c,m=h(s?n.translate:-n.translate),f=r.map(e=>h(e)),v=a.freeMode&&a.freeMode.enabled,p=r[f.indexOf(m)-1];void 0===p&&(a.cssMode||v)&&(r.forEach((e,t)=>{m>=e&&(c=t)}),void 0!==c&&(p=v?r[c]:r[c>0?c-1:c]));var g=0;if(void 0!==p&&((g=o.indexOf(p))<0&&(g=n.activeIndex-1),"auto"===a.slidesPerView&&1===a.slidesPerGroup&&a.slidesPerGroupAuto&&(g=g-n.slidesPerViewDynamic("previous",!0)+1,g=Math.max(g,0))),a.rewind&&n.isBeginning){var y=n.params.virtual&&n.params.virtual.enabled&&n.virtual?n.virtual.slides.length-1:n.slides.length-1;return n.slideTo(y,e,t,i)}return a.loop&&0===n.activeIndex&&a.cssMode?(requestAnimationFrame(()=>{n.slideTo(g,e,t,i)}),!0):n.slideTo(g,e,t,i)},slideReset:function(e,t=!0,i){var n=this;if(!n.destroyed)return void 0===e&&(e=n.params.speed),n.slideTo(n.activeIndex,e,t,i)},slideToClosest:function(e,t=!0,i,n=.5){var a=this;if(!a.destroyed){void 0===e&&(e=a.params.speed);var r=a.activeIndex,o=Math.min(a.params.slidesPerGroupSkip,r),s=o+Math.floor((r-o)/a.params.slidesPerGroup),u=a.rtlTranslate?a.translate:-a.translate;if(u>=a.snapGrid[s]){var l=a.snapGrid[s];u-l>(a.snapGrid[s+1]-l)*n&&(r+=a.params.slidesPerGroup)}else{var d=a.snapGrid[s-1];u-d<=(a.snapGrid[s]-d)*n&&(r-=a.params.slidesPerGroup)}return r=Math.max(r,0),r=Math.min(r,a.slidesGrid.length-1),a.slideTo(r,e,t,i)}},slideToClickedSlide:function(){var e=this;if(!e.destroyed){var t,i=e.params,n=e.slidesEl,a="auto"===i.slidesPerView?e.slidesPerViewDynamic():i.slidesPerView,r=e.getSlideIndexWhenGrid(e.clickedIndex),o=e.isElement?"swiper-slide":`.${i.slideClass}`,s=e.grid&&e.params.grid&&e.params.grid.rows>1;if(i.loop){if(e.animating)return;t=parseInt(e.clickedSlide.getAttribute("data-swiper-slide-index"),10),i.centeredSlides?e.slideToLoop(t):r>(s?(e.slides.length-a)/2-(e.params.grid.rows-1):e.slides.length-a)?(e.loopFix(),r=e.getSlideIndex(V_(n,`${o}[data-swiper-slide-index="${t}"]`)[0]),W_(()=>{e.slideTo(r)})):e.slideTo(r)}else e.slideTo(r)}}};var fR={loopCreate:function(e,t){var i=this,n=i.params,a=i.slidesEl;if(!(!n.loop||i.virtual&&i.params.virtual.enabled)){var r,o=()=>{V_(a,`.${n.slideClass}, swiper-slide`).forEach((e,t)=>{e.setAttribute("data-swiper-slide-index",t)})},s=i.grid&&n.grid&&n.grid.rows>1;n.loopAddBlankSlides&&(n.slidesPerGroup>1||s)&&((r=V_(a,`.${n.slideBlankClass}`)).forEach(e=>{e.remove()}),r.length>0&&(i.recalcSlides(),i.updateSlides()));var u=n.slidesPerGroup*(s?n.grid.rows:1),l=i.slides.length%u!==0,d=s&&i.slides.length%n.grid.rows!==0,h=e=>{for(var t=0;t<e;t+=1){var a=i.isElement?X_("swiper-slide",[n.slideBlankClass]):X_("div",[n.slideClass,n.slideBlankClass]);i.slidesEl.append(a)}};if(l){if(n.loopAddBlankSlides)h(u-i.slides.length%u),i.recalcSlides(),i.updateSlides();else K_("Swiper Loop Warning: The number of slides is not even to slidesPerGroup, loop mode may not function properly. You need to add more slides (or make duplicates, or empty slides)");o()}else if(d){if(n.loopAddBlankSlides)h(n.grid.rows-i.slides.length%n.grid.rows),i.recalcSlides(),i.updateSlides();else K_("Swiper Loop Warning: The number of slides is not even to grid.rows, loop mode may not function properly. You need to add more slides (or make duplicates, or empty slides)");o()}else o();var c=n.centeredSlides||!!n.slidesOffsetBefore||!!n.slidesOffsetAfter;i.loopFix({slideRealIndex:e,direction:c?void 0:"next",initial:t})}},loopFix:function({slideRealIndex:e,slideTo:t=!0,direction:i,setTranslate:n,activeSlideIndex:a,initial:r,byController:o,byMousewheel:s}={}){var u=this;if(u.params.loop){u.emit("beforeLoopFix");var l=u.slides,d=u.allowSlidePrev,h=u.allowSlideNext,c=u.slidesEl,m=u.params,f=m.centeredSlides,p=m.slidesOffsetBefore,g=m.slidesOffsetAfter,y=m.initialSlide,b=f||!!p||!!g;if(u.allowSlidePrev=!0,u.allowSlideNext=!0,u.virtual&&m.virtual.enabled)return t&&(b||0!==u.snapIndex?b&&u.snapIndex<m.slidesPerView?u.slideTo(u.virtual.slides.length+u.snapIndex,0,!1,!0):u.snapIndex===u.snapGrid.length-1&&u.slideTo(u.virtual.slidesBefore,0,!1,!0):u.slideTo(u.virtual.slides.length,0,!1,!0)),u.allowSlidePrev=d,u.allowSlideNext=h,void u.emit("loopFix");var w=m.slidesPerView;"auto"===w?w=u.slidesPerViewDynamic():(w=Math.ceil(parseFloat(m.slidesPerView,10)),b&&w%2==0&&(w+=1));var k=m.slidesPerGroupAuto?w:m.slidesPerGroup,S=b?Math.max(k,Math.ceil(w/2)):k;S%k!==0&&(S+=k-S%k),S+=m.loopAdditionalSlides,u.loopedSlides=S;var E=u.grid&&m.grid&&m.grid.rows>1;l.length<w+S||"cards"===u.params.effect&&l.length<w+2*S?K_("Swiper Loop Warning: The number of slides is not enough for loop mode, it will be disabled or not function properly. You need to add more slides (or make duplicates) or lower the values of slidesPerView and slidesPerGroup parameters"):E&&"row"===m.grid.fill&&K_("Swiper Loop Warning: Loop mode is not compatible with grid.fill = `row`");var T=[],P=[],M=E?Math.ceil(l.length/m.grid.rows):l.length,A=r&&M-y<w&&!b,D=A?y:u.activeIndex;void 0===a?a=u.getSlideIndex(l.find(e=>e.classList.contains(m.slideActiveClass))):D=a;var x="next"===i||!i,C="prev"===i||!i,I=0,L=0,_=(E?l[a].column:a)+(b&&void 0===n?-w/2+.5:0);if(_<S){I=Math.max(S-_,k);for(var R=0;R<S-_;R+=1){var F=R-Math.floor(R/M)*M;if(E)for(var O=M-F-1,W=l.length-1;W>=0;W-=1)l[W].column===O&&T.push(W);else T.push(M-F-1)}}else if(_+w>M-S){L=Math.max(_-(M-2*S),k),A&&(L=Math.max(L,w-M+y+1));for(var $=function(){var e=N-Math.floor(N/M)*M;E?l.forEach((t,i)=>{t.column===e&&P.push(i)}):P.push(e)},N=0;N<L;N+=1)$()}if(u.__preventObserver__=!0,requestAnimationFrame(()=>{u.__preventObserver__=!1}),"cards"===u.params.effect&&l.length<w+2*S&&(P.includes(a)&&P.splice(P.indexOf(a),1),T.includes(a)&&T.splice(T.indexOf(a),1)),C&&T.forEach(e=>{l[e].swiperLoopMoveDOM=!0,c.prepend(l[e]),l[e].swiperLoopMoveDOM=!1}),x&&P.forEach(e=>{l[e].swiperLoopMoveDOM=!0,c.append(l[e]),l[e].swiperLoopMoveDOM=!1}),u.recalcSlides(),"auto"===m.slidesPerView?u.updateSlides():E&&(T.length>0&&C||P.length>0&&x)&&u.slides.forEach((e,t)=>{u.grid.updateSlide(t,e,u.slides)}),m.watchSlidesProgress&&u.updateSlidesOffset(),t)if(T.length>0&&C){if(void 0===e){var j=u.slidesGrid[D],B=u.slidesGrid[D+I]-j;s?u.setTranslate(u.translate-B):(u.slideTo(D+Math.ceil(I),0,!1,!0),n&&(u.touchEventsData.startTranslate=u.touchEventsData.startTranslate-B,u.touchEventsData.currentTranslate=u.touchEventsData.currentTranslate-B))}else if(n){var z=E?T.length/m.grid.rows:T.length;u.slideTo(u.activeIndex+z,0,!1,!0),u.touchEventsData.currentTranslate=u.translate}}else if(P.length>0&&x)if(void 0===e){var U=u.slidesGrid[D],H=u.slidesGrid[D-L]-U;s?u.setTranslate(u.translate-H):(u.slideTo(D-L,0,!1,!0),n&&(u.touchEventsData.startTranslate=u.touchEventsData.startTranslate-H,u.touchEventsData.currentTranslate=u.touchEventsData.currentTranslate-H))}else{var G=E?P.length/m.grid.rows:P.length;u.slideTo(u.activeIndex-G,0,!1,!0)}if(u.allowSlidePrev=d,u.allowSlideNext=h,u.controller&&u.controller.control&&!o){var V={slideRealIndex:e,direction:i,setTranslate:n,activeSlideIndex:a,byController:!0};Array.isArray(u.controller.control)?u.controller.control.forEach(e=>{!e.destroyed&&e.params.loop&&e.loopFix(v({},V,{slideTo:e.params.slidesPerView===m.slidesPerView&&t}))}):u.controller.control instanceof u.constructor&&u.controller.control.params.loop&&u.controller.control.loopFix(v({},V,{slideTo:u.controller.control.params.slidesPerView===m.slidesPerView&&t}))}u.emit("loopFix")}},loopDestroy:function(){var e=this,t=e.params,i=e.slidesEl;if(t.loop&&i&&(!e.virtual||!e.params.virtual.enabled)){e.recalcSlides();var n=[];e.slides.forEach(e=>{var t=void 0===e.swiperSlideIndex?1*e.getAttribute("data-swiper-slide-index"):e.swiperSlideIndex;n[t]=e}),e.slides.forEach(e=>{e.removeAttribute("data-swiper-slide-index")}),n.forEach(e=>{i.append(e)}),e.recalcSlides(),e.slideTo(e.realIndex,0)}}};var vR={setGrabCursor:function(e){var t=this;if(!(!t.params.simulateTouch||t.params.watchOverflow&&t.isLocked||t.params.cssMode)){var i="container"===t.params.touchEventsTarget?t.el:t.wrapperEl;t.isElement&&(t.__preventObserver__=!0),i.style.cursor="move",i.style.cursor=e?"grabbing":"grab",t.isElement&&requestAnimationFrame(()=>{t.__preventObserver__=!1})}},unsetGrabCursor:function(){var e=this;e.params.watchOverflow&&e.isLocked||e.params.cssMode||(e.isElement&&(e.__preventObserver__=!0),e["container"===e.params.touchEventsTarget?"el":"wrapperEl"].style.cursor="",e.isElement&&requestAnimationFrame(()=>{e.__preventObserver__=!1}))}};function pR(e,t,i){var n=O_(),a=e.params,r=a.edgeSwipeDetection,o=a.edgeSwipeThreshold;return!r||!(i<=o||i>=n.innerWidth-o)||"prevent"===r&&(t.preventDefault(),!0)}function gR(e){var t=this,i=I_(),n=e;n.originalEvent&&(n=n.originalEvent);var a=t.touchEventsData;if("pointerdown"===n.type){if(null!==a.pointerId&&a.pointerId!==n.pointerId)return;a.pointerId=n.pointerId}else"touchstart"===n.type&&1===n.targetTouches.length&&(a.touchId=n.targetTouches[0].identifier);if("touchstart"!==n.type){var r=t.params,o=t.touches;if(t.enabled&&(r.simulateTouch||"mouse"!==n.pointerType)&&(!t.animating||!r.preventInteractionOnTransition)){!t.animating&&r.cssMode&&r.loop&&t.loopFix();var s=n.target;if(("wrapper"!==r.touchEventsTarget||function(e,t){var i=O_(),n=t.contains(e);return!n&&i.HTMLSlotElement&&t instanceof HTMLSlotElement&&((n=[...t.assignedElements()].includes(e))||(n=function(e,t){for(var i=[t];i.length>0;){var n=i.shift();if(e===n)return!0;i.push(...n.children,...n.shadowRoot?n.shadowRoot.children:[],...n.assignedElements?n.assignedElements():[])}}(e,t))),n}(s,t.wrapperEl))&&!("which"in n&&3===n.which||"button"in n&&n.button>0||a.isTouched&&a.isMoved)){var u=!!r.noSwipingClass&&""!==r.noSwipingClass,l=n.composedPath?n.composedPath():n.path;u&&n.target&&n.target.shadowRoot&&l&&(s=l[0]);var d=r.noSwipingSelector?r.noSwipingSelector:`.${r.noSwipingClass}`,h=!(!n.target||!n.target.shadowRoot);if(r.noSwiping&&(h?function(e,t=this){return function t(i){if(!i||i===I_()||i===O_())return null;i.assignedSlot&&(i=i.assignedSlot);var n=i.closest(e);return n||i.getRootNode?n||t(i.getRootNode().host):null}(t)}(d,s):s.closest(d)))t.allowClick=!0;else if(!r.swipeHandler||s.closest(r.swipeHandler)){o.currentX=n.pageX,o.currentY=n.pageY;var c=o.currentX,m=o.currentY;if(pR(t,n,c)){Object.assign(a,{isTouched:!0,isMoved:!1,allowTouchCallbacks:!0,isScrolling:void 0,startMoving:void 0}),o.startX=c,o.startY=m,a.touchStartTime=$_(),t.allowClick=!0,t.updateSize(),t.swipeDirection=void 0,r.threshold>0&&(a.allowThresholdMove=!1);var f=!0;s.matches(a.focusableElements)&&(f=!1,"SELECT"===s.nodeName&&(a.isTouched=!1)),i.activeElement&&i.activeElement.matches(a.focusableElements)&&i.activeElement!==s&&("mouse"===n.pointerType||"mouse"!==n.pointerType&&!s.matches(a.focusableElements))&&i.activeElement.blur();var v=f&&t.allowTouchMove&&r.touchStartPreventDefault;!r.touchStartForcePreventDefault&&!v||s.isContentEditable||n.preventDefault(),r.freeMode&&r.freeMode.enabled&&t.freeMode&&t.animating&&!r.cssMode&&t.freeMode.onTouchStart(),t.emit("touchStart",n)}}}}}else pR(t,n,n.targetTouches[0].pageX)}function yR(e){var t=I_(),i=this,n=i.touchEventsData,a=i.params,r=i.touches,o=i.rtlTranslate;if(i.enabled&&(a.simulateTouch||"mouse"!==e.pointerType)){var s,u=e;if(u.originalEvent&&(u=u.originalEvent),"pointermove"===u.type){if(null!==n.touchId)return;if(u.pointerId!==n.pointerId)return}if("touchmove"===u.type){if(s=[...u.changedTouches].find(e=>e.identifier===n.touchId),!s||s.identifier!==n.touchId)return}else s=u;if(n.isTouched){var l=s.pageX,d=s.pageY;if(u.preventedByNestedSwiper)return r.startX=l,void(r.startY=d);if(!i.allowTouchMove)return u.target.matches(n.focusableElements)||(i.allowClick=!1),void(n.isTouched&&(Object.assign(r,{startX:l,startY:d,currentX:l,currentY:d}),n.touchStartTime=$_()));if(a.touchReleaseOnEdges&&!a.loop)if(i.isVertical()){if(d<r.startY&&i.translate<=i.maxTranslate()||d>r.startY&&i.translate>=i.minTranslate())return n.isTouched=!1,void(n.isMoved=!1)}else{if(o&&(l>r.startX&&-i.translate<=i.maxTranslate()||l<r.startX&&-i.translate>=i.minTranslate()))return;if(!o&&(l<r.startX&&i.translate<=i.maxTranslate()||l>r.startX&&i.translate>=i.minTranslate()))return}if(t.activeElement&&t.activeElement.matches(n.focusableElements)&&t.activeElement!==u.target&&"mouse"!==u.pointerType&&t.activeElement.blur(),t.activeElement&&u.target===t.activeElement&&u.target.matches(n.focusableElements))return n.isMoved=!0,void(i.allowClick=!1);n.allowTouchCallbacks&&i.emit("touchMove",u),r.previousX=r.currentX,r.previousY=r.currentY,r.currentX=l,r.currentY=d;var h=r.currentX-r.startX,c=r.currentY-r.startY;if(!(i.params.threshold&&Math.sqrt(h**2+c**2)<i.params.threshold)){var m;if(void 0===n.isScrolling)i.isHorizontal()&&r.currentY===r.startY||i.isVertical()&&r.currentX===r.startX?n.isScrolling=!1:h*h+c*c>=25&&(m=180*Math.atan2(Math.abs(c),Math.abs(h))/Math.PI,n.isScrolling=i.isHorizontal()?m>a.touchAngle:90-m>a.touchAngle);if(n.isScrolling&&i.emit("touchMoveOpposite",u),void 0===n.startMoving&&(r.currentX===r.startX&&r.currentY===r.startY||(n.startMoving=!0)),n.isScrolling||"touchmove"===u.type&&n.preventTouchMoveFromPointerMove)n.isTouched=!1;else if(n.startMoving){i.allowClick=!1,!a.cssMode&&u.cancelable&&u.preventDefault(),a.touchMoveStopPropagation&&!a.nested&&u.stopPropagation();var f=i.isHorizontal()?h:c,v=i.isHorizontal()?r.currentX-r.previousX:r.currentY-r.previousY;a.oneWayMovement&&(f=Math.abs(f)*(o?1:-1),v=Math.abs(v)*(o?1:-1)),r.diff=f,f*=a.touchRatio,o&&(f=-f,v=-v);var p=i.touchesDirection;i.swipeDirection=f>0?"prev":"next",i.touchesDirection=v>0?"prev":"next";var g=i.params.loop&&!a.cssMode,y="next"===i.touchesDirection&&i.allowSlideNext||"prev"===i.touchesDirection&&i.allowSlidePrev;if(!n.isMoved){if(g&&y&&i.loopFix({direction:i.swipeDirection}),n.startTranslate=i.getTranslate(),i.setTransition(0),i.animating){var b=new window.CustomEvent("transitionend",{bubbles:!0,cancelable:!0,detail:{bySwiperTouchMove:!0}});i.wrapperEl.dispatchEvent(b)}n.allowMomentumBounce=!1,!a.grabCursor||!0!==i.allowSlideNext&&!0!==i.allowSlidePrev||i.setGrabCursor(!0),i.emit("sliderFirstMove",u)}if((new Date).getTime(),!1!==a._loopSwapReset&&n.isMoved&&n.allowThresholdMove&&p!==i.touchesDirection&&g&&y&&Math.abs(f)>=1)return Object.assign(r,{startX:l,startY:d,currentX:l,currentY:d,startTranslate:n.currentTranslate}),n.loopSwapReset=!0,void(n.startTranslate=n.currentTranslate);i.emit("sliderMove",u),n.isMoved=!0,n.currentTranslate=f+n.startTranslate;var w=!0,k=a.resistanceRatio;if(a.touchReleaseOnEdges&&(k=0),f>0?(g&&y&&n.allowThresholdMove&&n.currentTranslate>(a.centeredSlides?i.minTranslate()-i.slidesSizesGrid[i.activeIndex+1]-("auto"!==a.slidesPerView&&i.slides.length-a.slidesPerView>=2?i.slidesSizesGrid[i.activeIndex+1]+i.params.spaceBetween:0)-i.params.spaceBetween:i.minTranslate())&&i.loopFix({direction:"prev",setTranslate:!0,activeSlideIndex:0}),n.currentTranslate>i.minTranslate()&&(w=!1,a.resistance&&(n.currentTranslate=i.minTranslate()-1+(-i.minTranslate()+n.startTranslate+f)**k))):f<0&&(g&&y&&n.allowThresholdMove&&n.currentTranslate<(a.centeredSlides?i.maxTranslate()+i.slidesSizesGrid[i.slidesSizesGrid.length-1]+i.params.spaceBetween+("auto"!==a.slidesPerView&&i.slides.length-a.slidesPerView>=2?i.slidesSizesGrid[i.slidesSizesGrid.length-1]+i.params.spaceBetween:0):i.maxTranslate())&&i.loopFix({direction:"next",setTranslate:!0,activeSlideIndex:i.slides.length-("auto"===a.slidesPerView?i.slidesPerViewDynamic():Math.ceil(parseFloat(a.slidesPerView,10)))}),n.currentTranslate<i.maxTranslate()&&(w=!1,a.resistance&&(n.currentTranslate=i.maxTranslate()+1-(i.maxTranslate()-n.startTranslate-f)**k))),w&&(u.preventedByNestedSwiper=!0),!i.allowSlideNext&&"next"===i.swipeDirection&&n.currentTranslate<n.startTranslate&&(n.currentTranslate=n.startTranslate),!i.allowSlidePrev&&"prev"===i.swipeDirection&&n.currentTranslate>n.startTranslate&&(n.currentTranslate=n.startTranslate),i.allowSlidePrev||i.allowSlideNext||(n.currentTranslate=n.startTranslate),a.threshold>0){if(!(Math.abs(f)>a.threshold||n.allowThresholdMove))return void(n.currentTranslate=n.startTranslate);if(!n.allowThresholdMove)return n.allowThresholdMove=!0,r.startX=r.currentX,r.startY=r.currentY,n.currentTranslate=n.startTranslate,void(r.diff=i.isHorizontal()?r.currentX-r.startX:r.currentY-r.startY)}a.followFinger&&!a.cssMode&&((a.freeMode&&a.freeMode.enabled&&i.freeMode||a.watchSlidesProgress)&&(i.updateActiveIndex(),i.updateSlidesClasses()),a.freeMode&&a.freeMode.enabled&&i.freeMode&&i.freeMode.onTouchMove(),i.updateProgress(n.currentTranslate),i.setTranslate(n.currentTranslate))}}}else n.startMoving&&n.isScrolling&&i.emit("touchMoveOpposite",u)}}function bR(e){var t,i=this,n=i.touchEventsData,a=e;if(a.originalEvent&&(a=a.originalEvent),"touchend"===a.type||"touchcancel"===a.type){if(t=[...a.changedTouches].find(e=>e.identifier===n.touchId),!t||t.identifier!==n.touchId)return}else{if(null!==n.touchId)return;if(a.pointerId!==n.pointerId)return;t=a}if(["pointercancel","pointerout","pointerleave","contextmenu"].includes(a.type)&&!(["pointercancel","contextmenu"].includes(a.type)&&(i.browser.isSafari||i.browser.isWebView)))return;n.pointerId=null,n.touchId=null;var r=i.params,o=i.touches,s=i.rtlTranslate,u=i.slidesGrid;if(i.enabled&&(r.simulateTouch||"mouse"!==a.pointerType)){if(n.allowTouchCallbacks&&i.emit("touchEnd",a),n.allowTouchCallbacks=!1,!n.isTouched)return n.isMoved&&r.grabCursor&&i.setGrabCursor(!1),n.isMoved=!1,void(n.startMoving=!1);r.grabCursor&&n.isMoved&&n.isTouched&&(!0===i.allowSlideNext||!0===i.allowSlidePrev)&&i.setGrabCursor(!1);var l,d=$_(),h=d-n.touchStartTime;if(i.allowClick){var c=a.path||a.composedPath&&a.composedPath();i.updateClickedSlide(c&&c[0]||a.target,c),i.emit("tap click",a),h<300&&d-n.lastClickTime<300&&i.emit("doubleTap doubleClick",a)}if(n.lastClickTime=$_(),W_(()=>{i.destroyed||(i.allowClick=!0)}),!n.isTouched||!n.isMoved||!i.swipeDirection||0===o.diff&&!n.loopSwapReset||n.currentTranslate===n.startTranslate&&!n.loopSwapReset)return n.isTouched=!1,n.isMoved=!1,void(n.startMoving=!1);if(n.isTouched=!1,n.isMoved=!1,n.startMoving=!1,l=r.followFinger?s?i.translate:-i.translate:-n.currentTranslate,!r.cssMode)if(r.freeMode&&r.freeMode.enabled)i.freeMode.onTouchEnd({currentPos:l});else{for(var m=l>=-i.maxTranslate()&&!i.params.loop,f=0,v=i.slidesSizesGrid[0],p=0;p<u.length;p+=p<r.slidesPerGroupSkip?1:r.slidesPerGroup){var g=p<r.slidesPerGroupSkip-1?1:r.slidesPerGroup;void 0!==u[p+g]?(m||l>=u[p]&&l<u[p+g])&&(f=p,v=u[p+g]-u[p]):(m||l>=u[p])&&(f=p,v=u[u.length-1]-u[u.length-2])}var y=null,b=null;r.rewind&&(i.isBeginning?b=r.virtual&&r.virtual.enabled&&i.virtual?i.virtual.slides.length-1:i.slides.length-1:i.isEnd&&(y=0));var w=(l-u[f])/v,k=f<r.slidesPerGroupSkip-1?1:r.slidesPerGroup;if(h>r.longSwipesMs){if(!r.longSwipes)return void i.slideTo(i.activeIndex);"next"===i.swipeDirection&&(w>=r.longSwipesRatio?i.slideTo(r.rewind&&i.isEnd?y:f+k):i.slideTo(f)),"prev"===i.swipeDirection&&(w>1-r.longSwipesRatio?i.slideTo(f+k):null!==b&&w<0&&Math.abs(w)>r.longSwipesRatio?i.slideTo(b):i.slideTo(f))}else{if(!r.shortSwipes)return void i.slideTo(i.activeIndex);i.navigation&&(a.target===i.navigation.nextEl||a.target===i.navigation.prevEl)?a.target===i.navigation.nextEl?i.slideTo(f+k):i.slideTo(f):("next"===i.swipeDirection&&i.slideTo(null!==y?y:f+k),"prev"===i.swipeDirection&&i.slideTo(null!==b?b:f))}}}}function wR(){var e=this,t=e.params,i=e.el;if(!i||0!==i.offsetWidth){t.breakpoints&&e.setBreakpoint();var n=e.allowSlideNext,a=e.allowSlidePrev,r=e.snapGrid,o=e.virtual&&e.params.virtual.enabled;e.allowSlideNext=!0,e.allowSlidePrev=!0,e.updateSize(),e.updateSlides(),e.updateSlidesClasses();var s=o&&t.loop;if(!("auto"===t.slidesPerView||t.slidesPerView>1)||!e.isEnd||e.isBeginning||e.params.centeredSlides||s)e.params.loop&&!o?e.slideToLoop(e.realIndex,0,!1,!0):e.slideTo(e.activeIndex,0,!1,!0);else{var u=o?e.virtual.slides:e.slides;e.slideTo(u.length-1,0,!1,!0)}e.autoplay&&e.autoplay.running&&e.autoplay.paused&&(clearTimeout(e.autoplay.resizeTimeout),e.autoplay.resizeTimeout=setTimeout(()=>{e.autoplay&&e.autoplay.running&&e.autoplay.paused&&e.autoplay.resume()},500)),e.allowSlidePrev=a,e.allowSlideNext=n,e.params.watchOverflow&&r!==e.snapGrid&&e.checkOverflow()}}function kR(e){var t=this;t.enabled&&(t.allowClick||(t.params.preventClicks&&e.preventDefault(),t.params.preventClicksPropagation&&t.animating&&(e.stopPropagation(),e.stopImmediatePropagation())))}function SR(){var e=this,t=e.wrapperEl,i=e.rtlTranslate;if(e.enabled){e.previousTranslate=e.translate,e.isHorizontal()?e.translate=-t.scrollLeft:e.translate=-t.scrollTop,0===e.translate&&(e.translate=0),e.updateActiveIndex(),e.updateSlidesClasses();var n=e.maxTranslate()-e.minTranslate();(0===n?0:(e.translate-e.minTranslate())/n)!==e.progress&&e.updateProgress(i?-e.translate:e.translate),e.emit("setTranslate",e.translate,!1)}}function ER(e){var t=this;sR(t,e.target),t.params.cssMode||"auto"!==t.params.slidesPerView&&!t.params.autoHeight||t.update()}function TR(){var e=this;e.documentTouchHandlerProceeded||(e.documentTouchHandlerProceeded=!0,e.params.touchReleaseOnEdges&&(e.el.style.touchAction="auto"))}var PR=(e,t)=>{var i=I_(),n=e.params,a=e.el,r=e.wrapperEl,o=e.device,s=!!n.nested,u="on"===t?"addEventListener":"removeEventListener",l=t;a&&"string"!=typeof a&&(i[u]("touchstart",e.onDocumentTouchStart,{passive:!1,capture:s}),a[u]("touchstart",e.onTouchStart,{passive:!1}),a[u]("pointerdown",e.onTouchStart,{passive:!1}),i[u]("touchmove",e.onTouchMove,{passive:!1,capture:s}),i[u]("pointermove",e.onTouchMove,{passive:!1,capture:s}),i[u]("touchend",e.onTouchEnd,{passive:!0}),i[u]("pointerup",e.onTouchEnd,{passive:!0}),i[u]("pointercancel",e.onTouchEnd,{passive:!0}),i[u]("touchcancel",e.onTouchEnd,{passive:!0}),i[u]("pointerout",e.onTouchEnd,{passive:!0}),i[u]("pointerleave",e.onTouchEnd,{passive:!0}),i[u]("contextmenu",e.onTouchEnd,{passive:!0}),(n.preventClicks||n.preventClicksPropagation)&&a[u]("click",e.onClick,!0),n.cssMode&&r[u]("scroll",e.onScroll),n.updateOnWindowResize?e[l](o.ios||o.android?"resize orientationchange observerUpdate":"resize observerUpdate",wR,!0):e[l]("observerUpdate",wR,!0),a[u]("load",e.onLoad,{capture:!0}))};var MR=(e,t)=>e.grid&&t.grid&&t.grid.rows>1;var AR={setBreakpoint:function(){var e=this,t=e.realIndex,i=e.initialized,n=e.params,a=e.el,r=n.breakpoints;if(r&&(!r||0!==Object.keys(r).length)){var o=I_(),s="window"!==n.breakpointsBase&&n.breakpointsBase?"container":n.breakpointsBase,u=["window","container"].includes(n.breakpointsBase)||!n.breakpointsBase?e.el:o.querySelector(n.breakpointsBase),l=e.getBreakpoint(r,s,u);if(l&&e.currentBreakpoint!==l){var d=(l in r?r[l]:void 0)||e.originalParams,h=MR(e,n),c=MR(e,d),m=e.params.grabCursor,f=d.grabCursor,v=n.enabled;h&&!c?(a.classList.remove(`${n.containerModifierClass}grid`,`${n.containerModifierClass}grid-column`),e.emitContainerClasses()):!h&&c&&(a.classList.add(`${n.containerModifierClass}grid`),(d.grid.fill&&"column"===d.grid.fill||!d.grid.fill&&"column"===n.grid.fill)&&a.classList.add(`${n.containerModifierClass}grid-column`),e.emitContainerClasses()),m&&!f?e.unsetGrabCursor():!m&&f&&e.setGrabCursor(),["navigation","pagination","scrollbar"].forEach(t=>{if(void 0!==d[t]){var i=n[t]&&n[t].enabled,a=d[t]&&d[t].enabled;i&&!a&&e[t].disable(),!i&&a&&e[t].enable()}});var p=d.direction&&d.direction!==n.direction,g=n.loop&&(d.slidesPerView!==n.slidesPerView||p),y=n.loop;p&&i&&e.changeDirection(),z_(e.params,d);var b=e.params.enabled,w=e.params.loop;Object.assign(e,{allowTouchMove:e.params.allowTouchMove,allowSlideNext:e.params.allowSlideNext,allowSlidePrev:e.params.allowSlidePrev}),v&&!b?e.disable():!v&&b&&e.enable(),e.currentBreakpoint=l,e.emit("_beforeBreakpoint",d),i&&(g?(e.loopDestroy(),e.loopCreate(t),e.updateSlides()):!y&&w?(e.loopCreate(t),e.updateSlides()):y&&!w&&e.loopDestroy()),e.emit("breakpoint",d)}}},getBreakpoint:function(e,t="window",i){if(e&&("container"!==t||i)){var n=!1,a=O_(),r="window"===t?a.innerHeight:i.clientHeight,o=Object.keys(e).map(e=>{if("string"==typeof e&&0===e.indexOf("@")){var t=parseFloat(e.substr(1));return{value:r*t,point:e}}return{value:e,point:e}});o.sort((e,t)=>parseInt(e.value,10)-parseInt(t.value,10));for(var s=0;s<o.length;s+=1){var u=o[s],l=u.point,d=u.value;"window"===t?a.matchMedia(`(min-width: ${d}px)`).matches&&(n=l):d<=i.clientWidth&&(n=l)}return n||"max"}}};var DR={addClasses:function(){var e,t,i,n=this,a=n.classNames,r=n.params,o=n.rtl,s=n.el,u=n.device,l=(e=["initialized",r.direction,{"free-mode":n.params.freeMode&&r.freeMode.enabled},{autoheight:r.autoHeight},{rtl:o},{grid:r.grid&&r.grid.rows>1},{"grid-column":r.grid&&r.grid.rows>1&&"column"===r.grid.fill},{android:u.android},{ios:u.ios},{"css-mode":r.cssMode},{centered:r.cssMode&&r.centeredSlides},{"watch-progress":r.watchSlidesProgress}],t=r.containerModifierClass,i=[],e.forEach(e=>{"object"==typeof e?Object.keys(e).forEach(n=>{e[n]&&i.push(t+n)}):"string"==typeof e&&i.push(t+e)}),i);a.push(...l),s.classList.add(...a),n.emitContainerClasses()},removeClasses:function(){var e=this,t=e.el,i=e.classNames;t&&"string"!=typeof t&&(t.classList.remove(...i),e.emitContainerClasses())}};var xR={init:!0,direction:"horizontal",oneWayMovement:!1,swiperElementNodeName:"SWIPER-CONTAINER",touchEventsTarget:"wrapper",initialSlide:0,speed:300,cssMode:!1,updateOnWindowResize:!0,resizeObserver:!0,nested:!1,createElements:!1,eventsPrefix:"swiper",enabled:!0,focusableElements:"input, select, option, textarea, button, video, label",width:null,height:null,preventInteractionOnTransition:!1,userAgent:null,url:null,edgeSwipeDetection:!1,edgeSwipeThreshold:20,autoHeight:!1,setWrapperSize:!1,virtualTranslate:!1,effect:"slide",breakpoints:void 0,breakpointsBase:"window",spaceBetween:0,slidesPerView:1,slidesPerGroup:1,slidesPerGroupSkip:0,slidesPerGroupAuto:!1,centeredSlides:!1,centeredSlidesBounds:!1,slidesOffsetBefore:0,slidesOffsetAfter:0,normalizeSlideIndex:!0,centerInsufficientSlides:!1,snapToSlideEdge:!1,watchOverflow:!0,roundLengths:!1,touchRatio:1,touchAngle:45,simulateTouch:!0,shortSwipes:!0,longSwipes:!0,longSwipesRatio:.5,longSwipesMs:300,followFinger:!0,allowTouchMove:!0,threshold:5,touchMoveStopPropagation:!1,touchStartPreventDefault:!0,touchStartForcePreventDefault:!1,touchReleaseOnEdges:!1,uniqueNavElements:!0,resistance:!0,resistanceRatio:.85,watchSlidesProgress:!1,grabCursor:!1,preventClicks:!0,preventClicksPropagation:!0,slideToClickedSlide:!1,loop:!1,loopAddBlankSlides:!0,loopAdditionalSlides:0,loopPreventsSliding:!0,rewind:!1,allowSlidePrev:!0,allowSlideNext:!0,swipeHandler:null,noSwiping:!0,noSwipingClass:"swiper-no-swiping",noSwipingSelector:null,passiveListeners:!0,maxBackfaceHiddenSlides:10,containerModifierClass:"swiper-",slideClass:"swiper-slide",slideBlankClass:"swiper-slide-blank",slideActiveClass:"swiper-slide-active",slideVisibleClass:"swiper-slide-visible",slideFullyVisibleClass:"swiper-slide-fully-visible",slideNextClass:"swiper-slide-next",slidePrevClass:"swiper-slide-prev",wrapperClass:"swiper-wrapper",lazyPreloaderClass:"swiper-lazy-preloader",lazyPreloadPrevNext:0,runCallbacksOnInit:!0,_emitClasses:!1};function CR(e,t){return function(i={}){var n=Object.keys(i)[0],a=i[n];"object"==typeof a&&null!==a?(!0===e[n]&&(e[n]={enabled:!0}),"navigation"===n&&e[n]&&e[n].enabled&&!e[n].prevEl&&!e[n].nextEl&&(e[n].auto=!0),["pagination","scrollbar"].indexOf(n)>=0&&e[n]&&e[n].enabled&&!e[n].el&&(e[n].auto=!0),n in e&&"enabled"in a?("object"!=typeof e[n]||"enabled"in e[n]||(e[n].enabled=!0),e[n]||(e[n]={enabled:!1}),z_(t,i)):z_(t,i)):z_(t,i)}}var IR={eventsEmitter:aR,update:dR,translate:hR,transition:{setTransition:function(e,t){var i=this;i.params.cssMode||(i.wrapperEl.style.transitionDuration=`${e}ms`,i.wrapperEl.style.transitionDelay=0===e?"0ms":""),i.emit("setTransition",e,t)},transitionStart:function(e=!0,t){var i=this,n=i.params;n.cssMode||(n.autoHeight&&i.updateAutoHeight(),cR({swiper:i,runCallbacks:e,direction:t,step:"Start"}))},transitionEnd:function(e=!0,t){var i=this,n=i.params;i.animating=!1,n.cssMode||(i.setTransition(0),cR({swiper:i,runCallbacks:e,direction:t,step:"End"}))}},slide:mR,loop:fR,grabCursor:vR,events:{attachEvents:function(){var e=this,t=e.params;e.onTouchStart=gR.bind(e),e.onTouchMove=yR.bind(e),e.onTouchEnd=bR.bind(e),e.onDocumentTouchStart=TR.bind(e),t.cssMode&&(e.onScroll=SR.bind(e)),e.onClick=kR.bind(e),e.onLoad=ER.bind(e),PR(e,"on")},detachEvents:function(){PR(this,"off")}},breakpoints:AR,checkOverflow:{checkOverflow:function(){var e=this,t=e.isLocked,i=e.params,n=i.slidesOffsetBefore;if(n){var a=e.slides.length-1,r=e.slidesGrid[a]+e.slidesSizesGrid[a]+2*n;e.isLocked=e.size>r}else e.isLocked=1===e.snapGrid.length;!0===i.allowSlideNext&&(e.allowSlideNext=!e.isLocked),!0===i.allowSlidePrev&&(e.allowSlidePrev=!e.isLocked),t&&t!==e.isLocked&&(e.isEnd=!1),t!==e.isLocked&&e.emit(e.isLocked?"lock":"unlock")}},classes:DR},LR={},_R=function(){function e(...t){var i,n;u(this,e),1===t.length&&t[0].constructor&&"Object"===Object.prototype.toString.call(t[0]).slice(8,-1)?n=t[0]:(i=t[0],n=t[1]),n||(n={}),n=z_({},n),i&&!n.el&&(n.el=i);var a=I_();if(n.el&&"string"==typeof n.el&&a.querySelectorAll(n.el).length>1){var r=[];return a.querySelectorAll(n.el).forEach(t=>{var i=z_({},n,{el:t});r.push(new e(i))}),r}var o=this;o.__swiper__=!0,o.support=tR(),o.device=iR({userAgent:n.userAgent}),o.browser=nR(),o.eventsListeners={},o.eventsAnyListeners=[],o.modules=[...o.__modules__],n.modules&&Array.isArray(n.modules)&&n.modules.forEach(e=>{"function"==typeof e&&o.modules.indexOf(e)<0&&o.modules.push(e)});var s={};o.modules.forEach(e=>{e({params:n,swiper:o,extendParams:CR(n,s),on:o.on.bind(o),once:o.once.bind(o),off:o.off.bind(o),emit:o.emit.bind(o)})});var l=z_({},xR,s);return o.params=z_({},l,LR,n),o.originalParams=z_({},o.params),o.passedParams=z_({},n),o.params&&o.params.on&&Object.keys(o.params.on).forEach(e=>{o.on(e,o.params.on[e])}),o.params&&o.params.onAny&&o.onAny(o.params.onAny),Object.assign(o,{enabled:o.params.enabled,el:i,classNames:[],slides:[],slidesGrid:[],snapGrid:[],slidesSizesGrid:[],isHorizontal:()=>"horizontal"===o.params.direction,isVertical:()=>"vertical"===o.params.direction,activeIndex:0,realIndex:0,isBeginning:!0,isEnd:!1,translate:0,previousTranslate:0,progress:0,velocity:0,animating:!1,cssOverflowAdjustment(){return Math.trunc(this.translate/2**23)*2**23},allowSlideNext:o.params.allowSlideNext,allowSlidePrev:o.params.allowSlidePrev,touchEventsData:{isTouched:void 0,isMoved:void 0,allowTouchCallbacks:void 0,touchStartTime:void 0,isScrolling:void 0,currentTranslate:void 0,startTranslate:void 0,allowThresholdMove:void 0,focusableElements:o.params.focusableElements,lastClickTime:0,clickTimeout:void 0,velocities:[],allowMomentumBounce:void 0,startMoving:void 0,pointerId:null,touchId:null},allowClick:!0,allowTouchMove:o.params.allowTouchMove,touches:{startX:0,startY:0,currentX:0,currentY:0,diff:0},imagesToLoad:[],imagesLoaded:0}),o.emit("_swiper"),o.params.init&&o.init(),o}return m(e,[{key:"getDirectionLabel",value:function(e){return this.isHorizontal()?e:{width:"height","margin-top":"margin-left","margin-bottom ":"margin-right","margin-left":"margin-top","margin-right":"margin-bottom","padding-left":"padding-top","padding-right":"padding-bottom",marginRight:"marginBottom"}[e]}},{key:"getSlideIndex",value:function(e){var t=q_(V_(this.slidesEl,`.${this.params.slideClass}, swiper-slide`)[0]);return q_(e)-t}},{key:"getSlideIndexByData",value:function(e){return this.getSlideIndex(this.slides.find(t=>1*t.getAttribute("data-swiper-slide-index")===e))}},{key:"getSlideIndexWhenGrid",value:function(e){return this.grid&&this.params.grid&&this.params.grid.rows>1&&("column"===this.params.grid.fill?e=Math.floor(e/this.params.grid.rows):"row"===this.params.grid.fill&&(e%=Math.ceil(this.slides.length/this.params.grid.rows))),e}},{key:"recalcSlides",value:function(){var e=this,t=e.slidesEl,i=e.params;e.slides=V_(t,`.${i.slideClass}, swiper-slide`)}},{key:"enable",value:function(){var e=this;e.enabled||(e.enabled=!0,e.params.grabCursor&&e.setGrabCursor(),e.emit("enable"))}},{key:"disable",value:function(){var e=this;e.enabled&&(e.enabled=!1,e.params.grabCursor&&e.unsetGrabCursor(),e.emit("disable"))}},{key:"setProgress",value:function(e,t){var i=this;e=Math.min(Math.max(e,0),1);var n=i.minTranslate(),a=(i.maxTranslate()-n)*e+n;i.translateTo(a,void 0===t?0:t),i.updateActiveIndex(),i.updateSlidesClasses()}},{key:"emitContainerClasses",value:function(){var e=this;if(e.params._emitClasses&&e.el){var t=e.el.className.split(" ").filter(t=>0===t.indexOf("swiper")||0===t.indexOf(e.params.containerModifierClass));e.emit("_containerClasses",t.join(" "))}}},{key:"getSlideClasses",value:function(e){var t=this;return t.destroyed?"":e.className.split(" ").filter(e=>0===e.indexOf("swiper-slide")||0===e.indexOf(t.params.slideClass)).join(" ")}},{key:"emitSlidesClasses",value:function(){var e=this;if(e.params._emitClasses&&e.el){var t=[];e.slides.forEach(i=>{var n=e.getSlideClasses(i);t.push({slideEl:i,classNames:n}),e.emit("_slideClass",i,n)}),e.emit("_slideClasses",t)}}},{key:"slidesPerViewDynamic",value:function(e="current",t=!1){var i=this,n=i.params,a=i.slides,r=i.slidesGrid,o=i.slidesSizesGrid,s=i.size,u=i.activeIndex,l=1;if("number"==typeof n.slidesPerView)return n.slidesPerView;if(n.centeredSlides){for(var d,h=a[u]?Math.ceil(a[u].swiperSlideSize):0,c=u+1;c<a.length;c+=1)a[c]&&!d&&(l+=1,(h+=Math.ceil(a[c].swiperSlideSize))>s&&(d=!0));for(var m=u-1;m>=0;m-=1)a[m]&&!d&&(l+=1,(h+=a[m].swiperSlideSize)>s&&(d=!0))}else if("current"===e)for(var f=u+1;f<a.length;f+=1){(t?r[f]+o[f]-r[u]<s:r[f]-r[u]<s)&&(l+=1)}else for(var v=u-1;v>=0;v-=1){r[u]-r[v]<s&&(l+=1)}return l}},{key:"update",value:function(){var e=this;if(e&&!e.destroyed){var t,i=e.snapGrid,n=e.params;if(n.breakpoints&&e.setBreakpoint(),[...e.el.querySelectorAll('[loading="lazy"]')].forEach(t=>{t.complete&&sR(e,t)}),e.updateSize(),e.updateSlides(),e.updateProgress(),e.updateSlidesClasses(),n.freeMode&&n.freeMode.enabled&&!n.cssMode)r(),n.autoHeight&&e.updateAutoHeight();else{if(("auto"===n.slidesPerView||n.slidesPerView>1)&&e.isEnd&&!n.centeredSlides){var a=e.virtual&&n.virtual.enabled?e.virtual.slides:e.slides;t=e.slideTo(a.length-1,0,!1,!0)}else t=e.slideTo(e.activeIndex,0,!1,!0);t||r()}n.watchOverflow&&i!==e.snapGrid&&e.checkOverflow(),e.emit("update")}function r(){var t=e.rtlTranslate?-1*e.translate:e.translate,i=Math.min(Math.max(t,e.maxTranslate()),e.minTranslate());e.setTranslate(i),e.updateActiveIndex(),e.updateSlidesClasses()}}},{key:"changeDirection",value:function(e,t=!0){var i=this,n=i.params.direction;return e||(e="horizontal"===n?"vertical":"horizontal"),e===n||"horizontal"!==e&&"vertical"!==e||(i.el.classList.remove(`${i.params.containerModifierClass}${n}`),i.el.classList.add(`${i.params.containerModifierClass}${e}`),i.emitContainerClasses(),i.params.direction=e,i.slides.forEach(t=>{"vertical"===e?t.style.width="":t.style.height=""}),i.emit("changeDirection"),t&&i.update()),i}},{key:"changeLanguageDirection",value:function(e){var t=this;t.rtl&&"rtl"===e||!t.rtl&&"ltr"===e||(t.rtl="rtl"===e,t.rtlTranslate="horizontal"===t.params.direction&&t.rtl,t.rtl?(t.el.classList.add(`${t.params.containerModifierClass}rtl`),t.el.dir="rtl"):(t.el.classList.remove(`${t.params.containerModifierClass}rtl`),t.el.dir="ltr"),t.update())}},{key:"mount",value:function(e){var t=this;if(t.mounted)return!0;var i=e||t.params.el;if("string"==typeof i&&(i=document.querySelector(i)),!i)return!1;i.swiper=t,i.parentNode&&i.parentNode.host&&i.parentNode.host.nodeName===t.params.swiperElementNodeName.toUpperCase()&&(t.isElement=!0);var n=()=>`.${(t.params.wrapperClass||"").trim().split(" ").join(".")}`,a=i&&i.shadowRoot&&i.shadowRoot.querySelector?i.shadowRoot.querySelector(n()):V_(i,n())[0];return!a&&t.params.createElements&&(a=X_("div",t.params.wrapperClass),i.append(a),V_(i,`.${t.params.slideClass}`).forEach(e=>{a.append(e)})),Object.assign(t,{el:i,wrapperEl:a,slidesEl:t.isElement&&!i.parentNode.host.slideSlots?i.parentNode.host:a,hostEl:t.isElement?i.parentNode.host:i,mounted:!0,rtl:"rtl"===i.dir.toLowerCase()||"rtl"===Y_(i,"direction"),rtlTranslate:"horizontal"===t.params.direction&&("rtl"===i.dir.toLowerCase()||"rtl"===Y_(i,"direction")),wrongRTL:"-webkit-box"===Y_(a,"display")}),!0}},{key:"init",value:function(e){var t=this;if(t.initialized)return t;if(!1===t.mount(e))return t;t.emit("beforeInit"),t.params.breakpoints&&t.setBreakpoint(),t.addClasses(),t.updateSize(),t.updateSlides(),t.params.watchOverflow&&t.checkOverflow(),t.params.grabCursor&&t.enabled&&t.setGrabCursor(),t.params.loop&&t.virtual&&t.params.virtual.enabled?t.slideTo(t.params.initialSlide+t.virtual.slidesBefore,0,t.params.runCallbacksOnInit,!1,!0):t.slideTo(t.params.initialSlide,0,t.params.runCallbacksOnInit,!1,!0),t.params.loop&&t.loopCreate(void 0,!0),t.attachEvents();var i=[...t.el.querySelectorAll('[loading="lazy"]')];return t.isElement&&i.push(...t.hostEl.querySelectorAll('[loading="lazy"]')),i.forEach(e=>{e.complete?sR(t,e):e.addEventListener("load",e=>{sR(t,e.target)})}),lR(t),t.initialized=!0,lR(t),t.emit("init"),t.emit("afterInit"),t}},{key:"destroy",value:function(e=!0,t=!0){var i=this,n=i.params,a=i.el,r=i.wrapperEl,o=i.slides;return void 0===i.params||i.destroyed||(i.emit("beforeDestroy"),i.initialized=!1,i.detachEvents(),n.loop&&i.loopDestroy(),t&&(i.removeClasses(),a&&"string"!=typeof a&&a.removeAttribute("style"),r&&r.removeAttribute("style"),o&&o.length&&o.forEach(e=>{e.classList.remove(n.slideVisibleClass,n.slideFullyVisibleClass,n.slideActiveClass,n.slideNextClass,n.slidePrevClass),e.removeAttribute("style"),e.removeAttribute("data-swiper-slide-index")})),i.emit("destroy"),Object.keys(i.eventsListeners).forEach(e=>{i.off(e)}),!1!==e&&(i.el&&"string"!=typeof i.el&&(i.el.swiper=null),function(e){var t=e;Object.keys(t).forEach(e=>{try{t[e]=null}catch(e){}try{delete t[e]}catch(e){}})}(i)),i.destroyed=!0),null}}],[{key:"extendDefaults",value:function(e){z_(LR,e)}},{key:"extendedDefaults",get:function(){return LR}},{key:"defaults",get:function(){return xR}},{key:"installModule",value:function(t){e.prototype.__modules__||(e.prototype.__modules__=[]);var i=e.prototype.__modules__;"function"==typeof t&&i.indexOf(t)<0&&i.push(t)}},{key:"use",value:function(t){return Array.isArray(t)?(t.forEach(t=>e.installModule(t)),e):(e.installModule(t),e)}}])}();function RR(e=""){return`.${e.trim().replace(/([\.:!+\/()[\]#>~*^$|=,'"@{}\\])/g,"\\$1").replace(/ /g,".")}`}function FR({swiper:e,extendParams:t,on:i,emit:n}){var a,r="swiper-pagination";t({pagination:{el:null,bulletElement:"span",clickable:!1,hideOnClick:!1,renderBullet:null,renderProgressbar:null,renderFraction:null,renderCustom:null,progressbarOpposite:!1,type:"bullets",dynamicBullets:!1,dynamicMainBullets:1,formatFractionCurrent:e=>e,formatFractionTotal:e=>e,bulletClass:`${r}-bullet`,bulletActiveClass:`${r}-bullet-active`,modifierClass:`${r}-`,currentClass:`${r}-current`,totalClass:`${r}-total`,hiddenClass:`${r}-hidden`,progressbarFillClass:`${r}-progressbar-fill`,progressbarOppositeClass:`${r}-progressbar-opposite`,clickableClass:`${r}-clickable`,lockClass:`${r}-lock`,horizontalClass:`${r}-horizontal`,verticalClass:`${r}-vertical`,paginationDisabledClass:`${r}-disabled`}}),e.pagination={el:null,bullets:[]};var o=0;function s(){return!e.params.pagination.el||!e.pagination.el||Array.isArray(e.pagination.el)&&0===e.pagination.el.length}function u(t,i){var n=e.params.pagination.bulletActiveClass;t&&(t=t[("prev"===i?"previous":"next")+"ElementSibling"])&&(t.classList.add(`${n}-${i}`),(t=t[("prev"===i?"previous":"next")+"ElementSibling"])&&t.classList.add(`${n}-${i}-${i}`))}function l(t){var i=t.target.closest(RR(e.params.pagination.bulletClass));if(i){t.preventDefault();var n,a,r,o=q_(i)*e.params.slidesPerGroup;if(e.params.loop){if(e.realIndex===o)return;var s=(n=e.realIndex,a=o,r=e.slides.length,(a%=r)===1+(n%=r)?"next":a===n-1?"previous":void 0);"next"===s?e.slideNext():"previous"===s?e.slidePrev():e.slideToLoop(o)}else e.slideTo(o)}}function d(){var t=e.rtl,i=e.params.pagination;if(!s()){var r,l,d=e.pagination.el;d=Z_(d);var h=e.virtual&&e.params.virtual.enabled?e.virtual.slides.length:e.slides.length,c=e.params.loop?Math.ceil(h/e.params.slidesPerGroup):e.snapGrid.length;if(e.params.loop?(l=e.previousRealIndex||0,r=e.params.slidesPerGroup>1?Math.floor(e.realIndex/e.params.slidesPerGroup):e.realIndex):void 0!==e.snapIndex?(r=e.snapIndex,l=e.previousSnapIndex):(l=e.previousIndex||0,r=e.activeIndex||0),"bullets"===i.type&&e.pagination.bullets&&e.pagination.bullets.length>0){var m,f,v,p=e.pagination.bullets;if(i.dynamicBullets&&(a=Q_(p[0],e.isHorizontal()?"width":"height"),d.forEach(t=>{t.style[e.isHorizontal()?"width":"height"]=a*(i.dynamicMainBullets+4)+"px"}),i.dynamicMainBullets>1&&void 0!==l&&((o+=r-(l||0))>i.dynamicMainBullets-1?o=i.dynamicMainBullets-1:o<0&&(o=0)),m=Math.max(r-o,0),v=((f=m+(Math.min(p.length,i.dynamicMainBullets)-1))+m)/2),p.forEach(e=>{var t=[...["","-next","-next-next","-prev","-prev-prev","-main"].map(e=>`${i.bulletActiveClass}${e}`)].map(e=>"string"==typeof e&&e.includes(" ")?e.split(" "):e).flat();e.classList.remove(...t)}),d.length>1)p.forEach(t=>{var n=q_(t);n===r?t.classList.add(...i.bulletActiveClass.split(" ")):e.isElement&&t.setAttribute("part","bullet"),i.dynamicBullets&&(n>=m&&n<=f&&t.classList.add(...`${i.bulletActiveClass}-main`.split(" ")),n===m&&u(t,"prev"),n===f&&u(t,"next"))});else{var g=p[r];if(g&&g.classList.add(...i.bulletActiveClass.split(" ")),e.isElement&&p.forEach((e,t)=>{e.setAttribute("part",t===r?"bullet-active":"bullet")}),i.dynamicBullets){for(var y=p[m],b=p[f],w=m;w<=f;w+=1)p[w]&&p[w].classList.add(...`${i.bulletActiveClass}-main`.split(" "));u(y,"prev"),u(b,"next")}}if(i.dynamicBullets){var k=Math.min(p.length,i.dynamicMainBullets+4),S=(a*k-a)/2-v*a,E=t?"right":"left";p.forEach(t=>{t.style[e.isHorizontal()?E:"top"]=`${S}px`})}}d.forEach((t,a)=>{if("fraction"===i.type&&(t.querySelectorAll(RR(i.currentClass)).forEach(e=>{e.textContent=i.formatFractionCurrent(r+1)}),t.querySelectorAll(RR(i.totalClass)).forEach(e=>{e.textContent=i.formatFractionTotal(c)})),"progressbar"===i.type){var o;o=i.progressbarOpposite?e.isHorizontal()?"vertical":"horizontal":e.isHorizontal()?"horizontal":"vertical";var s=(r+1)/c,u=1,l=1;"horizontal"===o?u=s:l=s,t.querySelectorAll(RR(i.progressbarFillClass)).forEach(t=>{t.style.transform=`translate3d(0,0,0) scaleX(${u}) scaleY(${l})`,t.style.transitionDuration=`${e.params.speed}ms`})}"custom"===i.type&&i.renderCustom?(eR(t,i.renderCustom(e,r+1,c)),0===a&&n("paginationRender",t)):(0===a&&n("paginationRender",t),n("paginationUpdate",t)),e.params.watchOverflow&&e.enabled&&t.classList[e.isLocked?"add":"remove"](i.lockClass)})}}function h(){var t=e.params.pagination;if(!s()){var i=e.virtual&&e.params.virtual.enabled?e.virtual.slides.length:e.grid&&e.params.grid.rows>1?e.slides.length/Math.ceil(e.params.grid.rows):e.slides.length,a=e.pagination.el;a=Z_(a);var r="";if("bullets"===t.type){var o=e.params.loop?Math.ceil(i/e.params.slidesPerGroup):e.snapGrid.length;e.params.freeMode&&e.params.freeMode.enabled&&o>i&&(o=i);for(var u=0;u<o;u+=1)t.renderBullet?r+=t.renderBullet.call(e,u,t.bulletClass):r+=`<${t.bulletElement} ${e.isElement?'part="bullet"':""} class="${t.bulletClass}"></${t.bulletElement}>`}"fraction"===t.type&&(r=t.renderFraction?t.renderFraction.call(e,t.currentClass,t.totalClass):`<span class="${t.currentClass}"></span> / <span class="${t.totalClass}"></span>`),"progressbar"===t.type&&(r=t.renderProgressbar?t.renderProgressbar.call(e,t.progressbarFillClass):`<span class="${t.progressbarFillClass}"></span>`),e.pagination.bullets=[],a.forEach(i=>{"custom"!==t.type&&eR(i,r||""),"bullets"===t.type&&e.pagination.bullets.push(...i.querySelectorAll(RR(t.bulletClass)))}),"custom"!==t.type&&n("paginationRender",a[0])}}function c(){e.params.pagination=function(e,t,i,n){return e.params.createElements&&Object.keys(n).forEach(a=>{if(!i[a]&&!0===i.auto){var r=V_(e.el,`.${n[a]}`)[0];r||((r=X_("div",n[a])).className=n[a],e.el.append(r)),i[a]=r,t[a]=r}}),i}(e,e.originalParams.pagination,e.params.pagination,{el:"swiper-pagination"});var t,i=e.params.pagination;i.el&&("string"==typeof i.el&&e.isElement&&(t=e.el.querySelector(i.el)),t||"string"!=typeof i.el||(t=[...document.querySelectorAll(i.el)]),t||(t=i.el),t&&0!==t.length&&(e.params.uniqueNavElements&&"string"==typeof i.el&&Array.isArray(t)&&t.length>1&&(t=[...e.el.querySelectorAll(i.el)]).length>1&&(t=t.find(t=>J_(t,".swiper")[0]===e.el)),Array.isArray(t)&&1===t.length&&(t=t[0]),Object.assign(e.pagination,{el:t}),(t=Z_(t)).forEach(t=>{"bullets"===i.type&&i.clickable&&t.classList.add(...(i.clickableClass||"").split(" ")),t.classList.add(i.modifierClass+i.type),t.classList.add(e.isHorizontal()?i.horizontalClass:i.verticalClass),"bullets"===i.type&&i.dynamicBullets&&(t.classList.add(`${i.modifierClass}${i.type}-dynamic`),o=0,i.dynamicMainBullets<1&&(i.dynamicMainBullets=1)),"progressbar"===i.type&&i.progressbarOpposite&&t.classList.add(i.progressbarOppositeClass),i.clickable&&t.addEventListener("click",l),e.enabled||t.classList.add(i.lockClass)})))}function m(){var t=e.params.pagination;if(!s()){var i=e.pagination.el;i&&(i=Z_(i)).forEach(i=>{i.classList.remove(t.hiddenClass),i.classList.remove(t.modifierClass+t.type),i.classList.remove(e.isHorizontal()?t.horizontalClass:t.verticalClass),t.clickable&&(i.classList.remove(...(t.clickableClass||"").split(" ")),i.removeEventListener("click",l))}),e.pagination.bullets&&e.pagination.bullets.forEach(e=>e.classList.remove(...t.bulletActiveClass.split(" ")))}}i("changeDirection",()=>{if(e.pagination&&e.pagination.el){var t=e.params.pagination,i=e.pagination.el;(i=Z_(i)).forEach(i=>{i.classList.remove(t.horizontalClass,t.verticalClass),i.classList.add(e.isHorizontal()?t.horizontalClass:t.verticalClass)})}}),i("init",()=>{!1===e.params.pagination.enabled?f():(c(),h(),d())}),i("activeIndexChange",()=>{void 0===e.snapIndex&&d()}),i("snapIndexChange",()=>{d()}),i("snapGridLengthChange",()=>{h(),d()}),i("destroy",()=>{m()}),i("enable disable",()=>{var t=e.pagination.el;t&&(t=Z_(t)).forEach(t=>t.classList[e.enabled?"remove":"add"](e.params.pagination.lockClass))}),i("lock unlock",()=>{d()}),i("click",(t,i)=>{var a=i.target,r=Z_(e.pagination.el);if(e.params.pagination.el&&e.params.pagination.hideOnClick&&r&&r.length>0&&!a.classList.contains(e.params.pagination.bulletClass)){if(e.navigation&&(e.navigation.nextEl&&a===e.navigation.nextEl||e.navigation.prevEl&&a===e.navigation.prevEl))return;var o=r[0].classList.contains(e.params.pagination.hiddenClass);n(!0===o?"paginationShow":"paginationHide"),r.forEach(t=>t.classList.toggle(e.params.pagination.hiddenClass))}});var f=()=>{e.el.classList.add(e.params.pagination.paginationDisabledClass);var t=e.pagination.el;t&&(t=Z_(t)).forEach(t=>t.classList.add(e.params.pagination.paginationDisabledClass)),m()};Object.assign(e.pagination,{enable:()=>{e.el.classList.remove(e.params.pagination.paginationDisabledClass);var t=e.pagination.el;t&&(t=Z_(t)).forEach(t=>t.classList.remove(e.params.pagination.paginationDisabledClass)),c(),h(),d()},disable:f,render:h,update:d,init:c,destroy:m})}function OR({swiper:e,extendParams:t,on:i,emit:n,params:a}){var r,o;e.autoplay={running:!1,paused:!1,timeLeft:0},t({autoplay:{enabled:!1,delay:3e3,waitForTransition:!0,disableOnInteraction:!1,stopOnLastSlide:!1,reverseDirection:!1,pauseOnMouseEnter:!1}});var s,u,l,d,h,c,m,f=a&&a.autoplay?a.autoplay.delay:3e3,v=a&&a.autoplay?a.autoplay.delay:3e3,p=(new Date).getTime();function g(t){e&&!e.destroyed&&e.wrapperEl&&t.target===e.wrapperEl&&(e.wrapperEl.removeEventListener("transitionend",g),m||t.detail&&t.detail.bySwiperTouchMove||T())}var y=()=>{if(!e.destroyed&&e.autoplay.running){e.autoplay.paused?u=!0:u&&(v=s,u=!1);var t=e.autoplay.paused?s:p+v-(new Date).getTime();e.autoplay.timeLeft=t,n("autoplayTimeLeft",t,t/f),o=requestAnimationFrame(()=>{y()})}},b=()=>{var t=e.params.autoplay.delay,i=(()=>{var t;if(t=e.virtual&&e.params.virtual.enabled?e.slides.find(e=>e.classList.contains("swiper-slide-active")):e.slides[e.activeIndex])return parseInt(t.getAttribute("data-swiper-autoplay"),10)})();return!Number.isNaN(i)&&i>0&&(t=i),t},w=t=>{if(!e.destroyed&&e.autoplay.running){cancelAnimationFrame(o),y();var i=t;void 0===i&&(i=b(),f=i,v=i),s=i;var a=e.params.speed,u=()=>{e&&!e.destroyed&&(e.params.autoplay.reverseDirection?!e.isBeginning||e.params.loop||e.params.rewind?(e.slidePrev(a,!0,!0),n("autoplay")):e.params.autoplay.stopOnLastSlide||(e.slideTo(e.slides.length-1,a,!0,!0),n("autoplay")):!e.isEnd||e.params.loop||e.params.rewind?(e.slideNext(a,!0,!0),n("autoplay")):e.params.autoplay.stopOnLastSlide||(e.slideTo(0,a,!0,!0),n("autoplay")),e.params.cssMode&&(p=(new Date).getTime(),requestAnimationFrame(()=>{w()})))};return i>0?(clearTimeout(r),r=setTimeout(()=>{u()},i)):requestAnimationFrame(()=>{u()}),i}},k=()=>{p=(new Date).getTime(),e.autoplay.running=!0,w(),n("autoplayStart")},S=()=>{e.autoplay.running=!1,clearTimeout(r),cancelAnimationFrame(o),n("autoplayStop")},E=(t,i)=>{if(!e.destroyed&&e.autoplay.running){clearTimeout(r),t||(c=!0);var a=()=>{n("autoplayPause"),e.params.autoplay.waitForTransition?e.wrapperEl.addEventListener("transitionend",g):T()};if(e.autoplay.paused=!0,i)a();else{var o=s||e.params.autoplay.delay;s=o-((new Date).getTime()-p),e.isEnd&&s<0&&!e.params.loop||(s<0&&(s=0),a())}}},T=()=>{e.isEnd&&s<0&&!e.params.loop||e.destroyed||!e.autoplay.running||(p=(new Date).getTime(),c?(c=!1,w(s)):w(),e.autoplay.paused=!1,n("autoplayResume"))},P=()=>{if(!e.destroyed&&e.autoplay.running){var t=I_();"hidden"===t.visibilityState&&(c=!0,E(!0)),"visible"===t.visibilityState&&T()}},M=t=>{"mouse"===t.pointerType&&(c=!0,m=!0,e.animating||e.autoplay.paused||E(!0))},A=t=>{"mouse"===t.pointerType&&(m=!1,e.autoplay.paused&&T())};i("init",()=>{e.params.autoplay.enabled&&(e.params.autoplay.pauseOnMouseEnter&&(e.el.addEventListener("pointerenter",M),e.el.addEventListener("pointerleave",A)),I_().addEventListener("visibilitychange",P),k())}),i("destroy",()=>{e.el&&"string"!=typeof e.el&&(e.el.removeEventListener("pointerenter",M),e.el.removeEventListener("pointerleave",A)),I_().removeEventListener("visibilitychange",P),e.autoplay.running&&S()}),i("_freeModeStaticRelease",()=>{(d||c)&&T()}),i("_freeModeNoMomentumRelease",()=>{e.params.autoplay.disableOnInteraction?S():E(!0,!0)}),i("beforeTransitionStart",(t,i,n)=>{!e.destroyed&&e.autoplay.running&&(n||!e.params.autoplay.disableOnInteraction?E(!0,!0):S())}),i("sliderFirstMove",()=>{!e.destroyed&&e.autoplay.running&&(e.params.autoplay.disableOnInteraction?S():(l=!0,d=!1,c=!1,h=setTimeout(()=>{c=!0,d=!0,E(!0)},200)))}),i("touchEnd",()=>{if(!e.destroyed&&e.autoplay.running&&l){if(clearTimeout(h),clearTimeout(r),e.params.autoplay.disableOnInteraction)return d=!1,void(l=!1);d&&e.params.cssMode&&T(),d=!1,l=!1}}),i("slideChange",()=>{!e.destroyed&&e.autoplay.running&&e.autoplay.paused&&(s=b(),f=b())}),Object.assign(e.autoplay,{start:k,stop:S,pause:E,resume:T})}function WR(e,t){var i=G_(t);return i!==t&&(i.style.backfaceVisibility="hidden",i.style["-webkit-backface-visibility"]="hidden"),i}function $R(e,t,i){var n=`swiper-slide-shadow${i?`-${i}`:""} swiper-slide-shadow-${e}`,a=G_(t),r=a.querySelector(`.${n.split(" ").join(".")}`);return r||(r=X_("div",n.split(" ")),a.append(r)),r}function NR({swiper:e,extendParams:t,on:i}){t({coverflowEffect:{rotate:50,stretch:0,depth:100,scale:1,modifier:1,slideShadows:!0}});!function(e){var t,i=e.effect,n=e.swiper,a=e.on,r=e.setTranslate,o=e.setTransition,s=e.overwriteParams,u=e.perspective,l=e.recreateShadows,d=e.getEffectParams;a("beforeInit",()=>{if(n.params.effect===i){n.classNames.push(`${n.params.containerModifierClass}${i}`),u&&u()&&n.classNames.push(`${n.params.containerModifierClass}3d`);var e=s?s():{};Object.assign(n.params,e),Object.assign(n.originalParams,e)}}),a("setTranslate _virtualUpdated",()=>{n.params.effect===i&&r()}),a("setTransition",(e,t)=>{n.params.effect===i&&o(t)}),a("transitionEnd",()=>{if(n.params.effect===i&&l){if(!d||!d().slideShadows)return;n.slides.forEach(e=>{e.querySelectorAll(".swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left").forEach(e=>e.remove())}),l()}}),a("virtualUpdate",()=>{n.params.effect===i&&(n.slides.length||(t=!0),requestAnimationFrame(()=>{t&&n.slides&&n.slides.length&&(r(),t=!1)}))})}({effect:"coverflow",swiper:e,on:i,setTranslate:()=>{for(var t=e.width,i=e.height,n=e.slides,a=e.slidesSizesGrid,r=e.params.coverflowEffect,o=e.isHorizontal(),s=e.translate,u=o?t/2-s:i/2-s,l=o?r.rotate:-r.rotate,d=r.depth,h=function(e){return t=>Math.abs(t)>0&&e.browser&&e.browser.need3dFix&&Math.abs(t)%90==0?t+.001:t}(e),c=0,m=n.length;c<m;c+=1){var f=n[c],v=a[c],p=(u-f.swiperSlideOffset-v/2)/v,g="function"==typeof r.modifier?r.modifier(p):p*r.modifier,y=o?l*g:0,b=o?0:l*g,w=-d*Math.abs(g),k=r.stretch;"string"==typeof k&&-1!==k.indexOf("%")&&(k=parseFloat(r.stretch)/100*v);var S=o?0:k*g,E=o?k*g:0,T=1-(1-r.scale)*Math.abs(g);Math.abs(E)<.001&&(E=0),Math.abs(S)<.001&&(S=0),Math.abs(w)<.001&&(w=0),Math.abs(y)<.001&&(y=0),Math.abs(b)<.001&&(b=0),Math.abs(T)<.001&&(T=0);var P=`translate3d(${E}px,${S}px,${w}px) rotateX(${h(b)}deg) rotateY(${h(y)}deg) scale(${T})`;if(WR(0,f).style.transform=P,f.style.zIndex=1-Math.abs(Math.round(g)),r.slideShadows){var M=o?f.querySelector(".swiper-slide-shadow-left"):f.querySelector(".swiper-slide-shadow-top"),A=o?f.querySelector(".swiper-slide-shadow-right"):f.querySelector(".swiper-slide-shadow-bottom");M||(M=$R("coverflow",f,o?"left":"top")),A||(A=$R("coverflow",f,o?"right":"bottom")),M&&(M.style.opacity=g>0?g:0),A&&(A.style.opacity=-g>0?-g:0)}}},setTransition:t=>{e.slides.map(e=>G_(e)).forEach(e=>{e.style.transitionDuration=`${t}ms`,e.querySelectorAll(".swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left").forEach(e=>{e.style.transitionDuration=`${t}ms`})})},perspective:()=>!0,overwriteParams:()=>({watchSlidesProgress:!0})})}Object.keys(IR).forEach(e=>{Object.keys(IR[e]).forEach(t=>{_R.prototype[t]=IR[e][t]})}),_R.use([function({swiper:e,on:t,emit:i}){var n=O_(),a=null,r=null,o=()=>{e&&!e.destroyed&&e.initialized&&(i("beforeResize"),i("resize"))},s=()=>{e&&!e.destroyed&&e.initialized&&i("orientationchange")};t("init",()=>{e.params.resizeObserver&&void 0!==n.ResizeObserver?e&&!e.destroyed&&e.initialized&&(a=new ResizeObserver(t=>{r=n.requestAnimationFrame(()=>{var i=e.width,n=e.height,a=i,r=n;t.forEach(({contentBoxSize:t,contentRect:i,target:n})=>{n&&n!==e.el||(a=i?i.width:(t[0]||t).inlineSize,r=i?i.height:(t[0]||t).blockSize)}),a===i&&r===n||o()})})).observe(e.el):(n.addEventListener("resize",o),n.addEventListener("orientationchange",s))}),t("destroy",()=>{r&&n.cancelAnimationFrame(r),a&&a.unobserve&&e.el&&(a.unobserve(e.el),a=null),n.removeEventListener("resize",o),n.removeEventListener("orientationchange",s)})},function({swiper:e,extendParams:t,on:i,emit:n}){var a=[],r=O_(),o=(t,i={})=>{var o=new(r.MutationObserver||r.WebkitMutationObserver)(t=>{if(!e.__preventObserver__)if(1!==t.length){var i=function(){n("observerUpdate",t[0])};r.requestAnimationFrame?r.requestAnimationFrame(i):r.setTimeout(i,0)}else n("observerUpdate",t[0])});o.observe(t,{attributes:void 0===i.attributes||i.attributes,childList:e.isElement||(void 0===i.childList||i).childList,characterData:void 0===i.characterData||i.characterData}),a.push(o)};t({observer:!1,observeParents:!1,observeSlideChildren:!1}),i("init",()=>{if(e.params.observer){if(e.params.observeParents)for(var t=J_(e.hostEl),i=0;i<t.length;i+=1)o(t[i]);o(e.hostEl,{childList:e.params.observeSlideChildren}),o(e.wrapperEl,{attributes:!1})}}),i("destroy",()=>{a.forEach(e=>{e.disconnect()}),a.splice(0,a.length)})}]);var jR,BR,zR=e=>e,UR=function(){function i(){var e;return u(this,i),(e=s(this,i,arguments)).inFocusedState=!1,e.scaleFactor=1,e.updateSpacing=t=>{e.slideSpacing=t.detail.spacing,e.swiperInstance&&(e.swiperInstance.params.spaceBetween=e.slideSpacing,e.swiperInstance.update())},e}return y(i,bs),m(i,[{key:"connectedCallback",value:function(){M(i,"connectedCallback",this)([]),window.addEventListener("child-spacing",this.updateSpacing,!1)}},{key:"disconnectedCallback",value:function(){M(i,"disconnectedCallback",this)([]),window.removeEventListener("child-spacing",this.updateSpacing,!1)}},{key:"styles",value:function(){var e,i,n,a=this.scaleFactor,r=this.component,o=r.backgroundBlur,s=r.indicator,u=r.activeIndicator,l=r.previousSlidePadding,d=r.nextSlidePadding,h="vertical"===r.direction?"margin-top":"margin-left";return t.unsafeCSS(`\n :host {\n display: ${r.hidden?"none":"flex"};\n flex-direction: column !important;\n ${Ys(r.position)} \n width: 100%;\n bottom: -1px;\n background-repeat: no-repeat;\n background-size: cover;\n background-position: center;\n ${o?`backdrop-filter: blur(${o}px);`:""}\n z-index: ${null!==(e=r.zIndex)&&void 0!==e?e:1};\n top: 0px;\n transition: all 0.3s;\n ${Ns(r,a)}\n ${function(e,t){return`\n padding-right: ${xs(t,e.nextSlidePadding)}px !important;\n padding-left: ${xs(t,e.previousSlidePadding)}px !important;\n `}(r,a)}\n ${Fs(r)}\n ${Rs(r,!1)}\n max-width: 100vw;\n }\n :host(:focus){\n ${Rs(r,!0)}\n ${Ks(r,a,!0)}\n }\n :host(:focus-visible){\n ${Zs(r)}\n }\n :host > *:not(:first-child) {\n ${h}: ${r.spacing?r.spacing*a:0}px;\n }\n .swiper-container {\n ${zs(r,a)};\n padding-left: ${null!=l?l:0}px;\n padding-right: ${null!=d?d:0}px;\n box-sizing: border-box;\n }\n .swiper-pagination{\n position: relative;\n padding: 8px;\n }\n .swiper-pagination-bullet {\n opacity: 1 !important;\n ${null!=(null==s?void 0:s.width)?`width: ${s.width}px !important;`:""}\n ${null!=(null==s?void 0:s.height)?`height: ${s.height}px !important;`:""}\n ${null!=(null==s?void 0:s.borderRadius)?`border-radius: ${s.borderRadius}px !important;`:""}\n background: ${null!==(i=null==s?void 0:s.fillColor)&&void 0!==i?i:r.indicatorColor} !important;\n }\n .swiper-pagination-bullet-active {\n ${null!=(null==u?void 0:u.width)?`width: ${u.width}px !important;`:""}\n ${null!=(null==u?void 0:u.height)?`height: ${u.height}px !important;`:""}\n ${null!=(null==u?void 0:u.borderRadius)?`border-radius: ${u.borderRadius}px !important;`:""}\n background: ${null!==(n=null==u?void 0:u.fillColor)&&void 0!==n?n:r.activeIndicatorColor} !important;\n }\n `)}},{key:"updated",value:function(){var e,t,i=[FR,OR],n=this.component,a=n.autoplay,r=n.autoplaySeconds,o=n.showIndicators,s=n.slideSpacing,u=n.inactiveSlideScale;u&&i.push(NR),_R.use(i);var l=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector(".swiper-container"),d=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector(".swiper-pagination");if(l&&!this.swiperInstance){var h,c={initialSlide:0,slidesPerView:1,loop:a,spaceBetween:null!==(h=null!=s?s:this.slideSpacing)&&void 0!==h?h:0,autoplay:!!a&&{delay:1e3*r,disableOnInteraction:!1},pagination:!(null!=o&&!o)&&{el:d,clickable:!0},on:{init:e=>{this.handleSlideChange(e)},slideChange:e=>{this.handleSlideChange(e)}}};u&&(c.effect="coverflow",c.coverflowEffect={rotate:0,stretch:0,depth:100,modifier:1,slideShadows:!1,scale:u}),this.swiperInstance=new _R(l,c)}}},{key:"handleSlideChange",value:function(e){if(this.contextProvider.setCurrentSlideIndex(e.realIndex),this.component.onChange){var t,i=this.getCarouselOnChange(this.component),n=null==i||null===(t=i.parameters)||void 0===t||null===(t=t.partialState)||void 0===t?void 0:t.currentGroupId;n&&this.contextProvider.setCurrentGroupData(n,"")}}},{key:"getCarouselOnChange",value:function(e){var t;if(e.onChange&&e.onChange.parameters){var i=this.contextProvider.state.slides,n="string"==typeof e.loopSource?e.loopSource:"",a=null==i||null===(t=i[n])||void 0===t||null===(t=t.carouselName)||void 0===t?void 0:t[this.contextProvider.state.currentSlideIndex];return Gn(e.onChange,{slide:a,sku:this.contextProvider.state.sku,state:this.contextProvider.state,launch:this.contextProvider.state.launch,customer:this.contextProvider.state.customer})}}},{key:"getCarouselSlides",value:function(t){var i,n;if(!t.loopSource)return[];var a,r=this.contextProvider.state,o=r.slides,s=r.selectedProducts,u="string"==typeof t.loopSource?t.loopSource:"",l=Nn(this.contextProvider.productDetails,null!==(i=null===(n=this.contextProvider.getSelectedPaywall())||void 0===n?void 0:n.sku_menus)&&void 0!==i?i:[],u),d=[];e.empty(o)||(d=""!=u?o[u].carouselName:null!==(a=t.loopSource)&&void 0!==a?a:[]);var h=this.contextProvider.filteredSkuMenus.map(e=>e.id);return d.filter(e=>!e.productGroupId||h.includes(e.productGroupId)).map(e=>{var i=l.find(t=>t.id==s[e.productGroupId]);return Gn(t.components,Gn({slide:e},{sku:v({},Bn(null==i?void 0:i.product_details,e,l))}))||[]})}},{key:"render",value:function(){var e=this.getCarouselSlides(this.component),i=this.component,n=i.focusedBorderColor,a=i.focusedFillColor,r=i.fillColor;return!n&&na(r,a)||(this.tabIndex=0),t.html(jR||(jR=zR`
|
|
513
|
+
`),e.header?t.html(M_||(M_=A_`<div class="nami-group-header">${0}</div>`),e.header.map(r)):null,e.items.map(e=>e.map(r))))}}])}();function x_(e){return null!==e&&"object"==typeof e&&"constructor"in e&&e.constructor===Object}function C_(e={},t={}){var i=["__proto__","constructor","prototype"];Object.keys(t).filter(e=>i.indexOf(e)<0).forEach(i=>{void 0===e[i]?e[i]=t[i]:x_(t[i])&&x_(e[i])&&Object.keys(t[i]).length>0&&C_(e[i],t[i])})}Ae([ot({type:Object})],D_.prototype,"component",void 0),Ae([ot({type:Boolean})],D_.prototype,"inFocusedState",void 0),Ae([ot({type:Number})],D_.prototype,"scaleFactor",void 0),Ae([ot({type:Object})],D_.prototype,"minSDKVersion",void 0),D_=Ae([Fe("nami-repeating-grid")],D_);var I_={body:{},addEventListener(){},removeEventListener(){},activeElement:{blur(){},nodeName:""},querySelector:()=>null,querySelectorAll:()=>[],getElementById:()=>null,createEvent:()=>({initEvent(){}}),createElement:()=>({children:[],childNodes:[],style:{},setAttribute(){},getElementsByTagName:()=>[]}),createElementNS:()=>({}),importNode:()=>null,location:{hash:"",host:"",hostname:"",href:"",origin:"",pathname:"",protocol:"",search:""}};function L_(){var e="undefined"!=typeof document?document:{};return C_(e,I_),e}var __,R_,F_,O_={document:I_,navigator:{userAgent:""},location:{hash:"",host:"",hostname:"",href:"",origin:"",pathname:"",protocol:"",search:""},history:{replaceState(){},pushState(){},go(){},back(){}},CustomEvent:function(){return this},addEventListener(){},removeEventListener(){},getComputedStyle:()=>({getPropertyValue:()=>""}),Image(){},Date(){},screen:{},setTimeout(){},clearTimeout(){},matchMedia:()=>({}),requestAnimationFrame:e=>"undefined"==typeof setTimeout?(e(),null):setTimeout(e,0),cancelAnimationFrame(e){"undefined"!=typeof setTimeout&&clearTimeout(e)}};function W_(){var e="undefined"!=typeof window?window:{};return C_(e,O_),e}function $_(e,t=0){return setTimeout(e,t)}function N_(){return Date.now()}function j_(e,t="x"){var i,n,a,r=W_(),o=function(e){var t,i=W_();return i.getComputedStyle&&(t=i.getComputedStyle(e,null)),!t&&e.currentStyle&&(t=e.currentStyle),t||(t=e.style),t}(e);return r.WebKitCSSMatrix?((n=o.transform||o.webkitTransform).split(",").length>6&&(n=n.split(", ").map(e=>e.replace(",",".")).join(", ")),a=new r.WebKitCSSMatrix("none"===n?"":n)):i=(a=o.MozTransform||o.OTransform||o.MsTransform||o.msTransform||o.transform||o.getPropertyValue("transform").replace("translate(","matrix(1, 0, 0, 1,")).toString().split(","),"x"===t&&(n=r.WebKitCSSMatrix?a.m41:16===i.length?parseFloat(i[12]):parseFloat(i[4])),"y"===t&&(n=r.WebKitCSSMatrix?a.m42:16===i.length?parseFloat(i[13]):parseFloat(i[5])),n||0}function B_(e){return"object"==typeof e&&null!==e&&e.constructor&&"Object"===Object.prototype.toString.call(e).slice(8,-1)}function z_(e){return"undefined"!=typeof window&&void 0!==window.HTMLElement?e instanceof HTMLElement:e&&(1===e.nodeType||11===e.nodeType)}function U_(...e){for(var t=Object(e[0]),i=1;i<e.length;i+=1){var n=e[i];if(null!=n&&!z_(n))for(var a=Object.keys(Object(n)).filter(e=>"__proto__"!==e&&"constructor"!==e&&"prototype"!==e),r=0,o=a.length;r<o;r+=1){var s=a[r],u=Object.getOwnPropertyDescriptor(n,s);void 0!==u&&u.enumerable&&(B_(t[s])&&B_(n[s])?n[s].__swiper__?t[s]=n[s]:U_(t[s],n[s]):!B_(t[s])&&B_(n[s])?(t[s]={},n[s].__swiper__?t[s]=n[s]:U_(t[s],n[s])):t[s]=n[s])}}return t}function H_(e,t,i){e.style.setProperty(t,i)}function G_({swiper:e,targetPosition:t,side:i}){var n,a=W_(),r=-e.translate,o=null,s=e.params.speed;e.wrapperEl.style.scrollSnapType="none",a.cancelAnimationFrame(e.cssModeFrameID);var u=t>r?"next":"prev",l=(e,t)=>"next"===u&&e>=t||"prev"===u&&e<=t,d=()=>{n=(new Date).getTime(),null===o&&(o=n);var u=Math.max(Math.min((n-o)/s,1),0),h=.5-Math.cos(u*Math.PI)/2,c=r+h*(t-r);if(l(c,t)&&(c=t),e.wrapperEl.scrollTo({[i]:c}),l(c,t))return e.wrapperEl.style.overflow="hidden",e.wrapperEl.style.scrollSnapType="",setTimeout(()=>{e.wrapperEl.style.overflow="",e.wrapperEl.scrollTo({[i]:c})}),void a.cancelAnimationFrame(e.cssModeFrameID);e.cssModeFrameID=a.requestAnimationFrame(d)};d()}function V_(e){return e.querySelector(".swiper-slide-transform")||e.shadowRoot&&e.shadowRoot.querySelector(".swiper-slide-transform")||e}function K_(e,t=""){var i=W_(),n=[...e.children];return i.HTMLSlotElement&&e instanceof HTMLSlotElement&&n.push(...e.assignedElements()),t?n.filter(e=>e.matches(t)):n}function X_(e){try{return void console.warn(e)}catch(e){}}function Y_(e,t=[]){var i=document.createElement(e);return i.classList.add(...Array.isArray(t)?t:function(e=""){return e.trim().split(" ").filter(e=>!!e.trim())}(t)),i}function q_(e,t){return W_().getComputedStyle(e,null).getPropertyValue(t)}function J_(e){var t,i=e;if(i){for(t=0;null!==(i=i.previousSibling);)1===i.nodeType&&(t+=1);return t}}function Q_(e,t){for(var i=[],n=e.parentElement;n;)t?n.matches(t)&&i.push(n):i.push(n),n=n.parentElement;return i}function Z_(e,t,i){var n=W_();return e["width"===t?"offsetWidth":"offsetHeight"]+parseFloat(n.getComputedStyle(e,null).getPropertyValue("width"===t?"margin-right":"margin-top"))+parseFloat(n.getComputedStyle(e,null).getPropertyValue("width"===t?"margin-left":"margin-bottom"))}function eR(e){return(Array.isArray(e)?e:[e]).filter(e=>!!e)}function tR(e,t=""){"undefined"!=typeof trustedTypes?e.innerHTML=trustedTypes.createPolicy("html",{createHTML:e=>e}).createHTML(t):e.innerHTML=t}function iR(){return __||(__=function(){var e=W_(),t=L_();return{smoothScroll:t.documentElement&&t.documentElement.style&&"scrollBehavior"in t.documentElement.style,touch:!!("ontouchstart"in e||e.DocumentTouch&&t instanceof e.DocumentTouch)}}()),__}function nR(e={}){return R_||(R_=function({userAgent:e}={}){var t=iR(),i=W_(),n=i.navigator.platform,a=e||i.navigator.userAgent,r={ios:!1,android:!1},o=i.screen.width,s=i.screen.height,u=a.match(/(Android);?[\s\/]+([\d.]+)?/),l=a.match(/(iPad)(?!\1).*OS\s([\d_]+)/),d=a.match(/(iPod)(.*OS\s([\d_]+))?/),h=!l&&a.match(/(iPhone\sOS|iOS)\s([\d_]+)/),c="Win32"===n,m="MacIntel"===n;return!l&&m&&t.touch&&["1024x1366","1366x1024","834x1194","1194x834","834x1112","1112x834","768x1024","1024x768","820x1180","1180x820","810x1080","1080x810"].indexOf(`${o}x${s}`)>=0&&((l=a.match(/(Version)\/([\d.]+)/))||(l=[0,1,"13_0_0"]),m=!1),u&&!c&&(r.os="android",r.android=!0),(l||h||d)&&(r.os="ios",r.ios=!0),r}(e)),R_}function aR(){return F_||(F_=function(){var e=W_(),t=nR(),i=!1;function n(){var t=e.navigator.userAgent.toLowerCase();return t.indexOf("safari")>=0&&t.indexOf("chrome")<0&&t.indexOf("android")<0}if(n()){var a=String(e.navigator.userAgent);if(a.includes("Version/")){var r=a.split("Version/")[1].split(" ")[0].split(".").map(e=>Number(e)),o=r[0],s=r[1];i=o<16||16===o&&s<2}}var u=/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(e.navigator.userAgent),l=n();return{isSafari:i||l,needPerspectiveFix:i,need3dFix:l||u&&t.ios,isWebView:u}}()),F_}var rR={on(e,t,i){var n=this;if(!n.eventsListeners||n.destroyed)return n;if("function"!=typeof t)return n;var a=i?"unshift":"push";return e.split(" ").forEach(e=>{n.eventsListeners[e]||(n.eventsListeners[e]=[]),n.eventsListeners[e][a](t)}),n},once(e,t,i){var n=this;if(!n.eventsListeners||n.destroyed)return n;if("function"!=typeof t)return n;function a(...i){n.off(e,a),a.__emitterProxy&&delete a.__emitterProxy,t.apply(n,i)}return a.__emitterProxy=t,n.on(e,a,i)},onAny(e,t){var i=this;if(!i.eventsListeners||i.destroyed)return i;if("function"!=typeof e)return i;var n=t?"unshift":"push";return i.eventsAnyListeners.indexOf(e)<0&&i.eventsAnyListeners[n](e),i},offAny(e){var t=this;if(!t.eventsListeners||t.destroyed)return t;if(!t.eventsAnyListeners)return t;var i=t.eventsAnyListeners.indexOf(e);return i>=0&&t.eventsAnyListeners.splice(i,1),t},off(e,t){var i=this;return!i.eventsListeners||i.destroyed?i:i.eventsListeners?(e.split(" ").forEach(e=>{void 0===t?i.eventsListeners[e]=[]:i.eventsListeners[e]&&i.eventsListeners[e].forEach((n,a)=>{(n===t||n.__emitterProxy&&n.__emitterProxy===t)&&i.eventsListeners[e].splice(a,1)})}),i):i},emit(...e){var t,i,n,a=this;return!a.eventsListeners||a.destroyed?a:a.eventsListeners?("string"==typeof e[0]||Array.isArray(e[0])?(t=e[0],i=e.slice(1,e.length),n=a):(t=e[0].events,i=e[0].data,n=e[0].context||a),i.unshift(n),(Array.isArray(t)?t:t.split(" ")).forEach(e=>{a.eventsAnyListeners&&a.eventsAnyListeners.length&&a.eventsAnyListeners.forEach(t=>{t.apply(n,[e,...i])}),a.eventsListeners&&a.eventsListeners[e]&&a.eventsListeners[e].forEach(e=>{e.apply(n,i)})}),a):a}};var oR=(e,t,i)=>{t&&!e.classList.contains(i)?e.classList.add(i):!t&&e.classList.contains(i)&&e.classList.remove(i)};var sR=(e,t,i)=>{t&&!e.classList.contains(i)?e.classList.add(i):!t&&e.classList.contains(i)&&e.classList.remove(i)};var uR=(e,t)=>{if(e&&!e.destroyed&&e.params){var i=t.closest(e.isElement?"swiper-slide":`.${e.params.slideClass}`);if(i){var n=i.querySelector(`.${e.params.lazyPreloaderClass}`);!n&&e.isElement&&(i.shadowRoot?n=i.shadowRoot.querySelector(`.${e.params.lazyPreloaderClass}`):requestAnimationFrame(()=>{i.shadowRoot&&(n=i.shadowRoot.querySelector(`.${e.params.lazyPreloaderClass}`))&&!n.lazyPreloaderManaged&&n.remove()})),n&&!n.lazyPreloaderManaged&&n.remove()}}},lR=(e,t)=>{if(e.slides[t]){var i=e.slides[t].querySelector('[loading="lazy"]');i&&i.removeAttribute("loading")}},dR=e=>{if(e&&!e.destroyed&&e.params){var t=e.params.lazyPreloadPrevNext,i=e.slides.length;if(i&&t&&!(t<0)){t=Math.min(t,i);var n="auto"===e.params.slidesPerView?e.slidesPerViewDynamic():Math.ceil(e.params.slidesPerView),a=e.activeIndex;if(e.params.grid&&e.params.grid.rows>1){var r=a,o=[r-t];return o.push(...Array.from({length:t}).map((e,t)=>r+n+t)),void e.slides.forEach((t,i)=>{o.includes(t.column)&&lR(e,i)})}var s=a+n-1;if(e.params.rewind||e.params.loop)for(var u=a-t;u<=s+t;u+=1){var l=(u%i+i)%i;(l<a||l>s)&&lR(e,l)}else for(var d=Math.max(a-t,0);d<=Math.min(s+t,i-1);d+=1)d!==a&&(d>s||d<a)&&lR(e,d)}}};var hR={updateSize:function(){var e,t,i=this,n=i.el;e=void 0!==i.params.width&&null!==i.params.width?i.params.width:n.clientWidth,t=void 0!==i.params.height&&null!==i.params.height?i.params.height:n.clientHeight,0===e&&i.isHorizontal()||0===t&&i.isVertical()||(e=e-parseInt(q_(n,"padding-left")||0,10)-parseInt(q_(n,"padding-right")||0,10),t=t-parseInt(q_(n,"padding-top")||0,10)-parseInt(q_(n,"padding-bottom")||0,10),Number.isNaN(e)&&(e=0),Number.isNaN(t)&&(t=0),Object.assign(i,{width:e,height:t,size:i.isHorizontal()?e:t}))},updateSlides:function(){var e=this;function t(t,i){return parseFloat(t.getPropertyValue(e.getDirectionLabel(i))||0)}var i=e.params,n=e.wrapperEl,a=e.slidesEl,r=e.rtlTranslate,o=e.wrongRTL,s=e.virtual&&i.virtual.enabled,u=s?e.virtual.slides.length:e.slides.length,l=K_(a,`.${e.params.slideClass}, swiper-slide`),d=s?e.virtual.slides.length:l.length,h=[],c=[],m=[],f=i.slidesOffsetBefore;"function"==typeof f&&(f=i.slidesOffsetBefore.call(e));var v=i.slidesOffsetAfter;"function"==typeof v&&(v=i.slidesOffsetAfter.call(e));var p=e.snapGrid.length,g=e.slidesGrid.length,y=e.size-f-v,b=i.spaceBetween,w=-f,k=0,S=0;if(void 0!==y){"string"==typeof b&&b.indexOf("%")>=0?b=parseFloat(b.replace("%",""))/100*y:"string"==typeof b&&(b=parseFloat(b)),e.virtualSize=-b-f-v,l.forEach(e=>{r?e.style.marginLeft="":e.style.marginRight="",e.style.marginBottom="",e.style.marginTop=""}),i.centeredSlides&&i.cssMode&&(H_(n,"--swiper-centered-offset-before",""),H_(n,"--swiper-centered-offset-after","")),i.cssMode&&(H_(n,"--swiper-slides-offset-before",`${f}px`),H_(n,"--swiper-slides-offset-after",`${v}px`));var E,T=i.grid&&i.grid.rows>1&&e.grid;T?e.grid.initSlides(l):e.grid&&e.grid.unsetSlides();for(var P="auto"===i.slidesPerView&&i.breakpoints&&Object.keys(i.breakpoints).filter(e=>void 0!==i.breakpoints[e].slidesPerView).length>0,M=0;M<d;M+=1){E=0;var A=l[M];if(!A||(T&&e.grid.updateSlide(M,A,l),"none"!==q_(A,"display"))){if(s&&"auto"===i.slidesPerView)i.virtual.slidesPerViewAutoSlideSize&&(E=i.virtual.slidesPerViewAutoSlideSize),E&&A&&(i.roundLengths&&(E=Math.floor(E)),A.style[e.getDirectionLabel("width")]=`${E}px`);else if("auto"===i.slidesPerView){P&&(A.style[e.getDirectionLabel("width")]="");var D=getComputedStyle(A),x=A.style.transform,C=A.style.webkitTransform;if(x&&(A.style.transform="none"),C&&(A.style.webkitTransform="none"),i.roundLengths)E=e.isHorizontal()?Z_(A,"width"):Z_(A,"height");else{var I=t(D,"width"),L=t(D,"padding-left"),_=t(D,"padding-right"),R=t(D,"margin-left"),F=t(D,"margin-right"),O=D.getPropertyValue("box-sizing");if(O&&"border-box"===O)E=I+R+F;else{var W=A.clientWidth;E=I+L+_+R+F+(A.offsetWidth-W)}}x&&(A.style.transform=x),C&&(A.style.webkitTransform=C),i.roundLengths&&(E=Math.floor(E))}else E=(y-(i.slidesPerView-1)*b)/i.slidesPerView,i.roundLengths&&(E=Math.floor(E)),A&&(A.style[e.getDirectionLabel("width")]=`${E}px`);A&&(A.swiperSlideSize=E),m.push(E),i.centeredSlides?(w=w+E/2+k/2+b,0===k&&0!==M&&(w=w-y/2-b),0===M&&(w=w-y/2-b),Math.abs(w)<.001&&(w=0),i.roundLengths&&(w=Math.floor(w)),S%i.slidesPerGroup===0&&h.push(w),c.push(w)):(i.roundLengths&&(w=Math.floor(w)),(S-Math.min(e.params.slidesPerGroupSkip,S))%e.params.slidesPerGroup===0&&h.push(w),c.push(w),w=w+E+b),e.virtualSize+=E+b,k=E,S+=1}}if(e.virtualSize=Math.max(e.virtualSize,y)+v,r&&o&&("slide"===i.effect||"coverflow"===i.effect)&&(n.style.width=`${e.virtualSize+b}px`),i.setWrapperSize&&(n.style[e.getDirectionLabel("width")]=`${e.virtualSize+b}px`),T&&e.grid.updateWrapperSize(E,h),!i.centeredSlides){var $="auto"!==i.slidesPerView&&i.slidesPerView%1!=0,N=i.snapToSlideEdge&&!i.loop&&("auto"===i.slidesPerView||$),j=h.length;if(N){var B;if("auto"===i.slidesPerView){B=1;for(var z=0,U=m.length-1;U>=0&&(z+=m[U]+(U<m.length-1?b:0))<=y;U-=1)B=m.length-U}else B=Math.floor(i.slidesPerView);j=Math.max(d-B,0)}for(var H=[],G=0;G<h.length;G+=1){var V=h[G];i.roundLengths&&(V=Math.floor(V)),N?G<=j&&H.push(V):h[G]<=e.virtualSize-y&&H.push(V)}h=H,Math.floor(e.virtualSize-y)-Math.floor(h[h.length-1])>1&&(N||h.push(e.virtualSize-y))}if(s&&i.loop){var K=m[0]+b;if(i.slidesPerGroup>1)for(var X=Math.ceil((e.virtual.slidesBefore+e.virtual.slidesAfter)/i.slidesPerGroup),Y=K*i.slidesPerGroup,q=0;q<X;q+=1)h.push(h[h.length-1]+Y);for(var J=0;J<e.virtual.slidesBefore+e.virtual.slidesAfter;J+=1)1===i.slidesPerGroup&&h.push(h[h.length-1]+K),c.push(c[c.length-1]+K),e.virtualSize+=K}if(0===h.length&&(h=[0]),0!==b){var Q=e.isHorizontal()&&r?"marginLeft":e.getDirectionLabel("marginRight");l.filter((e,t)=>!(i.cssMode&&!i.loop)||t!==l.length-1).forEach(e=>{e.style[Q]=`${b}px`})}if(i.centeredSlides&&i.centeredSlidesBounds){var Z=0;m.forEach(e=>{Z+=e+(b||0)});var ee=(Z-=b)>y?Z-y:0;h=h.map(e=>e<=0?-f:e>ee?ee+v:e)}if(i.centerInsufficientSlides){var te=0;if(m.forEach(e=>{te+=e+(b||0)}),(te-=b)<y){var ie=(y-te)/2;h.forEach((e,t)=>{h[t]=e-ie}),c.forEach((e,t)=>{c[t]=e+ie})}}if(Object.assign(e,{slides:l,snapGrid:h,slidesGrid:c,slidesSizesGrid:m}),i.centeredSlides&&i.cssMode&&!i.centeredSlidesBounds){H_(n,"--swiper-centered-offset-before",-h[0]+"px"),H_(n,"--swiper-centered-offset-after",e.size/2-m[m.length-1]/2+"px");var ne=-e.snapGrid[0],ae=-e.slidesGrid[0];e.snapGrid=e.snapGrid.map(e=>e+ne),e.slidesGrid=e.slidesGrid.map(e=>e+ae)}if(d!==u&&e.emit("slidesLengthChange"),h.length!==p&&(e.params.watchOverflow&&e.checkOverflow(),e.emit("snapGridLengthChange")),c.length!==g&&e.emit("slidesGridLengthChange"),i.watchSlidesProgress&&e.updateSlidesOffset(),e.emit("slidesUpdated"),!(s||i.cssMode||"slide"!==i.effect&&"fade"!==i.effect)){var re=`${i.containerModifierClass}backface-hidden`,oe=e.el.classList.contains(re);d<=i.maxBackfaceHiddenSlides?oe||e.el.classList.add(re):oe&&e.el.classList.remove(re)}}},updateAutoHeight:function(e){var t,i=this,n=[],a=i.virtual&&i.params.virtual.enabled,r=0;"number"==typeof e?i.setTransition(e):!0===e&&i.setTransition(i.params.speed);var o=e=>a?i.slides[i.getSlideIndexByData(e)]:i.slides[e];if("auto"!==i.params.slidesPerView&&i.params.slidesPerView>1)if(i.params.centeredSlides)(i.visibleSlides||[]).forEach(e=>{n.push(e)});else for(t=0;t<Math.ceil(i.params.slidesPerView);t+=1){var s=i.activeIndex+t;if(s>i.slides.length&&!a)break;n.push(o(s))}else n.push(o(i.activeIndex));for(t=0;t<n.length;t+=1)if(void 0!==n[t]){var u=n[t].offsetHeight;r=u>r?u:r}(r||0===r)&&(i.wrapperEl.style.height=`${r}px`)},updateSlidesOffset:function(){for(var e=this,t=e.slides,i=e.isElement?e.isHorizontal()?e.wrapperEl.offsetLeft:e.wrapperEl.offsetTop:0,n=0;n<t.length;n+=1)t[n].swiperSlideOffset=(e.isHorizontal()?t[n].offsetLeft:t[n].offsetTop)-i-e.cssOverflowAdjustment()},updateSlidesProgress:function(e=this&&this.translate||0){var t=this,i=t.params,n=t.slides,a=t.rtlTranslate,r=t.snapGrid;if(0!==n.length){void 0===n[0].swiperSlideOffset&&t.updateSlidesOffset();var o=-e;a&&(o=e),t.visibleSlidesIndexes=[],t.visibleSlides=[];var s=i.spaceBetween;"string"==typeof s&&s.indexOf("%")>=0?s=parseFloat(s.replace("%",""))/100*t.size:"string"==typeof s&&(s=parseFloat(s));for(var u=0;u<n.length;u+=1){var l=n[u],d=l.swiperSlideOffset;i.cssMode&&i.centeredSlides&&(d-=n[0].swiperSlideOffset);var h=(o+(i.centeredSlides?t.minTranslate():0)-d)/(l.swiperSlideSize+s),c=(o-r[0]+(i.centeredSlides?t.minTranslate():0)-d)/(l.swiperSlideSize+s),m=-(o-d),f=m+t.slidesSizesGrid[u],v=m>=0&&m<=t.size-t.slidesSizesGrid[u],p=m>=0&&m<t.size-1||f>1&&f<=t.size||m<=0&&f>=t.size;p&&(t.visibleSlides.push(l),t.visibleSlidesIndexes.push(u)),oR(l,p,i.slideVisibleClass),oR(l,v,i.slideFullyVisibleClass),l.progress=a?-h:h,l.originalProgress=a?-c:c}}},updateProgress:function(e){var t=this;if(void 0===e){var i=t.rtlTranslate?-1:1;e=t&&t.translate&&t.translate*i||0}var n=t.params,a=t.maxTranslate()-t.minTranslate(),r=t.progress,o=t.isBeginning,s=t.isEnd,u=t.progressLoop,l=o,d=s;if(0===a)r=0,o=!0,s=!0;else{r=(e-t.minTranslate())/a;var h=Math.abs(e-t.minTranslate())<1,c=Math.abs(e-t.maxTranslate())<1;o=h||r<=0,s=c||r>=1,h&&(r=0),c&&(r=1)}if(n.loop){var m=t.getSlideIndexByData(0),f=t.getSlideIndexByData(t.slides.length-1),v=t.slidesGrid[m],p=t.slidesGrid[f],g=t.slidesGrid[t.slidesGrid.length-1],y=Math.abs(e);(u=y>=v?(y-v)/g:(y+g-p)/g)>1&&(u-=1)}Object.assign(t,{progress:r,progressLoop:u,isBeginning:o,isEnd:s}),(n.watchSlidesProgress||n.centeredSlides&&n.autoHeight)&&t.updateSlidesProgress(e),o&&!l&&t.emit("reachBeginning toEdge"),s&&!d&&t.emit("reachEnd toEdge"),(l&&!o||d&&!s)&&t.emit("fromEdge"),t.emit("progress",r)},updateSlidesClasses:function(){var e,t,i,n=this,a=n.slides,r=n.params,o=n.slidesEl,s=n.activeIndex,u=n.virtual&&r.virtual.enabled,l=n.grid&&r.grid&&r.grid.rows>1,d=e=>K_(o,`.${r.slideClass}${e}, swiper-slide${e}`)[0];if(u)if(r.loop){var h=s-n.virtual.slidesBefore;h<0&&(h=n.virtual.slides.length+h),h>=n.virtual.slides.length&&(h-=n.virtual.slides.length),e=d(`[data-swiper-slide-index="${h}"]`)}else e=d(`[data-swiper-slide-index="${s}"]`);else l?(e=a.find(e=>e.column===s),i=a.find(e=>e.column===s+1),t=a.find(e=>e.column===s-1)):e=a[s];e&&(l||(i=function(e,t){for(var i=[];e.nextElementSibling;){var n=e.nextElementSibling;t?n.matches(t)&&i.push(n):i.push(n),e=n}return i}(e,`.${r.slideClass}, swiper-slide`)[0],r.loop&&!i&&(i=a[0]),t=function(e,t){for(var i=[];e.previousElementSibling;){var n=e.previousElementSibling;t?n.matches(t)&&i.push(n):i.push(n),e=n}return i}(e,`.${r.slideClass}, swiper-slide`)[0],r.loop&&0===!t&&(t=a[a.length-1]))),a.forEach(n=>{sR(n,n===e,r.slideActiveClass),sR(n,n===i,r.slideNextClass),sR(n,n===t,r.slidePrevClass)}),n.emitSlidesClasses()},updateActiveIndex:function(e){var t,i=this,n=i.rtlTranslate?i.translate:-i.translate,a=i.snapGrid,r=i.params,o=i.activeIndex,s=i.realIndex,u=i.snapIndex,l=e,d=e=>{var t=e-i.virtual.slidesBefore;return t<0&&(t=i.virtual.slides.length+t),t>=i.virtual.slides.length&&(t-=i.virtual.slides.length),t};if(void 0===l&&(l=function(e){for(var t,i=e.slidesGrid,n=e.params,a=e.rtlTranslate?e.translate:-e.translate,r=0;r<i.length;r+=1)void 0!==i[r+1]?a>=i[r]&&a<i[r+1]-(i[r+1]-i[r])/2?t=r:a>=i[r]&&a<i[r+1]&&(t=r+1):a>=i[r]&&(t=r);return n.normalizeSlideIndex&&(t<0||void 0===t)&&(t=0),t}(i)),a.indexOf(n)>=0)t=a.indexOf(n);else{var h=Math.min(r.slidesPerGroupSkip,l);t=h+Math.floor((l-h)/r.slidesPerGroup)}if(t>=a.length&&(t=a.length-1),l!==o||i.params.loop)if(l===o&&i.params.loop&&i.virtual&&i.params.virtual.enabled)i.realIndex=d(l);else{var c,m=i.grid&&r.grid&&r.grid.rows>1;if(i.virtual&&r.virtual.enabled)c=r.loop?d(l):l;else if(m){var f=i.slides.find(e=>e.column===l),v=parseInt(f.getAttribute("data-swiper-slide-index"),10);Number.isNaN(v)&&(v=Math.max(i.slides.indexOf(f),0)),c=Math.floor(v/r.grid.rows)}else if(i.slides[l]){var p=i.slides[l].getAttribute("data-swiper-slide-index");c=p?parseInt(p,10):l}else c=l;Object.assign(i,{previousSnapIndex:u,snapIndex:t,previousRealIndex:s,realIndex:c,previousIndex:o,activeIndex:l}),i.initialized&&dR(i),i.emit("activeIndexChange"),i.emit("snapIndexChange"),(i.initialized||i.params.runCallbacksOnInit)&&(s!==c&&i.emit("realIndexChange"),i.emit("slideChange"))}else t!==u&&(i.snapIndex=t,i.emit("snapIndexChange"))},updateClickedSlide:function(e,t){var i=this,n=i.params,a=e.closest(`.${n.slideClass}, swiper-slide`);!a&&i.isElement&&t&&t.length>1&&t.includes(e)&&[...t.slice(t.indexOf(e)+1,t.length)].forEach(e=>{!a&&e.matches&&e.matches(`.${n.slideClass}, swiper-slide`)&&(a=e)});var r,o=!1;if(a)for(var s=0;s<i.slides.length;s+=1)if(i.slides[s]===a){o=!0,r=s;break}if(!a||!o)return i.clickedSlide=void 0,void(i.clickedIndex=void 0);i.clickedSlide=a,i.virtual&&i.params.virtual.enabled?i.clickedIndex=parseInt(a.getAttribute("data-swiper-slide-index"),10):i.clickedIndex=r,n.slideToClickedSlide&&void 0!==i.clickedIndex&&i.clickedIndex!==i.activeIndex&&i.slideToClickedSlide()}};var cR={getTranslate:function(e=(this.isHorizontal()?"x":"y")){var t=this,i=t.params,n=t.rtlTranslate,a=t.translate,r=t.wrapperEl;if(i.virtualTranslate)return n?-a:a;if(i.cssMode)return a;var o=j_(r,e);return o+=t.cssOverflowAdjustment(),n&&(o=-o),o||0},setTranslate:function(e,t){var i=this,n=i.rtlTranslate,a=i.params,r=i.wrapperEl,o=i.progress,s=0,u=0;i.isHorizontal()?s=n?-e:e:u=e,a.roundLengths&&(s=Math.floor(s),u=Math.floor(u)),i.previousTranslate=i.translate,i.translate=i.isHorizontal()?s:u,a.cssMode?r[i.isHorizontal()?"scrollLeft":"scrollTop"]=i.isHorizontal()?-s:-u:a.virtualTranslate||(i.isHorizontal()?s-=i.cssOverflowAdjustment():u-=i.cssOverflowAdjustment(),r.style.transform=`translate3d(${s}px, ${u}px, 0px)`);var l=i.maxTranslate()-i.minTranslate();(0===l?0:(e-i.minTranslate())/l)!==o&&i.updateProgress(e),i.emit("setTranslate",i.translate,t)},minTranslate:function(){return-this.snapGrid[0]},maxTranslate:function(){return-this.snapGrid[this.snapGrid.length-1]},translateTo:function(e=0,t=this.params.speed,i=!0,n=!0,a){var r=this,o=r.params,s=r.wrapperEl;if(r.animating&&o.preventInteractionOnTransition)return!1;var u,l=r.minTranslate(),d=r.maxTranslate();if(u=n&&e>l?l:n&&e<d?d:e,r.updateProgress(u),o.cssMode){var h=r.isHorizontal();if(0===t)s[h?"scrollLeft":"scrollTop"]=-u;else{if(!r.support.smoothScroll)return G_({swiper:r,targetPosition:-u,side:h?"left":"top"}),!0;s.scrollTo({[h?"left":"top"]:-u,behavior:"smooth"})}return!0}return 0===t?(r.setTransition(0),r.setTranslate(u),i&&(r.emit("beforeTransitionStart",t,a),r.emit("transitionEnd"))):(r.setTransition(t),r.setTranslate(u),i&&(r.emit("beforeTransitionStart",t,a),r.emit("transitionStart")),r.animating||(r.animating=!0,r.onTranslateToWrapperTransitionEnd||(r.onTranslateToWrapperTransitionEnd=function(e){r&&!r.destroyed&&e.target===this&&(r.wrapperEl.removeEventListener("transitionend",r.onTranslateToWrapperTransitionEnd),r.onTranslateToWrapperTransitionEnd=null,delete r.onTranslateToWrapperTransitionEnd,r.animating=!1,i&&r.emit("transitionEnd"))}),r.wrapperEl.addEventListener("transitionend",r.onTranslateToWrapperTransitionEnd))),!0}};function mR({swiper:e,runCallbacks:t,direction:i,step:n}){var a=e.activeIndex,r=e.previousIndex,o=i;o||(o=a>r?"next":a<r?"prev":"reset"),e.emit(`transition${n}`),t&&"reset"===o?e.emit(`slideResetTransition${n}`):t&&a!==r&&(e.emit(`slideChangeTransition${n}`),"next"===o?e.emit(`slideNextTransition${n}`):e.emit(`slidePrevTransition${n}`))}var fR={slideTo:function(e=0,t,i=!0,n,a){"string"==typeof e&&(e=parseInt(e,10));var r=this,o=e;o<0&&(o=0);var s=r.params,u=r.snapGrid,l=r.slidesGrid,d=r.previousIndex,h=r.activeIndex,c=r.rtlTranslate,m=r.wrapperEl;if(!r.enabled&&!n&&!a||r.destroyed||r.animating&&s.preventInteractionOnTransition)return!1;void 0===t&&(t=r.params.speed);var f=Math.min(r.params.slidesPerGroupSkip,o),v=f+Math.floor((o-f)/r.params.slidesPerGroup);v>=u.length&&(v=u.length-1);var p,g=-u[v];if(s.normalizeSlideIndex)for(var y=0;y<l.length;y+=1){var b=-Math.floor(100*g),w=Math.floor(100*l[y]),k=Math.floor(100*l[y+1]);void 0!==l[y+1]?b>=w&&b<k-(k-w)/2?o=y:b>=w&&b<k&&(o=y+1):b>=w&&(o=y)}if(r.initialized&&o!==h){if(!r.allowSlideNext&&(c?g>r.translate&&g>r.minTranslate():g<r.translate&&g<r.minTranslate()))return!1;if(!r.allowSlidePrev&&g>r.translate&&g>r.maxTranslate()&&(h||0)!==o)return!1}o!==(d||0)&&i&&r.emit("beforeSlideChangeStart"),r.updateProgress(g),p=o>h?"next":o<h?"prev":"reset";var S=r.virtual&&r.params.virtual.enabled;if(!(S&&a)&&(c&&-g===r.translate||!c&&g===r.translate))return r.updateActiveIndex(o),s.autoHeight&&r.updateAutoHeight(),r.updateSlidesClasses(),"slide"!==s.effect&&r.setTranslate(g),"reset"!==p&&(r.transitionStart(i,p),r.transitionEnd(i,p)),!1;if(s.cssMode){var E=r.isHorizontal(),T=c?g:-g;if(0===t)S&&(r.wrapperEl.style.scrollSnapType="none",r._immediateVirtual=!0),S&&!r._cssModeVirtualInitialSet&&r.params.initialSlide>0?(r._cssModeVirtualInitialSet=!0,requestAnimationFrame(()=>{m[E?"scrollLeft":"scrollTop"]=T})):m[E?"scrollLeft":"scrollTop"]=T,S&&requestAnimationFrame(()=>{r.wrapperEl.style.scrollSnapType="",r._immediateVirtual=!1});else{if(!r.support.smoothScroll)return G_({swiper:r,targetPosition:T,side:E?"left":"top"}),!0;m.scrollTo({[E?"left":"top"]:T,behavior:"smooth"})}return!0}var P=aR().isSafari;return S&&!a&&P&&r.isElement&&r.virtual.update(!1,!1,o),r.setTransition(t),r.setTranslate(g),r.updateActiveIndex(o),r.updateSlidesClasses(),r.emit("beforeTransitionStart",t,n),r.transitionStart(i,p),0===t?r.transitionEnd(i,p):r.animating||(r.animating=!0,r.onSlideToWrapperTransitionEnd||(r.onSlideToWrapperTransitionEnd=function(e){r&&!r.destroyed&&e.target===this&&(r.wrapperEl.removeEventListener("transitionend",r.onSlideToWrapperTransitionEnd),r.onSlideToWrapperTransitionEnd=null,delete r.onSlideToWrapperTransitionEnd,r.transitionEnd(i,p))}),r.wrapperEl.addEventListener("transitionend",r.onSlideToWrapperTransitionEnd)),!0},slideToLoop:function(e=0,t,i=!0,n){"string"==typeof e&&(e=parseInt(e,10));var a=this;if(!a.destroyed){void 0===t&&(t=a.params.speed);var r=a.grid&&a.params.grid&&a.params.grid.rows>1,o=e;if(a.params.loop)if(a.virtual&&a.params.virtual.enabled)o+=a.virtual.slidesBefore;else{var s;if(r){var u=o*a.params.grid.rows;s=a.slides.find(e=>1*e.getAttribute("data-swiper-slide-index")===u).column}else s=a.getSlideIndexByData(o);var l=r?Math.ceil(a.slides.length/a.params.grid.rows):a.slides.length,d=a.params,h=d.centeredSlides,c=d.slidesOffsetBefore,m=d.slidesOffsetAfter,f=h||!!c||!!m,v=a.params.slidesPerView;"auto"===v?v=a.slidesPerViewDynamic():(v=Math.ceil(parseFloat(a.params.slidesPerView,10)),f&&v%2==0&&(v+=1));var p=l-s<v;if(f&&(p=p||s<Math.ceil(v/2)),n&&f&&"auto"!==a.params.slidesPerView&&!r&&(p=!1),p){var g=f?s<a.activeIndex?"prev":"next":s-a.activeIndex-1<a.params.slidesPerView?"next":"prev";a.loopFix({direction:g,slideTo:!0,activeSlideIndex:"next"===g?s+1:s-l+1,slideRealIndex:"next"===g?a.realIndex:void 0})}if(r){var y=o*a.params.grid.rows;o=a.slides.find(e=>1*e.getAttribute("data-swiper-slide-index")===y).column}else o=a.getSlideIndexByData(o)}return requestAnimationFrame(()=>{a.slideTo(o,t,i,n)}),a}},slideNext:function(e,t=!0,i){var n=this,a=n.enabled,r=n.params,o=n.animating;if(!a||n.destroyed)return n;void 0===e&&(e=n.params.speed);var s=r.slidesPerGroup;"auto"===r.slidesPerView&&1===r.slidesPerGroup&&r.slidesPerGroupAuto&&(s=Math.max(n.slidesPerViewDynamic("current",!0),1));var u=n.activeIndex<r.slidesPerGroupSkip?1:s,l=n.virtual&&r.virtual.enabled;if(r.loop){if(o&&!l&&r.loopPreventsSliding)return!1;if(n.loopFix({direction:"next"}),n._clientLeft=n.wrapperEl.clientLeft,n.activeIndex===n.slides.length-1&&r.cssMode)return requestAnimationFrame(()=>{n.slideTo(n.activeIndex+u,e,t,i)}),!0}return r.rewind&&n.isEnd?n.slideTo(0,e,t,i):n.slideTo(n.activeIndex+u,e,t,i)},slidePrev:function(e,t=!0,i){var n=this,a=n.params,r=n.snapGrid,o=n.slidesGrid,s=n.rtlTranslate,u=n.enabled,l=n.animating;if(!u||n.destroyed)return n;void 0===e&&(e=n.params.speed);var d=n.virtual&&a.virtual.enabled;if(a.loop){if(l&&!d&&a.loopPreventsSliding)return!1;n.loopFix({direction:"prev"}),n._clientLeft=n.wrapperEl.clientLeft}function h(e){return e<0?-Math.floor(Math.abs(e)):Math.floor(e)}var c,m=h(s?n.translate:-n.translate),f=r.map(e=>h(e)),v=a.freeMode&&a.freeMode.enabled,p=r[f.indexOf(m)-1];void 0===p&&(a.cssMode||v)&&(r.forEach((e,t)=>{m>=e&&(c=t)}),void 0!==c&&(p=v?r[c]:r[c>0?c-1:c]));var g=0;if(void 0!==p&&((g=o.indexOf(p))<0&&(g=n.activeIndex-1),"auto"===a.slidesPerView&&1===a.slidesPerGroup&&a.slidesPerGroupAuto&&(g=g-n.slidesPerViewDynamic("previous",!0)+1,g=Math.max(g,0))),a.rewind&&n.isBeginning){var y=n.params.virtual&&n.params.virtual.enabled&&n.virtual?n.virtual.slides.length-1:n.slides.length-1;return n.slideTo(y,e,t,i)}return a.loop&&0===n.activeIndex&&a.cssMode?(requestAnimationFrame(()=>{n.slideTo(g,e,t,i)}),!0):n.slideTo(g,e,t,i)},slideReset:function(e,t=!0,i){var n=this;if(!n.destroyed)return void 0===e&&(e=n.params.speed),n.slideTo(n.activeIndex,e,t,i)},slideToClosest:function(e,t=!0,i,n=.5){var a=this;if(!a.destroyed){void 0===e&&(e=a.params.speed);var r=a.activeIndex,o=Math.min(a.params.slidesPerGroupSkip,r),s=o+Math.floor((r-o)/a.params.slidesPerGroup),u=a.rtlTranslate?a.translate:-a.translate;if(u>=a.snapGrid[s]){var l=a.snapGrid[s];u-l>(a.snapGrid[s+1]-l)*n&&(r+=a.params.slidesPerGroup)}else{var d=a.snapGrid[s-1];u-d<=(a.snapGrid[s]-d)*n&&(r-=a.params.slidesPerGroup)}return r=Math.max(r,0),r=Math.min(r,a.slidesGrid.length-1),a.slideTo(r,e,t,i)}},slideToClickedSlide:function(){var e=this;if(!e.destroyed){var t,i=e.params,n=e.slidesEl,a="auto"===i.slidesPerView?e.slidesPerViewDynamic():i.slidesPerView,r=e.getSlideIndexWhenGrid(e.clickedIndex),o=e.isElement?"swiper-slide":`.${i.slideClass}`,s=e.grid&&e.params.grid&&e.params.grid.rows>1;if(i.loop){if(e.animating)return;t=parseInt(e.clickedSlide.getAttribute("data-swiper-slide-index"),10),i.centeredSlides?e.slideToLoop(t):r>(s?(e.slides.length-a)/2-(e.params.grid.rows-1):e.slides.length-a)?(e.loopFix(),r=e.getSlideIndex(K_(n,`${o}[data-swiper-slide-index="${t}"]`)[0]),$_(()=>{e.slideTo(r)})):e.slideTo(r)}else e.slideTo(r)}}};var vR={loopCreate:function(e,t){var i=this,n=i.params,a=i.slidesEl;if(!(!n.loop||i.virtual&&i.params.virtual.enabled)){var r,o=()=>{K_(a,`.${n.slideClass}, swiper-slide`).forEach((e,t)=>{e.setAttribute("data-swiper-slide-index",t)})},s=i.grid&&n.grid&&n.grid.rows>1;n.loopAddBlankSlides&&(n.slidesPerGroup>1||s)&&((r=K_(a,`.${n.slideBlankClass}`)).forEach(e=>{e.remove()}),r.length>0&&(i.recalcSlides(),i.updateSlides()));var u=n.slidesPerGroup*(s?n.grid.rows:1),l=i.slides.length%u!==0,d=s&&i.slides.length%n.grid.rows!==0,h=e=>{for(var t=0;t<e;t+=1){var a=i.isElement?Y_("swiper-slide",[n.slideBlankClass]):Y_("div",[n.slideClass,n.slideBlankClass]);i.slidesEl.append(a)}};if(l){if(n.loopAddBlankSlides)h(u-i.slides.length%u),i.recalcSlides(),i.updateSlides();else X_("Swiper Loop Warning: The number of slides is not even to slidesPerGroup, loop mode may not function properly. You need to add more slides (or make duplicates, or empty slides)");o()}else if(d){if(n.loopAddBlankSlides)h(n.grid.rows-i.slides.length%n.grid.rows),i.recalcSlides(),i.updateSlides();else X_("Swiper Loop Warning: The number of slides is not even to grid.rows, loop mode may not function properly. You need to add more slides (or make duplicates, or empty slides)");o()}else o();var c=n.centeredSlides||!!n.slidesOffsetBefore||!!n.slidesOffsetAfter;i.loopFix({slideRealIndex:e,direction:c?void 0:"next",initial:t})}},loopFix:function({slideRealIndex:e,slideTo:t=!0,direction:i,setTranslate:n,activeSlideIndex:a,initial:r,byController:o,byMousewheel:s}={}){var u=this;if(u.params.loop){u.emit("beforeLoopFix");var l=u.slides,d=u.allowSlidePrev,h=u.allowSlideNext,c=u.slidesEl,m=u.params,f=m.centeredSlides,p=m.slidesOffsetBefore,g=m.slidesOffsetAfter,y=m.initialSlide,b=f||!!p||!!g;if(u.allowSlidePrev=!0,u.allowSlideNext=!0,u.virtual&&m.virtual.enabled)return t&&(b||0!==u.snapIndex?b&&u.snapIndex<m.slidesPerView?u.slideTo(u.virtual.slides.length+u.snapIndex,0,!1,!0):u.snapIndex===u.snapGrid.length-1&&u.slideTo(u.virtual.slidesBefore,0,!1,!0):u.slideTo(u.virtual.slides.length,0,!1,!0)),u.allowSlidePrev=d,u.allowSlideNext=h,void u.emit("loopFix");var w=m.slidesPerView;"auto"===w?w=u.slidesPerViewDynamic():(w=Math.ceil(parseFloat(m.slidesPerView,10)),b&&w%2==0&&(w+=1));var k=m.slidesPerGroupAuto?w:m.slidesPerGroup,S=b?Math.max(k,Math.ceil(w/2)):k;S%k!==0&&(S+=k-S%k),S+=m.loopAdditionalSlides,u.loopedSlides=S;var E=u.grid&&m.grid&&m.grid.rows>1;l.length<w+S||"cards"===u.params.effect&&l.length<w+2*S?X_("Swiper Loop Warning: The number of slides is not enough for loop mode, it will be disabled or not function properly. You need to add more slides (or make duplicates) or lower the values of slidesPerView and slidesPerGroup parameters"):E&&"row"===m.grid.fill&&X_("Swiper Loop Warning: Loop mode is not compatible with grid.fill = `row`");var T=[],P=[],M=E?Math.ceil(l.length/m.grid.rows):l.length,A=r&&M-y<w&&!b,D=A?y:u.activeIndex;void 0===a?a=u.getSlideIndex(l.find(e=>e.classList.contains(m.slideActiveClass))):D=a;var x="next"===i||!i,C="prev"===i||!i,I=0,L=0,_=(E?l[a].column:a)+(b&&void 0===n?-w/2+.5:0);if(_<S){I=Math.max(S-_,k);for(var R=0;R<S-_;R+=1){var F=R-Math.floor(R/M)*M;if(E)for(var O=M-F-1,W=l.length-1;W>=0;W-=1)l[W].column===O&&T.push(W);else T.push(M-F-1)}}else if(_+w>M-S){L=Math.max(_-(M-2*S),k),A&&(L=Math.max(L,w-M+y+1));for(var $=function(){var e=N-Math.floor(N/M)*M;E?l.forEach((t,i)=>{t.column===e&&P.push(i)}):P.push(e)},N=0;N<L;N+=1)$()}if(u.__preventObserver__=!0,requestAnimationFrame(()=>{u.__preventObserver__=!1}),"cards"===u.params.effect&&l.length<w+2*S&&(P.includes(a)&&P.splice(P.indexOf(a),1),T.includes(a)&&T.splice(T.indexOf(a),1)),C&&T.forEach(e=>{l[e].swiperLoopMoveDOM=!0,c.prepend(l[e]),l[e].swiperLoopMoveDOM=!1}),x&&P.forEach(e=>{l[e].swiperLoopMoveDOM=!0,c.append(l[e]),l[e].swiperLoopMoveDOM=!1}),u.recalcSlides(),"auto"===m.slidesPerView?u.updateSlides():E&&(T.length>0&&C||P.length>0&&x)&&u.slides.forEach((e,t)=>{u.grid.updateSlide(t,e,u.slides)}),m.watchSlidesProgress&&u.updateSlidesOffset(),t)if(T.length>0&&C){if(void 0===e){var j=u.slidesGrid[D],B=u.slidesGrid[D+I]-j;s?u.setTranslate(u.translate-B):(u.slideTo(D+Math.ceil(I),0,!1,!0),n&&(u.touchEventsData.startTranslate=u.touchEventsData.startTranslate-B,u.touchEventsData.currentTranslate=u.touchEventsData.currentTranslate-B))}else if(n){var z=E?T.length/m.grid.rows:T.length;u.slideTo(u.activeIndex+z,0,!1,!0),u.touchEventsData.currentTranslate=u.translate}}else if(P.length>0&&x)if(void 0===e){var U=u.slidesGrid[D],H=u.slidesGrid[D-L]-U;s?u.setTranslate(u.translate-H):(u.slideTo(D-L,0,!1,!0),n&&(u.touchEventsData.startTranslate=u.touchEventsData.startTranslate-H,u.touchEventsData.currentTranslate=u.touchEventsData.currentTranslate-H))}else{var G=E?P.length/m.grid.rows:P.length;u.slideTo(u.activeIndex-G,0,!1,!0)}if(u.allowSlidePrev=d,u.allowSlideNext=h,u.controller&&u.controller.control&&!o){var V={slideRealIndex:e,direction:i,setTranslate:n,activeSlideIndex:a,byController:!0};Array.isArray(u.controller.control)?u.controller.control.forEach(e=>{!e.destroyed&&e.params.loop&&e.loopFix(v({},V,{slideTo:e.params.slidesPerView===m.slidesPerView&&t}))}):u.controller.control instanceof u.constructor&&u.controller.control.params.loop&&u.controller.control.loopFix(v({},V,{slideTo:u.controller.control.params.slidesPerView===m.slidesPerView&&t}))}u.emit("loopFix")}},loopDestroy:function(){var e=this,t=e.params,i=e.slidesEl;if(t.loop&&i&&(!e.virtual||!e.params.virtual.enabled)){e.recalcSlides();var n=[];e.slides.forEach(e=>{var t=void 0===e.swiperSlideIndex?1*e.getAttribute("data-swiper-slide-index"):e.swiperSlideIndex;n[t]=e}),e.slides.forEach(e=>{e.removeAttribute("data-swiper-slide-index")}),n.forEach(e=>{i.append(e)}),e.recalcSlides(),e.slideTo(e.realIndex,0)}}};var pR={setGrabCursor:function(e){var t=this;if(!(!t.params.simulateTouch||t.params.watchOverflow&&t.isLocked||t.params.cssMode)){var i="container"===t.params.touchEventsTarget?t.el:t.wrapperEl;t.isElement&&(t.__preventObserver__=!0),i.style.cursor="move",i.style.cursor=e?"grabbing":"grab",t.isElement&&requestAnimationFrame(()=>{t.__preventObserver__=!1})}},unsetGrabCursor:function(){var e=this;e.params.watchOverflow&&e.isLocked||e.params.cssMode||(e.isElement&&(e.__preventObserver__=!0),e["container"===e.params.touchEventsTarget?"el":"wrapperEl"].style.cursor="",e.isElement&&requestAnimationFrame(()=>{e.__preventObserver__=!1}))}};function gR(e,t,i){var n=W_(),a=e.params,r=a.edgeSwipeDetection,o=a.edgeSwipeThreshold;return!r||!(i<=o||i>=n.innerWidth-o)||"prevent"===r&&(t.preventDefault(),!0)}function yR(e){var t=this,i=L_(),n=e;n.originalEvent&&(n=n.originalEvent);var a=t.touchEventsData;if("pointerdown"===n.type){if(null!==a.pointerId&&a.pointerId!==n.pointerId)return;a.pointerId=n.pointerId}else"touchstart"===n.type&&1===n.targetTouches.length&&(a.touchId=n.targetTouches[0].identifier);if("touchstart"!==n.type){var r=t.params,o=t.touches;if(t.enabled&&(r.simulateTouch||"mouse"!==n.pointerType)&&(!t.animating||!r.preventInteractionOnTransition)){!t.animating&&r.cssMode&&r.loop&&t.loopFix();var s=n.target;if(("wrapper"!==r.touchEventsTarget||function(e,t){var i=W_(),n=t.contains(e);return!n&&i.HTMLSlotElement&&t instanceof HTMLSlotElement&&((n=[...t.assignedElements()].includes(e))||(n=function(e,t){for(var i=[t];i.length>0;){var n=i.shift();if(e===n)return!0;i.push(...n.children,...n.shadowRoot?n.shadowRoot.children:[],...n.assignedElements?n.assignedElements():[])}}(e,t))),n}(s,t.wrapperEl))&&!("which"in n&&3===n.which||"button"in n&&n.button>0||a.isTouched&&a.isMoved)){var u=!!r.noSwipingClass&&""!==r.noSwipingClass,l=n.composedPath?n.composedPath():n.path;u&&n.target&&n.target.shadowRoot&&l&&(s=l[0]);var d=r.noSwipingSelector?r.noSwipingSelector:`.${r.noSwipingClass}`,h=!(!n.target||!n.target.shadowRoot);if(r.noSwiping&&(h?function(e,t=this){return function t(i){if(!i||i===L_()||i===W_())return null;i.assignedSlot&&(i=i.assignedSlot);var n=i.closest(e);return n||i.getRootNode?n||t(i.getRootNode().host):null}(t)}(d,s):s.closest(d)))t.allowClick=!0;else if(!r.swipeHandler||s.closest(r.swipeHandler)){o.currentX=n.pageX,o.currentY=n.pageY;var c=o.currentX,m=o.currentY;if(gR(t,n,c)){Object.assign(a,{isTouched:!0,isMoved:!1,allowTouchCallbacks:!0,isScrolling:void 0,startMoving:void 0}),o.startX=c,o.startY=m,a.touchStartTime=N_(),t.allowClick=!0,t.updateSize(),t.swipeDirection=void 0,r.threshold>0&&(a.allowThresholdMove=!1);var f=!0;s.matches(a.focusableElements)&&(f=!1,"SELECT"===s.nodeName&&(a.isTouched=!1)),i.activeElement&&i.activeElement.matches(a.focusableElements)&&i.activeElement!==s&&("mouse"===n.pointerType||"mouse"!==n.pointerType&&!s.matches(a.focusableElements))&&i.activeElement.blur();var v=f&&t.allowTouchMove&&r.touchStartPreventDefault;!r.touchStartForcePreventDefault&&!v||s.isContentEditable||n.preventDefault(),r.freeMode&&r.freeMode.enabled&&t.freeMode&&t.animating&&!r.cssMode&&t.freeMode.onTouchStart(),t.emit("touchStart",n)}}}}}else gR(t,n,n.targetTouches[0].pageX)}function bR(e){var t=L_(),i=this,n=i.touchEventsData,a=i.params,r=i.touches,o=i.rtlTranslate;if(i.enabled&&(a.simulateTouch||"mouse"!==e.pointerType)){var s,u=e;if(u.originalEvent&&(u=u.originalEvent),"pointermove"===u.type){if(null!==n.touchId)return;if(u.pointerId!==n.pointerId)return}if("touchmove"===u.type){if(s=[...u.changedTouches].find(e=>e.identifier===n.touchId),!s||s.identifier!==n.touchId)return}else s=u;if(n.isTouched){var l=s.pageX,d=s.pageY;if(u.preventedByNestedSwiper)return r.startX=l,void(r.startY=d);if(!i.allowTouchMove)return u.target.matches(n.focusableElements)||(i.allowClick=!1),void(n.isTouched&&(Object.assign(r,{startX:l,startY:d,currentX:l,currentY:d}),n.touchStartTime=N_()));if(a.touchReleaseOnEdges&&!a.loop)if(i.isVertical()){if(d<r.startY&&i.translate<=i.maxTranslate()||d>r.startY&&i.translate>=i.minTranslate())return n.isTouched=!1,void(n.isMoved=!1)}else{if(o&&(l>r.startX&&-i.translate<=i.maxTranslate()||l<r.startX&&-i.translate>=i.minTranslate()))return;if(!o&&(l<r.startX&&i.translate<=i.maxTranslate()||l>r.startX&&i.translate>=i.minTranslate()))return}if(t.activeElement&&t.activeElement.matches(n.focusableElements)&&t.activeElement!==u.target&&"mouse"!==u.pointerType&&t.activeElement.blur(),t.activeElement&&u.target===t.activeElement&&u.target.matches(n.focusableElements))return n.isMoved=!0,void(i.allowClick=!1);n.allowTouchCallbacks&&i.emit("touchMove",u),r.previousX=r.currentX,r.previousY=r.currentY,r.currentX=l,r.currentY=d;var h=r.currentX-r.startX,c=r.currentY-r.startY;if(!(i.params.threshold&&Math.sqrt(h**2+c**2)<i.params.threshold)){var m;if(void 0===n.isScrolling)i.isHorizontal()&&r.currentY===r.startY||i.isVertical()&&r.currentX===r.startX?n.isScrolling=!1:h*h+c*c>=25&&(m=180*Math.atan2(Math.abs(c),Math.abs(h))/Math.PI,n.isScrolling=i.isHorizontal()?m>a.touchAngle:90-m>a.touchAngle);if(n.isScrolling&&i.emit("touchMoveOpposite",u),void 0===n.startMoving&&(r.currentX===r.startX&&r.currentY===r.startY||(n.startMoving=!0)),n.isScrolling||"touchmove"===u.type&&n.preventTouchMoveFromPointerMove)n.isTouched=!1;else if(n.startMoving){i.allowClick=!1,!a.cssMode&&u.cancelable&&u.preventDefault(),a.touchMoveStopPropagation&&!a.nested&&u.stopPropagation();var f=i.isHorizontal()?h:c,v=i.isHorizontal()?r.currentX-r.previousX:r.currentY-r.previousY;a.oneWayMovement&&(f=Math.abs(f)*(o?1:-1),v=Math.abs(v)*(o?1:-1)),r.diff=f,f*=a.touchRatio,o&&(f=-f,v=-v);var p=i.touchesDirection;i.swipeDirection=f>0?"prev":"next",i.touchesDirection=v>0?"prev":"next";var g=i.params.loop&&!a.cssMode,y="next"===i.touchesDirection&&i.allowSlideNext||"prev"===i.touchesDirection&&i.allowSlidePrev;if(!n.isMoved){if(g&&y&&i.loopFix({direction:i.swipeDirection}),n.startTranslate=i.getTranslate(),i.setTransition(0),i.animating){var b=new window.CustomEvent("transitionend",{bubbles:!0,cancelable:!0,detail:{bySwiperTouchMove:!0}});i.wrapperEl.dispatchEvent(b)}n.allowMomentumBounce=!1,!a.grabCursor||!0!==i.allowSlideNext&&!0!==i.allowSlidePrev||i.setGrabCursor(!0),i.emit("sliderFirstMove",u)}if((new Date).getTime(),!1!==a._loopSwapReset&&n.isMoved&&n.allowThresholdMove&&p!==i.touchesDirection&&g&&y&&Math.abs(f)>=1)return Object.assign(r,{startX:l,startY:d,currentX:l,currentY:d,startTranslate:n.currentTranslate}),n.loopSwapReset=!0,void(n.startTranslate=n.currentTranslate);i.emit("sliderMove",u),n.isMoved=!0,n.currentTranslate=f+n.startTranslate;var w=!0,k=a.resistanceRatio;if(a.touchReleaseOnEdges&&(k=0),f>0?(g&&y&&n.allowThresholdMove&&n.currentTranslate>(a.centeredSlides?i.minTranslate()-i.slidesSizesGrid[i.activeIndex+1]-("auto"!==a.slidesPerView&&i.slides.length-a.slidesPerView>=2?i.slidesSizesGrid[i.activeIndex+1]+i.params.spaceBetween:0)-i.params.spaceBetween:i.minTranslate())&&i.loopFix({direction:"prev",setTranslate:!0,activeSlideIndex:0}),n.currentTranslate>i.minTranslate()&&(w=!1,a.resistance&&(n.currentTranslate=i.minTranslate()-1+(-i.minTranslate()+n.startTranslate+f)**k))):f<0&&(g&&y&&n.allowThresholdMove&&n.currentTranslate<(a.centeredSlides?i.maxTranslate()+i.slidesSizesGrid[i.slidesSizesGrid.length-1]+i.params.spaceBetween+("auto"!==a.slidesPerView&&i.slides.length-a.slidesPerView>=2?i.slidesSizesGrid[i.slidesSizesGrid.length-1]+i.params.spaceBetween:0):i.maxTranslate())&&i.loopFix({direction:"next",setTranslate:!0,activeSlideIndex:i.slides.length-("auto"===a.slidesPerView?i.slidesPerViewDynamic():Math.ceil(parseFloat(a.slidesPerView,10)))}),n.currentTranslate<i.maxTranslate()&&(w=!1,a.resistance&&(n.currentTranslate=i.maxTranslate()+1-(i.maxTranslate()-n.startTranslate-f)**k))),w&&(u.preventedByNestedSwiper=!0),!i.allowSlideNext&&"next"===i.swipeDirection&&n.currentTranslate<n.startTranslate&&(n.currentTranslate=n.startTranslate),!i.allowSlidePrev&&"prev"===i.swipeDirection&&n.currentTranslate>n.startTranslate&&(n.currentTranslate=n.startTranslate),i.allowSlidePrev||i.allowSlideNext||(n.currentTranslate=n.startTranslate),a.threshold>0){if(!(Math.abs(f)>a.threshold||n.allowThresholdMove))return void(n.currentTranslate=n.startTranslate);if(!n.allowThresholdMove)return n.allowThresholdMove=!0,r.startX=r.currentX,r.startY=r.currentY,n.currentTranslate=n.startTranslate,void(r.diff=i.isHorizontal()?r.currentX-r.startX:r.currentY-r.startY)}a.followFinger&&!a.cssMode&&((a.freeMode&&a.freeMode.enabled&&i.freeMode||a.watchSlidesProgress)&&(i.updateActiveIndex(),i.updateSlidesClasses()),a.freeMode&&a.freeMode.enabled&&i.freeMode&&i.freeMode.onTouchMove(),i.updateProgress(n.currentTranslate),i.setTranslate(n.currentTranslate))}}}else n.startMoving&&n.isScrolling&&i.emit("touchMoveOpposite",u)}}function wR(e){var t,i=this,n=i.touchEventsData,a=e;if(a.originalEvent&&(a=a.originalEvent),"touchend"===a.type||"touchcancel"===a.type){if(t=[...a.changedTouches].find(e=>e.identifier===n.touchId),!t||t.identifier!==n.touchId)return}else{if(null!==n.touchId)return;if(a.pointerId!==n.pointerId)return;t=a}if(["pointercancel","pointerout","pointerleave","contextmenu"].includes(a.type)&&!(["pointercancel","contextmenu"].includes(a.type)&&(i.browser.isSafari||i.browser.isWebView)))return;n.pointerId=null,n.touchId=null;var r=i.params,o=i.touches,s=i.rtlTranslate,u=i.slidesGrid;if(i.enabled&&(r.simulateTouch||"mouse"!==a.pointerType)){if(n.allowTouchCallbacks&&i.emit("touchEnd",a),n.allowTouchCallbacks=!1,!n.isTouched)return n.isMoved&&r.grabCursor&&i.setGrabCursor(!1),n.isMoved=!1,void(n.startMoving=!1);r.grabCursor&&n.isMoved&&n.isTouched&&(!0===i.allowSlideNext||!0===i.allowSlidePrev)&&i.setGrabCursor(!1);var l,d=N_(),h=d-n.touchStartTime;if(i.allowClick){var c=a.path||a.composedPath&&a.composedPath();i.updateClickedSlide(c&&c[0]||a.target,c),i.emit("tap click",a),h<300&&d-n.lastClickTime<300&&i.emit("doubleTap doubleClick",a)}if(n.lastClickTime=N_(),$_(()=>{i.destroyed||(i.allowClick=!0)}),!n.isTouched||!n.isMoved||!i.swipeDirection||0===o.diff&&!n.loopSwapReset||n.currentTranslate===n.startTranslate&&!n.loopSwapReset)return n.isTouched=!1,n.isMoved=!1,void(n.startMoving=!1);if(n.isTouched=!1,n.isMoved=!1,n.startMoving=!1,l=r.followFinger?s?i.translate:-i.translate:-n.currentTranslate,!r.cssMode)if(r.freeMode&&r.freeMode.enabled)i.freeMode.onTouchEnd({currentPos:l});else{for(var m=l>=-i.maxTranslate()&&!i.params.loop,f=0,v=i.slidesSizesGrid[0],p=0;p<u.length;p+=p<r.slidesPerGroupSkip?1:r.slidesPerGroup){var g=p<r.slidesPerGroupSkip-1?1:r.slidesPerGroup;void 0!==u[p+g]?(m||l>=u[p]&&l<u[p+g])&&(f=p,v=u[p+g]-u[p]):(m||l>=u[p])&&(f=p,v=u[u.length-1]-u[u.length-2])}var y=null,b=null;r.rewind&&(i.isBeginning?b=r.virtual&&r.virtual.enabled&&i.virtual?i.virtual.slides.length-1:i.slides.length-1:i.isEnd&&(y=0));var w=(l-u[f])/v,k=f<r.slidesPerGroupSkip-1?1:r.slidesPerGroup;if(h>r.longSwipesMs){if(!r.longSwipes)return void i.slideTo(i.activeIndex);"next"===i.swipeDirection&&(w>=r.longSwipesRatio?i.slideTo(r.rewind&&i.isEnd?y:f+k):i.slideTo(f)),"prev"===i.swipeDirection&&(w>1-r.longSwipesRatio?i.slideTo(f+k):null!==b&&w<0&&Math.abs(w)>r.longSwipesRatio?i.slideTo(b):i.slideTo(f))}else{if(!r.shortSwipes)return void i.slideTo(i.activeIndex);i.navigation&&(a.target===i.navigation.nextEl||a.target===i.navigation.prevEl)?a.target===i.navigation.nextEl?i.slideTo(f+k):i.slideTo(f):("next"===i.swipeDirection&&i.slideTo(null!==y?y:f+k),"prev"===i.swipeDirection&&i.slideTo(null!==b?b:f))}}}}function kR(){var e=this,t=e.params,i=e.el;if(!i||0!==i.offsetWidth){t.breakpoints&&e.setBreakpoint();var n=e.allowSlideNext,a=e.allowSlidePrev,r=e.snapGrid,o=e.virtual&&e.params.virtual.enabled;e.allowSlideNext=!0,e.allowSlidePrev=!0,e.updateSize(),e.updateSlides(),e.updateSlidesClasses();var s=o&&t.loop;if(!("auto"===t.slidesPerView||t.slidesPerView>1)||!e.isEnd||e.isBeginning||e.params.centeredSlides||s)e.params.loop&&!o?e.slideToLoop(e.realIndex,0,!1,!0):e.slideTo(e.activeIndex,0,!1,!0);else{var u=o?e.virtual.slides:e.slides;e.slideTo(u.length-1,0,!1,!0)}e.autoplay&&e.autoplay.running&&e.autoplay.paused&&(clearTimeout(e.autoplay.resizeTimeout),e.autoplay.resizeTimeout=setTimeout(()=>{e.autoplay&&e.autoplay.running&&e.autoplay.paused&&e.autoplay.resume()},500)),e.allowSlidePrev=a,e.allowSlideNext=n,e.params.watchOverflow&&r!==e.snapGrid&&e.checkOverflow()}}function SR(e){var t=this;t.enabled&&(t.allowClick||(t.params.preventClicks&&e.preventDefault(),t.params.preventClicksPropagation&&t.animating&&(e.stopPropagation(),e.stopImmediatePropagation())))}function ER(){var e=this,t=e.wrapperEl,i=e.rtlTranslate;if(e.enabled){e.previousTranslate=e.translate,e.isHorizontal()?e.translate=-t.scrollLeft:e.translate=-t.scrollTop,0===e.translate&&(e.translate=0),e.updateActiveIndex(),e.updateSlidesClasses();var n=e.maxTranslate()-e.minTranslate();(0===n?0:(e.translate-e.minTranslate())/n)!==e.progress&&e.updateProgress(i?-e.translate:e.translate),e.emit("setTranslate",e.translate,!1)}}function TR(e){var t=this;uR(t,e.target),t.params.cssMode||"auto"!==t.params.slidesPerView&&!t.params.autoHeight||t.update()}function PR(){var e=this;e.documentTouchHandlerProceeded||(e.documentTouchHandlerProceeded=!0,e.params.touchReleaseOnEdges&&(e.el.style.touchAction="auto"))}var MR=(e,t)=>{var i=L_(),n=e.params,a=e.el,r=e.wrapperEl,o=e.device,s=!!n.nested,u="on"===t?"addEventListener":"removeEventListener",l=t;a&&"string"!=typeof a&&(i[u]("touchstart",e.onDocumentTouchStart,{passive:!1,capture:s}),a[u]("touchstart",e.onTouchStart,{passive:!1}),a[u]("pointerdown",e.onTouchStart,{passive:!1}),i[u]("touchmove",e.onTouchMove,{passive:!1,capture:s}),i[u]("pointermove",e.onTouchMove,{passive:!1,capture:s}),i[u]("touchend",e.onTouchEnd,{passive:!0}),i[u]("pointerup",e.onTouchEnd,{passive:!0}),i[u]("pointercancel",e.onTouchEnd,{passive:!0}),i[u]("touchcancel",e.onTouchEnd,{passive:!0}),i[u]("pointerout",e.onTouchEnd,{passive:!0}),i[u]("pointerleave",e.onTouchEnd,{passive:!0}),i[u]("contextmenu",e.onTouchEnd,{passive:!0}),(n.preventClicks||n.preventClicksPropagation)&&a[u]("click",e.onClick,!0),n.cssMode&&r[u]("scroll",e.onScroll),n.updateOnWindowResize?e[l](o.ios||o.android?"resize orientationchange observerUpdate":"resize observerUpdate",kR,!0):e[l]("observerUpdate",kR,!0),a[u]("load",e.onLoad,{capture:!0}))};var AR=(e,t)=>e.grid&&t.grid&&t.grid.rows>1;var DR={setBreakpoint:function(){var e=this,t=e.realIndex,i=e.initialized,n=e.params,a=e.el,r=n.breakpoints;if(r&&(!r||0!==Object.keys(r).length)){var o=L_(),s="window"!==n.breakpointsBase&&n.breakpointsBase?"container":n.breakpointsBase,u=["window","container"].includes(n.breakpointsBase)||!n.breakpointsBase?e.el:o.querySelector(n.breakpointsBase),l=e.getBreakpoint(r,s,u);if(l&&e.currentBreakpoint!==l){var d=(l in r?r[l]:void 0)||e.originalParams,h=AR(e,n),c=AR(e,d),m=e.params.grabCursor,f=d.grabCursor,v=n.enabled;h&&!c?(a.classList.remove(`${n.containerModifierClass}grid`,`${n.containerModifierClass}grid-column`),e.emitContainerClasses()):!h&&c&&(a.classList.add(`${n.containerModifierClass}grid`),(d.grid.fill&&"column"===d.grid.fill||!d.grid.fill&&"column"===n.grid.fill)&&a.classList.add(`${n.containerModifierClass}grid-column`),e.emitContainerClasses()),m&&!f?e.unsetGrabCursor():!m&&f&&e.setGrabCursor(),["navigation","pagination","scrollbar"].forEach(t=>{if(void 0!==d[t]){var i=n[t]&&n[t].enabled,a=d[t]&&d[t].enabled;i&&!a&&e[t].disable(),!i&&a&&e[t].enable()}});var p=d.direction&&d.direction!==n.direction,g=n.loop&&(d.slidesPerView!==n.slidesPerView||p),y=n.loop;p&&i&&e.changeDirection(),U_(e.params,d);var b=e.params.enabled,w=e.params.loop;Object.assign(e,{allowTouchMove:e.params.allowTouchMove,allowSlideNext:e.params.allowSlideNext,allowSlidePrev:e.params.allowSlidePrev}),v&&!b?e.disable():!v&&b&&e.enable(),e.currentBreakpoint=l,e.emit("_beforeBreakpoint",d),i&&(g?(e.loopDestroy(),e.loopCreate(t),e.updateSlides()):!y&&w?(e.loopCreate(t),e.updateSlides()):y&&!w&&e.loopDestroy()),e.emit("breakpoint",d)}}},getBreakpoint:function(e,t="window",i){if(e&&("container"!==t||i)){var n=!1,a=W_(),r="window"===t?a.innerHeight:i.clientHeight,o=Object.keys(e).map(e=>{if("string"==typeof e&&0===e.indexOf("@")){var t=parseFloat(e.substr(1));return{value:r*t,point:e}}return{value:e,point:e}});o.sort((e,t)=>parseInt(e.value,10)-parseInt(t.value,10));for(var s=0;s<o.length;s+=1){var u=o[s],l=u.point,d=u.value;"window"===t?a.matchMedia(`(min-width: ${d}px)`).matches&&(n=l):d<=i.clientWidth&&(n=l)}return n||"max"}}};var xR={addClasses:function(){var e,t,i,n=this,a=n.classNames,r=n.params,o=n.rtl,s=n.el,u=n.device,l=(e=["initialized",r.direction,{"free-mode":n.params.freeMode&&r.freeMode.enabled},{autoheight:r.autoHeight},{rtl:o},{grid:r.grid&&r.grid.rows>1},{"grid-column":r.grid&&r.grid.rows>1&&"column"===r.grid.fill},{android:u.android},{ios:u.ios},{"css-mode":r.cssMode},{centered:r.cssMode&&r.centeredSlides},{"watch-progress":r.watchSlidesProgress}],t=r.containerModifierClass,i=[],e.forEach(e=>{"object"==typeof e?Object.keys(e).forEach(n=>{e[n]&&i.push(t+n)}):"string"==typeof e&&i.push(t+e)}),i);a.push(...l),s.classList.add(...a),n.emitContainerClasses()},removeClasses:function(){var e=this,t=e.el,i=e.classNames;t&&"string"!=typeof t&&(t.classList.remove(...i),e.emitContainerClasses())}};var CR={init:!0,direction:"horizontal",oneWayMovement:!1,swiperElementNodeName:"SWIPER-CONTAINER",touchEventsTarget:"wrapper",initialSlide:0,speed:300,cssMode:!1,updateOnWindowResize:!0,resizeObserver:!0,nested:!1,createElements:!1,eventsPrefix:"swiper",enabled:!0,focusableElements:"input, select, option, textarea, button, video, label",width:null,height:null,preventInteractionOnTransition:!1,userAgent:null,url:null,edgeSwipeDetection:!1,edgeSwipeThreshold:20,autoHeight:!1,setWrapperSize:!1,virtualTranslate:!1,effect:"slide",breakpoints:void 0,breakpointsBase:"window",spaceBetween:0,slidesPerView:1,slidesPerGroup:1,slidesPerGroupSkip:0,slidesPerGroupAuto:!1,centeredSlides:!1,centeredSlidesBounds:!1,slidesOffsetBefore:0,slidesOffsetAfter:0,normalizeSlideIndex:!0,centerInsufficientSlides:!1,snapToSlideEdge:!1,watchOverflow:!0,roundLengths:!1,touchRatio:1,touchAngle:45,simulateTouch:!0,shortSwipes:!0,longSwipes:!0,longSwipesRatio:.5,longSwipesMs:300,followFinger:!0,allowTouchMove:!0,threshold:5,touchMoveStopPropagation:!1,touchStartPreventDefault:!0,touchStartForcePreventDefault:!1,touchReleaseOnEdges:!1,uniqueNavElements:!0,resistance:!0,resistanceRatio:.85,watchSlidesProgress:!1,grabCursor:!1,preventClicks:!0,preventClicksPropagation:!0,slideToClickedSlide:!1,loop:!1,loopAddBlankSlides:!0,loopAdditionalSlides:0,loopPreventsSliding:!0,rewind:!1,allowSlidePrev:!0,allowSlideNext:!0,swipeHandler:null,noSwiping:!0,noSwipingClass:"swiper-no-swiping",noSwipingSelector:null,passiveListeners:!0,maxBackfaceHiddenSlides:10,containerModifierClass:"swiper-",slideClass:"swiper-slide",slideBlankClass:"swiper-slide-blank",slideActiveClass:"swiper-slide-active",slideVisibleClass:"swiper-slide-visible",slideFullyVisibleClass:"swiper-slide-fully-visible",slideNextClass:"swiper-slide-next",slidePrevClass:"swiper-slide-prev",wrapperClass:"swiper-wrapper",lazyPreloaderClass:"swiper-lazy-preloader",lazyPreloadPrevNext:0,runCallbacksOnInit:!0,_emitClasses:!1};function IR(e,t){return function(i={}){var n=Object.keys(i)[0],a=i[n];"object"==typeof a&&null!==a?(!0===e[n]&&(e[n]={enabled:!0}),"navigation"===n&&e[n]&&e[n].enabled&&!e[n].prevEl&&!e[n].nextEl&&(e[n].auto=!0),["pagination","scrollbar"].indexOf(n)>=0&&e[n]&&e[n].enabled&&!e[n].el&&(e[n].auto=!0),n in e&&"enabled"in a?("object"!=typeof e[n]||"enabled"in e[n]||(e[n].enabled=!0),e[n]||(e[n]={enabled:!1}),U_(t,i)):U_(t,i)):U_(t,i)}}var LR={eventsEmitter:rR,update:hR,translate:cR,transition:{setTransition:function(e,t){var i=this;i.params.cssMode||(i.wrapperEl.style.transitionDuration=`${e}ms`,i.wrapperEl.style.transitionDelay=0===e?"0ms":""),i.emit("setTransition",e,t)},transitionStart:function(e=!0,t){var i=this,n=i.params;n.cssMode||(n.autoHeight&&i.updateAutoHeight(),mR({swiper:i,runCallbacks:e,direction:t,step:"Start"}))},transitionEnd:function(e=!0,t){var i=this,n=i.params;i.animating=!1,n.cssMode||(i.setTransition(0),mR({swiper:i,runCallbacks:e,direction:t,step:"End"}))}},slide:fR,loop:vR,grabCursor:pR,events:{attachEvents:function(){var e=this,t=e.params;e.onTouchStart=yR.bind(e),e.onTouchMove=bR.bind(e),e.onTouchEnd=wR.bind(e),e.onDocumentTouchStart=PR.bind(e),t.cssMode&&(e.onScroll=ER.bind(e)),e.onClick=SR.bind(e),e.onLoad=TR.bind(e),MR(e,"on")},detachEvents:function(){MR(this,"off")}},breakpoints:DR,checkOverflow:{checkOverflow:function(){var e=this,t=e.isLocked,i=e.params,n=i.slidesOffsetBefore;if(n){var a=e.slides.length-1,r=e.slidesGrid[a]+e.slidesSizesGrid[a]+2*n;e.isLocked=e.size>r}else e.isLocked=1===e.snapGrid.length;!0===i.allowSlideNext&&(e.allowSlideNext=!e.isLocked),!0===i.allowSlidePrev&&(e.allowSlidePrev=!e.isLocked),t&&t!==e.isLocked&&(e.isEnd=!1),t!==e.isLocked&&e.emit(e.isLocked?"lock":"unlock")}},classes:xR},_R={},RR=function(){function e(...t){var i,n;u(this,e),1===t.length&&t[0].constructor&&"Object"===Object.prototype.toString.call(t[0]).slice(8,-1)?n=t[0]:(i=t[0],n=t[1]),n||(n={}),n=U_({},n),i&&!n.el&&(n.el=i);var a=L_();if(n.el&&"string"==typeof n.el&&a.querySelectorAll(n.el).length>1){var r=[];return a.querySelectorAll(n.el).forEach(t=>{var i=U_({},n,{el:t});r.push(new e(i))}),r}var o=this;o.__swiper__=!0,o.support=iR(),o.device=nR({userAgent:n.userAgent}),o.browser=aR(),o.eventsListeners={},o.eventsAnyListeners=[],o.modules=[...o.__modules__],n.modules&&Array.isArray(n.modules)&&n.modules.forEach(e=>{"function"==typeof e&&o.modules.indexOf(e)<0&&o.modules.push(e)});var s={};o.modules.forEach(e=>{e({params:n,swiper:o,extendParams:IR(n,s),on:o.on.bind(o),once:o.once.bind(o),off:o.off.bind(o),emit:o.emit.bind(o)})});var l=U_({},CR,s);return o.params=U_({},l,_R,n),o.originalParams=U_({},o.params),o.passedParams=U_({},n),o.params&&o.params.on&&Object.keys(o.params.on).forEach(e=>{o.on(e,o.params.on[e])}),o.params&&o.params.onAny&&o.onAny(o.params.onAny),Object.assign(o,{enabled:o.params.enabled,el:i,classNames:[],slides:[],slidesGrid:[],snapGrid:[],slidesSizesGrid:[],isHorizontal:()=>"horizontal"===o.params.direction,isVertical:()=>"vertical"===o.params.direction,activeIndex:0,realIndex:0,isBeginning:!0,isEnd:!1,translate:0,previousTranslate:0,progress:0,velocity:0,animating:!1,cssOverflowAdjustment(){return Math.trunc(this.translate/2**23)*2**23},allowSlideNext:o.params.allowSlideNext,allowSlidePrev:o.params.allowSlidePrev,touchEventsData:{isTouched:void 0,isMoved:void 0,allowTouchCallbacks:void 0,touchStartTime:void 0,isScrolling:void 0,currentTranslate:void 0,startTranslate:void 0,allowThresholdMove:void 0,focusableElements:o.params.focusableElements,lastClickTime:0,clickTimeout:void 0,velocities:[],allowMomentumBounce:void 0,startMoving:void 0,pointerId:null,touchId:null},allowClick:!0,allowTouchMove:o.params.allowTouchMove,touches:{startX:0,startY:0,currentX:0,currentY:0,diff:0},imagesToLoad:[],imagesLoaded:0}),o.emit("_swiper"),o.params.init&&o.init(),o}return m(e,[{key:"getDirectionLabel",value:function(e){return this.isHorizontal()?e:{width:"height","margin-top":"margin-left","margin-bottom ":"margin-right","margin-left":"margin-top","margin-right":"margin-bottom","padding-left":"padding-top","padding-right":"padding-bottom",marginRight:"marginBottom"}[e]}},{key:"getSlideIndex",value:function(e){var t=J_(K_(this.slidesEl,`.${this.params.slideClass}, swiper-slide`)[0]);return J_(e)-t}},{key:"getSlideIndexByData",value:function(e){return this.getSlideIndex(this.slides.find(t=>1*t.getAttribute("data-swiper-slide-index")===e))}},{key:"getSlideIndexWhenGrid",value:function(e){return this.grid&&this.params.grid&&this.params.grid.rows>1&&("column"===this.params.grid.fill?e=Math.floor(e/this.params.grid.rows):"row"===this.params.grid.fill&&(e%=Math.ceil(this.slides.length/this.params.grid.rows))),e}},{key:"recalcSlides",value:function(){var e=this,t=e.slidesEl,i=e.params;e.slides=K_(t,`.${i.slideClass}, swiper-slide`)}},{key:"enable",value:function(){var e=this;e.enabled||(e.enabled=!0,e.params.grabCursor&&e.setGrabCursor(),e.emit("enable"))}},{key:"disable",value:function(){var e=this;e.enabled&&(e.enabled=!1,e.params.grabCursor&&e.unsetGrabCursor(),e.emit("disable"))}},{key:"setProgress",value:function(e,t){var i=this;e=Math.min(Math.max(e,0),1);var n=i.minTranslate(),a=(i.maxTranslate()-n)*e+n;i.translateTo(a,void 0===t?0:t),i.updateActiveIndex(),i.updateSlidesClasses()}},{key:"emitContainerClasses",value:function(){var e=this;if(e.params._emitClasses&&e.el){var t=e.el.className.split(" ").filter(t=>0===t.indexOf("swiper")||0===t.indexOf(e.params.containerModifierClass));e.emit("_containerClasses",t.join(" "))}}},{key:"getSlideClasses",value:function(e){var t=this;return t.destroyed?"":e.className.split(" ").filter(e=>0===e.indexOf("swiper-slide")||0===e.indexOf(t.params.slideClass)).join(" ")}},{key:"emitSlidesClasses",value:function(){var e=this;if(e.params._emitClasses&&e.el){var t=[];e.slides.forEach(i=>{var n=e.getSlideClasses(i);t.push({slideEl:i,classNames:n}),e.emit("_slideClass",i,n)}),e.emit("_slideClasses",t)}}},{key:"slidesPerViewDynamic",value:function(e="current",t=!1){var i=this,n=i.params,a=i.slides,r=i.slidesGrid,o=i.slidesSizesGrid,s=i.size,u=i.activeIndex,l=1;if("number"==typeof n.slidesPerView)return n.slidesPerView;if(n.centeredSlides){for(var d,h=a[u]?Math.ceil(a[u].swiperSlideSize):0,c=u+1;c<a.length;c+=1)a[c]&&!d&&(l+=1,(h+=Math.ceil(a[c].swiperSlideSize))>s&&(d=!0));for(var m=u-1;m>=0;m-=1)a[m]&&!d&&(l+=1,(h+=a[m].swiperSlideSize)>s&&(d=!0))}else if("current"===e)for(var f=u+1;f<a.length;f+=1){(t?r[f]+o[f]-r[u]<s:r[f]-r[u]<s)&&(l+=1)}else for(var v=u-1;v>=0;v-=1){r[u]-r[v]<s&&(l+=1)}return l}},{key:"update",value:function(){var e=this;if(e&&!e.destroyed){var t,i=e.snapGrid,n=e.params;if(n.breakpoints&&e.setBreakpoint(),[...e.el.querySelectorAll('[loading="lazy"]')].forEach(t=>{t.complete&&uR(e,t)}),e.updateSize(),e.updateSlides(),e.updateProgress(),e.updateSlidesClasses(),n.freeMode&&n.freeMode.enabled&&!n.cssMode)r(),n.autoHeight&&e.updateAutoHeight();else{if(("auto"===n.slidesPerView||n.slidesPerView>1)&&e.isEnd&&!n.centeredSlides){var a=e.virtual&&n.virtual.enabled?e.virtual.slides:e.slides;t=e.slideTo(a.length-1,0,!1,!0)}else t=e.slideTo(e.activeIndex,0,!1,!0);t||r()}n.watchOverflow&&i!==e.snapGrid&&e.checkOverflow(),e.emit("update")}function r(){var t=e.rtlTranslate?-1*e.translate:e.translate,i=Math.min(Math.max(t,e.maxTranslate()),e.minTranslate());e.setTranslate(i),e.updateActiveIndex(),e.updateSlidesClasses()}}},{key:"changeDirection",value:function(e,t=!0){var i=this,n=i.params.direction;return e||(e="horizontal"===n?"vertical":"horizontal"),e===n||"horizontal"!==e&&"vertical"!==e||(i.el.classList.remove(`${i.params.containerModifierClass}${n}`),i.el.classList.add(`${i.params.containerModifierClass}${e}`),i.emitContainerClasses(),i.params.direction=e,i.slides.forEach(t=>{"vertical"===e?t.style.width="":t.style.height=""}),i.emit("changeDirection"),t&&i.update()),i}},{key:"changeLanguageDirection",value:function(e){var t=this;t.rtl&&"rtl"===e||!t.rtl&&"ltr"===e||(t.rtl="rtl"===e,t.rtlTranslate="horizontal"===t.params.direction&&t.rtl,t.rtl?(t.el.classList.add(`${t.params.containerModifierClass}rtl`),t.el.dir="rtl"):(t.el.classList.remove(`${t.params.containerModifierClass}rtl`),t.el.dir="ltr"),t.update())}},{key:"mount",value:function(e){var t=this;if(t.mounted)return!0;var i=e||t.params.el;if("string"==typeof i&&(i=document.querySelector(i)),!i)return!1;i.swiper=t,i.parentNode&&i.parentNode.host&&i.parentNode.host.nodeName===t.params.swiperElementNodeName.toUpperCase()&&(t.isElement=!0);var n=()=>`.${(t.params.wrapperClass||"").trim().split(" ").join(".")}`,a=i&&i.shadowRoot&&i.shadowRoot.querySelector?i.shadowRoot.querySelector(n()):K_(i,n())[0];return!a&&t.params.createElements&&(a=Y_("div",t.params.wrapperClass),i.append(a),K_(i,`.${t.params.slideClass}`).forEach(e=>{a.append(e)})),Object.assign(t,{el:i,wrapperEl:a,slidesEl:t.isElement&&!i.parentNode.host.slideSlots?i.parentNode.host:a,hostEl:t.isElement?i.parentNode.host:i,mounted:!0,rtl:"rtl"===i.dir.toLowerCase()||"rtl"===q_(i,"direction"),rtlTranslate:"horizontal"===t.params.direction&&("rtl"===i.dir.toLowerCase()||"rtl"===q_(i,"direction")),wrongRTL:"-webkit-box"===q_(a,"display")}),!0}},{key:"init",value:function(e){var t=this;if(t.initialized)return t;if(!1===t.mount(e))return t;t.emit("beforeInit"),t.params.breakpoints&&t.setBreakpoint(),t.addClasses(),t.updateSize(),t.updateSlides(),t.params.watchOverflow&&t.checkOverflow(),t.params.grabCursor&&t.enabled&&t.setGrabCursor(),t.params.loop&&t.virtual&&t.params.virtual.enabled?t.slideTo(t.params.initialSlide+t.virtual.slidesBefore,0,t.params.runCallbacksOnInit,!1,!0):t.slideTo(t.params.initialSlide,0,t.params.runCallbacksOnInit,!1,!0),t.params.loop&&t.loopCreate(void 0,!0),t.attachEvents();var i=[...t.el.querySelectorAll('[loading="lazy"]')];return t.isElement&&i.push(...t.hostEl.querySelectorAll('[loading="lazy"]')),i.forEach(e=>{e.complete?uR(t,e):e.addEventListener("load",e=>{uR(t,e.target)})}),dR(t),t.initialized=!0,dR(t),t.emit("init"),t.emit("afterInit"),t}},{key:"destroy",value:function(e=!0,t=!0){var i=this,n=i.params,a=i.el,r=i.wrapperEl,o=i.slides;return void 0===i.params||i.destroyed||(i.emit("beforeDestroy"),i.initialized=!1,i.detachEvents(),n.loop&&i.loopDestroy(),t&&(i.removeClasses(),a&&"string"!=typeof a&&a.removeAttribute("style"),r&&r.removeAttribute("style"),o&&o.length&&o.forEach(e=>{e.classList.remove(n.slideVisibleClass,n.slideFullyVisibleClass,n.slideActiveClass,n.slideNextClass,n.slidePrevClass),e.removeAttribute("style"),e.removeAttribute("data-swiper-slide-index")})),i.emit("destroy"),Object.keys(i.eventsListeners).forEach(e=>{i.off(e)}),!1!==e&&(i.el&&"string"!=typeof i.el&&(i.el.swiper=null),function(e){var t=e;Object.keys(t).forEach(e=>{try{t[e]=null}catch(e){}try{delete t[e]}catch(e){}})}(i)),i.destroyed=!0),null}}],[{key:"extendDefaults",value:function(e){U_(_R,e)}},{key:"extendedDefaults",get:function(){return _R}},{key:"defaults",get:function(){return CR}},{key:"installModule",value:function(t){e.prototype.__modules__||(e.prototype.__modules__=[]);var i=e.prototype.__modules__;"function"==typeof t&&i.indexOf(t)<0&&i.push(t)}},{key:"use",value:function(t){return Array.isArray(t)?(t.forEach(t=>e.installModule(t)),e):(e.installModule(t),e)}}])}();function FR(e=""){return`.${e.trim().replace(/([\.:!+\/()[\]#>~*^$|=,'"@{}\\])/g,"\\$1").replace(/ /g,".")}`}function OR({swiper:e,extendParams:t,on:i,emit:n}){var a,r="swiper-pagination";t({pagination:{el:null,bulletElement:"span",clickable:!1,hideOnClick:!1,renderBullet:null,renderProgressbar:null,renderFraction:null,renderCustom:null,progressbarOpposite:!1,type:"bullets",dynamicBullets:!1,dynamicMainBullets:1,formatFractionCurrent:e=>e,formatFractionTotal:e=>e,bulletClass:`${r}-bullet`,bulletActiveClass:`${r}-bullet-active`,modifierClass:`${r}-`,currentClass:`${r}-current`,totalClass:`${r}-total`,hiddenClass:`${r}-hidden`,progressbarFillClass:`${r}-progressbar-fill`,progressbarOppositeClass:`${r}-progressbar-opposite`,clickableClass:`${r}-clickable`,lockClass:`${r}-lock`,horizontalClass:`${r}-horizontal`,verticalClass:`${r}-vertical`,paginationDisabledClass:`${r}-disabled`}}),e.pagination={el:null,bullets:[]};var o=0;function s(){return!e.params.pagination.el||!e.pagination.el||Array.isArray(e.pagination.el)&&0===e.pagination.el.length}function u(t,i){var n=e.params.pagination.bulletActiveClass;t&&(t=t[("prev"===i?"previous":"next")+"ElementSibling"])&&(t.classList.add(`${n}-${i}`),(t=t[("prev"===i?"previous":"next")+"ElementSibling"])&&t.classList.add(`${n}-${i}-${i}`))}function l(t){var i=t.target.closest(FR(e.params.pagination.bulletClass));if(i){t.preventDefault();var n,a,r,o=J_(i)*e.params.slidesPerGroup;if(e.params.loop){if(e.realIndex===o)return;var s=(n=e.realIndex,a=o,r=e.slides.length,(a%=r)===1+(n%=r)?"next":a===n-1?"previous":void 0);"next"===s?e.slideNext():"previous"===s?e.slidePrev():e.slideToLoop(o)}else e.slideTo(o)}}function d(){var t=e.rtl,i=e.params.pagination;if(!s()){var r,l,d=e.pagination.el;d=eR(d);var h=e.virtual&&e.params.virtual.enabled?e.virtual.slides.length:e.slides.length,c=e.params.loop?Math.ceil(h/e.params.slidesPerGroup):e.snapGrid.length;if(e.params.loop?(l=e.previousRealIndex||0,r=e.params.slidesPerGroup>1?Math.floor(e.realIndex/e.params.slidesPerGroup):e.realIndex):void 0!==e.snapIndex?(r=e.snapIndex,l=e.previousSnapIndex):(l=e.previousIndex||0,r=e.activeIndex||0),"bullets"===i.type&&e.pagination.bullets&&e.pagination.bullets.length>0){var m,f,v,p=e.pagination.bullets;if(i.dynamicBullets&&(a=Z_(p[0],e.isHorizontal()?"width":"height"),d.forEach(t=>{t.style[e.isHorizontal()?"width":"height"]=a*(i.dynamicMainBullets+4)+"px"}),i.dynamicMainBullets>1&&void 0!==l&&((o+=r-(l||0))>i.dynamicMainBullets-1?o=i.dynamicMainBullets-1:o<0&&(o=0)),m=Math.max(r-o,0),v=((f=m+(Math.min(p.length,i.dynamicMainBullets)-1))+m)/2),p.forEach(e=>{var t=[...["","-next","-next-next","-prev","-prev-prev","-main"].map(e=>`${i.bulletActiveClass}${e}`)].map(e=>"string"==typeof e&&e.includes(" ")?e.split(" "):e).flat();e.classList.remove(...t)}),d.length>1)p.forEach(t=>{var n=J_(t);n===r?t.classList.add(...i.bulletActiveClass.split(" ")):e.isElement&&t.setAttribute("part","bullet"),i.dynamicBullets&&(n>=m&&n<=f&&t.classList.add(...`${i.bulletActiveClass}-main`.split(" ")),n===m&&u(t,"prev"),n===f&&u(t,"next"))});else{var g=p[r];if(g&&g.classList.add(...i.bulletActiveClass.split(" ")),e.isElement&&p.forEach((e,t)=>{e.setAttribute("part",t===r?"bullet-active":"bullet")}),i.dynamicBullets){for(var y=p[m],b=p[f],w=m;w<=f;w+=1)p[w]&&p[w].classList.add(...`${i.bulletActiveClass}-main`.split(" "));u(y,"prev"),u(b,"next")}}if(i.dynamicBullets){var k=Math.min(p.length,i.dynamicMainBullets+4),S=(a*k-a)/2-v*a,E=t?"right":"left";p.forEach(t=>{t.style[e.isHorizontal()?E:"top"]=`${S}px`})}}d.forEach((t,a)=>{if("fraction"===i.type&&(t.querySelectorAll(FR(i.currentClass)).forEach(e=>{e.textContent=i.formatFractionCurrent(r+1)}),t.querySelectorAll(FR(i.totalClass)).forEach(e=>{e.textContent=i.formatFractionTotal(c)})),"progressbar"===i.type){var o;o=i.progressbarOpposite?e.isHorizontal()?"vertical":"horizontal":e.isHorizontal()?"horizontal":"vertical";var s=(r+1)/c,u=1,l=1;"horizontal"===o?u=s:l=s,t.querySelectorAll(FR(i.progressbarFillClass)).forEach(t=>{t.style.transform=`translate3d(0,0,0) scaleX(${u}) scaleY(${l})`,t.style.transitionDuration=`${e.params.speed}ms`})}"custom"===i.type&&i.renderCustom?(tR(t,i.renderCustom(e,r+1,c)),0===a&&n("paginationRender",t)):(0===a&&n("paginationRender",t),n("paginationUpdate",t)),e.params.watchOverflow&&e.enabled&&t.classList[e.isLocked?"add":"remove"](i.lockClass)})}}function h(){var t=e.params.pagination;if(!s()){var i=e.virtual&&e.params.virtual.enabled?e.virtual.slides.length:e.grid&&e.params.grid.rows>1?e.slides.length/Math.ceil(e.params.grid.rows):e.slides.length,a=e.pagination.el;a=eR(a);var r="";if("bullets"===t.type){var o=e.params.loop?Math.ceil(i/e.params.slidesPerGroup):e.snapGrid.length;e.params.freeMode&&e.params.freeMode.enabled&&o>i&&(o=i);for(var u=0;u<o;u+=1)t.renderBullet?r+=t.renderBullet.call(e,u,t.bulletClass):r+=`<${t.bulletElement} ${e.isElement?'part="bullet"':""} class="${t.bulletClass}"></${t.bulletElement}>`}"fraction"===t.type&&(r=t.renderFraction?t.renderFraction.call(e,t.currentClass,t.totalClass):`<span class="${t.currentClass}"></span> / <span class="${t.totalClass}"></span>`),"progressbar"===t.type&&(r=t.renderProgressbar?t.renderProgressbar.call(e,t.progressbarFillClass):`<span class="${t.progressbarFillClass}"></span>`),e.pagination.bullets=[],a.forEach(i=>{"custom"!==t.type&&tR(i,r||""),"bullets"===t.type&&e.pagination.bullets.push(...i.querySelectorAll(FR(t.bulletClass)))}),"custom"!==t.type&&n("paginationRender",a[0])}}function c(){e.params.pagination=function(e,t,i,n){return e.params.createElements&&Object.keys(n).forEach(a=>{if(!i[a]&&!0===i.auto){var r=K_(e.el,`.${n[a]}`)[0];r||((r=Y_("div",n[a])).className=n[a],e.el.append(r)),i[a]=r,t[a]=r}}),i}(e,e.originalParams.pagination,e.params.pagination,{el:"swiper-pagination"});var t,i=e.params.pagination;i.el&&("string"==typeof i.el&&e.isElement&&(t=e.el.querySelector(i.el)),t||"string"!=typeof i.el||(t=[...document.querySelectorAll(i.el)]),t||(t=i.el),t&&0!==t.length&&(e.params.uniqueNavElements&&"string"==typeof i.el&&Array.isArray(t)&&t.length>1&&(t=[...e.el.querySelectorAll(i.el)]).length>1&&(t=t.find(t=>Q_(t,".swiper")[0]===e.el)),Array.isArray(t)&&1===t.length&&(t=t[0]),Object.assign(e.pagination,{el:t}),(t=eR(t)).forEach(t=>{"bullets"===i.type&&i.clickable&&t.classList.add(...(i.clickableClass||"").split(" ")),t.classList.add(i.modifierClass+i.type),t.classList.add(e.isHorizontal()?i.horizontalClass:i.verticalClass),"bullets"===i.type&&i.dynamicBullets&&(t.classList.add(`${i.modifierClass}${i.type}-dynamic`),o=0,i.dynamicMainBullets<1&&(i.dynamicMainBullets=1)),"progressbar"===i.type&&i.progressbarOpposite&&t.classList.add(i.progressbarOppositeClass),i.clickable&&t.addEventListener("click",l),e.enabled||t.classList.add(i.lockClass)})))}function m(){var t=e.params.pagination;if(!s()){var i=e.pagination.el;i&&(i=eR(i)).forEach(i=>{i.classList.remove(t.hiddenClass),i.classList.remove(t.modifierClass+t.type),i.classList.remove(e.isHorizontal()?t.horizontalClass:t.verticalClass),t.clickable&&(i.classList.remove(...(t.clickableClass||"").split(" ")),i.removeEventListener("click",l))}),e.pagination.bullets&&e.pagination.bullets.forEach(e=>e.classList.remove(...t.bulletActiveClass.split(" ")))}}i("changeDirection",()=>{if(e.pagination&&e.pagination.el){var t=e.params.pagination,i=e.pagination.el;(i=eR(i)).forEach(i=>{i.classList.remove(t.horizontalClass,t.verticalClass),i.classList.add(e.isHorizontal()?t.horizontalClass:t.verticalClass)})}}),i("init",()=>{!1===e.params.pagination.enabled?f():(c(),h(),d())}),i("activeIndexChange",()=>{void 0===e.snapIndex&&d()}),i("snapIndexChange",()=>{d()}),i("snapGridLengthChange",()=>{h(),d()}),i("destroy",()=>{m()}),i("enable disable",()=>{var t=e.pagination.el;t&&(t=eR(t)).forEach(t=>t.classList[e.enabled?"remove":"add"](e.params.pagination.lockClass))}),i("lock unlock",()=>{d()}),i("click",(t,i)=>{var a=i.target,r=eR(e.pagination.el);if(e.params.pagination.el&&e.params.pagination.hideOnClick&&r&&r.length>0&&!a.classList.contains(e.params.pagination.bulletClass)){if(e.navigation&&(e.navigation.nextEl&&a===e.navigation.nextEl||e.navigation.prevEl&&a===e.navigation.prevEl))return;var o=r[0].classList.contains(e.params.pagination.hiddenClass);n(!0===o?"paginationShow":"paginationHide"),r.forEach(t=>t.classList.toggle(e.params.pagination.hiddenClass))}});var f=()=>{e.el.classList.add(e.params.pagination.paginationDisabledClass);var t=e.pagination.el;t&&(t=eR(t)).forEach(t=>t.classList.add(e.params.pagination.paginationDisabledClass)),m()};Object.assign(e.pagination,{enable:()=>{e.el.classList.remove(e.params.pagination.paginationDisabledClass);var t=e.pagination.el;t&&(t=eR(t)).forEach(t=>t.classList.remove(e.params.pagination.paginationDisabledClass)),c(),h(),d()},disable:f,render:h,update:d,init:c,destroy:m})}function WR({swiper:e,extendParams:t,on:i,emit:n,params:a}){var r,o;e.autoplay={running:!1,paused:!1,timeLeft:0},t({autoplay:{enabled:!1,delay:3e3,waitForTransition:!0,disableOnInteraction:!1,stopOnLastSlide:!1,reverseDirection:!1,pauseOnMouseEnter:!1}});var s,u,l,d,h,c,m,f=a&&a.autoplay?a.autoplay.delay:3e3,v=a&&a.autoplay?a.autoplay.delay:3e3,p=(new Date).getTime();function g(t){e&&!e.destroyed&&e.wrapperEl&&t.target===e.wrapperEl&&(e.wrapperEl.removeEventListener("transitionend",g),m||t.detail&&t.detail.bySwiperTouchMove||T())}var y=()=>{if(!e.destroyed&&e.autoplay.running){e.autoplay.paused?u=!0:u&&(v=s,u=!1);var t=e.autoplay.paused?s:p+v-(new Date).getTime();e.autoplay.timeLeft=t,n("autoplayTimeLeft",t,t/f),o=requestAnimationFrame(()=>{y()})}},b=()=>{var t=e.params.autoplay.delay,i=(()=>{var t;if(t=e.virtual&&e.params.virtual.enabled?e.slides.find(e=>e.classList.contains("swiper-slide-active")):e.slides[e.activeIndex])return parseInt(t.getAttribute("data-swiper-autoplay"),10)})();return!Number.isNaN(i)&&i>0&&(t=i),t},w=t=>{if(!e.destroyed&&e.autoplay.running){cancelAnimationFrame(o),y();var i=t;void 0===i&&(i=b(),f=i,v=i),s=i;var a=e.params.speed,u=()=>{e&&!e.destroyed&&(e.params.autoplay.reverseDirection?!e.isBeginning||e.params.loop||e.params.rewind?(e.slidePrev(a,!0,!0),n("autoplay")):e.params.autoplay.stopOnLastSlide||(e.slideTo(e.slides.length-1,a,!0,!0),n("autoplay")):!e.isEnd||e.params.loop||e.params.rewind?(e.slideNext(a,!0,!0),n("autoplay")):e.params.autoplay.stopOnLastSlide||(e.slideTo(0,a,!0,!0),n("autoplay")),e.params.cssMode&&(p=(new Date).getTime(),requestAnimationFrame(()=>{w()})))};return i>0?(clearTimeout(r),r=setTimeout(()=>{u()},i)):requestAnimationFrame(()=>{u()}),i}},k=()=>{p=(new Date).getTime(),e.autoplay.running=!0,w(),n("autoplayStart")},S=()=>{e.autoplay.running=!1,clearTimeout(r),cancelAnimationFrame(o),n("autoplayStop")},E=(t,i)=>{if(!e.destroyed&&e.autoplay.running){clearTimeout(r),t||(c=!0);var a=()=>{n("autoplayPause"),e.params.autoplay.waitForTransition?e.wrapperEl.addEventListener("transitionend",g):T()};if(e.autoplay.paused=!0,i)a();else{var o=s||e.params.autoplay.delay;s=o-((new Date).getTime()-p),e.isEnd&&s<0&&!e.params.loop||(s<0&&(s=0),a())}}},T=()=>{e.isEnd&&s<0&&!e.params.loop||e.destroyed||!e.autoplay.running||(p=(new Date).getTime(),c?(c=!1,w(s)):w(),e.autoplay.paused=!1,n("autoplayResume"))},P=()=>{if(!e.destroyed&&e.autoplay.running){var t=L_();"hidden"===t.visibilityState&&(c=!0,E(!0)),"visible"===t.visibilityState&&T()}},M=t=>{"mouse"===t.pointerType&&(c=!0,m=!0,e.animating||e.autoplay.paused||E(!0))},A=t=>{"mouse"===t.pointerType&&(m=!1,e.autoplay.paused&&T())};i("init",()=>{e.params.autoplay.enabled&&(e.params.autoplay.pauseOnMouseEnter&&(e.el.addEventListener("pointerenter",M),e.el.addEventListener("pointerleave",A)),L_().addEventListener("visibilitychange",P),k())}),i("destroy",()=>{e.el&&"string"!=typeof e.el&&(e.el.removeEventListener("pointerenter",M),e.el.removeEventListener("pointerleave",A)),L_().removeEventListener("visibilitychange",P),e.autoplay.running&&S()}),i("_freeModeStaticRelease",()=>{(d||c)&&T()}),i("_freeModeNoMomentumRelease",()=>{e.params.autoplay.disableOnInteraction?S():E(!0,!0)}),i("beforeTransitionStart",(t,i,n)=>{!e.destroyed&&e.autoplay.running&&(n||!e.params.autoplay.disableOnInteraction?E(!0,!0):S())}),i("sliderFirstMove",()=>{!e.destroyed&&e.autoplay.running&&(e.params.autoplay.disableOnInteraction?S():(l=!0,d=!1,c=!1,h=setTimeout(()=>{c=!0,d=!0,E(!0)},200)))}),i("touchEnd",()=>{if(!e.destroyed&&e.autoplay.running&&l){if(clearTimeout(h),clearTimeout(r),e.params.autoplay.disableOnInteraction)return d=!1,void(l=!1);d&&e.params.cssMode&&T(),d=!1,l=!1}}),i("slideChange",()=>{!e.destroyed&&e.autoplay.running&&e.autoplay.paused&&(s=b(),f=b())}),Object.assign(e.autoplay,{start:k,stop:S,pause:E,resume:T})}function $R(e,t){var i=V_(t);return i!==t&&(i.style.backfaceVisibility="hidden",i.style["-webkit-backface-visibility"]="hidden"),i}function NR(e,t,i){var n=`swiper-slide-shadow${i?`-${i}`:""} swiper-slide-shadow-${e}`,a=V_(t),r=a.querySelector(`.${n.split(" ").join(".")}`);return r||(r=Y_("div",n.split(" ")),a.append(r)),r}function jR({swiper:e,extendParams:t,on:i}){t({coverflowEffect:{rotate:50,stretch:0,depth:100,scale:1,modifier:1,slideShadows:!0}});!function(e){var t,i=e.effect,n=e.swiper,a=e.on,r=e.setTranslate,o=e.setTransition,s=e.overwriteParams,u=e.perspective,l=e.recreateShadows,d=e.getEffectParams;a("beforeInit",()=>{if(n.params.effect===i){n.classNames.push(`${n.params.containerModifierClass}${i}`),u&&u()&&n.classNames.push(`${n.params.containerModifierClass}3d`);var e=s?s():{};Object.assign(n.params,e),Object.assign(n.originalParams,e)}}),a("setTranslate _virtualUpdated",()=>{n.params.effect===i&&r()}),a("setTransition",(e,t)=>{n.params.effect===i&&o(t)}),a("transitionEnd",()=>{if(n.params.effect===i&&l){if(!d||!d().slideShadows)return;n.slides.forEach(e=>{e.querySelectorAll(".swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left").forEach(e=>e.remove())}),l()}}),a("virtualUpdate",()=>{n.params.effect===i&&(n.slides.length||(t=!0),requestAnimationFrame(()=>{t&&n.slides&&n.slides.length&&(r(),t=!1)}))})}({effect:"coverflow",swiper:e,on:i,setTranslate:()=>{for(var t=e.width,i=e.height,n=e.slides,a=e.slidesSizesGrid,r=e.params.coverflowEffect,o=e.isHorizontal(),s=e.translate,u=o?t/2-s:i/2-s,l=o?r.rotate:-r.rotate,d=r.depth,h=function(e){return t=>Math.abs(t)>0&&e.browser&&e.browser.need3dFix&&Math.abs(t)%90==0?t+.001:t}(e),c=0,m=n.length;c<m;c+=1){var f=n[c],v=a[c],p=(u-f.swiperSlideOffset-v/2)/v,g="function"==typeof r.modifier?r.modifier(p):p*r.modifier,y=o?l*g:0,b=o?0:l*g,w=-d*Math.abs(g),k=r.stretch;"string"==typeof k&&-1!==k.indexOf("%")&&(k=parseFloat(r.stretch)/100*v);var S=o?0:k*g,E=o?k*g:0,T=1-(1-r.scale)*Math.abs(g);Math.abs(E)<.001&&(E=0),Math.abs(S)<.001&&(S=0),Math.abs(w)<.001&&(w=0),Math.abs(y)<.001&&(y=0),Math.abs(b)<.001&&(b=0),Math.abs(T)<.001&&(T=0);var P=`translate3d(${E}px,${S}px,${w}px) rotateX(${h(b)}deg) rotateY(${h(y)}deg) scale(${T})`;if($R(0,f).style.transform=P,f.style.zIndex=1-Math.abs(Math.round(g)),r.slideShadows){var M=o?f.querySelector(".swiper-slide-shadow-left"):f.querySelector(".swiper-slide-shadow-top"),A=o?f.querySelector(".swiper-slide-shadow-right"):f.querySelector(".swiper-slide-shadow-bottom");M||(M=NR("coverflow",f,o?"left":"top")),A||(A=NR("coverflow",f,o?"right":"bottom")),M&&(M.style.opacity=g>0?g:0),A&&(A.style.opacity=-g>0?-g:0)}}},setTransition:t=>{e.slides.map(e=>V_(e)).forEach(e=>{e.style.transitionDuration=`${t}ms`,e.querySelectorAll(".swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left").forEach(e=>{e.style.transitionDuration=`${t}ms`})})},perspective:()=>!0,overwriteParams:()=>({watchSlidesProgress:!0})})}Object.keys(LR).forEach(e=>{Object.keys(LR[e]).forEach(t=>{RR.prototype[t]=LR[e][t]})}),RR.use([function({swiper:e,on:t,emit:i}){var n=W_(),a=null,r=null,o=()=>{e&&!e.destroyed&&e.initialized&&(i("beforeResize"),i("resize"))},s=()=>{e&&!e.destroyed&&e.initialized&&i("orientationchange")};t("init",()=>{e.params.resizeObserver&&void 0!==n.ResizeObserver?e&&!e.destroyed&&e.initialized&&(a=new ResizeObserver(t=>{r=n.requestAnimationFrame(()=>{var i=e.width,n=e.height,a=i,r=n;t.forEach(({contentBoxSize:t,contentRect:i,target:n})=>{n&&n!==e.el||(a=i?i.width:(t[0]||t).inlineSize,r=i?i.height:(t[0]||t).blockSize)}),a===i&&r===n||o()})})).observe(e.el):(n.addEventListener("resize",o),n.addEventListener("orientationchange",s))}),t("destroy",()=>{r&&n.cancelAnimationFrame(r),a&&a.unobserve&&e.el&&(a.unobserve(e.el),a=null),n.removeEventListener("resize",o),n.removeEventListener("orientationchange",s)})},function({swiper:e,extendParams:t,on:i,emit:n}){var a=[],r=W_(),o=(t,i={})=>{var o=new(r.MutationObserver||r.WebkitMutationObserver)(t=>{if(!e.__preventObserver__)if(1!==t.length){var i=function(){n("observerUpdate",t[0])};r.requestAnimationFrame?r.requestAnimationFrame(i):r.setTimeout(i,0)}else n("observerUpdate",t[0])});o.observe(t,{attributes:void 0===i.attributes||i.attributes,childList:e.isElement||(void 0===i.childList||i).childList,characterData:void 0===i.characterData||i.characterData}),a.push(o)};t({observer:!1,observeParents:!1,observeSlideChildren:!1}),i("init",()=>{if(e.params.observer){if(e.params.observeParents)for(var t=Q_(e.hostEl),i=0;i<t.length;i+=1)o(t[i]);o(e.hostEl,{childList:e.params.observeSlideChildren}),o(e.wrapperEl,{attributes:!1})}}),i("destroy",()=>{a.forEach(e=>{e.disconnect()}),a.splice(0,a.length)})}]);var BR,zR,UR=e=>e,HR=function(){function i(){var e;return u(this,i),(e=s(this,i,arguments)).inFocusedState=!1,e.scaleFactor=1,e.updateSpacing=t=>{e.slideSpacing=t.detail.spacing,e.swiperInstance&&(e.swiperInstance.params.spaceBetween=e.slideSpacing,e.swiperInstance.update())},e}return y(i,bs),m(i,[{key:"connectedCallback",value:function(){M(i,"connectedCallback",this)([]),window.addEventListener("child-spacing",this.updateSpacing,!1)}},{key:"disconnectedCallback",value:function(){M(i,"disconnectedCallback",this)([]),window.removeEventListener("child-spacing",this.updateSpacing,!1)}},{key:"styles",value:function(){var e,i,n,a=this.scaleFactor,r=this.component,o=r.backgroundBlur,s=r.indicator,u=r.activeIndicator,l=r.previousSlidePadding,d=r.nextSlidePadding,h="vertical"===r.direction?"margin-top":"margin-left";return t.unsafeCSS(`\n :host {\n display: ${r.hidden?"none":"flex"};\n flex-direction: column !important;\n ${Ys(r.position)} \n width: 100%;\n bottom: -1px;\n background-repeat: no-repeat;\n background-size: cover;\n background-position: center;\n ${o?`backdrop-filter: blur(${o}px);`:""}\n z-index: ${null!==(e=r.zIndex)&&void 0!==e?e:1};\n top: 0px;\n transition: all 0.3s;\n ${Ns(r,a)}\n ${function(e,t){return`\n padding-right: ${xs(t,e.nextSlidePadding)}px !important;\n padding-left: ${xs(t,e.previousSlidePadding)}px !important;\n `}(r,a)}\n ${Fs(r)}\n ${Rs(r,!1)}\n max-width: 100vw;\n }\n :host(:focus){\n ${Rs(r,!0)}\n ${Ks(r,a,!0)}\n }\n :host(:focus-visible){\n ${Zs(r)}\n }\n :host > *:not(:first-child) {\n ${h}: ${r.spacing?r.spacing*a:0}px;\n }\n .swiper-container {\n ${zs(r,a)};\n padding-left: ${null!=l?l:0}px;\n padding-right: ${null!=d?d:0}px;\n box-sizing: border-box;\n }\n .swiper-pagination{\n position: relative;\n padding: 8px;\n }\n .swiper-pagination-bullet {\n opacity: 1 !important;\n ${null!=(null==s?void 0:s.width)?`width: ${s.width}px !important;`:""}\n ${null!=(null==s?void 0:s.height)?`height: ${s.height}px !important;`:""}\n ${null!=(null==s?void 0:s.borderRadius)?`border-radius: ${s.borderRadius}px !important;`:""}\n background: ${null!==(i=null==s?void 0:s.fillColor)&&void 0!==i?i:r.indicatorColor} !important;\n }\n .swiper-pagination-bullet-active {\n ${null!=(null==u?void 0:u.width)?`width: ${u.width}px !important;`:""}\n ${null!=(null==u?void 0:u.height)?`height: ${u.height}px !important;`:""}\n ${null!=(null==u?void 0:u.borderRadius)?`border-radius: ${u.borderRadius}px !important;`:""}\n background: ${null!==(n=null==u?void 0:u.fillColor)&&void 0!==n?n:r.activeIndicatorColor} !important;\n }\n `)}},{key:"updated",value:function(){var e,t,i=[OR,WR],n=this.component,a=n.autoplay,r=n.autoplaySeconds,o=n.showIndicators,s=n.slideSpacing,u=n.inactiveSlideScale;u&&i.push(jR),RR.use(i);var l=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector(".swiper-container"),d=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector(".swiper-pagination");if(l&&!this.swiperInstance){var h,c={initialSlide:0,slidesPerView:1,loop:a,spaceBetween:null!==(h=null!=s?s:this.slideSpacing)&&void 0!==h?h:0,autoplay:!!a&&{delay:1e3*r,disableOnInteraction:!1},pagination:!(null!=o&&!o)&&{el:d,clickable:!0},on:{init:e=>{this.handleSlideChange(e)},slideChange:e=>{this.handleSlideChange(e)}}};u&&(c.effect="coverflow",c.coverflowEffect={rotate:0,stretch:0,depth:100,modifier:1,slideShadows:!1,scale:u}),this.swiperInstance=new RR(l,c)}}},{key:"handleSlideChange",value:function(e){if(this.contextProvider.setCurrentSlideIndex(e.realIndex),this.component.onChange){var t,i=this.getCarouselOnChange(this.component),n=null==i||null===(t=i.parameters)||void 0===t||null===(t=t.partialState)||void 0===t?void 0:t.currentGroupId;n&&this.contextProvider.setCurrentGroupData(n,"")}}},{key:"getCarouselOnChange",value:function(e){var t;if(e.onChange&&e.onChange.parameters){var i=this.contextProvider.state.slides,n="string"==typeof e.loopSource?e.loopSource:"",a=null==i||null===(t=i[n])||void 0===t||null===(t=t.carouselName)||void 0===t?void 0:t[this.contextProvider.state.currentSlideIndex];return Gn(e.onChange,{slide:a,sku:this.contextProvider.state.sku,state:this.contextProvider.state,launch:this.contextProvider.state.launch,customer:this.contextProvider.state.customer})}}},{key:"getCarouselSlides",value:function(t){var i,n;if(!t.loopSource)return[];var a,r=this.contextProvider.state,o=r.slides,s=r.selectedProducts,u="string"==typeof t.loopSource?t.loopSource:"",l=Nn(this.contextProvider.productDetails,null!==(i=null===(n=this.contextProvider.getSelectedPaywall())||void 0===n?void 0:n.sku_menus)&&void 0!==i?i:[],u),d=[];e.empty(o)||(d=""!=u?o[u].carouselName:null!==(a=t.loopSource)&&void 0!==a?a:[]);var h=this.contextProvider.filteredSkuMenus.map(e=>e.id);return d.filter(e=>!e.productGroupId||h.includes(e.productGroupId)).map(e=>{var i=l.find(t=>t.id==s[e.productGroupId]);return Gn(t.components,Gn({slide:e},{sku:v({},Bn(null==i?void 0:i.product_details,e,l))}))||[]})}},{key:"render",value:function(){var e=this.getCarouselSlides(this.component),i=this.component,n=i.focusedBorderColor,a=i.focusedFillColor,r=i.fillColor;return!n&&na(r,a)||(this.tabIndex=0),t.html(BR||(BR=UR`
|
|
514
514
|
<link rel="stylesheet" href="https://unpkg.com/swiper/swiper-bundle.min.css"/>
|
|
515
515
|
<div class="swiper-container" aria-live="assertive" aria-atomic="true">
|
|
516
516
|
<div class="swiper-wrapper">
|
|
@@ -518,10 +518,10 @@
|
|
|
518
518
|
</div>
|
|
519
519
|
</div>
|
|
520
520
|
<div class="swiper-pagination"></div>
|
|
521
|
-
`),e.map(e=>e.map(e=>(e.spacing&&(this.slideSpacing=2*e.spacing),t.html(
|
|
521
|
+
`),e.map(e=>e.map(e=>(e.spacing&&(this.slideSpacing=2*e.spacing),t.html(zR||(zR=UR`
|
|
522
522
|
<div class="swiper-slide">
|
|
523
523
|
${0}
|
|
524
|
-
</div>`),Iu(this.contextProvider,e,this.scaleFactor,void 0,this.minSDKVersion))))))}}])}();Ae([ot({type:Object})],UR.prototype,"component",void 0),Ae([ot({type:Boolean})],UR.prototype,"inFocusedState",void 0),Ae([ot({type:Number})],UR.prototype,"scaleFactor",void 0),Ae([ot({type:Object})],UR.prototype,"minSDKVersion",void 0),UR=Ae([Fe("nami-carousel-container")],UR);var HR=function(){function e(){var t;return u(this,e),(t=s(this,e)).inFocusedState=!1,t.scaleFactor=1,t._handleFocus=()=>{t.inFocusedState=!0},t._handleBlur=()=>{t.inFocusedState=!1},t._handleKeyDown=e=>{"Enter"!==e.key&&" "!==e.key&&142!==e.keyCode&&195!==e.keyCode||t._handleClick()},t._handleClick=()=>{Ao({contextProvider:t.contextProvider,onTap:t.muted?t.component.mutedOnTap:t.component.volumeOnTap}),t.requestUpdate()},t.addEventListener("click",t._handleClick,!1),t.addEventListener("focus",t._handleFocus,!1),t.addEventListener("blur",t._handleBlur,!1),t.addEventListener("keydown",t._handleKeyDown,!1),t}return y(e,bs),m(e,[{key:"updated",value:function(){var e;this.ariaLabel=this.component.screenreaderText||this.component.title||"",this.ariaDescription=null!==(e=this.component.screenreaderHint)&&void 0!==e?e:""}},{key:"styles",value:function(){var e=this.component,i=this.scaleFactor,n="vertical"===e.direction?"margin-top":"margin-left";return t.unsafeCSS(`\n :host {\n box-sizing: border-box;\n display: ${e.hidden?"none":"flex"};\n cursor: pointer;\n ${Rs(e,!1)}\n ${Fs(e)}\n ${Ks(e,i,!1)}\n }\n :host(:focus){\n ${Rs(e,!0)}\n ${Ks(e,i,!0)}\n }\n :host(:focus-visible){\n ${Zs(e)}\n }\n :host > *:not(:first-child) {\n ${n}: ${e.spacing?e.spacing*i:0}px;\n }\n `)}},{key:"render",value:function(){var e,t;this.muted=null!==(e=null===(t=Mo.instance)||void 0===t?void 0:t.muted)&&void 0!==e&&e,this.tabIndex=0,this.role="button",1==this.inFocusedState&&this.focus({preventScroll:!0});var i=this.muted?this.component.mutedComponents:this.component.volumeComponents;return null==i?void 0:i.map(e=>Iu(this.contextProvider,e,this.scaleFactor,this.inFocusedState,this.minSDKVersion))}}])}();Ae([ot({type:Object})],HR.prototype,"component",void 0),Ae([ot({type:Boolean})],HR.prototype,"inFocusedState",void 0),Ae([ot({type:Number})],HR.prototype,"scaleFactor",void 0),Ae([ot({type:Object})],HR.prototype,"minSDKVersion",void 0),HR=Ae([Fe("nami-volume-button")],HR);var GR=function(){function e(){var t;return u(this,e),(t=s(this,e)).inFocusedState=!1,t.scaleFactor=1,t._handleFocus=()=>{t.inFocusedState=!0},t._handleBlur=()=>{t.inFocusedState=!1},t._handleKeyDown=e=>{"Enter"!==e.key&&" "!==e.key&&142!==e.keyCode&&195!==e.keyCode||t._handleClick()},t._handleClick=()=>{Ao({contextProvider:t.contextProvider,onTap:t.playing?t.component.playingOnTap:t.component.pausedOnTap}),t.requestUpdate()},t.addEventListener("click",t._handleClick,!1),t.addEventListener("focus",t._handleFocus,!1),t.addEventListener("blur",t._handleBlur,!1),t.addEventListener("keydown",t._handleKeyDown,!1),t}return y(e,bs),m(e,[{key:"updated",value:function(){var e;this.ariaLabel=this.component.screenreaderText||this.component.title||"",this.ariaDescription=null!==(e=this.component.screenreaderHint)&&void 0!==e?e:""}},{key:"styles",value:function(){var e=this.component,i=this.scaleFactor,n="vertical"===e.direction?"margin-top":"margin-left";return t.unsafeCSS(`\n :host {\n box-sizing: border-box;\n display: ${e.hidden?"none":"flex"};\n cursor: pointer;\n ${Rs(e,!1)}\n ${Fs(e)}\n ${Ks(e,i,!1)}\n }\n :host(:focus){\n ${Rs(e,!0)}\n ${Ks(e,i,!0)}\n }\n :host(:focus-visible){\n ${Zs(e)}\n }\n :host > *:not(:first-child) {\n ${n}: ${e.spacing?e.spacing*i:0}px;\n }\n `)}},{key:"render",value:function(){var e,t;return this.playing=null!==(e=null===(t=Mo.instance)||void 0===t?void 0:t.playing)&&void 0!==e&&e,this.tabIndex=0,this.role="button",1==this.inFocusedState&&this.focus({preventScroll:!0}),(this.playing?this.component.playingComponents:this.component.pausedComponents).map(e=>Iu(this.contextProvider,e,this.scaleFactor,this.inFocusedState,this.minSDKVersion))}}])}();Ae([ot({type:Object})],GR.prototype,"component",void 0),Ae([ot({type:Boolean})],GR.prototype,"inFocusedState",void 0),Ae([ot({type:Number})],GR.prototype,"scaleFactor",void 0),Ae([ot({type:Object})],GR.prototype,"minSDKVersion",void 0),GR=Ae([Fe("nami-play-pause-button")],GR);var VR=function(){function e(){var t;return u(this,e),(t=s(this,e,arguments)).inFocusedState=!1,t.scaleFactor=1,t}return y(e,bs),m(e,[{key:"styles",value:function(){var e=this.component,i=this.scaleFactor,n=this.minSDKVersion,a=e.backgroundBlur,r="vertical"===e.direction,o=r?"width":"height",s=r?"margin-top":"margin-left",u=e.fillImage?t.unsafeCSS(`\n line-height: 1.5715;\n background-image: url(${e.fillImage});\n background-position: center;\n background-repeat: no-repeat;\n background-size: cover;\n height: 100%;\n width: 100%;\n `):t.unsafeCSS(Rs(e,!1));return t.unsafeCSS(`\n :host {\n box-sizing: border-box;\n display: ${e.hidden?"none":"flex"};\n ${a?`backdrop-filter: blur(${a}px);`:""}\n ${u};\n ${Ys(e.position)}\n ${Fs(e)}\n ${Ks(e,i,!1)}\n display: ${e.hidden?"none":"flex"};\n align-items: center;\n justify-content: center;\n }\n :host(:focus){\n ${Rs(e,!0)}\n ${Ks(e,i,!0)}\n }\n :host(:focus-visible){\n ${Zs(e)}\n }\n /* Overlapping children center on both axes like the other SDKs' ZStack;\n the flex center on :host doesn't reach absolutely-positioned boxes. */\n :host > *:not(nami-text) {\n position: absolute;\n inset: 0;\n margin: auto;\n }\n :host > * {\n ${Ws(n,o)}\n }\n :host > nami-text:not(:first-child) {\n ${s}: ${e.spacing?e.spacing*i:0}px;\n }\n `)}},{key:"render",value:function(){var e,t=this.component,i=t.focusedBorderColor,n=t.focusedFillColor,a=t.fillColor;return!i&&na(a,n)||(this.tabIndex=0),(null!==(e=this.component.components)&&void 0!==e?e:[]).map(e=>Iu(this.contextProvider,e,this.scaleFactor,void 0,this.minSDKVersion))}}])}();Ae([ot({type:Object})],VR.prototype,"component",void 0),Ae([ot({type:Boolean})],VR.prototype,"inFocusedState",void 0),Ae([ot({type:Number})],VR.prototype,"scaleFactor",void 0),Ae([ot({type:Object})],VR.prototype,"minSDKVersion",void 0),VR=Ae([Fe("nami-stack")],VR);var KR,XR,YR,qR=e=>e,JR="nami-disabled",QR=(KR=function(){function i(){var e;return u(this,i),(e=s(this,i,arguments)).active=!0,e.timeSpentOnPaywall=0,e.activeTemplate=null,e}return y(i,t.LitElement),m(i,[{key:"connectedCallback",value:function(){M(i,"connectedCallback",this)([]),this.minSDKVersion=e.parseToSemver(this.paywall.template.min_sdk_version),this.contextProvider=ut.create(this.paywall,this.context,this.campaign),this.contextConsumer=new ds(this,this.contextProvider),this.flow&&this.contextProvider.setFlow(this.flow),this.contextProvider.setTimeSpentOnPaywall(this.timeSpentOnPaywall),this.contextProvider.state.userInteractionEnabled||this.classList.add(JR),this.teardownEvent=this.contextProvider.onEvent("user-interaction-changed",this.userInteractionListener.bind(this))}},{key:"disconnectedCallback",value:function(){var e;M(i,"disconnectedCallback",this)([]),ut.remove(this.contextProvider),this.teardownEvent(),null===(e=this.footerResizeObserver)||void 0===e||e.disconnect(),this.active&&Po()}},{key:"userInteractionListener",value:function(e){this.classList.toggle(JR,!e.enabled)}},{key:"firstUpdated",value:function(){this.postImpression(),this.postPaywallScreenData(),this.updateActiveRenderRoot(),this.observeFooterHeight()}},{key:"updated",value:function(){this.updateActiveRenderRoot()}},{key:"updateActiveRenderRoot",value:function(){this.active&&this.activeTemplate&&(yo(this.activeTemplate,this.contextProvider),function(e){if(Ua("setActivePageRenderRoot:enter",{hasRoot:!!e,rootType:e instanceof Element?Ga(e):e instanceof DocumentFragment?"document-fragment":String(e),activePageKey:ga,activePageAnnounced:pa,activeElement:Ga(Za())}),va=e,e&&ma&&!pa){var t=Za();if(t&&"contains"in e&&e.contains(t))bo(t);else if(e instanceof DocumentFragment){var i=e.activeElement;i&&bo(i)}}}(this.renderRoot))}},{key:"observeFooterHeight",value:function(){if("undefined"!=typeof ResizeObserver){var e=this.renderRoot.querySelector("nami-footer");e&&(this.footerResizeObserver=new ResizeObserver(e=>{var t,i,n=e[e.length-1];if(n){var a=null!==(t=null===(i=n.borderBoxSize)||void 0===i||null===(i=i[0])||void 0===i?void 0:i.blockSize)&&void 0!==t?t:n.contentRect.height;this.style.setProperty("--nami-footer-height",`${a}px`)}}),this.footerResizeObserver.observe(e))}}},{key:"postImpression",value:function(){var t,i;null!==(t=this.paywall)&&void 0!==t&&t.id&&(t=>{var i,n,a;S(function(r){for(;;)switch(r.p=r.n){case 0:if(!e.isAnonymousMode()){r.n=1;break}return e.logger.info("Skipping paywall impression - anonymous mode"),r.a(2);case 1:return(i=e.storageService.getSessionId())&&(t.session=i),(n=e.storageService.getLaunchId())&&(t.launch_id=n),t.app_env="production",t.url_params=e.getUrlParams(),e.logger.info("Post paywall impression - segment ",t.segment),r.p=2,r.n=3,o(e.NamiAPI.instance.postImpression(t));case 3:r.n=5;break;case 4:r.p=4,a=r.v,e.logger.error("Error posting impression",a);case 5:return r.a(2)}},null,null,[[2,4]],Promise)})({segment:null===(i=this.campaign)||void 0===i?void 0:i.segment,call_to_action:this.paywall.id})}},{key:"postPaywallScreenData",value:function(){e.NamiEventEmitter.getInstance().emit(e.PAYWALL_ACTION_EVENT,v({},this.contextProvider.getPaywallActionEventData(),{action:e.NamiPaywallAction.SHOW_PAYWALL}))}},{key:"getTemplate",value:function(){var e,t,i,n;this.contextProvider.state.selectedPaywall===this.paywall?t=this.contextProvider.state.currentPage:t=null!==(i=null===(n=this.paywall.template)||void 0===n||null===(n=n.initialState)||void 0===n?void 0:n.currentPage)&&void 0!==i?i:"page1";var a=null===(e=this.paywall.template)||void 0===e?void 0:e.pages.find(e=>e.name===t);if(!a)throw new Error(`Page with name ${t} not found in paywall template.`);return this.activeTemplate=a,this.active&&yo(a,this.contextProvider),a}},{key:"render",value:function(){var i,n=this.getTemplate(),a=n.backgroundContainer,r=n.header,o=void 0===r?[]:r,s=n.footer,u=void 0===s?[]:s,l=n.contentContainer,d=null!==(i=this.contextProvider.state.fullScreenPresentation)&&void 0!==i&&i,h=this.contextProvider.getFormFactor(),c=e.getDeviceScaleFactor(h);return t.html(XR||(XR=qR`
|
|
524
|
+
</div>`),Iu(this.contextProvider,e,this.scaleFactor,void 0,this.minSDKVersion))))))}}])}();Ae([ot({type:Object})],HR.prototype,"component",void 0),Ae([ot({type:Boolean})],HR.prototype,"inFocusedState",void 0),Ae([ot({type:Number})],HR.prototype,"scaleFactor",void 0),Ae([ot({type:Object})],HR.prototype,"minSDKVersion",void 0),HR=Ae([Fe("nami-carousel-container")],HR);var GR=function(){function e(){var t;return u(this,e),(t=s(this,e)).inFocusedState=!1,t.scaleFactor=1,t._handleFocus=()=>{t.inFocusedState=!0},t._handleBlur=()=>{t.inFocusedState=!1},t._handleKeyDown=e=>{"Enter"!==e.key&&" "!==e.key&&142!==e.keyCode&&195!==e.keyCode||t._handleClick()},t._handleClick=()=>{Ao({contextProvider:t.contextProvider,onTap:t.muted?t.component.mutedOnTap:t.component.volumeOnTap}),t.requestUpdate()},t.addEventListener("click",t._handleClick,!1),t.addEventListener("focus",t._handleFocus,!1),t.addEventListener("blur",t._handleBlur,!1),t.addEventListener("keydown",t._handleKeyDown,!1),t}return y(e,bs),m(e,[{key:"updated",value:function(){var e;this.ariaLabel=this.component.screenreaderText||this.component.title||"",this.ariaDescription=null!==(e=this.component.screenreaderHint)&&void 0!==e?e:""}},{key:"styles",value:function(){var e=this.component,i=this.scaleFactor,n="vertical"===e.direction?"margin-top":"margin-left";return t.unsafeCSS(`\n :host {\n box-sizing: border-box;\n display: ${e.hidden?"none":"flex"};\n cursor: pointer;\n ${Rs(e,!1)}\n ${Fs(e)}\n ${Ks(e,i,!1)}\n }\n :host(:focus){\n ${Rs(e,!0)}\n ${Ks(e,i,!0)}\n }\n :host(:focus-visible){\n ${Zs(e)}\n }\n :host > *:not(:first-child) {\n ${n}: ${e.spacing?e.spacing*i:0}px;\n }\n `)}},{key:"render",value:function(){var e,t;this.muted=null!==(e=null===(t=Mo.instance)||void 0===t?void 0:t.muted)&&void 0!==e&&e,this.tabIndex=0,this.role="button",1==this.inFocusedState&&this.focus({preventScroll:!0});var i=this.muted?this.component.mutedComponents:this.component.volumeComponents;return null==i?void 0:i.map(e=>Iu(this.contextProvider,e,this.scaleFactor,this.inFocusedState,this.minSDKVersion))}}])}();Ae([ot({type:Object})],GR.prototype,"component",void 0),Ae([ot({type:Boolean})],GR.prototype,"inFocusedState",void 0),Ae([ot({type:Number})],GR.prototype,"scaleFactor",void 0),Ae([ot({type:Object})],GR.prototype,"minSDKVersion",void 0),GR=Ae([Fe("nami-volume-button")],GR);var VR=function(){function e(){var t;return u(this,e),(t=s(this,e)).inFocusedState=!1,t.scaleFactor=1,t._handleFocus=()=>{t.inFocusedState=!0},t._handleBlur=()=>{t.inFocusedState=!1},t._handleKeyDown=e=>{"Enter"!==e.key&&" "!==e.key&&142!==e.keyCode&&195!==e.keyCode||t._handleClick()},t._handleClick=()=>{Ao({contextProvider:t.contextProvider,onTap:t.playing?t.component.playingOnTap:t.component.pausedOnTap}),t.requestUpdate()},t.addEventListener("click",t._handleClick,!1),t.addEventListener("focus",t._handleFocus,!1),t.addEventListener("blur",t._handleBlur,!1),t.addEventListener("keydown",t._handleKeyDown,!1),t}return y(e,bs),m(e,[{key:"updated",value:function(){var e;this.ariaLabel=this.component.screenreaderText||this.component.title||"",this.ariaDescription=null!==(e=this.component.screenreaderHint)&&void 0!==e?e:""}},{key:"styles",value:function(){var e=this.component,i=this.scaleFactor,n="vertical"===e.direction?"margin-top":"margin-left";return t.unsafeCSS(`\n :host {\n box-sizing: border-box;\n display: ${e.hidden?"none":"flex"};\n cursor: pointer;\n ${Rs(e,!1)}\n ${Fs(e)}\n ${Ks(e,i,!1)}\n }\n :host(:focus){\n ${Rs(e,!0)}\n ${Ks(e,i,!0)}\n }\n :host(:focus-visible){\n ${Zs(e)}\n }\n :host > *:not(:first-child) {\n ${n}: ${e.spacing?e.spacing*i:0}px;\n }\n `)}},{key:"render",value:function(){var e,t;return this.playing=null!==(e=null===(t=Mo.instance)||void 0===t?void 0:t.playing)&&void 0!==e&&e,this.tabIndex=0,this.role="button",1==this.inFocusedState&&this.focus({preventScroll:!0}),(this.playing?this.component.playingComponents:this.component.pausedComponents).map(e=>Iu(this.contextProvider,e,this.scaleFactor,this.inFocusedState,this.minSDKVersion))}}])}();Ae([ot({type:Object})],VR.prototype,"component",void 0),Ae([ot({type:Boolean})],VR.prototype,"inFocusedState",void 0),Ae([ot({type:Number})],VR.prototype,"scaleFactor",void 0),Ae([ot({type:Object})],VR.prototype,"minSDKVersion",void 0),VR=Ae([Fe("nami-play-pause-button")],VR);var KR=function(){function e(){var t;return u(this,e),(t=s(this,e,arguments)).inFocusedState=!1,t.scaleFactor=1,t}return y(e,bs),m(e,[{key:"styles",value:function(){var e=this.component,i=this.scaleFactor,n=this.minSDKVersion,a=e.backgroundBlur,r="vertical"===e.direction,o=r?"width":"height",s=r?"margin-top":"margin-left",u=e.fillImage?t.unsafeCSS(`\n line-height: 1.5715;\n background-image: url(${e.fillImage});\n background-position: center;\n background-repeat: no-repeat;\n background-size: cover;\n height: 100%;\n width: 100%;\n `):t.unsafeCSS(Rs(e,!1));return t.unsafeCSS(`\n :host {\n box-sizing: border-box;\n display: ${e.hidden?"none":"flex"};\n ${a?`backdrop-filter: blur(${a}px);`:""}\n ${u};\n ${Ys(e.position)}\n ${Fs(e)}\n ${Ks(e,i,!1)}\n display: ${e.hidden?"none":"flex"};\n align-items: center;\n justify-content: center;\n }\n :host(:focus){\n ${Rs(e,!0)}\n ${Ks(e,i,!0)}\n }\n :host(:focus-visible){\n ${Zs(e)}\n }\n /* Overlapping children center on both axes like the other SDKs' ZStack;\n the flex center on :host doesn't reach absolutely-positioned boxes. */\n :host > *:not(nami-text) {\n position: absolute;\n inset: 0;\n margin: auto;\n }\n :host > * {\n ${Ws(n,o)}\n }\n :host > nami-text:not(:first-child) {\n ${s}: ${e.spacing?e.spacing*i:0}px;\n }\n `)}},{key:"render",value:function(){var e,t=this.component,i=t.focusedBorderColor,n=t.focusedFillColor,a=t.fillColor;return!i&&na(a,n)||(this.tabIndex=0),(null!==(e=this.component.components)&&void 0!==e?e:[]).map(e=>Iu(this.contextProvider,e,this.scaleFactor,void 0,this.minSDKVersion))}}])}();Ae([ot({type:Object})],KR.prototype,"component",void 0),Ae([ot({type:Boolean})],KR.prototype,"inFocusedState",void 0),Ae([ot({type:Number})],KR.prototype,"scaleFactor",void 0),Ae([ot({type:Object})],KR.prototype,"minSDKVersion",void 0),KR=Ae([Fe("nami-stack")],KR);var XR,YR,qR,JR=e=>e,QR="nami-disabled",ZR=(XR=function(){function i(){var e;return u(this,i),(e=s(this,i,arguments)).active=!0,e.timeSpentOnPaywall=0,e.activeTemplate=null,e}return y(i,t.LitElement),m(i,[{key:"connectedCallback",value:function(){M(i,"connectedCallback",this)([]),this.minSDKVersion=e.parseToSemver(this.paywall.template.min_sdk_version),this.contextProvider=ut.create(this.paywall,this.context,this.campaign),this.contextConsumer=new ds(this,this.contextProvider),this.flow&&this.contextProvider.setFlow(this.flow),this.contextProvider.setTimeSpentOnPaywall(this.timeSpentOnPaywall),this.contextProvider.state.userInteractionEnabled||this.classList.add(QR),this.teardownEvent=this.contextProvider.onEvent("user-interaction-changed",this.userInteractionListener.bind(this))}},{key:"disconnectedCallback",value:function(){var e;M(i,"disconnectedCallback",this)([]),ut.remove(this.contextProvider),this.teardownEvent(),null===(e=this.footerResizeObserver)||void 0===e||e.disconnect(),this.active&&Po()}},{key:"userInteractionListener",value:function(e){this.classList.toggle(QR,!e.enabled)}},{key:"firstUpdated",value:function(){this.postImpression(),this.postPaywallScreenData(),this.updateActiveRenderRoot(),this.observeFooterHeight()}},{key:"updated",value:function(){this.updateActiveRenderRoot()}},{key:"updateActiveRenderRoot",value:function(){this.active&&this.activeTemplate&&(yo(this.activeTemplate,this.contextProvider),function(e){if(Ua("setActivePageRenderRoot:enter",{hasRoot:!!e,rootType:e instanceof Element?Ga(e):e instanceof DocumentFragment?"document-fragment":String(e),activePageKey:ga,activePageAnnounced:pa,activeElement:Ga(Za())}),va=e,e&&ma&&!pa){var t=Za();if(t&&"contains"in e&&e.contains(t))bo(t);else if(e instanceof DocumentFragment){var i=e.activeElement;i&&bo(i)}}}(this.renderRoot))}},{key:"observeFooterHeight",value:function(){if("undefined"!=typeof ResizeObserver){var e=this.renderRoot.querySelector("nami-footer");e&&(this.footerResizeObserver=new ResizeObserver(e=>{var t,i,n=e[e.length-1];if(n){var a=null!==(t=null===(i=n.borderBoxSize)||void 0===i||null===(i=i[0])||void 0===i?void 0:i.blockSize)&&void 0!==t?t:n.contentRect.height;this.style.setProperty("--nami-footer-height",`${a}px`)}}),this.footerResizeObserver.observe(e))}}},{key:"postImpression",value:function(){var t,i;null!==(t=this.paywall)&&void 0!==t&&t.id&&(t=>{var i,n,a;S(function(r){for(;;)switch(r.p=r.n){case 0:if(!e.isAnonymousMode()){r.n=1;break}return e.logger.info("Skipping paywall impression - anonymous mode"),r.a(2);case 1:return(i=e.storageService.getSessionId())&&(t.session=i),(n=e.storageService.getLaunchId())&&(t.launch_id=n),t.app_env="production",t.url_params=e.getUrlParams(),e.logger.info("Post paywall impression - segment ",t.segment),r.p=2,r.n=3,o(e.NamiAPI.instance.postImpression(t));case 3:r.n=5;break;case 4:r.p=4,a=r.v,e.logger.error("Error posting impression",a);case 5:return r.a(2)}},null,null,[[2,4]],Promise)})({segment:null===(i=this.campaign)||void 0===i?void 0:i.segment,call_to_action:this.paywall.id})}},{key:"postPaywallScreenData",value:function(){e.NamiEventEmitter.getInstance().emit(e.PAYWALL_ACTION_EVENT,v({},this.contextProvider.getPaywallActionEventData(),{action:e.NamiPaywallAction.SHOW_PAYWALL}))}},{key:"getTemplate",value:function(){var e,t,i,n;this.contextProvider.state.selectedPaywall===this.paywall?t=this.contextProvider.state.currentPage:t=null!==(i=null===(n=this.paywall.template)||void 0===n||null===(n=n.initialState)||void 0===n?void 0:n.currentPage)&&void 0!==i?i:"page1";var a=null===(e=this.paywall.template)||void 0===e?void 0:e.pages.find(e=>e.name===t);if(!a)throw new Error(`Page with name ${t} not found in paywall template.`);return this.activeTemplate=a,this.active&&yo(a,this.contextProvider),a}},{key:"render",value:function(){var i,n=this.getTemplate(),a=n.backgroundContainer,r=n.header,o=void 0===r?[]:r,s=n.footer,u=void 0===s?[]:s,l=n.contentContainer,d=null!==(i=this.contextProvider.state.fullScreenPresentation)&&void 0!==i&&i,h=this.contextProvider.getFormFactor(),c=e.getDeviceScaleFactor(h);return t.html(YR||(YR=JR`
|
|
525
525
|
<nami-background-container
|
|
526
526
|
.component=${0}
|
|
527
527
|
.scaleFactor=${0}
|
|
@@ -545,7 +545,7 @@
|
|
|
545
545
|
.scaleFactor=${0}
|
|
546
546
|
.minSDKVersion=${0}
|
|
547
547
|
></nami-footer>
|
|
548
|
-
`),a,c,this.minSDKVersion,o,h,c,d,this.minSDKVersion,l,c,h,this.minSDKVersion,u,c,this.minSDKVersion)}}])}(),
|
|
548
|
+
`),a,c,this.minSDKVersion,o,h,c,d,this.minSDKVersion,l,c,h,this.minSDKVersion,u,c,this.minSDKVersion)}}])}(),XR.styles=t.css(qR||(qR=JR`
|
|
549
549
|
:host {
|
|
550
550
|
display: flex;
|
|
551
551
|
flex-direction: column;
|
|
@@ -554,15 +554,15 @@
|
|
|
554
554
|
min-height: 0;
|
|
555
555
|
overflow: hidden;
|
|
556
556
|
}
|
|
557
|
-
`)),KR);Ae([ot({type:Object})],QR.prototype,"paywall",void 0),Ae([ot({type:Object})],QR.prototype,"campaign",void 0),Ae([ot({type:Object})],QR.prototype,"context",void 0),Ae([ot({type:Boolean})],QR.prototype,"active",void 0),Ae([function({context:e}){return(t,i)=>{var n=new WeakMap;if("object"==typeof i)return{get(){return t.get.call(this)},set(e){return n.get(this).setValue(e),t.set.call(this,e)},init(t){return n.set(this,new ls(this,{context:e,initialValue:t})),t}};t.constructor.addInitializer(t=>{n.set(t,new ls(t,{context:e}))});var a,r=Object.getOwnPropertyDescriptor(t,i);if(void 0===r){var o=new WeakMap;a={get(){return o.get(this)},set(e){n.get(this).setValue(e),o.set(this,e)},configurable:!0,enumerable:!0}}else{var s=r.set;a=v({},r,{set(e){n.get(this).setValue(e),null==s||s.call(this,e)}})}Object.defineProperty(t,i,a)}}({context:hs})],QR.prototype,"contextProvider",void 0),QR=Ae([Fe("nami-paywall-screen")],QR);var ZR,eF,tF={};function iF(){return eF?ZR:(eF=1,ZR=function(){return"function"==typeof Promise&&Promise.prototype&&Promise.prototype.then})}var nF,aF={},rF={};function oF(){if(nF)return rF;var e;nF=1;var t=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return rF.getSymbolSize=function(e){if(!e)throw new Error('"version" cannot be null or undefined');if(e<1||e>40)throw new Error('"version" should be in range from 1 to 40');return 4*e+17},rF.getSymbolTotalCodewords=function(e){return t[e]},rF.getBCHDigit=function(e){for(var t=0;0!==e;)t++,e>>>=1;return t},rF.setToSJISFunction=function(t){if("function"!=typeof t)throw new Error('"toSJISFunc" is not a valid function.');e=t},rF.isKanjiModeEnabled=function(){return void 0!==e},rF.toSJIS=function(t){return e(t)},rF}var sF,uF,lF,dF,hF,cF={};function mF(){return sF||(sF=1,function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2},e.isValid=function(e){return e&&void 0!==e.bit&&e.bit>=0&&e.bit<4},e.from=function(t,i){if(e.isValid(t))return t;try{return function(t){if("string"!=typeof t)throw new Error("Param is not a string");switch(t.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+t)}}(t)}catch(e){return i}}}(cF)),cF}var fF,vF={};var pF,gF={};var yF,bF={};var wF,kF={};function SF(){if(wF)return kF;wF=1;var e=mF(),t=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],i=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return kF.getBlocksCount=function(i,n){switch(n){case e.L:return t[4*(i-1)+0];case e.M:return t[4*(i-1)+1];case e.Q:return t[4*(i-1)+2];case e.H:return t[4*(i-1)+3];default:return}},kF.getTotalCodewordsCount=function(t,n){switch(n){case e.L:return i[4*(t-1)+0];case e.M:return i[4*(t-1)+1];case e.Q:return i[4*(t-1)+2];case e.H:return i[4*(t-1)+3];default:return}},kF}var EF,TF,PF,MF,AF={},DF={};function xF(){return TF||(TF=1,function(e){var t=function(){if(EF)return DF;EF=1;var e=new Uint8Array(512),t=new Uint8Array(256);return function(){for(var i=1,n=0;n<255;n++)e[n]=i,t[i]=n,256&(i<<=1)&&(i^=285);for(var a=255;a<512;a++)e[a]=e[a-255]}(),DF.log=function(e){if(e<1)throw new Error("log("+e+")");return t[e]},DF.exp=function(t){return e[t]},DF.mul=function(i,n){return 0===i||0===n?0:e[t[i]+t[n]]},DF}();e.mul=function(e,i){for(var n=new Uint8Array(e.length+i.length-1),a=0;a<e.length;a++)for(var r=0;r<i.length;r++)n[a+r]^=t.mul(e[a],i[r]);return n},e.mod=function(e,i){for(var n=new Uint8Array(e);n.length-i.length>=0;){for(var a=n[0],r=0;r<i.length;r++)n[r]^=t.mul(i[r],a);for(var o=0;o<n.length&&0===n[o];)o++;n=n.slice(o)}return n},e.generateECPolynomial=function(i){for(var n=new Uint8Array([1]),a=0;a<i;a++)n=e.mul(n,new Uint8Array([1,t.exp(a)]));return n}}(AF)),AF}var CF,IF={},LF={},_F={};function RF(){return CF||(CF=1,_F.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}),_F}var FF,OF,WF,$F={};function NF(){if(FF)return $F;FF=1;var e="[0-9]+",t="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+",i="(?:(?![A-Z0-9 $%*+\\-./:]|"+(t=t.replace(/u/g,"\\u"))+")(?:.|[\r\n]))+";$F.KANJI=new RegExp(t,"g"),$F.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),$F.BYTE=new RegExp(i,"g"),$F.NUMERIC=new RegExp(e,"g"),$F.ALPHANUMERIC=new RegExp("[A-Z $%*+\\-./:]+","g");var n=new RegExp("^"+t+"$"),a=new RegExp("^"+e+"$"),r=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return $F.testKanji=function(e){return n.test(e)},$F.testNumeric=function(e){return a.test(e)},$F.testAlphanumeric=function(e){return r.test(e)},$F}function jF(){return OF||(OF=1,function(e){var t=RF(),i=NF();e.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},e.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},e.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(e,i){if(!e.ccBits)throw new Error("Invalid mode: "+e);if(!t.isValid(i))throw new Error("Invalid version: "+i);return i>=1&&i<10?e.ccBits[0]:i<27?e.ccBits[1]:e.ccBits[2]},e.getBestModeForData=function(t){return i.testNumeric(t)?e.NUMERIC:i.testAlphanumeric(t)?e.ALPHANUMERIC:i.testKanji(t)?e.KANJI:e.BYTE},e.toString=function(e){if(e&&e.id)return e.id;throw new Error("Invalid mode")},e.isValid=function(e){return e&&e.bit&&e.ccBits},e.from=function(t,i){if(e.isValid(t))return t;try{return function(t){if("string"!=typeof t)throw new Error("Param is not a string");switch(t.toLowerCase()){case"numeric":return e.NUMERIC;case"alphanumeric":return e.ALPHANUMERIC;case"kanji":return e.KANJI;case"byte":return e.BYTE;default:throw new Error("Unknown mode: "+t)}}(t)}catch(e){return i}}}(LF)),LF}function BF(){return WF||(WF=1,function(e){var t=oF(),i=SF(),n=mF(),a=jF(),r=RF(),o=t.getBCHDigit(7973);function s(e,t){return a.getCharCountIndicator(e,t)+4}function u(e,t){var i=0;return e.forEach(function(e){var n=s(e.mode,t);i+=n+e.getBitsLength()}),i}e.from=function(e,t){return r.isValid(e)?parseInt(e,10):t},e.getCapacity=function(e,n,o){if(!r.isValid(e))throw new Error("Invalid QR Code version");void 0===o&&(o=a.BYTE);var u=8*(t.getSymbolTotalCodewords(e)-i.getTotalCodewordsCount(e,n));if(o===a.MIXED)return u;var l=u-s(o,e);switch(o){case a.NUMERIC:return Math.floor(l/10*3);case a.ALPHANUMERIC:return Math.floor(l/11*2);case a.KANJI:return Math.floor(l/13);case a.BYTE:default:return Math.floor(l/8)}},e.getBestVersionForData=function(t,i){var r,o=n.from(i,n.M);if(Array.isArray(t)){if(t.length>1)return function(t,i){for(var n=1;n<=40;n++)if(u(t,n)<=e.getCapacity(n,i,a.MIXED))return n}(t,o);if(0===t.length)return 1;r=t[0]}else r=t;return function(t,i,n){for(var a=1;a<=40;a++)if(i<=e.getCapacity(a,n,t))return a}(r.mode,r.getLength(),o)},e.getEncodedBits=function(e){if(!r.isValid(e)||e<7)throw new Error("Invalid QR Code version");for(var i=e<<12;t.getBCHDigit(i)-o>=0;)i^=7973<<t.getBCHDigit(i)-o;return e<<12|i}}(IF)),IF}var zF,UF={};var HF,GF,VF,KF,XF,YF,qF,JF,QF={};var ZF,eO,tO,iO={exports:{}};function nO(){return ZF||(ZF=1,function(e){var t={single_source_shortest_paths:function(e,i,n){var a={},r={};r[i]=0;var o,s,u,l,d,h,c,m=t.PriorityQueue.make();for(m.push(i,0);!m.empty();)for(u in s=(o=m.pop()).value,l=o.cost,d=e[s]||{})d.hasOwnProperty(u)&&(h=l+d[u],c=r[u],(void 0===r[u]||c>h)&&(r[u]=h,m.push(u,h),a[u]=s));if(void 0!==n&&void 0===r[n]){var f=["Could not find a path from ",i," to ",n,"."].join("");throw new Error(f)}return a},extract_shortest_path_from_predecessor_list:function(e,t){for(var i=[],n=t;n;)i.push(n),e[n],n=e[n];return i.reverse(),i},find_path:function(e,i,n){var a=t.single_source_shortest_paths(e,i,n);return t.extract_shortest_path_from_predecessor_list(a,n)},PriorityQueue:{make:function(e){var i,n=t.PriorityQueue,a={};for(i in e=e||{},n)n.hasOwnProperty(i)&&(a[i]=n[i]);return a.queue=[],a.sorter=e.sorter||n.default_sorter,a},default_sorter:function(e,t){return e.cost-t.cost},push:function(e,t){var i={value:e,cost:t};this.queue.push(i),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};e.exports=t}(iO)),iO.exports}function aO(){return eO||(eO=1,function(e){var t=jF(),i=function(){if(GF)return HF;GF=1;var e=jF();function t(t){this.mode=e.NUMERIC,this.data=t.toString()}return t.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(e){var t,i,n;for(t=0;t+3<=this.data.length;t+=3)i=this.data.substr(t,3),n=parseInt(i,10),e.put(n,10);var a=this.data.length-t;a>0&&(i=this.data.substr(t),n=parseInt(i,10),e.put(n,3*a+1))},HF=t}(),n=function(){if(KF)return VF;KF=1;var e=jF(),t=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function i(t){this.mode=e.ALPHANUMERIC,this.data=t}return i.getBitsLength=function(e){return 11*Math.floor(e/2)+e%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){var i;for(i=0;i+2<=this.data.length;i+=2){var n=45*t.indexOf(this.data[i]);n+=t.indexOf(this.data[i+1]),e.put(n,11)}this.data.length%2&&e.put(t.indexOf(this.data[i]),6)},VF=i}(),a=function(){if(YF)return XF;YF=1;var e=jF();function t(t){this.mode=e.BYTE,this.data="string"==typeof t?(new TextEncoder).encode(t):new Uint8Array(t)}return t.getBitsLength=function(e){return 8*e},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(e){for(var t=0,i=this.data.length;t<i;t++)e.put(this.data[t],8)},XF=t}(),r=function(){if(JF)return qF;JF=1;var e=jF(),t=oF();function i(t){this.mode=e.KANJI,this.data=t}return i.getBitsLength=function(e){return 13*e},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){var i;for(i=0;i<this.data.length;i++){var n=t.toSJIS(this.data[i]);if(n>=33088&&n<=40956)n-=33088;else{if(!(n>=57408&&n<=60351))throw new Error("Invalid SJIS character: "+this.data[i]+"\nMake sure your charset is UTF-8");n-=49472}n=192*(n>>>8&255)+(255&n),e.put(n,13)}},qF=i}(),o=NF(),s=oF(),u=nO();function l(e){return unescape(encodeURIComponent(e)).length}function d(e,t,i){for(var n,a=[];null!==(n=e.exec(i));)a.push({data:n[0],index:n.index,mode:t,length:n[0].length});return a}function h(e){var i,n,a=d(o.NUMERIC,t.NUMERIC,e),r=d(o.ALPHANUMERIC,t.ALPHANUMERIC,e);return s.isKanjiModeEnabled()?(i=d(o.BYTE,t.BYTE,e),n=d(o.KANJI,t.KANJI,e)):(i=d(o.BYTE_KANJI,t.BYTE,e),n=[]),a.concat(r,i,n).sort(function(e,t){return e.index-t.index}).map(function(e){return{data:e.data,mode:e.mode,length:e.length}})}function c(e,o){switch(o){case t.NUMERIC:return i.getBitsLength(e);case t.ALPHANUMERIC:return n.getBitsLength(e);case t.KANJI:return r.getBitsLength(e);case t.BYTE:return a.getBitsLength(e)}}function m(e,o){var u,l=t.getBestModeForData(e);if((u=t.from(o,l))!==t.BYTE&&u.bit<l.bit)throw new Error('"'+e+'" cannot be encoded with mode '+t.toString(u)+".\n Suggested mode is: "+t.toString(l));switch(u!==t.KANJI||s.isKanjiModeEnabled()||(u=t.BYTE),u){case t.NUMERIC:return new i(e);case t.ALPHANUMERIC:return new n(e);case t.KANJI:return new r(e);case t.BYTE:return new a(e)}}e.fromArray=function(e){return e.reduce(function(e,t){return"string"==typeof t?e.push(m(t,null)):t.data&&e.push(m(t.data,t.mode)),e},[])},e.fromString=function(i,n){for(var a=function(e){for(var i=[],n=0;n<e.length;n++){var a=e[n];switch(a.mode){case t.NUMERIC:i.push([a,{data:a.data,mode:t.ALPHANUMERIC,length:a.length},{data:a.data,mode:t.BYTE,length:a.length}]);break;case t.ALPHANUMERIC:i.push([a,{data:a.data,mode:t.BYTE,length:a.length}]);break;case t.KANJI:i.push([a,{data:a.data,mode:t.BYTE,length:l(a.data)}]);break;case t.BYTE:i.push([{data:a.data,mode:t.BYTE,length:l(a.data)}])}}return i}(h(i,s.isKanjiModeEnabled())),r=function(e,i){for(var n={},a={start:{}},r=["start"],o=0;o<e.length;o++){for(var s=e[o],u=[],l=0;l<s.length;l++){var d=s[l],h=""+o+l;u.push(h),n[h]={node:d,lastCount:0},a[h]={};for(var m=0;m<r.length;m++){var f=r[m];n[f]&&n[f].node.mode===d.mode?(a[f][h]=c(n[f].lastCount+d.length,d.mode)-c(n[f].lastCount,d.mode),n[f].lastCount+=d.length):(n[f]&&(n[f].lastCount=d.length),a[f][h]=c(d.length,d.mode)+4+t.getCharCountIndicator(d.mode,i))}}r=u}for(var v=0;v<r.length;v++)a[r[v]].end=0;return{map:a,table:n}}(a,n),o=u.find_path(r.map,"start","end"),d=[],m=1;m<o.length-1;m++)d.push(r.table[o[m]].node);return e.fromArray(function(e){return e.reduce(function(e,t){var i=e.length-1>=0?e[e.length-1]:null;return i&&i.mode===t.mode?(e[e.length-1].data+=t.data,e):(e.push(t),e)},[])}(d))},e.rawSplit=function(t){return e.fromArray(h(t,s.isKanjiModeEnabled()))}}(QF)),QF}function rO(){if(tO)return aF;tO=1;var e=oF(),t=mF(),i=function(){if(lF)return uF;function e(){this.buffer=[],this.length=0}return lF=1,e.prototype={get:function(e){var t=Math.floor(e/8);return 1==(this.buffer[t]>>>7-e%8&1)},put:function(e,t){for(var i=0;i<t;i++)this.putBit(1==(e>>>t-i-1&1))},getLengthInBits:function(){return this.length},putBit:function(e){var t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},uF=e}(),n=function(){if(hF)return dF;function e(e){if(!e||e<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}return hF=1,e.prototype.set=function(e,t,i,n){var a=e*this.size+t;this.data[a]=i,n&&(this.reservedBit[a]=!0)},e.prototype.get=function(e,t){return this.data[e*this.size+t]},e.prototype.xor=function(e,t,i){this.data[e*this.size+t]^=i},e.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]},dF=e}(),a=(fF||(fF=1,function(e){var t=oF().getSymbolSize;e.getRowColCoords=function(e){if(1===e)return[];for(var i=Math.floor(e/7)+2,n=t(e),a=145===n?26:2*Math.ceil((n-13)/(2*i-2)),r=[n-7],o=1;o<i-1;o++)r[o]=r[o-1]-a;return r.push(6),r.reverse()},e.getPositions=function(t){for(var i=[],n=e.getRowColCoords(t),a=n.length,r=0;r<a;r++)for(var o=0;o<a;o++)0===r&&0===o||0===r&&o===a-1||r===a-1&&0===o||i.push([n[r],n[o]]);return i}}(vF)),vF),r=function(){if(pF)return gF;pF=1;var e=oF().getSymbolSize;return gF.getPositions=function(t){var i=e(t);return[[0,0],[i-7,0],[0,i-7]]},gF}(),o=(yF||(yF=1,function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var t=3,i=3,n=40,a=10;function r(t,i,n){switch(t){case e.Patterns.PATTERN000:return(i+n)%2==0;case e.Patterns.PATTERN001:return i%2==0;case e.Patterns.PATTERN010:return n%3==0;case e.Patterns.PATTERN011:return(i+n)%3==0;case e.Patterns.PATTERN100:return(Math.floor(i/2)+Math.floor(n/3))%2==0;case e.Patterns.PATTERN101:return i*n%2+i*n%3==0;case e.Patterns.PATTERN110:return(i*n%2+i*n%3)%2==0;case e.Patterns.PATTERN111:return(i*n%3+(i+n)%2)%2==0;default:throw new Error("bad maskPattern:"+t)}}e.isValid=function(e){return null!=e&&""!==e&&!isNaN(e)&&e>=0&&e<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(e){for(var i=e.size,n=0,a=0,r=0,o=null,s=null,u=0;u<i;u++){a=r=0,o=s=null;for(var l=0;l<i;l++){var d=e.get(u,l);d===o?a++:(a>=5&&(n+=t+(a-5)),o=d,a=1),(d=e.get(l,u))===s?r++:(r>=5&&(n+=t+(r-5)),s=d,r=1)}a>=5&&(n+=t+(a-5)),r>=5&&(n+=t+(r-5))}return n},e.getPenaltyN2=function(e){for(var t=e.size,n=0,a=0;a<t-1;a++)for(var r=0;r<t-1;r++){var o=e.get(a,r)+e.get(a,r+1)+e.get(a+1,r)+e.get(a+1,r+1);4!==o&&0!==o||n++}return n*i},e.getPenaltyN3=function(e){for(var t=e.size,i=0,a=0,r=0,o=0;o<t;o++){a=r=0;for(var s=0;s<t;s++)a=a<<1&2047|e.get(o,s),s>=10&&(1488===a||93===a)&&i++,r=r<<1&2047|e.get(s,o),s>=10&&(1488===r||93===r)&&i++}return i*n},e.getPenaltyN4=function(e){for(var t=0,i=e.data.length,n=0;n<i;n++)t+=e.data[n];return Math.abs(Math.ceil(100*t/i/5)-10)*a},e.applyMask=function(e,t){for(var i=t.size,n=0;n<i;n++)for(var a=0;a<i;a++)t.isReserved(a,n)||t.xor(a,n,r(e,a,n))},e.getBestMask=function(t,i){for(var n=Object.keys(e.Patterns).length,a=0,r=1/0,o=0;o<n;o++){i(o),e.applyMask(o,t);var s=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(o,t),s<r&&(r=s,a=o)}return a}}(bF)),bF),s=SF(),u=function(){if(MF)return PF;MF=1;var e=xF();function t(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}return t.prototype.initialize=function(t){this.degree=t,this.genPoly=e.generateECPolynomial(this.degree)},t.prototype.encode=function(t){if(!this.genPoly)throw new Error("Encoder not initialized");var i=new Uint8Array(t.length+this.degree);i.set(t);var n=e.mod(i,this.genPoly),a=this.degree-n.length;if(a>0){var r=new Uint8Array(this.degree);return r.set(n,a),r}return n},PF=t}(),l=BF(),d=function(){if(zF)return UF;zF=1;var e=oF(),t=e.getBCHDigit(1335);return UF.getEncodedBits=function(i,n){for(var a=i.bit<<3|n,r=a<<10;e.getBCHDigit(r)-t>=0;)r^=1335<<e.getBCHDigit(r)-t;return 21522^(a<<10|r)},UF}(),h=jF(),c=aO();function m(e,t,i){var n,a,r=e.size,o=d.getEncodedBits(t,i);for(n=0;n<15;n++)a=1==(o>>n&1),n<6?e.set(n,8,a,!0):n<8?e.set(n+1,8,a,!0):e.set(r-15+n,8,a,!0),n<8?e.set(8,r-n-1,a,!0):n<9?e.set(8,15-n-1+1,a,!0):e.set(8,15-n-1,a,!0);e.set(r-8,8,1,!0)}function f(t,n,a){var r=new i;a.forEach(function(e){r.put(e.mode.bit,4),r.put(e.getLength(),h.getCharCountIndicator(e.mode,t)),e.write(r)});var o=8*(e.getSymbolTotalCodewords(t)-s.getTotalCodewordsCount(t,n));for(r.getLengthInBits()+4<=o&&r.put(0,4);r.getLengthInBits()%8!=0;)r.putBit(0);for(var l=(o-r.getLengthInBits())/8,d=0;d<l;d++)r.put(d%2?17:236,8);return function(t,i,n){for(var a=e.getSymbolTotalCodewords(i),r=s.getTotalCodewordsCount(i,n),o=a-r,l=s.getBlocksCount(i,n),d=l-a%l,h=Math.floor(a/l),c=Math.floor(o/l),m=c+1,f=h-c,v=new u(f),p=0,g=new Array(l),y=new Array(l),b=0,w=new Uint8Array(t.buffer),k=0;k<l;k++){var S=k<d?c:m;g[k]=w.slice(p,p+S),y[k]=v.encode(g[k]),p+=S,b=Math.max(b,S)}var E,T,P=new Uint8Array(a),M=0;for(E=0;E<b;E++)for(T=0;T<l;T++)E<g[T].length&&(P[M++]=g[T][E]);for(E=0;E<f;E++)for(T=0;T<l;T++)P[M++]=y[T][E];return P}(r,t,n)}function v(t,i,s,u){var d;if(Array.isArray(t))d=c.fromArray(t);else{if("string"!=typeof t)throw new Error("Invalid data");var h=i;if(!h){var v=c.rawSplit(t);h=l.getBestVersionForData(v,s)}d=c.fromString(t,h||40)}var p=l.getBestVersionForData(d,s);if(!p)throw new Error("The amount of data is too big to be stored in a QR Code");if(i){if(i<p)throw new Error("\nThe chosen QR Code version cannot contain this amount of data.\nMinimum version required to store current data is: "+p+".\n")}else i=p;var g=f(i,s,d),y=e.getSymbolSize(i),b=new n(y);return function(e,t){for(var i=e.size,n=r.getPositions(t),a=0;a<n.length;a++)for(var o=n[a][0],s=n[a][1],u=-1;u<=7;u++)if(!(o+u<=-1||i<=o+u))for(var l=-1;l<=7;l++)s+l<=-1||i<=s+l||(u>=0&&u<=6&&(0===l||6===l)||l>=0&&l<=6&&(0===u||6===u)||u>=2&&u<=4&&l>=2&&l<=4?e.set(o+u,s+l,!0,!0):e.set(o+u,s+l,!1,!0))}(b,i),function(e){for(var t=e.size,i=8;i<t-8;i++){var n=i%2==0;e.set(i,6,n,!0),e.set(6,i,n,!0)}}(b),function(e,t){for(var i=a.getPositions(t),n=0;n<i.length;n++)for(var r=i[n][0],o=i[n][1],s=-2;s<=2;s++)for(var u=-2;u<=2;u++)-2===s||2===s||-2===u||2===u||0===s&&0===u?e.set(r+s,o+u,!0,!0):e.set(r+s,o+u,!1,!0)}(b,i),m(b,s,0),i>=7&&function(e,t){for(var i,n,a,r=e.size,o=l.getEncodedBits(t),s=0;s<18;s++)i=Math.floor(s/3),n=s%3+r-8-3,a=1==(o>>s&1),e.set(i,n,a,!0),e.set(n,i,a,!0)}(b,i),function(e,t){for(var i=e.size,n=-1,a=i-1,r=7,o=0,s=i-1;s>0;s-=2)for(6===s&&s--;;){for(var u=0;u<2;u++)if(!e.isReserved(a,s-u)){var l=!1;o<t.length&&(l=1==(t[o]>>>r&1)),e.set(a,s-u,l),-1===--r&&(o++,r=7)}if((a+=n)<0||i<=a){a-=n,n=-n;break}}}(b,g),isNaN(u)&&(u=o.getBestMask(b,m.bind(null,b,s))),o.applyMask(u,b),m(b,s,u),{modules:b,version:i,errorCorrectionLevel:s,maskPattern:u,segments:d}}return aF.create=function(i,n){if(void 0===i||""===i)throw new Error("No input text");var a,r,s=t.M;return void 0!==n&&(s=t.from(n.errorCorrectionLevel,t.M),a=l.from(n.version),r=o.from(n.maskPattern),n.toSJISFunc&&e.setToSJISFunction(n.toSJISFunc)),v(i,a,s,r)},aF}var oO,sO,uO={},lO={};function dO(){return oO||(oO=1,function(e){function t(e){if("number"==typeof e&&(e=e.toString()),"string"!=typeof e)throw new Error("Color should be defined as hex string");var t=e.slice().replace("#","").split("");if(t.length<3||5===t.length||t.length>8)throw new Error("Invalid hex color: "+e);3!==t.length&&4!==t.length||(t=Array.prototype.concat.apply([],t.map(function(e){return[e,e]}))),6===t.length&&t.push("F","F");var i=parseInt(t.join(""),16);return{r:i>>24&255,g:i>>16&255,b:i>>8&255,a:255&i,hex:"#"+t.slice(0,6).join("")}}e.getOptions=function(e){e||(e={}),e.color||(e.color={});var i=void 0===e.margin||null===e.margin||e.margin<0?4:e.margin,n=e.width&&e.width>=21?e.width:void 0,a=e.scale||4;return{width:n,scale:n?4:a,margin:i,color:{dark:t(e.color.dark||"#000000ff"),light:t(e.color.light||"#ffffffff")},type:e.type,rendererOpts:e.rendererOpts||{}}},e.getScale=function(e,t){return t.width&&t.width>=e+2*t.margin?t.width/(e+2*t.margin):t.scale},e.getImageWidth=function(t,i){var n=e.getScale(t,i);return Math.floor((t+2*i.margin)*n)},e.qrToImageData=function(t,i,n){for(var a=i.modules.size,r=i.modules.data,o=e.getScale(a,n),s=Math.floor((a+2*n.margin)*o),u=n.margin*o,l=[n.color.light,n.color.dark],d=0;d<s;d++)for(var h=0;h<s;h++){var c=4*(d*s+h),m=n.color.light;if(d>=u&&h>=u&&d<s-u&&h<s-u)m=l[r[Math.floor((d-u)/o)*a+Math.floor((h-u)/o)]?1:0];t[c++]=m.r,t[c++]=m.g,t[c++]=m.b,t[c]=m.a}}}(lO)),lO}function hO(){return sO||(sO=1,function(e){var t=dO();e.render=function(e,i,n){var a=n,r=i;void 0!==a||i&&i.getContext||(a=i,i=void 0),i||(r=function(){try{return document.createElement("canvas")}catch(e){throw new Error("You need to specify a canvas element")}}()),a=t.getOptions(a);var o=t.getImageWidth(e.modules.size,a),s=r.getContext("2d"),u=s.createImageData(o,o);return t.qrToImageData(u.data,e,a),function(e,t,i){e.clearRect(0,0,t.width,t.height),t.style||(t.style={}),t.height=i,t.width=i,t.style.height=i+"px",t.style.width=i+"px"}(s,r,o),s.putImageData(u,0,0),r},e.renderToDataURL=function(t,i,n){var a=n;void 0!==a||i&&i.getContext||(a=i,i=void 0),a||(a={});var r=e.render(t,i,a),o=a.type||"image/png",s=a.rendererOpts||{};return r.toDataURL(o,s.quality)}}(uO)),uO}var cO,mO,fO={};function vO(){if(cO)return fO;cO=1;var e=dO();function t(e,t){var i=e.a/255,n=t+'="'+e.hex+'"';return i<1?n+" "+t+'-opacity="'+i.toFixed(2).slice(1)+'"':n}function i(e,t,i){var n=e+t;return void 0!==i&&(n+=" "+i),n}return fO.render=function(n,a,r){var o=e.getOptions(a),s=n.modules.size,u=n.modules.data,l=s+2*o.margin,d=o.color.light.a?"<path "+t(o.color.light,"fill")+' d="M0 0h'+l+"v"+l+'H0z"/>':"",h="<path "+t(o.color.dark,"stroke")+' d="'+function(e,t,n){for(var a="",r=0,o=!1,s=0,u=0;u<e.length;u++){var l=Math.floor(u%t),d=Math.floor(u/t);l||o||(o=!0),e[u]?(s++,u>0&&l>0&&e[u-1]||(a+=o?i("M",l+n,.5+d+n):i("m",r,0),r=0,o=!1),l+1<t&&e[u+1]||(a+=i("h",s),s=0)):r++}return a}(u,s,o.margin)+'"/>',c='viewBox="0 0 '+l+" "+l+'"',m='<svg xmlns="http://www.w3.org/2000/svg" '+(o.width?'width="'+o.width+'" height="'+o.width+'" ':"")+c+' shape-rendering="crispEdges">'+d+h+"</svg>\n";return"function"==typeof r&&r(null,m),m},fO}var pO,gO,yO=function(){if(mO)return tF;mO=1;var e=iF(),t=rO(),i=hO(),n=vO();function a(i,n,a,r,o){var s=[].slice.call(arguments,1),u=s.length,l="function"==typeof s[u-1];if(!l&&!e())throw new Error("Callback required as last argument");if(!l){if(u<1)throw new Error("Too few arguments provided");return 1===u?(a=n,n=r=void 0):2!==u||n.getContext||(r=a,a=n,n=void 0),new Promise(function(e,o){try{var s=t.create(a,r);e(i(s,n,r))}catch(e){o(e)}})}if(u<2)throw new Error("Too few arguments provided");2===u?(o=a,a=n,n=r=void 0):3===u&&(n.getContext&&void 0===o?(o=r,r=void 0):(o=r,r=a,a=n,n=void 0));try{var d=t.create(a,r);o(null,i(d,n,r))}catch(e){o(e)}}return tF.create=t.create,tF.toCanvas=a.bind(null,i.render),tF.toDataURL=a.bind(null,i.renderToDataURL),tF.toString=a.bind(null,function(e,t,i){return n.render(e,i)}),tF}(),bO=be(yO),wO=e=>e,kO=function(){function i(){var e;return u(this,i),(e=s(this,i,arguments)).scaleFactor=1,e}return y(i,bs),m(i,[{key:"styles",value:function(){var e;return this.component?t.unsafeCSS(`\n :host {\n box-sizing: border-box;\n ${zs(this.component,this.scaleFactor)}\n ${Ns(this.component,this.scaleFactor)}\n background-color: ${this.component.fillColor||this.component.borderColor||"transparent"};\n border-width: ${null!==(e=this.component.borderWidth)&&void 0!==e?e:0}px;\n ${Ls(this.component.borderColor||"transparent")}\n border-style: solid;\n display: inline-block;\n }`):t.unsafeCSS(":host { box-sizing: border-box; display: inline-block; }")}},{key:"renderQr",value:function(){var t,i,n,a,r,s,u,l;return S(function(d){for(;;)switch(d.p=d.n){case 0:if((a=this.renderRoot.querySelector("canvas"))&&null!==(t=this.component)&&void 0!==t&&t.url){d.n=1;break}return d.a(2);case 1:return r=this.computedSize,a.width=r,a.height=r,a.style.width=`${r}px`,a.style.height=`${r}px`,s=null!==(i=ia(this.component.color))&&void 0!==i?i:"#000000",u=null!==(n=ia(this.component.fillColor))&&void 0!==n?n:"#ffffff",d.p=2,d.n=3,o(bO.toCanvas(a,this.component.url,{width:r,color:{dark:s,light:u},margin:0}));case 3:d.n=5;break;case 4:d.p=4,l=d.v,e.logger.error(`QR render failed for URL "${this.component.url}":`,l);case 5:return d.a(2)}},null,this,[[2,4]],Promise)}},{key:"firstUpdated",value:function(){this.renderQr()}},{key:"updated",value:function(e){(e.has("component")||e.has("scaleFactor"))&&Promise.resolve().then(()=>this.renderQr())}},{key:"computedSize",get:function(){var e,t=Number(null!==(e=this.component.borderWidth)&&void 0!==e?e:0),i=Number(this.component.width)*this.scaleFactor,n=Math.floor(this.component.width?i-2*t:360);return Math.max(1,n)}},{key:"render",value:function(){if(this.component){var e=this.computedSize;return t.html(pO||(pO=wO`<canvas width="${0}" height="${0}" style="width:${0}px;height:${0}px;"></canvas>`),e,e,e,e)}return t.html(gO||(gO=wO`<canvas></canvas>`))}}])}();Ae([ot({type:Object})],kO.prototype,"component",void 0),Ae([ot({type:Number})],kO.prototype,"scaleFactor",void 0),kO=Ae([Fe("nami-qr-code")],kO);var SO,EO=e=>e,TO=function(){function i(){var e;return u(this,i),(e=s(this,i)).inFocusedState=!1,e.scaleFactor=1,e.isActive=!1,e._handleKeyDown=t=>{"Enter"!==t.key&&" "!==t.key&&142!==t.keyCode&&195!==t.keyCode||e._handleClick()},e}return y(i,bs),m(i,[{key:"connectedCallback",value:function(){M(i,"connectedCallback",this)([]),this.isActive=!!this.component.checked,this.contextProvider.setFormState(this.component.formId,this.isActive),this.addEventListener("click",this._handleClick,!1),this.addEventListener("keydown",this._handleKeyDown)}},{key:"disconnectedCallback",value:function(){M(i,"disconnectedCallback",this)([]),this.removeEventListener("click",this._handleClick),this.removeEventListener("keydown",this._handleKeyDown)}},{key:"_handleClick",value:function(){var t=this.component,i=t.onTap,n=t.disabled,a=t.formId;if(!0!==n){this.component.checked=!this.component.checked,this.isActive=this.component.checked;var r=void 0;r=a?{function:(null==i?void 0:i.function)||"",parameters:v({},null==i?void 0:i.parameters,{formId:a||""})}:i,!this.contextProvider.flow||a?Ao({onTap:r,contextProvider:this.contextProvider}):this.component.id?(e.logger.debug(`Trigger NamiFlow action for component ${this.component.id}`),this.contextProvider.flow.triggerActions(this.component.id)):e.logger.warn("Cannot trigger button hoisting without an id")}}},{key:"styles",value:function(){return t.unsafeCSS(`\n :host {\n box-sizing: border-box;\n }\n :host .toggle-plate {\n display: flex;\n position: relative;\n ${this.applyPlateStyles()}\n }\n :host .toggle-handle {\n display: flex;\n position: relative;\n ${this.applyHandleStyles()}\n }\n `)}},{key:"applyPlateStyles",value:function(){var e=this.component,t=this.scaleFactor,i=this.isActive||e.checked||!1,n=i?e.activePlateFillColor||"transparent":e.inactivePlateFillColor||"transparent",a=i?e.activePlateBorderColor||"transparent":e.inactivePlateBorderColor||"transparent";return`\n transition: all 0.3s;\n ${zs(e,t)};\n ${Ls(a)}\n border-width: ${i?e.activePlateBorderWidth||0:e.inactivePlateBorderWidth||0}px !important;\n border-style: solid;\n border-radius: ${e.borderRadius||0}px !important;\n padding: ${e.innerPadding||0}px !important;\n ${Is(n)}\n `}},{key:"applyHandleStyles",value:function(){var e=this.component,t=e.checked||!1,i=t?e.activeHandleFillColor||"transparent":e.inactiveHandleFillColor||"transparent",n=t?e.activeHandleBorderColor||"transparent":e.inactiveHandleBorderColor||"transparent";return`\n transition: all 0.3s;\n height: 100%;\n width: 50%;\n border-radius: ${e.borderRadius}px !important;\n ${Ls(n)}\n border-width: ${t?e.activeHandleBorderWidth||0:e.inactiveHandleBorderWidth||0}px !important;\n ${Hs(e.dropShadow)}\n border-style: solid;\n left: ${t?"50%":0};\n ${Is(i)}\n `}},{key:"render",value:function(){return this.tabIndex=0,this.role="switch",t.html(SO||(SO=EO`
|
|
557
|
+
`)),XR);Ae([ot({type:Object})],ZR.prototype,"paywall",void 0),Ae([ot({type:Object})],ZR.prototype,"campaign",void 0),Ae([ot({type:Object})],ZR.prototype,"context",void 0),Ae([ot({type:Boolean})],ZR.prototype,"active",void 0),Ae([function({context:e}){return(t,i)=>{var n=new WeakMap;if("object"==typeof i)return{get(){return t.get.call(this)},set(e){return n.get(this).setValue(e),t.set.call(this,e)},init(t){return n.set(this,new ls(this,{context:e,initialValue:t})),t}};t.constructor.addInitializer(t=>{n.set(t,new ls(t,{context:e}))});var a,r=Object.getOwnPropertyDescriptor(t,i);if(void 0===r){var o=new WeakMap;a={get(){return o.get(this)},set(e){n.get(this).setValue(e),o.set(this,e)},configurable:!0,enumerable:!0}}else{var s=r.set;a=v({},r,{set(e){n.get(this).setValue(e),null==s||s.call(this,e)}})}Object.defineProperty(t,i,a)}}({context:hs})],ZR.prototype,"contextProvider",void 0),ZR=Ae([Fe("nami-paywall-screen")],ZR);var eF,tF,iF={};function nF(){return tF?eF:(tF=1,eF=function(){return"function"==typeof Promise&&Promise.prototype&&Promise.prototype.then})}var aF,rF={},oF={};function sF(){if(aF)return oF;var e;aF=1;var t=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return oF.getSymbolSize=function(e){if(!e)throw new Error('"version" cannot be null or undefined');if(e<1||e>40)throw new Error('"version" should be in range from 1 to 40');return 4*e+17},oF.getSymbolTotalCodewords=function(e){return t[e]},oF.getBCHDigit=function(e){for(var t=0;0!==e;)t++,e>>>=1;return t},oF.setToSJISFunction=function(t){if("function"!=typeof t)throw new Error('"toSJISFunc" is not a valid function.');e=t},oF.isKanjiModeEnabled=function(){return void 0!==e},oF.toSJIS=function(t){return e(t)},oF}var uF,lF,dF,hF,cF,mF={};function fF(){return uF||(uF=1,function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2},e.isValid=function(e){return e&&void 0!==e.bit&&e.bit>=0&&e.bit<4},e.from=function(t,i){if(e.isValid(t))return t;try{return function(t){if("string"!=typeof t)throw new Error("Param is not a string");switch(t.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+t)}}(t)}catch(e){return i}}}(mF)),mF}var vF,pF={};var gF,yF={};var bF,wF={};var kF,SF={};function EF(){if(kF)return SF;kF=1;var e=fF(),t=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],i=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return SF.getBlocksCount=function(i,n){switch(n){case e.L:return t[4*(i-1)+0];case e.M:return t[4*(i-1)+1];case e.Q:return t[4*(i-1)+2];case e.H:return t[4*(i-1)+3];default:return}},SF.getTotalCodewordsCount=function(t,n){switch(n){case e.L:return i[4*(t-1)+0];case e.M:return i[4*(t-1)+1];case e.Q:return i[4*(t-1)+2];case e.H:return i[4*(t-1)+3];default:return}},SF}var TF,PF,MF,AF,DF={},xF={};function CF(){return PF||(PF=1,function(e){var t=function(){if(TF)return xF;TF=1;var e=new Uint8Array(512),t=new Uint8Array(256);return function(){for(var i=1,n=0;n<255;n++)e[n]=i,t[i]=n,256&(i<<=1)&&(i^=285);for(var a=255;a<512;a++)e[a]=e[a-255]}(),xF.log=function(e){if(e<1)throw new Error("log("+e+")");return t[e]},xF.exp=function(t){return e[t]},xF.mul=function(i,n){return 0===i||0===n?0:e[t[i]+t[n]]},xF}();e.mul=function(e,i){for(var n=new Uint8Array(e.length+i.length-1),a=0;a<e.length;a++)for(var r=0;r<i.length;r++)n[a+r]^=t.mul(e[a],i[r]);return n},e.mod=function(e,i){for(var n=new Uint8Array(e);n.length-i.length>=0;){for(var a=n[0],r=0;r<i.length;r++)n[r]^=t.mul(i[r],a);for(var o=0;o<n.length&&0===n[o];)o++;n=n.slice(o)}return n},e.generateECPolynomial=function(i){for(var n=new Uint8Array([1]),a=0;a<i;a++)n=e.mul(n,new Uint8Array([1,t.exp(a)]));return n}}(DF)),DF}var IF,LF={},_F={},RF={};function FF(){return IF||(IF=1,RF.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}),RF}var OF,WF,$F,NF={};function jF(){if(OF)return NF;OF=1;var e="[0-9]+",t="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+",i="(?:(?![A-Z0-9 $%*+\\-./:]|"+(t=t.replace(/u/g,"\\u"))+")(?:.|[\r\n]))+";NF.KANJI=new RegExp(t,"g"),NF.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),NF.BYTE=new RegExp(i,"g"),NF.NUMERIC=new RegExp(e,"g"),NF.ALPHANUMERIC=new RegExp("[A-Z $%*+\\-./:]+","g");var n=new RegExp("^"+t+"$"),a=new RegExp("^"+e+"$"),r=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return NF.testKanji=function(e){return n.test(e)},NF.testNumeric=function(e){return a.test(e)},NF.testAlphanumeric=function(e){return r.test(e)},NF}function BF(){return WF||(WF=1,function(e){var t=FF(),i=jF();e.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},e.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},e.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(e,i){if(!e.ccBits)throw new Error("Invalid mode: "+e);if(!t.isValid(i))throw new Error("Invalid version: "+i);return i>=1&&i<10?e.ccBits[0]:i<27?e.ccBits[1]:e.ccBits[2]},e.getBestModeForData=function(t){return i.testNumeric(t)?e.NUMERIC:i.testAlphanumeric(t)?e.ALPHANUMERIC:i.testKanji(t)?e.KANJI:e.BYTE},e.toString=function(e){if(e&&e.id)return e.id;throw new Error("Invalid mode")},e.isValid=function(e){return e&&e.bit&&e.ccBits},e.from=function(t,i){if(e.isValid(t))return t;try{return function(t){if("string"!=typeof t)throw new Error("Param is not a string");switch(t.toLowerCase()){case"numeric":return e.NUMERIC;case"alphanumeric":return e.ALPHANUMERIC;case"kanji":return e.KANJI;case"byte":return e.BYTE;default:throw new Error("Unknown mode: "+t)}}(t)}catch(e){return i}}}(_F)),_F}function zF(){return $F||($F=1,function(e){var t=sF(),i=EF(),n=fF(),a=BF(),r=FF(),o=t.getBCHDigit(7973);function s(e,t){return a.getCharCountIndicator(e,t)+4}function u(e,t){var i=0;return e.forEach(function(e){var n=s(e.mode,t);i+=n+e.getBitsLength()}),i}e.from=function(e,t){return r.isValid(e)?parseInt(e,10):t},e.getCapacity=function(e,n,o){if(!r.isValid(e))throw new Error("Invalid QR Code version");void 0===o&&(o=a.BYTE);var u=8*(t.getSymbolTotalCodewords(e)-i.getTotalCodewordsCount(e,n));if(o===a.MIXED)return u;var l=u-s(o,e);switch(o){case a.NUMERIC:return Math.floor(l/10*3);case a.ALPHANUMERIC:return Math.floor(l/11*2);case a.KANJI:return Math.floor(l/13);case a.BYTE:default:return Math.floor(l/8)}},e.getBestVersionForData=function(t,i){var r,o=n.from(i,n.M);if(Array.isArray(t)){if(t.length>1)return function(t,i){for(var n=1;n<=40;n++)if(u(t,n)<=e.getCapacity(n,i,a.MIXED))return n}(t,o);if(0===t.length)return 1;r=t[0]}else r=t;return function(t,i,n){for(var a=1;a<=40;a++)if(i<=e.getCapacity(a,n,t))return a}(r.mode,r.getLength(),o)},e.getEncodedBits=function(e){if(!r.isValid(e)||e<7)throw new Error("Invalid QR Code version");for(var i=e<<12;t.getBCHDigit(i)-o>=0;)i^=7973<<t.getBCHDigit(i)-o;return e<<12|i}}(LF)),LF}var UF,HF={};var GF,VF,KF,XF,YF,qF,JF,QF,ZF={};var eO,tO,iO,nO={exports:{}};function aO(){return eO||(eO=1,function(e){var t={single_source_shortest_paths:function(e,i,n){var a={},r={};r[i]=0;var o,s,u,l,d,h,c,m=t.PriorityQueue.make();for(m.push(i,0);!m.empty();)for(u in s=(o=m.pop()).value,l=o.cost,d=e[s]||{})d.hasOwnProperty(u)&&(h=l+d[u],c=r[u],(void 0===r[u]||c>h)&&(r[u]=h,m.push(u,h),a[u]=s));if(void 0!==n&&void 0===r[n]){var f=["Could not find a path from ",i," to ",n,"."].join("");throw new Error(f)}return a},extract_shortest_path_from_predecessor_list:function(e,t){for(var i=[],n=t;n;)i.push(n),e[n],n=e[n];return i.reverse(),i},find_path:function(e,i,n){var a=t.single_source_shortest_paths(e,i,n);return t.extract_shortest_path_from_predecessor_list(a,n)},PriorityQueue:{make:function(e){var i,n=t.PriorityQueue,a={};for(i in e=e||{},n)n.hasOwnProperty(i)&&(a[i]=n[i]);return a.queue=[],a.sorter=e.sorter||n.default_sorter,a},default_sorter:function(e,t){return e.cost-t.cost},push:function(e,t){var i={value:e,cost:t};this.queue.push(i),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};e.exports=t}(nO)),nO.exports}function rO(){return tO||(tO=1,function(e){var t=BF(),i=function(){if(VF)return GF;VF=1;var e=BF();function t(t){this.mode=e.NUMERIC,this.data=t.toString()}return t.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(e){var t,i,n;for(t=0;t+3<=this.data.length;t+=3)i=this.data.substr(t,3),n=parseInt(i,10),e.put(n,10);var a=this.data.length-t;a>0&&(i=this.data.substr(t),n=parseInt(i,10),e.put(n,3*a+1))},GF=t}(),n=function(){if(XF)return KF;XF=1;var e=BF(),t=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function i(t){this.mode=e.ALPHANUMERIC,this.data=t}return i.getBitsLength=function(e){return 11*Math.floor(e/2)+e%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){var i;for(i=0;i+2<=this.data.length;i+=2){var n=45*t.indexOf(this.data[i]);n+=t.indexOf(this.data[i+1]),e.put(n,11)}this.data.length%2&&e.put(t.indexOf(this.data[i]),6)},KF=i}(),a=function(){if(qF)return YF;qF=1;var e=BF();function t(t){this.mode=e.BYTE,this.data="string"==typeof t?(new TextEncoder).encode(t):new Uint8Array(t)}return t.getBitsLength=function(e){return 8*e},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(e){for(var t=0,i=this.data.length;t<i;t++)e.put(this.data[t],8)},YF=t}(),r=function(){if(QF)return JF;QF=1;var e=BF(),t=sF();function i(t){this.mode=e.KANJI,this.data=t}return i.getBitsLength=function(e){return 13*e},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){var i;for(i=0;i<this.data.length;i++){var n=t.toSJIS(this.data[i]);if(n>=33088&&n<=40956)n-=33088;else{if(!(n>=57408&&n<=60351))throw new Error("Invalid SJIS character: "+this.data[i]+"\nMake sure your charset is UTF-8");n-=49472}n=192*(n>>>8&255)+(255&n),e.put(n,13)}},JF=i}(),o=jF(),s=sF(),u=aO();function l(e){return unescape(encodeURIComponent(e)).length}function d(e,t,i){for(var n,a=[];null!==(n=e.exec(i));)a.push({data:n[0],index:n.index,mode:t,length:n[0].length});return a}function h(e){var i,n,a=d(o.NUMERIC,t.NUMERIC,e),r=d(o.ALPHANUMERIC,t.ALPHANUMERIC,e);return s.isKanjiModeEnabled()?(i=d(o.BYTE,t.BYTE,e),n=d(o.KANJI,t.KANJI,e)):(i=d(o.BYTE_KANJI,t.BYTE,e),n=[]),a.concat(r,i,n).sort(function(e,t){return e.index-t.index}).map(function(e){return{data:e.data,mode:e.mode,length:e.length}})}function c(e,o){switch(o){case t.NUMERIC:return i.getBitsLength(e);case t.ALPHANUMERIC:return n.getBitsLength(e);case t.KANJI:return r.getBitsLength(e);case t.BYTE:return a.getBitsLength(e)}}function m(e,o){var u,l=t.getBestModeForData(e);if((u=t.from(o,l))!==t.BYTE&&u.bit<l.bit)throw new Error('"'+e+'" cannot be encoded with mode '+t.toString(u)+".\n Suggested mode is: "+t.toString(l));switch(u!==t.KANJI||s.isKanjiModeEnabled()||(u=t.BYTE),u){case t.NUMERIC:return new i(e);case t.ALPHANUMERIC:return new n(e);case t.KANJI:return new r(e);case t.BYTE:return new a(e)}}e.fromArray=function(e){return e.reduce(function(e,t){return"string"==typeof t?e.push(m(t,null)):t.data&&e.push(m(t.data,t.mode)),e},[])},e.fromString=function(i,n){for(var a=function(e){for(var i=[],n=0;n<e.length;n++){var a=e[n];switch(a.mode){case t.NUMERIC:i.push([a,{data:a.data,mode:t.ALPHANUMERIC,length:a.length},{data:a.data,mode:t.BYTE,length:a.length}]);break;case t.ALPHANUMERIC:i.push([a,{data:a.data,mode:t.BYTE,length:a.length}]);break;case t.KANJI:i.push([a,{data:a.data,mode:t.BYTE,length:l(a.data)}]);break;case t.BYTE:i.push([{data:a.data,mode:t.BYTE,length:l(a.data)}])}}return i}(h(i,s.isKanjiModeEnabled())),r=function(e,i){for(var n={},a={start:{}},r=["start"],o=0;o<e.length;o++){for(var s=e[o],u=[],l=0;l<s.length;l++){var d=s[l],h=""+o+l;u.push(h),n[h]={node:d,lastCount:0},a[h]={};for(var m=0;m<r.length;m++){var f=r[m];n[f]&&n[f].node.mode===d.mode?(a[f][h]=c(n[f].lastCount+d.length,d.mode)-c(n[f].lastCount,d.mode),n[f].lastCount+=d.length):(n[f]&&(n[f].lastCount=d.length),a[f][h]=c(d.length,d.mode)+4+t.getCharCountIndicator(d.mode,i))}}r=u}for(var v=0;v<r.length;v++)a[r[v]].end=0;return{map:a,table:n}}(a,n),o=u.find_path(r.map,"start","end"),d=[],m=1;m<o.length-1;m++)d.push(r.table[o[m]].node);return e.fromArray(function(e){return e.reduce(function(e,t){var i=e.length-1>=0?e[e.length-1]:null;return i&&i.mode===t.mode?(e[e.length-1].data+=t.data,e):(e.push(t),e)},[])}(d))},e.rawSplit=function(t){return e.fromArray(h(t,s.isKanjiModeEnabled()))}}(ZF)),ZF}function oO(){if(iO)return rF;iO=1;var e=sF(),t=fF(),i=function(){if(dF)return lF;function e(){this.buffer=[],this.length=0}return dF=1,e.prototype={get:function(e){var t=Math.floor(e/8);return 1==(this.buffer[t]>>>7-e%8&1)},put:function(e,t){for(var i=0;i<t;i++)this.putBit(1==(e>>>t-i-1&1))},getLengthInBits:function(){return this.length},putBit:function(e){var t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},lF=e}(),n=function(){if(cF)return hF;function e(e){if(!e||e<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}return cF=1,e.prototype.set=function(e,t,i,n){var a=e*this.size+t;this.data[a]=i,n&&(this.reservedBit[a]=!0)},e.prototype.get=function(e,t){return this.data[e*this.size+t]},e.prototype.xor=function(e,t,i){this.data[e*this.size+t]^=i},e.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]},hF=e}(),a=(vF||(vF=1,function(e){var t=sF().getSymbolSize;e.getRowColCoords=function(e){if(1===e)return[];for(var i=Math.floor(e/7)+2,n=t(e),a=145===n?26:2*Math.ceil((n-13)/(2*i-2)),r=[n-7],o=1;o<i-1;o++)r[o]=r[o-1]-a;return r.push(6),r.reverse()},e.getPositions=function(t){for(var i=[],n=e.getRowColCoords(t),a=n.length,r=0;r<a;r++)for(var o=0;o<a;o++)0===r&&0===o||0===r&&o===a-1||r===a-1&&0===o||i.push([n[r],n[o]]);return i}}(pF)),pF),r=function(){if(gF)return yF;gF=1;var e=sF().getSymbolSize;return yF.getPositions=function(t){var i=e(t);return[[0,0],[i-7,0],[0,i-7]]},yF}(),o=(bF||(bF=1,function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var t=3,i=3,n=40,a=10;function r(t,i,n){switch(t){case e.Patterns.PATTERN000:return(i+n)%2==0;case e.Patterns.PATTERN001:return i%2==0;case e.Patterns.PATTERN010:return n%3==0;case e.Patterns.PATTERN011:return(i+n)%3==0;case e.Patterns.PATTERN100:return(Math.floor(i/2)+Math.floor(n/3))%2==0;case e.Patterns.PATTERN101:return i*n%2+i*n%3==0;case e.Patterns.PATTERN110:return(i*n%2+i*n%3)%2==0;case e.Patterns.PATTERN111:return(i*n%3+(i+n)%2)%2==0;default:throw new Error("bad maskPattern:"+t)}}e.isValid=function(e){return null!=e&&""!==e&&!isNaN(e)&&e>=0&&e<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(e){for(var i=e.size,n=0,a=0,r=0,o=null,s=null,u=0;u<i;u++){a=r=0,o=s=null;for(var l=0;l<i;l++){var d=e.get(u,l);d===o?a++:(a>=5&&(n+=t+(a-5)),o=d,a=1),(d=e.get(l,u))===s?r++:(r>=5&&(n+=t+(r-5)),s=d,r=1)}a>=5&&(n+=t+(a-5)),r>=5&&(n+=t+(r-5))}return n},e.getPenaltyN2=function(e){for(var t=e.size,n=0,a=0;a<t-1;a++)for(var r=0;r<t-1;r++){var o=e.get(a,r)+e.get(a,r+1)+e.get(a+1,r)+e.get(a+1,r+1);4!==o&&0!==o||n++}return n*i},e.getPenaltyN3=function(e){for(var t=e.size,i=0,a=0,r=0,o=0;o<t;o++){a=r=0;for(var s=0;s<t;s++)a=a<<1&2047|e.get(o,s),s>=10&&(1488===a||93===a)&&i++,r=r<<1&2047|e.get(s,o),s>=10&&(1488===r||93===r)&&i++}return i*n},e.getPenaltyN4=function(e){for(var t=0,i=e.data.length,n=0;n<i;n++)t+=e.data[n];return Math.abs(Math.ceil(100*t/i/5)-10)*a},e.applyMask=function(e,t){for(var i=t.size,n=0;n<i;n++)for(var a=0;a<i;a++)t.isReserved(a,n)||t.xor(a,n,r(e,a,n))},e.getBestMask=function(t,i){for(var n=Object.keys(e.Patterns).length,a=0,r=1/0,o=0;o<n;o++){i(o),e.applyMask(o,t);var s=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(o,t),s<r&&(r=s,a=o)}return a}}(wF)),wF),s=EF(),u=function(){if(AF)return MF;AF=1;var e=CF();function t(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}return t.prototype.initialize=function(t){this.degree=t,this.genPoly=e.generateECPolynomial(this.degree)},t.prototype.encode=function(t){if(!this.genPoly)throw new Error("Encoder not initialized");var i=new Uint8Array(t.length+this.degree);i.set(t);var n=e.mod(i,this.genPoly),a=this.degree-n.length;if(a>0){var r=new Uint8Array(this.degree);return r.set(n,a),r}return n},MF=t}(),l=zF(),d=function(){if(UF)return HF;UF=1;var e=sF(),t=e.getBCHDigit(1335);return HF.getEncodedBits=function(i,n){for(var a=i.bit<<3|n,r=a<<10;e.getBCHDigit(r)-t>=0;)r^=1335<<e.getBCHDigit(r)-t;return 21522^(a<<10|r)},HF}(),h=BF(),c=rO();function m(e,t,i){var n,a,r=e.size,o=d.getEncodedBits(t,i);for(n=0;n<15;n++)a=1==(o>>n&1),n<6?e.set(n,8,a,!0):n<8?e.set(n+1,8,a,!0):e.set(r-15+n,8,a,!0),n<8?e.set(8,r-n-1,a,!0):n<9?e.set(8,15-n-1+1,a,!0):e.set(8,15-n-1,a,!0);e.set(r-8,8,1,!0)}function f(t,n,a){var r=new i;a.forEach(function(e){r.put(e.mode.bit,4),r.put(e.getLength(),h.getCharCountIndicator(e.mode,t)),e.write(r)});var o=8*(e.getSymbolTotalCodewords(t)-s.getTotalCodewordsCount(t,n));for(r.getLengthInBits()+4<=o&&r.put(0,4);r.getLengthInBits()%8!=0;)r.putBit(0);for(var l=(o-r.getLengthInBits())/8,d=0;d<l;d++)r.put(d%2?17:236,8);return function(t,i,n){for(var a=e.getSymbolTotalCodewords(i),r=s.getTotalCodewordsCount(i,n),o=a-r,l=s.getBlocksCount(i,n),d=l-a%l,h=Math.floor(a/l),c=Math.floor(o/l),m=c+1,f=h-c,v=new u(f),p=0,g=new Array(l),y=new Array(l),b=0,w=new Uint8Array(t.buffer),k=0;k<l;k++){var S=k<d?c:m;g[k]=w.slice(p,p+S),y[k]=v.encode(g[k]),p+=S,b=Math.max(b,S)}var E,T,P=new Uint8Array(a),M=0;for(E=0;E<b;E++)for(T=0;T<l;T++)E<g[T].length&&(P[M++]=g[T][E]);for(E=0;E<f;E++)for(T=0;T<l;T++)P[M++]=y[T][E];return P}(r,t,n)}function v(t,i,s,u){var d;if(Array.isArray(t))d=c.fromArray(t);else{if("string"!=typeof t)throw new Error("Invalid data");var h=i;if(!h){var v=c.rawSplit(t);h=l.getBestVersionForData(v,s)}d=c.fromString(t,h||40)}var p=l.getBestVersionForData(d,s);if(!p)throw new Error("The amount of data is too big to be stored in a QR Code");if(i){if(i<p)throw new Error("\nThe chosen QR Code version cannot contain this amount of data.\nMinimum version required to store current data is: "+p+".\n")}else i=p;var g=f(i,s,d),y=e.getSymbolSize(i),b=new n(y);return function(e,t){for(var i=e.size,n=r.getPositions(t),a=0;a<n.length;a++)for(var o=n[a][0],s=n[a][1],u=-1;u<=7;u++)if(!(o+u<=-1||i<=o+u))for(var l=-1;l<=7;l++)s+l<=-1||i<=s+l||(u>=0&&u<=6&&(0===l||6===l)||l>=0&&l<=6&&(0===u||6===u)||u>=2&&u<=4&&l>=2&&l<=4?e.set(o+u,s+l,!0,!0):e.set(o+u,s+l,!1,!0))}(b,i),function(e){for(var t=e.size,i=8;i<t-8;i++){var n=i%2==0;e.set(i,6,n,!0),e.set(6,i,n,!0)}}(b),function(e,t){for(var i=a.getPositions(t),n=0;n<i.length;n++)for(var r=i[n][0],o=i[n][1],s=-2;s<=2;s++)for(var u=-2;u<=2;u++)-2===s||2===s||-2===u||2===u||0===s&&0===u?e.set(r+s,o+u,!0,!0):e.set(r+s,o+u,!1,!0)}(b,i),m(b,s,0),i>=7&&function(e,t){for(var i,n,a,r=e.size,o=l.getEncodedBits(t),s=0;s<18;s++)i=Math.floor(s/3),n=s%3+r-8-3,a=1==(o>>s&1),e.set(i,n,a,!0),e.set(n,i,a,!0)}(b,i),function(e,t){for(var i=e.size,n=-1,a=i-1,r=7,o=0,s=i-1;s>0;s-=2)for(6===s&&s--;;){for(var u=0;u<2;u++)if(!e.isReserved(a,s-u)){var l=!1;o<t.length&&(l=1==(t[o]>>>r&1)),e.set(a,s-u,l),-1===--r&&(o++,r=7)}if((a+=n)<0||i<=a){a-=n,n=-n;break}}}(b,g),isNaN(u)&&(u=o.getBestMask(b,m.bind(null,b,s))),o.applyMask(u,b),m(b,s,u),{modules:b,version:i,errorCorrectionLevel:s,maskPattern:u,segments:d}}return rF.create=function(i,n){if(void 0===i||""===i)throw new Error("No input text");var a,r,s=t.M;return void 0!==n&&(s=t.from(n.errorCorrectionLevel,t.M),a=l.from(n.version),r=o.from(n.maskPattern),n.toSJISFunc&&e.setToSJISFunction(n.toSJISFunc)),v(i,a,s,r)},rF}var sO,uO,lO={},dO={};function hO(){return sO||(sO=1,function(e){function t(e){if("number"==typeof e&&(e=e.toString()),"string"!=typeof e)throw new Error("Color should be defined as hex string");var t=e.slice().replace("#","").split("");if(t.length<3||5===t.length||t.length>8)throw new Error("Invalid hex color: "+e);3!==t.length&&4!==t.length||(t=Array.prototype.concat.apply([],t.map(function(e){return[e,e]}))),6===t.length&&t.push("F","F");var i=parseInt(t.join(""),16);return{r:i>>24&255,g:i>>16&255,b:i>>8&255,a:255&i,hex:"#"+t.slice(0,6).join("")}}e.getOptions=function(e){e||(e={}),e.color||(e.color={});var i=void 0===e.margin||null===e.margin||e.margin<0?4:e.margin,n=e.width&&e.width>=21?e.width:void 0,a=e.scale||4;return{width:n,scale:n?4:a,margin:i,color:{dark:t(e.color.dark||"#000000ff"),light:t(e.color.light||"#ffffffff")},type:e.type,rendererOpts:e.rendererOpts||{}}},e.getScale=function(e,t){return t.width&&t.width>=e+2*t.margin?t.width/(e+2*t.margin):t.scale},e.getImageWidth=function(t,i){var n=e.getScale(t,i);return Math.floor((t+2*i.margin)*n)},e.qrToImageData=function(t,i,n){for(var a=i.modules.size,r=i.modules.data,o=e.getScale(a,n),s=Math.floor((a+2*n.margin)*o),u=n.margin*o,l=[n.color.light,n.color.dark],d=0;d<s;d++)for(var h=0;h<s;h++){var c=4*(d*s+h),m=n.color.light;if(d>=u&&h>=u&&d<s-u&&h<s-u)m=l[r[Math.floor((d-u)/o)*a+Math.floor((h-u)/o)]?1:0];t[c++]=m.r,t[c++]=m.g,t[c++]=m.b,t[c]=m.a}}}(dO)),dO}function cO(){return uO||(uO=1,function(e){var t=hO();e.render=function(e,i,n){var a=n,r=i;void 0!==a||i&&i.getContext||(a=i,i=void 0),i||(r=function(){try{return document.createElement("canvas")}catch(e){throw new Error("You need to specify a canvas element")}}()),a=t.getOptions(a);var o=t.getImageWidth(e.modules.size,a),s=r.getContext("2d"),u=s.createImageData(o,o);return t.qrToImageData(u.data,e,a),function(e,t,i){e.clearRect(0,0,t.width,t.height),t.style||(t.style={}),t.height=i,t.width=i,t.style.height=i+"px",t.style.width=i+"px"}(s,r,o),s.putImageData(u,0,0),r},e.renderToDataURL=function(t,i,n){var a=n;void 0!==a||i&&i.getContext||(a=i,i=void 0),a||(a={});var r=e.render(t,i,a),o=a.type||"image/png",s=a.rendererOpts||{};return r.toDataURL(o,s.quality)}}(lO)),lO}var mO,fO,vO={};function pO(){if(mO)return vO;mO=1;var e=hO();function t(e,t){var i=e.a/255,n=t+'="'+e.hex+'"';return i<1?n+" "+t+'-opacity="'+i.toFixed(2).slice(1)+'"':n}function i(e,t,i){var n=e+t;return void 0!==i&&(n+=" "+i),n}return vO.render=function(n,a,r){var o=e.getOptions(a),s=n.modules.size,u=n.modules.data,l=s+2*o.margin,d=o.color.light.a?"<path "+t(o.color.light,"fill")+' d="M0 0h'+l+"v"+l+'H0z"/>':"",h="<path "+t(o.color.dark,"stroke")+' d="'+function(e,t,n){for(var a="",r=0,o=!1,s=0,u=0;u<e.length;u++){var l=Math.floor(u%t),d=Math.floor(u/t);l||o||(o=!0),e[u]?(s++,u>0&&l>0&&e[u-1]||(a+=o?i("M",l+n,.5+d+n):i("m",r,0),r=0,o=!1),l+1<t&&e[u+1]||(a+=i("h",s),s=0)):r++}return a}(u,s,o.margin)+'"/>',c='viewBox="0 0 '+l+" "+l+'"',m='<svg xmlns="http://www.w3.org/2000/svg" '+(o.width?'width="'+o.width+'" height="'+o.width+'" ':"")+c+' shape-rendering="crispEdges">'+d+h+"</svg>\n";return"function"==typeof r&&r(null,m),m},vO}var gO,yO,bO=function(){if(fO)return iF;fO=1;var e=nF(),t=oO(),i=cO(),n=pO();function a(i,n,a,r,o){var s=[].slice.call(arguments,1),u=s.length,l="function"==typeof s[u-1];if(!l&&!e())throw new Error("Callback required as last argument");if(!l){if(u<1)throw new Error("Too few arguments provided");return 1===u?(a=n,n=r=void 0):2!==u||n.getContext||(r=a,a=n,n=void 0),new Promise(function(e,o){try{var s=t.create(a,r);e(i(s,n,r))}catch(e){o(e)}})}if(u<2)throw new Error("Too few arguments provided");2===u?(o=a,a=n,n=r=void 0):3===u&&(n.getContext&&void 0===o?(o=r,r=void 0):(o=r,r=a,a=n,n=void 0));try{var d=t.create(a,r);o(null,i(d,n,r))}catch(e){o(e)}}return iF.create=t.create,iF.toCanvas=a.bind(null,i.render),iF.toDataURL=a.bind(null,i.renderToDataURL),iF.toString=a.bind(null,function(e,t,i){return n.render(e,i)}),iF}(),wO=be(bO),kO=e=>e,SO=function(){function i(){var e;return u(this,i),(e=s(this,i,arguments)).scaleFactor=1,e}return y(i,bs),m(i,[{key:"styles",value:function(){var e;return this.component?t.unsafeCSS(`\n :host {\n box-sizing: border-box;\n ${zs(this.component,this.scaleFactor)}\n ${Ns(this.component,this.scaleFactor)}\n background-color: ${this.component.fillColor||this.component.borderColor||"transparent"};\n border-width: ${null!==(e=this.component.borderWidth)&&void 0!==e?e:0}px;\n ${Ls(this.component.borderColor||"transparent")}\n border-style: solid;\n display: inline-block;\n }`):t.unsafeCSS(":host { box-sizing: border-box; display: inline-block; }")}},{key:"renderQr",value:function(){var t,i,n,a,r,s,u,l;return S(function(d){for(;;)switch(d.p=d.n){case 0:if((a=this.renderRoot.querySelector("canvas"))&&null!==(t=this.component)&&void 0!==t&&t.url){d.n=1;break}return d.a(2);case 1:return r=this.computedSize,a.width=r,a.height=r,a.style.width=`${r}px`,a.style.height=`${r}px`,s=null!==(i=ia(this.component.color))&&void 0!==i?i:"#000000",u=null!==(n=ia(this.component.fillColor))&&void 0!==n?n:"#ffffff",d.p=2,d.n=3,o(wO.toCanvas(a,this.component.url,{width:r,color:{dark:s,light:u},margin:0}));case 3:d.n=5;break;case 4:d.p=4,l=d.v,e.logger.error(`QR render failed for URL "${this.component.url}":`,l);case 5:return d.a(2)}},null,this,[[2,4]],Promise)}},{key:"firstUpdated",value:function(){this.renderQr()}},{key:"updated",value:function(e){(e.has("component")||e.has("scaleFactor"))&&Promise.resolve().then(()=>this.renderQr())}},{key:"computedSize",get:function(){var e,t=Number(null!==(e=this.component.borderWidth)&&void 0!==e?e:0),i=Number(this.component.width)*this.scaleFactor,n=Math.floor(this.component.width?i-2*t:360);return Math.max(1,n)}},{key:"render",value:function(){if(this.component){var e=this.computedSize;return t.html(gO||(gO=kO`<canvas width="${0}" height="${0}" style="width:${0}px;height:${0}px;"></canvas>`),e,e,e,e)}return t.html(yO||(yO=kO`<canvas></canvas>`))}}])}();Ae([ot({type:Object})],SO.prototype,"component",void 0),Ae([ot({type:Number})],SO.prototype,"scaleFactor",void 0),SO=Ae([Fe("nami-qr-code")],SO);var EO,TO=e=>e,PO=function(){function i(){var e;return u(this,i),(e=s(this,i)).inFocusedState=!1,e.scaleFactor=1,e.isActive=!1,e._handleKeyDown=t=>{"Enter"!==t.key&&" "!==t.key&&142!==t.keyCode&&195!==t.keyCode||e._handleClick()},e}return y(i,bs),m(i,[{key:"connectedCallback",value:function(){M(i,"connectedCallback",this)([]),this.isActive=!!this.component.checked,this.contextProvider.setFormState(this.component.formId,this.isActive),this.addEventListener("click",this._handleClick,!1),this.addEventListener("keydown",this._handleKeyDown)}},{key:"disconnectedCallback",value:function(){M(i,"disconnectedCallback",this)([]),this.removeEventListener("click",this._handleClick),this.removeEventListener("keydown",this._handleKeyDown)}},{key:"_handleClick",value:function(){var t=this.component,i=t.onTap,n=t.disabled,a=t.formId;if(!0!==n){this.component.checked=!this.component.checked,this.isActive=this.component.checked;var r=void 0;r=a?{function:(null==i?void 0:i.function)||"",parameters:v({},null==i?void 0:i.parameters,{formId:a||""})}:i,!this.contextProvider.flow||a?Ao({onTap:r,contextProvider:this.contextProvider}):this.component.id?(e.logger.debug(`Trigger NamiFlow action for component ${this.component.id}`),this.contextProvider.flow.triggerActions(this.component.id)):e.logger.warn("Cannot trigger button hoisting without an id")}}},{key:"styles",value:function(){return t.unsafeCSS(`\n :host {\n box-sizing: border-box;\n }\n :host .toggle-plate {\n display: flex;\n position: relative;\n ${this.applyPlateStyles()}\n }\n :host .toggle-handle {\n display: flex;\n position: relative;\n ${this.applyHandleStyles()}\n }\n `)}},{key:"applyPlateStyles",value:function(){var e=this.component,t=this.scaleFactor,i=this.isActive||e.checked||!1,n=i?e.activePlateFillColor||"transparent":e.inactivePlateFillColor||"transparent",a=i?e.activePlateBorderColor||"transparent":e.inactivePlateBorderColor||"transparent";return`\n transition: all 0.3s;\n ${zs(e,t)};\n ${Ls(a)}\n border-width: ${i?e.activePlateBorderWidth||0:e.inactivePlateBorderWidth||0}px !important;\n border-style: solid;\n border-radius: ${e.borderRadius||0}px !important;\n padding: ${e.innerPadding||0}px !important;\n ${Is(n)}\n `}},{key:"applyHandleStyles",value:function(){var e=this.component,t=e.checked||!1,i=t?e.activeHandleFillColor||"transparent":e.inactiveHandleFillColor||"transparent",n=t?e.activeHandleBorderColor||"transparent":e.inactiveHandleBorderColor||"transparent";return`\n transition: all 0.3s;\n height: 100%;\n width: 50%;\n border-radius: ${e.borderRadius}px !important;\n ${Ls(n)}\n border-width: ${t?e.activeHandleBorderWidth||0:e.inactiveHandleBorderWidth||0}px !important;\n ${Hs(e.dropShadow)}\n border-style: solid;\n left: ${t?"50%":0};\n ${Is(i)}\n `}},{key:"render",value:function(){return this.tabIndex=0,this.role="switch",t.html(EO||(EO=TO`
|
|
558
558
|
<div class="toggle-plate">
|
|
559
559
|
<div class="toggle-handle"></div>
|
|
560
560
|
</div>
|
|
561
|
-
`))}}])}();Ae([ot({type:Object})],
|
|
561
|
+
`))}}])}();Ae([ot({type:Object})],PO.prototype,"component",void 0),Ae([ot({type:Boolean})],PO.prototype,"inFocusedState",void 0),Ae([ot({type:Number})],PO.prototype,"scaleFactor",void 0),Ae([ot({type:Boolean})],PO.prototype,"isActive",void 0),PO=Ae([Fe("nami-toggle-switch")],PO);var MO,AO=e=>e,DO=function(){function e(){var t;return u(this,e),(t=s(this,e)).inFocusedState=!1,t.scaleFactor=1,t.tabIndex=0,t}return y(e,bs),m(e,[{key:"styles",value:function(){var e=this.component;return t.unsafeCSS(`\n :host {\n box-sizing: border-box;\n }\n :host .radio-button-wrapper {\n display: flex;\n transition: all 0.3s;\n ${zs(e,this.scaleFactor)}\n ${Ls(e.inactiveBorderColor||"transparent")}\n border-width: ${e.inactiveBorderWidth||0}px !important;\n border-style: solid;\n border-radius: 100%;\n padding: ${e.innerPadding||0}px !important;\n }\n :host .radio-button-wrapper.active {\n ${Ls(e.activeBorderColor||"transparent")}\n border-width: ${e.activeBorderWidth||0}px !important;\n ${Hs(e.dropShadow)}\n }\n :host .radio-button-inner {\n ${Is(e.inactiveFillColor||"transparent")}\n width: 100%;\n height: 100%;\n border-radius: 100%;\n }\n :host .radio-button-wrapper.active .radio-button-inner {\n ${Is(e.activeFillColor||"transparent")}\n }\n `)}},{key:"isActive",get:function(){var e,t,i=null!==(e=null===(t=this.component.sku)||void 0===t?void 0:t.id)&&void 0!==e?e:"";return Object.values(this.contextProvider.selectedProducts()).includes(i)}},{key:"render",value:function(){var e=this.isActive?"active":"";return t.html(MO||(MO=AO`
|
|
562
562
|
<div class="radio-button-wrapper ${0}">
|
|
563
563
|
<div class="radio-button-inner"></div>
|
|
564
564
|
</div>
|
|
565
|
-
`),e)}}])}();Ae([ot({type:Object})],
|
|
565
|
+
`),e)}}])}();Ae([ot({type:Object})],DO.prototype,"component",void 0),Ae([ot({type:Boolean})],DO.prototype,"inFocusedState",void 0),Ae([ot({type:Number})],DO.prototype,"scaleFactor",void 0),DO=Ae([Fe("nami-radio-button")],DO);var xO,CO=e=>e,IO=e._internal.NamiFlowManager,LO=function(){function i(){var e;return u(this,i),(e=s(this,i,arguments)).scaleFactor=1,e.inFocusedState=!1,e.currentWidth=0,e.hasInitialized=!1,e}return y(i,bs),m(i,[{key:"connectedCallback",value:function(){M(i,"connectedCallback",this)([]),e.validateMinSDKVersion(this.minSDKVersion,"ProgressIndicator")}},{key:"firstUpdated",value:function(e){var t;M(i,"firstUpdated",this)([e]),this.currentWidth=100*IO.getLastAnimatedFlowProgress((null===(t=this.component)||void 0===t?void 0:t.id)||"default"),this.hasInitialized=!0,this.animateProgress(!0)}},{key:"updated",value:function(e){M(i,"updated",this)([e]),this.hasInitialized&&this.animateProgress(!1)}},{key:"styles",value:function(){var e=this.component,i=this.scaleFactor,n=this.inFocusedState,a=e.inactiveFillColor,r=e.inactiveFillColorFallback,o=e.inactiveBorderRadius,s=e.activeFillColor,u=e.activeFillColorFallback,l=e.activeBorderRadius,d=e.innerPadding,h=void 0===d?0:d,c=e.activeDropShadow,m=e.inactiveDropShadow;return t.unsafeCSS(`\n :host {\n display: ${e.hidden?"none":"block"};\n ${Ks(e,i,n)}\n }\n \n .progress-container {\n ${zs(e,i)} \n background: ${a||r};\n border-radius: ${o||0}px;\n overflow: hidden;\n position: relative;\n padding: ${h*i}px;\n box-sizing: border-box;\n ${Hs(m)}\n }\n \n .progress-bar {\n height: 100%;\n background: ${s||u};\n border-radius: ${l||0}px;\n box-sizing: border-box;\n transition: width 0.8s ease-in-out;\n ${Hs(c)}\n }\n `)}},{key:"getProgressPercentage",value:function(){var e,t=null!==(e=this.component.percentage)&&void 0!==e?e:0;return"auto"===t&&(t=IO.getCurrentFlowProgress(this.component.id)),Math.min(100,Math.max(0,100*Number(t)))}},{key:"animateProgress",value:function(e){var t=this.component,i=t.id,n=t.percentage,a=this.getProgressPercentage();if(this.currentWidth!==a){var r=()=>{this.currentWidth=a,"auto"===n&&IO.setLastAnimatedFlowProgress(i||"default",a/100)};e?requestAnimationFrame(()=>requestAnimationFrame(r)):requestAnimationFrame(r)}}},{key:"render",value:function(){return t.html(xO||(xO=CO`
|
|
566
566
|
<div class="progress-container">
|
|
567
567
|
<div
|
|
568
568
|
class="progress-bar"
|
|
@@ -573,20 +573,20 @@
|
|
|
573
573
|
aria-valuemax="100"
|
|
574
574
|
></div>
|
|
575
575
|
</div>
|
|
576
|
-
`),this.currentWidth,Math.round(this.currentWidth))}}])}();Ae([ot({type:Object})],IO.prototype,"component",void 0),Ae([ot({type:Number})],IO.prototype,"scaleFactor",void 0),Ae([ot({type:Boolean})],IO.prototype,"inFocusedState",void 0),Ae([ot({type:Object})],IO.prototype,"minSDKVersion",void 0),Ae([ot({type:Number})],IO.prototype,"currentWidth",void 0),IO=Ae([Fe("nami-progress-indicator")],IO);var LO=function(){function e(){var t;return u(this,e),(t=s(this,e,arguments)).inFocusedState=!1,t.scaleFactor=1,t.isActive=!1,t._handleFocus=()=>{t.inFocusedState=!0},t._handleKeyDown=e=>{"Enter"!==e.key&&" "!==e.key&&142!==e.keyCode&&195!==e.keyCode||t._handleClick()},t}return y(e,bs),m(e,[{key:"connectedCallback",value:function(){M(e,"connectedCallback",this)([]),this.addEventListener("click",this._handleClick,!1),this.addEventListener("keydown",this._handleKeyDown),this.addEventListener("focus",this._handleFocus)}},{key:"disconnectedCallback",value:function(){M(e,"disconnectedCallback",this)([]),this.removeEventListener("click",this._handleClick),this.removeEventListener("keydown",this._handleKeyDown),this.removeEventListener("focus",this._handleFocus)}},{key:"_handleClick",value:function(){var e,t,i=null===(e=this.component.onTap)||void 0===e?void 0:e.function;if(i){var n={function:i,parameters:v({},null===(t=this.component.onTap)||void 0===t?void 0:t.parameters,{formId:this.component.formId||"",value:"radio"===this.component.mode?this.component.value:void 0})};Ao({onTap:n,contextProvider:this.contextProvider})}}},{key:"updated",value:function(){var e;this.ariaLabel=this.component.screenreaderText||this.component.title||"",this.ariaDescription=null!==(e=this.component.screenreaderHint)&&void 0!==e?e:""}},{key:"styles",value:function(){var e=this.component,i=this.contextProvider.getCurrentFormId(e.formId||""),n=!0===i||i===e.value;this.inFocusedState=n;var a=n?e.activeFillColor||e.activeFillColorFallback||"transparent":e.inactiveFillColor||e.inactiveFillColorFallback||"transparent",r=n?e.activeBorderColor||"transparent":e.inactiveBorderColor||"transparent";return t.unsafeCSS(`\n :host {\n box-sizing: border-box;\n display: ${e.hidden?"none":"flex"};\n position: relative;\n cursor: pointer;\n height: 100%;\n border-radius: ${e.borderRadius}px !important;\n ${Ks(e,this.scaleFactor,this.inFocusedState)}\n ${Ls(r)}\n border-width: ${n?e.activeBorderWidth||0:e.inactiveBorderWidth||0}px !important;\n ${Hs(n?e.activeDropShadow:e.inactiveDropShadow)};\n border-style: solid;\n ${Is(a)}\n }\n `)}},{key:"render",value:function(){return this.tabIndex=0,this.component.components.map(e=>Iu(this.contextProvider,e,this.scaleFactor,this.inFocusedState,this.minSDKVersion))}}])}();Ae([ot({type:Object})],LO.prototype,"component",void 0),Ae([ot({type:Boolean})],LO.prototype,"inFocusedState",void 0),Ae([ot({type:Number})],LO.prototype,"scaleFactor",void 0),Ae([ot({type:Object})],LO.prototype,"minSDKVersion",void 0),Ae([ot({type:Boolean})],LO.prototype,"isActive",void 0),LO=Ae([Fe("nami-toggle-button")],LO);var _O,RO,FO,OO,WO,$O,NO,jO,BO,zO,UO=e=>e,HO=(_O=function(){function i(){var e;return u(this,i),(e=s(this,i,arguments)).inFocusedState=!1,e.scaleFactor=1,e.timer=null,e.startTime=0,e.initialDuration=0,e.hasEmittedCompletion=!1,e}return y(i,bs),m(i,[{key:"firstUpdated",value:function(){this.loadTimerState(),this.startTimer()}},{key:"disconnectedCallback",value:function(){M(i,"disconnectedCallback",this)([]),this.saveTimerState(),this.clearTimer()}},{key:"getTimerId",value:function(){var e,t;return null!==(e=null===(t=this.component)||void 0===t?void 0:t.id)&&void 0!==e?e:""}},{key:"loadTimerState",value:function(){var e;null!==(e=this.contextProvider)&&void 0!==e&&e.flow&&(this.timerState=this.contextProvider.flow.timerStates[this.getTimerId()])}},{key:"saveTimerState",value:function(){var e;if(null!==(e=this.contextProvider)&&void 0!==e&&e.flow){var t=this.component,i=t.mode,n=t.durationSeconds;if("duration"===i&&void 0!==n){var a=this.calculateCurrentRemainingSeconds();this.contextProvider.flow.timerStates[this.getTimerId()]={remainingSeconds:a,savedAt:Date.now(),hasEmittedCompletion:this.hasEmittedCompletion}}}}},{key:"getSavedTimerState",value:function(){var e;return null===(e=this.contextProvider)||void 0===e||null===(e=e.flow)||void 0===e?void 0:e.timerStates[this.getTimerId()]}},{key:"startTimer",value:function(){this.initializeTimerState(),this.clearTimer(),this.timer=setInterval(()=>this.onTimerTick(),zO.TIMER_INTERVAL_MS)}},{key:"initializeTimerState",value:function(){var e=this.component,t=e.mode,i=e.durationSeconds,n=e.resetOnRemount;"duration"===t&&void 0!==i&&(this.timerState&&!n?this.restoreTimerFromState(this.timerState,i):this.resetTimerState(i))}},{key:"restoreTimerFromState",value:function(e,t){var i=(Date.now()-e.savedAt)/1e3,n=Math.max(0,e.remainingSeconds-i);this.initialDuration=t,this.startTime=Date.now()-1e3*(this.initialDuration-n),this.hasEmittedCompletion=e.hasEmittedCompletion}},{key:"resetTimerState",value:function(e){this.initialDuration=e,this.startTime=Date.now(),this.hasEmittedCompletion=!1}},{key:"onTimerTick",value:function(){var e=this.calculateTimeValues().isCompleted;this.requestUpdate(),e&&this.clearTimer()}},{key:"clearTimer",value:function(){this.timer&&(clearInterval(this.timer),this.timer=null)}},{key:"calculateTimeValues",value:function(){var e=this.calculateTotalRemainingSeconds(),t=e<=0,i=this.component.units||zO.DEFAULT_UNITS,n=i.days,a=i.hours,r=i.minutes,o=i.seconds;return v({},this.convertSecondsToTimeUnits(e,{days:n,hours:a,minutes:r,seconds:o}),{isCompleted:t})}},{key:"calculateTotalRemainingSeconds",value:function(){var e=this.component,t=e.mode,i=e.durationSeconds,n=e.targetDateTime;return"duration"===t?this.calculateDurationRemainingSeconds(i):"targetDateTime"===t&&n?this.calculateTargetDateTimeRemainingSeconds(n):0}},{key:"calculateDurationRemainingSeconds",value:function(e){var t=this.getSavedTimerState();if(t){var i=(Date.now()-t.savedAt)/1e3;return Math.max(0,t.remainingSeconds-i)}if(this.initialDuration>0&&this.startTime>0){var n=(Date.now()-this.startTime)/1e3;return Math.max(0,this.initialDuration-n)}return void 0!==e?Math.max(0,e):0}},{key:"calculateTargetDateTimeRemainingSeconds",value:function(e){var t=new Date(e).getTime(),i=Date.now();return Math.max(0,(t-i)/1e3)}},{key:"calculateCurrentRemainingSeconds",value:function(){var e=this.component.durationSeconds;if(this.initialDuration>0&&this.startTime>0){var t=(Date.now()-this.startTime)/1e3;return Math.max(0,this.initialDuration-t)}return null!=e?e:0}},{key:"convertSecondsToTimeUnits",value:function(e,t){var i=t.days?Math.floor(e/zO.SECONDS_PER_DAY):0,n=e-i*zO.SECONDS_PER_DAY,a=t.hours?Math.floor(n/zO.SECONDS_PER_HOUR):0,r=n-a*zO.SECONDS_PER_HOUR,o=t.minutes?Math.floor(r/zO.SECONDS_PER_MINUTE):0,s=r-o*zO.SECONDS_PER_MINUTE;return{days:i,hours:a,minutes:o,seconds:t.seconds?Math.floor(s):0}}},{key:"formatValue",value:function(e,t){return t?e.toString().padStart(2,"0"):e.toString()}},{key:"emitCompletionEvent",value:function(){!this.hasEmittedCompletion&&this.contextProvider&&(this.hasEmittedCompletion=!0,e.NamiEventEmitter.getInstance().emit(e.PAYWALL_ACTION_EVENT,v({},this.contextProvider.getPaywallActionEventData(),{action:e.NamiPaywallAction.COUNTDOWN_TIMER_COMPLETED,componentChange:{id:this.component.id,name:this.component.title}})))}},{key:"updated",value:function(e){this.updateAccessibilityAttributes(),e.has("component")&&this.handleComponentChange(e.get("component"))}},{key:"updateAccessibilityAttributes",value:function(){this.ariaLabel=this.component.screenreaderText||"",this.ariaDescription=this.component.screenreaderHint||""}},{key:"handleComponentChange",value:function(e){if(e){var t=this.component,i=t.mode,n=t.durationSeconds,a=t.targetDateTime;(i!==e.mode||n!==e.durationSeconds||a!==e.targetDateTime)&&this.startTimer()}}},{key:"styles",value:function(){var e=this.component,i=e.labels,n=e.separator,a=e.labelPosition,r=void 0===a?"none":a,o=e.direction,s=void 0===o?"horizontal":o,u=e.labelFontSize,l=e.labelFontColor,d=e.labelFontName,h=e.labelSpacing,c=e.spacing,m=e.fontSize,f=e.fontColor,v=e.fontName,p=e.alignment,g="below"===r?"bottom":"above"===r?"top":r,y="vertical"===s,b=i&&(i.days||i.hours||i.minutes||i.seconds)||"none"!==g;return t.unsafeCSS(`\n :host {\n box-sizing: border-box;\n display: ${e.hidden?"none":"flex"};\n position: relative;\n cursor: pointer;\n height: 100%;\n border-radius: ${e.borderRadius||0}px !important;\n flex-direction: ${y?"column":"row"};\n align-items: center;\n justify-content: flex-start;\n ${Rs(e,this.inFocusedState)}\n ${Ns(e,this.scaleFactor)}\n ${Bs(e,this.scaleFactor,this.inFocusedState)}\n ${Os(e)}\n ${zs(e,this.scaleFactor)}\n }\n .timer-text {\n display: flex;\n flex-direction: ${y?"column":"row"};\n align-items: center;\n gap: ${y?c?c*this.scaleFactor:4:0}px;\n }\n .timer-unit {\n display: flex;\n flex-direction: ${"top"===g||"bottom"===g?"column":"row"};\n align-items: center;\n ${y?`margin-top: ${c?c*this.scaleFactor:4}px;`:`margin-right: ${c?c*this.scaleFactor:4}px;`} \n }\n .timer-text-value-days,\n .timer-text-value-hours,\n .timer-text-value-minutes,\n .timer-text-value-seconds {\n ${m?`font-size: ${m*this.scaleFactor}px;`:""}\n ${f?_s(f):""}\n ${Vs(v)}\n ${p?`text-align: ${p};`:""}\n ${Hs(e.dropShadow,!0)}\n line-height: 1;\n }\n .timer-text-value-label {\n font-size: ${u?u*this.scaleFactor:12*this.scaleFactor}px;\n color: ${l||"inherit"};\n ${Vs(d)}\n ${"top"===g?`margin-bottom: ${h?h*this.scaleFactor:2}px;`:""}\n ${"bottom"===g?`margin-top: ${h?h*this.scaleFactor:2}px;`:""}\n ${b?"":"display: none;"}\n }\n .timer-text-value-separator {\n ${n?`\n display: flex;\n align-items: center;\n ${m?`font-size: ${m*this.scaleFactor}px;`:""}\n ${f?_s(f):""}\n ${Vs(v)}\n line-height: 1;\n ${y?`margin-top: ${c?c*this.scaleFactor:4}px;`:`margin-right: ${c?c*this.scaleFactor:4}px;`} \n ${"bottom"===g||"top"===g?"align-self: flex-start;":""}\n `:"display: none;"}\n }\n `)}},{key:"render",value:function(){this.tabIndex=0;var e=this.component.showWhenCompleted,i=void 0===e?"zero":e,n=this.calculateTimeValues();if(n.isCompleted&&(this.emitCompletionEvent(),"hidden"===i))return t.html(RO||(RO=UO``));var a=this.buildUnitsToRender(n);return 0===a.length?t.html(FO||(FO=UO`<div class="timer-text"></div>`)):this.renderTimerUnits(a)}},{key:"buildUnitsToRender",value:function(e){var t=this.component,i=t.labels,n=t.units,a=t.labelPosition,r=void 0===a?"none":a,o=n||{},s=o.days,u=o.hours,l=o.minutes,d=o.seconds,h=this.normalizeLabelPosition(r),c=this.shouldDisplayLabels(i,h);return[{enabled:s,value:e.days,label:this.getLabel("days",i,c),class:"timer-text-value-days"},{enabled:u,value:e.hours,label:this.getLabel("hours",i,c),class:"timer-text-value-hours"},{enabled:l,value:e.minutes,label:this.getLabel("minutes",i,c),class:"timer-text-value-minutes"},{enabled:d,value:e.seconds,label:this.getLabel("seconds",i,c),class:"timer-text-value-seconds"}].filter(e=>e.enabled).map(e=>({value:e.value,label:e.label,unitClass:e.class,showUnit:!0}))}},{key:"normalizeLabelPosition",value:function(e){return"below"===e?"bottom":"above"===e?"top":e}},{key:"shouldDisplayLabels",value:function(e,t){return Boolean(e&&(e.days||e.hours||e.minutes||e.seconds))||"none"!==t&&void 0!==t}},{key:"getLabel",value:function(e,t,i){var n;return null!==(n=null==t?void 0:t[e])&&void 0!==n?n:i?zO.DEFAULT_LABELS[e]:""}},{key:"renderTimerUnits",value:function(e){var i=this.component,n=i.separator,a=i.zeroPad,r=void 0===a||a,o=i.labelPosition,s=void 0===o?"none":o,u=this.component.labels,l=this.normalizeLabelPosition(s),d=u&&(u.days||u.hours||u.minutes||u.seconds),h=Boolean(d||"none"!==l),c=null!=n?n:":";return t.html(OO||(OO=UO`
|
|
576
|
+
`),this.currentWidth,Math.round(this.currentWidth))}}])}();Ae([ot({type:Object})],LO.prototype,"component",void 0),Ae([ot({type:Number})],LO.prototype,"scaleFactor",void 0),Ae([ot({type:Boolean})],LO.prototype,"inFocusedState",void 0),Ae([ot({type:Object})],LO.prototype,"minSDKVersion",void 0),Ae([ot({type:Number})],LO.prototype,"currentWidth",void 0),LO=Ae([Fe("nami-progress-indicator")],LO);var _O=function(){function e(){var t;return u(this,e),(t=s(this,e,arguments)).inFocusedState=!1,t.scaleFactor=1,t.isActive=!1,t._handleFocus=()=>{t.inFocusedState=!0},t._handleKeyDown=e=>{"Enter"!==e.key&&" "!==e.key&&142!==e.keyCode&&195!==e.keyCode||t._handleClick()},t}return y(e,bs),m(e,[{key:"connectedCallback",value:function(){M(e,"connectedCallback",this)([]),this.addEventListener("click",this._handleClick,!1),this.addEventListener("keydown",this._handleKeyDown),this.addEventListener("focus",this._handleFocus)}},{key:"disconnectedCallback",value:function(){M(e,"disconnectedCallback",this)([]),this.removeEventListener("click",this._handleClick),this.removeEventListener("keydown",this._handleKeyDown),this.removeEventListener("focus",this._handleFocus)}},{key:"_handleClick",value:function(){var e,t,i=null===(e=this.component.onTap)||void 0===e?void 0:e.function;if(i){var n={function:i,parameters:v({},null===(t=this.component.onTap)||void 0===t?void 0:t.parameters,{formId:this.component.formId||"",value:"radio"===this.component.mode?this.component.value:void 0})};Ao({onTap:n,contextProvider:this.contextProvider})}}},{key:"updated",value:function(){var e;this.ariaLabel=this.component.screenreaderText||this.component.title||"",this.ariaDescription=null!==(e=this.component.screenreaderHint)&&void 0!==e?e:""}},{key:"styles",value:function(){var e=this.component,i=this.contextProvider.getCurrentFormId(e.formId||""),n=!0===i||i===e.value;this.inFocusedState=n;var a=n?e.activeFillColor||e.activeFillColorFallback||"transparent":e.inactiveFillColor||e.inactiveFillColorFallback||"transparent",r=n?e.activeBorderColor||"transparent":e.inactiveBorderColor||"transparent";return t.unsafeCSS(`\n :host {\n box-sizing: border-box;\n display: ${e.hidden?"none":"flex"};\n position: relative;\n cursor: pointer;\n height: 100%;\n border-radius: ${e.borderRadius}px !important;\n ${Ks(e,this.scaleFactor,this.inFocusedState)}\n ${Ls(r)}\n border-width: ${n?e.activeBorderWidth||0:e.inactiveBorderWidth||0}px !important;\n ${Hs(n?e.activeDropShadow:e.inactiveDropShadow)};\n border-style: solid;\n ${Is(a)}\n }\n `)}},{key:"render",value:function(){return this.tabIndex=0,this.component.components.map(e=>Iu(this.contextProvider,e,this.scaleFactor,this.inFocusedState,this.minSDKVersion))}}])}();Ae([ot({type:Object})],_O.prototype,"component",void 0),Ae([ot({type:Boolean})],_O.prototype,"inFocusedState",void 0),Ae([ot({type:Number})],_O.prototype,"scaleFactor",void 0),Ae([ot({type:Object})],_O.prototype,"minSDKVersion",void 0),Ae([ot({type:Boolean})],_O.prototype,"isActive",void 0),_O=Ae([Fe("nami-toggle-button")],_O);var RO,FO,OO,WO,$O,NO,jO,BO,zO,UO,HO=e=>e,GO=(RO=function(){function i(){var e;return u(this,i),(e=s(this,i,arguments)).inFocusedState=!1,e.scaleFactor=1,e.timer=null,e.startTime=0,e.initialDuration=0,e.hasEmittedCompletion=!1,e}return y(i,bs),m(i,[{key:"firstUpdated",value:function(){this.loadTimerState(),this.startTimer()}},{key:"disconnectedCallback",value:function(){M(i,"disconnectedCallback",this)([]),this.saveTimerState(),this.clearTimer()}},{key:"getTimerId",value:function(){var e,t;return null!==(e=null===(t=this.component)||void 0===t?void 0:t.id)&&void 0!==e?e:""}},{key:"loadTimerState",value:function(){var e;null!==(e=this.contextProvider)&&void 0!==e&&e.flow&&(this.timerState=this.contextProvider.flow.timerStates[this.getTimerId()])}},{key:"saveTimerState",value:function(){var e;if(null!==(e=this.contextProvider)&&void 0!==e&&e.flow){var t=this.component,i=t.mode,n=t.durationSeconds;if("duration"===i&&void 0!==n){var a=this.calculateCurrentRemainingSeconds();this.contextProvider.flow.timerStates[this.getTimerId()]={remainingSeconds:a,savedAt:Date.now(),hasEmittedCompletion:this.hasEmittedCompletion}}}}},{key:"getSavedTimerState",value:function(){var e;return null===(e=this.contextProvider)||void 0===e||null===(e=e.flow)||void 0===e?void 0:e.timerStates[this.getTimerId()]}},{key:"startTimer",value:function(){this.initializeTimerState(),this.clearTimer(),this.timer=setInterval(()=>this.onTimerTick(),UO.TIMER_INTERVAL_MS)}},{key:"initializeTimerState",value:function(){var e=this.component,t=e.mode,i=e.durationSeconds,n=e.resetOnRemount;"duration"===t&&void 0!==i&&(this.timerState&&!n?this.restoreTimerFromState(this.timerState,i):this.resetTimerState(i))}},{key:"restoreTimerFromState",value:function(e,t){var i=(Date.now()-e.savedAt)/1e3,n=Math.max(0,e.remainingSeconds-i);this.initialDuration=t,this.startTime=Date.now()-1e3*(this.initialDuration-n),this.hasEmittedCompletion=e.hasEmittedCompletion}},{key:"resetTimerState",value:function(e){this.initialDuration=e,this.startTime=Date.now(),this.hasEmittedCompletion=!1}},{key:"onTimerTick",value:function(){var e=this.calculateTimeValues().isCompleted;this.requestUpdate(),e&&this.clearTimer()}},{key:"clearTimer",value:function(){this.timer&&(clearInterval(this.timer),this.timer=null)}},{key:"calculateTimeValues",value:function(){var e=this.calculateTotalRemainingSeconds(),t=e<=0,i=this.component.units||UO.DEFAULT_UNITS,n=i.days,a=i.hours,r=i.minutes,o=i.seconds;return v({},this.convertSecondsToTimeUnits(e,{days:n,hours:a,minutes:r,seconds:o}),{isCompleted:t})}},{key:"calculateTotalRemainingSeconds",value:function(){var e=this.component,t=e.mode,i=e.durationSeconds,n=e.targetDateTime;return"duration"===t?this.calculateDurationRemainingSeconds(i):"targetDateTime"===t&&n?this.calculateTargetDateTimeRemainingSeconds(n):0}},{key:"calculateDurationRemainingSeconds",value:function(e){var t=this.getSavedTimerState();if(t){var i=(Date.now()-t.savedAt)/1e3;return Math.max(0,t.remainingSeconds-i)}if(this.initialDuration>0&&this.startTime>0){var n=(Date.now()-this.startTime)/1e3;return Math.max(0,this.initialDuration-n)}return void 0!==e?Math.max(0,e):0}},{key:"calculateTargetDateTimeRemainingSeconds",value:function(e){var t=new Date(e).getTime(),i=Date.now();return Math.max(0,(t-i)/1e3)}},{key:"calculateCurrentRemainingSeconds",value:function(){var e=this.component.durationSeconds;if(this.initialDuration>0&&this.startTime>0){var t=(Date.now()-this.startTime)/1e3;return Math.max(0,this.initialDuration-t)}return null!=e?e:0}},{key:"convertSecondsToTimeUnits",value:function(e,t){var i=t.days?Math.floor(e/UO.SECONDS_PER_DAY):0,n=e-i*UO.SECONDS_PER_DAY,a=t.hours?Math.floor(n/UO.SECONDS_PER_HOUR):0,r=n-a*UO.SECONDS_PER_HOUR,o=t.minutes?Math.floor(r/UO.SECONDS_PER_MINUTE):0,s=r-o*UO.SECONDS_PER_MINUTE;return{days:i,hours:a,minutes:o,seconds:t.seconds?Math.floor(s):0}}},{key:"formatValue",value:function(e,t){return t?e.toString().padStart(2,"0"):e.toString()}},{key:"emitCompletionEvent",value:function(){!this.hasEmittedCompletion&&this.contextProvider&&(this.hasEmittedCompletion=!0,e.NamiEventEmitter.getInstance().emit(e.PAYWALL_ACTION_EVENT,v({},this.contextProvider.getPaywallActionEventData(),{action:e.NamiPaywallAction.COUNTDOWN_TIMER_COMPLETED,componentChange:{id:this.component.id,name:this.component.title}})))}},{key:"updated",value:function(e){this.updateAccessibilityAttributes(),e.has("component")&&this.handleComponentChange(e.get("component"))}},{key:"updateAccessibilityAttributes",value:function(){this.ariaLabel=this.component.screenreaderText||"",this.ariaDescription=this.component.screenreaderHint||""}},{key:"handleComponentChange",value:function(e){if(e){var t=this.component,i=t.mode,n=t.durationSeconds,a=t.targetDateTime;(i!==e.mode||n!==e.durationSeconds||a!==e.targetDateTime)&&this.startTimer()}}},{key:"styles",value:function(){var e=this.component,i=e.labels,n=e.separator,a=e.labelPosition,r=void 0===a?"none":a,o=e.direction,s=void 0===o?"horizontal":o,u=e.labelFontSize,l=e.labelFontColor,d=e.labelFontName,h=e.labelSpacing,c=e.spacing,m=e.fontSize,f=e.fontColor,v=e.fontName,p=e.alignment,g="below"===r?"bottom":"above"===r?"top":r,y="vertical"===s,b=i&&(i.days||i.hours||i.minutes||i.seconds)||"none"!==g;return t.unsafeCSS(`\n :host {\n box-sizing: border-box;\n display: ${e.hidden?"none":"flex"};\n position: relative;\n cursor: pointer;\n height: 100%;\n border-radius: ${e.borderRadius||0}px !important;\n flex-direction: ${y?"column":"row"};\n align-items: center;\n justify-content: flex-start;\n ${Rs(e,this.inFocusedState)}\n ${Ns(e,this.scaleFactor)}\n ${Bs(e,this.scaleFactor,this.inFocusedState)}\n ${Os(e)}\n ${zs(e,this.scaleFactor)}\n }\n .timer-text {\n display: flex;\n flex-direction: ${y?"column":"row"};\n align-items: center;\n gap: ${y?c?c*this.scaleFactor:4:0}px;\n }\n .timer-unit {\n display: flex;\n flex-direction: ${"top"===g||"bottom"===g?"column":"row"};\n align-items: center;\n ${y?`margin-top: ${c?c*this.scaleFactor:4}px;`:`margin-right: ${c?c*this.scaleFactor:4}px;`} \n }\n .timer-text-value-days,\n .timer-text-value-hours,\n .timer-text-value-minutes,\n .timer-text-value-seconds {\n ${m?`font-size: ${m*this.scaleFactor}px;`:""}\n ${f?_s(f):""}\n ${Vs(v)}\n ${p?`text-align: ${p};`:""}\n ${Hs(e.dropShadow,!0)}\n line-height: 1;\n }\n .timer-text-value-label {\n font-size: ${u?u*this.scaleFactor:12*this.scaleFactor}px;\n color: ${l||"inherit"};\n ${Vs(d)}\n ${"top"===g?`margin-bottom: ${h?h*this.scaleFactor:2}px;`:""}\n ${"bottom"===g?`margin-top: ${h?h*this.scaleFactor:2}px;`:""}\n ${b?"":"display: none;"}\n }\n .timer-text-value-separator {\n ${n?`\n display: flex;\n align-items: center;\n ${m?`font-size: ${m*this.scaleFactor}px;`:""}\n ${f?_s(f):""}\n ${Vs(v)}\n line-height: 1;\n ${y?`margin-top: ${c?c*this.scaleFactor:4}px;`:`margin-right: ${c?c*this.scaleFactor:4}px;`} \n ${"bottom"===g||"top"===g?"align-self: flex-start;":""}\n `:"display: none;"}\n }\n `)}},{key:"render",value:function(){this.tabIndex=0;var e=this.component.showWhenCompleted,i=void 0===e?"zero":e,n=this.calculateTimeValues();if(n.isCompleted&&(this.emitCompletionEvent(),"hidden"===i))return t.html(FO||(FO=HO``));var a=this.buildUnitsToRender(n);return 0===a.length?t.html(OO||(OO=HO`<div class="timer-text"></div>`)):this.renderTimerUnits(a)}},{key:"buildUnitsToRender",value:function(e){var t=this.component,i=t.labels,n=t.units,a=t.labelPosition,r=void 0===a?"none":a,o=n||{},s=o.days,u=o.hours,l=o.minutes,d=o.seconds,h=this.normalizeLabelPosition(r),c=this.shouldDisplayLabels(i,h);return[{enabled:s,value:e.days,label:this.getLabel("days",i,c),class:"timer-text-value-days"},{enabled:u,value:e.hours,label:this.getLabel("hours",i,c),class:"timer-text-value-hours"},{enabled:l,value:e.minutes,label:this.getLabel("minutes",i,c),class:"timer-text-value-minutes"},{enabled:d,value:e.seconds,label:this.getLabel("seconds",i,c),class:"timer-text-value-seconds"}].filter(e=>e.enabled).map(e=>({value:e.value,label:e.label,unitClass:e.class,showUnit:!0}))}},{key:"normalizeLabelPosition",value:function(e){return"below"===e?"bottom":"above"===e?"top":e}},{key:"shouldDisplayLabels",value:function(e,t){return Boolean(e&&(e.days||e.hours||e.minutes||e.seconds))||"none"!==t&&void 0!==t}},{key:"getLabel",value:function(e,t,i){var n;return null!==(n=null==t?void 0:t[e])&&void 0!==n?n:i?UO.DEFAULT_LABELS[e]:""}},{key:"renderTimerUnits",value:function(e){var i=this.component,n=i.separator,a=i.zeroPad,r=void 0===a||a,o=i.labelPosition,s=void 0===o?"none":o,u=this.component.labels,l=this.normalizeLabelPosition(s),d=u&&(u.days||u.hours||u.minutes||u.seconds),h=Boolean(d||"none"!==l),c=null!=n?n:":";return t.html(WO||(WO=HO`
|
|
577
577
|
<div class="timer-text">
|
|
578
578
|
${0}
|
|
579
579
|
</div>
|
|
580
|
-
`),e.map((i,n)=>t.html(
|
|
580
|
+
`),e.map((i,n)=>t.html($O||($O=HO`
|
|
581
581
|
${0}
|
|
582
582
|
${0}
|
|
583
|
-
`),this.renderUnit(i.value,i.label,i.unitClass,i.showUnit,r,l,h),n<e.length-1&&c?t.html(
|
|
583
|
+
`),this.renderUnit(i.value,i.label,i.unitClass,i.showUnit,r,l,h),n<e.length-1&&c?t.html(NO||(NO=HO`<span class="timer-text-value-separator">${0}</span>`),c):"")))}},{key:"renderUnit",value:function(e,i,n,a,r,o,s){if(!a)return null;var u=Boolean(i&&s);return t.html(jO||(jO=HO`
|
|
584
584
|
<div class="timer-unit">
|
|
585
585
|
${0}
|
|
586
586
|
<span class="${0}">${0}</span>
|
|
587
587
|
${0}
|
|
588
588
|
</div>
|
|
589
|
-
`),u&&"top"===o?t.html(
|
|
589
|
+
`),u&&"top"===o?t.html(BO||(BO=HO`<span class="timer-text-value-label">${0}</span>`),i):"",n,this.formatValue(e,r),u&&"bottom"===o?t.html(zO||(zO=HO`<span class="timer-text-value-label">${0}</span>`),i):"")}}])}(),UO=RO,RO.DEFAULT_LABELS={days:"days",hours:"hours",minutes:"minutes",seconds:"seconds"},RO.DEFAULT_UNITS={days:!1,hours:!0,minutes:!0,seconds:!0},RO.SECONDS_PER_DAY=86400,RO.SECONDS_PER_HOUR=3600,RO.SECONDS_PER_MINUTE=60,RO.TIMER_INTERVAL_MS=1e3,RO);Ae([ot({type:Object})],GO.prototype,"component",void 0),Ae([ot({type:Boolean})],GO.prototype,"inFocusedState",void 0),Ae([ot({type:Number})],GO.prototype,"scaleFactor",void 0),Ae([ot({type:Object})],GO.prototype,"minSDKVersion",void 0),GO=UO=Ae([Fe("nami-countdown-timer-text")],GO);var VO,KO=e=>e,XO=e._internal.NamiFlowManager,YO=function(){function i(){var e;return u(this,i),(e=s(this,i,arguments)).scaleFactor=1,e.inFocusedState=!1,e.currentProgress=0,e.isAnimating=!1,e.screenreaderAnnouncement="",e.hasInitialized=!1,e.delayTimeoutId=null,e.animationFrameId=null,e.animationStartTime=null,e.startPercentage=0,e}return y(i,bs),m(i,[{key:"connectedCallback",value:function(){M(i,"connectedCallback",this)([]),e.validateMinSDKVersion(this.minSDKVersion,"ProgressBar")}},{key:"disconnectedCallback",value:function(){M(i,"disconnectedCallback",this)([]),this.cleanup()}},{key:"firstUpdated",value:function(e){M(i,"firstUpdated",this)([e]),this.hasInitialized=!0,this.startAnimation()}},{key:"updated",value:function(e){M(i,"updated",this)([e]),this.hasInitialized&&e.has("component")&&(this.cleanup(),this.startAnimation())}},{key:"cleanup",value:function(){null!==this.delayTimeoutId&&(clearTimeout(this.delayTimeoutId),this.delayTimeoutId=null),null!==this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.animationStartTime=null,this.isAnimating=!1}},{key:"getResolvedDuration",value:function(){var e=this.component,t=e.duration,i=e.mode;if("auto"===t&&"determinate"===i){var n=XO.getCurrentFlowStepAutoAdvanceDelay();return null!=n?n:3}return"number"==typeof t&&t>0?t:"determinate"===i?3:2}},{key:"startAnimation",value:function(){var e=this.component,t=e.mode,i=e.delay,n=e.percentage,a=void 0===n?0:n,r="number"==typeof a&&!Number.isInteger(a);this.startPercentage="number"==typeof a?r?100*a:a:0,this.currentProgress=this.startPercentage;var o="number"==typeof i&&i>0?1e3*i:0;o>0?this.delayTimeoutId=setTimeout(()=>{this.delayTimeoutId=null,this.beginAnimation(t)},o):this.beginAnimation(t)}},{key:"beginAnimation",value:function(e){this.isAnimating=!0;var t=this.component.screenreaderText||"Loading";this.screenreaderAnnouncement=t,setTimeout(()=>{this.screenreaderAnnouncement=""},1e3),"determinate"===e&&this.animateDeterminate()}},{key:"animateDeterminate",value:function(){if(!this.isAnimating||null===this.animationFrameId){var e=1e3*this.getResolvedDuration(),t=this.startPercentage;this.animationStartTime=null;var i=n=>{null===this.animationStartTime&&(this.animationStartTime=n);var a=n-this.animationStartTime,r=Math.min(1,a/e);this.currentProgress=t+(100-t)*r,r<1?this.animationFrameId=requestAnimationFrame(i):(this.currentProgress=100,this.isAnimating=!1,this.animationFrameId=null,this.animationStartTime=null)};this.animationFrameId=requestAnimationFrame(i)}}},{key:"getActiveWidthCss",value:function(){var e=this.component.activeWidth;return null==e?"30%":"number"==typeof e?`${e}px`:String(e).trim()}},{key:"isActiveWidthPercent",value:function(){var e=this.component.activeWidth;return null==e||"number"!=typeof e&&String(e).endsWith("%")}},{key:"styles",value:function(){var e=this.component,i=this.scaleFactor,n=this.inFocusedState,a=e.mode,r=e.inactiveFillColor,o=e.inactiveFillColorFallback,s=e.inactiveBorderRadius,u=e.activeFillColor,l=e.activeFillColorFallback,d=e.activeBorderRadius,h=e.innerPadding,c=void 0===h?0:h,m=e.activeDropShadow,f=e.inactiveDropShadow,v=this.getActiveWidthCss(),p=this.getResolvedDuration(),g=this.isActiveWidthPercent(),y=g&&parseFloat(v)||30,b=(100-y)/y*100,w=g?0:parseFloat(v)||0;return t.unsafeCSS(`\n :host {\n display: ${e.hidden?"none":"block"};\n ${Ks(e,i,n)}\n }\n \n .progress-container {\n ${zs(e,i)} \n background: ${r||o};\n border-radius: ${s||0}px;\n overflow: hidden;\n position: relative;\n padding: ${c*i}px;\n box-sizing: border-box;\n ${Hs(f)}\n }\n \n .progress-bar {\n height: 100%;\n background: ${u||l};\n border-radius: ${d||0}px;\n box-sizing: border-box;\n ${Hs(m)}\n ${"indeterminate"===a?`\n position: absolute;\n left: 0;\n top: ${c*i}px;\n bottom: ${c*i}px;\n width: ${v};\n animation: slide ${p}s linear infinite;\n `:""}\n }\n\n ${"indeterminate"===a?g?`\n @keyframes slide {\n 0% {\n transform: translateX(-${b}%);\n }\n 100% {\n transform: translateX(${b+100}%);\n }\n }\n `:`\n @keyframes slide {\n 0% {\n left: -${w}px;\n }\n 100% {\n left: 100%;\n }\n }\n `:""}\n\n .sr-only {\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n border: 0;\n }\n `)}},{key:"render",value:function(){var e=this.component.mode;return t.html(VO||(VO=KO`
|
|
590
590
|
<div class="progress-container">
|
|
591
591
|
<div
|
|
592
592
|
class="progress-bar"
|
|
@@ -603,7 +603,7 @@
|
|
|
603
603
|
aria-live="polite"
|
|
604
604
|
aria-atomic="true"
|
|
605
605
|
>${0}</span>
|
|
606
|
-
`),"indeterminate"===e?"":`width: ${this.currentProgress}%`,"indeterminate"===e?void 0:Math.round(this.currentProgress),"indeterminate"===e?void 0:0,"indeterminate"===e?void 0:100,this.isAnimating,this.screenreaderAnnouncement)}}])}();Ae([ot({type:Object})],
|
|
606
|
+
`),"indeterminate"===e?"":`width: ${this.currentProgress}%`,"indeterminate"===e?void 0:Math.round(this.currentProgress),"indeterminate"===e?void 0:0,"indeterminate"===e?void 0:100,this.isAnimating,this.screenreaderAnnouncement)}}])}();Ae([ot({type:Object})],YO.prototype,"component",void 0),Ae([ot({type:Number})],YO.prototype,"scaleFactor",void 0),Ae([ot({type:Boolean})],YO.prototype,"inFocusedState",void 0),Ae([ot({type:Object})],YO.prototype,"minSDKVersion",void 0),Ae([st()],YO.prototype,"currentProgress",void 0),Ae([st()],YO.prototype,"isAnimating",void 0),Ae([st()],YO.prototype,"screenreaderAnnouncement",void 0),YO=Ae([Fe("nami-progress-bar")],YO);var qO,JO,QO=e=>e,ZO=2,eW=6,tW=20,iW=16,nW=16,aW=function(){function i(){var t;return u(this,i),(t=s(this,i)).inFocusedState=!1,t.scaleFactor=1,t._value="",t._focused=!1,t._handleInput=i=>{var n=i.target.value;t._value=n;var a=t.component,r=a.formId,o=a.validateOn;if(t.contextProvider.setFormState(r,n),"change"===o){var s,u=e.validateTextInput(t.validatorType(),!0===t.component.reqed,n);if(u)t.contextProvider.setFormFieldError(r,null!==(s=t.component.validationMessage)&&void 0!==s?s:u);else t.contextProvider.clearFormFieldError(r)}t.requestUpdate()},t._handleFocus=()=>{t._focused=!0,t.requestUpdate()},t._handleBlur=()=>{t._focused=!1,t.requestUpdate()},t}return y(i,bs),m(i,[{key:"connectedCallback",value:function(){var e;M(i,"connectedCallback",this)([]);var t=this.component.formId,n=null===(e=this.contextProvider.state.formStates)||void 0===e?void 0:e[t];this._value="string"==typeof n?n:"",this.contextProvider.setFormState(t,this._value),this.contextProvider.registerFormFieldValidator(t,this.validator())}},{key:"isTelevision",get:function(){return"television"===e.getDeviceFormFactor()}},{key:"validatorType",value:function(){return"email"===this.component.type?"email":"name"}},{key:"validator",value:function(){return{type:this.validatorType(),required:!0===this.component.reqed,message:this.component.validationMessage}}},{key:"currentError",get:function(){return this.contextProvider.getFormFieldErrors()[this.component.formId]}},{key:"styles",value:function(){return t.unsafeCSS(`\n :host {\n box-sizing: border-box;\n display: block;\n ${"100%"===this.component.width?"width: 100%;":""}\n }\n :host .nami-text-input-wrapper {\n display: flex;\n flex-direction: column;\n gap: ${this.resolvedSpacing()}px;\n ${"100%"===this.component.width?"width: 100%;":""}\n }\n :host label {\n ${this.applyLabelStyles()}\n }\n :host input {\n ${this.applyInputStyles()}\n }\n :host input::placeholder {\n ${this.component.placeholderFontColor?`color: ${this.component.placeholderFontColor};`:""}\n }\n :host .nami-text-input-error {\n ${this.applyErrorStyles()}\n }\n `)}},{key:"resolvedSpacing",value:function(){var e=this.component.spacing;return null==e?this.isTelevision?iW:0:Number(e)}},{key:"resolvedBorderWidth",value:function(e){return null==e?this.isTelevision?ZO:0:Number(e)}},{key:"applyLabelStyles",value:function(){var e,t=this.component,i=null!==(e=t.labelFontSize)&&void 0!==e?e:this.isTelevision?tW:void 0;return`\n ${_s(t.labelFontColor||"inherit")}\n ${Vs(t.labelFontName)}\n ${null!=i?`font-size: ${Cs(i,this.scaleFactor)};`:""}\n `}},{key:"applyInputStyles",value:function(){var e,t,i,n,a,r,o,s,u,l,d,h,c=this.component,m=!!this.currentError,f=this._focused,v=c.borderColor||"transparent",p=this.resolvedBorderWidth(c.borderWidth),g=Number(null!==(e=c.borderRadius)&&void 0!==e?e:this.isTelevision?eW:0),y=c.fillColor||"transparent";f&&(v=c.focusedBorderColor||v,p=this.resolvedBorderWidth(null!==(o=c.focusedBorderWidth)&&void 0!==o?o:c.borderWidth),g=Number(null!==(s=null!==(u=c.focusedBorderRadius)&&void 0!==u?u:c.borderRadius)&&void 0!==s?s:g),y=c.focusedFillColor||y);m&&(v=c.errorBorderColor||v,p=this.resolvedBorderWidth(null!==(l=c.errorBorderWidth)&&void 0!==l?l:c.borderWidth),g=Number(null!==(d=null!==(h=c.errorBorderRadius)&&void 0!==h?h:c.borderRadius)&&void 0!==d?d:g));var b=null!==(t=c.fontSize)&&void 0!==t?t:this.isTelevision?tW:void 0,w=null!==(i=c.innerTopPadding)&&void 0!==i?i:this.isTelevision?nW:0,k=null!==(n=c.innerBottomPadding)&&void 0!==n?n:this.isTelevision?nW:0,S=null!==(a=c.innerLeftPadding)&&void 0!==a?a:this.isTelevision?nW:0,E=null!==(r=c.innerRightPadding)&&void 0!==r?r:this.isTelevision?nW:0;return`\n box-sizing: border-box;\n width: 100%;\n outline: none;\n ${_s(c.fontColor||"inherit")}\n ${Vs(c.fontName)}\n ${null!=b?`font-size: ${Cs(b,this.scaleFactor)};`:""}\n ${Is(y)}\n ${Ls(v)}\n border-style: solid;\n border-width: ${p}px !important;\n border-radius: ${g}px !important;\n padding: ${Number(w)}px ${Number(E)}px ${Number(k)}px ${Number(S)}px !important;\n text-align: ${c.alignment||"left"};\n `}},{key:"applyErrorStyles",value:function(){var e,t=this.component,i=null!==(e=t.validationTextFontSize)&&void 0!==e?e:this.isTelevision?tW:void 0;return`\n ${_s(t.validationTextFontColor||"#D83A58")}\n ${Vs(t.validationTextFontName)}\n ${null!=i?`font-size: ${Cs(i,this.scaleFactor)};`:""}\n `}},{key:"render",value:function(){var e,i,n,a,r=this.component,o=`nami-text-input-${r.formId}`,s=this.currentError,u="none"!==r.labelPosition&&!!r.labelText,l=!0===r.reqed?`${r.labelText} *`:r.labelText,d="email"===r.type?"email":"text",h="email"===r.type?"email":"text";return t.html(qO||(qO=QO`
|
|
607
607
|
<div class="nami-text-input-wrapper">
|
|
608
608
|
${0}
|
|
609
609
|
<input
|
|
@@ -626,4 +626,4 @@
|
|
|
626
626
|
aria-live="polite"
|
|
627
627
|
>${0}</div>
|
|
628
628
|
</div>
|
|
629
|
-
`),u?t.html(
|
|
629
|
+
`),u?t.html(JO||(JO=QO`<label for=${0}>${0}</label>`),o,l):t.nothing,o,d,h,this._value,null!==(e=r.placeholderText)&&void 0!==e?e:"",null!==(i=null!==(n=r.screenreaderText)&&void 0!==n?n:l)&&void 0!==i?i:t.nothing,null!==(a=r.screenreaderHint)&&void 0!==a?a:t.nothing,s?"true":t.nothing,s?`${o}-error`:t.nothing,this._handleInput,this._handleFocus,this._handleBlur,`${o}-error`,null!=s?s:"")}}])}();Ae([ot({type:Object})],aW.prototype,"component",void 0),Ae([ot({type:Boolean})],aW.prototype,"inFocusedState",void 0),Ae([ot({type:Number})],aW.prototype,"scaleFactor",void 0),aW=Ae([Fe("nami-text-input")],aW),Object.defineProperty(exports,"LaunchCampaignError",{enumerable:!0,get:function(){return e.LaunchCampaignError}}),Object.defineProperty(exports,"LogLevel",{enumerable:!0,get:function(){return e.LogLevel}}),Object.defineProperty(exports,"Nami",{enumerable:!0,get:function(){return e.Nami}}),Object.defineProperty(exports,"NamiCampaignManager",{enumerable:!0,get:function(){return e.NamiCampaignManager}}),Object.defineProperty(exports,"NamiCampaignRuleType",{enumerable:!0,get:function(){return e.NamiCampaignRuleType}}),Object.defineProperty(exports,"NamiCustomerManager",{enumerable:!0,get:function(){return e.NamiCustomerManager}}),Object.defineProperty(exports,"NamiEntitlementManager",{enumerable:!0,get:function(){return e.NamiEntitlementManager}}),Object.defineProperty(exports,"NamiFlowManager",{enumerable:!0,get:function(){return e.NamiFlowManager}}),Object.defineProperty(exports,"NamiHandoffTag",{enumerable:!0,get:function(){return e.NamiHandoffTag}}),Object.defineProperty(exports,"NamiPaywallAction",{enumerable:!0,get:function(){return e.NamiPaywallAction}}),Object.defineProperty(exports,"NamiPaywallManager",{enumerable:!0,get:function(){return e.NamiPaywallManager}}),Object.defineProperty(exports,"NamiPaywallManagerEvents",{enumerable:!0,get:function(){return e.NamiPaywallManagerEvents}}),Object.defineProperty(exports,"NamiPermissionOutcome",{enumerable:!0,get:function(){return e.NamiPermissionOutcome}}),Object.defineProperty(exports,"NamiPurchaseManager",{enumerable:!0,get:function(){return e.NamiPurchaseManager}}),Object.defineProperty(exports,"_internal",{enumerable:!0,get:function(){return e._internal}}),Object.defineProperty(exports,"isNamiFlowCampaign",{enumerable:!0,get:function(){return e.isNamiFlowCampaign}});
|