/**
 * Minified by jsDelivr using Terser v5.48.0.
 * Original file: /npm/@mux/mux-player@3.14.1/dist/mux-player.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
"use strict";(()=>{var e=Object.defineProperty,t=Object.getPrototypeOf,i=Reflect.get,r=e=>{throw TypeError(e)},a=(t,i,r)=>((t,i,r)=>i in t?e(t,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[i]=r)(t,"symbol"!=typeof i?i+"":i,r),n=(e,t,i)=>t.has(e)||r("Cannot "+i),s=(e,t,i)=>(n(e,t,"read from private field"),i?i.call(e):t.get(e)),o=(e,t,i)=>t.has(e)?r("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,i),l=(e,t,i,r)=>(n(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i),d=(e,t,i)=>(n(e,t,"access private method"),i),u=(e,r,a)=>i(t(e),a,r),h=class{addEventListener(){}removeEventListener(){}dispatchEvent(e){return!0}};if("undefined"==typeof DocumentFragment){class e extends h{}globalThis.DocumentFragment=e}var c,m=class extends h{},f={get(e){},define(e,t,i){},getName:e=>null,upgrade(e){},whenDefined:e=>Promise.resolve(m)};c=new WeakMap;var p={document:{createElement:function(e,t){return new m}},DocumentFragment:DocumentFragment,customElements:f,CustomEvent:class{constructor(e,t={}){o(this,c),l(this,c,null==t?void 0:t.detail)}get detail(){return s(this,c)}initCustomEvent(){}},EventTarget:h,HTMLElement:m,HTMLVideoElement:class extends h{}},g="undefined"==typeof window||void 0===globalThis.customElements,v=g?p:globalThis,E=(g||globalThis.document,Object.create),y=Object.defineProperty,b=Object.getOwnPropertyDescriptor,T=Object.getOwnPropertyNames,A=Object.getPrototypeOf,_=Object.prototype.hasOwnProperty,S=function(e,t){return function(){return e&&(t=e(e=0)),t}},k=function(e,t){return function(){return t||e((t={exports:{}}).exports,t),t.exports}};function I(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):I(e,t)}var R=S(function(){R()});function L(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}var w=S(function(){}),D=k(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(),a=t(r);if(a)return a;r.childNodes&&r.childNodes.length&&(e=i.call(r.childNodes).concat(e))}}}),C=k(function(e,t){function i(e,t){if(!I(this,i))return new i(e,t);this.data=e,this.nodeValue=e,this.length=e.length,this.ownerDocument=t||null}R(),t.exports=i,i.prototype.nodeType=8,i.prototype.nodeName="#comment",i.prototype.toString=function(){return"[object Comment]"}}),M=k(function(e,t){function i(e,t){if(!I(this,i))return new i(e);this.data=e||"",this.length=this.data.length,this.ownerDocument=t||null}R(),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,a=r.substring(0,e),n=r.substring(e+t,r.length);this.data=a+i+n,this.length=this.data.length}}),P=k(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)}}),x=k(function(e,t){t.exports=function(e,t){var i=this;i.listeners||(i.listeners={}),i.listeners[e]||(i.listeners[e]=[]),-1===i.listeners[e].indexOf(t)&&i.listeners[e].push(t)}}),O=k(function(e,t){t.exports=function(e,t){var i=this;if(i.listeners&&i.listeners[e]){var r=i.listeners[e],a=r.indexOf(t);-1!==a&&r.splice(a,1)}}}),N=k(function(e,t){w(),t.exports=r;var i=["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"];function r(e){switch(e.nodeType){case 3:return s(e.data);case 8:return"\x3c!--"+e.data+"--\x3e";default:return function(e){var t=[],o=e.tagName;return"http://www.w3.org/1999/xhtml"===e.namespaceURI&&(o=o.toLowerCase()),t.push("<"+o+function(e){var t=[];for(var i in e)a(e,i)&&t.push({name:i,value:e[i]});for(var r in e._attributes)for(var s in e._attributes[r]){var o=e._attributes[r][s],l=(o.prefix?o.prefix+":":"")+s;t.push({name:l,value:o.value})}return e.className&&t.push({name:"class",value:e.className}),t.length?n(t):""}(e)+function(e){var t=e.dataset,i=[];for(var r in t)i.push({name:"data-"+r,value:t[r]});return i.length?n(i):""}(e)),i.indexOf(o)>-1?t.push(" />"):(t.push(">"),e.childNodes.length?t.push.apply(t,e.childNodes.map(r)):e.textContent||e.innerText?t.push(s(e.textContent||e.innerText)):e.innerHTML&&t.push(e.innerHTML),t.push("</"+o+">")),t.join("")}(e)}}function a(e,t){var i=L(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}function n(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+'="'+function(e){return s(e).replace(/"/g,"&quot;")}(r)+'"')}),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;")}}),U=k(function(e,t){R();var i=D(),r=P(),a=x(),n=O(),s=N(),o="http://www.w3.org/1999/xhtml";function l(e,t,i){if(!I(this,l))return new l(e);var r=void 0===i?o:i||null;this.tagName=r===o?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=l,l.prototype.type="DOMElement",l.prototype.nodeType=1,l.prototype.appendChild=function(e){return e.parentNode&&e.parentNode.removeChild(e),this.childNodes.push(e),e.parentNode=this,e},l.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},l.prototype.removeChild=function(e){var t=this.childNodes.indexOf(e);return this.childNodes.splice(t,1),e.parentNode=null,e},l.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},l.prototype.setAttributeNS=function(e,t,i){var r=null,a=t,n=t.indexOf(":");(n>-1&&(r=t.substr(0,n),a=t.substr(n+1)),"INPUT"===this.tagName&&"type"===t)?this.type=i:(this._attributes[e]||(this._attributes[e]={}))[a]={value:i,prefix:r}},l.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},l.prototype.removeAttributeNS=function(e,t){var i=this._attributes[e];i&&delete i[t]},l.prototype.hasAttributeNS=function(e,t){var i=this._attributes[e];return!!i&&t in i},l.prototype.setAttribute=function(e,t){return this.setAttributeNS(null,e,t)},l.prototype.getAttribute=function(e){return this.getAttributeNS(null,e)},l.prototype.removeAttribute=function(e){return this.removeAttributeNS(null,e)},l.prototype.hasAttribute=function(e){return this.hasAttributeNS(null,e)},l.prototype.removeEventListener=n,l.prototype.addEventListener=a,l.prototype.dispatchEvent=r,l.prototype.focus=function(){},l.prototype.toString=function(){return s(this)},l.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},l.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},l.prototype.contains=function(e){return i(this,function(t){return e===t})||!1}}),F=k(function(e,t){R();var i=U();function r(e){if(!I(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("")}}),B=k(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(){}}),$=k(function(e,t){R();var i=D(),r=C(),a=M(),n=U(),s=F(),o=B(),l=P(),d=x(),u=O();function h(){if(!I(this,h))return new h;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=h;var c=h.prototype;c.createTextNode=function(e){return new a(e,this)},c.createElementNS=function(e,t){var i=null===e?null:String(e);return new n(t,this,i)},c.createElement=function(e){return new n(e,this)},c.createDocumentFragment=function(){return new s(this)},c.createEvent=function(e){return new o(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=n.prototype.getElementsByClassName,c.getElementsByTagName=n.prototype.getElementsByTagName,c.contains=n.prototype.contains,c.removeEventListener=u,c.addEventListener=d,c.dispatchEvent=l}),H=k(function(e,t){var i=$();t.exports=new i}),G=k(function(e,t){var i,r="undefined"!=typeof global?global:"undefined"!=typeof window?window:{},a=H();"undefined"!=typeof document?i=document:(i=r["__GLOBAL_DOCUMENT_CACHE@4"])||(i=r["__GLOBAL_DOCUMENT_CACHE@4"]=a),t.exports=i});function K(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,r=new Array(t);i<t;i++)r[i]=e[i];return r}function W(e,t){if(e){if("string"==typeof e)return K(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 K(e,t)}}function V(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var r,a,n=[],s=!0,o=!1;try{for(i=i.call(e);!(s=(r=i.next()).done)&&(n.push(r.value),!t||n.length!==t);s=!0);}catch(e){o=!0,a=e}finally{try{!s&&null!=i.return&&i.return()}finally{if(o)throw a}}return n}}(e,t)||W(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var q="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{},Y={now:function(){var e=q.performance,t=e&&e.timing,i=t&&t.navigationStart,r="number"==typeof i&&"function"==typeof e.now?i+e.now():Date.now();return Math.round(r)}},j=Y,z=function(){var e,t,i;if("function"==typeof(null===(e=q.crypto)||void 0===e?void 0:e.getRandomValues)){i=new Uint8Array(32),q.crypto.getRandomValues(i);for(var r=0;r<32;r++)i[r]=i[r]%16}else{i=[];for(var a=0;a<32;a++)i[a]=16*Math.random()|0}var n=0;t="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t="x"===e?i[n]:3&i[n]|8;return n++,t.toString(16)});var s=j.now(),o=null==s?void 0:s.toString(16).substring(3);return o?t.substring(0,28)+o:t},Q=function(){return("000000"+(Math.random()*Math.pow(36,6)|0).toString(36)).slice(-6)},X=function(e){if(e&&void 0!==e.nodeName)return e.muxId||(e.muxId=Q()),e.muxId;var t;try{t=document.querySelector(e)}catch{}return t&&!t.muxId&&(t.muxId=e),(null==t?void 0:t.muxId)||e},Z=function(e){var t;e&&void 0!==e.nodeName?e=X(t=e):t=document.querySelector(e);var i=t&&t.nodeName?t.nodeName.toLowerCase():"";return[t,e,i]};function J(e){return function(e){if(Array.isArray(e))return K(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||W(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var ee=0,te=1,ie=2,re=3,ae=4,ne=function(e){var t,i,r,a,n,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,o=e?[console,e]:[console],l=(t=console.trace).bind.apply(t,J(o)),d=(i=console.info).bind.apply(i,J(o)),u=(r=console.debug).bind.apply(r,J(o)),h=(a=console.warn).bind.apply(a,J(o)),c=(n=console.error).bind.apply(n,J(o)),m=s;return{trace:function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];if(!(m>ee))return l.apply(void 0,J(t))},debug:function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];if(!(m>te))return u.apply(void 0,J(t))},info:function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];if(!(m>ie))return d.apply(void 0,J(t))},warn:function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];if(!(m>re))return h.apply(void 0,J(t))},error:function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];if(!(m>ae))return c.apply(void 0,J(t))},get level(){return m},set level(e){e!==this.level&&(m=null!=e?e:s)}}}("[mux]");function se(){return"1"===(q.doNotTrack||q.navigator&&q.navigator.doNotTrack)}function oe(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function le(e,t){if(!I(e,t))throw new TypeError("Cannot call a class as a function")}function de(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 ue(e,t,i){return t&&de(e.prototype,t),i&&de(e,i),e}function he(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function ce(e){return(ce=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function me(e,t,i){return me="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,i){var r=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=ce(e)););return e}(e,t);if(r){var a=Object.getOwnPropertyDescriptor(r,t);return a.get?a.get.call(i||e):a.value}},me(e,t,i||e)}function fe(e,t){return(fe=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function pe(e,t){if(null==e)return{};var i,r,a=function(e,t){if(null==e)return{};var i,r,a={},n=Object.keys(e);for(r=0;r<n.length;r++)i=n[r],!(t.indexOf(i)>=0)&&(a[i]=e[i]);return a}(e,t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);for(r=0;r<n.length;r++)i=n[r],!(t.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(e,i)&&(a[i]=e[i])}return a}function ge(e){var t=function(){if("undefined"==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{return!1}}();return function(){var i,r=ce(e);if(t){var a=ce(this).constructor;i=Reflect.construct(r,arguments,a)}else i=r.apply(this,arguments);return function(e,t){return!t||"object"!==L(t)&&"function"!=typeof t?oe(e):t}(this,i)}}R(),w();var ve=function(e){return Ee(e)[0]},Ee=function(e){if("string"!=typeof e||""===e)return["localhost"];var t,i=(e.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/)||[])[4];return i&&(t=(i.match(/[^\.]+\.[^\.]+$/)||[])[0]),[i,t]},ye={exists:function(){var e=q.performance;return void 0!==(e&&e.timing)},domContentLoadedEventEnd:function(){var e=q.performance,t=e&&e.timing;return t&&t.domContentLoadedEventEnd},navigationStart:function(){var e=q.performance,t=e&&e.timing;return t&&t.navigationStart}},be=ye;function Te(e,t,i){i=void 0===i?1:i,e[t]=e[t]||0,e[t]+=i}function Ae(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){he(e,t,i[t])})}return e}function _e(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(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}(Object(t)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(t,i))}),e}var Se=["x-request-id","cf-ray","x-amz-cf-id","x-akamai-request-id"],ke=["x-cdn","content-type"].concat(Se);function Ie(e){var t={};return(e=e||"").trim().split(/[\r\n]+/).forEach(function(e){if(e){var i=e.split(": "),r=i.shift();r&&(ke.indexOf(r.toLowerCase())>=0||0===r.toLowerCase().indexOf("x-litix-"))&&(t[r]=i.join(": "))}}),t}function Re(e){if(e){var t=Se.find(function(t){return void 0!==e[t]});return t?e[t]:void 0}}var Le=function(e){var t={};for(var i in e){var r=e[i];if(-1!==r["DATA-ID"].search("io.litix.data."))t[r["DATA-ID"].replace("io.litix.data.","")]=r.VALUE}return t},we=function(e){if(!e)return{};var t=be.navigationStart(),i=e.loading,r=i?i.start:e.trequest,a=i?i.first:e.tfirst,n=i?i.end:e.tload;return{bytesLoaded:e.total,requestStart:Math.round(t+r),responseStart:Math.round(t+a),responseEnd:Math.round(t+n)}},De=function(e){if(e&&"function"==typeof e.getAllResponseHeaders)return Ie(e.getAllResponseHeaders())},Ce=function(e,t){if(!e||!e.requestEndDate)return{};var i,r=ve(e.url),a=e.url,n=e.bytesLoaded,s=new Date(e.requestStartDate).getTime(),o=new Date(e.firstByteDate).getTime(),l=new Date(e.requestEndDate).getTime(),d=isNaN(e.duration)?0:e.duration,u="function"==typeof t.getMetricsFor?t.getMetricsFor(e.mediaType).HttpList:t.getDashMetrics().getHttpRequests(e.mediaType);return u.length>0&&(i=Ie(u[u.length-1]._responseHeaders||"")),{requestStart:s,requestResponseStart:o,requestResponseEnd:l,requestBytesLoaded:n,requestResponseHeaders:i,requestMediaDuration:d,requestHostname:r,requestUrl:a,requestId:i?Re(i):void 0}},Me=function(e){var t;return null===(t=e.match(/.*codecs\*?="(.*)"/))||void 0===t?void 0:t[1]},Pe=function(e,t,i){var r=e.log;if(i&&i.on){var a=function(e){try{var t,i;return null===(i=e.getVersion)||void 0===i||null===(t=i.call(e))||void 0===t?void 0:t.split(".").map(function(e){return parseInt(e)})[0]}catch{return!1}}(i),n=function(i,r){return e.emit(t,i,r)},s=function(e){var t=e.type,i=(e.data||{}).url;n("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:ve(i),request_url:i})};i.on("manifestLoaded",s);var o={},l=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,a=e.request,s=(r||{}).mediaInfo||{},l=s.type,d=s.bitrateList,u={};(d=d||[]).forEach(function(e,t){u[t]={},u[t].width=e.width,u[t].height=e.height,u[t].bitrate=e.bandwidth,u[t].attrs={}}),"video"===l?o.video=u:"audio"===l?o.audio=u:o.media=u;var h=Ce(a,i),c=h.requestStart,m=h.requestResponseStart,f=h.requestResponseEnd,p=h.requestResponseHeaders,g=h.requestMediaDuration,v=h.requestHostname,E=h.requestUrl,y=h.requestId;n("requestcompleted",{request_event_type:t,request_start:c,request_response_start:m,request_response_end:f,request_bytes_loaded:-1,request_type:l+"_init",request_response_headers:p,request_hostname:v,request_id:y,request_url:E,request_media_duration:g,request_rendition_lists:o})};a>=4?i.on("initFragmentLoaded",d):i.on("initFragmentLoaded",function(e){var t=e.type,i=e.fragmentModel,r=e.chunk,a=l(i);d({type:t,request:a,chunk:r})});var u=function(e){var t=e.type,r=e.chunk,a=e.request,s=r||{},o=s.mediaInfo,l=s.start,d=(o||{}).type,u=Ce(a,i),h=u.requestStart,c=u.requestResponseStart,m=u.requestResponseEnd,f=u.requestBytesLoaded,p=u.requestResponseHeaders,g=u.requestMediaDuration,v=u.requestHostname,E=u.requestUrl,y=u.requestId,b=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),a=t.getCurrentTrackFor(e).bitrateList;return a?{currentLevel:r,renditionWidth:a[r].width||null,renditionHeight:a[r].height||null,renditionBitrate:a[r].bandwidth}:{}}(d,i),T=b.currentLevel,A=b.renditionWidth,_=b.renditionHeight,S=b.renditionBitrate;n("requestcompleted",{request_event_type:t,request_start:h,request_response_start:c,request_response_end:m,request_bytes_loaded:f,request_type:d,request_response_headers:p,request_hostname:v,request_id:y,request_url:E,request_media_start_time:l,request_media_duration:g,request_current_level:T,request_labeled_bitrate:S,request_video_width:A,request_video_height:_})};a>=4?i.on("mediaFragmentLoaded",u):i.on("mediaFragmentLoaded",function(e){var t=e.type,i=e.fragmentModel,r=e.chunk,a=l(i);u({type:t,request:a,chunk:r})});var h={video:void 0,audio:void 0,totalBitrate:void 0},c=function(e,t,a){var s=e.mediaType;if("audio"===s||"video"===s){var o;if("function"==typeof i.getRepresentationsByType)if(e.newRepresentation)o={bitrate:e.newRepresentation.bandwidth,width:e.newRepresentation.width,height:e.newRepresentation.height,qualityIndex:e.newRepresentation.absoluteIndex};else{var l=i.getRepresentationsByType(s);if(l&&"number"==typeof e.newQuality){var d=l.find(function(t){return t.absoluteIndex===e.newQuality||t.index===e.newQuality});d&&(o={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);o=i.getBitrateInfoListFor(s).find(function(t){return t.qualityIndex===e.newQuality})}if(!o||"number"!=typeof o.bitrate)return void r.warn("missing bitrate info for ".concat(s));h[s]=_e(Ae({},o),{codec:i.getCurrentTrackFor(s).codec});var u=function(){if(h.video&&"number"==typeof h.video.bitrate){if(!h.video.width||!h.video.height)return void r.warn("have bitrate info for video but missing width/height");var e=h.video.bitrate;if(h.audio&&"number"==typeof h.audio.bitrate&&(e+=h.audio.bitrate),e!==h.totalBitrate)return h.totalBitrate=e,{video_source_bitrate:e,video_source_height:h.video.height,video_source_width:h.video.width,video_source_codec:Me(h.video.codec)}}}();u&&n("renditionchange",u)}};i.on("qualityChangeRendered",c);var m=function(e){var t=e.request,i=e.mediaType;n("requestcanceled",{request_event_type:(t=t||{}).type+"_"+t.action,request_url:t.url,request_type:i,request_hostname:ve(t.url)})};i.on("fragmentLoadingAbandoned",m);var f=function(e){var t,i,r=e.error,a=(null==r||null===(t=r.data)||void 0===t?void 0:t.request)||{},s=(null==r||null===(i=r.data)||void 0===i?void 0:i.response)||{};27===(null==r?void 0:r.code)&&n("requestfailed",{request_error:a.type+"_"+a.action,request_url:a.url,request_hostname:ve(a.url),request_type:a.mediaType,request_error_code:s.status,request_error_text:s.statusText});var o="".concat(null!=a&&a.url?"url: ".concat(a.url,"\n"):"")+"".concat(null!=s&&s.status||null!=s&&s.statusText?"response: ".concat(null==s?void 0:s.status,", ").concat(null==s?void 0:s.statusText,"\n"):"");n("error",{player_error_code:null==r?void 0:r.code,player_error_message:null==r?void 0:r.message,player_error_context:o})};i.on("error",f),i._stopMuxMonitor=function(){i.off("manifestLoaded",s),i.off("initFragmentLoaded",d),i.off("mediaFragmentLoaded",u),i.off("qualityChangeRendered",c),i.off("error",f),i.off("fragmentLoadingAbandoned",m),delete i._stopMuxMonitor}}else r.warn("Invalid dash.js player reference. Monitoring blocked.")},xe=0,Oe=function(){function e(){le(this,e),he(this,"_listeners",void 0)}return ue(e,[{key:"on",value:function(e,t,i){return t._eventEmitterGuid=t._eventEmitterGuid||++xe,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||++xe;var a=function(){r.off(e,a),t.apply(i||this,arguments)};a._eventEmitterGuid=t._eventEmitterGuid,this.on(e,a)}},{key:"emit",value:function(e,t){var i=this;if(this._listeners){t=t||{};var r=this._listeners["before"+e]||[],a=this._listeners["before*"]||[],n=this._listeners[e]||[],s=this._listeners["after"+e]||[],o=function(t,r){(t=t.slice()).forEach(function(t){t.call(i,{type:e},r)})};o(r,t),o(a,t),o(n,t),o(s,t)}}}]),e}(),Ne=Oe,Ue=function(){function e(t){var i=this;le(this,e),he(this,"_playbackHeartbeatInterval",void 0),he(this,"_playheadShouldBeProgressing",void 0),he(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&&(q.clearInterval(i._playbackHeartbeatInterval),t.emit("playbackheartbeatend",{viewer_time:r.viewer_time}),i._playbackHeartbeatInterval=null)})}return ue(e,[{key:"_startPlaybackHeartbeatInterval",value:function(){var e=this;null===this._playbackHeartbeatInterval&&(this.pm.emit("playbackheartbeat"),this._playbackHeartbeatInterval=q.setInterval(function(){e.pm.emit("playbackheartbeat")},this.pm.playbackHeartbeatTime))}},{key:"_stopPlaybackHeartbeatInterval",value:function(){this._playheadShouldBeProgressing=!1,null!==this._playbackHeartbeatInterval&&(q.clearInterval(this._playbackHeartbeatInterval),this.pm.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)}}]),e}(),Fe=Ue,Be=function e(t){var i=this;le(this,e),he(this,"viewErrored",void 0),t.on("viewinit",function(){i.viewErrored=!1}),t.on("error",function(e,r){try{var a=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});a&&(t.data.player_error_code=a.player_error_code||r.player_error_code,t.data.player_error_message=a.player_error_message||r.player_error_message,t.data.player_error_context=a.player_error_context||r.player_error_context,t.data.player_error_severity=a.player_error_severity||r.player_error_severity,t.data.player_error_business_exception=a.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,a,n;null===(e=t.data)||void 0===e||delete e.player_error_code,null===(i=t.data)||void 0===i||delete i.player_error_message,null===(r=t.data)||void 0===r||delete r.player_error_context,null===(a=t.data)||void 0===a||delete a.player_error_severity,null===(n=t.data)||void 0===n||delete n.player_error_business_exception})},$e=function(){function e(t){le(this,e),he(this,"_watchTimeTrackerLastCheckedTime",void 0),he(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 ue(e,[{key:"_updateWatchTime",value:function(e,t){var i=t.viewer_time;null===this._watchTimeTrackerLastCheckedTime&&(this._watchTimeTrackerLastCheckedTime=i),Te(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}(),He=$e,Ge=function(){function e(t){var i=this;le(this,e),he(this,"_playbackTimeTrackerLastPlayheadPosition",void 0),he(this,"_lastTime",void 0),he(this,"_isAdPlaying",void 0),he(this,"_callbackUpdatePlaybackTime",void 0),he(this,"pm",void 0),this.pm=t,this._playbackTimeTrackerLastPlayheadPosition=-1,this._lastTime=j.now(),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 a=function(){i.pm.data.player_is_paused||r()};t.on("seeked",a),t.on("rebufferend",a);var n=this._stopPlaybackTimeTracking.bind(this);t.on("playbackheartbeatend",n),t.on("seeking",n),t.on("rebufferstart",n),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=j.now(),i._isAdPlaying=!1,i._callbackUpdatePlaybackTime=null})}return ue(e,[{key:"_startPlaybackTimeTracking",value:function(){null===this._callbackUpdatePlaybackTime&&(this._callbackUpdatePlaybackTime=this._updatePlaybackTime.bind(this),this._playbackTimeTrackerLastPlayheadPosition=this.pm.data.player_playhead_time,this._lastTime=j.now(),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=j.now(),i=t-this._lastTime,r=-1;this._playbackTimeTrackerLastPlayheadPosition>=0&&e>this._playbackTimeTrackerLastPlayheadPosition?r=e-this._playbackTimeTrackerLastPlayheadPosition:this._isAdPlaying&&(r=i),r>0&&r<=1e3&&Te(this.pm.data,"view_content_playback_time",r),null!==this._callbackUpdatePlaybackTime&&i>0&&i<=1e3&&(this._isAdPlaying&&Te(this.pm.data,"ad_playing_time_ms_cumulative",i),Te(this.pm.data,"view_playing_time_ms_cumulative",i)),this._playbackTimeTrackerLastPlayheadPosition=e,this._lastTime=t}}]),e}(),Ke=Ge,We=function(){function e(t){le(this,e),he(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 ue(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 a=this.pm.getPlayheadTime();void 0!==a&&(this.pm.data.player_playhead_time=a,r(),this._updateMaxPlayheadPosition())}}}]),e}(),Ve=We,qe=3e5,Ye=function e(t){if(le(this,e),!t.disableRebufferTracking){var i,r=function(e,t){a(t),i=void 0},a=function(e){if(i){var r=e.viewer_time-i;Te(t.data,"view_rebuffer_duration",r),i=e.viewer_time,t.data.view_rebuffer_duration>qe&&(t.emit("viewend"),t.send("viewend"),t.mux.log.warn("Ending view after rebuffering for longer than ".concat(qe,"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 a(t)}),t.on("rebufferstart",function(e,a){i||(Te(t.data,"view_rebuffer_count",1),i=a.viewer_time,t.one("rebufferend",r))}),t.on("viewinit",function(){i=void 0,t.off("rebufferend",r)})}},je=function(){function e(t){var i=this;le(this,e),he(this,"_lastCheckedTime",void 0),he(this,"_lastPlayheadTime",void 0),he(this,"_lastPlayheadTimeUpdatedTime",void 0),he(this,"_rebuffering",void 0),he(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:j.now()})}))}return ue(e,[{key:"_checkIfRebuffering",value:function(e,t){if(this.pm.seekingTracker.isSeeking||this.pm.adTracker.isAdBreak||!this.pm.playbackHeartbeat._playheadShouldBeProgressing)this._cleanupRebufferTracker(e,t);else if(null!==this._lastCheckedTime)if(this._lastPlayheadTime===this.pm.data.player_playhead_time){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}else this._cleanupRebufferTracker(e,t,!0);else this._prepareRebufferTrackerState(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,a=t.viewer_time-this._lastPlayheadTimeUpdatedTime;"number"==typeof this.pm.minimumRebufferDuration&&r>0&&a-r>this.pm.minimumRebufferDuration&&(this._lastCheckedTime=null,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.pm.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+a-r}))}i?this._prepareRebufferTrackerState(t.viewer_time):this._clearRebufferTrackerState()}}]),e}(),ze=je,Qe=function(){function e(t){var i=this;le(this,e),he(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 a=function(e,a){var n=a.viewer_time;("playing"===e.type&&void 0===t.data.view_time_to_first_frame||"adplaying"===e.type&&(void 0===t.data.view_time_to_first_frame||i._inPrerollPosition()))&&i.calculateTimeToFirstFrame(n||j.now(),r)};t.one("playing",a),t.one("adplaying",a),t.one("viewend",function(){t.off("playing",a),t.off("adplaying",a)})}})}return ue(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}(),Xe=Qe,Ze=function e(t){var i=this;le(this,e),he(this,"_lastPlayerHeight",void 0),he(this,"_lastPlayerWidth",void 0),he(this,"_lastPlayheadPosition",void 0),he(this,"_lastSourceHeight",void 0),he(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)return void(i._lastPlayheadPosition=-1);var r=Math.min(i._lastPlayerWidth/i._lastSourceWidth,i._lastPlayerHeight/i._lastSourceHeight),a=Math.max(0,r-1),n=Math.max(0,1-r);t.data.view_max_upscale_percentage=Math.max(t.data.view_max_upscale_percentage||0,a),t.data.view_max_downscale_percentage=Math.max(t.data.view_max_downscale_percentage||0,n),Te(t.data,"view_total_content_playback_time",e),Te(t.data,"view_total_upscaling",a*e),Te(t.data,"view_total_downscaling",n*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})})},Je=function e(t){var i=this;le(this,e),he(this,"isSeeking",void 0),this.isSeeking=!1;var r=-1,a=function(){var e=j.now(),a=(t.data.viewer_time||e)-(r||e);Te(t.data,"view_seek_duration",a),t.data.view_max_seek_time=Math.max(t.data.view_max_seek_time||0,a),i.isSeeking=!1,r=-1};t.on("seeking",function(e,n){Object.assign(t.data,n),i.isSeeking&&n.viewer_time-r<=2e3?r=n.viewer_time:(i.isSeeking&&a(),i.isSeeking=!0,r=n.viewer_time,Te(t.data,"view_seek_count",1),t.send("seeking"))}),t.on("seeked",function(){a()}),t.on("viewend",function(){i.isSeeking&&(a(),t.send("seeked")),i.isSeeking=!1,r=-1})},et=function(e,t){e.push(t),e.sort(function(e,t){return e.viewer_time-t.viewer_time})},tt=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror","adclicked","adskipped"],it=function(){function e(t){var i=this;le(this,e),he(this,"_adHasPlayed",void 0),he(this,"_adRequests",void 0),he(this,"_adResponses",void 0),he(this,"_currentAdRequestNumber",void 0),he(this,"_currentAdResponseNumber",void 0),he(this,"_prerollPlayTime",void 0),he(this,"_wouldBeNewAdPlay",void 0),he(this,"isAdBreak",void 0),he(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}),tt.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),et(i._adRequests,r),Te(t.data,"view_ad_request_count"),i.inPrerollPosition()&&(t.data.view_preroll_requested=!0,i._adHasPlayed||Te(t.data,"view_preroll_request_count"))}),t.on("adresponse",function(e,r){r=Object.assign({ad_request_id:"generatedAdRequestId"+i._currentAdResponseNumber++},r),et(i._adResponses,r);var a=i.findAdRequest(r.ad_request_id);a&&Te(t.data,"view_ad_request_time",Math.max(0,r.viewer_time-a.viewer_time))}),t.on("adplay",function(e,r){i._adHasPlayed=!0,i._wouldBeNewAdPlay&&(i._wouldBeNewAdPlay=!1,Te(t.data,"view_ad_played_count")),i.inPrerollPosition()&&!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||Te(t.data,"view_ad_clicked_count")}),t.on("adskipped",function(e,r){i._wouldBeNewAdPlay||Te(t.data,"view_ad_skipped_count")}),t.on("adended",function(){i._wouldBeNewAdPlay=!0}),t.on("aderror",function(){i._wouldBeNewAdPlay=!0})}return ue(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=V(Ee(t.ad_tag_url),2),r=i[0],a=i[1];this.pm.data.view_preroll_ad_tag_domain=a,this.pm.data.view_preroll_ad_tag_hostname=r}if(!this.pm.data.view_preroll_ad_asset_hostname&&t.ad_asset_url){var n=V(Ee(t.ad_asset_url),2),s=n[0],o=n[1];this.pm.data.view_preroll_ad_asset_domain=o,this.pm.data.view_preroll_ad_asset_hostname=s}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}(),rt=it,at=function e(t){var i=this;le(this,e),he(this,"lastWallClockTime",void 0);var r=function(){i.lastWallClockTime=j.now(),t.on("before*",a)},a=function(e){var r=j.now(),a=i.lastWallClockTime;i.lastWallClockTime=r,r-a>3e4&&(t.emit("devicesleep",{viewer_time:a}),Object.assign(t.data,{viewer_time:a}),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*",a),t.one("playbackheartbeat",r)})},nt=function(){var e=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 t(i){function r(t,a,n){var s;if("undefined"!=typeof document){if(arguments.length>1){if("number"==typeof(n=e({path:"/"},r.defaults,n)).expires){var o=new Date;o.setMilliseconds(o.getMilliseconds()+864e5*n.expires),n.expires=o}try{s=JSON.stringify(a),/^[\{\[]/.test(s)&&(a=s)}catch{}return a=i.write?i.write(a,t):encodeURIComponent(String(a)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),t=(t=(t=encodeURIComponent(String(t))).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent)).replace(/[\(\)]/g,escape),document.cookie=[t,"=",a,n.expires?"; expires="+n.expires.toUTCString():"",n.path?"; path="+n.path:"",n.domain?"; domain="+n.domain:"",n.secure?"; secure":""].join("")}t||(s={});for(var l=document.cookie?document.cookie.split("; "):[],d=/(%[0-9A-Z]{2})+/g,u=0;u<l.length;u++){var h=l[u].split("="),c=h.slice(1).join("=");'"'===c.charAt(0)&&(c=c.slice(1,-1));try{var m=h[0].replace(d,decodeURIComponent);if(c=i.read?i.read(c,m):i(c,m)||c.replace(d,decodeURIComponent),this.json)try{c=JSON.parse(c)}catch{}if(t===m){s=c;break}t||(s[m]=c)}catch{}}return s}}return r.set=r,r.get=function(e){return r.call(r,e)},r.getJSON=function(){return r.apply({json:!0},[].slice.call(arguments))},r.defaults={},r.remove=function(t,i){r(t,"",e(i,{expires:-1}))},r.withConverter=t,r}return t(function(){})}(),st="muxData",ot=function(){var e;try{e=function(e){return e.split("&").reduce(function(e,t){var i=V(t.split("="),2),r=i[0],a=i[1],n=+a,s=a&&n==a?n:a;return e[r]=s,e},{})}(nt.get(st)||"")}catch{e={}}return e},lt=function(e){try{nt.set(st,function(e){return Object.entries(e).map(function(e){var t=V(e,2),i=t[0],r=t[1];return"".concat(i,"=").concat(r)}).join("&")}(e),{expires:365})}catch{}};var dt=ht({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"}),ut=ht({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:"connection",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",lw:"low",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",si:"sid",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 ht(e){var t={};for(var i in e)e.hasOwnProperty(i)&&(t[e[i]]=i);return t}function ct(e){var t={},i={};return Object.keys(e).forEach(function(r){var a=!1;if(e.hasOwnProperty(r)&&void 0!==e[r]){var n=r.split("_"),s=n[0],o=dt[s];o||(ne.info("Data key word `"+n[0]+"` not expected in "+r),o=s+"_"),n.splice(1).forEach(function(e){"url"===e&&(a=!0),ut[e]?o+=ut[e]:Number.isInteger(Number(e))?o+=e:(ne.info("Data key word `"+e+"` not expected in "+r),o+="_"+e+"_")}),a?i[o]=e[r]:t[o]=e[r]}}),Object.assign(t,i)}var mt,ft,pt,gt=(mt=G(),pt=null!=mt?E(A(mt)):{},function(e,t,i,r){if(t&&"object"==typeof t||"function"==typeof t)for(var a,n=T(t),s=0,o=n.length;s<o;s++)a=n[s],!_.call(e,a)&&a!==i&&y(e,a,{get:function(e){return t[e]}.bind(null,a),enumerable:!(r=b(t,a))||r.enumerable});return e}(!ft&&mt&&mt.__esModule?pt:y(pt,"default",{value:mt,enumerable:!0}),mt)),vt="undefined"!=typeof document?document:gt.default,Et={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4,maxPayloadKBSize:500},yt=["hb","requestcompleted","requestfailed","requestcanceled"],bt=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({},Et,t)};bt.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)},bt.prototype.flushEvents=function(){arguments.length>0&&void 0!==arguments[0]&&arguments[0]&&1===this._eventQueue.length?this._eventQueue.pop():(this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending())},bt.prototype.destroy=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.destroyed=!0,e?this._clearBeaconQueue():this.flushEvents(),q.clearTimeout(this._sendTimeout)},bt.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],ct({mux_view_message:"event queue truncated"}));var i=this._createPayload(t);At(this._beaconUrl,i,!0,function(){})},bt.prototype._sendBeaconQueue=function(){var e=this;if(this._postInFlight)this._resendAfterPost=!0;else{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=j.now();At(this._beaconUrl,i,!1,function(i,a){a?(e._eventQueue=t.concat(e._eventQueue),e._failureCount+=1,ne.info("Error sending beacon: "+a)):e._failureCount=0,e._roundTripTime=j.now()-r,e._postInFlight=!1,e._resendAfterPost&&(e._resendAfterPost=!1,e._eventQueue.length>0&&e._sendBeaconQueue())})}},bt.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},bt.prototype._startBeaconSending=function(){var e=this;q.clearTimeout(this._sendTimeout),!this.destroyed&&(this._sendTimeout=q.setTimeout(function(){e._eventQueue.length&&e._sendBeaconQueue(),e._startBeaconSending()},this._getNextBeaconTime()))},bt.prototype._createPayload=function(e){var t=this,i={transmission_timestamp:Math.round(j.now())};this._roundTripTime&&(i.rtt_ms=Math.round(this._roundTripTime));var r,a,n,s=function(){r=JSON.stringify({metadata:i,events:a||e}),n=r.length/1024},o=function(){return n<=t._options.maxPayloadKBSize};return s(),o()||(ne.info("Payload size is too big ("+n+" kb). Removing unnecessary events."),a=e.filter(function(e){return-1===yt.indexOf(e.e)}),s()),o()||(ne.info("Payload size still too big ("+n+" kb). Cropping fields.."),a.forEach(function(e){for(var t in e){var i=e[t];"string"==typeof i&&i.length>51200&&(e[t]=i.substring(0,51200))}}),s()),r};var Tt="function"==typeof vt.exitPictureInPicture?function(e){return e.length<=57344}:function(e){return!1},At=function(e,t,i,r){if(i&&navigator&&navigator.sendBeacon&&navigator.sendBeacon(e,t))r();else if(q.fetch)q.fetch(e,{method:"POST",body:t,headers:{"Content-Type":"text/plain"},keepalive:Tt(t)}).then(function(e){return r(null,e.ok?null:"Error")}).catch(function(e){return r(null,e)});else{if(q.XMLHttpRequest){var a=new q.XMLHttpRequest;return a.onreadystatechange=function(){if(4===a.readyState)return r(null,200!==a.status?"error":void 0)},a.open("POST",e),a.setRequestHeader("Content-Type","text/plain"),void a.send(t)}r()}},_t=bt,St=["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"],kt=["adplay","adplaying","adpause","adfirstquartile","admidpoint","adthirdquartile","adended","adresponse","adrequest"],It=["ad_id","ad_creative_id","ad_universal_id"],Rt=["viewstart","error","ended","viewend"],Lt=function(){function e(t,i){var r,a,n,s,o,l,d,u,h,c,m,f,p,g,v,E=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};le(this,e),he(this,"mux",void 0),he(this,"envKey",void 0),he(this,"options",void 0),he(this,"eventQueue",void 0),he(this,"sampleRate",void 0),he(this,"disableCookies",void 0),he(this,"respectDoNotTrack",void 0),he(this,"previousBeaconData",void 0),he(this,"lastEventTime",void 0),he(this,"rateLimited",void 0),he(this,"pageLevelData",void 0),he(this,"viewerData",void 0),this.mux=t,this.envKey=i,this.options=E,this.previousBeaconData=null,this.lastEventTime=0,this.rateLimited=!1,this.eventQueue=new _t(function(e,t){var i=t.beaconCollectionDomain,r=t.beaconDomain;if(i)return(/localhost(?::\d+)?$/.test(i)?"http://":"https://")+i;var a=r||"litix.io";return(e=e||"inferred").match(/^[a-z0-9]+$/)?"https://"+e+"."+a:"https://img.litix.io/a.gif"}(this.envKey,this.options)),this.sampleRate=null!==(p=this.options.sampleRate)&&void 0!==p?p:1,this.disableCookies=null!==(g=this.options.disableCookies)&&void 0!==g&&g,this.respectDoNotTrack=null!==(v=this.options.respectDoNotTrack)&&void 0!==v&&v,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===(r=this.options.platform)||void 0===r?void 0:r.name,viewer_application_version:null===(a=this.options.platform)||void 0===a?void 0:a.version,viewer_application_engine:null===(n=this.options.platform)||void 0===n?void 0:n.layout,viewer_device_name:null===(s=this.options.platform)||void 0===s?void 0:s.product,viewer_device_category:"",viewer_device_manufacturer:null===(o=this.options.platform)||void 0===o?void 0:o.manufacturer,viewer_os_family:null===(d=this.options.platform)||void 0===d||null===(l=d.os)||void 0===l?void 0:l.family,viewer_os_architecture:null===(h=this.options.platform)||void 0===h||null===(u=h.os)||void 0===u?void 0:u.architecture,viewer_os_version:null===(m=this.options.platform)||void 0===m||null===(c=m.os)||void 0===c?void 0:c.version,page_url:null==q||null===(f=q.location)||void 0===f?void 0:f.href},this.viewerData=this.disableCookies?{}:function(){var e=ot();return e.mux_viewer_id=e.mux_viewer_id||z(),e.msn=e.msn||Math.random(),lt(e),{mux_viewer_id:e.mux_viewer_id,mux_sample_number:e.msn}}()}return ue(e,[{key:"send",value:function(e,t){if(e&&null!=t&&t.view_id){if(this.respectDoNotTrack&&se())return ne.info("Not sending `"+e+"` because Do Not Track is enabled");if(!t||"object"!=typeof t)return ne.error("A data object was expected in send() but was not provided");var i=this.disableCookies?{}:function(){var e=ot(),t=j.now();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=z(),e.sst=t),e.sex=t+15e5,lt(e),{session_id:e.sid,session_start:e.sst,session_expires:e.sex}}(),r=_e(Ae({},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 a,n=(null!==(a=r.mux_sample_number)&&void 0!==a?a:0)>=this.sampleRate,s=ct(this._deduplicateBeaconData(e,r));if(this.lastEventTime=this.mux.utils.now(),n)return ne.info("Not sending event due to sample rate restriction",e,r,s);if(this.envKey||ne.info("Missing environment key (envKey) - beacons will be dropped if the video source is not a valid mux video URL",e,r,s),!this.rateLimited)if(ne.info("Sending event",e,r,s),this.rateLimited=!this.eventQueue.queueEvent(e,s),this.mux.WINDOW_UNLOADING&&"viewend"===e)this.eventQueue.destroy(!0);else{if(this.mux.WINDOW_HIDDEN&&"hb"===e)this.eventQueue.flushEvents(!0);else if(Rt.indexOf(e)>=0){if("error"===e&&"warning"===t.player_error_severity)return;this.eventQueue.flushEvents()}if(this.rateLimited)return r.event="eventrateexceeded",s=ct(r),this.eventQueue.queueEvent(r.event,s),ne.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={},a=t.view_id;if("-1"===a||"viewstart"===e||"viewend"===e||!this.previousBeaconData||this.mux.utils.now()-this.lastEventTime>=6e5)r=Ae({},t),a&&(this.previousBeaconData=r),a&&"viewend"===e&&(this.previousBeaconData=null);else{var n=0===e.indexOf("request");Object.entries(t).forEach(function(t){var a=V(t,2),s=a[0],o=a[1];i.previousBeaconData&&(o!==i.previousBeaconData[s]||St.indexOf(s)>-1||i.objectHasChanged(n,s,o,i.previousBeaconData[s])||i.eventRequiresKey(e,s))&&(r[s]=o,i.previousBeaconData[s]=o)})}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_")||It.includes(t)&&kt.includes(e)||"playbackmodechange"===e&&0===t.indexOf("player_playback_mode"))}}]),e}(),wt=function e(t){le(this,e);var i=0,r=0,a=0,n=0,s=0,o=0,l=0;t.on("requestcompleted",function(e,o){var l,d,u=o.request_start,h=o.request_response_start,c=o.request_response_end,m=o.request_bytes_loaded;if(n++,h?(l=h-(null!=u?u:0),d=(null!=c?c:0)-h):d=(null!=c?c:0)-(null!=u?u:0),d>0&&m&&m>0){var f=m/d*8e3;s++,r+=m,a+=d,t.data.view_min_request_throughput=Math.min(t.data.view_min_request_throughput||1/0,f),t.data.view_average_request_throughput=r/a*8e3,t.data.view_request_count=n,l>0&&(i+=l,t.data.view_max_request_latency=Math.max(t.data.view_max_request_latency||0,l),t.data.view_average_request_latency=i/s)}}),t.on("requestfailed",function(e,i){n++,o++,t.data.view_request_count=n,t.data.view_request_failed_count=o}),t.on("requestcanceled",function(e,i){n++,l++,t.data.view_request_count=n,t.data.view_request_canceled_count=l})},Dt=function e(t){var i=this;le(this,e),he(this,"_lastEventTime",void 0),t.on("before*",function(e,r){var a=r.viewer_time,n=j.now(),s=i._lastEventTime;if(i._lastEventTime=n,s&&n-s>36e5){var o=Object.keys(t.data).reduce(function(e,i){return 0===i.indexOf("video_")?Object.assign(e,he({},i,t.data[i])):e},{});t.mux.log.info("Received event after at least an hour inactivity, creating a new view");var l=t.playbackHeartbeat._playheadShouldBeProgressing;t._resetView(Object.assign({viewer_time:a},o)),t.playbackHeartbeat._playheadShouldBeProgressing=l,t.playbackHeartbeat._playheadShouldBeProgressing&&"play"!==e.type&&"adbreakstart"!==e.type&&(t.emit("play",{viewer_time:a}),"playing"!==e.type&&t.emit("playing",{viewer_time:a}))}})};function Ct(e,t){return(null==e?void 0:e.toLowerCase())===(null==t?void 0:t.toLowerCase())}var Mt=function e(t){le(this,e);var i=function(e){var i=function(e){var t;return null!=e&&e.request_type&&("media"===e.request_type||"video"===e.request_type)&&null!==(t=e.request_response_headers)&&void 0!==t&&t["x-cdn"]?e.request_response_headers["x-cdn"]:null!=e&&e.video_cdn?e.video_cdn:null}(e),r=function(e){return null!=e&&e.request_start?e.request_start:null!=e&&e.viewer_time?e.viewer_time:Date.now()}(e);if(null!=i&&!Ct(i,n)&&s<=r){n=i,s=r;var a={video_cdn:i};t.emit("cdnchange",a)}},r=null,a=null,n=null,s=0;t.on("viewinit",function(){r=null,a=null,n=null,s=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)&&(Ct(i,a)?t.video_previous_cdn=null!=r?r:void 0:(t.video_previous_cdn=null!=a?a:void 0,r=a,a=i))}),t.on("requestcompleted",function(e,t){i(t)})},Pt=function e(t){var i=this;le(this,e),he(this,"_emittingAutomaticEvent",!1),he(this,"_hasInitialized",!1),he(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?function(e){try{return JSON.parse(e),!0}catch{return!1}}(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)})},xt=function(){function e(t){le(this,e),he(this,"pm",void 0),he(this,"_currentRangeStart",void 0),he(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 ue(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)&&void 0!==e&&e.isAdBreak&&null!==this._lastPlayheadTime&&t<this._lastPlayheadTime)){if(null!==this._lastPlayheadTime&&null!==this._currentRangeStart)if(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}(),Ot=xt,Nt=Object.freeze({CELLULAR:"cellular",WIFI:"wifi",WIRED:"wired",OTHER:"other",NO_CONNECTION:"no_connection",UNKNOWN:"unknown"}),Ut=function(){function e(t){var i=this;le(this,e),he(this,"pm",void 0),he(this,"lastType",void 0),he(this,"lastLowDataMode",void 0),this.pm=t,this.pm.one("viewinit",function(){var t,r=i.emit.bind(i);r(),q.addEventListener("online",r),q.addEventListener("offline",r),null===(t=e.connection)||void 0===t||t.addEventListener("change",r),i.pm.on("destroy",function(){var t;null===(t=e.connection)||void 0===t||t.removeEventListener("change",r),q.removeEventListener("online",r),q.removeEventListener("offline",r)})})}return ue(e,[{key:"type",get:function(){var t,i;return!1===(null===(t=q.navigator)||void 0===t?void 0:t.onLine)?Nt.NO_CONNECTION:null!==(i=e.connection)&&void 0!==i&&i.type?function(e){if(!e)return Nt.UNKNOWN;switch(e){case"cellular":case"wimax":return Nt.CELLULAR;case"wifi":return Nt.WIFI;case"ethernet":return Nt.WIRED;case"none":return Nt.NO_CONNECTION;case"bluetooth":case"other":default:return Nt.OTHER;case"unknown":return Nt.UNKNOWN}}(e.connection.type):Nt.UNKNOWN}},{key:"lowDataMode",get:function(){var t;return null===(t=e.connection)||void 0===t?void 0:t.saveData}},{key:"emit",value:function(){var e=this.type,t=this.lowDataMode;e===this.lastType&&t===this.lastLowDataMode||(this.lastType=e,this.lastLowDataMode=t,this.pm.emit("networkchange",Ae({viewer_connection_type:e},void 0!==t&&{viewer_connection_low_data_mode:t})))}}],[{key:"connection",get:function(){return function(e){return"object"==typeof e&&"connection"in e&&"object"==typeof e.connection}(q.navigator)?q.navigator.connection:null}}]),e}(),Ft=Ut,Bt=["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","networkchange","cdnchange","playbackmodechange"],$t=new Set(["requestcompleted","requestfailed","requestcanceled"]),Ht=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&fe(e,t)}(i,e);var t=ge(i);function i(e,r,a){var n;le(this,i),he(oe(n=t.call(this)),"pageLoadEndTime",void 0),he(oe(n),"pageLoadInitTime",void 0),he(oe(n),"_destroyed",void 0),he(oe(n),"_heartBeatTimeout",void 0),he(oe(n),"adTracker",void 0),he(oe(n),"dashjs",void 0),he(oe(n),"data",void 0),he(oe(n),"disablePlayheadRebufferTracking",void 0),he(oe(n),"disableRebufferTracking",void 0),he(oe(n),"disableAdPlaybackRangeFiltering",void 0),he(oe(n),"errorTracker",void 0),he(oe(n),"errorTranslator",void 0),he(oe(n),"emitTranslator",void 0),he(oe(n),"getAdData",void 0),he(oe(n),"getPlayheadTime",void 0),he(oe(n),"getStateData",void 0),he(oe(n),"stateDataTranslator",void 0),he(oe(n),"hlsjs",void 0),he(oe(n),"id",void 0),he(oe(n),"longResumeTracker",void 0),he(oe(n),"minimumRebufferDuration",void 0),he(oe(n),"mux",void 0),he(oe(n),"playbackEventDispatcher",void 0),he(oe(n),"playbackHeartbeat",void 0),he(oe(n),"playbackHeartbeatTime",void 0),he(oe(n),"playheadTime",void 0),he(oe(n),"seekingTracker",void 0),he(oe(n),"sustainedRebufferThreshold",void 0),he(oe(n),"watchTimeTracker",void 0),he(oe(n),"currentFragmentPDT",void 0),he(oe(n),"currentFragmentStart",void 0),n.pageLoadInitTime=be.navigationStart(),n.pageLoadEndTime=be.domContentLoadedEventEnd();var s={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=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return t},stateDataTranslator:function(e){return e}};n.mux=e,n.id=r,null!=a&&a.beaconDomain&&n.mux.log.warn("The `beaconDomain` setting has been deprecated in favor of `beaconCollectionDomain`. Please change your integration to use `beaconCollectionDomain` instead of `beaconDomain`."),(a=Object.assign(s,a)).data=a.data||{},a.data.property_key&&(a.data.env_key=a.data.property_key,delete a.data.property_key),ne.level=a.debug?te:re,n.getPlayheadTime=a.getPlayheadTime,n.getStateData=a.getStateData||function(){return{}},n.getAdData=a.getAdData||function(){},n.minimumRebufferDuration=a.minimumRebufferDuration,n.sustainedRebufferThreshold=a.sustainedRebufferThreshold,n.playbackHeartbeatTime=a.playbackHeartbeatTime,n.disableRebufferTracking=a.disableRebufferTracking,n.disableRebufferTracking&&n.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."),n.disablePlayheadRebufferTracking=a.disablePlayheadRebufferTracking,n.disableAdPlaybackRangeFiltering=a.disableAdPlaybackRangeFiltering,n.errorTranslator=a.errorTranslator,n.emitTranslator=a.emitTranslator,n.stateDataTranslator=a.stateDataTranslator,n.playbackEventDispatcher=new Lt(e,a.data.env_key,a),n.data={player_instance_id:z(),mux_sample_rate:a.sampleRate,beacon_domain:a.beaconCollectionDomain||a.beaconDomain},n.data.view_sequence_number=1,n.data.player_sequence_number=1;var o=function(){void 0===this.data.view_start&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"),this.emit("renditionchange"))}.bind(oe(n));if(n.on("viewinit",function(e,t){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),Object.assign(this.data,t),this._initializeViewData(),this.one("play",o),this.one("adbreakstart",o)}),n.on("videochange",function(e,t){this._resetView(t)}),n.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})),o(),this.emit("play"),this.emit("playing")}),n.on("fragmentchange",function(e,t){this.currentFragmentPDT=t.currentFragmentPDT,this.currentFragmentStart=t.currentFragmentStart}),n.on("destroy",n.destroy),"undefined"!=typeof window&&"function"==typeof window.addEventListener&&"function"==typeof window.removeEventListener){var l=function(){var e=void 0!==n.data.view_start;n.mux.WINDOW_HIDDEN="hidden"===document.visibilityState,e&&n.mux.WINDOW_HIDDEN&&(n.data.player_is_paused||n.emit("hb"))};window.addEventListener("visibilitychange",l,!1);var d=function(e){e.persisted||n.destroy()};window.addEventListener("pagehide",d,!1),n.on("destroy",function(){window.removeEventListener("visibilitychange",l),window.removeEventListener("pagehide",d)})}n.on("playerready",function(e,t){Object.assign(this.data,t)}),Bt.forEach(function(e){n.on(e,function(t,i){0!==e.indexOf("ad")&&this._updateStateData(),Object.assign(this.data,i),this._sanitizeData()}),n.on("after"+e,function(){("error"!==e||this.errorTracker.viewErrored)&&this.send(e)})}),n.on("viewend",function(e,t){Object.assign(n.data,t)});return n.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}),n.longResumeTracker=new Dt(oe(n)),n.errorTracker=new Be(oe(n)),new at(oe(n)),n.seekingTracker=new Je(oe(n)),n.playheadTime=new Ve(oe(n)),n.playbackHeartbeat=new Fe(oe(n)),new Ze(oe(n)),n.watchTimeTracker=new He(oe(n)),new Ke(oe(n)),new Ot(oe(n)),n.adTracker=new rt(oe(n)),new ze(oe(n)),new Ye(oe(n)),new Xe(oe(n)),new wt(oe(n)),new Mt(oe(n)),new Pt(oe(n)),new Ft(oe(n)),a.hlsjs&&n.addHLSJS(a),a.dashjs&&n.addDashJS(a),n.emit("viewinit",a.data),n}return ue(i,[{key:"emit",value:function(e,t){var r,a=Object.assign({viewer_time:this.mux.utils.now()},t),n=[e,a];if(this.emitTranslator)try{n=this.emitTranslator(e,a)}catch(e){this.mux.log.warn("Exception in emit translator callback.",e)}null!=n&&n.length&&(r=me(ce(i.prototype),"emit",this)).call.apply(r,[this].concat(J(n)))}},{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=V(Ee(t.video_source_url),2),r=i[0],a=i[1];t.video_source_domain=a,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++,$t.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)}if(null!==(e=this.data)&&void 0!==e&&e.video_cdn&&null!=t&&t.video_cdn){t.video_cdn;t=pe(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=z(),i=function(){t===e.data.view_id&&Te(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,function(e,t,i){var r=arguments.length>4?arguments[4]:void 0,a=e.log,n=e.utils.secondsToMs,s=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(be.exists()){var o=function(i,r){return e.emit(t,i,r)},l=function(e,t){var i=t.levels,r=t.audioTracks,a=t.url,n=t.stats,s=t.networkDetails,l=t.sessionData,d={},u={};i.forEach(function(e,t){d[t]={width:e.width,height:e.height,bitrate:e.bitrate,attrs:e.attrs}}),r.forEach(function(e,t){u[t]={name:e.name,language:e.lang,bitrate:e.bitrate}});var h=we(n),c=h.bytesLoaded,m=h.requestStart,f=h.responseStart,p=h.responseEnd;o("requestcompleted",_e(Ae({},Le(l)),{request_event_type:e,request_bytes_loaded:c,request_start:m,request_response_start:f,request_response_end:p,request_type:"manifest",request_hostname:ve(a),request_response_headers:De(s),request_rendition_lists:{media:d,audio:u,video:{}}}))};i.on(r.Events.MANIFEST_LOADED,l);var d=function(e,t){var i=t.details,r=t.level,a=t.networkDetails,l=t.stats,d=we(l),u=d.bytesLoaded,h=d.requestStart,c=d.responseStart,m=d.responseEnd,f=i.fragments[i.fragments.length-1],p=s(f)+n(f.duration);o("requestcompleted",{request_event_type:e,request_bytes_loaded:u,request_start:h,request_response_start:c,request_response_end:m,request_current_level:r,request_type:"manifest",request_hostname:ve(i.url),request_response_headers:De(a),video_holdback:i.holdBack&&n(i.holdBack),video_part_holdback:i.partHoldBack&&n(i.partHoldBack),video_part_target_duration:i.partTarget&&n(i.partTarget),video_target_duration:i.targetduration&&n(i.targetduration),video_source_is_live:i.live,player_manifest_newest_program_time:isNaN(p)?void 0:p})};i.on(r.Events.LEVEL_LOADED,d);var u=function(e,t){var i=t.details,r=t.networkDetails,a=t.stats,n=we(a),s=n.bytesLoaded,l=n.requestStart,d=n.responseStart,u=n.responseEnd;o("requestcompleted",{request_event_type:e,request_bytes_loaded:s,request_start:l,request_response_start:d,request_response_end:u,request_type:"manifest",request_hostname:ve(i.url),request_response_headers:De(r)})};i.on(r.Events.AUDIO_TRACK_LOADED,u);var h=function(e,t){var r=t.stats,a=t.networkDetails,n=t.frag;r=r||n.stats;var s=we(r),l=s.bytesLoaded,d=s.requestStart,u=s.responseStart,h=s.responseEnd,c=a?De(a):void 0,m={request_event_type:e,request_bytes_loaded:l,request_start:d,request_response_start:u,request_response_end:h,request_hostname:a?ve(a.responseURL):void 0,request_id:c?Re(c):void 0,request_response_headers:c,request_media_duration:n.duration,request_url:null==a?void 0:a.responseURL};"main"===n.type?(m.request_type="media",m.request_current_level=n.level,m.request_video_width=(i.levels[n.level]||{}).width,m.request_video_height=(i.levels[n.level]||{}).height,m.request_labeled_bitrate=(i.levels[n.level]||{}).bitrate):m.request_type=n.type,o("requestcompleted",m)};i.on(r.Events.FRAG_LOADED,h);var c=function(e,t){var i=t.frag,r=i.start,a={currentFragmentPDT:s(i),currentFragmentStart:n(r)};o("fragmentchange",a)};i.on(r.Events.FRAG_CHANGED,c);var m=function(e,t){var i=t.type,a=t.details,n=t.response,s=t.fatal,l=t.frag,d=t.networkDetails,u=(null==l?void 0:l.url)||t.url||"",h=d?De(d):void 0;if((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)&&o("requestfailed",{request_error:a,request_url:u,request_hostname:ve(u),request_id:h?Re(h):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}),s){var c,m="".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===(c=t.err)||void 0===c?void 0:c.message,"\n"):"");o("error",{player_error_code:i,player_error_message:a,player_error_context:m})}};i.on(r.Events.ERROR,m);var f=function(e,t){var i=t.frag,r=i&&i._url||"";o("requestcanceled",{request_event_type:e,request_url:r,request_type:"media",request_hostname:ve(r)})};i.on(r.Events.FRAG_LOAD_EMERGENCY_ABORTED,f);var p=function(e,t){var r=t.level,n=i.levels[r];if(n&&n.attrs&&n.attrs.BANDWIDTH){var s,l=n.attrs.BANDWIDTH,d=parseFloat(n.attrs["FRAME-RATE"]);isNaN(d)||(s=d),l?o("renditionchange",{video_source_fps:s,video_source_bitrate:l,video_source_width:n.width,video_source_height:n.height,video_source_rendition_name:n.name,video_source_codec:null==n?void 0:n.videoCodec}):a.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};i.on(r.Events.LEVEL_SWITCHED,p),i._stopMuxMonitor=function(){i.off(r.Events.MANIFEST_LOADED,l),i.off(r.Events.LEVEL_LOADED,d),i.off(r.Events.AUDIO_TRACK_LOADED,u),i.off(r.Events.FRAG_LOADED,h),i.off(r.Events.FRAG_CHANGED,c),i.off(r.Events.ERROR,m),i.off(r.Events.FRAG_LOAD_EMERGENCY_ABORTED,f),i.off(r.Events.LEVEL_SWITCHED,p),i.off(r.Events.DESTROYING,i._stopMuxMonitor),delete i._stopMuxMonitor},i.on(r.Events.DESTROYING,i._stopMuxMonitor)}else a.warn("performance timing not supported. Not tracking HLS.js.")}(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&&(function(e){e&&"function"==typeof e._stopMuxMonitor&&e._stopMuxMonitor()}(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,Pe(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&&(function(e){e&&"function"==typeof e._stopMuxMonitor&&e._stopMuxMonitor()}(this.dashjs),this.dashjs=void 0)}}]),i}(Ne),Gt=Ht;function Kt(){return vt&&!!(vt.fullscreenElement||vt.webkitFullscreenElement||vt.mozFullScreenElement||vt.msFullscreenElement)}var Wt,Vt=["loadstart","pause","play","playing","seeking","seeked","timeupdate","ratechange","stalled","waiting","error","ended"],qt={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"};q&&q.WeakMap&&(Wt=new WeakMap);var Yt="#EXT-X-TARGETDURATION",jt="#EXT-X-PART-INF",zt="#EXT-X-SERVER-CONTROL",Qt="#EXTINF",Xt="#EXT-X-PROGRAM-DATE-TIME",Zt="#EXT-X-VERSION",Jt="#EXT-X-SESSION-DATA",ei=function(e){return this.buffer="",this.manifest={segments:[],serverControl:{},sessionData:{}},this.currentUri={},this.process(e),this.manifest};ei.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)},ei.prototype.processLine=function(e){var t=e.indexOf(":"),i=oi(e,t),r=i[0],a=2===i.length?ri(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 Yt:if(!isFinite(a)||a<0)return;this.manifest.targetDuration=a,this.setHoldBack();break;case jt:ti(this.manifest,i),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),this.setHoldBack();break;case zt:ti(this.manifest,i),this.setHoldBack();break;case Qt:0===a?this.currentUri.duration=.01:a>0&&(this.currentUri.duration=a);break;case Xt:var n=a,s=new Date(n);this.manifest.dateTimeString||(this.manifest.dateTimeString=n,this.manifest.dateTimeObject=s),this.currentUri.dateTimeString=n,this.currentUri.dateTimeObject=s;break;case Zt:ti(this.manifest,i);break;case Jt:var o=li(i[1]),l=Le(o);Object.assign(this.manifest.sessionData,l)}},ei.prototype.setHoldBack=function(){var e=this.manifest,t=e.serverControl,i=e.targetDuration,r=e.partTargetDuration;if(t){var a="holdBack",n="partHoldBack",s=i&&3*i,o=r&&2*r;i&&!t.hasOwnProperty(a)&&(t[a]=s),s&&t[a]<s&&(t[a]=s),r&&!t.hasOwnProperty(n)&&(t[n]=3*r),r&&t[n]<o&&(t[n]=o)}};var ti=function(e,t){var i,r=ii(t[0].replace("#EXT-X-",""));si(t[1])?(i={},i=Object.assign(ni(t[1]),i)):i=ri(t[1]),e[r]=i},ii=function(e){return e.toLowerCase().replace(/-(\w)/g,function(e){return e[1].toUpperCase()})},ri=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},ai=function(e){var t={},i=e.split("=");i.length>1&&(t[ii(i[0])]=ri(i[1]));return t},ni=function(e){for(var t=e.split(","),i={},r=0;t.length>r;r++){var a=t[r],n=ai(a);i=Object.assign(n,i)}return i},si=function(e){return e.indexOf("=")>-1},oi=function(e,t){return-1===t?[e]:[e.substring(0,t),e.substring(t+1)]},li=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("="),a=0;a<r.length;a++)"DATA-ID"===r[a]&&(t["DATA-ID"]=r[1-a]),"VALUE"===r[a]&&(t.VALUE=r[1-a])}),{data:t}}},di=ei,ui={safeCall:function(e,t,i,r){var a=r;if(e&&"function"==typeof e[t])try{a=e[t].apply(e,i)}catch(e){ne.info("safeCall error",e)}return a},safeIncrement:Te,getComputedStyle:function(e,t){return e&&t&&q&&"function"==typeof q.getComputedStyle?(Wt&&Wt.has(e)&&(i=Wt.get(e)),i||(i=q.getComputedStyle(e,null),Wt&&Wt.set(e,i)),i.getPropertyValue(t)):"";var i},secondsToMs:function(e){return Math.floor(1e3*e)},assign:Object.assign,headersStringToObject:Ie,cdnHeadersToRequestId:Re,extractHostnameAndDomain:Ee,extractHostname:ve,manifestParser:di,generateShortID:Q,generateUUID:z,now:j.now,findMediaElement:Z},hi=ui,ci={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",NETWORK_CHANGE:"networkchange",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"},mi={},fi=function(e){var t=arguments;"string"==typeof e?fi.hasOwnProperty(e)?q.setTimeout(function(){t=Array.prototype.splice.call(t,1),fi[e].apply(null,t)},0):ne.warn("`"+e+"` is an unknown task"):"function"==typeof e?q.setTimeout(function(){e(fi)},0):ne.warn("`"+e+"` is invalid.")},pi={loaded:j.now(),NAME:"mux-embed",VERSION:"5.18.2",API_VERSION:"2.1",PLAYER_TRACKED:!1,monitor:function(e,t){return function(e,t,i){var r=V(Z(t),3),a=r[0],n=r[1],s=r[2],o=e.log,l=e.utils.getComputedStyle,d=e.utils.secondsToMs;if(!a)return o.error("No element was found with the `"+n+"` query selector.");if("video"!==s&&"audio"!==s)return o.error("The element of `"+n+"` was not a media element.");a.mux&&(a.mux.destroy(),delete a.mux,o.warn("Already monitoring this video element, replacing existing event listeners"));var u={getPlayheadTime:function(){return d(a.currentTime)},getStateData:function(){var e,t,i=(null===(e=this.getPlayheadTime)||void 0===e?void 0:e.call(this))||d(a.currentTime),r=this.hlsjs&&this.hlsjs.url,n=this.dashjs&&"function"==typeof this.dashjs.getSource&&this.dashjs.getSource(),s={player_is_paused:a.paused,player_width:parseInt(l(a,"width")),player_height:parseInt(l(a,"height")),player_autoplay_on:a.autoplay,player_preload_on:a.preload,player_language_code:a.lang,player_is_fullscreen:Kt(),video_poster_url:a.poster,video_source_url:r||n||a.currentSrc,video_source_duration:d(a.duration),video_source_height:a.videoHeight,video_source_width:a.videoWidth,view_dropped_frame_count:null==a||null===(t=a.getVideoPlaybackQuality)||void 0===t?void 0:t.call(a).droppedVideoFrames};if(a.getStartDate&&i>0){var o=a.getStartDate();if(o&&"function"==typeof o.getTime&&o.getTime()){var u=o.getTime();if(s.player_program_time=u+i,a.seekable.length>0){var h=u+a.seekable.end(a.seekable.length-1);s.player_live_edge_program_time=h}}}return s}};(i=Object.assign({automaticErrorTracking:!0},i,u)).data=Object.assign({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:e.VERSION},i.data),a.mux=a.mux||{},a.mux.deleted=!1,a.mux.emit=function(t,i){e.emit(n,t,i)},a.mux.updateData=function(e){a.mux.emit("hb",e)};var h=function(){o.error("The monitor for this video element has already been destroyed.")};a.mux.destroy=function(){Object.keys(a.mux.listeners).forEach(function(e){a.removeEventListener(e,a.mux.listeners[e],!1)}),delete a.mux.listeners,a.mux.fullscreenChangeListener&&(document.removeEventListener("fullscreenchange",a.mux.fullscreenChangeListener,!1),delete a.mux.fullscreenChangeListener),a.mux.destroy=h,a.mux.swapElement=h,a.mux.emit=h,a.mux.addHLSJS=h,a.mux.addDashJS=h,a.mux.removeHLSJS=h,a.mux.removeDashJS=h,a.mux.updateData=h,a.mux.setEmitTranslator=h,a.mux.setStateDataTranslator=h,a.mux.setGetPlayheadTime=h,a.mux.deleted=!0,e.emit(n,"destroy")},a.mux.swapElement=function(t){var i=V(Z(t),3),r=i[0],n=i[1],s=i[2];return r?"video"!==s&&"audio"!==s?e.log.error("The element of `"+n+"` was not a media element."):(r.muxId=a.muxId,delete a.muxId,r.mux=r.mux||{},r.mux.listeners=Object.assign({},a.mux.listeners),delete a.mux.listeners,Object.keys(r.mux.listeners).forEach(function(e){a.removeEventListener(e,r.mux.listeners[e],!1),r.addEventListener(e,r.mux.listeners[e],!1)}),r.mux.fullscreenChangeListener=a.mux.fullscreenChangeListener,delete a.mux.fullscreenChangeListener,r.mux.swapElement=a.mux.swapElement,r.mux.destroy=a.mux.destroy,delete a.mux,void(a=r)):e.log.error("No element was found with the `"+n+"` query selector.")},a.mux.addHLSJS=function(t){e.addHLSJS(n,t)},a.mux.addDashJS=function(t){e.addDashJS(n,t)},a.mux.removeHLSJS=function(){e.removeHLSJS(n)},a.mux.removeDashJS=function(){e.removeDashJS(n)},a.mux.setEmitTranslator=function(t){e.setEmitTranslator(n,t)},a.mux.setStateDataTranslator=function(t){e.setStateDataTranslator(n,t)},a.mux.setGetPlayheadTime=function(t){t||(t=i.getPlayheadTime),e.setGetPlayheadTime(n,t)},e.init(n,i),e.emit(n,"playerready"),a.paused||(e.emit(n,"play"),a.readyState>2&&e.emit(n,"playing")),a.mux.listeners={},Vt.forEach(function(t){"error"===t&&!i.automaticErrorTracking||(a.mux.listeners[t]=function(){var i={};if("error"===t){if(!a.error||1===a.error.code)return;i.player_error_code=a.error.code,i.player_error_message=qt[a.error.code]||a.error.message}e.emit(n,t,i)},a.addEventListener(t,a.mux.listeners[t],!1))}),a.mux.listeners.enterpictureinpicture=function(){e.emit(n,"playbackmodechange",{player_playback_mode:"pip",player_playback_mode_data:"{}"})},a.mux.listeners.leavepictureinpicture=function(){var t=Kt()?"fullscreen":"standard";e.emit(n,"playbackmodechange",{player_playback_mode:t,player_playback_mode_data:"{}"})},a.addEventListener("enterpictureinpicture",a.mux.listeners.enterpictureinpicture,!1),a.addEventListener("leavepictureinpicture",a.mux.listeners.leavepictureinpicture,!1),a.mux.fullscreenChangeListener=function(){var t=Kt(),i=document.fullscreenElement;if(t&&(i===a||null!=i&&i.contains(a)))e.emit(n,"playbackmodechange",{player_playback_mode:"fullscreen",player_playback_mode_data:"{}"});else if(!t){var r=document.pictureInPictureElement===a?"pip":"standard";e.emit(n,"playbackmodechange",{player_playback_mode:r,player_playback_mode_data:"{}"})}},document.addEventListener("fullscreenchange",a.mux.fullscreenChangeListener,!1)}(fi,e,t)},destroyMonitor:function(e){var t=V(Z(e),1)[0];t&&t.mux&&"function"==typeof t.mux.destroy?t.mux.destroy():ne.error("A video element monitor for `"+e+"` has not been initialized via `mux.monitor`.")},addHLSJS:function(e,t){var i=X(e);mi[i]?mi[i].addHLSJS(t):ne.error("A monitor for `"+i+"` has not been initialized.")},addDashJS:function(e,t){var i=X(e);mi[i]?mi[i].addDashJS(t):ne.error("A monitor for `"+i+"` has not been initialized.")},removeHLSJS:function(e){var t=X(e);mi[t]?mi[t].removeHLSJS():ne.error("A monitor for `"+t+"` has not been initialized.")},removeDashJS:function(e){var t=X(e);mi[t]?mi[t].removeDashJS():ne.error("A monitor for `"+t+"` has not been initialized.")},init:function(e,t){se()&&t&&t.respectDoNotTrack&&ne.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var i=X(e);mi[i]=new Gt(fi,i,t)},emit:function(e,t,i){var r=X(e);mi[r]?(mi[r].emit(t,i),"destroy"===t&&delete mi[r]):ne.error("A monitor for `"+r+"` has not been initialized.")},updateData:function(e,t){var i=X(e);mi[i]?mi[i].emit("hb",t):ne.error("A monitor for `"+i+"` has not been initialized.")},setEmitTranslator:function(e,t){var i=X(e);mi[i]?mi[i].emitTranslator=t:ne.error("A monitor for `"+i+"` has not been initialized.")},setStateDataTranslator:function(e,t){var i=X(e);mi[i]?mi[i].stateDataTranslator=t:ne.error("A monitor for `"+i+"` has not been initialized.")},setGetPlayheadTime:function(e,t){var i=X(e);mi[i]?mi[i].getPlayheadTime=t:ne.error("A monitor for `"+i+"` has not been initialized.")},checkDoNotTrack:se,log:ne,utils:hi,events:ci,WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign(fi,pi),void 0!==q&&"function"==typeof q.addEventListener&&q.addEventListener("pagehide",function(e){e.persisted||(fi.WINDOW_UNLOADING=!0)},!1);var gi=fi,vi=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},Ei=Number.isSafeInteger||function(e){return"number"==typeof e&&Math.abs(e)<=yi},yi=Number.MAX_SAFE_INTEGER||9007199254740991,bi=function(e){return e.NETWORK_ERROR="networkError",e.MEDIA_ERROR="mediaError",e.KEY_SYSTEM_ERROR="keySystemError",e.MUX_ERROR="muxError",e.OTHER_ERROR="otherError",e}({}),Ti=function(e){return e.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",e.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",e.KEY_SYSTEM_NO_SESSION="keySystemNoSession",e.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",e.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",e.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",e.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",e.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",e.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR="keySystemDestroyMediaKeysError",e.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR="keySystemDestroyCloseSessionError",e.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR="keySystemDestroyRemoveSessionError",e.MANIFEST_LOAD_ERROR="manifestLoadError",e.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",e.MANIFEST_PARSING_ERROR="manifestParsingError",e.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",e.LEVEL_EMPTY_ERROR="levelEmptyError",e.PLAYLIST_UNCHANGED_ERROR="playlistUnchangedError",e.LEVEL_LOAD_ERROR="levelLoadError",e.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",e.LEVEL_PARSING_ERROR="levelParsingError",e.LEVEL_SWITCH_ERROR="levelSwitchError",e.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",e.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",e.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",e.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",e.FRAG_LOAD_ERROR="fragLoadError",e.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",e.FRAG_DECRYPT_ERROR="fragDecryptError",e.FRAG_PARSING_ERROR="fragParsingError",e.FRAG_GAP="fragGap",e.REMUX_ALLOC_ERROR="remuxAllocError",e.KEY_LOAD_ERROR="keyLoadError",e.KEY_LOAD_TIMEOUT="keyLoadTimeOut",e.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",e.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",e.BUFFER_APPEND_ERROR="bufferAppendError",e.BUFFER_APPENDING_ERROR="bufferAppendingError",e.BUFFER_APPEND_NO_PROGRESS="bufferAppendNoProgress",e.BUFFER_STALLED_ERROR="bufferStalledError",e.BUFFER_FULL_ERROR="bufferFullError",e.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",e.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",e.ASSET_LIST_LOAD_ERROR="assetListLoadError",e.ASSET_LIST_LOAD_TIMEOUT="assetListLoadTimeout",e.ASSET_LIST_PARSING_ERROR="assetListParsingError",e.INTERSTITIAL_ASSET_ITEM_ERROR="interstitialAssetItemError",e.INTERNAL_EXCEPTION="internalException",e.INTERNAL_ABORTED="aborted",e.ATTACH_MEDIA_ERROR="attachMediaError",e.MEDIA_SOURCE_REQUIRES_RESET="mediaSourceRequiresReset",e.UNKNOWN="unknown",e}({}),Ai=function(e){return e.MEDIA_ATTACHING="hlsMediaAttaching",e.MEDIA_ATTACHED="hlsMediaAttached",e.MEDIA_DETACHING="hlsMediaDetaching",e.MEDIA_DETACHED="hlsMediaDetached",e.MEDIA_ENDED="hlsMediaEnded",e.STALL_RESOLVED="hlsStallResolved",e.BUFFER_RESET="hlsBufferReset",e.BUFFER_CODECS="hlsBufferCodecs",e.BUFFER_CREATED="hlsBufferCreated",e.BUFFER_APPENDING="hlsBufferAppending",e.BUFFER_APPENDED="hlsBufferAppended",e.BUFFER_EOS="hlsBufferEos",e.BUFFERED_TO_END="hlsBufferedToEnd",e.BUFFER_FLUSHING="hlsBufferFlushing",e.BUFFER_FLUSHED="hlsBufferFlushed",e.MANIFEST_LOADING="hlsManifestLoading",e.MANIFEST_LOADED="hlsManifestLoaded",e.MANIFEST_PARSED="hlsManifestParsed",e.LEVEL_SWITCHING="hlsLevelSwitching",e.LEVEL_SWITCHED="hlsLevelSwitched",e.LEVEL_LOADING="hlsLevelLoading",e.LEVEL_LOADED="hlsLevelLoaded",e.LEVEL_UPDATED="hlsLevelUpdated",e.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",e.LEVELS_UPDATED="hlsLevelsUpdated",e.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",e.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",e.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",e.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",e.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",e.AUDIO_TRACK_UPDATED="hlsAudioTrackUpdated",e.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",e.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",e.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",e.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",e.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",e.SUBTITLE_TRACK_UPDATED="hlsSubtitleTrackUpdated",e.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",e.CUES_PARSED="hlsCuesParsed",e.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",e.INIT_PTS_FOUND="hlsInitPtsFound",e.FRAG_LOADING="hlsFragLoading",e.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",e.FRAG_LOADED="hlsFragLoaded",e.FRAG_DECRYPTED="hlsFragDecrypted",e.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",e.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",e.FRAG_PARSING_METADATA="hlsFragParsingMetadata",e.FRAG_PARSED="hlsFragParsed",e.FRAG_BUFFERED="hlsFragBuffered",e.FRAG_CHANGED="hlsFragChanged",e.FPS_DROP="hlsFpsDrop",e.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",e.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",e.ERROR="hlsError",e.DESTROYING="hlsDestroying",e.KEY_LOADING="hlsKeyLoading",e.KEY_LOADED="hlsKeyLoaded",e.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",e.BACK_BUFFER_REACHED="hlsBackBufferReached",e.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",e.ASSET_LIST_LOADING="hlsAssetListLoading",e.ASSET_LIST_LOADED="hlsAssetListLoaded",e.INTERSTITIALS_UPDATED="hlsInterstitialsUpdated",e.INTERSTITIALS_BUFFERED_TO_BOUNDARY="hlsInterstitialsBufferedToBoundary",e.INTERSTITIAL_ASSET_PLAYER_CREATED="hlsInterstitialAssetPlayerCreated",e.INTERSTITIAL_STARTED="hlsInterstitialStarted",e.INTERSTITIAL_ASSET_STARTED="hlsInterstitialAssetStarted",e.INTERSTITIAL_ASSET_ENDED="hlsInterstitialAssetEnded",e.INTERSTITIAL_ASSET_ERROR="hlsInterstitialAssetError",e.INTERSTITIAL_ENDED="hlsInterstitialEnded",e.INTERSTITIALS_PRIMARY_RESUMED="hlsInterstitialsPrimaryResumed",e.PLAYOUT_LIMIT_REACHED="hlsPlayoutLimitReached",e.EVENT_CUE_ENTER="hlsEventCueEnter",e}({});var _i,Si={exports:{}};var ki=(_i||(_i=1,function(e){var t,i,r,a,n;t=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,i=/^(?=([^\/?#]*))\1([^]*)$/,r=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,n={buildAbsoluteURL:function(e,t,r){if(r=r||{},e=e.trim(),!(t=t.trim())){if(!r.alwaysNormalize)return e;var a=n.parseURL(e);if(!a)throw new Error("Error trying to parse base URL.");return a.path=n.normalizePath(a.path),n.buildURLFromParts(a)}var s=n.parseURL(t);if(!s)throw new Error("Error trying to parse relative URL.");if(s.scheme)return r.alwaysNormalize?(s.path=n.normalizePath(s.path),n.buildURLFromParts(s)):t;var o=n.parseURL(e);if(!o)throw new Error("Error trying to parse base URL.");if(!o.netLoc&&o.path&&"/"!==o.path[0]){var l=i.exec(o.path);o.netLoc=l[1],o.path=l[2]}o.netLoc&&!o.path&&(o.path="/");var d={scheme:o.scheme,netLoc:s.netLoc,path:null,params:s.params,query:s.query,fragment:s.fragment};if(!s.netLoc&&(d.netLoc=o.netLoc,"/"!==s.path[0]))if(s.path){var u=o.path,h=u.substring(0,u.lastIndexOf("/")+1)+s.path;d.path=n.normalizePath(h)}else d.path=o.path,s.params||(d.params=o.params,s.query||(d.query=o.query));return null===d.path&&(d.path=r.alwaysNormalize?n.normalizePath(s.path):s.path),n.buildURLFromParts(d)},parseURL:function(e){var i=t.exec(e);return i?{scheme:i[1]||"",netLoc:i[2]||"",path:i[3]||"",params:i[4]||"",query:i[5]||"",fragment:i[6]||""}:null},normalizePath:function(e){for(e=e.split("").reverse().join("").replace(r,"");e.length!==(e=e.replace(a,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}},e.exports=n}(Si)),Si.exports),Ii=class{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}}},Ri=function(e){return e.MANIFEST="manifest",e.LEVEL="level",e.AUDIO_TRACK="audioTrack",e.SUBTITLE_TRACK="subtitleTrack",e.MEDIA_FRAGMENT="media-fragment",e.KEY="key",e.STEERING_MANIFEST="steering-manifest",e.SERVER_CERTIFICATE="server-certificate",e.INTERSTITIAL_ASSET_LIST="interstitial-asset-list",e}({}),Li=function(e){return e.MAIN="main",e.AUDIO="audio",e.SUBTITLE="subtitle",e}({}),wi="audio",Di="video",Ci="audiovideo",Mi=class{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=Fi(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={[wi]:null,[Di]:null,[Ci]: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 Ii),this._stats}set stats(e){this._stats=e}get url(){return!this._url&&this.relurl&&(this._url=ki.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}clearElementaryStreamInfo(){let{elementaryStreams:e}=this;e[wi]=null,e[Di]=null,e[Ci]=null,this.url=null}};function Pi(e){return"initSegment"!==e.sn}function xi(e,t){return e.sn===(null==t?void 0:t.sn)&&e.level===t.level}function Oi(e,t){return e.sn===(null==t?void 0:t.sn)&&e.level===t.level&&e.cc===t.cc}var Ni=class extends Mi{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(vi(e)&&vi(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=vi(this.duration)?this.duration:0;return this.programDateTime+1e3*e}get encrypted(){var e;if(null!=(e=this._decryptdata)&&e.encrypted)return!0;if(this.levelkeys){var t;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){vi(e)?this._programDateTime=e:this._programDateTime=this.rawProgramDateTime=null}get ref(){return Pi(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,a,n=!1){let{elementaryStreams:s}=this,o=s[e];o?(o.startPTS=Math.min(o.startPTS,t),o.endPTS=Math.max(o.endPTS,i),o.startDTS=Math.min(o.startDTS,r),o.endDTS=Math.max(o.endDTS,a)):s[e]={startPTS:t,endPTS:i,startDTS:r,endDTS:a,partial:n}}},Ui=class extends Mi{constructor(e,t,i,r,a){super(i),this.fragOffset=0,this.duration=0,this.independent=!1,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.gap=!1,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;let n=e.enumeratedString("BYTERANGE");n&&this.setByteRange(n,a),a&&(this.fragOffset=a.fragOffset+a.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){let{elementaryStreams:e}=this;return!!(e.audio||e.video||e.audiovideo||this.fragment.type===Li.SUBTITLE&&this.stats.loading.end>0)}};function Fi(e,t){let i=Object.getPrototypeOf(e);if(i){return Object.getOwnPropertyDescriptor(i,t)||Fi(i,t)}}function Bi(e,t,i){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var r=i.call(e,t);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function $i(){return $i=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var r in i)({}).hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e},$i.apply(null,arguments)}function Hi(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 Gi(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?Hi(Object(i),!0).forEach(function(t){Bi(e,t,i[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):Hi(Object(i)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})}return e}function Ki(e,t){if(null==e)return{};var i,r,a=function(e,t){if(null==e)return{};var i={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;i[r]=e[r]}return i}(e,t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);for(r=0;r<n.length;r++)i=n[r],-1===t.indexOf(i)&&{}.propertyIsEnumerable.call(e,i)&&(a[i]=e[i])}return a}function Wi(e){switch(e.details){case Ti.FRAG_LOAD_TIMEOUT:case Ti.KEY_LOAD_TIMEOUT:case Ti.LEVEL_LOAD_TIMEOUT:case Ti.MANIFEST_LOAD_TIMEOUT:case Ti.AUDIO_TRACK_LOAD_TIMEOUT:case Ti.SUBTITLE_TRACK_LOAD_TIMEOUT:case Ti.ASSET_LIST_LOAD_TIMEOUT:return!0}return!1}function Vi(e){return e.details.startsWith("key")}function qi(e){return Vi(e)&&!!e.frag&&!e.frag.decryptdata}function Yi(e,t){let i=Wi(t);return e.default[(i?"timeout":"error")+"Retry"]}function ji(e,t){let i="linear"===e.backoff?1:Math.pow(2,t);return Math.min(i*e.retryDelayMs,e.maxRetryDelayMs)}function zi(e){return Gi(Gi({},e),{errorRetry:null,timeoutRetry:null})}function Qi(e,t,i,r){if(!e)return!1;let a=null==r?void 0:r.code,n=t<e.maxNumRetry&&(function(e){return Xi(e)||!!e&&(e<400||e>499)}(a)||!!i);return e.shouldRetry?e.shouldRetry(e,t,i,r,n):n}function Xi(e){return 0===e&&!1===navigator.onLine}function Zi(e,t){return t>0&&e.loadError>0&&0!==e.loadErrorTime&&self.performance.now()-e.loadErrorTime>t}var Ji=class{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_}},er=class{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_=new Ji(e),this.fast_=new Ji(t),this.defaultTTFB_=r,this.ttfb_=new Ji(e)}update(e,t){let{slow_:i,fast_:r,ttfb_:a}=this;i.halfLife!==e&&(this.slow_=new Ji(e,i.getEstimate(),i.getTotalWeight())),r.halfLife!==t&&(this.fast_=new Ji(t,r.getEstimate(),r.getTotalWeight())),a.halfLife!==e&&(this.ttfb_=new Ji(e,a.getEstimate(),a.getTotalWeight()))}sample(e,t){if(t<=0)return;let i=Math.min(this.minDelayMs_,t/1e5),r=8*t,a=Math.max(e,i)/1e3,n=r/a;this.fast_.sample(a,n),this.slow_.sample(a,n)}sampleTTFB(e){let t=e/1e3,i=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(i,Math.max(e,5))}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}get defaultEstimate(){return this.defaultEstimate_}destroy(){}},tr=class{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;let i=`[${e}]:`;this.trace=ir,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)}},ir=function(){},rr={trace:ir,debug:ir,log:ir,warn:ir,info:ir,error:ir};function ar(){return $i({},rr)}function nr(e,t,i){return t[e]?t[e].bind(t):function(e,t){let i=self.console[e];return i?i.bind(self.console,`${t?"["+t+"] ":""}[${e}] >`):ir}(e,i)}var sr=ar();var or=sr;function lr(e=!0){return"undefined"==typeof self?void 0:(e||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function dr(e,t){let i=Object.keys(e),r=Object.keys(t),a=i.length,n=r.length;return!a||!n||a===n&&!i.some(e=>-1===r.indexOf(e))}function ur(e){return e instanceof ArrayBuffer||"undefined"!=typeof SharedArrayBuffer&&e instanceof SharedArrayBuffer}var hr="utf-16be",cr="utf-16le",mr="utf-8";function fr(e,t){if(e<0)return-fr(-e,t);let i=Math.pow(10,t);if(Math.abs(e*i%1-.5)<Number.EPSILON){let t=Math.floor(e*i);return(t%2==0?t:t+1)/i}return Math.round(e*i)/i}function pr(){try{return crypto.randomUUID()}catch{try{let e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}catch{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)})}}}function gr(e,t){return t+10<=e.length&&73===e[t]&&68===e[t+1]&&51===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128}function vr(e,t){let i=0;return i=(127&e[t])<<21,i|=(127&e[t+1])<<14,i|=(127&e[t+2])<<7,i|=127&e[t+3],i}function Er(e,t){return gr(e,t)&&vr(e,t+6)+10<=e.length-t}function yr(e,t){return t+10<=e.length&&51===e[t]&&68===e[t+1]&&73===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128}function br(e,t){let i=t,r=0;for(;gr(e,t);){r+=10,r+=vr(e,t+6),yr(e,t+10)&&(r+=10),t+=r}if(r>0)return e.subarray(i,i+r)}function Tr(e,t=0,i=1/0){return function(e,t,i,r){let a=function(e){return ur(e)?e:e.buffer}(e),n=1;"BYTES_PER_ELEMENT"in r&&(n=r.BYTES_PER_ELEMENT);let s=function(e){return e&&ur(e.buffer)&&void 0!==e.byteLength&&void 0!==e.byteOffset}(e)?e.byteOffset:0,o=(s+e.byteLength)/n,l=(s+t)/n,d=Math.floor(Math.max(0,Math.min(l,o)));return new r(a,d,Math.floor(Math.min(d+Math.max(i,0),o))-d)}(e,t,i,Uint8Array)}function Ar(e,t=!1){let i=t?e.indexOf(0):e.length,r=function(e,t={}){let i;i=ur(e)?new DataView(e):new DataView(e.buffer,e.byteOffset,e.byteLength);let r=0,{encoding:a}=t;if(!a){let e=i.getUint8(0),t=i.getUint8(1);239==e&&187==t&&191==i.getUint8(2)?(a=mr,r=3):254==e&&255==t?(a=hr,r=2):255==e&&254==t?(a=cr,r=2):a=mr}if("undefined"!=typeof TextDecoder)return new TextDecoder(a).decode(i);let n,{byteLength:s}=i,o=a!==hr,l="";for(;r<s;){switch(a){case mr:if(n=i.getUint8(r),n<128)r++;else if(n>=194&&n<=223)if(r+1<s){let e=i.getUint8(r+1);e>=128&&e<=191?(n=(31&n)<<6|63&e,r+=2):r++}else r++;else if(n>=224&&n<=239)if(r+2<=s-1){let e=i.getUint8(r+1),t=i.getUint8(r+2);e>=128&&e<=191&&t>=128&&t<=191?(n=(15&n)<<12|(63&e)<<6|63&t,r+=3):r++}else r++;else if(n>=240&&n<=244)if(r+3<=s-1){let e=i.getUint8(r+1),t=i.getUint8(r+2),a=i.getUint8(r+3);e>=128&&e<=191&&t>=128&&t<=191&&a>=128&&a<=191?(n=(7&n)<<18|(63&e)<<12|(63&t)<<6|63&a,r+=4):r++}else r++;else r++;break;case hr:case"utf-16":case cr:n=i.getUint16(r,o),r+=2}l+=String.fromCodePoint(n)}return l}(new DataView(e.buffer,e.byteOffset,i),{encoding:mr});return t?r:r.replace(/\0/g,"")}function _r(e){let t={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 i=e.data.subarray(1).indexOf(0);if(-1===i)return;let r=Ar(Tr(e.data,1,i)),a=e.data[2+i],n=e.data.subarray(3+i).indexOf(0);if(-1===n)return;let s,o=Ar(Tr(e.data,3+i,n));return s="--\x3e"===r?Ar(Tr(e.data,4+i+n)):function(e){return ur(e)?e:0==e.byteOffset&&e.byteLength==e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer}(e.data.subarray(4+i+n)),t.mimeType=r,t.pictureType=a,t.description=o,t.data=s,t}function Sr(e){return"PRIV"===e.type?function(e){if(e.size<2)return;let t=Ar(e.data,!0),i=new Uint8Array(e.data.subarray(t.length+1));return{key:e.type,info:t,data:i.buffer}}(e):"W"===e.type[0]?function(e){if("WXXX"===e.type){if(e.size<2)return;let t=1,i=Ar(e.data.subarray(t),!0);t+=i.length+1;let r=Ar(e.data.subarray(t));return{key:e.type,info:i,data:r}}let t=Ar(e.data);return{key:e.type,info:"",data:t}}(e):"APIC"===e.type?_r(e):function(e){if(e.size<2)return;if("TXXX"===e.type){let t=1,{data:i}=e,r=Ar(i.subarray(t),!0);t+=r.length+1;let a=Ar(i.subarray(t));return{key:e.type,info:r,data:a}}let t=Ar(e.data.subarray(1));return{key:e.type,info:"",data:t}}(e)}function kr(e){let t=String.fromCharCode(e[0],e[1],e[2],e[3]),i=vr(e,4);return{type:t,size:i,data:e.subarray(10,10+i)}}function Ir(e){let t=0,i=[];for(;gr(e,t);){let r=vr(e,t+6);e[t+5]>>6&1&&(t+=10),t+=10;let a=t+r;for(;t+10<a;){let r=kr(e.subarray(t)),a=Sr(r);a&&i.push(a),t+=r.size+10}yr(e,t)&&(t+=10)}return i}function Rr(e){return e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info}function Lr(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)}}function wr(e){let t=Ir(e);for(let e of t)if(Rr(e))return Lr(e)}function Dr(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 Cr(e){return Uint8Array.from(e.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}function Mr(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0))}function Pr(e){return String.fromCharCode.apply(null,e)}var xr,Or=Math.pow(2,32)-1,Nr={avc1:1635148593,avcC:1635148611,hvc1:1752589105,hvcC:1752589123,btrt:1651798644,dinf:1684631142,dref:1685218662,esds:1702061171,free:1718773093,ftyp:1718909296,hdlr:1751411826,mdat:1835295092,mdhd:1835296868,mdia:1835297121,mfhd:1835427940,minf:1835626086,moof:1836019558,moov:1836019574,mp4a:1836069985,".mp3":778924083,dac3:1684103987,"ac-3":1633889587,mvex:1836475768,mvhd:1836476516,pasp:1885434736,sdtp:1935963248,stbl:1937007212,stco:1937007471,stsc:1937011555,stsd:1937011556,stsz:1937011578,stts:1937011827,tfdt:1952867444,tfhd:1952868452,traf:1953653094,trak:1953653099,trun:1953658222,trex:1953654136,tkhd:1953196132,vmhd:1986881636,smhd:1936549988},Ur={video:1,audio:2,id3:3,text:4};function Fr(e,t){let i=e[t]<<8|e[t+1];return i<0?65536+i:i}function Br(e,t){let i=e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3];return i<0?4294967296+i:i}function $r(e,t){let i=Br(e,t);return i*=Math.pow(2,32),i+=Br(e,t+4),i}function Hr(e,t){let i="";for(let r=t;r<e.length;r++)if(i+=String.fromCharCode(e[r]),0===e[r])return i;return null}function Gr(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function Kr(e,t,i){e[t]=i>>24,e[t+1]=i>>16&255,e[t+2]=i>>8&255,e[t+3]=255&i}function Wr(e,t,i){let r=t.byteOffset-e.byteOffset-8,a=8+i,n=t.byteLength+8-a;n<8||(Kr(e,r,a),Kr(e,r+a,n),Kr(e,r+a+4,Nr.free))}function Vr(e,t){return[e.byteOffset-t-8,e.byteOffset-t+e.byteLength]}function qr(e,t){t.sort((e,t)=>e[0]-t[0]);let i=t.reduce((e,[t,i])=>e+i-t,0),r=new Uint8Array(e.byteLength-i),a=0,n=0;for(let i=0;i<t.length;i++){let[s,o]=t[i];r.set(e.subarray(a,s),n),n+=s-a,a=o}return r.set(e.subarray(a),n),{result:r,dropped:i,droppedBefore:e=>t.reduce((t,[i,r])=>r<=e?t+r-i:t,0)}}function Yr(e,t){let i=[];return t.length&&jr(e,t,0,0,e.byteLength,i),i}function jr(e,t,i,r,a,n){let s=t[i];if(4!==(null==s?void 0:s.length))return;let o=s.charCodeAt(0),l=s.charCodeAt(1),d=s.charCodeAt(2),u=s.charCodeAt(3),h=t.length-1;for(let s=r;s<a;){let r=s+8<=a,c=s+4<=a?16777216*e[s]+(e[s+1]<<16|e[s+2]<<8|e[s+3]):Br(e,s),m=c>1?s+c:a;if(r&&e[s+4]===o&&e[s+5]===l&&e[s+6]===d&&e[s+7]===u){let r=Math.min(m,a);i===h?n.push(e.subarray(s+8,r)):jr(e,t,i+1,s+8,r,n)}s=m}}function zr(e){let t=[],i=e[0],r=8,a=Br(e,r);r+=4;let n=0,s=0;0===i?(n=Br(e,r),s=Br(e,r+4),r+=8):(n=$r(e,r),s=$r(e,r+8),r+=16),r+=2;let o=e.length+s,l=Fr(e,r);r+=2;for(let i=0;i<l;i++){let i=r,n=Br(e,i);i+=4;let s=2147483647&n;if((2147483648&n)>>>31==1)return or.warn("SIDX has hierarchical references (not supported)"),null;let l=Br(e,i);i+=4,t.push({referenceSize:s,subsegmentDuration:l,info:{duration:l/a,start:o,end:o+s-1}}),o+=s,i+=4,r=i}return{earliestPresentationTime:n,timescale:a,version:i,referencesCount:l,references:t}}function Qr(e){let t=[],i=Yr(e,["moov","trak"]);for(let e=0;e<i.length;e++){let r=i[e],a=Yr(r,["tkhd"])[0];if(a){let e=a[0],i=Br(a,0===e?12:20),n=Yr(r,["mdia","mdhd"])[0];if(n){e=n[0];let a=Br(n,0===e?12:20),s=Yr(r,["mdia","hdlr"])[0];if(s){let e=Pr(s.subarray(8,12)),n={soun:wi,vide:Di}[e],o=Xr(Yr(r,["mdia","minf","stbl","stsd"])[0]);n?(t[i]={timescale:a,type:n,stsd:o},t[n]=Gi({timescale:a,id:i},o)):t[i]={timescale:a,type:e,stsd:o}}}}}return Yr(e,["moov","mvex","trex"]).forEach(e=>{let i=Br(e,4),r=t[i];r&&(r.default={duration:Br(e,12),sampleSize:Br(e,16),flags:Br(e,20)})}),t}function Xr(e){let t,i=e.subarray(8),r=i.subarray(86),a=Pr(i.subarray(4,8)),n=a,s="enca"===a||"encv"===a;if(s){let e=Yr(i,[a])[0].subarray("enca"===a?28:78);Yr(e,["sinf"]).forEach(e=>{let t=Yr(e,["schm"])[0];if(t){let i=Pr(t.subarray(4,8));if("cbcs"===i||"cenc"===i){let t=Yr(e,["frma"])[0];t&&(n=Pr(t))}}})}let o=n;switch(n){case"avc1":case"avc2":case"avc3":case"avc4":{let e=Yr(r,["avcC"])[0];e&&e.length>3&&(n+="."+ea(e[1])+ea(e[2])+ea(e[3]),t=Zr("avc1"===o?"dva1":"dvav",r));break}case"mp4a":{let e=Yr(i,[a])[0],t=Yr(e.subarray(28),["esds"])[0];if(t&&t.length>7){let e=4;if(3!==t[e++])break;e=Jr(t,e),e+=2;let i=t[e++];if(128&i&&(e+=2),64&i&&(e+=t[e++]),4!==t[e++])break;e=Jr(t,e);let r=t[e++];if(64!==r)break;if(n+="."+ea(r),e+=12,5!==t[e++])break;e=Jr(t,e);let a=t[e++],s=(248&a)>>3;31===s&&(s+=1+((7&a)<<3)+((224&t[e])>>5)),n+="."+s}break}case"hvc1":case"hev1":{let e=Yr(r,["hvcC"])[0];if(e&&e.length>12){let t=e[1],i=["","A","B","C"][t>>6],r=31&t,a=Br(e,2),s=(32&t)>>5?"H":"L",o=e[12],l=e.subarray(6,12);n+="."+i+r,n+="."+function(e){let t=0;for(let i=0;i<32;i++)t|=(e>>i&1)<<31-i;return t>>>0}(a).toString(16).toUpperCase(),n+="."+s+o;let d="";for(let e=l.length;e--;){let t=l[e];(t||d)&&(d="."+t.toString(16).toUpperCase()+d)}n+=d}t=Zr("hev1"==o?"dvhe":"dvh1",r);break}case"dvh1":case"dvhe":case"dvav":case"dva1":case"dav1":n=Zr(n,r)||n;break;case"vp09":{let e=Yr(r,["vpcC"])[0];if(e&&e.length>6){let t=e[4],i=e[5],r=e[6]>>4&15;n+="."+ta(t)+"."+ta(i)+"."+ta(r)}break}case"av01":{let e=Yr(r,["av1C"])[0];if(e&&e.length>2){let i=e[1]>>>5,a=31&e[1],s=e[2]>>>7?"H":"M",o=(64&e[2])>>6,l=(32&e[2])>>5,d=2===i&&o?l?12:10:o?10:8,u=(16&e[2])>>4,h=(8&e[2])>>3,c=(4&e[2])>>2,m=3&e[2];n+="."+i+"."+ta(a)+s+"."+ta(d)+"."+u+"."+h+c+m+"."+ta(1)+"."+ta(1)+"."+ta(1)+".0",t=Zr("dav1",r)}break}}return{codec:n,encrypted:s,supplemental:t}}function Zr(e,t){let i=Yr(t,["dvvC"]),r=i.length?i[0]:Yr(t,["dvcC"])[0];if(r){let t=r[2]>>1&127,i=r[2]<<5&32|r[3]>>3&31;return e+"."+ta(t)+"."+ta(i)}}function Jr(e,t){let i=t+5;for(;128&e[t++]&&t<i;);return t}function ea(e){return("0"+e.toString(16).toUpperCase()).slice(-2)}function ta(e){return(e<10?"0":"")+e}function ia(e,t){Yr(e,["moov","trak"]).forEach(e=>{let i=Yr(e,["mdia","minf","stbl","stsd"])[0];if(!i)return;let r=i.subarray(8),a=Yr(r,["enca"]),n=a.length>0;n||(a=Yr(r,["encv"])),a.forEach(e=>{Yr(n?e.subarray(28):e.subarray(78),["sinf"]).forEach(e=>{let i=ra(e);i&&t(i,n)})})})}function ra(e){let t=Yr(e,["schm"])[0];if(t){let i=Pr(t.subarray(4,8));if("cbcs"===i||"cenc"===i){let t=Yr(e,["schi","tenc"])[0];if(t)return t}}}function aa(e){return"undefined"==typeof TextDecoder?Ar(e):(xr||(xr=new TextDecoder("utf-8"))).decode(e).replace(/\0/g,"")}function na(e,t,i,r,a){let n={},s=!1,o=function(e){let t=e.byteLength,i=[];for(let r=0;r<t;){let a=r+8<=t,n=r+4<=t?16777216*e[r]+(e[r+1]<<16|e[r+2]<<8|e[r+3]):Br(e,r),s=n>1?r+n:t;if(a&&109===e[r+4]&&111===e[r+5]&&111===e[r+6]&&102===e[r+7]){let a=Math.min(s,t);for(let t=r+8;t<a;){let n=t+8<=a,s=t+4<=a?16777216*e[t]+(e[t+1]<<16|e[t+2]<<8|e[t+3]):Br(e,t),o=s>1?t+s:a;if(n&&116===e[t+4]&&114===e[t+5]&&97===e[t+6]&&102===e[t+7]){let n,s,l=Math.min(o,a),d=[];for(let i=t+8;i<l;){let t=i+8<=l,r=i+4<=l?16777216*e[i]+(e[i+1]<<16|e[i+2]<<8|e[i+3]):Br(e,i),a=r>1?i+r:l;if(t&&116===e[i+4]){let t=Math.min(a,l);102===e[i+5]&&104===e[i+6]&&100===e[i+7]?s||(s=e.subarray(i+8,t)):102===e[i+5]&&100===e[i+6]&&116===e[i+7]?n||(n=e.subarray(i+8,t)):114===e[i+5]&&117===e[i+6]&&110===e[i+7]&&d.push(e.subarray(i+8,t))}i=a}i.push({moofOffset:e.byteOffset+r,tfdt:n,tfhd:s,truns:d})}t=o}}r=s}return i}(e),l=e.byteLength;for(let h=0;h<o.length;h++){let{moofOffset:c,tfdt:m,tfhd:f,truns:p}=o[h],g=Br(f,4),v=t[g];if(!v)continue;let E,y=n[g]||(n[g]={start:NaN,duration:0,sampleCount:0,trun:[],timescale:v.timescale,type:v.type});if(m){let e=m[0];E=Br(m,4),1===e&&(E===Or?i.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"):(E*=Or+1,E+=Br(m,8))),vi(E)&&(!vi(y.start)||E<y.start)&&(y.start=E),a&&vi(E)&&(a.timeOffset=E/a.timescale)}let b,T=(null==a?void 0:a.trackId)===g&&v.type===Di,A=v.default,_=16777215&Br(f,0),S=(null==A?void 0:A.duration)||0,k=(null==A?void 0:A.sampleSize)||0,I=8;1&_&&(I+=8),2&_&&(I+=4),8&_&&(S=Br(f,I),b=f.byteOffset-e.byteOffset+I,I+=4),16&_&&(k=Br(f,I));let R=0,L=!!(1&_),w=!L&&!!(131072&_);L?(R=Br(f,8),R*=Math.pow(2,32),R+=Br(f,12)):w&&(R=c);let D=E||0,C=0,M=S;for(let t=0;t<p.length;t++){let i=p[t],n=Br(i,4),s=y.sampleCount;y.sampleCount+=n;let o=1&i[3],h=0,c=4&i[3],m=1&i[2],f=2&i[2],g=4&i[2],v=8&i[2],E=8;o&&(h=Gr(i,E),E+=4),c&&(!(1&i[E+1])&&void 0===y.keyFrameIndex&&(y.keyFrameIndex=s),E+=4);let A,_,I,L=R+h;if(!r&&0===i[1]&&6===i[2]&&1===i[3]){var d,u;let t=D,r=L,s=E,o=-1,h=0,c=0,m=null!=(d=null==a?void 0:a.timeOffset)?d:0,f=S/(null!=(u=null==a?void 0:a.timescale)?u:1),p=!0===(null==a?void 0:a.isHEVCFlavor),g=p?2:1;for(let t=0;t<n;t++){let r=0===i[E]?i[E+1]<<16|i[E+2]<<8|i[E+3]:Br(i,E),n=-1===o&&void 0===y.keyFrameIndex&&!(1&i[E+5]);E+=8;let s=L+r;if(T){if(r>0){let t=L;do{let i=0===e[t]?e[t+1]<<16|e[t+2]<<8|e[t+3]:Br(e,t);t+=4;let r=e[t],n=p?r>>1&63:31&r;(p?39===n||40===n:6===n)&&da(e.subarray(t,t+i),g,m,a.samples),t+=i}while(t<s)}m+=f}L=s,n&&(o=t,h=L)}if(L<=l)c=n;else{let e=r,t=s;for(let r=0;r<n;r++){if(e+=0===i[t]?i[t+1]<<16|i[t+2]<<8|i[t+3]:Br(i,t),e>l)break;c=r+1,t+=8}}if(T&&(a.timeOffset=m),-1!==o&&h<=l&&void 0===y.keyFrameIndex&&(y.keyFrameIndex=o,y.keyFrameStart=t+o*S),c){(!vi(y.ptsMin)||t<y.ptsMin)&&(y.ptsMin=t);let e=t+c*S;(!vi(y.ptsMax)||e>y.ptsMax)&&(y.ptsMax=e)}let v=S*n;D=t+v,C+=v;continue}r&&(A=[],_={sampleOffset:L,samples:A,defaultSampleDurationOffset:b},L<=l&&y.trun.push(_));for(let t=0;t<n;t++){let n,s,o;m?(r&&(n=i.byteOffset-e.byteOffset+E),M=Br(i,E),E+=4):M=S,f?(I=Br(i,E),E+=4):I=k,g&&(o=1&i[E+1]?1:0,r&&(s={isNonSync:o,dependsOn:1==(3&i[E])?1:2}),E+=4);let d=0;if(v&&(d=0===i[0]?Br(i,E):Gr(i,E),E+=4),T){let t=L,i=0;for(;i<I;){let r=Br(e,t);t+=4,la(a.isHEVCFlavor,e[t])&&da(e.subarray(t,t+r),a.isHEVCFlavor?2:1,a.timeOffset+d/a.timescale,a.samples),t+=r,i+=r+4}a.timeOffset+=M/a.timescale}if(L+=I,L<=l){_&&void 0!==n&&(_.lastSampleDurationOffset=n),0===o&&void 0===y.keyFrameIndex&&(y.keyFrameIndex=t,y.keyFrameStart=D);let e=D+d;(!vi(y.ptsMin)||e<y.ptsMin)&&(y.ptsMin=e),(!vi(y.ptsMax)||e+M>y.ptsMax)&&(y.ptsMax=e+M),A&&(A[t]={cts:d,duration:M,flags:s,size:I})}D+=M,C+=M}!C&&S&&(C+=S*n)}y.duration+=C,y.duration&&(s=!0)}if(!s){let t=1/0,i=0,r=Yr(e,["sidx"]);for(let e=0;e<r.length;e++){let a=zr(r[e]);if(null!=a&&a.references){t=Math.min(t,a.earliestPresentationTime/a.timescale);let e=a.references.reduce((e,t)=>e+t.info.duration||0,0);i=Math.max(i,e+a.earliestPresentationTime/a.timescale)}}i&&vi(i)&&Object.keys(n).forEach(e=>{n[e].duration||(n[e].duration=i*n[e].timescale-n[e].start)})}return n}function sa(e,t){let i=new Uint8Array(e.length+t.length);return i.set(e),i.set(t,e.length),i}function oa(e){if(!e)return!1;let t=e.substring(0,4);return"hvc1"===t||"hev1"===t||"dvh1"===t||"dvhe"===t}function la(e,t){if(e){let e=t>>1&63;return 39===e||40===e}return 6==(31&t)}function da(e,t,i,r){let a=ua(e),n=0;n+=t;let s=0,o=0,l=0;for(;n<a.length;){s=0;do{if(n>=a.length)break;l=a[n++],s+=l}while(255===l);o=0;do{if(n>=a.length)break;l=a[n++],o+=l}while(255===l);let e=a.length-n,t=n;if(o<e)n+=o;else if(o>e){or.error(`Malformed SEI payload. ${o} is too small, only ${e} bytes left to parse.`);break}if(4===s){if(181===a[t++]){let e=Fr(a,t);if(t+=2,49===e){let e=Br(a,t);if(t+=4,1195456820===e){let e=a[t++];if(3===e){let n=a[t++],o=64&n,l=o?2+3*(31&n):0,d=new Uint8Array(l);if(o){d[0]=n;for(let e=1;e<l;e++)d[e]=a[t++]}r.push({type:e,payloadType:s,pts:i,bytes:d})}}}}}else if(5===s&&o>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 n=o-16,l=new Uint8Array(n);for(let e=0;e<n;e++)l[e]=a[t++];r.push({payloadType:s,pts:i,uuid:e.join(""),userData:aa(l),userDataBytes:l})}}}function ua(e){let t,i=e.byteLength,r=e.indexOf(3,3);for(;-1!==r;)0===e[r-1]&&0===e[r-2]&&(t||(t=[])).push(r),r=e.indexOf(3,r+1);if(!t)return e;let a=i-t.length,n=new Uint8Array(a),s=0,o=0;for(let i=0;i<a;o++,i++)o===t[s]&&(o++,s++),n[i]=e[o];return n}function ha(e,t,i){if(16!==e.byteLength)throw new RangeError("Invalid system id");let r,a,n;r=0,a=new Uint8Array,n=new Uint8Array;let s=new Uint8Array(4);return i.byteLength>0&&new DataView(s.buffer).setUint32(0,i.byteLength,!1),function(e,...t){let i=t.length,r=8,a=i;for(;a--;)r+=t[a].byteLength;let n=new Uint8Array(r);for(n[0]=r>>24&255,n[1]=r>>16&255,n[2]=r>>8&255,n[3]=255&r,n.set(e,4),a=0,r=8;a<i;a++)n.set(t[a],r),r+=t[a].byteLength;return n}([112,115,115,104],new Uint8Array([0,0,0,0]),e,n,a,s,i)}function ca(e){let t=[];if(e instanceof ArrayBuffer){let i=e.byteLength,r=0;for(;r+32<i;){let i=ma(new DataView(e,r));t.push(i),r+=i.size}}return t}function ma(e){let t=e.getUint32(0),i=e.byteOffset,r=e.byteLength;if(r<t)return{offset:i,size:r};if(1886614376!==e.getUint32(4))return{offset:i,size:t};let a=e.getUint32(8)>>>24;if(0!==a&&1!==a)return{offset:i,size:t};let n=e.buffer,s=Dr(new Uint8Array(n,i+12,16)),o=null,l=null,d=0;if(0===a)d=28;else{let a=e.getUint32(28);if(!a||r<32+16*a)return{offset:i,size:t};o=[];for(let e=0;e<a;e++)o.push(new Uint8Array(n,i+32+16*e,16));d=32+16*a}if(!d)return{offset:i,size:t};let u=e.getUint32(d);return t-32<u?{offset:i,size:t}:(l=new Uint8Array(n,i+d+4,u),0===a&&(o=function(e){let t=[];for(let i=0;i<e.length;){let r=e[i++],a=7&r;if(0===a){for(;128&e[i++];);continue}if(2!==a){i+=1===a?8:4;continue}let n=0;for(let t=0,r=128;128&r;t+=7)n|=(127&(r=e[i++]))<<t;if(r>>3==2)if(32===n){let r=new Uint8Array(16);for(let t=0;t<16;t++)r[t]=parseInt(String.fromCharCode(e[i+2*t],e[i+2*t+1]),16);t.push(r)}else 16===n&&t.push(e.subarray(i,i+16));i+=n}return t}(l)),{version:a,systemId:s,kids:o,data:l,offset:i,size:t})}var fa,pa,ga,va=ya("userAgent"),Ea=ya("vendor");function ya(e){try{return navigator[e]||""}catch{}return""}function ba(){if(void 0===fa){let e=va.match(/Chrome\/(\d+)/i);fa=e?parseInt(e[1]):0}return fa}function Ta(){return/\(Windows.+Firefox\//i.test(va)}var Aa={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},image:{mjpg:1}};function _a(e,t){let i=Aa[t];return!!i&&!!i[e.slice(0,4)]}function Sa(e,t,i=!0){return!e.split(",").some(e=>!ka(e,t,i))}function ka(e,t,i=!0){var r;let a=lr(i);return null!=(r=null==a?void 0:a.isTypeSupported(Ia(e,t)))&&r}function Ia(e,t){return`${t}/mp4;codecs=${e}`}function Ra(e){if(e){let t=e.substring(0,4);return Aa.video[t]}return 2}function La(e){let t=Ta();return e.split(",").reduce((e,i)=>{let r=t&&oa(i)?9:Aa.video[i];return r?(2*r+e)/(e?3:2):(Aa.audio[i]+e)/(e?2:1)},0)}var wa={};var Da=/flac|opus|mp4a\.40\.34/i;function Ca(e,t=!0){return e.replace(Da,e=>function(e,t=!0){if(wa[e])return wa[e];let i={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"],"mp4a.40.34":["mp3"]}[e];for(let a=0;a<i.length;a++){var r;if(ka(i[a],"audio",t))return wa[e]=i[a],i[a];if("mp3"===i[a]&&null!=(r=lr(t))&&r.isTypeSupported("audio/mpeg"))return""}return e}(e.toLowerCase(),t))}function Ma(e,t){if(e&&(e.length>4||-1!==["ac-3","ec-3","alac","fLaC","Opus"].indexOf(e))&&(Pa(e,"audio")||Pa(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 Pa(e,t){return _a(e,t)&&ka(e,t)}function xa(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}function Oa(e){let t=lr(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 Na(e){return e.replace(/^.+codecs=["']?([^"']+).*$/,"$1")}var Ua={supported:!1,smooth:!1,powerEfficient:!1},Fa={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]};function Ba(e,t){return{supported:!1,configurations:t,decodingInfoResults:[Ua],error:e}}function $a(e,t,i,r,a,n){let s=e.videoCodec,o=e.audioCodec?e.audioGroups:null,l=null==n?void 0:n.audioCodec,d=null==n?void 0:n.channels,u=d?parseInt(d):l?1/0:2,h=null;if(null!=o&&o.length)try{h=1===o.length&&o[0]?t.groups[o[0]].channels:o.reduce((e,i)=>{if(i){let r=t.groups[i];if(!r)throw new 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{return!0}return void 0!==s&&(s.split(",").some(e=>oa(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(a,8e6))||!!h&&vi(u)&&Object.keys(h).some(e=>parseInt(e)>u)}function Ha(e,t,i,r={}){let a=e.videoCodec;if(!a&&!e.audioCodec||!i)return Promise.resolve(Fa);let n=[],s=function(e){var t;let i=null==(t=e.videoCodec)?void 0:t.split(","),r=Ka(e),a=e.width||640,n=e.height||480,s=e.frameRate||30,o=e.videoRange.toLowerCase();return i?i.map(e=>{let t={contentType:Ia(xa(e),"video"),width:a,height:n,bitrate:r,framerate:s};return"sdr"!==o&&(t.transferFunction=o),t}):[]}(e),o=s.length,l=function(e,t,i){var r;let a=null==(r=e.audioCodec)?void 0:r.split(","),n=Ka(e);return a&&e.audioGroups?e.audioGroups.reduce((e,r)=>{var s;let o=r?null==(s=t.groups[r])?void 0:s.tracks:null;return o?o.reduce((e,t)=>{if(t.groupId===r){let r=parseFloat(t.channels||"");a.forEach(t=>{let a={contentType:Ia(t,"audio"),bitrate:i?Ga(t,n):n};r&&(a.channels=""+r),e.push(a)})}return e},e):e},[]):[]}(e,t,o>0),d=l.length;for(let e=o||1*d||1;e--;){let t={type:"media-source"};if(o&&(t.video=s[e%o]),d){t.audio=l[e%d];let i=t.audio.bitrate;t.video&&i&&(t.video.bitrate-=i)}n.push(t)}if(a){let e=navigator.userAgent;if(a.split(",").some(e=>oa(e))&&Ta())return Promise.resolve(Ba(new Error(`Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent string: (${e})`),n))}return Promise.all(n.map(e=>{let t=function(e){let t="",{audio:i,video:r}=e;if(r){t+=`${Na(r.contentType)}_r${r.height}x${r.width}f${Math.ceil(r.framerate)}${r.transferFunction||"sd"}_${Math.ceil(r.bitrate/1e5)}`}if(i){t+=`${r?"_":""}${Na(i.contentType)}_c${i.channels}`}return t}(e);return r[t]||(r[t]=i.decodingInfo(e))})).then(e=>({supported:!e.some(e=>!e.supported),configurations:n,decodingInfoResults:e})).catch(e=>({supported:!1,configurations:n,decodingInfoResults:[],error:e}))}function Ga(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)}function Ka(e){return 1e3*Math.ceil(Math.max(.9*e.bitrate,e.averageBitrate)/1e3)||1}function Wa(e,t,i){let r=encodeURIComponent(t),a=`${r}=${encodeURIComponent(i)}`,n=!1,s=[];e.search.substring(1).split("&").forEach(e=>{e===r||e.startsWith(r+"=")?n||(s.push(a),n=!0):e&&s.push(e)}),n||s.push(a),e.search=s.join("&")}var Va=["NONE","TYPE-0","TYPE-1",null];var qa=["SDR","PQ","HLG"];var Ya="",ja="YES",za="v2";function Qa(e){let{canSkipUntil:t,canSkipDateRanges:i,age:r}=e;return t&&r<t/2?i?za:ja:Ya}var Xa=class{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&&Wa(t,"_HLS_msn",this.msn.toString()),void 0!==this.part&&Wa(t,"_HLS_part",this.part.toString()),this.skip&&Wa(t,"_HLS_skip",this.skip),t.href}},Za=class{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.imageCodec=void 0,this.iframes=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loadErrorTime=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,"imageCodec"in e&&(this.imageCodec=e.imageCodec),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;let i=null==(t=e.supplemental)?void 0:t.videoCodec;i&&i!==e.videoCodec&&(this.codecSet+=`,${i.substring(0,4)}`)}"iframes"in e&&e.iframes?this.iframes=!0:(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 Ja(this._audioGroups,e)}hasSubtitleGroup(e){return Ja(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 Ja(e,t){return!(!t||!e)&&-1!==e.indexOf(t)}function en(e,t){let i=!1,r=[];if(e&&(i="SDR"!==e,r=[e]),t){r=t.allowedVideoRanges||qa.slice(0);let e="SDR"!==r.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}(),i||(r=["SDR"])}return{preferHDR:i,allowedVideoRanges:r}}var tn=(e,t)=>JSON.stringify(e,(e=>{let t=new WeakSet;return(i,r)=>{if(e&&(r=e(i,r)),"object"==typeof r&&null!==r){if(t.has(r))return;t.add(r)}return r}})(t));function rn(e,t){or.log(`[abr] start candidates with "${e}" ignored because ${t}`)}function an(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 nn(e){if(!e)return e;let{lang:t,assocLang:i,characteristics:r,channels:a,audioCodec:n}=e;return{lang:t,assocLang:i,characteristics:r,channels:a,audioCodec:n}}function sn(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(on(e,t[r],i))return r}return-1}function on(e,t,i){let{groupId:r,name:a,lang:n,assocLang:s,default:o}=e,l=e.forced;return(void 0===r||t.groupId===r)&&(void 0===a||t.name===a)&&(void 0===n||function(e,t="--"){return e.length===t.length?e===t:e.startsWith(t)||t.startsWith(e)}(n,t.lang))&&(void 0===s||t.assocLang===s)&&(void 0===o||t.default===o)&&(void 0===l||t.forced===l)&&(!("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 ln(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 dn(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 un(e,t){var i;return!!e&&e!==(null==(i=t.loadLevelObj)?void 0:i.uri)}function hn(e,t){return!t||-1!==t.indexOf(e)}function cn(e,t){if(t||e){let i=$i({},t);return e&&(e.videoCodec&&(i.videoCodec=e.videoCodec),e.videoRange&&(i.allowedVideoRanges=[e.videoRange])),i}}var mn=function(e,t){let i=0,r=e.length-1,a=null,n=null;for(;i<=r;){a=(i+r)/2|0,n=e[a];let s=t(n);if(s>0)i=a+1;else{if(!(s<0))return n;r=a-1}}return null};function fn(e,t,i=0,r=0,a=.005){let n=null;if(e){n=t[1+e.sn-t[0].sn]||null;let r=e.endDTS-i;r>0&&r<15e-7&&(i+=15e-7),n&&e.level!==n.level&&n.end<=e.end&&(n=t[2+e.sn-t[0].sn]||null)}else 0===i&&0===t[0].start&&(n=t[0]);if(n&&((!e||e.level===n.level)&&0===pn(i,r,n)||function(e,t,i){if(0===(null==t?void 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}(n,e,Math.min(a,r))))return n;let s=mn(t,pn.bind(null,i,r));return!s||s===e&&n?n:s}function pn(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 gn(e,t,i){let r=1e3*Math.min(t,i.duration+(i.deltaPTS?i.deltaPTS:0));return(i.endProgramDateTime||0)-r>e}function vn(e,t,i){if(e&&e.startCC<=t&&e.endCC>=t){let r,a=e.fragments,{fragmentHint:n}=e;return n&&(a=a.concat(n)),mn(a,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 En(e,t){return t===e.endSN&&e.fragmentHint?e.fragmentHint:e.fragments[1+t-e.startSN]||null}var yn=0,bn=2,Tn=3,An=5,_n=0,Sn=1,kn=2,In=4,Rn=8,Ln=16;function wn(e){let t=e.details;return t===Ti.BUFFER_ADD_CODEC_ERROR||t===Ti.MEDIA_SOURCE_REQUIRES_RESET||t===Ti.BUFFER_APPEND_ERROR&&!Dn(e)}function Dn(e){return e.details===Ti.BUFFER_APPEND_ERROR&&("QuotaExceededError"===e.error.name||"InvalidStateError"===e.error.name)}function Cn(e){let t={action:yn,flags:_n};return e&&(t.resolved=!0),t}var Mn="NOT_LOADED",Pn="APPENDING",xn="PARTIAL",On="OK",Nn=class{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(Ai.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Ai.BUFFER_APPENDED,this.onBufferAppended,this),e.on(Ai.FRAG_BUFFERED,this.onFragBuffered,this),e.on(Ai.FRAG_LOADED,this.onFragLoaded,this))}_unregisterListeners(){let{hls:e}=this;e&&(e.off(Ai.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Ai.BUFFER_APPENDED,this.onBufferAppended,this),e.off(Ai.FRAG_BUFFERED,this.onFragBuffered,this),e.off(Ai.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;if(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,a=Object.keys(r);for(let n=a.length;n--;){let s=r[a[n]];if((null==s?void 0:s.body.type)===t&&(!i||s.buffered)){let t=s.body;if(t.start<=e&&e<=t.end)return t}}return null}detectEvictedFragments(e,t,i,r,a,n){this.timeRanges&&(this.timeRanges[e]=t);let s=(null==a?void 0:a.fragment.sn)||-1;Object.keys(this.fragments).forEach(a=>{let o=this.fragments[a];if(!o||!this.hls)return;let l=o.body;if(s>=l.sn)return;if(!o.buffered&&(!o.loaded||n))return void(l.type===i&&this.removeFragment(l));let d=o.range[e];if(d){if(0===d.time.length)return void this.removeFragment(l);if(d.time.some(e=>{let i=!this.isTimeBuffered(e.startPTS,e.endPTS,t);return i&&this.removeFragment(l),i}),r&&r!==l&&ba()){let e=r.endPTS,t=l.startPTS;if(e&&t&&o.range.video){let i=t-e;i<0&&i>-.1&&(this.removeFragment(l),this.hls.trigger(Ai.BUFFER_FLUSHING,{startOffset:e+.004,endOffset:1/0,type:"video"}))}}}})}detectPartialFragments(e){let t=this.timeRanges,{frag:i,part:r,id:a}=e;if(!t||!Pi(i))return;let n=Fn(i),s=this.fragments[n];if(!s||s.buffered&&i.gap)return;let o=!i.relurl;Object.keys(t).forEach(e=>{let n=i.elementaryStreams[e];if(!n)return;let l=t[e],d=o||!0===n.partial;s.range[e]=this.getBufferedTimes(i,r,d,l),this.detectEvictedFragments(e,l,a,i,r)}),s.loaded=null;let l=Object.keys(s.range);if(l.length){if(this.bufferedEnd(s,i),Un(s)||this.removeParts(i.sn-1,i.type),!r){let e=Math.min(.004,i.duration);l.some(t=>{var r;let a=null==(r=s.range[t])?void 0:r.time,n=0===a.length||1===a.length&&a[0].endPTS-a[0].startPTS<e;return n&&this.addAsGap(i),n})}}else this.removeFragment(i)}addAsGap(e){e.gap=!0,this.removeFragment(e),this.fragBuffered(e,!0)}bufferedEnd(e,t){e.buffered=!0,(e.body.endList=t.endList||e.body.endList)&&!t.gap&&(this.endListFragments[e.body.type]=e)}removeParts(e,t){let i=this.activePartLists[t];i&&(this.activePartLists[t]=Bn(i,t=>t.fragment.sn>=e))}fragBuffered(e,t){let i=Fn(e),r=this.fragments[i];return!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)),r}getBufferedTimes(e,t,i,r){let a={time:[],partial:i},n=e.start,s=e.end,o=e.minEndPTS||s,l=e.maxStartPTS||n;for(let e=0;e<r.length;e++){let t=r.start(e)-this.bufferPadding,i=r.end(e)+this.bufferPadding;if(l>=t&&o<=i){a.time.push({startPTS:Math.max(n,r.start(e)),endPTS:Math.min(s,r.end(e))});break}if(n<i&&s>t){let t=Math.max(n,r.start(e)),i=Math.min(s,r.end(e));i>t&&(a.partial=!0,a.time.push({startPTS:t,endPTS:i}))}else if(s<=t)break}return a}getPartialFragment(e){let t,i,r,a=null,n=0,{bufferPadding:s,fragments:o}=this;return Object.keys(o).forEach(l=>{let d=o[l];d&&Un(d)&&(i=d.body.start-s,r=d.body.end+s,e>=i&&e<=r&&(t=Math.min(e-i,r-e),n<=t&&(a=d.body,n=t)))}),a}isEndListAppended(e){let t=this.endListFragments[e];return void 0!==t&&(t.buffered||Un(t))}getState(e){let t=Fn(e),i=this.fragments[t];return i?i.buffered?Un(i)?xn:On:Pn:Mn}isTimeBuffered(e,t,i){let r,a;for(let n=0;n<i.length;n++){if(r=i.start(n)-this.bufferPadding,a=i.end(n)+this.bufferPadding,e>=r&&t<=a)return!0;if(t<=r)return!1}return!1}onManifestLoading(){this.removeAllFragments()}onFragLoaded(e,t){if(!Pi(t.frag)||t.frag.bitrateTest)return;let i=t.frag,r=t.part?null:t,a=Fn(i);this.fragments[a]={body:i,appendedPTS:null,loaded:r,buffered:!1,range:Object.create(null)}}onBufferAppended(e,t){let{frag:i,part:r,timeRanges:a}=t;if(!Pi(i))return;let n=i.type;if(r){let e=this.activePartLists[n];e||(this.activePartLists[n]=e=[]),e.push(r)}this.timeRanges=a}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){let t=Fn(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 a=t[i[r]];if((null==a?void 0:a.body.type)===e)return!0}return!1}hasParts(e){var t;return!(null==(t=this.activePartLists[e])||!t.length)}getBackBufferEvictionEnd(e,t,i){let{fragments:r}=this,a=0,n=0,s=Object.keys(r);for(let o=0;o<s.length;o++){let l=r[s[o]];if(!l||!l.buffered||l.body.type!==t)continue;let d=l.body;if(d.gap)return 0;let u=d.hasStats&&d.stats.loaded||d.byteLength||d.bitrate&&8*d.bitrate*d.duration;if(d.end<=e&&u&&(a+=u,n=Math.max(n,d.end),a>=i))return n}return n>0?n:0}removeFragmentsInRange(e,t,i,r,a){r&&!this.hasGaps||Object.keys(this.fragments).forEach(n=>{let s=this.fragments[n];if(!s)return;let o=s.body;o.type!==i||r&&!o.gap||o.start<t&&o.end>e&&(s.buffered||a)&&this.removeFragment(o)})}removeFragment(e){let t=Fn(e);e.clearElementaryStreamInfo();let i=this.activePartLists[e.type];if(i){let t=e.sn;this.activePartLists[e.type]=Bn(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;t&&t.forEach(e=>e.clearElementaryStreamInfo())}};function Un(e){var t,i,r,a;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||null!=(a=e.range.subs)&&a.partial)}function Fn(e){return`${e.type}_${e.level}_${e.sn}`}function Bn(e,t){return e.filter(e=>{let i=t(e);return i||e.clearElementaryStreamInfo(),i})}var $n=0,Hn=1,Gn=class{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 $n:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e);case Hn:return this.subtle.decrypt({name:"AES-CTR",counter:this.aesIV,length:64},t,e);default:throw new Error(`[AESCrypto] invalid aes mode ${this.aesMode}`)}}};var Kn=class{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],a=i[1],n=i[2],s=i[3],o=this.invSubMix,l=o[0],d=o[1],u=o[2],h=o[3],c=new Uint32Array(256),m=0,f=0,p=0;for(p=0;p<256;p++)c[p]=p<128?p<<1:p<<1^283;for(p=0;p<256;p++){let i=f^f<<1^f<<2^f<<3^f<<4;i=i>>>8^255&i^99,e[m]=i,t[i]=m;let o=c[m],p=c[o],g=c[p],v=257*c[i]^16843008*i;r[m]=v<<24|v>>>8,a[m]=v<<16|v>>>16,n[m]=v<<8|v>>>24,s[m]=v,v=16843009*g^65537*p^257*o^16843008*m,l[i]=v<<24|v>>>8,d[i]=v<<16|v>>>16,u[i]=v<<8|v>>>24,h[i]=v,m?(m=o^c[c[c[g^o]]],f^=c[c[f]]):m=f=1}}expandKey(e){let t=this.uint8ArrayToUint32Array_(e),i=!0,r=0;for(;r<t.length&&i;)i=t[r]===this.key[r],r++;if(i)return;this.key=t;let a=this.keySize=t.length;if(4!==a&&6!==a&&8!==a)throw new Error("Invalid aes key size="+a);let n,s,o,l,d=this.ksRows=4*(a+6+1),u=this.keySchedule=new Uint32Array(d),h=this.invKeySchedule=new Uint32Array(d),c=this.sBox,m=this.rcon,f=this.invSubMix,p=f[0],g=f[1],v=f[2],E=f[3];for(n=0;n<d;n++)n<a?o=u[n]=t[n]:(l=o,n%a===0?(l=l<<8|l>>>24,l=c[l>>>24]<<24|c[l>>>16&255]<<16|c[l>>>8&255]<<8|c[255&l],l^=m[n/a|0]<<24):a>6&&n%a===4&&(l=c[l>>>24]<<24|c[l>>>16&255]<<16|c[l>>>8&255]<<8|c[255&l]),u[n]=o=(u[n-a]^l)>>>0);for(s=0;s<d;s++)n=d-s,l=3&s?u[n]:u[n-4],h[s]=s<4||n<=4?l:p[c[l>>>24]]^g[c[l>>>16&255]]^v[c[l>>>8&255]]^E[c[255&l]],h[s]=h[s]>>>0}networkToHostOrderSwap(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24}decrypt(e,t,i){let r,a,n,s,o,l,d,u,h,c,m,f,p,g,v=this.keySize+6,E=this.invKeySchedule,y=this.invSBox,b=this.invSubMix,T=b[0],A=b[1],_=b[2],S=b[3],k=this.uint8ArrayToUint32Array_(i),I=k[0],R=k[1],L=k[2],w=k[3],D=new Int32Array(e),C=new Int32Array(D.length),M=this.networkToHostOrderSwap;for(;t<D.length;){for(h=M(D[t]),c=M(D[t+1]),m=M(D[t+2]),f=M(D[t+3]),o=h^E[0],l=f^E[1],d=m^E[2],u=c^E[3],p=4,g=1;g<v;g++)r=T[o>>>24]^A[l>>16&255]^_[d>>8&255]^S[255&u]^E[p],a=T[l>>>24]^A[d>>16&255]^_[u>>8&255]^S[255&o]^E[p+1],n=T[d>>>24]^A[u>>16&255]^_[o>>8&255]^S[255&l]^E[p+2],s=T[u>>>24]^A[o>>16&255]^_[l>>8&255]^S[255&d]^E[p+3],o=r,l=a,d=n,u=s,p+=4;r=y[o>>>24]<<24^y[l>>16&255]<<16^y[d>>8&255]<<8^y[255&u]^E[p],a=y[l>>>24]<<24^y[d>>16&255]<<16^y[u>>8&255]<<8^y[255&o]^E[p+1],n=y[d>>>24]<<24^y[u>>16&255]<<16^y[o>>8&255]<<8^y[255&l]^E[p+2],s=y[u>>>24]<<24^y[o>>16&255]<<16^y[l>>8&255]<<8^y[255&d]^E[p+3],C[t]=M(r^I),C[t+1]=M(s^R),C[t+2]=M(n^L),C[t+3]=M(a^w),I=h,R=c,L=m,w=f,t+=4}return C.buffer}},Wn=class{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 $n:return"AES-CBC";case Hn:return"AES-CTR";default:throw new Error(`[FastAESKey] invalid aes mode ${e}`)}}(this.aesMode);return this.subtle.importKey("raw",this.key,{name:e},!1,["encrypt","decrypt"])}};var Vn=class{constructor(e,t){if(this.logEnabled=!0,this.decryptRange=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.enableSoftwareAES=void 0,this.enableSoftwareAES=e.enableSoftwareAES,!0!==t)try{let e=self.crypto;e&&(this.subtle=e.subtle||e.webkitSubtle)}catch{}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);this.reset();let r=this.decryptRange;return r?0===r.start&&r.end>=i.length?i:i.slice(r.start,r.end):function(e){let t=e.byteLength,i=t&&new DataView(e.buffer).getUint8(t-1);return i?e.slice(0,t-i):e}(i)}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(e,t,i,r,a){return this.decryptRange=a,this.useSoftware||a?new Promise((a,n)=>{let s=ArrayBuffer.isView(e)?e:new Uint8Array(e);this.softwareDecrypt(s,t,i,r);let o=this.flush();o?a(o.buffer):n(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,i,r)}softwareDecrypt(e,t,i,r){let{currentIV:a,currentResult:n,remainderData:s}=this;if(r!==$n||16!==t.byteLength)return or.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;this.logOnce("JS AES decrypt"),s&&(e=sa(s,e),this.remainderData=null);let o=this.getValidChunk(e);if(!o.length)return null;a&&(i=a);let l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new Kn),l.expandKey(t);let d=n;return this.currentResult=l.decrypt(o.buffer,0,i),this.currentIV=o.slice(-16).buffer,d||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 Wn(this.subtle,t,r)}return this.fastAesKey.expandKey().then(t=>this.subtle?(this.logOnce("WebCrypto AES decrypt"),new Gn(this.subtle,new Uint8Array(i),r).decrypt(e.buffer,t)):Promise.reject(new Error("web crypto not initialized"))).catch(a=>(or.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${a.name}: ${a.message}`),this.onWebCryptoError(e,t,i,r)))}onWebCryptoError(e,t,i,r){let a=this.enableSoftwareAES;if(a){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,i,r);let a=this.flush();if(a)return a.buffer}throw new Error("WebCrypto"+(a?" 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&&(or.log(`[decrypter]: ${e}`),this.logEnabled=!1)}},qn=Math.pow(2,17),Yn=class{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,i,r){let a=e.url;if(!a)return Promise.reject(new Xn({type:bi.NETWORK_ERROR,details:Ti.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error("Fragment does not have a "+(a?"part list":"url")),networkDetails:null}));this.abort();let n=this.config,s=n.fLoader,o=n.loader;return new Promise((l,d)=>{if(this.loader&&this.loader.destroy(),e.gap){if(e.tagList.some(e=>"GAP"===e[0]))return void d(Qn(e));e.gap=!1}let u=this.loader=s?new s(n):new o(n),h=jn(e,null,t);e.loader=u;let c=zi(n.fragLoadPolicy.default),m={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===e.sn?1/0:qn};u.stats.retry=e.stats.retry,e.stats=u.stats;let f={onSuccess:(t,i,r,a)=>{this.resetLoader(e,u);let n=t.data;r.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(n.slice(0,16)),n=n.slice(16)),l({frag:e,part:null,payload:n,networkDetails:a})},onError:(t,i,r,n)=>{this.resetLoader(e,u),d(new Xn({type:bi.NETWORK_ERROR,details:Ti.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:Gi({url:a,data:void 0},t),error:new Error(`HTTP Error ${t.code} ${t.text}`),networkDetails:r,stats:n}))},onAbort:(t,i,r)=>{this.resetLoader(e,u),d(new Xn({type:bi.NETWORK_ERROR,details:Ti.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:r,stats:t}))},onTimeout:(t,i,r)=>{this.resetLoader(e,u),d(new Xn({type:bi.NETWORK_ERROR,details:Ti.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${m.timeout}ms`),networkDetails:r,stats:t}))}};if(i){let t=this.gateProgress(i,r);f.onProgress=(i,r,a,n)=>t({frag:e,part:null,payload:a,networkDetails:n})}u.load(h,m,f)})}gateProgress(e,t){let i=e;if(t){let r=[],a=!1;t.then(()=>{a=!0,r.forEach(t=>e(t)),r.length=0}).catch(()=>{}),i=t=>{a?e(t):r.push(t)}}return i}loadPart(e,t,i){this.abort();let r=this.config,a=r.fLoader,n=r.loader;return new Promise((s,o)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap)return void o(Qn(e,t));let l=this.loader=a?new a(r):new n(r),d=jn(e,t);e.loader=l;let u=zi(r.fragLoadPolicy.default),h={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:qn};t.stats=l.stats,l.load(d,h,{onSuccess:(r,a,n,o)=>{this.resetLoader(e,l),this.updateStatsFromPart(e,t);let d={frag:e,part:t,payload:r.data,networkDetails:o};i(d),s(d)},onError:(i,r,a,n)=>{this.resetLoader(e,l),o(new Xn({type:bi.NETWORK_ERROR,details:Ti.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:Gi({url:d.url,data:void 0},i),error:new Error(`HTTP Error ${i.code} ${i.text}`),networkDetails:a,stats:n}))},onAbort:(i,r,a)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,l),o(new Xn({type:bi.NETWORK_ERROR,details:Ti.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:a,stats:i}))},onTimeout:(i,r,a)=>{this.resetLoader(e,l),o(new Xn({type:bi.NETWORK_ERROR,details:Ti.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:a,stats:i}))}})})}updateStatsFromPart(e,t){let i=e.stats,r=t.stats,a=r.total;if(i.loaded+=r.loaded,a){let r=Math.round(e.duration/t.duration),n=Math.min(Math.round(i.loaded/a),r),s=(r-n)*Math.round(i.loaded/n);i.total=i.loaded+s}else i.total=Math.max(i.loaded,i.total);let n=i.loading,s=r.loading;n.start?n.first+=s.first-s.start:(n.start=s.start,n.first=s.first),n.end=s.end}resetLoader(e,t){e.loader=null,e.url=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}};function jn(e,t=null,i){let r=t||e,a={type:Ri.MEDIA_FRAGMENT,frag:e,part:t,responseType:"arraybuffer",url:r.url,headers:{},rangeStart:0,rangeEnd:0},n=zn(e,t,i);return n.resetIV&&(a.resetIV=!0),n.byteRange&&(a.rangeStart=n.byteRange.start,a.rangeEnd=n.byteRange.end),a}function zn(e,t=null,i){let r={},a=t||e,n=a.byteRangeStartOffset,s=a.byteRangeEndOffset;var o;if(vi(n)&&vi(s))if(("initSegment"===e.sn||i)&&function(e){return"AES-128"===e||"AES-256"===e}(null==(o=e.decryptdata)?void 0:o.method)){let e=16*Math.floor(n/16),t=16*Math.ceil(s/16);r.decryptRange={start:n-e,end:s-e},e>=16&&(r.resetIV=!0,e-=16),r.byteRange={start:e,end:t}}else r.byteRange={start:n,end:s};return r}function Qn(e,t){let i=new Error(`GAP ${e.gap?"tag":"attribute"} found`),r={type:bi.MEDIA_ERROR,details:Ti.FRAG_GAP,fatal:!1,frag:e,error:i,networkDetails:null};return t&&(r.part=t),(t||e).stats.aborted=!0,new Xn(r)}var Xn=class extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}},Zn=class extends tr{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):(this.log(`possible exception thrown in task-loop (${this.constructor.name}.doTick)`),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}},Jn=class{constructor(e,t,i,r=0,a=-1,n=!1,s,o,l){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.iframe=void 0,this.duration=void 0,this.decryptRange=void 0,this.transmuxing={start:0,executeStart:0,executeEnd:0,end:0},this.buffering={audio:{start:0,executeStart:0,executeEnd:0,end:0},video:{start:0,executeStart:0,executeEnd:0,end:0},audiovideo:{start:0,executeStart:0,executeEnd:0,end:0}},this.level=e,this.sn=t,this.id=i,this.size=r,this.part=a,this.partial=n,this.duration=s||0,this.decryptRange=l,this.iframe=o||!1}};var es={length:0,start:()=>0,end:()=>0},ts=class e{static isBuffered(t,i){if(t){let r=e.getBuffered(t);for(let e=r.length;e--;)if(i>=r.start(e)&&i<=r.end(e))return!0}return!1}static bufferedRanges(t){if(t){let i=e.getBuffered(t);return e.timeRangesToArray(i)}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(t,i,r){if(t){let a=e.bufferedRanges(t);if(a.length)return e.bufferedInfo(a,i,r)}return{len:0,start:i,end:i,bufferedIndex:-1}}static bufferedInfo(e,t,i){t=Math.max(0,t),e.length>1&&e.sort((e,t)=>e.start-t.start||t.end-e.end);let r=-1,a=[];if(i)for(let n=0;n<e.length;n++){t>=e[n].start&&t<=e[n].end&&(r=n);let s=a.length;if(s){let t=a[s-1].end;e[n].start-t<i?e[n].end>t&&(a[s-1].end=e[n].end):a.push(e[n])}else a.push(e[n])}else a=e;let n,s=0,o=t,l=t;for(let e=0;e<a.length;e++){let d=a[e].start,u=a[e].end;if(-1===r&&t>=d&&t<=u&&(r=e),t+i>=d&&t<u)o=d,l=u,s=l-t;else if(t+i<d){n=d;break}}return{len:s,start:o||0,end:l||0,nextStart:n,buffered:e,bufferedIndex:r}}static getBuffered(e){try{return e.buffered||es}catch(e){return or.log("failed to get media.buffered",e),es}}},is=/\{\$([a-zA-Z0-9-_]+)\}/g;function rs(e){return is.lastIndex=0,is.test(e)}function as(e,t){if(null!==e.variableList||e.hasVariableRefs){let i=e.variableList;return t.replace(is,t=>{let r=t.substring(2,t.length-1),a=null==i?void 0:i[r];return void 0===a?(e.playlistParsingError||(e.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${r}"`)),t):a})}return t}function ns(e,t,i){let r,a,n=e.variableList;if(n||(e.variableList=n={}),"QUERYPARAM"in t){r=t.QUERYPARAM;try{let e=new self.URL(i).searchParams;if(!e.has(r))throw new Error(`"${r}" does not match any query parameter in URI: "${i}"`);a=e.get(r)}catch(t){e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${t.message}`))}}else r=t.NAME,a=t.VALUE;r in n?e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${r}"`)):n[r]=a||""}function ss(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=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${r}"`))}var os=/^(\d+)x(\d+)$/,ls=/(.+?)=(".*?"|.*?)(?:,|$)/g,ds=class e{constructor(t,i){"string"==typeof t&&(t=e.parseAttrList(t,i)),$i(this,t)}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);t=(1&t.length?"0":"")+t;let i=new Uint8Array(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=os.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(ls.lastIndex=0;null!==(i=ls.exec(e));){let a=i[1].trim(),n=i[2],s=0===n.indexOf('"')&&n.lastIndexOf('"')===n.length-1,o=!1;if(s)n=n.slice(1,-1);else switch(a){case"IV":case"SCTE35-CMD":case"SCTE35-IN":case"SCTE35-OUT":o=!0}if(t&&(s||o))n=as(t,n);else if(!o&&!s)switch(a){case"CLOSED-CAPTIONS":if("NONE"===n)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":or.warn(`${e}: attribute ${a} is missing quotes`)}r[a]=n}return r}};function us(e){return"ID"!==e&&"CLASS"!==e&&"CUE"!==e&&"START-DATE"!==e&&"DURATION"!==e&&"END-DATE"!==e&&"END-ON-NEXT"!==e}function hs(e){return"SCTE35-OUT"===e||"SCTE35-IN"===e||"SCTE35-CMD"===e}var cs=class{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){let i=t.attr;for(let t in i)if(Object.prototype.hasOwnProperty.call(e,t)&&e[t]!==i[t]){or.warn(`DATERANGE tag attribute: "${t}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=t;break}e=$i(new ds({}),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 e){let i=(null==t?void 0:t.endDate)||new Date(e["END-DATE"]);vi(i.getTime())&&(this._endDate=i)}}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?(or.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(vi(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&&vi(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)}get invalidReason(){return this.id?this._badValueForSameId?`Date range ${this._badValueForSameId} mismatch`:vi(this.startDate.getTime())?!this.isInterstitial||"X-ASSET-URI"in this.attr||"X-ASSET-LIST"in this.attr?this.isValid?null:"Unknown (check DURATION(|END|NEXT), CLASS, and CUE)":"Interstitial Date range missing X-ASSET-(LIST|URI)":"Date range invalid start date":"Missing ID"}},ms=class{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.iframesOnly=!1,this.requestScheduled=-1,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.appliedTimelineOffset=void 0,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=e}reloaded(e){if(!e)return this.advanced=!0,void(this.updated=!0);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=0: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&&vi(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 fs(e,t){return e.length===t.length&&!e.some((e,i)=>e!==t[i])}function ps(e,t){return!e&&!t||!(!e||!t)&&fs(e,t)}function gs(e){return"AES-128"===e||"AES-256"===e||"AES-256-CTR"===e}function vs(e){switch(e){case"AES-128":case"AES-256":return $n;case"AES-256-CTR":return Hn;default:throw new Error(`invalid full segment method ${e}`)}}function Es(e){return Uint8Array.from(unescape(encodeURIComponent(e)),e=>e.charCodeAt(0))}function ys(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 bs(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],a=r[1];t?(e.splice(-1,1),i=Mr(a)):i=function(e){let t=Es(e).subarray(0,16),i=new Uint8Array(16);return i.set(t,16-t.length),i}(a)}}return i}var Ts="undefined"!=typeof self?self:void 0,As={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},_s="org.w3.clearkey",Ss="com.apple.streamingkeydelivery",ks="com.microsoft.playready",Is="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function Rs(e){switch(e){case Ss:return As.FAIRPLAY;case ks:return As.PLAYREADY;case Is:return As.WIDEVINE;case _s:return As.CLEARKEY}}var Ls="edef8ba979d64acea3c827dcd51d21ed";function ws(e){switch(e){case As.FAIRPLAY:return Ss;case As.PLAYREADY:return ks;case As.WIDEVINE:return Is;case As.CLEARKEY:return _s}}function Ds(e){let{drmSystems:t,widevineLicenseUrl:i}=e,r=t?[As.FAIRPLAY,As.WIDEVINE,As.PLAYREADY,As.CLEARKEY].filter(e=>!!t[e]):[];return!r[As.WIDEVINE]&&i&&r.push(As.WIDEVINE),r}var Cs=function(e){return null!=Ts&&null!=(e=Ts.navigator)&&e.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function Ms(e){let t=Pr(new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2)),i=t.substring(t.indexOf("<"),t.length),r=(new DOMParser).parseFromString(i,"text/xml").getElementsByTagName("KID")[0];if(r){let e=r.childNodes[0]?r.childNodes[0].nodeValue:r.getAttribute("VALUE");if(e){let t=Mr(e).subarray(0,16);return ys(t),t}}return null}var Ps={},xs=class e{static clearKeyUriToKeyIdMap(){Ps={}}static setKeyIdForUri(e,t){Ps[e]=t}static addKeyIdForUri(e){let t=Object.keys(Ps).length%Number.MAX_SAFE_INTEGER,i=new Uint8Array(16);return new DataView(i.buffer,12,4).setUint32(0,t),Ps[e]=i,i}constructor(e,t,i,r=[1],a=null,n){this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.scheme=void 0,this.method=e,this.uri=t,this.keyFormat=i,this.keyFormatVersions=r,this.iv=a,this.encrypted=!!e&&"NONE"!==e,this.isCommonEncryption=this.encrypted&&!gs(e),null!=n&&n.startsWith("0x")&&(this.keyId=new Uint8Array(Cr(n)))}matches(e){return e.uri===this.uri&&e.method===this.method&&e.encrypted===this.encrypted&&e.keyFormat===this.keyFormat&&fs(e.keyFormatVersions,this.keyFormatVersions)&&ps(e.iv,this.iv)&&ps(e.keyId,this.keyId)}isSupported(){if(this.method){if(gs(this.method)||"NONE"===this.method)return!0;if("identity"===this.keyFormat)return"SAMPLE-AES"===this.method;switch(this.keyFormat){case Ss:case Is:case ks:case _s:return-1!==["SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)}}return!1}getDecryptData(t,i){var r;if(!this.encrypted||!this.uri)return null;if(gs(this.method)){let i=this.iv;return i||("number"!=typeof t&&(or.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),t=0),i=function(e){let t=new Uint8Array(16);for(let i=12;i<16;i++)t[i]=e>>8*(15-i)&255;return t}(t)),new e(this.method,this.uri,"identity",this.keyFormatVersions,i)}if(this.keyId){let t=Ps[this.uri];if(t&&!fs(this.keyId,t)&&e.setKeyIdForUri(this.uri,this.keyId),this.pssh)return this}let a=bs(this.uri);if(a)switch(this.keyFormat){case Is:if(this.pssh=a,!this.keyId){let e=ca(a.buffer).filter(e=>e.systemId===Ls);if(e.length){var n;let t=e[0];this.keyId=null!=(n=t.kids)&&n.length?t.kids[0]:null}}this.keyId||(this.keyId=Os(i));break;case ks:{let e=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=ha(e,0,a),this.keyId=Ms(a);break}default:{let e=a.subarray(0,16);if(16!==e.length){let t=new Uint8Array(16);t.set(e,16-e.length),e=t}this.keyId=e;break}}if(16!==(null==(r=this.keyId)?void 0:r.byteLength)){let t;t=function(e){let t=null==e?void 0:e[Is];return t?t.keyId:null}(i),t||(t=Os(i),t||(t=Ps[this.uri])),t&&(this.keyId=t,e.setKeyIdForUri(this.uri,t))}return this}};function Os(e){let t=null==e?void 0:e[ks];if(t){let e=bs(t.uri);if(e)return Ms(e)}return null}var Ns=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(I-FRAME-STREAM-INF|SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)(?:[\r\n]+|$)/g,Us=/#EXT-X-MEDIA:(.*)/g,Fs=/^#EXT(?:INF|-X-TARGETDURATION):/m,Bs=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#.*/.source].join("|"),"g"),$s=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|I-FRAMES-ONLY)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),Hs=class e{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 ki.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return Fs.test(e)}static parseMasterPlaylist(t,i){let r,a={contentSteering:null,levels:[],iframeVariants:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:rs(t)},n=[];if(Ns.lastIndex=0,!t.startsWith("#EXTM3U"))return a.playlistParsingError=new Error("no EXTM3U delimiter"),a;for(;null!=(r=Ns.exec(t));)if(r[1]){let e=Gs(new ds(r[1],a),r[2],i,a,n);e&&a.levels.push(e)}else if(r[3]){let t=r[3],s=r[4];switch(t){case"I-FRAME-STREAM-INF":{let e=new ds(s,a),t=Gs(e,e.URI,i,a,n,!0);t&&a.iframeVariants.push(t)}break;case"SESSION-DATA":{let e=new ds(s,a),t=e["DATA-ID"];t&&(null===a.sessionData&&(a.sessionData={}),a.sessionData[t]=e);break}case"SESSION-KEY":{let e=Vs(s,i,a);e.encrypted&&e.isSupported()?(null===a.sessionKeys&&(a.sessionKeys=[]),a.sessionKeys.push(e)):or.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${s}"`);break}case"DEFINE":ns(a,new ds(s,a),i);break;case"CONTENT-STEERING":{let t=new ds(s,a);a.contentSteering={uri:e.resolve(t["SERVER-URI"],i),pathwayId:t["PATHWAY-ID"]||"."};break}case"START":a.startTimeOffset=qs(s)}}let s=n.length>0&&n.length<a.levels.length;return a.levels=s?n:a.levels,0===a.levels.length&&(a.playlistParsingError=new Error("no levels found in manifest")),a}static parseMasterPlaylistMedia(t,i,r){let a,n={},s=r.levels,o={AUDIO:s.map(e=>({id:e.attrs.AUDIO,audioCodec:e.audioCodec})),SUBTITLES:s.map(e=>({id:e.attrs.SUBTITLES,textCodec:e.textCodec})),"CLOSED-CAPTIONS":[]},l=0;for(Us.lastIndex=0;null!==(a=Us.exec(t));){let t=new ds(a[1],r),s=t.TYPE;if(s){let r=o[s],a=n[s]||[];n[s]=a;let d=t.LANGUAGE,u=t["ASSOC-LANGUAGE"],h=t.CHANNELS,c=t.CHARACTERISTICS,m=t["INSTREAM-ID"],f={attrs:t,bitrate:0,id:l++,groupId:t["GROUP-ID"]||"",name:t.NAME||d||"",type:s,default:t.bool("DEFAULT"),autoselect:t.bool("AUTOSELECT"),forced:t.bool("FORCED"),lang:d,url:t.URI?e.resolve(t.URI,i):""};if(u&&(f.assocLang=u),h&&(f.channels=h),c&&(f.characteristics=c),m&&(f.instreamId=m),null!=r&&r.length){let t=e.findGroup(r,f.groupId)||r[0];js(f,t,"audioCodec"),js(f,t,"textCodec")}a.push(f)}}return n}static parseLevelPlaylist(e,t,i,r,a,n){var s;let o,l,d,u,h={url:t},c=new ms(t),m=c.fragments,f=[],p=null,g=0,v=0,E=0,y=0,b=0,T=null,A=new Ni(r,h),_=-1,S=!1,k=null;if(Bs.lastIndex=0,c.m3u8=e,c.hasVariableRefs=rs(e),"#EXTM3U"!==(null==(s=Bs.exec(e))?void 0:s[0]))return c.playlistParsingError=new Error("Missing format identifier #EXTM3U"),c;for(;null!==(o=Bs.exec(e));){S&&(S=!1,A=new Ni(r,h),A.playlistOffset=E,A.setStart(E),A.sn=g,A.cc=y,b&&(A.bitrate=b),A.level=i,p&&(A.initSegment=p,p.rawProgramDateTime&&(A.rawProgramDateTime=p.rawProgramDateTime,p.rawProgramDateTime=null),k&&(A.setByteRange(k),k=null)));let e=o[1];if(e){A.duration=parseFloat(e);let t=(" "+o[2]).slice(1);A.title=t||null,A.tagList.push(t?["INF",e,t]:["INF",e])}else if(o[3]){if(vi(A.duration)){var I;A.playlistOffset=E,A.setStart(E),d&&Xs(A,d,c),A.sn=g,A.level=i,A.cc=y;let e=(" "+o[3]).slice(1);A.relurl=as(c,e),zs(A,T,f),T=A,E+=A.duration,g++,v=0;let t=A.byteRange;if(2===t.length&&(A.bitrate=8*(t[1]-t[0])/A.duration|0),c.iframesOnly&&t[0]&&(null==(I=p)?void 0:I.cc)!==y){let e=new Ni(r,h);e.relurl=A.relurl,e.setByteRange(`${Math.min(t[0],1316)}@0`),e.level=i,e.sn="initSegment",d&&(e.levelkeys=d,d.identity&&(e._decryptdata=d.identity.getDecryptData(0))),p=e,A.initSegment=p}m.push(A),S=!0}}else{if(o=o[0].match($s),!o){or.warn("No matches on slow regex match for level playlist!");continue}for(l=1;l<o.length&&void 0===o[l];l++);let e=(" "+o[l]).slice(1),a=(" "+o[l+1]).slice(1),s=o[l+2]?(" "+o[l+2]).slice(1):null;switch(e){case"BYTERANGE":T?A.setByteRange(a,T):A.setByteRange(a);break;case"PROGRAM-DATE-TIME":A.rawProgramDateTime=a,A.tagList.push(["PROGRAM-DATE-TIME",a]),-1===_&&(_=m.length);break;case"PLAYLIST-TYPE":c.type&&Zs(c,e,o),c.type=a.toUpperCase();break;case"MEDIA-SEQUENCE":0!==c.startSN?Zs(c,e,o):null!==T&&Js(c,e,o),c.startSN=parseInt(a),g=c.startSN+c.skippedSegments;break;case"SKIP":{c.skippedSegments&&Zs(c,e,o);let t=new ds(a,c),i=t.decimalInteger("SKIPPED-SEGMENTS");if(vi(i)){c.skippedSegments+=i;for(let e=i;e--;)m.push(null);g+=i}let r=t.enumeratedString("RECENTLY-REMOVED-DATERANGES");r&&(c.recentlyRemovedDateranges=(c.recentlyRemovedDateranges||[]).concat(r.split("\t")));break}case"TARGETDURATION":0!==c.targetduration&&Zs(c,e,o),c.targetduration=Math.max(parseInt(a),1);break;case"VERSION":null!==c.version&&Zs(c,e,o),c.version=parseInt(a);break;case"INDEPENDENT-SEGMENTS":break;case"I-FRAMES-ONLY":c.iframesOnly=!0;break;case"ENDLIST":c.live||Zs(c,e,o),c.live=!1;break;case"#":(a||s)&&A.tagList.push(s?[a,s]:[a]);break;case"DISCONTINUITY":y++,A.tagList.push(["DIS"]);break;case"GAP":A.gap=!0,A.tagList.push([e]);break;case"BITRATE":A.tagList.push([e,a]),b=1e3*parseInt(a),vi(b)?A.bitrate=b:b=0;break;case"DATERANGE":{let e=new ds(a,c),t=new cs(e,c.dateRanges[e.ID],c.dateRangeTagCount);c.dateRangeTagCount++,t.isValid||c.skippedSegments?c.dateRanges[t.id]=t:or.log(`Ignoring invalid DATERANGE tag: ${t.invalidReason}: ${a}`),A.tagList.push(["EXT-X-DATERANGE",a]);break}case"DEFINE":{let e=new ds(a,c);"IMPORT"in e?ss(c,e,n):ns(c,e,t)}break;case"DISCONTINUITY-SEQUENCE":0!==c.startCC&&Zs(c,e,o),c.startCC=y=parseInt(a),m.forEach(e=>e&&(e.cc=y));break;case"KEY":{let e=Vs(a,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=$i({},d)),d[e.keyFormat]=e)}else or.warn(`[Keys] Ignoring unsupported EXT-X-KEY tag: "${a}"`);break}case"START":c.startTimeOffset=qs(a);break;case"MAP":{let e=new ds(a,c);if(A.duration){let t=new Ni(r,h);Qs(t,e,i,d),p=t,A.initSegment=p,p.rawProgramDateTime&&!A.rawProgramDateTime&&(A.rawProgramDateTime=p.rawProgramDateTime)}else{let t=A.byteRangeEndOffset;if(t){let e=A.byteRangeStartOffset;k=`${t-e}@${e}`}else k=null;Qs(A,e,i,d),p=A,S=!0}p.cc=y;break}case"SERVER-CONTROL":u&&Zs(c,e,o),u=new ds(a),c.canBlockReload=u.bool("CAN-BLOCK-RELOAD"),c.canSkipUntil=u.optionalFloat("CAN-SKIP-UNTIL",0),c.canSkipDateRanges=c.canSkipUntil>0&&u.bool("CAN-SKIP-DATERANGES"),c.partHoldBack=u.optionalFloat("PART-HOLD-BACK",0),c.holdBack=u.optionalFloat("HOLD-BACK",0);break;case"PART-INF":{c.partTarget&&Zs(c,e,o);let t=new ds(a);c.partTarget=t.decimalFloatingPoint("PART-TARGET");break}case"PART":{let e=c.partList;e||(e=c.partList=[]);let t=v>0?e[e.length-1]:void 0,i=v++,r=new ds(a,c),n=new Ui(r,A,h,i,t);e.push(n),A.duration+=n.duration;break}case"PRELOAD-HINT":{let e=new ds(a,c);c.preloadHint=e;break}case"RENDITION-REPORT":{let e=new ds(a,c);c.renditionReports=c.renditionReports||[],c.renditionReports.push(e);break}default:or.warn(`line parsed but not handled: ${o}`)}}}T&&!T.relurl?(m.pop(),E-=T.duration,c.partList&&(c.fragmentHint=T)):c.partList&&(zs(A,T,f),A.cc=y,c.fragmentHint=A,d&&Xs(A,d,c)),c.targetduration||(c.playlistParsingError=new Error("Missing Target Duration"));let R=m.length,L=m[0],w=m[R-1];if(E+=c.skippedSegments*c.targetduration,E>0&&R&&w){c.averagetargetduration=E/R;let e=w.sn;c.endSN="initSegment"!==e?e:0,c.live||(w.endList=!0),_>0&&(function(e,t,i){if(i||(i=e[t]),i)for(let r=t;r--;){let t=e[r];if(!t)return;t.programDateTime=i.programDateTime-1e3*t.duration,i=t}}(m,_,_>R-1?A:null),L&&f.unshift(L))}return c.fragmentHint&&(E+=c.fragmentHint.duration),c.totalduration=E,f.length&&c.dateRangeTagCount&&L&&Ks(f,c),c.endCC=y,c}};function Gs(e,t,i,r,a,n){var s;if(void 0===t)return null;let o=as(r,t),l={attrs:e,bitrate:e.decimalInteger("BANDWIDTH")||e.decimalInteger("AVERAGE-BANDWIDTH"),name:e.NAME,url:Hs.resolve(o,i)},d=e.decimalResolution("RESOLUTION");d&&(l.width=d.width,l.height=d.height),Ys(e.CODECS,l);let u=e["SUPPLEMENTAL-CODECS"];return u&&(l.supplemental={},Ys(u,l.supplemental)),null!=(s=l.unknownCodecs)&&s.length||a.push(l),n&&(l.iframes=!0),l}function Ks(e,t){let i=e.length;if(!i){if(!t.hasProgramDateTime)return;{let r=t.fragments[t.fragments.length-1];e.push(r),i++}}let r=e[i-1],a=t.live?1/0:t.totalduration,n=Object.keys(t.dateRanges);for(let o=n.length;o--;){let l=t.dateRanges[n[o]],d=l.startDate.getTime();l.tagAnchor=r.ref;for(let r=i;r--;){var s;if((null==(s=e[r])?void 0:s.sn)<t.startSN)break;let i=Ws(t,d,e,r,a);if(i){l.tagAnchor=i.ref;break}}}}function Ws(e,t,i,r,a){let n=i[r];if(n){let o=n.programDateTime;if(t>=o||0===r){var s;if(t<=o+1e3*(((null==(s=i[r+1])?void 0:s.start)||a)-n.start)){let a=n.sn-e.startSN,s=e.fragments;if(a>=0&&a<s.length){if(s.length>i.length){let n=i[r+1]||s[s.length-1];for(let i=Math.min(n.sn-e.startSN,s.length-1);i>a;i--){let e=s[i].programDateTime;if(t>=e&&t<e+1e3*s[i].duration)return s[i]}}return s[a]}}}}return null}function Vs(e,t,i){var r,a;let n=new ds(e,i),s=null!=(r=n.METHOD)?r:"",o=n.URI,l=n.hexadecimalInteger("IV"),d=n.KEYFORMATVERSIONS,u=null!=(a=n.KEYFORMAT)?a:"identity";o&&n.IV&&!l&&or.error(`Invalid IV: ${n.IV}`);let h=o?Hs.resolve(o,t):"",c=(d||"1").split("/").map(Number).filter(Number.isFinite);return new xs(s,h,u,c,l,n.KEYID)}function qs(e){let t=new ds(e).decimalFloatingPoint("TIME-OFFSET");return vi(t)?t:null}function Ys(e,t){let i=(e||"").split(/[ ,]+/).filter(e=>e);["video","audio","text","image"].forEach(e=>{let r=i.filter(t=>_a(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 js(e,t,i){let r=t[i];r&&(e[i]=r)}function zs(e,t,i){e.rawProgramDateTime?i.push(e):null!=t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime)}function Qs(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 Xs(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 Zs(e,t,i){e.playlistParsingError=new Error(`#EXT-X-${t} must not appear more than once (${i[0]})`)}function Js(e,t,i){e.playlistParsingError=new Error(`#EXT-X-${t} must appear before the first Media Segment (${i[0]})`)}function eo(e,t){let i=t.startPTS;if(vi(i)){let r,a=0;t.sn>e.sn?(a=i-e.start,r=e):(a=e.start-i,r=t),r.duration!==a&&r.setDuration(a)}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 to(e,t,i,r,a,n,s,o){r-i<=0&&(o.warn("Fragment should have a positive duration",t),r=i+t.duration,n=a+t.duration);let l=i,d=r,u=t.startPTS,h=t.endPTS;if(vi(u)){let s=Math.abs(u-i);e&&s>e.totalduration?o.warn(`media timestamps and playlist times differ by ${s}s for level ${t.level} ${e.url}`):vi(t.deltaPTS)?t.deltaPTS=Math.max(s,t.deltaPTS):t.deltaPTS=s,l=Math.max(i,u),i=Math.min(i,u),a=void 0!==t.startDTS?Math.min(a,t.startDTS):a,d=Math.min(r,h),r=Math.max(r,h),n=void 0!==t.endDTS?Math.max(n,t.endDTS):n}let c=i-t.start;0!==t.start&&t.setStart(i),t.setDuration(r-t.start),t.startPTS=i,t.maxStartPTS=l,t.startDTS=a,t.endPTS=r,t.minEndPTS=d,t.endDTS=n;let m=t.sn;if(!e||m<e.startSN||m>e.endSN)return 0;let f,p=m-e.startSN,g=e.fragments;for(g[p]=t,f=p;f>0;f--)eo(g[f],g[f-1]);for(f=p;f<g.length-1;f++)eo(g[f],g[f+1]);return e.fragmentHint&&eo(g[g.length-1],e.fragmentHint),e.PTSKnown=e.alignedSliding=!0,c}function io(e,t,i){if(e===t)return;let r,a=null,n=e.fragments;for(let e=n.length-1;e>=0;e--){let t=n[e].initSegment;if(t){a=t;break}}e.fragmentHint&&delete e.fragmentHint.endPTS,function(e,t,i){var r;let a=t.skippedSegments,n=Math.max(e.startSN,t.startSN)-t.startSN,s=(e.fragmentHint?1:0)+(a?t.endSN:Math.min(e.endSN,t.endSN))-t.startSN,o=t.startSN-e.startSN,l=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,d=null!=(r=e.fragmentHint)&&r.duration?e.fragments.concat(e.fragmentHint):e.fragments;for(let r=n;r<=s;r++){let n=d[o+r],s=l[r];if(a&&!s&&n&&(s=t.fragments[r]=n),n&&s){i(n,s,r,l);let a=n.relurl,o=s.relurl;if(a&&ho(a,o))return void(t.playlistParsingError=ro(`media sequence mismatch ${s.sn}:`,e,t,n,s));if(n.cc!==s.cc)return void(t.playlistParsingError=ro(`discontinuity sequence mismatch (${n.cc}!=${s.cc})`,e,t,n,s))}}}(e,t,(e,i,n,s)=>{if((!t.startCC||t.skippedSegments)&&i.cc!==e.cc){let r=e.cc-i.cc;for(let e=n;e<s.length;e++)s[e].cc+=r;t.endCC=s[s.length-1].cc}vi(e.startPTS)&&vi(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.hasStreams&&(i.elementaryStreams=e.elementaryStreams),i.loader=e.loader,e.hasStats&&(i.stats=e.stats),e.initSegment&&(i.initSegment=e.initSegment,a=e.initSegment)});let s=t.fragments,o=t.fragmentHint?s.concat(t.fragmentHint):s;if(a&&o.forEach(e=>{var t;e&&(!e.initSegment||e.initSegment.relurl===(null==(t=a)?void 0:t.relurl))&&(e.initSegment=a)}),t.skippedSegments){if(t.deltaUpdateFailed=s.some(e=>!e),t.deltaUpdateFailed){i.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let e=t.skippedSegments;e--;)s.shift();t.startSN=s[0].sn}else{t.canSkipDateRanges&&(t.dateRanges=function(e,t,i){let{dateRanges:r,recentlyRemovedDateranges:a}=t,n=$i({},e);a&&a.forEach(e=>{delete n[e]});let s=Object.keys(n).length;return s?(Object.keys(r).forEach(e=>{let t=n[e],a=new cs(r[e].attr,t);a.isValid?(n[e]=a,t||(a.tagOrder+=s)):i.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${tn(r[e].attr)}"`)}),n):r}(e.dateRanges,t,i));let r=e.fragments.filter(e=>e.rawProgramDateTime);if(e.hasProgramDateTime&&!t.hasProgramDateTime)for(let e=1;e<o.length;e++)null===o[e].programDateTime&&zs(o[e],o[e-1],r);Ks(r,t)}t.endCC=s[s.length-1].cc}if(!t.startCC){var l;let i=so(e,t.startSN-1);t.startCC=null!=(l=null==i?void 0:i.cc)?l:s[0].cc}if(function(e,t,i){if(e&&t){let r=0;for(let a=0,n=e.length;a<n;a++){let n=e[a],s=t[a+r];n&&s&&n.index===s.index&&n.fragment.sn===s.fragment.sn?i(n,s):r--}}}(e.partList,t.partList,(e,t)=>{t.elementaryStreams=e.elementaryStreams,t.stats=e.stats,t.gap=e.gap||t.gap}),r){t.iframesOnly&&(r.type,Li.MAIN);to(t,r,r.startPTS,r.endPTS,r.startDTS,r.endDTS,0,i)}else ao(e,t);s.length&&(t.totalduration=t.edge-s[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)}function ro(e,t,i,r,a){return new Error(`${e} ${a.url}\nPlaylist starting @${t.startSN}\n${t.m3u8}\n\nPlaylist starting @${i.startSN}\n${i.m3u8}`)}function ao(e,t,i=!0,r){let a=t.startSN+t.skippedSegments-e.startSN,n=e.fragments,s=a>=0,o=0;if(s&&a<n.length)o=n[a].start,null==r||r.log(`Aligning playlists based on SN ${t.startSN} (diff: ${o})`);else if(s&&t.startSN===e.endSN+1)o=e.fragmentEnd,null==r||r.log(`Aligning playlists based on first/last SN ${t.startSN} (diff: ${o})`);else if(s&&i)o=e.fragmentStart+a*t.levelTargetDuration;else{if(t.skippedSegments||0!==t.fragmentStart)return o;o=e.fragmentStart,null==r||r.log(`Aligning playlists based on first SN ${t.startSN} (diff: ${o})`)}return function(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)}}(t,o),o}function no(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>0&&e<i&&(i=e)}}else i/=2;return Math.round(i)}function so(e,t,i){var r;if(!e)return null;let a=e.fragments[t-e.startSN];return a||(a=e.fragmentHint,(null==(r=a)?void 0:r.sn)===t)?a:i&&t<e.startSN&&i.sn===t?i:null}function oo(e,t,i){return e?lo(e.partList,t,i):null}function lo(e,t,i){if(e)for(let r=e.length;r--;){let a=e[r];if(a.index===i&&a.fragment.sn===t)return a}return null}function uo(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 ho(e,t){return!(e===t||!t)&&co(e)!==co(t)}function co(e){return e.replace(/\?[^?]*$/,"")}function mo(e,t){for(let r=0,a=e.length;r<a;r++){var i;if((null==(i=e[r])?void 0:i.cc)===t)return e[r]}return null}function fo(e,t){let i=e.start+t;e.setStart(i)}function po(e,t){let i=t.fragments;for(let t=0,r=i.length;t<r;t++)fo(i[t],e);t.fragmentHint&&fo(t.fragmentHint,e),t.alignedSliding=!0}function go(e,t,i){e&&(function(e,t,i){if(!function(e,t){return!!(e&&t.startCC<e.endCC&&t.endCC>e.startCC)}(t,e))return;let r=Math.min(t.endCC,e.endCC),a=mo(t.fragments,r),n=mo(e.fragments,r);if(!a||!n)return;let s=a.start-n.start;i.log(`Aligning playlists using dicontinuity sequence ${r} (diff: ${s})`),po(s,e)}(t,e,i),t.alignedSliding||function(e,t,i){if(!e.hasProgramDateTime||!t.hasProgramDateTime)return;let r=e.fragments,a=t.fragments;if(!r.length||!a.length)return;let n,s,o=Math.min(t.endCC,e.endCC);t.startCC<o&&e.startCC<o&&(n=mo(a,o),s=mo(r,o)),(!n||!s)&&(n=a[Math.floor(a.length/2)]||a.filter(e=>!!e)[0],s=mo(r,n.cc)||r[Math.floor(r.length/2)]);let l=n.programDateTime,d=s.programDateTime;if(!l||!d)return;let u=(d-l)/1e3;if(Math.abs(u)>Math.max(60,e.totalduration))return void i.log(`Cannot align playlists using PDT without overlap (${Math.abs(u)} > ${e.totalduration})`);let h=u-(s.start-n.start);i.log(`Aligning playlists using PDT (diff: ${h})`),po(h,e)}(t,e,i),!t.alignedSliding&&!t.skippedSegments&&ao(e,t,!1,i))}function vo(e,t,i){Eo(e,t,i),e.addEventListener(t,i)}function Eo(e,t,i){e.removeEventListener(t,i)}function yo(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}var bo="STOPPED",To="IDLE",Ao="KEY_LOADING",_o="FRAG_LOADING",So="FRAG_LOADING_WAITING_RETRY",ko="WAITING_TRACK",Io="PARSING",Ro="PARSED",Lo="ENDED",wo="ERROR",Do="WAITING_INIT_PTS",Co="WAITING_LEVEL",Mo=class extends Zn{constructor(e,t,i,r,a){super(r,e.logger),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragPlaying=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=bo,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=-1,this.startTimeOffset=null,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.initFragmentLoader=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:a}=this,n=i?i.currentTime:0,s=ts.bufferInfo(r||i,n,e.maxBufferHole),o=s.len;if(this.log(`Media seeking to ${n}, state: ${a}, ${o?"in":"out of"} buffer`),this.state===Lo)this.resetLoadingState();else if(t){let i=e.maxFragLookUpTolerance,r=t.start-i,a=t.start+t.duration+i;if(!o||a<s.start||r>s.end){let e=n<r,i=n>a;(e||i)&&(!t.loader||!i&&this.isFragmentNearlyDownloaded(t)?this.fragPrevious=null:(this.log(`Cancelling fragment load for seek (sn: ${t.sn}) - ${e?"backward":"forward"} seek`),t.abortRequests(),this.resetLoadingState()))}}if(i){if(this.fragmentTracker.removeFragmentsInRange(n,1/0,this.playlistType,!0),n>this.lastCurrentTime&&(this.lastCurrentTime=n),!this.loadingParts){let e=Math.max(s.end,n),t=this.shouldLoadParts(this.getLevelDetails(),e);t&&(this.log(`LL-Part loading ON after seeking to ${n} with buffer @${e}`),this.loadingParts=t)}}let l=!ts.isBuffered(i,n);(!this.hls.hasEnoughToStart||l)&&(this.log(`Setting ${l?"startPosition":"nextLoadPosition"} to ${n} for seek without enough to start`),this.nextLoadPosition=n,l&&(this.startPosition=n)),o<1&&this.state===To&&this.tickImmediate()},this.onMediaEnded=()=>{this.log("setting startPosition to 0 because media ended"),this.startPosition=this.lastCurrentTime=0},this.playlistType=a,this.hls=e,this.fragmentLoader=new Yn(e.config),this.initFragmentLoader=new Yn(e.config),this.keyLoader=i,this.fragmentTracker=t,this.config=e.config,this.decrypter=new Vn(e.config)}registerListeners(){let{hls:e}=this;e.on(Ai.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Ai.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Ai.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Ai.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(Ai.ERROR,this.onError,this)}unregisterListeners(){let{hls:e}=this;e.off(Ai.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Ai.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Ai.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Ai.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(Ai.ERROR,this.onError,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){if(this.state===bo)return;this.fragmentLoader.abort(),this.initFragmentLoader.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=bo}get startPositionValue(){let{nextLoadPosition:e,startPosition:t}=this;if(-1===t&&e){let t=this.getLevelDetails();return null!=t&&t.live?(this.hls.liveSyncPosition||t.fragmentStart)+this.timelineOffset:e}return t}get bufferingEnabled(){return this.buffering}get backtrackFragment(){}set backtrackFragment(e){}get couldBacktrack(){return!1}set couldBacktrack(e){}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 a=e.buffered;this.config.maxBufferHole&&a&&a.length>1&&(e=ts.bufferedInfo(a,e.start,0));let n=e.nextStart;if(n&&n>r&&n<t.edge||this.media.currentTime<e.start)return!1;let s=t.partList;if(null!=s&&s.length){let e=s[s.length-1];return ts.isBuffered(this.media,e.start+e.duration/2)}let o=t.fragments[t.fragments.length-1];return this.fragmentTracker.isEndListAppended(o.type)}getLevelDetails(){if(this.levels&&null!==this.levelLastLoaded)return this.levelLastLoaded.details}get timelineOffset(){let e=this.config.timelineOffset;var t;return e?(null==(t=this.getLevelDetails())?void 0:t.appliedTimelineOffset)||e:0}onMediaAttached(e,t){let i=this.media=this.mediaBuffer=t.media;vo(i,"seeking",this.onMediaSeeking),vo(i,"ended",this.onMediaEnded);let r=this.config;this.levels&&r.autoStartLoad&&this.state===bo&&this.startLoad(r.startPosition)}onMediaDetaching(e,t){this.fragPlaying=null;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),Eo(r,"seeking",this.onMediaSeeking),Eo(r,"ended",this.onMediaEnded),this.media=this.mediaBuffer=null,this.loopSn=void 0,i)return this.resetLoadingState(),void this.resetTransmuxer();this.loadingParts=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}}onManifestLoading(){this.initPTS=[],this.fragPlaying=this.levels=this.levelLastLoaded=this.fragCurrent=null,this.lastCurrentTime=0,this.startPosition=-1,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=bo,this.fragmentLoader&&this.fragmentLoader.destroy(),this.initFragmentLoader&&this.initFragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.decrypter=this.keyLoader=null,this.fragmentLoader=this.initFragmentLoader=this.fragmentTracker=null,super.onHandlerDestroyed()}loadFragment(e,t,i){this.startFragRequested=!0,this._loadFragForPlayback(e,t,i)}_loadFragForPlayback(e,t,i){this._doFragLoad(e,t,i,e=>{let t=e.frag;if(this.fragContextChanged(t))return this.warn(`${t.type} sn: ${t.sn}${e.part?" part: "+e.part.index:""} of ${this.fragInfo(t,!1,e.part)} was dropped during download.`),void this.fragmentTracker.removeFragment(t);let i=++t.stats.chunkCount;this.log(`load progress ${t.type} sn: ${t.sn}${e.part?" part: "+e.part.index:""} of ${this.fragInfo(t,!1,e.part)} chunk: ${i}`),this._handleFragmentLoadProgress(e)}).then(e=>{if(!e)return;let t=this.state,i=e.frag;this.fragContextChanged(i)?(t===_o||!this.fragCurrent&&t===Io)&&(this.fragmentTracker.removeFragment(i),this.state=To):("payload"in e&&(this.log(`Loaded ${i.type} sn: ${i.sn} of ${this.playlistLabel()} ${i.level} (bytes ${i.stats.loaded})`),this.hls.trigger(Ai.FRAG_LOADED,e)),this._handleFragmentLoadComplete(e))}).catch(t=>{this.state===bo||this.state===wo||(this.log(`Frag error ${e.type} sn:${e.sn} cc:${e.cc}: ${(null==t?void 0:t.message)||t}`),this.resetFragmentLoading(e))})}clearTrackerIfNeeded(e){var t;let{fragmentTracker:i}=this;if(i.getState(e)===Pn){let t=e.type,r=this.getFwdBufferInfo(this.mediaBuffer,t),a=Math.max(e.duration,r?r.len:this.config.maxBufferLength),n=this.backtrackFragment;(1===(n?e.sn-n.sn:0)||this.reduceMaxBufferLength(a,e.duration))&&i.removeFragment(e)}else 0===(null==(t=this.mediaBuffer)?void 0:t.buffered.length)?i.removeAllFragments():i.hasParts(e.type)&&(i.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),i.getState(e)===xn&&i.removeFragment(e))}checkLiveUpdate(e){if(e.updated&&!e.live){let t=this.fragmentTracker,i=e.fragments[e.fragments.length-1];if(i.endList&&!t.isEndListAppended(this.playlistType)){let e=t.getPartialFragment(i.end);e&&(t.removeFragment(e),t.fragBuffered(i,!0))}t.detectPartialFragments({frag:i,part:null,stats:i.stats,id:i.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){if(!(e-t))return;let r={startOffset:e,endOffset:t,type:i};this.hls.trigger(Ai.BUFFER_FLUSHING,r)}_loadInitSegment(e){let{hls:t}=this;return this.initFragmentLoader.abort(),t.trigger(Ai.FRAG_LOADING,{frag:e,targetBufferTime:0}),this.initFragmentLoader.load(e).then(e=>{var t;let i=e.frag;if(!this.levels||!Oi(i,null==(t=this.fragCurrent)?void 0:t.initSegment))throw new Xn({type:bi.NETWORK_ERROR,details:Ti.INTERNAL_ABORTED,error:new Error("init load aborted"),fatal:!1,frag:i,networkDetails:null});return e}).then(e=>{let{frag:i,payload:r}=e,a=i.decryptdata;if(r&&r.byteLength>0&&null!=a&&a.key&&a.iv&&gs(a.method)){let n=self.performance.now(),{decryptRange:s}=zn(i,null,this.iframesOnly);return this.decrypter.decrypt(new Uint8Array(r),a.key.buffer,a.iv.buffer,vs(a.method),s).catch(e=>{throw t.trigger(Ai.ERROR,{type:bi.MEDIA_ERROR,details:Ti.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:i}),this.fragmentLoader.abort(),e}).then(r=>{let a=self.performance.now();return t.trigger(Ai.FRAG_DECRYPTED,{frag:i,part:null,payload:r,stats:{tstart:n,tdecrypt:a}}),e.payload=r,this.completeInitSegmentLoad(e)})}return this.completeInitSegmentLoad(e)})}completeInitSegmentLoad(e){let t=e.frag.stats;e.frag.data=new Uint8Array(e.payload),t.parsing.start=t.buffering.start=self.performance.now(),t.parsing.end=t.buffering.end=self.performance.now()}loadInitSegmentIfNeeded(e){let{initSegment:t}=e;var i;if(!this.bitrateTest&&Pi(e)&&t&&!t.data)return(!t.encrypted||null!=(i=t.decryptdata)&&i.key?this._loadInitSegment(t):this.keyLoader.load(t).then(()=>this._loadInitSegment(t))).catch(t=>{throw this.state===bo||this.state===wo||("data"in t&&(t.data.frag=e,this.fragmentLoader.abort(),this.handleFragLoadError(t)),this.resetFragmentLoading(e)),t})}unhandledEncryptionError(e,t){var i,r;let a=e.tracks;if(a&&!t.encrypted&&(null!=(i=a.audio)&&i.encrypted||null!=(r=a.video)&&r.encrypted)&&(!this.config.emeEnabled||!this.keyLoader.emeController)){let e=this.media,i=new 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(Ai.ERROR,{type:bi.KEY_SYSTEM_ERROR,details:Ti.KEY_SYSTEM_NO_KEYS,fatal:!1,error:i,frag:t}),this.resetTransmuxer(),!0)}return!1}fragContextChanged(e){let{fragCurrent:t}=this;return!e||!Oi(e,t)}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?yo(ts.getBuffered(i)):"(detached)"})`),Pi(e)){var r;if(e.type!==Li.SUBTITLE){let t=e.elementaryStreams;if(!Object.keys(t).some(e=>!!t[e]))return void(this.state=To)}let i=null==(r=this.levels)?void 0:r[e.level];null!=i&&i.fragmentError&&(t||this.fragmentTracker.getState(e)!==xn)&&(this.log(`Resetting level fragment error count of ${i.fragmentError} on frag buffered`),i.fragmentError=0,e.stats.retry=0)}this.state=To}_handleFragmentLoadComplete(e){let{transmuxer:t}=this;if(!t)return;let i=e.frag,{part:r,partsLoaded:a}=e,n=!a||0===a.length||a.some(e=>!e),{decryptRange:s}=zn(i,r),o=new Jn(i.level,i.sn,i.stats.chunkCount+1,0,r?r.index:-1,!n,i.duration,this.iframesOnly,s);this.log(`load complete ${i.type} sn: ${i.sn}${r?" part: "+r.index:""} of ${this.fragInfo(i,!1,r)}`),t.flush(o)}_handleFragmentLoadProgress(e){}loadKeyFor(e,t,i){var r;let a=null;return!e.encrypted||null!=(r=e.decryptdata)&&r.key?e.encrypted||(a=this.keyLoader.loadClear(e,t.encryptedFragments,this.startFragRequested),a&&this.log(`[eme] blocking frag sn: ${e.sn} load until media-keys acquired`)):(this.log(`Loading key for ${e.sn} of [${t.startSN}-${t.endSN}], ${this.playlistLabel()} ${e.level}`),this.state=Ao,a=this.keyLoader.load(e,i).then(e=>{if(!this.fragContextChanged(e.frag))return this.hls.trigger(Ai.KEY_LOADED,e),this.state===Ao&&(this.state=To),e}),this.hls.trigger(Ai.KEY_LOADING,{frag:e})),a}_doFragLoad(e,t,i=null,r){this.fragCurrent=e;let a=t.details;if(!this.levels||!a)throw new Error(`frag load aborted, missing level${a?"":" detail"}s`);let n=this.fragPrevious;if(!xi(e,n)){let i=this.shouldLoadParts(t.details,e.end);i!==this.loadingParts&&(this.log(`LL-Part loading ${i?"ON":"OFF"} loading sn ${null==n?void 0:n.sn}->${e.sn}`),this.loadingParts=i)}if(i=Math.max(e.start,i||0),this.loadingParts){let s=a.partList;if(s&&r){i>a.fragmentEnd&&a.fragmentHint&&(e=a.fragmentHint);let o=this.getNextPart(s,e,i);if(o>-1){let l=s[o];if(!xi(e=this.fragCurrent=l.fragment,n)&&!this.shouldLoadParts(t.details,e.end))return this.log(`LL-Part loading OFF @${this.playhead} next part: ${this.fragInfo(e,!1,l)}`),this.loadingParts=!1,Promise.resolve(null);if(!this.filterReplacedPrimary(l,t.details))return Promise.resolve(null);let d=this.loadKeyFor(e,a);if(this.fragContextChanged(e))return Promise.resolve(null);this.log(`Loading ${e.type} sn: ${e.sn} part: ${l.index} (${o}/${s.length-1}) of ${this.fragInfo(e,!1,l)} cc: ${e.cc} [${a.startSN}-${a.endSN}], target: ${i}${l.byteRange.length?` range:${l.byteRange.join("-")}`:""}`),this.nextLoadPosition=l.start+l.duration,this.state=_o;let u,h=this.loadInitSegmentIfNeeded(e);if(d||h){let i=!!d;u=Promise.all([d,h]).then(([a])=>!i||a&&!this.fragContextChanged(a.frag)?this.doFragPartsLoad(e,l,t,r):null).catch(e=>this.handleFragLoadError(e))}else u=this.doFragPartsLoad(e,l,t,r).catch(e=>this.handleFragLoadError(e));return this.hls.trigger(Ai.FRAG_LOADING,{frag:e,part:l,targetBufferTime:i}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):u}if(!e.url||this.loadedEndOfParts(s,i))return Promise.resolve(null)}}var s;if(this.loadingParts)this.log(`LL-Part loading OFF after next part miss @${i} Check buffer at sn: ${e.sn} loaded parts: ${null==(s=a.partList)?void 0:s.filter(e=>e.loaded).map(e=>`[${e.start}-${e.end}]`)}`),this.loadingParts=!1;else if(!e.url)return Promise.resolve(null);if(!this.filterReplacedPrimary(e,t.details))return Promise.resolve(null);let o=this.loadInitSegmentIfNeeded(e),l=this.loadKeyFor(e,a,o);var d;if(this.fragContextChanged(e))return this.log(`Context changed in KEY_LOADING sn: ${e.sn} ${e.relurl} > ${null==(d=this.fragCurrent)?void 0:d.relurl}`),null==o||o.catch(()=>null),null==l||l.catch(()=>null),Promise.resolve(null);this.log(`Loading ${e.type} sn: ${e.sn} of ${this.fragInfo(e,!1)} cc: ${e.cc} ${"["+a.startSN+"-"+a.endSN+"]"}, target: ${i}${e.byteRange.length?` range:${e.byteRange.join("-")}`:""}`),vi(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=_o;let u,h=this.config.progressive&&e.type!==Li.SUBTITLE;return u=h&&l?l.then(t=>!t||this.fragContextChanged(t.frag)?null:this.fragmentLoader.load(e,this.iframesOnly,r,o)).catch(e=>this.handleFragLoadError(e)):Promise.all([this.fragmentLoader.load(e,this.iframesOnly,h?r:void 0,h?o:void 0),l,o]).then(([e])=>(!h&&r&&r(e),e)).catch(e=>this.handleFragLoadError(e)),this.hls.trigger(Ai.FRAG_LOADING,{frag:e,targetBufferTime:i}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):Promise.all([u,o]).then(([e])=>e)}doFragPartsLoad(e,t,i,r){return new Promise((a,n)=>{var s;let o=[],l=null==(s=i.details)?void 0:s.partList,d=t=>{this.fragmentLoader.loadPart(e,t,r).then(r=>{o[t.index]=r;let n=r.part;this.hls.trigger(Ai.FRAG_LOADED,r);let s=oo(i.details,e.sn,t.index+1)||lo(l,e.sn,t.index+1);if(!s)return a({frag:e,part:n,partsLoaded:o});d(s)}).catch(n)};d(t)})}handleFragLoadError(e){if("data"in e){let t=e.data;t.frag&&t.details===Ti.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):t.frag&&t.type===bi.KEY_SYSTEM_ERROR&&!t.fatal&&(t.frag.abortRequests(),this.resetStartWhenNotLoaded(),this.resetFragmentLoading(t.frag)),this.hls.trigger(Ai.ERROR,t)}else this.hls.trigger(Ai.ERROR,{type:bi.OTHER_ERROR,details:Ti.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){let t=this.getCurrentContext(e);if(!t||this.state!==Io)return void(!this.fragCurrent&&this.state!==bo&&this.state!==wo&&(this.state=To));let{frag:i,part:r,level:a}=t,n=self.performance.now();i.stats.parsing.end=n,r&&(r.stats.parsing.end=n);let s=this.getLevelDetails(),o=s&&i.sn>s.endSN||this.shouldLoadParts(s,i.end);o!==this.loadingParts&&(this.log(`LL-Part loading ${o?"ON":"OFF"} after parsing segment ending @${i.end}`),this.loadingParts=o),this.updateLevelTiming(i,r,a,e)}shouldLoadParts(e,t){if(this.config.lowLatencyMode){if(!e)return this.loadingParts;if(e.partList&&!this.iframesOnly){var i;let r=e.partList[0];if(t>=r.end+((null==(i=e.fragmentHint)?void 0:i.duration)||0)&&this.playhead>r.start-r.fragment.duration)return!0}}return!1}getCurrentContext(e){let{levels:t,fragCurrent:i}=this,{level:r,sn:a,part:n}=e;if(null==t||!t[r])return this.warn(`Levels object was unset while buffering fragment ${a} of ${this.playlistLabel()} ${r}. The current chunk will not be buffered.`),null;let s=t[r],o=s.details,l=n>-1?oo(o,a,n):null,d=l?l.fragment:so(o,a,i);return d?(i&&i!==d&&(d.stats=i.stats),{frag:d,part:l,level:s}):null}bufferFragmentData(e,t,i,r,a){if(this.state!==Io)return;Pi(t)&&!this.fragContextChanged(t)&&(this.fragPrevious=t);let{data1:n,data2:s}=e,o=n;if(s&&(o=sa(n,s)),!o.length)return;let l=this.initPTS[t.cc],d=l?-l.baseTime/l.timescale:void 0,u={type:e.type,frag:t,part:i,chunkMeta:r,offset:d,parent:t.type,data:o};if(this.hls.trigger(Ai.BUFFER_APPENDING,u),e.dropped&&e.independent&&!i){if(a)return;this.flushBufferGap(t)}}flushBufferGap(e){let t=this.media;if(!t)return;if(!ts.isBuffered(t,t.currentTime))return void this.flushMainBuffer(0,e.start);let i=t.currentTime,r=ts.bufferInfo(t,i,0),a=e.duration,n=Math.min(2*this.config.maxFragLookUpTolerance,.25*a),s=Math.max(Math.min(e.start-n,r.end-n),i+n);e.start-s>n&&this.flushMainBuffer(s,e.start)}getFwdBufferInfo(e,t){var i;let r=this.playhead,a=this.lastCurrentTime>r||null!=(i=this.media)&&i.paused?0:this.config.maxBufferHole;return this.getFwdBufferInfoAtPos(e,r,t,a)}getFwdBufferInfoAtPos(e,t,i,r){let a=ts.bufferInfo(e,t,r);if(0===a.len&&void 0!==a.nextStart){let n=this.fragmentTracker.getBufferedFrag(t,i);if(n&&(a.nextStart<=n.end||n.gap)){let i=Math.max(Math.min(a.nextStart,n.end)-t,r);return ts.bufferInfo(e,t,i)}}return a}getMaxBufferLength(e){let t,{config:i}=this;return t=e?Math.max(8*i.maxBufferSize/e,i.maxBufferLength):i.maxBufferLength,Math.min(t,i.maxMaxBufferLength)}exceedsMaxBuffer(e,t,i){let r=e.nextStart;if(r&&i.start>r){let r=e.buffered;if(r){let a=e.len,n=e.bufferedIndex;for(let e=r.length-1;e>n;e--)r[e].start<i.start&&(a+=r[e].end-r[e].start);return a>=t}}return!1}reduceMaxBufferLength(e,t){let i=this.config,r=Math.max(Math.min(e-t,i.maxBufferLength),t/2),a=Math.max(e-3*t,i.maxMaxBufferLength/2,r);return a>=r&&(i.maxMaxBufferLength=a,this.warn(`Reduce max buffer length to ${a}s`),!0)}getAppendedFrag(e){let t=this.fragmentTracker?this.fragmentTracker.getAppendedFrag(e,this.playlistType):null;return t&&"fragment"in t?t.fragment:t}getNextFragment(e,t){let i=t.fragments,r=i.length;if(!r)return null;let{config:a}=this,n=t.fragmentStart,s=a.lowLatencyMode&&!!t.partList,o=null;if(t.live){let i=a.initialLiveManifestSize;if(r<i)return this.warn(`Not enough fragments to start playback (have: ${r}, need: ${i})`),null;if(!this.startFragRequested&&s&&!this.loadingParts&&(this.log("LL-Part loading ON for initial live fragment"),this.loadingParts=!0),!t.PTSKnown&&!this.startFragRequested&&-1===this.startPosition||e<n){var l;o=this.getInitialLiveFragment(t);let i,r,a=this.config.startPosition,s=this.hls.startPosition,d=this.hls.liveSyncPosition,u=(null==(l=o)?void 0:l.start)||0;if(-1!==s&&s>=n?(i=s,r=s===a?"config":"next load start"):d?(i=d,r="live edge"):(i=e,r="buffer pos"),i<u&&(i=u,r="live frag start"),i<n&&(i=n,r="playlist start"),this.startPosition!=i||this.nextLoadPosition!=i){let l=t.live&&!this.filterReplacedPrimary(o,t)?-1:i;this.log(`Setting startPosition to ${l} next load ${i} ${-1===s?"":`(from ${a}) `}based on ${r}. live edge: ${d} live frag start: ${u} playlist start: ${n} buffer pos: ${e}`),this.startPosition=l,this.nextLoadPosition=i}}}else e<=n&&(o=i[0]);if(!o){let i=this.loadingParts?t.partEnd:t.fragmentEnd;o=this.getFragmentAtPosition(e,i,t)}let d=this.filterReplacedPrimary(o,t);return!d&&o&&(d=En(t,o.sn),d&&(this.nextLoadPosition=d.start)),d}isLoopLoading(e,t){if(this.nextLoadPosition<=t)return!1;let i=this.fragmentTracker.getState(e);return!!(i===On||i===xn&&(e.gap||e.stats.retry>1))}getNextFragmentLoopLoading(e,t,i,r,a){let n=null;if(e.gap&&(n=this.getNextFragment(this.nextLoadPosition,t),n&&!n.gap&&i.nextStart)){let e=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,i.nextStart,r,0);if(null!==e&&i.len+e.len>=a){let e=n.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,n}get primaryPrefetch(){var e;if(xo(this.config)&&(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(xo(this.config)&&("type"in e?e:e.fragment).type!==Li.SUBTITLE){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&&!1===(null==t?void 0:t.live)||e.start>=r.end&&r.nextEvent&&(r.nextEvent.appendInPlace&&!r.nextEvent.hasPlayed||e.start-r.end>1))return null}if(Po(e,null==i?void 0:i.playerQueue,this.playhead))return null}return e}getNextPart(e,t,i){let r=-1,a=!1,n=!0;for(let s=0,o=e.length;s<o;s++){let o=e[s];if(n=n&&!o.independent,r>-1&&i<o.start)break;let l=o.loaded||o.gap;l?r=-1:(a||(o.independent||n)&&o.fragment===t)&&(r=s),a=l&&!o.gap}let s=e[r];return s&&s.fragment!==t&&this.log(`Need buffer at ${i} but next unloaded part starts at ${s.start} (sn: ${t.sn} -> ${s.fragment.sn})`),r}loadedEndOfParts(e,t){let i;for(let r=e.length;r--;){if(i=e[r],!i.loaded)return!1;if(t>i.start)return!0}return!1}getInitialLiveFragment(e){let t=e.fragments,i=this.fragPrevious,r=null;if(i){if(e.hasProgramDateTime&&(r=function(e,t,i){if(null===t||!Array.isArray(e)||!e.length||!vi(t))return null;if(t<(e[0].programDateTime||0))return null;if(t>=(e[e.length-1].endProgramDateTime||0))return null;for(let r=0;r<e.length;++r){let a=e[r];if(gn(t,i,a))return a}return null}(t,i.endProgramDateTime,this.config.maxFragLookUpTolerance),r&&this.log(`Live playlist, switching playlist, load frag with same PDT: ${i.programDateTime}`)),!r){let a=i.sn+1;if(a>=e.startSN&&a<=e.endSN){let n=t[a-e.startSN];i.cc===n.cc&&(r=n,this.log(`Live playlist, switching playlist, load frag with next SN: ${r.sn}`))}r||(r=vn(e,i.cc,i.end),r&&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:a}=this,{fragPrevious:n}=this,{fragments:s,endSN:o}=i,{fragmentHint:l}=i,{maxFragLookUpTolerance:d}=a,u=i.partList,h=!!(this.loadingParts&&null!=u&&u.length&&l);if(h&&!this.bitrateTest&&u[u.length-1].fragment.sn===l.sn&&(s=s.concat(l),o=l.sn),n&&this.fragmentTracker.getState(n)===Mn&&(n=null),e<t){var c;r=fn(n,s,e,e<this.lastCurrentTime||e>t-d||null!=(c=this.media)&&c.paused||!this.startFragRequested?0:d)}else r=s[s.length-1];if(r){let e=r.sn-i.startSN,t=this.fragmentTracker.getState(r);if((t===On||t===xn&&r.gap)&&(n=r),xi(r,n)&&(!h||u[0].fragment.sn>r.sn||!i.live)){let t=s[e+1];r=r.sn<o&&this.fragmentTracker.getState(t)!==On?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 a=e.fragmentStart,n=!t,s=e.alignedSliding&&vi(a);if(n||!s&&!a){go(i,e,this);let a=e.fragmentStart;return this.log(`Live playlist sliding: ${a} start-sn: ${t?t.startSN:"na"}->${e.startSN} fragments: ${r}`),a}return a}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 a=null!==this.startTimeOffset,n=a?this.startTimeOffset:e.startTimeOffset;if(null!==n&&vi(n))i=t+n,n<0&&(i+=e.edge),i=Math.min(Math.max(t,i),t+e.totalduration),this.log(`Setting startPosition to ${i} for start time offset ${n} found in ${a?"multivariant":"media"} playlist`),this.startPosition=i;else if(e.live){let e=this.hls.liveSyncPosition;i=e||t,this.log(`Setting startPosition to -1 to start at ${e?"live edge":"playlist start"} ${i}`),this.startPosition=-1}else 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&&!this.iframesOnly?i=t.currentTime:this.nextLoadPosition>=0&&(i=this.nextLoadPosition),i}get playhead(){var e;if(null!=(e=this.hls)&&e.hasEnoughToStart){var t;let e=null==(t=this.media)?void 0:t.currentTime;return vi(e)?e:this.lastCurrentTime}return this.getLoadPosition()}get iframesOnly(){var e;if(this.playlistType!==Li.MAIN)return!1;let t=this.getLevelDetails();return t?t.iframesOnly:null==(e=this.levelLastLoaded)?void 0:e.iframes}handleFragLoadAborted(e,t){this.transmuxer&&e.type===this.playlistType&&Pi(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!==So)&&(this.state=To)}onFragmentOrKeyLoadError(e,t){if(t.chunkMeta&&!t.frag){let e=this.getCurrentContext(t.chunkMeta);e&&(t.frag=e.frag)}let{frag:i,part:r}=t;if(!i||!this.levels||i.type!==e)return;var a;if(this.fragContextChanged(i))return void this.warn(`Frag load error must match current frag to retry ${i.relurl} > ${null==(a=this.fragCurrent)?void 0:a.relurl}`);let n=t.details===Ti.FRAG_GAP;n&&this.fragmentTracker.addAsGap(i);let s=t.errorAction;if(!s)return void(this.state=wo);let{action:o,flags:l,retryCount:d=0,retryConfig:u}=s,h=!!u,c=h&&o===An,m=h&&!s.resolved&&l&Sn,f=this.hls.latestLevelDetails,p=null==f?void 0:f.live;if(!c&&m&&Pi(i)&&p&&i.sn<f.endSN&&!qi(t))this.resetFragmentErrors(e),r?r.gap=!0:this.treatAsGap(i),s.resolved=!0;else if((c||m)&&d<u.maxNumRetry){var g;let r=Xi(null==(g=t.response)?void 0:g.code),a=ji(u,d);if(this.resetStartWhenNotLoaded(),this.retryDate=self.performance.now()+a,this.state=So,s.resolved=!0,r)return this.log("Waiting for connection (offline)"),this.retryDate=1/0,void(t.reason="offline");this.warn(`Fragment ${i.sn} of ${e} ${i.level} errored with ${t.details}, retrying loading ${d+1}/${u.maxNumRetry} in ${a}ms`)}else if(u){if(this.resetFragmentErrors(e),!(d<u.maxNumRetry))return void this.warn(`${t.details} reached or exceeded max retry (${d})`);!n&&o!==Tn&&(s.resolved=!0)}else this.state=o===bn?Co:wo;this.tickImmediate()}checkRetryDate(){let e=self.performance.now(),t=this.retryDate,i=t===1/0;(!t||e>=t||i&&!Xi(0))&&(i&&this.log("Connection restored (online)"),this.resetStartWhenNotLoaded(),this.state=To)}reduceLengthAndFlushBuffer(e){if(this.state===Io||this.state===Ro){let t=e.frag,i=e.parent,r=this.getFwdBufferInfo(this.mediaBuffer,i),a=r&&r.len>.5;a&&this.reduceMaxBufferLength(r.len,(null==t?void 0:t.duration)||10);let n=!a;return n?this.warn(`Buffer full error while media.currentTime (${this.playhead}) is not buffered, flush ${i} buffer`):r.nextStart&&t&&r.nextStart>t.start&&this.flushMainBuffer(r.nextStart,Number.POSITIVE_INFINITY,i===Li.AUDIO?i:void 0),t&&(this.fragmentTracker.removeFragment(t),this.nextLoadPosition=t.start),this.resetLoadingState(),n}return!1}resetFragmentErrors(e){e===Li.AUDIO&&(this.fragCurrent=null),this.hls.hasEnoughToStart||(this.startFragRequested=!1),this.state!==bo&&(this.state=To)}afterBufferFlushed(e,t){if(!e)return;let i=ts.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,i,this.playlistType),this.state===Lo&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==bo&&(this.state=To)}resetStartWhenNotLoaded(){if(!this.hls.hasEnoughToStart){this.startFragRequested=!1;let e=this.getLevelDetails();null!=e&&e.live?(this.log("resetting startPosition for live start"),this.startPosition=-1,this.setStartPosition(e,e.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 a=i.details;if(a){if(this.log(`update level timing ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,!1,t)}`),!Object.keys(e.elementaryStreams).reduce((t,n)=>{let s=e.elementaryStreams[n];if(s){let o=s.endPTS-s.startPTS;if(o<=0)return this.warn(`Could not parse fragment ${e.sn} ${n} duration reliably (${o})`),t||!1;let l=r.partial?0:to(a,e,s.startPTS,s.endPTS,s.startDTS,s.endDTS,this.iframesOnly,this);return this.hls.trigger(Ai.LEVEL_PTS_UPDATED,{details:a,level:i,drift:l,type:n,frag:e,start:s.startPTS,end:s.endPTS}),!0}return t},!1)){var n,s,o,l;let r=null===(null==(n=this.transmuxer)?void 0:n.error),a=null!=(null==(s=this.transmuxer)?void 0:s.error),d=(null!=(o=null==(l=this.levels)?void 0:l.length)?o:0)>1;if((0===i.fragmentError||r&&(i.fragmentError<2||e.endList)||a&&d)&&this.treatAsGap(e,i),r){let r=new Error(`Found no media in ${this.playlistLabel()} ${e.level} ${t?`part: ${t.index} of `:""}sn: ${e.sn} at playlist time: ${e.start}. Resetting transmuxer to fallback to playlist timing`);if(this.warn(r.message),this.hls.trigger(Ai.ERROR,{type:bi.MEDIA_ERROR,details:Ti.FRAG_PARSING_ERROR,fatal:!1,error:r,frag:e,reason:`Found no media in msn ${e.sn} of ${this.playlistLabel()} "${i.url}"`}),!this.hls)return;this.resetTransmuxer()}}this.state=Ro,this.log(`Parsed ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,!1,t)}`),this.hls.trigger(Ai.FRAG_PARSED,{frag:e,part:t,chunkMeta:r})}else this.warn("level.details undefined")}playlistLabel(){return`${this.playlistType} playlist`}fragInfo(e,t=!0,i){var r,a;return`${this.playlistLabel()} ${e.level} (${i?"part":"frag"}:[${null!=(r=t&&!i?e.startPTS:(i||e).start)?r:NaN}-${null!=(a=t&&!i?e.endPTS:(i||e).end)?a:NaN}]${i&&"main"===e.type?"INDEPENDENT="+(i.independent?"YES":"NO"):""})`}treatAsGap(e,t){t&&t.fragmentError++,this.fragmentTracker.addAsGap(e)}resetTransmuxer(){var e;null==(e=this.transmuxer)||e.reset()}isFragmentNearlyDownloaded(e){var t;let i=null==(t=e.loader)?void 0:t.stats;if(!i)return!1;let r=i.loading.first>0,a=(i.total-i.loaded)/(this.hls.bandwidthEstimate||this.hls.config.abrEwmaDefaultEstimate);return r&&a<=.15}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}calculateOptimalSwitchPoint(e,t){let i=0,{hls:r,media:a,config:n,levels:s,playlistType:o}=this,l=this.getLevelDetails();if(a&&!a.paused&&s){var d;let t=o===Li.AUDIO?Ga(e.audioCodec,128e3):e.maxBitrate,a=1+r.ttfbEstimate/1e3,s=r.bandwidthEstimate*n.abrBandWidthUpFactor;i=a+t*(l&&(this.loadingParts?l.partTarget:l.averagetargetduration)||(null==(d=this.fragCurrent)?void 0:d.duration)||6)/s,e.details||(i+=a)}let u=this.playhead;return{fetchdelay:i,okToFlushForwardBuffer:!(null!=l&&l.live)||t.end-u>1.5*i}}scheduleTrackSwitch(e,t,i){let{media:r,playlistType:a}=this;if(!r||!e)return;let n=i?this.getBufferedFrag(this.playhead+t):null;if(n){let e=this.followingBufferedFrag(n);if(e){var s;this.abortCurrentFrag();let t=e.maxStartPTS?e.maxStartPTS:e.start,i=e.duration,r=Math.max(n.end,t+Math.min(Math.max(i-this.config.maxFragLookUpTolerance,i*(this.couldBacktrack?.5:.125)),i*(this.couldBacktrack?.75:.25)));if(((null==(s=this.getLevelDetails())?void 0:s.fragmentStart)||0)>r)return;let o=a===Li.MAIN?null:"audio";this.flushMainBuffer(r,Number.POSITIVE_INFINITY,o),this.cleanupBackBuffer()}}}cleanupBackBuffer(){let{media:e,playlistType:t}=this;if(!e)return;let i=this.getAppendedFrag(this.playhead);if(i&&i.start>1){let e=t===Li.AUDIO;this.flushMainBuffer(0,i.start-(e?0:1),e?"audio":null)}}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,this.playlistType)}followingBufferedFrag(e){return e?this.getBufferedFrag(e.end+.5):null}abortCurrentFrag(){let e=this.fragCurrent;switch(this.fragCurrent=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case Ao:case _o:case So:case Io:case Ro:this.state=To}this.nextLoadPosition=this.playhead}checkFragPlaying(){let e=this.media,t=null;if(e&&e.readyState>1&&!1===e.seeking){let i=e.currentTime;if(ts.isBuffered(e,i)?t=this.getAppendedFrag(i):ts.isBuffered(e,i+.1)&&(t=this.getAppendedFrag(i+.1)),t&&(this.backtrackFragment=void 0,!xi(t,this.fragPlaying)))return this.fragPlaying=t,!0}return!1}getBufferOutput(){return null}nextLevelSwitch(){let{levels:e,media:t,hls:i,config:r,playlistType:a}=this;if(null!=t&&t.readyState&&e&&i&&r){let t=this.getBufferOutput(),r=this.getFwdBufferInfo(t,a);if(!r)return;let n=e[a===Li.AUDIO?i.nextAudioTrack:i.nextLoadLevel],{fetchdelay:s,okToFlushForwardBuffer:o}=this.calculateOptimalSwitchPoint(n,r);this.scheduleTrackSwitch(r,s,o)}this.tickImmediate()}};function Po(e,t,i){if(t)for(let r=t.length;r--;){let a=t[r].interstitial,n=a.startTime,s=Math.min(n+a.duration,a.resumeTime);if(a.appendInPlace&&(e.start>=n&&e.end<=s||i>e.start&&e.end>n&&e.start<s))return!0}return!1}function xo(e){return!!e.interstitialsController&&!1!==e.enableInterstitialPlayback}var Oo=class{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 a=e[t];i.set(a,r),r+=a.length}return i}(t,i),this.reset(),e):new Uint8Array(0)}reset(){this.chunks.length=0,this.dataLength=0}};var No,Uo={exports:{}};var Fo=(No||(No=1,function(e){var t=Object.prototype.hasOwnProperty,i="~";function r(){}function a(e,t,i){this.fn=e,this.context=t,this.once=i||!1}function n(e,t,r,n,s){if("function"!=typeof r)throw new TypeError("The listener must be a function");var o=new a(r,n||e,s),l=i?i+t:t;return e._events[l]?e._events[l].fn?e._events[l]=[e._events[l],o]:e._events[l].push(o):(e._events[l]=o,e._eventsCount++),e}function s(e,t){0===--e._eventsCount?e._events=new r:delete e._events[t]}function o(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(i=!1)),o.prototype.eventNames=function(){var e,r,a=[];if(0===this._eventsCount)return a;for(r in e=this._events)t.call(e,r)&&a.push(i?r.slice(1):r);return Object.getOwnPropertySymbols?a.concat(Object.getOwnPropertySymbols(e)):a},o.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 a=0,n=r.length,s=new Array(n);a<n;a++)s[a]=r[a].fn;return s},o.prototype.listenerCount=function(e){var t=i?i+e:e,r=this._events[t];return r?r.fn?1:r.length:0},o.prototype.emit=function(e,t,r,a,n,s){var o=i?i+e:e;if(!this._events[o])return!1;var l,d,u=this._events[o],h=arguments.length;if(u.fn){switch(u.once&&this.removeListener(e,u.fn,void 0,!0),h){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,t),!0;case 3:return u.fn.call(u.context,t,r),!0;case 4:return u.fn.call(u.context,t,r,a),!0;case 5:return u.fn.call(u.context,t,r,a,n),!0;case 6:return u.fn.call(u.context,t,r,a,n,s),!0}for(d=1,l=new Array(h-1);d<h;d++)l[d-1]=arguments[d];u.fn.apply(u.context,l)}else{var c,m=u.length;for(d=0;d<m;d++)switch(u[d].once&&this.removeListener(e,u[d].fn,void 0,!0),h){case 1:u[d].fn.call(u[d].context);break;case 2:u[d].fn.call(u[d].context,t);break;case 3:u[d].fn.call(u[d].context,t,r);break;case 4:u[d].fn.call(u[d].context,t,r,a);break;default:if(!l)for(c=1,l=new Array(h-1);c<h;c++)l[c-1]=arguments[c];u[d].fn.apply(u[d].context,l)}}return!0},o.prototype.on=function(e,t,i){return n(this,e,t,i,!1)},o.prototype.once=function(e,t,i){return n(this,e,t,i,!0)},o.prototype.removeListener=function(e,t,r,a){var n=i?i+e:e;if(!this._events[n])return this;if(!t)return s(this,n),this;var o=this._events[n];if(o.fn)o.fn===t&&(!a||o.once)&&(!r||o.context===r)&&s(this,n);else{for(var l=0,d=[],u=o.length;l<u;l++)(o[l].fn!==t||a&&!o[l].once||r&&o[l].context!==r)&&d.push(o[l]);d.length?this._events[n]=1===d.length?d[0]:d:s(this,n)}return this},o.prototype.removeAllListeners=function(e){var t;return e?(t=i?i+e:e,this._events[t]&&s(this,t)):(this._events=new r,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=i,o.EventEmitter=o,e.exports=o}(Uo)),Uo.exports),Bo=function(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}(Fo),$o="1.7.3",Ho={};function Go(e,t){return 255===e[t]&&240==(246&e[t+1])}function Ko(e,t){return 1&e[t+1]?7:9}function Wo(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function Vo(e,t){return t+1<e.length&&Go(e,t)}function qo(e,t){if(Vo(e,t)){let i=Ko(e,t);if(t+i>=e.length)return!1;let r=Wo(e,t);if(r<=i)return!1;let a=t+r;return a===e.length||Vo(e,a)}return!1}function Yo(e,t,i,r,a){if(!e.samplerate){let n=function(e,t,i,r){let a=t[i+2],n=a>>2&15;if(n>12){let t=new Error(`invalid ADTS sampling index:${n}`);return void e.emit(Ai.ERROR,Ai.ERROR,{type:bi.MEDIA_ERROR,details:Ti.FRAG_PARSING_ERROR,fatal:!0,error:t,reason:t.message})}let s=1+(a>>6&3),o=t[i+3]>>6&3|(1&a)<<2,l=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350][n],d=n;(5===s||29===s)&&(d-=3);let u,h=(14&d)>>1,c=(1&d)<<7|o<<3,m=0;if(1===s&&n>=6){m=5;let e=n-3;u=[m<<3|h,c|(14&e)>>1,(1&e)<<7|8,0]}else u=[s<<3|h,c];let f="mp4a.40."+(m||s);return or.log(`manifest codec:${r}, parsed codec:${f}, channels:${o}, rate:${l} (ADTS object type:${s} sampling index:${n} esds config:[${u.join(",")}])`),{config:u,samplerate:l,channelCount:o,codec:f,parsedCodec:f,manifestCodec:r}}(t,i,r,a);if(!n)return;$i(e,n)}}function jo(e){return 9216e4/e}function zo(e,t,i,r,a){let n,s=r+a*jo(e.samplerate),o=function(e,t){let i=Ko(e,t);if(t+i<=e.length){let r=Wo(e,t)-i;if(r>0)return{headerLength:i,frameLength:r}}}(t,i);if(o){let{frameLength:r,headerLength:a}=o,l=a+r,d=Math.max(0,i+l-t.length);d?(n=new Uint8Array(l-a),n.set(t.subarray(i+a,t.length),0)):n=t.subarray(i+a,i+l);let u={unit:n,pts:s};return d||e.samples.push(u),{sample:u,length:l,missing:d}}let l=t.length-i;return n=new Uint8Array(l),n.set(t.subarray(i,t.length),0),{sample:{unit:n,pts:s},length:l,missing:-1}}var Qo=function(e){return e.audioId3="org.id3",e.dateRange="com.apple.quicktime.HLS",e.emsg="https://aomedia.org/emsg/ID3",e.misbklv="urn:misb:KLV:bin:1910.1",e}({});function Xo(e="",t=9e4){return{type:e,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}var Zo=class{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){this.cachedData&&(e=sa(this.cachedData,e),this.cachedData=null);let i,r=br(e,0),a=r?r.length:0,n=this._audioTrack,s=this._id3Track,o=r?wr(r):void 0,l=e.length;for((null===this.basePTS||0===this.frameIndex&&vi(o))&&(this.basePTS=Jo(o,t,this.initPTS),this.lastPTS=this.basePTS),null===this.lastPTS&&(this.lastPTS=this.basePTS),r&&r.length>0&&s.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:Qo.audioId3,duration:Number.POSITIVE_INFINITY});a<l;){if(this.canParse(e,a)){let t=this.appendFrame(n,e,a);t?(this.frameIndex++,this.lastPTS=t.sample.pts,a+=t.length,i=a):a=l}else Er(e,a)?(r=br(e,a),s.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:Qo.audioId3,duration:Number.POSITIVE_INFINITY}),a+=r.length,i=a):a++;if(a===l&&i!==l){let t=e.slice(i);this.cachedData?this.cachedData=sa(this.cachedData,t):this.cachedData=t}}return{audioTrack:n,videoTrack:Xo(),id3Track:s,textTrack:Xo()}}demuxSampleAes(e,t,i){return Promise.reject(new 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:Xo(),id3Track:this._id3Track,textTrack:Xo()}}destroy(){this.cachedData=null,this._audioTrack=this._id3Track=void 0}},Jo=(e,t,i)=>{if(vi(e))return 90*e;return 9e4*t+(i?9e4*i.baseTime/i.timescale:0)},el=[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],tl=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],il=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],rl=[0,1,1,4];function al(e,t,i,r,a){if(i+24>t.length)return;let n=nl(t,i);if(n&&i+n.frameLength<=t.length){let s=r+a*(9e4*n.samplesPerFrame/n.sampleRate),o={unit:t.subarray(i,i+n.frameLength),pts:s,dts:s};return e.config=[],e.channelCount=n.channelCount,e.samplerate=n.sampleRate,e.samples.push(o),{sample:o,length:n.frameLength,missing:0}}}function nl(e,t){let i=e[t+1]>>3&3,r=e[t+1]>>1&3,a=e[t+2]>>4&15,n=e[t+2]>>2&3;if(1!==i&&0!==a&&15!==a&&3!==n){let s=e[t+2]>>1&1,o=e[t+3]>>6,l=1e3*el[14*(3===i?3-r:3===r?3:4)+a-1],d=tl[3*(3===i?0:2===i?1:2)+n],u=3===o?1:2,h=il[i][r],c=rl[r],m=8*h*c,f=Math.floor(h*l/d+s)*c,p=ba();return!!p&&p<=87&&2===r&&l>=224e3&&0===o&&(e[t+3]=128|e[t+3]),{sampleRate:d,channelCount:u,frameLength:f,samplesPerFrame:m}}}function sl(e,t){return!(255!==e[t]||224&~e[t+1]||!(6&e[t+1]))}function ol(e,t){return t+1<e.length&&sl(e,t)}function ll(e,t){if(t+1<e.length&&sl(e,t)){let i=nl(e,t),r=4;null!=i&&i.frameLength&&(r=i.frameLength);let a=t+r;return a===e.length||ol(e,a)}return!1}var dl=class{constructor(e,t,i){this.keyData=void 0,this.decrypter=void 0,this.keyData=i,this.decrypter=new Vn(t,!0)}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer,$n,{start:0,end:e.byteLength})}decryptAacSample(e,t,i){let r=e[t].unit;if(r.length<=16)return;let a=r.subarray(16,r.length-r.length%16),n=a.buffer.slice(a.byteOffset,a.byteOffset+a.length);this.decryptBuffer(n).then(a=>{let n=new Uint8Array(a);r.set(n,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=16*Math.floor((e.length-48)/160)+16,i=new Int8Array(t),r=0;for(let t=32;t<e.length-16;t+=160,r+=16)i.set(e.subarray(t,t+16),r);return i}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,a){let n=ua(a.data),s=this.getAvcEncryptedData(n);this.decryptBuffer(s.buffer).then(s=>{a.data=this.getAvcDecryptedUnit(n,s),this.decrypter.isSync()||this.decryptAvcSamples(e,t,i+1,r)}).catch(r)}decryptAvcSamples(e,t,i,r){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,i=0){if(t>=e.length)return void r();let a=e[t].units;for(;!(i>=a.length);i++){let n=a[i];if(!(n.data.length<=48||1!==n.type&&5!==n.type||(this.decryptAvcSample(e,t,i,r,n),this.decrypter.isSync())))return}}}},ul=(e,t)=>{let i=0,r=5;t+=r;let a=new Uint32Array(1),n=new Uint32Array(1),s=new Uint8Array(1);for(;r>0;){s[0]=e[t];let o=Math.min(r,8),l=8-o;n[0]=4278190080>>>24+l<<l,a[0]=(s[0]&n[0])>>l,i=i?i<<o|a[0]:a[0],t+=1,r-=o}return i};function hl(e,t,i,r,a){if(i+8>t.length||11!==t[i]||119!==t[i+1])return-1;let n=t[i+4]>>6;if(n>=3)return-1;let s=[48e3,44100,32e3][n],o=63&t[i+4],l=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*o+n];if(i+l>t.length)return-1;let d=t[i+6]>>5,u=0;2===d?u+=2:(1&d&&1!==d&&(u+=2),4&d&&(u+=2));let h=(t[i+6]<<8|t[i+7])>>12-u&1,c=[2,1,2,3,3,4,4,5][d]+h,m=t[i+5]>>3,f=7&t[i+5],p=new Uint8Array([n<<6|m<<1|f>>2,(3&f)<<6|d<<3|h<<2|o>>4,o<<4&224]),g=r+a*(1536/s*9e4),v=t.subarray(i,i+l);return e.config=p,e.channelCount=c,e.samplerate=s,e.samples.push({unit:v,pts:g}),l}var cl=/\/emsg[-/]ID3/i;function ml(e,t){return vi(e.presentationTime)?e.presentationTime/e.timeScale:t+e.presentationTimeDelta/e.timeScale}var fl=class{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=t.byteLength;if(0===r)return[];let a=e.naluState||0,n=-1===a?0:a,s=[],o=0,l=0,d=-1,u=0;for(-1===a&&(d=0,u=this.getNALuType(t,0),l=1);l<r;){let i=t.indexOf(1,l);if(-1===i)break;l=i+1;let a=i;for(;a>0&&0===t[a-1];)a--;if(!(i-a+(0===a?n:0)<2)){if(d>=0)s.push({data:t.subarray(d,a),type:u});else{let i=this.getLastNalUnit(e.samples);i&&(a>0?i.data=sa(i.data,t.subarray(0,a)):n>0&&(i.data=i.data.subarray(0,i.data.byteLength-n)),i.state=0)}if(!(l<r)){o=-1,d=-1;break}d=l,u=this.getNALuType(t,l)}}if(-1!==o){let e=r;for(;e>0&&0===t[e-1];)e--;o=r-e+(0===e?n:0)}if(d>=0)s.push({data:t.subarray(d),type:u,state:o});else if(0===s.length&&-1!==o){let i=this.getLastNalUnit(e.samples);i&&(i.data=sa(i.data,t),i.state=o)}return e.naluState=o,s}},pl=class{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),a=Math.min(4,t);if(0===a)throw new Error("no bytes available");r.set(e.subarray(i,i+a)),this.word=new DataView(r.buffer).getUint32(0),this.bitsAvailable=8*a,this.bytesAvailable-=a}skipBits(e){let t;e=Math.min(e,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(t=(e-=this.bitsAvailable)>>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&&or.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return t=e-t,t>0&&this.bitsAvailable?i<<t|this.readBits(t):i}skipLZ(){let e;for(e=0;e<this.bitsAvailable;++e)if(this.word&2147483648>>>e)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){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)}},gl=class extends fl{parsePES(e,t,i,r,a){let n,s=a.iframe,o=this.parseNALu(e,i.data,r),l=this.VideoSample,d=!1;i.data=null,l&&o.length&&!e.audFound&&(this.pushAccessUnit(l,e),l=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts)),o.forEach(r=>{var a,o;switch(r.type){case 1:{if(s)break;let t=!1;n=!0;let a=r.data;if(d&&a.length>4){let e=this.readSliceType(a);(2===e||4===e||7===e||9===e)&&(t=!0)}var u;if(t)null!=(u=l)&&u.frame&&!l.key&&(this.pushAccessUnit(l,e),l=this.VideoSample=null);l||(l=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),l.frame=!0,l.key=t;break}case 5:n=!0,null!=(a=l)&&a.frame&&!l.key&&(this.pushAccessUnit(l,e),l=this.VideoSample=null),l||(l=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),l.key=!0,l.frame=!0;break;case 6:if(s)break;n=!0,da(r.data,1,i.pts,t.samples);break;case 7:{var h,c;n=!0,d=!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==(c=e.pixelRatio)?void 0:c[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),a="avc1.";for(let e=0;e<3;e++){let t=r[e].toString(16);t.length<2&&(t="0"+t),a+=t}e.codec=a}break}case 8:n=!0,e.pps=[r.data];break;case 9:n=!0,e.audFound=!0,null!=(o=l)&&o.frame&&(this.pushAccessUnit(l,e),l=null),l||(l=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts));break;case 12:n=!0;break;default:n=!1}l&&n&&l.units.push(r)}),r&&l&&(this.pushAccessUnit(l,e),this.VideoSample=null)}getNALuType(e,t){return 31&e[t]}readSliceType(e){let t=new pl(e);return t.readUByte(),t.readUEG(),t.readUEG()}skipScalingList(e,t){let i,r=8,a=8;for(let n=0;n<e;n++)0!==a&&(i=t.readEG(),a=(r+i+256)%256),r=0===a?r:a}readSPS(e){let t,i,r,a=new pl(e),n=0,s=0,o=0,l=0,d=a.readUByte.bind(a),u=a.readBits.bind(a),h=a.readUEG.bind(a),c=a.readBoolean.bind(a),m=a.skipBits.bind(a),f=a.skipEG.bind(a),p=a.skipUEG.bind(a),g=this.skipScalingList.bind(this);d();let v=d();if(u(5),m(3),d(),p(),100===v||110===v||122===v||244===v||44===v||83===v||86===v||118===v||128===v){let e=h();if(3===e&&m(1),p(),p(),m(1),c())for(i=3!==e?8:12,r=0;r<i;r++)c()&&g(r<6?16:64,a)}p();let E=h();if(0===E)h();else if(1===E)for(m(1),f(),f(),t=h(),r=0;r<t;r++)f();p(),m(1);let y=h(),b=h(),T=u(1);0===T&&m(1),m(1),c()&&(n=h(),s=h(),o=h(),l=h());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(16*(y+1)-2*n-2*s),height:(2-T)*(b+1)*16-(T?2:4)*(o+l),pixelRatio:A}}},vl=class extends fl{constructor(...e){super(...e),this.initVPS=null}parsePES(e,t,i,r){let a,n=this.parseNALu(e,i.data,r),s=this.VideoSample,o=!1;i.data=null;let l=e=>(s=this.VideoSample=this.createVideoSample(e,i.pts,i.dts),s);n.forEach((r,n)=>{var d,u;if(this.startsNewAccessUnit(s,e,r,n)){this.pushAccessUnit(s,e);let t=r.type>=16&&r.type<=23;s=l(t),o=!1}switch(r.type){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:s||(s=l(!1)),s.frame=!0,a=!0;break;case 16:case 17:case 18:case 21:case 22:case 23:var h;if(a=!0,o)null!=(h=s)&&h.frame&&!s.key&&(this.pushAccessUnit(s,e),s=this.VideoSample=null);s||(s=l(!0)),s.key=!0,s.frame=!0;break;case 19:case 20:a=!0,null!=(d=s)&&d.frame&&!s.key&&(this.pushAccessUnit(s,e),s=this.VideoSample=null),s||(s=l(!0)),s.key=!0,s.frame=!0;break;case 39:a=!0,da(r.data,2,i.pts,t.samples);break;case 32:a=!0,e.vps||("object"!=typeof e.params&&(e.params={}),e.params=$i(e.params,this.readVPS(r.data)),this.initVPS=r.data),e.vps=[r.data];break;case 33:if(a=!0,o=!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);e.width=t.width,e.height=t.height,e.pixelRatio=t.pixelRatio,e.codec=t.codecString,e.sps=[],"object"!=typeof e.params&&(e.params={});for(let i in t.params)e.params[i]=t.params[i]}this.pushParameterSet(e.sps,r.data,e.vps),s||(s=l(!1));break;case 34:if(a=!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:a=!0,e.audFound=!0,null!=(u=s)&&u.frame&&(this.pushAccessUnit(s,e),s=null),s||(s=l(!1));break;default:a=!1}s&&a&&s.units.push(r)}),r&&s&&(this.pushAccessUnit(s,e),this.VideoSample=null)}pushParameterSet(e,t,i){(i&&i[0]===this.initVPS||!i&&!e.length)&&e.push(t)}startsNewAccessUnit(e,t,i,r){if(!e)return!1;if(!t.audFound&&0===r)return!0;if(!e.frame)return!1;let{type:a,data:n}=i;return a>=32&&a<=35||39===a||a>=41&&a<=44||a>=48&&a<=55||a<=31&&n.length>2&&!!(128&n[2])}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 pl(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 pl(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.readBits(4);let i=t.readBits(3);t.readBoolean();let r=t.readBits(2),a=t.readBoolean(),n=t.readBits(5),s=t.readUByte(),o=t.readUByte(),l=t.readUByte(),d=t.readUByte(),u=t.readUByte(),h=t.readUByte(),c=t.readUByte(),m=t.readUByte(),f=t.readUByte(),p=t.readUByte(),g=t.readUByte(),v=[],E=[];for(let e=0;e<i;e++)v.push(t.readBoolean()),E.push(t.readBoolean());if(i>0)for(let e=i;e<8;e++)t.readBits(2);for(let e=0;e<i;e++)v[e]&&(t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte()),E[e]&&t.readUByte();t.readUEG();let y=t.readUEG();3==y&&t.skipBits(1);let b=t.readUEG(),T=t.readUEG(),A=t.readBoolean(),_=0,S=0,k=0,I=0;A&&(_+=t.readUEG(),S+=t.readUEG(),k+=t.readUEG(),I+=t.readUEG());let R=t.readUEG(),L=t.readUEG(),w=t.readUEG();for(let e=t.readBoolean()?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 D=t.readUEG(),C=0;for(let e=0;e<D;e++){let i=!1;if(0!==e&&(i=t.readBoolean()),i){e===D&&t.readUEG(),t.readBoolean(),t.readUEG();let i=0;for(let e=0;e<=C;e++){let e=t.readBoolean(),r=!1;e||(r=t.readBoolean()),(e||r)&&i++}C=i}else{let e=t.readUEG(),i=t.readUEG();C=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<w+4;e++)t.readBits(1);t.readBits(1)}}let M=0,P=1,x=1,O=!0,N=1,U=0;t.readBoolean(),t.readBoolean();let F=!1;if(t.readBoolean()){if(t.readBoolean()){let e=t.readUByte();e>0&&e<16?(P=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2][e-1],x=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1][e-1]):255===e&&(P=t.readBits(16),x=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(),F=t.readBoolean(),F&&(t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG()),t.readBoolean()&&(N=t.readBits(32),U=t.readBits(32),t.readBoolean()&&t.readUEG(),t.readBoolean())){let e=t.readBoolean(),r=t.readBoolean(),a=!1;(e||r)&&(a=t.readBoolean(),a&&(t.readUByte(),t.readBits(5),t.readBoolean(),t.readBits(5)),t.readBits(4),t.readBits(4),a&&t.readBits(4),t.readBits(5),t.readBits(5),t.readBits(5));for(let n=0;n<=i;n++){O=t.readBoolean();let i=!1;O||t.readBoolean()?t.readEG():i=t.readBoolean();let n=i?1:t.readUEG()+1;if(e)for(let e=0;e<n;e++)t.readUEG(),t.readUEG(),a&&(t.readUEG(),t.readUEG()),t.skipBits(1);if(r)for(let e=0;e<n;e++)t.readUEG(),t.readUEG(),a&&(t.readUEG(),t.readUEG()),t.skipBits(1)}}t.readBoolean()&&(t.readBoolean(),t.readBoolean(),t.readBoolean(),M=t.readUEG())}let B=b,$=T;if(A){let e=1,t=1;1===y?e=t=2:2==y&&(e=2),B=b-e*S-e*_,$=T-t*I-t*k}let H=r?["A","B","C"][r]:"",G=s<<24|o<<16|l<<8|d,K=0;for(let e=0;e<32;e++)K=(K|(G>>e&1)<<31-e)>>>0;let W=K.toString(16);return 1===n&&"2"===W&&(W="6"),{codecString:`hvc1.${H}${n}.${W}.${a?"H":"L"}${g}.B0`,params:{general_tier_flag:a,general_profile_idc:n,general_profile_space:r,general_profile_compatibility_flags:[s,o,l,d],general_constraint_indicator_flags:[u,h,c,m,f,p],general_level_idc:g,bit_depth:R+8,bit_depth_luma_minus8:R,bit_depth_chroma_minus8:L,min_spatial_segmentation_idc:M,chroma_format_idc:y,frame_rate:{fixed:O,fps:U/N}},width:B,height:$,pixelRatio:[P,x]}}readPPS(e){let t=new pl(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(),a=1;return r&&i?a=0:r?a=3:i&&(a=2),{parallelismType:a}}matchSPS(e,t){return Pr(e).substring(3)===Pr(t).substring(3)}},El=188,yl=class e{constructor(e,t,i,r){this.logger=void 0,this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this._klvPid=-1,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.videoIntegrityChecker=null,this.observer=e,this.config=t,this.typeSupported=i,this.logger=r,this.videoParser=null}static probe(t,i){let r=e.syncOffset(t);return r>0&&i.warn(`MPEG2-TS detected but first sync word found @ offset ${r}`),-1!==r}static syncOffset(e){let t=e.length,i=Math.min(940,t-El)+1,r=0;for(;r<i;){let a=!1,n=-1,s=0;for(let o=r;o<t;o+=El){if(71!==e[o]||t-o!==El&&71!==e[o+El]){if(s)return-1;break}if(s++,-1===n&&(n=o,0!==n&&(i=Math.min(n+18612,e.length-El)+1)),a||(a=0===bl(e,o)),a&&s>1&&(0===n&&s>2||o+El>i))return n}r++}return-1}static createTrack(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:Ur[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===e?t:void 0}}resetInitSegment(t,i,r,a,n,s){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=e.createTrack("video"),this._videoTrack.duration=a,this.videoIntegrityChecker="skip"===this.config.handleMpegTsVideoIntegrityErrors?new Rl(this.logger):null,this._audioTrack=e.createTrack("audio",a),this._id3Track=e.createTrack("id3"),this._txtTrack=e.createTrack("text"),this._audioTrack.segmentCodec="aac",this.videoParser=null,this.aacOverFlow=null,this.remainderData=null,this.audioCodec=i,this.videoCodec=r,t&&this.demux(t,0,s,"SAMPLE-AES"===(null==n?void 0:n.method))}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(t,i,r,a=!1,n=!1){a||(this.sampleAes=null);let s,o=this._videoTrack,l=this.videoIntegrityChecker,d=this._audioTrack,u=this._id3Track,h=this._txtTrack,c=r.iframe,m=o.pid,f=o.pesData,p=d.pid,g=u.pid,v=this._klvPid,E=d.pesData,y=u.pesData,b=null,T=null,A=this.pmtParsed,_=this._pmtId,S=t.length;if(this.remainderData&&(S=(t=sa(this.remainderData,t)).length,this.remainderData=null),S<El&&!n)return this.remainderData=t,{audioTrack:d,videoTrack:o,id3Track:u,textTrack:h};let k=Math.max(0,e.syncOffset(t));S-=(S-k)%El,S<t.byteLength&&!n&&(this.remainderData=new Uint8Array(t.buffer,S,t.buffer.byteLength-S));let I=0;for(let e=k;e<S;e+=El)if(71===t[e]){let i,n=!!(64&t[e+1]),S=bl(t,e);if((48&t[e+3])>>4>1){if(i=e+5+t[e+4],i===e+El)continue}else i=e+4;switch(S){case m:n&&(f&&!(null!=l&&l.isCorrupted)&&(s=kl(f,this.logger))&&(this.readyVideoParser(o.segmentCodec),null!==this.videoParser&&this.videoParser.parsePES(o,h,s,!1,r)),f={data:[],size:0},null==l||l.reset(m)),null==l||l.handlePacket(t.subarray(e)),f&&(f.data.push(t.subarray(i,e+El)),f.size+=e+El-i);break;case p:if(c)break;if(n){if(E&&(s=kl(E,this.logger)))switch(d.segmentCodec){case"aac":this.parseAACPES(d,s,r);break;case"mp3":this.parseMPEGPES(d,s);break;case"ac3":this.parseAC3PES(d,s)}E={data:[],size:0}}E&&(E.data.push(t.subarray(i,e+El)),E.size+=e+El-i);break;case g:if(c)break;n&&(y&&(s=kl(y,this.logger))&&this.parseID3PES(u,s),y={data:[],size:0}),y&&(y.data.push(t.subarray(i,e+El)),y.size+=e+El-i);break;case v:if(c)break;n&&(b&&(s=kl(b,this.logger))&&this.parseKlvPES(u,s),b={data:[],size:0}),b&&(b.data.push(t.subarray(i,e+El)),b.size+=e+El-i);break;case 0:n&&(i+=t[i]+1),_=this._pmtId=Tl(t,i);break;case _:{n&&(i+=t[i]+1);let s=Al(t,i,this.typeSupported,a,this.observer,this.logger,this.config,r);m=s.videoPid,m>0&&(o.pid=m,o.segmentCodec=s.segmentVideoCodec),p=s.audioPid,p>0&&(d.pid=p,d.segmentCodec=s.segmentAudioCodec),g=s.id3Pid,g>0&&(u.pid=g),v=s.klvPid,v>0&&(this._klvPid=v),null!==T&&!A&&(this.logger.warn(`MPEG-TS PMT found at ${e} after unknown PID '${T}'. Backtracking to sync byte @${k} to parse all TS packets.`),T=null,e=k-188),A=this.pmtParsed=!0;break}case 17:case 8191:break;default:T=S}}else I++;I>0&&_l(this.observer,new Error(`Found ${I} TS packet/s that do not start with 0x47`),r,void 0,this.logger),o.pesData=f,d.pesData=E,u.pesData=y;let R={audioTrack:d,videoTrack:o,id3Track:u,textTrack:h};return n&&this.extractRemainingSamples(R,r),R}flush(e,t){let i,{remainderData:r}=this;return this.remainderData=null,i=r?this.demux(r,0,t,!1,!0):{videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(i,t),this.sampleAes?this.decrypt(i,this.sampleAes):i}extractRemainingSamples(e,t){let i,{audioTrack:r,videoTrack:a,id3Track:n,textTrack:s}=e,o=a.pesData,l=r.pesData,d=n.pesData,u=this.videoIntegrityChecker;if(!o||null!=u&&u.isCorrupted||!(i=kl(o,this.logger))?a.pesData=o:(this.readyVideoParser(a.segmentCodec),null!==this.videoParser&&(this.videoParser.parsePES(a,s,i,!0,t),a.pesData=null)),l&&(i=kl(l,this.logger))){switch(r.segmentCodec){case"aac":this.parseAACPES(r,i,t);break;case"mp3":this.parseMPEGPES(r,i);break;case"ac3":this.parseAC3PES(r,i)}r.pesData=null}else null!=l&&l.size&&this.logger.log("last AAC PES packet truncated,might overlap between fragments"),r.pesData=l;d&&(i=kl(d,this.logger))?(this.parseID3PES(n,i),n.pesData=null):n.pesData=d}demuxSampleAes(e,t,i,r){let a=this.demux(e,i,r,!0,!this.config.progressive),n=this.sampleAes=new dl(this.observer,this.config,t);return this.decrypt(a,n)}readyVideoParser(e){null===this.videoParser&&("avc"===e?this.videoParser=new gl:"hevc"===e&&(this.videoParser=new vl))}decrypt(e,t){return new Promise(i=>{let{audioTrack:r,videoTrack:a}=e;r.samples&&"aac"===r.segmentCodec?t.decryptAacSamples(r.samples,0,()=>{a.samples?t.decryptAvcSamples(a.samples,0,0,()=>{i(e)}):i(e)}):a.samples&&t.decryptAvcSamples(a.samples,0,0,()=>{i(e)})})}destroy(){this.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,this.videoIntegrityChecker=null}parseAACPES(e,t,i){let r,a,n,s=0,o=this.aacOverFlow,l=t.data;if(o){this.aacOverFlow=null;let t=o.missing,i=o.sample.unit.byteLength;if(-1===t)l=sa(o.sample.unit,l);else{let r=i-t;o.sample.unit.set(l.subarray(0,t),r),e.samples.push(o.sample),s=o.missing}}for(r=s,a=l.length;r<a-1&&!Vo(l,r);r++);if(r!==s){let e,t=r<a-1;if(e=t?`AAC PES did not start with ADTS header,offset:${r}`:"No ADTS header found in AAC PES",_l(this.observer,new Error(e),i,t,this.logger),!t)return}if(Yo(e,this.observer,l,r,this.audioCodec),void 0!==t.pts)n=t.pts;else{if(!o)return void this.logger.warn("[tsdemuxer]: AAC PES unknown PTS");{let t=jo(e.samplerate);n=o.sample.pts+t}}let d,u=0;for(;r<a;){if(d=zo(e,l,r,n,u),r+=d.length,d.missing){this.aacOverFlow=d;break}for(u++;r<a-1&&!Vo(l,r);r++);}}parseMPEGPES(e,t){let i=t.data,r=i.length,a=0,n=0,s=t.pts;if(void 0!==s)for(;n<r;)if(ol(i,n)){let t=al(e,i,n,s,a);if(!t)break;n+=t.length,a++}else n++;else this.logger.warn("[tsdemuxer]: MPEG PES unknown PTS")}parseAC3PES(e,t){{let i=t.data,r=t.pts;if(void 0===r)return void this.logger.warn("[tsdemuxer]: AC3 PES unknown PTS");let a,n=i.length,s=0,o=0;for(;o<n&&(a=hl(e,i,o,r,s++))>0;)o+=a}}parseID3PES(e,t){if(void 0===t.pts)return void this.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");let i=$i({},t,{type:this._videoTrack?Qo.emsg:Qo.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(i)}parseKlvPES(e,t){var i;let r=null!=(i=t.pts)?i:t.dts;if(void 0===r)return void this.logger.warn("[tsdemuxer]: KLV PES unknown PTS and DTS");let a=t.data;if(a.length<16)return void this.logger.warn("[tsdemuxer]: KLV PES payload too short");let n=0;for(;n<a.length;){var s;if(n+16>a.length)break;let i=n;if(n+=16,n>=a.length)break;let o=a[n];n+=1;let l=0;if(128&o){let e=127&o;if(0===e||e>4||n+e>a.length){this.logger.warn("[tsdemuxer]: Invalid KLV length encoding");break}for(let t=0;t<e;t++)l=l<<8|a[n+t];n+=e}else l=o;if(n+l>a.length){this.logger.warn("[tsdemuxer]: KLV value extends beyond PES payload");break}let d=n+l,u=a.subarray(i,d),h={data:u,len:u.byteLength,pts:r,dts:null!=(s=t.dts)?s:r,type:Qo.misbklv,duration:Number.POSITIVE_INFINITY};e.samples.push(h),n=d}}};function bl(e,t){return((31&e[t+1])<<8)+e[t+2]}function Tl(e,t){return(31&e[t+10])<<8|e[t+11]}function Al(e,t,i,r,a,n,s,o){let l={audioPid:-1,videoPid:-1,id3Pid:-1,klvPid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},d=t+3+((15&e[t+1])<<8|e[t+2])-4;for(t+=12+((15&e[t+10])<<8|e[t+11]);t<d;){let d=bl(e,t),u=(15&e[t+3])<<8|e[t+4];switch(e[t]){case 207:if(!r){Sl("ADTS AAC",n);break}case 15:-1===l.audioPid&&(l.audioPid=d);break;case 21:-1===l.id3Pid&&(l.id3Pid=d);break;case 219:if(!r){Sl("H.264",n);break}case 27:-1===l.videoPid&&(l.videoPid=d);break;case 3:case 4:i.mpeg||i.mp3?-1===l.audioPid&&(l.audioPid=d,l.segmentAudioCodec="mp3"):n.log("MPEG audio found, not supported in this browser");break;case 193:if(!r){Sl("AC-3",n);break}case 129:i.ac3?-1===l.audioPid&&(l.audioPid=d,l.segmentAudioCodec="ac3"):n.log("AC-3 audio found, not supported in this browser");break;case 6:if(u>0){let r=t+5,a=u;for(;a>2;){switch(e[r]){case 106:-1===l.audioPid&&(!0!==i.ac3?n.log("AC-3 audio found, not supported in this browser for now"):(l.audioPid=d,l.segmentAudioCodec="ac3"));break;case 5:-1===l.klvPid&&s.enableEmsgKLVMetadata&&(l.klvPid=d,n.log(`KLV metadata PID found: ${d}`))}let t=e[r+1]+2;r+=t,a-=t}}break;case 194:case 135:return _l(a,new Error("Unsupported EC-3 in M2TS found"),o,void 0,n),l;case 36:-1===l.videoPid&&(l.videoPid=d,l.segmentVideoCodec="hevc",n.log("HEVC in M2TS found"))}t+=u+5}return l}function _l(e,t,i,r,a){a.warn(`parsing error: ${t.message}`),e.emit(Ai.ERROR,Ai.ERROR,{type:bi.MEDIA_ERROR,details:Ti.FRAG_PARSING_ERROR,fatal:!1,levelRetry:r,chunkMeta:i,error:t,reason:t.message})}function Sl(e,t){t.log(`${e} with AES-128-CBC encryption found in unencrypted stream`)}function kl(e,t){let i,r,a,n,s,o=0,l=e.data;if(!e||0===e.size)return null;for(;l[0].length<19&&l.length>1;)l[0]=sa(l[0],l[1]),l.splice(1,1);if(i=l[0],(i[0]<<16)+(i[1]<<8)+i[2]===1){if(r=(i[4]<<8)+i[5],r&&r>e.size-6)return null;let d=i[7];192&d&&(n=536870912*(14&i[9])+4194304*(255&i[10])+16384*(254&i[11])+128*(255&i[12])+(254&i[13])/2,64&d?(s=536870912*(14&i[14])+4194304*(255&i[15])+16384*(254&i[16])+128*(255&i[17])+(254&i[18])/2,n-s>54e5&&(t.warn(`${Math.round((n-s)/9e4)}s delta between PTS and DTS, align them`),n=s)):s=n),a=i[8];let u=a+9;if(e.size<=u)return null;e.size-=u;let h=new Uint8Array(e.size);for(let e=0,t=l.length;e<t;e++){i=l[e];let t=i.byteLength;if(u){if(u>t){u-=t;continue}i=i.subarray(u),t-=u,u=0}h.set(i,o),o+=t}return r&&(r-=a+3),{data:h,pts:n,dts:s,len:r}}return null}var Il,Rl=class{constructor(e){this.logger=void 0,this.pid=0,this.lastContinuityCounter=-1,this.integrityState="ok",this.logger=e}get isCorrupted(){return"ok"!==this.integrityState}reset(e){this.pid=e,this.lastContinuityCounter=-1,this.integrityState="ok"}handlePacket(e){if(e.byteLength<4)return;let t=bl(e,0);if(t!==this.pid)return void this.logger.debug(`Packet PID mismatch, expected ${this.pid} got ${t}`);let i=(48&e[3])>>4;if(0===i)return;let r=15&e[3],a=this.lastContinuityCounter;this.lastContinuityCounter=r;let n=!!(1&i);if(2&i&&0!=e[4]&&128&e[5]||a<0)return;let s=n?a+1&15:a;return r!==s?(this.logger.warn(`MPEG-TS Continuity Counter check failed for PID='${t}', CC=${r}, Expected-CC=${s} Last-CC=${a}`),void(this.integrityState="cc-failed")):128&e[1]?(this.logger.warn(`MPEG-TS Packet had TEI flag set for PID='${t}'`),void(this.integrityState="tei-bit")):void 0}},Ll=class{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]);if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(6===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(1===t)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(3===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}}},wl={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])},Dl=new Uint8Array([0,0,0,0,0,0,0,0]),Cl=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),Ml=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),Pl=new Uint8Array([0,0,0,0,0,0,0,0]),xl=new Uint8Array([0,0,0,0,0,0,0,1]),Ol=new Uint8Array([105,115,111,109]),Nl=new Uint8Array([97,118,99,49]),Ul=new Uint8Array([0,0,0,1]),Fl=class e{static box(e,...t){let i=8,r=t.length,a=r;for(;r--;)i+=t[r].byteLength;let n=new Uint8Array(i);for(Kr(n,0,i),Kr(n,4,e),r=0,i=8;r<a;r++)n.set(t[r],i),i+=t[r].byteLength;return n}static hdlr(t){return e.box(Nr.hdlr,wl[t])}static mdat(t){return e.box(Nr.mdat,t)}static mdhd(t,i){i*=t;let r=Math.floor(i/(Or+1)),a=Math.floor(i%(Or+1));return e.box(Nr.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,r>>24,r>>16&255,r>>8&255,255&r,a>>24,a>>16&255,a>>8&255,255&a,85,196,0,0]))}static mdia(t){return e.box(Nr.mdia,e.mdhd(t.timescale||0,t.duration||0),e.hdlr(t.type),e.minf(t))}static mfhd(t){return e.box(Nr.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))}static minf(t){return"audio"===t.type?e.box(Nr.minf,e.box(Nr.smhd,Pl),e.DINF,e.stbl(t)):e.box(Nr.minf,e.box(Nr.vmhd,Ml),e.DINF,e.stbl(t))}static moof(t,i,r){return e.box(Nr.moof,e.mfhd(t),e.traf(r,i))}static moov(t){let i=t.length,r=[];for(;i--;)r[i]=e.trak(t[i]);return e.box.apply(null,[Nr.moov,e.mvhd(t[0].timescale||0,t[0].duration||0)].concat(r).concat(e.mvex(t)))}static mvex(t){let i=t.length,r=[];for(;i--;)r[i]=e.trex(t[i]);return e.box.apply(null,[Nr.mvex,...r])}static mvhd(t,i){i*=t;let r=Math.floor(i/(Or+1)),a=Math.floor(i%(Or+1)),n=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,r>>24,r>>16&255,r>>8&255,255&r,a>>24,a>>16&255,a>>8&255,255&a,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return e.box(Nr.mvhd,n)}static sdtp(t){let i,r,a=t.samples||[],n=new Uint8Array(4+a.length);for(i=0;i<a.length;i++)r=a[i].flags,n[i+4]=r.dependsOn<<4|r.isDependedOn<<2|r.hasRedundancy;return e.box(Nr.sdtp,n)}static stbl(t){return e.box(Nr.stbl,e.stsd(t),e.box(Nr.stts,Dl),e.box(Nr.stsc,Dl),e.box(Nr.stsz,Cl),e.box(Nr.stco,Dl))}static avc1(t){let i,r,a,n=[],s=[];for(i=0;i<t.sps.length;i++)r=t.sps[i],a=r.byteLength,n.push(a>>>8&255),n.push(255&a),n=n.concat(Array.prototype.slice.call(r));for(i=0;i<t.pps.length;i++)r=t.pps[i],a=r.byteLength,s.push(a>>>8&255),s.push(255&a),s=s.concat(Array.prototype.slice.call(r));let o=e.box(Nr.avcC,new Uint8Array([1,n[3],n[4],n[5],255,224|t.sps.length].concat(n).concat([t.pps.length]).concat(s))),l=t.width,d=t.height,u=t.pixelRatio[0],h=t.pixelRatio[1];return e.box(Nr.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,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]),o,e.box(Nr.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),e.box(Nr.pasp,new Uint8Array([u>>24,u>>16&255,u>>8&255,255&u,h>>24,h>>16&255,h>>8&255,255&h])))}static esds(e){let t=e.config,i=t.length;return new Uint8Array([0,0,0,0,3,23+i,0,1,0,4,15+i,64,21,0,0,0,0,0,0,0,0,0,0,0,5,i,...t,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(t){return e.box(Nr.mp4a,e.audioStsd(t),e.box(Nr.esds,e.esds(t)))}static mp3(t){return e.box(Nr[".mp3"],e.audioStsd(t))}static ac3(t){return e.box(Nr["ac-3"],e.audioStsd(t),e.box(Nr.dac3,t.config))}static stsd(t){let{segmentCodec:i}=t;if("audio"===t.type){if("aac"===i)return e.box(Nr.stsd,xl,e.mp4a(t));if("ac3"===i&&t.config)return e.box(Nr.stsd,xl,e.ac3(t));if("mp3"===i&&"mp3"===t.codec)return e.box(Nr.stsd,xl,e.mp3(t))}else{if(!t.pps||!t.sps)throw new Error("video track missing pps or sps");if("avc"===i)return e.box(Nr.stsd,xl,e.avc1(t));if("hevc"===i&&t.vps)return e.box(Nr.stsd,xl,e.hvc1(t))}throw new Error(`unsupported ${t.type} segment codec (${i}/${t.codec})`)}static tkhd(t){let i=t.id,r=(t.duration||0)*(t.timescale||0),a=t.width||0,n=t.height||0,s=Math.floor(r/(Or+1)),o=Math.floor(r%(Or+1));return e.box(Nr.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,i>>24&255,i>>16&255,i>>8&255,255&i,0,0,0,0,s>>24,s>>16&255,s>>8&255,255&s,o>>24,o>>16&255,o>>8&255,255&o,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,a>>8&255,255&a,0,0,n>>8&255,255&n,0,0]))}static traf(t,i){let r=e.sdtp(t),a=t.id,n=Math.floor(i/(Or+1)),s=Math.floor(i%(Or+1));return e.box(Nr.traf,e.box(Nr.tfhd,new Uint8Array([0,0,0,0,a>>24,a>>16&255,a>>8&255,255&a])),e.box(Nr.tfdt,new Uint8Array([1,0,0,0,n>>24,n>>16&255,n>>8&255,255&n,s>>24,s>>16&255,s>>8&255,255&s])),e.trun(t,r.length+16+20+8+16+8+8),r)}static trak(t){return t.duration=t.duration||4294967295,e.box(Nr.trak,e.tkhd(t),e.mdia(t))}static trex(t){let i=t.id;return e.box(Nr.trex,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(t,i){let r,a,n,s,o,l,d=t.samples||[],u=d.length,h=12+16*u,c=new Uint8Array(h);for(i+=8+h,c.set(["video"===t.type?1:0,0,15,1,u>>>24&255,u>>>16&255,u>>>8&255,255&u,i>>>24&255,i>>>16&255,i>>>8&255,255&i],0),r=0;r<u;r++)a=d[r],n=a.duration,s=a.size,o=a.flags,l=a.cts,c.set([n>>>24&255,n>>>16&255,n>>>8&255,255&n,s>>>24&255,s>>>16&255,s>>>8&255,255&s,o.isLeading<<2|o.dependsOn,o.isDependedOn<<6|o.hasRedundancy<<4|o.paddingValue<<1|o.isNonSync,61440&o.degradPrio,15&o.degradPrio,l>>>24&255,l>>>16&255,l>>>8&255,255&l],12+16*r);return e.box(Nr.trun,c)}static initSegment(t){let i=e.moov(t);return sa(e.FTYP,i)}static hvc1(t){let i=t.params,r=[t.vps,t.sps,t.pps],a=new Uint8Array([1,i.general_profile_space<<6|(i.general_tier_flag?32:0)|i.general_profile_idc,i.general_profile_compatibility_flags[0],i.general_profile_compatibility_flags[1],i.general_profile_compatibility_flags[2],i.general_profile_compatibility_flags[3],i.general_constraint_indicator_flags[0],i.general_constraint_indicator_flags[1],i.general_constraint_indicator_flags[2],i.general_constraint_indicator_flags[3],i.general_constraint_indicator_flags[4],i.general_constraint_indicator_flags[5],i.general_level_idc,240|i.min_spatial_segmentation_idc>>8,255&i.min_spatial_segmentation_idc,252|i.parallelismType,252|i.chroma_format_idc,248|i.bit_depth_luma_minus8,248|i.bit_depth_chroma_minus8,0,parseInt(i.frame_rate.fps),3|i.temporal_id_nested<<2|i.num_temporal_layers<<3|(i.frame_rate.fixed?64:0),r.length]),n=a.length;for(let e=0;e<r.length;e+=1){n+=3;for(let t=0;t<r[e].length;t+=1)n+=2+r[e][t].length}let s=new Uint8Array(n);s.set(a,0),n=a.length;let o=r.length-1;for(let e=0;e<r.length;e+=1){s.set(new Uint8Array([32+e|(e===o?128:0),0,r[e].length]),n),n+=3;for(let t=0;t<r[e].length;t+=1)s.set(new Uint8Array([r[e][t].length>>8,255&r[e][t].length]),n),n+=2,s.set(r[e][t],n),n+=r[e][t].length}let l=e.box(Nr.hvcC,s),d=t.width,u=t.height,h=t.pixelRatio[0],c=t.pixelRatio[1];return e.box(Nr.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,d>>8&255,255&d,u>>8&255,255&u,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,e.box(Nr.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),e.box(Nr.pasp,new Uint8Array([h>>24,h>>16&255,h>>8&255,255&h,c>>24,c>>16&255,c>>8&255,255&c])))}};Il=Fl,Fl.FTYP=Il.box(Nr.ftyp,Ol,Ul,Ol,Nl),Fl.DINF=Il.box(Nr.dinf,Il.box(Nr.dref,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1])));function Bl(e,t,i=1,r=!1){let a=e*t*i;return r?Math.round(a):a}function $l(e,t=!1){return Bl(e,1e3,1/9e4,t)}function Hl(e){let{baseTime:t,timescale:i,trackId:r}=e;return`${t/i} (${t}/${i}) trackId: ${r}`}var Gl=8589934592;function Kl(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?0:1,paddingValue:0}}}var Wl=class extends tr{constructor(e,t,i,r){super("mp4-remuxer",r),this.observer=void 0,this.config=void 0,this.typeSupported=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}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&&Hl(t)} > ${e&&Hl(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 a=r.pts,n=a-e;return n<-4294967296&&(t=!0,a=Vl(a,i),n=a-e),n>0?e:a},i);return t&&this.debug("PTS rollover detected"),r}remux(e,t,i,r,a,n,s,o,l){let d,u,h,c,m,f,p=a,g=a,v=!l.iframe&&e.pid>-1,E=t.pid>-1,y=t.samples.length,b=e.samples.length>0,T=s&&y>0||y>1;if((!v||b)&&(!E||T)||this.ISGenerated||s){if(this.ISGenerated){var A,_,S,k;let e=this.videoTrackConfig;(e&&(t.width!==e.width||t.height!==e.height||(null==(A=t.pixelRatio)?void 0:A[0])!==(null==(_=e.pixelRatio)?void 0:_[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,a,n));let i,r=this.isVideoContiguous,s=-1;if(T&&(s=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,s>0){this.warn(`Dropped ${s} out of ${y} video samples due to a missing keyframe`);let e=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(s),t.dropped+=s,g+=(t.samples[0].pts-e)/t.inputTimeScale,i=g}else-1===s&&(this.warn(`No keyframe found out of ${y} video samples`),f=!1);if(this.ISGenerated){if(b&&T&&a){let i=this.getVideoStartPts(t.samples),r=(Vl(e.samples[0].pts,i)-i)/t.inputTimeScale;p+=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,a,n)),u=this.remuxAudio(e,p,this.isAudioContiguous,n,E||T||o===Li.AUDIO?g:void 0,l),T){let i=u?u.endPTS-u.startPTS:0;t.inputTimeScale||(this.warn("regenerate InitSegment as video detected"),h=this.generateIS(e,t,a,n)),d=this.remuxVideo(t,g,r,i,l)}}else T&&(d=this.remuxVideo(t,g,r,0,l));d&&(d.firstKeyFrame=s,d.independent=-1!==s,d.firstKeyFramePTS=i)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(i.samples.length&&(m=ql(i,a,this._initPTS,this._initDTS)),r.samples.length&&(c=Yl(r,a,this._initPTS))),{audio:u,video:d,initSegment:h,independent:f,text:c,id3:m}}computeInitPts(e,t,i,r){let a=Math.round(i*t),n=Vl(e,a);if(n<a)for(this.log(`Adjusting PTS for rollover in timeline near ${(a-n)/t} ${r}`);n<a;)n+=Gl;return n-a}generateIS(e,t,i,r){let a,n,s,o=e.samples,l=t.samples,d=this.typeSupported,u={},h=this._initPTS,c=!h||r,m="audio/mp4",f=-1;if(c&&(a=n=1/0),e.config&&o.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":d.mpeg?(m="audio/mpeg",e.codec=""):d.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3"}if(u.audio={id:"audio",container:m,codec:e.codec,initSegment:"mp3"===e.segmentCodec&&d.mpeg?new Uint8Array(0):Fl.initSegment([e]),metadata:{channelCount:e.channelCount}},c){f=e.id,s=e.inputTimeScale;let t=this.computeInitPts(o[0].pts,s,i,"audio");(!h||s!==h.timescale||0===i&&t<h.baseTime)&&(a=n=t)}}if(t.sps&&t.pps&&l.length){if(t.timescale=t.inputTimeScale,u.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:Fl.initSegment([t]),metadata:{width:t.width,height:t.height}},c){f=t.id,s=t.inputTimeScale;let e=this.getVideoStartPts(l),r=Vl(l[0].dts,e),o=this.computeInitPts(r,s,i,"video"),d=this.computeInitPts(e,s,i,"video");(!h||s!==h.timescale||vi(a)||0===i&&d<h.baseTime)&&(n=Math.min(n,o),a=Math.min(a,o))}this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(u).length)return this.ISGenerated=!0,c&&vi(a)?(h&&this.warn(`Timestamps at playlist time: ${r?"":"~"}${i} ${a/s} != initPTS: ${h.baseTime/h.timescale} (${h.baseTime}/${h.timescale}) trackId: ${h.trackId}`),this.log(`Found initPTS at playlist time: ${i} offset: ${a/s} (${a}/${s}) trackId: ${f}`),this._initPTS={baseTime:a,timescale:s,trackId:f},this._initDTS={baseTime:n,timescale:s,trackId:f}):a=s=void 0,{tracks:u,initPTS:a,timescale:s,trackId:f}}remuxVideo(e,t,i,r,a){let n,s,o=e.inputTimeScale,l=e.samples,d=[],u=l.length,h=this._initPTS,c=h.baseTime*o/h.timescale,m=this.nextVideoTs,f=8,p=this.videoSampleDuration,g=Number.POSITIVE_INFINITY,v=Number.NEGATIVE_INFINITY,E=!1;if(!i||null===m){let e=c+t*o,r=l[0].pts-Vl(l[0].dts,l[0].pts);ba()&&null!==m&&Math.abs(e-r-(m+c))<15e3?i=!0:m=e-r-c}let y=m+c;for(let e=0;e<u;e++){let t=l[e];t.pts=Vl(t.pts,y),t.dts=Vl(t.dts,y),t.dts<l[e>0?e-1:e].dts&&(E=!0)}E&&l.sort(function(e,t){let i=e.dts-t.dts,r=e.pts-t.pts;return i||r}),n=l[0].dts,s=l[l.length-1].dts;let b=s-n,T=b?Math.round(b/(u-1)):p||e.inputTimeScale/30;if(i){let i=n-y,r=i>T,a=i<-1;if((r||a)&&(r?this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${$l(i,!0)} ms (${i}dts) hole between fragments detected at ${t.toFixed(3)}`):this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${$l(-i,!0)} ms (${i}dts) overlapping between fragments detected at ${t.toFixed(3)}`),!a||y>=l[0].pts||ba())){n=y;let e=l[0].pts-i;if(r)l[0].dts=n,l[0].pts=e;else{let t=!0;for(let r=0;r<l.length&&!(l[r].dts>e&&t);r++){let e=l[r].pts;if(l[r].dts-=i,l[r].pts-=i,r<l.length-1){let i=l[r+1].pts;t=i<=l[r].pts==i<=e}}}this.log(`Video: Initial PTS/DTS adjusted: ${$l(e,!0)}/${$l(n,!0)}, delta: ${$l(i,!0)} ms`)}}n=Math.max(0,n);let A=0,_=0,S=n;for(let e=0;e<u;e++){let t=l[e],i=t.units,r=i.length,a=0;for(let e=0;e<r;e++)a+=i[e].data.length;_+=a,A+=r,t.length=a,t.dts<S?(t.dts=S,S+=T/4|0||1):S=t.dts,g=Math.min(t.pts,g),v=Math.max(t.pts,v)}s=l[u-1].dts;let k,I=_+4*A+8;try{k=new Uint8Array(I)}catch(e){return void this.observer.emit(Ai.ERROR,Ai.ERROR,{type:bi.MUX_ERROR,details:Ti.REMUX_ALLOC_ERROR,fatal:!1,chunkMeta:a,error:e,bytes:I,reason:`fail allocating video mdat ${I}`})}Kr(k,0,I),Kr(k,4,Nr.mdat);let R=!1,L=Number.POSITIVE_INFINITY,w=Number.POSITIVE_INFINITY,D=Number.NEGATIVE_INFINITY,C=Number.NEGATIVE_INFINITY;for(let e=0;e<u;e++){let t,n=l[e],s=n.units,h=0;for(let e=0,t=s.length;e<t;e++){let t=s[e],i=t.data,r=t.data.byteLength;Kr(k,f,r),f+=4,k.set(i,f),f+=r,h+=4+r}if(e<u-1)p=l[e+1].dts-n.dts,t=l[e+1].pts-n.pts;else{let i=this.config,a=e>0?n.dts-l[e-1].dts:T;if(t=e>0?n.pts-l[e-1].pts:T,i.stretchShortVideoTrack&&null!==this.nextAudioTs){let e=Math.floor(i.maxBufferHole*o),t=(r?g+r*o:this.nextAudioTs+c)-n.pts;t>e?(p=t-a,p<0?p=a:R=!0,this.log(`It is approximately ${t/90} ms to the next segment; using duration ${p/90} ms for the last video frame.`)):p=a}else p=a}let m=Math.round(n.pts-n.dts);if(L=Math.min(L,p),D=Math.max(D,p),w=Math.min(w,t),C=Math.max(C,t),!i&&0===e&&m>p){let e=Math.round(m/T)*T;e-m===1&&(this.log(`pad first CTS ${m} -> ${e} of sn: ${a.sn}`),m=e)}d.push(Kl(n.key,p,h,m))}if(d.length){let e=ba();if(e){if(e<70){let e=d[0].flags;e.dependsOn=2,e.isNonSync=0}}else if(function(){if(void 0===ga){let e=va.match(/Safari\/(\d+)/i);ga=e?parseInt(e[1]):0}return ga}()&&C-w<D-L&&T/D<.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=n;for(let t=0,i=d.length;t<i;t++){let r=e+d[t].duration,a=e+d[t].cts;if(t<i-1){let e=r+d[t+1].cts;d[t].duration=e-a}else d[t].duration=t?d[t-1].duration:T;d[t].cts=0,e=r}}}p=R||!p?T:p;let M=s+p;this.nextVideoTs=m=M-c,this.videoSampleDuration=p,this.isVideoContiguous=!0,a.iframe&&(1===d.length?(d[0].duration=p=a.duration*o,this.nextVideoTs=m=n+p-c):this.warn(`Not adjusting IFrame duration (sample count ${d.length})`));let P={data1:Fl.moof(a.sn,n,$i(e,{samples:d})),data2:k,startPTS:(g-c)/o,endPTS:(v+p-c)/o,startDTS:(n-c)/o,endDTS:m/o,type:"video",hasAudio:!1,hasVideo:!0,nb:d.length,dropped:e.dropped};return e.samples=[],e.dropped=0,P}getSamplesPerFrame(e){switch(e.segmentCodec){case"mp3":return 1152;case"ac3":return 1536;default:return 1024}}remuxAudio(e,t,i,r,a,n){let s=e.inputTimeScale,o=s/(e.samplerate?e.samplerate:s),l=this.getSamplesPerFrame(e),d=l*o,u=this._initPTS,h="mp3"===e.segmentCodec&&this.typeSupported.mpeg,c=[],m=void 0!==a,f=e.samples,p=h?0:8,g=this.nextAudioTs||-1,v=u.baseTime*s/u.timescale,E=v+t*s;if(this.isAudioContiguous=i=i||f.length&&g>0&&(r&&Math.abs(E-(g+v))<9e3||Math.abs(Vl(f[0].pts,E)-(g+v))<20*d),f.forEach(function(e){e.pts=Vl(e.pts,E)}),!i||g<0){let e=f.length;if(f=f.filter(e=>e.pts>=0),e!==f.length&&this.warn(`Removed ${f.length-e} of ${e} samples (initPTS ${v} / ${s})`),!f.length)return;g=0===a?0:r&&!m?Math.max(0,E-v):f[0].pts-v}if("aac"===e.segmentCodec){let t=this.config.maxAudioFramesDrift;for(let i=0,r=g+v;i<f.length;i++){let a=f[i],n=a.pts,o=n-r,l=Math.abs(1e3*o/s);if(o<=-t*d&&m)0===i&&(this.warn(`Audio frame @ ${(n/s).toFixed(3)}s overlaps marker by ${Math.round(1e3*o/s)} ms.`),this.nextAudioTs=g=n-v,r=n);else if(o>=t*d&&l<1e4&&m){let t=Math.round(o/d);for(r=n-t*d;r<0&&t&&d;)t--,r+=d;0===i&&(this.nextAudioTs=g=r-v),this.warn(`Injecting ${t} audio frames @ ${((r-v)/s).toFixed(3)}s due to ${Math.round(1e3*o/s)} ms gap.`);for(let n=0;n<t;n++){let t=Ll.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=a.unit.subarray()),f.splice(i,0,{unit:t,pts:r}),r+=d,i++}}a.pts=r,r+=d}}let y,b=null,T=null,A=0,_=f.length;for(;_--;)A+=f[_].unit.byteLength;for(let t=0,r=f.length;t<r;t++){let r=f[t],a=r.unit,s=r.pts;if(null!==T){c[t-1].duration=Math.round((s-T)/o)}else{if(i&&"aac"===e.segmentCodec&&(s=g+v),b=s,!(A>0))return;A+=p;try{y=new Uint8Array(A)}catch(e){return void this.observer.emit(Ai.ERROR,Ai.ERROR,{type:bi.MUX_ERROR,details:Ti.REMUX_ALLOC_ERROR,fatal:!1,chunkMeta:n,error:e,bytes:A,reason:`fail allocating audio mdat ${A}`})}h||(Kr(y,0,A),Kr(y,4,Nr.mdat))}y&&y.set(a,p);let d=a.byteLength;p+=d,c.push(Kl(!0,l,d,0)),T=s}let S=c.length;if(!S)return;let k=c[c.length-1];g=T-v,this.nextAudioTs=g+o*k.duration;let I=h?new Uint8Array(0):Fl.moof(e.sequenceNumber++,b/o,$i({},e,{samples:c}));e.samples=[];let R=(b-v)/s,L=this.nextAudioTs/s,w={data1:I,data2:y,startPTS:R,endPTS:L,startDTS:R,endDTS:L,type:"audio",hasAudio:!0,hasVideo:!1,nb:S};return this.isAudioContiguous=!0,w}};function Vl(e,t){let i;if(null===t)return e;for(i=t<e?-Gl:Gl;Math.abs(e-t)>4294967296;)e+=i;return e}function ql(e,t,i,r){let a=e.samples.length;if(!a)return;let n=e.inputTimeScale;for(let s=0;s<a;s++){let a=e.samples[s];a.pts=Vl(a.pts-i.baseTime*n/i.timescale,t*n)/n,a.dts=Vl(a.dts-r.baseTime*n/r.timescale,t*n)/n}let s=e.samples;return e.samples=[],{samples:s}}function Yl(e,t,i){let r=e.samples.length;if(!r)return;let a=e.inputTimeScale;for(let n=0;n<r;n++){let r=e.samples[n];r.pts=Vl(r.pts-i.baseTime*a/i.timescale,t*a)/a}e.samples.sort((e,t)=>e.pts-t.pts);let n=e.samples;return e.samples=[],{samples:n}}var jl;function zl(e,t,i=!1){return void 0!==(null==e?void 0:e.start)?(e.start+(i?e.duration:0))/e.timescale:t}function Ql(e,t,i){let r=e.codec;return r&&r.length>4?r:t===wi?"ec-3"===r||"ac-3"===r||"alac"===r?r:"fLaC"===r||"Opus"===r?Ca(r,!1):(i.warn(`Unhandled audio codec "${r}" in mp4 MAP`),r||"mp4a"):"mjpg"===r?r:(i.warn(`Unhandled video codec "${r}" in mp4 MAP`),r||"avc1")}try{jl=self.performance.now.bind(self.performance)}catch{jl=Date.now}var Xl=[{demux:class{constructor(e,t,i,r=or){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.initData=void 0,this.logger=void 0,this.config=t,this.logger=r}resetTimeStamp(){}resetInitSegment(e,t,i,r){let a=this.videoTrack=Xo("video",1),n=this.audioTrack=Xo("audio",1),s=this.txtTrack=Xo("text",1);if(this.id3Track=Xo("id3",1),this.initData=void 0,this.timeOffset=0,null==e||!e.byteLength)return;let o=this.initData=Qr(e);if(o.video){let{id:e,timescale:t,codec:i,supplemental:r}=o.video;a.id=e,a.timescale=s.timescale=t,a.codec=i,a.supplemental=r}if(o.audio){let{id:e,timescale:t,codec:i}=o.audio;n.id=e,n.timescale=t,n.codec=i}s.id=Ur.text,a.sampleDuration=0,a.duration=n.duration=r}resetContiguity(){this.remainderData=null}static probe(e){return function(e,t){let i=e.byteLength;for(let r=0;r<i;){let a=Br(e,r);if(a>8&&Br(e,r+4)===Nr[t])return!0;r=a>1?r+a:i}return!1}(e,"moof")}demux(e,t,i){this.timeOffset=t;let r=e,a=this.videoTrack,n=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=sa(this.remainderData,e));let t=function(e){let t={valid:null,remainder:null},i=Yr(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}(r);this.remainderData=t.remainder,a.samples=t.valid||new Uint8Array}else a.samples=r;let s=this.extractID3Track(a,t),o=this.parseFragment(a,n,t,i);return{videoTrack:a,audioTrack:this.audioTrack,id3Track:s,textTrack:this.txtTrack,initData:this.initData,sampleData:o}}flush(e,t){let i=this.timeOffset,r=this.videoTrack,a=this.txtTrack;r.samples=this.remainderData||new Uint8Array,this.remainderData=null;let n=this.extractID3Track(r,this.timeOffset),s=this.parseFragment(r,a,i,t);return{videoTrack:r,audioTrack:Xo(),id3Track:n,textTrack:Xo(),initData:this.initData,sampleData:s}}parseFragment(e,t,i,r){let a=this.initData;if(a&&r){let{samples:n,sampleData:s}=function(e,t,i,r,a=!1){let n=[];return{samples:n,sampleData:{includeSampleDetails:a,tracks:na(t.samples,i,r,a,{isHEVCFlavor:oa(t.codec),samples:n,timeOffset:e,timescale:t.timescale,trackId:t.id})}}}(i,e,a,this.logger,r.iframe);return t.samples=n,s}t.samples=function(e,t){let i=[],r=t.samples,a=t.timescale,n=t.id,s=!1;return Yr(r,["moof"]).map(o=>{let l=o.byteOffset-8;Yr(o,["traf"]).map(o=>{let d=Yr(o,["tfdt"]).map(e=>{let t=e[0],i=Br(e,4);return 1===t&&(i*=Math.pow(2,32),i+=Br(e,8)),i/a})[0];return void 0!==d&&(e=d),Yr(o,["tfhd"]).map(d=>{let u=Br(d,4),h=16777215&Br(d,0),c=!!(1&h),m=0,f=!!(2&h),p=!!(8&h),g=0,v=!!(16&h),E=0,y=!!(32&h),b=!c&&!!(131072&h),T=8;u===n&&(c?(m=Br(d,T),T+=4,m*=Math.pow(2,32),m+=Br(d,T),T+=4):b&&(m=l),f&&(T+=4),p&&(g=Br(d,T),T+=4),v&&(E=Br(d,T),T+=4),y&&(T+=4),"video"===t.type&&(s=oa(t.codec)),Yr(o,["trun"]).map(n=>{let o=n[0],l=16777215&Br(n,0),d=!!(1&l),u=0,h=!!(4&l),c=!!(256&l),f=0,p=!!(512&l),v=0,y=!!(1024&l),b=!!(2048&l),T=0,A=Br(n,4),_=8;d&&(u=Br(n,_),_+=4),h&&(_+=4);let S=m+u;for(let l=0;l<A;l++){if(c?(f=Br(n,_),_+=4):f=g,p?(v=Br(n,_),_+=4):v=E,y&&(_+=4),b&&(T=0===o?Br(n,_):Gr(n,_),_+=4),t.type===Di){let t=0;for(;t<v;){let n=Br(r,S);S+=4,la(s,r[S])&&da(r.subarray(S,S+n),s?2:1,e+T/a,i),S+=n,t+=n+4}}e+=f/a}}))})})}),i}(i,e)}extractID3Track(e,t){let i=this.id3Track;if(e.samples.length){let r=Yr(e.samples,["emsg"]);r&&r.forEach(e=>{let r=function(e){let t,i=e[0],r="",a="",n=0,s=0,o=0,l=0,d=4;if(0===i){let t=Hr(e,d),i=null!==t?Hr(e,d+t.length):null;null!==t&&null!==i?(r=t,a=i,d+=t.length+i.length,n=Br(e,d),d+=4,s=Br(e,d),d+=4,o=Br(e,d),d+=4,l=Br(e,d),d+=4):(or.warn(`Unterminated ${null===t?"scheme_id_uri":"value"} in parsing emsg box: version 0 box ends inside a string, dropping all of its fields`),d=e.length)}else if(1===i){n=Br(e,d),d+=4;let i=Br(e,d);d+=4;let s=Br(e,d);d+=4,t=2**32*i+s,Ei(t)||(t=Number.MAX_SAFE_INTEGER,or.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=Br(e,d),d+=4,l=Br(e,d),d+=4;let u=Hr(e,d),h=null!==u?Hr(e,d+u.length):null;null!==u&&(r=u,d+=u.length),null!==h?(a=h,d+=h.length):(or.warn(`Unterminated ${null===u?"scheme_id_uri":"value"} in parsing emsg box: version 1 box ends inside a string, dropping its ${null===u?"strings and payload":"value and payload"}`),d=e.length)}return{schemeIdUri:r,value:a,timeScale:n,presentationTime:t,presentationTimeDelta:s,eventDuration:o,id:l,payload:e.subarray(d,e.byteLength)}}(e);if(cl.test(r.schemeIdUri)){let e=ml(r,t),a=4294967295===r.eventDuration?Number.POSITIVE_INFINITY:r.eventDuration/r.timeScale;a<=.001&&(a=Number.POSITIVE_INFINITY);let n=r.payload;i.samples.push({data:n,len:n.byteLength,dts:e,pts:e,type:Qo.emsg,duration:a})}else if(this.config.enableEmsgKLVMetadata){let e=this.config.emsgKLVSchemaUri||Qo.misbklv;if(r.schemeIdUri.startsWith(e)){let e=ml(r,t);i.samples.push({data:r.payload,len:r.payload.byteLength,dts:e,pts:e,type:Qo.misbklv,duration:Number.POSITIVE_INFINITY})}}})}return i}demuxSampleAes(e,t,i){return Promise.reject(new 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,this.initData=void 0}},remux:class extends tr{constructor(e,t,i,r){super("passthrough-remuxer",r),this.observer=void 0,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,this.videoOnlyRemux=!1,this.decryptdata=null,this.pendingInitSegment=void 0,this.observer=e}destroy(){this.observer&&this.observer.removeAllListeners(),this.observer=null}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.decryptdata=r,this.pendingInitSegment=e,this.videoOnlyRemux=!1,this.initTracks=void 0,this.initData=void 0,this.emitInitSegment=!0}generateInitSegment(e,t,i){this.videoOnlyRemux=!1;let{audioCodec:r,videoCodec:a}=this;if(null==e||!e.byteLength)return this.initTracks=void 0,void(this.initData=void 0);let{audio:n,video:s}=this.initData=i||Qr(e);if(t)!function(e,t){if(!e||!t)return;let i=t.keyId;16===(null==i?void 0:i.byteLength)&&t.isCommonEncryption&&ia(e,(e,t)=>{let r=e.subarray(8,24);r.some(e=>0!==e)||(or.log(`[eme] Patching keyId in 'enc${t?"a":"v"}>sinf>>tenc' box: ${Dr(r)} -> ${Dr(i)}`),e.set(i,8))})}(e,t);else{let e=n||s;null!=e&&e.encrypted&&this.warn(`Init segment with encrypted track with has no key ("${e.codec}")!`)}n&&(r=Ql(n,wi,this)),s&&(a=Ql(s,Di,this));let o={};n&&s?o.audiovideo={container:"video/mp4",codec:r+","+a,supplemental:s.supplemental,encrypted:s.encrypted,initSegment:e,id:"main"}:n?o.audio={container:"audio/mp4",codec:r,encrypted:n.encrypted,initSegment:e,id:"audio"}:s?o.video={container:"video/mp4",codec:a,supplemental:s.supplemental,encrypted:s.encrypted,initSegment:e,id:"main"}:this.warn("initSegment does not contain moov or trak boxes."),this.initTracks=o}remux(e,t,i,r,a,n,s,o,l,d,u){var h,c;let{initPTS:m,lastEndTime:f}=this,p={audio:void 0,video:void 0,text:void 0,id3:i,initSegment:void 0};vi(f)||(f=this.lastEndTime=a||0);let g=t.samples;if(!g.length)return p;let v=this.pendingInitSegment;v&&(this.pendingInitSegment=void 0,this.generateInitSegment(v,this.decryptdata,d));let E={initPTS:void 0,timescale:void 0,trackId:void 0},y=this.initData;if(null!=(h=y)&&h.length||(this.generateInitSegment(g),y=this.initData),null==(c=y)||!c.length)return this.warn("Failed to generate initSegment."),p;if(l.iframe&&y.audio&&y.video){var b;let e=null==(b=this.initTracks)||null==(b=b.audiovideo)?void 0:b.initSegment,t=e?function(e){let t=Yr(e,["moov"]);if(1!==t.length||Yr(e,["moof"]).length)return null;let i=e.byteOffset,r=[],a=[],n=!1,s=Yr(t[0],["trak"]);for(let e=0;e<s.length;e++){let t=s[e],o=Yr(t,["mdia","hdlr"])[0];if("vide"===(o?Pr(o.subarray(8,12)):"")){n=!0;continue}let l=Yr(t,["tkhd"])[0];if(!l)return null;let d=l[0];a.push(Br(l,0===d?12:20)),r.push(Vr(t,i))}if(!n||!r.length)return null;let o=Yr(t[0],["mvex"])[0],l=0;if(o){let e=Yr(o,["trex"]);for(let t=0;t<e.length;t++){let n=e[t];-1!==a.indexOf(Br(n,4))&&(r.push(Vr(n,i)),l+=n.byteLength+8)}}let{result:d,dropped:u,droppedBefore:h}=qr(e,r);if(Kr(d,t[0].byteOffset-i-8,t[0].byteLength+8-u),o&&l){let e=o.byteOffset-i-8;Kr(d,e-h(e),o.byteLength+8-l)}return d}(e):null;var T;if(t)this.log("Converted muxed init segment to video-only for I-Frame playback"),this.generateInitSegment(t,this.decryptdata),null!=(T=this.initData)&&T.length&&(y=this.initData,this.emitInitSegment=!0,this.videoOnlyRemux=!0)}this.emitInitSegment&&(E.tracks=this.initTracks,p.initSegment=E,this.emitInitSegment=!1);let A=l.iframe,_=!u||A&&!u.includeSampleDetails?function(e,t,i,r,a=!0){return na(e,t,r,a)}(g,y,0,this,A):u.tracks,S=y.audio?_[y.audio.id]:null,k=y.video?_[y.video.id]:null,I=!!y.audio,R=!!y.video,L="";I&&(L+="audio"),R&&(L+="video");let w=zl(k,1/0),D=zl(S,1/0),C=zl(k,0,!0),M=zl(S,0,!0),P=a,x=0;k&&S&&y.audio&&(D>C||w>M)&&this.warn(`audio and video track sample timestamps do not overlap. v: ${w}-${C} a: ${D}-${M}}`,k,S);let O=!!S&&(!k||!m&&D<w||!!m&&m.trackId===y.audio.id),N=O?S:k;if(!N)return this.log(`No media samples found in ${o} ${l.level} ${-1===l.part?"":`part: ${l.part} of`} sn: ${l.sn} at playlist time: ${a}`),p;let U,F=g;if(k&&k.sampleCount>=1&&y.video&&l.iframe){let{trun:e,start:t}=k,i=1===e.length,r=e.length?i?e[0].samples:e[0].samples.concat(...e.slice(1).map(e=>e.samples)):[];if(r.length){let a=e[0],n=a;for(let t=e.length;t--;)if(e[t].samples.length){n=e[t];break}let s=n.lastSampleDurationOffset,{defaultSampleDurationOffset:o}=a,d=Math.abs(l.duration-(C-w))>.05,u=r.length<k.sampleCount;if(d||u||this.videoOnlyRemux||!i){let e=u?n.sampleOffset+n.samples.reduce((e,t)=>e+t.size,0):void 0,i=d?l.duration:C-w,a=function(e,t,i,r){if(void 0!==i){let r=e[e.length-1],a=t;for(let t=0;t<e.length-1;t++)a-=e[t].duration;return a<=0&&(a=r.duration),r.duration=a,{durationOffset:i,value:a}}if(void 0===r)return;let a=Math.round(t/e.length);for(let t=0;t<e.length;t++)e[t].duration=a;return{durationOffset:r,value:a}}(r,i*y.video.timescale,s,o),h=function(e,t,i,r,a){if(i<1)return null;let n=Yr(e,["moof"]);if(1!==n.length)return null;let s=n[0],o=e.byteOffset,l=[],d=[],u=Yr(s,["traf"]),h=!0;for(let e=0;e<u.length;e++){let i=u[e],r=Yr(i,["tfhd"])[0];if(!r)return null;Br(r,4)===t?(l.push(i),131072&Br(r,0)||(h=!1)):d.push(Vr(i,o))}if(!l.length||d.length&&!h)return null;if(void 0!==r){let t=i;for(let i=0;i<l.length;i++){let r=l[i],a=0,n=Yr(r,["trun"]);for(let i=0;i<n.length;i++){let r=n[i],s=Math.min(t,Br(r,4));if(s){Kr(e,r.byteOffset-o+4,s);let t=16777215&Br(r,0);Wr(e,r,8+(1&t?4:0)+(4&t?4:0)+s*((256&t?4:0)+(512&t?4:0)+(1024&t?4:0)+(2048&t?4:0)))}else Kr(e,r.byteOffset-o-4,Nr.free);t-=s,a+=s}let s=Yr(r,["senc"])[0];s&&Kr(e,s.byteOffset-o+4,a);let d=Yr(r,["saiz"])[0];if(d){let t=4;1&(d[1]<<16|d[2]<<8|d[3])&&(t+=8);let i=d[t];t+=1,Kr(e,d.byteOffset-o+t,a),Wr(e,d,t+4+(0===i?a:0))}}let a=Yr(e,["mdat"]);if(1===a.length){let t=a[0].byteOffset-o-8;Kr(e,t,r-t)}}let c=e,m=0,f=()=>0;if(d.length){({result:c,dropped:m,droppedBefore:f}=qr(e,d)),Kr(c,s.byteOffset-o-8,s.byteLength+8-m);for(let e=0;e<l.length;e++){let t=l[e],i=f(t.byteOffset-o),r=Yr(t,["trun"]);for(let e=0;e<r.length;e++){let t=r[e];1&Br(t,0)&&Kr(c,t.byteOffset-o-i+8,Br(t,8)-m)}if(i){let e=Yr(t,["saio"]);for(let t=0;t<e.length;t++){let r=e[t],a=0===r[0]?4:8,n=1&Br(r,0)?12:4,s=Br(r,n);for(n+=4;s--;n+=a){let e=n+a-4;Kr(c,r.byteOffset-o-i+e,Br(r,e)-i)}}}}}if(a){let{durationOffset:e,value:t}=a;Kr(c,e-f(e),t)}return void 0!==r?c.subarray(0,r-m):c}(g,y.video.id,r.length,e,a);h?(F=h,U=function(e,t){let i=e,r=e;for(let e=0;e<t.length;e++){let{cts:a,duration:n}=t[e];r=Math.max(r,i+(a||0)+n),i+=n}return r}(t,r)):this.warn(`IFrame remux skipped (sn ${l.sn}); using native sample duration`),x=h&&a?i:C-w}else x=C-w}else this.warn(`Could not remux IFrame track fragment (no samples in range, trun count ${e.length})`),x=C-w}else x=O?M-D:C-w;if(this.videoOnlyRemux&&F===g)return this.warn(`Dropping muxed I-Frame fragment that could not be remuxed to video-only (sn: ${l.sn})`),p;let B=N.timescale,$=N.start-a*B,H=O?y.audio.id:y.video.id;if(P=N.start/B,(n||!m)&&(function(e,t,i,r){if(null===e)return!0;let a=Math.max(r,1),n=t-e.baseTime/e.timescale;return Math.abs(n-i)>=a}(m,P,a,x)||B!==m.timescale)){let e=!1,t=O?"audio":"video";if(m){let i=0!==a?P/a:1+P/1;e=P>=0&&Math.abs(1-i)<.001,this.log(`${t} timestamps in track ${H} at playlist time: ${n?"":"~"}${a} maps to ${P} with initPTS: ${m.baseTime/m.timescale} (${$/B-m.baseTime/m.timescale}s diff) (${L}) drift estimate: ${i} ${e?"(ignoring drift)":"remapping timestamps (initPTS)"}`)}e||(this.log(`Found initPTS in ${t} track ${H} at playlist time: ${a} offset: ${P-a} (${$}/${B})`),m=null,E.initPTS=$,E.timescale=B,E.trackId=H)}m?(E.initPTS=m.baseTime,E.timescale=m.timescale,E.trackId=m.trackId):((!E.timescale||void 0===E.trackId||void 0===E.initPTS)&&(this.warn("Could not set initPTS"),E.initPTS=P,E.timescale=1,E.trackId=-1),this.initPTS=m={baseTime:E.initPTS,timescale:E.timescale,trackId:E.trackId});let G=P-m.baseTime/m.timescale,K=G+x,W=R&&void 0!==(null==N?void 0:N.ptsMin)?N.ptsMin/N.timescale-m.baseTime/m.timescale:G,V=void 0!==U&&k?U/k.timescale-m.baseTime/m.timescale:R&&null!=N&&N.ptsMax?N.ptsMax/N.timescale-m.baseTime/m.timescale:K;x>0?this.lastEndTime=K:(this.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());let q={data1:F,data2:void 0,startPTS:W,startDTS:G,endPTS:V,endDTS:K,type:L,hasAudio:I,hasVideo:R,nb:1,dropped:0,encrypted:!!y.audio&&y.audio.encrypted||!!y.video&&y.video.encrypted};p.audio=I&&!R?q:void 0,p.video=R?q:void 0;let Y=this.isVideoContiguous,j=null==k?void 0:k.sampleCount;if(j){let e=k.keyFrameIndex,t=-1!==e;q.nb=j,q.dropped=0===e||Y?0:t?e:j,q.independent=t,q.firstKeyFrame=e,t&&k.keyFrameStart&&(q.firstKeyFramePTS=(k.keyFrameStart-m.baseTime)/m.timescale),Y||(p.independent=t),this.isVideoContiguous||(this.isVideoContiguous=t),q.dropped&&this.warn(`fmp4 does not start with IDR: firstIDR ${e}/${j} dropped: ${q.dropped} start: ${q.firstKeyFramePTS||"NA"}`)}return p.initSegment=E,p.id3=ql(i,a,m,m),r.samples.length&&(p.text=Yl(r,a,m)),p}}},{demux:yl,remux:Wl},{demux:class extends Zo{constructor(e,t){super(),this.observer=void 0,this.config=void 0,this.sampleAes=null,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=br(e,0),r=(null==i?void 0:i.length)||0;if(ll(e,r))return!1;for(let i=e.length;r<i;r++)if(qo(e,r))return t.log("ADTS sync word found !"),!0;return!1}canParse(e,t){return function(e,t){return function(e,t){return t+5<e.length}(e,t)&&Go(e,t)&&Wo(e,t)<=e.length-t}(e,t)}appendFrame(e,t,i){Yo(e,this.observer,t,i,e.manifestCodec);let r=zo(e,t,i,this.basePTS,this.frameIndex);if(0===(null==r?void 0:r.missing))return r}demuxSampleAes(e,t,i){let r=this.demux(e,i),a=this.sampleAes=new dl(this.observer,this.config,t);return new Promise(e=>{a.decryptAacSamples(r.audioTrack.samples,0,()=>{e(r)})})}},remux:Wl},{demux:class extends Zo{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=br(e,0),i=(null==t?void 0:t.length)||0;if(t&&11===e[i]&&119===e[i+1]&&void 0!==wr(t)&&ul(e,i)<=16)return!1;for(let t=e.length;i<t;i++)if(ll(e,i))return or.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return function(e,t){return sl(e,t)&&4<=e.length-t}(e,t)}appendFrame(e,t,i){if(null!==this.basePTS)return al(e,t,i,this.basePTS,this.frameIndex)}},remux:Wl}];Xl.splice(2,0,{demux:class extends Zo{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=hl(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=br(e,0);if(!t)return!1;let i=t.length;if(11===e[i]&&119===e[i+1]&&void 0!==wr(t)){if(ul(e,i)<16)return!0;throw new Error("Containerless ec-3 is not supported")}return!1}},remux:Wl});var Zl=class{constructor(e,t,i,r,a,n){this.asyncResult=!1,this.logger=void 0,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=e,this.typeSupported=t,this.config=i,this.id=a,this.logger=n}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(e,t,i,r){if(!this.observer)return Jl(i);let a=i.transmuxing;a.executeStart=jl();let n=new Uint8Array(e),{currentTransmuxState:s,transmuxConfig:o}=this;r&&(this.currentTransmuxState=r);let{contiguous:l,discontinuity:d,trackSwitch:u,accurateTimeOffset:h,timeOffset:c,initSegmentChange:m}=r||s,{audioCodec:f,videoCodec:p,defaultInitPts:g,duration:v,initSegmentData:E}=o,y=function(e,t){let i=null;return e.byteLength>0&&null!=(null==t?void 0:t.key)&&null!==t.iv&&null!=t.method&&(i=t),i}(n,t);if(y&&gs(y.method)){let e=this.getDecrypter(),t=vs(y.method);return this.asyncResult=!0,this.decryptionPromise=e.decrypt(n,y.key.buffer,y.iv.buffer,t,i.decryptRange).then(e=>{let t=this.push(e,null,i);return this.decryptionPromise=null,t}),this.decryptionPromise}let b=this.needsProbing(d,u);if(b){let e=i.iframe&&E&&yl.probe(E,this.logger)?E:n,t=this.configureTransmuxer(e);if(t)return this.logger.warn(`[transmuxer] ${t.message}`),this.observer.emit(Ai.ERROR,Ai.ERROR,{type:bi.MEDIA_ERROR,details:Ti.FRAG_PARSING_ERROR,fatal:!1,error:t,reason:t.message}),a.executeEnd=jl(),Jl(i)}(d||u||m||b)&&this.resetInitSegment(E,f,p,v,t,i),(d||m||b)&&this.resetInitialTimestamp(g),l||this.resetContiguity();let T=this.transmux(n,y,c,h,i);this.asyncResult=ed(T);let A=this.currentTransmuxState;return A.contiguous=!0,A.discontinuity=!1,A.trackSwitch=!1,a.executeEnd=jl(),T}flush(e){let t=e.transmuxing;t.executeStart=jl();let{decrypter:i,currentTransmuxState:r,decryptionPromise:a}=this;if(a)return this.asyncResult=!0,a.then(()=>this.flush(e));let n=[],{timeOffset:s}=r;if(i){let t=i.flush();t&&n.push(this.push(t.buffer,null,e))}let{demuxer:o,remuxer:l}=this;if(!o||!l){t.executeEnd=jl();let i=[Jl(e)];return this.asyncResult?Promise.resolve(i):i}let d=o.flush(s,e);return ed(d)?(this.asyncResult=!0,d.then(t=>(this.flushRemux(n,t,e),n))):(this.flushRemux(n,d,e),this.asyncResult?Promise.resolve(n):n)}flushRemux(e,t,i){if(!this.remuxer)return;let{audioTrack:r,videoTrack:a,id3Track:n,textTrack:s}=t,{accurateTimeOffset:o,timeOffset:l}=this.currentTransmuxState;this.logger.log(`[transmuxer.ts]: Flushed ${this.id} sn: ${i.sn}${i.part>-1?" part: "+i.part:""} of ${this.id} playlist ${i.level}`);let d=this.remuxer.remux(r,a,n,s,l,o,!0,this.id,i,t.initData,t.sampleData);e.push({remuxResult:d,chunkMeta:i}),i.transmuxing.executeEnd=jl()}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,a,n){let{demuxer:s,remuxer:o}=this;!s||!o||(s.resetInitSegment(e,t,i,r,a,n),o.resetInitSegment(e,t,i,a))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0),this.observer&&this.observer.removeAllListeners(),this.decryptionPromise=null,this.decrypter=this.observer=void 0,this.logger=this.config=this.probe=void 0}transmux(e,t,i,r,a){let n;return n="SAMPLE-AES"===(null==t?void 0:t.method)?this.transmuxSampleAes(e,t,i,r,a):this.transmuxUnencrypted(e,i,r,a),n}transmuxUnencrypted(e,t,i,r){let{demuxer:a,remuxer:n}=this;if(!a||!n)return Jl(r);let s=a.demux(e,t,r,!1,!this.config.progressive),{audioTrack:o,videoTrack:l,id3Track:d,textTrack:u}=s;return{remuxResult:n.remux(o,l,d,u,t,i,!1,this.id,r,s.initData,s.sampleData),chunkMeta:r}}transmuxSampleAes(e,t,i,r,a){return this.demuxer?this.demuxer.demuxSampleAes(e,t,i,a).then(e=>({remuxResult:this.remuxer.remux(e.audioTrack,e.videoTrack,e.id3Track,e.textTrack,i,r,!1,this.id,a,e.initData,e.sampleData),chunkMeta:a})):Promise.reject(new Error("no demuxer"))}configureTransmuxer(e){let t,{config:i,observer:r,typeSupported:a}=this;if(!r)return;try{for(let i=0,r=Xl.length;i<r;i++){var n;if(null!=(n=Xl[i].demux)&&n.probe(e,this.logger)){t=Xl[i];break}}}catch(e){return e}if(!t)return new Error("Failed to find demuxer by probing fragment data");let s=this.demuxer,o=this.remuxer,l=t.demux,d=t.remux;(!s||!(s instanceof l))&&(this.logger.log(`Using ${l.name}`),this.demuxer=new l(r,i,a,this.logger),this.probe=l.probe),(!o||!(o instanceof d))&&(this.logger.log(`Using ${d.name}`),this.remuxer=new d(r,i,a,this.logger))}needsProbing(e,t){return!this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new Vn(this.config)),e}};var Jl=e=>({remuxResult:{},chunkMeta:e});function ed(e){return"then"in e&&e.then instanceof Function}var td=class{constructor(e,t,i,r,a){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=e,this.videoCodec=t,this.initSegmentData=i,this.duration=r,this.defaultInitPts=a||null}},id=class{constructor(e,t,i,r,a,n){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=a,this.initSegmentChange=n}},rd=0,ad=class{constructor(e,t,i,r){this.error=null,this.hls=void 0,this.id=void 0,this.instanceNo=rd++,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=new Error(`${e.message}  (${e.filename}:${e.lineno})`);this.hls.config.enableWorker=!1,this.hls.logger.warn(`Error in "${this.id}" Web Worker, fallback to inline`),this.hls.trigger(Ai.ERROR,{type:bi.OTHER_ERROR,details:Ti.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:t})};let a=e.config;this.hls=e,this.id=t,this.useWorker=!!a.enableWorker,this.onTransmuxComplete=i,this.onFlush=r;let n=(e,t)=>{(t=t||{}).frag=this.frag||void 0,e===Ai.ERROR&&(t.parent=this.id,t.part=this.part,this.error=t.error),this.hls.trigger(e,t)};this.observer=new Bo,this.observer.on(Ai.FRAG_DECRYPTED,n),this.observer.on(Ai.ERROR,n);let s=Oa(a.preferManagedMediaSource);if(this.useWorker&&"undefined"!=typeof Worker){let i=this.hls.logger;if(a.workerPath||"function"==typeof __HLS_WORKER_BUNDLE__){try{a.workerPath?(i.log(`loading Web Worker ${a.workerPath} for "${t}"`),this.workerContext=function(e){let t=Ho[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 Ho[e]=r,r}(a.workerPath)):(i.log(`injecting Web Worker for "${t}"`),this.workerContext=function(){let e=Ho[$o];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 Ho[$o]=r,r}());let{worker:e}=this.workerContext;e.addEventListener("message",this.onWorkerMessage),e.addEventListener("error",this.onWorkerError),e.postMessage({instanceNo:this.instanceNo,cmd:"init",typeSupported:s,id:t,config:tn(a)})}catch(r){i.warn(`Error setting up "${t}" Web Worker, fallback to inline`,r),this.terminateWorker(),this.error=null,this.transmuxer=new Zl(this.observer,s,a,"",t,e.logger)}return}}this.transmuxer=new Zl(this.observer,s,a,"",t,e.logger)}reset(){if(this.frag=null,this.part=null,this.workerContext){let e=this.instanceNo;this.instanceNo=rd++;let t=this.hls.config,i=Oa(t.preferManagedMediaSource);this.workerContext.worker.postMessage({instanceNo:this.instanceNo,cmd:"reset",resetNo:e,typeSupported:i,id:this.id,config:tn(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=Ho[e||$o];if(t&&1===t.clientCount--){let{worker:i,objectURL:r}=t;delete Ho[e||$o],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,a,n,s,o,l,d){var u,h;l.transmuxing.start=self.performance.now();let{instanceNo:c,transmuxer:m}=this,f=n?n.start:a.start,p=a.decryptdata,g=this.frag,v=!g||a.cc!==g.cc,E=!g||l.level!==g.level,y=g?l.sn-g.sn:-1,b=this.part?l.part-this.part.index:-1,T=0===y&&l.id>1&&l.id===(null==g?void 0:g.stats.chunkCount),A=!E&&(1===y||0===y&&(1===b||T&&b<=0)),_=self.performance.now();(E||y||0===a.stats.parsing.start)&&(a.stats.parsing.start=_),n&&(b||!A)&&(n.stats.parsing.start=_);let S=!(g&&(null==(u=a.initSegment)?void 0:u.url)===(null==(h=g.initSegment)?void 0:h.url)),k=new id(v,A,o,E,f,S);if(!A||v||S){this.hls.logger.log(`[transmuxer-interface]: Starting new transmux session for ${a.type} sn: ${l.sn}${l.part>-1?" part: "+l.part:""} ${this.id} playlist: ${l.level} id: ${l.id}\n        discontinuity: ${v}\n        trackSwitch: ${E}\n        contiguous: ${A}\n        accurateTimeOffset: ${o}\n        timeOffset: ${f}\n        initSegmentChange: ${S}`);let e=new td(i,r,t,s,d);this.configureTransmuxer(e)}if(this.frag=a,this.part=n,this.workerContext)this.workerContext.worker.postMessage({instanceNo:c,cmd:"demux",data:e,decryptdata:p,chunkMeta:l,state:k},e instanceof ArrayBuffer?[e]:[]);else if(m){let t=m.push(e,p,l,k);ed(t)?t.then(e=>{this.handleTransmuxComplete(e)}).catch(e=>{this.transmuxerError(e,l,"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);ed(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(Ai.ERROR,{type:bi.MEDIA_ERROR,details:Ti.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)}},nd=class extends tr{constructor(e,t){super(t,e.logger),this.hls=void 0,this.canLoad=!1,this.timer=-1,this.loadingSync=!1,this.hls=e}destroy(){this.clearTimer(),this.hls=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 a=-1;for(let i=0;i<r.length;i++){let n,s=r[i];try{n=new self.URL(s.URI,t.url).href}catch(e){this.warn(`Could not construct new URL for Rendition Report: ${e}`),n=s.URI||""}if(n===e){a=i;break}n===e.substring(0,n.length)&&(a=i)}if(-1!==a){let e=r[a],n=parseInt(e["LAST-MSN"])||t.lastPartSn,s=parseInt(e["LAST-PART"])||t.lastPartIndex;if(this.hls.config.lowLatencyMode){let e=Math.min(t.age-t.partTarget,t.targetduration);s>=0&&e>t.partTarget&&(s+=1)}let o=i&&Qa(i);return new Xa(n,s>=0?s:void 0,o)}}}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:a}=t,n=r.fragments,s=self.performance.now(),o=a.loading.first?Math.max(0,Math.floor(s-a.loading.first)):0;r.advancedDateTime=Date.now()-o;let l=this.hls.config.timelineOffset;if(l!==r.appliedTimelineOffset){let e=Math.max(l||0,0);r.appliedTimelineOffset=e,n.forEach(t=>{null==t||t.setStart(t.playlistOffset+e)})}if(r.live||null!=i&&i.live){var d;let l="levelInfo"in t?t.levelInfo:t.track;r.reloaded(i);let u=null==(d=n[n.length-1])?void 0:d.type;if(r.misses>=this.hls.config.liveMaxUnchangedPlaylistRefresh){let e=new Error(`${u} playlist ${l.id} hit max allowed unchanged reloads.`);this.warn(e);let{networkDetails:i,context:n}=t;return void this.hls.trigger(Ai.ERROR,{type:bi.NETWORK_ERROR,details:Ti.PLAYLIST_UNCHANGED_ERROR,fatal:!1,url:r.url,error:e,reason:e.message,level:t.level,parent:u,context:n,networkDetails:i,stats:a})}if(i){io(i,r,this);let e=r.playlistParsingError;if(e){this.warn(e);let i=this.hls;if(!i.config.ignorePlaylistParsingErrors){let{networkDetails:n}=t;return void i.trigger(Ai.ERROR,{type:bi.NETWORK_ERROR,details:Ti.LEVEL_PARSING_ERROR,fatal:!1,url:r.url,error:e,reason:e.message,level:t.level,parent:u,networkDetails:n,stats:a})}r.playlistParsingError=null}}-1===r.requestScheduled&&(r.requestScheduled=a.loading.start);let h=this.hls.mainForwardBufferInfo,c=h?h.end-h.len:0,m=no(r,1e3*(r.edge-c));r.requestScheduled+m<s?r.requestScheduled=s:r.requestScheduled<=s&&(r.requestScheduled+=m);let f,p,g,v=t.deliveryDirectives;if(this.log(`live playlist ${e} ${r.advanced?`REFRESHED ${r.lastPartSn} - ${r.lastPartIndex}`:r.updated?"UPDATED":`MISSED (received ${r.lastPartSn} - ${r.lastPartIndex}${v?` | requested ${v.msn} - ${v.part}`:""})`}`),!this.canLoad||!r.live)return;if(r.canBlockReload&&r.advanced){let e=this.hls.config.lowLatencyMode,a=r.lastPartSn,n=r.endSN,o=r.lastPartIndex,d=a===n;-1!==o?d?(p=n+1,g=e?0:o):(p=a,g=e?o+1:r.maxPartIndex):p=n+1;let u=r.age,h=u+r.ageHeader,c=Math.min(h-r.partTarget,1.5*r.targetduration);if(c>0){if(h>3*r.targetduration)this.log(`Playlist last advanced ${u.toFixed(2)}s ago. Omitting segment and part directives.`),p=void 0,g=void 0;else if(null!=i&&i.tuneInGoal&&h-r.partTarget>i.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${i.tuneInGoal} to: ${c} with playlist age: ${r.age}`),c=0;else{let e=Math.floor(c/r.targetduration);if(p+=e,void 0!==g){g+=Math.round(c%r.targetduration/r.partTarget)}this.log(`CDN Tune-in age: ${r.ageHeader}s last advanced ${u.toFixed(2)}s goal: ${c} skip sn ${e} to part ${g}`)}r.tuneInGoal=c}if(f=this.getDeliveryDirectives(r,t.deliveryDirectives,p,g),e||!d)return r.requestScheduled=s,void this.loadingPlaylist(l,f)}else(r.canBlockReload||r.canSkipUntil)&&(f=this.getDeliveryDirectives(r,t.deliveryDirectives,p,g));f&&void 0!==p&&r.canBlockReload&&(r.requestScheduled=a.loading.first+Math.max(m-2*o,m/2)),this.scheduleLoading(l,f,r)}else this.clearTimer()}scheduleLoading(e,t,i){let r=i||e.details;if(!r)return void this.loadingPlaylist(e,t);let a=self.performance.now(),n=r.requestScheduled;if(a>=n&&!this.loadingSync)return this.loadingSync=!0,this.loadingPlaylist(e,t),void(this.loadingSync=!1);let s=Math.max(n-a,0);this.log(`reload live playlist ${e.name||e.bitrate+"bps"} in ${Math.round(s)} ms`),this.clearTimer(),this.timer=self.setTimeout(()=>this.loadingPlaylist(e,t),s)}getDeliveryDirectives(e,t,i,r){let a=Qa(e);return null!=t&&t.skip&&e.deltaUpdateFailed&&(i=t.msn,r=t.part,a=Ya),new Xa(i,r,a)}checkRetry(e){let t=e.details,i=Wi(e),r=e.errorAction,{action:a,retryCount:n=0,retryConfig:s}=r||{},o=!!r&&!!s&&(a===An||!r.resolved&&a===bn);if(o){var l;if(n>=s.maxNumRetry)return!1;if(i&&null!=(l=e.context)&&l.deliveryDirectives)this.warn(`Retrying playlist loading ${n+1}/${s.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{var d;let i=Xi(null==(d=e.response)?void 0:d.code);if(this.clearTimer(),i)this.log("Waiting for connection (offline)"),e.reason="offline",this.timer=self.setTimeout(()=>this.checkOfflineStatus(),1e3);else{let e=ji(s,n);this.warn(`Retrying playlist loading ${n+1}/${s.maxNumRetry} after "${t}" in ${e}ms`),this.timer=self.setTimeout(()=>this.loadPlaylist(),e)}}e.levelRetry=!0,r.resolved=!0}return o}checkOfflineStatus(){this.clearTimer(),Xi(0)?this.timer=self.setTimeout(()=>this.checkOfflineStatus(),1e3):(this.log("Connection restored (online)"),this.loadPlaylist())}};function sd(e,t){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!od(e[i].attrs,t[i].attrs))return!1;return!0}function od(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])}var ld=class{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=>{let i={label:"async-blocker",execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};this.append(i,e)})}prependBlocker(e){return new Promise(t=>{if(this.queues){let i={label:"async-blocker-prepend",execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};this.queues[e].unshift(i)}})}removeBlockers(){null!==this.queues&&[this.queues.video,this.queues.audio,this.queues.audiovideo].forEach(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)):"block-audio"===i&&e.splice(0,1)})}insertNext(e,t){null!==this.queues&&this.queues[t].splice(1,0,...e)}unblockAudio(){var e;null!==this.queues&&"block-audio"===(null==(e=this.current("audio"))?void 0:e.label)&&this.shiftAndExecuteNext("audio")}audioBlocking(){return null!==this.queues&&this.queues.audio.some(e=>"block-audio"===e.label)}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(t){var i;if(r.onError(t),null===this.queues||null===this.tracks)return;let a=null==(i=this.tracks[e])?void 0:i.buffer;null!=a&&a.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>":`\n${this.list("video")}\n${this.list("audio")}\n${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(", "))||""}},dd=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,ud="HlsJsTrackRemovedError",hd=class extends Error{constructor(e){super(e),this.name=ud}};function cd(e){let t=e.querySelectorAll("source");[].slice.call(t).forEach(t=>{e.removeChild(t)})}function md(e){return"audio"===e?1:0}function fd(e,t){return`${e?"":" - triggering recovery"}${t?" with HTMLMediaElement Error: "+t.message:""}`}function pd(e){return`${e.type}_${e.sn}_${e.level}`}function gd(e,t){let{start:i,end:r}=t,a=0;for(let t=0;t<e.length;t++){let n=e[t];if(n.start>=r)break;let s=Math.max(i,n.start),o=Math.min(r,n.end);o>s&&(a+=o-s)}return a}function vd(e,t){return t.duration-e<=.05}var Ed=class e{constructor(e){this.hls=null,this.autoLevelCapping=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.observer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=e,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.media=null,this.restrictedLevels=[],this.clientRect=null,this.registerListeners()}setStreamController(e){this.streamController=e}destroy(){this.hls&&this.unregisterListener(),(this.timer||this.observer)&&this.stopCapping(),this.media=this.clientRect=this.hls=null,this.streamController=void 0}registerListeners(){let{hls:e}=this;e&&(e.on(Ai.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(Ai.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(Ai.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Ai.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(Ai.BUFFER_CODECS,this.onBufferCodecs,this),e.on(Ai.MEDIA_DETACHING,this.onMediaDetaching,this))}unregisterListener(){let{hls:e}=this;e&&(e.off(Ai.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(Ai.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(Ai.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Ai.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(Ai.BUFFER_CODECS,this.onBufferCodecs,this),e.off(Ai.MEDIA_DETACHING,this.onMediaDetaching,this))}onFpsDropLevelCapping(e,t){if(!this.hls)return;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){let i=t.media;this.clientRect=null,this.hls&&(i instanceof HTMLVideoElement?(this.media=i,this.hls.config.capLevelToPlayerSize&&this.observe()):this.media=null,(this.timer||this.observer)&&this.hls.levels.length>1&&this.detectPlayerSize())}onManifestParsed(e,t){this.restrictedLevels=[],t.video&&this.startCapping(),this.onLevelsUpdated()}onLevelsUpdated(){if(this.hls)if((this.timer||this.observer)&&(vi(this.autoLevelCapping)||this.clientRect))this.detectPlayerSize();else if(void 0===this.observer&&void 0===this.timer){let e=this.hls.levels;e.length>1&&e.some(e=>!!e.videoCodec)&&this.startCapping()}}onBufferCodecs(e,t){t.video&&this.startCapping()}onMediaDetaching(){this.stopCapping(),this.media=null}detectPlayerSize(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0||!this.hls)return void(this.clientRect=null);let e=this.hls.levels;if(e.length>1){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}else 1===e.length&&this.stopCapping()}}getMaxLevel(t){if(!this.hls)return-1;let i=this.hls.levels;if(!i.length)return-1;let r=i.filter((e,i)=>this.isLevelAllowed(e)&&i<=t);return this.observer||(this.clientRect=null),e.getMaxLevelByMediaSize(r,this.mediaWidth,this.mediaHeight)}observe(){let e=self.ResizeObserver;e&&(this.observer=new e(e=>{var t;let i=null==(t=e[0])?void 0:t.contentRect;i&&(this.clientRect=i,this.detectPlayerSize())})),this.observer&&this.media&&this.observer.observe(this.media)}startCapping(){var e;this.timer||this.observer||null==(e=this.hls)||!e.config.capLevelToPlayerSize||(self.clearInterval(this.timer),this.timer=void 0,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.observe(),this.observer||(this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3)),this.detectPlayerSize())}stopCapping(){this.restrictedLevels=[],this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0),this.observer&&(this.observer.disconnect(),this.observer=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.width||0,t.height=i.bottom-i.top||e.height||0)}return this.clientRect=t,t}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let e=1;if(!this.hls)return e;let{ignoreDevicePixelRatio:t,maxDevicePixelRatio:i}=this.hls.config;if(!t)try{e=self.devicePixelRatio}catch{}return Math.min(e,i)}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),a=e.length-1,n=Math.max(t,i);for(let t=0;t<e.length;t+=1){let i=e[t];if((i.width>=n||i.height>=n)&&r(i,e[t+1])){a=t;break}}return a}},yd=class e{constructor(t,i){Array.isArray(t)&&(t=t.map(t=>t instanceof e?t:new e(t))),this.value=t,this.params=i}};function bd(e,t,i,r){return new Error(`failed to ${e} "${function(e){return Array.isArray(e)?JSON.stringify(e):e instanceof Map?"Map{}":e instanceof Set?"Set{}":"object"==typeof e?JSON.stringify(e):String(e)}(t)}" as ${i}`,{cause:r})}var Td="Bare Item";var Ad=/[\x00-\x1f\x7f]+/,_d=class{constructor(e){this.description=e}};function Sd(e,t,i){return bd("serialize",e,t,i)}function kd(e){if(!1===ArrayBuffer.isView(e))throw Sd(e,"Byte Sequence");return`:${function(e){return btoa(String.fromCharCode(...e))}(e)}:`}function Id(e){if(function(e){return e<-999999999999999||999999999999999<e}(e))throw Sd(e,"Integer");return e.toString()}function Rd(e){let t=fr(e,3);if(Math.floor(Math.abs(t)).toString().length>12)throw Sd(e,"Decimal");let i=t.toString();return i.includes(".")?i:`${i}.0`}function Ld(e){let t=function(e){return e.description||e.toString().slice(7,-1)}(e);if(!1===/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(t))throw Sd(t,"Token");return t}function wd(e){switch(typeof e){case"number":if(!vi(e))throw Sd(e,Td);return Number.isInteger(e)?Id(e):Rd(e);case"string":return function(e){if(Ad.test(e))throw Sd(e,"String");return`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}(e);case"symbol":return Ld(e);case"boolean":return function(e){if("boolean"!=typeof e)throw Sd(e,"Boolean");return e?"?1":"?0"}(e);case"object":if(e instanceof Date)return function(e){return`@${Id(e.getTime()/1e3)}`}(e);if(e instanceof Uint8Array)return kd(e);if(e instanceof _d)return Ld(e);default:throw Sd(e,Td)}}function Dd(e){if(!1===/^[a-z*][a-z0-9\-_.*]*$/.test(e))throw Sd(e,"Key");return e}function Cd(e){return null==e?"":Object.entries(e).map(([e,t])=>!0===t?`;${Dd(e)}`:`;${Dd(e)}=${wd(t)}`).join("")}function Md(e){return e instanceof yd?`${wd(e.value)}${Cd(e.params)}`:wd(e)}function Pd(e,t={whitespace:!0}){if("object"!=typeof e||null==e)throw Sd(e,"Dict");let i=e instanceof Map?e.entries():Object.entries(e),r=null!=t&&t.whitespace?" ":"";return Array.from(i).map(([e,t])=>{t instanceof yd||(t=new yd(t));let i=Dd(e);return!0===t.value?i+=Cd(t.params):(i+="=",Array.isArray(t.value)?i+=function(e){return`(${e.value.map(Md).join(" ")})${Cd(e.params)}`}(t):i+=Md(t)),i}).join(`,${r}`)}function xd(e,t){return Pd(e,t)}var Od=["url"],Nd=["version","eventTargets","sid","transmissionMode"],Ud=["customData","headers"],Fd=e=>e instanceof yd?new yd(Math.round(e.value),e.params):Math.round(e),Bd=e=>Array.isArray(e)?e.map(Fd):Fd(e),$d=(e,t)=>Array.isArray(e)?e.map(e=>$d(e,t)):e instanceof yd&&"string"==typeof e.value?new yd($d(e.value,t),e.params):(t.baseUrl&&(e=function(e,t){let i;try{i=new URL(e)}catch{return e}let r=new URL(t);if(i.origin!==r.origin)return e;let a=i.pathname.split("/").slice(1),n=r.pathname.split("/").slice(1,-1),s=Math.min(a.length,n.length);for(let e=0;e<s&&a[e]===n[e];e++)a.shift(),n.shift();for(;n.length;)n.shift(),a.unshift("..");return a.join("/")+i.search+i.hash}(e,function(e){let t="string"==typeof e?new URL(e):e;return t.origin+t.pathname.substring(0,t.pathname.lastIndexOf("/")+1)}(t.baseUrl))),1===t.version?encodeURIComponent(e):e),Hd=e=>e instanceof yd?new yd(100*Math.round(e.value/100),e.params):100*Math.round(e/100),Gd=e=>Array.isArray(e)?e.map(Hd):Hd(e),Kd={br:Bd,d:Bd,bl:Gd,dl:Gd,mtp:Gd,nor:(e,t)=>{let i=e;return t.version>=2&&(e instanceof yd&&"string"==typeof e.value?i=new yd([e]):"string"==typeof e&&(i=[e])),$d(i,t)},rtp:Gd,tb:Bd},Wd=2,Vd="rr",qd="bc",Yd="e",jd=Vd,zd="ce",Qd=new Map([["ps","sta"],["pr","pr"],["c","cid"],["b","bg"],["bc","br"]]),Xd="event",Zd="request",Jd=["cen","e","h","ts"],eu=["ab","bg","bl","br","bs","bsa","bsd","bsda","cdn","cid","cs","d","dfa","dl","ec","lab","lb","ltc","msd","mtp","nor","nr","ot","pb","pr","pt","rtp","sf","sid","sn","st","sta","su","tab","tb","tbl","tpb","v"],tu=/^[a-zA-Z0-9-.]+-[a-zA-Z0-9-.]+$/;function iu(e){return tu.test(e)}var ru=new Set(eu);function au(e){return ru.has(e)||iu(e)}var nu=["cmsdd","cmsds","rc","smrt","ttfb","ttfbb","ttlb","url"],su=new Set(nu);function ou(e){return su.has(e)}var lu=new Set(Jd);var du=new Set(["ab","bl","br","bsa","bsd","bsda","lab","lb","mtp","pb","tab","tb","tbl","tpb"]),uu=["bl","br","bs","cid","d","dl","mtp","nor","nrr","ot","pr","rtp","sf","sid","st","su","tb","v"],hu=new Set(uu);function cu(e){return hu.has(e)||iu(e)}var mu=new Set(["ot","sf","st","e","sta"]);function fu(e){return mu.has(e)}function pu(e){return"number"==typeof e?vi(e):null!=e&&""!==e&&!1!==e}var gu={[Xd]:function(e){return au(e)||ou(e)||lu.has(e)},[Zd]:au};function vu(e,t){if(Array.isArray(e)){let i;return t&&(i=e.find(e=>{var i;return(null==(i=e.params)?void 0:i.ot)===t})),i||(i=e[0]),vu(i)}return e instanceof yd?e.value:e}function Eu(e,t={}){let i={};if(null==e||"object"!=typeof e)return i;let r=t.version||e.v||Wd,a=t.reportingMode||Zd,n=1===r?function(e){let t={};for(let[r,a]of Object.entries(e))if(null!=a)if("nor"===r){let e=(Array.isArray(a)?a:[a])[0];var i;e instanceof yd?(t.nor=e.value,null!=(i=e.params)&&i.r&&(t.nrr=e.params.r)):t.nor=e}else du.has(r)?t[r]=vu(a,e.ot):t[r]=a;else t[r]=a;return t}(e):e,s=1===r?cu:gu[a],o=Object.keys(n).filter(s);n.e&&n.e!==Vd&&(o=o.filter(e=>!ou(e)));let l=t.filter;"function"==typeof l&&(o=o.filter(l));let d=a===Xd;if(d){let e=n.e;!o.includes("e")&&null!=e&&o.push("e"),o.includes("ts")||o.push("ts"),!o.includes("cen")&&null!=n.cen&&"ce"===e&&o.push("cen");let t=e?Qd.get(e):void 0;t&&null!=n[t]&&!o.includes(t)&&o.push(t)}if(0===o.length)return i;r>1&&!o.includes("v")&&o.push("v");let u={version:r,reportingMode:a,baseUrl:t.baseUrl};o.sort();for(let e of o){var h,c;let a=n[e],s=null!=(h=null==(c=t.formatters)?void 0:c[e])?h:Kd[e];if("function"==typeof s&&(a=s(a,u)),"v"===e){if(1===r)continue;a=r}if("pr"===e&&1===a&&(!d||"pr"!==n.e))continue;d&&"ts"===e&&!vi(a)&&(a=Date.now());let o=d&&!1===a&&"bg"===e&&"b"===n.e;!pu(a)&&!o||(fu(e)&&"string"==typeof a&&(a=new _d(a)),i[e]=a)}return i}var yu="CMCD-Object",bu="CMCD-Request",Tu="CMCD-Session",Au="CMCD-Status",_u=bu,Su={ab:yu,br:yu,d:yu,lab:yu,lb:yu,ot:yu,tab:yu,tb:yu,tpb:yu,bl:bu,cs:bu,dfa:bu,dl:bu,ltc:bu,mtp:bu,nor:bu,nrr:bu,pb:bu,sn:bu,sta:bu,su:bu,tbl:bu,cid:Tu,msd:Tu,sf:Tu,sid:Tu,st:Tu,v:Tu,bg:Au,bs:Au,bsa:Au,bsd:Au,bsda:Au,cdn:Au,ec:Au,nr:Au,pr:Au,pt:Au,rtp:Au};function ku(e,t){let i={};if(!e)return i;let r=Object.keys(e),a=t?function(e){return Object.keys(e).reduce((t,i)=>{var r;return null==(r=e[i])||r.forEach(e=>t[e]=i),t},{})}(t):{};for(let t of r){var n;let r=Su[t]||a[t]||_u;(null!=(n=i[r])?n:i[r]={})[t]=e[t]}return i}var Iu="CMCD";function Ru(e){return xd(e,{whitespace:!1})}var Lu=[...uu,...eu,...nu,...Jd].filter((e,t,i)=>i.indexOf(e)===t),wu="m",Du="a",Cu="v",Mu="av",Pu="i",xu="tt",Ou="s",Nu="p",Uu="k",Fu="r",Bu="a",$u="e",Hu="f",Gu="d",Ku="query",Wu="headers";function Vu(e,t,i){var r;let a=new Set(null!=(r=t.enabledKeys)?r:[]);return{version:t.version||Wd,reportingMode:e,filter:e=>a.has(e),baseUrl:i}}var qu=Object.is,Yu=e=>e,ju=Array.from(Qd,([e,t])=>"br"===t?{event:e,field:t,equal:(e,t)=>void 0===e||void 0===t?e===t:function(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++){let r=e[i],a=t[i];if(r===a)continue;if("number"==typeof r||"number"==typeof a||r.value!==a.value)return!1;let n=r.params,s=a.params,o=n&&Object.keys(n)[0],l=s&&Object.keys(s)[0];if(o!==l||void 0!==o&&void 0!==l&&n&&s&&n[o]!==s[l])return!1}return!0}(e,t),snapshot:e=>e.slice()}:{event:e,field:t,equal:qu,snapshot:Yu}),zu=new Map(ju.map(e=>[e.event,e]));function Qu(e){let{url:t}=e,i=Ki(e,Od);return fetch(t,i)}var Xu=class{constructor(e,t=Qu){var i;this.timeOrigin=performance.timeOrigin||(null==(i=performance.timing)?void 0:i.fetchStart)||Date.now()-performance.now(),this.data={},this.msd=NaN,this.eventTargets=new Map,this.lastEmitted={},this.requestTarget={sn:0,msdSent:!1},this.config=function(e){let{version:t=Wd,eventTargets:i=[],sid:r=pr(),transmissionMode:a=Ku}=e;return Gi(Gi({},Ki(e,Nd)),{},{version:t,transmissionMode:a,sid:r,eventTargets:i.reduce((e,t)=>{var i,r,a;return null!=t&&t.url&&null!=(i=t.events)&&i.length&&e.push({version:t.version||Wd,enabledKeys:(null==(r=t.enabledKeys)?void 0:r.slice())||[],url:t.url,events:t.events.slice(),interval:null!=(a=t.interval)?a:30,batchSize:t.batchSize||1}),e},[])})}(e),this.data={cid:this.config.cid,sid:this.config.sid,v:this.config.version},this.requester=t;for(let e of this.config.eventTargets)this.eventTargets.set(e,{intervalId:void 0,sn:0,msdSent:!1,queue:[]})}start(){this.eventTargets.forEach((e,t)=>{if(this.disarmInterval(e),0===t.interval||!t.events.includes("t"))return;let i=()=>{this.recordTargetEvent(e,t,"t"),this.processEventTargets()};e.intervalId=setInterval(i,1e3*t.interval),i()})}stop(e=!1){e&&this.flush(),this.eventTargets.forEach(e=>{this.disarmInterval(e)})}flush(){this.processEventTargets(!0)}update(e){e.sid&&e.sid!==this.data.sid&&this.resetSession(),e.msd&&!isNaN(e.msd)&&(this.msd=e.msd),this.data=Gi(Gi(Gi({},this.data),e),{},{msd:void 0});for(let t of ju)t.field in e&&!t.equal(this.data[t.field],this.lastEmitted[t.field])&&this.recordEvent(t.event)}recordEvent(e,t={}){let i=zu.get(e);if(i){let e=i.field,r=t[e];void 0!==r&&$i(this.data,{[e]:r});let a=this.data[e];if(void 0===a||i.equal(a,this.lastEmitted[e]))return;$i(this.lastEmitted,{[e]:i.snapshot(a)})}this.eventTargets.forEach((i,r)=>{this.recordTargetEvent(i,r,e,t)}),this.processEventTargets()}recordTargetEvent(e,t,i,r={}){var a;if(!t.events.includes(i))return;let n=Gi(Gi(Gi({},this.data),r),{},{e:i,ts:null!=(a=r.ts)?a:Date.now(),sn:e.sn++});!isNaN(this.msd)&&!e.msdSent&&(n.msd=this.msd,e.msdSent=!0),e.queue.push(n)}recordResponseReceived(e,t={}){var i,r,a;let{request:n}=e,s=null!=(i=t.url)?i:null==n?void 0:n.url;if(!s)return;let o=new URL(s);o.searchParams.delete(Iu);let l={url:o.toString(),rc:e.status},d=e.resourceTiming;d&&(null!=d.startTime&&(l.ts=Math.round(this.timeOrigin+d.startTime),null!=d.responseStart&&(l.ttfb=Math.round(d.responseStart-d.startTime))),null!=d.duration&&(l.ttlb=Math.round(d.duration)));let u=null!=(r=null==(a=n.customData)?void 0:a.cmcd)?r:{};this.recordEvent(Vd,Gi(Gi(Gi({},u),l),t))}applyRequestReport(e){var t;return null!=(t=this.createRequestReport(e))?t:e}isRequestReportingEnabled(){var e;return!(null==(e=this.config.enabledKeys)||!e.length)}createRequestReport(e,t){var i;let{customData:r={},headers:a={}}=e,n=Gi(Gi({},Ki(e,Ud)),{},{headers:Gi({},a),customData:Gi(Gi({},r),{},{cmcd:{}})});if(null==(i=this.config.enabledKeys)||!i.length||!n.url)return n;let s=new URL(n.url),o=Gi(Gi(Gi({},this.data),t),{},{sn:this.requestTarget.sn++}),l=Vu(Zd,this.config,n.url);!isNaN(this.msd)&&!this.requestTarget.msdSent&&(o.msd=this.msd,this.requestTarget.msdSent=!0);let d=n.customData.cmcd=Eu(o,l);switch(this.config.transmissionMode){case Ku:let e=Ru(d);e&&(s.searchParams.set(Iu,e),n.url=s.toString());break;case Wu:$i(n.headers,function(e,t){let i={},r=ku(e,t);for(let[e,t]of Object.entries(r)){let r=xd(t,{whitespace:!1});r&&(i[e]=r)}return i}(d,l.customHeaderMap))}return n}processEventTargets(e=!1){let t=!1;this.eventTargets.forEach((i,r)=>{let{queue:a}=i;if(!a.length||a.length<r.batchSize&&!e)return;let n=e?a.length:r.batchSize,s=a.splice(0,n);this.sendEventReport(r,s).catch(()=>{i.queue.unshift(...s)}),t||(t=a.length>0)}),t&&this.processEventTargets()}async sendEventReport(e,t){let i=Vu(Xd,e),{status:r}=await this.requester({url:e.url,method:"POST",headers:{"Content-Type":"application/cmcd"},body:t.map(e=>function(e,t={}){return e?Ru(Eu(e,t)):""}(e,i)).join("\n")+"\n"});if(410===r)this.disposeEventTarget(e);else if(429===r||r>499&&r<600)throw new Error(`Event report failed with status ${r}`)}disarmInterval(e){clearInterval(e.intervalId),e.intervalId=void 0}disposeEventTarget(e){let t=this.eventTargets.get(e);t&&(this.disarmInterval(t),this.eventTargets.delete(e))}resetSession(){this.eventTargets.forEach(e=>e.sn=0),this.requestTarget.sn=0,this.lastEmitted={}}},Zu="h",Ju="v",eh="l",th="ll";function ih(e,t){return new yd(e,t)}new Set(uu),new Set(Lu);var rh=["includeKeys"];function ah(e){return Object.keys(e).every(iu)}function nh(e,t,i,r){e&&Object.keys(t).forEach(a=>{let n=e.filter(e=>e.groupId===a).map(e=>{let n=$i({},e);return n.details=void 0,n.attrs=new ds(n.attrs),n.url=n.attrs.URI=sh(e.url,e.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",i),n.groupId=n.attrs["GROUP-ID"]=t[a],n.attrs["PATHWAY-ID"]=r,n});e.push(...n)})}function sh(e,t,i,r){if(t){let{[i]:e}=r;if(e){let i=e[t];if(i)return i}}let{HOST:a,PARAMS:n}=r,s=new self.URL(e);return a&&(s.hostname=a),n&&Object.keys(n).sort().forEach(e=>{e&&Wa(s,e,n[e])}),s.href}var oh=class{constructor(){this.status="initialized",this.requestErrors=[],this.licenseXhr=void 0,this.onmessage=void 0,this.onkeystatuseschange=void 0,this.emitter=new Bo,this.error=void 0,this.ok=void 0}get errored(){return this.error}set errored(e){this.error=e,this.emitter.eventNames().length&&this.emitter.emit("error",e)}get hasListeners(){return this.emitter.eventNames().length>0}get resolved(){return this.ok}resolve(){this.ok=!0,this.emitter.emit("resolved")}get useable(){return this.ok?Promise.resolve():this.error?Promise.reject(this.error):new Promise((e,t)=>{this.emitter.on("error",t),this.emitter.on("resolved",e)})}reset(){this.emitter.removeAllListeners();let e=this.licenseXhr;e&&(e.readyState!==XMLHttpRequest.DONE&&e.abort(),this.licenseXhr=void 0),this.onmessage=this.onkeystatuseschange=void 0}},lh=class extends Error{constructor(e,t){super(t),this.data=void 0,e.error||(e.error=new Error(t)),this.data=e,e.err=e.error}},dh=class e extends tr{constructor(t){super("eme",t.logger),this.hls=void 0,this.config=void 0,this.media=null,this.mediaResolved=void 0,this.keyFormatPromise=null,this.keySystemAccessPromises={},this.sessionSetupByUri={},this.mediaKeySessions=[],this.activeKeys={},this.mediaKeys=null,this.setMediaKeysQueue=e.CDMCleanupPromise?[e.CDMCleanupPromise]:[],this.onMediaEncrypted=e=>{let{initDataType:t,initData:i}=e,r=`"${e.type}" event: init data type: "${t}"`;if(this.log(r),null!==i){if(!this.keyFormatPromise){let e=Object.keys(this.keySystemAccessPromises);e.length||(e=Ds(this.config));let t=e.map(ws).filter(e=>!!e);this.keyFormatPromise=this.getKeyFormatPromise(t)}this.keyFormatPromise.then(a=>{let n,s,o=Rs(a),l=this.activeLevelKeys();if(o===As.FAIRPLAY&&"sinf"===t)try{let e=Pr(new Uint8Array(i)),t=ra(Mr(JSON.parse(e).sinf));if(!t)throw new Error("'schm' box missing or not cbcs/cenc with schi > tenc");n=new Uint8Array(t.subarray(8,24))}catch(e){return void this.warn(`${r} Failed to parse sinf: ${e}`)}else if(o===As.PLAYREADY)n=Ms(new Uint8Array(i));else if(o===As.WIDEVINE){let e=ca(i).filter(e=>e.systemId===Ls);if(e.length){var d;let t=e[0];n=null!=(d=t.kids)&&d.length?t.kids[0]:null}}if(n){let e=Dr(n);for(let r=0;r<l.length;r++){let a=l[r];if(a.keyId&&(fs(n,a.keyId)||-1!==a.uri.replace(/-/g,"").indexOf(e))){a.pssh||(a.scheme=t,a.pssh=new Uint8Array(i),a.keyId=n,xs.setKeyIdForUri(a.uri,n)),s=this.getSessionForKey(a,"encrypted-event-key-match");break}}}if(!s){var u,h;if(l.length)return(u=l[0]).scheme||(u.scheme=t),(h=l[0]).pssh||(h.pssh=new Uint8Array(i)),this.getSessionForKey(l[0],"encrypted-event-no-match");if(n)throw new Error(`Key ID ${Dr(n)} not encountered in playlist`);this.log(`Ignoring "${e.type}" event - could not determine keyId`)}return s}).catch(e=>this.handleError(e))}},this.onWaitingForKey=e=>{this.log(`"${e.type}" event`)},this.hls=t,this.config=t.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=null,this.onMediaEncrypted=this.onWaitingForKey=null}registerListeners(){let{hls:e}=this;e&&(e.on(Ai.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Ai.MEDIA_DETACHED,this.onMediaDetached,this),e.on(Ai.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Ai.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(Ai.DESTROYING,this.onDestroying,this))}unregisterListeners(){let{hls:e}=this;e&&(e.off(Ai.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Ai.MEDIA_DETACHED,this.onMediaDetached,this),e.off(Ai.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Ai.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(Ai.DESTROYING,this.onDestroying,this))}attemptKeySystemAccess(e){if(!this.hls)return Promise.reject(new Error("destroyed"));let t=this.hls.levels,i=(e,t,i)=>!!e&&i.indexOf(e)===t,r=t.map(e=>e.audioCodec).filter(i),a=t.map(e=>e.videoCodec).filter(i);return r.length+a.length===0&&a.push("avc1.42e01e"),new Promise((t,i)=>{let n=e=>{let s=e.shift();this.getMediaKeysPromise(s,r,a).then(e=>t({keySystem:s,mediaKeys:e})).catch(t=>{e.length?n(e):i(t instanceof lh?t:new lh({type:bi.KEY_SYSTEM_ERROR,details:Ti.KEY_SYSTEM_NO_ACCESS,error:t,fatal:!0},t.message))})};n(e)})}requestMediaKeySystemAccess(e,t){let{requestMediaKeySystemAccessFunc:i}=this.config;if("function"!=typeof i){let e=`Configured requestMediaKeySystemAccess is not a function ${i}`;return null===Cs&&"http:"===self.location.protocol&&(e=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(e))}return i(e,t)}getMediaKeysPromise(e,t,i){var r;let a=function(e,t,i,r){let a;switch(e){case As.FAIRPLAY:a=["cenc","sinf"];break;case As.WIDEVINE:case As.PLAYREADY:a=["cenc"];break;case As.CLEARKEY:a=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${e}`)}return function(e,t,i,r){return[{initDataTypes:e,persistentState:r.persistentState||"optional",distinctiveIdentifier:r.distinctiveIdentifier||"optional",sessionTypes:r.sessionTypes||[r.sessionType||"temporary"],audioCapabilities:t.map(e=>({contentType:`audio/mp4; codecs=${e}`,robustness:r.audioRobustness||"",encryptionScheme:r.audioEncryptionScheme||null})),videoCapabilities:i.map(e=>({contentType:`video/mp4; codecs=${e}`,robustness:r.videoRobustness||"",encryptionScheme:r.videoEncryptionScheme||null}))}]}(a,t,i,r)}(e,t,i,this.config.drmSystemOptions||{}),n=this.keySystemAccessPromises[e],s=null==(r=n)?void 0:r.keySystemAccess;if(!s){this.log(`Requesting encrypted media "${e}" key-system access with config: ${tn(a)}`),s=this.requestMediaKeySystemAccess(e,a);let t=n=this.keySystemAccessPromises[e]={keySystemAccess:s};return s.catch(t=>{this.log(`Failed to obtain access to key-system "${e}": ${t}`)}),s.then(i=>{this.throwIfDestroyed(),this.log(`Access for key-system "${i.keySystem}" obtained`);let r=this.fetchServerCertificate(e);this.log(`Create media-keys for "${e}"`);let a=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 a.catch(t=>{this.error(`Failed to create media-keys for "${e}"}: ${t}`)}),a})}return s.then(()=>n.mediaKeys)}getMediaKeySessionContext(e,t,i,r){let{mediaKeySessions:a}=this,n=` key-session "${e}" keyId: ${Dr(i.keyId||[])} keyUri: ${i.uri} for "${r}"`;for(let e=0;e<a.length;e++){let t=a[e];if(!t.initialized&&t.createdFor.levelKey.uri===i.uri)return this.log(`Reusing${n}`),t}this.log(`Creating${n}`);let s=t.createSession(),o={keySystem:e,mediaKeys:t,mediaKeysSession:s,keyRequests:{},keyStatuses:{},createdFor:{levelKey:i,reason:r},initialized:!1};return a.push(o),o}resetMediaKeys(){var e;let t=null==(e=this.mediaKeySessions[0])?void 0:e.keySystem,i=this.keySystemAccessPromises[t];i&&(this.log("reset mediaKeys"),this.mediaKeys=null,i.hasMediaKeys=!1,delete i.mediaKeys,delete this.keySystemAccessPromises[t])}updateKeySession(e,t,i){let r=e.mediaKeysSession;return this.log(`Updating key-session "${r.sessionId}" for keyId ${Dr(t.keyId||[])}\n      } (data length: ${i.byteLength})`),r.update(i)}getSelectedKeySystemFormats(){return Object.keys(this.keySystemAccessPromises).map(e=>({keySystem:e,hasMediaKeys:this.keySystemAccessPromises[e].hasMediaKeys})).filter(({hasMediaKeys:e})=>!!e).map(({keySystem:e})=>ws(e)).filter(e=>!!e)}getKeySystemAccess(e){return this.getKeySystemSelectionPromise(e).then(({keySystem:e,mediaKeys:t})=>this.attemptSetMediaKeys(e,t))}selectKeySystem(e){return this.getKeySystemSelectionPromise(e).then(({keySystem:e})=>{let t=ws(e);if(!t)throw new Error(`Unable to find format for key-system "${e}"`);return t})}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=Ds(this.config),i=e.map(Rs).filter(e=>!!e&&-1!==t.indexOf(e));return this.selectKeySystem(i)}loadClear(e,t,i){if(this.config.emeEnabled&&!this.getSelectedKeySystemFormats().length){if(t.length)for(let r=0,a=t.length;r<a;r++){let n=t[r];if(e.cc<=n.cc&&(!Pi(e)||!Pi(n)||e.sn<n.sn)||!i&&r==a-1)return this.selectKeySystemFormat(n).then(e=>{if(!this.hls)return;n.setKeyFormat(e);let t=Rs(e);return t?this.getKeySystemAccess([t]):void 0})}if(this.config.requireKeySystemAccessOnStart){let e=Ds(this.config);if(e.length)return this.getKeySystemAccess(e)}}return null}getKeyStatus(e){let{mediaKeySessions:t}=this;for(let i=0;i<t.length;i++){let r=uh(e,t[i]);if(r)return r}}loadKey(e){let t=e.decryptdata,i=this.getKeyStatus(t);if("internal-error"===i){let r=hh(i,t);return r.data.frag=e,this.error(`${r.message} (${Dr(t.keyId||[])})`),Promise.reject(r)}let r=e.type,a=this.activeKeys,n=a[r];n&&!t.matches(n.decryptdata)&&(a.previous||(a.previous=[]),a.previous.push(n),delete a[r]),a[r]||(a[r]=e);for(let e=this.mediaKeySessions.length;e--;){let i=this.mediaKeySessions[e];if(t.keyId&&"expired"===i.keyStatuses[Dr(t.keyId)])return this.renewKeySession(t,i)}return this.updateUsablePromise(t,"playlist-key",e)}renewKeySession(e,t){return this.resetMediaKeys(),this.removeSession(t).then(()=>(this.throwIfDestroyed(),this.updateUsablePromise(e,"expired")))}updateUsablePromise(e,t,i){let r=this.getSessionForKey(e,t);return r.catch(e=>this.handleError(e,i)),r.then(t=>e)}getSessionForKey(e,t){let i=this.findContextForKey(e);if(void 0!==i)return Promise.resolve(i);let r,a=e.uri,n=this.sessionSetupByUri[a];r=void 0===n?this.resolveSessionForKey(e,t):n.catch(()=>{}).then(()=>(this.throwIfDestroyed(),this.resolveSessionForKey(e,t))),this.sessionSetupByUri[a]=r;let s=()=>{this.sessionSetupByUri[a]===r&&delete this.sessionSetupByUri[a]};return r.then(s,s),r}findContextForKey(e){let{mediaKeySessions:t}=this;for(let i=t.length;i--;){let r=t[i];if(uh(e,r))return r}}resolveSessionForKey(e,t){return this.getKeySystemForKeyPromise(e).then(({keySystem:i,mediaKeys:r})=>{this.throwIfDestroyed();for(let i=this.mediaKeySessions.length;i--;){let r=this.mediaKeySessions[i];if(uh(e,r))return r;let a=this.getUsableKeyPromise(r,e,t);if(a)return a}return this.attemptSetMediaKeys(i,r).then(()=>(this.throwIfDestroyed(),this.getMediaKeySessionContext(i,r,e,t))).then(i=>{this.throwIfDestroyed();let r=e.scheme||"cenc",a=e.pssh?e.pssh.buffer:null;return this.generateRequestWithPreferredKeySession(i,e,r,a,t)})})}getUsableKeyPromise(e,t,i){let r=e.keyRequests[t.uri];if(r)return this.log(`Waiting for usable key (${i} keyId: ${function(e){if(e.keyFormat===Ss)return e.uri;if(null===e.keyId)throw new Error("keyId is null");return Dr(e.keyId)}(t)} format: "${t.keyFormat}" URI: ${t.uri})`),r.useable.then(()=>e)}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e,t){if(this.hls)if(e instanceof lh){t&&(e.data.frag=t);let i=e.data.decryptdata;this.error(`${e.message}${i?` (${Dr(i.keyId||[])})`:""}`),this.hls.trigger(Ai.ERROR,e.data)}else this.error(e.message),this.hls.trigger(Ai.ERROR,{type:bi.KEY_SYSTEM_ERROR,details:Ti.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0})}getKeySystemForKeyPromise(e){let t=Rs(e.keyFormat),i=t?[t]:Ds(this.config);return this.attemptKeySystemAccess(i)}getKeySystemSelectionPromise(e){if(e.length||(e=Ds(this.config)),0===e.length)throw new lh({type:bi.KEY_SYSTEM_ERROR,details:Ti.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${tn({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}activeLevelKeys(){let e=this.activeKeys,t=(e.previous||[]).map(e=>e.decryptdata);return e.audio&&t.unshift(e.audio.decryptdata),e.main&&t.unshift(e.main.decryptdata),t}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(new Error("Attempted to set mediaKeys without media element attached"));this.mediaKeys=t,this.media.setMediaKeys(t).then(e).catch(i)}}));return this.mediaKeys=t,this.setMediaKeysQueue.push(r),r.then(()=>{this.log(`Media-keys set for "${e}"`),i.push(r),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(e=>-1===i.indexOf(e))})}filterInitData(e,t,i,r,a){var n;let s=null==(n=this.config.drmSystems)||null==(n=n[e.keySystem])?void 0:n.generateRequest;if(s)try{let n=s.call(this.hls,i,r,$i({},e,{decryptdata:t,reason:a}),a);if(!n)throw new Error("Invalid response from configured generateRequest filter");t.scheme=n.initDataType?n.initDataType:"cenc";let o=n.initData?n.initData:null;return t.pssh=o?new Uint8Array(o):null,n}catch(e){var o;if(this.warn(e.message),null!=(o=this.hls)&&o.config.debug)throw e}return{initDataType:i,initData:r}}generateRequestWithPreferredKeySession(e,t,i,r,a){let n=this.getUsableKeyPromise(e,t,a);if(n)return n;let s=this.filterInitData(e,t,i,r,a);if(s&&(r=s.initData?s.initData:null,i=s.initDataType),null===r)return a.startsWith("encrypted-event")?Promise.reject(new Error(`missing initialization data for "${a}"`)):(this.log(`Skipping key-session request for "${a}" (no initData)`),Promise.resolve(e));let o=t.uri,l=new oh;e.keyRequests[o]=l;let d=i=>{let r=e.mediaKeysSession;if(!r){let e=new Error("invalid state");return void(l.errored=e)}let{messageType:a,message:n}=i;l.status=a,this.log(`"${a}" message event for session "${r.sessionId}" message size: ${n.byteLength}`),"license-request"===a||"license-renewal"===a?this.renewLicense(e,t,n).catch(t=>{l.errored=t,l.hasListeners||this.handleError(t),this.removeSession(e)}):"license-release"===a?e.keySystem===As.FAIRPLAY&&this.updateKeySession(e,t,Es("acknowledged")).then(()=>this.removeSession(e)).catch(e=>this.handleError(e)):this.warn(`unhandled media key message type "${a}"`)};return l.onmessage=d,vo(e.mediaKeysSession,"message",d),this.generateRequest(e,t,i,r,a,!1)}generateRequest(e,t,i,r,a,n){if(n){let n=this.filterInitData(e,t,i,r,a);n&&(r=n.initData?n.initData:r,i=n.initDataType)}let s=t.uri,o=e.keyRequests[s],l=Dr(t.keyId||[]),d=e=>{let i;e.startsWith("usable")?o.resolve():"internal-error"===e||"output-restricted"===e||"output-downscaled"===e?i=hh(e,t):"expired"===e?i=new Error(`key expired (keyId: ${l})`):"released"===e?i=new Error("key released"):"status-pending"===e||this.warn(`unhandled key status change "${e}" (keyId: ${l})`),i&&(o.errored=i,o.hasListeners||this.handleError(i))},u=i=>{if(!e.mediaKeysSession){let e=new Error("invalid state");return void(o.errored=e)}let r=e.keyStatuses=this.getKeyStatuses(e);if(!Object.keys(r).some(e=>"status-pending"!==r[e]))return;let a=this.activeLevelKeys();for(let i=0;i<a.length;i++){let s=Dr(a[i].keyId||[]);if("expired"===r[s]){var n;this.log(`Expired key ${tn(r)} in key-session "${null==(n=e.mediaKeysSession)?void 0:n.sessionId}"`),this.renewKeySession(t,e).catch(e=>this.handleError(e));break}}let s=r[l];var u;s?d(s):(e.keyStatusTimeouts||(e.keyStatusTimeouts={}),(u=e.keyStatusTimeouts)[l]||(u[l]=self.setTimeout(()=>{var i;if(!e.mediaKeysSession)return;let r=this.getKeyStatus(t);var a;if(r&&"status-pending"!==r)return this.log(`No status for keyId ${l} in key-session "${null==(a=e.mediaKeysSession)?void 0:a.sessionId}". Using session key-status ${r} from other session.`),d(r);this.log(`key status for ${l} in key-session "${null==(i=e.mediaKeysSession)?void 0:i.sessionId}" timed out after 1000ms`),s="internal-error",d(s)},1e3)),this.log(`No status for keyId ${l} (${tn(r)}).`))};o.onkeystatuseschange=u,vo(e.mediaKeysSession,"keystatuseschange",u);let h=o.useable;return this.log(`Generating key-session request for "${a}" keyId: ${l} URI: ${s} (init data type: ${i} length: ${r.byteLength})`),o.status="started",e.initialized=!0,e.mediaKeysSession.generateRequest(i,r).then(()=>{var t;o.status="generated",this.log(`Request generated for key-session "${null==(t=e.mediaKeysSession)?void 0:t.sessionId}" keyId: ${l} URI: ${s}`)}).catch(e=>{throw this.log(`mediaKeysSession.generateRequest failed: ${e}`),new lh({type:bi.KEY_SYSTEM_ERROR,details:Ti.KEY_SYSTEM_NO_SESSION,error:e,decryptdata:t,fatal:!1},`Error generating key-session request: ${e}`)}).then(()=>h).catch(t=>{var i;this.log(`mediaKeysSession.generateRequest failed: ${t}`);let r=null==(i=t.data)?void 0:i.details;return r!==Ti.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED&&r!==Ti.KEY_SYSTEM_STATUS_INTERNAL_ERROR||!Object.keys(e.keyStatuses).some(t=>"usable"===e.keyStatuses[t])?this.removeSession(e).then(()=>{throw t}):(this.handleError(t),e)}).then(()=>e)}getKeyStatuses(e){let t={},i=e.mediaKeysSession.sessionId;return e.mediaKeysSession.keyStatuses.forEach((r,a)=>{if("string"==typeof a&&"object"==typeof r){let e=a;a=r,r=e}let n="buffer"in a?new Uint8Array(a.buffer,a.byteOffset,a.byteLength):new Uint8Array(a);if(e.keySystem===As.PLAYREADY&&16===n.length){let e=Dr(n);t[e]=r,ys(n)}let s=Dr(n);this.log(`key status change "${r}" for keyStatuses keyId: ${s} key-session "${i}"`),t[s]=r}),t}fetchServerCertificate(e){let t=this.config,i=new(0,t.loader)(t),r=function(e,t){let{drmSystems:i}=t,r=null==i?void 0:i[e];if(r)return r.serverCertificateUrl}(e,t);return r?(this.log(`Fetching server certificate for "${e}"`),new Promise((a,n)=>{let s={type:Ri.SERVER_CERTIFICATE,responseType:"arraybuffer",url:r},o=t.certLoadPolicy.default,l={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},d={onSuccess:(e,t,i,r)=>{a(e.data)},onError:(t,i,a,o)=>{n(new lh({type:bi.KEY_SYSTEM_ERROR,details:Ti.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:a,response:Gi({url:s.url,data:void 0},t)},`"${e}" certificate request failed (${r}). Status: ${t.code} (${t.text})`))},onTimeout:(t,i,a)=>{n(new lh({type:bi.KEY_SYSTEM_ERROR,details:Ti.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:a,response:{url:s.url,data:void 0}},`"${e}" certificate request timed out (${r})`))},onAbort:(e,t,i)=>{n(new Error("aborted"))}};i.load(s,l,d)})):(this.log(`No Server Certificate in config.drmSystems["${e}"]`),Promise.resolve())}setMediaKeysServerCertificate(e,t,i){return new Promise((r,a)=>{e.setServerCertificate(i).then(a=>{this.log(`setServerCertificate ${a?"success":"not supported by CDM"} (${i.byteLength}) on "${t}"`),r(e)}).catch(e=>{a(new lh({type:bi.KEY_SYSTEM_ERROR,details:Ti.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:e,fatal:!0},e.message))})})}renewLicense(e,t,i){return this.requestLicense(e,t,new Uint8Array(i)).then(i=>this.updateKeySession(e,t,new Uint8Array(i)).catch(e=>{throw new lh({type:bi.KEY_SYSTEM_ERROR,details:Ti.KEY_SYSTEM_SESSION_UPDATE_FAILED,decryptdata:t,error:e,fatal:!1},e.message)}))}unpackPlayReadyKeyMessage(e,t){let i=Pr(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"),a=r.querySelectorAll("HttpHeader");if(a.length>0){let t;for(let i=0,r=a.length;i<r;i++){var n,s;t=a[i];let r=null==(n=t.querySelector("name"))?void 0:n.textContent,o=null==(s=t.querySelector("value"))?void 0:s.textContent;r&&o&&e.setRequestHeader(r,o)}}let o=r.querySelector("Challenge"),l=null==o?void 0:o.textContent;if(!l)throw new Error("Cannot find <Challenge> in key message");return Es(atob(l))}setupLicenseXHR(e,t,i,r,a){let n=this.config.licenseXhrSetup;return n?Promise.resolve().then(()=>(this.throwIfDestroyed(),n.call(this.hls,e,t,Gi(Gi({},i),{},{decryptdata:r}),a))).catch(s=>{if(!i.mediaKeysSession)throw s;return e.open("POST",t,!0),n.call(this.hls,e,t,Gi(Gi({},i),{},{decryptdata:r}),a)}).then(i=>(e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:i||a})):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:a}))}requestLicense(e,t,i){return new Promise((r,a)=>{let n=function(e,t){let{drmSystems:i,widevineLicenseUrl:r}=t,a=null==i?void 0:i[e];if(a)return a.licenseUrl;if(e===As.WIDEVINE&&r)return r}(e.keySystem,this.config);if(!n)return a(new Error(`no license server URL configured for key-system "${e.keySystem}"`));let s=e.keyRequests[t.uri];if(!s)return a(new Error("License emitter removed"));this.log(`Sending license request to URL: ${n}`);let o=this.config.keyLoadPolicy.default,l=new XMLHttpRequest;l.responseType="arraybuffer",l.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return a(new Error("invalid state"));if(4===l.readyState)if(200===l.status){s.requestErrors=[];let i=l.response;this.log(`License received ${i instanceof ArrayBuffer?i.byteLength:i}`);let a=this.config.licenseResponseCallback;if(a)try{i=a.call(this.hls,l,n,Gi(Gi({},e),{},{decryptdata:t}))}catch(e){this.error(e)}r(i)}else{let d=o.errorRetry,u=d?d.maxNumRetry:0;if(s.requestErrors.push({status:l.status,message:l.statusText}),s.requestErrors.length>u||l.status>=400&&l.status<500)a(new lh({type:bi.KEY_SYSTEM_ERROR,details:Ti.KEY_SYSTEM_LICENSE_REQUEST_FAILED,decryptdata:t,fatal:!0,networkDetails:l,response:{url:n,data:void 0,code:l.status,text:l.statusText}},`License Request XHR failed (${n}). Status: ${l.status} (${l.statusText})`));else{let n=u-s.requestErrors.length;this.warn(`Retrying license request, ${n} attempts left`),this.requestLicense(e,t,i).then(r,a)}}},s.licenseXhr&&s.licenseXhr.readyState!==XMLHttpRequest.DONE&&s.licenseXhr.abort(),s.licenseXhr=l,this.setupLicenseXHR(l,n,e,t,i).then(({xhr:t,licenseChallenge:i})=>{e.keySystem==As.PLAYREADY&&(i=this.unpackPlayReadyKeyMessage(t,i)),t.send(i)}).catch(a)})}onDestroying(){this.unregisterListeners(),this._clear()}onMediaAttached(e,t){if(!this.config.emeEnabled)return;let i=t.media;this.media=i,vo(i,"encrypted",this.onMediaEncrypted),vo(i,"waitingforkey",this.onWaitingForKey);let r=this.mediaResolved;r?r():this.mediaKeys=i.mediaKeys}onMediaDetached(){let e=this.media;e&&(Eo(e,"encrypted",this.onMediaEncrypted),Eo(e,"waitingforkey",this.onWaitingForKey),this.media=null,this.mediaKeys=null)}_clear(){var t;this.keyFormatPromise=null,this.keySystemAccessPromises={},this.activeKeys={},this.sessionSetupByUri={};let i=this.mediaResolved;if(i&&i(),!this.mediaKeys&&!this.mediaKeySessions.length)return;let r=this.media,a=this.mediaKeySessions.slice();this.mediaKeySessions=[],this.mediaKeys=null,xs.clearKeyUriToKeyIdMap();let n=a.length;e.CDMCleanupPromise=Promise.all(a.map(e=>this.removeSession(e)).concat((null==r||null==(t=r.setMediaKeys(null))?void 0:t.catch(e=>{this.log(`Could not clear media keys: ${e}`),this.hls&&this.hls.trigger(Ai.ERROR,{type:bi.OTHER_ERROR,details:Ti.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR,fatal:!1,error:new Error(`Could not clear media keys: ${e}`)})}))||Promise.resolve())).catch(e=>{this.log(`Could not close sessions and clear media keys: ${e}`),this.hls&&this.hls.trigger(Ai.ERROR,{type:bi.OTHER_ERROR,details:Ti.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close sessions and clear media keys: ${e}`)})}).then(()=>{n&&this.log("finished closing key sessions and clearing media keys")})}onManifestLoading(){this._clear(),this.keyFormatPromise=null}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),this.keyFormatPromise.catch(()=>{})}}removeSession(e){let{mediaKeysSession:t}=e;if(t){this.log(`Remove licenses and keys and close session "${t.sessionId}"`),Object.keys(e.keyRequests).forEach(i=>{let r=e.keyRequests[i];r.onmessage&&t.removeEventListener("message",r.onmessage),r.onkeystatuseschange&&t.removeEventListener("keystatuseschange",r.onkeystatuseschange),r.reset(),e.keyRequests[i]=void 0}),e.mediaKeysSession=void 0;let i=this.mediaKeySessions.indexOf(e);i>-1&&this.mediaKeySessions.splice(i,1);let{keyStatusTimeouts:r}=e;r&&Object.keys(r).forEach(e=>self.clearTimeout(r[e]));let{drmSystemOptions:a}=this.config;return(function(e){var t;return!(!e||"persistent-license"!==e.sessionType&&(null==(t=e.sessionTypes)||!t.some(e=>"persistent-license"===e)))}(a)?new Promise((e,i)=>{self.setTimeout(()=>i(new 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(Ai.ERROR,{type:bi.OTHER_ERROR,details:Ti.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR,fatal:!1,error:new Error(`Could not remove session: ${e}`)})}).then(()=>t.close()).then(()=>t.closed).catch(e=>{this.log(`Could not close session: ${e}`),this.hls&&this.hls.trigger(Ai.ERROR,{type:bi.OTHER_ERROR,details:Ti.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close session: ${e}`)})})}return Promise.resolve()}};function uh(e,t){let i=e.keyId,r=t.mediaKeysSession;if(i&&r){let e=t.mediaKeysSession.keyStatuses;if(e.size)return e.has(i)?e.get(i):t.keyStatuses[Dr(i)]}}function hh(e,t){let i="output-restricted"===e,r=i?Ti.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:Ti.KEY_SYSTEM_STATUS_INTERNAL_ERROR;return new lh({type:bi.KEY_SYSTEM_ERROR,details:r,fatal:!1,decryptdata:t},i?"HDCP level output restricted":`key status changed to "${e}"`)}dh.CDMCleanupPromise=void 0;var ch=function(){if(null!=Ts&&Ts.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){return i(t,e)}function a(e,...t){let i=1;for(;i<arguments.length;i++){let t=arguments[i];for(let i in t)e[i]=t[i]}return e}function n(t,n,s){let o=this,l={enumerable:!0};o.hasBeenReset=!1;let d="",u=!1,h=t,c=n,m=s,f=null,p="",g=!0,v="auto",E="start",y=50,b="middle",T=50,A="middle";Object.defineProperty(o,"id",a({},l,{get:function(){return d},set:function(e){d=""+e}})),Object.defineProperty(o,"pauseOnExit",a({},l,{get:function(){return u},set:function(e){u=!!e}})),Object.defineProperty(o,"startTime",a({},l,{get:function(){return h},set:function(e){if("number"!=typeof e)throw new TypeError("Start time must be set to a number.");h=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"endTime",a({},l,{get:function(){return c},set:function(e){if("number"!=typeof e)throw new TypeError("End time must be set to a number.");c=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"text",a({},l,{get:function(){return m},set:function(e){m=""+e,this.hasBeenReset=!0}})),Object.defineProperty(o,"region",a({},l,{get:function(){return f},set:function(e){f=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"vertical",a({},l,{get:function(){return p},set:function(t){let r=function(t){return i(e,t)}(t);if(!1===r)throw new SyntaxError("An invalid or illegal string was specified.");p=r,this.hasBeenReset=!0}})),Object.defineProperty(o,"snapToLines",a({},l,{get:function(){return g},set:function(e){g=!!e,this.hasBeenReset=!0}})),Object.defineProperty(o,"line",a({},l,{get:function(){return v},set:function(e){if("number"!=typeof e&&"auto"!==e)throw new SyntaxError("An invalid number or illegal string was specified.");v=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"lineAlign",a({},l,{get:function(){return E},set:function(e){let t=r(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");E=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"position",a({},l,{get:function(){return y},set:function(e){if(e<0||e>100)throw new Error("Position must be between 0 and 100.");y=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"positionAlign",a({},l,{get:function(){return b},set:function(e){let t=r(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");b=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"size",a({},l,{get:function(){return T},set:function(e){if(e<0||e>100)throw new Error("Size must be between 0 and 100.");T=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"align",a({},l,{get:function(){return A},set:function(e){let t=r(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");A=t,this.hasBeenReset=!0}})),o.displayState=void 0}return n.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},n}(),mh=class{decode(e,t){if(!e)return"";if("string"!=typeof e)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}};function fh(e){function t(e,t,i,r){return 3600*(0|e)+60*(0|t)+(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}var ph=class{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 gh(e,t,i,r){let a=r?e.split(r):[e];for(let e in a){if("string"!=typeof a[e])continue;let r=a[e].split(i);2===r.length&&t(r[0],r[1])}}var vh=new ch(0,0,""),Eh="middle"===vh.align?"middle":"center";function yh(e,t,i){let r=e;function a(){let t=fh(e);if(null===t)throw new Error("Malformed timestamp: "+r);return e=e.replace(/^[^\sa-zA-Z-]+/,""),t}function n(){e=e.replace(/^\s+/,"")}if(n(),t.startTime=a(),n(),"--\x3e"!==e.slice(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+r);e=e.slice(3),n(),t.endTime=a(),n(),function(e,t){let r=new ph;gh(e,function(e,t){let a;switch(e){case"region":for(let a=i.length-1;a>=0;a--)if(i[a].id===t){r.set(e,i[a].region);break}break;case"vertical":r.alt(e,t,["rl","lr"]);break;case"line":a=t.split(","),r.integer(e,a[0]),r.percent(e,a[0])&&r.set("snapToLines",!1),r.alt(e,a[0],["auto"]),2===a.length&&r.alt("lineAlign",a[1],["start",Eh,"end"]);break;case"position":a=t.split(","),r.percent(e,a[0]),2===a.length&&r.alt("positionAlign",a[1],["start",Eh,"end","line-left","line-right","auto"]);break;case"size":r.percent(e,t);break;case"align":r.alt(e,t,["start",Eh,"end","left","right"])}},/:/,/\s/),t.region=r.get("region",null),t.vertical=r.get("vertical","");let a=r.get("line","auto");"auto"===a&&-1===vh.line&&(a=-1),t.line=a,t.lineAlign=r.get("lineAlign","start"),t.snapToLines=r.get("snapToLines",!0),t.size=r.get("size",100),t.align=r.get("align",Eh);let n=r.get("position","auto");"auto"===n&&50===vh.position&&(n="start"===t.align||"left"===t.align?0:"end"===t.align||"right"===t.align?100:50),t.position=n}(e,t)}function bh(e){return e.replace(/<br(?: \/)?>/gi,"\n")}var Th=class{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new mh,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=bh(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}function r(e){gh(e,function(e,t){},/:/)}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;e=i();let r=e.match(/^(ï»¿)?WEBVTT([ \t].*)?$/);if(null==r||!r[0])throw new Error("Malformed WebVTT signature.");t.state="HEADER"}let a=!1;for(;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(a?a=!1:e=i(),t.state){case"HEADER":/:/.test(e)?r(e):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 ch(0,0,""),t.state="CUE",-1===e.indexOf("--\x3e")){t.cue.id=e;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{yh(e,t.cue,t.regionList)}catch{t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":{let i=-1!==e.indexOf("--\x3e");if(!e||i&&(a=!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{"CUETEXT"===t.state&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state="INITIAL"===t.state?"BADWEBVTT":"BADCUE"}return this}flush(){let e=this;try{if((e.cue||"HEADER"===e.state)&&(e.buffer+="\n\n",e.parse()),"INITIAL"===e.state||"BADWEBVTT"===e.state)throw new Error("Malformed WebVTT signature.")}catch(t){e.onparsingerror&&e.onparsingerror(t)}return e.onflush&&e.onflush(),this}};function Ah(e){let t=5381,i=e.length;for(;i;)t=33*t^e.charCodeAt(--i);return(t>>>0).toString()}var _h=/\r\n|\n\r|\n|\r/g,Sh="Missing initPTS for VTT ";function kh(e,t,i){return Ah(e.toString())+Ah(t.toString())+Ah(i)}function Ih(e,t,i,r,a,n,s){let o,l=new Th,d=Ar(new Uint8Array(e)).trim().replace(_h,"\n").split("\n"),u=[],h=t?function(e,t=1){return Bl(e,9e4,1/t)}(t.baseTime,t.timescale):0,c="00:00.000",m=0,f=0,p=!1,g=!0;l.oncue=function(e){let n=i[r],s=i.ccOffset,l=(m-h)/9e4;if(p){if(null!=n&&n.new&&(s=i.ccOffset=n.start),l){if(!t)return void(o=new Error(Sh+"MPEGTS"));s=l-i.presentationOffset}}else{if(!t)return void(o=new Error(Sh+"without X-TIMESTAMP-MAP"));s=-t.baseTime/t.timescale}let d=e.endTime-e.startTime,c=Vl(9e4*(e.startTime+s-f),9e4*a)/9e4;e.startTime=Math.max(c,0),e.endTime=Math.max(c+d,0);let g=e.text.trim();e.text=decodeURIComponent(encodeURIComponent(g)),e.id?r&&(e.id=`hlsjscc${r}_${e.id}`):e.id=kh(e.startTime,e.endTime,g),e.endTime>0&&u.push(e)},l.onparsingerror=function(e){o=e},l.onflush=function(){o?s(o):n(u)},d.forEach(e=>{if(g){if(e.startsWith("X-TIMESTAMP-MAP=")){g=!1,p=!0,e.slice(16).split(",").forEach(e=>{e.startsWith("LOCAL:")?c=e.slice(6):e.startsWith("MPEGTS:")&&(m=parseInt(e.slice(7)))});try{f=function(e){let t=parseInt(e.slice(-3)),i=parseInt(e.slice(-6,-4)),r=parseInt(e.slice(-9,-7)),a=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!(vi(t)&&vi(i)&&vi(r)&&vi(a)))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*i,t+=6e4*r,t+=36e5*a,t}(c)/1e3}catch(e){o=e}return}""===e&&(g=!1)}l.parse(e+"\n")}),l.flush()}var Rh="stpp.ttml.im1t",Lh=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,wh=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,Dh={left:"start",center:"center",right:"end",start:"start",end:"end"};function Ch(e,t,i,r){let a=Yr(new Uint8Array(e),["mdat"]);if(0===a.length)return void r(new Error("Could not parse IMSC1 mdat"));let n=a.map(e=>Ar(e)),s=function(e,t,i=1,r=!1){return Bl(e,t,1/i,r)}(t.baseTime,1,t.timescale);try{n.forEach(e=>i(function(e,t){let i=(new DOMParser).parseFromString(e,"text/xml").getElementsByTagName("tt")[0];if(!i)throw new Error("Invalid ttml");let r={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:1},a=Object.keys(r).reduce((e,t)=>(e[t]=i.getAttribute(`ttp:${t}`)||r[t],e),{});!i.getAttribute("ttp:tickRate")&&i.getAttribute("ttp:frameRate")&&(a.tickRate=Number(a.frameRate)*Number(a.subFrameRate));let n="preserve"!==i.getAttribute("xml:space"),s=Ph(Mh(i,"styling","style")),o=Ph(Mh(i,"layout","region")),l=Mh(i,"body","[begin]");return[].map.call(l,e=>{let i=xh(e,n);if(!i||!e.hasAttribute("begin"))return null;let r=Uh(e.getAttribute("begin"),a),l=Uh(e.getAttribute("dur"),a),d=Uh(e.getAttribute("end"),a);if(null===r)throw Nh(e);if(null===d){if(null===l)throw Nh(e);d=r+l}let u=new ch(r-t,d-t,i);u.id=kh(u.startTime,u.endTime,u.text);let h=function(e,t,i){let r="http://www.w3.org/ns/ttml#styling",a=null,n=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],s=null!=e&&e.hasAttribute("style")?e.getAttribute("style"):null;return s&&i.hasOwnProperty(s)&&(a=i[s]),n.reduce((i,n)=>{let s=Oh(t,r,n)||Oh(e,r,n)||Oh(a,r,n);return s&&(i[n]=s),i},{})}(o[e.getAttribute("region")],s[e.getAttribute("style")],s),{textAlign:c}=h;if(c){let e=Dh[c];e&&(u.lineAlign=e),u.align=c}return $i(u,h),u}).filter(e=>null!==e)}(e,s)))}catch(e){r(e)}}function Mh(e,t,i){let r=e.getElementsByTagName(t)[0];return r?[].slice.call(r.querySelectorAll(i)):[]}function Ph(e){return e.reduce((e,t)=>{let i=t.getAttribute("xml:id");return i&&(e[i]=t),e},{})}function xh(e,t){return[].slice.call(e.childNodes).reduce((e,i,r)=>{var a;return"br"===i.nodeName&&r?e+"\n":null!=(a=i.childNodes)&&a.length?xh(i,t):t?e+i.textContent.trim().replace(/\s+/g," "):e+i.textContent},"")}function Oh(e,t,i){return e&&e.hasAttributeNS(t,i)?e.getAttributeNS(t,i):null}function Nh(e){return new Error(`Could not parse ttml timestamp ${e}`)}function Uh(e,t){if(!e)return null;let i=fh(e);return null===i&&(Lh.test(e)?i=function(e,t){let i=Lh.exec(e),r=(0|i[4])+(0|i[5])/t.subFrameRate;return 3600*(0|i[1])+60*(0|i[2])+(0|i[3])+r/t.frameRate}(e,t):wh.test(e)&&(i=function(e,t){let i=wh.exec(e),r=Number(i[1]);switch(i[2]){case"h":return 3600*r;case"m":return 60*r;case"ms":return r/1e3;case"f":return r/t.frameRate;case"t":return r/t.tickRate}return r}(e,t))),i}function Fh(e,t,i,r="",a="disabled"){let n=e.ownerDocument.createElement("track");return n.kind=t,n.label=i,r&&(n.srclang=r),n.src="data:,WEBVTT",n.track.mode=a,e.appendChild(n),n}function Bh(e){return e.forced&&(Ea.indexOf("Apple")>-1||/iPhone|iPad|iPod/.test(va))?"forced":e.characteristics&&/transcribes-spoken-dialog/gi.test(e.characteristics)&&/describes-music-and-sound/gi.test(e.characteristics)?"captions":"subtitles"}function $h(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 new Error(`addCue is failed for: ${t}`)}catch(i){or.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){or.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${e}`)}}"disabled"===i&&(e.mode=i)}function Hh(e,t,i,r){let a=e.mode;if("disabled"===a&&(e.mode="hidden"),e.cues&&e.cues.length>0){let a=function(e,t,i){let r=[],a=function(e,t){if(t<=e[0].startTime)return 0;let i=e.length-1;if(t>e[i].endTime)return-1;let r,a=0,n=i;for(;a<=n;)if(r=Math.floor((n+a)/2),t<e[r].startTime)n=r-1;else{if(!(t>e[r].startTime&&a<i))return r;a=r+1}return e[a].startTime-t<t-e[n].startTime?a:n}(e,t);if(a>-1)for(let n=a,s=e.length;n<s;n++){let a=e[n];if(a.startTime>=t&&a.endTime<=i)r.push(a);else if(a.startTime>i)return r}return r}(e.cues,t,i);for(let t=0;t<a.length;t++)(!r||r(a[t]))&&e.removeCue(a[t])}"disabled"===a&&(e.mode=a)}function Gh(e,t){let i=Kh(e.main);if(i&&i.start<=t)return i;let r=Kh(e.audio);return r&&r.start<=t?r:null}function Kh(e){if(!e)return null;switch(e.state){case To:case bo:case Lo:case wo:return null}return e.frag}function Wh(e,t){return t.getAppendedFrag(e,Li.MAIN)||t.getPartialFragment(e)}function Vh(e,t,i,r){let a=r.latestLevelDetails,n=Wh(t,i);if(xo(r.config)&&!e.nextStart&&a&&n&&r.interstitialsManager){let i="type"in n?n:n.fragment,s=En(a,i.sn);(null==s?void 0:s.level)===i.level&&Po(s,r.interstitialsManager.playerQueue,t)&&(e.nextStart=s.start)}}function qh(){if("undefined"!=typeof self)return self.VTTCue||self.TextTrackCue}function Yh(e,t,i,r,a){let n=new e(t,i,"");try{n.value=r,a&&(n.type=a)}catch{n=new e(t,i,tn(a?Gi({type:a},r):r))}return n}var jh=(()=>{let e=qh();try{e&&new e(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function zh(){return self.SourceBuffer||self.WebKitSourceBuffer}function Qh(){if(!lr())return!1;let e=zh();return!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove}var Xh,Zh,Jh=0,ec=1,tc=2,ic=class extends Mo{constructor(e,t,i){super(e,t,i,"stream-controller",Li.MAIN),this.audioCodecSwap=!1,this.level=-1,this._forceStartLoad=!1,this._hasEnoughToStart=!1,this.altAudio=Jh,this.audioOnly=!1,this._couldBacktrack=!1,this._backtrackFragment=void 0,this.audioCodecSwitch=!1,this.videoBuffer=null,this.onMediaPlaying=()=>{this.tick()},this.onMediaSeeked=()=>{let e=this.media,t=e?e.currentTime:null;if(null===t||!vi(t)||(this.log(`Media seeked to ${t}`),!this.getBufferedFrag(t)))return;let i=this.getFwdBufferInfoAtPos(e,t,Li.MAIN,0);i&&0!==i.len?this.tick():this.log(`Main buffer empty at ${t} on "seeked" event: ${i&&i.len}`)},this.registerListeners()}registerListeners(){super.registerListeners();let{hls:e}=this;e.on(Ai.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Ai.LEVEL_LOADING,this.onLevelLoading,this),e.on(Ai.LEVEL_LOADED,this.onLevelLoaded,this),e.on(Ai.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(Ai.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(Ai.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(Ai.BUFFER_CREATED,this.onBufferCreated,this),e.on(Ai.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(Ai.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(Ai.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){super.unregisterListeners();let{hls:e}=this;e.off(Ai.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Ai.LEVEL_LOADED,this.onLevelLoaded,this),e.off(Ai.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(Ai.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(Ai.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(Ai.BUFFER_CREATED,this.onBufferCreated,this),e.off(Ai.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(Ai.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(Ai.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.initPTS.length&&(this.log(`Override startPosition with lastCurrentTime @${i}`),e=i),this.state=To,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,!t&&!this.fragmentTracker.hasFragments(this.playlistType)&&(this._hasEnoughToStart=this.startFragRequested=!1),this.tick()}else this._forceStartLoad=!0,this.state=bo}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case Co:{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))){if(this.waitForCdnTuneIn(r))break;this.state=To;break}if(this.hls.nextLoadLevel!==this.level){this.state=To;break}break}case So:this.checkRetryDate()}this.state===To&&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;let a=this.buffering?e.nextLoadLevel:e.loadLevel;if(null==i||!i[a])return;let n=i[a],s=this.getMainFwdBufferInfo();if(null===s)return;let o=this.getLevelDetails();if(o&&this._streamEnded(s,o)){let e={type:this.targetBufferType()};return this.hls.trigger(Ai.BUFFER_EOS,e),void(this.state=Lo)}if(!this.buffering)return;e.loadLevel!==a&&-1===e.manualLevel&&this.log(`Adapting to level ${a} from level ${this.level}`),this.level=e.nextLoadLevel=a;let l=n.details;if(!l||this.state===Co||this.waitForLive(n))return this.level=a,this.state=Co,void(this.startFragRequested=!1);let d=s.len,u=this.getMaxBufferLength(n.maxBitrate);if(d>=u)return;this.backtrackFragment&&this.backtrackFragment.start>s.end&&(this.backtrackFragment=void 0);let h=this.backtrackFragment?this.backtrackFragment.start:s.end,c=this.getNextFragment(h,l);if(this.couldBacktrack&&!this.fragPrevious&&c&&Pi(c)&&this.fragmentTracker.getState(c)!==On){var m;let e=(null!=(m=this.backtrackFragment)?m:c).sn-l.startSN,t=l.fragments[e-1];t&&c.cc===t.cc&&(c=t,this.fragmentTracker.removeFragment(t))}else this.backtrackFragment&&s.len&&(this.backtrackFragment=void 0);if(c&&this.isLoopLoading(c,h)){if(!c.gap){let e=this.audioOnly&&!this.altAudio?wi:Di,t=(e===Di?this.videoBuffer:this.mediaBuffer)||this.media;t&&this.afterBufferFlushed(t,e)}c=this.getNextFragmentLoopLoading(c,l,s,Li.MAIN,u)}c&&(this.exceedsMaxBuffer(s,u,c)||this.loadFragment(c,n,h))}loadFragment(e,t,i){let r=this.fragmentTracker.getState(e);r===Mn||r===xn?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.clearTrackerIfNeeded(e)}immediateLevelSwitch(){var e;(this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY),this.altAudio!==Jh)&&(((null==(e=this.getLevelDetails())?void 0:e.fragmentStart)||0)>this.lastCurrentTime&&super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"))}getBufferOutput(){return this.mediaBuffer&&this.altAudio===tc?this.mediaBuffer:this.media}checkFragmentChanged(){let e=this.fragPlaying;if(!this.checkFragPlaying())return!1;let t=this.fragPlaying;if(t){let i=t.level;this.hls.trigger(Ai.FRAG_CHANGED,{frag:t,previousFrag:e}),(null==e?void 0:e.level)!==i&&this.hls.trigger(Ai.LEVEL_SWITCHED,{level:i})}return!0}get backtrackFragment(){return this._backtrackFragment}set backtrackFragment(e){this._backtrackFragment=e}get couldBacktrack(){return this._couldBacktrack}set couldBacktrack(e){this._couldBacktrack=e}abortCurrentFrag(){this.backtrackFragment=void 0,super.abortCurrentFrag()}flushMainBuffer(e,t){super.flushMainBuffer(e,t,this.targetBufferType())}targetBufferType(){return this.altAudio!==tc||this.audioOnly?null:"video"}onMediaAttached(e,t){super.onMediaAttached(e,t);let i=t.media;vo(i,"playing",this.onMediaPlaying),vo(i,"seeked",this.onMediaSeeked)}onMediaDetaching(e,t){let{media:i}=this;i&&(Eo(i,"playing",this.onMediaPlaying),Eo(i,"seeked",this.onMediaSeeked)),this.videoBuffer=null,super.onMediaDetaching(e,t),!t.transferMedia&&(this._hasEnoughToStart=!1)}onManifestLoading(){super.onManifestLoading(),this.log("Trigger BUFFER_RESET"),this.hls.trigger(Ai.BUFFER_RESET,void 0),this.couldBacktrack=!1,this.backtrackFragment=void 0,this.altAudio=Jh,this.audioOnly=!1}onManifestParsed(e,t){let i=!1,r=!1;for(let e=0;e<t.levels.length;e++){let a=t.levels[e].audioCodec;a&&(i=i||-1!==a.indexOf("mp4a.40.2"),r=r||-1!==a.indexOf("mp4a.40.5"))}this.audioCodecSwitch=i&&r&&!function(){var e;let t=zh();return"function"==typeof(null==t||null==(e=t.prototype)?void 0:e.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!==To)return;let r=t.levelInfo;(!r.details||r.details.live&&(this.levelLastLoaded!==r||r.details.expired)||this.waitForCdnTuneIn(r.details))&&(this.state=Co)}onLevelLoaded(e,t){var i;let{levels:r,startFragRequested:a}=this,n=t.level,s=t.details,o=s.totalduration;if(!r)return void this.warn(`Levels were reset while loading level ${n}`);this.log(`Level ${n} loaded [${s.startSN},${s.endSN}]${s.lastPartSn?`[part-${s.lastPartSn}-${s.lastPartIndex}]`:""}, cc [${s.startCC}, ${s.endCC}] duration:${o}`);let l=t.levelInfo,d=this.fragCurrent;d&&(this.state===_o||this.state===So)&&d.level!==t.level&&d.loader&&this.abortCurrentFrag();let u=0;if(s.live||null!=(i=l.details)&&i.live){var h;if(this.checkLiveUpdate(s),s.deltaUpdateFailed)return;u=this.alignPlaylists(s,l.details,null==(h=this.levelLastLoaded)?void 0:h.details)}if(l.details=s,this.levelLastLoaded=l,a||this.setStartPosition(s,u),this.hls.trigger(Ai.LEVEL_UPDATED,{details:s,level:n}),this.state===Co){if(this.waitForCdnTuneIn(s))return;this.state=To}a&&s.live&&this.synchronizeToLiveEdge(s),this.initPTS.some((e,t)=>{if(t>=s.startCC)return!0;delete this.initPTS[t]}),this.tick()}synchronizeToLiveEdge(e){let{config:t,media:i}=this;if(!i)return;let r=this.hls.liveSyncPosition,a=this.playhead,n=e.fragmentStart,s=e.edge,o=a>=n-t.maxFragLookUpTolerance&&a<=s;if(null!==r&&i.duration>r&&(a<r||!o)){let n=void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;if((!o&&i.readyState<4||a<s-n)&&(this._hasEnoughToStart||(this.nextLoadPosition=r),i.readyState))if(this.warn(`Playback: ${a} is located too far from the end of live sliding playlist: ${s}, reset currentTime to : ${r}`),"buffered"===this.config.liveSyncMode){var l;let e=ts.bufferInfo(i,r,0);if(null==(l=e.buffered)||!l.length)return void(i.currentTime=r);if(e.start<=a)return void(i.currentTime=r);let{nextStart:t}=ts.bufferedInfo(e.buffered,a,0);t&&(i.currentTime=t)}else i.currentTime=r}}_handleFragmentLoadProgress(e){var t;let i=e.frag,{part:r,payload:a}=e,{levels:n}=this;if(!n)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 s=n[i.level];if(!s)return void this.warn(`Level ${i.level} not found on progress`);let o=s.details;if(!o)return this.warn(`Dropping fragment ${i.sn} of level ${i.level} after level details were reset`),void this.fragmentTracker.removeFragment(i);let l=s.videoCodec,d=o.PTSKnown||!o.live,u=null==(t=i.initSegment)?void 0:t.data,h=this._getAudioCodec(s),c=this.transmuxer=this.transmuxer||new ad(this.hls,Li.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),m=r?r.index:-1,f=-1!==m,{decryptRange:p,byteRange:g}=zn(i,r,this.iframesOnly),v=new Jn(i.level,i.sn,i.stats.chunkCount,g?g.end-g.start:a.byteLength,m,f,i.duration,this.iframesOnly,p),E=this.initPTS[i.cc];c.push(a,u,h,l,i,r,o.totalduration,d,v,E)}onAudioTrackSwitching(e,t){let i=this.hls,r=this.altAudio!==Jh;if(un(t.url,i))this.altAudio=ec;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)return this.altAudio=Jh,this.fragmentTracker.removeAllFragments(),i.once(Ai.BUFFER_FLUSHED,()=>{this.hls&&this.hls.trigger(Ai.AUDIO_TRACK_SWITCHED,t)}),void i.trigger(Ai.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null});i.trigger(Ai.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){let i=un(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=i?tc:Jh,this.tick()}onBufferCreated(e,t){let i,r,a=t.tracks,n=!1;for(let e in a){let t=a[e];if("main"===t.id){if(r=e,i=t,"video"===e){let t=a[e];t&&(this.videoBuffer=t.buffer)}}else n=!0}n&&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,a=i.type===Li.MAIN;if(a){if(this.fragContextChanged(i))return this.warn(`Fragment ${i.sn}${r?" p: "+r.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}`),void(this.state===Ro&&(this.state=To));let e=!1;if(Pi(i)&&(e=!!i.gap&&!i.tagList.some(e=>"GAP"===e[0])),this.fragBufferedComplete(i,r),e){var n;i.stats.retry++;let e=null==(n=this.levels)?void 0:n[i.level];e&&e.fragmentError++}}let s=this.media;s&&(!this._hasEnoughToStart&&ts.getBuffered(s).length&&(this._hasEnoughToStart=!0,this.seekToStartPos()),a&&this.tick())}get hasEnoughToStart(){return this._hasEnoughToStart}onError(e,t){var i;if(t.fatal)this.state=wo;else switch(t.details){case Ti.FRAG_GAP:case Ti.FRAG_PARSING_ERROR:case Ti.FRAG_DECRYPT_ERROR:case Ti.FRAG_LOAD_ERROR:case Ti.FRAG_LOAD_TIMEOUT:case Ti.KEY_LOAD_ERROR:case Ti.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Li.MAIN,t);break;case Ti.LEVEL_LOAD_ERROR:case Ti.LEVEL_LOAD_TIMEOUT:case Ti.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===Co&&(null==(i=t.context)?void 0:i.type)===Ri.LEVEL&&(this.state=To);break;case Ti.BUFFER_APPEND_NO_PROGRESS:if("main"!==t.parent)return;t.frag&&(t.appendsWithoutProgress||0)>=this.config.appendErrorMaxRetry&&(this.warn(`Marking fragment ${t.frag.sn} of level ${t.frag.level} as a gap after ${t.appendsWithoutProgress} appends without buffered range growth, to prevent loop loading`),this.fragmentTracker.addAsGap(t.frag));break;case Ti.BUFFER_ADD_CODEC_ERROR:case Ti.BUFFER_APPEND_ERROR:if("main"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)&&this.resetLoadingState();break;case Ti.BUFFER_FULL_ERROR:if("main"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)&&(!this.config.interstitialsController&&this.config.assetPlayerId?this._hasEnoughToStart=!0:this.flushMainBuffer(0,Number.POSITIVE_INFINITY));break;case Ti.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}onFragLoadEmergencyAborted(){this.state=To,this._hasEnoughToStart||(this.startFragRequested=!1,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==wi||!this.altAudio){let e=(t===Di?this.videoBuffer:this.mediaBuffer)||this.media;e&&(this.afterBufferFlushed(e,t),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 a=this.getLevelDetails(),n=ts.getBuffered(e),s=n.length?n.start(0):0,o=s-i,l=Math.max(this.config.maxBufferHole,this.config.maxFragLookUpTolerance);(this.config.startOnSegmentBoundary||o>0&&(o<l||this.loadingParts&&o<2*((null==a?void 0:a.partTarget)||0)))&&(this.log(`adjusting start position by ${o} to match buffer start`),i+=o,this.startPosition=i),t<i&&(this.log(`seek to target start position ${i} from current time ${t} buffer start ${s}`),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=To,this.startFragRequested=!1,this.bitrateTest=!1;let a=r.stats;a.parsing.start=a.parsing.end=a.buffering.start=a.buffering.end=self.performance.now(),i.trigger(Ai.FRAG_LOADED,e),r.bitrateTest=!1}).catch(t=>{this.state===bo||this.state===wo||(this.warn(t),this.resetFragmentLoading(e))})}_handleTransmuxComplete(e){let t=this.playlistType,{hls:i}=this,{remuxResult:r,chunkMeta:a}=e,n=this.getCurrentContext(a);if(!n)return void this.resetWhenMissingContext(a);let{frag:s,part:o,level:l}=n,{video:d,text:u,id3:h,initSegment:c}=r,{details:m}=l,f=this.altAudio?void 0:r.audio;if(this.fragContextChanged(s))this.fragmentTracker.removeFragment(s);else{if(this.state=Io,c){let e=c.tracks;if(e){let r=s.initSegment||s;if(this.unhandledEncryptionError(c,s))return;this._bufferInitSegment(l,e,r,a),i.trigger(Ai.FRAG_PARSING_INIT_SEGMENT,{frag:r,id:t,tracks:e})}let r=c.initPTS,n=c.timescale,o=this.initPTS[s.cc];if(vi(r)&&(!o||o.baseTime!==r||o.timescale!==n)){let e=c.trackId;this.initPTS[s.cc]={baseTime:r,timescale:n,trackId:e};let a=this.initPTS.slice(0);i.trigger(Ai.INIT_PTS_FOUND,{timestampOffsets:a,frag:s,id:t,initPTS:r,timescale:n,trackId:e})}}if(d&&m){f&&"audiovideo"===d.type&&this.logMuxedErr(s);let e=m.fragments[s.sn-1-m.startSN],t=s.sn===m.startSN,i=!e||s.cc>e.cc;if(!1!==r.independent){let{startPTS:e,endPTS:r,startDTS:n,endDTS:l}=d;if(o)o.elementaryStreams[d.type]={startPTS:e,endPTS:r,startDTS:n,endDTS:l};else if(d.firstKeyFrame&&d.independent&&1===a.id&&!i&&(this.couldBacktrack=!0),d.dropped&&d.independent){let a=this.getMainFwdBufferInfo(),n=(a?a.end:this.getLoadPosition())+this.config.maxBufferHole,o=d.firstKeyFramePTS?d.firstKeyFramePTS:e;if(!t&&n<o-this.config.maxBufferHole&&!i)return void this.backtrack(s);i&&(s.gap=!0),s.setElementaryStreamInfo(d.type,s.start,r,s.start,l,!0)}else t&&e-(m.appliedTimelineOffset||0)>2&&(s.gap=!0);s.setElementaryStreamInfo(d.type,e,r,n,l),this.backtrackFragment&&(this.backtrackFragment=s),this.bufferFragmentData(d,s,o,a,t||i)}else{if(!t&&!i)return void this.backtrack(s);s.gap=!0}}if(f){let{startPTS:e,endPTS:t,startDTS:i,endDTS:r}=f;o&&(o.elementaryStreams[wi]={startPTS:e,endPTS:t,startDTS:i,endDTS:r}),s.setElementaryStreamInfo(wi,e,t,i,r),this.bufferFragmentData(f,s,o,a)}if(m&&null!=h&&h.samples.length){let e={id:t,frag:s,details:m,samples:h.samples};i.trigger(Ai.FRAG_PARSING_METADATA,e)}if(m&&u){let e={id:t,frag:s,details:m,samples:u.samples};i.trigger(Ai.FRAG_PARSING_USERDATA,e)}}}logMuxedErr(e){this.warn(`${Pi(e)?"Media":"Init"} segment with muxed audiovideo where only video expected: ${e.url}`)}_bufferInitSegment(e,t,i,r){if(this.state!==Io)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&(delete t.audio,t.audiovideo&&this.logMuxedErr(i));let{audio:a,video:n,audiovideo:s}=t;if(a){let i=e.audioCodec,r=Ma(a.codec,i);if("mp4a"===r&&(r="mp4a.40.5"),this.audioCodecSwitch){r&&(r=-1!==r.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5");let e=a.metadata;e&&"channelCount"in e&&1!==(e.channelCount||1)&&!function(){if(void 0===pa){let e=va.match(/Firefox\/(\d+)/i);pa=e?parseInt(e[1]):0}return pa}()&&(r="mp4a.40.5")}r&&-1!==r.indexOf("mp4a.40.5")&&/Android/.test(va)&&"audio/mpeg"!==a.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}"`),a.levelCodec=r,a.id=Li.MAIN,this.log(`Init audio buffer, container:${a.container}, codecs[selected/level/parsed]=[${r||""}/${i||""}/${a.codec}]`),delete t.audiovideo}if(n){n.levelCodec=e.videoCodec,n.id=Li.MAIN;let i=n.codec;if(4===(null==i?void 0:i.length))switch(i){case"hvc1":case"hev1":n.codec="hvc1.1.6.L120.90";break;case"av01":n.codec="av01.0.04M.08";break;case"avc1":n.codec="avc1.42e01e"}this.log(`Init video buffer, container:${n.container}, codecs[level/parsed]=[${e.videoCodec||""}/${i}]${n.codec!==i?" parsed-corrected="+n.codec:""}${n.supplemental?" supplemental="+n.supplemental:""}`),delete t.audiovideo}s&&(this.iframesOnly&&this.logMuxedErr(i),this.log(`Init audiovideo buffer, container:${s.container}, codecs[level/parsed]=[${e.codecs}/${s.codec}]`),delete t.video,delete t.audio);let o=Object.keys(t);if(o.length){if(this.hls.trigger(Ai.BUFFER_CODECS,t),!this.hls)return;o.forEach(e=>{let a=t[e].initSegment;null!=a&&a.byteLength&&this.hls.trigger(Ai.BUFFER_APPENDING,{type:e,data:a,frag:i,part:null,chunkMeta:r,parent:i.type})})}this.tickImmediate()}getMainFwdBufferInfo(){let e=this.getBufferOutput();return this.getFwdBufferInfo(e,Li.MAIN)}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=To}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 vi(t)?this.getAppendedFrag(t):null}get currentProgramDateTime(){var e;let t=(null==(e=this.media)?void 0:e.currentTime)||this.lastCurrentTime;if(vi(t)){let e=this.getLevelDetails(),i=this.currentFrag||(e?fn(null,e.fragments,t):null);if(i){let e=i.programDateTime;if(null!==e){let r=e+1e3*(t-i.start);return new Date(r)}}}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}},rc=class extends ic{constructor(...e){super(...e),this.currentOp=void 0,this.nextOp=void 0,this.cached=[],this.cachedSize=0,this.cacheFragmentData=!0,this.initDetails=void 0,this.onBufferedToEnd=()=>{let e=this.media;null!=e&&e.seeking&&(e.currentTime=e.currentTime)},this.onMediaSeeking=()=>{}}setInitPts(e){this.initPTS=e.slice()}loadMediaAt(e,t){if(!this.hls)return;let{seekOnAppend:i}=t,r=e+this.timelineOffset;switch(this.nextLoadPosition=this.lastCurrentTime=r,this.startPosition=e,this.state){case bo:case Lo:case wo:this.state=To}this.state===To?(this.hls.resumeBuffering(),this.tick(),this.currentOp=[r,t]):this.nextOp=[r,t],this.hls.off(Ai.BUFFERED_TO_END,this.onBufferedToEnd);let a=this.media;i&&a&&this.seekTo(r)&&(this.currentOp=[r,t],this.nextOp=void 0,this.flushPipeline(r,!0))}seekTo(e){let t=this.media;if(t){var i;let r=null==(i=this.getLevelDetails())?void 0:i.edge,a=void 0!==r?r:t.duration;if(e>=a&&(e=a-.01),ts.bufferInfo(t,e,0).len>0&&this.getBufferedAt(e))return t.currentTime=e,!0}return!1}getBufferedAt(e){return this.fragmentTracker.getBufferedFrag(e,Li.MAIN)}cacheSet(e,t){if(!this.hls)return;e.data=t;let i=this.cached;i.push(e),this.cachedSize+=t.buffer.byteLength;let r=this.hls.config.iframeCacheLimit;for(;this.cachedSize>r&&i.length>1;){let e=i.shift();if(!e.data){this.cached=i.filter(e=>!!e.data),this.cachedSize=i.reduce((e,{data:t})=>t?t.buffer.byteLength:0,0);break}this.cachedSize-=e.data.byteLength,e.data=void 0}}onHandlerDestroying(){this.cached.length=0,this.cachedSize=0,super.onHandlerDestroying()}_handleFragmentLoadProgress(e){let t=e.frag,{part:i,payload:r}=e;this.cacheFragmentData&&!i&&null!=r&&r.byteLength&&!t.data&&Pi(t)&&this.cacheSet(t,new Uint8Array(r.slice(0))),super._handleFragmentLoadProgress(e)}loadFragment(e,t,i){let r=this.fragmentTracker.getState(e);r!==Mn&&r!==xn||!this.canReplayCached(e)?super.loadFragment(e,t,i):this.replayCachedFragment(e)}canReplayCached(e){var t;if(!this.cacheFragmentData||null==(t=e.data)||!t.byteLength)return!1;let i=e.decryptdata;return"identity"!==(null==i?void 0:i.keyFormat)||!!i.key}replayCachedFragment(e){let t=e.data.slice().buffer;this.log(`Buffering cached ${e.type} sn: ${e.sn} of level ${e.level} (${t.byteLength} bytes)`),this.fragCurrent=e,this.startFragRequested=!0;let i=e.stats=new Ii;i.loading.start=i.loading.first=i.loading.end=self.performance.now(),i.loaded=i.total=t.byteLength,i.chunkCount=1,this.state=_o;let r={frag:e,part:null,payload:t,networkDetails:null};this._handleFragmentLoadProgress(r),this.hls.trigger(Ai.FRAG_LOADED,r),this._handleFragmentLoadComplete(r)}fragBufferedComplete(e,t){super.fragBufferedComplete(e,t);let{currentOp:i,nextOp:r}=this;this.currentOp=this.nextOp=void 0,this.state=bo,null!=i&&i[1].seekOnAppend&&(this.flushPipeline(i[0],!r),this.seekTo(i[0])||this.log(`Could not seek to ${i[0]} after fragment buffered (superseded or flushed) buffer: ${this.media?yo(ts.getBuffered(this.media)):"none"}`)),r&&this.loadMediaAt.apply(this,r)}flushPipeline(e,t){if(t){let t=this.media;if(t){let i=ts.bufferInfo(t,e,0),r=i.len?i.nextStart:0;r&&(this.fragmentTracker.removeFragmentsInRange(r,1/0,Li.MAIN),this.flushMainBuffer(r,1/0))}this.hls.once(Ai.BUFFERED_TO_END,this.onBufferedToEnd)}this.hls.trigger(Ai.BUFFER_EOS,{type:"video"})}get playhead(){return this.nextLoadPosition}startLoad(){if(!this.startFragRequested){let e=this.hls;e.nextLoadLevel=-1===e.startLevel?0:e.firstAutoLevel}}seekToStartPos(){}setStartPosition(){}alignPlaylists(e,t,i){let r=this.initDetails;return this.initDetails=null,super.alignPlaylists(e,t,i||r||void 0)}getMainFwdBufferInfo(){let e=this.playhead,t=this.getBufferedAt(e);if(t){let i=t.duration;return{len:i,start:e,end:e+i,bufferedIndex:-1}}return{len:0,start:e,end:e,bufferedIndex:-1}}_streamEnded(){let e=this.playhead,t=this.fragmentTracker.getBufferedFrag(e,Li.MAIN);return!(null==t||!t.endList)}},ac=class extends rc{constructor(...e){super(...e),this._img=void 0,this.queued=void 0,this.cacheFragmentData=!1}get image(){return this._img}set image(e){var t;let i=null==(t=this._img)?void 0:t.src;i&&self.URL.revokeObjectURL(i),this._img=e}loadMediaAt(e){if(!this.hls)return;let t=e+this.timelineOffset;switch(this.nextLoadPosition=this.lastCurrentTime=t,this.startPosition=e,this.state){case bo:case Lo:case wo:this.state=To}if(this.state===To){if(this.hls.resumeBuffering(),this.media||(this.media={}),this.tick(),this.state===To){let t=this.getBufferedAt(e);t&&(this.fragCurrent=t,this.updateImage(t,null))}}else{let i=this.fragCurrent;(!i||e>=i.start&&e<i.end)&&(this.queued=[t])}}updateImage(e,t,i){let r=e.data;r||this.fragmentTracker.removeFragment(e);let a=this._img;if(a&&r){let n=self.performance.now();(t?t.stats:e.stats).buffering.start=e.stats.buffering.start=n,a.onload=()=>{if(!this.hls)return;let r=this.hls.levels[e.level];null!=r&&r.fragmentError&&(r.fragmentError=0,e.stats.retry=0);let a=self.performance.now(),n=t?t.stats:e.stats;n.buffering.end=e.stats.buffering.end=a,this.hls.trigger(Ai.FRAG_BUFFERED,{frag:e,part:t,stats:n,id:e.type,chunkMeta:i})},a.onerror=()=>{this.handleError("Image decode error",e,t,i)};let s=a.src;s&&self.URL.revokeObjectURL(s);let o=new Blob([r],{type:"image/jpeg"});a.src=self.URL.createObjectURL(o)}else this.state=bo,this.processQueued()}processQueued(){let e=this.queued;this.queued=void 0,e&&this.loadMediaAt.apply(this,e)}handleError(e,t,i,r){if(!this.hls)return;let a=new Error(e);this.hls.trigger(Ai.ERROR,{type:bi.MEDIA_ERROR,details:Ti.FRAG_PARSING_ERROR,chunkMeta:r,frag:t,part:i,fatal:!1,error:a,err:a})}_bufferInitSegment(){}bufferFragmentData(e,t,i,r){super.bufferFragmentData(e,t,i,r,!0);let a=Yr(new Uint8Array(e.data1),["mdat"]);if(0===a.length)return void this.handleError("Could not find I-Frame mdat",t,i,r);let n=t;this.cacheSet(n,a[0]),this.updateImage(n,i,r)}fragBufferedComplete(e,t){this.fragmentTracker.fragBuffered(e,!0),super.fragBufferedComplete(e,t),this.processQueued()}checkFragPlaying(){var e;let t=null==(e=this.fragPrevious)?void 0:e.start;if(void 0!==t){let e=this.getAppendedFrag(t);if(e&&!xi(e,this.fragPlaying))return this.fragPlaying=e,!0}return!1}getMainFwdBufferInfo(){return{len:0,start:this.playhead,end:this.playhead,bufferedIndex:-1}}},nc="Image I-Frame player does not accept HTMLMediaElements",sc={seekOnAppend:!0};var oc=.025,lc=function(e){return e[e.Point=0]="Point",e[e.Range=1]="Range",e}({});function dc(e,t,i){return`${e.identifier}-${i+1}-${Ah(t)}`}var uc=class{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 cc(t,e)?hc(e,t):e}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;return t-hc(t,e)<.1}return!1}get resumptionOffset(){let e=this.resumeOffset,t=vi(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 cc(t,e)?hc(e,t):e}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&&Math.abs(this.resumeOffset-this.duration)<oc))}set appendInPlace(e){this.appendInPlaceStarted?this.resetOnResume=!e: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"]?lc.Range:lc.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(){return function(e){return`["${e.identifier}" ${e.cue.pre?"<pre>":e.cue.post?"<post>":""}${e.timelineStart.toFixed(2)}-${e.resumeTime.toFixed(2)}]`}(this)}};function hc(e,t){return e-t.start<t.duration/2&&!(Math.abs(e-(t.start+t.duration))<oc)?t.start:t.start+t.duration}function cc(e,t){return t>e.start-oc&&t<e.start+e.duration+oc}function mc(e,t,i){let r=new self.URL(e,i);return"data:"!==r.protocol&&Wa(r,"_HLS_primary_id",t),r}function fc(e,t){for(;null!=(i=e.assetList[++t])&&i.error;)var i;return t}function pc(e){let t=e.timelineStart,i=e.duration||0;return`["${e.identifier}" ${t.toFixed(2)}-${(t+i).toFixed(2)}]`}var gc=class{constructor(e,t,i,r){this.hls=void 0,this.interstitial=void 0,this.assetItem=void 0,this.tracks=null,this.hasDetails=!1,this.mediaAttached=null,this._currentTime=void 0,this._bufferedEosTime=void 0,this.checkPlayout=()=>{this.reachedPlayout(this.currentTime)&&this.hls&&this.hls.trigger(Ai.PLAYOUT_LIMIT_REACHED,{})};let a=this.hls=new e(t);this.interstitial=i,this.assetItem=r;let n=()=>{this.hasDetails=!0};a.once(Ai.LEVEL_LOADED,n),a.once(Ai.AUDIO_TRACK_LOADED,n),a.once(Ai.SUBTITLE_TRACK_LOADED,n),a.on(Ai.MEDIA_ATTACHING,(e,{media:t})=>{this.removeMediaListeners(),this.mediaAttached=t,this.interstitial.playoutLimit&&(t.addEventListener("timeupdate",this.checkPlayout),this.appendInPlace&&a.on(Ai.BUFFER_APPENDED,()=>{let e=this.bufferedEnd;this.reachedPlayout(e)&&(this._bufferedEosTime=e,a.trigger(Ai.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=mc(t,e.config.primarySessionId||"").href}catch{}e.loadSource(t)}}bufferedInPlaceToEnd(e,t){var i;if(!this.appendInPlace)return!1;if(null!=(i=this.hls)&&i.bufferedToEnd)return!0;if(!e)return!1;let r=Math.min(this._bufferedEosTime||1/0,this.duration),a=this.timelineOffset+(t||0),n=ts.bufferInfo(e,a,.02);return this.getAssetTime(n.end)>=r-.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=ts.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){let i=e-t;if(Math.abs(i)>1/9e4&&this.hls){if(this.hasDetails)throw new Error("Cannot set timelineOffset after playlists are loaded");this.hls.config.timelineOffset=e}}}getAssetTime(e){let t=this.timelineOffset,i=this.duration;return Math.min(Math.max(0,e-t),i)}removeMediaListeners(){let e=this.mediaAttached;e&&(this._currentTime=e.currentTime,this.bufferSnapShot(),e.removeEventListener("timeupdate",this.checkPlayout))}bufferSnapShot(){var e;this.mediaAttached&&(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: ${pc(this.assetItem)} ${null==(e=this.hls)?void 0:e.sessionId} ${this.appendInPlace?"append-in-place":""}`}},vc=.033,Ec=class extends tr{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={},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!=(a=r[i])&&a.event;){var a;i--}return i}findItemIndexAtTime(e,t){let i=this.items;if(i)for(let r=0;r<i.length;r++){let a=i[r];t&&"primary"!==t&&(a=a[t]);let n=a.start,s=i[r].event,o=null!=s&&s.cue.pre?s.duration:a.end;if(e===n||e>n&&e<o)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 a=i[e];if(!a.error){let i=a.timelineStart;if(t===i||t>i&&(t<i+(a.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,i=0){let r=e.main.details,{dateRanges:a}=r,n=this.events,s=this.parseDateRanges(a,{url:r.url},t),o=Object.keys(a),l=n?n.filter(e=>-1===o.indexOf(e.identifier)):[];s.length&&s.sort((e,t)=>{let i=e.cue.pre,r=e.cue.post,a=t.cue.pre,n=t.cue.post;if(i&&!a)return-1;if(a&&!i||r&&!n)return 1;if(n&&!r)return-1;if(!(i||a||r||n)){let i=e.startTime,r=t.startTime;if(i!==r)return i-r}return e.dateRange.tagOrder-t.dateRange.tagOrder}),this.events=s,l.forEach(e=>{this.removeEvent(e)}),this.updateSchedule(e,l,i)}updateSchedule(e,t=[],i=0,r=!1){let a=this.events||[];if(a.length||t.length||this.length<2){let n=this.items,s=this.parseSchedule(a,e,i);(r||t.length||(null==n?void 0:n.length)!==s.length||s.some((e,t)=>Math.abs(e.playout.start-n[t].playout.start)>.005||Math.abs(e.playout.end-n[t].playout.end)>.005))&&(this.items=s,this.onScheduleUpdate(t,n))}}parseDateRanges(e,t,i){let r=[],a=Object.keys(e);for(let n=0;n<a.length;n++){let s=a[n],o=e[s];if(o.isInterstitial){let e=this.eventMap[s];e?e.setDateRange(o):(e=new uc(o,t),this.eventMap[s]=e,!1===i&&(e.appendInPlace=i)),r.push(e)}}return r}parseSchedule(e,t,i=0){let r=[],a=t.main.details,n=a.live?1/0:a.edge,s=0;if((e=e.filter(e=>!(e.error||e.cue.once&&e.hasPlayed))).length){this.resolveOffsets(e,t);let l=0,d=0;if(e.forEach((t,o)=>{let u=t.cue.pre,h=t.cue.post,c=e[o-1]||null,m=t.appendInPlace,f=h?n:t.startOffset,p=t.duration,g=t.timelineOccupancy===lc.Range?p:0,v=u&&a.live?i+(t.resumeOffset||0):0,E=v||t.resumptionOffset,y=(null==c?void 0:c.startTime)===f,b=f+t.cumulativeDuration,T=m?b+p:f+E;if(u||!h&&f<=0){let e=d;d+=g,t.timelineStart=b;let i=s;s+=p,r.push({event:t,start:b,end:T,playout:{start:i,end:s},integrated:{start:e,end:d}})}else{if(!(f<=n))return;{if(!y){let i=f-l;if(i>vc){let a=l,n=d;d+=i;let u=s;s+=i;let h={previousEvent:e[o-1]||null,nextEvent:t,start:a,end:a+i,playout:{start:u,end:s},integrated:{start:n,end:d}};r.push(h)}else i>0&&c&&(c.cumulativeDuration+=i,r[r.length-1].end=f)}h&&(T=b),t.timelineStart=b;let i=d;d+=g;let a=s;s+=p,r.push({event:t,start:b,end:T,playout:{start:a,end:s},integrated:{start:i,end:d}})}}let A=v||t.resumeTime;l=h||A>n?n:!u&&T&&t.appendInPlaceStarted&&A-T>vc?T:A}),l<n){var o;let e=l,t=d,i=n-l;d+=i;let a=s;s+=i,r.push({previousEvent:(null==(o=r[r.length-1])?void 0:o.event)||null,nextEvent:null,start:l,end:e+i,playout:{start:a,end:s},integrated:{start:t,end:d}})}this.setDurations(n,s,d)}else r.push({previousEvent:null,nextEvent:null,start:0,end:n,playout:{start:0,end:n},integrated:{start:0,end:n}}),this.setDurations(n,n,n);return r}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,a=0,n=-1;e.forEach((s,o)=>{let l=s.cue.pre,d=s.cue.post,u=l?0:d?r:s.startTime;this.updateAssetDurations(s),n===u?s.cumulativeDuration=a:(a=0,n=u),!d&&s.snapOptions.in&&(s.resumeAnchor=fn(null,i.fragments,s.startOffset+s.resumptionOffset,0,0)||void 0),s.appendInPlace&&!s.appendInPlaceStarted&&(this.primaryCanResumeInPlaceAt(s,t)||(s.appendInPlace=!1)),!s.appendInPlace&&o+1<e.length&&e[o+1].startTime-e[o].resumeTime<vc&&(e[o+1].appendInPlace=!1,e[o+1].appendInPlace&&this.warn(`Could not change append strategy for abutting event ${s}`));let h=vi(s.resumeOffset)?s.resumeOffset:s.duration;a+=h})}primaryCanResumeInPlaceAt(e,t){let i=e.resumeTime,r=e.startTime+e.resumptionOffset;return Math.abs(i-r)>oc?(this.log(`"${e.identifier}" resumption ${i} not aligned with estimated timeline end ${r}`),!1):!Object.keys(t).some(r=>{let a=t[r].details,n=a.edge;if(i>=n)return this.log(`"${e.identifier}" resumption ${i} past ${r} playlist end ${n}`),!1;let s=fn(null,a.fragments,i);if(!s)return this.log(`"${e.identifier}" resumption ${i} does not align with any fragments in ${r} playlist (${a.fragStart}-${a.fragmentEnd})`),!0;let o="audio"===r?.175:0;return!(Math.abs(s.start-i)<oc+o||Math.abs(s.end-i)<oc+o)&&(this.log(`"${e.identifier}" resumption ${i} not aligned with ${r} fragment bounds (${s.start}-${s.end} sn: ${s.sn} cc: ${s.cc})`),!0)})}updateAssetDurations(e){if(!e.assetListLoaded)return;let t=e.timelineStart,i=0,r=!1,a=!1;for(let n=0;n<e.assetList.length;n++){let s=e.assetList[n],o=t+i;s.startOffset=i,s.timelineStart=o,r||(r=null===s.duration),a||(a=!!s.error),i+=s.error?0:s.duration||0}e.duration=r&&!a?Math.max(i,e.duration):i}removeEvent(e){e.reset(),delete this.eventMap[e.identifier]}};function yc(e){return`[${e.event?'"'+e.event.identifier+'"':"primary"}: ${e.start.toFixed(2)}-${e.end.toFixed(2)}]`}var bc=class{constructor(e){this.hls=void 0,this.hls=e}destroy(){this.hls=null}loadAssetList(e,t){let i,r=e.assetListUrl;try{i=mc(r,this.hls.sessionId,e.baseUrl)}catch(t){let i=this.assignAssetListError(e,Ti.ASSET_LIST_LOAD_ERROR,t,r);return void this.hls.trigger(Ai.ERROR,i)}t&&"data:"!==i.protocol&&Wa(i,"_HLS_start_offset",""+t);let a=this.hls.config,n=new(0,a.loader)(a),s={type:Ri.INTERSTITIAL_ASSET_LIST,responseType:"json",url:i.href},o=a.interstitialAssetListLoadPolicy.default,l={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},d={onSuccess:(t,i,r,a)=>{let n=t.data,s=null==n?void 0:n.ASSETS;if(!Array.isArray(s)){let t=this.assignAssetListError(e,Ti.ASSET_LIST_PARSING_ERROR,new Error("Invalid interstitial asset list"),r.url,i,a);return void this.hls.trigger(Ai.ERROR,t)}e.assetListResponse=n,this.hls.trigger(Ai.ASSET_LIST_LOADED,{event:e,assetListResponse:n,networkDetails:a})},onError:(t,i,r,a)=>{let n=this.assignAssetListError(e,Ti.ASSET_LIST_LOAD_ERROR,new Error(`Error loading X-ASSET-LIST: HTTP status ${t.code} ${t.text} (${i.url})`),i.url,a,r);this.hls.trigger(Ai.ERROR,n)},onTimeout:(t,i,r)=>{let a=this.assignAssetListError(e,Ti.ASSET_LIST_LOAD_TIMEOUT,new Error(`Timeout loading X-ASSET-LIST (${i.url})`),i.url,t,r);this.hls.trigger(Ai.ERROR,a)}};return n.load(s,l,d),this.hls.trigger(Ai.ASSET_LIST_LOADING,{event:e}),n}assignAssetListError(e,t,i,r,a,n){return e.error=i,{type:bi.NETWORK_ERROR,details:t,fatal:!1,interstitial:e,url:r,error:i,networkDetails:n,stats:a}}};function Tc(e){var t;null==e||null==(t=e.play())||t.catch(()=>{})}function Ac(e,t){return`[${e}] Advancing timeline position to ${t}`}var _c=class{constructor(e){this.buffered=void 0;let 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)}}},Sc={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},kc=e=>String.fromCharCode(Sc[e]||e),Ic=15,Rc=42,Lc={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},wc={17:2,18:4,21:6,22:8,23:10,19:13,20:15},Dc={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},Cc={25:2,26:4,29:6,30:8,31:10,27:13,28:15},Mc=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],Pc=class{constructor(){this.time=null,this.verboseLevel=0}log(e,t){if(this.verboseLevel>=e){let i="function"==typeof t?t():t;or.log(`${this.time} [${e}] ${i}`)}}},xc=function(e){let t=[];for(let i=0;i<e.length;i++)t.push(e[i].toString(16));return t},Oc=Object.freeze({foreground:"white",underline:!1,italics:!1,background:"black",flash:!1}),Nc=class{constructor(){this.styles=Oc}get foreground(){return this.styles.foreground}set foreground(e){let t=this.styles;this.styles={foreground:e,underline:t.underline,italics:t.italics,background:t.background,flash:t.flash}}get underline(){return this.styles.underline}set underline(e){let t=this.styles;this.styles={foreground:t.foreground,underline:e,italics:t.italics,background:t.background,flash:t.flash}}get italics(){return this.styles.italics}set italics(e){let t=this.styles;this.styles={foreground:t.foreground,underline:t.underline,italics:e,background:t.background,flash:t.flash}}get background(){return this.styles.background}set background(e){let t=this.styles;this.styles={foreground:t.foreground,underline:t.underline,italics:t.italics,background:e,flash:t.flash}}get flash(){return this.styles.flash}set flash(e){let t=this.styles;this.styles={foreground:t.foreground,underline:t.underline,italics:t.italics,background:t.background,flash:e}}reset(){this.styles=Oc}setStyles(e){let t=this.styles,i=Object.prototype.hasOwnProperty;this.styles={foreground:i.call(e,"foreground")?e.foreground:t.foreground,underline:i.call(e,"underline")?e.underline:t.underline,italics:i.call(e,"italics")?e.italics:t.italics,background:i.call(e,"background")?e.background:t.background,flash:i.call(e,"flash")?e.flash:t.flash}}toString(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}},Uc=class{constructor(){this.uchar=" ",this.penState=new Nc}reset(){this.uchar=" ",this.penState.reset()}setChar(e,t){this.uchar=e,this.penState.styles=t.styles}setPenState(e){this.penState.styles=e.styles}copy(e){this.uchar=e.uchar,this.penState.styles=e.penState.styles}},Fc=class{constructor(e){this.chars=[],this.pos=0,this.currPenState=new Nc,this.cueStartTime=null,this.logger=void 0;for(let e=0;e<Rc;e++)this.chars.push(new Uc);this.logger=e}equals(e){let t=this.chars,i=e.chars;for(let e=0;e<Rc;e++){let r=t[e],a=i[e];if(r.uchar!==a.uchar)return!1;let n=r.penState.styles,s=a.penState.styles;if(n!==s&&(n.foreground!==s.foreground||n.underline!==s.underline||n.italics!==s.italics||n.background!==s.background||n.flash!==s.flash))return!1}return!0}copy(e){for(let t=0;t<Rc;t++)this.chars[t].copy(e.chars[t])}isEmpty(){let e=this.chars;for(let t=0;t<Rc;t++){let i=e[t];if(" "!==i.uchar)return!1;let r=i.penState.styles;if(r!==Oc&&("white"!==r.foreground||r.underline||r.italics||"black"!==r.background||r.flash))return!1}return!0}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>=Rc&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=41)}moveCursor(e){let t=Math.min(this.pos+e,Rc);if(e>1)for(let e=this.pos+1;e<t;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=kc(e);this.pos>=Rc?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<Rc;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<Rc;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)}},Bc=class{constructor(e){this.rows=[],this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(let t=0;t<Ic;t++)this.rows.push(new Fc(e));this.logger=e}reset(){for(let e=0;e<Ic;e++)this.rows[e].clear();this.currRow=14}equals(e){let t=!0;for(let i=0;i<Ic;i++)if(!this.rows[i].equals(e.rows[i])){t=!1;break}return t}copy(e){for(let t=0;t<Ic;t++){let i=this.rows[t].chars,r=e.rows[t].chars;for(let e=0;e<Rc;e++){let t=i[e],a=r[e];t.uchar=a.uchar,t.penState.styles=a.penState.styles}}}isEmpty(){let e=!0;for(let t=0;t<Ic;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 = "+tn(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<Ic;e++)this.rows[e].clear();let e=this.currRow+1-this.nrRollUpRows,i=this.lastOutputScreen;if(i){let r=i.rows[e].cueStartTime,a=this.logger.time;if(null!==r&&null!==a&&r<a)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=e.indent,r=Math.max(t-1,0);i.setCursor(e.indent),e.color=i.chars[r].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 = "+tn(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<Ic;i++){let a=this.rows[i].getTextString();a&&(r=i+1,e?t.push("Row "+r+": '"+a+"'"):t.push(a.trim()))}return t.length>0&&(i=e?"["+t.join(" | ")+"]":t.join("\n")),i}getTextAndFormat(){return this.rows}},$c=class{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 Bc(i),this.nonDisplayedMemory=new Bc(i),this.lastOutputScreen=new Bc(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})}ccRDC(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}ccTR(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}ccRTD(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}ccEDM(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}ccCR(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}ccENM(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}ccEOC(){if(this.logger.log(2,"EOC - End Of Caption"),"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};if(t.underline=e%2==1,t.italics=e>=46,t.italics)t.foreground="white";else{let i=Math.floor(e/2)-16,r=["white","green","blue","cyan","red","yellow","magenta"];t.foreground=r[i]}this.logger.log(2,"MIDROW: "+tn(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))}},Hc=class{constructor(e,t,i){this.channels=[null,null,null],this.currentChannel=0,this.cmdHistory={a:null,b:null},this.logger=void 0,this.field=void 0,this.outputFilters=void 0,this.logger=new Pc,this.field=e,this.outputFilters=[null,t,i]}getHandler(e){return this.outputFilters[e]}setHandler(e,t){var i;this.outputFilters[e]=t,null==(i=this.channels[e])||i.setHandler(t)}getChannel(e){let t=this.channels[e];return t||(t=this.channels[e]=new $c(this.field+e-1,this.outputFilters[e],this.logger)),t}addData(e,t){this.logger.time=e;for(let e=0;e<t.length;e+=2){let i=127&t[e],r=127&t[e+1],a=!1,n=null;if(0===i&&0===r)continue;this.logger.log(3,()=>"["+xc([t[e],t[e+1]])+"] -> ("+xc([i,r])+")");let s=this.cmdHistory;if(i>=16&&i<=31){if(Kc(i,r,s)){Gc(null,null,s),this.logger.log(3,()=>"Repeated command ("+xc([i,r])+") is dropped");continue}Gc(i,r,this.cmdHistory),a=this.parseCmd(i,r),a||(a=this.parseMidrow(i,r)),a||(a=this.parsePAC(i,r)),a||(a=this.parseBackgroundAttributes(i,r))}else Gc(null,null,s);if(!a&&(n=this.parseChars(i,r),n)){let e=this.currentChannel;e&&e>0?this.getChannel(e).insertChars(n):this.logger.log(2,"No channel found yet. TEXT-MODE?")}!a&&!n&&this.logger.log(2,()=>"Couldn't parse cleaned data "+xc([i,r])+" orig: "+xc([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.getChannel(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,i!==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 ("+xc([e,t])+")"),!0)}return!1}parsePAC(e,t){let i;if(!((e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127)&&!((16===e||24===e)&&t>=64&&t<=95))return!1;let r=e<=23?1:2;return i=t>=64&&t<=95?1===r?Lc[e]:Dc[e]:1===r?wc[e]:Cc[e],this.getChannel(r).setPAC(this.interpretPAC(i,t)),this.currentChannel=r,!0}interpretPAC(e,t){let i,r={color:null,italics:!1,indent:null,underline:!1,row:e};return i=t>95?t-96:t-64,r.underline=!(1&~i),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,a=null;if(e>=25?(i=2,a=e-8):(i=1,a=e),a>=17&&a<=19){let e;e=17===a?t+80:18===a?t+112:t+144,this.logger.log(2,()=>"Special char '"+kc(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 =  "+xc(r).join(",")),r}parseBackgroundAttributes(e,t){if(!((16===e||24===e)&&t>=32&&t<=47)&&!((23===e||31===e)&&t>=45&&t<=47))return!1;let i,r={};16===e||24===e?(i=Math.floor((t-32)/2),r.background=Mc[i],t%2==1&&(r.background=r.background+"_semi")):45===t?r.background="transparent":(r.foreground="black",47===t&&(r.underline=!0));let a=e<=23?1:2;return this.getChannel(a).setBkgData(r),!0}reset(){for(let e=0;e<Object.keys(this.channels).length;e++){let t=this.channels[e];t&&t.reset()}Gc(null,null,this.cmdHistory)}cueSplitAtTime(e){for(let t=0;t<this.channels.length;t++){let i=this.channels[t];i&&i.cueSplitAtTime(e)}}};function Gc(e,t,i){i.a=e,i.b=t}function Kc(e,t,i){return i.a===e&&i.b===t}var Wc=class{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 Vc(e,t,i,r){return Math.min(t,r)-Math.max(e,i)}var qc=/\s/,Yc={newCue(e,t,i,r){let a,n,s,o,l,d=[],u=self.VTTCue||self.TextTrackCue;for(let c=0;c<r.rows.length;c++)if(a=r.rows[c],s=!0,o=0,l="",!a.isEmpty()){var h;for(let e=0;e<a.chars.length;e++)qc.test(a.chars[e].uchar)&&s?o++:(l+=a.chars[e].uchar,s=!1);a.cueStartTime=t,t===i&&(i+=1e-4),o>=16?o--:o++;let r=bh(l.trim()),m=kh(t,i,r);null!=e&&null!=(h=e.cues)&&h.getCueById(m)||(n=new u(t,i,r),n.id=m,n.line=c+1,n.align="left",n.position=10+Math.min(80,10*Math.floor(8*o/32)),d.push(n))}return e&&d.length&&(d.sort((e,t)=>"auto"===e.line||"auto"===t.line?0:e.line>8&&t.line>8?t.line-e.line:e.line-t.line),d.forEach(t=>$h(e,t))),d}},jc=class{constructor(){this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=0,this.config=null,this.callbacks=null,this.context=null,this.stats=new Ii}destroy(){this.callbacks=this.context=this.config=null,this.abortInternal(),this.stats=null}load(e,t,i){let r=this.stats;if(r.loading.start)throw new Error("Loader can only be used once.");r.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=i,this.loadInternal()}abort(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.getNetworkDetails())}loadtimeout(){if(!this.config)return;let e=this.config.loadPolicy.timeoutRetry;if(Qi(e,this.stats.retry,!0))this.retry(e);else{var t;or.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.getNetworkDetails()))}}retry(e){let{context:t,stats:i}=this;this.retryDelay=ji(e,i.retry),i.retry++,or.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.resetInternalLoader(),self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(()=>this.loadInternal(),this.retryDelay)}};var zc=/(\d+)-(\d+)\/(\d+)/,Qc=class extends jc{constructor(e){super(),this.fetchSetup=void 0,this.request=null,this.response=null,this.controller=null,this.fetchSetup=e.fetchSetup||Xc}destroy(){this.request=null,super.destroy(),this.response=null,this.controller=null,this.fetchSetup=null}abortInternal(){self.clearTimeout(this.retryTimeout),this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())}getNetworkDetails(){return this.response}resetInternalLoader(){this.response=null}loadInternal(){let{config:e,context:t,stats:i}=this;if(!e||!t)return;i.loading.first=0,i.loaded=0,i.aborted=!1,this.controller=new self.AbortController;let r=function(e,t){let i={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers($i({},e.headers))};return e.rangeEnd&&i.headers.set("Range","bytes="+e.rangeStart+"-"+String(e.rangeEnd-1)),i}(t,this.controller.signal),a="arraybuffer"===t.responseType,n=a?"byteLength":"length",{maxTimeToFirstByteMs:s,maxLoadTimeMs:o}=e.loadPolicy;this.request=this.fetchSetup(t,r),self.clearTimeout(this.requestTimeout),e.timeout=s&&vi(s)?s:o,this.requestTimeout=self.setTimeout(()=>{this.loadtimeout()},e.timeout),(ed(this.request)?this.request.then(self.fetch):self.fetch(this.request)).then(r=>{var n;this.response=r;let s=Math.max(self.performance.now(),i.loading.start);if(self.clearTimeout(this.requestTimeout),e.timeout=o,this.requestTimeout=self.setTimeout(()=>{this.loadtimeout()},o-(s-i.loading.start)),!r.ok){let{status:e,statusText:t}=r;throw new Zc(t||"fetch, bad network response",e,r)}i.loading.first=s,i.total=function(e){let t=e.get("Content-Range");if(t){let e=function(e){let t=zc.exec(e);if(t)return parseInt(t[2])-parseInt(t[1])+1}(t);if(vi(e))return e}let i=e.get("Content-Length");if(i)return parseInt(i)}(r.headers)||i.total;let l=null==(n=this.callbacks)?void 0:n.onProgress;return l&&vi(e.highWaterMark)?this.loadProgressively(r,i,t,e.highWaterMark,l):a?r.arrayBuffer():"json"===t.responseType?r.json():r.text()}).then(r=>{var a,s;let o=this.response;if(!o)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),i.loading.end=Math.max(self.performance.now(),i.loading.first);let l=r[n];l&&(i.loaded=i.total=l);let d={url:o.url,data:r,code:o.status},u=null==(a=this.callbacks)?void 0:a.onProgress;u&&!vi(e.highWaterMark)&&u(i,t,r,o),null==(s=this.callbacks)||s.onSuccess(d,i,t,o)}).catch(r=>{if(self.clearTimeout(this.requestTimeout),i.aborted)return;let a=r&&r.code||0,n=r?r.message:null,s=e.loadPolicy.errorRetry;var o;Qi(s,i.retry,!1,{url:t.url,data:void 0,code:a})?this.retry(s):(or.error(`${a} while loading ${t.url}`),null==(o=this.callbacks)||o.onError({code:a,text:n},t,r?r.details:null,i))})}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,a){let n=new Oo,s=e.body.getReader(),o=()=>s.read().then(s=>{if(s.done)return n.dataLength&&a(t,i,n.flush().buffer,e),Promise.resolve(new ArrayBuffer(0));let l=s.value,d=l.length;return t.loaded+=d,d<r||n.dataLength?(n.push(l),n.dataLength>=r&&a(t,i,n.flush().buffer,e)):a(t,i,l.buffer,e),o()}).catch(()=>Promise.reject());return o()}};function Xc(e,t){return new self.Request(e.url,t)}var Zc=class extends Error{constructor(e,t,i){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=i}},Jc=/^age:\s*[\d.]+\s*$/im,em=class extends jc{constructor(e){super(),this.xhrSetup=void 0,this.loader=null,this.xhrSetup=e.xhrSetup||null}destroy(){super.destroy(),this.loader=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()))}getNetworkDetails(){return this.loader}resetInternalLoader(){this.loader=null}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 a=this.xhrSetup;a?Promise.resolve().then(()=>{if(this.loader===i&&!this.stats.aborted)return a.call(this,i,t.url,t)}).catch(e=>{if(this.loader===i&&!this.stats.aborted)return i.open("GET",t.url,!0),a.call(this,i,t.url,t)}).then(()=>{this.loader!==i||this.stats.aborted||this.openAndSendXhr(i,t,e)}).catch(e=>{var a;null==(a=this.callbacks)||a.onError({code:i.status,text:e.message},t,i,r)}):this.openAndSendXhr(i,t,e)}openAndSendXhr(e,t,i){e.readyState||e.open("GET",t.url,!0);let r=t.headers,{maxTimeToFirstByteMs:a,maxLoadTimeMs:n}=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=a&&vi(a)?a:n,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,a=this.config;if(!i.aborted&&r>=2&&(0===i.loading.first&&(i.loading.first=Math.max(self.performance.now(),i.loading.start),a.timeout!==a.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),a.timeout=a.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),a.loadPolicy.maxLoadTimeMs-(i.loading.first-i.loading.start)))),4===r)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;let r=t.status,l="text"===t.responseType?t.responseText:null;if(r>=200&&r<300){let a=null!=l?l:t.response;if(null!=a){var n,s;i.loading.end=Math.max(self.performance.now(),i.loading.first);let o="arraybuffer"===t.responseType?a.byteLength:a.length;i.loaded=i.total=o,i.bwEstimate=8e3*i.total/(i.loading.end-i.loading.first);let l=null==(n=this.callbacks)?void 0:n.onProgress;l&&l(i,e,a,t);let d={url:t.responseURL,data:a,code:r};return e.rangeEnd&&o!==e.rangeEnd-e.rangeStart&&or.warn(`Payload length ${o} does not match requested Range: bytes=${e.rangeStart}-${e.rangeEnd-1}`),void(null==(s=this.callbacks)||s.onSuccess(d,i,e,t))}}let d=a.loadPolicy.errorRetry;var o;if(Qi(d,i.retry,!1,{url:e.url,data:void 0,code:r}))this.retry(d);else or.error(`${r} while loading ${e.url}`),null==(o=this.callbacks)||o.onError({code:r,text:t.statusText},e,t,i)}}loadprogress(e){let t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)}getCacheAge(){let e=null;if(this.loader&&Jc.test(this.loader.getAllResponseHeaders())){let t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.loader&&new RegExp(`^${e}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}},tm=Gi(Gi({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,maxDevicePixelRatio:Number.POSITIVE_INFINITY,preferManagedMediaSource:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,loopBackBufferFlush:void 0,startOnSegmentBoundary:!1,nextAudioTrackBufferFlushForwardOffset:.25,maxBufferSize:6e7,maxFragLookUpTolerance:.25,maxBufferHole:.1,detectStallWithCurrentTimeMs:1250,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,nudgeOnVideoHole:!0,skipBufferHolePadding:.1,liveSyncMode:"edge",liveSyncDurationCount:3,liveSyncOnStallIncrease:1,liveMaxLatencyDurationCount:1/0,liveMaxUnchangedPlaylistRefresh: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,appendTimeout:1/0,ignorePlaylistParsingErrors:!1,loader:em,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,handleMpegTsVideoIntegrityErrors:"process",abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,abrSwitchInterval:0,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:Cs,requireKeySystemAccessOnStart:!1,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableEmsgKLVMetadata:!1,enableID3MetadataCues:!0,emsgKLVSchemaUri:void 0,enableInterstitialPlayback:!0,interstitialAppendInPlace:!0,interstitialLiveLookAhead:10,iframeCacheLimit:2097152,useMediaCapabilities:!0,preserveManualLevelOnError:!1,errorPenaltyExpireMs:0,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,streamController:ic,abrController:class extends tr{constructor(e){super("abr",e.logger),this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.firstAutoFloor=-1,this._nextAutoLevel=-1,this.nextAutoLevelKey="",this.audioTracksByGroup=null,this.codecTiers=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{fragCurrent:i,partCurrent:r,hls:a}=this;if(!a)return;let{autoLevelEnabled:n,media:s}=a;if(!i||!s)return;let o=performance.now(),l=r?r.stats:i.stats,d=r?r.duration:i.duration,u=o-l.loading.start,h=a.minAutoLevel,c=i.level,m=this._nextAutoLevel;if(l.aborted||l.loaded&&l.loaded===l.total||c<=h)return this.clearTimer(),void(this._nextAutoLevel=-1);if(!n)return;let f=m>-1&&m!==c,p=!!e||f;if(!p&&(s.paused||!s.playbackRate||!s.readyState))return;let g=a.mainForwardBufferInfo;if(!p&&null===g)return;let v=this.bwEstimator.getEstimateTTFB(),E=Math.abs(s.playbackRate);if(u<=Math.max(v,d/(2*E)*1e3))return;let y=g?g.len/E:0,b=l.loading.first?l.loading.first-l.loading.start:-1,T=l.loaded&&b>-1,A=this.getBwEstimate(),_=a.levels,S=_[c],k=Math.max(l.loaded,Math.round(d*(i.bitrate||S.averageBitrate)/8)),I=T?u-b:u;I<1&&T&&(I=Math.min(u,8*l.loaded/A));let R=T?1e3*l.loaded/I:0,L=v/1e3,w=R?(k-l.loaded)/R:8*k/A+L;if(w<=y)return;let D,C=R?8*R:A,M=!0===(null==(t=(null==e?void 0:e.details)||a.latestLevelDetails)?void 0:t.live),P=a.config.abrBandWidthUpFactor,x=Number.POSITIVE_INFINITY;for(D=c-1;D>h;D--){let e=_[D].maxBitrate,t=!_[D].details||M;if(x=this.getTimeToLoadFrag(L,C,d*e,t),x<Math.min(y,d+L))break}if(x>=w||x>10*d)return;T?this.bwEstimator.sample(u-Math.min(v,b),l.loaded):this.bwEstimator.sampleTTFB(u);let O=_[D].maxBitrate;this.getBwEstimate()*P>O&&(this.firstAutoFloor=Math.min(D,a.firstLevel),this.resetEstimator(O));let N=this.findBestLevel(O,h,D,0,y,1,1);N>-1&&(D=N),this.warn(`Fragment ${i.sn}${r?" part "+r.index:""} of level ${c} is loading too slowly;\n      Fragment duration: ${i.duration.toFixed(3)}\n      Time to underbuffer: ${y.toFixed(3)} s\n      Estimated load time for current fragment: ${w.toFixed(3)} s\n      Estimated load time for down switch fragment: ${x.toFixed(3)} s\n      TTFB estimate: ${0|b} ms\n      Current BW estimate: ${vi(A)?0|A:"Unknown"} bps\n      New BW estimate: ${0|this.getBwEstimate()} bps\n      Switching to level ${D} @ ${0|O} bps`),a.nextLoadLevel=a.nextAutoLevel=D,this.clearTimer();let U=()=>{this.clearTimer();let e=this.hls;if(this.fragCurrent===i&&e.loadLevel===D&&D>0){let t=this.getStarvationDelay();if(this.warn(`Aborting inflight request ${D>0?"and switching down":""}\n      Fragment duration: ${i.duration.toFixed(3)} s\n      Time to underbuffer: ${t.toFixed(3)} s`),i.abortRequests(),this.fragCurrent=this.partCurrent=null,D>h){let i=this.findBestLevel(e.levels[h].bitrate,h,D,0,t,1,1);-1===i&&(i=h),e.nextLoadLevel=e.nextAutoLevel=i,this.firstAutoFloor=Math.min(i,e.firstLevel),this.resetEstimator(e.levels[i].bitrate)}}};f||w>2*x?U():this.timer=self.setInterval(U,1e3*x),a.trigger(Ai.FRAG_LOAD_EMERGENCY_ABORTED,{frag:i,part:r,stats:l})},this.hls=e,this.bwEstimator=this.initEstimator(),this.registerListeners()}resetEstimator(e){this.hls&&(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 er(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}registerListeners(){let e=this.hls;e.on(Ai.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Ai.FRAG_LOADING,this.onFragLoading,this),e.on(Ai.FRAG_LOADED,this.onFragLoaded,this),e.on(Ai.FRAG_BUFFERED,this.onFragBuffered,this),e.on(Ai.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(Ai.LEVEL_LOADED,this.onLevelLoaded,this),e.on(Ai.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(Ai.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(Ai.ERROR,this.onError,this)}unregisterListeners(){let{hls:e}=this;e&&(e.off(Ai.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Ai.FRAG_LOADING,this.onFragLoading,this),e.off(Ai.FRAG_LOADED,this.onFragLoaded,this),e.off(Ai.FRAG_BUFFERED,this.onFragBuffered,this),e.off(Ai.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(Ai.LEVEL_LOADED,this.onLevelLoaded,this),e.off(Ai.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(Ai.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(Ai.ERROR,this.onError,this))}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=this.supportedCache=null,this.audioTracksByGroup=this.codecTiers=this.fragCurrent=this.partCurrent=null}onManifestLoading(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.firstAutoFloor=-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;if(!this.ignoreFragment(i)){var r;if(!i.bitrateTest)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 Ti.BUFFER_ADD_CODEC_ERROR:case Ti.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case Ti.FRAG_LOAD_TIMEOUT:{let e=t.frag,{fragCurrent:i,partCurrent:r}=this;if(e&&Oi(e,i)){let t=performance.now(),i=r?r.stats:e.stats,a=t-i.loading.start,n=i.loading.first?i.loading.first-i.loading.start:-1;if(i.loaded&&n>-1){let e=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(a-Math.min(e,n),i.loaded)}else this.bwEstimator.sampleTTFB(a)}break}}}getTimeToLoadFrag(e,t,i,r){return e+i/t+(r?e+this.lastLevelLoadSec:0)}onLevelLoaded(e,t){let i=this.hls.config,{loading:r}=t.stats,a=r.end-r.first;vi(a)&&(this.lastLevelLoadSec=a/1e3),t.details.live?this.bwEstimator.update(i.abrEwmaSlowLive,i.abrEwmaFastLive):this.bwEstimator.update(i.abrEwmaSlowVoD,i.abrEwmaFastVoD),this.timer>-1&&this._abandonRulesCheck(t.levelInfo)}onFragLoaded(e,t){var i;let{frag:r,part:a}=t,n=a?a.stats:r.stats;if(r.type===Li.MAIN&&this.bwEstimator.sampleTTFB(n.loading.first-n.loading.start),!this.ignoreFragment(r)){if(this.clearTimer(),r.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,null!=(i=this.hls)&&i.config.abrMaxWithRealBitrate){let e=a?a.duration:r.duration,t=this.hls.levels[r.level],i=(t.loaded?t.loaded.bytes:0)+n.loaded,s=(t.loaded?t.loaded.duration:0)+e;t.loaded={bytes:i,duration:s},t.realBitrate=Math.round(8*i/s)}if(r.bitrateTest){let e={stats:n,frag:r,part:a,id:r.type};this.onFragBuffered(Ai.FRAG_BUFFERED,e),r.bitrateTest=!1}else this.lastLoadedFragLevel=r.level}}onFragBuffered(e,t){let{frag:i,part:r}=t,a=null!=r&&r.stats.loaded?r.stats:i.stats;if(a.aborted||this.ignoreFragment(i))return;let n=((i.bitrate||0)>=1e5?a.parsing.end:a.loading.end)-a.loading.start-Math.min(a.loading.first-a.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(n,a.loaded),a.bwEstimate=this.getBwEstimate(),i.bitrateTest?this.bitrateTestDelay=n/1e3:(this.bitrateTestDelay=0,this.firstAutoFloor>-1&&this.bwEstimator.canEstimate()&&(this.firstAutoFloor=-1))}ignoreFragment(e){return e.type!==Li.MAIN||"initSegment"===e.sn}clearTimer(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)}get firstAutoLevel(){let{hls:e}=this;if(!e)return 0;let{maxAutoLevel:t,minAutoLevel:i}=e,r=this.getBwEstimate(),a=this.getStarvationDelay(),n=e.config.maxStarvationDelay,s=this.findBestLevel(r,i,t,a/2,n,1,1);if(s>-1)return s;let o=e.firstLevel,l=-1===this.firstAutoFloor?1/0:this.firstAutoFloor,d=Math.min(Math.max(o,i),t,l);return this.warn(`Could not find best starting auto level. Defaulting to first in playlist ${o} clamped to ${d}`),d}get forcedAutoLevel(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}get nextAutoLevel(){if(!this.hls)return-1;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()}_${this.getStarvationDelay().toFixed(2)}`}getNextABRAutoLevel(){let{fragCurrent:e,partCurrent:t,hls:i}=this;if(!i)return-1;if(i.levels.length<=1)return i.loadLevel;let{maxAutoLevel:r,config:a,minAutoLevel:n}=i,s=t?t.duration:e?e.duration:0,o=this.getBwEstimate(),l=this.getStarvationDelay(),d=a.abrBandWidthFactor,u=a.abrBandWidthUpFactor;if(l){let e=this.findBestLevel(o,n,r,l,0,d,u);if(e>=0)return this.rebufferNotice=-1,e}let h=s?Math.min(s,a.maxStarvationDelay):a.maxStarvationDelay;if(!l){let e=this.bitrateTestDelay;e&&(h=(s?Math.min(s,a.maxLoadingDelay):a.maxLoadingDelay)-e,this.info(`bitrate test took ${Math.round(1e3*e)}ms, set first fragment max fetchDuration to ${Math.round(1e3*h)} ms`),d=u=1)}let c=this.findBestLevel(o,n,r,l,h,d,u);if(this.rebufferNotice!==c&&(this.rebufferNotice=c,this.info(`${l?"rebuffering expected":"buffer is empty"}, optimal quality level ${c}`)),c>-1)return c;let m=i.levels[n],f=i.loadLevelObj;return f&&(null==m?void 0:m.bitrate)<f.bitrate?n:i.loadLevel}getStarvationDelay(){let e=this.hls,t=null==e?void 0: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.getEstimate()}findBestLevel(e,t,i,r,a,n,s){let{hls:o,lastLoadedFragLevel:l,fragCurrent:d,partCurrent:u}=this;if(!o)return-1;let h=r+a,c=-1===l?o.firstLevel:l,{levels:m,allAudioTracks:f,loadLevel:p,latestLevelDetails:g,config:v}=o;if(1===m.length)return 0;let E,y=m[c],b=!(null==g||!g.live),T=-1===p||-1===l,A="SDR",_=(null==y?void 0:y.frameRate)||0,{audioPreference:S,videoPreference:k}=v,I=this.audioTracksByGroup||(this.audioTracksByGroup=an(f)),R=-1;if(T){if(-1!==this.firstSelection)return this.firstSelection;let r=this.codecTiers||(this.codecTiers=function(e,t,i,r){return e.slice(i,r+1).reduce((e,i,r)=>{if(!i.codecSet)return e;let a=i.audioGroups,n=e[i.codecSet];n||(e[i.codecSet]=n={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,minIndex:r,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!a,fragmentError:0}),n.minBitrate=Math.min(n.minBitrate,i.bitrate);let s=Math.min(i.height,i.width);return n.minHeight=Math.min(n.minHeight,s),n.minFramerate=Math.min(n.minFramerate,i.frameRate),n.minIndex=Math.min(n.minIndex,r),n.maxScore=Math.max(n.maxScore,i.score),n.fragmentError+=i.fragmentError,n.videoRanges[i.videoRange]=(n.videoRanges[i.videoRange]||0)+1,a&&a.forEach(e=>{if(!e)return;let i=t.groups[e];i&&(n.hasDefaultAudio=n.hasDefaultAudio||t.hasDefaultAudio?i.hasDefault:i.hasAutoSelect||!t.hasDefaultAudio&&!t.hasAutoSelectAudio,Object.keys(i.channels).forEach(e=>{n.channels[e]=(n.channels[e]||0)+i.channels[e]}))}),e},{})}(m,I,t,i)),a=function(e,t,i,r,a){let n=Object.keys(e),s=null==r?void 0:r.channels,o=null==r?void 0:r.audioCodec,l=null==a?void 0:a.videoCodec,d=s&&2===parseInt(s),u=!1,h=!1,c=1/0,m=1/0,f=1/0,p=1/0,g=0,v=[],{preferHDR:E,allowedVideoRanges:y}=en(t,a);for(let t=n.length;t--;){let i=e[n[t]];u||(u=i.channels[2]>0),c=Math.min(c,i.minHeight),m=Math.min(m,i.minFramerate),f=Math.min(f,i.minBitrate),y.filter(e=>i.videoRanges[e]>0).length>0&&(h=!0)}c=vi(c)?c:0,m=vi(m)?m:0;let b=Math.max(1080,c),T=Math.max(30,m);f=vi(f)?f:i,i=Math.max(f,i),h||(t=void 0);let A=n.length>1;return{codecSet:n.reduce((t,r)=>{let a=e[r];if(r===t)return t;if(v=h?y.filter(e=>a.videoRanges[e]>0):[],A){if(a.minBitrate>i)return rn(r,`min bitrate of ${a.minBitrate} > current estimate of ${i}`),t;if(!a.hasDefaultAudio)return rn(r,"no renditions with default or auto-select sound found"),t;if(o&&r.indexOf(o.substring(0,4))%5!=0)return rn(r,`audio codec preference "${o}" not found`),t;if(s&&!d){if(!a.channels[s])return rn(r,`no renditions with ${s} channel sound found (channels options: ${Object.keys(a.channels)})`),t}else if((!o||d)&&u&&0===a.channels[2])return rn(r,"no renditions with stereo sound found"),t;if(a.minHeight>b)return rn(r,`min resolution of ${a.minHeight} > maximum of ${b}`),t;if(a.minFramerate>T)return rn(r,`min framerate of ${a.minFramerate} > maximum of ${T}`),t;if(!v.some(e=>a.videoRanges[e]>0))return rn(r,`no variants with VIDEO-RANGE of ${tn(v)} found`),t;if(l&&r.indexOf(l.substring(0,4))%5!=0)return rn(r,`video codec preference "${l}" not found`),t;if(a.maxScore<g)return rn(r,`max score of ${a.maxScore} < selected max of ${g}`),t}return t&&(La(r)>=La(t)||a.fragmentError>e[t].fragmentError)?t:(p=a.minIndex,g=a.maxScore,r)},void 0),videoRanges:v,preferHDR:E,minFramerate:m,minBitrate:f,minIndex:p}}(r,A,e,S,k),{codecSet:n,videoRanges:s,minFramerate:o,minBitrate:l,minIndex:d,preferHDR:u}=a;R=d,E=n,A=u?s[s.length-1]:s[0],_=o,e=Math.max(e,l),this.log(`picked start tier ${tn(a)}`)}else E=null==y?void 0:y.codecSet,A=null==y?void 0:y.videoRange;let L=u?u.duration:d?d.duration:0,w=this.bwEstimator.getEstimateTTFB()/1e3,D=[];for(let o=i;o>=t;o--){var C;let t=m[o],d=o>c;if(!t)continue;if(v.useMediaCapabilities&&!t.supportedResult&&!t.supportedPromise){let i=navigator.mediaCapabilities;"function"==typeof(null==i?void 0:i.decodingInfo)&&$a(t,I,A,_,e,S)?(t.supportedPromise=Ha(t,I,i,this.supportedCache),t.supportedPromise.then(e=>{if(!this.hls)return;t.supportedResult=e;let i=this.hls.levels,r=i.indexOf(t);e.error?this.warn(`MediaCapabilities decodingInfo error: "${e.error}" for level ${r} ${tn(e)}`):e.supported?e.decodingInfoResults.some(e=>!1===e.smooth||!1===e.powerEfficient)&&this.log(`MediaCapabilities decodingInfo for level ${r} not smooth or powerEfficient: ${tn(e)}`):(this.warn(`Unsupported MediaCapabilities decodingInfo result for level ${r} ${tn(e)}`),r>-1&&i.length>1&&(this.log(`Removing unsupported level ${r}`),this.hls.removeLevel(r),-1===this.hls.loadLevel&&(this.hls.nextLoadLevel=0)))}).catch(e=>{this.warn(`Error handling MediaCapabilities decodingInfo: ${e}`)})):t.supportedResult=Fa}if((E&&t.codecSet!==E||A&&t.videoRange!==A||d&&_>t.frameRate||!d&&_>0&&_<t.frameRate||null!=(C=t.supportedResult)&&null!=(C=C.decodingInfoResults)&&C.some(e=>!1===e.smooth))&&(!T||o!==R)){D.push(o);continue}let f,g=t.details,y=(u?null==g?void 0:g.partTarget:null==g?void 0:g.averagetargetduration)||L||1;f=d?s*e:n*e;let k=L&&r>=2*L&&0===a?t.averageBitrate:t.maxBitrate,M=this.getTimeToLoadFrag(w,f,k*y,!g||g.live);if(f>=k&&(o===l||0===t.loadError&&0===t.fragmentError||Zi(t,v.errorPenaltyExpireMs))&&(M<=w||!vi(M)||b&&!this.bitrateTestDelay||M<h)){let e=this.forcedAutoLevel;return o!==p&&(-1===e||e!==p)&&(D.length&&this.trace(`Skipped level(s) ${D.join(",")} of ${i} max with CODECS and VIDEO-RANGE:"${m[D[0]].codecs}" ${m[D[0]].videoRange}; not compatible with "${E}" ${A}`),this.info(`switch candidate:${c}->${o} adjustedbw(${Math.round(f)})-bitrate=${Math.round(f-k)} ttfb:${w.toFixed(1)} avgDuration:${y.toFixed(1)} maxFetchDuration:${h.toFixed(1)} fetchDuration:${M.toFixed(1)} firstSelection:${T} codecSet:${t.codecSet} videoRange:${t.videoRange} hls.loadLevel:${p}`)),T&&(this.firstSelection=o),o}}return-1}set nextAutoLevel(e){let t=this.deriveNextAutoLevel(e);this._nextAutoLevel!==t&&(this.nextAutoLevelKey="",this._nextAutoLevel=t)}deriveNextAutoLevel(e){if(!this.hls)return-1;let{maxAutoLevel:t,minAutoLevel:i}=this.hls;return Math.min(Math.max(e,i),t)}},bufferController:class extends tr{constructor(e,t){super("buffer-controller",e.logger),this.hls=void 0,this.fragmentTracker=void 0,this.fragmentAppendProgress=Object.create(null),this.appendsWithoutProgress=Object.create(null),this.details=null,this._objectUrl=null,this.operationQueue=null,this.bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=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.appendError=void 0,this._quotaEvictionPending={},this.tracks={},this.sourceBuffers=[[null,null],[null,null]],this._onEndStreaming=e=>{var t;this.hls&&"open"===(null==(t=this.mediaSource)?void 0:t.readyState)&&(!this.media||this.media.seeking||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&&(Eo(i,"sourceopen",this._onMediaSourceOpen),Eo(t,"emptied",this._onMediaEmptied),this.updateDuration(),this.hls.trigger(Ai.MEDIA_ATTACHED,{media:t,mediaSource:i}),null!==this.mediaSource&&this.checkPendingTracks())},this._onMediaSourceClose=()=>{if(this.log("Media source closed"),this.media){let e=this.media.error,{appendError:t,appendErrors:i}=this,r=!1;!t&&e&&(r=Math.max(++i.audio,++i.video,++i.audiovideo)>=this.hls.config.appendErrorMaxRetry);let a=new Error(`MediaSource closed while media attached${fd(r,e)}`);this.warn(a),this.hls.trigger(Ai.ERROR,$i({fatal:r},t,{type:bi.MEDIA_ERROR,details:Ti.MEDIA_SOURCE_REQUIRES_RESET,error:a}))}},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._onMediaError=()=>{let{media:e}=this;var t,i;e&&this.log(`Media error (code: ${null==(t=e.error)?void 0:t.code}): ${null==(i=e.error)?void 0:i.message}`)},this.hls=e,this.fragmentTracker=t,this.appendSource=function(e){return"undefined"!=typeof self&&e===self.ManagedMediaSource}(lr(e.config.preferManagedMediaSource)),this.initTracks(),this.registerListeners()}hasSourceTypes(){return Object.keys(this.tracks).length>0}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=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,this._onMediaEmptied=this._onMediaError=null}registerListeners(){let{hls:e}=this;e.on(Ai.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(Ai.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Ai.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Ai.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Ai.BUFFER_RESET,this.onBufferReset,this),e.on(Ai.BUFFER_APPENDING,this.onBufferAppending,this),e.on(Ai.BUFFER_CODECS,this.onBufferCodecs,this),e.on(Ai.BUFFER_EOS,this.onBufferEos,this),e.on(Ai.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(Ai.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(Ai.FRAG_PARSED,this.onFragParsed,this),e.on(Ai.FRAG_CHANGED,this.onFragChanged,this),e.on(Ai.ERROR,this.onError,this)}unregisterListeners(){let{hls:e}=this;e.off(Ai.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(Ai.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Ai.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Ai.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Ai.BUFFER_RESET,this.onBufferReset,this),e.off(Ai.BUFFER_APPENDING,this.onBufferAppending,this),e.off(Ai.BUFFER_CODECS,this.onBufferCodecs,this),e.off(Ai.BUFFER_EOS,this.onBufferEos,this),e.off(Ai.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(Ai.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(Ai.FRAG_PARSED,this.onFragParsed,this),e.off(Ai.FRAG_CHANGED,this.onFragChanged,this),e.off(Ai.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 r&&!this.sourceBufferCount&&r.mediaSource===t?$i(i,r.tracks):this.sourceBuffers.forEach(e=>{let[t]=e;t&&(i[t]=$i({},this.tracks[t]),this.removeBuffer(t)),e[0]=e[1]=null}),{media:e,mediaSource:t,tracks:i}}initTracks(){this.resetAppendProgress(),this.sourceBuffers=[[null,null],[null,null]],this.tracks={},this.resetQueue(),this.lastMpegAudioChunk=null,this.lastVideoAppendEnd=0}onManifestLoading(){this.bufferCodecEventsTotal=0,this.details=null,this.resetAppendErrors(),this.resetAppendProgress()}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=lr(this.appendSource);if(r){let e=!!t.mediaSource;(e||t.overrides)&&(this.transferData=t,this.overrides=t.overrides);let a=this.mediaSource=t.mediaSource||new r;if(this.assignMediaSource(a),e)this._objectUrl=i.src,this.attachTransferred();else{let e=this._objectUrl=self.URL.createObjectURL(a);if(this.appendSource)try{i.removeAttribute("src");let t=self.ManagedMediaSource;i.disableRemotePlayback=i.disableRemotePlayback||t&&a instanceof t,cd(i),function(e,t){let i=self.document.createElement("source");i.type="video/mp4",i.src=t,e.appendChild(i)}(i,e),i.load()}catch{i.src=e}else i.src=e}vo(i,"emptied",this._onMediaEmptied),vo(i,"error",this._onMediaError),this.appendSource&&vo(i,"seeking",this._onStartStreaming)}}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}`),vo(e,"sourceopen",this._onMediaSourceOpen),vo(e,"sourceended",this._onMediaSourceEnded),vo(e,"sourceclose",this._onMediaSourceClose),this.appendSource&&(vo(e,"startstreaming",this._onStartStreaming),vo(e,"endstreaming",this._onEndStreaming))}attachTransferred(){let e=this.media,t=this.transferData;if(!t||!e)return;let i=this.tracks,r=t.tracks,a=r?Object.keys(r):null,n=a?a.length:0,s=()=>{Promise.resolve().then(()=>{this.media&&this.mediaSourceOpenOrEnded&&this._onMediaSourceOpen()})};if(r&&a&&n){if(!this.tracksReady)return this.hls.config.startFragPrefetch=!0,void this.log("attachTransferred: waiting for SourceBuffer track info");if(this.log(`attachTransferred: (bufferCodecEventsTotal ${this.bufferCodecEventsTotal})\nrequired tracks: ${tn(i,(e,t)=>"initSegment"===e?void 0:t)};\ntransfer tracks: ${tn(r,(e,t)=>"initSegment"===e?void 0:t)}}`),!dr(r,i)){t.mediaSource=null,t.tracks=void 0;let a=e.currentTime,n=this.details,s=Math.max(a,(null==n?void 0:n.fragments[0].start)||0);return s-a>1?void this.log(`attachTransferred: waiting for playback to reach new tracks start time ${a} -> ${s}`):(this.warn(`attachTransferred: resetting MediaSource for incompatible tracks ("${Object.keys(r)}"->"${Object.keys(i)}") start time: ${s} currentTime: ${a}`),this.onMediaDetaching(Ai.MEDIA_DETACHING,{}),this.onMediaAttaching(Ai.MEDIA_ATTACHING,t),void(e.currentTime=s))}this.transferData=void 0,a.forEach(e=>{let t=e,i=r[t];if(i){let e=i.buffer;if(e){let r=this.fragmentTracker,a=i.id;if(r.hasFragments(a)||r.hasParts(a)){let i=ts.getBuffered(e);r.detectEvictedFragments(t,i,a,null,null,!0)}let n=md(t),s=[t,e];this.sourceBuffers[n]=s,e.updating&&this.operationQueue&&this.operationQueue.prependBlocker(t),this.trackSourceBuffer(t,i)}}}),s(),this.bufferCreated()}else this.log("attachTransferred: MediaSource w/o SourceBuffers"),s()}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:a,_objectUrl:n}=this;if(a){if(this.log("media source "+(i?"transferring":"detaching")),i)this.sourceBuffers.forEach(([e])=>{e&&this.removeBuffer(e)}),this.resetQueue();else{if(this.mediaSourceOpenOrEnded){let e="open"===a.readyState;try{let t=a.sourceBuffers;for(let i=t.length;i--;)e&&t[i].abort(),a.removeSourceBuffer(t[i]);e&&a.endOfStream()}catch(e){this.warn(`onMediaDetaching: ${e.message} while calling endOfStream`)}}this.sourceBufferCount&&this.onBufferReset()}Eo(a,"sourceopen",this._onMediaSourceOpen),Eo(a,"sourceended",this._onMediaSourceEnded),Eo(a,"sourceclose",this._onMediaSourceClose),this.appendSource&&(Eo(a,"startstreaming",this._onStartStreaming),Eo(a,"endstreaming",this._onEndStreaming)),this.mediaSource=null,this._objectUrl=null}r&&(Eo(r,"emptied",this._onMediaEmptied),Eo(r,"error",this._onMediaError),Eo(r,"seeking",this._onStartStreaming),i||(n&&self.URL.revokeObjectURL(n),this.mediaSrc===n?(r.removeAttribute("src"),this.appendSource&&cd(r),r.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.media=null)}onBufferReset(){this.sourceBuffers.forEach(([e])=>{e&&this.resetBuffer(e)}),this.initTracks()}resetBuffer(e){var t;let i=null==(t=this.tracks[e])?void 0:t.buffer;if(this.removeBuffer(e),i)try{var r;null!=(r=this.mediaSource)&&r.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(i)}catch(t){this.warn(`onBufferReset ${e}`,t)}delete this.tracks[e]}removeBuffer(e){this.removeBufferListeners(e),this.sourceBuffers[md(e)]=[null,null];let t=this.tracks[e];t&&(this.clearBufferAppendTimeoutId(t),t.buffer=void 0)}resetQueue(){this.operationQueue&&this.operationQueue.destroy(),this.operationQueue=new ld(this.tracks)}onBufferCodecs(e,t){var i;let r=this.tracks,a=Object.keys(t);this.log(`BUFFER_CODECS: "${a}" (current SB count ${this.sourceBufferCount})`);let n="audiovideo"in t&&(r.audio||r.video)||r.audiovideo&&("audio"in t||"video"in t),s=!n&&this.sourceBufferCount&&this.media&&a.some(e=>!r[e]);n||s?this.warn(`Unsupported transition between "${Object.keys(r)}" and "${a}" SourceBuffers`):(a.forEach(e=>{var i,a;let n=t[e],{id:s,codec:o,levelCodec:l,container:d,metadata:u,supplemental:h}=n,c=r[e],m=null==(i=this.transferData)||null==(i=i.tracks)?void 0:i[e],f=null!=m&&m.buffer?m:c,p=(null==f?void 0:f.pendingCodec)||(null==f?void 0:f.codec),g=null==f?void 0:f.levelCodec;c||(c=r[e]={buffer:void 0,listeners:[],codec:o,supplemental:h,container:d,levelCodec:l,metadata:u,id:s});let v=Ma(p,g),E=null==v?void 0:v.replace(dd,"$1"),y=Ma(o,l),b=null==(a=y)?void 0:a.replace(dd,"$1");y&&v&&E!==b&&("audio"===e.slice(0,5)&&(y=Ca(y,this.appendSource)),this.log(`switching codec ${p} to ${y}`),y!==(c.pendingCodec||c.codec)&&(c.pendingCodec=y),c.container=d,this.appendChangeType(e,d,y))}),(this.tracksReady||this.sourceBufferCount)&&(t.tracks=this.sourceBufferTracks),!this.sourceBufferCount&&(this.bufferCodecEventsTotal>1&&!this.tracks.video&&!t.video&&"main"===(null==(i=t.audio)?void 0:i.id)&&(this.log("Main audio-only"),this.bufferCodecEventsTotal=1),this.mediaSourceOpenOrEnded&&this.checkPendingTracks()))}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}`,a={label:`change-type=${r}`,execute:()=>{let a=this.tracks[e];if(a){let n=a.buffer;null!=n&&n.changeType&&(this.log(`changing ${e} sourceBuffer type to ${r}`),n.changeType(r),a.codec=i,a.container=t)}this.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:t=>{this.warn(`Failed to change ${e} SourceBuffer type`,t)}};this.append(a,e,this.isPending(this.tracks[e]))}blockAudio(e){var t;let i=e.start,r=i+.05*e.duration;if(!0===(null==(t=this.fragmentTracker.getAppendedFrag(i,Li.MAIN))?void 0:t.gap))return;let a={label:"block-audio",execute:()=>{var e,t;(this.lastVideoAppendEnd>r||ts.isBuffered(null==(e=this.tracks.video)?void 0:e.buffer,r)||!0===(null==(t=this.fragmentTracker.getAppendedFrag(r,Li.MAIN))?void 0:t.gap))&&this.unblockAudio()},onStart:()=>{},onComplete:()=>{},onError:e=>{this.warn("Error executing block-audio operation",e)}};this.append(a,"audio",!0)}unblockAudio(){this.operationQueue&&this.operationQueue.unblockAudio()}onBufferAppending(e,t){let{tracks:i}=this,{data:r,type:a,parent:n,frag:s,part:o,chunkMeta:l,offset:d}=t,u=l.buffering[a],h=Pi(s)&&!o&&!s.gap&&!l.partial&&!l.iframe,c=null,m=!1,{sn:f,cc:p}=s,g=self.performance.now();u.start=g;let v=s.stats.buffering,E=o?o.stats.buffering:null;0===v.start&&(v.start=g),0===(null==E?void 0:E.start)&&(E.start=g);let y=i.audio,b=!1;"audio"===a&&"audio/mpeg"===(null==y?void 0:y.container)&&(b=!this.lastMpegAudioChunk||1===l.id||this.lastMpegAudioChunk.sn!==l.sn,this.lastMpegAudioChunk=l);let T=i.video,A=null==T?void 0:T.buffer;if(A&&"initSegment"!==f&&void 0!==d){let e=null==y?void 0:y.buffer,t=o||s;if("audio"===a&&"main"!==n&&!T.ending&&!T.ended&&e&&ts.getBuffered(e).length){let e=t.start+.05*t.duration,i=ts.getBuffered(A),r=this.currentOp("video");i.length||r?!ts.isBuffered(A,e)&&this.lastVideoAppendEnd<e&&this.blockAudio(t):this.blockAudio(t)}else if("video"===a){let e=t.end,i=this.lastVideoAppendEnd-e;this.lastVideoAppendEnd=e,i<0||i>t.duration?this.unblockAudio():this.isAudioBlocked()&&this.executeNext("audio")}}let _=(o||s).start,S={label:`append-${a}`,execute:()=>{var e;u.executeStart=self.performance.now();let t=null==(e=this.tracks[a])?void 0:e.buffer;t&&(h&&(c=ts.timeRangesToArray(ts.getBuffered(t)),m=vd(gd(c,s),s)),b?this.updateTimestampOffset(t,_,.1,a,f,p):void 0!==d&&vi(d)&&this.updateTimestampOffset(t,d,1e-6,a,f,p)),this.appendExecutor(r,a)},onStart:()=>{},onComplete:()=>{this.clearBufferAppendTimeoutId(this.tracks[a]);let e=self.performance.now();u.executeEnd=u.end=e,0===v.first&&(v.first=e),0===(null==E?void 0:E.first)&&(E.first=e);let t={};if(this.sourceBuffers.forEach(([e,i])=>{e&&(t[e]=ts.getBuffered(i))}),h){let e=this.getFragmentAppendProgress(s),i=t[a];if(i&&c){let t=gd(ts.timeRangesToArray(i),s);e.progressed||(e.progressed=t-gd(c,s)>.001);let r=m&&vd(t,s);e.fullyBuffered[a]=(void 0===e.fullyBuffered[a]||e.fullyBuffered[a])&&r}}this.hls.trigger(Ai.BUFFER_APPENDED,{type:a,frag:s,part:o,chunkMeta:l,parent:n,timeRanges:t})},onError:e=>{var t;this.clearBufferAppendTimeoutId(this.tracks[a]);let i=e.code===DOMException.QUOTA_EXCEEDED_ERR||"QuotaExceededError"==e.name||"quota"in e;if(i&&!this._quotaEvictionPending[a]){let e=this.getBackBufferEvictionTarget(a,r.byteLength,s.type);if(e>0){this._quotaEvictionPending[a]=!0,this.log(`QuotaExceededError on "${a}" append sn: ${f} - evicting back buffer to ${e.toFixed(3)}s and retrying`);let t=this.getFlushOp(a,0,e),i=this.getClearEvictionPendingOp(a);return void this.insertNext([t,S,i],a)}this.warn(`QuotaExceededError on "${a}" sn: ${f} - no back buffer available to evict`)}h&&(this.getFragmentAppendProgress(s).errored=!0);let d={type:bi.MEDIA_ERROR,parent:n,details:Ti.BUFFER_APPEND_ERROR,sourceBufferName:a,frag:s,part:o,chunkMeta:l,error:e,err:e,fatal:!1},u=null==(t=this.media)?void 0:t.error;if(e.name!==ud||0!==this.sourceBufferCount||this.media&&0!==this.pendingTrackCount){var c;i&&(d.details=Ti.BUFFER_FULL_ERROR);let t=++this.appendErrors[a],r=this.hls.config.appendErrorMaxRetry;this.warn(`Failed ${t}/${r+1} times to append segment in "${a}" sourceBuffer with error: ${e.message}`),t>=r&&(d.fatal=!i);let n=null==(c=this.mediaSource)?void 0:c.readyState;("ended"===n||"closed"===n||u)&&(this.warn(`MediaSource readyState "${n}" during SourceBuffer${fd(d.fatal,u)}`),d.details=Ti.MEDIA_SOURCE_REQUIRES_RESET)}else d.errorAction=Cn(!0);this.appendError=d,this.hls.trigger(Ai.ERROR,d),i&&this.hls&&this.trimBuffers(s.start,1)}};this.log(`queuing "${a}" append sn: ${f}${o?" p: "+o.index:""} of ${n} playlist ${s.level} cc: ${p} offset: ${d} bytes: ${r.byteLength}`),this.append(S,a,this.isPending(this.tracks[a]))}getClearEvictionPendingOp(e){return{label:"clear",execute:()=>{this._quotaEvictionPending[e]=!1,this.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:()=>{}}}getFlushOp(e,t,i){return this.log(`queuing "${e}" remove ${t}-${i}`),{label:"remove",execute:()=>{this.removeExecutor(e,t,i)},onStart:()=>{},onComplete:()=>{var r;let a=null==(r=this.tracks[e])?void 0:r.buffer;this.log(`Remove request ${t}-${i} from ${e} Source Buffer complete > buffer: ${a?yo(ts.getBuffered(a)):"(detached)"}`),this.hls.trigger(Ai.BUFFER_FLUSHED,{type:e,start:t,end:i})},onError:r=>{this.warn(`Failed to remove ${t}-${i} from "${e}" SourceBuffer`,r),this.hls.trigger(Ai.BUFFER_FLUSHED,{type:e,start:0,end:0,error:r})}}}onBufferFlushing(e,t){let{type:i,startOffset:r,endOffset:a}=t;(!i||"audio"===i)&&this.unblockAudio(),i?this.append(this.getFlushOp(i,r,a),i):this.sourceBuffers.forEach(([e])=>{e&&this.append(this.getFlushOp(e,r,a),e)})}onFragParsed(e,t){let{frag:i,part:r,chunkMeta:a}=t,n=[],s=r?r.elementaryStreams:i.elementaryStreams;s[Ci]?n.push("audiovideo"):(s[wi]&&n.push("audio"),s[Di]&&n.push("video"));0===n.length&&this.log(`Fragments must have at least one ElementaryStreamType set. ${i.type} ${i.level} ${r?`part: ${r.index} of `:""}sn: ${i.sn}`),this.blockBuffers(()=>{let e=self.performance.now();i.stats.buffering.end=e,r&&(r.stats.buffering.end=e);let t=r?r.stats:i.stats;this.checkAppendProgress(i,r,a,n),this.hls&&(this.hls.trigger(Ai.FRAG_BUFFERED,{frag:i,part:r,stats:t,id:i.type,chunkMeta:a}),!r&&i.gap&&t.retry&&this.log(`Nothing buffered for ${i.type} level: ${i.level} sn: ${i.sn} retries ${t.retry}`))},n).catch(e=>{this.warn(`Fragment buffered callback ${e.message}`),this.stepOperationQueue(this.sourceBufferTypes)})}onFragChanged(e,t){var i,r;let a=null==(i=this.hls)?void 0:i.config;if(!a)return;let{backBufferLength:n,frontBufferFlushThreshold:s}=a;this.trimBuffers(s,n,t.frag,t.previousFrag);let o=t.frag.elementaryStreams,{appendErrors:l}=this,d=null==(r=this.appendError)?void 0:r.sourceBufferName;Object.keys(o).forEach(e=>{o[e]&&(l[e]=0,e===d&&(this.appendError=void 0),"audio"===e||"video"===e?(l.audiovideo=0,"audiovideo"===d&&(this.appendError=void 0)):(l.audio=0,l.video=0,"audiovideo"!==d&&(this.appendError=void 0)))})}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=!1!==(null==(i=this.overrides)?void 0:i.endOfStream);this.sourceBufferCount>0&&!this.sourceBuffers.some(([e])=>{var t;return e&&!(null!=(t=this.tracks[e])&&t.ended)})?(this.unblockAudio(),r?(this.log("Queueing EOS"),this.blockUntilOpen(()=>{this.tracksEnded();let{mediaSource:e}=this;"open"===(null==e?void 0:e.readyState)?(this.log("Calling mediaSource.endOfStream()"),e.endOfStream(),this.hls.trigger(Ai.BUFFERED_TO_END,void 0)):e&&this.log(`Could not call mediaSource.endOfStream(). mediaSource.readyState: ${e.readyState}`)})):(this.tracksEnded(),this.hls.trigger(Ai.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===Ti.BUFFER_APPEND_ERROR&&t.frag){var i;let e=null==(i=t.errorAction)?void 0:i.nextAutoLevel;vi(e)&&e!==t.frag.level&&this.resetAppendErrors()}}getBackBufferEvictionTarget(e,t,i){let{media:r}=this;return r?this.fragmentTracker.getBackBufferEvictionEnd(r.currentTime,i,t):0}getFragmentAppendProgress(e){var t;let i=pd(e),r=this.fragmentAppendProgress[i];return(null==(t=r)?void 0:t.stats)!==e.stats&&(r={stats:e.stats,progressed:!1,errored:!1,fullyBuffered:Object.create(null)},this.fragmentAppendProgress[i]=r),r}checkAppendProgress(e,t,i,r){if(t||!Pi(e)||e.gap||i.iframe||i.partial)return;let a=pd(e),n=this.fragmentAppendProgress[a];delete this.fragmentAppendProgress[a];let s=e.stats.buffering;if(s.start&&!s.first)return;let o=(null==n?void 0:n.stats)===e.stats?n:void 0;if(null!=o&&o.errored)return;let l=r.length>0&&r.every(e=>!0===(null==o?void 0:o.fullyBuffered[e]));if(null!=o&&o.progressed||l)return void delete this.appendsWithoutProgress[a];if(!o&&0===r.length)return;let d=(this.appendsWithoutProgress[a]||0)+1,u=this.hls;d>=u.config.appendErrorMaxRetry?delete this.appendsWithoutProgress[a]:this.appendsWithoutProgress[a]=d,this.warn(`Fragment ${e.sn} of ${e.type} playlist ${e.level} appended ${d} time${d>1?"s":""} without buffered range growth`),u.trigger(Ai.ERROR,{type:bi.MEDIA_ERROR,details:Ti.BUFFER_APPEND_NO_PROGRESS,fatal:!1,frag:e,chunkMeta:i,parent:e.type,appendsWithoutProgress:d,error:new Error(`Fragment append did not increase buffered coverage (${d})`)})}resetAppendProgress(){this.fragmentAppendProgress=Object.create(null),this.appendsWithoutProgress=Object.create(null)}resetAppendErrors(){this.appendErrors={audio:0,video:0,audiovideo:0},this.appendError=void 0}trimBuffers(e,t,i,r){let{hls:a,details:n,media:s}=this;if(!s||null===n||!this.sourceBufferCount)return;let o=a.config,l=s.currentTime,d=n.levelTargetDuration;t=n.live&&null!==o.liveBackBufferLength?o.liveBackBufferLength:t;let u=-1/0;if(vi(t)&&t>=0){let e=Math.max(t,d);u=Math.floor(l/d)*d-e}if(i){let e=this.getLoopBackBufferFlushEnd(i,null!=r?r:null);e>0&&(u=Math.max(u,e))}if(u>0&&this.flushBackBuffer(l,d,u),vi(e)&&e>0){let t=Math.max(o.maxBufferLength,e),i=Math.max(t,d),r=Math.floor(l/d)*d+i;this.flushFrontBuffer(l,d,r)}}getLoopBackBufferFlushEnd(e,t){var i;let{media:r}=this;if(!1===(null==(i=this.hls)?void 0:i.config.loopBackBufferFlush)||null==r||!r.loop||!t||e.level<=t.level)return 0;let{video:a,audiovideo:n}=e.elementaryStreams;if(null!=a&&a.partial||null!=n&&n.partial)return 0;let s=this.getEarliestElementaryStreamStart(e)-.25;return s<=0?0:(this.log(`Flushing lower quality back buffer for loop: level ${e.level}, range [0-${s.toFixed(3)}]`),s)}getEarliestElementaryStreamStart(e){let{audio:t,video:i,audiovideo:r}=e.elementaryStreams,a=e.start;return r?a=Math.min(a,r.startDTS):(t&&(a=Math.min(a,t.startDTS)),i&&(a=Math.min(a,i.startDTS))),a}flushBackBuffer(e,t,i){this.sourceBuffers.forEach(([e,t])=>{if(t){let s=ts.getBuffered(t);if(s.length>0&&i>s.start(0)){var r,a,n;this.hls.trigger(Ai.BACK_BUFFER_REACHED,{bufferEnd:i});let t=this.tracks[e];if(null!=(r=this.details)&&r.live)this.hls.trigger(Ai.LIVE_BACK_BUFFER_REACHED,{bufferEnd:i});else if(null!=t&&t.ended&&(null==(a=this.media)||!a.loop||!1===(null==(n=this.hls)?void 0:n.config.loopBackBufferFlush)))return void this.log(`Cannot flush ${e} back buffer while SourceBuffer is in ended state`);this.hls.trigger(Ai.BUFFER_FLUSHING,{startOffset:0,endOffset:i,type:e})}}})}flushFrontBuffer(e,t,i){this.sourceBuffers.forEach(([t,r])=>{if(r){let a=ts.getBuffered(r),n=a.length;if(n<2)return;let s=a.start(n-1),o=a.end(n-1);if(i>s||e>=s&&e<=o)return;this.hls.trigger(Ai.BUFFER_FLUSHING,{startOffset:s,endOffset:1/0,type:t})}})}getDurationAndRange(){var e;let{details:t,mediaSource:i}=this;if(!t||!this.media||"open"!==(null==i?void 0:i.readyState))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);return{duration:1/0,start:e,end:Math.max(e,r)}}return{duration:1/0}}let a=null==(e=this.overrides)?void 0:e.duration;if(a)return vi(a)?{duration:a}:null;let n=this.media.duration;return r>(vi(i.duration)?i.duration:0)&&r>n||!vi(n)?{duration:r}:null}updateMediaSource({duration:e,start:t,end:i}){let r=this.mediaSource;!r||!this.media||"open"!==r.readyState||(r.duration!==e&&(vi(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}) ${tn(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(Ai.BUFFER_CREATED,{tracks:e}),this.log(`SourceBuffers created. Running queue: ${this.operationQueue}`),this.sourceBuffers.forEach(([e])=>{this.executeNext(e)})}else{let e=new Error("could not create source buffer for media codec(s)");this.hls.trigger(Ai.ERROR,{type:bi.MEDIA_ERROR,details:Ti.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:e,reason:e.message})}}createSourceBuffers(){let{tracks:e,sourceBuffers:t,mediaSource:i}=this;if(!i)throw new Error("createSourceBuffers called when mediaSource was null");for(let a in e){let n=a,s=e[n];if(this.isPending(s)){let e=this.getTrackCodec(s,n),a=`${s.container};codecs=${e}`;s.codec=e,this.log(`creating sourceBuffer(${a})${this.currentOp(n)?" Queued":""} ${tn(s)}`);try{let e=i.addSourceBuffer(a),r=md(n),o=[n,e];t[r]=o,s.buffer=e}catch(e){var r;return this.error(`error while trying to add sourceBuffer: ${e.message}`),this.shiftAndExecuteNext(n),null==(r=this.operationQueue)||r.removeBlockers(),delete this.tracks[n],void this.hls.trigger(Ai.ERROR,{type:bi.MEDIA_ERROR,details:Ti.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:e,sourceBufferName:n,mimeType:a,parent:s.id})}this.trackSourceBuffer(n,s)}}this.bufferCreated()}clearBufferAppendTimeoutId(e){e&&(self.clearTimeout(e.bufferAppendTimeoutId),e.bufferAppendTimeoutId=void 0)}getTrackCodec(e,t){let i=e.supplemental,r=e.codec;i&&("video"===t||"audiovideo"===t)&&Sa(i,"video")&&(r=function(e,t){let i=[];if(e){let t=e.split(",");for(let e=0;e<t.length;e++)_a(t[e],"video")||i.push(t[e])}return t&&i.push(t),i.join(",")}(r,i));let a=Ma(r,e.levelCodec);return a?"audio"===t.slice(0,5)?Ca(a,this.appendSource):a:""}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.log(`${e} buffer removed ${yo(i)}`),this.hls.trigger(Ai.BUFFER_FLUSHED,{type:e,start:i.start(0),end:i.end(i.length-1)}))})}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,i;if("closed"===(null==(t=this.mediaSource)?void 0:t.readyState))return void this.resetBuffer(e);let r=this.currentOp(e);return r?(r.onComplete(),(null==(i=this.tracks[e])||null==(i=i.buffer)?void 0:i.updating)?(this.log(`${e} SourceBuffer updating on "updateend"`),void this.blockUntilOpen(()=>{this.shiftAndExecuteNext(e)})):void this.shiftAndExecuteNext(e)):void 0}onSBUpdateError(e,t){var i;let r=null==(i=this.mediaSource)?void 0:i.readyState,a=new Error(`${e} SourceBuffer error. MediaSource readyState: ${r}`);this.error(`${a.message}`,t),this.hls.trigger(Ai.ERROR,{type:bi.MEDIA_ERROR,details:Ti.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:a,fatal:!1});let n=this.currentOp(e);n&&n.onError(a)}updateTimestampOffset(e,t,i,r,a,n){let s=t-e.timestampOffset;Math.abs(s)>=i&&(this.log(`Updating ${r} SourceBuffer timestampOffset to ${t} (sn: ${a} cc: ${n})`),e.timestampOffset=t)}removeExecutor(e,t,i){let{media:r,mediaSource:a}=this,n=this.tracks[e],s=null==n?void 0:n.buffer;if(!r||!a||!s)throw new Error(`Attempting to remove from the ${e} SourceBuffer, but it does not exist`);let o=vi(r.duration)?r.duration:1/0,l=vi(a.duration)?a.duration:1/0,d=Math.max(0,t);var u;if(d>=l)return null==(u=this.currentOp(e))||u.onComplete(),void this.shiftAndExecuteNext(e);let h=Math.min(i,o,l);if(!(h>d)||n.ending&&!n.ended)throw new Error(`Cannot remove ${h<=d?`invalid range (${d} >= ${h}) `:""}from the ${e} SourceBuffer${n.ending?" while track ending":""}`);n.ended=!1,this.log(`Removing [${d},${h}] from the ${e} SourceBuffer`),s.remove(d,h)}appendExecutor(e,t){let i=this.tracks[t],r=null==i?void 0:i.buffer;if(!r)throw new hd(`Attempting to append to the ${t} SourceBuffer, but it does not exist`);if(i.ending=!1,i.ended=!1,this.hls.config.appendTimeout!==1/0){let e=this.calculateAppendTimeoutTime(r);i.bufferAppendTimeoutId=self.setTimeout(()=>this.appendTimeoutHandler(t,r,e),e)}r.appendBuffer(e)}appendTimeoutHandler(e,t,i){this.log(`Received timeout after ${i}ms for append on ${e} source buffer. Aborting and triggering error.`);try{t.abort()}catch{this.log(`Failed to abort append on ${e} source buffer after timeout.`)}let r=this.currentOp(e);r&&r.onError(new Error(`${e}-append-timeout`))}calculateAppendTimeoutTime(e){let t=10;this.details&&(t=this.details.levelTargetDuration);let i=2*t*1e3;if(null===this.media)return i;let r=ts.bufferInfo(e,this.media.currentTime,0);return r.len?(i=Math.max(1e3*r.len,i),Math.max(this.hls.config.appendTimeout,i)):i}blockUntilOpen(e){if(this.isUpdating()||this.isQueued())this.blockBuffers(e).catch(e=>{this.warn(`SourceBuffer blocked callback ${e}`),this.stepOperationQueue(this.sourceBufferTypes)});else try{e()}catch(e){this.warn(`Callback run without blocking ${this.operationQueue} ${e}`)}}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}isAudioBlocked(){var e;return"block-audio"===(null==(e=this.currentOp("audio"))?void 0:e.label)}isAudioBlocking(){return!!this.operationQueue&&this.operationQueue.audioBlocking()}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=2===t.length&&this.isAudioBlocking()?[this.appendBlocker("video")]:t.map(e=>this.appendBlocker(e));return 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||"audio"===e&&this.isAudioBlocked()||this.shiftAndExecuteNext(e)})}append(e,t,i){this.operationQueue&&this.operationQueue.append(e,t,i)}insertNext(e,t){this.operationQueue&&this.operationQueue.insertNext(e,t)}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])?1:0),0)}get sourceBufferCount(){return this.sourceBuffers.reduce((e,[t])=>e+(t?1:0),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 a=r.buffer;if(!a)return;let n=i.bind(this,e);r.listeners.push({event:t,listener:n}),vo(a,t,n)}removeBufferListeners(e){let t=this.tracks[e];if(!t)return;let i=t.buffer;i&&(t.listeners.forEach(e=>{Eo(i,e.event,e.listener)}),t.listeners.length=0)}},capLevelController:Ed,errorController:class extends tr{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(Ai.ERROR,this.onError,this),e.on(Ai.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Ai.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){let e=this.hls;e&&(e.off(Ai.ERROR,this.onError,this),e.off(Ai.ERROR,this.onErrorOut,this),e.off(Ai.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Ai.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)===Li.MAIN?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;if(t.fatal)return;let r=this.hls,a=t.context;switch(t.details){case Ti.FRAG_LOAD_ERROR:case Ti.FRAG_LOAD_TIMEOUT:case Ti.KEY_LOAD_ERROR:case Ti.KEY_LOAD_TIMEOUT:return void(t.errorAction=this.getFragRetryOrSwitchAction(t));case Ti.FRAG_PARSING_ERROR:if(null!=(i=t.frag)&&i.gap)return void(t.errorAction=Cn());case Ti.FRAG_GAP:case Ti.FRAG_DECRYPT_ERROR:return t.errorAction=this.getFragRetryOrSwitchAction(t),void(t.errorAction.action=bn);case Ti.PLAYLIST_UNCHANGED_ERROR:case Ti.LEVEL_EMPTY_ERROR:case Ti.LEVEL_PARSING_ERROR:{var n;let e=t.parent===Li.MAIN?t.level:r.loadLevel;t.details===Ti.LEVEL_EMPTY_ERROR&&null!=(n=t.context)&&null!=(n=n.levelDetails)&&n.live?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,e):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,e))}return;case Ti.LEVEL_LOAD_ERROR:case Ti.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==a?void 0:a.level)&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,a.level)));case Ti.AUDIO_TRACK_LOAD_ERROR:case Ti.AUDIO_TRACK_LOAD_TIMEOUT:case Ti.SUBTITLE_LOAD_ERROR:case Ti.SUBTITLE_TRACK_LOAD_TIMEOUT:if(a){let e=r.loadLevelObj;if(e&&(a.type===Ri.AUDIO_TRACK&&e.hasAudioGroup(a.groupId)||a.type===Ri.SUBTITLE_TRACK&&e.hasSubtitleGroup(a.groupId)))return t.errorAction=this.getPlaylistRetryOrSwitchAction(t,r.loadLevel),t.errorAction.action=bn,void(t.errorAction.flags=Sn)}return;case Ti.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:return void(t.errorAction={action:bn,flags:kn});case Ti.KEY_SYSTEM_SESSION_UPDATE_FAILED:case Ti.KEY_SYSTEM_STATUS_INTERNAL_ERROR:case Ti.KEY_SYSTEM_NO_SESSION:return void(t.errorAction={action:bn,flags:In});case Ti.BUFFER_ADD_CODEC_ERROR:case Ti.REMUX_ALLOC_ERROR:case Ti.BUFFER_APPEND_ERROR:return void(t.errorAction||(t.errorAction=this.getLevelSwitchAction(t,t.level)));case Ti.MEDIA_SOURCE_REQUIRES_RESET:return t.errorAction||(t.errorAction=this.getLevelSwitchAction(t,t.level)),void(t.errorAction.flags|=Ln|Rn);case Ti.INTERNAL_EXCEPTION:case Ti.BUFFER_APPENDING_ERROR:case Ti.BUFFER_APPEND_NO_PROGRESS:case Ti.BUFFER_FULL_ERROR:case Ti.LEVEL_SWITCH_ERROR:case Ti.BUFFER_STALLED_ERROR:case Ti.BUFFER_SEEK_OVER_HOLE:case Ti.BUFFER_NUDGE_ON_STALL:return void(t.errorAction=Cn())}t.type===bi.KEY_SYSTEM_ERROR&&(t.levelRetry=!1,t.errorAction=Cn())}getPlaylistRetryOrSwitchAction(e,t){let i=Yi(this.hls.config.playlistLoadPolicy,e),r=this.playlistError++;if(Qi(i,r,Wi(e),e.response))return{action:An,flags:_n,retryConfig:i,retryCount:r};let a=this.getLevelSwitchAction(e,t);return i&&(a.retryConfig=i,a.retryCount=r),a}getFragRetryOrSwitchAction(e){let t=this.hls,i=this.getVariantLevelIndex(e.frag),r=t.levels[i],{fragLoadPolicy:a,keyLoadPolicy:n}=t.config,s=Yi(Vi(e)?n:a,e),o=t.levels.reduce((e,t)=>e+t.fragmentError,0);if(r&&(e.details!==Ti.FRAG_GAP&&r.fragmentError++,!qi(e)&&Qi(s,o,Wi(e),e.response)))return{action:An,flags:_n,retryConfig:s,retryCount:o};let l=this.getLevelSwitchAction(e,i);return s&&(l.retryConfig=s,l.retryCount=o),l}getLevelSwitchAction(e,t){let i=this.hls;null==t&&(t=i.loadLevel);let r=this.hls.levels[t];if(r){var a,n;let t=e.details;r.loadError++,r.loadErrorTime=self.performance.now(),t===Ti.BUFFER_APPEND_ERROR&&r.fragmentError++;let l=-1,{levels:d,loadLevel:u,minAutoLevel:h,maxAutoLevel:c}=i;!i.autoLevelEnabled&&!i.config.preserveManualLevelOnError&&(i.loadLevel=-1);let m=null==(a=e.frag)?void 0:a.type,f=(m===Li.AUDIO&&t===Ti.FRAG_PARSING_ERROR||"audio"===e.sourceBufferName&&wn(e))&&d.some(({audioCodec:e})=>r.audioCodec!==e),p="video"===e.sourceBufferName&&wn(e)&&d.some(({codecSet:e,audioCodec:t})=>r.codecSet!==e&&r.audioCodec===t),{type:g,groupId:v}=null!=(n=e.context)?n:{};for(let a=d.length;a--;){let n=(a+u)%d.length;if(n!==u&&n>=h&&n<=c&&(0===d[n].loadError||Zi(d[n],i.config.errorPenaltyExpireMs))){var s,o;let i=d[n];if(t===Ti.FRAG_GAP&&m===Li.MAIN&&e.frag){let t=d[n].details;if(t){let i=fn(e.frag,t.fragments,e.frag.start);if(null!=i&&i.gap)continue}}else{if(g===Ri.AUDIO_TRACK&&i.hasAudioGroup(v)||g===Ri.SUBTITLE_TRACK&&i.hasSubtitleGroup(v))continue;if(m===Li.AUDIO&&null!=(s=r.audioGroups)&&s.some(e=>i.hasAudioGroup(e))||m===Li.SUBTITLE&&null!=(o=r.subtitleGroups)&&o.some(e=>i.hasSubtitleGroup(e))||f&&r.audioCodec===i.audioCodec||p&&r.codecSet===i.codecSet||!f&&r.audioCodec!==i.audioCodec)continue}l=n;break}}if(l>-1&&i.loadLevel!==l)return e.levelRetry=!0,this.playlistError=0,{action:bn,flags:_n,nextAutoLevel:l}}return{action:bn,flags:Sn}}onErrorOut(e,t){var i,r;switch(null==(i=t.errorAction)?void 0:i.action){case yn:break;case bn:this.sendAlternateToPenaltyBox(t),!t.errorAction.resolved&&t.details!==Ti.FRAG_GAP&&t.details!==Ti.PLAYLIST_UNCHANGED_ERROR&&!Dn(t)&&(t.fatal=!0)}((null==(r=t.errorAction)?void 0:r.flags)||0)&Ln&&this.hls.recoverMediaError(),t.fatal&&this.hls.stopLoad()}sendAlternateToPenaltyBox(e){let t=this.hls,i=e.errorAction;if(!i)return;let r=i.nextAutoLevel;if(i.flags===_n)this.switchLevel(e,r);else if(i.flags&Rn){let e=this.hls.levels;for(let t=e.length;t--;)"SDR"!==e[t].videoRange?(e[t].fragmentError++,e[t].loadError++):void 0===r&&(r=t)}else if(i.flags&kn){let r=this.getVariantLevelIndex(e.frag),a=t.levels[r],n=null==a?void 0:a.attrs["HDCP-LEVEL"];i.hdcpLevel=n;let s="NONE"===n;n&&!s?(t.maxHdcpLevel=Va[Va.indexOf(n)-1],i.resolved=!0,this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`)):(s&&this.warn("HDCP policy resticted output with HDCP-LEVEL=NONE"),i.flags|=In)}if(i.flags&In){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) ${Dr(t.keyId||[])}`),r[i].fragmentError++,r[i].loadError++,this.log(`Removing level ${i} with key error (${e.error})`),this.hls.removeLevel(i)}let o=e.frag;if(this.hls.levels.length<s)i.resolved=!0;else if(o&&o.type!==Li.MAIN){let e=o.decryptdata;e&&!t.matches(e)&&(i.resolved=!0)}}}i.resolved||this.switchLevel(e,r)}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===Ti.BUFFER_ADD_CODEC_ERROR&&e.mimeType&&"audiovideo"!==e.sourceBufferName)){let t=Na(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}registerListeners(){this.hls.on(Ai.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.on(Ai.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListeners(){this.hls.off(Ai.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off(Ai.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,a=i-this.lastDroppedFrames,n=t-this.lastDecodedFrames,s=1e3*a/e,o=this.hls;if(o.trigger(Ai.FPS_DROP,{currentDropped:a,currentDecoded:n,totalDroppedFrames:i}),s>0&&a>o.config.fpsDroppedMonitoringThreshold*n){let e=o.currentLevel;o.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+e),e>0&&(-1===o.autoLevelCapping||o.autoLevelCapping>=e)&&(e-=1,o.trigger(Ai.FPS_DROP_LEVEL_CAPPING,{level:e,droppedLevel:o.currentLevel}),o.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)}},id3TrackController:class{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(Ai.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;e&&(e.on(Ai.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(Ai.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Ai.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Ai.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Ai.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(Ai.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(Ai.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(Ai.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}_unregisterListeners(){let{hls:e}=this;e&&(e.off(Ai.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(Ai.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Ai.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Ai.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Ai.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(Ai.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(Ai.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(Ai.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}onMediaAttaching(e,t){this.media=t.media}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.id3Track.remove(),this.id3Track=null),this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(e){return Fh(e,"metadata","id3","","hidden")}onFragParsingMetadata(e,t){if(!this.media||!this.hls)return;let{enableEmsgMetadataCues:i,enableID3MetadataCues:r}=this.hls.config;if(!i&&!r)return;let{samples:a}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));let n=qh();if(n)for(let e=0;e<a.length;e++){let t=a[e].type;if(t===Qo.emsg&&!i||!r)continue;let s=Ir(a[e].data),o=a[e].pts,l=o+a[e].duration;l>jh&&(l=jh),l-o<=0&&(l=o+.25);for(let e=0;e<s.length;e++){let i=s[e];if(!Rr(i)){this.updateId3CueEnds(o,t);let e=Yh(n,o,l,i,t);e&&this.id3Track.track.addCue(e)}}}}updateId3CueEnds(e,t){var i;let r=null==(i=this.id3Track)?void 0:i.track.cues;if(r)for(let i=r.length;i--;){let a=r[i];a.type===t&&a.startTime<e&&a.endTime===jh&&(a.endTime=e)}}onBufferFlushing(e,{startOffset:t,endOffset:i,type:r}){let{id3Track:a,hls:n}=this;if(!n)return;let{config:{enableEmsgMetadataCues:s,enableID3MetadataCues:o}}=n;if(a&&(s||o)){let e;e="audio"===r?e=>e.type===Qo.audioId3&&o:"video"===r?e=>e.type===Qo.emsg&&s:e=>e.type===Qo.audioId3&&o||e.type===Qo.emsg&&s,Hh(a.track,t,i,e)}}onLevelUpdated(e,{details:t}){this.updateDateRangeCues(t,!0)}onLevelPtsUpdated(e,t){Math.abs(t.drift)>.01&&this.updateDateRangeCues(t.details)}updateDateRangeCues(e,t){if(!this.hls||!this.media)return;let{assetPlayerId:i,timelineOffset:r,enableDateRangeMetadataCues:a,interstitialsController:n}=this.hls.config;if(!a)return;let s=qh();if(i&&r&&!n){let{fragmentStart:t,fragmentEnd:r}=e,a=this.assetCue;a?(a.startTime=t,a.endTime=r):s&&(a=this.assetCue=Yh(s,t,r,{assetPlayerId:this.hls.config.assetPlayerId},"hlsjs.interstitial.asset"),a&&(a.id=i,this.id3Track||(this.id3Track=this.createTrack(this.media)),this.id3Track.track.addCue(a),a.addEventListener("enter",this.onEventCueEnter)))}if(!e.hasProgramDateTime)return;let{id3Track:o}=this,{dateRanges:l}=e,d=Object.keys(l),u=this.dateRangeCuesAppended;var h;if(o&&t)if(null!=(h=o.track.cues)&&h.length){let e=Object.keys(u).filter(e=>-1===d.indexOf(e));for(let t=e.length;t--;){var c;let i=e[t],r=null==(c=u[i])?void 0:c.cues;delete u[i],r&&Object.keys(r).forEach(e=>{let t=r[e];if(t){t.removeEventListener("enter",this.onEventCueEnter);try{o.track.removeCue(t)}catch{}}})}}else u=this.dateRangeCuesAppended={};let m=e.fragments[e.fragments.length-1];if(0!==d.length&&vi(null==m?void 0:m.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(let e=0;e<d.length;e++){let t=d[e],i=l[t],r=i.startTime,a=u[t],o=(null==a?void 0:a.cues)||{},h=(null==a?void 0:a.durationKnown)||!1,c=jh,{duration:m,endDate:f}=i;if(f&&null!==m)c=r+m,h=!0;else if(i.endOnNext&&!h){let e=d.reduce((e,t)=>{if(t!==i.id){let r=l[t];if(r.class===i.class&&r.startDate>i.startDate&&(!e||i.startDate<e.startDate))return r}return e},null);e&&(c=e.startTime,h=!0)}let p=Object.keys(i.attr);for(let e=0;e<p.length;e++){let l=p[e];if(!us(l))continue;let d=o[l];if(d)!h||null!=a&&a.durationKnown?Math.abs(d.startTime-r)>.01&&(d.startTime=r,d.endTime=c):d.endTime=c;else if(s){let e=i.attr[l];hs(l)&&(e=Cr(e));let a=Yh(s,r,c,{key:l,data:e},Qo.dateRange);a&&(a.id=t,this.id3Track.track.addCue(a),o[l]=a,n&&("X-ASSET-LIST"===l||"X-ASSET-URL"===l)&&a.addEventListener("enter",this.onEventCueEnter))}}u[t]={cues:o,dateRange:i,durationKnown:h}}}}},gapController:class extends Zn{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.skipRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.buffered={},this.lastCurrentTime=void 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=()=>{var e;this.hls&&(this.ended=(null==(e=this.media)?void 0:e.currentTime)||1,this.hls.trigger(Ai.MEDIA_ENDED,{stalled:!1}))},this.hls=e,this.fragmentTracker=t,this.lastCurrentTime=this.getCurrentTime(),this.registerListeners()}registerListeners(){let{hls:e}=this;e&&(e.on(Ai.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Ai.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Ai.BUFFER_APPENDED,this.onBufferAppended,this))}unregisterListeners(){let{hls:e}=this;e&&(e.off(Ai.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Ai.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Ai.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;vo(i,"playing",this.onMediaPlaying),vo(i,"waiting",this.onMediaWaiting),vo(i,"ended",this.onMediaEnded)}onMediaDetaching(e,t){this.clearInterval();let{media:i}=this;i&&(Eo(i,"playing",this.onMediaPlaying),Eo(i,"waiting",this.onMediaWaiting),Eo(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}getCurrentTime(){var e;let t=(null==(e=this.hls)?void 0:e.config.timelineOffset)||0;return this.media?Math.max(this.media.currentTime,t):t}tick(){var e;if(null==(e=this.media)||!e.readyState||!this.hasBuffered)return;let t=this.getCurrentTime();this.media.currentTime<t||(this.poll(t,this.lastCurrentTime),this.lastCurrentTime=t)}poll(e,t){var i,r;let a=null==(i=this.hls)?void 0:i.config;if(!a)return;let n=this.media;if(!n)return;let{seeking:s}=n,o=this.seeking&&!s,l=!this.seeking&&s,d=n.paused&&!s||n.ended||0===n.playbackRate;if(this.seeking=s,e!==t)return t&&(this.ended=0),this.moved=!0,s||(this.skipRetry=this.nudgeRetry=0,a.nudgeOnVideoHole&&!d&&e>t&&this.nudgeOnVideoHole(e,t)),void(0===this.waiting&&this.stallResolved(e));if(l||o)return void(o&&this.stallResolved(e));if(d)return this.skipRetry=this.nudgeRetry=0,this.stallResolved(e),void(!this.ended&&n.ended&&this.hls&&(this.ended=e||1,this.hls.trigger(Ai.MEDIA_ENDED,{stalled:!1})));if(!ts.getBuffered(n).length)return void(this.skipRetry=this.nudgeRetry=0);let u=ts.bufferInfo(n,e,0),h=this.fragmentTracker;h&&this.hls&&Vh(u,e,h,this.hls);let c=u.nextStart||0;if(s&&h&&this.hls){let t=Gh(this.hls.inFlightFragments,e),i=u.len>2,r=!c||t||c-e>2&&!h.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&&h){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=Wh(e,h);if(t>0&&(t<=i||r))return void(n.paused||this._trySkipBufferHole(r))}let f=a.detectStallWithCurrentTimeMs,p=self.performance.now(),g=this.waiting,v=this.stalled;if(null===v){if(!(g>0&&p-g<f))return void(this.stalled=p);v=this.stalled=g}let E=p-v;if(!s&&(E>=f||g&&this.moved)&&this.hls){var y;if("ended"===(null==(y=this.mediaSource)?void 0:y.readyState)&&(null==m||!m.live)&&Math.abs(e-((null==m?void 0:m.edge)||0))<1){if(this.ended)return;return this.ended=e||1,void this.hls.trigger(Ai.MEDIA_ENDED,{stalled:!0})}if(this._reportStall(u),!this.media||!this.hls)return;if(n.currentTime!==e){let t=e;return e=n.currentTime,this.moved=!0,void this.log(`currentTime changed ${t} > ${e}`)}}let b=ts.bufferInfo(n,e,a.maxBufferHole);this._tryFixBufferStall(b,E,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(Ai.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=ts.bufferedInfo(ts.timeRangesToArray(this.buffered.audio),e,0);if(i.len>1&&t>=i.start){let i=ts.timeRangesToArray(r),a=ts.bufferedInfo(i,t,0).bufferedIndex;if(a>-1&&a<i.length-1){let t=ts.bufferedInfo(i,e,0).bufferedIndex,r=i[a].end,n=i[a+1].start;if((-1===t||t>a)&&n-r<1&&e-r<2){let i=new Error(`nudging playhead to flush pipeline after video hole. currentTime: ${e} hole: ${r} -> ${n} buffered index: ${t}`);this.warn(i.message),this.media.currentTime+=1e-6;let a=Wh(e,this.fragmentTracker);a&&"fragment"in a?a=a.fragment:a||(a=void 0);let s=ts.bufferInfo(this.media,e,0);this.hls.trigger(Ai.ERROR,{type:bi.MEDIA_ERROR,details:Ti.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:i,reason:i.message,frag:a,buffer:s.len,bufferInfo:s})}}}}}_tryFixBufferStall(e,t,i){var r,a;let{fragmentTracker:n,media:s}=this,o=null==(r=this.hls)?void 0:r.config;if(!s||!n||!o)return;let l=null==(a=this.hls)?void 0:a.latestLevelDetails,d=Wh(i,n);if((d||null!=l&&l.live&&i<l.fragmentStart)&&(this._trySkipBufferHole(d)||!this.media))return;let u=e.buffered,h=this.adjacentTraversal(e,i);(u&&u.length>1&&e.len>o.maxBufferHole||e.nextStart&&(e.nextStart-i<o.maxBufferHole||h))&&(t>1e3*o.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,Li.MAIN),a=i.getFragAtPos(r,Li.MAIN);if(e&&a)return a.sn-e.sn<2}return!1}_reportStall(e){let{hls:t,media:i,stallReported:r,stalled:a}=this;if(!r&&null!==a&&i&&t){this.stallReported=!0;let r=new Error(`Playback stalling at @${i.currentTime} due to low buffer (${tn(e)})`);this.warn(r.message),t.trigger(Ai.ERROR,{type:bi.MEDIA_ERROR,details:Ti.BUFFER_STALLED_ERROR,fatal:!1,error:r,buffer:e.len,bufferInfo:e,stalled:{start:a}})}}_trySkipBufferHole(e){let{fragmentTracker:t,media:i,hls:r}=this,a=null==r?void 0:r.config;if(!i||!t||!a)return 0;let n=i.currentTime,s=ts.bufferInfo(i,n,0);Vh(s,n,t,r);let o=n<s.start?s.start:s.nextStart;if(o){let d=s.len<=a.maxBufferHole,u=s.len>0&&s.len<1&&i.readyState<3,h=o-n;if(h>0&&(d||u)){if(h>a.maxBufferHole){let i=!1;if(0===n){let e=t.getAppendedFrag(0,Li.MAIN);e&&o<e.end&&(i=!0)}if(!i&&e){var l;if(null==(l=r.loadLevelObj)||!l.details||Gh(r.inFlightFragments,o))return 0;let i=!1,a=e.end;for(;a<o;){let e=Wh(a,t),r=e?e.duration:0;if(!(r>0)){i=!0;break}a+=r}if(i)return 0}}let{nudgeMaxRetry:d,skipBufferHolePadding:u}=a,c=++this.skipRetry>d,m=Math.max(o,n)+u;if(c||(this.warn(`skipping hole, adjusting currentTime from ${n} to ${m}`),this.moved=!0,i.currentTime=m),null==e||!e.gap||c){let t=new Error(c?`Playhead still not moving after seeking over buffer hole from ${n} to ${m} after ${a.nudgeMaxRetry} attempts.`:`fragment loaded with buffer holes, seeking from ${n} to ${m}`),i={type:bi.MEDIA_ERROR,details:Ti.BUFFER_SEEK_OVER_HOLE,fatal:c,error:t,reason:t.message,buffer:s.len,bufferInfo:s};e&&("fragment"in e?i.part=e:i.frag=e),r.trigger(Ai.ERROR,i)}return m}}return 0}_tryNudgeBuffer(e){let{hls:t,media:i,nudgeRetry:r}=this,a=null==t?void 0:t.config;if(!i||!a)return 0;let n=i.currentTime;if(this.nudgeRetry++,r<a.nudgeMaxRetry){let s=n+(r+1)*a.nudgeOffset,o=new Error(`Nudging 'currentTime' from ${n} to ${s}`);this.warn(o.message),i.currentTime=s,t.trigger(Ai.ERROR,{type:bi.MEDIA_ERROR,details:Ti.BUFFER_NUDGE_ON_STALL,error:o,fatal:!1,buffer:e.len,bufferInfo:e})}else{let i=new Error(`Playhead still not moving while enough data buffered @${n} after ${a.nudgeMaxRetry} nudges`);this.error(i.message),t.trigger(Ai.ERROR,{type:bi.MEDIA_ERROR,details:Ti.BUFFER_STALLED_ERROR,error:i,fatal:!0,buffer:e.len,bufferInfo:e})}}},latencyController:class{constructor(e){this.hls=void 0,this.media=null,this.currentTime=0,this.stallCount=0,this._latency=null,this._targetLatencyUpdated=!1,this.onTimeupdate=()=>{var e;let{media:t}=this,i=this.levelDetails;if(!t||!i||!this.hls)return;this.currentTime=t.currentTime;let r=this.hls.config,a=this.computeLatency();if(null===a)return;this._latency=a;let{lowLatencyMode:n,maxLiveSyncPlaybackRate:s}=r;if(!n||1===s||!i.live)return;let o=this.targetLatency;if(null===o)return;let l=a-o,d=l<Math.min(this.maxLatency,o+i.targetduration),u=xo(r)&&!(null==(e=this.hls.interstitialsManager)||null==(e=e.playingItem)||!e.event);if(d&&l>.05&&this.forwardBufferLength>1&&!u){let e=Math.min(2,Math.max(1,s)),i=Math.round(2/(1+Math.exp(-.75*l-this.edgeStalled))*20)/20,r=Math.min(e,Math.max(1,i));this.changeMediaPlaybackRate(t,r)}else 1!==t.playbackRate&&0!==t.playbackRate&&this.changeMediaPlaybackRate(t,1)},this.hls=e,this.registerListeners()}get levelDetails(){var e;return(null==(e=this.hls)?void 0:e.latestLevelDetails)||null}get latency(){return this._latency||0}get maxLatency(){var e;let t=null==(e=this.hls)?void 0:e.config;if(!t)return 0;if(void 0!==t.liveMaxLatencyDuration)return t.liveMaxLatencyDuration;let i=this.levelDetails;return i?t.liveMaxLatencyDurationCount*i.targetduration:0}get targetLatency(){let e=this.levelDetails;if(null===e||!this.hls)return null;let t=this.hls.config,{holdBack:i,partHoldBack:r,targetduration:a}=e,{liveSyncDuration:n,liveSyncDurationCount:s,lowLatencyMode:o}=t,l=this.hls.userConfig,d=o&&r||i;(this._targetLatencyUpdated||l.liveSyncDuration||l.liveSyncDurationCount||0===d)&&(d=void 0!==n?n:s*a);let u=a;return d+Math.min(this.stallCount*t.liveSyncOnStallIncrease,u)}set targetLatency(e){this.hls&&(this.stallCount=0,this.hls.config.liveSyncDuration=e,this._targetLatencyUpdated=!0)}get liveSyncPosition(){let e=this.estimateLiveEdge(),t=this.targetLatency;if(null===e||null===t||!this.hls)return null;let i=this.levelDetails;if(null===i)return null;let r=i.edge,a=e-t-this.edgeStalled,n=r-i.totalduration,s=r-(this.hls.config.lowLatencyMode&&i.partTarget||i.targetduration);return Math.min(Math.max(n,a),s)}get drift(){let e=this.levelDetails;return null===e?1:e.drift}get edgeStalled(){let e=this.levelDetails;if(null===e||!this.hls)return 0;let t=3*(this.hls.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;e&&(e.on(Ai.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Ai.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Ai.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Ai.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(Ai.ERROR,this.onError,this),e.on(Ai.INTERSTITIAL_ASSET_STARTED,this.onAssetStarted,this))}unregisterListeners(){let{hls:e}=this;e&&(e.off(Ai.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Ai.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Ai.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Ai.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(Ai.ERROR,this.onError,this),e.off(Ai.INTERSTITIAL_ASSET_STARTED,this.onAssetStarted,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)}onAssetStarted(e,t){var i;let r=this.hls,a=this.media||t.event.appendInPlace&&(null==r||null==(i=r.interstitialsManager)?void 0:i.playerQueue.reduce((e,t)=>e||t.media,null));r&&a&&a.playbackRate>1&&a.playbackRate<=r.config.maxLiveSyncPlaybackRate&&this.changeMediaPlaybackRate(a,1)}onError(e,t){var i;t.details===Ti.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}}},{cueHandler:Yc,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 Mo{constructor(e,t,i){super(e,t,i,"subtitle-stream-controller",Li.SUBTITLE),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(Ai.LEVEL_LOADED,this.onLevelLoaded,this),e.on(Ai.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(Ai.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(Ai.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(Ai.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(Ai.BUFFER_FLUSHING,this.onBufferFlushing,this)}unregisterListeners(){super.unregisterListeners();let{hls:e}=this;e.off(Ai.LEVEL_LOADED,this.onLevelLoaded,this),e.off(Ai.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(Ai.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(Ai.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(Ai.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(Ai.BUFFER_FLUSHING,this.onBufferFlushing,this)}startLoad(e,t){this.stopLoad(),this.state=To,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{frag:i,part:r,success:a}=t;if(!a)return;let n=this.tracksBuffered[this.currentTrackId];if(!n)return;let s,o=(r||i).start;for(let e=0;e<n.length;e++)if(o>=n[e].start&&o<=n[e].end){s=n[e];break}let l=o+(r||i).duration;if(s?s.end=l:(s={start:o,end:l},n.push(s)),!r||l>=i.end){let e=this.fragmentTracker.fragBuffered(i);r&&e&&(e.range.subs={time:[{startPTS:i.start,endPTS:l}],partial:!0}),Pi(i)&&!this.fragContextChanged(i)&&(this.fragPrevious=i),this.fragBufferedComplete(i,r),this.media&&this.tickImmediate()}}onBufferFlushing(e,t){let{startOffset:i,endOffset:r}=t;if(0===i&&r!==Number.POSITIVE_INFINITY){let e=r-1;if(e<=0)return;t.endOffsetSubtitles=Math.max(0,e),this.tracksBuffered.forEach(t=>{if(t)for(let i=0;i<t.length;)if(t[i].end<=e)t.shift();else{if(!(t[i].start<e))break;t[i].start=e,i++}}),this.fragmentTracker.removeFragmentsInRange(i,e,Li.SUBTITLE)}}onError(e,t){let i=t.frag;(null==i?void 0:i.type)===Li.SUBTITLE&&(t.details===Ti.FRAG_GAP&&this.fragmentTracker.addAsGap(i),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==bo&&(this.state=To))}onSubtitleTracksUpdated(e,{subtitleTracks:t}){this.levels&&sd(this.levels,t)?this.levels=t.map(e=>new Za(e)):(this.tracksBuffered=[],this.levels=t.map(e=>{let t=new Za(e);return this.tracksBuffered[t.id]=[],t}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,Li.SUBTITLE),this.fragPrevious=null,this.mediaBuffer=null)}onSubtitleTrackSwitch(e,t){var i;if(this.currentTrackId=t.id,this.abortCurrentFrag(),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.state!==bo&&this.setInterval(500)):this.mediaBuffer=null}onSubtitleTrackLoaded(e,t){var i;let{currentTrackId:r,levels:a}=this,{details:n,id:s}=t;if(!a)return void this.warn(`Subtitle tracks were reset while loading level ${s}`);let o=a[s];if(s>=a.length||!o)return;this.log(`Subtitle track ${s} loaded [${n.startSN},${n.endSN}]${n.lastPartSn?`[part-${n.lastPartSn}-${n.lastPartIndex}]`:""},duration:${n.totalduration}`),this.mediaBuffer=this.mediaBufferTimeRanges;let l=this.mainDetails,d=0;if(n.live||null!=(i=o.details)&&i.live){if(n.deltaUpdateFailed)return;if(!l)return void(this.startFragRequested=!1);var u;if(o.details)d=this.alignPlaylists(n,o.details,null==(u=this.levelLastLoaded)?void 0:u.details);n.alignedSliding||(go(l,n,this),d=n.fragmentStart)}o.details=n,this.levelLastLoaded=o,l&&!this.startFragRequested&&this.setStartPosition(l,d),s===r&&(this.hls.trigger(Ai.SUBTITLE_TRACK_UPDATED,{details:n,id:s,groupId:t.groupId}),this.tickImmediate())}_handleFragmentLoadProgress(e){let{frag:t,part:i,payload:r}=e;!i||null==r||!r.byteLength||!this.shouldDecrypt(t)||this.decryptPayload(r,t,i)}_handleFragmentLoadComplete(e){let{frag:t,payload:i}=e;this.fragContextChanged(t)||null==i||!i.byteLength||!this.shouldDecrypt(t)||this.decryptPayload(i,t,null)}shouldDecrypt(e){let t=e.decryptdata;return!!(null!=t&&t.key&&t.iv&&gs(t.method))}decryptPayload(e,t,i){let r=t.decryptdata,a=performance.now();this.decrypter.decrypt(new Uint8Array(e),r.key.buffer,r.iv.buffer,vs(r.method)).then(e=>{this.fragContextChanged(t)||this.hls.trigger(Ai.FRAG_DECRYPTED,{frag:t,part:i,payload:e,stats:{tstart:a,tdecrypt:performance.now()}})}).catch(e=>{this.hls.trigger(Ai.ERROR,{type:bi.MEDIA_ERROR,details:Ti.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:t,part:i}),i||(this.warn(`${e.name}: ${e.message}`),this.state=To)})}doTick(){if(this.state===To&&this.levels){var e;if(!this.media&&!this.primaryPrefetch&&(this.startFragRequested||!this.config.startFragPrefetch))return;let{currentTrackId:i,levels:r}=this,a=r[i],n=null==a?void 0:a.details;if(!n||this.waitForLive(a)||this.waitForCdnTuneIn(n))return void(this.startFragRequested=!1);let{config:s}=this,o=this.playhead,l=ts.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],o,s.maxBufferHole),{end:d,len:u}=l;if(u>Math.max(this.hls.maxBufferLength+n.levelTargetDuration,(null==(e=this.hls.mainForwardBufferInfo)?void 0:e.len)||0)||u&&!this.buffering)return;let h=this.getNextFragment(d,n);if(!h)return;if(Pi(h)){var t;let e=h.sn-n.startSN,i=n.fragments[e-1];h.cc===(null==i?void 0:i.cc)&&(null==(t=n.partList)||!t.length)&&this.fragmentTracker.getState(i)===Mn&&(h=i)}this.loadFragment(h,a,d)}}loadFragment(e,t,i){let r=this.fragmentTracker.getState(e);(r===Mn||r===xn)&&super.loadFragment(e,t,i)}get mediaBufferTimeRanges(){return new _c(this.tracksBuffered[this.currentTrackId]||[])}},subtitleTrackController:class extends nd{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=-1,t=!1;if(this.currentTrack){var i;let r=null==(i=this.currentTrack.trackNode)?void 0:i.track.mode;"showing"===r?(e=this.trackId,t=!0):"hidden"===r&&(e=this.trackId)}if(!t)for(let t=0;t<this.tracksInGroup.length;t++){var r;let i=null==(r=this.tracksInGroup[t].trackNode)?void 0:r.track.mode;if("showing"===i){e=t;break}e<0&&"hidden"===i&&(e=t)}var a;e>-1&&(this._subtitleDisplay="showing"===(null==(a=this.tracksInGroup[e].trackNode)?void 0:a.track.mode));this.setSubtitleTrack(e,!0)},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(Ai.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Ai.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Ai.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Ai.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Ai.LEVEL_LOADING,this.onLevelLoading,this),e.on(Ai.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(Ai.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(Ai.ERROR,this.onError,this)}unregisterListeners(){let{hls:e}=this;e.off(Ai.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Ai.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Ai.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Ai.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Ai.LEVEL_LOADING,this.onLevelLoading,this),e.off(Ai.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(Ai.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(Ai.ERROR,this.onError,this)}createTracksInGroup(){var e;if(!this.media||!this.hls.config.renderTextTracksNatively)return;this.tracksInGroup.forEach(e=>{e.trackNode||(e.trackNode=Fh(this.media,Bh(e),e.name,e.lang))});let t=null==(e=this.currentTrack)||null==(e=e.trackNode)?void 0:e.track;"disabled"===(null==t?void 0:t.mode)&&(t.mode=this._subtitleDisplay?"showing":"hidden")}onMediaAttached(e,t){let i=t.media;this.media=i;let r=this.trackId;this.queuedDefaultTrack>-1&&(r=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.setSubtitleTrack(r),this.createTracksInGroup(),this.useTextTrackPolling=!(i.textTracks&&"onchange"in i.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):i.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.setSubtitleTrack(-1)),this.media=null,!r&&this.hls.config.renderTextTracksNatively&&this.tracksInGroup.forEach(e=>{let t=e.trackNode;t&&(t.track.mode="hidden",t.remove(),e.trackNode=void 0)})}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:a}=t,n=this.tracksInGroup[i];if(!n||n.groupId!==r)return void this.warn(`Subtitle track with id:${i} and group:${r} not found in active group ${null==n?void 0:n.groupId}`);let s=n.details;n.details=t.details,this.log(`Subtitle track ${i} "${n.name}" lang:${n.lang} group:${r} loaded [${a.startSN}-${a.endSN}]`),i===this.trackId&&this.playlistLoaded(i,t,s)}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,a=this.currentTrack;if(!i||(null==r?void 0:r.length)!==(null==i?void 0:i.length)||null!=i&&i.some(e=>-1===(null==r?void 0:r.indexOf(e)))){this.groupIds=i;let e=[];if(this.tracks.forEach(t=>{(t.textCodec===Rh?this.hls.config.enableIMSC1:this.hls.config.enableWebVTT)&&(!i||i.indexOf(t.groupId)>-1?(t.id=e.length,e.push(t)):t.trackNode&&(t.trackNode.remove(),t.trackNode=void 0))}),e.length===this.tracksInGroup.length){let t=!1;for(let i=0;i<e.length;i++)if(e[i]!==this.tracksInGroup[i]){t=!0;break}if(!t)return}e.length&&this.selectDefaultTrack&&!e.some(e=>e.default)&&(this.selectDefaultTrack=!1),this.tracksInGroup=e,this.trackId=-1,this.currentTrack=null;let t=this.hls.config.subtitlePreference;if(!a&&t){this.selectDefaultTrack=!1;let i=sn(t,e);if(i>-1)a=e[i];else{let e=sn(t,this.tracks);a=this.tracks[e]}}let r=this.findTrackId(a);-1===r&&a&&(r=this.findTrackId(null));let n={subtitleTracks:e};this.log(`Updating subtitle tracks, ${e.length} track(s) found in "${null==i?void 0:i.join(",")}" group-id`),this.hls.trigger(Ai.SUBTITLE_TRACKS_UPDATED,n),this.setSubtitleTrack(r),this.createTracksInGroup()}}findTrackId(e){let t=this.tracksInGroup,i=this.selectDefaultTrack;for(let r=0;r<t.length;r++){let a=t[r];if((!i||a.default)&&(i||e)&&(!e||on(a,e)))return r}if(e){for(let i=0;i<t.length;i++){let r=t[i];if(od(e.attrs,r.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return i}for(let i=0;i<t.length;i++){let r=t[i];if(od(e.attrs,r.attrs,["LANGUAGE"]))return i}}return-1}onError(e,t){t.fatal||!t.context||t.context.type===Ri.SUBTITLE_TRACK&&t.context.id===this.trackId&&hn(t.context.groupId,this.groupIds)&&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,!0)}setSubtitleOption(e){if(this.hls.config.subtitlePreference=e,e){if(-1===e.id)return this.setSubtitleTrack(-1,!0),null;let t=this.allSubtitleTracks;if(this.selectDefaultTrack=!1,t.length){let i=this.currentTrack;if(i&&on(e,i))return i;let r=sn(e,this.tracksInGroup);if(r>-1){let e=this.tracksInGroup[r];return this.setSubtitleTrack(r,!0),e}if(i)return null;{let i=sn(e,t);if(i>-1)return t[i]}}}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,a=this.getUrlWithDirectives(e.url,t),n=e.details,s=null==n?void 0:n.age;this.log(`Loading subtitle ${i} "${e.name}" lang:${e.lang} group:${r}${void 0!==(null==t?void 0:t.msn)?" at sn "+t.msn+" part "+t.part:""}${s&&n.live?" age "+s.toFixed(1)+(n.type&&" "+n.type||""):""} ${a}`),this.hls.trigger(Ai.SUBTITLE_TRACK_LOADING,{url:a,id:i,groupId:r,deliveryDirectives:t||null,track:e})}toggleTrackModes(){if(!this.media||!this.hls.config.renderTextTracksNatively)return;let e=this.currentTrack;this.tracksInGroup.forEach(t=>{if(t.trackNode){let i=t===e?this._subtitleDisplay?"showing":"hidden":"disabled",r=t.trackNode.track;r.mode!==i&&(r.mode=i)}})}setSubtitleTrack(e,t=!1){let i=this.tracksInGroup;if(this.media||(this.queuedDefaultTrack=e),e<-1||e>=i.length||!vi(e))return void this.warn(`Invalid subtitle track id: ${e}`);let r=this.currentTrack,a=i[e]||null;if(this.trackId=e,this.currentTrack=a,t&&this.toggleTrackModes(),!a)return void(r&&this.hls.trigger(Ai.SUBTITLE_TRACK_SWITCH,{id:e}));let n=!!a.details&&!a.details.live;if(a===r&&n)return;this.log(`Switching to subtitle-track ${e}`+(a?` "${a.name}" lang:${a.lang} group:${a.groupId}`:""));let{id:s,groupId:o="",name:l,type:d,url:u}=a;this.hls.trigger(Ai.SUBTITLE_TRACK_SWITCH,{id:s,groupId:o,name:l,type:d,url:u});let h=this.switchParams(a.url,null==r?void 0:r.details,a.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.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.cueCache={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this.captionsProperties=void 0,this.hls=e,this.config=e.config,this.Cues=e.config.cueHandler,this.cueCache={},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}},e.on(Ai.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(Ai.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Ai.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Ai.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(Ai.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(Ai.FRAG_LOADING,this.onFragLoading,this),e.on(Ai.FRAG_LOADED,this.onFragLoaded,this),e.on(Ai.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(Ai.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(Ai.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(Ai.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(Ai.BUFFER_APPENDED,this.onBufferAppended,this),e.on(Ai.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){let{hls:e}=this;e.off(Ai.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(Ai.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Ai.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Ai.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(Ai.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(Ai.FRAG_LOADING,this.onFragLoading,this),e.off(Ai.FRAG_LOADED,this.onFragLoaded,this),e.off(Ai.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(Ai.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(Ai.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(Ai.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(Ai.BUFFER_APPENDED,this.onBufferAppended,this),e.off(Ai.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.media=null,this.cea608Parser1=this.cea608Parser2=void 0}initCea608Parsers(){let e=new Wc(this,"textTrack1"),t=new Wc(this,"textTrack2"),i=new Wc(this,"textTrack3"),r=new Wc(this,"textTrack4");this.cea608Parser1=new Hc(1,e,t),this.cea608Parser2=new Hc(3,i,r)}addCues(e,t,i,r,a){let n=!1;for(let e=a.length;e--;){let r=a[e],s=Vc(r[0],r[1],t,i);if(s>=0&&(r[0]=Math.min(r[0],t),r[1]=Math.max(r[1],i),n=!0,s/(i-t)>.5))return}if(n||a.push([t,i]),this.config.renderTextTracksNatively){let a=this.cueCache[e];if(a){let e=this.Cues.newCue(null,t,i,r);e.length&&a.push.apply(a,e)}else{let a=this.captionsTracks[e].track;this.Cues.newCue(a,t,i,r)}}else{var s;let a=this.Cues.newCue(null,t,i,r),n=null==(s=this.captionsProperties[e])?void 0:s.media;this.hls.trigger(Ai.CUES_PARSED,{type:"captions",cues:a,track:e,closedCaptions:n})}}onInitPtsFound(e,{id:t,timestampOffsets:i}){let{unparsedVttFrags:r}=this;t===Li.MAIN&&(this.initPTS=i),r.length&&(this.unparsedVttFrags=[],r.forEach(e=>{this.initPTS[e.frag.cc]?this.onFragLoaded(Ai.FRAG_LOADED,e):this.hls.trigger(Ai.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e.frag,part:null,error:new Error("Subtitle discontinuity domain does not match main")})}))}createCaptionsTrack(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}createNativeTrack(e){if(this.captionsTracks[e])return;let{captionsProperties:t,captionsTracks:i,cueCache:r,media:a}=this,{label:n,languageCode:s}=t[e];a&&(r[e]=[],i[e]=Fh(a,"captions",n,s,"hidden"))}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(Ai.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[i]})}onMediaAttaching(e,t){this.media=t.media}onMediaDetaching(e,t){let i=!!t.transferMedia;if(this.media=null,!i){if(this.config.renderTextTracksNatively){let{captionsTracks:e,cueCache:t}=this;for(let i in e)e[i].remove(),delete t[i]}this.cueCache={},this.captionsTracks={},this.nonNativeCaptionsTracks={}}}onManifestLoading(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}onSubtitleTracksUpdated(e,t){let i=t.subtitleTracks||[];if(i.length&&!this.config.renderTextTracksNatively&&!sd(this.tracks,i)){let e=i.map(e=>({label:e.name,kind:e.type.toLowerCase(),default:e.default,subtitleTrack:e}));this.hls.trigger(Ai.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:e})}this.tracks=i}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===Li.MAIN){var i,r;let{cea608Parser1:e,cea608Parser2:a,lastSn:n}=this,{cc:s,sn:o}=t.frag,l=null!=(i=null==(r=t.part)?void 0:r.index)?i:-1;e&&a&&(o!==n+1||o===n&&l!==this.lastPartIndex+1||s!==this.lastCc)&&(e.reset(),a.reset()),this.lastCc=s,this.lastSn=o,this.lastPartIndex=l}}onFragLoaded(e,t){let{frag:i,payload:r}=t;var a;if(i.level<this.tracks.length&&i.type===Li.SUBTITLE)if(r.byteLength||null!=(a=i.initSegment)&&null!=(a=a.data)&&a.byteLength){let e=i.decryptdata,r="stats"in t;if(null==e||!e.encrypted||r){let e=this.tracks[i.level],r=this.vttCCs;r[i.cc]||(r[i.cc]={start:i.start,prevCC:this.prevCC,new:!0},this.prevCC=i.cc),(null==e?void 0:e.textCodec)===Rh?this._parseIMSC1(t):this._parseVTTs(t)}}else{let e="part"in t?t.part:null;this.hls.trigger(Ai.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,part:e,error:new Error("Empty subtitle payload")})}}_parseIMSC1(e){let{frag:t,payload:i}=e,r="part"in e?e.part:null,a=this.hls;Ch(i,this.initPTS[t.cc],e=>{this._appendCues(e,t.level),a.trigger(Ai.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:t,part:r})},e=>{a.logger.log(`Cannot parse IMSC1 (sn: ${t.sn} @${t.start}): ${e}`),a.trigger(Ai.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,part:r,error:e})})}_parseVTTs(e){var t;let{frag:i,payload:r}=e,a="part"in e?e.part:null,{initPTS:n,unparsedVttFrags:s}=this,o=n.length-1;if(!n[i.cc]&&-1===o)return void s.push(e);let l=this.hls,d=null==(t=i.initSegment)?void 0:t.data;Ih(d?sa(d,new Uint8Array(r)).buffer:r,this.initPTS[i.cc],this.vttCCs,i.cc,(a&&!d?a:i).start,e=>{this._appendCues(e,i.level),l.trigger(Ai.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:i,part:a})},t=>{let r=t.message.startsWith("Missing initPTS");l.logger.log(`${r?"Deferred parsing of":"Cannot parse"} VTT cue (sn: ${i.sn} @${i.start}): ${t}`),r?s.push(e):(this.config.enableIMSC1&&this._fallbackToIMSC1(e),l.trigger(Ai.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,part:a,error:t}))})}_fallbackToIMSC1(e){let{frag:t,payload:i}=e,r=this.tracks[t.level];r.textCodec||Ch(i,this.initPTS[t.cc],()=>{r.textCodec=Rh,this._parseIMSC1(e)},()=>{r.textCodec="wvtt"})}_appendCues(e,t){let i=this.hls;if(this.config.renderTextTracksNatively){var r;let i=null==(r=this.tracks[t].trackNode)?void 0:r.track;if(!i||"disabled"===i.mode)return;e.forEach(e=>$h(i,e))}else{let r=this.tracks[t];if(!r)return;let a=r.default?"default":"subtitles"+t;i.trigger(Ai.CUES_PARSED,{type:"subtitles",cues:e,track:a,subtitleTrack:r})}}onFragDecrypted(e,t){let{frag:i}=t;i.type===Li.SUBTITLE&&this.onFragLoaded(Ai.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!==Li.MAIN||"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])}}}onBufferAppended(e,t){if(this.config.renderTextTracksNatively){var i;let{type:e,timeRanges:r}=t;if("video"===e&&null!=(i=r[e])&&i.length){let{captionsTracks:e,cueCache:t}=this;Object.keys(t).forEach(i=>{var r;let a=null==(r=e[i])?void 0:r.track;if(a){let e=t[i];for(let t=0;t<e.length;t++)$h(a,e[t])}delete t[i]})}}}onBufferFlushing(e,t){let{startOffset:i,endOffset:r,endOffsetSubtitles:a,type:n}=t,{media:s}=this;if(s&&!(s.currentTime<r)){if(!n||"video"===n){let{captionsTracks:e,cueCache:t}=this;Object.keys(e).forEach(t=>Hh(e[t].track,i,r)),Object.keys(t).forEach(e=>{let a=t[e];for(let e=a.length;e--;){let t=a[e];t.startTime>=i&&t.endTime<=r&&a.splice(e,1)}})}this.config.renderTextTracksNatively&&0===i&&void 0!==a&&this.tracks.forEach(e=>{var t;let r=null==(t=e.trackNode)?void 0:t.track;r&&Hh(r,i,a)})}}extractCea608Data(e){let t=[[],[]],i=31&e[0],r=2;for(let a=0;a<i;a++){let i=e[r++],a=127&e[r++],n=127&e[r++];if((0!==a||0!==n)&&4&i){let e=3&i;(0===e||1===e)&&(t[e].push(a),t[e].push(n))}}return t}},audioStreamController:class extends Mo{constructor(e,t,i){super(e,t,i,"audio-stream-controller",Li.AUDIO),this.mainAnchor=null,this.mainFragLoading=null,this.audioOnly=!1,this.bufferedTrack=null,this.switchingTrack=null,this.trackId=-1,this.nextTrackId=-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(Ai.LEVEL_LOADED,this.onLevelLoaded,this),e.on(Ai.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(Ai.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(Ai.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(Ai.BUFFER_RESET,this.onBufferReset,this),e.on(Ai.BUFFER_CREATED,this.onBufferCreated,this),e.on(Ai.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(Ai.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(Ai.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(Ai.FRAG_LOADING,this.onFragLoading,this),e.on(Ai.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){let{hls:e}=this;e&&(super.unregisterListeners(),e.off(Ai.LEVEL_LOADED,this.onLevelLoaded,this),e.off(Ai.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(Ai.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(Ai.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(Ai.BUFFER_RESET,this.onBufferReset,this),e.off(Ai.BUFFER_CREATED,this.onBufferCreated,this),e.off(Ai.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(Ai.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(Ai.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(Ai.FRAG_LOADING,this.onFragLoading,this),e.off(Ai.FRAG_BUFFERED,this.onFragBuffered,this))}onInitPtsFound(e,t){let{frag:i,id:r,initPTS:a,timescale:n,trackId:s,timestampOffsets:o}=t;if(r===Li.MAIN){let e=i.cc,t=this.fragCurrent;if(this.initPTS=o,this.log(`InitPTS for cc: ${e} found from main: ${a/n} (${a}/${n}) trackId: ${s}`),this.mainAnchor=i,this.state===Do){let t=this.waitingData;(!t&&!this.loadingParts||t&&t.frag.cc!==e)&&this.syncWithAnchor(i,null==t?void 0:t.frag)}else!this.hls.hasEnoughToStart&&t&&t.cc!==e?(t.abortRequests(),this.syncWithAnchor(i,t)):this.state===To&&this.tick()}}getLoadPosition(){var e;return!this.startFragRequested&&this.nextLoadPosition>=0&&!1!==(null==(e=this.switchingTrack)?void 0:e.flushImmediate)?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 a=(r||e).cc,n=vn(this.getLevelDetails(),a,this.getLoadPosition());n&&(this.log(`Syncing with main frag at ${n.start} cc ${n.cc}`),this.startFragRequested=!1,this.nextLoadPosition=n.start,this.resetLoadingState(),this.state===To&&this.doTickIdle())}startLoad(e,t){if(!this.levels)return this.startPosition=e,void(this.state=bo);let i=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),i>0&&-1===e&&!t&&this.initPTS.length&&(this.log(`Override startPosition with lastCurrentTime @${i.toFixed(3)}`),e=i),this.state=To,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,!t&&!this.fragmentTracker.hasFragments(this.playlistType)&&(this.startFragRequested=!1),this.tick()}doTick(){switch(this.state){case To:this.doTickIdle();break;case ko:{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=Do}break}case So:this.checkRetryDate();break;case Do:{let e=this.waitingData;if(e){let{frag:t,part:i,cache:r,complete:a}=e,n=this.mainAnchor;if(void 0!==this.initPTS[t.cc]){this.waitingData=null,this.state=_o;let e={frag:t,part:i,payload:r.flush().buffer,networkDetails:null};this._handleFragmentLoadProgress(e),a&&super._handleFragmentLoadComplete(e)}else n&&n.cc!==e.frag.cc&&this.syncWithAnchor(n,e.frag)}else this.state=To}}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,this.checkFragmentChanged())}doTickIdle(){var e;let{hls:t,levels:i,media:r,trackId:a}=this,n=t.config;if(!this.buffering||!r&&!this.primaryPrefetch&&(this.startFragRequested||!n.startFragPrefetch)||null==i||!i[a])return;let s=i[a],o=s.details;if(!o||this.waitForLive(s)||this.waitForCdnTuneIn(o))return this.state=ko,void(this.startFragRequested=!1);let l=this.getBufferOutput();this.bufferFlushed&&l&&(this.bufferFlushed=!1,this.afterBufferFlushed(l,wi));let d=this.getFwdBufferInfo();if(null===d)return;if(!this.switchingTrack&&this._streamEnded(d,o))return t.trigger(Ai.BUFFER_EOS,{type:"audio"}),void(this.state=Lo);let u=d.len,h=t.maxBufferLength,c=o.fragments,m=c[0].start,f=this.getLoadPosition(),p=this.flushing||this.switchingTrack&&!this.switchingTrack.flushImmediate?f:d.end;if(this.switchingTrack&&r){let e=f;o.PTSKnown&&e<m&&e>=this.timelineOffset&&(d.end>m||d.nextStart)&&(this.log(`Alt audio track ahead of main track, seek to start of alt audio track ${e} -> ${m} + 0.05`),r.currentTime=m+.05)}if(u>=h&&!this.switchingTrack&&p<c[c.length-1].start)return;let g=this.getNextFragment(p,o);if(g&&this.isLoopLoading(g,p)&&(g=this.getNextFragmentLoopLoading(g,o,d,Li.MAIN,h)),!g)return void(this.bufferFlushed=!0);if(this.exceedsMaxBuffer(d,h,g))return;let v=(null==(e=this.mainFragLoading)?void 0:e.frag)||null;if(!this.audioOnly&&this.startFragRequested&&v&&Pi(g)&&!g.endList&&(!o.live||!this.loadingParts&&p<this.hls.liveSyncPosition)&&(this.fragmentTracker.getState(v)===On&&(this.mainFragLoading=v=null),v&&Pi(v))){if(g.start>v.end){let e=this.fragmentTracker.getFragAtPos(p,Li.MAIN);e&&e.end>v.end&&(v=e,this.mainFragLoading={frag:e,targetBufferTime:null})}if(g.start>v.end)return}this.loadFragment(g,s,p)}onMediaDetaching(e,t){this.bufferFlushed=this.flushing=!1,super.onMediaDetaching(e,t)}onAudioTracksUpdated(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map(e=>new Za(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,t.flushImmediate||(this.nextTrackId=t.id,this.nextLevelSwitch()),this.flushAudioIfNeeded(t),this.state!==bo&&(this.setInterval(100),this.state=To,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(Ai.AUDIO_TRACK_LOADED,i))}onAudioTrackLoaded(e,t){var i;let{levels:r}=this,{details:a,id:n,groupId:s,track:o}=t;if(!r)return void this.warn(`Audio tracks reset while loading track ${n} "${o.name}" of "${s}"`);let l=this.mainDetails;if(!l||a.endCC>l.endCC||l.expired)return this.cachedTrackLoadedData=t,void(this.state!==bo&&(this.state=ko));this.cachedTrackLoadedData=null,this.log(`Audio track ${n} "${o.name}" of "${s}" loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""},duration:${a.totalduration}`);let d=r[n],u=0;if(a.live||null!=(i=d.details)&&i.live){if(this.checkLiveUpdate(a),a.deltaUpdateFailed)return;var h;if(d.details)u=this.alignPlaylists(a,d.details,null==(h=this.levelLastLoaded)?void 0:h.details);a.alignedSliding||(go(l,a,this),u=a.fragmentStart)}d.details=a,this.levelLastLoaded=d,this.startFragRequested||this.setStartPosition(l,u),this.hls.trigger(Ai.AUDIO_TRACK_UPDATED,{details:a,id:n,groupId:t.groupId}),this.state===ko&&!this.waitForCdnTuneIn(a)&&(this.state=To),this.tick()}_handleFragmentLoadProgress(e){var t;let i=e.frag,{part:r,payload:a}=e,{config:n,trackId:s,levels:o}=this;if(!o)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 l=o[s];if(!l)return void this.warn("Audio track is undefined on fragment load progress");let d=l.details;if(!d)return this.warn("Audio track details undefined on fragment load progress"),void this.removeUnbufferedFrags(i.start);let u=n.defaultAudioCodec||l.audioCodec||"mp4a.40.2",h=this.transmuxer;h||(h=this.transmuxer=new ad(this.hls,Li.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));let c=this.initPTS[i.cc],m=null==(t=i.initSegment)?void 0:t.data;if(void 0!==c){let e=r?r.index:-1,t=-1!==e,n=new Jn(i.level,i.sn,i.stats.chunkCount,a.byteLength,e,t,i.duration);h.push(a,m,u,"",i,r,d.totalduration,!1,n,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 ${s}`);let{cache:e}=this.waitingData=this.waitingData||{frag:i,part:r,cache:new Oo,complete:!1};e.push(new Uint8Array(a)),this.state!==bo&&(this.state=Do)}}_handleFragmentLoadComplete(e){this.waitingData?this.waitingData.complete=!0: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===Li.MAIN&&Pi(t.frag)&&(this.mainFragLoading=t,this.state===To&&this.tick())}onFragBuffered(e,t){let{frag:i,part:r}=t;if(i.type===Li.AUDIO)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}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);else{if(Pi(i)){let e=this.switchingTrack;e&&(this.bufferedTrack=e)}this.fragBufferedComplete(i,r),this.media&&this.tick()}else!this.audioOnly&&i.type===Li.MAIN&&!i.elementaryStreams.video&&!i.elementaryStreams.audiovideo&&(this.audioOnly=!0,this.mainFragLoading=null)}getFwdBufferInfo(){let e=this.getBufferOutput();return super.getFwdBufferInfo(e,Li.AUDIO)}getBufferOutput(){return this.mediaBuffer?this.mediaBuffer:this.media}checkFragmentChanged(){let e=this.fragPlaying;if(!this.checkFragPlaying())return!1;let t=this.fragPlaying,i=null==e?void 0:e.level;return(!t||t.level!==i)&&(e&&this.cleanupBackBuffer(),this.switchingTrack&&this.completeAudioSwitch(this.switchingTrack)),!0}onError(e,t){var i;if(t.fatal)this.state=wo;else switch(t.details){case Ti.FRAG_GAP:case Ti.FRAG_PARSING_ERROR:case Ti.FRAG_DECRYPT_ERROR:case Ti.FRAG_LOAD_ERROR:case Ti.FRAG_LOAD_TIMEOUT:case Ti.KEY_LOAD_ERROR:case Ti.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Li.AUDIO,t);break;case Ti.AUDIO_TRACK_LOAD_ERROR:case Ti.AUDIO_TRACK_LOAD_TIMEOUT:case Ti.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===ko&&(null==(i=t.context)?void 0:i.type)===Ri.AUDIO_TRACK&&(this.state=To);break;case Ti.BUFFER_APPEND_NO_PROGRESS:if("audio"!==t.parent)return;t.frag&&(t.appendsWithoutProgress||0)>=this.config.appendErrorMaxRetry&&(this.warn(`Marking fragment ${t.frag.sn} of track ${t.frag.level} as a gap after ${t.appendsWithoutProgress} appends without buffered range growth, to prevent loop loading`),this.fragmentTracker.addAsGap(t.frag));break;case Ti.BUFFER_ADD_CODEC_ERROR:case Ti.BUFFER_APPEND_ERROR:if("audio"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)||this.resetLoadingState();break;case Ti.BUFFER_FULL_ERROR:if("audio"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case Ti.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}onBufferFlushing(e,{type:t}){t!==Di&&(this.flushing=!0)}onBufferFlushed(e,{type:t}){if(t!==Di){this.flushing=!1,this.bufferFlushed=!0,this.state===Lo&&(this.state=To);let e=this.getBufferOutput();e&&(this.afterBufferFlushed(e,t),this.tick())}}_handleTransmuxComplete(e){var t;let i="audio",{hls:r}=this,{remuxResult:a,chunkMeta:n}=e,s=this.getCurrentContext(n);if(!s)return void this.resetWhenMissingContext(n);let{frag:o,part:l,level:d}=s,{details:u}=d,{audio:h,text:c,id3:m,initSegment:f}=a;if(this.fragContextChanged(o)||!u)return this.fragmentTracker.removeFragment(o),void(null!=f&&f.tracks&&this.resetTransmuxer());if(this.state=Io,h&&this.switchingTrack&&!this.switchingTrack.flushImmediate){let{config:e}=this,t=e.nextAudioTrackBufferFlushForwardOffset,i=Math.max(this.getLoadPosition()+t,o.start);super.flushMainBuffer(i,Number.POSITIVE_INFINITY,Li.AUDIO)}if(null!=f&&f.tracks){let e=o.initSegment||o;if(this.unhandledEncryptionError(f,o))return;this._bufferInitSegment(d,f.tracks,e,n),r.trigger(Ai.FRAG_PARSING_INIT_SEGMENT,{frag:e,id:i,tracks:f.tracks})}if(h){let{startPTS:e,endPTS:t,startDTS:i,endDTS:r}=h;l&&(l.elementaryStreams[wi]={startPTS:e,endPTS:t,startDTS:i,endDTS:r}),o.setElementaryStreamInfo(wi,e,t,i,r),this.bufferFragmentData(h,o,l,n)}if(null!=m&&null!=(t=m.samples)&&t.length){let e=$i({id:i,frag:o,details:u},m);r.trigger(Ai.FRAG_PARSING_METADATA,e)}if(c){let e=$i({id:i,frag:o,details:u},c);r.trigger(Ai.FRAG_PARSING_USERDATA,e)}}_bufferInitSegment(e,t,i,r){if(this.state!==Io||(t.video&&delete t.video,t.audiovideo&&delete t.audiovideo,!t.audio))return;let a=t.audio;a.id=Li.AUDIO;let n=e.audioCodec;this.log(`Init audio buffer, container:${a.container}, codecs[level/parsed]=[${n}/${a.codec}]`),1===(null==n?void 0:n.split(",").length)&&(a.levelCodec=n),this.hls.trigger(Ai.BUFFER_CODECS,t);let s=a.initSegment;if(null!=s&&s.byteLength){let e={type:"audio",frag:i,part:null,chunkMeta:r,parent:i.type,data:s};this.hls.trigger(Ai.BUFFER_APPENDING,e)}this.tickImmediate()}loadFragment(e,t,i){let r=this.fragmentTracker.getState(e);var a;if(this.switchingTrack||r===Mn||r===xn)if(null!=(a=t.details)&&a.live&&!this.initPTS[e.cc]){this.log(`Waiting for video PTS in continuity counter ${e.cc} of live stream before loading audio fragment ${e.sn} of level ${this.trackId}`),this.state=Do;let i=this.mainDetails;i&&i.fragmentStart!==t.details.fragmentStart&&go(i,t.details,this)}else super.loadFragment(e,t,i);else this.clearTrackerIfNeeded(e)}flushAudioIfNeeded(e){if(this.media&&this.bufferedTrack&&e.flushImmediate){let{name:t,lang:i,assocLang:r,characteristics:a,audioCodec:n,channels:s}=this.bufferedTrack;on({name:t,lang:i,assocLang:r,characteristics:a,audioCodec:n,channels:s},e,ln)||(un(e.url,this.hls)?(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"),this.bufferedTrack=null):this.bufferedTrack=e)}}completeAudioSwitch(e){let{hls:t}=this;this.bufferedTrack=e,this.switchingTrack=null,t.trigger(Ai.AUDIO_TRACK_SWITCHED,Gi({},e))}get nextAudioTrack(){return this.nextTrackId}},audioTrackController:class extends nd{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(Ai.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Ai.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Ai.LEVEL_LOADING,this.onLevelLoading,this),e.on(Ai.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(Ai.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(Ai.ERROR,this.onError,this)}unregisterListeners(){let{hls:e}=this;e.off(Ai.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Ai.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Ai.LEVEL_LOADING,this.onLevelLoading,this),e.off(Ai.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(Ai.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(Ai.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:a}=t,n=this.tracksInGroup[i];if(!n||n.groupId!==r)return void this.warn(`Audio track with id:${i} and group:${r} not found in active group ${null==n?void 0:n.groupId}`);let s=n.details;n.details=t.details,this.log(`Audio track ${i} "${n.name}" lang:${n.lang} group:${r} loaded [${a.startSN}-${a.endSN}]`),i===this.trackId&&this.playlistLoaded(i,t,s)}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,a=this.currentTrack;if(!i||(null==r?void 0:r.length)!==(null==i?void 0:i.length)||null!=i&&i.some(e=>-1===(null==r?void 0:r.indexOf(e)))){this.groupIds=i,this.trackId=-1,this.currentTrack=null;let e=this.tracks.filter(e=>hn(e.groupId,i));if(e.length)this.selectDefaultTrack&&!e.some(e=>e.default)&&(this.selectDefaultTrack=!1),e.forEach((e,t)=>{e.id=t});else if(!a&&!this.tracksInGroup.length)return;this.tracksInGroup=e;let t=this.hls.config.audioPreference;if(!a&&t){let i=sn(t,e,ln);if(i>-1)a=e[i];else{let e=sn(t,this.tracks);a=this.tracks[e]}}let r=this.findTrackId(a);-1===r&&a&&(r=this.findTrackId(null));let s={audioTracks:e};this.log(`Updating audio tracks, ${e.length} track(s) found in group(s): ${null==i?void 0:i.join(",")}`),this.hls.trigger(Ai.AUDIO_TRACKS_UPDATED,s);let o=this.trackId;if(-1!==r&&-1===o)this.setAudioTrack(r);else if(e.length&&-1===o){var n;let t=new Error(`No audio track selected for current audio group-ID(s): ${null==(n=this.groupIds)?void 0:n.join(",")} track count: ${e.length}`);this.warn(t.message),this.hls.trigger(Ai.ERROR,{type:bi.MEDIA_ERROR,details:Ti.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:t})}}}onError(e,t){t.fatal||!t.context||t.context.type===Ri.AUDIO_TRACK&&t.context.id===this.trackId&&hn(t.context.groupId,this.groupIds)&&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)}get nextAudioTrack(){return this.trackId}set nextAudioTrack(e){this.selectDefaultTrack=!1,this.setAudioTrack(e,!1)}setAudioOption(e){let t=this.hls;if(t.config.audioPreference=e,e){let i=this.allAudioTracks;if(this.selectDefaultTrack=!1,i.length){let r=this.currentTrack;if(r&&on(e,r,ln))return r;let a=sn(e,this.tracksInGroup,ln);if(a>-1){let t=this.tracksInGroup[a];return this.setAudioTrack(a,"flushImmediate"in e&&e.flushImmediate),t}if(r){let r=t.loadLevel;-1===r&&(r=t.firstAutoLevel);let a=function(e,t,i,r,a){let n=t[r],s=t.reduce((e,t,i)=>{let r=t.uri;return(e[r]||(e[r]=[])).push(i),e},{})[n.uri];s.length>1&&(r=Math.max.apply(Math,s));let o=n.videoRange,l=n.frameRate,d=n.codecSet.substring(0,4),u=dn(t,r,t=>{if(t.videoRange!==o||t.frameRate!==l||t.codecSet.substring(0,4)!==d)return!1;let r=t.audioGroups,n=i.filter(e=>hn(e.groupId,r));return sn(e,n,a)>-1});return u>-1?u:dn(t,r,t=>{let r=t.audioGroups,n=i.filter(e=>hn(e.groupId,r));return sn(e,n,a)>-1})}(e,t.levels,i,r,ln);if(-1===a)return null;t.nextLoadLevel=a}if(e.channels||e.audioCodec){let t=sn(e,i);if(t>-1)return i[t]}}}return null}setAudioTrack(e,t=!0){let i=this.tracksInGroup;if(e<0||e>=i.length)return void this.warn(`Invalid audio track id: ${e}`);this.selectDefaultTrack=!1;let r=this.currentTrack,a=i[e],n=a.details&&!a.details.live;if(e===this.trackId&&a===r&&n||(this.log(`Switching to audio-track ${e} "${a.name}" lang:${a.lang} group:${a.groupId} channels:${a.channels}`),this.trackId=e,this.currentTrack=a,this.hls.trigger(Ai.AUDIO_TRACK_SWITCHING,Gi(Gi({},a),{},{flushImmediate:t})),n))return;let s=this.switchParams(a.url,null==r?void 0:r.details,a.details);this.loadPlaylist(s)}findTrackId(e){let t=this.tracksInGroup;for(let i=0;i<t.length;i++){let r=t[i];if((!this.selectDefaultTrack||r.default)&&(!e||on(e,r,ln)))return i}if(e){let{name:i,lang:r,assocLang:a,characteristics:n,audioCodec:s,channels:o}=e;for(let e=0;e<t.length;e++){if(on({name:i,lang:r,assocLang:a,characteristics:n,audioCodec:s,channels:o},t[e],ln))return e}for(let i=0;i<t.length;i++){let r=t[i];if(od(e.attrs,r.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return i}for(let i=0;i<t.length;i++){let r=t[i];if(od(e.attrs,r.attrs,["LANGUAGE"]))return i}}return-1}loadPlaylist(e){super.loadPlaylist();let t=this.currentTrack;this.shouldLoadPlaylist(t)&&un(t.url,this.hls)&&this.scheduleLoading(t,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);let i=e.id,r=e.groupId,a=this.getUrlWithDirectives(e.url,t),n=e.details,s=null==n?void 0:n.age;this.log(`Loading audio-track ${i} "${e.name}" lang:${e.lang} group:${r}${void 0!==(null==t?void 0:t.msn)?" at sn "+t.msn+" part "+t.part:""}${s&&n.live?" age "+s.toFixed(1)+(n.type&&" "+n.type||""):""} ${a}`),this.hls.trigger(Ai.AUDIO_TRACK_LOADING,{url:a,id:i,groupId:r,deliveryDirectives:t||null,track:e})}},emeController:dh,cmcdController:class{constructor(e){this.hls=void 0,this.config=void 0,this.media=void 0,this.initialized=!1,this.starved=!1,this.buffering=!0,this.playerState=void 0,this.reporter=void 0,this.playheadLevel=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=!0,this.setPlayerState(Fu)),this.buffering=!0},this.onPlay=()=>{this.initialized||this.setPlayerState(Ou)},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1,this.setPlayerState(Nu)},this.onPause=()=>{this.media&&!this.media.ended&&this.setPlayerState(Bu)},this.onSeeking=()=>{this.initialized&&this.setPlayerState(Uu)},this.onSeeked=()=>{var e;this.initialized&&null!=(e=this.media)&&e.paused&&this.setPlayerState(Bu)},this.onRateChange=()=>{this.reporter&&this.media&&this.reporter.update({pr:this.media.playbackRate})},this.applyPlaylistData=e=>{try{this.apply(e,{ot:wu,su:!this.initialized})}catch(e){this.hls.logger.warn("Could not generate manifest CMCD data.",e)}},this.applyFragmentData=e=>{try{let{frag:r,part:a}=e,n=this.hls.levels[r.level],s=this.getObjectType(r,n),o={d:1e3*(a||r).duration,ot:s};if(s===Cu||s===Du||s===Mu||null==s&&("main"===r.type||"audio"===r.type)){var t;let e=n.bitrate/1e3;o.br=[e];let{cmcd:a}=this.config,l=null!=(t=null==a?void 0:a.rtpSafetyFactor)?t:5;if(o.rtp=100*Math.round(e*l/100),s===Mu||null==s&&"main"===r.type){let e=this.getTopBandwidth()/1e3;vi(e)&&(o.tb=[e]);let t=this.getLowestBandwidth()/1e3;vi(t)&&(o.lb=[t])}let d=this.getBufferLength(r);if(vi(d)){var i;o.bl=[d];let e=(null==(i=this.media)?void 0:i.playbackRate)||1;o.dl=100*Math.round(d/e/100)}this.playheadLevel&&(o.pb=[this.playheadLevel.bitrate/1e3]);let u=this.hls.maxAutoLevel;if(u>=0){let e=this.hls.levels[u];e&&(o.tpb=[e.bitrate/1e3])}}let l=a?this.getNextPart(a):this.getNextFrag(r);null!=l&&l.url&&l.url!==r.url&&(l.byteRange.length>0?o.nor=[ih(l.url,{r:`${l.byteRange[0]}-${l.byteRange[1]}`})]:o.nor=[l.url]),this.apply(e,o)}catch(e){this.hls.logger.warn("Could not generate segment CMCD data.",e)}},this.recordFragmentResponse=(e,t,i)=>{var r;let{cmcd:a}=this.config,n=null==a||null==(r=a.eventTargets)?void 0:r.some(e=>{var t;return null==(t=e.events)?void 0:t.includes(jd)});if(this.reporter&&i.loading.first>0&&n)try{this.reporter.recordResponseReceived({request:{url:e},status:t.code,resourceTiming:{startTime:i.loading.start,responseStart:i.loading.first,duration:i.loading.end-i.loading.start,encodedBodySize:i.total}})}catch(e){this.hls.logger.warn("Could not record fragment response CMCD data.",e)}},this.hls=e;let t=this.config=e.config,{cmcd:i}=t;null!=i&&(t.pLoader=this.createPlaylistLoader(),t.fLoader=this.createFragmentLoader(),this.registerListeners())}createReporter(){var e,t;let{cmcd:i}=this.config;if(null==i)return;let r=i.version||1;if(this.reporter=new Xu({sid:i.sessionId||this.hls.sessionId,cid:i.contentId,version:r,transmissionMode:!0===i.useHeaders?Wu:Ku,enabledKeys:null!=(e=i.includeKeys)?e:[...r>=Wd?Lu:uu],eventTargets:(null!=(t=i.eventTargets)?t:[]).map(e=>{let{includeKeys:t}=e;return Gi(Gi({},Ki(e,rh)),{},{enabledKeys:null!=t?t:Lu})})},i.loader),this.reporter.update({sf:Zu,sta:this.playerState}),i.reporterCallback){let e=this.reporter,t={updateCustomData:t=>{ah(t)&&e.update(t)},recordCustomEvent:(t,i={})=>{ah(i)&&e.recordEvent(zd,Gi({cen:t},i))}};i.reporterCallback(t)}this.reporter.start()}registerListeners(){let e=this.hls;e.on(Ai.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Ai.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(Ai.MEDIA_DETACHED,this.onMediaDetached,this),e.on(Ai.MEDIA_ENDED,this.onMediaEnded,this),e.on(Ai.ERROR,this.onError,this),e.on(Ai.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(Ai.LEVEL_SWITCHED,this.onLevelSwitched,this),e.on(Ai.BUFFER_APPENDED,this.onBufferInfoChange,this),e.on(Ai.BUFFER_FLUSHED,this.onBufferInfoChange,this)}unregisterListeners(){let e=this.hls;e.off(Ai.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Ai.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(Ai.MEDIA_DETACHED,this.onMediaDetached,this),e.off(Ai.MEDIA_ENDED,this.onMediaEnded,this),e.off(Ai.ERROR,this.onError,this),e.off(Ai.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(Ai.LEVEL_SWITCHED,this.onLevelSwitched,this),e.off(Ai.BUFFER_APPENDED,this.onBufferInfoChange,this),e.off(Ai.BUFFER_FLUSHED,this.onBufferInfoChange,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.reporter&&(this.reporter.stop(!0),this.reporter=void 0),this.hls=this.config=null,this.onWaiting=this.onPlay=this.onPlaying=this.onPause=null,this.onSeeking=this.onSeeked=this.onRateChange=this.media=null}onMediaAttaching(e,t){let i=this.media=t.media;this.setPlayerState(this.media.autoplay?Ou:Gu),vo(i,"waiting",this.onWaiting),vo(i,"play",this.onPlay),vo(i,"playing",this.onPlaying),vo(i,"pause",this.onPause),vo(i,"seeking",this.onSeeking),vo(i,"seeked",this.onSeeked),vo(i,"ratechange",this.onRateChange)}onMediaDetached(){let e=this.media;e&&(Eo(e,"waiting",this.onWaiting),Eo(e,"play",this.onPlay),Eo(e,"playing",this.onPlaying),Eo(e,"pause",this.onPause),Eo(e,"seeking",this.onSeeking),Eo(e,"seeked",this.onSeeked),Eo(e,"ratechange",this.onRateChange),this.media=null)}onMediaEnded(e,t){this.setPlayerState($u)}onManifestLoading(e,t){this.initialized=!1,this.starved=!1,this.buffering=!0,this.reporter&&(this.reporter.stop(!0),this.reporter=void 0),this.createReporter(),this.media||this.setPlayerState(Gu)}onError(e,t){t.fatal&&(this.setPlayerState(Hu),this.reporter&&this.reporter.recordEvent(Yd,{ec:[t.details]}))}onLevelSwitching(e,t){var i;if(!this.reporter)return;let r={br:[t.bitrate/1e3]},a=null==(i=t.details)?void 0:i.fragments[0];a&&(r.ot=this.getObjectType(a,t)),this.reporter.recordEvent(qd,r)}onLevelSwitched(e,t){let i=this.hls.levels[t.level];i&&(this.playheadLevel=i)}setPlayerState(e){this.playerState=e,this.reporter&&this.reporter.update({sta:e})}getStreamType(){let e=this.hls.latestLevelDetails;if(e)return e.live?e.partList&&e.canBlockReload?th:eh:Ju}apply(e,t={}){var i;if(!this.reporter)return;this.reporter.update({mtp:[this.hls.bandwidthEstimate/1e3],pr:null==(i=this.media)?void 0:i.playbackRate,st:this.getStreamType()});let r=t.ot===Pu||t.ot===Cu||t.ot===Mu;this.starved&&r&&(t.bs=!0,t.su=!0,this.starved=!1),null==t.su&&(t.su=this.buffering);let a=this.reporter.createRequestReport({url:e.url,headers:e.headers},t);e.url=a.url,e.headers=a.headers}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,a=null==(t=this.hls.levels[r.level])||null==(t=t.details)?void 0:t.partList;if(a){let{sn:e}=r;for(let t=a.length-1;t>=0;t--){let r=a[t];if(r.index===i&&r.fragment.sn===e)return a[t+1]}}}getObjectType(e,t){let{type:i}=e;if("subtitle"===i)return xu;if("initSegment"===e.sn)return Pu;if("audio"===i)return Du;if("main"===i){if(e.hasStreams){let t=e.elementaryStreams;if(t.audiovideo)return Mu;if(t.video)return Cu;if(t.audio)return Du}if(t){let{audioCodec:e,videoCodec:i}=t;if(!this.hls.audioTracks.length){if(e&&i)return Mu;if(e)return Du}if(i)return Cu}}}getTopBandwidth(){let e=0,t=this.hls,i=t.maxAutoLevel,r=i>-1?i+1:t.levels.length;return t.levels.slice(0,r).forEach(t=>{t.bitrate>e&&(e=t.bitrate)}),e>0?e:NaN}getLowestBandwidth(){let e=1/0,t=this.hls,i=t.maxAutoLevel,r=i>-1?i+1:t.levels.length;return t.levels.slice(0,r).forEach(t=>{t.bitrate<e&&(e=t.bitrate)}),vi(e)?e:NaN}getBufferLength(e){if(!this.media)return NaN;let t="audio"===e.type?this.hls.audioForwardBufferInfo:this.hls.mainForwardBufferInfo;return t?1e3*t.len:NaN}getEventBufferLength(){if(!this.media)return NaN;let e=this.hls.mainForwardBufferInfo,t=this.hls.audioForwardBufferInfo;if(e&&t)return 1e3*Math.min(e.len,t.len);let i=e||t;return i?1e3*i.len:NaN}onBufferInfoChange(e,t){if(!this.reporter)return;let i=this.getEventBufferLength();vi(i)&&this.reporter.update({bl:[i]})}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=this.recordFragmentResponse,r=e||this.config.loader;return class{constructor(e){this.loader=void 0,this.loader=new r(e)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(e,r,a){t(e);let{onSuccess:n}=a;this.loader.load(e,r,Gi(Gi({},a),{},{onSuccess:(t,r,a,s)=>{n(t,r,a,s),i(e.url,t,r)}}))}}}},contentSteeringController:class extends tr{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(Ai.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Ai.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(Ai.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Ai.ERROR,this.onError,this)}unregisterListeners(){let e=this.hls;e&&(e.off(Ai.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Ai.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(Ai.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Ai.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)===bn&&i.flags&Sn){let e=this.levels,r=this._pathwayPriority,a=this.pathwayId;if(t.context){let{groupId:i,pathwayId:r,type:n}=t.context;i&&e?a=this.getPathwayForGroupId(i,n,a):r&&(a=r)}a in this.penalizedPathways||(this.penalizedPathways[a]=performance.now()),!r&&e&&(r=this.pathways()),r&&r.length>1&&(this.updatePathwayPriority(r),i.resolved=this.pathwayId!==a,!i.resolved&&(t.details!==Ti.BUFFER_APPEND_ERROR||t.fatal)&&this.warn(`Could not resolve ${t.details} ("${t.error.message}") with content-steering for Pathway: ${a} levels: ${e&&e.length} priorities: ${tn(r)} penalized: ${tn(this.penalizedPathways)}`))}}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){this._pathwayPriority=e;let t,i=this.penalizedPathways,r=performance.now();Object.keys(i).forEach(e=>{r-i[e]>3e5&&delete i[e]});for(let r=0;r<e.length;r++){let a=e[r];if(a in i)continue;if(a===this.pathwayId)return;let n=this.hls.nextLoadLevel,s=this.hls.levels[n];if(t=this.getLevelsForPathway(a),t.length>0){this.log(`Setting Pathway to "${a}"`),this.pathwayId=a,uo(t),this.hls.trigger(Ai.LEVELS_UPDATED,{levels:t});let e=this.hls.levels[n];s&&e&&this.levels&&(e.attrs["STABLE-VARIANT-ID"]!==s.attrs["STABLE-VARIANT-ID"]&&e.bitrate!==s.bitrate&&this.log(`Unstable Pathways change from bitrate ${s.bitrate} to ${e.bitrate}`),this.hls.nextLoadLevel=n);break}}}getPathwayForGroupId(e,t,i){let r=this.getLevelsForPathway(i).concat(this.levels||[]);for(let i=0;i<r.length;i++)if(t===Ri.AUDIO_TRACK&&r[i].hasAudioGroup(e)||t===Ri.SUBTITLE_TRACK&&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:a,"BASE-ID":n,"URI-REPLACEMENT":s}=e;if(t.some(e=>e.pathwayId===a))return;let o=this.getLevelsForPathway(n).map(e=>{let t=new ds(e.attrs);t["PATHWAY-ID"]=a;let n=t.AUDIO&&`${t.AUDIO}_clone_${a}`,o=t.SUBTITLES&&`${t.SUBTITLES}_clone_${a}`;n&&(i[t.AUDIO]=n,t.AUDIO=n),o&&(r[t.SUBTITLES]=o,t.SUBTITLES=o);let l=sh(e.uri,t["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",s),d=new Za({attrs:t,audioCodec:e.audioCodec,bitrate:e.bitrate,height:e.height,name:e.name,url:l,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_${a}`);if(e.subtitleGroups)for(let t=1;t<e.subtitleGroups.length;t++)d.addGroupId("text",`${e.subtitleGroups[t]}_clone_${a}`);return d});t.push(...o),nh(this.audioTracks,i,s,a),nh(this.subtitleTracks,r,s,a)})}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{return this.enabled=!1,void this.log(`Failed to parse Steering Manifest URI: ${e}`)}if("data:"!==t.protocol){let e=0|(this.hls.bandwidthEstimate||i.abrEwmaDefaultEstimate);Wa(t,"_HLS_pathway",this.pathwayId),Wa(t,"_HLS_throughput",""+e)}let a={type:Ri.STEERING_MANIFEST,responseType:"json",url:t.href},n=i.steeringManifestLoadPolicy.default,s=n.errorRetry||n.timeoutRetry||{},o={loadPolicy:n,timeout:n.maxLoadTimeMs,maxRetry:s.maxNumRetry||0,retryDelay:s.retryDelayMs||0,maxRetryDelay:s.maxRetryDelayMs||0},l={onSuccess:(e,i,r,a)=>{this.log(`Loaded steering manifest: "${t}"`);let n=e.data;if(1!==(null==n?void 0:n.VERSION))return void this.log(`Steering VERSION ${n.VERSION} not supported!`);this.updated=performance.now(),this.timeToLoad=n.TTL;let{"RELOAD-URI":s,"PATHWAY-CLONES":o,"PATHWAY-PRIORITY":l}=n;if(s)try{this.uri=new self.URL(s,t).href}catch{return this.enabled=!1,void this.log(`Failed to parse Steering Manifest RELOAD-URI: ${s}`)}this.scheduleRefresh(this.uri||r.url),o&&this.clonePathways(o);let d={steeringManifest:n,url:t.toString()};this.hls.trigger(Ai.STEERING_MANIFEST_LOADED,d),l&&this.updatePathwayPriority(l)},onError:(e,t,i,r)=>{if(this.log(`Error loading steering manifest: ${e.code} ${e.text} (${t.url})`),this.stopLoad(),410===e.code)return this.enabled=!1,void this.log(`Steering manifest ${t.url} no longer available`);let a=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&&(a=1e3*parseFloat(t))}return void this.log(`Steering manifest ${t.url} rate limited`)}this.scheduleRefresh(this.uri||t.url,a)},onTimeout:(e,t,i)=>{this.log(`Timeout loading steering manifest (${t.url})`),this.scheduleRefresh(this.uri||t.url)}};this.log(`Requesting steering manifest: ${t}`),this.loader.load(a,o,l)}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.scheduleRefresh(e,1e3*this.timeToLoad):this.loadSteeringManifest(e)},t)}},iframeController:class extends tr{constructor(e,t){super("iframes",e.logger),this.hls=void 0,this.stats=void 0,this.variableList=null,this.initPTS=[],this.iframeInstances=void 0,this.instanceCounter=0,Xh||(Xh=function(e){return class extends e{constructor(e,t,i,r){e.streamController||(e.streamController=rc),super(e),this._url=t,this.streamController.setInitPts(i),this.streamController.initDetails=r}loadSource(){}loadMediaAt(e,t=sc){if(e<0)return;let i=Gi(Gi({},sc),t);this.loadingEnabled||this.startLoad(e),this.streamController.loadMediaAt(e,i)}}}(t)),Zh||(Zh=function(e){return class extends e{constructor(e,t,i,r){e.cmcdController=void 0,e.emeController=void 0,e.streamController||(e.streamController=ac),e.capLevelController=void 0,e.bufferController=void 0,super(e,t,i,r)}attachImage(e){this.streamController.image=e}detachImage(){this.streamController.image=void 0}loadSource(){}attachMedia(){throw new Error(nc)}detachMedia(){}recoverMediaError(){}transferMedia(){return null}loadMediaAt(e){if(e<0)return null;this.loadingEnabled||this.startLoad(e),this.streamController.loadMediaAt(e)}}}(Xh)),this.hls=e,this.iframeInstances=[],this.registerListeners()}registerListeners(){let e=this.hls;e&&(e.on(Ai.MANIFEST_LOADING,this.clearAsset,this),e.on(Ai.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(Ai.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(Ai.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(Ai.FRAG_BUFFERED,this.onFragBuffered,this),e.on(Ai.DESTROYING,this.onDestroying,this))}unregisterListeners(){let e=this.hls;e&&(e.off(Ai.MANIFEST_LOADING,this.clearAsset,this),e.off(Ai.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(Ai.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(Ai.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(Ai.FRAG_BUFFERED,this.onFragBuffered,this),e.off(Ai.DESTROYING,this.onDestroying,this))}clearAsset(){this.stats=void 0,this.variableList=null,this.initPTS=[],this.iframeInstances.forEach(e=>e.destroy()),this.iframeInstances.length=0}onDestroying(){this.unregisterListeners(),this.clearAsset(),this.hls=void 0}onManifestLoaded(e,t){this.stats=t.stats,this.variableList=t.variableList}onLevelsUpdated(e,{levels:t}){var i;let r=null==(i=this.hls)?void 0:i.pathwayPriority;t.length&&r&&this.iframeInstances.forEach(e=>{e.pathwayPriority=r})}onInitPtsFound(e,{id:t,timestampOffsets:i}){t===Li.MAIN&&(this.initPTS=i)}onFragBuffered(e,t){var i;let r=this.hls;r&&r.hasEnoughToStart&&((null==(i=r.mainForwardBufferInfo)?void 0:i.len)||0)>10&&this.iframeInstances.forEach(e=>{var t;e.loadingEnabled||e.startLoad((null==(t=this.hls)||null==(t=t.media)?void 0:t.currentTime)||0)})}createIFramePlayer(e){var t;return this.createInstance(Xh,null==(t=this.hls)?void 0:t.iframeVariants,e)}createImageIFramePlayer(e){var t;let i=null==(t=this.hls)?void 0:t.iframeVariants.filter(e=>e.imageCodec);return this.createInstance(Zh,i,e,"image-")}createInstance(e,t,i,r){let{hls:a}=this;if(!a)return null;let{url:n,userConfig:s,latestLevelDetails:o,loadLevelObj:l,loadLevel:d,bandwidthEstimate:u,sessionId:h}=a,{stats:c,variableList:m}=this;if(null==t||!t.length||!c||!n)return null;let f=`${r||""}iframe-player-${this.instanceCounter++}`,p=a.levels,g=l||p[d],v=cn(g,s.videoPreference),E=(null==g?void 0:g.pathwayId)||".",y=new e(Gi(Gi({},s),{},{loggerId:f,primarySessionId:h,videoPreference:v,abrEwmaDefaultEstimate:u,streamController:void 0,audioStreamController:void 0,audioTrackController:void 0,subtitleStreamController:void 0,subtitleTrackController:void 0,timelineController:void 0,id3TrackController:void 0,fpsController:void 0,gapController:void 0,iframeController:void 0,cmcd:void 0,interstitialsController:void 0,backBufferLength:1/0,maxMaxBufferLength:1,capLevelToPlayerSize:!0,enableWorker:!1,autoStartLoad:!1,startFragPrefetch:!1,testBandwidth:!1,progressive:!1},i),n,this.initPTS,o);return this.iframeInstances=this.iframeInstances.filter(e=>!e.url),this.iframeInstances.push(y),y.trigger(Ai.MANIFEST_LOADED,{levels:t,contentSteering:{uri:"",pathwayId:E},sessionKeys:null,audioTracks:[],iframeVariants:[],sessionData:null,startTimeOffset:null,stats:c,networkDetails:null,url:n,variableList:m}),y}},interstitialsController:class extends tr{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.bufferPastEdge=!1,this.shouldPlay=!1,this.onPlay=()=>{this.shouldPlay=!0},this.onPause=()=>{this.shouldPlay=!1},this.onSeeking=()=>{let e=this.currentTime;if(void 0===e||this.playbackDisabled||!this.schedule)return;let t=e-this.timelinePos;if(Math.abs(t)<1/7056e5)return;let i=t<=-.01;-1===this.timelinePos&&!this.effectivePlayingItem&&this.checkStart(),this.timelinePos=e,this.bufferedPos=e;let r=this.playingItem;if(!r)return void this.checkBuffer();if(i&&this.schedule.resetErrorsInRange(e,e-t)&&this.updateSchedule(!0),this.checkBuffer(),i&&e<r.start||e>=r.end){var a;let t=this.findItemIndex(r),n=this.schedule.findItemIndexAtTime(e);if(-1===n&&(n=t+(i?-1:1),this.log(`seeked ${i?"back ":""}to position not covered by schedule ${e} (resolving from ${t} to ${n})`)),!this.isInterstitial(r)&&null!=(a=this.media)&&a.paused&&(this.shouldPlay=!1),!i&&n>t){let e=this.schedule.findJumpRestrictedIndex(t+1,n);if(e>t)return void this.setSchedulePosition(e)}return void this.setSchedulePosition(n)}let n=this.playingAsset;if(!n){if(this.playingLastItem&&this.isInterstitial(r)){let t=r.event.assetList[0];t&&(this.endedItem=this.playingItem,this.playingItem=null,this.setScheduleToAssetAtTime(e,t))}return}let s=n.timelineStart,o=n.duration||0;var l;(i&&e<s||e>=s+o)&&(null!=(l=r.event)&&l.appendInPlace&&(this.clearAssetPlayers(r.event,r),this.flushFrontBuffer(e)),this.setScheduleToAssetAtTime(e,n))},this.onTimeupdate=()=>{let e=this.currentTime;if(void 0===e||this.playbackDisabled)return;if(-1===this.timelinePos&&!this.effectivePlayingItem&&this.checkStart(),!(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,a=i.events||[],n=i.items||[],s=i.durations,o=e.map(e=>e.identifier),l=!(!a.length&&!o.length);(l||t)&&this.log(`INTERSTITIALS_UPDATED (${a.length}): ${a}\nSchedule: ${n.map(e=>yc(e))} pos: ${this.timelinePos}`),o.length&&this.log(`Removed events ${o}`);let d=null,u=null;r&&(d=this.updateItem(r,this.timelinePos),this.itemsMatch(r,d)?this.playingItem=d:this.waitingItem=null),this.waitingItem=this.updateItem(this.waitingItem);let h=this.bufferingItem;if(h&&(u=this.updateItem(h,this.bufferedPos),this.itemsMatch(h,u)?this.bufferingItem=u:h.event&&(this.bufferingItem=this.playingItem,this.clearInterstitial(h.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)>oc&&this.warn(`${r} ("${e.assetId}" ${e.timelineOffset}->${t})`)}}}),l||t){if(this.hls.trigger(Ai.INTERSTITIALS_UPDATED,{events:a.slice(0),schedule:n.slice(0),durations:s,removedIds:o}),this.isInterstitial(r)&&o.indexOf(r.event.identifier)>-1)return this.warn(`Interstitial "${r.event.identifier}" removed while playing`),void this.primaryFallback(r.event);r&&this.trimInPlace(d,r),h&&u!==d&&this.trimInPlace(u,h),this.checkBuffer()}},this.hls=e,this.HlsPlayerClass=t,this.assetListLoader=new bc(e),this.schedule=new Ec(this.onScheduleUpdate,e.logger),this.registerListeners()}registerListeners(){let e=this.hls;e&&(e.on(Ai.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(Ai.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Ai.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Ai.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Ai.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(Ai.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(Ai.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.on(Ai.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(Ai.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.on(Ai.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.on(Ai.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.on(Ai.BUFFER_APPENDED,this.onBufferAppended,this),e.on(Ai.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(Ai.BUFFERED_TO_END,this.onBufferedToEnd,this),e.on(Ai.MEDIA_ENDED,this.onMediaEnded,this),e.on(Ai.ERROR,this.onError,this),e.on(Ai.DESTROYING,this.onDestroying,this))}unregisterListeners(){let e=this.hls;e&&(e.off(Ai.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(Ai.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Ai.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Ai.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Ai.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(Ai.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(Ai.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.off(Ai.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(Ai.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.off(Ai.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.off(Ai.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.off(Ai.BUFFER_CODECS,this.onBufferCodecs,this),e.off(Ai.BUFFER_APPENDED,this.onBufferAppended,this),e.off(Ai.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(Ai.BUFFERED_TO_END,this.onBufferedToEnd,this),e.off(Ai.MEDIA_ENDED,this.onMediaEnded,this),e.off(Ai.ERROR,this.onError,this),e.off(Ai.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=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){Eo(e,"play",this.onPlay),Eo(e,"pause",this.onPause),Eo(e,"seeking",this.onSeeking),Eo(e,"timeupdate",this.onTimeupdate)}onMediaAttaching(e,t){let i=this.media=t.media;vo(i,"seeking",this.onSeeking),vo(i,"timeupdate",this.onTimeupdate),vo(i,"play",this.onPlay),vo(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=()=>e.bufferingItem||e.waitingItem,i=t=>t&&e.getAssetPlayer(t.identifier),r=(t,r,n,s,o)=>{if(t){let l=t[r].start,d=t.event;if(d){if("playout"===r||d.timelineOccupancy!==lc.Point){let e=i(n);(null==e?void 0:e.interstitial)===d&&(l+=e.assetItem.startOffset+e[o])}}else{l+=("bufferedPos"===s?a():e[s])-t.start}return l}return 0},a=()=>{let t=e.bufferedPos;return t===Number.MAX_VALUE?n("primary"):Math.max(t,0)},n=t=>{var i,r;return null!=(i=e.primaryDetails)&&i.live?e.primaryDetails.edge:(null==(r=e.schedule)?void 0:r.durations[t])||0},s=(t,a)=>{var n,s;let o=e.effectivePlayingItem;if(null!=o&&null!=(n=o.event)&&n.restrictions.skip||!e.schedule)return;e.log(`seek to ${t} "${a}"`);let l=e.effectivePlayingItem,d=e.schedule.findItemIndexAtTime(t,a),u=null==(s=e.schedule.items)?void 0:s[d],h=e.getBufferingPlayer(),c=null==h?void 0:h.interstitial,m=null==c?void 0:c.appendInPlace,f=l&&e.itemsMatch(l,u);if(l&&(m||f)){let n=i(e.playingAsset),s=(null==n?void 0:n.media)||e.primaryMedia;if(s){let i="primary"===a?s.currentTime:r(l,a,e.playingAsset,"timelinePos","currentTime"),o=t-i,d=(m?i:s.currentTime)+o;if(d>=0&&(!n||m||d<=n.duration))return void(s.currentTime=d)}}if(u){let i=t;if("primary"!==a){let e=t-u[a].start;i=u.start+e}let r=!e.isInterstitial(u);if(e.isInterstitial(l)&&!l.event.appendInPlace||!r&&!u.event.appendInPlace){if(l){let n=e.findItemIndex(l);if(d>n){let t=e.schedule.findJumpRestrictedIndex(n+1,d);if(t>n)return void e.setSchedulePosition(t)}let s=0;if(r)e.timelinePos=i,e.checkBuffer();else{let e=u.event.assetList,i=t-(u[a]||u).start;for(let t=e.length;t--;){let r=e[t];if(r.duration&&i>=r.startOffset&&i<r.startOffset+r.duration){s=t;break}}}e.setSchedulePosition(d,s)}}else{let t=e.media||(m?null==h?void 0:h.media:null);t&&(t.currentTime=i)}}},o=()=>{let i=e.effectivePlayingItem;if(e.isInterstitial(i))return i;let r=t();return e.isInterstitial(r)?r:null},l={get bufferedEnd(){let i=t(),a=e.bufferingItem;var n;return a&&a===i&&(r(a,"playout",e.bufferingAsset,"bufferedPos","bufferedEnd")-a.playout.start||(null==(n=e.bufferingAsset)?void 0:n.startOffset))||0},get currentTime(){let t=o(),i=e.effectivePlayingItem;return i&&i===t?r(i,"playout",e.effectivePlayingAsset,"timelinePos","currentTime")-i.playout.start:0},set currentTime(t){let i=o(),r=e.effectivePlayingItem;r&&r===i&&s(t+r.playout.start,"playout")},get duration(){let e=o();return e?e.playout.end-e.playout.start:0},get assetPlayers(){var t;let i=null==(t=o())?void 0:t.event.assetList;return i?i.map(t=>e.getAssetPlayer(t.identifier)):[]},get playingIndex(){var t;let i=null==(t=o())?void 0:t.event;return i&&e.effectivePlayingAsset?i.findAssetIndex(e.effectivePlayingAsset):-1},get scheduleItem(){return o()}};return this.manager={get events(){var t;return(null==(t=e.schedule)||null==(t=t.events)?void 0:t.slice(0))||[]},get schedule(){var t;return(null==(t=e.schedule)||null==(t=t.items)?void 0:t.slice(0))||[]},get interstitialPlayer(){return o()?l:null},get playerQueue(){return e.playerQueue.slice(0)},get bufferingAsset(){return e.bufferingAsset},get bufferingItem(){return t()},get bufferingIndex(){let i=t();return e.findItemIndex(i)},get playingAsset(){return e.effectivePlayingAsset},get playingItem(){return e.effectivePlayingItem},get playingIndex(){let t=e.effectivePlayingItem;return e.findItemIndex(t)},primary:{get bufferedEnd(){return a()},get currentTime(){let t=e.timelinePos;return t>0?t:0},set currentTime(e){s(e,"primary")},get duration(){return n("primary")},get seekableStart(){return e.seekableStart}},integrated:{get bufferedEnd(){return r(t(),"integrated",e.bufferingAsset,"bufferedPos","bufferedEnd")},get currentTime(){return r(e.effectivePlayingItem,"integrated",e.effectivePlayingAsset,"timelinePos","currentTime")},set currentTime(e){s(e,"integrated")},get duration(){return n("integrated")},get seekableStart(){return((t,i)=>{var r;if(0!==t&&"primary"!==i&&null!=(r=e.schedule)&&r.length){var a;let r=e.schedule.findItemIndexAtTime(t),n=null==(a=e.schedule.items)?void 0:a[r];if(n)return t+(n[i].start-n.start)}return t})(e.seekableStart,"integrated")}},skip:()=>{let t=e.effectivePlayingItem,i=null==t?void 0:t.event;if(i&&!i.restrictions.skip){let r=e.findItemIndex(t);if(i.appendInPlace){let e=t.playout.start+t.event.duration;s(e+.001,"playout")}else 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 a=null==(t=r)?void 0:t.currentTime;return void 0!==a&&vi(a)?a:void 0}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)return void(this.detachedData={media:r});let i=e.transferMedia();this.log(`transfer MediaSource from ${e} ${tn(i)}`),this.detachedData=i}else t&&r&&(this.shouldPlay||(this.shouldPlay=!r.paused))}transferMediaTo(e,t){var i,r;if(e.media===t)return;let a,n=null,s=this.hls,o=e!==s,l=o&&e.interstitial.appendInPlace,d=null==(i=this.detachedData)?void 0:i.mediaSource;if(s.media)l&&(n=s.transferMedia(),this.detachedData=n),a="Primary";else{let e=this.getBufferingPlayer();e?(n=e.transferMedia(),this.detachedData=n,a=`${e}`):a=d?"detached MediaSource":"detached media"}if(!n)if(d)n=this.detachedData,this.log(`using detachedData: MediaSource ${tn(n)}`);else if(!this.detachedData||s.media===t){let e=this.playerQueue;e.length>1&&e.forEach(e=>{if(o&&e.interstitial.appendInPlace!==l){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 u=n&&"mediaSource"in n&&"closed"!==(null==(r=n.mediaSource)?void 0:r.readyState);if(this.log(`${u?"transfering MediaSource":"attaching media"} to ${o?e:"Primary"} from ${a} (media.currentTime: ${t.currentTime})`),!u&&!o)return void e.attachMedia(t);let h=u&&n?Gi({},n):{media:t},c=this.schedule;if(c&&o){let t=e.assetId===c.assetIdAtEnd;h.overrides={duration:c.duration,endOfStream:t||!1===e.appendInPlace}}if(!u&&l){let t=e,i=t.assetItem.timelineStart;if(i){let e=t.hls,r=Math.max(this.timelinePos-i,Number.EPSILON);e.startPosition!==r&&(this.log(`Set ${t} startPosition: ${r}`),e.config.startPosition=r,e.loadingEnabled&&e.startLoad(r))}}e.attachMedia(h)}onInterstitialCueEnter(){this.onTimeupdate()}checkStart(){let e=this.schedule,t=null==e?void 0:e.events,i=this.hls;if(!t||this.playbackDisabled||!this.media||!i)return;-1===this.bufferedPos&&(this.bufferedPos=0);let r=this.timelinePos,a=this.effectivePlayingItem;if(-1===r){if(!i.loadingEnabled)return void this.log("waiting for startLoad( <startPosition> )");let r=i.startPosition;if(this.timelinePos=r,0===t.length)this.setSchedulePosition(0);else if(t[0].cue.pre){this.log(Ac("checkStart (preroll)",r));let i=e.findEventIndex(t[0].identifier);this.setSchedulePosition(i)}else if(r>=0||!this.primaryLive){this.log(Ac("checkStart",r));let t=this.timelinePos=r>0?r:0,i=e.findItemIndexAtTime(t);this.setSchedulePosition(i)}else 0===i.liveSyncPosition?this.setSchedulePosition(0):this.log("[checkStart] waiting for live start")}else if(a&&!this.playingItem){this.log(Ac("checkStart (playing item)",a.start));let t=e.findItemIndex(a);this.setSchedulePosition(t)}}advanceAssetBuffering(e,t){let i=e.event,r=i.findAssetIndex(t),a=fc(i,r);if(i.isAssetPastPlayoutLimit(a)){if(this.schedule){var n;let t=this.getNextItemIndex(e,!0),i=null==(n=this.schedule.items)?void 0:n[t];i&&this.bufferedToItem(i)}}else this.bufferedToEvent(e,a)}livePrerollResumption(e,t){if(e.cue.pre&&this.primaryLive&&!vi(e.resumeOffset)&&this.hls){let e=this.getLiveStartPos();if(t){let t=this.getBufferingPlayer();return e+(null!=t&&t.interstitial.cue.pre?t.remaining:0)}return e}}getNextItemIndex(e,t){if(this.schedule){let i=this.livePrerollResumption(e.event,t);if(void 0!==i)return this.log(`find next item index @${i}`),this.schedule.findItemIndexAtTime(i)}return this.findItemIndex(e)+1}advanceAfterAssetEnded(e,t,i){let r=fc(e,i);if(e.isAssetPastPlayoutLimit(r)){if(this.schedule){let i=this.schedule.items;if(i){let r=i[t],a=r.event?this.getNextItemIndex(r):t+1;if(a>=i.length)return void this.setSchedulePosition(-1);let n=e.resumeTime;this.timelinePos<n&&(this.log(Ac("advanceAfterAssetEnded",n)),this.timelinePos=n,e.appendInPlace&&!i[a].event&&this.hls.startLoad(n+.01),this.checkBuffer(this.bufferedPos<n)),this.setSchedulePosition(a)}}}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,a=i.getEvent(r);if(a){let t=i.findEventIndex(r),n=i.findAssetIndex(a,e);this.advanceAfterAssetEnded(a,t,n-1)}}setSchedulePosition(e,t){var i;let r=null==(i=this.schedule)?void 0:i.items;if(!r||this.playbackDisabled)return;let a=e>=0?r[e]:null;this.log(`setSchedulePosition ${e}, ${t} (${a&&yc(a)}) pos: ${this.timelinePos}`);let n=this.waitingItem||this.playingItem,s=this.playingLastItem;if(this.isInterstitial(n)){let i=n.event,u=this.playingAsset,h=null==u?void 0:u.identifier,c=h?this.getAssetPlayer(h):null;if(c&&h&&(!this.eventItemsMatch(n,a)||void 0!==t&&h!==i.assetList[t].identifier)){var o;let t=i.findAssetIndex(u);if(this.log(`INTERSTITIAL_ASSET_ENDED ${t+1}/${i.assetList.length} ${pc(u)}`),this.endedAsset=u,this.playingAsset=null,this.hls.trigger(Ai.INTERSTITIAL_ASSET_ENDED,{asset:u,assetListIndex:t,event:i,schedule:r.slice(0),scheduleIndex:e,player:c}),n!==this.playingItem)return void(this.itemsMatch(n,this.playingItem)&&!this.playingAsset&&this.advanceAfterAssetEnded(i,this.findItemIndex(this.playingItem),t));this.retreiveMediaSource(h,a),c.media&&(null==(o=this.detachedData)||!o.mediaSource)&&c.detachMedia()}if(!this.eventItemsMatch(n,a)&&(this.endedItem=n,this.playingItem=this.waitingItem=null,this.log(`INTERSTITIAL_ENDED ${i} ${yc(n)}`),i.hasPlayed=!0,this.hls.trigger(Ai.INTERSTITIAL_ENDED,{event:i,schedule:r.slice(0),scheduleIndex:e}),i.cue.once&&this.hls)){var l;this.updateSchedule();let e=null==(l=this.schedule)?void 0:l.items;if(a&&e){let o=this.findItemIndex(a),l=this.livePrerollResumption(i);if(void 0!==l){let t=l,a=this.getNextItemIndex(n);if(!this.isInterstitial(r[a])){var d;let e=null==(d=this.primaryDetails)?void 0:d.fragments;if(i.snapOptions.in&&e){let i=fn(null,e,l);i&&(t=Math.min(Math.max(r[a].start,hc(t,i)),r[a].end))}}if(this.log(Ac("live join (preroll)",t)),this.timelinePos=t,a!==o&&(a||0===a))return void this.advanceSchedule(a,e,void 0,n,s)}this.advanceSchedule(o,e,t,n,s)}return}}this.advanceSchedule(e,r,t,n,s)}advanceSchedule(e,t,i,r,a){let n=this.schedule;if(!n)return;let s=t[e]||null,o=this.primaryMedia,l=this.playerQueue;if(l.length&&l.forEach(t=>{let i=t.interstitial,r=n.findEventIndex(i.identifier);(r<e||r>e+1)&&this.clearInterstitial(i,s)}),this.isInterstitial(s)){this.timelinePos=Math.min(Math.max(this.timelinePos,s.start),s.end);let a=s.event;if(void 0===i){let t=fc(a,(i=a.cue.pre?0:n.findAssetIndex(a,this.timelinePos))-1);if(a.isAssetPastPlayoutLimit(t)||a.appendInPlace&&this.timelinePos===s.end)return void this.advanceAfterAssetEnded(a,e,i);i=t}let l=this.waitingItem;this.assetsBuffered(s,o)||this.setBufferingItem(s);let d=this.preloadAssets(a,i);if(this.eventItemsMatch(s,l||r)||(this.waitingItem=s,this.log(`INTERSTITIAL_STARTED ${yc(s)} ${a.appendInPlace?"append in place":""}`),a.hasPlayed=!1,this.hls.trigger(Ai.INTERSTITIAL_STARTED,{event:a,schedule:t.slice(0),scheduleIndex:e})),!a.assetListLoaded)return void this.log(`Waiting for ASSET-LIST to complete loading ${a}`);if(a.assetListLoader&&(a.assetListLoader.destroy(),a.assetListLoader=void 0),!o)return void this.log(`Waiting for attachMedia to start Interstitial ${a}`);this.waitingItem=this.endedItem=null,this.playingItem=s;let u=a.assetList[i];if(!u)return void this.advanceAfterAssetEnded(a,e,i||0);if(d||(d=this.getAssetPlayer(u.identifier)),null===d||d.destroyed){let e=a.assetList.length;this.warn(`asset ${i+1}/${e} player destroyed ${a}`),d=this.createAssetPlayer(a,u,i),d.loadSource()}if(!this.eventItemsMatch(s,this.bufferingItem)&&a.appendInPlace&&this.isAssetBuffered(u))return;this.startAssetPlayer(d,i,t,e,o),this.shouldPlay&&Tc(d.media)}else s?(this.resumePrimary(s,e,r),this.shouldPlay&&Tc(this.hls.media)):a&&this.isInterstitial(r)&&(this.endedItem=null,this.playingItem=r,r.event.appendInPlace||this.attachPrimary(n.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,a;this.playingItem=e,this.playingAsset=this.endedAsset=null,this.waitingItem=null,this.bufferedToItem(e),this.endedItem=null,this.log(`resuming ${yc(e)}`);let n=this.timelinePos;if(null!=(r=this.detachedData)&&r.mediaSource?this.primaryLive&&this.startLoadingPrimaryAt(n):((n<e.start||n>=e.end||n<this.seekableStart)&&(n=this.getPrimaryResumption(e,t),this.log(Ac("resumePrimary",n)),this.timelinePos=n),this.attachPrimary(n,e)),!i)return;let s=null==(a=this.schedule)?void 0:a.items;s&&(this.log(`INTERSTITIALS_PRIMARY_RESUMED ${yc(e)}`),this.hls.trigger(Ai.INTERSTITIALS_PRIMARY_RESUMED,{schedule:s.slice(0),scheduleIndex:t}),this.checkBuffer())}get seekableStart(){var e;return this.primaryLive&&(null==(e=this.primaryDetails)?void 0:e.fragmentStart)||0}getPrimaryResumption(e,t,i){let r=e.start;if(this.primaryLive){if(0===t)return this.hls.startPosition;let e=this.endedItem||this.playingItem,a=null!=e&&e.event?this.livePrerollResumption(e.event,i):void 0;if(void 0!==a)return a;let n=this.primaryDetails;if(n){let{fragmentStart:e,edge:t}=n;if(r<e||r>t&&!i){let i=this.hls.liveSyncPosition;return this.log(`primary resumption out of bounds (${r} [${e}-${t}]) snapping to liveSync ${i}`),i||e}}}return this.log(`primary resumption itemStart: ${r}`),r}getLiveStartPos(){var e;let t=this.hls.startPosition,i=this.hls.liveSyncPosition||0,r=3*((null==(e=this.primaryDetails)?void 0:e.targetduration)||10);return-1===t||i&&i-t<r?i||0:t}isAssetBuffered(e){let t=this.getAssetPlayer(e.identifier);return null!=t&&t.hls?t.hls.bufferedToEnd:ts.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 a=this.hls;a.media?this.checkBuffer():(this.transferMediaTo(a,r),i&&this.startLoadingPrimaryAt(e,i)),i||(this.log(Ac("attachPrimary",e)),this.timelinePos=e,this.startLoadingPrimaryAt(e,i))}startLoadingPrimaryAt(e,t){let i=this.hls,{loadingEnabled:r,bufferingEnabled:a,startPosition:n}=i,s=i.hasEnoughToStart;if(this.log(`Start loading primary @${e} bufferedPos: ${this.bufferedPos} startPosition: ${n} skip seek: ${t} has enough ${s} loadingEnabled: ${r} bufferingEnabled: ${a}`),!t&&s||!r||Math.abs(n-e)>.1){let r=this.primaryDetails;if(null!=r&&r.live&&e+.5>=r.edge){let t=this.bufferingItem;return this.log(`Resume primary loading when live passes ${e} buffering item: ${t?yc(t):null}`),i.pauseBuffering(),void(this.bufferPastEdge=!0)}i.startLoad(e,t)}else a||i.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(Ai.BUFFER_CODECS,this.onBufferCodecs,this),this.hls.on(Ai.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=Gi(Gi({},this.mediaSelection||this.altSelection),{},{main:i});this.mediaSelection=r;let a=this.hls.startPosition;if(this.schedule.parseInterstitialDateRanges(r,this.hls.config.interstitialAppendInPlace,-1===a?0:a),this.schedule.items)if(this.effectivePlayingItem){if(this.bufferPastEdge){let e=this.primaryDetails,t=this.bufferedPos;if(null!=e&&e.live&&t+.5<e.edge){this.bufferPastEdge=!1;let i=this.bufferingItem;if(this.log(`Live edge ${e.edge} passed buffer: ${t} buffering item: ${i?yc(i):null}`),(null==i?void 0:i.end)===1/0){let e=this.playingItem,r=this.isInterstitial(e)&&e.event.appendInPlace;this.hls.startLoad(Math.max(t,i.start),r)}else{let e=this.getBufferingPlayer();e&&e.bufferedInPlaceToEnd(this.primaryMedia,e.currentTime)&&e.hls&&e.hls.trigger(Ai.BUFFERED_TO_END,void 0)}}}}else this.checkStart()}onAudioTrackUpdated(e,t){let i=this.hls.audioTracks[t.id],r=this.mediaSelection;if(!r)return void(this.altSelection=Gi(Gi({},this.altSelection),{},{audio:i}));let a=Gi(Gi({},r),{},{audio:i});this.mediaSelection=a}onSubtitleTrackUpdated(e,t){let i=this.hls.subtitleTracks[t.id],r=this.mediaSelection;if(!r)return void(this.altSelection=Gi(Gi({},this.altSelection),{},{subtitles:i}));let a=Gi(Gi({},r),{},{subtitles:i});this.mediaSelection=a}onAudioTrackSwitching(e,t){let i=nn(t);this.playerQueue.forEach(({hls:e})=>e&&(e.setAudioOption(t)||e.setAudioOption(i)))}onSubtitleTrackSwitch(e,t){let i=nn(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 i=t[e];if(i.cue.post){let e=this.getEventItem(i.identifier);e&&this.eventItemsMatch(e,this.bufferingItem)&&this.bufferedToItem(e,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;if(e&&r){return r[this.findItemIndex(e,t)]||null}return 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=ts.bufferInfo(this.primaryMedia,i,0);(r.end>i||(r.nextStart||0)>i)&&(this.log(`trim buffered interstitial ${yc(e)} (was ${yc(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))}findEventIndex(e){return this.schedule?this.schedule.findEventIndex(e):-1}getEventItem(e){if(this.schedule){var t;let i=null==(t=this.schedule.items)?void 0:t[this.findEventIndex(e)];if(this.isInterstitial(i)&&i.event.identifier===e)return i}}findItemIndex(e,t){return e&&this.schedule?this.schedule.findItemIndex(e,t):-1}updateSchedule(e=!1){var t,i;let r=this.mediaSelection;if(!r)return;let a=(null==(t=this.hls)?void 0:t.liveSyncPosition)||0;null==(i=this.schedule)||i.updateSchedule(r,[],a,e)}checkBuffer(e){var t;let i=null==(t=this.schedule)?void 0:t.items;if(!i)return;let r=ts.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,a=this.bufferingItem;if(this.bufferedPos>e||!r)return;if(1===t.length&&this.itemsMatch(t[0],a))return void(this.bufferedPos=e);let n=this.playingItem,s=this.findItemIndex(n),o=r.findItemIndexAtTime(e);if(this.bufferedPos<e){var l;let i=this.findItemIndex(a),r=Math.min(i+1,t.length-1),n=t[r];if((-1===o&&a&&e>=a.end||null!=(l=n.event)&&l.appendInPlace&&e+.01>=n.start)&&(o=r),this.isInterstitial(a)){let e=a.event;if(r-s>1&&!1===e.appendInPlace||0===e.assetList.length&&e.assetListLoader)return}if(this.bufferedPos=e,o>i&&o>s)this.bufferedToItem(n);else{let t=this.primaryDetails;this.primaryLive&&t&&e>t.edge-t.targetduration&&n.start<t.edge+this.hls.config.interstitialLiveLookAhead&&this.isInterstitial(n)&&this.preloadAssets(n.event,0)}}else i&&n&&!this.itemsMatch(n,a)&&(o===s?this.bufferedToItem(n):o===s+1&&this.bufferedToItem(t[o]))}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:a}=i;if(!r||!a)return t;let n=this.isInterstitial(e),s=this.getBufferingPlayer();this.bufferingItem=e,this.bufferedPos=Math.max(e.start,Math.min(e.end,this.timelinePos));let o=s?s.remaining:t?t.end-this.timelinePos:0;if(this.log(`INTERSTITIALS_BUFFERED_TO_BOUNDARY ${yc(e)}`+(t?` (${o.toFixed(2)} remaining)`:"")),!this.playbackDisabled)if(n){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(Ai.INTERSTITIALS_BUFFERED_TO_BOUNDARY,{events:a.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.getPrimaryResumption(e,this.findItemIndex(e),!0),i=this.bufferedPos=Math.max(t,Math.min(this.bufferedPos,e.end),this.timelinePos,e.start),r=this.detachedData;if(r)r.mediaSource?this.attachPrimary(i,e,!0):this.startLoadingPrimaryAt(i);else{let e=this.playingItem,t=this.isInterstitial(e)&&e.event.appendInPlace;this.startLoadingPrimaryAt(i,t)}}}bufferedToEvent(e,t){let i=e.event,r=0===i.assetList.length&&!i.assetListLoader,a=i.cue.once;if(r||!a){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,a=0===r&&!e.assetListLoader,n=e.cue.once;if(a){let a=e.timelineStart,n=this.playingItem,o=this.getBufferingPlayer();var s;if(e.appendInPlace)!this.isInterstitial(n)&&(null==n||null==(s=n.nextEvent)?void 0:s.identifier)===e.identifier&&this.flushFrontBuffer(a+.25);let l,d=0;if((!o||o.interstitial.cue.pre)&&this.primaryLive&&(d=this.getLiveStartPos(),o&&(d+=o.remaining)),d&&!e.cue.pre&&!e.cue.post){let e=d-a;e>0&&(l=Math.round(1e3*e)/1e3)}if(this.log(`Load interstitial asset ${t+1}/${i?1:r} ${e}${d?` live-start: ${d} start-offset: ${l} (timeline-start: ${a})`:""}`),i)return this.createAsset(e,0,0,a,e.duration,i);let u=this.assetListLoader.loadAssetList(e,l);u&&(e.assetListLoader=u)}else if(!n&&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;if(!t)return;let i=this.primaryDetails;i&&e>=i.edge||(this.log(`Removing front buffer starting at ${e}`),Object.keys(t).forEach(t=>{this.hls.trigger(Ai.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}getBufferingPlayer(){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,a,n){let s={parentIdentifier:e.identifier,identifier:dc(e,n,t),duration:a,startOffset:i,timelineStart:r,uri:n};return this.createAssetPlayer(e,s,t)}createAssetPlayer(e,t,i){let r=this.hls,a=r.userConfig,n=cn(r.loadLevelObj||r.levels[r.currentLevel],a.videoPreference),s=r.audioTracks[r.audioTrack],o=r.subtitleTracks[r.subtitleTrack],l=0;if(this.primaryLive||e.appendInPlace){let e=this.timelinePos-t.timelineStart;if(e>=0){let i=t.duration;i&&e<i&&(l=e)}}let d=t.identifier,u=Gi(Gi({},a),{},{maxMaxBufferLength:Math.min(15,r.config.maxMaxBufferLength),autoStartLoad:!0,startFragPrefetch:!0,primarySessionId:r.sessionId,assetPlayerId:d,abrEwmaDefaultEstimate:r.bandwidthEstimate,interstitialsController:void 0,startPosition:l,liveDurationInfinity:!1,testBandwidth:!1,videoPreference:n,audioPreference:s||a.audioPreference,subtitlePreference:o||a.subtitlePreference});e.appendInPlace&&(e.appendInPlaceStarted=!0,t.timelineStart&&(u.timelineOffset=t.timelineStart));let h=u.cmcd;null!=h&&h.sessionId&&h.contentId&&(u.cmcd=$i({},h,{contentId:Ah(t.uri)})),this.getAssetPlayer(d)&&this.warn(`Duplicate date range identifier ${e} and asset ${d}`);let c=new gc(this.HlsPlayerClass,u,e,t);this.playerQueue.push(c),e.assetList[i]=t;let m=!0,f=r=>{if(r.live){let t=new Error(`Interstitials MUST be VOD assets ${e}`),r={fatal:!0,type:bi.OTHER_ERROR,details:Ti.INTERSTITIAL_ASSET_ITEM_ERROR,error:t},a=this.findEventIndex(e.identifier);return void this.handleAssetItemError(r,e,a,i,t.message)}let a=r.edge-r.fragmentStart,n=t.duration;(m||null===n||a>n)&&(m=!1,this.log(`Interstitial asset "${d}" duration change ${n} > ${a}`),t.duration=a,this.updateSchedule())};c.on(Ai.LEVEL_UPDATED,(e,{details:t})=>f(t)),c.on(Ai.LEVEL_PTS_UPDATED,(e,{details:t})=>f(t)),c.on(Ai.EVENT_CUE_ENTER,()=>this.onInterstitialCueEnter());let p=(e,t)=>{let i=this.getAssetPlayer(d);if(i&&t.tracks){i.off(Ai.BUFFER_CODECS,p),i.tracks=t.tracks;let e=this.primaryMedia;this.bufferingAsset===i.assetItem&&e&&!i.media&&this.bufferAssetPlayer(i,e)}};c.on(Ai.BUFFER_CODECS,p);c.on(Ai.BUFFERED_TO_END,()=>{let t=this.getAssetPlayer(d);if(this.log(`buffered to end of asset ${t}`),!t||!this.schedule)return;let i=this.getEventItem(e.identifier);i&&this.advanceAssetBuffering(i,t.assetItem)});let g=t=>()=>{if(!this.getAssetPlayer(d)||!this.schedule)return;this.shouldPlay=!0;let i=this.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,i,t)};return c.once(Ai.MEDIA_ENDED,g(i)),c.once(Ai.PLAYOUT_LIMIT_REACHED,g(1/0)),c.on(Ai.ERROR,(t,r)=>{if(!this.schedule)return;let a=this.getAssetPlayer(d);if(r.details===Ti.BUFFER_STALLED_ERROR)return null!=a&&a.appendInPlace?void this.handleInPlaceStall(e):(this.onTimeupdate(),void this.checkBuffer(!0));r.details!==Ti.BUFFER_SEEK_OVER_HOLE&&this.handleAssetItemError(r,e,this.findEventIndex(e.identifier),i,`Asset player error ${r.error} ${e}`)}),c.on(Ai.DESTROYING,()=>{if(!this.getAssetPlayer(d)||!this.schedule)return;let t=new Error(`Asset player destroyed unexpectedly ${d}`),r={fatal:!0,type:bi.OTHER_ERROR,details:Ti.INTERSTITIAL_ASSET_ITEM_ERROR,error:t};this.handleAssetItemError(r,e,this.findEventIndex(e.identifier),i,t.message)}),this.log(`INTERSTITIAL_ASSET_PLAYER_CREATED ${pc(t)}`),this.hls.trigger(Ai.INTERSTITIAL_ASSET_PLAYER_CREATED,{asset:t,assetListIndex:i,event:e,player:c}),c}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&&yc(t)}`),this.transferMediaFromPlayer(e,t),this.playerQueue.splice(i,1),e.destroy()}}emptyPlayerQueue(){let e;for(;e=this.playerQueue.pop();)e.destroy();this.playerQueue=[]}startAssetPlayer(e,t,i,r,a){let{interstitial:n,assetItem:s,assetId:o}=e,l=n.assetList.length,d=this.playingAsset;this.endedAsset=null,this.playingAsset=s,(null==d?void 0:d.identifier)!==o&&(d&&(this.clearAssetPlayer(d.identifier,i[r]),delete d.error),this.log(`INTERSTITIAL_ASSET_STARTED ${t+1}/${l} ${pc(s)}`),this.hls.trigger(Ai.INTERSTITIAL_ASSET_STARTED,{asset:s,assetListIndex:t,event:n,schedule:i.slice(0),scheduleIndex:r,player:e})),this.bufferAssetPlayer(e,a)}bufferAssetPlayer(e,t){var i;if(!this.schedule)return;let{interstitial:r,assetItem:a}=e,n=this.getEventItem(r.identifier);if(!n)return;if(e.loadSource(),this.setBufferingItem(n),this.bufferingAsset=a,e.bufferedInPlaceToEnd(this.primaryMedia,e.currentTime))return void this.advanceAssetBuffering(n,a);let s=this.getBufferingPlayer();if(s===e)return;let o=r.appendInPlace;if(o&&!1===(null==s?void 0:s.interstitial.appendInPlace))return;let l=(null==s?void 0:s.tracks)||(null==(i=this.detachedData)?void 0:i.tracks)||this.requiredTracks;if(o&&a!==this.playingAsset){if(!e.tracks)return void this.log(`Waiting for track info before buffering ${e}`);if(l&&!dr(l,e.tracks)){let t=new Error(`Asset ${pc(a)} SourceBuffer tracks ('${Object.keys(e.tracks)}') are not compatible with primary content tracks ('${Object.keys(l)}')`),i={fatal:!0,type:bi.OTHER_ERROR,details:Ti.INTERSTITIAL_ASSET_ITEM_ERROR,error:t},n=r.findAssetIndex(a);return void this.handleAssetItemError(i,r,this.findEventIndex(r.identifier),n,t.message)}}this.transferMediaTo(e,t)}handleInPlaceStall(e){let t=this.schedule,i=this.primaryMedia;if(!t||!i)return;let r=i.currentTime,a=t.findAssetIndex(e,r),n=e.assetList[a];if(n){let s=this.getAssetPlayer(n.identifier);if(s){let o=s.currentTime||r-n.timelineStart,l=s.duration-o;if(this.warn(`Stalled at ${o} of ${o+l} in ${s} ${e} (media.currentTime: ${r})`),o&&(l/i.playbackRate<.5||s.bufferedInPlaceToEnd(i,s.currentTime))&&s.hls){let i=t.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,i,a)}}}}advanceInPlace(e){let t=this.primaryMedia;if(t&&t.currentTime<e){let i=`advance currentTime to ${e}, duration: ${t.duration}`;t.duration>e?(this.log(i),t.currentTime=e):this.log(`Cannot ${i}`)}}handleAssetItemError(e,t,i,r,a){if(e.details===Ti.BUFFER_STALLED_ERROR)return;let n=t.assetList[r]||null;if(this.warn(`INTERSTITIAL_ASSET_ERROR ${n&&pc(n)} ${e.error}`),!this.schedule)return;let s=(null==n?void 0:n.identifier)||"",o=this.getAssetPlayerQueueIndex(s),l=this.playerQueue[o]||null,d=this.schedule.items,u=$i({},e,{fatal:!1,errorAction:Cn(!0),asset:n,assetListIndex:r,event:t,schedule:d,scheduleIndex:i,player:l});if(this.hls.trigger(Ai.INTERSTITIAL_ASSET_ERROR,u),!e.fatal)return;let h=this.playingAsset,c=this.bufferingAsset,m=new Error(a);if(n&&(this.clearAssetPlayer(s,null),n.error=m),t.assetList.some(e=>!e.error))for(let e=r;e<t.assetList.length;e++)this.resetAssetPlayer(t.assetList[e].identifier);else t.error=m;this.updateSchedule(!0),t.error?this.primaryFallback(t):(null==h?void 0:h.identifier)===s?this.advanceAfterAssetEnded(t,i,r):(null==c?void 0:c.identifier)===s&&this.isInterstitial(this.bufferingItem)&&this.advanceAssetBuffering(this.bufferingItem,c)}primaryFallback(e){let t=e.timelineStart,i=this.effectivePlayingItem,r=this.playingItem,a=this.seekableStart,n=this.hls.startPosition,s=this.timelinePos;if(this.isInterstitial(i)){this.log(`Fallback to primary from event "${e.identifier}" start: ${t} pos: ${s} playing: ${yc(i)} startPosition: ${n} seekableStart: ${a} error: ${e.error}`),-1===s&&(s=n),s=Math.max(s,a);let r=this.updateItem(i,s);this.itemsMatch(i,r)&&this.clearInterstitial(e,null),e.appendInPlace&&(this.attachPrimary(t,null),this.flushFrontBuffer(t))}else if(-1===s)return void this.checkStart();if(!this.schedule||!this.isInterstitial(r))return;let o=this.schedule.findItemIndexAtTime(s);this.setSchedulePosition(o)}onAssetListLoaded(e,t){var i,r;let a=t.event,n=a.identifier,s=t.assetListResponse.ASSETS;if(null==(i=this.schedule)||!i.hasEvent(n))return;let o=a.timelineStart,l=a.duration,d=0;s.forEach((e,t)=>{let i=parseFloat(e.DURATION);this.createAsset(a,t,d,o+d,i,e.URI),d+=i}),a.duration=d,this.log(`Loaded asset-list with duration: ${d} (was: ${l}) ${a}`);let u=this.waitingItem,h=(null==u?void 0:u.event.identifier)===n;this.updateSchedule();let c=null==(r=this.bufferingItem)?void 0:r.event;if(h){let e=this.findEventIndex(n),t=this.getEventItem(n);if(t){if(!this.playingItem&&this.timelinePos>t.end&&this.schedule.findItemIndexAtTime(this.timelinePos)!==e)return a.error=new Error(`Interstitial ${s.length?"no longer within playback range":"asset-list is empty"} ${this.timelinePos} ${a}`),this.log(a.error.message),this.updateSchedule(!0),void this.primaryFallback(a);this.setBufferingItem(t)}this.setSchedulePosition(e)}else if((null==c?void 0:c.identifier)===n){let e=a.assetList[0];if(e){let t=this.getAssetPlayer(e.identifier);if(c.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 Ti.ASSET_LIST_PARSING_ERROR:case Ti.ASSET_LIST_LOAD_ERROR:case Ti.ASSET_LIST_LOAD_TIMEOUT:{let e=t.interstitial;e&&(this.updateSchedule(!0),this.primaryFallback(e));break}case Ti.BUFFER_STALLED_ERROR:{let e=this.endedItem||this.waitingItem||this.playingItem;if(this.isInterstitial(e)&&e.event.appendInPlace)return void this.handleInPlaceStall(e.event);let t=this.primaryMedia;this.log(`Primary player stall @${this.timelinePos} currentTime: ${null==t?void 0:t.currentTime} bufferedPos: ${this.bufferedPos}`),this.onTimeupdate(),this.checkBuffer(!0);break}}}}});function im(e,t,i){if((t.liveSyncDurationCount||t.liveMaxLatencyDurationCount)&&(t.liveSyncDuration||t.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==t.liveMaxLatencyDurationCount&&(void 0===t.liveSyncDurationCount||t.liveMaxLatencyDurationCount<=t.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==t.liveMaxLatencyDuration&&(void 0===t.liveSyncDuration||t.liveMaxLatencyDuration<=t.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');if(void 0!==t.liveMaxUnchangedPlaylistRefresh){let e=t.liveMaxUnchangedPlaylistRefresh,r=((e,t,i)=>Math.max(t,Math.min(e,i)))(e,2,1/0);r!==e&&i.warn(`hls.js config: "liveMaxUnchangedPlaylistRefresh" clamped from ${e} to ${r}.`),t.liveMaxUnchangedPlaylistRefresh=r}let r=rm(e),a=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach(e=>{let n=`${"level"===e?"playlist":e}LoadPolicy`,s=void 0===t[n],o=[];a.forEach(i=>{let a=`${e}Loading${i}`,l=t[a];if(void 0!==l&&s){o.push(a);let e=r[n].default;switch(t[n]={default:e},i){case"TimeOut":e.maxLoadTimeMs=l,e.maxTimeToFirstByteMs=l;break;case"MaxRetry":e.errorRetry.maxNumRetry=l,e.timeoutRetry.maxNumRetry=l;break;case"RetryDelay":e.errorRetry.retryDelayMs=l,e.timeoutRetry.retryDelayMs=l;break;case"MaxRetryTimeout":e.errorRetry.maxRetryDelayMs=l,e.timeoutRetry.maxRetryDelayMs=l}}}),o.length&&i.warn(`hls.js config: "${o.join('", "')}" setting(s) are deprecated, use "${n}": ${tn(t[n])}`)}),Gi(Gi({},r),t)}function rm(e){return e&&"object"==typeof e?Array.isArray(e)?e.map(rm):Object.keys(e).reduce((t,i)=>(t[i]=rm(e[i]),t),{}):e}function am(e,t){let i=e.loader;i!==Qc&&i!==em?(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{}return!1}()&&(e.loader=Qc,e.progressive=!0,e.enableSoftwareAES=!0,t.log("[config]: Progressive streaming enabled, using FetchLoader"))}var nm=class extends nd{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.lastABRSwitchTime=-1,this._iframeVariants=[],this.onParsedComplete=void 0,this.steering=t,this._registerListeners()}_registerListeners(){let{hls:e}=this;e.on(Ai.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Ai.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(Ai.LEVEL_LOADED,this.onLevelLoaded,this),e.on(Ai.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(Ai.FRAG_BUFFERED,this.onFragBuffered,this),e.on(Ai.ERROR,this.onError,this)}_unregisterListeners(){let{hls:e}=this;e.off(Ai.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Ai.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(Ai.LEVEL_LOADED,this.onLevelLoaded,this),e.off(Ai.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(Ai.FRAG_BUFFERED,this.onFragBuffered,this),e.off(Ai.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,this._iframeVariants=[]}onManifestLoading(e,t){this.resetLevels()}onManifestLoaded(e,t){let i=this.hls.config.preferManagedMediaSource,r=[],a={},n={},s=!1,o=!1,l=!1,d=!1;t.levels.forEach(e=>{let t=e.attrs,u=lm(e,i),{audioCodec:h,videoCodec:c,imageCodec:m,width:f,height:p}=e;if(!u)return void this.log(`Some or all CODECS not supported "${t.CODECS}"`);s||(s=!(!f||!p)),o||(o=!!c),l||(l=!!h),d||(d=!!m);let{CODECS:g,"FRAME-RATE":v,"HDCP-LEVEL":E,"PATHWAY-ID":y,RESOLUTION:b,"VIDEO-RANGE":T}=t,A=`${y||"."}-${e.bitrate}-${b}-${v}-${g}-${T}-${E}`;if(a[A])if(a[A].uri===e.url||e.attrs["PATHWAY-ID"])e.iframes||(a[A].addGroupId("audio",t.AUDIO),a[A].addGroupId("text",t.SUBTITLES));else{let t=n[A]+=1;e.attrs["PATHWAY-ID"]=new Array(t+1).join(".");let i=this.createLevel(e);a[A]=i,r.push(i)}else{let t=this.createLevel(e);a[A]=t,n[A]=1,r.push(t)}}),this.filterAndSortMediaOptions(r,t,s,o,l,d)}createLevel(e){let t=new Za(e),i=e.supplemental;if(null!=i&&i.videoCodec&&!om(i.videoCodec,this.hls.config.preferManagedMediaSource)){let e=new Error(`SUPPLEMENTAL-CODECS not supported "${i.videoCodec}"`);this.log(e.message),t.supportedResult=Ba(e,[])}return t}filterAndSortMediaOptions(e,t,i,r,a,n){var s;let o=[],l=[],d=e,u=(null==(s=t.stats)?void 0:s.parsing)||{},h=this.hls.config.preferManagedMediaSource;if((i||r)&&a&&(d=d.filter(({videoCodec:e,videoRange:t,width:i,height:r})=>(!!e||!(!i||!r))&&function(e){return!!e&&qa.indexOf(e)>-1}(t))),r&&n&&(d=d.filter(e=>!e.imageCodec)),0===d.length)return Promise.resolve().then(()=>{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: ${tn(t.levels.map(e=>e.attrs.CODECS).filter((e,t,i)=>i.indexOf(e)===t))}`,this.warn(i),e+=` (${i})`);let r=new Error(e);this.hls.trigger(Ai.ERROR,{type:bi.MEDIA_ERROR,details:Ti.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:r,reason:i})}}),void(u.end=performance.now());t.audioTracks&&(o=t.audioTracks.filter(e=>!e.audioCodec||sm(e.audioCodec,h)),dm(o)),t.subtitles&&(l=t.subtitles,dm(l));let c=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 qa.indexOf(e.videoRange)-qa.indexOf(t.videoRange);if(e.videoCodec!==t.videoCodec){let i=Ra(e.videoCodec),r=Ra(t.videoCodec);if(i!==r)return r-i}if(e.uri===t.uri&&e.codecSet!==t.codecSet){let i=La(e.codecSet),r=La(t.codecSet);if(i!==r)return r-i}return e.averageBitrate!==t.averageBitrate?e.averageBitrate-t.averageBitrate:0});let m=c[0];if(this.steering&&(d=this.steering.filterParsedLevels(d),d.length!==c.length))for(let e=0;e<c.length;e++)if(c[e].pathwayId===d[0].pathwayId){m=c[e];break}this._levels=d;for(let e=0;e<d.length;e++)if(d[e]===m){var f;this._firstLevel=e;let t=m.bitrate,i=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${d.length} level(s) found, first bitrate: ${t}`),void 0===(null==(f=this.hls.userConfig)?void 0:f.abrEwmaDefaultEstimate)){let e=Math.min(t,this.hls.config.abrEwmaDefaultEstimateMax);e>i&&i===this.hls.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=e)}break}let p=t.iframeVariants.filter(e=>lm(e,h));this._iframeVariants=p;let g=a&&!r,v=this.hls.config,E=!(!v.audioStreamController||!v.audioTrackController),y={levels:d,audioTracks:o,subtitleTracks:l,iframeVariants:p,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:a,video:r,altAudio:E&&!g&&o.some(e=>!!e.url)};u.end=performance.now(),this.hls.trigger(Ai.MANIFEST_PARSED,y)}get iframeVariants(){return 0===this._iframeVariants.length?null:this._iframeVariants}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=new Error("invalid level idx"),r=e<0;if(this.hls.trigger(Ai.ERROR,{type:bi.OTHER_ERROR,details:Ti.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,a=r?r.attrs["PATHWAY-ID"]:void 0,n=t[e],s=n.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=n,i===e&&r&&a===s)return;this.log(`Switching to level ${e} (${n.height?n.height+"p ":""}${n.videoRange?n.videoRange+" ":""}${n.codecSet?n.codecSet+" ":""}@${n.bitrate})${s?" with Pathway "+s:""} from level ${i}${a?" with Pathway "+a:""}`);let o={level:e,attrs:n.attrs,details:n.details,bitrate:n.bitrate,averageBitrate:n.averageBitrate,maxBitrate:n.maxBitrate,realBitrate:n.realBitrate,width:n.width,height:n.height,codecSet:n.codecSet,audioCodec:n.audioCodec,videoCodec:n.videoCodec,audioGroups:n.audioGroups,subtitleGroups:n.subtitleGroups,loaded:n.loaded,loadError:n.loadError,fragmentError:n.fragmentError,name:n.name,id:n.id,uri:n.uri,url:n.url,urlId:0,audioGroupIds:n.audioGroupIds,textGroupIds:n.textGroupIds};this.hls.trigger(Ai.LEVEL_SWITCHING,o);let l=n.details;if(!l||l.live){let e=this.switchParams(n.uri,null==r?void 0:r.details,l);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===Ri.LEVEL&&t.context.level===this.level&&this.checkRetry(t)}onFragBuffered(e,{frag:t}){if(t.type===Li.MAIN){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;let{level:r,details:a}=t,n=t.levelInfo;var s;if(!n)return this.warn(`Invalid level index ${r}`),void(null!=(s=t.deliveryDirectives)&&s.skip&&(a.deltaUpdateFailed=!0));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(r,t,e)}else null!=(i=t.deliveryDirectives)&&i.skip&&(a.deltaUpdateFailed=!0)}loadPlaylist(e){super.loadPlaylist(),this.shouldLoadPlaylist(this.currentLevel)&&this.scheduleLoading(this.currentLevel,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);let i=this.getUrlWithDirectives(e.uri,t),r=this.currentLevelIndex,a=e.attrs["PATHWAY-ID"],n=e.details,s=null==n?void 0:n.age;this.log(`Loading level index ${r}${void 0!==(null==t?void 0:t.msn)?" at sn "+t.msn+" part "+t.part:""}${a?" Pathway "+a:""}${s&&n.live?" age "+s.toFixed(1)+(n.type&&" "+n.type||""):""} ${i}`),this.hls.trigger(Ai.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){let t=this.currentLevelIndex;if(-1===this.manualLevelIndex&&e!==t&&-1!==e){let i=this.hls.config.abrSwitchInterval;if(i>0){let r=performance.now(),a=r-this.lastABRSwitchTime,n=1e3*i;if(this.lastABRSwitchTime>-1&&a<n)return void this.warn(`Preventing ABR level switch: ${t} -> ${e} (${Math.round(a)}ms < ${n}ms / ${i}s)`);this.lastABRSwitchTime=r,this.log(`Allowing ABR level switch: ${t} -> ${e} (${Math.round(a)}ms >= ${n}ms / ${i}s)`)}}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));uo(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(Ai.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(Ai.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:e,levels:this.levels,maxAutoLevel:t,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:i}))}};function sm(e,t){return Sa(e,"audio",t)}function om(e,t){return Sa(e,"video",t)}function lm(e,t){let{audioCodec:i,videoCodec:r}=e;i&&(e.audioCodec=i=Ca(i,t)||void 0),r&&(r=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(",")}(r));let{unknownCodecs:a}=e;return!((null==a?void 0:a.length)||i&&!sm(i,t)||r&&!om(r,t))}function dm(e){let t={};e.forEach(e=>{let i=e.groupId||"";e.id=t[i]=t[i]||0,t[i]++})}var um=class extends tr{constructor(e,t){super("key-loader",t),this.config=void 0,this.keyLoaderInfo={},this.emeController=null,this.config=e}abort(e){for(let i in this.keyLoaderInfo){let r=this.keyLoaderInfo[i].loader;if(r){var t;if(e&&e!==(null==(t=r.context)?void 0:t.frag.type))return;r.abort()}}}destroy(){for(let e in this.keyLoaderInfo){let t=this.keyLoaderInfo[e].loader;t&&t.destroy()}this.emeController=null,this.keyLoaderInfo={}}loadClear(e,t,i){return this.emeController?this.emeController.loadClear(e,t,i):null}load(e,t){return!e.decryptdata&&e.encrypted&&this.emeController&&this.config.emeEnabled?this.emeController.selectKeySystemFormat(e).then(i=>this.loadInternal(e,t,i)):this.loadInternal(e,t)}loadInternal(e,t,i){i&&e.setKeyFormat(i);let r=e.decryptdata;if(!r){let t=new Error(i?`Expected frag.decryptdata to be defined after setting format ${i}`:`Missing decryption data on fragment in onKeyLoading (emeEnabled with controller: ${this.emeController&&this.config.emeEnabled})`);return Promise.reject(hm(e,Ti.KEY_LOAD_ERROR,t))}let a=e;switch(r.method){case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return"identity"===r.keyFormat?this.loadKeyHTTP(a):t?t.then(()=>this.loadKeyEME(a)):this.loadKeyEME(a);case"AES-128":case"AES-256":case"AES-256-CTR":return this.loadKeyHTTP(a);default:return Promise.reject(hm(e,Ti.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${r.method}"`)))}}loadKeyEME(e){if(this.emeController&&this.config.emeEnabled){var t;if(!e.decryptdata.keyId&&null!=(t=e.initSegment)&&t.data){let t=function(e){let t=[];return ia(e,e=>t.push(e.subarray(8,24))),t}(e.initSegment.data);if(t.length){let i=t[0],r=e.decryptdata.uri;if(i.some(e=>0!==e))this.log(`Using keyId found in init segment ${Dr(i)} keyUri: ${r}`),xs.setKeyIdForUri(r,i);else{let e=xs.addKeyIdForUri(r);this.log(`Patching empty keyId with ${Dr(e)} keyUri: ${r}`),i=e}e.decryptdata.keyId=i}}return this.emeController.loadKey(e).then(()=>({frag:e,keyInfo:{decryptdata:e.decryptdata}}))}return Promise.reject(hm(e,Ti.KEY_LOAD_ERROR,new Error(`emeEnabled with controller: ${this.emeController&&this.config.emeEnabled})`)))}loadKeyHTTP(e){let t=e.decryptdata,i=t.uri;if(!i)return Promise.reject(hm(e,Ti.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${i}"`)));let r=this.keyLoaderInfo[i];if(r){if(r.decryptdata.key)return t.key=r.decryptdata.key,r.keyLoadPromise=null,Promise.resolve({frag:e,keyInfo:r});if(r.keyLoadPromise)return r.keyLoadPromise.then(i=>(t.key=r.decryptdata.key,Gi(Gi({},i),{},{frag:e})))}this.log(`Loading${t.keyId?" keyId: "+Dr(t.keyId):""} URI: ${t.uri} from ${e.type} ${e.level}`);let a=this.config,n=new(0,a.loader)(a);e.keyLoader=n;let s=this.keyLoaderInfo[i]={decryptdata:t,keyLoadPromise:null,loader:n};return s.keyLoadPromise=new Promise((t,r)=>{let o={type:Ri.KEY,keyInfo:s,frag:e,responseType:"arraybuffer",url:i},l=a.keyLoadPolicy.default,d={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},u={onSuccess:(e,i,a,n)=>{let{frag:s,keyInfo:o,url:l}=a;if(!s.decryptdata||o!==this.keyLoaderInfo[l])return r(hm(s,Ti.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),n));o.decryptdata.key=s.decryptdata.key=new Uint8Array(e.data),s.keyLoader=o.loader=o.keyLoadPromise=null,t({frag:s,keyInfo:o})},onError:(t,a,n,s)=>{this.resetLoader(a),r(hm(e,Ti.KEY_LOAD_ERROR,new Error(`HTTP Error ${t.code} loading key ${t.text}`),n,Gi({url:i,data:void 0},t)))},onTimeout:(t,i,a)=>{this.resetLoader(i),r(hm(e,Ti.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),a))},onAbort:(t,i,a)=>{this.resetLoader(i),r(hm(e,Ti.INTERNAL_ABORTED,new Error("key loading aborted"),a))}};n.load(o,d,u)})}resetLoader(e){let{frag:t,keyInfo:i,url:r}=e,a=i.loader;t.keyLoader===a&&(t.keyLoader=i.loader=i.keyLoadPromise=null),delete this.keyLoaderInfo[r],a&&a.destroy()}};function hm(e,t=Ti.KEY_LOAD_ERROR,i,r,a){return new Xn({type:bi.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:a,error:i,networkDetails:r||null})}function cm(e){let{type:t}=e;switch(t){case Ri.AUDIO_TRACK:return Li.AUDIO;case Ri.SUBTITLE_TRACK:return Li.SUBTITLE;default:return Li.MAIN}}function mm(e,t){let i=e.url;return(void 0===i||0===i.indexOf("data:"))&&(i=t.url),i}var fm=class{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(Ai.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Ai.LEVEL_LOADING,this.onLevelLoading,this),e.on(Ai.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(Ai.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.on(Ai.LEVELS_UPDATED,this.onLevelsUpdated,this)}unregisterListeners(){let{hls:e}=this;e.off(Ai.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Ai.LEVEL_LOADING,this.onLevelLoading,this),e.off(Ai.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(Ai.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.off(Ai.LEVELS_UPDATED,this.onLevelsUpdated,this)}createInternalLoader(e){let t=this.hls.config,i=t.pLoader,r=t.loader,a=new(i||r)(t);return this.loaders[e.type]=a,a}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:Ri.MANIFEST,url:i,deliveryDirectives:null,levelOrTrack:null})}onLevelLoading(e,t){let{id:i,level:r,pathwayId:a,url:n,deliveryDirectives:s,levelInfo:o}=t;this.load({id:i,level:r,pathwayId:a,responseType:"text",type:Ri.LEVEL,url:n,deliveryDirectives:s,levelOrTrack:o})}onAudioTrackLoading(e,t){let{id:i,groupId:r,url:a,deliveryDirectives:n,track:s}=t;this.load({id:i,groupId:r,level:null,responseType:"text",type:Ri.AUDIO_TRACK,url:a,deliveryDirectives:n,levelOrTrack:s})}onSubtitleTrackLoading(e,t){let{id:i,groupId:r,url:a,deliveryDirectives:n,track:s}=t;this.load({id:i,groupId:r,level:null,responseType:"text",type:Ri.SUBTITLE_TRACK,url:a,deliveryDirectives:n,levelOrTrack:s})}onLevelsUpdated(e,t){let i=this.loaders[Ri.LEVEL];if(i){let e=i.context;e&&!t.levels.some(t=>t===e.levelOrTrack)&&(i.abort(),delete this.loaders[Ri.LEVEL])}}load(e){var t;let i,r=this.hls.config,a=this.getInternalLoader(e);if(a){let t=this.hls.logger,i=a.context;if((null==i?void 0: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}`),a.abort()}if(i=e.type===Ri.MANIFEST?r.manifestLoadPolicy.default:$i({},r.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),a=this.createInternalLoader(e),vi(null==(t=e.deliveryDirectives)?void 0:t.part)){let t;if(e.type===Ri.LEVEL&&null!==e.level?t=this.hls.levels[e.level].details:e.type===Ri.AUDIO_TRACK&&null!==e.id?t=this.hls.audioTracks[e.id].details:e.type===Ri.SUBTITLE_TRACK&&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=$i({},i,{maxTimeToFirstByteMs:Math.min(t,i.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(t,i.maxTimeToFirstByteMs)})}}}let n=i.errorRetry||i.timeoutRetry||{},s={loadPolicy:i,timeout:i.maxLoadTimeMs,maxRetry:n.maxNumRetry||0,retryDelay:n.retryDelayMs||0,maxRetryDelay:n.maxRetryDelayMs||0},o={onSuccess:(e,t,i,r)=>{let a=this.getInternalLoader(i);this.resetInternalLoader(i.type);let n=e.data;t.parsing.start=performance.now(),Hs.isMediaPlaylist(n)||i.type!==Ri.MANIFEST?this.handleTrackOrLevelPlaylist(e,t,i,r||null,a):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)}};a.load(e,s,o)}checkAutostartLoad(){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 a=this.hls,n=e.data,s=mm(e,i),o=Hs.parseMasterPlaylist(n,s);if(o.playlistParsingError)return t.parsing.end=performance.now(),void this.handleManifestParsingError(e,i,o.playlistParsingError,r,t);let{contentSteering:l,levels:d,iframeVariants:u,sessionData:h,sessionKeys:c,startTimeOffset:m,variableList:f}=o;this.variableList=f,d.forEach(e=>{let{unknownCodecs:t}=e;if(t){let{preferManagedMediaSource:i}=this.hls.config,{audioCodec:r,videoCodec:a}=e;for(let n=t.length;n--;){let s=t[n];Sa(s,"audio",i)?(e.audioCodec=r=r?`${r},${s}`:s,Aa.audio[r.substring(0,4)]=2,t.splice(n,1)):Sa(s,"video",i)&&(e.videoCodec=a=a?`${a},${s}`:s,Aa.video[a.substring(0,4)]=2,t.splice(n,1))}}});let{AUDIO:p=[],SUBTITLES:g,"CLOSED-CAPTIONS":v}=Hs.parseMasterPlaylistMedia(n,s,o);p.length&&!p.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"),p.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new ds({}),bitrate:0,url:""})),a.trigger(Ai.MANIFEST_LOADED,{levels:d,audioTracks:p,subtitles:g,iframeVariants:u,captions:v,contentSteering:l,url:s,stats:t,networkDetails:r,sessionData:h,sessionKeys:c,startTimeOffset:m,variableList:f})}handleTrackOrLevelPlaylist(e,t,i,r,a){let n=this.hls,{id:s,level:o,type:l}=i,d=mm(e,i),u=vi(o)?o:vi(s)?s:0,h=cm(i),c=Hs.parseLevelPlaylist(e.data,d,u,h,0,this.variableList);if(l===Ri.MANIFEST){let e={attrs:new ds({}),bitrate:0,details:c,name:"",url:d};c.requestScheduled=t.loading.start+no(c,0),n.trigger(Ai.MANIFEST_LOADED,{levels:[e],audioTracks:[],iframeVariants:[],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,a)}handleManifestParsingError(e,t,i,r,a){this.hls.trigger(Ai.ERROR,{type:bi.NETWORK_ERROR,details:Ti.MANIFEST_PARSING_ERROR,fatal:t.type===Ri.MANIFEST,url:e.url,err:i,error:i,reason:i.message,response:e,context:t,networkDetails:r,stats:a})}handleNetworkError(e,t,i=!1,r,a){let n=`A network ${i?"timeout":"error"+(r?" (status "+r.code+")":"")} occurred while loading ${e.type}`;e.type===Ri.LEVEL?n+=`: ${e.level} id: ${e.id}`:(e.type===Ri.AUDIO_TRACK||e.type===Ri.SUBTITLE_TRACK)&&(n+=` id: ${e.id} group-id: "${e.groupId}"`);let s=new Error(n);this.hls.logger.warn(`[playlist-loader]: ${n}`);let o=Ti.UNKNOWN,l=!1,d=this.getInternalLoader(e);switch(e.type){case Ri.MANIFEST:o=i?Ti.MANIFEST_LOAD_TIMEOUT:Ti.MANIFEST_LOAD_ERROR,l=!0;break;case Ri.LEVEL:o=i?Ti.LEVEL_LOAD_TIMEOUT:Ti.LEVEL_LOAD_ERROR,l=!1;break;case Ri.AUDIO_TRACK:o=i?Ti.AUDIO_TRACK_LOAD_TIMEOUT:Ti.AUDIO_TRACK_LOAD_ERROR,l=!1;break;case Ri.SUBTITLE_TRACK:o=i?Ti.SUBTITLE_TRACK_LOAD_TIMEOUT:Ti.SUBTITLE_LOAD_ERROR,l=!1}d&&this.resetInternalLoader(e.type);let u={type:bi.NETWORK_ERROR,details:o,fatal:l,url:e.url,loader:d,context:e,error:s,networkDetails:t,stats:a};if(r){let i=e.url;t&&"url"in t&&(i=t.url),u.response=Gi({url:i,data:void 0},r)}this.hls.trigger(Ai.ERROR,u)}handlePlaylistLoaded(e,t,i,r,a,n){let s=this.hls,{type:o,level:l,levelOrTrack:d,id:u,groupId:h,deliveryDirectives:c}=r,m=mm(t,r),f=cm(r),p="number"==typeof r.level&&f===Li.MAIN?l:void 0;d&&"iframes"in d&&d.iframes&&!e.iframesOnly&&(e.playlistParsingError=new Error("EXT-X-I-FRAME-STREAM-INF media playlist MUST contain an EXT-X-I-FRAMES-ONLY tag"),e.iframesOnly=!0);let g=e.playlistParsingError;if(g){if(this.hls.logger.warn(`${g} ${e.url}`),!s.config.ignorePlaylistParsingErrors)return void s.trigger(Ai.ERROR,{type:bi.NETWORK_ERROR,details:Ti.LEVEL_PARSING_ERROR,fatal:!1,url:m,error:g,reason:g.message,response:t,context:r,level:p,parent:f,networkDetails:a,stats:i});e.playlistParsingError=null}if(!e.fragments.length){let n=e.playlistParsingError=new Error("No Segments found in Playlist");return void s.trigger(Ai.ERROR,{type:bi.NETWORK_ERROR,details:Ti.LEVEL_EMPTY_ERROR,fatal:!1,url:m,error:n,reason:n.message,response:t,context:r,level:p,parent:f,networkDetails:a,stats:i})}switch(e.live&&n&&(n.getCacheAge&&(e.ageHeader=n.getCacheAge()||0),(!n.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),o){case Ri.MANIFEST:case Ri.LEVEL:if(p)if(d){if(d!==s.levels[p]){let e=s.levels.indexOf(d);e>-1&&(p=e)}}else p=0;s.trigger(Ai.LEVEL_LOADED,{details:e,levelInfo:d||s.levels[0],level:p||0,id:u||0,stats:i,networkDetails:a,deliveryDirectives:c,withoutMultiVariant:o===Ri.MANIFEST,context:r});break;case Ri.AUDIO_TRACK:s.trigger(Ai.AUDIO_TRACK_LOADED,{details:e,track:d,id:u||0,groupId:h||"",stats:i,networkDetails:a,deliveryDirectives:c,context:r});break;case Ri.SUBTITLE_TRACK:s.trigger(Ai.SUBTITLE_TRACK_LOADED,{details:e,track:d,id:u||0,groupId:h||"",stats:i,networkDetails:a,deliveryDirectives:c,context:r})}}},pm=class e{static get version(){return $o}static isMSESupported(){return Qh()}static isSupported(){return function(){if(!Qh())return!1;let e=lr();return"function"==typeof(null==e?void 0:e.isTypeSupported)&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(t=>e.isTypeSupported(Ia(t,"video")))||["mp4a.40.2","fLaC"].some(t=>e.isTypeSupported(Ia(t,"audio"))))}()}static getMediaSource(){return lr()}static get Events(){return Ai}static get MetadataSchema(){return Qo}static get ErrorTypes(){return bi}static get ErrorDetails(){return Ti}static get DefaultConfig(){return e.defaultConfig?e.defaultConfig:tm}static set DefaultConfig(t){e.defaultConfig=t}constructor(t={}){this.config=void 0,this.userConfig=void 0,this.logger=void 0,this._url=null,this.streamController=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new Bo,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.audioStreamController=void 0,this.subtititleStreamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.interstitialsController=void 0,this.iframeController=void 0,this.gapController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this._sessionId=void 0,this.triggeringException=void 0,this.started=!1;let i=this.logger=function(e,t,i){let r=ar();if("object"==typeof console&&!0===e||"object"==typeof e){let a=["debug","log","info","warn","error"];a.forEach(t=>{r[t]=nr(t,e,i)});try{r.log(`Debug logs enabled for "${t}" in hls.js version 1.7.3`)}catch{return ar()}a.forEach(t=>{sr[t]=nr(t,e)})}else $i(sr,r);return r}(t.debug||!1,"Hls instance",t.loggerId||t.assetPlayerId),r=this.config=im(e.DefaultConfig,t,i);this.userConfig=t,r.progressive&&am(r,i);let{streamController:a,abrController:n,bufferController:s,capLevelController:o,errorController:l,fpsController:d,id3TrackController:u,iframeController:h,gapController:c}=r,m=new l(this),f=this.abrController=new n(this),p=new Nn(this),g=r.interstitialsController,v=g?this.interstitialsController=new g(this,e):null,E=s?this.bufferController=new s(this,p):null,y=o?this.capLevelController=new o(this):null,b=d?new d(this):null,T=r.cmcdController,A=T?this.cmcdController=new T(this):null,_=new fm(this),S=r.contentSteeringController,k=S?new S(this):null,I=this.levelController=new nm(this,k),R=u?new u(this):void 0,L=new um(this.config,this.logger),w=this.streamController=new a(this,p,L),D=this.gapController=c?new c(this,p):void 0;y&&y.setStreamController(w);let C=[_,I,w];v&&C.splice(1,0,v),k&&C.splice(1,0,k),this.networkControllers=C;let M=[f];E&&M.push(E),D&&M.push(D),y&&M.push(y),b&&(b.setStreamController(w),M.push(b)),R&&M.push(R),M.push(p),this.audioTrackController=this.createController(r.audioTrackController,C);let P=r.audioStreamController;P&&C.push(this.audioStreamController=new P(this,p,L)),this.subtitleTrackController=this.createController(r.subtitleTrackController,C);let x=r.subtitleStreamController;x&&C.push(this.subtititleStreamController=new x(this,p,L)),this.createController(r.timelineController,M),L.emeController=this.emeController=this.createController(r.emeController,M),A&&M.push(A),this.latencyController=this.createController(r.latencyController,M),this.coreComponents=M,this.iframeController=h?new h(this,e):void 0,C.push(m);let O=m.onErrorOut;"function"==typeof O&&this.on(Ai.ERROR,O,m),this.on(Ai.MANIFEST_LOADED,_.onManifestLoaded,_)}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===Ai.ERROR;this.trigger(Ai.ERROR,{type:bi.OTHER_ERROR,details:Ti.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(Ai.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,this.iframeController=void 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=new Error(`attachMedia failed: invalid argument (${e})`);return void this.trigger(Ai.ERROR,{type:bi.OTHER_ERROR,details:Ti.ATTACH_MEDIA_ERROR,fatal:!0,error:t})}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(Ai.MEDIA_ATTACHING,r)}detachMedia(){this.logger.log("detachMedia");let e={};this.trigger(Ai.MEDIA_DETACHING,e),this._media=null,this.trigger(Ai.MEDIA_DETACHED,e)}transferMedia(){var e;this._media=null;let t=(null==(e=this.bufferController)?void 0:e.transferMedia())||null,i={transferMedia:t};return this.trigger(Ai.MEDIA_DETACHING,i),this.trigger(Ai.MEDIA_DETACHED,i),t}loadSource(e){var t;this.stopLoad();let i=this.media,r=this._url,a=this._url=ki.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.logger.log(`loadSource:${a}`),i&&r&&(r!==a||null!=(t=this.bufferController)&&t.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(i)),this.trigger(Ai.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&&this.streamController.state!==bo}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={[Li.MAIN]:this.streamController.inFlightFrag};return this.audioStreamController&&(e[Li.AUDIO]=this.audioStreamController.inFlightFrag),this.subtititleStreamController&&(e[Li.SUBTITLE]=this.subtititleStreamController.inFlightFrag),e}swapAudioCodec(){this.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){this.logger.log("recoverMediaError");let e=this._media,t=this.started,i=null==e?void 0:e.currentTime;this.detachMedia(),e&&(this.attachMedia(e),t&&(i?this.startLoad(i):this.config.autoStartLoad||this.startLoad()))}removeLevel(e){this.levelController.removeLevel(e)}get sessionId(){let e=this._sessionId;return e||(e=this._sessionId=pr()),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=this.capLevelController,i=!!e;t&&i!==this.config.capLevelToPlayerSize&&(i?t.startCapping():(t.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=i)}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){(function(e){return Va.indexOf(e)>-1})(e)&&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 audioForwardBufferInfo(){var e;return(null==(e=this.audioStreamController)?void 0:e.getFwdBufferInfo())||null}get maxBufferLength(){return this.streamController.maxBufferLength}setAudioOption(e){var t;return(null==(t=this.audioTrackController)?void 0:t.setAudioOption(e))||null}setSubtitleOption(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 nextAudioTrack(){var e,t;return null!=(e=null==(t=this.audioStreamController)?void 0:t.nextAudioTrack)?e:-1}set nextAudioTrack(e){let{audioTrackController:t}=this;t&&(t.nextAudioTrack=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(){var e,t;return null!=(e=null==(t=this.latencyController)?void 0:t.liveSyncPosition)?e:null}get latency(){var e;return(null==(e=this.latencyController)?void 0:e.latency)||0}get maxLatency(){var e;return(null==(e=this.latencyController)?void 0:e.maxLatency)||0}get targetLatency(){var e;return(null==(e=this.latencyController)?void 0:e.targetLatency)||null}set targetLatency(e){this.latencyController&&(this.latencyController.targetLatency=e)}get drift(){var e;return(null==(e=this.latencyController)?void 0:e.drift)||null}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(){return this.interstitialsController?this.interstitialsController.interstitialsManager:null}get iframeVariants(){return this.levelController.iframeVariants||[]}createIFramePlayer(e){return this._url&&this.iframeController?this.iframeController.createIFramePlayer(e):null}createImageIFramePlayer(e){return this._url&&this.iframeController?this.iframeController.createImageIFramePlayer(e):null}getMediaDecodingInfo(e,t=this.allAudioTracks){return Ha(e,an(t),navigator.mediaCapabilities)}};pm.defaultConfig=void 0;var gm=pm,vm="video",Em="drm",ym={NOT_AN_ERROR:0,NETWORK_OFFLINE:2000002,NETWORK_RECONNECTING:2000003,NETWORK_UNKNOWN_ERROR:2e6,NETWORK_NO_STATUS:2000001,NETWORK_INVALID_URL:24e5,NETWORK_NOT_FOUND:2404e3,NETWORK_NOT_READY:2412e3,NETWORK_GENERIC_SERVER_FAIL:25e5,NETWORK_TOKEN_MISSING:2403201,NETWORK_TOKEN_MALFORMED:2412202,NETWORK_TOKEN_EXPIRED:2403210,NETWORK_TOKEN_AUD_MISSING:2403221,NETWORK_TOKEN_AUD_MISMATCH:2403222,NETWORK_TOKEN_SUB_MISMATCH:2403232,ENCRYPTED_ERROR:5e6,ENCRYPTED_UNSUPPORTED_KEY_SYSTEM:5000001,ENCRYPTED_GENERATE_REQUEST_FAILED:5000002,ENCRYPTED_UPDATE_LICENSE_FAILED:5000003,ENCRYPTED_UPDATE_SERVER_CERT_FAILED:5000004,ENCRYPTED_CDM_ERROR:5000005,ENCRYPTED_OUTPUT_RESTRICTED:5000006,ENCRYPTED_MISSING_TOKEN:5000002},bm=e=>e===vm?"playback":e,Tm=class e extends Error{constructor(t,i=e.MEDIA_ERR_CUSTOM,r,a){var n;super(t),this.name="MediaError",this.code=i,this.context=a,this.fatal=null!=r?r:i>=e.MEDIA_ERR_NETWORK&&i<=e.MEDIA_ERR_ENCRYPTED,this.message||(this.message=null!=(n=e.defaultMessages[this.code])?n:"")}};Tm.MEDIA_ERR_ABORTED=1,Tm.MEDIA_ERR_NETWORK=2,Tm.MEDIA_ERR_DECODE=3,Tm.MEDIA_ERR_SRC_NOT_SUPPORTED=4,Tm.MEDIA_ERR_ENCRYPTED=5,Tm.MEDIA_ERR_CUSTOM=100,Tm.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 Am=Tm,_m=(e,t)=>!(e=>null==e)(t)&&e in t,Sm={ANY:"any",MUTED:"muted"},km={ON_DEMAND:"on-demand",LIVE:"live",UNKNOWN:"unknown"},Im="mse",Rm="native",Lm={HEADER:"header",QUERY:"query",NONE:"none"},wm=Object.values(Lm),Dm={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},Cm={HLS:Dm.M3U8},Mm=(Object.keys(Cm),Object.values(Dm),{code:"en"}),Pm=e=>{let t=e;for(;t;){if(t.hasAttribute("lang"))return t.getAttribute("lang")||void 0;let e=t.getRootNode();t=e instanceof ShadowRoot?e.host:void 0}},xm=(e,t,i,r,a=e)=>{a.addEventListener(t,i,r),e.addEventListener("teardown",()=>{a.removeEventListener(t,i)},{once:!0})};var Om=e=>{let t=e.indexOf("?");return t<0?[e]:[e.slice(0,t),e.slice(t)]},Nm=e=>{let{type:t}=e;if(t){let e=t.toUpperCase();return _m(e,Cm)?Cm[e]:t}return Bm(e)},Um=e=>"VOD"===e?km.ON_DEMAND:km.LIVE,Fm=e=>"EVENT"===e?Number.POSITIVE_INFINITY:"VOD"===e?Number.NaN:0,Bm=e=>{let{src:t}=e;if(!t)return"";let i="";try{i=Hm(t).pathname}catch{console.error("Invalid url when trying to infer mime type",t)}let r=i.lastIndexOf(".");if(r<0)return Gm(e)?Dm.M3U8:"";let a=i.slice(r+1).toUpperCase();return _m(a,Dm)?Dm[a]:""},$m=e=>{try{return new URL(e),!1}catch{return!0}},Hm=(e,t)=>{var i;if(!$m(e))return new URL(e);let r=null==(i=null==window?void 0:window.location)?void 0:i.href,a=null!=t?t:r;return t&&$m(t.toString())&&(a=new URL(t,r)),new URL(e,a)},Gm=({src:e,customDomain:t="mux.com"})=>{let i;try{i=new URL(`${e}`)}catch{return!1}let r="https:"===i.protocol,a=i.hostname===`stream.${t}`.toLowerCase(),n=i.pathname.split("/"),s=2===n.length,o=!(null!=n&&n[1].includes("."));return r&&a&&s&&o},Km=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}};function Wm(e,t=!0){var i,r;let a=t&&null!=(r=null==(i=Mm)?void 0:i[e])?r:e;return new Vm(a,t?Mm.code:"en")}var Vm=class{constructor(e,t=(e=>null!=(e=Mm)?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}},qm=Object.values(Sm),Ym=e=>"boolean"==typeof e||"string"==typeof e&&qm.includes(e),jm=(e,t)=>{if(!t)return;let i=e.muted,r=()=>e.muted=i;switch(t){case Sm.ANY:e.play().catch(()=>{e.muted=!0,e.play().catch(r)});break;case Sm.MUTED:e.muted=!0,e.play().catch(r);break;default:e.play().catch(()=>{})}};function zm(e,t){var i;if(!("videoTracks"in e))return;let r=new WeakMap;t.on(gm.Events.MANIFEST_PARSED,function(t,i){o();let a=e.addVideoTrack("main");a.selected=!0;for(let[e,t]of i.levels.entries()){let i=a.addRendition(t.url[0],t.width,t.height,t.videoCodec,t.bitrate);r.set(t,`${e}`),i.id=`${e}`}}),t.on(gm.Events.AUDIO_TRACKS_UPDATED,function(t,i){s();for(let t of 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 a=()=>{var i;let r=+(null==(i=[...e.audioTracks].find(e=>e.enabled))?void 0:i.id),a=t.audioTracks.map(e=>e.id);r!=t.audioTrack&&a.includes(r)&&(t.audioTrack=r)};e.audioTracks.addEventListener("change",a),t.on(gm.Events.LEVELS_UPDATED,function(t,i){var a;let n=e.videoTracks[null!=(a=e.videoTracks.selectedIndex)?a:0];if(!n)return;let s=i.levels.map(e=>r.get(e));for(let t of e.videoRenditions)t.id&&!s.includes(t.id)&&n.removeRendition(t)});let n=e=>{let i=e.target.selectedIndex;i!=t.nextLevel&&(t.nextLevel=i)};null==(i=e.videoRenditions)||i.addEventListener("change",n);let s=()=>{for(let t of e.audioTracks)e.removeAudioTrack(t)},o=()=>{(()=>{for(let t of e.videoTracks)e.removeVideoTrack(t)})(),s()};t.once(gm.Events.DESTROYING,()=>{var t,i;o(),null==(t=e.audioTracks)||t.removeEventListener("change",a),null==(i=e.videoRenditions)||i.removeEventListener("change",n)})}var Qm=e=>e.split("-")[0],Xm=({language:e})=>"string"==typeof e?e.toLowerCase():void 0;function Zm(e,t){var i,r;let a=t.toLowerCase(),n=Qm(a);return null!=(r=null!=(i=e.find(e=>Xm(e)===a))?i:e.find(e=>Xm(e)===n))?r:e.find(e=>{let t=Xm(e);return void 0!==t&&Qm(t)===n})}function Jm(e,t){var i;let r=(Array.isArray(e)?e:[]).filter(e=>"string"==typeof(null==e?void 0:e.title)&&""!==e.title);if(!r.length)return"";for(let e of t){let t=Zm(r,e);if(t)return t.title}return(null!=(i=r.find(e=>"und"===Xm(e)))?i:r[0]).title}var ef=Number.MAX_SAFE_INTEGER,tf=e=>"time"in e?e.time:e.startTime;function rf(e,t,i,r,a,n){let s=document.createElement("track");return s.kind=t,s.label=i,r&&(s.srclang=r),a&&(s.id=a),n&&(s.default=!0),s.track.mode=["subtitles","captions"].includes(t)?"disabled":"hidden",s.setAttribute("data-removeondestroy",""),e.append(s),s.track}function af(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}var nf=new WeakMap;async function sf(e,t,i){let r=af(e,t,i);if(r){let e=nf.get(r);return e&&await e,r}let a=rf(e,i,t);a.mode="hidden";let n=new Promise(e=>setTimeout(e,0));return nf.set(a,n),await n,nf.delete(a),a}function of(e,t,i,r){"hidden"!==t.mode&&(t.mode="hidden"),[...i].sort((e,t)=>tf(t)-tf(e)).forEach(i=>{var a,n;let s=i.value,o=tf(i);if("endTime"in i&&null!=i.endTime&&Number.isFinite(i.endTime))null==t||t.addCue(new VTTCue(o,i.endTime,"chapters"===r?s:JSON.stringify(null!=s?s:null)));else{let i=Array.prototype.findIndex.call(null==t?void 0:t.cues,e=>e.startTime>=o),l=null==(a=null==t?void 0:t.cues)?void 0:a[i],d=l?l.startTime:Number.isFinite(e.duration)&&e.duration>0?e.duration:ef,u=null==(n=null==t?void 0:t.cues)?void 0:n[i-1];u&&(u.endTime=o),null==t||t.addCue(new VTTCue(o,d,"chapters"===r?s:JSON.stringify(null!=s?s:null)))}}),e.textTracks.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}var lf="cuepoints",df=Object.freeze({label:lf});async function uf(e,t,i=df){return async function(e,t,i,r){let a=await sf(e,i,r);return of(e,a,t,r),a}(e,t,i.label,"metadata")}var hf=e=>({time:e.startTime,value:JSON.parse(e.text)});function cf(e,t={label:lf}){var i,r;let a=af(e,t.label,"metadata");if(null==(i=null==a?void 0:a.activeCues)||!i.length)return;if(1===a.activeCues.length)return hf(a.activeCues[0]);let{currentTime:n}=e,s=Array.prototype.find.call(null!=(r=a.activeCues)?r:[],({startTime:e,endTime:t})=>e<=n&&t>n);return hf(s||a.activeCues[0])}var mf="chapters",ff=Object.freeze({label:mf}),pf=(e,t)=>{let{duration:i}=t,r=Number.isFinite(i)&&i>0?Math.min(e.endTime,i):e.endTime>=ef?1/0:e.endTime;return{startTime:e.startTime,endTime:r,value:e.text}},gf=new WeakSet;function vf(e){var t;Array.from(null!=(t=e.cues)?t:[]).filter(e=>gf.has(e)).forEach(t=>e.removeCue(t))}async function Ef(e,t,i=ff){let r=await sf(e,i.label,"chapters");return t.length&&vf(r),of(e,r,t,"chapters"),r}function yf(e,t={label:mf}){var i,r;let a=af(e,t.label,"chapters");if(null==(i=null==a?void 0:a.activeCues)||!i.length)return;if(1===a.activeCues.length)return pf(a.activeCues[0],e);let{currentTime:n}=e,s=Array.prototype.find.call(null!=(r=a.activeCues)?r:[],({startTime:e,endTime:t})=>e<=n&&t>n);return pf(s||a.activeCues[0],e)}var bf="v",Tf="t",Af="s",_f="d",Sf=(e,t,i,r,a=!1,n=!(e=>null==(e=globalThis.navigator)?void 0:e.onLine)())=>{var s;if(n){let i,r=Wm("Your device appears to be offline",a),n=Am.MEDIA_ERR_NETWORK,s=new Am(r,n,!1,i);return s.errorCategory=t,s.muxCode=ym.NETWORK_OFFLINE,s.data=e,s}let o="status"in e?e.status:e.code,l=Date.now(),d=Am.MEDIA_ERR_NETWORK;if(200===o)return;let u=bm(t),h=((e,t)=>{var i,r;let a=bm(e),n=`${a}Token`;return null!=(i=t.tokens)&&i[a]?null==(r=t.tokens)?void 0:r[a]:_m(n,t)?t[n]:void 0})(t,i),c=(e=>e===vm?bf:e===Em?_f:void 0)(t),[m]=Om(null!=(s=i.playbackId)?s:"");if(!o||!m)return;let f=Km(h);if(h&&!f){let i=Wm("The {tokenNamePrefix}-token provided is invalid or malformed.",a).format({tokenNamePrefix:u}),r=Wm("Compact JWT string: {token}",a).format({token:h}),n=new Am(i,d,!0,r);return n.errorCategory=t,n.muxCode=ym.NETWORK_TOKEN_MALFORMED,n.data=e,n}if(o>=500){let e=new Am("",d,null==r||r);return e.errorCategory=t,e.muxCode=ym.NETWORK_UNKNOWN_ERROR,e}if(403===o){if(!f){let i=Wm("Authorization error trying to access this {category} URL. If this is a signed URL, you might need to provide a {tokenNamePrefix}-token.",a).format({tokenNamePrefix:u,category:t}),n=Wm("Specified playback ID: {playbackId}",a).format({playbackId:m}),s=new Am(i,d,null==r||r,n);return s.errorCategory=t,s.muxCode=ym.NETWORK_TOKEN_MISSING,s.data=e,s}if((({exp:e},t=Date.now())=>!e||1e3*e<t)(f,l)){let i={timeStyle:"medium",dateStyle:"medium"},r=Wm("The video’s secured {tokenNamePrefix}-token has expired.",a).format({tokenNamePrefix:u}),n=new Intl.DateTimeFormat("en",i).format(l),s=f.exp?Wm("Expired at: {expiredDate}. Current time: {currentDate}.",a).format({expiredDate:new Intl.DateTimeFormat("en",i).format(1e3*f.exp),currentDate:n}):Wm("The {tokenNamePrefix}-token has no exp value. Current time: {currentDate}.",a).format({tokenNamePrefix:u,currentDate:n}),o=new Am(r,d,!0,s);return o.errorCategory=t,o.muxCode=ym.NETWORK_TOKEN_EXPIRED,o.data=e,o}if((({sub:e},t)=>e!==t)(f,m)){let i=Wm("The video’s playback ID does not match the one encoded in the {tokenNamePrefix}-token.",a).format({tokenNamePrefix:u}),r=Wm("Specified playback ID: {playbackId} and the playback ID encoded in the {tokenNamePrefix}-token: {tokenPlaybackId}",a).format({tokenNamePrefix:u,playbackId:m,tokenPlaybackId:f.sub}),n=new Am(i,d,!0,r);return n.errorCategory=t,n.muxCode=ym.NETWORK_TOKEN_SUB_MISMATCH,n.data=e,n}if((({aud:e})=>!e)(f)){let i=Wm("The {tokenNamePrefix}-token is formatted with incorrect information.",a).format({tokenNamePrefix:u}),r=Wm("The {tokenNamePrefix}-token has no aud value. aud value should be {expectedAud}.",a).format({tokenNamePrefix:u,expectedAud:c}),n=new Am(i,d,!0,r);return n.errorCategory=t,n.muxCode=ym.NETWORK_TOKEN_AUD_MISSING,n.data=e,n}if((({aud:e},t)=>e!==t)(f,c)){let i=Wm("The {tokenNamePrefix}-token is formatted with incorrect information.",a).format({tokenNamePrefix:u}),r=Wm("The {tokenNamePrefix}-token has an incorrect aud value: {aud}. aud value should be {expectedAud}.",a).format({tokenNamePrefix:u,expectedAud:c,aud:f.aud}),n=new Am(i,d,!0,r);return n.errorCategory=t,n.muxCode=ym.NETWORK_TOKEN_AUD_MISMATCH,n.data=e,n}}if(412===o){let n=Wm("This playback-id may belong to a live stream that is not currently active or an asset that is not ready.",a),s=Wm("Specified playback ID: {playbackId}",a).format({playbackId:m}),o=new Am(n,d,null==r||r,s);return o.errorCategory=t,o.muxCode=ym.NETWORK_NOT_READY,o.streamType=i.streamType===km.LIVE?"live":i.streamType===km.ON_DEMAND?"on-demand":"unknown",o.data=e,o}if(404===o){let i=Wm("This URL or playback-id does not exist. You may have used an Asset ID or an ID from a different resource.",a),n=Wm("Specified playback ID: {playbackId}",a).format({playbackId:m}),s=new Am(i,d,null==r||r,n);return s.errorCategory=t,s.muxCode=ym.NETWORK_NOT_FOUND,s.data=e,s}if(400===o){let i=Wm("The URL or playback-id was invalid. You may have used an invalid value as a playback-id."),n=Wm("Specified playback ID: {playbackId}",a).format({playbackId:m}),s=new Am(i,d,null==r||r,n);return s.errorCategory=t,s.muxCode=ym.NETWORK_INVALID_URL,s.data=e,s}let p=new Am("",d,null==r||r);return p.errorCategory=t,p.muxCode=ym.NETWORK_UNKNOWN_ERROR,p.data=e,p},kf=gm.DefaultConfig.capLevelController;kf||console.error("MinCapLevelController - hls.js DefaultConfig.capLevelController is unavailable");var If={"720p":921600,"1080p":2073600,"1440p":4194304,"2160p":8294400};var Rf=class e extends kf{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=function(e){let t=e.toLowerCase().trim();return If[t]}(i);if(!r)return super.getMaxLevel(e);let a=t.filter(e=>e.width*e.height<=r),n=a.findIndex(e=>e.width*e.height===r);if(-1!==n){let e=a[n];return t.findIndex(t=>t===e)}if(0===a.length)return 0;let s=a[a.length-1];return t.findIndex(e=>e===s)}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 a=Math.min(r[i].width,r[i].height),n=e.minMaxResolution;return a>=n?i:kf.getMaxLevelByMediaSize(r,n*(16/9),n)}};Rf.minMaxResolution=720,Rf.maxAutoResolution=new WeakMap;var Lf=Rf,wf=(e,t)=>{let i=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}(Df(e)),r=new Uint8Array(e),a=new Uint8Array(i),n=new Uint8Array(t),s=r.byteLength+4+n.byteLength+4+a.byteLength,o=new Uint8Array(s),l=0,d=e=>{o.set(e,l),l+=e.byteLength},u=e=>{let t=new DataView(o.buffer),i=e.byteLength;t.setUint32(l,i,!0),l+=4,d(e)};return d(r),u(a),u(n),o},Df=e=>new TextDecoder("utf-16le").decode(e).replace("skd://","").slice(1);var Cf=({mediaEl:e,getAppCertificate:t,getLicenseKey:i,saveAndDispatchError:r,drmTypeCb:a,fallbackToWebkitFairplay:n})=>{let s=null,o=async t=>{try{let i=t.initDataType;if("skd"!==i)return void console.error(`Received unexpected initialization data type "${i}"`);e.mediaKeys||await l(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){return void r(e,t)}},l=async i=>{let n=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=>(a(),e)).catch(()=>{let t=Wm("Cannot play DRM-protected content with current security configuration on this browser. Try playing in another browser."),i=new Am(t,Am.MEDIA_ERR_ENCRYPTED,!0);i.errorCategory=Em,i.muxCode=ym.ENCRYPTED_UNSUPPORTED_KEY_SYSTEM,r(e,i)});if(!n)return;let s=await n.createMediaKeys();try{let e=await t();await s.setServerCertificate(e).catch(()=>{let e=Wm("Your server certificate failed when attempting to set it. This may be an issue with a no longer valid certificate."),t=new Am(e,Am.MEDIA_ERR_ENCRYPTED,!0);return t.errorCategory=Em,t.muxCode=ym.ENCRYPTED_UPDATE_SERVER_CERT_FAILED,Promise.reject(t)})}catch(t){return void r(e,t)}await e.setMediaKeys(s)},d=async(t,a)=>{let o=e.mediaKeys.createSession(),l=async t=>{let a=t.message,n=await i(a);try{await o.update(n)}catch{let t=Wm("Failed to update DRM license. This may be an issue with the player or your protected content."),i=new Am(t,Am.MEDIA_ERR_ENCRYPTED,!0);i.errorCategory=Em,i.muxCode=ym.ENCRYPTED_UPDATE_LICENSE_FAILED,r(e,i)}},d=()=>{o.keyStatuses.forEach(t=>(t=>{let i;if("internal-error"===t){let e=Wm("The DRM Content Decryption Module system had an internal failure. Try reloading the page, updating your browser, or playing in another browser.");i=new Am(e,Am.MEDIA_ERR_ENCRYPTED,!0),i.errorCategory=Em,i.muxCode=ym.ENCRYPTED_CDM_ERROR}else if("output-restricted"===t||"output-downscaled"===t){let e=Wm("DRM playback is being attempted in an environment that is not sufficiently secure. User may see black screen.");i=new Am(e,Am.MEDIA_ERR_ENCRYPTED,!1),i.errorCategory=Em,i.muxCode=ym.ENCRYPTED_OUTPUT_RESTRICTED}i&&r(e,i)})(t))};o.addEventListener("keystatuseschange",d),o.addEventListener("message",l);let u=async()=>{o.removeEventListener("keystatuseschange",d),o.removeEventListener("message",l),"webkitCurrentPlaybackTargetIsWireless"in e&&e.removeEventListener("webkitcurrentplaybacktargetiswirelesschanged",u),e.removeEventListener("teardown",u),await o.close().catch(e=>{console.warn("There was an error when closing EME session",e)}),s=null};"webkitCurrentPlaybackTargetIsWireless"in e&&e.addEventListener("webkitcurrentplaybacktargetiswirelesschanged",u,{once:!0}),e.addEventListener("teardown",u,{once:!0}),s=u,await o.generateRequest(t,a).catch(async t=>{if("NotSupportedError"!==t.name||!("webkitCurrentPlaybackTargetIsWireless"in e)||!e.webkitCurrentPlaybackTargetIsWireless){let e=Wm("Failed to generate a DRM license request. This may be an issue with the player or your protected content."),i=new Am(e,Am.MEDIA_ERR_ENCRYPTED,!0);return i.errorCategory=Em,i.muxCode=ym.ENCRYPTED_GENERATE_REQUEST_FAILED,console.error("Failed to generate license request",t),Promise.reject(i)}console.warn("Failed to generate a DRM license request. Attempting to fallback to Webkit DRM"),null==n||n()})},u=async()=>{e.removeEventListener("encrypted",o),e.removeEventListener("teardown",u),s&&await s(),await e.setMediaKeys(null).catch(()=>{})};return e.addEventListener("encrypted",o),e.addEventListener("teardown",u,{once:!0}),u},Mf=({hls:e,mediaEl:t,src:i,muxMediaState:r,saveAndDispatchError:a,maxRetries:n})=>{var s;let o,l=0,d=!1,u=!1,h=!1,c=()=>{null!=o&&(clearTimeout(o),o=void 0)},m=e=>(null==e?void 0:e.muxCode)===ym.NETWORK_RECONNECTING,f=()=>{h||!i?e.startLoad(t.currentTime):e.loadSource(i)},p=()=>{if(null!=o||d)return;if(l>=n)return void(()=>{d=!1,u=!0,c();let e=new Am(Wm("Network error, try reloading."),Am.MEDIA_ERR_NETWORK,!0);e.errorCategory=vm,e.reload=!0,a(t,e)})();d=!0;let e=Math.min(1e3*2**l,3e4);o=setTimeout(()=>{o=void 0,l+=1,f()},e)},g=()=>{let e=r.get(t);null==e||!e.networkError||u||!t.paused&&t.readyState<HTMLMediaElement.HAVE_FUTURE_DATA&&((()=>{let e=r.get(t);if(m(null==e?void 0:e.error))return;let i=new Am(Wm("Attempting to reconnect..."),Am.MEDIA_ERR_NETWORK,!1);i.errorCategory=vm,i.muxCode=ym.NETWORK_RECONNECTING,e&&(e.error=i),t.dispatchEvent(new CustomEvent("error",{detail:i}))})(),p())},v=()=>{let e=r.get(t);null!=e&&e.networkError&&(l=0,u=!1,c(),d=!0,f())};null==(s=globalThis.addEventListener)||s.call(globalThis,"online",v);return e.on(gm.Events.FRAG_BUFFERED,()=>{let e=r.get(t);e&&(!e.networkError&&!m(e.error)||(e.networkError=!1,d=!1,l=0,u=!1,c(),e.error&&(e.error=null,t.dispatchEvent(new Event("emptied")))))}),xm(t,"playing",()=>{let e=r.get(t);null!=e&&e.networkError&&(d=!1,l=0,u=!1,c(),e.error&&(e.error=null))}),xm(t,"waiting",g),t.addEventListener("teardown",()=>{var e;null==(e=globalThis.removeEventListener)||e.call(globalThis,"online",v),c()},{once:!0}),{handleHlsError:(e,i)=>{var a,n;if(e.type!==gm.ErrorTypes.NETWORK_ERROR)return!1;let s=null!=(n=null==(a=e.response)?void 0:a.code)?n:0;return!(!(i.muxCode===ym.NETWORK_OFFLINE||0===s||s>=500)||!e.fatal)&&((()=>{let e=r.get(t);e&&(e.networkError=!0),d=!1,g()})(),!0)},onManifestLoaded:()=>{h=!0,d=!1,c()}}},Pf="fairplay",xf="playready",Of="widevine",Nf=e=>{let t=e.split("\n").filter(e=>e.startsWith("#EXT-X-SESSION-DATA"));if(!t.length)return{};let i={};for(let e of t){let t=Ff(e),r=t["DATA-ID"];r&&(i[r]={...t})}return{sessionData:i}},Uf=/([A-Z0-9-]+)="?(.*?)"?(?:,|$)/g;function Ff(e){let t=[...e.matchAll(Uf)];return Object.fromEntries(t.map(([,e,t])=>[e,t]))}var Bf,$f,Hf,Gf,Kf,Wf,Vf,qf=e=>{var t,i,r;let a,n=e.split("\n"),s=null==(i=(null!=(t=n.find(e=>e.startsWith("#EXT-X-PLAYLIST-TYPE")))?t:"").split(":")[1])?void 0:i.trim(),o=Um(s),l=Fm(s);if(o===km.LIVE){let e=n.find(e=>e.startsWith("#EXT-X-PART-INF"));if(e)a=2*+e.split(":")[1].split("=")[1];else{let e=n.find(e=>e.startsWith("#EXT-X-TARGETDURATION")),t=null==(r=null==e?void 0:e.split(":"))?void 0:r[1];a=3*+(null!=t?t:6)}}return{streamType:o,targetLiveWindow:l,liveEdgeStartOffset:a}},Yf=async(e,t,i)=>{if(t===Dm.MP4)return{streamType:km.ON_DEMAND,targetLiveWindow:Number.NaN,liveEdgeStartOffset:void 0,sessionData:void 0,playlistUrl:void 0};if(t===Dm.M3U8){let t=await fetch(e,{signal:i});if(!t.ok)return Promise.reject(t);let r=await t.text(),a=t.url||e,n=await((e,t,i)=>{let r,a=(e=>e.split("\n").find((e,t,i)=>t>0&&i[t-1].startsWith("#EXT-X-STREAM-INF")))(e);if(!a)return Promise.reject(new Error("No media playlist URL found in multivariant playlist"));if($m(a)&&!t)return Promise.reject(new Error("masterPlaylistUrl is required to resolve relative media playlist URL"));try{r=Hm(a,t)}catch(e){return Promise.reject(e)}return fetch(r,{signal:i}).then(e=>200!==e.status?Promise.reject(e):e.text())})(r,a,i);return{...Nf(r),...qf(n),playlistUrl:a}}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,playlistUrl:void 0}},jf=(e,t)=>{var i;let r=(null==e?void 0:e.URI)||(null!=(i=null==e?void 0:e.VALUE)&&i.toLocaleLowerCase().startsWith("http")?e.VALUE:void 0);if(r)try{return Hm(r,t).toString()}catch{return}},zf=e=>{let t=new AbortController;return e.addEventListener("teardown",()=>t.abort(),{once:!0}),t.signal},Qf=async(e,t)=>{try{let i=await fetch(e,{signal:t});if(!i.ok)throw new Error(`Failed to fetch ${e}: ${i.status} ${i.statusText}`);let r=await i.json();return t.aborted?void 0:r}catch(e){return void(t.aborted||console.error(e))}},Xf=(e,t)=>{var i,r;if(!Array.isArray(null==(i=null==e?void 0:e[0])?void 0:i.metadata))return;let a={};for(let t of e[0].metadata)null!=t&&t.key&&null!=t&&t.value&&(a[t.key]=t.value);(null!=(r=rp.get(t))?r:{}).metadata=a;let n=new CustomEvent("muxmetadata");t.dispatchEvent(n)},Zf=async(e,t,i=zf(t))=>{let r=await Qf(e,i);void 0!==r&&(Xf(r,t),await async function(e,t,i,r=ff){var a,n;let s=await sf(e,r.label,"chapters");return null!=i&&i.aborted||Array.from(null!=(a=s.cues)?a:[]).some(e=>!gf.has(e))||(vf(s),of(e,s,t,"chapters"),Array.from(null!=(n=s.cues)?n:[]).forEach(e=>gf.add(e))),s}(t,function(e,t=[]){return Array.isArray(e)?e.filter(e=>"number"==typeof(null==e?void 0:e["start-time"])).map((e,i,r)=>{var a;let n=e["start-time"],s=null==(a=r[i+1])?void 0:a["start-time"],o="number"==typeof e.duration?n+e.duration:"number"==typeof s?s:void 0;return{startTime:n,...null!=o?{endTime:o}:{},value:Jm(e.titles,t)}}).filter(e=>""!==e.value):[]}(r,(e=>{var t,i,r;let a=null!=(r=null==(t=globalThis.navigator)?void 0:t.languages)?r:[null==(i=globalThis.navigator)?void 0:i.language];return[Pm(e),...a].filter(e=>!!e)})(t)),i))},Jf=(e,t,i)=>{var r,a,n,s,o,l,d,u;let{streamType:h,targetLiveWindow:c,liveEdgeStartOffset:m,lowLatency:f}=(e=>{var t;let i,r=e.type,a=Um(r),n=Fm(r),s=!(null==(t=e.partList)||!t.length);return a===km.LIVE&&(i=s?2*e.partTarget:3*e.targetduration),{streamType:a,targetLiveWindow:n,liveEdgeStartOffset:i,lowLatency:s}})(e);if(h===km.LIVE){f?(i.config.backBufferLength=null!=(r=i.userConfig.backBufferLength)?r:4,i.config.maxFragLookUpTolerance=null!=(a=i.userConfig.maxFragLookUpTolerance)?a:.001,i.config.abrBandWidthUpFactor=null!=(n=i.userConfig.abrBandWidthUpFactor)?n:i.config.abrBandWidthFactor):i.config.backBufferLength=null!=(s=i.userConfig.backBufferLength)?s: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!=(o=rp.get(t))?o:{}).seekable=e}(null!=(l=rp.get(t))?l:{}).liveEdgeStartOffset=m,(null!=(d=rp.get(t))?d:{}).targetLiveWindow=c,t.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),(null!=(u=rp.get(t))?u:{}).streamType=h,t.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},ep=null!=($f=null==(Bf=null==globalThis?void 0:globalThis.navigator)?void 0:Bf.userAgent)?$f:"",tp=null!=(Kf=null==(Gf=null==(Hf=null==globalThis?void 0:globalThis.navigator)?void 0:Hf.userAgentData)?void 0:Gf.platform)?Kf:"",ip=ep.toLowerCase().includes("android")||["x11","android"].some(e=>tp.toLowerCase().includes(e)),rp=new WeakMap,ap="mux.com",np=null==(Vf=(Wf=gm).isSupported)?void 0:Vf.call(Wf),sp=e=>ip||!(e=>/^((?!chrome|android).)*safari/i.test(ep)&&!!e.canPlayType("application/vnd.apple.mpegurl"))(e),op=()=>{if("undefined"!=typeof window)return gi.utils.now()},lp=gi.utils.generateUUID,dp=({playbackId:e,customDomain:t=ap,maxResolution:i,minResolution:r,renditionOrder:a,programStartTime:n,programEndTime:s,assetStartTime:o,assetEndTime:l,playbackToken:d,tokens:{playback:u=d}={},extraSourceParams:h={}}={})=>{if(!e)return;let[c,m=""]=Om(e),f=new URL(`https://stream.${t}/${c}.m3u8${m}`);return u||f.searchParams.has("token")?(f.searchParams.forEach((e,t)=>{"token"!=t&&f.searchParams.delete(t)}),u&&f.searchParams.set("token",u)):(i&&f.searchParams.set("max_resolution",i),r&&(f.searchParams.set("min_resolution",r),i&&+i.slice(0,-1)<+r.slice(0,-1)&&console.error("minResolution must be <= maxResolution","minResolution",r,"maxResolution",i)),a&&f.searchParams.set("rendition_order",a),n&&f.searchParams.set("program_start_time",`${n}`),s&&f.searchParams.set("program_end_time",`${s}`),o&&f.searchParams.set("asset_start_time",`${o}`),l&&f.searchParams.set("asset_end_time",`${l}`),Object.entries(h).forEach(([e,t])=>{null!=t&&f.searchParams.set(e,t)})),f.toString()},up=e=>{if(!e)return;let[t]=e.split("?");return t||void 0},hp=e=>{if(!e||!e.startsWith("https://stream."))return;let[t]=new URL(e).pathname.slice(1).split(/\.m3u8|\//);return t||void 0},cp=e=>{var t;return null==(t=rp.get(e))?void 0:t.error},mp=e=>{var t,i;return null!=(i=null==(t=rp.get(e))?void 0:t.streamType)?i:km.UNKNOWN},fp=e=>{var t,i;return null!=(i=null==(t=rp.get(e))?void 0:t.seekable)?i:e.seekable},pp=.034,gp=(e,t,i=pp)=>e>t||((e,t,i=pp)=>Math.abs(e-t)<=i)(e,t,i),vp=(e,t)=>{var i,r,a;if(!t||!e.buffered.length)return;if(e.readyState>2)return!1;let n=t.currentLevel>=0?null==(r=null==(i=t.levels)?void 0:i[t.currentLevel])?void 0:r.details:null==(a=t.levels.find(e=>!!e.details))?void 0:a.details;if(!n||n.live)return;let{fragments:s}=n;if(null==s||!s.length)return;if(e.currentTime<e.duration-(n.targetduration+.5))return!1;let o=s[s.length-1];if(e.currentTime<=o.start)return!1;let l=o.start+o.duration/2,d=e.buffered.start(e.buffered.length-1),u=e.buffered.end(e.buffered.length-1);return l>d&&l<u},Ep=(e,t)=>e.ended||e.loop?e.ended:!(!t||!vp(e,t))||((e,t=pp)=>e.paused&&gp(e.currentTime,e.duration,t))(e),yp=(e,t,i)=>{Ap(t,i,e);let{metadata:r={}}=e,{view_session_id:a=lp()}=r,n=(e=>{var t,i,r;return null!=(t=null==e?void 0:e.metadata)&&t.video_id?e.metadata.video_id:Dp(e)&&null!=(r=null!=(i=up(e.playbackId))?i:hp(e.src))?r:e.src})(e);r.view_session_id=a,r.video_id=n,e.metadata=r;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,a=t.currentTime;e.useWebkitFairplay=!0;let n=e.muxDataKeepSession;e.muxDataKeepSession=!0;let s=null==(i=rp.get(t))?void 0:i.coreReference;yp(e,t,s),e.muxDataKeepSession=n,e.useWebkitFairplay=!1,r&&await t.play().then(()=>{t.currentTime=a}).catch(()=>{}),t.currentTime=a},rp.set(t,{retryCount:0});let s=Sp(e,t),o=(({preload:e,src:t},i,r)=>{let a=e=>{null!=e&&["","none","metadata","auto"].includes(e)?i.setAttribute("preload",e):i.removeAttribute("preload")};if(!r)return a(e),a;let n=!1,s=!1,o=r.config.maxBufferLength,l=r.config.maxBufferSize,d=e=>{a(e);let t=null!=e?e:i.preload;s||"none"===t||("metadata"===t?(r.config.maxBufferLength=1,r.config.maxBufferSize=1):(r.config.maxBufferLength=o,r.config.maxBufferSize=l),u())},u=()=>{!n&&t&&(n=!0,r.loadSource(t))};return xm(i,"play",()=>{s=!0,r.config.maxBufferLength=o,r.config.maxBufferSize=l,u()},{once:!0}),d(e),d})(e,t,s);null!=e&&e.muxDataKeepSession&&null!=t&&t.mux&&!t.mux.deleted?s&&t.mux.addHLSJS({hlsjs:s,Hls:s?gm:void 0}):Mp(e,t,s),Pp(e,t,s),async function(e,t=df){new Promise(i=>{xm(e,"loadstart",async()=>{let r=await uf(e,[],t);xm(e,"cuechange",()=>{let t=cf(e);if(t){let i=new CustomEvent("cuepointchange",{composed:!0,bubbles:!0,detail:t});e.dispatchEvent(i)}},{},r),i(r)})})}(t),async function(e,t=ff){new Promise(i=>{xm(e,"loadstart",async()=>{let r=await Ef(e,[],t);xm(e,"cuechange",()=>{let t=yf(e);if(t){let i=new CustomEvent("chapterchange",{composed:!0,bubbles:!0,detail:t});e.dispatchEvent(i)}},{},r),i(r)})})}(t);let l=((e,t,i)=>{let{autoplay:r}=e,a=!1,n=!1,s=Ym(r)?r:!!r,o=()=>{a||xm(t,"playing",()=>{a=!0},{once:!0})};if(o(),xm(t,"loadstart",()=>{a=!1,o(),jm(t,s)},{once:!0}),xm(t,"loadstart",()=>{i||(n=e.streamType&&e.streamType!==km.UNKNOWN?e.streamType===km.LIVE:!Number.isFinite(t.duration)),jm(t,s)},{once:!0}),i&&i.once(gm.Events.LEVEL_LOADED,(t,i)=>{var r;n=e.streamType&&e.streamType!==km.UNKNOWN?e.streamType===km.LIVE:null!=(r=i.details.live)&&r}),!s){let r=()=>{!n||Number.isFinite(e.startTime)||(null!=i&&i.liveSyncPosition?t.currentTime=i.liveSyncPosition:Number.isFinite(t.seekable.end(0))&&(t.currentTime=t.seekable.end(0)))};i&&xm(t,"play",()=>{"metadata"===t.preload?i.once(gm.Events.LEVEL_UPDATED,r):r()},{once:!0})}return e=>{a||(s=Ym(e)?e:!!e,jm(t,s))}})(e,t,s);((e,t,i)=>{let{minPreloadSegments:r}=e;if(null==r||r<=0||!i)return;let a=0,n=!1,s=t.playbackRate||1,o=()=>{0!==t.playbackRate&&(s=t.playbackRate,t.playbackRate=0)};t.playbackRate=0,xm(t,"ratechange",o);let l=(e,{frag:i})=>{n||"main"!==i.type||(a++,a>=r&&(n=!0,t.removeEventListener("ratechange",o),t.playbackRate=s))};i.on(gm.Events.FRAG_BUFFERED,l),t.addEventListener("teardown",()=>{n||(n=!0,i.off(gm.Events.FRAG_BUFFERED,l),t.playbackRate=s)},{once:!0})})(e,t,s),((e,t,i)=>{let{initialEstimateSegments:r}=e;if(null==r||r<=0||!i)return;let a=0;i.on(gm.Events.FRAG_BUFFERED,(e,{frag:t})=>{"main"===t.type&&(a++,a<r&&i.abrController.resetEstimator(i.config.abrEwmaDefaultEstimate))})})(e,0,s);let d={engine:s,setAutoplay:l,setPreload:o},u=rp.get(t);return u&&(u.coreReference=d),d},bp=new WeakMap,Tp=(e,t,i)=>{if(!t)return;let r=!!e.disableCookies,a=rp.get(t);!a||a.muxDataDisableCookies===r||(((e,t,i)=>{t&&(t.mux&&(t.mux.deleted||t.mux.destroy(),delete t.mux),!bp.has(t)&&bp.set(t,Promise.resolve().then(()=>{var r,a;bp.delete(t);let n=rp.get(t);if(!n||t.mux&&!t.mux.deleted)return;let s=null==(a=null!=(r=n.coreReference)?r:i)?void 0:a.engine;Mp(e,t,s)})))})(e,t,i),r&&Promise.resolve().then(()=>{e.disableCookies&&(()=>{let e=new Date(0).toUTCString(),t=new Set(["muxData"]);document.cookie.split(";").forEach(e=>{let i=e.split("=")[0].trim();i.startsWith("muxData")&&t.add(i)}),t.forEach(t=>{document.cookie=`${t}=;expires=${e};path=/`})})()}))},Ap=(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",Op),e.removeEventListener("error",Up),e.removeEventListener("durationchange",xp),rp.delete(e),e.dispatchEvent(new Event("teardown")))};function _p(e,t){var i;let r=Nm(e);if(r!==Dm.M3U8)return!0;let a=!r||null==(i=t.canPlayType(r))||i,{preferPlayback:n}=e,s=n===Rm,o=np&&(n===Im||sp(t));return a&&(s||!o)}var Sp=(e,t)=>{let{debug:i,streamType:r,startTime:a=-1,metadata:n,preferCmcd:s,_hlsConfig:o={},maxAutoResolution:l,initialBandwidthEstimateKbps:d}=e,u=Nm(e)===Dm.M3U8,h=_p(e,t);if(u&&!h&&np){let u={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0,capLevelOnFPSDrop:!0,...null!=d?{abrEwmaDefaultEstimate:1e3*d}:{}},h=kp(r),c=Ip(e),m=[Lm.QUERY,Lm.HEADER].includes(s)?{useHeaders:s===Lm.HEADER,sessionId:null==n?void 0:n.view_session_id,contentId:null==n?void 0:n.video_id}:void 0,f=Cp(e,o),p=new gm({debug:i,startPosition:a,cmcd:m,xhrSetup:(e,t)=>{var i,r;if(s&&s!==Lm.QUERY)return;let a=Hm(t);if(!a.searchParams.has("CMCD"))return;let n=(null!=(r=null==(i=a.searchParams.get("CMCD"))?void 0:i.split(","))?r:[]).filter(e=>e.startsWith("sid")||e.startsWith("cid")).join(",");a.searchParams.set("CMCD",n),e.open("GET",a)},...u,...f,...h,...c,...o});return f.capLevelController===Lf&&void 0!==l&&Lf.setMaxAutoResolution(p,l),p.on(gm.Events.MANIFEST_LOADED,async function(e,i){var r;let a=jf(null==(r=i.sessionData)?void 0:r["com.apple.hls.chapters"],i.url);a&&Zf(a,t)}),p}},kp=e=>e===km.LIVE?{backBufferLength:8}:{},Ip=e=>{let{tokens:{drm:t}={},playbackId:i,drmTypeCb:r}=e,a=up(i);return t&&a?{emeEnabled:!0,drmSystems:{"com.apple.fps":{licenseUrl:Lp(e,"fairplay"),serverCertificateUrl:wp(e,"fairplay")},"com.widevine.alpha":{licenseUrl:Lp(e,"widevine")},"com.microsoft.playready":{licenseUrl:Lp(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=>e.includes("fps")?Pf:e.includes("playready")?xf:e.includes("widevine")?Of:void 0)(e);return null==r||r(i),t}))}:{}},Rp=(e,t)=>{let i={mediaEl:t,getAppCertificate:()=>(async e=>{let t=await fetch(e);return 200!==t.status?Promise.reject(t):await t.arrayBuffer()})(wp(e,"fairplay")).catch(t=>{if(t instanceof Response){let i=Sf(t,Em,e);return console.error("mediaError",null==i?void 0:i.message,null==i?void 0:i.context),i?Promise.reject(i):Promise.reject(new Error("Unexpected error in app cert request"))}return Promise.reject(t)}),getLicenseKey:t=>(async(e,t)=>{let i=await fetch(t,{method:"POST",headers:{"Content-type":"application/octet-stream"},body:e});if(200!==i.status)return Promise.reject(i);let r=await i.arrayBuffer();return new Uint8Array(r)})(t,Lp(e,"fairplay")).catch(t=>{if(t instanceof Response){let i=Sf(t,Em,e);return console.error("mediaError",null==i?void 0:i.message,null==i?void 0:i.context),i?Promise.reject(i):Promise.reject(new Error("Unexpected error in license key request"))}return Promise.reject(t)}),saveAndDispatchError:Np,drmTypeCb:()=>{var t;null==(t=e.drmTypeCb)||t.call(e,Pf)}};if(e.useWebkitFairplay)(({mediaEl:e,getAppCertificate:t,getLicenseKey:i,saveAndDispatchError:r,drmTypeCb:a})=>{if(!window.WebKitMediaKeys||!("onwebkitneedkey"in e)){console.error("No WebKitMediaKeys. FairPlay may not be supported");let t=Wm("Cannot play DRM-protected content with current security configuration on this browser. Try playing in another browser."),i=new Am(t,Am.MEDIA_ERR_ENCRYPTED,!0);return i.errorCategory=Em,i.muxCode=ym.ENCRYPTED_CDM_ERROR,r(e,i),()=>{}}let n=e,s=t(),o=null,l=e=>{(async()=>{try{n.webkitKeys||d();let t=await s;if(null===e.initData||null==t)return;let i=wf(e.initData,t);u(i)}catch(e){console.error("Could not start encrypted playback due to exception",e),r(n,e)}})()},d=()=>{try{let e=new WebKitMediaKeys("com.apple.fps.1_0");n.webkitSetMediaKeys(e),a()}catch{let e=new Am("Cannot play DRM-protected content with current security configuration on this browser. Try playing in another browser.",Am.MEDIA_ERR_ENCRYPTED,!0);throw e.errorCategory=Em,e.muxCode=ym.ENCRYPTED_UNSUPPORTED_KEY_SYSTEM,e}},u=t=>{let a=n.webkitKeys.createSession("application/vnd.apple.mpegurl",t),s=async t=>{try{let e=t.message,r=await i(e);a.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 a=Wm("The DRM Content Decryption Module system had an internal failure. Try reloading the page, updating your browser, or playing in another browser."),n=new Am(a,Am.MEDIA_ERR_ENCRYPTED,!0);n.errorCategory=Em,n.muxCode=ym.ENCRYPTED_CDM_ERROR,r(e,n)},d=()=>{a.removeEventListener("webkitkeymessage",s),a.removeEventListener("webkitkeyerror",l),e.removeEventListener("teardown",d),"webkitCurrentPlaybackTargetIsWireless"in e&&e.removeEventListener("webkitcurrentplaybacktargetiswirelesschanged",d),o=null;try{a.close()}catch{}};"webkitCurrentPlaybackTargetIsWireless"in e&&e.addEventListener("webkitcurrentplaybacktargetiswirelesschanged",d,{once:!0}),a.addEventListener("webkitkeymessage",s),a.addEventListener("webkitkeyerror",l),e.addEventListener("teardown",d),o=d},h=()=>{e.removeEventListener("webkitneedkey",l),e.removeEventListener("teardown",h),null==o||o();try{n.webkitSetMediaKeys(null)}catch{}};e.addEventListener("webkitneedkey",l),e.addEventListener("teardown",h,{once:!0})})(i);else{let t={fallbackToWebkitFairplay:async()=>{var t;await r(),null==(t=e.fallbackToWebkitFairplay)||t.call(e)},...i},r=Cf(t)}},Lp=({playbackId:e,tokens:{drm:t}={},customDomain:i=ap},r)=>{let a=up(e);return`https://license.${i.toLocaleLowerCase().endsWith(ap)?i:ap}/license/${r}/${a}?token=${t}`},wp=({playbackId:e,tokens:{drm:t}={},customDomain:i=ap},r)=>{let a=up(e);return`https://license.${i.toLocaleLowerCase().endsWith(ap)?i:ap}/appcert/${r}/${a}?token=${t}`},Dp=({playbackId:e,src:t,customDomain:i})=>{if(e)return!0;if("string"!=typeof t)return!1;let r=null==window?void 0:window.location.href,a=new URL(t,r).hostname.toLocaleLowerCase();return a.includes(ap)||!!i&&a.includes(i.toLocaleLowerCase())},Cp=(e,t)=>{let i={};return i.capLevelToPlayerSize=e.capRenditionToPlayerSize,null==i.capLevelToPlayerSize?(i.capLevelController=Lf,i.capLevelToPlayerSize=!0):i.capLevelController=Ed,i},Mp=(e,t,i)=>{var r;let{envKey:a,disableTracking:n,muxDataSDK:s=gi,muxDataSDKOptions:o={}}=e,l=Dp(e),d=rp.get(t);if(d&&(d.muxDataDisableCookies=!!e.disableCookies),!n&&(a||l)){let{playerInitTime:n,playerSoftwareName:l,playerSoftwareVersion:d,beaconCollectionDomain:u,debug:h,disableCookies:c}=e,m={...e.metadata,video_title:(null==(r=null==e?void 0:e.metadata)?void 0:r.video_title)||void 0},f=t=>"string"!=typeof t.player_error_code&&("function"==typeof e.errorTranslator?e.errorTranslator(t):t);s.monitor(t,{debug:h,beaconCollectionDomain:u,hlsjs:i,Hls:i?gm:void 0,automaticErrorTracking:!1,errorTranslator:f,disableCookies:c,...o,data:{...a?{env_key:a}:{},player_software_name:l,player_software:l,player_software_version:d,player_init_time:n,...m}})}},Pp=(e,t,i)=>{var r,a,n;let s,o,l=_p(e,t),{src:d,customDomain:u=ap}=e,h=()=>{t.ended||e.disablePseudoEnded||!Ep(t,i)||(vp(t,i)?t.currentTime=t.buffered.end(t.buffered.length-1):t.dispatchEvent(new Event("ended")))},c=()=>{let e,i,r=fp(t);r.length>0&&(e=r.start(0),i=r.end(0)),(o!==i||s!==e)&&t.dispatchEvent(new CustomEvent("seekablechange",{composed:!0})),s=e,o=i};if(xm(t,"durationchange",c),t&&l){let i=Nm(e);if("string"==typeof d){if(d.endsWith(".mp4")&&d.includes(u)){let e=hp(d);(async(e,t,i=zf(t))=>{let r=await Qf(e,i);void 0!==r&&Xf(r,t)})(new URL(`https://stream.${u}/${e}/metadata.json`).toString(),t)}let n=()=>{if(mp(t)!==km.LIVE||Number.isFinite(t.duration))return;let e=setInterval(c,1e3);t.addEventListener("teardown",()=>{clearInterval(e)},{once:!0}),xm(t,"durationchange",()=>{Number.isFinite(t.duration)&&clearInterval(e)})},s=async()=>{let r=zf(t);return(async(e,t,i=Nm({src:e}),r=zf(t))=>{var a,n,s;let{streamType:o,targetLiveWindow:l,liveEdgeStartOffset:d,sessionData:u,playlistUrl:h}=await Yf(e,i,r);if(r.aborted)return;let c=jf(null==u?void 0:u["com.apple.hls.chapters"],null!=h?h:e);c&&Zf(c,t,r),(null!=(a=rp.get(t))?a:{}).liveEdgeStartOffset=d,(null!=(n=rp.get(t))?n:{}).targetLiveWindow=l,t.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),(null!=(s=rp.get(t))?s:{}).streamType=o,t.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))})(d,t,i,r).then(()=>{r.aborted||n()}).catch(i=>{if(i instanceof Response){let r=Sf(i,vm,e);if(r)return void Np(t,r)}else Error})};if("none"===t.preload){let e=()=>{s(),t.removeEventListener("loadedmetadata",i)},i=()=>{s(),t.removeEventListener("play",e)};xm(t,"play",e,{once:!0}),xm(t,"loadedmetadata",i,{once:!0})}else s();null!=(r=e.tokens)&&r.drm?Rp(e,t):xm(t,"encrypted",()=>{let e=Wm("Attempting to play DRM-protected content without providing a DRM token."),i=new Am(e,Am.MEDIA_ERR_ENCRYPTED,!0);i.errorCategory=Em,i.muxCode=ym.ENCRYPTED_MISSING_TOKEN,Np(t,i)},{once:!0}),t.setAttribute("src",d),e.startTime&&((null!=(a=rp.get(t))?a:{}).startTime=e.startTime,t.addEventListener("durationchange",xp,{once:!0}))}else t.removeAttribute("src");t.addEventListener("error",Op),t.addEventListener("error",Up),t.addEventListener("emptied",()=>{t.querySelectorAll("track[data-removeondestroy]").forEach(e=>{e.remove()})},{once:!0}),xm(t,"pause",h),xm(t,"seeked",h),xm(t,"play",()=>{t.ended||gp(t.currentTime,t.duration)&&(t.currentTime=t.seekable.length?t.seekable.start(0):0)})}else if(i&&d){i.once(gm.Events.LEVEL_LOADED,(e,r)=>{Jf(r.details,t,i),c(),mp(t)===km.LIVE&&!Number.isFinite(t.duration)&&(i.on(gm.Events.LEVEL_UPDATED,c),xm(t,"durationchange",()=>{Number.isFinite(t.duration)&&i.off(gm.Events.LEVELS_UPDATED,c)}))});let r=null!=(n=e.maxReconnectRetries)?n:0,a=r>0?Mf({hls:i,mediaEl:t,src:d,muxMediaState:rp,saveAndDispatchError:Np,maxRetries:r}):void 0;i.on(gm.Events.ERROR,(r,n)=>{var s,o;let l=Fp(n,e);if(l.muxCode===ym.NETWORK_NOT_READY){let e=null!=(s=rp.get(t))?s:{},r=null!=(o=e.retryCount)?o:0;if(r<6){let a=0===r?5e3:6e4,s=new Am(`Retrying in ${a/1e3} seconds...`,l.code,l.fatal);Object.assign(s,l),Np(t,s);let o=setTimeout(()=>{e.retryCount=r+1,"manifestLoadError"===n.details&&n.url&&i.loadSource(n.url)},a);return void t.addEventListener("teardown",()=>clearTimeout(o),{once:!0})}{e.retryCount=0;let i=new Am("Network error, try reloading.",l.code,l.fatal);return Object.assign(i,l),i.reload=!0,void Np(t,i)}}null!=a&&a.handleHlsError(n,l)||Np(t,l)}),i.on(gm.Events.MANIFEST_LOADED,()=>{null==a||a.onManifestLoaded();let e=rp.get(t);null!=e&&e.networkError||e&&e.error&&(e.error=null,e.retryCount=0,t.dispatchEvent(new Event("emptied")),t.dispatchEvent(new Event("loadstart")))}),t.addEventListener("error",Up),xm(t,"waiting",h),zm(e,i),function(e,t){t.on(gm.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(i,{tracks:r})=>{r.forEach(i=>{var r,a;let n=null!=(r=i.subtitleTrack)?r:i.closedCaptions,s=t.subtitleTracks.findIndex(({lang:e,name:t,type:r})=>e==(null==n?void 0:n.lang)&&t===i.label&&r.toLowerCase()===i.kind),o=(null!=(a=i._id)?a:i.default)?"default":`${i.kind}${s}`;rf(e,i.kind,i.label,null==n?void 0:n.lang,o,i.default)})});let i=()=>{if(!t.subtitleTracks.length)return;let i=Array.from(e.textTracks).find(e=>e.id&&"showing"===e.mode&&["subtitles","captions"].includes(e.kind));if(!i)return;let r=t.subtitleTracks[t.subtitleTrack],a=r?r.default?"default":`${t.subtitleTracks[t.subtitleTrack].type.toLowerCase()}${t.subtitleTrack}`:void 0;if(t.subtitleTrack<0||(null==i?void 0:i.id)!==a){let e=t.subtitleTracks.findIndex(({lang:e,name:t,type:r,default:a})=>"default"===i.id&&a||e==i.language&&t===i.label&&r.toLowerCase()===i.kind);t.subtitleTrack=e}(null==i?void 0:i.id)===a&&i.cues&&Array.from(i.cues).forEach(e=>{i.addCue(e)})};e.textTracks.addEventListener("change",i),t.on(gm.Events.CUES_PARSED,(t,{track:i,cues:r})=>{let a=e.textTracks.getTrackById(i);if(!a)return;let n="disabled"===a.mode;n&&(a.mode="hidden"),r.forEach(e=>{var t;null!=(t=a.cues)&&t.getCueById(e.id)||a.addCue(e)}),n&&(a.mode="disabled")}),t.once(gm.Events.DESTROYING,()=>{e.textTracks.removeEventListener("change",i),e.querySelectorAll("track[data-removeondestroy]").forEach(e=>{e.remove()})});let r=()=>{Array.from(e.textTracks).forEach(t=>{var i;if(!["subtitles","caption"].includes(t.kind)&&("thumbnails"===t.label||"chapters"===t.kind)){if(null==(i=t.cues)||!i.length){let i="track";t.kind&&(i+=`[kind="${t.kind}"]`),t.label&&(i+=`[label="${t.label}"]`);let r=e.querySelector(i),a=null==r?void 0:r.getAttribute("src");r&&a&&(r.removeAttribute("src"),setTimeout(()=>{r.setAttribute("src",a)},0))}"hidden"!==t.mode&&(t.mode="hidden")}})};t.once(gm.Events.MANIFEST_LOADED,r),t.once(gm.Events.MEDIA_ATTACHED,r)}(t,i),i.attachMedia(t)}else 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 xp(e){var t;let i=e.target,r=null==(t=rp.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 Op(e){if(!e.isTrusted)return;e.stopImmediatePropagation();let t=e.target;if(null==t||!t.error)return;let{message:i,code:r}=t.error,a=new Am(i,r);if(t.src&&r===Am.MEDIA_ERR_SRC_NOT_SUPPORTED&&t.readyState===HTMLMediaElement.HAVE_NOTHING)setTimeout(()=>{var e;let i=null!=(e=cp(t))?e:t.error;(null==i?void 0:i.code)===Am.MEDIA_ERR_SRC_NOT_SUPPORTED&&Np(t,a)},500);else{if(t.src&&(r!==Am.MEDIA_ERR_DECODE||void 0!==r))try{let{status:e}=await fetch(t.src);a.data={response:{code:e}}}catch{}Np(t,a)}}function Np(e,t){var i;t.fatal&&((null!=(i=rp.get(e))?i:{}).error=t,e.dispatchEvent(new CustomEvent("error",{detail:t})))}function Up(e){var t,i;if(!(e instanceof CustomEvent&&e.detail instanceof Am))return;let r=e.target,a=e.detail;!a||!a.fatal||((null!=(t=rp.get(r))?t:{}).error=a,null==(i=r.mux)||i.emit("error",{player_error_code:a.code,player_error_message:a.message,player_error_context:a.context}))}var Fp=(e,t)=>{var i,r,a;e.fatal?console.error("getErrorFromHlsErrorData()",e):t.debug&&console.warn("getErrorFromHlsErrorData() (non-fatal)",e);let n,s={[gm.ErrorTypes.NETWORK_ERROR]:Am.MEDIA_ERR_NETWORK,[gm.ErrorTypes.MEDIA_ERROR]:Am.MEDIA_ERR_DECODE,[gm.ErrorTypes.KEY_SYSTEM_ERROR]:Am.MEDIA_ERR_ENCRYPTED},o=(l=e,[gm.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,gm.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED].includes(l.details)?Am.MEDIA_ERR_NETWORK:s[l.type]);var l;if(o===Am.MEDIA_ERR_NETWORK&&e.response){let a=null!=(i=(e=>e.type===gm.ErrorTypes.KEY_SYSTEM_ERROR?Em:e.type===gm.ErrorTypes.NETWORK_ERROR?vm:void 0)(e))?i:vm;n=null!=(r=Sf(e.response,a,t,e.fatal))?r:new Am("",o,e.fatal)}else if(o===Am.MEDIA_ERR_ENCRYPTED)if(e.details===gm.ErrorDetails.KEY_SYSTEM_NO_CONFIGURED_LICENSE){let t=Wm("Attempting to play DRM-protected content without providing a DRM token.");n=new Am(t,Am.MEDIA_ERR_ENCRYPTED,e.fatal),n.errorCategory=Em,n.muxCode=ym.ENCRYPTED_MISSING_TOKEN}else if(e.details===gm.ErrorDetails.KEY_SYSTEM_NO_ACCESS){let t=Wm("Cannot play DRM-protected content with current security configuration on this browser. Try playing in another browser.");n=new Am(t,Am.MEDIA_ERR_ENCRYPTED,e.fatal),n.errorCategory=Em,n.muxCode=ym.ENCRYPTED_UNSUPPORTED_KEY_SYSTEM}else if(e.details===gm.ErrorDetails.KEY_SYSTEM_NO_SESSION){let e=Wm("Failed to generate a DRM license request. This may be an issue with the player or your protected content.");n=new Am(e,Am.MEDIA_ERR_ENCRYPTED,!0),n.errorCategory=Em,n.muxCode=ym.ENCRYPTED_GENERATE_REQUEST_FAILED}else if(e.details===gm.ErrorDetails.KEY_SYSTEM_SESSION_UPDATE_FAILED){let t=Wm("Failed to update DRM license. This may be an issue with the player or your protected content.");n=new Am(t,Am.MEDIA_ERR_ENCRYPTED,e.fatal),n.errorCategory=Em,n.muxCode=ym.ENCRYPTED_UPDATE_LICENSE_FAILED}else if(e.details===gm.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED){let t=Wm("Your server certificate failed when attempting to set it. This may be an issue with a no longer valid certificate.");n=new Am(t,Am.MEDIA_ERR_ENCRYPTED,e.fatal),n.errorCategory=Em,n.muxCode=ym.ENCRYPTED_UPDATE_SERVER_CERT_FAILED}else if(e.details===gm.ErrorDetails.KEY_SYSTEM_STATUS_INTERNAL_ERROR){let t=Wm("The DRM Content Decryption Module system had an internal failure. Try reloading the page, updating your browser, or playing in another browser.");n=new Am(t,Am.MEDIA_ERR_ENCRYPTED,e.fatal),n.errorCategory=Em,n.muxCode=ym.ENCRYPTED_CDM_ERROR}else if(e.details===gm.ErrorDetails.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED){let e=Wm("DRM playback is being attempted in an environment that is not sufficiently secure. User may see black screen.");n=new Am(e,Am.MEDIA_ERR_ENCRYPTED,!1),n.errorCategory=Em,n.muxCode=ym.ENCRYPTED_OUTPUT_RESTRICTED}else n=new Am(e.error.message,Am.MEDIA_ERR_ENCRYPTED,e.fatal),n.errorCategory=Em,n.muxCode=ym.ENCRYPTED_ERROR;else n=new Am("",o,e.fatal);return n.context||(n.context=`${e.url?`url: ${e.url}\n`:""}${e.response&&(e.response.code||e.response.text)?`response: ${e.response.code}, ${e.response.text}\n`:""}${e.reason?`failure reason: ${e.reason}\n`:""}${e.level?`level: ${e.level}\n`:""}${e.parent?`parent stream controller: ${e.parent}\n`:""}${e.buffer?`buffer length: ${e.buffer}\n`:""}${e.error?`error: ${e.error}\n`:""}${e.event?`event: ${e.event}\n`:""}${e.err?`error message: ${null==(a=e.err)?void 0:a.message}\n`:""}`),n.data=e,n},Bp=["abort","canplay","canplaythrough","durationchange","emptied","encrypted","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting","waitingforkey","resize","enterpictureinpicture","leavepictureinpicture","webkitbeginfullscreen","webkitendfullscreen","webkitpresentationmodechanged"],$p=["autopictureinpicture","disablepictureinpicture","disableremoteplayback","autoplay","controls","controlslist","crossorigin","loop","muted","playsinline","poster","preload","src"];function Hp(e){return`\n    <style>\n      :host {\n        display: inline-flex;\n        line-height: 0;\n        flex-direction: column;\n        justify-content: end;\n      }\n\n      audio {\n        width: 100%;\n      }\n    </style>\n    <slot name="media">\n      <audio${Wp(e)}></audio>\n    </slot>\n    <slot></slot>\n  `}function Gp(e){return`\n    <style>\n      :host {\n        display: inline-block;\n        line-height: 0;\n      }\n\n      video {\n        max-width: 100%;\n        max-height: 100%;\n        min-width: 100%;\n        min-height: 100%;\n        object-fit: var(--media-object-fit, contain);\n        object-position: var(--media-object-position, 50% 50%);\n      }\n\n      video::-webkit-media-text-track-container {\n        transform: var(--media-webkit-text-track-transform);\n        transition: var(--media-webkit-text-track-transition);\n      }\n    </style>\n    <slot name="media">\n      <video${Wp(e)}></video>\n    </slot>\n    <slot></slot>\n  `}function Kp(e,{tag:t,is:i}){var r,n,u,h,c,m,f,p,g,v,E,y,b,T,A,_,S,k,I;let R=null==(n=null==(r=globalThis.document)?void 0:r.createElement)?void 0:n.call(r,t,{is:i}),L=R?function(e){let t=[];for(let i=Object.getPrototypeOf(e);i&&i!==HTMLElement.prototype;i=Object.getPrototypeOf(i)){let e=Object.getOwnPropertyNames(i);t.push(...e)}return t}(R):[];return u=class extends e{constructor(){super(...arguments),o(this,y),o(this,f,!1),o(this,p,null),o(this,g,new Map),o(this,v),o(this,E),a(this,"get"),a(this,"set"),a(this,"call")}static get observedAttributes(){var e,t,i;return d(e=u,c,m).call(e),[...null!=(i=null==(t=null==R?void 0:R.constructor)?void 0:t.observedAttributes)?i:[],...$p]}get nativeEl(){var e,i,r,a,n;return d(this,y,b).call(this),null!=(n=null!=(a=null!=(i=null!=(e=s(this,p))?e:this.querySelector(":scope > [slot=media]"))?i:this.querySelector(t))?a:null==(r=this.shadowRoot)?void 0:r.querySelector(t))?n:null}set nativeEl(e){l(this,p,e)}get defaultMuted(){return this.hasAttribute("muted")}set defaultMuted(e){this.toggleAttribute("muted",e)}get src(){return this.getAttribute("src")}set src(e){this.setAttribute("src",`${e}`)}get preload(){var e,t;return null!=(t=this.getAttribute("preload"))?t:null==(e=this.nativeEl)?void 0:e.preload}set preload(e){this.setAttribute("preload",`${e}`)}init(){if(!this.shadowRoot){this.attachShadow({mode:"open"});let e=function(e){let t={};for(let i of e)t[i.name]=i.value;return t}(this.attributes);i&&(e.is=i),t&&(e.part=t),this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e)}this.nativeEl.muted=this.hasAttribute("muted");for(let e of L)d(this,y,k).call(this,e);d(this,y,T).call(this)}handleEvent(e){e.target===this.nativeEl&&this.dispatchEvent(new CustomEvent(e.type,{detail:e.detail}))}attributeChangedCallback(e,t,i){d(this,y,b).call(this),d(this,y,I).call(this,e,t,i)}connectedCallback(){d(this,y,b).call(this),s(this,E)||d(this,y,T).call(this)}disconnectedCallback(){var e,t,i;null==(e=s(this,v))||e.disconnect(),l(this,v,void 0),s(this,E)&&(null==(t=this.shadowRoot)||t.removeEventListener("slotchange",s(this,E)),l(this,E,void 0));for(let e of this.constructor.Events)null==(i=this.shadowRoot)||i.removeEventListener(e,this,!0);s(this,g).forEach(e=>e.remove()),s(this,g).clear(),l(this,p,null)}},h=new WeakMap,c=new WeakSet,m=function(){if(s(this,h))return;l(this,h,!0);let e=new Set(this.observedAttributes);e.delete("muted");for(let t of L)if(!(t in this.prototype))if("function"==typeof R[t])this.prototype[t]=function(...e){return d(this,y,b).call(this),(()=>{var i;if(this.call)return this.call(t,...e);let r=null==(i=this.nativeEl)?void 0:i[t];return null==r?void 0:r.apply(this.nativeEl,e)})()};else{let i={get(){var i,r,a;d(this,y,b).call(this);let n=t.toLowerCase();if(e.has(n)){let e=this.getAttribute(n);return null!==e&&(""===e||e)}return null!=(a=null==(i=this.get)?void 0:i.call(this,t))?a:null==(r=this.nativeEl)?void 0:r[t]}};t!==t.toUpperCase()&&(i.set=function(i){d(this,y,b).call(this);let r=t.toLowerCase();e.has(r)?!0===i||!1===i||null==i?this.toggleAttribute(r,!!i):this.setAttribute(r,i):this.set?this.set(t,i):this.nativeEl&&(this.nativeEl[t]=i)}),Object.defineProperty(this.prototype,t,i)}},f=new WeakMap,p=new WeakMap,g=new WeakMap,v=new WeakMap,E=new WeakMap,y=new WeakSet,b=function(){s(this,f)||(l(this,f,!0),this.init())},T=function(){var e,t;l(this,v,new MutationObserver(d(this,y,_).bind(this))),l(this,E,()=>d(this,y,A).call(this)),null==(e=this.shadowRoot)||e.addEventListener("slotchange",s(this,E)),d(this,y,A).call(this);for(let e of this.constructor.Events)null==(t=this.shadowRoot)||t.addEventListener(e,this,!0)},A=function(){var e;let t=new Map(s(this,g)),i=null==(e=this.shadowRoot)?void 0:e.querySelector("slot:not([name])");(null==i?void 0:i.assignedElements({flatten:!0}).filter(e=>["track","source"].includes(e.localName))).forEach(e=>{var i,r;t.delete(e);let a=s(this,g).get(e);a||(a=e.cloneNode(),s(this,g).set(e,a),null==(i=s(this,v))||i.observe(e,{attributes:!0})),null==(r=this.nativeEl)||r.append(a),d(this,y,S).call(this,a)}),t.forEach((e,t)=>{e.remove(),s(this,g).delete(t)})},_=function(e){var t;for(let i of e)if("attributes"===i.type){let{target:e,attributeName:r}=i,a=s(this,g).get(e);a&&r&&(a.setAttribute(r,null!=(t=e.getAttribute(r))?t:""),d(this,y,S).call(this,a))}},S=function(e){e&&"track"===e.localName&&e.default&&("chapters"===e.kind||"metadata"===e.kind)&&"disabled"===e.track.mode&&(e.track.mode="hidden")},k=function(e){if(Object.prototype.hasOwnProperty.call(this,e)){let t=this[e];delete this[e],this[e]=t}},I=function(e,t,i){var r,a,n;["id","class"].includes(e)||!u.observedAttributes.includes(e)&&this.constructor.observedAttributes.includes(e)||(null===i?null==(r=this.nativeEl)||r.removeAttribute(e):(null==(a=this.nativeEl)?void 0:a.getAttribute(e))!==i&&(null==(n=this.nativeEl)||n.setAttribute(e,i)))},o(u,c),a(u,"getTemplateHTML",t.endsWith("audio")?Hp:Gp),a(u,"shadowRootOptions",{mode:"open"}),a(u,"Events",Bp),o(u,h,!1),u}function Wp(e){let t="";for(let i in e){if(!$p.includes(i))continue;let r=e[i];t+=""===r?` ${Vp(i)}`:` ${Vp(i)}="${Vp(`${r}`)}"`}return t}function Vp(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/`/g,"&#x60;")}var qp,Yp,jp=Kp(null!=(qp=globalThis.HTMLElement)?qp:class{},{tag:"video"}),zp=(Kp(null!=(Yp=globalThis.HTMLElement)?Yp:class{},{tag:"audio"}),e=>{throw TypeError(e)}),Qp=(e,t,i)=>t.has(e)||zp("Cannot "+i),Xp=(e,t,i)=>(Qp(e,t,"read from private field"),i?i.call(e):t.get(e)),Zp=(e,t,i)=>t.has(e)?zp("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,i),Jp=(e,t,i,r)=>(Qp(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i),eg=(e,t,i)=>(Qp(e,t,"access private method"),i),tg=(()=>{try{return"0.31.6"}catch{}return"UNKNOWN"})();var ig,rg,ag,ng,sg,og,lg,dg,ug,hg,cg,mg,fg,pg,gg={BEACON_COLLECTION_DOMAIN:"beacon-collection-domain",CUSTOM_DOMAIN:"custom-domain",DEBUG:"debug",DISABLE_TRACKING:"disable-tracking",DISABLE_COOKIES:"disable-cookies",DISABLE_PSEUDO_ENDED:"disable-pseudo-ended",MAX_RECONNECT_RETRIES:"max-reconnect-retries",DRM_TOKEN:"drm-token",PLAYBACK_TOKEN:"playback-token",ENV_KEY:"env-key",MAX_RESOLUTION:"max-resolution",MIN_RESOLUTION:"min-resolution",MAX_AUTO_RESOLUTION:"max-auto-resolution",RENDITION_ORDER:"rendition-order",PROGRAM_START_TIME:"program-start-time",PROGRAM_END_TIME:"program-end-time",ASSET_START_TIME:"asset-start-time",ASSET_END_TIME:"asset-end-time",METADATA_URL:"metadata-url",PLAYBACK_ID:"playback-id",PLAYER_SOFTWARE_NAME:"player-software-name",PLAYER_SOFTWARE_VERSION:"player-software-version",PLAYER_INIT_TIME:"player-init-time",PREFER_CMCD:"prefer-cmcd",PREFER_PLAYBACK:"prefer-playback",START_TIME:"start-time",STREAM_TYPE:"stream-type",TARGET_LIVE_WINDOW:"target-live-window",LIVE_EDGE_OFFSET:"live-edge-offset",TYPE:"type",LOGO:"logo",CAP_RENDITION_TO_PLAYER_SIZE:"cap-rendition-to-player-size",INITIAL_BANDWIDTH_ESTIMATE_KBPS:"initial-bandwidth-estimate-kbps",INITIAL_ESTIMATE_SEGMENTS:"initial-estimate-segments",MIN_PRELOAD_SEGMENTS:"min-preload-segments"},vg=Object.values(gg),Eg=tg,yg="mux-video",bg=class extends jp{constructor(){super(),Zp(this,cg),Zp(this,ig),Zp(this,rg),Zp(this,ag,{}),Zp(this,ng,{}),Zp(this,sg),Zp(this,og),Zp(this,lg),Zp(this,dg),Zp(this,ug,""),Zp(this,hg,e=>{var t;let i=(e=>{var t;return null==(t=rp.get(e))?void 0:t.metadata})(this.nativeEl),r=null!=(t=this.metadata)?t:{};this.metadata={...i,...r},"mux-free-plan"===(null==i?void 0:i["com.mux.video.branding"])&&(Jp(this,ug,"default"),this.updateLogo())}),Zp(this,fg),Jp(this,rg,op())}static get NAME(){return yg}static get VERSION(){return Eg}static get observedAttributes(){var e;return[...vg,...null!=(e=jp.observedAttributes)?e:[]]}static getLogoHTML(e){return e&&"false"!==e?"default"===e?'\n<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" part="logo" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2" viewBox="0 0 1600 500"><g fill="#fff"><path d="M994.287 93.486c-17.121 0-31-13.879-31-31 0-17.121 13.879-31 31-31 17.121 0 31 13.879 31 31 0 17.121-13.879 31-31 31m0-93.486c-34.509 0-62.484 27.976-62.484 62.486v187.511c0 68.943-56.09 125.033-125.032 125.033s-125.03-56.09-125.03-125.033V62.486C681.741 27.976 653.765 0 619.256 0s-62.484 27.976-62.484 62.486v187.511C556.772 387.85 668.921 500 806.771 500c137.851 0 250.001-112.15 250.001-250.003V62.486c0-34.51-27.976-62.486-62.485-62.486M1537.51 468.511c-17.121 0-31-13.879-31-31 0-17.121 13.879-31 31-31 17.121 0 31 13.879 31 31 0 17.121-13.879 31-31 31m-275.883-218.509-143.33 143.329c-24.402 24.402-24.402 63.966 0 88.368 24.402 24.402 63.967 24.402 88.369 0l143.33-143.329 143.328 143.329c24.402 24.4 63.967 24.402 88.369 0 24.403-24.402 24.403-63.966.001-88.368l-143.33-143.329.001-.004 143.329-143.329c24.402-24.402 24.402-63.965 0-88.367s-63.967-24.402-88.369 0L1349.996 161.63 1206.667 18.302c-24.402-24.401-63.967-24.402-88.369 0s-24.402 63.965 0 88.367l143.329 143.329v.004ZM437.511 468.521c-17.121 0-31-13.879-31-31 0-17.121 13.879-31 31-31 17.121 0 31 13.879 31 31 0 17.121-13.879 31-31 31M461.426 4.759C438.078-4.913 411.2.432 393.33 18.303L249.999 161.632 106.669 18.303C88.798.432 61.922-4.913 38.573 4.759 15.224 14.43-.001 37.214-.001 62.488v375.026c0 34.51 27.977 62.486 62.487 62.486 34.51 0 62.486-27.976 62.486-62.486V213.341l80.843 80.844c24.404 24.402 63.965 24.402 88.369 0l80.843-80.844v224.173c0 34.51 27.976 62.486 62.486 62.486s62.486-27.976 62.486-62.486V62.488c0-25.274-15.224-48.058-38.573-57.729" style="fill-rule:nonzero"/></g></svg>':`<img part="logo" src="${function(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}(e)}" />`:""}static getTemplateHTML(e={}){var t;return`\n      ${jp.getTemplateHTML(e)}\n      <style>\n        :host {\n          position: relative;\n        }\n        slot[name="logo"] {\n          display: flex;\n          justify-content: end;\n          position: absolute;\n          top: 1rem;\n          right: 1rem;\n          opacity: 0;\n          transition: opacity 0.25s ease-in-out;\n          z-index: 1;\n        }\n        slot[name="logo"]:has([part="logo"]) {\n          opacity: 1;\n        }\n        slot[name="logo"] [part="logo"] {\n          width: 5rem;\n          pointer-events: none;\n          user-select: none;\n        }\n      </style>\n      <slot name="logo">\n        ${this.getLogoHTML(null!=(t=e[gg.LOGO])?t:"")}\n      </slot>\n    `}get preferCmcd(){var e;return null!=(e=this.getAttribute(gg.PREFER_CMCD))?e:void 0}set preferCmcd(e){e!==this.preferCmcd&&(e?wm.includes(e)?this.setAttribute(gg.PREFER_CMCD,e):console.warn(`Invalid value for preferCmcd. Must be one of ${wm.join()}`):this.removeAttribute(gg.PREFER_CMCD))}get playerInitTime(){return this.hasAttribute(gg.PLAYER_INIT_TIME)?+this.getAttribute(gg.PLAYER_INIT_TIME):Xp(this,rg)}set playerInitTime(e){e!=this.playerInitTime&&(null==e?this.removeAttribute(gg.PLAYER_INIT_TIME):this.setAttribute(gg.PLAYER_INIT_TIME,""+ +e))}get playerSoftwareName(){var e;return null!=(e=Xp(this,lg))?e:yg}set playerSoftwareName(e){Jp(this,lg,e)}get playerSoftwareVersion(){var e;return null!=(e=Xp(this,og))?e:Eg}set playerSoftwareVersion(e){Jp(this,og,e)}get _hls(){var e;return null==(e=Xp(this,cg,mg))?void 0:e.engine}get mux(){var e;return null==(e=this.nativeEl)?void 0:e.mux}get error(){var e;return null!=(e=cp(this.nativeEl))?e:null}get errorTranslator(){return Xp(this,dg)}set errorTranslator(e){Jp(this,dg,e)}get src(){return this.getAttribute("src")}set src(e){e!==this.src&&(null==e?this.removeAttribute("src"):this.setAttribute("src",e))}get type(){var e;return null!=(e=this.getAttribute(gg.TYPE))?e:void 0}set type(e){e!==this.type&&(e?this.setAttribute(gg.TYPE,e):this.removeAttribute(gg.TYPE))}get preload(){let e=this.getAttribute("preload");return""===e?"auto":["none","metadata","auto"].includes(e)?e:super.preload}set preload(e){e!=this.getAttribute("preload")&&(["","none","metadata","auto"].includes(e)?this.setAttribute("preload",e):this.removeAttribute("preload"))}get debug(){return null!=this.getAttribute(gg.DEBUG)}set debug(e){e!==this.debug&&(e?this.setAttribute(gg.DEBUG,""):this.removeAttribute(gg.DEBUG))}get disableTracking(){return this.hasAttribute(gg.DISABLE_TRACKING)}set disableTracking(e){e!==this.disableTracking&&this.toggleAttribute(gg.DISABLE_TRACKING,!!e)}get disableCookies(){return this.hasAttribute(gg.DISABLE_COOKIES)}set disableCookies(e){e!==this.disableCookies&&(e?this.setAttribute(gg.DISABLE_COOKIES,""):this.removeAttribute(gg.DISABLE_COOKIES))}get disablePseudoEnded(){return this.hasAttribute(gg.DISABLE_PSEUDO_ENDED)}set disablePseudoEnded(e){e!==this.disablePseudoEnded&&(e?this.setAttribute(gg.DISABLE_PSEUDO_ENDED,""):this.removeAttribute(gg.DISABLE_PSEUDO_ENDED))}get maxReconnectRetries(){let e=this.getAttribute(gg.MAX_RECONNECT_RETRIES);if(null==e)return;let t=+e;return Number.isNaN(t)?void 0:t}set maxReconnectRetries(e){e!==this.maxReconnectRetries&&(null==e?this.removeAttribute(gg.MAX_RECONNECT_RETRIES):this.setAttribute(gg.MAX_RECONNECT_RETRIES,`${e}`))}get startTime(){let e=this.getAttribute(gg.START_TIME);if(null==e)return;let t=+e;return Number.isNaN(t)?void 0:t}set startTime(e){e!==this.startTime&&(null==e?this.removeAttribute(gg.START_TIME):this.setAttribute(gg.START_TIME,`${e}`))}get initialBandwidthEstimateKbps(){let e=this.getAttribute(gg.INITIAL_BANDWIDTH_ESTIMATE_KBPS);if(null==e)return;let t=+e;return Number.isNaN(t)?void 0:t}set initialBandwidthEstimateKbps(e){e!==this.initialBandwidthEstimateKbps&&(null==e?this.removeAttribute(gg.INITIAL_BANDWIDTH_ESTIMATE_KBPS):this.setAttribute(gg.INITIAL_BANDWIDTH_ESTIMATE_KBPS,`${e}`))}get initialEstimateSegments(){let e=this.getAttribute(gg.INITIAL_ESTIMATE_SEGMENTS);if(null==e)return;let t=+e;return Number.isNaN(t)?void 0:t}set initialEstimateSegments(e){e!==this.initialEstimateSegments&&(null==e?this.removeAttribute(gg.INITIAL_ESTIMATE_SEGMENTS):this.setAttribute(gg.INITIAL_ESTIMATE_SEGMENTS,`${e}`))}get minPreloadSegments(){let e=this.getAttribute(gg.MIN_PRELOAD_SEGMENTS);if(null==e)return;let t=+e;return Number.isNaN(t)?void 0:t}set minPreloadSegments(e){e!==this.minPreloadSegments&&(null==e?this.removeAttribute(gg.MIN_PRELOAD_SEGMENTS):this.setAttribute(gg.MIN_PRELOAD_SEGMENTS,`${e}`))}get playbackId(){var e;return this.hasAttribute(gg.PLAYBACK_ID)?this.getAttribute(gg.PLAYBACK_ID):null!=(e=hp(this.src))?e:void 0}set playbackId(e){e!==this.playbackId&&(e?this.setAttribute(gg.PLAYBACK_ID,e):this.removeAttribute(gg.PLAYBACK_ID))}get maxResolution(){var e;return null!=(e=this.getAttribute(gg.MAX_RESOLUTION))?e:void 0}set maxResolution(e){e!==this.maxResolution&&(e?this.setAttribute(gg.MAX_RESOLUTION,e):this.removeAttribute(gg.MAX_RESOLUTION))}get minResolution(){var e;return null!=(e=this.getAttribute(gg.MIN_RESOLUTION))?e:void 0}set minResolution(e){e!==this.minResolution&&(e?this.setAttribute(gg.MIN_RESOLUTION,e):this.removeAttribute(gg.MIN_RESOLUTION))}get maxAutoResolution(){var e;return null!=(e=this.getAttribute(gg.MAX_AUTO_RESOLUTION))?e:void 0}set maxAutoResolution(e){null==e?this.removeAttribute(gg.MAX_AUTO_RESOLUTION):this.setAttribute(gg.MAX_AUTO_RESOLUTION,e)}get renditionOrder(){var e;return null!=(e=this.getAttribute(gg.RENDITION_ORDER))?e:void 0}set renditionOrder(e){e!==this.renditionOrder&&(e?this.setAttribute(gg.RENDITION_ORDER,e):this.removeAttribute(gg.RENDITION_ORDER))}get programStartTime(){let e=this.getAttribute(gg.PROGRAM_START_TIME);if(null==e)return;let t=+e;return Number.isNaN(t)?void 0:t}set programStartTime(e){null==e?this.removeAttribute(gg.PROGRAM_START_TIME):this.setAttribute(gg.PROGRAM_START_TIME,`${e}`)}get programEndTime(){let e=this.getAttribute(gg.PROGRAM_END_TIME);if(null==e)return;let t=+e;return Number.isNaN(t)?void 0:t}set programEndTime(e){null==e?this.removeAttribute(gg.PROGRAM_END_TIME):this.setAttribute(gg.PROGRAM_END_TIME,`${e}`)}get assetStartTime(){let e=this.getAttribute(gg.ASSET_START_TIME);if(null==e)return;let t=+e;return Number.isNaN(t)?void 0:t}set assetStartTime(e){null==e?this.removeAttribute(gg.ASSET_START_TIME):this.setAttribute(gg.ASSET_START_TIME,`${e}`)}get assetEndTime(){let e=this.getAttribute(gg.ASSET_END_TIME);if(null==e)return;let t=+e;return Number.isNaN(t)?void 0:t}set assetEndTime(e){null==e?this.removeAttribute(gg.ASSET_END_TIME):this.setAttribute(gg.ASSET_END_TIME,`${e}`)}get customDomain(){var e;return null!=(e=this.getAttribute(gg.CUSTOM_DOMAIN))?e:void 0}set customDomain(e){e!==this.customDomain&&(e?this.setAttribute(gg.CUSTOM_DOMAIN,e):this.removeAttribute(gg.CUSTOM_DOMAIN))}get capRenditionToPlayerSize(){var e;return null!=(null==(e=this._hlsConfig)?void 0:e.capLevelToPlayerSize)?this._hlsConfig.capLevelToPlayerSize:Xp(this,fg)}set capRenditionToPlayerSize(e){Jp(this,fg,e)}get drmToken(){var e;return null!=(e=this.getAttribute(gg.DRM_TOKEN))?e:void 0}set drmToken(e){e!==this.drmToken&&(e?this.setAttribute(gg.DRM_TOKEN,e):this.removeAttribute(gg.DRM_TOKEN))}get playbackToken(){var e,t,i,r;if(this.hasAttribute(gg.PLAYBACK_TOKEN))return null!=(e=this.getAttribute(gg.PLAYBACK_TOKEN))?e:void 0;if(this.hasAttribute(gg.PLAYBACK_ID)){let[,e]=Om(null!=(t=this.playbackId)?t:"");return null!=(i=new URLSearchParams(e).get("token"))?i:void 0}return this.src&&null!=(r=new URLSearchParams(this.src).get("token"))?r:void 0}set playbackToken(e){e!==this.playbackToken&&(e?this.setAttribute(gg.PLAYBACK_TOKEN,e):this.removeAttribute(gg.PLAYBACK_TOKEN))}get tokens(){let e=this.getAttribute(gg.PLAYBACK_TOKEN),t=this.getAttribute(gg.DRM_TOKEN);return{...Xp(this,ng),...null!=e?{playback:e}:{},...null!=t?{drm:t}:{}}}set tokens(e){Jp(this,ng,null!=e?e:{})}get ended(){return Ep(this.nativeEl,this._hls)}get envKey(){var e;return null!=(e=this.getAttribute(gg.ENV_KEY))?e:void 0}set envKey(e){e!==this.envKey&&(e?this.setAttribute(gg.ENV_KEY,e):this.removeAttribute(gg.ENV_KEY))}get beaconCollectionDomain(){var e;return null!=(e=this.getAttribute(gg.BEACON_COLLECTION_DOMAIN))?e:void 0}set beaconCollectionDomain(e){e!==this.beaconCollectionDomain&&(e?this.setAttribute(gg.BEACON_COLLECTION_DOMAIN,e):this.removeAttribute(gg.BEACON_COLLECTION_DOMAIN))}get streamType(){var e;return null!=(e=this.getAttribute(gg.STREAM_TYPE))?e:mp(this.nativeEl)}set streamType(e){e!==this.streamType&&(e?this.setAttribute(gg.STREAM_TYPE,e):this.removeAttribute(gg.STREAM_TYPE))}get targetLiveWindow(){return this.hasAttribute(gg.TARGET_LIVE_WINDOW)?+this.getAttribute(gg.TARGET_LIVE_WINDOW):(e=>{var t,i;return null!=(i=null==(t=rp.get(e))?void 0:t.targetLiveWindow)?i:Number.NaN})(this.nativeEl)}set targetLiveWindow(e){e!=this.targetLiveWindow&&(null==e?this.removeAttribute(gg.TARGET_LIVE_WINDOW):this.setAttribute(gg.TARGET_LIVE_WINDOW,""+ +e))}get liveEdgeStart(){var e,t;if(this.hasAttribute(gg.LIVE_EDGE_OFFSET)){let{liveEdgeOffset:i}=this,r=null!=(e=this.nativeEl.seekable.end(0))?e:0,a=null!=(t=this.nativeEl.seekable.start(0))?t:0;return Math.max(a,r-i)}return(e=>{var t;let i=null==(t=rp.get(e))?void 0:t.liveEdgeStartOffset;if("number"!=typeof i)return Number.NaN;let r=fp(e);return r.length?r.end(r.length-1)-i:Number.NaN})(this.nativeEl)}get liveEdgeOffset(){if(this.hasAttribute(gg.LIVE_EDGE_OFFSET))return+this.getAttribute(gg.LIVE_EDGE_OFFSET)}set liveEdgeOffset(e){e!=this.liveEdgeOffset&&(null==e?this.removeAttribute(gg.LIVE_EDGE_OFFSET):this.setAttribute(gg.LIVE_EDGE_OFFSET,""+ +e))}get seekable(){return fp(this.nativeEl)}async addCuePoints(e){return this.nativeEl.currentSrc||console.warn("addCuePoints() was called before the media element has loaded. Wait for the loadstart event before calling addCuePoints()."),uf(this.nativeEl,e)}get activeCuePoint(){return cf(this.nativeEl)}get cuePoints(){return function(e,t={label:lf}){let i=af(e,t.label,"metadata");return null!=i&&i.cues?Array.from(i.cues,e=>hf(e)):[]}(this.nativeEl)}async addChapters(e){return this.nativeEl.currentSrc||console.warn("addChapters() was called before the media element has loaded. Wait for the loadstart event before calling addChapters()."),Ef(this.nativeEl,e)}get activeChapter(){return yf(this.nativeEl)}get chapters(){return function(e,t={label:mf}){var i;let r=af(e,t.label,"chapters");return null!=(i=null==r?void 0:r.cues)&&i.length?Array.from(r.cues,t=>pf(t,e)):[]}(this.nativeEl)}getStartDate(){return function(e,t){if(t){let i=t.playingDate;if(null!=i)return new Date(i.getTime()-1e3*e.currentTime)}return"function"==typeof e.getStartDate?e.getStartDate():new Date(NaN)}(this.nativeEl,this._hls)}get currentPdt(){return function(e,t){if(t&&t.playingDate)return t.playingDate;if("function"==typeof e.getStartDate){let t=e.getStartDate();return new Date(t.getTime()+1e3*e.currentTime)}return new Date(NaN)}(this.nativeEl,this._hls)}get preferPlayback(){let e=this.getAttribute(gg.PREFER_PLAYBACK);if(e===Im||e===Rm)return e}set preferPlayback(e){e!==this.preferPlayback&&(e===Im||e===Rm?this.setAttribute(gg.PREFER_PLAYBACK,e):this.removeAttribute(gg.PREFER_PLAYBACK))}get metadata(){return{...this.getAttributeNames().filter(e=>e.startsWith("metadata-")&&![gg.METADATA_URL].includes(e)).reduce((e,t)=>{let i=this.getAttribute(t);return null!=i&&(e[t.replace(/^metadata-/,"").replace(/-/g,"_")]=i),e},{}),...Xp(this,ag)}}set metadata(e){Jp(this,ag,null!=e?e:{}),this.mux&&this.mux.emit("hb",Xp(this,ag))}get _hlsConfig(){return Xp(this,sg)}set _hlsConfig(e){Jp(this,sg,e)}get logo(){var e;return null!=(e=this.getAttribute(gg.LOGO))?e:Xp(this,ug)}set logo(e){e?this.setAttribute(gg.LOGO,e):this.removeAttribute(gg.LOGO)}load(){yp(this,this.nativeEl,Xp(this,cg,mg))}unload(){Ap(this.nativeEl,Xp(this,cg,mg),this)}attributeChangedCallback(e,t,i){var r,a;switch(jp.observedAttributes.includes(e)&&!["src","autoplay","preload"].includes(e)&&super.attributeChangedCallback(e,t,i),e){case gg.PLAYER_SOFTWARE_NAME:this.playerSoftwareName=null!=i?i:void 0;break;case gg.PLAYER_SOFTWARE_VERSION:this.playerSoftwareVersion=null!=i?i:void 0;break;case"src":{let e=!!t,r=!!i;!e&&r?eg(this,cg,pg).call(this):e&&!r?this.unload():e&&r&&(this.unload(),eg(this,cg,pg).call(this));break}case"autoplay":if(i===t)break;null==(r=Xp(this,cg,mg))||r.setAutoplay(this.autoplay);break;case"preload":if(i===t)break;null==(a=Xp(this,cg,mg))||a.setPreload(i);break;case gg.PLAYBACK_ID:case gg.CUSTOM_DOMAIN:case gg.MAX_RESOLUTION:case gg.MIN_RESOLUTION:case gg.RENDITION_ORDER:case gg.PROGRAM_START_TIME:case gg.PROGRAM_END_TIME:case gg.ASSET_START_TIME:case gg.ASSET_END_TIME:case gg.PLAYBACK_TOKEN:this.hasAttribute(gg.PLAYBACK_ID)&&(this.src=dp(this));break;case gg.DEBUG:{let e=this.debug;this.mux&&console.info("Cannot toggle debug mode of mux data after initialization. Make sure you set all metadata to override before setting the src."),this._hls&&(this._hls.config.debug=e);break}case gg.METADATA_URL:i&&fetch(i).then(e=>e.json()).then(e=>this.metadata=e).catch(()=>console.error(`Unable to load or parse metadata JSON from metadata-url ${i}!`));break;case gg.STREAM_TYPE:(null==i||i!==t)&&this.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}));break;case gg.TARGET_LIVE_WINDOW:(null==i||i!==t)&&this.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0,detail:this.targetLiveWindow}));break;case gg.LOGO:(null==i||i!==t)&&this.updateLogo();break;case gg.DISABLE_TRACKING:if(null==i||i!==t){let e=this.currentTime,t=this.paused;this.unload(),eg(this,cg,pg).call(this).then(()=>{this.currentTime=e,t||this.play()})}break;case gg.DISABLE_COOKIES:(null==i||i!==t)&&Tp(this,this.nativeEl,Xp(this,cg,mg));break;case gg.CAP_RENDITION_TO_PLAYER_SIZE:(null==i||i!==t)&&(this.capRenditionToPlayerSize=null!=i||void 0)}}updateLogo(){if(!this.shadowRoot)return;let e=this.shadowRoot.querySelector('slot[name="logo"]');if(!e)return;let t=this.constructor.getLogoHTML(Xp(this,ug)||this.logo);e.innerHTML=t}connectedCallback(){var e,t;null==(e=super.connectedCallback)||e.call(this),null==(t=this.nativeEl)||t.addEventListener("muxmetadata",Xp(this,hg)),this.nativeEl&&this.src&&!Xp(this,cg,mg)&&eg(this,cg,pg).call(this)}disconnectedCallback(){var e,t;null==(e=this.nativeEl)||e.removeEventListener("muxmetadata",Xp(this,hg)),this.unload(),null==(t=super.disconnectedCallback)||t.call(this)}handleEvent(e){e.target===this.nativeEl&&this.dispatchEvent(new CustomEvent(e.type,{composed:!0,detail:e.detail}))}};ig=new WeakMap,rg=new WeakMap,ag=new WeakMap,ng=new WeakMap,sg=new WeakMap,og=new WeakMap,lg=new WeakMap,dg=new WeakMap,ug=new WeakMap,hg=new WeakMap,cg=new WeakSet,mg=function(){return(e=>{var t;return null==(t=rp.get(e))?void 0:t.coreReference})(this.nativeEl)},fg=new WeakMap,pg=async function(){Xp(this,ig)||(await Jp(this,ig,Promise.resolve()),Jp(this,ig,null),this.load())};var Tg=new WeakMap,Ag=class extends Error{},_g=class extends Error{},Sg=["application/x-mpegURL","application/vnd.apple.mpegurl","audio/mpegurl"],kg=globalThis.WeakRef?class extends Set{add(e){super.add(new WeakRef(e))}forEach(e){super.forEach(t=>{let i=t.deref();i&&e(i)})}}:Set;function Ig(){var e,t;return null==(t=null==(e=globalThis.cast)?void 0:e.framework)?void 0:t.CastContext.getInstance()}function Rg(){var e;return null==(e=Ig())?void 0:e.getCurrentSession()}function Lg(){var e;return null==(e=Rg())?void 0:e.getSessionObj().media[0]}function wg(e){return Ig().setOptions({receiverApplicationId:"CC1AD845",autoJoinPolicy:"origin_scoped",androidReceiverCompatible:!1,language:"en-US",resumeSavedSession:!0,...e})}function Dg(e){if(!e)return;let t=e.match(/\.([a-zA-Z0-9]+)(?:\?.*)?$/);return t?t[1]:null}function Cg(e){let t=e.split("\n").find(e=>!e.trim().startsWith("#")&&""!==e.trim());return null==t?void 0:t.trim()}var Mg,Pg=new kg,xg=new WeakSet;!function(e){var t,i,r;null!=(i=null==(t=globalThis.chrome)?void 0:t.cast)&&i.isAvailable?null!=(r=globalThis.cast)&&r.framework?e():customElements.whenDefined("google-cast-button").then(e):globalThis.__onGCastApiAvailable=()=>{customElements.whenDefined("google-cast-button").then(e)}}(()=>{var e,t,i,r;null!=(t=null==(e=globalThis.chrome)?void 0:e.cast)&&t.isAvailable?Mg||(Mg=cast.framework,Ig().addEventListener(Mg.CastContextEventType.CAST_STATE_CHANGED,e=>{Pg.forEach(t=>{var i,r;return null==(r=(i=Tg.get(t)).onCastStateChanged)?void 0:r.call(i,e)})}),Ig().addEventListener(Mg.CastContextEventType.SESSION_STATE_CHANGED,e=>{Pg.forEach(t=>{var i,r;return null==(r=(i=Tg.get(t)).onSessionStateChanged)?void 0:r.call(i,e)})}),Pg.forEach(e=>{var t,i;return null==(i=(t=Tg.get(e)).init)?void 0:i.call(t)})):console.debug("chrome.cast.isAvailable",null==(r=null==(i=globalThis.chrome)?void 0:i.cast)?void 0:r.isAvailable)});var Og,Ng,Ug,Fg,Bg,$g,Hg,Gg,Kg,Wg,Vg,qg,Yg,jg,zg,Qg,Xg,Zg,Jg=0,ev=class extends EventTarget{constructor(e){super(),o(this,Wg),o(this,Og),o(this,Ng),o(this,Ug),o(this,Fg),o(this,Bg,"disconnected"),o(this,$g,!1),o(this,Hg,new Set),o(this,Gg,new WeakMap),o(this,Kg,()=>d(this,Wg,Zg).call(this)),l(this,Og,e),Pg.add(this),Tg.set(this,{init:()=>d(this,Wg,Qg).call(this),onCastStateChanged:()=>d(this,Wg,jg).call(this),onSessionStateChanged:()=>d(this,Wg,zg).call(this),getCastPlayer:()=>s(this,Wg,Vg)}),d(this,Wg,Qg).call(this)}destroy(){var e,t,i;null==(t=null==(e=s(this,Og))?void 0:e.textTracks)||t.removeEventListener("change",s(this,Kg)),s(this,Fg)&&null!=(i=s(this,Ug))&&i.controller&&Object.entries(s(this,Fg)).forEach(([e,t])=>{s(this,Ug).controller.removeEventListener(e,t)}),s(this,Og)&&xg.delete(s(this,Og)),l(this,Ng,!1)}get state(){return s(this,Bg)}async watchAvailability(e){if(s(this,Og).disableRemotePlayback)throw new Ag("disableRemotePlayback attribute is present.");return s(this,Gg).set(e,++Jg),s(this,Hg).add(e),queueMicrotask(()=>e(d(this,Wg,Yg).call(this))),Jg}async cancelWatchAvailability(e){if(s(this,Og).disableRemotePlayback)throw new Ag("disableRemotePlayback attribute is present.");e?s(this,Hg).delete(e):s(this,Hg).clear()}async prompt(){var e,t,i,r;if(s(this,Og).disableRemotePlayback)throw new Ag("disableRemotePlayback attribute is present.");if(null==(t=null==(e=globalThis.chrome)?void 0:e.cast)||!t.isAvailable)throw new _g("The RemotePlayback API is disabled on this platform.");let a=xg.has(s(this,Og));xg.add(s(this,Og)),wg(s(this,Og).castOptions),Object.entries(s(this,Fg)).forEach(([e,t])=>{s(this,Ug).controller.addEventListener(e,t)});try{await Ig().requestSession()}catch(e){if(a||xg.delete(s(this,Og)),"cancel"===e)return;throw new Error(e)}null==(r=null==(i=Tg.get(s(this,Og)))?void 0:i.loadOnPrompt)||r.call(i)}};Og=new WeakMap,Ng=new WeakMap,Ug=new WeakMap,Fg=new WeakMap,Bg=new WeakMap,$g=new WeakMap,Hg=new WeakMap,Gg=new WeakMap,Kg=new WeakMap,Wg=new WeakSet,Vg=function(){if(xg.has(s(this,Og)))return s(this,Ug)},qg=function(){xg.has(s(this,Og))&&(Object.entries(s(this,Fg)).forEach(([e,t])=>{s(this,Ug).controller.removeEventListener(e,t)}),xg.delete(s(this,Og)),s(this,Og).muted=s(this,Ug).isMuted,s(this,Og).currentTime=s(this,Ug).savedPlayerState.currentTime,!1===s(this,Ug).savedPlayerState.isPaused&&s(this,Og).play())},Yg=function(){var e;let t=null==(e=Ig())?void 0:e.getCastState();return t&&"NO_DEVICES_AVAILABLE"!==t},jg=function(){let e=Ig().getCastState();if(xg.has(s(this,Og))&&"CONNECTING"===e&&(l(this,Bg,"connecting"),this.dispatchEvent(new Event("connecting"))),!s(this,$g)&&null!=e&&e.includes("CONNECT")){l(this,$g,!0);for(let e of s(this,Hg))e(!0)}else if(s(this,$g)&&(!e||"NO_DEVICES_AVAILABLE"===e)){l(this,$g,!1);for(let e of s(this,Hg))e(!1)}},zg=async function(){var e;let{SESSION_RESUMED:t}=Mg.SessionState;if(Ig().getSessionState()===t&&s(this,Og).castSrc===(null==(e=Lg())?void 0:e.media.contentId)){xg.add(s(this,Og)),Object.entries(s(this,Fg)).forEach(([e,t])=>{s(this,Ug).controller.addEventListener(e,t)});try{await function(e){return new Promise((t,i)=>{Lg().getStatus(e,t,i)})}(new chrome.cast.media.GetStatusRequest)}catch(e){console.error(e)}s(this,Fg)[Mg.RemotePlayerEventType.IS_PAUSED_CHANGED](),s(this,Fg)[Mg.RemotePlayerEventType.PLAYER_STATE_CHANGED]()}},Qg=function(){!Mg||s(this,Ng)||(l(this,Ng,!0),wg(s(this,Og).castOptions),s(this,Og).textTracks.addEventListener("change",s(this,Kg)),d(this,Wg,jg).call(this),l(this,Ug,new Mg.RemotePlayer),new Mg.RemotePlayerController(s(this,Ug)),l(this,Fg,{[Mg.RemotePlayerEventType.IS_CONNECTED_CHANGED]:({value:e})=>{!0===e?(l(this,Bg,"connected"),this.dispatchEvent(new Event("connect"))):(d(this,Wg,qg).call(this),l(this,Bg,"disconnected"),this.dispatchEvent(new Event("disconnect")))},[Mg.RemotePlayerEventType.DURATION_CHANGED]:()=>{s(this,Og).dispatchEvent(new Event("durationchange"))},[Mg.RemotePlayerEventType.VOLUME_LEVEL_CHANGED]:()=>{s(this,Og).dispatchEvent(new Event("volumechange"))},[Mg.RemotePlayerEventType.IS_MUTED_CHANGED]:()=>{s(this,Og).dispatchEvent(new Event("volumechange"))},[Mg.RemotePlayerEventType.CURRENT_TIME_CHANGED]:()=>{var e;null!=(e=s(this,Wg,Vg))&&e.isMediaLoaded&&s(this,Og).dispatchEvent(new Event("timeupdate"))},[Mg.RemotePlayerEventType.VIDEO_INFO_CHANGED]:()=>{s(this,Og).dispatchEvent(new Event("resize"))},[Mg.RemotePlayerEventType.IS_PAUSED_CHANGED]:()=>{s(this,Og).dispatchEvent(new Event(this.paused?"pause":"play"))},[Mg.RemotePlayerEventType.PLAYER_STATE_CHANGED]:()=>{var e,t;(null==(e=s(this,Wg,Vg))?void 0:e.playerState)!==chrome.cast.media.PlayerState.PAUSED&&s(this,Og).dispatchEvent(new Event({[chrome.cast.media.PlayerState.PLAYING]:"playing",[chrome.cast.media.PlayerState.BUFFERING]:"waiting",[chrome.cast.media.PlayerState.IDLE]:"emptied"}[null==(t=s(this,Wg,Vg))?void 0:t.playerState]))},[Mg.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED]:async()=>{var e;null!=(e=s(this,Wg,Vg))&&e.isMediaLoaded&&(await Promise.resolve(),d(this,Wg,Xg).call(this))}}))},Xg=function(){d(this,Wg,Zg).call(this)},Zg=async function(){var e,t,i,r,a;if(!s(this,Wg,Vg))return;let n=(null!=(t=null==(e=s(this,Ug).mediaInfo)?void 0:e.tracks)?t:[]).filter(({type:e})=>e===chrome.cast.media.TrackType.TEXT),o=[...s(this,Og).textTracks].filter(({kind:e})=>"subtitles"===e||"captions"===e),l=n.map(({language:e,name:t,trackId:i})=>{var r;let{mode:a}=null!=(r=o.find(i=>i.language===e&&i.label===t))?r:{};return!!a&&{mode:a,trackId:i}}).filter(Boolean),d=l.filter(({mode:e})=>"showing"!==e).map(({trackId:e})=>e),u=l.find(({mode:e})=>"showing"===e),h=null!=(a=null==(r=null==(i=Rg())?void 0:i.getSessionObj().media[0])?void 0:r.activeTrackIds)?a:[],c=h;if(h.length&&(c=c.filter(e=>!d.includes(e))),null!=u&&u.trackId&&(c=[...c,u.trackId]),c=[...new Set(c)],f=c,(m=h).length!==f.length||!m.every(e=>f.includes(e)))try{let e=new chrome.cast.media.EditTracksInfoRequest(c);await function(e){return new Promise((t,i)=>{Lg().editTracksInfo(e,t,i)})}(e)}catch(m){console.error(m)}var m,f};var tv=e=>{var t,i,r,n,h,c,m,f,p;return i=class extends e{constructor(){super(...arguments),o(this,m),o(this,r,{paused:!1}),o(this,n,{receiverApplicationId:"CC1AD845",autoJoinPolicy:"origin_scoped",androidReceiverCompatible:!1,language:"en-US",resumeSavedSession:!0}),o(this,h),o(this,c)}get remote(){return s(this,c)?s(this,c):globalThis.chrome?this.isConnected?(this.disableRemotePlayback||function(){var e;let t="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1";if(null!=(e=globalThis.chrome)&&e.cast||document.querySelector(`script[src="${t}"]`))return;let i=document.createElement("script");i.src=t,document.head.append(i)}(),Tg.set(this,{loadOnPrompt:()=>d(this,m,p).call(this)}),l(this,c,new ev(this))):void 0:super.remote}disconnectedCallback(){var e,t;null==(e=s(this,c))||e.destroy(),l(this,c,null),Tg.delete(this),null==(t=super.disconnectedCallback)||t.call(this)}attributeChangedCallback(e,t,i){if(super.attributeChangedCallback(e,t,i),"cast-receiver"===e&&i)s(this,n).receiverApplicationId=i;else if(s(this,m,f))switch(e){case"cast-stream-type":case"cast-src":this.load()}}async load(){var e,t;if(!s(this,m,f))return super.load();let i=new chrome.cast.media.MediaInfo(this.castSrc,this.castContentType);i.customData=this.castCustomData;let a=[...this.querySelectorAll("track")].filter(({kind:e,src:t})=>t&&("subtitles"===e||"captions"===e)),n=[],o=0;if(a.length&&(i.tracks=a.map(e=>{let t=++o;0===n.length&&"showing"===e.track.mode&&n.push(t);let i=new chrome.cast.media.Track(t,chrome.cast.media.TrackType.TEXT);return i.trackContentId=e.src,i.trackContentType="text/vtt",i.subtype="captions"===e.kind?chrome.cast.media.TextTrackType.CAPTIONS:chrome.cast.media.TextTrackType.SUBTITLES,i.name=e.label,i.language=e.srclang,i})),"live"===this.castStreamType?i.streamType=chrome.cast.media.StreamType.LIVE:i.streamType=chrome.cast.media.StreamType.BUFFERED,i.metadata=new chrome.cast.media.GenericMediaMetadata,i.metadata.title=this.title,i.metadata.images=[{url:this.poster}],await async function(e){if(!e)return!1;if(/\.m3u8?(\?.*)?$/i.test(e))return!0;if(e.startsWith("blob:"))return!1;try{let t=(await fetch(e,{method:"HEAD"})).headers.get("Content-Type");return Sg.some(e=>t===e)}catch(e){return console.error("Error while trying to get the Content-Type of the manifest",e),!1}}(this.castSrc)){i.contentType||(i.contentType="application/x-mpegURL");let{videoFormat:e,audioFormat:t}=await async function(e){var t;if(!e||e.startsWith("blob:"))return{videoFormat:void 0,audioFormat:void 0};try{let i=await(await fetch(e)).text(),r=i,a=function(e){let t=e.split("\n"),i=[];for(let e=0;e<t.length;e++)if(t[e].trim().startsWith("#EXT-X-STREAM-INF")){let r=t[e+1]?t[e+1].trim():"";r&&!r.startsWith("#")&&i.push(r)}return i}(i);if(a.length>0){let t=new URL(a[0],e).toString();r=await(await fetch(t)).text()}let n=Dg(Cg(r)),s=function(e){for(let t of e.split("\n")){let e=t.trim();if(e.startsWith("#EXT-X-MEDIA")&&/TYPE=AUDIO/i.test(e)){let t=e.match(/URI="([^"]+)"/i);if(t)return t[1]}}}(i),o=n;if(s)try{let i=new URL(s,e).toString();o=null!=(t=Dg(Cg(await(await fetch(i)).text())))?t:n}catch(e){console.error("Error while trying to parse the audio rendition playlist",e)}return{videoFormat:n,audioFormat:o}}catch(e){return console.error("Error while trying to parse the manifest playlist",e),{videoFormat:void 0,audioFormat:void 0}}}(this.castSrc);(null==e?void 0:e.includes("m4s"))||(null==e?void 0:e.includes("mp4"))||(null==e?void 0:e.includes("m4a"))?(i.hlsSegmentFormat=chrome.cast.media.HlsSegmentFormat.FMP4,i.hlsVideoSegmentFormat=chrome.cast.media.HlsVideoSegmentFormat.FMP4):null!=t&&t.includes("aac")?(i.hlsSegmentFormat=chrome.cast.media.HlsSegmentFormat.AAC,i.hlsVideoSegmentFormat=chrome.cast.media.HlsVideoSegmentFormat.MPEG2_TS):(null!=e&&e.includes("ts")||null!=t&&t.includes("ts"))&&(i.hlsSegmentFormat=chrome.cast.media.HlsSegmentFormat.TS,i.hlsVideoSegmentFormat=chrome.cast.media.HlsVideoSegmentFormat.MPEG2_TS)}let l=new chrome.cast.media.LoadRequest(i);l.currentTime=null!=(e=super.currentTime)?e:0,l.autoplay=!s(this,r).paused,l.activeTrackIds=n,await(null==(t=Rg())?void 0:t.loadMedia(l)),this.dispatchEvent(new Event("volumechange"))}play(){var e;if(!s(this,m,f))return super.play();s(this,m,f).isPaused&&(null==(e=s(this,m,f).controller)||e.playOrPause())}pause(){var e;s(this,m,f)?s(this,m,f).isPaused||null==(e=s(this,m,f).controller)||e.playOrPause():super.pause()}get castOptions(){return s(this,n)}get castReceiver(){var e;return null!=(e=this.getAttribute("cast-receiver"))?e:void 0}set castReceiver(e){this.castReceiver!=e&&this.setAttribute("cast-receiver",`${e}`)}get castSrc(){var e,t,i,r,a;let n=this.currentSrc,s=null!=n&&n.startsWith("blob:")?void 0:n;return null!=(a=null!=(r=null!=(i=null!=(t=this.getAttribute("cast-src"))?t:null==(e=this.querySelector("source"))?void 0:e.src)?i:s)?r:this.getAttribute("src"))?a:void 0}set castSrc(e){this.castSrc!=e&&this.setAttribute("cast-src",`${e}`)}get castContentType(){var e;return null!=(e=this.getAttribute("cast-content-type"))?e:void 0}set castContentType(e){this.setAttribute("cast-content-type",`${e}`)}get castStreamType(){var e,t;return null!=(t=null!=(e=this.getAttribute("cast-stream-type"))?e:this.streamType)?t:void 0}set castStreamType(e){this.setAttribute("cast-stream-type",`${e}`)}get castCustomData(){return s(this,h)}set castCustomData(e){let t=typeof e;["object","undefined"].includes(t)?l(this,h,e):console.error(`castCustomData must be nullish or an object but value was of type ${t}`)}get readyState(){if(s(this,m,f))switch(s(this,m,f).playerState){case chrome.cast.media.PlayerState.IDLE:return 0;case chrome.cast.media.PlayerState.BUFFERING:return 2;default:return 3}return super.readyState}get paused(){return s(this,m,f)?s(this,m,f).isPaused:super.paused}get muted(){var e;return s(this,m,f)?null==(e=s(this,m,f))?void 0:e.isMuted:super.muted}set muted(e){var t;s(this,m,f)?(e&&!s(this,m,f).isMuted||!e&&s(this,m,f).isMuted)&&(null==(t=s(this,m,f).controller)||t.muteOrUnmute()):super.muted=e}get volume(){var e,t;return s(this,m,f)?null!=(t=null==(e=s(this,m,f))?void 0:e.volumeLevel)?t:1:super.volume}set volume(e){var t;if(s(this,m,f))return s(this,m,f).volumeLevel=+e,void(null==(t=s(this,m,f).controller)||t.setVolumeLevel());super.volume=e}get duration(){var e,t,i;return s(this,m,f)&&null!=(e=s(this,m,f))&&e.isMediaLoaded?null!=(i=null==(t=s(this,m,f))?void 0:t.duration)?i:NaN:super.duration}get currentTime(){var e,t,i;return s(this,m,f)&&null!=(e=s(this,m,f))&&e.isMediaLoaded?null!=(i=null==(t=s(this,m,f))?void 0:t.currentTime)?i:0:super.currentTime}set currentTime(e){var t;if(s(this,m,f))return s(this,m,f).currentTime=e,void(null==(t=s(this,m,f).controller)||t.seek());super.currentTime=e}},r=new WeakMap,n=new WeakMap,h=new WeakMap,c=new WeakMap,m=new WeakSet,f=function(){var e,t;return null==(t=null==(e=Tg.get(s(this,c)))?void 0:e.getCastPlayer)?void 0:t.call(e)},p=async function(){s(this,r).paused=u(i.prototype,this,"paused"),u(i.prototype,this,"pause").call(this),this.muted=u(i.prototype,this,"muted");try{await this.load()}catch(e){console.error(e)}},a(i,"observedAttributes",[...null!=(t=e.observedAttributes)?t:[],"cast-src","cast-content-type","cast-stream-type","cast-receiver"]),i},iv=class extends Event{constructor(e,t){super(e),a(this,"track"),this.track=t.track}},rv=new WeakMap;function av(e){var t;return null!=(t=rv.get(e))?t:function(e,t){let i=rv.get(e);return i||rv.set(e,i={}),Object.assign(i,t)}(e,{})}function nv(e,t){let i=e.videoTracks;av(t).media=new WeakRef(e),av(t).renditionSet||(av(t).renditionSet=new Set);let r=av(i).trackSet;r.add(t);let a=r.size-1;a in cv.prototype||Object.defineProperty(cv.prototype,a,{get(){return[...av(this).trackSet][a]}}),queueMicrotask(()=>{i.dispatchEvent(new iv("addtrack",{track:t}))})}function sv(e){var t,i;let r=null==(i=null==(t=av(e).media)?void 0:t.deref())?void 0:i.videoTracks;r&&(av(r).trackSet.delete(e),queueMicrotask(()=>{r.dispatchEvent(new iv("removetrack",{track:e}))}))}var ov,lv,dv,uv,hv,cv=class extends EventTarget{constructor(){super(),o(this,uv),o(this,ov),o(this,lv),o(this,dv),av(this).trackSet=new Set}[Symbol.iterator](){return s(this,uv,hv).values()}get length(){return s(this,uv,hv).size}getTrackById(e){var t;return null!=(t=[...s(this,uv,hv)].find(t=>t.id===e))?t:null}get selectedIndex(){return[...s(this,uv,hv)].findIndex(e=>e.selected)}get onaddtrack(){return s(this,ov)}set onaddtrack(e){s(this,ov)&&(this.removeEventListener("addtrack",s(this,ov)),l(this,ov,void 0)),"function"==typeof e&&(l(this,ov,e),this.addEventListener("addtrack",e))}get onremovetrack(){return s(this,lv)}set onremovetrack(e){s(this,lv)&&(this.removeEventListener("removetrack",s(this,lv)),l(this,lv,void 0)),"function"==typeof e&&(l(this,lv,e),this.addEventListener("removetrack",e))}get onchange(){return s(this,dv)}set onchange(e){s(this,dv)&&(this.removeEventListener("change",s(this,dv)),l(this,dv,void 0)),"function"==typeof e&&(l(this,dv,e),this.addEventListener("change",e))}};ov=new WeakMap,lv=new WeakMap,dv=new WeakMap,uv=new WeakSet,hv=function(){return av(this).trackSet};var mv=class extends Event{constructor(e,t){super(e),a(this,"rendition"),this.rendition=t.rendition}};function fv(e){var t;let i=null==(t=av(e).media)?void 0:t.deref();return i?[...i.videoTracks].filter(e=>e.selected).flatMap(e=>[...av(e).renditionSet]):[]}var pv,gv,vv,Ev=class extends EventTarget{constructor(){super(...arguments),o(this,pv),o(this,gv),o(this,vv)}[Symbol.iterator](){return fv(this).values()}get length(){return fv(this).length}getRenditionById(e){var t;return null!=(t=fv(this).find(t=>`${t.id}`==`${e}`))?t:null}get selectedIndex(){return fv(this).findIndex(e=>e.selected)}set selectedIndex(e){for(let[t,i]of fv(this).entries())i.selected=t===e}get onaddrendition(){return s(this,pv)}set onaddrendition(e){s(this,pv)&&(this.removeEventListener("addrendition",s(this,pv)),l(this,pv,void 0)),"function"==typeof e&&(l(this,pv,e),this.addEventListener("addrendition",e))}get onremoverendition(){return s(this,gv)}set onremoverendition(e){s(this,gv)&&(this.removeEventListener("removerendition",s(this,gv)),l(this,gv,void 0)),"function"==typeof e&&(l(this,gv,e),this.addEventListener("removerendition",e))}get onchange(){return s(this,vv)}set onchange(e){s(this,vv)&&(this.removeEventListener("change",s(this,vv)),l(this,vv,void 0)),"function"==typeof e&&(l(this,vv,e),this.addEventListener("change",e))}};pv=new WeakMap,gv=new WeakMap,vv=new WeakMap;var yv,bv=class{constructor(){a(this,"src"),a(this,"id"),a(this,"width"),a(this,"height"),a(this,"bitrate"),a(this,"frameRate"),a(this,"codec"),o(this,yv,!1)}get selected(){return s(this,yv)}set selected(e){s(this,yv)!==e&&(l(this,yv,e),function(e){var t,i;let r=null==(i=null==(t=av(e).media)?void 0:t.deref())?void 0:i.videoRenditions;!r||av(r).changeRequested||(av(r).changeRequested=!0,queueMicrotask(()=>{delete av(r).changeRequested,av(e).track.selected&&r.dispatchEvent(new Event("change"))}))}(this))}};yv=new WeakMap;var Tv,Av=class{constructor(){a(this,"id"),a(this,"kind"),a(this,"label",""),a(this,"language",""),a(this,"sourceBuffer"),o(this,Tv,!1)}addRendition(e,t,i,r,a,n){let s=new bv;return s.src=e,s.width=t,s.height=i,s.frameRate=n,s.bitrate=a,s.codec=r,function(e,t){var i,r;let a=null==(r=null==(i=av(e).media)?void 0:i.deref())?void 0:r.videoRenditions;av(t).media=av(e).media,av(t).track=e;let n=av(e).renditionSet;n.add(t);let s=n.size-1;s in Ev.prototype||Object.defineProperty(Ev.prototype,s,{get(){return fv(this)[s]}}),queueMicrotask(()=>{!a||!e.selected||a.dispatchEvent(new mv("addrendition",{rendition:t}))})}(this,s),s}removeRendition(e){!function(e){var t,i;let r=null==(i=null==(t=av(e).media)?void 0:t.deref())?void 0:i.videoRenditions,a=av(e).track;av(a).renditionSet.delete(e),queueMicrotask(()=>{let t=av(e).track;!r||!t.selected||r.dispatchEvent(new mv("removerendition",{rendition:e}))})}(e)}get selected(){return s(this,Tv)}set selected(e){s(this,Tv)!==e&&(l(this,Tv,e),!0===e&&function(e){var t,i,r;let a=null!=(r=null==(i=null==(t=av(e).media)?void 0:t.deref())?void 0:i.videoTracks)?r:[],n=!1;for(let t of a)t!==e&&(t.selected=!1,n=!0);if(n){if(av(a).changeRequested)return;av(a).changeRequested=!0,queueMicrotask(()=>{delete av(a).changeRequested,a.dispatchEvent(new Event("change"))})}}(this))}};function _v(e){var t;let i=null==(t=av(e).media)?void 0:t.deref();return i?[...i.audioTracks].filter(e=>e.enabled).flatMap(e=>[...av(e).renditionSet]):[]}Tv=new WeakMap;var Sv,kv,Iv,Rv=class extends EventTarget{constructor(){super(...arguments),o(this,Sv),o(this,kv),o(this,Iv)}[Symbol.iterator](){return _v(this).values()}get length(){return _v(this).length}getRenditionById(e){var t;return null!=(t=_v(this).find(t=>`${t.id}`==`${e}`))?t:null}get selectedIndex(){return _v(this).findIndex(e=>e.selected)}set selectedIndex(e){for(let[t,i]of _v(this).entries())i.selected=t===e}get onaddrendition(){return s(this,Sv)}set onaddrendition(e){s(this,Sv)&&(this.removeEventListener("addrendition",s(this,Sv)),l(this,Sv,void 0)),"function"==typeof e&&(l(this,Sv,e),this.addEventListener("addrendition",e))}get onremoverendition(){return s(this,kv)}set onremoverendition(e){s(this,kv)&&(this.removeEventListener("removerendition",s(this,kv)),l(this,kv,void 0)),"function"==typeof e&&(l(this,kv,e),this.addEventListener("removerendition",e))}get onchange(){return s(this,Iv)}set onchange(e){s(this,Iv)&&(this.removeEventListener("change",s(this,Iv)),l(this,Iv,void 0)),"function"==typeof e&&(l(this,Iv,e),this.addEventListener("change",e))}};Sv=new WeakMap,kv=new WeakMap,Iv=new WeakMap;var Lv,wv=class{constructor(){a(this,"src"),a(this,"id"),a(this,"bitrate"),a(this,"codec"),o(this,Lv,!1)}get selected(){return s(this,Lv)}set selected(e){s(this,Lv)!==e&&(l(this,Lv,e),function(e){var t,i;let r=null==(i=null==(t=av(e).media)?void 0:t.deref())?void 0:i.audioRenditions;!r||av(r).changeRequested||(av(r).changeRequested=!0,queueMicrotask(()=>{delete av(r).changeRequested,av(e).track.enabled&&r.dispatchEvent(new Event("change"))}))}(this))}};function Dv(e,t){let i=e.audioTracks;av(t).media=new WeakRef(e),av(t).renditionSet||(av(t).renditionSet=new Set);let r=av(i).trackSet;r.add(t);let a=r.size-1;a in Uv.prototype||Object.defineProperty(Uv.prototype,a,{get(){return[...av(this).trackSet][a]}}),queueMicrotask(()=>{i.dispatchEvent(new iv("addtrack",{track:t}))})}function Cv(e){var t,i;let r=null==(i=null==(t=av(e).media)?void 0:t.deref())?void 0:i.audioTracks;r&&(av(r).trackSet.delete(e),queueMicrotask(()=>{r.dispatchEvent(new iv("removetrack",{track:e}))}))}Lv=new WeakMap;var Mv,Pv,xv,Ov,Nv,Uv=class extends EventTarget{constructor(){super(),o(this,Ov),o(this,Mv),o(this,Pv),o(this,xv),av(this).trackSet=new Set}[Symbol.iterator](){return s(this,Ov,Nv).values()}get length(){return s(this,Ov,Nv).size}getTrackById(e){var t;return null!=(t=[...s(this,Ov,Nv)].find(t=>t.id===e))?t:null}get onaddtrack(){return s(this,Mv)}set onaddtrack(e){s(this,Mv)&&(this.removeEventListener("addtrack",s(this,Mv)),l(this,Mv,void 0)),"function"==typeof e&&(l(this,Mv,e),this.addEventListener("addtrack",e))}get onremovetrack(){return s(this,Pv)}set onremovetrack(e){s(this,Pv)&&(this.removeEventListener("removetrack",s(this,Pv)),l(this,Pv,void 0)),"function"==typeof e&&(l(this,Pv,e),this.addEventListener("removetrack",e))}get onchange(){return s(this,xv)}set onchange(e){s(this,xv)&&(this.removeEventListener("change",s(this,xv)),l(this,xv,void 0)),"function"==typeof e&&(l(this,xv,e),this.addEventListener("change",e))}};Mv=new WeakMap,Pv=new WeakMap,xv=new WeakMap,Ov=new WeakSet,Nv=function(){return av(this).trackSet};var Fv,Bv=class{constructor(){a(this,"id"),a(this,"kind"),a(this,"label",""),a(this,"language",""),a(this,"sourceBuffer"),o(this,Fv,!1)}addRendition(e,t,i){let r=new wv;return r.src=e,r.codec=t,r.bitrate=i,function(e,t){var i,r;let a=null==(r=null==(i=av(e).media)?void 0:i.deref())?void 0:r.audioRenditions;av(t).media=av(e).media,av(t).track=e;let n=av(e).renditionSet;n.add(t);let s=n.size-1;s in Rv.prototype||Object.defineProperty(Rv.prototype,s,{get(){return _v(this)[s]}}),queueMicrotask(()=>{!a||!e.enabled||a.dispatchEvent(new mv("addrendition",{rendition:t}))})}(this,r),r}removeRendition(e){!function(e){var t,i;let r=null==(i=null==(t=av(e).media)?void 0:t.deref())?void 0:i.audioRenditions,a=av(e).track;av(a).renditionSet.delete(e),queueMicrotask(()=>{let t=av(e).track;!r||!t.enabled||r.dispatchEvent(new mv("removerendition",{rendition:e}))})}(e)}get enabled(){return s(this,Fv)}set enabled(e){s(this,Fv)!==e&&(l(this,Fv,e),function(e){var t,i;let r=null==(i=null==(t=av(e).media)?void 0:t.deref())?void 0:i.audioTracks;!r||av(r).changeRequested||(av(r).changeRequested=!0,queueMicrotask(()=>{delete av(r).changeRequested,r.dispatchEvent(new Event("change"))}))}(this))}};Fv=new WeakMap;var $v=Kv(globalThis.HTMLMediaElement,"video"),Hv=Kv(globalThis.HTMLMediaElement,"audio");function Gv(e){if(null==e||!e.prototype)return e;let t=Kv(e,"video");(!t||`${t}`.includes("[native code]"))&&Object.defineProperty(e.prototype,"videoTracks",{get(){return function(e){var t;let i=av(e).videoTracks;if(!i&&(i=new cv,av(e).videoTracks=i,$v)){let r=$v.call(null!=(t=e.nativeEl)?t:e);for(let t of r)nv(e,t);let a=()=>{i.dispatchEvent(new Event("change"))},n=t=>{if([...i].some(e=>e instanceof Av))for(let e of r)sv(e);else nv(e,t.track)},s=e=>{sv(e.track)};r.addEventListener("change",a),r.addEventListener("addtrack",n),r.addEventListener("removetrack",s)}return i}(this)}});let i=Kv(e,"audio");(!i||`${i}`.includes("[native code]"))&&Object.defineProperty(e.prototype,"audioTracks",{get(){return function(e){var t;let i=av(e).audioTracks;if(!i&&(i=new Uv,av(e).audioTracks=i,Hv)){let r=Hv.call(null!=(t=e.nativeEl)?t:e);for(let t of r)Dv(e,t);let a=()=>{i.dispatchEvent(new Event("change"))},n=t=>{if([...i].some(e=>e instanceof Bv))for(let e of r)Cv(e);else Dv(e,t.track)},s=e=>{Cv(e.track)};r.addEventListener("change",a),r.addEventListener("addtrack",n),r.addEventListener("removetrack",s)}return i}(this)}}),"addVideoTrack"in e.prototype||(e.prototype.addVideoTrack=function(e,t="",i=""){let r=new Av;return r.kind=e,r.label=t,r.language=i,nv(this,r),r}),"removeVideoTrack"in e.prototype||(e.prototype.removeVideoTrack=sv),"addAudioTrack"in e.prototype||(e.prototype.addAudioTrack=function(e,t="",i=""){let r=new Bv;return r.kind=e,r.label=t,r.language=i,Dv(this,r),r}),"removeAudioTrack"in e.prototype||(e.prototype.removeAudioTrack=Cv),"videoRenditions"in e.prototype||Object.defineProperty(e.prototype,"videoRenditions",{get(){return r(this)}});let r=e=>{let t=av(e).videoRenditions;return t||(t=new Ev,av(t).media=new WeakRef(e),av(e).videoRenditions=t),t};"audioRenditions"in e.prototype||Object.defineProperty(e.prototype,"audioRenditions",{get(){return a(this)}});let a=e=>{let t=av(e).audioRenditions;return t||(t=new Rv,av(t).media=new WeakRef(e),av(e).audioRenditions=t),t};return e}function Kv(e,t){var i;if(null!=e&&e.prototype)return null==(i=Object.getOwnPropertyDescriptor(e.prototype,`${t}Tracks`))?void 0:i.get}var Wv=e=>{throw TypeError(e)},Vv=(e,t,i)=>t.has(e)||Wv("Cannot "+i),qv=(e,t,i)=>(Vv(e,t,"read from private field"),i?i.call(e):t.get(e)),Yv=(e,t,i)=>t.has(e)?Wv("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,i),jv=(e,t,i,r)=>(Vv(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i),zv=class{addEventListener(){}removeEventListener(){}dispatchEvent(e){return!0}};if("undefined"==typeof DocumentFragment){class e extends zv{}globalThis.DocumentFragment=e}var Qv,Xv=class extends zv{},Zv={get(e){},define(e,t,i){},getName:e=>null,upgrade(e){},whenDefined:e=>Promise.resolve(Xv)};Qv=new WeakMap;var Jv,eE={document:{createElement:function(e,t){return new Xv}},DocumentFragment:DocumentFragment,customElements:Zv,CustomEvent:class{constructor(e,t={}){Yv(this,Qv),jv(this,Qv,null==t?void 0:t.detail)}get detail(){return qv(this,Qv)}initCustomEvent(){}},EventTarget:zv,HTMLElement:Xv,HTMLVideoElement:class extends zv{}},tE="undefined"==typeof window||void 0===globalThis.customElements,iE=tE?eE:globalThis,rE=(tE||globalThis.document,class extends(tv(Gv(bg))){constructor(){super(...arguments),Yv(this,Jv)}get autoplay(){let e=this.getAttribute("autoplay");return null!==e&&(""===e||e)}set autoplay(e){e!==this.autoplay&&(e?this.setAttribute("autoplay","string"==typeof e?e:""):this.removeAttribute("autoplay"))}get muxCastCustomData(){return{mux:{playbackId:this.playbackId,minResolution:this.minResolution,maxResolution:this.maxResolution,renditionOrder:this.renditionOrder,customDomain:this.customDomain,tokens:{drm:this.drmToken},envKey:this.envKey,metadata:this.metadata,disableCookies:this.disableCookies,disableTracking:this.disableTracking,beaconCollectionDomain:this.beaconCollectionDomain,startTime:this.startTime,preferCmcd:this.preferCmcd}}}get castCustomData(){var e;return null!=(e=qv(this,Jv))?e:this.muxCastCustomData}set castCustomData(e){jv(this,Jv,e)}});Jv=new WeakMap,iE.customElements.get("mux-video")||(iE.customElements.define("mux-video",rE),iE.MuxVideoElement=rE);var aE={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:"mediashowtexttracksrequest",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"},nE={MEDIA_CHROME_ATTRIBUTES:"mediachromeattributes",MEDIA_CONTROLLER:"mediacontroller"},sE={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_PLAYED:"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"},oE=Object.entries(sE),lE=oE.reduce((e,[t,i])=>(e[t]=i.toLowerCase(),e),{}),dE=oE.reduce((e,[t,i])=>(e[t]=i.toLowerCase(),e),{USER_INACTIVE_CHANGE:"userinactivechange",BREAKPOINTS_CHANGE:"breakpointchange",BREAKPOINTS_COMPUTED:"breakpointscomputed"}),uE=(Object.entries(dE).reduce((e,[t,i])=>{let r=lE[t];return r&&(e[i]=r),e},{userinactivechange:"userinactive"}),Object.entries(lE).reduce((e,[t,i])=>{let r=dE[t];return r&&(e[i]=r),e},{userinactive:"userinactivechange"})),hE={SUBTITLES:"subtitles",CAPTIONS:"captions",DESCRIPTIONS:"descriptions",CHAPTERS:"chapters",METADATA:"metadata"},cE="disabled",mE="showing",fE="mouse",pE="pen",gE="touch",vE="unavailable",EE="unsupported",yE={LIVE:"live",ON_DEMAND:"on-demand",UNKNOWN:"unknown"},bE="fullscreen";function TE(e){if(e){let{id:t,width:i,height:r}=e;return[t,i,r].filter(e=>null!=e).join(":")}}function AE(e){if(e){let[t,i,r]=e.split(":");return{id:t,width:+i,height:+r}}}function _E(e){if(e){let{id:t,kind:i,language:r,label:a}=e;return[t,i,r,a].filter(e=>null!=e).join(":")}}function SE(e){if(e){let[t,i,r,a]=e.split(":");return{id:t,kind:i,language:r,label:a}}}function kE(e){return e.replace(/[-_]([a-z])/g,(e,t)=>t.toUpperCase())}function IE(e){return"number"==typeof e&&!Number.isNaN(e)&&Number.isFinite(e)}function RE(e){return"string"==typeof e&&(!isNaN(e)&&!isNaN(parseFloat(e)))}var LE=e=>new Promise(t=>setTimeout(t,e)),wE={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function DE(e){return String(e).replace(/[&<>"']/g,e=>wE[e])}var CE,ME={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","Source 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."}},PE=(null==(CE=globalThis.navigator)?void 0:CE.language)||"en",xE=(e,t={})=>(e=>{var t,i,r;let[a]=PE.split("-");return(null==(t=ME[PE])?void 0:t[e])||(null==(i=ME[a])?void 0:i[e])||(null==(r=ME.en)?void 0:r[e])||e})(e).replace(/\{(\w+)\}/g,(e,i)=>i in t?String(t[i]):`{${i}}`),OE=[{singular:"hour",plural:"hours"},{singular:"minute",plural:"minutes"},{singular:"second",plural:"seconds"}],NE=(e,t)=>`${e} ${xE(1===e?OE[t].singular:OE[t].plural)}`,UE=e=>{if(!IE(e))return"";let t=Math.abs(e),i=t!==e,r=new Date(0,0,0,0,0,t,0),a=[r.getHours(),r.getMinutes(),r.getSeconds()].map((e,t)=>e&&NE(e,t)).filter(e=>e).join(", ");return i?xE("{time} remaining",{time:a}):0===t?NE(0,2):a};function FE(e,t){let i=!1;e<0&&(i=!0,e=0-e),e=e<0?0:e;let r=Math.floor(e%60),a=Math.floor(e/60%60),n=Math.floor(e/3600),s=Math.floor(t/60%60),o=Math.floor(t/3600);return(isNaN(e)||e===1/0)&&(n=a=r="0"),n=n>0||o>0?n+":":"",a=((n||s>=10)&&a<10?"0"+a:a)+":",r=r<10?"0"+r:r,(i?"-":"")+n+a+r}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}});var BE=class{addEventListener(){}removeEventListener(){}dispatchEvent(){return!0}},$E=class extends BE{},HE=class extends $E{constructor(){super(...arguments),this.role=null}},GE={createElement:function(){return new KE.HTMLElement},createElementNS:function(){return new KE.HTMLElement},addEventListener(){},removeEventListener(){},dispatchEvent:e=>!1},KE={ResizeObserver:class{observe(){}unobserve(){}disconnect(){}},document:GE,Node:$E,Element:HE,HTMLElement:class extends HE{constructor(){super(...arguments),this.innerHTML=""}get content(){return new KE.DocumentFragment}},DocumentFragment:class extends BE{},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}}}}},WE="global"in globalThis&&(null==globalThis?void 0:globalThis.global)===globalThis||"undefined"==typeof window||void 0===window.customElements,VE=Object.keys(KE).every(e=>e in globalThis),qE=WE&&!VE?KE:globalThis,YE=WE&&!VE?GE:globalThis.document,jE=new WeakMap,zE=e=>{let t=jE.get(e);return t||jE.set(e,t=new Set),t},QE=new qE.ResizeObserver(e=>{for(let t of e)for(let e of zE(t.target))e(t)});function XE(e,t){zE(e).add(t),QE.observe(e)}function ZE(e,t){let i=zE(e);i.delete(t),i.size||QE.unobserve(e)}function JE(e){let t={};for(let i of e)t[i.name]=i.value;return t}function ey(e){var t;return null!=(t=ty(e))?t:ny(e,"media-controller")}function ty(e){var t;let{MEDIA_CONTROLLER:i}=nE,r=e.getAttribute(i);if(r)return null==(t=oy(e))?void 0:t.getElementById(r)}var iy=(e,t,i=".value")=>{let r=e.querySelector(i);r&&(r.textContent=t)},ry=(e,t)=>((e,t)=>{let i=`slot[name="${t}"]`,r=e.shadowRoot.querySelector(i);return r?r.children:[]})(e,t)[0],ay=(e,t)=>!(!e||!t)&&(!(null==e||!e.contains(t))||ay(e,t.getRootNode().host)),ny=(e,t)=>{if(!e)return null;return e.closest(t)||ny(e.getRootNode().host,t)};function sy(e=document){var t;let i=null==e?void 0:e.activeElement;return i?null!=(t=sy(i.shadowRoot))?t:i:null}function oy(e){var t;let i=null==(t=null==e?void 0:e.getRootNode)?void 0:t.call(e);return i instanceof ShadowRoot||i instanceof Document?i:null}function ly(e,{depth:t=3,checkOpacity:i=!0,checkVisibilityCSS:r=!0}={}){if(e.checkVisibility)return e.checkVisibility({checkOpacity:i,checkVisibilityCSS:r});let a=e;for(;a&&t>0;){let e=getComputedStyle(a);if(i&&"0"===e.opacity||r&&"hidden"===e.visibility||"none"===e.display)return!1;a=a.parentElement,t--}return!0}function dy(e,t){let i=function(e,t){var i,r;let a;for(a of null!=(i=e.querySelectorAll("style:not([media])"))?i:[]){let e;try{e=null==(r=a.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||uy(e,t)}function uy(e,t){var i,r;let a=null!=(i=e.querySelectorAll("style:not([media])"))?i:[],n=null==a?void 0:a[a.length-1];if(null==n||!n.sheet)return console.warn("Media Chrome: No style sheet found on style tag of",e),{style:{setProperty:()=>{},removeProperty:()=>"",getPropertyValue:()=>""}};let s=null==n?void 0:n.sheet.insertRule(`${t}{}`,n.sheet.cssRules.length);return null==(r=n.sheet.cssRules)?void 0:r[s]}function hy(e,t,i=Number.NaN){let r=e.getAttribute(t);return null!=r?+r:i}function cy(e,t,i){let r=+i;null==i||Number.isNaN(r)?e.hasAttribute(t)&&e.removeAttribute(t):hy(e,t,void 0)!==r&&e.setAttribute(t,`${r}`)}function my(e,t){return e.hasAttribute(t)}function fy(e,t,i){null!=i?my(e,t)!=i&&e.toggleAttribute(t,i):e.hasAttribute(t)&&e.removeAttribute(t)}function py(e,t,i=null){var r;return null!=(r=e.getAttribute(t))?r:i}function gy(e,t,i){if(null==i)return void(e.hasAttribute(t)&&e.removeAttribute(t));let r=`${i}`;py(e,t,void 0)!==r&&e.setAttribute(t,r)}var vy,Ey=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},yy=(e,t,i)=>(Ey(e,t,"read from private field"),i?i.call(e):t.get(e)),by=(e,t,i,r)=>(Ey(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i);var Ty=class extends qE.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,vy,void 0),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);let e=JE(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e)}}static get observedAttributes(){return[nE.MEDIA_CONTROLLER,lE.MEDIA_PAUSED]}attributeChangedCallback(e,t,i){var r,a,n,s,o;e===nE.MEDIA_CONTROLLER&&(t&&(null==(a=null==(r=yy(this,vy))?void 0:r.unassociateElement)||a.call(r,this),by(this,vy,null)),i&&this.isConnected&&(by(this,vy,null==(n=this.getRootNode())?void 0:n.getElementById(i)),null==(o=null==(s=yy(this,vy))?void 0:s.associateElement)||o.call(s,this)))}connectedCallback(){var e,t;this.tabIndex=-1,this.setAttribute("aria-hidden","true"),by(this,vy,function(e){var t;let i=e.getAttribute(nE.MEDIA_CONTROLLER);return i?null==(t=e.getRootNode())?void 0:t.getElementById(i):ny(e,"media-controller")}(this)),this.getAttribute(nE.MEDIA_CONTROLLER)&&(null==(t=null==(e=yy(this,vy))?void 0:e.associateElement)||t.call(e,this)),yy(this,vy)&&(yy(this,vy).addEventListener("pointerdown",this),yy(this,vy).addEventListener("click",this),yy(this,vy).hasAttribute("tabindex")||(yy(this,vy).tabIndex=0))}disconnectedCallback(){var e,t,i,r;this.getAttribute(nE.MEDIA_CONTROLLER)&&(null==(t=null==(e=yy(this,vy))?void 0:e.unassociateElement)||t.call(e,this)),null==(i=yy(this,vy))||i.removeEventListener("pointerdown",this),null==(r=yy(this,vy))||r.removeEventListener("click",this),by(this,vy,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:a,width:n,height:s}=this.getBoundingClientRect(),o=t-r,l=i-a;if(o<0||l<0||o>n||l>s||0===n&&0===s)return;let d=this._pointerType||"mouse";if(this._pointerType=void 0,d===gE)return void this.handleTap(e);if(d===fE||d===pE)return void this.handleMouseClick(e)}}get mediaPaused(){return my(this,lE.MEDIA_PAUSED)}set mediaPaused(e){fy(this,lE.MEDIA_PAUSED,e)}handleTap(e){}handleMouseClick(e){let t=this.mediaPaused?aE.MEDIA_PLAY_REQUEST:aE.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new qE.CustomEvent(t,{composed:!0,bubbles:!0}))}};vy=new WeakMap,Ty.shadowRootOptions={mode:"open"},Ty.getTemplateHTML=function(e){return"\n    <style>\n      :host {\n        display: var(--media-control-display, var(--media-gesture-receiver-display, inline-block));\n        box-sizing: border-box;\n      }\n    </style>\n  "},qE.customElements.get("media-gesture-receiver")||qE.customElements.define("media-gesture-receiver",Ty);var Ay,_y,Sy,ky,Iy,Ry,Ly,wy,Dy,Cy,My,Py,xy,Oy,Ny,Uy,Fy,By,$y,Hy,Gy=Ty,Ky=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},Wy=(e,t,i)=>(Ky(e,t,"read from private field"),i?i.call(e):t.get(e)),Vy=(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)},qy=(e,t,i,r)=>(Ky(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i),Yy=(e,t,i)=>(Ky(e,t,"access private method"),i),jy={AUDIO:"audio",AUTOHIDE:"autohide",BREAKPOINTS:"breakpoints",GESTURES_DISABLED:"gesturesdisabled",KEYBOARD_CONTROL:"keyboardcontrol",NO_AUTOHIDE:"noautohide",USER_INACTIVE:"userinactive",AUTOHIDE_OVER_CONTROLS:"autohideovercontrols"};var zy=Object.values(lE);function Qy(e,t){var i;if(!e.isConnected)return;let r=function(e){let t=e.split(/\s+/);return Object.fromEntries(t.map(e=>e.split(":")))}(null!=(i=e.getAttribute(jy.BREAKPOINTS))?i:"sm:384 md:576 lg:768 xl:960"),a=function(e,t){return Object.keys(e).filter(i=>t>=parseInt(e[i]))}(r,t),n=!1;if(Object.keys(r).forEach(t=>{a.includes(t)?e.hasAttribute(`breakpoint${t}`)||(e.setAttribute(`breakpoint${t}`,""),n=!0):e.hasAttribute(`breakpoint${t}`)&&(e.removeAttribute(`breakpoint${t}`),n=!0)}),n){let t=new CustomEvent(dE.BREAKPOINTS_CHANGE,{detail:a});e.dispatchEvent(t)}e.breakpointsComputed||(e.breakpointsComputed=!0,e.dispatchEvent(new CustomEvent(dE.BREAKPOINTS_COMPUTED,{bubbles:!0,composed:!0})))}var Xy=class extends qE.HTMLElement{constructor(){if(super(),Vy(this,Dy),Vy(this,My),Vy(this,xy),Vy(this,Ny),Vy(this,Fy),Vy(this,Ay,void 0),Vy(this,_y,0),Vy(this,Sy,null),Vy(this,ky,null),Vy(this,Iy,void 0),this.breakpointsComputed=!1,Vy(this,Ry,e=>{let t=this.media;for(let i of e){if("childList"!==i.type)continue;let e=i.removedNodes;for(let r of e){if("media"!=r.slot||i.target!=this)continue;let e=i.previousSibling&&i.previousSibling.previousElementSibling;if(e&&t){let t="media"!==e.slot;for(;null!==(e=e.previousSibling);)"media"==e.slot&&(t=!1);t&&this.mediaUnsetCallback(r)}else this.mediaUnsetCallback(r)}if(t)for(let e of i.addedNodes)e===t&&this.handleMediaUpdated(t)}}),Vy(this,Ly,!1),Vy(this,wy,e=>{Wy(this,Ly)||(setTimeout(()=>{(function(e){Qy(e.target,e.contentRect.width)})(e),qy(this,Ly,!1)},0),qy(this,Ly,!0))}),Vy(this,$y,void 0),Vy(this,Hy,()=>{Wy(this,$y).assignedElements({flatten:!0}).length?this.handleMediaUpdated(this.media):Wy(this,Sy)&&this.mediaUnsetCallback(Wy(this,Sy))}),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);let e=JE(this.attributes),t=this.constructor.getTemplateHTML(e);this.shadowRoot.setHTMLUnsafe?this.shadowRoot.setHTMLUnsafe(t):this.shadowRoot.innerHTML=t}qy(this,Ay,new MutationObserver(Wy(this,Ry)))}static get observedAttributes(){return[jy.AUTOHIDE,jy.GESTURES_DISABLED].concat(zy).filter(e=>![lE.MEDIA_RENDITION_LIST,lE.MEDIA_AUDIO_TRACK_LIST,lE.MEDIA_CHAPTERS_CUES,lE.MEDIA_WIDTH,lE.MEDIA_HEIGHT,lE.MEDIA_ERROR,lE.MEDIA_ERROR_MESSAGE].includes(e))}attributeChangedCallback(e,t,i){e.toLowerCase()==jy.AUTOHIDE&&(this.autohide=i)}get media(){let e=this.querySelector(":scope > [slot=media]");return"SLOT"==(null==e?void 0:e.nodeName)&&(e=e.assignedElements({flatten:!0})[0]),e}async handleMediaUpdated(e){e&&(qy(this,Sy,e),e.localName.includes("-")&&await qE.customElements.whenDefined(e.localName),this.mediaSetCallback(e))}connectedCallback(){var e;Wy(this,Ay).observe(this,{childList:!0,subtree:!0}),XE(this,Wy(this,wy));let t=null!=this.getAttribute(jy.AUDIO)?xE("audio player"):xE("video player");this.setAttribute("role","region"),this.setAttribute("aria-label",t),this.handleMediaUpdated(this.media),this.setAttribute(jy.USER_INACTIVE,""),Qy(this,this.getBoundingClientRect().width);let i=this.querySelector(":scope > slot[slot=media]");i&&(qy(this,$y,i),Wy(this,$y).addEventListener("slotchange",Wy(this,Hy))),this.addEventListener("pointerdown",this),this.addEventListener("pointermove",this),this.addEventListener("pointerup",this),this.addEventListener("mouseleave",this),this.addEventListener("keyup",this),null==(e=qE.window)||e.addEventListener("mouseup",this)}disconnectedCallback(){var e;ZE(this,Wy(this,wy)),clearTimeout(Wy(this,ky)),Wy(this,Ay).disconnect(),this.media&&this.mediaUnsetCallback(this.media),null==(e=qE.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),Wy(this,$y)&&(Wy(this,$y).removeEventListener("slotchange",Wy(this,Hy)),qy(this,$y,null)),qy(this,Ly,!1)}mediaSetCallback(e){}mediaUnsetCallback(e){qy(this,Sy,null)}handleEvent(e){switch(e.type){case"pointerdown":qy(this,_y,e.timeStamp);break;case"pointermove":Yy(this,Dy,Cy).call(this,e);break;case"pointerup":Yy(this,My,Py).call(this,e);break;case"mouseleave":Yy(this,xy,Oy).call(this);break;case"mouseup":this.removeAttribute(jy.KEYBOARD_CONTROL);break;case"keyup":Yy(this,Fy,By).call(this),this.setAttribute(jy.KEYBOARD_CONTROL,"")}}set autohide(e){let t=Number(e);qy(this,Iy,isNaN(t)?0:t)}get autohide(){return(void 0===Wy(this,Iy)?2:Wy(this,Iy)).toString()}get breakpoints(){return py(this,jy.BREAKPOINTS)}set breakpoints(e){gy(this,jy.BREAKPOINTS,e)}get audio(){return my(this,jy.AUDIO)}set audio(e){fy(this,jy.AUDIO,e)}get gesturesDisabled(){return my(this,jy.GESTURES_DISABLED)}set gesturesDisabled(e){fy(this,jy.GESTURES_DISABLED,e)}get keyboardControl(){return my(this,jy.KEYBOARD_CONTROL)}set keyboardControl(e){fy(this,jy.KEYBOARD_CONTROL,e)}get noAutohide(){return my(this,jy.NO_AUTOHIDE)}set noAutohide(e){fy(this,jy.NO_AUTOHIDE,e)}get autohideOverControls(){return my(this,jy.AUTOHIDE_OVER_CONTROLS)}set autohideOverControls(e){fy(this,jy.AUTOHIDE_OVER_CONTROLS,e)}get userInteractive(){return my(this,jy.USER_INACTIVE)}set userInteractive(e){fy(this,jy.USER_INACTIVE,e)}};Ay=new WeakMap,_y=new WeakMap,Sy=new WeakMap,ky=new WeakMap,Iy=new WeakMap,Ry=new WeakMap,Ly=new WeakMap,wy=new WeakMap,Dy=new WeakSet,Cy=function(e){if("mouse"!==e.pointerType&&e.timeStamp-Wy(this,_y)<250)return;Yy(this,Ny,Uy).call(this),clearTimeout(Wy(this,ky));let t=this.hasAttribute(jy.AUTOHIDE_OVER_CONTROLS);([this,this.media].includes(e.target)||t)&&Yy(this,Fy,By).call(this)},My=new WeakSet,Py=function(e){if("touch"===e.pointerType){let t=!this.hasAttribute(jy.USER_INACTIVE);[this,this.media].includes(e.target)&&t?Yy(this,xy,Oy).call(this):Yy(this,Fy,By).call(this)}else e.composedPath().some(e=>["media-play-button","media-fullscreen-button"].includes(null==e?void 0:e.localName))&&Yy(this,Fy,By).call(this)},xy=new WeakSet,Oy=function(){if(Wy(this,Iy)<0||this.hasAttribute(jy.USER_INACTIVE))return;this.setAttribute(jy.USER_INACTIVE,"");let e=new qE.CustomEvent(dE.USER_INACTIVE_CHANGE,{composed:!0,bubbles:!0,detail:!0});this.dispatchEvent(e)},Ny=new WeakSet,Uy=function(){if(!this.hasAttribute(jy.USER_INACTIVE))return;this.removeAttribute(jy.USER_INACTIVE);let e=new qE.CustomEvent(dE.USER_INACTIVE_CHANGE,{composed:!0,bubbles:!0,detail:!1});this.dispatchEvent(e)},Fy=new WeakSet,By=function(){Yy(this,Ny,Uy).call(this),clearTimeout(Wy(this,ky));let e=parseInt(this.autohide);e<0||qy(this,ky,setTimeout(()=>{Yy(this,xy,Oy).call(this)},1e3*e))},$y=new WeakMap,Hy=new WeakMap,Xy.shadowRootOptions={mode:"open"},Xy.getTemplateHTML=function(e){return`\n    <style>\n      \n      :host([${lE.MEDIA_IS_FULLSCREEN}]) ::slotted([slot=media]) {\n        outline: none;\n      }\n\n      :host {\n        box-sizing: border-box;\n        position: relative;\n        display: inline-block;\n        line-height: 0;\n        background-color: var(--media-background-color, #000);\n        overflow: hidden;\n      }\n\n      :host(:not([${jy.AUDIO}])) [part~=layer]:not([part~=media-layer]) {\n        position: absolute;\n        top: 0;\n        left: 0;\n        bottom: 0;\n        right: 0;\n        display: flex;\n        flex-flow: column nowrap;\n        align-items: start;\n        pointer-events: none;\n        background: none;\n      }\n\n      slot[name=media] {\n        display: var(--media-slot-display, contents);\n      }\n\n      \n      :host([${jy.AUDIO}]) slot[name=media] {\n        display: var(--media-slot-display, none);\n      }\n\n      \n      :host([${jy.AUDIO}]) [part~=layer][part~=gesture-layer] {\n        height: 0;\n        display: block;\n      }\n\n      \n      :host(:not([${jy.AUDIO}])[${jy.GESTURES_DISABLED}]) ::slotted([slot=gestures-chrome]),\n          :host(:not([${jy.AUDIO}])[${jy.GESTURES_DISABLED}]) media-gesture-receiver[slot=gestures-chrome] {\n        display: none;\n      }\n\n      \n      ::slotted(:not([slot=media]):not([slot=poster]):not(media-loading-indicator):not([role=dialog]):not([hidden])) {\n        pointer-events: auto;\n      }\n\n      :host(:not([${jy.AUDIO}])) *[part~=layer][part~=centered-layer] {\n        align-items: center;\n        justify-content: center;\n      }\n\n      :host(:not([${jy.AUDIO}])) ::slotted(media-gesture-receiver[slot=gestures-chrome]),\n      :host(:not([${jy.AUDIO}])) media-gesture-receiver[slot=gestures-chrome] {\n        align-self: stretch;\n        flex-grow: 1;\n      }\n\n      slot[name=middle-chrome] {\n        display: inline;\n        flex-grow: 1;\n        pointer-events: none;\n        background: none;\n      }\n\n      \n      ::slotted([slot=media]),\n      ::slotted([slot=poster]) {\n        width: 100%;\n        height: 100%;\n      }\n\n      \n      :host(:not([${jy.AUDIO}])) .spacer {\n        flex-grow: 1;\n      }\n\n      \n      :host(:-webkit-full-screen) {\n        \n        width: 100% !important;\n        height: 100% !important;\n      }\n\n      \n      ::slotted(:not([slot=media]):not([slot=poster]):not([${jy.NO_AUTOHIDE}]):not([hidden]):not([role=dialog])) {\n        opacity: 1;\n        transition: var(--media-control-transition-in, opacity 0.25s);\n      }\n\n      \n      :host([${jy.USER_INACTIVE}]:not([${lE.MEDIA_PAUSED}]):not([${lE.MEDIA_IS_AIRPLAYING}]):not([${lE.MEDIA_IS_CASTING}]):not([${jy.AUDIO}])) ::slotted(:not([slot=media]):not([slot=poster]):not([${jy.NO_AUTOHIDE}]):not([role=dialog])) {\n        opacity: 0;\n        transition: var(--media-control-transition-out, opacity 1s);\n      }\n\n      :host([${jy.USER_INACTIVE}]:not([${jy.NO_AUTOHIDE}]):not([${lE.MEDIA_PAUSED}]):not([${lE.MEDIA_IS_CASTING}]):not([${jy.AUDIO}])) ::slotted([slot=media]) {\n        cursor: none;\n      }\n\n      :host([${jy.USER_INACTIVE}][${jy.AUTOHIDE_OVER_CONTROLS}]:not([${jy.NO_AUTOHIDE}]):not([${lE.MEDIA_PAUSED}]):not([${lE.MEDIA_IS_CASTING}]):not([${jy.AUDIO}])) * {\n        --media-cursor: none;\n        cursor: none;\n      }\n\n\n      ::slotted(media-control-bar)  {\n        align-self: stretch;\n      }\n\n      \n      \n      :host(:not([${jy.AUDIO}])[${lE.MEDIA_HAS_PLAYED}]) slot[name=poster],\n      :host(:not([${jy.AUDIO}])[${lE.MEDIA_STREAM_TYPE}="${yE.ON_DEMAND}"][${lE.MEDIA_CURRENT_TIME}]:not([${lE.MEDIA_CURRENT_TIME}="0"])) slot[name=poster] {\n        display: none;\n      }\n\n      ::slotted([role=dialog]) {\n        width: 100%;\n        height: 100%;\n        align-self: center;\n      }\n\n      ::slotted([role=menu]) {\n        align-self: end;\n      }\n    </style>\n\n    <slot name="media" part="layer media-layer"></slot>\n    <slot name="poster" part="layer poster-layer"></slot>\n    <slot name="gestures-chrome" part="layer gesture-layer">\n      <media-gesture-receiver slot="gestures-chrome">\n        <template shadowrootmode="${Gy.shadowRootOptions.mode}">\n          ${Gy.getTemplateHTML({})}\n        </template>\n      </media-gesture-receiver>\n    </slot>\n    <span part="layer vertical-layer">\n      <slot name="top-chrome" part="top chrome"></slot>\n      <slot name="middle-chrome" part="middle chrome"></slot>\n      <slot name="centered-chrome" part="layer centered-layer center centered chrome"></slot>\n      \n      <slot part="bottom chrome"></slot>\n    </span>\n    <slot name="dialog" part="layer dialog-layer"></slot>\n  `},qE.customElements.get("media-container")||qE.customElements.define("media-container",Xy);var Zy,Jy,eb,tb,ib,rb,ab,nb,sb,ob,lb,db,ub,hb,cb,mb=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},fb=(e,t,i)=>(mb(e,t,"read from private field"),i?i.call(e):t.get(e)),pb=(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)},gb=(e,t,i,r)=>(mb(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i),vb=(e,t,i)=>(mb(e,t,"access private method"),i);var Eb="open",yb="anchor",bb=class extends qE.HTMLElement{constructor(){super(),pb(this,tb),pb(this,rb),pb(this,nb),pb(this,ob),pb(this,db),pb(this,hb),pb(this,Zy,!1),pb(this,Jy,null),pb(this,eb,null)}static get observedAttributes(){return[Eb,yb]}get open(){return my(this,Eb)}set open(e){fy(this,Eb,e)}handleEvent(e){switch(e.type){case"invoke":vb(this,ob,lb).call(this,e);break;case"focusout":vb(this,db,ub).call(this,e);break;case"keydown":vb(this,hb,cb).call(this,e)}}connectedCallback(){vb(this,tb,ib).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){vb(this,tb,ib).call(this),e===Eb&&i!==t&&(this.open?vb(this,rb,ab).call(this):vb(this,nb,sb).call(this))}focus(){gb(this,Jy,sy());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;let i=this.querySelector('[autofocus], [tabindex]:not([tabindex="-1"]), [role="menu"]');null==i||i.focus()}get keysUsed(){return["Escape","Tab"]}};Zy=new WeakMap,Jy=new WeakMap,eb=new WeakMap,tb=new WeakSet,ib=function(){if(!fb(this,Zy)&&(gb(this,Zy,!0),!this.shadowRoot)){this.attachShadow(this.constructor.shadowRootOptions);let e=JE(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e),queueMicrotask(()=>{let{style:e}=dy(this.shadowRoot,":host");e.setProperty("transition","display .15s, visibility .15s, opacity .15s ease-in, transform .15s ease-in")})}},rb=new WeakSet,ab=function(){var e;null==(e=fb(this,eb))||e.setAttribute("aria-expanded","true"),this.dispatchEvent(new Event("open",{composed:!0,bubbles:!0})),this.addEventListener("transitionend",()=>this.focus(),{once:!0})},nb=new WeakSet,sb=function(){var e;null==(e=fb(this,eb))||e.setAttribute("aria-expanded","false"),this.dispatchEvent(new Event("close",{composed:!0,bubbles:!0}))},ob=new WeakSet,lb=function(e){gb(this,eb,e.relatedTarget),ay(this,e.relatedTarget)||(this.open=!this.open)},db=new WeakSet,ub=function(e){var t;ay(this,e.relatedTarget)||(null==(t=fb(this,Jy))||t.focus(),fb(this,eb)&&fb(this,eb)!==e.relatedTarget&&this.open&&(this.open=!1))},hb=new WeakSet,cb=function(e){var t,i,r,a,n;let{key:s,ctrlKey:o,altKey:l,metaKey:d}=e;o||l||d||this.keysUsed.includes(s)&&(e.preventDefault(),e.stopPropagation(),"Tab"===s?(e.shiftKey?null==(i=null==(t=this.previousElementSibling)?void 0:t.focus)||i.call(t):null==(a=null==(r=this.nextElementSibling)?void 0:r.focus)||a.call(r),this.blur()):"Escape"===s&&(null==(n=fb(this,Jy))||n.focus(),this.open=!1))},bb.shadowRootOptions={mode:"open"},bb.getTemplateHTML=function(e){return`\n    <style>\n      :host {\n        font: var(--media-font,\n          var(--media-font-weight, normal)\n          var(--media-font-size, 14px) /\n          var(--media-text-content-height, var(--media-control-height, 24px))\n          var(--media-font-family, helvetica neue, segoe ui, roboto, arial, sans-serif));\n        color: var(--media-text-color, var(--media-primary-color, rgb(238 238 238)));\n        display: var(--media-dialog-display, inline-flex);\n        justify-content: center;\n        align-items: center;\n        \n        transition-behavior: allow-discrete;\n        visibility: hidden;\n        opacity: 0;\n        transform: translateY(2px) scale(.99);\n        pointer-events: none;\n      }\n\n      :host([open]) {\n        transition: display .2s, visibility 0s, opacity .2s ease-out, transform .15s ease-out;\n        visibility: visible;\n        opacity: 1;\n        transform: translateY(0) scale(1);\n        pointer-events: auto;\n      }\n\n      #content {\n        display: flex;\n        position: relative;\n        box-sizing: border-box;\n        width: min(320px, 100%);\n        word-wrap: break-word;\n        max-height: 100%;\n        overflow: auto;\n        text-align: center;\n        line-height: 1.4;\n      }\n    </style>\n    ${this.getSlotTemplateHTML(e)}\n  `},bb.getSlotTemplateHTML=function(e){return'\n    <slot id="content"></slot>\n  '},qE.customElements.get("media-chrome-dialog")||qE.customElements.define("media-chrome-dialog",bb);var Tb,Ab,_b=(e,t,i)=>(((e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)})(e,t,"read from private field"),i?i.call(e):t.get(e)),Sb=(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)},kb="hotkeys",Ib=[{keys:[{key:" ",label:"Space"},{key:"k"}],description:"Toggle Playback"},{keys:[{key:"m"}],description:"Toggle mute"},{keys:[{key:"f"}],description:"Toggle fullscreen"},{keys:[{key:"c"}],description:"Toggle captions or subtitles, if available"},{keys:[{key:"p"}],description:"Toggle Picture in Picture"},{keys:[{key:"ArrowLeft",label:"←"},{key:"j"}],description:"Seek back 10s"},{keys:[{key:"ArrowRight",label:"→"},{key:"l"}],description:"Seek forward 10s"},{keys:[{key:"ArrowUp",label:"↑"}],description:"Turn volume up"},{keys:[{key:"ArrowDown",label:"↓"}],description:"Turn volume down"},{keys:[{key:"<",label:"< (SHIFT+,)"}],description:"Decrease playback rate"},{keys:[{key:">",label:"> (SHIFT+.)"}],description:"Increase playback rate"},{keys:[{key:"shift+/",label:"SHIFT+/"}],description:"Show keyboard shortcuts"}];function Rb(e){return" "===e?"nospace":`no${e.toLowerCase()}`}function Lb(e){return`\n    <h2>Keyboard Shortcuts</h2>\n    <table class="shortcuts-table">${function(e){let t=new Set(null==e?void 0:e.split(/\s+/));return Ib.map(({keys:e,description:i})=>({keys:e.filter(({key:e})=>!t.has(Rb(e))),description:i})).filter(({keys:e})=>e.length)}(e).map(({keys:e,description:t})=>`\n        <tr>\n          <td>\n            <div class="key-combo">${e.map(({key:e,label:t=e},i)=>i>0?`<span class="key-separator">or</span><span class="key">${t}</span>`:`<span class="key">${t}</span>`).join("")}</div>\n          </td>\n          <td class="description">${t}</td>\n        </tr>\n      `).join("")}</table>\n  `}var wb=class extends bb{constructor(){super(...arguments),Sb(this,Tb,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(),a=r[0]===this||r.includes(this),n=r.includes(i);a&&!n&&(this.open=!1)}),Sb(this,Ab,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())})}static get observedAttributes(){return[...super.observedAttributes,kb]}get hotkeys(){var e;return null!=(e=py(this,kb))?e:void 0}set hotkeys(e){gy(this,kb,e)}connectedCallback(){super.connectedCallback(),this.open&&(this.addEventListener("click",_b(this,Tb)),document.addEventListener("keydown",_b(this,Ab)))}disconnectedCallback(){this.removeEventListener("click",_b(this,Tb)),document.removeEventListener("keydown",_b(this,Ab))}attributeChangedCallback(e,t,i){var r;if(super.attributeChangedCallback(e,t,i),"open"===e)this.open?(this.addEventListener("click",_b(this,Tb)),document.addEventListener("keydown",_b(this,Ab))):(this.removeEventListener("click",_b(this,Tb)),document.removeEventListener("keydown",_b(this,Ab)));else if(e===kb&&i!==t){let e=null==(r=this.shadowRoot)?void 0:r.querySelector("#content");e&&(e.innerHTML=Lb(i))}}};Tb=new WeakMap,Ab=new WeakMap,wb.getSlotTemplateHTML=function(e){return`\n    <style>\n      :host {\n        position: fixed;\n        top: 0;\n        left: 0;\n        z-index: 9999;\n        background: rgb(20 20 30 / .8);\n        backdrop-filter: blur(10px);\n      }\n\n      #content {\n        display: block;\n        width: clamp(400px, 40vw, 700px);\n        max-width: 90vw;\n        text-align: left;\n      }\n\n      h2 {\n        margin: 0 0 1.5rem 0;\n        font-size: 1.5rem;\n        font-weight: 500;\n        text-align: center;\n      }\n\n      .shortcuts-table {\n        width: 100%;\n        border-collapse: collapse;\n      }\n\n      .shortcuts-table tr {\n        border-bottom: 1px solid rgba(255, 255, 255, 0.1);\n      }\n\n      .shortcuts-table tr:last-child {\n        border-bottom: none;\n      }\n\n      .shortcuts-table td {\n        padding: 0.75rem 0.5rem;\n      }\n\n      .shortcuts-table td:first-child {\n        text-align: right;\n        padding-right: 1rem;\n        width: 40%;\n        min-width: 120px;\n      }\n\n      .shortcuts-table td:last-child {\n        padding-left: 1rem;\n      }\n\n      .key {\n        display: inline-block;\n        background: rgba(255, 255, 255, 0.15);\n        border: 1px solid rgba(255, 255, 255, 0.2);\n        border-radius: 4px;\n        padding: 0.25rem 0.5rem;\n        font-family: 'Courier New', monospace;\n        font-size: 0.9rem;\n        font-weight: 500;\n        min-width: 1.5rem;\n        text-align: center;\n        margin: 0 0.2rem;\n      }\n\n      .description {\n        color: rgba(255, 255, 255, 0.9);\n        font-size: 0.95rem;\n      }\n\n      .key-combo {\n        display: flex;\n        align-items: center;\n        justify-content: flex-end;\n        gap: 0.3rem;\n      }\n\n      .key-separator {\n        color: rgba(255, 255, 255, 0.5);\n        font-size: 0.9rem;\n      }\n    </style>\n    <slot id="content">\n      ${Lb(e[kb])}\n    </slot>\n  `},qE.customElements.get("media-keyboard-shortcuts-dialog")||qE.customElements.define("media-keyboard-shortcuts-dialog",wb);var Db,Cb,Mb,Pb,xb,Ob,Nb=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},Ub=(e,t,i)=>(Nb(e,t,"read from private field"),i?i.call(e):t.get(e)),Fb=(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)},Bb=(e,t,i,r)=>(Nb(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i),$b=class{constructor(e,t,{defaultValue:i}={defaultValue:void 0}){Fb(this,xb),Fb(this,Db,void 0),Fb(this,Cb,void 0),Fb(this,Mb,void 0),Fb(this,Pb,new Set),Bb(this,Db,e),Bb(this,Cb,t),Bb(this,Mb,new Set(i))}[Symbol.iterator](){return Ub(this,xb,Ob).values()}get length(){return Ub(this,xb,Ob).size}get value(){var e;return null!=(e=[...Ub(this,xb,Ob)].join(" "))?e:""}set value(e){var t;e!==this.value&&(Bb(this,Pb,new Set),this.add(...null!=(t=null==e?void 0:e.split(" "))?t:[]))}toString(){return this.value}item(e){return[...Ub(this,xb,Ob)][e]}values(){return Ub(this,xb,Ob).values()}forEach(e,t){Ub(this,xb,Ob).forEach(e,t)}add(...e){var t,i;e.forEach(e=>Ub(this,Pb).add(e)),(""!==this.value||null!=(t=Ub(this,Db))&&t.hasAttribute(`${Ub(this,Cb)}`))&&(null==(i=Ub(this,Db))||i.setAttribute(`${Ub(this,Cb)}`,`${this.value}`))}remove(...e){var t;e.forEach(e=>Ub(this,Pb).delete(e)),null==(t=Ub(this,Db))||t.setAttribute(`${Ub(this,Cb)}`,`${this.value}`)}contains(e){return Ub(this,xb,Ob).has(e)}toggle(e,t){return void 0!==t?t?(this.add(e),!0):(this.remove(e),!1):this.contains(e)?(this.remove(e),!1):(this.add(e),!0)}replace(e,t){return this.remove(e),this.add(t),e===t}};Db=new WeakMap,Cb=new WeakMap,Mb=new WeakMap,Pb=new WeakMap,xb=new WeakSet,Ob=function(){return Ub(this,Pb).size?Ub(this,Pb):Ub(this,Mb)};var Hb,Gb,Kb,Wb,Vb,qb,Yb,jb,zb,Qb,Xb,Zb,Jb,eT,tT,iT,rT,aT,nT,sT=(e="")=>{let[t,i,r]=e.split(":"),a=r?decodeURIComponent(r):void 0;return{kind:"cc"===t?hE.CAPTIONS:hE.SUBTITLES,language:i,label:a}},oT=(e="",t={})=>((e="")=>e.split(/\s+/))(e).map(e=>{let i=sT(e);return{...t,...i}}),lT=e=>e?Array.isArray(e)?e.map(e=>"string"==typeof e?sT(e):e):"string"==typeof e?oT(e):[e]:[],dT=({kind:e,label:t,language:i}={kind:"subtitles"})=>t?`${"captions"===e?"cc":"sb"}:${i}:${encodeURIComponent(t)}`:i,uT=(e=[])=>Array.prototype.map.call(e,dT).join(" "),hT=e=>{let t=Object.entries(e).map(([e,t])=>((e,t)=>i=>i[e]===t)(e,t));return e=>t.every(t=>t(e))},cT=(e,t=[],i=[])=>{let r=lT(i).map(hT);Array.from(t).filter(e=>r.some(t=>t(e))).forEach(t=>{t.mode=e})},mT=(e,t=()=>!0)=>{if(null==e||!e.textTracks)return[];let i="function"==typeof t?t:hT(t);return Array.from(e.textTracks).filter(i)},fT=e=>{var t;return!(null==(t=e.mediaSubtitlesShowing)||!t.length)||e.hasAttribute(lE.MEDIA_SUBTITLES_SHOWING)},pT="exitFullscreen"in YE?"exitFullscreen":"webkitExitFullscreen"in YE?"webkitExitFullscreen":"webkitCancelFullScreen"in YE?"webkitCancelFullScreen":void 0,gT="fullscreenElement"in YE?"fullscreenElement":"webkitFullscreenElement"in YE?"webkitFullscreenElement":void 0,vT=e=>{var t;let{media:i,documentElement:r,fullscreenElement:a=i}=e;if(!i||!r)return!1;let n=(e=>{let{documentElement:t,media:i}=e,r=null==t?void 0:t[gT];return!r&&"webkitDisplayingFullscreen"in i&&"webkitPresentationMode"in i&&i.webkitDisplayingFullscreen&&i.webkitPresentationMode===bE?i:r})(e);if(!n)return!1;if(n===a||n===i)return!0;if(n.localName.includes("-")){let e=n.shadowRoot;if(!(gT in e))return ay(n,a);for(;null!=e&&e[gT];){if(e[gT]===a)return!0;e=null==(t=e[gT])?void 0:t.shadowRoot}}return!1},ET="fullscreenEnabled"in YE?"fullscreenEnabled":"webkitFullscreenEnabled"in YE?"webkitFullscreenEnabled":void 0,yT=()=>{var e,t;return Hb||(Hb=null==(t=null==(e=YE)?void 0:e.createElement)?void 0:t.call(e,"video"))},bT=(e,t)=>new Promise(i=>{e.addEventListener("volumechange",()=>i(!0),{signal:t})}),TT=async(e,t)=>{for(let i=0;i<10;i++){if(e.volume===t)return!1;await LE(10)}return e.volume!==t},AT=/.*Version\/.*Safari\/.*/.test(qE.navigator.userAgent),_T=(e=yT())=>(!qE.matchMedia("(display-mode: standalone)").matches||!AT)&&"function"==typeof(null==e?void 0:e.requestPictureInPicture),ST=(e=yT())=>(e=>{let{documentElement:t,media:i}=e;return!(null==t||!t[ET])||i&&"webkitSupportsFullscreen"in i})({documentElement:YE,media:e}),kT=ST(),IT=_T(),RT=!!qE.WebKitPlaybackTargetAvailabilityEvent,LT=!!qE.chrome,wT=e=>mT(e.media,e=>[hE.SUBTITLES,hE.CAPTIONS].includes(e.kind)).sort((e,t)=>e.kind>=t.kind?1:-1),DT=e=>mT(e.media,e=>e.mode===mE&&[hE.SUBTITLES,hE.CAPTIONS].includes(e.kind)),CT=(e,t)=>{let i=wT(e),r=DT(e),a=!!r.length;if(i.length)if(!1===t||a&&!0!==t)cT(cE,i,r);else if(!0===t||!a&&!1!==t){let t=i[0],{options:a}=e;if(null==a||!a.noSubtitlesLangPref){let e=qE.localStorage.getItem("media-chrome-pref-subtitles-lang"),r=e?[e,...qE.navigator.languages]:qE.navigator.languages,a=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])));a[0]&&(t=a[0])}let{language:n,label:s,kind:o}=t;cT(cE,i,r),cT(mE,i,[{language:n,label:s,kind:o}])}},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)?PT(e,t):Object.entries(e).every(([e,i])=>e in t&&MT(i,t[e])))),PT=(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])))},xT=Object.values(yE),OT=(async(e=yT())=>{if(!e)return!1;let t=e.volume;e.volume=t/2+.1;let i=new AbortController,r=await Promise.race([bT(e,i.signal),TT(e,t)]);return i.abort(),r})().then(e=>Gb=e),NT=new qE.DOMParser,UT=e=>e&&(NT.parseFromString(e,"text/html").body.textContent||e),FT={mediaError:{get(e,t){let{media:i}=e;if("playing"!==(null==t?void 0:t.type))return null==i?void 0:i.error},mediaEvents:["emptied","error","playing"]},mediaErrorCode:{get(e,t){var i;let{media:r}=e;if("playing"!==(null==t?void 0:t.type))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:a}=e;if("playing"!==(null==t?void 0:t.type))return null!=(r=null==(i=null==a?void 0:a.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!==qE.localStorage.getItem("media-chrome-pref-muted"),a=i.hasAttribute("muted");if(r)return void(t&&qE.localStorage.removeItem("media-chrome-pref-muted"));if(a&&!t)return;qE.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"===qE.localStorage.getItem("media-chrome-pref-muted");FT.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?qE.localStorage.removeItem("media-chrome-pref-volume"):!i.hasAttribute("muted")&&!r&&qE.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=qE.localStorage.getItem("media-chrome-pref-volume");if(null==r)return;FT.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||!IE(e)||(i.currentTime=e)},mediaEvents:["timeupdate","loadedmetadata","seeking"]},mediaDuration:{get(e){let{media:t,options:{defaultDuration:i}={}}=e;return!i||t&&t.duration&&!Number.isNaN(t.duration)&&Number.isFinite(t.duration)?Number.isFinite(null==t?void 0:t.duration)?t.duration:Number.NaN:i},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)||!t.length)return;let r=i.seekable.start(0),a=i.seekable.end(i.seekable.length-1);return r||a?[Number(r.toFixed(3)),Number(a.toFixed(3))]:void 0},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}={}}=e,r=[yE.LIVE,yE.ON_DEMAND].includes(i)?i:void 0;if(!t)return r;let{streamType:a}=t;if(xT.includes(a))return a===yE.UNKNOWN?r:a;let n=t.duration;return n===1/0?yE.LIVE:Number.isFinite(n)?yE.ON_DEMAND:r},mediaEvents:["emptied","durationchange","loadedmetadata","streamtypechange"]},mediaTargetLiveWindow:{get(e){let{media:t}=e;if(!t)return Number.NaN;let{targetLiveWindow:i}=t,r=FT.mediaStreamType.get(e);return null!=i&&!Number.isNaN(i)||r!==yE.LIVE?i:0},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(FT.mediaStreamType.get(e)!==yE.LIVE)return!1;let r=t.seekable;if(!r)return!0;if(!r.length)return!1;let a=r.end(r.length-1)-i;return t.currentTime>=a},mediaEvents:["playing","timeupdate","progress","waiting","emptied"]},mediaSubtitlesList:{get:e=>wT(e).map(({kind:e,label:t,language:i})=>({kind:e,label:t,language:i})),mediaEvents:["loadstart"],textTracksEvents:["addtrack","removetrack"]},mediaSubtitlesShowing:{get:e=>DT(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:a,options:n}=t;if(!a)return;let s=e=>{var i;!n.defaultSubtitles||e&&![hE.CAPTIONS,hE.SUBTITLES].includes(null==(i=null==e?void 0:e.track)?void 0:i.kind)||CT(t,!0)};return a.addEventListener("loadstart",s),null==(i=a.textTracks)||i.addEventListener("addtrack",s),null==(r=a.textTracks)||r.addEventListener("removetrack",s),()=>{var e,t;a.removeEventListener("loadstart",s),null==(e=a.textTracks)||e.removeEventListener("addtrack",s),null==(t=a.textTracks)||t.removeEventListener("removetrack",s)}}]},mediaChaptersCues:{get(e){var t;let{media:i}=e;if(!i)return[];let[r]=mT(i,{kind:hE.CHAPTERS});return Array.from(null!=(t=null==r?void 0:r.cues)?t:[]).map(({text:e,startTime:t,endTime:i})=>({text:UT(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 a=r.querySelector('track[kind="chapters"][default][src]'),n=null==(i=r.shadowRoot)?void 0:i.querySelector(':is(video,audio) > track[kind="chapters"][default][src]');return null==a||a.addEventListener("load",e),null==n||n.addEventListener("load",e),()=>{null==a||a.removeEventListener("load",e),null==n||n.removeEventListener("load",e)}}]},mediaIsPip:{get(e){var t,i;let{media:r,documentElement:a}=e;if(!r||!a||!a.pictureInPictureElement)return!1;if(a.pictureInPictureElement===r)return!0;if(a.pictureInPictureElement instanceof HTMLMediaElement)return!(null==(t=r.localName)||!t.includes("-"))&&ay(r,a.pictureInPictureElement);if(a.pictureInPictureElement.localName.includes("-")){let e=a.pictureInPictureElement.shadowRoot;for(;null!=e&&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(!YE.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)throw t;if(i.src){if(0!==i.readyState||"none"!==i.preload)throw t;{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 console.warn("MediaChrome: The media is not ready for picture-in-picture. It must have a src set.")})}else YE.pictureInPictureElement&&YE.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:a}=e;return null==(r=null==(i=null==a?void 0:a.videoRenditions)?void 0:i[null==(t=a.videoRenditions)?void 0:t.selectedIndex])?void 0:r.id},set(e,t){let{media:i}=t;if(null==i||!i.videoRenditions)return void console.warn("MediaController: Rendition selection not supported by this media.");let r=e,a=Array.prototype.findIndex.call(i.videoRenditions,e=>e.id==r);i.videoRenditions.selectedIndex!=a&&(i.videoRenditions.selectedIndex=a)},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||!i.audioTracks)return void console.warn("MediaChrome: Audio track selection not supported by this media.");let r=e;for(let e of i.audioTracks)e.enabled=r==e.id},mediaEvents:["emptied"],audioTracksEvents:["addtrack","removetrack","change"]},mediaIsFullscreen:{get:e=>vT(e),set(e,t,i){var r,a;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&&i.webkitEnterFullscreen?i.webkitEnterFullscreen():null!=i&&i.requestFullscreen&&i.requestFullscreen()}catch(e){console.error(e)}})(t),i.detail&&(null==(r=t.media)||!r.inert)&&(null==(a=t.media)||a.focus())):(e=>{var t;let{documentElement:i}=e;if(pT){let e=null==(t=null==i?void 0:i[pT])?void 0:t.call(i);if(e instanceof Promise)e.catch(()=>{})}})(t)},rootEvents:["fullscreenchange","webkitfullscreenchange"],mediaEvents:["webkitbeginfullscreen","webkitendfullscreen","webkitpresentationmodechanged"]},mediaIsCasting:{get(e){var t;let{media:i}=e;return!(null==i||!i.remote||"disconnected"===(null==(t=i.remote)?void 0:t.state))&&"connected"===i.remote.state},set(e,t){var i,r;let{media:a}=t;if(a&&(!e||"disconnected"===(null==(i=a.remote)?void 0:i.state))&&(e||"connected"===(null==(r=a.remote)?void 0:r.state))){if("function"!=typeof a.remote.prompt)return void console.warn("MediaChrome: Casting is not supported in this environment");a.remote.prompt().catch(()=>{})}},remoteEvents:["connect","connecting","disconnect"]},mediaIsAirplaying:{get:()=>!1,set(e,t){let{media:i}=t;if(i){if(!i.webkitShowPlaybackTargetPicker||!qE.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(!kT||!ST(t))return EE}},mediaPipUnavailable:{get(e){let{media:t}=e;return IT&&_T(t)?null!=t&&t.disablePictureInPicture?vE:void 0:EE}},mediaVolumeUnavailable:{get(e){let{media:t}=e;if(!1===Gb||null==(null==t?void 0:t.volume))return EE},stateOwnersUpdateHandlers:[e=>{null==Gb&&OT.then(t=>e(t?void 0:EE))}]},mediaCastUnavailable:{get(e,{availability:t="not-available"}={}){var i;let{media:r}=e;return LT&&null!=(i=null==r?void 0:r.remote)&&i.state?null!=t&&"available"!==t?vE:void 0:EE},stateOwnersUpdateHandlers:[(e,t)=>{var i;let{media:r}=t;return r?(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(()=>{})}):void 0}]},mediaAirplayUnavailable:{get:(e,t)=>RT?"not-available"===(null==t?void 0:t.availability)?vE:void 0:EE,mediaEvents:["webkitplaybacktargetavailabilitychanged"],stateOwnersUpdateHandlers:[(e,t)=>{var i;let{media:r}=t;return r?(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(()=>{})}):void 0}]},mediaRenditionUnavailable:{get(e){var t;let{media:i}=e;return null!=i&&i.videoRenditions?null!=(t=i.videoRenditions)&&t.length?void 0:vE:EE},mediaEvents:["emptied","loadstart"],videoRenditionsEvents:["addrendition","removerendition"]},mediaAudioTrackUnavailable:{get(e){var t,i;let{media:r}=e;return null!=r&&r.audioTracks?(null!=(i=null==(t=r.audioTracks)?void 0:t.length)?i:0)<=1?vE:void 0:EE},mediaEvents:["emptied","loadstart"],audioTracksEvents:["addtrack","removetrack"]},mediaLang:{get(e){let{options:{mediaLang:t}={}}=e;return null!=t?t:"en"}}},BT={[aE.MEDIA_PREVIEW_REQUEST](e,t,{detail:i}){var r,a,n;let s,o,{media:l}=t,d=null!=i?i:void 0;if(l&&null!=d){let[e]=mT(l,{kind:hE.METADATA,label:"thumbnails"}),t=Array.prototype.find.call(null!=(r=null==e?void 0:e.cues)?r:[],(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==(a=null==l?void 0:l.querySelector('track[label="thumbnails"]'))?void 0:a.src,i=new URL(t.text,e);o=new URLSearchParams(i.hash).get("#xywh").split(",").map(e=>+e),s=i.href}}let u=e.mediaDuration.get(t),h=null==(n=e.mediaChaptersCues.get(t).find((e,t,i)=>t===i.length-1&&u===e.endTime?e.startTime<=d&&e.endTime>=d:e.startTime<=d&&e.endTime>d))?void 0:n.text;return null!=i&&null==h&&(h=""),{mediaPreviewTime:d,mediaPreviewImage:s,mediaPreviewCoords:o,mediaPreviewChapter:h}},[aE.MEDIA_PAUSE_REQUEST](e,t){e.mediaPaused.set(!0,t)},[aE.MEDIA_PLAY_REQUEST](e,t){var i,r,a,n;let s=e.mediaStreamType.get(t)===yE.LIVE,o=!(null!=(i=t.options)&&i.noAutoSeekToLive),l=e.mediaTargetLiveWindow.get(t)>0;if(s&&o&&!l){let i=null==(r=e.mediaSeekable.get(t))?void 0:r[1];if(i){let r=i-(null!=(n=null==(a=t.options)?void 0:a.seekToLiveOffset)?n:0);e.mediaCurrentTime.set(r,t)}}e.mediaPaused.set(!1,t)},[aE.MEDIA_PLAYBACK_RATE_REQUEST](e,t,{detail:i}){let r=i;e.mediaPlaybackRate.set(r,t)},[aE.MEDIA_MUTE_REQUEST](e,t){e.mediaMuted.set(!0,t)},[aE.MEDIA_UNMUTE_REQUEST](e,t){e.mediaVolume.get(t)||e.mediaVolume.set(.25,t),e.mediaMuted.set(!1,t)},[aE.MEDIA_LOOP_REQUEST](e,t,{detail:i}){let r=!!i;return e.mediaLoop.set(r,t),{mediaLoop:r}},[aE.MEDIA_VOLUME_REQUEST](e,t,{detail:i}){let r=i;r&&e.mediaMuted.get(t)&&e.mediaMuted.set(!1,t),e.mediaVolume.set(r,t)},[aE.MEDIA_SEEK_REQUEST](e,t,{detail:i}){let r=i;e.mediaCurrentTime.set(r,t)},[aE.MEDIA_SEEK_TO_LIVE_REQUEST](e,t){var i,r,a;let n=null==(i=e.mediaSeekable.get(t))?void 0:i[1];if(Number.isNaN(Number(n)))return;let s=n-(null!=(a=null==(r=t.options)?void 0:r.seekToLiveOffset)?a:0);e.mediaCurrentTime.set(s,t)},[aE.MEDIA_SHOW_SUBTITLES_REQUEST](e,t,{detail:i}){var r;let{options:a}=t,n=wT(t),s=lT(i),o=null==(r=s[0])?void 0:r.language;o&&!a.noSubtitlesLangPref&&qE.localStorage.setItem("media-chrome-pref-subtitles-lang",o),cT(mE,n,s)},[aE.MEDIA_DISABLE_SUBTITLES_REQUEST](e,t,{detail:i}){let r=wT(t);cT(cE,r,null!=i?i:[])},[aE.MEDIA_TOGGLE_SUBTITLES_REQUEST](e,t,{detail:i}){CT(t,i)},[aE.MEDIA_RENDITION_REQUEST](e,t,{detail:i}){let r=i;e.mediaRenditionSelected.set(r,t)},[aE.MEDIA_AUDIO_TRACK_REQUEST](e,t,{detail:i}){let r=i;e.mediaAudioTrackEnabled.set(r,t)},[aE.MEDIA_ENTER_PIP_REQUEST](e,t){e.mediaIsFullscreen.get(t)&&e.mediaIsFullscreen.set(!1,t),e.mediaIsPip.set(!0,t)},[aE.MEDIA_EXIT_PIP_REQUEST](e,t){e.mediaIsPip.set(!1,t)},[aE.MEDIA_ENTER_FULLSCREEN_REQUEST](e,t,i){e.mediaIsPip.get(t)&&e.mediaIsPip.set(!1,t),e.mediaIsFullscreen.set(!0,t,i)},[aE.MEDIA_EXIT_FULLSCREEN_REQUEST](e,t){e.mediaIsFullscreen.set(!1,t)},[aE.MEDIA_ENTER_CAST_REQUEST](e,t){e.mediaIsFullscreen.get(t)&&e.mediaIsFullscreen.set(!1,t),e.mediaIsCasting.set(!0,t)},[aE.MEDIA_EXIT_CAST_REQUEST](e,t){e.mediaIsCasting.set(!1,t)},[aE.MEDIA_AIRPLAY_REQUEST](e,t){e.mediaIsAirplaying.set(!0,t)}},$T=({media:e,fullscreenElement:t,documentElement:i,stateMediator:r=FT,requestMap:a=BT,options:n={},monitorStateOwnersOnlyWithSubscriptions:s=!0})=>{let o,l=[],d={options:{...n}},u=Object.freeze({mediaPreviewTime:void 0,mediaPreviewImage:void 0,mediaPreviewCoords:void 0,mediaPreviewChapter:void 0}),h=e=>{null!=e&&(MT(e,u)||(u=Object.freeze({...u,...e}),l.forEach(e=>e(u))))},c=()=>{let e=Object.entries(r).reduce((e,[t,{get:i}])=>(e[t]=i(d),e),{});h(e)},m={},f=async(e,t)=>{var i,a,n,u,f,p,g,v,E,y,b,T,A,_,S,k;let I=!!o;if(o={...d,...null!=o?o:{},...e},I)return;await(async(...e)=>{await Promise.all(e.filter(e=>e).map(async e=>{if(!("localName"in e&&e instanceof qE.HTMLElement))return;let t=e.localName;if(!t.includes("-"))return;let i=qE.customElements.get(t);i&&e instanceof i||(await qE.customElements.whenDefined(t),qE.customElements.upgrade(e))}))})(...Object.values(e));let R=l.length>0&&0===t&&s,L=d.media!==o.media,w=(null==(i=d.media)?void 0:i.textTracks)!==(null==(a=o.media)?void 0:a.textTracks),D=(null==(n=d.media)?void 0:n.videoRenditions)!==(null==(u=o.media)?void 0:u.videoRenditions),C=(null==(f=d.media)?void 0:f.audioTracks)!==(null==(p=o.media)?void 0:p.audioTracks),M=(null==(g=d.media)?void 0:g.remote)!==(null==(v=o.media)?void 0:v.remote),P=d.documentElement!==o.documentElement,x=!!d.media&&(L||R),O=!(null==(E=d.media)||!E.textTracks)&&(w||R),N=!(null==(y=d.media)||!y.videoRenditions)&&(D||R),U=!(null==(b=d.media)||!b.audioTracks)&&(C||R),F=!(null==(T=d.media)||!T.remote)&&(M||R),B=!!d.documentElement&&(P||R),$=x||O||N||U||F||B,H=0===l.length&&1===t&&s,G=!!o.media&&(L||H),K=!(null==(A=o.media)||!A.textTracks)&&(w||H),W=!(null==(_=o.media)||!_.videoRenditions)&&(D||H),V=!(null==(S=o.media)||!S.audioTracks)&&(C||H),q=!(null==(k=o.media)||!k.remote)&&(M||H),Y=!!o.documentElement&&(P||H),j=G||K||W||V||q||Y;if(!$&&!j)return Object.entries(o).forEach(([e,t])=>{d[e]=t}),c(),void(o=void 0);Object.entries(r).forEach(([e,{get:t,mediaEvents:i=[],textTracksEvents:r=[],videoRenditionsEvents:a=[],audioTracksEvents:n=[],remoteEvents:s=[],rootEvents:l=[],stateOwnersUpdateHandlers:u=[]}])=>{m[e]||(m[e]={});let c,f=i=>{let r=t(d,i);h({[e]:r})};c=m[e].mediaEvents,i.forEach(t=>{c&&x&&(d.media.removeEventListener(t,c),m[e].mediaEvents=void 0),G&&(o.media.addEventListener(t,f),m[e].mediaEvents=f)}),c=m[e].textTracksEvents,r.forEach(t=>{var i,r;c&&O&&(null==(i=d.media.textTracks)||i.removeEventListener(t,c),m[e].textTracksEvents=void 0),K&&(null==(r=o.media.textTracks)||r.addEventListener(t,f),m[e].textTracksEvents=f)}),c=m[e].videoRenditionsEvents,a.forEach(t=>{var i,r;c&&N&&(null==(i=d.media.videoRenditions)||i.removeEventListener(t,c),m[e].videoRenditionsEvents=void 0),W&&(null==(r=o.media.videoRenditions)||r.addEventListener(t,f),m[e].videoRenditionsEvents=f)}),c=m[e].audioTracksEvents,n.forEach(t=>{var i,r;c&&U&&(null==(i=d.media.audioTracks)||i.removeEventListener(t,c),m[e].audioTracksEvents=void 0),V&&(null==(r=o.media.audioTracks)||r.addEventListener(t,f),m[e].audioTracksEvents=f)}),c=m[e].remoteEvents,s.forEach(t=>{var i,r;c&&F&&(null==(i=d.media.remote)||i.removeEventListener(t,c),m[e].remoteEvents=void 0),q&&(null==(r=o.media.remote)||r.addEventListener(t,f),m[e].remoteEvents=f)}),c=m[e].rootEvents,l.forEach(t=>{c&&B&&(d.documentElement.removeEventListener(t,c),m[e].rootEvents=void 0),Y&&(o.documentElement.addEventListener(t,f),m[e].rootEvents=f)});let p=m[e].stateOwnersUpdateHandlers;if(p&&$&&(Array.isArray(p)?p:[p]).forEach(e=>{"function"==typeof e&&e()}),j){let t=u.map(e=>e(f,o)).filter(e=>"function"==typeof e);m[e].stateOwnersUpdateHandlers=1===t.length?t[0]:t}else $&&(m[e].stateOwnersUpdateHandlers=void 0)}),Object.entries(o).forEach(([e,t])=>{d[e]=t}),c(),o=void 0};return f({media:e,fullscreenElement:t,documentElement:i,options:n}),{dispatch(e){let{type:t,detail:i}=e;a[t]&&null==u.mediaErrorCode?h(a[t](r,d,e)):"mediaelementchangerequest"===t?f({media:i}):"fullscreenelementchangerequest"===t?f({fullscreenElement:i}):"documentelementchangerequest"===t?f({documentElement:i}):"optionschangerequest"===t&&(Object.entries(null!=i?i:{}).forEach(([e,t])=>{d.options[e]=t}),c())},getState:()=>u,subscribe:e=>(f({},l.length+1),l.push(e),e(u),()=>{let t=l.indexOf(e);t>=0&&(f({},l.length-1),l.splice(t,1))})}},HT=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},GT=(e,t,i)=>(HT(e,t,"read from private field"),i?i.call(e):t.get(e)),KT=(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)},WT=(e,t,i,r)=>(HT(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i),VT=(e,t,i)=>(HT(e,t,"access private method"),i),qT=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Enter"," ","f","m","k","c","l","j",">","<","p"],YT="defaultsubtitles",jT="defaultstreamtype",zT="defaultduration",QT="fullscreenelement",XT="hotkeys",ZT="keyboardbackwardseekoffset",JT="keyboardforwardseekoffset",eA="keyboarddownvolumestep",tA="keyboardupvolumestep",iA="keysused",rA="lang",aA="loop",nA="liveedgeoffset",sA="noautoseektolive",oA="nodefaultstore",lA="nohotkeys",dA="nomutedpref",uA="nosubtitleslangpref",hA="novolumepref",cA="seektoliveoffset",mA=class extends Xy{constructor(){super(),KT(this,Xb),KT(this,eT),KT(this,iT),KT(this,aT),this.mediaStateReceivers=[],this.associatedElementSubscriptions=new Map,KT(this,Kb,new $b(this,XT)),KT(this,Wb,void 0),KT(this,Vb,void 0),KT(this,qb,null),KT(this,Yb,void 0),KT(this,jb,void 0),KT(this,zb,e=>{var t;null==(t=GT(this,Vb))||t.dispatch(e)}),KT(this,Qb,void 0),KT(this,Jb,e=>{let{key:t,shiftKey:i}=e;i&&("/"===t||"?"===t)||qT.includes(t)?this.keyboardShortcutHandler(e):this.removeEventListener("keyup",GT(this,Jb))}),this.associateElement(this);let e={};WT(this,Yb,t=>{Object.entries(t).forEach(([t,i])=>{if(t in e&&e[t]===i)return;this.propagateMediaState(t,i);let r=t.toLowerCase(),a=new qE.CustomEvent(uE[r],{composed:!0,detail:i});this.dispatchEvent(a)}),e=t})}static get observedAttributes(){return super.observedAttributes.concat(lA,XT,jT,YT,zT,dA,hA,rA,aA,nA,cA,sA)}get mediaStore(){return GT(this,Vb)}set mediaStore(e){var t,i;GT(this,Vb)&&(null==(t=GT(this,jb))||t.call(this),WT(this,jb,void 0)),WT(this,Vb,e),GT(this,Vb)||this.hasAttribute(oA)?WT(this,jb,null==(i=GT(this,Vb))?void 0:i.subscribe(GT(this,Yb))):VT(this,Xb,Zb).call(this)}get fullscreenElement(){var e;return null!=(e=GT(this,Wb))?e:this}set fullscreenElement(e){var t;this.hasAttribute(QT)&&this.removeAttribute(QT),WT(this,Wb,e),null==(t=GT(this,Vb))||t.dispatch({type:"fullscreenelementchangerequest",detail:this.fullscreenElement})}get defaultSubtitles(){return my(this,YT)}set defaultSubtitles(e){fy(this,YT,e)}get defaultStreamType(){return py(this,jT)}set defaultStreamType(e){gy(this,jT,e)}get defaultDuration(){return hy(this,zT)}set defaultDuration(e){cy(this,zT,e)}get noHotkeys(){return my(this,lA)}set noHotkeys(e){fy(this,lA,e)}get keysUsed(){return py(this,iA)}set keysUsed(e){gy(this,iA,e)}get liveEdgeOffset(){return hy(this,nA)}set liveEdgeOffset(e){cy(this,nA,e)}get noAutoSeekToLive(){return my(this,sA)}set noAutoSeekToLive(e){fy(this,sA,e)}get noVolumePref(){return my(this,hA)}set noVolumePref(e){fy(this,hA,e)}get noMutedPref(){return my(this,dA)}set noMutedPref(e){fy(this,dA,e)}get noSubtitlesLangPref(){return my(this,uA)}set noSubtitlesLangPref(e){fy(this,uA,e)}get noDefaultStore(){return my(this,oA)}set noDefaultStore(e){fy(this,oA,e)}get resolvedLang(){return(()=>{let[e]=PE.split("-");return ME[PE]?PE:ME[e]?e:"en"})()}attributeChangedCallback(e,t,i){var r,a,n,s,o,l,d,u,h,c,m,f;if(super.attributeChangedCallback(e,t,i),e===lA)i!==t&&""===i?(this.hasAttribute(XT)&&console.warn("Media Chrome: Both `hotkeys` and `nohotkeys` have been set. All hotkeys will be disabled."),this.disableHotkeys()):i!==t&&null===i&&this.enableHotkeys(),VT(this,iT,rT).call(this);else if(e===XT)GT(this,Kb).value=i,VT(this,iT,rT).call(this);else if(e===YT&&i!==t)null==(r=GT(this,Vb))||r.dispatch({type:"optionschangerequest",detail:{defaultSubtitles:this.hasAttribute(YT)}});else if(e===jT)null==(n=GT(this,Vb))||n.dispatch({type:"optionschangerequest",detail:{defaultStreamType:null!=(a=this.getAttribute(jT))?a:void 0}});else if(e===nA&&i!==t)null==(s=GT(this,Vb))||s.dispatch({type:"optionschangerequest",detail:{liveEdgeOffset:this.hasAttribute(nA)?+this.getAttribute(nA):void 0,seekToLiveOffset:this.hasAttribute(cA)?+this.getAttribute(cA):this.hasAttribute(nA)?+this.getAttribute(nA):void 0}});else if(e===cA&&i!==t)null==(o=GT(this,Vb))||o.dispatch({type:"optionschangerequest",detail:{seekToLiveOffset:this.hasAttribute(cA)?+this.getAttribute(cA):this.hasAttribute(nA)?+this.getAttribute(nA):void 0}});else if(e===sA)null==(l=GT(this,Vb))||l.dispatch({type:"optionschangerequest",detail:{noAutoSeekToLive:this.hasAttribute(sA)}});else if(e===QT){let e=i?null==(d=this.getRootNode())?void 0:d.getElementById(i):void 0;WT(this,Wb,e),null==(u=GT(this,Vb))||u.dispatch({type:"fullscreenelementchangerequest",detail:this.fullscreenElement})}else e===rA&&i!==t?((e=>{PE=e})(i),null==(h=GT(this,Vb))||h.dispatch({type:"optionschangerequest",detail:{mediaLang:i}})):e===aA&&i!==t?null==(c=GT(this,Vb))||c.dispatch({type:aE.MEDIA_LOOP_REQUEST,detail:null!=i}):e===hA&&i!==t?null==(m=GT(this,Vb))||m.dispatch({type:"optionschangerequest",detail:{noVolumePref:this.hasAttribute(hA)}}):e===dA&&i!==t&&(null==(f=GT(this,Vb))||f.dispatch({type:"optionschangerequest",detail:{noMutedPref:this.hasAttribute(dA)}}))}connectedCallback(){var e,t,i;this.associateElement(this),!GT(this,Vb)&&!this.hasAttribute(oA)&&VT(this,Xb,Zb).call(this),null==(e=GT(this,Vb))||e.dispatch({type:"documentelementchangerequest",detail:YE}),null==(t=GT(this,Vb))||t.dispatch({type:"fullscreenelementchangerequest",detail:this.fullscreenElement}),super.connectedCallback(),GT(this,Vb)&&!GT(this,jb)&&WT(this,jb,null==(i=GT(this,Vb))?void 0:i.subscribe(GT(this,Yb))),void 0!==GT(this,Qb)&&GT(this,Vb)&&this.media&&setTimeout(()=>{var e,t,i;null!=(t=null==(e=this.media)?void 0:e.textTracks)&&t.length&&(null==(i=GT(this,Vb))||i.dispatch({type:aE.MEDIA_TOGGLE_SUBTITLES_REQUEST,detail:GT(this,Qb)}))},0),this.hasAttribute(lA)?this.disableHotkeys():this.enableHotkeys()}disconnectedCallback(){var e,t,i,r,a,n;if(null==(e=super.disconnectedCallback)||e.call(this),this.disableHotkeys(),GT(this,Vb)){let e=GT(this,Vb).getState();WT(this,Qb,!(null==(t=e.mediaSubtitlesShowing)||!t.length)),null==(i=GT(this,Vb))||i.dispatch({type:"fullscreenelementchangerequest",detail:void 0}),null==(r=GT(this,Vb))||r.dispatch({type:"documentelementchangerequest",detail:void 0}),null==(a=GT(this,Vb))||a.dispatch({type:aE.MEDIA_TOGGLE_SUBTITLES_REQUEST,detail:!1})}GT(this,jb)&&(null==(n=GT(this,jb))||n.call(this),WT(this,jb,void 0)),this.unassociateElement(this),GT(this,qb)&&(GT(this,qb).remove(),WT(this,qb,null))}mediaSetCallback(e){var t;super.mediaSetCallback(e),null==(t=GT(this,Vb))||t.dispatch({type:"mediaelementchangerequest",detail:e}),e.hasAttribute("tabindex")||(e.tabIndex=-1)}mediaUnsetCallback(e){var t;super.mediaUnsetCallback(e),null==(t=GT(this,Vb))||t.dispatch({type:"mediaelementchangerequest",detail:void 0})}propagateMediaState(e,t){TA(this.mediaStateReceivers,e,t)}associateElement(e){if(!e)return;let{associatedElementSubscriptions:t}=this;if(t.has(e))return;let i=this.registerMediaStateReceiver.bind(this),r=this.unregisterMediaStateReceiver.bind(this),a=AA(e,i,r);Object.values(aE).forEach(t=>{e.addEventListener(t,GT(this,zb))}),t.set(e,a)}unassociateElement(e){if(!e)return;let{associatedElementSubscriptions:t}=this;t.has(e)&&(t.get(e)(),t.delete(e),Object.values(aE).forEach(t=>{e.removeEventListener(t,GT(this,zb))}))}registerMediaStateReceiver(e){if(!e)return;let t=this.mediaStateReceivers;t.indexOf(e)>-1||(t.push(e),GT(this,Vb)&&Object.entries(GT(this,Vb).getState()).forEach(([t,i])=>{TA([e],t,i)}))}unregisterMediaStateReceiver(e){let t=this.mediaStateReceivers,i=t.indexOf(e);i<0||t.splice(i,1)}enableHotkeys(){this.addEventListener("keydown",VT(this,eT,tT))}disableHotkeys(){this.removeEventListener("keydown",VT(this,eT,tT)),this.removeEventListener("keyup",GT(this,Jb))}get hotkeys(){return GT(this,Kb)}set hotkeys(e){gy(this,XT,e)}keyboardShortcutHandler(e){var t,i,r,a,n,s,o,l,d;let u,h,c,m=e.target;if(!(null!=(r=null!=(i=null==(t=m.getAttribute(iA))?void 0:t.split(" "))?i:null==m?void 0:m.keysUsed)?r:[]).map(e=>"Space"===e?" ":e).filter(Boolean).includes(e.key)&&!(GT(this,Kb).contains(Rb(e.key))||e.shiftKey&&("/"===e.key||"?"===e.key)&&GT(this,Kb).contains("noshift+/")))switch(e.key){case" ":case"k":u=GT(this,Vb).getState().mediaPaused?aE.MEDIA_PLAY_REQUEST:aE.MEDIA_PAUSE_REQUEST,this.dispatchEvent(new qE.CustomEvent(u,{composed:!0,bubbles:!0}));break;case"m":u="off"===this.mediaStore.getState().mediaVolumeLevel?aE.MEDIA_UNMUTE_REQUEST:aE.MEDIA_MUTE_REQUEST,this.dispatchEvent(new qE.CustomEvent(u,{composed:!0,bubbles:!0}));break;case"f":u=this.mediaStore.getState().mediaIsFullscreen?aE.MEDIA_EXIT_FULLSCREEN_REQUEST:aE.MEDIA_ENTER_FULLSCREEN_REQUEST,this.dispatchEvent(new qE.CustomEvent(u,{composed:!0,bubbles:!0}));break;case"c":this.dispatchEvent(new qE.CustomEvent(aE.MEDIA_TOGGLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0}));break;case"ArrowLeft":case"j":{let e=this.hasAttribute(ZT)?+this.getAttribute(ZT):10;h=Math.max((null!=(a=this.mediaStore.getState().mediaCurrentTime)?a:0)-e,0),c=new qE.CustomEvent(aE.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:h}),this.dispatchEvent(c);break}case"ArrowRight":case"l":{let e=this.hasAttribute(JT)?+this.getAttribute(JT):10;h=Math.max((null!=(n=this.mediaStore.getState().mediaCurrentTime)?n:0)+e,0),c=new qE.CustomEvent(aE.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:h}),this.dispatchEvent(c);break}case"ArrowUp":{let e=this.hasAttribute(tA)?+this.getAttribute(tA):.025;h=Math.min((null!=(s=this.mediaStore.getState().mediaVolume)?s:1)+e,1),c=new qE.CustomEvent(aE.MEDIA_VOLUME_REQUEST,{composed:!0,bubbles:!0,detail:h}),this.dispatchEvent(c);break}case"ArrowDown":{let e=this.hasAttribute(eA)?+this.getAttribute(eA):.025;h=Math.max((null!=(o=this.mediaStore.getState().mediaVolume)?o:1)-e,0),c=new qE.CustomEvent(aE.MEDIA_VOLUME_REQUEST,{composed:!0,bubbles:!0,detail:h}),this.dispatchEvent(c);break}case"<":{let e=null!=(l=this.mediaStore.getState().mediaPlaybackRate)?l:1;h=Math.max(e-.25,.25).toFixed(2),c=new qE.CustomEvent(aE.MEDIA_PLAYBACK_RATE_REQUEST,{composed:!0,bubbles:!0,detail:h}),this.dispatchEvent(c);break}case">":{let e=null!=(d=this.mediaStore.getState().mediaPlaybackRate)?d:1;h=Math.min(e+.25,2).toFixed(2),c=new qE.CustomEvent(aE.MEDIA_PLAYBACK_RATE_REQUEST,{composed:!0,bubbles:!0,detail:h}),this.dispatchEvent(c);break}case"/":case"?":e.shiftKey&&VT(this,aT,nT).call(this);break;case"p":u=this.mediaStore.getState().mediaIsPip?aE.MEDIA_EXIT_PIP_REQUEST:aE.MEDIA_ENTER_PIP_REQUEST,c=new qE.CustomEvent(u,{composed:!0,bubbles:!0}),this.dispatchEvent(c)}}};Kb=new WeakMap,Wb=new WeakMap,Vb=new WeakMap,qb=new WeakMap,Yb=new WeakMap,jb=new WeakMap,zb=new WeakMap,Qb=new WeakMap,Xb=new WeakSet,Zb=function(){var e;this.mediaStore=$T({media:this.media,fullscreenElement:this.fullscreenElement,options:{defaultSubtitles:this.hasAttribute(YT),defaultDuration:this.hasAttribute(zT)?+this.getAttribute(zT):void 0,defaultStreamType:null!=(e=this.getAttribute(jT))?e:void 0,liveEdgeOffset:this.hasAttribute(nA)?+this.getAttribute(nA):void 0,seekToLiveOffset:this.hasAttribute(cA)?+this.getAttribute(cA):this.hasAttribute(nA)?+this.getAttribute(nA):void 0,noAutoSeekToLive:this.hasAttribute(sA),noVolumePref:this.hasAttribute(hA),noMutedPref:this.hasAttribute(dA),noSubtitlesLangPref:this.hasAttribute(uA)}})},Jb=new WeakMap,eT=new WeakSet,tT=function(e){var t;let{metaKey:i,altKey:r,key:a,shiftKey:n}=e,s=n&&("/"===a||"?"===a);if(s&&null!=(t=GT(this,qb))&&t.open)return void this.removeEventListener("keyup",GT(this,Jb));if(i||r||!s&&!qT.includes(a))return void this.removeEventListener("keyup",GT(this,Jb));let o=e.target,l=o instanceof HTMLElement&&("media-volume-range"===o.tagName.toLowerCase()||"media-time-range"===o.tagName.toLowerCase());[" ","ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(a)&&!GT(this,Kb).contains(Rb(a))&&!l&&e.preventDefault(),this.addEventListener("keyup",GT(this,Jb),{once:!0})},iT=new WeakSet,rT=function(){GT(this,qb)&&(GT(this,qb).hotkeys=GT(this,Kb).value||void 0,(this.noHotkeys||GT(this,Kb).contains("noshift+/"))&&(GT(this,qb).open=!1))},aT=new WeakSet,nT=function(){GT(this,qb)||(WT(this,qb,YE.createElement("media-keyboard-shortcuts-dialog")),VT(this,iT,rT).call(this),this.appendChild(GT(this,qb))),GT(this,qb).open=!0};var fA=Object.values(lE),pA=Object.values(sE),gA=e=>{var t,i,r,a;let{observedAttributes:n}=e.constructor;!n&&null!=(t=e.nodeName)&&t.includes("-")&&(qE.customElements.upgrade(e),({observedAttributes:n}=e.constructor));let s=null==(a=null==(r=null==(i=null==e?void 0:e.getAttribute)?void 0:i.call(e,nE.MEDIA_CHROME_ATTRIBUTES))?void 0:r.split)?void 0:a.call(r,/\s+/);return Array.isArray(n||s)?(n||s).filter(e=>fA.includes(e)):[]},vA=e=>(e=>{var t,i;return null!=(t=e.nodeName)&&t.includes("-")&&qE.customElements.get(null==(i=e.nodeName)?void 0:i.toLowerCase())&&!(e instanceof qE.customElements.get(e.nodeName.toLowerCase()))&&qE.customElements.upgrade(e),pA.some(t=>t in e)})(e)||!!gA(e).length,EA=e=>{var t;return null==(t=null==e?void 0:e.join)?void 0:t.call(e,":")},yA={[lE.MEDIA_SUBTITLES_LIST]:uT,[lE.MEDIA_SUBTITLES_SHOWING]:uT,[lE.MEDIA_SEEKABLE]:EA,[lE.MEDIA_BUFFERED]:e=>null==e?void 0:e.map(EA).join(" "),[lE.MEDIA_PREVIEW_COORDS]:e=>null==e?void 0:e.join(" "),[lE.MEDIA_RENDITION_LIST]:function(e){return null==e?void 0:e.map(TE).join(" ")},[lE.MEDIA_AUDIO_TRACK_LIST]:function(e){return null==e?void 0:e.map(_E).join(" ")}},bA=(e,t)=>{if((e=>{var t;return!(null==(t=e.closest)||!t.call(e,'*[slot="media"]'))})(e))return;let i=(e,t)=>{var i,r;vA(e)&&t(e);let{children:a=[]}=null!=e?e:{};[...a,...null!=(r=null==(i=null==e?void 0:e.shadowRoot)?void 0:i.children)?r:[]].forEach(e=>bA(e,t))},r=null==e?void 0:e.nodeName.toLowerCase();!r.includes("-")||vA(e)?i(e,t):qE.customElements.whenDefined(r).then(()=>{i(e,t)})},TA=(e,t,i)=>{e.forEach(e=>{if(t in e)return void(e[t]=i);let r=gA(e),a=t.toLowerCase();r.includes(a)&&(async(e,t,i)=>{var r,a;if(e.isConnected||await LE(0),"boolean"==typeof i||null==i)return fy(e,t,i);if("number"==typeof i)return cy(e,t,i);if("string"==typeof i)return gy(e,t,i);if(Array.isArray(i)&&!i.length)return e.removeAttribute(t);let n=null!=(a=null==(r=yA[t])?void 0:r.call(yA,i))?a:i;e.setAttribute(t,n)})(e,a,i)})},AA=(e,t,i)=>{bA(e,t);let r=e=>{var i;let r=null!=(i=null==e?void 0:e.composedPath()[0])?i:e.target;t(r)},a=e=>{var t;let r=null!=(t=null==e?void 0:e.composedPath()[0])?t:e.target;i(r)};e.addEventListener(aE.REGISTER_MEDIA_STATE_RECEIVER,r),e.addEventListener(aE.UNREGISTER_MEDIA_STATE_RECEIVER,a);let n=[],s=e=>{let r=e.target;"media"!==r.name&&(n.forEach(e=>bA(e,i)),n=[...r.assignedElements({flatten:!0})],n.forEach(e=>bA(e,t)))};e.addEventListener("slotchange",s);let o=new MutationObserver(e=>{e.forEach(e=>{let{addedNodes:r=[],removedNodes:a=[],type:n,target:s,attributeName:o}=e;"childList"===n?(Array.prototype.forEach.call(r,e=>bA(e,t)),Array.prototype.forEach.call(a,e=>bA(e,i))):"attributes"===n&&o===nE.MEDIA_CHROME_ATTRIBUTES&&(vA(s)?t(s):i(s))})});return o.observe(e,{childList:!0,attributes:!0,subtree:!0}),()=>{bA(e,i),e.removeEventListener("slotchange",s),o.disconnect(),e.removeEventListener(aE.REGISTER_MEDIA_STATE_RECEIVER,r),e.removeEventListener(aE.UNREGISTER_MEDIA_STATE_RECEIVER,a)}};qE.customElements.get("media-controller")||qE.customElements.define("media-controller",mA);var _A=mA,SA="placement",kA="bounds";var IA=class extends qE.HTMLElement{constructor(){if(super(),this.updateXOffset=()=>{var e;if(!ly(this,{checkOpacity:!1,checkVisibilityCSS:!1}))return;let t=this.placement;if("left"===t||"right"===t)return void this.style.removeProperty("--media-tooltip-offset-x");let i=getComputedStyle(this),r=null!=(e=ny(this,"#"+this.bounds))?e:ey(this);if(!r)return;let{x:a,width:n}=r.getBoundingClientRect(),{x:s,width:o}=this.getBoundingClientRect(),l=s+o,d=a+n,u=i.getPropertyValue("--media-tooltip-offset-x"),h=u?parseFloat(u.replace("px","")):0,c=i.getPropertyValue("--media-tooltip-container-margin"),m=c?parseFloat(c.replace("px","")):0,f=s-a+h-m,p=l-d+h+m;f<0?this.style.setProperty("--media-tooltip-offset-x",`${f}px`):p>0?this.style.setProperty("--media-tooltip-offset-x",`${p}px`):this.style.removeProperty("--media-tooltip-offset-x")},!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);let e=JE(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e)}if(this.arrowEl=this.shadowRoot.querySelector("#arrow"),Object.prototype.hasOwnProperty.call(this,"placement")){let e=this.placement;delete this.placement,this.placement=e}}static get observedAttributes(){return[SA,kA]}get placement(){return py(this,SA)}set placement(e){gy(this,SA,e)}get bounds(){return py(this,kA)}set bounds(e){gy(this,kA,e)}};IA.shadowRootOptions={mode:"open"},IA.getTemplateHTML=function(e){return'\n    <style>\n      :host {\n        --_tooltip-background-color: var(--media-tooltip-background-color, var(--media-secondary-color, rgba(20, 20, 30, .7)));\n        --_tooltip-background: var(--media-tooltip-background, var(--_tooltip-background-color));\n        --_tooltip-arrow-half-width: calc(var(--media-tooltip-arrow-width, 12px) / 2);\n        --_tooltip-arrow-height: var(--media-tooltip-arrow-height, 5px);\n        --_tooltip-arrow-background: var(--media-tooltip-arrow-color, var(--_tooltip-background-color));\n        position: relative;\n        pointer-events: none;\n        display: var(--media-tooltip-display, inline-flex);\n        justify-content: center;\n        align-items: center;\n        box-sizing: border-box;\n        z-index: var(--media-tooltip-z-index, 1);\n        background: var(--_tooltip-background);\n        color: var(--media-text-color, var(--media-primary-color, rgb(238 238 238)));\n        font: var(--media-font,\n          var(--media-font-weight, 400)\n          var(--media-font-size, 13px) /\n          var(--media-text-content-height, var(--media-control-height, 18px))\n          var(--media-font-family, helvetica neue, segoe ui, roboto, arial, sans-serif));\n        padding: var(--media-tooltip-padding, .35em .7em);\n        border: var(--media-tooltip-border, none);\n        border-radius: var(--media-tooltip-border-radius, 5px);\n        filter: var(--media-tooltip-filter, drop-shadow(0 0 4px rgba(0, 0, 0, .2)));\n        white-space: var(--media-tooltip-white-space, nowrap);\n      }\n\n      :host([hidden]) {\n        display: none;\n      }\n\n      img, svg {\n        display: inline-block;\n      }\n\n      #arrow {\n        position: absolute;\n        width: 0px;\n        height: 0px;\n        border-style: solid;\n        display: var(--media-tooltip-arrow-display, block);\n      }\n\n      :host(:not([placement])),\n      :host([placement="top"]) {\n        position: absolute;\n        bottom: calc(100% + var(--media-tooltip-distance, 12px));\n        left: 50%;\n        transform: translate(calc(-50% - var(--media-tooltip-offset-x, 0px)), 0);\n      }\n      :host(:not([placement])) #arrow,\n      :host([placement="top"]) #arrow {\n        top: 100%;\n        left: 50%;\n        border-width: var(--_tooltip-arrow-height) var(--_tooltip-arrow-half-width) 0 var(--_tooltip-arrow-half-width);\n        border-color: var(--_tooltip-arrow-background) transparent transparent transparent;\n        transform: translate(calc(-50% + var(--media-tooltip-offset-x, 0px)), 0);\n      }\n\n      :host([placement="right"]) {\n        position: absolute;\n        left: calc(100% + var(--media-tooltip-distance, 12px));\n        top: 50%;\n        transform: translate(0, -50%);\n      }\n      :host([placement="right"]) #arrow {\n        top: 50%;\n        right: 100%;\n        border-width: var(--_tooltip-arrow-half-width) var(--_tooltip-arrow-height) var(--_tooltip-arrow-half-width) 0;\n        border-color: transparent var(--_tooltip-arrow-background) transparent transparent;\n        transform: translate(0, -50%);\n      }\n\n      :host([placement="bottom"]) {\n        position: absolute;\n        top: calc(100% + var(--media-tooltip-distance, 12px));\n        left: 50%;\n        transform: translate(calc(-50% - var(--media-tooltip-offset-x, 0px)), 0);\n      }\n      :host([placement="bottom"]) #arrow {\n        bottom: 100%;\n        left: 50%;\n        border-width: 0 var(--_tooltip-arrow-half-width) var(--_tooltip-arrow-height) var(--_tooltip-arrow-half-width);\n        border-color: transparent transparent var(--_tooltip-arrow-background) transparent;\n        transform: translate(calc(-50% + var(--media-tooltip-offset-x, 0px)), 0);\n      }\n\n      :host([placement="left"]) {\n        position: absolute;\n        right: calc(100% + var(--media-tooltip-distance, 12px));\n        top: 50%;\n        transform: translate(0, -50%);\n      }\n      :host([placement="left"]) #arrow {\n        top: 50%;\n        left: 100%;\n        border-width: var(--_tooltip-arrow-half-width) 0 var(--_tooltip-arrow-half-width) var(--_tooltip-arrow-height);\n        border-color: transparent transparent transparent var(--_tooltip-arrow-background);\n        transform: translate(0, -50%);\n      }\n      \n      :host([placement="none"]) #arrow {\n        display: none;\n      }\n    </style>\n    <slot></slot>\n    <div id="arrow"></div>\n  '},qE.customElements.get("media-tooltip")||qE.customElements.define("media-tooltip",IA);var RA,LA,wA,DA,CA,MA,PA,xA,OA,NA=IA,UA=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},FA=(e,t,i)=>(UA(e,t,"read from private field"),i?i.call(e):t.get(e)),BA=(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)},$A=(e,t,i,r)=>(UA(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i),HA=(e,t,i)=>(UA(e,t,"access private method"),i),GA="tooltipplacement",KA="disabled",WA="notooltip";var VA=class extends qE.HTMLElement{constructor(){if(super(),BA(this,wA),BA(this,xA),BA(this,RA,void 0),this.preventClick=!1,this.tooltipEl=null,BA(this,LA,e=>{this.preventClick||this.handleClick(e),setTimeout(FA(this,CA),0)}),BA(this,CA,()=>{var e,t;null==(t=null==(e=this.tooltipEl)?void 0:e.updateXOffset)||t.call(e)}),BA(this,MA,e=>{let{key:t}=e;this.keysUsed.includes(t)?this.preventClick||this.handleClick(e):this.removeEventListener("keyup",FA(this,MA))}),BA(this,PA,e=>{let{metaKey:t,altKey:i,key:r}=e;t||i||!this.keysUsed.includes(r)?this.removeEventListener("keyup",FA(this,MA)):this.addEventListener("keyup",FA(this,MA),{once:!0})}),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);let e=JE(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",GA,nE.MEDIA_CONTROLLER,lE.MEDIA_LANG]}enable(){this.addEventListener("click",FA(this,LA)),this.addEventListener("keydown",FA(this,PA)),this.tabIndex=0}disable(){this.removeEventListener("click",FA(this,LA)),this.removeEventListener("keydown",FA(this,PA)),this.removeEventListener("keyup",FA(this,MA)),this.tabIndex=-1}attributeChangedCallback(e,t,i){var r,a,n,s,o;e===nE.MEDIA_CONTROLLER?(t&&(null==(a=null==(r=FA(this,RA))?void 0:r.unassociateElement)||a.call(r,this),$A(this,RA,null)),i&&this.isConnected&&($A(this,RA,null==(n=this.getRootNode())?void 0:n.getElementById(i)),null==(o=null==(s=FA(this,RA))?void 0:s.associateElement)||o.call(s,this))):"disabled"===e&&i!==t?null==i?this.enable():this.disable():e===GA&&this.tooltipEl&&i!==t?this.tooltipEl.placement=i:e===lE.MEDIA_LANG&&(this.shadowRoot.querySelector('slot[name="tooltip-content"]').innerHTML=this.constructor.getTooltipContentHTML()),HA(this,wA,DA).call(this)&&FA(this,CA).call(this)}connectedCallback(){var e,t,i;let{style:r}=dy(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 a=this.getAttribute(nE.MEDIA_CONTROLLER);a&&($A(this,RA,null==(e=this.getRootNode())?void 0:e.getElementById(a)),null==(i=null==(t=FA(this,RA))?void 0:t.associateElement)||i.call(t,this)),qE.customElements.whenDefined("media-tooltip").then(()=>HA(this,xA,OA).call(this))}disconnectedCallback(){var e,t;this.disable(),null==(t=null==(e=FA(this,RA))?void 0:e.unassociateElement)||t.call(e,this),$A(this,RA,null),this.removeEventListener("mouseenter",FA(this,CA)),this.removeEventListener("focus",FA(this,CA)),this.removeEventListener("click",FA(this,LA))}get keysUsed(){return["Enter"," "]}get tooltipPlacement(){return py(this,GA)}set tooltipPlacement(e){gy(this,GA,e)}get mediaController(){return py(this,nE.MEDIA_CONTROLLER)}set mediaController(e){gy(this,nE.MEDIA_CONTROLLER,e)}get disabled(){return my(this,KA)}set disabled(e){fy(this,KA,e)}get noTooltip(){return my(this,WA)}set noTooltip(e){fy(this,WA,e)}handleClick(e){}};RA=new WeakMap,LA=new WeakMap,wA=new WeakSet,DA=function(){try{return this.matches(":hover, :focus-visible")}catch{return this.matches(":hover, :focus")}},CA=new WeakMap,MA=new WeakMap,PA=new WeakMap,xA=new WeakSet,OA=function(){this.addEventListener("mouseenter",FA(this,CA)),this.addEventListener("focus",FA(this,CA)),this.addEventListener("click",FA(this,LA));let e=this.tooltipPlacement;e&&this.tooltipEl&&(this.tooltipEl.placement=e)},VA.shadowRootOptions={mode:"open"},VA.getTemplateHTML=function(e,t={}){return`\n    <style>\n      :host {\n        position: relative;\n        font: var(--media-font,\n          var(--media-font-weight, bold)\n          var(--media-font-size, 14px) /\n          var(--media-text-content-height, var(--media-control-height, 24px))\n          var(--media-font-family, helvetica neue, segoe ui, roboto, arial, sans-serif));\n        color: var(--media-text-color, var(--media-primary-color, rgb(238 238 238)));\n        background: var(--media-control-background, var(--media-secondary-color, rgb(20 20 30 / .7)));\n        padding: var(--media-button-padding, var(--media-control-padding, 10px));\n        justify-content: var(--media-button-justify-content, center);\n        display: inline-flex;\n        align-items: center;\n        vertical-align: middle;\n        box-sizing: border-box;\n        transition: background .15s linear;\n        pointer-events: auto;\n        cursor: var(--media-cursor, pointer);\n        -webkit-tap-highlight-color: transparent;\n      }\n\n      \n      :host(:focus-visible) {\n        box-shadow: var(--media-focus-box-shadow, inset 0 0 0 2px rgb(27 127 204 / .9));\n        outline: 0;\n      }\n      \n      :host(:where(:focus)) {\n        box-shadow: none;\n        outline: 0;\n      }\n\n      :host(:hover) {\n        background: var(--media-control-hover-background, rgba(50 50 70 / .7));\n      }\n\n      slot[name="icon"] {\n        display: inline-flex;\n        align-items: center;\n      }\n\n      svg, img, ::slotted(svg), ::slotted(img) {\n        width: var(--media-button-icon-width);\n        height: var(--media-button-icon-height, var(--media-control-height, 24px));\n        transform: var(--media-button-icon-transform);\n        transition: var(--media-button-icon-transition);\n        fill: var(--media-icon-color, var(--media-primary-color, rgb(238 238 238)));\n        vertical-align: middle;\n        max-width: 100%;\n        max-height: 100%;\n        min-width: 100%;\n      }\n\n      media-tooltip {\n        \n        max-width: 0;\n        overflow-x: clip;\n        opacity: 0;\n        transition: opacity .3s, max-width 0s 9s;\n      }\n\n      :host(:hover) media-tooltip,\n      :host(:focus-visible) media-tooltip {\n        max-width: 100vw;\n        opacity: 1;\n        transition: opacity .3s;\n      }\n\n      :host([notooltip]) slot[name="tooltip"] {\n        display: none;\n      }\n    </style>\n\n    ${this.getSlotTemplateHTML(e,t)}\n\n    <slot name="tooltip">\n      <media-tooltip part="tooltip" aria-hidden="true">\n        <template shadowrootmode="${NA.shadowRootOptions.mode}">\n          ${NA.getTemplateHTML({})}\n        </template>\n        <slot name="tooltip-content">\n          ${this.getTooltipContentHTML(e)}\n        </slot>\n      </media-tooltip>\n    </slot>\n  `},VA.getSlotTemplateHTML=function(e,t){return"\n    <slot></slot>\n  "},VA.getTooltipContentHTML=function(){return""},qE.customElements.get("media-chrome-button")||qE.customElements.define("media-chrome-button",VA);var qA='<svg aria-hidden="true" viewBox="0 0 26 24">\n  <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"/>\n</svg>\n';var YA=e=>{let t=e.mediaIsAirplaying?xE("stop airplay"):xE("start airplay");e.setAttribute("aria-label",t)},jA=class extends VA{static get observedAttributes(){return[...super.observedAttributes,lE.MEDIA_IS_AIRPLAYING,lE.MEDIA_AIRPLAY_UNAVAILABLE]}connectedCallback(){super.connectedCallback(),YA(this)}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===lE.MEDIA_IS_AIRPLAYING&&YA(this)}get mediaIsAirplaying(){return my(this,lE.MEDIA_IS_AIRPLAYING)}set mediaIsAirplaying(e){fy(this,lE.MEDIA_IS_AIRPLAYING,e)}get mediaAirplayUnavailable(){return py(this,lE.MEDIA_AIRPLAY_UNAVAILABLE)}set mediaAirplayUnavailable(e){gy(this,lE.MEDIA_AIRPLAY_UNAVAILABLE,e)}handleClick(){let e=new qE.CustomEvent(aE.MEDIA_AIRPLAY_REQUEST,{composed:!0,bubbles:!0});this.dispatchEvent(e)}};jA.getSlotTemplateHTML=function(e){return`\n    <style>\n      :host([${lE.MEDIA_IS_AIRPLAYING}]) slot[name=icon] slot:not([name=exit]) {\n        display: none !important;\n      }\n\n      \n      :host(:not([${lE.MEDIA_IS_AIRPLAYING}])) slot[name=icon] slot:not([name=enter]) {\n        display: none !important;\n      }\n\n      :host([${lE.MEDIA_IS_AIRPLAYING}]) slot[name=tooltip-enter],\n      :host(:not([${lE.MEDIA_IS_AIRPLAYING}])) slot[name=tooltip-exit] {\n        display: none;\n      }\n    </style>\n\n    <slot name="icon">\n      <slot name="enter">${qA}</slot>\n      <slot name="exit">${qA}</slot>\n    </slot>\n  `},jA.getTooltipContentHTML=function(){return`\n    <slot name="tooltip-enter">${xE("start airplay")}</slot>\n    <slot name="tooltip-exit">${xE("stop airplay")}</slot>\n  `},qE.customElements.get("media-airplay-button")||qE.customElements.define("media-airplay-button",jA);var zA=e=>{e.setAttribute("aria-checked",fT(e).toString())},QA=class extends VA{static get observedAttributes(){return[...super.observedAttributes,lE.MEDIA_SUBTITLES_LIST,lE.MEDIA_SUBTITLES_SHOWING]}connectedCallback(){super.connectedCallback(),this.setAttribute("role","button"),this.setAttribute("aria-label",xE("closed captions")),zA(this)}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===lE.MEDIA_SUBTITLES_SHOWING&&zA(this)}get mediaSubtitlesList(){return XA(this,lE.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){ZA(this,lE.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return XA(this,lE.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){ZA(this,lE.MEDIA_SUBTITLES_SHOWING,e)}handleClick(){this.dispatchEvent(new qE.CustomEvent(aE.MEDIA_TOGGLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0}))}};QA.getSlotTemplateHTML=function(e){return'\n    <style>\n      :host([aria-checked="true"]) slot[name=off] {\n        display: none !important;\n      }\n\n      \n      :host(:not([aria-checked="true"])) slot[name=on] {\n        display: none !important;\n      }\n\n      :host([aria-checked="true"]) slot[name=tooltip-enable],\n      :host(:not([aria-checked="true"])) slot[name=tooltip-disable] {\n        display: none;\n      }\n    </style>\n\n    <slot name="icon">\n      <slot name="on"><svg aria-hidden="true" viewBox="0 0 26 24">\n  <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 0 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"/>\n</svg></slot>\n      <slot name="off"><svg aria-hidden="true" viewBox="0 0 26 24">\n  <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"/>\n</svg></slot>\n    </slot>\n  '},QA.getTooltipContentHTML=function(){return`\n    <slot name="tooltip-enable">${xE("Enable captions")}</slot>\n    <slot name="tooltip-disable">${xE("Disable captions")}</slot>\n  `};var XA=(e,t)=>{let i=e.getAttribute(t);return i?oT(i):[]},ZA=(e,t,i)=>{if(null==i||!i.length)return void e.removeAttribute(t);let r=uT(i);e.getAttribute(t)!==r&&e.setAttribute(t,r)};qE.customElements.get("media-captions-button")||qE.customElements.define("media-captions-button",QA);var JA=e=>{let t=e.mediaIsCasting?xE("stop casting"):xE("start casting");e.setAttribute("aria-label",t)},e_=class extends VA{static get observedAttributes(){return[...super.observedAttributes,lE.MEDIA_IS_CASTING,lE.MEDIA_CAST_UNAVAILABLE]}connectedCallback(){super.connectedCallback(),JA(this)}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===lE.MEDIA_IS_CASTING&&JA(this)}get mediaIsCasting(){return my(this,lE.MEDIA_IS_CASTING)}set mediaIsCasting(e){fy(this,lE.MEDIA_IS_CASTING,e)}get mediaCastUnavailable(){return py(this,lE.MEDIA_CAST_UNAVAILABLE)}set mediaCastUnavailable(e){gy(this,lE.MEDIA_CAST_UNAVAILABLE,e)}handleClick(){let e=this.mediaIsCasting?aE.MEDIA_EXIT_CAST_REQUEST:aE.MEDIA_ENTER_CAST_REQUEST;this.dispatchEvent(new qE.CustomEvent(e,{composed:!0,bubbles:!0}))}};e_.getSlotTemplateHTML=function(e){return`\n    <style>\n      :host([${lE.MEDIA_IS_CASTING}]) slot[name=icon] slot:not([name=exit]) {\n        display: none !important;\n      }\n\n      \n      :host(:not([${lE.MEDIA_IS_CASTING}])) slot[name=icon] slot:not([name=enter]) {\n        display: none !important;\n      }\n\n      :host([${lE.MEDIA_IS_CASTING}]) slot[name=tooltip-enter],\n      :host(:not([${lE.MEDIA_IS_CASTING}])) slot[name=tooltip-exit] {\n        display: none;\n      }\n    </style>\n\n    <slot name="icon">\n      <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>\n      <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>\n    </slot>\n  `},e_.getTooltipContentHTML=function(){return`\n    <slot name="tooltip-enter">${xE("Start casting")}</slot>\n    <slot name="tooltip-exit">${xE("Stop casting")}</slot>\n  `},qE.customElements.get("media-cast-button")||qE.customElements.define("media-cast-button",e_);var t_,i_,r_,a_,n_,s_,o_,l_,d_,u_,h_,c_,m_,f_,p_,g_,v_,E_,y_,b_,T_,A_,__,S_,k_,I_=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},R_=(e,t,i)=>(I_(e,t,"read from private field"),i?i.call(e):t.get(e)),L_=(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)},w_=(e,t,i,r)=>(I_(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i),D_=(e,t,i)=>(I_(e,t,"access private method"),i);var C_=class extends qE.HTMLElement{constructor(){if(super(),L_(this,u_),L_(this,c_),L_(this,f_),L_(this,g_),L_(this,E_),L_(this,b_),L_(this,A_),L_(this,S_),L_(this,t_,void 0),L_(this,i_,void 0),L_(this,r_,void 0),L_(this,a_,void 0),L_(this,n_,{}),L_(this,s_,[]),L_(this,o_,()=>{if(this.range.matches(":focus-visible")){let{style:e}=dy(this.shadowRoot,":host");e.setProperty("--_focus-visible-box-shadow","var(--_focus-box-shadow)")}}),L_(this,l_,()=>{let{style:e}=dy(this.shadowRoot,":host");e.removeProperty("--_focus-visible-box-shadow")}),L_(this,d_,()=>{let e=this.shadowRoot.querySelector("#segments-clipping");e&&e.parentNode.append(e)}),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);let e=JE(this.attributes),t=this.constructor.getTemplateHTML(e);this.shadowRoot.setHTMLUnsafe?this.shadowRoot.setHTMLUnsafe(t):this.shadowRoot.innerHTML=t}this.container=this.shadowRoot.querySelector("#container"),w_(this,r_,this.shadowRoot.querySelector("#startpoint")),w_(this,a_,this.shadowRoot.querySelector("#endpoint")),this.range=this.shadowRoot.querySelector("#range"),this.appearance=this.shadowRoot.querySelector("#appearance")}static get observedAttributes(){return["disabled","aria-disabled",nE.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,i){var r,a,n,s,o;e===nE.MEDIA_CONTROLLER?(t&&(null==(a=null==(r=R_(this,t_))?void 0:r.unassociateElement)||a.call(r,this),w_(this,t_,null)),i&&this.isConnected&&(w_(this,t_,null==(n=this.getRootNode())?void 0:n.getElementById(i)),null==(o=null==(s=R_(this,t_))?void 0:s.associateElement)||o.call(s,this))):("disabled"===e||"aria-disabled"===e&&t!==i)&&(null==i?(this.range.removeAttribute(e),D_(this,c_,m_).call(this)):(this.range.setAttribute(e,i),D_(this,f_,p_).call(this)))}connectedCallback(){var e,t,i;let{style:r}=dy(this.shadowRoot,":host");r.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`),R_(this,n_).pointer=dy(this.shadowRoot,"#pointer"),R_(this,n_).progress=dy(this.shadowRoot,"#progress"),R_(this,n_).thumb=dy(this.shadowRoot,'#thumb, ::slotted([slot="thumb"])'),R_(this,n_).activeSegment=dy(this.shadowRoot,"#segments-clipping rect:nth-child(0)");let a=this.getAttribute(nE.MEDIA_CONTROLLER);a&&(w_(this,t_,null==(e=this.getRootNode())?void 0:e.getElementById(a)),null==(i=null==(t=R_(this,t_))?void 0:t.associateElement)||i.call(t,this)),this.updateBar(),this.shadowRoot.addEventListener("focusin",R_(this,o_)),this.shadowRoot.addEventListener("focusout",R_(this,l_)),D_(this,c_,m_).call(this),XE(this.container,R_(this,d_))}disconnectedCallback(){var e,t;D_(this,f_,p_).call(this),null==(t=null==(e=R_(this,t_))?void 0:e.unassociateElement)||t.call(e,this),w_(this,t_,null),this.shadowRoot.removeEventListener("focusin",R_(this,o_)),this.shadowRoot.removeEventListener("focusout",R_(this,l_)),ZE(this.container,R_(this,d_))}updatePointerBar(e){var t;null==(t=R_(this,n_).pointer)||t.style.setProperty("width",100*this.getPointerRatio(e)+"%")}updateBar(){var e,t;let i=100*this.range.valueAsNumber;null==(e=R_(this,n_).progress)||e.style.setProperty("width",`${i}%`),null==(t=R_(this,n_).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||!e.length)),null==e||!e.length)return;let i=[...new Set([+this.range.min,...e.flatMap(e=>[e.start,e.end]),+this.range.max])];w_(this,s_,[...i]);let r=i.pop();for(let[e,a]of i.entries()){let[n,s]=[0===e,e===i.length-1],o=n?"calc(var(--segments-gap) / -1)":100*a+"%",l=`calc(${100*((s?r:i[e+1])-a)}%${n||s?"":" - var(--segments-gap)"})`,d=YE.createElementNS("http://www.w3.org/2000/svg","rect"),u=uy(this.shadowRoot,`#segments-clipping rect:nth-child(${e+1})`);u.style.setProperty("x",o),u.style.setProperty("width",l),t.append(d)}}getPointerRatio(e){return function(e,t,i,r){let a=r.x-i.x,n=r.y-i.y,s=a*a+n*n;if(0===s)return 0;let o=((e-i.x)*a+(t-i.y)*n)/s;return Math.max(0,Math.min(1,o))}(e.clientX,e.clientY,R_(this,r_).getBoundingClientRect(),R_(this,a_).getBoundingClientRect())}get dragging(){return this.hasAttribute("dragging")}handleEvent(e){switch(e.type){case"pointermove":D_(this,S_,k_).call(this,e);break;case"input":this.updateBar();break;case"pointerenter":D_(this,E_,y_).call(this,e);break;case"pointerdown":D_(this,g_,v_).call(this,e);break;case"pointerup":D_(this,b_,T_).call(this);break;case"pointerleave":D_(this,A_,__).call(this)}}get keysUsed(){return["ArrowUp","ArrowRight","ArrowDown","ArrowLeft"]}};t_=new WeakMap,i_=new WeakMap,r_=new WeakMap,a_=new WeakMap,n_=new WeakMap,s_=new WeakMap,o_=new WeakMap,l_=new WeakMap,d_=new WeakMap,u_=new WeakSet,h_=function(e){let t=R_(this,n_).activeSegment;if(!t)return;let i=this.getPointerRatio(e),r=`#segments-clipping rect:nth-child(${R_(this,s_).findIndex((e,t,r)=>{let a=r[t+1];return null!=a&&i>=e&&i<=a})+1})`;(t.selectorText!=r||!t.style.transform)&&(t.selectorText=r,t.style.setProperty("transform","var(--media-range-segment-hover-transform, scaleY(2))"))},c_=new WeakSet,m_=function(){this.hasAttribute("disabled")||!this.isConnected||(this.addEventListener("input",this),this.addEventListener("pointerdown",this),this.addEventListener("pointerenter",this))},f_=new WeakSet,p_=function(){var e,t;this.removeEventListener("input",this),this.removeEventListener("pointerdown",this),this.removeEventListener("pointerenter",this),this.removeEventListener("pointerleave",this),null==(e=qE.window)||e.removeEventListener("pointerup",this),null==(t=qE.window)||t.removeEventListener("pointermove",this)},g_=new WeakSet,v_=function(e){var t;w_(this,i_,e.composedPath().includes(this.range)),null==(t=qE.window)||t.addEventListener("pointerup",this,{once:!0})},E_=new WeakSet,y_=function(e){var t;"mouse"!==e.pointerType&&D_(this,g_,v_).call(this,e),this.addEventListener("pointerleave",this,{once:!0}),null==(t=qE.window)||t.addEventListener("pointermove",this)},b_=new WeakSet,T_=function(){var e;null==(e=qE.window)||e.removeEventListener("pointerup",this),this.toggleAttribute("dragging",!1),this.range.disabled=this.hasAttribute("disabled")},A_=new WeakSet,__=function(){var e,t;this.removeEventListener("pointerleave",this),null==(e=qE.window)||e.removeEventListener("pointermove",this),this.toggleAttribute("dragging",!1),this.range.disabled=this.hasAttribute("disabled"),null==(t=R_(this,n_).activeSegment)||t.style.removeProperty("transform")},S_=new WeakSet,k_=function(e){"pen"===e.pointerType&&0===e.buttons||(this.toggleAttribute("dragging",1===e.buttons||"mouse"!==e.pointerType),this.updatePointerBar(e),D_(this,u_,h_).call(this,e),this.dragging&&("mouse"!==e.pointerType||!R_(this,i_))&&(this.range.disabled=!0,this.range.valueAsNumber=this.getPointerRatio(e),this.range.dispatchEvent(new Event("input",{bubbles:!0,composed:!0}))))},C_.shadowRootOptions={mode:"open"},C_.getTemplateHTML=function(e){return`\n    <style>\n      :host {\n        --_focus-box-shadow: var(--media-focus-box-shadow, inset 0 0 0 2px rgb(27 127 204 / .9));\n        --_media-range-padding: var(--media-range-padding, var(--media-control-padding, 10px));\n\n        box-shadow: var(--_focus-visible-box-shadow, none);\n        background: var(--media-control-background, var(--media-secondary-color, rgb(20 20 30 / .7)));\n        height: calc(var(--media-control-height, 24px) + 2 * var(--_media-range-padding));\n        display: inline-flex;\n        align-items: center;\n        \n        vertical-align: middle;\n        box-sizing: border-box;\n        position: relative;\n        width: 100px;\n        transition: background .15s linear;\n        cursor: var(--media-cursor, pointer);\n        pointer-events: auto;\n        touch-action: none; \n      }\n\n      \n      input[type=range]:focus {\n        outline: 0;\n      }\n      input[type=range]:focus::-webkit-slider-runnable-track {\n        outline: 0;\n      }\n\n      :host(:hover) {\n        background: var(--media-control-hover-background, rgb(50 50 70 / .7));\n      }\n\n      #leftgap {\n        padding-left: var(--media-range-padding-left, var(--_media-range-padding));\n      }\n\n      #rightgap {\n        padding-right: var(--media-range-padding-right, var(--_media-range-padding));\n      }\n\n      #startpoint,\n      #endpoint {\n        position: absolute;\n      }\n\n      #endpoint {\n        right: 0;\n      }\n\n      #container {\n        \n        width: var(--media-range-track-width, 100%);\n        transform: translate(var(--media-range-track-translate-x, 0px), var(--media-range-track-translate-y, 0px));\n        position: relative;\n        height: 100%;\n        display: flex;\n        align-items: center;\n        min-width: 40px;\n      }\n\n      #range {\n        \n        display: var(--media-time-range-hover-display, block);\n        bottom: var(--media-time-range-hover-bottom, 0);\n        height: var(--media-time-range-hover-height, max(100% , 25px));\n        width: 100%;\n        position: absolute;\n        cursor: var(--media-cursor, pointer);\n\n        -webkit-appearance: none; \n        -webkit-tap-highlight-color: transparent;\n        background: transparent; \n        margin: 0;\n        z-index: 1;\n      }\n\n      @media (hover: hover) {\n        #range {\n          bottom: var(--media-time-range-hover-bottom, 0);\n          height: var(--media-time-range-hover-height, max(100%, 20px));\n        }\n      }\n\n      \n      \n      #range::-webkit-slider-thumb {\n        -webkit-appearance: none;\n        background: transparent;\n        width: .1px;\n        height: .1px;\n      }\n\n      \n      #range::-moz-range-thumb {\n        background: transparent;\n        border: transparent;\n        width: .1px;\n        height: .1px;\n      }\n\n      #appearance {\n        height: var(--media-range-track-height, 4px);\n        display: flex;\n        flex-direction: column;\n        justify-content: center;\n        width: 100%;\n        position: absolute;\n        \n        will-change: transform;\n      }\n\n      #track {\n        background: var(--media-range-track-background, rgb(255 255 255 / .2));\n        border-radius: var(--media-range-track-border-radius, 1px);\n        border: var(--media-range-track-border, none);\n        outline: var(--media-range-track-outline);\n        outline-offset: var(--media-range-track-outline-offset);\n        backdrop-filter: var(--media-range-track-backdrop-filter);\n        -webkit-backdrop-filter: var(--media-range-track-backdrop-filter);\n        box-shadow: var(--media-range-track-box-shadow, none);\n        position: absolute;\n        width: 100%;\n        height: 100%;\n        overflow: hidden;\n      }\n\n      #progress,\n      #pointer {\n        position: absolute;\n        height: 100%;\n        will-change: width;\n      }\n\n      #progress {\n        background: var(--media-range-bar-color, var(--media-primary-color, rgb(238 238 238)));\n        transition: var(--media-range-track-transition);\n      }\n\n      #pointer {\n        background: var(--media-range-track-pointer-background);\n        border-right: var(--media-range-track-pointer-border-right);\n        transition: visibility .25s, opacity .25s;\n        visibility: hidden;\n        opacity: 0;\n      }\n\n      @media (hover: hover) {\n        :host(:hover) #pointer {\n          transition: visibility .5s, opacity .5s;\n          visibility: visible;\n          opacity: 1;\n        }\n      }\n\n      #thumb,\n      ::slotted([slot=thumb]) {\n        width: var(--media-range-thumb-width, 10px);\n        height: var(--media-range-thumb-height, 10px);\n        transition: var(--media-range-thumb-transition);\n        transform: var(--media-range-thumb-transform, none);\n        opacity: var(--media-range-thumb-opacity, 1);\n        translate: -50%;\n        position: absolute;\n        left: 0;\n        cursor: var(--media-cursor, pointer);\n      }\n\n      #thumb {\n        border-radius: var(--media-range-thumb-border-radius, 10px);\n        background: var(--media-range-thumb-background, var(--media-primary-color, rgb(238 238 238)));\n        box-shadow: var(--media-range-thumb-box-shadow, 1px 1px 1px transparent);\n        border: var(--media-range-thumb-border, none);\n      }\n\n      :host([disabled]) #thumb {\n        background-color: #777;\n      }\n\n      .segments #appearance {\n        height: var(--media-range-segment-hover-height, 7px);\n      }\n\n      #track {\n        clip-path: url(#segments-clipping);\n      }\n\n      #segments {\n        --segments-gap: var(--media-range-segments-gap, 2px);\n        position: absolute;\n        width: 100%;\n        height: 100%;\n      }\n\n      #segments-clipping {\n        transform: translateX(calc(var(--segments-gap) / 2));\n      }\n\n      #segments-clipping:empty {\n        display: none;\n      }\n\n      #segments-clipping rect {\n        height: var(--media-range-track-height, 4px);\n        y: calc((var(--media-range-segment-hover-height, 7px) - var(--media-range-track-height, 4px)) / 2);\n        transition: var(--media-range-segment-transition, transform .1s ease-in-out);\n        transform: var(--media-range-segment-transform, scaleY(1));\n        transform-origin: center;\n      }\n\n      /* Visible label for accessibility - positioned off-screen but technically visible (Firefox requires visible labels) */\n      #range-label {\n        position: absolute;\n        left: -10000px;\n        background: var(--media-control-background, var(--media-secondary-color, rgb(20 20 30 / .7)));\n        pointer-events: none;\n      }\n    </style>\n    <div id="leftgap"></div>\n    <div id="container">\n      <div id="startpoint"></div>\n      <div id="endpoint"></div>\n      <div id="appearance">\n        <div id="track" part="track">\n          <div id="pointer"></div>\n          <div id="progress" part="progress"></div>\n        </div>\n        <slot name="thumb">\n          <div id="thumb" part="thumb"></div>\n        </slot>\n        <svg id="segments" aria-hidden="true"><clipPath id="segments-clipping"></clipPath></svg>\n      </div>\n        <input id="range" type="range" min="0" max="1" step="any" value="0">\n        <label for="range" id="range-label"></label>\n\n      ${this.getContainerTemplateHTML(e)}\n    </div>\n    <div id="rightgap"></div>\n  `},C_.getContainerTemplateHTML=function(e){return""},qE.customElements.get("media-chrome-range")||qE.customElements.define("media-chrome-range",C_);var M_,P_=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},x_=(e,t,i)=>(P_(e,t,"read from private field"),i?i.call(e):t.get(e)),O_=(e,t,i,r)=>(P_(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i);var N_=class extends qE.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,M_,void 0),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);let e=JE(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e)}}static get observedAttributes(){return[nE.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,i){var r,a,n,s,o;e===nE.MEDIA_CONTROLLER&&(t&&(null==(a=null==(r=x_(this,M_))?void 0:r.unassociateElement)||a.call(r,this),O_(this,M_,null)),i&&this.isConnected&&(O_(this,M_,null==(n=this.getRootNode())?void 0:n.getElementById(i)),null==(o=null==(s=x_(this,M_))?void 0:s.associateElement)||o.call(s,this)))}connectedCallback(){var e,t,i;let r=this.getAttribute(nE.MEDIA_CONTROLLER);r&&(O_(this,M_,null==(e=this.getRootNode())?void 0:e.getElementById(r)),null==(i=null==(t=x_(this,M_))?void 0:t.associateElement)||i.call(t,this))}disconnectedCallback(){var e,t;null==(t=null==(e=x_(this,M_))?void 0:e.unassociateElement)||t.call(e,this),O_(this,M_,null)}};M_=new WeakMap,N_.shadowRootOptions={mode:"open"},N_.getTemplateHTML=function(e){return'\n    <style>\n      :host {\n        \n        box-sizing: border-box;\n        display: var(--media-control-display, var(--media-control-bar-display, inline-flex));\n        color: var(--media-text-color, var(--media-primary-color, rgb(238 238 238)));\n        --media-loading-indicator-icon-height: 44px;\n      }\n\n      ::slotted(media-time-range),\n      ::slotted(media-volume-range) {\n        min-height: 100%;\n      }\n\n      ::slotted(media-time-range),\n      ::slotted(media-clip-selector) {\n        flex-grow: 1;\n      }\n\n      ::slotted([role="menu"]) {\n        position: absolute;\n      }\n    </style>\n\n    <slot></slot>\n  '},qE.customElements.get("media-control-bar")||qE.customElements.define("media-control-bar",N_);var U_,F_=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},B_=(e,t,i)=>(F_(e,t,"read from private field"),i?i.call(e):t.get(e)),$_=(e,t,i,r)=>(F_(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i);var H_=class extends qE.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,U_,void 0),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);let e=JE(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e)}}static get observedAttributes(){return[nE.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,i){var r,a,n,s,o;e===nE.MEDIA_CONTROLLER&&(t&&(null==(a=null==(r=B_(this,U_))?void 0:r.unassociateElement)||a.call(r,this),$_(this,U_,null)),i&&this.isConnected&&($_(this,U_,null==(n=this.getRootNode())?void 0:n.getElementById(i)),null==(o=null==(s=B_(this,U_))?void 0:s.associateElement)||o.call(s,this)))}connectedCallback(){var e,t,i;let{style:r}=dy(this.shadowRoot,":host");r.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`);let a=this.getAttribute(nE.MEDIA_CONTROLLER);a&&($_(this,U_,null==(e=this.getRootNode())?void 0:e.getElementById(a)),null==(i=null==(t=B_(this,U_))?void 0:t.associateElement)||i.call(t,this))}disconnectedCallback(){var e,t;null==(t=null==(e=B_(this,U_))?void 0:e.unassociateElement)||t.call(e,this),$_(this,U_,null)}};U_=new WeakMap,H_.shadowRootOptions={mode:"open"},H_.getTemplateHTML=function(e,t={}){return`\n    <style>\n      :host {\n        font: var(--media-font,\n          var(--media-font-weight, normal)\n          var(--media-font-size, 14px) /\n          var(--media-text-content-height, var(--media-control-height, 24px))\n          var(--media-font-family, helvetica neue, segoe ui, roboto, arial, sans-serif));\n        color: var(--media-text-color, var(--media-primary-color, rgb(238 238 238)));\n        background: var(--media-text-background, var(--media-control-background, var(--media-secondary-color, rgb(20 20 30 / .7))));\n        padding: var(--media-control-padding, 10px);\n        display: inline-flex;\n        justify-content: center;\n        align-items: center;\n        vertical-align: middle;\n        box-sizing: border-box;\n        text-align: center;\n        pointer-events: auto;\n      }\n\n      \n      :host(:focus-visible) {\n        box-shadow: var(--media-focus-box-shadow, inset 0 0 0 2px rgb(27 127 204 / .9));\n        outline: 0;\n      }\n\n      \n      :host(:where(:focus)) {\n        box-shadow: none;\n        outline: 0;\n      }\n    </style>\n\n    ${this.getSlotTemplateHTML(e,t)}\n  `},H_.getSlotTemplateHTML=function(e,t){return"\n    <slot></slot>\n  "},qE.customElements.get("media-text-display")||qE.customElements.define("media-text-display",H_);var G_,K_=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},W_=(e,t,i)=>(K_(e,t,"read from private field"),i?i.call(e):t.get(e));var V_=class extends H_{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,G_,void 0),((e,t,i,r)=>{K_(e,t,"write to private field"),r?r.call(e,i):t.set(e,i)})(this,G_,this.shadowRoot.querySelector("slot")),W_(this,G_).textContent=FE(null!=(e=this.mediaDuration)?e:0)}static get observedAttributes(){return[...super.observedAttributes,lE.MEDIA_DURATION]}attributeChangedCallback(e,t,i){e===lE.MEDIA_DURATION&&(W_(this,G_).textContent=FE(+i)),super.attributeChangedCallback(e,t,i)}get mediaDuration(){return hy(this,lE.MEDIA_DURATION)}set mediaDuration(e){cy(this,lE.MEDIA_DURATION,e)}};G_=new WeakMap,V_.getSlotTemplateHTML=function(e,t){return`\n    <slot>${FE(t.mediaDuration)}</slot>\n  `},qE.customElements.get("media-duration-display")||qE.customElements.define("media-duration-display",V_);var q_,Y_={2:xE("Network Error"),3:xE("Decode Error"),4:xE("Source Not Supported"),5:xE("Encryption Error")},j_={2:xE("A network error caused the media download to fail."),3:xE("A media error caused playback to be aborted. The media could be corrupt or your browser does not support this format."),4:xE("An unsupported error occurred. The server or network failed, or your browser does not support this format."),5:xE("The media is encrypted and there are no keys to decrypt it.")},z_=e=>{var t,i;return 1===e.code?null:{title:null!=(t=Y_[e.code])?t:`Error ${e.code}`,message:null!=(i=j_[e.code])?i:e.message}},Q_=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)};function X_(e){var t;let{title:i,message:r}=null!=(t=z_(e))?t:{},a=DE(e.code),n="";return i&&(n+=`<slot name="error-${a}-title"><h3>${DE(i)}</h3></slot>`),r&&(n+=`<slot name="error-${a}-message"><p>${DE(r)}</p></slot>`),n}var Z_=[lE.MEDIA_ERROR_CODE,lE.MEDIA_ERROR_MESSAGE],J_=class extends bb{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,q_,null)}static get observedAttributes(){return[...super.observedAttributes,...Z_]}formatErrorMessage(e){return this.constructor.formatErrorMessage(e)}attributeChangedCallback(e,t,i){var r;if(super.attributeChangedCallback(e,t,i),!Z_.includes(e))return;let a=null!=(r=this.mediaError)?r:{code:this.mediaErrorCode,message:this.mediaErrorMessage};if(this.open=function(e){return e.code&&null!==z_(e)}(a),this.open&&(this.shadowRoot.querySelector("slot").name=`error-${this.mediaErrorCode}`,this.shadowRoot.querySelector("#content").innerHTML=this.formatErrorMessage(a),!this.hasAttribute("aria-label"))){let{title:e}=z_(a);e&&this.setAttribute("aria-label",e)}}get mediaError(){return((e,t,i)=>(Q_(e,t,"read from private field"),i?i.call(e):t.get(e)))(this,q_)}set mediaError(e){((e,t,i,r)=>{Q_(e,t,"write to private field"),r?r.call(e,i):t.set(e,i)})(this,q_,e)}get mediaErrorCode(){return hy(this,"mediaerrorcode")}set mediaErrorCode(e){cy(this,"mediaerrorcode",e)}get mediaErrorMessage(){return py(this,"mediaerrormessage")}set mediaErrorMessage(e){gy(this,"mediaerrormessage",e)}};q_=new WeakMap,J_.getSlotTemplateHTML=function(e){let t=+e.mediaerrorcode;return`\n    <style>\n      :host {\n        background: rgb(20 20 30 / .8);\n      }\n\n      #content {\n        display: block;\n        padding: 1.2em 1.5em;\n      }\n\n      h3,\n      p {\n        margin-block: 0 .3em;\n      }\n    </style>\n    <slot name="error-${t}" id="content">\n      ${X_({code:t,message:e.mediaerrormessage})}\n    </slot>\n  `},J_.formatErrorMessage=X_,qE.customElements.get("media-error-dialog")||qE.customElements.define("media-error-dialog",J_);var eS,tS=J_,iS=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)};var rS=e=>{let t=e.mediaIsFullscreen?xE("exit fullscreen mode"):xE("enter fullscreen mode");e.setAttribute("aria-label",t)},aS=class extends VA{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,eS,null)}static get observedAttributes(){return[...super.observedAttributes,lE.MEDIA_IS_FULLSCREEN,lE.MEDIA_FULLSCREEN_UNAVAILABLE]}connectedCallback(){super.connectedCallback(),rS(this)}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===lE.MEDIA_IS_FULLSCREEN&&rS(this)}get mediaFullscreenUnavailable(){return py(this,lE.MEDIA_FULLSCREEN_UNAVAILABLE)}set mediaFullscreenUnavailable(e){gy(this,lE.MEDIA_FULLSCREEN_UNAVAILABLE,e)}get mediaIsFullscreen(){return my(this,lE.MEDIA_IS_FULLSCREEN)}set mediaIsFullscreen(e){fy(this,lE.MEDIA_IS_FULLSCREEN,e)}handleClick(e){((e,t,i,r)=>{iS(e,t,"write to private field"),r?r.call(e,i):t.set(e,i)})(this,eS,e);let t=((e,t,i)=>(iS(e,t,"read from private field"),i?i.call(e):t.get(e)))(this,eS)instanceof PointerEvent,i=this.mediaIsFullscreen?new qE.CustomEvent(aE.MEDIA_EXIT_FULLSCREEN_REQUEST,{composed:!0,bubbles:!0}):new qE.CustomEvent(aE.MEDIA_ENTER_FULLSCREEN_REQUEST,{composed:!0,bubbles:!0,detail:t});this.dispatchEvent(i)}};eS=new WeakMap,aS.getSlotTemplateHTML=function(e){return`\n    <style>\n      :host([${lE.MEDIA_IS_FULLSCREEN}]) slot[name=icon] slot:not([name=exit]) {\n        display: none !important;\n      }\n\n      \n      :host(:not([${lE.MEDIA_IS_FULLSCREEN}])) slot[name=icon] slot:not([name=enter]) {\n        display: none !important;\n      }\n\n      :host([${lE.MEDIA_IS_FULLSCREEN}]) slot[name=tooltip-enter],\n      :host(:not([${lE.MEDIA_IS_FULLSCREEN}])) slot[name=tooltip-exit] {\n        display: none;\n      }\n    </style>\n\n    <slot name="icon">\n      <slot name="enter"><svg aria-hidden="true" viewBox="0 0 26 24">\n  <path d="M16 3v2.5h3.5V9H22V3h-6ZM4 9h2.5V5.5H10V3H4v6Zm15.5 9.5H16V21h6v-6h-2.5v3.5ZM6.5 15H4v6h6v-2.5H6.5V15Z"/>\n</svg></slot>\n      <slot name="exit"><svg aria-hidden="true" viewBox="0 0 26 24">\n  <path d="M18.5 6.5V3H16v6h6V6.5h-3.5ZM16 21h2.5v-3.5H22V15h-6v6ZM4 17.5h3.5V21H10v-6H4v2.5Zm3.5-11H4V9h6V3H7.5v3.5Z"/>\n</svg></slot>\n    </slot>\n  `},aS.getTooltipContentHTML=function(){return`\n    <slot name="tooltip-enter">${xE("Enter fullscreen mode")}</slot>\n    <slot name="tooltip-exit">${xE("Exit fullscreen mode")}</slot>\n  `},qE.customElements.get("media-fullscreen-button")||qE.customElements.define("media-fullscreen-button",aS);var{MEDIA_TIME_IS_LIVE:nS,MEDIA_PAUSED:sS}=lE,{MEDIA_SEEK_TO_LIVE_REQUEST:oS,MEDIA_PLAY_REQUEST:lS}=aE;var dS=e=>{var t;let i=e.mediaPaused||!e.mediaTimeIsLive,r=xE(i?"seek to live":"playing live");e.setAttribute("aria-label",r);let a=null==(t=e.shadowRoot)?void 0:t.querySelector('slot[name="text"]');a&&(a.textContent=xE("live")),i?e.removeAttribute("aria-disabled"):e.setAttribute("aria-disabled","true")},uS=class extends VA{static get observedAttributes(){return[...super.observedAttributes,nS,sS]}connectedCallback(){super.connectedCallback(),dS(this)}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),dS(this)}get mediaPaused(){return my(this,lE.MEDIA_PAUSED)}set mediaPaused(e){fy(this,lE.MEDIA_PAUSED,e)}get mediaTimeIsLive(){return my(this,lE.MEDIA_TIME_IS_LIVE)}set mediaTimeIsLive(e){fy(this,lE.MEDIA_TIME_IS_LIVE,e)}handleClick(){!this.mediaPaused&&this.mediaTimeIsLive||(this.dispatchEvent(new qE.CustomEvent(oS,{composed:!0,bubbles:!0})),this.hasAttribute(sS)&&this.dispatchEvent(new qE.CustomEvent(lS,{composed:!0,bubbles:!0})))}};uS.getSlotTemplateHTML=function(e){return`\n    <style>\n      :host { --media-tooltip-display: none; }\n      \n      slot[name=indicator] > *,\n      :host ::slotted([slot=indicator]) {\n        \n        min-width: auto;\n        fill: var(--media-live-button-icon-color, rgb(140, 140, 140));\n        color: var(--media-live-button-icon-color, rgb(140, 140, 140));\n      }\n\n      :host([${nS}]:not([${sS}])) slot[name=indicator] > *,\n      :host([${nS}]:not([${sS}])) ::slotted([slot=indicator]) {\n        fill: var(--media-live-button-indicator-color, rgb(255, 0, 0));\n        color: var(--media-live-button-indicator-color, rgb(255, 0, 0));\n      }\n\n      :host([${nS}]:not([${sS}])) {\n        cursor: var(--media-cursor, not-allowed);\n      }\n\n      slot[name=text]{\n        text-transform: uppercase;\n      }\n\n    </style>\n\n    <slot name="indicator"><svg viewBox="0 0 6 12" aria-hidden="true"><circle cx="3" cy="6" r="2"></circle></svg></slot>\n    \n    <slot name="spacer">&nbsp;</slot><slot name="text">${xE("live")}</slot>\n  `},qE.customElements.get("media-live-button")||qE.customElements.define("media-live-button",uS);var hS,cS,mS=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},fS=(e,t,i)=>(mS(e,t,"read from private field"),i?i.call(e):t.get(e)),pS=(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)},gS=(e,t,i,r)=>(mS(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i),vS="loadingdelay",ES="noautohide";var yS=class extends qE.HTMLElement{constructor(){if(super(),pS(this,hS,void 0),pS(this,cS,500),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);let e=JE(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e)}}static get observedAttributes(){return[nE.MEDIA_CONTROLLER,lE.MEDIA_PAUSED,lE.MEDIA_LOADING,vS]}attributeChangedCallback(e,t,i){var r,a,n,s,o;e===vS&&t!==i?this.loadingDelay=Number(i):e===nE.MEDIA_CONTROLLER&&(t&&(null==(a=null==(r=fS(this,hS))?void 0:r.unassociateElement)||a.call(r,this),gS(this,hS,null)),i&&this.isConnected&&(gS(this,hS,null==(n=this.getRootNode())?void 0:n.getElementById(i)),null==(o=null==(s=fS(this,hS))?void 0:s.associateElement)||o.call(s,this)))}connectedCallback(){var e,t,i;let r=this.getAttribute(nE.MEDIA_CONTROLLER);r&&(gS(this,hS,null==(e=this.getRootNode())?void 0:e.getElementById(r)),null==(i=null==(t=fS(this,hS))?void 0:t.associateElement)||i.call(t,this))}disconnectedCallback(){var e,t;null==(t=null==(e=fS(this,hS))?void 0:e.unassociateElement)||t.call(e,this),gS(this,hS,null)}get loadingDelay(){return fS(this,cS)}set loadingDelay(e){gS(this,cS,e);let{style:t}=dy(this.shadowRoot,":host");t.setProperty("--_loading-indicator-delay",`var(--media-loading-indicator-transition-delay, ${e}ms)`)}get mediaPaused(){return my(this,lE.MEDIA_PAUSED)}set mediaPaused(e){fy(this,lE.MEDIA_PAUSED,e)}get mediaLoading(){return my(this,lE.MEDIA_LOADING)}set mediaLoading(e){fy(this,lE.MEDIA_LOADING,e)}get mediaController(){return py(this,nE.MEDIA_CONTROLLER)}set mediaController(e){gy(this,nE.MEDIA_CONTROLLER,e)}get noAutohide(){return my(this,ES)}set noAutohide(e){fy(this,ES,e)}};hS=new WeakMap,cS=new WeakMap,yS.shadowRootOptions={mode:"open"},yS.getTemplateHTML=function(e){return`\n    <style>\n      :host {\n        display: var(--media-control-display, var(--media-loading-indicator-display, inline-block));\n        vertical-align: middle;\n        box-sizing: border-box;\n        --_loading-indicator-delay: var(--media-loading-indicator-transition-delay, 500ms);\n      }\n\n      #status {\n        color: rgba(0,0,0,0);\n        width: 0px;\n        height: 0px;\n      }\n\n      :host slot[name=icon] > *,\n      :host ::slotted([slot=icon]) {\n        opacity: var(--media-loading-indicator-opacity, 0);\n        transition: opacity 0.15s;\n      }\n\n      :host([${lE.MEDIA_LOADING}]:not([${lE.MEDIA_PAUSED}])) slot[name=icon] > *,\n      :host([${lE.MEDIA_LOADING}]:not([${lE.MEDIA_PAUSED}])) ::slotted([slot=icon]) {\n        opacity: var(--media-loading-indicator-opacity, 1);\n        transition: opacity 0.15s var(--_loading-indicator-delay);\n      }\n\n      :host #status {\n        visibility: var(--media-loading-indicator-opacity, hidden);\n        transition: visibility 0.15s;\n      }\n\n      :host([${lE.MEDIA_LOADING}]:not([${lE.MEDIA_PAUSED}])) #status {\n        visibility: var(--media-loading-indicator-opacity, visible);\n        transition: visibility 0.15s var(--_loading-indicator-delay);\n      }\n\n      svg, img, ::slotted(svg), ::slotted(img) {\n        width: var(--media-loading-indicator-icon-width);\n        height: var(--media-loading-indicator-icon-height, 100px);\n        fill: var(--media-icon-color, var(--media-primary-color, rgb(238 238 238)));\n        vertical-align: middle;\n      }\n    </style>\n\n    <slot name="icon">\n<svg aria-hidden="true" viewBox="0 0 100 100">\n  <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">\n    <animateTransform\n       attributeName="transform"\n       attributeType="XML"\n       type="rotate"\n       dur="1s"\n       from="0 50 50"\n       to="360 50 50"\n       repeatCount="indefinite" />\n  </path>\n</svg>\n</slot>\n    <div id="status" role="status" aria-live="polite">${xE("media loading")}</div>\n  `},qE.customElements.get("media-loading-indicator")||qE.customElements.define("media-loading-indicator",yS);var bS='<svg aria-hidden="true" viewBox="0 0 24 24">\n  <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"/>\n</svg>';var TS=e=>{let t="off"===e.mediaVolumeLevel?xE("unmute"):xE("mute");e.setAttribute("aria-label",t)},AS=class extends VA{static get observedAttributes(){return[...super.observedAttributes,lE.MEDIA_VOLUME_LEVEL]}connectedCallback(){super.connectedCallback(),TS(this)}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===lE.MEDIA_VOLUME_LEVEL&&TS(this)}get mediaVolumeLevel(){return py(this,lE.MEDIA_VOLUME_LEVEL)}set mediaVolumeLevel(e){gy(this,lE.MEDIA_VOLUME_LEVEL,e)}handleClick(){let e="off"===this.mediaVolumeLevel?aE.MEDIA_UNMUTE_REQUEST:aE.MEDIA_MUTE_REQUEST;this.dispatchEvent(new qE.CustomEvent(e,{composed:!0,bubbles:!0}))}};AS.getSlotTemplateHTML=function(e){return`\n    <style>\n      :host(:not([${lE.MEDIA_VOLUME_LEVEL}])) slot[name=icon] slot:not([name=high]),\n      :host([${lE.MEDIA_VOLUME_LEVEL}=high]) slot[name=icon] slot:not([name=high]) {\n        display: none !important;\n      }\n\n      :host([${lE.MEDIA_VOLUME_LEVEL}=off]) slot[name=icon] slot:not([name=off]) {\n        display: none !important;\n      }\n\n      :host([${lE.MEDIA_VOLUME_LEVEL}=low]) slot[name=icon] slot:not([name=low]) {\n        display: none !important;\n      }\n\n      :host([${lE.MEDIA_VOLUME_LEVEL}=medium]) slot[name=icon] slot:not([name=medium]) {\n        display: none !important;\n      }\n\n      :host(:not([${lE.MEDIA_VOLUME_LEVEL}=off])) slot[name=tooltip-unmute],\n      :host([${lE.MEDIA_VOLUME_LEVEL}=off]) slot[name=tooltip-mute] {\n        display: none;\n      }\n    </style>\n\n    <slot name="icon">\n      <slot name="off"><svg aria-hidden="true" viewBox="0 0 24 24">\n  <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"/>\n</svg></slot>\n      <slot name="low">${bS}</slot>\n      <slot name="medium">${bS}</slot>\n      <slot name="high"><svg aria-hidden="true" viewBox="0 0 24 24">\n  <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"/>\n</svg></slot>\n    </slot>\n  `},AS.getTooltipContentHTML=function(){return`\n    <slot name="tooltip-mute">${xE("Mute")}</slot>\n    <slot name="tooltip-unmute">${xE("Unmute")}</slot>\n  `},qE.customElements.get("media-mute-button")||qE.customElements.define("media-mute-button",AS);var _S='<svg aria-hidden="true" viewBox="0 0 28 24">\n  <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"/>\n</svg>';var SS=e=>{let t=e.mediaIsPip?xE("exit picture in picture mode"):xE("enter picture in picture mode");e.setAttribute("aria-label",t)},kS=class extends VA{static get observedAttributes(){return[...super.observedAttributes,lE.MEDIA_IS_PIP,lE.MEDIA_PIP_UNAVAILABLE]}connectedCallback(){super.connectedCallback(),SS(this)}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===lE.MEDIA_IS_PIP&&SS(this)}get mediaPipUnavailable(){return py(this,lE.MEDIA_PIP_UNAVAILABLE)}set mediaPipUnavailable(e){gy(this,lE.MEDIA_PIP_UNAVAILABLE,e)}get mediaIsPip(){return my(this,lE.MEDIA_IS_PIP)}set mediaIsPip(e){fy(this,lE.MEDIA_IS_PIP,e)}handleClick(){let e=this.mediaIsPip?aE.MEDIA_EXIT_PIP_REQUEST:aE.MEDIA_ENTER_PIP_REQUEST;this.dispatchEvent(new qE.CustomEvent(e,{composed:!0,bubbles:!0}))}};kS.getSlotTemplateHTML=function(e){return`\n    <style>\n      :host([${lE.MEDIA_IS_PIP}]) slot[name=icon] slot:not([name=exit]) {\n        display: none !important;\n      }\n\n      :host(:not([${lE.MEDIA_IS_PIP}])) slot[name=icon] slot:not([name=enter]) {\n        display: none !important;\n      }\n\n      :host([${lE.MEDIA_IS_PIP}]) slot[name=tooltip-enter],\n      :host(:not([${lE.MEDIA_IS_PIP}])) slot[name=tooltip-exit] {\n        display: none;\n      }\n    </style>\n\n    <slot name="icon">\n      <slot name="enter">${_S}</slot>\n      <slot name="exit">${_S}</slot>\n    </slot>\n  `},kS.getTooltipContentHTML=function(){return`\n    <slot name="tooltip-enter">${xE("Enter picture in picture mode")}</slot>\n    <slot name="tooltip-exit">${xE("Exit picture in picture mode")}</slot>\n  `},qE.customElements.get("media-pip-button")||qE.customElements.define("media-pip-button",kS);var IS,RS=(e,t,i)=>(((e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)})(e,t,"read from private field"),i?i.call(e):t.get(e)),LS="rates",wS=[1,1.2,1.5,1.7,2];function DS(e){return Math.round(100*e)/100}var CS=class extends VA{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,IS,new $b(this,LS,{defaultValue:wS})),this.container=this.shadowRoot.querySelector('slot[name="icon"]'),this.container.innerHTML=`${DS(null!=(e=this.mediaPlaybackRate)?e:1)}x`}static get observedAttributes(){return[...super.observedAttributes,lE.MEDIA_PLAYBACK_RATE,LS]}attributeChangedCallback(e,t,i){if(super.attributeChangedCallback(e,t,i),e===LS&&(RS(this,IS).value=i),e===lE.MEDIA_PLAYBACK_RATE){let e=i?+i:Number.NaN,t=DS(Number.isNaN(e)?1:e);this.container.innerHTML=`${t}x`,this.setAttribute("aria-label",xE("Playback rate {playbackRate}",{playbackRate:t}))}}get rates(){return RS(this,IS)}set rates(e){e?Array.isArray(e)?RS(this,IS).value=e.join(" "):"string"==typeof e&&(RS(this,IS).value=e):RS(this,IS).value=""}get mediaPlaybackRate(){return hy(this,lE.MEDIA_PLAYBACK_RATE,1)}set mediaPlaybackRate(e){cy(this,lE.MEDIA_PLAYBACK_RATE,e)}handleClick(){var e,t;let i=Array.from(RS(this,IS).values(),e=>+e).sort((e,t)=>e-t),r=null!=(t=null!=(e=i.find(e=>e>this.mediaPlaybackRate))?e:i[0])?t:1,a=new qE.CustomEvent(aE.MEDIA_PLAYBACK_RATE_REQUEST,{composed:!0,bubbles:!0,detail:r});this.dispatchEvent(a)}};IS=new WeakMap,CS.getSlotTemplateHTML=function(e){return`\n    <style>\n      :host {\n        min-width: 5ch;\n        padding: var(--media-button-padding, var(--media-control-padding, 10px 5px));\n      }\n    </style>\n    <slot name="icon">${e.mediaplaybackrate?DS(+e.mediaplaybackrate):1}x</slot>\n  `},CS.getTooltipContentHTML=function(){return xE("Playback rate")},qE.customElements.get("media-playback-rate-button")||qE.customElements.define("media-playback-rate-button",CS);var MS=e=>{let t=e.mediaPaused?xE("play"):xE("pause");e.setAttribute("aria-label",t)},PS=class extends VA{static get observedAttributes(){return[...super.observedAttributes,lE.MEDIA_PAUSED,lE.MEDIA_ENDED]}connectedCallback(){super.connectedCallback(),MS(this)}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),(e===lE.MEDIA_PAUSED||e===lE.MEDIA_LANG)&&MS(this)}get mediaPaused(){return my(this,lE.MEDIA_PAUSED)}set mediaPaused(e){fy(this,lE.MEDIA_PAUSED,e)}handleClick(){let e=this.mediaPaused?aE.MEDIA_PLAY_REQUEST:aE.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new qE.CustomEvent(e,{composed:!0,bubbles:!0}))}};PS.getSlotTemplateHTML=function(e){return`\n    <style>\n      :host([${lE.MEDIA_PAUSED}]) slot[name=pause],\n      :host(:not([${lE.MEDIA_PAUSED}])) slot[name=play] {\n        display: none !important;\n      }\n\n      :host([${lE.MEDIA_PAUSED}]) slot[name=tooltip-pause],\n      :host(:not([${lE.MEDIA_PAUSED}])) slot[name=tooltip-play] {\n        display: none;\n      }\n    </style>\n\n    <slot name="icon">\n      <slot name="play"><svg aria-hidden="true" viewBox="0 0 24 24">\n  <path d="m6 21 15-9L6 3v18Z"/>\n</svg></slot>\n      <slot name="pause"><svg aria-hidden="true" viewBox="0 0 24 24">\n  <path d="M6 20h4V4H6v16Zm8-16v16h4V4h-4Z"/>\n</svg></slot>\n    </slot>\n  `},PS.getTooltipContentHTML=function(){return`\n    <slot name="tooltip-play">${xE("Play")}</slot>\n    <slot name="tooltip-pause">${xE("Pause")}</slot>\n  `},qE.customElements.get("media-play-button")||qE.customElements.define("media-play-button",PS);var xS="placeholdersrc",OS="src";var NS=class extends qE.HTMLElement{static get observedAttributes(){return[xS,OS]}constructor(){if(super(),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);let e=JE(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e)}this.image=this.shadowRoot.querySelector("#image")}attributeChangedCallback(e,t,i){e===OS&&(null==i?this.image.removeAttribute(OS):this.image.setAttribute(OS,i)),e===xS&&(null==i?(e=>{e.style.removeProperty("background-image")})(this.image):((e,t)=>{e.style["background-image"]=`url('${t}')`})(this.image,i))}get placeholderSrc(){return py(this,xS)}set placeholderSrc(e){gy(this,OS,e)}get src(){return py(this,OS)}set src(e){gy(this,OS,e)}};NS.shadowRootOptions={mode:"open"},NS.getTemplateHTML=function(e){return'\n    <style>\n      :host {\n        pointer-events: none;\n        display: var(--media-poster-image-display, inline-block);\n        box-sizing: border-box;\n      }\n\n      img {\n        max-width: 100%;\n        max-height: 100%;\n        min-width: 100%;\n        min-height: 100%;\n        background-repeat: no-repeat;\n        background-position: var(--media-poster-image-background-position, var(--media-object-position, center));\n        background-size: var(--media-poster-image-background-size, var(--media-object-fit, contain));\n        object-fit: var(--media-object-fit, contain);\n        object-position: var(--media-object-position, center);\n      }\n    </style>\n\n    <img part="poster img" aria-hidden="true" id="image"/>\n  '},qE.customElements.get("media-poster-image")||qE.customElements.define("media-poster-image",NS);var US,FS=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)};US=new WeakMap,qE.customElements.get("media-preview-chapter-display")||qE.customElements.define("media-preview-chapter-display",class extends H_{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,US,void 0),((e,t,i,r)=>{FS(e,t,"write to private field"),r?r.call(e,i):t.set(e,i)})(this,US,this.shadowRoot.querySelector("slot"))}static get observedAttributes(){return[...super.observedAttributes,lE.MEDIA_PREVIEW_CHAPTER,lE.MEDIA_LANG]}attributeChangedCallback(e,t,i){if(super.attributeChangedCallback(e,t,i),(e===lE.MEDIA_PREVIEW_CHAPTER||e===lE.MEDIA_LANG)&&i!==t&&null!=i)if(((e,t,i)=>(FS(e,t,"read from private field"),i?i.call(e):t.get(e)))(this,US).textContent=i,""!==i){let e=xE("chapter: {chapterName}",{chapterName:i});this.setAttribute("aria-valuetext",e)}else this.removeAttribute("aria-valuetext")}get mediaPreviewChapter(){return py(this,lE.MEDIA_PREVIEW_CHAPTER)}set mediaPreviewChapter(e){gy(this,lE.MEDIA_PREVIEW_CHAPTER,e)}});var BS,$S=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},HS=(e,t,i)=>($S(e,t,"read from private field"),i?i.call(e):t.get(e)),GS=(e,t,i,r)=>($S(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i);var KS=class extends qE.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,BS,void 0),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);let e=JE(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e)}}static get observedAttributes(){return[nE.MEDIA_CONTROLLER,lE.MEDIA_PREVIEW_IMAGE,lE.MEDIA_PREVIEW_COORDS]}connectedCallback(){var e,t,i;let r=this.getAttribute(nE.MEDIA_CONTROLLER);r&&(GS(this,BS,null==(e=this.getRootNode())?void 0:e.getElementById(r)),null==(i=null==(t=HS(this,BS))?void 0:t.associateElement)||i.call(t,this))}disconnectedCallback(){var e,t;null==(t=null==(e=HS(this,BS))?void 0:e.unassociateElement)||t.call(e,this),GS(this,BS,null)}attributeChangedCallback(e,t,i){var r,a,n,s,o;[lE.MEDIA_PREVIEW_IMAGE,lE.MEDIA_PREVIEW_COORDS].includes(e)&&this.update(),e===nE.MEDIA_CONTROLLER&&(t&&(null==(a=null==(r=HS(this,BS))?void 0:r.unassociateElement)||a.call(r,this),GS(this,BS,null)),i&&this.isConnected&&(GS(this,BS,null==(n=this.getRootNode())?void 0:n.getElementById(i)),null==(o=null==(s=HS(this,BS))?void 0:s.associateElement)||o.call(s,this)))}get mediaPreviewImage(){return py(this,lE.MEDIA_PREVIEW_IMAGE)}set mediaPreviewImage(e){gy(this,lE.MEDIA_PREVIEW_IMAGE,e)}get mediaPreviewCoords(){let e=this.getAttribute(lE.MEDIA_PREVIEW_COORDS);if(e)return e.split(/\s+/).map(e=>+e)}set mediaPreviewCoords(e){e?this.setAttribute(lE.MEDIA_PREVIEW_COORDS,e.join(" ")):this.removeAttribute(lE.MEDIA_PREVIEW_COORDS)}update(){let e=this.mediaPreviewCoords,t=this.mediaPreviewImage;if(!e||!t)return;let i,r,[a,n,s,o]=e,l=t.split("#")[0],d=getComputedStyle(this),{maxWidth:u,maxHeight:h,minWidth:c,minHeight:m}=d;if("fill"===(d.getPropertyValue("--media-preview-thumbnail-object-fit").trim()||"contain")){let e=parseInt(u)/s,t=parseInt(h)/o,a=parseInt(c)/s,n=parseInt(m)/o;i=e<1?e:Math.max(e,a),r=t<1?t:Math.max(t,n)}else{let e=Math.min(parseInt(u)/s,parseInt(h)/o),t=Math.max(parseInt(c)/s,parseInt(m)/o),a=e<1?e:t>1?t:1;i=a,r=a}let{style:f}=dy(this.shadowRoot,":host"),p=dy(this.shadowRoot,"img").style,g=this.shadowRoot.querySelector("img"),v=Math.min(i,r)<1?"min":"max";f.setProperty(`${v}-width`,"initial","important"),f.setProperty(`${v}-height`,"initial","important"),f.width=s*i+"px",f.height=o*r+"px";let E=()=>{p.width=this.imgWidth*i+"px",p.height=this.imgHeight*r+"px",p.display="block"};g.src!==l&&(g.onload=()=>{this.imgWidth=g.naturalWidth,this.imgHeight=g.naturalHeight,E(),g.onload=null},g.src=l,E()),E(),p.transform=`translate(-${a*i}px, -${n*r}px)`}};BS=new WeakMap,KS.shadowRootOptions={mode:"open"},KS.getTemplateHTML=function(e){return'\n    <style>\n      :host {\n        box-sizing: border-box;\n        display: var(--media-control-display, var(--media-preview-thumbnail-display, inline-block));\n        overflow: hidden;\n      }\n\n      img {\n        display: none;\n        position: relative;\n      }\n    </style>\n    <img crossorigin loading="eager" decoding="async">\n  '},qE.customElements.get("media-preview-thumbnail")||qE.customElements.define("media-preview-thumbnail",KS);var WS,VS=KS,qS=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},YS=(e,t,i)=>(qS(e,t,"read from private field"),i?i.call(e):t.get(e));WS=new WeakMap,qE.customElements.get("media-preview-time-display")||qE.customElements.define("media-preview-time-display",class extends H_{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,WS,void 0),((e,t,i,r)=>{qS(e,t,"write to private field"),r?r.call(e,i):t.set(e,i)})(this,WS,this.shadowRoot.querySelector("slot")),YS(this,WS).textContent=FE(0)}static get observedAttributes(){return[...super.observedAttributes,lE.MEDIA_PREVIEW_TIME]}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===lE.MEDIA_PREVIEW_TIME&&null!=i&&(YS(this,WS).textContent=FE(parseFloat(i)))}get mediaPreviewTime(){return hy(this,lE.MEDIA_PREVIEW_TIME)}set mediaPreviewTime(e){cy(this,lE.MEDIA_PREVIEW_TIME,e)}});var jS="seekoffset";var zS=class extends VA{static get observedAttributes(){return[...super.observedAttributes,lE.MEDIA_CURRENT_TIME,jS]}connectedCallback(){super.connectedCallback(),this.seekOffset=hy(this,jS,30)}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),((e,t)=>{e.setAttribute("aria-label",xE("seek back {seekOffset} seconds",{seekOffset:t}))})(this,this.seekOffset),e===jS&&(this.seekOffset=hy(this,jS,30))}get seekOffset(){return hy(this,jS,30)}set seekOffset(e){cy(this,jS,e),this.setAttribute("aria-label",xE("seek back {seekOffset} seconds",{seekOffset:this.seekOffset})),iy(ry(this,"icon"),this.seekOffset)}get mediaCurrentTime(){return hy(this,lE.MEDIA_CURRENT_TIME,0)}set mediaCurrentTime(e){cy(this,lE.MEDIA_CURRENT_TIME,e)}handleClick(){let e=Math.max(this.mediaCurrentTime-this.seekOffset,0),t=new qE.CustomEvent(aE.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)}};zS.getSlotTemplateHTML=function(e,t){return`\n    <slot name="icon">${(e=>`\n  <svg aria-hidden="true" viewBox="0 0 20 24">\n    <defs>\n      <style>.text{font-size:8px;font-family:Arial-BoldMT, Arial;font-weight:700;}</style>\n    </defs>\n    <text class="text value" transform="translate(2.18 19.87)">${e}</text>\n    <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"/>\n  </svg>`)(t.seekOffset)}</slot>\n  `},zS.getTooltipContentHTML=function(){return xE("Seek backward")},qE.customElements.get("media-seek-backward-button")||qE.customElements.define("media-seek-backward-button",zS);var QS="seekoffset";var XS=class extends VA{static get observedAttributes(){return[...super.observedAttributes,lE.MEDIA_CURRENT_TIME,QS]}connectedCallback(){super.connectedCallback(),this.seekOffset=hy(this,QS,30)}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),((e,t)=>{e.setAttribute("aria-label",xE("seek forward {seekOffset} seconds",{seekOffset:t}))})(this,this.seekOffset),e===QS&&(this.seekOffset=hy(this,QS,30))}get seekOffset(){return hy(this,QS,30)}set seekOffset(e){cy(this,QS,e),this.setAttribute("aria-label",xE("seek forward {seekOffset} seconds",{seekOffset:this.seekOffset})),iy(ry(this,"icon"),this.seekOffset)}get mediaCurrentTime(){return hy(this,lE.MEDIA_CURRENT_TIME,0)}set mediaCurrentTime(e){cy(this,lE.MEDIA_CURRENT_TIME,e)}handleClick(){let e=this.mediaCurrentTime+this.seekOffset,t=new qE.CustomEvent(aE.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)}};XS.getSlotTemplateHTML=function(e,t){return`\n    <slot name="icon">${(e=>`\n  <svg aria-hidden="true" viewBox="0 0 20 24">\n    <defs>\n      <style>.text{font-size:8px;font-family:Arial-BoldMT, Arial;font-weight:700;}</style>\n    </defs>\n    <text class="text value" transform="translate(8.9 19.87)">${e}</text>\n    <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"/>\n  </svg>`)(t.seekOffset)}</slot>\n  `},XS.getTooltipContentHTML=function(){return xE("Seek forward")},qE.customElements.get("media-seek-forward-button")||qE.customElements.define("media-seek-forward-button",XS);var ZS,JS,ek,tk,ik,rk,ak,nk,sk,ok,lk,dk=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},uk=(e,t,i)=>(dk(e,t,"read from private field"),i?i.call(e):t.get(e)),hk=(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)},ck=(e,t,i,r)=>(dk(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i),mk=(e,t,i)=>(dk(e,t,"access private method"),i),fk={REMAINING:"remaining",SHOW_DURATION:"showduration",NO_TOGGLE:"notoggle"},pk=[...Object.values(fk),lE.MEDIA_CURRENT_TIME,lE.MEDIA_DURATION,lE.MEDIA_SEEKABLE],gk=["Enter"," "],vk=(e,{timesSep:t="&nbsp;/&nbsp;"}={})=>{var i,r;let a=null!=(i=e.mediaCurrentTime)?i:0,[,n]=null!=(r=e.mediaSeekable)?r:[],s=0;Number.isFinite(e.mediaDuration)?s=e.mediaDuration:Number.isFinite(n)&&(s=n);let o=e.remaining?FE(0-(s-a)):FE(a);return e.showDuration?`${o}${t}${FE(s)}`:o};var Ek=class extends H_{constructor(){super(),hk(this,tk),hk(this,rk),hk(this,nk),hk(this,ok),hk(this,ZS,void 0),hk(this,JS,null),hk(this,ek,e=>{let{metaKey:t,altKey:i,key:r}=e;t||i||!gk.includes(r)?this.removeEventListener("keyup",uk(this,JS)):this.addEventListener("keyup",uk(this,JS))}),ck(this,ZS,this.shadowRoot.querySelector("slot")),uk(this,ZS).innerHTML=`${vk(this)}`}static get observedAttributes(){return[...super.observedAttributes,...pk,"disabled"]}connectedCallback(){let{style:e}=dy(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",xE("playback time")),mk(this,nk,sk).call(this),super.connectedCallback()}toggleTimeDisplay(){this.noToggle||(this.hasAttribute("remaining")?this.removeAttribute("remaining"):this.setAttribute("remaining",""))}disconnectedCallback(){this.disable(),mk(this,rk,ak).call(this),super.disconnectedCallback()}attributeChangedCallback(e,t,i){(e=>{e.setAttribute("aria-label",xE("playback time"))})(this),pk.includes(e)?this.update():"disabled"===e&&i!==t?null==i?mk(this,nk,sk).call(this):mk(this,ok,lk).call(this):e===fk.NO_TOGGLE&&i!==t&&(this.noToggle?mk(this,ok,lk).call(this):mk(this,nk,sk).call(this)),super.attributeChangedCallback(e,t,i)}enable(){this.noToggle||(this.tabIndex=0)}disable(){this.tabIndex=-1}get remaining(){return my(this,fk.REMAINING)}set remaining(e){fy(this,fk.REMAINING,e)}get showDuration(){return my(this,fk.SHOW_DURATION)}set showDuration(e){fy(this,fk.SHOW_DURATION,e)}get noToggle(){return my(this,fk.NO_TOGGLE)}set noToggle(e){fy(this,fk.NO_TOGGLE,e)}get mediaDuration(){return hy(this,lE.MEDIA_DURATION)}set mediaDuration(e){cy(this,lE.MEDIA_DURATION,e)}get mediaCurrentTime(){return hy(this,lE.MEDIA_CURRENT_TIME)}set mediaCurrentTime(e){cy(this,lE.MEDIA_CURRENT_TIME,e)}get mediaSeekable(){let e=this.getAttribute(lE.MEDIA_SEEKABLE);if(e)return e.split(":").map(e=>+e)}set mediaSeekable(e){null!=e?this.setAttribute(lE.MEDIA_SEEKABLE,e.join(":")):this.removeAttribute(lE.MEDIA_SEEKABLE)}update(){let e=vk(this);(e=>{var t;let i=e.mediaCurrentTime,[,r]=null!=(t=e.mediaSeekable)?t:[],a=null;if(Number.isFinite(e.mediaDuration)?a=e.mediaDuration:Number.isFinite(r)&&(a=r),null==i||null===a)return void e.setAttribute("aria-description",xE("video not loaded, unknown time."));let n=e.remaining?UE(0-(a-i)):UE(i);if(!e.showDuration)return void e.setAttribute("aria-description",n);let s=UE(a),o=xE("{currentTime} of {totalTime}",{currentTime:n,totalTime:s});e.setAttribute("aria-description",o)})(this),e!==uk(this,ZS).innerHTML&&(uk(this,ZS).innerHTML=e)}};ZS=new WeakMap,JS=new WeakMap,ek=new WeakMap,tk=new WeakSet,ik=function(){uk(this,JS)||(ck(this,JS,e=>{let{key:t}=e;gk.includes(t)?this.toggleTimeDisplay():this.removeEventListener("keyup",uk(this,JS))}),this.addEventListener("keydown",uk(this,ek)),this.addEventListener("click",this.toggleTimeDisplay))},rk=new WeakSet,ak=function(){uk(this,JS)&&(this.removeEventListener("keyup",uk(this,JS)),this.removeEventListener("keydown",uk(this,ek)),this.removeEventListener("click",this.toggleTimeDisplay),ck(this,JS,null))},nk=new WeakSet,sk=function(){!this.noToggle&&!this.hasAttribute("disabled")&&(this.setAttribute("role","button"),this.enable(),mk(this,tk,ik).call(this))},ok=new WeakSet,lk=function(){this.removeAttribute("role"),this.disable(),mk(this,rk,ak).call(this)},Ek.getSlotTemplateHTML=function(e,t){return`\n    <slot>${vk(t)}</slot>\n  `},qE.customElements.get("media-time-display")||qE.customElements.define("media-time-display",Ek);var yk,bk,Tk,Ak,_k,Sk,kk,Ik,Rk,Lk,wk=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},Dk=(e,t,i)=>(wk(e,t,"read from private field"),i?i.call(e):t.get(e)),Ck=(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)},Mk=(e,t,i,r)=>(wk(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i),Pk=class{constructor(e,t,i){Ck(this,yk,void 0),Ck(this,bk,void 0),Ck(this,Tk,void 0),Ck(this,Ak,void 0),Ck(this,_k,void 0),Ck(this,Sk,void 0),Ck(this,kk,void 0),Ck(this,Ik,void 0),Ck(this,Rk,0),Ck(this,Lk,(e=performance.now())=>{Mk(this,Rk,requestAnimationFrame(Dk(this,Lk))),Mk(this,Ak,performance.now()-Dk(this,Tk));let t=1e3/this.fps;if(Dk(this,Ak)>t){Mk(this,Tk,e-Dk(this,Ak)%t);let i=1e3/((e-Dk(this,bk))/++((e,t,i,r)=>({set _(r){Mk(e,t,r,i)},get _(){return Dk(e,t,r)}}))(this,_k)._),r=(e-Dk(this,Sk))/1e3/this.duration,a=Dk(this,kk)+r*this.playbackRate;a-Dk(this,yk).valueAsNumber>0?Mk(this,Ik,this.playbackRate/this.duration/i):(Mk(this,Ik,.995*Dk(this,Ik)),a=Dk(this,yk).valueAsNumber+Dk(this,Ik)),this.callback(a)}}),Mk(this,yk,e),this.callback=t,this.fps=i}start(){0===Dk(this,Rk)&&(Mk(this,Tk,performance.now()),Mk(this,bk,Dk(this,Tk)),Mk(this,_k,0),Dk(this,Lk).call(this))}stop(){0!==Dk(this,Rk)&&(cancelAnimationFrame(Dk(this,Rk)),Mk(this,Rk,0))}update({start:e,duration:t,playbackRate:i}){let r=e-Dk(this,yk).valueAsNumber,a=Math.abs(t-this.duration);(r>0||r<-.5/t||a>=.5)&&this.callback(e),Mk(this,kk,e),Mk(this,Sk,performance.now()),this.duration=t,this.playbackRate=i}};yk=new WeakMap,bk=new WeakMap,Tk=new WeakMap,Ak=new WeakMap,_k=new WeakMap,Sk=new WeakMap,kk=new WeakMap,Ik=new WeakMap,Rk=new WeakMap,Lk=new WeakMap;var xk,Ok,Nk,Uk,Fk,Bk,$k,Hk,Gk,Kk,Wk,Vk,qk,Yk,jk,zk,Qk,Xk,Zk,Jk,eI,tI,iI,rI,aI,nI,sI=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},oI=(e,t,i)=>(sI(e,t,"read from private field"),i?i.call(e):t.get(e)),lI=(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)},dI=(e,t,i,r)=>(sI(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i),uI=(e,t,i)=>(sI(e,t,"access private method"),i);var hI=(e,t=e.mediaCurrentTime)=>{let i=Number.isFinite(e.mediaSeekableStart)?e.mediaSeekableStart:0,r=Number.isFinite(e.mediaDuration)?e.mediaDuration:e.mediaSeekableEnd;if(Number.isNaN(r))return 0;let a=(t-i)/(r-i);return Math.max(0,Math.min(a,1))},cI=(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},mI=class extends C_{constructor(){super(),lI(this,Vk),lI(this,jk),lI(this,Qk),lI(this,Zk),lI(this,eI),lI(this,iI),lI(this,aI),lI(this,xk,null),lI(this,Ok,void 0),lI(this,Nk,void 0),lI(this,Uk,void 0),lI(this,Fk,void 0),lI(this,Bk,void 0),lI(this,$k,void 0),lI(this,Hk,void 0),lI(this,Gk,void 0),lI(this,Kk,void 0),lI(this,Wk,()=>{uI(this,Vk,qk).call(this)?oI(this,Ok).start():oI(this,Ok).stop()}),lI(this,Yk,e=>{this.dragging||(IE(e)&&(this.range.valueAsNumber=e),oI(this,Kk)||this.updateBar())}),this.shadowRoot.querySelector("#track").insertAdjacentHTML("afterbegin",'<div id="buffered" part="buffered"></div>'),dI(this,Nk,this.shadowRoot.querySelectorAll('[part~="box"]')),dI(this,Fk,this.shadowRoot.querySelector('[part~="preview-box"]')),dI(this,Bk,this.shadowRoot.querySelector('[part~="current-box"]'));let e=getComputedStyle(this);dI(this,$k,parseInt(e.getPropertyValue("--media-box-padding-left"))),dI(this,Hk,parseInt(e.getPropertyValue("--media-box-padding-right"))),dI(this,Ok,new Pk(this.range,oI(this,Yk),60))}static get observedAttributes(){return[...super.observedAttributes,lE.MEDIA_PAUSED,lE.MEDIA_DURATION,lE.MEDIA_SEEKABLE,lE.MEDIA_CURRENT_TIME,lE.MEDIA_PREVIEW_IMAGE,lE.MEDIA_PREVIEW_TIME,lE.MEDIA_PREVIEW_CHAPTER,lE.MEDIA_BUFFERED,lE.MEDIA_PLAYBACK_RATE,lE.MEDIA_LOADING,lE.MEDIA_ENDED]}connectedCallback(){var e;super.connectedCallback(),this.range.setAttribute("aria-label",xE("seek")),oI(this,Wk).call(this),dI(this,xk,this.getRootNode()),null==(e=oI(this,xk))||e.addEventListener("transitionstart",this)}disconnectedCallback(){var e;super.disconnectedCallback(),oI(this,Ok).stop(),null==(e=oI(this,xk))||e.removeEventListener("transitionstart",this),dI(this,xk,null)}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),t!=i&&(e===lE.MEDIA_CURRENT_TIME||e===lE.MEDIA_PAUSED||e===lE.MEDIA_ENDED||e===lE.MEDIA_LOADING||e===lE.MEDIA_DURATION||e===lE.MEDIA_SEEKABLE?(oI(this,Ok).update({start:hI(this),duration:this.mediaSeekableEnd-this.mediaSeekableStart,playbackRate:this.mediaPlaybackRate}),oI(this,Wk).call(this),(e=>{let t=e.range,i=UE(+cI(e)),r=UE(+e.mediaSeekableEnd),a=i&&r?xE("{currentTime} of {totalTime}",{currentTime:i,totalTime:r}):xE("video not loaded, unknown time.");t.setAttribute("aria-valuetext",a)})(this)):e===lE.MEDIA_BUFFERED&&this.updateBufferedBar(),(e===lE.MEDIA_DURATION||e===lE.MEDIA_SEEKABLE)&&(this.mediaChaptersCues=oI(this,Gk),this.updateBar()))}get mediaChaptersCues(){return oI(this,Gk)}set mediaChaptersCues(e){var t;dI(this,Gk,e),this.updateSegments(null==(t=oI(this,Gk))?void 0:t.map(e=>({start:hI(this,e.startTime),end:hI(this,e.endTime)})))}get mediaPaused(){return my(this,lE.MEDIA_PAUSED)}set mediaPaused(e){fy(this,lE.MEDIA_PAUSED,e)}get mediaLoading(){return my(this,lE.MEDIA_LOADING)}set mediaLoading(e){fy(this,lE.MEDIA_LOADING,e)}get mediaDuration(){return hy(this,lE.MEDIA_DURATION)}set mediaDuration(e){cy(this,lE.MEDIA_DURATION,e)}get mediaCurrentTime(){return hy(this,lE.MEDIA_CURRENT_TIME)}set mediaCurrentTime(e){cy(this,lE.MEDIA_CURRENT_TIME,e)}get mediaPlaybackRate(){return hy(this,lE.MEDIA_PLAYBACK_RATE,1)}set mediaPlaybackRate(e){cy(this,lE.MEDIA_PLAYBACK_RATE,e)}get mediaBuffered(){let e=this.getAttribute(lE.MEDIA_BUFFERED);return e?e.split(" ").map(e=>e.split(":").map(e=>+e)):[]}set mediaBuffered(e){if(!e)return void this.removeAttribute(lE.MEDIA_BUFFERED);let t=e.map(e=>e.join(":")).join(" ");this.setAttribute(lE.MEDIA_BUFFERED,t)}get mediaSeekable(){let e=this.getAttribute(lE.MEDIA_SEEKABLE);if(e)return e.split(":").map(e=>+e)}set mediaSeekable(e){null!=e?this.setAttribute(lE.MEDIA_SEEKABLE,e.join(":")):this.removeAttribute(lE.MEDIA_SEEKABLE)}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 py(this,lE.MEDIA_PREVIEW_IMAGE)}set mediaPreviewImage(e){gy(this,lE.MEDIA_PREVIEW_IMAGE,e)}get mediaPreviewTime(){return hy(this,lE.MEDIA_PREVIEW_TIME)}set mediaPreviewTime(e){cy(this,lE.MEDIA_PREVIEW_TIME,e)}get mediaEnded(){return my(this,lE.MEDIA_ENDED)}set mediaEnded(e){fy(this,lE.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,[,a=this.mediaSeekableStart]=null!=(e=i.find(([e,t])=>e<=r&&r<=t))?e:[];t=hI(this,a)}let{style:r}=dy(this.shadowRoot,"#buffered");r.setProperty("width",100*t+"%")}updateCurrentBox(){if(!this.shadowRoot.querySelector('slot[name="current"]').assignedElements().length)return;let e=dy(this.shadowRoot,"#current-rail"),t=dy(this.shadowRoot,'[part~="current-box"]'),i=uI(this,jk,zk).call(this,oI(this,Bk)),r=uI(this,Qk,Xk).call(this,i,this.range.valueAsNumber),a=uI(this,Zk,Jk).call(this,i,this.range.valueAsNumber);e.style.transform=`translateX(${r})`,e.style.setProperty("--_range-width",`${i.range.width}`),t.style.setProperty("--_box-shift",`${a}`),t.style.setProperty("--_box-width",`${i.box.width}px`),t.style.setProperty("visibility","initial")}handleEvent(e){switch(super.handleEvent(e),e.type){case"input":uI(this,aI,nI).call(this);break;case"pointermove":uI(this,eI,tI).call(this,e);break;case"pointerup":oI(this,Kk)&&dI(this,Kk,!1);break;case"pointerdown":dI(this,Kk,!0);break;case"pointerleave":uI(this,iI,rI).call(this,null);break;case"transitionstart":ay(e.target,this)&&setTimeout(()=>oI(this,Wk).call(this),0)}}};xk=new WeakMap,Ok=new WeakMap,Nk=new WeakMap,Uk=new WeakMap,Fk=new WeakMap,Bk=new WeakMap,$k=new WeakMap,Hk=new WeakMap,Gk=new WeakMap,Kk=new WeakMap,Wk=new WeakMap,Vk=new WeakSet,qk=function(){return this.isConnected&&!this.mediaPaused&&!this.mediaLoading&&!this.mediaEnded&&this.mediaSeekableEnd>0&&ly(this)},Yk=new WeakMap,jk=new WeakSet,zk=function(e){var t;let i=(null!=(t=this.getAttribute("bounds")?ny(this,`#${this.getAttribute("bounds")}`):this.parentElement)?t:this).getBoundingClientRect(),r=this.range.getBoundingClientRect(),a=e.offsetWidth;return{box:{width:a,min:-(r.left-i.left-a/2),max:i.right-r.left-a/2},bounds:i,range:r}},Qk=new WeakSet,Xk=function(e,t){let i=100*t+"%",{width:r,min:a,max:n}=e.box;if(!r)return i;if(Number.isNaN(a)||(i=`max(calc(1 / var(--_range-width) * 100 * ${a}% + var(--media-box-padding-left)), ${i})`),!Number.isNaN(n)){i=`min(${i}, ${`calc(1 / var(--_range-width) * 100 * ${n}% - var(--media-box-padding-right))`})`}return i},Zk=new WeakSet,Jk=function(e,t){let{width:i,min:r,max:a}=e.box,n=t*e.range.width;if(n<r+oI(this,$k)){return`${n-i/2+(e.range.left-e.bounds.left-oI(this,$k))}px`}if(n>a-oI(this,Hk)){return n+i/2-(e.bounds.right-e.range.right-oI(this,Hk))-e.range.width+"px"}return 0},eI=new WeakSet,tI=function(e){let t=[...oI(this,Nk)].some(t=>e.composedPath().includes(t));if(!this.dragging&&(t||!e.composedPath().includes(this)))return void uI(this,iI,rI).call(this,null);let i=this.mediaSeekableEnd;if(!i)return;let r=dy(this.shadowRoot,"#preview-rail"),a=dy(this.shadowRoot,'[part~="preview-box"]'),n=uI(this,jk,zk).call(this,oI(this,Fk)),s=(e.clientX-n.range.left)/n.range.width;s=Math.max(0,Math.min(1,s));let o=uI(this,Qk,Xk).call(this,n,s),l=uI(this,Zk,Jk).call(this,n,s);r.style.transform=`translateX(${o})`,r.style.setProperty("--_range-width",`${n.range.width}`),a.style.setProperty("--_box-shift",`${l}`),a.style.setProperty("--_box-width",`${n.box.width}px`);let d=Math.round(oI(this,Uk))-Math.round(s*i);Math.abs(d)<1&&s>.01&&s<.99||(dI(this,Uk,s*i),uI(this,iI,rI).call(this,oI(this,Uk)))},iI=new WeakSet,rI=function(e){this.dispatchEvent(new qE.CustomEvent(aE.MEDIA_PREVIEW_REQUEST,{composed:!0,bubbles:!0,detail:e}))},aI=new WeakSet,nI=function(){oI(this,Ok).stop();let e=cI(this);this.dispatchEvent(new qE.CustomEvent(aE.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:e}))},mI.shadowRootOptions={mode:"open"},mI.getContainerTemplateHTML=function(e){return`\n    <style>\n      :host {\n        --media-box-border-radius: 4px;\n        --media-box-padding-left: 10px;\n        --media-box-padding-right: 10px;\n        --media-preview-border-radius: var(--media-box-border-radius);\n        --media-box-arrow-offset: var(--media-box-border-radius);\n        --_control-background: var(--media-control-background, var(--media-secondary-color, rgb(20 20 30 / .7)));\n        --_preview-background: var(--media-preview-background, var(--_control-background));\n\n        \n        contain: layout;\n      }\n\n      #buffered {\n        background: var(--media-time-range-buffered-color, rgb(255 255 255 / .4));\n        position: absolute;\n        height: 100%;\n        will-change: width;\n      }\n\n      #preview-rail,\n      #current-rail {\n        width: 100%;\n        position: absolute;\n        left: 0;\n        bottom: 100%;\n        pointer-events: none;\n        will-change: transform;\n      }\n\n      [part~="box"] {\n        width: min-content;\n        \n        position: absolute;\n        bottom: 100%;\n        flex-direction: column;\n        align-items: center;\n        transform: translateX(-50%);\n      }\n\n      [part~="current-box"] {\n        display: var(--media-current-box-display, var(--media-box-display, flex));\n        margin: var(--media-current-box-margin, var(--media-box-margin, 0 0 5px));\n        visibility: hidden;\n      }\n\n      [part~="preview-box"] {\n        display: var(--media-preview-box-display, var(--media-box-display, flex));\n        margin: var(--media-preview-box-margin, var(--media-box-margin, 0 0 5px));\n        transition-property: var(--media-preview-transition-property, visibility, opacity);\n        transition-duration: var(--media-preview-transition-duration-out, .25s);\n        transition-delay: var(--media-preview-transition-delay-out, 0s);\n        visibility: hidden;\n        opacity: 0;\n      }\n\n      :host(:is([${lE.MEDIA_PREVIEW_IMAGE}], [${lE.MEDIA_PREVIEW_TIME}])[dragging]) [part~="preview-box"] {\n        transition-duration: var(--media-preview-transition-duration-in, .5s);\n        transition-delay: var(--media-preview-transition-delay-in, .25s);\n        visibility: visible;\n        opacity: 1;\n      }\n\n      @media (hover: hover) {\n        :host(:is([${lE.MEDIA_PREVIEW_IMAGE}], [${lE.MEDIA_PREVIEW_TIME}]):hover) [part~="preview-box"] {\n          transition-duration: var(--media-preview-transition-duration-in, .5s);\n          transition-delay: var(--media-preview-transition-delay-in, .25s);\n          visibility: visible;\n          opacity: 1;\n        }\n      }\n\n      media-preview-thumbnail,\n      ::slotted(media-preview-thumbnail) {\n        visibility: hidden;\n        \n        transition: visibility 0s .25s;\n        transition-delay: calc(var(--media-preview-transition-delay-out, 0s) + var(--media-preview-transition-duration-out, .25s));\n        background: var(--media-preview-thumbnail-background, var(--_preview-background));\n        box-shadow: var(--media-preview-thumbnail-box-shadow, 0 0 4px rgb(0 0 0 / .2));\n        max-width: var(--media-preview-thumbnail-max-width, 180px);\n        max-height: var(--media-preview-thumbnail-max-height, 160px);\n        min-width: var(--media-preview-thumbnail-min-width, 120px);\n        min-height: var(--media-preview-thumbnail-min-height, 80px);\n        border: var(--media-preview-thumbnail-border);\n        border-radius: var(--media-preview-thumbnail-border-radius,\n          var(--media-preview-border-radius) var(--media-preview-border-radius) 0 0);\n      }\n\n      :host([${lE.MEDIA_PREVIEW_IMAGE}][dragging]) media-preview-thumbnail,\n      :host([${lE.MEDIA_PREVIEW_IMAGE}][dragging]) ::slotted(media-preview-thumbnail) {\n        transition-delay: var(--media-preview-transition-delay-in, .25s);\n        visibility: visible;\n      }\n\n      @media (hover: hover) {\n        :host([${lE.MEDIA_PREVIEW_IMAGE}]:hover) media-preview-thumbnail,\n        :host([${lE.MEDIA_PREVIEW_IMAGE}]:hover) ::slotted(media-preview-thumbnail) {\n          transition-delay: var(--media-preview-transition-delay-in, .25s);\n          visibility: visible;\n        }\n\n        :host([${lE.MEDIA_PREVIEW_TIME}]:hover) {\n          --media-time-range-hover-display: block;\n        }\n      }\n\n      media-preview-chapter-display,\n      ::slotted(media-preview-chapter-display) {\n        font-size: var(--media-font-size, 13px);\n        line-height: 17px;\n        min-width: 0;\n        visibility: hidden;\n        \n        transition: min-width 0s, border-radius 0s, margin 0s, padding 0s, visibility 0s;\n        transition-delay: calc(var(--media-preview-transition-delay-out, 0s) + var(--media-preview-transition-duration-out, .25s));\n        background: var(--media-preview-chapter-background, var(--_preview-background));\n        border-radius: var(--media-preview-chapter-border-radius,\n          var(--media-preview-border-radius) var(--media-preview-border-radius)\n          var(--media-preview-border-radius) var(--media-preview-border-radius));\n        padding: var(--media-preview-chapter-padding, 3.5px 9px);\n        margin: var(--media-preview-chapter-margin, 0 0 5px);\n        text-shadow: var(--media-preview-chapter-text-shadow, 0 0 4px rgb(0 0 0 / .75));\n      }\n\n      :host([${lE.MEDIA_PREVIEW_IMAGE}]) media-preview-chapter-display,\n      :host([${lE.MEDIA_PREVIEW_IMAGE}]) ::slotted(media-preview-chapter-display) {\n        transition-delay: var(--media-preview-transition-delay-in, .25s);\n        border-radius: var(--media-preview-chapter-border-radius, 0);\n        padding: var(--media-preview-chapter-padding, 3.5px 9px 0);\n        margin: var(--media-preview-chapter-margin, 0);\n        min-width: 100%;\n      }\n\n      media-preview-chapter-display[${lE.MEDIA_PREVIEW_CHAPTER}],\n      ::slotted(media-preview-chapter-display[${lE.MEDIA_PREVIEW_CHAPTER}]) {\n        visibility: visible;\n      }\n\n      media-preview-chapter-display:not([aria-valuetext]),\n      ::slotted(media-preview-chapter-display:not([aria-valuetext])) {\n        display: none;\n      }\n\n      media-preview-time-display,\n      ::slotted(media-preview-time-display),\n      media-time-display,\n      ::slotted(media-time-display) {\n        font-size: var(--media-font-size, 13px);\n        line-height: 17px;\n        min-width: 0;\n        \n        transition: min-width 0s, border-radius 0s;\n        transition-delay: calc(var(--media-preview-transition-delay-out, 0s) + var(--media-preview-transition-duration-out, .25s));\n        background: var(--media-preview-time-background, var(--_preview-background));\n        border-radius: var(--media-preview-time-border-radius,\n          var(--media-preview-border-radius) var(--media-preview-border-radius)\n          var(--media-preview-border-radius) var(--media-preview-border-radius));\n        padding: var(--media-preview-time-padding, 3.5px 9px);\n        margin: var(--media-preview-time-margin, 0);\n        text-shadow: var(--media-preview-time-text-shadow, 0 0 4px rgb(0 0 0 / .75));\n        transform: translateX(min(\n          max(calc(50% - var(--_box-width) / 2),\n          calc(var(--_box-shift, 0))),\n          calc(var(--_box-width) / 2 - 50%)\n        ));\n      }\n\n      :host([${lE.MEDIA_PREVIEW_IMAGE}]) media-preview-time-display,\n      :host([${lE.MEDIA_PREVIEW_IMAGE}]) ::slotted(media-preview-time-display) {\n        transition-delay: var(--media-preview-transition-delay-in, .25s);\n        border-radius: var(--media-preview-time-border-radius,\n          0 0 var(--media-preview-border-radius) var(--media-preview-border-radius));\n        min-width: 100%;\n      }\n\n      :host([${lE.MEDIA_PREVIEW_TIME}]:hover) {\n        --media-time-range-hover-display: block;\n      }\n\n      [part~="arrow"],\n      ::slotted([part~="arrow"]) {\n        display: var(--media-box-arrow-display, inline-block);\n        transform: translateX(min(\n          max(calc(50% - var(--_box-width) / 2 + var(--media-box-arrow-offset)),\n          calc(var(--_box-shift, 0))),\n          calc(var(--_box-width) / 2 - 50% - var(--media-box-arrow-offset))\n        ));\n        \n        border-color: transparent;\n        border-top-color: var(--media-box-arrow-background, var(--_control-background));\n        border-width: var(--media-box-arrow-border-width,\n          var(--media-box-arrow-height, 5px) var(--media-box-arrow-width, 6px) 0);\n        border-style: solid;\n        justify-content: center;\n        height: 0;\n      }\n    </style>\n    <div id="preview-rail">\n      <slot name="preview" part="box preview-box">\n        <media-preview-thumbnail>\n          <template shadowrootmode="${VS.shadowRootOptions.mode}">\n            ${VS.getTemplateHTML({})}\n          </template>\n        </media-preview-thumbnail>\n        <media-preview-chapter-display></media-preview-chapter-display>\n        <media-preview-time-display></media-preview-time-display>\n        <slot name="preview-arrow"><div part="arrow"></div></slot>\n      </slot>\n    </div>\n    <div id="current-rail">\n      <slot name="current" part="box current-box">\n        \n      </slot>\n    </div>\n  `},qE.customElements.get("media-time-range")||qE.customElements.define("media-time-range",mI);var fI,pI=(e,t,i)=>(((e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)})(e,t,"read from private field"),i?i.call(e):t.get(e));fI=new WeakMap,qE.customElements.get("media-volume-range")||qE.customElements.define("media-volume-range",class extends C_{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,fI,()=>{let e=this.range.value,t=new qE.CustomEvent(aE.MEDIA_VOLUME_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)})}static get observedAttributes(){return[...super.observedAttributes,lE.MEDIA_VOLUME,lE.MEDIA_MUTED,lE.MEDIA_VOLUME_UNAVAILABLE]}connectedCallback(){super.connectedCallback(),this.range.setAttribute("aria-label",xE("volume")),this.range.addEventListener("input",pI(this,fI))}disconnectedCallback(){this.range.removeEventListener("input",pI(this,fI)),super.disconnectedCallback()}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),(e===lE.MEDIA_VOLUME||e===lE.MEDIA_MUTED)&&(this.range.valueAsNumber=(e=>e.mediaMuted?0:e.mediaVolume)(this),this.range.setAttribute("aria-valuetext",(e=>`${Math.round(100*e)}%`)(this.range.valueAsNumber)),this.updateBar())}get mediaVolume(){return hy(this,lE.MEDIA_VOLUME,1)}set mediaVolume(e){cy(this,lE.MEDIA_VOLUME,e)}get mediaMuted(){return my(this,lE.MEDIA_MUTED)}set mediaMuted(e){fy(this,lE.MEDIA_MUTED,e)}get mediaVolumeUnavailable(){return py(this,lE.MEDIA_VOLUME_UNAVAILABLE)}set mediaVolumeUnavailable(e){gy(this,lE.MEDIA_VOLUME_UNAVAILABLE,e)}});var gI=class extends VA{constructor(){super(...arguments),this.container=null}static get observedAttributes(){return[...super.observedAttributes,lE.MEDIA_LOOP]}connectedCallback(){var e;super.connectedCallback(),this.container=(null==(e=this.shadowRoot)?void 0:e.querySelector("#icon"))||null,this.container&&(this.container.textContent=xE("Loop"))}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===lE.MEDIA_LOOP&&this.container&&this.setAttribute("aria-checked",this.mediaLoop?"true":"false")}get mediaLoop(){return my(this,lE.MEDIA_LOOP)}set mediaLoop(e){fy(this,lE.MEDIA_LOOP,e)}handleClick(){let e=!this.mediaLoop,t=new qE.CustomEvent(aE.MEDIA_LOOP_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)}};gI.getSlotTemplateHTML=function(e){return`\n      <style>\n        :host {\n          min-width: 4ch;\n          padding: var(--media-button-padding, var(--media-control-padding, 10px 5px));\n          width: 100%;\n          display: grid;\n          grid-template-columns: 1fr auto;\n          gap: 1rem;\n          font-weight: var(--media-button-font-weight, normal);\n        }\n\n        #checked-indicator {\n          display: none;\n        }\n\n        :host([${lE.MEDIA_LOOP}]) #checked-indicator {\n          display: block;\n        }\n      </style>\n      \n      <span id="icon">\n     </span>\n\n      <div id="checked-indicator">\n        <svg aria-hidden="true" viewBox="0 1 24 24" part="checked-indicator indicator">\n          <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"/>\n        </svg>\n      </div>\n    `},gI.getTooltipContentHTML=function(){return xE("Loop")},qE.customElements.get("media-loop-button")||qE.customElements.define("media-loop-button",gI);var vI,EI,yI,bI,TI,AI,_I,SI,kI,II,RI,LI=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},wI=(e,t,i)=>(LI(e,t,"read from private field"),i?i.call(e):t.get(e)),DI=(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)},CI=(e,t,i,r)=>(LI(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i),MI={processCallback(e,t,i){if(i)for(let[e,r]of t)if(e in i){let t=i[e];"boolean"==typeof t&&r instanceof $I&&"boolean"==typeof r.element[r.attributeName]?r.booleanValue=t:"function"==typeof t&&r instanceof $I?r.element[r.attributeName]=t:r.value=t}}},PI=class extends qE.DocumentFragment{constructor(e,t,i=MI){var r;super(),DI(this,vI,void 0),DI(this,EI,void 0),this.append(e.content.cloneNode(!0)),CI(this,vI,xI(this)),CI(this,EI,i),null==(r=i.createCallback)||r.call(i,this,wI(this,vI),t),i.processCallback(this,wI(this,vI),t)}update(e){wI(this,EI).processCallback(this,wI(this,vI),e)}};vI=new WeakMap,EI=new WeakMap;var xI=(e,t=[])=>{let i,r;for(let a of e.attributes||[])if(a.value.includes("{{")){let n=new BI;for([i,r]of NI(a.value))if(i){let i=new $I(e,a.name,a.namespaceURI);n.append(i),t.push([r,i])}else n.append(r);a.value=n.toString()}for(let a of e.childNodes)if(1!==a.nodeType||a instanceof HTMLTemplateElement){let n=a.data;if(1===a.nodeType||n.includes("{{")){let s=[];if(n)for([i,r]of NI(n))if(i){let i=new HI(e);s.push(i),t.push([r,i])}else s.push(new Text(r));else if(a instanceof HTMLTemplateElement){let i=new GI(e,a);s.push(i),t.push([i.expression,i])}a.replaceWith(...s.flatMap(e=>e.replacementNodes||[e]))}}else xI(a,t);return t},OI={},NI=e=>{let t,i="",r=0,a=OI[e],n=0;if(a)return a;for(a=[];t=e[n];n++)"{"===t&&"{"===e[n+1]&&"\\"!==e[n-1]&&e[n+2]&&1==++r?(i&&a.push([0,i]),i="",n++):"}"!==t||"}"!==e[n+1]||"\\"===e[n-1]||--r?i+=t||"":(a.push([1,i.trim()]),i="",n++);return i&&a.push([0,(r>0?"{{":"")+i]),OI[e]=a},UI=class{get value(){return""}set value(e){}toString(){return this.value}},FI=new WeakMap,BI=class{constructor(){DI(this,yI,[])}[Symbol.iterator](){return wI(this,yI).values()}get length(){return wI(this,yI).length}item(e){return wI(this,yI)[e]}append(...e){for(let t of e)t instanceof $I&&FI.set(t,this),wI(this,yI).push(t)}toString(){return wI(this,yI).join("")}};yI=new WeakMap;var $I=class extends UI{constructor(e,t,i){super(),DI(this,SI),DI(this,bI,""),DI(this,TI,void 0),DI(this,AI,void 0),DI(this,_I,void 0),CI(this,TI,e),CI(this,AI,t),CI(this,_I,i)}get attributeName(){return wI(this,AI)}get attributeNamespace(){return wI(this,_I)}get element(){return wI(this,TI)}get value(){return wI(this,bI)}set value(e){wI(this,bI)!==e&&(CI(this,bI,e),wI(this,SI,kI)&&1!==wI(this,SI,kI).length?wI(this,TI).setAttributeNS(wI(this,_I),wI(this,AI),wI(this,SI,kI).toString()):null==e?wI(this,TI).removeAttributeNS(wI(this,_I),wI(this,AI)):wI(this,TI).setAttributeNS(wI(this,_I),wI(this,AI),e))}get booleanValue(){return wI(this,TI).hasAttributeNS(wI(this,_I),wI(this,AI))}set booleanValue(e){if(wI(this,SI,kI)&&1!==wI(this,SI,kI).length)throw new DOMException("Value is not fully templatized");this.value=e?"":null}};bI=new WeakMap,TI=new WeakMap,AI=new WeakMap,_I=new WeakMap,SI=new WeakSet,kI=function(){return FI.get(this)};var HI=class extends UI{constructor(e,t){super(),DI(this,II,void 0),DI(this,RI,void 0),CI(this,II,e),CI(this,RI,t?[...t]:[new Text])}get replacementNodes(){return wI(this,RI)}get parentNode(){return wI(this,II)}get nextSibling(){return wI(this,RI)[wI(this,RI).length-1].nextSibling}get previousSibling(){return wI(this,RI)[0].previousSibling}get value(){return wI(this,RI).map(e=>e.textContent).join("")}set value(e){this.replace(e)}replace(...e){let t=e.flat().flatMap(e=>null==e?[new Text]:e.forEach?[...e]:11===e.nodeType?[...e.childNodes]:e.nodeType?[e]:[new Text(e)]);t.length||t.push(new Text),CI(this,RI,function(e,t,i,r=null){let a,n,s,o=0,l=i.length,d=t.length;for(;o<l&&o<d&&t[o]==i[o];)o++;for(;o<l&&o<d&&i[l-1]==t[d-1];)r=i[--d,--l];if(o==d)for(;o<l;)e.insertBefore(i[o++],r);if(o==l)for(;o<d;)e.removeChild(t[o++]);else{for(a=t[o];o<l;)s=i[o++],n=a?a.nextSibling:r,a==s?a=n:o<l&&i[o]==n?(e.replaceChild(s,a),a=n):e.insertBefore(s,a);for(;a!=r;)n=a.nextSibling,e.removeChild(a),a=n}return i}(wI(this,RI)[0].parentNode,wI(this,RI),t,this.nextSibling))}};II=new WeakMap,RI=new WeakMap;var GI=class extends HI{constructor(e,t){let i=t.getAttribute("directive")||t.getAttribute("type"),r=t.getAttribute("expression")||t.getAttribute(i)||"";r.startsWith("{{")&&(r=r.trim().slice(2,-2).trim()),super(e),this.expression=r,this.template=t,this.directive=i}};var KI={string:e=>String(e)},WI=class{constructor(e){this.template=e,this.state=void 0}},VI=new WeakMap,qI=new WeakMap,YI={partial:(e,t)=>{t[e.expression]=new WI(e.template)},if:(e,t)=>{var i;if(XI(e.expression,t))if(VI.get(e)!==e.template){VI.set(e,e.template);let i=new PI(e.template,t,zI);e.replace(i),qI.set(e,i)}else null==(i=qI.get(e))||i.update(t);else e.replace(""),VI.delete(e),qI.delete(e)}},jI=Object.keys(YI),zI={processCallback(e,t,i){var r,a;if(i)for(let[e,n]of t){if(n instanceof GI){if(!n.directive){let e=jI.find(e=>n.template.hasAttribute(e));e&&(n.directive=e,n.expression=n.template.getAttribute(e))}null==(r=YI[n.directive])||r.call(YI,n,i);continue}let t=XI(e,i);t instanceof WI?VI.get(n)!==t.template?(VI.set(n,t.template),t=new PI(t.template,t.state,zI),n.value=t,qI.set(n,t)):null==(a=qI.get(n))||a.update(t.state):t?(n instanceof $I&&n.attributeName.startsWith("aria-")&&(t=String(t)),n instanceof $I?"boolean"==typeof t?n.booleanValue=t:"function"==typeof t?n.element[n.attributeName]=t:n.value=t:(n.value=t,VI.delete(n),qI.delete(n))):n instanceof $I?n.value=void 0:(n.value=void 0,VI.delete(n),qI.delete(n))}}},QI={"!":e=>!e,"!!":e=>!!e,"==":(e,t)=>e==t,"!=":(e,t)=>e!=t,">":(e,t)=>e>t,">=":(e,t)=>e>=t,"<":(e,t)=>e<t,"<=":(e,t)=>e<=t,"??":(e,t)=>null!=e?e:t,"|":(e,t)=>{var i;return null==(i=KI[t])?void 0:i.call(KI,e)}};function XI(e,t={}){var i,r,a,n,s,o,l;let d=function(e){return function(e,t){let i,r,a,n=[];for(;e;){a=null,i=e.length;for(let n in t)r=t[n].exec(e),r&&r.index<i&&(a={token:r[0],type:n,matches:r.slice(1)},i=r.index);i&&n.push({token:e.substr(0,i),type:void 0}),a&&n.push(a),e=e.substr(i+(a?a.token.length:0))}return n}(e,{boolean:/true|false/,number:/-?\d+\.?\d*/,string:/(["'])((?:\\.|[^\\])*?)\1/,operator:/[!=><][=!]?|\?\?|\|/,ws:/\s+/,param:/[$a-z_][$\w]*/i}).filter(({type:e})=>"ws"!==e)}(e);if(0===d.length||d.some(({type:e})=>!e))return ZI(e);if(">"===(null==(i=d[0])?void 0:i.token)){let i=t[null==(r=d[1])?void 0:r.token];if(!i)return ZI(e);let o={...t};i.state=o;let l=d.slice(2);for(let e=0;e<l.length;e+=3){let i=null==(a=l[e])?void 0:a.token,r=null==(n=l[e+1])?void 0:n.token,d=null==(s=l[e+2])?void 0:s.token;i&&"="===r&&(o[i]=eR(d,t))}return i}if(1===d.length)return JI(d[0])?eR(d[0].token,t):ZI(e);if(2===d.length){let i=null==(o=d[0])?void 0:o.token,r=QI[i];return r&&JI(d[1])?r(eR(d[1].token,t)):ZI(e)}if(3===d.length){let i=null==(l=d[1])?void 0:l.token,r=QI[i];if(!r||!JI(d[0])||!JI(d[2]))return ZI(e);let a=eR(d[0].token,t);return r(a,"|"===i?d[2].token:eR(d[2].token,t))}}function ZI(e){return console.warn(`Warning: invalid expression \`${e}\``),!1}function JI({type:e}){return["number","boolean","string","param"].includes(e)}function eR(e,t){let i=e[0],r=e.slice(-1);return"true"===e||"false"===e?"true"===e:i===r&&["'",'"'].includes(i)?e.slice(1,-1):RE(e)?parseFloat(e):t[e]}var tR,iR,rR,aR,nR,sR,oR,lR,dR,uR=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},hR=(e,t,i)=>(uR(e,t,"read from private field"),i?i.call(e):t.get(e)),cR=(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)},mR=(e,t,i,r)=>(uR(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i),fR=(e,t,i)=>(uR(e,t,"access private method"),i),pR={mediatargetlivewindow:"targetlivewindow",mediastreamtype:"streamtype"},gR=YE.createElement("template");gR.innerHTML="\n  <style>\n    :host {\n      display: inline-block;\n      line-height: 0;\n    }\n\n    media-controller {\n      width: 100%;\n      height: 100%;\n    }\n\n    media-captions-button:not([mediasubtitleslist]),\n    media-captions-menu:not([mediasubtitleslist]),\n    media-captions-menu-button:not([mediasubtitleslist]),\n    media-audio-track-menu[mediaaudiotrackunavailable],\n    media-audio-track-menu-button[mediaaudiotrackunavailable],\n    media-rendition-menu[mediarenditionunavailable],\n    media-rendition-menu-button[mediarenditionunavailable],\n    media-volume-range[mediavolumeunavailable],\n    media-airplay-button[mediaairplayunavailable],\n    media-fullscreen-button[mediafullscreenunavailable],\n    media-cast-button[mediacastunavailable],\n    media-pip-button[mediapipunavailable] {\n      display: none;\n    }\n  </style>\n";var vR=class extends qE.HTMLElement{constructor(){super(),cR(this,nR),cR(this,oR),cR(this,tR,void 0),cR(this,iR,void 0),cR(this,rR,void 0),cR(this,aR,void 0),cR(this,dR,void 0),this.shadowRoot?this.renderRoot=this.shadowRoot:(this.renderRoot=this.attachShadow({mode:"open"}),this.createRenderer()),mR(this,aR,new MutationObserver(e=>{var t;this.mediaController&&(null==(t=this.mediaController)||!t.breakpointsComputed)||e.some(e=>{let t=e.target;return t===this||"media-controller"===t.localName&&!(!pR[e.attributeName]&&!e.attributeName.startsWith("breakpoint"))})&&this.render()})),mR(this,dR,this.render.bind(this)),fR(this,nR,sR).call(this,"template")}get mediaController(){return this.renderRoot.querySelector("media-controller")}get template(){var e;return null!=(e=hR(this,tR))?e:this.constructor.template}set template(e){null!==e?"string"==typeof e?this.setAttribute("template",e):e instanceof HTMLTemplateElement&&(mR(this,tR,e),mR(this,rR,null),this.createRenderer()):this.removeAttribute("template")}get props(){var e,t,i;let r=[...Array.from(null!=(t=null==(e=this.mediaController)?void 0:e.attributes)?t:[]).filter(({name:e})=>pR[e]||e.startsWith("breakpoint")),...Array.from(this.attributes)],a={};for(let e of r){let t=null!=(i=pR[e.name])?i:kE(e.name),{value:r}=e;null!=r?(RE(r)&&(r=parseFloat(r)),a[t]=""===r||r):a[t]=!1}return a}attributeChangedCallback(e,t,i){"template"===e&&t!=i&&fR(this,oR,lR).call(this)}connectedCallback(){this.addEventListener(dE.BREAKPOINTS_COMPUTED,hR(this,dR)),hR(this,aR).observe(this,{attributes:!0}),hR(this,aR).observe(this.renderRoot,{attributes:!0,subtree:!0}),fR(this,oR,lR).call(this)}disconnectedCallback(){this.removeEventListener(dE.BREAKPOINTS_COMPUTED,hR(this,dR)),hR(this,aR).disconnect()}createRenderer(){this.template instanceof HTMLTemplateElement&&this.template!==hR(this,iR)&&(mR(this,iR,this.template),this.renderer=new PI(this.template,this.props,this.constructor.processor),this.renderRoot.textContent="",this.renderRoot.append(gR.content.cloneNode(!0),this.renderer))}render(){var e;null==(e=this.renderer)||e.update(this.props)}};function ER({anchor:e,floating:t,placement:i}){let r=function({anchor:e,floating:t}){return{anchor:yR(e,t.offsetParent),floating:{x:0,y:0,width:t.offsetWidth,height:t.offsetHeight}}}({anchor:e,floating:t}),{x:a,y:n}=function({anchor:e,floating:t},i){let r,a="x"===function(e){return["top","bottom"].includes(bR(e))?"y":"x"}(i)?"y":"x",n="y"===a?"height":"width",s=bR(i),o=e.x+e.width/2-t.width/2,l=e.y+e.height/2-t.height/2,d=e[n]/2-t[n]/2;switch(s){case"top":r={x:o,y:e.y-t.height};break;case"bottom":r={x:o,y:e.y+e.height};break;case"right":r={x:e.x+e.width,y:l};break;case"left":r={x:e.x-t.width,y:l};break;default:r={x:e.x,y:e.y}}switch(i.split("-")[1]){case"start":r[a]-=d;break;case"end":r[a]+=d}return r}(r,i);return{x:a,y:n}}function yR(e,t){var i;let r=e.getBoundingClientRect(),a=null!=(i=null==t?void 0:t.getBoundingClientRect())?i:{x:0,y:0};return{x:r.x-a.x,y:r.y-a.y,width:r.width,height:r.height}}function bR(e){return e.split("-")[0]}tR=new WeakMap,iR=new WeakMap,rR=new WeakMap,aR=new WeakMap,nR=new WeakSet,sR=function(e){if(Object.prototype.hasOwnProperty.call(this,e)){let t=this[e];delete this[e],this[e]=t}},oR=new WeakSet,lR=function(){var e;let t=this.getAttribute("template");if(!t||t===hR(this,rR))return;let i=this.getRootNode(),r=null==(e=null==i?void 0:i.getElementById)?void 0:e.call(i,t);if(r)return mR(this,rR,t),mR(this,tR,r),void this.createRenderer();(function(e){if(!/^(\/|\.\/|https?:\/\/)/.test(e))return!1;let t=/^https?:\/\//.test(e)?void 0:location.origin;try{new URL(e,t)}catch{return!1}return!0})(t)&&(mR(this,rR,t),async function(e){let t=await fetch(e);if(200!==t.status)throw new Error(`Failed to load resource: the server responded with a status of ${t.status}`);return t.text()}(t).then(e=>{let t=YE.createElement("template");t.innerHTML=e,mR(this,tR,t),this.createRenderer()}).catch(console.error))},dR=new WeakMap,vR.observedAttributes=["template"],vR.processor=zI,qE.customElements.get("media-theme")||qE.customElements.define("media-theme",vR);var TR,AR,_R,SR,kR,IR,RR,LR,wR,DR,CR,MR,PR,xR,OR,NR,UR,FR,BR,$R,HR,GR,KR,WR,VR,qR,YR,jR,zR,QR,XR,ZR,JR,eL,tL,iL,rL,aL,nL,sL,oL,lL,dL,uL,hL,cL,mL=class extends Event{constructor({action:e="auto",relatedTarget:t,...i}){super("invoke",i),this.action=e,this.relatedTarget=t}},fL=class extends Event{constructor({newState:e,oldState:t,...i}){super("toggle",i),this.newState=e,this.oldState=t}},pL=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},gL=(e,t,i)=>(pL(e,t,"read from private field"),i?i.call(e):t.get(e)),vL=(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)},EL=(e,t,i,r)=>(pL(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i),yL=(e,t,i)=>(pL(e,t,"access private method"),i);function bL({type:e,text:t,value:i,checked:r}){let a=YE.createElement("media-chrome-menu-item");a.type=null!=e?e:"",a.part.add("menu-item"),e&&a.part.add(e),a.value=i,a.checked=r;let n=YE.createElement("span");return n.textContent=t,a.append(n),a}function TL(e,t){let i=e.querySelector(`:scope > [slot="${t}"]`);if("SLOT"==(null==i?void 0:i.nodeName)&&(i=i.assignedElements({flatten:!0})[0]),i)return i=i.cloneNode(!0),i;let r=e.shadowRoot.querySelector(`[name="${t}"] > svg`);return r?r.cloneNode(!0):""}var AL="style",_L="hidden",SL="disabled",kL="anchor",IL=class extends qE.HTMLElement{constructor(){if(super(),vL(this,LR),vL(this,DR),vL(this,PR),vL(this,OR),vL(this,UR),vL(this,BR),vL(this,KR),vL(this,VR),vL(this,YR),vL(this,zR),vL(this,XR),vL(this,JR),vL(this,tL),vL(this,rL),vL(this,nL),vL(this,oL),vL(this,dL),vL(this,hL),vL(this,TR,null),vL(this,AR,null),vL(this,_R,null),vL(this,SR,new Set),vL(this,kR,void 0),vL(this,IR,!1),vL(this,RR,null),vL(this,MR,()=>{let e=gL(this,SR),t=new Set(this.items);for(let i of e)t.has(i)||this.dispatchEvent(new CustomEvent("removemenuitem",{detail:i}));for(let i of t)e.has(i)||this.dispatchEvent(new CustomEvent("addmenuitem",{detail:i}));EL(this,SR,t)}),vL(this,HR,()=>{yL(this,KR,WR).call(this),yL(this,VR,qR).call(this,!1)}),vL(this,GR,()=>{yL(this,KR,WR).call(this)}),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);let e=JE(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e)}this.container=this.shadowRoot.querySelector("#container"),this.defaultSlot=this.shadowRoot.querySelector("slot:not([name])"),EL(this,kR,new MutationObserver(gL(this,MR)))}static get observedAttributes(){return[SL,_L,AL,kL,nE.MEDIA_CONTROLLER]}static formatMenuItemText(e,t){return e}enable(){this.addEventListener("click",this),this.addEventListener("focusout",this),this.addEventListener("keydown",this),this.addEventListener("invoke",this),this.addEventListener("toggle",this)}disable(){this.removeEventListener("click",this),this.removeEventListener("focusout",this),this.removeEventListener("keyup",this),this.removeEventListener("invoke",this),this.removeEventListener("toggle",this)}handleEvent(e){switch(e.type){case"slotchange":yL(this,LR,wR).call(this,e);break;case"invoke":yL(this,OR,NR).call(this,e);break;case"click":yL(this,YR,jR).call(this,e);break;case"toggle":yL(this,XR,ZR).call(this,e);break;case"focusout":yL(this,tL,iL).call(this,e);break;case"keydown":yL(this,rL,aL).call(this,e)}}connectedCallback(){var e,t;gL(this,kR).observe(this.defaultSlot,{childList:!0}),EL(this,RR,uy(this.shadowRoot,":host")),yL(this,PR,xR).call(this),this.hasAttribute("disabled")||this.enable(),this.role||(this.role="menu"),EL(this,TR,ty(this)),null==(t=null==(e=gL(this,TR))?void 0:e.associateElement)||t.call(e,this),this.hidden||(XE(LL(this),gL(this,HR)),XE(this,gL(this,GR))),yL(this,DR,CR).call(this),this.shadowRoot.addEventListener("slotchange",this)}disconnectedCallback(){var e,t;gL(this,kR).disconnect(),ZE(LL(this),gL(this,HR)),ZE(this,gL(this,GR)),this.disable(),null==(t=null==(e=gL(this,TR))?void 0:e.unassociateElement)||t.call(e,this),EL(this,TR,null),EL(this,AR,null),EL(this,_R,null),this.shadowRoot.removeEventListener("slotchange",this)}attributeChangedCallback(e,t,i){var r,a,n,s;e===_L&&i!==t?(gL(this,IR)||EL(this,IR,!0),this.hidden?yL(this,BR,$R).call(this):yL(this,UR,FR).call(this),this.dispatchEvent(new fL({oldState:this.hidden?"open":"closed",newState:this.hidden?"closed":"open",bubbles:!0}))):e===nE.MEDIA_CONTROLLER?(t&&(null==(a=null==(r=gL(this,TR))?void 0:r.unassociateElement)||a.call(r,this),EL(this,TR,null)),i&&this.isConnected&&(EL(this,TR,ty(this)),null==(s=null==(n=gL(this,TR))?void 0:n.associateElement)||s.call(n,this))):e===SL&&i!==t?null==i?this.enable():this.disable():e===AL&&i!==t&&yL(this,PR,xR).call(this)}formatMenuItemText(e,t){return this.constructor.formatMenuItemText(e,t)}get anchor(){return this.getAttribute("anchor")}set anchor(e){this.setAttribute("anchor",`${e}`)}get anchorElement(){var e;return this.anchor?null==(e=oy(this))?void 0:e.querySelector(`#${this.anchor}`):null}get items(){return this.defaultSlot.assignedElements({flatten:!0}).filter(RL)}get radioGroupItems(){return this.items.filter(e=>"menuitemradio"===e.role)}get checkedItems(){return this.items.filter(e=>e.checked)}get value(){var e,t;return null!=(t=null==(e=this.checkedItems[0])?void 0:e.value)?t:""}set value(e){let t=this.items.find(t=>t.value===e);t&&yL(this,hL,cL).call(this,t)}focus(){if(EL(this,AR,sy()),this.items.length)return yL(this,dL,uL).call(this,this.items[0]),void this.items[0].focus();let e=this.querySelector('[autofocus], [tabindex]:not([tabindex="-1"]), [role="menu"]');null==e||e.focus()}handleSelect(e){var t;let i=yL(this,nL,sL).call(this,e);i&&(yL(this,hL,cL).call(this,i,"checkbox"===i.type),gL(this,_R)&&!this.hidden&&(null==(t=gL(this,AR))||t.focus(),this.hidden=!0))}get keysUsed(){return["Enter","Escape","Tab"," ","ArrowDown","ArrowUp","Home","End"]}handleMove(e){var t,i;let{key:r}=e,a=this.items,n=null!=(i=null!=(t=yL(this,nL,sL).call(this,e))?t:yL(this,oL,lL).call(this))?i:a[0],s=a.indexOf(n),o=Math.max(0,s);"ArrowDown"===r?o++:"ArrowUp"===r?o--:"Home"===e.key?o=0:"End"===e.key&&(o=a.length-1),o<0&&(o=a.length-1),o>a.length-1&&(o=0),yL(this,dL,uL).call(this,a[o]),a[o].focus()}};function RL(e){return["menuitem","menuitemradio","menuitemcheckbox"].includes(null==e?void 0:e.role)}function LL(e){var t;return null!=(t=e.getAttribute("bounds")?ny(e,`#${e.getAttribute("bounds")}`):ey(e)||e.parentElement)?t:e}TR=new WeakMap,AR=new WeakMap,_R=new WeakMap,SR=new WeakMap,kR=new WeakMap,IR=new WeakMap,RR=new WeakMap,LR=new WeakSet,wR=function(e){let t=e.target;for(let e of t.assignedNodes({flatten:!0}))3===e.nodeType&&""===e.textContent.trim()&&e.remove();["header","title"].includes(t.name)&&yL(this,DR,CR).call(this),t.name||gL(this,MR).call(this)},DR=new WeakSet,CR=function(){let e=this.shadowRoot.querySelector('slot[name="header"]'),t=this.shadowRoot.querySelector('slot[name="title"]');e.hidden=0===t.assignedNodes().length&&0===e.assignedNodes().length},MR=new WeakMap,PR=new WeakSet,xR=function(){var e;let t=this.shadowRoot.querySelector("#layout-row"),i=null==(e=getComputedStyle(this).getPropertyValue("--media-menu-layout"))?void 0:e.trim();t.setAttribute("media","row"===i?"":"width:0")},OR=new WeakSet,NR=function(e){EL(this,_R,e.relatedTarget),ay(this,e.relatedTarget)||(this.hidden=!this.hidden)},UR=new WeakSet,FR=function(){var e;null==(e=gL(this,_R))||e.setAttribute("aria-expanded","true"),this.addEventListener("transitionend",()=>this.focus(),{once:!0}),XE(LL(this),gL(this,HR)),XE(this,gL(this,GR))},BR=new WeakSet,$R=function(){var e;null==(e=gL(this,_R))||e.setAttribute("aria-expanded","false"),ZE(LL(this),gL(this,HR)),ZE(this,gL(this,GR))},HR=new WeakMap,GR=new WeakMap,KR=new WeakSet,WR=function(e){if(this.hasAttribute("mediacontroller")&&!this.anchor||this.hidden||!this.anchorElement)return;let{x:t,y:i}=ER({anchor:this.anchorElement,floating:this,placement:"top-start"});null!=e||(e=this.offsetWidth);let r=LL(this).getBoundingClientRect(),a=r.width-t-e,n=r.height-i-this.offsetHeight,{style:s}=gL(this,RR);s.setProperty("position","absolute"),s.setProperty("right",`${Math.max(0,a)}px`),s.setProperty("--_menu-bottom",`${n}px`);let o=getComputedStyle(this),l=s.getPropertyValue("--_menu-bottom")===o.bottom?n:parseFloat(o.bottom),d=r.height-l-parseFloat(o.marginBottom);this.style.setProperty("--_menu-max-height",`${d}px`)},VR=new WeakSet,qR=function(e){let t=this.querySelector('[role="menuitem"][aria-haspopup][aria-expanded="true"]'),i=null==t?void 0:t.querySelector('[role="menu"]'),{style:r}=gL(this,RR);if(e||r.setProperty("--media-menu-transition-in","none"),i){let e=i.offsetHeight,r=Math.max(i.offsetWidth,t.offsetWidth);this.style.setProperty("min-width",`${r}px`),this.style.setProperty("min-height",`${e}px`),yL(this,KR,WR).call(this,r)}else this.style.removeProperty("min-width"),this.style.removeProperty("min-height"),yL(this,KR,WR).call(this);r.removeProperty("--media-menu-transition-in")},YR=new WeakSet,jR=function(e){var t;if(e.stopPropagation(),e.composedPath().includes(gL(this,zR,QR)))return null==(t=gL(this,AR))||t.focus(),void(this.hidden=!0);let i=yL(this,nL,sL).call(this,e);!i||i.hasAttribute("disabled")||(yL(this,dL,uL).call(this,i),this.handleSelect(e))},zR=new WeakSet,QR=function(){var e;return null==(e=this.shadowRoot.querySelector('slot[name="header"]').assignedElements({flatten:!0}))?void 0:e.find(e=>e.matches('button[part~="back"]'))},XR=new WeakSet,ZR=function(e){if(e.target===this)return;yL(this,JR,eL).call(this);let t=Array.from(this.querySelectorAll('[role="menuitem"][aria-haspopup]'));for(let i of t)i.invokeTargetElement!=e.target&&"open"==e.newState&&"true"==i.getAttribute("aria-expanded")&&!i.invokeTargetElement.hidden&&i.invokeTargetElement.dispatchEvent(new mL({relatedTarget:i}));for(let e of t)e.setAttribute("aria-expanded",`${!e.submenuElement.hidden}`);yL(this,VR,qR).call(this,!0)},JR=new WeakSet,eL=function(){let e=this.querySelector('[role="menuitem"] > [role="menu"]:not([hidden])');this.container.classList.toggle("has-expanded",!!e)},tL=new WeakSet,iL=function(e){var t;ay(this,e.relatedTarget)||(gL(this,IR)&&(null==(t=gL(this,AR))||t.focus()),gL(this,_R)&&gL(this,_R)!==e.relatedTarget&&!this.hidden&&(this.hidden=!0))},rL=new WeakSet,aL=function(e){var t,i,r,a,n;let{key:s,ctrlKey:o,altKey:l,metaKey:d}=e;if(!(o||l||d)&&this.keysUsed.includes(s))if(e.preventDefault(),e.stopPropagation(),"Tab"===s){if(gL(this,IR))return void(this.hidden=!0);e.shiftKey?null==(i=null==(t=this.previousElementSibling)?void 0:t.focus)||i.call(t):null==(a=null==(r=this.nextElementSibling)?void 0:r.focus)||a.call(r),this.blur()}else"Escape"===s?(null==(n=gL(this,AR))||n.focus(),gL(this,IR)&&(this.hidden=!0)):"Enter"===s||" "===s?this.handleSelect(e):this.handleMove(e)},nL=new WeakSet,sL=function(e){return e.composedPath().find(e=>["menuitemradio","menuitemcheckbox"].includes(e.role))},oL=new WeakSet,lL=function(){return this.items.find(e=>0===e.tabIndex)},dL=new WeakSet,uL=function(e){for(let t of this.items)t.tabIndex=t===e?0:-1},hL=new WeakSet,cL=function(e,t){let i=[...this.checkedItems];"radio"===e.type&&this.radioGroupItems.forEach(e=>e.checked=!1),e.checked=!t||!e.checked,this.checkedItems.some((e,t)=>e!=i[t])&&this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))},IL.shadowRootOptions={mode:"open"},IL.getTemplateHTML=function(e){return'\n    <style>\n      :host {\n        font: var(--media-font,\n          var(--media-font-weight, normal)\n          var(--media-font-size, 14px) /\n          var(--media-text-content-height, var(--media-control-height, 24px))\n          var(--media-font-family, helvetica neue, segoe ui, roboto, arial, sans-serif));\n        color: var(--media-text-color, var(--media-primary-color, rgb(238 238 238)));\n        --_menu-bg: rgb(20 20 30 / .8);\n        background: var(--media-menu-background, var(--media-control-background, var(--media-secondary-color, var(--_menu-bg))));\n        border-radius: var(--media-menu-border-radius);\n        border: var(--media-menu-border, none);\n        display: var(--media-menu-display, inline-flex) !important;\n        \n        transition: var(--media-menu-transition-in,\n          visibility 0s,\n          opacity .2s ease-out,\n          transform .15s ease-out,\n          left .2s ease-in-out,\n          min-width .2s ease-in-out,\n          min-height .2s ease-in-out\n        ) !important;\n        \n        visibility: var(--media-menu-visibility, visible);\n        opacity: var(--media-menu-opacity, 1);\n        max-height: var(--media-menu-max-height, var(--_menu-max-height, 300px));\n        transform: var(--media-menu-transform-in, translateY(0) scale(1));\n        flex-direction: column;\n        \n        min-height: 0;\n        position: relative;\n        bottom: var(--_menu-bottom);\n        box-sizing: border-box;\n      } \n\n      @-moz-document url-prefix() {\n        :host{\n          --_menu-bg: rgb(20 20 30);\n        }\n      }\n\n      :host([hidden]) {\n        transition: var(--media-menu-transition-out,\n          visibility .15s ease-in,\n          opacity .15s ease-in,\n          transform .15s ease-in\n        ) !important;\n        visibility: var(--media-menu-hidden-visibility, hidden);\n        opacity: var(--media-menu-hidden-opacity, 0);\n        max-height: var(--media-menu-hidden-max-height,\n          var(--media-menu-max-height, var(--_menu-max-height, 300px)));\n        transform: var(--media-menu-transform-out, translateY(2px) scale(.99));\n        pointer-events: none;\n      }\n\n      :host([slot="submenu"]) {\n        background: none;\n        width: 100%;\n        min-height: 100%;\n        position: absolute;\n        bottom: 0;\n        right: -100%;\n      }\n\n      #container {\n        display: flex;\n        flex-direction: column;\n        min-height: 0;\n        transition: transform .2s ease-out;\n        transform: translate(0, 0);\n      }\n\n      #container.has-expanded {\n        transition: transform .2s ease-in;\n        transform: translate(-100%, 0);\n      }\n\n      button {\n        background: none;\n        color: inherit;\n        border: none;\n        padding: 0;\n        font: inherit;\n        outline: inherit;\n        display: inline-flex;\n        align-items: center;\n      }\n\n      slot[name="header"][hidden] {\n        display: none;\n      }\n\n      slot[name="header"] > *,\n      slot[name="header"]::slotted(*) {\n        padding: .4em .7em;\n        border-bottom: 1px solid rgb(255 255 255 / .25);\n        cursor: var(--media-cursor, default);\n      }\n\n      slot[name="header"] > button[part~="back"],\n      slot[name="header"]::slotted(button[part~="back"]) {\n        cursor: var(--media-cursor, pointer);\n      }\n\n      svg[part~="back"] {\n        height: var(--media-menu-icon-height, var(--media-control-height, 24px));\n        fill: var(--media-icon-color, var(--media-primary-color, rgb(238 238 238)));\n        display: block;\n        margin-right: .5ch;\n      }\n\n      slot:not([name]) {\n        gap: var(--media-menu-gap);\n        flex-direction: var(--media-menu-flex-direction, column);\n        overflow: var(--media-menu-overflow, hidden auto);\n        display: flex;\n        min-height: 0;\n      }\n\n      :host([role="menu"]) slot:not([name]) {\n        padding-block: .4em;\n      }\n\n      slot:not([name])::slotted([role="menu"]) {\n        background: none;\n      }\n\n      media-chrome-menu-item > span {\n        margin-right: .5ch;\n        max-width: var(--media-menu-item-max-width);\n        text-overflow: ellipsis;\n        overflow: hidden;\n      }\n    </style>\n    <style id="layout-row" media="width:0">\n\n      slot[name="header"] > *,\n      slot[name="header"]::slotted(*) {\n        padding: .4em .5em;\n      }\n\n      slot:not([name]) {\n        gap: var(--media-menu-gap, .25em);\n        flex-direction: var(--media-menu-flex-direction, row);\n        padding-inline: .5em;\n      }\n\n      media-chrome-menu-item {\n        padding: .3em .5em;\n      }\n\n      media-chrome-menu-item[aria-checked="true"] {\n        background: var(--media-menu-item-checked-background, rgb(255 255 255 / .2));\n      }\n\n      \n      media-chrome-menu-item::part(checked-indicator) {\n        display: var(--media-menu-item-checked-indicator-display, none);\n      }\n    </style>\n    <div id="container" part="container">\n      <slot name="header" hidden>\n        <button part="back button" aria-label="Back to previous menu">\n          <slot name="back-icon">\n            <svg aria-hidden="true" viewBox="0 0 20 24" part="back indicator">\n              <path d="m11.88 17.585.742-.669-4.2-4.665 4.2-4.666-.743-.669-4.803 5.335 4.803 5.334Z"/>\n            </svg>\n          </slot>\n          <slot name="title"></slot>\n        </button>\n      </slot>\n      <slot></slot>\n    </div>\n    <slot name="checked-indicator" hidden></slot>\n  '},qE.customElements.get("media-chrome-menu")||qE.customElements.define("media-chrome-menu",IL);var wL,DL,CL,ML,PL,xL,OL,NL,UL,FL,BL,$L,HL,GL=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},KL=(e,t,i)=>(GL(e,t,"read from private field"),i?i.call(e):t.get(e)),WL=(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)},VL=(e,t,i,r)=>(GL(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i),qL=(e,t,i)=>(GL(e,t,"access private method"),i);var YL="type",jL="value",zL="checked",QL="disabled",XL=class extends qE.HTMLElement{constructor(){if(super(),WL(this,CL),WL(this,PL),WL(this,OL),WL(this,$L),WL(this,wL,!1),WL(this,DL,void 0),WL(this,UL,()=>{var e,t;this.submenuElement.items&&this.setAttribute("submenusize",`${this.submenuElement.items.length}`);let i=this.shadowRoot.querySelector('slot[name="description"]'),r=null==(e=this.submenuElement.checkedItems)?void 0:e[0],a=null!=(t=null==r?void 0:r.dataset.description)?t:null==r?void 0:r.text,n=YE.createElement("span");n.textContent=null!=a?a:"",i.replaceChildren(n)}),WL(this,FL,e=>{let{key:t}=e;this.keysUsed.includes(t)?this.handleClick(e):this.removeEventListener("keyup",KL(this,FL))}),WL(this,BL,e=>{let{metaKey:t,altKey:i,key:r}=e;t||i||!this.keysUsed.includes(r)?this.removeEventListener("keyup",KL(this,FL)):this.addEventListener("keyup",KL(this,FL),{once:!0})}),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);let e=JE(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e)}}static get observedAttributes(){return[YL,QL,zL,jL]}enable(){this.hasAttribute("tabindex")||this.setAttribute("tabindex","-1"),ZL(this)&&!this.hasAttribute("aria-checked")&&this.setAttribute("aria-checked","false"),this.addEventListener("click",this),this.addEventListener("keydown",this)}disable(){this.removeAttribute("tabindex"),this.removeEventListener("click",this),this.removeEventListener("keydown",this),this.removeEventListener("keyup",this)}handleEvent(e){switch(e.type){case"slotchange":qL(this,CL,ML).call(this,e);break;case"click":this.handleClick(e);break;case"keydown":KL(this,BL).call(this,e);break;case"keyup":KL(this,FL).call(this,e)}}attributeChangedCallback(e,t,i){e===zL&&ZL(this)&&!KL(this,wL)?this.setAttribute("aria-checked",null!=i?"true":"false"):e===YL&&i!==t?this.role="menuitem"+i:e===QL&&i!==t&&(null==i?this.enable():this.disable())}connectedCallback(){this.hasAttribute(QL)||this.enable(),this.role="menuitem"+this.type,VL(this,DL,JL(this,this.parentNode)),qL(this,$L,HL).call(this),this.submenuElement&&qL(this,PL,xL).call(this),this.shadowRoot.addEventListener("slotchange",this)}disconnectedCallback(){this.disable(),qL(this,$L,HL).call(this),VL(this,DL,null),this.shadowRoot.removeEventListener("slotchange",this)}get invokeTarget(){return this.getAttribute("invoketarget")}set invokeTarget(e){this.setAttribute("invoketarget",`${e}`)}get invokeTargetElement(){var e;return this.invokeTarget?null==(e=oy(this))?void 0:e.querySelector(`#${this.invokeTarget}`):this.submenuElement}get submenuElement(){return this.shadowRoot.querySelector('slot[name="submenu"]').assignedElements({flatten:!0})[0]}get type(){var e;return null!=(e=this.getAttribute(YL))?e:""}set type(e){this.setAttribute(YL,`${e}`)}get value(){var e;return null!=(e=this.getAttribute(jL))?e:this.text}set value(e){this.setAttribute(jL,e)}get text(){var e;return(null!=(e=this.textContent)?e:"").trim()}get checked(){if(ZL(this))return"true"===this.getAttribute("aria-checked")}set checked(e){ZL(this)&&(VL(this,wL,!0),this.setAttribute("aria-checked",e?"true":"false"),e?this.part.add("checked"):this.part.remove("checked"))}handleClick(e){ZL(this)||this.invokeTargetElement&&ay(this,e.target)&&this.invokeTargetElement.dispatchEvent(new mL({relatedTarget:this}))}get keysUsed(){return["Enter"," "]}};function ZL(e){return"radio"===e.type||"checkbox"===e.type}function JL(e,t){if(!e)return null;let{host:i}=e.getRootNode();return!t&&i?JL(e,i):null!=t&&t.items?t:JL(t,null==t?void 0:t.parentNode)}wL=new WeakMap,DL=new WeakMap,CL=new WeakSet,ML=function(e){let t=e.target;if(null==t||!t.name)for(let e of t.assignedNodes({flatten:!0}))e instanceof Text&&""===e.textContent.trim()&&e.remove();"submenu"===t.name&&(this.submenuElement?qL(this,PL,xL).call(this):qL(this,OL,NL).call(this))},PL=new WeakSet,xL=async function(){this.setAttribute("aria-haspopup","menu"),this.setAttribute("aria-expanded",`${!this.submenuElement.hidden}`),this.submenuElement.addEventListener("change",KL(this,UL)),this.submenuElement.addEventListener("addmenuitem",KL(this,UL)),this.submenuElement.addEventListener("removemenuitem",KL(this,UL)),KL(this,UL).call(this)},OL=new WeakSet,NL=function(){this.removeAttribute("aria-haspopup"),this.removeAttribute("aria-expanded"),this.submenuElement.removeEventListener("change",KL(this,UL)),this.submenuElement.removeEventListener("addmenuitem",KL(this,UL)),this.submenuElement.removeEventListener("removemenuitem",KL(this,UL)),KL(this,UL).call(this)},UL=new WeakMap,FL=new WeakMap,BL=new WeakMap,$L=new WeakSet,HL=function(){var e;let t=null==(e=KL(this,DL))?void 0:e.radioGroupItems;if(!t)return;let i=t.filter(e=>"true"===e.getAttribute("aria-checked")).pop();i||(i=t[0]);for(let e of t)e.setAttribute("aria-checked","false");null==i||i.setAttribute("aria-checked","true")},XL.shadowRootOptions={mode:"open"},XL.getTemplateHTML=function(e){return`\n    <style>\n      :host {\n        transition: var(--media-menu-item-transition,\n          background .15s linear,\n          opacity .2s ease-in-out\n        );\n        outline: var(--media-menu-item-outline, 0);\n        outline-offset: var(--media-menu-item-outline-offset, -1px);\n        cursor: var(--media-cursor, pointer);\n        display: flex;\n        align-items: center;\n        align-self: stretch;\n        justify-self: stretch;\n        white-space: nowrap;\n        white-space-collapse: collapse;\n        text-wrap: nowrap;\n        padding: .4em .8em .4em 1em;\n      }\n\n      :host(:focus-visible) {\n        box-shadow: var(--media-menu-item-focus-shadow, inset 0 0 0 2px rgb(27 127 204 / .9));\n        outline: var(--media-menu-item-hover-outline, 0);\n        outline-offset: var(--media-menu-item-hover-outline-offset,  var(--media-menu-item-outline-offset, -1px));\n      }\n\n      :host(:hover) {\n        cursor: var(--media-cursor, pointer);\n        background: var(--media-menu-item-hover-background, rgb(92 92 102 / .5));\n        outline: var(--media-menu-item-hover-outline);\n        outline-offset: var(--media-menu-item-hover-outline-offset,  var(--media-menu-item-outline-offset, -1px));\n      }\n\n      :host([aria-checked="true"]) {\n        background: var(--media-menu-item-checked-background);\n      }\n\n      :host([hidden]) {\n        display: none;\n      }\n\n      :host([disabled]) {\n        pointer-events: none;\n        color: rgba(255, 255, 255, .3);\n      }\n\n      slot:not([name]) {\n        width: 100%;\n      }\n\n      slot:not([name="submenu"]) {\n        display: inline-flex;\n        align-items: center;\n        transition: inherit;\n        opacity: var(--media-menu-item-opacity, 1);\n      }\n\n      slot[name="description"] {\n        justify-content: end;\n      }\n\n      slot[name="description"] > span {\n        display: inline-block;\n        margin-inline: 1em .2em;\n        max-width: var(--media-menu-item-description-max-width, 100px);\n        text-overflow: ellipsis;\n        overflow: hidden;\n        font-size: .8em;\n        font-weight: 400;\n        text-align: right;\n        position: relative;\n        top: .04em;\n      }\n\n      slot[name="checked-indicator"] {\n        display: none;\n      }\n\n      :host(:is([role="menuitemradio"],[role="menuitemcheckbox"])) slot[name="checked-indicator"] {\n        display: var(--media-menu-item-checked-indicator-display, inline-block);\n      }\n\n      \n      svg, img, ::slotted(svg), ::slotted(img) {\n        height: var(--media-menu-item-icon-height, var(--media-control-height, 24px));\n        fill: var(--media-icon-color, var(--media-primary-color, rgb(238 238 238)));\n        display: block;\n      }\n\n      \n      [part~="indicator"],\n      ::slotted([part~="indicator"]) {\n        fill: var(--media-menu-item-indicator-fill,\n          var(--media-icon-color, var(--media-primary-color, rgb(238 238 238))));\n        height: var(--media-menu-item-indicator-height, 1.25em);\n        margin-right: .5ch;\n      }\n\n      [part~="checked-indicator"] {\n        visibility: hidden;\n      }\n\n      :host([aria-checked="true"]) [part~="checked-indicator"] {\n        visibility: visible;\n      }\n    </style>\n    <slot name="checked-indicator">\n      <svg aria-hidden="true" viewBox="0 1 24 24" part="checked-indicator indicator">\n        <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"/>\n      </svg>\n    </slot>\n    <slot name="prefix"></slot>\n    <slot></slot>\n    <slot name="description"></slot>\n    <slot name="suffix">\n      ${this.getSuffixSlotInnerHTML(e)}\n    </slot>\n    <slot name="submenu"></slot>\n  `},XL.getSuffixSlotInnerHTML=function(e){return""},qE.customElements.get("media-chrome-menu-item")||qE.customElements.define("media-chrome-menu-item",XL);var ew=class extends IL{get anchorElement(){return"auto"!==this.anchor?super.anchorElement:ey(this).querySelector("media-settings-menu-button")}};ew.getTemplateHTML=function(e){return`\n    ${IL.getTemplateHTML(e)}\n    <style>\n      :host {\n        --_menu-bg: rgb(20 20 30 / .8);\n        background: var(--media-settings-menu-background,\n            var(--media-menu-background,\n              var(--media-control-background,\n                var(--media-secondary-color, var(--_menu-bg)))));\n        min-width: var(--media-settings-menu-min-width, 170px);\n        border-radius: 2px 2px 0 0;\n        overflow: hidden;\n      }\n\n      @-moz-document url-prefix() {\n        :host{\n          --_menu-bg: rgb(20 20 30);\n        }\n      }\n\n      :host([role="menu"]) {\n        \n        justify-content: end;\n      }\n\n      slot:not([name]) {\n        justify-content: var(--media-settings-menu-justify-content);\n        flex-direction: var(--media-settings-menu-flex-direction, column);\n        overflow: visible;\n      }\n\n      #container.has-expanded {\n        --media-settings-menu-item-opacity: 0;\n      }\n    </style>\n  `},qE.customElements.get("media-settings-menu")||qE.customElements.define("media-settings-menu",ew);var tw=class extends XL{};tw.shadowRootOptions={mode:"open"},tw.getTemplateHTML=function(e){return`\n    ${XL.getTemplateHTML.call(this,e)}\n    <style>\n      slot:not([name="submenu"]) {\n        opacity: var(--media-settings-menu-item-opacity, var(--media-menu-item-opacity));\n      }\n\n      :host([aria-expanded="true"]:hover) {\n        background: transparent;\n      }\n    </style>\n  `},tw.getSuffixSlotInnerHTML=function(e){return'\n    <svg aria-hidden="true" viewBox="0 0 20 24">\n      <path d="m8.12 17.585-.742-.669 4.2-4.665-4.2-4.666.743-.669 4.803 5.335-4.803 5.334Z"/>\n    </svg>\n  '},qE.customElements.get("media-settings-menu-item")||qE.customElements.define("media-settings-menu-item",tw);var iw=class extends VA{connectedCallback(){super.connectedCallback(),this.invokeTargetElement&&this.setAttribute("aria-haspopup","menu")}get invokeTarget(){return this.getAttribute("invoketarget")}set invokeTarget(e){this.setAttribute("invoketarget",`${e}`)}get invokeTargetElement(){var e;return this.invokeTarget?null==(e=oy(this))?void 0:e.querySelector(`#${this.invokeTarget}`):null}handleClick(){var e;null==(e=this.invokeTargetElement)||e.dispatchEvent(new mL({relatedTarget:this}))}};qE.customElements.get("media-chrome-menu-button")||qE.customElements.define("media-chrome-menu-button",iw);var rw=class extends iw{static get observedAttributes(){return[...super.observedAttributes,"target"]}connectedCallback(){super.connectedCallback(),this.setAttribute("aria-label",xE("settings"))}get invokeTargetElement(){return null!=this.invokeTarget?super.invokeTargetElement:ey(this).querySelector("media-settings-menu")}};rw.getSlotTemplateHTML=function(){return'\n    <style>\n      :host([aria-expanded="true"]) slot[name=tooltip] {\n        display: none;\n      }\n    </style>\n    <slot name="icon">\n      <svg aria-hidden="true" viewBox="0 0 24 24">\n        <path d="M4.5 14.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5Zm7.5 0a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5Zm7.5 0a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5Z"/>\n      </svg>\n    </slot>\n  '},rw.getTooltipContentHTML=function(){return xE("Settings")},qE.customElements.get("media-settings-menu-button")||qE.customElements.define("media-settings-menu-button",rw);var aw,nw,sw,ow,lw,dw,uw=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},hw=(e,t,i)=>(uw(e,t,"read from private field"),i?i.call(e):t.get(e)),cw=(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)},mw=(e,t,i,r)=>(uw(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i),fw=(e,t,i)=>(uw(e,t,"access private method"),i);aw=new WeakMap,nw=new WeakMap,sw=new WeakSet,ow=function(){if(hw(this,nw)===JSON.stringify(this.mediaAudioTrackList))return;mw(this,nw,JSON.stringify(this.mediaAudioTrackList));let e=this.mediaAudioTrackList;this.defaultSlot.textContent="",e.sort((e,t)=>e.id.localeCompare(t.id,void 0,{numeric:!0}));for(let t of e){let e=bL({type:"radio",text:this.formatMenuItemText(t.label,t),value:`${t.id}`,checked:t.enabled});e.prepend(TL(this,"checked-indicator")),this.defaultSlot.append(e)}},lw=new WeakSet,dw=function(){if(null==this.value)return;let e=new qE.CustomEvent(aE.MEDIA_AUDIO_TRACK_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(e)},qE.customElements.get("media-audio-track-menu")||qE.customElements.define("media-audio-track-menu",class extends IL{constructor(){super(...arguments),cw(this,sw),cw(this,lw),cw(this,aw,[]),cw(this,nw,void 0)}static get observedAttributes(){return[...super.observedAttributes,lE.MEDIA_AUDIO_TRACK_LIST,lE.MEDIA_AUDIO_TRACK_ENABLED,lE.MEDIA_AUDIO_TRACK_UNAVAILABLE]}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===lE.MEDIA_AUDIO_TRACK_ENABLED&&t!==i?this.value=i:e===lE.MEDIA_AUDIO_TRACK_LIST&&t!==i&&(mw(this,aw,function(e){return null==e?void 0:e.split(/\s+/).map(SE)}(null!=i?i:"")),fw(this,sw,ow).call(this))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",fw(this,lw,dw))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",fw(this,lw,dw))}get anchorElement(){var e;return"auto"!==this.anchor?super.anchorElement:null==(e=ey(this))?void 0:e.querySelector("media-audio-track-menu-button")}get mediaAudioTrackList(){return hw(this,aw)}set mediaAudioTrackList(e){mw(this,aw,e),fw(this,sw,ow).call(this)}get mediaAudioTrackEnabled(){var e;return null!=(e=py(this,lE.MEDIA_AUDIO_TRACK_ENABLED))?e:""}set mediaAudioTrackEnabled(e){gy(this,lE.MEDIA_AUDIO_TRACK_ENABLED,e)}});var pw=e=>{let t=xE("Audio");e.setAttribute("aria-label",t)},gw=class extends iw{static get observedAttributes(){return[...super.observedAttributes,lE.MEDIA_AUDIO_TRACK_ENABLED,lE.MEDIA_AUDIO_TRACK_UNAVAILABLE]}connectedCallback(){super.connectedCallback(),pw(this)}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===lE.MEDIA_LANG&&pw(this)}get invokeTargetElement(){var e;return null!=this.invokeTarget?super.invokeTargetElement:null==(e=ey(this))?void 0:e.querySelector("media-audio-track-menu")}get mediaAudioTrackEnabled(){var e;return null!=(e=py(this,lE.MEDIA_AUDIO_TRACK_ENABLED))?e:""}set mediaAudioTrackEnabled(e){gy(this,lE.MEDIA_AUDIO_TRACK_ENABLED,e)}};gw.getSlotTemplateHTML=function(){return'\n    <style>\n      :host([aria-expanded="true"]) slot[name=tooltip] {\n        display: none;\n      }\n    </style>\n    <slot name="icon"><svg aria-hidden="true" viewBox="0 0 24 24">\n  <path d="M11 17H9.5V7H11v10Zm-3-3H6.5v-4H8v4Zm6-5h-1.5v6H14V9Zm3 7h-1.5V8H17v8Z"/>\n  <path d="M22 12c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10Zm-2 0a8 8 0 1 0-16 0 8 8 0 0 0 16 0Z"/>\n</svg></slot>\n  '},gw.getTooltipContentHTML=function(){return xE("Audio")},qE.customElements.get("media-audio-track-menu-button")||qE.customElements.define("media-audio-track-menu-button",gw);var vw,Ew,yw,bw,Tw,Aw=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},_w=(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)},Sw=(e,t,i)=>(Aw(e,t,"access private method"),i);var kw=class extends IL{constructor(){super(...arguments),_w(this,Ew),_w(this,bw),_w(this,vw,void 0)}static get observedAttributes(){return[...super.observedAttributes,lE.MEDIA_SUBTITLES_LIST,lE.MEDIA_SUBTITLES_SHOWING]}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===lE.MEDIA_SUBTITLES_LIST&&t!==i?Sw(this,Ew,yw).call(this):e===lE.MEDIA_SUBTITLES_SHOWING&&t!==i&&(this.value=i||"",Sw(this,Ew,yw).call(this))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",Sw(this,bw,Tw))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",Sw(this,bw,Tw))}get anchorElement(){return"auto"!==this.anchor?super.anchorElement:ey(this).querySelector("media-captions-menu-button")}get mediaSubtitlesList(){return Iw(this,lE.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){Rw(this,lE.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return Iw(this,lE.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){Rw(this,lE.MEDIA_SUBTITLES_SHOWING,e)}};vw=new WeakMap,Ew=new WeakSet,yw=function(){var e;let t=((e,t,i)=>(Aw(e,t,"read from private field"),i?i.call(e):t.get(e)))(this,vw)!==JSON.stringify(this.mediaSubtitlesList),i=this.value!==this.getAttribute(lE.MEDIA_SUBTITLES_SHOWING);if(!t&&!i)return;((e,t,i,r)=>{Aw(e,t,"write to private field"),r?r.call(e,i):t.set(e,i)})(this,vw,JSON.stringify(this.mediaSubtitlesList)),this.defaultSlot.textContent="";let r=!this.value,a=bL({type:"radio",text:this.formatMenuItemText(xE("Off")),value:"off",checked:r});a.prepend(TL(this,"checked-indicator")),this.defaultSlot.append(a);let n=this.mediaSubtitlesList;for(let t of n){let i=bL({type:"radio",text:this.formatMenuItemText(t.label,t),value:dT(t),checked:this.value==dT(t)});i.prepend(TL(this,"checked-indicator")),"captions"===(null!=(e=t.kind)?e:"subs")&&i.append(TL(this,"captions-indicator")),this.defaultSlot.append(i)}},bw=new WeakSet,Tw=function(){let e=this.mediaSubtitlesShowing,t=this.getAttribute(lE.MEDIA_SUBTITLES_SHOWING),i=this.value!==t;if(null!=e&&e.length&&i&&this.dispatchEvent(new qE.CustomEvent(aE.MEDIA_DISABLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:e})),!this.value||!i)return;let r=new qE.CustomEvent(aE.MEDIA_SHOW_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(r)},kw.getTemplateHTML=function(e){return`\n    ${IL.getTemplateHTML(e)}\n    <slot name="captions-indicator" hidden>\n  <svg aria-hidden="true" viewBox="0 0 26 24" part="captions-indicator indicator">\n    <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 0 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"/>\n  </svg></slot>\n  `};var Iw=(e,t)=>{let i=e.getAttribute(t);return i?oT(i):[]},Rw=(e,t,i)=>{if(null==i||!i.length)return void e.removeAttribute(t);let r=uT(i);e.getAttribute(t)!==r&&e.setAttribute(t,r)};qE.customElements.get("media-captions-menu")||qE.customElements.define("media-captions-menu",kw);var Lw=e=>{e.setAttribute("data-captions-enabled",fT(e).toString())},ww=e=>{e.setAttribute("aria-label",xE("closed captions"))},Dw=class extends iw{static get observedAttributes(){return[...super.observedAttributes,lE.MEDIA_SUBTITLES_LIST,lE.MEDIA_SUBTITLES_SHOWING,lE.MEDIA_LANG]}connectedCallback(){super.connectedCallback(),ww(this),Lw(this)}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===lE.MEDIA_SUBTITLES_SHOWING?Lw(this):e===lE.MEDIA_LANG&&ww(this)}get invokeTargetElement(){var e;return null!=this.invokeTarget?super.invokeTargetElement:null==(e=ey(this))?void 0:e.querySelector("media-captions-menu")}get mediaSubtitlesList(){return Cw(this,lE.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){Mw(this,lE.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return Cw(this,lE.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){Mw(this,lE.MEDIA_SUBTITLES_SHOWING,e)}};Dw.getSlotTemplateHTML=function(){return'\n    <style>\n      :host([data-captions-enabled="true"]) slot[name=off] {\n        display: none !important;\n      }\n\n      \n      :host(:not([data-captions-enabled="true"])) slot[name=on] {\n        display: none !important;\n      }\n\n      :host([aria-expanded="true"]) slot[name=tooltip] {\n        display: none;\n      }\n    </style>\n\n    <slot name="icon">\n      <slot name="on"><svg aria-hidden="true" viewBox="0 0 26 24">\n  <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 0 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"/>\n</svg></slot>\n      <slot name="off"><svg aria-hidden="true" viewBox="0 0 26 24">\n  <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"/>\n</svg></slot>\n    </slot>\n  '},Dw.getTooltipContentHTML=function(){return xE("Captions")};var Cw=(e,t)=>{let i=e.getAttribute(t);return i?oT(i):[]},Mw=(e,t,i)=>{if(null==i||!i.length)return void e.removeAttribute(t);let r=uT(i);e.getAttribute(t)!==r&&e.setAttribute(t,r)};qE.customElements.get("media-captions-menu-button")||qE.customElements.define("media-captions-menu-button",Dw);var Pw,xw,Ow,Nw,Uw,Fw=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},Bw=(e,t,i)=>(Fw(e,t,"read from private field"),i?i.call(e):t.get(e)),$w=(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)},Hw=(e,t,i)=>(Fw(e,t,"access private method"),i),Gw="rates";Pw=new WeakMap,xw=new WeakSet,Ow=function(){this.defaultSlot.textContent="";let e=DS(this.mediaPlaybackRate),t=new Set(Array.from(Bw(this,Pw)).map(e=>DS(Number(e))));e>0&&!t.has(e)&&t.add(e);let i=Array.from(t).sort((e,t)=>e-t);for(let t of i){let i=bL({type:"radio",text:this.formatMenuItemText(`${t}x`,t),value:t.toString(),checked:e===t});i.prepend(TL(this,"checked-indicator")),this.defaultSlot.append(i)}},Nw=new WeakSet,Uw=function(){if(!this.value)return;let e=new qE.CustomEvent(aE.MEDIA_PLAYBACK_RATE_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(e)},qE.customElements.get("media-playback-rate-menu")||qE.customElements.define("media-playback-rate-menu",class extends IL{constructor(){super(),$w(this,xw),$w(this,Nw),$w(this,Pw,new $b(this,Gw,{defaultValue:wS})),Hw(this,xw,Ow).call(this)}static get observedAttributes(){return[...super.observedAttributes,lE.MEDIA_PLAYBACK_RATE,Gw]}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===lE.MEDIA_PLAYBACK_RATE&&t!=i?(this.value=i,Hw(this,xw,Ow).call(this)):e===Gw&&t!=i&&(Bw(this,Pw).value=i,Hw(this,xw,Ow).call(this))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",Hw(this,Nw,Uw))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",Hw(this,Nw,Uw))}get anchorElement(){return"auto"!==this.anchor?super.anchorElement:ey(this).querySelector("media-playback-rate-menu-button")}get rates(){return Bw(this,Pw)}set rates(e){e?Array.isArray(e)?Bw(this,Pw).value=e.join(" "):"string"==typeof e&&(Bw(this,Pw).value=e):Bw(this,Pw).value="",Hw(this,xw,Ow).call(this)}get mediaPlaybackRate(){return hy(this,lE.MEDIA_PLAYBACK_RATE,1)}set mediaPlaybackRate(e){cy(this,lE.MEDIA_PLAYBACK_RATE,e)}});var Kw=class extends iw{static get observedAttributes(){return[...super.observedAttributes,lE.MEDIA_PLAYBACK_RATE]}constructor(){var e;super(),this.container=this.shadowRoot.querySelector('slot[name="icon"]'),this.container.innerHTML=`${DS(null!=(e=this.mediaPlaybackRate)?e:1)}x`}attributeChangedCallback(e,t,i){if(super.attributeChangedCallback(e,t,i),e===lE.MEDIA_PLAYBACK_RATE){let e=i?+i:Number.NaN,t=DS(Number.isNaN(e)?1:e);this.container.innerHTML=`${t}x`,this.setAttribute("aria-label",xE("Playback rate {playbackRate}",{playbackRate:t}))}}get invokeTargetElement(){return null!=this.invokeTarget?super.invokeTargetElement:ey(this).querySelector("media-playback-rate-menu")}get mediaPlaybackRate(){return hy(this,lE.MEDIA_PLAYBACK_RATE,1)}set mediaPlaybackRate(e){cy(this,lE.MEDIA_PLAYBACK_RATE,e)}};Kw.getSlotTemplateHTML=function(e){return`\n    <style>\n      :host {\n        min-width: 5ch;\n        padding: var(--media-button-padding, var(--media-control-padding, 10px 5px));\n      }\n\n      :host([aria-expanded="true"]) slot {\n        display: block;\n      }\n\n      :host([aria-expanded="true"]) slot[name=tooltip] {\n        display: none;\n      }\n    </style>\n    <slot name="icon">${e.mediaplaybackrate?DS(+e.mediaplaybackrate):1}x</slot>\n  `},Kw.getTooltipContentHTML=function(){return xE("Playback rate")},qE.customElements.get("media-playback-rate-menu-button")||qE.customElements.define("media-playback-rate-menu-button",Kw);var Ww,Vw,qw,Yw,jw,zw,Qw=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},Xw=(e,t,i)=>(Qw(e,t,"read from private field"),i?i.call(e):t.get(e)),Zw=(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)},Jw=(e,t,i,r)=>(Qw(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i),eD=(e,t,i)=>(Qw(e,t,"access private method"),i);Ww=new WeakMap,Vw=new WeakMap,qw=new WeakSet,Yw=function(){let e=!this.mediaRenditionSelected;if(Xw(this,Vw).mediaRenditionList===JSON.stringify(this.mediaRenditionList)&&Xw(this,Vw).mediaHeight===this.mediaHeight&&Xw(this,Vw).mediaWidth===this.mediaWidth&&Xw(this,Vw).isAuto===e)return;Xw(this,Vw).mediaRenditionList=JSON.stringify(this.mediaRenditionList),Xw(this,Vw).mediaHeight=this.mediaHeight,Xw(this,Vw).mediaWidth=this.mediaWidth,Xw(this,Vw).isAuto=e;let t=this.mediaRenditionList.sort(this.compareRendition.bind(this)),i=t.find(e=>e.id===this.mediaRenditionSelected);for(let e of t)e.selected=e===i;this.defaultSlot.textContent="";for(let i of t){let t=bL({type:"radio",text:this.formatRendition(i,{showBitrate:this.showRenditionBitrate(i)}),value:`${i.id}`,checked:i.selected&&!e});t.prepend(TL(this,"checked-indicator")),this.defaultSlot.append(t)}let r,a=i&&this.showRenditionBitrate(i);e&&(i?r=this.formatMenuItemText(`${xE("Auto")} • ${this.formatRendition(i,{showBitrate:a})}`,i):this.mediaHeight>0&&this.mediaWidth>0&&(r=this.formatMenuItemText(`${xE("Auto")} (${Math.min(this.mediaWidth,this.mediaHeight)}p)`))),r||(r=this.formatMenuItemText(xE("Auto")));let n=bL({type:"radio",text:r,value:"auto",checked:e});n.dataset.description=r,n.prepend(TL(this,"checked-indicator")),this.defaultSlot.append(n)},jw=new WeakSet,zw=function(){if(null==this.value)return;let e=new qE.CustomEvent(aE.MEDIA_RENDITION_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(e)},qE.customElements.get("media-rendition-menu")||qE.customElements.define("media-rendition-menu",class extends IL{constructor(){super(...arguments),Zw(this,qw),Zw(this,jw),Zw(this,Ww,[]),Zw(this,Vw,{})}static get observedAttributes(){return[...super.observedAttributes,lE.MEDIA_RENDITION_LIST,lE.MEDIA_RENDITION_SELECTED,lE.MEDIA_RENDITION_UNAVAILABLE,lE.MEDIA_HEIGHT,lE.MEDIA_WIDTH]}static formatMenuItemText(e,t){return super.formatMenuItemText(e,t)}static formatRendition(e,{showBitrate:t=!1}={}){let i=`${Math.min(e.width,e.height)}p`;if(t&&e.bitrate){let t=e.bitrate/1e6;return`${i} (${`${t.toFixed(t<1?1:0)} Mbps`})`}return this.formatMenuItemText(i,e)}static compareRendition(e,t){var i,r;return t.height===e.height?(null!=(i=t.bitrate)?i:0)-(null!=(r=e.bitrate)?r:0):t.height-e.height}attributeChangedCallback(e,t,i){if(super.attributeChangedCallback(e,t,i),t!==i)switch(e){case lE.MEDIA_RENDITION_SELECTED:this.value=null!=i?i:"auto",eD(this,qw,Yw).call(this);break;case lE.MEDIA_RENDITION_LIST:Jw(this,Ww,function(e){return null==e?void 0:e.split(/\s+/).map(AE)}(i)),eD(this,qw,Yw).call(this);break;case lE.MEDIA_HEIGHT:case lE.MEDIA_WIDTH:eD(this,qw,Yw).call(this)}}connectedCallback(){super.connectedCallback(),this.addEventListener("change",eD(this,jw,zw))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",eD(this,jw,zw))}get anchorElement(){return"auto"!==this.anchor?super.anchorElement:ey(this).querySelector("media-rendition-menu-button")}get mediaRenditionList(){return Xw(this,Ww)}set mediaRenditionList(e){Jw(this,Ww,e),eD(this,qw,Yw).call(this)}get mediaRenditionSelected(){return py(this,lE.MEDIA_RENDITION_SELECTED)}set mediaRenditionSelected(e){gy(this,lE.MEDIA_RENDITION_SELECTED,e)}get mediaHeight(){return hy(this,lE.MEDIA_HEIGHT)}set mediaHeight(e){cy(this,lE.MEDIA_HEIGHT,e)}get mediaWidth(){return hy(this,lE.MEDIA_WIDTH)}set mediaWidth(e){cy(this,lE.MEDIA_WIDTH,e)}compareRendition(e,t){return this.constructor.compareRendition(e,t)}formatMenuItemText(e,t){return this.constructor.formatMenuItemText(e,t)}formatRendition(e,t){return this.constructor.formatRendition(e,t)}showRenditionBitrate(e){return this.mediaRenditionList.some(t=>t!==e&&t.height===e.height&&t.bitrate!==e.bitrate)}});var tD=class extends iw{static get observedAttributes(){return[...super.observedAttributes,lE.MEDIA_RENDITION_SELECTED,lE.MEDIA_RENDITION_UNAVAILABLE,lE.MEDIA_HEIGHT]}connectedCallback(){super.connectedCallback(),this.setAttribute("aria-label",xE("quality"))}get invokeTargetElement(){return null!=this.invokeTarget?super.invokeTargetElement:ey(this).querySelector("media-rendition-menu")}get mediaRenditionSelected(){return py(this,lE.MEDIA_RENDITION_SELECTED)}set mediaRenditionSelected(e){gy(this,lE.MEDIA_RENDITION_SELECTED,e)}get mediaHeight(){return hy(this,lE.MEDIA_HEIGHT)}set mediaHeight(e){cy(this,lE.MEDIA_HEIGHT,e)}};tD.getSlotTemplateHTML=function(){return'\n    <style>\n      :host([aria-expanded="true"]) slot[name=tooltip] {\n        display: none;\n      }\n    </style>\n    <slot name="icon"><svg aria-hidden="true" viewBox="0 0 24 24">\n  <path d="M13.5 2.5h2v6h-2v-2h-11v-2h11v-2Zm4 2h4v2h-4v-2Zm-12 4h2v6h-2v-2h-3v-2h3v-2Zm4 2h12v2h-12v-2Zm1 4h2v6h-2v-2h-8v-2h8v-2Zm4 2h7v2h-7v-2Z" />\n</svg></slot>\n  '},tD.getTooltipContentHTML=function(){return xE("Quality")},qE.customElements.get("media-rendition-menu-button")||qE.customElements.define("media-rendition-menu-button",tD);var iD,rD,aD,nD,sD,oD,lD,dD,uD,hD,cD,mD,fD,pD,gD,vD=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},ED=(e,t,i)=>(vD(e,t,"read from private field"),i?i.call(e):t.get(e)),yD=(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)},bD=(e,t,i,r)=>(vD(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i),TD=(e,t,i)=>(vD(e,t,"access private method"),i);var AD=class extends IL{constructor(){super(),yD(this,rD),yD(this,nD),yD(this,oD),yD(this,dD),yD(this,cD),yD(this,iD,!1),yD(this,hD,e=>{let t=e.target,i="VIDEO"===(null==t?void 0:t.nodeName),r=TD(this,dD,uD).call(this,t);(i||r)&&(ED(this,iD)?TD(this,nD,sD).call(this):TD(this,cD,mD).call(this,e))}),yD(this,fD,e=>{let t=e.target,i=this.contains(t),r=2===e.button,a="VIDEO"===(null==t?void 0:t.nodeName),n=TD(this,dD,uD).call(this,t);i||r&&(a||n)||TD(this,nD,sD).call(this)}),yD(this,pD,e=>{"Escape"===e.key&&TD(this,nD,sD).call(this)}),yD(this,gD,e=>{var t,i;let r=e.target;if(null!=(t=r.matches)&&t.call(r,'button[invoke="copy"]')){let e=null==(i=r.closest("media-context-menu-item"))?void 0:i.querySelector('input[slot="copy"]');e&&navigator.clipboard.writeText(e.value)}TD(this,nD,sD).call(this)}),this.setAttribute("noautohide",""),TD(this,rD,aD).call(this)}connectedCallback(){super.connectedCallback(),ey(this).addEventListener("contextmenu",ED(this,hD)),this.addEventListener("click",ED(this,gD))}disconnectedCallback(){super.disconnectedCallback(),ey(this).removeEventListener("contextmenu",ED(this,hD)),this.removeEventListener("click",ED(this,gD)),document.removeEventListener("mousedown",ED(this,fD)),document.removeEventListener("keydown",ED(this,pD))}};iD=new WeakMap,rD=new WeakSet,aD=function(){this.hidden=!ED(this,iD)},nD=new WeakSet,sD=function(){bD(this,iD,!1),TD(this,rD,aD).call(this)},oD=new WeakSet,lD=function(){document.querySelectorAll("media-context-menu").forEach(e=>{var t;e!==this&&TD(t=e,nD,sD).call(t)})},dD=new WeakSet,uD=function(e){return!!e&&(!(!e.hasAttribute("slot")||"media"!==e.getAttribute("slot"))||!(!e.nodeName.includes("-")||!e.tagName.includes("-"))&&(e.hasAttribute("src")||e.hasAttribute("poster")||e.hasAttribute("preload")||e.hasAttribute("playsinline")))},hD=new WeakMap,cD=new WeakSet,mD=function(e){e.preventDefault(),TD(this,oD,lD).call(this),bD(this,iD,!0),this.style.position="fixed",this.style.left=`${e.clientX}px`,this.style.top=`${e.clientY}px`,TD(this,rD,aD).call(this),document.addEventListener("mousedown",ED(this,fD),{once:!0}),document.addEventListener("keydown",ED(this,pD),{once:!0})},fD=new WeakMap,pD=new WeakMap,gD=new WeakMap,AD.getTemplateHTML=function(e){return`\n      ${IL.getTemplateHTML(e)}\n      <style>\n        :host {\n          --_menu-bg: rgb(20 20 30 / .8);\n          background: var(--media-settings-menu-background,\n            var(--media-menu-background,\n              var(--media-control-background,\n                var(--media-secondary-color, var(--_menu-bg)))));\n          min-width: var(--media-settings-menu-min-width, 170px);\n          border-radius: 2px;\n          overflow: hidden;\n        }\n      </style>\n    `},qE.customElements.get("media-context-menu")||qE.customElements.define("media-context-menu",AD);var _D=class extends XL{};_D.shadowRootOptions={mode:"open"},_D.getTemplateHTML=function(e){return`\n    ${XL.getTemplateHTML.call(this,e)}\n    <style>\n        ::slotted(*) {\n            color: var(--media-text-color, white);\n            text-decoration: none;\n            border: none;\n            background: none;\n            cursor: pointer;\n            padding: 0;\n            min-height: var(--media-control-height, 24px);\n        }\n    </style>\n  `},qE.customElements.get("media-context-menu-item")||qE.customElements.define("media-context-menu-item",_D);var SD=e=>{throw TypeError(e)},kD=(e,t,i)=>t.has(e)||SD("Cannot "+i),ID=(e,t,i)=>(kD(e,t,"read from private field"),i?i.call(e):t.get(e)),RD=(e,t,i)=>t.has(e)?SD("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,i),LD=(e,t,i,r)=>(kD(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i),wD=(e,t,i)=>(kD(e,t,"access private method"),i),DD=class{addEventListener(){}removeEventListener(){}dispatchEvent(e){return!0}};if("undefined"==typeof DocumentFragment){class e extends DD{}globalThis.DocumentFragment=e}var CD,MD=class extends DD{},PD={get(e){},define(e,t,i){},getName:e=>null,upgrade(e){},whenDefined:e=>Promise.resolve(MD)};CD=new WeakMap;var xD={document:{createElement:function(e,t){return new MD}},DocumentFragment:DocumentFragment,customElements:PD,CustomEvent:class{constructor(e,t={}){RD(this,CD),LD(this,CD,null==t?void 0:t.detail)}get detail(){return ID(this,CD)}initCustomEvent(){}},EventTarget:DD,HTMLElement:MD,HTMLVideoElement:class extends DD{}},OD="undefined"==typeof window||void 0===globalThis.customElements,ND=OD?xD:globalThis,UD=OD?xD.document:globalThis.document;function FD(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function BD(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function $D(e){return e.replace(/[-_]([a-z])/g,(e,t)=>t.toUpperCase())}function HD(e){if(null==e)return;let t=+e;return Number.isNaN(t)?void 0:t}function GD(e){let t=function(e){let t={};for(let i in e)null!=e[i]&&(t[i]=e[i]);return new URLSearchParams(t)}(e).toString();return t?"?"+t:""}var KD=(e,t)=>!(!e||!t)&&(!!e.contains(t)||KD(e,t.getRootNode().host)),WD="mux.com",VD=(()=>{try{return"3.14.1"}catch{}return"UNKNOWN"})(),qD=()=>VD,YD=e=>{if(e){if([km.LIVE,km.ON_DEMAND].includes(e))return e;if(null!=e&&e.includes("live"))return km.LIVE}},jD={crossorigin:"crossOrigin",playsinline:"playsInline"};function zD(e){var t;return null!=(t=jD[e])?t:$D(e)}var QD,XD,ZD,JD=class{constructor(e,t){RD(this,QD),RD(this,XD),RD(this,ZD,[]),LD(this,QD,e),LD(this,XD,t)}[Symbol.iterator](){return ID(this,ZD).values()}get length(){return ID(this,ZD).length}get value(){var e;return null!=(e=ID(this,ZD).join(" "))?e:""}set value(e){var t;e!==this.value&&(LD(this,ZD,[]),this.add(...null!=(t=null==e?void 0:e.split(" "))?t:[]))}toString(){return this.value}item(e){return ID(this,ZD)[e]}values(){return ID(this,ZD).values()}keys(){return ID(this,ZD).keys()}forEach(e){ID(this,ZD).forEach(e)}add(...e){var t,i;e.forEach(e=>{this.contains(e)||ID(this,ZD).push(e)}),(""!==this.value||null!=(t=ID(this,QD))&&t.hasAttribute(`${ID(this,XD)}`))&&(null==(i=ID(this,QD))||i.setAttribute(`${ID(this,XD)}`,`${this.value}`))}remove(...e){var t;e.forEach(e=>{ID(this,ZD).splice(ID(this,ZD).indexOf(e),1)}),null==(t=ID(this,QD))||t.setAttribute(`${ID(this,XD)}`,`${this.value}`)}contains(e){return ID(this,ZD).includes(e)}toggle(e,t){return void 0!==t?t?(this.add(e),!0):(this.remove(e),!1):this.contains(e)?(this.remove(e),!1):(this.add(e),!0)}replace(e,t){this.remove(e),this.add(t)}};QD=new WeakMap,XD=new WeakMap,ZD=new WeakMap;var eC=`[mux-player ${qD()}]`;function tC(...e){console.warn(eC,...e)}function iC(...e){console.error(eC,...e)}function rC(e){var t;let i=null!=(t=e.message)?t:"";e.context&&(i+=` ${e.context}`),e.file&&(i+=` ${Wm("Read more: ")}\nhttps://github.com/muxinc/elements/blob/main/errors/${e.file}`),tC(i)}var aC={AUTOPLAY:"autoplay",CROSSORIGIN:"crossorigin",LOOP:"loop",MUTED:"muted",PLAYSINLINE:"playsinline",PRELOAD:"preload"},nC={VOLUME:"volume",PLAYBACKRATE:"playbackrate",MUTED:"muted"},sC=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}}),oC=Object.values(aC).filter(e=>aC.PLAYSINLINE!==e),lC=[...oC,...Object.values(nC)],dC=class extends ND.HTMLElement{static get observedAttributes(){return lC}constructor(){super()}attributeChangedCallback(e,t,i){var r,a;switch(e){case nC.MUTED:return void(this.media&&(this.media.muted=null!=i,this.media.defaultMuted=null!=i));case nC.VOLUME:{let e=null!=(r=HD(i))?r:1;return void(this.media&&(this.media.volume=e))}case nC.PLAYBACKRATE:{let e=null!=(a=HD(i))?a:1;return void(this.media&&(this.media.playbackRate=e,this.media.defaultPlaybackRate=e))}}}play(){var e,t;return null!=(t=null==(e=this.media)?void 0:e.play())?t:Promise.reject()}pause(){var e;null==(e=this.media)||e.pause()}load(){var e;null==(e=this.media)||e.load()}get media(){var e;return null==(e=this.shadowRoot)?void 0:e.querySelector("mux-video")}get audioTracks(){return this.media.audioTracks}get videoTracks(){return this.media.videoTracks}get audioRenditions(){return this.media.audioRenditions}get videoRenditions(){return this.media.videoRenditions}get paused(){var e,t;return null==(t=null==(e=this.media)?void 0:e.paused)||t}get duration(){var e,t;return null!=(t=null==(e=this.media)?void 0:e.duration)?t:NaN}get ended(){var e,t;return null!=(t=null==(e=this.media)?void 0:e.ended)&&t}get buffered(){var e,t;return null!=(t=null==(e=this.media)?void 0:e.buffered)?t:sC}get seekable(){var e,t;return null!=(t=null==(e=this.media)?void 0:e.seekable)?t:sC}get readyState(){var e,t;return null!=(t=null==(e=this.media)?void 0:e.readyState)?t:0}get videoWidth(){var e,t;return null!=(t=null==(e=this.media)?void 0:e.videoWidth)?t:0}get videoHeight(){var e,t;return null!=(t=null==(e=this.media)?void 0:e.videoHeight)?t:0}get currentSrc(){var e,t;return null!=(t=null==(e=this.media)?void 0:e.currentSrc)?t:""}get currentTime(){var e,t;return null!=(t=null==(e=this.media)?void 0:e.currentTime)?t:0}set currentTime(e){this.media&&(this.media.currentTime=Number(e))}get volume(){var e,t;return null!=(t=null==(e=this.media)?void 0:e.volume)?t:1}set volume(e){this.media&&(this.media.volume=Number(e))}get playbackRate(){var e,t;return null!=(t=null==(e=this.media)?void 0:e.playbackRate)?t:1}set playbackRate(e){this.media&&(this.media.playbackRate=Number(e))}get defaultPlaybackRate(){var e;return null!=(e=HD(this.getAttribute(nC.PLAYBACKRATE)))?e:1}set defaultPlaybackRate(e){null!=e?this.setAttribute(nC.PLAYBACKRATE,`${e}`):this.removeAttribute(nC.PLAYBACKRATE)}get crossOrigin(){return uC(this,aC.CROSSORIGIN)}set crossOrigin(e){this.setAttribute(aC.CROSSORIGIN,`${e}`)}get autoplay(){return null!=uC(this,aC.AUTOPLAY)}set autoplay(e){e?this.setAttribute(aC.AUTOPLAY,"string"==typeof e?e:""):this.removeAttribute(aC.AUTOPLAY)}get loop(){return null!=uC(this,aC.LOOP)}set loop(e){e?this.setAttribute(aC.LOOP,""):this.removeAttribute(aC.LOOP)}get muted(){var e,t;return null!=(t=null==(e=this.media)?void 0:e.muted)&&t}set muted(e){this.media&&(this.media.muted=!!e)}get defaultMuted(){return null!=uC(this,aC.MUTED)}set defaultMuted(e){e?this.setAttribute(aC.MUTED,""):this.removeAttribute(aC.MUTED)}get playsInline(){return null!=uC(this,aC.PLAYSINLINE)}set playsInline(e){iC("playsInline is set to true by default and is not currently supported as a setter.")}get preload(){return this.media?this.media.preload:this.getAttribute("preload")}set preload(e){["","none","metadata","auto"].includes(e)?this.setAttribute(aC.PRELOAD,e):this.removeAttribute(aC.PRELOAD)}};function uC(e,t){return e.media?e.media.getAttribute(t):e.getAttribute(t)}var hC=dC,cC=new WeakMap,mC=class e{constructor(e,t){this.element=e,this.type=t,this.element.addEventListener(this.type,this);let i=cC.get(this.element);i&&i.set(this.type,this)}set(e){if("function"==typeof e)this.handleEvent=e.bind(this.element);else if("object"==typeof e&&"function"==typeof e.handleEvent)this.handleEvent=e.handleEvent.bind(e);else{this.element.removeEventListener(this.type,this);let e=cC.get(this.element);e&&e.delete(this.type)}}static for(t){cC.has(t.element)||cC.set(t.element,new Map);let i=t.attributeName.slice(2),r=cC.get(t.element);return r&&r.has(i)?r.get(i):new e(t.element,i)}};function fC(e,t){(function(e,t){if(e instanceof $I&&t instanceof Element){let i=e.element;return i[e.attributeName]!==t&&(e.element.removeAttributeNS(e.attributeNamespace,e.attributeName),i[e.attributeName]=t),!0}return!1})(e,t)||function(e,t){if("boolean"==typeof t&&e instanceof $I){let i=e.attributeNamespace;return t!==e.element.hasAttributeNS(i,e.attributeName)&&(e.booleanValue=t),!0}return!1}(e,t)||function(e,t){return!!(e instanceof $I&&e.attributeName.startsWith("on"))&&(mC.for(e).set(t),e.element.removeAttributeNS(e.attributeNamespace,e.attributeName),!0)}(e,t)||function(e,t){return!1===t&&e instanceof HI&&(e.replace(""),!0)}(e,t)||function(e,t){return t instanceof EC&&e instanceof HI&&(t.renderInto(e),!0)}(e,t)||function(e,t){return t instanceof DocumentFragment&&e instanceof HI&&(t.childNodes.length&&e.replace(...t.childNodes),!0)}(e,t)||function(e,t){if(e instanceof $I){let i=e.attributeNamespace,r=e.element.getAttributeNS(i,e.attributeName);return String(t)!==r&&(e.value=String(t)),!0}e.value=String(t)}(e,t)}var pC=new Map,gC=new WeakMap,vC=new WeakMap,EC=class{constructor(e,t,i){this.strings=e,this.values=t,this.processor=i,this.stringsKey=this.strings.join("")}get template(){if(pC.has(this.stringsKey))return pC.get(this.stringsKey);{let e=UD.createElement("template"),t=this.strings.length-1;return e.innerHTML=this.strings.reduce((e,i,r)=>e+i+(r<t?`{{ ${r} }}`:""),""),pC.set(this.stringsKey,e),e}}renderInto(e){var t;let i=this.template;if(gC.get(e)!==i){gC.set(e,i);let t=new PI(i,this.values,this.processor);return vC.set(e,t),void(e instanceof HI?e.replace(...t.children):e.appendChild(t))}let r=vC.get(e);null==(t=null==r?void 0:r.update)||t.call(r,this.values)}},yC={processCallback(e,t,i){var r;if(i)for(let[e,a]of t)if(e in i){fC(a,null!=(r=i[e])?r:"")}}};function bC(e,...t){return new EC(e,t,yC)}var TC=Object.values({TOP:"top",CENTER:"center",BOTTOM:"bottom",LAYER:"layer",MEDIA_LAYER:"media-layer",POSTER_LAYER:"poster-layer",VERTICAL_LAYER:"vertical-layer",CENTERED_LAYER:"centered-layer",GESTURE_LAYER:"gesture-layer",CONTROLLER_LAYER:"controller",BUTTON:"button",RANGE:"range",THUMB:"thumb",DISPLAY:"display",CONTROL_BAR:"control-bar",MENU_BUTTON:"menu-button",MENU:"menu",MENU_ITEM:"menu-item",OPTION:"option",POSTER:"poster",LIVE:"live",PLAY:"play",PRE_PLAY:"pre-play",SEEK_BACKWARD:"seek-backward",SEEK_FORWARD:"seek-forward",MUTE:"mute",CAPTIONS:"captions",AIRPLAY:"airplay",PIP:"pip",FULLSCREEN:"fullscreen",CAST:"cast",PLAYBACK_RATE:"playback-rate",VOLUME:"volume",TIME:"time",TITLE:"title",AUDIO_TRACK:"audio-track",RENDITION:"rendition"}).join(", "),AC=e=>{var t,i,r,a,n,s,o,l,d,u,h,c,m,f,p,g,v,E,y,b,T,A,_,S,k,I,R,L,w,D,C,M,P,x,O,N,U,F,B,$,H,G;return bC`
  <media-theme
    template="${e.themeTemplate||!1}"
    defaultstreamtype="${null!=(t=e.defaultStreamType)&&t}"
    hotkeys="${(e=>{let t=e.hotKeys?`${e.hotKeys}`:"";return"live"===YD(e.streamType)&&(t+=" noarrowleft noarrowright"),t})(e)||!1}"
    nohotkeys="${e.noHotKeys||!e.hasSrc||!1}"
    noautoseektolive="${!(null==(i=e.streamType)||!i.includes(km.LIVE))&&0!==e.targetLiveWindow}"
    novolumepref="${e.novolumepref||!1}"
    nomutedpref="${e.nomutedpref||!1}"
    disabled="${!e.hasSrc||e.isDialogOpen}"
    audio="${null!=(r=e.audio)&&r}"
    style="${null!=(a=function(e){let t="";return Object.entries(e).forEach(([e,i])=>{null!=i&&(t+=`${BD(e)}: ${i}; `)}),t?t.trim():void 0}({"--media-primary-color":e.primaryColor,"--media-secondary-color":e.secondaryColor,"--media-accent-color":e.accentColor}))&&a}"
    defaultsubtitles="${!e.defaultHiddenCaptions}"
    forwardseekoffset="${null!=(n=e.forwardSeekOffset)&&n}"
    backwardseekoffset="${null!=(s=e.backwardSeekOffset)&&s}"
    playbackrates="${null!=(o=e.playbackRates)&&o}"
    defaultshowremainingtime="${null!=(l=e.defaultShowRemainingTime)&&l}"
    defaultduration="${null!=(d=e.defaultDuration)&&d}"
    hideduration="${null!=(u=e.hideDuration)&&u}"
    title="${null!=(h=e.title)&&h}"
    videotitle="${null!=(c=e.videoTitle)&&c}"
    proudlydisplaymuxbadge="${null!=(m=e.proudlyDisplayMuxBadge)&&m}"
    exportparts="${TC}"
  >
    <mux-video
      slot="media"
      inert="${null!=(f=e.noHotKeys)&&f}"
      target-live-window="${null!=(p=e.targetLiveWindow)&&p}"
      stream-type="${null!=(g=YD(e.streamType))&&g}"
      crossorigin="${null!=(v=e.crossOrigin)?v:""}"
      playsinline
      autoplay="${null!=(E=e.autoplay)&&E}"
      muted="${null!=(y=e.muted)&&y}"
      loop="${null!=(b=e.loop)&&b}"
      preload="${null!=(T=e.preload)&&T}"
      debug="${null!=(A=e.debug)&&A}"
      prefer-cmcd="${null!=(_=e.preferCmcd)&&_}"
      disable-tracking="${null!=(S=e.disableTracking)&&S}"
      disable-cookies="${null!=(k=e.disableCookies)&&k}"
      prefer-playback="${null!=(I=e.preferPlayback)&&I}"
      start-time="${null!=e.startTime&&e.startTime}"
      initial-bandwidth-estimate-kbps="${null!=e.initialBandwidthEstimateKbps&&e.initialBandwidthEstimateKbps}"
      initial-estimate-segments="${null!=e.initialEstimateSegments&&e.initialEstimateSegments}"
      min-preload-segments="${null!=e.minPreloadSegments&&e.minPreloadSegments}"
      beacon-collection-domain="${null!=(R=e.beaconCollectionDomain)&&R}"
      player-init-time="${null!=(L=e.playerInitTime)&&L}"
      player-software-name="${null!=(w=e.playerSoftwareName)&&w}"
      player-software-version="${null!=(D=e.playerSoftwareVersion)&&D}"
      env-key="${null!=(C=e.envKey)&&C}"
      custom-domain="${null!=(M=e.customDomain)&&M}"
      src="${e.src?e.src:!!e.playbackId&&dp(e)}"
      cast-src="${e.src?e.src:!!e.playbackId&&dp(e)}"
      cast-receiver="${null!=(P=e.castReceiver)&&P}"
      drm-token="${null!=(O=null==(x=e.tokens)?void 0:x.drm)&&O}"
      playback-token="${null!=(U=null==(N=e.tokens)?void 0:N.playback)&&U}"
      exportparts="video"
      disable-pseudo-ended="${null!=(F=e.disablePseudoEnded)&&F}"
      max-reconnect-retries="${null!=(B=e.maxReconnectRetries)&&B}"
      max-auto-resolution="${null!=($=e.maxAutoResolution)&&$}"
      cap-rendition-to-player-size="${null!=(H=e.capRenditionToPlayerSize)&&H}"
    >
      ${e.storyboard?bC`<track label="thumbnails" default kind="metadata" src="${e.storyboard}" />`:bC``}
      <slot></slot>
    </mux-video>
    <slot name="poster" slot="poster">
      <media-poster-image
        part="poster"
        exportparts="poster, img"
        src="${!!e.poster&&e.poster}"
        placeholdersrc="${null!=(G=e.placeholder)&&G}"
      ></media-poster-image>
    </slot>
  </media-theme>
`},_C=e=>e.charAt(0).toUpperCase()+e.slice(1),SC=(e,t=!1)=>{let i=((e,t=!1)=>{var i,r;if(e.muxCode){let a=_C(null!=(i=e.errorCategory)?i:"video"),n=bm(null!=(r=e.errorCategory)?r:vm);if(e.muxCode===ym.NETWORK_OFFLINE)return Wm("Your device appears to be offline",t);if(e.muxCode===ym.NETWORK_RECONNECTING)return Wm("Reconnecting...",t);if(e.muxCode===ym.NETWORK_TOKEN_EXPIRED)return Wm("{category} URL has expired",t).format({category:a});if([ym.NETWORK_TOKEN_SUB_MISMATCH,ym.NETWORK_TOKEN_AUD_MISMATCH,ym.NETWORK_TOKEN_AUD_MISSING,ym.NETWORK_TOKEN_MALFORMED].includes(e.muxCode))return Wm("{category} URL is formatted incorrectly",t).format({category:a});if(e.muxCode===ym.NETWORK_TOKEN_MISSING)return Wm("Invalid {categoryName} URL",t).format({categoryName:n});if(e.muxCode===ym.NETWORK_NOT_FOUND)return Wm("{category} does not exist",t).format({category:a});if(e.muxCode===ym.NETWORK_NOT_READY){let i="live"===e.streamType?"Live stream":"Video";return Wm("{mediaType} is not currently available",t).format({mediaType:i})}}if(e.code){if(e.code===Am.MEDIA_ERR_NETWORK)return Wm("Network Error",t);if(e.code===Am.MEDIA_ERR_DECODE)return Wm("Media Error",t);if(e.code===Am.MEDIA_ERR_SRC_NOT_SUPPORTED)return Wm("Source Not Supported",t)}return Wm("Error",t)})(e,t).toString(),r=((e,t=!1)=>{var i,r;if(e.reload)return"";if(e.muxCode){let a=_C(null!=(i=e.errorCategory)?i:"video"),n=bm(null!=(r=e.errorCategory)?r:vm);return e.muxCode===ym.NETWORK_OFFLINE?Wm("Check your internet connection and try reloading this video.",t):e.muxCode===ym.NETWORK_RECONNECTING?Wm("Your connection was interrupted. Attempting to resume playback...",t):e.muxCode===ym.NETWORK_TOKEN_EXPIRED?Wm("The video’s secured {tokenNamePrefix}-token has expired.",t).format({tokenNamePrefix:n}):e.muxCode===ym.NETWORK_TOKEN_SUB_MISMATCH?Wm("The video’s playback ID does not match the one encoded in the {tokenNamePrefix}-token.",t).format({tokenNamePrefix:n}):e.muxCode===ym.NETWORK_TOKEN_MALFORMED?Wm("{category} URL is formatted incorrectly",t).format({category:a}):[ym.NETWORK_TOKEN_AUD_MISMATCH,ym.NETWORK_TOKEN_AUD_MISSING].includes(e.muxCode)?Wm("The {tokenNamePrefix}-token is formatted with incorrect information.",t).format({tokenNamePrefix:n}):[ym.NETWORK_TOKEN_MISSING,ym.NETWORK_INVALID_URL].includes(e.muxCode)?Wm("The video URL or {tokenNamePrefix}-token are formatted with incorrect or incomplete information.",t).format({tokenNamePrefix:n}):e.muxCode===ym.NETWORK_NOT_FOUND?"":e.message}return e.code&&(e.code===Am.MEDIA_ERR_NETWORK||e.code===Am.MEDIA_ERR_DECODE||(e.code,Am.MEDIA_ERR_SRC_NOT_SUPPORTED)),e.message})(e,t).toString();return{title:i,message:r,reload:!!e.reload}},kC=(e,t)=>{let i=(e=>{if(e.muxCode){if(e.muxCode===ym.NETWORK_TOKEN_EXPIRED)return"403-expired-token.md";if(e.muxCode===ym.NETWORK_TOKEN_MALFORMED)return"403-malformatted-token.md";if([ym.NETWORK_TOKEN_AUD_MISMATCH,ym.NETWORK_TOKEN_AUD_MISSING].includes(e.muxCode))return"403-incorrect-aud-value.md";if(e.muxCode===ym.NETWORK_TOKEN_SUB_MISMATCH)return"403-playback-id-mismatch.md";if(e.muxCode===ym.NETWORK_TOKEN_MISSING)return"missing-signed-tokens.md";if(e.muxCode===ym.NETWORK_NOT_FOUND)return"404-not-found.md";if(e.muxCode===ym.NETWORK_NOT_READY)return"412-not-playable.md"}if(e.code){if(e.code===Am.MEDIA_ERR_NETWORK)return"";if(e.code===Am.MEDIA_ERR_DECODE)return"media-decode-error.md";if(e.code===Am.MEDIA_ERR_SRC_NOT_SUPPORTED)return"media-src-not-supported.md"}return""})(e);return{message:e.message,context:e.context,file:i}},IC=UD.createElement("template");"innerHTML"in IC&&(IC.innerHTML='<template id="media-theme-gerwig">\n  <style>\n    @keyframes pre-play-hide {\n      0% {\n        transform: scale(1);\n        opacity: 1;\n      }\n\n      30% {\n        transform: scale(0.7);\n      }\n\n      100% {\n        transform: scale(1.5);\n        opacity: 0;\n      }\n    }\n\n    :host {\n      --_primary-color: var(--media-primary-color, #fff);\n      --_secondary-color: var(--media-secondary-color, transparent);\n      --_accent-color: var(--media-accent-color, #fa50b5);\n      --_text-color: var(--media-text-color, #000);\n\n      --media-icon-color: var(--_primary-color);\n      --media-control-background: var(--_secondary-color);\n      --media-control-hover-background: var(--_accent-color);\n      --media-time-buffered-color: rgba(255, 255, 255, 0.4);\n      --media-preview-time-text-shadow: none;\n      --media-control-height: 14px;\n      --media-control-padding: 6px;\n      --media-tooltip-container-margin: 6px;\n      --media-tooltip-distance: 18px;\n\n      color: var(--_primary-color);\n      display: inline-block;\n      width: 100%;\n      height: 100%;\n    }\n\n    :host([audio]) {\n      --_secondary-color: var(--media-secondary-color, black);\n      --media-preview-time-text-shadow: none;\n    }\n\n    :host([audio]) ::slotted([slot=\'media\']) {\n      height: 0px;\n    }\n\n    :host([audio]) media-loading-indicator {\n      display: none;\n    }\n\n    :host([audio]) media-controller {\n      background: transparent;\n    }\n\n    :host([audio]) media-controller::part(vertical-layer) {\n      background: transparent;\n    }\n\n    :host([audio]) media-control-bar {\n      width: 100%;\n      background-color: var(--media-control-background);\n    }\n\n    /*\n     * 0.433s is the transition duration for VTT Regions.\n     * Borrowed here, so the captions don\'t move too fast.\n     */\n    media-controller {\n      --media-webkit-text-track-transform: translateY(0) scale(0.98);\n      --media-webkit-text-track-transition: transform 0.433s ease-out 0.3s;\n    }\n    media-controller:is([mediapaused], :not([userinactive])) {\n      --media-webkit-text-track-transform: translateY(-50px) scale(0.98);\n      --media-webkit-text-track-transition: transform 0.15s ease;\n    }\n\n    /*\n     * CSS specific to iOS devices.\n     * See: https://stackoverflow.com/questions/30102792/css-media-query-to-target-only-ios-devices/60220757#60220757\n     */\n    @supports (-webkit-touch-callout: none) {\n      /* Disable subtitle adjusting for iOS Safari */\n      media-controller[mediaisfullscreen] {\n        --media-webkit-text-track-transform: unset;\n        --media-webkit-text-track-transition: unset;\n      }\n    }\n\n    media-time-range {\n      --media-box-padding-left: 6px;\n      --media-box-padding-right: 6px;\n      --media-range-bar-color: var(--_accent-color);\n      --media-time-range-buffered-color: var(--_primary-color);\n      --media-range-track-color: transparent;\n      --media-range-track-background: rgba(255, 255, 255, 0.4);\n      --media-range-thumb-background: radial-gradient(\n        circle,\n        #000 0%,\n        #000 25%,\n        var(--_accent-color) 25%,\n        var(--_accent-color)\n      );\n      --media-range-thumb-width: 12px;\n      --media-range-thumb-height: 12px;\n      --media-range-thumb-transform: scale(0);\n      --media-range-thumb-transition: transform 0.3s;\n      --media-range-thumb-opacity: 1;\n      --media-preview-background: var(--_primary-color);\n      --media-box-arrow-background: var(--_primary-color);\n      --media-preview-thumbnail-border: 5px solid var(--_primary-color);\n      --media-preview-border-radius: 5px;\n      --media-text-color: var(--_text-color);\n      --media-control-hover-background: transparent;\n      --media-preview-chapter-text-shadow: none;\n      color: var(--_accent-color);\n      padding: 0 6px;\n    }\n\n    :host([audio]) media-time-range {\n      --media-preview-time-padding: 1.5px 6px;\n      --media-preview-box-margin: 0 0 -5px;\n    }\n\n    media-time-range:hover {\n      --media-range-thumb-transform: scale(1);\n    }\n\n    media-preview-thumbnail {\n      border-bottom-width: 0;\n    }\n\n    [part~=\'menu\'] {\n      border-radius: 2px;\n      border: 1px solid rgba(0, 0, 0, 0.1);\n      bottom: 50px;\n      padding: 2.5px 10px;\n    }\n\n    [part~=\'menu\']::part(indicator) {\n      fill: var(--_accent-color);\n    }\n\n    [part~=\'menu\']::part(menu-item) {\n      box-sizing: border-box;\n      display: flex;\n      align-items: center;\n      padding: 6px 10px;\n      min-height: 34px;\n    }\n\n    [part~=\'menu\']::part(checked) {\n      font-weight: 700;\n    }\n\n    media-captions-menu,\n    media-rendition-menu,\n    media-audio-track-menu,\n    media-playback-rate-menu {\n      position: absolute; /* ensure they don\'t take up space in DOM on load */\n      --media-menu-background: var(--_primary-color);\n      --media-menu-item-checked-background: transparent;\n      --media-text-color: var(--_text-color);\n      --media-menu-item-hover-background: transparent;\n      --media-menu-item-hover-outline: var(--_accent-color) solid 1px;\n    }\n\n    media-rendition-menu {\n      min-width: 140px;\n    }\n\n    /* The icon is a circle so make it 16px high instead of 14px for more balance. */\n    media-audio-track-menu-button {\n      --media-control-padding: 5px;\n      --media-control-height: 16px;\n    }\n\n    media-playback-rate-menu-button {\n      --media-control-padding: 6px 3px;\n      min-width: 4.4ch;\n    }\n\n    media-playback-rate-menu {\n      --media-menu-flex-direction: row;\n      --media-menu-item-checked-background: var(--_accent-color);\n      --media-menu-item-checked-indicator-display: none;\n      margin-right: 6px;\n      padding: 0;\n      --media-menu-gap: 0.25em;\n    }\n\n    media-playback-rate-menu[part~=\'menu\']::part(menu-item) {\n      padding: 6px 6px 6px 8px;\n    }\n\n    media-playback-rate-menu[part~=\'menu\']::part(checked) {\n      color: #fff;\n    }\n\n    :host(:not([audio])) media-time-range {\n      /* Adding px is required here for calc() */\n      --media-range-padding: 0px;\n      background: transparent;\n      z-index: 10;\n      height: 10px;\n      bottom: -3px;\n      width: 100%;\n    }\n\n    media-control-bar :is([role=\'button\'], [role=\'switch\'], button) {\n      line-height: 0;\n    }\n\n    media-control-bar :is([part*=\'button\'], [part*=\'range\'], [part*=\'display\']) {\n      border-radius: 3px;\n    }\n\n    .spacer {\n      flex-grow: 1;\n      background-color: var(--media-control-background, rgba(20, 20, 30, 0.7));\n    }\n\n    media-control-bar[slot~=\'top-chrome\'] {\n      min-height: 42px;\n      pointer-events: none;\n    }\n\n    media-control-bar {\n      --gradient-steps:\n        hsl(0 0% 0% / 0) 0%, hsl(0 0% 0% / 0.013) 8.1%, hsl(0 0% 0% / 0.049) 15.5%, hsl(0 0% 0% / 0.104) 22.5%,\n        hsl(0 0% 0% / 0.175) 29%, hsl(0 0% 0% / 0.259) 35.3%, hsl(0 0% 0% / 0.352) 41.2%, hsl(0 0% 0% / 0.45) 47.1%,\n        hsl(0 0% 0% / 0.55) 52.9%, hsl(0 0% 0% / 0.648) 58.8%, hsl(0 0% 0% / 0.741) 64.7%, hsl(0 0% 0% / 0.825) 71%,\n        hsl(0 0% 0% / 0.896) 77.5%, hsl(0 0% 0% / 0.951) 84.5%, hsl(0 0% 0% / 0.987) 91.9%, hsl(0 0% 0%) 100%;\n    }\n\n    :host([title]) media-control-bar[slot=\'top-chrome\']::before,\n    :host([videotitle]) media-control-bar[slot=\'top-chrome\']::before {\n      content: \'\';\n      position: absolute;\n      width: 100%;\n      padding-bottom: min(100px, 25%);\n      background: linear-gradient(to top, var(--gradient-steps));\n      opacity: 0.8;\n      pointer-events: none;\n    }\n\n    :host(:not([audio])) media-control-bar[part~=\'bottom\']::before {\n      content: \'\';\n      position: absolute;\n      width: 100%;\n      bottom: 0;\n      left: 0;\n      padding-bottom: min(100px, 25%);\n      background: linear-gradient(to bottom, var(--gradient-steps));\n      opacity: 0.8;\n      z-index: 1;\n      pointer-events: none;\n    }\n\n    media-control-bar[part~=\'bottom\'] > * {\n      z-index: 20;\n    }\n\n    media-control-bar[part~=\'bottom\'] {\n      padding: 6px 6px;\n    }\n\n    media-control-bar[slot~=\'top-chrome\'] > * {\n      --media-control-background: transparent;\n      --media-control-hover-background: transparent;\n      position: relative;\n    }\n\n    media-controller::part(vertical-layer) {\n      transition: background-color 1s;\n    }\n\n    media-controller:is([mediapaused], :not([userinactive]))::part(vertical-layer) {\n      background-color: var(--controls-backdrop-color, var(--controls, transparent));\n      transition: background-color 0.25s;\n    }\n\n    .center-controls {\n      --media-button-icon-width: 100%;\n      --media-button-icon-height: auto;\n      --media-tooltip-display: none;\n      pointer-events: none;\n      width: 100%;\n      display: flex;\n      flex-flow: row;\n      align-items: center;\n      justify-content: center;\n      paint-order: stroke;\n      stroke: rgba(102, 102, 102, 1);\n      stroke-width: 0.3px;\n      text-shadow:\n        0 0 2px rgb(0 0 0 / 0.25),\n        0 0 6px rgb(0 0 0 / 0.25);\n      filter: drop-shadow(0 0 2px rgb(0 0 0 / 0.25)) drop-shadow(0 0 6px rgb(0 0 0 / 0.25));\n    }\n\n    .center-controls media-play-button {\n      --media-control-background: transparent;\n      --media-control-hover-background: transparent;\n      --media-control-padding: 0;\n      width: 40px;\n    }\n\n    [breakpointsm] .center-controls media-play-button {\n      width: 90px;\n      height: 90px;\n      border-radius: 50%;\n      transition: background 0.4s;\n      padding: 24px;\n      --media-control-background: #000;\n      --media-control-hover-background: var(--_accent-color);\n    }\n\n    .center-controls media-seek-backward-button,\n    .center-controls media-seek-forward-button {\n      --media-control-background: transparent;\n      --media-control-hover-background: transparent;\n      padding: 0;\n      margin: 0 20px;\n      width: max(33px, min(8%, 40px));\n      text-shadow:\n        0 0 2px rgb(0 0 0 / 0.25),\n        0 0 6px rgb(0 0 0 / 0.25);\n    }\n\n    [breakpointsm]:not([audio]) .center-controls.pre-playback {\n      display: grid;\n      align-items: initial;\n      justify-content: initial;\n      height: 100%;\n      overflow: hidden;\n    }\n\n    [breakpointsm]:not([audio]) .center-controls.pre-playback media-play-button {\n      place-self: var(--_pre-playback-place, center);\n      grid-area: 1 / 1;\n      margin: 16px;\n    }\n\n    /* Show and hide controls or pre-playback state */\n\n    [breakpointsm]:is([mediahasplayed], :not([mediapaused])):not([audio])\n      .center-controls.pre-playback\n      media-play-button {\n      /* Using `forwards` would lead to a laggy UI after the animation got in the end state */\n      animation: 0.3s linear pre-play-hide;\n      opacity: 0;\n      pointer-events: none;\n    }\n\n    .autoplay-unmute {\n      --media-control-hover-background: transparent;\n      width: 100%;\n      display: flex;\n      align-items: center;\n      justify-content: center;\n      filter: drop-shadow(0 0 2px rgb(0 0 0 / 0.25)) drop-shadow(0 0 6px rgb(0 0 0 / 0.25));\n    }\n\n    .autoplay-unmute-btn {\n      --media-control-height: 16px;\n      border-radius: 8px;\n      background: #000;\n      color: var(--_primary-color);\n      display: flex;\n      align-items: center;\n      padding: 8px 16px;\n      font-size: 18px;\n      font-weight: 500;\n      cursor: pointer;\n    }\n\n    .autoplay-unmute-btn:hover {\n      background: var(--_accent-color);\n    }\n\n    [breakpointsm] .autoplay-unmute-btn {\n      --media-control-height: 30px;\n      padding: 14px 24px;\n      font-size: 26px;\n    }\n\n    .autoplay-unmute-btn svg {\n      margin: 0 6px 0 0;\n    }\n\n    [breakpointsm] .autoplay-unmute-btn svg {\n      margin: 0 10px 0 0;\n    }\n\n    media-controller:not([audio]):not([mediahasplayed]) *:is(media-control-bar, media-time-range) {\n      display: none;\n    }\n\n    media-error-dialog:not([mediaerrorcode]) {\n      opacity: 0;\n    }\n\n    media-loading-indicator {\n      --media-loading-icon-width: 100%;\n      --media-button-icon-height: auto;\n      display: var(--media-control-display, var(--media-loading-indicator-display, flex));\n      pointer-events: none;\n      position: absolute;\n      width: min(15%, 150px);\n      flex-flow: row;\n      align-items: center;\n      justify-content: center;\n    }\n\n    /* Intentionally don\'t target the div for transition but the children\n     of the div. Prevents messing with media-chrome\'s autohide feature. */\n    media-loading-indicator + div * {\n      transition: opacity 0.15s;\n      opacity: 1;\n    }\n\n    media-loading-indicator[medialoading]:not([mediapaused]) ~ div > * {\n      opacity: 0;\n      transition-delay: 400ms;\n    }\n\n    media-volume-range {\n      width: min(100%, 100px);\n      --media-range-padding-left: 10px;\n      --media-range-padding-right: 10px;\n      --media-range-thumb-width: 12px;\n      --media-range-thumb-height: 12px;\n      --media-range-thumb-background: radial-gradient(\n        circle,\n        #000 0%,\n        #000 25%,\n        var(--_primary-color) 25%,\n        var(--_primary-color)\n      );\n      --media-control-hover-background: none;\n    }\n\n    media-time-display {\n      white-space: nowrap;\n    }\n\n    /* Generic style for explicitly disabled controls */\n    media-control-bar[part~=\'bottom\'] [disabled],\n    media-control-bar[part~=\'bottom\'] [aria-disabled=\'true\'] {\n      opacity: 60%;\n      cursor: not-allowed;\n    }\n\n    media-text-display {\n      --media-font-size: 16px;\n      --media-control-padding: 14px;\n      font-weight: 500;\n    }\n\n    media-play-button.animated *:is(g, path) {\n      transition: all 0.3s;\n    }\n\n    media-play-button.animated[mediapaused] .pause-icon-pt1 {\n      opacity: 0;\n    }\n\n    media-play-button.animated[mediapaused] .pause-icon-pt2 {\n      transform-origin: center center;\n      transform: scaleY(0);\n    }\n\n    media-play-button.animated[mediapaused] .play-icon {\n      clip-path: inset(0 0 0 0);\n    }\n\n    media-play-button.animated:not([mediapaused]) .play-icon {\n      clip-path: inset(0 0 0 100%);\n    }\n\n    media-seek-forward-button,\n    media-seek-backward-button {\n      --media-font-weight: 400;\n    }\n\n    .mute-icon {\n      display: inline-block;\n    }\n\n    .mute-icon :is(path, g) {\n      transition: opacity 0.5s;\n    }\n\n    .muted {\n      opacity: 0;\n    }\n\n    media-mute-button[mediavolumelevel=\'low\'] :is(.volume-medium, .volume-high),\n    media-mute-button[mediavolumelevel=\'medium\'] :is(.volume-high) {\n      opacity: 0;\n    }\n\n    media-mute-button[mediavolumelevel=\'off\'] .unmuted {\n      opacity: 0;\n    }\n\n    media-mute-button[mediavolumelevel=\'off\'] .muted {\n      opacity: 1;\n    }\n\n    /**\n     * Our defaults for these buttons are to hide them at small sizes\n     * users can override this with CSS\n     */\n    media-controller:not([breakpointsm]):not([audio]) {\n      --bottom-play-button: none;\n      --bottom-seek-backward-button: none;\n      --bottom-seek-forward-button: none;\n      --bottom-time-display: none;\n      --bottom-playback-rate-menu-button: none;\n      --bottom-pip-button: none;\n    }\n\n    [part=\'mux-badge\'] {\n      position: absolute;\n      bottom: 10px;\n      right: 10px;\n      z-index: 2;\n      opacity: 0.6;\n      transition:\n        opacity 0.2s ease-in-out,\n        bottom 0.2s ease-in-out;\n    }\n\n    [part=\'mux-badge\']:hover {\n      opacity: 1;\n    }\n\n    [part=\'mux-badge\'] a {\n      font-size: 14px;\n      font-family: var(--_font-family);\n      color: var(--_primary-color);\n      text-decoration: none;\n      display: flex;\n      align-items: center;\n      gap: 5px;\n    }\n\n    [part=\'mux-badge\'] .mux-badge-text {\n      transition: opacity 0.5s ease-in-out;\n      opacity: 0;\n    }\n\n    [part=\'mux-badge\'] .mux-badge-logo {\n      width: 40px;\n      height: auto;\n      display: inline-block;\n    }\n\n    [part=\'mux-badge\'] .mux-badge-logo svg {\n      width: 100%;\n      height: 100%;\n      fill: white;\n    }\n\n    media-controller:not([userinactive]):not([mediahasplayed]) [part=\'mux-badge\'],\n    media-controller:not([userinactive]) [part=\'mux-badge\'],\n    media-controller[mediahasplayed][mediapaused] [part=\'mux-badge\'] {\n      transition: bottom 0.1s ease-in-out;\n    }\n\n    media-controller[userinactive]:not([mediapaused]) [part=\'mux-badge\'] {\n      transition: bottom 0.2s ease-in-out 0.62s;\n    }\n\n    media-controller:not([userinactive]) [part=\'mux-badge\'] .mux-badge-text,\n    media-controller[mediahasplayed][mediapaused] [part=\'mux-badge\'] .mux-badge-text {\n      opacity: 1;\n    }\n\n    media-controller[userinactive]:not([mediapaused]) [part=\'mux-badge\'] .mux-badge-text {\n      opacity: 0;\n    }\n\n    media-controller[userinactive]:not([mediapaused]) [part=\'mux-badge\'] {\n      bottom: 10px;\n    }\n\n    media-controller:not([userinactive]):not([mediahasplayed]) [part=\'mux-badge\'] {\n      bottom: 10px;\n    }\n\n    media-controller:not([userinactive])[mediahasplayed] [part=\'mux-badge\'],\n    media-controller[mediahasplayed][mediapaused] [part=\'mux-badge\'] {\n      bottom: calc(28px + var(--media-control-height, 0px) + var(--media-control-padding, 0px) * 2);\n    }\n  </style>\n\n  <template partial="TitleDisplay">\n    <template if="videotitle">\n      <template if="videotitle != true">\n        <media-text-display part="top title display" class="title-display">{{videotitle}}</media-text-display>\n      </template>\n    </template>\n    <template if="!videotitle">\n      <template if="title">\n        <media-text-display part="top title display" class="title-display">{{title}}</media-text-display>\n      </template>\n    </template>\n  </template>\n\n  <template partial="PlayButton">\n    <media-play-button\n      part="{{section ?? \'bottom\'}} play button"\n      disabled="{{disabled}}"\n      aria-disabled="{{disabled}}"\n      class="animated"\n    >\n      <svg aria-hidden="true" viewBox="0 0 18 14" slot="icon">\n        <g class="play-icon">\n          <path\n            d="M15.5987 6.2911L3.45577 0.110898C2.83667 -0.204202 2.06287 0.189698 2.06287 0.819798V13.1802C2.06287 13.8103 2.83667 14.2042 3.45577 13.8891L15.5987 7.7089C16.2178 7.3938 16.2178 6.6061 15.5987 6.2911Z"\n          />\n        </g>\n        <g class="pause-icon">\n          <path\n            class="pause-icon-pt1"\n            d="M5.90709 0H2.96889C2.46857 0 2.06299 0.405585 2.06299 0.9059V13.0941C2.06299 13.5944 2.46857 14 2.96889 14H5.90709C6.4074 14 6.81299 13.5944 6.81299 13.0941V0.9059C6.81299 0.405585 6.4074 0 5.90709 0Z"\n          />\n          <path\n            class="pause-icon-pt2"\n            d="M15.1571 0H12.2189C11.7186 0 11.313 0.405585 11.313 0.9059V13.0941C11.313 13.5944 11.7186 14 12.2189 14H15.1571C15.6574 14 16.063 13.5944 16.063 13.0941V0.9059C16.063 0.405585 15.6574 0 15.1571 0Z"\n          />\n        </g>\n      </svg>\n    </media-play-button>\n  </template>\n\n  <template partial="PrePlayButton">\n    <media-play-button\n      part="{{section ?? \'center\'}} play button pre-play"\n      disabled="{{disabled}}"\n      aria-disabled="{{disabled}}"\n    >\n      <svg aria-hidden="true" viewBox="0 0 18 14" slot="icon" style="transform: translate(3px, 0)">\n        <path\n          d="M15.5987 6.2911L3.45577 0.110898C2.83667 -0.204202 2.06287 0.189698 2.06287 0.819798V13.1802C2.06287 13.8103 2.83667 14.2042 3.45577 13.8891L15.5987 7.7089C16.2178 7.3938 16.2178 6.6061 15.5987 6.2911Z"\n        />\n      </svg>\n    </media-play-button>\n  </template>\n\n  <template partial="SeekBackwardButton">\n    <media-seek-backward-button\n      seekoffset="{{backwardseekoffset}}"\n      part="{{section ?? \'bottom\'}} seek-backward button"\n      disabled="{{disabled}}"\n      aria-disabled="{{disabled}}"\n    >\n      <svg viewBox="0 0 22 14" aria-hidden="true" slot="icon">\n        <path\n          d="M3.65 2.07888L0.0864 6.7279C-0.0288 6.87812 -0.0288 7.12188 0.0864 7.2721L3.65 11.9211C3.7792 12.0896 4 11.9703 4 11.7321V2.26787C4 2.02968 3.7792 1.9104 3.65 2.07888Z"\n        />\n        <text transform="translate(6 12)" style="font-size: 14px; font-family: \'ArialMT\', \'Arial\'">\n          {{backwardseekoffset}}\n        </text>\n      </svg>\n    </media-seek-backward-button>\n  </template>\n\n  <template partial="SeekForwardButton">\n    <media-seek-forward-button\n      seekoffset="{{forwardseekoffset}}"\n      part="{{section ?? \'bottom\'}} seek-forward button"\n      disabled="{{disabled}}"\n      aria-disabled="{{disabled}}"\n    >\n      <svg viewBox="0 0 22 14" aria-hidden="true" slot="icon">\n        <g>\n          <text transform="translate(-1 12)" style="font-size: 14px; font-family: \'ArialMT\', \'Arial\'">\n            {{forwardseekoffset}}\n          </text>\n          <path\n            d="M18.35 11.9211L21.9136 7.2721C22.0288 7.12188 22.0288 6.87812 21.9136 6.7279L18.35 2.07888C18.2208 1.91041 18 2.02968 18 2.26787V11.7321C18 11.9703 18.2208 12.0896 18.35 11.9211Z"\n          />\n        </g>\n      </svg>\n    </media-seek-forward-button>\n  </template>\n\n  <template partial="MuteButton">\n    <media-mute-button part="bottom mute button" disabled="{{disabled}}" aria-disabled="{{disabled}}">\n      <svg viewBox="0 0 18 14" slot="icon" class="mute-icon" aria-hidden="true">\n        <g class="unmuted">\n          <path\n            d="M6.76786 1.21233L3.98606 3.98924H1.19937C0.593146 3.98924 0.101743 4.51375 0.101743 5.1607V6.96412L0 6.99998L0.101743 7.03583V8.83926C0.101743 9.48633 0.593146 10.0108 1.19937 10.0108H3.98606L6.76773 12.7877C7.23561 13.2547 8 12.9007 8 12.2171V1.78301C8 1.09925 7.23574 0.745258 6.76786 1.21233Z"\n          />\n          <path\n            class="volume-low"\n            d="M10 3.54781C10.7452 4.55141 11.1393 5.74511 11.1393 6.99991C11.1393 8.25471 10.7453 9.44791 10 10.4515L10.7988 11.0496C11.6734 9.87201 12.1356 8.47161 12.1356 6.99991C12.1356 5.52821 11.6735 4.12731 10.7988 2.94971L10 3.54781Z"\n          />\n          <path\n            class="volume-medium"\n            d="M12.3778 2.40086C13.2709 3.76756 13.7428 5.35806 13.7428 7.00026C13.7428 8.64246 13.2709 10.233 12.3778 11.5992L13.2106 12.1484C14.2107 10.6185 14.739 8.83796 14.739 7.00016C14.739 5.16236 14.2107 3.38236 13.2106 1.85156L12.3778 2.40086Z"\n          />\n          <path\n            class="volume-high"\n            d="M15.5981 0.75L14.7478 1.2719C15.7937 2.9919 16.3468 4.9723 16.3468 7C16.3468 9.0277 15.7937 11.0082 14.7478 12.7281L15.5981 13.25C16.7398 11.3722 17.343 9.211 17.343 7C17.343 4.789 16.7398 2.6268 15.5981 0.75Z"\n          />\n        </g>\n        <g class="muted">\n          <path\n            fill-rule="evenodd"\n            clip-rule="evenodd"\n            d="M4.39976 4.98924H1.19937C1.19429 4.98924 1.17777 4.98961 1.15296 5.01609C1.1271 5.04369 1.10174 5.09245 1.10174 5.1607V8.83926C1.10174 8.90761 1.12714 8.95641 1.15299 8.984C1.17779 9.01047 1.1943 9.01084 1.19937 9.01084H4.39977L7 11.6066V2.39357L4.39976 4.98924ZM7.47434 1.92006C7.4743 1.9201 7.47439 1.92002 7.47434 1.92006V1.92006ZM6.76773 12.7877L3.98606 10.0108H1.19937C0.593146 10.0108 0.101743 9.48633 0.101743 8.83926V7.03583L0 6.99998L0.101743 6.96412V5.1607C0.101743 4.51375 0.593146 3.98924 1.19937 3.98924H3.98606L6.76786 1.21233C7.23574 0.745258 8 1.09925 8 1.78301V12.2171C8 12.9007 7.23561 13.2547 6.76773 12.7877Z"\n          />\n          <path\n            fill-rule="evenodd"\n            clip-rule="evenodd"\n            d="M15.2677 9.30323C15.463 9.49849 15.7796 9.49849 15.9749 9.30323C16.1701 9.10796 16.1701 8.79138 15.9749 8.59612L14.2071 6.82841L15.9749 5.06066C16.1702 4.8654 16.1702 4.54882 15.9749 4.35355C15.7796 4.15829 15.4631 4.15829 15.2678 4.35355L13.5 6.1213L11.7322 4.35348C11.537 4.15822 11.2204 4.15822 11.0251 4.35348C10.8298 4.54874 10.8298 4.86532 11.0251 5.06058L12.7929 6.82841L11.0251 8.59619C10.8299 8.79146 10.8299 9.10804 11.0251 9.3033C11.2204 9.49856 11.537 9.49856 11.7323 9.3033L13.5 7.53552L15.2677 9.30323Z"\n          />\n        </g>\n      </svg>\n    </media-mute-button>\n  </template>\n\n  <template partial="PipButton">\n    <media-pip-button part="bottom pip button" disabled="{{disabled}}" aria-disabled="{{disabled}}">\n      <svg viewBox="0 0 18 14" aria-hidden="true" slot="icon">\n        <path\n          d="M15.9891 0H2.011C0.9004 0 0 0.9003 0 2.0109V11.989C0 13.0996 0.9004 14 2.011 14H15.9891C17.0997 14 18 13.0997 18 11.9891V2.0109C18 0.9003 17.0997 0 15.9891 0ZM17 11.9891C17 12.5465 16.5465 13 15.9891 13H2.011C1.4536 13 1.0001 12.5465 1.0001 11.9891V2.0109C1.0001 1.4535 1.4536 0.9999 2.011 0.9999H15.9891C16.5465 0.9999 17 1.4535 17 2.0109V11.9891Z"\n        />\n        <path\n          d="M15.356 5.67822H8.19523C8.03253 5.67822 7.90063 5.81012 7.90063 5.97282V11.3836C7.90063 11.5463 8.03253 11.6782 8.19523 11.6782H15.356C15.5187 11.6782 15.6506 11.5463 15.6506 11.3836V5.97282C15.6506 5.81012 15.5187 5.67822 15.356 5.67822Z"\n        />\n      </svg>\n    </media-pip-button>\n  </template>\n\n  <template partial="CaptionsMenu">\n    <media-captions-menu-button part="bottom captions button">\n      <svg aria-hidden="true" viewBox="0 0 18 14" slot="on">\n        <path\n          d="M15.989 0H2.011C0.9004 0 0 0.9003 0 2.0109V11.9891C0 13.0997 0.9004 14 2.011 14H15.989C17.0997 14 18 13.0997 18 11.9891V2.0109C18 0.9003 17.0997 0 15.989 0ZM4.2292 8.7639C4.5954 9.1902 5.0935 9.4031 5.7233 9.4031C6.1852 9.4031 6.5544 9.301 6.8302 9.0969C7.1061 8.8933 7.2863 8.614 7.3702 8.26H8.4322C8.3062 8.884 8.0093 9.3733 7.5411 9.7273C7.0733 10.0813 6.4703 10.2581 5.732 10.2581C5.108 10.2581 4.5699 10.1219 4.1168 9.8489C3.6637 9.5759 3.3141 9.1946 3.0685 8.7058C2.8224 8.2165 2.6994 7.6511 2.6994 7.009C2.6994 6.3611 2.8224 5.7927 3.0685 5.3034C3.3141 4.8146 3.6637 4.4323 4.1168 4.1559C4.5699 3.88 5.108 3.7418 5.732 3.7418C6.4703 3.7418 7.0733 3.922 7.5411 4.2818C8.0094 4.6422 8.3062 5.1461 8.4322 5.794H7.3702C7.2862 5.4283 7.106 5.1368 6.8302 4.921C6.5544 4.7052 6.1852 4.5968 5.7233 4.5968C5.0934 4.5968 4.5954 4.8116 4.2292 5.2404C3.8635 5.6696 3.6804 6.259 3.6804 7.009C3.6804 7.7531 3.8635 8.3381 4.2292 8.7639ZM11.0974 8.7639C11.4636 9.1902 11.9617 9.4031 12.5915 9.4031C13.0534 9.4031 13.4226 9.301 13.6984 9.0969C13.9743 8.8933 14.1545 8.614 14.2384 8.26H15.3004C15.1744 8.884 14.8775 9.3733 14.4093 9.7273C13.9415 10.0813 13.3385 10.2581 12.6002 10.2581C11.9762 10.2581 11.4381 10.1219 10.985 9.8489C10.5319 9.5759 10.1823 9.1946 9.9367 8.7058C9.6906 8.2165 9.5676 7.6511 9.5676 7.009C9.5676 6.3611 9.6906 5.7927 9.9367 5.3034C10.1823 4.8146 10.5319 4.4323 10.985 4.1559C11.4381 3.88 11.9762 3.7418 12.6002 3.7418C13.3385 3.7418 13.9415 3.922 14.4093 4.2818C14.8776 4.6422 15.1744 5.1461 15.3004 5.794H14.2384C14.1544 5.4283 13.9742 5.1368 13.6984 4.921C13.4226 4.7052 13.0534 4.5968 12.5915 4.5968C11.9616 4.5968 11.4636 4.8116 11.0974 5.2404C10.7317 5.6696 10.5486 6.259 10.5486 7.009C10.5486 7.7531 10.7317 8.3381 11.0974 8.7639Z"\n        />\n      </svg>\n      <svg aria-hidden="true" viewBox="0 0 18 14" slot="off">\n        <path\n          d="M5.73219 10.258C5.10819 10.258 4.57009 10.1218 4.11699 9.8488C3.66389 9.5758 3.31429 9.1945 3.06869 8.7057C2.82259 8.2164 2.69958 7.651 2.69958 7.0089C2.69958 6.361 2.82259 5.7926 3.06869 5.3033C3.31429 4.8145 3.66389 4.4322 4.11699 4.1558C4.57009 3.8799 5.10819 3.7417 5.73219 3.7417C6.47049 3.7417 7.07348 3.9219 7.54128 4.2817C8.00958 4.6421 8.30638 5.146 8.43238 5.7939H7.37039C7.28639 5.4282 7.10618 5.1367 6.83039 4.9209C6.55459 4.7051 6.18538 4.5967 5.72348 4.5967C5.09358 4.5967 4.59559 4.8115 4.22939 5.2403C3.86369 5.6695 3.68058 6.2589 3.68058 7.0089C3.68058 7.753 3.86369 8.338 4.22939 8.7638C4.59559 9.1901 5.09368 9.403 5.72348 9.403C6.18538 9.403 6.55459 9.3009 6.83039 9.0968C7.10629 8.8932 7.28649 8.6139 7.37039 8.2599H8.43238C8.30638 8.8839 8.00948 9.3732 7.54128 9.7272C7.07348 10.0812 6.47049 10.258 5.73219 10.258Z"\n        />\n        <path\n          d="M12.6003 10.258C11.9763 10.258 11.4382 10.1218 10.9851 9.8488C10.532 9.5758 10.1824 9.1945 9.93685 8.7057C9.69075 8.2164 9.56775 7.651 9.56775 7.0089C9.56775 6.361 9.69075 5.7926 9.93685 5.3033C10.1824 4.8145 10.532 4.4322 10.9851 4.1558C11.4382 3.8799 11.9763 3.7417 12.6003 3.7417C13.3386 3.7417 13.9416 3.9219 14.4094 4.2817C14.8777 4.6421 15.1745 5.146 15.3005 5.7939H14.2385C14.1545 5.4282 13.9743 5.1367 13.6985 4.9209C13.4227 4.7051 13.0535 4.5967 12.5916 4.5967C11.9617 4.5967 11.4637 4.8115 11.0975 5.2403C10.7318 5.6695 10.5487 6.2589 10.5487 7.0089C10.5487 7.753 10.7318 8.338 11.0975 8.7638C11.4637 9.1901 11.9618 9.403 12.5916 9.403C13.0535 9.403 13.4227 9.3009 13.6985 9.0968C13.9744 8.8932 14.1546 8.6139 14.2385 8.2599H15.3005C15.1745 8.8839 14.8776 9.3732 14.4094 9.7272C13.9416 10.0812 13.3386 10.258 12.6003 10.258Z"\n        />\n        <path\n          d="M15.9891 1C16.5465 1 17 1.4535 17 2.011V11.9891C17 12.5465 16.5465 13 15.9891 13H2.0109C1.4535 13 1 12.5465 1 11.9891V2.0109C1 1.4535 1.4535 0.9999 2.0109 0.9999L15.9891 1ZM15.9891 0H2.0109C0.9003 0 0 0.9003 0 2.0109V11.9891C0 13.0997 0.9003 14 2.0109 14H15.9891C17.0997 14 18 13.0997 18 11.9891V2.0109C18 0.9003 17.0997 0 15.9891 0Z"\n        />\n      </svg>\n    </media-captions-menu-button>\n    <media-captions-menu\n      hidden\n      anchor="auto"\n      part="bottom captions menu"\n      disabled="{{disabled}}"\n      aria-disabled="{{disabled}}"\n      exportparts="menu-item"\n    >\n      <div slot="checked-indicator">\n        <style>\n          .indicator {\n            position: relative;\n            top: 1px;\n            width: 0.9em;\n            height: auto;\n            fill: var(--_accent-color);\n            margin-right: 5px;\n          }\n\n          [aria-checked=\'false\'] .indicator {\n            display: none;\n          }\n        </style>\n        <svg viewBox="0 0 14 18" class="indicator">\n          <path\n            d="M12.252 3.48c-.115.033-.301.161-.425.291-.059.063-1.407 1.815-2.995 3.894s-2.897 3.79-2.908 3.802c-.013.014-.661-.616-1.672-1.624-.908-.905-1.702-1.681-1.765-1.723-.401-.27-.783-.211-1.176.183a1.285 1.285 0 0 0-.261.342.582.582 0 0 0-.082.35c0 .165.01.205.08.35.075.153.213.296 2.182 2.271 1.156 1.159 2.17 2.159 2.253 2.222.189.143.338.196.539.194.203-.003.412-.104.618-.299.205-.193 6.7-8.693 6.804-8.903a.716.716 0 0 0 .085-.345c.01-.179.005-.203-.062-.339-.124-.252-.45-.531-.746-.639a.784.784 0 0 0-.469-.027"\n            fill-rule="evenodd"\n          />\n        </svg></div\n    ></media-captions-menu>\n  </template>\n\n  <template partial="AirplayButton">\n    <media-airplay-button part="bottom airplay button" disabled="{{disabled}}" aria-disabled="{{disabled}}">\n      <svg viewBox="0 0 18 14" aria-hidden="true" slot="icon">\n        <path\n          d="M16.1383 0H1.8618C0.8335 0 0 0.8335 0 1.8617V10.1382C0 11.1664 0.8335 12 1.8618 12H3.076C3.1204 11.9433 3.1503 11.8785 3.2012 11.826L4.004 11H1.8618C1.3866 11 1 10.6134 1 10.1382V1.8617C1 1.3865 1.3866 0.9999 1.8618 0.9999H16.1383C16.6135 0.9999 17.0001 1.3865 17.0001 1.8617V10.1382C17.0001 10.6134 16.6135 11 16.1383 11H13.9961L14.7989 11.826C14.8499 11.8785 14.8798 11.9432 14.9241 12H16.1383C17.1665 12 18.0001 11.1664 18.0001 10.1382V1.8617C18 0.8335 17.1665 0 16.1383 0Z"\n        />\n        <path\n          d="M9.55061 8.21903C9.39981 8.06383 9.20001 7.98633 9.00011 7.98633C8.80021 7.98633 8.60031 8.06383 8.44951 8.21903L4.09771 12.697C3.62471 13.1838 3.96961 13.9998 4.64831 13.9998H13.3518C14.0304 13.9998 14.3754 13.1838 13.9023 12.697L9.55061 8.21903Z"\n        />\n      </svg>\n    </media-airplay-button>\n  </template>\n\n  <template partial="FullscreenButton">\n    <media-fullscreen-button part="bottom fullscreen button" disabled="{{disabled}}" aria-disabled="{{disabled}}">\n      <svg viewBox="0 0 18 14" aria-hidden="true" slot="enter">\n        <path\n          d="M1.00745 4.39539L1.01445 1.98789C1.01605 1.43049 1.47085 0.978289 2.02835 0.979989L6.39375 0.992589L6.39665 -0.007411L2.03125 -0.020011C0.920646 -0.023211 0.0176463 0.874489 0.0144463 1.98509L0.00744629 4.39539H1.00745Z"\n        />\n        <path\n          d="M17.0144 2.03431L17.0076 4.39541H18.0076L18.0144 2.03721C18.0176 0.926712 17.1199 0.0237125 16.0093 0.0205125L11.6439 0.0078125L11.641 1.00781L16.0064 1.02041C16.5638 1.02201 17.016 1.47681 17.0144 2.03431Z"\n        />\n        <path\n          d="M16.9925 9.60498L16.9855 12.0124C16.9839 12.5698 16.5291 13.022 15.9717 13.0204L11.6063 13.0078L11.6034 14.0078L15.9688 14.0204C17.0794 14.0236 17.9823 13.1259 17.9855 12.0153L17.9925 9.60498H16.9925Z"\n        />\n        <path\n          d="M0.985626 11.9661L0.992426 9.60498H-0.0074737L-0.0142737 11.9632C-0.0174737 13.0738 0.880226 13.9767 1.99083 13.98L6.35623 13.9926L6.35913 12.9926L1.99373 12.98C1.43633 12.9784 0.983926 12.5236 0.985626 11.9661Z"\n        />\n      </svg>\n      <svg viewBox="0 0 18 14" aria-hidden="true" slot="exit">\n        <path\n          d="M5.39655 -0.0200195L5.38955 2.38748C5.38795 2.94488 4.93315 3.39708 4.37565 3.39538L0.0103463 3.38278L0.00744629 4.38278L4.37285 4.39538C5.48345 4.39858 6.38635 3.50088 6.38965 2.39028L6.39665 -0.0200195H5.39655Z"\n        />\n        <path\n          d="M12.6411 2.36891L12.6479 0.0078125H11.6479L11.6411 2.36601C11.6379 3.47651 12.5356 4.37951 13.6462 4.38271L18.0116 4.39531L18.0145 3.39531L13.6491 3.38271C13.0917 3.38111 12.6395 2.92641 12.6411 2.36891Z"\n        />\n        <path\n          d="M12.6034 14.0204L12.6104 11.613C12.612 11.0556 13.0668 10.6034 13.6242 10.605L17.9896 10.6176L17.9925 9.61759L13.6271 9.60499C12.5165 9.60179 11.6136 10.4995 11.6104 11.6101L11.6034 14.0204H12.6034Z"\n        />\n        <path\n          d="M5.359 11.6315L5.3522 13.9926H6.3522L6.359 11.6344C6.3622 10.5238 5.4645 9.62088 4.3539 9.61758L-0.0115043 9.60498L-0.0144043 10.605L4.351 10.6176C4.9084 10.6192 5.3607 11.074 5.359 11.6315Z"\n        />\n      </svg>\n    </media-fullscreen-button>\n  </template>\n\n  <template partial="CastButton">\n    <media-cast-button part="bottom cast button" disabled="{{disabled}}" aria-disabled="{{disabled}}">\n      <svg viewBox="0 0 18 14" aria-hidden="true" slot="enter">\n        <path\n          d="M16.0072 0H2.0291C0.9185 0 0.0181 0.9003 0.0181 2.011V5.5009C0.357 5.5016 0.6895 5.5275 1.0181 5.5669V2.011C1.0181 1.4536 1.4716 1 2.029 1H16.0072C16.5646 1 17.0181 1.4536 17.0181 2.011V11.9891C17.0181 12.5465 16.5646 13 16.0072 13H8.4358C8.4746 13.3286 8.4999 13.6611 8.4999 13.9999H16.0071C17.1177 13.9999 18.018 13.0996 18.018 11.989V2.011C18.0181 0.9003 17.1178 0 16.0072 0ZM0 6.4999V7.4999C3.584 7.4999 6.5 10.4159 6.5 13.9999H7.5C7.5 9.8642 4.1357 6.4999 0 6.4999ZM0 8.7499V9.7499C2.3433 9.7499 4.25 11.6566 4.25 13.9999H5.25C5.25 11.1049 2.895 8.7499 0 8.7499ZM0.0181 11V14H3.0181C3.0181 12.3431 1.675 11 0.0181 11Z"\n        />\n      </svg>\n      <svg viewBox="0 0 18 14" aria-hidden="true" slot="exit">\n        <path\n          d="M15.9891 0H2.01103C0.900434 0 3.35947e-05 0.9003 3.35947e-05 2.011V5.5009C0.338934 5.5016 0.671434 5.5275 1.00003 5.5669V2.011C1.00003 1.4536 1.45353 1 2.01093 1H15.9891C16.5465 1 17 1.4536 17 2.011V11.9891C17 12.5465 16.5465 13 15.9891 13H8.41773C8.45653 13.3286 8.48183 13.6611 8.48183 13.9999H15.989C17.0996 13.9999 17.9999 13.0996 17.9999 11.989V2.011C18 0.9003 17.0997 0 15.9891 0ZM-0.0180664 6.4999V7.4999C3.56593 7.4999 6.48193 10.4159 6.48193 13.9999H7.48193C7.48193 9.8642 4.11763 6.4999 -0.0180664 6.4999ZM-0.0180664 8.7499V9.7499C2.32523 9.7499 4.23193 11.6566 4.23193 13.9999H5.23193C5.23193 11.1049 2.87693 8.7499 -0.0180664 8.7499ZM3.35947e-05 11V14H3.00003C3.00003 12.3431 1.65693 11 3.35947e-05 11Z"\n        />\n        <path d="M2.15002 5.634C5.18352 6.4207 7.57252 8.8151 8.35282 11.8499H15.8501V2.1499H2.15002V5.634Z" />\n      </svg>\n    </media-cast-button>\n  </template>\n\n  <template partial="LiveButton">\n    <media-live-button part="{{section ?? \'top\'}} live button" disabled="{{disabled}}" aria-disabled="{{disabled}}">\n      <span slot="text">Live</span>\n    </media-live-button>\n  </template>\n\n  <template partial="PlaybackRateMenu">\n    <media-playback-rate-menu-button part="bottom playback-rate button"></media-playback-rate-menu-button>\n    <media-playback-rate-menu\n      hidden\n      anchor="auto"\n      rates="{{playbackrates}}"\n      exportparts="menu-item"\n      part="bottom playback-rate menu"\n      disabled="{{disabled}}"\n      aria-disabled="{{disabled}}"\n    ></media-playback-rate-menu>\n  </template>\n\n  <template partial="VolumeRange">\n    <media-volume-range\n      part="bottom volume range"\n      disabled="{{disabled}}"\n      aria-disabled="{{disabled}}"\n    ></media-volume-range>\n  </template>\n\n  <template partial="TimeDisplay">\n    <media-time-display\n      remaining="{{defaultshowremainingtime}}"\n      showduration="{{!hideduration}}"\n      part="bottom time display"\n      disabled="{{disabled}}"\n      aria-disabled="{{disabled}}"\n    ></media-time-display>\n  </template>\n\n  <template partial="TimeRange">\n    <media-time-range part="bottom time range" disabled="{{disabled}}" aria-disabled="{{disabled}}" exportparts="thumb">\n      <media-preview-thumbnail slot="preview"></media-preview-thumbnail>\n      <media-preview-chapter-display slot="preview"></media-preview-chapter-display>\n      <media-preview-time-display slot="preview"></media-preview-time-display>\n      <div slot="preview" part="arrow"></div>\n    </media-time-range>\n  </template>\n\n  <template partial="AudioTrackMenu">\n    <media-audio-track-menu-button part="bottom audio-track button">\n      <svg aria-hidden="true" slot="icon" viewBox="0 0 18 16">\n        <path d="M9 15A7 7 0 1 1 9 1a7 7 0 0 1 0 14Zm0 1A8 8 0 1 0 9 0a8 8 0 0 0 0 16Z" />\n        <path\n          d="M5.2 6.3a.5.5 0 0 1 .5.5v2.4a.5.5 0 1 1-1 0V6.8a.5.5 0 0 1 .5-.5Zm2.4-2.4a.5.5 0 0 1 .5.5v7.2a.5.5 0 0 1-1 0V4.4a.5.5 0 0 1 .5-.5ZM10 5.5a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5Zm2.4-.8a.5.5 0 0 1 .5.5v5.6a.5.5 0 0 1-1 0V5.2a.5.5 0 0 1 .5-.5Z"\n        />\n      </svg>\n    </media-audio-track-menu-button>\n    <media-audio-track-menu\n      hidden\n      anchor="auto"\n      part="bottom audio-track menu"\n      disabled="{{disabled}}"\n      aria-disabled="{{disabled}}"\n      exportparts="menu-item"\n    >\n      <div slot="checked-indicator">\n        <style>\n          .indicator {\n            position: relative;\n            top: 1px;\n            width: 0.9em;\n            height: auto;\n            fill: var(--_accent-color);\n            margin-right: 5px;\n          }\n\n          [aria-checked=\'false\'] .indicator {\n            display: none;\n          }\n        </style>\n        <svg viewBox="0 0 14 18" class="indicator">\n          <path\n            d="M12.252 3.48c-.115.033-.301.161-.425.291-.059.063-1.407 1.815-2.995 3.894s-2.897 3.79-2.908 3.802c-.013.014-.661-.616-1.672-1.624-.908-.905-1.702-1.681-1.765-1.723-.401-.27-.783-.211-1.176.183a1.285 1.285 0 0 0-.261.342.582.582 0 0 0-.082.35c0 .165.01.205.08.35.075.153.213.296 2.182 2.271 1.156 1.159 2.17 2.159 2.253 2.222.189.143.338.196.539.194.203-.003.412-.104.618-.299.205-.193 6.7-8.693 6.804-8.903a.716.716 0 0 0 .085-.345c.01-.179.005-.203-.062-.339-.124-.252-.45-.531-.746-.639a.784.784 0 0 0-.469-.027"\n            fill-rule="evenodd"\n          />\n        </svg>\n      </div>\n    </media-audio-track-menu>\n  </template>\n\n  <template partial="RenditionMenu">\n    <media-rendition-menu-button part="bottom rendition button">\n      <svg aria-hidden="true" slot="icon" viewBox="0 0 18 14">\n        <path\n          d="M2.25 9a2 2 0 1 0 0-4 2 2 0 0 0 0 4ZM9 9a2 2 0 1 0 0-4 2 2 0 0 0 0 4Zm6.75 0a2 2 0 1 0 0-4 2 2 0 0 0 0 4Z"\n        />\n      </svg>\n    </media-rendition-menu-button>\n    <media-rendition-menu\n      hidden\n      anchor="auto"\n      part="bottom rendition menu"\n      disabled="{{disabled}}"\n      aria-disabled="{{disabled}}"\n    >\n      <div slot="checked-indicator">\n        <style>\n          .indicator {\n            position: relative;\n            top: 1px;\n            width: 0.9em;\n            height: auto;\n            fill: var(--_accent-color);\n            margin-right: 5px;\n          }\n\n          [aria-checked=\'false\'] .indicator {\n            opacity: 0;\n          }\n        </style>\n        <svg viewBox="0 0 14 18" class="indicator">\n          <path\n            d="M12.252 3.48c-.115.033-.301.161-.425.291-.059.063-1.407 1.815-2.995 3.894s-2.897 3.79-2.908 3.802c-.013.014-.661-.616-1.672-1.624-.908-.905-1.702-1.681-1.765-1.723-.401-.27-.783-.211-1.176.183a1.285 1.285 0 0 0-.261.342.582.582 0 0 0-.082.35c0 .165.01.205.08.35.075.153.213.296 2.182 2.271 1.156 1.159 2.17 2.159 2.253 2.222.189.143.338.196.539.194.203-.003.412-.104.618-.299.205-.193 6.7-8.693 6.804-8.903a.716.716 0 0 0 .085-.345c.01-.179.005-.203-.062-.339-.124-.252-.45-.531-.746-.639a.784.784 0 0 0-.469-.027"\n            fill-rule="evenodd"\n          />\n        </svg>\n      </div>\n    </media-rendition-menu>\n  </template>\n\n  <template partial="MuxBadge">\n    <div part="mux-badge">\n      <a href="https://www.mux.com/player" target="_blank">\n        <span class="mux-badge-text">Powered by</span>\n        <div class="mux-badge-logo">\n          <svg\n            viewBox="0 0 1600 500"\n            style="fill-rule: evenodd; clip-rule: evenodd; stroke-linejoin: round; stroke-miterlimit: 2"\n          >\n            <g>\n              <path\n                d="M994.287,93.486c-17.121,-0 -31,-13.879 -31,-31c0,-17.121 13.879,-31 31,-31c17.121,-0 31,13.879 31,31c0,17.121 -13.879,31 -31,31m0,-93.486c-34.509,-0 -62.484,27.976 -62.484,62.486l0,187.511c0,68.943 -56.09,125.033 -125.032,125.033c-68.942,-0 -125.03,-56.09 -125.03,-125.033l0,-187.511c0,-34.51 -27.976,-62.486 -62.485,-62.486c-34.509,-0 -62.484,27.976 -62.484,62.486l0,187.511c0,137.853 112.149,250.003 249.999,250.003c137.851,-0 250.001,-112.15 250.001,-250.003l0,-187.511c0,-34.51 -27.976,-62.486 -62.485,-62.486"\n                style="fill-rule: nonzero"\n              ></path>\n              <path\n                d="M1537.51,468.511c-17.121,-0 -31,-13.879 -31,-31c0,-17.121 13.879,-31 31,-31c17.121,-0 31,13.879 31,31c0,17.121 -13.879,31 -31,31m-275.883,-218.509l-143.33,143.329c-24.402,24.402 -24.402,63.966 0,88.368c24.402,24.402 63.967,24.402 88.369,-0l143.33,-143.329l143.328,143.329c24.402,24.4 63.967,24.402 88.369,-0c24.403,-24.402 24.403,-63.966 0.001,-88.368l-143.33,-143.329l0.001,-0.004l143.329,-143.329c24.402,-24.402 24.402,-63.965 0,-88.367c-24.402,-24.402 -63.967,-24.402 -88.369,-0l-143.329,143.328l-143.329,-143.328c-24.402,-24.401 -63.967,-24.402 -88.369,-0c-24.402,24.402 -24.402,63.965 0,88.367l143.329,143.329l0,0.004Z"\n                style="fill-rule: nonzero"\n              ></path>\n              <path\n                d="M437.511,468.521c-17.121,-0 -31,-13.879 -31,-31c0,-17.121 13.879,-31 31,-31c17.121,-0 31,13.879 31,31c0,17.121 -13.879,31 -31,31m23.915,-463.762c-23.348,-9.672 -50.226,-4.327 -68.096,13.544l-143.331,143.329l-143.33,-143.329c-17.871,-17.871 -44.747,-23.216 -68.096,-13.544c-23.349,9.671 -38.574,32.455 -38.574,57.729l0,375.026c0,34.51 27.977,62.486 62.487,62.486c34.51,-0 62.486,-27.976 62.486,-62.486l0,-224.173l80.843,80.844c24.404,24.402 63.965,24.402 88.369,-0l80.843,-80.844l0,224.173c0,34.51 27.976,62.486 62.486,62.486c34.51,-0 62.486,-27.976 62.486,-62.486l0,-375.026c0,-25.274 -15.224,-48.058 -38.573,-57.729"\n                style="fill-rule: nonzero"\n              ></path>\n            </g>\n          </svg>\n        </div>\n      </a>\n    </div>\n  </template>\n\n  <media-controller\n    part="controller"\n    defaultstreamtype="{{defaultstreamtype ?? \'on-demand\'}}"\n    breakpoints="sm:470"\n    gesturesdisabled="{{disabled}}"\n    hotkeys="{{hotkeys}}"\n    nohotkeys="{{nohotkeys}}"\n    novolumepref="{{novolumepref}}"\n    audio="{{audio}}"\n    noautoseektolive="{{noautoseektolive}}"\n    defaultsubtitles="{{defaultsubtitles}}"\n    defaultduration="{{defaultduration ?? false}}"\n    keyboardforwardseekoffset="{{forwardseekoffset}}"\n    keyboardbackwardseekoffset="{{backwardseekoffset}}"\n    exportparts="layer, media-layer, poster-layer, vertical-layer, centered-layer, gesture-layer"\n    style="--_pre-playback-place:{{preplaybackplace ?? \'center\'}}"\n  >\n    <slot name="media" slot="media"></slot>\n    <slot name="poster" slot="poster"></slot>\n\n    <media-loading-indicator slot="centered-chrome" noautohide></media-loading-indicator>\n\n    <template if="!audio">\n      <media-error-dialog slot="dialog" noautohide></media-error-dialog>\n      \x3c!-- Pre-playback UI --\x3e\n      \x3c!-- same for both on-demand and live --\x3e\n      <div slot="centered-chrome" class="center-controls pre-playback">\n        <template if="!breakpointsm">{{>PlayButton section="center"}}</template>\n        <template if="breakpointsm">{{>PrePlayButton section="center"}}</template>\n      </div>\n\n      \x3c!-- Mux Badge --\x3e\n      <template if="proudlydisplaymuxbadge"> {{>MuxBadge}} </template>\n\n      \x3c!-- Autoplay centered unmute button --\x3e\n      \x3c!--\n        todo: figure out how show this with available state variables\n        needs to show when:\n        - autoplay is enabled\n        - playback has been successful\n        - audio is muted\n        - in place / instead of the pre-plaback play button\n        - not to show again after user has interacted with this button\n          - OR user has interacted with the mute button in the control bar\n      --\x3e\n      \x3c!--\n        There should be a >MuteButton to the left of the "Unmute" text, but a templating bug\n        makes it appear even if commented out in the markup, add it back when code is un-commented\n      --\x3e\n      \x3c!-- <div slot="centered-chrome" class="autoplay-unmute">\n        <div role="button" class="autoplay-unmute-btn">Unmute</div>\n      </div> --\x3e\n\n      <template if="streamtype == \'on-demand\'">\n        <template if="breakpointsm">\n          <media-control-bar part="control-bar top" slot="top-chrome">{{>TitleDisplay}} </media-control-bar>\n        </template>\n        {{>TimeRange}}\n        <media-control-bar part="control-bar bottom">\n          {{>PlayButton}} {{>SeekBackwardButton}} {{>SeekForwardButton}} {{>TimeDisplay}} {{>MuteButton}}\n          {{>VolumeRange}}\n          <div class="spacer"></div>\n          {{>RenditionMenu}} {{>PlaybackRateMenu}} {{>AudioTrackMenu}} {{>CaptionsMenu}} {{>AirplayButton}}\n          {{>CastButton}} {{>PipButton}} {{>FullscreenButton}}\n        </media-control-bar>\n      </template>\n\n      <template if="streamtype == \'live\'">\n        <media-control-bar part="control-bar top" slot="top-chrome">\n          {{>LiveButton}}\n          <template if="breakpointsm"> {{>TitleDisplay}} </template>\n        </media-control-bar>\n        <template if="targetlivewindow > 0">{{>TimeRange}}</template>\n        <media-control-bar part="control-bar bottom">\n          {{>PlayButton}}\n          <template if="targetlivewindow > 0">{{>SeekBackwardButton}} {{>SeekForwardButton}}</template>\n          {{>MuteButton}} {{>VolumeRange}}\n          <div class="spacer"></div>\n          {{>RenditionMenu}} {{>AudioTrackMenu}} {{>CaptionsMenu}} {{>AirplayButton}} {{>CastButton}} {{>PipButton}}\n          {{>FullscreenButton}}\n        </media-control-bar>\n      </template>\n    </template>\n\n    <template if="audio">\n      <template if="streamtype == \'on-demand\'">\n        <template if="title">\n          <media-control-bar part="control-bar top">{{>TitleDisplay}}</media-control-bar>\n        </template>\n        <media-control-bar part="control-bar bottom">\n          {{>PlayButton}}\n          <template if="breakpointsm"> {{>SeekBackwardButton}} {{>SeekForwardButton}} </template>\n          {{>MuteButton}}\n          <template if="breakpointsm">{{>VolumeRange}}</template>\n          {{>TimeDisplay}} {{>TimeRange}}\n          <template if="breakpointsm">{{>PlaybackRateMenu}}</template>\n          {{>AirplayButton}} {{>CastButton}}\n        </media-control-bar>\n      </template>\n\n      <template if="streamtype == \'live\'">\n        <template if="title">\n          <media-control-bar part="control-bar top">{{>TitleDisplay}}</media-control-bar>\n        </template>\n        <media-control-bar part="control-bar bottom">\n          {{>PlayButton}} {{>LiveButton section="bottom"}} {{>MuteButton}}\n          <template if="breakpointsm">\n            {{>VolumeRange}}\n            <template if="targetlivewindow > 0"> {{>SeekBackwardButton}} {{>SeekForwardButton}} </template>\n          </template>\n          <template if="targetlivewindow > 0"> {{>TimeDisplay}} {{>TimeRange}} </template>\n          <template if="!targetlivewindow"><div class="spacer"></div></template>\n          {{>AirplayButton}} {{>CastButton}}\n        </media-control-bar>\n      </template>\n    </template>\n\n    <slot></slot>\n  </media-controller>\n</template>\n');var RC,LC,wC=class extends vR{};wC.template=null==(LC=null==(RC=IC.content)?void 0:RC.children)?void 0:LC[0],ND.customElements.get("media-theme-gerwig")||ND.customElements.define("media-theme-gerwig",wC);var DC={SRC:"src",POSTER:"poster"},CC={STYLE:"style",DEFAULT_HIDDEN_CAPTIONS:"default-hidden-captions",PRIMARY_COLOR:"primary-color",SECONDARY_COLOR:"secondary-color",ACCENT_COLOR:"accent-color",FORWARD_SEEK_OFFSET:"forward-seek-offset",BACKWARD_SEEK_OFFSET:"backward-seek-offset",PLAYBACK_TOKEN:"playback-token",THUMBNAIL_TOKEN:"thumbnail-token",STORYBOARD_TOKEN:"storyboard-token",FULLSCREEN_ELEMENT:"fullscreen-element",DRM_TOKEN:"drm-token",STORYBOARD_SRC:"storyboard-src",THUMBNAIL_TIME:"thumbnail-time",AUDIO:"audio",NOHOTKEYS:"nohotkeys",HOTKEYS:"hotkeys",PLAYBACK_RATES:"playbackrates",DEFAULT_SHOW_REMAINING_TIME:"default-show-remaining-time",DEFAULT_DURATION:"default-duration",TITLE:"title",VIDEO_TITLE:"video-title",PLACEHOLDER:"placeholder",THEME:"theme",DEFAULT_STREAM_TYPE:"default-stream-type",TARGET_LIVE_WINDOW:"target-live-window",EXTRA_SOURCE_PARAMS:"extra-source-params",NO_VOLUME_PREF:"no-volume-pref",NO_MUTED_PREF:"no-muted-pref",CAST_RECEIVER:"cast-receiver",NO_TOOLTIPS:"no-tooltips",PROUDLY_DISPLAY_MUX_BADGE:"proudly-display-mux-badge",DISABLE_PSEUDO_ENDED:"disable-pseudo-ended"},MC=["audio","backwardseekoffset","defaultduration","defaultshowremainingtime","defaultsubtitles","noautoseektolive","disabled","exportparts","forwardseekoffset","hideduration","hotkeys","nohotkeys","playbackrates","defaultstreamtype","streamtype","style","targetlivewindow","template","title","videotitle","novolumepref","nomutedpref","proudlydisplaymuxbadge"];var PC=tS.formatErrorMessage;function xC(e){var t,i;let r=e.theme;if(r){let a=null==(i=null==(t=e.getRootNode())?void 0:t.getElementById)?void 0:i.call(t,r);if(a&&a instanceof HTMLTemplateElement)return a;r.startsWith("media-theme-")||(r=`media-theme-${r}`);let n=ND.customElements.get(r);if(null!=n&&n.template)return n.template}}function OC(e){var t;let i=null==(t=e.mediaController)?void 0:t.querySelector("media-time-display");return i&&"none"===getComputedStyle(i).getPropertyValue("--media-duration-display-display").trim()}function NC(e){let t=e.videoTitle?{video_title:e.videoTitle}:{};return e.getAttributeNames().filter(e=>e.startsWith("metadata-")).reduce((t,i)=>{let r=e.getAttribute(i);return null!==r&&(t[i.replace(/^metadata-/,"").replace(/-/g,"_")]=r),t},t)}tS.formatErrorMessage=e=>{var t,i,r;if(e instanceof Am){let a=SC(e,!1);return null!=a&&a.reload?`\n      ${null!=a&&a.title?`<h3>${FD(a.title)}</h3>`:""}\n      <p>Try again later or <a href="#" data-mux-reload style="color: #4a90e2;">click here to retry</a></p>\n    `:`\n      ${null!=a&&a.title?`<h3>${FD(a.title)}</h3>`:""}\n      ${null!=a&&a.message||null!=a&&a.linkUrl?`<p>\n        ${FD(null!=(t=null==a?void 0:a.message)?t:"")}\n        ${null!=a&&a.linkUrl?`<a\n              href="${FD(a.linkUrl)}"\n              target="_blank"\n              rel="external noopener"\n              aria-label="${FD(null!=(i=a.linkText)?i:"")} ${Wm("(opens in a new window)")}"\n              >${FD(null!=(r=a.linkText)?r:a.linkUrl)}</a\n            >`:""}\n      </p>`:""}\n    `}return PC(e)};var UC,FC,BC,$C,HC,GC,KC,WC,VC,qC,YC,jC,zC,QC,XC,ZC,JC,eM,tM,iM,rM,aM,nM,sM,oM=Object.values(gg),lM=Object.values(DC),dM=Object.values(CC),uM=qD(),hM="mux-player",cM={isDialogOpen:!1},mM={redundant_streams:!0};function fM(e,t){return e.media?e.media.getAttribute(t):e.getAttribute(t)}UC=new WeakMap,FC=new WeakMap,BC=new WeakMap,$C=new WeakMap,HC=new WeakMap,GC=new WeakMap,KC=new WeakMap,WC=new WeakMap,VC=new WeakMap,qC=new WeakMap,YC=new WeakMap,jC=new WeakMap,zC=new WeakMap,QC=new WeakMap,XC=new WeakMap,ZC=new WeakSet,JC=function(){var e,t,i,r;if(!ID(this,FC)){LD(this,FC,!0),wD(this,ZC,iM).call(this);try{if(customElements.upgrade(this.mediaTheme),!(this.mediaTheme instanceof ND.HTMLElement))throw""}catch{iC("<media-theme> failed to upgrade!")}try{customElements.upgrade(this.media)}catch{iC("underlying media element failed to upgrade!")}try{if(customElements.upgrade(this.mediaController),!(this.mediaController instanceof _A))throw""}catch{iC("<media-controller> failed to upgrade!")}wD(this,ZC,rM).call(this),wD(this,ZC,aM).call(this),wD(this,ZC,nM).call(this),LD(this,$C,null==(t=null==(e=this.mediaController)?void 0:e.hasAttribute(jy.USER_INACTIVE))||t),wD(this,ZC,sM).call(this),null==(i=this.media)||i.addEventListener("streamtypechange",ID(this,KC)),null==(r=this.media)||r.addEventListener("loadstart",ID(this,WC)),this.media&&(this.media.metadata=NC(this))}},eM=function(){var e,t;try{null==(e=null==window?void 0:window.CSS)||e.registerProperty({name:"--media-primary-color",syntax:"<color>",inherits:!0}),null==(t=null==window?void 0:window.CSS)||t.registerProperty({name:"--media-secondary-color",syntax:"<color>",inherits:!0})}catch{}},tM=function(e){Object.assign(ID(this,QC),e),wD(this,ZC,iM).call(this)},iM=function(e={}){!function(e,t){e.renderInto(t)}((e=>bC`
  <style>
    ${(e=>{let{tokens:t}=e;return t.drm?":host(:not([cast-receiver])) { --_cast-button-drm-display: none; }":""})(e)}
    ${":host {\n  --media-control-display: var(--controls);\n  --media-loading-indicator-display: var(--loading-indicator);\n  --media-dialog-display: var(--dialog);\n  --media-play-button-display: var(--play-button);\n  --media-live-button-display: var(--live-button);\n  --media-seek-backward-button-display: var(--seek-backward-button);\n  --media-seek-forward-button-display: var(--seek-forward-button);\n  --media-mute-button-display: var(--mute-button);\n  --media-captions-button-display: var(--captions-button);\n  --media-captions-menu-button-display: var(--captions-menu-button, var(--media-captions-button-display));\n  --media-rendition-menu-button-display: var(--rendition-menu-button);\n  --media-audio-track-menu-button-display: var(--audio-track-menu-button);\n  --media-airplay-button-display: var(--airplay-button);\n  --media-pip-button-display: var(--pip-button);\n  --media-fullscreen-button-display: var(--fullscreen-button);\n  --media-cast-button-display: var(--cast-button, var(--_cast-button-drm-display));\n  --media-playback-rate-button-display: var(--playback-rate-button);\n  --media-playback-rate-menu-button-display: var(--playback-rate-menu-button);\n  --media-volume-range-display: var(--volume-range);\n  --media-time-range-display: var(--time-range);\n  --media-time-display-display: var(--time-display);\n  --media-duration-display-display: var(--duration-display);\n  --media-title-display-display: var(--title-display);\n\n  display: inline-block;\n  line-height: 0;\n  width: 100%;\n}\n\na {\n  color: #fff;\n  font-size: 0.9em;\n  text-decoration: underline;\n}\n\nmedia-theme {\n  display: inline-block;\n  line-height: 0;\n  width: 100%;\n  height: 100%;\n  direction: ltr;\n}\n\nmedia-poster-image {\n  display: inline-block;\n  line-height: 0;\n  width: 100%;\n  height: 100%;\n}\n\nmedia-poster-image:not([src]):not([placeholdersrc]) {\n  display: none;\n}\n\n::part(top),\n[part~='top'] {\n  --media-control-display: var(--controls, var(--top-controls));\n  --media-play-button-display: var(--play-button, var(--top-play-button));\n  --media-live-button-display: var(--live-button, var(--top-live-button));\n  --media-seek-backward-button-display: var(--seek-backward-button, var(--top-seek-backward-button));\n  --media-seek-forward-button-display: var(--seek-forward-button, var(--top-seek-forward-button));\n  --media-mute-button-display: var(--mute-button, var(--top-mute-button));\n  --media-captions-button-display: var(--captions-button, var(--top-captions-button));\n  --media-captions-menu-button-display: var(\n    --captions-menu-button,\n    var(--media-captions-button-display, var(--top-captions-menu-button))\n  );\n  --media-rendition-menu-button-display: var(--rendition-menu-button, var(--top-rendition-menu-button));\n  --media-audio-track-menu-button-display: var(--audio-track-menu-button, var(--top-audio-track-menu-button));\n  --media-airplay-button-display: var(--airplay-button, var(--top-airplay-button));\n  --media-pip-button-display: var(--pip-button, var(--top-pip-button));\n  --media-fullscreen-button-display: var(--fullscreen-button, var(--top-fullscreen-button));\n  --media-cast-button-display: var(--cast-button, var(--top-cast-button, var(--_cast-button-drm-display)));\n  --media-playback-rate-button-display: var(--playback-rate-button, var(--top-playback-rate-button));\n  --media-playback-rate-menu-button-display: var(\n    --captions-menu-button,\n    var(--media-playback-rate-button-display, var(--top-playback-rate-menu-button))\n  );\n  --media-volume-range-display: var(--volume-range, var(--top-volume-range));\n  --media-time-range-display: var(--time-range, var(--top-time-range));\n  --media-time-display-display: var(--time-display, var(--top-time-display));\n  --media-duration-display-display: var(--duration-display, var(--top-duration-display));\n  --media-title-display-display: var(--title-display, var(--top-title-display));\n}\n\n::part(center),\n[part~='center'] {\n  --media-control-display: var(--controls, var(--center-controls));\n  --media-play-button-display: var(--play-button, var(--center-play-button));\n  --media-live-button-display: var(--live-button, var(--center-live-button));\n  --media-seek-backward-button-display: var(--seek-backward-button, var(--center-seek-backward-button));\n  --media-seek-forward-button-display: var(--seek-forward-button, var(--center-seek-forward-button));\n  --media-mute-button-display: var(--mute-button, var(--center-mute-button));\n  --media-captions-button-display: var(--captions-button, var(--center-captions-button));\n  --media-captions-menu-button-display: var(\n    --captions-menu-button,\n    var(--media-captions-button-display, var(--center-captions-menu-button))\n  );\n  --media-rendition-menu-button-display: var(--rendition-menu-button, var(--center-rendition-menu-button));\n  --media-audio-track-menu-button-display: var(--audio-track-menu-button, var(--center-audio-track-menu-button));\n  --media-airplay-button-display: var(--airplay-button, var(--center-airplay-button));\n  --media-pip-button-display: var(--pip-button, var(--center-pip-button));\n  --media-fullscreen-button-display: var(--fullscreen-button, var(--center-fullscreen-button));\n  --media-cast-button-display: var(--cast-button, var(--center-cast-button, var(--_cast-button-drm-display)));\n  --media-playback-rate-button-display: var(--playback-rate-button, var(--center-playback-rate-button));\n  --media-playback-rate-menu-button-display: var(\n    --playback-rate-menu-button,\n    var(--media-playback-rate-button-display, var(--center-playback-rate-menu-button))\n  );\n  --media-volume-range-display: var(--volume-range, var(--center-volume-range));\n  --media-time-range-display: var(--time-range, var(--center-time-range));\n  --media-time-display-display: var(--time-display, var(--center-time-display));\n  --media-duration-display-display: var(--duration-display, var(--center-duration-display));\n}\n\n::part(bottom),\n[part~='bottom'] {\n  --media-control-display: var(--controls, var(--bottom-controls));\n  --media-play-button-display: var(--play-button, var(--bottom-play-button));\n  --media-live-button-display: var(--live-button, var(--bottom-live-button));\n  --media-seek-backward-button-display: var(--seek-backward-button, var(--bottom-seek-backward-button));\n  --media-seek-forward-button-display: var(--seek-forward-button, var(--bottom-seek-forward-button));\n  --media-mute-button-display: var(--mute-button, var(--bottom-mute-button));\n  --media-captions-button-display: var(--captions-button, var(--bottom-captions-button));\n  --media-captions-menu-button-display: var(\n    --captions-menu-button,\n    var(--media-captions-button-display, var(--bottom-captions-menu-button))\n  );\n  --media-rendition-menu-button-display: var(--rendition-menu-button, var(--bottom-rendition-menu-button));\n  --media-audio-track-menu-button-display: var(--audio-track-menu-button, var(--bottom-audio-track-menu-button));\n  --media-airplay-button-display: var(--airplay-button, var(--bottom-airplay-button));\n  --media-pip-button-display: var(--pip-button, var(--bottom-pip-button));\n  --media-fullscreen-button-display: var(--fullscreen-button, var(--bottom-fullscreen-button));\n  --media-cast-button-display: var(--cast-button, var(--bottom-cast-button, var(--_cast-button-drm-display)));\n  --media-playback-rate-button-display: var(--playback-rate-button, var(--bottom-playback-rate-button));\n  --media-playback-rate-menu-button-display: var(\n    --playback-rate-menu-button,\n    var(--media-playback-rate-button-display, var(--bottom-playback-rate-menu-button))\n  );\n  --media-volume-range-display: var(--volume-range, var(--bottom-volume-range));\n  --media-time-range-display: var(--time-range, var(--bottom-time-range));\n  --media-time-display-display: var(--time-display, var(--bottom-time-display));\n  --media-duration-display-display: var(--duration-display, var(--bottom-duration-display));\n  --media-title-display-display: var(--title-display, var(--bottom-title-display));\n}\n\n:host([no-tooltips]) {\n  --media-tooltip-display: none;\n}\n"}
  </style>
  ${AC(e)}
`)(function(e,t){var i,r,a;return{src:!e.playbackId&&e.src,playbackId:e.playbackId,hasSrc:!!e.playbackId||!!e.src||!!e.currentSrc,poster:e.poster,storyboard:(null==(i=e.media)?void 0:i.currentSrc)&&e.storyboard,storyboardSrc:e.getAttribute(CC.STORYBOARD_SRC),fullscreenElement:e.getAttribute(CC.FULLSCREEN_ELEMENT),placeholder:e.getAttribute("placeholder"),themeTemplate:xC(e),thumbnailTime:!e.tokens.thumbnail&&e.thumbnailTime,autoplay:e.autoplay,crossOrigin:e.crossOrigin,loop:e.loop,noHotKeys:e.hasAttribute(CC.NOHOTKEYS),hotKeys:e.getAttribute(CC.HOTKEYS),muted:e.muted,paused:e.paused,preload:e.preload,envKey:e.envKey,preferCmcd:e.preferCmcd,debug:e.debug,disableTracking:e.disableTracking,disableCookies:e.disableCookies,tokens:e.tokens,beaconCollectionDomain:e.beaconCollectionDomain,maxResolution:e.maxResolution,minResolution:e.minResolution,maxAutoResolution:e.maxAutoResolution,programStartTime:e.programStartTime,programEndTime:e.programEndTime,assetStartTime:e.assetStartTime,assetEndTime:e.assetEndTime,renditionOrder:e.renditionOrder,metadata:e.metadata,playerInitTime:e.playerInitTime,playerSoftwareName:e.playerSoftwareName,playerSoftwareVersion:e.playerSoftwareVersion,startTime:e.startTime,initialBandwidthEstimateKbps:e.initialBandwidthEstimateKbps,initialEstimateSegments:e.initialEstimateSegments,minPreloadSegments:e.minPreloadSegments,preferPlayback:e.preferPlayback,audio:e.audio,defaultStreamType:e.defaultStreamType,targetLiveWindow:e.getAttribute(gg.TARGET_LIVE_WINDOW),streamType:YD(e.getAttribute(gg.STREAM_TYPE)),primaryColor:e.getAttribute(CC.PRIMARY_COLOR),secondaryColor:e.getAttribute(CC.SECONDARY_COLOR),accentColor:e.getAttribute(CC.ACCENT_COLOR),forwardSeekOffset:e.forwardSeekOffset,backwardSeekOffset:e.backwardSeekOffset,defaultHiddenCaptions:e.defaultHiddenCaptions,defaultDuration:e.defaultDuration,defaultShowRemainingTime:e.defaultShowRemainingTime,hideDuration:OC(e),playbackRates:e.getAttribute(CC.PLAYBACK_RATES),customDomain:null!=(r=e.getAttribute(gg.CUSTOM_DOMAIN))?r:void 0,title:e.getAttribute(CC.TITLE),videoTitle:null!=(a=e.getAttribute(CC.VIDEO_TITLE))?a:e.getAttribute(CC.TITLE),novolumepref:e.hasAttribute(CC.NO_VOLUME_PREF),nomutedpref:e.hasAttribute(CC.NO_MUTED_PREF),proudlyDisplayMuxBadge:e.hasAttribute(CC.PROUDLY_DISPLAY_MUX_BADGE),castReceiver:e.castReceiver,disablePseudoEnded:e.hasAttribute(CC.DISABLE_PSEUDO_ENDED),maxReconnectRetries:e.maxReconnectRetries,capRenditionToPlayerSize:e.capRenditionToPlayerSize,...t,extraSourceParams:e.extraSourceParams}}(this,{...ID(this,QC),...e})),this.shadowRoot)},rM=function(){let e=e=>{var t,i;if(null==e||!e.startsWith("theme-"))return;let r=e.replace(/^theme-/,"");if(MC.includes(r))return;let a=this.getAttribute(e);null!=a?null==(t=this.mediaTheme)||t.setAttribute(r,a):null==(i=this.mediaTheme)||i.removeAttribute(r)};LD(this,GC,new MutationObserver(t=>{for(let{attributeName:i}of t)e(i)})),ID(this,GC).observe(this,{attributes:!0}),this.getAttributeNames().forEach(e)},aM=function(){var e,t;this.addEventListener("error",ID(this,XC)),this.addEventListener("click",ID(this,qC)),null==(e=this.mediaTheme)||e.addEventListener("close",ID(this,YC)),null==(t=this.mediaTheme)||t.addEventListener("focusin",ID(this,jC)),this.media&&(this.media.errorTranslator=(e={})=>{var t,i,r;if(!((null==(t=this.media)?void 0:t.error)instanceof Am))return e;let a=kC(null==(i=this.media)?void 0:i.error);return{player_error_code:null==(r=this.media)?void 0:r.error.code,player_error_message:a.message?String(a.message):e.player_error_message,player_error_context:a.context?String(a.context):e.player_error_context}})},nM=function(){var e,t,i,r;null==(t=null==(e=this.media)?void 0:e.textTracks)||t.addEventListener("addtrack",ID(this,VC)),null==(r=null==(i=this.media)?void 0:i.textTracks)||r.addEventListener("removetrack",ID(this,VC))},sM=function(){var e,t;if(!/Firefox/i.test(navigator.userAgent))return;let i,r=new WeakMap,a=()=>this.streamType===km.LIVE&&!this.secondaryColor&&this.offsetWidth>=800,n=(e,t,i=!1)=>{a()||Array.from(e&&e.activeCues||[]).forEach(e=>{if(!(!e.snapToLines||e.line<-5||e.line>=0&&e.line<10))if(!t||this.paused){let t=e.text.split("\n").length,a=-3;this.streamType===km.LIVE&&(a=-2);let n=a-t;if(e.line===n&&!i)return;r.has(e)||r.set(e,e.line),e.line=n}else setTimeout(()=>{e.line=r.get(e)||"auto"},500)})},s=()=>{var e,t;n(i,null!=(t=null==(e=this.mediaController)?void 0:e.hasAttribute(jy.USER_INACTIVE))&&t)},o=()=>{var e,t;let r=Array.from((null==(t=null==(e=this.mediaController)?void 0:e.media)?void 0:t.textTracks)||[]).filter(e=>["subtitles","captions"].includes(e.kind)&&"showing"===e.mode)[0];r!==i&&(null==i||i.removeEventListener("cuechange",s)),i=r,null==i||i.addEventListener("cuechange",s),n(i,ID(this,$C))};o(),null==(e=this.textTracks)||e.addEventListener("change",o),null==(t=this.textTracks)||t.addEventListener("addtrack",o);let l=()=>{var e,t;let r=null==(t=null==(e=this.mediaController)?void 0:e.hasAttribute(jy.USER_INACTIVE))||t;ID(this,$C)!==r&&(LD(this,$C,r),n(i,ID(this,$C)))};this.addEventListener("userinactivechange",l),LD(this,zC,()=>{var e,t;null==i||i.removeEventListener("cuechange",s),null==(e=this.textTracks)||e.removeEventListener("change",o),null==(t=this.textTracks)||t.removeEventListener("addtrack",o),this.removeEventListener("userinactivechange",l)})};var pM=class extends hC{constructor(){super(),RD(this,ZC),RD(this,UC),RD(this,FC,!1),RD(this,BC,{}),RD(this,$C,!0),RD(this,HC,new JD(this,"hotkeys")),RD(this,GC),RD(this,KC,()=>wD(this,ZC,iM).call(this)),RD(this,WC,()=>wD(this,ZC,iM).call(this)),RD(this,VC,()=>wD(this,ZC,iM).call(this)),RD(this,qC,e=>{e.composedPath().find(e=>{var t;return null==(t=null==e?void 0:e.hasAttribute)?void 0:t.call(e,"data-mux-reload")})&&(e.preventDefault(),window.location.reload())}),RD(this,YC,e=>{var t;"media-error-dialog"===(null==(t=e.composedPath()[0])?void 0:t.localName)&&wD(this,ZC,tM).call(this,{isDialogOpen:!1})}),RD(this,jC,e=>{var t;"media-error-dialog"===(null==(t=e.composedPath()[0])?void 0:t.localName)&&(KD(this,UD.activeElement)||e.preventDefault())}),RD(this,zC),RD(this,QC,{...cM}),RD(this,XC,e=>{var t;let i=null==(t=this.media)?void 0:t.error;if(!(i instanceof Am)){let{message:e,code:t}=null!=i?i:{};i=new Am(e,t)}if(null==i||!i.fatal)return tC(i),void(i.data&&tC(`${i.name} data:`,i.data));let r=kC(i);r.message&&rC(r),iC(i),i.data&&iC(`${i.name} data:`,i.data),wD(this,ZC,tM).call(this,{isDialogOpen:!0})}),LD(this,UC,op()),this.attachShadow({mode:"open"}),wD(this,ZC,eM).call(this),this.isConnected&&wD(this,ZC,JC).call(this)}static get NAME(){return hM}static get VERSION(){return uM}static get observedAttributes(){var e;return[...null!=(e=hC.observedAttributes)?e:[],...lM,...oM,...dM]}setAttribute(e,t){super.setAttribute(e,t),e.startsWith("metadata-")&&this.media&&(this.media.metadata=NC(this))}removeAttribute(e){super.removeAttribute(e),e.startsWith("metadata-")&&this.media&&(this.media.metadata=NC(this))}get mediaTheme(){var e;return null==(e=this.shadowRoot)?void 0:e.querySelector("media-theme")}get mediaController(){var e,t;return null==(t=null==(e=this.mediaTheme)?void 0:e.shadowRoot)?void 0:t.querySelector("media-controller")}connectedCallback(){wD(this,ZC,JC).call(this);let e=this.media;e&&(e.metadata=NC(this))}disconnectedCallback(){var e,t,i,r,a,n,s,o,l,d;null==(e=ID(this,GC))||e.disconnect(),null==(t=this.media)||t.removeEventListener("streamtypechange",ID(this,KC)),null==(i=this.media)||i.removeEventListener("loadstart",ID(this,WC)),this.removeEventListener("error",ID(this,XC)),this.removeEventListener("click",ID(this,qC)),null==(r=this.mediaTheme)||r.removeEventListener("close",ID(this,YC)),null==(a=this.mediaTheme)||a.removeEventListener("focusin",ID(this,jC)),this.media&&(this.media.errorTranslator=void 0),null==(s=null==(n=this.media)?void 0:n.textTracks)||s.removeEventListener("addtrack",ID(this,VC)),null==(l=null==(o=this.media)?void 0:o.textTracks)||l.removeEventListener("removetrack",ID(this,VC)),null==(d=ID(this,zC))||d.call(this),LD(this,zC,void 0),LD(this,FC,!1)}attributeChangedCallback(e,t,i){switch(wD(this,ZC,JC).call(this),super.attributeChangedCallback(e,t,i),e){case CC.HOTKEYS:ID(this,HC).value=i;break;case CC.THUMBNAIL_TIME:null!=i&&this.tokens.thumbnail&&tC(Wm("Use of thumbnail-time with thumbnail-token is currently unsupported. Ignore thumbnail-time.").toString());break;case CC.THUMBNAIL_TOKEN:if(i){let e=Km(i);if(e){let{aud:t}=e,i=Tf;t!==i&&tC(Wm("The {tokenNamePrefix}-token has an incorrect aud value: {aud}. aud value should be {expectedAud}.").format({aud:t,expectedAud:i,tokenNamePrefix:"thumbnail"}))}}break;case CC.STORYBOARD_TOKEN:if(i){let e=Km(i);if(e){let{aud:t}=e,i=Af;t!==i&&tC(Wm("The {tokenNamePrefix}-token has an incorrect aud value: {aud}. aud value should be {expectedAud}.").format({aud:t,expectedAud:i,tokenNamePrefix:"storyboard"}))}}break;case CC.DRM_TOKEN:if(i){let e=Km(i);if(e){let{aud:t}=e,i=_f;t!==i&&tC(Wm("The {tokenNamePrefix}-token has an incorrect aud value: {aud}. aud value should be {expectedAud}.").format({aud:t,expectedAud:i,tokenNamePrefix:"drm"}))}}break;case gg.PLAYBACK_ID:null!=i&&i.includes("?token")&&iC(Wm("The specificed playback ID {playbackId} contains a token which must be provided via the playback-token attribute.").format({playbackId:i}));break;case gg.STREAM_TYPE:i&&![km.LIVE,km.ON_DEMAND,km.UNKNOWN].includes(i)?["ll-live","live:dvr","ll-live:dvr"].includes(this.streamType)?this.targetLiveWindow=i.includes("dvr")?Number.POSITIVE_INFINITY:0:rC({file:"invalid-stream-type.md",message:Wm("Invalid stream-type value supplied: `{streamType}`. Please provide stream-type as either: `on-demand` or `live`").format({streamType:this.streamType})}):i===km.LIVE?null==this.getAttribute(CC.TARGET_LIVE_WINDOW)&&(this.targetLiveWindow=0):this.targetLiveWindow=Number.NaN;break;case CC.FULLSCREEN_ELEMENT:if(null!=i||i!==t){let e=UD.getElementById(i),t=null==e?void 0:e.querySelector("mux-player");this.mediaController&&e&&t&&(this.mediaController.fullscreenElement=e)}break;case gg.CAP_RENDITION_TO_PLAYER_SIZE:(null==i||i!==t)&&(this.capRenditionToPlayerSize=null!=i||void 0);break;case gg.MAX_RECONNECT_RETRIES:(null==i||i!==t)&&(this.maxReconnectRetries=Number(i))}[gg.PLAYBACK_ID,DC.SRC,CC.PLAYBACK_TOKEN].includes(e)&&t!==i&&LD(this,QC,{...ID(this,QC),...cM}),wD(this,ZC,iM).call(this,{[zD(e)]:i})}async requestFullscreen(e){var t;if(this.mediaController&&!this.mediaController.hasAttribute(lE.MEDIA_IS_FULLSCREEN))return null==(t=this.mediaController)||t.dispatchEvent(new ND.CustomEvent(aE.MEDIA_ENTER_FULLSCREEN_REQUEST,{composed:!0,bubbles:!0})),new Promise((e,t)=>{var i;null==(i=this.mediaController)||i.addEventListener(dE.MEDIA_IS_FULLSCREEN,()=>e(),{once:!0})})}async exitFullscreen(){var e;if(this.mediaController&&this.mediaController.hasAttribute(lE.MEDIA_IS_FULLSCREEN))return null==(e=this.mediaController)||e.dispatchEvent(new ND.CustomEvent(aE.MEDIA_EXIT_FULLSCREEN_REQUEST,{composed:!0,bubbles:!0})),new Promise((e,t)=>{var i;null==(i=this.mediaController)||i.addEventListener(dE.MEDIA_IS_FULLSCREEN,()=>e(),{once:!0})})}get preferCmcd(){var e;return null!=(e=this.getAttribute(gg.PREFER_CMCD))?e:void 0}set preferCmcd(e){e!==this.preferCmcd&&(e?wm.includes(e)?this.setAttribute(gg.PREFER_CMCD,e):tC(`Invalid value for preferCmcd. Must be one of ${wm.join()}`):this.removeAttribute(gg.PREFER_CMCD))}get hasPlayed(){var e,t;return null!=(t=null==(e=this.mediaController)?void 0:e.hasAttribute(lE.MEDIA_HAS_PLAYED))&&t}get inLiveWindow(){var e;return null==(e=this.mediaController)?void 0:e.hasAttribute(lE.MEDIA_TIME_IS_LIVE)}get _hls(){var e;return null==(e=this.media)?void 0:e._hls}get mux(){var e;return null==(e=this.media)?void 0:e.mux}get theme(){var e;return null!=(e=this.getAttribute(CC.THEME))?e:"gerwig"}set theme(e){this.setAttribute(CC.THEME,`${e}`)}get themeProps(){let e=this.mediaTheme;if(!e)return;let t={};for(let i of e.getAttributeNames()){if(MC.includes(i))continue;let r=e.getAttribute(i);t[$D(i)]=""===r||r}return t}set themeProps(e){var t,i;wD(this,ZC,JC).call(this);let r={...this.themeProps,...e};for(let a in r){if(MC.includes(a))continue;let r=null==e?void 0:e[a];"boolean"==typeof r||null==r?null==(t=this.mediaTheme)||t.toggleAttribute(BD(a),!!r):null==(i=this.mediaTheme)||i.setAttribute(BD(a),r)}}get playbackId(){var e;return null!=(e=this.getAttribute(gg.PLAYBACK_ID))?e:void 0}set playbackId(e){e?this.setAttribute(gg.PLAYBACK_ID,e):this.removeAttribute(gg.PLAYBACK_ID)}get src(){var e,t;return this.playbackId?null!=(e=fM(this,DC.SRC))?e:void 0:null!=(t=this.getAttribute(DC.SRC))?t:void 0}set src(e){e?this.setAttribute(DC.SRC,e):this.removeAttribute(DC.SRC)}get poster(){var e;let t=this.getAttribute(DC.POSTER);if(null!=t)return t;let{tokens:i}=this;if(!i.playback||i.thumbnail)return this.playbackId&&!this.audio?((e,{token:t,customDomain:i=WD,thumbnailTime:r,programTime:a}={})=>{var n;let s=null==t?r:void 0,{aud:o}=null!=(n=Km(t))?n:{};if(!t||"t"===o)return`https://image.${i}/${e}/thumbnail.webp${GD({token:t,time:s,program_time:a})}`})(this.playbackId,{customDomain:this.customDomain,thumbnailTime:null!=(e=this.thumbnailTime)?e:this.startTime,programTime:this.programStartTime,token:i.thumbnail}):void 0;tC("Missing expected thumbnail token. No poster image will be shown")}set poster(e){e||""===e?this.setAttribute(DC.POSTER,e):this.removeAttribute(DC.POSTER)}get storyboardSrc(){var e;return null!=(e=this.getAttribute(CC.STORYBOARD_SRC))?e:void 0}set storyboardSrc(e){e?this.setAttribute(CC.STORYBOARD_SRC,e):this.removeAttribute(CC.STORYBOARD_SRC)}get storyboard(){let{tokens:e}=this;return this.storyboardSrc&&!e.storyboard?this.storyboardSrc:this.audio||!this.playbackId||!this.streamType||[km.LIVE,km.UNKNOWN].includes(this.streamType)||e.playback&&!e.storyboard?void 0:((e,{token:t,customDomain:i=WD,programStartTime:r,programEndTime:a}={})=>{var n;let{aud:s}=null!=(n=Km(t))?n:{};if(!t||"s"===s)return`https://image.${i}/${e}/storyboard.vtt${GD({token:t,format:"webp",program_start_time:r,program_end_time:a})}`})(this.playbackId,{customDomain:this.customDomain,token:e.storyboard,programStartTime:this.programStartTime,programEndTime:this.programEndTime})}get audio(){return this.hasAttribute(CC.AUDIO)}set audio(e){e?this.setAttribute(CC.AUDIO,""):this.removeAttribute(CC.AUDIO)}get hotkeys(){return ID(this,HC)}get nohotkeys(){return this.hasAttribute(CC.NOHOTKEYS)}set nohotkeys(e){e?this.setAttribute(CC.NOHOTKEYS,""):this.removeAttribute(CC.NOHOTKEYS)}get thumbnailTime(){return HD(this.getAttribute(CC.THUMBNAIL_TIME))}set thumbnailTime(e){this.setAttribute(CC.THUMBNAIL_TIME,`${e}`)}get videoTitle(){var e,t;return null!=(t=null!=(e=this.getAttribute(CC.VIDEO_TITLE))?e:this.getAttribute(CC.TITLE))?t:""}set videoTitle(e){e!==this.videoTitle&&(e?this.setAttribute(CC.VIDEO_TITLE,e):this.removeAttribute(CC.VIDEO_TITLE))}get placeholder(){var e;return null!=(e=fM(this,CC.PLACEHOLDER))?e:""}set placeholder(e){this.setAttribute(CC.PLACEHOLDER,`${e}`)}get primaryColor(){var e,t;let i=this.getAttribute(CC.PRIMARY_COLOR);if(null!=i||this.mediaTheme&&(i=null==(t=null==(e=ND.getComputedStyle(this.mediaTheme))?void 0:e.getPropertyValue("--_primary-color"))?void 0:t.trim(),i))return i}set primaryColor(e){this.setAttribute(CC.PRIMARY_COLOR,`${e}`)}get secondaryColor(){var e,t;let i=this.getAttribute(CC.SECONDARY_COLOR);if(null!=i||this.mediaTheme&&(i=null==(t=null==(e=ND.getComputedStyle(this.mediaTheme))?void 0:e.getPropertyValue("--_secondary-color"))?void 0:t.trim(),i))return i}set secondaryColor(e){this.setAttribute(CC.SECONDARY_COLOR,`${e}`)}get accentColor(){var e,t;let i=this.getAttribute(CC.ACCENT_COLOR);if(null!=i||this.mediaTheme&&(i=null==(t=null==(e=ND.getComputedStyle(this.mediaTheme))?void 0:e.getPropertyValue("--_accent-color"))?void 0:t.trim(),i))return i}set accentColor(e){this.setAttribute(CC.ACCENT_COLOR,`${e}`)}get defaultShowRemainingTime(){return this.hasAttribute(CC.DEFAULT_SHOW_REMAINING_TIME)}set defaultShowRemainingTime(e){e?this.setAttribute(CC.DEFAULT_SHOW_REMAINING_TIME,""):this.removeAttribute(CC.DEFAULT_SHOW_REMAINING_TIME)}get playbackRates(){if(this.hasAttribute(CC.PLAYBACK_RATES))return this.getAttribute(CC.PLAYBACK_RATES).trim().split(/\s*,?\s+/).map(e=>Number(e)).filter(e=>!Number.isNaN(e)).sort((e,t)=>e-t)}set playbackRates(e){e?this.setAttribute(CC.PLAYBACK_RATES,e.join(" ")):this.removeAttribute(CC.PLAYBACK_RATES)}get forwardSeekOffset(){var e;return null!=(e=HD(this.getAttribute(CC.FORWARD_SEEK_OFFSET)))?e:10}set forwardSeekOffset(e){this.setAttribute(CC.FORWARD_SEEK_OFFSET,`${e}`)}get backwardSeekOffset(){var e;return null!=(e=HD(this.getAttribute(CC.BACKWARD_SEEK_OFFSET)))?e:10}set backwardSeekOffset(e){this.setAttribute(CC.BACKWARD_SEEK_OFFSET,`${e}`)}get defaultHiddenCaptions(){return this.hasAttribute(CC.DEFAULT_HIDDEN_CAPTIONS)}set defaultHiddenCaptions(e){e?this.setAttribute(CC.DEFAULT_HIDDEN_CAPTIONS,""):this.removeAttribute(CC.DEFAULT_HIDDEN_CAPTIONS)}get defaultDuration(){return HD(this.getAttribute(CC.DEFAULT_DURATION))}set defaultDuration(e){null==e?this.removeAttribute(CC.DEFAULT_DURATION):this.setAttribute(CC.DEFAULT_DURATION,`${e}`)}get playerInitTime(){return this.hasAttribute(gg.PLAYER_INIT_TIME)?HD(this.getAttribute(gg.PLAYER_INIT_TIME)):ID(this,UC)}set playerInitTime(e){e!=this.playerInitTime&&(null==e?this.removeAttribute(gg.PLAYER_INIT_TIME):this.setAttribute(gg.PLAYER_INIT_TIME,""+ +e))}get playerSoftwareName(){var e;return null!=(e=this.getAttribute(gg.PLAYER_SOFTWARE_NAME))?e:hM}get playerSoftwareVersion(){var e;return null!=(e=this.getAttribute(gg.PLAYER_SOFTWARE_VERSION))?e:uM}get beaconCollectionDomain(){var e;return null!=(e=this.getAttribute(gg.BEACON_COLLECTION_DOMAIN))?e:void 0}set beaconCollectionDomain(e){e!==this.beaconCollectionDomain&&(e?this.setAttribute(gg.BEACON_COLLECTION_DOMAIN,e):this.removeAttribute(gg.BEACON_COLLECTION_DOMAIN))}get maxResolution(){var e;return null!=(e=this.getAttribute(gg.MAX_RESOLUTION))?e:void 0}set maxResolution(e){e!==this.maxResolution&&(e?this.setAttribute(gg.MAX_RESOLUTION,e):this.removeAttribute(gg.MAX_RESOLUTION))}get minResolution(){var e;return null!=(e=this.getAttribute(gg.MIN_RESOLUTION))?e:void 0}set minResolution(e){e!==this.minResolution&&(e?this.setAttribute(gg.MIN_RESOLUTION,e):this.removeAttribute(gg.MIN_RESOLUTION))}get maxAutoResolution(){var e;return null!=(e=this.getAttribute(gg.MAX_AUTO_RESOLUTION))?e:void 0}set maxAutoResolution(e){null==e?this.removeAttribute(gg.MAX_AUTO_RESOLUTION):this.setAttribute(gg.MAX_AUTO_RESOLUTION,e)}get renditionOrder(){var e;return null!=(e=this.getAttribute(gg.RENDITION_ORDER))?e:void 0}set renditionOrder(e){e!==this.renditionOrder&&(e?this.setAttribute(gg.RENDITION_ORDER,e):this.removeAttribute(gg.RENDITION_ORDER))}get programStartTime(){return HD(this.getAttribute(gg.PROGRAM_START_TIME))}set programStartTime(e){null==e?this.removeAttribute(gg.PROGRAM_START_TIME):this.setAttribute(gg.PROGRAM_START_TIME,`${e}`)}get programEndTime(){return HD(this.getAttribute(gg.PROGRAM_END_TIME))}set programEndTime(e){null==e?this.removeAttribute(gg.PROGRAM_END_TIME):this.setAttribute(gg.PROGRAM_END_TIME,`${e}`)}get assetStartTime(){return HD(this.getAttribute(gg.ASSET_START_TIME))}set assetStartTime(e){null==e?this.removeAttribute(gg.ASSET_START_TIME):this.setAttribute(gg.ASSET_START_TIME,`${e}`)}get assetEndTime(){return HD(this.getAttribute(gg.ASSET_END_TIME))}set assetEndTime(e){null==e?this.removeAttribute(gg.ASSET_END_TIME):this.setAttribute(gg.ASSET_END_TIME,`${e}`)}get extraSourceParams(){return this.hasAttribute(CC.EXTRA_SOURCE_PARAMS)?[...new URLSearchParams(this.getAttribute(CC.EXTRA_SOURCE_PARAMS)).entries()].reduce((e,[t,i])=>(e[t]=i,e),{}):mM}set extraSourceParams(e){null==e?this.removeAttribute(CC.EXTRA_SOURCE_PARAMS):this.setAttribute(CC.EXTRA_SOURCE_PARAMS,new URLSearchParams(e).toString())}get customDomain(){var e;return null!=(e=this.getAttribute(gg.CUSTOM_DOMAIN))?e:void 0}set customDomain(e){e!==this.customDomain&&(e?this.setAttribute(gg.CUSTOM_DOMAIN,e):this.removeAttribute(gg.CUSTOM_DOMAIN))}get envKey(){var e;return null!=(e=fM(this,gg.ENV_KEY))?e:void 0}set envKey(e){this.setAttribute(gg.ENV_KEY,`${e}`)}get noVolumePref(){return this.hasAttribute(CC.NO_VOLUME_PREF)}set noVolumePref(e){e?this.setAttribute(CC.NO_VOLUME_PREF,""):this.removeAttribute(CC.NO_VOLUME_PREF)}get noMutedPref(){return this.hasAttribute(CC.NO_MUTED_PREF)}set noMutedPref(e){e?this.setAttribute(CC.NO_MUTED_PREF,""):this.removeAttribute(CC.NO_MUTED_PREF)}get debug(){return null!=fM(this,gg.DEBUG)}set debug(e){e?this.setAttribute(gg.DEBUG,""):this.removeAttribute(gg.DEBUG)}get disableTracking(){return null!=fM(this,gg.DISABLE_TRACKING)}set disableTracking(e){this.toggleAttribute(gg.DISABLE_TRACKING,!!e)}get disableCookies(){return null!=fM(this,gg.DISABLE_COOKIES)}set disableCookies(e){e?this.setAttribute(gg.DISABLE_COOKIES,""):this.removeAttribute(gg.DISABLE_COOKIES)}get streamType(){var e,t,i;return null!=(i=null!=(t=this.getAttribute(gg.STREAM_TYPE))?t:null==(e=this.media)?void 0:e.streamType)?i:km.UNKNOWN}set streamType(e){this.setAttribute(gg.STREAM_TYPE,`${e}`)}get defaultStreamType(){var e,t,i;return null!=(i=null!=(t=this.getAttribute(CC.DEFAULT_STREAM_TYPE))?t:null==(e=this.mediaController)?void 0:e.getAttribute(CC.DEFAULT_STREAM_TYPE))?i:km.ON_DEMAND}set defaultStreamType(e){e?this.setAttribute(CC.DEFAULT_STREAM_TYPE,e):this.removeAttribute(CC.DEFAULT_STREAM_TYPE)}get targetLiveWindow(){var e,t;return this.hasAttribute(CC.TARGET_LIVE_WINDOW)?+this.getAttribute(CC.TARGET_LIVE_WINDOW):null!=(t=null==(e=this.media)?void 0:e.targetLiveWindow)?t:Number.NaN}set targetLiveWindow(e){e==this.targetLiveWindow||Number.isNaN(e)&&Number.isNaN(this.targetLiveWindow)||(null==e?this.removeAttribute(CC.TARGET_LIVE_WINDOW):this.setAttribute(CC.TARGET_LIVE_WINDOW,""+ +e))}get liveEdgeStart(){var e;return null==(e=this.media)?void 0:e.liveEdgeStart}get startTime(){return HD(fM(this,gg.START_TIME))}set startTime(e){this.setAttribute(gg.START_TIME,`${e}`)}get initialBandwidthEstimateKbps(){return HD(fM(this,gg.INITIAL_BANDWIDTH_ESTIMATE_KBPS))}set initialBandwidthEstimateKbps(e){null==e?this.removeAttribute(gg.INITIAL_BANDWIDTH_ESTIMATE_KBPS):this.setAttribute(gg.INITIAL_BANDWIDTH_ESTIMATE_KBPS,`${e}`)}get initialEstimateSegments(){return HD(fM(this,gg.INITIAL_ESTIMATE_SEGMENTS))}set initialEstimateSegments(e){null==e?this.removeAttribute(gg.INITIAL_ESTIMATE_SEGMENTS):this.setAttribute(gg.INITIAL_ESTIMATE_SEGMENTS,`${e}`)}get minPreloadSegments(){return HD(fM(this,gg.MIN_PRELOAD_SEGMENTS))}set minPreloadSegments(e){null==e?this.removeAttribute(gg.MIN_PRELOAD_SEGMENTS):this.setAttribute(gg.MIN_PRELOAD_SEGMENTS,`${e}`)}get preferPlayback(){let e=this.getAttribute(gg.PREFER_PLAYBACK);if(e===Im||e===Rm)return e}set preferPlayback(e){e!==this.preferPlayback&&(e===Im||e===Rm?this.setAttribute(gg.PREFER_PLAYBACK,e):this.removeAttribute(gg.PREFER_PLAYBACK))}get metadata(){var e;return null==(e=this.media)?void 0:e.metadata}set metadata(e){wD(this,ZC,JC).call(this),this.media?this.media.metadata={...NC(this),...e}:iC("underlying media element missing when trying to set metadata. metadata will not be set.")}get _hlsConfig(){var e;return null==(e=this.media)?void 0:e._hlsConfig}set _hlsConfig(e){wD(this,ZC,JC).call(this),this.media?this.media._hlsConfig=e:iC("underlying media element missing when trying to set _hlsConfig. _hlsConfig will not be set.")}async addCuePoints(e){var t;if(wD(this,ZC,JC).call(this),this.media)return null==(t=this.media)?void 0:t.addCuePoints(e);iC("underlying media element missing when trying to addCuePoints. cuePoints will not be added.")}get activeCuePoint(){var e;return null==(e=this.media)?void 0:e.activeCuePoint}get cuePoints(){var e,t;return null!=(t=null==(e=this.media)?void 0:e.cuePoints)?t:[]}addChapters(e){var t;if(wD(this,ZC,JC).call(this),this.media)return null==(t=this.media)?void 0:t.addChapters(e);iC("underlying media element missing when trying to addChapters. chapters will not be added.")}get activeChapter(){var e;return null==(e=this.media)?void 0:e.activeChapter}get chapters(){var e,t;return null!=(t=null==(e=this.media)?void 0:e.chapters)?t:[]}getStartDate(){var e;return null==(e=this.media)?void 0:e.getStartDate()}get currentPdt(){var e;return null==(e=this.media)?void 0:e.currentPdt}get tokens(){let e=this.getAttribute(CC.PLAYBACK_TOKEN),t=this.getAttribute(CC.DRM_TOKEN),i=this.getAttribute(CC.THUMBNAIL_TOKEN),r=this.getAttribute(CC.STORYBOARD_TOKEN);return{...ID(this,BC),...null!=e?{playback:e}:{},...null!=t?{drm:t}:{},...null!=i?{thumbnail:i}:{},...null!=r?{storyboard:r}:{}}}set tokens(e){LD(this,BC,null!=e?e:{})}get playbackToken(){var e;return null!=(e=this.getAttribute(CC.PLAYBACK_TOKEN))?e:void 0}set playbackToken(e){this.setAttribute(CC.PLAYBACK_TOKEN,`${e}`)}get drmToken(){var e;return null!=(e=this.getAttribute(CC.DRM_TOKEN))?e:void 0}set drmToken(e){this.setAttribute(CC.DRM_TOKEN,`${e}`)}get thumbnailToken(){var e;return null!=(e=this.getAttribute(CC.THUMBNAIL_TOKEN))?e:void 0}set thumbnailToken(e){this.setAttribute(CC.THUMBNAIL_TOKEN,`${e}`)}get storyboardToken(){var e;return null!=(e=this.getAttribute(CC.STORYBOARD_TOKEN))?e:void 0}set storyboardToken(e){this.setAttribute(CC.STORYBOARD_TOKEN,`${e}`)}addTextTrack(e,t,i,r){var a;let n=null==(a=this.media)?void 0:a.nativeEl;if(n)return rf(n,e,t,i,r)}removeTextTrack(e){var t;let i=null==(t=this.media)?void 0:t.nativeEl;if(i)return function(e,t){let i=Array.prototype.find.call(e.querySelectorAll("track"),e=>e.track===t);null==i||i.remove()}(i,e)}get textTracks(){var e;return null==(e=this.media)?void 0:e.textTracks}get castReceiver(){var e;return null!=(e=this.getAttribute(CC.CAST_RECEIVER))?e:void 0}set castReceiver(e){e!==this.castReceiver&&(e?this.setAttribute(CC.CAST_RECEIVER,e):this.removeAttribute(CC.CAST_RECEIVER))}get castCustomData(){var e;return null==(e=this.media)?void 0:e.castCustomData}set castCustomData(e){this.media?this.media.castCustomData=e:iC("underlying media element missing when trying to set castCustomData. castCustomData will not be set.")}get noTooltips(){return this.hasAttribute(CC.NO_TOOLTIPS)}set noTooltips(e){e?this.setAttribute(CC.NO_TOOLTIPS,""):this.removeAttribute(CC.NO_TOOLTIPS)}get proudlyDisplayMuxBadge(){return this.hasAttribute(CC.PROUDLY_DISPLAY_MUX_BADGE)}set proudlyDisplayMuxBadge(e){e?this.setAttribute(CC.PROUDLY_DISPLAY_MUX_BADGE,""):this.removeAttribute(CC.PROUDLY_DISPLAY_MUX_BADGE)}get capRenditionToPlayerSize(){var e;return null==(e=this.media)?void 0:e.capRenditionToPlayerSize}set capRenditionToPlayerSize(e){this.media?this.media.capRenditionToPlayerSize=e:iC("underlying media element missing when trying to set capRenditionToPlayerSize")}get maxReconnectRetries(){var e;return null==(e=this.media)?void 0:e.maxReconnectRetries}set maxReconnectRetries(e){this.media?this.media.maxReconnectRetries=e:iC("underlying media element missing when trying to set maxReconnectRetries")}};v.customElements.get("mux-player")||(v.customElements.define("mux-player",pM),v.MuxPlayerElement=pM)})();
/*! Bundled license information:

mux-embed/dist/mux.mjs:
  (*!
  * JavaScript Cookie v2.1.3
  * https://github.com/js-cookie/js-cookie
  *
  * Copyright 2006, 2015 Klaus Hartl & Fagner Brack
  * Released under the MIT license
  *)
*/
//# sourceMappingURL=/sm/5923e4e13e310e63c8cb3fe757f8ba6d87ea6e89a5e36ea96e5028c7bcece6fe.map