PageSourceSearch

https://cursor.com/marketing-static/_next/static/chunks/0o.h1-3825zax.js?dpl=dpl_sKR9XmvGCHNUAEHcqzaift4tiXUF

js cursor.com collected 2026-10-09 21:36:10 UTC 835,610 bytes, 1,451 lines download raw bytes

1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,35305,(e,t,i)=>{"use strict";t.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},561227,(e,t,i)=>{"use strict";var r=e.r(35305);function s(){}function a(){}a.resetWarningCache=s,t.exports=function(){function e(e,t,i,s,a,n){if(n!==r){var l=Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw l.name="Invariant Violation",l}}function t(){return e}e.isRequired=e;var i={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:a,resetWarningCache:s};return i.PropTypes=i,i}},304153,(e,t,i)=>{t.exports=e.r(561227)()},180185,e=>{"use strict";let t,i,r;var s,a,n,l,o,d,h,u,c,f,m,g,v,E,y,b,T,_,A,S,k,L,R,I,w,D,C,P,x,M,O,N,U,F,$,B,H,G,V,K,W,q,j,Y,Q,z,X,Z,J,ee,et,ei,er,es,ea,en,el,eo,ed,eh,eu,ec,ef,em,ep,eg,ev,eE,ey,eb,eT,e_,eA,eS,ek,eL,eR,eI,ew,eD,eC,eP,ex,eM,eO,eN,eU,eF,e$,eB,eH,eG,eV,eK,eW,eq,ej,eY,eQ,ez,eX,eZ,eJ,e0,e1,e2,e3,e4,e5,e8,e6,e9,e7,te,tt,ti,tr,ts,ta,tn,tl,to,td,th,tu,tc,tf,tm,tp,tg,tv,tE,ty,tb,tT,t_,tA,tS,tk,tL,tR,tI,tw,tD,tC,tP,tx,tM,tO,tN,tU,tF=e.i(505278),t$=e.i(207849),tB=e.i(612793),tH=e.i(304153),tG=Object.create,tV=Object.defineProperty,tK=Object.getOwnPropertyDescriptor,tW=Object.getOwnPropertyNames,tq=Object.getPrototypeOf,tj=Object.prototype.hasOwnProperty,tY=function(e,t){return function(){return e&&(t=e(e=0)),t}},tQ=function(e,t){return function(){return t||e((t={exports:{}}).exports,t),t.exports}},tz=function(e,t,i,r){if(t&&"object"==typeof t||"function"==typeof t)for(var s,a=tW(t),n=0,l=a.length;n<l;n++)s=a[n],tj.call(e,s)||s===i||tV(e,s,{get:(function(e){return t[e]}).bind(null,s),enumerable:!(r=tK(t,s))||r.enumerable});return e},tX=function(e,t,i){return i=null!=e?tG(tq(e)):{},tz(!t&&e&&e.__esModule?i:tV(i,"default",{value:e,enumerable:!0}),e)},tZ=tQ(function(t,i){i.exports="u">typeof window?window:e.g});function tJ(e,t){return null!=t&&"u">typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):tJ(e,t)}var t0=tY(function(){t0()});function t1(e){return e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}var t2=tY(function(){}),t3=tQ(function(e,t){var i=Array.prototype.slice;t.exports=function(e,t){for(("length"in e)||(e=[e]),e=i.call(e);e.length;){var r=e.shift(),s=t(r);if(s)return s;r.childNodes&&r.childNodes.length&&(e=i.call(r.childNodes).concat(e))}}}),t4=tQ(function(e,t){function i(e,t){if(!tJ(this,i))return new i(e,t);this.data=e,this.nodeValue=e,this.length=e.length,this.ownerDocument=t||null}t0(),t.exports=i,i.prototype.nodeType=8,i.prototype.nodeName="#comment",i.prototype.toString=function(){return"[object Comment]"}}),t5=tQ(function(e,t){function i(e,t){if(!tJ(this,i))return new i(e);this.data=e||"",this.length=this.data.length,this.ownerDocument=t||null}t0(),t.exports=i,i.prototype.type="DOMTextNode",i.prototype.nodeType=3,i.prototype.nodeName="#text",i.prototype.toString=function(){return this.data},i.prototype.replaceData=function(e,t,i){var r=this.data,s=r.substring(0,e),a=r.substring(e+t,r.length);this.data=s+i+a,this.length=this.data.length}}),t8=tQ(function(e,t){t.exports=function(e){var t=this,i=e.type;e.target||(e.target=t),t.listeners||(t.listeners={});var r=t.listeners[i];if(r)return r.forEach(function(i){e.currentTarget=t,"function"==typeof i?i(e):i.handleEvent(e)});t.parentNode&&t.parentNode.dispatchEvent(e)}}),t6=tQ(function(e,t){t.exports=function(e,t){this.listeners||(this.listeners={}),this.listeners[e]||(this.listeners[e]=[]),-1===this.listeners[e].indexOf(t)&&this.listeners[e].push(t)}}),t9=tQ(function(e,t){t.exports=function(e,t){if(this.listeners&&this.listeners[e]){var i=this.listeners[e],r=i.indexOf(t);-1!==r&&i.splice(r,1)}}}),t7=tQ(function(e,t){t2(),t.exports=function e(t){switch(t.nodeType){case 3:return s(t.data);case 8:return"<!--"+t.data+"-->";default:var a,n,l;return n=[],l=(a=t).tagName,"http://www.w3.org/1999/xhtml"===a.namespaceURI&&(l=l.toLowerCase()),n.push("<"+l+function(e){var t=[];for(var i in e)(function(e,t){var i=t1(e[t]);return"style"===t&&Object.keys(e.style).length>0||e.hasOwnProperty(t)&&("string"===i||"boolean"===i||"number"===i)&&"nodeName"!==t&&"className"!==t&&"tagName"!==t&&"textContent"!==t&&"innerText"!==t&&"namespaceURI"!==t&&"innerHTML"!==t}
1)(e,i)&&t.push({name:i,value:e[i]});for(var s in e._attributes)for(var a in e._attributes[s]){var n=e._attributes[s][a],l=(n.prefix?n.prefix+":":"")+a;t.push({name:l,value:n.value})}return e.className&&t.push({name:"class",value:e.className}),t.length?r(t):""}(a)+function(e){var t=e.dataset,i=[];for(var s in t)i.push({name:"data-"+s,value:t[s]});return i.length?r(i):""}(a)),i.indexOf(l)>-1?n.push(" />"):(n.push(">"),a.childNodes.length?n.push.apply(n,a.childNodes.map(e)):a.textContent||a.innerText?n.push(s(a.textContent||a.innerText)):a.innerHTML&&n.push(a.innerHTML),n.push("</"+l+">")),n.join("")}};var i=["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"];function r(e){var t=[];return e.forEach(function(e){var i=e.name,r=e.value;"style"===i&&(r=function(e){if("string"==typeof e)return e;var t="";return Object.keys(e).forEach(function(i){var r=e[i];i=i.replace(/[A-Z]/g,function(e){return"-"+e.toLowerCase()}),t+=i+":"+r+";"}),t}(r)),t.push(i+'="'+s(r).replace(/"/g,"&quot;")+'"')}),t.length?" "+t.join(" "):""}function s(e){var t="";return"string"==typeof e?t=e:e&&(t=e.toString()),t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}}),ie=tQ(function(e,t){t0();var i=t3(),r=t8(),s=t6(),a=t9(),n=t7(),l="http://www.w3.org/1999/xhtml";function o(e,t,i){if(!tJ(this,o))return new o(e);var r=void 0===i?l:i||null;this.tagName=r===l?String(e).toUpperCase():e,this.nodeName=this.tagName,this.className="",this.dataset={},this.childNodes=[],this.parentNode=null,this.style={},this.ownerDocument=t||null,this.namespaceURI=r,this._attributes={},"INPUT"===this.tagName&&(this.type="text")}t.exports=o,o.prototype.type="DOMElement",o.prototype.nodeType=1,o.prototype.appendChild=function(e){return e.parentNode&&e.parentNode.removeChild(e),this.childNodes.push(e),e.parentNode=this,e},o.prototype.replaceChild=function(e,t){e.parentNode&&e.parentNode.removeChild(e);var i=this.childNodes.indexOf(t);return t.parentNode=null,this.childNodes[i]=e,e.parentNode=this,t},o.prototype.removeChild=function(e){var t=this.childNodes.indexOf(e);return this.childNodes.splice(t,1),e.parentNode=null,e},o.prototype.insertBefore=function(e,t){e.parentNode&&e.parentNode.removeChild(e);var i=null==t?-1:this.childNodes.indexOf(t);return i>-1?this.childNodes.splice(i,0,e):this.childNodes.push(e),e.parentNode=this,e},o.prototype.setAttributeNS=function(e,t,i){var r=null,s=t,a=t.indexOf(":");(a>-1&&(r=t.substr(0,a),s=t.substr(a+1)),"INPUT"===this.tagName&&"type"===t)?this.type=i:(this._attributes[e]||(this._attributes[e]={}))[s]={value:i,prefix:r}},o.prototype.getAttributeNS=function(e,t){var i=this._attributes[e],r=i&&i[t]&&i[t].value;return"INPUT"===this.tagName&&"type"===t?this.type:"string"!=typeof r?null:r},o.prototype.removeAttributeNS=function(e,t){var i=this._attributes[e];i&&delete i[t]},o.prototype.hasAttributeNS=function(e,t){var i=this._attributes[e];return!!i&&t in i},o.prototype.setAttribute=function(e,t){return this.setAttributeNS(null,e,t)},o.prototype.getAttribute=function(e){return this.getAttributeNS(null,e)},o.prototype.removeAttribute=function(e){return this.removeAttributeNS(null,e)},o.prototype.hasAttribute=function(e){return this.hasAttributeNS(null,e)},o.prototype.removeEventListener=a,o.prototype.addEventListener=s,o.prototype.dispatchEvent=r,o.prototype.focus=function(){},o.prototype.toString=function(){return n(this)},o.prototype.getElementsByClassName=function(e){var t=e.split(" "),r=[];return i(this,function(e){if(1===e.nodeType){var i=(e.className||"").split(" ");t.every(function(e){return -1!==i.indexOf(e)})&&r.push(e)}}),r},o.prototype.getElementsByTagName=function(e){e=e.toLowerCase();var t=[];return i(this.childNodes,function(i){1===i.nodeType&&("*"===e||i.tagName.toLowerCase()===e)&&t.push(i)}),t},o.prototype.contains=function(e){return i(this,function(t){return e===t})||!1}}),it=tQ(function(e,t){t0();var i=ie();function r(e){if(!tJ(this,r))return new r;this.childNodes=[],this.parentNode=null,this.ownerDocument=e||null}t.exports=r,r.prototype.type="DocumentFragment",r.prototype.nodeType=11,r.prototype.nodeName="#document-fragment",r.prototype.appendChild=i.prototype.appendChild,r.prototype.replaceChild=i.prototype.replaceChild,r.prototype.removeChild=i.prototype.removeChild,r.prototype.toString=function(){return this.childNodes.map(function(e){return String(e)}).join("")}}),ii=tQ(function(e,t){function i(e){}t.exports=i,i.prototype.initEvent=function(e,t,i){this.type=e,this.bubbles=t,this.cancelable=i},i.prototype.preventDefault=function(){}}),ir=tQ(function(e,t){t0();var i=t3(),r=t4(),s=t5(),a=ie(),n=it(),l=ii(),o=t8(),d=t6(),h=t9();function u(){if(!tJ(this,u))return new u;this.head=this.createElement("head"),this.body=this.createElement("body"),this.documentElement=this.createElement("html"),this.documentElement.appendChild(this.head),this.documentElement.appendChild(this.body),this.childNodes=[this.documentElement],this.nodeType=9}t.exports=u;var c=u.prototype;c.createTextNode=function(e){return new s(e,this)},c.createElementNS=function(e,t){return new a(t,this,null===e?null:String(e))},c.createElement=function(e){return new a(e,this)},c.createDocumentFragment=function(){return new n(this)},c.createEvent=function(e){return new l(e)},c.createComment=function(e){return new r(e,this)},c.getElementById=function(e){return e=String(e),i(this.childNodes,function(t){if(String(t.id)===e)return t})||null},c.getElementsByClassName=a.prototype.getElementsByClassName,c.getElementsByTagName=a.prototype.getElementsByTagName,c.contains=a.prototype.contains,c.removeEventListener=h,c.addEventListener=d,c.dispatchEvent=o}),is=tQ(function(e,t){t.exports=new(ir())}),ia=tQ(function(t,i){var r,s=e.g,a=is();"u">typeof document?r=document:(r=s["__GLOBAL_DOCUMENT_CACHE@4"])||(r=s["__GLOBAL_DOCUMENT_CACHE@4"]=a),i.exports=r});function il(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,r=Array(t);i<t;i++)r[i]=e[i];return r}function io(e,t){if(e){if("string"==typeof e)return il(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);if("Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i)return Array.from(i);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return il(e,t)}}function id(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var i=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var r,s,a=[],n=!0,l=!1;try{for(i=i.call(e);!(n=(r=i.next()).done)&&(a.push(r.value),!(t&&a.length===t));n=!0);}catch(e){l=!0,s=e}finally{try{n||null==i.return||i.return()}finally{if(l)throw s}}return a}}(e,t)||io(e,t)||function(){throw TypeError("Invalid attempt to de
1structure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var ih=tX(tZ()),iu=tX(tZ()),ic=tX(tZ()),im=function(){var e=ic.default.performance,t=e&&e.timing,i=t&&t.navigationStart;return Math.round("number"==typeof i&&"function"==typeof e.now?i+e.now():Date.now())},ip=function(){if("function"==typeof(null==(e=iu.default.crypto)?void 0:e.getRandomValues)){i=new Uint8Array(32),iu.default.crypto.getRandomValues(i);for(var e,t,i,r=0;r<32;r++)i[r]=i[r]%16}else{i=[];for(var s=0;s<32;s++)i[s]=16*Math.random()|0}var a=0;t="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t="x"===e?i[a]:3&i[a]|8;return a++,t.toString(16)});var n=im(),l=null==n?void 0:n.toString(16).substring(3);return l?t.substring(0,28)+l:t},ig=function(){return("000000"+(0x81bf1000*Math.random()|0).toString(36)).slice(-6)},iv=function(e){var t;if(e&&void 0!==e.nodeName)return e.muxId||(e.muxId=ig()),e.muxId;try{t=document.querySelector(e)}catch(e){}return t&&!t.muxId&&(t.muxId=e),(null==t?void 0:t.muxId)||e},iE=function(e){e&&void 0!==e.nodeName?e=iv(t=e):t=document.querySelector(e);var t,i=t&&t.nodeName?t.nodeName.toLowerCase():"";return[t,e,i]};function iy(e){return function(e){if(Array.isArray(e))return il(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||io(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var ib=function(e){var t,i,r,s,a,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,l=e?[console,e]:[console],o=(t=console.trace).bind.apply(t,iy(l)),d=(i=console.info).bind.apply(i,iy(l)),h=(r=console.debug).bind.apply(r,iy(l)),u=(s=console.warn).bind.apply(s,iy(l)),c=(a=console.error).bind.apply(a,iy(l)),f=n;return{trace:function(){for(var e=arguments.length,t=Array(e),i=0;i<e;i++)t[i]=arguments[i];if(!(f>0))return o.apply(void 0,iy(t))},debug:function(){for(var e=arguments.length,t=Array(e),i=0;i<e;i++)t[i]=arguments[i];if(!(f>1))return h.apply(void 0,iy(t))},info:function(){for(var e=arguments.length,t=Array(e),i=0;i<e;i++)t[i]=arguments[i];if(!(f>2))return d.apply(void 0,iy(t))},warn:function(){for(var e=arguments.length,t=Array(e),i=0;i<e;i++)t[i]=arguments[i];if(!(f>3))return u.apply(void 0,iy(t))},error:function(){for(var e=arguments.length,t=Array(e),i=0;i<e;i++)t[i]=arguments[i];if(!(f>4))return c.apply(void 0,iy(t))},get level(){return f},set level(p){p!==this.level&&(f=null!=p?p:n)}}}("[mux]"),iT=tX(tZ());function i_(){return"1"===(iT.default.doNotTrack||iT.default.navigator&&iT.default.navigator.doNotTrack)}function iA(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function iS(e,t){if(!tJ(e,t))throw TypeError("Cannot call a class as a function")}function ik(e,t){for(var i=0;i<t.length;i++){var r=t[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function iL(e,t,i){return t&&ik(e.prototype,t),i&&ik(e,i),e}function iR(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function iI(e){return(iI=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function iw(e,t,i){return(iw="u">typeof Reflect&&Reflect.get?Reflect.get:function(e,t,i){var r=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=iI(e)););return e}(e,t);if(r){var s=Object.getOwnPropertyDescriptor(r,t);return s.get?s.get.call(i||e):s.value}})(e,t,i||e)}function iD(e,t){return(iD=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}t0(),t2();var iC=function(e){return iP(e)[0]},iP=function(e){if("string"!=typeof e||""===e)return["localhost"];var t,i=(e.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/)||[])[4];return i&&(t=(i.match(/[^\.]+\.[^\.]+$/)||[])[0]),[i,t]},ix=tX(tZ()),iM=function(){var e=ix.default.performance;return void 0!==(e&&e.timing)}
1,iO=function(){var e=ix.default.performance,t=e&&e.timing;return t&&t.domContentLoadedEventEnd},iN=function(){var e=ix.default.performance,t=e&&e.timing;return t&&t.navigationStart};function iU(e,t,i){i=void 0===i?1:i,e[t]=e[t]||0,e[t]+=i}function iF(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{},r=Object.keys(i);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(i).filter(function(e){return Object.getOwnPropertyDescriptor(i,e).enumerable}))),r.forEach(function(t){iR(e,t,i[t])})}return e}function i$(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t.push.apply(t,i)}return t})(Object(t)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(t,i))}),e}var iB=["x-request-id","cf-ray","x-amz-cf-id","x-akamai-request-id"],iH=["x-cdn","content-type"].concat(iB);function iG(e){var t={};return(e=e||"").trim().split(/[\r\n]+/).forEach(function(e){if(e){var i=e.split(": "),r=i.shift();r&&(iH.indexOf(r.toLowerCase())>=0||0===r.toLowerCase().indexOf("x-litix-"))&&(t[r]=i.join(": "))}}),t}function iV(e){if(e){var t=iB.find(function(t){return void 0!==e[t]});return t?e[t]:void 0}}var iK=function(e){var t={};for(var i in e){var r=e[i];-1!==r["DATA-ID"].search("io.litix.data.")&&(t[r["DATA-ID"].replace("io.litix.data.","")]=r.VALUE)}return t},iW=function(e){if(!e)return{};var t=iN(),i=e.loading,r=i?i.start:e.trequest,s=i?i.first:e.tfirst,a=i?i.end:e.tload;return{bytesLoaded:e.total,requestStart:Math.round(t+r),responseStart:Math.round(t+s),responseEnd:Math.round(t+a)}},iq=function(e){if(!(!e||"function"!=typeof e.getAllResponseHeaders))return iG(e.getAllResponseHeaders())},ij=function(e,t,i){arguments.length>3&&void 0!==arguments[3]&&arguments[3];var r=arguments.length>4?arguments[4]:void 0,s=e.log,a=e.utils.secondsToMs,n=function(e){var t,i=parseInt(r.version);return 1===i&&null!==e.programDateTime&&(t=e.programDateTime),0===i&&null!==e.pdt&&(t=e.pdt),t};if(!iM())return void s.warn("performance timing not supported. Not tracking HLS.js.");var l=function(i,r){return e.emit(t,i,r)},o=function(e,t){var i=t.levels,r=t.audioTracks,s=t.url,a=t.stats,n=t.networkDetails,o=t.sessionData,d={},h={};i.forEach(function(e,t){d[t]={width:e.width,height:e.height,bitrate:e.bitrate,attrs:e.attrs}}),r.forEach(function(e,t){h[t]={name:e.name,language:e.lang,bitrate:e.bitrate}});var u=iW(a),c=u.bytesLoaded,f=u.requestStart,m=u.responseStart,g=u.responseEnd;l("requestcompleted",i$(iF({},iK(o)),{request_event_type:e,request_bytes_loaded:c,request_start:f,request_response_start:m,request_response_end:g,request_type:"manifest",request_hostname:iC(s),request_response_headers:iq(n),request_rendition_lists:{media:d,audio:h,video:{}}}))};i.on(r.Events.MANIFEST_LOADED,o);var d=function(e,t){var i=t.details,r=t.level,s=t.networkDetails,o=iW(t.stats),d=o.bytesLoaded,h=o.requestStart,u=o.responseStart,c=o.responseEnd,f=i.fragments[i.fragments.length-1],m=n(f)+a(f.duration);l("requestcompleted",{request_event_type:e,request_bytes_loaded:d,request_start:h,request_response_start:u,request_response_end:c,request_current_level:r,request_type:"manifest",request_hostname:iC(i.url),request_response_headers:iq(s),video_holdback:i.holdBack&&a(i.holdBack),video_part_holdback:i.partHoldBack&&a(i.partHoldBack),video_part_target_duration:i.partTarget&&a(i.partTarget),video_target_duration:i.targetduration&&a(i.targetduration),video_source_is_live:i.live,player_manifest_newest_program_time:isNaN(m)?void 0:m})};i.on(r.Events.LEVEL_LOADED,d);var h=function(e,t){var i=t.details,r=t.networkDetails,s=iW(t.stats);l("requestcompleted",{request_event_type:e,request_bytes_loaded:s.bytesLoaded,request_start:s.requestStart,request_response_start:s.responseStart,request_response_end:s.responseEnd,request_type:"manifest",request_hostname:iC(i.url),request_response_headers:iq(r)})};i.on(r.Events.AUDIO_TRACK_LOADED,h);var u=function(e,t){var r=t.stats,s=t.networkDetails,a=t.frag,n=iW(r=r||a.stats),o=n.bytesLoaded,d=n.requestStart,h=n.responseStart,u=n.responseEnd,c=s?iq(s):void 0,f={request_event_type:e,request_bytes_loaded:o,request_start:d,request_response_start:h,request_response_end:u,request_hostname:s?iC(s.responseURL):void 0,request_id:c?iV(c):void 0,request_response_headers:c,request_media_duration:a.duration,request_url:null==s?void 0:s.responseURL};"main"===a.type?(f.request_type="media",f.request_current_level=a.level,f.request_video_width=(i.levels[a.level]||{}).width,f.request_video_height=(i.levels[a.level]||{}).height,f.request_labeled_bitrate=(i.levels[a.level]||{}).bitrate):f.request_type=a.type,l("requestcompleted",f)};i.on(r.Events.FRAG_LOADED,u);var c=function(e,t){var i=t.frag,r=i.start;l("fragmentchange",{currentFragmentPDT:n(i),currentFragmentStart:a(r)})};i.on(r.Events.FRAG_CHANGED,c);var f=function(e,t){var i,s=t.type,a=t.details,n=t.response,o=t.fatal,d=t.frag,h=t.networkDetails,u=(null==d?void 0:d.url)||t.url||"",c=h?iq(h):void 0;(a===r.ErrorDetails.MANIFEST_LOAD_ERROR||a===r.ErrorDetails.MANIFEST_LOAD_TIMEOUT||a===r.ErrorDetails.FRAG_LOAD_ERROR||a===r.ErrorDetails.FRAG_LOAD_TIMEOUT||a===r.ErrorDetails.LEVEL_LOAD_ERROR||a===r.ErrorDetails.LEVEL_LOAD_TIMEOUT||a===r.ErrorDetails.AUDIO_TRACK_LOAD_ERROR||a===r.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT||a===r.ErrorDetails.SUBTITLE_LOAD_ERROR||a===r.ErrorDetails.SUBTITLE_LOAD_TIMEOUT||a===r.ErrorDetails.KEY_LOAD_ERROR||a===r.ErrorDetails.KEY_LOAD_TIMEOUT)&&l("requestfailed",{request_error:a,request_url:u,request_hostname:iC(u),request_id:c?iV(c):void 0,request_type:a===r.ErrorDetails.FRAG_LOAD_ERROR||a===r.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":a===r.ErrorDetails.AUDIO_TRACK_LOAD_ERROR||a===r.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT?"audio":a===r.ErrorDetails.SUBTITLE_LOAD_ERROR||a===r.ErrorDetails.SUBTITLE_LOAD_TIMEOUT?"subtitle":a===r.ErrorDetails.KEY_LOAD_ERROR||a===r.ErrorDetails.KEY_LOAD_TIMEOUT?"encryption":"manifest",request_error_code:null==n?void 0:n.code,request_error_text:null==n?void 0:n.text}),o&&l("error",{player_error_code:s,player_error_message:a,player_error_context:"".concat(u?"url: ".concat(u,"\n"):"")+"".concat(n&&(n.code||n.text)?"response: ".concat(n.code,", ").concat(n.text,"\n"):"")+"".concat(t.reason?"failure reason: ".concat(t.reason,"\n"):"")+"".concat(t.level?"level: ".concat(t.level,"\n"):"")+"".concat(t.parent?"parent stream controller: ".concat(t.parent,"\n"):"")+"".concat(t.buffer?"buffer length: ".concat(t.buffer,"\n"):"")+"".concat(t.error?"error: ".concat(t.error,"\n"):"")+"".concat(t.event?"event: ".concat(t.event,"\n"):"")+"".concat(t.err?"error message: ".concat(null==(i=t.err)?void 0:i.message,"\n"):"")})};i.on(r.Events.ERROR,f);var m=function(e,t){var i=t.frag,r=i&&i._url||"";l("requestcanceled",{request_event_type:e,request_url:r,request_type:"media",request_hostname:iC(r)})};i.on(r.Events.FRAG_LOAD_EMERGENCY_ABORTED,m);var g=function(e,t){var r=t.level,a=i.levels[r];if(a&&a.attrs&&a.attrs.BANDWIDTH){var n,o=a.attrs.BANDWIDTH,d=parseFloat(a.attrs["FRAME-RATE"]);isNaN(d)||(n=d),o?l("renditionchange",{video_source_fps:n,video_source_bitrate:o,video_source_width:a.width,video_source_height:a.height,video_source_rendition_name:a.name,video_source_codec:null==a?void 0:a.videoCodec}):s.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};i.on(r.Events.LEVEL_SWITCHED,g),i._stopMuxMonitor=function(){i.off(r.Events.MANIFEST_LOADED,o),i.off(r.Events.LEVEL_LOADED,d),i.off(r.Events.AUDIO_TRACK_LOADED,h),i.off(r.Events.FRAG_LOADED,u),i.off(r.Events.FRAG_CHANGED,c),i.off(r.Events.ERROR,f),i.off(r.Events.FRAG_LOAD_EMERGENCY_ABORTED,m),i.off(r.Events.LEVEL_SWITCHED,g),i.off(r.Events.DESTROYING,i._stopMuxMonitor),delete i._stopMuxMonitor},i.on(r.Events.DESTROYING,i._stopMuxMonitor)},iY=function(e){e&&"function"==typeof e._stopMuxMonitor&&e._stopMuxMonitor()},iQ=function(e,t){if(!e||!e.requestEndDate)return{};var i,r=iC(e.url),s=e.url,a=e.bytesLoaded,n=new Date(e.requestStartDate).getTime(),l=new Date(e.firstByteDate).getTime(),o=new Date(e.requestEndDate).getTime(),d=isNaN(e.duration)?0:e.duration,h="function"==typeof t.getMetricsFor?t.getMetricsFor(e.mediaType).HttpList:t.getDashMetrics().getHttpRequests(e.mediaType);h.length>0&&(i=iG(h[h.length-1]._responseHeaders||""));var u=i?iV(i):void 0;return{requestStart:n,requestResponseStart:l,requestResponseEnd:o,requestBytesLoaded:a,requestResponseHeaders:i,requestMediaDuration:d,requestHostname:r,requestUrl:s,requestId:u}},iz=function(e,t){if("function"==typeof t.getCurrentRepresentationForType){var i=t.getCurrentRepresentationForType(e);return i?{currentLevel:i.absoluteIndex,renditionWidth:i.width||null,renditionHeight:i.height||null,renditionBitrate:i.bandwidth}:{}}var r=t.getQualityFor(e),s=t.getCurrentTrackFor(e).bitrateList;return s?{currentLevel:r,renditionWidth:s[r].width||null,renditionHeight:s[r].height||null,renditionBitrate:s[r].bandwidth}:{}},iX=function(e){var t;return null==(t=e.match(/.*codecs\*?="(.*)"/))?void 0:t[1]},iZ=function(e){try{var t,i;return null==(i=e.getVersion)||null==(t=i.call(e))?void 0:t.split(".").map(function(e){return parseInt(e)})[0]}catch(e){return!1}},iJ=function(e,t,i){arguments.length>3&&void 0!==arguments[3]&&arguments[3];var r=e.log;if(!i||!i.on)return void r.warn("Invalid dash.js player reference. Monitoring blocked.");var s=iZ(i),a=function(i,r){return e.emit(t,i,r)},n=function(e){var t=e.type,i=(e.data||{}).url;a("requestcompleted",{request_event_type:t,request_start:0,request_response_start:0,request_response_end:0,request_bytes_loaded:-1,request_type:"manifest",request_hostname:iC(i),request_url:i})};i.on("manifestLoaded",n);var l={},o=function(e){if("function"!=typeof e.getRequests)return null;var t=e.getRequests({state:"executed"});return 0===t.length?null:t[t.length-1]},d=function(e){var t=e.type,r=e.chunk,s=e.request,n=(r||{}).mediaInfo||{},o=n.type,d=n.bitrateList,h={};
1(d=d||[]).forEach(function(e,t){h[t]={},h[t].width=e.width,h[t].height=e.height,h[t].bitrate=e.bandwidth,h[t].attrs={}}),"video"===o?l.video=h:"audio"===o?l.audio=h:l.media=h;var u=iQ(s,i),c=u.requestStart,f=u.requestResponseStart,m=u.requestResponseEnd,g=u.requestResponseHeaders,v=u.requestMediaDuration,E=u.requestHostname,y=u.requestUrl;a("requestcompleted",{request_event_type:t,request_start:c,request_response_start:f,request_response_end:m,request_bytes_loaded:-1,request_type:o+"_init",request_response_headers:g,request_hostname:E,request_id:u.requestId,request_url:y,request_media_duration:v,request_rendition_lists:l})};s>=4?i.on("initFragmentLoaded",d):i.on("initFragmentLoaded",function(e){var t=e.type,i=e.fragmentModel,r=e.chunk;d({type:t,request:o(i),chunk:r})});var h=function(e){var t=e.type,r=e.chunk,s=e.request,n=r||{},l=n.mediaInfo,o=n.start,d=(l||{}).type,h=iQ(s,i),u=h.requestStart,c=h.requestResponseStart,f=h.requestResponseEnd,m=h.requestBytesLoaded,g=h.requestResponseHeaders,v=h.requestMediaDuration,E=h.requestHostname,y=h.requestUrl,b=h.requestId,T=iz(d,i),_=T.currentLevel,A=T.renditionWidth,S=T.renditionHeight;a("requestcompleted",{request_event_type:t,request_start:u,request_response_start:c,request_response_end:f,request_bytes_loaded:m,request_type:d,request_response_headers:g,request_hostname:E,request_id:b,request_url:y,request_media_start_time:o,request_media_duration:v,request_current_level:_,request_labeled_bitrate:T.renditionBitrate,request_video_width:A,request_video_height:S})};s>=4?i.on("mediaFragmentLoaded",h):i.on("mediaFragmentLoaded",function(e){var t=e.type,i=e.fragmentModel,r=e.chunk;h({type:t,request:o(i),chunk:r})});var u={video:void 0,audio:void 0,totalBitrate:void 0},c=function(){if(u.video&&"number"==typeof u.video.bitrate){if(!(u.video.width&&u.video.height))return void r.warn("have bitrate info for video but missing width/height");var e=u.video.bitrate;if(u.audio&&"number"==typeof u.audio.bitrate&&(e+=u.audio.bitrate),e!==u.totalBitrate)return u.totalBitrate=e,{video_source_bitrate:e,video_source_height:u.video.height,video_source_width:u.video.width,video_source_codec:iX(u.video.codec)}}},f=function(e,t,s){var n=e.mediaType;if("audio"===n||"video"===n){if("function"==typeof i.getRepresentationsByType)if(e.newRepresentation)l={bitrate:e.newRepresentation.bandwidth,width:e.newRepresentation.width,height:e.newRepresentation.height,qualityIndex:e.newRepresentation.absoluteIndex};else{var l,o=i.getRepresentationsByType(n);if(o&&"number"==typeof e.newQuality){var d=o.find(function(t){return t.absoluteIndex===e.newQuality||t.index===e.newQuality});d&&(l={bitrate:d.bandwidth,width:d.width,height:d.height,qualityIndex:e.newQuality})}}else{if("number"!=typeof e.newQuality)return void r.warn("missing evt.newQuality in qualityChangeRendered event",e);l=i.getBitrateInfoListFor(n).find(function(t){return t.qualityIndex===e.newQuality})}if(!(l&&"number"==typeof l.bitrate))return void r.warn("missing bitrate info for ".concat(n));u[n]=i$(iF({}
1,l),{codec:i.getCurrentTrackFor(n).codec});var h=c();h&&a("renditionchange",h)}};i.on("qualityChangeRendered",f);var m=function(e){var t=e.request,i=e.mediaType;a("requestcanceled",{request_event_type:(t=t||{}).type+"_"+t.action,request_url:t.url,request_type:i,request_hostname:iC(t.url)})};i.on("fragmentLoadingAbandoned",m);var g=function(e){var t,i,r=e.error,s=(null==r||null==(t=r.data)?void 0:t.request)||{},n=(null==r||null==(i=r.data)?void 0:i.response)||{};(null==r?void 0:r.code)===27&&a("requestfailed",{request_error:s.type+"_"+s.action,request_url:s.url,request_hostname:iC(s.url),request_type:s.mediaType,request_error_code:n.status,request_error_text:n.statusText});var l="".concat(null!=s&&s.url?"url: ".concat(s.url,"\n"):"")+"".concat(null!=n&&n.status||null!=n&&n.statusText?"response: ".concat(null==n?void 0:n.status,", ").concat(null==n?void 0:n.statusText,"\n"):"");a("error",{player_error_code:null==r?void 0:r.code,player_error_message:null==r?void 0:r.message,player_error_context:l})};i.on("error",g),i._stopMuxMonitor=function(){i.off("manifestLoaded",n),i.off("initFragmentLoaded",d),i.off("mediaFragmentLoaded",h),i.off("qualityChangeRendered",f),i.off("error",g),i.off("fragmentLoadingAbandoned",m),delete i._stopMuxMonitor}},i0=function(e){e&&"function"==typeof e._stopMuxMonitor&&e._stopMuxMonitor()},i1=0,i2=function(){function e(){iS(this,e),iR(this,"_listeners",void 0)}return iL(e,[{key:"on",value:function(e,t,i){return t._eventEmitterGuid=t._eventEmitterGuid||++i1,this._listeners=this._listeners||{},this._listeners[e]=this._listeners[e]||[],i&&(t=t.bind(i)),this._listeners[e].push(t),t}},{key:"off",value:function(e,t){var i=this._listeners&&this._listeners[e];i&&i.forEach(function(e,r){e._eventEmitterGuid===t._eventEmitterGuid&&i.splice(r,1)})}},{key:"one",value:function(e,t,i){var r=this;t._eventEmitterGuid=t._eventEmitterGuid||++i1;var s=function(){r.off(e,s),t.apply(i||this,arguments)};s._eventEmitterGuid=t._eventEmitterGuid,this.on(e,s)}},{key:"emit",value:function(e,t){var i=this;if(this._listeners){t=t||{};var r=this._listeners["before"+e]||[],s=this._listeners["before*"]||[],a=this._listeners[e]||[],n=this._listeners["after"+e]||[],l=function(t,r){(t=t.slice()).forEach(function(t){t.call(i,{type:e},r)})};l(r,t),l(s,t),l(a,t),l(n,t)}}}]),e}(),i3=tX(tZ()),i4=function(){function e(t){var i=this;iS(this,e),iR(this,"_playbackHeartbeatInterval",void 0),iR(this,"_playheadShouldBeProgressing",void 0),iR(this,"pm",void 0),this.pm=t,this._playbackHeartbeatInterval=null,this._playheadShouldBeProgressing=!1,t.on("playing",function(){i._playheadShouldBeProgressing=!0}),t.on("play",this._startPlaybackHeartbeatInterval.bind(this)),t.on("playing",this._startPlaybackHeartbeatInterval.bind(this)),t.on("adbreakstart",this._startPlaybackHeartbeatInterval.bind(this)),t.on("adplay",this._startPlaybackHeartbeatInterval.bind(this)),t.on("adplaying",this._startPlaybackHeartbeatInterval.bind(this)),t.on("devicewake",this._startPlaybackHeartbeatInterval.bind(this)),t.on("viewstart",this._startPlaybackHeartbeatInterval.bind(this)),t.on("rebufferstart",this._startPlaybackHeartbeatInterval.bind(this)),t.on("pause",this._stopPlaybackHeartbeatInterval.bind(this)),t.on("ended",this._stopPlaybackHeartbeatInterval.bind(this)),t.on("viewend",this._stopPlaybackHeartbeatInterval.bind(this)),t.on("error",this._stopPlaybackHeartbeatInterval.bind(this)),t.on("aderror",this._stopPlaybackHeartbeatInterval.bind(this)),t.on("adpause",this._stopPlaybackHeartbeatInterval.bind(this)),t.on("adended",this._stopPlaybackHeartbeatInterval.bind(this)),t.on("adbreakend",this._stopPlaybackHeartbeatInterval.bind(this)),t.on("seeked",function(){t.data.player_is_paused?i._stopPlaybackHeartbeatInterval():i._startPlaybackHeartbeatInterval()}),t.on("timeupdate",function(){null!==i._playbackHeartbeatInterval&&t.emit("playbackheartbeat")}),t.on("devicesleep",function(e,r){null!==i._playbackHeartbeatInterval&&(i3.default.clearInterval(i._playbackHeartbeatInterval),t.emit("playbackheartbeatend",{viewer_time:r.viewer_time}),i._playbackHeartbeatInterval=null)})}return iL(e,[{key:"_startPlaybackHeartbeatInterval",value:function(){var e=this;null===this._playbackHeartbeatInterval&&(this.pm.emit("playbackheartbeat"),this._playbackHeartbeatInterval=i3.default.setInterval(function(){e.pm.emit("playbackheartbeat")},this.pm.playbackHeartbeatTime))}},{key:"_stopPlaybackHeartbeatInterval",value:function(){this._playheadShouldBeProgressing=!1,null!==this._playbackHeartbeatInterval&&(i3.default.clearInterval(this._playbackHeartbeatInterval),this.pm.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)}}]),e}(),i5=function e(t){var i=this;iS(this,e),iR(this,"viewErrored",void 0),t.on("viewinit",function(){i.viewErrored=!1}),t.on("error",function(e,r){try{var s=t.errorTranslator({player_error_code:r.player_error_code,player_error_message:r.player_error_message,player_error_context:r.player_error_context,player_error_severity:r.player_error_severity,player_error_business_exception:r.player_error_business_exception});s&&(t.data.player_error_code=s.player_error_code||r.player_error_code,t.data.player_error_message=s.player_error_message||r.player_error_message,t.data.player_error_context=s.player_error_context||r.player_error_context,t.data.player_error_severity=s.player_error_severity||r.player_error_severity,t.data.player_error_business_exception=s.player_error_business_exception||r.player_error_business_exception,i.viewErrored=!0)}catch(e){t.mux.log.warn("Exception in error translator callback.",e),i.viewErrored=!0}}),t.on("aftererror",function(){var e,i,r,s,a;null==(e=t.data)||delete e.player_error_code,null==(i=t.data)||delete i.player_error_message,null==(r=t.data)||delete r.player_error_context,null==(s=t.data)||delete s.player_error_severity,null==(a=t.data)||delete a.player_error_business_exception})},i8=function(){function e(t){iS(this,e),iR(this,"_watchTimeTrackerLastCheckedTime",void 0),iR(this,"pm",void 0),this.pm=t,this._watchTimeTrackerLastCheckedTime=null,t.on("playbackheartbeat",this._updateWatchTime.bind(this)),t.on("playbackheartbeatend",this._clearWatchTimeState.bind(this))}return iL(e,[{key:"_updateWatchTime",value:function(e,t){var i=t.viewer_time;null===this._watchTimeTrackerLastCheckedTime&&(this._watchTimeTrackerLastCheckedTime=i),iU(this.pm.data,"view_watch_time",i-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=i}},{key:"_clearWatchTimeState",value:function(e,t){this._updateWatchTime(e,t),this._watchTimeTrackerLastCheckedTime=null}}]),e}(),i6=function(){function e(t){var i=this;iS(this,e),iR(this,"_playbackTimeTrackerLastPlayheadPosition",void 0),iR(this,"_lastTime",void 0),iR(this,"_isAdPlaying",void 0),iR(this,"_callbackUpdatePlaybackTime",void 0),iR(this,"pm",void 0),this.pm=t,this._playbackTimeTrackerLastPlayheadPosition=-1,this._lastTime=im(),this._isAdPlaying=!1,this._callbackUpdatePlaybackTime=null,t.on("viewinit",function(){i.pm.data.view_playing_time_ms_cumulative=0});var r=this._startPlaybackTimeTracking.bind(this);t.on("playing",r),t.on("adplaying",r);var s=function(){i.pm.data.player_is_paused||r()};t.on("seeked",s),t.on("rebufferend",s);var a=this._stopPlaybackTimeTracking.bind(this);t.on("playbackheartbeatend",a),t.on("seeking",a),t.on("rebufferstart",a),t.on("adplaying",function(){i._isAdPlaying=!0}),t.on("adended",function(){i._isAdPlaying=!1}),t.on("adpause",function(){i._isAdPlaying=!1}),t.on("adbreakstart",function(){i._isAdPlaying=!1}),t.on("adbreakend",function(){i._isAdPlaying=!1}),t.on("adplay",function(){i._isAdPlaying=!1}),t.on("viewinit",function(){i._playbackTimeTrackerLastPlayheadPosition=-1,i._lastTime=im(),i._isAdPlaying=!1,i._callbackUpdatePlaybackTime=null})}return iL(e,[{key:"_startPlaybackTimeTracking",value:function(){null===this._callbackUpdatePlaybackTime&&(this._callbackUpdatePlaybackTime=this._updatePlaybackTime.bind(this),this._playbackTimeTrackerLastPlayheadPosition=this.pm.data.player_playhead_time,this._lastTime=im(),this.pm.on("playbackheartbeat",this._callbackUpdatePlaybackTime))}},{key:"_stopPlaybackTimeTracking",value:function(){this._callbackUpdatePlaybackTime&&(this._updatePlaybackTime(),this.pm.off("playbackheartbeat",this._callbackUpdatePlaybackTime),this._callbackUpdatePlaybackTime=null,this._playbackTimeTrackerLastPlayheadPosition=-1)}},{key:"_updatePlaybackTime",value:function(){var e=this.pm.data.player_playhead_time||0,t=im(),i=t-this._lastTime,r=-1;this._playbackTimeTrackerLastPlayheadPosition>=0&&e>
1this._playbackTimeTrackerLastPlayheadPosition?r=e-this._playbackTimeTrackerLastPlayheadPosition:this._isAdPlaying&&(r=i),r>0&&r<=1e3&&iU(this.pm.data,"view_content_playback_time",r),null!==this._callbackUpdatePlaybackTime&&i>0&&i<=1e3&&(this._isAdPlaying&&iU(this.pm.data,"ad_playing_time_ms_cumulative",i),iU(this.pm.data,"view_playing_time_ms_cumulative",i)),this._playbackTimeTrackerLastPlayheadPosition=e,this._lastTime=t}}]),e}(),i9=function(){function e(t){iS(this,e),iR(this,"pm",void 0),this.pm=t;var i=this._updatePlayheadTime.bind(this);t.on("playbackheartbeat",i),t.on("playbackheartbeatend",i),t.on("timeupdate",i),t.on("destroy",function(){t.off("timeupdate",i)})}return iL(e,[{key:"_updateMaxPlayheadPosition",value:function(){this.pm.data.view_max_playhead_position=void 0===this.pm.data.view_max_playhead_position?this.pm.data.player_playhead_time:Math.max(this.pm.data.view_max_playhead_position,this.pm.data.player_playhead_time)}},{key:"_updatePlayheadTime",value:function(e,t){var i=this,r=function(){i.pm.currentFragmentPDT&&i.pm.currentFragmentStart&&(i.pm.data.player_program_time=i.pm.currentFragmentPDT+i.pm.data.player_playhead_time-i.pm.currentFragmentStart)};if(t&&t.player_playhead_time)this.pm.data.player_playhead_time=t.player_playhead_time,r(),this._updateMaxPlayheadPosition();else if(this.pm.getPlayheadTime){var s=this.pm.getPlayheadTime();void 0!==s&&(this.pm.data.player_playhead_time=s,r(),this._updateMaxPlayheadPosition())}}}]),e}(),i7=function e(t){if(iS(this,e),!t.disableRebufferTracking){var i,r=function(e,t){s(t),i=void 0},s=function(e){if(i){var r=e.viewer_time-i;iU(t.data,"view_rebuffer_duration",r),i=e.viewer_time,t.data.view_rebuffer_duration>3e5&&(t.emit("viewend"),t.send("viewend"),t.mux.log.warn("Ending view after rebuffering for longer than ".concat(3e5,"ms, future events will be ignored unless a programchange or videochange occurs.")))}t.data.view_watch_time>=0&&t.data.view_rebuffer_count>0&&(t.data.view_rebuffer_frequency=t.data.view_rebuffer_count/t.data.view_watch_time,t.data.view_rebuffer_percentage=t.data.view_rebuffer_duration/t.data.view_watch_time)};t.on("playbackheartbeat",function(e,t){return s(t)}),t.on("rebufferstart",function(e,s){i||(iU(t.data,"view_rebuffer_count",1),i=s.viewer_time,t.one("rebufferend",r))}),t.on("viewinit",function(){i=void 0,t.off("rebufferend",r)})}},re=function(){function e(t){var i=this;iS(this,e),iR(this,"_lastCheckedTime",void 0),iR(this,"_lastPlayheadTime",void 0),iR(this,"_lastPlayheadTimeUpdatedTime",void 0),iR(this,"_rebuffering",void 0),iR(this,"pm",void 0),this.pm=t,t.disableRebufferTracking||t.disablePlayheadRebufferTracking||(this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null,t.on("playbackheartbeat",this._checkIfRebuffering.bind(this)),t.on("playbackheartbeatend",this._cleanupRebufferTracker.bind(this)),t.on("seeking",function(){i._cleanupRebufferTracker(null,{viewer_time:im()})}))}return iL(e,[{key:"_checkIfRebuffering",value:function(e,t){if(this.pm.seekingTracker.isSeeking||this.pm.adTracker.isAdBreak||!this.pm.playbackHeartbeat._playheadShouldBeProgressing)return void this._cleanupRebufferTracker(e,t);if(null===this._lastCheckedTime)return void this._prepareRebufferTrackerState(t.viewer_time);if(this._lastPlayheadTime!==this.pm.data.player_playhead_time)return void this._cleanupRebufferTracker(e,t,!0);var i=t.viewer_time-this._lastPlayheadTimeUpdatedTime;"number"==typeof this.pm.sustainedRebufferThreshold&&i>=this.pm.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),this._lastCheckedTime=t.viewer_time}},{key:"_clearRebufferTrackerState",value:function(){this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null}},{key:"_prepareRebufferTrackerState",value:function(e){this._lastCheckedTime=e,this._lastPlayheadTime=this.pm.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=e}},{key:"_cleanupRebufferTracker",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(this._rebuffering)this._rebuffering=!1,this.pm.emit("rebufferend",{viewer_time:t.viewer_time});else{if(null===this._lastCheckedTime)return;var r=this.pm.data.player_playhead_time-this._lastPlayheadTime,s=t.viewer_time-this._lastPlayheadTimeUpdatedTime;"number"==typeof this.pm.minimumRebufferDuration&&r>0&&s-r>this.pm.minimumRebufferDuration&&(this._lastCheckedTime=null,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.pm.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+s-r}))}i?this._prepareRebufferTrackerState(t.viewer_time):this._clearRebufferTrackerState()}}]),e}(),rt=function(){function e(t){var i=this;iS(this,e),iR(this,"pm",void 0),this.pm=t,t.on("viewinit",function(){var e=t.data,r=e.view_id;if(!e.view_program_changed){var s=function(e,s){var a=s.viewer_time;"playing"===e.type&&void 0===t.data.view_time_to_first_frame?i.calculateTimeToFirstFrame(a||im(),r):"adplaying"===e.type&&(void 0===t.data.view_time_to_first_frame||i._inPrerollPosition())&&i.calculateTimeToFirstFrame(a||im(),r)};t.one("playing",s),t.one("adplaying",s),t.one("viewend",function(){t.off("playing",s),t.off("adplaying",s)})}})}return iL(e,[{key:"_inPrerollPosition",value:function(){return void 0===this.pm.data.view_content_playback_time||this.pm.data.view_content_playback_time<=1e3}},{key:"calculateTimeToFirstFrame",value:function(e,t){t===this.pm.data.view_id&&(this.pm.watchTimeTracker._updateWatchTime(null,{viewer_time:e}),this.pm.data.view_time_to_first_frame=this.pm.data.view_watch_time,(this.pm.data.player_autoplay_on||this.pm.data.video_is_autoplay)&&this.pm.pageLoadInitTime&&(this.pm.data.view_aggregate_startup_time=this.pm.data.view_start+this.pm.data.view_watch_time-this.pm.pageLoadInitTime))}}]),e}(),ri=function e(t){var i=this;iS(this,e),iR(this,"_lastPlayerHeight",void 0),iR(this,"_lastPlayerWidth",void 0),iR(this,"_lastPlayheadPosition",void 0),iR(this,"_lastSourceHeight",void 0),iR(this,"_lastSourceWidth",void 0),t.on("viewinit",function(){i._lastPlayheadPosition=-1}),["pause","rebufferstart","seeking","error","adbreakstart","hb","renditionchange","orientationchange","viewend","playbackmodechange"].forEach(function(e){t.on(e,function(){if(i._lastPlayheadPosition>=0&&t.data.player_playhead_time>=0&&i._lastPlayerWidth>=0&&i._lastSourceWidth>0&&i._lastPlayerHeight>=0&&i._lastSourceHeight>0){var e=t.data.player_playhead_time-i._lastPlayheadPosition;if(e<0){i._lastPlayheadPosition=-1;return}var r=Math.min(i._lastPlayerWidth/i._lastSourceWidth,i._lastPlayerHeight/i._lastSourceHeight),s=Math.max(0,r-1),a=Math.max(0,1-r);t.data.view_max_upscale_percentage=Math.max(t.data.view_max_upscale_percentage||0,s),t.data.view_max_downscale_percentage=Math.max(t.data.view_max_downscale_percentage||0,a),iU(t.data,"view_total_content_playback_time",e),iU(t.data,"view_total_upscaling",s*e),iU(t.data,"view_total_downscaling",a*e)}i._lastPlayheadPosition=-1})}),["playing","hb","renditionchange","orientationchange","playbackmodechange"].forEach(function(e){t.on(e,function(){i._lastPlayheadPosition=t.data.player_playhead_time,i._lastPlayerWidth=t.data.player_width,i._lastPlayerHeight=t.data.player_height,i._lastSourceWidth=t.data.video_source_width,i._lastSourceHeight=t.data.video_source_height})})},rr=function e(t){var i=this;iS(this,e),iR(this,"isSeeking",void 0),this.isSeeking=!1;var r=-1,s=function(){var e=im(),s=(t.data.viewer_time||e)-(r||e);iU(t.data,"view_seek_duration",s),t.data.view_max_seek_time=Math.max(t.data.view_max_seek_time||0,s),i.isSeeking=!1,r=-1};t.on("seeking",function(e,a){if(Object.assign(t.data,a),i.isSeeking&&a.viewer_time-r<=2e3){r=a.viewer_time;return}i.isSeeking&&s(),i.isSeeking=!0,r=a.viewer_time,iU(t.data,"view_seek_count",1),t.send("seeking")}),t.on("seeked",function(){s()}),t.on("viewend",function(){i.isSeeking&&(s(),t.send("seeked")),i.isSeeking=!1,r=-1})},rs=function(e,t){e.push(t),e.sort(function(e,t){return e.viewer_time-t.viewer_time})},ra=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror","adclicked","adskipped"],rn=function(){function e(t){var i=this;iS(this,e),iR(this,"_adHasPlayed",void 0),iR(this,"_adRequests",void 0),iR(this,"_adResponses",void 0),iR(this,"_currentAdRequestNumber",void 0),iR(this,"_currentAdResponseNumber",void 0),iR(this,"_prerollPlayTime",void 0),iR(this,"_wouldBeNewAdPlay",void 0),iR(this,"isAdBreak",void 0),iR(this,"pm",void 0),this.pm=t,t.on("viewinit",function(){i.isAdBreak=!1,i._currentAdRequestNumber=0,i._currentAdResponseNumber=0,i._adRequests=[],i._adResponses=[],i._adHasPlayed=!1,i._wouldBeNewAdPlay=!0,i._prerollPlayTime=void 0}),ra.forEach(function(e){return t.on(e,i._updateAdData.bind(i))});var r=function(){i.isAdBreak=!1};t.on("adbreakstart",function(){i.isAdBreak=!0}),t.on("play",r),t.on("playing",r),t.on("viewend",r),t.on("adrequest",function(e,r){r=Object.assign({ad_request_id:"generatedAdRequestId"+i._currentAdRequestNumber++},r),rs(i._adRequests,r),iU(t.data,"view_ad_request_count"),i.inPrerollPosition()&&(t.data.view_preroll_requested=!0,i._adHasPlayed||iU(t.data,"view_preroll_request_count"))}),t.on("adresponse",function(e,r){r=Object.assign({ad_request_id:"generatedAdRequestId"+i._currentAdResponseNumber++},r),rs(i._adResponses,r);var s=i.findAdRequest(r.ad_request_id);s&&iU(t.data,"view_ad_request_time",Math.max(0,r.viewer_time-s.viewer_time))}),t.on("adplay",function(e,r){i._adHasPlayed=!0,i._wouldBeNewAdPlay&&(i._wouldBeNewAdPlay=!1,iU(t.data,"view_ad_played_count")),i.inPrerollPosition()&&
1!t.data.view_preroll_played&&(t.data.view_preroll_played=!0,i._adRequests.length>0&&(t.data.view_preroll_request_time=Math.max(0,r.viewer_time-i._adRequests[0].viewer_time)),t.data.view_start&&(t.data.view_startup_preroll_request_time=Math.max(0,r.viewer_time-t.data.view_start)),i._prerollPlayTime=r.viewer_time)}),t.on("adplaying",function(e,r){i.inPrerollPosition()&&void 0===t.data.view_preroll_load_time&&void 0!==i._prerollPlayTime&&(t.data.view_preroll_load_time=r.viewer_time-i._prerollPlayTime,t.data.view_startup_preroll_load_time=r.viewer_time-i._prerollPlayTime)}),t.on("adclicked",function(e,r){i._wouldBeNewAdPlay||iU(t.data,"view_ad_clicked_count")}),t.on("adskipped",function(e,r){i._wouldBeNewAdPlay||iU(t.data,"view_ad_skipped_count")}),t.on("adended",function(){i._wouldBeNewAdPlay=!0}),t.on("aderror",function(){i._wouldBeNewAdPlay=!0})}return iL(e,[{key:"inPrerollPosition",value:function(){return void 0===this.pm.data.view_content_playback_time||this.pm.data.view_content_playback_time<=1e3}},{key:"findAdRequest",value:function(e){for(var t=0;t<this._adRequests.length;t++)if(this._adRequests[t].ad_request_id===e)return this._adRequests[t]}},{key:"_updateAdData",value:function(e,t){if(this.inPrerollPosition()){if(!this.pm.data.view_preroll_ad_tag_hostname&&t.ad_tag_url){var i=id(iP(t.ad_tag_url),2),r=i[0],s=i[1];this.pm.data.view_preroll_ad_tag_domain=s,this.pm.data.view_preroll_ad_tag_hostname=r}if(!this.pm.data.view_preroll_ad_asset_hostname&&t.ad_asset_url){var a=id(iP(t.ad_asset_url),2),n=a[0],l=a[1];this.pm.data.view_preroll_ad_asset_domain=l,this.pm.data.view_preroll_ad_asset_hostname=n}this.pm.data.ad_type="preroll"}this.pm.data.ad_asset_url=null==t?void 0:t.ad_asset_url,this.pm.data.ad_tag_url=null==t?void 0:t.ad_tag_url,this.pm.data.ad_creative_id=null==t?void 0:t.ad_creative_id,this.pm.data.ad_id=null==t?void 0:t.ad_id,this.pm.data.ad_universal_id=null==t?void 0:t.ad_universal_id,null!=t&&t.ad_type&&(this.pm.data.ad_type=null==t?void 0:t.ad_type)}}]),e}(),rl=function e(t){var i=this;iS(this,e),iR(this,"lastWallClockTime",void 0);var r=function(){i.lastWallClockTime=im(),t.on("before*",s)},s=function(e){var r=im(),s=i.lastWallClockTime;i.lastWallClockTime=r,r-s>3e4&&(t.emit("devicesleep",{viewer_time:s}),Object.assign(t.data,{viewer_time:s}),t.send("devicesleep"),t.emit("devicewake",{viewer_time:r}),Object.assign(t.data,{viewer_time:r}),t.send("devicewake"))};t.one("playbackheartbeat",r),t.on("playbackheartbeatend",function(){t.off("before*",s),t.one("playbackheartbeat",r)})},ro=tX(tZ()),rd=(rq=function(){for(var e=0,t={};e<arguments.length;e++){var i=arguments[e];for(var r in i)t[r]=i[r]}return t},function e(t){function i(e,r,s){var a;if("u">typeof document){if(arguments.length>1){if("number"==typeof(s=rq({path:"/"},i.defaults,s)).expires){var n=new Date;n.setMilliseconds(n.getMilliseconds()+864e5*s.expires),s.expires=n}try{a=JSON.stringify(r),/^[\{\[]/.test(a)&&(r=a)}catch(e){}return r=t.write?t.write(r,e):encodeURIComponent(String(r)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),e=(e=(e=encodeURIComponent(String(e))).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent)).replace(/[\(\)]/g,escape),document.cookie=e+"="+r+(s.expires?"; expires="+s.expires.toUTCString():"")+(s.path?"; path="+s.path:"")+(s.domain?"; domain="+s.domain:"")+(s.secure?"; secure":"")}e||(a={});for(var l=document.cookie?document.cookie.split("; "):[],o=/(%[0-9A-Z]{2})+/g,d=0;d<l.length;d++){var h=l[d].split("="),u=h.slice(1).join("=");'"'===u.charAt(0)&&(u=u.slice(1,-1));try{var c=h[0].replace(o,decodeURIComponent);if(u=t.read?t.read(u,c):t(u,c)||u.replace(o,decodeURIComponent),this.json)try{u=JSON.parse(u)}catch(e){}if(e===c){a=u;break}e||(a[c]=u)}catch(e){}}return a}}return i.set=i,i.get=function(e){return i.call(i,e)},i.getJSON=function(){return i.apply({json:!0},[].slice.call(arguments))},i.defaults={},i.remove=function(e,t){i(e,"",rq(t,{expires:-1}))},i.withConverter=e,i}(function(){})),rh="muxData",ru=function(){var e;try{e=(rd.get(rh)||"").split("&").reduce(function(e,t){var i=id(t.split("="),2),r=i[0],s=i[1],a=+s;return e[r]=s&&a==s?a:s,e},{})}catch(t){e={}}return e},rc=function(e){try{rd.set(rh,Object.entries(e).map(function(e){var t=id(e,2),i=t[0],r=t[1];return"".concat(i,"=").concat(r)}).join("&"),{expires:365})}catch(e){}},rf=function(){var e=ru();return e.mux_viewer_id=e.mux_viewer_id||ip(),e.msn=e.msn||Math.random(),rc(e),{mux_viewer_id:e.mux_viewer_id,mux_sample_number:e.msn}},rm=function(){var e=ru(),t=im();return e.session_start&&(e.sst=e.session_start,delete e.session_start),e.session_id&&(e.sid=e.session_id,delete e.session_id),e.session_expires&&(e.sex=e.session_expires,delete e.session_expires),(!e.sex||e.sex<t)&&(e.sid=ip(),e.sst=t),e.sex=t+15e5,rc(e),{session_id:e.sid,session_start:e.sst,session_expires:e.sex}},rp=tX(tZ()),rg=function(){var e;switch(rv()){case"cellular":e="cellular";break;case"ethernet":e="wired";break;case"wifi":e="wifi";break;case void 0:break;default:e="other"}return e},rv=function(){var e=rp.default.navigator,t=e&&(e.connection||e.mozConnection||e.webkitConnection);return t&&t.type};rg.getConnectionFromAPI=rv;var rE=rb({a:"env",b:"beacon",c:"custom",d:"ad",e:"event",f:"experiment",i:"internal",m:"mux",n:"response",p:"player",q:"request",r:"retry",s:"session",t:"timestamp",u:"viewer",v:"video",w:"page",x:"view",y:"sub"}),ry=rb({ad:"ad",af:"affiliate",ag:"aggregate",ap:"api",al:"application",ao:"audio",ar:"architecture",as:"asset",au:"autoplay",av:"average",bi:"bitrate",bn:"brand",br:"break",bw:"browser",by:"bytes",bz:"business",ca:"cached",cb:"cancel",cc:"codec",cd:"code",cg:"category",ch:"changed",ci:"client",ck:"clicked",cl:"canceled",cm:"cmcd",cn:"config",co:"count",ce:"counter",cp:"complete",cq:"creator",cr:"creative",cs:"captions",ct:"content",cu:"current",cv:"cumulative",cx:"c
1onnection",cz:"context",da:"data",dg:"downscaling",dm:"domain",dn:"cdn",do:"downscale",dr:"drm",dp:"dropped",du:"duration",dv:"device",dy:"dynamic",eb:"enabled",ec:"encoding",ed:"edge",en:"end",eg:"engine",em:"embed",er:"error",ep:"experiments",es:"errorcode",et:"errortext",ee:"event",ev:"events",ex:"expires",ez:"exception",fa:"failed",fi:"first",fm:"family",ft:"format",fp:"fps",fq:"frequency",fr:"frame",fs:"fullscreen",ha:"has",hb:"holdback",he:"headers",ho:"host",hn:"hostname",ht:"height",id:"id",ii:"init",in:"instance",ip:"ip",is:"is",ke:"key",la:"language",lb:"labeled",le:"level",li:"live",ld:"loaded",lo:"load",ls:"lists",lt:"latency",ma:"max",md:"media",me:"message",mf:"manifest",mi:"mime",ml:"midroll",mm:"min",mn:"manufacturer",mo:"model",mp:"mode",ms:"ms",mx:"mux",ne:"newest",nm:"name",no:"number",on:"on",or:"origin",os:"os",pa:"paused",pb:"playback",pd:"producer",pe:"percentage",pf:"played",pg:"program",ph:"playhead",pi:"plugin",pl:"preroll",pn:"playing",po:"poster",pp:"pip",pr:"preload",ps:"position",pt:"part",pv:"previous",py:"property",px:"pop",pz:"plan",ra:"rate",rd:"requested",re:"rebuffer",rf:"rendition",rg:"range",rm:"remote",ro:"ratio",rp:"response",rq:"request",rs:"requests",sa:"sample",sd:"skipped",se:"session",sh:"shift",sk:"seek",sm:"stream",so:"source",sq:"sequence",sr:"series",ss:"status",st:"start",su:"startup",sv:"server",sw:"software",sy:"severity",ta:"tag",tc:"tech",te:"text",tg:"target",th:"throughput",ti:"time",tl:"total",to:"to",tt:"title",ty:"type",ug:"upscaling",un:"universal",up:"upscale",ur:"url",us:"user",va:"variant",vd:"viewed",vi:"video",ve:"version",vw:"view",vr:"viewer",wd:"width",wa:"watch",wt:"waiting"});function rb(e){var t={};for(var i in e)e.hasOwnProperty(i)&&(t[e[i]]=i);return t}function rT(e){var t={},i={};return Object.keys(e).forEach(function(r){var s=!1;if(e.hasOwnProperty(r)&&void 0!==e[r]){var a=r.split("_"),n=a[0],l=rE[n];l||(ib.info("Data key word `"+a[0]+"` not expected in "+r),l=n+"_"),a.splice(1).forEach(function(e){"url"===e&&(s=!0),ry[e]?l+=ry[e]:Number.isInteger(Number(e))?l+=e:(ib.info("Data key word `"+e+"` not expected in "+r),l+="_"+e+"_")}),s?i[l]=e[r]:t[l]=e[r]}}),Object.assign(t,i)}var r_=tX(tZ()),rA=tX(ia()),rS={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4,maxPayloadKBSize:500},rk=["hb","requestcompleted","requestfailed","requestcanceled"],rL=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this._beaconUrl=e||"https://img.litix.io",this._eventQueue=[],this._postInFlight=!1,this._resendAfterPost=!1,this._failureCount=0,this._sendTimeout=!1,this._options=Object.assign({},rS,t)};rL.prototype.queueEvent=function(e,t){var i=Object.assign({},t);return(this._eventQueue.length<=this._options.maxQueueLength||"eventrateexceeded"===e)&&(this._eventQueue.push(i),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength)},rL.prototype.flushEvents=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];e&&1===this._eventQueue.length?this._eventQueue.pop():(this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending())},rL.prototype.destroy=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.destroyed=!0,e?this._clearBeaconQueue():this.flushEvents(),r_.default.clearTimeout(this._sendTimeout)},rL.prototype._clearBeaconQueue=function(){var e=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,t=this._eventQueue.slice(e);e>0&&Object.assign(t[t.length-1],rT({mux_view_message:"event queue truncated"}));var i=this._createPayload(t);rI(this._beaconUrl,i,!0,function(){})},rL.prototype._sendBeaconQueue=function(){var e=this;if(this._postInFlight){this._resendAfterPost=!0;return}var t=this._eventQueue.slice(0,this._options.maxBeaconSize);this._eventQueue=this._eventQueue.slice(this._options.maxBeaconSize),this._postInFlight=!0;var i=this._createPayload(t),r=im();rI(this._beaconUrl,i,!1,function(i,s){s?(e._eventQueue=t.concat(e._eventQueue),e._failureCount+=1,ib.info("Error sending beacon: "+s)):e._failureCount=0,e._roundTripTime=im()-r,e._postInFlight=!1,e._resendAfterPost&&(e._resendAfterPost=!1,e._eventQueue.length>0&&e._sendBeaconQueue())})},rL.prototype._getNextBeaconTime=function(){if(!this._failureCount)return this._options.baseTimeBetweenBeacons;var e=Math.pow(2,this._failureCount-1);return(1+(e*=Math.random()))*this._options.baseTimeBetweenBeacons},rL.prototype._startBeaconSending=function(){var e=this;r_.default.clearTimeout(this._sendTimeout),this.destroyed||(this._sendTimeout=r_.default.setTimeout(function(){e._eventQueue.length&&e._sendBeaconQueue(),e._startBeaconSending()},this._getNextBeaconTime()))},rL.prototype._createPayload=function(e){var t=this,i={transmission_timestamp:Math.round(im())};this._roundTripTime&&(i.rtt_ms=Math.round(this._roundTripTime));var r,s,a,n=function(){a=(r=JSON.stringify({metadata:i,events:s||e})).length/1024},l=function(){return a<=t._options.maxPayloadKBSize};return n(),l()||(ib.info("Payload size is too big ("+a+" kb). Removing unnecessary events."),s=e.filter(function(e){return -1===rk.indexOf(e.e)}),n()),l()||(ib.info("Payload size still too big ("+a+" kb). Cropping fields.."),s.forEac
1h(function(e){for(var t in e){var i=e[t];"string"==typeof i&&i.length>51200&&(e[t]=i.substring(0,51200))}}),n()),r};var rR="function"==typeof rA.default.exitPictureInPicture?function(e){return e.length<=57344}:function(e){return!1},rI=function(e,t,i,r){if(i&&navigator&&navigator.sendBeacon&&navigator.sendBeacon(e,t))return void r();if(r_.default.fetch)return void r_.default.fetch(e,{method:"POST",body:t,headers:{"Content-Type":"text/plain"},keepalive:rR(t)}).then(function(e){return r(null,e.ok?null:"Error")}).catch(function(e){return r(null,e)});if(r_.default.XMLHttpRequest){var s=new r_.default.XMLHttpRequest;s.onreadystatechange=function(){if(4===s.readyState)return r(null,200!==s.status?"error":void 0)},s.open("POST",e),s.setRequestHeader("Content-Type","text/plain"),s.send(t);return}r()},rw=["env_key","view_id","view_sequence_number","player_sequence_number","beacon_domain","player_playhead_time","viewer_time","mux_api_version","event","video_id","player_instance_id","player_error_code","player_error_message","player_error_context","player_error_severity","player_error_business_exception","view_playing_time_ms_cumulative","ad_playing_time_ms_cumulative"],rD=["adplay","adplaying","adpause","adfirstquartile","admidpoint","adthirdquartile","adended","adresponse","adrequest"],rC=["ad_id","ad_creative_id","ad_universal_id"],rP=["viewstart","error","ended","viewend"],rx=function(){function e(t,i){var r,s,a,n,l,o,d,h,u,c,f,m,g,v,E,y,b,T,_,A=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};iS(this,e),iR(this,"mux",void 0),iR(this,"envKey",void 0),iR(this,"options",void 0),iR(this,"eventQueue",void 0),iR(this,"sampleRate",void 0),iR(this,"disableCookies",void 0),iR(this,"respectDoNotTrack",void 0),iR(this,"previousBeaconData",void 0),iR(this,"lastEventTime",void 0),iR(this,"rateLimited",void 0),iR(this,"pageLevelData",void 0),iR(this,"viewerData",void 0),this.mux=t,this.envKey=i,this.options=A,this.previousBeaconData=null,this.lastEventTime=0,this.rateLimited=!1,this.eventQueue=new rL((r=this.envKey,a=(s=this.options).beaconCollectionDomain,n=s.beaconDomain,a?"https://"+a:(r=r||"inferred").match(/^[a-z0-9]+$/)?"https://"+r+"."+(n||"litix.io"):"https://img.litix.io/a.gif")),this.sampleRate=null!=(b=this.options.sampleRate)?b:1,this.disableCookies=null!=(T=this.options.disableCookies)&&T,this.respectDoNotTrack=null!=(_=this.options.respectDoNotTrack)&&_,this.previousBeaconData=null,this.lastEventTime=0,this.rateLimited=!1,this.pageLevelData={mux_api_version:this.mux.API_VERSION,mux_embed:this.mux.NAME,mux_embed_version:this.mux.VERSION,viewer_application_name:null==(l=this.options.platform)?void 0:l.name,viewer_application_version:null==(o=this.options.platform)?void 0:o.version,viewer_application_engine:null==(d=this.options.platform)?void 0:d.layout,viewer_device_name:null==(h=this.options.platform)?void 0:h.product,viewer_device_category:"",viewer_device_manufacturer:null==(u=this.options.platform)?void 0:u.manufacturer,viewer_os_family:null==(f=this.options.platform)||null==(c=f.os)?void 0:c.family,viewer_os_architecture:null==(g=this.options.platform)||null==(m=g.os)?void 0:m.architecture,viewer_os_version:null==(E=this.options.platform)||null==(v=E.os)?void 0:v.version,viewer_connection_type:rg(),page_url:null===ro.default||void 0===ro.default||null==(y=ro.default.location)?void 0:y.href},this.viewerData=this.disableCookies?{}:rf()}return iL(e,[{key:"send",value:function(e,t){if(!(!e||!(null!=t&&t.view_id))){if(this.respectDoNotTrack&&i_())return ib.info("Not sending `"+e+"` because Do Not Track is enabled");if(!t||"object"!=typeof t)return ib.error("A data object was expected in send() but was not provided");var i=this.disableCookies?{}:rm(),r=i$(iF({},this.pageLevelData,t,i,this.viewerData),{event:e,env_key:this.envKey});r.user_id&&(r.viewer_user_id=r.user_id,delete r.user_id);var s,a=(null!=(s=r.mux_sample_number)?s:0)>=this.sampleRate,n=rT(this._deduplicateBeaconData(e,r));if(this.lastEventTime=this.mux.utils.now(),a)return ib.info("Not sending event due to sample rate restriction",e,r,n);if(this.envKey||ib.info("Missing environment key (envKey) - beacons will be dropped if the video source is not a valid mux video URL",e,r,n),!this.rateLimited)if(ib.info("Sending event",e,r,n),this.rateLimited=!this.eventQueue.queueEvent(e,n),this.mux.WINDOW_UNLOADING&&"viewend"===e)this.eventQueue.destroy(!0);else{if(this.mux.WINDOW_HIDDEN&&"hb"===e)this.eventQueue.flushEvents(!0);else if(rP.indexOf(e)>=0){if("error"===e&&"warning"===t.player_error_severity)return;this.eventQueue.flushEvents()}if(this.rateLimited)return r.event="eventrateexceeded",n=rT(r),this.eventQueue.queueEvent(r.event,n),ib.error("Beaconing disabled due to rate limit.")}}}},{key:"destroy",value:function(){this.eventQueue.destroy(!1)}},{key:"_deduplicateBeaconData",value:function(e,t){var i=this,r={},s=t.view_id;if("-1"===s||"viewstart"===e||"viewend"===e||!this.previousBeaconData||this.mux.utils.now()-this.lastEventTime>=6e5)r=iF({},t),s&&(this.previousBeaconData=r),s&&"viewend"===e&&(this.previousBeaconData=null);else{var a=0===e.indexOf("request");Object.entries(t).forEach(function(t){var s=id(t,2),n=s[0],l=s[1];i.previousBeaconData&&(l!==i.previousBeaconData[n]||rw.indexOf(n)>-1||i.objectHasChanged(a,n,l,i.previousBeaconData[n])||i.eventRequiresKey(e,n))&&
1(r[n]=l,i.previousBeaconData[n]=l)})}return r}},{key:"objectHasChanged",value:function(e,t,i,r){return!!e&&0===t.indexOf("request_")&&("request_response_headers"===t||"object"!=typeof i||"object"!=typeof r||Object.keys(i||{}).length!==Object.keys(r||{}).length)}},{key:"eventRequiresKey",value:function(e,t){return!!("renditionchange"===e&&0===t.indexOf("video_source_")||rC.includes(t)&&rD.includes(e)||"playbackmodechange"===e&&0===t.indexOf("player_playback_mode"))}}]),e}(),rM=function e(t){iS(this,e);var i=0,r=0,s=0,a=0,n=0,l=0,o=0;t.on("requestcompleted",function(e,l){var o,d,h=l.request_start,u=l.request_response_start,c=l.request_response_end,f=l.request_bytes_loaded;if(a++,u?(o=u-(null!=h?h:0),d=(null!=c?c:0)-u):d=(null!=c?c:0)-(null!=h?h:0),d>0&&f&&f>0){var m=f/d*8e3;n++,r+=f,s+=d,t.data.view_min_request_throughput=Math.min(t.data.view_min_request_throughput||1/0,m),t.data.view_average_request_throughput=r/s*8e3,t.data.view_request_count=a,o>0&&(i+=o,t.data.view_max_request_latency=Math.max(t.data.view_max_request_latency||0,o),t.data.view_average_request_latency=i/n)}}),t.on("requestfailed",function(e,i){a++,l++,t.data.view_request_count=a,t.data.view_request_failed_count=l}),t.on("requestcanceled",function(e,i){a++,o++,t.data.view_request_count=a,t.data.view_request_canceled_count=o})},rO=function e(t){var i=this;iS(this,e),iR(this,"_lastEventTime",void 0),t.on("before*",function(e,r){var s=r.viewer_time,a=im(),n=i._lastEventTime;if(i._lastEventTime=a,n&&a-n>36e5){var l=Object.keys(t.data).reduce(function(e,i){return 0===i.indexOf("video_")?Object.assign(e,iR({},i,t.data[i])):e},{});t.mux.log.info("Received event after at least an hour inactivity, creating a new view");var o=t.playbackHeartbeat._playheadShouldBeProgressing;t._resetView(Object.assign({viewer_time:s},l)),t.playbackHeartbeat._playheadShouldBeProgressing=o,t.playbackHeartbeat._playheadShouldBeProgressing&&"play"!==e.type&&"adbreakstart"!==e.type&&(t.emit("play",{viewer_time:s}),"playing"!==e.type&&t.emit("playing",{viewer_time:s}))}})};function rN(e,t){return(null==e?void 0:e.toLowerCase())===(null==t?void 0:t.toLowerCase())}var rU=function e(t){iS(this,e);var i=function(e){var i,r,s,l=null!=(i=e)&&i.request_type&&("media"===i.request_type||"video"===i.request_type)&&null!=(r=i.request_response_headers)&&r["x-cdn"]?i.request_response_headers["x-cdn"]:null!=i&&i.video_cdn?i.video_cdn:null,o=null!=(s=e)&&s.request_start?s.request_start:null!=s&&s.viewer_time?s.viewer_time:Date.now();null!=l&&!rN(l,a)&&n<=o&&(a=l,n=o,t.emit("cdnchange",{video_cdn:l}))},r=null,s=null,a=null,n=0;t.on("viewinit",function(){r=null,s=null,a=null,n=0}),t.on("beforecdnchange",function(e,t){var i=null==t?void 0:t.video_cdn;i&&(void 0===t.video_previous_cdn||null===t.video_previous_cdn)&&(rN(i,s)?t.video_previous_cdn=null!=r?r:void 0:(t.video_previous_cdn=null!=s?s:void 0,r=s,s=i))}),t.on("requestcompleted",function(e,t){i(t)})},rF=function(e){try{return JSON.parse(e),!0}catch(e){return!1}},r$=function e(t){var i=this;iS(this,e),iR(this,"_emittingAutomaticEvent",!1),iR(this,"_hasInitialized",!1),iR(this,"_currentMode","standard"),t.on("viewstart",function(){i._hasInitialized||(i._hasInitialized=!0,i._currentMode=t.data.player_playback_mode||"standard",i._emittingAutomaticEvent=!0,t.emit("playbackmodechange",{player_playback_mode:i._currentMode,player_playback_mode_data:"{}"}),i._emittingAutomaticEvent=!1)}),t.on("viewend",function(){i._hasInitialized=!1}),t.on("playbackmodechange",function(e,r){i._emittingAutomaticEvent||(r.player_playback_mode_data?rF(r.player_playback_mode_data)||(t.mux.log.warn("Invalid JSON string for player_playback_mode_data"),r.player_playback_mode_data="{}"):r.player_playback_mode_data="{}",t.data.player_playback_mode_data=r.player_playback_mode_data,t.data.player_playback_mode=r.player_playback_mode,i._currentMode=r.player_playback_mode)})},rB=function(){function e(t){iS(this,e),iR(this,"pm",void 0),iR(this,"_currentRangeStart",void 0),iR(this,"_lastPlayheadTime",void 0),this.pm=t,this._currentRangeStart=null,this._lastPlayheadTime=null,t.on("playbackheartbeat",this._updatePlaybackRange.bind(this)),t.on("playbackheartbeatend",this._endPlaybackRange.bind(this))}return iL(e,[{key:"_updateLastRangeEnd",value:function(){var e=this.pm.data.video_playback_ranges;if(e&&e.length>0){var t=this.pm.data.player_playhead_time||0;e[e.length-1][1]=t}}},{key:"_updatePlaybackRange",value:function(){var e,t=this.pm.data.player_playhead_time||0;if(!(!this.pm.disableAdPlaybackRangeFiltering&&null!=(e=this.pm.adTracker)&&e.isAdBreak&&null!==this._lastPlayheadTime&&t<this._lastPlayheadTime)){if(null!==this._lastPlayheadTime&&null!==this._currentRangeStart&&Math.abs(t-this._lastPlayheadTime)>1e3){var i=this.pm.data.video_playback_ranges;i&&i.length>0&&(i[i.length-1][1]=this._lastPlayheadTime),this._currentRangeStart=null}if(null===this._currentRangeStart){var r=this.pm.data.video_playback_ranges||[];r.length>0&&r[r.length-1][1]===t?this._currentRangeStart=r[r.length-1][0]:(this._currentRangeStart=t,r.push([t,t])),this.pm.data.video_playback_ranges=r}else this._updateLastRangeEnd();this._lastPlayheadTime=t}}},{key:"_endPlaybackRange",value:function(){null!==this._currentRangeStart&&(this._updateLastRangeEnd(),this._currentRangeStart=null,this._lastPlayheadTime=null)}}]),e}(),rH=["viewstart","ended","loadstart","pause","play","playing","ratechange","waiting","adplay","adpause","adended","aderror","adplaying","adrequest","adresponse","adbreakstart","adbreakend","adfirstquartile","admidpoint","adthirdquartile","rebufferstart","rebufferend","seeked","error","hb","requestcompleted","requestfailed","requestcanceled","renditionchange","cdnchange","playbackmodechange"],rG=new Set(["requestcompleted","requestfailed","requestcanceled"]),rV=function(e){if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&iD(r,e);var t,i=(t=function(){if("u"<typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}(),function(){var e,i=iI(r);return e=t?Reflect.construct(i,arguments,iI(this).constructor):i.apply(this,arguments),e&&("object"===t1(e)||"function"==typeof e)?e:iA(this)});function r(e,t,s){iS(this,r),iR(iA(a=i.call(this)),"pageLoadEndTime",void 0),iR(iA(a),"pageLoadInitTime",void 0),iR(iA(a),"_destroyed",void 0),iR(iA(a),"_heartBeatTimeout",void 0),iR(iA(a),"adTracker",void 0),iR(iA(a),"dashjs",void 0),iR(iA(a),"data",void 0),iR(iA(a),"disablePlayheadRebufferTracking",void 0),iR(iA(a),"disableRebufferTracking",void 0),iR(iA(a),"disableAdPlaybackRangeFiltering",void 0),iR(iA(a),"errorTracker",void 0),iR(iA(a),"errorTranslator",void 0),iR(iA(a),"emitTranslator",void 0),iR(iA(a),"getAdData",void 0),iR(iA(a),"getPlayheadTime",void 0),iR(iA(a),"getStateData",void 0),iR(iA(a),"stateDataTranslator",void 0),iR(iA(a),"hlsjs",void 0),iR(iA(a),"id",void 0),iR(iA(a),"longResumeTracker",void 0),iR(iA(a),"minimumRebufferDuration",void 0),iR(iA(a),"mux",void 0),iR(iA(a),"playbackEventDispatcher",void 0),iR(iA(a),"playbackHeartbeat",void 0),iR(iA(a),"playbackHeartbeatTime",void 0),iR(iA(a),"playheadTime",void 0),iR(iA(a),"seekingTracker",void 0),iR(iA(a),"sustainedRebufferThreshold",void 0),iR(iA(a),"watchTimeTracker",void 0),iR(iA(a),"currentFragmentPDT",void 0),iR(iA(a),"currentFragmentStart",void 0),a.pageLoadInitTime=iN(),a.pageLoadEndTime=iO(),a.mux=e,a.id=t,null!=s&&s.beaconDomain&&a.mux.log.warn("The `beaconDomain` setting has been deprecated 
1in favor of `beaconCollectionDomain`. Please change your integration to use `beaconCollectionDomain` instead of `beaconDomain`."),(s=Object.assign({debug:!1,minimumRebufferDuration:250,sustainedRebufferThreshold:1e3,playbackHeartbeatTime:25,beaconDomain:"litix.io",sampleRate:1,disableCookies:!1,respectDoNotTrack:!1,disableRebufferTracking:!1,disablePlayheadRebufferTracking:!1,disableAdPlaybackRangeFiltering:!1,errorTranslator:function(e){return e},emitTranslator:function(){for(var e=arguments.length,t=Array(e),i=0;i<e;i++)t[i]=arguments[i];return t},stateDataTranslator:function(e){return e}},s)).data=s.data||{},s.data.property_key&&(s.data.env_key=s.data.property_key,delete s.data.property_key),ib.level=s.debug?1:3,a.getPlayheadTime=s.getPlayheadTime,a.getStateData=s.getStateData||function(){return{}},a.getAdData=s.getAdData||function(){},a.minimumRebufferDuration=s.minimumRebufferDuration,a.sustainedRebufferThreshold=s.sustainedRebufferThreshold,a.playbackHeartbeatTime=s.playbackHeartbeatTime,a.disableRebufferTracking=s.disableRebufferTracking,a.disableRebufferTracking&&a.mux.log.warn("Disabling rebuffer tracking. This should only be used in specific circumstances as a last resort when your player is known to unreliably track rebuffering."),a.disablePlayheadRebufferTracking=s.disablePlayheadRebufferTracking,a.disableAdPlaybackRangeFiltering=s.disableAdPlaybackRangeFiltering,a.errorTranslator=s.errorTranslator,a.emitTranslator=s.emitTranslator,a.stateDataTranslator=s.stateDataTranslator,a.playbackEventDispatcher=new rx(e,s.data.env_key,s),a.data={player_instance_id:ip(),mux_sample_rate:s.sampleRate,beacon_domain:s.beaconCollectionDomain||s.beaconDomain},a.data.view_sequence_number=1,a.data.player_sequence_number=1;var a,n=(function(){void 0===this.data.view_start&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"),this.emit("renditionchange"))}).bind(iA(a));if(a.on("viewinit",function(e,t){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),Object.assign(this.data,t),this._initializeViewData(),this.one("play",n),this.one("adbreakstart",n)}),a.on("videochange",function(e,t){this._resetView(t)}),a.on("programchange",function(e,t){this.data.player_is_paused&&this.mux.log.warn("The `programchange` event is intended to be used when the content changes mid playback without the video source changing, however the video is not currently playing. If the video source is changing please use the videochange event otherwise you will lose startup time information."),this._resetView(Object.assign(t,{view_program_changed:!0})),n(),this.emit("play"),this.emit("playing")}),a.on("fragmentchange",function(e,t){this.currentFragmentPDT=t.currentFragmentPDT,this.currentFragmentStart=t.currentFragmentStart}),a.on("destroy",a.destroy),"u">typeof window&&"function"==typeof window.addEventListener&&"function"==typeof window.removeEventListener){var l=function(){var e=void 0!==a.data.view_start;a.mux.WINDOW_HIDDEN="hidden"===document.visibilityState,e&&a.mux.WINDOW_HIDDEN&&(a.data.player_is_paused||a.emit("hb"))};window.addEventListener("visibilitychange",l,!1);var o=function(e){e.persisted||a.destroy()};window.addEventListener("pagehide",o,!1),a.on("destroy",function(){window.removeEventListener("visibilitychange",l),window.removeEventListener("pagehide",o)})}return a.on("playerready",function(e,t){Object.assign(this.data,t)}),rH.forEach(function(e){a.on(e,function(t,i){0!==e.indexOf("ad")&&this._updateStateData(),Object.assign(this.data,i),this._sanitizeData()}),a.on("after"+e,function(){("error"!==e||this.errorTracker.viewErrored)&&this.send(e)})}),a.on("viewend",function(e,t){Object.assign(a.data,t)}),a.one("playerready",function(e){var t=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=t-this.data.player_init_time),this.pageLoadInitTime=this.data.page_load_init_time||this.pageLoadInitTime,this.pageLoadEndTime=this.data.page_load_end_time||this.pageLoadEndTime,!this.mux.PLAYER_TRACKED&&this.pageLoadInitTime&&(this.mux.PLAYER_TRACKED=!0,(this.data.player_init_time||this.pageLoadEndTime)&&(this.data.page_load_time=Math.min(this.data.player_init_time||1/0,this.pageLoadEndTime||1/0)-this.pageLoadInitTime)),this.send("playerready"),delete this.data.player_startup_time,delete this.data.page_load_time}),a.longResumeTracker=new rO(iA(a)),a.errorTracker=new i5(iA(a)),new rl(iA(a)),a.seekingTracker=new rr(iA(a)),a.playheadTime=new i9(iA(a)),a.playbackHeartbeat=new i4(iA(a)),new ri(iA(a)),a.watchTimeTracker=new i8(iA(a)),new i6(iA(a)),new rB(iA(a)),a.adTracker=new rn(iA(a)),new re(iA(a)),new i7(iA(a)),new rt(iA(a)),new rM(iA(a)),new rU(iA(a)),new r$(iA(a)),s.hlsjs&&a.addHLSJS(s),s.dashjs&&a.addD
1ashJS(s),a.emit("viewinit",s.data),a}return iL(r,[{key:"emit",value:function(e,t){var i,s=Object.assign({viewer_time:this.mux.utils.now()},t),a=[e,s];if(this.emitTranslator)try{a=this.emitTranslator(e,s)}catch(e){this.mux.log.warn("Exception in emit translator callback.",e)}null!=a&&a.length&&(i=iw(iI(r.prototype),"emit",this)).call.apply(i,[this].concat(iy(a)))}},{key:"destroy",value:function(){this._destroyed||(this._destroyed=!0,void 0!==this.data.view_start&&(this.emit("viewend"),this.send("viewend")),this.playbackEventDispatcher.destroy(),this.removeHLSJS(),this.removeDashJS(),window.clearTimeout(this._heartBeatTimeout))}},{key:"send",value:function(e){if(this.data.view_id){var t=Object.assign({},this.data);if(void 0===t.video_source_is_live&&(t.player_source_duration===1/0||t.video_source_duration===1/0?t.video_source_is_live=!0:(t.player_source_duration>0||t.video_source_duration>0)&&(t.video_source_is_live=!1)),t.video_source_is_live||["player_program_time","player_manifest_newest_program_time","player_live_edge_program_time","player_program_time","video_holdback","video_part_holdback","video_target_duration","video_part_target_duration"].forEach(function(e){t[e]=void 0}),t.video_source_url=t.video_source_url||t.player_source_url,t.video_source_url){var i=id(iP(t.video_source_url),2),r=i[0];t.video_source_domain=i[1],t.video_source_hostname=r}delete t.ad_request_id,t.video_playback_ranges&&(t.video_playback_range=JSON.stringify(t.video_playback_ranges.filter(function(e){return e[0]!==e[1]}).map(function(e){return"".concat(e[0],":").concat(e[1])})),delete t.video_playback_ranges),this.playbackEventDispatcher.send(e,t),this.data.view_sequence_number++,this.data.player_sequence_number++,rG.has(e)||this._restartHeartBeat(),"viewend"===e&&delete this.data.view_id}}},{key:"_resetView",value:function(e){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",e)}},{key:"_updateStateData",value:function(){var e,t=this.getStateData();if("function"==typeof this.stateDataTranslator)try{t=this.stateDataTranslator(t)}catch(e){this.mux.log.warn("Exception in stateDataTranslator translator callback.",e)}null!=(e=this.data)&&e.video_cdn&&null!=t&&t.video_cdn&&(t.video_cdn,t=function(e,t){if(null==e)return{};var i,r,s=function(e,t){if(null==e)return{};var i,r,s={},a=Object.keys(e);for(r=0;r<a.length;r++)i=a[r],t.indexOf(i)>=0||(s[i]=e[i]);return s}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)i=a[r],!(t.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(e,i)&&(s[i]=e[i])}return s}(t,["video_cdn"])),Object.assign(this.data,t),this.playheadTime._updatePlayheadTime(),this._sanitizeData()}},{key:"_sanitizeData",value:function(){var e=this;["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"].forEach(function(t){var i=parseInt(e.data[t],10);e.data[t]=isNaN(i)?void 0:i}),["player_source_url","video_source_url"].forEach(function(t){if(e.data[t]){var i=e.data[t].toLowerCase();(0===i.indexOf("data:")||0===i.indexOf("blob:"))&&(e.data[t]="MSE style URL")}})}},{key:"_resetVideoData",value:function(){var e=this;Object.keys(this.data).forEach(function(t){0===t.indexOf("video_")&&delete e.data[t]})}},{key:"_resetViewData",value:function(){var e=this;Object.keys(this.data).forEach(function(t){0===t.indexOf("view_")&&delete e.data[t]}),this.data.view_sequence_number=1}},{key:"_resetErrorData",value:function(){delete this.data.player_error_code,delete this.data.player_error_message,delete this.data.player_error_context,delete this.data.player_error_severity,delete this.data.player_error_business_exception}},{key:"_initializeViewData",value:function(){var e=this,t=this.data.view_id=ip(),i=function(){t===e.data.view_id&&iU(e.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",i):i()}},{key:"_restartHeartBeat",value:function(){var e=this;window.clearTimeout(this._heartBeatTimeout),this._heartBeatTimeout=window.setTimeout(function(){e.data.player_is_paused||e.emit("hb")},1e4)}},{key:"addHLSJS",value:function(e){e.hlsjs?this.hlsjs?this.mux.log.warn("An instance of HLS.js is already being monitored for this player."):(this.hlsjs=e.hlsjs,ij(this.mux,this.id,e.hlsjs,{},e.Hls||window.Hls)):this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.")}},{key:"removeHLSJS",value:function(){this.hlsjs&&(iY(this.hlsjs),this.hlsjs=void 0)}},{key:"addDashJS",value:function(e){e.dashjs?this.dashjs?this.mux.log.warn("An instance of Dash.js is already being monitored for this player."):(this.dashjs=e.dashjs,iJ(this.mux,this.id,e.dashjs)):this.mux.log.warn("You must pass a valid dashjs instance in order to track it.")}},{key:"removeDashJS",value:function(){this.dashjs&&(i0(this.dashjs),this.dashjs=void 0)}}]),r}(i2),rK=tX(ia());function rW(){return rK.default&&!!(rK.default.fullscreenElement||rK.default.webkitFullscreenElement||rK.default.mozFullScreenElement||rK.default.msFullscreenElement)}var rq,rj,rY=["loadstart","pause","play","playing","seeking","seeked","timeupdate","ratechange","stalled","waiting","error","ended"],rQ={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"},rz=tX(tZ());rz.default&&rz.default.WeakMap&&(rj=new WeakMap);var rX=function(e){return this.buffer="",this.manifest={segments:[],serverControl:{},sessionData:{}},this.currentUri={},this.process(e),this.manifest};rX.prototype.process=function(e){var t;for(this.buffer+=e,t=this.buffer.indexOf("\n");t>-1;t=this.buffer.indexOf("\n"))this.processLine(this.buffer.substring(0,t)),this.buffer=this.buffer.substring(t+1)}
1,rX.prototype.processLine=function(e){var t=e.indexOf(":"),i=r4(e,t),r=i[0],s=2===i.length?r0(i[1]):void 0;if("#"!==r[0])this.currentUri.uri=r,this.manifest.segments.push(this.currentUri),!this.manifest.targetDuration||"duration"in this.currentUri||(this.currentUri.duration=this.manifest.targetDuration),this.currentUri={};else switch(r){case"#EXT-X-TARGETDURATION":if(!isFinite(s)||s<0)return;this.manifest.targetDuration=s,this.setHoldBack();break;case"#EXT-X-PART-INF":rZ(this.manifest,i),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),this.setHoldBack();break;case"#EXT-X-SERVER-CONTROL":rZ(this.manifest,i),this.setHoldBack();break;case"#EXTINF":0===s?this.currentUri.duration=.01:s>0&&(this.currentUri.duration=s);break;case"#EXT-X-PROGRAM-DATE-TIME":var a=new Date(s);this.manifest.dateTimeString||(this.manifest.dateTimeString=s,this.manifest.dateTimeObject=a),this.currentUri.dateTimeString=s,this.currentUri.dateTimeObject=a;break;case"#EXT-X-VERSION":rZ(this.manifest,i);break;case"#EXT-X-SESSION-DATA":var n=iK(r5(i[1]));Object.assign(this.manifest.sessionData,n)}},rX.prototype.setHoldBack=function(){var e=this.manifest,t=e.serverControl,i=e.targetDuration,r=e.partTargetDuration;if(t){var s="holdBack",a="partHoldBack",n=i&&3*i,l=r&&2*r;i&&!t.hasOwnProperty(s)&&(t[s]=n),n&&t[s]<n&&(t[s]=n),r&&!t.hasOwnProperty(a)&&(t[a]=3*r),r&&t[a]<l&&(t[a]=l)}};var rZ=function(e,t){var i,r=rJ(t[0].replace("#EXT-X-",""));r3(t[1])?(i={},i=Object.assign(r2(t[1]),i)):i=r0(t[1]),e[r]=i},rJ=function(e){return e.toLowerCase().replace(/-(\w)/g,function(e){return e[1].toUpperCase()})},r0=function(e){if("yes"===e.toLowerCase()||"no"===e.toLowerCase())return"yes"===e.toLowerCase();var t=-1!==e.indexOf(":")?e:parseFloat(e);return isNaN(t)?e:t},r1=function(e){var t={},i=e.split("=");return i.length>1&&(t[rJ(i[0])]=r0(i[1])),t},r2=function(e){for(var t=e.split(","),i={},r=0;t.length>r;r++)i=Object.assign(r1(t[r]),i);return i},r3=function(e){return e.indexOf("=")>-1},r4=function(e,t){return -1===t?[e]:[e.substring(0,t),e.substring(t+1)]},r5=function(e){var t={};if(e){var i=e.search(",");return[e.slice(0,i),e.slice(i+1)].forEach(function(e,i){for(var r=e.replace(/['"]+/g,"").split("="),s=0;s<r.length;s++)"DATA-ID"===r[s]&&(t["DATA-ID"]=r[1-s]),"VALUE"===r[s]&&(t.VALUE=r[1-s])}),{data:t}}},r8={safeCall:function(e,t,i,r){var s=r;if(e&&"function"==typeof e[t])try{s=e[t].apply(e,i)}catch(e){ib.info("safeCall error",e)}return s},safeIncrement:iU,getComputedStyle:function(e,t){var i;return e&&t&&rz.default&&"function"==typeof rz.default.getComputedStyle?(rj&&rj.has(e)&&(i=rj.get(e)),i||(i=rz.default.getComputedStyle(e,null),rj&&rj.set(e,i)),i.getPropertyValue(t)):""},secondsToMs:function(e){return Math.floor(1e3*e)},assign:Object.assign,headersStringToObject:iG,cdnHeadersToRequestId:iV,extractHostnameAndDomain:iP,extractHostname:iC,manifestParser:rX,generateShortID:ig,generateUUID:ip,now:im,findMediaElement:iE},r6={},r9=function(e){var t=arguments;"string"==typeof e?r9.hasOwnProperty(e)?ih.default.setTimeout(function(){t=Array.prototype.splice.call(t,1),r9[e].apply(null,t)},0):ib.warn("`"+e+"` is an unknown task"):"function"==typeof e?ih.default.setTimeout(function(){e(r9)},0):ib.warn("`"+e+"` is invalid.")},r7={loaded:im(),NAME:"mux-embed",VERSION:"5.17.10",API_VERSION:"2.1",PLAYER_TRACKED:!1,monitor:function(e,t){return function(e,t,i){var r=id(iE(t),3),s=r[0],a=r[1],n=r[2],l=e.log,o=e.utils.getComputedStyle,d=e.utils.secondsToMs;if(!s)return l.error("No element was found with the `"+a+"` query selector.");if("video"!==n&&"audio"!==n)return l.error("The element of `"+a+"` was not a media element.");s.mux&&(s.mux.destroy(),delete s.mux,l.warn("Already monitoring this video element, replacing existing event listeners")),(i=Object.assign({automaticErrorTracking:!0},i,{getPlayheadTime:function(){return d(s.currentTime)},getStateData:function(){var e,t,i=(null==(e=this.getPlayheadTime)?void 0:e.call(this))||d(s.currentTime),r=this.hlsjs&&this.hlsjs.url,a=this.dashjs&&"function"==typeof this.dashjs.getSource&&this.dashjs.getSource(),n={player_is_paused:s.paused,player_width:parseInt(o(s,"width")),player_height:parseInt(o(s,"height")),player_autoplay_on:s.autoplay,player_preload_on:s.preload,player_language_code:s.lang,player_is_fullscreen:rW(),video_poster_url:s.poster,video_source_url:r||a||s.currentSrc,video_source_duration:d(s.duration),video_source_height:s.videoHeight,video_source_width:s.videoWidth,view_dropped_frame_count:null==s||null==(t=s.getVideoPlaybackQuality)?void 0:t.call(s).droppedVideoFrames};if(s.getStartDate&&i>0){var l=s.getStartDate();if(l&&"function"==typeof l.getTime&&l.getTime()){var h=l.getTime();n.player_program_time=h+i,s.seekable.length>0&&(n.player_live_edge_program_time=h+s.seekable.end(s.seekable.length-1))}}return n}})).data=Object.assign({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:e.VERSION},i.data),s.mux=s.mux||{},s.mux.deleted=!1,s.mux.emit=function(t,i){e.emit(a,t,i)},s.mux.updateData=function(e){s.mux.emit("hb",e)};var h=function(){l.error("The monitor for this video element has already been destroyed.")};
1s.mux.destroy=function(){Object.keys(s.mux.listeners).forEach(function(e){s.removeEventListener(e,s.mux.listeners[e],!1)}),delete s.mux.listeners,s.mux.fullscreenChangeListener&&(document.removeEventListener("fullscreenchange",s.mux.fullscreenChangeListener,!1),delete s.mux.fullscreenChangeListener),s.mux.destroy=h,s.mux.swapElement=h,s.mux.emit=h,s.mux.addHLSJS=h,s.mux.addDashJS=h,s.mux.removeHLSJS=h,s.mux.removeDashJS=h,s.mux.updateData=h,s.mux.setEmitTranslator=h,s.mux.setStateDataTranslator=h,s.mux.setGetPlayheadTime=h,s.mux.deleted=!0,e.emit(a,"destroy")},s.mux.swapElement=function(t){var i=id(iE(t),3),r=i[0],a=i[1],n=i[2];return r?"video"!==n&&"audio"!==n?e.log.error("The element of `"+a+"` was not a media element."):void(r.muxId=s.muxId,delete s.muxId,r.mux=r.mux||{},r.mux.listeners=Object.assign({},s.mux.listeners),delete s.mux.listeners,Object.keys(r.mux.listeners).forEach(function(e){s.removeEventListener(e,r.mux.listeners[e],!1),r.addEventListener(e,r.mux.listeners[e],!1)}),r.mux.fullscreenChangeListener=s.mux.fullscreenChangeListener,delete s.mux.fullscreenChangeListener,r.mux.swapElement=s.mux.swapElement,r.mux.destroy=s.mux.destroy,delete s.mux,s=r):e.log.error("No element was found with the `"+a+"` query selector.")},s.mux.addHLSJS=function(t){e.addHLSJS(a,t)}
1,s.mux.addDashJS=function(t){e.addDashJS(a,t)},s.mux.removeHLSJS=function(){e.removeHLSJS(a)},s.mux.removeDashJS=function(){e.removeDashJS(a)},s.mux.setEmitTranslator=function(t){e.setEmitTranslator(a,t)},s.mux.setStateDataTranslator=function(t){e.setStateDataTranslator(a,t)},s.mux.setGetPlayheadTime=function(t){t||(t=i.getPlayheadTime),e.setGetPlayheadTime(a,t)},e.init(a,i),e.emit(a,"playerready"),s.paused||(e.emit(a,"play"),s.readyState>2&&e.emit(a,"playing")),s.mux.listeners={},rY.forEach(function(t){("error"!==t||i.automaticErrorTracking)&&(s.mux.listeners[t]=function(){var i={};if("error"===t){if(!s.error||1===s.error.code)return;i.player_error_code=s.error.code,i.player_error_message=rQ[s.error.code]||s.error.message}e.emit(a,t,i)},s.addEventListener(t,s.mux.listeners[t],!1))}),s.mux.listeners.enterpictureinpicture=function(){e.emit(a,"playbackmodechange",{player_playback_mode:"pip",player_playback_mode_data:"{}"})},s.mux.listeners.leavepictureinpicture=function(){var t=rW()?"fullscreen":"standard";e.emit(a,"playbackmodechange",{player_playback_mode:t,player_playback_mode_data:"{}"})},s.addEventListener("enterpictureinpicture",s.mux.listeners.enterpictureinpicture,!1),s.addEventListener("leavepictureinpicture",s.mux.listeners.leavepictureinpicture,!1),s.mux.fullscreenChangeListener=function(){var t=rW(),i=document.fullscreenElement;if(t&&(i===s||null!=i&&i.contains(s)))e.emit(a,"playbackmodechange",{player_playback_mode:"fullscreen",player_playback_mode_data:"{}"});else if(!t){var r=document.pictureInPictureElement===s;e.emit(a,"playbackmodechange",{player_playback_mode:r?"pip":"standard",player_playback_mode_data:"{}"})}},document.addEventListener("fullscreenchange",s.mux.fullscreenChangeListener,!1)}(r9,e,t)},destroyMonitor:function(e){var t=id(iE(e),1)[0];t&&t.mux&&"function"==typeof t.mux.destroy?t.mux.destroy():ib.error("A video element monitor for `"+e+"` has not been initialized via `mux.monitor`.")},addHLSJS:function(e,t){var i=iv(e);r6[i]?r6[i].addHLSJS(t):ib.error("A monitor for `"+i+"` has not been initialized.")},addDashJS:function(e,t){var i=iv(e);r6[i]?r6[i].addDashJS(t):ib.error("A monitor for `"+i+"` has not been initialized.")},removeHLSJS:function(e){var t=iv(e);r6[t]?r6[t].removeHLSJS():ib.error("A monitor for `"+t+"` has not been initialized.")},removeDashJS:function(e){var t=iv(e);r6[t]?r6[t].removeDashJS():ib.error("A monitor for `"+t+"` has not been initialized.")},init:function(e,t){i_()&&t&&t.respectDoNotTrack&&ib.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var i=iv(e);r6[i]=new rV(r9,i,t)},emit:function(e,t,i){var r=iv(e);r6[r]?(r6[r].emit(t,i),"destroy"===t&&delete r6[r]):ib.error("A monitor for `"+r+"` has not been initialized.")},updateData:function(e,t){var i=iv(e);r6[i]?r6[i].emit("hb",t):ib.error("A monitor for `"+i+"` has not been initialized.")},setEmitTranslator:function(e,t){var i=iv(e);r6[i]?r6[i].emitTranslator=t:ib.error("A monitor for `"+i+"` has not been initialized.")},setStateDataTranslator:function(e,t){var i=iv(e);r6[i]?r6[i].stateDataTranslator=t:ib.error("A monitor for `"+i+"` has not been initialized.")},setGetPlayheadTime:function(e,t){var i=iv(e);r6[i]?r6[i].getPlayheadTime=t:ib.error("A monitor for `"+i+"` has not been initialized.")},checkDoNotTrack:i_,log:ib,utils:r8,events:{PLAYER_READY:"playerready",VIEW_INIT:"viewinit",VIDEO_CHANGE:"videochange",PLAY:"play",PAUSE:"pause",PLAYING:"playing",TIME_UPDATE:"timeupdate",SEEKING:"seeking",SEEKED:"seeked",REBUFFER_START:"rebufferstart",REBUFFER_END:"rebufferend",ERROR:"error",ENDED:"ended",RENDITION_CHANGE:"renditionchange",ORIENTATION_CHANGE:"orientationchange",PLAYBACK_MODE_CHANGE:"playbackmodechange",AD_REQUEST:"adrequest",AD_RESPONSE:"adresponse",AD_BREAK_START:"adbreakstart",AD_PLAY:"adplay",AD_PLAYING:"adplaying",AD_PAUSE:"adpause",AD_FIRST_QUARTILE:"adfirstquartile",AD_MID_POINT:"admidpoint",AD_THIRD_QUARTILE:"adthirdquartile",AD_ENDED:"adended",AD_BREAK_END:"adbreakend",AD_ERROR:"aderror",REQUEST_COMPLETED:"requestcompleted",REQUEST_FAILED:"requestfailed",REQUEST_CANCELLED:"requestcanceled",HEARTBEAT:"hb",DESTROY:"destroy"},WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign(r9,r7),void 0!==ih.default&&"function"==typeof ih.default.addEventListener&&ih.default.addEventListener("pagehide",function(e){e.persisted||(r9.WINDOW_UNLOADING=!0)},!1);let se=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},st=Number.isSafeInteger||function(e){return"number"==typeof e&&Math.abs(e)<=si},si=Number.MAX_SAFE_INTEGER||0x1fffffffffffff,sr=((uT={}
1).NETWORK_ERROR="networkError",uT.MEDIA_ERROR="mediaError",uT.KEY_SYSTEM_ERROR="keySystemError",uT.MUX_ERROR="muxError",uT.OTHER_ERROR="otherError",uT),ss=((u_={}).KEY_SYSTEM_NO_KEYS="keySystemNoKeys",u_.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",u_.KEY_SYSTEM_NO_SESSION="keySystemNoSession",u_.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",u_.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",u_.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",u_.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",u_.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",u_.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",u_.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",u_.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR="keySystemDestroyMediaKeysError",u_.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR="keySystemDestroyCloseSessionError",u_.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR="keySystemDestroyRemoveSessionError",u_.MANIFEST_LOAD_ERROR="manifestLoadError",u_.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",u_.MANIFEST_PARSING_ERROR="manifestParsingError",u_.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",u_.LEVEL_EMPTY_ERROR="levelEmptyError",u_.LEVEL_LOAD_ERROR="levelLoadError",u_.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",u_.LEVEL_PARSING_ERROR="levelParsingError",u_.LEVEL_SWITCH_ERROR="levelSwitchError",u_.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",u_.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",u_.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",u_.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",u_.FRAG_LOAD_ERROR="fragLoadError",u_.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",u_.FRAG_DECRYPT_ERROR="fragDecryptError",u_.FRAG_PARSING_ERROR="fragParsingError",u_.FRAG_GAP="fragGap",u_.REMUX_ALLOC_ERROR="remuxAllocError",u_.KEY_LOAD_ERROR="keyLoadError",u_.KEY_LOAD_TIMEOUT="keyLoadTimeOut",u_.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",u_.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",u_.BUFFER_APPEND_ERROR="bufferAppendError",u_.BUFFER_APPENDING_ERROR="bufferAppendingError",u_.BUFFER_STALLED_ERROR="bufferStalledError",u_.BUFFER_FULL_ERROR="bufferFullError",u_.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",u_.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",u_.ASSET_LIST_LOAD_ERROR="assetListLoadError",u_.ASSET_LIST_LOAD_TIMEOUT="assetListLoadTimeout",u_.ASSET_LIST_PARSING_ERROR="assetListParsingError",u_.INTERSTITIAL_ASSET_ITEM_ERROR="interstitialAssetItemError",u_.INTERNAL_EXCEPTION="internalException",u_.INTERNAL_ABORTED="aborted",u_.ATTACH_MEDIA_ERROR="attachMediaError",u_.UNKNOWN="unknown",u_),sa=((uA={}).MEDIA_ATTACHING="hlsMediaAttaching",uA.MEDIA_ATTACHED="hlsMediaAttached",uA.MEDIA_DETACHING="hlsMediaDetaching",uA.MEDIA_DETACHED="hlsMediaDetached",uA.MEDIA_ENDED="hlsMediaEnded",uA.STALL_RESOLVED="hlsStallResolved",uA.BUFFER_RESET="hlsBufferReset",uA.BUFFER_CODECS="hlsBufferCodecs",uA.BUFFER_CREATED="hlsBufferCreated",uA.BUFFER_APPENDING="hlsBufferAppending",uA.BUFFER_APPENDED="hlsBufferAppended",uA.BUFFER_EOS="hlsBufferEos",uA.BUFFERED_TO_END="hlsBufferedToEnd",uA.BUFFER_FLUSHING="hlsBufferFlushing",uA.BUFFER_FLUSHED="hlsBufferFlushed",uA.MANIFEST_LOADING="hlsManifestLoading",uA.MANIFEST_LOADED="hlsManifestLoaded",uA.MANIFEST_PARSED="hlsManifestParsed",uA.LEVEL_SWITCHING="hlsLevelSwitching",uA.LEVEL_SWITCHED="hlsLevelSwitched",uA.LEVEL_LOADING="hlsLevelLoading",uA.LEVEL_LOADED="hlsLevelLoaded",uA.LEVEL_UPDATED="hlsLevelUpdated",uA.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",uA.LEVELS_UPDATED="hlsLevelsUpdated",uA.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",uA.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",uA.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",uA.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",uA.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",uA.AUDIO_TRACK_UPDATED="hlsAudioTrackUpdated",uA.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",uA.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",uA.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",uA.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",uA.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",uA.SUBTITLE_TRACK_UPDATED="hlsSubtitleTrackUpdated",uA.SUBTITLE_FRAG_PROCESSED="hl
1sSubtitleFragProcessed",uA.CUES_PARSED="hlsCuesParsed",uA.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",uA.INIT_PTS_FOUND="hlsInitPtsFound",uA.FRAG_LOADING="hlsFragLoading",uA.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",uA.FRAG_LOADED="hlsFragLoaded",uA.FRAG_DECRYPTED="hlsFragDecrypted",uA.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",uA.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",uA.FRAG_PARSING_METADATA="hlsFragParsingMetadata",uA.FRAG_PARSED="hlsFragParsed",uA.FRAG_BUFFERED="hlsFragBuffered",uA.FRAG_CHANGED="hlsFragChanged",uA.FPS_DROP="hlsFpsDrop",uA.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",uA.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",uA.ERROR="hlsError",uA.DESTROYING="hlsDestroying",uA.KEY_LOADING="hlsKeyLoading",uA.KEY_LOADED="hlsKeyLoaded",uA.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",uA.BACK_BUFFER_REACHED="hlsBackBufferReached",uA.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",uA.ASSET_LIST_LOADING="hlsAssetListLoading",uA.ASSET_LIST_LOADED="hlsAssetListLoaded",uA.INTERSTITIALS_UPDATED="hlsInterstitialsUpdated",uA.INTERSTITIALS_BUFFERED_TO_BOUNDARY="hlsInterstitialsBufferedToBoundary",uA.INTERSTITIAL_ASSET_PLAYER_CREATED="hlsInterstitialAssetPlayerCreated",uA.INTERSTITIAL_STARTED="hlsInterstitialStarted",uA.INTERSTITIAL_ASSET_STARTED="hlsInterstitialAssetStarted",uA.INTERSTITIAL_ASSET_ENDED="hlsInterstitialAssetEnded",uA.INTERSTITIAL_ASSET_ERROR="hlsInterstitialAssetError",uA.INTERSTITIAL_ENDED="hlsInterstitialEnded",uA.INTERSTITIALS_PRIMARY_RESUMED="hlsInterstitialsPrimaryResumed",uA.PLAYOUT_LIMIT_REACHED="hlsPlayoutLimitReached",uA.EVENT_CUE_ENTER="hlsEventCueEnter",uA);var sn="manifest",sl="level",so="audioTrack",sd="subtitleTrack",sh="main",su="audio",sc="subtitle";class sf{constructor(e,t=0,i=0){this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=i}sample(e,t){let i=Math.pow(this.alpha_,e);this.estimate_=t*(1-i)+i*this.estimate_,this.totalWeight_+=e}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){let e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}}class sm{constructor(e,t,i,r=100){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=i,this.minWeight_=.001,this.minDelayMs_=50,this.slow_
1=new sf(e),this.fast_=new sf(t),this.defaultTTFB_=r,this.ttfb_=new sf(e)}update(e,t){let{slow_:i,fast_:r,ttfb_:s}=this;i.halfLife!==e&&(this.slow_=new sf(e,i.getEstimate(),i.getTotalWeight())),r.halfLife!==t&&(this.fast_=new sf(t,r.getEstimate(),r.getTotalWeight())),s.halfLife!==e&&(this.ttfb_=new sf(e,s.getEstimate(),s.getTotalWeight()))}sample(e,t){let i=(e=Math.max(e,this.minDelayMs_))/1e3,r=8*t/i;this.fast_.sample(i,r),this.slow_.sample(i,r)}sampleTTFB(e){let t=Math.sqrt(2)*Math.exp(-Math.pow(e/1e3,2)/2);this.ttfb_.sample(t,Math.max(e,5))}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}get defaultEstimate(){return this.defaultEstimate_}destroy(){}}function sp(){return(sp=Object.assign.bind()).apply(null,arguments)}function sg(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),i.push.apply(i,r)}return i}function sv(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?sg(Object(i),!0).forEach(function(t){var r,s;r=t,s=i[t],(r=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var r=i.call(e,t);if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(r))in e?Object.defineProperty(e,r,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[r]=s}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):sg(Object(i)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})}return e}class sE{constructor(e,t){this.trace=void 0,this.debug=void 0,this.log=void 0,this.warn=void 0,this.info=void 0,this.error=void 0;const i=`[${e}]:`;this.trace=sy,this.debug=t.debug.bind(null,i),this.log=t.log.bind(null,i),this.warn=t.warn.bind(null,i),this.info=t.info.bind(null,i),this.error=t.error.bind(null,i)}}let sy=function(){},sb={trace:sy,debug:sy,log:sy,warn:sy,info:sy,error:sy};function sT(){return sp({},sb)}function s_(e,t,i){let r;return t[e]?t[e].bind(t):(r=self.console[e])?r.bind(self.console,`${i?"["+i+"] ":""}[${e}] >`):sy}let sA=sT();function sS(e=!0){if(!("u"<typeof self))return(e||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function sk(e,t){let i=Object.keys(e),r=Object.keys(t),s=i.length,a=r.length;return!s||!a||s===a&&!i.some(e=>-1===r.indexOf(e))}function sL(e,t=!1){let i,r;if("u">typeof TextDecoder){let i=new TextDecoder("utf-8").decode(e);if(t){let e=i.indexOf("\0");return -1!==e?i.substring(0,e):i}return i.replace(/\0/g,"")}let s=e.length,a="",n=0;for(;n<s&&(0!==(i=e[n++])||!t);)if(0!==i&&3!==i)switch(i>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:a+=String.fromCharCode(i);break;case 12:case 13:a+=String.fromCharCode((31&i)<<6|63&(r=e[n++]));break;case 14:a+=String.fromCharCode((15&i)<<12|(63&(r=e[n++]))<<6|63&e[n++])}return a}function sR(e){let t="";for(let i=0;i<e.length;i++){let r=e[i].toString(16);r.length<2&&(r="0"+r),t+=r}return t}function sI(e){return Uint8Array.from(e.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var sw={exports:{}},sD=uI?sw.exports:(uI=1,ug=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,uv=/^(?=([^\/?#]*))\1([^]*)$/,uE=/(?:\/|^)\.(?=\/)/g,uy=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,sw.exports=ub={buildAbsoluteURL:function(e,t,i){if(i=i||{},e=e.trim(),!(t=t.trim())){if(!i.alwaysNormalize)return e;var r=ub.parseURL(e);if(!r)throw Error("Error trying to parse base URL.");return r.path=ub.normalizePath(r.path),ub.buildURLFromParts(r)}var s=ub.parseURL(t);if(!s)throw Error("Error trying to parse relative URL.");
vendor: 1,118 bytes, line 1
1if(s.scheme)return i.alwaysNormalize?(s.path=ub.normalizePath(s.path),ub.buildURLFromParts(s)):t;var a=ub.parseURL(e);if(!a)throw Error("Error trying to parse base URL.");if(!a.netLoc&&a.path&&"/"!==a.path[0]){var n=uv.exec(a.path);a.netLoc=n[1],a.path=n[2]}a.netLoc&&!a.path&&(a.path="/");var l={scheme:a.scheme,netLoc:s.netLoc,path:null,params:s.params,query:s.query,fragment:s.fragment};if(!s.netLoc&&(l.netLoc=a.netLoc,"/"!==s.path[0]))if(s.path){var o=a.path,d=o.substring(0,o.lastIndexOf("/")+1)+s.path;l.path=ub.normalizePath(d)}else l.path=a.path,!s.params&&(l.params=a.params,s.query||(l.query=a.query));return null===l.path&&(l.path=i.alwaysNormalize?ub.normalizePath(s.path):s.path),ub.buildURLFromParts(l)},parseURL:function(e){var t=ug.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(uE,"");e.length!==(e=e.replace(uy,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}}
1,sw.exports);class sC{constructor(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}}var sP="audio",sx="video",sM="audiovideo";class sO{constructor(e){this._byteRange=null,this._url=null,this._stats=null,this._streams=null,this.base=void 0,this.relurl=void 0,"string"==typeof e&&(e={url:e}),this.base=e,function(e,t){let i=function e(t,i){let r=Object.getPrototypeOf(t);if(r){let t=Object.getOwnPropertyDescriptor(r,i);return t||e(r,i)}}(e,t);i&&(i.enumerable=!0,Object.defineProperty(e,t,i))}(this,"stats")}setByteRange(e,t){let i,r=e.split("@",2);i=1===r.length?(null==t?void 0:t.byteRangeEndOffset)||0:parseInt(r[1]),this._byteRange=[i,parseInt(r[0])+i]}get baseurl(){return this.base.url}get byteRange(){return null===this._byteRange?[]:this._byteRange}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get elementaryStreams(){return null===this._streams&&(this._streams={[sP]:null,[sx]:null,[sM]:null}),this._streams}set elementaryStreams(e){this._streams=e}get hasStats(){return null!==this._stats}get hasStreams(){return null!==this._streams}get stats(){return null===this._stats&&(this._stats=new sC),this._stats}set stats(e){this._stats=e}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=sD.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}clearElementaryStreamInfo(){let{elementaryStreams:e}=this;e[sP]=null,e[sx]=null,e[sM]=null}}function sN(e){return"initSegment"!==e.sn}class sU extends sO{constructor(e,t){super(t),this._decryptdata=null,this._programDateTime=null,this._ref=null,this._bitrate=void 0,this.rawProgramDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.playlistOffset=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.urlId=0,this.type=e}get byteLength(){if(this.hasStats){let e=this.stats.total;if(e)return e}if(this.byteRange.length){let e=this.byteRange[0],t=this.byteRange[1];if(se(e)&&se(t))return t-e}return null}get bitrate(){return this.byteLength?8*this.byteLength/this.duration:this._bitrate?this._bitrate:null}set bitrate(e){this._bitrate=e}get decryptdata(){var e;let{levelkeys:t}=this;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)){let e=Object.keys(t);if(1===e.length){let i=this._decryptdata=t[e[0]]||null;i&&(this._decryptdata=i.getDecryptData(this.sn,t))}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(null===this.programDateTime)return null;let e=se(this.duration)?this.duration:0;return this.programDateTime+1e3*e}get encrypted(){var e,t;if(null!=(e=this._decryptdata)&&e.encrypted)return!0;if(this.levelkeys){let e=Object.keys(this.levelkeys),i=e.length;if(i>1||1===i&&null!=(t=this.levelkeys[e[0]])&&t.encrypted)return!0}return!1}get programDateTime(){return null===this._programDateTime&&this.rawProgramDateTime&&(this.programDateTime=Date.parse(this.rawProgramDateTime)),this._programDateTime}set programDateTime(e){if(!se(e)){this._programDateTime=this.rawProgramDateTime=null;return}this._programDateTime=e}get ref(){return sN(this)?(this._ref||(this._ref={base:this.base,start:this.start,duration:this.duration,sn:this.sn,programDateTime:this.programDateTime}),this._ref):null}addStart(e){this.setStart(this.start+e)}setStart(e){this.start=e,this._ref&&(this._ref.start=e)}setDuration(e){this.duration=e,this._ref&&(this._ref.duration=e)}setKeyFormat(e){let t=this.levelkeys;if(t){var i;let r=t[e];r&&!(null!=(i=this._decryptdata)&&i.keyId)&&(this._decryptdata=r.getDecryptData(this.sn,t))}}abortRequests(){var e,t;null==(e=this.loader)||e.abort(),null==(t=this.keyLoader)||t.abort()}setElementaryStreamInfo(e,t,i,r,s,a=!1){let{elementaryStreams:n}=this,l=n[e];if(!l){n[e]={startPTS:t,endPTS:i,startDTS:r,endDTS:s,partial:a};return}l.startPTS=Math.min(l.startPTS,t),l.endPTS=Math.max(l.endPTS,i),l.startDTS=Math.min(l.startDTS,r),l.endDTS=Math.max(l.endDTS,s)}}class sF extends sO{constructor(e,t,i,r,s){super(i),this.fragOffset=0,this.duration=0,this.gap=!1,this.independent=!1,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.duration=e.decimalFloatingPoint("DURATION"),this.gap=e.bool("GAP"),this.independent=e.bool("INDEPENDENT"),this.relurl=e.enumeratedString("URI"),this.fragment=t,this.index=r;const a=e.enumeratedString("BYTERANGE");a&&this.setByteRange(a,s),s&&(this.fragOffset=s.fragOffset+s.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){let{elementaryStreams:e}=this;return!!(e.audio||e.video||e.audiovideo)}}let s$=[].push,sB={video:1,audio:2,id3:3,text:4};function sH(e){return String.fromCharCode.apply(null,e)}function sG(e,t){let i=e[t]<<8|e[t+1];return i<0?65536+i:i}function sV(e,t){let i=sW(e,t);return i<0?0x100000000+i:i}function sK(e,t){let i=sV(e,t);return i*=0x100000000,i+=sV(e,t+4)}function sW(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function sq(e,t){let i=[];if(!t.length)return i;let r=e.byteLength;for(let s=0;s<r;){let a=sV(e,s),n=sH(e.subarray(s+4,s+8)),l=a>1?s+a:r;if(n===t[0])if(1===t.length)i.push(e.subarray(s+8,l));else{let r=sq(e.subarray(s+8,l),t.slice(1));r.length&&s$.apply(i,r)}s=l}return i}function sj(e){let t=[],i=sq(e,["moov","trak"]);for(let e=0;e<i.length;e++){let r=i[e],s=sq(r,["tkhd"])[0];if(s){let e=s[0],i=sV(s,0===e?12:20),a=sq(r,["mdia","mdhd"])[0];if(a){e=a[0];let s=sV(a,0===e?12:20),n=sq(r,["mdia","hdlr"])[0];if(n){let e=sH(n.subarray(8,12)),a={soun:sP,vide:sx}[e],l=function(e){let t,i=e.subarray(8),r=i.subarray(86),s=sH(i.subarray(4,8)),a=s,n="enca"===s||"encv"===s;if(n){let e=sq(i,[s])[0].subarray("enca"===s?28:78);
1sq(e,["sinf"]).forEach(e=>{let t=sq(e,["schm"])[0];if(t){let i=sH(t.subarray(4,8));if("cbcs"===i||"cenc"===i){let t=sq(e,["frma"])[0];t&&(a=sH(t))}}})}let l=a;switch(a){case"avc1":case"avc2":case"avc3":case"avc4":{let e=sq(r,["avcC"])[0];e&&e.length>3&&(a+="."+sz(e[1])+sz(e[2])+sz(e[3]),t=sY("avc1"===l?"dva1":"dvav",r));break}case"mp4a":{let e=sq(i,[s])[0],t=sq(e.subarray(28),["esds"])[0];if(t&&t.length>7){let e=4;if(3!==t[e++])break;e=sQ(t,e)+2;let i=t[e++];if(128&i&&(e+=2),64&i&&(e+=t[e++]),4!==t[e++])break;e=sQ(t,e);let r=t[e++];if(64===r)a+="."+sz(r);else break;if(e+=12,5!==t[e++])break;e=sQ(t,e);let s=t[e++],n=(248&s)>>3;31===n&&(n+=1+((7&s)<<3)+((224&t[e])>>5)),a+="."+n}break}case"hvc1":case"hev1":{let e=sq(r,["hvcC"])[0];if(e&&e.length>12){let t=e[1],i=["","A","B","C"][t>>6],r=sV(e,2),s=e[12],n=e.subarray(6,12);a+="."+i+(31&t),a+="."+(function(e){let t=0;for(let i=0;i<32;i++)t|=(e>>i&1)<<31-i;return t>>>0})(r).toString(16).toUpperCase(),a+="."+((32&t)>>5?"H":"L")+s;let l="";for(let e=n.length;e--;){let t=n[e];(t||l)&&(l="."+t.toString(16).toUpperCase()+l)}a+=l}t=sY("hev1"==l?"dvhe":"dvh1",r);break}case"dvh1":case"dvhe":case"dvav":case"dva1":case"dav1":a=sY(a,r)||a;break;case"vp09":{let e=sq(r,["vpcC"])[0];if(e&&e.length>6){let t=e[4],i=e[5],r=e[6]>>4&15;a+="."+sX(t)+"."+sX(i)+"."+sX(r)}break}case"av01":{let e=sq(r,["av1C"])[0];if(e&&e.length>2){let i=e[1]>>>5,s=31&e[1],n=e[2]>>>7?"H":"M",l=(64&e[2])>>6,o=(32&e[2])>>5,d=(16&e[2])>>4,h=(8&e[2])>>3,u=(4&e[2])>>2,c=3&e[2];a+="."+i+"."+sX(s)+n+"."+sX(2===i&&l?o?12:10:l?10:8)+"."+d+"."+h+u+c+"."+sX(1)+"."+sX(1)+"."+sX(1)+".0",t=sY("dav1",r)}}}return{codec:a,encrypted:n,supplemental:t}}(sq(r,["mdia","minf","stbl","stsd"])[0]);a?(t[i]={timescale:s,type:a,stsd:l},t[a]=sv({timescale:s,id:i},l)):t[i]={timescale:s,type:e,stsd:l}}}}}return sq(e,["moov","mvex","trex"]).forEach(e=>{let i=t[sV(e,4)];i&&(i.default={duration:sV(e,12),flags:sV(e,20)})}),t}function sY(e,t){let i=sq(t,["dvvC"]),r=i.length?i[0]:sq(t,["dvcC"])[0];if(r){let t=r[2]>>1&127,i=r[2]<<5&32|r[3]>>3&31;return e+"."+sX(t)+"."+sX(i)}}function sQ(e,t){let i=t+5;for(;128&e[t++]&&t<i;);return t}function sz(e){return("0"+e.toString(16).toUpperCase()).slice(-2)}function sX(e){return(e<10?"0":"")+e}function sZ(e,t){sq(e,["moov","trak"]).forEach(e=>{let i=sq(e,["mdia","minf","stbl","stsd"])[0];if(!i)return;let r=i.subarray(8),s=sq(r,["enca"]),a=s.length>0;a||(s=sq(r,["encv"])),s.forEach(e=>{sq(a?e.subarray(28):e.subarray(78),["sinf"]).forEach(e=>{let i=sJ(e);i&&t(i,a)})})})}function sJ(e){let t=sq(e,["schm"])[0];if(t){let i=sH(t.subarray(4,8));if("cbcs"===i||"cenc"===i){let t=sq(e,["schi","tenc"])[0];if(t)return t}}}function s0(e,t){let i=new Uint8Array(e.length+t.length);return i.set(e),i.set(t,e.length),i}function s1(e,t){let i=[],r=t.samples,s=t.timescale,a=t.id,n=!1;
1return sq(r,["moof"]).map(l=>{let o=l.byteOffset-8;sq(l,["traf"]).map(l=>{let d=sq(l,["tfdt"]).map(e=>{let t=e[0],i=sV(e,4);return 1===t&&(i*=0x100000000,i+=sV(e,8)),i/s})[0];return void 0!==d&&(e=d),sq(l,["tfhd"]).map(d=>{let h=sV(d,4),u=0xffffff&sV(d,0),c=0,f=0,m=8;h===a&&((1&u)!=0&&(m+=8),(2&u)!=0&&(m+=4),(8&u)!=0&&(c=sV(d,m),m+=4),(16&u)!=0&&(f=sV(d,m),m+=4),(32&u)!=0&&(m+=4),"video"===t.type&&(n=s2(t.codec)),sq(l,["trun"]).map(a=>{let l=a[0],d=0xffffff&sV(a,0),h=0,u=(256&d)!=0,m=0,g=(512&d)!=0,v=0,E=(1024&d)!=0,y=(2048&d)!=0,b=0,T=sV(a,4),_=8;(1&d)!=0&&(h=sV(a,_),_+=4),(4&d)!=0&&(_+=4);let A=h+o;for(let o=0;o<T;o++){if(u?(m=sV(a,_),_+=4):m=c,g?(v=sV(a,_),_+=4):v=f,E&&(_+=4),y&&(b=0===l?sV(a,_):sW(a,_),_+=4),t.type===sx){let t=0;for(;t<v;){let a=sV(r,A);A+=4,function(e,t){if(!e)return 6==(31&t);{let e=t>>1&63;return 39===e||40===e}}(n,r[A])&&s3(r.subarray(A,A+a),n?2:1,e+b/s,i),A+=a,t+=a+4}}e+=m/s}}))})})}),i}function s2(e){if(!e)return!1;let t=e.substring(0,4);return"hvc1"===t||"hev1"===t||"dvh1"===t||"dvhe"===t}function s3(e,t,i,r){let s,a=s4(e);s=0+t;let n=0,l=0,o=0;for(;s<a.length;){n=0;do{if(s>=a.length)break;n+=o=a[s++]}while(255===o)l=0;do{if(s>=a.length)break;l+=o=a[s++]}while(255===o)let e=a.length-s,t=s;if(l<e)s+=l;else if(l>e){sA.error(`Malformed SEI payload. ${l} is too small, only ${e} bytes left to parse.`);break}if(4===n){if(181===a[t++]){let e=sG(a,t);if(t+=2,49===e){let e=sV(a,t);if(t+=4,0x47413934===e){let e=a[t++];if(3===e){let s=a[t++],l=31&s,o=64&s,d=o?2+3*l:0,h=new Uint8Array(d);if(o){h[0]=s;for(let e=1;e<d;e++)h[e]=a[t++]}r.push({type:e,payloadType:n,pts:i,bytes:h})}}}}}else if(5===n&&l>16){let e=[];for(let i=0;i<16;i++){let r=a[t++].toString(16);e.push(1==r.length?"0"+r:r),(3===i||5===i||7===i||9===i)&&e.push("-")}let s=l-16,o=new Uint8Array(s);for(let e=0;e<s;e++)o[e]=a[t++];r.push({payloadType:n,pts:i,uuid:e.join(""),userData:sL(o),userDataBytes:o})}}}function s4(e){let t=e.byteLength,i=[],r=1;for(;r<t-2;)0===e[r]&&0===e[r+1]&&3===e[r+2]?(i.push(r+2),r+=2):r++;if(0===i.length)return e;let s=t-i.length,a=new Uint8Array(s),n=0;for(r=0;r<s;n++,r++)n===i[0]&&(n++,i.shift()),a[r]=e[n];return a}let s5={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 s8(e,t){let i=s5[t];return!!i&&!!i[e.slice(0,4)]}function s6(e,t,i=!0){return!e.split(",").some(e=>!s9(e,t,i))}function s9(e,t,i=!0){var r;let s=sS(i);return null!=(r=null==s?void 0:s.isTypeSupported(s7(e,t)))&&r}function s7(e,t){return`${t}/mp4;codecs=${e}`}function ae(e){if(e){let t=e.substring(0,4);return s5.video[t]}return 2}function at(e){let t=/\(Windows.+Firefox\//i.test(navigator.userAgent);return e.split(",").reduce((e,i)=>{let r=t&&s2(i)?9:s5.video[i];return r?(2*r+e)/(e?3:2):(s5.audio[i]+e)/(e?2:1)},0)}let ai={},ar=/flac|opus|mp4a\.40\.34/i;function as(e,t=!0){return e.replace(ar,e=>(function(e,t=!0){if(ai[e])return ai[e];let i={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"],"mp4a.40.34":["mp3"]}[e];for(let s=0;s<i.length;s++){var r;if(s9(i[s],"audio",t))return ai[e]=i[s],i[s];if("mp3"===i[s]&&null!=(r=sS(t))&&r.isTypeSupported("audio/mpeg"))return""}return e})(e.toLowerCase(),t))}function aa(e,t){if(e&&(e.length>4||-1!==["ac-3","ec-3","alac","fLaC","Opus"].indexOf(e))&&(an(e,"audio")||an(e,"video")))return e;if(t){let i=t.split(",");if(i.length>1){if(e){for(let t=i.length;t--;)if(i[t].substring(0,4)===e.substring(0,4))return i[t]}return i[0]}}return t||e}function an(e,t){return s8(e,t)&&s9(e,t)}function al(e){let t=sS(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 ao(e){return e.replace(/^.+codecs=["']?([^"']+).*$/,"$1")}let ad={supported:!1,smooth:!1,powerEfficient:!1},ah={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]};function au(e,t){return{supported:!1,configurations:t,decodingInfoResults:[ad],error:e}}function ac(e,t,i,r={}){var s,a,n,l,o,d;
1let h,u,c,f,m,g,v,E,y=e.videoCodec;if(!y&&!e.audioCodec||!i)return Promise.resolve(ah);let b=[],T=(h=null==(a=(s=e).videoCodec)?void 0:a.split(","),u=af(s),c=s.width||640,f=s.height||480,m=s.frameRate||30,g=s.videoRange.toLowerCase(),h?h.map(e=>{let t={contentType:s7(function(e){if(e.startsWith("av01.")){let t=e.split("."),i=["0","111","01","01","01","0"];for(let e=t.length;e>4&&e<10;e++)t[e]=i[e-4];return t.join(".")}return e}(e),"video"),width:c,height:f,bitrate:u,framerate:m};return"sdr"!==g&&(t.transferFunction=g),t}):[]),_=T.length,A=(n=e,l=t,o=_>0,v=null==(d=n.audioCodec)?void 0:d.split(","),E=af(n),v&&n.audioGroups?n.audioGroups.reduce((e,t)=>{var i;let r=t?null==(i=l.groups[t])?void 0:i.tracks:null;return r?r.reduce((e,i)=>{if(i.groupId===t){let t=parseFloat(i.channels||"");v.forEach(i=>{let r={contentType:s7(i,"audio"),bitrate:o?function(e,t){if(t<=1)return 1;let i=128e3;return"ec-3"===e?i=768e3:"ac-3"===e&&(i=64e4),Math.min(t/2,i)}(i,E):E};t&&(r.channels=""+t),e.push(r)})}return e},e):e},[]):[]),S=A.length;for(let e=_||+S||1;e--;){let t={type:"media-source"};if(_&&(t.video=T[e%_]),S){t.audio=A[e%S];let i=t.audio.bitrate;t.video&&i&&(t.video.bitrate-=i)}b.push(t)}if(y){let e=navigator.userAgent;if(y.split(",").some(e=>s2(e))&&/\(Windows.+Firefox\//i.test(navigator.userAgent))return Promise.resolve(au(Error(`Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent string: (${e})`),b))}return Promise.all(b.map(e=>{let t=function(e){let t="",{audio:i,video:r}=e;if(r){let e=ao(r.contentType);t+=`${e}_r${r.height}x${r.width}f${Math.ceil(r.framerate)}${r.transferFunction||"sd"}_${Math.ceil(r.bitrate/1e5)}`}if(i){let e=ao(i.contentType);t+=`${r?"_":""}${e}_c${i.channels}`}return t}(e);return r[t]||(r[t]=i.decodingInfo(e))})).then(e=>({supported:!e.some(e=>!e.supported),configurations:b,decodingInfoResults:e})).catch(e=>({supported:!1,configurations:b,decodingInfoResults:[],error:e}))}function af(e){return 1e3*Math.ceil(Math.max(.9*e.bitrate,e.averageBitrate)/1e3)||1}let am=["NONE","TYPE-0","TYPE-1",null],ap=["SDR","PQ","HLG"];function ag(e){let{canSkipUntil:t,canSkipDateRanges:i,age:r}=e;return t&&r<t/2?i?"v2":"YES":""}class av{constructor(e,t,i){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=i}addDirectives(e){let 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}}class aE{constructor(e){if(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=[e.url],this._attrs=[e.attrs],this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.frameRate=e.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=e.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.codecSet=[e.videoCodec,e.audioCodec].filter(e=>!!e).map(e=>e.substring(0,4)).join(","),"supplemental"in e){var t;this.supplemental=e.supplemental;const i=null==(t=e.supplemental)?void 0:t.videoCodec;i&&i!==e.videoCodec&&(this.codecSet+=`,${i.substring(0,4)}`)}this.addGroupId("audio",e.attrs.AUDIO),this.addGroupId("text",e.attrs.SUBTITLES)}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get averageBitrate(){return this._avgBitrate||this.realBitrate||this.bitrate}get attrs(){return this._attrs[0]}get codecs(){return this.attrs.CODECS||""}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get videoRange(){return this.attrs["VIDEO-RANGE"]||"SDR"}get score(){return this.attrs.optionalFloat("SCORE",0)}get uri(){return this.url[0]||""}hasAudioGroup(e){return ay(this._audioGroups,e)}hasSubtitleGroup(e){return ay(this._subtitleGroups,e)}get audioGroups(){return this._audioGroups}get subtitleGroups(){return this._subtitleGroups}addGroupId(e,t){if(t){if("audio"===e){let e=this._audioGroups;e||(e=this._audioGroups=[]),-1===e.indexOf(t)&&e.push(t)}else if("text"===e){let e=this._subtitleGroups;e||(e=this._subtitleGroups=[]),-1===e.indexOf(t)&&e.push(t)}}}get urlId(){return 0}set urlId(e){}get audioGroupIds(){return this.audioGroups?[this.audioGroupId]:void 0}get textGroupIds(){return this.subtitleGroups?[this.textGroupId]:void 0}get audioGroupId(){var e;return null==(e=this.audioGroups)?void 0:e[0]}get textGroupId(){var e;return null==(e=this.subtitleGroups)?void 0:e[0]}addFallback(){}}function ay(e,t){return!!t&&!!e&&-1!==e.indexOf(t)}let ab=(e,t)=>
1{let i;return JSON.stringify(e,(i=new WeakSet,(e,r)=>{if(t&&(r=t(e,r)),"object"==typeof r&&null!==r){if(i.has(r))return;i.add(r)}return r}))};function aT(e,t){sA.log(`[abr] start candidates with "${e}" ignored because ${t}`)}function a_(e){return e.reduce((e,t)=>{let i=e.groups[t.groupId];i||(i=e.groups[t.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),i.tracks.push(t);let r=t.channels||"2";return i.channels[r]=(i.channels[r]||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 aA(e){if(!e)return e;let{lang:t,assocLang:i,characteristics:r,channels:s,audioCodec:a}=e;return{lang:t,assocLang:i,characteristics:r,channels:s,audioCodec:a}}function aS(e,t,i){if("attrs"in e){let i=t.indexOf(e);if(-1!==i)return i}for(let r=0;r<t.length;r++)if(ak(e,t[r],i))return r;return -1}function ak(e,t,i){let{groupId:r,name:s,lang:a,assocLang:n,default:l}=e,o=e.forced;return(void 0===r||t.groupId===r)&&(void 0===s||t.name===s)&&(void 0===a||function(e,t="--"){return e.length===t.length?e===t:e.startsWith(t)||t.startsWith(e)}(a,t.lang))&&(void 0===a||t.assocLang===n)&&(void 0===l||t.default===l)&&(void 0===o||t.forced===o)&&(!("characteristics"in e)||function(e,t=""){let i=e.split(","),r=t.split(",");return i.length===r.length&&!i.some(e=>-1===r.indexOf(e))}(e.characteristics||"",t.characteristics))&&(void 0===i||i(e,t))}function aL(e,t){let{audioCodec:i,channels:r}=e;return(void 0===i||(t.audioCodec||"").substring(0,4)===i.substring(0,4))&&(void 0===r||r===(t.channels||"2"))}function aR(e,t,i){for(let r=t;r>-1;r--)if(i(e[r]))return r;for(let r=t+1;r<e.length;r++)if(i(e[r]))return r;return -1}function aI(e,t){var i;return!!e&&e!==(null==(i=t.loadLevelObj)?void 0:i.uri)}let aw=function(e,t){let i=0,r=e.length-1,s=null,a=null;for(;i<=r;){let n=t(a=e[s=(i+r)/2|0]);if(n>0)i=s+1;else{if(!(n<0))return a;r=s-1}}return null};function aD(e,t,i=0,r=0,s=.005){let a=null;if(e){a=t[1+e.sn-t[0].sn]||null;let r=e.endDTS-i;r>0&&r<15e-7&&(i+=15e-7),a&&e.level!==a.level&&a.end<=e.end&&(a=t[2+e.sn-t[0].sn]||null)}else 0===i&&0===t[0].start&&(a=t[0]);if(a&&((!e||e.level===a.level)&&0===aC(i,r,a)||function(e,t,i){if(t&&0===t.start&&t.level<e.level&&(t.endPTS||0)>0){let r=t.tagList.reduce((e,t)=>("INF"===t[0]&&(e+=parseFloat(t[1])),e),i);return e.start<=r}return!1}(a,e,Math.min(s,r))))return a;let n=aw(t,aC.bind(null,i,r));return n&&(n!==e||!a)?n:a}function aC(e=0,t=0,i){if(i.start<=e&&i.start+i.duration>e)return 0;let r=Math.min(t,i.duration+(i.deltaPTS?i.deltaPTS:0));return i.start+i.duration-r<=e?1:i.start-r>e&&i.start?-1:0}function aP(e,t,i){if(e&&e.startCC<=t&&e.endCC>=t){let r,s=e.fragments,{fragmentHint:a}=e;return a&&(s=s.concat(a)),aw(s,e=>e.cc<t?1:e.cc>t?-1:(r=e,e.end<=i)?1:e.start>i?-1:0),r||null}return null}function ax(e){switch(e.details){case ss.FRAG_LOAD_TIMEOUT:case ss.KEY_LOAD_TIMEOUT:case ss.LEVEL_LOAD_TIMEOUT:case ss.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function aM(e){return e.details.startsWith("key")}function aO(e){return aM(e)&&!!e.frag&&!e.frag.decryptdata}function aN(e,t){let i=ax(t);return e.default[`${i?"timeout":"error"}Retry`]}function aU(e,t){return Math.min(("linear"===e.backoff?1:Math.pow(2,t))*e.retryDelayMs,e.maxRetryDelayMs)}function aF(e){return sv(sv({},e),{errorRetry:null,timeoutRetry:null})}function a$(e,t,i,r){var s;if(!e)return!1;let a=null==r?void 0:r.code,n=t<e.maxNumRetry&&(aB(s=a)||!!s&&(s<400||s>499)||!!i);return e.shouldRetry?e.shouldRetry(e,t,i,r,n):n}function aB(e){return 0===e&&!1===navigator.onLine}function aH(e){let t={action:0,flags:0};return e&&(t.resolved=!0),t}var aG="NOT_LOADED",aV="APPENDING",aK="PARTIAL";class aW{constructor(e){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=e,this._registerListeners()}_registerListeners(){let{hls:e}=this;e&&(e.on(sa.MANIFEST_LOADING,this.onManifestLoading,this),e.on(sa.BUFFER_APPENDED,this.onBufferAppended,this),e.on(sa.FRAG_BUFFERED,this.onFragBuffered,this),e.on(sa.FRAG_LOADED,this.onFragLoaded,this))}_unregisterListeners(){let{hls:e}=this;e&&(e.off(sa.MANIFEST_LOADING,this.onManifestLoading,this),e.off(sa.BUFFER_APPENDED,this.onBufferAppended,this),e.off(sa.FRAG_BUFFERED,this.onFragBuffered,this),e.off(sa.FRAG_LOADED,this.onFragLoaded,this))}destroy(){this._unregisterListeners(),this.hls=this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(e,t){let i=this.activePartLists[t];if(i)for(let t=i.length;t--;){let r=i[t];if(!r)break;
1if(r.start<=e&&e<=r.end&&r.loaded)return r}return this.getBufferedFrag(e,t)}getBufferedFrag(e,t){return this.getFragAtPos(e,t,!0)}getFragAtPos(e,t,i){let{fragments:r}=this,s=Object.keys(r);for(let a=s.length;a--;){let n=r[s[a]];if((null==n?void 0:n.body.type)===t&&(!i||n.buffered)){let t=n.body;if(t.start<=e&&e<=t.end)return t}}return null}detectEvictedFragments(e,t,i,r,s){this.timeRanges&&(this.timeRanges[e]=t);let a=(null==r?void 0:r.fragment.sn)||-1;Object.keys(this.fragments).forEach(r=>{let n=this.fragments[r];if(!n||a>=n.body.sn)return;if(!n.buffered&&(!n.loaded||s)){n.body.type===i&&this.removeFragment(n.body);return}let l=n.range[e];if(l){if(0===l.time.length)return void this.removeFragment(n.body);l.time.some(e=>{let i=!this.isTimeBuffered(e.startPTS,e.endPTS,t);return i&&this.removeFragment(n.body),i})}})}detectPartialFragments(e){let t=this.timeRanges;if(!t||"initSegment"===e.frag.sn)return;let i=e.frag,r=aj(i),s=this.fragments[r];if(!s||s.buffered&&i.gap)return;let a=!i.relurl;Object.keys(t).forEach(r=>{let n=i.elementaryStreams[r];if(!n)return;let l=t[r],o=a||!0===n.partial;s.range[r]=this.getBufferedTimes(i,e.part,o,l)}),s.loaded=null,Object.keys(s.range).length?(this.bufferedEnd(s,i),aq(s)||this.removeParts(i.sn-1,i.type)):this.removeFragment(s.body)}bufferedEnd(e,t){e.buffered=!0,(e.body.endList=t.endList||e.body.endList)&&(this.endListFragments[e.body.type]=e)}removeParts(e,t){let i=this.activePartLists[t];i&&(this.activePartLists[t]=aY(i,t=>t.fragment.sn>=e))}fragBuffered(e,t){let i=aj(e),r=this.fragments[i];!r&&t&&(r=this.fragments[i]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),r&&(r.loaded=null,this.bufferedEnd(r,e))}getBufferedTimes(e,t,i,r){let s={time:[],partial:i},a=e.start,n=e.end,l=e.minEndPTS||n,o=e.maxStartPTS||a;for(let e=0;e<r.length;e++){let t=r.start(e)-this.bufferPadding,i=r.end(e)+this.bufferPadding;if(o>=t&&l<=i){s.time.push({startPTS:Math.max(a,r.start(e)),endPTS:Math.min(n,r.end(e))});break}if(a<i&&n>t){let t=Math.max(a,r.start(e)),i=Math.min(n,r.end(e));i>t&&(s.partial=!0,s.time.push({startPTS:t,endPTS:i}))}else if(n<=t)break}return s}getPartialFragment(e){let t,i,r,s=null,a=0,{bufferPadding:n,fragments:l}=this;return Object.keys(l).forEach(o=>{let d=l[o];d&&aq(d)&&(i=d.body.start-n,r=d.body.end+n,e>=i&&e<=r&&a<=(t=Math.min(e-i,r-e))&&(s=d.body,a=t))}),s}isEndListAppended(e){let t=this.endListFragments[e];return void 0!==t&&(t.buffered||aq(t))}getState(e){let t=aj(e),i=this.fragments[t];if(i)if(!i.buffered)return aV;else if(aq(i))return aK;else return"OK";return aG}isTimeBuffered(e,t,i){let r,s;for(let a=0;a<i.length;a++){if(r=i.start(a)-this.bufferPadding,s=i.end(a)+this.bufferPadding,e>=r&&t<=s)return!0;if(t<=r)break}return!1}onManifestLoading(){this.removeAllFragments()}onFragLoaded(e,t){if("initSegment"===t.frag.sn||t.frag.bitrateTest)return;let i=t.frag,r=t.part?null:t,s=aj(i);this.fragments[s]={body:i,appendedPTS:null,loaded:r,buffered:!1,range:Object.create(null)}}onBufferAppended(e,t){let{frag:i,part:r,timeRanges:s,type:a}=t;if("initSegment"===i.sn)return;let n=i.type;if(r){let e=this.activePartLists[n];e||(this.activePartLists[n]=e=[]),e.push(r)}this.timeRanges=s;let l=s[a];this.detectEvictedFragments(a,l,n,r)}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){let t=aj(e);return!!this.fragments[t]}hasFragments(e){let{fragments:t}=this,i=Object.keys(t);if(!e)return i.length>0;for(let r=i.length;r--;){let s=t[i[r]];if((null==s?void 0:s.body.type)===e)return!0}return!1}hasParts(e){var t;return!!(null!=(t=this.activePartLists[e])&&t.length)}removeFragmentsInRange(e,t,i,r,s){(!r||this.hasGaps)&&Object.keys(this.fragments).forEach(a=>{let n=this.fragments[a];if(!n)return;let l=n.body;l.type===i&&(!r||l.gap)&&l.start<t&&l.end>e&&(n.buffered||s)&&this.removeFragment(l)})}removeFragment(e){let t=aj(e);e.clearElementaryStreamInfo();let i=this.activePartLists[e.type];if(i){let t=e.sn;this.activePartLists[e.type]=aY(i,e=>e.fragment.sn!==t)}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}removeAllFragments(){var e;this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1;let t=null==(e=this.hls)||null==(e=e.latestLevelDetails)?void 0:e.partList;
1t&&t.forEach(e=>e.clearElementaryStreamInfo())}}function aq(e){var t,i,r;return e.buffered&&!!(e.body.gap||null!=(t=e.range.video)&&t.partial||null!=(i=e.range.audio)&&i.partial||null!=(r=e.range.audiovideo)&&r.partial)}function aj(e){return`${e.type}_${e.level}_${e.sn}`}function aY(e,t){return e.filter(e=>{let i=t(e);return i||e.clearElementaryStreamInfo(),i})}class aQ{constructor(e,t,i){this.subtle=void 0,this.aesIV=void 0,this.aesMode=void 0,this.subtle=e,this.aesIV=t,this.aesMode=i}decrypt(e,t){switch(this.aesMode){case 0:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e);case 1:return this.subtle.decrypt({name:"AES-CTR",counter:this.aesIV,length:64},t,e);default:throw Error(`[AESCrypto] invalid aes mode ${this.aesMode}`)}}}class az{constructor(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}uint8ArrayToUint32Array_(e){let t=new DataView(e),i=new Uint32Array(4);for(let e=0;e<4;e++)i[e]=t.getUint32(4*e);return i}initTable(){let e=this.sBox,t=this.invSBox,i=this.subMix,r=i[0],s=i[1],a=i[2],n=i[3],l=this.invSubMix,o=l[0],d=l[1],h=l[2],u=l[3],c=new Uint32Array(256),f=0,m=0,g=0;for(g=0;g<256;g++)g<128?c[g]=g<<1:c[g]=g<<1^283;for(g=0;g<256;g++){let i=m^m<<1^m<<2^m<<3^m<<4;i=i>>>8^255&i^99,e[f]=i,t[i]=f;let l=c[f],g=c[l],v=c[g],E=257*c[i]^0x1010100*i;r[f]=E<<24|E>>>8,s[f]=E<<16|E>>>16,a[f]=E<<8|E>>>24,n[f]=E,E=0x1010101*v^65537*g^257*l^0x1010100*f,o[i]=E<<24|E>>>8,d[i]=E<<16|E>>>16,h[i]=E<<8|E>>>24,u[i]=E,f?(f=l^c[c[c[v^l]]],m^=c[c[m]]):f=m=1}}expandKey(e){let t,i,r,s,a=this.uint8ArrayToUint32Array_(e),n=!0,l=0;for(;l<a.length&&n;)n=a[l]===this.key[l],l++;if(n)return;this.key=a;let o=this.keySize=a.length;if(4!==o&&6!==o&&8!==o)throw Error("Invalid aes key size="+o);let d=this.ksRows=(o+6+1)*4,h=this.keySchedule=new Uint32Array(d),u=this.invKeySchedule=new Uint32Array(d),c=this.sBox,f=this.rcon,m=this.invSubMix,g=m[0],v=m[1],E=m[2],y=m[3];for(t=0;t<d;t++){if(t<o){r=h[t]=a[t];continue}s=r,t%o==0?s=(c[(s=s<<8|s>>>24)>>>24]<<24|c[s>>>16&255]<<16|c[s>>>8&255]<<8|c[255&s])^f[t/o|0]<<24:o>6&&t%o==4&&(s=c[s>>>24]<<24|c[s>>>16&255]<<16|c[s>>>8&255]<<8|c[255&s]),h[t]=r=(h[t-o]^s)>>>0}for(i=0;i<d;i++)t=d-i,s=3&i?h[t]:h[t-4],i<4||t<=4?u[i]=s:u[i]=g[c[s>>>24]]^v[c[s>>>16&255]]^E[c[s>>>8&255]]^y[c[255&s]],u[i]=u[i]>>>0}networkToHostOrderSwap(e){return e<<24|(65280&e)<<8|(0xff0000&e)>>8|e>>>24}decrypt(e,t,i){let r,s,a,n,l,o,d,h,u,c,f,m,g,v,E=this.keySize+6,y=this.invKeySchedule,b=this.invSBox,T=this.invSubMix,_=T[0],A=T[1],S=T[2],k=T[3],L=this.uint8ArrayToUint32Array_(i),R=L[0],I=L[1],w=L[2],D=L[3],C=new Int32Array(e),P=new Int32Array(C.length),x=this.networkToHostOrderSwap;for(;t<C.length;){for(v=1,u=x(C[t]),c=x(C[t+1]),f=x(C[t+2]),m=x(C[t+3]),l=u^y[0],o=m^y[1],d=f^y[2],h=c^y[3],g=4;v<E;v++)r=_[l>>>24]^A[o>>16&255]^S[d>>8&255]^k[255&h]^y[g],s=_[o>>>24]^A[d>>16&255]^S[h>>8&255]^k[255&l]^y[g+1],a=_[d>>>24]^A[h>>16&255]^S[l>>8&255]^k[255&o]^y[g+2],n=_[h>>>24]^A[l>>16&255]^S[o>>8&255]^k[255&d]^y[g+3],l=r,o=s,d=a,h=n,g+=4;r=b[l>>>24]<<24^b[o>>16&255]<<16^b[d>>8&255]<<8^b[255&h]^y[g],s=b[o>>>24]<<24^b[d>>16&255]<<16^b[h>>8&255]<<8^b[255&l]^y[g+1],a=b[d>>>24]<<24^b[h>>16&255]<<16^b[l>>8&255]<<8^b[255&o]^y[g+2],n=b[h>>>24]<<24^b[l>>16&255]<<16^b[o>>8&255]<<8^b[255&d]^y[g+3],P[t]=x(r^R),P[t+1]=x(n^I),P[t+2]=x(a^w),P[t+3]=x(s^D),R=u,I=c,w=f,D=m,t+=4}return P.buffer}}class aX{constructor(e,t,i){this.subtle=void 0,this.key=void 0,this.aesMode=void 0,this.subtle=e,this.key=t,this.aesMode=i}expandKey(){let e=function(e){switch(e){case 0:return"AES-CBC";case 1:return"AES-CTR";default:throw Error(`[FastAESKey] invalid aes mode ${e}`)}}(this.aesMode);return this.subtle.importKey("raw",this.key,{name:e},!1,["encrypt","decrypt"])}}class aZ{constructor(e,{removePKCS7Padding:t=!0}={}){if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.enableSoftw
1areAES=void 0,this.enableSoftwareAES=e.enableSoftwareAES,this.removePKCS7Padding=t,t)try{const e=self.crypto;e&&(this.subtle=e.subtle||e.webkitSubtle)}catch(e){}this.useSoftware=!this.subtle}destroy(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}isSync(){return this.useSoftware}flush(){let{currentResult:e,remainderData:t}=this;if(!e||t)return this.reset(),null;let i=new Uint8Array(e);if(this.reset(),this.removePKCS7Padding){let e,t;return(t=(e=i.byteLength)&&new DataView(i.buffer).getUint8(e-1))?i.slice(0,e-t):i}return i}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(e,t,i,r){return this.useSoftware?new Promise((s,a)=>{let n=ArrayBuffer.isView(e)?e:new Uint8Array(e);this.softwareDecrypt(n,t,i,r);let l=this.flush();l?s(l.buffer):a(Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,i,r)}softwareDecrypt(e,t,i,r){let{currentIV:s,currentResult:a,remainderData:n}=this;if(0!==r||16!==t.byteLength)return sA.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;this.logOnce("JS AES decrypt"),n&&(e=s0(n,e),this.remainderData=null);let l=this.getValidChunk(e);if(!l.length)return null;s&&(i=s);let o=this.softwareDecrypter;return(o||(o=this.softwareDecrypter=new az),o.expandKey(t),this.currentResult=o.decrypt(l.buffer,0,i),this.currentIV=l.slice(-16).buffer,a)?a:null}webCryptoDecrypt(e,t,i,r){if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,t,i,r));this.key=t,this.fastAesKey=new aX(this.subtle,t,r)}return this.fastAesKey.expandKey().then(t=>this.subtle?(this.logOnce("WebCrypto AES decrypt"),new aQ(this.subtle,new Uint8Array(i),r).decrypt(e.buffer,t)):Promise.reject(Error("web crypto not initialized"))).catch(s=>(sA.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${s.name}: ${s.message}`),this.onWebCryptoError(e,t,i,r)))}onWebCryptoError(e,t,i,r){let s=this.enableSoftwareAES;if(s){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,i,r);let s=this.flush();if(s)return s.buffer}throw Error("WebCrypto"+(s?" and softwareDecrypt":"")+": failed to decrypt data")}getValidChunk(e){let t=e,i=e.length-e.length%16;return i!==e.length&&(t=e.slice(0,i),this.remainderData=e.slice(i)),t}logOnce(e){this.logEnabled&&(sA.log(`[decrypter]: ${e}`),this.logEnabled=!1)}}class aJ{constructor(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(e,t){let i=e.url;if(!i)return Promise.reject(new a2({type:sr.NETWORK_ERROR,details:ss.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:Error(`Fragment does not have a ${i?"part list":"url"}`),networkDetails:null}));this.abort();let r=this.config,s=r.fLoader,a=r.loader;return new Promise((n,l)=>{if(this.loader&&this.loader.destroy(),e.gap)if(e.tagList.some(e=>"GAP"===e[0]))return void l(a1(e));else e.gap=!1;let o=this.loader=s?new s(r):new a(r),d=a0(e);e.loader=o;let h=aF(r.fragLoadPolicy.default),u={loadPolicy:h,timeout:h.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===e.sn?1/0:131072};e.stats=o.stats;let c={onSuccess:(t,i,r,s)=>{this.resetLoader(e,o);let a=t.data;r.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(a.slice(0,16)),a=a.slice(16)),n({frag:e,part:null,payload:a,networkDetails:s})},onError:(t,r,s,a)=>{this.resetLoader(e,o),l(new a2({type:sr.NETWORK_ERROR,details:ss.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:sv({url:i,data:void 0},t),error:Error(`HTTP Error ${t.code} ${t.text}`),networkDetails:s,stats:a}))},onAbort:(t,i,r)=>{this.resetLoader(e,o),l(new a2({type:sr.NETWORK_ERROR,details:ss.INTERNAL_ABORTED,fatal:!1,frag:e,error:Error("Aborted"),networkDetails:r,stats:t}))},onTimeout:(t,i,r)=>{this.resetLoader(e,o),l(new a2({type:sr.NETWORK_ERROR,details:ss.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:Error(`Timeout after ${u.timeout}ms`),networkDetails:r,stats:t}))}};t&&(c.onProgress=(i,r,s,a)=>t({frag:e,part:null,payload:s,networkDetails:a})),o.load(d,u,c)})}loadPart(e,t,i){this.abort();
1let r=this.config,s=r.fLoader,a=r.loader;return new Promise((n,l)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap)return void l(a1(e,t));let o=this.loader=s?new s(r):new a(r),d=a0(e,t);e.loader=o;let h=aF(r.fragLoadPolicy.default),u={loadPolicy:h,timeout:h.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:131072};t.stats=o.stats,o.load(d,u,{onSuccess:(r,s,a,l)=>{this.resetLoader(e,o),this.updateStatsFromPart(e,t);let d={frag:e,part:t,payload:r.data,networkDetails:l};i(d),n(d)},onError:(i,r,s,a)=>{this.resetLoader(e,o),l(new a2({type:sr.NETWORK_ERROR,details:ss.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:sv({url:d.url,data:void 0},i),error:Error(`HTTP Error ${i.code} ${i.text}`),networkDetails:s,stats:a}))},onAbort:(i,r,s)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,o),l(new a2({type:sr.NETWORK_ERROR,details:ss.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:Error("Aborted"),networkDetails:s,stats:i}))},onTimeout:(i,r,s)=>{this.resetLoader(e,o),l(new a2({type:sr.NETWORK_ERROR,details:ss.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:Error(`Timeout after ${u.timeout}ms`),networkDetails:s,stats:i}))}})})}updateStatsFromPart(e,t){let i=e.stats,r=t.stats,s=r.total;if(i.loaded+=r.loaded,s){let r=Math.round(e.duration/t.duration),a=Math.min(Math.round(i.loaded/s),r),n=(r-a)*Math.round(i.loaded/a);i.total=i.loaded+n}else i.total=Math.max(i.loaded,i.total);let a=i.loading,n=r.loading;a.start?a.first+=n.first-n.start:(a.start=n.start,a.first=n.first),a.end=n.end}resetLoader(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}}function a0(e,t=null){let i=t||e,r={frag:e,part:t,responseType:"arraybuffer",url:i.url,headers:{},rangeStart:0,rangeEnd:0},s=i.byteRangeStartOffset,a=i.byteRangeEndOffset;if(se(s)&&se(a)){var n,l;let t=s,i=a;if("initSegment"===e.sn&&("AES-128"===(l=null==(n=e.decryptdata)?void 0:n.method)||"AES-256"===l)){let e=a-s;e%16&&(i=a+(16-e%16)),0!==s&&(r.resetIV=!0,t=s-16)}r.rangeStart=t,r.rangeEnd=i}return r}function a1(e,t){let i=Error(`GAP ${e.gap?"tag":"attribute"} found`),r={type:sr.MEDIA_ERROR,details:ss.FRAG_GAP,fatal:!1,frag:e,error:i,networkDetails:null};return t&&(r.part=t),(t||e).stats.aborted=!0,new a2(r)}class a2 extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}}class a3 extends sE{constructor(e,t){super(e,t),this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed()}onHandlerDestroying(){this.clearNextTick(),this.clearInterval()}onHandlerDestroyed(){}hasInterval(){return!!this._tickInterval}hasNextTick(){return!!this._tickTimer}setInterval(e){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)}clearInterval(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)}clearNextTick(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)}tick(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}}class a4{constructor(e,t,i,r=0,s=-1,a=!1){this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing=a5(),this.buffering={audio:a5(),video:a5(),audiovideo:a5()},this.level=e,this.sn=t,this.id=i,this.size=r,this.part=s,this.partial=a}}function a5(){return{start:0,executeStart:0,executeEnd:0,end:0}}let a8={length:0,start:()=>0,end:()=>0};class a6{static isBuffered(e,t){if(e){let i=a6.getBuffered(e);for(let e=i.length;e--;)if(t>=i.start(e)&&t<=i.end(e))return!0}return!1}static bufferedRanges(e){if(e){let t=a6.getBuffered(e);return a6.timeRangesToArray(t)}return[]}static timeRangesToArray(e){let t=[];for(let i=0;i<e.length;i++)t.push({start:e.start(i),end:e.end(i)});return t}static bufferInfo(e,t,i){if(e){let r=a6.bufferedRanges(e);if(r.length)return a6.bufferedInfo(r,t,i)}return{len:0,start:t,end:t,bufferedIndex:-1}}static bufferedInfo(e,t,i){let r;t=Math.max(0,t),e.length>1&&e.sort((e,t)=>
1e.start-t.start||t.end-e.end);let s=-1,a=[];if(i)for(let r=0;r<e.length;r++){t>=e[r].start&&t<=e[r].end&&(s=r);let n=a.length;if(n){let t=a[n-1].end;e[r].start-t<i?e[r].end>t&&(a[n-1].end=e[r].end):a.push(e[r])}else a.push(e[r])}else a=e;let n=0,l=t,o=t;for(let e=0;e<a.length;e++){let d=a[e].start,h=a[e].end;if(-1===s&&t>=d&&t<=h&&(s=e),t+i>=d&&t<h)l=d,n=(o=h)-t;else if(t+i<d){r=d;break}}return{len:n,start:l||0,end:o||0,nextStart:r,buffered:e,bufferedIndex:s}}static getBuffered(e){try{return e.buffered||a8}catch(e){return sA.log("failed to get media.buffered",e),a8}}}let a9=/\{\$([a-zA-Z0-9-_]+)\}/g;function a7(e,t){if(null!==e.variableList||e.hasVariableRefs){let i=e.variableList;return t.replace(a9,t=>{let r=t.substring(2,t.length-1),s=null==i?void 0:i[r];return void 0===s?(e.playlistParsingError||(e.playlistParsingError=Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${r}"`)),t):s})}return t}function ne(e,t,i){let r,s,a=e.variableList;if(a||(e.variableList=a={}),"QUERYPARAM"in t){r=t.QUERYPARAM;try{let e=new self.URL(i).searchParams;if(e.has(r))s=e.get(r);else throw Error(`"${r}" does not match any query parameter in URI: "${i}"`)}catch(t){e.playlistParsingError||(e.playlistParsingError=Error(`EXT-X-DEFINE QUERYPARAM: ${t.message}`))}}else r=t.NAME,s=t.VALUE;r in a?e.playlistParsingError||(e.playlistParsingError=Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${r}"`)):a[r]=s||""}let nt=/^(\d+)x(\d+)$/,ni=/(.+?)=(".*?"|.*?)(?:,|$)/g;class nr{constructor(e,t){"string"==typeof e&&(e=nr.parseAttrList(e,t)),sp(this,e)}get clientAttrs(){return Object.keys(this).filter(e=>"X-"===e.substring(0,2))}decimalInteger(e){let t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t}hexadecimalInteger(e){if(this[e]){let t=(this[e]||"0x").slice(2),i=new Uint8Array((t=(1&t.length?"0":"")+t).length/2);for(let e=0;e<t.length/2;e++)i[e]=parseInt(t.slice(2*e,2*e+2),16);return i}return null}hexadecimalIntegerAsNumber(e){let t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t}decimalFloatingPoint(e){return parseFloat(this[e])}optionalFloat(e,t){let i=this[e];return i?parseFloat(i):t}enumeratedString(e){return this[e]}enumeratedStringList(e,t){let i=this[e];return(i?i.split(/[ ,]+/):[]).reduce((e,t)=>(e[t.toLowerCase()]=!0,e),t)}bool(e){return"YES"===this[e]}decimalResolution(e){let t=nt.exec(this[e]);if(null!==t)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(e,t){let i,r={};for(ni.lastIndex=0;null!==(i=ni.exec(e));){let s=i[1].trim(),a=i[2],n=0===a.indexOf('"')&&a.lastIndexOf('"')===a.length-1,l=!1;if(n)a=a.slice(1,-1);else switch(s){case"IV":case"SCTE35-CMD":case"SCTE35-IN":case"SCTE35-OUT":l=!0}if(t&&(n||l))a=a7(t,a);else if(!l&&!n)switch(s){case"CLOSED-CAPTIONS":if("NONE"===a)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":sA.warn(`${e}: attribute ${s} is missing quotes`)}r[s]=a}return r}}class ns{constructor(e,t,i=0){var r;if(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==t?void 0:t.tagAnchor)||null,this.tagOrder=null!=(r=null==t?void 0:t.tagOrder)?r:i,t){const i=t.attr;for(const t in i)if(Object.prototype.hasOwnProperty.call(e,t)&&e[t]!==i[t]){sA.warn(`DATERANGE tag attribute: "${t}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=t;break}e=sp(new nr({}),i,e)}if(this.attr=e,t?(this._startDate=t._startDate,this._cue=t._cue,this._endDate=t._endDate,this._dateAtEnd=t._dateAtEnd):this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){const e=(null==t?void 0:t.endDate)||new Date(this.attr["END-DATE"]);se(e.getTime())&&(this._endDate=e)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get cue(){let 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}get startTime(){let{tagAnchor:e}=this;return null===e||null===e.programDateTime?(sA.warn(`Expected tagAnchor Fragment with PDT set for DateRange "${this.id}": ${e}`),NaN):e.start+(this.startDate.getTime()-e.programDateTime)/1e3}get startDate(){return this._startDate}get endDate(){let e=this._endDate||this._dateAtEnd;if(e)return e;let t=this.duration;return null!==t?this._dateAtEnd=new Date(this._startDate.getTime()+1e3*t):null}get duration(){if("DURATION"in this.attr){let e=this.attr.decimalFloatingPoint("DURATION");if(se(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isInterstitial(){return"com.apple.hls.interstitial"===this.class}get isValid(){return!!this.id&&!this._badValueForSameId&&se(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)}}class na{constructor(e){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.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.drift
1StartTime=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=e}reloaded(e){if(!e){this.advanced=!0,this.updated=!0;return}let 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}hasKey(e){return this.encryptedFragments.some(t=>{let i=t.decryptdata;return i||(t.setKeyFormat(e.keyFormat),i=t.decryptdata),!!i&&e.matches(i)})}get hasProgramDateTime(){return!!this.fragments.length&&se(this.fragments[this.fragments.length-1].programDateTime)}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||10}get drift(){let e=this.driftEndTime-this.driftStartTime;return e>0?1e3*(this.driftEnd-this.driftStart)/e:1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){return this.fragments.length?this.fragments[this.fragments.length-1].end:0}get fragmentStart(){return this.fragments.length?this.fragments[0].start:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].index:-1}get maxPartIndex(){let e=this.partList;if(e){let t=this.lastPartIndex;if(-1!==t){for(let i=e.length;i--;)if(e[i].index>t)return e[i].index;return t}}return 0}get lastPartSn(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}get expired(){if(this.live&&this.age&&this.misses<3){let e=this.partEnd-this.fragmentStart;return this.age>Math.max(e,this.totalduration)+this.levelTargetDuration}return!1}}function nn(e,t){return e.length===t.length&&!e.some((e,i)=>e!==t[i])}function nl(e,t){return!e&&!t||!!e&&!!t&&nn(e,t)}function no(e){return"AES-128"===e||"AES-256"===e||"AES-256-CTR"===e}function nd(e){switch(e){case"AES-128":case"AES-256":return 0;case"AES-256-CTR":return 1;default:throw Error(`invalid full segment method ${e}`)}}function nh(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0))}function nu(e){return Uint8Array.from(unescape(encodeURIComponent(e)),e=>e.charCodeAt(0))}function nc(e){let t=function(e,t,i){let r=e[t];e[t]=e[i],e[i]=r};t(e,0,3),t(e,1,2),t(e,4,5),t(e,6,7)}function nf(e){let t=e.split(":"),i=null;if("data"===t[0]&&2===t.length){let e=t[1].split(";"),r=e[e.length-1].split(",");if(2===r.length){let t="base64"===r[0],s=r[1];if(t)e.splice(-1,1),i=nh(s);else{let e,t;e=nu(s).subarray(0,16),(t=new Uint8Array(16)).set(e,16-e.length),i=t}}}return i}let nm="u">typeof self?self:void 0;var np="org.w3.clearkey",ng="com.apple.fps",nv="com.microsoft.playready",nE="com.widevine.alpha",ny="org.w3.clearkey",nb="com.apple.streamingkeydelivery",nT="com.microsoft.playready",n_="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function nA(e){switch(e){case nb:return ng;case nT:return nv;case n_:return nE;case ny:return np}}function nS(e){switch(e){case ng:return nb;case nv:return nT;case nE:return n_;case np:return ny}}function nk(e){let{drmSystems:t,widevineLicenseUrl:i}=e,r=t?[ng,nE,nv,np].filter(e=>!!t[e]):[];return!r[nE]&&i&&r.push(nE),r}let nL=null!=nm&&null!=(uS=nm.navigator)&&uS.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;function nR(e){let t=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2),i=String.fromCharCode.apply(null,Array.from(t)),r=i.substring(i.indexOf("<"),i.length),s=new DOMParser().parseFromString(r,"text/xml").getElementsByTagName("KID")[0];if(s){let e=s.childNodes[0]?s.childNodes[0].nodeValue:s.getAttribute("VALUE");if(e){let t=nh(e).subarray(0,16);return nc(t),t}}return null}let nI={};class nw{static clearKeyUriToKeyIdMap(){nI={}}static setKeyIdForUri(e,t){nI[e]=t}static addKeyIdForUri(e){let t=Object.keys(nI).length%Number.MAX_SAFE_INTEGER,i=new Uint8Array(16);return new DataView(i.buffer,12,4).setUint32(0,t),nI[e]=i,i}constructor(e,t,i,r=[1],s=null,a){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.pss
1h=null,this.method=e,this.uri=t,this.keyFormat=i,this.keyFormatVersions=r,this.iv=s,this.encrypted=!!e&&"NONE"!==e,this.isCommonEncryption=this.encrypted&&!no(e),null!=a&&a.startsWith("0x")&&(this.keyId=new Uint8Array(sI(a)))}matches(e){return e.uri===this.uri&&e.method===this.method&&e.encrypted===this.encrypted&&e.keyFormat===this.keyFormat&&nn(e.keyFormatVersions,this.keyFormatVersions)&&nl(e.iv,this.iv)&&nl(e.keyId,this.keyId)}isSupported(){if(this.method){if(no(this.method)||"NONE"===this.method)return!0;if("identity"===this.keyFormat)return"SAMPLE-AES"===this.method;switch(this.keyFormat){case nb:case n_:case nT:case ny:return -1!==["SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)}}return!1}getDecryptData(e,t){var i,r;if(!this.encrypted||!this.uri)return null;if(no(this.method)){let t=this.iv;return t||("number"!=typeof e&&(sA.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0),t=function(e){let t=new Uint8Array(16);for(let i=12;i<16;i++)t[i]=e>>8*(15-i)&255;return t}(e)),new nw(this.method,this.uri,"identity",this.keyFormatVersions,t)}if(this.keyId){let e=nI[this.uri];if(e&&!nn(this.keyId,e)&&nw.setKeyIdForUri(this.uri,this.keyId),this.pssh)return this}let s=nf(this.uri);if(s)switch(this.keyFormat){case n_:if(this.pssh=s,!this.keyId){let e=function(e){let t=[];if(e instanceof ArrayBuffer){let i=e.byteLength,r=0;for(;r+32<i;){let i=function(e){let t=e.getUint32(0),i=e.byteOffset,r=e.byteLength;if(r<t)return{offset:i,size:r};if(0x70737368!==e.getUint32(4))return{offset:i,size:t};let s=e.getUint32(8)>>>24;if(0!==s&&1!==s)return{offset:i,size:t};let a=e.buffer,n=sR(new Uint8Array(a,i+12,16)),l=null,o=0;if(0===s)o=28;else{let s=e.getUint32(28);if(!s||r<32+16*s)return{offset:i,size:t};l=[];for(let e=0;e<s;e++)l.push(new Uint8Array(a,i+32+16*e,16));o=32+16*s}if(!o)return{offset:i,size:t};let d=e.getUint32(o);return t-32<d?{offset:i,size:t}:{version:s,systemId:n,kids:l,data:new Uint8Array(a,i+o+4,d),offset:i,size:t}}(new DataView(e,r));t.push(i),r+=i.size}}return t}(s.buffer);if(e.length){let t=e[0];this.keyId=null!=(i=t.kids)&&i.length?t.kids[0]:null}}this.keyId||(this.keyId=nD(t));break;case nT:{let e=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=function(e,t){let i,r;if(16!==e.byteLength)throw RangeError("Invalid system id");i=new Uint8Array,r=new Uint8Array;let s=new Uint8Array(4);return t.byteLength>0&&new DataView(s.buffer).setUint32(0,t.byteLength,!1),function(e,...t){let i=t.length,r=8,s=i;for(;s--;)r+=t[s].byteLength;let a=new Uint8Array(r);for(a[0]=r>>24&255,a[1]=r>>16&255,a[2]=r>>8&255,a[3]=255&r,a.set(e,4),s=0,r=8;s<i;s++)a.set(t[s],r),r+=t[s].byteLength;return a}([112,115,115,104],new Uint8Array([0,0,0,0]),e,r,i,s,t)}(e,s),this.keyId=nR(s);break}default:{let e=s.subarray(0,16);if(16!==e.length){let t=new Uint8Array(16);t.set(e,16-e.length),e=t}this.keyId=e}}if(!this.keyId||16!==this.keyId.byteLength){let e,i;!(e=(i=null==(r=t)?void 0:r[n_])?i.keyId:null)&&((e=nD(t))||(e=nI[this.uri])),e&&(this.keyId=e,nw.setKeyIdForUri(this.uri,e))}return this}}function nD(e){let t=null==e?void 0:e[nT];if(t){let e=nf(t.uri);if(e)return nR(e)}return null}let nC=/#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,nP=/#EXT-X-MEDIA:(.*)/g,nx=/^#EXT(?:INF|-X-TARGETDURATION):/m,nM=RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#.*/.source].join("|"),"g"),nO=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("|"));class nN{static findGroup(e,t){for(let i=0;i<e.length;i++){let r=e[i];if(r.id===t)return r}}static resolve(e,t){return sD.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return nx.test(e)}static parseMasterPlaylist(e,t){var i;let r,s={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:a9.test(e)},a=[];if(nC.lastIndex=0,!e.startsWith("#EXTM3U"))return s.playlistParsingError=Error("no EXTM3U delimiter"),s;for(;null!=(r=nC.exec(e));)if(r[1]){let e=new nr(r[1],s),n=a7(s,r[2]),l={attrs:e,bitrate:e.decimalInteger("BANDWIDTH")||e.decimalInteger("AVERAGE-BANDWIDTH"),name:e.NAME,url:nN.resolve(n,t)},o=e.decimalResolution("RESOLUTION");o&&(l.width=o.width,l.height=o.height),nB(e.CODECS,l);let d=e["SUPPLEMENTAL-CODECS"];d&&(l.supplemental={},nB(d,l.supplemental)),null!=(i=l.unknownCodecs)&&i.length||a.push(l),s.levels.push(l)}else if(r[3]){let e=r[3],i=r[4];switch(e){case"SESSION-DATA":{let e=new nr(i,s),t=e["DATA-ID"];t&&(null===s.sessionData&&(s.sessionData={}),s.sessionData[t]=e);break}case"SESSION-KEY":{let e=nF(i,t,s);e.encrypted&&e.isSupported()?(null===s.sessionKeys&&(s.sessionKeys=[]),s.sessionKeys.push(e)):sA.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${i}"`);break}case"DEFINE":{let e=new nr(i,s);ne(s,e,t)}break;case"CONTENT-STEERING":{let e=new nr(i,s);s.contentSteering={uri:nN.resolve(e["SERVER-URI"],t),pathwayId:e["PATHWAY-ID"]||"."};break}case"START":s.startTimeOffset=n$(i)}}let n=a.length>0&&a.length<s.levels.length;return s.levels=n?a:s.levels,0===s.levels.length&&(s.playlistParsingError=Error("no levels found in manifest")),s}static parseMasterPlaylistMedia(e,t,i){let r,s={},a=i.levels,n={AUDIO:a.map(e=>({id:e.attrs.AUDIO,audioCodec:e.audioCodec})),SUBTITLES:a.map(e=>({id:e.attrs.SUBTITLES,textCodec:e.textCodec})),"CLOSED-CAPTIONS":[]},l=0;for(nP.lastIndex=0;null!==(r=nP.exec(e));){let e=new nr(r[1],i),a=e.TYPE;if(a){let i=n[a],r=s[a]||[];s[a]=r;let o=e.LANGUAGE,d=e["ASSOC-LANGUAGE"],h=e.CHANNELS,u=e.CHARACTERISTICS,c=e["INSTREAM-ID"],f={attrs:e,bitrate:0,id:l++,groupId:e["GROUP-ID"]||"",name:e.NAME||o||"",type:a,default:e.bool("DEFAULT"),autoselect:e.bool("AUTOSELECT"),forced:e.bool("FORCED"),lang:o,url:e.URI?nN.resolve(e.URI,t):""};if(d&&(f.assocLang=d),h&&(f.channels=h),u&&(f.characteristics=u),c&&(f.instreamId=c),null!=i&&i.length){let e=nN.findGroup(i,f.groupId)||i[0];nH(f,e,"audioCodec"),nH(f,e,"textCodec")}r.push(f)}}return s}static parseLevelPlaylist(e,t,i,r,s,a){var n;let l,o,d,h,u={url:t},c=new na(t),f=c.fragments,m=[],g=null,v=0,E=0,y=0,b=0,T=0,_=null,A=new sU(r,u),S=-1,k=!1,L=null;if(nM.lastIndex=0,c.m3u8=e,c.hasVariableRefs=a9.test(e),(null==(n=nM.exec(e))?void 0:n[0])!=="#EXTM3U")return c.playlistParsingError=Error("Missing format identifier #EXTM3U"),c;for(;null!==(l=nM.exec(e));){k&&(k=!1,(A=new sU(r,u)).playlistOffset=y,A.setStart(y),A.sn=v,A.cc=b,T&&(A.bitrate=T),A.level=i,g&&(A.initSegment=g,g.rawProgramDateTime&&(A.rawProgramDateTime=g.rawProgramDateTime,g.rawProgramDateTime=null),L&&(A.setByteRange(L),L=null)));let e=l[1];if(e){A.duration=parseFloat(e);let t=(" "+l[2]).slice(1);A.title=t||null,A.tagList.push(t?["INF",e,t]:["INF",e])}else if(l[3]){if(se(A.duration)){A.playlistOffset=y,A.setStart(y),d&&nK(A,d,c),A.sn=v,A.level=i,A.cc=b,f.push(A);let e=(" "+l[3]).slice(1);A.relurl=a7(c,e),nG(A,_,m),_=A,y+=A.duration,v++,E=0,k=!0}}
1else{if(!(l=l[0].match(nO))){sA.warn("No matches on slow regex match for level playlist!");continue}for(o=1;o<l.length&&void 0===l[o];o++);let e=(" "+l[o]).slice(1),s=(" "+l[o+1]).slice(1),n=l[o+2]?(" "+l[o+2]).slice(1):null;switch(e){case"BYTERANGE":_?A.setByteRange(s,_):A.setByteRange(s);break;case"PROGRAM-DATE-TIME":A.rawProgramDateTime=s,A.tagList.push(["PROGRAM-DATE-TIME",s]),-1===S&&(S=f.length);break;case"PLAYLIST-TYPE":c.type&&nW(c,e,l),c.type=s.toUpperCase();break;case"MEDIA-SEQUENCE":0!==c.startSN?nW(c,e,l):f.length>0&&nq(c,e,l),v=c.startSN=parseInt(s);break;case"SKIP":{c.skippedSegments&&nW(c,e,l);let t=new nr(s,c),i=t.decimalInteger("SKIPPED-SEGMENTS");if(se(i)){c.skippedSegments+=i;for(let e=i;e--;)f.push(null);v+=i}let r=t.enumeratedString("RECENTLY-REMOVED-DATERANGES");r&&(c.recentlyRemovedDateranges=(c.recentlyRemovedDateranges||[]).concat(r.split("	")));break}case"TARGETDURATION":0!==c.targetduration&&nW(c,e,l),c.targetduration=Math.max(parseInt(s),1);break;case"VERSION":null!==c.version&&nW(c,e,l),c.version=parseInt(s);break;case"INDEPENDENT-SEGMENTS":break;case"ENDLIST":c.live||nW(c,e,l),c.live=!1;break;case"#":(s||n)&&A.tagList.push(n?[s,n]:[s]);break;case"DISCONTINUITY":b++,A.tagList.push(["DIS"]);break;case"GAP":A.gap=!0,A.tagList.push([e]);break;case"BITRATE":A.tagList.push([e,s]),se(T=1e3*parseInt(s))?A.bitrate=T:T=0;break;case"DATERANGE":{let e=new nr(s,c),t=new ns(e,c.dateRanges[e.ID],c.dateRangeTagCount);c.dateRangeTagCount++,t.isValid||c.skippedSegments?c.dateRanges[t.id]=t:sA.warn(`Ignoring invalid DATERANGE tag: "${s}"`),A.tagList.push(["EXT-X-DATERANGE",s]);break}case"DEFINE":{let e=new nr(s,c);"IMPORT"in e?function(e,t,i){let r=t.IMPORT;if(i&&r in i){let t=e.variableList;t||(e.variableList=t={}),t[r]=i[r]}else e.playlistParsingError||(e.playlistParsingError=Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${r}"`))}(c,e,a):ne(c,e,t)}break;case"DISCONTINUITY-SEQUENCE":0!==c.startCC?nW(c,e,l):f.length>0&&nq(c,e,l),c.startCC=b=parseInt(s);break;case"KEY":{let e=nF(s,t,c);if(e.isSupported()){if("NONE"===e.method){d=void 0;break}d||(d={});let t=d[e.keyFormat];null!=t&&t.matches(e)||(t&&(d=sp({},d)),d[e.keyFormat]=e)}else sA.warn(`[Keys] Ignoring unsupported EXT-X-KEY tag: "${s}"`);break}case"START":c.startTimeOffset=n$(s);break;case"MAP":{let e=new nr(s,c);if(A.duration){let t=new sU(r,u);nV(t,e,i,d),g=t,A.initSegment=g,g.rawProgramDateTime&&!A.rawProgramDateTime&&(A.rawProgramDateTime=g.rawProgramDateTime)}else{let t=A.byteRangeEndOffset;if(t){let e=A.byteRangeStartOffset;L=`${t-e}@${e}`}else L=null;nV(A,e,i,d),g=A,k=!0}g.cc=b;break}case"SERVER-CONTROL":h&&nW(c,e,l),c.canBlockReload=(h=new nr(s)).bool("CAN-BLOCK-RELOAD"),c.canSkipUntil=h.optionalFloat("CAN-SKIP-UNTIL",0),c.canSkipDateRanges=c.canSkipUntil>0&&h.bool("CAN-SKIP-DATERANGES"),c.partHoldBack=h.optionalFloat("PART-HOLD-BACK",0),c.holdBack=h.optionalFloat("HOLD-BACK",0);break;case"PART-INF":c.partTarget&&nW(c,e,l),c.partTarget=new nr(s).decimalFloatingPoint("PART-TARGET");break;case"PART":{let e=c.partList;e||(e=c.partList=[]);let t=E>0?e[e.length-1]:void 0,i=E++,r=new sF(new nr(s,c),A,u,i,t);e.push(r),A.duration+=r.duration;break}case"PRELOAD-HINT":{let e=new nr(s,c);c.preloadHint=e;break}case"RENDITION-REPORT":{let e=new nr(s,c);c.renditionReports=c.renditionReports||[],c.renditionReports.push(e);break}default:sA.warn(`line parsed but not handled: ${l}`)}}}_&&!_.relurl?(f.pop(),y-=_.duration,c.partList&&(c.fragmentHint=_)):c.partList&&(nG(A,_,m),A.cc=b,c.fragmentHint=A,d&&nK(A,d,c)),c.targetduration||(c.playlistParsingError=Error("Missing Target Duration"));let R=f.length,I=f[0],w=f[R-1];if((y+=c.skippedSegments*c.targetduration)>0&&R&&w){c.averagetargetduration=y/R;let e=w.sn;c.endSN="initSegment"!==e?e:0,c.live||(w.endList=!0),S>0&&(function(e,t){let i=e[t];for(let r=t;r--;){let t=e[r];if(!t)return;t.programDateTime=i.programDateTime-1e3*t.duration,i=t}}(f,S),I&&m.unshift(I))}return c.fragmentHint&&(y+=c.fragmentHint.duration),c.totalduration=y,m.length&&c.dateRangeTagCount&&I&&nU(m,c),c.endCC=b,c}}function nU(e,t){let i=e.length;if(!i)if(!t.hasProgramDateTime)return;else{let r=t.fragments[t.fragments.length-1];e.push(r),i++}let r=e[i-1],s=t.live?1/0:t.totalduration,a=Object.keys(t.dateRanges);for(let l=a.length;l--;){let o=t.dateRanges[a[l]],d=o.startDate.getTime();o.tagAnchor=r.ref;for(let r=i;r--;){var n;if((null==(n=e[r])?void 0:n.sn)<t.startSN)break;let i=function(e,t,i,r,s){let a=i[r];if(a){let l=a.programDateTime;if(t>=l||0===r){var n;if(t<=l+1e3*(((null==(n=i[r+1])?void 0:n.start)||s)-a.start)){let s=i[r].sn-e.startSN;if(s<0)return -1;let a=e.fragments;if(a.length>i.length){let n=(i[r+1]||a[a.length-1]).sn-e.startSN;for(let e=n;e>s;e--){let i=a[e].programDateTime;if(t>=i&&t<i+1e3*a[e].duration)return e}}return s}}}return -1}(t,d,e,r,s);if(-1!==i){o.tagAnchor=t.fragments[i].ref;break}}}}function nF(e,t,i){var r,s;let a=new nr(e,i),n=null!=(r=a.METHOD)?r:"",l=a.URI,o=a.hexadecimalInteger("IV"),d=a.KEYFORMATVERSIONS,h=null!=(s=a.KEYFORMAT)?s:"identity";return l&&a.IV&&!o&&sA.error(`Invalid IV: ${a.IV}
1`),new nw(n,l?nN.resolve(l,t):"",h,(d||"1").split("/").map(Number).filter(Number.isFinite),o,a.KEYID)}function n$(e){let t=new nr(e).decimalFloatingPoint("TIME-OFFSET");return se(t)?t:null}function nB(e,t){let i=(e||"").split(/[ ,]+/).filter(e=>e);["video","audio","text"].forEach(e=>{let r=i.filter(t=>s8(t,e));r.length&&(t[`${e}Codec`]=r.map(e=>e.split("/")[0]).join(","),i=i.filter(e=>-1===r.indexOf(e)))}),t.unknownCodecs=i}function nH(e,t,i){let r=t[i];r&&(e[i]=r)}function nG(e,t,i){e.rawProgramDateTime?i.push(e):null!=t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime)}function nV(e,t,i,r){e.relurl=t.URI,t.BYTERANGE&&e.setByteRange(t.BYTERANGE),e.level=i,e.sn="initSegment",r&&(e.levelkeys=r),e.initSegment=null}function nK(e,t,i){e.levelkeys=t;let{encryptedFragments:r}=i;(!r.length||r[r.length-1].levelkeys!==t)&&Object.keys(t).some(e=>t[e].isCommonEncryption)&&r.push(e)}function nW(e,t,i){e.playlistParsingError=Error(`#EXT-X-${t} must not appear more than once (${i[0]})`)}function nq(e,t,i){e.playlistParsingError=Error(`#EXT-X-${t} must appear before the first Media Segment (${i[0]})`)}function nj(e,t){let i=t.startPTS;if(se(i)){let r,s=0;t.sn>e.sn?(s=i-e.start,r=e):(s=e.start-i,r=t),r.duration!==s&&r.setDuration(s)}else t.sn>e.sn?e.cc===t.cc&&e.minEndPTS?t.setStart(e.start+(e.minEndPTS-e.start)):t.setStart(e.start+e.duration):t.setStart(Math.max(e.start-t.duration,0))}function nY(e,t,i,r,s,a,n){let l;r-i<=0&&(n.warn("Fragment should have a positive duration",t),r=i+t.duration,a=s+t.duration);let o=i,d=r,h=t.startPTS,u=t.endPTS;if(se(h)){let l=Math.abs(h-i);e&&l>e.totalduration?n.warn(`media timestamps and playlist times differ by ${l}s for level ${t.level} ${e.url}`):se(t.deltaPTS)?t.deltaPTS=Math.max(l,t.deltaPTS):t.deltaPTS=l,o=Math.max(i,h),i=Math.min(i,h),s=void 0!==t.startDTS?Math.min(s,t.startDTS):s,d=Math.min(r,u),r=Math.max(r,u),a=void 0!==t.endDTS?Math.max(a,t.endDTS):a}let c=i-t.start;0!==t.start&&t.setStart(i),t.setDuration(r-t.start),t.startPTS=i,t.maxStartPTS=o,t.startDTS=s,t.endPTS=r,t.minEndPTS=d,t.endDTS=a;let f=t.sn;if(!e||f<e.startSN||f>e.endSN)return 0;let m=f-e.startSN,g=e.fragments;for(g[m]=t,l=m;l>0;l--)nj(g[l],g[l-1]);for(l=m;l<g.length-1;l++)nj(g[l],g[l+1]);return e.fragmentHint&&nj(g[g.length-1],e.fragmentHint),e.PTSKnown=e.alignedSliding=!0,c}function nQ(e,t,i,r,s){return Error(`${e} ${s.url}
2Playlist starting @${t.startSN}
3${t.m3u8}
4
5Playlist starting @${i.startSN}
6${i.m3u8}`)}function nz(e,t,i=!0){let r=t.startSN+t.skippedSegments-e.startSN,s=e.fragments,a=r>=0,n=0;if(a&&r<s.length)n=s[r].start;else if(a&&t.startSN===e.endSN+1)n=e.fragmentEnd;else if(a&&i)n=e.fragmentStart+r*t.levelTargetDuration;else{if(t.skippedSegments||0!==t.fragmentStart)return;n=e.fragmentStart}nX(t,n)}function nX(e,t){if(t){let i=e.fragments;for(let r=e.skippedSegments;r<i.length;r++)i[r].addStart(t);e.fragmentHint&&e.fragmentHint.addStart(t)}}function nZ(e,t=1/0){let i=1e3*e.targetduration;if(e.updated){let r=e.fragments;if(r.length&&4*i>t){let e=1e3*r[r.length-1].duration;e<i&&(i=e)}}else i/=2;return Math.round(i)}function nJ(e,t,i){if(!e)return null;let r=e.fragments[t-e.startSN];return r||(r=e.fragmentHint)&&r.sn===t?r:t<e.startSN&&i&&i.sn===t?i:null}function n0(e,t,i){return e?n1(e.partList,t,i):null}function n1(e,t,i){if(e)for(let r=e.length;r--;){let s=e[r];if(s.index===i&&s.fragment.sn===t)return s}return null}function n2(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 n3(e){return e.replace(/\?[^?]*$/,"")}function n4(e,t){for(let r=0,s=e.length;r<s;r++){var i;if((null==(i=e[r])?void 0:i.cc)===t)return e[r]}return null}function n5(e,t){let i=e.start+t;e.startPTS=i,e.setStart(i),e.endPTS=i+e.duration}function n8(e,t){let i=t.fragments;for(let t=0,r=i.length;t<r;t++)n5(i[t],e);t.fragmentHint&&n5(t.fragmentHint,e),t.alignedSliding=!0}function n6(e,t){if((!t||!(e.startCC<t.endCC)||!(e.endCC>t.startCC))&&1)return;let i=Math.min(t.endCC,e.endCC),r=n4(t.fragments,i),s=n4(e.fragments,i);r&&s&&(sA.log(`Aligning playlist at start of dicontinuity sequence ${i}`),n8(r.start-s.start,e))}function n9(e,t){let i,r;if(!e.hasProgramDateTime||!t.hasProgramDateTime)return;let s=e.fragments,a=t.fragments;if(!s.length||!a.length)return;let n=Math.min(t.endCC,e.endCC);t.startCC<n&&e.startCC<n&&(i=n4(a,n),r=n4(s,n)),i&&r||(r=n4(s,(i=a[Math.floor(a.length/2)]).cc)||s[Math.floor(s.length/2)]);let l=i.programDateTime,o=r.programDateTime;l&&o&&n8((o-l)/1e3-(r.start-i.start),e)}function n7(e,t,i){le(e,t,i),e.addEventListener(t,i)}function le(e,t,i){e.removeEventListener(t,i)}let lt=function(e){let t="",i=e.length;for(let r=0;r<i;r++)t+=`[${e.start(r).toFixed(3)}-${e.end(r).toFixed(3)}]`;return t},li="STOPPED",lr="IDLE",ls="KEY_LOADING",la="FRAG_LOADING",ln="FRAG_LOADING_WAITING_RETRY",ll="WAITING_TRACK",lo="PARSING",ld="PARSED",lh="ENDED",lu="ERROR",lc="WAITING_INIT_PTS",lf="WAITING_LEVEL";class lm extends a3{constructor(e,t,i,r,s){super(r,e.logger),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=li,this.playlistType=void 0,this.media=null,this.mediaBuffer=null,this.config=void 0,this.bitrateTest=!1,this.lastCurrentTime=0,this.nextLoadPosition=0,this.startPosition=0,this.startTimeOffset=null,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.keyLoader=void 0,this.levelLastLoaded=null,this.startFragRequested=!1,this.decrypter=void 0,this.initPTS=[],this.buffering=!0,this.loadingParts=!1,this.loopSn=void 0,this.onMediaSeeking=()=>{let{config:e,fragCurrent:t,media:i,mediaBuffer:r,state:s}=this,a=i?i.currentTime:0,n=a6.bufferInfo(r||i,a,e.maxBufferHole),l=!n.len;if(this.log(`Media seeking to ${se(a)?a.toFixed(3):a}, state: ${s}, ${l?"out of":"in"} buffer`),this.state===lh)this.resetLoadingState();else if(t){let i=e.maxFragLookUpTolerance,r=t.start-i,s=t.start+t.duration+i;if(l||s<n.start||r>n.end){let e=a>s;(a<r||e)&&(e&&t.loader&&(this.log(`Cancelling fragment load for seek (sn: ${t.sn})`),t.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}if(i&&(this.fragmentTracker.removeFragmentsInRange(a,1/0,this.playlistType,!0),a>this.lastCurrentTime&&(this.lastCurrentTime=a),!this.loadingParts)){let e=Math.max(n.end,a),t=this.shouldLoadParts(this.getLevelDetails(),e);t&&(this.log(`LL-Part loading ON after seeking to ${a.toFixed(2)} with buffer @${e.toFixed(2)}`),this.loadingParts=t)}!this.hls.hasEnoughToStart&&(this.log(`Setting ${l?"startPosition":"nextLoadPosition"} to ${a} for seek without enough to start`),this.nextLoadPosition=a,l&&(this.startPosition=a)),l&&this.state===lr&&this.tickImmediate()},this.onMediaEnded=()=>{this.log("setting startPosition to 0 because media ended"),this.startPosition=this.lastCurrentTime=0},this.playlistType=s,this.hls=e,this.fragmentLoader=new aJ(e.config),this.keyLoader=i,this.fragmentTracker=t,this.config=e.config,this.decrypter=new aZ(e.config)}registerListeners(){let{hls:e}=this;
6e.on(sa.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(sa.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(sa.MANIFEST_LOADING,this.onManifestLoading,this),e.on(sa.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(sa.ERROR,this.onError,this)}unregisterListeners(){let{hls:e}=this;e.off(sa.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(sa.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(sa.MANIFEST_LOADING,this.onManifestLoading,this),e.off(sa.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(sa.ERROR,this.onError,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){if(this.state===li)return;this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);let 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=li}get startPositionValue(){let{nextLoadPosition:e,startPosition:t}=this;return -1===t&&e?e:t}get bufferingEnabled(){return this.buffering}pauseBuffering(){this.buffering=!1}resumeBuffering(){this.buffering=!0}get inFlightFrag(){return{frag:this.fragCurrent,state:this.state}}_streamEnded(e,t){if(t.live||!this.media)return!1;let i=e.end||0,r=this.config.timelineOffset||0;if(i<=r)return!1;let s=e.buffered;this.config.maxBufferHole&&s&&s.length>1&&(e=a6.bufferedInfo(s,e.start,0));let a=e.nextStart;if(a&&a>r&&a<t.edge||this.media.currentTime<e.start)return!1;let n=t.partList;if(null!=n&&n.length){let e=n[n.length-1];return a6.isBuffered(this.media,e.start+e.duration/2)}let l=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(l)}getLevelDetails(){if(this.levels&&null!==this.levelLastLoaded)return this.levelLastLoaded.details}get timelineOffset(){let e=this.config.timelineOffset;if(e){var t;return(null==(t=this.getLevelDetails())?void 0:t.appliedTimelineOffset)||e}return 0}onMediaAttached(e,t){let i=this.media=this.mediaBuffer=t.media;n7(i,"seeking",this.onMediaSeeking),n7(i,"ended",this.onMediaEnded);let r=this.config;this.levels&&r.autoStartLoad&&this.state===li&&this.startLoad(r.startPosition)}onMediaDetaching(e,t){let i=!!t.transferMedia,r=this.media;if(null!==r){if(r.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),le(r,"seeking",this.onMediaSeeking),le(r,"ended",this.onMediaEnded),this.keyLoader&&!i&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loopSn=void 0,i){this.resetLoadingState(),this.resetTransmuxer();return}this.loadingParts=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}}onManifestLoading(){this.initPTS=[],this.levels=this.levelLastLoaded=this.fragCurrent=null,this.lastCurrentTime=this.startPosition=0,this.startFragRequested=!1}onError(e,t){}onManifestLoaded(e,t){this.startTimeOffset=t.startTimeOffset}onHandlerDestroying(){this.stopLoad(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),super.onHandlerDestroying(),this.hls=this.onMediaSeeking=this.onMediaEnded=null}onHandlerDestroyed(){this.state=li,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,super.onHandlerDestroyed()}loadFragment(e,t,i){this.startFragRequested=!0,this._loadFragForPlayback(e,t,i)}_loadFragForPlayback(e,t,i){let r=e=>{let t=e.frag;if(this.fragContextChanged(t)){this.warn(`${t.type} sn: ${t.sn}${e.part?" part: "+e.part.index:""} of ${this.fragInfo(t,!1,e.part)}) was dropped during download.`),this.fragmentTracker.removeFragment(t);return}t.stats.chunkCount++,this._handleFragmentLoadProgress(e)};this._doFragLoad(e,t,i,r).then(e=>{if(!e)return;let t=this.state,i=e.frag;if(this.fragContextChanged(i)){t!==la&&(this.fragCurrent||t!==lo)||(this.fragmentTracker.removeFragment(i),this.state=lr);return}"payload"in e&&(this.log(`Loaded ${i.type} sn: ${i.sn} of ${this.playlistLabel()} ${i.level}`),this.hls.trigger(sa.FRAG_LOADED,e)),this._handleFragmentLoadComplete(e)}).catch(t=>{this.state!==li&&this.state!==lu&&(this.warn(`Frag error: ${(null==t?void 0:t.message)||t}`),this.resetFragmentLoading(e))})}clearTrackerIfNeeded(e){var t;let{fragmentTracker:i}=this;if(i.getState(e)===aV){let t=e.type,r=this.getFwdBufferInfo(this.mediaBuffer,t),s=Math.max(e.duration,r?r.len:this.config.maxBufferLength),a=this.backtrackFragment;(1==(a?e.sn-a.sn:0)||this.reduceMaxBufferLength(s,e.duration))&&i.removeFragment(e)}else(null==(t=this.mediaBuffer)?void 0:t.buffered.length)===0?i.removeAllFragments():i.hasParts(e.type)&&(i.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),i.getState(e)===aK&&i.removeFragment(e))}checkLiveUpdate(e){if(e.updated&&!e.live){let 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)}waitForLive(e){let t=e.details;return(null==t?void 0:t.live)&&"EVENT"!==t.type&&(this.levelLastLoaded!==e||t.expired)}flushMainBuffer(e,t,i=null){e-t&&this.hls.trigger(sa.BUFFER_FLUSHING,{startOffset:e,endOffset:t,type:i})}_loadInitSegment(e,t){this._doFragLoad(e,t).then(e=>{let t=null==e?void 0:e.frag;if(!t||this.fragContextChanged(t)||!this.levels)throw Error("init load aborted");return e}).then(e=>{let{hls:t}=this,{frag:i,payload:r}=e,s=i.decryptdata;if(r&&r.byteLength>0&&null!=s&&s.key&&s.iv&&no(s.method)){let a=self.performance.now();
6return this.decrypter.decrypt(new Uint8Array(r),s.key.buffer,s.iv.buffer,nd(s.method)).catch(e=>{throw t.trigger(sa.ERROR,{type:sr.MEDIA_ERROR,details:ss.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:i}),e}).then(r=>{let s=self.performance.now();return t.trigger(sa.FRAG_DECRYPTED,{frag:i,payload:r,stats:{tstart:a,tdecrypt:s}}),e.payload=r,this.completeInitSegmentLoad(e)})}return this.completeInitSegmentLoad(e)}).catch(t=>{this.state!==li&&this.state!==lu&&(this.warn(t),this.resetFragmentLoading(e))})}completeInitSegmentLoad(e){let{levels:t}=this;if(!t)throw Error("init load aborted, missing levels");let i=e.frag.stats;this.state!==li&&(this.state=lr),e.frag.data=new Uint8Array(e.payload),i.parsing.start=i.buffering.start=self.performance.now(),i.parsing.end=i.buffering.end=self.performance.now(),this.tick()}unhandledEncryptionError(e,t){var i,r;let s=e.tracks;if(s&&!t.encrypted&&(null!=(i=s.audio)&&i.encrypted||null!=(r=s.video)&&r.encrypted)&&(!this.config.emeEnabled||!this.keyLoader.emeController)){let e=this.media,i=Error(`Encrypted track with no key in ${this.fragInfo(t)} (media ${e?"attached mediaKeys: "+e.mediaKeys:"detached"})`);return this.warn(i.message),!!e&&!e.mediaKeys&&(this.hls.trigger(sa.ERROR,{type:sr.KEY_SYSTEM_ERROR,details:ss.KEY_SYSTEM_NO_KEYS,fatal:!1,error:i,frag:t}),this.resetTransmuxer(),!0)}return!1}fragContextChanged(e){let{fragCurrent:t}=this;return!e||!t||e.sn!==t.sn||e.level!==t.level}fragBufferedComplete(e,t){let 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?lt(a6.getBuffered(i)):"(detached)"})`),sN(e)){var r;if(e.type!==sc){let t=e.elementaryStreams;if(!Object.keys(t).some(e=>!!t[e])){this.state=lr;return}}let t=null==(r=this.levels)?void 0:r[e.level];null!=t&&t.fragmentError&&(this.log(`Resetting level fragment error count of ${t.fragmentError} on frag buffered`),t.fragmentError=0)}this.state=lr}_handleFragmentLoadComplete(e){let{transmuxer:t}=this;if(!t)return;let{frag:i,part:r,partsLoaded:s}=e,a=!s||0===s.length||s.some(e=>!e),n=new a4(i.level,i.sn,i.stats.chunkCount+1,0,r?r.index:-1,!a);t.flush(n)}_handleFragmentLoadProgress(e){}_doFragLoad(e,t,i=null,r){var s,a;let n;this.fragCurrent=e;let l=t.details;if(!this.levels||!l)throw Error(`frag load aborted, missing level${l?"":" detail"}s`);let o=null;if(e.encrypted&&!(null!=(s=e.decryptdata)&&s.key)){if(this.log(`Loading key for ${e.sn} of [${l.startSN}-${l.endSN}], ${this.playlistLabel()} ${e.level}`),this.state=ls,this.fragCurrent=e,o=this.keyLoader.load(e).then(e=>{if(!this.fragContextChanged(e.frag))return this.hls.trigger(sa.KEY_LOADED,e),this.state===ls&&(this.state=lr),e}),this.hls.trigger(sa.KEY_LOADING,{frag:e}),null===this.fragCurrent)return this.log("context changed in KEY_LOADING"),Promise.resolve(null)}else!e.encrypted&&(o=this.keyLoader.loadClear(e,l.encryptedFragments,this.startFragRequested))&&this.log("[eme] blocking frag load until media-keys acquired");let d=this.fragPrevious;if(sN(e)&&(!d||e.sn!==d.sn)){let i=this.shouldLoadParts(t.details,e.end);i!==this.loadingParts&&(this.log(`LL-Part loading ${i?"ON":"OFF"} loading sn ${null==d?void 0:d.sn}->${e.sn}`),this.loadingParts=i)}if(i=Math.max(e.start,i||0),this.loadingParts&&sN(e)){let s=l.partList;if(s&&r){i>l.fragmentEnd&&l.fragmentHint&&(e=l.fragmentHint);let a=this.getNextPart(s,e,i);if(a>-1){let n,d=s[a];return(e=this.fragCurrent=d.fragment,this.log(`Loading ${e.type} sn: ${e.sn} part: ${d.index} (${a}/${s.length-1}) of ${this.fragInfo(e,!1,d)}) cc: ${e.cc} [${l.startSN}-${l.endSN}], target: ${parseFloat(i.toFixed(3))}`),this.nextLoadPosition=d.start+d.duration,this.state=la,n=o?o.then(i=>!i||this.fragContextChanged(i.frag)?null:this.doFragPartsLoad(e,d,t,r)).catch(e=>this.handleFragLoadError(e)):this.doFragPartsLoad(e,d,t,r).catch(e=>this.handleFragLoadError(e)),this.hls.trigger(sa.FRAG_LOADING,{frag:e,part:d,targetBufferTime:i}),null===this.fragCurrent)?Promise.reject(Error("frag load aborted, context changed in FRAG_LOADING parts")):n}if(!e.url||this.loadedEndOfParts(s,i))return Promise.resolve(null)}}if(sN(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==(a=l.partList)?void 0:a.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} ${"["+l.startSN+"-"+l.endSN+"]"}, target: ${parseFloat(i.toFixed(3))}`),se(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=la;let h=this.config.progressive&&e.type!==sc;return(n=h&&o?o.then(t=>!t||this.fragContextChanged(t.frag)?null:this.fragmentLoader.load(e,r)).catch(e=>this.handleFragLoadError(e)):Promise.all([this.fragmentLoader.load(e,h?r:void 0),o]).then(([e])=>(!h&&r&&r(e),e)).catch(e=>this.handleFragLoadError(e)),this.hls.trigger(sa.FRAG_LOADING,{frag:e,targetBufferTime:i}),null===this.fragCurrent)?Promise.reject(Error("frag load aborted, context changed in FRAG_LOADING")):n}doFragPartsLoad(e,t,i,r){return new Promise((s,a)=>{var n;let l=[],o=null==(n=i.details)?void 0:n.partList,d=t=>{this.fragmentLoader.loadPart(e,t,r).then(r=>{l[t.index]=r;let a=r.part;this.hls.trigger(sa.FRAG_LOADED,r);let n=n0(i.details,e.sn,t.index+1)||n1(o,e.sn,t.index+1);if(!n)return s({frag:e,part:a,partsLoaded:l});d(n)}).catch(a)};d(t)})}handleFragLoadError(e){if("data"in e){let t=e.data;t.frag&&t.details===ss.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):t.frag&&t.type===sr.KEY_SYSTEM_ERROR?(t.frag.abortRequests(),this.resetStartWhenNotLoaded(),this.resetFragmentLoading(t.frag)):this.hls.trigger(sa.ERROR,t)}else this.hls.trigger(sa.ERROR,{type:sr.OTHER_ERROR,details:ss.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){let t=this.getCurrentContext(e);if(!t||this.state!==lo){this.fragCurrent||this.state===li||this.state===lu||(this.state=lr);return}let{frag:i,part:r,level:s}=t,a=self.performance.now();i.stats.parsing.end=a,r&&(r.stats.parsing.end=a);let n=this.getLevelDetails(),l=n&&i.sn>n.endSN||this.shouldLoadParts(n,i.end);l!==this.loadingParts&&(this.log(`LL-Part loading ${l?"ON":"OFF"} after parsing segment ending @${i.end.toFixed(2)}`),this.loadingParts=l),this.updateLevelTiming(i,r,s,e.partial)}shouldLoadParts(e,t){if(this.config.lowLatencyMode){if(!e)return this.loadingParts;if(e.partList){var i,r;let s=e.partList[0];if(s.fragment.type===sc)return!1;if(t>=s.end+((null==(i=e.fragmentHint)?void 0:i.duration)||0)&&(this.hls.hasEnoughToStart?(null==(r=this.media)?void 0:r.currentTime)||this.lastCurrentTime:this.getLoadPosition())>s.start-s.fragment.duration)return!0}}return!1}getCurrentContext(e){let{levels:t,fragCurrent:i}=this,{level:r,sn:s,part:a}=e;if(!(null!=t&&t[r]))return this.warn(`Levels object was unset while buffering fragment ${s} of ${this.playlistLabel()} ${r}. The current chunk will not be buffered.`),null;let n=t[r],l=n.details,o=a>-1?n0(l,s,a):null,d=o?o.fragment:nJ(l,s,i);return d?(i&&i!==d&&(d.stats=i.stats),{frag:d,part:o,level:n}):null}bufferFragmentData(e,t,i,r,s){if(this.state!==lo)return;let{data1:a,data2:n}=e,l=a;if(n&&(l=s0(a,n)),!l.length)return;let o=this.initPTS[t.cc],d=o?-o.baseTime/o.timescale:void 0,h={type:e.type,frag:t,part:i,chunkMeta:r,offset:d,parent:t.type,data:l};if(this.hls.trigger(sa.BUFFER_APPENDING,h),e.dropped&&e.independent&&!i){if(s)return;this.flushBufferGap(t)}}flushBufferGap(e){let t=this.media;if(!t)return;if(!a6.isBuffered(t,t.currentTime))return void this.flushMainBuffer(0,e.start);let i=t.currentTime,r=a6.bufferInfo(t,i,0),s=e.duration,a=Math.min(2*this.config.maxFragLookUpTolerance,.25*s),n=Math.max(Math.min(e.start-a,r.end-a),i+a);e.start-n>a&&this.flushMainBuffer(n,e.start)}getFwdBufferInfo(e,t){var i;let r=this.getLoadPosition();if(!se(r))return null;let s=this.lastCurrentTime>r||null!=(i=this.media)&&i.paused?0:this.config.maxBufferHole;return this.getFwdBufferInfoAtPos(e,r,t,s)}getFwdBufferInfoAtPos(e,t,i,r){let s=a6.bufferInfo(e,t,r);if(0===s.len&&void 0!==s.nextStart){let a=this.fragmentTracker.getBufferedFrag(t,i);if(a&&(s.nextStart<=a.end||a.gap)){let i=Math.max(Math.min(s.nextStart,a.end)-t,r);return a6.bufferInfo(e,t,i)}}return s}
6getMaxBufferLength(e){let{config:t}=this;return Math.min(e?Math.max(8*t.maxBufferSize/e,t.maxBufferLength):t.maxBufferLength,t.maxMaxBufferLength)}reduceMaxBufferLength(e,t){let i=this.config,r=Math.max(Math.min(e-t,i.maxBufferLength),t),s=Math.max(e-3*t,i.maxMaxBufferLength/2,r);return s>=r&&(i.maxMaxBufferLength=s,this.warn(`Reduce max buffer length to ${s}s`),!0)}getAppendedFrag(e,t=sh){let i=this.fragmentTracker?this.fragmentTracker.getAppendedFrag(e,t):null;return i&&"fragment"in i?i.fragment:i}getNextFragment(e,t){let i=t.fragments,r=i.length;if(!r)return null;let{config:s}=this,a=i[0].start,n=s.lowLatencyMode&&!!t.partList,l=null;if(t.live){let i=s.initialLiveManifestSize;if(r<i)return this.warn(`Not enough fragments to start playback (have: ${r}, need: ${i})`),null;if(!t.PTSKnown&&!this.startFragRequested&&-1===this.startPosition||e<a){var o;n&&!this.loadingParts&&(this.log("LL-Part loading ON for initial live fragment"),this.loadingParts=!0),l=this.getInitialLiveFragment(t);let i=this.hls.startPosition,r=this.hls.liveSyncPosition,s=l?(-1!==i&&i>=a?i:r)||l.start:e;this.log(`Setting startPosition to ${s} to match start frag at live edge. mainStart: ${i} liveSyncPosition: ${r} frag.start: ${null==(o=l)?void 0:o.start}`),this.startPosition=this.nextLoadPosition=s}}else e<=a&&(l=i[0]);if(!l){let i=this.loadingParts?t.partEnd:t.fragmentEnd;l=this.getFragmentAtPosition(e,i,t)}let d=this.filterReplacedPrimary(l,t);if(!d&&l){let e=l.sn-t.startSN;d=this.filterReplacedPrimary(i[e+1]||null,t)}return this.mapToInitFragWhenRequired(d)}isLoopLoading(e,t){let i=this.fragmentTracker.getState(e);return("OK"===i||i===aK&&!!e.gap)&&this.nextLoadPosition>t}getNextFragmentLoopLoading(e,t,i,r,s){let a=null;if(e.gap&&(a=this.getNextFragment(this.nextLoadPosition,t))&&!a.gap&&i.nextStart){let e=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,i.nextStart,r,0);if(null!==e&&i.len+e.len>=s){let e=a.sn;return this.loopSn!==e&&(this.log(`buffer full after gaps in "${r}" playlist starting at sn: ${e}`),this.loopSn=e),null}}return this.loopSn=void 0,a}get primaryPrefetch(){if(lp(this.config)){var e;if(null==(e=this.hls.interstitialsManager)||null==(e=e.playingItem)?void 0:e.event)return!0}return!1}filterReplacedPrimary(e,t){if(!e)return e;if(lp(this.config)&&e.type!==sc){let i=this.hls.interstitialsManager,r=null==i?void 0:i.bufferingItem;if(r){let i=r.event;if(i){if(i.appendInPlace||Math.abs(e.start-r.start)>1||0===r.start)return null}else if(e.end<=r.start&&(null==t?void 0:t.live)===!1||e.start>r.end&&r.nextEvent&&(r.nextEvent.appendInPlace||e.start-r.end>1))return null}let s=null==i?void 0:i.playerQueue;if(s)for(let t=s.length;t--;){let i=s[t].interstitial;if(i.appendInPlace&&e.start>=i.startTime&&e.end<=i.resumeTime)return null}}return e}mapToInitFragWhenRequired(e){return null==e||!e.initSegment||e.initSegment.data||this.bitrateTest?e:e.initSegment}getNextPart(e,t,i){let r=-1,s=!1,a=!0;for(let n=0,l=e.length;n<l;n++){let l=e[n];if(a=a&&!l.independent,r>-1&&i<l.start)break;let o=l.loaded;o?r=-1:(s||(l.independent||a)&&l.fragment===t)&&(l.fragment!==t&&this.warn(`Need buffer at ${i} but next unloaded part starts at ${l.start}`),r=n),s=o}return r}loadedEndOfParts(e,t){let i;for(let r=e.length;r--&&(i=e[r]).loaded;)if(t>i.start)return!0;return!1}getInitialLiveFragment(e){let t=e.fragments,i=this.fragPrevious,r=null;if(i){if(e.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${i.programDateTime}`),r=function(e,t,i){if(null===t||!Array.isArray(e)||!e.length||!se(t)||t<(e[0].programDateTime||0)||t>=(e[e.length-1].endProgramDateTime||0))return null;for(let r=0;r<e.length;++r){let s=e[r];if(function(e,t,i){let r=1e3*Math.min(t,i.duration+(i.deltaPTS?i.deltaPTS:0));return(i.endProgramDateTime||0)-r>e}(t,i,s))return s}return null}(t,i.endProgramDateTime,this.config.maxFragLookUpTolerance)),!r){let s=i.sn+1;if(s>=e.startSN&&s<=e.endSN){let a=t[s-e.startSN];i.cc===a.cc&&(r=a,this.log(`Live playlist, switching playlist, load frag with next SN: ${r.sn}`))}!r&&(r=aP(e,i.cc,i.end))&&this.log(`Live playlist, switching playlist, load frag with same CC: ${r.sn}`)}}else{let t=this.hls.liveSyncPosition;null!==t&&(r=this.getFragmentAtPosition(t,this.bitrateTest?e.fragmentEnd:e.edge,e))}return r}getFragmentAtPosition(e,t,i){let r,{config:s}=this,{fragPrevious:a}=this,{fragments:n,endSN:l}=i,{fragmentHint:o}=i,{maxFragLookUpTolerance:d}=s,h=i.partList,u=!!(this.loadingParts&&null!=h&&h.length&&o);if(u&&!this.bitrateTest&&h[h.length-1].fragment.sn===o.sn&&(n=n.concat(o),l=o.sn),e<t){var c;let i=e<this.lastCurrentTime||e>t-d||null!=(c=this.media)&&c.paused||!this.startFragRequested?0:d;r=aD(a,n,e,i)}else r=n[n.length-1];if(r){let e=r.sn-i.startSN,t=this.fragmentTracker.getState(r);
6if(("OK"===t||t===aK&&r.gap)&&(a=r),a&&r.sn===a.sn&&(!u||h[0].fragment.sn>r.sn||!i.live)&&r.level===a.level){let t=n[e+1];r=r.sn<l&&"OK"!==this.fragmentTracker.getState(t)?t:null}}return r}alignPlaylists(e,t,i){let r=e.fragments.length;if(!r)return this.warn("No fragments in live playlist"),0;let s=e.fragmentStart,a=!t,n=e.alignedSliding&&se(s);if(a||!n&&!s){i&&(n6(e,i),e.alignedSliding||n9(e,i),e.alignedSliding||e.skippedSegments||nz(i,e,!1));let s=e.fragmentStart;return this.log(`Live playlist sliding: ${s.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${e.startSN} fragments: ${r}`),s}return s}waitForCdnTuneIn(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,3*e.partTarget)}setStartPosition(e,t){let i=this.startPosition;i<t&&(i=-1);let r=this.timelineOffset;if(-1===i){let s=null!==this.startTimeOffset,a=s?this.startTimeOffset:e.startTimeOffset;null!==a&&se(a)?(i=t+a,a<0&&(i+=e.edge),i=Math.min(Math.max(t,i),t+e.totalduration),this.log(`Setting startPosition to ${i} for start time offset ${a} found in ${s?"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+r}this.nextLoadPosition=i+r}getLoadPosition(){var e;let{media:t}=this,i=0;return null!=(e=this.hls)&&e.hasEnoughToStart&&t?i=t.currentTime:this.nextLoadPosition>=0&&(i=this.nextLoadPosition),i}handleFragLoadAborted(e,t){this.transmuxer&&e.type===this.playlistType&&sN(e)&&e.stats.aborted&&(this.log(`Fragment ${e.sn}${t?" part "+t.index:""} of ${this.playlistLabel()} ${e.level} was aborted`),this.resetFragmentLoading(e))}resetFragmentLoading(e){this.fragCurrent&&(this.fragContextChanged(e)||this.state===ln)||(this.state=lr)}onFragmentOrKeyLoadError(e,t){var i,r,s;if(t.chunkMeta&&!t.frag){let e=this.getCurrentContext(t.chunkMeta);e&&(t.frag=e.frag)}let a=t.frag;if(!a||a.type!==e||!this.levels)return;if(this.fragContextChanged(a))return void this.warn(`Frag load error must match current frag to retry ${a.url} > ${null==(r=this.fragCurrent)?void 0:r.url}`);let n=t.details===ss.FRAG_GAP;n&&this.fragmentTracker.fragBuffered(a,!0);let l=t.errorAction;if(!l){this.state=lu;return}let{action:o,flags:d,retryCount:h=0,retryConfig:u}=l,c=!!u,f=c&&5===o,m=c&&!l.resolved&&1===d,g=null==(i=this.hls.latestLevelDetails)?void 0:i.live;if(!f&&m&&sN(a)&&!a.endList&&g&&!aO(t))this.resetFragmentErrors(e),this.treatAsGap(a),l.resolved=!0;else if((f||m)&&h<u.maxNumRetry){let i=aB(null==(s=t.response)?void 0:s.code),r=aU(u,h);if(this.resetStartWhenNotLoaded(),this.retryDate=self.performance.now()+r,this.state=ln,l.resolved=!0,i){this.log("Waiting for connection (offline)"),this.retryDate=1/0,t.reason="offline";return}this.warn(`Fragment ${a.sn} of ${e} ${a.level} errored with ${t.details}, retrying loading ${h+1}/${u.maxNumRetry} in ${r}ms`)}else if(u){if(this.resetFragmentErrors(e),!(h<u.maxNumRetry))return void this.warn(`${t.details} reached or exceeded max retry (${h})`);n||3===o||(l.resolved=!0)}else 2===o?this.state=lf:this.state=lu;this.tickImmediate()}checkRetryDate(){let e=self.performance.now(),t=this.retryDate,i=t===1/0;(!t||e>=t||i&&!aB(0))&&(i&&this.log("Connection restored (online)"),this.resetStartWhenNotLoaded(),this.state=lr)}reduceLengthAndFlushBuffer(e){if(this.state===lo||this.state===ld){let t=e.frag,i=e.parent,r=this.getFwdBufferInfo(this.mediaBuffer,i),s=r&&r.len>.5;s&&this.reduceMaxBufferLength(r.len,(null==t?void 0:t.duration)||10);let a=!s;return a&&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(),a}return!1}resetFragmentErrors(e){e===su&&(this.fragCurrent=null),this.hls.hasEnoughToStart||(this.startFragRequested=!1),this.state!==li&&(this.state=lr)}afterBufferFlushed(e,t,i){if(!e)return;let r=a6.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,r,i),this.state===lh&&this.resetLoadingState()}
6resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==li&&(this.state=lr)}resetStartWhenNotLoaded(){if(!this.hls.hasEnoughToStart){this.startFragRequested=!1;let 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}}resetWhenMissingContext(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()}removeUnbufferedFrags(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}updateLevelTiming(e,t,i,r){let s=i.details;if(!s)return void this.warn("level.details undefined");if(!Object.keys(e.elementaryStreams).reduce((t,a)=>{let n=e.elementaryStreams[a];if(n){let l=n.endPTS-n.startPTS;if(l<=0)return this.warn(`Could not parse fragment ${e.sn} ${a} duration reliably (${l})`),t||!1;let o=r?0:nY(s,e,n.startPTS,n.endPTS,n.startDTS,n.endDTS,this);return this.hls.trigger(sa.LEVEL_PTS_UPDATED,{details:s,level:i,drift:
6o,type:a,frag:e,start:n.startPTS,end:n.endPTS}),!0}return t},!1)){var a;let t=(null==(a=this.transmuxer)?void 0:a.error)===null;if((0===i.fragmentError||t&&(i.fragmentError<2||e.endList))&&this.treatAsGap(e,i),t){let t=Error(`Found no media in fragment ${e.sn} of ${this.playlistLabel()} ${e.level} resetting transmuxer to fallback to playlist timing`);if(this.warn(t.message),this.hls.trigger(sa.ERROR,{type:sr.MEDIA_ERROR,details:ss.FRAG_PARSING_ERROR,fatal:!1,error:t,frag:e,reason:`Found no media in msn ${e.sn} of ${this.playlistLabel()} "${i.url}"`}),!this.hls)return;this.resetTransmuxer()}}this.state=ld,this.log(`Parsed ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,!1,t)})`),this.hls.trigger(sa.FRAG_PARSED,{frag:e,part:t})}playlistLabel(){return this.playlistType===sh?"level":"track"}fragInfo(e,t=!0,i){var r,s;return`${this.playlistLabel()} ${e.level} (${i?"part":"frag"}:[${(null!=(r=t&&!i?e.startPTS:(i||e).start)?r:NaN).toFixed(3)}-${(null!=(s=t&&!i?e.endPTS:(i||e).end)?s:NaN).toFixed(3)}]${i&&"main"===e.type?"INDEPENDENT="+(i.independent?"YES":"NO"):""}`}treatAsGap(e,t){t&&t.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)}resetTransmuxer(){var e;null==(e=this.transmuxer)||e.reset()}recoverWorkerError(e){"demuxerWorker"===e.event&&(this.fragmentTracker.removeAllFragments(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),this.resetStartWhenNotLoaded(),this.resetLoadingState())}set state(e){let t=this._state;t!==e&&(this._state=e,this.log(`${t}->${e}`))}get state(){return this._state}}function lp(e){return!!e.interstitialsController&&!1!==e.enableInterstitialPlayback}class lg{constructor(){this.chunks=[],this.dataLength=0}push(e){this.chunks.push(e),this.dataLength+=e.length}flush(){let e,{chunks:t,dataLength:i}=this;return t.length?(e=1===t.length?t[0]:function(e,t){let i=new Uint8Array(t),r=0;for(let t=0;t<e.length;t++){let s=e[t];i.set(s,r),r+=s.length}return i}(t,i),this.reset(),e):new Uint8Array(0)}reset(){this.chunks.length=0,this.dataLength=0}}var lv={exports:{}},lE=(uw||(uw=1,!function(e){var t=Object.prototype.hasOwnProperty,i="~";function r(){}function s(e,t,i){this.fn=e,this.context=t,this.once=i||!1}function a(e,t,r,a,n){if("function"!=typeof r)throw TypeError("The listener must be a function");
6var l=new s(r,a||e,n),o=i?i+t:t;return e._events[o]?e._events[o].fn?e._events[o]=[e._events[o],l]:e._events[o].push(l):(e._events[o]=l,e._eventsCount++),e}function n(e,t){0==--e._eventsCount?e._events=new r:delete e._events[t]}function l(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(i=!1)),l.prototype.eventNames=function(){var e,r,s=[];if(0===this._eventsCount)return s;for(r in e=this._events)t.call(e,r)&&s.push(i?r.slice(1):r);return Object.getOwnPropertySymbols?s.concat(Object.getOwnPropertySymbols(e)):s},l.prototype.listeners=function(e){var t=i?i+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var s=0,a=r.length,n=Array(a);s<a;s++)n[s]=r[s].fn;return n},l.prototype.listenerCount=function(e){var t=i?i+e:e,r=this._events[t];return r?r.fn?1:r.length:0},l.prototype.emit=function(e,t,r,s,a,n){var l=i?i+e:e;if(!this._events[l])return!1;var o,d,h=this._events[l],u=arguments.length;if(h.fn){switch(h.once&&this.removeListener(e,h.fn,void 0,!0),u){case 1:return h.fn.call(h.context),!0;case 2:return h.fn.call(h.context,t),!0;case 3:return h.fn.call(h.context,t,r),!0;case 4:return h.fn.call(h.context,t,r,s),!0;case 5:return h.fn.call(h.context,t,r,s,a),!0;case 6:return h.fn.call(h.context,t,r,s,a,n),!0}for(d=1,o=Array(u-1);d<u;d++)o[d-1]=arguments[d];h.fn.apply(h.context,o)}else{var c,f=h.length;for(d=0;d<f;d++)switch(h[d].once&&this.removeListener(e,h[d].fn,void 0,!0),u){case 1:h[d].fn.call(h[d].context);break;case 2:h[d].fn.call(h[d].context,t);break;case 3:h[d].fn.call(h[d].context,t,r);break;case 4:h[d].fn.call(h[d].context,t,r,s);break;default:if(!o)for(c=1,o=Array(u-1);c<u;c++)o[c-1]=arguments[c];h[d].fn.apply(h[d].context,o)}}return!0},l.prototype.on=function(e,t,i){return a(this,e,t,i,!1)},l.prototype.once=function(e,t,i){return a(this,e,t,i,!0)},l.prototype.removeListener=function(e,t,r,s){var a=i?i+e:e;if(!this._events[a])return this;if(!t)return n(this,a),this;var l=this._events[a];if(l.fn)l.fn!==t||s&&!l.once||r&&l.context!==r||n(this,a);else{for(var o=0,d=[],h=l.length;o<h;o++)(l[o].fn!==t||s&&!l[o].once||r&&l[o].context!==r)&&d.push(l[o]);d.length?this._events[a]=1===d.length?d[0]:d:n(this,a)}return this},l.prototype.removeAllListeners=function(e){var t;return e?(t=i?i+e:e,this._events[t]&&n(this,t)):(this._events=new r,this._eventsCount=0),this},l.prototype.off=l.prototype.removeListener,l.prototype.addListener=l.prototype.on,l.prefixed=i,l.EventEmitter=l,e.exports=l}(lv)),(uk=lv.exports)&&uk.__esModule&&Object.prototype.hasOwnProperty.call(uk,"default"))?uk.default:uk;let ly="1.6.15",lb={};function lT(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||!1}function l_(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||!1}function lA(e,t){return(127&e[t])<<21|(127&e[t+1])<<14|(127&e[t+2])<<7|127&e[t+3]}function lS(e,t){let i=t,r=0;for(;l_(e,t);)r+=10,r+=lA(e,t+6),lT(e,t+10)&&(r+=10),t+=r;if(r>0)return e.subarray(i,i+r)}function lk(e,t){return 255===e[t]&&(246&e[t+1])==240}function lL(e,t){return 1&e[t+1]?7:9}function lR(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function lI(e,t){return t+1<e.length&&lk(e,t)}function lw(e,t,i,r,s){if(!e.samplerate){let a=function(e,t,i,r){let s=t[i+2],a=s>>2&15;if(a>12){let t=Error(`invalid ADTS sampling index:${a}`);e.emit(sa.ERROR,sa.ERROR,{type:sr.MEDIA_ERROR,details:ss.FRAG_PARSING_ERROR,fatal:!0,error:t,reason:t.message});return}let n=(s>>6&3)+1,l=t[i+3]>>6&3|(1&s)<<2,o="mp4a.40."+n,d=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350][a],h=a;(5===n||29===n)&&(h-=3);let u=[n<<3|(14&h)>>1,(1&h)<<7|l<<3];return sA.log(`manifest codec:${r}, parsed codec:${o}, channels:${l}, rate:${d} (ADTS object type:${n} sampling index:${a})`),{config:u,samplerate:d,channelCount:l,codec:o,parsedCodec:o,manifestCodec:r}}(t,i,r,s);a&&sp(e,a)}}function lD(e,t,i,r,s){let a,n=r+s*(9216e4/e.samplerate),l=function(e,t){let i=lL(e,t);if(t+i<=e.length){let r=lR(e,t)-i;if(r>0)return{headerLength:i,frameLength:r}}}(t,i);if(l){let{frameLength:r,headerLength:s}=l,o=s+r,d=Math.max(0,i+o-t.length);d?(a=new Uint8Array(o-s)).set(t.subarray(i+s,t.length),0):a=t.subarray(i+s,i+o);let h={unit:a,pts:n};return d||e.samples.push(h),{sample:h,length:o,missing:d}}let o=t.length-i;return(a=new Uint8Array(o)).set(t.subarray(i,t.length),0),{sample:{unit:a,pts:n},length:o,missing:-1}}function lC(e,t=0,i=1/0){var r,s,a,n,l,o;let d,h,u,c,f,m;return r=e,s=t,a=i,n=Uint8Array,d=(l=r)instanceof ArrayBuffer?l:l.buffer,h=1,"BYTES_PER_ELEMENT"in n&&(h=n.BYTES_PER_ELEMENT),c=((u=(o=r)&&o.buffer instanceof ArrayBuffer&&void 0!==o.byteLength&&void 0!==o.byteOffset?r.byteOffset:0)+r.byteLength)/h,m=Math.floor(Math.min((f=
6Math.floor(Math.max(0,Math.min((u+s)/h,c))))+Math.max(a,0),c)),new n(d,f,m-f)}function lP(e){let t=0,i=[];for(;l_(e,t);){let r=lA(e,t+6);e[t+5]>>6&1&&(t+=10);let s=(t+=10)+r;for(;t+10<s;){let r=function(e){let t=String.fromCharCode(e[0],e[1],e[2],e[3]),i=lA(e,4);return{type:t,size:i,data:e.subarray(10,10+i)}}(e.subarray(t)),s=function(e){if("PRIV"===e.type){if(e.size<2)return;let t=sL(e.data,!0),i=new Uint8Array(e.data.subarray(t.length+1));return{key:e.type,info:t,data:i.buffer}}if("W"===e.type[0]){if("WXXX"===e.type){if(e.size<2)return;let t=1,i=sL(e.data.subarray(t),!0);t+=i.length+1;let r=sL(e.data.subarray(t));return{key:e.type,info:i,data:r}}let t=sL(e.data);return{key:e.type,info:"",data:t}}if("APIC"===e.type)return function(e){let t,i={key:e.type,description:"",data:"",mimeType:null,pictureType:null};if(e.size<2)return;if(3!==e.data[0])return void console.log("Ignore frame with unrecognized character encoding");let r=e.data.subarray(1).indexOf(0);if(-1===r)return;let s=sL(lC(e.data,1,r)),a=e.data[2+r],n=e.data.subarray(3+r).indexOf(0);if(-1===n)return;let l=sL(lC(e.data,3+r,n));if("-->"===s)t=sL(lC(e.data,4+r+n));else{var o;t=(o=e.data.subarray(4+r+n))instanceof ArrayBuffer?o:0==o.byteOffset&&o.byteLength==o.buffer.byteLength?o.buffer:new Uint8Array(o).buffer}return i.mimeType=s,i.pictureType=a,i.description=l,i.data=t,i}(e);if(e.size<2)return;if("TXXX"===e.type){let t=1,i=sL(e.data.subarray(t),!0);t+=i.length+1;let r=sL(e.data.subarray(t));return{key:e.type,info:i,data:r}}let t=sL(e.data.subarray(1));return{key:e.type,info:"",data:t}}(r);s&&i.push(s),t+=r.size+10}lT(e,t)&&(t+=10)}return i}function lx(e){return e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info}function lM(e){let t=lP(e);for(let e=0;e<t.length;e++){let i=t[e];if(lx(i))return function(e){if(8===e.data.byteLength){let t=new Uint8Array(e.data),i=1&t[3],r=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return r/=45,i&&(r+=47721858.84),Math.round(r)}}(i)}}let lO=((uL={}).audioId3="org.id3",uL.dateRange="com.apple.quicktime.HLS",uL.emsg="https://aomedia.org/emsg/ID3",uL.misbklv="urn:misb:KLV:bin:1910.1",uL);
6function lN(e="",t=9e4){return{type:e,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}class lU{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(e,t,i,r){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(e){this.initPTS=e,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(e,t){return!1}appendFrame(e,t,i){}demux(e,t){let i;this.cachedData&&(e=s0(this.cachedData,e),this.cachedData=null);let r=lS(e,0),s=r?r.length:0,a=this._audioTrack,n=this._id3Track,l=r?lM(r):void 0,o=e.length;for((null===this.basePTS||0===this.frameIndex&&se(l))&&(this.basePTS=lF(l,t,this.initPTS),this.lastPTS=this.basePTS),null===this.lastPTS&&(this.lastPTS=this.basePTS),r&&r.length>0&&n.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:lO.audioId3,duration:1/0});s<o;){if(this.canParse(e,s)){let t=this.appendFrame(a,e,s);t?(this.frameIndex++,this.lastPTS=t.sample.pts,s+=t.length,i=s):s=o}else{var d,h;l_(d=e,h=s)&&lA(d,h+6)+10<=d.length-h?(r=lS(e,s),n.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:lO.audioId3,duration:1/0}),s+=r.length,i=s):s++}if(s===o&&i!==o){let t=e.slice(i);this.cachedData?this.cachedData=s0(this.cachedData,t):this.cachedData=t}}return{audioTrack:a,videoTrack:lN(),id3Track:n,textTrack:lN()}}demuxSampleAes(e,t,i){return Promise.reject(Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(e){let t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:lN(),id3Track:this._id3Track,textTrack:lN()}}destroy(){this.cachedData=null,this._audioTrack=this._id3Track=void 0}}let lF=(e,t,i)=>se(e)?90*e:9e4*t+(i?9e4*i.baseTime/i.timescale:0),l$=null,lB=[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],lH=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],lG=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],lV=[0,1,1,4];function lK(e,t,i,r,s){if(i+24>t.length)return;let a=lW(t,i);if(a&&i+a.frameLength<=t.length){let n=r+s*(9e4*a.samplesPerFrame/a.sampleRate),l={unit:t.subarray(i,i+a.frameLength),pts:n,dts:n};return e.config=[],e.channelCount=a.channelCount,e.samplerate=a.sampleRate,e.samples.push(l),{sample:l,length:a.frameLength,missing:0}}}function lW(e,t){let i=e[t+1]>>3&3,r=e[t+1]>>1&3,s=e[t+2]>>4&15,a=e[t+2]>>2&3;if(1!==i&&0!==s&&15!==s&&3!==a){let n=e[t+2]>>1&1,l=e[t+3]>>6,o=1e3*lB[14*(3===i?3-r:3===r?3:4)+s-1],d=lH[3*(3===i?0:2===i?1:2)+a],h=lG[i][r],u=lV[r],c=Math.floor(h*o/d+n)*u;if(null===l$){let e=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);l$=e?parseInt(e[1]):0}return l$&&l$<=87&&2===r&&o>=224e3&&0===l&&(e[t+3]=128|e[t+3]),{sampleRate:d,channelCount:3===l?1:2,frameLength:c,samplesPerFrame:8*h*u}}}function lq(e,t){return 255===e[t]&&(224&e[t+1])==224&&(6&e[t+1])!=0}function lj(e,t){return t+1<e.length&&lq(e,t)}function lY(e,t){if(t+1<e.length&&lq(e,t)){let i=lW(e,t),r=4;null!=i&&i.frameLength&&(r=i.frameLength);let s=t+r;return s===e.length||lj(e,s)}return!1}let lQ=(e,t)=>{let i=0,r=5;t+=5;let s=new Uint32Array(1),a=new Uint32Array(1),n=new Uint8Array(1);for(;r>0;){n[0]=e[t];let l=Math.min(r,8),o=8-l;a[0]=0xff000000>>>24+o<<o,s[0]=(n[0]&a[0])>>o,i=i?i<<l|s[0]:s[0],t+=1,r-=l}return i};function lz(e,t,i,r,s){if(i+8>t.length||11!==t[i]||119!==t[i+1])return -1;let a=t[i+4]>>6;if(a>=3)return -1;let n=[48e3,44100,32e3][a],l=63&t[i+4],o=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*l+a];if(i+o>t.length)return -1;let d=t[i+6]>>5,h=0;2===d?h+=2:(1&d&&1!==d&&(h+=2),4&d&&(h+=2));let u=(t[i+6]<<8|t[i+7])>>12-h&1,c=[2,1,2,3,3,4,4,5][d]+u,f=t[i+5]>>3,m=7&t[i+5],g=new Uint8Array([a<<6|f<<1|m>>2,(3&m)<<6|d<<3|u<<2|l>>4,l<<4&224]),v=t.subarray(i,i+o);return e.config=g,e.channelCount=c,e.samplerate=n,e.samples.push({unit:v,pts:r+1536/n*9e4*s}),o}let lX=/\/emsg[-/]ID3/i;function lZ(e,t){return se(e.presentationTime)?e.presentationTime/e.timeScale:t+e.presentationTimeDelta/e.timeScale}class lJ{constructor(e,t,i){this.keyData=void 0,this.decrypter=void 0,this.keyData=i,this.decrypter=new aZ(t,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer,0)}decryptAacSample(e,t,i){let r=e[t].unit;if(r.length<=16)return;let s=r.subarray(16,r.length-r.length%16),a=s.buffer.slice(s.byteOffset,s.byteOffset+s.length);this.decryptBuffer(a).then(s=>{let a=new Uint8Array(s);r.set(a,16),this.decrypter.isSync()||this.decryptAacSamples(e,t+1,i)}).catch(i)}decryptAacSamples(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}}getAvcEncryptedData(e){let t=new Int8Array(16*Math.floor((e.length-48)/160)+16),i=0;for(let r=32;r<e.length-16;r+=160,i+=16)t.set(e.subarray(r,r+16),i);return t}getAvcDecryptedUnit(e,t){let i=new Uint8Array(t),r=0;for(let t=32;t<e.length-16;t+=160,r+=16)e.set(i.subarray(r,r+16),t);return e}decryptAvcSample(e,t,i,r,s){let a=s4(s.data),n=this.getAvcEncryptedData(a);this.decryptBuffer(n.buffer).then(n=>{s.data=this.getAvcDecryptedUnit(a,n),this.decrypter.isSync()||this.decryptAvcSamples(e,t,i+1,r)}).catch(r)}decryptAvcSamples(e,t,i,r){if(e instanceof Uint8Array)throw Error("Cannot decrypt samples of type Uint8Array");for(;;t++,i=0){if(t>=e.length)return void r();let s=e[t].units;for(;!(i>=s.length);i++){let a=s[i];if(!(a.data.length<=48)&&(1===a.type||5===a.type)&&(this.decryptAvcSample(e,t,i,r,a),!this.decrypter.isSync()))return}}}}class l0{constructor(){this.VideoSample=null}createVideoSample(e,t,i){return{key:e,frame:!1,pts:t,dts:i,units:[],length:0}}getLastNalUnit(e){var t;let i,r=this.VideoSample;if(r&&0!==r.units.length||(r=e[e.length-1]),null!=(t=r)&&t.units){let e=r.units;i=e[e.length-1]}return i}pushAccessUnit(e,t){if(e.units.length&&e.frame){if(void 0===e.pts){let i=t.samples,r=i.length;if(!r)return void t.dropped++;{let t=i[r-1];e.pts=t.pts,e.dts=t.dts}}t.samples.push(e)}}parseNALu(e,t,i){let r,s,a,n=t.byteLength,l=e.naluState||0,o=l,d=[],h=0,u=-1,c=0;for(-1===l&&(u=0,c=this.getNALuType(t,0),l=0,h=1);h<n;){if(r=t[h++],!l){l=+!r;continue}if(1===l){l=2*!r;continue}if(r)if(1===r){if(s=h-l-1,u>
6=0){let e={data:t.subarray(u,s),type:c};d.push(e)}else{let i=this.getLastNalUnit(e.samples);i&&(o&&h<=4-o&&i.state&&(i.data=i.data.subarray(0,i.data.byteLength-o)),s>0&&(i.data=s0(i.data,t.subarray(0,s)),i.state=0))}h<n?(a=this.getNALuType(t,h),u=h,c=a,l=0):l=-1}else l=0;else l=3}if(u>=0&&l>=0){let e={data:t.subarray(u,n),type:c,state:l};d.push(e)}if(0===d.length){let i=this.getLastNalUnit(e.samples);i&&(i.data=s0(i.data,t))}return e.naluState=l,d}}class l1{constructor(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}loadWord(){let e=this.data,t=this.bytesAvailable,i=e.byteLength-t,r=new Uint8Array(4),s=Math.min(4,t);if(0===s)throw Error("no bytes available");r.set(e.subarray(i,i+s)),this.word=new DataView(r.buffer).getUint32(0),this.bitsAvailable=8*s,this.bytesAvailable-=s}skipBits(e){let t;e=Math.min(e,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>e||(e-=this.bitsAvailable,t=e>>3,e-=t<<3,this.bytesAvailable-=t,this.loadWord()),this.word<<=e,this.bitsAvailable-=e}readBits(e){let t=Math.min(this.bitsAvailable,e),i=this.word>>>32-t;if(e>32&&sA.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else if(this.bytesAvailable>0)this.loadWord();else throw Error("no bits available");return(t=e-t)>0&&this.bitsAvailable?i<<t|this.readBits(t):i}skipLZ(){let e;for(e=0;e<this.bitsAvailable;++e)if((this.word&0x80000000>>>e)!=0)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){let e=this.skipLZ();return this.readBits(e+1)-1}readEG(){let e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}readBoolean(){return 1===this.readBits(1)}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}}class l2 extends l0{parsePES(e,t,i,r){let s,a=this.parseNALu(e,i.data,r),n=this.VideoSample,l=!1;i.data=null,n&&a.length&&!e.audFound&&(this.pushAccessUnit(n,e),n=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts)),a.forEach(r=>{var a,o,d,h,u;switch(r.type){case 1:{let t=!1;s=!0;let a=r.data;if(l&&a.length>4){let e=this.readSliceType(a);(2===e||4===e||7===e||9===e)&&(t=!0)}t&&null!=(d=n)&&d.frame&&!n.key&&(this.pushAccessUnit(n,e),n=this.VideoSample=null),n||(n=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),n.frame=!0,n.key=t;break}case 5:s=!0,null!=(a=n)&&a.frame&&!n.key&&(this.pushAccessUnit(n,e),n=this.VideoSample=null),n||(n=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),n.key=!0,n.frame=!0;break;case 6:s=!0,s3(r.data,1,i.pts,t.samples);break;case 7:{s=!0,l=!0;let t=r.data,i=this.readSPS(t);if(!e.sps||e.width!==i.width||e.height!==i.height||(null==(h=e.pixelRatio)?void 0:h[0])!==i.pixelRatio[0]||(null==(u=e.pixelRatio)?void 0:u[1])!==i.pixelRatio[1]){e.width=i.width,e.height=i.height,e.pixelRatio=i.pixelRatio,e.sps=[t];let r=t.subarray(1,4),s="avc1.";for(let e=0;e<3;e++){let t=r[e].toString(16);t.length<2&&(t="0"+t),s+=t}e.codec=s}break}case 8:s=!0,e.pps=[r.data];break;case 9:s=!0,e.audFound=!0,null!=(o=n)&&o.frame&&(this.pushAccessUnit(n,e),n=null),n||(n=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts));break;case 12:s=!0;break;default:s=!1}n&&s&&n.units.push(r)}),r&&n&&(this.pushAccessUnit(n,e),this.VideoSample=null)}getNALuType(e,t){return 31&e[t]}readSliceType(e){let t=new l1(e);return t.readUByte(),t.readUEG(),t.readUEG()}skipScalingList(e,t){let i=8,r=8;for(let s=0;s<e;s++)0!==r&&(r=(i+t.readEG()+256)%256),i=0===r?i:r}readSPS(e){let t,i,r,s=new l1(e),a=0,n=0,l=0,o=0,d=s.readUByte.bind(s),h=s.readBits.bind(s),u=s.readUEG.bind(s),c=s.readBoolean.bind(s),f=s.skipBits.bind(s),m=s.skipEG.bind(s),g=s.skipUEG.bind(s),v=this.skipScalingList.bind(this);d();let E=d();if(h(5),f(3),d(),g(),100===E||110===E||122===E||244===E||44===E||83===E||86===E||118===E||128===E){let e=u();if(3===e&&f(1),g(),g(),f(1),c())for(r=0,i=3!==e?8:12;r<i;r++)c()&&v(r<6?16:64,s)}g();let y=u();if(0===y)u();else if(1===y)for(f(1),m(),m(),t=u(),r=0;r<t;r++)m();g(),f(1);let b=u(),T=u(),_=h(1);0===_&&f(1),f(1),c()&&(a=u(),n=u(),l=u(),o=u());let A=[1,1];if(c()&&c())switch(d()){case 1:A=[1,1];break;case 2:A=[12,11];break;case 3:A=[10,11];break;case 4:A=[16,11];break;case 5:A=[40,33];break;case 6:A=[24,11];break;case 7:A=[20,11];break;case 8:A=[32,11];break;case 9:A=[80,33];break;case 10:A=[18,11];break;case 11:A=[15,11];break;case 12:A=[64,33];break;case 13:A=[160,99];break;case 14:A=[4,3];break;case 15:A=[3,2];break;case 16:A=[2,1];break;case 255:A=[d()<<8|d(),d()<<8|d()]}return{width:Math.ceil((b+1)*16-2*a-2*n),height:(2-_)*(T+1)*16-(_?2:4)*(l+o),pixelRatio:A}}}class l3 extends l0{constructor(...e){super(...e),this.initVPS=null}parsePES(e,t,i,r){let s,a=this.parseNALu(e,i.data,r),n=this.VideoSample,l=!1;i.data=null,n&&a.length&&!e.audFound&&(this.pushAccessUnit(n,e),n=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts)),a.forEach(r=>{var a,o,d;
6switch(r.type){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:n||(n=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts)),n.frame=!0,s=!0;break;case 16:case 17:case 18:case 21:s=!0,l&&null!=(d=n)&&d.frame&&!n.key&&(this.pushAccessUnit(n,e),n=this.VideoSample=null),n||(n=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),n.key=!0,n.frame=!0;break;case 19:case 20:s=!0,null!=(a=n)&&a.frame&&!n.key&&(this.pushAccessUnit(n,e),n=this.VideoSample=null),n||(n=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),n.key=!0,n.frame=!0;break;case 39:s=!0,s3(r.data,2,i.pts,t.samples);break;case 32:s=!0,e.vps||("object"!=typeof e.params&&(e.params={}),e.params=sp(e.params,this.readVPS(r.data)),this.initVPS=r.data),e.vps=[r.data];break;case 33:if(s=!0,l=!0,void 0===e.vps||e.vps[0]===this.initVPS||void 0===e.sps||this.matchSPS(e.sps[0],r.data)||(this.initVPS=e.vps[0],e.sps=e.pps=void 0),!e.sps){let t=this.readSPS(r.data);for(let i in e.width=t.width,e.height=t.height,e.pixelRatio=t.pixelRatio,e.codec=t.codecString,e.sps=[],"object"!=typeof e.params&&(e.params={}),t.params)e.params[i]=t.params[i]}this.pushParameterSet(e.sps,r.data,e.vps),n||(n=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),n.key=!0;break;case 34:if(s=!0,"object"==typeof e.params){if(!e.pps){e.pps=[];let t=this.readPPS(r.data);for(let i in t)e.params[i]=t[i]}this.pushParameterSet(e.pps,r.data,e.vps)}break;case 35:s=!0,e.audFound=!0,null!=(o=n)&&o.frame&&(this.pushAccessUnit(n,e),n=null),n||(n=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts));break;default:s=!1}n&&s&&n.units.push(r)}),r&&n&&(this.pushAccessUnit(n,e),this.VideoSample=null)}pushParameterSet(e,t,i){(!i||i[0]!==this.initVPS)&&(i||e.length)||e.push(t)}getNALuType(e,t){return(126&e[t])>>>1}ebsp2rbsp(e){let t=new Uint8Array(e.byteLength),i=0;for(let r=0;r<e.byteLength;r++)(!(r>=2)||3!==e[r]||0!==e[r-1]||0!==e[r-2])&&(t[i]=e[r],i++);return new Uint8Array(t.buffer,0,i)}pushAccessUnit(e,t){super.pushAccessUnit(e,t),this.initVPS&&(this.initVPS=null)}readVPS(e){let t=new l1(e);return t.readUByte(),t.readUByte(),t.readBits(4),t.skipBits(2),t.readBits(6),{numTemporalLayers:t.readBits(3)+1,temporalIdNested:t.readBoolean()}}readSPS(e){let t=new l1(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.readBits(4);let i=t.readBits(3);t.readBoolean();let r=t.readBits(2),s=t.readBoolean(),a=t.readBits(5),n=t.readUByte(),l=t.readUByte(),o=t.readUByte(),d=t.readUByte(),h=t.readUByte(),u=t.readUByte(),c=t.readUByte(),f=t.readUByte(),m=t.readUByte(),g=t.readUByte(),v=t.readUByte(),E=[],y=[];for(let e=0;e<i;e++)E.push(t.readBoolean()),y.push(t.readBoolean());if(i>0)for(let e=i;e<8;e++)t.readBits(2);for(let e=0;e<i;e++)E[e]&&(t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte()),y[e]&&t.readUByte();t.readUEG();let b=t.readUEG();3==b&&t.skipBits(1);let T=t.readUEG(),_=t.readUEG(),A=t.readBoolean(),S=0,k=0,L=0,R=0;A&&(S+=t.readUEG(),k+=t.readUEG(),L+=t.readUEG(),R+=t.readUEG());let I=t.readUEG(),w=t.readUEG(),D=t.readUEG(),C=t.readBoolean();for(let e=C?0:i;e<=i;e++)t.skipUEG(),t.skipUEG(),t.skipUEG();if(t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.readBoolean()&&t.readBoolean())for(let e=0;e<4;e++)for(let i=0;i<(3===e?2:6);i++)if(t.readBoolean()){let i=Math.min(64,1<<4+(e<<1));e>1&&t.readEG();for(let e=0;e<i;e++)t.readEG()}else t.readUEG();t.readBoolean(),t.readBoolean(),t.readBoolean()&&(t.readUByte(),t.skipUEG(),t.skipUEG(),t.readBoolean());let P=t.readUEG(),x=0;for(let e=0;e<P;e++){let i=!1;if(0!==e&&(i=t.readBoolean()),i){e===P&&t.readUEG(),t.readBoolean(),t.readUEG();let i=0;for(let e=0;e<=x;e++){let e=t.readBoolean(),r=!1;e||(r=t.readBoolean()),(e||r)&&i++}x=i}else{let e=t.readUEG(),i=t.readUEG();x=e+i;for(let i=0;i<e;i++)t.readUEG(),t.readBoolean();for(let e=0;e<i;e++)t.readUEG(),t.readBoolean()}}if(t.readBoolean()){let e=t.readUEG();for(let i=0;i<e;i++){for(let e=0;e<D+4;e++)t.readBits(1);t.readBits(1)}}let M=0,O=1,N=1,U=!0,F=1,$=0;t.readBoolean(),t.readBoolean();if(t.readBoolean()){if(t.readBoolean()){let e=t.readUByte();e>0&&e<16?(O=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2][e-1],N=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1][e-1]):255===e&&(O=t.readBits(16),N=t.readBits(16))}if(t.readBoolean()&&t.readBoolean(),t.readBoolean()&&(t.readBits(3),t.readBoolean(),t.readBoolean()&&(t.readUByte(),t.readUByte(),t.readUByte())),t.readBoolean()&&(t.readUEG(),t.readUEG()),t.readBoolean(),t.readBoolean(),t.readBoolean(),t.readBoolean()&&(t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG()),t.readBoolean()&&(F=t.readBits(32),$=t.readBits(32),t.readBoolean()&&t.readUEG(),t.readBoolean())){let e=t.readBoolean(),r=t.readBoolean(),s=!1;(e||r)&&((s=t.readBoolean())&&(t.readUByte(),t.readBits(5),t.readBoolean(),t.readBits(5)),t.readBits(4),t.readBits(4),s&&t.readBits(4),t.readBits(5),t.readBits(5),t.readBits(5));for(let a=0;a<=i;a++){let i=(U=t.readBoolean())||t.readBoolean(),a=!1;i?t.readEG():a=t.readBoolean();let n=a?1:t.readUEG()+1;if(e)for(let e=0;e<n;e++)t.readUEG(),t.readUEG(),s&&(t.readUEG(),t.readUEG()),t.skipBits(1);if(r)for(let e=0;e<n;e++)t.readUEG(),t.readUEG(),s&&(t.readUEG(),t.readUEG()),t.skipBits(1)}}t.readBoolean()&&(t.readBoolean(),t.readBoolean(),t.readBoolean(),M=t.readUEG())}let B=T,H=_;if(A){let e=1,t=1;1===b?e=t=2:2==b&&(e=2),B=T-e*k-e*S,H=_-t*R-t*L}let G=r?["A","B","C"][r]:"",V=n<<24|l<<16|o<<8|d,K=0;for(let e=0;e<32;e++)K=(K|(V>>e&1)<<31-e)>>>0;let W=K.toString(16);return 1===a&&"2"===W&&(W="6"),{codecString:`hvc1.${G}${a}.${W}.${s?"H":"L"}${v}.B0`,params:{general_tier_flag:s,general_profile_idc:a,general_profile_space:r,general_profile_compatibility_flags:[n,l,o,d],general_constraint_indicator_flags:[h,u,c,f,m,g],general_level_idc:v,bit_depth:I+8,bit_depth_luma_minus8:I,bit_depth_chroma_minus8:w,min_spatial_segmentation_idc:M,chroma_format_idc:b,frame_rate:{fixed:U,fps:$/F}},width:B,height:H,pixelRatio:[O,N]}}readPPS(e){let t=new l1(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);let i=t.readBoolean(),r=t.readBoolean(),s=1;return r&&i?s=0:r?s=3:i&&(s=2),{parallelismType:s}}matchSPS(e,t){return String.fromCharCode.apply(null,e).substr(3)===String.fromCharCode.apply(null,t).substr(3)}}class l4{constructor(e,t,i,r){this.logger=void 0,this.observer=void 0,this.config=void 0,this.typeSupp
6orted=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=e,this.config=t,this.typeSupported=i,this.logger=r,this.videoParser=null}static probe(e,t){let i=l4.syncOffset(e);return i>0&&t.warn(`MPEG2-TS detected but first sync word found @ offset ${i}`),-1!==i}static syncOffset(e){let t=e.length,i=Math.min(940,t-188)+1,r=0;for(;r<i;){let s=!1,a=-1,n=0;for(let l=r;l<t;l+=188)if(71===e[l]&&(t-l==188||71===e[l+188])){if(n++,-1===a&&0!==(a=l)&&(i=Math.min(a+18612,e.length-188)+1),s||(s=0===l5(e,l)),s&&n>1&&(0===a&&n>2||l+188>i))return a}else if(n)return -1;else break;r++}return -1}static createTrack(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:sB[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===e?t:void 0}}resetInitSegment(e,t,i,r){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=l4.createTrack("video"),this._videoTrack.duration=r,this._audioTrack=l4.createTrack("audio",r),this._id3Track=l4.createTrack("id3"),this._txtTrack=l4.createTrack("text"),this._audioTrack.segmentCodec="aac",this.videoParser=null,this.aacOverFlow=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=i}resetTimeStamp(){}resetContiguity(){let{_audioTrack:e,_videoTrack:t,_id3Track:i}=this;e&&(e.pesData=null),t&&(t.pesData=null),i&&(i.pesData=null),this.aacOverFlow=null,this.remainderData=null}demux(e,t,i=!1,r=!1){let s;i||(this.sampleAes=null);let a=this._videoTrack,n=this._audioTrack,l=this._id3Track,o=this._txtTrack,d=a.pid,h=a.pesData,u=n.pid,c=l.pid,f=n.pesData,m=l.pesData,g=null,v=this.pmtParsed,E=this._pmtId,y=e.length;if(this.remainderData&&(y=(e=s0(this.remainderData,e)).length,this.remainderData=null),y<188&&!r)return this.remainderData=e,{audioTrack:n,videoTrack:a,id3Track:l,textTrack:o};let b=Math.max(0,l4.syncOffset(e));(y-=(y-b)%188)<e.byteLength&&!r&&(this.remainderData=new Uint8Array(e.buffer,y,e.buffer.byteLength-y));let T=0;for(let t=b;t<y;t+=188)if(71===e[t]){let r,y=!!(64&e[t+1]),T=l5(e,t);if((48&e[t+3])>>4>1){if((r=t+5+e[t+4])===t+188)continue}else r=t+4;switch(T){case d:y&&(h&&(s=l9(h,this.logger))&&(this.readyVideoParser(a.segmentCodec),null!==this.videoParser&&this.videoParser.parsePES(a,o,s,!1)),h={data:[],size:0}),h&&(h.data.push(e.subarray(r,t+188)),h.size+=t+188-r);break;case u:if(y){if(f&&(s=l9(f,this.logger)))switch(n.segmentCodec){case"aac":this.parseAACPES(n,s);break;case"mp3":this.parseMPEGPES(n,s);break;case"ac3":this.parseAC3PES(n,s)}f={data:[],size:0}}f&&(f.data.push(e.subarray(r,t+188)),f.size+=t+188-r);break;case c:y&&(m&&(s=l9(m,this.logger))&&this.parseID3PES(l,s),m={data:[],size:0}),m&&(m.data.push(e.subarray(r,t+188)),m.size+=t+188-r);break;case 0:var _,A;y&&(r+=e[r]+1),E=this._pmtId=(31&(_=e)[(A=r)+10])<<8|_[A+11];break;case E:{y&&(r+=e[r]+1);let s=function(e,t,i,r,s,a){let n={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},l=(15&e[t+1])<<8|e[t+2],o=t+3+l-4,d=(15&e[t+10])<<8|e[t+11];for(t+=12+d;t<o;){let l=l5(e,t),o=(15&e[t+3])<<8|e[t+4];switch(e[t]){case 207:if(!r){l6("ADTS AAC",a);break}case 15:-1===n.audioPid&&(n.audioPid=l);break;case 21:-1===n.id3Pid&&(n.id3Pid=l);break;case 219:if(!r){l6("H.264",a);break}case 27:-1===n.videoPid&&(n.videoPid=l);break;case 3:case 4:i.mpeg||i.mp3?-1===n.audioPid&&(n.audioPid=l,n.segmentAudioCodec="mp3"):a.log("MPEG audio found, not supported in this browser");break;case 193:if(!r){l6("AC-3",a);break}case 129:i.ac3?-1===n.audioPid&&(n.audioPid=l,n.segmentAudioCodec="ac3"):a.log("AC-3 audio found, not supported in this browser");break;case 6:if(-1===n.audioPid&&o>0){let r=t+5,s=o;for(;s>2;){106===e[r]&&(!0!==i.ac3?a.log("AC-3 audio found, not supported in this browser for now"):(n.audioPid=l,n.segmentAudioCodec="ac3"));let t=e[r+1]+2;r+=t,s-=t}}break;case 194:case 135:return l8(s,Error("Unsupported EC-3 in M2TS found"),void 0,a),n;case 36:-1===n.videoPid&&(n.videoPid=l,n.segmentVideoCodec="hevc",a.log("HEVC in M2TS found"))}t+=o+5}return n}
6(e,r,this.typeSupported,i,this.observer,this.logger);(d=s.videoPid)>0&&(a.pid=d,a.segmentCodec=s.segmentVideoCodec),(u=s.audioPid)>0&&(n.pid=u,n.segmentCodec=s.segmentAudioCodec),(c=s.id3Pid)>0&&(l.pid=c),null===g||v||(this.logger.warn(`MPEG-TS PMT found at ${t} after unknown PID '${g}'. Backtracking to sync byte @${b} to parse all TS packets.`),g=null,t=b-188),v=this.pmtParsed=!0;break}case 17:case 8191:break;default:g=T}}else T++;T>0&&l8(this.observer,Error(`Found ${T} TS packet/s that do not start with 0x47`),void 0,this.logger),a.pesData=h,n.pesData=f,l.pesData=m;let S={audioTrack:n,videoTrack:a,id3Track:l,textTrack:o};return r&&this.extractRemainingSamples(S),S}flush(){let e,{remainderData:t}=this;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}extractRemainingSamples(e){let t,{audioTrack:i,videoTrack:r,id3Track:s,textTrack:a}=e,n=r.pesData,l=i.pesData,o=s.pesData;if(n&&(t=l9(n,this.logger))?(this.readyVideoParser(r.segmentCodec),null!==this.videoParser&&(this.videoParser.parsePES(r,a,t,!0),r.pesData=null)):r.pesData=n,l&&(t=l9(l,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!=l&&l.size&&this.logger.log("last AAC PES packet truncated,might overlap between fragments"),i.pesData=l;o&&(t=l9(o,this.logger))?(this.parseID3PES(s,t),s.pesData=null):s.pesData=o}demuxSampleAes(e,t,i){let r=this.demux(e,i,!0,!this.config.progressive),s=this.sampleAes=new lJ(this.observer,this.config,t);return this.decrypt(r,s)}readyVideoParser(e){null===this.videoParser&&("avc"===e?this.videoParser=new l2:"hevc"===e&&(this.videoParser=new l3))}decrypt(e,t){return new Promise(i=>{let{audioTrack:r,videoTrack:s}=e;r.samples&&"aac"===r.segmentCodec?t.decryptAacSamples(r.samples,0,()=>{s.samples?t.decryptAvcSamples(s.samples,0,0,()=>{i(e)}):i(e)}):s.samples&&t.decryptAvcSamples(s.samples,0,0,()=>{i(e)})})}destroy(){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}parseAACPES(e,t){let i,r,s,a,n=0,l=this.aacOverFlow,o=t.data;if(l){this.aacOverFlow=null;let t=l.missing,i=l.sample.unit.byteLength;-1===t?o=s0(l.sample.unit,o):(l.sample.unit.set(o.subarray(0,t),i-t),e.samples.push(l.sample),n=l.missing)}for(i=n,r=o.length;i<r-1&&!lI(o,i);i++);if(i!==n){let e,t=i<r-1;if(e=t?`AAC PES did not start with ADTS header,offset:${i}`:"No ADTS header found in AAC PES",l8(this.observer,Error(e),t,this.logger),!t)return}if(lw(e,this.observer,o,i,this.audioCodec),void 0!==t.pts)s=t.pts;else{if(!l)return void this.logger.warn("[tsdemuxer]: AAC PES unknown PTS");let t=9216e4/e.samplerate;s=l.sample.pts+t}let d=0;for(;i<r;){if(a=lD(e,o,i,s,d),i+=a.length,a.missing){this.aacOverFlow=a;break}for(d++;i<r-1&&!lI(o,i);i++);}}parseMPEGPES(e,t){let i=t.data,r=i.length,s=0,a=0,n=t.pts;if(void 0===n)return void this.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");for(;a<r;)if(lj(i,a)){let t=lK(e,i,a,n,s);if(t)a+=t.length,s++;else break}else a++}parseAC3PES(e,t){{let i,r=t.data,s=t.pts;if(void 0===s)return void this.logger.warn("[tsdemuxer]: AC3 PES unknown PTS");let a=r.length,n=0,l=0;for(;l<a&&(i=lz(e,r,l,s,n++))>0;)l+=i}}parseID3PES(e,t){if(void 0===t.pts)return void this.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");let i=sp({},t,{type:this._videoTrack?lO.emsg:lO.audioId3,duration:1/0});e.samples.push(i)}}function l5(e,t){return((31&e[t+1])<<8)+e[t+2]}function l8(e,t,i,r){r.warn(`parsing error: ${t.message}`),e.emit(sa.ERROR,sa.ERROR,{type:sr.MEDIA_ERROR,details:ss.FRAG_PARSING_ERROR,fatal:!1,levelRetry:i,error:t,reason:t.message})}function l6(e,t){t.log(`${e} with AES-128-CBC encryption found in unencrypted stream`)}function l9(e,t){let i,r,s,a,n,l=0,o=e.data;if(!e||0===e.size)return null;for(;o[0].length<19&&o.length>1;)o[0]=s0(o[0],o[1]),o.splice(1,1);if(1===((i=o[0])[0]<<16)+(i[1]<<8)+i[2]){if((r=(i[4]<<8)+i[5])&&r>e.size-6)return null;let d=i[7];192&d&&(a=(14&i[9])*0x20000000+(255&i[10])*4194304+(254&i[11])*16384+(255&i[12])*128+(254&i[13])/2,64&d?a-(n=(14&i[14])*0x20000000+(255&i[15])*4194304+(254&i[16])*16384+(255&i[17])*128+(254&i[18])/2)>54e5&&(t.warn(`${Math.round((a-n)/9e4)}s delta between PTS and DTS, align them`),a=n):n=a);let h=(s=i[8])+9;if(e.size<=h)return null;e.size-=h;let u=new Uint8Array(e.size);for(let e=0,t=o.length;e<t;e++){let t=(i=o[e]).byteLength;if(h)if(h>t){h-=t;continue}else i=i.subarray(h),t-=h,h=0;u.set(i,l),l+=t}return r&&(r-=s+3),{data:u,pts:a,dts:n,len:r}}return null}class l7{static getSilentFrame(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]);else if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);else 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]);else 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])}}}class oe{static init(){let e;for(e in oe.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:[]},oe.types)oe.types.hasOwnProperty(e)&&(oe.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);oe.HDLR_TYPES={video: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]),audio: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])};let t=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]);oe.STTS=oe.STSC=oe.STCO=new Uint8Array([0,0,0,0,0,0,0,0]),oe.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),oe.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),oe.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),oe.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);
6let i=new Uint8Array([105,115,111,109]),r=new Uint8Array([97,118,99,49]),s=new Uint8Array([0,0,0,1]);oe.FTYP=oe.box(oe.types.ftyp,i,s,i,r),oe.DINF=oe.box(oe.types.dinf,oe.box(oe.types.dref,t))}static box(e,...t){let i=8,r=t.length,s=r;for(;r--;)i+=t[r].byteLength;let a=new Uint8Array(i);for(a[0]=i>>24&255,a[1]=i>>16&255,a[2]=i>>8&255,a[3]=255&i,a.set(e,4),r=0,i=8;r<s;r++)a.set(t[r],i),i+=t[r].byteLength;return a}static hdlr(e){return oe.box(oe.types.hdlr,oe.HDLR_TYPES[e])}static mdat(e){return oe.box(oe.types.mdat,e)}static mdhd(e,t){let i=Math.floor((t*=e)/0x100000000),r=Math.floor(t%0x100000000);return oe.box(oe.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,i>>24,i>>16&255,i>>8&255,255&i,r>>24,r>>16&255,r>>8&255,255&r,85,196,0,0]))}static mdia(e){return oe.box(oe.types.mdia,oe.mdhd(e.timescale||0,e.duration||0),oe.hdlr(e.type),oe.minf(e))}static mfhd(e){return oe.box(oe.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e]))}static minf(e){return"audio"===e.type?oe.box(oe.types.minf,oe.box(oe.types.smhd,oe.SMHD),oe.DINF,oe.stbl(e)):oe.box(oe.types.minf,oe.box(oe.types.vmhd,oe.VMHD),oe.DINF,oe.stbl(e))}static moof(e,t,i){return oe.box(oe.types.moof,oe.mfhd(e),oe.traf(i,t))}static moov(e){let t=e.length,i=[];for(;t--;)i[t]=oe.trak(e[t]);return oe.box.apply(null,[oe.types.moov,oe.mvhd(e[0].timescale||0,e[0].duration||0)].concat(i).concat(oe.mvex(e)))}static mvex(e){let t=e.length,i=[];for(;t--;)i[t]=oe.trex(e[t]);return oe.box.apply(null,[oe.types.mvex,...i])}static mvhd(e,t){let i=Math.floor((t*=e)/0x100000000),r=Math.floor(t%0x100000000),s=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,i>>24,i>>16&255,i>>8&255,255&i,r>>24,r>>16&255,r>>8&255,255&r,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 oe.box(oe.types.mvhd,s)}static sdtp(e){let t,i,r=e.samples||[],s=new Uint8Array(4+r.length);for(t=0;t<r.length;t++)i=r[t].flags,s[t+4]=i.dependsOn<<4|i.isDependedOn<<2|i.hasRedundancy;return oe.box(oe.types.sdtp,s)}static stbl(e){return oe.box(oe.types.stbl,oe.stsd(e),oe.box(oe.types.stts,oe.STTS),oe.box(oe.types.stsc,oe.STSC),oe.box(oe.types.stsz,oe.STSZ),oe.box(oe.types.stco,oe.STCO))}static avc1(e){let t,i,r,s=[],a=[];for(t=0;t<e.sps.length;t++)r=(i=e.sps[t]).byteLength,s.push(r>>>8&255),s.push(255&r),s=s.concat(Array.prototype.slice.call(i));for(t=0;t<e.pps.length;t++)r=(i=e.pps[t]).byteLength,a.push(r>>>8&255),a.push(255&r),a=a.concat(Array.prototype.slice.call(i));let n=oe.box(oe.types.avcC,new Uint8Array([1,s[3],s[4],s[5],255,224|e.sps.length].concat(s).concat([e.pps.length]).concat(a))),l=e.width,o=e.height,d=e.pixelRatio[0],h=e.pixelRatio[1];return oe.box(oe.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,l>>8&255,255&l,o>>8&255,255&o,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]),n,oe.box(oe.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),oe.box(oe.types.pasp,new Uint8Array([d>>24,d>>16&255,d>>8&255,255&d,h>>24,h>>16&255,h>>8&255,255&h])))}static esds(e){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,...e.config,6,1,2])}static audioStsd(e){let 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])}static mp4a(e){return oe.box(oe.types.mp4a,oe.audioStsd(e),oe.box(oe.types.esds,oe.esds(e)))}static mp3(e){return oe.box(oe.types[".mp3"],oe.audioStsd(e))}static ac3(e){return oe.box(oe.types["ac-3"],oe.audioStsd(e),oe.box(oe.types.dac3,e.config))}static stsd(e){let{segmentCodec:t}=e;if("audio"===e.type){if("aac"===t)return oe.box(oe.types.stsd,oe.STSD,oe.mp4a(e));if("ac3"===t&&e.config)return oe.box(oe.types.stsd,oe.STSD,oe.ac3(e));if("mp3"===t&&"mp3"===e.codec)return oe.box(oe.types.stsd,oe.STSD,oe.mp3(e))}else if(e.pps&&e.sps){if("avc"===t)return oe.box(oe.types.stsd,oe.STSD,oe.avc1(e));if("hevc"===t&&e.vps)return oe.box(oe.types.stsd,oe.STSD,oe.hvc1(e))}
6else throw Error("video track missing pps or sps");throw Error(`unsupported ${e.type} segment codec (${t}/${e.codec})`)}static tkhd(e){let t=e.id,i=(e.duration||0)*(e.timescale||0),r=e.width||0,s=e.height||0,a=Math.floor(i/0x100000000),n=Math.floor(i%0x100000000);return oe.box(oe.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,0,0,0,0,a>>24,a>>16&255,a>>8&255,255&a,n>>24,n>>16&255,n>>8&255,255&n,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,r>>8&255,255&r,0,0,s>>8&255,255&s,0,0]))}static traf(e,t){let i=oe.sdtp(e),r=e.id,s=Math.floor(t/0x100000000),a=Math.floor(t%0x100000000);return oe.box(oe.types.traf,oe.box(oe.types.tfhd,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r])),oe.box(oe.types.tfdt,new Uint8Array([1,0,0,0,s>>24,s>>16&255,s>>8&255,255&s,a>>24,a>>16&255,a>>8&255,255&a])),oe.trun(e,i.length+16+20+8+16+8+8),i)}static trak(e){return e.duration=e.duration||0xffffffff,oe.box(oe.types.trak,oe.tkhd(e),oe.mdia(e))}static trex(e){let t=e.id;return oe.box(oe.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(e,t){let i,r,s,a,n,l,o=e.samples||[],d=o.length,h=12+16*d,u=new Uint8Array(h);for(t+=8+h,u.set([+("video"===e.type),0,15,1,d>>>24&255,d>>>16&255,d>>>8&255,255&d,t>>>24&255,t>>>16&255,t>>>8&255,255&t],0),i=0;i<d;i++)s=(r=o[i]).duration,a=r.size,n=r.flags,l=r.cts,u.set([s>>>24&255,s>>>16&255,s>>>8&255,255&s,a>>>24&255,a>>>16&255,a>>>8&255,255&a,n.isLeading<<2|n.dependsOn,n.isDependedOn<<6|n.hasRedundancy<<4|n.paddingValue<<1|n.isNonSync,61440&n.degradPrio,15&n.degradPrio,l>>>24&255,l>>>16&255,l>>>8&255,255&l],12+16*i);return oe.box(oe.types.trun,u)}static initSegment(e){oe.types||oe.init();let t=oe.moov(e);return s0(oe.FTYP,t)}static hvc1(e){let t=e.params,i=[e.vps,e.sps,e.pps],r=new Uint8Array([1,t.general_profile_space<<6|32*!!t.general_tier_flag|t.general_profile_idc,t.general_profile_compatibility_flags[0],t.general_profile_compatibility_flags[1],t.general_profile_compatibility_flags[2],t.general_profile_compatibility_flags[3],t.general_constraint_indicator_flags[0],t.general_constraint_indicator_flags[1],t.general_constraint_indicator_flags[2],t.general_constraint_indicator_flags[3],t.general_constraint_indicator_flags[4],t.general_constraint_indicator_flags[5],t.general_level_idc,240|t.min_spatial_segmentation_idc>>8,255&t.min_spatial_segmentation_idc,252|t.parallelismType,252|t.chroma_format_idc,248|t.bit_depth_luma_minus8,248|t.bit_depth_chroma_minus8,0,parseInt(t.frame_rate.fps),3|t.temporal_id_nested<<2|t.num_temporal_layers<<3|64*!!t.frame_rate.fixed,i.length]),s=r.length;for(let e=0;e<i.length;e+=1){s+=3;for(let t=0;t<i[e].length;t+=1)s+=2+i[e][t].length}let a=new Uint8Array(s);a.set(r,0),s=r.length;let n=i.length-1;for(let e=0;e<i.length;e+=1){a.set(new Uint8Array([32+e|128*(e===n),0,i[e].length]),s),s+=3;for(let t=0;t<i[e].length;t+=1)a.set(new Uint8Array([i[e][t].length>>8,255&i[e][t].length]),s),s+=2,a.set(i[e][t],s),s+=i[e][t].length}let l=oe.box(oe.types.hvcC,a),o=e.width,d=e.height,h=e.pixelRatio[0],u=e.pixelRatio[1];return oe.box(oe.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,o>>8&255,255&o,d>>8&255,255&d,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]),l,oe.box(oe.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),oe.box(oe.types.pasp,new Uint8Array([h>>24,h>>16&255,h>>8&255,255&h,u>>24,u>>16&255,u>>8&255,255&u])))}}function ot(e,t,i=1,r=!1){let s=e*t*i;return r?Math.round(s):s}function oi(e,t=!1){return ot(e,1e3,11111111111111112e-21,t)}function or(e){let{baseTime:t,timescale:i,trackId:r}=e;return`${t/i} (${t}/${i}) trackId: ${r}`}oe.types=void 0,oe.HDLR_TYPES=void 0,oe.STTS=void 0,oe.STSC=void 0,oe.STCO=void 0,oe.STSZ=void 0,oe.VMHD=void 0,oe.SMHD=void 0,oe.STSD=void 0,oe.FTYP=void 0,oe.DINF=void 0;let os=null,oa=null;function on(e,t,i,r){return{duration:t,size:i,cts:r,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:e?2:1,isNonSync:+!e}}}class ol extends sE{constructor(e,t,i,r){if(super("mp4-remuxer",r),this.observer=void 0,this.config=void 0,this.typeSupp
6orted=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextVideoTs=null,this.nextAudioTs=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.videoTrackConfig=void 0,this.observer=e,this.config=t,this.typeSupported=i,this.ISGenerated=!1,null===os){const e=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);os=e?parseInt(e[1]):0}if(null===oa){const e=navigator.userAgent.match(/Safari\/(\d+)/i);oa=e?parseInt(e[1]):0}}destroy(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null}resetTimeStamp(e){let t=this._initPTS;t&&e&&e.trackId===t.trackId&&e.baseTime===t.baseTime&&e.timescale===t.timescale||this.log(`Reset initPTS: ${t?or(t):t} > ${e?or(e):e}`),this._initPTS=this._initDTS=e}resetNextTimestamp(){this.log("reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){this.log("ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0}getVideoStartPts(e){let t=!1,i=e[0].pts,r=e.reduce((e,r)=>{let s=r.pts,a=s-e;return(a<-0x100000000&&(t=!0,a=(s=oo(s,i))-e),a>0)?e:s},i);return t&&this.debug("PTS rollover detected"),r}remux(e,t,i,r,s,a,n,l){let o,d,h,u,c,f,m=s,g=s,v=e.pid>-1,E=t.pid>-1,y=t.samples.length,b=e.samples.length>0,T=n&&y>0||y>1;if((!v||b)&&(!E||T)||this.ISGenerated||n){let i;if(this.ISGenerated){var _,A,S,k;let e=this.videoTrackConfig;(e&&(t.width!==e.width||t.height!==e.height||(null==(_=t.pixelRatio)?void 0:_[0])!==(null==(A=e.pixelRatio)?void 0:A[0])||(null==(S=t.pixelRatio)?void 0:S[1])!==(null==(k=e.pixelRatio)?void 0:k[1]))||!e&&T||null===this.nextAudioTs&&b)&&this.resetInitSegment()}this.ISGenerated||(h=this.generateIS(e,t,s,a));let r=this.isVideoContiguous,n=-1;if(T&&(n=function(e){for(let t=0;t<e.length;t++)if(e[t].key)return t;return -1}(t.samples),!r&&this.config.forceKeyFrameOnDiscontinuity))if(f=!0,n>0){this.warn(`Dropped ${n} out of ${y} video samples due to a missing keyframe`);let e=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(n),t.dropped+=n,g+=(t.samples[0].pts-e)/t.inputTimeScale,i=g}else -1===n&&(this.warn(`No keyframe found out of ${y} video samples`),f=!1);if(this.ISGenerated){if(b&&T){let i=this.getVideoStartPts(t.samples),r=(oo(e.samples[0].pts,i)-i)/t.inputTimeScale;m+=Math.max(0,r),g+=Math.max(0,-r)}if(b){if(e.samplerate||(this.warn("regenerate InitSegment as audio detected"),h=this.generateIS(e,t,s,a)),d=this.remuxAudio(e,m,this.isAudioContiguous,a,E||T||l===su?g:void 0),T){let i=d?d.endPTS-d.startPTS:0;t.inputTimeScale||(this.warn("regenerate InitSegment as video detected"),h=this.generateIS(e,t,s,a)),o=this.remuxVideo(t,g,r,i)}}else T&&(o=this.remuxVideo(t,g,r,0));o&&(o.firstKeyFrame=n,o.independent=-1!==n,o.firstKeyFramePTS=i)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(i.samples.length&&(c=od(i,s,this._initPTS,this._initDTS)),r.samples.length&&(u=oh(r,s,this._initPTS))),{audio:d,video:o,initSegment:h,independent:f,text:u,id3:c}}computeInitPts(e,t,i,r){let s=Math.round(i*t),a=oo(e,s);if(a<s+t)for(this.log(`Adjusting PTS for rollover in timeline near ${(s-a)/t} ${r}`);a<s+t;)a+=0x200000000;return a-s}generateIS(e,t,i,r){let s,a,n,l=e.samples,o=t.samples,d=this.typeSupported,h={},u=this._initPTS,c=!u||r,f="audio/mp4",m=-1;if(c&&(s=a=1/0),e.config&&l.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":d.mpeg?(f="audio/mpeg",e.codec=""):d.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3"}h.audio={id:"audio",container:f,codec:e.codec,initSegment:"mp3"===e.segmentCodec&&d.mpeg?new Uint8Array(0):oe.initSegment([e]),metadata:{channelCount:e.channelCount}},c&&(m=e.id,n=e.inputTimeScale,u&&n===u.timescale?c=!1:s=a=this.computeInitPts(l[0].pts,n,i,"audio"))}if(t.sps&&t.pps&&o.length){if(t.timescale=t.inputTimeScale,h.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:oe.initSegment([t]),metadata:{width:t.width,height:t.height}},c)if(m=t.id,n=t.inputTimeScale,u&&n===u.timescale)c=!1;else{let e=this.getVideoStartPts(o),t=oo(o[0].dts,e),r=this.computeInitPts(t,n,i,"video"),l=this.computeInitPts(e,n,i,"video");a=Math.min(a,r),s=Math.min(s,l)}this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(h).length)return this.ISGenerated=!0,c?(u&&this.warn(`Timestamps at playlist time: ${r?"":"~"}${i} ${s/n} != initPTS: ${u.baseTime/u.timescale} (${u.baseTime}/${u.timescale}) trackId: ${u.trackId}`),this.log(`Found initPTS at playlist time: ${i} offset: ${s/n} (${s}/${n}) trackId: ${m}`),this._initPTS={baseTime:s,timescale:n,trackId:m},this._initDTS={baseTime:a,timescale:n,trackId:m}):s=n=void 0,{tracks:h,initPTS:s,timescale:n,trackId:m}}remuxVideo(e,t,i,r){let s,a,n,l=e.inputTimeScale,o=e.samples,d=[],h=o.length,u=this._initPTS,c=u.baseTime*l/u.timescale,f=this.nextVideoTs,m=8,g=this.videoSampleDuration,v=1/0,E=-1/0,y=!1;if(!i||null===f){let e=c+t*l,r=o[0].pts-oo(o[0].dts,o[0].pts);os&&null!==f&&15e3>Math.abs(e-r-(f+c))?i=!0:f=e-r-c}let b=f+c;for(let e=0;e<h;
6e++){let t=o[e];t.pts=oo(t.pts,b),t.dts=oo(t.dts,b),t.dts<o[e>0?e-1:e].dts&&(y=!0)}y&&o.sort(function(e,t){let i=e.dts-t.dts,r=e.pts-t.pts;return i||r}),s=o[0].dts;let T=(a=o[o.length-1].dts)-s,_=T?Math.round(T/(h-1)):g||e.inputTimeScale/30;if(i){let i=s-b,r=i>_,a=i<-1;if((r||a)&&(r?this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${oi(i,!0)} ms (${i}dts) hole between fragments detected at ${t.toFixed(3)}`):this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${oi(-i,!0)} ms (${i}dts) overlapping between fragments detected at ${t.toFixed(3)}`),!a||b>=o[0].pts||os)){s=b;let e=o[0].pts-i;if(r)o[0].dts=s,o[0].pts=e;else{let t=!0;for(let r=0;r<o.length&&(!(o[r].dts>e)||!t);r++){let e=o[r].pts;if(o[r].dts-=i,o[r].pts-=i,r<o.length-1){let i=o[r+1].pts;t=i<=o[r].pts==i<=e}}}this.log(`Video: Initial PTS/DTS adjusted: ${oi(e,!0)}/${oi(s,!0)}, delta: ${oi(i,!0)} ms`)}}let A=0,S=0,k=s=Math.max(0,s);for(let e=0;e<h;e++){let t=o[e],i=t.units,r=i.length,s=0;for(let e=0;e<r;e++)s+=i[e].data.length;S+=s,A+=r,t.length=s,t.dts<k?(t.dts=k,k+=_/4|0||1):k=t.dts,v=Math.min(t.pts,v),E=Math.max(t.pts,E)}a=o[h-1].dts;let L=S+4*A+8;try{n=new Uint8Array(L)}catch(e){this.observer.emit(sa.ERROR,sa.ERROR,{type:sr.MUX_ERROR,details:ss.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:L,reason:`fail allocating video mdat ${L}`});return}let R=new DataView(n.buffer);R.setUint32(0,L),n.set(oe.types.mdat,4);let I=!1,w=1/0,D=1/0,C=-1/0,P=-1/0;for(let e=0;e<h;e++){let t,i=o[e],s=i.units,a=0;for(let e=0,t=s.length;e<t;e++){let t=s[e],i=t.data,r=t.data.byteLength;R.setUint32(m,r),m+=4,n.set(i,m),m+=r,a+=4+r}if(e<h-1)g=o[e+1].dts-i.dts,t=o[e+1].pts-i.pts;else{let s=this.config,a=e>0?i.dts-o[e-1].dts:_;if(t=e>0?i.pts-o[e-1].pts:_,s.stretchShortVideoTrack&&null!==this.nextAudioTs){let e=Math.floor(s.maxBufferHole*l),t=(r?v+r*l:this.nextAudioTs+c)-i.pts;t>e?((g=t-a)<0?g=a:I=!0,this.log(`It is approximately ${t/90} ms to the next segment; using duration ${g/90} ms for the last video frame.`)):g=a}else g=a}let u=Math.round(i.pts-i.dts);w=Math.min(w,g),C=Math.max(C,g),D=Math.min(D,t),P=Math.max(P,t),d.push(on(i.key,g,a,u))}if(d.length){if(os){if(os<70){let e=d[0].flags;e.dependsOn=2,e.isNonSync=0}}else if(oa&&P-D<C-w&&_/C<.025&&0===d[0].cts){this.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let e=s;for(let t=0,i=d.length;t<i;t++){let r=e+d[t].duration,s=e+d[t].cts;if(t<i-1){let e=r+d[t+1].cts;d[t].duration=e-s}else d[t].duration=t?d[t-1].duration:_;d[t].cts=0,e=r}}}let x=a+(g=I||!g?_:g);this.nextVideoTs=f=x-c,this.videoSampleDuration=g,this.isVideoContiguous=!0;let M={data1:oe.moof(e.sequenceNumber++,s,sp(e,{samples:d})),data2:n,startPTS:(v-c)/l,endPTS:(E+g-c)/l,startDTS:(s-c)/l,endDTS:f/l,type:"video",hasAudio:!1,hasVideo:!0,nb:d.length,dropped:e.dropped};return e.samples=[],e.dropped=0,M}getSamplesPerFrame(e){switch(e.segmentCodec){case"mp3":return 1152;case"ac3":return 1536;default:return 1024}}remuxAudio(e,t,i,r,s){let a,n=e.inputTimeScale,l=e.samplerate?e.samplerate:n,o=n/l,d=this.getSamplesPerFrame(e),h=d*o,u=this._initPTS,c="mp3"===e.segmentCodec&&this.typeSupported.mpeg,f=[],m=void 0!==s,g=e.samples,v=8*!c,E=this.nextAudioTs||-1,y=u.baseTime*n/u.timescale,b=y+t*n;if(this.isAudioContiguous=i=i||g.length&&E>0&&(r&&9e3>Math.abs(b-(E+y))||Math.abs(oo(g[0].pts,b)-(E+y))<20*h),g.forEach(function(e){e.pts=oo(e.pts,b)}),!i||E<0){let e=g.length;if(e!==(g=g.filter(e=>e.pts>=0)).length&&this.warn(`Removed ${g.length-e} of ${e} samples (initPTS ${y} / ${n})`),!g.length)return;E=0===s?0:r&&!m?Math.max(0,b-y):g[0].pts-y}if("aac"===e.segmentCodec){let t=this.config.maxAudioFramesDrift;for(let i=0,r=E+y;i<g.length;i++){let s=g[i],a=s.pts,l=a-r,o=Math.abs(1e3*l/n);
6if(l<=-t*h&&m)0===i&&(this.warn(`Audio frame @ ${(a/n).toFixed(3)}s overlaps marker by ${Math.round(1e3*l/n)} ms.`),this.nextAudioTs=E=a-y,r=a);else if(l>=t*h&&o<1e4&&m){let t=Math.round(l/h);for(r=a-t*h;r<0&&t&&h;)t--,r+=h;0===i&&(this.nextAudioTs=E=r-y),this.warn(`Injecting ${t} audio frames @ ${((r-y)/n).toFixed(3)}s due to ${Math.round(1e3*l/n)} ms gap.`);for(let a=0;a<t;a++){let t=l7.getSilentFrame(e.parsedCodec||e.manifestCodec||e.codec,e.channelCount);t||(this.log("Unable to get silent frame for given audio codec; duplicating last frame instead."),t=s.unit.subarray()),g.splice(i,0,{unit:t,pts:r}),r+=h,i++}}s.pts=r,r+=h}}let T=null,_=null,A=0,S=g.length;for(;S--;)A+=g[S].unit.byteLength;for(let t=0,r=g.length;t<r;t++){let r=g[t],s=r.unit,n=r.pts;if(null!==_)f[t-1].duration=Math.round((n-_)/o);else{if(i&&"aac"===e.segmentCodec&&(n=E+y),T=n,!(A>0))return;A+=v;try{a=new Uint8Array(A)}catch(e){this.observer.emit(sa.ERROR,sa.ERROR,{type:sr.MUX_ERROR,details:ss.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:A,reason:`fail allocating audio mdat ${A}`});return}c||(new DataView(a.buffer).setUint32(0,A),a.set(oe.types.mdat,4))}a.set(s,v);let l=s.byteLength;v+=l,f.push(on(!0,d,l,0)),_=n}let k=f.length;if(!k)return;let L=f[f.length-1];E=_-y,this.nextAudioTs=E+o*L.duration;let R=c?new Uint8Array(0):oe.moof(e.sequenceNumber++,T/o,sp({},e,{samples:f}));e.samples=[];let I=(T-y)/n,w=this.nextAudioTs/n,D={data1:R,data2:a,startPTS:I,endPTS:w,startDTS:I,endDTS:w,type:"audio",hasAudio:!0,hasVideo:!1,nb:k};return this.isAudioContiguous=!0,D}}function oo(e,t){let i;if(null===t)return e;for(i=t<e?-0x200000000:0x200000000;Math.abs(e-t)>0x100000000;)e+=i;return e}function od(e,t,i,r){let s=e.samples.length;if(!s)return;let a=e.inputTimeScale;for(let n=0;n<s;n++){let s=e.samples[n];s.pts=oo(s.pts-i.baseTime*a/i.timescale,t*a)/a,s.dts=oo(s.dts-r.baseTime*a/r.timescale,t*a)/a}let n=e.samples;return e.samples=[],{samples:n}}function oh(e,t,i){let r=e.samples.length;if(!r)return;let s=e.inputTimeScale;for(let a=0;a<r;a++){let r=e.samples[a];r.pts=oo(r.pts-i.baseTime*s/i.timescale,t*s)/s}e.samples.sort((e,t)=>e.pts-t.pts);let a=e.samples;return e.samples=[],{samples:a}}function ou(e,t,i=!1){return(null==e?void 0:e.start)!==void 0?(e.start+(i?e.duration:0))/e.timescale:t}function oc(e,t,i){let r=e.codec;return r&&r.length>4?r:t===sP?"ec-3"===r||"ac-3"===r||"alac"===r?r:"fLaC"===r||"Opus"===r?as(r,!1):(i.warn(`Unhandled audio codec "${r}" in mp4 MAP`),r||"mp4a"):(i.warn(`Unhandled video codec "${r}" in mp4 MAP`),r||"avc1")}try{t=self.performance.now.bind(self.performance)}catch(e){t=Date.now}let of=[{demux:class{constructor(e,t){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=t}resetTimeStamp(){}resetInitSegment(e,t,i,r){let s=this.videoTrack=lN("video",1),a=this.audioTrack=lN("audio",1),n=this.txtTrack=lN("text",1);if(this.id3Track=lN("id3",1),this.timeOffset=0,!(null!=e&&e.byteLength))return;let l=sj(e);if(l.video){let{id:e,timescale:t,codec:i,supplemental:r}=l.video;s.id=e,s.timescale=n.timescale=t,s.codec=i,s.supplemental=r}if(l.audio){let{id:e,timescale:t,codec:i}=l.audio;a.id=e,a.timescale=t,a.codec=i}n.id=sB.text,s.sampleDuration=0,s.duration=a.duration=r}resetContiguity(){this.remainderData=null}static probe(e){let t=e.byteLength;for(let i=0;i<t;){let r=sV(e,i);if(r>8&&109===e[i+4]&&111===e[i+5]&&111===e[i+6]&&102===e[i+7])return!0;i=r>1?i+r:t}return!1}demux(e,t){this.timeOffset=t;let i=e,r=this.videoTrack,s=this.txtTrack;if(this.config.progressive){this.remainderData&&(i=s0(this.remainderData,e));let t=function(e){let t={valid:null,remainder:null},i=sq(e,["moof"]);if(i.length<2)return t.remainder=e,t;let r=i[i.length-1];return t.valid=e.slice(0,r.byteOffset-8),t.remainder=e.slice(r.byteOffset-8),t}(i);this.remainderData=t.remainder,r.samples=t.valid||new Uint8Array}else r.samples=i;let a=this.extractID3Track(r,t);return s.samples=s1(t,r),{videoTrack:r,audioTrack:this.audioTrack,id3Track:a,textTrack:this.txtTrack}}flush(){let e=this.timeOffset,t=this.videoTrack,i=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;let r=this.extractID3Track(t,this.timeOffset);return i.samples=s1(e,t),{videoTrack:t,audioTrack:lN(),id3Track:r,textTrack:lN()}}extractID3Track(e,t){let i=this.id3Track;
6return e.samples.length&&sq(e.samples,["emsg"]).forEach(e=>{let r=function(e){let t=e[0],i="",r="",s=0,a=0,n=0,l=0,o=0,d=0;if(0===t){for(;"\0"!==sH(e.subarray(d,d+1));)i+=sH(e.subarray(d,d+1)),d+=1;for(i+=sH(e.subarray(d,d+1)),d+=1;"\0"!==sH(e.subarray(d,d+1));)r+=sH(e.subarray(d,d+1)),d+=1;r+=sH(e.subarray(d,d+1)),d+=1,s=sV(e,12),a=sV(e,16),l=sV(e,20),o=sV(e,24),d=28}else if(1===t){d+=4,s=sV(e,d);let t=sV(e,d+=4),a=sV(e,d+=4);for(d+=4,st(n=0x100000000*t+a)||(n=Number.MAX_SAFE_INTEGER,sA.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),l=sV(e,d),d+=4,o=sV(e,d),d+=4;"\0"!==sH(e.subarray(d,d+1));)i+=sH(e.subarray(d,d+1)),d+=1;for(i+=sH(e.subarray(d,d+1)),d+=1;"\0"!==sH(e.subarray(d,d+1));)r+=sH(e.subarray(d,d+1)),d+=1;r+=sH(e.subarray(d,d+1)),d+=1}return{schemeIdUri:i,value:r,timeScale:s,presentationTime:n,presentationTimeDelta:a,eventDuration:l,id:o,payload:e.subarray(d,e.byteLength)}}(e);if(lX.test(r.schemeIdUri)){let e=lZ(r,t),s=0xffffffff===r.eventDuration?1/0:r.eventDuration/r.timeScale;s<=.001&&(s=1/0);let a=r.payload;i.samples.push({data:a,len:a.byteLength,dts:e,pts:e,type:lO.emsg,duration:s})}else if(this.config.enableEmsgKLVMetadata&&r.schemeIdUri.startsWith("urn:misb:KLV:bin:1910.1")){let e=lZ(r,t);i.samples.push({data:r.payload,len:r.payload.byteLength,dts:e,pts:e,type:lO.misbklv,duration:1/0})}}),i}demuxSampleAes(e,t,i){return Promise.reject(Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){this.config=null,this.remainderData=null,this.videoTrack=this.audioTrack=this.id3Track=this.txtTrack=void 0}},remux:class extends sE{constructor(e,t,i,r){super("passthrough-remuxer",r),this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null,this.isVideoContiguous=!1}destroy(){}resetTimeStamp(e){this.lastEndTime=null;let t=this.initPTS;t&&e&&t.baseTime===e.baseTime&&t.timescale===e.timescale||(this.initPTS=e)}resetNextTimestamp(){this.isVideoContiguous=!1,this.lastEndTime=null}resetInitSegment(e,t,i,r){this.audioCodec=t,this.videoCodec=i,this.generateInitSegment(e,r),this.emitInitSegment=!0}generateInitSegment(e,t){let{audioCodec:i,videoCodec:r}=this;if(!(null!=e&&e.byteLength)){this.initTracks=void 0,this.initData=void 0;return}let{audio:s,video:a}=this.initData=sj(e);if(t)!function(e,t){if(!e||!t)return;let i=t.keyId;i&&t.isCommonEncryption&&sZ(e,(e,t)=>{let r=e.subarray(8,24);r.some(e=>0!==e)||(sA.log(`[eme] Patching keyId in 'enc${t?"a":"v"}>sinf>>tenc' box: ${sR(r)} -> ${sR(i)}`),e.set(i,8))})}(e,t);else{let e=s||a;null!=e&&e.encrypted&&this.warn(`Init segment with encrypted track with has no key ("${e.codec}")!`)}s&&(i=oc(s,sP,this)),a&&(r=oc(a,sx,this));let n={};s&&a?n.audiovideo={container:"video/mp4",codec:i+","+r,supplemental:a.supplemental,encrypted:a.encrypted,initSegment:e,id:"main"}:s?n.audio={container:"audio/mp4",codec:i,encrypted:s.encrypted,initSegment:e,id:"audio"}:a?n.video={container:"video/mp4",codec:r,supplemental:a.supplemental,encrypted:a.encrypted,initSegment:e,id:"main"}:this.warn("initSegment does not contain moov or trak boxes."),this.initTracks=n}remux(e,t,i,r,s,a){var n,l;let{initPTS:o,lastEndTime:d}=this,h={audio:void 0,video:void 0,text:r,id3:i,initSegment:void 0};se(d)||(d=this.lastEndTime=s||0);let u=t.samples;if(!u.length)return h;let c={initPTS:void 0,timescale:void 0,trackId:void 0},f=this.initData;if(null!=(n=f)&&n.length||(this.generateInitSegment(u),f=this.initData),!(null!=(l=f)&&l.length))return this.warn("Failed to generate initSegment."),h;this.emitInitSegment&&(c.tracks=this.initTracks,this.emitInitSegment=!1);let m=function(e,t,i){let r={},s=sq(e,["moof","traf"]);for(let e=0;e<s.length;e++){let a=s[e],n=sq(a,["tfhd"])[0],l=sV(n,4),o=t[l];if(!o)continue;r[l]||(r[l]={start:NaN,duration:0,sampleCount:0,timescale:o.timescale,type:o.type});let d=r[l],h=sq(a,["tfdt"])[0];if(h){let e=h[0],t=sV(h,4);1===e&&(0xffffffff===t?i.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"):(t*=0x100000000,t+=sV(h,8))),se(t)&&(!se(d.start)||t<d.start)&&(d.start=t)}let u=o.default,c=sV(n,0)|(null==u?void 0:u.flags),f=(null==u?void 0:u.duration)||0;8&c&&(f=2&c?sV(n,12):sV(n,8));let m=sq(a,["trun"]),g=d.start||0,v=0,E=f;for(let e=0;e<m.length;e++){let t=m[e],i=sV(t,4),r=d.sampleCount;d.sampleCount+=i;let s=1&t[3],a=4&t[3],n=1&t[2],l=2&t[2],o=4&t[2],h=8&t[2],u=8,c=i;for(s&&(u+=4),a&&i&&(1&t[u+1]||void 0!==d.keyFrameIndex||(d.keyFrameIndex=r),u+=4,n?(E=sV(t,u),u+=4):E=f,l&&(u+=4),h&&(u+=4),g+=E,v+=E,c--);c--;)n?(E=sV(t,u),u+=4):E=f,l&&(u+=4),o&&(1&t[u+1]||void 0!==d.keyFrameIndex||(d.keyFrameIndex=d.sampleCount-(c+1),d.keyFrameStart=g),u+=4),h&&(u+=4),g+=E,v+=E;!v&&f&&(v+=f*i)}d.duration+=v}if(!Object.keys(r).some(e=>r[e].duration)){let t=1/0,i=0,s=sq(e,["sidx"]);for(let e=0;e<s.length;e++){let r=function(e){let t=[],i=e[0],r=8,s=sV(e,8);r+=4;let a=0,n=0;0===i?(a=sV(e,r),n=sV(e,r+4),r+=8):(a=sK(e,r),n=sK(e,r+8),r+=16),r+=2;let l=e.length+n,o=sG(e,r);r+=2;
6for(let i=0;i<o;i++){let i=r,a=sV(e,i);i+=4;let n=0x7fffffff&a;if(1==(0x80000000&a)>>>31)return sA.warn("SIDX has hierarchical references (not supported)"),null;let o=sV(e,i);i+=4,t.push({referenceSize:n,subsegmentDuration:o,info:{duration:o/s,start:l,end:l+n-1}}),l+=n,i+=4,r=i}return{earliestPresentationTime:a,timescale:s,version:i,referencesCount:o,references:t}}(s[e]);if(null!=r&&r.references){t=Math.min(t,r.earliestPresentationTime/r.timescale);let e=r.references.reduce((e,t)=>e+t.info.duration||0,0);i=Math.max(i,e+r.earliestPresentationTime/r.timescale)}}i&&se(i)&&Object.keys(r).forEach(e=>{r[e].duration||(r[e].duration=i*r[e].timescale-r[e].start)})}return r}(u,f,this),g=f.audio?m[f.audio.id]:null,v=f.video?m[f.video.id]:null,E=ou(v,1/0),y=ou(g,1/0),b=ou(v,0,!0),T=ou(g,0,!0),_=s,A=0,S=g&&(!v||!o&&y<E||o&&o.trackId===f.audio.id),k=S?g:v;if(k){let e=k.timescale,t=k.start-s*e,i=S?f.audio.id:f.video.id;_=k.start/e,A=S?T-y:b-E,(a||!o)&&(function(e,t,i,r){if(null===e)return!0;let s=Math.max(r,1);return Math.abs(t-e.baseTime/e.timescale-i)>s}(o,_,s,A)||e!==o.timescale)&&(o&&this.warn(`Timestamps at playlist time: ${a?"":"~"}${s} ${t/e} != initPTS: ${o.baseTime/o.timescale} (${o.baseTime}/${o.timescale}) trackId: ${o.trackId}`),this.log(`Found initPTS at playlist time: ${s} offset: ${_-s} (${t}/${e}) trackId: ${i}`),o=null,c.initPTS=t,c.timescale=e,c.trackId=i)}else this.warn(`No audio or video samples found for initPTS at playlist time: ${s}`);o?(c.initPTS=o.baseTime,c.timescale=o.timescale,c.trackId=o.trackId):(c.timescale&&void 0!==c.trackId&&void 0!==c.initPTS||(this.warn("Could not set initPTS"),c.initPTS=_,c.timescale=1,c.trackId=-1),this.initPTS=o={baseTime:c.initPTS,timescale:c.timescale,trackId:c.trackId});let L=_-o.baseTime/o.timescale,R=L+A;A>0?this.lastEndTime=R:(this.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());let I=!!f.audio,w=!!f.video,D="";I&&(D+="audio"),w&&(D+="video");let C={data1:u,startPTS:L,startDTS:L,endPTS:R,endDTS:R,type:D,hasAudio:I,hasVideo:w,nb:1,dropped:0,encrypted:!!f.audio&&f.audio.encrypted||!!f.video&&f.video.encrypted};h.audio=I&&!w?C:void 0,h.video=w?C:void 0;let P=null==v?void 0:v.sampleCount;if(P){let e=v.keyFrameIndex,t=-1!==e;C.nb=P,C.dropped=0===e||this.isVideoContiguous?0:t?e:P,C.independent=t,C.firstKeyFrame=e,t&&v.keyFrameStart&&(C.firstKeyFramePTS=(v.keyFrameStart-o.baseTime)/o.timescale),this.isVideoContiguous||(h.independent=t),this.isVideoContiguous||(this.isVideoContiguous=t),C.dropped&&this.warn(`fmp4 does not start with IDR: firstIDR ${e}/${P} dropped: ${C.dropped} start: ${C.firstKeyFramePTS||"NA"}`)}return h.initSegment=c,h.id3=od(i,s,o,o),r.samples.length&&(h.text=oh(r,s,o)),h}}},{demux:l4,remux:ol},{demux:class extends lU{constructor(e,t){super(),this.observer=void 0,this.config=void 0,this.observer=e,this.config=t}resetInitSegment(e,t,i,r){super.resetInitSegment(e,t,i,r),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:r,inputTimeScale:9e4,dropped:0}}static probe(e,t){if(!e)return!1;let i=lS(e,0),r=(null==i?void 0:i.length)||0;if(lY(e,r))return!1;for(let i=e.length;r<i;r++)if(function(e,t){if(lI(e,t)){let i=lL(e,t);if(t+i>=e.length)return!1;let r=lR(e,t);if(r<=i)return!1;let s=t+r;return s===e.length||lI(e,s)}return!1}(e,r))return t.log("ADTS sync word found !"),!0;return!1}canParse(e,t){return t+5<e.length&&lk(e,t)&&lR(e,t)<=e.length-t}appendFrame(e,t,i){lw(e,this.observer,t,i,e.manifestCodec);let r=lD(e,t,i,this.basePTS,this.frameIndex);if(r&&0===r.missing)return r}},remux:ol},{demux:class extends lU{resetInitSegment(e,t,i,r){super.resetInitSegment(e,t,i,r),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:r,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;let t=lS(e,0),i=(null==t?void 0:t.length)||0;if(t&&11===e[i]&&119===e[i+1]&&void 0!==lM(t)&&16>=lQ(e,i))return!1;for(let t=e.length;i<t;i++)if(lY(e,i))return sA.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return lq(e,t)&&4<=e.length-t}appendFrame(e,t,i){if(null!==this.basePTS)return lK(e,t,i,this.basePTS,this.frameIndex)}},remux:ol}];of.splice(2,0,{demux:class extends lU{constructor(e){super(),this.observer=void 0,this.observer=e}resetInitSegment(e,t,i,r){super.resetInitSegment(e,t,i,r),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:t,duration:r,inputTimeScale:9e4,dropped:0}}canParse(e,t){return t+64<e.length}appendFrame(e,t,i){let r=lz(e,t,i,this.basePTS,this.frameIndex);if(-1!==r)return{sample:e.samples[e.samples.length-1],length:r,missing:0}}static probe(e){if(!e)return!1;let t=lS(e,0);if(!t)return!1;let i=t.length;return!!(11===e[i]&&119===e[i+1]&&void 0!==lM(t)&&16>lQ(e,i))}},remux:ol});class om{constructor(e,t,i,r,s,a){this.asyncResult=!1,this.logger=void 0,this.observer=void 0,this.typeSupp
6orted=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=e,this.typeSupported=t,this.config=i,this.id=s,this.logger=a}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(e,i,r,s){var a,n;let l,o=r.transmuxing;o.executeStart=t();let d=new Uint8Array(e),{currentTransmuxState:h,transmuxConfig:u}=this;s&&(this.currentTransmuxState=s);let{contiguous:c,discontinuity:f,trackSwitch:m,accurateTimeOffset:g,timeOffset:v,initSegmentChange:E}=s||h,{audioCodec:y,videoCodec:b,defaultInitPts:T,duration:_,initSegmentData:A}=u,S=(a=d,n=i,l=null,a.byteLength>0&&(null==n?void 0:n.key)!=null&&null!==n.iv&&null!=n.method&&(l=n),l);if(S&&no(S.method)){let e=this.getDecrypter(),i=nd(S.method);if(!e.isSync())return this.asyncResult=!0,this.decryptionPromise=e.webCryptoDecrypt(d,S.key.buffer,S.iv.buffer,i).then(e=>{let t=this.push(e,null,r);return this.decryptionPromise=null,t}),this.decryptionPromise;{let s=e.softwareDecrypt(d,S.key.buffer,S.iv.buffer,i);if(r.part>-1){let t=e.flush();s=t?t.buffer:t}if(!s)return o.executeEnd=t(),op(r);d=new Uint8Array(s)}}let k=this.needsProbing(f,m);if(k){let e=this.configureTransmuxer(d);if(e)return this.logger.warn(`[transmuxer] ${e.message}`),this.observer.emit(sa.ERROR,sa.ERROR,{type:sr.MEDIA_ERROR,details:ss.FRAG_PARSING_ERROR,fatal:!1,error:e,reason:e.message}),o.executeEnd=t(),op(r)}(f||m||E||k)&&this.resetInitSegment(A,y,b,_,i),(f||E||k)&&this.resetInitialTimestamp(T),c||this.resetContiguity();let L=this.transmux(d,S,v,g,r);this.asyncResult=og(L);let R=this.currentTransmuxState;return R.contiguous=!0,R.discontinuity=!1,R.trackSwitch=!1,o.executeEnd=t(),L}flush(e){let i=e.transmuxing;i.executeStart=t();let{decrypter:r,currentTransmuxState:s,decryptionPromise:a}=this;if(a)return this.asyncResult=!0,a.then(()=>this.flush(e));let n=[],{timeOffset:l}=s;if(r){let t=r.flush();t&&n.push(this.push(t.buffer,null,e))}let{demuxer:o,remuxer:d}=this;if(!o||!d){i.executeEnd=t();let r=[op(e)];return this.asyncResult?Promise.resolve(r):r}let h=o.flush(l);return og(h)?(this.asyncResult=!0,h.then(t=>(this.flushRemux(n,t,e),n))):(this.flushRemux(n,h,e),this.asyncResult)?Promise.resolve(n):n}flushRemux(e,i,r){let{audioTrack:s,videoTrack:a,id3Track:n,textTrack:l}=i,{accurateTimeOffset:o,timeOffset:d}=this.currentTransmuxState;this.logger.log(`[transmuxer.ts]: Flushed ${this.id} sn: ${r.sn}${r.part>-1?" part: "+r.part:""} of ${this.id===sh?"level":"track"} ${r.level}`);let h=this.remuxer.remux(s,a,n,l,d,o,!0,this.id);e.push({remuxResult:h,chunkMeta:r}),r.transmuxing.executeEnd=t()}resetInitialTimestamp(e){let{demuxer:t,remuxer:i}=this;t&&i&&(t.resetTimeStamp(e),i.resetTimeStamp(e))}resetContiguity(){let{demuxer:e,remuxer:t}=this;e&&t&&(e.resetContiguity(),t.resetNextTimestamp())}resetInitSegment(e,t,i,r,s){let{demuxer:a,remuxer:n}=this;a&&n&&(a.resetInitSegment(e,t,i,r),n.resetInitSegment(e,t,i,s))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(e,t,i,r,s){return t&&"SAMPLE-AES"===t.method?this.transmuxSampleAes(e,t,i,r,s):this.transmuxUnencrypted(e,i,r,s)}transmuxUnencrypted(e,t,i,r){let{audioTrack:s,videoTrack:a,id3Track:n,textTrack:l}=this.demuxer.demux(e,t,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(s,a,n,l,t,i,!1,this.id),chunkMeta:r}}transmuxSampleAes(e,t,i,r,s){return this.demuxer.demuxSampleAes(e,t,i).then(e=>({remuxResult:this.remuxer.remux(e.audioTrack,e.videoTrack,e.id3Track,e.textTrack,i,r,!1,this.id),chunkMeta:s}))}
6configureTransmuxer(e){let t,{config:i,observer:r,typeSupported:s}=this;for(let i=0,r=of.length;i<r;i++){var a;if(null!=(a=of[i].demux)&&a.probe(e,this.logger)){t=of[i];break}}if(!t)return Error("Failed to find demuxer by probing fragment data");let n=this.demuxer,l=this.remuxer,o=t.remux,d=t.demux;l&&l instanceof o||(this.remuxer=new o(r,i,s,this.logger)),n&&n instanceof d||(this.demuxer=new d(r,i,s,this.logger),this.probe=d.probe)}needsProbing(e,t){return!this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new aZ(this.config)),e}}let op=e=>({remuxResult:{},chunkMeta:e});function og(e){return"then"in e&&e.then instanceof Function}class ov{constructor(e,t,i,r,s){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=e,this.videoCodec=t,this.initSegmentData=i,this.duration=r,this.defaultInitPts=s||null}}class oE{constructor(e,t,i,r,s,a){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=e,this.contiguous=t,this.accurateTimeOffset=i,this.trackSwitch=r,this.timeOffset=s,this.initSegmentChange=a}}let oy=0;class ob{constructor(e,t,i,r){this.error=null,this.hls=void 0,this.id=void 0,this.instanceNo=oy++,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=>{let t=e.data,i=this.hls;if(i&&null!=t&&t.event&&t.instanceNo===this.instanceNo)switch(t.event){case"init":{var r;let e=null==(r=this.workerContext)?void 0:r.objectURL;e&&self.URL.revokeObjectURL(e);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)return;let t=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(sa.ERROR,{type:sr.OTHER_ERROR,details:ss.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:t})};const s=e.config;this.hls=e,this.id=t,this.useWorker=!!s.enableWorker,this.onTransmuxComplete=i,this.onFlush=r;const a=(e,t)=>{(t=t||{}).frag=this.frag||void 0,e===sa.ERROR&&(t.parent=this.id,t.part=this.part,this.error=t.error),this.hls.trigger(e,t)};this.observer=new lE,this.observer.on(sa.FRAG_DECRYPTED,a),this.observer.on(sa.ERROR,a);const n=al(s.preferManagedMediaSource);if(this.useWorker&&"u">typeof Worker){const i=this.hls.logger;if(s.workerPath||"function"==typeof __HLS_WORKER_BUNDLE__){try{s.workerPath?(i.log(`loading Web Worker ${s.workerPath} for "${t}"`),this.workerContext=function(e){let t=lb[e];if(t)return t.clientCount++,t;let i=new self.URL(e,self.location.href).href,r={worker:new self.Worker(i),scriptURL:i,clientCount:1};return lb[e]=r,r}(s.workerPath)):(i.log(`injecting Web Worker for "${t}"`),this.workerContext=function(){let e=lb[ly];if(e)return e.clientCount++,e;let 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),r={worker:new self.Worker(i),objectURL:i,clientCount:1};return lb[ly]=r,r}());const{worker:e}=this.workerContext;e.addEventListener("message",this.onWorkerMessage),e.addEventListener("error",this.onWorkerError),e.postMessage({instanceNo:this.instanceNo,cmd:"init",typeSupported:n,id:t,config:ab(s)})}catch(r){i.warn(`Error setting up "${t}" Web Worker, fallback to inline`,r),this.terminateWorker(),this.error=null,this.transmuxer=new om(this.observer,n,s,"",t,e.logger)}return}}this.transmuxer=new om(this.observer,n,s,"",t,e.logger)}reset(){if(this.frag=null,this.part=null,this.workerContext){let e=this.instanceNo;this.instanceNo=oy++;let t=this.hls.config,i=al(t.preferManagedMediaSource);this.workerContext.worker.postMessage({instanceNo:this.instanceNo,cmd:"reset",resetNo:e,typeSupp
6orted:i,id:this.id,config:ab(t)})}}terminateWorker(){if(this.workerContext){let{worker:e}=this.workerContext;this.workerContext=null,e.removeEventListener("message",this.onWorkerMessage),e.removeEventListener("error",this.onWorkerError),function(e){let t=lb[e||ly];if(t&&1==t.clientCount--){let{worker:i,objectURL:r}=t;delete lb[e||ly],r&&self.URL.revokeObjectURL(r),i.terminate()}}(this.hls.config.workerPath)}}destroy(){if(this.workerContext)this.terminateWorker(),this.onWorkerMessage=this.onWorkerError=null;else{let e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}let e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.part=null,this.observer=null,this.hls=null}push(e,t,i,r,s,a,n,l,o,d){var h,u;o.transmuxing.start=self.performance.now();let{instanceNo:c,transmuxer:f}=this,m=a?a.start:s.start,g=s.decryptdata,v=this.frag,E=!(v&&s.cc===v.cc),y=!(v&&o.level===v.level),b=v?o.sn-v.sn:-1,T=this.part?o.part-this.part.index:-1,_=0===b&&o.id>1&&o.id===(null==v?void 0:v.stats.chunkCount),A=!y&&(1===b||0===b&&(1===T||_&&T<=0)),S=self.performance.now();(y||b||0===s.stats.parsing.start)&&(s.stats.parsing.start=S),a&&(T||!A)&&(a.stats.parsing.start=S);let k=!(v&&(null==(h=s.initSegment)?void 0:h.url)===(null==(u=v.initSegment)?void 0:u.url)),L=new oE(E,A,l,y,m,k);if(!A||E||k){this.hls.logger.log(`[transmuxer-interface]: Starting new transmux session for ${s.type} sn: ${o.sn}${o.part>-1?" part: "+o.part:""} ${this.id===sh?"level":"track"}: ${o.level} id: ${o.id}
7        discontinuity: ${E}
8        trackSwitch: ${y}
9        contiguous: ${A}
10        accurateTimeOffset: ${l}
11        timeOffset: ${m}
12        initSegmentChange: ${k}`);let e=new ov(i,r,t,n,d);this.configureTransmuxer(e)}if(this.frag=s,this.part=a,this.workerContext)this.workerContext.worker.postMessage({instanceNo:c,cmd:"demux",data:e,decryptdata:g,chunkMeta:o,state:L},e instanceof ArrayBuffer?[e]:[]);else if(f){let t=f.push(e,g,o,L);og(t)?t.then(e=>{this.handleTransmuxComplete(e)}).catch(e=>{this.transmuxerError(e,o,"transmuxer-interface push error")}):this.handleTransmuxComplete(t)}}flush(e){e.transmuxing.start=self.performance.now();let{instanceNo:t,transmuxer:i}=this;if(this.workerContext)this.workerContext.worker.postMessage({instanceNo:t,cmd:"flush",chunkMeta:e});else if(i){let t=i.flush(e);og(t)?t.then(t=>{this.handleFlushResult(t,e)}).catch(t=>{this.transmuxerError(t,e,"transmuxer-interface flush error")}):this.handleFlushResult(t,e)}}transmuxerError(e,t,i){this.hls&&(this.error=e,this.hls.trigger(sa.ERROR,{type:sr.MEDIA_ERROR,details:ss.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,part:this.part||void 0,fatal:!1,error:e,err:e,reason:i}))}handleFlushResult(e,t){e.forEach(e=>{this.handleTransmuxComplete(e)}),this.onFlush(t)}configureTransmuxer(e){let{instanceNo:t,transmuxer:i}=this;this.workerContext?this.workerContext.worker.postMessage({instanceNo:t,cmd:"configure",config:e}):i&&i.configure(e)}handleTransmuxComplete(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}}class oT extends sE{constructor(e,t){super(t,e.logger),this.hls=void 0,this.canLoad=!1,this.timer=-1,this.hls=e}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){-1!==this.timer&&(self.clearTimeout(this.timer),this.timer=-1)}startLoad(){this.canLoad=!0,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(e,t,i){let r=null==t?void 0:t.renditionReports;if(r){let s=-1;for(let i=0;i<r.length;i++){let a,n=r[i];try{a=new self.URL(n.URI,t.url).href}catch(e){this.warn(`Could not construct new URL for Rendition Report: ${e}`),a=n.URI||""}if(a===e){s=i;break}a===e.substring(0,a.length)&&(s=i)}if(-1!==s){let e=r[s],a=parseInt(e["LAST-MSN"])||t.lastPartSn,n=parseInt(e["LAST-PART"])||t.lastPartIndex;if(this.hls.config.lowLatencyMode){let e=Math.min(t.age-t.partTarget,t.targetduration);n>=0&&e>t.partTarget&&(n+=1)}return new av(a,n>=0?n:void 0,i&&ag(i))}}}loadPlaylist(e){this.clearTimer()}loadingPlaylist(e,t){this.clearTimer()}shouldLoadPlaylist(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}getUrlWithDirectives(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}playlistLoaded(e,t,i){let{details:r,stats:s}=t,a=self.performance.now(),n=s.loading.first?Math.max(0,a-s.loading.first):0;r.advancedDateTime=Date.now()-n;let l=this.hls.config.timelineOffset;
12if(l!==r.appliedTimelineOffset){let e=Math.max(l||0,0);r.appliedTimelineOffset=e,r.fragments.forEach(t=>{t.setStart(t.playlistOffset+e)})}if(r.live||null!=i&&i.live){let l,d,h,u="levelInfo"in t?t.levelInfo:t.track;if(r.reloaded(i),i&&r.fragments.length>0){!function(e,t,i){let r;if(e===t)return;let s=null,a=e.fragments;for(let e=a.length-1;e>=0;e--){let t=a[e].initSegment;if(t){s=t;break}}e.fragmentHint&&delete e.fragmentHint.endPTS,function(e,t,i){let r=t.skippedSegments,s=Math.max(e.startSN,t.startSN)-t.startSN,a=+!!e.fragmentHint+(r?t.endSN:Math.min(e.endSN,t.endSN))-t.startSN,n=t.startSN-e.startSN,l=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,o=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments;for(let u=s;u<=a;u++){let s=o[n+u],a=l[u];if(r&&!a&&s&&(a=t.fragments[u]=s),s&&a){var d,h;i(s,a,u,l);let r=s.relurl,n=a.relurl;if(r&&(d=r)!==(h=n)&&h&&n3(d)!==n3(h)){t.playlistParsingError=nQ(`media sequence mismatch ${a.sn}:`,e,t,s,a);return}if(s.cc!==a.cc){t.playlistParsingError=nQ(`discontinuity sequence mismatch (${s.cc}!=${a.cc})`,e,t,s,a);return}}}}(e,t,(e,i,a,n)=>{if((!t.startCC||t.skippedSegments)&&i.cc!==e.cc){let r=e.cc-i.cc;for(let e=a;e<n.length;e++)n[e].cc+=r;t.endCC=n[n.length-1].cc}se(e.startPTS)&&se(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&&(r=i),t.PTSKnown=t.alignedSliding=!0),e.hasStream
12s&&(i.elementaryStreams=e.elementaryStreams),i.loader=e.loader,e.hasStats&&(i.stats=e.stats),e.initSegment&&(i.initSegment=e.initSegment,s=e.initSegment)});let n=t.fragments,l=t.fragmentHint?n.concat(t.fragmentHint):n;if(s&&l.forEach(e=>{var t;e&&(!e.initSegment||e.initSegment.relurl===(null==(t=s)?void 0:t.relurl))&&(e.initSegment=s)}),t.skippedSegments){if(t.deltaUpdateFailed=n.some(e=>!e),t.deltaUpdateFailed){i.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let e=t.skippedSegments;e--;)n.shift();t.startSN=n[0].sn}else{t.canSkipDateRanges&&(t.dateRanges=function(e,t,i){let{dateRanges:r,recentlyRemovedDateranges:s}=t,a=sp({},e);s&&s.forEach(e=>{delete a[e]});let n=Object.keys(a).length;return n?(Object.keys(r).forEach(e=>{let t=a[e],s=new ns(r[e].attr,t);s.isValid?(a[e]=s,t||(s.tagOrder+=n)):i.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${ab(r[e].attr)}"`)}),a):r}(e.dateRanges,t,i));let r=e.fragments.filter(e=>e.rawProgramDateTime);if(e.hasProgramDateTime&&!t.hasProgramDateTime)for(let e=1;e<l.length;e++)null===l[e].programDateTime&&nG(l[e],l[e-1],r);nU(r,t)}t.endCC=n[n.length-1].cc}if(!t.startCC){var o;let i=nJ(e,t.startSN-1);t.startCC=null!=(o=null==i?void 0:i.cc)?o:n[0].cc}(function(e,t,i){if(e&&t){let r=0;for(let s=0,a=e.length;s<=a;s++){let a=e[s],n=t[s+r];a&&n&&a.index===n.index&&a.fragment.sn===n.fragment.sn?i(a,n):r--}}})(e.partList,t.partList,(e,t)=>{t.elementaryStreams=e.elementaryStreams,t.stats=e.stats}),r?nY(t,r,r.startPTS,r.endPTS,r.startDTS,r.endDTS,i):nz(e,t),n.length&&(t.totalduration=t.edge-n[0].start),t.driftStartTime=e.driftStartTime,t.driftStart=e.driftStart;let d=t.advancedDateTime;if(t.advanced&&d){let e=t.edge;t.driftStart||(t.driftStartTime=d,t.driftStart=e),t.driftEndTime=d,t.driftEnd=e}else t.driftEndTime=e.driftEndTime,t.driftEnd=e.driftEnd,t.advancedDateTime=e.advancedDateTime;-1===t.requestScheduled&&(t.requestScheduled=e.requestScheduled)}(i,r,this);let e=r.playlistParsingError;if(e){this.warn(e);let i=this.hls;if(!i.config.ignorePlaylistParsingErrors){var o;let{networkDetails:a}=t;i.trigger(sa.ERROR,{type:sr.NETWORK_ERROR,details:ss.LEVEL_PARSING_ERROR,fatal:!1,url:r.url,error:e,reason:e.message,level:t.level||void 0,parent:null==(o=r.fragments[0])?void 0:o.type,networkDetails:a,stats:s});return}r.playlistParsingError=null}}-1===r.requestScheduled&&(r.requestScheduled=s.loading.start);let c=this.hls.mainForwardBufferInfo,f=c?c.end-c.len:0,m=(r.edge-f)*1e3,g=nZ(r,m);if(r.requestScheduled+g<a?r.requestScheduled=a:r.requestScheduled+=g,this.log(`live playlist ${e} ${r.advanced?"REFRESHED "+r.lastPartSn+"-"+r.lastPartIndex:r.updated?"UPDATED":"MISSED"}`),!this.canLoad||!r.live)return;if(r.canBlockReload&&r.endSN&&r.advanced){let e=this.hls.config.lowLatencyMode,s=r.lastPartSn,n=r.endSN,o=r.lastPartIndex,c=s===n;-1!==o?c?(d=n+1,h=e?0:o):(d=s,h=e?o+1:r.maxPartIndex):d=n+1;let f=r.age,m=f+r.ageHeader,g=Math.min(m-r.partTarget,1.5*r.targetduration);if(g>0){if(m>3*r.targetduration)this.log(`Playlist last advanced ${f.toFixed(2)}s ago. Omitting segment and part directives.`),d=void 0,h=void 0;else if(null!=i&&i.tuneInGoal&&m-r.partTarget>i.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${i.tuneInGoal} to: ${g} with playlist age: ${r.age}`),g=0;else{let e=Math.floor(g/r.targetduration);d+=e,void 0!==h&&(h+=Math.round(g%r.targetduration/r.partTarget)),this.log(`CDN Tune-in age: ${r.ageHeader}s last advanced ${f.toFixed(2)}s goal: ${g} skip sn ${e} to part ${h}`)}r.tuneInGoal=g}if(l=this.getDeliveryDirectives(r,t.deliveryDirectives,d,h),e||!c){r.requestScheduled=a,this.loadingPlaylist(u,l);return}}else(r.canBlockReload||r.canSkipUntil)&&(l=this.getDeliveryDirectives(r,t.deliveryDirectives,d,h));l&&void 0!==d&&r.canBlockReload&&(r.requestScheduled=s.loading.first+Math.max(g-2*n,g/2)),this.scheduleLoading(u,l,r)}else this.clearTimer()}scheduleLoading(e,t,i){let r=i||e.details;if(!r)return void this.loadingPlaylist(e,t);let s=self.performance.now(),a=r.requestScheduled;if(s>=a)return void this.loadingPlaylist(e,t);let n=a-s;this.log(`reload live playlist ${e.name||e.bitrate+"bps"} in ${Math.round(n)} ms`),this.clearTimer(),this.timer=self.setTimeout(()=>this.loadingPlaylist(e,t),n)}getDeliveryDirectives(e,t,i,r){let s=ag(e);return null!=t&&t.skip&&e.deltaUpdateFailed&&(i=t.msn,r=t.part,s=""),new av(i,r,s)}checkRetry(e){let t=e.details,i=ax(e),r=e.errorAction,{action:s,retryCount:a=0,retryConfig:n}=r||{},l=!!r&&!!n&&(5===s||!r.resolved&&2===s);if(l){var o;if(a>=n.maxNumRetry)return!1;if(i&&null!=(o=e.context)&&o.deliveryDirectives)this.warn(`Retrying playlist loading ${a+1}/${n.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{let e=aU(n,a);this.clearTimer(),this.timer=self.setTimeout(()=>this.loadPlaylist(),e),this.warn(`Retrying playlist loading ${a+1}/${n.maxNumRetry} after "${t}" in ${e}ms`)}e.levelRetry=!0,r.resolved=!0}return l}}function o_(e,t){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!oA(e[i].attrs,t[i].attrs))return!1;return!0}function oA(e,t,i){let r=e["STABLE-RENDITION-ID"];return r&&!i?r===t["STABLE-RENDITION-ID"]:!(i||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).some(i=>e[i]!==t[i])}function oS(e,t){return t.label.toLowerCase()===e.name.toLowerCase()&&(!t.language||t.language.toLowerCase()===(e.lang||"").toLowerCase())}class ok{constructor(e){this.tracks=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.tracks=e}destroy(){this.tracks=this.queues=null}append(e,t,i){if(null===this.queues||null===this.tracks)return;let r=this.queues[t];r.push(e),1!==r.length||i||this.executeNext(t)}appendBlocker(e){return new Promise(t=>{this.append({label:"async-blocker",execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}},e)})}prependBlocker(e){return new Promise(t=>{this.queues&&this.queues[e].unshift({label:"async-blocker-prepend",execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}})})}removeBlockers(){null!==this.queues&&[this.queues.video,this.queues.audio,this.queues.audiovideo].forEac
12h(e=>{var t;let i=null==(t=e[0])?void 0:t.label;("async-blocker"===i||"async-blocker-prepend"===i)&&(e[0].execute(),e.splice(0,1))})}unblockAudio(e){null===this.queues||this.queues.audio[0]===e&&this.shiftAndExecuteNext("audio")}executeNext(e){if(null===this.queues||null===this.tracks)return;let t=this.queues[e];if(t.length){let r=t[0];try{r.execute()}catch(s){var i;if(r.onError(s),null===this.queues||null===this.tracks)return;let t=null==(i=this.tracks[e])?void 0:i.buffer;null!=t&&t.updating||this.shiftAndExecuteNext(e)}}}shiftAndExecuteNext(e){null!==this.queues&&(this.queues[e].shift(),this.executeNext(e))}current(e){var t;return(null==(t=this.queues)?void 0:t[e][0])||null}toString(){let{queues:e,tracks:t}=this;return null===e||null===t?"<destroyed>":`
13${this.list("video")}
14${this.list("audio")}
15${this.list("audiovideo")}}`}list(e){var t,i;return null!=(t=this.queues)&&t[e]||null!=(i=this.tracks)&&i[e]?`${e}: (${this.listSbInfo(e)}) ${this.listOps(e)}`:""}listSbInfo(e){var t;let i=null==(t=this.tracks)?void 0:t[e],r=null==i?void 0:i.buffer;return r?`SourceBuffer${r.updating?" updating":""}${i.ended?" ended":""}${i.ending?" ending":""}`:"none"}listOps(e){var t;return(null==(t=this.queues)?void 0:t[e].map(e=>e.label).join(", "))||""}}let oL=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,oR="HlsJsTrackRemovedError";class oI extends Error{constructor(e){super(e),this.name=oR}}function ow(e){let t=e.querySelectorAll("source");[].slice.call(t).forEach(t=>{e.removeChild(t)})}function oD(e){return+("audio"===e)}class oC{constructor(e){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=e,this.autoLevelCapping=1/0,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}setStreamController(e){this.streamController=e}destroy(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){let{hls:e}=this;e.on(sa.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(sa.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(sa.MANIFEST_PARSED,this.onManifestParsed,this),e.on(sa.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(sa.BUFFER_CODECS,this.onBufferCodecs,this),e.on(sa.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){let{hls:e}=this;e.off(sa.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(sa.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(sa.MANIFEST_PARSED,this.onManifestParsed,this),e.off(sa.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(sa.BUFFER_CODECS,this.onBufferCodecs,this),e.off(sa.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(e,t){let i=this.hls.levels[t.droppedLevel];this.isLevelAllowed(i)&&this.restrictedLevels.push({bitrate:i.bitrate,height:i.height,width:i.width})}onMediaAttaching(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()}onManifestParsed(e,t){let i=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,i.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onLevelsUpdated(e,t){this.timer&&se(this.autoLevelCapping)&&this.detectPlayerSize()}onBufferCodecs(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onMediaDetaching(){this.stopCapping(),this.media=null}detectPlayerSize(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0){this.clientRect=null;return}let e=this.hls.levels;if(e.length){let 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}}}getMaxLevel(e){let t=this.hls.levels;if(!t.length)return -1;let i=t.filter((t,i)=>this.isLevelAllowed(t)&&i<=e);return this.clientRect=null,oC.getMaxLevelByMediaSize(i,this.mediaWidth,this.mediaHeight)}startCapping(){this.timer||(this.autoLevelCapping=1/0,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())}stopCapping(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=1/0,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)}getDimensions(){if(this.clientRect)return this.clientRect;let e=this.media,t={width:0,height:0};if(e){let i=e.getBoundingClientRect();t.width=i.width,t.height=i.height,t.width||t.height||(t.width=i.right-i.left||e.
15width||0,t.height=i.bottom-i.top||e.height||0)}return this.clientRect=t,t}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch(e){}return Math.min(e,this.hls.config.maxDevicePixelRatio)}isLevelAllowed(e){return!this.restrictedLevels.some(t=>e.bitrate===t.bitrate&&e.width===t.width&&e.height===t.height)}static getMaxLevelByMediaSize(e,t,i){if(!(null!=e&&e.length))return -1;let r=(e,t)=>!t||e.width!==t.width||e.height!==t.height,s=e.length-1,a=Math.max(t,i);for(let t=0;t<e.length;t+=1){let i=e[t];if((i.width>=a||i.height>=a)&&r(i,e[t+1])){s=t;break}}return s}}class oP{constructor(e,t){Array.isArray(e)&&(e=e.map(e=>e instanceof oP?e:new oP(e))),this.value=e,this.params=t}}function ox(e,t,i){return Error(`failed to serialize "${Array.isArray(e)?JSON.stringify(e):e instanceof Map?"Map{}":e instanceof Set?"Set{}":"object"==typeof e?JSON.stringify(e):String(e)}" as ${t}`,{cause:i})}class oM{constructor(e){this.description=e}}let oO="Bare Item";function oN(e){if(e<-0x38d7ea4c67fff||0x38d7ea4c67fff<e)throw ox(e,"Integer");return e.toString()}let oU=/[\x00-\x1f\x7f]+/;function oF(e){let t=e.description||e.toString().slice(7,-1);if(!1===/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(t))throw ox(t,"Token");return t}function o$(e){switch(typeof e){case"number":if(!se(e))throw ox(e,oO);if(Number.isInteger(e))return oN(e);let t=function e(t,i){if(t<0)return-e(-t,i);let r=Math.pow(10,i);if(!(Math.abs(t*r%1-.5)<Number.EPSILON))return Math.round(t*r)/r;{let e=Math.floor(t*r);return(e%2==0?e:e+1)/r}}(e,3);if(Math.floor(Math.abs(t)).toString().length>12)throw ox(e,"Decimal");let i=t.toString();return i.includes(".")?i:`${i}.0`;case"string":if(oU.test(e))throw ox(e,"String");return`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`;case"symbol":return oF(e);case"boolean":if("boolean"!=typeof e)throw ox(e,"Boolean");return e?"?1":"?0";case"object":if(e instanceof Date)return`@${oN(e.getTime()/1e3)}`;if(e instanceof Uint8Array){if(!1===ArrayBuffer.isView(e))throw ox(e,"Byte Sequence");return`:${btoa(String.fromCharCode(...e))}:`}if(e instanceof oM)return oF(e);default:throw ox(e,oO)}}function oB(e){if(!1===/^[a-z*][a-z0-9\-_.*]*$/.test(e))throw ox(e,"Key");return e}function oH(e){return null==e?"":Object.entries(e).map(([e,t])=>!0===t?`;${oB(e)}`:`;${oB(e)}=${o$(t)}`).join("")}function oG(e){return e instanceof oP?`${o$(e.value)}${oH(e.params)}`:o$(e)}function oV(e,t){return function(e,t={whitespace:!0}){if("object"!=typeof e||null==e)throw ox(e,"Dict");let i=e instanceof Map?e.entries():Object.entries(e),r=(null==t?void 0:t.whitespace)?" ":"";return Array.from(i).map(([e,t])=>{t instanceof oP==!1&&(t=new oP(t));let i=oB(e);if(!0===t.value)i+=oH(t.params);else if(i+="=",Array.isArray(t.value)){var r;i+=(r=t,`(${r.value.map(oG).join(" ")})${oH(r.params)}`)}else i+=oG(t);return i}).join(`,${r}`)}(e,t)}let oK="CMCD-Object",oW="CMCD-Request",oq="CMCD-Session",oj="CMCD-Status",oY={br:oK,ab:oK,d:oK,ot:oK,tb:oK,tpb:oK,lb:oK,tab:oK,lab:oK,url:oK,pb:oW,bl:oW,tbl:oW,dl:oW,ltc:oW,mtp:oW,nor:oW,nrr:oW,rc:oW,sn:oW,sta:oW,su:oW,ttfb:oW,ttfbb:oW,ttlb:oW,cmsdd:oW,cmsds:oW,smrt:oW,df:oW,cs:oW,ts:oW,cid:oq,pr:oq,sf:oq,sid:oq,st:oq,v:oq,msd:oq,bs:oj,bsd:oj,cdn:oj,rtp:oj,bg:oj,pt:oj,ec:oj,e:oj},oQ="event",oz=e=>Math.round(e),oX=(e,t)=>Array.isArray(e)?e.map(e=>oX(e,t)):e instanceof oP&&"string"==typeof e.value?new oP(oX(e.value,t),e.params):(t.baseUrl&&(e=function(e,t){let i=new URL(e),r=new URL(t);if(i.origin!==r.origin)return e;let s=i.pathname.split("/").slice(1),a=r.pathname.split("/").slice(1,-1);for(;s[0]===a[0];)s.shift(),a.shift();for(;a.length;)a.shift(),s.unshift("..");return s.join("/")+i.search+i.hash}(e,t.baseUrl)),1===t.version?encodeURIComponent(e):e),oZ=e=>100*oz(e/100),oJ={br:oz,d:oz,bl:oZ,dl:oZ,mtp:oZ,nor:(e,t)=>{let i=e;return t.version>=2&&(e instanceof oP&&"string"==typeof e.value?i=new oP([e]):"string"==typeof e&&(i=[e])),oX(i,t)},rtp:oZ,tb:oz}
15,o0="request",o1="response",o2=["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"],o3=["e"],o4=/^[a-zA-Z0-9-.]+-[a-zA-Z0-9-.]+$/;function o5(e){return o4.test(e)}let o8=["d","dl","nor","ot","rtp","su"],o6=["cmsdd","cmsds","rc","smrt","ttfb","ttfbb","ttlb","url"],o9=["bl","br","bs","cid","d","dl","mtp","nor","nrr","ot","pr","rtp","sf","sid","st","su","tb","v"];function o7(e){return o9.includes(e)||o5(e)}let de={[o1]:function(e){return o2.includes(e)||o8.includes(e)||o6.includes(e)||o5(e)},[oQ]:function(e){return o2.includes(e)||o3.includes(e)||o5(e)},[o0]:function(e){return o2.includes(e)||o8.includes(e)||o5(e)}};function dt(e,t={}){let i={};if(null==e||"object"!=typeof e)return i;let r=t.version||e.v||1,s=t.reportingMode||o0,a=1===r?o7:de[s],n=Object.keys(e).filter(a),l=t.filter;"function"==typeof l&&(n=n.filter(l));let o=s===o1||s===oQ;o&&!n.includes("ts")&&n.push("ts"),r>1&&!n.includes("v")&&n.push("v");let d=sp({},oJ,t.formatters),h={version:r,reportingMode:s,baseUrl:t.baseUrl};return n.sort().forEach(t=>{var s;let a=e[t],n=d[t];if("function"==typeof n&&(a=n(a,h)),"v"===t)if(1===r)return;else a=r;("pr"!=t||1!==a)&&(o&&"ts"===t&&!se(a)&&(a=Date.now()),("number"==typeof(s=a)?se(s):null!=s&&""!==s&&!1!==s)&&(["ot","sf","st","e","sta"].includes(t)&&"string"==typeof a&&(a=new oM(a)),i[t]=a))}),i}let di=/CMCD=[^&#]+/;function dr(e,t,i,r){e&&Object.keys(t).forEach(s=>{let a=e.filter(e=>e.groupId===s).map(e=>{let a=sp({},e);return a.details=void 0,a.attrs=new nr(a.attrs),a.url=a.attrs.URI=ds(e.url,e.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",i),a.groupId=a.attrs["GROUP-ID"]=t[s],a.attrs["PATHWAY-ID"]=r,a});e.push(...a)})}function ds(e,t,i,r){let s,{HOST:a,PARAMS:n,[i]:l}=r;t&&(s=null==l?void 0:l[t])&&(e=s);let o=new self.URL(e);return a&&!s&&(o.host=a),n&&Object.keys(n).sort().forEach(e=>{e&&o.searchParams.set(e,n[e])}),o.href}class da extends sE{constructor(e){super("eme",e.logger),this.hls=void 0,this.config=void 0,this.media=null,this.mediaResolved=void 0,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.mediaKeys=null,this.setMediaKeysQueue=da.CDMCleanupPromise?[da.CDMCleanupPromise]:[],this.bannedKeyIds={},this.onMediaEncrypted=e=>{let{initDataType:t,initData:i}=e,r=`"${e.type}" event: init data type: "${t}"`;if(this.debug(r),null!==i){if(!this.keyFormatPromise){let e=Object.keys(this.keySystemAccessPromises);e.length||(e=nk(this.config));let t=e.map(nS).filter(e=>!!e);this.keyFormatPromise=this.getKeyFormatPromise(t)}this.keyFormatPromise.then(s=>{let a,n=nA(s);if("sinf"!==t||n!==ng)return void this.log(`Ignoring "${e.type}" event with init data type: "${t}" for selected key-system ${n}`);try{let e=sH(new Uint8Array(i)),t=nh(JSON.parse(e).sinf),r=sJ(t);if(!r)throw Error("'schm' box missing or not cbcs/cenc with schi > tenc");a=new Uint8Array(r.subarray(8,24))}catch(e){this.warn(`${r} Failed to parse sinf: ${e}`);return}let l=sR(a),{keyIdToKeySessionPromise:o,mediaKeySessions:d}=this,h=o[l];for(let e=0;e<d.length;e++){let r=d[e],s=r.decryptdata;if(!s.keyId)continue;let n=sR(s.keyId);if(nn(a,s.keyId)||-1!==s.uri.replace(/-/g,"").indexOf(l)){if(!(h=o[n]))continue;if(s.pssh)break;delete o[n],s.pssh=new Uint8Array(i),s.keyId=a,(h=o[l]=h.then(()=>this.generateRequestWithPreferredKeySession(r,t,i,"encrypted-event-key-match"))).catch(e=>this.handleError(e));break}}h||this.handleError(Error(`Key ID ${l} not encountered in playlist. Key-system sessions ${d.length}.`))}).catch(e=>this.handleError(e))}},this.onWaitingForKey=e=>{this.log(`"${e.type}" event`)},this.hls=e,this.config=e.config,this.registerListeners()}destroy(){this.onDestroying(),this.onMediaDetached();let 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}
15registerListeners(){this.hls.on(sa.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(sa.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(sa.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(sa.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.on(sa.DESTROYING,this.onDestroying,this)}unregisterListeners(){this.hls.off(sa.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(sa.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(sa.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(sa.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.off(sa.DESTROYING,this.onDestroying,this)}getLicenseServerUrl(e){let{drmSystems:t,widevineLicenseUrl:i}=this.config,r=null==t?void 0:t[e];return r?r.licenseUrl:e===nE&&i?i:void 0}getLicenseServerUrlOrThrow(e){let t=this.getLicenseServerUrl(e);if(void 0===t)throw Error(`no license server URL configured for key-system "${e}"`);return t}getServerCertificateUrl(e){let{drmSystems:t}=this.config,i=null==t?void 0:t[e];if(i)return i.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`)}attemptKeySystemAccess(e){let t=this.hls.levels,i=(e,t,i)=>!!e&&i.indexOf(e)===t,r=t.map(e=>e.audioCodec).filter(i),s=t.map(e=>e.videoCodec).filter(i);return r.length+s.length===0&&s.push("avc1.42e01e"),new Promise((t,i)=>{let a=e=>{let n=e.shift();this.getMediaKeysPromise(n,r,s).then(e=>t({keySystem:n,mediaKeys:e})).catch(t=>{e.length?a(e):t instanceof dl?i(t):i(new dl({type:sr.KEY_SYSTEM_ERROR,details:ss.KEY_SYSTEM_NO_ACCESS,error:t,fatal:!0},t.message))})};a(e)})}requestMediaKeySystemAccess(e,t){let{requestMediaKeySystemAccessFunc:i}=this.config;if("function"!=typeof i){let e=`Configured requestMediaKeySystemAccess is not a function ${i}`;return null===nL&&"http:"===self.location.protocol&&(e=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(Error(e))}return i(e,t)}getMediaKeysPromise(e,t,i){var r;let s=function(e,t,i,r){var s,a,n,l;let o;switch(e){case ng:o=["cenc","sinf"];break;case nE:case nv:o=["cenc"];break;case np:o=["cenc","keyids"];break;default:throw Error(`Unknown key-system: ${e}`)}return s=o,a=t,n=i,[{initDataTypes:s,persistentState:(l=r).persistentState||"optional",distinctiveIdentifier:l.distinctiveIdentifier||"optional",sessionTypes:l.sessionTypes||[l.sessionType||"temporary"],audioCapabilities:a.map(e=>({contentType:`audio/mp4; codecs=${e}`,robustness:l.audioRobustness||"",encryptionScheme:l.audioEncryptionScheme||null})),videoCapabilities:n.map(e=>({contentType:`video/mp4; codecs=${e}`,robustness:l.videoRobustness||"",encryptionScheme:l.videoEncryptionScheme||null}))}]}(e,t,i,this.config.drmSystemOptions||{}),a=this.keySystemAccessPromises[e],n=null==(r=a)?void 0:r.keySystemAccess;if(!n){this.log(`Requesting encrypted media "${e}" key-system access with config: ${ab(s)}`),n=this.requestMediaKeySystemAccess(e,s);let t=a=this.keySystemAccessPromises[e]={keySystemAccess:n};return n.catch(t=>{this.log(`Failed to obtain access to key-system "${e}": ${t}`)}),n.then(i=>{this.log(`Access for key-system "${i.keySystem}" obtained`);let r=this.fetchServerCertificate(e);this.log(`Create media-keys for "${e}"`);let s=t.mediaKeys=i.createMediaKeys().then(i=>(this.log(`Media-keys created for "${e}"`),t.hasMediaKeys=!0,r.then(t=>t?this.setMediaKeysServerCertificate(i,e,t):i)));return s.catch(t=>{this.error(`Failed to create media-keys for "${e}"}: ${t}`)}),s})}return n.then(()=>a.mediaKeys)}createMediaKeySessionContext({decryptdata:e,keySystem:t,mediaKeys:i}){this.log(`Creating key-system session "${t}" keyId: ${sR(e.keyId||[])} keyUri: ${e.uri}`);let r=i.createSession(),s={decryptdata:e,keySystem:t,mediaKeys:i,mediaKeysSession:r,keyStatus:"status-pending"};return this.mediaKeySessions.push(s),s}renewKeySession(e){let t=e.decryptdata;if(t.pssh){let i=this.createMediaKeySessionContext(e),r=dn(t);this.keyIdToKeySessionPromise[r]=this.generateRequestWithPreferredKeySession(i,"cenc",t.pssh.buffer,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)}updateKeySession(e,t){let i=e.mediaKeysSession;return this.log(`Updating key-session "${i.sessionId}" for keyId ${sR(e.decryptdata.keyId||[])}
16      } (data length: ${t.byteLength})`),i.update(t)}getSelectedKeySystemFormats(){return Object.keys(this.keySystemAccessPromises).map(e=>({keySystem:e,hasMediaKeys:this.keySystemAccessPromises[e].hasMediaKeys})).filter(({hasMediaKeys:e})=>!!e).map(({keySystem:e})=>nS(e)).filter(e=>!!e)}getKeySystemAccess(e){return this.getKeySystemSelectionPromise(e).then(({keySystem:e,mediaKeys:t})=>this.attemptSetMediaKeys(e,t))}selectKeySystem(e){return new Promise((t,i)=>{this.getKeySystemSelectionPromise(e).then(({keySystem:e})=>{let r=nS(e);r?t(r):i(Error(`Unable to find format for key-system "${e}"`))}).catch(i)})}selectKeySystemFormat(e){let t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${e.sn} ${e.type}: ${e.level}) key formats ${t.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise}getKeyFormatPromise(e){let t=nk(this.config),i=e.map(nA).filter(e=>!!e&&-1!==t.indexOf(e));return this.selectKeySystem(i)}getKeyStatus(e){let{mediaKeySessions:t}=this;for(let s=0;s<t.length;s++){var i,r;let a=(i=e,r=t[s],i.keyId&&r.mediaKeysSession.keyStatuses.has(i.keyId)?r.mediaKeysSession.keyStatuses.get(i.keyId):i.matches(r.decryptdata)?r.keyStatus:void 0);if(a)return a}}loadKey(e){let t=e.keyInfo.decryptdata,i=dn(t),r=this.bannedKeyIds[i];if(r||"internal-error"===this.getKeyStatus(t)){let i=dd(r||"internal-error",t);return this.handleError(i,e.frag),Promise.reject(i)}let s=`(keyId: ${i} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${s}`);let a=this.keyIdToKeySessionPromise[i];if(!a){let r=this.getKeySystemForKeyPromise(t).then(({keySystem:i,mediaKeys:r})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${s}`),this.attemptSetMediaKeys(i,r).then(()=>(this.throwIfDestroyed(),this.createMediaKeySessionContext({keySystem:i,mediaKeys:r,decryptdata:t}))))).then(e=>{let i=t.pssh?t.pssh.buffer:null;return this.generateRequestWithPreferredKeySession(e,"cenc",i,"playlist-key")});return r.catch(t=>this.handleError(t,e.frag)),this.keyIdToKeySessionPromise[i]=r,r}return a.catch(i=>{if(i instanceof dl){let r=sv({},i.data);"internal-error"===this.getKeyStatus(t)&&(r.decryptdata=t);let s=new dl(r,i.message);this.handleError(s,e.frag)}}),a}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw Error("invalid state")}handleError(e,t){if(this.hls)if(e instanceof dl){t&&(e.data.frag=t);let i=e.data.decryptdata;this.error(`${e.message}${i?` (${sR(i.keyId||[])})`:""}`),this.hls.trigger(sa.ERROR,e.data)}else this.error(e.message),this.hls.trigger(sa.ERROR,{type:sr.KEY_SYSTEM_ERROR,details:ss.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0})}
16getKeySystemForKeyPromise(e){let t=dn(e),i=this.keyIdToKeySessionPromise[t];if(!i){let t=nA(e.keyFormat),i=t?[t]:nk(this.config);return this.attemptKeySystemAccess(i)}return i}getKeySystemSelectionPromise(e){if(e.length||(e=nk(this.config)),0===e.length)throw new dl({type:sr.KEY_SYSTEM_ERROR,details:ss.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${ab({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}attemptSetMediaKeys(e,t){if(this.mediaResolved=void 0,this.mediaKeys===t)return Promise.resolve();let i=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);let r=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(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(r),r.then(()=>{this.log(`Media-keys set for "${e}"`),i.push(r),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(e=>-1===i.indexOf(e))})}generateRequestWithPreferredKeySession(e,t,i,r){var s;let a=null==(s=this.config.drmSystems)||null==(s=s[e.keySystem])?void 0:s.generateRequest;if(a)try{let r=a.call(this.hls,t,i,e);if(!r)throw Error("Invalid response from configured generateRequest filter");t=r.initDataType,i=r.initData?r.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 "${r}" (no initData)`),Promise.resolve(e);let n=dn(e.decryptdata),l=e.decryptdata.uri;this.log(`Generating key-session request for "${r}" keyId: ${n} URI: ${l} (init data type: ${t} length: ${i.byteLength})`);let o=new lE,d=e._onmessage=t=>{let i=e.mediaKeysSession;if(!i)return void o.emit("error",Error("invalid state"));let{messageType:r,message:s}=t;this.log(`"${r}" message event for session "${i.sessionId}" message size: ${s.byteLength}`),"license-request"===r||"license-renewal"===r?this.renewLicense(e,s).catch(e=>
16{o.eventNames().length?o.emit("error",e):this.handleError(e)}):"license-release"===r?e.keySystem===ng&&this.updateKeySession(e,nu("acknowledged")).then(()=>this.removeSession(e)).catch(e=>this.handleError(e)):this.warn(`unhandled media key message type "${r}"`)},h=(e,t)=>{let i;t.keyStatus=e,e.startsWith("usable")?o.emit("resolved"):"internal-error"===e||"output-restricted"===e||"output-downscaled"===e?i=dd(e,t.decryptdata):"expired"===e?i=Error(`key expired (keyId: ${n})`):"released"===e?i=Error("key released"):"status-pending"===e||this.warn(`unhandled key status change "${e}" (keyId: ${n})`),i&&(o.eventNames().length?o.emit("error",i):this.handleError(i))},u=e._onkeystatuseschange=t=>{if(!e.mediaKeysSession)return void o.emit("error",Error("invalid state"));let i=this.getKeyStatuses(e);if(!Object.keys(i).some(e=>"status-pending"!==i[e]))return;if("expired"===i[n]){this.log(`Expired key ${ab(i)} in key-session "${e.mediaKeysSession.sessionId}"`),this.renewKeySession(e);return}let r=i[n];if(r)h(r,e);else{var s;e.keyStatusTimeouts||(e.keyStatusTimeouts={}),(s=e.keyStatusTimeouts)[n]||(s[n]=self.setTimeout(()=>{if(!e.mediaKeysSession||!this.mediaKeys)return;let t=this.getKeyStatus(e.decryptdata);if(t&&"status-pending"!==t)return this.log(`No status for keyId ${n} in key-session "${e.mediaKeysSession.sessionId}". Using session key-status ${t} from other session.`),h(t,e);this.log(`key status for ${n} in key-session "${e.mediaKeysSession.sessionId}" timed out after 1000ms`),h(r="internal-error",e)},1e3)),this.log(`No status for keyId ${n} (${ab(i)}).`)}};n7(e.mediaKeysSession,"message",d),n7(e.mediaKeysSession,"keystatuseschange",u);let c=new Promise((e,t)=>{o.on("error",t),o.on("resolved",e)});return e.mediaKeysSession.generateRequest(t,i).then(()=>{this.log(`Request generated for key-session "${e.mediaKeysSession.sessionId}" keyId: ${n} URI: ${l}`)}).catch(t=>{throw new dl({type:sr.KEY_SYSTEM_ERROR,details:ss.KEY_SYSTEM_NO_SESSION,error:t,decryptdata:e.decryptdata,fatal:!1},`Error generating key-session request: ${t}`)}).then(()=>c).catch(t=>(o.removeAllListeners(),this.removeSession(e).then(()=>{throw t}))).then(()=>(o.removeAllListeners(),e))}getKeyStatuses(e){let t={};return e.mediaKeysSession.keyStatuses.forEach((i,r)=>{if("string"==typeof r&&"object"==typeof i){let e=r;r=i,i=e}let s="buffer"in r?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):new Uint8Array(r);e.keySystem===nv&&16===s.length&&(t[sR(s)]=i,nc(s));let a=sR(s);"internal-error"===i&&(this.bannedKeyIds[a]=i),this.log(`key status change "${i}" for keyStatuses keyId: ${a} key-session "${e.mediaKeysSession.sessionId}"`),t[a]=i}),t}fetchServerCertificate(e){let t=this.config,i=new t.loader(t),r=this.getServerCertificateUrl(e);return r?(this.log(`Fetching server certificate for "${e}"`),new Promise((s,a)=>{let n={responseType:"arraybuffer",url:r},l=t.certLoadPolicy.default,o={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0};i.load(n,o,{onSuccess:(e,t,i,r)=>{s(e.data)},onError:(t,i,s,l)=>{a(new dl({type:sr.KEY_SYSTEM_ERROR,details:ss.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:s,response:sv({url:n.url,data:void 0},t)},`"${e}" certificate request failed (${r}). Status: ${t.code} (${t.text})`))},onTimeout:(t,i,s)=>{a(new dl({type:sr.KEY_SYSTEM_ERROR,details:ss.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:s,response:{url:n.url,data:void 0}},`"${e}" certificate request timed out (${r})`))},onAbort:(e,t,i)=>{a(Error("aborted"))}})})):Promise.resolve()}setMediaKeysServerCertificate(e,t,i){return new Promise((r,s)=>{e.setServerCertificate(i).then(s=>{this.log(`setServerCertificate ${s?"success":"not supported by CDM"} (${i.byteLength}) on "${t}"`),r(e)}).catch(e=>{s(new dl({type:sr.KEY_SYSTEM_ERROR,details:ss.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:e,fatal:!0},e.message))})})}renewLicense(e,t){return this.requestLicense(e,new Uint8Array(t)).then(t=>this.updateKeySession(e,new Uint8Array(t)).catch(t=>{throw new dl({type:sr.KEY_SYSTEM_ERROR,details:ss.KEY_SYSTEM_SESSION_UPDATE_FAILED,decryptdata:e.decryptdata,error:t,fatal:!1},t.message)}))}unpackPlayReadyKeyMessage(e,t){let i=String.fromCharCode.apply(null,new Uint16Array(t.buffer));if(!i.includes("PlayReadyKeyMessage"))return e.setRequestHeader("Content-Type","text/xml; charset=utf-8"),t;let r=new DOMParser().parseFromString(i,"application/xml"),s=r.querySelectorAll("HttpHeader");if(s.length>0){let t;for(let i=0,r=s.length;i<r;i++){var a,n;let r=null==(a=(t=s[i]).querySelector("name"))?void 0:a.textContent,l=null==(n=t.querySelector("value"))?void 0:n.textContent;r&&l&&e.setRequestHeader(r,l)}}let l=r.querySelector("Challenge"),o=null==l?void 0:l.textContent;
16if(!o)throw Error("Cannot find <Challenge> in key message");return nu(atob(o))}setupLicenseXHR(e,t,i,r){let s=this.config.licenseXhrSetup;return s?Promise.resolve().then(()=>{if(!i.decryptdata)throw Error("Key removed");return s.call(this.hls,e,t,i,r)}).catch(a=>{if(!i.decryptdata)throw a;return e.open("POST",t,!0),s.call(this.hls,e,t,i,r)}).then(i=>(e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:i||r})):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:r}))}requestLicense(e,t){let i=this.config.keyLoadPolicy.default;return new Promise((r,s)=>{let a=this.getLicenseServerUrlOrThrow(e.keySystem);this.log(`Sending license request to URL: ${a}`);let n=new XMLHttpRequest;n.responseType="arraybuffer",n.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return s(Error("invalid state"));if(4===n.readyState)if(200===n.status){this._requestLicenseFailureCount=0;let t=n.response;this.log(`License received ${t instanceof ArrayBuffer?t.byteLength:t}`);let i=this.config.licenseResponseCallback;if(i)try{t=i.call(this.hls,n,a,e)}catch(e){this.error(e)}r(t)}else{let l=i.errorRetry,o=l?l.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>o||n.status>=400&&n.status<500)s(new dl({type:sr.KEY_SYSTEM_ERROR,details:ss.KEY_SYSTEM_LICENSE_REQUEST_FAILED,decryptdata:e.decryptdata,fatal:!0,networkDetails:n,response:{url:a,data:void 0,code:n.status,text:n.statusText}},`License Request XHR failed (${a}). Status: ${n.status} (${n.statusText})`));else{let i=o-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${i} attempts left`),this.requestLicense(e,t).then(r,s)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=n,this.setupLicenseXHR(n,a,e,t).then(({xhr:t,licenseChallenge:i})=>{e.keySystem==nv&&(i=this.unpackPlayReadyKeyMessage(t,i)),t.send(i)}).catch(s)})}onDestroying(){this.unregisterListeners(),this._clear()}onMediaAttached(e,t){if(!this.config.emeEnabled)return;let i=t.media;this.media=i,n7(i,"encrypted",this.onMediaEncrypted),n7(i,"waitingforkey",this.onWaitingForKey);let r=this.mediaResolved;r?r():this.mediaKeys=i.mediaKeys}onMediaDetached(){let e=this.media;e&&(le(e,"encrypted",this.onMediaEncrypted),le(e,"waitingforkey",this.onWaitingForKey),this.media=null,this.mediaKeys=null)}_clear(){var e;this._requestLicenseFailureCount=0,this.keyIdToKeySessionPromise={},this.bannedKeyIds={};let t=this.mediaResolved;if(t&&t(),!this.mediaKeys&&!this.mediaKeySessions.length)return;let i=this.media,r=this.mediaKeySessions.slice();this.mediaKeySessions=[],this.mediaKeys=null,nw.clearKeyUriToKeyIdMap();let s=r.length;da.CDMCleanupPromise=Promise.all(r.map(e=>this.removeSession(e)).concat((null==i||null==(e=i.setMediaKeys(null))?void 0:e.catch(e=>{this.log(`Could not clear media keys: ${e}`),this.hls&&this.hls.trigger(sa.ERROR,{type:sr.OTHER_ERROR,details:ss.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR,fatal:!1,error: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(sa.ERROR,{type:sr.OTHER_ERROR,details:ss.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:Error(`Could not close sessions and clear media keys: ${e}`)})}).then(()=>{s&&this.log("finished closing key sessions and clearing media keys")})}onManifestLoading(){this._clear()}onManifestLoaded(e,{sessionKeys:t}){if(t&&this.config.emeEnabled&&!this.keyFormatPromise){let e=t.reduce((e,t)=>(-1===e.indexOf(t.keyFormat)&&e.push(t.keyFormat),e),[]);this.log(`Selecting key-system from session-keys ${e.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(e)}}removeSession(e){let{mediaKeysSession:t,licenseXhr:i,decryptdata:r}=e;if(t){var s;this.log(`Remove licenses and keys and close session "${t.sessionId}" keyId: ${sR((null==r?void 0:r.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;let a=this.mediaKeySessions.indexOf(e);a>-1&&this.mediaKeySessions.splice(a,1);let{keyStatusTimeouts:n}=e;
16n&&Object.keys(n).forEach(e=>self.clearTimeout(n[e]));let{drmSystemOptions:l}=this.config;return(l&&("persistent-license"===l.sessionType||null!=(s=l.sessionTypes)&&s.some(e=>"persistent-license"===e))?new Promise((e,i)=>{self.setTimeout(()=>i(Error("MediaKeySession.remove() timeout")),8e3),t.remove().then(e).catch(i)}):Promise.resolve()).catch(e=>{this.log(`Could not remove session: ${e}`),this.hls&&this.hls.trigger(sa.ERROR,{type:sr.OTHER_ERROR,details:ss.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR,fatal:!1,error:Error(`Could not remove session: ${e}`)})}).then(()=>t.close()).catch(e=>{this.log(`Could not close session: ${e}`),this.hls&&this.hls.trigger(sa.ERROR,{type:sr.OTHER_ERROR,details:ss.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:Error(`Could not close session: ${e}`)})})}return Promise.resolve()}}function dn(e){if(!e)throw Error("Could not read keyId of undefined decryptdata");if(null===e.keyId)throw Error("keyId is null");return sR(e.keyId)}da.CDMCleanupPromise=void 0;class dl extends Error{constructor(e,t){super(t),this.data=void 0,e.error||(e.error=Error(t)),this.data=e,e.err=e.error}}function dd(e,t){let i="output-restricted"===e,r=i?ss.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:ss.KEY_SYSTEM_STATUS_INTERNAL_ERROR;return new dl({type:sr.KEY_SYSTEM_ERROR,details:r,fatal:!1,decryptdata:t},i?"HDCP level output restricted":`key status changed to "${e}"`)}function dh(e,t){let i;try{i=new Event("addtrack")}catch(e){(i=document.createEvent("Event")).initEvent("addtrack",!1,!1)}i.track=e,t.dispatchEvent(i)}function du(e,t){let 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 Error(`addCue is failed for: ${t}`)}catch(i){sA.debug(`[texttrack-utils]: ${i}`);try{let i=new self.TextTrackCue(t.startTime,t.endTime,t.text);i.id=t.id,e.addCue(i)}catch(e){sA.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${e}`)}}"disabled"===i&&(e.mode=i)}function dc(e,t){let i=e.mode;if("disabled"===i&&(e.mode="hidden"),e.cues)for(let i=e.cues.length;i--;)t&&e.cues[i].removeEventListener("enter",t),e.removeCue(e.cues[i]);"disabled"===i&&(e.mode=i)}function df(e,t,i,r){let s=e.mode;if("disabled"===s&&(e.mode="hidden"),e.cues&&e.cues.length>0){let s=function(e,t,i){let r=[],s=function(e,t){let i;if(t<=e[0].startTime)return 0;let r=e.length-1;if(t>e[r].endTime)return -1;let s=0,a=r;for(;s<=a;)if(t<e[i=Math.floor((a+s)/2)].startTime)a=i-1;else{if(!(t>e[i].startTime)||!(s<r))return i;s=i+1}return e[s].startTime-t<t-e[a].startTime?s:a}(e,t);if(s>-1)for(let a=s,n=e.length;a<n;a++){let s=e[a];if(s.startTime>=t&&s.endTime<=i)r.push(s);else if(s.startTime>i)break}return r}(e.cues,t,i);for(let t=0;t<s.length;t++)(!r||r(s[t]))&&e.removeCue(s[t])}"disabled"===s&&(e.mode=s)}function dm(e){let t=[];for(let i=0;i<e.length;i++){let r=e[i];("subtitles"===r.kind||"captions"===r.kind)&&r.label&&t.push(e[i])}return t}function dp(e){let t=5381,i=e.length;for(;i;)t=33*t^e.charCodeAt(--i);return(t>>>0).toString()}let dg=((uR={})[uR.Point=0]="Point",uR[uR.Range=1]="Range",uR);class dv{constructor(e,t){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=t,this.dateRange=e,this.setDateRange(e)}setDateRange(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)}reset(){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)}isAssetPastPlayoutLimit(e){var t;if(e>0&&e>=this.assetList.length)return!0;let i=this.playoutLimit;return!(e<=0||isNaN(i))&&(0===i||((null==(t=this.assetList[e])?void 0:t.startOffset)||0)>i)}findAssetIndex(e){return this.assetList.indexOf(e)}get identifier(){return this.dateRange.id}get startDate(){return this.dateRange.startDate}get startTime(){let e=this.dateRange.startTime;if(this.snapOptions.out){let t=this.dateRange.tagAnchor;if(t)return dE(e,t)}return e}get startOffset(){return this.cue.pre?0:this.startTime}get startIsAligned(){if(0===this.startTime||this.snapOptions.out)return!0;let e=this.dateRange.tagAnchor;if(e){let t=this.dateRange.startTime,i=dE(t,e);return t-i<.1}return!1}get resumptionOffset(){let e=this.resumeOffset,t=se(e)?e:this.duration;return this.cumulativeDuration+t}get resumeTime(){let e=this.startOffset+this.resumptionOffset;if(this.snapOptions.in){let t=this.resumeAnchor;if(t)return dE(e,t)}return e}get appendInPlace(){return!!this.appendInPlaceStarted||!this.appendInPlaceDisabled&&!!(!this.cue.once&&!this.cue.pre&&this.startIsAligned&&(isNaN(this.playoutLimit)&&isNaN(this.resumeOffset)||this.resumeOffset&&this.duration&&.025>Math.abs(this.resumeOffset-this.duration)))}set appendInPlace(e){if(this.appendInPlaceStarted){this.resetOnResume=!e;return}this.appendInPlaceDisabled=!e}get timelineStart(){return null!==this._timelineStart?this._timelineStart:this.startTime}set timelineStart(e){this._timelineStart=e}get duration(){let 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 duration(e){this._duration=e}get cue(){return this.dateRange.cue}get timelineOccupancy(){return"RANGE"===this.dateRange.attr["X-TIMELINE-OCCUPIES"]?dg.Range:dg.Point}get supplementsPrimary(){return"PRIMARY"===this.dateRange.attr["X-TIMELINE-STYLE"]}get contentMayVary(){return"NO"!==this.dateRange.attr["X-CONTENT-MAY-VARY"]}get assetUrl(){return this.dateRange.attr["X-ASSET-URI"]}get assetListUrl(){return this.dateRange.attr["X-ASSET-LIST"]}get baseUrl(){return this.base.url}get assetListLoaded(){return this.assetList.length>0||null!==this.assetListResponse}toString(){var e;return e=this,`["${e.identifier}" ${e.cue.pre?"<pre>":e.cue.post?"<post>":""}${e.timelineStart.toFixed(2)}-${e.resumeTime.toFixed(2)}]`}}function dE(e,t){return e-t.start<t.duration/2&&!(.025>Math.abs(e-(t.start+t.duration)))?t.start:t.start+t.duration}function dy(e,t,i){let r=new self.URL(e,i);return"data:"!==r.protocol&&r.searchParams.set("_HLS_primary_id",t),r}function db(e,t){for(;null!=(i=e.assetList[++t])&&i.error;)var i;return t}function dT(e){let t=e.timelineStart,i=e.duration||0;return`["${e.identifier}" ${t.toFixed(2)}-${(t+i).toFixed(2)}]`}class d_{constructor(e,t,i,r){this.hls=void 0,this.interstitial=void 0,this.assetItem=void 0,this.tracks=null,this.hasDetail
16s=!1,this.mediaAttached=null,this._currentTime=void 0,this._bufferedEosTime=void 0,this.checkPlayout=()=>{this.reachedPlayout(this.currentTime)&&this.hls&&this.hls.trigger(sa.PLAYOUT_LIMIT_REACHED,{})};const s=this.hls=new e(t);this.interstitial=i,this.assetItem=r;const a=()=>{this.hasDetails=!0};s.once(sa.LEVEL_LOADED,a),s.once(sa.AUDIO_TRACK_LOADED,a),s.once(sa.SUBTITLE_TRACK_LOADED,a),s.on(sa.MEDIA_ATTACHING,(e,{media:t})=>{this.removeMediaListeners(),this.mediaAttached=t,this.interstitial.playoutLimit&&(t.addEventListener("timeupdate",this.checkPlayout),this.appendInPlace&&s.on(sa.BUFFER_APPENDED,()=>{let e=this.bufferedEnd;this.reachedPlayout(e)&&(this._bufferedEosTime=e,s.trigger(sa.BUFFERED_TO_END,void 0))}))})}get appendInPlace(){return this.interstitial.appendInPlace}loadSource(){let e=this.hls;if(e)if(e.url)e.levels.length&&!e.started&&e.startLoad(-1,!0);else{let t=this.assetItem.uri;try{t=dy(t,e.config.primarySessionId||"").href}catch(e){}e.loadSource(t)}}bufferedInPlaceToEnd(e){var t;if(!this.appendInPlace)return!1;if(null!=(t=this.hls)&&t.bufferedToEnd)return!0;if(!e)return!1;let i=Math.min(this._bufferedEosTime||1/0,this.duration),r=this.timelineOffset,s=a6.bufferInfo(e,r,0);return this.getAssetTime(s.end)>=i-.02}reachedPlayout(e){let t=this.interstitial.playoutLimit;return this.startOffset+e>=t}get destroyed(){var e;return!(null!=(e=this.hls)&&e.userConfig)}get assetId(){return this.assetItem.identifier}get interstitialId(){return this.assetItem.parentIdentifier}get media(){var e;return(null==(e=this.hls)?void 0:e.media)||null}get bufferedEnd(){let e=this.media||this.mediaAttached;if(!e)return this._bufferedEosTime?this._bufferedEosTime:this.currentTime;let t=a6.bufferInfo(e,e.currentTime,.001);return this.getAssetTime(t.end)}get currentTime(){let e=this.media||this.mediaAttached;return e?this.getAssetTime(e.currentTime):this._currentTime||0}get duration(){let e=this.assetItem.duration;if(!e)return 0;let t=this.interstitial.playoutLimit;if(t){let i=t-this.startOffset;if(i>0&&i<e)return i}return e}get remaining(){let e=this.duration;return e?Math.max(0,e-this.currentTime):0}get startOffset(){return this.assetItem.startOffset}get timelineOffset(){var e;return(null==(e=this.hls)?void 0:e.config.timelineOffset)||0}set timelineOffset(e){let t=this.timelineOffset;if(e!==t&&Math.abs(e-t)>1/9e4&&this.hls){if(this.hasDetails)throw Error("Cannot set timelineOffset after playlists are loaded");this.hls.config.timelineOffset=e}}getAssetTime(e){return Math.min(Math.max(0,e-this.timelineOffset),this.duration)}removeMediaListeners(){let e=this.mediaAttached;e&&(this._currentTime=e.currentTime,this.bufferSnapShot(),e.removeEventListener("timeupdate",this.checkPlayout))}bufferSnapShot(){if(this.mediaAttached){var e;null!=(e=this.hls)&&e.bufferedToEnd&&(this._bufferedEosTime=this.bufferedEnd)}}destroy(){this.removeMediaListeners(),this.hls&&this.hls.destroy(),this.hls=null,this.tracks=this.mediaAttached=this.checkPlayout=null}attachMedia(e){var t;this.loadSource(),null==(t=this.hls)||t.attachMedia(e)}detachMedia(){var e;this.removeMediaListeners(),this.mediaAttached=null,null==(e=this.hls)||e.detachMedia()}resumeBuffering(){var e;null==(e=this.hls)||e.resumeBuffering()}pauseBuffering(){var e;null==(e=this.hls)||e.pauseBuffering()}transferMedia(){var e;return this.bufferSnapShot(),(null==(e=this.hls)?void 0:e.transferMedia())||null}resetDetails(){let e=this.hls;if(e&&this.hasDetails){e.stopLoad();let t=e=>delete e.details;e.levels.forEach(t),e.allAudioTracks.forEach(t),e.allSubtitleTracks.forEach(t),this.hasDetails=!1}}on(e,t,i){var r;null==(r=this.hls)||r.on(e,t)}once(e,t,i){var r;null==(r=this.hls)||r.once(e,t)}off(e,t,i){var r;null==(r=this.hls)||r.off(e,t)}toString(){var e;return`HlsAssetPlayer: ${dT(this.assetItem)} ${null==(e=this.hls)?void 0:e.sessionId} ${this.appendInPlace?"append-in-place":""}`}}class dA extends sE{constructor(e,t){super("interstitials-sched",t),this.onScheduleUpdate=void 0,this.eventMap={},this.events=null,this.items=null,this.durations={primary:0,playout:0,integrated:0},this.onScheduleUpdate=e}destroy(){this.reset(),this.onScheduleUpdate=null}reset(){this.eventMap={}
16,this.setDurations(0,0,0),this.events&&this.events.forEach(e=>e.reset()),this.events=this.items=null}resetErrorsInRange(e,t){return this.events?this.events.reduce((i,r)=>e<=r.startOffset&&t>r.startOffset?(delete r.error,i+1):i,0):0}get duration(){let e=this.items;return e?e[e.length-1].end:0}get length(){return this.items?this.items.length:0}getEvent(e){return e&&this.eventMap[e]||null}hasEvent(e){return e in this.eventMap}findItemIndex(e,t){if(e.event)return this.findEventIndex(e.event.identifier);let i=-1;e.nextEvent?i=this.findEventIndex(e.nextEvent.identifier)-1:e.previousEvent&&(i=this.findEventIndex(e.previousEvent.identifier)+1);let r=this.items;if(r)for(r[i]||(void 0===t&&(t=e.start),i=this.findItemIndexAtTime(t));i>=0&&null!=(s=r[i])&&s.event;){var s;i--}return i}findItemIndexAtTime(e,t){let i=this.items;if(i)for(let r=0;r<i.length;r++){let s=i[r];if(t&&"primary"!==t&&(s=s[t]),e===s.start||e>s.start&&e<s.end)return r}return -1}findJumpRestrictedIndex(e,t){let i=this.items;if(i)for(let r=e;r<=t&&i[r];r++){let e=i[r].event;if(null!=e&&e.restrictions.jump&&!e.appendInPlace)return r}return -1}findEventIndex(e){let t=this.items;if(t)for(let r=t.length;r--;){var i;if((null==(i=t[r].event)?void 0:i.identifier)===e)return r}return -1}findAssetIndex(e,t){let i=e.assetList,r=i.length;if(r>1)for(let e=0;e<r;e++){let s=i[e];if(!s.error){let i=s.timelineStart;if(t===i||t>i&&(t<i+(s.duration||0)||e===r-1))return e}}return 0}get assetIdAtEnd(){var e;let t=null==(e=this.items)||null==(e=e[this.length-1])?void 0:e.event;if(t){let e=t.assetList,i=e[e.length-1];if(i)return i.identifier}return null}parseInterstitialDateRanges(e,t){let i=e.main.details,{dateRanges:r}=i,s=this.events,a=this.parseDateRanges(r,{url:i.url},t),n=Object.keys(r),l=s?s.filter(e=>!n.includes(e.identifier)):[];a.length&&a.sort((e,t)=>{let i=e.cue.pre,r=e.cue.post,s=t.cue.pre,a=t.cue.post;if(i&&!s)return -1;if(s&&!i||r&&!a)return 1;if(a&&!r)return -1;if(!i&&!s&&!r&&!a){let i=e.startTime,r=t.startTime;if(i!==r)return i-r}return e.dateRange.tagOrder-t.dateRange.tagOrder}),this.events=a,l.forEach(e=>{this.removeEvent(e)}),this.updateSchedule(e,l)}updateSchedule(e,t=[],i=!1){let r=this.events||[];
16if(r.length||t.length||this.length<2){let s=this.items,a=this.parseSchedule(r,e);(i||t.length||(null==s?void 0:s.length)!==a.length||a.some((e,t)=>Math.abs(e.playout.start-s[t].playout.start)>.005||Math.abs(e.playout.end-s[t].playout.end)>.005))&&(this.items=a,this.onScheduleUpdate(t,s))}}parseDateRanges(e,t,i){let r=[],s=Object.keys(e);for(let a=0;a<s.length;a++){let n=s[a],l=e[n];if(l.isInterstitial){let e=this.eventMap[n];e?e.setDateRange(l):(e=new dv(l,t),this.eventMap[n]=e,!1===i&&(e.appendInPlace=i)),r.push(e)}}return r}parseSchedule(e,t){let i=[],r=t.main.details,s=r.live?1/0:r.edge,a=0;if((e=e.filter(e=>!e.error&&!(e.cue.once&&e.hasPlayed))).length){this.resolveOffsets(e,t);let r=0,l=0;if(e.forEach((t,n)=>{let o=t.cue.pre,d=t.cue.post,h=e[n-1]||null,u=t.appendInPlace,c=d?s:t.startOffset,f=t.duration,m=t.timelineOccupancy===dg.Range?f:0,g=t.resumptionOffset,v=(null==h?void 0:h.startTime)===c,E=c+t.cumulativeDuration,y=u?E+f:c+g;if(o||!d&&c<=0){let e=l;l+=m,t.timelineStart=E;let r=a;a+=f,i.push({event:t,start:E,end:y,playout:{start:r,end:a},integrated:{start:e,end:l}})}else{if(!(c<=s))return;if(!v){let s=c-r;if(s>.033){let o=r,d=l;l+=s;let h=a;a+=s;let u={previousEvent:e[n-1]||null,nextEvent:t,start:o,end:o+s,playout:{start:h,end:a},integrated:{start:d,end:l}};i.push(u)}else s>0&&h&&(h.cumulativeDuration+=s,i[i.length-1].end=c)}d&&(y=E),t.timelineStart=E;let o=l;l+=m;let u=a;a+=f,i.push({event:t,start:E,end:y,playout:{start:u,end:a},integrated:{start:o,end:l}})}let b=t.resumeTime;r=d||b>s?s:b}),r<s){var n;let e=r,t=l,o=s-r;l+=o;let d=a;a+=o,i.push({previousEvent:(null==(n=i[i.length-1])?void 0:n.event)||null,nextEvent:null,start:r,end:e+o,playout:{start:d,end:a},integrated:{start:t,end:l}})}this.setDurations(s,a,l)}else i.push({previousEvent:null,nextEvent:null,start:0,end:s,playout:{start:0,end:s},integrated:{start:0,end:s}}),this.setDurations(s,s,s);return i}setDurations(e,t,i){this.durations={primary:e,playout:t,integrated:i}}resolveOffsets(e,t){let i=t.main.details,r=i.live?1/0:i.edge,s=0,a=-1;e.forEach((n,l)=>{let o=n.cue.pre,d=n.cue.post,h=o?0:d?r:n.startTime;this.updateAssetDurations(n),a===h?n.cumulativeDuration=s:(s=0,a=h),!d&&n.snapOptions.in&&(n.resumeAnchor=aD(null,i.fragments,n.startOffset+n.resumptionOffset,0,0)||void 0),n.appendInPlace&&!n.appendInPlaceStarted&&(this.primaryCanResumeInPlaceAt(n,t)||(n.appendInPlace=!1)),!n.appendInPlace&&l+1<e.length&&e[l+1].startTime-e[l].resumeTime<.033&&(e[l+1].appendInPlace=!1,e[l+1].appendInPlace&&this.warn(`Could not change append strategy for abutting event ${n}`));let u=se(n.resumeOffset)?n.resumeOffset:n.duration;s+=u})}primaryCanResumeInPlaceAt(e,t){let i=e.resumeTime,r=e.startTime+e.resumptionOffset;return Math.abs(i-r)>.025?(this.log(`"${e.identifier}" resumption ${i} not aligned with estimated timeline end ${r}`),!1):!Object.keys(t).some(r=>{let s=t[r].details,a=s.edge;if(i>=a)return this.log(`"${e.identifier}" resumption ${i} past ${r} playlist end ${a}`),!1;let n=aD(null,s.fragments,i);if(!n)return this.log(`"${e.identifier}" resumption ${i} does not align with any fragments in ${r} playlist (${s.fragStart}-${s.fragmentEnd})`),!0;let l=.175*("audio"===r);return!(Math.abs(n.start-i)<.025+l||Math.abs(n.end-i)<.025+l)&&(this.log(`"${e.identifier}" resumption ${i} not aligned with ${r} fragment bounds (${n.start}-${n.end} sn: ${n.sn} cc: ${n.cc})`),!0)})}updateAssetDurations(e){if(!e.assetListLoaded)return;let t=e.timelineStart,i=0,r=!1,s=!1;for(let a=0;a<e.assetList.length;a++){let n=e.assetList[a],l=t+i;n.startOffset=i,n.timelineStart=l,r||(r=null===n.duration),s||(s=!!n.error),i+=n.error?0:n.duration||0}r&&!s?e.duration=Math.max(i,e.duration):e.duration=i}removeEvent(e){e.reset(),delete this.eventMap[e.identifier]}}function dS(e){return`[${e.event?'"'+e.event.identifier+'"':"primary"}: ${e.start.toFixed(2)}-${e.end.toFixed(2)}]`}class dk{constructor(e){this.hls=void 0,this.hls=e}destroy(){this.hls=null}loadAssetList(e,t){let i,r=e.assetListUrl;try{i=dy(r,this.hls.sessionId,e.baseUrl)}catch(i){let t=this.assignAssetListError(e,ss.ASSET_LIST_LOAD_ERROR,i,r);this.hls.trigger(sa.ERROR,t);return}t&&"data:"!==i.protocol&&i.searchParams.set("_HLS_start_offset",""+t);let s=this.hls.config,a=new s.loader(s),n={responseType:"json",url:i.href},l=s.interstitialAssetListLoadPolicy.default,o={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0};return a.load(n,o,{onSuccess:(t,i,r,s)=>{let a=t.data;if(!Array.isArray(null==a?void 0:a.ASSETS)){let t=this.assignAssetListError(e,ss.ASSET_LIST_PARSING_ERROR,Error("Invalid interstitial asset list"),r.url,i,s);this.hls.trigger(sa.ERROR,t);return}e.assetListResponse=a,this.hls.trigger(sa.ASSET_LIST_LOADED,{event:e,assetListResponse:a,networkDetails:s})},onError:(t,i,r,s)=>{let a=this.assignAssetListError(e,ss.ASSET_LIST_LOAD_ERROR,Error(`Error loading X-ASSET-LIST: HTTP status ${t.code} ${t.text} (${i.url})`),i.url,s,r);this.hls.trigger(sa.ERROR,a)},onTimeout:(t,i,r)=>{let s=this.assignAssetListError(e,ss.ASSET_LIST_LOAD_TIMEOUT,Error(`Timeout loading X-ASSET-LIST (${i.url})`),i.url,t,r);this.hls.trigger(sa.ERROR,s)}}),this.hls.trigger(sa.ASSET_LIST_LOADING,{event:e}),a}assignAssetListError(e,t,i,r,s,a){return e.error=i,{type:sr.NETWORK_E
16RROR,details:t,fatal:!1,interstitial:e,url:r,error:i,networkDetails:a,stats:s}}}function dL(e){var t;null==e||null==(t=e.play())||t.catch(()=>{})}function dR(e,t){return`[${e}] Advancing timeline position to ${t}`}class dI{constructor(e){this.buffered=void 0;const t=(t,i,r)=>{if((i>>>=0)>r-1)throw new DOMException(`Failed to execute '${t}' on 'TimeRanges': The index provided (${i}) is greater than the maximum bound (${r})`);return e[i][t]};this.buffered={get length(){return e.length},end:i=>t("end",i,e.length),start:i=>t("start",i,e.length)}}}let dw={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},dD=e=>String.fromCharCode(dw[e]||e),dC={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},dP={17:2,18:4,21:6,22:8,23:10,19:13,20:15},dx={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},dM={25:2,26:4,29:6,30:8,31:10,27:13,28:15},dO=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class dN{constructor(){this.time=null,this.verboseLevel=0}log(e,t){if(this.verboseLevel>=e){let i="function"==typeof t?t():t;sA.log(`${this.time} [${e}] ${i}`)}}}let dU=function(e){let t=[];for(let i=0;i<e.length;i++)t.push(e[i].toString(16));return t};class dF{constructor(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}reset(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}setStyles(e){let t=["foreground","underline","italics","background","flash"];for(let i=0;i<t.length;i++){let r=t[i];e.hasOwnProperty(r)&&(this[r]=e[r])}}isDefault(){return"white"===this.foreground&&!this.underline&&!this.italics&&"black"===this.background&&!this.flash}equals(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash}copy(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash}toString(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}}class d${constructor(){this.uchar=" ",this.penState=new dF}reset(){this.uchar=" ",this.penState.reset()}setChar(e,t){this.uchar=e,this.penState.copy(t)}setPenState(e){this.penState.copy(e)}equals(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)}copy(e){this.uchar=e.uchar,this.penState.copy(e.penState)}isEmpty(){return" "===this.uchar&&this.penState.isDefault()}}class dB{constructor(e){this.chars=[],this.pos=0,this.currPenState=new dF,this.cueStartTime=null,this.logger=void 0;for(let e=0;e<100;e++)this.chars.push(new d$);this.logger=e}equals(e){for(let t=0;t<100;t++)if(!this.chars[t].equals(e.chars[t]))return!1;return!0}copy(e){for(let t=0;t<100;t++)this.chars[t].copy(e.chars[t])}isEmpty(){let e=!0;for(let t=0;t<100;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e}setCursor(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>100&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=100)}moveCursor(e){let t=this.pos+e;if(e>1)for(let e=this.pos+1;e<t+1;e++)this.chars[e].setPenState(this.currPenState);this.setCursor(t)}backSpace(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}insertChar(e){e>=144&&this.backSpace();let t=dD(e);this.pos>=100?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))}clearFromPos(e){let t;for(t=e;t<100;t++)this.chars[t].reset()}clear(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}clearToEndOfRow(){this.clearFromPos(this.pos)}getTextString(){let e=[],t=!0;for(let i=0;i<100;i++){let r=this.chars[i].uchar;" "!==r&&(t=!1),e.push(r)}return t?"":e.join("")}setPenStyles(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)}}class dH{constructor(e){this.rows=[],this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(let t=0;t<15;t++)this.rows.push(new dB(e));this.logger=e}reset(){for(let e=0;e<15;e++)this.rows[e].clear();this.currRow=14}equals(e){let t=!0;for(let i=0;i<15;i++)if(!this.rows[i].equals(e.rows[i])){t=!1;break}return t}copy(e){for(let t=0;t<15;t++)this.rows[t].copy(e.rows[t])}isEmpty(){let e=!0;for(let t=0;t<15;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e}backSpace(){this.rows[this.currRow].backSpace()}clearToEndOfRow(){this.rows[this.currRow].clearToEndOfRow()}insertChar(e){this.rows[this.currRow].insertChar(e)}setPen(e){this.rows[this.currRow].setPenStyles(e)}moveCursor(e){this.rows[this.currRow].moveCursor(e)}setCursor(e){this.logger.log(2,"setCursor: "+e),this.rows[this.currRow].setCursor(e)}setPAC(e){this.logger.log(2,()=>"pacData = "+ab(e));let t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(let e=0;e<15;e++)this.rows[e].clear();let e=this.currRow+1-this.nrRollUpRows,i=this.lastOutputScreen;if(i){let r=i.rows[e].cueStartTime,s=this.logger.time;if(null!==r&&null!==s&&r<s)for(let r=0;r<this.nrRollUpRows;r++)this.rows[t-this.nrRollUpRows+r+1].copy(i.rows[e+r])}}this.currRow=t;let i=this.rows[this.currRow];if(null!==e.indent){let t=Math.max(e.indent-1,0);i.setCursor(e.indent),e.color=i.chars[t].penState.foreground}let r={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(r)}setBkgData(e){this.logger.log(2,()=>"bkgData = "+ab(e)),this.backSpace(),this.setPen(e),this.insertChar(32)}setRollUpRows(e){this.nrRollUpRows=e}rollUp(){if(null===this.nrRollUpRows)return void this.logger.log(3,"roll_up but nrRollUpRows not set yet");this.logger.log(1,()=>this.getDisplayText());let e=this.currRow+1-this.nrRollUpRows,t=this.rows.splice(e,1)[0];t.clear(),this.rows.splice(this.currRow,0,t),this.logger.log(2,"Rolling up")}getDisplayText(e){e=e||!1;let t=[],i="",r=-1;for(let i=0;i<15;i++){let s=this.rows[i].getTextString();s&&(r=i+1,e?t.push("Row "+r+": '"+s+"'"):t.push(s.trim()))}return t.length>0&&(i=e?"["+t.join(" | ")+"]":t.join("\n")),i}getTextAndFormat(){return this.rows}}class dG{constructor(e,t,i){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=e,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new dH(i),this.nonDisplayedMemory=new dH(i),this.lastOutputScreen=new dH(i),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=i}reset(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}getHandler(){return this.outputFilter}setHandler(e){this.outputFilter=e}setPAC(e){this.writeScreen.setPAC(e)}setBkgData(e){this.writeScreen.setBkgData(e)}setMode(e){e!==this.mode&&(this.mode=e,this.logger.log(2,()=>"MODE="+e),"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)}insertChars(e){for(let t=0;t<e.length;t++)this.writeScreen.insertChar(e[t]);let t=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,()=>t+": "+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())}ccRCL(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}ccBS(){this.logger.log(2,"BS - BackSpace"),"MODE_TEXT"!==this.mode&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}ccAOF(){}ccAON(){}ccDER(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}ccRU(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)}ccFON(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}
16ccRDC(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}ccTR(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}ccRTD(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}ccEDM(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}ccCR(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}ccENM(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}ccEOC(){if(this.logger.log(2,"EOC - End Of Caption"),"MODE_POP-ON"===this.mode){let e=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,()=>"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)}ccTO(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)}ccMIDROW(e){let t={flash:!1};(t.underline=e%2==1,t.italics=e>=46,t.italics)?t.foreground="white":t.foreground=["white","green","blue","cyan","red","yellow","magenta"][Math.floor(e/2)-16],this.logger.log(2,"MIDROW: "+ab(t)),this.writeScreen.setPen(t)}outputDataUpdate(e=!1){let 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))}cueSplitAtTime(e){this.outputFilter&&!this.displayedMemory.isEmpty()&&(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e)}}class dV{constructor(e,t,i){this.channels=void 0,this.currentChannel=0,this.cmdHistory={a:null,b:null},this.logger=void 0;const r=this.logger=new dN;this.channels=[null,new dG(e,t,r),new dG(e+1,i,r)]}getHandler(e){return this.channels[e].getHandler()}setHandler(e,t){this.channels[e].setHandler(t)}addData(e,t){this.logger.time=e;for(let e=0;e<t.length;e+=2){var i,r,s,a,n,l,o,d;let h=127&t[e],u=127&t[e+1],c=!1,f=null;if(0===h&&0===u)continue;this.logger.log(3,()=>"["+dU([t[e],t[e+1]])+"] -> ("+dU([h,u])+")");let m=this.cmdHistory;if(h>=16&&h<=31){if(i=h,r=u,(s=m).a===i&&s.b===r){(a=m).a=null,a.b=null,this.logger.log(3,()=>"Repeated command ("+dU([h,u])+") is dropped");continue}n=h,l=u,(o=this.cmdHistory).a=n,o.b=l,(c=this.parseCmd(h,u))||(c=this.parseMidrow(h,u)),c||(c=this.parsePAC(h,u)),c||(c=this.parseBackgroundAttributes(h,u))}else{(d=m).a=null,d.b=null}if(!c&&(f=this.parseChars(h,u))){let e=this.currentChannel;e&&e>0?this.channels[e].insertChars(f):this.logger.log(2,"No channel found yet. TEXT-MODE?")}c||f||this.logger.log(2,()=>"Couldn't parse cleaned data "+dU([h,u])+" orig: "+dU([t[e],t[e+1]]))}}parseCmd(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;let i=20===e||21===e||23===e?1:2,r=this.channels[i];return 20===e||21===e||28===e||29===e?32===t?r.ccRCL():33===t?r.ccBS():34===t?r.ccAOF():35===t?r.ccAON():36===t?r.ccDER():37===t?r.ccRU(2):38===t?r.ccRU(3):39===t?r.ccRU(4):40===t?r.ccFON():41===t?r.ccRDC():42===t?r.ccTR():43===t?r.ccRTD():44===t?r.ccEDM():45===t?r.ccCR():46===t?r.ccENM():47===t&&r.ccEOC():r.ccTO(t-32),this.currentChannel=i,!0}parseMidrow(e,t){let 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;let r=this.channels[i];return!!r&&(r.ccMIDROW(t),this.logger.log(3,()=>"MIDROW ("+dU([e,t])+")"),!0)}return!1}parsePAC(e,t){let i,r=(e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127,s=(16===e||24===e)&&t>=64&&t<=95;if(!(r||s))return!1;let a=e<=23?1:2;i=t>=64&&t<=95?1===a?dC[e]:dx[e]:1===a?dP[e]:dM[e];let n=this.channels[a];return!!n&&(n.setPAC(this.interpretPAC(i,t)),this.currentChannel=a,!0)}interpretPAC(e,t){let i,r={color:null,italics:!1,indent:null,underline:!1,row:e};return r.underline=(1&(i=t>95?t-96:t-64))==1,i<=13?r.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(i/2)]:i<=15?(r.italics=!0,r.color="white"):r.indent=4*Math.floor((i-16)/2),r}parseChars(e,t){let i,r=null,s=null;if(e>=25?(i=2,s=e-8):(i=1,s=e),s>=17&&s<=19){let e;e=17===s?t+80:18===s?t+112:t+144,this.logger.log(2,()=>"Special char '"+dD(e)+"' in channel "+i),r=[e]}else e>=32&&e<=127&&(r=0===t?[e]:[e,t]);return r&&this.logger.log(3,()=>"Char codes =  "+dU(r).join(",")),r}
16parseBackgroundAttributes(e,t){if(!((16===e||24===e)&&t>=32&&t<=47||(23===e||31===e)&&t>=45&&t<=47))return!1;let i={};return 16===e||24===e?(i.background=dO[Math.floor((t-32)/2)],t%2==1&&(i.background=i.background+"_semi")):45===t?i.background="transparent":(i.foreground="black",47===t&&(i.underline=!0)),this.channels[e<=23?1:2].setBkgData(i),!0}reset(){var e;for(let e=0;e<Object.keys(this.channels).length;e++){let t=this.channels[e];t&&t.reset()}(e=this.cmdHistory).a=null,e.b=null}cueSplitAtTime(e){for(let t=0;t<this.channels.length;t++){let i=this.channels[t];i&&i.cueSplitAtTime(e)}}}var dK=function(){if(null!=nm&&nm.VTTCue)return self.VTTCue;let e=["","lr","rl"],t=["start","middle","end","left","right"];function i(e,t){if("string"!=typeof t||!Array.isArray(e))return!1;let i=t.toLowerCase();return!!~e.indexOf(i)&&i}function r(e){let t=1;for(;t<arguments.length;t++){let i=arguments[t];for(let t in i)e[t]=i[t]}return e}function s(s,a,n){let l={enumerable:!0};this.hasBeenReset=!1;let o="",d=!1,h=s,u=a,c=n,f=null,m="",g=!0,v="auto",E="start",y=50,b="middle",T=50,_="middle";Object.defineProperty(this,"id",r({},l,{get:function(){return o},set:function(e){o=""+e}})),Object.defineProperty(this,"pauseOnExit",r({},l,{get:function(){return d},set:function(e){d=!!e}})),Object.defineProperty(this,"startTime",r({},l,{get:function(){return h},set:function(e){if("number"!=typeof e)throw TypeError("Start time must be set to a number.");h=e,this.hasBeenReset=!0}})),Object.defineProperty(this,"endTime",r({},l,{get:function(){return u},set:function(e){if("number"!=typeof e)throw TypeError("End time must be set to a number.");u=e,this.hasBeenReset=!0}})),Object.defineProperty(this,"text",r({},l,{get:function(){return c},set:function(e){c=""+e,this.hasBeenReset=!0}})),Object.defineProperty(this,"region",r({},l,{get:function(){return f},set:function(e){f=e,this.hasBeenReset=!0}})),Object.defineProperty(this,"vertical",r({},l,{get:function(){return m},set:function(t){let r=i(e,t);if(!1===r)throw SyntaxError("An invalid or illegal string was specified.");m=r,this.hasBeenReset=!0}})),Object.defineProperty(this,"snapToLines",r({},l,{get:function(){return g},set:function(e){g=!!e,this.hasBeenReset=!0}})),Object.defineProperty(this,"line",r({},l,{get:function(){return v},set:function(e){if("number"!=typeof e&&"auto"!==e)throw SyntaxError("An invalid number or illegal string was specified.");v=e,this.hasBeenReset=!0}})),Object.defineProperty(this,"lineAlign",r({},l,{get:function(){return E},set:function(e){let r=i(t,e);if(!r)throw SyntaxError("An invalid or illegal string was specified.");E=r,this.hasBeenReset=!0}})),Object.defineProperty(this,"position",r({},l,{get:function(){return y},set:function(e){if(e<0||e>100)throw Error("Position must be between 0 and 100.");y=e,this.hasBeenReset=!0}})),Object.defineProperty(this,"positionAlign",r({},l,{get:function(){return b},set:function(e){let r=i(t,e);if(!r)throw SyntaxError("An invalid or illegal string was specified.");b=r,this.hasBeenReset=!0}})),Object.defineProperty(this,"size",r({},l,{get:function(){return T},set:function(e){if(e<0||e>100)throw Error("Size must be between 0 and 100.");T=e,this.hasBeenReset=!0}})),Object.defineProperty(this,"align",r({},l,{get:function(){return _},set:function(e){let r=i(t,e);if(!r)throw SyntaxError("An invalid or illegal string was specified.");_=r,this.hasBeenReset=!0}})),this.displayState=void 0}return s.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},s}();class dW{decode(e,t){if(!e)return"";if("string"!=typeof e)throw Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}function dq(e){function t(e,t,i,r){return(0|e)*3600+(0|t)*60+(0|i)+parseFloat(r||0)}let 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}class dj{constructor(){this.values=Object.create(null)}set(e,t){this.get(e)||""===t||(this.values[e]=t)}get(e,t,i){return i?this.has(e)?this.values[e]:t[i]:this.has(e)?this.values[e]:t}has(e){return e in this.values}alt(e,t,i){for(let r=0;r<i.length;++r)if(t===i[r]){this.set(e,t);break}}integer(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))}percent(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){let i=parseFloat(t);if(i>=0&&i<=100)return this.set(e,i),!0}return!1}}function dY(e,t,i,r){let s=r?e.split(r):[e];for(let e in s){if("string"!=typeof s[e])continue;let r=s[e].split(i);if(2===r.length)t(r[0],r[1])}}let dQ=new dK(0,0,""),dz="middle"===dQ.align?"middle":"center";function dX(e){return e.replace(/<br(?: \/)?>/gi,"\n")}class dZ{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new dW,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(e){let t=this;function i(){let e=t.buffer,i=0;for(e=dX(e);i<e.length&&"\r"!==e[i]&&"\n"!==e[i];)++i;let r=e.slice(0,i);return"\r"===e[i]&&++i,"\n"===e[i]&&++i,t.buffer=e.slice(i),r}e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));try{let e="";if("INITIAL"===t.state){if(!/\r\n|\n/.test(t.buffer))return this;let r=(e=i()).match(/^()?WEBVTT([ \t].*)?$/);if(!(null!=r&&r[0]))throw Error("Malformed WebVTT signature.");t.state="HEADER"}let s=!1;for(;t.buffer&&/\r\n|\n/.test(t.buffer);)switch(s?s=!1:e=i(),t.state){case"HEADER":if(/:/.test(e)){var r;r=e,dY(r,function(e,t){},/:/)}else e||(t.state="ID");continue;case"NOTE":e||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(e)){t.state="NOTE";break}if(!e)continue;if(t.cue=new dK(0,0,""),t.state="CUE",-1===e.indexOf("-->")){t.cue.id=e;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{!function(e,t,i){var r;let s,a,n,l=e;function o(){let t=dq(e);if(null===t)throw Error("Malformed timestamp: "+l);return e=e.replace(/^[^\sa-zA-Z-]+/,""),t}function d(){e=e.replace(/^\s+/,"")}if(d(),t.startTime=o(),d(),"-->"!==e.slice(0,3))throw Error("Malformed time stamp (time stamps must be separated by '-->'): "+l);e=e.slice(3),d(),t.endTime=o(),d(),r=e,s=new dj,dY(r,function(e,t){let r;switch(e){case"region":for(let r=i.length-1;r>=0;r--)if(i[r].id===t){s.set(e,i[r].region);break}break;case"vertical":s.alt(e,t,["rl","lr"]);break;case"line":r=t.split(","),s.integer(e,r[0]),s.percent(e,r[0])&&s.set("snapToLines",!1),s.alt(e,r[0],["auto"]),2===r.length&&s.alt("lineAlign",r[1],["start",dz,"end"]);break;case"position":r=t.split(","),s.percent(e,r[0]),2===r.length&&s.alt("positionAlign",r[1],["start",dz,"end","line-left","line-right","auto"]);break;case"size":s.percent(e,t);break;case"align":s.alt(e,t,["start",dz,"end","left","right"])}},/:/,/\s/),t.region=s.get("region",null),t.vertical=s.get("vertical",""),"auto"===(a=s.get("line","auto"))&&-1===dQ.line&&(a=-1),t.line=a,t.lineAlign=s.get("lineAlign","start"),t.snapToLines=s.get("snapToLines",!0),t.size=s.get("size",100),t.align=s.get("align",dz),"auto"===(n=s.get("position","auto"))&&50===dQ.position&&(n="start"===t.align||"left"===t.align?0:"end"===t.align||"right"===t.align?100:50),t.position=n}(e,t.cue,t.regionList)}catch(e){t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":{let i=-1!==e.indexOf("-->");if(!e||i&&(s=!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+=e}continue;case"BADCUE":e||(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}flush(){try{if((this.cue||"HEADER"===this.state)&&(this.buffer+="\n\n",this.parse()),"INITIAL"===this.state||"BADWEBVTT"===this.state)throw Error("Malformed WebVTT signature.")}catch(e){this.onparsingerror&&this.onparsingerror(e)}return this.onflush&&this.onflush(),this}}let dJ=/\r\n|\n\r|\n|\r/g,d0=function(e,t,i=0){return e.slice(i,i+t.length)===t},d1=function(e){let t=parseInt(e.slice(-3)),i=parseInt(e.slice(-6,-4)),r=parseInt(e.slice(-9,-7)),s=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!se(t)||!se(i)||!se(r)||!se(s))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*i,t+=6e4*r,t+=36e5*s};function d2(e,t,i){return dp(e.toString())+dp(t.toString())+dp(i)}
16let d3=function(e,t,i){let r=e[t],s=e[r.prevCC];if(!s||!s.new&&r.new){e.ccOffset=e.presentationOffset=r.start,r.new=!1;return}for(;null!=(a=s)&&a.new;){var a;e.ccOffset+=r.start-s.start,r.new=!1,s=e[(r=s).prevCC]}e.presentationOffset=i},d4="stpp.ttml.im1t",d5=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,d8=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,d6={left:"start",center:"center",right:"end",start:"start",end:"end"};function d9(e,t,i,r){let s=sq(new Uint8Array(e),["mdat"]);if(0===s.length)return void r(Error("Could not parse IMSC1 mdat"));let a=s.map(e=>sL(e)),n=function(e,t=1,i=!1){return ot(e,1,1/t,i)}(t.baseTime,t.timescale);try{a.forEach(e=>i(function(e,t){let i=new DOMParser().parseFromString(e,"text/xml").getElementsByTagName("tt")[0];if(!i)throw Error("Invalid ttml");let r={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},s=Object.keys(r).reduce((e,t)=>(e[t]=i.getAttribute(`ttp:${t}`)||r[t],e),{}),a="preserve"!==i.getAttribute("xml:space"),n=he(d7(i,"styling","style")),l=he(d7(i,"layout","region")),o=d7(i,"body","[begin]");return[].map.call(o,e=>{var i,r,o;let d,h,u,c=function e(t,i){return[].slice.call(t.childNodes).reduce((t,r,s)=>{var a;return"br"===r.nodeName&&s?t+"\n":null!=(a=r.childNodes)&&a.length?e(r,i):i?t+r.textContent.trim().replace(/\s+/g," "):t+r.textContent},"")}(e,a);if(!c||!e.hasAttribute("begin"))return null;let f=hr(e.getAttribute("begin"),s),m=hr(e.getAttribute("dur"),s),g=hr(e.getAttribute("end"),s);if(null===f)throw hi(e);if(null===g){if(null===m)throw hi(e);g=f+m}let v=new dK(f-t,g-t,c);v.id=d2(v.startTime,v.endTime,v.text);let E=(i=l[e.getAttribute("region")],r=n[e.getAttribute("style")],o=n,d="http://www.w3.org/ns/ttml#styling",h=null,(u=null!=i&&i.hasAttribute("style")?i.getAttribute("style"):null)&&o.hasOwnProperty(u)&&(h=o[u]),["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"].reduce((e,t)=>{let s=ht(r,d,t)||ht(i,d,t)||ht(h,d,t);return s&&(e[t]=s),e},{})),{textAlign:y}=E;if(y){let e=d6[y];e&&(v.lineAlign=e),v.align=y}return sp(v,E),v}).filter(e=>null!==e)}(e,n)))}catch(e){r(e)}}function d7(e,t,i){let r=e.getElementsByTagName(t)[0];return r?[].slice.call(r.querySelectorAll(i)):[]}function he(e){return e.reduce((e,t)=>{let i=t.getAttribute("xml:id");return i&&(e[i]=t),e},{})}function ht(e,t,i){return e&&e.hasAttributeNS(t,i)?e.getAttributeNS(t,i):null}function hi(e){return Error(`Could not parse ttml timestamp ${e}`)}function hr(e,t){var i,r;let s,a;if(!e)return null;let n=dq(e);return null===n&&(d5.test(e)?(i=e,r=t,a=(0|(s=d5.exec(i))[4])+(0|s[5])/r.subFrameRate,n=(0|s[1])*3600+(0|s[2])*60+(0|s[3])+a/r.frameRate):d8.test(e)&&(n=function(e,t){let i=d8.exec(e),r=Number(i[1]);switch(i[2]){case"h":return 3600*r;case"m":return 60*r;case"ms":return 1e3*r;case"f":return r/t.frameRate;case"t":return r/t.tickRate}return r}(e,t))),n}class hs{constructor(e,t){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=e,this.trackName=t}dispatchCue(){null!==this.startTime&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(e,t,i){(null===this.startTime||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=i,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}}function ha(e){return e.characteristics&&/transcribes-spoken-dialog/gi.test(e.characteristics)&&/describes-music-and-sound/gi.test(e.characteristics)?"captions":"subtitles"}function hn(e,t){return!!e&&e.kind===ha(t)&&oS(t,e)}function hl(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}let ho=/\s/,hd={newCue(e,t,i,r){let s,a,n,l,o,d=[],h=self.VTTCue||self.TextTrackCue;for(let c=0;c<r.rows.length;c++)if(s=r.rows[c],n=!0,l=0,o="",!s.isEmpty()){var u;for(let e=0;e<s.chars.length;e++)ho.test(s.chars[e].uchar)&&n?l++:(o+=s.chars[e].uchar,n=!1);s.cueStartTime=t,t===i&&(i+=1e-4),l>=16?l--:l++;let r=dX(o.trim()),f=d2(t,i,r);null!=e&&null!=(u=e.cues)&&u.getCueById(f)||((a=new h(t,i,r)).id=f,a.line=c+1,a.align="left",a.position=10+Math.min(80,10*Math.floor(8*l/32)),d.push(a))}return e&&d.length&&(d.sort((e,t)=>
16"auto"===e.line||"auto"===t.line?0:e.line>8&&t.line>8?t.line-e.line:e.line-t.line),d.forEach(t=>du(e,t))),d}},hh=/(\d+)-(\d+)\/(\d+)/;class hu{constructor(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=e.fetchSetup||hc,this.controller=new self.AbortController,this.stats=new sC}destroy(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null}abortInternal(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())}abort(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(e,t,i){var r;let s,a=this.stats;if(a.loading.start)throw Error("Loader can only be used once.");a.loading.start=self.performance.now();let n=(r=e,s={method:"GET",mode:"cors",credentials:"same-origin",signal:this.controller.signal,headers:new self.Headers(sp({},r.headers))},r.rangeEnd&&s.headers.set("Range","bytes="+r.rangeStart+"-"+String(r.rangeEnd-1)),s),l="arraybuffer"===e.responseType,o=l?"byteLength":"length",{maxTimeToFirstByteMs:d,maxLoadTimeMs:h}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=i,this.request=this.fetchSetup(e,n),self.clearTimeout(this.requestTimeout),t.timeout=d&&se(d)?d:h,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(a,e,this.response))},t.timeout),(og(this.request)?this.request.then(self.fetch):self.fetch(this.request)).then(i=>{var r;this.response=this.loader=i;let s=Math.max(self.performance.now(),a.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=h,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(a,e,this.response))},h-(s-a.loading.start)),!i.ok){let{status:e,statusText:t}=i;throw new hf(t||"fetch, bad network response",e,i)}a.loading.first=s,a.total=function(e){let t=e.get("Content-Range");if(t){let e=function(e){let t=hh.exec(e);if(t)return parseInt(t[2])-parseInt(t[1])+1}(t);if(se(e))return e}let i=e.get("Content-Length");if(i)return parseInt(i)}(i.headers)||a.total;let n=null==(r=this.callbacks)?void 0:r.onProgress;return n&&se(t.highWaterMark)?this.loadProgressively(i,a,e,t.highWaterMark,n):l?i.arrayBuffer():"json"===e.responseType?i.json():i.text()}).then(i=>{var r,s;let n=this.response;if(!n)throw Error("loader destroyed");self.clearTimeout(this.requestTimeout),a.loading.end=Math.max(self.performance.now(),a.loading.first);let l=i[o];l&&(a.loaded=a.total=l);let d={url:n.url,data:i,code:n.status},h=null==(r=this.callbacks)?void 0:r.onProgress;h&&!se(t.highWaterMark)&&h(a,e,i,n),null==(s=this.callbacks)||s.onSuccess(d,a,e,n)}).catch(t=>{var i;if(self.clearTimeout(this.requestTimeout),a.aborted)return;let r=t&&t.code||0,s=t?t.message:null;null==(i=this.callbacks)||i.onError({code:r,text:s},e,t?t.details:null,a)})}getCacheAge(){let e=null;if(this.response){let t=this.response.headers.get("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.response?this.response.headers.get(e):null}loadProgressively(e,t,i,r=0,s){let a=new lg,n=e.body.getReader(),l=()=>n.read().then(n=>{if(n.done)return a.dataLength&&s(t,i,a.flush().buffer,e),Promise.resolve(new ArrayBuffer(0));let o=n.value,d=o.length;return t.loaded+=d,d<r||a.dataLength?(a.push(o),a.dataLength>=r&&s(t,i,a.flush().buffer,e)):s(t,i,o.buffer,e),l()}).catch(()=>Promise.reject());return l()}}function hc(e,t){return new self.Request(e.url,t)}class hf extends Error{constructor(e,t,i){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=i}}let hm=/^age:\s*[\d.]+\s*$/im;class hp{constructor(e){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=null,this.loader=null,this.stats=void 0,this.xhrSetup=e&&e.xhrSetup||null,this.stats=new sC,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null}abortInternal(){let 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()))}abort(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(e,t,i){if(this.stats.loading.start)throw Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=i,this.loadInternal()}loadInternal(){let{config:e,context:t}=this;if(!e||!t)return;let i=this.loader=new self.XMLHttpRequest,r=this.stats;r.loading.first=0,r.loaded=0,r.aborted=!1;let s=this.xhrSetup;s?Promise.resolve().then(()=>
16{if(this.loader===i&&!this.stats.aborted)return s(i,t.url)}).catch(e=>{if(this.loader===i&&!this.stats.aborted)return i.open("GET",t.url,!0),s(i,t.url)}).then(()=>{this.loader!==i||this.stats.aborted||this.openAndSendXhr(i,t,e)}).catch(e=>{var s;null==(s=this.callbacks)||s.onError({code:i.status,text:e.message},t,i,r)}):this.openAndSendXhr(i,t,e)}openAndSendXhr(e,t,i){e.readyState||e.open("GET",t.url,!0);let r=t.headers,{maxTimeToFirstByteMs:s,maxLoadTimeMs:a}=i.loadPolicy;if(r)for(let t in r)e.setRequestHeader(t,r[t]);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=s&&se(s)?s:a,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.timeout),e.send()}readystatechange(){let{context:e,loader:t,stats:i}=this;if(!e||!t)return;let r=t.readyState,s=this.config;if(!i.aborted&&r>=2&&(0===i.loading.first&&(i.loading.first=Math.max(self.performance.now(),i.loading.start),s.timeout!==s.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),s.timeout=s.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),s.loadPolicy.maxLoadTimeMs-(i.loading.first-i.loading.start)))),4===r)){var a,n,l;self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;let r=t.status,o="text"===t.responseType?t.responseText:null;if(r>=200&&r<300){let s=null!=o?o:t.response;if(null!=s){i.loading.end=Math.max(self.performance.now(),i.loading.first),i.loaded=i.total="arraybuffer"===t.responseType?s.byteLength:s.length,i.bwEstimate=8e3*i.total/(i.loading.end-i.loading.first);let l=null==(a=this.callbacks)?void 0:a.onProgress;l&&l(i,e,s,t);let o={url:t.responseURL,data:s,code:r};null==(n=this.callbacks)||n.onSuccess(o,i,e,t);return}}let d=s.loadPolicy.errorRetry;a$(d,i.retry,!1,{url:e.url,data:void 0,code:r})?this.retry(d):(sA.error(`${r} while loading ${e.url}`),null==(l=this.callbacks)||l.onError({code:r,text:t.statusText},e,t,i))}}loadtimeout(){if(!this.config)return;let e=this.config.loadPolicy.timeoutRetry;if(a$(e,this.stats.retry,!0))this.retry(e);else{var t;sA.warn(`timeout while loading ${null==(t=this.context)?void 0:t.url}`);let e=this.callbacks;e&&(this.abortInternal(),e.onTimeout(this.stats,this.context,this.loader))}}retry(e){let{context:t,stats:i}=this;this.retryDelay=aU(e,i.retry),i.retry++,sA.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)}loadprogress(e){let t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)}getCacheAge(){let e=null;if(this.loader&&hm.test(this.loader.getAllResponseHeaders())){let t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.loader&&RegExp(`^${e}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}}let hg=sv(sv({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,maxDevicePixelRatio:1/0,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:hp,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:class extends sE{constructor(e){super("abr",e.logger),this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=-1,this.firstSelection=-1,this._nextAutoLevel=-1,this.nextAutoLevelKey="",this.audioTracksByGroup=null,this.co
16decTiers=null,this.timer=-1,this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.rebufferNotice=-1,this.supportedCache={},this.bwEstimator=void 0,this._abandonRulesCheck=e=>{var t;let i,{fragCurrent:r,partCurrent:s,hls:a}=this,{autoLevelEnabled:n,media:l}=a;if(!r||!l)return;let o=performance.now(),d=s?s.stats:r.stats,h=s?s.duration:r.duration,u=o-d.loading.start,c=a.minAutoLevel,f=r.level,m=this._nextAutoLevel;if(d.aborted||d.loaded&&d.loaded===d.total||f<=c){this.clearTimer(),this._nextAutoLevel=-1;return}if(!n)return;let g=m>-1&&m!==f,v=!!e||g;if(!v&&(l.paused||!l.playbackRate||!l.readyState))return;let E=a.mainForwardBufferInfo;if(!v&&null===E)return;let y=this.bwEstimator.getEstimateTTFB(),b=Math.abs(l.playbackRate);if(u<=Math.max(y,h/(2*b)*1e3))return;let T=E?E.len/b:0,_=d.loading.first?d.loading.first-d.loading.start:-1,A=d.loaded&&_>-1,S=this.getBwEstimate(),k=a.levels,L=k[f],R=Math.max(d.loaded,Math.round(h*(r.bitrate||L.averageBitrate)/8)),I=A?u-_:u;I<1&&A&&(I=Math.min(u,8*d.loaded/S));let w=A?1e3*d.loaded/I:0,D=y/1e3,C=w?(R-d.loaded)/w:8*R/S+D;if(C<=T)return;let P=w?8*w:S,x=(null==(t=(null==e?void 0:e.details)||this.hls.latestLevelDetails)?void 0:t.live)===!0,M=this.hls.config.abrBandWidthUpFactor,O=1/0;for(i=f-1;i>c;i--){let e=k[i].maxBitrate,t=!k[i].details||x;if((O=this.getTimeToLoadFrag(D,P,h*e,t))<Math.min(T,h+D))break}if(O>=C||O>10*h)return;A?this.bwEstimator.sample(u-Math.min(y,_),d.loaded):this.bwEstimator.sampleTTFB(u);let N=k[i].maxBitrate;this.getBwEstimate()*M>N&&this.resetEstimator(N);let U=this.findBestLevel(N,c,i,0,T,1,1);U>-1&&(i=U),this.warn(`Fragment ${r.sn}${s?" part "+s.index:""} of level ${f} is loading too slowly;
17      Fragment duration: ${r.duration.toFixed(3)}
18      Time to underbuffer: ${T.toFixed(3)} s
19      Estimated load time for current fragment: ${C.toFixed(3)} s
20      Estimated load time for down switch fragment: ${O.toFixed(3)} s
21      TTFB estimate: ${0|_} ms
22      Current BW estimate: ${se(S)?0|S:"Unknown"} bps
23      New BW estimate: ${0|this.getBwEstimate()} bps
24      Switching to level ${i} @ ${0|N} bps`),a.nextLoadLevel=a.nextAutoLevel=i,this.clearTimer();let F=()=>{if(this.clearTimer(),this.fragCurrent===r&&this.hls.loadLevel===i&&i>0){let e=this.getStarvationDelay();if(this.warn(`Aborting inflight request ${i>0?"and switching down":""}
25      Fragment duration: ${r.duration.toFixed(3)} s
26      Time to underbuffer: ${e.toFixed(3)} s`),r.abortRequests(),this.fragCurrent=this.partCurrent=null,i>c){let t=this.findBestLevel(this.hls.levels[c].bitrate,c,i,0,e,1,1);-1===t&&(t=c),this.hls.nextLoadLevel=this.hls.nextAutoLevel=t,this.resetEstimator(this.hls.levels[t].bitrate)}}};g||C>2*O?F():this.timer=self.setInterval(F,1e3*O),a.trigger(sa.FRAG_LOAD_EMERGENCY_ABORTED,{frag:r,part:s,stats:d})},this.hls=e,this.bwEstimator=this.initEstimator(),this.registerListeners()}resetEstimator(e){e&&(this.log(`setting initial bwe to ${e}`),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()}initEstimator(){let e=this.hls.config;return new sm(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}registerListeners(){let{hls:e}=this;e.on(sa.MANIFEST_LOADING,this.onManifestLoading,this),e.on(sa.FRAG_LOADING,this.onFragLoading,this),e.on(sa.FRAG_LOADED,this.onFragLoaded,this),e.on(sa.FRAG_BUFFERED,this.onFragBuffered,this),e.on(sa.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(sa.LEVEL_LOADED,this.onLevelLoaded,this),e.on(sa.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(sa.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(sa.ERROR,this.onError,this)}unregisterListeners(){let{hls:e}=this;e&&(e.off(sa.MANIFEST_LOADING,this.onManifestLoading,this),e.off(sa.FRAG_LOADING,this.onFragLoading,this),e.off(sa.FRAG_LOADED,this.onFragLoaded,this),e.off(sa.FRAG_BUFFERED,this.onFragBuffered,this),e.off(sa.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(sa.LEVEL_LOADED,this.onLevelLoaded,this),e.off(sa.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(sa.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(sa.ERROR,this.onError,this))}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=this.supportedCache=null,this.fragCurrent=this.partCurrent=null}onManifestLoading(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.supportedCache={},this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()}onLevelsUpdated(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null}onMaxAutoLevelUpdated(){this.firstSelection=-1,this.nextAutoLevelKey=""}onFragLoading(e,t){let i=t.frag;
26if(!this.ignoreFragment(i)){if(!i.bitrateTest){var r;this.fragCurrent=i,this.partCurrent=null!=(r=t.part)?r:null}this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100)}}onLevelSwitching(e,t){this.clearTimer()}onError(e,t){if(!t.fatal)switch(t.details){case ss.BUFFER_ADD_CODEC_ERROR:case ss.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case ss.FRAG_LOAD_TIMEOUT:{let e=t.frag,{fragCurrent:i,partCurrent:r}=this;if(e&&i&&e.sn===i.sn&&e.level===i.level){let t=performance.now(),i=r?r.stats:e.stats,s=t-i.loading.start,a=i.loading.first?i.loading.first-i.loading.start:-1;if(i.loaded&&a>-1){let e=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(s-Math.min(e,a),i.loaded)}else this.bwEstimator.sampleTTFB(s)}}}}getTimeToLoadFrag(e,t,i,r){let s=r?e+this.lastLevelLoadSec:0;return e+i/t+s}onLevelLoaded(e,t){let i=this.hls.config,{loading:r}=t.stats,s=r.end-r.first;se(s)&&(this.lastLevelLoadSec=s/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)}onFragLoaded(e,{frag:t,part:i}){let r=i?i.stats:t.stats;if(t.type===sh&&this.bwEstimator.sampleTTFB(r.loading.first-r.loading.start),!this.ignoreFragment(t)){if(this.clearTimer(),t.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){let e=i?i.duration:t.duration,s=this.hls.levels[t.level],a=(s.loaded?s.loaded.bytes:0)+r.loaded,n=(s.loaded?s.loaded.duration:0)+e;s.loaded={bytes:a,duration:n},s.realBitrate=Math.round(8*a/n)}if(t.bitrateTest){let e={stats:r,frag:t,part:i,id:t.type};this.onFragBuffered(sa.FRAG_BUFFERED,e),t.bitrateTest=!1}else this.lastLoadedFragLevel=t.level}}onFragBuffered(e,t){let{frag:i,part:r}=t,s=null!=r&&r.stats.loaded?r.stats:i.stats;if(s.aborted||this.ignoreFragment(i))return;let a=s.parsing.end-s.loading.start-Math.min(s.loading.first-s.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(a,s.loaded),s.bwEstimate=this.getBwEstimate(),i.bitrateTest?this.bitrateTestDelay=a/1e3:this.bitrateTestDelay=0}ignoreFragment(e){return e.type!==sh||"initSegment"===e.sn}clearTimer(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)}get firstAutoLevel(){let{maxAutoLevel:e,minAutoLevel:t}=this.hls,i=this.getBwEstimate(),r=this.hls.config.maxStarvationDelay,s=this.findBestLevel(i,t,e,0,r,1,1);if(s>-1)return s;let a=this.hls.firstLevel,n=Math.min(Math.max(a,t),e);return this.warn(`Could not find best starting auto level. Defaulting to first in playlist ${a} clamped to ${n}`),n}get forcedAutoLevel(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}get nextAutoLevel(){let e=this.forcedAutoLevel,t=this.bwEstimator.canEstimate(),i=this.lastLoadedFragLevel>-1;if(-1!==e&&(!t||!i||this.nextAutoLevelKey===this.getAutoLevelKey()))return e;let r=t&&i?this.getNextABRAutoLevel():this.firstAutoLevel;if(-1!==e){let t=this.hls.levels;if(t.length>Math.max(e,r)&&t[e].loadError<=t[r].loadError)return e}return this._nextAutoLevel=r,this.nextAutoLevelKey=this.getAutoLevelKey(),r}getAutoLevelKey(){return`${this.getBwEstimate()}
26_${this.getStarvationDelay().toFixed(2)}`}getNextABRAutoLevel(){let{fragCurrent:e,partCurrent:t,hls:i}=this;if(i.levels.length<=1)return i.loadLevel;let{maxAutoLevel:r,config:s,minAutoLevel:a}=i,n=t?t.duration:e?e.duration:0,l=this.getBwEstimate(),o=this.getStarvationDelay(),d=s.abrBandWidthFactor,h=s.abrBandWidthUpFactor;if(o){let e=this.findBestLevel(l,a,r,o,0,d,h);if(e>=0)return this.rebufferNotice=-1,e}let u=n?Math.min(n,s.maxStarvationDelay):s.maxStarvationDelay;if(!o){let e=this.bitrateTestDelay;e&&(u=(n?Math.min(n,s.maxLoadingDelay):s.maxLoadingDelay)-e,this.info(`bitrate test took ${Math.round(1e3*e)}ms, set first fragment max fetchDuration to ${Math.round(1e3*u)} ms`),d=h=1)}let c=this.findBestLevel(l,a,r,o,u,d,h);if(this.rebufferNotice!==c&&(this.rebufferNotice=c,this.info(`${o?"rebuffering expected":"buffer is empty"}, optimal quality level ${c}`)),c>-1)return c;let f=i.levels[a],m=i.loadLevelObj;return m&&(null==f?void 0:f.bitrate)<m.bitrate?a:i.loadLevel}getStarvationDelay(){let e=this.hls,t=e.media;if(!t)return 1/0;let i=t&&0!==t.playbackRate?Math.abs(t.playbackRate):1,r=e.mainForwardBufferInfo;return(r?r.len:0)/i}getBwEstimate(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate}findBestLevel(e,t,i,r,s,a,n){var l,o;let d,h=r+s,u=this.lastLoadedFragLevel,c=-1===u?this.hls.firstLevel:u,{fragCurrent:f,partCurrent:m}=this,{levels:g,allAudioTracks:v,loadLevel:E,config:y}=this.hls;if(1===g.length)return 0;let b=g[c],T=!!(null!=(l=this.hls.latestLevelDetails)&&l.live),_=-1===E||-1===u,A="SDR",S=(null==b?void 0:b.frameRate)||0,{audioPreference:k,videoPreference:L}=y,R=this.audioTracksByGroup||(this.audioTracksByGroup=a_(v)),I=-1;if(_){if(-1!==this.firstSelection)return this.firstSelection;let r=function(e,t,i,r,s){let a=Object.keys(e),n=null==r?void 0:r.channels,l=null==r?void 0:r.audioCodec,o=null==s?void 0:s.videoCodec,d=n&&2===parseInt(n),h=!1,u=!1,
26c=1/0,f=1/0,m=1/0,g=1/0,v=0,E=[],{preferHDR:y,allowedVideoRanges:b}=function(e,t){let i=!1,r=[];if(e&&(i="SDR"!==e,r=[e]),t){let e="SDR"!==(r=t.allowedVideoRanges||ap.slice(0)).join("")&&!t.videoCodec;(i=void 0!==t.preferHDR?t.preferHDR:e&&function(){if("function"==typeof matchMedia){let e=matchMedia("(dynamic-range: high)"),t=matchMedia("bad query");if(e.media!==t.media)return!0===e.matches}return!1}())||(r=["SDR"])}return{preferHDR:i,allowedVideoRanges:r}}(t,s);for(let t=a.length;t--;){let i=e[a[t]];h||(h=i.channels[2]>0),c=Math.min(c,i.minHeight),f=Math.min(f,i.minFramerate),m=Math.min(m,i.minBitrate),b.filter(e=>i.videoRanges[e]>0).length>0&&(u=!0)}c=se(c)?c:0,f=se(f)?f:0;let T=Math.max(1080,c),_=Math.max(30,f);i=Math.max(m=se(m)?m:i,i),u||(t=void 0);let A=a.length>1;return{codecSet:a.reduce((t,r)=>{let s=e[r];if(r===t)return t;if(E=u?b.filter(e=>s.videoRanges[e]>0):[],A){if(s.minBitrate>i)return aT(r,`min bitrate of ${s.minBitrate} > current estimate of ${i}`),t;if(!s.hasDefaultAudio)return aT(r,"no renditions with default or auto-select sound found"),t;if(l&&r.indexOf(l.substring(0,4))%5!=0)return aT(r,`audio codec preference "${l}" not found`),t;if(n&&!d){if(!s.channels[n])return aT(r,`no renditions with ${n} channel sound found (channels options: ${Object.keys(s.channels)})`),t}else if((!l||d)&&h&&0===s.channels["2"])return aT(r,"no renditions with stereo sound found"),t;if(s.minHeight>T)return aT(r,`min resolution of ${s.minHeight} > maximum of ${T}`),t;if(s.minFramerate>_)return aT(r,`min framerate of ${s.minFramerate} > maximum of ${_}`),t;if(!E.some(e=>s.videoRanges[e]>0))return aT(r,`no variants with VIDEO-RANGE of ${ab(E)} found`),t;if(o&&r.indexOf(o.substring(0,4))%5!=0)return aT(r,`video codec preference "${o}" not found`),t;if(s.maxScore<v)return aT(r,`max score of ${s.maxScore} < selected max of ${v}`),t}return t&&(at(r)>=at(t)||s.fragmentError>e[t].fragmentError)?t:(g=s.minIndex,v=s.maxScore,r)},void 0),videoRanges:E,preferHDR:y,minFramerate:f,minBitrate:m,minIndex:g}}(this.codecTiers||(this.codecTiers=g.slice(t,i+1).reduce((e,t,i)=>{if(!t.codecSet)return e;let r=t.audioGroups,s=e[t.codecSet];s||(e[t.codecSet]=s={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,minIndex:i,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!r,fragmentError:0}),s.minBitrate=Math.min(s.minBitrate,t.bitrate);let a=Math.min(t.height,t.width);return s.minHeight=Math.min(s.minHeight,a),s.minFramerate=Math.min(s.minFramerate,t.frameRate),s.minIndex=Math.min(s.minIndex,i),s.maxScore=Math.max(s.maxScore,t.score),s.fragmentError+=t.fragmentError,s.videoRanges[t.videoRange]=(s.videoRanges[t.videoRange]||0)+1,r&&r.forEach(e=>{if(!e)return;let t=R.groups[e];t&&(s.hasDefaultAudio=s.hasDefaultAudio||R.hasDefaultAudio?t.hasDefault:t.hasAutoSelect||!R.hasDefaultAudio&&!R.hasAutoSelectAudio,Object.keys(t.channels).forEach(e=>{s.channels[e]=(s.channels[e]||0)+t.channels[e]}))}),e},{})),A,e,k,L),{codecSet:s,videoRanges:a,minFramerate:n,minBitrate:l,minIndex:o,preferHDR:h}=r;I=o,d=s,A=h?a[a.length-1]:a[0],S=n,e=Math.max(e,l),this.log(`picked start tier ${ab(r)}`)}else d=null==b?void 0:b.codecSet,A=null==b?void 0:b.videoRange;let w=m?m.duration:f?f.duration:0,D=this.bwEstimator.getEstimateTTFB()/1e3,C=[];for(let l=i;l>=t;l--){let t,f=g[l],v=l>c;if(!f)continue;if(y.useMediaCapabilities&&!f.supportedResult&&!f.supportedPromise){let t=navigator.mediaCapabilities;"function"==typeof(null==t?void 0:t.decodingInfo)&&function(e,t,i,r,s,a){let n=e.videoCodec,l=e.audioCodec?e.audioGroups:null,o=null==a?void 0:a.audioCodec,d=null==a?void 0:a.channels,h=d?parseInt(d):o?1/0:2,u=null;if(null!=l&&l.length)try{u=1===l.length&&l[0]?t.groups[l[0]].channels:l.reduce((e,i)=>{if(i){let r=t.groups[i];if(!r)throw Error(`Audio track group ${i} not found`);Object.keys(r.channels).forEach(t=>{e[t]=(e[t]||0)+r.channels[t]})}return e},{2:0})}catch(e){return!0}return void 0!==n&&(n.split(",").some(e=>s2(e))||e.width>1920&&e.height>1088||e.height>1920&&e.width>1088||e.frameRate>Math.max(r,30)||"SDR"!==e.videoRange&&e.videoRange!==i||e.bitrate>Math.max(s,8e6))||!!u&&se(h)&&Object.keys(u).some(e=>parseInt(e)>h)}
26(f,R,A,S,e,k)?(f.supportedPromise=ac(f,R,t,this.supportedCache),f.supportedPromise.then(e=>{if(!this.hls)return;f.supportedResult=e;let t=this.hls.levels,i=t.indexOf(f);e.error?this.warn(`MediaCapabilities decodingInfo error: "${e.error}" for level ${i} ${ab(e)}`):e.supported?e.decodingInfoResults.some(e=>!1===e.smooth||!1===e.powerEfficient)&&this.log(`MediaCapabilities decodingInfo for level ${i} not smooth or powerEfficient: ${ab(e)}`):(this.warn(`Unsupported MediaCapabilities decodingInfo result for level ${i} ${ab(e)}`),i>-1&&t.length>1&&(this.log(`Removing unsupported level ${i}`),this.hls.removeLevel(i),-1===this.hls.loadLevel&&(this.hls.nextLoadLevel=0)))}).catch(e=>{this.warn(`Error handling MediaCapabilities decodingInfo: ${e}`)})):f.supportedResult=ah}if((d&&f.codecSet!==d||A&&f.videoRange!==A||v&&S>f.frameRate||!v&&S>0&&S<f.frameRate||null!=(o=f.supportedResult)&&null!=(o=o.decodingInfoResults)&&o.some(e=>!1===e.smooth))&&(!_||l!==I)){C.push(l);continue}let b=f.details,L=(m?null==b?void 0:b.partTarget:null==b?void 0:b.averagetargetduration)||w;t=v?n*e:a*e;let P=w&&r>=2*w&&0===s?f.averageBitrate:f.maxBitrate,x=this.getTimeToLoadFrag(D,t,P*L,void 0===b);if(t>=P&&(l===u||0===f.loadError&&0===f.fragmentError)&&(x<=D||!se(x)||T&&!this.bitrateTestDelay||x<h)){let e=this.forcedAutoLevel;return l!==E&&(-1===e||e!==E)&&(C.length&&this.trace(`Skipped level(s) ${C.join(",")} of ${i} max with CODECS and VIDEO-RANGE:"${g[C[0]].codecs}" ${g[C[0]].videoRange}; not compatible with "${d}" ${A}`),this.info(`switch candidate:${c}->${l} adjustedbw(${Math.round(t)})-bitrate=${Math.round(t-P)} ttfb:${D.toFixed(1)} avgDuration:${L.toFixed(1)} maxFetchDuration:${h.toFixed(1)} fetchDuration:${x.toFixed(1)} firstSelection:${_} codecSet:${f.codecSet} videoRange:${f.videoRange} hls.loadLevel:${E}`)),_&&(this.firstSelection=l),l}}return -1}set nextAutoLevel(e){let t=this.deriveNextAutoLevel(e);this._nextAutoLevel!==t&&(this.nextAutoLevelKey="",this._nextAutoLevel=t)}deriveNextAutoLevel(e){let{maxAutoLevel:t,minAutoLevel:i}=this.hls;return Math.min(Math.max(e,i),t)}},bufferController:class extends sE{constructor(e,t){super("buffer-controller",e.logger),this.hls=void 0,this.fragmentTracker=void 0,this.details=null,this._objectUrl=null,this.operationQueue=null,this.bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.blockedAudioAppend=null,this.lastVideoAppendEnd=0,this.appendSource=void 0,this.transferData=void 0,this.overrides=void 0,this.appendErrors={audio:0,video:0,audiovideo:0},this.tracks={},this.sourceBuffers=[[null,null],[null,null]],this._onEndStreaming=e=>{var t;this.hls&&(null==(t=this.mediaSource)?void 0:t.readyState)==="open"&&this.hls.pauseBuffering()},this._onStartStreaming=e=>{this.hls&&this.hls.resumeBuffering()},this._onMediaSourceOpen=e=>{let{media:t,mediaSource:i}=this;e&&this.log("Media source opened"),t&&i&&(i.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("emptied",this._onMediaEmptied),this.updateDuration(),this.hls.trigger(sa.MEDIA_ATTACHED,{media:t,mediaSource:i}),null!==this.mediaSource&&this.checkPendingTracks())},this._onMediaSourceClose=()=>{this.log("Media source closed")},this._onMediaSourceEnded=()=>{this.log("Media source ended")},this._onMediaEmptied=()=>{let{mediaSrc:e,_objectUrl:t}=this;e!==t&&this.error(`Media element src was set while attaching MediaSource (${t} > ${e})`)},this.hls=e,this.fragmentTracker=t,this.appendSource=function(e){return"u">typeof self&&e===self.ManagedMediaSource}(sS(e.config.preferManagedMediaSource)),this.initTracks(),this.registerListeners()}hasSourceTypes(){return Object.keys(this.tracks).length>0}destroy(){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}registerListeners(){let{hls:e}=this;
26e.on(sa.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(sa.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(sa.MANIFEST_LOADING,this.onManifestLoading,this),e.on(sa.MANIFEST_PARSED,this.onManifestParsed,this),e.on(sa.BUFFER_RESET,this.onBufferReset,this),e.on(sa.BUFFER_APPENDING,this.onBufferAppending,this),e.on(sa.BUFFER_CODECS,this.onBufferCodecs,this),e.on(sa.BUFFER_EOS,this.onBufferEos,this),e.on(sa.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(sa.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(sa.FRAG_PARSED,this.onFragParsed,this),e.on(sa.FRAG_CHANGED,this.onFragChanged,this),e.on(sa.ERROR,this.onError,this)}unregisterListeners(){let{hls:e}=this;e.off(sa.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(sa.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(sa.MANIFEST_LOADING,this.onManifestLoading,this),e.off(sa.MANIFEST_PARSED,this.onManifestParsed,this),e.off(sa.BUFFER_RESET,this.onBufferReset,this),e.off(sa.BUFFER_APPENDING,this.onBufferAppending,this),e.off(sa.BUFFER_CODECS,this.onBufferCodecs,this),e.off(sa.BUFFER_EOS,this.onBufferEos,this),e.off(sa.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(sa.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(sa.FRAG_PARSED,this.onFragParsed,this),e.off(sa.FRAG_CHANGED,this.onFragChanged,this),e.off(sa.ERROR,this.onError,this)}transferMedia(){let{media:e,mediaSource:t}=this;if(!e)return null;let i={};if(this.operationQueue){let e=this.isUpdating();e||this.operationQueue.removeBlockers();let t=this.isQueued();(e||t)&&this.warn(`Transfering MediaSource with${t?" operations in queue":""}${e?" updating SourceBuffer(s)":""} ${this.operationQueue}`),this.operationQueue.destroy()}let r=this.transferData;return!this.sourceBufferCount&&r&&r.mediaSource===t?sp(i,r.tracks):this.sourceBuffers.forEach(e=>{let[t]=e;t&&(i[t]=sp({},this.tracks[t]),this.removeBuffer(t)),e[0]=e[1]=null}),{media:e,mediaSource:t,tracks:i}}initTracks(){this.sourceBuffers=[[null,null],[null,null]],this.tracks={},this.resetQueue(),this.resetAppendErrors(),this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.lastVideoAppendEnd=0}onManifestLoading(){this.bufferCodecEventsTotal=0,this.details=null}onManifestParsed(e,t){var i;let r=2;(!t.audio||t.video)&&t.altAudio||(r=1),this.bufferCodecEventsTotal=r,this.log(`${r} bufferCodec event(s) expected.`),null!=(i=this.transferData)&&i.mediaSource&&this.sourceBufferCount&&r&&this.bufferCreated()}onMediaAttaching(e,t){let i=this.media=t.media;this.transferData=this.overrides=void 0;let r=sS(this.appendSource);if(r){let e=!!t.mediaSource;(e||t.overrides)&&(this.transferData=t,this.overrides=t.overrides);let n=this.mediaSource=t.mediaSource||new r;if(this.assignMediaSource(n),e)this._objectUrl=i.src,this.attachTransferred();else{let e=this._objectUrl=self.URL.createObjectURL(n);if(this.appendSource)try{var s,a;let t;i.removeAttribute("src");let r=self.ManagedMediaSource;i.disableRemotePlayback=i.disableRemotePlayback||r&&n instanceof r,ow(i),s=i,a=e,(t=self.document.createElement("source")).type="video/mp4",t.src=a,s.appendChild(t),i.load()}catch(t){i.src=e}else i.src=e}i.addEventListener("emptied",this._onMediaEmptied)}}assignMediaSource(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))}attachTransferred(){let e=this.media,t=this.transferData;if(!t||!e)return;let i=this.tracks,r=t.tracks,s=r?Object.keys(r):null,a=s?s.length:0,n=()=>{Promise.resolve().then(()=>{this.media&&this.mediaSourceOpenOrEnded&&this._onMediaSourceOpen()})};if(r&&s&&a){if(!this.tracksReady){this.hls.config.startFragPrefetch=!0,this.log("attachTransferred: waiting for SourceBuffer track info");return}if(this.log(`attachTransferred: (bufferCodecEventsTotal ${this.bufferCodecEventsTotal})
27required tracks: ${ab(i,(e,t)=>"initSegment"===e?void 0:t)};
28transfer tracks: ${ab(r,(e,t)=>"initSegment"===e?void 0:t)}}`),!sk(r,i)){t.mediaSource=null,t.tracks=void 0;let s=e.currentTime,a=this.details,n=Math.max(s,(null==a?void 0:a.fragments[0].start)||0);return n-s>1?void this.log(`attachTransferred: waiting for playback to reach new tracks start time ${s} -> ${n}`):(this.warn(`attachTransferred: resetting MediaSource for incompatible tracks ("${Object.keys(r)}"->"${Object.keys(i)}") start time: ${n} currentTime: ${s}`),this.onMediaDetaching(sa.MEDIA_DETACHING,{}
28),this.onMediaAttaching(sa.MEDIA_ATTACHING,t),void(e.currentTime=n))}this.transferData=void 0,s.forEach(e=>{let t=r[e];if(t){let i=t.buffer;if(i){let r=this.fragmentTracker,s=t.id;if(r.hasFragments(s)||r.hasParts(s)){let t=a6.getBuffered(i);r.detectEvictedFragments(e,t,s,null,!0)}let a=oD(e),n=[e,i];this.sourceBuffers[a]=n,i.updating&&this.operationQueue&&this.operationQueue.prependBlocker(e),this.trackSourceBuffer(e,t)}}}),n(),this.bufferCreated()}else this.log("attachTransferred: MediaSource w/o SourceBuffers"),n()}get mediaSourceOpenOrEnded(){var e;let t=null==(e=this.mediaSource)?void 0:e.readyState;return"open"===t||"ended"===t}onMediaDetaching(e,t){let i=!!t.transferMedia;this.transferData=this.overrides=void 0;let{media:r,mediaSource:s,_objectUrl:a}=this;if(s){if(this.log(`media source ${i?"transferring":"detaching"}`),i)this.sourceBuffers.forEach(([e])=>{e&&this.removeBuffer(e)}),this.resetQueue();else{if(this.mediaSourceOpenOrEnded){let e="open"===s.readyState;try{let t=s.sourceBuffers;for(let i=t.length;i--;)e&&t[i].abort(),s.removeSourceBuffer(t[i]);e&&s.endOfStream()}catch(e){this.warn(`onMediaDetaching: ${e.message} while calling endOfStream`)}}this.sourceBufferCount&&this.onBufferReset()}s.removeEventListener("sourceopen",this._onMediaSourceOpen),s.removeEventListener("sourceended",this._onMediaSourceEnded),s.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(s.removeEventListener("startstreaming",this._onStartStreaming),s.removeEventListener("endstreaming",this._onEndStreaming)),this.mediaSource=null,this._objectUrl=null}r&&(r.removeEventListener("emptied",this._onMediaEmptied),i||(a&&self.URL.revokeObjectURL(a),this.mediaSrc===a?(r.removeAttribute("src"),this.appendSource&&ow(r),r.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.media=null),this.hls.trigger(sa.MEDIA_DETACHED,t)}onBufferReset(){this.sourceBuffers.forEach(([e])=>{e&&this.resetBuffer(e)}),this.initTracks()}resetBuffer(e){var t,i;let r=null==(t=this.tracks[e])?void 0:t.buffer;if(this.removeBuffer(e),r)try{null!=(i=this.mediaSource)&&i.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(r)}catch(t){this.warn(`onBufferReset ${e}`,t)}delete this.tracks[e]}removeBuffer(e){this.removeBufferListeners(e),this.sourceBuffers[oD(e)]=[null,null];let t=this.tracks[e];t&&(t.buffer=void 0)}resetQueue(){this.operationQueue&&this.operationQueue.destroy(),this.operationQueue=new ok(this.tracks)}onBufferCodecs(e,t){var i;let r=this.tracks,s=Object.keys(t);this.log(`BUFFER_CODECS: "${s}" (current SB count ${this.sourceBufferCount})`);let a="audiovideo"in t&&(r.audio||r.video)||r.audiovideo&&("audio"in t||"video"in t),n=!a&&this.sourceBufferCount&&this.media&&s.some(e=>!r[e]);a||n?this.warn(`Unsupported transition between "${Object.keys(r)}" and "${s}" SourceBuffers`):(s.forEach(e=>{var i,s;let{id:a,codec:n,levelCodec:l,container:o,metadata:d,supplemental:h}=t[e],u=r[e],c=null==(i=this.transferData)||null==(i=i.tracks)?void 0:i[e],f=null!=c&&c.buffer?c:u,m=(null==f?void 0:f.pendingCodec)||(null==f?void 0:f.codec),g=null==f?void 0:f.levelCodec;u||(u=r[e]={buffer:void 0,listeners:[],codec:n,supplemental:h,container:o,levelCodec:l,metadata:d,id:a});let v=aa(m,g),E=null==v?void 0:v.replace(oL,"$1"),y=aa(n,l),b=null==(s=y)?void 0:s.replace(oL,"$1");y&&v&&E!==b&&("audio"===e.slice(0,5)&&(y=as(y,this.appendSource)),this.log(`switching codec ${m} to ${y}`),y!==(u.pendingCodec||u.codec)&&(u.pendingCodec=y),u.container=o,this.appendChangeType(e,o,y))}),(this.tracksReady||this.sourceBufferCount)&&(t.tracks=this.sourceBufferTracks),!this.sourceBufferCount&&(!(this.bufferCodecEventsTotal>1)||this.tracks.video||t.video||(null==(i=t.audio)?void 0:i.id)!=="main"||(this.log("Main audio-only"),this.bufferCodecEventsTotal=1),this.mediaSourceOpenOrEnded&&this.checkPendingTracks()))}get sourceBufferTracks(){return Object.keys(this.tracks).reduce((e,t)=>{let i=this.tracks[t];return e[t]={id:i.id,container:i.container,codec:i.codec,levelCodec:i.levelCodec},e},{})}appendChangeType(e,t,i){let r=`${t};codecs=${i}`,s={label:`change-type=${r}`,execute:()=>{let s=this.tracks[e];if(s){let a=s.buffer;null!=a&&a.changeType&&(this.log(`changing ${e} sourceBuffer type to ${r}`),a.changeType(r),s.codec=i,s.container=t)}this.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:t=>{this.warn(`Failed to change ${e} SourceBuffer type`,t)}};this.append(s,e,this.isPending(this.tracks[e]))}blockAudio(e){var t;let i=e.start,r=i+.05*e.duration;if((null==(t=this.fragmentTracker.getAppendedFrag(i,sh))?void 0:t.gap)===!0)return;let s={label:"block-audio",execute:()=>{var e;let t=this.tracks.video;(this.lastVideoAppendEnd>r||null!=t&&t.buffer&&a6.isBuffered(t.buffer,r)||(null==(e=this.fragmentTracker.getAppendedFrag(r,sh))?void 0:e.gap)===!0)&&(this.blockedAudioAppend=null,this.shiftAndExecuteNext("audio"))},onStart:()=>{},onComplete:()=>{},onError:e=>{this.warn("Error executing block-audio operation",e)}};this.blockedAudioAppend={op:s,frag:e},this.append(s,"audio",!0)}unblockAudio(){let{blockedAudioAppend:e,operationQueue:t}=this;e&&t&&(this.blockedAudioAppend=null,t.unblockAudio(e.op))}onBufferAppending(e,t){let{tracks:i}=this,{data:r,type:s,parent:a,frag:n,part:l,chunkMeta:o,offset:d}=t,h=o.buffering[s],{sn:u,cc:c}=n,f=self.performance.now();h.start=f;let m=n.stats.buffering,g=l?l.stats.buffering:null;0===m.start&&(m.start=f),g&&0===g.start&&(g.start=f);let v=i.audio,E=!1;"audio"===s&&(null==v?void 0:v.container)==="audio/mpeg"&&(E=!this.lastMpegAudioChunk||1===o.id||this.lastMpegAudioChunk.sn!==o.sn,this.lastMpegAudioChunk=o);let y=i.video,b=null==y?void 0:y.buffer;if(b&&"initSegment"!==u){let e=l||n,t=this.blockedAudioAppend;if("audio"!==s||"main"===a||this.blockedAudioAppend||y.ending||y.ended){if("video"===s){let i=e.end;if(t){let e=t.frag.start;(i>e||i<this.lastVideoAppendEnd||a6.isBuffered(b,e))&&this.unblockAudio()}this.lastVideoAppendEnd=i}}else{let t=e.start+.05*e.duration,i=b.buffered,r=this.currentOp("video");(i.length||r)&&(r||a6.isBuffered(b,t)||!(this.lastVideoAppendEnd<t))||this.blockAudio(e)}}let T=(l||n).start,_={label:`append-${s}`,execute:()=>{var e;h.executeStart=self.performance.now();let t=null==(e=this.tracks[s])?void 0:e.buffer;t&&(E?this.updateTimestampOffset(t,T,.1,s,u,c):void 0!==d&&se(d)&&this.updateTimestampOffset(t,d,1e-6,s,u,c)),this.appendExecutor(r,s)},onStart:()=>{},onComplete:()=>{let e=self.performance.now();h.executeEnd=h.end=e,0===m.first&&(m.first=e),g&&0===g.first&&(g.first=e);let t={};
28this.sourceBuffers.forEach(([e,i])=>{e&&(t[e]=a6.getBuffered(i))}),this.appendErrors[s]=0,"audio"===s||"video"===s?this.appendErrors.audiovideo=0:(this.appendErrors.audio=0,this.appendErrors.video=0),this.hls.trigger(sa.BUFFER_APPENDED,{type:s,frag:n,part:l,chunkMeta:o,parent:n.type,timeRanges:t})},onError:e=>{var t;let i={type:sr.MEDIA_ERROR,parent:n.type,details:ss.BUFFER_APPEND_ERROR,sourceBufferName:s,frag:n,part:l,chunkMeta:o,error:e,err:e,fatal:!1},r=null==(t=this.media)?void 0:t.error;if(e.code===DOMException.QUOTA_EXCEEDED_ERR||"QuotaExceededError"==e.name||"quota"in e)i.details=ss.BUFFER_FULL_ERROR;else if(e.code===DOMException.INVALID_STATE_ERR&&this.mediaSourceOpenOrEnded&&!r)i.errorAction=aH(!0);else if(e.name===oR&&0===this.sourceBufferCount)i.errorAction=aH(!0);else{let e=++this.appendErrors[s];this.warn(`Failed ${e}/${this.hls.config.appendErrorMaxRetry} times to append segment in "${s}" sourceBuffer (${r||"no media error"})`),(e>=this.hls.config.appendErrorMaxRetry||r)&&(i.fatal=!0)}this.hls.trigger(sa.ERROR,i)}};this.log(`queuing "${s}" append sn: ${u}${l?" p: "+l.index:""} of ${n.type===sh?"level":"track"} ${n.level} cc: ${c}`),this.append(_,s,this.isPending(this.tracks[s]))}getFlushOp(e,t,i){return this.log(`queuing "${e}" remove ${t}-${i}`),{label:"remove",execute:()=>{this.removeExecutor(e,t,i)},onStart:()=>{},onComplete:()=>{this.hls.trigger(sa.BUFFER_FLUSHED,{type:e})},onError:r=>{this.warn(`Failed to remove ${t}-${i} from "${e}" SourceBuffer`,r)}}}onBufferFlushing(e,t){let{type:i,startOffset:r,endOffset:s}=t;i?this.append(this.getFlushOp(i,r,s),i):this.sourceBuffers.forEach(([e])=>{e&&this.append(this.getFlushOp(e,r,s),e)})}onFragParsed(e,t){let{frag:i,part:r}=t,s=[],a=r?r.elementaryStreams:i.elementaryStreams;a[sM]?s.push("audiovideo"):(a[sP]&&s.push("audio"),a[sx]&&s.push("video"));let n=()=>{let e=self.performance.now();i.stats.buffering.end=e,r&&(r.stats.buffering.end=e);let t=r?r.stats:i.stats;this.hls.trigger(sa.FRAG_BUFFERED,{frag:i,part:r,stats:t,id:i.type})};0===s.length&&this.warn(`Fragments must have at least one ElementaryStreamType set. type: ${i.type} level: ${i.level} sn: ${i.sn}`),this.blockBuffers(n,s).catch(e=>{this.warn(`Fragment buffered callback ${e}`),this.stepOperationQueue(this.sourceBufferTypes)})}onFragChanged(e,t){this.trimBuffers()}get bufferedToEnd(){return this.sourceBufferCount>0&&!this.sourceBuffers.some(([e])=>{if(e){let t=this.tracks[e];if(t)return!t.ended||t.ending}return!1})}onBufferEos(e,t){var i;this.sourceBuffers.forEach(([e])=>{if(e){let i=this.tracks[e];(!t.type||t.type===e)&&(i.ending=!0,i.ended||(i.ended=!0,this.log(`${e} buffer reached EOS`)))}});let r=(null==(i=this.overrides)?void 0:i.endOfStream)!==!1;this.sourceBufferCount>0&&!this.sourceBuffers.some(([e])=>{var t;return e&&!(null!=(t=this.tracks[e])&&t.ended)})?r?(this.log("Queueing EOS"),this.blockUntilOpen(()=>{this.tracksEnded();let{mediaSource:e}=this;if(!e||"open"!==e.readyState){e&&this.log(`Could not call mediaSource.endOfStream(). mediaSource.readyState: ${e.readyState}`);return}this.log("Calling mediaSource.endOfStream()"),e.endOfStream(),this.hls.trigger(sa.BUFFERED_TO_END,void 0)})):(this.tracksEnded(),this.hls.trigger(sa.BUFFERED_TO_END,void 0)):"video"===t.type&&this.unblockAudio()}tracksEnded(){this.sourceBuffers.forEach(([e])=>{if(null!==e){let t=this.tracks[e];t&&(t.ending=!1)}})}onLevelUpdated(e,{details:t}){t.fragments.length&&(this.details=t,this.updateDuration())}updateDuration(){this.blockUntilOpen(()=>{let e=this.getDurationAndRange();e&&this.updateMediaSource(e)})}onError(e,t){if(t.details===ss.BUFFER_APPEND_ERROR&&t.frag){var i;let e=null==(i=t.errorAction)?void 0:i.nextAutoLevel;se(e)&&e!==t.frag.level&&this.resetAppendErrors()}}resetAppendErrors(){this.appendErrors={audio:0,video:0,audiovideo:0}}trimBuffers(){let{hls:e,details:t,media:i}=this;if(!i||null===t||!this.sourceBufferCount)return;let r=e.config,s=i.currentTime,a=t.levelTargetDuration,n=t.live&&null!==r.liveBackBufferLength?r.liveBackBufferLength:r.backBufferLength;if(se(n)&&n>=0){let e=Math.max(n,a),t=Math.floor(s/a)*a-e;this.flushBackBuffer(s,a,t)}let l=r.frontBufferFlushThreshold;if(se(l)&&l>0){let e=Math.max(Math.max(r.maxBufferLength,l),a),t=Math.floor(s/a)*a+e;this.flushFrontBuffer(s,a,t)}}
28flushBackBuffer(e,t,i){this.sourceBuffers.forEach(([e,t])=>{if(t){let s=a6.getBuffered(t);if(s.length>0&&i>s.start(0)){var r;this.hls.trigger(sa.BACK_BUFFER_REACHED,{bufferEnd:i});let t=this.tracks[e];if(null!=(r=this.details)&&r.live)this.hls.trigger(sa.LIVE_BACK_BUFFER_REACHED,{bufferEnd:i});else if(null!=t&&t.ended)return void this.log(`Cannot flush ${e} back buffer while SourceBuffer is in ended state`);this.hls.trigger(sa.BUFFER_FLUSHING,{startOffset:0,endOffset:i,type:e})}}})}flushFrontBuffer(e,t,i){this.sourceBuffers.forEach(([t,r])=>{if(r){let s=a6.getBuffered(r),a=s.length;if(a<2)return;let n=s.start(a-1),l=s.end(a-1);i>n||e>=n&&e<=l||this.hls.trigger(sa.BUFFER_FLUSHING,{startOffset:n,endOffset:1/0,type:t})}})}getDurationAndRange(){var e;let{details:t,mediaSource:i}=this;if(!t||!this.media||(null==i?void 0:i.readyState)!=="open")return null;let r=t.edge;if(t.live&&this.hls.config.liveDurationInfinity){if(t.fragments.length&&i.setLiveSeekableRange){let e=Math.max(0,t.fragmentStart),i=Math.max(e,r);return{duration:1/0,start:e,end:i}}return{duration:1/0}}let s=null==(e=this.overrides)?void 0:e.duration;if(s)return se(s)?{duration:s}:null;let a=this.media.duration;return r>(se(i.duration)?i.duration:0)&&r>a||!se(a)?{duration:r}:null}updateMediaSource({duration:e,start:t,end:i}){let r=this.mediaSource;this.media&&r&&"open"===r.readyState&&(r.duration!==e&&(se(e)&&this.log(`Updating MediaSource duration to ${e.toFixed(3)}`),r.duration=e),void 0!==t&&void 0!==i&&(this.log(`MediaSource duration is set to ${r.duration}. Setting seekable range to ${t}-${i}.`),r.setLiveSeekableRange(t,i)))}get tracksReady(){let e=this.pendingTrackCount;return e>0&&(e>=this.bufferCodecEventsTotal||this.isPending(this.tracks.audiovideo))}checkPendingTracks(){let{bufferCodecEventsTotal:e,pendingTrackCount:t,tracks:i}=this;if(this.log(`checkPendingTracks (pending: ${t} codec events expected: ${e}) ${ab(i)}`),this.tracksReady){var r;let e=null==(r=this.transferData)?void 0:r.tracks;e&&Object.keys(e).length?this.attachTransferred():this.createSourceBuffers()}}bufferCreated(){if(this.sourceBufferCount){let e={};this.sourceBuffers.forEach(([t,i])=>{if(t){let r=this.tracks[t];e[t]={buffer:i,container:r.container,codec:r.codec,supplemental:r.supplemental,levelCodec:r.levelCodec,id:r.id,metadata:r.metadata}}}),this.hls.trigger(sa.BUFFER_CREATED,{tracks:e}),this.log(`SourceBuffers created. Running queue: ${this.operationQueue}`),this.sourceBuffers.forEach(([e])=>{this.executeNext(e)})}else{let e=Error("could not create source buffer for media codec(s)");this.hls.trigger(sa.ERROR,{type:sr.MEDIA_ERROR,details:ss.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:e,reason:e.message})}}createSourceBuffers(){let{tracks:e,sourceBuffers:t,mediaSource:i}=this;if(!i)throw Error("createSourceBuffers called when mediaSource was null");for(let s in e){let a=e[s];if(this.isPending(a)){let e=this.getTrackCodec(a,s),n=`${a.container};codecs=${e}`;a.codec=e,this.log(`creating sourceBuffer(${n})${this.currentOp(s)?" Queued":""} ${ab(a)}`);try{let e=i.addSourceBuffer(n),r=oD(s),l=[s,e];t[r]=l,a.buffer=e}catch(e){var r;this.error(`error while trying to add sourceBuffer: ${e.message}`),this.shiftAndExecuteNext(s),null==(r=this.operationQueue)||r.removeBlockers(),delete this.tracks[s],this.hls.trigger(sa.ERROR,{type:sr.MEDIA_ERROR,details:ss.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:e,sourceBufferName:s,mimeType:n,parent:a.id});return}this.trackSourceBuffer(s,a)}}this.bufferCreated()}getTrackCodec(e,t){let i=e.supplemental,r=e.codec;i&&("video"===t||"audiovideo"===t)&&s6(i,"video")&&(r=function(e,t){let i=[];if(e){let t=e.split(",");for(let e=0;e<t.length;e++)s8(t[e],"video")||i.push(t[e])}return t&&i.push(t),i.join(",")}(r,i));let s=aa(r,e.levelCodec);return s?"audio"===t.slice(0,5)?as(s,this.appendSource):s:""}trackSourceBuffer(e,t){let i=t.buffer;if(!i)return;let r=this.getTrackCodec(t,e);this.tracks[e]={buffer:i,codec:r,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)=>{let i=t.removedRanges;null!=i&&i.length&&this.hls.trigger(sa.BUFFER_FLUSHED,{type:e})})}get mediaSrc(){var e,t;let i=(null==(e=this.media)||null==(t=e.querySelector)?void 0:t.call(e,"source"))||this.media;return null==i?void 0:i.src}onSBUpdateStart(e){let t=this.currentOp(e);t&&t.onStart()}onSBUpdateEnd(e){var t;if((null==(t=this.mediaSource)?void 0:t.readyState)==="closed")return void this.resetBuffer(e);let i=this.currentOp(e);i&&(i.onComplete(),this.shiftAndExecuteNext(e))}onSBUpdateError(e,t){var i;let r=Error(`${e} SourceBuffer error. MediaSource readyState: ${null==(i=this.mediaSource)?void 0:i.readyState}`);this.error(`${r}`,t),this.hls.trigger(sa.ERROR,{type:sr.MEDIA_ERROR,details:ss.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:r,fatal:!1});let s=this.currentOp(e);s&&s.onError(r)}updateTimestampOffset(e,t,i,r,s,a){Math.abs(t-e.timestampOffset)>=i&&(this.log(`Updating ${r} SourceBuffer timestampOffset to ${t} (sn: ${s} cc: ${a})`),e.timestampOffset=t)}removeExecutor(e,t,i){let{media:r,mediaSource:s}=this,a=this.tracks[e],n=null==a?void 0:a.buffer;if(!r||!s||!n){this.warn(`Attempting to remove from the ${e} SourceBuffer, but it does not exist`),this.shiftAndExecuteNext(e);return}let l=se(r.duration)?r.duration:1/0,o=se(s.duration)?s.duration:1/0,d=Math.max(0,t),h=Math.min(i,l,o);h>d&&(!a.ending||a.ended)?(a.ended=!1,this.log(`Removing [${d},${h}] from the ${e} SourceBuffer`),n.remove(d,h)):this.shiftAndExecuteNext(e)}appendExecutor(e,t){let i=this.tracks[t],r=null==i?void 0:i.buffer;if(!r)throw new oI(`Attempting to append to the ${t} SourceBuffer, but it does not exist`);i.ending=!1,i.ended=!1,r.appendBuffer(e)}blockUntilOpen(e){if(this.isUpdating()||this.isQueued())this.blockBuffers(e).catch(e=>{this.warn(`SourceBuffer blocked callback ${e}
28`),this.stepOperationQueue(this.sourceBufferTypes)});else try{e()}catch(e){this.warn(`Callback run without blocking ${this.operationQueue} ${e}`)}}isUpdating(){return this.sourceBuffers.some(([e,t])=>e&&t.updating)}isQueued(){return this.sourceBuffers.some(([e])=>e&&!!this.currentOp(e))}isPending(e){return!!e&&!e.buffer}blockBuffers(e,t=this.sourceBufferTypes){if(!t.length)return this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);let{operationQueue:i}=this,r=t.map(e=>this.appendBlocker(e));return t.length>1&&this.blockedAudioAppend&&this.unblockAudio(),Promise.all(r).then(t=>{i===this.operationQueue&&(e(),this.stepOperationQueue(this.sourceBufferTypes))})}stepOperationQueue(e){e.forEach(e=>{var t;let i=null==(t=this.tracks[e])?void 0:t.buffer;i&&!i.updating&&this.shiftAndExecuteNext(e)})}append(e,t,i){this.operationQueue&&this.operationQueue.append(e,t,i)}appendBlocker(e){if(this.operationQueue)return this.operationQueue.appendBlocker(e)}currentOp(e){return this.operationQueue?this.operationQueue.current(e):null}executeNext(e){e&&this.operationQueue&&this.operationQueue.executeNext(e)}shiftAndExecuteNext(e){this.operationQueue&&this.operationQueue.shiftAndExecuteNext(e)}get pendingTrackCount(){return Object.keys(this.tracks).reduce((e,t)=>e+ +!!this.isPending(this.tracks[t]),0)}get sourceBufferCount(){return this.sourceBuffers.reduce((e,[t])=>e+ +!!t,0)}get sourceBufferTypes(){return this.sourceBuffers.map(([e])=>e).filter(e=>!!e)}addBufferListener(e,t,i){let r=this.tracks[e];if(!r)return;let s=r.buffer;if(!s)return;let a=i.bind(this,e);r.listeners.push({event:t,listener:a}),s.addEventListener(t,a)}removeBufferListeners(e){let t=this.tracks[e];if(!t)return;let i=t.buffer;i&&(t.listeners.forEach(e=>{i.removeEventListener(e.event,e.listener)}),t.listeners.length=0)}},capLevelController:oC,errorController:class extends sE{constructor(e){super("error-controller",e.logger),this.hls=void 0,this.playlistError=0,this.hls=e,this.registerListeners()}registerListeners(){let e=this.hls;e.on(sa.ERROR,this.onError,this),e.on(sa.MANIFEST_LOADING,this.onManifestLoading,this),e.on(sa.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){let e=this.hls;e&&(e.off(sa.ERROR,this.onError,this),e.off(sa.ERROR,this.onErrorOut,this),e.off(sa.MANIFEST_LOADING,this.onManifestLoading,this),e.off(sa.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null}startLoad(e){}stopLoad(){this.playlistError=0}getVariantLevelIndex(e){return(null==e?void 0:e.type)===sh?e.level:this.getVariantIndex()}getVariantIndex(){var e;let t=this.hls,i=t.currentLevel;return null!=(e=t.loadLevelObj)&&e.details||-1===i?t.loadLevel:i}variantHasKey(e,t){if(e){var i;if(null!=(i=e.details)&&i.hasKey(t))return!0;let r=e.audioGroups;if(r)return this.hls.allAudioTracks.filter(e=>r.indexOf(e.groupId)>=0).some(e=>{var i;return null==(i=e.details)?void 0:i.hasKey(t)})}return!1}onManifestLoading(){this.playlistError=0}onLevelUpdated(){this.playlistError=0}onError(e,t){var i,r,s;if(t.fatal)return;let a=this.hls,n=t.context;switch(t.details){case ss.FRAG_LOAD_ERROR:case ss.FRAG_LOAD_TIMEOUT:case ss.KEY_LOAD_ERROR:case ss.KEY_LOAD_TIMEOUT:t.errorAction=this.getFragRetryOrSwitchAction(t);return;case ss.FRAG_PARSING_ERROR:if(null!=(i=t.frag)&&i.gap){t.errorAction=aH();return}case ss.FRAG_GAP:case ss.FRAG_DECRYPT_ERROR:t.errorAction=this.getFragRetryOrSwitchAction(t),t.errorAction.action=2;return;case ss.LEVEL_EMPTY_ERROR:case ss.LEVEL_PARSING_ERROR:{let e=t.parent===sh?t.level:a.loadLevel;t.details===ss.LEVEL_EMPTY_ERROR&&null!=(r=t.context)&&null!=(r=r.levelDetails)&&r.live?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,e):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,e))}return;case ss.LEVEL_LOAD_ERROR:case ss.LEVEL_LOAD_TIMEOUT:"number"==typeof(null==n?void 0:n.level)&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.level));return;case ss.AUDIO_TRACK_LOAD_ERROR:case ss.AUDIO_TRACK_LOAD_TIMEOUT:case ss.SUBTITLE_LOAD_ERROR:case ss.SUBTITLE_TRACK_LOAD_TIMEOUT:if(n){let e=a.loadLevelObj;e&&(n.type===so&&e.hasAudioGroup(n.groupId)||n.type===sd&&e.hasSubtitleGroup(n.groupId))&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,a.loadLevel),t.errorAction.action=2,t.errorAction.flags=1)}return;case ss.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:t.errorAction={action:2,flags:2};return;case ss.KEY_SYSTEM_SESSION_UPDATE_FAILED:case ss.KEY_SYSTEM_STATUS_INTERNAL_ERROR:case ss.KEY_SYSTEM_NO_SESSION:t.errorAction={action:2,flags:4};return;
28case ss.BUFFER_ADD_CODEC_ERROR:case ss.REMUX_ALLOC_ERROR:case ss.BUFFER_APPEND_ERROR:t.errorAction||(t.errorAction=this.getLevelSwitchAction(t,null!=(s=t.level)?s:a.loadLevel));return;case ss.INTERNAL_EXCEPTION:case ss.BUFFER_APPENDING_ERROR:case ss.BUFFER_FULL_ERROR:case ss.LEVEL_SWITCH_ERROR:case ss.BUFFER_STALLED_ERROR:case ss.BUFFER_SEEK_OVER_HOLE:case ss.BUFFER_NUDGE_ON_STALL:t.errorAction=aH();return}t.type===sr.KEY_SYSTEM_ERROR&&(t.levelRetry=!1,t.errorAction=aH())}getPlaylistRetryOrSwitchAction(e,t){let i=aN(this.hls.config.playlistLoadPolicy,e),r=this.playlistError++;if(a$(i,r,ax(e),e.response))return{action:5,flags:0,retryConfig:i,retryCount:r};let s=this.getLevelSwitchAction(e,t);return i&&(s.retryConfig=i,s.retryCount=r),s}getFragRetryOrSwitchAction(e){let t=this.hls,i=this.getVariantLevelIndex(e.frag),r=t.levels[i],{fragLoadPolicy:s,keyLoadPolicy:a}=t.config,n=aN(aM(e)?a:s,e),l=t.levels.reduce((e,t)=>e+t.fragmentError,0);if(r&&(e.details!==ss.FRAG_GAP&&r.fragmentError++,!aO(e))&&a$(n,l,ax(e),e.response))return{action:5,flags:0,retryConfig:n,retryCount:l};let o=this.getLevelSwitchAction(e,i);return n&&(o.retryConfig=n,o.retryCount=l),o}getLevelSwitchAction(e,t){let i=this.hls;null==t&&(t=i.loadLevel);let r=this.hls.levels[t];if(r){var s,a,n,l;let t=e.details;r.loadError++,t===ss.BUFFER_APPEND_ERROR&&r.fragmentError++;let o=-1,{levels:d,loadLevel:h,minAutoLevel:u,maxAutoLevel:c}=i;i.autoLevelEnabled||i.config.preserveManualLevelOnError||(i.loadLevel=-1);let f=null==(s=e.frag)?void 0:s.type,m=(f===su&&t===ss.FRAG_PARSING_ERROR||"audio"===e.sourceBufferName&&(t===ss.BUFFER_ADD_CODEC_ERROR||t===ss.BUFFER_APPEND_ERROR))&&d.some(({audioCodec:e})=>r.audioCodec!==e),g="video"===e.sourceBufferName&&(t===ss.BUFFER_ADD_CODEC_ERROR||t===ss.BUFFER_APPEND_ERROR)&&d.some(({codecSet:e,audioCodec:t})=>r.codecSet!==e&&r.audioCodec===t),{type:v,groupId:E}=null!=(a=e.context)?a:{};for(let i=d.length;i--;){let s=(i+h)%d.length;if(s!==h&&s>=u&&s<=c&&0===d[s].loadError){let i=d[s];if(t===ss.FRAG_GAP&&f===sh&&e.frag){let t=d[s].details;if(t){let i=aD(e.frag,t.fragments,e.frag.start);if(null!=i&&i.gap)continue}}else if(v===so&&i.hasAudioGroup(E)||v===sd&&i.hasSubtitleGroup(E))continue;else if(f===su&&null!=(n=r.audioGroups)&&n.some(e=>i.hasAudioGroup(e))||f===sc&&null!=(l=r.subtitleGroups)&&l.some(e=>i.hasSubtitleGroup(e))||m&&r.audioCodec===i.audioCodec||g&&r.codecSet===i.codecSet||!m&&r.codecSet!==i.codecSet)continue;o=s;break}}if(o>-1&&i.loadLevel!==o)return e.levelRetry=!0,this.playlistError=0,{action:2,flags:0,nextAutoLevel:o}}return{action:2,flags:1}}onErrorOut(e,t){var i;switch(null==(i=t.errorAction)?void 0:i.action){case 0:break;case 2:this.sendAlternateToPenaltyBox(t),t.errorAction.resolved||t.details===ss.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}if(t.fatal)return void this.hls.stopLoad()}sendAlternateToPenaltyBox(e){let t=this.hls,i=e.errorAction;if(!i)return;let{flags:r}=i,s=i.nextAutoLevel;switch(r){case 0:this.switchLevel(e,s);break;case 2:{let r=this.getVariantLevelIndex(e.frag),s=t.levels[r],a=null==s?void 0:s.attrs["HDCP-LEVEL"];if(i.hdcpLevel=a,"NONE"===a)this.warn("HDCP policy resticted output with HDCP-LEVEL=NONE");else if(a){t.maxHdcpLevel=am[am.indexOf(a)-1],i.resolved=!0,this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}}case 4:{let t=e.decryptdata;if(t){let r=this.hls.levels,s=r.length;for(let i=s;i--;)if(this.variantHasKey(r[i],t)){var a,n;this.log(`Banned key found in level ${i} (${r[i].bitrate}bps) or audio group "${null==(a=r[i].audioGroups)?void 0:a.join(",")}" (${null==(n=e.frag)?void 0:n.type} fragment) ${sR(t.keyId||[])}`),r[i].fragmentError++,r[i].loadError++,this.log(`Removing level ${i} with key error (${e.error})`),this.hls.removeLevel(i)}let l=e.frag;if(this.hls.levels.length<s)i.resolved=!0;else if(l&&l.type!==sh){let e=l.decryptdata;e&&!t.matches(e)&&(i.resolved=!0)}}}}i.resolved||this.switchLevel(e,s)}switchLevel(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===ss.BUFFER_ADD_CODEC_ERROR&&e.mimeType&&"audiovideo"!==e.sourceBufferName)){let t=ao(e.mimeType),i=this.hls.levels;for(let r=i.length;r--;)i[r][`${e.sourceBufferName}Codec`]===t&&(this.log(`Removing level ${r} for ${e.details} ("${t}" not supported)`),this.hls.removeLevel(r))}}},fpsController:class{constructor(e){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=e,this.registerListeners()}setStreamController(e){this.streamController=e}
28registerListeners(){this.hls.on(sa.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.on(sa.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListeners(){this.hls.off(sa.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off(sa.MEDIA_DETACHING,this.onMediaDetaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(e,t){let i=this.hls.config;if(i.capLevelOnFPSDrop){let e=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=e,e&&"function"==typeof e.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),i.fpsDroppedMonitoringPeriod)}}onMediaDetaching(){this.media=null}checkFPS(e,t,i){let r=performance.now();if(t){if(this.lastTime){let e=r-this.lastTime,s=i-this.lastDroppedFrames,a=t-this.lastDecodedFrames,n=1e3*s/e,l=this.hls;if(l.trigger(sa.FPS_DROP,{currentDropped:s,currentDecoded:a,totalDroppedFrames:i}),n>0&&s>l.config.fpsDroppedMonitoringThreshold*a){let e=l.currentLevel;l.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+e),e>0&&(-1===l.autoLevelCapping||l.autoLevelCapping>=e)&&(e-=1,l.trigger(sa.FPS_DROP_LEVEL_CAPPING,{level:e,droppedLevel:l.currentLevel}),l.autoLevelCapping=e,this.streamController.nextLevelSwitch())}}this.lastTime=r,this.lastDroppedFrames=i,this.lastDecodedFrames=t}}checkFPSInterval(){let e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){let t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}},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:nL,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:hd,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:class extends lm{constructor(e,t,i){super(e,t,i,"subt
28itle-stream-controller",sc),this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this.registerListeners()}onHandlerDestroying(){this.unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null}registerListeners(){super.registerListeners();let{hls:e}=this;e.on(sa.LEVEL_LOADED,this.onLevelLoaded,this),e.on(sa.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(sa.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(sa.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(sa.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(sa.BUFFER_FLUSHING,this.onBufferFlushing,this)}unregisterListeners(){super.unregisterListeners();let{hls:e}=this;e.off(sa.LEVEL_LOADED,this.onLevelLoaded,this),e.off(sa.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(sa.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(sa.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(sa.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(sa.BUFFER_FLUSHING,this.onBufferFlushing,this)}startLoad(e,t){this.stopLoad(),this.state=lr,this.setInterval(500),this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}onManifestLoading(){super.onManifestLoading(),this.mainDetails=null}onMediaDetaching(e,t){this.tracksBuffered=[],super.onMediaDetaching(e,t)}onLevelLoaded(e,t){this.mainDetails=t.details}onSubtitleFragProcessed(e,t){let i,{frag:r,success:s}=t;if(this.fragContextChanged(r)||(sN(r)&&(this.fragPrevious=r),this.state=lr),!s)return;let a=this.tracksBuffered[this.currentTrackId];if(!a)return;let n=r.start;for(let e=0;e<a.length;e++)if(n>=a[e].start&&n<=a[e].end){i=a[e];break}let l=r.start+r.duration;i?i.end=l:(i={start:n,end:l},a.push(i)),this.fragmentTracker.fragBuffered(r),this.fragBufferedComplete(r,null),this.media&&this.tick()}onBufferFlushing(e,t){let{startOffset:i,endOffset:r}=t;if(0===i&&r!==1/0){let e=r-1;if(e<=0)return;t.endOffsetSubtitles=Math.max(0,e),this.tracksBuffered.forEach(t=>{for(let i=0;i<t.length;){if(t[i].end<=e){t.shift();continue}if(t[i].start<e)t[i].start=e;else break;i++}}),this.fragmentTracker.removeFragmentsInRange(i,e,sc)}}onError(e,t){let i=t.frag;(null==i?void 0:i.type)===sc&&(t.details===ss.FRAG_GAP&&this.fragmentTracker.fragBuffered(i,!0),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==li&&(this.state=lr))}onSubtitleTracksUpdated(e,{subtitleTracks:t}){if(this.levels&&o_(this.levels,t)){this.levels=t.map(e=>new aE(e));return}this.tracksBuffered=[],this.levels=t.map(e=>{let t=new aE(e);return this.tracksBuffered[t.id]=[],t}),this.fragmentTracker.removeFragmentsInRange(0,1/0,sc),this.fragPrevious=null,this.mediaBuffer=null}onSubtitleTrackSwitch(e,t){var i;if(this.currentTrackId=t.id,!(null!=(i=this.levels)&&i.length)||-1===this.currentTrackId)return void this.clearInterval();let r=this.levels[this.currentTrackId];null!=r&&r.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,r&&this.state!==li&&this.setInterval(500)}onSubtitleTrackLoaded(e,t){var i,r;let{currentTrackId:s,levels:a}=this,{details:n,id:l}=t;if(!a)return void this.warn(`Subtitle tracks were reset while loading level ${l}`);let o=a[l];if(l>=a.length||!o)return;this.log(`Subtitle track ${l} loaded [${n.startSN},${n.endSN}]${n.lastPartSn?`[part-${n.lastPartSn}-${n.lastPartIndex}]`:""},duration:${n.totalduration}`),this.mediaBuffer=this.mediaBufferTimeRanges;let d=0;if(n.live||null!=(i=o.details)&&i.live){if(n.deltaUpdateFailed)return;let e=this.mainDetails;if(!e){this.startFragRequested=!1;return}let t=e.fragments[0];o.details?0===(d=this.alignPlaylists(n,o.details,null==(r=this.levelLastLoaded)?void 0:r.details))&&t&&nX(n,d=t.start):n.hasProgramDateTime&&e.hasProgramDateTime?(n9(n,e),d=n.fragmentStart):t&&nX(n,d=t.start),e&&!this.startFragRequested&&this.setStartPosition(e,d)}o.details=n,this.levelLastLoaded=o,l===s&&(this.hls.trigger(sa.SUBTITLE_TRACK_UPDATED,{details:n,id:l,groupId:t.groupId}),this.tick(),n.live&&!this.fragCurrent&&this.media&&this.state===lr&&(aD(null,n.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),o.details=void 0)))}_handleFragmentLoadComplete(e){let{frag:t,payload:i}=e,r=t.decryptdata,s=this.hls;if(!this.fragContextChanged(t)&&i&&i.byteLength>
280&&null!=r&&r.key&&r.iv&&no(r.method)){let e=performance.now();this.decrypter.decrypt(new Uint8Array(i),r.key.buffer,r.iv.buffer,nd(r.method)).catch(e=>{throw s.trigger(sa.ERROR,{type:sr.MEDIA_ERROR,details:ss.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:t}),e}).then(i=>{let r=performance.now();s.trigger(sa.FRAG_DECRYPTED,{frag:t,payload:i,stats:{tstart:e,tdecrypt:r}})}).catch(e=>{this.warn(`${e.name}: ${e.message}`),this.state=lr})}}doTick(){if(!this.media){this.state=lr;return}if(this.state===lr){let{currentTrackId:e,levels:t}=this,i=null==t?void 0:t[e];if(!i||!t.length||!i.details||this.waitForLive(i))return;let{config:r}=this,s=this.getLoadPosition(),{end:a,len:n}=a6.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],s,r.maxBufferHole),l=i.details;if(n>this.hls.maxBufferLength+l.levelTargetDuration)return;let o=l.fragments,d=o.length,h=l.edge,u=null,c=this.fragPrevious;if(a<h){let e=r.maxFragLookUpTolerance;(u=aD(c,o,Math.max(o[0].start,a),a>h-e?0:e))||!c||!(c.start<o[0].start)||(u=o[0])}else u=o[d-1];if(!(u=this.filterReplacedPrimary(u,i.details)))return;let f=o[u.sn-l.startSN-1];if(f&&f.cc===u.cc&&this.fragmentTracker.getState(f)===aG&&(u=f),this.fragmentTracker.getState(u)===aG){let e=this.mapToInitFragWhenRequired(u);e&&this.loadFragment(e,i,a)}}}loadFragment(e,t,i){sN(e)?super.loadFragment(e,t,i):this._loadInitSegment(e,t)}get mediaBufferTimeRanges(){return new dI(this.tracksBuffered[this.currentTrackId]||[])}},subtitleTrackController:class extends oT{constructor(e){super(e,"subtitle-track-controller"),this.media=null,this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.queuedDefaultTrack=-1,this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.onTextTracksChanged=()=>{if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let e=null,t=dm(this.media.textTracks);for(let i=0;i<t.length;i++)if("hidden"===t[i].mode)e=t[i];else if("showing"===t[i].mode){e=t[i];break}let i=this.findTrackForTextTrack(e);this.subtitleTrack!==i&&this.setSubtitleTrack(i)},this.registerListeners()}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,this.onTextTracksChanged=this.asyncPollTrackChange=null,super.destroy()}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes()}registerListeners(){let{hls:e}=this;e.on(sa.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(sa.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(sa.MANIFEST_LOADING,this.onManifestLoading,this),e.on(sa.MANIFEST_PARSED,this.onManifestParsed,this),e.on(sa.LEVEL_LOADING,this.onLevelLoading,this),e.on(sa.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(sa.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(sa.ERROR,this.onError,this)}unregisterListeners(){let{hls:e}=this;e.off(sa.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(sa.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(sa.MANIFEST_LOADING,this.onManifestLoading,this),e.off(sa.MANIFEST_PARSED,this.onManifestParsed,this),e.off(sa.LEVEL_LOADING,this.onLevelLoading,this),e.off(sa.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(sa.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(sa.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))}pollTrackChange(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.onTextTracksChanged,e)}onMediaDetaching(e,t){let i=this.media;if(!i)return;let r=!!t.transferMedia;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,r||dm(i.textTracks).forEac
28h(e=>{dc(e)})}onManifestLoading(){this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.subtitleTracks}onSubtitleTrackLoaded(e,t){let{id:i,groupId:r,details:s}=t,a=this.tracksInGroup[i];if(!a||a.groupId!==r)return void this.warn(`Subtitle track with id:${i} and group:${r} not found in active group ${null==a?void 0:a.groupId}`);let n=a.details;a.details=t.details,this.log(`Subtitle track ${i} "${a.name}" lang:${a.lang} group:${r} loaded [${s.startSN}-${s.endSN}]`),i===this.trackId&&this.playlistLoaded(i,t,n)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){let t=this.hls.levels[e];if(!t)return;let i=t.subtitleGroups||null,r=this.groupIds,s=this.currentTrack;if(!i||(null==r?void 0:r.length)!==(null==i?void 0:i.length)||null!=i&&i.some(e=>(null==r?void 0:r.indexOf(e))===-1)){this.groupIds=i,this.trackId=-1,this.currentTrack=null;let e=this.tracks.filter(e=>!i||-1!==i.indexOf(e.groupId));if(e.length)this.selectDefaultTrack&&!e.some(e=>e.default)&&(this.selectDefaultTrack=!1),e.forEach((e,t)=>{e.id=t});else if(!s&&!this.tracksInGroup.length)return;this.tracksInGroup=e;let t=this.hls.config.subtitlePreference;if(!s&&t){this.selectDefaultTrack=!1;let i=aS(t,e);if(i>-1)s=e[i];else{let e=aS(t,this.tracks);s=this.tracks[e]}}let r=this.findTrackId(s);-1===r&&s&&(r=this.findTrackId(null)),this.log(`Updating subtitle tracks, ${e.length} track(s) found in "${null==i?void 0:i.join(",")}" group-id`),this.hls.trigger(sa.SUBTITLE_TRACKS_UPDATED,{subtitleTracks:e}),-1!==r&&-1===this.trackId&&this.setSubtitleTrack(r)}}findTrackId(e){let t=this.tracksInGroup,i=this.selectDefaultTrack;for(let r=0;r<t.length;r++){let s=t[r];if((!i||s.default)&&(i||e)&&(!e||ak(s,e)))return r}if(e){for(let i=0;i<t.length;i++){let r=t[i];if(oA(e.attrs,r.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return i}for(let i=0;i<t.length;i++){let r=t[i];if(oA(e.attrs,r.attrs,["LANGUAGE"]))return i}}return -1}findTrackForTextTrack(e){if(e){let t=this.tracksInGroup;for(let i=0;i<t.length;i++)if(oS(t[i],e))return i}return -1}onError(e,t){!t.fatal&&t.context&&(t.context.type!==sd||t.context.id!==this.trackId||this.groupIds&&-1===this.groupIds.indexOf(t.context.groupId)||this.checkRetry(t))}get allSubtitleTracks(){return this.tracks}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(e){this.selectDefaultTrack=!1,this.setSubtitleTrack(e)}setSubtitleOption(e){if(this.hls.config.subtitlePreference=e,e){if(-1===e.id)return this.setSubtitleTrack(-1),null;let t=this.allSubtitleTracks;if(this.selectDefaultTrack=!1,t.length){let i=this.currentTrack;if(i&&ak(e,i))return i;let r=aS(e,this.tracksInGroup);if(r>-1){let e=this.tracksInGroup[r];return this.setSubtitleTrack(r),e}{if(i)return null;let r=aS(e,t);if(r>-1)return t[r]}}}return null}loadPlaylist(e){super.loadPlaylist(),this.shouldLoadPlaylist(this.currentTrack)&&this.scheduleLoading(this.currentTrack,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);let i=e.id,r=e.groupId,s=this.getUrlWithDirectives(e.url,t),a=e.details,n=null==a?void 0:a.age;this.log(`Loading subtitle ${i} "${e.name}" lang:${e.lang} group:${r}${(null==t?void 0:t.msn)!==void 0?" at sn "+t.msn+" part "+t.part:""}${n&&a.live?" age "+n.toFixed(1)+(a.type?" "+a.type:""):""} ${s}`),this.hls.trigger(sa.SUBTITLE_TRACK_LOADING,{url:s,id:i,groupId:r,deliveryDirectives:t||null,track:e})}toggleTrackModes(){let e,{media:t}=this;if(!t)return;let i=dm(t.textTracks),r=this.currentTrack;if(r&&((e=i.filter(e=>oS(r,e))[0])||this.warn(`Unable to find subtitle TextTrack with name "${r.name}" and language "${r.lang}"`)),[].slice.call(i).forEach(t=>{"disabled"!==t.mode&&t!==e&&(t.mode="disabled")}),e){let t=this.subtitleDisplay?"showing":"hidden";e.mode!==t&&(e.mode=t)}}setSubtitleTrack(e){let t=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(e<-1||e>=t.length||!se(e))return void this.warn(`Invalid subtitle track id: ${e}`);this.selectDefaultTrack=!1;let i=this.currentTrack,r=t[e]||null;if(this.trackId=e,this.currentTrack=r,this.toggleTrackModes(),!r)return void this.hls.trigger(sa.SUBTITLE_TRACK_SWITCH,{id:e});let s=!!r.details&&!r.details.live;if(e===this.trackId&&r===i&&s)return;this.log(`Switching to subtitle-track ${e}`+(r?` "${r.name}" lang:${r.lang} group:${r.groupId}`:""));let{id:a,groupId:n="",name:l,type:o,url:d}=r;this.hls.trigger(sa.SUBTITLE_TRACK_SWITCH,{id:a,groupId:n,name:l,type:o,url:d});let h=this.switchParams(r.url,null==i?void 0:i.details,r.details);this.loadPlaylist(h)}},timelineController:class{constructor(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=hl(),this.captionsProperties=void 0,this.hls=e,this.config=e.config,this.Cues=e.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}}
28,e.on(sa.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(sa.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(sa.MANIFEST_LOADING,this.onManifestLoading,this),e.on(sa.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(sa.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(sa.FRAG_LOADING,this.onFragLoading,this),e.on(sa.FRAG_LOADED,this.onFragLoaded,this),e.on(sa.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(sa.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(sa.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(sa.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(sa.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){let{hls:e}=this;e.off(sa.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(sa.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(sa.MANIFEST_LOADING,this.onManifestLoading,this),e.off(sa.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(sa.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(sa.FRAG_LOADING,this.onFragLoading,this),e.off(sa.FRAG_LOADED,this.onFragLoaded,this),e.off(sa.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(sa.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(sa.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(sa.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(sa.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.media=null,this.cea608Parser1=this.cea608Parser2=void 0}initCea608Parsers(){let e=new hs(this,"textTrack1"),t=new hs(this,"textTrack2"),i=new hs(this,"textTrack3"),r=new hs(this,"textTrack4");this.cea608Parser1=new dV(1,e,t),this.cea608Parser2=new dV(3,i,r)}addCues(e,t,i,r,s){let a=!1;for(let e=s.length;e--;){var n,l;let r=s[e],o=(n=r[0],l=r[1],Math.min(l,i)-Math.max(n,t));if(o>=0&&(r[0]=Math.min(r[0],t),r[1]=Math.max(r[1],i),a=!0,o/(i-t)>.5))return}if(a||s.push([t,i]),this.config.renderTextTracksNatively){let s=this.captionsTracks[e];this.Cues.newCue(s,t,i,r)}else{let s=this.Cues.newCue(null,t,i,r);this.hls.trigger(sa.CUES_PARSED,{type:"captions",cues:s,track:e})}}onInitPtsFound(e,{frag:t,id:i,initPTS:r,timescale:s,trackId:a}){let{unparsedVttFrags:n}=this;i===sh&&(this.initPTS[t.cc]={baseTime:r,timescale:s,trackId:a}),n.length&&(this.unparsedVttFrags=[],n.forEach(e=>{this.initPTS[e.frag.cc]?this.onFragLoaded(sa.FRAG_LOADED,e):this.hls.trigger(sa.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e.frag,error:Error("Subtitle discontinuity domain does not match main")})}))}getExistingTrack(e,t){let{media:i}=this;if(i)for(let r=0;r<i.textTracks.length;r++){let s=i.textTracks[r];if(hn(s,{name:e,lang:t,characteristics:"transcribes-spoken-dialog,describes-music-and-sound"}))return s}return null}createCaptionsTrack(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}createNativeTrack(e){if(this.captionsTracks[e])return;let{captionsProperties:t,captionsTracks:i,media:r}=this,{label:s,languageCode:a}=t[e],n=this.getExistingTrack(s,a);if(n)i[e]=n,dc(i[e]),dh(i[e],r);else{let t=this.createTextTrack("captions",s,a);t&&(t[e]=!0,i[e]=t)}}createNonNativeTrack(e){if(this.nonNativeCaptionsTracks[e])return;let t=this.captionsProperties[e];if(!t)return;let i={_id:e,label:t.label,kind:"captions",default:!!t.media&&!!t.media.default,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=i,this.hls.trigger(sa.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[i]})}createTextTrack(e,t,i){let r=this.media;if(r)return r.addTextTrack(e,t,i)}onMediaAttaching(e,t){this.media=t.media,t.mediaSource||this._cleanTracks()}onMediaDetaching(e,t){let i=!!t.transferMedia;if(this.media=null,i)return;let{captionsTracks:r}=this;Object.keys(r).forEach(e=>{dc(r[e]),delete r[e]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=hl(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}_cleanTracks(){let{media:e}=this;if(!e)return;let t=e.textTracks;
28if(t)for(let e=0;e<t.length;e++)dc(t[e])}onSubtitleTracksUpdated(e,t){let i=t.subtitleTracks||[],r=i.some(e=>e.textCodec===d4);if(this.config.enableWebVTT||r&&this.config.enableIMSC1){if(o_(this.tracks,i)){this.tracks=i;return}if(this.textTracks=[],this.tracks=i,this.config.renderTextTracksNatively){let e=this.media,t=e?dm(e.textTracks):null;if(this.tracks.forEach((e,i)=>{let r;if(t){let i=null;for(let r=0;r<t.length;r++)if(t[r]&&hn(t[r],e)){i=t[r],t[r]=null;break}i&&(r=i)}if(r)dc(r);else{let t=ha(e);(r=this.createTextTrack(t,e.name,e.lang))&&(r.mode="disabled")}r&&this.textTracks.push(r)}),null!=t&&t.length){let e=t.filter(e=>null!==e).map(e=>e.label);e.length&&this.hls.logger.warn(`Media element contains unused subtitle tracks: ${e.join(", ")}. Replace media element for each source to clear TextTracks and captions menu.`)}}else if(this.tracks.length){let e=this.tracks.map(e=>({label:e.name,kind:e.type.toLowerCase(),default:e.default,subtitleTrack:e}));this.hls.trigger(sa.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:e})}}}onManifestLoaded(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(e=>{let t=/(?:CC|SERVICE)([1-4])/.exec(e.instreamId);if(!t)return;let i=`textTrack${t[1]}`,r=this.captionsProperties[i];r&&(r.label=e.name,e.lang&&(r.languageCode=e.lang),r.media=e)})}closedCaptionsForLevel(e){let t=this.hls.levels[e.level];return null==t?void 0:t.attrs["CLOSED-CAPTIONS"]}onFragLoading(e,t){if(this.enabled&&t.frag.type===sh){var i,r;let{cea608Parser1:e,cea608Parser2:s,lastSn:a}=this,{cc:n,sn:l}=t.frag,o=null!=(i=null==(r=t.part)?void 0:r.index)?i:-1;e&&s&&(l!==a+1||l===a&&o!==this.lastPartIndex+1||n!==this.lastCc)&&(e.reset(),s.reset()),this.lastCc=n,this.lastSn=l,this.lastPartIndex=o}}onFragLoaded(e,t){let{frag:i,payload:r}=t;if(i.type===sc)if(r.byteLength){let e=i.decryptdata,s="stats"in t;if(null==e||!e.encrypted||s){let e=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),e&&e.textCodec===d4?this._parseIMSC1(i,r):this._parseVTTs(t)}}else this.hls.trigger(sa.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:Error("Empty subtitle payload")})}_parseIMSC1(e,t){let i=this.hls;d9(t,this.initPTS[e.cc],t=>{this._appendCues(t,e.level),i.trigger(sa.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},t=>{i.logger.log(`Failed to parse IMSC1: ${t}`),i.trigger(sa.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:t})})}_parseVTTs(e){var t,i,r,s,a,n,l,o;let d,h,u,c,f,m,g,v,E,{frag:y,payload:b}=e,{initPTS:T,unparsedVttFrags:_}=this,A=T.length-1;if(!T[y.cc]&&-1===A)return void _.push(e);let S=this.hls;i=null!=(t=y.initSegment)&&t.data?s0(y.initSegment.data,new Uint8Array(b)).buffer:b,r=this.initPTS[y.cc],s=this.vttCCs,a=y.cc,n=y.start,l=e=>{this._appendCues(e,y.level),S.trigger(sa.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:y})},o=t=>{let i="Missing initPTS for VTT MPEGTS"===t.message;i?_.push(e):this._fallbackToIMSC1(y,b),S.logger.log(`Failed to parse VTT cue: ${t}`),i&&A>y.cc||S.trigger(sa.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:y,error:t})},h=new dZ,u=sL(new Uint8Array(i)).trim().replace(dJ,"\n").split("\n"),c=[],f=r?function(e,t=1){return ot(e,9e4,1/t)}(r.baseTime,r.timescale):0,m="00:00.000",g=0,v=0,E=!0,h.oncue=function(e){let t=s[a],i=s.ccOffset,l=(g-f)/9e4;if(null!=t&&t.new&&(void 0!==v?i=s.ccOffset=t.start:d3(s,a,l)),l){if(!r){d=Error("Missing initPTS for VTT MPEGTS");return}i=l-s.presentationOffset}let o=e.endTime-e.startTime,h=oo((e.startTime+i-v)*9e4,9e4*n)/9e4;e.startTime=Math.max(h,0),e.endTime=Math.max(h+o,0);let u=e.text.trim();e.text=decodeURIComponent(encodeURIComponent(u)),e.id||(e.id=d2(e.startTime,e.endTime,u)),e.endTime>0&&c.push(e)},h.onparsingerror=function(e){d=e},h.onflush=function(){d?o(d):l(c)},u.forEach(e=>{if(E)if(d0(e,"X-TIMESTAMP-MAP=")){E=!1,e.slice(16).split(",").forEach(e=>{d0(e,"LOCAL:")?m=e.slice(6):d0(e,"MPEGTS:")&&(g=parseInt(e.slice(7)))});try{v=d1(m)/1e3}catch(e){d=e}return}else""===e&&(E=!1);h.parse(e+"\n")}),h.flush()}_fallbackToIMSC1(e,t){let i=this.tracks[e.level];i.textCodec||d9(t,this.initPTS[e.cc],()=>{i.textCodec=d4,this._parseIMSC1(e,t)},()=>{i.textCodec="wvtt"})}_appendCues(e,t){let i=this.hls;if(this.config.renderTextTracksNatively){let i=this.textTracks[t];if(!i||"disabled"===i.mode)return;
28e.forEach(e=>du(i,e))}else{let r=this.tracks[t];if(!r)return;let s=r.default?"default":"subtitles"+t;i.trigger(sa.CUES_PARSED,{type:"subtitles",cues:e,track:s})}}onFragDecrypted(e,t){let{frag:i}=t;i.type===sc&&this.onFragLoaded(sa.FRAG_LOADED,t)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(e,t){if(!this.enabled||!this.config.enableCEA708Captions)return;let{frag:i,samples:r}=t;if(i.type!==sh||"NONE"!==this.closedCaptionsForLevel(i))for(let e=0;e<r.length;e++){let t=r[e].bytes;if(t){this.cea608Parser1||this.initCea608Parsers();let i=this.extractCea608Data(t);this.cea608Parser1.addData(r[e].pts,i[0]),this.cea608Parser2.addData(r[e].pts,i[1])}}}onBufferFlushing(e,{startOffset:t,endOffset:i,endOffsetSubtitles:r,type:s}){let{media:a}=this;if(a&&!(a.currentTime<i)){if(!s||"video"===s){let{captionsTracks:e}=this;Object.keys(e).forEach(r=>df(e[r],t,i))}if(this.config.renderTextTracksNatively&&0===t&&void 0!==r){let{textTracks:e}=this;Object.keys(e).forEach(i=>df(e[i],t,r))}}}extractCea608Data(e){let t=[[],[]],i=31&e[0],r=2;for(let s=0;s<i;s++){let i=e[r++],s=127&e[r++],a=127&e[r++];if((0!==s||0!==a)&&(4&i)!=0){let e=3&i;(0===e||1===e)&&(t[e].push(s),t[e].push(a))}}return t}},audioStreamController:class extends lm{constructor(e,t,i){super(e,t,i,"audio-stream-controller",su),this.mainAnchor=null,this.mainFragLoading=null,this.audioOnly=!1,this.bufferedTrack=null,this.switchingTrack=null,this.trackId=-1,this.waitingData=null,this.mainDetails=null,this.flushing=!1,this.bufferFlushed=!1,this.cachedTrackLoadedData=null,this.registerListeners()}onHandlerDestroying(){this.unregisterListeners(),super.onHandlerDestroying(),this.resetItem()}resetItem(){this.mainDetails=this.mainAnchor=this.mainFragLoading=this.bufferedTrack=this.switchingTrack=this.waitingData=this.cachedTrackLoadedData=null}registerListeners(){super.registerListeners();let{hls:e}=this;e.on(sa.LEVEL_LOADED,this.onLevelLoaded,this),e.on(sa.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(sa.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(sa.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(sa.BUFFER_RESET,this.onBufferReset,this),e.on(sa.BUFFER_CREATED,this.onBufferCreated,this),e.on(sa.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(sa.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(sa.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(sa.FRAG_LOADING,this.onFragLoading,this),e.on(sa.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){let{hls:e}=this;e&&(super.unregisterListeners(),e.off(sa.LEVEL_LOADED,this.onLevelLoaded,this),e.off(sa.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(sa.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(sa.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(sa.BUFFER_RESET,this.onBufferReset,this),e.off(sa.BUFFER_CREATED,this.onBufferCreated,this),e.off(sa.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(sa.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(sa.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(sa.FRAG_LOADING,this.onFragLoading,this),e.off(sa.FRAG_BUFFERED,this.onFragBuffered,this))}onInitPtsFound(e,{frag:t,id:i,initPTS:r,timescale:s,trackId:a}){if(i===sh){let e=t.cc,i=this.fragCurrent;if(this.initPTS[e]={baseTime:r,timescale:s,trackId:a},this.log(`InitPTS for cc: ${e} found from main: ${r/s} (${r}/${s}) trackId: ${a}`),this.mainAnchor=t,this.state===lc){let i=this.waitingData;(i||this.loadingParts)&&(!i||i.frag.cc===e)||this.syncWithAnchor(t,null==i?void 0:i.frag)}else!this.hls.hasEnoughToStart&&i&&i.cc!==e?(i.abortRequests(),this.syncWithAnchor(t,i)):this.state===lr&&this.tick()}}getLoadPosition(){return!this.startFragRequested&&this.nextLoadPosition>=0?this.nextLoadPosition:super.getLoadPosition()}syncWithAnchor(e,t){var i;let r=(null==(i=this.mainFragLoading)?void 0:i.frag)||null;if(t&&(null==r?void 0:r.cc)===t.cc)return;let s=(r||e).cc,a=aP(this.getLevelDetails(),s,this.getLoadPosition());a&&(this.log(`Syncing with main frag at ${a.start} cc ${a.cc}`),this.startFragRequested=!1,this.nextLoadPosition=a.start,this.resetLoadingState(),this.state===lr&&this.doTickIdle())}
28startLoad(e,t){if(!this.levels){this.startPosition=e,this.state=li;return}let 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=lr):this.state=ll,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}doTick(){switch(this.state){case lr:this.doTickIdle();break;case ll:{let{levels:e,trackId:t}=this,i=null==e?void 0:e[t],r=null==i?void 0:i.details;if(r&&!this.waitForLive(i)){if(this.waitForCdnTuneIn(r))break;this.state=lc}break}case ln:this.checkRetryDate();break;case lc:{let e=this.waitingData;if(e){let{frag:t,part:i,cache:r,complete:s}=e,a=this.mainAnchor;if(void 0!==this.initPTS[t.cc]){this.waitingData=null,this.state=la;let e={frag:t,part:i,payload:r.flush().buffer,networkDetails:null};this._handleFragmentLoadProgress(e),s&&super._handleFragmentLoadComplete(e)}else a&&a.cc!==e.frag.cc&&this.syncWithAnchor(a,e.frag)}else this.state=lr}}this.onTickEnd()}resetLoadingState(){let e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null),super.resetLoadingState()}onTickEnd(){let{media:e}=this;null!=e&&e.readyState&&(this.lastCurrentTime=e.currentTime)}doTickIdle(){var e;let{hls:t,levels:i,media:r,trackId:s}=this,a=t.config;if(!this.buffering||!r&&!this.primaryPrefetch&&(this.startFragRequested||!a.startFragPrefetch)||!(null!=i&&i[s]))return;let n=i[s],l=n.details;if(!l||this.waitForLive(n)||this.waitForCdnTuneIn(l)){this.state=ll,this.startFragRequested=!1;return}let o=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&o&&(this.bufferFlushed=!1,this.afterBufferFlushed(o,sP,su));let d=this.getFwdBufferInfo(o,su);if(null===d)return;if(!this.switchingTrack&&this._streamEnded(d,l)){t.trigger(sa.BUFFER_EOS,{type:"audio"}),this.state=lh;return}let h=d.len,u=t.maxBufferLength,c=l.fragments,f=c[0].start,m=this.getLoadPosition(),g=this.flushing?m:d.end;if(this.switchingTrack&&r&&l.PTSKnown&&m<f&&(d.end>f||d.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),r.currentTime=f+.05),h>=u&&!this.switchingTrack&&g<c[c.length-1].start)return;let v=this.getNextFragment(g,l);if(v&&this.isLoopLoading(v,g)&&(v=this.getNextFragmentLoopLoading(v,l,d,sh,u)),!v){this.bufferFlushed=!0;return}let E=(null==(e=this.mainFragLoading)?void 0:e.frag)||null;if(!this.audioOnly&&this.startFragRequested&&E&&sN(v)&&!v.endList&&(!l.live||!this.loadingParts&&g<this.hls.liveSyncPosition)&&("OK"===this.fragmentTracker.getState(E)&&(this.mainFragLoading=E=null),E&&sN(E))){if(v.start>E.end){let e=this.fragmentTracker.getFragAtPos(g,sh);e&&e.end>E.end&&(E=e,this.mainFragLoading={frag:e,targetBufferTime:null})}if(v.start>E.end)return}this.loadFragment(v,n,g)}onMediaDetaching(e,t){this.bufferFlushed=this.flushing=!1,super.onMediaDetaching(e,t)}onAudioTracksUpdated(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map(e=>new aE(e))}onAudioTrackSwitching(e,t){let i=!!t.url;this.trackId=t.id;let{fragCurrent:r}=this;r&&(r.abortRequests(),this.removeUnbufferedFrags(r.start)),this.resetLoadingState(),i?(this.switchingTrack=t,this.flushAudioIfNeeded(t),this.state!==li&&(this.setInterval(100),this.state=lr,this.tick())):(this.resetTransmuxer(),this.switchingTrack=null,this.bufferedTrack=t,this.clearInterval())}onManifestLoading(){super.onManifestLoading(),this.bufferFlushed=this.flushing=this.audioOnly=!1,this.resetItem(),this.trackId=-1}onLevelLoaded(e,t){this.mainDetails=t.details;let i=this.cachedTrackLoadedData;i&&(this.cachedTrackLoadedData=null,this.onAudioTrackLoaded(sa.AUDIO_TRACK_LOADED,i))}onAudioTrackLoaded(e,t){var i,r;let{levels:s}=this,{details:a,id:n,groupId:l,track:o}=t;if(!s)return void this.warn(`Audio tracks reset while loading track ${n} "${o.name}" of "${l}"`);let d=this.mainDetails;if(!d||a.endCC>d.endCC||d.expired){this.cachedTrackLoadedData=t,this.state!==li&&(this.state=ll);return}this.cachedTrackLoadedData=null,this.log(`Audio track ${n} "${o.name}" of "${l}" loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""},duration:${a.totalduration}`);let h=s[n],u=0;if(a.live||null!=(i=h.details)&&i.live){if(this.checkLiveUpdate(a),a.deltaUpdateFailed)return;h.details&&(u=this.alignPlaylists(a,h.details,null==(r=this.levelLastLoaded)?void 0:r.details)),a.alignedSliding||(n6(a,d),a.alignedSliding||n9(a,d),u=a.fragmentStart)}h.details=a,this.levelLastLoaded=h,this.startFragRequested||this.setStartPosition(d,u),this.hls.trigger(sa.AUDIO_TRACK_UPDATED,{details:a,id:n,groupId:t.groupId}),this.state!==ll||this.waitForCdnTuneIn(a)||(this.state=lr),this.tick()}_handleFragmentLoadProgress(e){var t;let i=e.frag,{part:r,payload:s}=e,{config:a,trackId:n,levels:l}=this;if(!l)return void this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`);let o=l[n];if(!o)return void this.warn("Audio track is undefined on fragment load progress");let d=o.details;if(!d){this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(i.start);return}let h=a.defaultAudioCodec||o.audioCodec||"mp4a.40.2",u=this.transmuxer;u||(u=this.transmuxer=new ob(this.hls,su,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));let c=this.initPTS[i.cc],f=null==(t=i.initSegment)?void 0:t.data;if(void 0!==c){let e=r?r.index:-1,t=new a4(i.level,i.sn,i.stats.chunkCount,s.byteLength,e,-1!==e);u.push(s,f,h,"",i,r,d.totalduration,!1,t,c)}else{this.log(`Unknown video PTS for cc ${i.cc}, waiting for video PTS before demuxing audio frag ${i.sn} of [${d.startSN} ,${d.endSN}],track ${n}`);let{cache:e}=this.waitingData=this.waitingData||{frag:i,part:r,cache:new lg,complete:!1};e.push(new Uint8Array(s)),this.state!==li&&(this.state=lc)}}_handleFragmentLoadComplete(e){if(this.waitingData){this.waitingData.complete=!0;return}super._handleFragmentLoadComplete(e)}onBufferReset(){this.mediaBuffer=null}onBufferCreated(e,t){this.bufferFlushed=this.flushing=!1;let i=t.tracks.audio;i&&(this.mediaBuffer=i.buffer||null)}onFragLoading(e,t){!this.audioOnly&&t.frag.type===sh&&sN(t.frag)&&(this.mainFragLoading=t,this.state===lr&&this.tick())}onFragBuffered(e,t){let{frag:i,part:r}=t;if(i.type!==su){this.audioOnly||i.type!==sh||i.elementaryStreams.video||i.elementaryStreams.audiovideo||(this.audioOnly=!0,this.mainFragLoading=null);return}if(this.fragContextChanged(i))return void this.warn(`Fragment ${i.sn}${r?" p: "+r.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);if(sN(i)){this.fragPrevious=i;let e=this.switchingTrack;e&&(this.bufferedTrack=e,this.switchingTrack=null,this.hls.trigger(sa.AUDIO_TRACK_SWITCHED,sv({},e)))}this.fragBufferedComplete(i,r),this.media&&this.tick()}onError(e,t){var i;if(t.fatal){this.state=lu;return}switch(t.details){case ss.FRAG_GAP:case ss.FRAG_PARSING_ERROR:case ss.FRAG_DECRYPT_ERROR:case ss.FRAG_LOAD_ERROR:case ss.FRAG_LOAD_TIMEOUT:case ss.KEY_LOAD_ERROR:case ss.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(su,t);break;case ss.AUDIO_TRACK_LOAD_ERROR:case ss.AUDIO_TRACK_LOAD_TIMEOUT:case ss.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==ll||(null==(i=t.context)?void 0:i.type)!==so||(this.state=lr);break;case ss.BUFFER_ADD_CODEC_ERROR:case ss.BUFFER_APPEND_ERROR:if("audio"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)||this.resetLoadingState();break;case ss.BUFFER_FULL_ERROR:if("audio"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,1/0,"audio"));break;case ss.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}onBufferFlushing(e,{type:t}){t!==sx&&(this.flushing=!0)}onBufferFlushed(e,{type:t}){if(t!==sx){this.flushing=!1,this.bufferFlushed=!0,this.state===lh&&(this.state=lr);let e=this.mediaBuffer||this.media;e&&(this.afterBufferFlushed(e,t,su),this.tick())}}_handleTransmuxComplete(e){var t;let i="audio",{hls:r}=this,{remuxResult:s,chunkMeta:a}=e,n=this.getCurrentContext(a);if(!n)return void this.resetWhenMissingContext(a);let{frag:l,part:o,level:d}=n,{details:h}=d,{audio:u,text:c,id3:f,initSegment:m}=s;if(this.fragContextChanged(l)||!h)return void this.fragmentTracker.removeFragment(l);
28if(this.state=lo,this.switchingTrack&&u&&this.completeAudioSwitch(this.switchingTrack),null!=m&&m.tracks){let e=l.initSegment||l;if(this.unhandledEncryptionError(m,l))return;this._bufferInitSegment(d,m.tracks,e,a),r.trigger(sa.FRAG_PARSING_INIT_SEGMENT,{frag:e,id:i,tracks:m.tracks})}if(u){let{startPTS:e,endPTS:t,startDTS:i,endDTS:r}=u;o&&(o.elementaryStreams[sP]={startPTS:e,endPTS:t,startDTS:i,endDTS:r}),l.setElementaryStreamInfo(sP,e,t,i,r),this.bufferFragmentData(u,l,o,a)}if(null!=f&&null!=(t=f.samples)&&t.length){let e=sp({id:i,frag:l,details:h},f);r.trigger(sa.FRAG_PARSING_METADATA,e)}if(c){let e=sp({id:i,frag:l,details:h},c);r.trigger(sa.FRAG_PARSING_USERDATA,e)}}_bufferInitSegment(e,t,i,r){if(this.state!==lo||(t.video&&delete t.video,t.audiovideo&&delete t.audiovideo,!t.audio))return;let s=t.audio;s.id=su;let a=e.audioCodec;this.log(`Init audio buffer, container:${s.container}, codecs[level/parsed]=[${a}/${s.codec}]`),a&&1===a.split(",").length&&(s.levelCodec=a),this.hls.trigger(sa.BUFFER_CODECS,t);let n=s.initSegment;if(null!=n&&n.byteLength){let e={type:"audio",frag:i,part:null,chunkMeta:r,parent:i.type,data:n};this.hls.trigger(sa.BUFFER_APPENDING,e)}this.tickImmediate()}loadFragment(e,t,i){let r=this.fragmentTracker.getState(e);if(this.switchingTrack||r===aG||r===aK){var s;if(sN(e))if(null!=(s=t.details)&&s.live&&!this.initPTS[e.cc]){this.log(`Waiting for video PTS in continuity counter ${e.cc} of live stream before loading audio fragment ${e.sn} of level ${this.trackId}`),this.state=lc;let i=this.mainDetails;i&&i.fragmentStart!==t.details.fragmentStart&&n9(t.details,i)}else super.loadFragment(e,t,i);else this._loadInitSegment(e,t)}else this.clearTrackerIfNeeded(e)}flushAudioIfNeeded(e){if(this.media&&this.bufferedTrack){let{name:t,lang:i,assocLang:r,characteristics:s,audioCodec:a,channels:n}=this.bufferedTrack;ak({name:t,lang:i,assocLang:r,characteristics:s,audioCodec:a,channels:n},e,aL)||(aI(e.url,this.hls)?(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,1/0,"audio"),this.bufferedTrack=null):this.bufferedTrack=e)}}completeAudioSwitch(e){let{hls:t}=this;this.flushAudioIfNeeded(e),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(sa.AUDIO_TRACK_SWITCHED,sv({},e))}},audioTrackController:class extends oT{constructor(e){super(e,"audio-track-controller"),this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){let{hls:e}=this;e.on(sa.MANIFEST_LOADING,this.onManifestLoading,this),e.on(sa.MANIFEST_PARSED,this.onManifestParsed,this),e.on(sa.LEVEL_LOADING,this.onLevelLoading,this),e.on(sa.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(sa.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(sa.ERROR,this.onError,this)}unregisterListeners(){let{hls:e}=this;e.off(sa.MANIFEST_LOADING,this.onManifestLoading,this),e.off(sa.MANIFEST_PARSED,this.onManifestParsed,this),e.off(sa.LEVEL_LOADING,this.onLevelLoading,this),e.off(sa.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(sa.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(sa.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.tracksInGroup=[],this.groupIds=null,this.currentTrack=null,this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.audioTracks||[]}onAudioTrackLoaded(e,t){let{id:i,groupId:r,details:s}=t,a=this.tracksInGroup[i];if(!a||a.groupId!==r)return void this.warn(`Audio track with id:${i} and group:${r} not found in active group ${null==a?void 0:a.groupId}`);let n=a.details;a.details=t.details,this.log(`Audio track ${i} "${a.name}" lang:${a.lang} group:${r} loaded [${s.startSN}-${s.endSN}]`),i===this.trackId&&this.playlistLoaded(i,t,n)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){let t=this.hls.levels[e];if(!t)return;let i=t.audioGroups||null,r=this.groupIds,s=this.currentTrack;if(!i||(null==r?void 0:r.length)!==(null==i?void 0:i.length)||null!=i&&i.some(e=>(null==r?void 0:r.indexOf(e))===-1)){this.groupIds=i,this.trackId=-1,this.currentTrack=null;let e=this.tracks.filter(e=>!i||-1!==i.indexOf(e.groupId));if(e.length)this.selectDefaultTrack&&!e.some(e=>e.default)&&(this.selectDefaultTrack=!1),e.forEach((e,t)=>
28{e.id=t});else if(!s&&!this.tracksInGroup.length)return;this.tracksInGroup=e;let t=this.hls.config.audioPreference;if(!s&&t){let i=aS(t,e,aL);if(i>-1)s=e[i];else{let e=aS(t,this.tracks);s=this.tracks[e]}}let r=this.findTrackId(s);-1===r&&s&&(r=this.findTrackId(null)),this.log(`Updating audio tracks, ${e.length} track(s) found in group(s): ${null==i?void 0:i.join(",")}`),this.hls.trigger(sa.AUDIO_TRACKS_UPDATED,{audioTracks:e});let n=this.trackId;if(-1!==r&&-1===n)this.setAudioTrack(r);else if(e.length&&-1===n){var a;let t=Error(`No audio track selected for current audio group-ID(s): ${null==(a=this.groupIds)?void 0:a.join(",")} track count: ${e.length}`);this.warn(t.message),this.hls.trigger(sa.ERROR,{type:sr.MEDIA_ERROR,details:ss.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:t})}}}onError(e,t){!t.fatal&&t.context&&(t.context.type!==so||t.context.id!==this.trackId||this.groupIds&&-1===this.groupIds.indexOf(t.context.groupId)||this.checkRetry(t))}get allAudioTracks(){return this.tracks}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}setAudioOption(e){let t=this.hls;if(t.config.audioPreference=e,e){let s=this.allAudioTracks;
28if(this.selectDefaultTrack=!1,s.length){let a=this.currentTrack;if(a&&ak(e,a,aL))return a;let n=aS(e,this.tracksInGroup,aL);if(n>-1){let e=this.tracksInGroup[n];return this.setAudioTrack(n),e}if(a){var i,r;let a,n,l,o,d,h,u=t.loadLevel;-1===u&&(u=t.firstAutoLevel);let c=(i=t.levels,a=i[r=u],(n=i.reduce((e,t,i)=>{let r=t.uri;return(e[r]||(e[r]=[])).push(i),e},{})[a.uri]).length>1&&(r=Math.max.apply(Math,n)),l=a.videoRange,o=a.frameRate,d=a.codecSet.substring(0,4),(h=aR(i,r,t=>{if(t.videoRange!==l||t.frameRate!==o||t.codecSet.substring(0,4)!==d)return!1;let i=t.audioGroups;return aS(e,s.filter(e=>!i||-1!==i.indexOf(e.groupId)),aL)>-1}))>-1?h:aR(i,r,t=>{let i=t.audioGroups;return aS(e,s.filter(e=>!i||-1!==i.indexOf(e.groupId)),aL)>-1}));if(-1===c)return null;t.nextLoadLevel=c}if(e.channels||e.audioCodec){let t=aS(e,s);if(t>-1)return s[t]}}}return null}setAudioTrack(e){let t=this.tracksInGroup;if(e<0||e>=t.length)return void this.warn(`Invalid audio track id: ${e}`);this.selectDefaultTrack=!1;let i=this.currentTrack,r=t[e],s=r.details&&!r.details.live;if(e===this.trackId&&r===i&&s||(this.log(`Switching to audio-track ${e} "${r.name}" lang:${r.lang} group:${r.groupId} channels:${r.channels}`),this.trackId=e,this.currentTrack=r,this.hls.trigger(sa.AUDIO_TRACK_SWITCHING,sv({},r)),s))return;let a=this.switchParams(r.url,null==i?void 0:i.details,r.details);this.loadPlaylist(a)}findTrackId(e){let t=this.tracksInGroup;for(let i=0;i<t.length;i++){let r=t[i];if((!this.selectDefaultTrack||r.default)&&(!e||ak(e,r,aL)))return i}if(e){let{name:i,lang:r,assocLang:s,characteristics:a,audioCodec:n,channels:l}=e;for(let e=0;e<t.length;e++)if(ak({name:i,lang:r,assocLang:s,characteristics:a,audioCodec:n,channels:l},t[e],aL))return e;for(let i=0;i<t.length;i++){let r=t[i];if(oA(e.attrs,r.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return i}for(let i=0;i<t.length;i++){let r=t[i];if(oA(e.attrs,r.attrs,["LANGUAGE"]))return i}}return -1}loadPlaylist(e){super.loadPlaylist();let t=this.currentTrack;this.shouldLoadPlaylist(t)&&aI(t.url,this.hls)&&this.scheduleLoading(t,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);let i=e.id,r=e.groupId,s=this.getUrlWithDirectives(e.url,t),a=e.details,n=null==a?void 0:a.age;this.log(`Loading audio-track ${i} "${e.name}" lang:${e.lang} group:${r}${(null==t?void 0:t.msn)!==void 0?" at sn "+t.msn+" part "+t.part:""}${n&&a.live?" age "+n.toFixed(1)+(a.type?" "+a.type:""):""} ${s}`),this.hls.trigger(sa.AUDIO_TRACK_LOADING,{url:s,id:i,groupId:r,deliveryDirectives:t||null,track:e})}},emeController:da,cmcdController:class{constructor(e){this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.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:"m",su:!this.initialized})}catch(e){this.hls.logger.warn("Could not generate manifest CMCD data.",e)}},this.applyFragmentData=e=>{try{let{frag:t,part:i}=e,r=this.hls.levels[t.level],s=this.getObjectType(t),a={d:1e3*(i||t).duration,ot:s};("v"===s||"a"===s||"av"==s)&&(a.br=r.bitrate/1e3,a.tb=this.getTopBandwidth(s)/1e3,a.bl=this.getBufferLength(s));let n=i?this.getNextPart(i):this.getNextFrag(t);null!=n&&n.url&&n.url!==t.url&&(a.nor=n.url),this.apply(e,a)}catch(e){this.hls.logger.warn("Could not generate segment CMCD data.",e)}},this.hls=e;const t=this.config=e.config,{cmcd:i}=t;null!=i&&(t.pLoader=this.createPlaylistLoader(),t.fLoader=this.createFragmentLoader(),this.sid=i.sessionId||e.sessionId,this.cid=i.contentId,this.useHeaders=!0===i.useHeaders,this.includeKeys=i.includeKeys,this.registerListeners())}registerListeners(){let e=this.hls;e.on(sa.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(sa.MEDIA_DETACHED,this.onMediaDetached,this),e.on(sa.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){let e=this.hls;e.off(sa.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(sa.MEDIA_DETACHED,this.onMediaDetached,this),e.off(sa.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null,this.onWaiting=this.onPlaying=this.media=null}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}onMediaDetached(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}onBufferCreated(e,t){var i,r;this.audioBuffer=null==(i=t.tracks.audio)?void 0:i.buffer,this.videoBuffer=null==(r=t.tracks.video)?void 0:r.buffer}createData(){var e;return{v:1,sf:"h",sid:this.sid,cid:this.cid,pr:null==(e=this.media)?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){sp(t,this.createData());let i="i"===t.ot||"v"===t.ot||"av"===t.ot;this.starved&&i&&(t.bs=!0,t.su=!0,this.starved=!1),null==t.su&&(t.su=this.buffering);let{includeKeys:r}=this;r&&(t=Object.keys(t).reduce((e,i)=>(r.includes(i)&&(e[i]=t[i]),e),{}));let s={baseUrl:e.url};if(this.useHeaders){var a;e.headers||(e.headers={}),a=e.headers,sp(a,function(e,t={}){let i={};return e?Object.entries(function(e,t){let i={};if(!e)return i;let r=Object.keys(e),s=t?Object.keys(t).reduce((e,i)=>{var r;return null==(r=t[i])||r.forEach(t=>e[t]=i),e},{}):{};return r.reduce((t,i)=>{var r;let a=oY[i]||s[i]||oW;return(null!=(r=t[a])?r:t[a]={})[i]=e[i],t},i)}
28(dt(e,t),null==t?void 0:t.customHeaderMap)).reduce((e,[t,i])=>{let r=oV(i,{whitespace:!1});return r&&(e[t]=r),e},i):i}(t,s))}else e.url=function(e,t,i){let r=function(e,t={}){if(!e)return"";let i=function(e,t={}){return e?encodeURIComponent(function(e,t={}){return e?oV(dt(e,t),{whitespace:!1}):""}(e,t)):""}(e,t);return`CMCD=${i}`}(t,i);if(!r)return e;if(di.test(e))return e.replace(di,r);let s=e.includes("?")?"&":"?";return`${e}${s}${r}`}(e.url,t,s)}getNextFrag(e){var t;let i=null==(t=this.hls.levels[e.level])?void 0:t.details;if(i){let t=e.sn-i.startSN;return i.fragments[t+1]}}getNextPart(e){var t;let{index:i,fragment:r}=e,s=null==(t=this.hls.levels[r.level])||null==(t=t.details)?void 0:t.partList;if(s){let{sn:e}=r;for(let t=s.length-1;t>=0;t--){let r=s[t];if(r.index===i&&r.fragment.sn===e)return s[t+1]}}}getObjectType(e){let{type:t}=e;return"subtitle"===t?"tt":"initSegment"===e.sn?"i":"audio"===t?"a":"main"===t?this.hls.audioTracks.length?"v":"av":void 0}getTopBandwidth(e){let t,i=0,r=this.hls;if("a"===e)t=r.audioTracks;else{let e=r.maxAutoLevel,i=e>-1?e+1:r.levels.length;t=r.levels.slice(0,i)}return t.forEach(e=>{e.bitrate>i&&(i=e.bitrate)}),i>0?i:NaN}getBufferLength(e){let t=this.media,i="a"===e?this.audioBuffer:this.videoBuffer;return i&&t?1e3*a6.bufferInfo(i,t.currentTime,this.config.maxBufferHole).len:NaN}createPlaylistLoader(){let{pLoader:e}=this.config,t=this.applyPlaylistData,i=e||this.config.loader;return class{constructor(e){this.loader=void 0,this.loader=new i(e)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(e,i,r){t(e),this.loader.load(e,i,r)}}}createFragmentLoader(){let{fLoader:e}=this.config,t=this.applyFragmentData,i=e||this.config.loader;return class{constructor(e){this.loader=void 0,this.loader=new i(e)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(e,i,r){t(e),this.loader.load(e,i,r)}}}},contentSteeringController:class extends sE{constructor(e){super("content-steering",e.logger),this.hls=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this._pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=e,this.registerListeners()}registerListeners(){let e=this.hls;e.on(sa.MANIFEST_LOADING,this.onManifestLoading,this),e.on(sa.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(sa.MANIFEST_PARSED,this.onManifestParsed,this),e.on(sa.ERROR,this.onError,this)}unregisterListeners(){let e=this.hls;e&&(e.off(sa.MANIFEST_LOADING,this.onManifestLoading,this),e.off(sa.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(sa.MANIFEST_PARSED,this.onManifestParsed,this),e.off(sa.ERROR,this.onError,this))}pathways(){return(this.levels||[]).reduce((e,t)=>(-1===e.indexOf(t.pathwayId)&&e.push(t.pathwayId),e),[])}get pathwayPriority(){return this._pathwayPriority}set pathwayPriority(e){this.updatePathwayPriority(e)}startLoad(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){let e=1e3*this.timeToLoad-(performance.now()-this.updated);if(e>0)return void this.scheduleRefresh(this.uri,e)}this.loadSteeringManifest(this.uri)}}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()}clearTimeout(){-1!==this.reloadTimer&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(e){let t=this.levels;t&&(this.levels=t.filter(t=>t!==e))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(e,t){let{contentSteering:i}=t;null!==i&&(this.pathwayId=i.pathwayId,this.uri=i.uri,this.started&&this.startLoad())}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}onError(e,t){let{errorAction:i}=t;if((null==i?void 0:i.action)===2&&1===i.flags){let e=this.levels,r=this._pathwayPriority,s=this.pathwayId;if(t.context){let{groupId:i,pathwayId:r,type:a}=t.context;i&&e?s=this.getPathwayForGroupId(i,a,s):r&&(s=r)}s in this.penalizedPathways||(this.penalizedPathways[s]=performance.now()),!r&&e&&(r=this.pathways()),r&&r.length>1&&(this.updatePathwayPriority(r),i.resolved=this.pathwayId!==s),t.details!==ss.BUFFER_APPEND_ERROR||t.fatal?i.resolved||this.warn(`Could not resolve ${t.details} ("${t.error.message}") with content-steering for Pathway: ${s} levels: ${e?e.length:e} priorities: ${ab(r)} penalized: ${ab(this.penalizedPathways)}`):i.resolved=!0}}filterParsedLevels(e){this.levels=e;let t=this.getLevelsForPathway(this.pathwayId);if(0===t.length){let 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}getLevelsForPathway(e){return null===this.levels?[]:this.levels.filter(t=>e===t.pathwayId)}updatePathwayPriority(e){let t;this._pathwayPriority=e;let i=this.penalizedPathways,r=performance.now();
28Object.keys(i).forEach(e=>{r-i[e]>3e5&&delete i[e]});for(let r=0;r<e.length;r++){let s=e[r];if(s in i)continue;if(s===this.pathwayId)return;let a=this.hls.nextLoadLevel,n=this.hls.levels[a];if((t=this.getLevelsForPathway(s)).length>0){this.log(`Setting Pathway to "${s}"`),this.pathwayId=s,n2(t),this.hls.trigger(sa.LEVELS_UPDATED,{levels:t});let e=this.hls.levels[a];n&&e&&this.levels&&(e.attrs["STABLE-VARIANT-ID"]!==n.attrs["STABLE-VARIANT-ID"]&&e.bitrate!==n.bitrate&&this.log(`Unstable Pathways change from bitrate ${n.bitrate} to ${e.bitrate}`),this.hls.nextLoadLevel=a);break}}}getPathwayForGroupId(e,t,i){let r=this.getLevelsForPathway(i).concat(this.levels||[]);for(let i=0;i<r.length;i++)if(t===so&&r[i].hasAudioGroup(e)||t===sd&&r[i].hasSubtitleGroup(e))return r[i].pathwayId;return i}clonePathways(e){let t=this.levels;if(!t)return;let i={},r={};e.forEach(e=>{let{ID:s,"BASE-ID":a,"URI-REPLACEMENT":n}=e;if(t.some(e=>e.pathwayId===s))return;let l=this.getLevelsForPathway(a).map(e=>{let t=new nr(e.attrs);t["PATHWAY-ID"]=s;let a=t.AUDIO&&`${t.AUDIO}_clone_${s}`,l=t.SUBTITLES&&`${t.SUBTITLES}_clone_${s}`;a&&(i[t.AUDIO]=a,t.AUDIO=a),l&&(r[t.SUBTITLES]=l,t.SUBTITLES=l);let o=ds(e.uri,t["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",n),d=new aE({attrs:t,audioCodec:e.audioCodec,bitrate:e.bitrate,height:e.height,name:e.name,url:o,videoCodec:e.videoCodec,width:e.width});if(e.audioGroups)for(let t=1;t<e.audioGroups.length;t++)d.addGroupId("audio",`${e.audioGroups[t]}_clone_${s}`);if(e.subtitleGroups)for(let t=1;t<e.subtitleGroups.length;t++)d.addGroupId("text",`${e.subtitleGroups[t]}_clone_${s}`);return d});t.push(...l),dr(this.audioTracks,i,n,s),dr(this.subtitleTracks,r,n,s)})}loadSteeringManifest(e){let t,i=this.hls.config,r=i.loader;this.loader&&this.loader.destroy(),this.loader=new r(i);try{t=new self.URL(e)}catch(t){this.enabled=!1,this.log(`Failed to parse Steering Manifest URI: ${e}`);return}if("data:"!==t.protocol){let e=0|(this.hls.bandwidthEstimate||i.abrEwmaDefaultEstimate);t.searchParams.set("_HLS_pathway",this.pathwayId),t.searchParams.set("_HLS_throughput",""+e)}let s={responseType:"json",url:t.href},a=i.steeringManifestLoadPolicy.default,n=a.errorRetry||a.timeoutRetry||{},l={loadPolicy:a,timeout:a.maxLoadTimeMs,maxRetry:n.maxNumRetry||0,retryDelay:n.retryDelayMs||0,maxRetryDelay:n.maxRetryDelayMs||0};this.log(`Requesting steering manifest: ${t}`),this.loader.load(s,l,{onSuccess:(e,i,r,s)=>{this.log(`Loaded steering manifest: "${t}"`);let a=e.data;if((null==a?void 0:a.VERSION)!==1)return void this.log(`Steering VERSION ${a.VERSION} not supported!`);this.updated=performance.now(),this.timeToLoad=a.TTL;let{"RELOAD-URI":n,"PATHWAY-CLONES":l,"PATHWAY-PRIORITY":o}=a;if(n)try{this.uri=new self.URL(n,t).href}catch(e){this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${n}`);return}this.scheduleRefresh(this.uri||r.url),l&&this.clonePathways(l);let d={steeringManifest:a,url:t.toString()};this.hls.trigger(sa.STEERING_MANIFEST_LOADED,d),o&&this.updatePathwayPriority(o)},onError:(e,t,i,r)=>{if(this.log(`Error loading steering manifest: ${e.code} ${e.text} (${t.url})`),this.stopLoad(),410===e.code){this.enabled=!1,this.log(`Steering manifest ${t.url} no longer available`);return}let s=1e3*this.timeToLoad;if(429===e.code){let e=this.loader;if("function"==typeof(null==e?void 0:e.getResponseHeader)){let t=e.getResponseHeader("Retry-After");t&&(s=1e3*parseFloat(t))}this.log(`Steering manifest ${t.url} rate limited`);return}this.scheduleRefresh(this.uri||t.url,s)},onTimeout:(e,t,i)=>{this.log(`Timeout loading steering manifest (${t.url})`),this.scheduleRefresh(this.uri||t.url)}})}scheduleRefresh(e,t=1e3*this.timeToLoad){this.clearTimeout(),this.reloadTimer=self.setTimeout(()=>{var t;let i=null==(t=this.hls)?void 0:t.media;i&&!i.ended?this.loadSteeringManifest(e):this.scheduleRefresh(e,1e3*this.timeToLoad)},t)}},interstitialsController:class extends sE{constructor(e,t){super("interstitials",e.logger),this.HlsPlayerClass=void 0,this.hls=void 0,this.assetListLoader=void 0,this.mediaSelection=null,this.altSelection=null,this.media=null,this.detachedData=null,this.requiredTracks=null,this.manager=null,this.playerQueue=[],this.bufferedPos=-1,this.timelinePos=-1,this.schedule=void 0,this.playingItem=null,this.bufferingItem=null,this.waitingItem=null,this.endedItem=null,this.playingAsset=null,this.endedAsset=null,this.bufferingAsset=null,this.shouldPlay=!1,this.onPlay=()=>{this.shouldPlay=!0},this.onPause=()=>{this.shouldPlay=!1}
28,this.onSeeking=()=>{var e,t;let i=this.currentTime;if(void 0===i||this.playbackDisabled||!this.schedule)return;let r=i-this.timelinePos;if(Math.abs(r)<1/7056e5)return;let s=r<=-.01;this.timelinePos=i,this.bufferedPos=i;let a=this.playingItem;if(!a)return void this.checkBuffer();if(s&&this.schedule.resetErrorsInRange(i,i-r)&&this.updateSchedule(!0),this.checkBuffer(),s&&i<a.start||i>=a.end){let t=this.findItemIndex(a),r=this.schedule.findItemIndexAtTime(i);if(-1===r&&(r=t+(s?-1:1),this.log(`seeked ${s?"back ":""}to position not covered by schedule ${i} (resolving from ${t} to ${r})`)),!this.isInterstitial(a)&&null!=(e=this.media)&&e.paused&&(this.shouldPlay=!1),!s&&r>t){let e=this.schedule.findJumpRestrictedIndex(t+1,r);if(e>t)return void this.setSchedulePosition(e)}this.setSchedulePosition(r);return}let n=this.playingAsset;if(!n){if(this.playingLastItem&&this.isInterstitial(a)){let e=a.event.assetList[0];e&&(this.endedItem=this.playingItem,this.playingItem=null,this.setScheduleToAssetAtTime(i,e))}return}let l=n.timelineStart,o=n.duration||0;(s&&i<l||i>=l+o)&&(null!=(t=a.event)&&t.appendInPlace&&(this.clearAssetPlayers(a.event,a),this.flushFrontBuffer(i)),this.setScheduleToAssetAtTime(i,n))},this.onTimeupdate=()=>{let e=this.currentTime;if(void 0===e||this.playbackDisabled||!(e>this.timelinePos))return;this.timelinePos=e,e>this.bufferedPos&&this.checkBuffer();let t=this.playingItem;if(!t||this.playingLastItem)return;if(e>=t.end){this.timelinePos=t.end;let e=this.findItemIndex(t);this.setSchedulePosition(e+1)}let i=this.playingAsset;!i||e>=i.timelineStart+(i.duration||0)&&this.setScheduleToAssetAtTime(e,i)},this.onScheduleUpdate=(e,t)=>{let i=this.schedule;if(!i)return;let r=this.playingItem,s=i.events||[],a=i.items||[],n=i.durations,l=e.map(e=>e.identifier),o=!!(s.length||l.length);(o||t)&&this.log(`INTERSTITIALS_UPDATED (${s.length}): ${s}
29Schedule: ${a.map(e=>dS(e))} pos: ${this.timelinePos}`),l.length&&this.log(`Removed events ${l}`);let d=null,h=null;r&&(d=this.updateItem(r,this.timelinePos),this.itemsMatch(r,d)?this.playingItem=d:this.waitingItem=this.endedItem=null),this.waitingItem=this.updateItem(this.waitingItem),this.endedItem=this.updateItem(this.endedItem);let u=this.bufferingItem;if(u&&(h=this.updateItem(u,this.bufferedPos),this.itemsMatch(u,h)?this.bufferingItem=h:u.event&&(this.bufferingItem=this.playingItem,this.clearInterstitial(u.event,null))),e.forEach(e=>{e.assetList.forEach(e=>{this.clearAssetPlayer(e.identifier,null)})}),this.playerQueue.forEach(e=>{if(e.interstitial.appendInPlace){let t=e.assetItem.timelineStart,i=e.timelineOffset-t;if(i)try{e.timelineOffset=t}catch(r){Math.abs(i)>.025&&this.warn(`${r} ("${e.assetId}" ${e.timelineOffset}->${t})`)}}}),o||t){if(this.hls.trigger(sa.INTERSTITIALS_UPDATED,{events:s.slice(0),schedule:a.slice(0),durations:n,removedIds:l}),this.isInterstitial(r)&&l.includes(r.event.identifier)){this.warn(`Interstitial "${r.event.identifier}" removed while playing`),this.primaryFallback(r.event);return}r&&this.trimInPlace(d,r),u&&h!==d&&this.trimInPlace(h,u),this.checkBuffer()}},this.hls=e,this.HlsPlayerClass=t,this.assetListLoader=new dk(e),this.schedule=new dA(this.onScheduleUpdate,e.logger),this.registerListeners()}registerListeners(){let e=this.hls;e&&(e.on(sa.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(sa.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(sa.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(sa.MANIFEST_LOADING,this.onManifestLoading,this),e.on(sa.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(sa.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(sa.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.on(sa.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(sa.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.on(sa.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.on(sa.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.on(sa.BUFFER_APPENDED,this.onBufferAppended,this),e.on(sa.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(sa.BUFFERED_TO_END,this.onBufferedToEnd,this),e.on(sa.MEDIA_ENDED,this.onMediaEnded,this),e.on(sa.ERROR,this.onError,this),e.on(sa.DESTROYING,this.onDestroying,this))}unregisterListeners(){let e=this.hls;
29e&&(e.off(sa.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(sa.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(sa.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(sa.MANIFEST_LOADING,this.onManifestLoading,this),e.off(sa.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(sa.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(sa.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.off(sa.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(sa.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.off(sa.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.off(sa.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.off(sa.BUFFER_CODECS,this.onBufferCodecs,this),e.off(sa.BUFFER_APPENDED,this.onBufferAppended,this),e.off(sa.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(sa.BUFFERED_TO_END,this.onBufferedToEnd,this),e.off(sa.MEDIA_ENDED,this.onMediaEnded,this),e.off(sa.ERROR,this.onError,this),e.off(sa.DESTROYING,this.onDestroying,this))}startLoad(){this.resumeBuffering()}stopLoad(){this.pauseBuffering()}resumeBuffering(){var e;null==(e=this.getBufferingPlayer())||e.resumeBuffering()}pauseBuffering(){var e;null==(e=this.getBufferingPlayer())||e.pauseBuffering()}destroy(){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}onDestroying(){let e=this.primaryMedia||this.media;e&&this.removeMediaListeners(e)}removeMediaListeners(e){le(e,"play",this.onPlay),le(e,"pause",this.onPause),le(e,"seeking",this.onSeeking),le(e,"timeupdate",this.onTimeupdate)}onMediaAttaching(e,t){let i=this.media=t.media;n7(i,"seeking",this.onSeeking),n7(i,"timeupdate",this.onTimeupdate),n7(i,"play",this.onPlay),n7(i,"pause",this.onPause)}onMediaAttached(e,t){let i=this.effectivePlayingItem,r=this.detachedData;if(this.detachedData=null,null===i)this.checkStart();else if(!r){this.clearScheduleState();let e=this.findItemIndex(i);this.setSchedulePosition(e)}}clearScheduleState(){this.log("clear schedule state"),this.playingItem=this.bufferingItem=this.waitingItem=this.endedItem=this.playingAsset=this.endedAsset=this.bufferingAsset=null}onMediaDetaching(e,t){let i=!!t.transferMedia,r=this.media;if(this.media=null,!i&&(r&&this.removeMediaListeners(r),this.detachedData)){let e=this.getBufferingPlayer();e&&(this.log(`Removing schedule state for detachedData and ${e}`),this.playingAsset=this.endedAsset=this.bufferingAsset=this.bufferingItem=this.waitingItem=this.detachedData=null,e.detachMedia()),this.shouldPlay=!1}}get interstitialsManager(){if(!this.hls)return null;if(this.manager)return this.manager;let e=this,t=t=>t?e.getAssetPlayer(t.identifier):t,i=(i,s,a,n,l)=>{if(i){let o=i[s].start,d=i.event;if(d){if("playout"===s||d.timelineOccupancy!==dg.Point){let e=t(a);(null==e?void 0:e.interstitial)===d&&(o+=e.assetItem.startOffset+e[l])}}else o+=("bufferedPos"===n?r():e[n])-i.start;return o}return 0},r=()=>{let t=e.bufferedPos;return t===Number.MAX_VALUE?s("primary"):Math.max(t,0)},s=t=>{var i,r;return null!=(i=e.primaryDetails)&&i.live?e.primaryDetails.edge:(null==(r=e.schedule)?void 0:r.durations[t])||0},a=(r,s)=>{var a,n;let l=e.effectivePlayingItem;if(null!=l&&null!=(a=l.event)&&a.restrictions.skip||!e.schedule)return;e.log(`seek to ${r} "${s}"`);let o=e.effectivePlayingItem,d=e.schedule.findItemIndexAtTime(r,s),h=null==(n=e.schedule.items)?void 0:n[d],u=e.getBufferingPlayer(),c=null==u?void 0:u.interstitial,f=null==c?void 0:c.appendInPlace,m=o&&e.itemsMatch(o,h);if(o&&(f||m)){let a=t(e.playingAsset),n=(null==a?void 0:a.media)||e.primaryMedia;if(n){let t="primary"===s?n.currentTime:i(o,s,e.playingAsset,"timelinePos","currentTime"),l=r-t,d=(f?t:n.currentTime)+l;if(d>=0&&(!a||f||d<=a.duration)){n.currentTime=d;return}}}if(h){let t=r;if("primary"!==s){let e=r-h[s].start;t=h.start+e}let i=!e.isInterstitial(h);if((!e.isInterstitial(o)||o.event.appendInPlace)&&(i||h.event.appendInPlace)){let i=e.media||(f?null==u?void 0:u.media:null);i&&(i.currentTime=t)}else if(o){let a=e.findItemIndex(o);if(d>a){let t=e.schedule.findJumpRestrictedIndex(a+1,d);if(t>a)return void e.setSchedulePosition(t)}let n=0;if(i)e.timelinePos=t,e.checkBuffer();else{let e=h.event.assetList,t=r-(h[s]||h).start;for(let i=e.length;i--;){let r=e[i];if(r.duration&&t>=r.startOffset&&t<r.startOffset+r.duration){n=i;break}}}e.setSchedulePosition(d,n)}}},n=()=>{let t=e.effectivePlayingItem;if(e.isInterstitial(t))return t;let i=e.bufferingItem||e.waitingItem;return e.isInterstitial(i)?i:null},l={get bufferedEnd(){let t=e.bufferingItem||e.waitingItem,r=e.bufferingItem;if(r&&r===t){var o;return i(r,"playout",e.bufferingAsset,"bufferedPos","bufferedEnd")-r.playout.start||(null==(o=e.bufferingAsset)?void 0:o.startOffset)||0}return 0},get currentTime(){let t=n(),r=e.effectivePlayingItem;if(r&&r===t)return i(r,"playout",e.effectivePlayingAsset,"timelinePos","currentTime")-r.playout.start;return 0},set currentTime(time){let t=n(),i=e.effectivePlayingItem;i&&i===t&&a(time+i.playout.start,"playout")},get duration(){let e=n();if(e)return e.playout.end-e.playout.start;return 0},get assetPlayers(){var d;let t=null==(d=n())?void 0:d.event.assetList;if(t)return t.map(t=>e.getAssetPlayer(t.identifier));return[]},get playingIndex(){var h;let t=null==(h=n())?void 0:h.event;if(t&&e.effectivePlayingAsset)return t.findAssetIndex(e.effectivePlayingAsset);return -1},get scheduleItem(){return n()}};return this.manager={get events(){var u;return(null==(u=e.schedule)||null==(u=u.events)?void 0:u.slice(0))||[]},get schedule(){var c;return(null==(c=e.schedule)||null==(c=c.items)?void 0:c.slice(0))||[]},get interstitialPlayer(){if(n())return l;return null},get playerQueue(){return e.playerQueue.slice(0)},get bufferingAsset(){return e.bufferingAsset},get bufferingItem(){return e.bufferingItem||e.waitingItem},get bufferingIndex(){let t=e.bufferingItem||e.waitingItem;return e.findItemIndex(t)},get playingAsset(){return e.effectivePlayingAsset},get playingItem(){return e.effectivePlayingItem},get playingIndex(){let t=e.effectivePlayingItem;return e.findItemIndex(t)},primary:{get bufferedEnd(){return r()},get currentTime(){let t=e.timelinePos;return t>0?t:0},set currentTime(time){a(time,"primary")},get duration(){return s("primary")},get seekableStart(){var f;return(null==(f=e.primaryDetails)?void 0:f.fragmentStart)||0}},integrated:{get bufferedEnd(){return i(e.bufferingItem||e.waitingItem,"integrated",e.bufferingAsset,"bufferedPos","bufferedEnd")},get currentTime(){return i(e.effectivePlayingItem,"integrated",e.effectivePlayingAsset,"timelinePos","currentTime")},set currentTime(time){a(time,"integrated")},get duration(){return s("integrated")},get seekableStart(){var m;return((t,i)=>{var r,s;if(0!==t&&"primary"!==i&&null!=(r=e.schedule)&&r.length){let r=e.schedule.findItemIndexAtTime(t),a=null==(s=e.schedule.items)?void 0:s[r];if(a)return t+(a[i].start-a.start)}return t})((null==(m=e.primaryDetails)?void 0:m.fragmentStart)||0,"integrated")}},skip:()=>{let t=e.effectivePlayingItem,i=null==t?void 0:t.event;if(i&&!i.restrictions.skip){let r=e.findItemIndex(t);i.appendInPlace?a(t.playout.start+t.event.duration+.001,"playout"):e.advanceAfterAssetEnded(i,r,1/0)}}}}get effectivePlayingItem(){return this.waitingItem||this.playingItem||this.endedItem}get effectivePlayingAsset(){return this.playingAsset||this.endedAsset}get playingLastItem(){var e;let t=this.playingItem,i=null==(e=this.schedule)?void 0:e.items;return!!this.playbackStarted&&!!t&&!!i&&this.findItemIndex(t)===i.length-1}get playbackStarted(){return null!==this.effectivePlayingItem}get currentTime(){var e,t;if(null===this.mediaSelection)return;let i=this.waitingItem||this.playingItem;if(this.isInterstitial(i)&&!i.event.appendInPlace)return;let r=this.media;!r&&null!=(e=this.bufferingItem)&&null!=(e=e.event)&&e.appendInPlace&&(r=this.primaryMedia);let s=null==(t=r)?void 0:t.currentTime;if(void 0!==s&&se(s))return s}get primaryMedia(){var e;return this.media||(null==(e=this.detachedData)?void 0:e.media)||null}isInterstitial(e){return!!(null!=e&&e.event)}retreiveMediaSource(e,t){let i=this.getAssetPlayer(e);i&&this.transferMediaFromPlayer(i,t)}transferMediaFromPlayer(e,t){let i=e.interstitial.appendInPlace,r=e.media;if(i&&r===this.primaryMedia){if(this.bufferingAsset=null,(!t||this.isInterstitial(t)&&!t.event.appendInPlace)&&t&&r){this.detachedData={media:r};return}let i=e.transferMedia();this.log(`transfer MediaSource from ${e} ${ab(i)}`),this.detachedData=i}else t&&r&&(this.shouldPlay||(this.shouldPlay=!r.paused))}transferMediaTo(e,t){var i,r;let s;if(e.media===t)return;let a=null,n=this.hls,l=e!==n,o=l&&e.interstitial.appendInPlace,d=null==(i=this.detachedData)?void 0:i.mediaSource;if(n.media)o&&(a=n.transferMedia(),this.detachedData=a),s="Primary";
29else if(d){let e=this.getBufferingPlayer();e?(a=e.transferMedia(),s=`${e}`):s="detached MediaSource"}else s="detached media";if(!a){if(d)a=this.detachedData,this.log(`using detachedData: MediaSource ${ab(a)}`);else if(!this.detachedData||n.media===t){let e=this.playerQueue;e.length>1&&e.forEach(e=>{if(l&&e.interstitial.appendInPlace!==o){let 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}}}let h=a&&"mediaSource"in a&&(null==(r=a.mediaSource)?void 0:r.readyState)!=="closed",u=h&&a?a:t;this.log(`${h?"transfering MediaSource":"attaching media"} to ${l?e:"Primary"} from ${s} (media.currentTime: ${t.currentTime})`);let c=this.schedule;if(u===a&&c){let t=l&&e.assetId===c.assetIdAtEnd;u.overrides={duration:c.duration,endOfStream:!l||t,cueRemoval:!l}}e.attachMedia(u)}onInterstitialCueEnter(){this.onTimeupdate()}checkStart(){let e=this.schedule,t=null==e?void 0:e.events;if(!t||this.playbackDisabled||!this.media)return;-1===this.bufferedPos&&(this.bufferedPos=0);let i=this.timelinePos,r=this.effectivePlayingItem;if(-1===i){let i=this.hls.startPosition;if(this.log(dR("checkStart",i)),this.timelinePos=i,t.length&&t[0].cue.pre){let i=e.findEventIndex(t[0].identifier);this.setSchedulePosition(i)}else if(i>=0||!this.primaryLive){let t=this.timelinePos=i>0?i:0,r=e.findItemIndexAtTime(t);this.setSchedulePosition(r)}}else if(r&&!this.playingItem){let t=e.findItemIndex(r);this.setSchedulePosition(t)}}advanceAssetBuffering(e,t){let i=e.event,r=i.findAssetIndex(t),s=db(i,r);if(i.isAssetPastPlayoutLimit(s)){if(this.schedule){var a;let t=null==(a=this.schedule.items)?void 0:a[this.findItemIndex(e)+1];t&&this.bufferedToItem(t)}}else this.bufferedToEvent(e,s)}advanceAfterAssetEnded(e,t,i){let r=db(e,i);if(e.isAssetPastPlayoutLimit(r)){if(this.schedule){let i=this.schedule.items;if(i){let r=t+1;if(r>=i.length)return void this.setSchedulePosition(-1);let s=e.resumeTime;this.timelinePos<s&&(this.log(dR("advanceAfterAssetEnded",s)),this.timelinePos=s,e.appendInPlace&&this.advanceInPlace(s),this.checkBuffer(this.bufferedPos<s)),this.setSchedulePosition(r)}}}else{if(e.appendInPlace){let t=e.assetList[r];t&&this.advanceInPlace(t.timelineStart)}this.setSchedulePosition(t,r)}}setScheduleToAssetAtTime(e,t){let i=this.schedule;if(!i)return;let r=t.parentIdentifier,s=i.getEvent(r);if(s){let t=i.findEventIndex(r),a=i.findAssetIndex(s,e);this.advanceAfterAssetEnded(s,t,a-1)}}setSchedulePosition(e,t){var i,r,s;let a=null==(i=this.schedule)?void 0:i.items;if(!a||this.playbackDisabled)return;let n=e>=0?a[e]:null;this.log(`setSchedulePosition ${e}, ${t} (${n?dS(n):n}) pos: ${this.timelinePos}`);let l=this.waitingItem||this.playingItem,o=this.playingLastItem;if(this.isInterstitial(l)){let i=l.event,d=this.playingAsset,h=null==d?void 0:d.identifier,u=h?this.getAssetPlayer(h):null;if(u&&h&&(!this.eventItemsMatch(l,n)||void 0!==t&&h!==i.assetList[t].identifier)){let t=i.findAssetIndex(d);if(this.log(`INTERSTITIAL_ASSET_ENDED ${t+1}/${i.assetList.length} ${dT(d)}`),this.endedAsset=d,this.playingAsset=null,this.hls.trigger(sa.INTERSTITIAL_ASSET_ENDED,{asset:d,assetListIndex:t,event:i,schedule:a.slice(0),scheduleIndex:e,player:u}),l!==this.playingItem){this.itemsMatch(l,this.playingItem)&&!this.playingAsset&&this.advanceAfterAssetEnded(i,this.findItemIndex(this.playingItem),t);return}this.retreiveMediaSource(h,n),u.media&&!(null!=(r=this.detachedData)&&r.mediaSource)&&u.detachMedia()}if(!this.eventItemsMatch(l,n)&&(this.endedItem=l,this.playingItem=null,this.log(`INTERSTITIAL_ENDED ${i} ${dS(l)}`),i.hasPlayed=!0,this.hls.trigger(sa.INTERSTITIAL_ENDED,{event:i,schedule:a.slice(0),scheduleIndex:e}),i.cue.once)){this.updateSchedule();let e=null==(s=this.schedule)?void 0:s.items;if(n&&e){let i=this.findItemIndex(n);this.advanceSchedule(i,e,t,l,o)}return}}this.advanceSchedule(e,a,t,l,o)}advanceSchedule(e,t,i,r,s){let a=this.schedule;if(!a)return;let n=t[e]||null,l=this.primaryMedia,o=this.playerQueue;if(o.length&&o.forEach(t=>{let i=t.interstitial,r=a.findEventIndex(i.identifier);(r<e||r>e+1)&&this.clearInterstitial(i,n)}),this.isInterstitial(n)){this.timelinePos=Math.min(Math.max(this.timelinePos,n.start),n.end);let s=n.event;if(void 0===i){i=a.findAssetIndex(s,this.timelinePos);let t=db(s,i-1);
29if(s.isAssetPastPlayoutLimit(t)||s.appendInPlace&&this.timelinePos===n.end)return void this.advanceAfterAssetEnded(s,e,i);i=t}let o=this.waitingItem;this.assetsBuffered(n,l)||this.setBufferingItem(n);let d=this.preloadAssets(s,i);if(this.eventItemsMatch(n,o||r)||(this.waitingItem=n,this.log(`INTERSTITIAL_STARTED ${dS(n)} ${s.appendInPlace?"append in place":""}`),this.hls.trigger(sa.INTERSTITIAL_STARTED,{event:s,schedule:t.slice(0),scheduleIndex:e})),!s.assetListLoaded)return void this.log(`Waiting for ASSET-LIST to complete loading ${s}`);if(s.assetListLoader&&(s.assetListLoader.destroy(),s.assetListLoader=void 0),!l)return void this.log(`Waiting for attachMedia to start Interstitial ${s}`);this.waitingItem=this.endedItem=null,this.playingItem=n;let h=s.assetList[i];if(!h)return void this.advanceAfterAssetEnded(s,e,i||0);if(d||(d=this.getAssetPlayer(h.identifier)),null===d||d.destroyed){let e=s.assetList.length;this.warn(`asset ${i+1}/${e} player destroyed ${s}`),(d=this.createAssetPlayer(s,h,i)).loadSource()}if(!this.eventItemsMatch(n,this.bufferingItem)&&s.appendInPlace&&this.isAssetBuffered(h))return;this.startAssetPlayer(d,i,t,e,l),this.shouldPlay&&dL(d.media)}else n?(this.resumePrimary(n,e,r),this.shouldPlay&&dL(this.hls.media)):s&&this.isInterstitial(r)&&(this.endedItem=null,this.playingItem=r,r.event.appendInPlace||this.attachPrimary(a.durations.primary,null))}get playbackDisabled(){return!1===this.hls.config.enableInterstitialPlayback}get primaryDetails(){var e;return null==(e=this.mediaSelection)?void 0:e.main.details}get primaryLive(){var e;return!!(null!=(e=this.primaryDetails)&&e.live)}resumePrimary(e,t,i){var r,s;if(this.playingItem=e,this.playingAsset=this.endedAsset=null,this.waitingItem=this.endedItem=null,this.bufferedToItem(e),this.log(`resuming ${dS(e)}`),!(null!=(r=this.detachedData)&&r.mediaSource)){let i=this.timelinePos;(i<e.start||i>=e.end)&&(i=this.getPrimaryResumption(e,t),this.log(dR("resumePrimary",i)),this.timelinePos=i),this.attachPrimary(i,e)}if(!i)return;let a=null==(s=this.schedule)?void 0:s.items;a&&(this.log(`INTERSTITIALS_PRIMARY_RESUMED ${dS(e)}`),this.hls.trigger(sa.INTERSTITIALS_PRIMARY_RESUMED,{schedule:a.slice(0),scheduleIndex:t}),this.checkBuffer())}getPrimaryResumption(e,t){let i=e.start;if(this.primaryLive){let e=this.primaryDetails;if(0===t)return this.hls.startPosition;if(e&&(i<e.fragmentStart||i>e.edge))return this.hls.liveSyncPosition||-1}return i}isAssetBuffered(e){let t=this.getAssetPlayer(e.identifier);return null!=t&&t.hls?t.hls.bufferedToEnd:a6.bufferInfo(this.primaryMedia,this.timelinePos,0).end+1>=e.timelineStart+(e.duration||0)}attachPrimary(e,t,i){t?this.setBufferingItem(t):this.bufferingItem=this.playingItem,this.bufferingAsset=null;let r=this.primaryMedia;if(!r)return;let s=this.hls;s.media?this.checkBuffer():(this.transferMediaTo(s,r),i&&this.startLoadingPrimaryAt(e,i)),i||(this.log(dR("attachPrimary",e)),this.timelinePos=e,this.startLoadingPrimaryAt(e,i))}startLoadingPrimaryAt(e,t){var i;let r=this.hls;!r.loadingEnabled||!r.media||Math.abs(((null==(i=r.mainForwardBufferInfo)?void 0:i.start)||r.media.currentTime)-e)>.5?r.startLoad(e,t):r.bufferingEnabled||r.resumeBuffering()}onManifestLoading(){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(sa.BUFFER_CODECS,this.onBufferCodecs,this),this.hls.on(sa.BUFFER_CODECS,this.onBufferCodecs,this)}onLevelUpdated(e,t){if(-1===t.level||!this.schedule)return;let i=this.hls.levels[t.level];if(!i.details)return;let r=sv(sv({},this.mediaSelection||this.altSelection),{},{main:i});this.mediaSelection=r,this.schedule.parseInterstitialDateRanges(r,this.hls.config.interstitialAppendInPlace),!this.effectivePlayingItem&&this.schedule.items&&this.checkStart()}onAudioTrackUpdated(e,t){let i=this.hls.audioTracks[t.id],r=this.mediaSelection;if(!r){this.altSelection=sv(sv({},this.altSelection),{},{audio:i});return}let s=sv(sv({},r),{},{audio:i});this.mediaSelection=s}onSubtitleTrackUpdated(e,t){let i=this.hls.subtitleTracks[t.id],r=this.mediaSelection;if(!r){this.altSelection=sv(sv({},this.altSelection),{},{subtitles:i});return}let s=sv(sv({},r),{},{subtitles:i});this.mediaSelection=s}onAudioTrackSwitching(e,t){let i=aA(t);this.playerQueue.forEach(({hls:e})=>
29e&&(e.setAudioOption(t)||e.setAudioOption(i)))}onSubtitleTrackSwitch(e,t){let i=aA(t);this.playerQueue.forEach(({hls:e})=>e&&(e.setSubtitleOption(t)||-1!==t.id&&e.setSubtitleOption(i)))}onBufferCodecs(e,t){let i=t.tracks;i&&(this.requiredTracks=i)}onBufferAppended(e,t){this.checkBuffer()}onBufferFlushed(e,t){let i=this.playingItem;if(i&&!this.itemsMatch(i,this.bufferingItem)&&!this.isInterstitial(i)){let e=this.timelinePos;this.bufferedPos=e,this.checkBuffer()}}onBufferedToEnd(e){if(!this.schedule)return;let t=this.schedule.events;if(this.bufferedPos<Number.MAX_VALUE&&t){for(let e=0;e<t.length;e++){let r=t[e];if(r.cue.post){var i;let e=this.schedule.findEventIndex(r.identifier),t=null==(i=this.schedule.items)?void 0:i[e];this.isInterstitial(t)&&this.eventItemsMatch(t,this.bufferingItem)&&this.bufferedToItem(t,0);break}}this.bufferedPos=Number.MAX_VALUE}}onMediaEnded(e){let t=this.playingItem;if(!this.playingLastItem&&t){let e=this.findItemIndex(t);this.setSchedulePosition(e+1)}else this.shouldPlay=!1}updateItem(e,t){var i;let r=null==(i=this.schedule)?void 0:i.items;return e&&r&&r[this.findItemIndex(e,t)]||null}trimInPlace(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)});let i=e.end+.25,r=a6.bufferInfo(this.primaryMedia,i,0);(r.end>i||(r.nextStart||0)>i)&&(this.log(`trim buffered interstitial ${dS(e)} (was ${dS(t)})`),this.attachPrimary(i,null,!0),this.flushFrontBuffer(i))}}itemsMatch(e,t){return!!t&&(e===t||e.event&&t.event&&this.eventItemsMatch(e,t)||!e.event&&!t.event&&this.findItemIndex(e)===this.findItemIndex(t))}eventItemsMatch(e,t){var i;return!!t&&(e===t||e.event.identifier===(null==(i=t.event)?void 0:i.identifier))}findItemIndex(e,t){return e&&this.schedule?this.schedule.findItemIndex(e,t):-1}updateSchedule(e=!1){var t;let i=this.mediaSelection;i&&(null==(t=this.schedule)||t.updateSchedule(i,[],e))}checkBuffer(e){var t;let i=null==(t=this.schedule)?void 0:t.items;if(!i)return;let r=a6.bufferInfo(this.primaryMedia,this.timelinePos,0);e&&(this.bufferedPos=this.timelinePos),e||(e=r.len<1),this.updateBufferedPos(r.end,i,e)}updateBufferedPos(e,t,i){let r=this.schedule,s=this.bufferingItem;if(this.bufferedPos>e||!r)return;if(1===t.length&&this.itemsMatch(t[0],s)){this.bufferedPos=e;return}let a=this.playingItem,n=this.findItemIndex(a),l=r.findItemIndexAtTime(e);if(this.bufferedPos<e){var o;let i=this.findItemIndex(s),r=Math.min(i+1,t.length-1),a=t[r];if((-1===l&&s&&e>=s.end||null!=(o=a.event)&&o.appendInPlace&&e+.01>=a.start)&&(l=r),this.isInterstitial(s)){let e=s.event;if(r-n>1&&!1===e.appendInPlace||0===e.assetList.length&&e.assetListLoader)return}if(this.bufferedPos=e,l>i&&l>n)this.bufferedToItem(a);else{let t=this.primaryDetails;this.primaryLive&&t&&e>t.edge-t.targetduration&&a.start<t.edge+this.hls.config.interstitialLiveLookAhead&&this.isInterstitial(a)&&this.preloadAssets(a.event,0)}}else i&&a&&!this.itemsMatch(a,s)&&(l===n?this.bufferedToItem(a):l===n+1&&this.bufferedToItem(t[l]))}assetsBuffered(e,t){return 0!==e.event.assetList.length&&!e.event.assetList.some(e=>{let i=this.getAssetPlayer(e.identifier);return!(null!=i&&i.bufferedInPlaceToEnd(t))})}setBufferingItem(e){let t=this.bufferingItem,i=this.schedule;if(!this.itemsMatch(e,t)&&i){let{items:r,events:s}=i;if(!r||!s)return t;let a=this.isInterstitial(e),n=this.getBufferingPlayer();this.bufferingItem=e,this.bufferedPos=Math.max(e.start,Math.min(e.end,this.timelinePos));let l=n?n.remaining:t?t.end-this.timelinePos:0;if(this.log(`INTERSTITIALS_BUFFERED_TO_BOUNDARY ${dS(e)}`+(t?` (${l.toFixed(2)} remaining)`:"")),!this.playbackDisabled)if(a){let t=i.findAssetIndex(e.event,this.bufferedPos);e.event.assetList.forEach((e,i)=>{let r=this.getAssetPlayer(e.identifier);r&&(i===t&&r.loadSource(),r.resumeBuffering())})}else this.hls.resumeBuffering(),this.playerQueue.forEach(e=>e.pauseBuffering());this.hls.trigger(sa.INTERSTITIALS_BUFFERED_TO_BOUNDARY,{events:s.slice(0),schedule:r.slice(0),bufferingIndex:this.findItemIndex(e),playingIndex:this.findItemIndex(this.playingItem)})}else this.bufferingItem!==e&&(this.bufferingItem=e);return t}bufferedToItem(e,t=0){let i=this.setBufferingItem(e);if(!this.playbackDisabled){if(this.isInterstitial(e))this.bufferedToEvent(e,t);else if(null!==i){this.bufferingAsset=null;let t=this.detachedData;t&&t.mediaSource?this.attachPrimary(e.start,e,!0):this.preloadPrimary(e)}}}preloadPrimary(e){let t=this.findItemIndex(e),i=this.getPrimaryResumption(e,t);this.startLoadingPrimaryAt(i)}bufferedToEvent(e,t){let i=e.event,r=0===i.assetList.length&&!i.assetListLoader,s=i.cue.once;if(r||!s){let e=this.preloadAssets(i,t);if(null!=e&&e.interstitial.appendInPlace){let t=this.primaryMedia;t&&this.bufferAssetPlayer(e,t)}}}preloadAssets(e,t){let i=e.assetUrl,r=e.assetList.length,s=0===r&&!e.assetListLoader,a=e.cue.once;if(s){let s,a=e.timelineStart;if(e.appendInPlace){var n;let t=this.playingItem;this.isInterstitial(t)||(null==t||null==(n=t.nextEvent)?void 0:n.identifier)!==e.identifier||this.flushFrontBuffer(a+.25)}let l=0;if(!this.playingItem&&this.primaryLive&&-1===(l=this.hls.startPosition)&&(l=this.hls.liveSyncPosition||0),l&&!(e.cue.pre||e.cue.post)){let e=l-a;e>0&&(s=Math.round(1e3*e)/1e3)}if(this.log(`Load interstitial asset ${t+1}/${i?1:r} ${e}${s?` live-start: ${l} start-offset: ${s}`:""}`),i)return this.createAsset(e,0,0,a,e.duration,i);let o=this.assetListLoader.loadAssetList(e,s);o&&(e.assetListLoader=o)}else if(!a&&r){for(let i=t;i<r;i++){let t=e.assetList[i],r=this.getAssetPlayerQueueIndex(t.identifier);(-1===r||this.playerQueue[r].destroyed)&&!t.error&&this.createAssetPlayer(e,t,i)}let i=e.assetList[t];if(i){let e=this.getAssetPlayer(i.identifier);return e&&e.loadSource(),e}}return null}flushFrontBuffer(e){let t=this.requiredTracks;t&&(this.log(`Removing front buffer starting at ${e}`),Object.keys(t).forEach(t=>{this.hls.trigger(sa.BUFFER_FLUSHING,{startOffset:e,endOffset:1/0,type:t})}))}getAssetPlayerQueueIndex(e){let t=this.playerQueue;for(let i=0;i<t.length;i++)if(e===t[i].assetId)return i;return -1}getAssetPlayer(e){let t=this.getAssetPlayerQueueIndex(e);return this.playerQueue[t]||null}
29getBufferingPlayer(){let{playerQueue:e,primaryMedia:t}=this;if(t){for(let i=0;i<e.length;i++)if(e[i].media===t)return e[i]}return null}createAsset(e,t,i,r,s,a){let n={parentIdentifier:e.identifier,identifier:`${e.identifier}-${t+1}-${dp(a)}`,duration:s,startOffset:i,timelineStart:r,uri:a};return this.createAssetPlayer(e,n,t)}createAssetPlayer(e,t,i){let r=this.hls,s=r.userConfig,a=s.videoPreference,n=r.loadLevelObj||r.levels[r.currentLevel];(a||n)&&(a=sp({},a),n.videoCodec&&(a.videoCodec=n.videoCodec),n.videoRange&&(a.allowedVideoRanges=[n.videoRange]));let l=r.audioTracks[r.audioTrack],o=r.subtitleTracks[r.subtitleTrack],d=0;if(this.primaryLive||e.appendInPlace){let e=this.timelinePos-t.timelineStart;if(e>1){let i=t.duration;i&&e<i&&(d=e)}}let h=t.identifier,u=sv(sv({},s),{},{maxMaxBufferLength:Math.min(180,r.config.maxMaxBufferLength),autoStartLoad:!0,startFragPrefetch:!0,primarySessionId:r.sessionId,assetPlayerId:h,abrEwmaDefaultEstimate:r.bandwidthEstimate,interstitialsController:void 0,startPosition:d,liveDurationInfinity:!1,testBandwidth:!1,videoPreference:a,audioPreference:l||s.audioPreference,subtitlePreference:o||s.subtitlePreference});e.appendInPlace&&(e.appendInPlaceStarted=!0,t.timelineStart&&(u.timelineOffset=t.timelineStart));let c=u.cmcd;null!=c&&c.sessionId&&c.contentId&&(u.cmcd=sp({},c,{contentId:dp(t.uri)})),this.getAssetPlayer(h)&&this.warn(`Duplicate date range identifier ${e} and asset ${h}`);let f=new d_(this.HlsPlayerClass,u,e,t);this.playerQueue.push(f),e.assetList[i]=t;let m=!0,g=r=>{if(r.live){var s;let t=Error(`Interstitials MUST be VOD assets ${e}`),r={fatal:!0,type:sr.OTHER_ERROR,details:ss.INTERSTITIAL_ASSET_ITEM_ERROR,error:t},a=(null==(s=this.schedule)?void 0:s.findEventIndex(e.identifier))||-1;this.handleAssetItemError(r,e,a,i,t.message);return}let a=r.edge-r.fragmentStart,n=t.duration;(m||null===n||a>n)&&(m=!1,this.log(`Interstitial asset "${h}" duration change ${n} > ${a}`),t.duration=a,this.updateSchedule())};f.on(sa.LEVEL_UPDATED,(e,{details:t})=>g(t)),f.on(sa.LEVEL_PTS_UPDATED,(e,{details:t})=>g(t)),f.on(sa.EVENT_CUE_ENTER,()=>this.onInterstitialCueEnter());let v=(e,t)=>{let i=this.getAssetPlayer(h);if(i&&t.tracks){i.off(sa.BUFFER_CODECS,v),i.tracks=t.tracks;let e=this.primaryMedia;this.bufferingAsset===i.assetItem&&e&&!i.media&&this.bufferAssetPlayer(i,e)}};f.on(sa.BUFFER_CODECS,v);let E=()=>{var i;let r=this.getAssetPlayer(h);if(this.log(`buffered to end of asset ${r}`),!r||!this.schedule)return;let s=this.schedule.findEventIndex(e.identifier),a=null==(i=this.schedule.items)?void 0:i[s];this.isInterstitial(a)&&this.advanceAssetBuffering(a,t)};f.on(sa.BUFFERED_TO_END,E);let y=t=>()=>{if(!this.getAssetPlayer(h)||!this.schedule)return;this.shouldPlay=!0;let i=this.schedule.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,i,t)};return f.once(sa.MEDIA_ENDED,y(i)),f.once(sa.PLAYOUT_LIMIT_REACHED,y(1/0)),f.on(sa.ERROR,(t,r)=>{if(!this.schedule)return;let s=this.getAssetPlayer(h);r.details===ss.BUFFER_STALLED_ERROR?null!=s&&s.appendInPlace?this.handleInPlaceStall(e):(this.onTimeupdate(),this.checkBuffer(!0)):this.handleAssetItemError(r,e,this.schedule.findEventIndex(e.identifier),i,`Asset player error ${r.error} ${e}`)}),f.on(sa.DESTROYING,()=>{if(!this.getAssetPlayer(h)||!this.schedule)return;let t=Error(`Asset player destroyed unexpectedly ${h}`),r={fatal:!0,type:sr.OTHER_ERROR,details:ss.INTERSTITIAL_ASSET_ITEM_ERROR,error:t};this.handleAssetItemError(r,e,this.schedule.findEventIndex(e.identifier),i,t.message)}),this.log(`INTERSTITIAL_ASSET_PLAYER_CREATED ${dT(t)}`),this.hls.trigger(sa.INTERSTITIAL_ASSET_PLAYER_CREATED,{asset:t,assetListIndex:i,event:e,player:f}),f}clearInterstitial(e,t){this.clearAssetPlayers(e,t),e.reset()}clearAssetPlayers(e,t){e.assetList.forEach(e=>{this.clearAssetPlayer(e.identifier,t)})}resetAssetPlayer(e){let t=this.getAssetPlayerQueueIndex(e);if(-1!==t){this.log(`reset asset player "${e}" after error`);let i=this.playerQueue[t];this.transferMediaFromPlayer(i,null),i.resetDetails()}}clearAssetPlayer(e,t){let i=this.getAssetPlayerQueueIndex(e);if(-1!==i){let e=this.playerQueue[i];this.log(`clear ${e} toSegment: ${t?dS(t):t}`),this.transferMediaFromPlayer(e,t),this.playerQueue.splice(i,1),e.destroy()}}emptyPlayerQueue(){let e;for(;e=this.playerQueue.pop();)e.destroy();this.playerQueue=[]}
29startAssetPlayer(e,t,i,r,s){let{interstitial:a,assetItem:n,assetId:l}=e,o=a.assetList.length,d=this.playingAsset;this.endedAsset=null,this.playingAsset=n,d&&d.identifier===l||(d&&(this.clearAssetPlayer(d.identifier,i[r]),delete d.error),this.log(`INTERSTITIAL_ASSET_STARTED ${t+1}/${o} ${dT(n)}`),this.hls.trigger(sa.INTERSTITIAL_ASSET_STARTED,{asset:n,assetListIndex:t,event:a,schedule:i.slice(0),scheduleIndex:r,player:e})),this.bufferAssetPlayer(e,s)}bufferAssetPlayer(e,t){var i,r;if(!this.schedule)return;let{interstitial:s,assetItem:a}=e,n=this.schedule.findEventIndex(s.identifier),l=null==(i=this.schedule.items)?void 0:i[n];if(!l)return;e.loadSource(),this.setBufferingItem(l),this.bufferingAsset=a;let o=this.getBufferingPlayer();if(o===e)return;let d=s.appendInPlace;if(d&&(null==o?void 0:o.interstitial.appendInPlace)===!1)return;let h=(null==o?void 0:o.tracks)||(null==(r=this.detachedData)?void 0:r.tracks)||this.requiredTracks;if(d&&a!==this.playingAsset){if(!e.tracks)return void this.log(`Waiting for track info before buffering ${e}`);if(h&&!sk(h,e.tracks)){let t=Error(`Asset ${dT(a)} SourceBuffer tracks ('${Object.keys(e.tracks)}') are not compatible with primary content tracks ('${Object.keys(h)}')`),i={fatal:!0,type:sr.OTHER_ERROR,details:ss.INTERSTITIAL_ASSET_ITEM_ERROR,error:t},r=s.findAssetIndex(a);this.handleAssetItemError(i,s,n,r,t.message);return}}this.transferMediaTo(e,t)}handleInPlaceStall(e){let t=this.schedule,i=this.primaryMedia;if(!t||!i)return;let r=i.currentTime,s=t.findAssetIndex(e,r),a=e.assetList[s];if(a){let n=this.getAssetPlayer(a.identifier);if(n){let l=n.currentTime||r-a.timelineStart,o=n.duration-l;if(this.warn(`Stalled at ${l} of ${l+o} in ${n} ${e} (media.currentTime: ${r})`),l&&(o/i.playbackRate<.5||n.bufferedInPlaceToEnd(i))&&n.hls){let i=t.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,i,s)}}}}advanceInPlace(e){let t=this.primaryMedia;t&&t.currentTime<e&&(t.currentTime=e)}handleAssetItemError(e,t,i,r,s){if(e.details===ss.BUFFER_STALLED_ERROR)return;let a=t.assetList[r]||null;if(this.warn(`INTERSTITIAL_ASSET_ERROR ${a?dT(a):a} ${e.error}`),!this.schedule)return;let n=(null==a?void 0:a.identifier)||"",l=this.getAssetPlayerQueueIndex(n),o=this.playerQueue[l]||null,d=this.schedule.items,h=sp({},e,{fatal:!1,errorAction:aH(!0),asset:a,assetListIndex:r,event:t,schedule:d,scheduleIndex:i,player:o});if(this.hls.trigger(sa.INTERSTITIAL_ASSET_ERROR,h),!e.fatal)return;let u=this.playingAsset,c=this.bufferingAsset,f=Error(s);if(a&&(this.clearAssetPlayer(n,null),a.error=f),t.assetList.some(e=>!e.error))for(let e=r;e<t.assetList.length;e++)this.resetAssetPlayer(t.assetList[e].identifier);else t.error=f;this.updateSchedule(!0),t.error?this.primaryFallback(t):u&&u.identifier===n?this.advanceAfterAssetEnded(t,i,r):c&&c.identifier===n&&this.isInterstitial(this.bufferingItem)&&this.advanceAssetBuffering(this.bufferingItem,c)}primaryFallback(e){let t=e.timelineStart,i=this.effectivePlayingItem,r=this.timelinePos;if(i){this.log(`Fallback to primary from event "${e.identifier}" start: ${t} pos: ${r} playing: ${dS(i)} error: ${e.error}`),-1===r&&(r=this.hls.startPosition);let s=this.updateItem(i,r);this.itemsMatch(i,s)&&this.clearInterstitial(e,null),e.appendInPlace&&(this.attachPrimary(t,null),this.flushFrontBuffer(t))}else if(-1===r)return void this.checkStart();if(!this.schedule)return;let s=this.schedule.findItemIndexAtTime(r);this.setSchedulePosition(s)}onAssetListLoaded(e,t){var i,r,s;let a=t.event,n=a.identifier,l=t.assetListResponse.ASSETS;if(!(null!=(i=this.schedule)&&i.hasEvent(n)))return;let o=a.timelineStart,d=a.duration,h=0;l.forEach((e,t)=>{let i=parseFloat(e.DURATION);this.createAsset(a,t,h,o+h,i,e.URI),h+=i}),a.duration=h,this.log(`Loaded asset-list with duration: ${h} (was: ${d}) ${a}`);let u=this.waitingItem,c=(null==u?void 0:u.event.identifier)===n;this.updateSchedule();let f=null==(r=this.bufferingItem)?void 0:r.event;if(c){let e=this.schedule.findEventIndex(n),t=null==(s=this.schedule.items)?void 0:s[e];if(t){if(!this.playingItem&&this.timelinePos>t.end&&this.schedule.findItemIndexAtTime(this.timelinePos)!==e){a.error=Error(`Interstitial ${l.length?"no longer within playback range":"asset-list is empty"} ${this.timelinePos} ${a}`),this.log(a.error.message),this.updateSchedule(!0),this.primaryFallback(a);return}this.setBufferingItem(t)}this.setSchedulePosition(e)}else if((null==f?void 0:f.identifier)===n){let e=a.assetList[0];if(e){let t=this.getAssetPlayer(e.identifier);if(f.appendInPlace){let e=this.primaryMedia;t&&e&&this.bufferAssetPlayer(t,e)}else t&&t.loadSource()}}}onError(e,t){if(this.schedule)switch(t.details){case ss.ASSET_LIST_PARSING_ERROR:case ss.ASSET_LIST_LOAD_ERROR:case ss.ASSET_LIST_LOAD_TIMEOUT:{let e=t.interstitial;e&&(this.updateSchedule(!0),this.primaryFallback(e));break}case ss.BUFFER_STALLED_ERROR:{let e=this.endedItem||this.waitingItem||this.playingItem;if(this.isInterstitial(e)&&e.event.appendInPlace)return void this.handleInPlaceStall(e.event);this.log(`Primary player stall @${this.timelinePos} bufferedPos: ${this.bufferedPos}`),this.onTimeupdate(),this.checkBuffer(!0)}}}}});class hv extends a3{constructor(e,t){super("gap-controller",e.logger),this.hls=void 0,this.fragmentTracker=void 0,this.media=null,this.mediaSource=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.buffered={},this.lastCurrentTime=0,this.ended=0,this.waiting=0,this.onMediaPlaying=()=>{this.ended=0,this.waiting=0},this.onMediaWaiting=()=>{var e;null!=(e=this.media)&&e.seeking||(this.waiting=self.performance.now(),this.tick())},this.onMediaEnded=()=>
29{if(this.hls){var e;this.ended=(null==(e=this.media)?void 0:e.currentTime)||1,this.hls.trigger(sa.MEDIA_ENDED,{stalled:!1})}},this.hls=e,this.fragmentTracker=t,this.registerListeners()}registerListeners(){let{hls:e}=this;e&&(e.on(sa.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(sa.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(sa.BUFFER_APPENDED,this.onBufferAppended,this))}unregisterListeners(){let{hls:e}=this;e&&(e.off(sa.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(sa.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(sa.BUFFER_APPENDED,this.onBufferAppended,this))}destroy(){super.destroy(),this.unregisterListeners(),this.media=this.hls=this.fragmentTracker=null,this.mediaSource=void 0}onMediaAttached(e,t){this.setInterval(100),this.mediaSource=t.mediaSource;let i=this.media=t.media;n7(i,"playing",this.onMediaPlaying),n7(i,"waiting",this.onMediaWaiting),n7(i,"ended",this.onMediaEnded)}onMediaDetaching(e,t){this.clearInterval();let{media:i}=this;i&&(le(i,"playing",this.onMediaPlaying),le(i,"waiting",this.onMediaWaiting),le(i,"ended",this.onMediaEnded),this.media=null),this.mediaSource=void 0}onBufferAppended(e,t){this.buffered=t.timeRanges}get hasBuffered(){return Object.keys(this.buffered).length>0}tick(){var e;if(!(null!=(e=this.media)&&e.readyState)||!this.hasBuffered)return;let t=this.media.currentTime;this.poll(t,this.lastCurrentTime),this.lastCurrentTime=t}poll(e,t){var i,r,s;let a=null==(i=this.hls)?void 0:i.config;if(!a)return;let n=this.media;if(!n)return;let{seeking:l}=n,o=this.seeking&&!l,d=!this.seeking&&l,h=n.paused&&!l||n.ended||0===n.playbackRate;if(this.seeking=l,e!==t){t&&(this.ended=0),this.moved=!0,!l&&(this.nudgeRetry=0,a.nudgeOnVideoHole&&!h&&e>t&&this.nudgeOnVideoHole(e,t)),0===this.waiting&&this.stallResolved(e);return}if(d||o){o&&this.stallResolved(e);return}if(h){this.nudgeRetry=0,this.stallResolved(e),!this.ended&&n.ended&&this.hls&&(this.ended=e||1,this.hls.trigger(sa.MEDIA_ENDED,{stalled:!1}));return}if(!a6.getBuffered(n).length){this.nudgeRetry=0;return}let u=a6.bufferInfo(n,e,0),c=u.nextStart||0,f=this.fragmentTracker;if(l&&f&&this.hls){let t=hE(this.hls.inFlightFragments,e),i=u.len>2,r=!c||t||c-e>2&&!f.getPartialFragment(e);if(i||r)return;this.moved=!1}let m=null==(r=this.hls)?void 0:r.latestLevelDetails;if(!this.moved&&null!==this.stalled&&f){if(!(u.len>0)&&!c)return;let t=Math.max(c,u.start||0)-e,i=null!=m&&m.live?2*m.targetduration:2,r=hb(e,f);if(t>0&&(t<=i||r)){n.paused||this._trySkipBufferHole(r);return}}let g=a.detectStallWithCurrentTimeMs,v=self.performance.now(),E=this.waiting,y=this.stalled;if(null===y)if(E>0&&v-E<g)y=this.stalled=E;else{this.stalled=v;return}let b=v-y;if(!l&&(b>=g||E)&&this.hls){if((null==(s=this.mediaSource)?void 0:s.readyState)==="ended"&&!(null!=m&&m.live)&&1>Math.abs(e-((null==m?void 0:m.edge)||0))){if(this.ended)return;this.ended=e||1,this.hls.trigger(sa.MEDIA_ENDED,{stalled:!0});return}if(this._reportStall(u),!this.media||!this.hls)return}let T=a6.bufferInfo(n,e,a.maxBufferHole);this._tryFixBufferStall(T,b,e)}stallResolved(e){let t=this.stalled;if(t&&this.hls&&(this.stalled=null,this.stallReported)){let 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(sa.STALL_RESOLVED,{})}}nudgeOnVideoHole(e,t){var i;let r=this.buffered.video;if(this.hls&&this.media&&this.fragmentTracker&&null!=(i=this.buffered.audio)&&i.length&&r&&r.length>1&&e>r.end(0)){let i=a6.bufferedInfo(a6.timeRangesToArray(this.buffered.audio),e,0);if(i.len>1&&t>=i.start){let i=a6.timeRangesToArray(r),s=a6.bufferedInfo(i,t,0).bufferedIndex;if(s>-1&&s<i.length-1){let t=a6.bufferedInfo(i,e,0).bufferedIndex,r=i[s].end,a=i[s+1].start;if((-1===t||t>s)&&a-r<1&&e-r<2){let i=Error(`nudging playhead to flush pipeline after video hole. currentTime: ${e} hole: ${r} -> ${a} buffered index: ${t}`);this.warn(i.message),this.media.currentTime+=1e-6;let s=hb(e,this.fragmentTracker);s&&"fragment"in s?s=s.fragment:s||(s=void 0);let n=a6.bufferInfo(this.media,e,0);this.hls.trigger(sa.ERROR,{type:sr.MEDIA_ERROR,details:ss.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:i,reason:i.message,frag:s,buffer:n.len,bufferInfo:n})}}}}}_tryFixBufferStall(e,t,i){var r,s;let{fragmentTracker:a,media:n}=this,l=null==(r=this.hls)?void 0:r.config;if(!n||!a||!l)return;let o=null==(s=this.hls)?void 0:s.latestLevelDetails,d=hb(i,a);if((d||null!=o&&o.live&&i<o.fragmentStart)&&(this._trySkipBufferHole(d)||!this.media))return;let h=e.buffered,u=this.adjacentTraversal(e,i);(h&&h.length>1&&e.len>l.maxBufferHole||e.nextStart&&(e.nextStart-i<l.maxBufferHole||u))&&(t>1e3*l.highBufferWatchdogPeriod||this.waiting)&&(this.warn("Trying to nudge playhead over buffer-hole"),this._tryNudgeBuffer(e))}adjacentTraversal(e,t){let i=this.fragmentTracker,r=e.nextStart;if(i&&r){let e=i.getFragAtPos(t,sh),s=i.getFragAtPos(r,sh);if(e&&s)return s.sn-e.sn<2}return!1}_reportStall(e){let{hls:t,media:i,stallReported:r,stalled:s}=this;if(!r&&null!==s&&i&&t){this.stallReported=!0;let r=Error(`Playback stalling at @${i.currentTime} due to low buffer (${ab(e)})`);this.warn(r.message),t.trigger(sa.ERROR,{type:sr.MEDIA_ERROR,details:ss.BUFFER_STALLED_ERROR,fatal:!1,error:r,buffer:e.len,bufferInfo:e,stalled:{start:s}})}}_trySkipBufferHole(e){var t,i;let{fragmentTracker:r,media:s}=this,a=null==(t=this.hls)?void 0:t.config;if(!s||!r||!a)return 0;let n=s.currentTime,l=a6.bufferInfo(s,n,0),o=n<l.start?l.start:l.nextStart;if(o&&this.hls){let t=l.len<=a.maxBufferHole,d=l.len>0&&l.len<1&&s.readyState<3,h=o-n;if(h>0&&(t||d)){if(h>a.maxBufferHole){let t=!1;if(0===n){let e=r.getAppendedFrag(0,sh);e&&o<e.end&&(t=!0)}if(!t&&e){if(!(null!=(i=this.hls.loadLevelObj)&&i.details)||hE(this.hls.inFlightFragments,o))return 0;let t=!1,s=e.end;for(;s<o;){let e=hb(s,r);if(e)s+=e.duration;else{t=!0;break}}if(t)return 0}}let t=Math.max(o+.05,n+.1);if(this.warn(`skipping hole, adjusting currentTime from ${n} to ${t}`),this.moved=!0,s.currentTime=t,!(null!=e&&e.gap)){let i=Error(`fragment loaded with buffer holes, seeking from ${n} to ${t}`),r={type:sr.MEDIA_ERROR,details:ss.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:i,reason:i.message,buffer:l.len,bufferInfo:l};e&&("fragment"in e?r.part=e:r.frag=e),this.hls.trigger(sa.ERROR,r)}return t}}return 0}_tryNudgeBuffer(e){let{hls:t,media:i,nudgeRetry:r}=this,s=null==t?void 0:t.config;if(!i||!s)return 0;let a=i.currentTime;if(this.nudgeRetry++,r<s.nudgeMaxRetry){let n=a+(r+1)*s.nudgeOffset,l=Error(`Nudging 'currentTime' from ${a} to ${n}`);this.warn(l.message),i.currentTime=n,t.trigger(sa.ERROR,{type:sr.MEDIA_ERROR,details:ss.BUFFER_NUDGE_ON_STALL,error:l,fatal:!1,buffer:e.len,bufferInfo:e})}else{let i=Error(`Playhead still not moving while enough data buffered @${a} after ${s.nudgeMaxRetry} nudges`);this.error(i.message),t.trigger(sa.ERROR,{type:sr.MEDIA_ERROR,details:ss.BUFFER_STALLED_ERROR,error:i,fatal:!0,buffer:e.len,bufferInfo:e})}}}function hE(e,t){let i=hy(e.main);if(i&&i.start<=t)return i;let r=hy(e.audio);return r&&r.start<=t?r:null}function hy(e){if(!e)return null;switch(e.state){case lr:case li:case lh:case lu:return null}return e.frag}function hb(e,t){return t.getAppendedFrag(e,sh)||t.getPartialFragment(e)}function hT(){if("u">typeof self)return self.VTTCue||self.TextTrackCue}function h_(e,t,i,r,s){let a=new e(t,i,"");try{a.value=r,s&&(a.type=s)}catch(n){a=new e(t,i,ab(s?sv({type:s},r):r))}return a}let hA=(()=>{let e=hT();try{e&&new e(0,1/0,"")}catch(e){return Number.MAX_VALUE}return 1/0})();class hS{constructor(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(sa.EVENT_CUE_ENTER,{})},this.hls=e,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=this.onEventCueEnter=null}_registerListeners(){let{hls:e}=this;
29e&&(e.on(sa.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(sa.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(sa.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(sa.MANIFEST_LOADING,this.onManifestLoading,this),e.on(sa.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(sa.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(sa.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(sa.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}_unregisterListeners(){let{hls:e}=this;e&&(e.off(sa.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(sa.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(sa.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(sa.MANIFEST_LOADING,this.onManifestLoading,this),e.off(sa.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(sa.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(sa.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(sa.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}onMediaAttaching(e,t){var i;this.media=t.media,(null==(i=t.overrides)?void 0:i.cueRemoval)===!1&&(this.removeCues=!1)}onMediaAttached(){var e;let t=null==(e=this.hls)?void 0:e.latestLevelDetails;t&&this.updateDateRangeCues(t)}onMediaDetaching(e,t){this.media=null,t.transferMedia||(this.id3Track&&(this.removeCues&&dc(this.id3Track,this.onEventCueEnter),this.id3Track=null),this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(e){let t=this.getID3Track(e.textTracks);return t.mode="hidden",t}getID3Track(e){if(this.media){for(let t=0;t<e.length;t++){let i=e[t];if("metadata"===i.kind&&"id3"===i.label)return dh(i,this.media),i}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(e,t){if(!this.media||!this.hls)return;let{enableEmsgMetadataCues:i,enableID3MetadataCues:r}=this.hls.config;if(!i&&!r)return;let{samples:s}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));let a=hT();if(a)for(let e=0;e<s.length;e++){let t=s[e].type;if(t===lO.emsg&&!i||!r)continue;let n=lP(s[e].data),l=s[e].pts,o=l+s[e].duration;o>hA&&(o=hA),o-l<=0&&(o=l+.25);for(let e=0;e<n.length;e++){let i=n[e];if(!lx(i)){this.updateId3CueEnds(l,t);let e=h_(a,l,o,i,t);e&&this.id3Track.addCue(e)}}}}updateId3CueEnds(e,t){var i;let r=null==(i=this.id3Track)?void 0:i.cues;if(r)for(let i=r.length;i--;){let s=r[i];s.type===t&&s.startTime<e&&s.endTime===hA&&(s.endTime=e)}}onBufferFlushing(e,{startOffset:t,endOffset:i,type:r}){let{id3Track:s,hls:a}=this;if(!a)return;let{config:{enableEmsgMetadataCues:n,enableID3MetadataCues:l}}=a;s&&(n||l)&&df(s,t,i,"audio"===r?e=>
29e.type===lO.audioId3&&l:"video"===r?e=>e.type===lO.emsg&&n:e=>e.type===lO.audioId3&&l||e.type===lO.emsg&&n)}onLevelUpdated(e,{details:t}){this.updateDateRangeCues(t,!0)}onLevelPtsUpdated(e,t){Math.abs(t.drift)>.01&&this.updateDateRangeCues(t.details)}updateDateRangeCues(e,t){var i,r;if(!this.hls||!this.media)return;let{assetPlayerId:s,timelineOffset:a,enableDateRangeMetadataCues:n,interstitialsController:l}=this.hls.config;if(!n)return;let o=hT();if(s&&a&&!l){let{fragmentStart:t,fragmentEnd:i}=e,r=this.assetCue;r?(r.startTime=t,r.endTime=i):o&&(r=this.assetCue=h_(o,t,i,{assetPlayerId:this.hls.config.assetPlayerId},"hlsjs.interstitial.asset"))&&(r.id=s,this.id3Track||(this.id3Track=this.createTrack(this.media)),this.id3Track.addCue(r),r.addEventListener("enter",this.onEventCueEnter))}if(!e.hasProgramDateTime)return;let{id3Track:d}=this,{dateRanges:h}=e,u=Object.keys(h),c=this.dateRangeCuesAppended;if(d&&t)if(null!=(i=d.cues)&&i.length){let e=Object.keys(c).filter(e=>!u.includes(e));for(let t=e.length;t--;){let i=e[t],s=null==(r=c[i])?void 0:r.cues;delete c[i],s&&Object.keys(s).forEach(e=>{let t=s[e];if(t){t.removeEventListener("enter",this.onEventCueEnter);try{d.removeCue(t)}catch(e){}}})}}else c=this.dateRangeCuesAppended={};let f=e.fragments[e.fragments.length-1];if(0!==u.length&&se(null==f?void 0:f.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(let e=0;e<u.length;e++){let t=u[e],i=h[t],r=i.startTime,s=c[t],a=(null==s?void 0:s.cues)||{},n=(null==s?void 0:s.durationKnown)||!1,d=hA,{duration:f,endDate:m}=i;if(m&&null!==f)d=r+f,n=!0;else if(i.endOnNext&&!n){let e=u.reduce((e,t)=>{if(t!==i.id){let r=h[t];if(r.class===i.class&&r.startDate>i.startDate&&(!e||i.startDate<e.startDate))return r}return e},null);e&&(d=e.startTime,n=!0)}let g=Object.keys(i.attr);for(let e=0;e<g.length;e++){let h=g[e];if("ID"===h||"CLASS"===h||"CUE"===h||"START-DATE"===h||"DURATION"===h||"END-DATE"===h||"END-ON-NEXT"===h)continue;let u=a[h];if(u)n&&!(null!=s&&s.durationKnown)?u.endTime=d:Math.abs(u.startTime-r)>.01&&(u.startTime=r,u.endTime=d);else if(o){let e=i.attr[h];("SCTE35-OUT"===h||"SCTE35-IN"===h||"SCTE35-CMD"===h)&&(e=sI(e));let s=h_(o,r,d,{key:h,data:e},lO.dateRange);s&&(s.id=t,this.id3Track.addCue(s),a[h]=s,l&&("X-ASSET-LIST"===h||"X-ASSET-URL"===h)&&s.addEventListener("enter",this.onEventCueEnter))}}c[t]={cues:a,dateRange:i,durationKnown:n}}}}}class hk{constructor(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=()=>{let{media:e}=this,t=this.levelDetails;if(!e||!t)return;this.currentTime=e.currentTime;let i=this.computeLatency();if(null===i)return;this._latency=i;let{lowLatencyMode:r,maxLiveSyncPlaybackRate:s}=this.config;if(!r||1===s||!t.live)return;let a=this.targetLatency;if(null===a)return;let n=i-a;if(n<Math.min(this.maxLatency,a+t.targetduration)&&n>.05&&this.forwardBufferLength>1){let t=Math.min(Math.min(2,Math.max(1,s)),Math.max(1,Math.round(2/(1+Math.exp(-.75*n-this.edgeStalled))*20)/20));this.changeMediaPlaybackRate(e,t)}else 1!==e.playbackRate&&0!==e.playbackRate&&this.changeMediaPlaybackRate(e,1)},this.hls=e,this.config=e.config,this.registerListeners()}get levelDetails(){var e;return(null==(e=this.hls)?void 0:e.latestLevelDetails)||null}get latency(){return this._latency||0}get maxLatency(){let{config:e}=this;if(void 0!==e.liveMaxLatencyDuration)return e.liveMaxLatencyDuration;let t=this.levelDetails;return t?e.liveMaxLatencyDurationCount*t.targetduration:0}get targetLatency(){let e=this.levelDetails;if(null===e||null===this.hls)return null;let{holdBack:t,partHoldBack:i,targetduration:r}=e,{liveSyncDuration:s,liveSyncDurationCount:a,lowLatencyMode:n}=this.config,l=this.hls.userConfig,o=n&&i||t;return(this._targetLatencyUpdated||l.liveSyncDuration||l.liveSyncDurationCount||0===o)&&(o=void 0!==s?s:a*r),o+Math.min(this.stallCount*this.config.liveSyncOnStallIncrease,r)}set targetLatency(e){this.stallCount=0,this.config.liveSyncDuration=e,this._targetLatencyUpdated=!0}get liveSyncPosition(){let e=this.estimateLiveEdge(),t=this.targetLatency;if(null===e||null===t)return null;let i=this.levelDetails;if(null===i)return null;let r=i.edge,s=e-t-this.edgeStalled;return Math.min(Math.max(r-i.totalduration,s),r-(this.config.lowLatencyMode&&i.partTarget||i.targetduration))}get drift(){let e=this.levelDetails;return null===e?1:e.drift}get edgeStalled(){let e=this.levelDetails;if(null===e)return 0;let t=3*(this.config.lowLatencyMode&&e.partTarget||e.targetduration);return Math.max(e.age-t,0)}get forwardBufferLength(){let{media:e}=this,t=this.levelDetails;if(!e||!t)return 0;let i=e.buffered.length;return(i?e.buffered.end(i-1):t.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.hls=null}registerListeners(){let{hls:e}=this;
29e&&(e.on(sa.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(sa.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(sa.MANIFEST_LOADING,this.onManifestLoading,this),e.on(sa.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(sa.ERROR,this.onError,this))}unregisterListeners(){let{hls:e}=this;e&&(e.off(sa.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(sa.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(sa.MANIFEST_LOADING,this.onManifestLoading,this),e.off(sa.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(sa.ERROR,this.onError,this))}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.onTimeupdate)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.onTimeupdate),this.media=null)}onManifestLoading(){this._latency=null,this.stallCount=0}onLevelUpdated(e,{details:t}){t.advanced&&this.onTimeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.onTimeupdate)}onError(e,t){var i;t.details===ss.BUFFER_STALLED_ERROR&&(this.stallCount++,this.hls&&null!=(i=this.levelDetails)&&i.live&&this.hls.logger.warn("[latency-controller]: Stall detected, adjusting target latency"))}changeMediaPlaybackRate(e,t){var i,r;e.playbackRate!==t&&(null==(i=this.hls)||i.logger.debug(`[latency-controller]: latency=${this.latency.toFixed(3)}, targetLatency=${null==(r=this.targetLatency)?void 0:r.toFixed(3)}, forwardBufferLength=${this.forwardBufferLength.toFixed(3)}: adjusting playback rate from ${e.playbackRate} to ${t}`),e.playbackRate=t)}estimateLiveEdge(){let e=this.levelDetails;return null===e?null:e.edge+e.age}computeLatency(){let e=this.estimateLiveEdge();return null===e?null:e-this.currentTime}}class hL extends oT{constructor(e,t){super(e,"level-controller"),this._levels=[],this._firstLevel=-1,this._maxAutoLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=t,this._registerListeners()}_registerListeners(){let{hls:e}=this;e.on(sa.MANIFEST_LOADING,this.onManifestLoading,this),e.on(sa.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(sa.LEVEL_LOADED,this.onLevelLoaded,this),e.on(sa.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(sa.FRAG_BUFFERED,this.onFragBuffered,this),e.on(sa.ERROR,this.onError,this)}_unregisterListeners(){let{hls:e}=this;e.off(sa.MANIFEST_LOADING,this.onManifestLoading,this),e.off(sa.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(sa.LEVEL_LOADED,this.onLevelLoaded,this),e.off(sa.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(sa.FRAG_BUFFERED,this.onFragBuffered,this),e.off(sa.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}stopLoad(){this._levels.forEach(e=>{e.loadError=0,e.fragmentError=0}),super.stopLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1}onManifestLoading(e,t){this.resetLevels()}onManifestLoaded(e,t){let i=this.hls.config.preferManagedMediaSource,r=[],s={},a={},n=!1,l=!1,o=!1;t.levels.forEach(e=>{let t=e.attrs,{audioCodec:d,videoCodec:h}=e;d&&(e.audioCodec=d=as(d,i)||void 0),h&&(h=e.videoCodec=function(e){let t=e.split(",");for(let e=0;e<t.length;e++){let i=t[e].split(".");i.length>2&&"avc1"===i[0]&&(t[e]=`avc1.${parseInt(i[1]).toString(16)}${("000"+parseInt(i[2]).toString(16)).slice(-4)}`)}return t.join(",")}(h));let{width:u,height:c,unknownCodecs:f}=e,m=(null==f?void 0:f.length)||0;if(n||(n=!!(u&&c)),l||(l=!!h),o||(o=!!d),m||d&&!this.isAudioSupported(d)||h&&!this.isVideoSupported(h))return void this.log(`Some or all CODECS not supported "${t.CODECS}"`);let{CODECS:g,"FRAME-RATE":v,"HDCP-LEVEL":E,"PATHWAY-ID":y,RESOLUTION:b,"VIDEO-RANGE":T}=t,_=`${y||"."}-`,A=`${_}${e.bitrate}-${b}-${v}-${g}-${T}-${E}`;if(s[A])if(s[A].uri===e.url||e.attrs["PATHWAY-ID"])s[A].addGroupId("audio",t.AUDIO),s[A].addGroupId("text",t.SUBTITLES);else{let t=a[A]+=1;e.attrs["PATHWAY-ID"]=Array(t+1).join(".");let i=this.createLevel(e);s[A]=i,r.push(i)}else{let t=this.createLevel(e);s[A]=t,a[A]=1,r.push(t)}}),this.filterAndSortMediaOptions(r,t,n,l,o)}createLevel(e){let t=new aE(e),i=e.supplemental;if(null!=i&&i.videoCodec&&!this.isVideoSupported(i.videoCodec)){let e=Error(`SUPPLEMENTAL-CODECS not supported "${i.videoCodec}"`);this.log(e.message),t.supportedResult=au(e,[])}return t}isAudioSupported(e){return s6(e,"audio",this.hls.config.preferManagedMediaSource)}isVideoSupported(e){return s6(e,"video",this.hls.config.preferManagedMediaSource)}filterAndSortMediaOptions(e,t,i,r,s){var a,n;let l=[],o=[],d=e,h=(null==(a=t.stats)?void 0:a.parsing)||{};if((i||r)&&s&&(d=d.filter(({videoCodec:e,videoRange:t,width:i,height:r})=>{var s;return(!!e||!!(i&&r))&&!!(s=t)&&ap.indexOf(s)>-1})),0===d.length){Promise.resolve().then(()=>
29{if(this.hls){let e="no level with compatible codecs found in manifest",i=e;t.levels.length&&(i=`one or more CODECS in variant not supported: ${ab(t.levels.map(e=>e.attrs.CODECS).filter((e,t,i)=>i.indexOf(e)===t))}`,this.warn(i),e+=` (${i})`);let r=Error(e);this.hls.trigger(sa.ERROR,{type:sr.MEDIA_ERROR,details:ss.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:r,reason:i})}}),h.end=performance.now();return}t.audioTracks&&hR(l=t.audioTracks.filter(e=>!e.audioCodec||this.isAudioSupported(e.audioCodec))),t.subtitles&&hR(o=t.subtitles);let u=d.slice(0);d.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){let i=ae(e.videoCodec),r=ae(t.videoCodec);if(i!==r)return r-i}if(e.uri===t.uri&&e.codecSet!==t.codecSet){let i=at(e.codecSet),r=at(t.codecSet);if(i!==r)return r-i}return e.averageBitrate!==t.averageBitrate?e.averageBitrate-t.averageBitrate:0});let c=u[0];if(this.steering&&(d=this.steering.filterParsedLevels(d)).length!==u.length){for(let e=0;e<u.length;e++)if(u[e].pathwayId===d[0].pathwayId){c=u[e];break}}this._levels=d;for(let e=0;e<d.length;e++)if(d[e]===c){this._firstLevel=e;let t=c.bitrate,i=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${d.length} level(s) found, first bitrate: ${t}`),(null==(n=this.hls.userConfig)?void 0:n.abrEwmaDefaultEstimate)===void 0){let e=Math.min(t,this.hls.config.abrEwmaDefaultEstimateMax);e>i&&i===this.hls.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=e)}break}let f=s&&!r,m=this.hls.config,g=!!(m.audioStreamController&&m.audioTrackController),v={levels:d,audioTracks:l,subtitleTracks:o,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:s,video:r,altAudio:g&&!f&&l.some(e=>!!e.url)};h.end=performance.now(),this.hls.trigger(sa.MANIFEST_PARSED,v)}get levels(){return 0===this._levels.length?null:this._levels}get loadLevelObj(){return this.currentLevel}get level(){return this.currentLevelIndex}set level(e){let t=this._levels;if(0===t.length)return;if(e<0||e>=t.length){let i=Error("invalid level idx"),r=e<0;if(this.hls.trigger(sa.ERROR,{type:sr.OTHER_ERROR,details:ss.LEVEL_SWITCH_ERROR,level:e,fatal:r,error:i,reason:i.message}),r)return;e=Math.min(e,t.length-1)}let i=this.currentLevelIndex,r=this.currentLevel,s=r?r.attrs["PATHWAY-ID"]:void 0,a=t[e],n=a.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=a,i===e&&r&&s===n)return;this.log(`Switching to level ${e} (${a.height?a.height+"p ":""}${a.videoRange?a.videoRange+" ":""}${a.codecSet?a.codecSet+" ":""}@${a.bitrate})${n?" with Pathway "+n:""} from level ${i}${s?" with Pathway "+s:""}`);let l={level:e,attrs:a.attrs,details:a.details,bitrate:a.bitrate,averageBitrate:a.averageBitrate,maxBitrate:a.maxBitrate,realBitrate:a.realBitrate,width:a.width,height:a.height,codecSet:a.codecSet,audioCodec:a.audioCodec,videoCodec:a.videoCodec,audioGroups:a.audioGroups,subtitleGroups:a.subtitleGroups,loaded:a.loaded,loadError:a.loadError,fragmentError:a.fragmentError,name:a.name,id:a.id,uri:a.uri,url:a.url,urlId:0,audioGroupIds:a.audioGroupIds,textGroupIds:a.textGroupIds};this.hls.trigger(sa.LEVEL_SWITCHING,l);let o=a.details;if(!o||o.live){let e=this.switchParams(a.uri,null==r?void 0:r.details,o);this.loadPlaylist(e)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(e){this.manualLevelIndex=e,void 0===this._startLevel&&(this._startLevel=e),-1!==e&&(this.level=e)}get firstLevel(){return this._firstLevel}set firstLevel(e){this._firstLevel=e}get startLevel(){if(void 0===this._startLevel){let e=this.hls.config.startLevel;return void 0!==e?e:this.hls.firstAutoLevel}return this._startLevel}set startLevel(e){this._startLevel=e}get pathways(){return this.steering?this.steering.pathways():[]}get pathwayPriority(){return this.steering?this.steering.pathwayPriority:null}set pathwayPriority(e){if(this.steering){let 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}}onError(e,t){!t.fatal&&t.context&&t.context.type===sl&&t.context.level===this.level&&this.checkRetry(t)}onFragBuffered(e,{frag:t}){if(void 0!==t&&t.type===sh){let e=t.elementaryStreams;if(!Object.keys(e).some(t=>!!e[t]))return;let i=this._levels[t.level];null!=i&&i.loadError&&(this.log(`Resetting level error count of ${i.loadError} on frag buffered`),i.loadError=0)}}onLevelLoaded(e,t){var i,r;let{level:s,details:a}=t,n=t.levelInfo;if(!n){this.warn(`Invalid level index ${s}`),null!=(r=t.deliveryDirectives)&&r.skip&&(a.deltaUpdateFailed=!0);return}if(n===this.currentLevel||t.withoutMultiVariant){0===n.fragmentError&&(n.loadError=0);let e=n.details;e===t.details&&e.advanced&&(e=void 0),this.playlistLoaded(s,t,e)}else null!=(i=t.deliveryDirectives)&&i.skip&&(a.deltaUpdateFailed=!0)}loadPlaylist(e){super.loadPlaylist(),this.shouldLoadPlaylist(this.currentLevel)&&this.scheduleLo
29ading(this.currentLevel,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);let i=this.getUrlWithDirectives(e.uri,t),r=this.currentLevelIndex,s=e.attrs["PATHWAY-ID"],a=e.details,n=null==a?void 0:a.age;this.log(`Loading level index ${r}${(null==t?void 0:t.msn)!==void 0?" at sn "+t.msn+" part "+t.part:""}${s?" Pathway "+s:""}${n&&a.live?" age "+n.toFixed(1)+(a.type?" "+a.type:""):""} ${i}`),this.hls.trigger(sa.LEVEL_LOADING,{url:i,level:r,levelInfo:e,pathwayId:e.attrs["PATHWAY-ID"],id:0,deliveryDirectives:t||null})}get nextLoadLevel(){return -1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(e){this.level=e,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=e)}removeLevel(e){var t;if(1===this._levels.length)return;let 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));n2(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);let r=i.length-1;this._firstLevel=Math.min(this._firstLevel,r),this._startLevel&&(this._startLevel=Math.min(this._startLevel,r)),this.hls.trigger(sa.LEVELS_UPDATED,{levels:i})}onLevelsUpdated(e,{levels:t}){this._levels=t}checkMaxAutoUpdated(){let{autoLevelCapping:e,maxAutoLevel:t,maxHdcpLevel:i}=this.hls;this._maxAutoLevel!==t&&(this._maxAutoLevel=t,this.hls.trigger(sa.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:e,levels:this.levels,maxAutoLevel:t,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:i}))}}function hR(e){let t={};e.forEach(e=>{let i=e.groupId||"";e.id=t[i]=t[i]||0,t[i]++})}function hI(){return self.SourceBuffer||self.WebKitSourceBuffer}function hw(){if(!sS())return!1;let e=hI();return!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove}class hD extends lm{constructor(e,t,i){super(e,t,i,"stream-controller",sh),this.audioCodecSwap=!1,this.level=-1,this._forceStartLoad=!1,this._hasEnoughToStart=!1,this.altAudio=0,this.audioOnly=!1,this.fragPlaying=null,this.fragLastKbps=0,this.couldBacktrack=!1,this.backtrackFragment=null,this.audioCodecSwitch=!1,this.videoBuffer=null,this.onMediaPlaying=()=>{this.tick()},this.onMediaSeeked=()=>{let e=this.media,t=e?e.currentTime:null;if(null===t||!se(t)||(this.log(`Media seeked to ${t.toFixed(3)}`),!this.getBufferedFrag(t)))return;let i=this.getFwdBufferInfoAtPos(e,t,sh,0);null===i||0===i.len?this.warn(`Main forward buffer length at ${t} on "seeked" event ${i?i.len:"empty"})`):this.tick()},this.registerListeners()}registerListeners(){super.registerListeners();let{hls:e}=this;e.on(sa.MANIFEST_PARSED,this.onManifestParsed,this),e.on(sa.LEVEL_LOADING,this.onLevelLoading,this),e.on(sa.LEVEL_LOADED,this.onLevelLoaded,this),e.on(sa.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(sa.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(sa.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(sa.BUFFER_CREATED,this.onBufferCreated,this),e.on(sa.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(sa.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(sa.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){super.unregisterListeners();let{hls:e}=this;e.off(sa.MANIFEST_PARSED,this.onManifestParsed,this),e.off(sa.LEVEL_LOADED,this.onLevelLoaded,this),e.off(sa.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(sa.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(sa.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(sa.BUFFER_CREATED,this.onBufferCreated,this),e.off(sa.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(sa.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(sa.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this.onMediaPlaying=this.onMediaSeeked=null,this.unregisterListeners(),super.onHandlerDestroying()}startLoad(e,t){if(this.levels){let{lastCurrentTime:i,hls:r}=this;if(this.stopLoad(),this.setInterval(100),this.level=-1,!this.startFragRequested){let e=r.startLevel;-1===e&&(r.config.testBandwidth&&this.levels.length>1?(e=0,this.bitrateTest=!0):e=r.firstAutoLevel),r.nextLoadLevel=e,this.level=r.loadLevel,this._hasEnoughToStart=!!t}i>0&&-1===e&&!t&&(this.log(`Override startPosition with lastCurrentTime @${i.toFixed(3)}`),e=i),this.state=lr,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}else this._forceStartLoad=!0,this.state=li}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case lf:{let{levels:e,level:t}=this,i=null==e?void 0:e[t],r=null==i?void 0:i.details;if(!r||r.live&&(this.levelLastLoaded!==i||this.waitForLive(i)))this.hls.nextLoadLevel!==this.level&&(this.state=lr);else{if(this.waitForCdnTuneIn(r))break;this.state=lr}break}case ln:this.checkRetryDate()}this.state===lr&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){var e;super.onTickEnd(),null!=(e=this.media)&&e.readyState&&!1===this.media.seeking&&(this.lastCurrentTime=this.media.currentTime),this.checkFragmentChanged()}doTickIdle(){let{hls:e,levelLastLoaded:t,levels:i,media:r}=this;if(null===t||!r&&!this.primaryPrefetch&&(this.startFragRequested||!e.config.startFragPrefetch)||this.altAudio&&this.audioOnly)return;
29let s=this.buffering?e.nextLoadLevel:e.loadLevel;if(!(null!=i&&i[s]))return;let a=i[s],n=this.getMainFwdBufferInfo();if(null===n)return;let l=this.getLevelDetails();if(l&&this._streamEnded(n,l)){let e={};2===this.altAudio&&(e.type="video"),this.hls.trigger(sa.BUFFER_EOS,e),this.state=lh;return}if(!this.buffering)return;e.loadLevel!==s&&-1===e.manualLevel&&this.log(`Adapting to level ${s} from level ${this.level}`),this.level=e.nextLoadLevel=s;let o=a.details;if(!o||this.state===lf||this.waitForLive(a)){this.level=s,this.state=lf,this.startFragRequested=!1;return}let d=n.len,h=this.getMaxBufferLength(a.maxBitrate);if(d>=h)return;this.backtrackFragment&&this.backtrackFragment.start>n.end&&(this.backtrackFragment=null);let u=this.backtrackFragment?this.backtrackFragment.start:n.end,c=this.getNextFragment(u,o);if(this.couldBacktrack&&!this.fragPrevious&&c&&sN(c)&&"OK"!==this.fragmentTracker.getState(c)){var f;let e=(null!=(f=this.backtrackFragment)?f:c).sn-o.startSN,t=o.fragments[e-1];t&&c.cc===t.cc&&(c=t,this.fragmentTracker.removeFragment(t))}else this.backtrackFragment&&n.len&&(this.backtrackFragment=null);if(c&&this.isLoopLoading(c,u)){if(!c.gap){let e=this.audioOnly&&!this.altAudio?sP:sx,t=(e===sx?this.videoBuffer:this.mediaBuffer)||this.media;t&&this.afterBufferFlushed(t,e,sh)}c=this.getNextFragmentLoopLoading(c,o,n,sh,h)}c&&(!c.initSegment||c.initSegment.data||this.bitrateTest||(c=c.initSegment),this.loadFragment(c,a,u))}loadFragment(e,t,i){let r=this.fragmentTracker.getState(e);r===aG||r===aK?sN(e)?this.bitrateTest?(this.log(`Fragment ${e.sn} of level ${e.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(e,t)):super.loadFragment(e,t,i):this._loadInitSegment(e,t):this.clearTrackerIfNeeded(e)}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,sh)}followingBufferedFrag(e){return e?this.getBufferedFrag(e.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,1/0)}nextLevelSwitch(){let{levels:e,media:t}=this;if(null!=t&&t.readyState){let i,r=this.getAppendedFrag(t.currentTime);r&&r.start>1&&this.flushMainBuffer(0,r.start-1);let s=this.getLevelDetails();if(null!=s&&s.live){let e=this.getMainFwdBufferInfo();if(!e||e.len<2*s.targetduration)return}if(!t.paused&&e){let t=e[this.hls.nextLoadLevel],r=this.fragLastKbps;i=r&&this.fragCurrent?this.fragCurrent.duration*t.maxBitrate/(1e3*r)+1:0}else i=0;let a=this.getBufferedFrag(t.currentTime+i);if(a){let e=this.followingBufferedFrag(a);if(e){this.abortCurrentFrag();let t=e.maxStartPTS?e.maxStartPTS:e.start,i=e.duration,r=Math.max(a.end,t+Math.min(Math.max(i-this.config.maxFragLookUpTolerance,i*(this.couldBacktrack?.5:.125)),i*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(r,1/0)}}}}abortCurrentFrag(){let e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case ls:case la:case ln:case lo:case ld:this.state=lr}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(e,t){super.flushMainBuffer(e,t,2===this.altAudio?"video":null)}onMediaAttached(e,t){super.onMediaAttached(e,t);let i=t.media;n7(i,"playing",this.onMediaPlaying),n7(i,"seeked",this.onMediaSeeked)}onMediaDetaching(e,t){let{media:i}=this;i&&(le(i,"playing",this.onMediaPlaying),le(i,"seeked",this.onMediaSeeked)),this.videoBuffer=null,this.fragPlaying=null,super.onMediaDetaching(e,t),t.transferMedia||(this._hasEnoughToStart=!1)}onManifestLoading(){super.onManifestLoading(),this.log("Trigger BUFFER_RESET"),this.hls.trigger(sa.BUFFER_RESET,void 0),this.couldBacktrack=!1,this.fragLastKbps=0,this.fragPlaying=this.backtrackFragment=null,this.altAudio=0,this.audioOnly=!1}onManifestParsed(e,t){var i;let r,s=!1,a=!1;for(let e=0;e<t.levels.length;e++){let i=t.levels[e].audioCodec;i&&(s=s||-1!==i.indexOf("mp4a.40.2"),a=a||-1!==i.indexOf("mp4a.40.5"))}this.audioCodecSwitch=s&&a&&"function"!=typeof(null==(r=hI())||null==(i=r.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}onLevelLoading(e,t){let{levels:i}=this;if(!i||this.state!==lr)return;let r=t.levelInfo;(!r.details||r.details.live&&(this.levelLastLoaded!==r||r.details.expired)||this.waitForCdnTuneIn(r.details))&&(this.state=lf)}onLevelLoaded(e,t){var i,r;let{levels:s,startFragRequested:a}=this,n=t.level,l=t.details,o=l.totalduration;if(!s)return void this.warn(`Levels were reset while loading level ${n}`);this.log(`Level ${n} loaded [${l.startSN},${l.endSN}]${l.lastPartSn?`[part-${l.lastPartSn}-${l.lastPartIndex}]`:""}, cc [${l.startCC}, ${l.endCC}] duration:${o}`);let d=t.levelInfo,h=this.fragCurrent;h&&(this.state===la||this.state===ln)&&h.level!==t.level&&h.loader&&this.abortCurrentFrag();let u=0;if(l.live||null!=(i=d.details)&&i.live){if(this.checkLiveUpdate(l),l.deltaUpdateFailed)return;u=this.alignPlaylists(l,d.details,null==(r=this.levelLastLoaded)?void 0:r.details)}if(d.details=l,this.levelLastLoaded=d,a||this.setStartPosition(l,u),this.hls.trigger(sa.LEVEL_UPDATED,{details:l,level:n}),this.state===lf){if(this.waitForCdnTuneIn(l))return;this.state=lr}a&&l.live&&this.synchronizeToLiveEdge(l),this.tick()}
29synchronizeToLiveEdge(e){let{config:t,media:i}=this;if(!i)return;let r=this.hls.liveSyncPosition,s=this.getLoadPosition(),a=e.fragmentStart,n=e.edge,l=s>=a-t.maxFragLookUpTolerance&&s<=n;if(null!==r&&i.duration>r&&(s<r||!l)){let a=void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;if((!l&&i.readyState<4||s<n-a)&&(this._hasEnoughToStart||(this.nextLoadPosition=r),i.readyState))if(this.warn(`Playback: ${s.toFixed(3)} is located too far from the end of live sliding playlist: ${n}, reset currentTime to : ${r.toFixed(3)}`),"buffered"===this.config.liveSyncMode){var o;let e=a6.bufferInfo(i,r,0);if(!(null!=(o=e.buffered)&&o.length)||e.start<=s){i.currentTime=r;return}let{nextStart:t}=a6.bufferedInfo(e.buffered,s,0);t&&(i.currentTime=t)}else i.currentTime=r}}_handleFragmentLoadProgress(e){var t;let i=e.frag,{part:r,payload:s}=e,{levels:a}=this;if(!a)return void this.warn(`Levels were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`);let n=a[i.level];if(!n)return void this.warn(`Level ${i.level} not found on progress`);let l=n.details;if(!l){this.warn(`Dropping fragment ${i.sn} of level ${i.level} after level details were reset`),this.fragmentTracker.removeFragment(i);return}let o=n.videoCodec,d=l.PTSKnown||!l.live,h=null==(t=i.initSegment)?void 0:t.data,u=this._getAudioCodec(n),c=this.transmuxer=this.transmuxer||new ob(this.hls,sh,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),f=r?r.index:-1,m=new a4(i.level,i.sn,i.stats.chunkCount,s.byteLength,f,-1!==f),g=this.initPTS[i.cc];c.push(s,h,u,o,i,r,l.totalduration,d,m,g)}onAudioTrackSwitching(e,t){let i=this.hls,r=0!==this.altAudio;if(aI(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;let e=this.fragCurrent;e&&(this.log("Switching to main audio track, cancel main fragment load"),e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();if(r){this.altAudio=0,this.fragmentTracker.removeAllFragments(),i.once(sa.BUFFER_FLUSHED,()=>{this.hls&&this.hls.trigger(sa.AUDIO_TRACK_SWITCHED,t)}),i.trigger(sa.BUFFER_FLUSHING,{startOffset:0,endOffset:1/0,type:null});return}i.trigger(sa.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){let i=aI(t.url,this.hls);if(i){let e=this.videoBuffer;e&&this.mediaBuffer!==e&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=e)}this.altAudio=2*!!i,this.tick()}onBufferCreated(e,t){let i,r,s=t.tracks,a=!1;for(let e in s){let t=s[e];if("main"===t.id){if(r=e,i=t,"video"===e){let t=s[e];t&&(this.videoBuffer=t.buffer)}}else a=!0}a&&i?(this.log(`Alternate track found, use ${r}.buffered to schedule main fragment loading`),this.mediaBuffer=i.buffer):this.mediaBuffer=this.media}onFragBuffered(e,t){let{frag:i,part:r}=t,s=i.type===sh;if(s){if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${r?" p: "+r.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}`),this.state===ld&&(this.state=lr);return}let e=r?r.stats:i.stats;this.fragLastKbps=Math.round(8*e.total/(e.buffering.end-e.loading.first)),sN(i)&&(this.fragPrevious=i),this.fragBufferedComplete(i,r)}let a=this.media;a&&(!this._hasEnoughToStart&&a6.getBuffered(a).length&&(this._hasEnoughToStart=!0,this.seekToStartPos()),s&&this.tick())}get hasEnoughToStart(){return this._hasEnoughToStart}onError(e,t){var i;if(t.fatal){this.state=lu;return}switch(t.details){case ss.FRAG_GAP:case ss.FRAG_PARSING_ERROR:case ss.FRAG_DECRYPT_ERROR:case ss.FRAG_LOAD_ERROR:case ss.FRAG_LOAD_TIMEOUT:case ss.KEY_LOAD_ERROR:case ss.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(sh,t);break;case ss.LEVEL_LOAD_ERROR:case ss.LEVEL_LOAD_TIMEOUT:case ss.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==lf||(null==(i=t.context)?void 0:i.type)!==sl||(this.state=lr);break;case ss.BUFFER_ADD_CODEC_ERROR:case ss.BUFFER_APPEND_ERROR:if("main"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)&&this.resetLoadingState();break;case ss.BUFFER_FULL_ERROR:if("main"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)&&(!this.config.interstitialsController&&this.config.assetPlayerId?this._hasEnoughToStart=!0:this.flushMainBuffer(0,1/0));break;case ss.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}onFragLoadEmergencyAborted(){this.state=lr,this._hasEnoughToStart||(this.startFragRequested=!1,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==sP||!this.altAudio){let e=(t===sx?this.videoBuffer:this.mediaBuffer)||this.media;e&&(this.afterBufferFlushed(e,t,sh),this.tick())}}onLevelsUpdated(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level,-1===this.level&&this.resetWhenMissingContext(this.fragCurrent)),this.levels=t.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){let{media:e}=this;if(!e)return;let 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}`);let r=this.timelineOffset;r&&i&&(i+=r);let s=this.getLevelDetails(),a=a6.getBuffered(e),n=a.length?a.start(0):0,l=n-i,o=Math.max(this.config.maxBufferHole,this.config.maxFragLookUpTolerance);(this.config.startOnSegmentBoundary||l>0&&(l<o||this.loadingParts&&l<2*((null==s?void 0:s.partTarget)||0)))&&(this.log(`adjusting start position by ${l} to match buffer start`),i+=l,this.startPosition=i),t<i&&(this.log(`seek to target start position ${i} from current time ${t} buffer start ${n}`),e.currentTime=i)}}_getAudioCodec(e){let 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}_loadBitrateTestFrag(e,t){e.bitrateTest=!0,this._doFragLoad(e,t).then(e=>{let{hls:i}=this,r=null==e?void 0:e.frag;if(!r||this.fragContextChanged(r))return;t.fragmentError=0,this.state=lr,this.startFragRequested=!1,this.bitrateTest=!1;let s=r.stats;s.parsing.start=s.parsing.end=s.buffering.start=s.buffering.end=self.performance.now(),i.trigger(sa.FRAG_LOADED,e),r.bitrateTest=!1}
29).catch(t=>{this.state!==li&&this.state!==lu&&(this.warn(t),this.resetFragmentLoading(e))})}_handleTransmuxComplete(e){let t=this.playlistType,{hls:i}=this,{remuxResult:r,chunkMeta:s}=e,a=this.getCurrentContext(s);if(!a)return void this.resetWhenMissingContext(s);let{frag:n,part:l,level:o}=a,{video:d,text:h,id3:u,initSegment:c}=r,{details:f}=o,m=this.altAudio?void 0:r.audio;if(this.fragContextChanged(n))return void this.fragmentTracker.removeFragment(n);if(this.state=lo,c){let e=c.tracks;if(e){let r=n.initSegment||n;if(this.unhandledEncryptionError(c,n))return;this._bufferInitSegment(o,e,r,s),i.trigger(sa.FRAG_PARSING_INIT_SEGMENT,{frag:r,id:t,tracks:e})}let r=c.initPTS,a=c.timescale,l=this.initPTS[n.cc];if(se(r)&&(!l||l.baseTime!==r||l.timescale!==a)){let e=c.trackId;this.initPTS[n.cc]={baseTime:r,timescale:a,trackId:e},i.trigger(sa.INIT_PTS_FOUND,{frag:n,id:t,initPTS:r,timescale:a,trackId:e})}}if(d&&f){m&&"audiovideo"===d.type&&this.logMuxedErr(n);let e=f.fragments[n.sn-1-f.startSN],t=n.sn===f.startSN,i=!e||n.cc>e.cc;if(!1!==r.independent){let{startPTS:e,endPTS:r,startDTS:a,endDTS:o}=d;if(l)l.elementaryStreams[d.type]={startPTS:e,endPTS:r,startDTS:a,endDTS:o};else if(d.firstKeyFrame&&d.independent&&1===s.id&&!i&&(this.couldBacktrack=!0),d.dropped&&d.independent){let s=this.getMainFwdBufferInfo(),a=(s?s.end:this.getLoadPosition())+this.config.maxBufferHole,l=d.firstKeyFramePTS?d.firstKeyFramePTS:e;if(!t&&a<l-this.config.maxBufferHole&&!i)return void this.backtrack(n);i&&(n.gap=!0),n.setElementaryStreamInfo(d.type,n.start,r,n.start,o,!0)}else t&&e-(f.appliedTimelineOffset||0)>2&&(n.gap=!0);n.setElementaryStreamInfo(d.type,e,r,a,o),this.backtrackFragment&&(this.backtrackFragment=n),this.bufferFragmentData(d,n,l,s,t||i)}else{if(!t&&!i)return void this.backtrack(n);n.gap=!0}}if(m){let{startPTS:e,endPTS:t,startDTS:i,endDTS:r}=m;l&&(l.elementaryStreams[sP]={startPTS:e,endPTS:t,startDTS:i,endDTS:r}),n.setElementaryStreamInfo(sP,e,t,i,r),this.bufferFragmentData(m,n,l,s)}if(f&&null!=u&&u.samples.length){let e={id:t,frag:n,details:f,samples:u.samples};i.trigger(sa.FRAG_PARSING_METADATA,e)}if(f&&h){let e={id:t,frag:n,details:f,samples:h.samples};i.trigger(sa.FRAG_PARSING_USERDATA,e)}}logMuxedErr(e){this.warn(`${sN(e)?"Media":"Init"} segment with muxed audiovideo where only video expected: ${e.url}`)}_bufferInitSegment(e,t,i,r){if(this.state!==lo)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&(delete t.audio,t.audiovideo&&this.logMuxedErr(i));let{audio:s,video:a,audiovideo:n}=t;if(s){let i=e.audioCodec,r=aa(s.codec,i);"mp4a"===r&&(r="mp4a.40.5");let a=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){r&&(r=-1!==r.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5");let e=s.metadata;e&&"channelCount"in e&&1!==(e.channelCount||1)&&-1===a.indexOf("firefox")&&(r="mp4a.40.5")}r&&-1!==r.indexOf("mp4a.40.5")&&-1!==a.indexOf("android")&&"audio/mpeg"!==s.container&&(r="mp4a.40.2",this.log(`Android: force audio codec to ${r}`)),i&&i!==r&&this.log(`Swapping manifest audio codec "${i}" for "${r}"`),s.levelCodec=r,s.id=sh,this.log(`Init audio buffer, container:${s.container}, codecs[selected/level/parsed]=[${r||""}/${i||""}/${s.codec}]`),delete t.audiovideo}if(a){a.levelCodec=e.videoCodec,a.id=sh;let i=a.codec;if((null==i?void 0:i.length)===4)switch(i){case"hvc1":case"hev1":a.codec="hvc1.1.6.L120.90";break;case"av01":a.codec="av01.0.04M.08";break;case"avc1":a.codec="avc1.42e01e"}this.log(`Init video buffer, container:${a.container}, codecs[level/parsed]=[${e.videoCodec||""}/${i}]${a.codec!==i?" parsed-corrected="+a.codec:""}${a.supplemental?" supplemental="+a.supplemental:""}`),delete t.audiovideo}n&&(this.log(`Init audiovideo buffer, container:${n.container}, codecs[level/parsed]=[${e.codecs}/${n.codec}]`),delete t.video,delete t.audio);let l=Object.keys(t);if(l.length){if(this.hls.trigger(sa.BUFFER_CODECS,t),!this.hls)return;l.forEach(e=>{let s=t[e].initSegment;null!=s&&s.byteLength&&this.hls.trigger(sa.BUFFER_APPENDING,{type:e,data:s,frag:i,part:null,chunkMeta:r,parent:i.type})})}this.tickImmediate()}getMainFwdBufferInfo(){let e=this.mediaBuffer&&2===this.altAudio?this.mediaBuffer:this.media;return this.getFwdBufferInfo(e,sh)}get maxBufferLength(){let{levels:e,level:t}=this,i=null==e?void 0:e[t];return i?this.getMaxBufferLength(i.maxBitrate):this.config.maxBufferLength}backtrack(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=lr}checkFragmentChanged(){let e=this.media,t=null;if(e&&e.readyState>1&&!1===e.seeking){let i=e.currentTime;if(a6.isBuffered(e,i)?t=this.getAppendedFrag(i):a6.isBuffered(e,i+.
291)&&(t=this.getAppendedFrag(i+.1)),t){this.backtrackFragment=null;let e=this.fragPlaying,i=t.level;(!e||t.sn!==e.sn||e.level!==i)&&(this.fragPlaying=t,this.hls.trigger(sa.FRAG_CHANGED,{frag:t}),e&&e.level===i||this.hls.trigger(sa.LEVEL_SWITCHED,{level:i}))}}}get nextLevel(){let e=this.nextBufferedFrag;return e?e.level:-1}get currentFrag(){var e;if(this.fragPlaying)return this.fragPlaying;let t=(null==(e=this.media)?void 0:e.currentTime)||this.lastCurrentTime;return se(t)?this.getAppendedFrag(t):null}get currentProgramDateTime(){var e;let t=(null==(e=this.media)?void 0:e.currentTime)||this.lastCurrentTime;if(se(t)){let e=this.getLevelDetails(),i=this.currentFrag||(e?aD(null,e.fragments,t):null);if(i){let e=i.programDateTime;if(null!==e)return new Date(e+(t-i.start)*1e3)}}return null}get currentLevel(){let e=this.currentFrag;return e?e.level:-1}get nextBufferedFrag(){let e=this.currentFrag;return e?this.followingBufferedFrag(e):null}get forceStartLoad(){return this._forceStartLoad}}class hC extends sE{constructor(e,t){super("key-loader",t),this.config=void 0,this.keyIdToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(let i in this.keyIdToKeyInfo){let r=this.keyIdToKeyInfo[i].loader;if(r){var t;if(e&&e!==(null==(t=r.context)?void 0:t.frag.type))return;r.abort()}}}detach(){for(let e in this.keyIdToKeyInfo){let t=this.keyIdToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyIdToKeyInfo[e]}}destroy(){for(let e in this.detach(),this.keyIdToKeyInfo){let t=this.keyIdToKeyInfo[e].loader;t&&t.destroy()}this.keyIdToKeyInfo={}}createKeyLoadError(e,t=ss.KEY_LOAD_ERROR,i,r,s){return new a2({type:sr.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:s,error:i,networkDetails:r})}loadClear(e,t,i){if(this.emeController&&this.config.emeEnabled&&!this.emeController.getSelectedKeySystemFormats().length){if(t.length)for(let r=0,s=t.length;r<s;r++){let a=t[r];if(e.cc<=a.cc&&(!sN(e)||!sN(a)||e.sn<a.sn)||!i&&r==s-1)return this.emeController.selectKeySystemFormat(a).then(e=>{if(!this.emeController)return;a.setKeyFormat(e);let t=nA(e);if(t)return this.emeController.getKeySystemAccess([t])})}if(this.config.requireKeySystemAccessOnStart){let e=nk(this.config);if(e.length)return this.emeController.getKeySystemAccess(e)}}return null}load(e){return!e.decryptdata&&e.encrypted&&this.emeController&&this.config.emeEnabled?this.emeController.selectKeySystemFormat(e).then(t=>this.loadInternal(e,t)):this.loadInternal(e)}loadInternal(e,t){var i,r;t&&e.setKeyFormat(t);let s=e.decryptdata;if(!s){let i=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,ss.KEY_LOAD_ERROR,i))}let a=s.uri;if(!a)return Promise.reject(this.createKeyLoadError(e,ss.KEY_LOAD_ERROR,Error(`Invalid key URI: "${a}"`)));let n=hP(s),l=this.keyIdToKeyInfo[n];if(null!=(i=l)&&i.decryptdata.key)return s.key=l.decryptdata.key,Promise.resolve({frag:e,keyInfo:l});if(this.emeController&&null!=(r=l)&&r.keyLoadPromise)switch(this.emeController.getKeyStatus(l.decryptdata)){case"usable":case"usable-in-future":return l.keyLoadPromise.then(t=>{let{keyInfo:i}=t;return s.key=i.decryptdata.key,{frag:e,keyInfo:i}})}switch(this.log(`${this.keyIdToKeyInfo[n]?"Rel":"L"}oading${s.keyId?" keyId: "+sR(s.keyId):""} URI: ${s.uri} from ${e.type} ${e.level}`),l=this.keyIdToKeyInfo[n]={decryptdata:s,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},s.method){case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":if("identity"===s.keyFormat)return this.loadKeyHTTP(l,e);return this.loadKeyEME(l,e);case"AES-128":case"AES-256":case"AES-256-CTR":return this.loadKeyHTTP(l,e);default:return Promise.reject(this.createKeyLoadError(e,ss.KEY_LOAD_ERROR,Error(`Key supplied with unsupported METHOD: "${s.method}"`)))}}loadKeyEME(e,t){let i={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){var r,s;if(!e.decryptdata.keyId&&null!=(r=t.initSegment)&&r.data){let i,r=(s=t.initSegment.data,i=[],sZ(s,e=>i.push(e.subarray(8,24))),i);if(r.length){let t=r[0];t.some(e=>0!==e)?(this.log(`Using keyId found in init segment ${sR(t)}`),nw.setKeyIdForUri(e.decryptdata.uri,t)):(t=nw.addKeyIdForUri(e.decryptdata.uri),this.log(`Generating keyId to patch media ${sR(t)}`)),e.decryptdata.keyId=t}}return e.decryptdata.keyId||sN(t)?(e.keyLoadPromise=this.emeController.loadKey(i).then(t=>(e.mediaKeySessionContext=t,i))).catch(i=>{throw e.keyLoadPromise=null,"data"in i&&(i.data.frag=t),i}):Promise.resolve(i)}return Promise.resolve(i)}loadKeyHTTP(e,t){let i=this.config,r=new i.loader(i);return t.keyLoader=e.loader=r,e.keyLoadPromise=new Promise((s,a)=>{let n={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},l=i.keyLoadPolicy.default,o={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0};r.load(n,o,{onSuccess:(e,t,i,r)=>{let{frag:n,keyInfo:l}=i,o=hP(l.decryptdata);if(!n.decryptdata||l!==this.keyIdToKeyInfo[o])return a(this.createKeyLoadError(n,ss.KEY_LOAD_ERROR,Error("after key load, decryptdata unset or changed"),r));l.decryptdata.key=n.decryptdata.key=new Uint8Array(e.data),n.keyLoader=null,l.loader=null,s({frag:n,keyInfo:l})},onError:(e,i,r,s)=>{this.resetLoader(i),a(this.createKeyLoadError(t,ss.KEY_LOAD_ERROR,Error(`HTTP Error ${e.code} loading key ${e.text}`),r,sv({url:n.url,data:void 0},e)))},onTimeout:(e,i,r)=>{this.resetLoader(i),a(this.createKeyLoadError(t,ss.KEY_LOAD_TIMEOUT,Error("key loading timed out"),r))},onAbort:(e,i,r)=>{this.resetLoader(i),a(this.createKeyLoadError(t,ss.INTERNAL_ABORTED,Error("key loading aborted"),r))}})})}
29resetLoader(e){let{frag:t,keyInfo:i,url:r}=e,s=i.loader;t.keyLoader===s&&(t.keyLoader=null,i.loader=null);let a=hP(i.decryptdata)||r;delete this.keyIdToKeyInfo[a],s&&s.destroy()}}function hP(e){if(e.keyFormat!==nb){let t=e.keyId;if(t)return sR(t)}return e.uri}function hx(e){let{type:t}=e;switch(t){case so:return su;case sd:return sc;default:return sh}}function hM(e,t){let i=e.url;return(void 0===i||0===i.indexOf("data:"))&&(i=t.url),i}class hO{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.onManifestLoaded=this.checkAutostartLoad,this.hls=e,this.registerListeners()}startLoad(e){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){let{hls:e}=this;e.on(sa.MANIFEST_LOADING,this.onManifestLoading,this),e.on(sa.LEVEL_LOADING,this.onLevelLoading,this),e.on(sa.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(sa.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.on(sa.LEVELS_UPDATED,this.onLevelsUpdated,this)}unregisterListeners(){let{hls:e}=this;e.off(sa.MANIFEST_LOADING,this.onManifestLoading,this),e.off(sa.LEVEL_LOADING,this.onLevelLoading,this),e.off(sa.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(sa.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.off(sa.LEVELS_UPDATED,this.onLevelsUpdated,this)}createInternalLoader(e){let t=this.hls.config,i=t.pLoader,r=t.loader,s=new(i||r)(t);return this.loaders[e.type]=s,s}getInternalLoader(e){return this.loaders[e.type]}resetInternalLoader(e){this.loaders[e]&&delete this.loaders[e]}destroyInternalLoaders(){for(let e in this.loaders){let t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(e,t){let{url:i}=t;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:sn,url:i,deliveryDirectives:null,levelOrTrack:null})}onLevelLoading(e,t){let{id:i,level:r,pathwayId:s,url:a,deliveryDirectives:n,levelInfo:l}=t;this.load({id:i,level:r,pathwayId:s,responseType:"text",type:sl,url:a,deliveryDirectives:n,levelOrTrack:l})}onAudioTrackLoading(e,t){let{id:i,groupId:r,url:s,deliveryDirectives:a,track:n}=t;this.load({id:i,groupId:r,level:null,responseType:"text",type:so,url:s,deliveryDirectives:a,levelOrTrack:n})}onSubtitleTrackLoading(e,t){let{id:i,groupId:r,url:s,deliveryDirectives:a,track:n}=t;this.load({id:i,groupId:r,level:null,responseType:"text",type:sd,url:s,deliveryDirectives:a,levelOrTrack:n})}onLevelsUpdated(e,t){let i=this.loaders[sl];if(i){let e=i.context;e&&!t.levels.some(t=>t===e.levelOrTrack)&&(i.abort(),delete this.loaders[sl])}}load(e){var t;let i,r=this.hls.config,s=this.getInternalLoader(e);if(s){let t=this.hls.logger,i=s.context;if(i&&i.levelOrTrack===e.levelOrTrack&&(i.url===e.url||i.deliveryDirectives&&!e.deliveryDirectives))return void(i.url===e.url?t.log(`[playlist-loader]: ignore ${e.url} ongoing request`):t.log(`[playlist-loader]: ignore ${e.url} in favor of ${i.url}`));t.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),s.abort()}if(i=e.type===sn?r.manifestLoadPolicy.default:sp({},r.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),s=this.createInternalLoader(e),se(null==(t=e.deliveryDirectives)?void 0:t.part)){let t;if(e.type===sl&&null!==e.level?t=this.hls.levels[e.level].details:e.type===so&&null!==e.id?t=this.hls.audioTracks[e.id].details:e.type===sd&&null!==e.id&&(t=this.hls.subtitleTracks[e.id].details),t){let e=t.partTarget,r=t.targetduration;if(e&&r){let t=1e3*Math.max(3*e,.8*r);i=sp({},i,{maxTimeToFirstByteMs:Math.min(t,i.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(t,i.maxTimeToFirstByteMs)})}}}let a=i.errorRetry||i.timeoutRetry||{},n={loadPolicy:i,timeout:i.maxLoadTimeMs,maxRetry:a.maxNumRetry||0,retryDelay:a.retryDelayMs||0,maxRetryDelay:a.maxRetryDelayMs||0};s.load(e,n,{onSuccess:(e,t,i,r)=>{let s=this.getInternalLoader(i);this.resetInternalLoader(i.type);let a=e.data;t.parsing.start=performance.now(),nN.isMediaPlaylist(a)||i.type!==sn?this.handleTrackOrLevelPlaylist(e,t,i,r||null,s):this.handleMasterPlaylist(e,t,i,r)},onError:(e,t,i,r)=>{this.handleNetworkError(t,i,!1,e,r)},onTimeout:(e,t,i)=>{this.handleNetworkError(t,i,!0,void 0,e)}})}
29checkAutostartLoad(){if(!this.hls)return;let{config:{autoStartLoad:e,startPosition:t},forceStartLoad:i}=this.hls;(e||i)&&(this.hls.logger.log(`${e?"auto":"force"} startLoad with configured startPosition ${t}`),this.hls.startLoad(t))}handleMasterPlaylist(e,t,i,r){let s=this.hls,a=e.data,n=hM(e,i),l=nN.parseMasterPlaylist(a,n);if(l.playlistParsingError){t.parsing.end=performance.now(),this.handleManifestParsingError(e,i,l.playlistParsingError,r,t);return}let{contentSteering:o,levels:d,sessionData:h,sessionKeys:u,startTimeOffset:c,variableList:f}=l;this.variableList=f,d.forEach(e=>{let{unknownCodecs:t}=e;if(t){let{preferManagedMediaSource:i}=this.hls.config,{audioCodec:r,videoCodec:s}=e;for(let a=t.length;a--;){let n=t[a];s6(n,"audio",i)?(e.audioCodec=r=r?`${r},${n}`:n,s5.audio[r.substring(0,4)]=2,t.splice(a,1)):s6(n,"video",i)&&(e.videoCodec=s=s?`${s},${n}`:n,s5.video[s.substring(0,4)]=2,t.splice(a,1))}}});let{AUDIO:m=[],SUBTITLES:g,"CLOSED-CAPTIONS":v}=nN.parseMasterPlaylistMedia(a,n,l);m.length&&(m.some(e=>!e.url)||!d[0].audioCodec||d[0].attrs.AUDIO||(this.hls.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),m.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new nr({}),bitrate:0,url:""}))),s.trigger(sa.MANIFEST_LOADED,{levels:d,audioTracks:m,subtitles:g,captions:v,contentSteering:o,url:n,stats:t,networkDetails:r,sessionData:h,sessionKeys:u,startTimeOffset:c,variableList:f})}handleTrackOrLevelPlaylist(e,t,i,r,s){let a=this.hls,{id:n,level:l,type:o}=i,d=hM(e,i),h=se(l)?l:se(n)?n:0,u=hx(i),c=nN.parseLevelPlaylist(e.data,d,h,u,0,this.variableList);if(o===sn){let e={attrs:new nr({}),bitrate:0,details:c,name:"",url:d};c.requestScheduled=t.loading.start+nZ(c,0),a.trigger(sa.MANIFEST_LOADED,{levels:[e],audioTracks:[],url:d,stats:t,networkDetails:r,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),i.levelDetails=c,this.handlePlaylistLoaded(c,e,t,i,r,s)}handleManifestParsingError(e,t,i,r,s){this.hls.trigger(sa.ERROR,{type:sr.NETWORK_ERROR,details:ss.MANIFEST_PARSING_ERROR,fatal:t.type===sn,url:e.url,err:i,error:i,reason:i.message,response:e,context:t,networkDetails:r,stats:s})}handleNetworkError(e,t,i=!1,r,s){let a=`A network ${i?"timeout":"error"+(r?" (status "+r.code+")":"")} occurred while loading ${e.type}`;e.type===sl?a+=`: ${e.level} id: ${e.id}`:(e.type===so||e.type===sd)&&(a+=` id: ${e.id} group-id: "${e.groupId}"`);let n=Error(a);this.hls.logger.warn(`[playlist-loader]: ${a}`);let l=ss.UNKNOWN,o=!1,d=this.getInternalLoader(e);switch(e.type){case sn:l=i?ss.MANIFEST_LOAD_TIMEOUT:ss.MANIFEST_LOAD_ERROR,o=!0;break;case sl:l=i?ss.LEVEL_LOAD_TIMEOUT:ss.LEVEL_LOAD_ERROR,o=!1;break;case so:l=i?ss.AUDIO_TRACK_LOAD_TIMEOUT:ss.AUDIO_TRACK_LOAD_ERROR,o=!1;break;case sd:l=i?ss.SUBTITLE_TRACK_LOAD_TIMEOUT:ss.SUBTITLE_LOAD_ERROR,o=!1}d&&this.resetInternalLoader(e.type);let h={type:sr.NETWORK_ERROR,details:l,fatal:o,url:e.url,loader:d,context:e,error:n,networkDetails:t,stats:s};r&&(h.response=sv({url:(null==t?void 0:t.url)||e.url,data:void 0},r)),this.hls.trigger(sa.ERROR,h)}handlePlaylistLoaded(e,t,i,r,s,a){let n=this.hls,{type:l,level:o,levelOrTrack:d,id:h,groupId:u,deliveryDirectives:c}=r,f=hM(t,r),m=hx(r),g="number"==typeof r.level&&m===sh?o:void 0,v=e.playlistParsingError;if(v){if(this.hls.logger.warn(`${v} ${e.url}`),!n.config.ignorePlaylistParsingErrors)return void n.trigger(sa.ERROR,{type:sr.NETWORK_ERROR,details:ss.LEVEL_PARSING_ERROR,fatal:!1,url:f,error:v,reason:v.message,response:t,context:r,level:g,parent:m,networkDetails:s,stats:i});e.playlistParsingError=null}if(!e.fragments.length){let a=e.playlistParsingError=Error("No Segments found in Playlist");n.trigger(sa.ERROR,{type:sr.NETWORK_ERROR,details:ss.LEVEL_EMPTY_ERROR,fatal:!1,url:f,error:a,reason:a.message,response:t,context:r,level:g,parent:m,networkDetails:s,stats:i});return}switch(e.live&&a&&(a.getCacheAge&&(e.ageHeader=a.getCacheAge()||0),(!a.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),l){case sn:case sl:if(g)if(d){if(d!==n.levels[g]){let e=n.levels.indexOf(d);e>-1&&(g=e)}}else g=0;n.trigger(sa.LEVEL_LOADED,{details:e,levelInfo:d||n.levels[0],level:g||0,id:h||0,stats:i,networkDetails:s,deliveryDirectives:c,withoutMultiVariant:l===sn});break;case so:n.trigger(sa.AUDIO_TRACK_LOADED,{details:e,track:d,id:h||0,groupId:u||"",stats:i,networkDetails:s,deliveryDirectives:c});break;case sd:n.trigger(sa.SUBTITLE_TRACK_LOADED,{details:e,track:d,id:h||0,groupId:u||"",stats:i,networkDetails:s,deliveryDirectives:c})}}}class hN{static get version(){return ly}static isMSESupported(){return hw()}static isSupported(){if(!hw())return!1;let e=sS();
29return"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(s7(t,"video")))||["mp4a.40.2","fLaC"].some(t=>e.isTypeSupported(s7(t,"audio"))))}static getMediaSource(){return sS()}static get Events(){return sa}static get MetadataSchema(){return lO}static get ErrorTypes(){return sr}static get ErrorDetails(){return ss}static get DefaultConfig(){return hN.defaultConfig?hN.defaultConfig:hg}static set DefaultConfig(e){hN.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.logger=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new lE,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;const t=this.logger=function(e,t,i){let r=sT();if("object"==typeof console&&!0===e||"object"==typeof e){let s=["debug","log","info","warn","error"];s.forEach(t=>{r[t]=s_(t,e,i)});try{r.log(`Debug logs enabled for "${t}" in hls.js version 1.6.15`)}catch(e){return sT()}s.forEach(t=>{sA[t]=s_(t,e)})}else sp(sA,r);return r}(e.debug||!1,"Hls instance",e.assetPlayerId),i=this.config=function(e,t,i){if((t.liveSyncDurationCount||t.liveMaxLatencyDurationCount)&&(t.liveSyncDuration||t.liveMaxLatencyDuration))throw 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 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 Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');let r=function e(t){return t&&"object"==typeof t?Array.isArray(t)?t.map(e):Object.keys(t).reduce((i,r)=>(i[r]=e(t[r]),i),{}):t}(e),s=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach(e=>{let a=`${"level"===e?"playlist":e}LoadPolicy`,n=void 0===t[a],l=[];s.forEach(i=>{let s=`${e}Loading${i}`,o=t[s];if(void 0!==o&&n){l.push(s);let e=r[a].default;switch(t[a]={default:e},i){case"TimeOut":e.maxLoadTimeMs=o,e.maxTimeToFirstByteMs=o;break;case"MaxRetry":e.errorRetry.maxNumRetry=o,e.timeoutRetry.maxNumRetry=o;break;case"RetryDelay":e.errorRetry.retryDelayMs=o,e.timeoutRetry.retryDelayMs=o;break;case"MaxRetryTimeout":e.errorRetry.maxRetryDelayMs=o,e.timeoutRetry.maxRetryDelayMs=o}}}),l.length&&i.warn(`hls.js config: "${l.join('", "')}" setting(s) are deprecated, use "${a}": ${ab(t[a])}`)}),sv(sv({},r),t)}(hN.DefaultConfig,e,t);this.userConfig=e,i.progressive&&function(e,t){let i=e.loader;i!==hu&&i!==hp?(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=hu,e.progressive=!0,e.enableSoftwareAES=!0,t.log("[config]: Progressive streaming enabled, using FetchLoader"))}(i,t);const{abrController:r,bufferController:s,capLevelController:a,errorController:n,fpsController:l}=i,o=new n(this),d=this.abrController=new r(this),h=new aW(this),u=i.interstitialsController,c=u?this.interstitialsController=new u(this,hN):null,f=this.bufferController=new s(this,h),m=this.capLevelController=new a(this),g=new l(this),v=new hO(this),E=i.contentSteeringController,y=E?new E(this):null,b=this.levelController=new hL(this,y),T=new hS(this),_=new hC(this.config,this.logger),A=this.streamController=new hD(this,h,_),S=this.gapController=new hv(this,h);m.setStreamController(A),g.setStreamController(A);const k=[v,b,A];c&&k.splice(1,0,c),y&&k.splice(1,0,y),this.networkControllers=k;
29const L=[d,f,S,m,g,T,h];this.audioTrackController=this.createController(i.audioTrackController,k);const R=i.audioStreamController;R&&k.push(this.audioStreamController=new R(this,h,_)),this.subtitleTrackController=this.createController(i.subtitleTrackController,k);const I=i.subtitleStreamController;I&&k.push(this.subtititleStreamController=new I(this,h,_)),this.createController(i.timelineController,L),_.emeController=this.emeController=this.createController(i.emeController,L),this.cmcdController=this.createController(i.cmcdController,L),this.latencyController=this.createController(hk,L),this.coreComponents=L,k.push(o);const w=o.onErrorOut;"function"==typeof w&&this.on(sa.ERROR,w,o),this.on(sa.MANIFEST_LOADED,v.onManifestLoaded,v)}createController(e,t){if(e){let i=new e(this);return t&&t.push(i),i}return null}on(e,t,i=this){this._emitter.on(e,t,i)}once(e,t,i=this){this._emitter.once(e,t,i)}removeAllListeners(e){this._emitter.removeAllListeners(e)}off(e,t,i=this,r){this._emitter.off(e,t,i,r)}listeners(e){return this._emitter.listeners(e)}emit(e,t,i){return this._emitter.emit(e,t,i)}trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(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;let i=e===sa.ERROR;this.trigger(sa.ERROR,{type:sr.OTHER_ERROR,details:ss.INTERNAL_EXCEPTION,fatal:i,event:e,error:t}),this.triggeringException=!1}}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){this.logger.log("destroy"),this.trigger(sa.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;let e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null}attachMedia(e){if(!e||"media"in e&&!e.media){let t=Error(`attachMedia failed: invalid argument (${e})`);this.trigger(sa.ERROR,{type:sr.OTHER_ERROR,details:ss.ATTACH_MEDIA_ERROR,fatal:!0,error:t});return}this.logger.log("attachMedia"),this._media&&(this.logger.warn("media must be detached before attaching"),this.detachMedia());let t="media"in e,i=t?e.media:e,r=t?e:{media:i};this._media=i,this.trigger(sa.MEDIA_ATTACHING,r)}detachMedia(){this.logger.log("detachMedia"),this.trigger(sa.MEDIA_DETACHING,{}),this._media=null}transferMedia(){this._media=null;let e=this.bufferController.transferMedia();return this.trigger(sa.MEDIA_DETACHING,{transferMedia:e}),e}loadSource(e){this.stopLoad();let t=this.media,i=this._url,r=this._url=sD.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.logger.log(`loadSource:${r}`),t&&i&&(i!==r||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(sa.MANIFEST_LOADING,{url:e})}get url(){return this._url}get hasEnoughToStart(){return this.streamController.hasEnoughToStart}get startPosition(){return this.streamController.startPositionValue}startLoad(e=-1,t){this.logger.log(`startLoad(${e+(t?", <skip seek to start>":"")})`),this.started=!0,this.resumeBuffering();for(let i=0;i<this.networkControllers.length&&(this.networkControllers[i].startLoad(e,t),this.started&&this.networkControllers);i++);}stopLoad(){this.logger.log("stopLoad"),this.started=!1;for(let e=0;e<this.networkControllers.length&&(this.networkControllers[e].stopLoad(),!this.started&&this.networkControllers);e++);}get loadingEnabled(){return this.started}get bufferingEnabled(){return this.streamController.bufferingEnabled}resumeBuffering(){this.bufferingEnabled||(this.logger.log("resume buffering"),this.networkControllers.forEach(e=>{e.resumeBuffering&&e.resumeBuffering()}))}pauseBuffering(){this.bufferingEnabled&&(this.logger.log("pause buffering"),this.networkControllers.forEach(e=>{e.pauseBuffering&&e.pauseBuffering()}))}get inFlightFragments(){let e={[sh]:this.streamController.inFlightFrag};return this.audioStreamController&&(e[su]=this.audioStreamController.inFlightFrag),this.subtititleStreamController&&(e[sc]=this.subtititleStreamController.inFlightFrag),e}swapAudioCodec(){this.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){this.logger.log("recoverMediaError");let e=this._media,t=null==e?void 0:e.currentTime;this.detachMedia(),e&&(this.attachMedia(e),t&&this.startLoad(t))}removeLevel(e){this.levelController.removeLevel(e)}get sessionId(){let e=this._sessionId;return e||(e=this._sessionId=function(){try{return crypto.randomUUID()}catch(e){try{let e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}catch(t){let e=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{let i=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"==t?i:3&i|8).toString(16)})}}}()),e}get levels(){return this.levelController.levels||[]}get latestLevelDetails(){return this.streamController.getLevelDetails()||null}get loadLevelObj(){return this.levelController.loadLevelObj}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){this.logger.log(`set currentLevel:${e}`),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){this.logger.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){this.logger.log(`set loadLevel:${e}`),this.levelController.manualLevel=e}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(e){this.levelController.nextLoadLevel=e}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(e){this.logger.log(`set firstLevel:${e}`),this.levelController.firstLevel=e}get startLevel(){let e=this.levelController.startLevel;return -1===e&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e}set startLevel(e){this.logger.log(`set startLevel:${e}`),-1!==e&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(e){let t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){let{bwEstimator:e}=this.abrController;return e?e.getEstimate():NaN}set bandwidthEstimate(e){this.abrController.resetEstimator(e)}get abrEwmaDefaultEstimate(){let{bwEstimator:e}=this.abrController;return e?e.defaultEstimate:NaN}get ttfbEstimate(){let{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(this.logger.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){am.indexOf(e)>-1&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}get autoLevelEnabled(){return -1===this.levelController.manualLevel}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){let{levels:e,config:{minAutoBitrate:t}}=this;if(!e)return 0;let i=e.length;for(let r=0;r<i;r++)if(e[r].maxBitrate>=t)return r;return 0}get maxAutoLevel(){let e,{levels:t,autoLevelCapping:i,maxHdcpLevel:r}=this;if(e=-1===i&&null!=t&&t.length?t.length-1:i,r)for(let i=e;i--;){let e=t[i].attrs["HDCP-LEVEL"];if(e&&e<=r)return i}return e}get firstAutoLevel(){return this.abrController.firstAutoLevel}get nextAutoLevel(){return this.abrController.nextAutoLevel}set nextAutoLevel(e){this.abrController.nextAutoLevel=e}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}get maxBufferLength(){return this.streamController.maxBufferLength}setAudioOption(e){var t;return(null==(t=this.audioTrackController)?void 0:t.setAudioOption(e))||null}
29setSubtitleOption(e){var t;return(null==(t=this.subtitleTrackController)?void 0:t.setSubtitleOption(e))||null}get allAudioTracks(){let e=this.audioTrackController;return e?e.allAudioTracks:[]}get audioTracks(){let e=this.audioTrackController;return e?e.audioTracks:[]}get audioTrack(){let e=this.audioTrackController;return e?e.audioTrack:-1}set audioTrack(e){let t=this.audioTrackController;t&&(t.audioTrack=e)}get allSubtitleTracks(){let e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}get subtitleTracks(){let e=this.subtitleTrackController;return e?e.subtitleTracks:[]}get subtitleTrack(){let e=this.subtitleTrackController;return e?e.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(e){let t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}get subtitleDisplay(){let e=this.subtitleTrackController;return!!e&&e.subtitleDisplay}set subtitleDisplay(e){let t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(e){this.config.lowLatencyMode=e}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}set targetLatency(e){this.latencyController.targetLatency=e}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}get pathways(){return this.levelController.pathways}get pathwayPriority(){return this.levelController.pathwayPriority}set pathwayPriority(e){this.levelController.pathwayPriority=e}get bufferedToEnd(){var e;return!!(null!=(e=this.bufferController)&&e.bufferedToEnd)}get interstitialsManager(){var e;return(null==(e=this.interstitialsController)?void 0:e.interstitialsManager)||null}getMediaDecodingInfo(e,t=this.allAudioTracks){return ac(e,a_(t),navigator.mediaCapabilities)}}hN.defaultConfig=void 0;var hU="video",hF=e=>e===hU?"playback":e,h$=class e extends Error{constructor(t,i=e.MEDIA_ERR_CUSTOM,r,s){var a;super(t),this.name="MediaError",this.code=i,this.context=s,this.fatal=null!=r?r:i>=e.MEDIA_ERR_NETWORK&&i<=e.MEDIA_ERR_ENCRYPTED,this.message||(this.message=null!=(a=e.defaultMessages[this.code])?a:"")}};h$.MEDIA_ERR_ABORTED=1,h$.MEDIA_ERR_NETWORK=2,h$.MEDIA_ERR_DECODE=3,h$.MEDIA_ERR_SRC_NOT_SUPPORTED=4,h$.MEDIA_ERR_ENCRYPTED=5,h$.MEDIA_ERR_CUSTOM=100,h$.defaultMessages={1:"You aborted the media playback",2:"A network error caused the media download to fail.",3:"A media error caused playback to be aborted. The media could be corrupt or your browser does not support this format.",4:"An unsupported error occurred. The server or network failed, or your browser does not support this format.",5:"The media is encrypted and there are no keys to decrypt it."};var hB=(e,t)=>null!=t&&e in t,hH={ANY:"any",MUTED:"muted"},hG={ON_DEMAND:"on-demand",LIVE:"live",UNKNOWN:"unknown"},hV={MSE:"mse",NATIVE:"native"},hK={HEADER:"header",QUERY:"query",NONE:"none"},hW=(Object.values(hK),{M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"}),hq={HLS:hW.M3U8},hj=(Object.keys(hq),[...Object.values(hW),"hls","HLS"]),hY={code:"en"},hQ=(e,t,i,r,s=e)=>{s.addEventListener(t,i,r),e.addEventListener("teardown",()=>{s.removeEventListener(t,i)},{once:!0})},hz=e=>{let t=e.indexOf("?");return t<0?[e]:[e.slice(0,t),e.slice(t)]},hX=e=>{let{type:t}=e;if(t){let e=t.toUpperCase();return hB(e,hq)?hq[e]:t}return h0(e)},hZ=e=>"VOD"===e?hG.ON_DEMAND:hG.LIVE,hJ=e=>"EVENT"===e?1/0:"VOD"===e?NaN:0,h0=e=>{let{src:t}=e;if(!t)return"";let i="";try{i=new URL(t).pathname}catch{console.error("invalid url")}let r=i.lastIndexOf(".");if(r<0)return h2(e)?hW.M3U8:"";let s=i.slice(r+1).toUpperCase();return hB(s,hW)?hW[s]:""},h1="mux.com",h2=({src:e,customDomain:t=h1})=>{let i;try{i=new URL(`${e}`)}catch{return!1}let r="https:"===i.protocol,s=i.hostname===`stream.${t}`.toLowerCase(),a=i.pathname.split("/"),n=2===a.length,l=!(null!=a&&a[1].includes("."));return r&&s&&n&&l};function h3(e,t=!0){var i;return new h4(t&&null!=(i=null==hY?void 0:hY[e])?i:e,t?hY.code:"en")}
29var h4=class{constructor(e,t=(e=>null!=(e=hY)?e:"en")()){this.message=e,this.locale=t}format(e){return this.message.replace(/\{(\w+)\}/g,(t,i)=>{var r;return null!=(r=e[i])?r:""})}toString(){return this.message}},h5=Object.values(hH),h8=e=>"boolean"==typeof e||"string"==typeof e&&h5.includes(e),h6=(e,t)=>{if(!t)return;let i=e.muted,r=()=>e.muted=i;switch(t){case hH.ANY:e.play().catch(()=>{e.muted=!0,e.play().catch(r)});break;case hH.MUTED:e.muted=!0,e.play().catch(r);break;default:e.play().catch(()=>{})}},h9=e=>"time"in e?e.time:e.startTime;function h7(e,t,i,r,s,a){let n=document.createElement("track");return n.kind=t,n.label=i,r&&(n.srclang=r),s&&(n.id=s),a&&(n.default=!0),n.track.mode=["subtitles","captions"].includes(t)?"disabled":"hidden",n.setAttribute("data-removeondestroy",""),e.append(n),n.track}function ue(e,t,i){var r;return null==(r=Array.from(e.querySelectorAll("track")).find(e=>e.track.label===t&&e.track.kind===i))?void 0:r.track}async function ut(e,t,i,r){let s=ue(e,i,r);return s||((s=h7(e,r,i)).mode="hidden",await new Promise(e=>setTimeout(()=>e(void 0),0))),"hidden"!==s.mode&&(s.mode="hidden"),[...t].sort((e,t)=>h9(t)-h9(e)).forEach(t=>{var i,a;let n=t.value,l=h9(t);if("endTime"in t&&null!=t.endTime)null==s||s.addCue(new VTTCue(l,t.endTime,"chapters"===r?n:JSON.stringify(null!=n?n:null)));else{let t=Array.prototype.findIndex.call(null==s?void 0:s.cues,e=>e.startTime>=l),o=null==(i=null==s?void 0:s.cues)?void 0:i[t],d=o?o.startTime:Number.isFinite(e.duration)?e.duration:Number.MAX_SAFE_INTEGER,h=null==(a=null==s?void 0:s.cues)?void 0:a[t-1];h&&(h.endTime=l),null==s||s.addCue(new VTTCue(l,d,"chapters"===r?n:JSON.stringify(null!=n?n:null)))}}),e.textTracks.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})),s}var ui="cuepoints",ur=Object.freeze({label:ui});async function us(e,t,i=ur){return ut(e,t,i.label,"metadata")}var ua=e=>({time:e.startTime,value:JSON.parse(e.text)});async function un(e,t=ur){return new Promise(i=>{hQ(e,"loadstart",async()=>{let r=await us(e,[],t);hQ(e,"cuechange",()=>{let t=function(e,t={label:ui}){var i,r;let s=ue(e,t.label,"metadata");if(!(null!=(i=null==s?void 0:s.activeCues)&&i.length))return;if(1===s.activeCues.length)return ua(s.activeCues[0]);let{currentTime:a}=e;return ua(Array.prototype.find.call(null!=(r=s.activeCues)?r:[],({startTime:e,endTime:t})=>e<=a&&t>a)||s.activeCues[0])}(e);if(t){let i=new CustomEvent("cuepointchange",{composed:!0,bubbles:!0,detail:t});e.dispatchEvent(i)}},{},r),i(r)})})}var ul="chapters",uo=Object.freeze({label:ul}),ud=e=>({startTime:e.startTime,endTime:e.endTime,value:e.text});async function uh(e,t,i=uo){return ut(e,t,i.label,"chapters")}async function uu(e,t=uo){return new Promise(i=>{hQ(e,"loadstart",async()=>{let r=await uh(e,[],t);hQ(e,"cuechange",()=>{let t=function(e,t={label:ul}){var i,r;let s=ue(e,t.label,"chapters");if(!(null!=(i=null==s?void 0:s.activeCues)&&i.length))return;if(1===s.activeCues.length)return ud(s.activeCues[0]);let{currentTime:a}=e;return ud(Array.prototype.find.call(null!=(r=s.activeCues)?r:[],({startTime:e,endTime:t})=>e<=a&&t>a)||s.activeCues[0])}(e);if(t){let i=new CustomEvent("chapterchange",{composed:!0,bubbles:!0,detail:t});e.dispatchEvent(i)}},{},r),i(r)})})}var uc=(e,t,i,r,s=!1,a=!(e=>null==(e=globalThis.navigator)?void 0:e.onLine)())=>{var n,l,o,d;let h,u;if(a){let i=h3("Your device appears to be offline",s),r=h$.MEDIA_ERR_NETWORK,a=new h$(i,r,!1,void 0);return a.errorCategory=t,a.muxCode=2000002,a.data=e,a}let c="status"in e?e.status:e.code,f=Date.now(),m=h$.MEDIA_ERR_NETWORK;if(200===c)return;let g=hF(t),v=(h=hF(t),u=`${h}Token`,null!=(o=i.tokens)&&o[h]?null==(d=i.tokens)?void 0:d[h]:hB(u,i)?i[u]:void 0),E=t===hU?"v":"drm"===t?"d":void 0,[y]=hz(null!=(n=i.playbackId)?n:"");if(!c||!y)return;let b=(e=>{let t=(null!=e?e:"").split(".")[1];if(t)try{let e=t.replace(/-/g,"+").replace(/_/g,"/"),i=decodeURIComponent(atob(e).split("").map(function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)}).join(""));return JSON.parse(i)}catch{return}})(v);if(v&&!b){let i=new h$(h3("The {tokenNamePrefix}
29-token provided is invalid or malformed.",s).format({tokenNamePrefix:g}),m,!0,h3("Compact JWT string: {token}",s).format({token:v}));return i.errorCategory=t,i.muxCode=2412202,i.data=e,i}if(c>=500){let e=new h$("",m,null==r||r);return e.errorCategory=t,e.muxCode=2e6,e}if(403===c)if(b){if((({exp:e},t=Date.now())=>!e||1e3*e<t)(b,f)){let i={timeStyle:"medium",dateStyle:"medium"},r=new h$(h3("The video’s secured {tokenNamePrefix}-token has expired.",s).format({tokenNamePrefix:g}),m,!0,h3("Expired at: {expiredDate}. Current time: {currentDate}.",s).format({expiredDate:new Intl.DateTimeFormat("en",i).format(null!=(l=b.exp)?l:0),currentDate:new Intl.DateTimeFormat("en",i).format(f)}));return r.errorCategory=t,r.muxCode=2403210,r.data=e,r}if((({sub:e},t)=>e!==t)(b,y)){let i=new h$(h3("The video’s playback ID does not match the one encoded in the {tokenNamePrefix}-token.",s).format({tokenNamePrefix:g}),m,!0,h3("Specified playback ID: {playbackId} and the playback ID encoded in the {tokenNamePrefix}-token: {tokenPlaybackId}",s).format({tokenNamePrefix:g,playbackId:y,tokenPlaybackId:b.sub}));return i.errorCategory=t,i.muxCode=2403232,i.data=e,i}if((({aud:e},t)=>!e)(b,0)){let i=new h$(h3("The {tokenNamePrefix}-token is formatted with incorrect information.",s).format({tokenNamePrefix:g}),m,!0,h3("The {tokenNamePrefix}-token has no aud value. aud value should be {expectedAud}.",s).format({tokenNamePrefix:g,expectedAud:E}));return i.errorCategory=t,i.muxCode=2403221,i.data=e,i}if((({aud:e},t)=>e!==t)(b,E)){let i=new h$(h3("The {tokenNamePrefix}-token is formatted with incorrect information.",s).format({tokenNamePrefix:g}),m,!0,h3("The {tokenNamePrefix}-token has an incorrect aud value: {aud}. aud value should be {expectedAud}.",s).format({tokenNamePrefix:g,expectedAud:E,aud:b.aud}));return i.errorCategory=t,i.muxCode=2403222,i.data=e,i}}else{let i=new h$(h3("Authorization error trying to access this {category} URL. If this is a signed URL, you might need to provide a {tokenNamePrefix}-token.",s).format({tokenNamePrefix:g,category:t}),m,null==r||r,h3("Specified playback ID: {playbackId}",s).format({playbackId:y}));return i.errorCategory=t,i.muxCode=2403201,i.data=e,i}if(412===c){let a=new h$(h3("This playback-id may belong to a live stream that is not currently active or an asset that is not ready.",s),m,null==r||r,h3("Specified playback ID: {playbackId}",s).format({playbackId:y}));return a.errorCategory=t,a.muxCode=2412e3,a.streamType=i.streamType===hG.LIVE?"live":i.streamType===hG.ON_DEMAND?"on-demand":"unknown",a.data=e,a}if(404===c){let i=new h$(h3("This URL or playback-id does not exist. You may have used an Asset ID or an ID from a different resource.",s),m,null==r||r,h3("Specified playback ID: {playbackId}",s).format({playbackId:y}));return i.errorCategory=t,i.muxCode=2404e3,i.data=e,i}if(400===c){let i=new h$(h3("The URL or playback-id was invalid. You may have used an invalid value as a playback-id."),m,null==r||r,h3("Specified playback ID: {playbackId}",s).format({playbackId:y}));return i.errorCategory=t,i.muxCode=24e5,i.data=e,i}let T=new h$("",m,null==r||r);return T.errorCategory=t,T.muxCode=2e6,T.data=e,T},uf=hN.DefaultConfig.capLevelController,um={"720p":921600,"1080p":2073600,"1440p":4194304,"2160p":8294400},up=class e extends uf{constructor(e){super(e)}static setMaxAutoResolution(t,i){i?e.maxAutoResolution.set(t,i):e.maxAutoResolution.delete(t)}getMaxAutoResolution(){var t;let i=this.hls;return null!=(t=e.maxAutoResolution.get(i))?t:void 0}get levels(){var e;return null!=(e=this.hls.levels)?e:[]}getValidLevels(e){return this.levels.filter((t,i)=>this.isLevelAllowed(t)&&i<=e)}getMaxLevelCapped(e){let t=this.getValidLevels(e),i=this.getMaxAutoResolution();if(!i)return super.getMaxLevel(e);let r=um[i.toLowerCase().trim()];if(!r)return super.getMaxLevel(e);let s=t.filter(e=>e.width*e.height<=r),a=s.findIndex(e=>e.width*e.height===r);if(-1!==a){let e=s[a];return t.findIndex(t=>t===e)}if(0===s.length)return 0;let n=s[s.length-1];return t.findIndex(e=>e===n)}getMaxLevel(t){if(void 0!==this.getMaxAutoResolution())return this.getMaxLevelCapped(t);let i=super.getMaxLevel(t),r=this.getValidLevels(t);if(!r[i])return i;let s=Math.min(r[i].width,r[i].height),a=e.minMaxResolution;return s>=a?i:uf.getMaxLevelByMediaSize(r,16/9*a,a)}};up.minMaxResolution=720,up.maxAutoResolution=new WeakMap;var ug,uv,uE,uy,ub,uT,u_,uA,uS,uk,uL,uR,uI,uw,uD,uC,uP,ux,uM,uO,uN=e=>new TextDecoder("utf-16le").decode(e).replace("skd://","").slice(1),uU="fairplay",uF=/([A-Z0-9-]+)="?(.*?)"?(?:,|$)/g,u$=async(e,t)=>{if(t===hW.MP4)return{streamType:hG.ON_DEMAND,targetLiveWindow:NaN,liveEdgeStartOffset:void 0,sessionData:void 0};if(t===hW.M3U8){let t=await fetch(e);if(!t.ok)return Promise.reject(t);let i=await t.text(),r=await fetch(i.split(`
30`).find((e,t,i)=>t&&i[t-1].startsWith("#EXT-X-STREAM-INF"))).then(e=>200!==e.status?Promise.reject(e):e.text());return{...(e=>{let t=e.split(`
31`).filter(e=>e.startsWith("#EXT-X-SESSION-DATA"));if(!t.length)return{};let i={};for(let e of t){let t=Object.fromEntries([...e.matchAll(uF)].map(([,e,t])=>[e,t])),r=t["DATA-ID"];r&&(i[r]={...t})}return{sessionData:i}})(i),...(e=>{var t,i,r;let s=e.split(`
32`),a=null==(i=(null!=(t=s.find(e=>e.startsWith("#EXT-X-PLAYLIST-TYPE")))?t:"").split(":")[1])?void 0:i.trim(),n=hZ(a),l=hJ(a),o;if(n===hG.LIVE){let e=s.find(e=>e.startsWith("#EXT-X-PART-INF"));if(e)o=2*e.split(":")[1].split("=")[1];else{let e=s.find(e=>e.startsWith("#EXT-X-TARGETDURATION")),t=null==(r=null==e?void 0:e.split(":"))?void 0:r[1];o=(null!=t?t:6)*3}}return{streamType:n,targetLiveWindow:l,liveEdgeStartOffset:o}})(r)}}return console.error(`Media type ${t} is an unrecognized or unsupported type for src ${e}.`),{streamType:void 0,targetLiveWindow:void 0,liveEdgeStartOffset:void 0,sessionData:void 0}},uB=async(e,t,i=hX({src:e}))=>{var r,s,a,n;let{streamType:l,targetLiveWindow:o,liveEdgeStartOffset:d,sessionData:h}=await u$(e,i),u=null==h?void 0:h["com.apple.hls.chapters"];(null!=u&&u.URI||null!=u&&u.VALUE.toLocaleLowerCase().startsWith("http"))&&uH(null!=(r=u.URI)?r:u.VALUE,t),(null!=(s=uW.get(t))?s:{}).liveEdgeStartOffset=d,(null!=(a=uW.get(t))?a:{}).targetLiveWindow=o,t.dispatchEvent(new CustomEvent("targetlivewindowch
32ange",{composed:!0,bubbles:!0})),(null!=(n=uW.get(t))?n:{}).streamType=l,t.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},uH=async(e,t)=>{var i,r;try{let s=await fetch(e);if(!s.ok)throw Error(`Failed to fetch Mux metadata: ${s.status} ${s.statusText}`);let a=await s.json(),n={};if(!(null!=(i=null==a?void 0:a[0])&&i.metadata))return;for(let e of a[0].metadata)e.key&&e.value&&(n[e.key]=e.value);(null!=(r=uW.get(t))?r:{}).metadata=n;let l=new CustomEvent("muxmetadata");t.dispatchEvent(l)}catch(e){console.error(e)}},uG=null!=(uC=null==(uD=null==globalThis?void 0:globalThis.navigator)?void 0:uD.userAgent)?uC:"",uV=null!=(uM=null==(ux=null==(uP=null==globalThis?void 0:globalThis.navigator)?void 0:uP.userAgentData)?void 0:ux.platform)?uM:"",uK=uG.toLowerCase().includes("android")||["x11","android"].some(e=>uV.toLowerCase().includes(e)),uW=new WeakMap,uq="mux.com",uj=null==(uO=hN.isSupported)?void 0:uO.call(hN),uY=r9.utils.generateUUID,uQ=({playbackId:e,customDomain:t=uq,maxResolution:i,minResolution:r,renditionOrder:s,programStartTime:a,programEndTime:n,assetStartTime:l,assetEndTime:o,playbackToken:d,tokens:{playback:h=d}={},extraSourceParams:u={}}={})=>{if(!e)return;let[c,f=""]=hz(e),m=new URL(`https://stream.${t}/${c}.m3u8${f}`);return h||m.searchParams.has("token")?(m.searchParams.forEach((e,t)=>{"token"!=t&&m.searchParams.delete(t)}),h&&m.searchParams.set("token",h)):(i&&m.searchParams.set("max_resolution",i),r&&(m.searchParams.set("min_resolution",r),i&&+i.slice(0,-1)<+r.slice(0,-1)&&console.error("minResolution must be <= maxResolution","minResolution",r,"maxResolution",i)),s&&m.searchParams.set("rendition_order",s),a&&m.searchParams.set("program_start_time",`${a}`),n&&m.searchParams.set("program_end_time",`${n}`),l&&m.searchParams.set("asset_start_time",`${l}`),o&&m.searchParams.set("asset_end_time",`${o}`),Object.entries(u).forEach(([e,t])=>{null!=t&&m.searchParams.set(e,t)})),m.toString()},uz=e=>{if(!e)return;let[t]=e.split("?");return t||void 0},uX=e=>{if(!e||!e.startsWith("https://stream."))return;let[t]=new URL(e).pathname.slice(1).split(/\.m3u8|\//);return t||void 0},uZ=e=>{var t,i;return null!=(i=null==(t=uW.get(e))?void 0:t.streamType)?i:hG.UNKNOWN},uJ=.034,u0=(e,t,i=uJ)=>e>t||((e,t,i=uJ)=>Math.abs(e-t)<=i)(e,t,i),u1=(e,t)=>{var i,r,s;if(!t||!e.buffered.length)return;if(e.readyState>2)return!1;let a=t.currentLevel>=0?null==(r=null==(i=t.levels)?void 0:i[t.currentLevel])?void 0:r.details:null==(s=t.levels.find(e=>!!e.details))?void 0:s.details;if(!a||a.live)return;let{fragments:n}=a;if(!(null!=n&&n.length))return;if(e.currentTime<e.duration-(a.targetduration+.5))return!1;let l=n[n.length-1];if(e.currentTime<=l.start)return!1;let o=l.start+l.duration/2,d=e.buffered.start(e.buffered.length-1),h=e.buffered.end(e.buffered.length-1);return o>d&&o<h},u2=(e,t,i)=>{var r,s,a;u3(t,i,e);let{metadata:n={}}=e,{view_session_id:l=uY()}=n,o=null!=(r=null==e?void 0:e.metadata)&&r.video_id?e.metadata.video_id:ci(e)&&null!=(a=null!=(s=uz(e.playbackId))?s:uX(e.src))?a:e.src;n.view_session_id=l,n.video_id=o,e.metadata=n,e.drmTypeCb=e=>{var i;null==(i=t.mux)||i.emit("hb",{view_drm_type:e})},e.fallbackToWebkitFairplay=async()=>{var i;let r=!t.paused,s=t.currentTime;e.useWebkitFairplay=!0;let a=e.muxDataKeepSession;e.muxDataKeepSession=!0;let n=null==(i=uW.get(t))?void 0:i.coreReference;u2(e,t,n),e.muxDataKeepSession=a,e.useWebkitFairplay=!1,r&&await t.play().then(()=>{t.currentTime=s}).catch(()=>{}),t.currentTime=s},uW.set(t,{retryCount:0});let d=u5(e,t),h=(({preload:e,src:t},i,r)=>{let s=e=>{null!=e&&["","none","metadata","auto"].includes(e)?i.setAttribute("preload",e):i.removeAttribute("preload")};if(!r)return s(e),s;let a=!1,n=!1,l=r.config.maxBufferLength,o=r.config.maxBufferSize,d=e=>{s(e);let t=null!=e?e:i.preload;n||"none"===t||("metadata"===t?(r.config.maxBufferLength=1,r.config.maxBufferSize=1):(r.config.maxBufferLength=l,r.config.maxBufferSize=o),h())},h=()=>{!a&&t&&(a=!0,r.loadSource(t))};return hQ(i,"play",()=>{n=!0,r.config.maxBufferLength=l,r.config.maxBufferSize=o,h()},{once:!0}),d(e),d})(e,t,d);null!=e&&e.muxDataKeepSession&&null!=t&&t.mux&&!t.mux.deleted?d&&t.mux.addHLSJS({hlsjs:d,Hls:d?hN:void 0}):cs(e,t,d),ca(e,t,d),un(t),uu(t);let u=((e,t,i)=>{let{autoplay:r}=e,s=!1,a=!1,n=h8(r)?r:!!r,l=()=>{s||hQ(t,"playing",()=>{s=!0},{once:!0})};if(l(),hQ(t,"loadstart",()=>{s=!1,l(),h6(t,n)},{once:!0}),hQ(t,"loadstart",()=>{i||(a=e.streamType&&e.streamType!==hG.UNKNOWN?e.streamType===hG.LIVE:!Number.isFinite(t.duration)),h6(t,n)},{once:!0}),i&&i.once(hN.Events.LEVEL_LOADED,(t,i)=>{var r;a=e.streamType&&e.streamType!==hG.UNKNOWN?e.streamType===hG.LIVE:null!=(r=i.details.live)&&r}),!n){let r=()=>{!a||Number.isFinite(e.startTime)||(null!=i&&i.liveSyncPosition?t.currentTime=i.liveSyncPosition:Number.isFinite(t.seekable.end(0))&&(t.currentTime=t.
32seekable.end(0)))};i&&hQ(t,"play",()=>{"metadata"===t.preload?i.once(hN.Events.LEVEL_UPDATED,r):r()},{once:!0})}return e=>{s||h6(t,n=h8(e)?e:!!e)}})(e,t,d),c={engine:d,setAutoplay:u,setPreload:h},f=uW.get(t);return f&&(f.coreReference=c),c},u3=(e,t,i)=>{let r=null==t?void 0:t.engine;null!=e&&e.mux&&!e.mux.deleted&&(null!=i&&i.muxDataKeepSession?r&&e.mux.removeHLSJS():(e.mux.destroy(),delete e.mux)),r&&(r.detachMedia(),r.destroy()),e&&(e.hasAttribute("src")&&(e.removeAttribute("src"),e.load()),e.removeEventListener("error",cl),e.removeEventListener("error",cd),e.removeEventListener("durationchange",cn),uW.delete(e),e.dispatchEvent(new Event("teardown")))};function u4(e,t){var i;let r=hX(e);if(r!==hW.M3U8)return!0;let s=!r||null==(i=t.canPlayType(r))||i,{preferPlayback:a}=e,n=a===hV.MSE,l=a===hV.NATIVE,o=uj&&(n||uK||!(/^((?!chrome|android).)*safari/i.test(uG)&&t.canPlayType("application/vnd.apple.mpegurl")));return s&&(l||!o)}var u5=(e,t)=>{let{debug:i,streamType:r,startTime:s=-1,metadata:a,preferCmcd:n,_hlsConfig:l={},maxAutoResolution:o}=e,d=hX(e)===hW.M3U8,h=u4(e,t);if(d&&!h&&uj){let d=u8(r),h=u6(e),u=[hK.QUERY,hK.HEADER].includes(n)?{useHeaders:n===hK.HEADER,sessionId:null==a?void 0:a.view_session_id,contentId:null==a?void 0:a.video_id}:void 0,c=cr(e,l),f=new hN({debug:i,startPosition:s,cmcd:u,xhrSetup:(e,t)=>{var i,r;if(n&&n!==hK.QUERY)return;let s=new URL(t);if(!s.searchParams.has("CMCD"))return;let a=(null!=(r=null==(i=s.searchParams.get("CMCD"))?void 0:i.split(","))?r:[]).filter(e=>e.startsWith("sid")||e.startsWith("cid")).join(",");s.searchParams.set("CMCD",a),e.open("GET",s)},backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0,capLevelOnFPSDrop:!0,...c,...d,...h,...l});return c.capLevelController===up&&void 0!==o&&up.setMaxAutoResolution(f,o),f.on(hN.Events.MANIFEST_PARSED,async function(e,i){var r,s;let a=null==(r=i.sessionData)?void 0:r["com.apple.hls.chapters"];(null!=a&&a.URI||null!=a&&a.VALUE.toLocaleLowerCase().startsWith("http"))&&uH(null!=(s=null==a?void 0:a.URI)?s:null==a?void 0:a.VALUE,t)}),f}},u8=e=>e===hG.LIVE?{backBufferLength:8}:{},u6=e=>{let{tokens:{drm:t}={},playbackId:i,drmTypeCb:r}=e,s=uz(i);return t&&s?{emeEnabled:!0,drmSystems:{"com.apple.fps":{licenseUrl:ce(e,"fairplay"),serverCertificateUrl:ct(e,"fairplay")},"com.widevine.alpha":{licenseUrl:ce(e,"widevine")},"com.microsoft.playready":{licenseUrl:ce(e,"playready")}},requestMediaKeySystemAccessFunc:(e,t)=>("com.widevine.alpha"===e&&(t=[...t.map(e=>{var t;let i=null==(t=e.videoCapabilities)?void 0:t.map(e=>({...e,robustness:"HW_SECURE_ALL"}));return{...e,videoCapabilities:i}}),...t]),navigator.requestMediaKeySystemAccess(e,t).then(t=>{let i=e.includes("fps")?uU:e.includes("playready")?"playready":e.includes("widevine")?"widevine":void 0;return null==r||r(i),t}))}:{}},u9=async e=>{let t=await fetch(e);return 200!==t.status?Promise.reject(t):await t.arrayBuffer()},u7=async(e,t)=>{let i=await fetch(t,{method:"POST",headers:{"Content-type":"application/octet-stream"},body:e});return 200!==i.status?Promise.reject(i):new Uint8Array(await i.arrayBuffer())},ce=({playbackId:e,tokens:{drm:t}={},customDomain:i=uq},r)=>{let s=uz(e);return`https://license.${i.toLocaleLowerCase().endsWith(uq)?i:uq}/license/${r}/${s}?token=${t}`},ct=({playbackId:e,tokens:{drm:t}={},customDomain:i=uq},r)=>{let s=uz(e);return`https://license.${i.toLocaleLowerCase().endsWith(uq)?i:uq}/appcert/${r}/${s}?token=${t}`},ci=({playbackId:e,src:t,customDomain:i})=>{if(e)return!0;if("string"!=typeof t)return!1;let r=new URL(t,null==window?void 0:window.location.href).hostname.toLocaleLowerCase();return r.includes(uq)||!!i&&r.includes(i.toLocaleLowerCase())},cr=(e,t)=>{let i={};return i.capLevelToPlayerSize=e.capRenditionToPlayerSize,null==i.capLevelToPlayerSize?(i.capLevelController=up,i.capLevelToPlayerSize=!0):i.capLevelController=oC,i},cs=(e,t,i)=>{var r;let{envKey:s,disableTracking:a,muxDataSDK:n=r9,muxDataSDKOptions:l={}}=e,o=ci(e);if(!a&&(s||o)){let{playerInitTime:a,playerSoftwareName:o,playerSoftwareVersion:d,beaconCollectionDomain:h,debug:u,disableCookies:c}=e,f={...e.metadata,video_title:(null==(r=null==e?void 0:e.metadata)?void 0:r.video_title)||void 0};n.monitor(t,{debug:u,beaconCollectionDomain:h,hlsjs:i,Hls:i?hN:void 0,automaticErrorTracking:!1,errorTranslator:t=>"string"!=typeof t.player_error_code&&("function"==typeof e.errorTranslator?e.errorTranslator(t):t),disableCookies:c,...l,data:{...s?{env_key:s}:{},player_software_name:o,player_software:o,player_software_version:d,player_init_time:a,...f}})}},ca=(e,t,i)=>{var r,s;let a=u4(e,t),{src:n,customDomain:l=uq}=e,o=()=>{t.ended||e.disablePseudoEnded||(t.ended||t.loop?!t.ended:!(i&&u1(t,i)||((e,t=uJ)=>e.paused&&u0(e.currentTime,e.duration,t))(t)))||(u1(t,i)?t.currentTime=t.buffered.end(t.buffered.length-1):t.dispatchEvent(new Event("ended")))},d,h,u=()=>{var e,i;let r=null!=(i=null==(e=uW.get(t))?void 0:e.seekable)?i:t.seekable,s,a;r.length>0&&(s=r.start(0),a=r.end(0)),(h!==a||d!==s)&&t.dispatchEvent(new CustomEvent("seekablechange",{composed:!0})),d=s,h=a};if(hQ(t,"durationchange",u),t&&a){let i=hX(e);if("string"==typeof n){if(n.endsWith(".mp4")&&n.includes(l)){let e=uX(n);uH(new URL(`https://stream.${l}/${e}/metadata.json`).toString(),t)}let a=()=>
32{if(uZ(t)!==hG.LIVE||Number.isFinite(t.duration))return;let e=setInterval(u,1e3);t.addEventListener("teardown",()=>{clearInterval(e)},{once:!0}),hQ(t,"durationchange",()=>{Number.isFinite(t.duration)&&clearInterval(e)})},o=async()=>uB(n,t,i).then(a).catch(i=>{if(i instanceof Response){let r=uc(i,hU,e);if(r)return void co(t,r)}});if("none"===t.preload){let e=()=>{o(),t.removeEventListener("loadedmetadata",i)},i=()=>{o(),t.removeEventListener("play",e)};hQ(t,"play",e,{once:!0}),hQ(t,"loadedmetadata",i,{once:!0})}else o();null!=(r=e.tokens)&&r.drm?((e,t)=>{let i={mediaEl:t,getAppCertificate:()=>u9(ct(e,"fairplay")).catch(t=>{if(t instanceof Response){let i=uc(t,"drm",e);return console.error("mediaError",null==i?void 0:i.message,null==i?void 0:i.context),i?Promise.reject(i):Promise.reject(Error("Unexpected error in app cert request"))}return Promise.reject(t)}),getLicenseKey:t=>u7(t,ce(e,"fairplay")).catch(t=>{if(t instanceof Response){let i=uc(t,"drm",e);return console.error("mediaError",null==i?void 0:i.message,null==i?void 0:i.context),i?Promise.reject(i):Promise.reject(Error("Unexpected error in license key request"))}return Promise.reject(t)}),saveAndDispatchError:co,drmTypeCb:()=>{var t;null==(t=e.drmTypeCb)||t.call(e,uU)}};if(e.useWebkitFairplay)(({mediaEl:e,getAppCertificate:t,getLicenseKey:i,saveAndDispatchError:r,drmTypeCb:s})=>{if(!window.WebKitMediaKeys||!("onwebkitneedkey"in e)){console.error("No WebKitMediaKeys. FairPlay may not be supported");let t=new h$(h3("Cannot play DRM-protected content with current security configuration on this browser. Try playing in another browser."),h$.MEDIA_ERR_ENCRYPTED,!0);return t.errorCategory="drm",t.muxCode=5000005,r(e,t),()=>{}}let a=t(),n=null,l=t=>{(async()=>{try{var i,s;let r,n,l,h,u,c,f,m;e.webkitKeys||o();let g=await a;if(null===t.initData||null==g)return;let v=(i=t.initData,s=g,r=function(e){let t=new ArrayBuffer(2*e.length),i=new DataView(t);for(let t=0;t<e.length;t++)i.setUint16(2*t,e.charCodeAt(t),!0);return t}(uN(i)),n=new Uint8Array(i),l=new Uint8Array(r),h=new Uint8Array(s),u=new Uint8Array(n.byteLength+4+h.byteLength+4+l.byteLength),c=0,f=e=>{u.set(e,c),c+=e.byteLength},m=e=>{let t=new DataView(u.buffer),i=e.byteLength;t.setUint32(c,i,!0),c+=4,f(e)},f(n),m(l),m(h),u);d(v)}catch(t){console.error("Could not start encrypted playback due to exception",t),r(e,t)}})()},o=()=>{try{let t=new WebKitMediaKeys("com.apple.fps.1_0");e.webkitSetMediaKeys(t),s()}catch{let e=new h$("Cannot play DRM-protected content with current security configuration on this browser. Try playing in another browser.",h$.MEDIA_ERR_ENCRYPTED,!0);throw e.errorCategory="drm",e.muxCode=5000001,e}},d=t=>{let s=e.webkitKeys.createSession("application/vnd.apple.mpegurl",t),a=async t=>{try{let e=t.message,r=await i(e);s.update(r)}catch(t){console.error("Error on FairPlay session message",t),r(e,t)}},l=t=>{let i=t.target.error;if(!i)return;console.error(`Internal Webkit Key Session Error - sysCode: ${i.systemCode} code: ${i.code}`);let s=new h$(h3("The DRM Content Decryption Module system had an internal failure. Try reloading the page, upading your browser, or playing in another browser."),h$.MEDIA_ERR_ENCRYPTED,!0);s.errorCategory="drm",s.muxCode=5000005,r(e,s)},o=()=>{s.removeEventListener("webkitkeymessage",a),s.removeEventListener("webkitkeyerror",l),e.removeEventListener("teardown",o),"webkitCurrentPlaybackTargetIsWireless"in e&&e.removeEventListener("webkitcurrentplaybacktargetiswirelesschanged",o),n=null;try{s.close()}catch{}};"webkitCurrentPlaybackTargetIsWireless"in e&&e.addEventListener("webkitcurrentplaybacktargetiswirelesschanged",o,{once:!0}),s.addEventListener("webkitkeymessage",a),s.addEventListener("webkitkeyerror",l),e.addEventListener("teardown",o),n=o},h=()=>{e.removeEventListener("webkitneedkey",l),e.removeEventListener("teardown",h),null==n||n();try{e.webkitSetMediaKeys(null)}catch{}};return e.addEventListener("webkitneedkey",l),e.addEventListener("teardown",h,{once:!0})})(i);else{let t=(({mediaEl:e,getAppCertificate:t,getLicenseKey:i,saveAndDispatchError:r,drmTypeCb:s,fallbackToWebkitFairplay:a})=>{let n=null,l=async t=>{try{let i=t.initDataType;if("skd"!==i)return void console.error(`Received unexpected initialization data type "${i}"`);e.mediaKeys||await o(i);let r=t.initData;if(null==r)return void console.error(`Could not start encrypted playback due to missing initData in ${t.type} event`);await d(i,r)}catch(t){r(e,t);return}},o=async i=>{let a=await navigator.requestMediaKeySystemAccess("com.apple.fps",[{initDataTypes:[i],videoCapabilities:[{contentType:"application/vnd.apple.mpegurl",robustness:""}],distinctiveIdentifier:"not-allowed",persistentState:"not-allowed",sessionTypes:["temporary"]}]).then(e=>(s(),e)).catch(()=>
32{let t=new h$(h3("Cannot play DRM-protected content with current security configuration on this browser. Try playing in another browser."),h$.MEDIA_ERR_ENCRYPTED,!0);t.errorCategory="drm",t.muxCode=5000001,r(e,t)});if(!a)return;let n=await a.createMediaKeys();try{let e=await t();await n.setServerCertificate(e).catch(()=>{let e=h3("Your server certificate failed when attempting to set it. This may be an issue with a no longer valid certificate."),t=new h$(e,h$.MEDIA_ERR_ENCRYPTED,!0);return t.errorCategory="drm",t.muxCode=5000004,Promise.reject(t)})}catch(t){r(e,t);return}await e.setMediaKeys(n)},d=async(t,s)=>{let l=e.mediaKeys.createSession(),o=async t=>{let s=t.message,a=await i(s);try{await l.update(a)}catch{let t=new h$(h3("Failed to update DRM license. This may be an issue with the player or your protected content."),h$.MEDIA_ERR_ENCRYPTED,!0);t.errorCategory="drm",t.muxCode=5000003,r(e,t)}},d=()=>{l.keyStatuses.forEach(t=>{let i;"internal-error"===t?((i=new h$(h3("The DRM Content Decryption Module system had an internal failure. Try reloading the page, upading your browser, or playing in another browser."),h$.MEDIA_ERR_ENCRYPTED,!0)).errorCategory="drm",i.muxCode=5000005):("output-restricted"===t||"output-downscaled"===t)&&((i=new h$(h3("DRM playback is being attempted in an environment that is not sufficiently secure. User may see black screen."),h$.MEDIA_ERR_ENCRYPTED,!1)).errorCategory="drm",i.muxCode=5000006),i&&r(e,i)})};l.addEventListener("keystatuseschange",d),l.addEventListener("message",o);let h=async()=>{l.removeEventListener("keystatuseschange",d),l.removeEventListener("message",o),"webkitCurrentPlaybackTargetIsWireless"in e&&e.removeEventListener("webkitcurrentplaybacktargetiswirelesschanged",h),e.removeEventListener("teardown",h),await l.close().catch(e=>{console.warn("There was an error when closing EME session",e)}),n=null};"webkitCurrentPlaybackTargetIsWireless"in e&&e.addEventListener("webkitcurrentplaybacktargetiswirelesschanged",h,{once:!0}),e.addEventListener("teardown",h,{once:!0}),n=h,await l.generateRequest(t,s).catch(async t=>{if("NotSupportedError"===t.name&&"webkitCurrentPlaybackTargetIsWireless"in e&&e.webkitCurrentPlaybackTargetIsWireless)console.warn("Failed to generate a DRM license request. Attempting to fallback to Webkit DRM"),null==a||a();else{let e=new h$(h3("Failed to generate a DRM license request. This may be an issue with the player or your protected content."),h$.MEDIA_ERR_ENCRYPTED,!0);return e.errorCategory="drm",e.muxCode=5000002,console.error("Failed to generate license request",t),Promise.reject(e)}})},h=async()=>{e.removeEventListener("encrypted",l),e.removeEventListener("teardown",h),n&&await n(),await e.setMediaKeys(null).catch(()=>{})};return e.addEventListener("encrypted",l),e.addEventListener("teardown",h,{once:!0}),h})({fallbackToWebkitFairplay:async()=>{var i;await t(),null==(i=e.fallbackToWebkitFairplay)||i.call(e)},...i})}})(e,t):hQ(t,"encrypted",()=>{let e=new h$(h3("Attempting to play DRM-protected content without providing a DRM token."),h$.MEDIA_ERR_ENCRYPTED,!0);e.errorCategory="drm",e.muxCode=5000002,co(t,e)},{once:!0}),t.setAttribute("src",n),e.startTime&&((null!=(s=uW.get(t))?s:{}).startTime=e.startTime,t.addEventListener("durationchange",cn,{once:!0}))}else t.removeAttribute("src");t.addEventListener("error",cl),t.addEventListener("error",cd),t.addEventListener("emptied",()=>{t.querySelectorAll("track[data-removeondestroy]").forEach(e=>{e.remove()})},{once:!0}),hQ(t,"pause",o),hQ(t,"seeked",o),hQ(t,"play",()=>{t.ended||u0(t.currentTime,t.duration)&&(t.currentTime=t.seekable.length?t.seekable.start(0):0)})}else{let r,s;i&&n?(i.once(hN.Events.LEVEL_LOADED,(e,r)=>{((e,t,i)=>{var r,s,a,n,l,o,d,h,u;let c,f,m,g,v,{streamType:E,targetLiveWindow:y,liveEdgeStartOffset:b,lowLatency:T}=(f=hZ(c=e.type),m=hJ(c),v=!!(null!=(u=e.partList)&&u.length),f===hG.LIVE&&(g=v?2*e.partTarget:3*e.targetduration),{streamType:f,targetLiveWindow:m,liveEdgeStartOffset:g,lowLatency:v});if(E===hG.LIVE){T?(i.config.backBufferLength=null!=(r=i.userConfig.backBufferLength)?r:4,i.config.maxFragLookUpTolerance=null!=(s=i.userConfig.maxFragLookUpTolerance)?
32s:.001,i.config.abrBandWidthUpFactor=null!=(a=i.userConfig.abrBandWidthUpFactor)?a:i.config.abrBandWidthFactor):i.config.backBufferLength=null!=(n=i.userConfig.backBufferLength)?n:8;let e=Object.freeze({get length(){return t.seekable.length},start:e=>t.seekable.start(e),end(e){var r;return e>this.length||e<0||Number.isFinite(t.duration)?t.seekable.end(e):null!=(r=i.liveSyncPosition)?r:t.seekable.end(e)}});(null!=(l=uW.get(t))?l:{}).seekable=e}(null!=(o=uW.get(t))?o:{}).liveEdgeStartOffset=b,(null!=(d=uW.get(t))?d:{}).targetLiveWindow=y,t.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),(null!=(h=uW.get(t))?h:{}).streamType=E,t.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))})(r.details,t,i),u(),uZ(t)!==hG.LIVE||Number.isFinite(t.duration)||(i.on(hN.Events.LEVEL_UPDATED,u),hQ(t,"durationchange",()=>{Number.isFinite(t.duration)&&i.off(hN.Events.LEVELS_UPDATED,u)}))}),i.on(hN.Events.ERROR,(r,s)=>{var a,n;let l=ch(s,e);if(2412e3===l.muxCode){let e=null!=(a=uW.get(t))?a:{},r=null!=(n=e.retryCount)?n:0;if(r<6){let a=0===r?5e3:6e4,n=new h$(`Retrying in ${a/1e3} seconds...`,l.code,l.fatal);Object.assign(n,l),co(t,n);let o=setTimeout(()=>{e.retryCount=r+1,"manifestLoadError"===s.details&&s.url&&i.loadSource(s.url)},a);t.addEventListener("teardown",()=>clearTimeout(o),{once:!0});return}{e.retryCount=0;let i=new h$('Try again later or <a href="#" onclick="window.location.reload(); return false;" style="color: #4a90e2;">click here to retry</a>',l.code,l.fatal);Object.assign(i,l),co(t,i);return}}co(t,l)}),i.on(hN.Events.MANIFEST_LOADED,()=>{let e=uW.get(t);e&&e.error&&(e.error=null,e.retryCount=0,t.dispatchEvent(new Event("emptied")),t.dispatchEvent(new Event("loadstart")))}),t.addEventListener("error",cd),hQ(t,"waiting",o),function(e,t){var i;if(!("videoTracks"in e))return;let r=new WeakMap;t.on(hN.Events.MANIFEST_PARSED,function(t,i){l();let s=e.addVideoTrack("main");for(let[e,t]of(s.selected=!0,i.levels.entries())){let i=s.addRendition(t.url[0],t.width,t.height,t.videoCodec,t.bitrate);r.set(t,`${e}`),i.id=`${e}`}}),t.on(hN.Events.AUDIO_TRACKS_UPDATED,function(t,i){for(let t of(n(),i.audioTracks)){let i=t.default?"main":"alternative",r=e.addAudioTrack(i,t.name,t.lang);r.id=`${t.id}`,t.default&&(r.enabled=!0)}});let s=()=>{var i;let r=+(null==(i=[...e.audioTracks].find(e=>e.enabled))?void 0:i.id),s=t.audioTracks.map(e=>e.id);r!=t.audioTrack&&s.includes(r)&&(t.audioTrack=r)};e.audioTracks.addEventListener("change",s),t.on(hN.Events.LEVELS_UPDATED,function(t,i){var s;let a=e.videoTracks[null!=(s=e.videoTracks.selectedIndex)?s:0];if(!a)return;let n=i.levels.map(e=>r.get(e));for(let t of e.videoRenditions)t.id&&!n.includes(t.id)&&a.removeRendition(t)});let a=e=>{let i=e.target.selectedIndex;i!=t.nextLevel&&(t.nextLevel=i)};null==(i=e.videoRenditions)||i.addEventListener("change",a);let n=()=>{for(let t of e.audioTracks)e.removeAudioTrack(t)},l=()=>{(()=>{for(let t of e.videoTracks)e.removeVideoTrack(t)})(),n()};t.once(hN.Events.DESTROYING,()=>{var t,i;l(),null==(t=e.audioTracks)||t.removeEventListener("change",s),null==(i=e.videoRenditions)||i.removeEventListener("change",a)})}(e,i),i.on(hN.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(e,{tracks:r})=>{r.forEach(e=>{var r,s;let a=null!=(r=e.subtitleTrack)?r:e.closedCaptions,n=i.subtitleTracks.findIndex(({lang:t,name:i,type:r})=>t==(null==a?void 0:a.lang)&&i===e.label&&r.toLowerCase()===e.kind),l=(null!=(s=e._id)?s:e.default)?"default":`${e.kind}${n}`;h7(t,e.kind,e.label,null==a?void 0:a.lang,l,e.default)})}),r=()=>{if(!i.subtitleTracks.length)return;let e=Array.from(t.textTracks).find(e=>e.id&&"showing"===e.mode&&["subtitles","captions"].includes(e.kind));if(!e)return;let r=i.subtitleTracks[i.subtitleTrack],s=r?r.default?"default":`${i.subtitleTracks[i.subtitleTrack].type.toLowerCase()}${i.subtitleTrack}`:void 0;if(i.subtitleTrack<0||(null==e?void 0:e.id)!==s){let t=i.subtitleTracks.findIndex(({lang:t,name:i,type:r,default:s})=>"default"===e.id&&s||t==e.language&&i===e.label&&r.toLowerCase()===e.kind);i.subtitleTrack=t}
32(null==e?void 0:e.id)===s&&e.cues&&Array.from(e.cues).forEach(t=>{e.addCue(t)})},t.textTracks.addEventListener("change",r),i.on(hN.Events.CUES_PARSED,(e,{track:i,cues:r})=>{let s=t.textTracks.getTrackById(i);if(!s)return;let a="disabled"===s.mode;a&&(s.mode="hidden"),r.forEach(e=>{var t;null!=(t=s.cues)&&t.getCueById(e.id)||s.addCue(e)}),a&&(s.mode="disabled")}),i.once(hN.Events.DESTROYING,()=>{t.textTracks.removeEventListener("change",r),t.querySelectorAll("track[data-removeondestroy]").forEach(e=>{e.remove()})}),s=()=>{Array.from(t.textTracks).forEach(e=>{var i,r;if(!["subtitles","caption"].includes(e.kind)&&("thumbnails"===e.label||"chapters"===e.kind)){if(!(null!=(i=e.cues)&&i.length)){let i="track";e.kind&&(i+=`[kind="${e.kind}"]`),e.label&&(i+=`[label="${e.label}"]`);let s=t.querySelector(i),a=null!=(r=null==s?void 0:s.getAttribute("src"))?r:"";null==s||s.removeAttribute("src"),setTimeout(()=>{null==s||s.setAttribute("src",a)},0)}"hidden"!==e.mode&&(e.mode="hidden")}})},i.once(hN.Events.MANIFEST_LOADED,s),i.once(hN.Events.MEDIA_ATTACHED,s),i.attachMedia(t)):console.error("It looks like the video you're trying to play will not work on this system! If possible, try upgrading to the newest versions of your browser or software.")}};function cn(e){var t;let i=e.target,r=null==(t=uW.get(i))?void 0:t.startTime;if(r&&function(e,t,i){t&&i>t&&(i=t);for(let t=0;t<e.length;t++)if(e.start(t)<=i&&e.end(t)>=i)return!0;return!1}(i.seekable,i.duration,r)){let e="auto"===i.preload;e&&(i.preload="none"),i.currentTime=r,e&&(i.preload="auto")}}async function cl(e){if(!e.isTrusted)return;e.stopImmediatePropagation();let t=e.target;if(!(null!=t&&t.error))return;let{message:i,code:r}=t.error,s=new h$(i,r);if(t.src&&r===h$.MEDIA_ERR_SRC_NOT_SUPPORTED&&t.readyState===HTMLMediaElement.HAVE_NOTHING)return void setTimeout(()=>{var e,i;let r=null!=(e=null==(i=uW.get(t))?void 0:i.error)?e:t.error;(null==r?void 0:r.code)===h$.MEDIA_ERR_SRC_NOT_SUPPORTED&&co(t,s)},500);if(t.src&&(r!==h$.MEDIA_ERR_DECODE||void 0!==r))try{let{status:e}=await fetch(t.src);s.data={response:{code:e}}}catch{}co(t,s)}function co(e,t){var i;t.fatal&&((null!=(i=uW.get(e))?i:{}).error=t,e.dispatchEvent(new CustomEvent("error",{detail:t})))}function cd(e){var t,i;if(!(e instanceof CustomEvent)||!(e.detail instanceof h$))return;let r=e.target,s=e.detail;s&&s.fatal&&((null!=(t=uW.get(r))?t:{}).error=s,null==(i=r.mux)||i.emit("error",{player_error_code:s.code,player_error_message:s.message,player_error_context:s.context}))}var ch=(e,t)=>{var i,r,s;e.fatal?console.error("getErrorFromHlsErrorData()",e):t.debug&&console.warn("getErrorFromHlsErrorData() (non-fatal)",e);let a={[hN.ErrorTypes.NETWORK_ERROR]:h$.MEDIA_ERR_NETWORK,[hN.ErrorTypes.MEDIA_ERROR]:h$.MEDIA_ERR_DECODE,[hN.ErrorTypes.KEY_SYSTEM_ERROR]:h$.MEDIA_ERR_ENCRYPTED},n,l=[hN.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,hN.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED].includes(e.details)?h$.MEDIA_ERR_NETWORK:a[e.type];if(l===h$.MEDIA_ERR_NETWORK&&e.response){let s=null!=(i=e.type===hN.ErrorTypes.KEY_SYSTEM_ERROR?"drm":e.type===hN.ErrorTypes.NETWORK_ERROR?hU:void 0)?i:hU;n=null!=(r=uc(e.response,s,t,e.fatal))?r:new h$("",l,e.fatal)}else l===h$.MEDIA_ERR_ENCRYPTED?e.details===hN.ErrorDetails.KEY_SYSTEM_NO_CONFIGURED_LICENSE?((n=new h$(h3("Attempting to play DRM-protected content without providing a DRM token."),h$.MEDIA_ERR_ENCRYPTED,e.fatal)).errorCategory="drm",n.muxCode=5000002):e.details===hN.ErrorDetails.KEY_SYSTEM_NO_ACCESS?((n=new h$(h3("Cannot play DRM-protected content with current security configuration on this browser. Try playing in another browser."),h$.MEDIA_ERR_ENCRYPTED,e.fatal)).errorCategory="drm",n.muxCode=5000001):e.details===hN.ErrorDetails.KEY_SYSTEM_NO_SESSION?((n=new h$(h3("Failed to generate a DRM license request. This may be an issue with the player or your protected content."),h$.MEDIA_ERR_ENCRYPTED,!0)).errorCategory="drm",n.muxCode=5000002):e.details===hN.ErrorDetails.KEY_SYSTEM_SESSION_UPDATE_FAILED?((n=new h$(h3("Failed to update DRM license. This may be an issue with the player or your protected content."),h$.MEDIA_ERR_ENCRYPTED,e.fatal)).errorCategory="drm",n.muxCode=5000003):e.details===hN.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED?((n=new h$(h3("Your server certificate failed when attempting to set it. This may be an issue with a no longer valid certificate."),h$.MEDIA_ERR_ENCRYPTED,e.fatal)).errorCategory="drm",n.muxCode=5000004):e.details===hN.ErrorDetails.KEY_SYSTEM_STATUS_INTERNAL_ERROR?((n=new h$(h3("The DRM Content Decryption Module system had an internal failure. Try reloading the page, upading your browser, or playing in another browser."),h$.MEDIA_ERR_ENCRYPTED,e.fatal)).errorCategory="drm",n.muxCode=5000005):e.details===hN.ErrorDetails.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED?((n=new h$(h3("DRM playback is being attempted in an environment that is not sufficiently secure. User may see black screen."),h$.MEDIA_ERR_ENCRYPTED,!1)).errorCategory="drm",n.muxCode=5000006):((n=new h$(e.error.message,h$.MEDIA_ERR_ENCRYPTED,e.fatal)).errorCategory="drm",n.muxCode=5e6):n=new h$("",l,e.fatal);return n.context||(n.context=`${e.url?`url: ${e.url}
33`:""}${e.response&&(e.response.code||e.response.text)?`response: ${e.response.code}, ${e.response.text}
34`:""}${e.reason?`failure reason: ${e.reason}
35`:""}${e.level?`level: ${e.level}
36`:""}${e.parent?`parent stream controller: ${e.parent}
37`:""}${e.buffer?`buffer length: ${e.buffer}
38`:""}${e.error?`error: ${e.error}
39`:""}${e.event?`event: ${e.event}
40`:""}${e.err?`error message: ${null==(s=e.err)?void 0:s.message}
41`:""}`),n.data=e,n},cu=(()=>{try{return"0.30.4"}catch{}return"UNKNOWN"})(),cc=tB.default.forwardRef((e,t)=>
41{var i,r;let{playbackId:s,src:a,children:n,autoPlay:l,preload:o,tokens:d,playbackToken:h,drmToken:u,...c}=e,f=Object.fromEntries(Object.entries(c).filter(([e])=>!Object.keys(cc.propTypes).includes(e))),[m]=(0,tB.useState)(null!=(i=e.playerInitTime)?i:(()=>{if("u">typeof window)return r9.utils.now()})()),[g,v]=(0,tB.useState)(null!=(r=uQ(e))?r:a),E=(0,tB.useRef)(void 0),y=((...e)=>{let t=(0,tB.useRef)(null);return(0,tB.useEffect)(()=>{e.forEach(e=>{e&&("function"==typeof e?e(t.current):e.current=t.current)})},[e]),t})((0,tB.useRef)(null),t);return(0,tB.useEffect)(()=>{var t;v(null!=(t=uQ(e))?t:a)},[a,s]),(0,tB.useEffect)(()=>{let t={playerInitTime:m,...e,src:g,playerSoftwareName:"mux-video-react",playerSoftwareVersion:cu,autoplay:l},i=y.current;return i&&(E.current=u2(t,i,E.current)),()=>{u3(i,E.current),i=void 0,E.current=void 0}},[g]),(0,tB.useEffect)(()=>{var e;null==(e=E.current)||e.setAutoplay(l)},[l]),(0,tB.useEffect)(()=>{var e;null==(e=E.current)||e.setPreload(o)},[o]),tB.default.createElement("video",{ref:y,...f},n)});cc.propTypes={_hlsConfig:tH.default.any,beaconCollectionDomain:tH.default.string,capRenditionToPlayerSize:tH.default.bool,customDomain:tH.default.string,debug:tH.default.bool,disableCookies:tH.default.bool,disableTracking:tH.default.bool,drmToken:tH.default.string,envKey:tH.default.string,errorTranslator:tH.default.func,liveEdgeStart:tH.default.number,maxResolution:tH.default.oneOf(["720p","1080p","1440p","2160p"]),metadata:tH.default.any,minResolution:tH.default.oneOf(["480p","540p","720p","1080p","1440p","2160p"]),playbackId:tH.default.string,playbackToken:tH.default.string,playerInitTime:tH.default.number,preferCmcd:tH.default.oneOf(Object.values(hK)),preferPlayback:tH.default.oneOf(Object.values(hV)),programStartTime:tH.default.number,programEndTime:tH.default.number,assetStartTime:tH.default.number,assetEndTime:tH.default.number,renditionOrder:tH.default.oneOf(["desc"]),startTime:tH.default.number,streamType:tH.default.oneOf(Object.values(hG)),targetLiveWindow:tH.default.number,tokens:tH.default.object,type:tH.default.oneOf(hj)};var cf=e.i(540796);let cm=(0,cf.default)("maximize",[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]),cp=(0,cf.default)("minimize",[["path",{d:"M8 3v3a2 2 0 0 1-2 2H3",key:"hohbtr"}],["path",{d:"M21 8h-3a2 2 0 0 1-2-2V3",key:"5jw1f3"}],["path",{d:"M3 16h3a2 2 0 0 1 2 2v3",key:"198tvr"}],["path",{d:"M16 21v-3a2 2 0 0 1 2-2h3",key:"ph8mxp"}]]),cg=(0,cf.default)("pause",[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1",key:"kaeet6"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1",key:"1wsw3u"}]]),cv=(0,cf.default)("play",[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]]),cE=(0,cf.default)("volume-2",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]]),cy=(0,cf.default)("volume-x",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["line",{x1:"22",x2:"16",y1:"9",y2:"15",key:"1ewh16"}],["line",{x1:"16",x2:"22",y1:"9",y2:"15",key:"5ykzw1"}]]),cb=new Set(["style","children","ref","key","suppressContentEditableWarning","suppressHydrationWarning","dangerouslySetInnerHTML"]),cT={className:"class",htmlFor:"for"};function c_(e){return e.toLowerCase()}function cA(e){return"boolean"==typeof e?e?"":void 0:"function"==typeof e?void 0:"object"!=typeof e||null===e?e:void 0}function cS({react:e,tagName:t,elementClass:i,events:r,displayName:s,defaultProps:a,toAttributeName:n=c_,toAttributeValue:l=cA}){let o=Number.parseInt(e.version)>=19,d=e.forwardRef((s,d)=>{let h=e.useRef(null),u=e.useRef(new Map),c={},f={},m={},g={};for(let[e,t]of Object.entries(s)){if(cb.has(e)){m[e]=t;continue}let r=n(cT[e]??e);if(i.prototype&&e in i.prototype&&!(e in(globalThis.HTMLElement?.prototype??{}))&&!i.observedAttributes?.some(e=>e===r)){g[e]=t;continue}if(e.startsWith("on")){c[e]=t;continue}let s=l(t);r&&null!=s&&(f[r]=String(s),o||(m[r]=s)),r&&o&&(s!==cA(t)?m[r]=s:m[r]=t)}if("u">typeof window){for(let t in c){let i=c[t],s=t.endsWith("Capture"),a=(r?.[t]??t.slice(2).toLowerCase()).slice(0,s?-7:void 0);e.useLayoutEffect(()=>{let e=h?.current;if(e&&"function"==typeof i)return e.addEventListener(a,i,s),()=>{e.removeEventListener(a,i,s)}},[h?.current,i])}e.useLayoutEffect(()=>{if(null===h.current)return;let e=new Map;for(let t in g)ck(h.current,t,g[t]),u.current.delete(t),e.set(t,g[t]);for(let[e,t]of u.current)ck(h.current,e,void 0);u.current=e})}if("u"<typeof window&&i?.getTemplateHTML&&i?.shadowRootOptions){let{mode:t,delegatesFocus:r}=i.shadowRootOptions;m.children=[e.createElement("template",{shadowrootmode:t,shadowrootdelegatesfocus:r,dangerouslySetInnerHTML:{__html:i.getTemplateHTML(f,s)},key:"ce-la-react-ssr-template-shadow-root"}),m.children]}return e.createElement(t,{...a,...m,ref:e.useCallback(e=>{h.current=e,"function"==typeof d?d(e):null!==d&&(d.current=e)},[d])},m.children)});return d.displayName=s??i.name,d}function ck(e,t,i){e[t]=i,null==i&&t in(globalThis.HTMLElement?.prototype??{})&&e.removeAttribute(t)}let cL={MEDIA_PLAY_REQUEST:"mediaplayrequest",MEDIA_PAUSE_REQUEST:"mediapauserequest",MEDIA_MUTE_REQUEST:"mediamuterequest",MEDIA_UNMUTE_REQUEST:"mediaunmuterequest",MEDIA_LOOP_REQUEST:"medialooprequest",MEDIA_VOLUME_REQUEST:"mediavolumerequest",MEDIA_SEEK_REQUEST:"mediaseekrequest",MEDIA_AIRPLAY_REQUEST:"mediaairplayrequest",MEDIA_ENTER_FULLSCREEN_REQUEST:"mediaenterfullscreenrequest",MEDIA_EXIT_FULLSCREEN_REQUEST:"mediaexitfullscreenrequest",MEDIA_PREVIEW_REQUEST:"mediapreviewrequest",MEDIA_ENTER_PIP_REQUEST:"mediaenterpiprequest",MEDIA_EXIT_PIP_REQUEST:"mediaexitpiprequest",MEDIA_ENTER_CAST_REQUEST:"mediaentercastrequest",MEDIA_EXIT_CAST_REQUEST:"mediaexitcastrequest",MEDIA_SHOW_TEXT_TRACKS_REQUEST:"mediash
41owtexttracksrequest",MEDIA_HIDE_TEXT_TRACKS_REQUEST:"mediahidetexttracksrequest",MEDIA_SHOW_SUBTITLES_REQUEST:"mediashowsubtitlesrequest",MEDIA_DISABLE_SUBTITLES_REQUEST:"mediadisablesubtitlesrequest",MEDIA_TOGGLE_SUBTITLES_REQUEST:"mediatogglesubtitlesrequest",MEDIA_PLAYBACK_RATE_REQUEST:"mediaplaybackraterequest",MEDIA_RENDITION_REQUEST:"mediarenditionrequest",MEDIA_AUDIO_TRACK_REQUEST:"mediaaudiotrackrequest",MEDIA_SEEK_TO_LIVE_REQUEST:"mediaseektoliverequest",REGISTER_MEDIA_STATE_RECEIVER:"registermediastatereceiver",UNREGISTER_MEDIA_STATE_RECEIVER:"unregistermediastatereceiver"},cR={MEDIA_CHROME_ATTRIBUTES:"mediachromeattributes",MEDIA_CONTROLLER:"mediacontroller"},cI={MEDIA_AIRPLAY_UNAVAILABLE:"mediaAirplayUnavailable",MEDIA_AUDIO_TRACK_ENABLED:"mediaAudioTrackEnabled",MEDIA_AUDIO_TRACK_LIST:"mediaAudioTrackList",MEDIA_AUDIO_TRACK_UNAVAILABLE:"mediaAudioTrackUnavailable",MEDIA_BUFFERED:"mediaBuffered",MEDIA_CAST_UNAVAILABLE:"mediaCastUnavailable",MEDIA_CHAPTERS_CUES:"mediaChaptersCues",MEDIA_CURRENT_TIME:"mediaCurrentTime",MEDIA_DURATION:"mediaDuration",MEDIA_ENDED:"mediaEnded",MEDIA_ERROR:"mediaError",MEDIA_ERROR_CODE:"mediaErrorCode",MEDIA_ERROR_MESSAGE:"mediaErrorMessage",MEDIA_FULLSCREEN_UNAVAILABLE:"mediaFullscreenUnavailable",MEDIA_HAS_P
41LAYED:"mediaHasPlayed",MEDIA_HEIGHT:"mediaHeight",MEDIA_IS_AIRPLAYING:"mediaIsAirplaying",MEDIA_IS_CASTING:"mediaIsCasting",MEDIA_IS_FULLSCREEN:"mediaIsFullscreen",MEDIA_IS_PIP:"mediaIsPip",MEDIA_LOADING:"mediaLoading",MEDIA_MUTED:"mediaMuted",MEDIA_LOOP:"mediaLoop",MEDIA_PAUSED:"mediaPaused",MEDIA_PIP_UNAVAILABLE:"mediaPipUnavailable",MEDIA_PLAYBACK_RATE:"mediaPlaybackRate",MEDIA_PREVIEW_CHAPTER:"mediaPreviewChapter",MEDIA_PREVIEW_COORDS:"mediaPreviewCoords",MEDIA_PREVIEW_IMAGE:"mediaPreviewImage",MEDIA_PREVIEW_TIME:"mediaPreviewTime",MEDIA_RENDITION_LIST:"mediaRenditionList",MEDIA_RENDITION_SELECTED:"mediaRenditionSelected",MEDIA_RENDITION_UNAVAILABLE:"mediaRenditionUnavailable",MEDIA_SEEKABLE:"mediaSeekable",MEDIA_STREAM_TYPE:"mediaStreamType",MEDIA_SUBTITLES_LIST:"mediaSubtitlesList",MEDIA_SUBTITLES_SHOWING:"mediaSubtitlesShowing",MEDIA_TARGET_LIVE_WINDOW:"mediaTargetLiveWindow",MEDIA_TIME_IS_LIVE:"mediaTimeIsLive",MEDIA_VOLUME:"mediaVolume",MEDIA_VOLUME_LEVEL:"mediaVolumeLevel",MEDIA_VOLUME_UNAVAILABLE:"mediaVolumeUnavailable",MEDIA_LANG:"mediaLang",MEDIA_WIDTH:"mediaWidth"},cw=Object.entries(cI),cD=cw.reduce((e,[t,i])=>(e[t]=i.toLowerCase(),e),{}),cC=cw.reduce((e,[t,i])=>(e[t]=i.toLowerCase(),e),{USER_INACTIVE_CHANGE:"userinactivechange",BREAKPOINTS_CHANGE:"breakpointchange",BREAKPOINTS_COMPUTED:"breakpointscomputed"}),cP=Object.entries(cC).reduce((e,[t,i])=>{let r=cD[t];return r&&(e[i]=r),e},{userinactivechange:"userinactive"}),cx=Object.entries(cD).reduce((e,[t,i])=>{let r=cC[t];return r&&(e[i]=r),e},{userinactive:"userinactivechange"}),cM={SUBTITLES:"subtitles",CAPTIONS:"captions",DESCRIPTIONS:"descriptions",CHAPTERS:"chapters",METADATA:"metadata"},cO={DISABLED:"disabled",HIDDEN:"hidden",SHOWING:"showing"},cN={MOUSE:"mouse",PEN:"pen",TOUCH:"touch"},cU={UNAVAILABLE:"unavailable",UNSUPPORTED:"unsupported"},cF={LIVE:"live",ON_DEMAND:"on-demand",UNKNOWN:"unknown"},c$={INLINE:"inline",FULLSCREEN:"fullscreen",PICTURE_IN_PICTURE:"picture-in-picture"};function cB(e){if(e){let{id:t,width:i,height:r}=e;return[t,i,r].filter(e=>null!=e).join(":")}}function cH(e){if(e){let{id:t,kind:i,language:r,label:s}=e;return[t,i,r,s].filter(e=>null!=e).join(":")}}function cG(e){return"number"==typeof e&&!Number.isNaN(e)&&Number.isFinite(e)}e.s(["AttributeToStateChangeEventMap",0,cx,"AvailabilityStates",0,cU,"MediaStateChangeEvents",0,cC,"MediaStateReceiverAttributes",0,cR,"MediaUIAttributes",0,cD,"MediaUIEvents",0,cL,"MediaUIProps",0,cI,"PointerTypes",0,cN,"ReadyStates",0,{HAVE_NOTHING:0,HAVE_METADATA:1,HAVE_CURRENT_DATA:2,HAVE_FUTURE_DATA:3,HAVE_ENOUGH_DATA:4},"StateChangeEventToAttributeMap",0,cP,"StreamTypes",0,cF,"TextTrackKinds",0,cM,"TextTrackModes",0,cO,"VolumeLevels",0,{HIGH:"high",MEDIUM:"medium",LOW:"low",OFF:"off"},"WebkitPresentationModes",0,c$],209048),e.i(209048);let cV=e=>new Promise(t=>setTimeout(t,e)),cK={en:{"Start airplay":"Start airplay","Stop airplay":"Stop airplay",Audio:"Audio",Captions:"Captions","Enable captions":"Enable captions","Disable captions":"Disable captions","Start casting":"Start casting","Stop casting":"Stop casting","Enter fullscreen mode":"Enter fullscreen mode","Exit fullscreen mode":"Exit fullscreen mode",Mute:"Mute",Unmute:"Unmute",Loop:"Loop","Enter picture in picture mode":"Enter picture in picture mode","Exit picture in picture mode":"Exit picture in picture mode",Play:"Play",Pause:"Pause","Playback rate":"Playback rate","Playback rate {playbackRate}":"Playback rate {playbackRate}",Quality:"Quality","Seek backward":"Seek backward","Seek forward":"Seek forward",Settings:"Settings",Auto:"Auto","audio player":"audio player","video player":"video player",volume:"volume",seek:"seek","closed captions":"closed captions","current playback rate":"current playback rate","playback time":"playback time","media loading":"media loading",settings:"settings","audio tracks":"audio tracks",quality:"quality",play:"play",pause:"pause",mute:"mute",unmute:"unmute","chapter: {chapterName}":"chapter: {chapterName}",live:"live",Off:"Off","start airplay":"start airplay","stop airplay":"stop airplay","start casting":"start casting","stop casting":"stop casting","enter fullscreen mode":"enter fullscreen mode","exit fullscreen mode":"exit fullscreen mode","enter picture in picture mode":"enter picture in picture mode","exit picture in picture mode":"exit picture in picture mode","seek to live":"seek to live","playing live":"playing live","seek back {seekOffset} seconds":"seek back {seekOffset} seconds","seek forward {seekOffset} seconds":"seek forward {seekOffset} seconds","Network Error":"Network Error","Decode Error":"Decode Error","S
41ource Not Supported":"Source Not Supported","Encryption Error":"Encryption Error","A network error caused the media download to fail.":"A network error caused the media download to fail.","A media error caused playback to be aborted. The media could be corrupt or your browser does not support this format.":"A media error caused playback to be aborted. The media could be corrupt or your browser does not support this format.","An unsupported error occurred. The server or network failed, or your browser does not support this format.":"An unsupported error occurred. The server or network failed, or your browser does not support this format.","The media is encrypted and there are no keys to decrypt it.":"The media is encrypted and there are no keys to decrypt it.",hour:"hour",hours:"hours",minute:"minute",minutes:"minutes",second:"second",seconds:"seconds","{time} remaining":"{time} remaining","{currentTime} of {totalTime}":"{currentTime} of {totalTime}","video not loaded, unknown time.":"video not loaded, unknown time."}},cW=(null==(s=globalThis.navigator)?void 0:s.language)||"en",cq=(e,t={})=>(e=>{var t,i,r;let[s]=cW.split("-");return(null==(t=cK[cW])?void 0:t[e])||(null==(i=cK[s])?void 0:i[e])||(null==(r=cK.en)?void 0:r[e])||e})(e).replace(/\{(\w+)\}/g,(e,i)=>i in t?String(t[i]):`{${i}}`),cj=[{singular:"hour",plural:"hours"},{singular:"minute",plural:"minutes"},{singular:"second",plural:"seconds"}],cY=e=>{if(!cG(e))return"";let t=Math.abs(e),i=t!==e,r=new Date(0,0,0,0,0,t,0),s=[r.getHours(),r.getMinutes(),r.getSeconds()].map((e,t)=>{let i;return e&&(i=1===e?cq(cj[t].singular):cq(cj[t].plural),`${e} ${i}`)}).filter(e=>e).join(", ");return i?cq("{time} remaining",{time:s}):s};function cQ(e,t){let i=!1;e<0&&(i=!0,e=0-e);let r=Math.floor((e=e<0?0:e)%60),s=Math.floor(e/60%60),a=Math.floor(e/3600),n=Math.floor(t/60%60),l=Math.floor(t/3600);return(isNaN(e)||e===1/0)&&(a=s=r="0"),s=(((a=a>0||l>0?a+":":"")||n>=10)&&s<10?"0"+s:s)+":",(i?"-":"")+a+s+(r=r<10?"0"+r:r)}let cz=Object.freeze({length:0,start(e){let t=e>>>0;if(t>=this.length)throw new DOMException(`Failed to execute 'start' on 'TimeRanges': The index provided (${t}) is greater than or equal to the maximum bound (${this.length}).`);return 0},end(e){let t=e>>>0;if(t>=this.length)throw new DOMException(`Failed to execute 'end' on 'TimeRanges': The index provided (${t}) is greater than or equal to the maximum bound (${this.length}).`);return 0}});e.s(["emptyTimeRanges",0,cz,"formatAsTimePhrase",0,cY,"formatTime",0,cQ,"serializeTimeRanges",0,function(e=cz){return Array.from(e).map((t,i)=>[Number(e.start(i).toFixed(3)),Number(e.end(i).toFixed(3))].join(":")).join(" ")}],212973),e.i(212973);class cX{addEventListener(){}removeEventListener(){}dispatchEvent(){return!0}}class cZ extends cX{}class cJ extends cZ{constructor(){super(...arguments),this.role=null}}let c0={createElement:function(){return new c1.HTMLElement},createElementNS:function(){return new c1.HTMLElement},addEventListener(){},removeEventListener(){},dispatchEvent:e=>!1},c1={ResizeObserver:class{observe(){}unobserve(){}disconnect(){}},document:c0,Node:cZ,Element:cJ,HTMLElement:class extends cJ{constructor(){super(...arguments),this.innerHTML=""}get content(){return new c1.DocumentFragment}},DocumentFragment:class extends cX{},customElements:{get:function(){},define:function(){},whenDefined:function(){}},localStorage:{getItem:e=>null,setItem(e,t){},removeItem(e){}},CustomEvent:function(){},getComputedStyle:function(){},navigator:{languages:[],get userAgent(){return""}},matchMedia:e=>({matches:!1,media:e}),DOMParser:class{parseFromString(e,t){return{body:{textContent:e}}}}},c2="global"in globalThis&&(null==globalThis?void 0:globalThis.global)===globalThis||"u"<typeof window||void 0===window.customElements,c3=Object.keys(c1).every(e=>e in globalThis),c4=c2&&!c3?c1:globalThis,c5=c2&&!c3?c0:globalThis.document,c8=new WeakMap,c6=e=>{let t=c8.get(e);return t||c8.set(e,t=new Set),t},c9=new c4.ResizeObserver(e=>{for(let t of e)for(let e of c6(t.target))e(t)});function c7(e,t){c6(e).add(t),c9.observe(e)}function fe(e,t){let i=c6(e);i.delete(t),i.size||c9.unobserve(e)}function ft(e){let t={};for(let i of e)t[i.name]=i.value;return t}let fi=(e,t,i=".value")=>{let r=e.querySelector(i);r&&(r.textContent=t)},fr=(e,t)=>{let i,r;return(i=`slot[name="${t}"]`,!(r=e.shadowRoot.querySelector(i))?[]:r.children)[0]},fs=(e,t)=>!!e&&!!t&&(null!=e&&!!e.contains(t)||fs(e,t.getRootNode().host)),fa=(e,t)=>{if(!e)return null;let i=e.closest(t);return i||fa(e.getRootNode().host,t)};function fn(e,{depth:t=3,checkOpacity:i=!0,checkVisibilityCSS:r=!0}={}){if(e.checkVisibility)return e.checkVisibility({checkOpacity:i,checkVisibilityCSS:r});let s=e;for(;s&&t>0;){let e=getComputedStyle(s);if(i&&"0"===e.opacity||r&&"hidden"===e.visibility||"none"===e.display)return!1;s=s.parentElement,t--}return!0}function fl(e,t){let i=function(e,t){var i,r;let s;for(s of null!=(i=e.querySelectorAll("style:not([media])"))?i:[]){let e;try{e=null==(r=s.sheet)?void 0:r.cssRules}catch{continue}for(let i of null!=e?e:[])if(t(i.selectorText))return i}}(e,e=>e===t);return i||fo(e,t)}function fo(e,t){var i,r;let s=null!=(i=e.querySelectorAll("style:not([media])"))?i:[],a=null==s?void 0:s[s.length-1];if(!(null==a?void 0:a.sheet))return console.warn("Media Chrome: No style sheet found on style tag of",e),{style:{setProperty:()=>{},removeProperty:()=>"",getPropertyValue:()=>""}};let n=null==a?void 0:a.sheet.insertRule(`${t}{}`,a.sheet.cssRules.length);return null==(r=a.sheet.cssRules)?void 0:r[n]}function fd(e,t,i=NaN){let r=e.getAttribute(t);return null!=r?+r:i}function fh(e,t,i){let r=+i;if(null==i||Number.isNaN(r)){e.hasAttribute(t)&&e.removeAttribute(t);return}fd(e,t,void 0)!==r&&e.setAttribute(t,`${r}`)}function fu(e,t){return e.hasAttribute(t)}function fc(e,t,i){if(null==i){e.hasAttribute(t)&&e.removeAttribute(t);return}fu(e,t)!=i&&e.toggleAttribute(t,i)}function ff(e,t,i=null){var r;return null!=(r=e.getAttribute(t))?r:i}function fm(e,t,i){if(null==i){e.hasAttribute(t)&&e.removeAttribute(t);return}let r=`${i}`;ff(e,t,void 0)!==r&&e.setAttribute(t,r)}var fp=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},fg=(e,t,i)=>(fp(e,t,"read from private field"),i?i.call(e):t.get(e)),fv=(e,t,i,r)=>(fp(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i);class fE extends c4.HTMLElement{constructor(){if(super(),((e,t,i)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,i)})(this,a,void 0),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);const e=ft(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e)}}static get observedAttributes(){return[cR.MEDIA_CONTROLLER,cD.MEDIA_PAUSED]}attributeChangedCallback(e,t,i){var r,s,n,l,o;e===cR.MEDIA_CONTROLLER&&(t&&(null==(s=null==(r=fg(this,a))?void 0:r.unassociateElement)||s.call(r,this),fv(this,a,null)),i&&this.isConnected&&(fv(this,a,null==(n=this.getRootNode())?void 0:n.getElementById(i)),null==(o=null==(l=fg(this,a))?void 0:l.associateElement)||o.call(l,this)))}connectedCallback(){var e,t,i,r;let s;this.tabIndex=-1,this.setAttribute("aria-hidden","true"),fv(this,a,(i=this,(s=i.getAttribute(cR.MEDIA_CONTROLLER))?null==(r=i.getRootNode())?void 0:r.getElementById(s):fa(i,"media-controller"))),this.getAttribute(cR.MEDIA_CONTROLLER)&&(null==(t=null==(e=fg(this,a))?void 0:e.associateElement)||t.call(e,this)),fg(this,a)&&(fg(this,a).addEventListener("pointerdown",this),fg(this,a).addEventListener("click",this),fg(this,a).hasAttribute("tabindex")||(fg(this,a).tabIndex=0))}disconnectedCallback(){var e,t,i,r;this.getAttribute(cR.MEDIA_CONTROLLER)&&(null==(t=null==(e=fg(this,a))?void 0:e.unassociateElement)||t.call(e,this)),null==(i=fg(this,a))||i.removeEventListener("pointerdown",this),null==(r=fg(this,a))||r.removeEventListener("click",this),fv(this,a,null)}handleEvent(e){var t;let i=null==(t=e.composedPath())?void 0:t[0];if(["video","media-controller"].includes(null==i?void 0:i.localName)){if("pointerdown"===e.type)this._pointerType=e.pointerType;else if("click"===e.type){let{clientX:t,clientY:i}=e,{left:r,top:s,width:a,height:n}=this.getBoundingClientRect(),l=t-r,o=i-s;if(l<0||o<0||l>a||o>n||0===a&&0===n)return;let d=this._pointerType||"mouse";if(this._pointerType=void 0,d===cN.TOUCH)return void this.handleTap(e);if(d===cN.MOUSE||d===cN.PEN)return void this.handleMouseClick(e)}}}get mediaPaused(){return fu(this,cD.MEDIA_PAUSED)}set mediaPaused(e){fc(this,cD.MEDIA_PAUSED,e)}handleTap(e){}handleMouseClick(e){let t=this.mediaPaused?cL.MEDIA_PLAY_REQUEST:cL.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new c4.CustomEvent(t,{composed:!0,bubbles:!0}))}}a=new WeakMap,fE.shadowRootOptions={mode:"open"},fE.getTemplateHTML=function(e){return`
42    <style>
43      :host {
44        display: var(--media-control-display, var(--media-gesture-receiver-display, inline-block));
45        box-sizing: border-box;
46      }
47    </style>
48  `},c4.customElements.get("media-gesture-receiver")||c4.customElements.define("media-gesture-receiver",fE);var fy=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},fb=(e,t,i)=>(fy(e,t,"read from private field"),i?i.call(e):t.get(e)),fT=(e,t,i)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,i)},f_=(e,t,i,r)=>(fy(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i),fA=(e,t,i)=>(fy(e,t,"access private method"),i);let fS="audio",fk="autohide",fL="breakpoints",fR="gesturesdisabled",fI="keyboardcontrol",fw="no
48autohide",fD="userinactive",fC="autohideovercontrols",fP=Object.values(cD);function fx(e,t){var i,r,s;if(!e.isConnected)return;let a=Object.fromEntries((null!=(i=e.getAttribute(fL))?i:"sm:384 md:576 lg:768 xl:960").split(/\s+/).map(e=>e.split(":"))),n=(r=a,s=t,Object.keys(r).filter(e=>s>=parseInt(r[e]))),l=!1;if(Object.keys(a).forEach(t=>{if(n.includes(t)){e.hasAttribute(`breakpoint${t}`)||(e.setAttribute(`breakpoint${t}`,""),l=!0);return}e.hasAttribute(`breakpoint${t}`)&&(e.removeAttribute(`breakpoint${t}`),l=!0)}),l){let t=new CustomEvent(cC.BREAKPOINTS_CHANGE,{detail:n});e.dispatchEvent(t)}e.breakpointsComputed||(e.breakpointsComputed=!0,e.dispatchEvent(new CustomEvent(cC.BREAKPOINTS_COMPUTED,{bubbles:!0,composed:!0})))}class fM extends c4.HTMLElement{constructor(){if(super(),fT(this,m),fT(this,v),fT(this,y),fT(this,T),fT(this,A),fT(this,n,void 0),fT(this,l,0),fT(this,o,null),fT(this,d,null),fT(this,h,void 0),this.breakpointsComputed=!1,fT(this,u,e=>{let t=this.media;for(let i of e)if("childList"===i.type){for(let e of i.removedNodes){if("media"!=e.slot||i.target!=this)continue;let r=i.previousSibling&&i.previousSibling.previousElementSibling;if(r&&t){let t="media"!==r.slot;for(;null!==(r=r.previousSibling);)"media"==r.slot&&(t=!1);t&&this.mediaUnsetCallback(e)}else this.mediaUnsetCallback(e)}if(t)for(let e of i.addedNodes)e===t&&this.handleMediaUpdated(t)}}),fT(this,c,!1),fT(this,f,e=>{fb(this,c)||(setTimeout(()=>{fx(e.target,e.contentRect.width),f_(this,c,!1)},0),f_(this,c,!0))}),fT(this,k,void 0),fT(this,L,()=>{if(!fb(this,k).assignedElements({flatten:!0}).length){fb(this,o)&&this.mediaUnsetCallback(fb(this,o));return}this.handleMediaUpdated(this.media)}),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);const e=ft(this.attributes),t=this.constructor.getTemplateHTML(e);this.shadowRoot.setHTMLUnsafe?this.shadowRoot.setHTMLUnsafe(t):this.shadowRoot.innerHTML=t}f_(this,n,new MutationObserver(fb(this,u)))}static get observedAttributes(){return[fk,fR].concat(fP).filter(e=>![cD.MEDIA_RENDITION_LIST,cD.MEDIA_AUDIO_TRACK_LIST,cD.MEDIA_CHAPTERS_CUES,cD.MEDIA_WIDTH,cD.MEDIA_HEIGHT,cD.MEDIA_ERROR,cD.MEDIA_ERROR_MESSAGE].includes(e))}attributeChangedCallback(e,t,i){e.toLowerCase()==fk&&(this.autohide=i)}get media(){let e=this.querySelector(":scope > [slot=media]");return(null==e?void 0:e.nodeName)=="SLOT"&&(e=e.assignedElements({flatten:!0})[0]),e}async handleMediaUpdated(e){e&&(f_(this,o,e),e.localName.includes("-")&&await c4.customElements.whenDefined(e.localName),this.mediaSetCallback(e))}connectedCallback(){var e;fb(this,n).observe(this,{childList:!0,subtree:!0}),c7(this,fb(this,f));let t=null!=this.getAttribute(fS)?cq("audio player"):cq("video player");this.setAttribute("role","region"),this.setAttribute("aria-label",t),this.handleMediaUpdated(this.media),this.setAttribute(fD,""),fx(this,this.getBoundingClientRect().width);let i=this.querySelector(":scope > slot[slot=media]");i&&(f_(this,k,i),fb(this,k).addEventListener("slotchange",fb(this,L))),this.addEventListener("pointerdown",this),this.addEventListener("pointermove",this),this.addEventListener("pointerup",this),this.addEventListener("mouseleave",this),this.addEventListener("keyup",this),null==(e=c4.window)||e.addEventListener("mouseup",this)}disconnectedCallback(){var e;fe(this,fb(this,f)),clearTimeout(fb(this,d)),fb(this,n).disconnect(),this.media&&this.mediaUnsetCallback(this.media),null==(e=c4.window)||e.removeEventListener("mouseup",this),this.removeEventListener("pointerdown",this),this.removeEventListener("pointermove",this),this.removeEventListener("pointerup",this),this.removeEventListener("mouseleave",this),this.removeEventListener("keyup",this),fb(this,k)&&(fb(this,k).removeEventListener("slotchange",fb(this,L)),f_(this,k,null)),f_(this,c,!1)}mediaSetCallback(e){}mediaUnsetCallback(e){f_(this,o,null)}handleEvent(e){switch(e.type){case"pointerdown":f_(this,l,e.timeStamp);break;case"pointermove":fA(this,m,g).call(this,e);break;case"pointerup":fA(this,v,E).call(this,e);break;case"mouseleave":fA(this,y,b).call(this);break;case"mouseup":this.removeAttribute(fI);break;case"keyup":fA(this,A,S).call(this),this.setAttribute(fI,"")}}set autohide(e){let t=Number(e);f_(this,h,isNaN(t)?0:t)}get autohide(){return(void 0===fb(this,h)?2:fb(this,h)).toString()}get breakpoints(){return ff(this,fL)}set breakpoints(e){fm(this,fL,e)}get audio(){return fu(this,fS)}set audio(e){fc(this,fS,e)}get gesturesDisabled(){return fu(this,fR)}set gesturesDisabled(e){fc(this,fR,e)}get keyboardControl(){return fu(this,fI)}set keyboardControl(e){fc(this,fI,e)}get noAutohide(){return fu(this,fw)}set noAutohide(e){fc(this,fw,e)}get autohideOverControls(){return fu(this,fC)}set autohideOverControls(e){fc(this,fC,e)}get userInteractive(){return fu(this,fD)}set userInteractive(e){fc(this,fD,e)}}n=new WeakMap,l=new WeakMap,o=new WeakMap,d=new WeakMap,h=new WeakMap,u=new WeakMap,c=new WeakMap,f=new WeakMap,m=new WeakSet,g=function(e){if("mouse"!==e.pointerType&&e.timeStamp-fb(this,l)<250)return;fA(this,T,_).call(this),clearTimeout(fb(this,d));let t=this.hasAttribute(fC);([this,this.media].includes(e.target)||t)&&fA(this,A,S).call(this)},v=new WeakSet,E=function(e){if("touch"===e.pointerType){let t=!this.hasAttribute(fD);[this,this.media].includes(e.target)&&t?fA(this,y,b).call(this):fA(this,A,S).call(this)}else e.composedPath().some(e=>["media-play-button","media-fullscreen-button"].includes(null==e?void 0:e.localName))&&fA(this,A,S).call(this)},y=new WeakSet,b=function(){if(0>fb(this,h)||this.hasAttribute(fD))return;this.setAttribute(fD,"");let e=new c4.CustomEvent(cC.USER_INACTIVE_CHANGE,{composed:!0,bubbles:!0,detail:!0});this.dispatchEvent(e)},T=new WeakSet,_=function(){if(!this.hasAttribute(fD))return;this.removeAttribute(fD);let e=new c4.CustomEvent(cC.USER_INACTIVE_CHANGE,{composed:!0,bubbles:!0,detail:!1});this.dispatchEvent(e)},A=new WeakSet,S=function(){fA(this,T,_).call(this),clearTimeout(fb(this,d));let e=parseInt(this.autohide);e<0||f_(this,d,setTimeout(()=>{fA(this,y,b).call(this)},1e3*e))},k=new WeakMap,L=new WeakMap,fM.shadowRootOptions={mode:"open"},fM.getTemplateHTML=function(e){return`
49    <style>
50      
51      :host([${cD.MEDIA_IS_FULLSCREEN}]) ::slotted([slot=media]) {
52        outline: none;
53      }
54
55      :host {
56        box-sizing: border-box;
57        position: relative;
58        display: inline-block;
59        line-height: 0;
60        background-color: var(--media-background-color, #000);
61        overflow: hidden;
62      }
63
64      :host(:not([${fS}])) [part~=layer]:not([part~=media-layer]) {
65        position: absolute;
66        top: 0;
67        left: 0;
68        bottom: 0;
69        right: 0;
70        display: flex;
71        flex-flow: column nowrap;
72        align-items: start;
73        pointer-events: none;
74        background: none;
75      }
76
77      slot[name=media] {
78        display: var(--media-slot-display, contents);
79      }
80
81      
82      :host([${fS}]) slot[name=media] {
83        display: var(--media-slot-display, none);
84      }
85
86      
87      :host([${fS}]) [part~=layer][part~=gesture-layer] {
88        height: 0;
89        display: block;
90      }
91
92      
93      :host(:not([${fS}])[${fR}]) ::slotted([slot=gestures-chrome]),
94          :host(:not([${fS}])[${fR}]) media-gesture-receiver[slot=gestures-chrome] {
95        display: none;
96      }
97
98      
99      ::slotted(:not([slot=media]):not([slot=poster]):not(media-loading-indicator):not([role=dialog]):not([hidden])) {
100        pointer-events: auto;
101      }
102
103      :host(:not([${fS}])) *[part~=layer][part~=centered-layer] {
104        align-items: center;
105        justify-content: center;
106      }
107
108      :host(:not([${fS}])) ::slotted(media-gesture-receiver[slot=gestures-chrome]),
109      :host(:not([${fS}])) media-gesture-receiver[slot=gestures-chrome] {
110        align-self: stretch;
111        flex-grow: 1;
112      }
113
114      slot[name=middle-chrome] {
115        display: inline;
116        flex-grow: 1;
117        pointer-events: none;
118        background: none;
119      }
120
121      
122      ::slotted([slot=media]),
123      ::slotted([slot=poster]) {
124        width: 100%;
125        height: 100%;
126      }
127
128      
129      :host(:not([${fS}])) .spacer {
130        flex-grow: 1;
131      }
132
133      
134      :host(:-webkit-full-screen) {
135        
136        width: 100% !important;
137        height: 100% !important;
138      }
139
140      
141      ::slotted(:not([slot=media]):not([slot=poster]):not([${fw}]):not([hidden]):not([role=dialog])) {
142        opacity: 1;
143        transition: var(--media-control-transition-in, opacity 0.25s);
144      }
145
146      
147      :host([${fD}]:not([${cD.MEDIA_PAUSED}]):not([${cD.MEDIA_IS_AIRPLAYING}
147]):not([${cD.MEDIA_IS_CASTING}]):not([${fS}])) ::slotted(:not([slot=media]):not([slot=poster]):not([${fw}]):not([role=dialog])) {
148        opacity: 0;
149        transition: var(--media-control-transition-out, opacity 1s);
150      }
151
152      :host([${fD}]:not([${fw}]):not([${cD.MEDIA_PAUSED}]):not([${cD.MEDIA_IS_CASTING}]):not([${fS}])) ::slotted([slot=media]) {
153        cursor: none;
154      }
155
156      :host([${fD}][${fC}]:not([${fw}]):not([${cD.MEDIA_PAUSED}]):not([${cD.MEDIA_IS_CASTING}]):not([${fS}])) * {
157        --media-cursor: none;
158        cursor: none;
159      }
160
161
162      ::slotted(media-control-bar)  {
163        align-self: stretch;
164      }
165
166      
167      :host(:not([${fS}])[${cD.MEDIA_HAS_PLAYED}]) slot[name=poster] {
168        display: none;
169      }
170
171      ::slotted([role=dialog]) {
172        width: 100%;
173        height: 100%;
174        align-self: center;
175      }
176
177      ::slotted([role=menu]) {
178        align-self: end;
179      }
180    </style>
181
182    <slot name="media" part="layer media-layer"></slot>
183    <slot name="poster" part="layer poster-layer"></slot>
184    <slot name="gestures-chrome" part="layer gesture-layer">
185      <media-gesture-receiver slot="gestures-chrome">
186        <template shadowrootmode="${fE.shadowRootOptions.mode}">
187          ${fE.getTemplateHTML({})}
188        </template>
189      </media-gesture-receiver>
190    </slot>
191    <span part="layer vertical-layer">
192      <slot name="top-chrome" part="top chrome"></slot>
193      <slot name="middle-chrome" part="middle chrome"></slot>
194      <slot name="centered-chrome" part="layer centered-layer center centered chrome"></slot>
195      
196      <slot part="bottom chrome"></slot>
197    </span>
198    <slot name="dialog" part="layer dialog-layer"></slot>
199  `},c4.customElements.get("media-container")||c4.customElements.define("media-container",fM);var fO=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},fN=(e,t,i)=>(fO(e,t,"read from private field"),i?i.call(e):t.get(e)),fU=(e,t,i)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,i)},fF=(e,t,i,r)=>(fO(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i);class f${constructor(e,t,{defaultValue:i}={defaultValue:void 0}){fU(this,C),fU(this,R,void 0),fU(this,I,void 0),fU(this,w,void 0),fU(this,D,new Set),fF(this,R,e),fF(this,I,t),fF(this,w,new Set(i))}[Symbol.iterator](){return fN(this,C,P).values()}get length(){return fN(this,C,P).size}get value(){var e;return null!=(e=[...fN(this,C,P)].join(" "))?e:""}set value(e){var t;e!==this.value&&(fF(this,D,new Set),this.add(...null!=(t=null==e?void 0:e.split(" "))?t:[]))}toString(){return this.value}item(e){return[...fN(this,C,P)][e]}values(){return fN(this,C,P).values()}forEach(e,t){fN(this,C,P).forEach(e,t)}add(...e){var t,i;e.forEach(e=>fN(this,D).add(e)),(""!==this.value||(null==(t=fN(this,R))?void 0:t.hasAttribute(`${fN(this,I)}`)))&&(null==(i=fN(this,R))||i.setAttribute(`${fN(this,I)}`,`${this.value}`))}remove(...e){var t;e.forEach(e=>fN(this,D).delete(e)),null==(t=fN(this,R))||t.setAttribute(`${fN(this,I)}`,`${this.value}`)}contains(e){return fN(this,C,P).has(e)}toggle(e,t){if(void 0!==t)if(t)return this.add(e),!0;else return this.remove(e),!1;return this.contains(e)?(this.remove(e),!1):(this.add(e),!0)}replace(e,t){return this.remove(e),this.add(t),e===t}}R=new WeakMap,I=new WeakMap,w=new WeakMap,D=new WeakMap,C=new WeakSet,P=function(){return fN(this,D).size?fN(this,D):fN(this,w)};let fB=(e="")=>{let[t,i,r]=e.split(":"),s=r?decodeURIComponent(r):void 0;return{kind:"cc"===t?cM.CAPTIONS:cM.SUBTITLES,language:i,label:s}},fH=(e="",t={})=>((e="")=>e.split(/\s+/))(e).map(e=>{let i=fB(e);return{...t,...i}}),fG=e=>e?Array.isArray(e)?e.map(e=>"string"==typeof e?fB(e):e):"string"==typeof e?fH(e):[e]:[],fV=({kind:e,label:t,language:i}={kind:"subtitles"})=>t?`${"captions"===e?"cc":"sb"}:${i}:${encodeURIComponent(t)}`:i,fK=(e=[])=>Array.prototype.map.call(e,fV).join(" "),fW=e=>{let t=Object.entries(e).map(([e,t])=>i=>i[e]===t);return e=>t.every(t=>t(e))},fq=(e,t=[],i=[])=>{let r=fG(i).map(fW);Array.from(t).filter(e=>r.some(t=>
199t(e))).forEach(t=>{t.mode=e})},fj=(e,t=()=>!0)=>{if(!(null==e?void 0:e.textTracks))return[];let i="function"==typeof t?t:fW(t);return Array.from(e.textTracks).filter(i)},fY="exitFullscreen"in c5?"exitFullscreen":"webkitExitFullscreen"in c5?"webkitExitFullscreen":"webkitCancelFullScreen"in c5?"webkitCancelFullScreen":void 0,fQ="fullscreenElement"in c5?"fullscreenElement":"webkitFullscreenElement"in c5?"webkitFullscreenElement":void 0,fz="fullscreenEnabled"in c5?"fullscreenEnabled":"webkitFullscreenEnabled"in c5?"webkitFullscreenEnabled":void 0,fX=()=>{var e;return i||(i=null==(e=null==c5?void 0:c5.createElement)?void 0:e.call(c5,"video"))},fZ=async(e=fX())=>{if(!e)return!1;let t=e.volume;e.volume=t/2+.1;let i=new AbortController,r=await Promise.race([fJ(e,i.signal),f0(e,t)]);return i.abort(),r},fJ=(e,t)=>new Promise(i=>{e.addEventListener("volumechange",()=>i(!0),{signal:t})}),f0=async(e,t)=>{for(let i=0;i<10;i++){if(e.volume===t)return!1;await cV(10)}return e.volume!==t},f1=/.*Version\/.*Safari\/.*/.test(c4.navigator.userAgent),f2=(e=fX())=>(!c4.matchMedia("(display-mode: standalone)").matches||!f1)&&"function"==typeof(null==e?void 0:e.requestPictureInPicture),f3=(e=fX())=>(e=>{let{documentElement:t,media:i}=e;return!!(null==t?void 0:t[fz])||i&&"webkitSupportsFullscreen"in i})({documentElement:c5,media:e}),f4=f3(),f5=f2(),f8=!!c4.WebKitPlaybackTargetAvailabilityEvent,f6=!!c4.chrome,f9=e=>fj(e.media,e=>[cM.SUBTITLES,cM.CAPTIONS].includes(e.kind)).sort((e,t)=>e.kind>=t.kind?1:-1),f7=e=>fj(e.media,e=>e.mode===cO.SHOWING&&[cM.SUBTITLES,cM.CAPTIONS].includes(e.kind)),me=(e,t)=>
199{let i=f9(e),r=f7(e),s=!!r.length;if(i.length){if(!1===t||s&&!0!==t)fq(cO.DISABLED,i,r);else if(!0===t||!s&&!1!==t){let t=i[0],{options:s}=e;if(!(null==s?void 0:s.noSubtitlesLangPref)){let e=c4.localStorage.getItem("media-chrome-pref-subtitles-lang"),r=e?[e,...c4.navigator.languages]:c4.navigator.languages,s=i.filter(e=>r.some(t=>e.language.toLowerCase().startsWith(t.split("-")[0]))).sort((e,t)=>r.findIndex(t=>e.language.toLowerCase().startsWith(t.split("-")[0]))-r.findIndex(e=>t.language.toLowerCase().startsWith(e.split("-")[0])));s[0]&&(t=s[0])}let{language:a,label:n,kind:l}=t;fq(cO.DISABLED,i,r),fq(cO.SHOWING,i,[{language:a,label:n,kind:l}])}}},mt=(e,t)=>e===t||null!=e&&null!=t&&typeof e==typeof t&&(!!("number"==typeof e&&Number.isNaN(e)&&Number.isNaN(t))||"object"==typeof e&&(Array.isArray(e)?mi(e,t):Object.entries(e).every(([e,i])=>e in t&&mt(i,t[e])))),mi=(e,t)=>{let i=Array.isArray(e),r=Array.isArray(t);return i===r&&(!i&&!r||e.length===t.length&&e.every((e,i)=>mt(e,t[i])))},mr=Object.values(cF),ms=fZ().then(e=>r=e),ma=async(...e)=>{await Promise.all(e.filter(e=>e).map(async e=>{if(!("localName"in e&&e instanceof c4.HTMLElement))return;let t=e.localName;if(!t.includes("-"))return;let i=c4.customElements.get(t);i&&e instanceof i||(await c4.customElements.whenDefined(t),c4.customElements.upgrade(e))}))},mn=new c4.DOMParser,ml={mediaError:{get(e,t){let{media:i}=e;if((null==t?void 0:t.type)!=="playing")return null==i?void 0:i.error},mediaEvents:["emptied","error","playing"]},mediaErrorCode:{get(e,t){var i;let{media:r}=e;if((null==t?void 0:t.type)!=="playing")return null==(i=null==r?void 0:r.error)?void 0:i.code},mediaEvents:["emptied","error","playing"]},mediaErrorMessage:{get(e,t){var i,r;let{media:s}=e;if((null==t?void 0:t.type)!=="playing")return null!=(r=null==(i=null==s?void 0:s.error)?void 0:i.message)?r:""},mediaEvents:["emptied","error","playing"]},mediaWidth:{get(e){var t;let{media:i}=e;return null!=(t=null==i?void 0:i.videoWidth)?t:0},mediaEvents:["resize"]},mediaHeight:{get(e){var t;let{media:i}=e;return null!=(t=null==i?void 0:i.videoHeight)?t:0},mediaEvents:["resize"]},mediaPaused:{get(e){var t;let{media:i}=e;return null==(t=null==i?void 0:i.paused)||t},set(e,t){var i;let{media:r}=t;r&&(e?r.pause():null==(i=r.play())||i.catch(()=>{}))},mediaEvents:["play","playing","pause","emptied"]},mediaHasPlayed:{get(e,t){let{media:i}=e;return!!i&&(t?"playing"===t.type:!i.paused)},mediaEvents:["playing","emptied"]},mediaEnded:{get(e){var t;let{media:i}=e;return null!=(t=null==i?void 0:i.ended)&&t},mediaEvents:["seeked","ended","emptied"]},mediaPlaybackRate:{get(e){var t;let{media:i}=e;return null!=(t=null==i?void 0:i.playbackRate)?t:1},set(e,t){let{media:i}=t;!i||Number.isFinite(+e)&&(i.playbackRate=+e)},mediaEvents:["ratechange","loadstart"]},mediaMuted:{get(e){var t;let{media:i}=e;return null!=(t=null==i?void 0:i.muted)&&t},set(e,t){let{media:i,options:{noMutedPref:r}={}}=t;if(i){i.muted=e;try{let t=null!==c4.localStorage.getItem("media-chrome-pref-muted"),s=i.hasAttribute("muted");if(r){t&&c4.localStorage.removeItem("media-chrome-pref-muted");return}if(s&&!t)return;c4.localStorage.setItem("media-chrome-pref-muted",e?"true":"false")}catch(e){console.debug("Error setting muted pref",e)}}},mediaEvents:["volumechange"],stateOwnersUpdateHandlers:[(e,t)=>{let{options:{noMutedPref:i}}=t,{media:r}=t;if(r&&!r.muted&&!i)try{let i="true"===c4.localStorage.getItem("media-chrome-pref-muted");ml.mediaMuted.set(i,t),e(i)}catch(e){console.debug("Error getting muted pref",e)}}]},mediaLoop:{get(e){let{media:t}=e;return null==t?void 0:t.loop},set(e,t){let{media:i}=t;i&&(i.loop=e)},mediaEvents:["medialooprequest"]},mediaVolume:{get(e){var t;let{media:i}=e;return null!=(t=null==i?void 0:i.volume)?t:1},set(e,t){let{media:i,options:{noVolumePref:r}={}}=t;if(i){try{null==e?c4.localStorage.removeItem("media-chrome-pref-volume"):i.hasAttribute("muted")||r||c4.localStorage.setItem("media-chrome-pref-volume",e.toString())}catch(e){console.debug("Error setting volume pref",e)}Number.isFinite(+e)&&(i.volume=+e)}},mediaEvents:["volumechange"],stateOwnersUpdateHandlers:[(e,t)=>{let{options:{noVolumePref:i}}=t;if(!i)try{let{media:i}=t;if(!i)return;let r=c4.localStorage.getItem("media-chrome-pref-volume");if(null==r)return;ml.mediaVolume.set(+r,t),e(+r)}catch(e){console.debug("Error getting volume pref",e)}}]},mediaVolumeLevel:{get(e){let{media:t}=e;return void 0===(null==t?void 0:t.volume)?"high":t.muted||0===t.volume?"off":t.volume<.5?"low":t.volume<.75?"medium":"high"},mediaEvents:["volumechange"]},mediaCurrentTime:{get(e){var t;let{media:i}=e;return null!=(t=null==i?void 0:i.currentTime)?t:0},set(e,t){let{media:i}=t;i&&cG(e)&&(i.currentTime=e)},mediaEvents:["timeupdate","loadedmetadata"]},mediaDuration:{get(e){let{media:t,options:{defaultDuration:i}={}}=e;return i&&(!t||!t.duration||Number.isNaN(t.duration)||!Number.isFinite(t.duration))?i:Number.isFinite(null==t?void 0:t.duration)?t.duration:NaN},mediaEvents:["durationchange","loadedmetadata","emptied"]},mediaLoading:{get(e){let{media:t}=e;return(null==t?void 0:t.readyState)<3},mediaEvents:["waiting","playing","emptied"]},mediaSeekable:{get(e){var t;let{media:i}=e;if(!(null==(t=null==i?void 0:i.seekable)?void 0:t.length))return;let r=i.seekable.start(0),s=i.seekable.end(i.seekable.length-1);if(r||s)return[Number(r.toFixed(3)),Number(s.toFixed(3))]},mediaEvents:["loadedmetadata","emptied","progress","seekablechange"]},mediaBuffered:{get(e){var t;let{media:i}=e,r=null!=(t=null==i?void 0:i.buffered)?t:[];return Array.from(r).map((e,t)=>[Number(r.start(t).toFixed(3)),Number(r.end(t).toFixed(3))])},mediaEvents:["progress","emptied"]},mediaStreamType:{get(e){let{media:t,options:{defaultStreamType:i}={}}
199=e,r=[cF.LIVE,cF.ON_DEMAND].includes(i)?i:void 0;if(!t)return r;let{streamType:s}=t;if(mr.includes(s))return s===cF.UNKNOWN?r:s;let a=t.duration;return a===1/0?cF.LIVE:Number.isFinite(a)?cF.ON_DEMAND:r},mediaEvents:["emptied","durationchange","loadedmetadata","streamtypechange"]},mediaTargetLiveWindow:{get(e){let{media:t}=e;if(!t)return NaN;let{targetLiveWindow:i}=t,r=ml.mediaStreamType.get(e);return(null==i||Number.isNaN(i))&&r===cF.LIVE?0:i},mediaEvents:["emptied","durationchange","loadedmetadata","streamtypechange","targetlivewindowchange"]},mediaTimeIsLive:{get(e){let{media:t,options:{liveEdgeOffset:i=10}={}}=e;if(!t)return!1;if("number"==typeof t.liveEdgeStart)return!Number.isNaN(t.liveEdgeStart)&&t.currentTime>=t.liveEdgeStart;if(ml.mediaStreamType.get(e)!==cF.LIVE)return!1;let r=t.seekable;if(!r)return!0;if(!r.length)return!1;let s=r.end(r.length-1)-i;return t.currentTime>=s},mediaEvents:["playing","timeupdate","progress","waiting","emptied"]},mediaSubtitlesList:{get:e=>f9(e).map(({kind:e,label:t,language:i})=>({kind:e,label:t,language:i})),mediaEvents:["loadstart"],textTracksEvents:["addtrack","removetrack"]},mediaSubtitlesShowing:{get:e=>f7(e).map(({kind:e,label:t,language:i})=>({kind:e,label:t,language:i})),mediaEvents:["loadstart"],textTracksEvents:["addtrack","removetrack","change"],stateOwnersUpdateHandlers:[(e,t)=>{var i,r;let{media:s,options:a}=t;if(!s)return;let n=e=>{var i;a.defaultSubtitles&&(e&&![cM.CAPTIONS,cM.SUBTITLES].includes(null==(i=null==e?void 0:e.track)?void 0:i.kind)||me(t,!0))};return s.addEventListener("loadstart",n),null==(i=s.textTracks)||i.addEventListener("addtrack",n),null==(r=s.textTracks)||r.addEventListener("removetrack",n),()=>{var e,t;s.removeEventListener("loadstart",n),null==(e=s.textTracks)||e.removeEventListener("addtrack",n),null==(t=s.textTracks)||t.removeEventListener("removetrack",n)}}]},mediaChaptersCues:{get(e){var t;let{media:i}=e;if(!i)return[];let[r]=fj(i,{kind:cM.CHAPTERS});return Array.from(null!=(t=null==r?void 0:r.cues)?t:[]).map(({text:e,startTime:t,endTime:i})=>({text:e&&mn.parseFromString(e,"text/html").body.textContent||e,startTime:t,endTime:i}))},mediaEvents:["loadstart","loadedmetadata"],textTracksEvents:["addtrack","removetrack","change"],stateOwnersUpdateHandlers:[(e,t)=>{var i;let{media:r}=t;if(!r)return;let s=r.querySelector('track[kind="chapters"][default][src]'),a=null==(i=r.shadowRoot)?void 0:i.querySelector(':is(video,audio) > track[kind="chapters"][default][src]');return null==s||s.addEventListener("load",e),null==a||a.addEventListener("load",e),()=>{null==s||s.removeEventListener("load",e),null==a||a.removeEventListener("load",e)}}]},mediaIsPip:{get(e){var t,i;let{media:r,documentElement:s}=e;if(!r||!s||!s.pictureInPictureElement)return!1;if(s.pictureInPictureElement===r)return!0;if(s.pictureInPictureElement instanceof HTMLMediaElement)return!!(null==(t=r.localName)?void 0:t.includes("-"))&&fs(r,s.pictureInPictureElement);if(s.pictureInPictureElement.localName.includes("-")){let e=s.pictureInPictureElement.shadowRoot;for(;null==e?void 0:e.pictureInPictureElement;){if(e.pictureInPictureElement===r)return!0;e=null==(i=e.pictureInPictureElement)?void 0:i.shadowRoot}}return!1},set(e,t){let{media:i}=t;if(i)if(e){if(!c5.pictureInPictureEnabled)return void console.warn("MediaChrome: Picture-in-picture is not enabled");if(!i.requestPictureInPicture)return void console.warn("MediaChrome: The current media does not support picture-in-picture");let e=()=>{console.warn("MediaChrome: The media is not ready for picture-in-picture. It must have a readyState > 0.")};i.requestPictureInPicture().catch(t=>{if(11===t.code){if(!i.src)return void console.warn("MediaChrome: The media is not ready for picture-in-picture. It must have a src set.");if(0===i.readyState&&"none"===i.preload){let t=()=>{i.removeEventListener("loadedmetadata",r),i.preload="none"},r=()=>{i.requestPictureInPicture().catch(e),t()};i.addEventListener("loadedmetadata",r),i.preload="metadata",setTimeout(()=>{0===i.readyState&&e(),t()},1e3)}else throw t}else throw t})}else c5.pictureInPictureElement&&c5.exitPictureInPicture()},mediaEvents:["enterpictureinpicture","leavepictureinpicture"]},mediaRenditionList:{get(e){var t;let{media:i}=e;return[...null!=(t=null==i?void 0:i.videoRenditions)?t:[]].map(e=>({...e}))},mediaEvents:["emptied","loadstart"],videoRenditionsEvents:["addrendition","removerendition"]},mediaRenditionSelected:{get(e){var t,i,r;let{media:s}=e;return null==(r=null==(i=null==s?void 0:s.videoRenditions)?void 0:i[null==(t=s.videoRenditions)?void 0:t.selectedIndex])?void 0:r.id},set(e,t){let{media:i}=t;if(!(null==i?void 0:i.videoRenditions))return void console.warn("MediaController: Rendition selection not supported by this media.");let r=Array.prototype.findIndex.call(i.videoRenditions,t=>t.id==e);i.videoRenditions.selectedIndex!=r&&(i.videoRenditions.selectedIndex=r)},mediaEvents:["emptied"],videoRenditionsEvents:["addrendition","removerendition","change"]},mediaAudioTrackList:{get(e){var t;let{media:i}=e;return[...null!=(t=null==i?void 0:i.audioTracks)?t:[]]},mediaEvents:["emptied","loadstart"],audioTracksEvents:["addtrack","removetrack"]},mediaAudioTrackEnabled:{get(e){var t,i;let{media:r}=e;return null==(i=[...null!=(t=null==r?void 0:r.audioTracks)?t:[]].find(e=>e.enabled))?void 0:i.id},set(e,t){let{media:i}=t;if(!(null==i?void 0:i.audioTracks))return void console.warn("MediaChrome: Audio track selection not supported by this media.");
199for(let t of i.audioTracks)t.enabled=e==t.id},mediaEvents:["emptied"],audioTracksEvents:["addtrack","removetrack","change"]},mediaIsFullscreen:{get:e=>(e=>{var t;let{media:i,documentElement:r,fullscreenElement:s=i}=e;if(!i||!r)return!1;let a=(e=>{let{documentElement:t,media:i}=e,r=null==t?void 0:t[fQ];return!r&&"webkitDisplayingFullscreen"in i&&"webkitPresentationMode"in i&&i.webkitDisplayingFullscreen&&i.webkitPresentationMode===c$.FULLSCREEN?i:r})(e);if(!a)return!1;if(a===s||a===i)return!0;if(a.localName.includes("-")){let e=a.shadowRoot;if(!(fQ in e))return fs(a,s);for(;null==e?void 0:e[fQ];){if(e[fQ]===s)return!0;e=null==(t=e[fQ])?void 0:t.shadowRoot}}return!1})(e),set(e,t,i){var r,s;e?((e=>{var t;let{media:i,fullscreenElement:r}=e;try{let e=r&&"requestFullscreen"in r?"requestFullscreen":r&&"webkitRequestFullScreen"in r?"webkitRequestFullScreen":void 0;if(e){let i=null==(t=r[e])?void 0:t.call(r);if(i instanceof Promise)return i.catch(()=>{})}else(null==i?void 0:i.webkitEnterFullscreen)?i.webkitEnterFullscreen():(null==i?void 0:i.requestFullscreen)&&i.requestFullscreen()}catch(e){console.error(e)}})(t),!i.detail||(null==(r=t.media)?void 0:r.inert)||null==(s=t.media)||s.focus()):(e=>{var t;let{documentElement:i}=e;if(fY){let e=null==(t=null==i?void 0:i[fY])?void 0:t.call(i);if(e instanceof Promise)return e.catch(()=>{})}})(t)},rootEvents:["fullscreenchange","webkitfullscreenchange"],mediaEvents:["webkitbeginfullscreen","webkitendfullscreen","webkitpresentationmodechanged"]},mediaIsCasting:{get(e){var t;let{media:i}=e;return!!(null==i?void 0:i.remote)&&(null==(t=i.remote)?void 0:t.state)!=="disconnected"&&!!i.remote.state},set(e,t){var i,r;let{media:s}=t;if(s&&(!e||(null==(i=s.remote)?void 0:i.state)==="disconnected")&&(e||(null==(r=s.remote)?void 0:r.state)==="connected")){if("function"!=typeof s.remote.prompt)return void console.warn("MediaChrome: Casting is not supported in this environment");s.remote.prompt().catch(()=>{})}},remoteEvents:["connect","connecting","disconnect"]},mediaIsAirplaying:{get:()=>!1,set(e,t){let{media:i}=t;if(i){if(!(i.webkitShowPlaybackTargetPicker&&c4.WebKitPlaybackTargetAvailabilityEvent))return void console.error("MediaChrome: received a request to select AirPlay but AirPlay is not supported in this environment");i.webkitShowPlaybackTargetPicker()}},mediaEvents:["webkitcurrentplaybacktargetiswirelesschanged"]},mediaFullscreenUnavailable:{get(e){let{media:t}=e;if(!f4||!f3(t))return cU.UNSUPPORTED}},mediaPipUnavailable:{get(e){let{media:t}=e;return f5&&f2(t)?(null==t?void 0:t.disablePictureInPicture)?cU.UNAVAILABLE:void 0:cU.UNSUPPORTED}},mediaVolumeUnavailable:{get(e){let{media:t}=e;if(!1===r||(null==t?void 0:t.volume)==void 0)return cU.UNSUPPORTED},stateOwnersUpdateHandlers:[e=>{null==r&&ms.then(t=>e(t?void 0:cU.UNSUPPORTED))}]},mediaCastUnavailable:{get(e,{availability:t="not-available"}={}){var i;let{media:r}=e;return f6&&(null==(i=null==r?void 0:r.remote)?void 0:i.state)?null!=t&&"available"!==t?cU.UNAVAILABLE:void 0:cU.UNSUPPORTED},stateOwnersUpdateHandlers:[(e,t)=>{var i;let{media:r}=t;if(r)return r.disableRemotePlayback||r.hasAttribute("disableremoteplayback")||null==(i=null==r?void 0:r.remote)||i.watchAvailability(t=>{e({availability:t?"available":"not-available"})}).catch(t=>{"NotSupportedError"===t.name?e({availability:null}):e({availability:"not-available"})}),()=>{var e;null==(e=null==r?void 0:r.remote)||e.cancelWatchAvailability().catch(()=>{})}}]},mediaAirplayUnavailable:{get:(e,t)=>f8?(null==t?void 0:t.availability)==="not-available"?cU.UNAVAILABLE:void 0:cU.UNSUPPORTED,mediaEvents:["webkitplaybacktargetavailabilitychanged"],stateOwnersUpdateHandlers:[(e,t)=>{var i;let{media:r}=t;if(r)return r.disableRemotePlayback||r.hasAttribute("disableremoteplayback")||null==(i=null==r?void 0:r.remote)||i.watchAvailability(t=>{e({availability:t?"available":"not-available"})}).catch(t=>{"NotSupportedError"===t.name?e({availability:null}):e({availability:"not-available"})}),()=>{var e;null==(e=null==r?void 0:r.remote)||e.cancelWatchAvailability().catch(()=>{})}}]},mediaRenditionUnavailable:{get(e){var t;let{media:i}=e;return(null==i?void 0:i.videoRenditions)?(null==(t=i.videoRenditions)?void 0:t.length)?void 0:cU.UNAVAILABLE:cU.UNSUPPORTED},mediaEvents:["emptied","loadstart"],videoRenditionsEvents:["addrendition","removerendition"]},mediaAudioTrackUnavailable:{get(e){var t,i;let{media:r}=e;return(null==r?void 0:r.audioTracks)?(null!=(i=null==(t=r.audioTracks)?void 0:t.length)?i:0)<=1?cU.UNAVAILABLE:void 0:cU.UNSUPPORTED},mediaEvents:["emptied","loadstart"],audioTracksEvents:["addtrack","removetrack"]},mediaLang:{get(e){let{options:{mediaLang:t}={}}=e;return null!=t?t:"en"}}},mo={[cL.MEDIA_PREVIEW_REQUEST](e,t,{detail:i}){var r,s,a;let n,l,{media:o}=t,d=null!=i?i:void 0;if(o&&null!=d){let[e]=fj(o,{kind:cM.METADATA,label:"thumbnails"}),t=Array.prototype.find.call(null!=(r=null==e?void 0:e.cues)?r:[],
199(e,t,i)=>0===t?e.endTime>d:t===i.length-1?e.startTime<=d:e.startTime<=d&&e.endTime>d);if(t){let e=/'^(?:[a-z]+:)?\/\//i.test(t.text)||null==(s=null==o?void 0:o.querySelector('track[label="thumbnails"]'))?void 0:s.src,i=new URL(t.text,e);l=new URLSearchParams(i.hash).get("#xywh").split(",").map(e=>+e),n=i.href}}let h=e.mediaDuration.get(t),u=null==(a=e.mediaChaptersCues.get(t).find((e,t,i)=>t===i.length-1&&h===e.endTime?e.startTime<=d&&e.endTime>=d:e.startTime<=d&&e.endTime>d))?void 0:a.text;return null!=i&&null==u&&(u=""),{mediaPreviewTime:d,mediaPreviewImage:n,mediaPreviewCoords:l,mediaPreviewChapter:u}},[cL.MEDIA_PAUSE_REQUEST](e,t){e.mediaPaused.set(!0,t)},[cL.MEDIA_PLAY_REQUEST](e,t){var i,r,s,a;let n=e.mediaStreamType.get(t)===cF.LIVE,l=!(null==(i=t.options)?void 0:i.noAutoSeekToLive),o=e.mediaTargetLiveWindow.get(t)>0;if(n&&l&&!o){let i=null==(r=e.mediaSeekable.get(t))?void 0:r[1];if(i){let r=null!=(a=null==(s=t.options)?void 0:s.seekToLiveOffset)?a:0;e.mediaCurrentTime.set(i-r,t)}}e.mediaPaused.set(!1,t)},[cL.MEDIA_PLAYBACK_RATE_REQUEST](e,t,{detail:i}){e.mediaPlaybackRate.set(i,t)},[cL.MEDIA_MUTE_REQUEST](e,t){e.mediaMuted.set(!0,t)},[cL.MEDIA_UNMUTE_REQUEST](e,t){e.mediaVolume.get(t)||e.mediaVolume.set(.25,t),e.mediaMuted.set(!1,t)},[cL.MEDIA_LOOP_REQUEST](e,t,{detail:i}){let r=!!i;return e.mediaLoop.set(r,t),{mediaLoop:r}},[cL.MEDIA_VOLUME_REQUEST](e,t,{detail:i}){i&&e.mediaMuted.get(t)&&e.mediaMuted.set(!1,t),e.mediaVolume.set(i,t)},[cL.MEDIA_SEEK_REQUEST](e,t,{detail:i}){e.mediaCurrentTime.set(i,t)},[cL.MEDIA_SEEK_TO_LIVE_REQUEST](e,t){var i,r,s;let a=null==(i=e.mediaSeekable.get(t))?void 0:i[1];if(Number.isNaN(Number(a)))return;let n=null!=(s=null==(r=t.options)?void 0:r.seekToLiveOffset)?s:0;e.mediaCurrentTime.set(a-n,t)},[cL.MEDIA_SHOW_SUBTITLES_REQUEST](e,t,{detail:i}){var r;let{options:s}=t,a=f9(t),n=fG(i),l=null==(r=n[0])?void 0:r.language;l&&!s.noSubtitlesLangPref&&c4.localStorage.setItem("media-chrome-pref-subtitles-lang",l),fq(cO.SHOWING,a,n)},[cL.MEDIA_DISABLE_SUBTITLES_REQUEST](e,t,{detail:i}){let r=f9(t);fq(cO.DISABLED,r,null!=i?i:[])},[cL.MEDIA_TOGGLE_SUBTITLES_REQUEST](e,t,{detail:i}){me(t,i)},[cL.MEDIA_RENDITION_REQUEST](e,t,{detail:i}){e.mediaRenditionSelected.set(i,t)},[cL.MEDIA_AUDIO_TRACK_REQUEST](e,t,{detail:i}){e.mediaAudioTrackEnabled.set(i,t)},[cL.MEDIA_ENTER_PIP_REQUEST](e,t){e.mediaIsFullscreen.get(t)&&e.mediaIsFullscreen.set(!1,t),e.mediaIsPip.set(!0,t)},[cL.MEDIA_EXIT_PIP_REQUEST](e,t){e.mediaIsPip.set(!1,t)},[cL.MEDIA_ENTER_FULLSCREEN_REQUEST](e,t,i){e.mediaIsPip.get(t)&&e.mediaIsPip.set(!1,t),e.mediaIsFullscreen.set(!0,t,i)},[cL.MEDIA_EXIT_FULLSCREEN_REQUEST](e,t){e.mediaIsFullscreen.set(!1,t)},[cL.MEDIA_ENTER_CAST_REQUEST](e,t){e.mediaIsFullscreen.get(t)&&e.mediaIsFullscreen.set(!1,t),e.mediaIsCasting.set(!0,t)},[cL.MEDIA_EXIT_CAST_REQUEST](e,t){e.mediaIsCasting.set(!1,t)},[cL.MEDIA_AIRPLAY_REQUEST](e,t){e.mediaIsAirplaying.set(!0,t)}};var md=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},mh=(e,t,i)=>(md(e,t,"read from private field"),i?i.call(e):t.get(e)),mu=(e,t,i)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,i)},mc=(e,t,i,r)=>(md(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i),mf=(e,t,i)=>(md(e,t,"access private method"),i);let mm=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Enter"," ","f","m","k","c","l","j",">","<","p"],mp="defaultsubtitles",mg="defaultstreamtype",mv="defaultduration",mE="fullscreenelement",my="hotkeys",mb="keyboardbackwardseekoffset",mT="keyboardforwardseekoffset",m_="keyboarddownvolumestep",mA="keyboardupvolumestep",mS="keysused",mk="lang",mL="loop",mR="liveedgeoffset",mI="noautoseektolive",mw="nodefaultstore",mD="nohotkeys",mC="nomutedpref",mP="nosubtitleslangpref",mx="novolumepref",mM="seektoliveoffset";class mO extends fM{constructor(){super(),mu(this,H),mu(this,K),mu(this,q),this.mediaStateReceivers=[],this.associatedElementSubscriptions=new Map,mu(this,x,new f$(this,my)),mu(this,M,void 0),mu(this,O,void 0),mu(this,N,null),mu(this,U,void 0),mu(this,F,void 0),mu(this,$,e=>{var t;null==(t=mh(this,O))||t.dispatch(e)}),mu(this,B,void 0),mu(this,V,e=>{let{key:t,shiftKey:i}=e;i&&("/"===t||"?"===t)||mm.includes(t)?this.keyboardShortcutHandler(e):this.removeEventListener("keyup",mh(this,V))}),this.associateElement(this);let e={};mc(this,U,t=>{Object.entries(t).forEach(([t,i])=>{if(t in e&&e[t]===i)return;
199this.propagateMediaState(t,i);let r=t.toLowerCase(),s=new c4.CustomEvent(cx[r],{composed:!0,detail:i});this.dispatchEvent(s)}),e=t}),this.hasAttribute(mD)?this.disableHotkeys():this.enableHotkeys()}static get observedAttributes(){return super.observedAttributes.concat(mD,my,mg,mp,mv,mC,mx,mk,mL,mR,mM,mI)}get mediaStore(){return mh(this,O)}set mediaStore(e){var t,i;(mh(this,O)&&(null==(t=mh(this,F))||t.call(this),mc(this,F,void 0)),mc(this,O,e),mh(this,O)||this.hasAttribute(mw))?mc(this,F,null==(i=mh(this,O))?void 0:i.subscribe(mh(this,U))):mf(this,H,G).call(this)}get fullscreenElement(){var e;return null!=(e=mh(this,M))?e:this}set fullscreenElement(e){var t;this.hasAttribute(mE)&&this.removeAttribute(mE),mc(this,M,e),null==(t=mh(this,O))||t.dispatch({type:"fullscreenelementchangerequest",detail:this.fullscreenElement})}get defaultSubtitles(){return fu(this,mp)}set defaultSubtitles(e){fc(this,mp,e)}get defaultStreamType(){return ff(this,mg)}set defaultStreamType(e){fm(this,mg,e)}get defaultDuration(){return fd(this,mv)}set defaultDuration(e){fh(this,mv,e)}get noHotkeys(){return fu(this,mD)}set noHotkeys(e){fc(this,mD,e)}get keysUsed(){return ff(this,mS)}set keysUsed(e){fm(this,mS,e)}get liveEdgeOffset(){return fd(this,mR)}set liveEdgeOffset(e){fh(this,mR,e)}get noAutoSeekToLive(){return fu(this,mI)}set noAutoSeekToLive(e){fc(this,mI,e)}get noVolumePref(){return fu(this,mx)}set noVolumePref(e){fc(this,mx,e)}get noMutedPref(){return fu(this,mC)}set noMutedPref(e){fc(this,mC,e)}get noSubtitlesLangPref(){return fu(this,mP)}set noSubtitlesLangPref(e){fc(this,mP,e)}get noDefaultStore(){return fu(this,mw)}set noDefaultStore(e){fc(this,mw,e)}attributeChangedCallback(e,t,i){var r,s,a,n,l,o,d,h,u,c,f,m;if(super.attributeChangedCallback(e,t,i),e===mD)i!==t&&""===i?(this.hasAttribute(my)&&console.warn("Media Chrome: Both `hotkeys` and `nohotkeys` have been set. All hotkeys will be disabled."),this.disableHotkeys()):i!==t&&null===i&&this.enableHotkeys();else if(e===my)mh(this,x).value=i;else if(e===mp&&i!==t)null==(r=mh(this,O))||r.dispatch({type:"optionschangerequest",detail:{defaultSubtitles:this.hasAttribute(mp)}});else if(e===mg)null==(a=mh(this,O))||a.dispatch({type:"optionschangerequest",detail:{defaultStreamType:null!=(s=this.getAttribute(mg))?s:void 0}});else if(e===mR&&i!==t)null==(n=mh(this,O))||n.dispatch({type:"optionschangerequest",detail:{liveEdgeOffset:this.hasAttribute(mR)?+this.getAttribute(mR):void 0,seekToLiveOffset:this.hasAttribute(mM)?+this.getAttribute(mM):this.hasAttribute(mR)?+this.getAttribute(mR):void 0}});else if(e===mM&&i!==t)null==(l=mh(this,O))||l.dispatch({type:"optionschangerequest",detail:{seekToLiveOffset:this.hasAttribute(mM)?+this.getAttribute(mM):this.hasAttribute(mR)?+this.getAttribute(mR):void 0}});else if(e===mI)null==(o=mh(this,O))||o.dispatch({type:"optionschangerequest",detail:{noAutoSeekToLive:this.hasAttribute(mI)}});else if(e===mE){let e=i?null==(d=this.getRootNode())?void 0:d.getElementById(i):void 0;mc(this,M,e),null==(h=mh(this,O))||h.dispatch({type:"fullscreenelementchangerequest",detail:this.fullscreenElement})}else e===mk&&i!==t?(cW=i,null==(u=mh(this,O))||u.dispatch({type:"optionschangerequest",detail:{mediaLang:i}})):e===mL&&i!==t?null==(c=mh(this,O))||c.dispatch({type:cL.MEDIA_LOOP_REQUEST,detail:null!=i}):e===mx&&i!==t?null==(f=mh(this,O))||f.dispatch({type:"optionschangerequest",detail:{noVolumePref:this.hasAttribute(mx)}}):e===mC&&i!==t&&(null==(m=mh(this,O))||m.dispatch({type:"optionschangerequest",detail:{noMutedPref:this.hasAttribute(mC)}}))}connectedCallback(){var e,t,i;mh(this,O)||this.hasAttribute(mw)||mf(this,H,G).call(this),null==(e=mh(this,O))||e.dispatch({type:"documentelementchangerequest",detail:c5}),null==(t=mh(this,O))||t.dispatch({type:"fullscreenelementchangerequest",detail:this.fullscreenElement}),super.connectedCallback(),mh(this,O)&&!mh(this,F)&&mc(this,F,null==(i=mh(this,O))?void 0:i.subscribe(mh(this,U))),void 0!==mh(this,B)&&mh(this,O)&&this.media&&setTimeout(()=>{var e,t,i;(null==(t=null==(e=this.media)?void 0:e.textTracks)?void 0:t.length)&&(null==(i=mh(this,O))||i.dispatch({type:cL.MEDIA_TOGGLE_SUBTITLES_REQUEST,detail:mh(this,B)}))},0),this.hasAttribute(mD)?this.disableHotkeys():this.enableHotkeys()}disconnectedCallback(){var e,t,i,r,s,a;if(null==(e=super.disconnectedCallback)||e.call(this),this.disableHotkeys(),mh(this,O)){let e=mh(this,O).getState();mc(this,B,!!(null==(t=e.mediaSubtitlesShowing)?void 0:t.length)),null==(i=mh(this,O))||i.dispatch({type:"fullscreenelementchangerequest",detail:void 0}),null==(r=mh(this,O))||r.dispatch({type:"documentelementchangerequest",detail:void 0}),null==(s=mh(this,O))||s.dispatch({type:cL.MEDIA_TOGGLE_SUBTITLES_REQUEST,detail:!1})}mh(this,F)&&(null==(a=mh(this,F))||a.call(this),mc(this,F,void 0)),this.unassociateElement(this),mh(this,N)&&(mh(this,N).remove(),mc(this,N,null))}mediaSetCallback(e){var t;super.mediaSetCallback(e),null==(t=mh(this,O))||t.dispatch({type:"mediaelementchangerequest",detail:e}),e.hasAttribute("tabindex")||(e.tabIndex=-1)}mediaUnsetCallback(e){var t;super.mediaUnsetCallback(e),null==(t=mh(this,O))||t.dispatch({type:"mediaelementchangerequest",detail:void 0})}propagateMediaState(e,t){mK(this.mediaStateReceivers,e,t)}associateElement(e){if(!e)return;let{associatedElementSubscriptions:t}=this;if(t.has(e))return;let i=mW(e,this.registerMediaStateReceiver.bind(this),this.unregisterMediaStateReceiver.bind(this));
199Object.values(cL).forEach(t=>{e.addEventListener(t,mh(this,$))}),t.set(e,i)}unassociateElement(e){if(!e)return;let{associatedElementSubscriptions:t}=this;t.has(e)&&(t.get(e)(),t.delete(e),Object.values(cL).forEach(t=>{e.removeEventListener(t,mh(this,$))}))}registerMediaStateReceiver(e){if(!e)return;let t=this.mediaStateReceivers;!(t.indexOf(e)>-1)&&(t.push(e),mh(this,O)&&Object.entries(mh(this,O).getState()).forEach(([t,i])=>{mK([e],t,i)}))}unregisterMediaStateReceiver(e){let t=this.mediaStateReceivers,i=t.indexOf(e);i<0||t.splice(i,1)}enableHotkeys(){this.addEventListener("keydown",mf(this,K,W))}disableHotkeys(){this.removeEventListener("keydown",mf(this,K,W)),this.removeEventListener("keyup",mh(this,V))}get hotkeys(){return mh(this,x)}set hotkeys(e){fm(this,my,e)}keyboardShortcutHandler(e){var t,i,r,s,a,n,l,o,d;let h,u,c,f=e.target;if(!((null!=(r=null!=(i=null==(t=f.getAttribute(mS))?void 0:t.split(" "))?i:null==f?void 0:f.keysUsed)?r:[]).map(e=>"Space"===e?" ":e).filter(Boolean).includes(e.key)||mh(this,x).contains(`no${e.key.toLowerCase()}`)||" "===e.key&&mh(this,x).contains("nospace"))&&!(e.shiftKey&&("/"===e.key||"?"===e.key)&&mh(this,x).contains("noshift+/")))switch(e.key){case" ":case"k":h=mh(this,O).getState().mediaPaused?cL.MEDIA_PLAY_REQUEST:cL.MEDIA_PAUSE_REQUEST,this.dispatchEvent(new c4.CustomEvent(h,{composed:!0,bubbles:!0}));break;case"m":h="off"===this.mediaStore.getState().mediaVolumeLevel?cL.MEDIA_UNMUTE_REQUEST:cL.MEDIA_MUTE_REQUEST,this.dispatchEvent(new c4.CustomEvent(h,{composed:!0,bubbles:!0}));break;case"f":h=this.mediaStore.getState().mediaIsFullscreen?cL.MEDIA_EXIT_FULLSCREEN_REQUEST:cL.MEDIA_ENTER_FULLSCREEN_REQUEST,this.dispatchEvent(new c4.CustomEvent(h,{composed:!0,bubbles:!0}));break;case"c":this.dispatchEvent(new c4.CustomEvent(cL.MEDIA_TOGGLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0}));break;case"ArrowLeft":case"j":{let e=this.hasAttribute(mb)?+this.getAttribute(mb):10;u=Math.max((null!=(s=this.mediaStore.getState().mediaCurrentTime)?s:0)-e,0),c=new c4.CustomEvent(cL.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:u}),this.dispatchEvent(c);break}case"ArrowRight":case"l":{let e=this.hasAttribute(mT)?+this.getAttribute(mT):10;u=Math.max((null!=(a=this.mediaStore.getState().mediaCurrentTime)?a:0)+e,0),c=new c4.CustomEvent(cL.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:u}),this.dispatchEvent(c);break}case"ArrowUp":{let e=this.hasAttribute(mA)?+this.getAttribute(mA):.025;u=Math.min((null!=(n=this.mediaStore.getState().mediaVolume)?n:1)+e,1),c=new c4.CustomEvent(cL.MEDIA_VOLUME_REQUEST,{composed:!0,bubbles:!0,detail:u}),this.dispatchEvent(c);break}case"ArrowDown":{let e=this.hasAttribute(m_)?+this.getAttribute(m_):.025;u=Math.max((null!=(l=this.mediaStore.getState().mediaVolume)?l:1)-e,0),c=new c4.CustomEvent(cL.MEDIA_VOLUME_REQUEST,{composed:!0,bubbles:!0,detail:u}),this.dispatchEvent(c);break}case"<":u=Math.max((null!=(o=this.mediaStore.getState().mediaPlaybackRate)?o:1)-.25,.25).toFixed(2),c=new c4.CustomEvent(cL.MEDIA_PLAYBACK_RATE_REQUEST,{composed:!0,bubbles:!0,detail:u}),this.dispatchEvent(c);break;case">":u=Math.min((null!=(d=this.mediaStore.getState().mediaPlaybackRate)?d:1)+.25,2).toFixed(2),c=new c4.CustomEvent(cL.MEDIA_PLAYBACK_RATE_REQUEST,{composed:!0,bubbles:!0,detail:u}),this.dispatchEvent(c);break;case"/":case"?":e.shiftKey&&mf(this,q,j).call(this);break;case"p":h=this.mediaStore.getState().mediaIsPip?cL.MEDIA_EXIT_PIP_REQUEST:cL.MEDIA_ENTER_PIP_REQUEST,c=new c4.CustomEvent(h,{composed:!0,bubbles:!0}),this.dispatchEvent(c)}}}x=new WeakMap,M=new WeakMap,O=new WeakMap,N=new WeakMap,U=new WeakMap,F=new WeakMap,$=new WeakMap,B=new WeakMap,H=new WeakSet,G=function(){var e;this.mediaStore=(({media:e,fullscreenElement:t,documentElement:i,stateMediator:r=ml,requestMap:s=mo,options:a={},monitorStateOwnersOnlyWithSubscriptions:n=!0})=>{let l,o=[],d={options:{...a}},h=Object.freeze({mediaPreviewTime:void 0,mediaPreviewImage:void 0,mediaPreviewCoords:void 0,mediaPreviewChapter:void 0}),u=e=>{void 0==e||mt(e,h)||(h=Object.freeze({...h,...e}),o.forEach(e=>e(h)))},c=()=>{u(Object.entries(r).reduce((e,[t,{get:i}])=>(e[t]=i(d),e),{}))},f={},m=async(e,t)=>{var i,s,a,h,m,g,v,E,y,b,T,_,A,S,k,L;let R=!!l;if(l={...d,...null!=l?l:{},...e},R)return;await ma(...Object.values(e));let I=o.length>0&&0===t&&n,w=d.media!==l.media,D=(null==(i=d.media)?void 0:i.textTracks)!==(null==(s=l.media)?void 0:s.textTracks),C=(null==(a=d.media)?void 0:a.videoRenditions)!==(null==(h=l.media)?void 0:h.videoRenditions),P=(null==(m=d.media)?void 0:m.audioTracks)!==(null==(g=l.media)?void 0:g.audioTracks),x=(null==(v=d.media)?void 0:v.remote)!==(null==(E=l.media)?void 0:E.remote),M=d.documentElement!==l.documentElement,O=!!d.media&&(w||I),N=!!(null==(y=d.media)?void 0:y.textTracks)&&(D||I),U=!!(null==(b=d.media)?void 0:b.videoRenditions)&&(C||I),F=!!(null==(T=d.media)?void 0:T.audioTracks)&&(P||I),$=!!(null==(_=d.media)?void 0:_.remote)&&(x||I),B=!!d.documentElement&&(M||I),H=O||N||U||F||$||B,G=0===o.length&&1===t&&n,V=!!l.media&&(w||G),K=!!(null==(A=l.media)?void 0:A.textTracks)&&(D||G),W=!!(null==(S=l.media)?void 0:S.videoRenditions)&&(C||G),q=!!(null==(k=l.media)?void 0:k.audioTracks)&&(P||G),j=!!(null==(L=l.media)?void 0:L.remote)&&(x||G),Y=!!l.documentElement&&(M||G),Q=V||K||W||q||j||Y;if(!(H||Q)){Object.entries(l).forEach(([e,t])=>{d[e]=t}),c(),l=void 0;return}Object.entries(r).forEach(([e,{get:t,mediaEvents:i=[],textTracksEvents:r=[],videoRenditionsEvents:s=[],audioTracksEvents:a=[],remoteEvents:n=[],rootEvents:o=[],stateOwnersUpdateHandlers:h=[]}])=>{let c;f[e]||(f[e]={});let m=i=>{u({[e]:t(d,i)})};
199c=f[e].mediaEvents,i.forEach(t=>{c&&O&&(d.media.removeEventListener(t,c),f[e].mediaEvents=void 0),V&&(l.media.addEventListener(t,m),f[e].mediaEvents=m)}),c=f[e].textTracksEvents,r.forEach(t=>{var i,r;c&&N&&(null==(i=d.media.textTracks)||i.removeEventListener(t,c),f[e].textTracksEvents=void 0),K&&(null==(r=l.media.textTracks)||r.addEventListener(t,m),f[e].textTracksEvents=m)}),c=f[e].videoRenditionsEvents,s.forEach(t=>{var i,r;c&&U&&(null==(i=d.media.videoRenditions)||i.removeEventListener(t,c),f[e].videoRenditionsEvents=void 0),W&&(null==(r=l.media.videoRenditions)||r.addEventListener(t,m),f[e].videoRenditionsEvents=m)}),c=f[e].audioTracksEvents,a.forEach(t=>{var i,r;c&&F&&(null==(i=d.media.audioTracks)||i.removeEventListener(t,c),f[e].audioTracksEvents=void 0),q&&(null==(r=l.media.audioTracks)||r.addEventListener(t,m),f[e].audioTracksEvents=m)}),c=f[e].remoteEvents,n.forEach(t=>{var i,r;c&&$&&(null==(i=d.media.remote)||i.removeEventListener(t,c),f[e].remoteEvents=void 0),j&&(null==(r=l.media.remote)||r.addEventListener(t,m),f[e].remoteEvents=m)}),c=f[e].rootEvents,o.forEach(t=>{c&&B&&(d.documentElement.removeEventListener(t,c),f[e].rootEvents=void 0),Y&&(l.documentElement.addEventListener(t,m),f[e].rootEvents=m)});let g=f[e].stateOwnersUpdateHandlers;if(g&&H&&(Array.isArray(g)?g:[g]).forEach(e=>{"function"==typeof e&&e()}),Q){let t=h.map(e=>e(m,l)).filter(e=>"function"==typeof e);f[e].stateOwnersUpdateHandlers=1===t.length?t[0]:t}else H&&(f[e].stateOwnersUpdateHandlers=void 0)}),Object.entries(l).forEach(([e,t])=>{d[e]=t}),c(),l=void 0};return m({media:e,fullscreenElement:t,documentElement:i,options:a}),{dispatch(e){let{type:t,detail:i}=e;s[t]&&null==h.mediaErrorCode?u(s[t](r,d,e)):"mediaelementchangerequest"===t?m({media:i}):"fullscreenelementchangerequest"===t?m({fullscreenElement:i}):"documentelementchangerequest"===t?m({documentElement:i}):"optionschangerequest"===t&&(Object.entries(null!=i?i:{}).forEach(([e,t])=>{d.options[e]=t}),c())},getState:()=>h,subscribe:e=>(m({},o.length+1),o.push(e),e(h),()=>{let t=o.indexOf(e);t>=0&&(m({},o.length-1),o.splice(t,1))})}})({media:this.media,fullscreenElement:this.fullscreenElement,options:{defaultSubtitles:this.hasAttribute(mp),defaultDuration:this.hasAttribute(mv)?+this.getAttribute(mv):void 0,defaultStreamType:null!=(e=this.getAttribute(mg))?e:void 0,liveEdgeOffset:this.hasAttribute(mR)?+this.getAttribute(mR):void 0,seekToLiveOffset:this.hasAttribute(mM)?+this.getAttribute(mM):this.hasAttribute(mR)?+this.getAttribute(mR):void 0,noAutoSeekToLive:this.hasAttribute(mI),noVolumePref:this.hasAttribute(mx),noMutedPref:this.hasAttribute(mC),noSubtitlesLangPref:this.hasAttribute(mP)}})},V=new WeakMap,K=new WeakSet,W=function(e){var t;let{metaKey:i,altKey:r,key:s,shiftKey:a}=e,n=a&&("/"===s||"?"===s);if(n&&(null==(t=mh(this,N))?void 0:t.open)||i||r||!n&&!mm.includes(s))return void this.removeEventListener("keyup",mh(this,V));let l=e.target,o=l instanceof HTMLElement&&("media-volume-range"===l.tagName.toLowerCase()||"media-time-range"===l.tagName.toLowerCase());![" ","ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(s)||mh(this,x).contains(`no${s.toLowerCase()}`)||" "===s&&mh(this,x).contains("nospace")||o||e.preventDefault(),this.addEventListener("keyup",mh(this,V),{once:!0})},q=new WeakSet,j=function(){mh(this,N)||(mc(this,N,c5.createElement("media-keyboard-shortcuts-dialog")),this.appendChild(mh(this,N))),mh(this,N).open=!0};let mN=Object.values(cD),mU=Object.values(cI),mF=e=>{var t,i,r,s;let{observedAttributes:a}=e.constructor;!a&&(null==(t=e.nodeName)?void 0:t.includes("-"))&&(c4.customElements.upgrade(e),{observedAttributes:a}=e.constructor);let n=null==(s=null==(r=null==(i=null==e?void 0:e.getAttribute)?void 0:i.call(e,cR.MEDIA_CHROME_ATTRIBUTES))?void 0:r.split)?void 0:s.call(r,/\s+/);return Array.isArray(a||n)?(a||n).filter(e=>mN.includes(e)):[]},m$=e=>{var t,i;return(null==(t=e.nodeName)?void 0:t.includes("-"))&&c4.customElements.get(null==(i=e.nodeName)?void 0:i.toLowerCase())&&!(e instanceof c4.customElements.get(e.nodeName.toLowerCase()))&&c4.customElements.upgrade(e),mU.some(t=>t in e)||!!mF(e).length},mB=e=>{var t;return null==(t=null==e?void 0:e.join)?void 0:t.call(e,":")},mH={[cD.MEDIA_SUBTITLES_LIST]:fK,[cD.MEDIA_SUBTITLES_SHOWING]:fK,[cD.MEDIA_SEEKABLE]:mB,[cD.MEDIA_BUFFERED]:e=>null==e?void 0:e.map(mB).join(" "),[cD.MEDIA_PREVIEW_COORDS]:e=>null==e?void 0:e.join(" "),[cD.MEDIA_RENDITION_LIST]:function(e){return null==e?void 0:e.map(cB).join(" ")},[cD.MEDIA_AUDIO_TRACK_LIST]:function(e){return null==e?void 0:e.map(cH).join(" ")}},mG=async(e,t,i)=>{var r,s;if(e.isConnected||await cV(0),"boolean"==typeof i||null==i)return fc(e,t,i);if("number"==typeof i)return fh(e,t,i);if("string"==typeof i)return fm(e,t,i);if(Array.isArray(i)&&!i.length)return e.removeAttribute(t);let a=null!=(s=null==(r=mH[t])?void 0:r.call(mH,i))?s:i;return e.setAttribute(t,a)},mV=(e,t)=>{var i;if(null==(i=e.closest)?void 0:i.call(e,'*[slot="media"]'))return;let r=(e,t)=>{var i,r;m$(e)&&t(e);let{children:s=[]}=null!=e?e:{};[...s,...null!=(r=null==(i=null==e?void 0:e.shadowRoot)?void 0:i.children)?r:[]].forEac
199h(e=>mV(e,t))},s=null==e?void 0:e.nodeName.toLowerCase();s.includes("-")&&!m$(e)?c4.customElements.whenDefined(s).then(()=>{r(e,t)}):r(e,t)},mK=(e,t,i)=>{e.forEach(e=>{if(t in e){e[t]=i;return}let r=mF(e),s=t.toLowerCase();r.includes(s)&&mG(e,s,i)})},mW=(e,t,i)=>{mV(e,t);let r=e=>{var i;t(null!=(i=null==e?void 0:e.composedPath()[0])?i:e.target)},s=e=>{var t;i(null!=(t=null==e?void 0:e.composedPath()[0])?t:e.target)};e.addEventListener(cL.REGISTER_MEDIA_STATE_RECEIVER,r),e.addEventListener(cL.UNREGISTER_MEDIA_STATE_RECEIVER,s);let a=[],n=e=>{let r=e.target;"media"!==r.name&&(a.forEach(e=>mV(e,i)),(a=[...r.assignedElements({flatten:!0})]).forEach(e=>mV(e,t)))};e.addEventListener("slotchange",n);let l=new MutationObserver(e=>{e.forEach(e=>{let{addedNodes:r=[],removedNodes:s=[],type:a,target:n,attributeName:l}=e;"childList"===a?(Array.prototype.forEach.call(r,e=>mV(e,t)),Array.prototype.forEach.call(s,e=>mV(e,i))):"attributes"===a&&l===cR.MEDIA_CHROME_ATTRIBUTES&&(m$(n)?t(n):i(n))})});return l.observe(e,{childList:!0,attributes:!0,subtree:!0}),()=>{mV(e,i),e.removeEventListener("slotchange",n),l.disconnect(),e.removeEventListener(cL.REGISTER_MEDIA_STATE_RECEIVER,r),e.removeEventListener(cL.UNREGISTER_MEDIA_STATE_RECEIVER,s)}};c4.customElements.get("media-controller")||c4.customElements.define("media-controller",mO);let mq="placement",mj="bounds";class mY extends c4.HTMLElement{constructor(){if(super(),this.updateXOffset=()=>{var e,t;if(!fn(this,{checkOpacity:!1,checkVisibilityCSS:!1}))return;let i=this.placement;if("left"===i||"right"===i)return void this.style.removeProperty("--media-tooltip-offset-x");let r=getComputedStyle(this),s=null!=(e=fa(this,"#"+this.bounds))?e:null!=(t=function(e){var t,i,r;let{MEDIA_CONTROLLER:s}=cR,a=e.getAttribute(s);if(a){let s;return null==(t=(s=null==(r=null==(i=e)?void 0:i.getRootNode)?void 0:r.call(i))instanceof ShadowRoot||s instanceof Document?s:null)?void 0:t.getElementById(a)}}(this))?t:fa(this,"media-controller");if(!s)return;let{x:a,width:n}=s.getBoundingClientRect(),{x:l,width:o}=this.getBoundingClientRect(),d=r.getPropertyValue("--media-tooltip-offset-x"),h=d?parseFloat(d.replace("px","")):0,u=r.getPropertyValue("--media-tooltip-container-margin"),c=u?parseFloat(u.replace("px","")):0,f=l-a+h-c,m=l+o-(a+n)+h+c;f<0?this.style.setProperty("--media-tooltip-offset-x",`${f}px`):m>0?this.style.setProperty("--media-tooltip-offset-x",`${m}px`):this.style.removeProperty("--media-tooltip-offset-x")},!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);const e=ft(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e)}if(this.arrowEl=this.shadowRoot.querySelector("#arrow"),Object.prototype.hasOwnProperty.call(this,"placement")){const e=this.placement;delete this.placement,this.placement=e}}static get observedAttributes(){return[mq,mj]}get placement(){return ff(this,mq)}set placement(e){fm(this,mq,e)}get bounds(){return ff(this,mj)}set bounds(e){fm(this,mj,e)}}mY.shadowRootOptions={mode:"open"},mY.getTemplateHTML=function(e){return`
200    <style>
201      :host {
202        --_tooltip-background-color: var(--media-tooltip-background-color, var(--media-secondary-color, rgba(20, 20, 30, .7)));
203        --_tooltip-background: var(--media-tooltip-background, var(--_tooltip-background-color));
204        --_tooltip-arrow-half-width: calc(var(--media-tooltip-arrow-width, 12px) / 2);
205        --_tooltip-arrow-height: var(--media-tooltip-arrow-height, 5px);
206        --_tooltip-arrow-background: var(--media-tooltip-arrow-color, var(--_tooltip-background-color));
207        position: relative;
208        pointer-events: none;
209        display: var(--media-tooltip-display, inline-flex);
210        justify-content: center;
211        align-items: center;
212        box-sizing: border-box;
213        z-index: var(--media-tooltip-z-index, 1);
214        background: var(--_tooltip-background);
215        color: var(--media-text-color, var(--media-primary-color, rgb(238 238 238)));
216        font: var(--media-font,
217          var(--media-font-weight, 400)
218          var(--media-font-size, 13px) /
219          var(--media-text-content-height, var(--media-control-height, 18px))
220          var(--media-font-family, helvetica neue, segoe ui, roboto, arial, sans-serif));
221        padding: var(--media-tooltip-padding, .35em .7em);
222        border: var(--media-tooltip-border, none);
223        border-radius: var(--media-tooltip-border-radius, 5px);
224        filter: var(--media-tooltip-filter, drop-shadow(0 0 4px rgba(0, 0, 0, .2)));
225        white-space: var(--media-tooltip-white-space, nowrap);
226      }
227
228      :host([hidden]) {
229        display: none;
230      }
231
232      img, svg {
233        display: inline-block;
234      }
235
236      #arrow {
237        position: absolute;
238        width: 0px;
239        height: 0px;
240        border-style: solid;
241        display: var(--media-tooltip-arrow-display, block);
242      }
243
244      :host(:not([placement])),
245      :host([placement="top"]) {
246        position: absolute;
247        bottom: calc(100% + var(--media-tooltip-distance, 12px));
248        left: 50%;
249        transform: translate(calc(-50% - var(--media-tooltip-offset-x, 0px)), 0
249);
250      }
251      :host(:not([placement])) #arrow,
252      :host([placement="top"]) #arrow {
253        top: 100%;
254        left: 50%;
255        border-width: var(--_tooltip-arrow-height) var(--_tooltip-arrow-half-width) 0 var(--_tooltip-arrow-half-width);
256        border-color: var(--_tooltip-arrow-background) transparent transparent transparent;
257        transform: translate(calc(-50% + var(--media-tooltip-offset-x, 0px)), 0);
258      }
259
260      :host([placement="right"]) {
261        position: absolute;
262        left: calc(100% + var(--media-tooltip-distance, 12px));
263        top: 50%;
264        transform: translate(0, -50%);
265      }
266      :host([placement="right"]) #arrow {
267        top: 50%;
268        right: 100%;
269        border-width: var(--_tooltip-arrow-half-width) var(--_tooltip-arrow-height) var(--_tooltip-arrow-half-width) 0;
270        border-color: transparent var(--_tooltip-arrow-background) transparent transparent;
271        transform: translate(0, -50%);
272      }
273
274      :host([placement="bottom"]) {
275        position: absolute;
276        top: calc(100% + var(--media-tooltip-distance, 12px));
277        left: 50%;
278        transform: translate(calc(-50% - var(--media-tooltip-offset-x, 0px)), 0);
279      }
280      :host([placement="bottom"]) #arrow {
281        bottom: 100%;
282        left: 50%;
283        border-width: 0 var(--_tooltip-arrow-half-width) var(--_tooltip-arrow-height) var(--_tooltip-arrow-half-width);
284        border-color: transparent transparent var(--_tooltip-arrow-background) transparent;
285        transform: translate(calc(-50% + var(--media-tooltip-offset-x, 0px)), 0);
286      }
287
288      :host([placement="left"]) {
289        position: absolute;
290        right: calc(100% + var(--media-tooltip-distance, 12px));
291        top: 50%;
292        transform: translate(0, -50%);
293      }
294      :host([placement="left"]) #arrow {
295        top: 50%;
296        left: 100%;
297        border-width: var(--_tooltip-arrow-half-width) 0 var(--_tooltip-arrow-half-width) var(--_tooltip-arrow-height);
298        border-color: transparent transparent transparent var(--_tooltip-arrow-background);
299        transform: translate(0, -50%);
300      }
301      
302      :host([placement="none"]) #arrow {
303        display: none;
304      }
305    </style>
306    <slot></slot>
307    <div id="arrow"></div>
308  `},c4.customElements.get("media-tooltip")||c4.customElements.define("media-tooltip",mY);var mQ=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},mz=(e,t,i)=>(mQ(e,t,"read from private field"),i?i.call(e):t.get(e)),mX=(e,t,i)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,i)},mZ=(e,t,i,r)=>(mQ(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i);let mJ="tooltipplacement",m0="disabled",m1="notooltip";class m2 extends c4.HTMLElement{constructor(){if(super(),mX(this,J),mX(this,Y,void 0),this.preventClick=!1,this.tooltipEl=null,mX(this,Q,e=>{this.preventClick||this.handleClick(e),setTimeout(mz(this,z),0)}),mX(this,z,()=>{var e,t;null==(t=null==(e=this.tooltipEl)?void 0:e.updateXOffset)||t.call(e)}),mX(this,X,e=>{let{key:t}=e;this.keysUsed.includes(t)?this.preventClick||this.handleClick(e):this.removeEventListener("keyup",mz(this,X))}),mX(this,Z,e=>{let{metaKey:t,altKey:i,key:r}=e;t||i||!this.keysUsed.includes(r)?this.removeEventListener("keyup",mz(this,X)):this.addEventListener("keyup",mz(this,X),{once:!0})}),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);const e=ft(this.attributes),t=this.constructor.getTemplateHTML(e);this.shadowRoot.setHTMLUnsafe?this.shadowRoot.setHTMLUnsafe(t):this.shadowRoot.innerHTML=t}this.tooltipEl=this.shadowRoot.querySelector("media-tooltip")}static get observedAttributes(){return["disabled",mJ,cR.MEDIA_CONTROLLER,cD.MEDIA_LANG]}enable(){this.addEventListener("click",mz(this,Q)),this.addEventListener("keydown",mz(this,Z)),this.tabIndex=0}disable(){this.removeEventListener("click",mz(this,Q)),this.removeEventListener("keydown",mz(this,Z)),this.removeEventListener("keyup",mz(this,X)),this.tabIndex=-1}attributeChangedCallback(e,t,i){var r,s,a,n,l;e===cR.MEDIA_CONTROLLER?(t&&(null==(s=null==(r=mz(this,Y))?void 0:r.unassociateElement)||s.call(r,this),mZ(this,Y,null)),i&&this.isConnected&&(mZ(this,Y,null==(a=this.getRootNode())?void 0:a.getElementById(i)),null==(l=null==(n=mz(this,Y))?void 0:n.associateElement)||l.call(n,this))):"disabled"===e&&i!==t?null==i?this.enable():this.disable():e===mJ&&this.tooltipEl&&i!==t?this.tooltipEl.placement=i:e===cD.MEDIA_LA
308NG&&(this.shadowRoot.querySelector('slot[name="tooltip-content"]').innerHTML=this.constructor.getTooltipContentHTML()),mz(this,z).call(this)}connectedCallback(){var e,t,i;let{style:r}=fl(this.shadowRoot,":host");r.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`),this.hasAttribute("disabled")?this.disable():this.enable(),this.setAttribute("role","button");let s=this.getAttribute(cR.MEDIA_CONTROLLER);s&&(mZ(this,Y,null==(e=this.getRootNode())?void 0:e.getElementById(s)),null==(i=null==(t=mz(this,Y))?void 0:t.associateElement)||i.call(t,this)),c4.customElements.whenDefined("media-tooltip").then(()=>{var e,t;return(e=J,t=ee,mQ(this,e,"access private method"),t).call(this)})}disconnectedCallback(){var e,t;this.disable(),null==(t=null==(e=mz(this,Y))?void 0:e.unassociateElement)||t.call(e,this),mZ(this,Y,null),this.removeEventListener("mouseenter",mz(this,z)),this.removeEventListener("focus",mz(this,z)),this.removeEventListener("click",mz(this,Q))}get keysUsed(){return["Enter"," "]}get tooltipPlacement(){return ff(this,mJ)}set tooltipPlacement(e){fm(this,mJ,e)}get mediaController(){return ff(this,cR.MEDIA_CONTROLLER)}set mediaController(e){fm(this,cR.MEDIA_CONTROLLER,e)}get disabled(){return fu(this,m0)}set disabled(e){fc(this,m0,e)}get noTooltip(){return fu(this,m1)}set noTooltip(e){fc(this,m1,e)}handleClick(e){}}Y=new WeakMap,Q=new WeakMap,z=new WeakMap,X=new WeakMap,Z=new WeakMap,J=new WeakSet,ee=function(){this.addEventListener("mouseenter",mz(this,z)),this.addEventListener("focus",mz(this,z)),this.addEventListener("click",mz(this,Q));let e=this.tooltipPlacement;e&&this.tooltipEl&&(this.tooltipEl.placement=e)},m2.shadowRootOptions={mode:"open"},m2.getTemplateHTML=function(e,t={}){return`
309    <style>
310      :host {
311        position: relative;
312        font: var(--media-font,
313          var(--media-font-weight, bold)
314          var(--media-font-size, 14px) /
315          var(--media-text-content-height, var(--media-control-height, 24px))
316          var(--media-font-family, helvetica neue, segoe ui, roboto, arial, sans-serif));
317        color: var(--media-text-color, var(--media-primary-color, rgb(238 238 238)));
318        background: var(--media-control-background, var(--media-secondary-color, rgb(20 20 30 / .7)));
319        padding: var(--media-button-padding, var(--media-control-padding, 10px));
320        justify-content: var(--media-button-justify-content, center);
321        display: inline-flex;
322        align-items: center;
323        vertical-align: middle;
324        box-sizing: border-box;
325        transition: background .15s linear;
326        pointer-events: auto;
327        cursor: var(--media-cursor, pointer);
328        -webkit-tap-highlight-color: transparent;
329      }
330
331      
332      :host(:focus-visible) {
333        box-shadow: var(--media-focus-box-shadow, inset 0 0 0 2px rgb(27 127 204 / .9));
334        outline: 0;
335      }
336      
337      :host(:where(:focus)) {
338        box-shadow: none;
339        outline: 0;
340      }
341
342      :host(:hover) {
343        background: var(--media-control-hover-background, rgba(50 50 70 / .7));
344      }
345
346      svg, img, ::slotted(svg), ::slotted(img) {
347        width: var(--media-button-icon-width);
348        height: var(--media-button-icon-height, var(--media-control-height, 24px));
349        transform: var(--media-button-icon-transform);
350        transition: var(--media-button-icon-transition);
351        fill: var(--media-icon-color, var(--media-primary-color, rgb(238 238 238)));
352        vertical-align: middle;
353        max-width: 100%;
354        max-height: 100%;
355        min-width: 100%;
356      }
357
358      media-tooltip {
359        
360        max-width: 0;
361        overflow-x: clip;
362        opacity: 0;
363        transition: opacity .3s, max-width 0s 9s;
364      }
365
366      :host(:hover) media-tooltip,
367      :host(:focus-visible) media-tooltip {
368        max-width: 100vw;
369        opacity: 1;
370        transition: opacity .3s;
371      }
372
373      :host([notooltip]) slot[name="tooltip"] {
374        display: none;
375      }
376    </style>
377
378    ${this.getSlotTemplateHTML(e,t)}
379
380    <slot name="tooltip">
381      <media-tooltip part="tooltip" aria-hidden="true">
382        <template shadowrootmode="${mY.shadowRootOptions.mode}">
383          ${mY.getTemplateHTML({})}
384        </template>
385        <slot name="tooltip-content">
386          ${this.getTooltipContentHTML(e)}
387        </slot>
388      </media-tooltip>
389    </slot>
390  `},m2.getSlotTemplateHTML=function(e,t){return`
391    <slot></slot>
392  `},m2.getTooltipContentHTML=function(){return""},c4.customElements.get("media-chrome-button")||c4.customElements.define("media-chrome-button",m2);let m3=`<svg aria-hidden="true" viewBox="0 0 26 24">
393  <path d="M22.13 3H3.87a.87.87 0 0 0-.87.87v13.26a.87.87 0 0 0 .87.87h3.4L9 16H5V5h16v11h-4l1.72 2h3.4a.87.87 0 0 0 .87-.87V3.87a.87.87 0 0 0-.86-.87Zm-8.75 11.44a.5.5 0 0 0-.76 0l-4.91 5.73a.5.5 0 0 0 .38.83h9.82a.501.501 0 0 0 .38-.83l-4.91-5.73Z"/>
394</svg>
395`,m4=e=>{let t=e.mediaIsAirplaying?cq("stop airplay"):cq("start airplay");e.setAttribute("aria-label",t)};class m5 extends m2{static get observedAttributes(){return[...super.observedAttributes,cD.MEDIA_IS_AIRPLAYING,cD.MEDIA_AIRPLAY_UNAVAILABLE]}connectedCallback(){super.connectedCallback(),m4(this)}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===cD.MEDIA_IS_AIRPLAYING&&m4(this)}get mediaIsAirplaying(){return fu(this,cD.MEDIA_IS_AIRPLAYING)}set mediaIsAirplaying(e){fc(this,cD.MEDIA_IS_AIRPLAYING,e)}get mediaAirplayUnavailable(){return ff(this,cD.MEDIA_AIRPLAY_UNAVAILABLE)}set mediaAirplayUnavailable(e){fm(this,cD.MEDIA_AIRPLAY_UNAVAILABLE,e)}handleClick(){let e=new c4.CustomEvent(cL.MEDIA_AIRPLAY_REQUEST,{composed:!0,bubbles:!0});this.dispatchEvent(e)}}m5.getSlotTemplateHTML=function(e){return`
396    <style>
397      :host([${cD.MEDIA_IS_AIRPLAYING}]) slot[name=icon] slot:not([name=exit]) {
398        display: none !important;
399      }
400
401      
402      :host(:not([${cD.MEDIA_IS_AIRPLAYING}])) slot[name=icon] slot:not([name=enter]) {
403        display: none !important;
404      }
405
406      :host([${cD.MEDIA_IS_AIRPLAYING}]) slot[name=tooltip-enter],
407      :host(:not([${cD.MEDIA_IS_AIRPLAYING}])) slot[name=tooltip-exit] {
408        display: none;
409      }
410    </style>
411
412    <slot name="icon">
413      <slot name="enter">${m3}</slot>
414      <slot name="exit">${m3}</slot>
415    </slot>
416  `},m5.getTooltipContentHTML=function(){return`
417    <slot name="tooltip-enter">${cq("start airplay")}</slot>
418    <slot name="tooltip-exit">${cq("stop airplay")}</slot>
419  `},c4.customElements.get("media-airplay-button")||c4.customElements.define("media-airplay-button",m5);let m8=`<svg aria-hidden="true" viewBox="0 0 26 24">
420  <path d="M22.83 5.68a2.58 2.58 0 0 0-2.3-2.5c-3.62-.24-11.44-.24-15.06 0a2.58 2.58 0 0 0-2.3 2.5c-.23 4.21-.23 8.43 0 12.64a2.58 2.58 0 0 0 2.3 2.5c3.62.24 11.44.24 15.06 0a2.58 2.58 0 0 0 2.3-2.5c.23-4.21.23-8.43 0-12.64Zm-11.39 9.45a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.92 3.92 0 0 1 .92-2.77 3.18 3.18 0 0 1 2.43-1 2.94 2.94 0 0 1 2.13.78c.364.359.62.813.74 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.17 1.61 1.61 0 0 0-1.29.58 2.79 2.79 
4200 0 0-.5 1.89 3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.48 1.48 0 0 0 1-.37 2.1 2.1 0 0 0 .59-1.14l1.4.44a3.23 3.23 0 0 1-1.07 1.69Zm7.22 0a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.88 3.88 0 0 1 .93-2.77 3.14 3.14 0 0 1 2.42-1 3 3 0 0 1 2.16.82 2.8 2.8 0 0 1 .73 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.21 1.61 1.61 0 0 0-1.29.58A2.79 2.79 0 0 0 15 12a3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.44 1.44 0 0 0 1-.37 2.1 2.1 0 0 0 .6-1.15l1.4.44a3.17 3.17 0 0 1-1.1 1.7Z"/>
421</svg>`,m6=`<svg aria-hidden="true" viewBox="0 0 26 24">
422  <path d="M17.73 14.09a1.4 1.4 0 0 1-1 .37 1.579 1.579 0 0 1-1.27-.58A3 3 0 0 1 15 12a2.8 2.8 0 0 1 .5-1.85 1.63 1.63 0 0 1 1.29-.57 1.47 1.47 0 0 1 1.51 1.2l1.43-.34A2.89 2.89 0 0 0 19 9.07a3 3 0 0 0-2.14-.78 3.14 3.14 0 0 0-2.42 1 3.91 3.91 0 0 0-.93 2.78 3.74 3.74 0 0 0 .92 2.66 3.07 3.07 0 0 0 2.34 1 3.07 3.07 0 0 0 1.91-.57 3.17 3.17 0 0 0 1.07-1.74l-1.4-.45c-.083.43-.3.822-.62 1.12Zm-7.22 0a1.43 1.43 0 0 1-1 .37 1.58 1.58 0 0 1-1.27-.58A3 3 0 0 1 7.76 12a2.8 2.8 0 0 1 .5-1.85 1.63 1.63 0 0 1 1.29-.57 1.47 1.47 0 0 1 1.51 1.2l1.43-.34a2.81 2.81 0 0 0-.74-1.32 2.94 2.94 0 0 0-2.13-.78 3.18 3.18 0 0 0-2.43 1 4 4 0 0 0-.92 2.78 3.74 3.74 0 0 0 .92 2.66 3.07 3.07 0 0 0 2.34 1 3.07 3.07 0 0 0 1.91-.57 3.23 3.23 0 0 0 1.07-1.74l-1.4-.45a2.06 2.06 0 0 1-.6 1.07Zm12.32-8.41a2.59 2.59 0 0 0-2.3-2.51C18.72 3.05 15.86 3 13 3c-2.86 0-5.72.05-7.53.17a2.59 2.59 0 0 0-2.3 2.51c-.23 4.207-.23 8.423 0 12.63a2.57 2.57 0 0 0 2.3 2.5c1.81.13 4.67.19 7.53.19 2.86 0 5.72-.06 7.53-.19a2.57 2.57 0 0 0 2.3-2.5c.23-4.207.23-8.423 0-12.63Zm-1.49 12.53a1.11 1.11 0 0 1-.91 1.11c-1.67.11-4.45.18-7.43.18-2.98 0-5.76-.07-7.43-.18a1.11 1.11 0 0 1-.91-1.11c-.21-4.14-.21-8.29 0-12.43a1.11 1.11 0 0 1 .91-1.11C7.24 4.56 10 4.49 13 4.49s5.76.07 7.43.18a1.11 1.11 0 0 1 .91 1.11c.21 4.14.21 8.29 0 12.43Z"/>
423</svg>`,m9=e=>{var t;e.setAttribute("aria-checked",(!!(null==(t=e.mediaSubtitlesShowing)?void 0:t.length)||e.hasAttribute(cD.MEDIA_SUBTITLES_SHOWING)).toString())};class m7 extends m2{static get observedAttributes(){return[...super.observedAttributes,cD.MEDIA_SUBTITLES_LIST,cD.MEDIA_SUBTITLES_SHOWING]}connectedCallback(){super.connectedCallback(),this.setAttribute("role","button"),this.setAttribute("aria-label",cq("closed captions")),m9(this)}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===cD.MEDIA_SUBTITLES_SHOWING&&m9(this)}get mediaSubtitlesList(){return pe(this,cD.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){pt(this,cD.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return pe(this,cD.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){pt(this,cD.MEDIA_SUBTITLES_SHOWING,e)}handleClick(){this.dispatchEvent(new c4.CustomEvent(cL.MEDIA_TOGGLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0}))}}m7.getSlotTemplateHTML=function(e){return`
424    <style>
425      :host([aria-checked="true"]) slot[name=off] {
426        display: none !important;
427      }
428
429      
430      :host(:not([aria-checked="true"])) slot[name=on] {
431        display: none !important;
432      }
433
434      :host([aria-checked="true"]) slot[name=tooltip-enable],
435      :host(:not([aria-checked="true"])) slot[name=tooltip-disable] {
436        display: none;
437      }
438    </style>
439
440    <slot name="icon">
441      <slot name="on">${m8}</slot>
442      <slot name="off">${m6}</slot>
443    </slot>
444  `},m7.getTooltipContentHTML=function(){return`
445    <slot name="tooltip-enable">${cq("Enable captions")}</slot>
446    <slot name="tooltip-disable">${cq("Disable captions")}</slot>
447  `};let pe=(e,t)=>{let i=e.getAttribute(t);return i?fH(i):[]},pt=(e,t,i)=>{if(!(null==i?void 0:i.length))return void e.removeAttribute(t);let r=fK(i);e.getAttribute(t)!==r&&e.setAttribute(t,r)};c4.customElements.get("media-captions-button")||c4.customElements.define("media-captions-button",m7);let pi=e=>{let t=e.mediaIsCasting?cq("stop casting"):cq("start casting");e.setAttribute("aria-label",t)};class pr extends m2{static get observedAttributes(){return[...super.observedAttributes,cD.MEDIA_IS_CASTING,cD.MEDIA_CAST_UNAVAILABLE]}connectedCallback(){super.connectedCallback(),pi(this)}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===cD.MEDIA_IS_CASTING&&pi(this)}get mediaIsCasting(){return fu(this,cD.MEDIA_IS_CASTING)}set mediaIsCasting(e){fc(this,cD.MEDIA_IS_CASTING,e)}get mediaCastUnavailable(){return ff(this,cD.MEDIA_CAST_UNAVAILABLE)}set mediaCastUnavailable(e){fm(this,cD.MEDIA_CAST_UNAVAILABLE,e)}handleClick(){let e=this.mediaIsCasting?cL.MEDIA_EXIT_CAST_REQUEST:cL.MEDIA_ENTER_CAST_REQUEST;this.dispatchEvent(new c4.CustomEvent(e,{composed:!0,bubbles:!0}))}}pr.getSlotTemplateHTML=function(e){return`
448    <style>
449      :host([${cD.MEDIA_IS_CASTING}]) slot[name=icon] slot:not([name=exit]) {
450        display: none !important;
451      }
452
453      
454      :host(:not([${cD.MEDIA_IS_CASTING}])) slot[name=icon] slot:not([name=enter]) {
455        display: none !important;
456      }
457
458      :host([${cD.MEDIA_IS_CASTING}]) slot[name=tooltip-enter],
459      :host(:not([${cD.MEDIA_IS_CASTING}])) slot[name=tooltip-exit] {
460        display: none;
461      }
462    </style>
463
464    <slot name="icon">
465      <slot name="enter"><svg aria-hidden="true" viewBox="0 0 24 24"><g><path class="cast_caf_icon_arch0" d="M1,18 L1,21 L4,21 C4,19.3 2.66,18 1,18 L1,18 Z"/><path class="cast_caf_icon_arch1" d="M1,14 L1,16 C3.76,16 6,18.2 6,21 L8,21 C8,17.13 4.87,14 1,14 L1,14 Z"/><path class="cast_caf_icon_arch2" d="M1,10 L1,12 C5.97,12 10,16.0 10,21 L12,21 C12,14.92 7.07,10 1,10 L1,10 Z"/><path class="cast_caf_icon_box" d="M21,3 L3,3 C1.9,3 1,3.9 1,5 L1,8 L3,8 L3,5 L21,5 L21,19 L14,19 L14,21 L21,21 C22.1,21 23,20.1 23,19 L23,5 C23,3.9 22.1,3 21,3 L21,3 Z"/></g></svg></slot>
466      <slot name="exit"><svg aria-hidden="true" viewBox="0 0 24 24"><g><path class="cast_caf_icon_arch0" d="M1,18 L1,21 L4,21 C4,19.3 2.66,18 1,18 L1,18 Z"/><path class="cast_caf_icon_arch1" d="M1,14 L1,16 C3.76,16 6,18.2 6,21 L8,21 C8,17.13 4.87,14 1,14 L1,14 Z"/><path class="cast_caf_icon_arch2" d="M1,10 L1,12 C5.97,12 10,16.0 10,21 L12,21 C12,14.92 7.07,10 1,10 L1,10 Z"/><path class="cast_caf_icon_box" d="M21,3 L3,3 C1.9,3 1,3.9 1,5 L1,8 L3,8 L3,5 L21,5 L21,19 L14,19 L14,21 L21,21 C22.1,21 23,20.1 23,19 L23,5 C23,3.9 22.1,3 21,3 L21,3 Z"/><path class="cast_caf_icon_boxfill" d="M5,7 L5,8.63 C8,8.6 13.37,14 13.37,17 L19,17 L19,7 Z"/></g></svg></slot>
467    </slot>
468  `},pr.getTooltipContentHTML=function(){return`
469    <slot name="tooltip-enter">${cq("Start casting")}</slot>
470    <slot name="tooltip-exit">${cq("Stop casting")}</slot>
471  `},c4.customElements.get("media-cast-button")||c4.customElements.define("media-cast-button",pr);var ps=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},pa=(e,t,i)=>(ps(e,t,"read from private field"),i?i.call(e):t.get(e)),pn=(e,t,i)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,i)},pl=(e,t,i,r)=>(ps(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i),po=(e,t,i)=>(ps(e,t,"access private method"),i);let pd="open";class ph extends c4.HTMLElement{constructor(){super(),pn(this,es),pn(this,en),pn(this,eo),pn(this,eh),pn(this,ec),pn(this,em),pn(this,et,!1),pn(this,ei,null),pn(this,er,null)}static get observedAttributes(){return[pd,"anchor"]}get open(){return fu(this,pd)}set open(e){fc(this,pd,e)}handleEvent(e){switch(e.type){case"invoke":po(this,eh,eu).call(this,e);break;case"focusout":po(this,ec,ef).call(this,e);break;case"keydown":po(this,em,ep).call(this,e)}}connectedCallback(){po(this,es,ea).call(this),this.role||(this.role="dialog"),this.addEventListener("invoke",this),this.addEventListener("focusout",this),this.addEventListener("keydown",this)}disconnectedCallback(){this.removeEventListener("invoke",this),this.removeEventListener("focusout",this),this.removeEventListener("keydown",this)}attributeChangedCallback(e,t,i){po(this,es,ea).call(this),e===pd&&i!==t&&(this.open?po(this,en,el).call(this):po(this,eo,ed).call(this))}focus(){pl(this,ei,function e(t=document){var i;let r=null==t?void 0:t.activeElement;return r?null!=(i=e(r.shadowRoot))?i:r:null}());let e=!this.dispatchEvent(new Event("focus",{composed:!0,cancelable:!0})),t=!this.dispatchEvent(new Event("focusin",{composed:!0,bubbles:!0,cancelable:!0}));if(e||t)return;
471let i=this.querySelector('[autofocus], [tabindex]:not([tabindex="-1"]), [role="menu"]');null==i||i.focus()}get keysUsed(){return["Escape","Tab"]}}et=new WeakMap,ei=new WeakMap,er=new WeakMap,es=new WeakSet,ea=function(){if(!pa(this,et)&&(pl(this,et,!0),!this.shadowRoot)){this.attachShadow(this.constructor.shadowRootOptions);let e=ft(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e),queueMicrotask(()=>{let{style:e}=fl(this.shadowRoot,":host");e.setProperty("transition","display .15s, visibility .15s, opacity .15s ease-in, transform .15s ease-in")})}},en=new WeakSet,el=function(){var e;null==(e=pa(this,er))||e.setAttribute("aria-expanded","true"),this.dispatchEvent(new Event("open",{composed:!0,bubbles:!0})),this.addEventListener("transitionend",()=>this.focus(),{once:!0})},eo=new WeakSet,ed=function(){var e;null==(e=pa(this,er))||e.setAttribute("aria-expanded","false"),this.dispatchEvent(new Event("close",{composed:!0,bubbles:!0}))},eh=new WeakSet,eu=function(e){pl(this,er,e.relatedTarget),fs(this,e.relatedTarget)||(this.open=!this.open)},ec=new WeakSet,ef=function(e){var t;!fs(this,e.relatedTarget)&&(null==(t=pa(this,ei))||t.focus(),pa(this,er)&&pa(this,er)!==e.relatedTarget&&this.open&&(this.open=!1))},em=new WeakSet,ep=function(e){var t,i,r,s,a;let{key:n,ctrlKey:l,altKey:o,metaKey:d}=e;l||o||d||this.keysUsed.includes(n)&&(e.preventDefault(),e.stopPropagation(),"Tab"===n?(e.shiftKey?null==(i=null==(t=this.previousElementSibling)?void 0:t.focus)||i.call(t):null==(s=null==(r=this.nextElementSibling)?void 0:r.focus)||s.call(r),this.blur()):"Escape"===n&&(null==(a=pa(this,ei))||a.focus(),this.open=!1))},ph.shadowRootOptions={mode:"open"},ph.getTemplateHTML=function(e){return`
472    <style>
473      :host {
474        font: var(--media-font,
475          var(--media-font-weight, normal)
476          var(--media-font-size, 14px) /
477          var(--media-text-content-height, var(--media-control-height, 24px))
478          var(--media-font-family, helvetica neue, segoe ui, roboto, arial, sans-serif));
479        color: var(--media-text-color, var(--media-primary-color, rgb(238 238 238)));
480        display: var(--media-dialog-display, inline-flex);
481        justify-content: center;
482        align-items: center;
483        
484        transition-behavior: allow-discrete;
485        visibility: hidden;
486        opacity: 0;
487        transform: translateY(2px) scale(.99);
488        pointer-events: none;
489      }
490
491      :host([open]) {
492        transition: display .2s, visibility 0s, opacity .2s ease-out, transform .15s ease-out;
493        visibility: visible;
494        opacity: 1;
495        transform: translateY(0) scale(1);
496        pointer-events: auto;
497      }
498
499      #content {
500        display: flex;
501        position: relative;
502        box-sizing: border-box;
503        width: min(320px, 100%);
504        word-wrap: break-word;
505        max-height: 100%;
506        overflow: auto;
507        text-align: center;
508        line-height: 1.4;
509      }
510    </style>
511    ${this.getSlotTemplateHTML(e)}
512  `},ph.getSlotTemplateHTML=function(e){return`
513    <slot id="content"></slot>
514  `},c4.customElements.get("media-chrome-dialog")||c4.customElements.define("media-chrome-dialog",ph);var pu=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},pc=(e,t,i)=>(pu(e,t,"read from private field"),i?i.call(e):t.get(e)),pf=(e,t,i)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,i)},pm=(e,t,i,r)=>(pu(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i),pp=(e,t,i)=>(pu(e,t,"access private method"),i);class pg extends c4.HTMLElement{constructor(){if(super(),pf(this,ek),pf(this,eR),pf(this,ew),pf(this,eC),pf(this,ex),pf(this,eO),pf(this,eU),pf(this,e$),pf(this,eg,void 0),pf(this,ev,void 0),pf(this,eE,void 0),pf(this,ey,void 0),pf(this,eb,{}),pf(this,eT,[]),pf(this,e_,()=>{if(this.range.matches(":focus-visible")){let{style:e}=fl(this.shadowRoot,":host");e.setProperty("--_focus-visible-box-shadow","var(--_focus-box-shadow)")}}),pf(this,eA,()=>{let{style:e}=fl(this.shadowRoot,":host");e.removeProperty("--_focus-visible-box-shadow")}),pf(this,eS,()=>{let e=this.shadowRoot.querySelector("#segments-clipping");e&&e.parentNode.append(e)}),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);const e=ft(this.attributes),t=this.constructor.getTemplateHTML(e);this.shadowRoot.setHTMLUnsafe?this.shadowRoot.setHTMLUnsafe(t):this.shadowRoot.innerHTML=t}this.container=this.shadowRoot.querySelector("#container"),pm(this,eE,this.shadowRoot.querySelector("#startpoint")),pm(this,ey,this.shadowRoot.querySelector("#endpoint")),this.range=this.shadowRoot.querySelector("#range"),this.appearance=this.shadowRoot.querySelector("#appearance")}static get observedAttributes(){return["disabled","aria-disabled",cR.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,i){var r,s,a,n,l;e===cR.MEDIA_CONTROLLER?(t&&(null==(s=null==(r=pc(this,eg))?void 0:r.unassociateElement)||s.call(r,this),pm(this,eg,null)),i&&this.isConnected&&(pm(this,eg,null==(a=this.getRootNode())?void 0:a.getElementById(i)),null==(l=null==(n=pc(this,eg))?void 0:n.associateElement)||l.call(n,this))):("disabled"===e||"aria-disabled"===e&&t!==i)&&(null==i?(this.range.removeAttribute(e),pp(this,eR,eI).call(this)):(this.range.setAttribute(e,i),pp(this,ew,eD).call(this)))}connectedCallback(){var e,t,i;let{style:r}=fl(this.shadowRoot,":host");r.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`),pc(this,eb).pointer=fl(this.shadowRoot,"#pointer"),pc(this,eb).progress=fl(this.shadowRoot,"#progress"),pc(this,eb).thumb=fl(this.shadowRoot,'#thumb, ::slotted([slot="thumb"])'),pc(this,eb).activeSegment=fl(this.shadowRoot,"#segments-clipping rect:nth-child(0)");let s=this.getAttribute(cR.MEDIA_CONTROLLER);s&&(pm(this,eg,null==(e=this.getRootNode())?void 0:e.getElementById(s)),null==(i=null==(t=pc(this,eg))?void 0:t.associateElement)||i.call(t,this)),this.updateBar(),this.shadowRoot.addEventListener("focusin",pc(this,e_)),this.shadowRoot.addEventListener("focusout",pc(this,eA)),pp(this,eR,eI).call(this),c7(this.container,pc(this,eS))}disconnectedCallback(){var e,t;pp(this,ew,eD).call(this),null==(t=null==(e=pc(this,eg))?void 0:e.unassociateElement)||t.call(e,this),pm(this,eg,null),this.shadowRoot.removeEventListener("focusin",pc(this,e_)),this.shadowRoot.removeEventListener("focusout",pc(this,eA)),fe(this.container,pc(this,eS))}updatePointerBar(e){var t;null==(t=pc(this,eb).pointer)||t.style.setProperty("width",`${100*this.getPointerRatio(e)}%`)}updateBar(){var e,t;let i=100*this.range.valueAsNumber;null==(e=pc(this,eb).progress)||e.style.setProperty("width",`${i}%`),null==(t=pc(this,eb).thumb)||t.style.setProperty("left",`${i}%`)}updateSegments(e){let t=this.shadowRoot.querySelector("#segments-clipping");if(t.textContent="",this.container.classList.toggle("segments",!!(null==e?void 0:e.length)),!(null==e?void 0:e.length))return;let i=[...new Set([+this.range.min,...e.flatMap(e=>[e.start,e.end]),+this.range.max])];pm(this,eT,[...i]);let r=i.pop();for(let[e,s]of i.entries()){let[a,n]=[0===e,e===i.length-1],l=a?"calc(var(--segments-gap) / -1)":`${100*s}%`,o=n?r:i[e+1],d=`calc(${(o-s)*100}%${a||n?"":" - var(--segments-gap)"})`,h=c5.createElementNS("http://www.w3.org/2000/svg","rect"),u=fo(this.shadowRoot,`#segments-clipping rect:nth-child(${e+1})`);u.style.setProperty("x",l),u.style.setProperty("width",d),t.append(h)}}getPointerRatio(e){var t,i,r,s;let a,n,l;return t=e.clientX,i=e.clientY,r=pc(this,eE).getBoundingClientRect(),a=(s=pc(this,ey).getBoundingClientRect()).x-r.x,0==(l=a*a+(n=s.y-r.y)*n)?0:Math.max(0,Math.min(1,((t-r.x)*a+(i-r.y)*n)/l))}get dragging(){return this.hasAttribute("dragging")}handleEvent(e){switch(e.type){case"pointermove":pp(this,e$,eB).call(this,e);break;case"input":this.updateBar();break;case"pointerenter":pp(this,ex,eM).call(this,e);break;case"pointerdown":pp(this,eC,eP).call(this,e);break;case"pointerup":pp(this,eO,eN).call(this);break;case"pointerleave":pp(this,eU,eF).call(this)}}get keysUsed(){return["ArrowUp","ArrowRight","ArrowDown","ArrowLeft"]}}eg=new WeakMap,ev=new WeakMap,eE=new WeakMap,ey=new WeakMap,eb=new WeakMap,eT=new WeakMap,e_=new WeakMap,eA=new WeakMap,eS=new WeakMap,ek=new WeakSet,eL=function(e){let t=pc(this,eb).activeSegment;if(!t)return;let i=this.getPointerRatio(e),r=pc(this,eT).findIndex((e,t,r)=>{let s=r[t+1];return null!=s&&i>=e&&i<=s}),s=`#segments-clipping rect:nth-child(${r+1})`;t.selectorText==s&&t.style.transform||(t.selectorText=s,t.style.setProperty("transform","var(--media-range-segment-hover-transform, scaleY(2))"))},eR=new WeakSet,eI=function(){!this.hasAttribute("disabled")&&this.isConnected&&(this.addEventListener("input",this),this.addEventListener("pointerdown",this),this.addEventListener("pointerenter",this))},ew=new WeakSet,eD=function(){var e,t;this.removeEventListener("input",this),this.removeEventListener("pointerdown",this),this.removeEventListener("pointerenter",this),this.removeEventListener("pointerleave",this),null==(e=c4.window)||e.removeEventListener("pointerup",this),null==(t=c4.window)||t.removeEventListener("pointermove",this)},eC=new WeakSet,eP=function(e){var t;pm(this,ev,e.composedPath().includes(this.range)),null==(t=c4.window)||t.addEventListener("pointerup",this,{once:!0})},ex=new WeakSet,eM=function(e){var t;"mouse"!==e.pointerType&&pp(this,eC,eP).call(this,e),this.addEventListener("pointerleave",this,{once:!0}),null==(t=c4.window)||t.addEventListener("pointermove",this)},eO=new WeakSet,eN=function(){var e;null==(e=c4.window)||e.removeEventListener("pointerup",this),this.toggleAttribute("dragging",!1),this.range.disabled=this.hasAttribute("disabled")},eU=new WeakSet,eF=function(){var e,t;this.removeEventListener("pointerleave",this),null==(e=c4.window)||e.removeEventListener("pointermove",this),this.toggleAttribute("dragging",!1),this.range.disabled=this.hasAttribute("disabled"),null==(t=pc(this,eb).activeSegment)||t.style.removeProperty("transform")},e$=new WeakSet,eB=function(e){("pen"!==e.pointerType||0!==e.buttons)&&(this.toggleAttribute("dragging",1===e.buttons||"mouse"!==e.pointerType),this.updatePointerBar(e),pp(this,ek,eL).call(this,e),this.dragging&&("mouse"!==e.pointerType||!pc(this,ev))&&(this.range.disabled=!0,this.range.valueAsNumber=this.getPointerRatio(e),this.range.dispatchEvent(new Event("input",{bubbles:!0,composed:!0}))))},pg.shadowRootOptions={mode:"open"},pg.getTemplateHTML=function(e){return`
515    <style>
516      :host {
517        --_focus-box-shadow: var(--media-focus-box-shadow, inset 0 0 0 2px rgb(27 127 204 / .9));
518        --_media-range-padding: var(--media-range-padding, var(--media-control-padding, 10px));
519
520        box-shadow: var(--_focus-visible-box-shadow, none);
521        background: var(--media-control-background, var(--media-secondary-color, rgb(20 20 30 / .7)));
522        height: calc(var(--media-control-height, 24px) + 2 * var(--_media-range-padding));
523        display: inline-flex;
524        align-items: center;
525        
526        vertical-align: middle;
527        box-sizing: border-box;
528        position: relative;
529        width: 100px;
530        transition: background .15s linear;
531        cursor: var(--media-cursor, pointer);
532        pointer-events: auto;
533        touch-action: none; 
534      }
535
536      
537      input[type=range]:focus {
538        outline: 0;
539      }
540      input[type=range]:focus::-webkit-slider-runnable-track {
541        outline: 0;
542      }
543
544      :host(:hover) {
545        background: var(--media-control-hover-background, rgb(50 50 70 / .7));
546      }
547
548      #leftgap {
549        padding-left: var(--media-range-padding-left, var(--_media-range-padding));
550      }
551
552      #rightgap {
553        padding-right: var(--media-range-padding-right, var(--_media-range-padding));
554      }
555
556      #startpoint,
557      #endpoint {
558        position: absolute;
559      }
560
561      #endpoint {
562        right: 0;
563      }
564
565      #container {
566        
567        width: var(--media-range-track-width, 100%);
568        transform: translate(var(--media-range-track-translate-x, 0px), var(--media-range-track-translate-y, 0px));
569        position: relative;
570        height: 100%;
571        display: flex;
572        align-items: center;
573        min-width: 40px;
574      }
575
576      #range {
577        
578        display: var(--media-time-range-hover-display, block);
579        bottom: var(--media-time-range-hover-bottom, -7px);
580        height: var(--media-time-range-hover-height, max(100% + 7px, 25px));
581        width: 100%;
582        position: absolute;
583        cursor: var(--media-cursor, pointer);
584
585        -webkit-appearance: none; 
586        -webkit-tap-highlight-color: transparent;
587        background: transparent; 
588        margin: 0;
589        z-index: 1;
590      }
591
592      @media (hover: hover) {
593        #range {
594          bottom: var(--media-time-range-hover-bottom, -5px);
595          height: var(--media-time-range-hover-height, max(100% + 5px
vendor: 4,756 bytes, lines 595-750
595, 20px));
596        }
597      }
598
599      
600      
601      #range::-webkit-slider-thumb {
602        -webkit-appearance: none;
603        background: transparent;
604        width: .1px;
605        height: .1px;
606      }
607
608      
609      #range::-moz-range-thumb {
610        background: transparent;
611        border: transparent;
612        width: .1px;
613        height: .1px;
614      }
615
616      #appearance {
617        height: var(--media-range-track-height, 4px);
618        display: flex;
619        flex-direction: column;
620        justify-content: center;
621        width: 100%;
622        position: absolute;
623        
624        will-change: transform;
625      }
626
627      #track {
628        background: var(--media-range-track-background, rgb(255 255 255 / .2));
629        border-radius: var(--media-range-track-border-radius, 1px);
630        border: var(--media-range-track-border, none);
631        outline: var(--media-range-track-outline);
632        outline-offset: var(--media-range-track-outline-offset);
633        backdrop-filter: var(--media-range-track-backdrop-filter);
634        -webkit-backdrop-filter: var(--media-range-track-backdrop-filter);
635        box-shadow: var(--media-range-track-box-shadow, none);
636        position: absolute;
637        width: 100%;
638        height: 100%;
639        overflow: hidden;
640      }
641
642      #progress,
643      #pointer {
644        position: absolute;
645        height: 100%;
646        will-change: width;
647      }
648
649      #progress {
650        background: var(--media-range-bar-color, var(--media-primary-color, rgb(238 238 238)));
651        transition: var(--media-range-track-transition);
652      }
653
654      #pointer {
655        background: var(--media-range-track-pointer-background);
656        border-right: var(--media-range-track-pointer-border-right);
657        transition: visibility .25s, opacity .25s;
658        visibility: hidden;
659        opacity: 0;
660      }
661
662      @media (hover: hover) {
663        :host(:hover) #pointer {
664          transition: visibility .5s, opacity .5s;
665          visibility: visible;
666          opacity: 1;
667        }
668      }
669
670      #thumb,
671      ::slotted([slot=thumb]) {
672        width: var(--media-range-thumb-width, 10px);
673        height: var(--media-range-thumb-height, 10px);
674        transition: var(--media-range-thumb-transition);
675        transform: var(--media-range-thumb-transform, none);
676        opacity: var(--media-range-thumb-opacity, 1);
677        translate: -50%;
678        position: absolute;
679        left: 0;
680        cursor: var(--media-cursor, pointer);
681      }
682
683      #thumb {
684        border-radius: var(--media-range-thumb-border-radius, 10px);
685        background: var(--media-range-thumb-background, var(--media-primary-color, rgb(238 238 238)));
686        box-shadow: var(--media-range-thumb-box-shadow, 1px 1px 1px transparent);
687        border: var(--media-range-thumb-border, none);
688      }
689
690      :host([disabled]) #thumb {
691        background-color: #777;
692      }
693
694      .segments #appearance {
695        height: var(--media-range-segment-hover-height, 7px);
696      }
697
698      #track {
699        clip-path: url(#segments-clipping);
700      }
701
702      #segments {
703        --segments-gap: var(--media-range-segments-gap, 2px);
704        position: absolute;
705        width: 100%;
706        height: 100%;
707      }
708
709      #segments-clipping {
710        transform: translateX(calc(var(--segments-gap) / 2));
711      }
712
713      #segments-clipping:empty {
714        display: none;
715      }
716
717      #segments-clipping rect {
718        height: var(--media-range-track-height, 4px);
719        y: calc((var(--media-range-segment-hover-height, 7px) - var(--media-range-track-height, 4px)) / 2);
720        transition: var(--media-range-segment-transition, transform .1s ease-in-out);
721        transform: var(--media-range-segment-transform, scaleY(1));
722        transform-origin: center;
723      }
724
725      /* Visible label for accessibility - positioned off-screen but technically visible (Firefox requires visible labels) */
726      #range-label {
727        position: absolute;
728        left: -10000px;
729        background: var(--media-control-background, var(--media-secondary-color, rgb(20 20 30 / .7)));
730        pointer-events: none;
731      }
732    </style>
733    <div id="leftgap"></div>
734    <div id="container">
735      <div id="startpoint"></div>
736      <div id="endpoint"></div>
737      <div id="appearance">
738        <div id="track" part="track">
739          <div id="pointer"></div>
740          <div id="progress" part="progress"></div>
741        </div>
742        <slot name="thumb">
743          <div id="thumb" part="thumb"></div>
744        </slot>
745        <svg id="segments" aria-hidden="true"><clipPath id="segments-clipping"></clipPath></svg>
746      </div>
747        <input id="range" type="range" min="0" max="1" step="any" value="0">
748        <label for="range" id="range-label"></label>
749
750      ${this.getContainerTemplateHTML(
750e)}
751    </div>
752    <div id="rightgap"></div>
753  `},pg.getContainerTemplateHTML=function(e){return""},c4.customElements.get("media-chrome-range")||c4.customElements.define("media-chrome-range",pg);var pv=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},pE=(e,t,i)=>(pv(e,t,"read from private field"),i?i.call(e):t.get(e)),py=(e,t,i,r)=>(pv(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i);class pb extends c4.HTMLElement{constructor(){if(super(),((e,t,i)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,i)})(this,eH,void 0),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);const e=ft(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e)}}static get observedAttributes(){return[cR.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,i){var r,s,a,n,l;e===cR.MEDIA_CONTROLLER&&(t&&(null==(s=null==(r=pE(this,eH))?void 0:r.unassociateElement)||s.call(r,this),py(this,eH,null)),i&&this.isConnected&&(py(this,eH,null==(a=this.getRootNode())?void 0:a.getElementById(i)),null==(l=null==(n=pE(this,eH))?void 0:n.associateElement)||l.call(n,this)))}connectedCallback(){var e,t,i;let r=this.getAttribute(cR.MEDIA_CONTROLLER);r&&(py(this,eH,null==(e=this.getRootNode())?void 0:e.getElementById(r)),null==(i=null==(t=pE(this,eH))?void 0:t.associateElement)||i.call(t,this))}disconnectedCallback(){var e,t;null==(t=null==(e=pE(this,eH))?void 0:e.unassociateElement)||t.call(e,this),py(this,eH,null)}}eH=new WeakMap,pb.shadowRootOptions={mode:"open"},pb.getTemplateHTML=function(e){return`
754    <style>
755      :host {
756        
757        box-sizing: border-box;
758        display: var(--media-control-display, var(--media-control-bar-display, inline-flex));
759        color: var(--media-text-color, var(--media-primary-color, rgb(238 238 238)));
760        --media-loading-indicator-icon-height: 44px;
761      }
762
763      ::slotted(media-time-range),
764      ::slotted(media-volume-range) {
765        min-height: 100%;
766      }
767
768      ::slotted(media-time-range),
769      ::slotted(media-clip-selector) {
770        flex-grow: 1;
771      }
772
773      ::slotted([role="menu"]) {
774        position: absolute;
775      }
776    </style>
777
778    <slot></slot>
779  `},c4.customElements.get("media-control-bar")||c4.customElements.define("media-control-bar",pb);var pT=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},p_=(e,t,i)=>(pT(e,t,"read from private field"),i?i.call(e):t.get(e)),pA=(e,t,i,r)=>(pT(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i);class pS extends c4.HTMLElement{constructor(){if(super(),((e,t,i)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,i)})(this,eG,void 0),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);const e=ft(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e)}}static get observedAttributes(){return[cR.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,i){var r,s,a,n,l;e===cR.MEDIA_CONTROLLER&&(t&&(null==(s=null==(r=p_(this,eG))?void 0:r.unassociateElement)||s.call(r,this),pA(this,eG,null)),i&&this.isConnected&&(pA(this,eG,null==(a=this.getRootNode())?void 0:a.getElementById(i)),null==(l=null==(n=p_(this,eG))?void 0:n.associateElement)||l.call(n,this)))}connectedCallback(){var e,t,i;let{style:r}=fl(this.shadowRoot,":host");r.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`);let s=this.getAttribute(cR.MEDIA_CONTROLLER);s&&(pA(this,eG,null==(e=this.getRootNode())?void 0:e.getElementById(s)),null==(i=null==(t=p_(this,eG))?void 0:t.associateElement)||i.call(t,this))}disconnectedCallback(){var e,t;null==(t=null==(e=p_(this,eG))?void 0:e.unassociateElement)||t.call(e,this),pA(this,eG,null)}}eG=new WeakMap,pS.shadowRootOptions={mode:"open"},pS.getTemplateHTML=function(e,t={}){return`
780    <style>
781      :host {
782        font: var(--media-font,
783          var(--media-font-weight, normal)
784          var(--media-font-size, 14px) /
785          var(--media-text-content-height, var(--media-control-height, 24px))
786          var(--media-font-family, helvetica neue, segoe ui, roboto, arial, sans-serif));
787        color: var(--media-text-color, var(--media-primary-color, rgb(238 238 238)));
788        background: var(--media-text-background, var(--media-control-background, var(--media-secondary-color, rgb(20 20 30 / .7))));
789        padding: var(--media-control-padding, 10px);
790        display: inline-flex;
791        justify-content: center;
792        align-items: center;
793        vertical-align: middle;
794        box-sizing: border-box;
795        text-align: center;
796        pointer-events: auto;
797      }
798
799      
800      :host(:focus-visible) {
801        box-shadow: inset 0 0 0 2px rgb(27 127 204 / .9);
802        outline: 0;
803      }
804
805      
806      :host(:where(:focus)) {
807        box-shadow: none;
808        outline: 0;
809      }
810    </style>
811
812    ${this.getSlotTemplateHTML(e,t)}
813  `},pS.getSlotTemplateHTML=function(e,t){return`
814    <slot></slot>
815  `},c4.customElements.get("media-text-display")||c4.customElements.define("media-text-display",pS);var pk=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},pL=(e,t,i)=>(pk(e,t,"read from private field"),i?i.call(e):t.get(e));class pR extends pS{constructor(){var e;super(),((e,t,i)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,i)})(this,eV,void 0),((e,t,i,r)=>(pk(e,t,"write to private field"),r?r.call(e,i):t.set(e,i)))(this,eV,this.shadowRoot.querySelector("slot")),pL(this,eV).textContent=cQ(null!=(e=this.mediaDuration)?e:0)}static get observedAttributes(){return[...super.observedAttributes,cD.MEDIA_DURATION]}attributeChangedCallback(e,t,i){e===cD.MEDIA_DURATION&&(pL(this,eV).textContent=cQ(+i)),super.attributeChangedCallback(e,t,i)}get mediaDuration(){return fd(this,cD.MEDIA_DURATION)}set mediaDuration(e){fh(this,cD.MEDIA_DURATION,e)}}eV=new WeakMap,pR.getSlotTemplateHTML=function(e,t){return`
816    <slot>${cQ(t.mediaDuration)}</slot>
817  `},c4.customElements.get("media-duration-display")||c4.customElements.define("media-duration-display",pR);let pI={2:cq("Network Error"),3:cq("Decode Error"),4:cq("Source Not Supported"),5:cq("Encryption 
817Error")},pw={2:cq("A network error caused the media download to fail."),3:cq("A media error caused playback to be aborted. The media could be corrupt or your browser does not support this format."),4:cq("An unsupported error occurred. The server or network failed, or your browser does not support this format."),5:cq("The media is encrypted and there are no keys to decrypt it.")},pD=e=>{var t,i;return 1===e.code?null:{title:null!=(t=pI[e.code])?t:`Error ${e.code}`,message:null!=(i=pw[e.code])?i:e.message}};var pC=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)};function pP(e){var t;let{title:i,message:r}=null!=(t=pD(e))?t:{},s="";return i&&(s+=`<slot name="error-${e.code}-title"><h3>${i}</h3></slot>`),r&&(s+=`<slot name="error-${e.code}-message"><p>${r}</p></slot>`),s}let px=[cD.MEDIA_ERROR_CODE,cD.MEDIA_ERROR_MESSAGE];class pM extends ph{constructor(){super(...arguments),((e,t,i)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,i)})(this,eK,null)}static get observedAttributes(){return[...super.observedAttributes,...px]}formatErrorMessage(e){return this.constructor.formatErrorMessage(e)}attributeChangedCallback(e,t,i){var r;if(super.attributeChangedCallback(e,t,i),!px.includes(e))return;let s=null!=(r=this.mediaError)?r:{code:this.mediaErrorCode,message:this.mediaErrorMessage};if(this.open=s.code&&null!==pD(s),this.open&&(this.shadowRoot.querySelector("slot").name=`error-${this.mediaErrorCode}`,this.shadowRoot.querySelector("#content").innerHTML=this.formatErrorMessage(s),!this.hasAttribute("aria-label"))){let{title:e}=pD(s);e&&this.setAttribute("aria-label",e)}}get mediaError(){var e,t;return pC(this,e=eK,"read from private field"),t?t.call(this):e.get(this)}set mediaError(e){var t,i;pC(this,t=eK,"write to private field"),i?i.call(this,e):t.set(this,e)}get mediaErrorCode(){return fd(this,"mediaerrorcode")}set mediaErrorCode(e){fh(this,"mediaerrorcode",e)}get mediaErrorMessage(){return ff(this,"mediaerrormessage")}set mediaErrorMessage(e){fm(this,"mediaerrormessage",e)}}eK=new WeakMap,pM.getSlotTemplateHTML=function(e){return`
818    <style>
819      :host {
820        background: rgb(20 20 30 / .8);
821      }
822
823      #content {
824        display: block;
825        padding: 1.2em 1.5em;
826      }
827
828      h3,
829      p {
830        margin-block: 0 .3em;
831      }
832    </style>
833    <slot name="error-${e.mediaerrorcode}" id="content">
834      ${pP({code:+e.mediaerrorcode,message:e.mediaerrormessage})}
835    </slot>
836  `},pM.formatErrorMessage=pP,c4.customElements.get("media-error-dialog")||c4.customElements.define("media-error-dialog",pM);var pO=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot read from private field");return i?i.call(e):t.get(e)},pN=(e,t,i)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,i)};class pU extends ph{constructor(){super(...arguments),pN(this,eW,e=>{var t;if(!this.open)return;let i=null==(t=this.shadowRoot)?void 0:t.querySelector("#content");if(!i)return;let r=e.composedPath(),s=r[0]===this||r.includes(this),a=r.includes(i);s&&!a&&(this.open=!1)}),pN(this,eq,e=>{if(!this.open)return;let t=e.shiftKey&&("/"===e.key||"?"===e.key);"Escape"!==e.key&&!t||e.ctrlKey||e.altKey||e.metaKey||(this.open=!1,e.preventDefault(),e.stopPropagation())})}connectedCallback(){super.connectedCallback(),this.open&&(this.addEventListener("click",pO(this,eW)),document.addEventListener("keydown",pO(this,eq)))}disconnectedCallback(){this.removeEventListener("click",pO(this,eW)),document.removeEventListener("keydown",pO(this,eq))}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),"open"===e&&(this.open?(this.addEventListener("click",pO(this,eW)),document.addEventListener("keydown",pO(this,eq))):(this.removeEventListener("click",pO(this,eW)),document.removeEventListener("keydown",pO(this,eq))))}}eW=new WeakMap,eq=new WeakMap,pU.getSlotTemplateHTML=function(e){let t;return`
837    <style>
838      :host {
839        position: fixed;
840        top: 0;
841        left: 0;
842        z-index: 9999;
843        background: rgb(20 20 30 / .8);
844        backdrop-filter: blur(10px);
845      }
846
847      #content {
848        display: block;
849        width: clamp(400px, 40vw, 700px);
850        max-width: 90vw;
851        text-align: left;
852      }
853
854      h2 {
855        margin: 0 0 1.5rem 0;
856        font-size: 1.5rem;
857        font-weight: 500;
858        text-align: center;
859      }
860
861      .shortcuts-table {
862        width: 100%;
863        border-collapse: collapse;
864      }
865
866      .shortcuts-table tr {
867        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
868      }
869
870      .shortcuts-table tr:last-child {
871        border-bottom: none;
872      }
873
874      .shortcuts-table td {
875        padding: 0.75rem 0.5rem;
876      }
877
878      .shortcuts-table td:first-child {
879        text-align: right;
880        padding-right: 1rem;
881        width: 40%;
882        min-width: 120px;
883      }
884
885      .shortcuts-table td:last-child {
886        padding-left: 1rem;
887      }
888
889      .key {
890        display: inline-block;
891        background: rgba(255, 255, 255, 0.15);
892        border: 1px solid rgba(255, 255, 255, 0.2);
893        border-radius: 4px;
894        padding: 0.25rem 0.5rem;
895        font-family: 'Courier New', monospace;
896        font-size: 0.9rem;
897        font-weight: 500;
898        min-width: 1.5rem;
899        text-align: center;
900        margin: 0 0.2rem;
901      }
902
903      .description {
904        color: rgba(255, 255, 255, 0.9);
905        font-size: 0.95rem;
906      }
907
908      .key-combo {
909        display: flex;
910        align-items: center;
911        justify-content: flex-end;
912        gap: 0.3rem;
913      }
914
915      .key-separator {
916        color: rgba(255, 255, 255, 0.5);
917        font-size: 0.9rem;
918      }
919    </style>
920    <slot id="content">
921      ${t=[{keys:["Space","k"],description:"Toggle Playback"},{keys:["m"],description:"Toggle mute"},{keys:["f"],description:"Toggle fullscreen"},{keys:["c"],description:"Toggle captions or subtitles, if available"},{keys:["p"],description:"Toggle Picture in Picture"},{keys:["←","j"],description:"Seek back 10s"},{keys:["→","l"],description:"Seek forward 10s"},{keys:["↑"],description:"Turn volume up"},{keys:["↓"],description:"Turn volume down"},{keys:["< (SHIFT+,)"],description:"Decrease playback rate"},{keys:["> (SHIFT+.)"],description:"Increase playback rate"}].map(({keys:e,description:t})=>{let i=e.map((e,t)=>t>0?`<span class="key-separator">or</span><span class="key">${e}</span>`:`<span class="key">${e}</span>`).join("");return`
922      <tr>
923        <td>
924          <div class="key-combo">${i}</div>
925        </td>
926        <td class="description">${t}</td>
927      </tr>
928    `}).join(""),`
929    <h2>Keyboard Shortcuts</h2>
930    <table class="shortcuts-table">${t}</table>
931  `}
932    </slot>
933  `},c4.customElements.get("media-keyboard-shortcuts-dialog")||c4.customElements.define("media-keyboard-shortcuts-dialog",pU);var pF=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)};let p$=`<svg aria-hidden="true" viewBox="0 0 26 24">
934  <path d="M16 3v2.5h3.5V9H22V3h-6ZM4 9h2.5V5.5H10V3H4v6Zm15.5 9.5H16V21h6v-6h-2.5v3.5ZM6.5 15H4v6h6v-2.5H6.5V15Z"/>
935</svg>`,pB=`<svg aria-hidden="true" viewBox="0 0 26 24">
936  <path d="M18.5 6.5V3H16v6h6V6.5h-3.5ZM16 21h2.5v-3.5H22V15h-6v6ZM4 17.5h3.5V21H10v-6H4v2.5Zm3.5-11H4V9h6V3H7.5v3.5Z"/>
937</svg>`,pH=e=>{let t=e.mediaIsFullscreen?cq("exit fullscreen mode"):cq("enter fullscreen mode");e.setAttribute("aria-label",t)};class pG extends m2{constructor(){super(...arguments),((e,t,i)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,i)})(this,ej,null)}static get observedAttributes(){return[...super.observedAttributes,cD.MEDIA_IS_FULLSCREEN,cD.MEDIA_FULLSCREEN_UNAVAILABLE]}connectedCallback(){super.connectedCallback(),pH(this)}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===cD.MEDIA_IS_FULLSCREEN&&pH(this)}get mediaFullscreenUnavailable(){return ff(this,cD.MEDIA_FULLSCREEN_UNAVAILABLE)}set mediaFullscreenUnavailable(e){fm(this,cD.MEDIA_FULLSCREEN_UNAVAILABLE,e)}get mediaIsFullscreen(){return fu(this,cD.MEDIA_IS_FULLSCREEN)}set mediaIsFullscreen(e){fc(this,cD.MEDIA_IS_FULLSCREEN,e)}handleClick(e){var t,i,r,s;pF(this,t=ej,"write to private field"),i?i.call(this,e):t.set(this,e);
937let a=(pF(this,r=ej,"read from private field"),(s?s.call(this):r.get(this))instanceof PointerEvent),n=this.mediaIsFullscreen?new c4.CustomEvent(cL.MEDIA_EXIT_FULLSCREEN_REQUEST,{composed:!0,bubbles:!0}):new c4.CustomEvent(cL.MEDIA_ENTER_FULLSCREEN_REQUEST,{composed:!0,bubbles:!0,detail:a});this.dispatchEvent(n)}}ej=new WeakMap,pG.getSlotTemplateHTML=function(e){return`
938    <style>
939      :host([${cD.MEDIA_IS_FULLSCREEN}]) slot[name=icon] slot:not([name=exit]) {
940        display: none !important;
941      }
942
943      
944      :host(:not([${cD.MEDIA_IS_FULLSCREEN}])) slot[name=icon] slot:not([name=enter]) {
945        display: none !important;
946      }
947
948      :host([${cD.MEDIA_IS_FULLSCREEN}]) slot[name=tooltip-enter],
949      :host(:not([${cD.MEDIA_IS_FULLSCREEN}])) slot[name=tooltip-exit] {
950        display: none;
951      }
952    </style>
953
954    <slot name="icon">
955      <slot name="enter">${p$}</slot>
956      <slot name="exit">${pB}</slot>
957    </slot>
958  `},pG.getTooltipContentHTML=function(){return`
959    <slot name="tooltip-enter">${cq("Enter fullscreen mode")}</slot>
960    <slot name="tooltip-exit">${cq("Exit fullscreen mode")}</slot>
961  `},c4.customElements.get("media-fullscreen-button")||c4.customElements.define("media-fullscreen-button",pG);let{MEDIA_TIME_IS_LIVE:pV,MEDIA_PAUSED:pK}=cD,{MEDIA_SEEK_TO_LIVE_REQUEST:pW,MEDIA_PLAY_REQUEST:pq}=cL,pj=e=>{var t;let i=e.mediaPaused||!e.mediaTimeIsLive,r=i?cq("seek to live"):cq("playing live");e.setAttribute("aria-label",r);let s=null==(t=e.shadowRoot)?void 0:t.querySelector('slot[name="text"]');s&&(s.textContent=cq("live")),i?e.removeAttribute("aria-disabled"):e.setAttribute("aria-disabled","true")};class pY extends m2{static get observedAttributes(){return[...super.observedAttributes,pV,pK]}connectedCallback(){super.connectedCallback(),pj(this)}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),pj(this)}get mediaPaused(){return fu(this,cD.MEDIA_PAUSED)}set mediaPaused(e){fc(this,cD.MEDIA_PAUSED,e)}get mediaTimeIsLive(){return fu(this,cD.MEDIA_TIME_IS_LIVE)}set mediaTimeIsLive(e){fc(this,cD.MEDIA_TIME_IS_LIVE,e)}handleClick(){(this.mediaPaused||!this.mediaTimeIsLive)&&(this.dispatchEvent(new c4.CustomEvent(pW,{composed:!0,bubbles:!0})),this.hasAttribute(pK)&&this.dispatchEvent(new c4.CustomEvent(pq,{composed:!0,bubbles:!0})))}}pY.getSlotTemplateHTML=function(e){return`
962    <style>
963      :host { --media-tooltip-display: none; }
964      
965      slot[name=indicator] > *,
966      :host ::slotted([slot=indicator]) {
967        
968        min-width: auto;
969        fill: var(--media-live-button-icon-color, rgb(140, 140, 140));
970        color: var(--media-live-button-icon-color, rgb(140, 140, 140));
971      }
972
973      :host([${pV}]:not([${pK}])) slot[name=indicator] > *,
974      :host([${pV}]:not([${pK}])) ::slotted([slot=indicator]) {
975        fill: var(--media-live-button-indicator-color, rgb(255, 0, 0));
976        color: var(--media-live-button-indicator-color, rgb(255, 0, 0));
977      }
978
979      :host([${pV}]:not([${pK}])) {
980        cursor: var(--media-cursor, not-allowed);
981      }
982
983      slot[name=text]{
984        text-transform: uppercase;
985      }
986
987    </style>
988
989    <slot name="indicator"><svg viewBox="0 0 6 12" aria-hidden="true"><circle cx="3" cy="6" r="2"></circle></svg></slot>
990    
991    <slot name="spacer">&nbsp;</slot><slot name="text">${cq("live")}</slot>
992  `},c4.customElements.get("media-live-button")||c4.customElements.define("media-live-button",pY);var pQ=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},pz=(e,t,i)=>(pQ(e,t,"read from private field"),i?i.call(e):t.get(e)),pX=(e,t,i)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,i)},pZ=(e,t,i,r)=>(pQ(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i);let pJ="loadingdelay",p0="noautohide",p1=`
993<svg aria-hidden="true" viewBox="0 0 100 100">
994  <path d="M73,50c0-12.7-10.3-23-23-23S27,37.3,27,50 M30.9,50c0-10.5,8.5-19.1,19.1-19.1S69.1,39.5,69.1,50">
995    <animateTransform
996       attributeName="transform"
997       attributeType="XML"
998       type="rotate"
999       dur="1s"
1000       from="0 50 50"
1001       to="360 50 50"
1002       repeatCount="indefinite" />
1003  </path>
1004</svg>
1005`;class p2 extends c4.HTMLElement{constructor(){if(super(),pX(this,eY,void 0),pX(this,eQ,500),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);const e=ft(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e)}}static get observedAttributes(){return[cR.MEDIA_CONTROLLER,cD.MEDIA_PAUSED,cD.MEDIA_LOADING,pJ]}attributeChangedCallback(e,t,i){var r,s,a,n,l;e===pJ&&t!==i?this.loadingDelay=Number(i):e===cR.MEDIA_CONTROLLER&&(t&&(null==(s=null==(r=pz(this,eY))?void 0:r.unassociateElement)||s.call(r,this),pZ(this,eY,null)),i&&this.isConnected&&(pZ(this,eY,null==(a=this.getRootNode())?void 0:a.getElementById(i)),null==(l=null==(n=pz(this,eY))?void 0:n.associateElement)||l.call(n,this)))}connectedCallback(){var e,t,i;let r=this.getAttribute(cR.MEDIA_CONTROLLER);r&&(pZ(this,eY,null==(e=this.getRootNode())?void 0:e.getElementById(r)),null==(i=null==(t=pz(this,eY))?void 0:t.associateElement)||i.call(t,this))}disconnectedCallback(){var e,t;null==(t=null==(e=pz(this,eY))?void 0:e.unassociateElement)||t.call(e,this),pZ(this,eY,null)}get loadingDelay(){return pz(this,eQ)}set loadingDelay(e){pZ(this,eQ,e);let{style:t}=fl(this.shadowRoot,":host");t.setProperty("--_loading-indicator-delay",`var(--media-loading-indicator-transition-delay, ${e}ms)`)}get mediaPaused(){return fu(this,cD.MEDIA_PAUSED)}set mediaPaused(e){fc(this,cD.MEDIA_PAUSED,e)}get mediaLoading(){return fu(this,cD.MEDIA_LOADING)}set mediaLoading(e){fc(this,cD.MEDIA_LOADING,e)}get mediaController(){return ff(this,cR.MEDIA_CONTROLLER)}set mediaController(e){fm(this,cR.MEDIA_CONTROLLER,e)}get noAutohide(){return fu(this,p0)}set noAutohide(e){fc(this,p0,e)}}eY=new WeakMap,eQ=new WeakMap,p2.shadowRootOptions={mode:"open"},p2.getTemplateHTML=function(e){return`
1006    <style>
1007      :host {
1008        display: var(--media-control-display, var(--media-loading-indicator-display, inline-block));
1009        vertical-align: middle;
1010        box-sizing: border-box;
1011        --_loading-indicator-delay: var(--media-loading-indicator-transition-delay, 500ms);
1012      }
1013
1014      #status {
1015        color: rgba(0,0,0,0);
1016        width: 0px;
1017        height: 0px;
1018      }
1019
1020      :host slot[name=icon] > *,
1021      :host ::slotted([slot=icon]) {
1022        opacity: var(--media-loading-indicator-opacity, 0);
1023        transition: opacity 0.15s;
1024      }
1025
1026      :host([${cD.MEDIA_LOADING}]:not([${cD.MEDIA_PAUSED}])) slot[name=icon] > *,
1027      :host([${cD.MEDIA_LOADING}]:not([${cD.MEDIA_PAUSED}])) ::slotted([slot=icon]) {
1028        opacity: var(--media-loading-indicator-opacity, 1);
1029        transition: opacity 0.15s var(--_loading-indicator-delay);
1030      }
1031
1032      :host #status {
1033        visibility: var(--media-loading-indicator-opacity, hidden);
1034        transition: visibility 0.15s;
1035      }
1036
1037      :host([${cD.MEDIA_LOADING}]:not([${cD.MEDIA_PAUSED}])) #status {
1038        visibility: var(--media-loading-indicator-opacity, visible);
1039        transition: visibility 0.15s var(--_loading-indicator-delay);
1040      }
1041
1042      svg, img, ::slotted(svg), ::slotted(img) {
1043        width: var(--media-loading-indicator-icon-width);
1044        height: var(--media-loading-indicator-icon-height, 100px);
1045        fill: var(--media-icon-color, var(--media-primary-color, rgb(238 238 238)));
1046        vertical-align: middle;
1047      }
1048    </style>
1049
1050    <slot name="icon">${p1}</slot>
1051    <div id="status" role="status" aria-live="polite">${cq("media loading")}</div>
1052  `},c4.customElements.get("media-loading-indicator")||c4.customElements.define("media-loading-indicator",p2);let p3=`<svg aria-hidden="true" viewBox="0 0 24 24">
1053  <path d="M16.5 12A4.5 4.5 0 0 0 14 8v2.18l2.45 2.45a4.22 4.22 0 0 0 .05-.63Zm2.5 0a6.84 6.84 0 0 1-.54 2.64L20 16.15A8.8 8.8 0 0 0 21 12a9 9 0 0 0-7-8.77v2.06A7 7 0 0 1 19 12ZM4.27 3 3 4.27 7.73 9H3v6h4l5 5v-6.73l4.25 4.25A6.92 6.92 0 0 1 14 18.7v2.06A9 9 0 0 0 17.69 19l2 2.05L21 19.73l-9-9L4.27 3ZM12 4 9.91 6.09 12 8.18V4Z"/>
1054</svg>`,p4=`<svg aria-hidden="true" viewBox="0 0 24 24">
1055  <path d="M3 9v6h4l5 5V4L7 9H3Zm13.5 3A4.5 4.5 0 0 0 14 8v8a4.47 4.47 0 0 0 2.5-4Z"/>
1056</svg>`,p5=`<svg aria-hidden="true" viewBox="0 0 24 24">
1057  <path d="M3 9v6h4l5 5V4L7 9H3Zm13.5 3A4.5 4.5 0 0 0 14 8v8a4.47 4.47 0 0 0 2.5-4ZM14 3.23v2.06a7 7 0 0 1 0 13.42v2.06a9 9 0 0 0 0-17.54Z"/>
1058</svg>`,p8=e=>{let t="off"===e.mediaVolumeLevel?cq("unmute"):cq("mute");e.setAttribute("aria-label",t)};class p6 extends m2{static get observedAttributes(){return[...super.observedAttributes,cD.MEDIA_VOLUME_LEVEL]}connectedCallback(){super.connectedCallback(),p8(this)}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===cD.MEDIA_VOLUME_LEVEL&&p8(this)}get mediaVolumeLevel(){return ff(this,cD.MEDIA_VOLUME_LEVEL)}set mediaVolumeLevel(e){fm(this,cD.MEDIA_VOLUME_LEVEL,e)}handleClick(){let e="off"===this.mediaVolumeLevel?cL.MEDIA_UNMUTE_REQUEST:cL.MEDIA_MUTE_REQUEST;this.dispatchEvent(new c4.CustomEvent(e,{composed:!0,bubbles:!0}))}}p6.getSlotTemplateHTML=function(e){return`
1059    <style>
1060      :host(:not([${cD.MEDIA_VOLUME_LEVEL}])) slot[name=icon] slot:not([name=high]),
1061      :host([${cD.MEDIA_VOLUME_LEVEL}=high]) slot[name=icon] slot:not([name=high]) {
1062        display: none !important;
1063      }
1064
1065      :host([${cD.MEDIA_VOLUME_LEVEL}=off]) slot[name=icon] slot:not([name=off]) {
1066        display: none !important;
1067      }
1068
1069      :host([${cD.MEDIA_VOLUME_LEVEL}=low]) slot[name=icon] slot:not([name=low]) {
1070        display: none !important;
1071      }
1072
1073      :host([${cD.MEDIA_VOLUME_LEVEL}=medium]) slot[name=icon] slot:not([name=medium]) {
1074        display: none !important;
1075      }
1076
1077      :host(:not([${cD.MEDIA_VOLUME_LEVEL}=off])) slot[name=tooltip-unmute],
1078      :host([${cD.MEDIA_VOLUME_LEVEL}=off]) slot[name=tooltip-mute] {
1079        display: none;
1080      }
1081    </style>
1082
1083    <slot name="icon">
1084      <slot name="off">${p3}</slot>
1085      <slot name="low">${p4}</slot>
1086      <slot name="medium">${p4}</slot>
1087      <slot name="high">${p5}</slot>
1088    </slot>
1089  `},p6.getTooltipContentHTML=function(){return`
1090    <slot name="tooltip-mute">${cq("Mute")}</slot>
1091    <slot name="tooltip-unmute">${cq("Unmute")}</slot>
1092  `},c4.customElements.get("media-mute-button")||c4.customElements.define("media-mute-button",p6);let p9=`<svg aria-hidden="true" viewBox="0 0 28 24">
1093  <path d="M24 3H4a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h20a1 1 0 0 0 1-1V4a1 1 0 0 0-1-1Zm-1 16H5V5h18v14Zm-3-8h-7v5h7v-5Z"/>
1094</svg>`,p7=e=>{let t=e.mediaIsPip?cq("exit picture in picture mode"):cq("enter picture in picture mode");e.setAttribute("aria-label",t)};class ge extends m2{static get observedAttributes(){return[...super.observedAttributes,cD.MEDIA_IS_PIP,cD.MEDIA_PIP_UNAVAILABLE]}
1094connectedCallback(){super.connectedCallback(),p7(this)}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===cD.MEDIA_IS_PIP&&p7(this)}get mediaPipUnavailable(){return ff(this,cD.MEDIA_PIP_UNAVAILABLE)}set mediaPipUnavailable(e){fm(this,cD.MEDIA_PIP_UNAVAILABLE,e)}get mediaIsPip(){return fu(this,cD.MEDIA_IS_PIP)}set mediaIsPip(e){fc(this,cD.MEDIA_IS_PIP,e)}handleClick(){let e=this.mediaIsPip?cL.MEDIA_EXIT_PIP_REQUEST:cL.MEDIA_ENTER_PIP_REQUEST;this.dispatchEvent(new c4.CustomEvent(e,{composed:!0,bubbles:!0}))}}ge.getSlotTemplateHTML=function(e){return`
1095    <style>
1096      :host([${cD.MEDIA_IS_PIP}]) slot[name=icon] slot:not([name=exit]) {
1097        display: none !important;
1098      }
1099
1100      :host(:not([${cD.MEDIA_IS_PIP}])) slot[name=icon] slot:not([name=enter]) {
1101        display: none !important;
1102      }
1103
1104      :host([${cD.MEDIA_IS_PIP}]) slot[name=tooltip-enter],
1105      :host(:not([${cD.MEDIA_IS_PIP}])) slot[name=tooltip-exit] {
1106        display: none;
1107      }
1108    </style>
1109
1110    <slot name="icon">
1111      <slot name="enter">${p9}</slot>
1112      <slot name="exit">${p9}</slot>
1113    </slot>
1114  `},ge.getTooltipContentHTML=function(){return`
1115    <slot name="tooltip-enter">${cq("Enter picture in picture mode")}</slot>
1116    <slot name="tooltip-exit">${cq("Exit picture in picture mode")}</slot>
1117  `},c4.customElements.get("media-pip-button")||c4.customElements.define("media-pip-button",ge);var gt=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot read from private field");return i?i.call(e):t.get(e)};let gi="rates",gr=[1,1.2,1.5,1.7,2];class gs extends m2{constructor(){var e;super(),((e,t,i)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,i)})(this,ez,new f$(this,gi,{defaultValue:gr})),this.container=this.shadowRoot.querySelector('slot[name="icon"]'),this.container.innerHTML=`${null!=(e=this.mediaPlaybackRate)?e:1}x`}static get observedAttributes(){return[...super.observedAttributes,cD.MEDIA_PLAYBACK_RATE,gi]}attributeChangedCallback(e,t,i){if(super.attributeChangedCallback(e,t,i),e===gi&&(gt(this,ez).value=i),e===cD.MEDIA_PLAYBACK_RATE){let e=i?+i:NaN,t=Number.isNaN(e)?1:e;this.container.innerHTML=`${t}x`,this.setAttribute("aria-label",cq("Playback rate {playbackRate}",{playbackRate:t}))}}get rates(){return gt(this,ez)}set rates(e){e?Array.isArray(e)?gt(this,ez).value=e.join(" "):"string"==typeof e&&(gt(this,ez).value=e):gt(this,ez).value=""}get mediaPlaybackRate(){return fd(this,cD.MEDIA_PLAYBACK_RATE,1)}set mediaPlaybackRate(e){fh(this,cD.MEDIA_PLAYBACK_RATE,e)}handleClick(){var e,t;let i=Array.from(gt(this,ez).values(),e=>+e).sort((e,t)=>e-t),r=null!=(t=null!=(e=i.find(e=>e>this.mediaPlaybackRate))?e:i[0])?t:1,s=new c4.CustomEvent(cL.MEDIA_PLAYBACK_RATE_REQUEST,{composed:!0,bubbles:!0,detail:r});this.dispatchEvent(s)}}ez=new WeakMap,gs.getSlotTemplateHTML=function(e){return`
1118    <style>
1119      :host {
1120        min-width: 5ch;
1121        padding: var(--media-button-padding, var(--media-control-padding, 10px 5px));
1122      }
1123    </style>
1124    <slot name="icon">${e.mediaplaybackrate||1}x</slot>
1125  `},gs.getTooltipContentHTML=function(){return cq("Playback rate")},c4.customElements.get("media-playback-rate-button")||c4.customElements.define("media-playback-rate-button",gs);let ga=`<svg aria-hidden="true" viewBox="0 0 24 24">
1126  <path d="m6 21 15-9L6 3v18Z"/>
1127</svg>`,gn=`<svg aria-hidden="true" viewBox="0 0 24 24">
1128  <path d="M6 20h4V4H6v16Zm8-16v16h4V4h-4Z"/>
1129</svg>`,gl=e=>{let t=e.mediaPaused?cq("play"):cq("pause");e.setAttribute("aria-label",t)};class go extends m2{static get observedAttributes(){return[...super.observedAttributes,cD.MEDIA_PAUSED,cD.MEDIA_ENDED]}connectedCallback(){super.connectedCallback(),gl(this)}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),(e===cD.MEDIA_PAUSED||e===cD.MEDIA_LANG)&&gl(this)}get mediaPaused(){return fu(this,cD.MEDIA_PAUSED)}set mediaPaused(e){fc(this,cD.MEDIA_PAUSED,e)}handleClick(){let e=this.mediaPaused?cL.MEDIA_PLAY_REQUEST:cL.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new c4.CustomEvent(e,{composed:!0,bubbles:!0}))}}go.getSlotTemplateHTML=function(e){return`
1130    <style>
1131      :host([${cD.MEDIA_PAUSED}]) slot[name=pause],
1132      :host(:not([${cD.MEDIA_PAUSED}])) slot[name=play] {
1133        display: none !important;
1134      }
1135
1136      :host([${cD.MEDIA_PAUSED}]) slot[name=tooltip-pause],
1137      :host(:not([${cD.MEDIA_PAUSED}
1137])) slot[name=tooltip-play] {
1138        display: none;
1139      }
1140    </style>
1141
1142    <slot name="icon">
1143      <slot name="play">${ga}</slot>
1144      <slot name="pause">${gn}</slot>
1145    </slot>
1146  `},go.getTooltipContentHTML=function(){return`
1147    <slot name="tooltip-play">${cq("Play")}</slot>
1148    <slot name="tooltip-pause">${cq("Pause")}</slot>
1149  `},c4.customElements.get("media-play-button")||c4.customElements.define("media-play-button",go);let gd="placeholdersrc";class gh extends c4.HTMLElement{static get observedAttributes(){return[gd,"src"]}constructor(){if(super(),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);const e=ft(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e)}this.image=this.shadowRoot.querySelector("#image")}attributeChangedCallback(e,t,i){if("src"===e&&(null==i?this.image.removeAttribute("src"):this.image.setAttribute("src",i)),e===gd)if(null==i)this.image.style.removeProperty("background-image");else{var r;r=this.image,r.style["background-image"]=`url('${i}')`}}get placeholderSrc(){return ff(this,gd)}set placeholderSrc(e){fm(this,"src",e)}get src(){return ff(this,"src")}set src(e){fm(this,"src",e)}}gh.shadowRootOptions={mode:"open"},gh.getTemplateHTML=function(e){return`
1150    <style>
1151      :host {
1152        pointer-events: none;
1153        display: var(--media-poster-image-display, inline-block);
1154        box-sizing: border-box;
1155      }
1156
1157      img {
1158        max-width: 100%;
1159        max-height: 100%;
1160        min-width: 100%;
1161        min-height: 100%;
1162        background-repeat: no-repeat;
1163        background-position: var(--media-poster-image-background-position, var(--media-object-position, center));
1164        background-size: var(--media-poster-image-background-size, var(--media-object-fit, contain));
1165        object-fit: var(--media-object-fit, contain);
1166        object-position: var(--media-object-position, center);
1167      }
1168    </style>
1169
1170    <img part="poster img" aria-hidden="true" id="image"/>
1171  `},c4.customElements.get("media-poster-image")||c4.customElements.define("media-poster-image",gh);var gu=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)};class gc extends pS{constructor(){super(),((e,t,i)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,i)})(this,eX,void 0),((e,t,i,r)=>(gu(e,t,"write to private field"),r?r.call(e,i):t.set(e,i)))(this,eX,this.shadowRoot.querySelector("slot"))}static get observedAttributes(){return[...super.observedAttributes,cD.MEDIA_PREVIEW_CHAPTER,cD.MEDIA_LANG]}attributeChangedCallback(e,t,i){if(super.attributeChangedCallback(e,t,i),(e===cD.MEDIA_PREVIEW_CHAPTER||e===cD.MEDIA_LANG)&&i!==t&&null!=i){var r,s;if((gu(this,r=eX,"read from private field"),s?s.call(this):r.get(this)).textContent=i,""!==i){let e=cq("chapter: {chapterName}",{chapterName:i});this.setAttribute("aria-valuetext",e)}else this.removeAttribute("aria-valuetext")}}get mediaPreviewChapter(){return ff(this,cD.MEDIA_PREVIEW_CHAPTER)}set mediaPreviewChapter(e){fm(this,cD.MEDIA_PREVIEW_CHAPTER,e)}}eX=new WeakMap,c4.customElements.get("media-preview-chapter-display")||c4.customElements.define("media-preview-chapter-display",gc);var gf=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},gm=(e,t,i)=>(gf(e,t,"read from private field"),i?i.call(e):t.get(e)),gp=(e,t,i,r)=>(gf(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i);class gg extends c4.HTMLElement{constructor(){if(super(),((e,t,i)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,i)})(this,eZ,void 0),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);const e=ft(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e)}}static get observedAttributes(){return[cR.MEDIA_CONTROLLER,cD.MEDIA_PREVIEW_IMAGE,cD.MEDIA_PREVIEW_COORDS]}connectedCallback(){var e,t,i;let r=this.getAttribute(cR.MEDIA_CONTROLLER);r&&(gp(this,eZ,null==(e=this.getRootNode())?void 0:e.getElementById(r)),null==(i=null==(t=gm(this,eZ))?void 0:t.associateElement)||i.call(t,this))}disconnectedCallback(){var e,t;null==(t=null==(e=gm(this,eZ))?void 0:e.unassociateElement)||t.call(e,this),gp(this,eZ,null)}attributeChangedCallback(e,t,i){var r,s,a,n,l;[cD.MEDIA_PREVIEW_IMAGE,cD.MEDIA_PREVIEW_COORDS].includes(e)&&this.update(),e===cR.MEDIA_CONTROLLER&&(t&&(null==(s=null==(r=gm(this,eZ))?void 0:r.unassociateElement)||s.call(r,this),gp(this,eZ,null)),i&&this.isConnected&&(gp(this,eZ,null==(a=this.getRootNode())?void 0:a.getElementById(i)),null==(l=null==(n=gm(this,eZ))?void 0:n.associateElement)||l.call(n,this)))}get mediaPreviewImage(){return ff(this,cD.MEDIA_PREVIEW_IMAGE)}set mediaPreviewImage(e){fm(this,cD.MEDIA_PREVIEW_IMAGE,e)}get mediaPreviewCoords(){let e=this.getAttribute(cD.MEDIA_PREVIEW_COORDS);if(e)return e.split(/\s+/).map(e=>+e)}set mediaPreviewCoords(e){e?this.setAttribute(cD.MEDIA_PREVIEW_COORDS,e.join(" ")):this.removeAttribute(cD.MEDIA_PREVIEW_COORDS)}update(){let e,t,i=this.mediaPreviewCoords,r=this.mediaPreviewImage;if(!(i&&r))return;let[s,a,n,l]=i,o=r.split("#")[0],d=getComputedStyle(this),{maxWidth:h,maxHeight:u,minWidth:c,minHeight:f}=d;
1171if("fill"===(d.getPropertyValue("--media-preview-thumbnail-object-fit").trim()||"contain")){let i=parseInt(h)/n,r=parseInt(u)/l,s=parseInt(c)/n,a=parseInt(f)/l;e=i<1?i:Math.max(i,s),t=r<1?r:Math.max(r,a)}else{let i=Math.min(parseInt(h)/n,parseInt(u)/l),r=Math.max(parseInt(c)/n,parseInt(f)/l),s=i<1?i:r>1?r:1;e=s,t=s}let{style:m}=fl(this.shadowRoot,":host"),g=fl(this.shadowRoot,"img").style,v=this.shadowRoot.querySelector("img"),E=1>Math.min(e,t)?"min":"max";m.setProperty(`${E}-width`,"initial","important"),m.setProperty(`${E}-height`,"initial","important"),m.width=`${n*e}px`,m.height=`${l*t}px`;let y=()=>{g.width=`${this.imgWidth*e}px`,g.height=`${this.imgHeight*t}px`,g.display="block"};v.src!==o&&(v.onload=()=>{this.imgWidth=v.naturalWidth,this.imgHeight=v.naturalHeight,y(),v.onload=null},v.src=o,y()),y(),g.transform=`translate(-${s*e}px, -${a*t}px)`}}eZ=new WeakMap,gg.shadowRootOptions={mode:"open"},gg.getTemplateHTML=function(e){return`
1172    <style>
1173      :host {
1174        box-sizing: border-box;
1175        display: var(--media-control-display, var(--media-preview-thumbnail-display, inline-block));
1176        overflow: hidden;
1177      }
1178
1179      img {
1180        display: none;
1181        position: relative;
1182      }
1183    </style>
1184    <img crossorigin loading="eager" decoding="async">
1185  `},c4.customElements.get("media-preview-thumbnail")||c4.customElements.define("media-preview-thumbnail",gg);var gv=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},gE=(e,t,i)=>(gv(e,t,"read from private field"),i?i.call(e):t.get(e));class gy extends pS{constructor(){super(),((e,t,i)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,i)})(this,eJ,void 0),((e,t,i,r)=>(gv(e,t,"write to private field"),r?r.call(e,i):t.set(e,i)))(this,eJ,this.shadowRoot.querySelector("slot")),gE(this,eJ).textContent=cQ(0)}static get observedAttributes(){return[...super.observedAttributes,cD.MEDIA_PREVIEW_TIME]}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===cD.MEDIA_PREVIEW_TIME&&null!=i&&(gE(this,eJ).textContent=cQ(parseFloat(i)))}get mediaPreviewTime(){return fd(this,cD.MEDIA_PREVIEW_TIME)}set mediaPreviewTime(e){fh(this,cD.MEDIA_PREVIEW_TIME,e)}}eJ=new WeakMap,c4.customElements.get("media-preview-time-display")||c4.customElements.define("media-preview-time-display",gy);let gb="seekoffset";class gT extends m2{static get observedAttributes(){return[...super.observedAttributes,cD.MEDIA_CURRENT_TIME,gb]}connectedCallback(){super.connectedCallback(),this.seekOffset=fd(this,gb,30)}attributeChangedCallback(e,t,i){var r;super.attributeChangedCallback(e,t,i),r=this.seekOffset,this.setAttribute("aria-label",cq("seek back {seekOffset} seconds",{seekOffset:r})),e===gb&&(this.seekOffset=fd(this,gb,30))}get seekOffset(){return fd(this,gb,30)}set seekOffset(e){fh(this,gb,e),this.setAttribute("aria-label",cq("seek back {seekOffset} seconds",{seekOffset:this.seekOffset})),fi(fr(this,"icon"),this.seekOffset)}get mediaCurrentTime(){return fd(this,cD.MEDIA_CURRENT_TIME,0)}set mediaCurrentTime(e){fh(this,cD.MEDIA_CURRENT_TIME,e)}handleClick(){let e=Math.max(this.mediaCurrentTime-this.seekOffset,0),t=new c4.CustomEvent(cL.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)}}gT.getSlotTemplateHTML=function(e,t){let i;return`
1186    <slot name="icon">${i=t.seekOffset,`
1187  <svg aria-hidden="true" viewBox="0 0 20 24">
1188    <defs>
1189      <style>.text{font-size:8px;font-family:Arial-BoldMT, Arial;font-weight:700;}</style>
1190    </defs>
1191    <text class="text value" transform="translate(2.18 19.87)">${i}</text>
1192    <path d="M10 6V3L4.37 7 10 10.94V8a5.54 5.54 0 0 1 1.9 10.48v2.12A7.5 7.5 0 0 0 10 6Z"/>
1193  </svg>`}</slot>
1194  `},gT.getTooltipContentHTML=function(){return cq("Seek backward")},c4.customElements.get("media-seek-backward-button")||c4.customElements.define("media-seek-backward-button",gT);let g_="seekoffset";class gA extends m2{static get observedAttributes(){return[...super.observedAttributes,cD.MEDIA_CURRENT_TIME,g_]}connectedCallback(){super.connectedCallback(),this.seekOffset=fd(this,g_,30)}attributeChangedCallback(e,t,i){var r;super.attributeChangedCallback(e,t,i),r=this.seekOffset,this.setAttribute("aria-label",cq("seek forward {seekOffset} seconds",{seekOffset:r})),e===g_&&(this.seekOffset=fd(this,g_,30))}get seekOffset(){return fd(this,g_,30)}set seekOffset(e){fh(this,g_,e),this.setAttribute("aria-label",cq("seek forward {seekOffset} seconds",{seekOffset:this.seekOffset})),fi(fr(this,"icon"),this.seekOffset)}get mediaCurrentTime(){return fd(this,cD.MEDIA_CURRENT_TIME,0)}set mediaCurrentTime(e){fh(this,cD.MEDIA_CURRENT_TIME,e)}handleClick(){let e=this.mediaCurrentTime+this.seekOffset,t=new c4.CustomEvent(cL.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)}}gA.getSlotTemplateHTML=function(e,t){let i;return`
1195    <slot name="icon">${i=t.seekOffset,`
1196  <svg aria-hidden="true" viewBox="0 0 20 24">
1197    <defs>
1198      <style>.text{font-size:8px;font-family:Arial-BoldMT, Arial;font-weight:700;}</style>
1199    </defs>
1200    <text class="text value" transform="translate(8.9 19.87)">${i}</text>
1201    <path d="M10 6V3l5.61 4L10 10.94V8a5.54 5.54 0 0 0-1.9 10.48v2.12A7.5 7.5 0 0 1 10 6Z"/>
1202  </svg>`}</slot>
1203  `},gA.getTooltipContentHTML=function(){return cq("Seek forward")},c4.customElements.get("media-seek-forward-button")||c4.customElements.define("media-seek-forward-button",gA);var gS=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},gk=(e,t,i)=>(gS(e,t,"read from private field"),i?i.call(e):t.get(e)),gL=(e,t,i)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,i)},gR=(e,t,i,r)=>(gS(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i),gI=(e,t,i)=>(gS(e,t,"access private method"),i);let gw={REMAINING:"remaining",SHOW_DURATION:"showduration",NO_TOGGLE:"notoggle"},gD=[...Object.values(gw),cD.MEDIA_CURRENT_TIME,cD.MEDIA_DURATION,cD.MEDIA_SEEKABLE],gC=["Enter"," "],gP="&nbsp;/&nbsp;",gx=(e,{timesSep:t=gP}={})=>{var i,r;let s=null!=(i=e.mediaCurrentTime)?i:0,[,a]=null!=(r=e.mediaSeekable)?r:[],n=0;Number.isFinite(e.mediaDuration)?n=e.mediaDuration:Number.isFinite(a)&&(n=a);let l=e.remaining?cQ(0-(n-s)):cQ(s);return e.showDuration?`${l}${t}${cQ(n)}`:l};class gM extends pS{constructor(){super(),gL(this,e3),gL(this,e5),gL(this,e6),gL(this,e7),gL(this,e0,void 0),gL(this,e1,null),gL(this,e2,e=>{let{metaKey:t,altKey:i,key:r}=e;t||i||!gC.includes(r)?this.removeEventListener("keyup",gk(this,e1)):this.addEventListener("keyup",gk(this,e1))}),gR(this,e0,this.shadowRoot.querySelector("slot")),gk(this,e0).innerHTML=`${gx(this)}`}static get observedAttributes(){return[...super.observedAttributes,...gD,"disabled"]}connectedCallback(){let{style:e}=fl(this.shadowRoot,":host(:hover:not([notoggle]))");e.setProperty("cursor","var(--media-cursor, pointer)"),e.setProperty("background","var(--media-control-hover-background, rgba(50 50 70 / .7))"),this.setAttribute("aria-label",cq("playback time")),gI(this,e6,e9).call(this),super.connectedCallback()}toggleTimeDisplay(){this.noToggle||(this.hasAttribute("remaining")?this.removeAttribute("remaining"):this.setAttribute("remaining",""))}disconnectedCallback(){this.disable(),gI(this,e5,e8).call(this),super.disconnectedCallback()}attributeChangedCallback(e,t,i){this.setAttribute("aria-label",cq("playback time")),gD.includes(e)?this.update():"disabled"===e&&i!==t?null==i?gI(this,e6,e9).call(this):gI(this,e7,te).call(this):e===gw.NO_TOGGLE&&i!==t&&(this.noToggle?gI(this,e7,te).call(this):gI(this,e6,e9).call(this)),super.attributeChangedCallback(e,t,i)}enable(){this.noToggle||(this.tabIndex=0)}disable(){this.tabIndex=-1}get remaining(){return fu(this,gw.REMAINING)}set remaining(e){fc(this,gw.REMAINING,e)}get showDuration(){return fu(this,gw.SHOW_DURATION)}set showDuration(e){fc(this,gw.SHOW_DURATION,e)}get noToggle(){return fu(this,gw.NO_TOGGLE)}set noToggle(e){fc(this,gw.NO_TOGGLE,e)}get mediaDuration(){return fd(this,cD.MEDIA_DURATION)}set mediaDuration(e){fh(this,cD.MEDIA_DURATION,e)}get mediaCurrentTime(){return fd(this,cD.MEDIA_CURRENT_TIME)}set mediaCurrentTime(e){fh(this,cD.MEDIA_CURRENT_TIME,e)}get mediaSeekable(){let e=this.getAttribute(cD.MEDIA_SEEKABLE);if(e)return e.split(":").map(e=>+e)}set mediaSeekable(e){null==e?this.removeAttribute(cD.MEDIA_SEEKABLE):this.setAttribute(cD.MEDIA_SEEKABLE,e.join(":"))}update(){let e=gx(this);(e=>{var t;let i=e.mediaCurrentTime,[,r]=null!=(t=e.mediaSeekable)?t:[],s=null;if(Number.isFinite(e.mediaDuration)?s=e.mediaDuration:Number.isFinite(r)&&(s=r),null==i||null===s)return e.setAttribute("aria-valuetext",cq("video not loaded, unknown time."));let a=e.remaining?cY(0-(s-i)):cY(i);if(!e.showDuration)return e.setAttribute("aria-valuetext",a);let n=cq("{currentTime} of {totalTime}",{currentTime:a,totalTime:cY(s)});e.setAttribute("aria-valuetext",n)})(this),e!==gk(this,e0).innerHTML&&(gk(this,e0).innerHTML=e)}}e0=new WeakMap,e1=new WeakMap,e2=new WeakMap,e3=new WeakSet,e4=function(){gk(this,e1)||(gR(this,e1,e=>{let{key:t}=e;gC.includes(t)?this.toggleTimeDisplay():this.removeEventListener("keyup",gk(this,e1))}),this.addEventListener("keydown",gk(this,e2)),this.addEventListener("click",this.toggleTimeDisplay))},e5=new WeakSet,e8=function(){gk(this,e1)&&(this.removeEventListener("keyup",gk(this,e1)),this.removeEventListener("keydown",gk(this,e2)),this.removeEventListener("click",this.toggleTimeDisplay),gR(this,e1,null))},e6=new WeakSet,e9=function(){this.noToggle||this.hasAttribute("disabled")||(this.setAttribute("role","button"),this.enable(),gI(this,e3,e4).call(this))},e7=new WeakSet,te=function(){this.removeAttribute("role"),this.disable(),gI(this,e5,e8).call(this)},gM.getSlotTemplateHTML=function(e,t){return`
1204    <slot>${gx(t)}</slot>
1205  `},c4.customElements.get("media-time-display")||c4.customElements.define("media-time-display",gM);var gO=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},gN=(e,t,i)=>(gO(e,t,"read from private field"),i?i.call(e):t.get(e)),gU=(e,t,i)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,i)},gF=(e,t,i,r)=>(gO(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i);class g${constructor(e,t,i){gU(this,tt,void 0),gU(this,ti,void 0),gU(this,tr,void 0),gU(this,ts,void 0),gU(this,ta,void 0),gU(this,tn,void 0),gU(this,tl,void 0),gU(this,to,void 0),gU(this,td,0),gU(this,th,(e=performance.now())=>{gF(this,td,requestAnimationFrame(gN(this,th))),gF(this,ts,performance.now()-gN(this,tr));let t=1e3/this.fps;if(gN(this,ts)>t){let i,r,s,a;gF(this,tr,e-gN(this,ts)%t);let n=1e3/((e-gN(this,ti))/++(i=this,r=ta,{set _(value){gF(i,r,value,s)},get _(){return gN(i,r,a)}})._),l=(e-gN(this,tn))/1e3/this.duration,o=gN(this,tl)+l*this.playbackRate;o-gN(this,tt).valueAsNumber>0?gF(this,to,this.playbackRate/this.duration/n):(gF(this,to,.995*gN(this,to)),o=gN(this,tt).valueAsNumber+gN(this,to)),this.callback(o)}}),gF(this,tt,e),this.callback=t,this.fps=i}start(){0===gN(this,td)&&(gF(this,tr,performance.now()),gF(this,ti,gN(this,tr)),gF(this,ta,0),gN(this,th).call(this))}stop(){0!==gN(this,td)&&(cancelAnimationFrame(gN(this,td)),gF(this,td,0))}update({start:e,duration:t,playbackRate:i}){let r=e-gN(this,tt).valueAsNumber,s=Math.abs(t-this.duration);(r>0||r<-.03||s>=.5)&&this.callback(e),gF(this,tl,e),gF(this,tn,performance.now()),this.duration=t,this.playbackRate=i}}tt=new WeakMap,ti=new WeakMap,tr=new WeakMap,ts=new WeakMap,ta=new WeakMap,tn=new WeakMap,tl=new WeakMap,to=new WeakMap,td=new WeakMap,th=new WeakMap;var gB=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},gH=(e,t,i)=>(gB(e,t,"read from private field"),i?i.call(e):t.get(e)),gG=(e,t,i)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,i)},gV=(e,t,i,r)=>(gB(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i),gK=(e,t,i)=>(gB(e,t,"access private method"),i);let gW=(e,t=e.mediaCurrentTime)=>{let i=Number.isFinite(e.mediaSeekableStart)?e.mediaSeekableStart:0,r=Number.isFinite(e.mediaDuration)?e.mediaDuration:e.mediaSeekableEnd;return Number.isNaN(r)?0:Math.max(0,Math.min((t-i)/(r-i),1))},gq=(e,t=e.range.valueAsNumber)=>{let i=Number.isFinite(e.mediaSeekableStart)?e.mediaSeekableStart:0,r=Number.isFinite(e.mediaDuration)?e.mediaDuration:e.mediaSeekableEnd;return Number.isNaN(r)?0:t*(r-i)+i};class gj extends pg{constructor(){super(),gG(this,t_),gG(this,tk),gG(this,tR),gG(this,tw),gG(this,tC),gG(this,tx),gG(this,tO),gG(this,tu,null),gG(this,tc,void 0),gG(this,tf,void 0),gG(this,tm,void 0),gG(this,tp,void 0),gG(this,tg,void 0),gG(this,tv,void 0),gG(this,tE,void 0),gG(this,ty,void 0),gG(this,tb,void 0),gG(this,tT,()=>{gK(this,t_,tA).call(this)?gH(this,tc).start():gH(this,tc).stop()}),gG(this,tS,e=>{!this.dragging&&(cG(e)&&(this.range.valueAsNumber=e),gH(this,tb)||this.updateBar())}),this.shadowRoot.querySelector("#track").insertAdjacentHTML("afterbegin",'<div id="buffered" part="buffered"></div>'),gV(this,tf,this.shadowRoot.querySelectorAll('[part~="box"]')),gV(this,tp,this.shadowRoot.querySelector('[part~="preview-box"]')),gV(this,tg,this.shadowRoot.querySelector('[part~="current-box"]'));const e=getComputedStyle(this);gV(this,tv,parseInt(e.getPropertyValue("--media-box-padding-left"))),gV(this,tE,parseInt(e.getPropertyValue("--media-box-padding-right"))),gV(this,tc,new g$(this.range,gH(this,tS),60))}static get observedAttributes(){return[...super.observedAttributes,cD.MEDIA_PAUSED,cD.MEDIA_DURATION,cD.MEDIA_SEEKABLE,cD.MEDIA_CURRENT_TIME,cD.MEDIA_PREVIEW_IMAGE,cD.MEDIA_PREVIEW_TIME,cD.MEDIA_PREVIEW_CHAPTER,cD.MEDIA_BUFFERED,cD.MEDIA_PLAYBACK_RATE,cD.MEDIA_LOADING,cD.MEDIA_ENDED]}connectedCallback(){var e;super.connectedCallback(),this.range.setAttribute("aria-label",cq("seek")),gH(this,tT).call(this),gV(this,tu,this.getRootNode()),null==(e=gH(this,tu))||e.addEventListener("transitionstart",this)}disconnectedCallback(){var e;super.disconnectedCallback(),gH(this,tc).stop(),null==(e=gH(this,tu))||e.removeEventListener("transitionstart",this),gV(this,tu,null)}attributeChangedCallback(e,t,i){if(super.attributeChangedCallback(e,t,i),t!=i){if(e===cD.MEDIA_CURRENT_TIME||e===cD.MEDIA_PAUSED||e===cD.MEDIA_ENDED||e===cD.MEDIA_LOADING||e===cD.MEDIA_DURATION||e===cD.MEDIA_SEEKABLE){let e,t,i,r;gH(this,tc).update({start:gW(this),duration:this.mediaSeekableEnd-this.mediaSeekableStart,playbackRate:this.mediaPlaybackRate}),gH(this,tT).call(this),e=this.range,t=cY(+gq(this)),i=cY(+this.mediaSeekableEnd),r
1205=t&&i?cq("{currentTime} of {totalTime}",{currentTime:t,totalTime:i}):cq("video not loaded, unknown time."),e.setAttribute("aria-valuetext",r)}else e===cD.MEDIA_BUFFERED&&this.updateBufferedBar();(e===cD.MEDIA_DURATION||e===cD.MEDIA_SEEKABLE)&&(this.mediaChaptersCues=gH(this,ty),this.updateBar())}}get mediaChaptersCues(){return gH(this,ty)}set mediaChaptersCues(e){var t;gV(this,ty,e),this.updateSegments(null==(t=gH(this,ty))?void 0:t.map(e=>({start:gW(this,e.startTime),end:gW(this,e.endTime)})))}get mediaPaused(){return fu(this,cD.MEDIA_PAUSED)}set mediaPaused(e){fc(this,cD.MEDIA_PAUSED,e)}get mediaLoading(){return fu(this,cD.MEDIA_LOADING)}set mediaLoading(e){fc(this,cD.MEDIA_LOADING,e)}get mediaDuration(){return fd(this,cD.MEDIA_DURATION)}set mediaDuration(e){fh(this,cD.MEDIA_DURATION,e)}get mediaCurrentTime(){return fd(this,cD.MEDIA_CURRENT_TIME)}set mediaCurrentTime(e){fh(this,cD.MEDIA_CURRENT_TIME,e)}get mediaPlaybackRate(){return fd(this,cD.MEDIA_PLAYBACK_RATE,1)}set mediaPlaybackRate(e){fh(this,cD.MEDIA_PLAYBACK_RATE,e)}get mediaBuffered(){let e=this.getAttribute(cD.MEDIA_BUFFERED);return e?e.split(" ").map(e=>e.split(":").map(e=>+e)):[]}set mediaBuffered(e){if(!e)return void this.removeAttribute(cD.MEDIA_BUFFERED);let t=e.map(e=>e.join(":")).join(" ");this.setAttribute(cD.MEDIA_BUFFERED,t)}get mediaSeekable(){let e=this.getAttribute(cD.MEDIA_SEEKABLE);if(e)return e.split(":").map(e=>+e)}set mediaSeekable(e){null==e?this.removeAttribute(cD.MEDIA_SEEKABLE):this.setAttribute(cD.MEDIA_SEEKABLE,e.join(":"))}get mediaSeekableEnd(){var e;let[,t=this.mediaDuration]=null!=(e=this.mediaSeekable)?e:[];return t}get mediaSeekableStart(){var e;let[t=0]=null!=(e=this.mediaSeekable)?e:[];return t}get mediaPreviewImage(){return ff(this,cD.MEDIA_PREVIEW_IMAGE)}set mediaPreviewImage(e){fm(this,cD.MEDIA_PREVIEW_IMAGE,e)}get mediaPreviewTime(){return fd(this,cD.MEDIA_PREVIEW_TIME)}set mediaPreviewTime(e){fh(this,cD.MEDIA_PREVIEW_TIME,e)}get mediaEnded(){return fu(this,cD.MEDIA_ENDED)}set mediaEnded(e){fc(this,cD.MEDIA_ENDED,e)}updateBar(){super.updateBar(),this.updateBufferedBar(),this.updateCurrentBox()}updateBufferedBar(){var e;let t,i=this.mediaBuffered;if(!i.length)return;if(this.mediaEnded)t=1;else{let r=this.mediaCurrentTime,[,s=this.mediaSeekableStart]=null!=(e=i.find(([e,t])=>e<=r&&r<=t))?e:[];t=gW(this,s)}let{style:r}=fl(this.shadowRoot,"#buffered");r.setProperty("width",`${100*t}%`)}updateCurrentBox(){if(!this.shadowRoot.querySelector('slot[name="current"]').assignedElements().length)return;let e=fl(this.shadowRoot,"#current-rail"),t=fl(this.shadowRoot,'[part~="current-box"]'),i=gK(this,tk,tL).call(this,gH(this,tg)),r=gK(this,tR,tI).call(this,i,this.range.valueAsNumber),s=gK(this,tw,tD).call(this,i,this.range.valueAsNumber);e.style.transform=`translateX(${r})`,e.style.setProperty("--_range-width",`${i.range.width}`),t.style.setProperty("--_box-shift",`${s}`),t.style.setProperty("--_box-width",`${i.box.width}px`),t.style.setProperty("visibility","initial")}handleEvent(e){switch(super.handleEvent(e),e.type){case"input":gK(this,tO,tN).call(this);break;case"pointermove":gK(this,tC,tP).call(this,e);break;case"pointerup":gH(this,tb)&&gV(this,tb,!1);break;case"pointerdown":gV(this,tb,!0);break;case"pointerleave":gK(this,tx,tM).call(this,null);break;case"transitionstart":fs(e.target,this)&&setTimeout(()=>gH(this,tT).call(this),0)}}}tu=new WeakMap,tc=new WeakMap,tf=new WeakMap,tm=new WeakMap,tp=new WeakMap,tg=new WeakMap,tv=new WeakMap,tE=new WeakMap,ty=new WeakMap,tb=new WeakMap,tT=new WeakMap,t_=new WeakSet,tA=function(){return this.isConnected&&!this.mediaPaused&&!this.mediaLoading&&!this.mediaEnded&&this.mediaSeekableEnd>0&&fn(this)},tS=new WeakMap,tk=new WeakSet,tL=function(e){var t;let i=(null!=(t=this.getAttribute("bounds")?fa(this,`#${this.getAttribute("bounds")}`):this.parentElement)?t:this).getBoundingClientRect(),r=this.range.getBoundingClientRect(),s=e.offsetWidth,a=-(r.left-i.left-s/2),n=i.right-r.left-s/2;return{box:{width:s,min:a,max:n},bounds:i,range:r}},tR=new WeakSet,tI=function(e,t){let i=`${100*t}%`,{width:r,min:s,max:a}=e.box;if(!r)return i;if(!Number.isNaN(s)){let e=`calc(1 / var(--_range-width) * 100 * ${s}% + var(--media-box-padding-left))`;i=`max(${e}, ${i})`}if(!Number.isNaN(a)){let e=`calc(1 / var(--_range-width) * 100 * ${a}% - var(--media-box-padding-right))`;i=`min(${i}, ${e})`}return i},tw=new WeakSet,tD=function(e,t){let{width:i,min:r,max:s}
1205=e.box,a=t*e.range.width;if(a<r+gH(this,tv)){let t=e.range.left-e.bounds.left-gH(this,tv);return`${a-i/2+t}px`}if(a>s-gH(this,tE)){let t=e.bounds.right-e.range.right-gH(this,tE);return`${a+i/2-t-e.range.width}px`}return 0},tC=new WeakSet,tP=function(e){let t=[...gH(this,tf)].some(t=>e.composedPath().includes(t));if(!this.dragging&&(t||!e.composedPath().includes(this)))return void gK(this,tx,tM).call(this,null);let i=this.mediaSeekableEnd;if(!i)return;let r=fl(this.shadowRoot,"#preview-rail"),s=fl(this.shadowRoot,'[part~="preview-box"]'),a=gK(this,tk,tL).call(this,gH(this,tp)),n=(e.clientX-a.range.left)/a.range.width;n=Math.max(0,Math.min(1,n));let l=gK(this,tR,tI).call(this,a,n),o=gK(this,tw,tD).call(this,a,n);r.style.transform=`translateX(${l})`,r.style.setProperty("--_range-width",`${a.range.width}`),s.style.setProperty("--_box-shift",`${o}`),s.style.setProperty("--_box-width",`${a.box.width}px`),1>Math.abs(Math.round(gH(this,tm))-Math.round(n*i))&&n>.01&&n<.99||(gV(this,tm,n*i),gK(this,tx,tM).call(this,gH(this,tm)))},tx=new WeakSet,tM=function(e){this.dispatchEvent(new c4.CustomEvent(cL.MEDIA_PREVIEW_REQUEST,{composed:!0,bubbles:!0,detail:e}))},tO=new WeakSet,tN=function(){gH(this,tc).stop();let e=gq(this);this.dispatchEvent(new c4.CustomEvent(cL.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:e}))},gj.shadowRootOptions={mode:"open"},gj.getContainerTemplateHTML=function(e){return`
1206    <style>
1207      :host {
1208        --media-box-border-radius: 4px;
1209        --media-box-padding-left: 10px;
1210        --media-box-padding-right: 10px;
1211        --media-preview-border-radius: var(--media-box-border-radius);
1212        --media-box-arrow-offset: var(--media-box-border-radius);
1213        --_control-background: var(--media-control-background, var(--media-secondary-color, rgb(20 20 30 / .7)));
1214        --_preview-background: var(--media-preview-background, var(--_control-background));
1215
1216        
1217        contain: layout;
1218      }
1219
1220      #buffered {
1221        background: var(--media-time-range-buffered-color, rgb(255 255 255 / .4));
1222        position: absolute;
1223        height: 100%;
1224        will-change: width;
1225      }
1226
1227      #preview-rail,
1228      #current-rail {
1229        width: 100%;
1230        position: absolute;
1231        left: 0;
1232        bottom: 100%;
1233        pointer-events: none;
1234        will-change: transform;
1235      }
1236
1237      [part~="box"] {
1238        width: min-content;
1239        
1240        position: absolute;
1241        bottom: 100%;
1242        flex-direction: column;
1243        align-items: center;
1244        transform: translateX(-50%);
1245      }
1246
1247      [part~="current-box"] {
1248        display: var(--media-current-box-display, var(--media-box-display, flex));
1249        margin: var(--media-current-box-margin, var(--media-box-margin, 0 0 5px));
1250        visibility: hidden;
1251      }
1252
1253      [part~="preview-box"] {
1254        display: var(--media-preview-box-display, var(--media-box-display, flex));
1255        margin: var(--media-preview-box-margin, var(--media-box-margin, 0 0 5px));
1256        transition-property: var(--media-preview-transition-property, visibility, opacity);
1257        transition-duration: var(--media-preview-transition-duration-out, .25s);
1258        transition-delay: var(--media-preview-transition-delay-out, 0s);
1259        visibility: hidden;
1260        opacity: 0;
1261      }
1262
1263      :host(:is([${cD.MEDIA_PREVIEW_IMAGE}], [${cD.MEDIA_PREVIEW_TIME}])[dragging]) [part~="preview-box"] {
1264        transition-duration: var(--media-preview-transition-duration-in, .5s);
1265        transition-delay: var(--media-preview-transition-delay-in, .25s);
1266        visibility: visible;
1267        opacity: 1;
1268      }
1269
1270      @media (hover: hover) {
1271        :host(:is([${cD.MEDIA_PREVIEW_IMAGE}], [${cD.MEDIA_PREVIEW_TIME}]):hover) [part~="preview-box"] {
1272          transition-duration: var(--media-preview-transition-duration-in, .5s);
1273          transition-delay: var(--media-preview-transition-delay-in, .25s);
1274          visibility: visible;
1275          opacity: 1;
1276        }
1277      }
1278
1279      media-preview-thumbnail,
1280      ::slotted(media-preview-thumbnail) {
1281        visibility: hidden;
1282        
1283        transition: visibility 0s .25s;
1284        transition-delay: calc(var(--media-preview-transition-delay-out, 0s) + var(--media-preview-transition-duration-out, .25s));
1285        background: var(--media-preview-thumbnail-background, var(--_preview-background));
1286        box-shadow: var(--media-preview-thumbnail-box-shadow, 0 0 4px rgb(0 0 0 / .2));
1287        max-width: var(--media-preview-thumbnail-max-width, 180px);
1288        max-height: var(--media-preview-thumbnail-max-height, 160px);
1289        min-width: var(--media-preview-thumbnail-min-width, 120px);
1290        min-height: var(--media-preview-thumbnail-min-height, 80px);
1291        border: var(--media-preview-thumbnail-border);
1292        border-radius: var(--media-preview-thumbnail-border-radius,
1293          var(--media-preview-border-radius) var(--media-preview-border-radius) 0 0);
1294      }
1295
1296      :host([${cD.MEDIA_PREVIEW_IMAGE}][dragging]) media-preview-thumbnail,
1297      :host([${cD.MEDIA_PREVIEW_IMAGE}][dragging]) ::slotted(media-preview-thumbnail) {
1298        transition-delay: var(--media-preview-transition-delay-in, .25s);
1299        visibility: visible;
1300      }
1301
1302      @media (hover: hover) {
1303        :host([${cD.MEDIA_PREVIEW_IMAGE}]:hover) media-preview-thumbnail,
1304        :host([${cD.MEDIA_PREVIEW_IMAGE}]:hover) ::slotted(media-preview-thumbnail) {
1305          transition-delay: var(--media-preview-transition-delay-in, .25s);
1306          visibility: visible;
1307        }
1308
1309        :host([${cD.MEDIA_PREVIEW_TIME}]:hover) {
1310          --media-time-range-hover-display: block;
1311        }
1312      }
1313
1314      media-preview-chapter-display,
1315      ::slotted(media-preview-chapter-display) {
1316        font-size: var(--media-font-size, 13px);
1317        line-height: 17px;
1318        min-width: 0;
1319        visibility: hidden;
1320        
1321        transition: min-width 0s, border-radius 0s, margin 0s, padding 0s, visibility 0s;
1322        transition-delay: calc(var(--media-preview-transition-delay-out, 0s) + var(--media-preview-transition-duration-out, .25s));
1323        background: var(--media-preview-chapter-background, var(--_preview-background));
1324        border-radius: var(--media-preview-chapter-border-radius,
1325          var(--media-preview-border-radius) var(--media-preview-border-radius)
1326          var(--media-preview-border-radius) var(--media-preview-border-radius));
1327        padding: var(--media-preview-chapter-padding, 3.5px 9px);
1328        margin: var(--media-preview-chapter-margin, 0 0 5px);
1329        text-shadow: var(--media-preview-chapter-text-shadow, 0 0 4px rgb(0 0 0 / .75));
1330      }
1331
1332      :host([${cD.MEDIA_PREVIEW_IMAGE}]) media-preview-chapter-display,
1333      :host([${cD.MEDIA_PREVIEW_IMAGE}]) ::slotted(media-preview-chapter-display) {
1334        transition-delay: var(--media-preview-transition-delay-in, .25s);
1335        border-radius: var(--media-preview-chapter-border-radius, 0);
1336        padding: var(--media-preview-chapter-padding, 3.5px 9px 0);
1337        margin: var(--media-preview-chapter-margin, 0);
1338        min-width: 100%;
1339      }
1340
1341      media-preview-chapter-display[${cD.MEDIA_PREVIEW_CHAPTER}],
1342      ::slotted(media-preview-chapter-display[${cD.MEDIA_PREVIEW_CHAPTER}]) {
1343        visibility: visible;
1344      }
1345
1346      media-preview-chapter-display:not([aria-valuetext]),
1347      ::slotted(media-preview-chapter-display:not([aria-valuetext])) {
1348        display: none;
1349      }
1350
1351      media-preview-time-display,
1352      ::slotted(media-preview-time-display),
1353      media-time-display,
1354      ::slotted(media-time-display) {
1355        font-size: var(--media-font-size, 13px);
1356        line-height: 17px;
1357        min-width: 0;
1358        
1359        transition: min-width 0s, border-radius 0s;
1360        transition-delay: calc(var(--media-preview-transition-delay-out, 0s) + var(--media-preview-transition-duration-out, .25s));
1361        background: var(--media-preview-time-background, var(--_preview-background));
1362        border-radius: var(--media-preview-time-border-radius,
1363          var(--media-preview-border-radius) var(--media-preview-border-radius)
1364          var(--media-preview-border-radius) var(--media-preview-border-radius));
1365        padding: var(--media-preview-time-padding, 3.5px 9px);
1366        margin: var(--media-preview-time-margin, 0);
1367        text-shadow: var(--media-preview-time-text-shadow, 0 0 4px rgb(0 0 0 / .75));
1368        transform: translateX(min(
1369          max(calc(50% - var(--_box-width) / 2),
1370          calc(var(--_box-shift, 0))),
1371          calc(var(--_box-width) / 2 - 50%)
1372        ));
1373      }
1374
1375      :host([${cD.MEDIA_PREVIEW_IMAGE}]) media-preview-time-display,
1376      :host([${cD.MEDIA_PREVIEW_IMAGE}]) ::slotted(media-preview-time-display) {
1377        transition-delay: var(--media-preview-transition-delay-in, .25s);
1378        border-radius: var(--media-preview-time-border-radius,
1379          0 0 var(--media-preview-border-radius) var(--media-preview-border-radius));
1380        min-width: 100%;
1381      }
1382
1383      :host([${cD.MEDIA_PREVIEW_TIME}]:hover) {
1384        --media-time-range-hover-display: block;
1385      }
1386
1387      [part~="arrow"],
1388      ::slotted([part~="arrow"]) {
1389        display: var(--media-box-arrow-display, inline-block);
1390        transform: translateX(min(
1391          max(calc(50% - var(--_box-width) / 2 + var(--media-box-arrow-offset)),
1392          calc(var(--_box-shift, 0))),
1393          calc(var(--_box-width) / 2 - 50% - var(--media-box-arrow-offset))
1394        ));
1395        
1396        border-color: transparent;
1397        border-top-color: var(--media-box-arrow-background, var(--_control-background));
1398        border-width: var(--media-box-arrow-border-width,
1399          var(--media-box-arrow-height, 5px) var(--media-box-arrow-width, 6px) 0);
1400        border-style: solid;
1401        justify-content: center;
1402        height: 0;
1403      }
1404    </style>
1405    <div id="preview-rail">
1406      <slot name="preview" part="box preview-box">
1407        <media-preview-thumbnail>
1408          <template shadowrootmode="${gg.shadowRootOptions.mode}">
1409            ${gg.getTemplateHTML({})}
1410          </template>
1411        </media-preview-thumbnail>
1412        <media-preview-chapter-display></media-preview-chapter-display>
1413        <media-preview-time-display></media-preview-time-display>
1414        <slot name="preview-arrow"><div part="arrow"></div></slot>
1415      </slot>
1416    </div>
1417    <div id="current-rail">
1418      <slot name="current" part="box current-box">
1419        
1420      </slot>
1421    </div>
1422  `},c4.customElements.get("media-time-range")||c4.customElements.define("media-time-range",gj);var gY=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot read from private field");return i?i.call(e):t.get(e)};class gQ extends pg{constructor(){super(...arguments),((e,t,i)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,i)})(this,tU,()=>{let e=this.range.value,t=new c4.CustomEvent(cL.MEDIA_VOLUME_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)})}static get observedAttributes(){return[...super.observedAttributes,cD.MEDIA_VOLUME,cD.MEDIA_MUTED,cD.MEDIA_VOLUME_UNAVAILABLE]}connectedCallback(){super.connectedCallback(),this.range.setAttribute("aria-label",cq("volume")),this.range.addEventListener("input",gY(this,tU))}disconnectedCallback(){this.range.removeEventListener("input",gY(this,tU)),super.disconnectedCallback()}attributeChangedCallback(e,t,i){if(super.attributeChangedCallback(e,t,i),e===cD.MEDIA_VOLUME||e===cD.MEDIA_MUTED){let e;this.range.valueAsNumber=this.mediaMuted?0:this.mediaVolume,this.range.setAttribute("aria-valuetext",(e=this.range.valueAsNumber,`${Math.round(100*e)}%`)),this.updateBar()}}
1422get mediaVolume(){return fd(this,cD.MEDIA_VOLUME,1)}set mediaVolume(e){fh(this,cD.MEDIA_VOLUME,e)}get mediaMuted(){return fu(this,cD.MEDIA_MUTED)}set mediaMuted(e){fc(this,cD.MEDIA_MUTED,e)}get mediaVolumeUnavailable(){return ff(this,cD.MEDIA_VOLUME_UNAVAILABLE)}set mediaVolumeUnavailable(e){fm(this,cD.MEDIA_VOLUME_UNAVAILABLE,e)}}tU=new WeakMap,c4.customElements.get("media-volume-range")||c4.customElements.define("media-volume-range",gQ);class gz extends m2{constructor(){super(...arguments),this.container=null}static get observedAttributes(){return[...super.observedAttributes,cD.MEDIA_LOOP]}connectedCallback(){var e;super.connectedCallback(),this.container=(null==(e=this.shadowRoot)?void 0:e.querySelector("#icon"))||null,this.container&&(this.container.textContent=cq("Loop"))}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===cD.MEDIA_LOOP&&this.container&&this.setAttribute("aria-checked",this.mediaLoop?"true":"false")}get mediaLoop(){return fu(this,cD.MEDIA_LOOP)}set mediaLoop(e){fc(this,cD.MEDIA_LOOP,e)}handleClick(){let e=!this.mediaLoop,t=new c4.CustomEvent(cL.MEDIA_LOOP_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)}}function gX(e){return"boolean"==typeof e?e?"":void 0:"function"==typeof e?void 0:Array.isArray(e)&&e.every(e=>"string"==typeof e||"number"==typeof e||"boolean"==typeof e)?e.join(" "):"object"!=typeof e||null===e?e:void 0}gz.getSlotTemplateHTML=function(e){return`
1423      <style>
1424        :host {
1425          min-width: 4ch;
1426          padding: var(--media-button-padding, var(--media-control-padding, 10px 5px));
1427          width: 100%;
1428          display: grid;
1429          grid-template-columns: 1fr auto;
1430          gap: 1rem;
1431          font-weight: var(--media-button-font-weight, normal);
1432        }
1433
1434        #checked-indicator {
1435          display: none;
1436        }
1437
1438        :host([${cD.MEDIA_LOOP}]) #checked-indicator {
1439          display: block;
1440        }
1441      </style>
1442      
1443      <span id="icon">
1444     </span>
1445
1446      <div id="checked-indicator">
1447        <svg aria-hidden="true" viewBox="0 1 24 24" part="checked-indicator indicator">
1448          <path d="m10 15.17 9.193-9.191 1.414 1.414-10.606 10.606-6.364-6.364 1.414-1.414 4.95 4.95Z"/>
1449        </svg>
1450      </div>
1451    `},gz.getTooltipContentHTML=function(){return cq("Loop")},c4.customElements.get("media-loop-button")||c4.customElements.define("media-loop-button",gz),cS({tagName:"media-gesture-receiver",elementClass:fE,react:tB.default,toAttributeValue:gX,defaultProps:{suppressHydrationWarning:!0}}),cS({tagName:"media-container",elementClass:fM,react:tB.default,toAttributeValue:gX,defaultProps:{suppressHydrationWarning:!0}});let gZ=cS({tagName:"media-controller",elementClass:mO,react:tB.default,toAttributeValue:gX,defaultProps:{suppressHydrationWarning:!0}});cS({tagName:"media-tooltip",elementClass:mY,react:tB.default,toAttributeValue:gX,defaultProps:{suppressHydrationWarning:!0}}),cS({tagName:"media-chrome-button",elementClass:m2,react:tB.default,toAttributeValue:gX,defaultProps:{suppressHydrationWarning:!0}}),cS({tagName:"media-airplay-button",elementClass:m5,react:tB.default,toAttributeValue:gX,defaultProps:{suppressHydrationWarning:!0}}),cS({tagName:"media-captions-button",elementClass:m7,react:tB.default,toAttributeValue:gX,defaultProps:{suppressHydrationWarning:!0}}),cS({tagName:"media-cast-button",elementClass:pr,react:tB.default,toAttributeValue:gX,defaultProps:{suppressHydrationWarning:!0}}),cS({tagName:"media-chrome-dialog",elementClass:ph,react:tB.default,toAttributeValue:gX,defaultProps:{suppressHydrationWarning:!0}}),cS({tagName:"media-chrome-range",elementClass:pg,react:tB.default,toAttributeValue:gX,defaultProps:{suppressHydrationWarning:!0}});let gJ=cS({tagName:"media-control-bar",elementClass:pb,react:tB.default,toAttributeValue:gX,defaultProps:{suppressHydrationWarning:!0}});cS({tagName:"media-text-display",elementClass:pS,react:tB.default,toAttributeValue:gX,defaultProps:{suppressHydrationWarning:!0}}),cS({tagName:"media-duration-display",elementClass:pR,react:tB.default,toAttributeValue:gX,defaultProps:{suppressHydrationWarning:!0}}),cS({tagName:"media-error-dialog",elementClass:pM,react:tB.default,toAttributeValue:gX,defaultProps:{suppressHydrationWarning:!0}}),cS({tagName:"media-keyboard-shortcuts-dialog",elementClass:pU,react:tB.default,toAttributeValue:gX,defaultProps:{suppressHydrationWarning:!0}});let g0=cS({tagName:"media-fullscreen-button",elementClass:pG,react:tB.default,toAttributeValue:gX,defaultProps:{suppressHydrationWarning:!0}});cS({tagName:"media-live-button",elementClass:pY,react:tB.default,toAttributeValue:gX,defaultProps:{suppressHydrationWarning:!0}}),cS({tagName:"media-loading-indicator",elementClass:p2,react:tB.default,toAttributeValue:gX,defaultProps:{suppressHydrationWarning:!0}});let g1=cS({tagName:"media-mute-button",elementClass:p6,react:tB.default,toAttributeValue:gX,defaultProps:{suppressHydrationWarning:!0}});cS({tagName:"media-pip-button",elementClass:ge,react:tB.default,toAttributeValue:gX,defaultProps:{suppressHydrationWarning:!0}}),cS({tagName:"media-playback-rate-button",elementClass:gs,react:tB.default,toAttributeValue:gX,defaultProps:{suppressHydrationWarning:!0}});let g2=cS({tagName:"media-play-button",elementClass:go,react:tB.default,toAttributeValue:gX,defaultProps:{suppressHydrationWarning:!0}});cS({tagName:"media-poster-image",elementClass:gh,react:tB.default,toAttributeValue:gX,defaultProps:{suppressHydrationWarning:!0}}),cS({tagName:"media-preview-chapter-display",elementClass:gc,react:tB.default,toAttributeValue:gX,defaultProps:{suppressHydrationWarning:!0}}
1451),cS({tagName:"media-preview-thumbnail",elementClass:gg,react:tB.default,toAttributeValue:gX,defaultProps:{suppressHydrationWarning:!0}}),cS({tagName:"media-preview-time-display",elementClass:gy,react:tB.default,toAttributeValue:gX,defaultProps:{suppressHydrationWarning:!0}}),cS({tagName:"media-seek-backward-button",elementClass:gT,react:tB.default,toAttributeValue:gX,defaultProps:{suppressHydrationWarning:!0}}),cS({tagName:"media-seek-forward-button",elementClass:gA,react:tB.default,toAttributeValue:gX,defaultProps:{suppressHydrationWarning:!0}});let g3=cS({tagName:"media-time-display",elementClass:gM,react:tB.default,toAttributeValue:gX,defaultProps:{suppressHydrationWarning:!0}}),g4=cS({tagName:"media-time-range",elementClass:gj,react:tB.default,toAttributeValue:gX,defaultProps:{suppressHydrationWarning:!0}});cS({tagName:"media-volume-range",elementClass:gQ,react:tB.default,toAttributeValue:gX,defaultProps:{suppressHydrationWarning:!0}}),cS({tagName:"media-loop-button",elementClass:gz,react:tB.default,toAttributeValue:gX,defaultProps:{suppressHydrationWarning:!0}});var g5=e.i(225927);function g8(e){let t,i,r,s,a,n,l,o,d,h,u,c,f,m=(0,t$.c)(46),{src:g,playbackId:v,className:E,keyPrefix:y,loop:b,width:T,height:_,full:A,autoSize:S,aspectRatio:k,showControls:L,autoPlay:R}=e,I=void 0===y?"":y,w=void 0===L||L,D=void 0===R||R,C=(0,tB.useRef)(null),P=(0,tB.useRef)(null),[x,M]=(0,tB.useState)(!1),[O,N]=(0,tB.useState)(null),U=(0,g5.usePathname)(),F=(0,tB.useRef)(U),$=S||"auto"===k,B=$?T&&_?`${T} / ${_}`:O?`${O.width} / ${O.height}`:void 0:void 0;m[0]!==k||m[1]!==B||m[2]!==A||m[3]!==_||m[4]!==$||m[5]!==T?(t=A?void 0:$?B:k&&"auto"!==k?k.replace("/"," / "):T&&_?`${T} / ${_}`:"16 / 9",m[0]=k,m[1]=B,m[2]=A,m[3]=_,m[4]=$,m[5]=T,m[6]=t):t=m[6];let H=t;if(m[7]!==x?(i=()=>{if(x)return;if("u"<typeof IntersectionObserver)return void M(!0);let e=C.current;if(!e)return;let t=new IntersectionObserver(e=>{e.forEach(e=>{e.isIntersecting&&(M(!0),t.disconnect())})},{rootMargin:"200px",threshold:0});return t.observe(e),()=>{t.disconnect()}},m[7]=x,m[8]=i):i=m[8],m[9]!==x||m[10]!==v||m[11]!==g?(r=[g,v,x],m[9]=x,m[10]=v,m[11]=g,m[12]=r):r=m[12],(0,tB.useEffect)(i,r),m[13]!==U?(s=()=>{U!==F.current&&P.current?.pause()},a=[U],m[13]=U,m[14]=s,m[15]=a):(s=m[14],a=m[15]),(0,tB.useEffect)(s,a),m[16]===Symbol.for("react.memo_cache_sentinel")?(l=()=>()=>{P.current?.pause()},n=[],m[16]=n,m[17]=l):(n=m[16],l=m[17]),(0,tB.useEffect)(l,n),!g&&!v)return null;let G=g?.startsWith("http://")||g?.startsWith("https://")?"anonymous":void 0,V=v?`https://image.mux.com/${v}/thumbnail.jpg?time=0`:void 0;m[18]===Symbol.for("react.memo_cache_sentinel")?(o=e=>{let t=e.currentTarget;t.videoWidth&&t.videoHeight&&N({width:t.videoWidth,height:t.videoHeight})},m[18]=o):o=m[18];let K=o;m[19]!==A?(d=A&&{width:"100%",height:"100%",minHeight:"100vh"},m[19]=A,m[20]=d):d=m[20],m[21]!==$?(h=$&&{width:"fit-content",maxWidth:"100%"},m[21]=$,m[22]=h):h=m[22],m[23]!==H||m[24]!==d||m[25]!==h?(u={aspectRatio:H,overflow:"hidden",...d,...h},m[23]=H,m[24]=d,m[25]=h,m[26]=u):u=m[26];let W=A?"w-full min-h-screen":void 0;return m[27]!==H||m[28]!==B||m[29]!==D||m[30]!==E||m[31]!==A||m[32]!==x||m[33]!==I||m[34]!==b||m[35]!==v||m[36]!==V||m[37]!==w||m[38]!==g||m[39]!==$||m[40]!==G?(c=x?(0,tF.jsxs)(gZ,{className:E,style:{...H&&{aspectRatio:H},...$?{width:"fit-content",maxWidth:"100%"}:{width:"100%",height:"100%"}},children:[v?(0,tF.jsx)(cc,{ref:e=>{P.current=e},slot:"media",playbackId:v,poster:V,preload:D?"auto":"metadata",autoPlay:D,playsInline:!0,muted:D,tabIndex:-1,loop:b,streamType:"on-demand",onLoadedMetadata:K,style:{...$?{width:"auto",height:"auto",maxWidth:"100%"}:{width:"100%",height:"100%"},display:"block",...A&&{objectFit:"cover"}}}):(0,tF.jsx)("video",{ref:P,slot:"media",src:g,preload:D?"auto":"metadata",autoPlay:D,playsInline:!0,muted:D,crossOrigin:G,tabIndex:-1,loop:b,onLoadedMetadata:K,style:{...$?{width:"auto",height:"auto",maxWidth:"100%"}:{width:"100%",height:"100%"},display:"block",...A&&{objectFit:"cover"}}}),w&&(0,tF.jsxs)(gJ,{className:"media-control-bar",children:[(0,tF.jsx)(g3,{showDuration:!1,className:"media-control-bar-button"},`${I}time-display`),(0,tF.jsx)(g4,{className:"media-control-bar-time-range"},`${I}time-range`),(0,tF.jsxs)(g2,{noTooltip:!0,className:"media-control-bar-button",children:[(0,tF.jsx)("span",{slot:"play",children:(0,tF.jsx)(cv,{size:16})}),(0,tF.jsx)("span",{slot:"pause",children:(0,tF.jsx)(cg,{size:16})})]},`${I}play-button`),(0,tF.jsxs)(g1,{noTooltip:!0,className:"media-control-bar-button",children:[(0,tF.jsx)("span",{slot:"off",children:(0,tF.jsx)(cy,{size:16})}),(0,tF.jsx)("span",{slot:"high",children:(0,tF.jsx)(cE,{size:16})}),(0,tF.jsx)("span",{slot:"medium",children:(0,tF.jsx)(cE,{size:16})}),(0,tF.jsx)("span",{slot:"low",children:(0,tF.jsx)(cE,{size:16})})]},`${I}mute-button`),(0,tF.jsxs)(g0,{noTooltip:!0,className:"media-control-bar-button",children:[(0,tF.jsx)("span",{slot:"enter",children:(0,tF.jsx)(cm,{size:16})}),(0,tF.jsx)("span",{slot:"exit",children:(0,tF.jsx)(cp,{size:16})})]},`${I}fullscreen-button`)]})]},`${I}media-controller`):(0,tF.jsx)("div",{className:E,style:{...$?{aspectRatio:B??"16/9",maxWidth:"100%",width:"100%"}:{width:"100%",height:"100%"}
1451,backgroundColor:"var(--theme-bg-sec, #1a1a1a)",...V&&{backgroundImage:`url(${V})`,backgroundSize:"cover",backgroundPosition:"center"}}}),m[27]=H,m[28]=B,m[29]=D,m[30]=E,m[31]=A,m[32]=x,m[33]=I,m[34]=b,m[35]=v,m[36]=V,m[37]=w,m[38]=g,m[39]=$,m[40]=G,m[41]=c):c=m[41],m[42]!==u||m[43]!==W||m[44]!==c?(f=(0,tF.jsx)("div",{ref:C,style:u,className:W,children:c}),m[42]=u,m[43]=W,m[44]=c,m[45]=f):f=m[45],f}e.s(["Video",0,g8,"default",0,function(e){let t,i,r,s=(0,t$.c)(19),{src:a,playbackId:n,caption:l,className:o,keyPrefix:d,loop:h,width:u,height:c,full:f,wide:m,autoSize:g,aspectRatio:v,compact:E,showControls:y,autoPlay:b}=e,T=void 0===y||y,_=void 0===b||b,A=f?"grid-prose__w-full grid-prose__w-full--no-margin":m?"grid-prose__w-wide grid-prose__w-wide--no-margin":void 0===E||E?"!my-1":"",S=`media-border-container media-controller ${g||"auto"===v?"":"w-full"} ${void 0===o?"":o}`;return s[0]!==v||s[1]!==_||s[2]!==g||s[3]!==f||s[4]!==c||s[5]!==d||s[6]!==h||s[7]!==n||s[8]!==T||s[9]!==a||s[10]!==S||s[11]!==u?(t=(0,tF.jsx)(g8,{src:a,playbackId:n,className:S,keyPrefix:d,loop:h,width:u,height:c,full:f,autoSize:g,aspectRatio:v,showControls:T,autoPlay:_}),s[0]=v,s[1]=_,s[2]=g,s[3]=f,s[4]=c,s[5]=d,s[6]=h,s[7]=n,s[8]=T,s[9]=a,s[10]=S,s[11]=u,s[12]=t):t=s[12],s[13]!==l?(i="string"==typeof l&&l.length>0?(0,tF.jsx)("figcaption",{children:l}):null,s[13]=l,s[14]=i):i=s[14],s[15]!==A||s[16]!==t||s[17]!==i?(r=(0,tF.jsxs)("figure",{className:A,children:[t,i]}),s[15]=A,s[16]=t,s[17]=i,s[18]=r):r=s[18],r}],180185)}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.