PageSourceSearch

https://xyne.ai/_next/static/chunks/1y0c8jyf4jkyi.js

js xyne.ai collected 2026-10-05 15:10:56 UTC 1,120,683 bytes, 3,375 lines download raw bytes

1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,84141,e=>{"use strict";let t,i,r,a,s,n,l,o,d,h;var u=e.i(47456),c=Object.create,m=Object.defineProperty,f=Object.getOwnPropertyDescriptor,p=Object.getOwnPropertyNames,g=Object.getPrototypeOf,v=Object.prototype.hasOwnProperty,E=function(e,t){return function(){return e&&(t=e(e=0)),t}},y=function(e,t){return function(){return t||e((t={exports:{}}).exports,t),t.exports}},b=function(e,t,i,r){if(t&&"object"==typeof t||"function"==typeof t)for(var a,s=p(t),n=0,l=s.length;n<l;n++)a=s[n],v.call(e,a)||a===i||m(e,a,{get:(function(e){return t[e]}).bind(null,a),enumerable:!(r=f(t,a))||r.enumerable});return e},T=function(e,t,i){return i=null!=e?c(g(e)):{},b(!t&&e&&e.__esModule?i:m(i,"default",{value:e,enumerable:!0}),e)},A=y(function(t,i){i.exports="u">typeof window?window:e.g});function S(e,t){return null!=t&&"u">typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):S(e,t)}var k=E(function(){k()});function R(e){return e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}var L=E(function(){}),I=y(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))}}}),w=y(function(e,t){function i(e,t){if(!S(this,i))return new i(e,t);this.data=e,this.nodeValue=e,this.length=e.length,this.ownerDocument=t||null}k(),t.exports=i,i.prototype.nodeType=8,i.prototype.nodeName="#comment",i.prototype.toString=function(){return"[object Comment]"}}),D=y(function(e,t){function i(e,t){if(!S(this,i))return new i(e);this.data=e||"",this.length=this.data.length,this.ownerDocument=t||null}k(),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),s=r.substring(e+t,r.length);this.data=a+i+s,this.length=this.data.length}}),C=y(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)}}),M=y(function(e,t){t.exports=function(e,t){this.listeners||(this.listeners={}),this.listeners[e]||(this.listeners[e]=[]),-1===this.listeners[e].indexOf(t)&&this.listeners[e].push(t)}}),x=y(function(e,t){t.exports=function(e,t){if(this.listeners&&this.listeners[e]){var i=this.listeners[e],r=i.indexOf(t);-1!==r&&i.splice(r,1)}}}),P=y(function(e,t){L(),t.exports=function e(t){switch(t.nodeType){case 3:return a(t.data);case 8:return"<!--"+t.data+"-->";default:var s,n,l;return n=[],l=(s=t).tagName,"http://www.w3.org/1999/xhtml"===s.namespaceURI&&(l=l.toLowerCase()),n.push("<"+l+function(e){var t=[];for(var i in e)(function(e,t){var i=R(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})(e,i)&&t.push({name:i,value:e[i]});for(var a in e._attributes)for(var s in e._attributes[a]){var n=e._attributes[a][s],l=(n.prefix?n.prefix+":":"")+s;t.push({name:l,value:n.value})}return e.className&&t.push({name:"class",value:e.className}),t.length?r(t):""}(s)+function(e){var t=e.dataset,i=[];for(var a in t)i.push({name:"data-"+a,value:t[a]});return i.length?r(i):""}(s)),i.indexOf(l)>-1?n.push(" />"):(n.push(">"),s.childNodes.length?n.push.apply(n,s.childNodes.map(e)):s.textContent||s.innerText?n.push(a(s.textContent||s.innerText)):s.innerHTML&&n.push(s.innerHTML),n.push("</"+l+">")),n.join("")}};var i=["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"];function r(e){var t=[];return e.forEach(function(e){var i=e.name,r=e.value;"style"===i&&(r=function(e){if("string"==typeof e)return e;var t="";return Object.keys(e).forEach(function(i){var r=e[i];i=i.replace(/[A-Z]/g,function(e){return"-"+e.toLowerCase()}),t+=i+":"+r+";"}),t}(r)),t.push(i+'="'+a(r).replace(/"/g,"&quot;")+'"')}),t.length?" "+t.join(" "):""}function a(e){var t="";return"string"==typeof e?t=e:e&&(t=e.toString()),t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}}),O=y(function(e,t){k();var i=I(),r=C(),a=M(),s=x(),n=P(),l="http://www.w3.org/1999/xhtml";function o(e,t,i){if(!S(this,o))return new o(e);var r=void 0===i?l:i||null;this.tagName=r===l?String(e).toUpperCase():e,this.nodeName=this.tagName,this.className="",this.dataset={},this.childNodes=[],this.parentNode=null,this.style={},this.ownerDocument=t||null,this.namespaceURI=r,this._attributes={}
1,"INPUT"===this.tagName&&(this.type="text")}t.exports=o,o.prototype.type="DOMElement",o.prototype.nodeType=1,o.prototype.appendChild=function(e){return e.parentNode&&e.parentNode.removeChild(e),this.childNodes.push(e),e.parentNode=this,e},o.prototype.replaceChild=function(e,t){e.parentNode&&e.parentNode.removeChild(e);var i=this.childNodes.indexOf(t);return t.parentNode=null,this.childNodes[i]=e,e.parentNode=this,t},o.prototype.removeChild=function(e){var t=this.childNodes.indexOf(e);return this.childNodes.splice(t,1),e.parentNode=null,e},o.prototype.insertBefore=function(e,t){e.parentNode&&e.parentNode.removeChild(e);var i=null==t?-1:this.childNodes.indexOf(t);return i>-1?this.childNodes.splice(i,0,e):this.childNodes.push(e),e.parentNode=this,e},o.prototype.setAttributeNS=function(e,t,i){var r=null,a=t,s=t.indexOf(":");(s>-1&&(r=t.substr(0,s),a=t.substr(s+1)),"INPUT"===this.tagName&&"type"===t)?this.type=i:(this._attributes[e]||(this._attributes[e]={}))[a]={value:i,prefix:r}},o.prototype.getAttributeNS=function(e,t){var i=this._attributes[e],r=i&&i[t]&&i[t].value;return"INPUT"===this.tagName&&"type"===t?this.type:"string"!=typeof r?null:r},o.prototype.removeAttributeNS=function(e,t){var i=this._attributes[e];i&&delete i[t]},o.prototype.hasAttributeNS=function(e,t){var i=this._attributes[e];return!!i&&t in i},o.prototype.setAttribute=function(e,t){return this.setAttributeNS(null,e,t)},o.prototype.getAttribute=function(e){return this.getAttributeNS(null,e)},o.prototype.removeAttribute=function(e){return this.removeAttributeNS(null,e)},o.prototype.hasAttribute=function(e){return this.hasAttributeNS(null,e)},o.prototype.removeEventListener=s,o.prototype.addEventListener=a,o.prototype.dispatchEvent=r,o.prototype.focus=function(){},o.prototype.toString=function(){return n(this)},o.prototype.getElementsByClassName=function(e){var t=e.split(" "),r=[];return i(this,function(e){if(1===e.nodeType){var i=(e.className||"").split(" ");t.every(function(e){return -1!==i.indexOf(e)})&&r.push(e)}}),r},o.prototype.getElementsByTagName=function(e){e=e.toLowerCase();var t=[];return i(this.childNodes,function(i){1===i.nodeType&&("*"===e||i.tagName.toLowerCase()===e)&&t.push(i)}),t},o.prototype.contains=function(e){return i(this,function(t){return e===t})||!1}}),N=y(function(e,t){k();var i=O();function r(e){if(!S(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("")}}),U=y(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(){}}),F=y(function(e,t){k();var i=I(),r=w(),a=D(),s=O(),n=N(),l=U(),o=C(),d=M(),h=x();function u(){if(!S(this,u))return new u;this.head=this.createElement("head"),this.body=this.createElement("body"),this.documentElement=this.createElement("html"),this.documentElement.appendChild(this.head),this.documentElement.appendChild(this.body),this.childNodes=[this.documentElement],this.nodeType=9}t.exports=u;var c=u.prototype;c.createTextNode=function(e){return new a(e,this)},c.createElementNS=function(e,t){return new s(t,this,null===e?null:String(e))},c.createElement=function(e){return new s(e,this)},c.createDocumentFragment=function(){return new n(this)},c.createEvent=function(e){return new l(e)},c.createComment=function(e){return new r(e,this)},c.getElementById=function(e){return e=String(e),i(this.childNodes,function(t){if(String(t.id)===e)return t})||null},c.getElementsByClassName=s.prototype.getElementsByClassName,c.getElementsByTagName=s.prototype.getElementsByTagName,c.contains=s.prototype.contains,c.removeEventListener=h,c.addEventListener=d,c.dispatchEvent=o}),B=y(function(e,t){t.exports=new(F())}),$=y(function(t,i){var r,a=e.g,s=B();"u">typeof document?r=document:(r=a["__GLOBAL_DOCUMENT_CACHE@4"])||(r=a["__GLOBAL_DOCUMENT_CACHE@4"]=s),i.exports=r});function H(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,r=Array(t);i<t;i++)r[i]=e[i];return r}function G(e,t){if(e){if("string"==typeof e)return H(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 H(e,t)}}function W(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var i=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var r,a,s=[],n=!0,l=!1;try{for(i=i.call(e);!(n=(r=i.next()).done)&&(s.push(r.value),!(t&&s.length===t));n=!0);}catch(e){l=!0,a=e}finally{try{n||null==i.return||i.return()}finally{if(l)throw a}}return s}}(e,t)||G(e,t)||function(){throw TypeError("Invalid attempt to de
1structure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var K=T(A()),V=T(A()),q=T(A()),j=function(){var e=q.default.performance,t=e&&e.timing,i=t&&t.navigationStart;return Math.round("number"==typeof i&&"function"==typeof e.now?i+e.now():Date.now())},Y=function(){if("function"==typeof(null==(e=V.default.crypto)?void 0:e.getRandomValues)){i=new Uint8Array(32),V.default.crypto.getRandomValues(i);for(var e,t,i,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 s=0;t="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t="x"===e?i[s]:3&i[s]|8;return s++,t.toString(16)});var n=j(),l=null==n?void 0:n.toString(16).substring(3);return l?t.substring(0,28)+l:t},z=function(){return("000000"+(0x81bf1000*Math.random()|0).toString(36)).slice(-6)},Q=function(e){var t;if(e&&void 0!==e.nodeName)return e.muxId||(e.muxId=z()),e.muxId;try{t=document.querySelector(e)}catch(e){}return t&&!t.muxId&&(t.muxId=e),(null==t?void 0:t.muxId)||e},X=function(e){e&&void 0!==e.nodeName?e=Q(t=e):t=document.querySelector(e);var t,i=t&&t.nodeName?t.nodeName.toLowerCase():"";return[t,e,i]};function Z(e){return function(e){if(Array.isArray(e))return H(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||G(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var J=function(e){var t,i,r,a,s,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,l=e?[console,e]:[console],o=(t=console.trace).bind.apply(t,Z(l)),d=(i=console.info).bind.apply(i,Z(l)),h=(r=console.debug).bind.apply(r,Z(l)),u=(a=console.warn).bind.apply(a,Z(l)),c=(s=console.error).bind.apply(s,Z(l)),m=n;return{trace:function(){for(var e=arguments.length,t=Array(e),i=0;i<e;i++)t[i]=arguments[i];if(!(m>0))return o.apply(void 0,Z(t))},debug:function(){for(var e=arguments.length,t=Array(e),i=0;i<e;i++)t[i]=arguments[i];if(!(m>1))return h.apply(void 0,Z(t))},info:function(){for(var e=arguments.length,t=Array(e),i=0;i<e;i++)t[i]=arguments[i];if(!(m>2))return d.apply(void 0,Z(t))},warn:function(){for(var e=arguments.length,t=Array(e),i=0;i<e;i++)t[i]=arguments[i];if(!(m>3))return u.apply(void 0,Z(t))},error:function(){for(var e=arguments.length,t=Array(e),i=0;i<e;i++)t[i]=arguments[i];if(!(m>4))return c.apply(void 0,Z(t))},get level(){return m},set level(_){_!==this.level&&(m=null!=_?_:n)}}}("[mux]"),ee=T(A());function et(){return"1"===(ee.default.doNotTrack||ee.default.navigator&&ee.default.navigator.doNotTrack)}function ei(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function er(e,t){if(!S(e,t))throw TypeError("Cannot call a class as a function")}function ea(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 es(e,t,i){return t&&ea(e.prototype,t),i&&ea(e,i),e}function en(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function el(e){return(el=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function eo(e,t,i){return(eo="u">typeof Reflect&&Reflect.get?Reflect.get:function(e,t,i){var r=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=el(e)););return e}(e,t);if(r){var a=Object.getOwnPropertyDescriptor(r,t);return a.get?a.get.call(i||e):a.value}})(e,t,i||e)}function ed(e,t){return(ed=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}k(),L();var eh=function(e){return eu(e)[0]},eu=function(e){if("string"!=typeof e||""===e)return["localhost"];var t,i=(e.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/)||[])[4];return i&&(t=(i.match(/[^\.]+\.[^\.]+$/)||[])[0]),[i,t]},ec=T(A()),em=function(){var e=ec.default.performance;return void 0!==(e&&e.timing)}
1,ef=function(){var e=ec.default.performance,t=e&&e.timing;return t&&t.domContentLoadedEventEnd},ep=function(){var e=ec.default.performance,t=e&&e.timing;return t&&t.navigationStart};function eg(e,t,i){i=void 0===i?1:i,e[t]=e[t]||0,e[t]+=i}function ev(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){en(e,t,i[t])})}return e}function eE(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t.push.apply(t,i)}return t})(Object(t)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(t,i))}),e}var ey=["x-request-id","cf-ray","x-amz-cf-id","x-akamai-request-id"],eb=["x-cdn","content-type"].concat(ey);function eT(e){var t={};return(e=e||"").trim().split(/[\r\n]+/).forEach(function(e){if(e){var i=e.split(": "),r=i.shift();r&&(eb.indexOf(r.toLowerCase())>=0||0===r.toLowerCase().indexOf("x-litix-"))&&(t[r]=i.join(": "))}}),t}function eA(e){if(e){var t=ey.find(function(t){return void 0!==e[t]});return t?e[t]:void 0}}var e_=function(e){var t={};for(var i in e){var r=e[i];-1!==r["DATA-ID"].search("io.litix.data.")&&(t[r["DATA-ID"].replace("io.litix.data.","")]=r.VALUE)}return t},eS=function(e){if(!e)return{};var t=ep(),i=e.loading,r=i?i.start:e.trequest,a=i?i.first:e.tfirst,s=i?i.end:e.tload;return{bytesLoaded:e.total,requestStart:Math.round(t+r),responseStart:Math.round(t+a),responseEnd:Math.round(t+s)}},ek=function(e){if(!(!e||"function"!=typeof e.getAllResponseHeaders))return eT(e.getAllResponseHeaders())},eR=function(e,t,i){arguments.length>3&&void 0!==arguments[3]&&arguments[3];var r=arguments.length>4?arguments[4]:void 0,a=e.log,s=e.utils.secondsToMs,n=function(e){var t,i=parseInt(r.version);return 1===i&&null!==e.programDateTime&&(t=e.programDateTime),0===i&&null!==e.pdt&&(t=e.pdt),t};if(!em())return void a.warn("performance timing not supported. Not tracking HLS.js.");var l=function(i,r){return e.emit(t,i,r)},o=function(e,t){var i=t.levels,r=t.audioTracks,a=t.url,s=t.stats,n=t.networkDetails,o=t.sessionData,d={},h={};i.forEach(function(e,t){d[t]={width:e.width,height:e.height,bitrate:e.bitrate,attrs:e.attrs}}),r.forEach(function(e,t){h[t]={name:e.name,language:e.lang,bitrate:e.bitrate}});var u=eS(s),c=u.bytesLoaded,m=u.requestStart,f=u.responseStart,p=u.responseEnd;l("requestcompleted",eE(ev({},e_(o)),{request_event_type:e,request_bytes_loaded:c,request_start:m,request_response_start:f,request_response_end:p,request_type:"manifest",request_hostname:eh(a),request_response_headers:ek(n),request_rendition_lists:{media:d,audio:h,video:{}}}))};i.on(r.Events.MANIFEST_LOADED,o);var d=function(e,t){var i=t.details,r=t.level,a=t.networkDetails,o=eS(t.stats),d=o.bytesLoaded,h=o.requestStart,u=o.responseStart,c=o.responseEnd,m=i.fragments[i.fragments.length-1],f=n(m)+s(m.duration);l("requestcompleted",{request_event_type:e,request_bytes_loaded:d,request_start:h,request_response_start:u,request_response_end:c,request_current_level:r,request_type:"manifest",request_hostname:eh(i.url),request_response_headers:ek(a),video_holdback:i.holdBack&&s(i.holdBack),video_part_holdback:i.partHoldBack&&s(i.partHoldBack),video_part_target_duration:i.partTarget&&s(i.partTarget),video_target_duration:i.targetduration&&s(i.targetduration),video_source_is_live:i.live,player_manifest_newest_program_time:isNaN(f)?void 0:f})};i.on(r.Events.LEVEL_LOADED,d);var h=function(e,t){var i=t.details,r=t.networkDetails,a=eS(t.stats);l("requestcompleted",{request_event_type:e,request_bytes_loaded:a.bytesLoaded,request_start:a.requestStart,request_response_start:a.responseStart,request_response_end:a.responseEnd,request_type:"manifest",request_hostname:eh(i.url),request_response_headers:ek(r)})};i.on(r.Events.AUDIO_TRACK_LOADED,h);var u=function(e,t){var r=t.stats,a=t.networkDetails,s=t.frag,n=eS(r=r||s.stats),o=n.bytesLoaded,d=n.requestStart,h=n.responseStart,u=n.responseEnd,c=a?ek(a):void 0,m={request_event_type:e,request_bytes_loaded:o,request_start:d,request_response_start:h,request_response_end:u,request_hostname:a?eh(a.responseURL):void 0,request_id:c?eA(c):void 0,request_response_headers:c,request_media_duration:s.duration,request_url:null==a?void 0:a.responseURL};"main"===s.type?(m.request_type="media",m.request_current_level=s.level,m.request_video_width=(i.levels[s.level]||{}).width,m.request_video_height=(i.levels[s.level]||{}).height,m.request_labeled_bitrate=(i.levels[s.level]||{}).bitrate):m.request_type=s.type,l("requestcompleted",m)};i.on(r.Events.FRAG_LOADED,u);var c=function(e,t){var i=t.frag,r=i.start;l("fragmentchange",{currentFragmentPDT:n(i),currentFragmentStart:s(r)})};i.on(r.Events.FRAG_CHANGED,c);var m=function(e,t){var i,a=t.type,s=t.details,n=t.response,o=t.fatal,d=t.frag,h=t.networkDetails,u=(null==d?void 0:d.url)||t.url||"",c=h?ek(h):void 0;(s===r.ErrorDetails.MANIFEST_LOAD_ERROR||s===r.ErrorDetails.MANIFEST_LOAD_TIMEOUT||s===r.ErrorDetails.FRAG_LOAD_ERROR||s===r.ErrorDetails.FRAG_LOAD_TIMEOUT||s===r.ErrorDetails.LEVEL_LOAD_ERROR||s===r.ErrorDetails.LEVEL_LOAD_TIMEOUT||s===r.ErrorDetails.AUDIO_TRACK_LOAD_ERROR||s===r.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT||s===r.ErrorDetails.SUBTITLE_LOAD_ERROR||s===r.ErrorDetails.SUBTITLE_LOAD_TIMEOUT||s===r.ErrorDetails.KEY_LOAD_ERROR||s===r.ErrorDetails.KEY_LOAD_TIMEOUT)&&l("requestfailed",{request_error:s,request_url:u,request_hostname:eh(u),request_id:c?eA(c):void 0,request_type:s===r.ErrorDetails.FRAG_LOAD_ERROR||s===r.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":s===r.ErrorDetails.AUDIO_TRACK_LOAD_ERROR||s===r.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT?"audio":s===r.ErrorDetails.SUBTITLE_LOAD_ERROR||s===r.ErrorDetails.SUBTITLE_LOAD_TIMEOUT?"subtitle":s===r.ErrorDetails.KEY_LOAD_ERROR||s===r.ErrorDetails.KEY_LOAD_TIMEOUT?"encryption":"manifest",request_error_code:null==n?void 0:n.code,request_error_text:null==n?void 0:n.text}),o&&l("error",{player_error_code:a,player_error_message:s,player_error_context:"".concat(u?"url: ".concat(u,"\n"):"")+"".concat(n&&(n.code||n.text)?"response: ".concat(n.code,", ").concat(n.text,"\n"):"")+"".concat(t.reason?"failure reason: ".concat(t.reason,"\n"):"")+"".concat(t.level?"level: ".concat(t.level,"\n"):"")+"".concat(t.parent?"parent stream controller: ".concat(t.parent,"\n"):"")+"".concat(t.buffer?"buffer length: ".concat(t.buffer,"\n"):"")+"".concat(t.error?"error: ".concat(t.error,"\n"):"")+"".concat(t.event?"event: ".concat(t.event,"\n"):"")+"".concat(t.err?"error message: ".concat(null==(i=t.err)?void 0:i.message,"\n"):"")})};i.on(r.Events.ERROR,m);var f=function(e,t){var i=t.frag,r=i&&i._url||"";l("requestcanceled",{request_event_type:e,request_url:r,request_type:"media",request_hostname:eh(r)})};i.on(r.Events.FRAG_LOAD_EMERGENCY_ABORTED,f);var p=function(e,t){var r=t.level,s=i.levels[r];if(s&&s.attrs&&s.attrs.BANDWIDTH){var n,o=s.attrs.BANDWIDTH,d=parseFloat(s.attrs["FRAME-RATE"]);isNaN(d)||(n=d),o?l("renditionchange",{video_source_fps:n,video_source_bitrate:o,video_source_width:s.width,video_source_height:s.height,video_source_rendition_name:s.name,video_source_codec:null==s?void 0:s.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,o),i.off(r.Events.LEVEL_LOADED,d),i.off(r.Events.AUDIO_TRACK_LOADED,h),i.off(r.Events.FRAG_LOADED,u),i.off(r.Events.FRAG_CHANGED,c),i.off(r.Events.ERROR,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)},eL=function(e){e&&"function"==typeof e._stopMuxMonitor&&e._stopMuxMonitor()},eI=function(e,t){if(!e||!e.requestEndDate)return{};var i,r=eh(e.url),a=e.url,s=e.bytesLoaded,n=new Date(e.requestStartDate).getTime(),l=new Date(e.firstByteDate).getTime(),o=new Date(e.requestEndDate).getTime(),d=isNaN(e.duration)?0:e.duration,h="function"==typeof t.getMetricsFor?t.getMetricsFor(e.mediaType).HttpList:t.getDashMetrics().getHttpRequests(e.mediaType);h.length>0&&(i=eT(h[h.length-1]._responseHeaders||""));var u=i?eA(i):void 0;return{requestStart:n,requestResponseStart:l,requestResponseEnd:o,requestBytesLoaded:s,requestResponseHeaders:i,requestMediaDuration:d,requestHostname:r,requestUrl:a,requestId:u}},ew=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}:{}},eD=function(e){var t;return null==(t=e.match(/.*codecs\*?="(.*)"/))?void 0:t[1]},eC=function(e){try{var t,i;return null==(i=e.getVersion)||null==(t=i.call(e))?void 0:t.split(".").map(function(e){return parseInt(e)})[0]}catch(e){return!1}},eM=function(e,t,i){arguments.length>3&&void 0!==arguments[3]&&arguments[3];var r=e.log;if(!i||!i.on)return void r.warn("Invalid dash.js player reference. Monitoring blocked.");var a=eC(i),s=function(i,r){return e.emit(t,i,r)},n=function(e){var t=e.type,i=(e.data||{}).url;s("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:eh(i),request_url:i})};i.on("manifestLoaded",n);var l={},o=function(e){if("function"!=typeof e.getRequests)return null;var t=e.getRequests({state:"executed"});return 0===t.length?null:t[t.length-1]},d=function(e){var t=e.type,r=e.chunk,a=e.request,n=(r||{}).mediaInfo||{},o=n.type,d=n.bitrateList,h={};
1(d=d||[]).forEach(function(e,t){h[t]={},h[t].width=e.width,h[t].height=e.height,h[t].bitrate=e.bandwidth,h[t].attrs={}}),"video"===o?l.video=h:"audio"===o?l.audio=h:l.media=h;var u=eI(a,i),c=u.requestStart,m=u.requestResponseStart,f=u.requestResponseEnd,p=u.requestResponseHeaders,g=u.requestMediaDuration,v=u.requestHostname,E=u.requestUrl;s("requestcompleted",{request_event_type:t,request_start:c,request_response_start:m,request_response_end:f,request_bytes_loaded:-1,request_type:o+"_init",request_response_headers:p,request_hostname:v,request_id:u.requestId,request_url:E,request_media_duration:g,request_rendition_lists:l})};a>=4?i.on("initFragmentLoaded",d):i.on("initFragmentLoaded",function(e){var t=e.type,i=e.fragmentModel,r=e.chunk;d({type:t,request:o(i),chunk:r})});var h=function(e){var t=e.type,r=e.chunk,a=e.request,n=r||{},l=n.mediaInfo,o=n.start,d=(l||{}).type,h=eI(a,i),u=h.requestStart,c=h.requestResponseStart,m=h.requestResponseEnd,f=h.requestBytesLoaded,p=h.requestResponseHeaders,g=h.requestMediaDuration,v=h.requestHostname,E=h.requestUrl,y=h.requestId,b=ew(d,i),T=b.currentLevel,A=b.renditionWidth,S=b.renditionHeight;s("requestcompleted",{request_event_type:t,request_start:u,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:o,request_media_duration:g,request_current_level:T,request_labeled_bitrate:b.renditionBitrate,request_video_width:A,request_video_height:S})};a>=4?i.on("mediaFragmentLoaded",h):i.on("mediaFragmentLoaded",function(e){var t=e.type,i=e.fragmentModel,r=e.chunk;h({type:t,request:o(i),chunk:r})});var u={video:void 0,audio:void 0,totalBitrate:void 0},c=function(){if(u.video&&"number"==typeof u.video.bitrate){if(!(u.video.width&&u.video.height))return void r.warn("have bitrate info for video but missing width/height");var e=u.video.bitrate;if(u.audio&&"number"==typeof u.audio.bitrate&&(e+=u.audio.bitrate),e!==u.totalBitrate)return u.totalBitrate=e,{video_source_bitrate:e,video_source_height:u.video.height,video_source_width:u.video.width,video_source_codec:eD(u.video.codec)}}},m=function(e,t,a){var n=e.mediaType;if("audio"===n||"video"===n){if("function"==typeof i.getRepresentationsByType)if(e.newRepresentation)l={bitrate:e.newRepresentation.bandwidth,width:e.newRepresentation.width,height:e.newRepresentation.height,qualityIndex:e.newRepresentation.absoluteIndex};else{var l,o=i.getRepresentationsByType(n);if(o&&"number"==typeof e.newQuality){var d=o.find(function(t){return t.absoluteIndex===e.newQuality||t.index===e.newQuality});d&&(l={bitrate:d.bandwidth,width:d.width,height:d.height,qualityIndex:e.newQuality})}}else{if("number"!=typeof e.newQuality)return void r.warn("missing evt.newQuality in qualityChangeRendered event",e);l=i.getBitrateInfoListFor(n).find(function(t){return t.qualityIndex===e.newQuality})}if(!(l&&"number"==typeof l.bitrate))return void r.warn("missing bitrate info for ".concat(n));u[n]=eE(ev({}
1,l),{codec:i.getCurrentTrackFor(n).codec});var h=c();h&&s("renditionchange",h)}};i.on("qualityChangeRendered",m);var f=function(e){var t=e.request,i=e.mediaType;s("requestcanceled",{request_event_type:(t=t||{}).type+"_"+t.action,request_url:t.url,request_type:i,request_hostname:eh(t.url)})};i.on("fragmentLoadingAbandoned",f);var p=function(e){var t,i,r=e.error,a=(null==r||null==(t=r.data)?void 0:t.request)||{},n=(null==r||null==(i=r.data)?void 0:i.response)||{};(null==r?void 0:r.code)===27&&s("requestfailed",{request_error:a.type+"_"+a.action,request_url:a.url,request_hostname:eh(a.url),request_type:a.mediaType,request_error_code:n.status,request_error_text:n.statusText});var l="".concat(null!=a&&a.url?"url: ".concat(a.url,"\n"):"")+"".concat(null!=n&&n.status||null!=n&&n.statusText?"response: ".concat(null==n?void 0:n.status,", ").concat(null==n?void 0:n.statusText,"\n"):"");s("error",{player_error_code:null==r?void 0:r.code,player_error_message:null==r?void 0:r.message,player_error_context:l})};i.on("error",p),i._stopMuxMonitor=function(){i.off("manifestLoaded",n),i.off("initFragmentLoaded",d),i.off("mediaFragmentLoaded",h),i.off("qualityChangeRendered",m),i.off("error",p),i.off("fragmentLoadingAbandoned",f),delete i._stopMuxMonitor}},ex=function(e){e&&"function"==typeof e._stopMuxMonitor&&e._stopMuxMonitor()},eP=0,eO=function(){function e(){er(this,e),en(this,"_listeners",void 0)}return es(e,[{key:"on",value:function(e,t,i){return t._eventEmitterGuid=t._eventEmitterGuid||++eP,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||++eP;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*"]||[],s=this._listeners[e]||[],n=this._listeners["after"+e]||[],l=function(t,r){(t=t.slice()).forEach(function(t){t.call(i,{type:e},r)})};l(r,t),l(a,t),l(s,t),l(n,t)}}}]),e}(),eN=T(A()),eU=function(){function e(t){var i=this;er(this,e),en(this,"_playbackHeartbeatInterval",void 0),en(this,"_playheadShouldBeProgressing",void 0),en(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&&(eN.default.clearInterval(i._playbackHeartbeatInterval),t.emit("playbackheartbeatend",{viewer_time:r.viewer_time}),i._playbackHeartbeatInterval=null)})}return es(e,[{key:"_startPlaybackHeartbeatInterval",value:function(){var e=this;null===this._playbackHeartbeatInterval&&(this.pm.emit("playbackheartbeat"),this._playbackHeartbeatInterval=eN.default.setInterval(function(){e.pm.emit("playbackheartbeat")},this.pm.playbackHeartbeatTime))}},{key:"_stopPlaybackHeartbeatInterval",value:function(){this._playheadShouldBeProgressing=!1,null!==this._playbackHeartbeatInterval&&(eN.default.clearInterval(this._playbackHeartbeatInterval),this.pm.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)}}]),e}(),eF=function e(t){var i=this;er(this,e),en(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,s;null==(e=t.data)||delete e.player_error_code,null==(i=t.data)||delete i.player_error_message,null==(r=t.data)||delete r.player_error_context,null==(a=t.data)||delete a.player_error_severity,null==(s=t.data)||delete s.player_error_business_exception})},eB=function(){function e(t){er(this,e),en(this,"_watchTimeTrackerLastCheckedTime",void 0),en(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 es(e,[{key:"_updateWatchTime",value:function(e,t){var i=t.viewer_time;null===this._watchTimeTrackerLastCheckedTime&&(this._watchTimeTrackerLastCheckedTime=i),eg(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}(),e$=function(){function e(t){var i=this;er(this,e),en(this,"_playbackTimeTrackerLastPlayheadPosition",void 0),en(this,"_lastTime",void 0),en(this,"_isAdPlaying",void 0),en(this,"_callbackUpdatePlaybackTime",void 0),en(this,"pm",void 0),this.pm=t,this._playbackTimeTrackerLastPlayheadPosition=-1,this._lastTime=j(),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 s=this._stopPlaybackTimeTracking.bind(this);t.on("playbackheartbeatend",s),t.on("seeking",s),t.on("rebufferstart",s),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(),i._isAdPlaying=!1,i._callbackUpdatePlaybackTime=null})}return es(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(),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(),i=t-this._lastTime,r=-1;this._playbackTimeTrackerLastPlayheadPosition>=0&&e>
1this._playbackTimeTrackerLastPlayheadPosition?r=e-this._playbackTimeTrackerLastPlayheadPosition:this._isAdPlaying&&(r=i),r>0&&r<=1e3&&eg(this.pm.data,"view_content_playback_time",r),null!==this._callbackUpdatePlaybackTime&&i>0&&i<=1e3&&(this._isAdPlaying&&eg(this.pm.data,"ad_playing_time_ms_cumulative",i),eg(this.pm.data,"view_playing_time_ms_cumulative",i)),this._playbackTimeTrackerLastPlayheadPosition=e,this._lastTime=t}}]),e}(),eH=function(){function e(t){er(this,e),en(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 es(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}(),eG=function e(t){if(er(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;eg(t.data,"view_rebuffer_duration",r),i=e.viewer_time,t.data.view_rebuffer_duration>3e5&&(t.emit("viewend"),t.send("viewend"),t.mux.log.warn("Ending view after rebuffering for longer than ".concat(3e5,"ms, future events will be ignored unless a programchange or videochange occurs.")))}t.data.view_watch_time>=0&&t.data.view_rebuffer_count>0&&(t.data.view_rebuffer_frequency=t.data.view_rebuffer_count/t.data.view_watch_time,t.data.view_rebuffer_percentage=t.data.view_rebuffer_duration/t.data.view_watch_time)};t.on("playbackheartbeat",function(e,t){return a(t)}),t.on("rebufferstart",function(e,a){i||(eg(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)})}},eW=function(){function e(t){var i=this;er(this,e),en(this,"_lastCheckedTime",void 0),en(this,"_lastPlayheadTime",void 0),en(this,"_lastPlayheadTimeUpdatedTime",void 0),en(this,"_rebuffering",void 0),en(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()})}))}return es(e,[{key:"_checkIfRebuffering",value:function(e,t){if(this.pm.seekingTracker.isSeeking||this.pm.adTracker.isAdBreak||!this.pm.playbackHeartbeat._playheadShouldBeProgressing)return void this._cleanupRebufferTracker(e,t);if(null===this._lastCheckedTime)return void this._prepareRebufferTrackerState(t.viewer_time);if(this._lastPlayheadTime!==this.pm.data.player_playhead_time)return void this._cleanupRebufferTracker(e,t,!0);var i=t.viewer_time-this._lastPlayheadTimeUpdatedTime;"number"==typeof this.pm.sustainedRebufferThreshold&&i>=this.pm.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),this._lastCheckedTime=t.viewer_time}},{key:"_clearRebufferTrackerState",value:function(){this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null}},{key:"_prepareRebufferTrackerState",value:function(e){this._lastCheckedTime=e,this._lastPlayheadTime=this.pm.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=e}},{key:"_cleanupRebufferTracker",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(this._rebuffering)this._rebuffering=!1,this.pm.emit("rebufferend",{viewer_time:t.viewer_time});else{if(null===this._lastCheckedTime)return;var r=this.pm.data.player_playhead_time-this._lastPlayheadTime,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}(),eK=function(){function e(t){var i=this;er(this,e),en(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 s=a.viewer_time;"playing"===e.type&&void 0===t.data.view_time_to_first_frame?i.calculateTimeToFirstFrame(s||j(),r):"adplaying"===e.type&&(void 0===t.data.view_time_to_first_frame||i._inPrerollPosition())&&i.calculateTimeToFirstFrame(s||j(),r)};t.one("playing",a),t.one("adplaying",a),t.one("viewend",function(){t.off("playing",a),t.off("adplaying",a)})}})}return es(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}(),eV=function e(t){var i=this;er(this,e),en(this,"_lastPlayerHeight",void 0),en(this,"_lastPlayerWidth",void 0),en(this,"_lastPlayheadPosition",void 0),en(this,"_lastSourceHeight",void 0),en(this,"_lastSourceWidth",void 0),t.on("viewinit",function(){i._lastPlayheadPosition=-1}),["pause","rebufferstart","seeking","error","adbreakstart","hb","renditionchange","orientationchange","viewend","playbackmodechange"].forEach(function(e){t.on(e,function(){if(i._lastPlayheadPosition>=0&&t.data.player_playhead_time>=0&&i._lastPlayerWidth>=0&&i._lastSourceWidth>0&&i._lastPlayerHeight>=0&&i._lastSourceHeight>0){var e=t.data.player_playhead_time-i._lastPlayheadPosition;if(e<0){i._lastPlayheadPosition=-1;return}var r=Math.min(i._lastPlayerWidth/i._lastSourceWidth,i._lastPlayerHeight/i._lastSourceHeight),a=Math.max(0,r-1),s=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,s),eg(t.data,"view_total_content_playback_time",e),eg(t.data,"view_total_upscaling",a*e),eg(t.data,"view_total_downscaling",s*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})})},eq=function e(t){var i=this;er(this,e),en(this,"isSeeking",void 0),this.isSeeking=!1;var r=-1,a=function(){var e=j(),a=(t.data.viewer_time||e)-(r||e);eg(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,s){if(Object.assign(t.data,s),i.isSeeking&&s.viewer_time-r<=2e3){r=s.viewer_time;return}i.isSeeking&&a(),i.isSeeking=!0,r=s.viewer_time,eg(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})},ej=function(e,t){e.push(t),e.sort(function(e,t){return e.viewer_time-t.viewer_time})},eY=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror","adclicked","adskipped"],ez=function(){function e(t){var i=this;er(this,e),en(this,"_adHasPlayed",void 0),en(this,"_adRequests",void 0),en(this,"_adResponses",void 0),en(this,"_currentAdRequestNumber",void 0),en(this,"_currentAdResponseNumber",void 0),en(this,"_prerollPlayTime",void 0),en(this,"_wouldBeNewAdPlay",void 0),en(this,"isAdBreak",void 0),en(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}),eY.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),ej(i._adRequests,r),eg(t.data,"view_ad_request_count"),i.inPrerollPosition()&&(t.data.view_preroll_requested=!0,i._adHasPlayed||eg(t.data,"view_preroll_request_count"))}),t.on("adresponse",function(e,r){r=Object.assign({ad_request_id:"generatedAdRequestId"+i._currentAdResponseNumber++},r),ej(i._adResponses,r);var a=i.findAdRequest(r.ad_request_id);a&&eg(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,eg(t.data,"view_ad_played_count")),i.inPrerollPosition()&&
1!t.data.view_preroll_played&&(t.data.view_preroll_played=!0,i._adRequests.length>0&&(t.data.view_preroll_request_time=Math.max(0,r.viewer_time-i._adRequests[0].viewer_time)),t.data.view_start&&(t.data.view_startup_preroll_request_time=Math.max(0,r.viewer_time-t.data.view_start)),i._prerollPlayTime=r.viewer_time)}),t.on("adplaying",function(e,r){i.inPrerollPosition()&&void 0===t.data.view_preroll_load_time&&void 0!==i._prerollPlayTime&&(t.data.view_preroll_load_time=r.viewer_time-i._prerollPlayTime,t.data.view_startup_preroll_load_time=r.viewer_time-i._prerollPlayTime)}),t.on("adclicked",function(e,r){i._wouldBeNewAdPlay||eg(t.data,"view_ad_clicked_count")}),t.on("adskipped",function(e,r){i._wouldBeNewAdPlay||eg(t.data,"view_ad_skipped_count")}),t.on("adended",function(){i._wouldBeNewAdPlay=!0}),t.on("aderror",function(){i._wouldBeNewAdPlay=!0})}return es(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=W(eu(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 s=W(eu(t.ad_asset_url),2),n=s[0],l=s[1];this.pm.data.view_preroll_ad_asset_domain=l,this.pm.data.view_preroll_ad_asset_hostname=n}this.pm.data.ad_type="preroll"}this.pm.data.ad_asset_url=null==t?void 0:t.ad_asset_url,this.pm.data.ad_tag_url=null==t?void 0:t.ad_tag_url,this.pm.data.ad_creative_id=null==t?void 0:t.ad_creative_id,this.pm.data.ad_id=null==t?void 0:t.ad_id,this.pm.data.ad_universal_id=null==t?void 0:t.ad_universal_id,null!=t&&t.ad_type&&(this.pm.data.ad_type=null==t?void 0:t.ad_type)}}]),e}(),eQ=function e(t){var i=this;er(this,e),en(this,"lastWallClockTime",void 0);var r=function(){i.lastWallClockTime=j(),t.on("before*",a)},a=function(e){var r=j(),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)})},eX=T(A()),eZ=(tR=function(){for(var e=0,t={};e<arguments.length;e++){var i=arguments[e];for(var r in i)t[r]=i[r]}return t},function e(t){function i(e,r,a){var s;if("u">typeof document){if(arguments.length>1){if("number"==typeof(a=tR({path:"/"},i.defaults,a)).expires){var n=new Date;n.setMilliseconds(n.getMilliseconds()+864e5*a.expires),a.expires=n}try{s=JSON.stringify(r),/^[\{\[]/.test(s)&&(r=s)}catch(e){}return r=t.write?t.write(r,e):encodeURIComponent(String(r)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),e=(e=(e=encodeURIComponent(String(e))).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent)).replace(/[\(\)]/g,escape),document.cookie=e+"="+r+(a.expires?"; expires="+a.expires.toUTCString():"")+(a.path?"; path="+a.path:"")+(a.domain?"; domain="+a.domain:"")+(a.secure?"; secure":"")}e||(s={});for(var l=document.cookie?document.cookie.split("; "):[],o=/(%[0-9A-Z]{2})+/g,d=0;d<l.length;d++){var h=l[d].split("="),u=h.slice(1).join("=");'"'===u.charAt(0)&&(u=u.slice(1,-1));try{var c=h[0].replace(o,decodeURIComponent);if(u=t.read?t.read(u,c):t(u,c)||u.replace(o,decodeURIComponent),this.json)try{u=JSON.parse(u)}catch(e){}if(e===c){s=u;break}e||(s[c]=u)}catch(e){}}return s}}return i.set=i,i.get=function(e){return i.call(i,e)},i.getJSON=function(){return i.apply({json:!0},[].slice.call(arguments))},i.defaults={},i.remove=function(e,t){i(e,"",tR(t,{expires:-1}))},i.withConverter=e,i}(function(){})),eJ="muxData",e0=function(){var e;try{e=(eZ.get(eJ)||"").split("&").reduce(function(e,t){var i=W(t.split("="),2),r=i[0],a=i[1],s=+a;return e[r]=a&&s==a?s:a,e},{})}catch(t){e={}}return e},e1=function(e){try{eZ.set(eJ,Object.entries(e).map(function(e){var t=W(e,2),i=t[0],r=t[1];return"".concat(i,"=").concat(r)}).join("&"),{expires:365})}catch(e){}},e2=function(){var e=e0();return e.mux_viewer_id=e.mux_viewer_id||Y(),e.msn=e.msn||Math.random(),e1(e),{mux_viewer_id:e.mux_viewer_id,mux_sample_number:e.msn}},e3=function(){var e=e0(),t=j();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=Y(),e.sst=t),e.sex=t+15e5,e1(e),{session_id:e.sid,session_start:e.sst,session_expires:e.sex}},e4=e8({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"}),e5=e8({ad:"ad",af:"affiliate",ag:"aggregate",ap:"api",al:"application",ao:"audio",ar:"architecture",as:"asset",au:"autoplay",av:"average",bi:"bitrate",bn:"brand",br:"break",bw:"browser",by:"bytes",bz:"business",ca:"cached",cb:"cancel",cc:"codec",cd:"code",cg:"category",ch:"changed",ci:"client",ck:"clicked",cl:"canceled",cm:"cmcd",cn:"config",co:"count",ce:"counter",cp:"complete",cq:"creator",cr:"creative",cs:"captions",ct:"content",cu:"current",cv:"cumulative",cx:"c
1onnection",cz:"context",da:"data",dg:"downscaling",dm:"domain",dn:"cdn",do:"downscale",dr:"drm",dp:"dropped",du:"duration",dv:"device",dy:"dynamic",eb:"enabled",ec:"encoding",ed:"edge",en:"end",eg:"engine",em:"embed",er:"error",ep:"experiments",es:"errorcode",et:"errortext",ee:"event",ev:"events",ex:"expires",ez:"exception",fa:"failed",fi:"first",fm:"family",ft:"format",fp:"fps",fq:"frequency",fr:"frame",fs:"fullscreen",ha:"has",hb:"holdback",he:"headers",ho:"host",hn:"hostname",ht:"height",id:"id",ii:"init",in:"instance",ip:"ip",is:"is",ke:"key",la:"language",lb:"labeled",le:"level",li:"live",ld:"loaded",lo:"load",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",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 e8(e){var t={};for(var i in e)e.hasOwnProperty(i)&&(t[e[i]]=i);return t}function e6(e){var t={},i={};return Object.keys(e).forEach(function(r){var a=!1;if(e.hasOwnProperty(r)&&void 0!==e[r]){var s=r.split("_"),n=s[0],l=e4[n];l||(J.info("Data key word `"+s[0]+"` not expected in "+r),l=n+"_"),s.splice(1).forEach(function(e){"url"===e&&(a=!0),e5[e]?l+=e5[e]:Number.isInteger(Number(e))?l+=e:(J.info("Data key word `"+e+"` not expected in "+r),l+="_"+e+"_")}),a?i[l]=e[r]:t[l]=e[r]}}),Object.assign(t,i)}var e9=T(A()),e7=T($()),te={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4,maxPayloadKBSize:500},tt=["hb","requestcompleted","requestfailed","requestcanceled"],ti=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({},te,t)};ti.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)},ti.prototype.flushEvents=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];e&&1===this._eventQueue.length?this._eventQueue.pop():(this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending())},ti.prototype.destroy=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.destroyed=!0,e?this._clearBeaconQueue():this.flushEvents(),e9.default.clearTimeout(this._sendTimeout)},ti.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],e6({mux_view_message:"event queue truncated"}));var i=this._createPayload(t);ta(this._beaconUrl,i,!0,function(){})},ti.prototype._sendBeaconQueue=function(){var e=this;if(this._postInFlight){this._resendAfterPost=!0;return}var t=this._eventQueue.slice(0,this._options.maxBeaconSize);this._eventQueue=this._eventQueue.slice(this._options.maxBeaconSize),this._postInFlight=!0;var i=this._createPayload(t),r=j();ta(this._beaconUrl,i,!1,function(i,a){a?(e._eventQueue=t.concat(e._eventQueue),e._failureCount+=1,J.info("Error sending beacon: "+a)):e._failureCount=0,e._roundTripTime=j()-r,e._postInFlight=!1,e._resendAfterPost&&(e._resendAfterPost=!1,e._eventQueue.length>0&&e._sendBeaconQueue())})},ti.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},ti.prototype._startBeaconSending=function(){var e=this;e9.default.clearTimeout(this._sendTimeout),this.destroyed||(this._sendTimeout=e9.default.setTimeout(function(){e._eventQueue.length&&e._sendBeaconQueue(),e._startBeaconSending()},this._getNextBeaconTime()))},ti.prototype._createPayload=function(e){var t=this,i={transmission_timestamp:Math.round(j())};this._roundTripTime&&(i.rtt_ms=Math.round(this._roundTripTime));var r,a,s,n=function(){s=(r=JSON.stringify({metadata:i,events:a||e})).length/1024},l=function(){return s<=t._options.maxPayloadKBSize};return n(),l()||(J.info("Payload size is too big ("+s+" kb). Removing unnecessary events."),a=e.filter(function(e){return -1===tt.indexOf(e.e)}),n()),l()||(J.info("Payload size still too big ("+s+" 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))}}),n()),r};var tr="function"==typeof e7.default.exitPictureInPicture?function(e){return e.length<=57344}:function(e){return!1},ta=function(e,t,i,r){if(i&&navigator&&navigator.sendBeacon&&navigator.sendBeacon(e,t))return void r();if(e9.default.fetch)return void e9.default.fetch(e,{method:"POST",body:t,headers:{"Content-Type":"text/plain"},keepalive:tr(t)}).then(function(e){return r(null,e.ok?null:"Error")}).catch(function(e){return r(null,e)});if(e9.default.XMLHttpRequest){var a=new e9.default.XMLHttpRequest;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"),a.send(t);return}r()},ts=["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"],tn=["adplay","adplaying","adpause","adfirstquartile","admidpoint","adthirdquartile","adended","adresponse","adrequest"],tl=["ad_id","ad_creative_id","ad_universal_id"],to=["viewstart","error","ended","viewend"],td=function(){function e(t,i){var r,a,s,n,l,o,d,h,u,c,m,f,p,g,v,E,y,b,T,A=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};er(this,e),en(this,"mux",void 0),en(this,"envKey",void 0),en(this,"options",void 0),en(this,"eventQueue",void 0),en(this,"sampleRate",void 0),en(this,"disableCookies",void 0),en(this,"respectDoNotTrack",void 0),en(this,"previousBeaconData",void 0),en(this,"lastEventTime",void 0),en(this,"rateLimited",void 0),en(this,"pageLevelData",void 0),en(this,"viewerData",void 0),this.mux=t,this.envKey=i,this.options=A,this.previousBeaconData=null,this.lastEventTime=0,this.rateLimited=!1,this.eventQueue=new ti((r=this.envKey,s=(a=this.options).beaconCollectionDomain,n=a.beaconDomain,s?(/localhost(?::\d+)?$/.test(s)?"http://":"https://")+s:(r=r||"inferred").match(/^[a-z0-9]+$/)?"https://"+r+"."+(n||"litix.io"):"https://img.litix.io/a.gif")),this.sampleRate=null!=(y=this.options.sampleRate)?y:1,this.disableCookies=null!=(b=this.options.disableCookies)&&b,this.respectDoNotTrack=null!=(T=this.options.respectDoNotTrack)&&T,this.previousBeaconData=null,this.lastEventTime=0,this.rateLimited=!1,this.pageLevelData={mux_api_version:this.mux.API_VERSION,mux_embed:this.mux.NAME,mux_embed_version:this.mux.VERSION,viewer_application_name:null==(l=this.options.platform)?void 0:l.name,viewer_application_version:null==(o=this.options.platform)?void 0:o.version,viewer_application_engine:null==(d=this.options.platform)?void 0:d.layout,viewer_device_name:null==(h=this.options.platform)?void 0:h.product,viewer_device_category:"",viewer_device_manufacturer:null==(u=this.options.platform)?void 0:u.manufacturer,viewer_os_family:null==(m=this.options.platform)||null==(c=m.os)?void 0:c.family,viewer_os_architecture:null==(p=this.options.platform)||null==(f=p.os)?void 0:f.architecture,viewer_os_version:null==(v=this.options.platform)||null==(g=v.os)?void 0:g.version,page_url:null===eX.default||void 0===eX.default||null==(E=eX.default.location)?void 0:E.href},this.viewerData=this.disableCookies?{}:e2()}return es(e,[{key:"send",value:function(e,t){if(!(!e||!(null!=t&&t.view_id))){if(this.respectDoNotTrack&&et())return J.info("Not sending `"+e+"` because Do Not Track is enabled");if(!t||"object"!=typeof t)return J.error("A data object was expected in send() but was not provided");var i=this.disableCookies?{}:e3(),r=eE(ev({},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,s=(null!=(a=r.mux_sample_number)?a:0)>=this.sampleRate,n=e6(this._deduplicateBeaconData(e,r));if(this.lastEventTime=this.mux.utils.now(),s)return J.info("Not sending event due to sample rate restriction",e,r,n);if(this.envKey||J.info("Missing environment key (envKey) - beacons will be dropped if the video source is not a valid mux video URL",e,r,n),!this.rateLimited)if(J.info("Sending event",e,r,n),this.rateLimited=!this.eventQueue.queueEvent(e,n),this.mux.WINDOW_UNLOADING&&"viewend"===e)this.eventQueue.destroy(!0);else{if(this.mux.WINDOW_HIDDEN&&"hb"===e)this.eventQueue.flushEvents(!0);else if(to.indexOf(e)>=0){if("error"===e&&"warning"===t.player_error_severity)return;this.eventQueue.flushEvents()}if(this.rateLimited)return r.event="eventrateexceeded",n=e6(r),this.eventQueue.queueEvent(r.event,n),J.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=ev({},t),a&&(this.previousBeaconData=r),a&&"viewend"===e&&(this.previousBeaconData=null);else{var s=0===e.indexOf("request");Object.entries(t).forEach(function(t){var a=W(t,2),n=a[0],l=a[1];i.previousBeaconData&&(l!==i.previousBeaconData[n]||ts.indexOf(n)>-1||i.objectHasChanged(s,n,l,i.previousBeaconData[n])||i.eventRequiresKey(e,n))&&
1(r[n]=l,i.previousBeaconData[n]=l)})}return r}},{key:"objectHasChanged",value:function(e,t,i,r){return!!e&&0===t.indexOf("request_")&&("request_response_headers"===t||"object"!=typeof i||"object"!=typeof r||Object.keys(i||{}).length!==Object.keys(r||{}).length)}},{key:"eventRequiresKey",value:function(e,t){return!!("renditionchange"===e&&0===t.indexOf("video_source_")||tl.includes(t)&&tn.includes(e)||"playbackmodechange"===e&&0===t.indexOf("player_playback_mode"))}}]),e}(),th=function e(t){er(this,e);var i=0,r=0,a=0,s=0,n=0,l=0,o=0;t.on("requestcompleted",function(e,l){var o,d,h=l.request_start,u=l.request_response_start,c=l.request_response_end,m=l.request_bytes_loaded;if(s++,u?(o=u-(null!=h?h:0),d=(null!=c?c:0)-u):d=(null!=c?c:0)-(null!=h?h:0),d>0&&m&&m>0){var f=m/d*8e3;n++,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=s,o>0&&(i+=o,t.data.view_max_request_latency=Math.max(t.data.view_max_request_latency||0,o),t.data.view_average_request_latency=i/n)}}),t.on("requestfailed",function(e,i){s++,l++,t.data.view_request_count=s,t.data.view_request_failed_count=l}),t.on("requestcanceled",function(e,i){s++,o++,t.data.view_request_count=s,t.data.view_request_canceled_count=o})},tu=function e(t){var i=this;er(this,e),en(this,"_lastEventTime",void 0),t.on("before*",function(e,r){var a=r.viewer_time,s=j(),n=i._lastEventTime;if(i._lastEventTime=s,n&&s-n>36e5){var l=Object.keys(t.data).reduce(function(e,i){return 0===i.indexOf("video_")?Object.assign(e,en({},i,t.data[i])):e},{});t.mux.log.info("Received event after at least an hour inactivity, creating a new view");var o=t.playbackHeartbeat._playheadShouldBeProgressing;t._resetView(Object.assign({viewer_time:a},l)),t.playbackHeartbeat._playheadShouldBeProgressing=o,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 tc(e,t){return(null==e?void 0:e.toLowerCase())===(null==t?void 0:t.toLowerCase())}var tm=function e(t){er(this,e);var i=function(e){var i,r,a,l=null!=(i=e)&&i.request_type&&("media"===i.request_type||"video"===i.request_type)&&null!=(r=i.request_response_headers)&&r["x-cdn"]?i.request_response_headers["x-cdn"]:null!=i&&i.video_cdn?i.video_cdn:null,o=null!=(a=e)&&a.request_start?a.request_start:null!=a&&a.viewer_time?a.viewer_time:Date.now();null!=l&&!tc(l,s)&&n<=o&&(s=l,n=o,t.emit("cdnchange",{video_cdn:l}))},r=null,a=null,s=null,n=0;t.on("viewinit",function(){r=null,a=null,s=null,n=0}),t.on("beforecdnchange",function(e,t){var i=null==t?void 0:t.video_cdn;i&&(void 0===t.video_previous_cdn||null===t.video_previous_cdn)&&(tc(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)})},tf=function(e){try{return JSON.parse(e),!0}catch(e){return!1}},tp=function e(t){var i=this;er(this,e),en(this,"_emittingAutomaticEvent",!1),en(this,"_hasInitialized",!1),en(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?tf(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)})},tg=function(){function e(t){er(this,e),en(this,"pm",void 0),en(this,"_currentRangeStart",void 0),en(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 es(e,[{key:"_updateLastRangeEnd",value:function(){var e=this.pm.data.video_playback_ranges;if(e&&e.length>0){var t=this.pm.data.player_playhead_time||0;e[e.length-1][1]=t}}},{key:"_updatePlaybackRange",value:function(){var e,t=this.pm.data.player_playhead_time||0;if(!(!this.pm.disableAdPlaybackRangeFiltering&&null!=(e=this.pm.adTracker)&&e.isAdBreak&&null!==this._lastPlayheadTime&&t<this._lastPlayheadTime)){if(null!==this._lastPlayheadTime&&null!==this._currentRangeStart&&Math.abs(t-this._lastPlayheadTime)>1e3){var i=this.pm.data.video_playback_ranges;i&&i.length>0&&(i[i.length-1][1]=this._lastPlayheadTime),this._currentRangeStart=null}if(null===this._currentRangeStart){var r=this.pm.data.video_playback_ranges||[];r.length>0&&r[r.length-1][1]===t?this._currentRangeStart=r[r.length-1][0]:(this._currentRangeStart=t,r.push([t,t])),this.pm.data.video_playback_ranges=r}else this._updateLastRangeEnd();this._lastPlayheadTime=t}}},{key:"_endPlaybackRange",value:function(){null!==this._currentRangeStart&&(this._updateLastRangeEnd(),this._currentRangeStart=null,this._lastPlayheadTime=null)}}]),e}(),tv=Object.freeze({CELLULAR:"cellular",WIFI:"wifi",WIRED:"wired",OTHER:"other",NO_CONNECTION:"no_connection",UNKNOWN:"unknown"}),tE=function(e){if(!e)return tv.UNKNOWN;switch(e){case"cellular":case"wimax":return tv.CELLULAR;case"wifi":return tv.WIFI;case"ethernet":return tv.WIRED;case"none":return tv.NO_CONNECTION;case"bluetooth":case"other":default:return tv.OTHER;case"unknown":return tv.UNKNOWN}},ty=T(A()),tb=function(){function e(t){var i=this;er(this,e),en(this,"pm",void 0),en(this,"lastType",void 0),en(this,"lastLowDataMode",void 0),this.pm=t,this.pm.one("viewinit",function(){var t,r=i.emit.bind(i);r(),ty.default.addEventListener("online",r),ty.default.addEventListener("offline",r),null==(t=e.connection)||t.addEventListener("change",r),i.pm.on("destroy",function(){var t;null==(t=e.connection)||t.removeEventListener("change",r),ty.default.removeEventListener("online",r),ty.default.removeEventListener("offline",r)})})}return es(e,[{key:"type",get:function(){var t,i;return(null==(t=ty.default.navigator)?void 0:t.onLine)===!1?tv.NO_CONNECTION:null!=(i=e.connection)&&i.type?tE(e.connection.type):tv.UNKNOWN}},{key:"lowDataMode",get:function(){var t;return null==(t=e.connection)?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",ev({viewer_connection_type:e},void 0!==t&&{viewer_connection_low_data_mode:t})))}}
1],[{key:"connection",get:function(){var e;return"object"==typeof(e=ty.default.navigator)&&"connection"in e&&"object"==typeof e.connection?ty.default.navigator.connection:null}}]),e}(),tT=["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"],tA=new Set(["requestcompleted","requestfailed","requestcanceled"]),t_=function(e){if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&ed(r,e);var t,i=(t=function(){if("u"<typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}(),function(){var e,i=el(r);return e=t?Reflect.construct(i,arguments,el(this).constructor):i.apply(this,arguments),e&&("object"===R(e)||"function"==typeof e)?e:ei(this)});function r(e,t,a){er(this,r),en(ei(s=i.call(this)),"pageLoadEndTime",void 0),en(ei(s),"pageLoadInitTime",void 0),en(ei(s),"_destroyed",void 0),en(ei(s),"_heartBeatTimeout",void 0),en(ei(s),"adTracker",void 0),en(ei(s),"dashjs",void 0),en(ei(s),"data",void 0),en(ei(s),"disablePlayheadRebufferTracking",void 0),en(ei(s),"disableRebufferTracking",void 0),en(ei(s),"disableAdPlaybackRangeFiltering",void 0),en(ei(s),"errorTracker",void 0),en(ei(s),"errorTranslator",void 0),en(ei(s),"emitTranslator",void 0),en(ei(s),"getAdData",void 0),en(ei(s),"getPlayheadTime",void 0),en(ei(s),"getStateData",void 0),en(ei(s),"stateDataTranslator",void 0),en(ei(s),"hlsjs",void 0),en(ei(s),"id",void 0),en(ei(s),"longResumeTracker",void 0),en(ei(s),"minimumRebufferDuration",void 0),en(ei(s),"mux",void 0),en(ei(s),"playbackEventDispatcher",void 0),en(ei(s),"playbackHeartbeat",void 0),en(ei(s),"playbackHeartbeatTime",void 0),en(ei(s),"playheadTime",void 0),en(ei(s),"seekingTracker",void 0),en(ei(s),"sustainedRebufferThreshold",void 0),en(ei(s),"watchTimeTracker",void 0),en(ei(s),"currentFragmentPDT",void 0),en(ei(s),"currentFragmentStart",void 0),s.pageLoadInitTime=ep(),s.pageLoadEndTime=ef(),s.mux=e,s.id=t,null!=a&&a.beaconDomain&&s.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({debug:!1,minimumRebufferDuration:250,sustainedRebufferThreshold:1e3,playbackHeartbeatTime:25,beaconDomain:"litix.io",sampleRate:1,disableCookies:!1,respectDoNotTrack:!1,disableRebufferTracking:!1,disablePlayheadRebufferTracking:!1,disableAdPlaybackRangeFiltering:!1,errorTranslator:function(e){return e},emitTranslator:function(){for(var e=arguments.length,t=Array(e),i=0;i<e;i++)t[i]=arguments[i];return t},stateDataTranslator:function(e){return e}},a)).data=a.data||{},a.data.property_key&&(a.data.env_key=a.data.property_key,delete a.data.property_key),J.level=a.debug?1:3,s.getPlayheadTime=a.getPlayheadTime,s.getStateData=a.getStateData||function(){return{}},s.getAdData=a.getAdData||function(){},s.minimumRebufferDuration=a.minimumRebufferDuration,s.sustainedRebufferThreshold=a.sustainedRebufferThreshold,s.playbackHeartbeatTime=a.playbackHeartbeatTime,s.disableRebufferTracking=a.disableRebufferTracking,s.disableRebufferTracking&&s.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."),s.disablePlayheadRebufferTracking=a.disablePlayheadRebufferTracking,s.disableAdPlaybackRangeFiltering=a.disableAdPlaybackRangeFiltering,s.errorTranslator=a.errorTranslator,s.emitTranslator=a.emitTranslator,s.stateDataTranslator=a.stateDataTranslator,s.playbackEventDispatcher=new td(e,a.data.env_key,a),s.data={player_instance_id:Y(),mux_sample_rate:a.sampleRate,beacon_domain:a.beaconCollectionDomain||a.beaconDomain},s.data.view_sequence_number=1,s.data.player_sequence_number=1;var s,n=(function(){void 0===this.data.view_start&&(this.data.view_start=this.mux.utils.now(),this.emit
1("viewstart"),this.emit("renditionchange"))}).bind(ei(s));if(s.on("viewinit",function(e,t){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),Object.assign(this.data,t),this._initializeViewData(),this.one("play",n),this.one("adbreakstart",n)}),s.on("videochange",function(e,t){this._resetView(t)}),s.on("programchange",function(e,t){this.data.player_is_paused&&this.mux.log.warn("The `programchange` event is intended to be used when the content changes mid playback without the video source changing, however the video is not currently playing. If the video source is changing please use the videochange event otherwise you will lose startup time information."),this._resetView(Object.assign(t,{view_program_changed:!0})),n(),this.emit("play"),this.emit("playing")}),s.on("fragmentchange",function(e,t){this.currentFragmentPDT=t.currentFragmentPDT,this.currentFragmentStart=t.currentFragmentStart}),s.on("destroy",s.destroy),"u">typeof window&&"function"==typeof window.addEventListener&&"function"==typeof window.removeEventListener){var l=function(){var e=void 0!==s.data.view_start;s.mux.WINDOW_HIDDEN="hidden"===document.visibilityState,e&&s.mux.WINDOW_HIDDEN&&(s.data.player_is_paused||s.emit("hb"))};window.addEventListener("visibilitychange",l,!1);var o=function(e){e.persisted||s.destroy()};window.addEventListener("pagehide",o,!1),s.on("destroy",function(){window.removeEventListener("visibilitychange",l),window.removeEventListener("pagehide",o)})}return s.on("playerready",function(e,t){Object.assign(this.data,t)}),tT.forEach(function(e){s.on(e,function(t,i){0!==e.indexOf("ad")&&this._updateStateData(),Object.assign(this.data,i),this._sanitizeData()}),s.on("after"+e,function(){("error"!==e||this.errorTracker.viewErrored)&&this.send(e)})}),s.on("viewend",function(e,t){Object.assign(s.data,t)}),s.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}),s.longResumeTracker=new tu(ei(s)),s.errorTracker=new eF(ei(s)),new eQ(ei(s)),s.seekingTracker=new eq(ei(s)),s.playheadTime=new eH(ei(s)),s.playbackHeartbeat=new eU(ei(s)),new eV(ei(s)),s.watchTimeTracker=new eB(ei(s)),new e$(ei(s)),new tg(ei(s)),s.adTracker=new ez(ei(s)),new eW(ei(s)),new eG(ei(s)),new eK(ei(s)),new th(ei(s)),new tm(ei(s)),new tp(ei(s)),new tb(ei(s)),a.hlsjs&&s.addHLSJS(a),a.dashjs&&s.addDashJS(a),s.emit("viewinit",a.data),s}return es(r,[{key:"emit",value:function(e,t){var i,a=Object.assign({viewer_time:this.mux.utils.now()},t),s=[e,a];if(this.emitTranslator)try{s=this.emitTranslator(e,a)}catch(e){this.mux.log.warn("Exception in emit translator callback.",e)}null!=s&&s.length&&(i=eo(el(r.prototype),"emit",this)).call.apply(i,[this].concat(Z(s)))}},{key:"destroy",value:function(){this._destroyed||(this._destroyed=!0,void 0!==this.data.view_start&&(this.emit
1("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=W(eu(t.video_source_url),2),r=i[0];t.video_source_domain=i[1],t.video_source_hostname=r}delete t.ad_request_id,t.video_playback_ranges&&(t.video_playback_range=JSON.stringify(t.video_playback_ranges.filter(function(e){return e[0]!==e[1]}).map(function(e){return"".concat(e[0],":").concat(e[1])})),delete t.video_playback_ranges),this.playbackEventDispatcher.send(e,t),this.data.view_sequence_number++,this.data.player_sequence_number++,tA.has(e)||this._restartHeartBeat(),"viewend"===e&&delete this.data.view_id}}},{key:"_resetView",value:function(e){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",e)}},{key:"_updateStateData",value:function(){var e,t=this.getStateData();if("function"==typeof this.stateDataTranslator)try{t=this.stateDataTranslator(t)}catch(e){this.mux.log.warn("Exception in stateDataTranslator translator callback.",e)}null!=(e=this.data)&&e.video_cdn&&null!=t&&t.video_cdn&&(t.video_cdn,t=function(e,t){if(null==e)return{};var i,r,a=function(e,t){if(null==e)return{};var i,r,a={},s=Object.keys(e);for(r=0;r<s.length;r++)i=s[r],t.indexOf(i)>=0||(a[i]=e[i]);return a}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(r=0;r<s.length;r++)i=s[r],!(t.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(e,i)&&(a[i]=e[i])}return a}(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=Y(),i=function(){t===e.data.view_id&&eg(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,eR(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&&(eL(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,eM(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&&(ex(this.dashjs),this.dashjs=void 0)}}]),r}(eO),tS=T($());function tk(){return tS.default&&!!(tS.default.fullscreenElement||tS.default.webkitFullscreenElement||tS.default.mozFullScreenElement||tS.default.msFullscreenElement)}var tR,tL,tI=["loadstart","pause","play","playing","seeking","seeked","timeupdate","ratechange","stalled","waiting","error","ended"],tw={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"},tD=T(A());tD.default&&tD.default.WeakMap&&(tL=new WeakMap);var tC=function(e){return this.buffer="",this.manifest={segments:[],serverControl:{},sessionData:{}},this.currentUri={},this.process(e),this.manifest};tC.prototype.process=function(e){var t;for(this.buffer+=e,t=this.buffer.indexOf("\n");t>-1;t=this.buffer.indexOf("\n"))this.processLine(this.buffer.substring(0,t)),this.buffer=this.buffer.substring(t+1)}
1,tC.prototype.processLine=function(e){var t=e.indexOf(":"),i=tF(e,t),r=i[0],a=2===i.length?tP(i[1]):void 0;if("#"!==r[0])this.currentUri.uri=r,this.manifest.segments.push(this.currentUri),!this.manifest.targetDuration||"duration"in this.currentUri||(this.currentUri.duration=this.manifest.targetDuration),this.currentUri={};else switch(r){case"#EXT-X-TARGETDURATION":if(!isFinite(a)||a<0)return;this.manifest.targetDuration=a,this.setHoldBack();break;case"#EXT-X-PART-INF":tM(this.manifest,i),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),this.setHoldBack();break;case"#EXT-X-SERVER-CONTROL":tM(this.manifest,i),this.setHoldBack();break;case"#EXTINF":0===a?this.currentUri.duration=.01:a>0&&(this.currentUri.duration=a);break;case"#EXT-X-PROGRAM-DATE-TIME":var s=new Date(a);this.manifest.dateTimeString||(this.manifest.dateTimeString=a,this.manifest.dateTimeObject=s),this.currentUri.dateTimeString=a,this.currentUri.dateTimeObject=s;break;case"#EXT-X-VERSION":tM(this.manifest,i);break;case"#EXT-X-SESSION-DATA":var n=e_(tB(i[1]));Object.assign(this.manifest.sessionData,n)}},tC.prototype.setHoldBack=function(){var e=this.manifest,t=e.serverControl,i=e.targetDuration,r=e.partTargetDuration;if(t){var a="holdBack",s="partHoldBack",n=i&&3*i,l=r&&2*r;i&&!t.hasOwnProperty(a)&&(t[a]=n),n&&t[a]<n&&(t[a]=n),r&&!t.hasOwnProperty(s)&&(t[s]=3*r),r&&t[s]<l&&(t[s]=l)}};var tM=function(e,t){var i,r=tx(t[0].replace("#EXT-X-",""));tU(t[1])?(i={},i=Object.assign(tN(t[1]),i)):i=tP(t[1]),e[r]=i},tx=function(e){return e.toLowerCase().replace(/-(\w)/g,function(e){return e[1].toUpperCase()})},tP=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},tO=function(e){var t={},i=e.split("=");return i.length>1&&(t[tx(i[0])]=tP(i[1])),t},tN=function(e){for(var t=e.split(","),i={},r=0;t.length>r;r++)i=Object.assign(tO(t[r]),i);return i},tU=function(e){return e.indexOf("=")>-1},tF=function(e,t){return -1===t?[e]:[e.substring(0,t),e.substring(t+1)]},tB=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}}},t$={safeCall:function(e,t,i,r){var a=r;if(e&&"function"==typeof e[t])try{a=e[t].apply(e,i)}catch(e){J.info("safeCall error",e)}return a},safeIncrement:eg,getComputedStyle:function(e,t){var i;return e&&t&&tD.default&&"function"==typeof tD.default.getComputedStyle?(tL&&tL.has(e)&&(i=tL.get(e)),i||(i=tD.default.getComputedStyle(e,null),tL&&tL.set(e,i)),i.getPropertyValue(t)):""},secondsToMs:function(e){return Math.floor(1e3*e)},assign:Object.assign,headersStringToObject:eT,cdnHeadersToRequestId:eA,extractHostnameAndDomain:eu,extractHostname:eh,manifestParser:tC,generateShortID:z,generateUUID:Y,now:j,findMediaElement:X},tH={},tG=function(e){var t=arguments;"string"==typeof e?tG.hasOwnProperty(e)?K.default.setTimeout(function(){t=Array.prototype.splice.call(t,1),tG[e].apply(null,t)},0):J.warn("`"+e+"` is an unknown task"):"function"==typeof e?K.default.setTimeout(function(){e(tG)},0):J.warn("`"+e+"` is invalid.")},tW={loaded:j(),NAME:"mux-embed",VERSION:"5.18.1",API_VERSION:"2.1",PLAYER_TRACKED:!1,monitor:function(e,t){return function(e,t,i){var r=W(X(t),3),a=r[0],s=r[1],n=r[2],l=e.log,o=e.utils.getComputedStyle,d=e.utils.secondsToMs;if(!a)return l.error("No element was found with the `"+s+"` query selector.");if("video"!==n&&"audio"!==n)return l.error("The element of `"+s+"` was not a media element.");a.mux&&(a.mux.destroy(),delete a.mux,l.warn("Already monitoring this video element, replacing existing event listeners")),(i=Object.assign({automaticErrorTracking:!0},i,{getPlayheadTime:function(){return d(a.currentTime)},getStateData:function(){var e,t,i=(null==(e=this.getPlayheadTime)?void 0:e.call(this))||d(a.currentTime),r=this.hlsjs&&this.hlsjs.url,s=this.dashjs&&"function"==typeof this.dashjs.getSource&&this.dashjs.getSource(),n={player_is_paused:a.paused,player_width:parseInt(o(a,"width")),player_height:parseInt(o(a,"height")),player_autoplay_on:a.autoplay,player_preload_on:a.preload,player_language_code:a.lang,player_is_fullscreen:tk(),video_poster_url:a.poster,video_source_url:r||s||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.call(a).droppedVideoFrames};if(a.getStartDate&&i>0){var l=a.getStartDate();if(l&&"function"==typeof l.getTime&&l.getTime()){var h=l.getTime();n.player_program_time=h+i,a.seekable.length>0&&(n.player_live_edge_program_time=h+a.seekable.end(a.seekable.length-1))}}return n}})).data=Object.assign({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:e.VERSION},i.data),a.mux=a.mux||{},a.mux.deleted=!1,a.mux.emit=function(t,i){e.emit(s,t,i)},a.mux.updateData=function(e){a.mux.emit("hb",e)};var h=function(){l.error("The monitor for this video element has already been destroyed.")};
1a.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(s,"destroy")},a.mux.swapElement=function(t){var i=W(X(t),3),r=i[0],s=i[1],n=i[2];return r?"video"!==n&&"audio"!==n?e.log.error("The element of `"+s+"` was not a media element."):void(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,a=r):e.log.error("No element was found with the `"+s+"` query selector.")},a.mux.addHLSJS=function(t){e.addHLSJS(s,t)},a.mux.addDashJS=function(t){e.addDashJS(s,t)},a.mux.removeHLSJS=function(){e.removeHLSJS(s)},a.mux.removeDashJS=function(){e.removeDashJS(s)},a.mux.setEmitTranslator=function(t){e.setEmitTranslator(s,t)},a.mux.setStateDataTranslator=function(t){e.setStateDataTranslator(s,t)},a.mux.setGetPlayheadTime=function(t){t||(t=i.getPlayheadTime),e.setGetPlayheadTime(s,t)},e.init(s,i),e.emit(s,"playerready"),a.paused||(e.emit(s,"play"),a.readyState>2&&e.emit(s,"playing")),a.mux.listeners={},tI.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=tw[a.error.code]||a.error.message}e.emit(s,t,i)},a.addEventListener(t,a.mux.listeners[t],!1))}),a.mux.listeners.enterpictureinpicture=function(){e.emit(s,"playbackmodechange",{player_playback_mode:"pip",player_playback_mode_data:"{}"})},a.mux.listeners.leavepictureinpicture=function(){var t=tk()?"fullscreen":"standard";e.emit(s,"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=tk(),i=document.fullscreenElement;if(t&&(i===a||null!=i&&i.contains(a)))e.emit(s,"playbackmodechange",{player_playback_mode:"fullscreen",player_playback_mode_data:"{}"});else if(!t){var r=document.pictureInPictureElement===a;e.emit(s,"playbackmodechange",{player_playback_mode:r?"pip":"standard",player_playback_mode_data:"{}"})}},document.addEventListener("fullscreenchange",a.mux.fullscreenChangeListener,!1)}(tG,e,t)},destroyMonitor:function(e){var t=W(X(e),1)[0];t&&t.mux&&"function"==typeof t.mux.destroy?t.mux.destroy():J.error("A video element monitor for `"+e+"` has not been initialized via `mux.monitor`.")},addHLSJS:function(e,t){var i=Q(e);tH[i]?tH[i].addHLSJS(t):J.error("A monitor for `"+i+"` has not been initialized.")},addDashJS:function(e,t){var i=Q(e);tH[i]?tH[i].addDashJS(t):J.error("A monitor for `"+i+"` has not been initialized.")},removeHLSJS:function(e){var t=Q(e);tH[t]?tH[t].removeHLSJS():J.error("A monitor for `"+t+"` has not been initialized.")},removeDashJS:function(e){var t=Q(e);tH[t]?tH[t].removeDashJS():J.error("A monitor for `"+t+"` has not been initialized.")},init:function(e,t){et()&&t&&t.respectDoNotTrack&&J.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var i=Q(e);tH[i]=new t_(tG,i,t)},emit:function(e,t,i){var r=Q(e);tH[r]?(tH[r].emit(t,i),"destroy"===t&&delete tH[r]):J.error("A monitor for `"+r+"` has not been initialized.")},updateData:function(e,t){var i=Q(e);tH[i]?tH[i].emit("hb",t):J.error("A monitor for `"+i+"` has not been initialized.")},setEmitTranslator:function(e,t){var i=Q(e);tH[i]?tH[i].emitTranslator=t:J.error("A monitor for `"+i+"` has not been initialized.")},setStateDataTranslator:function(e,t){var i=Q(e);tH[i]?tH[i].stateDataTranslator=t:J.error("A monitor for `"+i+"` has not been initialized.")},setGetPlayheadTime:function(e,t){var i=Q(e);tH[i]?tH[i].getPlayheadTime=t:J.error("A monitor for `"+i+"` has not been initialized.")},checkDoNotTrack:et,log:J,utils:t$,events:{PLAYER_READY:"playerready",VIEW_INIT:"viewinit",VIDEO_CHANGE:"videochange",PLAY:"play",PAUSE:"pause",PLAYING:"playing",TIME_UPDATE:"timeupdate",SEEKING:"seeking",SEEKED:"seeked",REBUFFER_START:"rebufferstart",REBUFFER_END:"rebufferend",ERROR:"error",ENDED:"ended",RENDITION_CHANGE:"renditionchange",ORIENTATION_CHANGE:"orientationchange",PLAYBACK_MODE_CHANGE:"playbackmodechange",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"},WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign(tG,tW),void 0!==K.default&&"function"==typeof K.default.addEventListener&&K.default.addEventListener("pagehide",function(e){e.persisted||(tG.WINDOW_UNLOADING=!0)},!1);let tK=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},tV=Number.isSafeInteger||function(e){return"number"==typeof e&&Math.abs(e)<=tq},tq=Number.MAX_SAFE_INTEGER||0x1fffffffffffff,tj=((hY={}
1).NETWORK_ERROR="networkError",hY.MEDIA_ERROR="mediaError",hY.KEY_SYSTEM_ERROR="keySystemError",hY.MUX_ERROR="muxError",hY.OTHER_ERROR="otherError",hY),tY=((hz={}).KEY_SYSTEM_NO_KEYS="keySystemNoKeys",hz.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",hz.KEY_SYSTEM_NO_SESSION="keySystemNoSession",hz.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",hz.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",hz.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",hz.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",hz.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",hz.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",hz.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",hz.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR="keySystemDestroyMediaKeysError",hz.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR="keySystemDestroyCloseSessionError",hz.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR="keySystemDestroyRemoveSessionError",hz.MANIFEST_LOAD_ERROR="manifestLoadError",hz.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",hz.MANIFEST_PARSING_ERROR="manifestParsingError",hz.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",hz.LEVEL_EMPTY_ERROR="levelEmptyError",hz.PLAYLIST_UNCHANGED_ERROR="playlistUnchangedError",hz.LEVEL_LOAD_ERROR="levelLoadError",hz.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",hz.LEVEL_PARSING_ERROR="levelParsingError",hz.LEVEL_SWITCH_ERROR="levelSwitchError",hz.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",hz.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",hz.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",hz.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",hz.FRAG_LOAD_ERROR="fragLoadError",hz.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",hz.FRAG_DECRYPT_ERROR="fragDecryptError",hz.FRAG_PARSING_ERROR="fragParsingError",hz.FRAG_GAP="fragGap",hz.REMUX_ALLOC_ERROR="remuxAllocError",hz.KEY_LOAD_ERROR="keyLoadError",hz.KEY_LOAD_TIMEOUT="keyLoadTimeOut",hz.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",hz.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",hz.BUFFER_APPEND_ERROR="bufferAppendError",hz.BUFFER_APPENDING_ERROR="bufferAppendingError",hz.BUFFER_APPEND_NO_PROGRESS="bufferAppendNoProgress",hz.BUFFER_STALLED_ERROR="bufferStalledError",hz.BUFFER_FULL_ERROR="bufferFullError",hz.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",hz.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",hz.ASSET_LIST_LOAD_ERROR="assetListLoadError",hz.ASSET_LIST_LOAD_TIMEOUT="assetListLoadTimeout",hz.ASSET_LIST_PARSING_ERROR="assetListParsingError",hz.INTERSTITIAL_ASSET_ITEM_ERROR="interstitialAssetItemError",hz.INTERNAL_EXCEPTION="internalException",hz.INTERNAL_ABORTED="aborted",hz.ATTACH_MEDIA_ERROR="attachMediaError",hz.MEDIA_SOURCE_REQUIRES_RESET="mediaSourceRequiresReset",hz.UNKNOWN="unknown",hz),tz=((hQ={}).MEDIA_ATTACHING="hlsMediaAttaching",hQ.MEDIA_ATTACHED="hlsMediaAttached",hQ.MEDIA_DETACHING="hlsMediaDetaching",hQ.MEDIA_DETACHED="hlsMediaDetached",hQ.MEDIA_ENDED="hlsMediaEnded",hQ.STALL_RESOLVED="hlsStallResolved",hQ.BUFFER_RESET="hlsBufferReset",hQ.BUFFER_CODECS="hlsBufferCodecs",hQ.BUFFER_CREATED="hlsBufferCreated",hQ.BUFFER_APPENDING="hlsBufferAppending",hQ.BUFFER_APPENDED="hlsBufferAppended",hQ.BUFFER_EOS="hlsBufferEos",hQ.BUFFERED_TO_END="hlsBufferedToEnd",hQ.BUFFER_FLUSHING="hlsBufferFlushing",hQ.BUFFER_FLUSHED="hlsBufferFlushed",hQ.MANIFEST_LOADING="hlsManifestLoading",hQ.MANIFEST_LOADED="hlsManifestLoaded",hQ.MANIFEST_PARSED="hlsManifestParsed",hQ.LEVEL_SWITCHING="hlsLevelSwitching",hQ.LEVEL_SWITCHED="hlsLevelSwitched",hQ.LEVEL_LOADING="hlsLevelLoading",hQ.LEVEL_LOADED="hlsLevelLoaded",hQ.LEVEL_UPDATED="hlsLevelUpdated",hQ.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",hQ.LEVELS_UPDATED="hlsLevelsUpdated",hQ.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",hQ.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",hQ.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",hQ.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",hQ.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",hQ.AUDIO_TRACK_UPDATED="hlsAudioTrackUpdated",hQ.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUp
1dated",hQ.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",hQ.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",hQ.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",hQ.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",hQ.SUBTITLE_TRACK_UPDATED="hlsSubtitleTrackUpdated",hQ.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",hQ.CUES_PARSED="hlsCuesParsed",hQ.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",hQ.INIT_PTS_FOUND="hlsInitPtsFound",hQ.FRAG_LOADING="hlsFragLoading",hQ.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",hQ.FRAG_LOADED="hlsFragLoaded",hQ.FRAG_DECRYPTED="hlsFragDecrypted",hQ.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",hQ.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",hQ.FRAG_PARSING_METADATA="hlsFragParsingMetadata",hQ.FRAG_PARSED="hlsFragParsed",hQ.FRAG_BUFFERED="hlsFragBuffered",hQ.FRAG_CHANGED="hlsFragChanged",hQ.FPS_DROP="hlsFpsDrop",hQ.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",hQ.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",hQ.ERROR="hlsError",hQ.DESTROYING="hlsDestroying",hQ.KEY_LOADING="hlsKeyLoading",hQ.KEY_LOADED="hlsKeyLoaded",hQ.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",hQ.BACK_BUFFER_REACHED="hlsBackBufferReached",hQ.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",hQ.ASSET_LIST_LOADING="hlsAssetListLoading",hQ.ASSET_LIST_LOADED="hlsAssetListLoaded",hQ.INTERSTITIALS_UPDATED="hlsInterstitialsUpdated",hQ.INTERSTITIALS_BUFFERED_TO_BOUNDARY="hlsInterstitialsBufferedToBoundary",hQ.INTERSTITIAL_ASSET_PLAYER_CREATED="hlsInterstitialAssetPlayerCreated",hQ.INTERSTITIAL_STARTED="hlsInterstitialStarted",hQ.INTERSTITIAL_ASSET_STARTED="hlsInterstitialAssetStarted",hQ.INTERSTITIAL_ASSET_ENDED="hlsInterstitialAssetEnded",hQ.INTERSTITIAL_ASSET_ERROR="hlsInterstitialAssetError",hQ.INTERSTITIAL_ENDED="hlsInterstitialEnded",hQ.INTERSTITIALS_PRIMARY_RESUMED="hlsInterstitialsPrimaryResumed",hQ.PLAYOUT_LIMIT_REACHED="hlsPlayoutLimitReached",hQ.EVENT_CUE_ENTER="hlsEventCueEnter",hQ);var tQ={exports:{}},tX=h3?tQ.exports:(h3=1,hW=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,hK=/^(?=([^\/?#]*))\1([^]*)$/,hV=/(?:\/|^)\.(?=\/)/g,hq=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,tQ.exports=hj={buildAbsoluteURL:function(e,t,i){if(i=i||{},e=e.trim(),!(t=t.trim())){if(!i.alwaysNormalize)return e;var r=hj.parseURL(e);if(!r)throw Error("Error trying to parse base URL.");return r.path=hj.normalizePath(r.path),hj.buildURLFromParts(r)}var a=hj.parseURL(t);if(!a)throw Error("Error trying to parse relative URL.");if(a.scheme)return i.alwaysNormalize?(a.path=hj.normalizePath(a.path),hj.buildURLFromParts(a)):t;var s=hj.parseURL(e);if(!s)throw Error("Error trying to parse base URL.");if(!s.netLoc&&s.path&&"/"!==s.path[0]){var n=hK.exec(s.path);s.netLoc=n[1],s.path=n[2]}s.netLoc&&!s.path&&(s.path="/");var l={scheme:s.scheme,netLoc:a.netLoc,path:null,params:a.params,query:a.query,fragment:a.fragment};if(!a.netLoc&&(l.netLoc=s.netLoc,"/"!==a.path[0]))if(a.path){var o=s.path,d=o.substring(0,o.lastIndexOf("/")+1)+a.path;l.path=hj.normalizePath(d)}else l.path=s.path,!a.params&&(l.params=s.params,a.query||(l.query=s.query));return null===l.path&&(l.path=i.alwaysNormalize?hj.normalizePath(a.path):a.path),hj.buildURLFromParts(l)},parseURL:function(e){var t=hW.exec(e);return t?{scheme:t[1]||"",netLoc:t[2]||"",path:t[3]||"",params:t[4]||"",query:t[5]||"",fragment:t[6]||""}:null},normalizePath:function(e){for(e=e.split("").reverse().join("").replace(hV,"");e.length!==(e=e.replace(hq,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}},tQ.exports);class tZ{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}}}let tJ=((hX={}).MANIFEST="manifest",hX.LEVEL="level",hX.AUDIO_TRACK="audioTrack",hX.SUBTITLE_TRACK="subtitleTrack",hX.MEDIA_FRAGMENT="media-fragment",hX.KEY="key",hX.STEERING_MANIFEST="steering-manifest",hX.SERVER_CERTIFICATE="server-certificate",hX.INTERSTITIAL_ASSET_LIST="interstitial-asset-list",hX),t0=((hZ={}).MAIN="main",hZ.AUDIO="audio",hZ.SUBTITLE="subtitle",hZ);var t1="audio",t2="video",t3="audiovideo";class t4{constructor(e){this._byteRange=null,this._url=null,this._stats=null,this._streams=null,this.base=void 0,this.relurl=void 0,"string"==typeof e&&(e={url:e}),this.base=e,function(e,t){let i=function e(t,i){let r=Object.getPrototypeOf(t);if(r){let t=Object.getOwnPropertyDescriptor(r,i);return t||e(r,i)}}(e,t);i&&(i.enumerable=!0,Object.defineProperty(e,t,i))}(this,"stats")}
1setByteRange(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={[t1]:null,[t2]:null,[t3]: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 tZ),this._stats}set stats(e){this._stats=e}get url(){return!this._url&&this.relurl&&(this._url=tX.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}clearElementaryStreamInfo(){let{elementaryStreams:e}=this;e[t1]=null,e[t2]=null,e[t3]=null,this.url=null}}function t5(e){return"initSegment"!==e.sn}function t8(e,t){return e.sn===(null==t?void 0:t.sn)&&e.level===t.level}function t6(e,t){return e.sn===(null==t?void 0:t.sn)&&e.level===t.level&&e.cc===t.cc}class t9 extends t4{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(tK(e)&&tK(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=tK(this.duration)?this.duration:0;return this.programDateTime+1e3*e}get encrypted(){var e,t;if(null!=(e=this._decryptdata)&&e.encrypted)return!0;if(this.levelkeys){let e=Object.keys(this.levelkeys),i=e.length;if(i>1||1===i&&null!=(t=this.levelkeys[e[0]])&&t.encrypted)return!0}return!1}get programDateTime(){return null===this._programDateTime&&this.rawProgramDateTime&&(this.programDateTime=Date.parse(this.rawProgramDateTime)),this._programDateTime}set programDateTime(e){if(!tK(e)){this._programDateTime=this.rawProgramDateTime=null;return}this._programDateTime=e}get ref(){return t5(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,s=!1){let{elementaryStreams:n}=this,l=n[e];if(!l){n[e]={startPTS:t,endPTS:i,startDTS:r,endDTS:a,partial:s};return}l.startPTS=Math.min(l.startPTS,t),l.endPTS=Math.max(l.endPTS,i),l.startDTS=Math.min(l.startDTS,r),l.endDTS=Math.max(l.endDTS,a)}}class t7 extends t4{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;const s=e.enumeratedString("BYTERANGE");s&&this.setByteRange(s,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===t0.SUBTITLE&&this.stats.loading.end>0)}}function ie(){return(ie=Object.assign.bind()).apply(null,arguments)}function it(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 ii(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};
1t%2?it(Object(i),!0).forEach(function(t){var r,a;r=t,a=i[t],(r=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var r=i.call(e,t);if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(r))in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):it(Object(i)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})}return e}function ir(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 s=Object.getOwnPropertySymbols(e);for(r=0;r<s.length;r++)i=s[r],-1===t.indexOf(i)&&({}).propertyIsEnumerable.call(e,i)&&(a[i]=e[i])}return a}function ia(e){switch(e.details){case tY.FRAG_LOAD_TIMEOUT:case tY.KEY_LOAD_TIMEOUT:case tY.LEVEL_LOAD_TIMEOUT:case tY.MANIFEST_LOAD_TIMEOUT:case tY.AUDIO_TRACK_LOAD_TIMEOUT:case tY.SUBTITLE_TRACK_LOAD_TIMEOUT:case tY.ASSET_LIST_LOAD_TIMEOUT:return!0}return!1}function is(e){return e.details.startsWith("key")}function il(e){return is(e)&&!!e.frag&&!e.frag.decryptdata}function io(e,t){let i=ia(t);return e.default[`${i?"timeout":"error"}Retry`]}function id(e,t){return Math.min(("linear"===e.backoff?1:Math.pow(2,t))*e.retryDelayMs,e.maxRetryDelayMs)}function ih(e){return ii(ii({},e),{errorRetry:null,timeoutRetry:null})}function iu(e,t,i,r){var a;if(!e)return!1;let s=null==r?void 0:r.code,n=t<e.maxNumRetry&&(ic(a=s)||!!a&&(a<400||a>499)||!!i);return e.shouldRetry?e.shouldRetry(e,t,i,r,n):n}function ic(e){return 0===e&&!1===navigator.onLine}function im(e,t){return t>0&&e.loadError>0&&0!==e.loadErrorTime&&self.performance.now()-e.loadErrorTime>t}class ip{constructor(e,t=0,i=0){this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=i}sample(e,t){let i=Math.pow(this.alpha_,e);this.estimate_=t*(1-i)+i*this.estimate_,this.totalWeight_+=e}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){let e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}}class ig{constructor(e,t,i,r=100){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=i,this.minWeight_=.001,this.minDelayMs_=50,this.slow_
1=new ip(e),this.fast_=new ip(t),this.defaultTTFB_=r,this.ttfb_=new ip(e)}update(e,t){let{slow_:i,fast_:r,ttfb_:a}=this;i.halfLife!==e&&(this.slow_=new ip(e,i.getEstimate(),i.getTotalWeight())),r.halfLife!==t&&(this.fast_=new ip(t,r.getEstimate(),r.getTotalWeight())),a.halfLife!==e&&(this.ttfb_=new ip(e,a.getEstimate(),a.getTotalWeight()))}sample(e,t){if(t<=0)return;let i=Math.max(e,Math.min(this.minDelayMs_,t/1e5))/1e3,r=8*t/i;this.fast_.sample(i,r),this.slow_.sample(i,r)}sampleTTFB(e){let t=Math.sqrt(2)*Math.exp(-Math.pow(e/1e3,2)/2);this.ttfb_.sample(t,Math.max(e,5))}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}get defaultEstimate(){return this.defaultEstimate_}destroy(){}}class iv{constructor(e,t){this.trace=void 0,this.debug=void 0,this.log=void 0,this.warn=void 0,this.info=void 0,this.error=void 0;const i=`[${e}]:`;this.trace=iE,this.debug=t.debug.bind(null,i),this.log=t.log.bind(null,i),this.warn=t.warn.bind(null,i),this.info=t.info.bind(null,i),this.error=t.error.bind(null,i)}}let iE=function(){},iy={trace:iE,debug:iE,log:iE,warn:iE,info:iE,error:iE};function ib(){return ie({},iy)}function iT(e,t,i){let r;return t[e]?t[e].bind(t):(r=self.console[e])?r.bind(self.console,`${i?"["+i+"] ":""}[${e}] >`):iE}let iA=ib();function i_(e=!0){if(!("u"<typeof self))return(e||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function iS(e,t){let i=Object.keys(e),r=Object.keys(t),a=i.length,s=r.length;return!a||!s||a===s&&!i.some(e=>-1===r.indexOf(e))}function ik(e){return e instanceof ArrayBuffer||"u">typeof SharedArrayBuffer&&e instanceof SharedArrayBuffer}let iR="utf-16be",iL="utf-16le",iI="utf-8";function iw(){try{return crypto.randomUUID()}catch(e){try{let e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}catch(t){let e=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{let i=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"==t?i:3&i|8).toString(16)})}}}function iD(e,t){return t+10<=e.length&&73===e[t]&&68===e[t+1]&&51===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128||!1}function iC(e,t){return(127&e[t])<<21|(127&e[t+1])<<14|(127&e[t+2])<<7|127&e[t+3]}function iM(e,t){return t+10<=e.length&&51===e[t]&&68===e[t+1]&&73===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128||!1}function ix(e,t){let i=t,r=0;for(;iD(e,t);)r+=10,r+=iC(e,t+6),iM(e,t+10)&&(r+=10),t+=r;if(r>0)return e.subarray(i,i+r)}function iP(e,t=0,i=1/0){var r,a,s,n,l,o;let d,h,u,c,m;return r=e,a=t,s=i,n=Uint8Array,d=ik(l=r)?l:l.buffer,h=1,"BYTES_PER_ELEMENT"in n&&(h=n.BYTES_PER_ELEMENT),c=((u=(o=r)&&ik(o.buffer)&&void 0!==o.byteLength&&void 0!==o.byteOffset?r.byteOffset:0)+r.byteLength)/h,new n(d,m=Math.floor(Math.max(0,Math.min((u+a)/h,c))),Math.floor(Math.min(m+Math.max(s,0),c))-m)}function iO(e,t=!1){let i=t?e.indexOf(0):e.length,r=function(e,t={}){let i,r;i=ik(e)?new DataView(e):new DataView(e.buffer,e.byteOffset,e.byteLength);let a=0,{encoding:s}=t;if(!s){let e=i.getUint8(0),t=i.getUint8(1);239==e&&187==t&&191==i.getUint8(2)?(s=iI,a=3):254==e&&255==t?(s=iR,a=2):255==e&&254==t?(s=iL,a=2):s=iI}if("u">typeof TextDecoder)return new TextDecoder(s).decode(i);let{byteLength:n}=i,l=s!==iR,o="";for(;a<n;){switch(s){case iI:if((r=i.getUint8(a))<128)a++;else if(r>=194&&r<=223)if(a+1<n){let e=i.getUint8(a+1);e>=128&&e<=191?(r=(31&r)<<6|63&e,a+=2):a++}else a++;else if(r>=224&&r<=239)if(a+2<=n-1){let e=i.getUint8(a+1),t=i.getUint8(a+2);e>=128&&e<=191&&t>=128&&t<=191?(r=(15&r)<<12|(63&e)<<6|63&t,a+=3):a++}else a++;else if(r>=240&&r<=244)if(a+3<=n-1){let e=i.getUint8(a+1),t=i.getUint8(a+2),s=i.getUint8(a+3);e>=128&&e<=191&&t>=128&&t<=191&&s>=128&&s<=191?(r=(7&r)<<18|(63&e)<<12|(63&t)<<6|63&s,a+=4):a++}else a++;else a++;break;case iR:case"utf-16":case iL:r=i.getUint16(a,l),a+=2}o+=String.fromCodePoint(r)}return o}(new DataView(e.buffer,e.byteOffset,i),{encoding:iI});return t?r:r.replace(/\0/g,"")}function iN(e){let t=0,i=[];for(;iD(e,t);){let r=iC(e,t+6);e[t+5]>>6&1&&(t+=10);let a=(t+=10)+r;for(;t+10<a;){let r=function(e){let t=String.fromCharCode(e[0],e[1],e[2],e[3]),i=iC(e,4);return{type:t,size:i,data:e.subarray(10,10+i)}}(e.subarray(t)),a=function(e){if("PRIV"===e.type){if(e.size<2)return;let t=iO(e.data,!0),i=new Uint8Array(e.data.subarray(t.length+1));return{key:e.type,info:t,data:i.buffer}}if("W"===e.type[0]){if("WXXX"===e.type){if(e.size<2)return;let t=1,i=iO(e.data.subarray(t),!0);t+=i.length+1;let r=iO(e.data.subarray(t));return{key:e.type,info:i,data:r}}let t=iO(e.data);return{key:e.type,info:"",data:t}}return"APIC"===e.type?function(e){let t,i={key:e.type,description:"",data:"",mimeType:null,pictureType:null};if(e.size<2)return;if(3!==e.data[0])return void console.log("Ignore frame with unrecognized character encoding");let r=e.data.subarray(1).indexOf(0);if(-1===r)return;let a=iO(iP(e.data,1,r)),s=e.data[2+r],n=e.data.subarray(3+r).indexOf(0);if(-1===n)return;let l=iO(iP(e.data,3+r,n));if("-->"===a)t=iO(iP(e.data,4+r+n));else{var o;t=ik(o=e.data.subarray(4+r+n))?o:0==o.byteOffset&&o.byteLength==o.buffer.byteLength?o.buffer:new Uint8Array(o).buffer}return i.mimeType=a,i.pictureType=s,i.description=l,i.data=t,i}(e):function(e){if(e.size<2)return;if("TXXX"===e.type){let t=1,{data:i}=e,r=iO(i.subarray(t),!0);t+=r.length+1;let a=iO(i.subarray(t));return{key:e.type,info:r,data:a}}let t=iO(e.data.subarray(1));return{key:e.type,info:"",data:t}}(e)}(r);a&&i.push(a),t+=r.size+10}iM(e,t)&&(t+=10)}return i}function iU(e){return e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info}function iF(e){for(let t of iN(e))if(iU(t))return function(e){if(8===e.data.byteLength){let t=new Uint8Array(e.data),i=1&t[3],r=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return r/=45,i&&(r+=47721858.84),Math.round(r)}}(t)}function iB(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 i$(e){return Uint8Array.from(e.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}function iH(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0))}function iG(e){return String.fromCharCode.apply(null,e)}let iW=0x61766331,iK=0x61766343,iV=0x68766331,iq=0x68766343,ij=0x62747274,iY=0x64696e66,iz=0x64726566,iQ=0x65736473,iX=0x66726565,iZ=0x66747970,iJ=0x68646c72,i0=0x6d646174,i1=0x6d646864,i2=0x6d646961,i3=0x6d666864,i4=0x6d696e66,i5=0x6d6f6f66,i8=0x6d6f6f76,i6=0x6d703461,i9=0x2e6d7033,i7=0x64616333,re=0x61632d33,rt=0x6d766578,ri=0x6d766864,rr=0x70617370,ra=0x73647470,rs=0x7374626c,rn=0x7374636f,rl=0x73747363,ro=0x73747364,rd=0x7374737a,rh=0x73747473,ru=0x74666474,rc=0x74666864,rm=0x74726166,rf=0x7472616b,rp=0x7472756e,rg=0x74726578,rv=0x746b6864,rE=0x766d6864,ry=0x736d6864,rb={video:1,audio:2,id3:3,text:4};function rT(e,t){let i=e[t]<<8|e[t+1];return i<0?65536+i:i}function rA(e,t){let i=e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3];return i<0?0x100000000+i:i}function r_(e,t){let i=rA(e,t);return i*=0x100000000,i+=rA(e,t+4)}function rS(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 rk(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function rR(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 rL(e,t,i){let r=t.byteOffset-e.byteOffset-8,a=8+i,s=t.byteLength+8-a;s<8||(rR(e,r,a),rR(e,r+a,s),rR(e,r+a+4,iX))}function rI(e,t){return[e.byteOffset-t-8,e.byteOffset-t+e.byteLength]}
1function rw(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,s=0;for(let i=0;i<t.length;i++){let[n,l]=t[i];r.set(e.subarray(a,n),s),s+=n-a,a=l}return r.set(e.subarray(a),s),{result:r,dropped:i,droppedBefore:e=>t.reduce((t,[i,r])=>r<=e?t+r-i:t,0)}}function rD(e,t){let i=[];return t.length&&function e(t,i,r,a,s,n){let l=i[r];if((null==l?void 0:l.length)!==4)return;let o=l.charCodeAt(0),d=l.charCodeAt(1),h=l.charCodeAt(2),u=l.charCodeAt(3),c=i.length-1;for(let l=a;l<s;){let a=l+8<=s,m=l+4<=s?0x1000000*t[l]+(t[l+1]<<16|t[l+2]<<8|t[l+3]):rA(t,l),f=m>1?l+m:s;if(a&&t[l+4]===o&&t[l+5]===d&&t[l+6]===h&&t[l+7]===u){let a=Math.min(f,s);r===c?n.push(t.subarray(l+8,a)):e(t,i,r+1,l+8,a,n)}l=f}}(e,t,0,0,e.byteLength,i),i}function rC(e){let t=[],i=rD(e,["moov","trak"]);for(let e=0;e<i.length;e++){let r=i[e],a=rD(r,["tkhd"])[0];if(a){let e=a[0],i=rA(a,0===e?12:20),s=rD(r,["mdia","mdhd"])[0];if(s){e=s[0];let a=rA(s,0===e?12:20),n=rD(r,["mdia","hdlr"])[0];if(n){let e=iG(n.subarray(8,12)),s={soun:t1,vide:t2}[e],l=function(e){let t,i=e.subarray(8),r=i.subarray(86),a=iG(i.subarray(4,8)),s=a,n="enca"===a||"encv"===a;if(n){let e=rD(i,[a])[0].subarray("enca"===a?28:78);rD(e,["sinf"]).forEach(e=>{let t=rD(e,["schm"])[0];if(t){let i=iG(t.subarray(4,8));if("cbcs"===i||"cenc"===i){let t=rD(e,["frma"])[0];t&&(s=iG(t))}}})}let l=s;switch(s){case"avc1":case"avc2":case"avc3":case"avc4":{let e=rD(r,["avcC"])[0];e&&e.length>3&&(s+="."+rP(e[1])+rP(e[2])+rP(e[3]),t=rM("avc1"===l?"dva1":"dvav",r));break}case"mp4a":{let e=rD(i,[a])[0],t=rD(e.subarray(28),["esds"])[0];if(t&&t.length>7){let e=4;if(3!==t[e++])break;e=rx(t,e)+2;let i=t[e++];if(128&i&&(e+=2),64&i&&(e+=t[e++]),4!==t[e++])break;e=rx(t,e);let r=t[e++];if(64===r)s+="."+rP(r);else break;if(e+=12,5!==t[e++])break;e=rx(t,e);let a=t[e++],n=(248&a)>>3;31===n&&(n+=1+((7&a)<<3)+((224&t[e])>>5)),s+="."+n}break}case"hvc1":case"hev1":{let e=rD(r,["hvcC"])[0];if(e&&e.length>12){let t=e[1],i=["","A","B","C"][t>>6],r=rA(e,2),a=e[12],n=e.subarray(6,12);s+="."+i+(31&t),s+="."+(function(e){let t=0;for(let i=0;i<32;i++)t|=(e>>i&1)<<31-i;return t>>>0})(r).toString(16).toUpperCase(),s+="."+((32&t)>>5?"H":"L")+a;let l="";for(let e=n.length;e--;){let t=n[e];(t||l)&&(l="."+t.toString(16).toUpperCase()+l)}s+=l}t=rM("hev1"==l?"dvhe":"dvh1",r);break}case"dvh1":case"dvhe":case"dvav":case"dva1":case"dav1":s=rM(s,r)||s;break;case"vp09":{let e=rD(r,["vpcC"])[0];if(e&&e.length>6){let t=e[4],i=e[5],r=e[6]>>4&15;s+="."+rO(t)+"."+rO(i)+"."+rO(r)}break}case"av01":{let e=rD(r,["av1C"])[0];if(e&&e.length>2){let i=e[1]>>>5,a=31&e[1],n=e[2]>>>7?"H":"M",l=(64&e[2])>>6,o=(32&e[2])>>5,d=(16&e[2])>>4,h=(8&e[2])>>3,u=(4&e[2])>>2,c=3&e[2];s+="."+i+"."+rO(a)+n+"."+rO(2===i&&l?o?12:10:l?10:8)+"."+d+"."+h+u+c+"."+rO(1)+"."+rO(1)+"."+rO(1)+".0",t=rM("dav1",r)}}}return{codec:s,encrypted:n,supplemental:t}}(rD(r,["mdia","minf","stbl","stsd"])[0]);s?(t[i]={timescale:a,type:s,stsd:l},t[s]=ii({timescale:a,id:i},l)):t[i]={timescale:a,type:e,stsd:l}}}}}return rD(e,["moov","mvex","trex"]).forEach(e=>{let i=t[rA(e,4)];i&&(i.default={duration:rA(e,12),sampleSize:rA(e,16),flags:rA(e,20)})}),t}function rM(e,t){let i=rD(t,["dvvC"]),r=i.length?i[0]:rD(t,["dvcC"])[0];if(r){let t=r[2]>>1&127,i=r[2]<<5&32|r[3]>>3&31;return e+"."+rO(t)+"."+rO(i)}}function rx(e,t){let i=t+5;for(;128&e[t++]&&t<i;);return t}function rP(e){return("0"+e.toString(16).toUpperCase()).slice(-2)}function rO(e){return(e<10?"0":"")+e}function rN(e,t){rD(e,["moov","trak"]).forEach(e=>{let i=rD(e,["mdia","minf","stbl","stsd"])[0];if(!i)return;let r=i.subarray(8),a=rD(r,["enca"]),s=a.length>0;s||(a=rD(r,["encv"])),a.forEach(e=>{rD(s?e.subarray(28):e.subarray(78),["sinf"]).forEach(e=>{let i=rU(e);i&&t(i,s)})})})}function rU(e){let t=rD(e,["schm"])[0];if(t){let i=iG(t.subarray(4,8));if("cbcs"===i||"cenc"===i){let t=rD(e,["schi","tenc"])[0];if(t)return t}}}function rF(e,t,i,r,a){let s={},n=!1,l=function(e){let t=e.byteLength,i=[];for(let r=0;r<t;){let a=r+8<=t,s=r+4<=t?0x1000000*e[r]+(e[r+1]<<16|e[r+2]<<8|e[r+3]):rA(e,r),n=s>1?r+s:t;if(a&&109===e[r+4]&&111===e[r+5]&&111===e[r+6]&&102===e[r+7]){let a=Math.min(n,t);for(let t=r+8;t<a;){let s=t+8<=a,n=t+4<=a?0x1000000*e[t]+(e[t+1]<<16|e[t+2]<<8|e[t+3]):rA(e,t),l=n>1?t+n:a;
1if(s&&116===e[t+4]&&114===e[t+5]&&97===e[t+6]&&102===e[t+7]){let s,n,o=Math.min(l,a),d=[];for(let i=t+8;i<o;){let t=i+8<=o,r=i+4<=o?0x1000000*e[i]+(e[i+1]<<16|e[i+2]<<8|e[i+3]):rA(e,i),a=r>1?i+r:o;if(t&&116===e[i+4]){let t=Math.min(a,o);102===e[i+5]&&104===e[i+6]&&100===e[i+7]?n||(n=e.subarray(i+8,t)):102===e[i+5]&&100===e[i+6]&&116===e[i+7]?s||(s=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:s,tfhd:n,truns:d})}t=l}}r=n}return i}(e),o=e.byteLength;for(let u=0;u<l.length;u++){let c,m,{moofOffset:f,tfdt:p,tfhd:g,truns:v}=l[u],E=rA(g,4),y=t[E];if(!y)continue;let b=s[E]||(s[E]={start:NaN,duration:0,sampleCount:0,trun:[],timescale:y.timescale,type:y.type});if(p){let e=p[0];c=rA(p,4),1===e&&(0xffffffff===c?i.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"):(c*=0x100000000,c+=rA(p,8))),tK(c)&&(!tK(b.start)||c<b.start)&&(b.start=c),a&&tK(c)&&(a.timeOffset=c/a.timescale)}let T=(null==a?void 0:a.trackId)===E&&y.type===t2,A=y.default,S=0xffffff&rA(g,0),k=(null==A?void 0:A.duration)||0,R=(null==A?void 0:A.sampleSize)||0,L=8;1&S&&(L+=8),2&S&&(L+=4),8&S&&(k=rA(g,L),m=g.byteOffset-e.byteOffset+L,L+=4),16&S&&(R=rA(g,L));let I=0,w=(1&S)!=0,D=!w&&(131072&S)!=0;w?I=0x100000000*rA(g,8)+rA(g,12):D&&(I=f);let C=c||0,M=0,x=k;for(let t=0;t<v.length;t++){let i,s,n,l=v[t],u=rA(l,4),c=b.sampleCount;b.sampleCount+=u;let f=1&l[3],p=0,g=4&l[3],E=1&l[2],y=2&l[2],A=4&l[2],S=8&l[2],L=8;f&&(p=rk(l,L),L+=4),g&&(1&l[L+1]||void 0!==b.keyFrameIndex||(b.keyFrameIndex=c),L+=4);let w=I+p;if(!r&&0===l[1]&&6===l[2]&&1===l[3]){var d,h;let t=C,i=w,r=L,s=-1,n=0,c=0,m=null!=(d=null==a?void 0:a.timeOffset)?d:0,f=k/(null!=(h=null==a?void 0:a.timescale)?h:1),p=(null==a?void 0:a.isHEVCFlavor)===!0,g=p?2:1;for(let t=0;t<u;t++){let i=0===l[L]?l[L+1]<<16|l[L+2]<<8|l[L+3]:rA(l,L),r=-1===s&&void 0===b.keyFrameIndex&&(1&l[L+5])==0;L+=8;let o=w+i;if(T){if(i>0){let t=w;do{let i=0===e[t]?e[t+1]<<16|e[t+2]<<8|e[t+3]:rA(e,t),r=e[t+=4],s=p?r>>1&63:31&r;(p?39===s||40===s:6===s)&&rG(e.subarray(t,t+i),g,m,a.samples),t+=i}while(t<o)}m+=f}w=o,r&&(s=t,n=w)}if(w<=o)c=u;else{let e=i,t=r;for(let i=0;i<u&&!((e+=0===l[t]?l[t+1]<<16|l[t+2]<<8|l[t+3]:rA(l,t))>o);i++)c=i+1,t+=8}if(T&&(a.timeOffset=m),-1!==s&&n<=o&&void 0===b.keyFrameIndex&&(b.keyFrameIndex=s,b.keyFrameStart=t+s*k),c){(!tK(b.ptsMin)||t<b.ptsMin)&&(b.ptsMin=t);let e=t+c*k;(!tK(b.ptsMax)||e>b.ptsMax)&&(b.ptsMax=e)}let v=k*u;C=t+v,M+=v;continue}r&&(s={sampleOffset:w,samples:i=[],defaultSampleDurationOffset:m},w<=o&&b.trun.push(s));for(let t=0;t<u;t++){let d,h,u;E?(r&&(d=l.byteOffset-e.byteOffset+L),x=rA(l,L),L+=4):x=k,y?(n=rA(l,L),L+=4):n=R,A&&(u=1&l[L+1]?1:0,r&&(h={isNonSync:u,dependsOn:(3&l[L])==1?1:2}),L+=4);let c=0;if(S&&(c=0===l[0]?rA(l,L):rk(l,L),L+=4),T){let t=w,i=0;for(;i<n;){let r=rA(e,t);t+=4,rH(a.isHEVCFlavor,e[t])&&rG(e.subarray(t,t+r),a.isHEVCFlavor?2:1,a.timeOffset+c/a.timescale,a.samples),t+=r,i+=r+4}a.timeOffset+=x/a.timescale}if((w+=n)<=o){s&&void 0!==d&&(s.lastSampleDurationOffset=d),0===u&&void 0===b.keyFrameIndex&&(b.keyFrameIndex=t,b.keyFrameStart=C);let e=C+c;(!tK(b.ptsMin)||e<b.ptsMin)&&(b.ptsMin=e),(!tK(b.ptsMax)||e+x>b.ptsMax)&&(b.ptsMax=e+x),i&&(i[t]={cts:c,duration:x,flags:h,size:n})}C+=x,M+=x}!M&&k&&(M+=k*u)}b.duration+=M,b.duration&&(n=!0)}if(!n){let t=1/0,i=0,r=rD(e,["sidx"]);for(let e=0;e<r.length;e++){let a=function(e){let t=[],i=e[0],r=8,a=rA(e,8);r+=4;let s=0,n=0;0===i?(s=rA(e,r),n=rA(e,r+4),r+=8):(s=r_(e,r),n=r_(e,r+8),r+=16),r+=2;let l=e.length+n,o=rT(e,r);r+=2;for(let i=0;i<o;i++){let i=r,s=rA(e,i);i+=4;let n=0x7fffffff&s;if(1==(0x80000000&s)>>>31)return iA.warn("SIDX has hierarchical references (not supported)"),null;let o=rA(e,i);i+=4,t.push({referenceSize:n,subsegmentDuration:o,info:{duration:o/a,start:l,end:l+n-1}}),l+=n,i+=4,r=i}return{earliestPresentationTime:s,timescale:a,version:i,referencesCount:o,references:t}}(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)}}
1i&&tK(i)&&Object.keys(s).forEach(e=>{s[e].duration||(s[e].duration=i*s[e].timescale-s[e].start)})}return s}function rB(e,t){let i=new Uint8Array(e.length+t.length);return i.set(e),i.set(t,e.length),i}function r$(e){if(!e)return!1;let t=e.substring(0,4);return"hvc1"===t||"hev1"===t||"dvh1"===t||"dvhe"===t}function rH(e,t){if(!e)return 6==(31&t);{let e=t>>1&63;return 39===e||40===e}}function rG(e,i,r,a){let s,n=rW(e);s=0+i;let l=0,o=0,d=0;for(;s<n.length;){l=0;do{if(s>=n.length)break;l+=d=n[s++]}while(255===d)o=0;do{if(s>=n.length)break;o+=d=n[s++]}while(255===d)let e=n.length-s,i=s;if(o<e)s+=o;else if(o>e){iA.error(`Malformed SEI payload. ${o} is too small, only ${e} bytes left to parse.`);break}if(4===l){if(181===n[i++]){let e=rT(n,i);if(i+=2,49===e){let e=rA(n,i);if(i+=4,0x47413934===e){let e=n[i++];if(3===e){let t=n[i++],s=31&t,o=64&t,d=o?2+3*s:0,h=new Uint8Array(d);if(o){h[0]=t;for(let e=1;e<d;e++)h[e]=n[i++]}a.push({type:e,payloadType:l,pts:r,bytes:h})}}}}}else if(5===l&&o>16){let e=[];for(let t=0;t<16;t++){let r=n[i++].toString(16);e.push(1==r.length?"0"+r:r),(3===t||5===t||7===t||9===t)&&e.push("-")}let s=o-16,d=new Uint8Array(s);for(let e=0;e<s;e++)d[e]=n[i++];a.push({payloadType:l,pts:r,uuid:e.join(""),userData:"u"<typeof TextDecoder?iO(d):(t||(t=new TextDecoder("utf-8"))).decode(d).replace(/\0/g,""),userDataBytes:d})}}}function rW(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,s=new Uint8Array(a),n=0,l=0;for(let i=0;i<a;l++,i++)l===t[n]&&(l++,n++),s[i]=e[l];return s}function rK(e){let t=[];if(e instanceof ArrayBuffer){let i=e.byteLength,r=0;for(;r+32<i;){let i=function(e){let t=e.getUint32(0),i=e.byteOffset,r=e.byteLength;if(r<t)return{offset:i,size:r};if(0x70737368!==e.getUint32(4))return{offset:i,size:t};let a=e.getUint32(8)>>>24;if(0!==a&&1!==a)return{offset:i,size:t};let s=e.buffer,n=iB(new Uint8Array(s,i+12,16)),l=null,o=null,d=0;
1if(0===a)d=28;else{let a=e.getUint32(28);if(!a||r<32+16*a)return{offset:i,size:t};l=[];for(let e=0;e<a;e++)l.push(new Uint8Array(s,i+32+16*e,16));d=32+16*a}if(!d)return{offset:i,size:t};let h=e.getUint32(d);return t-32<h?{offset:i,size:t}:(o=new Uint8Array(s,i+d+4,h),0===a&&(l=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 s=0;for(let t=0,r=128;128&r;t+=7)s|=(127&(r=e[i++]))<<t;if(r>>3==2)if(32===s){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===s&&t.push(e.subarray(i,i+16));i+=s}return t}(o)),{version:a,systemId:n,kids:l,data:o,offset:i,size:t})}(new DataView(e,r));t.push(i),r+=i.size}}return t}let rV=rj("userAgent"),rq=rj("vendor");function rj(e){try{return navigator[e]||""}catch(e){}return""}function rY(){if(void 0===i){let e=rV.match(/Chrome\/(\d+)/i);i=e?parseInt(e[1]):0}return i}function rz(){return/\(Windows.+Firefox\//i.test(rV)}let rQ={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 rX(e,t){let i=rQ[t];return!!i&&!!i[e.slice(0,4)]}function rZ(e,t,i=!0){return!e.split(",").some(e=>!rJ(e,t,i))}function rJ(e,t,i=!0){var r;let a=i_(i);return null!=(r=null==a?void 0:a.isTypeSupported(r0(e,t)))&&r}function r0(e,t){return`${t}/mp4;codecs=${e}`}function r1(e){if(e){let t=e.substring(0,4);return rQ.video[t]}return 2}function r2(e){let t=rz();return e.split(",").reduce((e,i)=>{let r=t&&r$(i)?9:rQ.video[i];return r?(2*r+e)/(e?3:2):(rQ.audio[i]+e)/(e?2:1)},0)}let r3={},r4=/flac|opus|mp4a\.40\.34/i;function r5(e,t=!0){return e.replace(r4,e=>(function(e,t=!0){if(r3[e])return r3[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(rJ(i[a],"audio",t))return r3[e]=i[a],i[a];if("mp3"===i[a]&&null!=(r=i_(t))&&r.isTypeSupported("audio/mpeg"))return""}return e})(e.toLowerCase(),t))}function r8(e,t){if(e&&(e.length>4||-1!==["ac-3","ec-3","alac","fLaC","Opus"].indexOf(e))&&(r6(e,"audio")||r6(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 r6(e,t){return rX(e,t)&&rJ(e,t)}function r9(e){let t=i_(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 r7(e){return e.replace(/^.+codecs=["']?([^"']+).*$/,"$1")}let ae={supported:!1,smooth:!1,powerEfficient:!1},at={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]};function ai(e,t){return{supported:!1,configurations:t,decodingInfoResults:[ae],error:e}}function ar(e,t,i,r={}){var a,s,n,l,o,d;let h,u,c,m,f,p,g,v,E=e.videoCodec;if(!E&&!e.audioCodec||!i)return Promise.resolve(at);let y=[],b=(h=null==(s=(a=e).videoCodec)?void 0:s.split(","),u=as(a),c=a.width||640,m=a.height||480,f=a.frameRate||30,p=a.videoRange.toLowerCase(),h?h.map(e=>{let t={contentType:r0(function(e){if(e.startsWith("av01.")){let t=e.split("."),i=["0","111","01","01","01","0"];for(let e=t.length;e>4&&e<10;e++)t[e]=i[e-4];return t.join(".")}return e}(e),"video"),width:c,height:m,bitrate:u,framerate:f};return"sdr"!==p&&(t.transferFunction=p),t}):[]),T=b.length,A=(n=e,l=t,o=T>0,g=null==(d=n.audioCodec)?void 0:d.split(","),v=as(n),g&&n.audioGroups?n.audioGroups.reduce((e,t)=>{var i;let r=t?null==(i=l.groups[t])?void 0:i.tracks:null;return r?r.reduce((e,i)=>{if(i.groupId===t){let t=parseFloat(i.channels||"");g.forEach(i=>
1{let r={contentType:r0(i,"audio"),bitrate:o?aa(i,v):v};t&&(r.channels=""+t),e.push(r)})}return e},e):e},[]):[]),S=A.length;for(let e=T||+S||1;e--;){let t={type:"media-source"};if(T&&(t.video=b[e%T]),S){t.audio=A[e%S];let i=t.audio.bitrate;t.video&&i&&(t.video.bitrate-=i)}y.push(t)}if(E){let e=navigator.userAgent;if(E.split(",").some(e=>r$(e))&&rz())return Promise.resolve(ai(Error(`Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent string: (${e})`),y))}return Promise.all(y.map(e=>{let t=function(e){let t="",{audio:i,video:r}=e;if(r){let e=r7(r.contentType);t+=`${e}_r${r.height}x${r.width}f${Math.ceil(r.framerate)}${r.transferFunction||"sd"}_${Math.ceil(r.bitrate/1e5)}`}if(i){let e=r7(i.contentType);t+=`${r?"_":""}${e}_c${i.channels}`}return t}(e);return r[t]||(r[t]=i.decodingInfo(e))})).then(e=>({supported:!e.some(e=>!e.supported),configurations:y,decodingInfoResults:e})).catch(e=>({supported:!1,configurations:y,decodingInfoResults:[],error:e}))}function aa(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 as(e){return 1e3*Math.ceil(Math.max(.9*e.bitrate,e.averageBitrate)/1e3)||1}function an(e,t,i){let r=encodeURIComponent(t),a=`${r}=${encodeURIComponent(i)}`,s=!1,n=[];e.search.substring(1).split("&").forEach(e=>{e===r||e.startsWith(r+"=")?s||(n.push(a),s=!0):e&&n.push(e)}),s||n.push(a),e.search=n.join("&")}let al=["NONE","TYPE-0","TYPE-1",null],ao=["SDR","PQ","HLG"];function ad(e){let{canSkipUntil:t,canSkipDateRanges:i,age:r}=e;return t&&r<t/2?i?"v2":"YES":""}class ah{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&&an(t,"_HLS_msn",this.msn.toString()),void 0!==this.part&&an(t,"_HLS_part",this.part.toString()),this.skip&&an(t,"_HLS_skip",this.skip),t.href}}class au{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;const 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 ac(this._audioGroups,e)}hasSubtitleGroup(e){return ac(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 ac(e,t){return!!t&&!!e&&-1!==e.indexOf(t)}let am=(e,t)=>{let i;return JSON.stringify(e,(i=new WeakSet,(e,r)=>{if(t&&(r=t(e,r)),"object"==typeof r&&null!==r){if(i.has(r))return;i.add(r)}return r}))};function af(e,t){iA.log(`[abr] start candidates with "${e}" ignored because ${t}`)}function ap(e){return e.reduce((e,t)=>
1{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 ag(e){if(!e)return e;let{lang:t,assocLang:i,characteristics:r,channels:a,audioCodec:s}=e;return{lang:t,assocLang:i,characteristics:r,channels:a,audioCodec:s}}function av(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(aE(e,t[r],i))return r;return -1}function aE(e,t,i){let{groupId:r,name:a,lang:s,assocLang:n,default:l}=e,o=e.forced;return(void 0===r||t.groupId===r)&&(void 0===a||t.name===a)&&(void 0===s||function(e,t="--"){return e.length===t.length?e===t:e.startsWith(t)||t.startsWith(e)}(s,t.lang))&&(void 0===n||t.assocLang===n)&&(void 0===l||t.default===l)&&(void 0===o||t.forced===o)&&(!("characteristics"in e)||function(e,t=""){let i=e.split(","),r=t.split(",");return i.length===r.length&&!i.some(e=>-1===r.indexOf(e))}(e.characteristics||"",t.characteristics))&&(void 0===i||i(e,t))}function ay(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 ab(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 aT(e,t){var i;return!!e&&e!==(null==(i=t.loadLevelObj)?void 0:i.uri)}function aA(e,t){return!t||-1!==t.indexOf(e)}function a_(e,t){if(t||e){let i=ie({},t);return e&&(e.videoCodec&&(i.videoCodec=e.videoCodec),e.videoRange&&(i.allowedVideoRanges=[e.videoRange])),i}}let aS=function(e,t){let i=0,r=e.length-1,a=null,s=null;for(;i<=r;){let n=t(s=e[a=(i+r)/2|0]);if(n>0)i=a+1;else{if(!(n<0))return s;r=a-1}}return null};function ak(e,t,i=0,r=0,a=.005){let s=null;if(e){s=t[1+e.sn-t[0].sn]||null;let r=e.endDTS-i;r>0&&r<15e-7&&(i+=15e-7),s&&e.level!==s.level&&s.end<=e.end&&(s=t[2+e.sn-t[0].sn]||null)}else 0===i&&0===t[0].start&&(s=t[0]);if(s&&((!e||e.level===s.level)&&0===aR(i,r,s)||function(e,t,i){if((null==t?void 0:t.start)===0&&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}(s,e,Math.min(a,r))))return s;let n=aS(t,aR.bind(null,i,r));return n&&(n!==e||!s)?n:s}function aR(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 aL(e,t,i){if(e&&e.startCC<=t&&e.endCC>=t){let r,a=e.fragments,{fragmentHint:s}=e;return s&&(a=a.concat(s)),aS(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 aI(e,t){return t===e.endSN&&e.fragmentHint?e.fragmentHint:e.fragments[1+t-e.startSN]||null}function aw(e){let t=e.details;return!(t!==tY.BUFFER_ADD_CODEC_ERROR&&t!==tY.MEDIA_SOURCE_REQUIRES_RESET&&(t!==tY.BUFFER_APPEND_ERROR||aD(e)))}function aD(e){return e.details===tY.BUFFER_APPEND_ERROR&&("QuotaExceededError"===e.error.name||"InvalidStateError"===e.error.name)}function aC(e){let t={action:0,flags:0};return e&&(t.resolved=!0),t}var aM="NOT_LOADED",ax="APPENDING",aP="PARTIAL";class aO{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(tz.MANIFEST_LOADING,this.onManifestLoading,this),e.on(tz.BUFFER_APPENDED,this.onBufferAppended,this),e.on(tz.FRAG_BUFFERED,this.onFragBuffered,this),e.on(tz.FRAG_LOADED,this.onFragLoaded,this))}_unregisterListeners(){let{hls:e}=this;e&&(e.off(tz.MANIFEST_LOADING,this.onManifestLoading,this),e.off(tz.BUFFER_APPENDED,this.onBufferAppended,this),e.off(tz.FRAG_BUFFERED,this.onFragBuffered,this),e.off(tz.FRAG_LOADED,this.onFragLoaded,this))}destroy(){this._unregisterListeners(),this.hls=this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(e,t){let i=this.activePartLists[t];if(i)for(let t=i.length;t--;){let r=i[t];if(!r)break;
1if(r.start<=e&&e<=r.end&&r.loaded)return r}return this.getBufferedFrag(e,t)}getBufferedFrag(e,t){return this.getFragAtPos(e,t,!0)}getFragAtPos(e,t,i){let{fragments:r}=this,a=Object.keys(r);for(let s=a.length;s--;){let n=r[a[s]];if((null==n?void 0:n.body.type)===t&&(!i||n.buffered)){let t=n.body;if(t.start<=e&&e<=t.end)return t}}return null}detectEvictedFragments(e,t,i,r,a,s){this.timeRanges&&(this.timeRanges[e]=t);let n=(null==a?void 0:a.fragment.sn)||-1;Object.keys(this.fragments).forEach(a=>{let l=this.fragments[a];if(!l||!this.hls)return;let o=l.body;if(n>=o.sn)return;if(!l.buffered&&(!l.loaded||s)){o.type===i&&this.removeFragment(o);return}let d=l.range[e];if(d){if(0===d.time.length)return void this.removeFragment(o);if(d.time.some(e=>{let i=!this.isTimeBuffered(e.startPTS,e.endPTS,t);return i&&this.removeFragment(o),i}),r&&r!==o&&rY()){let e=r.endPTS,t=o.startPTS;if(e&&t&&l.range.video){let i=t-e;i<0&&i>-.1&&(this.removeFragment(o),this.hls.trigger(tz.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||!t5(i))return;let s=aU(i),n=this.fragments[s];if(!n||n.buffered&&i.gap)return;let l=!i.relurl;Object.keys(t).forEach(e=>{let s=i.elementaryStreams[e];if(!s)return;let o=t[e],d=l||!0===s.partial;n.range[e]=this.getBufferedTimes(i,r,d,o),this.detectEvictedFragments(e,o,a,i,r)}),n.loaded=null;let o=Object.keys(n.range);if(o.length){if(this.bufferedEnd(n,i),aN(n)||this.removeParts(i.sn-1,i.type),!r){let e=Math.min(.004,i.duration);o.some(t=>{var r;let a=null==(r=n.range[t])?void 0:r.time,s=0===a.length||1===a.length&&a[0].endPTS-a[0].startPTS<e;return s&&this.addAsGap(i),s})}}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]=aF(i,t=>t.fragment.sn>=e))}fragBuffered(e,t){let i=aU(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},s=e.start,n=e.end,l=e.minEndPTS||n,o=e.maxStartPTS||s;for(let e=0;e<r.length;e++){let t=r.start(e)-this.bufferPadding,i=r.end(e)+this.bufferPadding;if(o>=t&&l<=i){a.time.push({startPTS:Math.max(s,r.start(e)),endPTS:Math.min(n,r.end(e))});break}if(s<i&&n>t){let t=Math.max(s,r.start(e)),i=Math.min(n,r.end(e));i>t&&(a.partial=!0,a.time.push({startPTS:t,endPTS:i}))}else if(n<=t)break}return a}getPartialFragment(e){let t,i,r,a=null,s=0,{bufferPadding:n,fragments:l}=this;return Object.keys(l).forEach(o=>{let d=l[o];d&&aN(d)&&(i=d.body.start-n,r=d.body.end+n,e>=i&&e<=r&&s<=(t=Math.min(e-i,r-e))&&(a=d.body,s=t))}),a}isEndListAppended(e){let t=this.endListFragments[e];return void 0!==t&&(t.buffered||aN(t))}getState(e){let t=aU(e),i=this.fragments[t];if(i)if(!i.buffered)return ax;else if(aN(i))return aP;else return"OK";return aM}isTimeBuffered(e,t,i){let r,a;for(let s=0;s<i.length;s++){if(r=i.start(s)-this.bufferPadding,a=i.end(s)+this.bufferPadding,e>=r&&t<=a)return!0;if(t<=r)break}return!1}onManifestLoading(){this.removeAllFragments()}onFragLoaded(e,t){if(!t5(t.frag)||t.frag.bitrateTest)return;let i=t.frag,r=t.part?null:t,a=aU(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(!t5(i))return;let s=i.type;if(r){let e=this.activePartLists[s];e||(this.activePartLists[s]=e=[]),e.push(r)}this.timeRanges=a}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){let t=aU(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,s=0,n=Object.keys(r);for(let l=0;l<n.length;l++){let o=r[n[l]];if(!o||!o.buffered||o.body.type!==t)continue;let d=o.body;if(d.gap)return 0;let h=d.hasStats&&d.stats.loaded||d.byteLength||d.bitrate&&8*d.bitrate*d.duration;if(d.end<=e&&h&&(a+=h,s=Math.max(s,d.end),a>=i))return s}return s>0?s:0}removeFragmentsInRange(e,t,i,r,a){(!r||this.hasGaps)&&Object.keys(this.fragments).forEac
1h(s=>{let n=this.fragments[s];if(!n)return;let l=n.body;l.type===i&&(!r||l.gap)&&l.start<t&&l.end>e&&(n.buffered||a)&&this.removeFragment(l)})}removeFragment(e){let t=aU(e);e.clearElementaryStreamInfo();let i=this.activePartLists[e.type];if(i){let t=e.sn;this.activePartLists[e.type]=aF(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 aN(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 aU(e){return`${e.type}_${e.level}_${e.sn}`}function aF(e,t){return e.filter(e=>{let i=t(e);return i||e.clearElementaryStreamInfo(),i})}class aB{constructor(e,t,i){this.subtle=void 0,this.aesIV=void 0,this.aesMode=void 0,this.subtle=e,this.aesIV=t,this.aesMode=i}decrypt(e,t){switch(this.aesMode){case 0:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e);case 1:return this.subtle.decrypt({name:"AES-CTR",counter:this.aesIV,length:64},t,e);default:throw Error(`[AESCrypto] invalid aes mode ${this.aesMode}`)}}}class a${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],s=i[2],n=i[3],l=this.invSubMix,o=l[0],d=l[1],h=l[2],u=l[3],c=new Uint32Array(256),m=0,f=0,p=0;for(p=0;p<256;p++)p<128?c[p]=p<<1:c[p]=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 l=c[m],p=c[l],g=c[p],v=257*c[i]^0x1010100*i;r[m]=v<<24|v>>>8,a[m]=v<<16|v>>>16,s[m]=v<<8|v>>>24,n[m]=v,v=0x1010101*g^65537*p^257*l^0x1010100*m,o[i]=v<<24|v>>>8,d[i]=v<<16|v>>>16,h[i]=v<<8|v>>>24,u[i]=v,m?(m=l^c[c[c[g^l]]],f^=c[c[f]]):m=f=1}}expandKey(e){let t,i,r,a,s=this.uint8ArrayToUint32Array_(e),n=!0,l=0;for(;l<s.length&&n;)n=s[l]===this.key[l],l++;if(n)return;this.key=s;let o=this.keySize=s.length;if(4!==o&&6!==o&&8!==o)throw Error("Invalid aes key size="+o);let d=this.ksRows=(o+6+1)*4,h=this.keySchedule=new Uint32Array(d),u=this.invKeySchedule=new Uint32Array(d),c=this.sBox,m=this.rcon,f=this.invSubMix,p=f[0],g=f[1],v=f[2],E=f[3];for(t=0;t<d;t++){if(t<o){r=h[t]=s[t];continue}a=r,t%o==0?a=(c[(a=a<<8|a>>>24)>>>24]<<24|c[a>>>16&255]<<16|c[a>>>8&255]<<8|c[255&a])^m[t/o|0]<<24:o>6&&t%o==4&&(a=c[a>>>24]<<24|c[a>>>16&255]<<16|c[a>>>8&255]<<8|c[255&a]),h[t]=r=(h[t-o]^a)>>>0}for(i=0;i<d;i++)t=d-i,a=3&i?h[t]:h[t-4],i<4||t<=4?u[i]=a:u[i]=p[c[a>>>24]]^g[c[a>>>16&255]]^v[c[a>>>8&255]]^E[c[255&a]],u[i]=u[i]>>>0}networkToHostOrderSwap(e){return e<<24|(65280&e)<<8|(0xff0000&e)>>8|e>>>24}decrypt(e,t,i){let r,a,s,n,l,o,d,h,u,c,m,f,p,g,v=this.keySize+6,E=this.invKeySchedule,y=this.invSBox,b=this.invSubMix,T=b[0],A=b[1],S=b[2],k=b[3],R=this.uint8ArrayToUint32Array_(i),L=R[0],I=R[1],w=R[2],D=R[3],C=new Int32Array(e),M=new Int32Array(C.length),x=this.networkToHostOrderSwap;for(;t<C.length;){for(g=1,u=x(C[t]),c=x(C[t+1]),m=x(C[t+2]),f=x(C[t+3]),l=u^E[0],o=f^E[1],d=m^E[2],h=c^E[3],p=4;g<v;g++)r=T[l>>>24]^A[o>>16&255]^S[d>>8&255]^k[255&h]^E[p],a=T[o>>>24]^A[d>>16&255]^S[h>>8&255]^k[255&l]^E[p+1],s=T[d>>>24]^A[h>>16&255]^S[l>>8&255]^k[255&o]^E[p+2],n=T[h>>>24]^A[l>>16&255]^S[o>>8&255]^k[255&d]^E[p+3],l=r,o=a,d=s,h=n,p+=4;r=y[l>>>24]<<24^y[o>>16&255]<<16^y[d>>8&255]<<8^y[255&h]^E[p],a=y[o>>>24]<<24^y[d>>16&255]<<16^y[h>>8&255]<<8^y[255&l]^E[p+1],s=y[d>>>24]<<24^y[h>>16&255]<<16^y[l>>8&255]<<8^y[255&o]^E[p+2],n=y[h>>>24]<<24^y[l>>16&255]<<16^y[o>>8&255]<<8^y[255&d]^E[p+3],M[t]=x(r^L),M[t+1]=x(n^I),M[t+2]=x(s^w),M[t+3]=x(a^D),L=u,I=c,w=m,D=f,t+=4}return M.buffer}}class aH{constructor(e,t,i){this.subtle=void 0,this.key=void 0,this.aesMode=void 0,this.subtle=e,this.key=t,this.aesMode=i}expandKey(){let e=function(e){switch(e){case 0:return"AES-CBC";case 1:return"AES-CTR";default:throw Error(`[FastAESKey] invalid aes mode ${e}`)}}(this.aesMode);return this.subtle.importKey("raw",this.key,{name:e},!1,["encrypt","decrypt"])}}class aG{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.enableSoftw
1areAES=void 0,this.enableSoftwareAES=e.enableSoftwareAES,!0!==t)try{const e=self.crypto;e&&(this.subtle=e.subtle||e.webkitSubtle)}catch(e){}this.useSoftware=!this.subtle}destroy(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}isSync(){return this.useSoftware}flush(){let e,t,{currentResult:i,remainderData:r}=this;if(!i||r)return this.reset(),null;let a=new Uint8Array(i);this.reset();let s=this.decryptRange;return s?0===s.start&&s.end>=a.length?a:a.slice(s.start,s.end):(t=(e=a.byteLength)&&new DataView(a.buffer).getUint8(e-1))?a.slice(0,e-t):a}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,s)=>{let n=ArrayBuffer.isView(e)?e:new Uint8Array(e);this.softwareDecrypt(n,t,i,r);let l=this.flush();l?a(l.buffer):s(Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,i,r)}softwareDecrypt(e,t,i,r){let{currentIV:a,currentResult:s,remainderData:n}=this;if(0!==r||16!==t.byteLength)return iA.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;this.logOnce("JS AES decrypt"),n&&(e=rB(n,e),this.remainderData=null);let l=this.getValidChunk(e);if(!l.length)return null;a&&(i=a);let o=this.softwareDecrypter;return(o||(o=this.softwareDecrypter=new a$),o.expandKey(t),this.currentResult=o.decrypt(l.buffer,0,i),this.currentIV=l.slice(-16).buffer,s)?s: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 aH(this.subtle,t,r)}return this.fastAesKey.expandKey().then(t=>this.subtle?(this.logOnce("WebCrypto AES decrypt"),new aB(this.subtle,new Uint8Array(i),r).decrypt(e.buffer,t)):Promise.reject(Error("web crypto not initialized"))).catch(a=>(iA.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 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&&(iA.log(`[decrypter]: ${e}`),this.logEnabled=!1)}}class aW{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 aj({type:tj.NETWORK_ERROR,details:tY.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:Error(`Fragment does not have a ${a?"part list":"url"}`),networkDetails:null}));this.abort();let s=this.config,n=s.fLoader,l=s.loader;return new Promise((o,d)=>{if(this.loader&&this.loader.destroy(),e.gap)if(e.tagList.some(e=>"GAP"===e[0]))return void d(aq(e));else e.gap=!1;let h=this.loader=n?new n(s):new l(s),u=aK(e,null,t);e.loader=h;let c=ih(s.fragLoadPolicy.default),m={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===e.sn?1/0:131072};h.stats.retry=e.stats.retry,e.stats=h.stats;let f={onSuccess:(t,i,r,a)=>{this.resetLoader(e,h);let s=t.data;r.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(s.slice(0,16)),s=s.slice(16)),o({frag:e,part:null,payload:s,networkDetails:a})},onError:(t,i,r,s)=>{this.resetLoader(e,h),d(new aj({type:tj.NETWORK_ERROR,details:tY.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:ii({url:a,data:void 0},t),error:Error(`HTTP Error ${t.code} ${t.text}`),networkDetails:r,stats:s}))},onAbort:(t,i,r)=>{this.resetLoader(e,h),d(new aj({type:tj.NETWORK_ERROR,details:tY.INTERNAL_ABORTED,fatal:!1,frag:e,error:Error("Aborted"),networkDetails:r,stats:t}))},onTimeout:(t,i,r)=>{this.resetLoader(e,h),d(new aj({type:tj.NETWORK_ERROR,details:tY.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:Error(`Timeout after ${m.timeout}ms`),networkDetails:r,stats:t}))}};if(i){let t=this.gateProgress(i,r);f.onProgress=(i,r,a,s)=>t({frag:e,part:null,payload:a,networkDetails:s})}h.load(u,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}
1).catch(()=>{}),i=t=>{a?e(t):r.push(t)}}return i}loadPart(e,t,i){this.abort();let r=this.config,a=r.fLoader,s=r.loader;return new Promise((n,l)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap)return void l(aq(e,t));let o=this.loader=a?new a(r):new s(r),d=aK(e,t);e.loader=o;let h=ih(r.fragLoadPolicy.default),u={loadPolicy:h,timeout:h.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:131072};t.stats=o.stats,o.load(d,u,{onSuccess:(r,a,s,l)=>{this.resetLoader(e,o),this.updateStatsFromPart(e,t);let d={frag:e,part:t,payload:r.data,networkDetails:l};i(d),n(d)},onError:(i,r,a,s)=>{this.resetLoader(e,o),l(new aj({type:tj.NETWORK_ERROR,details:tY.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:ii({url:d.url,data:void 0},i),error:Error(`HTTP Error ${i.code} ${i.text}`),networkDetails:a,stats:s}))},onAbort:(i,r,a)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,o),l(new aj({type:tj.NETWORK_ERROR,details:tY.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:Error("Aborted"),networkDetails:a,stats:i}))},onTimeout:(i,r,a)=>{this.resetLoader(e,o),l(new aj({type:tj.NETWORK_ERROR,details:tY.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:Error(`Timeout after ${u.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),s=Math.min(Math.round(i.loaded/a),r),n=(r-s)*Math.round(i.loaded/s);i.total=i.loaded+n}else i.total=Math.max(i.loaded,i.total);let s=i.loading,n=r.loading;s.start?s.first+=n.first-n.start:(s.start=n.start,s.first=n.first),s.end=n.end}resetLoader(e,t){e.loader=null,e.url=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}}function aK(e,t=null,i){let r=t||e,a={type:tJ.MEDIA_FRAGMENT,frag:e,part:t,responseType:"arraybuffer",url:r.url,headers:{},rangeStart:0,rangeEnd:0},s=aV(e,t,i);return s.resetIV&&(a.resetIV=!0),s.byteRange&&(a.rangeStart=s.byteRange.start,a.rangeEnd=s.byteRange.end),a}function aV(e,t=null,i){let r={},a=t||e,s=a.byteRangeStartOffset,n=a.byteRangeEndOffset;if(tK(s)&&tK(n)){var l,o;if(("initSegment"===e.sn||i)&&("AES-128"===(o=null==(l=e.decryptdata)?void 0:l.method)||"AES-256"===o)){let e=16*Math.floor(s/16),t=16*Math.ceil(n/16);r.decryptRange={start:s-e,end:n-e},e>=16&&(r.resetIV=!0,e-=16),r.byteRange={start:e,end:t}}else r.byteRange={start:s,end:n}}return r}function aq(e,t){let i=Error(`GAP ${e.gap?"tag":"attribute"} found`),r={type:tj.MEDIA_ERROR,details:tY.FRAG_GAP,fatal:!1,frag:e,error:i,networkDetails:null};return t&&(r.part=t),(t||e).stats.aborted=!0,new aj(r)}class aj extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}}class aY extends iv{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.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(){}}class az{constructor(e,t,i,r=0,a=-1,s=!1,n,l,o){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=aQ(),this.buffering={audio:aQ(),video:aQ(),audiovideo:aQ()},this.level=e,this.sn=t,this.id=i,this.size=r,this.part=a,this.partial=s,this.duration=n||0,this.decryptRange=o,this.iframe=l||!1}}function aQ(){return{start:0,executeStart:0,executeEnd:0,end:0}}let aX={length:0,start:()=>0,end:()=>0};class aZ{static isBuffered(e,t){if(e){let i=aZ.getBuffered(e);for(let e=i.length;e--;)if(t>=i.start(e)&&t<=i.end(e))return!0}return!1}static bufferedRanges(e){if(e){let t=aZ.getBuffered(e);return aZ.timeRangesToArray(t)}return[]}static timeRangesToArray(e){let t=[];for(let i=0;i<e.length;i++)t.push({start:e.start(i),end:e.end(i)});return t}static bufferInfo(e,t,i){if(e){let r=aZ.bufferedRanges(e);if(r.length)return aZ.bufferedInfo(r,t,i)}return{len:0,start:t,end:t,bufferedIndex:-1}}static bufferedInfo(e,t,i){let r;t=Math.max(0,t),e.length>1&&e.sort((e,t)=>
1e.start-t.start||t.end-e.end);let a=-1,s=[];if(i)for(let r=0;r<e.length;r++){t>=e[r].start&&t<=e[r].end&&(a=r);let n=s.length;if(n){let t=s[n-1].end;e[r].start-t<i?e[r].end>t&&(s[n-1].end=e[r].end):s.push(e[r])}else s.push(e[r])}else s=e;let n=0,l=t,o=t;for(let e=0;e<s.length;e++){let d=s[e].start,h=s[e].end;if(-1===a&&t>=d&&t<=h&&(a=e),t+i>=d&&t<h)l=d,n=(o=h)-t;else if(t+i<d){r=d;break}}return{len:n,start:l||0,end:o||0,nextStart:r,buffered:e,bufferedIndex:a}}static getBuffered(e){try{return e.buffered||aX}catch(e){return iA.log("failed to get media.buffered",e),aX}}}let aJ=/\{\$([a-zA-Z0-9-_]+)\}/g;function a0(e){return aJ.lastIndex=0,aJ.test(e)}function a1(e,t){if(null!==e.variableList||e.hasVariableRefs){let i=e.variableList;return t.replace(aJ,t=>{let r=t.substring(2,t.length-1),a=null==i?void 0:i[r];return void 0===a?(e.playlistParsingError||(e.playlistParsingError=Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${r}"`)),t):a})}return t}function a2(e,t,i){let r,a,s=e.variableList;if(s||(e.variableList=s={}),"QUERYPARAM"in t){r=t.QUERYPARAM;try{let e=new self.URL(i).searchParams;if(e.has(r))a=e.get(r);else throw Error(`"${r}" does not match any query parameter in URI: "${i}"`)}catch(t){e.playlistParsingError||(e.playlistParsingError=Error(`EXT-X-DEFINE QUERYPARAM: ${t.message}`))}}else r=t.NAME,a=t.VALUE;r in s?e.playlistParsingError||(e.playlistParsingError=Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${r}"`)):s[r]=a||""}let a3=/^(\d+)x(\d+)$/,a4=/(.+?)=(".*?"|.*?)(?:,|$)/g;class a5{constructor(e,t){"string"==typeof e&&(e=a5.parseAttrList(e,t)),ie(this,e)}get clientAttrs(){return Object.keys(this).filter(e=>"X-"===e.substring(0,2))}decimalInteger(e){let t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t}hexadecimalInteger(e){if(this[e]){let t=(this[e]||"0x").slice(2),i=new Uint8Array((t=(1&t.length?"0":"")+t).length/2);for(let e=0;e<t.length/2;e++)i[e]=parseInt(t.slice(2*e,2*e+2),16);return i}return null}hexadecimalIntegerAsNumber(e){let t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t}decimalFloatingPoint(e){return parseFloat(this[e])}optionalFloat(e,t){let i=this[e];return i?parseFloat(i):t}enumeratedString(e){return this[e]}enumeratedStringList(e,t){let i=this[e];return(i?i.split(/[ ,]+/):[]).reduce((e,t)=>(e[t.toLowerCase()]=!0,e),t)}bool(e){return"YES"===this[e]}decimalResolution(e){let t=a3.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(a4.lastIndex=0;null!==(i=a4.exec(e));){let a=i[1].trim(),s=i[2],n=0===s.indexOf('"')&&s.lastIndexOf('"')===s.length-1,l=!1;if(n)s=s.slice(1,-1);else switch(a){case"IV":case"SCTE35-CMD":case"SCTE35-IN":case"SCTE35-OUT":l=!0}if(t&&(n||l))s=a1(t,s);else if(!l&&!n)switch(a){case"CLOSED-CAPTIONS":if("NONE"===s)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":iA.warn(`${e}: attribute ${a} is missing quotes`)}r[a]=s}return r}}class a8{constructor(e,t,i=0){var r;if(this.attr=void 0,this.tagAnchor=void 0,this.tagOrder=void 0,this._startDate=void 0,this._endDate=void 0,this._dateAtEnd=void 0,this._cue=void 0,this._badValueForSameId=void 0,this.tagAnchor=(null==t?void 0:t.tagAnchor)||null,this.tagOrder=null!=(r=null==t?void 0:t.tagOrder)?r:i,t){const i=t.attr;for(const t in i)if(Object.prototype.hasOwnProperty.call(e,t)&&e[t]!==i[t]){iA.warn(`DATERANGE tag attribute: "${t}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=t;break}e=ie(new a5({}),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){const i=(null==t?void 0:t.endDate)||new Date(e["END-DATE"]);tK(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?(iA.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(tK(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&&tK(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`:tK(this.startDate.getTime())?this.isInterstitial&&!("X-ASSET-URI"in this.attr||"X-ASSET-LIST"in this.attr)?"Interstitial Date range missing X-ASSET-(LIST|URI)":this.isValid?null:"Unknown (check DURATION(|END|NEXT), CLASS, and CUE)":"Date range invalid start date":"Missing ID"}}class a6{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.drift
1StartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.appliedTimelineOffset=void 0,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=e}reloaded(e){if(!e){this.advanced=!0,this.updated=!0;return}let t=this.lastPartSn-e.lastPartSn,i=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!i||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||0===t&&i>0,this.updated||this.advanced?this.misses=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&&tK(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 a9(e,t){return e.length===t.length&&!e.some((e,i)=>e!==t[i])}function a7(e,t){return!e&&!t||!!e&&!!t&&a9(e,t)}function se(e){return"AES-128"===e||"AES-256"===e||"AES-256-CTR"===e}function st(e){switch(e){case"AES-128":case"AES-256":return 0;case"AES-256-CTR":return 1;default:throw Error(`invalid full segment method ${e}`)}}function si(e){return Uint8Array.from(unescape(encodeURIComponent(e)),e=>e.charCodeAt(0))}function sr(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 sa(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];if(t)e.splice(-1,1),i=iH(a);else{let e,t;e=si(a).subarray(0,16),(t=new Uint8Array(16)).set(e,16-e.length),i=t}}}return i}let ss="u">typeof self?self:void 0;var sn="org.w3.clearkey",sl="com.apple.fps",so="com.microsoft.playready",sd="com.widevine.alpha",sh="org.w3.clearkey",su="com.apple.streamingkeydelivery",sc="com.microsoft.playready",sm="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function sf(e){switch(e){case su:return sl;case sc:return so;case sm:return sd;case sh:return sn}}var sp="edef8ba979d64acea3c827dcd51d21ed";function sg(e){switch(e){case sl:return su;case so:return sc;case sd:return sm;case sn:return sh}}function sv(e){let{drmSystems:t,widevineLicenseUrl:i}=e,r=t?[sl,sd,so,sn].filter(e=>!!t[e]):[];return!r[sd]&&i&&r.push(sd),r}let sE=null!=ss&&null!=(hJ=ss.navigator)&&hJ.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;function sy(e){let t=iG(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=iH(e).subarray(0,16);return sr(t),t}}return null}let sb={};class sT{static clearKeyUriToKeyIdMap(){sb={}}static setKeyIdForUri(e,t){sb[e]=t}static addKeyIdForUri(e){let t=Object.keys(sb).length%Number.MAX_SAFE_INTEGER,i=new Uint8Array(16);return new DataView(i.buffer,12,4).setUint32(0,t),sb[e]=i,i}constructor(e,t,i,r=[1],a=null,s){this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pss
1h=null,this.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&&!se(e),null!=s&&s.startsWith("0x")&&(this.keyId=new Uint8Array(i$(s)))}matches(e){return e.uri===this.uri&&e.method===this.method&&e.encrypted===this.encrypted&&e.keyFormat===this.keyFormat&&a9(e.keyFormatVersions,this.keyFormatVersions)&&a7(e.iv,this.iv)&&a7(e.keyId,this.keyId)}isSupported(){if(this.method){if(se(this.method)||"NONE"===this.method)return!0;if("identity"===this.keyFormat)return"SAMPLE-AES"===this.method;switch(this.keyFormat){case su:case sm:case sc:case sh:return -1!==["SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)}}return!1}getDecryptData(e,t){var i,r,a;if(!this.encrypted||!this.uri)return null;if(se(this.method)){let t=this.iv;return t||("number"!=typeof e&&(iA.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0),t=function(e){let t=new Uint8Array(16);for(let i=12;i<16;i++)t[i]=e>>8*(15-i)&255;return t}(e)),new sT(this.method,this.uri,"identity",this.keyFormatVersions,t)}if(this.keyId){let e=sb[this.uri];if(e&&!a9(this.keyId,e)&&sT.setKeyIdForUri(this.uri,this.keyId),this.pssh)return this}let s=sa(this.uri);if(s)switch(this.keyFormat){case sm:if(this.pssh=s,!this.keyId){let e=rK(s.buffer).filter(e=>e.systemId===sp);if(e.length){let t=e[0];this.keyId=null!=(r=t.kids)&&r.length?t.kids[0]:null}}this.keyId||(this.keyId=sA(t));break;case sc:{let e=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=function(e,t){let i,r;if(16!==e.byteLength)throw RangeError("Invalid system id");i=new Uint8Array,r=new Uint8Array;let a=new Uint8Array(4);return t.byteLength>0&&new DataView(a.buffer).setUint32(0,t.byteLength,!1),function(e,...t){let i=t.length,r=8,a=i;for(;a--;)r+=t[a].byteLength;let s=new Uint8Array(r);for(s[0]=r>>24&255,s[1]=r>>16&255,s[2]=r>>8&255,s[3]=255&r,s.set(e,4),a=0,r=8;a<i;a++)s.set(t[a],r),r+=t[a].byteLength;return s}([112,115,115,104],new Uint8Array([0,0,0,0]),e,r,i,a,t)}(e,s),this.keyId=sy(s);break}default:{let e=s.subarray(0,16);if(16!==e.length){let t=new Uint8Array(16);t.set(e,16-e.length),e=t}this.keyId=e}}if((null==(i=this.keyId)?void 0:i.byteLength)!==16){let e,i;!(e=(i=null==(a=t)?void 0:a[sm])?i.keyId:null)&&((e=sA(t))||(e=sb[this.uri])),e&&(this.keyId=e,sT.setKeyIdForUri(this.uri,e))}return this}}function sA(e){let t=null==e?void 0:e[sc];if(t){let e=sa(t.uri);if(e)return sy(e)}return null}let s_=/#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,sS=/#EXT-X-MEDIA:(.*)/g,sk=/^#EXT(?:INF|-X-TARGETDURATION):/m,sR=RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#.*/.source].join("|"),"g"),sL=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("|"));class sI{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 tX.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return sk.test(e)}static parseMasterPlaylist(e,t){let i,r={contentSteering:null,levels:[],iframeVariants:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:a0(e)},a=[];if(s_.lastIndex=0,!e.startsWith("#EXTM3U"))return r.playlistParsingError=Error("no EXTM3U delimiter"),r;for(;null!=(i=s_.exec(e));)if(i[1]){let e=sw(new a5(i[1],r),i[2],t,r,a);e&&r.levels.push(e)}else if(i[3]){let e=i[3],s=i[4];switch(e){case"I-FRAME-STREAM-INF":{let e=new a5(s,r),i=sw(e,e.URI,t,r,a,!0);i&&r.iframeVariants.push(i)}break;case"SESSION-DATA":{let e=new a5(s,r),t=e["DATA-ID"];t&&(null===r.sessionData&&(r.sessionData={}),r.sessionData[t]=e);break}case"SESSION-KEY":{let e=sC(s,t,r);e.encrypted&&e.isSupported()?(null===r.sessionKeys&&(r.sessionKeys=[]),r.sessionKeys.push(e)):iA.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${s}"`);break}case"DEFINE":{let e=new a5(s,r);a2(r,e,t)}break;case"CONTENT-STEERING":{let e=new a5(s,r);r.contentSteering={uri:sI.resolve(e["SERVER-URI"],t),pathwayId:e["PATHWAY-ID"]||"."};break}case"START":r.startTimeOffset=sM(s)}}let s=a.length>0&&a.length<r.levels.length;return r.levels=s?a:r.levels,0===r.levels.length&&(r.playlistParsingError=Error("no levels found in manifest")),r}static parseMasterPlaylistMedia(e,t,i){let r,a={},s=i.levels,n={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(sS.lastIndex=0;null!==(r=sS.exec(e));){let e=new a5(r[1],i),s=e.TYPE;if(s){let i=n[s],r=a[s]||[];a[s]=r;let o=e.LANGUAGE,d=e["ASSOC-LANGUAGE"],h=e.CHANNELS,u=e.CHARACTERISTICS,c=e["INSTREAM-ID"],m={attrs:e,bitrate:0,id:l++,groupId:e["GROUP-ID"]||"",name:e.NAME||o||"",type:s,default:e.bool("DEFAULT"),autoselect:e.bool("AUTOSELECT"),forced:e.bool("FORCED"),lang:o,url:e.URI?sI.resolve(e.URI,t):""};if(d&&(m.assocLang=d),h&&(m.channels=h),u&&(m.characteristics=u),c&&(m.instreamId=c),null!=i&&i.length){let e=sI.findGroup(i,m.groupId)||i[0];sP(m,e,"audioCodec"),sP(m,e,"textCodec")}r.push(m)}}return a}static parseLevelPlaylist(e,t,i,r,a,s){var n,l,o,d,h;let u,c,m,f,p={url:t},g=new a6(t),v=g.fragments,E=[],y=null,b=0,T=0,A=0,S=0,k=0,R=null,
1L=new t9(r,p),I=-1,w=!1,D=null;if(sR.lastIndex=0,g.m3u8=e,g.hasVariableRefs=a0(e),(null==(n=sR.exec(e))?void 0:n[0])!=="#EXTM3U")return g.playlistParsingError=Error("Missing format identifier #EXTM3U"),g;for(;null!==(u=sR.exec(e));){w&&(w=!1,(L=new t9(r,p)).playlistOffset=A,L.setStart(A),L.sn=b,L.cc=S,k&&(L.bitrate=k),L.level=i,y&&(L.initSegment=y,y.rawProgramDateTime&&(L.rawProgramDateTime=y.rawProgramDateTime,y.rawProgramDateTime=null),D&&(L.setByteRange(D),D=null)));let e=u[1];if(e){L.duration=parseFloat(e);let t=(" "+u[2]).slice(1);L.title=t||null,L.tagList.push(t?["INF",e,t]:["INF",e])}else if(u[3]){if(tK(L.duration)){L.playlistOffset=A,L.setStart(A),m&&sU(L,m,g),L.sn=b,L.level=i,L.cc=S;let e=(" "+u[3]).slice(1);L.relurl=a1(g,e),sO(L,R,E),R=L,A+=L.duration,b++,T=0;let t=L.byteRange;if(2===t.length&&(L.bitrate=(t[1]-t[0])*8/L.duration|0),g.iframesOnly&&t[0]&&(null==(l=y)?void 0:l.cc)!==S){let e=new t9(r,p);e.relurl=L.relurl,e.setByteRange(`${Math.min(t[0],1316)}@0`),e.level=i,e.sn="initSegment",m&&(e.levelkeys=m,m.identity&&(e._decryptdata=m.identity.getDecryptData(0))),y=e,L.initSegment=y}v.push(L),w=!0}}else{if(!(u=u[0].match(sL))){iA.warn("No matches on slow regex match for level playlist!");continue}for(c=1;c<u.length&&void 0===u[c];c++);let e=(" "+u[c]).slice(1),a=(" "+u[c+1]).slice(1),n=u[c+2]?(" "+u[c+2]).slice(1):null;switch(e){case"BYTERANGE":R?L.setByteRange(a,R):L.setByteRange(a);break;case"PROGRAM-DATE-TIME":L.rawProgramDateTime=a,L.tagList.push(["PROGRAM-DATE-TIME",a]),-1===I&&(I=v.length);break;case"PLAYLIST-TYPE":g.type&&sF(g,e,u),g.type=a.toUpperCase();break;case"MEDIA-SEQUENCE":0!==g.startSN?sF(g,e,u):null!==R&&(o=g,d=e,h=u,o.playlistParsingError=Error(`#EXT-X-${d} must appear before the first Media Segment (${h[0]})`)),g.startSN=parseInt(a),b=g.startSN+g.skippedSegments;break;case"SKIP":{g.skippedSegments&&sF(g,e,u);let t=new a5(a,g),i=t.decimalInteger("SKIPPED-SEGMENTS");if(tK(i)){g.skippedSegments+=i;for(let e=i;e--;)v.push(null);b+=i}let r=t.enumeratedString("RECENTLY-REMOVED-DATERANGES");r&&(g.recentlyRemovedDateranges=(g.recentlyRemovedDateranges||[]).concat(r.split("	")));break}case"TARGETDURATION":0!==g.targetduration&&sF(g,e,u),g.targetduration=Math.max(parseInt(a),1);break;case"VERSION":null!==g.version&&sF(g,e,u),g.version=parseInt(a);break;case"INDEPENDENT-SEGMENTS":break;case"I-FRAMES-ONLY":g.iframesOnly=!0;break;case"ENDLIST":g.live||sF(g,e,u),g.live=!1;break;case"#":(a||n)&&L.tagList.push(n?[a,n]:[a]);break;case"DISCONTINUITY":S++,L.tagList.push(["DIS"]);break;case"GAP":L.gap=!0,L.tagList.push([e]);break;case"BITRATE":L.tagList.push([e,a]),tK(k=1e3*parseInt(a))?L.bitrate=k:k=0;break;case"DATERANGE":{let e=new a5(a,g),t=new a8(e,g.dateRanges[e.ID],g.dateRangeTagCount);g.dateRangeTagCount++,t.isValid||g.skippedSegments?g.dateRanges[t.id]=t:iA.log(`Ignoring invalid DATERANGE tag: ${t.invalidReason}: ${a}`),L.tagList.push(["EXT-X-DATERANGE",a]);break}case"DEFINE":{let e=new a5(a,g);"IMPORT"in e?function(e,t,i){let r=t.IMPORT;if(i&&r in i){let t=e.variableList;t||(e.variableList=t={}),t[r]=i[r]}else e.playlistParsingError||(e.playlistParsingError=Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${r}"`))}(g,e,s):a2(g,e,t)}break;case"DISCONTINUITY-SEQUENCE":0!==g.startCC&&sF(g,e,u),g.startCC=S=parseInt(a),v.forEach(e=>e&&(e.cc=S));break;case"KEY":{let e=sC(a,t,g);if(e.isSupported()){if("NONE"===e.method){m=void 0;break}m||(m={});let t=m[e.keyFormat];null!=t&&t.matches(e)||(t&&(m=ie({},m)),m[e.keyFormat]=e)}else iA.warn(`[Keys] Ignoring unsupported EXT-X-KEY tag: "${a}"`);break}case"START":g.startTimeOffset=sM(a);break;case"MAP":{let e=new a5(a,g);if(L.duration){let t=new t9(r,p);sN(t,e,i,m),y=t,L.initSegment=y,y.rawProgramDateTime&&!L.rawProgramDateTime&&(L.rawProgramDateTime=y.rawProgramDateTime)}else{let t=L.byteRangeEndOffset;if(t){let e=L.byteRangeStartOffset;D=`${t-e}@${e}`}else D=null;sN(L,e,i,m),y=L,w=!0}y.cc=S;break}case"SERVER-CONTROL":f&&sF(g,e,u),g.canBlockReload=(f=new a5(a)).bool("CAN-BLOCK-RELOAD"),g.canSkipUntil=f.optionalFloat("CAN-SKIP-UNTIL",0),g.canSkipDateRanges=g.canSkipUntil>0&&f.bool("CAN-SKIP-DATERANGES"),g.partHoldBack=f.optionalFloat("PART-HOLD-BACK",0),g.holdBack=f.optionalFloat("HOLD-BACK",0);break;case"PART-INF":g.partTarget&&sF(g,e,u),g.partTarget=new a5(a).decimalFloatingPoint("PART-TARGET");break;case"PART":{let e=g.partList;e||(e=g.partList=[]);let t=T>0?e[e.length-1]:void 0,i=T++,r=new t7(new a5(a,g),L,p,i,t);e.push(r),L.duration+=r.duration;break}case"PRELOAD-HINT":{let e=new a5(a,g);g.preloadHint=e;break}case"RENDITION-REPORT":{let e=new a5(a,g);g.renditionReports=g.renditionReports||[],g.renditionReports.push(e);break}default:iA.warn(`line parsed but not handled: ${u}`)}}}R&&!R.relurl?(v.pop(),A-=R.duration,g.partList&&(g.fragmentHint=R)):g.partList&&(sO(L,R,E),L.cc=S,g.fragmentHint=L,m&&sU(L,m,g)),g.targetduration||(g.playlistParsingError=Error("Missing Target Duration"));let C=v.length,M=v[0],x=v[C-1];if((A+=g.skippedSegments*g.targetduration)>0&&C&&x){g.averagetargetduration=A/C;let e=x.sn;g.endSN="initSegment"!==e?e:0,g.live||(x.endList=!0),I>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}}(v,I,I>C-1?L:null),M&&E.unshift(M))}return g.fragmentHint&&(A+=g.fragmentHint.duration),g.totalduration=A,E.length&&g.dateRangeTagCount&&M&&sD(E,g),g.endCC=S,g}}function sw(e,t,i,r,a,s){var n;if(void 0===t)return null;let l=a1(r,t),o={attrs:e,bitrate:e.decimalInteger("BANDWIDTH")||e.decimalInteger("AVERAGE-BANDWIDTH"),name:e.NAME,url:sI.resolve(l,i)},d=e.decimalResolution("RESOLUTION");d&&(o.width=d.width,o.height=d.height),sx(e.CODECS,o);let h=e["SUPPLEMENTAL-CODECS"];return h&&(o.supplemental={},sx(h,o.supplemental)),null!=(n=o.unknownCodecs)&&n.length||a.push(o),s&&(o.iframes=!0),o}function sD(e,t){let i=e.length;if(!i)if(!t.hasProgramDateTime)return;else{let r=t.fragments[t.fragments.length-1];e.push(r),i++}let r=e[i-1],a=t.live?1/0:t.totalduration,s=Object.keys(t.dateRanges);for(let l=s.length;l--;){let o=t.dateRanges[s[l]],d=o.startDate.getTime();o.tagAnchor=r.ref;for(let r=i;r--;){var n;if((null==(n=e[r])?void 0:n.sn)<t.startSN)break;let i=function(e,t,i,r,a){let s=i[r];if(s){let l=s.programDateTime;if(t>=l||0===r){var n;if(t<=l+1e3*(((null==(n=i[r+1])?void 0:n.start)||a)-s.start)){let a=s.sn-e.startSN,n=e.fragments;if(a>=0&&a<n.length){if(n.length>i.length){let s=Math.min((i[r+1]||n[n.length-1]).sn-e.startSN,n.length-1);for(let e=s;e>a;e--){let i=n[e].programDateTime;if(t>=i&&t<i+1e3*n[e].duration)return n[e]}}return n[a]}}}}return null}(t,d,e,r,a);if(i){o.tagAnchor=i.ref;break}}}}function sC(e,t,i){var r,a;let s=new a5(e,i),n=null!=(r=s.METHOD)?r:"",l=s.URI,o=s.hexadecimalInteger("IV"),d=s.KEYFORMATVERSIONS,h=null!=(a=s.KEYFORMAT)?a:"identity";return l&&s.IV&&!o&&iA.error(`Invalid IV: ${s.IV}
1`),new sT(n,l?sI.resolve(l,t):"",h,(d||"1").split("/").map(Number).filter(Number.isFinite),o,s.KEYID)}function sM(e){let t=new a5(e).decimalFloatingPoint("TIME-OFFSET");return tK(t)?t:null}function sx(e,t){let i=(e||"").split(/[ ,]+/).filter(e=>e);["video","audio","text","image"].forEach(e=>{let r=i.filter(t=>rX(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 sP(e,t,i){let r=t[i];r&&(e[i]=r)}function sO(e,t,i){e.rawProgramDateTime?i.push(e):null!=t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime)}function sN(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 sU(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 sF(e,t,i){e.playlistParsingError=Error(`#EXT-X-${t} must not appear more than once (${i[0]})`)}function sB(e,t){let i=t.startPTS;if(tK(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 s$(e,t,i,r,a,s,n,l){let o;r-i<=0&&(l.warn("Fragment should have a positive duration",t),r=i+t.duration,s=a+t.duration);let d=i,h=r,u=t.startPTS,c=t.endPTS;if(tK(u)){let n=Math.abs(u-i);e&&n>e.totalduration?l.warn(`media timestamps and playlist times differ by ${n}s for level ${t.level} ${e.url}`):tK(t.deltaPTS)?t.deltaPTS=Math.max(n,t.deltaPTS):t.deltaPTS=n,d=Math.max(i,u),i=Math.min(i,u),a=void 0!==t.startDTS?Math.min(a,t.startDTS):a,h=Math.min(r,c),r=Math.max(r,c),s=void 0!==t.endDTS?Math.max(s,t.endDTS):s}let m=i-t.start;0!==t.start&&t.setStart(i),t.setDuration(r-t.start),t.startPTS=i,t.maxStartPTS=d,t.startDTS=a,t.endPTS=r,t.minEndPTS=h,t.endDTS=s;let f=t.sn;if(!e||f<e.startSN||f>e.endSN)return 0;let p=f-e.startSN,g=e.fragments;for(g[p]=t,o=p;o>0;o--)sB(g[o],g[o-1]);for(o=p;o<g.length-1;o++)sB(g[o],g[o+1]);return e.fragmentHint&&sB(g[g.length-1],e.fragmentHint),e.PTSKnown=e.alignedSliding=!0,m}function sH(e,t,i,r,a){return Error(`${e} ${a.url}
2Playlist starting @${t.startSN}
3${t.m3u8}
4
5Playlist starting @${i.startSN}
6${i.m3u8}`)}function sG(e,t,i=!0,r){let a=t.startSN+t.skippedSegments-e.startSN,s=e.fragments,n=a>=0,l=0;if(n&&a<s.length)l=s[a].start,null==r||r.log(`Aligning playlists based on SN ${t.startSN} (diff: ${l})`);else if(n&&t.startSN===e.endSN+1)l=e.fragmentEnd,null==r||r.log(`Aligning playlists based on first/last SN ${t.startSN} (diff: ${l})`);else if(n&&i)l=e.fragmentStart+a*t.levelTargetDuration;else{if(t.skippedSegments||0!==t.fragmentStart)return l;l=e.fragmentStart,null==r||r.log(`Aligning playlists based on first SN ${t.startSN} (diff: ${l})`)}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,l),l}function sW(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 sK(e,t,i){var r;if(!e)return null;let a=e.fragments[t-e.startSN];return a||(null==(r=a=e.fragmentHint)?void 0:r.sn)===t?a:i&&t<e.startSN&&i.sn===t?i:null}function sV(e,t,i){return e?sq(e.partList,t,i):null}function sq(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 sj(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 sY(e){return e.replace(/\?[^?]*$/,"")}function sz(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 sQ(e,t){let i=e.start+t;e.setStart(i)}function sX(e,t){let i=t.fragments;for(let t=0,r=i.length;t<r;t++)sQ(i[t],e);t.fragmentHint&&sQ(t.fragmentHint,e),t.alignedSliding=!0}function sZ(e,t,i){e&&(function(e,t,i){if((!t||!(e.startCC<t.endCC)||!(e.endCC>t.startCC))&&1)return;let r=Math.min(t.endCC,e.endCC),a=sz(t.fragments,r),s=sz(e.fragments,r);if(!a||!s)return;let n=a.start-s.start;i.log(`Aligning playlists using dicontinuity sequence ${r} (diff: ${n})`),sX(n,e)}(t,e,i),t.alignedSliding||function(e,t,i){let r,a;
6if(!e.hasProgramDateTime||!t.hasProgramDateTime)return;let s=e.fragments,n=t.fragments;if(!s.length||!n.length)return;let l=Math.min(t.endCC,e.endCC);t.startCC<l&&e.startCC<l&&(r=sz(n,l),a=sz(s,l)),r&&a||(a=sz(s,(r=n[Math.floor(n.length/2)]||n.filter(e=>!!e)[0]).cc)||s[Math.floor(s.length/2)]);let o=r.programDateTime,d=a.programDateTime;if(!o||!d)return;let h=(d-o)/1e3;if(Math.abs(h)>Math.max(60,e.totalduration))return i.log(`Cannot align playlists using PDT without overlap (${Math.abs(h)} > ${e.totalduration})`);let u=h-(a.start-r.start);i.log(`Aligning playlists using PDT (diff: ${u})`),sX(u,e)}(t,e,i),t.alignedSliding||t.skippedSegments||sG(e,t,!1,i))}function sJ(e,t,i){s0(e,t,i),e.addEventListener(t,i)}function s0(e,t,i){e.removeEventListener(t,i)}function s1(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}let s2="STOPPED",s3="IDLE",s4="KEY_LOADING",s5="FRAG_LOADING",s8="FRAG_LOADING_WAITING_RETRY",s6="WAITING_TRACK",s9="PARSING",s7="PARSED",ne="ENDED",nt="ERROR",ni="WAITING_INIT_PTS",nr="WAITING_LEVEL";class na extends aY{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=s2,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,s=i?i.currentTime:0,n=aZ.bufferInfo(r||i,s,e.maxBufferHole),l=n.len;if(this.log(`Media seeking to ${s}, state: ${a}, ${!l?"out of":"in"} buffer`),this.state===ne)this.resetLoadingState();else if(t){let i=e.maxFragLookUpTolerance,r=t.start-i,a=t.start+t.duration+i;if(!l||a<n.start||r>n.end){let e=s<r,i=s>a;(e||i)&&(t.loader&&(i||!this.isFragmentNearlyDownloaded(t))?(this.log(`Cancelling fragment load for seek (sn: ${t.sn}) - ${e?"backward":"forward"} seek`),t.abortRequests(),this.resetLoadingState()):this.fragPrevious=null)}}if(i&&(this.fragmentTracker.removeFragmentsInRange(s,1/0,this.playlistType,!0),s>this.lastCurrentTime&&(this.lastCurrentTime=s),!this.loadingParts)){let e=Math.max(n.end,s),t=this.shouldLoadParts(this.getLevelDetails(),e);t&&(this.log(`LL-Part loading ON after seeking to ${s} with buffer @${e}`),this.loadingParts=t)}let o=!aZ.isBuffered(i,s);(!this.hls.hasEnoughToStart||o)&&(this.log(`Setting ${o?"startPosition":"nextLoadPosition"} to ${s} for seek without enough to start`),this.nextLoadPosition=s,o&&(this.startPosition=s)),l<1&&this.state===s3&&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 aW(e.config),this.initFragmentLoader=new aW(e.config),this.keyLoader=i,this.fragmentTracker=t,this.config=e.config,this.decrypter=new aG(e.config)}registerListeners(){let{hls:e}=this;
6e.on(tz.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(tz.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(tz.MANIFEST_LOADING,this.onManifestLoading,this),e.on(tz.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(tz.ERROR,this.onError,this)}unregisterListeners(){let{hls:e}=this;e.off(tz.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(tz.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(tz.MANIFEST_LOADING,this.onManifestLoading,this),e.off(tz.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(tz.ERROR,this.onError,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){if(this.state===s2)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=s2}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=aZ.bufferedInfo(a,e.start,0));let s=e.nextStart;if(s&&s>r&&s<t.edge||this.media.currentTime<e.start)return!1;let n=t.partList;if(null!=n&&n.length){let e=n[n.length-1];return aZ.isBuffered(this.media,e.start+e.duration/2)}let l=t.fragments[t.fragments.length-1];return this.fragmentTracker.isEndListAppended(l.type)}getLevelDetails(){if(this.levels&&null!==this.levelLastLoaded)return this.levelLastLoaded.details}get timelineOffset(){let e=this.config.timelineOffset;if(e){var t;return(null==(t=this.getLevelDetails())?void 0:t.appliedTimelineOffset)||e}return 0}onMediaAttached(e,t){let i=this.media=this.mediaBuffer=t.media;sJ(i,"seeking",this.onMediaSeeking),sJ(i,"ended",this.onMediaEnded);let r=this.config;this.levels&&r.autoStartLoad&&this.state===s2&&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),s0(r,"seeking",this.onMediaSeeking),s0(r,"ended",this.onMediaEnded),this.media=this.mediaBuffer=null,this.loopSn=void 0,i){this.resetLoadingState(),this.resetTransmuxer();return}this.loadingParts=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}}onManifestLoading(){this.initPTS=[],this.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=s2,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){let r=e=>{let t=e.frag;if(this.fragContextChanged(t)){this.warn(`${t.type} sn: ${t.sn}${e.part?" part: "+e.part.index:""} of ${this.fragInfo(t,!1,e.part)} was dropped during download.`),this.fragmentTracker.removeFragment(t);return}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)};this._doFragLoad(e,t,i,r).then(e=>{if(!e)return;let t=this.state,i=e.frag;if(this.fragContextChanged(i)){t!==s5&&(this.fragCurrent||t!==s9)||(this.fragmentTracker.removeFragment(i),this.state=s3);return}"payload"in e&&(this.log(`Loaded ${i.type} sn: ${i.sn} of ${this.playlistLabel()} ${i.level} (bytes ${i.stats.loaded})`),this.hls.trigger(tz.FRAG_LOADED,e)),this._handleFragmentLoadComplete(e)}).catch(t=>{this.state!==s2&&this.state!==nt&&(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)===ax){let t=e.type,r=this.getFwdBufferInfo(this.mediaBuffer,t),a=Math.max(e.duration,r?r.len:this.config.maxBufferLength),s=this.backtrackFragment;(1==(s?e.sn-s.sn:0)||this.reduceMaxBufferLength(a,e.duration))&&i.removeFragment(e)}else(null==(t=this.mediaBuffer)?void 0:t.buffered.length)===0?i.removeAllFragments():i.hasParts(e.type)&&(i.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),i.getState(e)===aP&&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){e-t&&this.hls.trigger(tz.BUFFER_FLUSHING,{startOffset:e,endOffset:t,type:i})}_loadInitSegment(e){let{hls:t}=this;return this.initFragmentLoader.abort(),t.trigger(tz.FRAG_LOADING,{frag:e,targetBufferTime:0}),this.initFragmentLoader.load(e).then(e=>{var t;let i=e.frag;if(!this.levels||!t6(i,null==(t=this.fragCurrent)?void 0:t.initSegment))throw new aj({type:tj.NETWORK_E
6RROR,details:tY.INTERNAL_ABORTED,error: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&&se(a.method)){let s=self.performance.now(),{decryptRange:n}=aV(i,null,this.iframesOnly);return this.decrypter.decrypt(new Uint8Array(r),a.key.buffer,a.iv.buffer,st(a.method),n).catch(e=>{throw t.trigger(tz.ERROR,{type:tj.MEDIA_ERROR,details:tY.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(tz.FRAG_DECRYPTED,{frag:i,part:null,payload:r,stats:{tstart:s,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;if(!this.bitrateTest&&t5(e)&&t&&!t.data){var i;return(t.encrypted&&!(null!=(i=t.decryptdata)&&i.key)?this.keyLoader.load(t).then(()=>this._loadInitSegment(t)):this._loadInitSegment(t)).catch(t=>{if(this.state===s2||this.state===nt)throw t;throw"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=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(tz.ERROR,{type:tj.KEY_SYSTEM_ERROR,details:tY.KEY_SYSTEM_NO_KEYS,fatal:!1,error:i,frag:t}),this.resetTransmuxer(),!0)}return!1}fragContextChanged(e){let{fragCurrent:t}=this;return!e||!t6(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?s1(aZ.getBuffered(i)):"(detached)"})`),t5(e)){var r;if(e.type!==t0.SUBTITLE){let t=e.elementaryStreams;if(!Object.keys(t).some(e=>!!t[e])){this.state=s3;return}}let i=null==(r=this.levels)?void 0:r[e.level];null!=i&&i.fragmentError&&(t||this.fragmentTracker.getState(e)!==aP)&&(this.log(`Resetting level fragment error count of ${i.fragmentError} on frag buffered`),i.fragmentError=0,e.stats.retry=0)}this.state=s3}_handleFragmentLoadComplete(e){let{transmuxer:t}=this;if(!t)return;let i=e.frag,{part:r,partsLoaded:a}=e,s=!a||0===a.length||a.some(e=>!e),{decryptRange:n}=aV(i,r),l=new az(i.level,i.sn,i.stats.chunkCount+1,0,r?r.index:-1,!s,i.duration,this.iframesOnly,n);this.log(`load complete ${i.type} sn: ${i.sn}${r?" part: "+r.index:""} of ${this.fragInfo(i,!1,r)}`),t.flush(l)}_handleFragmentLoadProgress(e){}loadKeyFor(e,t,i){var r;let a=null;return e.encrypted&&!(null!=(r=e.decryptdata)&&r.key)?(this.log(`Loading key for ${e.sn} of [${t.startSN}-${t.endSN}], ${this.playlistLabel()} ${e.level}`),this.state=s4,a=this.keyLoader.load(e,i).then(e=>{if(!this.fragContextChanged(e.frag))return this.hls.trigger(tz.KEY_LOADED,e),this.state===s4&&(this.state=s3),e}),this.hls.trigger(tz.KEY_LOADING,{frag:e})):!e.encrypted&&(a=this.keyLoader.loadClear(e,t.encryptedFragments,this.startFragRequested))&&this.log(`[eme] blocking frag sn: ${e.sn} load until media-keys acquired`),a}_doFragLoad(e,t,i=null,r){var a,s;let n;this.fragCurrent=e;let l=t.details;if(!this.levels||!l)throw Error(`frag load aborted, missing level${l?"":" detail"}s`);let o=this.fragPrevious;if(!t8(e,o)){let i=this.shouldLoadParts(t.details,e.end);i!==this.loadingParts&&(this.log(`LL-Part loading ${i?"ON":"OFF"} loading sn ${null==o?void 0:o.sn}->${e.sn}`),this.loadingParts=i)}if(i=Math.max(e.start,i||0),this.loadingParts){let a=l.partList;if(a&&r){i>l.fragmentEnd&&l.fragmentHint&&(e=l.fragmentHint);let s=this.getNextPart(a,e,i);if(s>-1){let n,d=a[s];if(!t8(e=this.fragCurrent=d.fragment,o)&&!this.shouldLoadParts(t.details,e.end))return this.log(`LL-Part loading OFF @${this.playhead} next part: ${this.fragInfo(e,!1,d)}`),this.loadingParts=!1,Promise.resolve(null);if(!this.filterReplacedPrimary(d,t.details))return Promise.resolve(null);let h=this.loadKeyFor(e,l);if(this.fragContextChanged(e))return Promise.resolve(null);this.log(`Loading ${e.type} sn: ${e.sn} part: ${d.index} (${s}/${a.length-1}) of ${this.fragInfo(e,!1,d)} cc: ${e.cc} [${l.startSN}-${l.endSN}], target: ${i}${d.byteRange.length?` range:${d.byteRange.join("-")}`:""}`),this.nextLoadPosition=d.start+d.duration,this.state=s5;let u=this.loadInitSegmentIfNeeded(e);if(h||u){let i=!!h;n=Promise.all([h,u]).then(([a])=>i&&(!a||this.fragContextChanged(a.frag))?null:this.doFragPartsLoad(e,d,t,r)).catch(e=>this.handleFragLoadError(e))}else n=this.doFragPartsLoad(e,d,t,r).catch(e=>this.handleFragLoadError(e));return(this.hls.trigger(tz.FRAG_LOADING,{frag:e,part:d,targetBufferTime:i}),null===this.fragCurrent)?Promise.reject(Error("frag load aborted, context changed in FRAG_LOADING parts")):n}if(!e.url||this.loadedEndOfParts(a,i))return Promise.resolve(null)}}if(this.loadingParts)this.log(`LL-Part loading OFF after next part miss @${i} Check buffer at sn: ${e.sn} loaded parts: ${null==(a=l.partList)?void 0:a.filter(e=>e.loaded).map(e=>`[${e.start}-${e.end}]`)}`),this.loadingParts=!1;else if(!e.url)return Promise.resolve(null);if(!this.filterReplacedPrimary(e,t.details))return Promise.resolve(null);let d=this.loadInitSegmentIfNeeded(e),h=this.loadKeyFor(e,l,d);if(this.fragContextChanged(e))return this.log(`Context changed in KEY_LOADING sn: ${e.sn} ${e.relurl} > ${null==(s=this.fragCurrent)?void 0:s.relurl}`),null==d||d.catch(()=>null),null==h||h.catch(()=>null),Promise.resolve(null);this.log(`Loading ${e.type} sn: ${e.sn} of ${this.fragInfo(e,!1)} cc: ${e.cc} ${"["+l.startSN+"-"+l.endSN+"]"}, target: ${i}${e.byteRange.length?` range:${e.byteRange.join("-")}`:""}`),tK(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=s5;let u=this.config.progressive&&e.type!==t0.SUBTITLE;return(n=u&&h?h.then(t=>!t||this.fragContextChanged(t.frag)?null:this.fragmentLoader.load(e,this.iframesOnly,r,d)).catch(e=>this.handleFragLoadError(e)):Promise.all([this.fragmentLoader.load(e,this.iframesOnly,u?r:void 0,u?d:void 0),h,d]).then(([e])=>(!u&&r&&r(e),e)).catch(e=>this.handleFragLoadError(e)),this.hls.trigger(tz.FRAG_LOADING,{frag:e,targetBufferTime:i}),null===this.fragCurrent)?Promise.reject(Error("frag load aborted, context changed in FRAG_LOADING")):Promise.all([n,d]).then(([e])=>e)}doFragPartsLoad(e,t,i,r){return new Promise((a,s)=>{var n;let l=[],o=null==(n=i.details)?void 0:n.partList,d=t=>{this.fragmentLoader.loadPart(e,t,r).then(r=>{l[t.index]=r;let s=r.part;this.hls.trigger(tz.FRAG_LOADED,r);let n=sV(i.details,e.sn,t.index+1)||sq(o,e.sn,t.index+1);if(!n)return a({frag:e,part:s,partsLoaded:l});d(n)}).catch(s)};d(t)})}handleFragLoadError(e){if("data"in e){let t=e.data;t.frag&&t.details===tY.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):t.frag&&t.type===tj.KEY_SYSTEM_ERROR&&!t.fatal&&(t.frag.abortRequests(),this.resetStartWhenNotLoaded(),this.resetFragmentLoading(t.frag)),this.hls.trigger(tz.ERROR,t)}else this.hls.trigger(tz.ERROR,{type:tj.OTHER_ERROR,details:tY.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){let t=this.getCurrentContext(e);if(!t||this.state!==s9){this.fragCurrent||this.state===s2||this.state===nt||(this.state=s3);return}let{frag:i,part:r,level:a}=t,s=self.performance.now();i.stats.parsing.end=s,r&&(r.stats.parsing.end=s);let n=this.getLevelDetails(),l=n&&i.sn>n.endSN||this.shouldLoadParts(n,i.end);l!==this.loadingParts&&(this.log(`LL-Part loading ${l?"ON":"OFF"} after parsing segment ending @${i.end}`),this.loadingParts=l),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:s}=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 n=t[r],l=n.details,o=s>-1?sV(l,a,s):null,d=o?o.fragment:sK(l,a,i);return d?(i&&i!==d&&(d.stats=i.stats),{frag:d,part:o,level:n}):null}bufferFragmentData(e,t,i,r,a){if(this.state!==s9)return;t5(t)&&!this.fragContextChanged(t)&&(this.fragPrevious=t);let{data1:s,data2:n}=e,l=s;if(n&&(l=rB(s,n)),!l.length)return;let o=this.initPTS[t.cc],d=o?-o.baseTime/o.timescale:void 0,h={type:e.type,frag:t,part:i,chunkMeta:r,offset:d,parent:t.type,data:l};if(this.hls.trigger(tz.BUFFER_APPENDING,h),e.dropped&&e.independent&&!i){if(a)return;this.flushBufferGap(t)}}flushBufferGap(e){let t=this.media;if(!t)return;if(!aZ.isBuffered(t,t.currentTime))return void this.flushMainBuffer(0,e.start);let i=t.currentTime,r=aZ.bufferInfo(t,i,0),a=e.duration,s=Math.min(2*this.config.maxFragLookUpTolerance,.25*a),n=Math.max(Math.min(e.start-s,r.end-s),i+s);e.start-n>s&&this.flushMainBuffer(n,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=aZ.bufferInfo(e,t,r);if(0===a.len&&void 0!==a.nextStart){let s=this.fragmentTracker.getBufferedFrag(t,i);if(s&&(a.nextStart<=s.end||s.gap)){let i=Math.max(Math.min(a.nextStart,s.end)-t,r);return aZ.bufferInfo(e,t,i)}}return a}
6getMaxBufferLength(e){let{config:t}=this;return Math.min(e?Math.max(8*t.maxBufferSize/e,t.maxBufferLength):t.maxBufferLength,t.maxMaxBufferLength)}exceedsMaxBuffer(e,t,i){let r=e.nextStart;if(r&&i.start>r){let r=e.buffered;if(r){let a=e.len,s=e.bufferedIndex;for(let e=r.length-1;e>s;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,s=t.fragmentStart,n=a.lowLatencyMode&&!!t.partList,l=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||!n||this.loadingParts||(this.log("LL-Part loading ON for initial live fragment"),this.loadingParts=!0),!t.PTSKnown&&!this.startFragRequested&&-1===this.startPosition||e<s){var o;let i,r;l=this.getInitialLiveFragment(t);let a=this.config.startPosition,n=this.hls.startPosition,d=this.hls.liveSyncPosition,h=(null==(o=l)?void 0:o.start)||0;if(-1!==n&&n>=s?(i=n,r=n===a?"config":"next load start"):d?(i=d,r="live edge"):(i=e,r="buffer pos"),i<h&&(i=h,r="live frag start"),i<s&&(i=s,r="playlist start"),this.startPosition!=i||this.nextLoadPosition!=i){let o=t.live&&!this.filterReplacedPrimary(l,t)?-1:i;this.log(`Setting startPosition to ${o} next load ${i} ${-1===n?"":`(from ${a}) `}based on ${r}. live edge: ${d} live frag start: ${h} playlist start: ${s} buffer pos: ${e}`),this.startPosition=o,this.nextLoadPosition=i}}}else e<=s&&(l=i[0]);if(!l){let i=this.loadingParts?t.partEnd:t.fragmentEnd;l=this.getFragmentAtPosition(e,i,t)}let d=this.filterReplacedPrimary(l,t);return!d&&l&&(d=aI(t,l.sn))&&(this.nextLoadPosition=d.start),d}isLoopLoading(e,t){if(this.nextLoadPosition<=t)return!1;let i=this.fragmentTracker.getState(e);return"OK"===i||i===aP&&(!!e.gap||!!(e.stats.retry>1))||!1}getNextFragmentLoopLoading(e,t,i,r,a){let s=null;if(e.gap&&(s=this.getNextFragment(this.nextLoadPosition,t))&&!s.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=s.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,s}get primaryPrefetch(){if(nn(this.config)){var e;if(null==(e=this.hls.interstitialsManager)||null==(e=e.playingItem)?void 0:e.event)return!0}return!1}filterReplacedPrimary(e,t){if(!e)return e;if(nn(this.config)&&("type"in e?e:e.fragment).type!==t0.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&&(null==t?void 0:t.live)===!1||e.start>=r.end&&r.nextEvent&&(r.nextEvent.appendInPlace&&!r.nextEvent.hasPlayed||e.start-r.end>1))return null}if(ns(e,null==i?void 0:i.playerQueue,this.playhead))return null}return e}getNextPart(e,t,i){let r=-1,a=!1,s=!0;for(let n=0,l=e.length;n<l;n++){let l=e[n];if(s=s&&!l.independent,r>-1&&i<l.start)break;let o=l.loaded||l.gap;o?r=-1:(a||(l.independent||s)&&l.fragment===t)&&(r=n),a=o&&!l.gap}let n=e[r];return n&&n.fragment!==t&&this.log(`Need buffer at ${i} but next unloaded part starts at ${n.start} (sn: ${t.sn} -> ${n.fragment.sn})`),r}loadedEndOfParts(e,t){let i;for(let r=e.length;r--&&(i=e[r]).loaded;)if(t>i.start)return!0;return!1}getInitialLiveFragment(e){let t=e.fragments,i=this.fragPrevious,r=null;if(i){if(e.hasProgramDateTime&&(r=function(e,t,i){if(null===t||!Array.isArray(e)||!e.length||!tK(t)||t<(e[0].programDateTime||0)||t>=(e[e.length-1].endProgramDateTime||0))return null;for(let r=0;r<e.length;++r){let a=e[r];if(function(e,t,i){let r=1e3*Math.min(t,i.duration+(i.deltaPTS?i.deltaPTS:0));return(i.endProgramDateTime||0)-r>e}(t,i,a))return a}return null}(t,i.endProgramDateTime,this.config.maxFragLookUpTolerance))&&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 s=t[a-e.startSN];i.cc===s.cc&&(r=s,this.log(`Live playlist, switching playlist, load frag with next SN: ${r.sn}`))}!r&&(r=aL(e,i.cc,i.end))&&this.log(`Live playlist, switching playlist, load frag with same CC: ${r.sn}`)}}else{let t=this.hls.liveSyncPosition;null!==t&&(r=this.getFragmentAtPosition(t,this.bitrateTest?e.fragmentEnd:e.edge,e))}return r}getFragmentAtPosition(e,t,i){let r,{config:a}=this,{fragPrevious:s}=this,{fragments:n,endSN:l}=i,{fragmentHint:o}=i,{maxFragLookUpTolerance:d}=a,h=i.partList,u=!!(this.loadingParts&&null!=h&&h.length&&o);if(u&&!this.bitrateTest&&h[h.length-1].fragment.sn===o.sn&&(n=n.concat(o),l=o.sn),s&&this.fragmentTracker.getState(s)===aM&&(s=null),e<t){var c;let i=e<this.lastCurrentTime||e>t-d||null!=(c=this.media)&&c.paused||!this.startFragRequested?0:d;r=ak(s,n,e,i)}else r=n[n.length-1];if(r){let e=r.sn-i.startSN,t=this.fragmentTracker.getState(r);
6if(("OK"===t||t===aP&&r.gap)&&(s=r),t8(r,s)&&(!u||h[0].fragment.sn>r.sn||!i.live)){let t=n[e+1];r=r.sn<l&&"OK"!==this.fragmentTracker.getState(t)?t:null}}return r}alignPlaylists(e,t,i){let r=e.fragments.length;if(!r)return this.warn("No fragments in live playlist"),0;let a=e.fragmentStart,s=!t,n=e.alignedSliding&&tK(a);if(s||!n&&!a){sZ(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,s=a?this.startTimeOffset:e.startTimeOffset;if(null!==s&&tK(s))i=t+s,s<0&&(i+=e.edge),i=Math.min(Math.max(t,i),t+e.totalduration),this.log(`Setting startPosition to ${i} for start time offset ${s} 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,t;if(null!=(e=this.hls)&&e.hasEnoughToStart){let e=null==(t=this.media)?void 0:t.currentTime;return tK(e)?e:this.lastCurrentTime}return this.getLoadPosition()}get iframesOnly(){var e;if(this.playlistType!==t0.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&&t5(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===s8)||(this.state=s3)}onFragmentOrKeyLoadError(e,t){var i,r;if(t.chunkMeta&&!t.frag){let e=this.getCurrentContext(t.chunkMeta);e&&(t.frag=e.frag)}let{frag:a,part:s}=t;if(!a||!this.levels||a.type!==e)return;if(this.fragContextChanged(a))return void this.warn(`Frag load error must match current frag to retry ${a.relurl} > ${null==(i=this.fragCurrent)?void 0:i.relurl}`);let n=t.details===tY.FRAG_GAP;n&&this.fragmentTracker.addAsGap(a);let l=t.errorAction;if(!l){this.state=nt;return}let{action:o,flags:d,retryCount:h=0,retryConfig:u}=l,c=!!u,m=c&&5===o,f=c&&!l.resolved&&1&d,p=this.hls.latestLevelDetails,g=null==p?void 0:p.live;if(!m&&f&&t5(a)&&g&&a.sn<p.endSN&&!il(t))this.resetFragmentErrors(e),s?s.gap=!0:this.treatAsGap(a),l.resolved=!0;else if((m||f)&&h<u.maxNumRetry){let i=ic(null==(r=t.response)?void 0:r.code),s=id(u,h);if(this.resetStartWhenNotLoaded(),this.retryDate=self.performance.now()+s,this.state=s8,l.resolved=!0,i){this.log("Waiting for connection (offline)"),this.retryDate=1/0,t.reason="offline";return}this.warn(`Fragment ${a.sn} of ${e} ${a.level} errored with ${t.details}, retrying loading ${h+1}/${u.maxNumRetry} in ${s}ms`)}else if(u){if(this.resetFragmentErrors(e),!(h<u.maxNumRetry))return void this.warn(`${t.details} reached or exceeded max retry (${h})`);n||3===o||(l.resolved=!0)}else 2===o?this.state=nr:this.state=nt;this.tickImmediate()}checkRetryDate(){let e=self.performance.now(),t=this.retryDate,i=t===1/0;(!t||e>=t||i&&!ic(0))&&(i&&this.log("Connection restored (online)"),this.resetStartWhenNotLoaded(),this.state=s3)}reduceLengthAndFlushBuffer(e){if(this.state===s9||this.state===s7){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 s=!a;return s?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,1/0,i===t0.AUDIO?i:void 0),t&&(this.fragmentTracker.removeFragment(t),this.nextLoadPosition=t.start),this.resetLoadingState(),s}return!1}resetFragmentErrors(e){e===t0.AUDIO&&(this.fragCurrent=null),this.hls.hasEnoughToStart||(this.startFragRequested=!1),this.state!==s2&&(this.state=s3)}afterBufferFlushed(e,t){if(!e)return;let i=aZ.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,i,this.playlistType),this.state===ne&&this.resetLoadingState()}
6resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==s2&&(this.state=s3)}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)return void this.warn("level.details undefined");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,s)=>{let n=e.elementaryStreams[s];if(n){let l=n.endPTS-n.startPTS;if(l<=0)return this.warn(`Could not parse fragment ${e.sn} ${s} duration reliably (${l})`),t||!1;let o=r.partial?0:s$(a,e,n.startPTS,n.endPTS,n.startDTS,n.endDTS,this.iframesOnly,this);return this.hls.trigger(tz.LEVEL_PTS_UPDATED,{details:a,level:i,drift:
6o,type:s,frag:e,start:n.startPTS,end:n.endPTS}),!0}return t},!1)){var s,n,l,o;let r=(null==(s=this.transmuxer)?void 0:s.error)===null,a=(null==(n=this.transmuxer)?void 0:n.error)!=null,d=(null!=(l=null==(o=this.levels)?void 0:o.length)?l:0)>1;if((0===i.fragmentError||r&&(i.fragmentError<2||e.endList)||a&&d)&&this.treatAsGap(e,i),r){let r=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(tz.ERROR,{type:tj.MEDIA_ERROR,details:tY.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=s7,this.log(`Parsed ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,!1,t)}`),this.hls.trigger(tz.FRAG_PARSED,{frag:e,part:t,chunkMeta:r})}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:s,levels:n,playlistType:l}=this,o=this.getLevelDetails();if(a&&!a.paused&&n){var d;let t=l===t0.AUDIO?aa(e.audioCodec,128e3):e.maxBitrate,a=1+r.ttfbEstimate/1e3,n=r.bandwidthEstimate*s.abrBandWidthUpFactor;i=a+t*(o&&(this.loadingParts?o.partTarget:o.averagetargetduration)||(null==(d=this.fragCurrent)?void 0:d.duration)||6)/n,e.details||(i+=a)}let h=this.playhead,u=!(null!=o&&o.live)||t.end-h>1.5*i;return{fetchdelay:i,okToFlushForwardBuffer:u}}scheduleTrackSwitch(e,t,i){let{media:r,playlistType:a}=this;if(!r||!e)return;let s=i?this.getBufferedFrag(this.playhead+t):null;if(s){let e=this.followingBufferedFrag(s);if(e){var n;this.abortCurrentFrag();let t=e.maxStartPTS?e.maxStartPTS:e.start,i=e.duration,r=Math.max(s.end,t+Math.min(Math.max(i-this.config.maxFragLookUpTolerance,i*(this.couldBacktrack?.5:.125)),i*(this.couldBacktrack?.75:.25)));if(((null==(n=this.getLevelDetails())?void 0:n.fragmentStart)||0)>r)return;let l=a===t0.MAIN?null:"audio";this.flushMainBuffer(r,1/0,l),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===t0.AUDIO;this.flushMainBuffer(0,i.start-!e,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 s4:case s5:case s8:case s9:case s7:this.state=s3}this.nextLoadPosition=this.playhead}checkFragPlaying(){let e=this.media,t=null;if(e&&e.readyState>1&&!1===e.seeking){let i=e.currentTime;if(aZ.isBuffered(e,i)?t=this.getAppendedFrag(i):aZ.isBuffered(e,i+.1)&&(t=this.getAppendedFrag(i+.1)),t&&(this.backtrackFragment=void 0,!t8(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 s=e[a===t0.AUDIO?i.nextAudioTrack:i.nextLoadLevel],{fetchdelay:n,okToFlushForwardBuffer:l}=this.calculateOptimalSwitchPoint(s,r);this.scheduleTrackSwitch(r,n,l)}this.tickImmediate()}}function ns(e,t,i){if(t)for(let r=t.length;r--;){let a=t[r].interstitial,s=a.startTime,n=Math.min(s+a.duration,a.resumeTime);if(a.appendInPlace&&(e.start>=s&&e.end<=n||i>e.start&&e.end>s&&e.start<n))return!0}return!1}function nn(e){return!!e.interstitialsController&&!1!==e.enableInterstitialPlayback}class nl{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={exports:{}},nd=(h4||(h4=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 s(e,t,r,s,n){if("function"!=typeof r)throw TypeError("The listener must be a function");var l=new a(r,s||e,n),o=i?i+t:t;return e._events[o]?e._events[o].fn?e._events[o]=[e._events[o],l]:e._events[o].push(l):(e._events[o]=l,e._eventsCount++),e}function n(e,t){0==--e._eventsCount?e._events=new r:delete e._events[t]}function l(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(i=!1)),l.prototype.eventNames=function(){var e,r,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},l.prototype.listeners=function(e){var t=i?i+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var a=0,s=r.length,n=Array(s);a<s;a++)n[a]=r[a].fn;return n},l.prototype.listenerCount=function(e){var t=i?i+e:e,r=this._events[t];return r?r.fn?1:r.length:0},l.prototype.emit=function(e,t,r,a,s,n){var l=i?i+e:e;if(!this._events[l])return!1;var o,d,h=this._events[l],u=arguments.length;if(h.fn){switch(h.once&&this.removeListener(e,h.fn,void 0,!0),u){case 1:return h.fn.call(h.context),!0;case 2:return h.fn.call(h.context,t),!0;case 3:return h.fn.call(h.context,t,r),!0;case 4:return h.fn.call(h.context,t,r,a),!0;case 5:return h.fn.call(h.context,t,r,a,s),!0;case 6:return h.fn.call(h.context,t,r,a,s,n),!0}for(d=1,o=Array(u-1);d<u;d++)o[d-1]=arguments[d];h.fn.apply(h.context,o)}else{var c,m=h.length;for(d=0;d<m;d++)switch(h[d].once&&this.removeListener(e,h[d].fn,void 0,!0),u){case 1:h[d].fn.call(h[d].context);break;case 2:h[d].fn.call(h[d].context,t);break;case 3:h[d].fn.call(h[d].context,t,r);break;case 4:h[d].fn.call(h[d].context,t,r,a);break;default:if(!o)for(c=1,o=Array(u-1);c<u;c++)o[c-1]=arguments[c];h[d].fn.apply(h[d].context,o)}}return!0},l.prototype.on=function(e,t,i){return s(this,e,t,i,!1)},l.prototype.once=function(e,t,i){return s(this,e,t,i,!0)},l.prototype.removeListener=function(e,t,r,a){var s=i?i+e:e;if(!this._events[s])return this;if(!t)return n(this,s),this;var l=this._events[s];if(l.fn)l.fn!==t||a&&!l.once||r&&l.context!==r||n(this,s);else{for(var o=0,d=[],h=l.length;o<h;o++)(l[o].fn!==t||a&&!l[o].once||r&&l[o].context!==r)&&d.push(l[o]);d.length?this._events[s]=1===d.length?d[0]:d:n(this,s)}return this},l.prototype.removeAllListeners=function(e){var t;return e?(t=i?i+e:e,this._events[t]&&n(this,t)):(this._events=new r,this._eventsCount=0),this},l.prototype.off=l.prototype.removeListener,l.prototype.addListener=l.prototype.on,l.prefixed=i,l.EventEmitter=l,e.exports=l}
6(no)),(h0=no.exports)&&h0.__esModule&&Object.prototype.hasOwnProperty.call(h0,"default"))?h0.default:h0;let nh="1.7.3",nu={};function nc(e,t){return 255===e[t]&&(246&e[t+1])==240}function nm(e,t){return 1&e[t+1]?7:9}function nf(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function np(e,t){return t+1<e.length&&nc(e,t)}function ng(e,t,i,r,a){if(!e.samplerate){let s=function(e,t,i,r){let a,s=t[i+2],n=s>>2&15;if(n>12){let t=Error(`invalid ADTS sampling index:${n}`);e.emit(tz.ERROR,tz.ERROR,{type:tj.MEDIA_ERROR,details:tY.FRAG_PARSING_ERROR,fatal:!0,error:t,reason:t.message});return}let l=(s>>6&3)+1,o=t[i+3]>>6&3|(1&s)<<2,d=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350][n],h=n;(5===l||29===l)&&(h-=3);let u=(14&h)>>1,c=(1&h)<<7|o<<3,m=0;if(1===l&&n>=6){let e=n-3;a=[(m=5)<<3|u,c|(14&e)>>1,(1&e)<<7|8,0]}else a=[l<<3|u,c];let f="mp4a.40."+(m||l);return iA.log(`manifest codec:${r}, parsed codec:${f}, channels:${o}, rate:${d} (ADTS object type:${l} sampling index:${n} esds config:[${a.join(",")}])`),{config:a,samplerate:d,channelCount:o,codec:f,parsedCodec:f,manifestCodec:r}}(t,i,r,a);s&&ie(e,s)}}function nv(e,t,i,r,a){let s,n=r+a*(9216e4/e.samplerate),l=function(e,t){let i=nm(e,t);if(t+i<=e.length){let r=nf(e,t)-i;if(r>0)return{headerLength:i,frameLength:r}}}(t,i);if(l){let{frameLength:r,headerLength:a}=l,o=a+r,d=Math.max(0,i+o-t.length);d?(s=new Uint8Array(o-a)).set(t.subarray(i+a,t.length),0):s=t.subarray(i+a,i+o);let h={unit:s,pts:n};return d||e.samples.push(h),{sample:h,length:o,missing:d}}let o=t.length-i;return(s=new Uint8Array(o)).set(t.subarray(i,t.length),0),{sample:{unit:s,pts:n},length:o,missing:-1}}let nE=((h1={}).audioId3="org.id3",h1.dateRange="com.apple.quicktime.HLS",h1.emsg="https://aomedia.org/emsg/ID3",h1.misbklv="urn:misb:KLV:bin:1910.1",h1);function ny(e="",t=9e4){return{type:e,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}class nb{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(e,t,i,r){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(e){this.initPTS=e,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(e,t){return!1}appendFrame(e,t,i){}demux(e,t){let i;this.cachedData&&(e=rB(this.cachedData,e),this.cachedData=null);let r=ix(e,0),a=r?r.length:0,s=this._audioTrack,n=this._id3Track,l=r?iF(r):void 0,o=e.length;for((null===this.basePTS||0===this.frameIndex&&tK(l))&&(this.basePTS=nT(l,t,this.initPTS),this.lastPTS=this.basePTS),null===this.lastPTS&&(this.lastPTS=this.basePTS),r&&r.length>0&&n.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:nE.audioId3,duration:1/0});a<o;){if(this.canParse(e,a)){let t=this.appendFrame(s,e,a);t?(this.frameIndex++,this.lastPTS=t.sample.pts,a+=t.length,i=a):a=o}else{var d,h;iD(d=e,h=a)&&iC(d,h+6)+10<=d.length-h?(r=ix(e,a),n.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:nE.audioId3,duration:1/0}),a+=r.length,i=a):a++}if(a===o&&i!==o){let t=e.slice(i);this.cachedData?this.cachedData=rB(this.cachedData,t):this.cachedData=t}}return{audioTrack:s,videoTrack:ny(),id3Track:n,textTrack:ny()}}demuxSampleAes(e,t,i){return Promise.reject(Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(e){let t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:ny(),id3Track:this._id3Track,textTrack:ny()}}destroy(){this.cachedData=null,this._audioTrack=this._id3Track=void 0}}let nT=(e,t,i)=>tK(e)?90*e:9e4*t+(i?9e4*i.baseTime/i.timescale:0),nA=[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],n_=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],nS=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],nk=[0,1,1,4];function nR(e,t,i,r,a){if(i+24>t.length)return;let s=nL(t,i);if(s&&i+s.frameLength<=t.length){let n=r+a*(9e4*s.samplesPerFrame/s.sampleRate),l={unit:t.subarray(i,i+s.frameLength),pts:n,dts:n};return e.config=[],e.channelCount=s.channelCount,e.samplerate=s.sampleRate,e.samples.push(l),{sample:l,length:s.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,s=e[t+2]>>2&3;if(1!==i&&0!==a&&15!==a&&3!==s){let n=e[t+2]>>1&1,l=e[t+3]>>6,o=1e3*nA[14*(3===i?3-r:3===r?3:4)+a-1],d=n_[3*(3===i?0:2===i?1:2)+s
6],h=nS[i][r],u=nk[r],c=Math.floor(h*o/d+n)*u,m=rY();return m&&m<=87&&2===r&&o>=224e3&&0===l&&(e[t+3]=128|e[t+3]),{sampleRate:d,channelCount:3===l?1:2,frameLength:c,samplesPerFrame:8*h*u}}}function nI(e,t){return 255===e[t]&&(224&e[t+1])==224&&(6&e[t+1])!=0}function nw(e,t){return t+1<e.length&&nI(e,t)}function nD(e,t){if(t+1<e.length&&nI(e,t)){let i=nL(e,t),r=4;null!=i&&i.frameLength&&(r=i.frameLength);let a=t+r;return a===e.length||nw(e,a)}return!1}class nC{constructor(e,t,i){this.keyData=void 0,this.decrypter=void 0,this.keyData=i,this.decrypter=new aG(t,!0)}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer,0,{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),s=a.buffer.slice(a.byteOffset,a.byteOffset+a.length);this.decryptBuffer(s).then(a=>{let s=new Uint8Array(a);r.set(s,16),this.decrypter.isSync()||this.decryptAacSamples(e,t+1,i)}).catch(i)}decryptAacSamples(e,t,i){for(;;t++){if(t>=e.length)return void i();if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,i),!this.decrypter.isSync()))return}}getAvcEncryptedData(e){let t=new Int8Array(16*Math.floor((e.length-48)/160)+16),i=0;for(let r=32;r<e.length-16;r+=160,i+=16)t.set(e.subarray(r,r+16),i);return t}getAvcDecryptedUnit(e,t){let i=new Uint8Array(t),r=0;for(let t=32;t<e.length-16;t+=160,r+=16)e.set(i.subarray(r,r+16),t);return e}decryptAvcSample(e,t,i,r,a){let s=rW(a.data),n=this.getAvcEncryptedData(s);this.decryptBuffer(n.buffer).then(n=>{a.data=this.getAvcDecryptedUnit(s,n),this.decrypter.isSync()||this.decryptAvcSamples(e,t,i+1,r)}).catch(r)}decryptAvcSamples(e,t,i,r){if(e instanceof Uint8Array)throw Error("Cannot decrypt samples of type Uint8Array");for(;;t++,i=0){if(t>=e.length)return void r();let a=e[t].units;for(;!(i>=a.length);i++){let s=a[i];if(!(s.data.length<=48)&&(1===s.type||5===s.type)&&(this.decryptAvcSample(e,t,i,r,s),!this.decrypter.isSync()))return}}}}let nM=(e,t)=>{let i=0,r=5;t+=5;let a=new Uint32Array(1),s=new Uint32Array(1),n=new Uint8Array(1);for(;r>0;){n[0]=e[t];let l=Math.min(r,8),o=8-l;s[0]=0xff000000>>>24+o<<o,a[0]=(n[0]&s[0])>>o,i=i?i<<l|a[0]:a[0],t+=1,r-=l}return i};function nx(e,t,i,r,a){if(i+8>t.length||11!==t[i]||119!==t[i+1])return -1;let s=t[i+4]>>6;if(s>=3)return -1;let n=[48e3,44100,32e3][s],l=63&t[i+4],o=2*[64,69,96,64,70,96,80,87,120,80,88,120,96,104,144,96,105,144,112,121,168,112,122,168,128,139,192,128,140,192,160,174,240,160,175,240,192,208,288,192,209,288,224,243,336,224,244,336,256,278,384,256,279,384,320,348,480,320,349,480,384,417,576,384,418,576,448,487,672,448,488,672,512,557,768,512,558,768,640,696,960,640,697,960,768,835,1152,768,836,1152,896,975,1344,896,976,1344,1024,1114,1536,1024,1115,1536,1152,1253,1728,1152,1254,1728,1280,1393,1920,1280,1394,1920][3*l+s];if(i+o>t.length)return -1;let d=t[i+6]>>5,h=0;2===d?h+=2:(1&d&&1!==d&&(h+=2),4&d&&(h+=2));let u=(t[i+6]<<8|t[i+7])>>12-h&1,c=[2,1,2,3,3,4,4,5][d]+u,m=t[i+5]>>3,f=7&t[i+5],p=new Uint8Array([s<<6|m<<1|f>>2,(3&f)<<6|d<<3|u<<2|l>>4,l<<4&224]),g=t.subarray(i,i+o);return e.config=p,e.channelCount=c,e.samplerate=n,e.samples.push({unit:g,pts:r+1536/n*9e4*a}),o}let nP=/\/emsg[-/]ID3/i;function nO(e,t){return tK(e.presentationTime)?e.presentationTime/e.timeScale:t+e.presentationTimeDelta/e.timeScale}class nN{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,s=-1===a?0:a,n=[],l=0,o=0,d=-1,h=0;for(-1===a&&(d=0,h=this.getNALuType(t,0),o=1);o<r;){let i=t.indexOf(1,o);if(-1===i)break;o=i+1;let a=i;for(;a>0&&0===t[a-1];)a--;if(!(i-a+(0===a?s:0)<2)){if(d>=0)n.push({data:t.subarray(d,a),type:h});else{let i=this.getLastNalUnit(e.samples);i&&(a>0?i.data=rB(i.data,t.subarray(0,a)):s>0&&(i.data=i.data.subarray(0,i.data.byteLength-s)),i.state=0)}if(o<r)d=o,h=this.getNALuType(t,o);else{l=-1,d=-1;break}}}if(-1!==l){let e=r;
6for(;e>0&&0===t[e-1];)e--;l=r-e+(0===e?s:0)}if(d>=0)n.push({data:t.subarray(d),type:h,state:l});else if(0===n.length&&-1!==l){let i=this.getLastNalUnit(e.samples);i&&(i.data=rB(i.data,t),i.state=l)}return e.naluState=l,n}}class nU{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 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||(e-=this.bitsAvailable,t=e>>3,e-=t<<3,this.bytesAvailable-=t,this.loadWord()),this.word<<=e,this.bitsAvailable-=e}readBits(e){let t=Math.min(this.bitsAvailable,e),i=this.word>>>32-t;if(e>32&&iA.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else if(this.bytesAvailable>0)this.loadWord();else throw Error("no bits available");return(t=e-t)>0&&this.bitsAvailable?i<<t|this.readBits(t):i}skipLZ(){let e;for(e=0;e<this.bitsAvailable;++e)if((this.word&0x80000000>>>e)!=0)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){let e=this.skipLZ();return this.readBits(e+1)-1}readEG(){let e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}readBoolean(){return 1===this.readBits(1)}readUByte(){return this.readBits(8)}}class nF extends nN{parsePES(e,t,i,r,a){let s,n=a.iframe,l=this.parseNALu(e,i.data,r),o=this.VideoSample,d=!1;i.data=null,o&&l.length&&!e.audFound&&(this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts)),l.forEach(r=>{var a,l,h,u,c;switch(r.type){case 1:{if(n)break;let t=!1;s=!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)}t&&null!=(h=o)&&h.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null),o||(o=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),o.frame=!0,o.key=t;break}case 5:s=!0,null!=(a=o)&&a.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null),o||(o=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),o.key=!0,o.frame=!0;break;case 6:if(n)break;s=!0,rG(r.data,1,i.pts,t.samples);break;case 7:{s=!0,d=!0;let t=r.data,i=this.readSPS(t);if(!e.sps||e.width!==i.width||e.height!==i.height||(null==(u=e.pixelRatio)?void 0:u[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:s=!0,e.pps=[r.data];break;case 9:s=!0,e.audFound=!0,null!=(l=o)&&l.frame&&(this.pushAccessUnit(o,e),o=null),o||(o=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts));break;case 12:s=!0;break;default:s=!1}o&&s&&o.units.push(r)}),r&&o&&(this.pushAccessUnit(o,e),this.VideoSample=null)}getNALuType(e,t){return 31&e[t]}readSliceType(e){let t=new nU(e);return t.readUByte(),t.readUEG(),t.readUEG()}skipScalingList(e,t){let i=8,r=8;for(let a=0;a<e;a++)0!==r&&(r=(i+t.readEG()+256)%256),i=0===r?i:r}readSPS(e){let t,i,r,a=new nU(e),s=0,n=0,l=0,o=0,d=a.readUByte.bind(a),h=a.readBits.bind(a),u=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(h(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=u();if(3===e&&m(1),p(),p(),m(1),c())for(r=0,i=3!==e?8:12;r<i;r++)c()&&g(r<6?16:64,a)}p();let E=u();if(0===E)u();else if(1===E)for(m(1),f(),f(),t=u(),r=0;r<t;r++)f();p(),m(1);let y=u(),b=u(),T=h(1);0===T&&m(1),m(1),c()&&(s=u(),n=u(),l=u(),o=u());let A=[1,1];if(c()&&c())switch(d()){case 1:A=[1,1];break;case 2:A=[12,11];break;case 3:A=[10,11];break;case 4:A=[16,11];break;case 5:A=[40,33];break;case 6:A=[24,11];break;case 7:A=[20,11];break;case 8:A=[32,11];break;case 9:A=[80,33];break;case 10:A=[18,11];break;case 11:A=[15,11];break;case 12:A=[64,33];break;case 13:A=[160,99];break;case 14:A=[4,3];break;case 15:A=[3,2];break;case 16:A=[2,1];break;case 255:A=[d()<<8|d(),d()<<8|d()]}return{width:Math.ceil((y+1)*16-2*s-2*n),height:(2-T)*(b+1)*16-(T?2:4)*(l+o),pixelRatio:A}}}class nB extends nN{constructor(...e){super(...e),this.initVPS=null}parsePES(e,t,i,r){let a,s=this.parseNALu(e,i.data,r),n=this.VideoSample,l=!1;i.data=null;let o=e=>n=this.VideoSample=this.createVideoSample(e,i.pts,i.dts);
6s.forEach((r,s)=>{var d,h,u;switch(this.startsNewAccessUnit(n,e,r,s)&&(this.pushAccessUnit(n,e),n=o(r.type>=16&&r.type<=23),l=!1),r.type){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:n||(n=o(!1)),n.frame=!0,a=!0;break;case 16:case 17:case 18:case 21:case 22:case 23:a=!0,l&&null!=(u=n)&&u.frame&&!n.key&&(this.pushAccessUnit(n,e),n=this.VideoSample=null),n||(n=o(!0)),n.key=!0,n.frame=!0;break;case 19:case 20:a=!0,null!=(d=n)&&d.frame&&!n.key&&(this.pushAccessUnit(n,e),n=this.VideoSample=null),n||(n=o(!0)),n.key=!0,n.frame=!0;break;case 39:a=!0,rG(r.data,2,i.pts,t.samples);break;case 32:a=!0,e.vps||("object"!=typeof e.params&&(e.params={}),e.params=ie(e.params,this.readVPS(r.data)),this.initVPS=r.data),e.vps=[r.data];break;case 33:if(a=!0,l=!0,void 0===e.vps||e.vps[0]===this.initVPS||void 0===e.sps||this.matchSPS(e.sps[0],r.data)||(this.initVPS=e.vps[0],e.sps=e.pps=void 0),!e.sps){let t=this.readSPS(r.data);for(let i in e.width=t.width,e.height=t.height,e.pixelRatio=t.pixelRatio,e.codec=t.codecString,e.sps=[],"object"!=typeof e.params&&(e.params={}),t.params)e.params[i]=t.params[i]}this.pushParameterSet(e.sps,r.data,e.vps),n||(n=o(!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!=(h=n)&&h.frame&&(this.pushAccessUnit(n,e),n=null),n||(n=o(!1));break;default:a=!1}n&&a&&n.units.push(r)}),r&&n&&(this.pushAccessUnit(n,e),this.VideoSample=null)}pushParameterSet(e,t,i){(!i||i[0]!==this.initVPS)&&(i||e.length)||e.push(t)}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:s}=i;return a>=32&&a<=35||39===a||a>=41&&a<=44||a>=48&&a<=55||a<=31&&s.length>2&&(128&s[2])!=0}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 nU(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 nU(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(),s=t.readBits(5),n=t.readUByte(),l=t.readUByte(),o=t.readUByte(),d=t.readUByte(),h=t.readUByte(),u=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(),S=0,k=0,R=0,L=0;A&&(S+=t.readUEG(),k+=t.readUEG(),R+=t.readUEG(),L+=t.readUEG());let I=t.readUEG(),w=t.readUEG(),D=t.readUEG(),C=t.readBoolean();for(let e=C?0:i;e<=i;e++)t.skipUEG(),t.skipUEG(),t.skipUEG();if(t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.readBoolean()&&t.readBoolean())for(let e=0;e<4;e++)for(let i=0;i<(3===e?2:6);i++)if(t.readBoolean()){let i=Math.min(64,1<<4+(e<<1));e>1&&t.readEG();for(let e=0;e<i;e++)t.readEG()}else t.readUEG();t.readBoolean(),t.readBoolean(),t.readBoolean()&&(t.readUByte(),t.skipUEG(),t.skipUEG(),t.readBoolean());let M=t.readUEG(),x=0;for(let e=0;e<M;e++){let i=!1;if(0!==e&&(i=t.readBoolean()),i){e===M&&t.readUEG(),t.readBoolean(),t.readUEG();let i=0;for(let e=0;e<=x;e++){let e=t.readBoolean(),r=!1;e||(r=t.readBoolean()),(e||r)&&i++}x=i}else{let e=t.readUEG(),i=t.readUEG();x=e+i;for(let i=0;i<e;i++)t.readUEG(),t.readBoolean();for(let e=0;e<i;e++)t.readUEG(),t.readBoolean()}}if(t.readBoolean()){let e=t.readUEG();for(let i=0;i<e;i++){for(let e=0;e<D+4;e++)t.readBits(1);t.readBits(1)}}let P=0,O=1,N=1,U=!0,F=1,B=0;t.readBoolean(),t.readBoolean();if(t.readBoolean()){if(t.readBoolean()){let e=t.readUByte();e>0&&e<16?(O=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2][e-1],N=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1][e-1]):255===e&&(O=t.readBits(16),N=t.readBits(16))}if(t.readBoolean()&&t.readBoolean(),t.readBoolean()&&(t.readBits(3),t.readBoolean(),t.readBoolean()&&(t.readUByte(),t.readUByte(),t.readUByte())),t.readBoolean()&&(t.readUEG(),t.readUEG()),t.readBoolean(),t.readBoolean(),t.readBoolean(),t.readBoolean()&&(t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG()),t.readBoolean()&&(F=t.readBits(32),B=t.readBits(32),t.readBoolean()&&t.readUEG(),t.readBoolean())){let e=t.readBoolean(),r=t.readBoolean(),a=!1;(e||r)&&((a=t.readBoolean())&&(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 s=0;s<=i;s++){let i=(U=t.readBoolean())||t.readBoolean(),s=!1;i?t.readEG():s=t.readBoolean();let n=s?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(),P=t.readUEG())}let $=b,H=T;if(A){let e=1,t=1;1===y?e=t=2:2==y&&(e=2),$=b-e*k-e*S,H=T-t*L-t*R}let G=r?["A","B","C"][r]:"",W=n<<24|l<<16|o<<8|d,K=0;for(let e=0;e<32;e++)K=(K|(W>>e&1)<<31-e)>>>0;let V=K.toString(16);return 1===s&&"2"===V&&(V="6"),{codecString:`hvc1.${G}${s}.${V}.${a?"H":"L"}${g}.B0`,params:{general_tier_flag:a,general_profile_idc:s,general_profile_space:r,general_profile_compatibility_flags:[n,l,o,d],general_constraint_indicator_flags:[h,u,c,m,f,p],general_level_idc:g,bit_depth:I+8,bit_depth_luma_minus8:I,bit_depth_chroma_minus8:w,min_spatial_segmentation_idc:P,chroma_format_idc:y,frame_rate:{fixed:U,fps:B/F}},width:$,height:H,pixelRatio:[O,N]}}readPPS(e){let t=new nU(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 iG(e).substring(3)===iG(t).substring(3)}}class n${constructor(e,t,i,r){this.logger=void 0,this.observer=void 0,this.config=void 0,this.typeSupp
6orted=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this._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(e,t){let i=n$.syncOffset(e);return i>0&&t.warn(`MPEG2-TS detected but first sync word found @ offset ${i}`),-1!==i}static syncOffset(e){let t=e.length,i=Math.min(940,t-188)+1,r=0;for(;r<i;){let a=!1,s=-1,n=0;for(let l=r;l<t;l+=188)if(71===e[l]&&(t-l==188||71===e[l+188])){if(n++,-1===s&&0!==(s=l)&&(i=Math.min(s+18612,e.length-188)+1),a||(a=0===nH(e,l)),a&&n>1&&(0===s&&n>2||l+188>i))return s}else if(n)return -1;else break;r++}return -1}static createTrack(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:rb[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===e?t:void 0}}resetInitSegment(e,t,i,r,a,s){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=n$.createTrack("video"),this._videoTrack.duration=r,this.videoIntegrityChecker="skip"===this.config.handleMpegTsVideoIntegrityErrors?new nV(this.logger):null,this._audioTrack=n$.createTrack("audio",r),this._id3Track=n$.createTrack("id3"),this._txtTrack=n$.createTrack("text"),this._audioTrack.segmentCodec="aac",this.videoParser=null,this.aacOverFlow=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=i,e&&this.demux(e,0,s,(null==a?void 0:a.method)==="SAMPLE-AES")}resetTimeStamp(){}resetContiguity(){let{_audioTrack:e,_videoTrack:t,_id3Track:i}=this;e&&(e.pesData=null),t&&(t.pesData=null),i&&(i.pesData=null),this.aacOverFlow=null,this.remainderData=null}demux(e,t,i,r=!1,a=!1){let s;r||(this.sampleAes=null);let n=this._videoTrack,l=this.videoIntegrityChecker,o=this._audioTrack,d=this._id3Track,h=this._txtTrack,u=i.iframe,c=n.pid,m=n.pesData,f=o.pid,p=d.pid,g=this._klvPid,v=o.pesData,E=d.pesData,y=null,b=null,T=this.pmtParsed,A=this._pmtId,S=e.length;if(this.remainderData&&(S=(e=rB(this.remainderData,e)).length,this.remainderData=null),S<188&&!a)return this.remainderData=e,{audioTrack:o,videoTrack:n,id3Track:d,textTrack:h};let k=Math.max(0,n$.syncOffset(e));(S-=(S-k)%188)<e.byteLength&&!a&&(this.remainderData=new Uint8Array(e.buffer,S,e.buffer.byteLength-S));let R=0;for(let t=k;t<S;t+=188)if(71===e[t]){let a,S=!!(64&e[t+1]),R=nH(e,t);if((48&e[t+3])>>4>1){if((a=t+5+e[t+4])===t+188)continue}else a=t+4;switch(R){case c:S&&(m&&!(null!=l&&l.isCorrupted)&&(s=nK(m,this.logger))&&(this.readyVideoParser(n.segmentCodec),null!==this.videoParser&&this.videoParser.parsePES(n,h,s,!1,i)),m={data:[],size:0},null==l||l.reset(c)),null==l||l.handlePacket(e.subarray(t)),m&&(m.data.push(e.subarray(a,t+188)),m.size+=t+188-a);break;case f:if(u)break;if(S){if(v&&(s=nK(v,this.logger)))switch(o.segmentCodec){case"aac":this.parseAACPES(o,s,i);break;case"mp3":this.parseMPEGPES(o,s);break;case"ac3":this.parseAC3PES(o,s)}v={data:[],size:0}}v&&(v.data.push(e.subarray(a,t+188)),v.size+=t+188-a);break;case p:if(u)break;S&&(E&&(s=nK(E,this.logger))&&this.parseID3PES(d,s),E={data:[],size:0}),E&&(E.data.push(e.subarray(a,t+188)),E.size+=t+188-a);break;case g:if(u)break;S&&(y&&(s=nK(y,this.logger))&&this.parseKlvPES(d,s),y={data:[],size:0}),y&&(y.data.push(e.subarray(a,t+188)),y.size+=t+188-a);break;case 0:var L,I;S&&(a+=e[a]+1),A=this._pmtId=(31&(L=e)[(I=a)+10])<<8|L[I+11];break;case A:{S&&(a+=e[a]+1);let s=function(e,t,i,r,a,s,n,l){let o={audioPid:-1,videoPid:-1,id3Pid:-1,klvPid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},d=(15&e[t+1])<<8|e[t+2],h=t+3+d-4,u=(15&e[t+10])<<8|e[t+11];for(t+=12+u;t<h;){let d=nH(e,t),h=(15&e[t+3])<<8|e[t+4];switch(e[t]){case 207:if(!r){nW("ADTS AAC",s);break}case 15:-1===o.audioPid&&(o.audioPid=d);break;case 21:-1===o.id3Pid&&(o.id3Pid=d);break;case 219:if(!r){nW("H.264",s);break}case 27:-1===o.videoPid&&(o.videoPid=d);break;case 3:case 4:i.mpeg||i.mp3?-1===o.audioPid&&(o.audioPid=d,o.segmentAudioCodec="mp3"):s.log("MPEG audio found, not supported in this browser");break;case 193:if(!r){nW("AC-3",s);break}case 129:i.ac3?-1===o.audioPid&&(o.audioPid=d,o.segmentAudioCodec="ac3"):s.log("AC-3 audio found, not supported in this browser");break;case 6:if(h>0){let r=t+5,a=h;for(;a>2;){switch(e[r]){case 106:-1===o.audioPid&&(!0!==i.ac3?s.log("AC-3 audio found, not supported in this browser for now"):(o.audioPid=d,o.segmentAudioCodec="ac3"));break;case 5:-1===o.klvPid&&n.enableEmsgKLVMetadata&&(o.klvPid=d,s.log(`KLV metadata PID found: ${d}`))}let t=e[r+1]+2;r+=t,a-=t}}break;case 194:case 135:return nG(a,Error("Unsupported EC-3 in M2TS found"),l,void 0,s),o;case 36:-1===o.videoPid&&(o.videoPid=d,o.segmentVideoCodec="hevc",s.log("HEVC in M2TS found"))}t+=h+5}return o}
6(e,a,this.typeSupported,r,this.observer,this.logger,this.config,i);(c=s.videoPid)>0&&(n.pid=c,n.segmentCodec=s.segmentVideoCodec),(f=s.audioPid)>0&&(o.pid=f,o.segmentCodec=s.segmentAudioCodec),(p=s.id3Pid)>0&&(d.pid=p),(g=s.klvPid)>0&&(this._klvPid=g),null===b||T||(this.logger.warn(`MPEG-TS PMT found at ${t} after unknown PID '${b}'. Backtracking to sync byte @${k} to parse all TS packets.`),b=null,t=k-188),T=this.pmtParsed=!0;break}case 17:case 8191:break;default:b=R}}else R++;R>0&&nG(this.observer,Error(`Found ${R} TS packet/s that do not start with 0x47`),i,void 0,this.logger),n.pesData=m,o.pesData=v,d.pesData=E;let w={audioTrack:o,videoTrack:n,id3Track:d,textTrack:h};return a&&this.extractRemainingSamples(w,i),w}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:s,textTrack:n}=e,l=a.pesData,o=r.pesData,d=s.pesData,h=this.videoIntegrityChecker;if(l&&!(null!=h&&h.isCorrupted)&&(i=nK(l,this.logger))?(this.readyVideoParser(a.segmentCodec),null!==this.videoParser&&(this.videoParser.parsePES(a,n,i,!0,t),a.pesData=null)):a.pesData=l,o&&(i=nK(o,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!=o&&o.size&&this.logger.log("last AAC PES packet truncated,might overlap between fragments"),r.pesData=o;d&&(i=nK(d,this.logger))?(this.parseID3PES(s,i),s.pesData=null):s.pesData=d}demuxSampleAes(e,t,i,r){let a=this.demux(e,i,r,!0,!this.config.progressive),s=this.sampleAes=new nC(this.observer,this.config,t);return this.decrypt(a,s)}readyVideoParser(e){null===this.videoParser&&("avc"===e?this.videoParser=new nF:"hevc"===e&&(this.videoParser=new nB))}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,s,n,l=0,o=this.aacOverFlow,d=t.data;if(o){this.aacOverFlow=null;let t=o.missing,i=o.sample.unit.byteLength;-1===t?d=rB(o.sample.unit,d):(o.sample.unit.set(d.subarray(0,t),i-t),e.samples.push(o.sample),l=o.missing)}for(r=l,a=d.length;r<a-1&&!np(d,r);r++);if(r!==l){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",nG(this.observer,Error(e),i,t,this.logger),!t)return}if(ng(e,this.observer,d,r,this.audioCodec),void 0!==t.pts)s=t.pts;else{if(!o)return void this.logger.warn("[tsdemuxer]: AAC PES unknown PTS");let t=9216e4/e.samplerate;s=o.sample.pts+t}let h=0;for(;r<a;){if(n=nv(e,d,r,s,h),r+=n.length,n.missing){this.aacOverFlow=n;break}for(h++;r<a-1&&!np(d,r);r++);}}parseMPEGPES(e,t){let i=t.data,r=i.length,a=0,s=0,n=t.pts;if(void 0===n)return void this.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");for(;s<r;)if(nw(i,s)){let t=nR(e,i,s,n,a);if(t)s+=t.length,a++;else break}else s++}parseAC3PES(e,t){{let i,r=t.data,a=t.pts;if(void 0===a)return void this.logger.warn("[tsdemuxer]: AC3 PES unknown PTS");let s=r.length,n=0,l=0;for(;l<s&&(i=nx(e,r,l,a,n++))>0;)l+=i}}parseID3PES(e,t){if(void 0===t.pts)return void this.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");let i=ie({},t,{type:this._videoTrack?nE.emsg:nE.audioId3,duration:1/0});e.samples.push(i)}parseKlvPES(e,t){var i,r;let a=null!=(i=t.pts)?i:t.dts;if(void 0===a)return void this.logger.warn("[tsdemuxer]: KLV PES unknown PTS and DTS");let s=t.data;if(s.length<16)return void this.logger.warn("[tsdemuxer]: KLV PES payload too short");let n=0;for(;n<s.length&&!(n+16>s.length);){let i=n;if((n+=16)>=s.length)break;let l=s[n];n+=1;let o=0;if(128&l){let e=127&l;if(0===e||e>4||n+e>s.length){this.logger.warn("[tsdemuxer]: Invalid KLV length encoding");break}for(let t=0;t<e;t++)o=o<<8|s[n+t];n+=e}else o=l;if(n+o>s.length){this.logger.warn("[tsdemuxer]: KLV value extends beyond PES payload");break}let d=n+o,h=s.subarray(i,d),u={data:h,len:h.byteLength,pts:a,dts:null!=(r=t.dts)?r:a,type:nE.misbklv,duration:1/0};e.samples.push(u),n=d}}}function nH(e,t){return((31&e[t+1])<<8)+e[t+2]}function nG(e,t,i,r,a){a.warn(`parsing error: ${t.message}`),e.emit(tz.ERROR,tz.ERROR,{type:tj.MEDIA_ERROR,details:tY.FRAG_PARSING_ERROR,fatal:!1,levelRetry:r,chunkMeta:i,error:t,reason:t.message})}function nW(e,t){t.log(`${e} with AES-128-CBC encryption found in unencrypted stream`)}function nK(e,t){let i,r,a,s,n,l=0,o=e.data;if(!e||0===e.size)return null;for(;o[0].length<19&&o.length>1;)o[0]=rB(o[0],o[1]),o.splice(1,1);if(1===((i=o[0])[0]<<16)+(i[1]<<8)+i[2]){if((r=(i[4]<<8)+i[5])&&r>e.size-6)return null;let d=i[7];192&d&&(s=(14&i[9])*0x20000000+(255&i[10])*4194304+(254&i[11])*16384+(255&i[12])*128+(254&i[13])/2,64&d?s-(n=(14&i[14])*0x20000000+(255&i[15])*4194304+(254&i[16])*16384+(255&i[17])*128+(254&i[18])/2)>54e5&&(t.warn(`${Math.round((s-n)/9e4)}s delta between PTS and DTS, align them`),s=n):n=s);let h=(a=i[8])+9;if(e.size<=h)return null;e.size-=h;let u=new Uint8Array(e.size);for(let e=0,t=o.length;e<t;e++){let t=(i=o[e]).byteLength;if(h)if(h>t){h-=t;continue}else i=i.subarray(h),t-=h,h=0;u.set(i,l),l+=t}return r&&(r-=a+3),{data:u,pts:s,dts:n,len:r}}return null}class nV{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=nH(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;if(this.lastContinuityCounter=r,(2&i)!=0&&0!=e[4]&&(128&e[5])!=0||a<0)return;let s=(1&i)!=0?a+1&15:a;if(r!==s){this.logger.warn(`MPEG-TS Continuity Counter check failed for PID='${t}', CC=${r}, Expected-CC=${s} Last-CC=${a}`),this.integrityState="cc-failed";return}if((128&e[1])!=0){this.logger.warn(`MPEG-TS Packet had TEI flag set for PID='${t}'`),this.integrityState="tei-bit";return}}}class nq{static getSilentFrame(e,t){if("mp4a.40.2"===e){if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);else if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);else if(5===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);else if(6===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(1===t)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(3===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}}}let nj={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])}
6,nY=new Uint8Array([0,0,0,0,0,0,0,0]),nz=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),nQ=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),nX=new Uint8Array([0,0,0,0,0,0,0,0]),nZ=new Uint8Array([0,0,0,0,0,0,0,1]),nJ=new Uint8Array([105,115,111,109]),n0=new Uint8Array([97,118,99,49]),n1=new Uint8Array([0,0,0,1]);class n2{static box(e,...t){let i=8,r=t.length,a=r;for(;r--;)i+=t[r].byteLength;let s=new Uint8Array(i);for(rR(s,0,i),rR(s,4,e),r=0,i=8;r<a;r++)s.set(t[r],i),i+=t[r].byteLength;return s}static hdlr(e){return n2.box(iJ,nj[e])}static mdat(e){return n2.box(i0,e)}static mdhd(e,t){let i=Math.floor((t*=e)/0x100000000),r=Math.floor(t%0x100000000);return n2.box(i1,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,i>>24,i>>16&255,i>>8&255,255&i,r>>24,r>>16&255,r>>8&255,255&r,85,196,0,0]))}static mdia(e){return n2.box(i2,n2.mdhd(e.timescale||0,e.duration||0),n2.hdlr(e.type),n2.minf(e))}static mfhd(e){return n2.box(i3,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e]))}static minf(e){return"audio"===e.type?n2.box(i4,n2.box(ry,nX),n2.DINF,n2.stbl(e)):n2.box(i4,n2.box(rE,nQ),n2.DINF,n2.stbl(e))}static moof(e,t,i){return n2.box(i5,n2.mfhd(e),n2.traf(i,t))}static moov(e){let t=e.length,i=[];for(;t--;)i[t]=n2.trak(e[t]);return n2.box.apply(null,[i8,n2.mvhd(e[0].timescale||0,e[0].duration||0)].concat(i).concat(n2.mvex(e)))}static mvex(e){let t=e.length,i=[];for(;t--;)i[t]=n2.trex(e[t]);return n2.box.apply(null,[rt,...i])}static mvhd(e,t){let i=Math.floor((t*=e)/0x100000000),r=Math.floor(t%0x100000000),a=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,i>>24,i>>16&255,i>>8&255,255&i,r>>24,r>>16&255,r>>8&255,255&r,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return n2.box(ri,a)}static sdtp(e){let t,i,r=e.samples||[],a=new Uint8Array(4+r.length);for(t=0;t<r.length;t++)i=r[t].flags,a[t+4]=i.dependsOn<<4|i.isDependedOn<<2|i.hasRedundancy;return n2.box(ra,a)}static stbl(e){return n2.box(rs,n2.stsd(e),n2.box(rh,nY),n2.box(rl,nY),n2.box(rd,nz),n2.box(rn,nY))}static avc1(e){let t,i,r,a=[],s=[];for(t=0;t<e.sps.length;t++)r=(i=e.sps[t]).byteLength,a.push(r>>>8&255),a.push(255&r),a=a.concat(Array.prototype.slice.call(i));for(t=0;t<e.pps.length;t++)r=(i=e.pps[t]).byteLength,s.push(r>>>8&255),s.push(255&r),s=s.concat(Array.prototype.slice.call(i));let n=n2.box(iK,new Uint8Array([1,a[3],a[4],a[5],255,224|e.sps.length].concat(a).concat([e.pps.length]).concat(s))),l=e.width,o=e.height,d=e.pixelRatio[0],h=e.pixelRatio[1];return n2.box(iW,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,l>>8&255,255&l,o>>8&255,255&o,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),n,n2.box(ij,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),n2.box(rr,new Uint8Array([d>>24,d>>16&255,d>>8&255,255&d,h>>24,h>>16&255,h>>8&255,255&h])))}static esds(e){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(e){return n2.box(i6,n2.audioStsd(e),n2.box(iQ,n2.esds(e)))}static mp3(e){return n2.box(i9,n2.audioStsd(e))}static ac3(e){return n2.box(re,n2.audioStsd(e),n2.box(i7,e.config))}static stsd(e){let{segmentCodec:t}=e;if("audio"===e.type){if("aac"===t)return n2.box(ro,nZ,n2.mp4a(e));if("ac3"===t&&e.config)return n2.box(ro,nZ,n2.ac3(e));if("mp3"===t&&"mp3"===e.codec)return n2.box(ro,nZ,n2.mp3(e))}else if(e.pps&&e.sps){if("avc"===t)return n2.box(ro,nZ,n2.avc1(e));if("hevc"===t&&e.vps)return n2.box(ro,nZ,n2.hvc1(e))}else throw Error("video track missing pps or sps");throw Error(`unsupported ${e.type} segment codec (${t}/${e.codec})`)}static tkhd(e){let t=e.id,i=(e.duration||0)*(e.timescale||0),r=e.width||0,a=e.height||0,s=Math.floor(i/0x100000000),n=Math.floor(i%0x100000000);return n2.box(rv,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,0,0,0,0,s>>24,s>>16&255,s>>8&255,255&s,n>>24,n>>16&255,n>>8&255,255&n,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,r>>8&255,255&r,0,0,a>>8&255,255&a,0,0]))}static traf(e,t){let i=n2.sdtp(e),r=e.id,a=Math.floor(t/0x100000000),s=Math.floor(t%0x100000000);return n2.box(rm,n2.box(rc,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r])),n2.box(ru,new Uint8Array([1,0,0,0,a>>24,a>>16&255,a>>8&255,255&a,s>>24,s>>16&255,s>>8&255,255&s])),n2.trun(e,i.length+16+20+8+16+8+8),i)}static trak(e){return e.duration=e.duration||0xffffffff,n2.box(rf,n2.tkhd(e),n2.mdia(e))}static trex(e){let t=e.id;return n2.box(rg,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(e,t){let i,r,a,s,n,l,o=e.samples||[],d=o.length,h=12+16*d,u=new Uint8Array(h);for(t+=8+h,u.set([+("video"===e.type),0,15,1,d>>>24&255,d>>>16&255,d>>>8&255,255&d,t>>>24&255,t>>>16&255,t>>>8&255,255&t],0),i=0;i<d;i++)a=(r=o[i]).duration,s=r.size,n=r.flags,l=r.cts,u.set([a>>>24&255,a>>>16&255,a>>>8&255,255&a,s>>>24&255,s>>>16&255,s>>>8&255,255&s,n.isLeading<<2|n.dependsOn,n.isDependedOn<<6|n.hasRedundancy<<4|n.paddingValue<<1|n.isNonSync,61440&n.degradPrio,15&n.degradPrio,l>>>24&255,l>>>16&255,l>>>8&255,255&l],12+16*i);return n2.box(rp,u)}static initSegment(e){let t=n2.moov(e);return rB(n2.FTYP,t)}
6static hvc1(e){let t=e.params,i=[e.vps,e.sps,e.pps],r=new Uint8Array([1,t.general_profile_space<<6|32*!!t.general_tier_flag|t.general_profile_idc,t.general_profile_compatibility_flags[0],t.general_profile_compatibility_flags[1],t.general_profile_compatibility_flags[2],t.general_profile_compatibility_flags[3],t.general_constraint_indicator_flags[0],t.general_constraint_indicator_flags[1],t.general_constraint_indicator_flags[2],t.general_constraint_indicator_flags[3],t.general_constraint_indicator_flags[4],t.general_constraint_indicator_flags[5],t.general_level_idc,240|t.min_spatial_segmentation_idc>>8,255&t.min_spatial_segmentation_idc,252|t.parallelismType,252|t.chroma_format_idc,248|t.bit_depth_luma_minus8,248|t.bit_depth_chroma_minus8,0,parseInt(t.frame_rate.fps),3|t.temporal_id_nested<<2|t.num_temporal_layers<<3|64*!!t.frame_rate.fixed,i.length]),a=r.length;for(let e=0;e<i.length;e+=1){a+=3;for(let t=0;t<i[e].length;t+=1)a+=2+i[e][t].length}let s=new Uint8Array(a);s.set(r,0),a=r.length;let n=i.length-1;for(let e=0;e<i.length;e+=1){s.set(new Uint8Array([32+e|128*(e===n),0,i[e].length]),a),a+=3;for(let t=0;t<i[e].length;t+=1)s.set(new Uint8Array([i[e][t].length>>8,255&i[e][t].length]),a),a+=2,s.set(i[e][t],a),a+=i[e][t].length}let l=n2.box(iq,s),o=e.width,d=e.height,h=e.pixelRatio[0],u=e.pixelRatio[1];return n2.box(iV,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,o>>8&255,255&o,d>>8&255,255&d,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),l,n2.box(ij,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),n2.box(rr,new Uint8Array([h>>24,h>>16&255,h>>8&255,255&h,u>>24,u>>16&255,u>>8&255,255&u])))}}function n3(e,t,i=1,r=!1){let a=e*t*i;return r?Math.round(a):a}function n4(e,t=!1){return n3(e,1e3,11111111111111112e-21,t)}function n5(e){let{baseTime:t,timescale:i,trackId:r}=e;return`${t/i} (${t}/${i}) trackId: ${r}`}function n8(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,paddingValue:0}}}n2.FTYP=n2.box(iZ,nJ,n1,nJ,n0),n2.DINF=n2.box(iY,n2.box(iz,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1])));class n6 extends iv{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?n5(t):t} > ${e?n5(e):e}`),this._initPTS=this._initDTS=e}resetNextTimestamp(){this.log("reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){this.log("ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0}getVideoStartPts(e){let t=!1,i=e[0].pts,r=e.reduce((e,r)=>{let a=r.pts,s=a-e;return(s<-0x100000000&&(t=!0,s=(a=n9(a,i))-e),s>0)?e:a},i);return t&&this.debug("PTS rollover detected"),r}remux(e,t,i,r,a,s,n,l,o){let d,h,u,c,m,f,p=a,g=a,v=!o.iframe&&e.pid>-1,E=t.pid>-1,y=t.samples.length,b=e.samples.length>0,T=n&&y>0||y>1;if((!v||b)&&(!E||T)||this.ISGenerated||n){let i;if(this.ISGenerated){var A,S,k,R;let e=this.videoTrackConfig;(e&&(t.width!==e.width||t.height!==e.height||(null==(A=t.pixelRatio)?void 0:A[0])!==(null==(S=e.pixelRatio)?void 0:S[0])||(null==(k=t.pixelRatio)?void 0:k[1])!==(null==(R=e.pixelRatio)?void 0:R[1]))||!e&&T||null===this.nextAudioTs&&b)&&this.resetInitSegment()}this.ISGenerated||(u=this.generateIS(e,t,a,s));let r=this.isVideoContiguous,n=-1;if(T&&(n=function(e){for(let t=0;t<e.length;t++)if(e[t].key)return t;return -1}(t.samples),!r&&this.config.forceKeyFrameOnDiscontinuity))if(f=!0,n>0){this.warn(`Dropped ${n} out of ${y} video samples due to a missing keyframe`);let e=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(n),t.dropped+=n,g+=(t.samples[0].pts-e)/t.inputTimeScale,i=g}else -1===n&&(this.warn(`No keyframe found out of ${y} video samples`),f=!1);if(this.ISGenerated){if(b&&T&&a){let i=this.getVideoStartPts(t.samples),r=(n9(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"),u=this.generateIS(e,t,a,s)),h=this.remuxAudio(e,p,this.isAudioContiguous,s,E||T||l===t0.AUDIO?g:void 0,o),T){let i=h?h.endPTS-h.startPTS:0;t.inputTimeScale||(this.warn("regenerate InitSegment as video detected"),u=this.generateIS(e,t,a,s)),d=this.remuxVideo(t,g,r,i,o)}}else T&&(d=this.remuxVideo(t,g,r,0,o));d&&(d.firstKeyFrame=n,d.independent=-1!==n,d.firstKeyFramePTS=i)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(i.samples.length&&(m=n7(i,a,this._initPTS,this._initDTS)),r.samples.length&&(c=le(r,a,this._initPTS))),{audio:h,video:d,initSegment:u,independent:f,text:c,id3:m}}computeInitPts(e,t,i,r){let a=Math.round(i*t),s=n9(e,a);if(s<a)for(this.log(`Adjusting PTS for rollover in timeline near ${(a-s)/t} ${r}`);s<a;)s+=0x200000000;return s-a}generateIS(e,t,i,r){let a,s,n,l=e.samples,o=t.samples,d=this.typeSupp
6orted,h={},u=this._initPTS,c=!u||r,m="audio/mp4",f=-1;if(c&&(a=s=1/0),e.config&&l.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(h.audio={id:"audio",container:m,codec:e.codec,initSegment:"mp3"===e.segmentCodec&&d.mpeg?new Uint8Array(0):n2.initSegment([e]),metadata:{channelCount:e.channelCount}},c){f=e.id,n=e.inputTimeScale;let t=this.computeInitPts(l[0].pts,n,i,"audio");(!u||n!==u.timescale||0===i&&t<u.baseTime)&&(a=s=t)}}if(t.sps&&t.pps&&o.length){if(t.timescale=t.inputTimeScale,h.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:n2.initSegment([t]),metadata:{width:t.width,height:t.height}},c){f=t.id,n=t.inputTimeScale;let e=this.getVideoStartPts(o),r=n9(o[0].dts,e),l=this.computeInitPts(r,n,i,"video"),d=this.computeInitPts(e,n,i,"video");(!u||n!==u.timescale||tK(a)||0===i&&d<u.baseTime)&&(s=Math.min(s,l),a=Math.min(a,l))}this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(h).length)return this.ISGenerated=!0,c&&tK(a)?(u&&this.warn(`Timestamps at playlist time: ${r?"":"~"}${i} ${a/n} != initPTS: ${u.baseTime/u.timescale} (${u.baseTime}/${u.timescale}) trackId: ${u.trackId}`),this.log(`Found initPTS at playlist time: ${i} offset: ${a/n} (${a}/${n}) trackId: ${f}`),this._initPTS={baseTime:a,timescale:n,trackId:f},this._initDTS={baseTime:s,timescale:n,trackId:f}):a=n=void 0,{tracks:h,initPTS:a,timescale:n,trackId:f}}remuxVideo(e,t,i,r,s){let n,l,o,d=e.inputTimeScale,h=e.samples,u=[],c=h.length,m=this._initPTS,f=m.baseTime*d/m.timescale,p=this.nextVideoTs,g=8,v=this.videoSampleDuration,E=1/0,y=-1/0,b=!1;if(!i||null===p){let e=f+t*d,r=h[0].pts-n9(h[0].dts,h[0].pts);rY()&&null!==p&&15e3>Math.abs(e-r-(p+f))?i=!0:p=e-r-f}let T=p+f;for(let e=0;e<c;e++){let t=h[e];t.pts=n9(t.pts,T),t.dts=n9(t.dts,T),t.dts<h[e>0?e-1:e].dts&&(b=!0)}b&&h.sort(function(e,t){let i=e.dts-t.dts,r=e.pts-t.pts;return i||r}),n=h[0].dts;let A=(l=h[h.length-1].dts)-n,S=A?Math.round(A/(c-1)):v||e.inputTimeScale/30;if(i){let i=n-T,r=i>S,a=i<-1;if((r||a)&&(r?this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${n4(i,!0)} ms (${i}dts) hole between fragments detected at ${t.toFixed(3)}`):this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${n4(-i,!0)} ms (${i}dts) overlapping between fragments detected at ${t.toFixed(3)}`),!a||T>=h[0].pts||rY())){n=T;let e=h[0].pts-i;if(r)h[0].dts=n,h[0].pts=e;else{let t=!0;for(let r=0;r<h.length&&(!(h[r].dts>e)||!t);r++){let e=h[r].pts;if(h[r].dts-=i,h[r].pts-=i,r<h.length-1){let i=h[r+1].pts;t=i<=h[r].pts==i<=e}}}this.log(`Video: Initial PTS/DTS adjusted: ${n4(e,!0)}/${n4(n,!0)}, delta: ${n4(i,!0)} ms`)}}let k=0,R=0,L=n=Math.max(0,n);for(let e=0;e<c;e++){let t=h[e],i=t.units,r=i.length,a=0;for(let e=0;e<r;e++)a+=i[e].data.length;R+=a,k+=r,t.length=a,t.dts<L?(t.dts=L,L+=S/4|0||1):L=t.dts,E=Math.min(t.pts,E),y=Math.max(t.pts,y)}l=h[c-1].dts;let I=R+4*k+8;try{o=new Uint8Array(I)}catch(e){this.observer.emit(tz.ERROR,tz.ERROR,{type:tj.MUX_ERROR,details:tY.REMUX_ALLOC_ERROR,fatal:!1,chunkMeta:s,error:e,bytes:I,reason:`fail allocating video mdat ${I}`});return}rR(o,0,I),rR(o,4,i0);let w=!1,D=1/0,C=1/0,M=-1/0,x=-1/0;for(let e=0;e<c;e++){let t,a=h[e],n=a.units,l=0;for(let e=0,t=n.length;e<t;e++){let t=n[e],i=t.data,r=t.data.byteLength;rR(o,g,r),g+=4,o.set(i,g),g+=r,l+=4+r}if(e<c-1)v=h[e+1].dts-a.dts,t=h[e+1].pts-a.pts;else{let i=this.config,s=e>0?a.dts-h[e-1].dts:S;if(t=e>0?a.pts-h[e-1].pts:S,i.stretchShortVideoTrack&&null!==this.nextAudioTs){let e=Math.floor(i.maxBufferHole*d),t=(r?E+r*d:this.nextAudioTs+f)-a.pts;t>e?((v=t-s)<0?v=s:w=!0,this.log(`It is approximately ${t/90} ms to the next segment; using duration ${v/90} ms for the last video frame.`)):v=s}else v=s}let m=Math.round(a.pts-a.dts);if(D=Math.min(D,v),M=Math.max(M,v),C=Math.min(C,t),x=Math.max(x,t),!i&&0===e&&m>v){let e=Math.round(m/S)*S;e-m==1&&(this.log(`pad first CTS ${m} -> ${e} of sn: ${s.sn}`),m=e)}u.push(n8(a.key,v,l,m))}if(u.length){let e=rY();if(e){if(e<70){let e=u[0].flags;e.dependsOn=2,e.isNonSync=0}}else if(function(){if(void 0===a){let e=rV.match(/Safari\/(\d+)/i);a=e?parseInt(e[1]):0}return a}()&&x-C<M-D&&S/M<.025&&0===u[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=u.length;t<i;t++){let r=e+u[t].duration,a=e+u[t].cts;if(t<i-1){let e=r+u[t+1].cts;u[t].duration=e-a}else u[t].duration=t?u[t-1].duration:S;u[t].cts=0,e=r}}}let P=l+(v=w||!v?S:v);this.nextVideoTs=p=P-f,this.videoSampleDuration=v,this.isVideoContiguous=!0,s.iframe&&(1===u.length?(u[0].duration=v=s.duration*d,this.nextVideoTs=p=n+v-f):this.warn(`Not adjusting IFrame duration (sample count ${u.length})`));let O={data1:n2.moof(s.sn,n,ie(e,{samples:u})),data2:o,startPTS:(E-f)/d,endPTS:(y+v-f)/d,startDTS:(n-f)/d,endDTS:p/d,type:"video",hasAudio:!1,hasVideo:!0,nb:u.length,dropped:e.dropped};return e.samples=[],e.dropped=0,O}
6getSamplesPerFrame(e){switch(e.segmentCodec){case"mp3":return 1152;case"ac3":return 1536;default:return 1024}}remuxAudio(e,t,i,r,a,s){let n,l=e.inputTimeScale,o=e.samplerate?e.samplerate:l,d=l/o,h=this.getSamplesPerFrame(e),u=h*d,c=this._initPTS,m="mp3"===e.segmentCodec&&this.typeSupported.mpeg,f=[],p=void 0!==a,g=e.samples,v=8*!m,E=this.nextAudioTs||-1,y=c.baseTime*l/c.timescale,b=y+t*l;if(this.isAudioContiguous=i=i||g.length&&E>0&&(r&&9e3>Math.abs(b-(E+y))||Math.abs(n9(g[0].pts,b)-(E+y))<20*u),g.forEach(function(e){e.pts=n9(e.pts,b)}),!i||E<0){let e=g.length;if(e!==(g=g.filter(e=>e.pts>=0)).length&&this.warn(`Removed ${g.length-e} of ${e} samples (initPTS ${y} / ${l})`),!g.length)return;E=0===a?0:r&&!p?Math.max(0,b-y):g[0].pts-y}if("aac"===e.segmentCodec){let t=this.config.maxAudioFramesDrift;for(let i=0,r=E+y;i<g.length;i++){let a=g[i],s=a.pts,n=s-r,o=Math.abs(1e3*n/l);if(n<=-t*u&&p)0===i&&(this.warn(`Audio frame @ ${(s/l).toFixed(3)}s overlaps marker by ${Math.round(1e3*n/l)} ms.`),this.nextAudioTs=E=s-y,r=s);else if(n>=t*u&&o<1e4&&p){let t=Math.round(n/u);for(r=s-t*u;r<0&&t&&u;)t--,r+=u;0===i&&(this.nextAudioTs=E=r-y),this.warn(`Injecting ${t} audio frames @ ${((r-y)/l).toFixed(3)}s due to ${Math.round(1e3*n/l)} ms gap.`);for(let s=0;s<t;s++){let t=nq.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()),g.splice(i,0,{unit:t,pts:r}),r+=u,i++}}a.pts=r,r+=u}}let T=null,A=null,S=0,k=g.length;for(;k--;)S+=g[k].unit.byteLength;for(let t=0,r=g.length;t<r;t++){let r=g[t],a=r.unit,l=r.pts;if(null!==A)f[t-1].duration=Math.round((l-A)/d);else{if(i&&"aac"===e.segmentCodec&&(l=E+y),T=l,!(S>0))return;S+=v;try{n=new Uint8Array(S)}catch(e){this.observer.emit(tz.ERROR,tz.ERROR,{type:tj.MUX_ERROR,details:tY.REMUX_ALLOC_ERROR,fatal:!1,chunkMeta:s,error:e,bytes:S,reason:`fail allocating audio mdat ${S}`});return}m||(rR(n,0,S),rR(n,4,i0))}n&&n.set(a,v);let o=a.byteLength;v+=o,f.push(n8(!0,h,o,0)),A=l}let R=f.length;if(!R)return;let L=f[f.length-1];E=A-y,this.nextAudioTs=E+d*L.duration;let I=m?new Uint8Array(0):n2.moof(e.sequenceNumber++,T/d,ie({},e,{samples:f}));e.samples=[];let w=(T-y)/l,D=this.nextAudioTs/l,C={data1:I,data2:n,startPTS:w,endPTS:D,startDTS:w,endDTS:D,type:"audio",hasAudio:!0,hasVideo:!1,nb:R};return this.isAudioContiguous=!0,C}}function n9(e,t){let i;if(null===t)return e;for(i=t<e?-0x200000000:0x200000000;Math.abs(e-t)>0x100000000;)e+=i;return e}function n7(e,t,i,r){let a=e.samples.length;if(!a)return;let s=e.inputTimeScale;for(let n=0;n<a;n++){let a=e.samples[n];a.pts=n9(a.pts-i.baseTime*s/i.timescale,t*s)/s,a.dts=n9(a.dts-r.baseTime*s/r.timescale,t*s)/s}let n=e.samples;return e.samples=[],{samples:n}}function le(e,t,i){let r=e.samples.length;if(!r)return;let a=e.inputTimeScale;for(let s=0;s<r;s++){let r=e.samples[s];r.pts=n9(r.pts-i.baseTime*a/i.timescale,t*a)/a}e.samples.sort((e,t)=>e.pts-t.pts);let s=e.samples;return e.samples=[],{samples:s}}function lt(e,t,i=!1){return(null==e?void 0:e.start)!==void 0?(e.start+(i?e.duration:0))/e.timescale:t}function li(e,t,i){let r=e.codec;return r&&r.length>4?r:t===t1?"ec-3"===r||"ac-3"===r||"alac"===r?r:"fLaC"===r||"Opus"===r?r5(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{s=self.performance.now.bind(self.performance)}catch(e){s=Date.now}let lr=[{demux:class{constructor(e,t,i,r=iA){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=ny("video",1),s=this.audioTrack=ny("audio",1),n=this.txtTrack=ny("text",1);if(this.id3Track=ny("id3",1),this.initData=void 0,this.timeOffset=0,!(null!=e&&e.byteLength))return;let l=this.initData=rC(e);if(l.video){let{id:e,timescale:t,codec:i,supplemental:r}=l.video;a.id=e,a.timescale=n.timescale=t,a.codec=i,a.supplemental=r}if(l.audio){let{id:e,timescale:t,codec:i}=l.audio;s.id=e,s.timescale=t,s.codec=i}n.id=rb.text,a.sampleDuration=0,a.duration=s.duration=r}resetContiguity(){this.remainderData=null}static probe(e){let t=e.byteLength;for(let i=0;i<t;){let r=rA(e,i);if(r>8&&rA(e,i+4)===i5)return!0;
6i=r>1?i+r:t}return!1}demux(e,t,i){this.timeOffset=t;let r=e,a=this.videoTrack,s=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=rB(this.remainderData,e));let t=function(e){let t={valid:null,remainder:null},i=rD(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 n=this.extractID3Track(a,t),l=this.parseFragment(a,s,t,i);return{videoTrack:a,audioTrack:this.audioTrack,id3Track:n,textTrack:this.txtTrack,initData:this.initData,sampleData:l}}flush(e,t){let i=this.timeOffset,r=this.videoTrack,a=this.txtTrack;r.samples=this.remainderData||new Uint8Array,this.remainderData=null;let s=this.extractID3Track(r,this.timeOffset),n=this.parseFragment(r,a,i,t);return{videoTrack:r,audioTrack:ny(),id3Track:s,textTrack:ny(),initData:this.initData,sampleData:n}}parseFragment(e,t,i,r){var a;let s,n,l,o,d,h=this.initData;if(h&&r){let{samples:a,sampleData:s}=function(e,t,i,r,a=!1){let s=[],n=rF(t.samples,i,r,a,{isHEVCFlavor:r$(t.codec),samples:s,timeOffset:e,timescale:t.timescale,trackId:t.id});return{samples:s,sampleData:{includeSampleDetails:a,tracks:n}}}(i,e,h,this.logger,r.iframe);return t.samples=a,s}a=i,s=[],n=e.samples,l=e.timescale,o=e.id,d=!1,rD(n,["moof"]).map(t=>{let i=t.byteOffset-8;rD(t,["traf"]).map(t=>{let r=rD(t,["tfdt"]).map(e=>{let t=e[0],i=rA(e,4);return 1===t&&(i*=0x100000000,i+=rA(e,8)),i/l})[0];return void 0!==r&&(a=r),rD(t,["tfhd"]).map(r=>{let h=rA(r,4),u=0xffffff&rA(r,0),c=(1&u)!=0,m=0,f=0,p=0,g=8;h===o&&(c?(m=rA(r,g),g+=4,m*=0x100000000,m+=rA(r,g),g+=4):c||(131072&u)==0||(m=i),(2&u)!=0&&(g+=4),(8&u)!=0&&(f=rA(r,g),g+=4),(16&u)!=0&&(p=rA(r,g),g+=4),(32&u)!=0&&(g+=4),"video"===e.type&&(d=r$(e.codec)),rD(t,["trun"]).map(t=>{let i=t[0],r=0xffffff&rA(t,0),o=0,h=(256&r)!=0,u=0,c=(512&r)!=0,g=0,v=(1024&r)!=0,E=(2048&r)!=0,y=0,b=rA(t,4),T=8;(1&r)!=0&&(o=rA(t,T),T+=4),(4&r)!=0&&(T+=4);let A=m+o;for(let r=0;r<b;r++){if(h?(u=rA(t,T),T+=4):u=f,c?(g=rA(t,T),T+=4):g=p,v&&(T+=4),E&&(y=0===i?rA(t,T):rk(t,T),T+=4),e.type===t2){let e=0;for(;e<g;){let t=rA(n,A);A+=4,rH(d,n[A])&&rG(n.subarray(A,A+t),d?2:1,a+y/l,s),A+=t,e+=t+4}}a+=u/l}}))})})}),t.samples=s}extractID3Track(e,t){let i=this.id3Track;return e.samples.length&&rD(e.samples,["emsg"]).forEach(e=>{let r=function(e){let t,i=e[0],r="",a="",s=0,n=0,l=0,o=0,d=4;if(0===i){let t=rS(e,d),i=null!==t?rS(e,d+t.length):null;null!==t&&null!==i?(r=t,a=i,d+=t.length+i.length,s=rA(e,d),d+=4,n=rA(e,d),d+=4,l=rA(e,d),d+=4,o=rA(e,d),d+=4):(iA.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){s=rA(e,d);let i=rA(e,d+=4),n=rA(e,d+=4);d+=4,tV(t=0x100000000*i+n)||(t=Number.MAX_SAFE_INTEGER,iA.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),l=rA(e,d),d+=4,o=rA(e,d);let h=rS(e,d+=4),u=null!==h?rS(e,d+h.length):null;null!==h&&(r=h,d+=h.length),null!==u?(a=u,d+=u.length):(iA.warn(`Unterminated ${null===h?"scheme_id_uri":"value"} in parsing emsg box: version 1 box ends inside a string, dropping its ${null===h?"strings and payload":"value and payload"}`),d=e.length)}return{schemeIdUri:r,value:a,timeScale:s,presentationTime:t,presentationTimeDelta:n,eventDuration:l,id:o,payload:e.subarray(d,e.byteLength)}}(e);if(nP.test(r.schemeIdUri)){let e=nO(r,t),a=0xffffffff===r.eventDuration?1/0:r.eventDuration/r.timeScale;a<=.001&&(a=1/0);let s=r.payload;i.samples.push({data:s,len:s.byteLength,dts:e,pts:e,type:nE.emsg,duration:a})}else if(this.config.enableEmsgKLVMetadata){let e=this.config.emsgKLVSchemaUri||nE.misbklv;if(r.schemeIdUri.startsWith(e)){let e=nO(r,t);i.samples.push({data:r.payload,len:r.payload.byteLength,dts:e,pts:e,type:nE.misbklv,duration:1/0})}}}),i}demuxSampleAes(e,t,i){return Promise.reject(Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){this.config=null,this.remainderData=null,this.videoTrack=this.audioTrack=this.id3Track=this.txtTrack=void 0,this.initData=void 0}},remux:class extends iv{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)){this.initTracks=void 0,this.initData=void 0;return}let{audio:s,video:n}=this.initData=i||rC(e);if(t)!function(e,t){if(!e||!t)return;let i=t.keyId;(null==i?void 0:i.byteLength)===16&&t.isCommonEncryption&&rN(e,(e,t)=>{let r=e.subarray(8,24);r.some(e=>0!==e)||(iA.log(`[eme] Patching keyId in 'enc${t?"a":"v"}>sinf>>tenc' box: ${iB(r)} -> ${iB(i)}`),e.set(i,8))})}(e,t);else{let e=s||n;null!=e&&e.encrypted&&this.warn(`Init segment with encrypted track with has no key ("${e.codec}")!`)}s&&(r=li(s,t1,this)),n&&(a=li(n,t2,this));let l={};s&&n?l.audiovideo={container:"video/mp4",codec:r+","+a,supplemental:n.supplemental,encrypted:n.encrypted,initSegment:e,id:"main"}:s?l.audio={container:"audio/mp4",codec:r,encrypted:s.encrypted,initSegment:e,id:"audio"}:n?l.video={container:"video/mp4",codec:a,supplemental:n.supplemental,encrypted:n.encrypted,initSegment:e,id:"main"}:this.warn("initSegment does not contain moov or trak boxes."),this.initTracks=l}remux(e,t,i,r,a,s,n,l,o,d,h){var u,c,m,f;let p,g,{initPTS:v,lastEndTime:E}=this,y={audio:void 0,video:void 0,text:void 0,id3:i,initSegment:void 0};tK(E)||(E=this.lastEndTime=a||0);let b=t.samples;if(!b.length)return y;let T=this.pendingInitSegment;T&&(this.pendingInitSegment=void 0,this.generateInitSegment(T,this.decryptdata,d));let A={initPTS:void 0,timescale:void 0,trackId:void 0},S=this.initData;if(null!=(u=S)&&u.length||(this.generateInitSegment(b),S=this.initData),!(null!=(c=S)&&c.length))return this.warn("Failed to generate initSegment."),y;if(o.iframe&&S.audio&&S.video){let e=null==(m=this.initTracks)||null==(m
6=m.audiovideo)?void 0:m.initSegment,t=e?function(e){let t=rD(e,["moov"]);if(1!==t.length||rD(e,["moof"]).length)return null;let i=e.byteOffset,r=[],a=[],s=!1,n=rD(t[0],["trak"]);for(let e=0;e<n.length;e++){let t=n[e],l=rD(t,["mdia","hdlr"])[0];if("vide"===(l?iG(l.subarray(8,12)):"")){s=!0;continue}let o=rD(t,["tkhd"])[0];if(!o)return null;let d=o[0];a.push(rA(o,0===d?12:20)),r.push(rI(t,i))}if(!s||!r.length)return null;let l=rD(t[0],["mvex"])[0],o=0;if(l){let e=rD(l,["trex"]);for(let t=0;t<e.length;t++){let s=e[t];-1!==a.indexOf(rA(s,4))&&(r.push(rI(s,i)),o+=s.byteLength+8)}}let{result:d,dropped:h,droppedBefore:u}=rw(e,r);if(rR(d,t[0].byteOffset-i-8,t[0].byteLength+8-h),l&&o){let e=l.byteOffset-i-8;rR(d,e-u(e),l.byteLength+8-o)}return d}(e):null;t&&(this.log("Converted muxed init segment to video-only for I-Frame playback"),this.generateInitSegment(t,this.decryptdata),null!=(f=this.initData)&&f.length&&(S=this.initData,this.emitInitSegment=!0,this.videoOnlyRemux=!0))}this.emitInitSegment&&(A.tracks=this.initTracks,y.initSegment=A,this.emitInitSegment=!1);let k=o.iframe,R=h&&(!k||h.includeSampleDetails)?h.tracks:function(e,t,i,r=!0){return rF(e,t,i,r)}(b,S,this,k),L=S.audio?R[S.audio.id]:null,I=S.video?R[S.video.id]:null,w=!!S.audio,D=!!S.video,C="";w&&(C+="audio"),D&&(C+="video");let M=lt(I,1/0),x=lt(L,1/0),P=lt(I,0,!0),O=lt(L,0,!0),N=a,U=0;I&&L&&S.audio&&(x>P||M>O)&&this.warn(`audio and video track sample timestamps do not overlap. v: ${M}-${P} a: ${x}-${O}}`,I,L);let F=!!L&&(!I||!v&&x<M||!!v&&v.trackId===S.audio.id),B=F?L:I;if(!B)return this.log(`No media samples found in ${l} ${o.level} ${-1===o.part?"":`part: ${o.part} of`} sn: ${o.sn} at playlist time: ${a}`),y;let $=b;if(I&&I.sampleCount>=1&&S.video&&o.iframe){let{trun:e,start:t}=I,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],s=a;for(let t=e.length;t--;)if(e[t].samples.length){s=e[t];break}let n=s.lastSampleDurationOffset,{defaultSampleDurationOffset:l}=a,d=Math.abs(o.duration-(P-M))>.05,h=r.length<I.sampleCount;if(d||h||this.videoOnlyRemux||!i){let e=h?s.sampleOffset+s.samples.reduce((e,t)=>e+t.size,0):void 0,i=d?o.duration:P-M,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*S.video.timescale,n,l),u=function(e,t,i,r,a){if(i<1)return null;let s=rD(e,["moof"]);if(1!==s.length)return null;let n=s[0],l=e.byteOffset,o=[],d=[],h=rD(n,["traf"]),u=!0;for(let e=0;e<h.length;e++){let i=h[e],r=rD(i,["tfhd"])[0];if(!r)return null;rA(r,4)===t?(o.push(i),131072&rA(r,0)||(u=!1)):d.push(rI(i,l))}if(!o.length||d.length&&!u)return null;if(void 0!==r){let t=i;for(let i=0;i<o.length;i++){let r=o[i],a=0,s=rD(r,["trun"]);for(let i=0;i<s.length;i++){let r=s[i],n=Math.min(t,rA(r,4));if(n){rR(e,r.byteOffset-l+4,n);let t=0xffffff&rA(r,0),i=(256&t?4:0)+(512&t?4:0)+(1024&t?4:0)+(2048&t?4:0);rL(e,r,8+(1&t?4:0)+(4&t?4:0)+n*i)}else rR(e,r.byteOffset-l-4,iX);t-=n,a+=n}let n=rD(r,["senc"])[0];n&&rR(e,n.byteOffset-l+4,a);let d=rD(r,["saiz"])[0];if(d){let t=d[1]<<16|d[2]<<8|d[3],i=4;1&t&&(i+=8);let r=d[i];i+=1,rR(e,d.byteOffset-l+i,a),rL(e,d,i+4+(0===r?a:0))}}let a=rD(e,["mdat"]);if(1===a.length){let t=a[0].byteOffset-l-8;rR(e,t,r-t)}}let c=e,m=0,f=()=>0;if(d.length){({result:c,dropped:m,droppedBefore:f}=rw(e,d)),rR(c,n.byteOffset-l-8,n.byteLength+8-m);for(let e=0;e<o.length;e++){let t=o[e],i=f(t.byteOffset-l),r=rD(t,["trun"]);for(let e=0;e<r.length;e++){let t=r[e];1&rA(t,0)&&rR(c,t.byteOffset-l-i+8,rA(t,8)-m)}if(i){let e=rD(t,["saio"]);for(let t=0;t<e.length;t++){let r=e[t],a=0===r[0]?4:8,s=1&rA(r,0)?12:4,n=rA(r,s);for(s+=4;n--;s+=a){let e=s+a-4;rR(c,r.byteOffset-l-i+e,rA(r,e)-i)}}}}}if(a){let{durationOffset:e,value:t}=a;rR(c,e-f(e),t)}return void 0!==r?c.subarray(0,r-m):c}(b,S.video.id,r.length,e,a);u?($=u,g=function(e,t){let i=e,r=e;for(let e=0;e<t.length;e++){let{cts:a,duration:s}=t[e];
6r=Math.max(r,i+(a||0)+s),i+=s}return r}(t,r)):this.warn(`IFrame remux skipped (sn ${o.sn}); using native sample duration`),U=u&&a?i:P-M}else U=P-M}else this.warn(`Could not remux IFrame track fragment (no samples in range, trun count ${e.length})`),U=P-M}else U=F?O-x:P-M;if(this.videoOnlyRemux&&$===b)return this.warn(`Dropping muxed I-Frame fragment that could not be remuxed to video-only (sn: ${o.sn})`),y;let H=B.timescale,G=B.start-a*H,W=F?S.audio.id:S.video.id;if(N=B.start/H,(s||!v)&&(function(e,t,i,r){if(null===e)return!0;let a=Math.max(r,1);return Math.abs(t-e.baseTime/e.timescale-i)>=a}(v,N,a,U)||H!==v.timescale)){let e=!1,t=F?"audio":"video";if(v){let i=0!==a?N/a:1+N/1;e=N>=0&&.001>Math.abs(1-i),this.log(`${t} timestamps in track ${W} at playlist time: ${s?"":"~"}${a} maps to ${N} with initPTS: ${v.baseTime/v.timescale} (${G/H-v.baseTime/v.timescale}s diff) (${C}) drift estimate: ${i} ${e?"(ignoring drift)":"remapping timestamps (initPTS)"}`)}e||(this.log(`Found initPTS in ${t} track ${W} at playlist time: ${a} offset: ${N-a} (${G}/${H})`),v=null,A.initPTS=G,A.timescale=H,A.trackId=W)}v?(A.initPTS=v.baseTime,A.timescale=v.timescale,A.trackId=v.trackId):(A.timescale&&void 0!==A.trackId&&void 0!==A.initPTS||(this.warn("Could not set initPTS"),A.initPTS=N,A.timescale=1,A.trackId=-1),this.initPTS=v={baseTime:A.initPTS,timescale:A.timescale,trackId:A.trackId});let K=N-v.baseTime/v.timescale,V=K+U,q=D&&(null==B?void 0:B.ptsMin)!==void 0?B.ptsMin/B.timescale-v.baseTime/v.timescale:K,j=void 0!==g&&I?g/I.timescale-v.baseTime/v.timescale:D&&null!=B&&B.ptsMax?B.ptsMax/B.timescale-v.baseTime/v.timescale:V;U>0?this.lastEndTime=V:(this.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());let Y={data1:$,data2:p,startPTS:q,startDTS:K,endPTS:j,endDTS:V,type:C,hasAudio:w,hasVideo:D,nb:1,dropped:0,encrypted:!!S.audio&&S.audio.encrypted||!!S.video&&S.video.encrypted};y.audio=w&&!D?Y:void 0,y.video=D?Y:void 0;let z=this.isVideoContiguous,Q=null==I?void 0:I.sampleCount;if(Q){let e=I.keyFrameIndex,t=-1!==e;Y.nb=Q,Y.dropped=0===e||z?0:t?e:Q,Y.independent=t,Y.firstKeyFrame=e,t&&I.keyFrameStart&&(Y.firstKeyFramePTS=(I.keyFrameStart-v.baseTime)/v.timescale),z||(y.independent=t),this.isVideoContiguous||(this.isVideoContiguous=t),Y.dropped&&this.warn(`fmp4 does not start with IDR: firstIDR ${e}/${Q} dropped: ${Y.dropped} start: ${Y.firstKeyFramePTS||"NA"}`)}return y.initSegment=A,y.id3=n7(i,a,v,v),r.samples.length&&(y.text=le(r,a,v)),y}}},{demux:n$,remux:n6},{demux:class extends nb{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=ix(e,0),r=(null==i?void 0:i.length)||0;if(nD(e,r))return!1;for(let i=e.length;r<i;r++)if(function(e,t){if(np(e,t)){let i=nm(e,t);if(t+i>=e.length)return!1;let r=nf(e,t);if(r<=i)return!1;let a=t+r;return a===e.length||np(e,a)}return!1}(e,r))return t.log("ADTS sync word found !"),!0;return!1}canParse(e,t){return t+5<e.length&&nc(e,t)&&nf(e,t)<=e.length-t}appendFrame(e,t,i){ng(e,this.observer,t,i,e.manifestCodec);let r=nv(e,t,i,this.basePTS,this.frameIndex);if((null==r?void 0:r.missing)===0)return r}demuxSampleAes(e,t,i){let r=this.demux(e,i),a=this.sampleAes=new nC(this.observer,this.config,t);return new Promise(e=>{a.decryptAacSamples(r.audioTrack.samples,0,()=>{e(r)})})}},remux:n6},{demux:class extends nb{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=ix(e,0),i=(null==t?void 0:t.length)||0;if(t&&11===e[i]&&119===e[i+1]&&void 0!==iF(t)&&16>=nM(e,i))return!1;for(let t=e.length;i<t;i++)if(nD(e,i))return iA.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return nI(e,t)&&4<=e.length-t}appendFrame(e,t,i){if(null!==this.basePTS)return nR(e,t,i,this.basePTS,this.frameIndex)}},remux:n6}];lr.splice(2,0,{demux:class extends nb{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=nx(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=ix(e,0);if(!t)return!1;let i=t.length;if(11===e[i]&&119===e[i+1]&&void 0!==iF(t)){if(16>nM(e,i))return!0;throw Error("Containerless ec-3 is not supported")}return!1}},remux:n6});class la{constructor(e,t,i,r,a,s){this.asyncResult=!1,this.logger=void 0,this.observer=void 0,this.typeSupp
6orted=void 0,this.config=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=e,this.typeSupported=t,this.config=i,this.id=a,this.logger=s}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(e,t,i,r){var a,n;let l;if(!this.observer)return ls(i);let o=i.transmuxing;o.executeStart=s();let d=new Uint8Array(e),{currentTransmuxState:h,transmuxConfig:u}=this;r&&(this.currentTransmuxState=r);let{contiguous:c,discontinuity:m,trackSwitch:f,accurateTimeOffset:p,timeOffset:g,initSegmentChange:v}=r||h,{audioCodec:E,videoCodec:y,defaultInitPts:b,duration:T,initSegmentData:A}=u,S=(a=d,n=t,l=null,a.byteLength>0&&(null==n?void 0:n.key)!=null&&null!==n.iv&&null!=n.method&&(l=n),l);if(S&&se(S.method)){let e=this.getDecrypter(),t=st(S.method);return this.asyncResult=!0,this.decryptionPromise=e.decrypt(d,S.key.buffer,S.iv.buffer,t,i.decryptRange).then(e=>{let t=this.push(e,null,i);return this.decryptionPromise=null,t}),this.decryptionPromise}let k=this.needsProbing(m,f);if(k){let e=i.iframe&&A&&n$.probe(A,this.logger)?A:d,t=this.configureTransmuxer(e);if(t)return this.logger.warn(`[transmuxer] ${t.message}`),this.observer.emit(tz.ERROR,tz.ERROR,{type:tj.MEDIA_ERROR,details:tY.FRAG_PARSING_ERROR,fatal:!1,error:t,reason:t.message}),o.executeEnd=s(),ls(i)}(m||f||v||k)&&this.resetInitSegment(A,E,y,T,t,i),(m||v||k)&&this.resetInitialTimestamp(b),c||this.resetContiguity();let R=this.transmux(d,S,g,p,i);this.asyncResult=ln(R);let L=this.currentTransmuxState;return L.contiguous=!0,L.discontinuity=!1,L.trackSwitch=!1,o.executeEnd=s(),R}flush(e){let t=e.transmuxing;t.executeStart=s();let{decrypter:i,currentTransmuxState:r,decryptionPromise:a}=this;if(a)return this.asyncResult=!0,a.then(()=>this.flush(e));let n=[],{timeOffset:l}=r;if(i){let t=i.flush();t&&n.push(this.push(t.buffer,null,e))}let{demuxer:o,remuxer:d}=this;if(!o||!d){t.executeEnd=s();let i=[ls(e)];return this.asyncResult?Promise.resolve(i):i}let h=o.flush(l,e);return ln(h)?(this.asyncResult=!0,h.then(t=>(this.flushRemux(n,t,e),n))):(this.flushRemux(n,h,e),this.asyncResult)?Promise.resolve(n):n}flushRemux(e,t,i){if(!this.remuxer)return;let{audioTrack:r,videoTrack:a,id3Track:n,textTrack:l}=t,{accurateTimeOffset:o,timeOffset:d}=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 h=this.remuxer.remux(r,a,n,l,d,o,!0,this.id,i,t.initData,t.sampleData);e.push({remuxResult:h,chunkMeta:i}),i.transmuxing.executeEnd=s()}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,s){let{demuxer:n,remuxer:l}=this;n&&l&&(n.resetInitSegment(e,t,i,r,a,s),l.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){return(null==t?void 0:t.method)==="SAMPLE-AES"?this.transmuxSampleAes(e,t,i,r,a):this.transmuxUnencrypted(e,i,r,a)}transmuxUnencrypted(e,t,i,r){let{demuxer:a,remuxer:s}=this;if(!a||!s)return ls(r);let n=a.demux(e,t,r,!1,!this.config.progressive),{audioTrack:l,videoTrack:o,id3Track:d,textTrack:h}=n;return{remuxResult:s.remux(l,o,d,h,t,i,!1,this.id,r,n.initData,n.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(Error("no demuxer"))}
6configureTransmuxer(e){let t,{config:i,observer:r,typeSupported:a}=this;if(!r)return;try{for(let i=0,r=lr.length;i<r;i++){var s;if(null!=(s=lr[i].demux)&&s.probe(e,this.logger)){t=lr[i];break}}}catch(e){return e}if(!t)return Error("Failed to find demuxer by probing fragment data");let n=this.demuxer,l=this.remuxer,o=t.demux,d=t.remux;n&&n instanceof o||(this.logger.log(`Using ${o.name}`),this.demuxer=new o(r,i,a,this.logger),this.probe=o.probe),l&&l 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 aG(this.config)),e}}let ls=e=>({remuxResult:{},chunkMeta:e});function ln(e){return"then"in e&&e.then instanceof Function}class ll{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}}class lo{constructor(e,t,i,r,a,s){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=s}}let ld=0;class lh{constructor(e,t,i,r){this.error=null,this.hls=void 0,this.id=void 0,this.instanceNo=ld++,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.onWorkerMessage=e=>{let t=e.data,i=this.hls;if(i&&null!=t&&t.event&&t.instanceNo===this.instanceNo)switch(t.event){case"init":{var r;let e=null==(r=this.workerContext)?void 0:r.objectURL;e&&self.URL.revokeObjectURL(e);break}case"transmuxComplete":this.handleTransmuxComplete(t.data);break;case"flush":this.onFlush(t.data);break;case"workerLog":i.logger[t.data.logType]&&i.logger[t.data.logType](t.data.message);break;default:t.data=t.data||{},t.data.frag=this.frag,t.data.part=this.part,t.data.id=this.id,i.trigger(t.event,t.data)}},this.onWorkerError=e=>{if(!this.hls)return;let t=Error(`${e.message}  (${e.filename}:${e.lineno})`);this.hls.config.enableWorker=!1,this.hls.logger.warn(`Error in "${this.id}" Web Worker, fallback to inline`),this.hls.trigger(tz.ERROR,{type:tj.OTHER_ERROR,details:tY.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:t})};const a=e.config;this.hls=e,this.id=t,this.useWorker=!!a.enableWorker,this.onTransmuxComplete=i,this.onFlush=r;const s=(e,t)=>{(t=t||{}).frag=this.frag||void 0,e===tz.ERROR&&(t.parent=this.id,t.part=this.part,this.error=t.error),this.hls.trigger(e,t)};this.observer=new nd,this.observer.on(tz.FRAG_DECRYPTED,s),this.observer.on(tz.ERROR,s);const n=r9(a.preferManagedMediaSource);if(this.useWorker&&"u">typeof Worker){const 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=nu[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 nu[e]=r,r}(a.workerPath)):(i.log(`injecting Web Worker for "${t}"`),this.workerContext=function(){let e=nu[nh];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 nu[nh]=r,r}());const{worker:e}=this.workerContext;e.addEventListener("message",this.onWorkerMessage),e.addEventListener("error",this.onWorkerError),e.postMessage({instanceNo:this.instanceNo,cmd:"init",typeSupported:n,id:t,config:am(a)})}catch(r){i.warn(`Error setting up "${t}" Web Worker, fallback to inline`,r),this.terminateWorker(),this.error=null,this.transmuxer=new la(this.observer,n,a,"",t,e.logger)}return}}this.transmuxer=new la(this.observer,n,a,"",t,e.logger)}reset(){if(this.frag=null,this.part=null,this.workerContext){let e=this.instanceNo;this.instanceNo=ld++;let t=this.hls.config,i=r9(t.preferManagedMediaSource);this.workerContext.worker.postMessage({instanceNo:this.instanceNo,cmd:"reset",resetNo:e,typeSupp
6orted:i,id:this.id,config:am(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=nu[e||nh];if(t&&1==t.clientCount--){let{worker:i,objectURL:r}=t;delete nu[e||nh],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,s,n,l,o,d){var h,u;o.transmuxing.start=self.performance.now();let{instanceNo:c,transmuxer:m}=this,f=s?s.start:a.start,p=a.decryptdata,g=this.frag,v=!g||a.cc!==g.cc,E=!g||o.level!==g.level,y=g?o.sn-g.sn:-1,b=this.part?o.part-this.part.index:-1,T=0===y&&o.id>1&&o.id===(null==g?void 0:g.stats.chunkCount),A=!E&&(1===y||0===y&&(1===b||T&&b<=0)),S=self.performance.now();(E||y||0===a.stats.parsing.start)&&(a.stats.parsing.start=S),s&&(b||!A)&&(s.stats.parsing.start=S);let k=!(g&&(null==(h=a.initSegment)?void 0:h.url)===(null==(u=g.initSegment)?void 0:u.url)),R=new lo(v,A,l,E,f,k);if(!A||v||k){this.hls.logger.log(`[transmuxer-interface]: Starting new transmux session for ${a.type} sn: ${o.sn}${o.part>-1?" part: "+o.part:""} ${this.id} playlist: ${o.level} id: ${o.id}
7        discontinuity: ${v}
8        trackSwitch: ${E}
9        contiguous: ${A}
10        accurateTimeOffset: ${l}
11        timeOffset: ${f}
12        initSegmentChange: ${k}`);let e=new ll(i,r,t,n,d);this.configureTransmuxer(e)}if(this.frag=a,this.part=s,this.workerContext)this.workerContext.worker.postMessage({instanceNo:c,cmd:"demux",data:e,decryptdata:p,chunkMeta:o,state:R},e instanceof ArrayBuffer?[e]:[]);else if(m){let t=m.push(e,p,o,R);ln(t)?t.then(e=>{this.handleTransmuxComplete(e)}).catch(e=>{this.transmuxerError(e,o,"transmuxer-interface push error")}):this.handleTransmuxComplete(t)}}flush(e){e.transmuxing.start=self.performance.now();let{instanceNo:t,transmuxer:i}=this;if(this.workerContext)this.workerContext.worker.postMessage({instanceNo:t,cmd:"flush",chunkMeta:e});else if(i){let t=i.flush(e);ln(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(tz.ERROR,{type:tj.MEDIA_ERROR,details:tY.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,part:this.part||void 0,fatal:!1,error:e,err:e,reason:i}))}handleFlushResult(e,t){e.forEach(e=>{this.handleTransmuxComplete(e)}),this.onFlush(t)}configureTransmuxer(e){let{instanceNo:t,transmuxer:i}=this;this.workerContext?this.workerContext.worker.postMessage({instanceNo:t,cmd:"configure",config:e}):i&&i.configure(e)}handleTransmuxComplete(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}}class lu extends iv{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 s,n=r[i];try{s=new self.URL(n.URI,t.url).href}catch(e){this.warn(`Could not construct new URL for Rendition Report: ${e}`),s=n.URI||""}if(s===e){a=i;break}s===e.substring(0,s.length)&&(a=i)}if(-1!==a){let e=r[a],s=parseInt(e["LAST-MSN"])||t.lastPartSn,n=parseInt(e["LAST-PART"])||t.lastPartIndex;if(this.hls.config.lowLatencyMode){let e=Math.min(t.age-t.partTarget,t.targetduration);n>=0&&e>t.partTarget&&(n+=1)}return new ah(s,n>=0?n:void 0,i&&ad(i))}}}loadPlaylist(e){this.clearTimer()}loadingPlaylist(e,t){this.clearTimer()}shouldLoadPlaylist(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}getUrlWithDirectives(e,t){if(t)try{return t.addDirectives(e)}catch(e){this.warn(`Could not construct new URL with HLS Delivery Directives: ${e}`)}return e}playlistLoaded(e,t,i){let{details:r,stats:a}=t,s=r.fragments,n=self.performance.now(),l=a.loading.first?Math.max(0,Math.floor(n-a.loading.first)):0;r.advancedDateTime=Date.now()-l;let o=this.hls.config.timelineOffset;
12if(o!==r.appliedTimelineOffset){let e=Math.max(o||0,0);r.appliedTimelineOffset=e,s.forEach(t=>{null==t||t.setStart(t.playlistOffset+e)})}if(r.live||null!=i&&i.live){var d;let o,h,u,c="levelInfo"in t?t.levelInfo:t.track;r.reloaded(i);let m=null==(d=s[s.length-1])?void 0:d.type;if(r.misses>=this.hls.config.liveMaxUnchangedPlaylistRefresh){let e=Error(`${m} playlist ${c.id} hit max allowed unchanged reloads.`);this.warn(e);let{networkDetails:i,context:s}=t;this.hls.trigger(tz.ERROR,{type:tj.NETWORK_ERROR,details:tY.PLAYLIST_UNCHANGED_ERROR,fatal:!1,url:r.url,error:e,reason:e.message,level:t.level,parent:m,context:s,networkDetails:i,stats:a});return}if(i){!function(e,t,i){let r;if(e===t)return;let a=null,s=e.fragments;for(let e=s.length-1;e>=0;e--){let t=s[e].initSegment;if(t){a=t;break}}e.fragmentHint&&delete e.fragmentHint.endPTS,function(e,t,i){var r,a,s;let n=t.skippedSegments,l=Math.max(e.startSN,t.startSN)-t.startSN,o=+!!e.fragmentHint+(n?t.endSN:Math.min(e.endSN,t.endSN))-t.startSN,d=t.startSN-e.startSN,h=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,u=null!=(r=e.fragmentHint)&&r.duration?e.fragments.concat(e.fragmentHint):e.fragments;for(let r=l;r<=o;r++){let l=u[d+r],o=h[r];if(n&&!o&&l&&(o=t.fragments[r]=l),l&&o){i(l,o,r,h);let n=l.relurl,d=o.relurl;if(n&&(a=n)!==(s=d)&&s&&sY(a)!==sY(s)){t.playlistParsingError=sH(`media sequence mismatch ${o.sn}:`,e,t,l,o);return}if(l.cc!==o.cc){t.playlistParsingError=sH(`discontinuity sequence mismatch (${l.cc}!=${o.cc})`,e,t,l,o);return}}}}(e,t,(e,i,s,n)=>{if((!t.startCC||t.skippedSegments)&&i.cc!==e.cc){let r=e.cc-i.cc;for(let e=s;e<n.length;e++)n[e].cc+=r;t.endCC=n[n.length-1].cc}tK(e.startPTS)&&tK(e.endPTS)&&(i.setStart(i.startPTS=e.startPTS),i.startDTS=e.startDTS,i.maxStartPTS=e.maxStartPTS,i.endPTS=e.endPTS,i.endDTS=e.endDTS,i.minEndPTS=e.minEndPTS,i.setDuration(e.endPTS-e.startPTS),i.duration&&(r=i),t.PTSKnown=t.alignedSliding=!0),e.hasStream
12s&&(i.elementaryStreams=e.elementaryStreams),i.loader=e.loader,e.hasStats&&(i.stats=e.stats),e.initSegment&&(i.initSegment=e.initSegment,a=e.initSegment)});let n=t.fragments,l=t.fragmentHint?n.concat(t.fragmentHint):n;if(a&&l.forEach(e=>{var t;e&&(!e.initSegment||e.initSegment.relurl===(null==(t=a)?void 0:t.relurl))&&(e.initSegment=a)}),t.skippedSegments){if(t.deltaUpdateFailed=n.some(e=>!e),t.deltaUpdateFailed){i.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let e=t.skippedSegments;e--;)n.shift();t.startSN=n[0].sn}else{t.canSkipDateRanges&&(t.dateRanges=function(e,t,i){let{dateRanges:r,recentlyRemovedDateranges:a}=t,s=ie({},e);a&&a.forEach(e=>{delete s[e]});let n=Object.keys(s).length;return n?(Object.keys(r).forEach(e=>{let t=s[e],a=new a8(r[e].attr,t);a.isValid?(s[e]=a,t||(a.tagOrder+=n)):i.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${am(r[e].attr)}"`)}),s):r}(e.dateRanges,t,i));let r=e.fragments.filter(e=>e.rawProgramDateTime);if(e.hasProgramDateTime&&!t.hasProgramDateTime)for(let e=1;e<l.length;e++)null===l[e].programDateTime&&sO(l[e],l[e-1],r);sD(r,t)}t.endCC=n[n.length-1].cc}if(!t.startCC){var o;let i=sK(e,t.startSN-1);t.startCC=null!=(o=null==i?void 0:i.cc)?o:n[0].cc}if(function(e,t,i){if(e&&t){let r=0;for(let a=0,s=e.length;a<s;a++){let s=e[a],n=t[a+r];s&&n&&s.index===n.index&&s.fragment.sn===n.fragment.sn?i(s,n):r--}}}(e.partList,t.partList,(e,t)=>{t.elementaryStreams=e.elementaryStreams,t.stats=e.stats,t.gap=e.gap||t.gap}),r){let e=t.iframesOnly&&r.type===t0.MAIN;s$(t,r,r.startPTS,r.endPTS,r.startDTS,r.endDTS,e,i)}else sG(e,t);n.length&&(t.totalduration=t.edge-n[0].start),t.driftStartTime=e.driftStartTime,t.driftStart=e.driftStart;let d=t.advancedDateTime;if(t.advanced&&d){let e=t.edge;t.driftStart||(t.driftStartTime=d,t.driftStart=e),t.driftEndTime=d,t.driftEnd=e}else t.driftEndTime=e.driftEndTime,t.driftEnd=e.driftEnd,t.advancedDateTime=e.advancedDateTime;-1===t.requestScheduled&&(t.requestScheduled=e.requestScheduled)}(i,r,this);let e=r.playlistParsingError;if(e){this.warn(e);let i=this.hls;if(!i.config.ignorePlaylistParsingErrors){let{networkDetails:s}=t;i.trigger(tz.ERROR,{type:tj.NETWORK_ERROR,details:tY.LEVEL_PARSING_ERROR,fatal:!1,url:r.url,error:e,reason:e.message,level:t.level,parent:m,networkDetails:s,stats:a});return}r.playlistParsingError=null}}-1===r.requestScheduled&&(r.requestScheduled=a.loading.start);let f=this.hls.mainForwardBufferInfo,p=f?f.end-f.len:0,g=(r.edge-p)*1e3,v=sW(r,g);r.requestScheduled+v<n?r.requestScheduled=n:r.requestScheduled<=n&&(r.requestScheduled+=v);let E=t.deliveryDirectives;if(this.log(`live playlist ${e} ${r.advanced?`REFRESHED ${r.lastPartSn} - ${r.lastPartIndex}`:r.updated?"UPDATED":`MISSED (received ${r.lastPartSn} - ${r.lastPartIndex}${E?` | requested ${E.msn} - ${E.part}`:""})`}`),!this.canLoad||!r.live)return;if(r.canBlockReload&&r.advanced){let e=this.hls.config.lowLatencyMode,a=r.lastPartSn,s=r.endSN,l=r.lastPartIndex,d=a===s;-1!==l?d?(h=s+1,u=e?0:l):(h=a,u=e?l+1:r.maxPartIndex):h=s+1;let m=r.age,f=m+r.ageHeader,p=Math.min(f-r.partTarget,1.5*r.targetduration);if(p>0){if(f>3*r.targetduration)this.log(`Playlist last advanced ${m.toFixed(2)}s ago. Omitting segment and part directives.`),h=void 0,u=void 0;else if(null!=i&&i.tuneInGoal&&f-r.partTarget>i.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${i.tuneInGoal} to: ${p} with playlist age: ${r.age}`),p=0;else{let e=Math.floor(p/r.targetduration);h+=e,void 0!==u&&(u+=Math.round(p%r.targetduration/r.partTarget)),this.log(`CDN Tune-in age: ${r.ageHeader}s last advanced ${m.toFixed(2)}s goal: ${p} skip sn ${e} to part ${u}`)}r.tuneInGoal=p}if(o=this.getDeliveryDirectives(r,t.deliveryDirectives,h,u),e||!d){r.requestScheduled=n,this.loadingPlaylist(c,o);return}}else(r.canBlockReload||r.canSkipUntil)&&(o=this.getDeliveryDirectives(r,t.deliveryDirectives,h,u));o&&void 0!==h&&r.canBlockReload&&(r.requestScheduled=a.loading.first+Math.max(v-2*l,v/2)),this.scheduleLoading(c,o,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(),s=r.requestScheduled;if(a>=s&&!this.loadingSync){this.loadingSync=!0,this.loadingPlaylist(e,t),this.loadingSync=!1;return}let n=Math.max(s-a,0);this.log(`reload live playlist ${e.name||e.bitrate+"bps"} in ${Math.round(n)} ms`),this.clearTimer(),this.timer=self.setTimeout(()=>this.loadingPlaylist(e,t),n)}getDeliveryDirectives(e,t,i,r){let a=ad(e);return null!=t&&t.skip&&e.deltaUpdateFailed&&(i=t.msn,r=t.part,a=""),new ah(i,r,a)}checkRetry(e){let t=e.details,i=ia(e),r=e.errorAction,{action:a,retryCount:s=0,retryConfig:n}=r||{},l=!!r&&!!n&&(5===a||!r.resolved&&2===a);if(l){var o,d;if(s>=n.maxNumRetry)return!1;if(i&&null!=(o=e.context)&&o.deliveryDirectives)this.warn(`Retrying playlist loading ${s+1}/${n.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{let i=ic(null==(d=e.response)?void 0:d.code);
12if(this.clearTimer(),i)this.log("Waiting for connection (offline)"),e.reason="offline",this.timer=self.setTimeout(()=>this.checkOfflineStatus(),1e3);else{let e=id(n,s);this.warn(`Retrying playlist loading ${s+1}/${n.maxNumRetry} after "${t}" in ${e}ms`),this.timer=self.setTimeout(()=>this.loadPlaylist(),e)}}e.levelRetry=!0,r.resolved=!0}return l}checkOfflineStatus(){this.clearTimer(),ic(0)?this.timer=self.setTimeout(()=>this.checkOfflineStatus(),1e3):(this.log("Connection restored (online)"),this.loadPlaylist())}}function lc(e,t){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!lm(e[i].attrs,t[i].attrs))return!1;return!0}function lm(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])}class lf{constructor(e){this.tracks=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.tracks=e}destroy(){this.tracks=this.queues=null}append(e,t,i){if(null===this.queues||null===this.tracks)return;let r=this.queues[t];r.push(e),1!==r.length||i||this.executeNext(t)}appendBlocker(e){return new Promise(t=>{this.append({label:"async-blocker",execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}},e)})}prependBlocker(e){return new Promise(t=>{this.queues&&this.queues[e].unshift({label:"async-blocker-prepend",execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}})})}removeBlockers(){null!==this.queues&&[this.queues.video,this.queues.audio,this.queues.audiovideo].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&&(null==(e=this.current("audio"))?void 0:e.label)==="block-audio"&&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(a){var i;if(r.onError(a),null===this.queues||null===this.tracks)return;let t=null==(i=this.tracks[e])?void 0:i.buffer;null!=t&&t.updating||this.shiftAndExecuteNext(e)}}}shiftAndExecuteNext(e){null!==this.queues&&(this.queues[e].shift(),this.executeNext(e))}current(e){var t;return(null==(t=this.queues)?void 0:t[e][0])||null}toString(){let{queues:e,tracks:t}=this;return null===e||null===t?"<destroyed>":`
13${this.list("video")}
14${this.list("audio")}
15${this.list("audiovideo")}}`}list(e){var t,i;return null!=(t=this.queues)&&t[e]||null!=(i=this.tracks)&&i[e]?`${e}: (${this.listSbInfo(e)}) ${this.listOps(e)}`:""}listSbInfo(e){var t;let i=null==(t=this.tracks)?void 0:t[e],r=null==i?void 0:i.buffer;return r?`SourceBuffer${r.updating?" updating":""}${i.ended?" ended":""}${i.ending?" ending":""}`:"none"}listOps(e){var t;return(null==(t=this.queues)?void 0:t[e].map(e=>e.label).join(", "))||""}}let lp=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,lg="HlsJsTrackRemovedError";class lv extends Error{constructor(e){super(e),this.name=lg}}function lE(e){let t=e.querySelectorAll("source");[].slice.call(t).forEach(t=>{e.removeChild(t)})}function ly(e){return+("audio"===e)}function lb(e,t){return`${e?"":" - triggering recovery"}${t?" with HTMLMediaElement Error: "+t.message:""}`}function lT(e){return`${e.type}_${e.sn}_${e.level}`}function lA(e,t){let{start:i,end:r}=t,a=0;for(let t=0;t<e.length;t++){let s=e[t];if(s.start>=r)break;let n=Math.max(i,s.start),l=Math.min(r,s.end);l>n&&(a+=l-n)}return a}function l_(e,t){return t.duration-e<=.05}class lS{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=1/0,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(tz.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(tz.MEDIA_ATTA
15CHING,this.onMediaAttaching,this),e.on(tz.MANIFEST_PARSED,this.onManifestParsed,this),e.on(tz.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(tz.BUFFER_CODECS,this.onBufferCodecs,this),e.on(tz.MEDIA_DETACHING,this.onMediaDetaching,this))}unregisterListener(){let{hls:e}=this;e&&(e.off(tz.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(tz.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(tz.MANIFEST_PARSED,this.onManifestParsed,this),e.off(tz.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(tz.BUFFER_CODECS,this.onBufferCodecs,this),e.off(tz.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)&&(tK(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){this.clientRect=null;return}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(e){if(!this.hls)return -1;let t=this.hls.levels;if(!t.length)return -1;let i=t.filter((t,i)=>this.isLevelAllowed(t)&&i<=e);return this.observer||(this.clientRect=null),lS.getMaxLevelByMediaSize(i,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=1/0,this.observe(),this.observer||(this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3)),this.detectPlayerSize())}stopCapping(){this.restrictedLevels=[],this.autoLevelCapping=1/0,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(e){}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,s=Math.max(t,i);for(let t=0;t<e.length;t+=1){let i=e[t];if((i.width>=s||i.height>=s)&&r(i,e[t+1])){a=t;break}}return a}}var lk=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}};let lR="Bare Item",lL=/[\x00-\x1f\x7f]+/;var lI=class{constructor(e){this.description=e}};function lw(e,t,i){return Error(`failed to serialize "${Array.isArray(e)?JSON.stringify(e):e instanceof Map?"Map{}":e instanceof Set?"Set{}":"object"==typeof e?JSON.stringify(e):String(e)}" as ${t}`,{cause:i})}function lD(e){if(e<-0x38d7ea4c67fff||0x38d7ea4c67fff<e)throw lw(e,"Integer");return e.toString()}function lC(e){let t=e.description||e.toString().slice(7,-1);if(!1===/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(t))throw lw(t,"Token");return t}function lM(e){switch(typeof e){case"number":if(!tK(e))throw lw(e,lR);if(Number.isInteger(e))return lD(e);let t=function e(t,i){if(t<0)return-e(-t,i);let r=Math.pow(10,i);if(!(Math.abs(t*r%1-.5)<Number.EPSILON))return Math.round(t*r)/r;{let e=Math.floor(t*r);return(e%2==0?e:e+1)/r}}(e,3);if(Math.floor(Math.abs(t)).toString().length>12)throw lw(e,"Decimal");let i=t.toString();return i.includes(".")?i:`${i}.0`;case"string":if(lL.test(e))throw lw(e,"String");return`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`;case"symbol":return lC(e);case"boolean":if("boolean"!=typeof e)throw lw(e,"Boolean");return e?"?1":"?0";case"object":if(e instanceof Date)return`@${lD(e.getTime()/1e3)}`;if(e instanceof Uint8Array){if(!1===ArrayBuffer.isView(e))throw lw(e,"Byte Sequence");return`:${btoa(String.fromCharCode(...e))}:`}if(e instanceof lI)return lC(e);default:throw lw(e,lR)}}function lx(e){if(!1===/^[a-z*][a-z0-9\-_.*]*$/.test(e))throw lw(e,"Key");return e}function lP(e){return null==e?"":Object.entries(e).map(([e,t])=>!0===t?`;${lx(e)}`:`;${lx(e)}=${lM(t)}`).join("")}function lO(e){return e instanceof lk?`${lM(e.value)}${lP(e.params)}`:lM(e)}function lN(e,t){return function(e,t={whitespace:!0}){if("object"!=typeof e||null==e)throw lw(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 lk==!1&&(t=new lk(t));let i=lx(e);if(!0===t.value)i+=lP(t.params);else if(i+="=",Array.isArray(t.value)){var r;i+=(r=t,`(${r.value.map(lO).join(" ")})${lP(r.params)}`)}else i+=lO(t);return i}).join(`,${r}`)}(e,t)}let lU=["url"],lF=["version","eventTargets","sid","transmissionMode"],lB=["customData","headers"],l$=e=>e instanceof lk?new lk(Math.round(e.value),e.params):Math.round(e),lH=e
15=>Array.isArray(e)?e.map(l$):l$(e),lG=(e,t)=>{if(Array.isArray(e))return e.map(e=>lG(e,t));if(e instanceof lk&&"string"==typeof e.value)return new lk(lG(e.value,t),e.params);{var i;let r;return t.baseUrl&&(e=function(e,t){let i;try{i=new URL(e)}catch(t){return e}let r=new URL(t);if(i.origin!==r.origin)return e;let a=i.pathname.split("/").slice(1),s=r.pathname.split("/").slice(1,-1),n=Math.min(a.length,s.length);for(let e=0;e<n&&a[e]===s[e];e++)a.shift(),s.shift();for(;s.length;)s.shift(),a.unshift("..");return a.join("/")+i.search+i.hash}(e,(r="string"==typeof(i=t.baseUrl)?new URL(i):i).origin+r.pathname.substring(0,r.pathname.lastIndexOf("/")+1))),1===t.version?encodeURIComponent(e):e}},lW=e=>e instanceof lk?new lk(100*Math.round(e.value/100),e.params):100*Math.round(e/100),lK=e=>Array.isArray(e)?e.map(lW):lW(e),lV={br:lH,d:lH,bl:lK,dl:lK,mtp:lK,nor:(e,t)=>{let i=e;return t.version>=2&&(e instanceof lk&&"string"==typeof e.value?i=new lk([e]):"string"==typeof e&&(i=[e])),lG(i,t)},rtp:lK,tb:lH},lq=new Map([["ps","sta"],["pr","pr"],["c","cid"],["b","bg"],["bc","br"]]),lj="event",lY="request",lz=["cen","e","h","ts"],lQ=["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"],lX=/^[a-zA-Z0-9-.]+-[a-zA-Z0-9-.]+$/;function lZ(e){return lX.test(e)}let lJ=new Set(lQ);function l0(e){return lJ.has(e)||lZ(e)}let l1=["cmsdd","cmsds","rc","smrt","ttfb","ttfbb","ttlb","url"],l2=new Set(l1),l3=new Set(lz),l4=new Set(["ab","bl","br","bsa","bsd","bsda","lab","lb","mtp","pb","tab","tb","tbl","tpb"]),l5=["bl","br","bs","cid","d","dl","mtp","nor","nrr","ot","pr","rtp","sf","sid","st","su","tb","v"],l8=new Set(l5);function l6(e){return l8.has(e)||lZ(e)}let l9=new Set(["ot","sf","st","e","sta"]),l7={[lj]:function(e){return l0(e)||l2.has(e)||l3.has(e)},[lY]:l0};function oe(e,t={}){let i={};if(null==e||"object"!=typeof e)return i;let r=t.version||e.v||2,a=t.reportingMode||lY,s=1===r?function(e){let t={};for(let[r,a]of Object.entries(e)){if(null==a){t[r]=a;continue}if("nor"===r){let e=(Array.isArray(a)?a:[a])[0];if(e instanceof lk){var i;t.nor=e.value,null!=(i=e.params)&&i.r&&(t.nrr=e.params.r)}else t.nor=e}else l4.has(r)?t[r]=function e(t,i){if(Array.isArray(t)){let r;return i&&(r=t.find(e=>{var t;return(null==(t=e.params)?void 0:t.ot)===i})),r||(r=t[0]),e(r)}return t instanceof lk?t.value:t}(a,e.ot):t[r]=a}return t}(e):e,n=1===r?l6:l7[a],l=Object.keys(s).filter(n);s.e&&"rr"!==s.e&&(l=l.filter(e=>!l2.has(e)));let o=t.filter;"function"==typeof o&&(l=l.filter(o));let d=a===lj;if(d){let e=s.e;l.includes("e")||null==e||l.push("e"),l.includes("ts")||l.push("ts"),l.includes("cen")||null==s.cen||"ce"!==e||l.push("cen");let t=e?lq.get(e):void 0;t&&null!=s[t]&&!l.includes(t)&&l.push(t)}if(0===l.length)return i;r>1&&!l.includes("v")&&l.push("v");let h={version:r,reportingMode:a,baseUrl:t.baseUrl};for(let e of(l.sort(),l)){var u,c,m;let a=s[e],n=null!=(u=null==(c=t.formatters)?void 0:c[e])?u:lV[e];if("function"==typeof n&&(a=n(a,h)),"v"===e)if(1===r)continue;else a=r;if("pr"===e&&1===a&&!(d&&"pr"===s.e))continue;d&&"ts"===e&&!tK(a)&&(a=Date.now());let l=d&&!1===a&&"bg"===e&&"b"===s.e;(("number"==typeof(m=a)?tK(m):null!=m&&""!==m&&!1!==m)||l)&&(l9.has(e)&&"string"==typeof a&&(a=new lI(a)),i[e]=a)}return i}let ot="CMCD-Object",oi="CMCD-Request",or="CMCD-Session",oa="CMCD-Status",os={ab:ot,br:ot,d:ot,lab:ot,lb:ot,ot:ot,tab:ot,tb:ot,tpb:ot,bl:oi,cs:oi,dfa:oi,dl:oi,ltc:oi,mtp:oi,nor:oi,nrr:oi,pb:oi,sn:oi,sta:oi,su:oi,tbl:oi,cid:or,msd:or,sf:or,sid:or,st:or,v:or,bg:oa,bs:oa,bsa:oa,bsd:oa,bsda:oa,cdn:oa,ec:oa,nr:oa,pr:oa,pt:oa,rtp:oa},on="CMCD";function ol(e){return lN(e,{whitespace:!1})}let oo=[...l5,...lQ,...l1,...lz].filter((e,t,i)=>i.indexOf(e)===t),od="query",oh="headers";function ou(e,t,i){var r;let a=new Set(null!=(r=t.enabledKeys)?r:[]);return{version:t.version||2,reportingMode:e,filter:e=>a.has(e),baseUrl:i}}let oc=Object.is,om=e=>e,of=Array.from(lq,([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;
15if(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 s=r.params,n=a.params,l=s&&Object.keys(s)[0],o=n&&Object.keys(n)[0];if(l!==o||void 0!==l&&void 0!==o&&s&&n&&s[l]!==n[o])return!1}return!0}(e,t),snapshot:e=>e.slice()}:{event:e,field:t,equal:oc,snapshot:om}),op=new Map(of.map(e=>[e.event,e]));function og(e){let{url:t}=e;return fetch(t,ir(e,lU))}var ov=class{constructor(e,t=og){var i;for(const r of(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=2,eventTargets:i=[],sid:r=iw(),transmissionMode:a=od}=e;return ii(ii({},ir(e,lF)),{},{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||2,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,this.config.eventTargets))this.eventTargets.set(r,{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){for(let t of(e.sid&&e.sid!==this.data.sid&&this.resetSession(),e.msd&&!isNaN(e.msd)&&(this.msd=e.msd),this.data=ii(ii(ii({},this.data),e),{},{msd:void 0}),of))t.field in e&&!t.equal(this.data[t.field],this.lastEmitted[t.field])&&this.recordEvent(t.event)}recordEvent(e,t={}){let i=op.get(e);if(i){let e=i.field,r=t[e];void 0!==r&&ie(this.data,{[e]:r});let a=this.data[e];if(void 0===a||i.equal(a,this.lastEmitted[e]))return;ie(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 s=ii(ii(ii({},this.data),r),{},{e:i,ts:null!=(a=r.ts)?a:Date.now(),sn:e.sn++});isNaN(this.msd)||e.msdSent||(s.msd=this.msd,e.msdSent=!0),e.queue.push(s)}recordResponseReceived(e,t={}){var i,r,a;let{request:s}=e,n=null!=(i=t.url)?i:null==s?void 0:s.url;if(!n)return;let l=new URL(n);l.searchParams.delete(on);let o={url:l.toString(),rc:e.status},d=e.resourceTiming;d&&(null!=d.startTime&&(o.ts=Math.round(this.timeOrigin+d.startTime),null!=d.responseStart&&(o.ttfb=Math.round(d.responseStart-d.startTime))),null!=d.duration&&(o.ttlb=Math.round(d.duration)));let h=null!=(r=null==(a=s.customData)?void 0:a.cmcd)?r:{};this.recordEvent("rr",ii(ii(ii({},h),o),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,s=ii(ii({},ir(e,lB)),{},{headers:ii({},a),customData:ii(ii({},r),{},{cmcd:{}})});if(!(null!=(i=this.config.enabledKeys)&&i.length)||!s.url)return s;let n=new URL(s.url),l=ii(ii(ii({},this.data),t),{},{sn:this.requestTarget.sn++}),o=ou(lY,this.config,s.url);isNaN(this.msd)||this.requestTarget.msdSent||(l.msd=this.msd,this.requestTarget.msdSent=!0);let d=s.customData.cmcd=oe(l,o);switch(this.config.transmissionMode){case od:let h=ol(d);h&&(n.searchParams.set(on,h),s.url=n.toString());break;case oh:ie(s.headers,function(e,t){let i={};for(let[r,a]of Object.entries(function(e,t){var i;let r={};if(!e)return r;let a=Object.keys(e),s=t?Object.keys(t).reduce((e,i)=>{var r;return null==(r=t[i])||r.forEach(t=>e[t]=i),e},{}):{};for(let t of a){let a=os[t]||s[t]||oi;(null!=(i=r[a])?i:r[a]={})[t]=e[t]}return r}(e,t))){let e=lN(a,{whitespace:!1});e&&(i[r]=e)}return i}
15(d,o.customHeaderMap))}return s}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 s=e?a.length:r.batchSize,n=a.splice(0,s);this.sendEventReport(r,n).catch(()=>{i.queue.unshift(...n)}),t||(t=a.length>0)}),t&&this.processEventTargets()}async sendEventReport(e,t){let i=ou(lj,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?ol(oe(e,t)):""})(e,i)).join("\n")+"\n"});if(410===r)this.disposeEventTarget(e);else if(429===r||r>499&&r<600)throw 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={}}};let oE=["includeKeys"];function oy(e){return Object.keys(e).every(lZ)}function ob(e,t,i,r){e&&Object.keys(t).forEach(a=>{let s=e.filter(e=>e.groupId===a).map(e=>{let s=ie({},e);return s.details=void 0,s.attrs=new a5(s.attrs),s.url=s.attrs.URI=oT(e.url,e.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",i),s.groupId=s.attrs["GROUP-ID"]=t[a],s.attrs["PATHWAY-ID"]=r,s});e.push(...s)})}function oT(e,t,i,r){if(t){let{[i]:e}=r;if(e){let i=e[t];if(i)return i}}let{HOST:a,PARAMS:s}=r,n=new self.URL(e);return a&&(n.hostname=a),s&&Object.keys(s).sort().forEach(e=>{e&&an(n,e,s[e])}),n.href}class oA{constructor(){this.status="initialized",this.requestErrors=[],this.licenseXhr=void 0,this.onmessage=void 0,this.onkeystatuseschange=void 0,this.emitter=new nd,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}}class o_ extends Error{constructor(e,t){super(t),this.data=void 0,e.error||(e.error=Error(t)),this.data=e,e.err=e.error}}class oS extends iv{constructor(e){super("eme",e.logger),this.hls=void 0,this.config=void 0,this.media=null,this.mediaResolved=void 0,this.keyFormatPromise=null,this.keySystemAccessPromises={},this.sessionSetupByUri={},this.mediaKeySessions=[],this.activeKeys={},this.mediaKeys=null,this.setMediaKeysQueue=oS.CDMCleanupPromise?[oS.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=sv(this.config));let t=e.map(sg).filter(e=>!!e);this.keyFormatPromise=this.getKeyFormatPromise(t)}this.keyFormatPromise.then(a=>{var s,n,l;let o,d,h=sf(a),u=this.activeLevelKeys();if(h===sl&&"sinf"===t)try{let e=iG(new Uint8Array(i)),t=iH(JSON.parse(e).sinf),r=rU(t);if(!r)throw Error("'schm' box missing or not cbcs/cenc with schi > tenc");o=new Uint8Array(r.subarray(8,24))}catch(e){this.warn(`${r} Failed to parse sinf: ${e}`);return}else if(h===so)o=sy(new Uint8Array(i));else if(h===sd){let e=rK(i).filter(e=>e.systemId===sp);if(e.length){let t=e[0];o=null!=(s=t.kids)&&s.length?t.kids[0]:null}}if(o){let e=iB(o);for(let r=0;r<u.length;r++){let a=u[r];if(a.keyId&&(a9(o,a.keyId)||-1!==a.uri.replace(/-/g,"").indexOf(e))){a.pssh||(a.scheme=t,a.pssh=new Uint8Array(i),a.keyId=o,sT.setKeyIdForUri(a.uri,o)),d=this.getSessionForKey(a,"encrypted-event-key-match");break}}}if(!d){if(u.length)return(n=u[0]).scheme||(n.scheme=t),(l=u[0]).pssh||(l.pssh=new Uint8Array(i)),this.getSessionForKey(u[0],"encrypted-event-no-match");if(o)throw Error(`Key ID ${iB(o)} not encountered in playlist`);this.log(`Ignoring "${e.type}" event - could not determine keyId`)}return d}).catch(e=>this.handleError(e))}},this.onWaitingForKey=e=>{this.log(`"${e.type}" event`)},this.hls=e,this.config=e.config,this.registerListeners()}destroy(){this.onDestroying(),this.onMediaDetached();let e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.config=null,this.onMediaEncrypted=this.onWaitingForKey=null}registerListeners(){let{hls:e}=this;
15e&&(e.on(tz.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(tz.MEDIA_DETACHED,this.onMediaDetached,this),e.on(tz.MANIFEST_LOADING,this.onManifestLoading,this),e.on(tz.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(tz.DESTROYING,this.onDestroying,this))}unregisterListeners(){let{hls:e}=this;e&&(e.off(tz.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(tz.MEDIA_DETACHED,this.onMediaDetached,this),e.off(tz.MANIFEST_LOADING,this.onManifestLoading,this),e.off(tz.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(tz.DESTROYING,this.onDestroying,this))}attemptKeySystemAccess(e){if(!this.hls)return Promise.reject(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 s=e=>{let n=e.shift();this.getMediaKeysPromise(n,r,a).then(e=>t({keySystem:n,mediaKeys:e})).catch(t=>{e.length?s(e):t instanceof o_?i(t):i(new o_({type:tj.KEY_SYSTEM_ERROR,details:tY.KEY_SYSTEM_NO_ACCESS,error:t,fatal:!0},t.message))})};s(e)})}requestMediaKeySystemAccess(e,t){let{requestMediaKeySystemAccessFunc:i}=this.config;if("function"!=typeof i){let e=`Configured requestMediaKeySystemAccess is not a function ${i}`;return null===sE&&"http:"===self.location.protocol&&(e=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(Error(e))}return i(e,t)}getMediaKeysPromise(e,t,i){var r;let a=function(e,t,i,r){var a,s,n,l;let o;switch(e){case sl:o=["cenc","sinf"];break;case sd:case so:o=["cenc"];break;case sn:o=["cenc","keyids"];break;default:throw Error(`Unknown key-system: ${e}`)}return a=o,s=t,n=i,[{initDataTypes:a,persistentState:(l=r).persistentState||"optional",distinctiveIdentifier:l.distinctiveIdentifier||"optional",sessionTypes:l.sessionTypes||[l.sessionType||"temporary"],audioCapabilities:s.map(e=>({contentType:`audio/mp4; codecs=${e}`,robustness:l.audioRobustness||"",encryptionScheme:l.audioEncryptionScheme||null})),videoCapabilities:n.map(e=>({contentType:`video/mp4; codecs=${e}`,robustness:l.videoRobustness||"",encryptionScheme:l.videoEncryptionScheme||null}))}]}(e,t,i,this.config.drmSystemOptions||{}),s=this.keySystemAccessPromises[e],n=null==(r=s)?void 0:r.keySystemAccess;if(!n){this.log(`Requesting encrypted media "${e}" key-system access with config: ${am(a)}`),n=this.requestMediaKeySystemAccess(e,a);let t=s=this.keySystemAccessPromises[e]={keySystemAccess:n};return n.catch(t=>{this.log(`Failed to obtain access to key-system "${e}": ${t}`)}),n.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 n.then(()=>s.mediaKeys)}getMediaKeySessionContext(e,t,i,r){let{mediaKeySessions:a}=this,s=` key-session "${e}" keyId: ${iB(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${s}`),t}this.log(`Creating${s}`);let n=t.createSession(),l={keySystem:e,mediaKeys:t,mediaKeysSession:n,keyRequests:{},keyStatuses:{},createdFor:{levelKey:i,reason:r},initialized:!1};return a.push(l),l}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 ${iB(t.keyId||[])}
16      } (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})=>sg(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=sg(e);if(!t)throw 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=sv(this.config),i=e.map(sf).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 s=t[r];
16if(e.cc<=s.cc&&(!t5(e)||!t5(s)||e.sn<s.sn)||!i&&r==a-1)return this.selectKeySystemFormat(s).then(e=>{if(!this.hls)return;s.setKeyFormat(e);let t=sf(e);if(t)return this.getKeySystemAccess([t])})}if(this.config.requireKeySystemAccessOnStart){let e=sv(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=ok(e,t[i]);if(r)return r}}loadKey(e){let t=e.decryptdata,i=this.getKeyStatus(t);if("internal-error"===i){let r=oR(i,t);return r.data.frag=e,this.error(`${r.message} (${iB(t.keyId||[])})`),Promise.reject(r)}let r=e.type,a=this.activeKeys,s=a[r];s&&!t.matches(s.decryptdata)&&(a.previous||(a.previous=[]),a.previous.push(s),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[iB(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,r=this.findContextForKey(e);if(void 0!==r)return Promise.resolve(r);let a=e.uri,s=this.sessionSetupByUri[a];i=void 0===s?this.resolveSessionForKey(e,t):s.catch(()=>void 0).then(()=>(this.throwIfDestroyed(),this.resolveSessionForKey(e,t))),this.sessionSetupByUri[a]=i;let n=()=>{this.sessionSetupByUri[a]===i&&delete this.sessionSetupByUri[a]};return i.then(n,n),i}findContextForKey(e){let{mediaKeySessions:t}=this;for(let i=t.length;i--;){let r=t[i];if(ok(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(ok(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===su)return e.uri;if(null===e.keyId)throw Error("keyId is null");return iB(e.keyId)}(t)} format: "${t.keyFormat}" URI: ${t.uri})`),r.useable.then(()=>e)}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw Error("invalid state")}handleError(e,t){if(this.hls)if(e instanceof o_){t&&(e.data.frag=t);let i=e.data.decryptdata;this.error(`${e.message}${i?` (${iB(i.keyId||[])})`:""}`),this.hls.trigger(tz.ERROR,e.data)}else this.error(e.message),this.hls.trigger(tz.ERROR,{type:tj.KEY_SYSTEM_ERROR,details:tY.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0})}getKeySystemForKeyPromise(e){let t=sf(e.keyFormat),i=t?[t]:sv(this.config);return this.attemptKeySystemAccess(i)}getKeySystemSelectionPromise(e){if(e.length||(e=sv(this.config)),0===e.length)throw new o_({type:tj.KEY_SYSTEM_ERROR,details:tY.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${am({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(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 s,n;let l=null==(s=this.config.drmSystems)||null==(s=s[e.keySystem])?void 0:s.generateRequest;if(l)try{let s=l.call(this.hls,i,r,ie({},e,{decryptdata:t,reason:a}),a);if(!s)throw Error("Invalid response from configured generateRequest filter");t.scheme=s.initDataType?s.initDataType:"cenc";let n=s.initData?s.initData:null;return t.pssh=n?new Uint8Array(n):null,s}catch(e){if(this.warn(e.message),null!=(n=this.hls)&&n.config.debug)throw e}return{initDataType:i,initData:r}}generateRequestWithPreferredKeySession(e,t,i,r,a){let s=this.getUsableKeyPromise(e,t,a);if(s)return s;let n=this.filterInitData(e,t,i,r,a);if(n&&(r=n.initData?n.initData:null,i=n.initDataType),null===r)if(a.startsWith("encrypted-event"))return Promise.reject(Error(`missing initialization data for "${a}"`));else return this.log(`Skipping key-session request for "${a}" (no initData)`),Promise.resolve(e);let l=t.uri,o=new oA;e.keyRequests[l]=o;let d=i=>{let r=e.mediaKeysSession;if(!r){o.errored=Error("invalid state");return}let{messageType:a,message:s}=i;o.status=a,this.log(`"${a}" message event for session "${r.sessionId}" message size: ${s.byteLength}`),"license-request"===a||"license-renewal"===a?this.renewLicense(e,t,s).catch(t=>{o.errored=t,o.hasListeners||this.handleError(t),this.removeSession(e)}):"license-release"===a?e.keySystem===sl&&this.updateKeySession(e,t,si("acknowledged")).then(()=>this.removeSession(e)).catch(e=>
16this.handleError(e)):this.warn(`unhandled media key message type "${a}"`)};return o.onmessage=d,sJ(e.mediaKeysSession,"message",d),this.generateRequest(e,t,i,r,a,!1)}generateRequest(e,t,i,r,a,s){if(s){let s=this.filterInitData(e,t,i,r,a);s&&(r=s.initData?s.initData:r,i=s.initDataType)}let n=t.uri,l=e.keyRequests[n],o=iB(t.keyId||[]),d=e=>{let i;e.startsWith("usable")?l.resolve():"internal-error"===e||"output-restricted"===e||"output-downscaled"===e?i=oR(e,t):"expired"===e?i=Error(`key expired (keyId: ${o})`):"released"===e?i=Error("key released"):"status-pending"===e||this.warn(`unhandled key status change "${e}" (keyId: ${o})`),i&&(l.errored=i,l.hasListeners||this.handleError(i))},h=i=>{var r,a;if(!e.mediaKeysSession){l.errored=Error("invalid state");return}let s=e.keyStatuses=this.getKeyStatuses(e);if(!Object.keys(s).some(e=>"status-pending"!==s[e]))return;let n=this.activeLevelKeys();for(let i=0;i<n.length;i++)if("expired"===s[iB(n[i].keyId||[])]){this.log(`Expired key ${am(s)} in key-session "${null==(r=e.mediaKeysSession)?void 0:r.sessionId}"`),this.renewKeySession(t,e).catch(e=>this.handleError(e));break}let h=s[o];h?d(h):(e.keyStatusTimeouts||(e.keyStatusTimeouts={}),(a=e.keyStatusTimeouts)[o]||(a[o]=self.setTimeout(()=>{var i,r;if(!e.mediaKeysSession)return;let a=this.getKeyStatus(t);if(a&&"status-pending"!==a)return this.log(`No status for keyId ${o} in key-session "${null==(r=e.mediaKeysSession)?void 0:r.sessionId}". Using session key-status ${a} from other session.`),d(a);this.log(`key status for ${o} in key-session "${null==(i=e.mediaKeysSession)?void 0:i.sessionId}" timed out after 1000ms`),d(h="internal-error")},1e3)),this.log(`No status for keyId ${o} (${am(s)}).`))};l.onkeystatuseschange=h,sJ(e.mediaKeysSession,"keystatuseschange",h);let u=l.useable;return this.log(`Generating key-session request for "${a}" keyId: ${o} URI: ${n} (init data type: ${i} length: ${r.byteLength})`),l.status="started",e.initialized=!0,e.mediaKeysSession.generateRequest(i,r).then(()=>{var t;l.status="generated",this.log(`Request generated for key-session "${null==(t=e.mediaKeysSession)?void 0:t.sessionId}" keyId: ${o} URI: ${n}`)}).catch(e=>{throw this.log(`mediaKeysSession.generateRequest failed: ${e}`),new o_({type:tj.KEY_SYSTEM_ERROR,details:tY.KEY_SYSTEM_NO_SESSION,error:e,decryptdata:t,fatal:!1},`Error generating key-session request: ${e}`)}).then(()=>u).catch(t=>{var i;this.log(`mediaKeysSession.generateRequest failed: ${t}`);let r=null==(i=t.data)?void 0:i.details;return(r===tY.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED||r===tY.KEY_SYSTEM_STATUS_INTERNAL_ERROR)&&Object.keys(e.keyStatuses).some(t=>"usable"===e.keyStatuses[t])?(this.handleError(t),e):this.removeSession(e).then(()=>{throw t})}).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 s="buffer"in a?new Uint8Array(a.buffer,a.byteOffset,a.byteLength):new Uint8Array(a);e.keySystem===so&&16===s.length&&(t[iB(s)]=r,sr(s));let n=iB(s);this.log(`key status change "${r}" for keyStatuses keyId: ${n} key-session "${i}"`),t[n]=r}),t}fetchServerCertificate(e){let t=this.config,i=new 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,s)=>{let n={type:tJ.SERVER_CERTIFICATE,responseType:"arraybuffer",url:r},l=t.certLoadPolicy.default,o={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0};i.load(n,o,{onSuccess:(e,t,i,r)=>{a(e.data)},onError:(t,i,a,l)=>{s(new o_({type:tj.KEY_SYSTEM_ERROR,details:tY.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:a,response:ii({url:n.url,data:void 0},t)},`"${e}" certificate request failed (${r}). Status: ${t.code} (${t.text})`))},onTimeout:(t,i,a)=>{s(new o_({type:tj.KEY_SYSTEM_ERROR,details:tY.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:a,response:{url:n.url,data:void 0}},`"${e}" certificate request timed out (${r})`))},onAbort:(e,t,i)=>{s(Error("aborted"))}})})):(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 o_({type:tj.KEY_SYSTEM_ERROR,details:tY.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 o_({type:tj.KEY_SYSTEM_ERROR,details:tY.KEY_SYSTEM_SESSION_UPDATE_FAILED,decryptdata:t,error:e,fatal:!1},e.message)}))}unpackPlayReadyKeyMessage(e,t){let i=iG(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 s,n;let r=null==(s=(t=a[i]).querySelector("name"))?void 0:s.textContent,l=null==(n=t.querySelector("value"))?void 0:n.textContent;r&&l&&e.setRequestHeader(r,l)}}let l=r.querySelector("Challenge"),o=null==l?void 0:l.textContent;
16if(!o)throw Error("Cannot find <Challenge> in key message");return si(atob(o))}setupLicenseXHR(e,t,i,r,a){let s=this.config.licenseXhrSetup;return s?Promise.resolve().then(()=>(this.throwIfDestroyed(),s.call(this.hls,e,t,ii(ii({},i),{},{decryptdata:r}),a))).catch(n=>{if(!i.mediaKeysSession)throw n;return e.open("POST",t,!0),s.call(this.hls,e,t,ii(ii({},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 s=function(e,t){let{drmSystems:i,widevineLicenseUrl:r}=t,a=null==i?void 0:i[e];return a?a.licenseUrl:e===sd&&r?r:void 0}(e.keySystem,this.config);if(!s)return a(Error(`no license server URL configured for key-system "${e.keySystem}"`));let n=e.keyRequests[t.uri];if(!n)return a(Error("License emitter removed"));this.log(`Sending license request to URL: ${s}`);let l=this.config.keyLoadPolicy.default,o=new XMLHttpRequest;o.responseType="arraybuffer",o.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return a(Error("invalid state"));if(4===o.readyState)if(200===o.status){n.requestErrors=[];let i=o.response;this.log(`License received ${i instanceof ArrayBuffer?i.byteLength:i}`);let a=this.config.licenseResponseCallback;if(a)try{i=a.call(this.hls,o,s,ii(ii({},e),{},{decryptdata:t}))}catch(e){this.error(e)}r(i)}else{let d=l.errorRetry,h=d?d.maxNumRetry:0;if(n.requestErrors.push({status:o.status,message:o.statusText}),n.requestErrors.length>h||o.status>=400&&o.status<500)a(new o_({type:tj.KEY_SYSTEM_ERROR,details:tY.KEY_SYSTEM_LICENSE_REQUEST_FAILED,decryptdata:t,fatal:!0,networkDetails:o,response:{url:s,data:void 0,code:o.status,text:o.statusText}},`License Request XHR failed (${s}). Status: ${o.status} (${o.statusText})`));else{let s=h-n.requestErrors.length;this.warn(`Retrying license request, ${s} attempts left`),this.requestLicense(e,t,i).then(r,a)}}},n.licenseXhr&&n.licenseXhr.readyState!==XMLHttpRequest.DONE&&n.licenseXhr.abort(),n.licenseXhr=o,this.setupLicenseXHR(o,s,e,t,i).then(({xhr:t,licenseChallenge:i})=>{e.keySystem==so&&(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,sJ(i,"encrypted",this.onMediaEncrypted),sJ(i,"waitingforkey",this.onWaitingForKey);let r=this.mediaResolved;r?r():this.mediaKeys=i.mediaKeys}onMediaDetached(){let e=this.media;e&&(s0(e,"encrypted",this.onMediaEncrypted),s0(e,"waitingforkey",this.onWaitingForKey),this.media=null,this.mediaKeys=null)}_clear(){var e;this.keyFormatPromise=null,this.keySystemAccessPromises={},this.activeKeys={},this.sessionSetupByUri={};let t=this.mediaResolved;if(t&&t(),!this.mediaKeys&&!this.mediaKeySessions.length)return;let i=this.media,r=this.mediaKeySessions.slice();this.mediaKeySessions=[],this.mediaKeys=null,sT.clearKeyUriToKeyIdMap();let a=r.length;oS.CDMCleanupPromise=Promise.all(r.map(e=>this.removeSession(e)).concat((null==i||null==(e=i.setMediaKeys(null))?void 0:e.catch(e=>{this.log(`Could not clear media keys: ${e}`),this.hls&&this.hls.trigger(tz.ERROR,{type:tj.OTHER_ERROR,details:tY.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR,fatal:!1,error:Error(`Could not clear media keys: ${e}`)})}))||Promise.resolve())).catch(e=>{this.log(`Could not close sessions and clear media keys: ${e}`),this.hls&&this.hls.trigger(tz.ERROR,{type:tj.OTHER_ERROR,details:tY.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:Error(`Could not close sessions and clear media keys: ${e}`)})}).then(()=>{a&&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){var i;
16this.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 r=this.mediaKeySessions.indexOf(e);r>-1&&this.mediaKeySessions.splice(r,1);let{keyStatusTimeouts:a}=e;a&&Object.keys(a).forEach(e=>self.clearTimeout(a[e]));let{drmSystemOptions:s}=this.config;return(s&&("persistent-license"===s.sessionType||null!=(i=s.sessionTypes)&&i.some(e=>"persistent-license"===e))?new Promise((e,i)=>{self.setTimeout(()=>i(Error("MediaKeySession.remove() timeout")),8e3),t.remove().then(e).catch(i)}):Promise.resolve()).catch(e=>{this.log(`Could not remove session: ${e}`),this.hls&&this.hls.trigger(tz.ERROR,{type:tj.OTHER_ERROR,details:tY.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR,fatal:!1,error: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(tz.ERROR,{type:tj.OTHER_ERROR,details:tY.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:Error(`Could not close session: ${e}`)})})}return Promise.resolve()}}function ok(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[iB(i)]}}function oR(e,t){let i="output-restricted"===e,r=i?tY.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:tY.KEY_SYSTEM_STATUS_INTERNAL_ERROR;return new o_({type:tj.KEY_SYSTEM_ERROR,details:r,fatal:!1,decryptdata:t},i?"HDCP level output restricted":`key status changed to "${e}"`)}oS.CDMCleanupPromise=void 0;var oL=function(){if(null!=ss&&ss.VTTCue)return self.VTTCue;let e=["","lr","rl"],t=["start","middle","end","left","right"];function i(e,t){if("string"!=typeof t||!Array.isArray(e))return!1;let i=t.toLowerCase();return!!~e.indexOf(i)&&i}function r(e){let t=1;for(;t<arguments.length;t++){let i=arguments[t];for(let t in i)e[t]=i[t]}return e}function a(a,s,n){let l={enumerable:!0};this.hasBeenReset=!1;let o="",d=!1,h=a,u=s,c=n,m=null,f="",p=!0,g="auto",v="start",E=50,y="middle",b=50,T="middle";Object.defineProperty(this,"id",r({},l,{get:function(){return o},set:function(e){o=""+e}})),Object.defineProperty(this,"pauseOnExit",r({},l,{get:function(){return d},set:function(e){d=!!e}})),Object.defineProperty(this,"startTime",r({},l,{get:function(){return h},set:function(e){if("number"!=typeof e)throw TypeError("Start time must be set to a number.");h=e,this.hasBeenReset=!0}})),Object.defineProperty(this,"endTime",r({},l,{get:function(){return u},set:function(e){if("number"!=typeof e)throw TypeError("End time must be set to a number.");u=e,this.hasBeenReset=!0}})),Object.defineProperty(this,"text",r({},l,{get:function(){return c},set:function(e){c=""+e,this.hasBeenReset=!0}})),Object.defineProperty(this,"region",r({},l,{get:function(){return m},set:function(e){m=e,this.hasBeenReset=!0}})),Object.defineProperty(this,"vertical",r({},l,{get:function(){return f},set:function(t){let r=i(e,t);if(!1===r)throw SyntaxError("An invalid or illegal string was specified.");f=r,this.hasBeenReset=!0}})),Object.defineProperty(this,"snapToLines",r({},l,{get:function(){return p},set:function(e){p=!!e,this.hasBeenReset=!0}})),Object.defineProperty(this,"line",r({},l,{get:function(){return g},set:function(e){if("number"!=typeof e&&"auto"!==e)throw SyntaxError("An invalid number or illegal string was specified.");g=e,this.hasBeenReset=!0}})),Object.defineProperty(this,"lineAlign",r({},l,{get:function(){return v},set:function(e){let r=i(t,e);if(!r)throw SyntaxError("An invalid or illegal string was specified.");v=r,this.hasBeenReset=!0}})),Object.defineProperty(this,"position",r({},l,{get:function(){return E},set:function(e){if(e<0||e>100)throw Error("Position must be between 0 and 100.");E=e,this.hasBeenReset=!0}})),Object.defineProperty(this,"positionAlign",r({},l,{get:function(){return y},set:function(e){let r=i(t,e);if(!r)throw SyntaxError("An invalid or illegal string was specified.");y=r,this.hasBeenReset=!0}})),Object.defineProperty(this,"size",r({},l,{get:function(){return b},set:function(e){if(e<0||e>100)throw Error("Size must be between 0 and 100.");b=e,this.hasBeenReset=!0}})),Object.defineProperty(this,"align",r({},l,{get:function(){return T},set:function(e){let r=i(t,e);if(!r)throw SyntaxError("An invalid or illegal string was specified.");T=r,this.hasBeenReset=!0}})),this.displayState=void 0}return a.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},a}();class oI{decode(e,t){if(!e)return"";if("string"!=typeof e)throw Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}function ow(e){function t(e,t,i,r){return(0|e)*3600+(0|t)*60+(0|i)+parseFloat(r||0)}let i=e.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return i?parseFloat(i[2])>59?t(i[2],i[3],0,i[4]):t(i[1],i[2],i[3],i[4]):null}class oD{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 oC(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);if(2===r.length)t(r[0],r[1])}}let oM=new oL(0,0,""),ox="middle"===oM.align?"middle":"center";function oP(e){return e.replace(/<br(?: \/)?>/gi,"\n")}class oO{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new oI,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=oP(e);i<e.length&&"\r"!==e[i]&&"\n"!==e[i];)++i;let r=e.slice(0,i);return"\r"===e[i]&&++i,"\n"===e[i]&&++i,t.buffer=e.slice(i),r}e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));try{let e="";if("INITIAL"===t.state){if(!/\r\n|\n/.test(t.buffer))return this;let r=(e=i()).match(/^()?WEBVTT([ \t].*)?$/);if(!(null!=r&&r[0]))throw Error("Malformed WebVTT signature.");t.state="HEADER"}let a=!1;for(;t.buffer&&/\r\n|\n/.test(t.buffer);)switch(a?a=!1:e=i(),t.state){case"HEADER":if(/:/.test(e)){var r;r=e,oC(r,function(e,t){},/:/)}else e||(t.state="ID");continue;case"NOTE":e||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(e)){t.state="NOTE";break}if(!e)continue;if(t.cue=new oL(0,0,""),t.state="CUE",-1===e.indexOf("-->")){t.cue.id=e;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{!function(e,t,i){var r;let a,s,n,l=e;
16function o(){let t=ow(e);if(null===t)throw Error("Malformed timestamp: "+l);return e=e.replace(/^[^\sa-zA-Z-]+/,""),t}function d(){e=e.replace(/^\s+/,"")}if(d(),t.startTime=o(),d(),"-->"!==e.slice(0,3))throw Error("Malformed time stamp (time stamps must be separated by '-->'): "+l);e=e.slice(3),d(),t.endTime=o(),d(),r=e,a=new oD,oC(r,function(e,t){let r;switch(e){case"region":for(let r=i.length-1;r>=0;r--)if(i[r].id===t){a.set(e,i[r].region);break}break;case"vertical":a.alt(e,t,["rl","lr"]);break;case"line":r=t.split(","),a.integer(e,r[0]),a.percent(e,r[0])&&a.set("snapToLines",!1),a.alt(e,r[0],["auto"]),2===r.length&&a.alt("lineAlign",r[1],["start",ox,"end"]);break;case"position":r=t.split(","),a.percent(e,r[0]),2===r.length&&a.alt("positionAlign",r[1],["start",ox,"end","line-left","line-right","auto"]);break;case"size":a.percent(e,t);break;case"align":a.alt(e,t,["start",ox,"end","left","right"])}},/:/,/\s/),t.region=a.get("region",null),t.vertical=a.get("vertical",""),"auto"===(s=a.get("line","auto"))&&-1===oM.line&&(s=-1),t.line=s,t.lineAlign=a.get("lineAlign","start"),t.snapToLines=a.get("snapToLines",!0),t.size=a.get("size",100),t.align=a.get("align",ox),"auto"===(n=a.get("position","auto"))&&50===oM.position&&(n="start"===t.align||"left"===t.align?0:"end"===t.align||"right"===t.align?100:50),t.position=n}(e,t.cue,t.regionList)}catch(e){t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":{let i=-1!==e.indexOf("-->");if(!e||i&&(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(e){"CUETEXT"===t.state&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state="INITIAL"===t.state?"BADWEBVTT":"BADCUE"}return this}flush(){try{if((this.cue||"HEADER"===this.state)&&(this.buffer+="\n\n",this.parse()),"INITIAL"===this.state||"BADWEBVTT"===this.state)throw Error("Malformed WebVTT signature.")}catch(e){this.onparsingerror&&this.onparsingerror(e)}return this.onflush&&this.onflush(),this}}function oN(e){let t=5381,i=e.length;for(;i;)t=33*t^e.charCodeAt(--i);return(t>>>0).toString()}let oU=/\r\n|\n\r|\n|\r/g,oF="Missing initPTS for VTT ",oB=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(!tK(t)||!tK(i)||!tK(r)||!tK(a))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*i,t+=6e4*r,t+=36e5*a};function o$(e,t,i){return oN(e.toString())+oN(t.toString())+oN(i)}let oH="stpp.ttml.im1t",oG=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,oW=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,oK={left:"start",center:"center",right:"end",start:"start",end:"end"};function oV(e,t,i,r){let a=rD(new Uint8Array(e),["mdat"]);if(0===a.length)return void r(Error("Could not parse IMSC1 mdat"));let s=a.map(e=>iO(e)),n=function(e,t=1,i=!1){return n3(e,1,1/t,i)}(t.baseTime,t.timescale);try{s.forEach(e=>i(function(e,t){let i=new DOMParser().parseFromString(e,"text/xml").getElementsByTagName("tt")[0];if(!i)throw Error("Invalid ttml");let r={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate: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 s="preserve"!==i.getAttribute("xml:space"),n=oj(oq(i,"styling","style")),l=oj(oq(i,"layout","region")),o=oq(i,"body","[begin]");return[].map.call(o,e=>{var i,r,o;let d,h,u,c=function e(t,i){return[].slice.call(t.childNodes).reduce((t,r,a)=>{var s;return"br"===r.nodeName&&a?t+"\n":null!=(s=r.childNodes)&&s.length?e(r,i):i?t+r.textContent.trim().replace(/\s+/g," "):t+r.textContent},"")}(e,s);if(!c||!e.hasAttribute("begin"))return null;let m=oQ(e.getAttribute("begin"),a),f=oQ(e.getAttribute("dur"),a),p=oQ(e.getAttribute("end"),a);if(null===m)throw oz(e);if(null===p){if(null===f)throw oz(e);p=m+f}let g=new oL(m-t,p-t,c);g.id=o$(g.startTime,g.endTime,g.text);let v=(i=l[e.getAttribute("region")],r=n[e.getAttribute("style")],o=n,d="http://www.w3.org/ns/ttml#styling",h=null,(u=null!=i&&i.hasAttribute("style")?i.getAttribute("style"):null)&&o.hasOwnProperty(u)&&(h=o[u]),["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"].reduce((e,t)=>
16{let a=oY(r,d,t)||oY(i,d,t)||oY(h,d,t);return a&&(e[t]=a),e},{})),{textAlign:E}=v;if(E){let e=oK[E];e&&(g.lineAlign=e),g.align=E}return ie(g,v),g}).filter(e=>null!==e)}(e,n)))}catch(e){r(e)}}function oq(e,t,i){let r=e.getElementsByTagName(t)[0];return r?[].slice.call(r.querySelectorAll(i)):[]}function oj(e){return e.reduce((e,t)=>{let i=t.getAttribute("xml:id");return i&&(e[i]=t),e},{})}function oY(e,t,i){return e&&e.hasAttributeNS(t,i)?e.getAttributeNS(t,i):null}function oz(e){return Error(`Could not parse ttml timestamp ${e}`)}function oQ(e,t){var i,r;let a,s;if(!e)return null;let n=ow(e);return null===n&&(oG.test(e)?(i=e,r=t,s=(0|(a=oG.exec(i))[4])+(0|a[5])/r.subFrameRate,n=(0|a[1])*3600+(0|a[2])*60+(0|a[3])+s/r.frameRate):oW.test(e)&&(n=function(e,t){let i=oW.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))),n}function oX(e,t,i,r="",a="disabled"){let s=e.ownerDocument.createElement("track");return s.kind=t,s.label=i,r&&(s.srclang=r),s.src="data:,WEBVTT",s.track.mode=a,e.appendChild(s),s}function oZ(e,t){let i=e.mode;if("disabled"===i&&(e.mode="hidden"),e.cues&&!e.cues.getCueById(t.id))try{if(e.addCue(t),!e.cues.getCueById(t.id))throw Error(`addCue is failed for: ${t}`)}catch(i){iA.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){iA.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${e}`)}}"disabled"===i&&(e.mode=i)}function oJ(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){let i;if(t<=e[0].startTime)return 0;let r=e.length-1;if(t>e[r].endTime)return -1;let a=0,s=r;for(;a<=s;)if(t<e[i=Math.floor((s+a)/2)].startTime)s=i-1;else{if(!(t>e[i].startTime)||!(a<r))return i;a=i+1}return e[a].startTime-t<t-e[s].startTime?a:s}(e,t);if(a>-1)for(let s=a,n=e.length;s<n;s++){let a=e[s];if(a.startTime>=t&&a.endTime<=i)r.push(a);else if(a.startTime>i)break}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 o0(e,t){let i=o1(e.main);if(i&&i.start<=t)return i;let r=o1(e.audio);return r&&r.start<=t?r:null}function o1(e){if(!e)return null;switch(e.state){case s3:case s2:case ne:case nt:return null}return e.frag}function o2(e,t){return t.getAppendedFrag(e,t0.MAIN)||t.getPartialFragment(e)}function o3(e,t,i,r){let a=r.latestLevelDetails,s=o2(t,i);if(nn(r.config)&&!e.nextStart&&a&&s&&r.interstitialsManager){let i="type"in s?s:s.fragment,n=aI(a,i.sn);(null==n?void 0:n.level)===i.level&&ns(n,r.interstitialsManager.playerQueue,t)&&(e.nextStart=n.start)}}function o4(){if("u">typeof self)return self.VTTCue||self.TextTrackCue}function o5(e,t,i,r,a){let s=new e(t,i,"");try{s.value=r,a&&(s.type=a)}catch(n){s=new e(t,i,am(a?ii({type:a},r):r))}return s}let o8=(()=>{let e=o4();try{e&&new e(0,1/0,"")}catch(e){return Number.MAX_VALUE}return 1/0})();function o6(){return self.SourceBuffer||self.WebKitSourceBuffer}function o9(){if(!i_())return!1;let e=o6();return!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove}class o7 extends na{constructor(e,t,i){super(e,t,i,"stream-controller",t0.MAIN),this.audioCodecSwap=!1,this.level=-1,this._forceStartLoad=!1,this._hasEnoughToStart=!1,this.altAudio=0,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||!tK(t)||(this.log(`Media seeked to ${t}`),!this.getBufferedFrag(t)))return;let i=this.getFwdBufferInfoAtPos(e,t,t0.MAIN,0);i&&0!==i.len?this.tick():this.log(`Main buffer empty at ${t} on "seeked" event: ${i?i.len:i}`)},this.registerListeners()}registerListeners(){super.registerListeners();let{hls:e}=this;e.on(tz.MANIFEST_PARSED,this.onManifestParsed,this),e.on(tz.LEVEL_LOADING,this.onLevelLoading,this),e.on(tz.LEVEL_LOADED,this.onLevelLoaded,this),e.on(tz.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(tz.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(tz.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(tz.BUFFER_CREATED,this.onBufferCreated,this),e.on(tz.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(tz.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(tz.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){super.unregisterListeners();let{hls:e}=this;e.off(tz.MANIFEST_PARSED,this.onManifestParsed,this),e.off(tz.LEVEL_LOADED,this.onLevelLoaded,this),e.off(tz.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(tz.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(tz.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(tz.BUFFER_CREATED,this.onBufferCreated,this),e.off(tz.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(tz.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(tz.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this.onMediaPlaying=this.onMediaSeeked=null,this.unregisterListeners(),super.onHandlerDestroying()}
16startLoad(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=s3,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=s2}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case nr:{let{levels:e,level:t}=this,i=null==e?void 0:e[t],r=null==i?void 0:i.details;if(!r||r.live&&(this.levelLastLoaded!==i||this.waitForLive(i)))this.hls.nextLoadLevel!==this.level&&(this.state=s3);else{if(this.waitForCdnTuneIn(r))break;this.state=s3}break}case s8:this.checkRetryDate()}this.state===s3&&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 s=i[a],n=this.getMainFwdBufferInfo();if(null===n)return;let l=this.getLevelDetails();if(l&&this._streamEnded(n,l)){let e={type:this.targetBufferType()};this.hls.trigger(tz.BUFFER_EOS,e),this.state=ne;return}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 o=s.details;if(!o||this.state===nr||this.waitForLive(s)){this.level=a,this.state=nr,this.startFragRequested=!1;return}let d=n.len,h=this.getMaxBufferLength(s.maxBitrate);if(d>=h)return;this.backtrackFragment&&this.backtrackFragment.start>n.end&&(this.backtrackFragment=void 0);let u=this.backtrackFragment?this.backtrackFragment.start:n.end,c=this.getNextFragment(u,o);if(this.couldBacktrack&&!this.fragPrevious&&c&&t5(c)&&"OK"!==this.fragmentTracker.getState(c)){var m;let e=(null!=(m=this.backtrackFragment)?m:c).sn-o.startSN,t=o.fragments[e-1];t&&c.cc===t.cc&&(c=t,this.fragmentTracker.removeFragment(t))}else this.backtrackFragment&&n.len&&(this.backtrackFragment=void 0);if(c&&this.isLoopLoading(c,u)){if(!c.gap){let e=this.audioOnly&&!this.altAudio?t1:t2,t=(e===t2?this.videoBuffer:this.mediaBuffer)||this.media;t&&this.afterBufferFlushed(t,e)}c=this.getNextFragmentLoopLoading(c,o,n,t0.MAIN,h)}!c||this.exceedsMaxBuffer(n,h,c)||this.loadFragment(c,s,u)}loadFragment(e,t,i){let r=this.fragmentTracker.getState(e);r===aM||r===aP?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(){if(this.abortCurrentFrag(),this.flushMainBuffer(0,1/0),0!==this.altAudio){var e;((null==(e=this.getLevelDetails())?void 0:e.fragmentStart)||0)>this.lastCurrentTime&&super.flushMainBuffer(0,1/0,"audio")}}getBufferOutput(){return this.mediaBuffer&&2===this.altAudio?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(tz.FRAG_CHANGED,{frag:t,previousFrag:e}),(null==e?void 0:e.level)!==i&&this.hls.trigger(tz.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 2!==this.altAudio||this.audioOnly?null:"video"}onMediaAttached(e,t){super.onMediaAttached(e,t);let i=t.media;sJ(i,"playing",this.onMediaPlaying),sJ(i,"seeked",this.onMediaSeeked)}onMediaDetaching(e,t){let{media:i}=this;i&&(s0(i,"playing",this.onMediaPlaying),s0(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(tz.BUFFER_RESET,void 0),this.couldBacktrack=!1,this.backtrackFragment=void 0,this.altAudio=0,this.audioOnly=!1}onManifestParsed(e,t){var i;let r,a=!1,s=!1;for(let e=0;e<t.levels.length;e++){let i=t.levels[e].audioCodec;i&&(a=a||-1!==i.indexOf("mp4a.40.2"),s=s||-1!==i.indexOf("mp4a.40.5"))}this.audioCodecSwitch=a&&s&&"function"!=typeof(null==(r=o6())||null==(i=r.prototype)?void 0:i.changeType),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1}onLevelLoading(e,t){let{levels:i}=this;if(!i||this.state!==s3)return;let r=t.levelInfo;(!r.details||r.details.live&&(this.levelLastLoaded!==r||r.details.expired)||this.waitForCdnTuneIn(r.details))&&(this.state=nr)}onLevelLoaded(e,t){var i,r;let{levels:a,startFragRequested:s}=this,n=t.level,l=t.details,o=l.totalduration;if(!a)return void this.warn(`Levels were reset while loading level ${n}`);this.log(`Level ${n} loaded [${l.startSN},${l.endSN}]${l.lastPartSn?`[part-${l.lastPartSn}-${l.lastPartIndex}]`:""}, cc [${l.startCC}, ${l.endCC}] duration:${o}`);let d=t.levelInfo,h=this.fragCurrent;h&&(this.state===s5||this.state===s8)&&h.level!==t.level&&h.loader&&this.abortCurrentFrag();let u=0;if(l.live||null!=(i=d.details)&&i.live){if(this.checkLiveUpdate(l),l.deltaUpdateFailed)return;u=this.alignPlaylists(l,d.details,null==(r=this.levelLastLoaded)?void 0:r.details)}if(d.details=l,this.levelLastLoaded=d,s||this.setStartPosition(l,u),this.hls.trigger(tz.LEVEL_UPDATED,{details:l,level:n}),this.state===nr){if(this.waitForCdnTuneIn(l))return;this.state=s3}s&&l.live&&this.synchronizeToLiveEdge(l),this.initPTS.some((e,t)=>{if(t>=l.startCC)return!0;delete this.initPTS[t]}),this.tick()}
16synchronizeToLiveEdge(e){let{config:t,media:i}=this;if(!i)return;let r=this.hls.liveSyncPosition,a=this.playhead,s=e.fragmentStart,n=e.edge,l=a>=s-t.maxFragLookUpTolerance&&a<=n;if(null!==r&&i.duration>r&&(a<r||!l)){let s=void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;if((!l&&i.readyState<4||a<n-s)&&(this._hasEnoughToStart||(this.nextLoadPosition=r),i.readyState))if(this.warn(`Playback: ${a} is located too far from the end of live sliding playlist: ${n}, reset currentTime to : ${r}`),"buffered"===this.config.liveSyncMode){var o;let e=aZ.bufferInfo(i,r,0);if(!(null!=(o=e.buffered)&&o.length)||e.start<=a){i.currentTime=r;return}let{nextStart:t}=aZ.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:s}=this;if(!s)return void this.warn(`Levels were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`);let n=s[i.level];if(!n)return void this.warn(`Level ${i.level} not found on progress`);let l=n.details;if(!l){this.warn(`Dropping fragment ${i.sn} of level ${i.level} after level details were reset`),this.fragmentTracker.removeFragment(i);return}let o=n.videoCodec,d=l.PTSKnown||!l.live,h=null==(t=i.initSegment)?void 0:t.data,u=this._getAudioCodec(n),c=this.transmuxer=this.transmuxer||new lh(this.hls,t0.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),m=r?r.index:-1,{decryptRange:f,byteRange:p}=aV(i,r,this.iframesOnly),g=new az(i.level,i.sn,i.stats.chunkCount,p?p.end-p.start:a.byteLength,m,-1!==m,i.duration,this.iframesOnly,f),v=this.initPTS[i.cc];c.push(a,h,u,o,i,r,l.totalduration,d,g,v)}onAudioTrackSwitching(e,t){let i=this.hls,r=0!==this.altAudio;if(aT(t.url,i))this.altAudio=1;else{if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;let e=this.fragCurrent;e&&(this.log("Switching to main audio track, cancel main fragment load"),e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();if(r){this.altAudio=0,this.fragmentTracker.removeAllFragments(),i.once(tz.BUFFER_FLUSHED,()=>{this.hls&&this.hls.trigger(tz.AUDIO_TRACK_SWITCHED,t)}),i.trigger(tz.BUFFER_FLUSHING,{startOffset:0,endOffset:1/0,type:null});return}i.trigger(tz.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){let i=aT(t.url,this.hls);if(i){let e=this.videoBuffer;e&&this.mediaBuffer!==e&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=e)}this.altAudio=2*!!i,this.tick()}onBufferCreated(e,t){let i,r,a=t.tracks,s=!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 s=!0}s&&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===t0.MAIN;if(a){if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${r?" p: "+r.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}`),this.state===s7&&(this.state=s3);return}let e=!1;if(t5(i)&&(e=!!i.gap&&!i.tagList.some(e=>"GAP"===e[0])),this.fragBufferedComplete(i,r),e){var s;i.stats.retry++;let e=null==(s=this.levels)?void 0:s[i.level];e&&e.fragmentError++}}let n=this.media;n&&(!this._hasEnoughToStart&&aZ.getBuffered(n).length&&(this._hasEnoughToStart=!0,this.seekToStartPos()),a&&this.tick())}get hasEnoughToStart(){return this._hasEnoughToStart}onError(e,t){var i;if(t.fatal){this.state=nt;return}switch(t.details){case tY.FRAG_GAP:case tY.FRAG_PARSING_ERROR:case tY.FRAG_DECRYPT_ERROR:case tY.FRAG_LOAD_ERROR:case tY.FRAG_LOAD_TIMEOUT:case tY.KEY_LOAD_ERROR:case tY.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(t0.MAIN,t);break;case tY.LEVEL_LOAD_ERROR:case tY.LEVEL_LOAD_TIMEOUT:case tY.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==nr||(null==(i=t.context)?void 0:i.type)!==tJ.LEVEL||(this.state=s3);break;case tY.BUFFER_APPEND_NO_PROGRESS:if("main"!==t.parent)return;t.frag&&(t.appendsWithoutProgress||0)>
16=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 tY.BUFFER_ADD_CODEC_ERROR:case tY.BUFFER_APPEND_ERROR:if("main"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)&&this.resetLoadingState();break;case tY.BUFFER_FULL_ERROR:if("main"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)&&(!this.config.interstitialsController&&this.config.assetPlayerId?this._hasEnoughToStart=!0:this.flushMainBuffer(0,1/0));break;case tY.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}onFragLoadEmergencyAborted(){this.state=s3,this._hasEnoughToStart||(this.startFragRequested=!1,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==t1||!this.altAudio){let e=(t===t2?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(),s=aZ.getBuffered(e),n=s.length?s.start(0):0,l=n-i,o=Math.max(this.config.maxBufferHole,this.config.maxFragLookUpTolerance);(this.config.startOnSegmentBoundary||l>0&&(l<o||this.loadingParts&&l<2*((null==a?void 0:a.partTarget)||0)))&&(this.log(`adjusting start position by ${l} to match buffer start`),i+=l,this.startPosition=i),t<i&&(this.log(`seek to target start position ${i} from current time ${t} buffer start ${n}`),e.currentTime=i)}}_getAudioCodec(e){let t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t=-1!==t.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),t}_loadBitrateTestFrag(e,t){e.bitrateTest=!0,this._doFragLoad(e,t).then(e=>{let{hls:i}=this,r=null==e?void 0:e.frag;if(!r||this.fragContextChanged(r))return;t.fragmentError=0,this.state=s3,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(tz.FRAG_LOADED,e),r.bitrateTest=!1}).catch(t=>{this.state!==s2&&this.state!==nt&&(this.warn(t),this.resetFragmentLoading(e))})}_handleTransmuxComplete(e){let t=this.playlistType,{hls:i}=this,{remuxResult:r,chunkMeta:a}=e,s=this.getCurrentContext(a);if(!s)return void this.resetWhenMissingContext(a);let{frag:n,part:l,level:o}=s,{video:d,text:h,id3:u,initSegment:c}=r,{details:m}=o,f=this.altAudio?void 0:r.audio;if(this.fragContextChanged(n))return void this.fragmentTracker.removeFragment(n);if(this.state=s9,c){let e=c.tracks;if(e){let r=n.initSegment||n;if(this.unhandledEncryptionError(c,n))return;this._bufferInitSegment(o,e,r,a),i.trigger(tz.FRAG_PARSING_INIT_SEGMENT,{frag:r,id:t,tracks:e})}let r=c.initPTS,s=c.timescale,l=this.initPTS[n.cc];if(tK(r)&&(!l||l.baseTime!==r||l.timescale!==s)){let e=c.trackId;this.initPTS[n.cc]={baseTime:r,timescale:s,trackId:e};let a=this.initPTS.slice(0);i.trigger(tz.INIT_PTS_FOUND,{timestampOffsets:a,frag:n,id:t,initPTS:r,timescale:s,trackId:e})}}if(d&&m){f&&"audiovideo"===d.type&&this.logMuxedErr(n);let e=m.fragments[n.sn-1-m.startSN],t=n.sn===m.startSN,i=!e||n.cc>e.cc;if(!1!==r.independent){let{startPTS:e,endPTS:r,startDTS:s,endDTS:o}=d;if(l)l.elementaryStreams[d.type]={startPTS:e,endPTS:r,startDTS:s,endDTS:o};else if(d.firstKeyFrame&&d.independent&&1===a.id&&!i&&(this.couldBacktrack=!0),d.dropped&&d.independent){let a=this.getMainFwdBufferInfo(),s=(a?a.end:this.getLoadPosition())+this.config.maxBufferHole,l=d.firstKeyFramePTS?d.firstKeyFramePTS:e;if(!t&&s<l-this.config.maxBufferHole&&!i)return void this.backtrack(n);i&&(n.gap=!0),n.setElementaryStreamInfo(d.type,n.start,r,n.start,o,!0)}
16else t&&e-(m.appliedTimelineOffset||0)>2&&(n.gap=!0);n.setElementaryStreamInfo(d.type,e,r,s,o),this.backtrackFragment&&(this.backtrackFragment=n),this.bufferFragmentData(d,n,l,a,t||i)}else{if(!t&&!i)return void this.backtrack(n);n.gap=!0}}if(f){let{startPTS:e,endPTS:t,startDTS:i,endDTS:r}=f;l&&(l.elementaryStreams[t1]={startPTS:e,endPTS:t,startDTS:i,endDTS:r}),n.setElementaryStreamInfo(t1,e,t,i,r),this.bufferFragmentData(f,n,l,a)}if(m&&null!=u&&u.samples.length){let e={id:t,frag:n,details:m,samples:u.samples};i.trigger(tz.FRAG_PARSING_METADATA,e)}if(m&&h){let e={id:t,frag:n,details:m,samples:h.samples};i.trigger(tz.FRAG_PARSING_USERDATA,e)}}logMuxedErr(e){this.warn(`${t5(e)?"Media":"Init"} segment with muxed audiovideo where only video expected: ${e.url}`)}_bufferInitSegment(e,t,i,a){if(this.state!==s9)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&(delete t.audio,t.audiovideo&&this.logMuxedErr(i));let{audio:s,video:n,audiovideo:l}=t;if(s){let i=e.audioCodec,a=r8(s.codec,i);if("mp4a"===a&&(a="mp4a.40.5"),this.audioCodecSwitch){a&&(a=-1!==a.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5");let e=s.metadata;e&&"channelCount"in e&&1!==(e.channelCount||1)&&!function(){if(void 0===r){let e=rV.match(/Firefox\/(\d+)/i);r=e?parseInt(e[1]):0}return r}()&&(a="mp4a.40.5")}a&&-1!==a.indexOf("mp4a.40.5")&&/Android/.test(rV)&&"audio/mpeg"!==s.container&&(a="mp4a.40.2",this.log(`Android: force audio codec to ${a}`)),i&&i!==a&&this.log(`Swapping manifest audio codec "${i}" for "${a}"`),s.levelCodec=a,s.id=t0.MAIN,this.log(`Init audio buffer, container:${s.container}, codecs[selected/level/parsed]=[${a||""}/${i||""}/${s.codec}]`),delete t.audiovideo}if(n){n.levelCodec=e.videoCodec,n.id=t0.MAIN;let i=n.codec;if((null==i?void 0:i.length)===4)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}l&&(this.iframesOnly&&this.logMuxedErr(i),this.log(`Init audiovideo buffer, container:${l.container}, codecs[level/parsed]=[${e.codecs}/${l.codec}]`),delete t.video,delete t.audio);let o=Object.keys(t);if(o.length){if(this.hls.trigger(tz.BUFFER_CODECS,t),!this.hls)return;o.forEach(e=>{let r=t[e].initSegment;null!=r&&r.byteLength&&this.hls.trigger(tz.BUFFER_APPENDING,{type:e,data:r,frag:i,part:null,chunkMeta:a,parent:i.type})})}this.tickImmediate()}getMainFwdBufferInfo(){let e=this.getBufferOutput();return this.getFwdBufferInfo(e,t0.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=s3}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 tK(t)?this.getAppendedFrag(t):null}get currentProgramDateTime(){var e;let t=(null==(e=this.media)?void 0:e.currentTime)||this.lastCurrentTime;if(tK(t)){let e=this.getLevelDetails(),i=this.currentFrag||(e?ak(null,e.fragments,t):null);if(i){let e=i.programDateTime;if(null!==e)return new Date(e+(t-i.start)*1e3)}}return null}get currentLevel(){let e=this.currentFrag;return e?e.level:-1}get nextBufferedFrag(){let e=this.currentFrag;return e?this.followingBufferedFrag(e):null}get forceStartLoad(){return this._forceStartLoad}}class de extends o7{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 s2:case ne:case nt:this.state=s3}this.state===s3?(this.hls.resumeBuffering(),this.tick(),this.currentOp=[r,t]):this.nextOp=[r,t],this.hls.off(tz.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),aZ.bufferInfo(t,e,0).len>0&&this.getBufferedAt(e))return t.currentTime=e,!0}return!1}getBufferedAt(e){return this.fragmentTracker.getBufferedFrag(e,t0.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.cachedSize-=e.data.byteLength,e.data=void 0;else{this.cached=i.filter(e=>!!e.data),this.cachedSize=i.reduce((e,{data:t})=>t?t.buffer.byteLength:0,0);break}}}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&&t5(t)&&this.cacheSet(t,new Uint8Array(r.slice(0))),super._handleFragmentLoadProgress(e)}loadFragment(e,t,i){let r=this.fragmentTracker.getState(e);(r===aM||r===aP)&&this.canReplayCached(e)?this.replayCachedFragment(e):super.loadFragment(e,t,i)}canReplayCached(e){var t;if(!this.cacheFragmentData||!(null!=(t=e.data)&&t.byteLength))return!1;let i=e.decryptdata;return(null==i?void 0:i.keyFormat)!=="identity"||!!i.key}replayCachedFragment(e){let t=e.data.slice().buffer;
16this.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 tZ;i.loading.start=i.loading.first=i.loading.end=self.performance.now(),i.loaded=i.total=t.byteLength,i.chunkCount=1,this.state=s5;let r={frag:e,part:null,payload:t,networkDetails:null};this._handleFragmentLoadProgress(r),this.hls.trigger(tz.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=s2,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?s1(aZ.getBuffered(this.media)):"none"}`)),r&&this.loadMediaAt.apply(this,r)}flushPipeline(e,t){if(t){let t=this.media;if(t){let i=aZ.bufferInfo(t,e,0),r=i.len?i.nextStart:0;r&&(this.fragmentTracker.removeFragmentsInRange(r,1/0,t0.MAIN),this.flushMainBuffer(r,1/0))}this.hls.once(tz.BUFFERED_TO_END,this.onBufferedToEnd)}this.hls.trigger(tz.BUFFER_EOS,{type:"video"})}get playhead(){return this.nextLoadPosition}startLoad(){if(!this.startFragRequested){let e=this.hls;
16e.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,t0.MAIN);return!!(null!=t&&t.endList)}}class dt extends de{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 s2:case ne:case nt:this.state=s3}if(this.state===s3){if(this.hls.resumeBuffering(),this.media||(this.media={}),this.tick(),this.state===s3){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 s=self.performance.now();(t?t.stats:e.stats).buffering.start=e.stats.buffering.start=s,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(),s=t?t.stats:e.stats;s.buffering.end=e.stats.buffering.end=a,this.hls.trigger(tz.FRAG_BUFFERED,{frag:e,part:t,stats:s,id:e.type,chunkMeta:i})},a.onerror=()=>{this.handleError("Image decode error",e,t,i)};let n=a.src;n&&self.URL.revokeObjectURL(n);let l=new Blob([r],{type:"image/jpeg"});a.src=self.URL.createObjectURL(l)}else this.state=s2,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=Error(e);this.hls.trigger(tz.ERROR,{type:tj.MEDIA_ERROR,details:tY.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=rD(new Uint8Array(e.data1),["mdat"]);0===a.length?this.handleError("Could not find I-Frame mdat",t,i,r):(this.cacheSet(t,a[0]),this.updateImage(t,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&&!t8(e,this.fragPlaying))return this.fragPlaying=e,!0}return!1}getMainFwdBufferInfo(){return{len:0,start:this.playhead,end:this.playhead,bufferedIndex:-1}}}let di={seekOnAppend:!0},dr=((h2={})[h2.Point=0]="Point",h2[h2.Range=1]="Range",h2);class da{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 dn(t,e)?ds(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,i=ds(t,e);return t-i<.1}return!1}get resumptionOffset(){let e=this.resumeOffset,t=tK(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 dn(t,e)?ds(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&&.025>Math.abs(this.resumeOffset-this.duration)))}set appendInPlace(e){if(this.appendInPlaceStarted){this.resetOnResume=!e;return}this.appendInPlaceDisabled=!e}get timelineStart(){return null!==this._timelineStart?this._timelineStart:this.startTime}set timelineStart(e){this._timelineStart=e}get duration(){let e,t=this.playoutLimit;return e=null!==this._duration?this._duration:this.dateRange.duration?this.dateRange.duration:this.dateRange.plannedDuration||0,!isNaN(t)&&t<e&&(e=t),e}set duration(e){this._duration=e}get cue(){return this.dateRange.cue}get timelineOccupancy(){return"RANGE"===this.dateRange.attr["X-TIMELINE-OCCUPIES"]?dr.Range:dr.Point}get supplementsPrimary(){return"PRIMARY"===this.dateRange.attr["X-TIMELINE-STYLE"]}get contentMayVary(){return"NO"!==this.dateRange.attr["X-CONTENT-MAY-VARY"]}get assetUrl(){return this.dateRange.attr["X-ASSET-URI"]}get assetListUrl(){return this.dateRange.attr["X-ASSET-LIST"]}get baseUrl(){return this.base.url}get assetListLoaded(){return this.assetList.length>0||null!==this.assetListResponse}toString(){var e;return e=this,`["${e.identifier}" ${e.cue.pre?"<pre>":e.cue.post?"<post>":""}${e.timelineStart.toFixed(2)}-${e.resumeTime.toFixed(2)}]`}}function ds(e,t){return e-t.start<t.duration/2&&!(.025>Math.abs(e-(t.start+t.duration)))?t.start:t.start+t.duration}function dn(e,t){return t>e.start-.025&&t<e.start+e.duration+.025}function dl(e,t,i){let r=new self.URL(e,i);return"data:"!==r.protocol&&an(r,"_HLS_primary_id",t),r}function dd(e,t){for(;null!=(i=e.assetList[++t])&&i.error;)var i;return t}function dh(e){let t=e.timelineStart,i=e.duration||0;return`["${e.identifier}" ${t.toFixed(2)}-${(t+i).toFixed(2)}]`}class du{constructor(e,t,i,r){this.hls=void 0,this.interstitial=void 0,this.assetItem=void 0,this.tracks=null,this.hasDetail
16s=!1,this.mediaAttached=null,this._currentTime=void 0,this._bufferedEosTime=void 0,this.checkPlayout=()=>{this.reachedPlayout(this.currentTime)&&this.hls&&this.hls.trigger(tz.PLAYOUT_LIMIT_REACHED,{})};const a=this.hls=new e(t);this.interstitial=i,this.assetItem=r;const s=()=>{this.hasDetails=!0};a.once(tz.LEVEL_LOADED,s),a.once(tz.AUDIO_TRACK_LOADED,s),a.once(tz.SUBTITLE_TRACK_LOADED,s),a.on(tz.MEDIA_ATTACHING,(e,{media:t})=>{this.removeMediaListeners(),this.mediaAttached=t,this.interstitial.playoutLimit&&(t.addEventListener("timeupdate",this.checkPlayout),this.appendInPlace&&a.on(tz.BUFFER_APPENDED,()=>{let e=this.bufferedEnd;this.reachedPlayout(e)&&(this._bufferedEosTime=e,a.trigger(tz.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=dl(t,e.config.primarySessionId||"").href}catch(e){}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),s=aZ.bufferInfo(e,a,.02);return this.getAssetTime(s.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=aZ.bufferInfo(e,e.currentTime,.001);return this.getAssetTime(t.end)}get currentTime(){let e=this.media||this.mediaAttached;return e?this.getAssetTime(e.currentTime):this._currentTime||0}get duration(){let e=this.assetItem.duration;if(!e)return 0;let t=this.interstitial.playoutLimit;if(t){let i=t-this.startOffset;if(i>0&&i<e)return i}return e}get remaining(){let e=this.duration;return e?Math.max(0,e-this.currentTime):0}get startOffset(){return this.assetItem.startOffset}get timelineOffset(){var e;return(null==(e=this.hls)?void 0:e.config.timelineOffset)||0}set timelineOffset(e){let t=this.timelineOffset;if(e!==t&&Math.abs(e-t)>1/9e4&&this.hls){if(this.hasDetails)throw Error("Cannot set timelineOffset after playlists are loaded");this.hls.config.timelineOffset=e}}getAssetTime(e){return Math.min(Math.max(0,e-this.timelineOffset),this.duration)}removeMediaListeners(){let e=this.mediaAttached;e&&(this._currentTime=e.currentTime,this.bufferSnapShot(),e.removeEventListener("timeupdate",this.checkPlayout))}bufferSnapShot(){if(this.mediaAttached){var e;null!=(e=this.hls)&&e.bufferedToEnd&&(this._bufferedEosTime=this.bufferedEnd)}}destroy(){this.removeMediaListeners(),this.hls&&this.hls.destroy(),this.hls=null,this.tracks=this.mediaAttached=this.checkPlayout=null}attachMedia(e){var t;this.loadSource(),null==(t=this.hls)||t.attachMedia(e)}detachMedia(){var e;this.removeMediaListeners(),this.mediaAttached=null,null==(e=this.hls)||e.detachMedia()}resumeBuffering(){var e;null==(e=this.hls)||e.resumeBuffering()}pauseBuffering(){var e;null==(e=this.hls)||e.pauseBuffering()}transferMedia(){var e;return this.bufferSnapShot(),(null==(e=this.hls)?void 0:e.transferMedia())||null}resetDetails(){let e=this.hls;if(e&&this.hasDetails){e.stopLoad();let t=e=>delete e.details;e.levels.forEach(t),e.allAudioTracks.forEach(t),e.allSubtitleTracks.forEach(t),this.hasDetails=!1}}on(e,t,i){var r;null==(r=this.hls)||r.on(e,t)}once(e,t,i){var r;null==(r=this.hls)||r.once(e,t)}off(e,t,i){var r;null==(r=this.hls)||r.off(e,t)}toString(){var e;return`HlsAssetPlayer: ${dh(this.assetItem)} ${null==(e=this.hls)?void 0:e.sessionId} ${this.appendInPlace?"append-in-place":""}`}}class dc extends iv{constructor(e,t){super("interstitials-sched",t),this.onScheduleUpdate=void 0,this.eventMap={},this.events=null,this.items=null,this.durations={primary:0,playout:0,integrated:0},this.onScheduleUpdate=e}destroy(){this.reset(),this.onScheduleUpdate=null}reset(){this.eventMap={}
16,this.setDurations(0,0,0),this.events&&this.events.forEach(e=>e.reset()),this.events=this.items=null}resetErrorsInRange(e,t){return this.events?this.events.reduce((i,r)=>e<=r.startOffset&&t>r.startOffset?(delete r.error,i+1):i,0):0}get duration(){let e=this.items;return e?e[e.length-1].end:0}get length(){return this.items?this.items.length:0}getEvent(e){return e&&this.eventMap[e]||null}hasEvent(e){return e in this.eventMap}findItemIndex(e,t){if(e.event)return this.findEventIndex(e.event.identifier);let i=-1;e.nextEvent?i=this.findEventIndex(e.nextEvent.identifier)-1:e.previousEvent&&(i=this.findEventIndex(e.previousEvent.identifier)+1);let r=this.items;if(r)for(r[i]||(void 0===t&&(t=e.start),i=this.findItemIndexAtTime(t));i>=0&&null!=(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 s=a.start,n=i[r].event,l=null!=n&&n.cue.pre?n.duration:a.end;if(e===s||e>s&&e<l)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,s=this.events,n=this.parseDateRanges(a,{url:r.url},t),l=Object.keys(a),o=s?s.filter(e=>-1===l.indexOf(e.identifier)):[];n.length&&n.sort((e,t)=>{let i=e.cue.pre,r=e.cue.post,a=t.cue.pre,s=t.cue.post;if(i&&!a)return -1;if(a&&!i||r&&!s)return 1;if(s&&!r)return -1;if(!i&&!a&&!r&&!s){let i=e.startTime,r=t.startTime;if(i!==r)return i-r}return e.dateRange.tagOrder-t.dateRange.tagOrder}),this.events=n,o.forEach(e=>{this.removeEvent(e)}),this.updateSchedule(e,o,i)}updateSchedule(e,t=[],i=0,r=!1){let a=this.events||[];
16if(a.length||t.length||this.length<2){let s=this.items,n=this.parseSchedule(a,e,i);(r||t.length||(null==s?void 0:s.length)!==n.length||n.some((e,t)=>Math.abs(e.playout.start-s[t].playout.start)>.005||Math.abs(e.playout.end-s[t].playout.end)>.005))&&(this.items=n,this.onScheduleUpdate(t,s))}}parseDateRanges(e,t,i){let r=[],a=Object.keys(e);for(let s=0;s<a.length;s++){let n=a[s],l=e[n];if(l.isInterstitial){let e=this.eventMap[n];e?e.setDateRange(l):(e=new da(l,t),this.eventMap[n]=e,!1===i&&(e.appendInPlace=i)),r.push(e)}}return r}parseSchedule(e,t,i=0){let r=[],a=t.main.details,s=a.live?1/0:a.edge,n=0;if((e=e.filter(e=>!e.error&&!(e.cue.once&&e.hasPlayed))).length){this.resolveOffsets(e,t);let o=0,d=0;if(e.forEach((t,l)=>{let h=t.cue.pre,u=t.cue.post,c=e[l-1]||null,m=t.appendInPlace,f=u?s:t.startOffset,p=t.duration,g=t.timelineOccupancy===dr.Range?p:0,v=h&&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(h||!u&&f<=0){let e=d;d+=g,t.timelineStart=b;let i=n;n+=p,r.push({event:t,start:b,end:T,playout:{start:i,end:n},integrated:{start:e,end:d}})}else{if(!(f<=s))return;if(!y){let i=f-o;if(i>.033){let a=o,s=d;d+=i;let h=n;n+=i;let u={previousEvent:e[l-1]||null,nextEvent:t,start:a,end:a+i,playout:{start:h,end:n},integrated:{start:s,end:d}};r.push(u)}else i>0&&c&&(c.cumulativeDuration+=i,r[r.length-1].end=f)}u&&(T=b),t.timelineStart=b;let i=d;d+=g;let a=n;n+=p,r.push({event:t,start:b,end:T,playout:{start:a,end:n},integrated:{start:i,end:d}})}let A=v||t.resumeTime;o=u||A>s?s:!h&&T&&t.appendInPlaceStarted&&A-T>.033?T:A}),o<s){var l;let e=o,t=d,i=s-o;d+=i;let a=n;n+=i,r.push({previousEvent:(null==(l=r[r.length-1])?void 0:l.event)||null,nextEvent:null,start:o,end:e+i,playout:{start:a,end:n},integrated:{start:t,end:d}})}this.setDurations(s,n,d)}else r.push({previousEvent:null,nextEvent:null,start:0,end:s,playout:{start:0,end:s},integrated:{start:0,end:s}}),this.setDurations(s,s,s);return 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,s=-1;e.forEach((n,l)=>{let o=n.cue.pre,d=n.cue.post,h=o?0:d?r:n.startTime;this.updateAssetDurations(n),s===h?n.cumulativeDuration=a:(a=0,s=h),!d&&n.snapOptions.in&&(n.resumeAnchor=ak(null,i.fragments,n.startOffset+n.resumptionOffset,0,0)||void 0),n.appendInPlace&&!n.appendInPlaceStarted&&(this.primaryCanResumeInPlaceAt(n,t)||(n.appendInPlace=!1)),!n.appendInPlace&&l+1<e.length&&e[l+1].startTime-e[l].resumeTime<.033&&(e[l+1].appendInPlace=!1,e[l+1].appendInPlace&&this.warn(`Could not change append strategy for abutting event ${n}`));let u=tK(n.resumeOffset)?n.resumeOffset:n.duration;a+=u})}primaryCanResumeInPlaceAt(e,t){let i=e.resumeTime,r=e.startTime+e.resumptionOffset;return Math.abs(i-r)>.025?(this.log(`"${e.identifier}" resumption ${i} not aligned with estimated timeline end ${r}`),!1):!Object.keys(t).some(r=>{let a=t[r].details,s=a.edge;if(i>=s)return this.log(`"${e.identifier}" resumption ${i} past ${r} playlist end ${s}`),!1;let n=ak(null,a.fragments,i);if(!n)return this.log(`"${e.identifier}" resumption ${i} does not align with any fragments in ${r} playlist (${a.fragStart}-${a.fragmentEnd})`),!0;let l=.175*("audio"===r);return!(Math.abs(n.start-i)<.025+l||Math.abs(n.end-i)<.025+l)&&(this.log(`"${e.identifier}" resumption ${i} not aligned with ${r} fragment bounds (${n.start}-${n.end} sn: ${n.sn} cc: ${n.cc})`),!0)})}updateAssetDurations(e){if(!e.assetListLoaded)return;let t=e.timelineStart,i=0,r=!1,a=!1;for(let s=0;s<e.assetList.length;s++){let n=e.assetList[s],l=t+i;n.startOffset=i,n.timelineStart=l,r||(r=null===n.duration),a||(a=!!n.error),i+=n.error?0:n.duration||0}r&&!a?e.duration=Math.max(i,e.duration):e.duration=i}removeEvent(e){e.reset(),delete this.eventMap[e.identifier]}}function dm(e){return`[${e.event?'"'+e.event.identifier+'"':"primary"}: ${e.start.toFixed(2)}-${e.end.toFixed(2)}]`}class df{constructor(e){this.hls=void 0,this.hls=e}destroy(){this.hls=null}loadAssetList(e,t){let i,r=e.assetListUrl;try{i=dl(r,this.hls.sessionId,e.baseUrl)}catch(i){let t=this.assignAssetListError(e,tY.ASSET_LIST_LOAD_ERROR,i,r);this.hls.trigger(tz.ERROR,t);return}t&&"data:"!==i.protocol&&an(i,"_HLS_start_offset",""+t);let a=this.hls.config,s=new a.loader(a),n={type:tJ.INTERSTITIAL_ASSET_LIST,responseType:"json",url:i.href},l=a.interstitialAssetListLoadPolicy.default,o={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0};return s.load(n,o,{onSuccess:(t,i,r,a)=>{let s=t.data;if(!Array.isArray(null==s?void 0:s.ASSETS)){let t=this.assignAssetListError(e,tY.ASSET_LIST_PARSING_ERROR,Error("Invalid interstitial asset list"),r.url,i,a);this.hls.trigger(tz.ERROR,t);return}e.assetListResponse=s,this.hls.trigger(tz.ASSET_LIST_LOADED,{event:e,assetListResponse:s,networkDetails:a})},onError:(t,i,r,a)=>{let s=this.assignAssetListError(e,tY.ASSET_LIST_LOAD_ERROR,Error(`Error loading X-ASSET-LIST: HTTP status ${t.code} ${t.text} (${i.url})`),i.url,a,r);this.hls.trigger(tz.ERROR,s)},onTimeout:(t,i,r)=>{let a=this.assignAssetListError(e,tY.ASSET_LIST_LOAD_TIMEOUT,Error(`Timeout loading X-ASSET-LIST (${i.url})`),i.url,t,r);this.hls.trigger(tz.ERROR,a)}}),this.hls.trigger(tz.ASSET_LIST_LOADING,{event:e}),s}assignAssetListError(e,t,i,r,a,s){return e.error=i,{type:tj.NETWORK_E
16RROR,details:t,fatal:!1,interstitial:e,url:r,error:i,networkDetails:s,stats:a}}}function dp(e){var t;null==e||null==(t=e.play())||t.catch(()=>{})}function dg(e,t){return`[${e}] Advancing timeline position to ${t}`}class dv{constructor(e){this.buffered=void 0;const t=(t,i,r)=>{if((i>>>=0)>r-1)throw new DOMException(`Failed to execute '${t}' on 'TimeRanges': The index provided (${i}) is greater than the maximum bound (${r})`);return e[i][t]};this.buffered={get length(){return e.length},end:i=>t("end",i,e.length),start:i=>t("start",i,e.length)}}}let dE={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},dy=e=>String.fromCharCode(dE[e]||e),db={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},dT={17:2,18:4,21:6,22:8,23:10,19:13,20:15},dA={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},d_={25:2,26:4,29:6,30:8,31:10,27:13,28:15},dS=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class dk{constructor(){this.time=null,this.verboseLevel=0}log(e,t){if(this.verboseLevel>=e){let i="function"==typeof t?t():t;iA.log(`${this.time} [${e}] ${i}`)}}}let dR=function(e){let t=[];for(let i=0;i<e.length;i++)t.push(e[i].toString(16));return t},dL=Object.freeze({foreground:"white",underline:!1,italics:!1,background:"black",flash:!1});class dI{constructor(){this.styles=dL}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=dL}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}}class dw{constructor(){this.uchar=" ",this.penState=new dI}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}}class dD{constructor(e){this.chars=[],this.pos=0,this.currPenState=new dI,this.cueStartTime=null,this.logger=void 0;for(let e=0;e<42;e++)this.chars.push(new dw);this.logger=e}equals(e){let t=this.chars,i=e.chars;for(let e=0;e<42;e++){let r=t[e],a=i[e];if(r.uchar!==a.uchar)return!1;let s=r.penState.styles,n=a.penState.styles;if(s!==n&&(s.foreground!==n.foreground||s.underline!==n.underline||s.italics!==n.italics||s.background!==n.background||s.flash!==n.flash))return!1}return!0}copy(e){for(let t=0;t<42;t++)this.chars[t].copy(e.chars[t])}isEmpty(){let e=this.chars;for(let t=0;t<42;t++){let i=e[t];if(" "!==i.uchar)return!1;let r=i.penState.styles;if(r!==dL&&("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>=42&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=41)}moveCursor(e){let t=Math.min(this.pos+e,42);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=dy(e);this.pos>=42?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<42;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<42;i++){let r=this.chars[i].uchar;" "!==r&&(t=!1),e.push(r)}return t?"":e.join("")}setPenStyles(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)}}class dC{constructor(e){this.rows=[],this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(let t=0;t<15;t++)this.rows.push(new dD(e));this.logger=e}reset(){for(let e=0;e<15;e++)this.rows[e].clear();this.currRow=14}equals(e){let t=!0;for(let i=0;i<15;i++)if(!this.rows[i].equals(e.rows[i])){t=!1;break}return t}copy(e){for(let t=0;t<15;t++){let i=this.rows[t].chars,r=e.rows[t].chars;for(let e=0;e<42;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<15;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e}backSpace(){this.rows[this.currRow].backSpace()}clearToEndOfRow(){this.rows[this.currRow].clearToEndOfRow()}insertChar(e){this.rows[this.currRow].insertChar(e)}setPen(e){this.rows[this.currRow].setPenStyles(e)}moveCursor(e){this.rows[this.currRow].moveCursor(e)}setCursor(e){this.logger.log(2,"setCursor: "+e),this.rows[this.currRow].setCursor(e)}setPAC(e){this.logger.log(2,()=>"pacData = "+am(e));let t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(let e=0;e<15;e++)this.rows[e].clear();let e=this.currRow+1-this.nrRollUpRows,i=this.lastOutputScreen;if(i){let r=i.rows[e].cueStartTime,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=Math.max(e.indent-1,0);i.setCursor(e.indent),e.color=i.chars[t].penState.foreground}let r={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(r)}setBkgData(e){this.logger.log(2,()=>"bkgData = "+am(e)),this.backSpace(),this.setPen(e),this.insertChar(32)}setRollUpRows(e){this.nrRollUpRows=e}rollUp(){if(null===this.nrRollUpRows)return void this.logger.log(3,"roll_up but nrRollUpRows not set yet");this.logger.log(1,()=>this.getDisplayText());let e=this.currRow+1-this.nrRollUpRows,t=this.rows.splice(e,1)[0];t.clear(),this.rows.splice(this.currRow,0,t),this.logger.log(2,"Rolling up")}getDisplayText(e){e=e||!1;let t=[],i="",r=-1;for(let i=0;i<15;i++){let 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}}class dM{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 dC(i),this.nonDisplayedMemory=new dC(i),this.lastOutputScreen=new dC(i),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=i}reset(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}getHandler(){return this.outputFilter}setHandler(e){this.outputFilter=e}setPAC(e){this.writeScreen.setPAC(e)}setBkgData(e){this.writeScreen.setBkgData(e)}setMode(e){e!==this.mode&&(this.mode=e,this.logger.log(2,()=>"MODE="+e),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)}insertChars(e){for(let t=0;t<e.length;t++)this.writeScreen.insertChar(e[t]);let t=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,()=>t+": "+this.writeScreen.getDisplayText(!0)),("MODE_PAINT-ON"===this.mode||"MODE_ROLL-UP"===this.mode)&&(this.logger.log(1,()=>"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())}ccRCL(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}ccBS(){this.logger.log(2,"BS - BackSpace"),"MODE_TEXT"!==this.mode&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}ccAOF(){}ccAON(){}ccDER(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}ccRU(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)}ccFON(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}
16ccRDC(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}ccTR(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}ccRTD(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}ccEDM(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}ccCR(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}ccENM(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}ccEOC(){if(this.logger.log(2,"EOC - End Of Caption"),"MODE_POP-ON"===this.mode){let e=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,()=>"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)}ccTO(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)}ccMIDROW(e){let t={flash:!1};(t.underline=e%2==1,t.italics=e>=46,t.italics)?t.foreground="white":t.foreground=["white","green","blue","cyan","red","yellow","magenta"][Math.floor(e/2)-16],this.logger.log(2,"MIDROW: "+am(t)),this.writeScreen.setPen(t)}outputDataUpdate(e=!1){let t=this.logger.time;null!==t&&this.outputFilter&&(null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t):this.cueStartTime=t,this.lastOutputScreen.copy(this.displayedMemory))}cueSplitAtTime(e){this.outputFilter&&!this.displayedMemory.isEmpty()&&(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e)}}class dx{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 dk,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 dM(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){var i,r,a,s,n,l,o,d;let h=127&t[e],u=127&t[e+1],c=!1,m=null;if(0===h&&0===u)continue;this.logger.log(3,()=>"["+dR([t[e],t[e+1]])+"] -> ("+dR([h,u])+")");let f=this.cmdHistory;if(h>=16&&h<=31){if(i=h,r=u,(a=f).a===i&&a.b===r){(s=f).a=null,s.b=null,this.logger.log(3,()=>"Repeated command ("+dR([h,u])+") is dropped");continue}n=h,l=u,(o=this.cmdHistory).a=n,o.b=l,(c=this.parseCmd(h,u))||(c=this.parseMidrow(h,u)),c||(c=this.parsePAC(h,u)),c||(c=this.parseBackgroundAttributes(h,u))}else{(d=f).a=null,d.b=null}if(!c&&(m=this.parseChars(h,u))){let e=this.currentChannel;e&&e>0?this.getChannel(e).insertChars(m):this.logger.log(2,"No channel found yet. TEXT-MODE?")}c||m||this.logger.log(2,()=>"Couldn't parse cleaned data "+dR([h,u])+" orig: "+dR([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)!==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 ("+dR([e,t])+")"),!0)}return!1}parsePAC(e,t){let i,r=(e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127,a=(16===e||24===e)&&t>=64&&t<=95;if(!(r||a))return!1;let s=e<=23?1:2;return i=t>=64&&t<=95?1===s?db[e]:dA[e]:1===s?dT[e]:d_[e],this.getChannel(s).setPAC(this.interpretPAC(i,t)),this.currentChannel=s,!0}interpretPAC(e,t){let i,r={color:null,italics:!1,indent:null,underline:!1,row:e};return r.underline=(1&(i=t>95?t-96:t-64))==1,i<=13?r.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(i/2)]:i<=15?(r.italics=!0,r.color="white"):r.indent=4*Math.floor((i-16)/2),r}parseChars(e,t){let i,r=null,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 '"+dy(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 =  "+dR(r).join(",")),r}
16parseBackgroundAttributes(e,t){if(!((16===e||24===e)&&t>=32&&t<=47||(23===e||31===e)&&t>=45&&t<=47))return!1;let i={};return 16===e||24===e?(i.background=dS[Math.floor((t-32)/2)],t%2==1&&(i.background=i.background+"_semi")):45===t?i.background="transparent":(i.foreground="black",47===t&&(i.underline=!0)),this.getChannel(e<=23?1:2).setBkgData(i),!0}reset(){var e;for(let e=0;e<Object.keys(this.channels).length;e++){let t=this.channels[e];t&&t.reset()}(e=this.cmdHistory).a=null,e.b=null}cueSplitAtTime(e){for(let t=0;t<this.channels.length;t++){let i=this.channels[t];i&&i.cueSplitAtTime(e)}}}class dP{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 dO(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}let dN=/\s/,dU={newCue(e,t,i,r){let a,s,n,l,o,d=[],h=self.VTTCue||self.TextTrackCue;for(let c=0;c<r.rows.length;c++)if(a=r.rows[c],n=!0,l=0,o="",!a.isEmpty()){var u;for(let e=0;e<a.chars.length;e++)dN.test(a.chars[e].uchar)&&n?l++:(o+=a.chars[e].uchar,n=!1);a.cueStartTime=t,t===i&&(i+=1e-4),l>=16?l--:l++;let r=oP(o.trim()),m=o$(t,i,r);null!=e&&null!=(u=e.cues)&&u.getCueById(m)||((s=new h(t,i,r)).id=m,s.line=c+1,s.align="left",s.position=10+Math.min(80,10*Math.floor(8*l/32)),d.push(s))}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=>oZ(e,t))),d}};class dF{constructor(){this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=0,this.config=null,this.callbacks=null,this.context=null,this.stats=new tZ}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 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(iu(e,this.stats.retry,!0))this.retry(e);else{var t;iA.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=id(e,i.retry),i.retry++,iA.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)}}let dB=/(\d+)-(\d+)\/(\d+)/;class d$ extends dF{constructor(e){super(),this.fetchSetup=void 0,this.request=null,this.response=null,this.controller=null,this.fetchSetup=e.fetchSetup||dH}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(){var e;let t,{config:i,context:r,stats:a}=this;if(!i||!r)return;a.loading.first=0,a.loaded=0,a.aborted=!1,this.controller=new self.AbortController;let s=(e=r,t={method:"GET",mode:"cors",credentials:"same-origin",signal:this.controller.signal,headers:new self.Headers(ie({},e.headers))},e.rangeEnd&&t.headers.set("Range","bytes="+e.rangeStart+"-"+String(e.rangeEnd-1)),t),n="arraybuffer"===r.responseType,l=n?"byteLength":"length",{maxTimeToFirstByteMs:o,maxLoadTimeMs:d}=i.loadPolicy;this.request=this.fetchSetup(r,s),self.clearTimeout(this.requestTimeout),i.timeout=o&&tK(o)?o:d,this.requestTimeout=self.setTimeout(()=>{this.loadtimeout()},i.timeout),(ln(this.request)?this.request.then(self.fetch):self.fetch(this.request)).then(e=>{var t;this.response=e;let s=Math.max(self.performance.now(),a.loading.start);
16if(self.clearTimeout(this.requestTimeout),i.timeout=d,this.requestTimeout=self.setTimeout(()=>{this.loadtimeout()},d-(s-a.loading.start)),!e.ok){let{status:t,statusText:i}=e;throw new dG(i||"fetch, bad network response",t,e)}a.loading.first=s,a.total=function(e){let t=e.get("Content-Range");if(t){let e=function(e){let t=dB.exec(e);if(t)return parseInt(t[2])-parseInt(t[1])+1}(t);if(tK(e))return e}let i=e.get("Content-Length");if(i)return parseInt(i)}(e.headers)||a.total;let l=null==(t=this.callbacks)?void 0:t.onProgress;return l&&tK(i.highWaterMark)?this.loadProgressively(e,a,r,i.highWaterMark,l):n?e.arrayBuffer():"json"===r.responseType?e.json():e.text()}).then(e=>{var t,s;let n=this.response;if(!n)throw Error("loader destroyed");self.clearTimeout(this.requestTimeout),a.loading.end=Math.max(self.performance.now(),a.loading.first);let o=e[l];o&&(a.loaded=a.total=o);let d={url:n.url,data:e,code:n.status},h=null==(t=this.callbacks)?void 0:t.onProgress;h&&!tK(i.highWaterMark)&&h(a,r,e,n),null==(s=this.callbacks)||s.onSuccess(d,a,r,n)}).catch(e=>{if(self.clearTimeout(this.requestTimeout),a.aborted)return;let t=e&&e.code||0,s=e?e.message:null,n=i.loadPolicy.errorRetry;if(iu(n,a.retry,!1,{url:r.url,data:void 0,code:t}))this.retry(n);else{var l;iA.error(`${t} while loading ${r.url}`),null==(l=this.callbacks)||l.onError({code:t,text:s},r,e?e.details:null,a)}})}getCacheAge(){let e=null;if(this.response){let t=this.response.headers.get("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.response?this.response.headers.get(e):null}loadProgressively(e,t,i,r=0,a){let s=new nl,n=e.body.getReader(),l=()=>n.read().then(n=>{if(n.done)return s.dataLength&&a(t,i,s.flush().buffer,e),Promise.resolve(new ArrayBuffer(0));let o=n.value,d=o.length;return t.loaded+=d,d<r||s.dataLength?(s.push(o),s.dataLength>=r&&a(t,i,s.flush().buffer,e)):a(t,i,o.buffer,e),l()}).catch(()=>Promise.reject());return l()}}function dH(e,t){return new self.Request(e.url,t)}class dG extends Error{constructor(e,t,i){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=i}}let dW=/^age:\s*[\d.]+\s*$/im;class dK extends dF{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:s}=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&&tK(a)?a:s,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)){var s,n,l;self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;let r=t.status,o="text"===t.responseType?t.responseText:null;if(r>=200&&r<300){let a=null!=o?o:t.response;if(null!=a){i.loading.end=Math.max(self.performance.now(),i.loading.first);let l="arraybuffer"===t.responseType?a.byteLength:a.length;i.loaded=i.total=l,i.bwEstimate=8e3*i.total/(i.loading.end-i.loading.first);let o=null==(s=this.callbacks)?void 0:s.onProgress;o&&o(i,e,a,t);let d={url:t.responseURL,data:a,code:r};e.rangeEnd&&l!==e.rangeEnd-e.rangeStart&&iA.warn(`Payload length ${l} does not match requested Range: bytes=${e.rangeStart}-${e.rangeEnd-1}`),null==(n=this.callbacks)||n.onSuccess(d,i,e,t);return}}let d=a.loadPolicy.errorRetry;iu(d,i.retry,!1,{url:e.url,data:void 0,code:r})?this.retry(d):(iA.error(`${r} while loading ${e.url}`),null==(l=this.callbacks)||l.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&&dW.test(this.loader.getAllResponseHeaders())){let t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.loader&&RegExp(`^${e}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}}let dV=ii(ii({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,maxDevicePixelRatio:1/0,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,enableSoftw
16areAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,appendTimeout:1/0,ignorePlaylistParsingErrors:!1,loader:dK,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:sE,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:o7,abrController:class extends iv{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.co
16decTiers=null,this.timer=-1,this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.rebufferNotice=-1,this.supportedCache={},this.bwEstimator=void 0,this._abandonRulesCheck=e=>{var t;let i,{fragCurrent:r,partCurrent:a,hls:s}=this;if(!s)return;let{autoLevelEnabled:n,media:l}=s;if(!r||!l)return;let o=performance.now(),d=a?a.stats:r.stats,h=a?a.duration:r.duration,u=o-d.loading.start,c=s.minAutoLevel,m=r.level,f=this._nextAutoLevel;if(d.aborted||d.loaded&&d.loaded===d.total||m<=c){this.clearTimer(),this._nextAutoLevel=-1;return}if(!n)return;let p=f>-1&&f!==m,g=!!e||p;if(!g&&(l.paused||!l.playbackRate||!l.readyState))return;let v=s.mainForwardBufferInfo;if(!g&&null===v)return;let E=this.bwEstimator.getEstimateTTFB(),y=Math.abs(l.playbackRate);if(u<=Math.max(E,h/(2*y)*1e3))return;let b=v?v.len/y:0,T=d.loading.first?d.loading.first-d.loading.start:-1,A=d.loaded&&T>-1,S=this.getBwEstimate(),k=s.levels,R=k[m],L=Math.max(d.loaded,Math.round(h*(r.bitrate||R.averageBitrate)/8)),I=A?u-T:u;I<1&&A&&(I=Math.min(u,8*d.loaded/S));let w=A?1e3*d.loaded/I:0,D=E/1e3,C=w?(L-d.loaded)/w:8*L/S+D;if(C<=b)return;let M=w?8*w:S,x=(null==(t=(null==e?void 0:e.details)||s.latestLevelDetails)?void 0:t.live)===!0,P=s.config.abrBandWidthUpFactor,O=1/0;for(i=m-1;i>c;i--){let e=k[i].maxBitrate,t=!k[i].details||x;if((O=this.getTimeToLoadFrag(D,M,h*e,t))<Math.min(b,h+D))break}if(O>=C||O>10*h)return;A?this.bwEstimator.sample(u-Math.min(E,T),d.loaded):this.bwEstimator.sampleTTFB(u);let N=k[i].maxBitrate;this.getBwEstimate()*P>N&&(this.firstAutoFloor=Math.min(i,s.firstLevel),this.resetEstimator(N));
16let U=this.findBestLevel(N,c,i,0,b,1,1);U>-1&&(i=U),this.warn(`Fragment ${r.sn}${a?" part "+a.index:""} of level ${m} is loading too slowly;
17      Fragment duration: ${r.duration.toFixed(3)}
18      Time to underbuffer: ${b.toFixed(3)} s
19      Estimated load time for current fragment: ${C.toFixed(3)} s
20      Estimated load time for down switch fragment: ${O.toFixed(3)} s
21      TTFB estimate: ${0|T} ms
22      Current BW estimate: ${tK(S)?0|S:"Unknown"} bps
23      New BW estimate: ${0|this.getBwEstimate()} bps
24      Switching to level ${i} @ ${0|N} bps`),s.nextLoadLevel=s.nextAutoLevel=i,this.clearTimer();let F=()=>{this.clearTimer();let e=this.hls;if(this.fragCurrent===r&&e.loadLevel===i&&i>0){let t=this.getStarvationDelay();if(this.warn(`Aborting inflight request ${i>0?"and switching down":""}
25      Fragment duration: ${r.duration.toFixed(3)} s
26      Time to underbuffer: ${t.toFixed(3)} s`),r.abortRequests(),this.fragCurrent=this.partCurrent=null,i>c){let r=this.findBestLevel(e.levels[c].bitrate,c,i,0,t,1,1);-1===r&&(r=c),e.nextLoadLevel=e.nextAutoLevel=r,this.firstAutoFloor=Math.min(r,e.firstLevel),this.resetEstimator(e.levels[r].bitrate)}}};p||C>2*O?F():this.timer=self.setInterval(F,1e3*O),s.trigger(tz.FRAG_LOAD_EMERGENCY_ABORTED,{frag:r,part:a,stats:d})},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 ig(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}registerListeners(){let e=this.hls;e.on(tz.MANIFEST_LOADING,this.onManifestLoading,this),e.on(tz.FRAG_LOADING,this.onFragLoading,this),e.on(tz.FRAG_LOADED,this.onFragLoaded,this),e.on(tz.FRAG_BUFFERED,this.onFragBuffered,this),e.on(tz.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(tz.LEVEL_LOADED,this.onLevelLoaded,this),e.on(tz.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(tz.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(tz.ERROR,this.onError,this)}unregisterListeners(){let{hls:e}=this;e&&(e.off(tz.MANIFEST_LOADING,this.onManifestLoading,this),e.off(tz.FRAG_LOADING,this.onFragLoading,this),e.off(tz.FRAG_LOADED,this.onFragLoaded,this),e.off(tz.FRAG_BUFFERED,this.onFragBuffered,this),e.off(tz.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(tz.LEVEL_LOADED,this.onLevelLoaded,this),e.off(tz.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(tz.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(tz.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)){if(!i.bitrateTest){var r;this.fragCurrent=i,this.partCurrent=null!=(r=t.part)?r:null}this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100)}}onLevelSwitching(e,t){this.clearTimer()}onError(e,t){if(!t.fatal)switch(t.details){case tY.BUFFER_ADD_CODEC_ERROR:case tY.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case tY.FRAG_LOAD_TIMEOUT:{let e=t.frag,{fragCurrent:i,partCurrent:r}=this;if(e&&t6(e,i)){let t=performance.now(),i=r?r.stats:e.stats,a=t-i.loading.start,s=i.loading.first?i.loading.first-i.loading.start:-1;if(i.loaded&&s>-1){let e=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(a-Math.min(e,s),i.loaded)}else this.bwEstimator.sampleTTFB(a)}}}}getTimeToLoadFrag(e,t,i,r){let a=r?e+this.lastLevelLoadSec:0;return e+i/t+a}onLevelLoaded(e,t){let i=this.hls.config,{loading:r}=t.stats,a=r.end-r.first;tK(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,s=a?a.stats:r.stats;if(r.type===t0.MAIN&&this.bwEstimator.sampleTTFB(s.loading.first-s.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)+s.loaded,n=(t.loaded?t.loaded.duration:0)+e;t.loaded={bytes:i,duration:n},t.realBitrate=Math.round(8*i/n)}if(r.bitrateTest){let e={stats:s,frag:r,part:a,id:r.type};this.onFragBuffered(tz.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 s=((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(s,a.loaded),a.bwEstimate=this.getBwEstimate(),i.bitrateTest?this.bitrateTestDelay=s/1e3:(this.bitrateTestDelay=0,this.firstAutoFloor>-1&&this.bwEstimator.canEstimate()&&(this.firstAutoFloor=-1))}ignoreFragment(e){return e.type!==t0.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(),s=e.config.maxStarvationDelay,n=this.findBestLevel(r,i,t,a/2,s,1,1);if(n>-1)return n;let l=e.firstLevel,o=Math.min(Math.max(l,i),t,-1===this.firstAutoFloor?1/0:this.firstAutoFloor);return this.warn(`Could not find best starting auto level. Defaulting to first in playlist ${l} clamped to ${o}`),o}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()}
26_${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:s}=i,n=t?t.duration:e?e.duration:0,l=this.getBwEstimate(),o=this.getStarvationDelay(),d=a.abrBandWidthFactor,h=a.abrBandWidthUpFactor;if(o){let e=this.findBestLevel(l,s,r,o,0,d,h);if(e>=0)return this.rebufferNotice=-1,e}let u=n?Math.min(n,a.maxStarvationDelay):a.maxStarvationDelay;if(!o){let e=this.bitrateTestDelay;e&&(u=(n?Math.min(n,a.maxLoadingDelay):a.maxLoadingDelay)-e,this.info(`bitrate test took ${Math.round(1e3*e)}ms, set first fragment max fetchDuration to ${Math.round(1e3*u)} ms`),d=h=1)}let c=this.findBestLevel(l,s,r,o,u,d,h);if(this.rebufferNotice!==c&&(this.rebufferNotice=c,this.info(`${o?"rebuffering expected":"buffer is empty"}, optimal quality level ${c}`)),c>-1)return c;let m=i.levels[s],f=i.loadLevelObj;return f&&(null==m?void 0:m.bitrate)<f.bitrate?s: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,s,n){var l;let o,{hls:d,lastLoadedFragLevel:h,fragCurrent:u,partCurrent:c}=this;if(!d)return -1;let m=r+a,f=-1===h?d.firstLevel:h,{levels:p,allAudioTracks:g,loadLevel:v,latestLevelDetails:E,config:y}=d;if(1===p.length)return 0;let b=p[f],T=!!(null!=E&&E.live),A=-1===v||-1===h,S="SDR",k=(null==b?void 0:b.frameRate)||0,{audioPreference:R,videoPreference:L}=y,I=this.audioTracksByGroup||(this.audioTracksByGroup=ap(g)),w=-1;if(A){if(-1!==this.firstSelection)return this.firstSelection;let r=function(e,t,i,r,a){let s=Object.keys(e),n=null==r?void 0:r.channels,l=null==r?void 0:r.audioCodec,o=null==a?void 0:a.videoCodec,d=n&&2===parseInt(n),h=!1,u=!1,
26c=1/0,m=1/0,f=1/0,p=1/0,g=0,v=[],{preferHDR:E,allowedVideoRanges:y}=function(e,t){let i=!1,r=[];if(e&&(i="SDR"!==e,r=[e]),t){let e="SDR"!==(r=t.allowedVideoRanges||ao.slice(0)).join("")&&!t.videoCodec;(i=void 0!==t.preferHDR?t.preferHDR:e&&function(){if("function"==typeof matchMedia){let e=matchMedia("(dynamic-range: high)"),t=matchMedia("bad query");if(e.media!==t.media)return!0===e.matches}return!1}())||(r=["SDR"])}return{preferHDR:i,allowedVideoRanges:r}}(t,a);for(let t=s.length;t--;){let i=e[s[t]];h||(h=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&&(u=!0)}c=tK(c)?c:0,m=tK(m)?m:0;let b=Math.max(1080,c),T=Math.max(30,m);i=Math.max(f=tK(f)?f:i,i),u||(t=void 0);let A=s.length>1;return{codecSet:s.reduce((t,r)=>{let a=e[r];if(r===t)return t;if(v=u?y.filter(e=>a.videoRanges[e]>0):[],A){if(a.minBitrate>i)return af(r,`min bitrate of ${a.minBitrate} > current estimate of ${i}`),t;if(!a.hasDefaultAudio)return af(r,"no renditions with default or auto-select sound found"),t;if(l&&r.indexOf(l.substring(0,4))%5!=0)return af(r,`audio codec preference "${l}" not found`),t;if(n&&!d){if(!a.channels[n])return af(r,`no renditions with ${n} channel sound found (channels options: ${Object.keys(a.channels)})`),t}else if((!l||d)&&h&&0===a.channels["2"])return af(r,"no renditions with stereo sound found"),t;if(a.minHeight>b)return af(r,`min resolution of ${a.minHeight} > maximum of ${b}`),t;if(a.minFramerate>T)return af(r,`min framerate of ${a.minFramerate} > maximum of ${T}`),t;if(!v.some(e=>a.videoRanges[e]>0))return af(r,`no variants with VIDEO-RANGE of ${am(v)} found`),t;if(o&&r.indexOf(o.substring(0,4))%5!=0)return af(r,`video codec preference "${o}" not found`),t;if(a.maxScore<g)return af(r,`max score of ${a.maxScore} < selected max of ${g}`),t}return t&&(r2(r)>=r2(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}}(this.codecTiers||(this.codecTiers=p.slice(t,i+1).reduce((e,t,i)=>{if(!t.codecSet)return e;let r=t.audioGroups,a=e[t.codecSet];a||(e[t.codecSet]=a={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,minIndex:i,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!r,fragmentError:0}),a.minBitrate=Math.min(a.minBitrate,t.bitrate);let s=Math.min(t.height,t.width);return a.minHeight=Math.min(a.minHeight,s),a.minFramerate=Math.min(a.minFramerate,t.frameRate),a.minIndex=Math.min(a.minIndex,i),a.maxScore=Math.max(a.maxScore,t.score),a.fragmentError+=t.fragmentError,a.videoRanges[t.videoRange]=(a.videoRanges[t.videoRange]||0)+1,r&&r.forEach(e=>{if(!e)return;let t=I.groups[e];t&&(a.hasDefaultAudio=a.hasDefaultAudio||I.hasDefaultAudio?t.hasDefault:t.hasAutoSelect||!I.hasDefaultAudio&&!I.hasAutoSelectAudio,Object.keys(t.channels).forEach(e=>{a.channels[e]=(a.channels[e]||0)+t.channels[e]}))}),e},{})),S,e,R,L),{codecSet:a,videoRanges:s,minFramerate:n,minBitrate:l,minIndex:d,preferHDR:h}=r;w=d,o=a,S=h?s[s.length-1]:s[0],k=n,e=Math.max(e,l),this.log(`picked start tier ${am(r)}`)}else o=null==b?void 0:b.codecSet,S=null==b?void 0:b.videoRange;let D=c?c.duration:u?u.duration:0,C=this.bwEstimator.getEstimateTTFB()/1e3,M=[];for(let d=i;d>=t;d--){let t,u=p[d],g=d>f;if(!u)continue;if(y.useMediaCapabilities&&!u.supportedResult&&!u.supportedPromise){let t=navigator.mediaCapabilities;"function"==typeof(null==t?void 0:t.decodingInfo)&&function(e,t,i,r,a,s){let n=e.videoCodec,l=e.audioCodec?e.audioGroups:null,o=null==s?void 0:s.audioCodec,d=null==s?void 0:s.channels,h=d?parseInt(d):o?1/0:2,u=null;if(null!=l&&l.length)try{u=1===l.length&&l[0]?t.groups[l[0]].channels:l.reduce((e,i)=>{if(i){let r=t.groups[i];if(!r)throw Error(`Audio track group ${i} not found`);Object.keys(r.channels).forEach(t=>{e[t]=(e[t]||0)+r.channels[t]})}return e},{2:0})}catch(e){return!0}return void 0!==n&&(n.split(",").some(e=>r$(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))||!!u&&tK(h)&&Object.keys(u).some(e=>parseInt(e)>h)}(u,I,S,k,e,R)?(u.supportedPromise=ar(u,I,t,this.supportedCache),u.supportedPromise.then(e=>{if(!this.hls)return;u.supportedResult=e;let t=this.hls.levels,i=t.indexOf(u);e.error?this.warn(`MediaCapabilities decodingInfo error: "${e.error}" for level ${i} ${am(e)}`):e.supported?e.decodingInfoResults.some(e=>!1===e.smooth||!1===e.powerEfficient)&&this.log(`MediaCapabilities decodingInfo for level ${i} not smooth or powerEfficient: ${am(e)}`):(this.warn(`Unsupported MediaCapabilities decodingInfo result for level ${i} ${am(e)}`),i>-1&&t.length>1&&(this.log(`Removing unsupported level ${i}`),this.hls.removeLevel(i),-1===this.hls.loadLevel&&(this.hls.nextLoadLevel=0)))}).catch(e=>{this.warn(`Error handling MediaCapabilities decodingInfo: ${e}`)})):u.supportedResult=at}if((o&&u.codecSet!==o||S&&u.videoRange!==S||g&&k>u.frameRate||!g&&k>0&&k<u.frameRate||null!=(l=u.supportedResult)&&null!=(l=l.decodingInfoResults)&&l.some(e=>!1===e.smooth))&&(!A||d!==w)){M.push(d);continue}let E=u.details,b=(c?null==E?void 0:E.partTarget:null==E?void 0:E.averagetargetduration)||D||1;t=g?n*e:s*e;let L=D&&r>=2*D&&0===a?u.averageBitrate:u.maxBitrate,x=this.getTimeToLoadFrag(C,t,L*b,!E||E.live);if(t>=L&&(d===h||0===u.loadError&&0===u.fragmentError||im(u,y.errorPenaltyExpireMs))&&(x<=C||!tK(x)||T&&!this.bitrateTestDelay||x<m)){let e=this.forcedAutoLevel;return d!==v&&(-1===e||e!==v)&&(M.length&&this.trace(`Skipped level(s) ${M.join(",")} of ${i} max with CODECS and VIDEO-RANGE:"${p[M[0]].codecs}" ${p[M[0]].videoRange}; not compatible with "${o}" ${S}`),this.info(`switch candidate:${f}->${d} adjustedbw(${Math.round(t)})-bitrate=${Math.round(t-L)} ttfb:${C.toFixed(1)} avgDuration:${b.toFixed(1)} maxFetchDuration:${m.toFixed(1)} fetchDuration:${x.toFixed(1)}
26 firstSelection:${A} codecSet:${u.codecSet} videoRange:${u.videoRange} hls.loadLevel:${v}`)),A&&(this.firstSelection=d),d}}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 iv{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&&(null==(t=this.mediaSource)?void 0:t.readyState)==="open"&&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&&(s0(i,"sourceopen",this._onMediaSourceOpen),s0(t,"emptied",this._onMediaEmptied),this.updateDuration(),this.hls.trigger(tz.MEDIA_ATTA
26CHED,{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=Error(`MediaSource closed while media attached${lb(r,e)}`);this.warn(a),this.hls.trigger(tz.ERROR,ie({fatal:r},t,{type:tj.MEDIA_ERROR,details:tY.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;if(e){var t,i;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"u">typeof self&&e===self.ManagedMediaSource}(i_(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;
26e.on(tz.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(tz.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(tz.MANIFEST_LOADING,this.onManifestLoading,this),e.on(tz.MANIFEST_PARSED,this.onManifestParsed,this),e.on(tz.BUFFER_RESET,this.onBufferReset,this),e.on(tz.BUFFER_APPENDING,this.onBufferAppending,this),e.on(tz.BUFFER_CODECS,this.onBufferCodecs,this),e.on(tz.BUFFER_EOS,this.onBufferEos,this),e.on(tz.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(tz.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(tz.FRAG_PARSED,this.onFragParsed,this),e.on(tz.FRAG_CHANGED,this.onFragChanged,this),e.on(tz.ERROR,this.onError,this)}unregisterListeners(){let{hls:e}=this;e.off(tz.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(tz.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(tz.MANIFEST_LOADING,this.onManifestLoading,this),e.off(tz.MANIFEST_PARSED,this.onManifestParsed,this),e.off(tz.BUFFER_RESET,this.onBufferReset,this),e.off(tz.BUFFER_APPENDING,this.onBufferAppending,this),e.off(tz.BUFFER_CODECS,this.onBufferCodecs,this),e.off(tz.BUFFER_EOS,this.onBufferEos,this),e.off(tz.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(tz.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(tz.FRAG_PARSED,this.onFragParsed,this),e.off(tz.FRAG_CHANGED,this.onFragChanged,this),e.off(tz.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?ie(i,r.tracks):this.sourceBuffers.forEach(e=>{let[t]=e;t&&(i[t]=ie({},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=i_(this.appendSource);if(r){let e=!!t.mediaSource;(e||t.overrides)&&(this.transferData=t,this.overrides=t.overrides);let n=this.mediaSource=t.mediaSource||new r;if(this.assignMediaSource(n),e)this._objectUrl=i.src,this.attachTransferred();else{let e=this._objectUrl=self.URL.createObjectURL(n);if(this.appendSource)try{var a,s;let t;i.removeAttribute("src");let r=self.ManagedMediaSource;i.disableRemotePlayback=i.disableRemotePlayback||r&&n instanceof r,lE(i),a=i,s=e,(t=self.document.createElement("source")).type="video/mp4",t.src=s,a.appendChild(t),i.load()}catch(t){i.src=e}else i.src=e}sJ(i,"emptied",this._onMediaEmptied),sJ(i,"error",this._onMediaError),this.appendSource&&sJ(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}`),sJ(e,"sourceopen",this._onMediaSourceOpen),sJ(e,"sourceended",this._onMediaSourceEnded),sJ(e,"sourceclose",this._onMediaSourceClose),this.appendSource&&(sJ(e,"startstreaming",this._onStartStreaming),sJ(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,s=a?a.length:0,n=()=>{Promise.resolve().then(()=>{this.media&&this.mediaSourceOpenOrEnded&&this._onMediaSourceOpen()})};if(r&&a&&s){if(!this.tracksReady){this.hls.config.startFragPrefetch=!0,this.log("attachTransferred: waiting for SourceBuffer track info");return}if(this.log(`attachTransferred: (bufferCodecEventsTotal ${this.bufferCodecEventsTotal})
27required tracks: ${am(i,(e,t)=>"initSegment"===e?void 0:t)};
28transfer tracks: ${am(r,(e,t)=>"initSegment"===e?void 0:t)}}`),!iS(r,i)){t.mediaSource=null,t.tracks=void 0;let a=e.currentTime,s=this.details,n=Math.max(a,(null==s?void 0:s.fragments[0].start)||0);return n-a>1?void this.log(`attachTransferred: waiting for playback to reach new tracks start time ${a} -> ${n}`):(this.warn(`attachTransferred: resetting MediaSource for incompatible tracks ("${Object.keys(r)}"->"${Object.keys(i)}") start time: ${n} currentTime: ${a}`),this.onMediaDetaching(tz.MEDIA_DETACHING,{}
28),this.onMediaAttaching(tz.MEDIA_ATTACHING,t),void(e.currentTime=n))}this.transferData=void 0,a.forEach(e=>{let t=r[e];if(t){let i=t.buffer;if(i){let r=this.fragmentTracker,a=t.id;if(r.hasFragments(a)||r.hasParts(a)){let t=aZ.getBuffered(i);r.detectEvictedFragments(e,t,a,null,null,!0)}let s=ly(e),n=[e,i];this.sourceBuffers[s]=n,i.updating&&this.operationQueue&&this.operationQueue.prependBlocker(e),this.trackSourceBuffer(e,t)}}}),n(),this.bufferCreated()}else this.log("attachTransferred: MediaSource w/o SourceBuffers"),n()}get mediaSourceOpenOrEnded(){var e;let t=null==(e=this.mediaSource)?void 0:e.readyState;return"open"===t||"ended"===t}onMediaDetaching(e,t){let i=!!t.transferMedia;this.transferData=this.overrides=void 0;let{media:r,mediaSource:a,_objectUrl:s}=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()}s0(a,"sourceopen",this._onMediaSourceOpen),s0(a,"sourceended",this._onMediaSourceEnded),s0(a,"sourceclose",this._onMediaSourceClose),this.appendSource&&(s0(a,"startstreaming",this._onStartStreaming),s0(a,"endstreaming",this._onEndStreaming)),this.mediaSource=null,this._objectUrl=null}r&&(s0(r,"emptied",this._onMediaEmptied),s0(r,"error",this._onMediaError),s0(r,"seeking",this._onStartStreaming),i||(s&&self.URL.revokeObjectURL(s),this.mediaSrc===s?(r.removeAttribute("src"),this.appendSource&&lE(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,i;let r=null==(t=this.tracks[e])?void 0:t.buffer;if(this.removeBuffer(e),r)try{null!=(i=this.mediaSource)&&i.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(r)}catch(t){this.warn(`onBufferReset ${e}`,t)}delete this.tracks[e]}removeBuffer(e){this.removeBufferListeners(e),this.sourceBuffers[ly(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 lf(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 s="audiovideo"in t&&(r.audio||r.video)||r.audiovideo&&("audio"in t||"video"in t),n=!s&&this.sourceBufferCount&&this.media&&a.some(e=>!r[e]);s||n?this.warn(`Unsupported transition between "${Object.keys(r)}" and "${a}" SourceBuffers`):(a.forEach(e=>{var i,a;let{id:s,codec:n,levelCodec:l,container:o,metadata:d,supplemental:h}=t[e],u=r[e],c=null==(i=this.transferData)||null==(i=i.tracks)?void 0:i[e],m=null!=c&&c.buffer?c:u,f=(null==m?void 0:m.pendingCodec)||(null==m?void 0:m.codec),p=null==m?void 0:m.levelCodec;u||(u=r[e]={buffer:void 0,listeners:[],codec:n,supplemental:h,container:o,levelCodec:l,metadata:d,id:s});let g=r8(f,p),v=null==g?void 0:g.replace(lp,"$1"),E=r8(n,l),y=null==(a=E)?void 0:a.replace(lp,"$1");E&&g&&v!==y&&("audio"===e.slice(0,5)&&(E=r5(E,this.appendSource)),this.log(`switching codec ${f} to ${E}`),E!==(u.pendingCodec||u.codec)&&(u.pendingCodec=E),u.container=o,this.appendChangeType(e,o,E))}),(this.tracksReady||this.sourceBufferCount)&&(t.tracks=this.sourceBufferTracks),!this.sourceBufferCount&&(!(this.bufferCodecEventsTotal>1)||this.tracks.video||t.video||(null==(i=t.audio)?void 0:i.id)!=="main"||(this.log("Main audio-only"),this.bufferCodecEventsTotal=1),this.mediaSourceOpenOrEnded&&this.checkPendingTracks()))}get sourceBufferTracks(){return Object.keys(this.tracks).reduce((e,t)=>{let i=this.tracks[t];return e[t]={id:i.id,container:i.container,codec:i.codec,levelCodec:i.levelCodec},e},{})}appendChangeType(e,t,i){let r=`${t};codecs=${i}`,a={label:`change-type=${r}`,execute:()=>{let a=this.tracks[e];if(a){let s=a.buffer;null!=s&&s.changeType&&(this.log(`changing ${e} sourceBuffer type to ${r}`),s.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;(null==(t=this.fragmentTracker.getAppendedFrag(i,t0.MAIN))?void 0:t.gap)===!0||this.append({label:"block-audio",execute:()=>{var e,t;(this.lastVideoAppendEnd>r||aZ.isBuffered(null==(e=this.tracks.video)?void 0:e.buffer,r)||(null==(t=this.fragmentTracker.getAppendedFrag(r,t0.MAIN))?void 0:t.gap)===!0)&&this.unblockAudio()},onStart:()=>{},onComplete:()=>{},onError:e=>{this.warn("Error executing block-audio operation",e)}},"audio",!0)}unblockAudio(){this.operationQueue&&this.operationQueue.unblockAudio()}onBufferAppending(e,t){let{tracks:i}=this,{data:r,type:a,parent:s,frag:n,part:l,chunkMeta:o,offset:d}=t,h=o.buffering[a],u=t5(n)&&!l&&!n.gap&&!o.partial&&!o.iframe,c=null,m=!1,{sn:f,cc:p}=n,g=self.performance.now();h.start=g;let v=n.stats.buffering,E=l?l.stats.buffering:null;0===v.start&&(v.start=g),(null==E?void 0:E.start)===0&&(E.start=g);let y=i.audio,b=!1;"audio"===a&&(null==y?void 0:y.container)==="audio/mpeg"&&(b=!this.lastMpegAudioChunk||1===o.id||this.lastMpegAudioChunk.sn!==o.sn,this.lastMpegAudioChunk=o);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=l||n;if("audio"===a&&"main"!==s&&!(T.ending||T.ended)&&e&&aZ.getBuffered(e).length){let e=t.start+.05*t.duration,i=aZ.getBuffered(A),r=this.currentOp("video");i.length||r?!aZ.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 S=(l||n).start,k={label:`append-${a}`,execute:()=>{var e;h.executeStart=self.performance.now();let t=null==(e=this.tracks[a])?void 0:e.buffer;t&&(u&&(m=l_(lA(c=aZ.timeRangesToArray(aZ.getBuffered(t)),n),n)),b?this.updateTimestampOffset(t,S,.1,a,f,p):void 0!==d&&tK(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();h.executeEnd=h.end=e,0===v.first&&(v.first=e),(null==E?void 0:E.first)===0&&(E.first=e);let t={};
28if(this.sourceBuffers.forEach(([e,i])=>{e&&(t[e]=aZ.getBuffered(i))}),u){let e=this.getFragmentAppendProgress(n),i=t[a];if(i&&c){let t=lA(aZ.timeRangesToArray(i),n);e.progressed||(e.progressed=t-lA(c,n)>.001);let r=m&&l_(t,n);e.fullyBuffered[a]=void 0===e.fullyBuffered[a]?r:e.fullyBuffered[a]&&r}}this.hls.trigger(tz.BUFFER_APPENDED,{type:a,frag:n,part:l,chunkMeta:o,parent:s,timeRanges:t})},onError:e=>{var t,i;this.clearBufferAppendTimeoutId(this.tracks[a]);let d=e.code===DOMException.QUOTA_EXCEEDED_ERR||"QuotaExceededError"==e.name||"quota"in e;if(d&&!this._quotaEvictionPending[a]){let e=this.getBackBufferEvictionTarget(a,r.byteLength,n.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);this.insertNext([t,k,i],a);return}this.warn(`QuotaExceededError on "${a}" sn: ${f} - no back buffer available to evict`)}u&&(this.getFragmentAppendProgress(n).errored=!0);let h={type:tj.MEDIA_ERROR,parent:s,details:tY.BUFFER_APPEND_ERROR,sourceBufferName:a,frag:n,part:l,chunkMeta:o,error:e,err:e,fatal:!1},c=null==(t=this.media)?void 0:t.error;if(e.name!==lg||0!==this.sourceBufferCount||this.media&&0!==this.pendingTrackCount){d&&(h.details=tY.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&&(h.fatal=!d);let s=null==(i=this.mediaSource)?void 0:i.readyState;("ended"===s||"closed"===s||c)&&(this.warn(`MediaSource readyState "${s}" during SourceBuffer${lb(h.fatal,c)}`),h.details=tY.MEDIA_SOURCE_REQUIRES_RESET)}else h.errorAction=aC(!0);this.appendError=h,this.hls.trigger(tz.ERROR,h),d&&this.hls&&this.trimBuffers(n.start,1)}};this.log(`queuing "${a}" append sn: ${f}${l?" p: "+l.index:""} of ${s} playlist ${n.level} cc: ${p} offset: ${d} bytes: ${r.byteLength}`),this.append(k,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?s1(aZ.getBuffered(a)):"(detached)"}`),this.hls.trigger(tz.BUFFER_FLUSHED,{type:e,start:t,end:i})},onError:r=>{this.warn(`Failed to remove ${t}-${i} from "${e}" SourceBuffer`,r),this.hls.trigger(tz.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,s=[],n=r?r.elementaryStreams:i.elementaryStreams;n[t3]?s.push("audiovideo"):(n[t1]&&s.push("audio"),n[t2]&&s.push("video"));let l=()=>{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,s),this.hls&&(this.hls.trigger(tz.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}`))};0===s.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(l,s).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:s,frontBufferFlushThreshold:n}=a;this.trimBuffers(n,s,t.frag,t.previousFrag);let l=t.frag.elementaryStreams,{appendErrors:o}=this,d=null==(r=this.appendError)?void 0:r.sourceBufferName;Object.keys(l).forEach(e=>{l[e]&&(o[e]=0,e===d&&(this.appendError=void 0),"audio"===e||"video"===e?(o.audiovideo=0,"audiovideo"===d&&(this.appendError=void 0)):(o.audio=0,o.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;
28this.sourceBuffers.forEach(([e])=>{if(e){let i=this.tracks[e];(!t.type||t.type===e)&&(i.ending=!0,i.ended||(i.ended=!0,this.log(`${e} buffer reached EOS`)))}});let r=(null==(i=this.overrides)?void 0:i.endOfStream)!==!1;this.sourceBufferCount>0&&!this.sourceBuffers.some(([e])=>{var t;return e&&!(null!=(t=this.tracks[e])&&t.ended)})?(this.unblockAudio(),r?(this.log("Queueing EOS"),this.blockUntilOpen(()=>{this.tracksEnded();let{mediaSource:e}=this;if((null==e?void 0:e.readyState)!=="open"){e&&this.log(`Could not call mediaSource.endOfStream(). mediaSource.readyState: ${e.readyState}`);return}this.log("Calling mediaSource.endOfStream()"),e.endOfStream(),this.hls.trigger(tz.BUFFERED_TO_END,void 0)})):(this.tracksEnded(),this.hls.trigger(tz.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===tY.BUFFER_APPEND_ERROR&&t.frag){var i;let e=null==(i=t.errorAction)?void 0:i.nextAutoLevel;tK(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=lT(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||!t5(e)||e.gap||i.iframe||i.partial)return;let a=lT(e),s=this.fragmentAppendProgress[a];delete this.fragmentAppendProgress[a];let n=e.stats.buffering;if(n.start&&!n.first)return;let l=(null==s?void 0:s.stats)===e.stats?s:void 0;if(null!=l&&l.errored)return;let o=r.length>0&&r.every(e=>(null==l?void 0:l.fullyBuffered[e])===!0);if(null!=l&&l.progressed||o)return void delete this.appendsWithoutProgress[a];if(!l&&0===r.length)return;let d=(this.appendsWithoutProgress[a]||0)+1,h=this.hls;d>=h.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`),h.trigger(tz.ERROR,{type:tj.MEDIA_ERROR,details:tY.BUFFER_APPEND_NO_PROGRESS,fatal:!1,frag:e,chunkMeta:i,parent:e.type,appendsWithoutProgress:d,error: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:s,media:n}=this;if(!n||null===s||!this.sourceBufferCount)return;let l=a.config,o=n.currentTime,d=s.levelTargetDuration;t=s.live&&null!==l.liveBackBufferLength?l.liveBackBufferLength:t;let h=-1/0;
28if(tK(t)&&t>=0){let e=Math.max(t,d);h=Math.floor(o/d)*d-e}if(i){let e=this.getLoopBackBufferFlushEnd(i,null!=r?r:null);e>0&&(h=Math.max(h,e))}if(h>0&&this.flushBackBuffer(o,d,h),tK(e)&&e>0){let t=Math.max(Math.max(l.maxBufferLength,e),d),i=Math.floor(o/d)*d+t;this.flushFrontBuffer(o,d,i)}}getLoopBackBufferFlushEnd(e,t){var i;let{media:r}=this;if((null==(i=this.hls)?void 0:i.config.loopBackBufferFlush)===!1||!(null!=r&&r.loop)||!t||e.level<=t.level)return 0;let{video:a,audiovideo:s}=e.elementaryStreams;if(null!=a&&a.partial||null!=s&&s.partial)return 0;let n=this.getEarliestElementaryStreamStart(e)-.25;return n<=0?0:(this.log(`Flushing lower quality back buffer for loop: level ${e.level}, range [0-${n.toFixed(3)}]`),n)}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 n=aZ.getBuffered(t);if(n.length>0&&i>n.start(0)){var r,a,s;this.hls.trigger(tz.BACK_BUFFER_REACHED,{bufferEnd:i});let t=this.tracks[e];if(null!=(r=this.details)&&r.live)this.hls.trigger(tz.LIVE_BACK_BUFFER_REACHED,{bufferEnd:i});else if(null!=t&&t.ended&&!(null!=(a=this.media)&&a.loop&&(null==(s=this.hls)?void 0:s.config.loopBackBufferFlush)!==!1))return void this.log(`Cannot flush ${e} back buffer while SourceBuffer is in ended state`);this.hls.trigger(tz.BUFFER_FLUSHING,{startOffset:0,endOffset:i,type:e})}}})}flushFrontBuffer(e,t,i){this.sourceBuffers.forEach(([t,r])=>{if(r){let a=aZ.getBuffered(r),s=a.length;if(s<2)return;let n=a.start(s-1),l=a.end(s-1);i>n||e>=n&&e<=l||this.hls.trigger(tz.BUFFER_FLUSHING,{startOffset:n,endOffset:1/0,type:t})}})}getDurationAndRange(){var e;let{details:t,mediaSource:i}=this;if(!t||!this.media||(null==i?void 0:i.readyState)!=="open")return null;let r=t.edge;if(t.live&&this.hls.config.liveDurationInfinity){if(t.fragments.length&&i.setLiveSeekableRange){let e=Math.max(0,t.fragmentStart),i=Math.max(e,r);return{duration:1/0,start:e,end:i}}return{duration:1/0}}let a=null==(e=this.overrides)?void 0:e.duration;if(a)return tK(a)?{duration:a}:null;let s=this.media.duration;return r>(tK(i.duration)?i.duration:0)&&r>s||!tK(s)?{duration:r}:null}updateMediaSource({duration:e,start:t,end:i}){let r=this.mediaSource;r&&this.media&&"open"===r.readyState&&(r.duration!==e&&(tK(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}) ${am(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(tz.BUFFER_CREATED,{tracks:e}),this.log(`SourceBuffers created. Running queue: ${this.operationQueue}`),this.sourceBuffers.forEach(([e])=>{this.executeNext(e)})}else{let e=Error("could not create source buffer for media codec(s)");this.hls.trigger(tz.ERROR,{type:tj.MEDIA_ERROR,details:tY.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:e,reason:e.message})}}createSourceBuffers(){let{tracks:e,sourceBuffers:t,mediaSource:i}=this;if(!i)throw Error("createSourceBuffers called when mediaSource was null");for(let a in e){let s=e[a];if(this.isPending(s)){let e=this.getTrackCodec(s,a),n=`${s.container};codecs=${e}`;s.codec=e,this.log(`creating sourceBuffer(${n})${this.currentOp(a)?" Queued":""} ${am(s)}`);try{let e=i.addSourceBuffer(n),r=ly(a),l=[a,e];t[r]=l,s.buffer=e}catch(e){var r;this.error(`error while trying to add sourceBuffer: ${e.message}`),this.shiftAndExecuteNext(a),null==(r=this.operationQueue)||r.removeBlockers(),delete this.tracks[a],this.hls.trigger(tz.ERROR,{type:tj.MEDIA_ERROR,details:tY.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:e,sourceBufferName:a,mimeType:n,parent:s.id});return}this.trackSourceBuffer(a,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)&&rZ(i,"video")&&(r=function(e,t){let i=[];if(e){let t=e.split(",");for(let e=0;e<t.length;e++)rX(t[e],"video")||i.push(t[e])}return t&&i.push(t),i.join(",")}(r,i));let a=r8(r,e.levelCodec);return a?"audio"===t.slice(0,5)?r5(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 ${s1(i)}`),this.hls.trigger(tz.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((null==(t=this.mediaSource)?void 0:t.readyState)==="closed")return void this.resetBuffer(e);let r=this.currentOp(e);if(r){if(r.onComplete(),null==(i=this.tracks[e])||null==(i=i.buffer)?void 0:i.updating){this.log(`${e} SourceBuffer updating on "updateend"`),this.blockUntilOpen(()=>{this.shiftAndExecuteNext(e)});return}this.shiftAndExecuteNext(e)}}onSBUpdateError(e,t){var i;let r=null==(i=this.mediaSource)?void 0:i.readyState,a=Error(`${e} SourceBuffer error. MediaSource readyState: ${r}`);this.error(`${a.message}`,t),this.hls.trigger(tz.ERROR,{type:tj.MEDIA_ERROR,details:tY.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:a,fatal:!1});let s=this.currentOp(e);s&&s.onError(a)}updateTimestampOffset(e,t,i,r,a,s){Math.abs(t-e.timestampOffset)>=i&&(this.log(`Updating ${r} SourceBuffer timestampOffset to ${t} (sn: ${a} cc: ${s})`),e.timestampOffset=t)}removeExecutor(e,t,i){let{media:r,mediaSource:a}=this,s=this.tracks[e],n=null==s?void 0:s.buffer;if(!r||!a||!n)throw Error(`Attempting to remove from the ${e} SourceBuffer, but it does not exist`);let l=tK(r.duration)?r.duration:1/0,o=tK(a.duration)?a.duration:1/0,d=Math.max(0,t);if(d>=o){var h;null==(h=this.currentOp(e))||h.onComplete(),this.shiftAndExecuteNext(e);return}let u=Math.min(i,l,o);if(u>d&&(!s.ending||s.ended))s.ended=!1,this.log(`Removing [${d},${u}] from the ${e} SourceBuffer`),n.remove(d,u);else throw Error(`Cannot remove ${u<=d?`invalid range (${d} >= ${u}) `:""}from the ${e} SourceBuffer${s.ending?" while track ending":""}`)}appendExecutor(e,t){let i=this.tracks[t],r=null==i?void 0:i.buffer;if(!r)throw new lv(`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(t){this.log(`Failed to abort append on ${e} source buffer after timeout.`)}let r=this.currentOp(e);r&&r.onError(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=aZ.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}
28`),this.stepOperationQueue(this.sourceBufferTypes)});else try{e()}catch(e){this.warn(`Callback run without blocking ${this.operationQueue} ${e}`)}}isUpdating(){return this.sourceBuffers.some(([e,t])=>e&&t.updating)}isQueued(){return this.sourceBuffers.some(([e])=>e&&!!this.currentOp(e))}isPending(e){return!!e&&!e.buffer}isAudioBlocked(){var e;return(null==(e=this.currentOp("audio"))?void 0:e.label)==="block-audio"}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;return Promise.all(2===t.length&&this.isAudioBlocking()?[this.appendBlocker("video")]:t.map(e=>this.appendBlocker(e))).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]),0)}get sourceBufferCount(){return this.sourceBuffers.reduce((e,[t])=>e+ +!!t,0)}get sourceBufferTypes(){return this.sourceBuffers.map(([e])=>e).filter(e=>!!e)}addBufferListener(e,t,i){let r=this.tracks[e];if(!r)return;let a=r.buffer;if(!a)return;let s=i.bind(this,e);r.listeners.push({event:t,listener:s}),sJ(a,t,s)}removeBufferListeners(e){let t=this.tracks[e];if(!t)return;let i=t.buffer;i&&(t.listeners.forEach(e=>{s0(i,e.event,e.listener)}),t.listeners.length=0)}},capLevelController:lS,errorController:class extends iv{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(tz.ERROR,this.onError,this),e.on(tz.MANIFEST_LOADING,this.onManifestLoading,this),e.on(tz.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){let e=this.hls;e&&(e.off(tz.ERROR,this.onError,this),e.off(tz.ERROR,this.onErrorOut,this),e.off(tz.MANIFEST_LOADING,this.onManifestLoading,this),e.off(tz.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)===t0.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,r;if(t.fatal)return;let a=this.hls,s=t.context;switch(t.details){case tY.FRAG_LOAD_ERROR:case tY.FRAG_LOAD_TIMEOUT:case tY.KEY_LOAD_ERROR:case tY.KEY_LOAD_TIMEOUT:t.errorAction=this.getFragRetryOrSwitchAction(t);return;case tY.FRAG_PARSING_ERROR:if(null!=(i=t.frag)&&i.gap){t.errorAction=aC();return}case tY.FRAG_GAP:case tY.FRAG_DECRYPT_ERROR:t.errorAction=this.getFragRetryOrSwitchAction(t),t.errorAction.action=2;return;case tY.PLAYLIST_UNCHANGED_ERROR:case tY.LEVEL_EMPTY_ERROR:case tY.LEVEL_PARSING_ERROR:{let e=t.parent===t0.MAIN?t.level:a.loadLevel;t.details===tY.LEVEL_EMPTY_ERROR&&null!=(r=t.context)&&null!=(r=r.levelDetails)&&r.live?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,e):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,e))}return;case tY.LEVEL_LOAD_ERROR:case tY.LEVEL_LOAD_TIMEOUT:"number"==typeof(null==s?void 0:s.level)&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,s.level));return;case tY.AUDIO_TRACK_LOAD_ERROR:case tY.AUDIO_TRACK_LOAD_TIMEOUT:case tY.SUBTITLE_LOAD_ERROR:case tY.SUBTITLE_TRACK_LOAD_TIMEOUT:if(s){let e=a.loadLevelObj;e&&(s.type===tJ.AUDIO_TRACK&&e.hasAudioGroup(s.groupId)||s.type===tJ.SUBTITLE_TRACK&&e.hasSubtitleGroup(s.groupId))&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,a.loadLevel),t.errorAction.action=2,t.errorAction.flags=1)}return;case tY.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:t.errorAction={action:2,flags:2};return;case tY.KEY_SYSTEM_SESSION_UPDATE_FAILED:case tY.KEY_SYSTEM_STATUS_INTERNAL_ERROR:case tY.KEY_SYSTEM_NO_SESSION:t.errorAction={action:2,flags:4};return;
28case tY.BUFFER_ADD_CODEC_ERROR:case tY.REMUX_ALLOC_ERROR:case tY.BUFFER_APPEND_ERROR:t.errorAction||(t.errorAction=this.getLevelSwitchAction(t,t.level));return;case tY.MEDIA_SOURCE_REQUIRES_RESET:t.errorAction||(t.errorAction=this.getLevelSwitchAction(t,t.level)),t.errorAction.flags|=24;return;case tY.INTERNAL_EXCEPTION:case tY.BUFFER_APPENDING_ERROR:case tY.BUFFER_APPEND_NO_PROGRESS:case tY.BUFFER_FULL_ERROR:case tY.LEVEL_SWITCH_ERROR:case tY.BUFFER_STALLED_ERROR:case tY.BUFFER_SEEK_OVER_HOLE:case tY.BUFFER_NUDGE_ON_STALL:t.errorAction=aC();return}t.type===tj.KEY_SYSTEM_ERROR&&(t.levelRetry=!1,t.errorAction=aC())}getPlaylistRetryOrSwitchAction(e,t){let i=io(this.hls.config.playlistLoadPolicy,e),r=this.playlistError++;if(iu(i,r,ia(e),e.response))return{action:5,flags:0,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:s}=t.config,n=io(is(e)?s:a,e),l=t.levels.reduce((e,t)=>e+t.fragmentError,0);if(r&&(e.details!==tY.FRAG_GAP&&r.fragmentError++,!il(e))&&iu(n,l,ia(e),e.response))return{action:5,flags:0,retryConfig:n,retryCount:l};let o=this.getLevelSwitchAction(e,i);return n&&(o.retryConfig=n,o.retryCount=l),o}getLevelSwitchAction(e,t){let i=this.hls;null==t&&(t=i.loadLevel);let r=this.hls.levels[t];if(r){var a,s,n,l;let t=e.details;r.loadError++,r.loadErrorTime=self.performance.now(),t===tY.BUFFER_APPEND_ERROR&&r.fragmentError++;let o=-1,{levels:d,loadLevel:h,minAutoLevel:u,maxAutoLevel:c}=i;i.autoLevelEnabled||i.config.preserveManualLevelOnError||(i.loadLevel=-1);let m=null==(a=e.frag)?void 0:a.type,f=(m===t0.AUDIO&&t===tY.FRAG_PARSING_ERROR||"audio"===e.sourceBufferName&&aw(e))&&d.some(({audioCodec:e})=>r.audioCodec!==e),p="video"===e.sourceBufferName&&aw(e)&&d.some(({codecSet:e,audioCodec:t})=>r.codecSet!==e&&r.audioCodec===t),{type:g,groupId:v}=null!=(s=e.context)?s:{};for(let a=d.length;a--;){let s=(a+h)%d.length;if(s!==h&&s>=u&&s<=c&&(0===d[s].loadError||im(d[s],i.config.errorPenaltyExpireMs))){let i=d[s];if(t===tY.FRAG_GAP&&m===t0.MAIN&&e.frag){let t=d[s].details;if(t){let i=ak(e.frag,t.fragments,e.frag.start);if(null!=i&&i.gap)continue}}else if(g===tJ.AUDIO_TRACK&&i.hasAudioGroup(v)||g===tJ.SUBTITLE_TRACK&&i.hasSubtitleGroup(v))continue;else if(m===t0.AUDIO&&null!=(n=r.audioGroups)&&n.some(e=>i.hasAudioGroup(e))||m===t0.SUBTITLE&&null!=(l=r.subtitleGroups)&&l.some(e=>i.hasSubtitleGroup(e))||f&&r.audioCodec===i.audioCodec||p&&r.codecSet===i.codecSet||!f&&r.audioCodec!==i.audioCodec)continue;o=s;break}}if(o>-1&&i.loadLevel!==o)return e.levelRetry=!0,this.playlistError=0,{action:2,flags:0,nextAutoLevel:o}}return{action:2,flags:1}}onErrorOut(e,t){var i,r;switch(null==(i=t.errorAction)?void 0:i.action){case 0:break;case 2:this.sendAlternateToPenaltyBox(t),t.errorAction.resolved||t.details===tY.FRAG_GAP||t.details===tY.PLAYLIST_UNCHANGED_ERROR||aD(t)||(t.fatal=!0)}if(16&((null==(r=t.errorAction)?void 0:r.flags)||0)&&this.hls.recoverMediaError(),t.fatal)return void this.hls.stopLoad()}sendAlternateToPenaltyBox(e){let t=this.hls,i=e.errorAction;if(!i)return;let r=i.nextAutoLevel;if(0===i.flags)this.switchLevel(e,r);else if(8&i.flags){let e=this.hls.levels,t=e.length;for(let i=t;i--;)"SDR"!==e[i].videoRange?(e[i].fragmentError++,e[i].loadError++):void 0===r&&(r=i)}else if(2&i.flags){let r=this.getVariantLevelIndex(e.frag),a=t.levels[r],s=null==a?void 0:a.attrs["HDCP-LEVEL"];i.hdcpLevel=s;let n="NONE"===s;s&&!n?(t.maxHdcpLevel=al[al.indexOf(s)-1],i.resolved=!0,this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`)):(n&&this.warn("HDCP policy resticted output with HDCP-LEVEL=NONE"),i.flags|=4)}if(4&i.flags){let t=e.decryptdata;if(t){let r=this.hls.levels,n=r.length;for(let i=n;i--;)if(this.variantHasKey(r[i],t)){var a,s;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==(s=e.frag)?void 0:s.type} fragment) ${iB(t.keyId||[])}`),r[i].fragmentError++,r[i].loadError++,this.log(`Removing level ${i} with key error (${e.error})`),this.hls.removeLevel(i)}let l=e.frag;if(this.hls.levels.length<n)i.resolved=!0;else if(l&&l.type!==t0.MAIN){let e=l.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===tY.BUFFER_ADD_CODEC_ERROR&&e.mimeType&&"audiovideo"!==e.sourceBufferName)){let t=r7(e.mimeType),i=this.hls.levels;for(let r=i.length;r--;)i[r][`${e.sourceBufferName}Codec`]===t&&(this.log(`Removing level ${r} for ${e.details} ("${t}" not supported)`),this.hls.removeLevel(r))}}},fpsController:class{constructor(e){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=e,this.registerListeners()}setStreamController(e){this.streamController=e}
28registerListeners(){this.hls.on(tz.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.on(tz.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListeners(){this.hls.off(tz.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off(tz.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,s=t-this.lastDecodedFrames,n=1e3*a/e,l=this.hls;if(l.trigger(tz.FPS_DROP,{currentDropped:a,currentDecoded:s,totalDroppedFrames:i}),n>0&&a>l.config.fpsDroppedMonitoringThreshold*s){let e=l.currentLevel;l.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+e),e>0&&(-1===l.autoLevelCapping||l.autoLevelCapping>=e)&&(e-=1,l.trigger(tz.FPS_DROP_LEVEL_CAPPING,{level:e,droppedLevel:l.currentLevel}),l.autoLevelCapping=e,this.streamController.nextLevelSwitch())}}this.lastTime=r,this.lastDroppedFrames=i,this.lastDecodedFrames=t}}checkFPSInterval(){let e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){let t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}},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(tz.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;
28e&&(e.on(tz.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(tz.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(tz.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(tz.MANIFEST_LOADING,this.onManifestLoading,this),e.on(tz.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(tz.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(tz.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(tz.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}_unregisterListeners(){let{hls:e}=this;e&&(e.off(tz.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(tz.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(tz.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(tz.MANIFEST_LOADING,this.onManifestLoading,this),e.off(tz.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(tz.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(tz.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(tz.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 oX(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 s=o4();if(s)for(let e=0;e<a.length;e++){let t=a[e].type;if(t===nE.emsg&&!i||!r)continue;let n=iN(a[e].data),l=a[e].pts,o=l+a[e].duration;o>o8&&(o=o8),o-l<=0&&(o=l+.25);for(let e=0;e<n.length;e++){let i=n[e];if(!iU(i)){this.updateId3CueEnds(l,t);let e=o5(s,l,o,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===o8&&(a.endTime=e)}}onBufferFlushing(e,{startOffset:t,endOffset:i,type:r}){let{id3Track:a,hls:s}=this;if(!s)return;let{config:{enableEmsgMetadataCues:n,enableID3MetadataCues:l}}=s;if(a&&(n||l)){let e;e="audio"===r?e=>e.type===nE.audioId3&&l:"video"===r?e=>e.type===nE.emsg&&n:e=>e.type===nE.audioId3&&l||e.type===nE.emsg&&n,oJ(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){var i,r;if(!this.hls||!this.media)return;let{assetPlayerId:a,timelineOffset:s,enableDateRangeMetadataCues:n,interstitialsController:l}=this.hls.config;if(!n)return;let o=o4();if(a&&s&&!l){let{fragmentStart:t,fragmentEnd:i}=e,r=this.assetCue;r?(r.startTime=t,r.endTime=i):o&&(r=this.assetCue=o5(o,t,i,{assetPlayerId:this.hls.config.assetPlayerId},"hlsjs.interstitial.asset"))&&(r.id=a,this.id3Track||(this.id3Track=this.createTrack(this.media)),this.id3Track.track.addCue(r),r.addEventListener("enter",this.onEventCueEnter))}if(!e.hasProgramDateTime)return;let{id3Track:d}=this,{dateRanges:h}=e,u=Object.keys(h),c=this.dateRangeCuesAppended;if(d&&t)if(null!=(i=d.track.cues)&&i.length){let e=Object.keys(c).filter(e=>-1===u.indexOf(e));for(let t=e.length;t--;){let i=e[t],a=null==(r=c[i])?void 0:r.cues;delete c[i],a&&Object.keys(a).forEach(e=>{let t=a[e];if(t){t.removeEventListener("enter",this.onEventCueEnter);try{d.track.removeCue(t)}catch(e){}}})}}else c=this.dateRangeCuesAppended={};let m=e.fragments[e.fragments.length-1];if(0!==u.length&&tK(null==m?void 0:m.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(let e=0;e<u.length;e++){let t=u[e],i=h[t],r=i.startTime,a=c[t],s=(null==a?void 0:a.cues)||{},n=(null==a?void 0:a.durationKnown)||!1,d=o8,{duration:m,endDate:f}=i;if(f&&null!==m)d=r+m,n=!0;else if(i.endOnNext&&!n){let e=u.reduce((e,t)=>{if(t!==i.id){let r=h[t];if(r.class===i.class&&r.startDate>i.startDate&&(!e||i.startDate<e.startDate))return r}return e},null);e&&(d=e.startTime,n=!0)}let p=Object.keys(i.attr);for(let e=0;e<p.length;e++){let h=p[e];if("ID"===h||"CLASS"===h||"CUE"===h||"START-DATE"===h||"DURATION"===h||"END-DATE"===h||"END-ON-NEXT"===h)continue;let u=s[h];if(u)n&&!(null!=a&&a.durationKnown)?u.endTime=d:Math.abs(u.startTime-r)>.01&&(u.startTime=r,u.endTime=d);else if(o){let e=i.attr[h];("SCTE35-OUT"===h||"SCTE35-IN"===h||"SCTE35-CMD"===h)&&(e=i$(e));let a=o5(o,r,d,{key:h,data:e},nE.dateRange);a&&(a.id=t,this.id3Track.track.addCue(a),s[h]=a,l&&("X-ASSET-LIST"===h||"X-ASSET-URL"===h)&&a.addEventListener("enter",this.onEventCueEnter))}}c[t]={cues:s,dateRange:i,durationKnown:n}}}}},gapController:class extends aY{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=()=>
28{if(this.hls){var e;this.ended=(null==(e=this.media)?void 0:e.currentTime)||1,this.hls.trigger(tz.MEDIA_ENDED,{stalled:!1})}},this.hls=e,this.fragmentTracker=t,this.lastCurrentTime=this.getCurrentTime(),this.registerListeners()}registerListeners(){let{hls:e}=this;e&&(e.on(tz.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(tz.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(tz.BUFFER_APPENDED,this.onBufferAppended,this))}unregisterListeners(){let{hls:e}=this;e&&(e.off(tz.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(tz.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(tz.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;sJ(i,"playing",this.onMediaPlaying),sJ(i,"waiting",this.onMediaWaiting),sJ(i,"ended",this.onMediaEnded)}onMediaDetaching(e,t){this.clearInterval();let{media:i}=this;i&&(s0(i,"playing",this.onMediaPlaying),s0(i,"waiting",this.onMediaWaiting),s0(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,a;let s=null==(i=this.hls)?void 0:i.config;if(!s)return;let n=this.media;if(!n)return;let{seeking:l}=n,o=this.seeking&&!l,d=!this.seeking&&l,h=n.paused&&!l||n.ended||0===n.playbackRate;if(this.seeking=l,e!==t){t&&(this.ended=0),this.moved=!0,!l&&(this.skipRetry=this.nudgeRetry=0,s.nudgeOnVideoHole&&!h&&e>t&&this.nudgeOnVideoHole(e,t)),0===this.waiting&&this.stallResolved(e);return}if(d||o){o&&this.stallResolved(e);return}if(h){this.skipRetry=this.nudgeRetry=0,this.stallResolved(e),!this.ended&&n.ended&&this.hls&&(this.ended=e||1,this.hls.trigger(tz.MEDIA_ENDED,{stalled:!1}));return}if(!aZ.getBuffered(n).length){this.skipRetry=this.nudgeRetry=0;return}let u=aZ.bufferInfo(n,e,0),c=this.fragmentTracker;c&&this.hls&&o3(u,e,c,this.hls);let m=u.nextStart||0;if(l&&c&&this.hls){let t=o0(this.hls.inFlightFragments,e),i=u.len>2,r=!m||t||m-e>2&&!c.getPartialFragment(e);if(i||r)return;this.moved=!1}let f=null==(r=this.hls)?void 0:r.latestLevelDetails;if(!this.moved&&null!==this.stalled&&c){if(!(u.len>0)&&!m)return;let t=Math.max(m,u.start||0)-e,i=null!=f&&f.live?2*f.targetduration:2,r=o2(e,c);if(t>0&&(t<=i||r)){n.paused||this._trySkipBufferHole(r);return}}let p=s.detectStallWithCurrentTimeMs,g=self.performance.now(),v=this.waiting,E=this.stalled;if(null===E)if(v>0&&g-v<p)E=this.stalled=v;else{this.stalled=g;return}let y=g-E;if(!l&&(y>=p||v&&this.moved)&&this.hls){if((null==(a=this.mediaSource)?void 0:a.readyState)==="ended"&&!(null!=f&&f.live)&&1>Math.abs(e-((null==f?void 0:f.edge)||0))){if(this.ended)return;this.ended=e||1,this.hls.trigger(tz.MEDIA_ENDED,{stalled:!0});return}if(this._reportStall(u),!this.media||!this.hls)return;if(n.currentTime!==e){let t=e;e=n.currentTime,this.moved=!0,this.log(`currentTime changed ${t} > ${e}`);return}}let b=aZ.bufferInfo(n,e,s.maxBufferHole);this._tryFixBufferStall(b,y,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(tz.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=aZ.bufferedInfo(aZ.timeRangesToArray(this.buffered.audio),e,0);if(i.len>1&&t>=i.start){let i=aZ.timeRangesToArray(r),a=aZ.bufferedInfo(i,t,0).bufferedIndex;if(a>-1&&a<i.length-1){let t=aZ.bufferedInfo(i,e,0).bufferedIndex,r=i[a].end,s=i[a+1].start;if((-1===t||t>a)&&s-r<1&&e-r<2){let i=Error(`nudging playhead to flush pipeline after video hole. currentTime: ${e} hole: ${r} -> ${s} buffered index: ${t}`);this.warn(i.message),this.media.currentTime+=1e-6;let a=o2(e,this.fragmentTracker);a&&"fragment"in a?a=a.fragment:a||(a=void 0);let n=aZ.bufferInfo(this.media,e,0);this.hls.trigger(tz.ERROR,{type:tj.MEDIA_ERROR,details:tY.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:i,reason:i.message,frag:a,buffer:n.len,bufferInfo:n})}}}}}_tryFixBufferStall(e,t,i){var r,a;let{fragmentTracker:s,media:n}=this,l=null==(r=this.hls)?void 0:r.config;if(!n||!s||!l)return;let o=null==(a=this.hls)?void 0:a.latestLevelDetails,d=o2(i,s);if((d||null!=o&&o.live&&i<o.fragmentStart)&&(this._trySkipBufferHole(d)||!this.media))return;let h=e.buffered,u=this.adjacentTraversal(e,i);(h&&h.length>1&&e.len>l.maxBufferHole||e.nextStart&&(e.nextStart-i<l.maxBufferHole||u))&&(t>1e3*l.highBufferWatchdogPeriod||this.waiting)&&(this.warn("Trying to nudge playhead over buffer-hole"),this._tryNudgeBuffer(e))}adjacentTraversal(e,t){let i=this.fragmentTracker,r=e.nextStart;if(i&&r){let e=i.getFragAtPos(t,t0.MAIN),a=i.getFragAtPos(r,t0.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=Error(`Playback stalling at @${i.currentTime} due to low buffer (${am(e)})`);this.warn(r.message),t.trigger(tz.ERROR,{type:tj.MEDIA_ERROR,details:tY.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 s=i.currentTime,n=aZ.bufferInfo(i,s,0);o3(n,s,t,r);let l=s<n.start?n.start:n.nextStart;if(l){let d=n.len<=a.maxBufferHole,h=n.len>0&&n.len<1&&i.readyState<3,u=l-s;if(u>0&&(d||h)){if(u>a.maxBufferHole){let i=!1;if(0===s){let e=t.getAppendedFrag(0,t0.MAIN);e&&l<e.end&&(i=!0)}if(!i&&e){var o;
28if(!(null!=(o=r.loadLevelObj)&&o.details)||o0(r.inFlightFragments,l))return 0;let i=!1,a=e.end;for(;a<l;){let e=o2(a,t),r=e?e.duration:0;if(r>0)a+=r;else{i=!0;break}}if(i)return 0}}let{nudgeMaxRetry:d,skipBufferHolePadding:h}=a,c=++this.skipRetry>d,m=Math.max(l,s)+h;if(c||(this.warn(`skipping hole, adjusting currentTime from ${s} to ${m}`),this.moved=!0,i.currentTime=m),!(null!=e&&e.gap)||c){let t=Error(c?`Playhead still not moving after seeking over buffer hole from ${s} to ${m} after ${a.nudgeMaxRetry} attempts.`:`fragment loaded with buffer holes, seeking from ${s} to ${m}`),i={type:tj.MEDIA_ERROR,details:tY.BUFFER_SEEK_OVER_HOLE,fatal:c,error:t,reason:t.message,buffer:n.len,bufferInfo:n};e&&("fragment"in e?i.part=e:i.frag=e),r.trigger(tz.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 s=i.currentTime;if(this.nudgeRetry++,r<a.nudgeMaxRetry){let n=s+(r+1)*a.nudgeOffset,l=Error(`Nudging 'currentTime' from ${s} to ${n}`);this.warn(l.message),i.currentTime=n,t.trigger(tz.ERROR,{type:tj.MEDIA_ERROR,details:tY.BUFFER_NUDGE_ON_STALL,error:l,fatal:!1,buffer:e.len,bufferInfo:e})}else{let i=Error(`Playhead still not moving while enough data buffered @${s} after ${a.nudgeMaxRetry} nudges`);this.error(i.message),t.trigger(tz.ERROR,{type:tj.MEDIA_ERROR,details:tY.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:s,maxLiveSyncPlaybackRate:n}=r;if(!s||1===n||!i.live)return;let l=this.targetLatency;if(null===l)return;let o=a-l,d=Math.min(this.maxLatency,l+i.targetduration),h=nn(r)&&!!(null!=(e=this.hls.interstitialsManager)&&null!=(e=e.playingItem)&&e.event);if(o<d&&o>.05&&this.forwardBufferLength>1&&!h){let e=Math.min(Math.min(2,Math.max(1,n)),Math.max(1,Math.round(2/(1+Math.exp(-.75*o-this.edgeStalled))*20)/20));this.changeMediaPlaybackRate(t,e)}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:s,liveSyncDurationCount:n,lowLatencyMode:l}=t,o=this.hls.userConfig,d=l&&r||i;return(this._targetLatencyUpdated||o.liveSyncDuration||o.liveSyncDurationCount||0===d)&&(d=void 0!==s?s:n*a),d+Math.min(this.stallCount*t.liveSyncOnStallIncrease,a)}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;return Math.min(Math.max(r-i.totalduration,a),r-(this.hls.config.lowLatencyMode&&i.partTarget||i.targetduration))}get drift(){let e=this.levelDetails;return null===e?1:e.drift}get edgeStalled(){let e=this.levelDetails;if(null===e||!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;
28e&&(e.on(tz.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(tz.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(tz.MANIFEST_LOADING,this.onManifestLoading,this),e.on(tz.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(tz.ERROR,this.onError,this),e.on(tz.INTERSTITIAL_ASSET_STARTED,this.onAssetStarted,this))}unregisterListeners(){let{hls:e}=this;e&&(e.off(tz.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(tz.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(tz.MANIFEST_LOADING,this.onManifestLoading,this),e.off(tz.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(tz.ERROR,this.onError,this),e.off(tz.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===tY.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:dU,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 na{constructor(e,t,i){super(e,t,i,"subtitle-stream-controller",t0.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(tz.LEVEL_LOADED,this.onLevelLoaded,this),e.on(tz.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(tz.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(tz.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(tz.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(tz.BUFFER_FLUSHING,this.onBufferFlushing,this)}unregisterListeners(){super.unregisterListeners();let{hls:e}=this;e.off(tz.LEVEL_LOADED,this.onLevelLoaded,this),e.off(tz.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(tz.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(tz.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(tz.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(tz.BUFFER_FLUSHING,this.onBufferFlushing,this)}startLoad(e,t){this.stopLoad(),this.state=s3,this.setInterval(500),this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}onManifestLoading(){super.onManifestLoading(),this.mainDetails=null}onMediaDetaching(e,t){this.tracksBuffered=[],super.onMediaDetaching(e,t)}onLevelLoaded(e,t){this.mainDetails=t.details}onSubtitleFragProcessed(e,t){let i,{frag:r,part:a,success:s}=t;if(!s)return;let n=this.tracksBuffered[this.currentTrackId];if(!n)return;let l=(a||r).start;for(let e=0;e<n.length;e++)if(l>=n[e].start&&l<=n[e].end){i=n[e];break}let o=l+(a||r).duration;if(i?i.end=o:(i={start:l,end:o},n.push(i)),!a||o>=r.end){let e=this.fragmentTracker.fragBuffered(r);a&&e&&(e.range.subs={time:[{startPTS:r.start,endPTS:o}],partial:!0}),t5(r)&&!this.fragContextChanged(r)&&(this.fragPrevious=r),this.fragBufferedComplete(r,a),this.media&&this.tickImmediate()}}onBufferFlushing(e,t){let{startOffset:i,endOffset:r}=t;if(0===i&&r!==1/0){let e=r-1;if(e<=0)return;t.endOffsetSubtitles=Math.max(0,e),this.tracksBuffered.forEach(t=>{if(t)for(let i=0;i<t.length;){if(t[i].end<=e){t.shift();continue}if(t[i].start<e)t[i].start=e;else break;i++}}),this.fragmentTracker.removeFragmentsInRange(i,e,t0.SUBTITLE)}}onError(e,t){let i=t.frag;(null==i?void 0:i.type)===t0.SUBTITLE&&(t.details===tY.FRAG_GAP&&this.fragmentTracker.addAsGap(i),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==s2&&(this.state=s3))}
28onSubtitleTracksUpdated(e,{subtitleTracks:t}){if(this.levels&&lc(this.levels,t)){this.levels=t.map(e=>new au(e));return}this.tracksBuffered=[],this.levels=t.map(e=>{let t=new au(e);return this.tracksBuffered[t.id]=[],t}),this.fragmentTracker.removeFragmentsInRange(0,1/0,t0.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];if(!(null!=r&&r.details)){this.mediaBuffer=null;return}this.mediaBuffer=this.mediaBufferTimeRanges,this.state!==s2&&this.setInterval(500)}onSubtitleTrackLoaded(e,t){var i,r;let{currentTrackId:a,levels:s}=this,{details:n,id:l}=t;if(!s)return void this.warn(`Subtitle tracks were reset while loading level ${l}`);let o=s[l];if(l>=s.length||!o)return;this.log(`Subtitle track ${l} loaded [${n.startSN},${n.endSN}]${n.lastPartSn?`[part-${n.lastPartSn}-${n.lastPartIndex}]`:""},duration:${n.totalduration}`),this.mediaBuffer=this.mediaBufferTimeRanges;let d=this.mainDetails,h=0;if(n.live||null!=(i=o.details)&&i.live){if(n.deltaUpdateFailed)return;if(!d){this.startFragRequested=!1;return}o.details&&(h=this.alignPlaylists(n,o.details,null==(r=this.levelLastLoaded)?void 0:r.details)),n.alignedSliding||(sZ(d,n,this),h=n.fragmentStart)}o.details=n,this.levelLastLoaded=o,d&&!this.startFragRequested&&this.setStartPosition(d,h),l===a&&(this.hls.trigger(tz.SUBTITLE_TRACK_UPDATED,{details:n,id:l,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&&se(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,st(r.method)).then(e=>{this.fragContextChanged(t)||this.hls.trigger(tz.FRAG_DECRYPTED,{frag:t,part:i,payload:e,stats:{tstart:a,tdecrypt:performance.now()}})}).catch(e=>{this.hls.trigger(tz.ERROR,{type:tj.MEDIA_ERROR,details:tY.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:t,part:i}),i||(this.warn(`${e.name}: ${e.message}`),this.state=s3)})}doTick(){if(this.state===s3&&this.levels){var e,t;if(!this.media&&!this.primaryPrefetch&&(this.startFragRequested||!this.config.startFragPrefetch))return;let{currentTrackId:i,levels:r}=this,a=r[i],s=null==a?void 0:a.details;if(!s||this.waitForLive(a)||this.waitForCdnTuneIn(s)){this.startFragRequested=!1;return}let{config:n}=this,l=this.playhead,{end:o,len:d}=aZ.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],l,n.maxBufferHole);if(d>Math.max(this.hls.maxBufferLength+s.levelTargetDuration,(null==(e=this.hls.mainForwardBufferInfo)?void 0:e.len)||0)||d&&!this.buffering)return;let h=this.getNextFragment(o,s);if(h){if(t5(h)){let e=h.sn-s.startSN,i=s.fragments[e-1];h.cc!==(null==i?void 0:i.cc)||null!=(t=s.partList)&&t.length||this.fragmentTracker.getState(i)!==aM||(h=i)}this.loadFragment(h,a,o)}}}loadFragment(e,t,i){let r=this.fragmentTracker.getState(e);(r===aM||r===aP)&&super.loadFragment(e,t,i)}get mediaBufferTimeRanges(){return new dv(this.tracksBuffered[this.currentTrackId]||[])}},subtitleTrackController:class extends lu{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=()=>{var e,t,i;if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let r=-1,a=!1;if(this.currentTrack){let t=null==(e=this.currentTrack.trackNode)?void 0:e.track.mode;"showing"===t?(r=this.trackId,a=!0):"hidden"===t&&(r=this.trackId)}if(!a)for(let e=0;e<this.tracksInGroup.length;e++){let i=null==(t=this.tracksInGroup[e].trackNode)?void 0:t.track.mode;if("showing"===i){r=e;break}r<0&&"hidden"===i&&(r=e)}r>-1&&(this._subtitleDisplay=(null==(i=this.tracksInGroup[r].trackNode)?void 0:i.track.mode)==="showing"),this.setSubtitleTrack(r,!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;
28e.on(tz.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(tz.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(tz.MANIFEST_LOADING,this.onManifestLoading,this),e.on(tz.MANIFEST_PARSED,this.onManifestParsed,this),e.on(tz.LEVEL_LOADING,this.onLevelLoading,this),e.on(tz.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(tz.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(tz.ERROR,this.onError,this)}unregisterListeners(){let{hls:e}=this;e.off(tz.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(tz.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(tz.MANIFEST_LOADING,this.onManifestLoading,this),e.off(tz.MANIFEST_PARSED,this.onManifestParsed,this),e.off(tz.LEVEL_LOADING,this.onLevelLoading,this),e.off(tz.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(tz.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(tz.ERROR,this.onError,this)}createTracksInGroup(){var e;if(!this.media||!this.hls.config.renderTextTracksNatively)return;this.tracksInGroup.forEach(e=>{e.trackNode||(e.trackNode=oX(this.media,e.forced&&(rq.indexOf("Apple")>-1||/iPhone|iPad|iPod/.test(rV))?"forced":e.characteristics&&/transcribes-spoken-dialog/gi.test(e.characteristics)&&/describes-music-and-sound/gi.test(e.characteristics)?"captions":"subtitles",e.name,e.lang))});let t=null==(e=this.currentTrack)||null==(e=e.trackNode)?void 0:e.track;(null==t?void 0:t.mode)==="disabled"&&(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,s=this.tracksInGroup[i];if(!s||s.groupId!==r)return void this.warn(`Subtitle track with id:${i} and group:${r} not found in active group ${null==s?void 0:s.groupId}`);let n=s.details;s.details=t.details,this.log(`Subtitle track ${i} "${s.name}" lang:${s.lang} group:${r} loaded [${a.startSN}-${a.endSN}]`),i===this.trackId&&this.playlistLoaded(i,t,n)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){let t=this.hls.levels[e];if(!t)return;let i=t.subtitleGroups||null,r=this.groupIds,a=this.currentTrack;if(!i||(null==r?void 0:r.length)!==(null==i?void 0:i.length)||null!=i&&i.some(e=>(null==r?void 0:r.indexOf(e))===-1)){this.groupIds=i;let e=[];
28if(this.tracks.forEach(t=>{(t.textCodec===oH?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=av(t,e);if(i>-1)a=e[i];else{let e=av(t,this.tracks);a=this.tracks[e]}}let r=this.findTrackId(a);-1===r&&a&&(r=this.findTrackId(null)),this.log(`Updating subtitle tracks, ${e.length} track(s) found in "${null==i?void 0:i.join(",")}" group-id`),this.hls.trigger(tz.SUBTITLE_TRACKS_UPDATED,{subtitleTracks:e}),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||aE(a,e)))return r}if(e){for(let i=0;i<t.length;i++){let r=t[i];if(lm(e.attrs,r.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return i}for(let i=0;i<t.length;i++){let r=t[i];if(lm(e.attrs,r.attrs,["LANGUAGE"]))return i}}return -1}onError(e,t){!t.fatal&&t.context&&t.context.type===tJ.SUBTITLE_TRACK&&t.context.id===this.trackId&&aA(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&&aE(e,i))return i;let r=av(e,this.tracksInGroup);if(r>-1){let e=this.tracksInGroup[r];return this.setSubtitleTrack(r,!0),e}{if(i)return null;let r=av(e,t);if(r>-1)return t[r]}}}return null}loadPlaylist(e){super.loadPlaylist(),this.shouldLoadPlaylist(this.currentTrack)&&this.scheduleLoading(this.currentTrack,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);let i=e.id,r=e.groupId,a=this.getUrlWithDirectives(e.url,t),s=e.details,n=null==s?void 0:s.age;this.log(`Loading subtitle ${i} "${e.name}" lang:${e.lang} group:${r}${(null==t?void 0:t.msn)!==void 0?" at sn "+t.msn+" part "+t.part:""}${n&&s.live?" age "+n.toFixed(1)+(s.type?" "+s.type:""):""} ${a}`),this.hls.trigger(tz.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||!tK(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){r&&this.hls.trigger(tz.SUBTITLE_TRACK_SWITCH,{id:e});return}let s=!!a.details&&!a.details.live;if(a===r&&s)return;this.log(`Switching to subtitle-track ${e}`+(a?` "${a.name}" lang:${a.lang} group:${a.groupId}`:""));let{id:n,groupId:l="",name:o,type:d,url:h}=a;this.hls.trigger(tz.SUBTITLE_TRACK_SWITCH,{id:n,groupId:l,name:o,type:d,url:h});let u=this.switchParams(a.url,null==r?void 0:r.details,a.details);this.loadPlaylist(u)}},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=dO(),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}}
28,e.on(tz.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(tz.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(tz.MANIFEST_LOADING,this.onManifestLoading,this),e.on(tz.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(tz.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(tz.FRAG_LOADING,this.onFragLoading,this),e.on(tz.FRAG_LOADED,this.onFragLoaded,this),e.on(tz.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(tz.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(tz.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(tz.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(tz.BUFFER_APPENDED,this.onBufferAppended,this),e.on(tz.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){let{hls:e}=this;e.off(tz.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(tz.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(tz.MANIFEST_LOADING,this.onManifestLoading,this),e.off(tz.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(tz.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(tz.FRAG_LOADING,this.onFragLoading,this),e.off(tz.FRAG_LOADED,this.onFragLoaded,this),e.off(tz.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(tz.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(tz.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(tz.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(tz.BUFFER_APPENDED,this.onBufferAppended,this),e.off(tz.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.media=null,this.cea608Parser1=this.cea608Parser2=void 0}initCea608Parsers(){let e=new dP(this,"textTrack1"),t=new dP(this,"textTrack2"),i=new dP(this,"textTrack3"),r=new dP(this,"textTrack4");this.cea608Parser1=new dx(1,e,t),this.cea608Parser2=new dx(3,i,r)}addCues(e,t,i,r,a){var s,n,l;let o=!1;for(let e=a.length;e--;){let r=a[e],l=(s=r[0],n=r[1],Math.min(n,i)-Math.max(s,t));if(l>=0&&(r[0]=Math.min(r[0],t),r[1]=Math.max(r[1],i),o=!0,l/(i-t)>.5))return}if(o||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{let a=this.Cues.newCue(null,t,i,r),s=null==(l=this.captionsProperties[e])?void 0:l.media;this.hls.trigger(tz.CUES_PARSED,{type:"captions",cues:a,track:e,closedCaptions:s})}}onInitPtsFound(e,{id:t,timestampOffsets:i}){let{unparsedVttFrags:r}=this;t===t0.MAIN&&(this.initPTS=i),r.length&&(this.unparsedVttFrags=[],r.forEach(e=>{this.initPTS[e.frag.cc]?this.onFragLoaded(tz.FRAG_LOADED,e):this.hls.trigger(tz.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e.frag,part:null,error: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:s,languageCode:n}=t[e];a&&(r[e]=[],i[e]=oX(a,"captions",s,n,"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(tz.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=dO(),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&&!lc(this.tracks,i)){let e=i.map(e=>
28({label:e.name,kind:e.type.toLowerCase(),default:e.default,subtitleTrack:e}));this.hls.trigger(tz.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===t0.MAIN){var i,r;let{cea608Parser1:e,cea608Parser2:a,lastSn:s}=this,{cc:n,sn:l}=t.frag,o=null!=(i=null==(r=t.part)?void 0:r.index)?i:-1;e&&a&&(l!==s+1||l===s&&o!==this.lastPartIndex+1||n!==this.lastCc)&&(e.reset(),a.reset()),this.lastCc=n,this.lastSn=l,this.lastPartIndex=o}}onFragLoaded(e,t){let{frag:i,payload:r}=t;if(i.level<this.tracks.length&&i.type===t0.SUBTITLE){var a;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)===oH?this._parseIMSC1(t):this._parseVTTs(t)}}else{let e="part"in t?t.part:null;this.hls.trigger(tz.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,part:e,error:Error("Empty subtitle payload")})}}}_parseIMSC1(e){let{frag:t,payload:i}=e,r="part"in e?e.part:null,a=this.hls;oV(i,this.initPTS[t.cc],e=>{this._appendCues(e,t.level),a.trigger(tz.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:t,part:r})},e=>{a.logger.log(`Cannot parse IMSC1 (sn: ${t.sn} @${t.start}): ${e}`),a.trigger(tz.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,part:r,error:e})})}_parseVTTs(e){var t,i,r,a,s,n,l,o;let d,h,u,c,m,f,p,g,v,E,{frag:y,payload:b}=e,T="part"in e?e.part:null,{initPTS:A,unparsedVttFrags:S}=this,k=A.length-1;if(!A[y.cc]&&-1===k)return void S.push(e);let R=this.hls,L=null==(t=y.initSegment)?void 0:t.data;i=L?rB(L,new Uint8Array(b)).buffer:b,r=this.initPTS[y.cc],a=this.vttCCs,s=y.cc,n=(T&&!L?T:y).start,l=e=>{this._appendCues(e,y.level),R.trigger(tz.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:y,part:T})},o=t=>{let i=t.message.startsWith("Missing initPTS");(R.logger.log(`${i?"Deferred parsing of":"Cannot parse"} VTT cue (sn: ${y.sn} @${y.start}): ${t}`),i)?S.push(e):(this.config.enableIMSC1&&this._fallbackToIMSC1(e),R.trigger(tz.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:y,part:T,error:t}))},h=new oO,u=iO(new Uint8Array(i)).trim().replace(oU,"\n").split("\n"),c=[],m=r?function(e,t=1){return n3(e,9e4,1/t)}(r.baseTime,r.timescale):0,f="00:00.000",p=0,g=0,v=!1,E=!0,h.oncue=function(e){let t=a[s],i=a.ccOffset,l=(p-m)/9e4;if(v){if(null!=t&&t.new&&(i=a.ccOffset=t.start),l){if(!r){d=Error(oF+"MPEGTS");return}i=l-a.presentationOffset}}else if(r)i=-r.baseTime/r.timescale;else{d=Error(oF+"without X-TIMESTAMP-MAP");return}let o=e.endTime-e.startTime,h=n9((e.startTime+i-g)*9e4,9e4*n)/9e4;e.startTime=Math.max(h,0),e.endTime=Math.max(h+o,0);let u=e.text.trim();e.text=decodeURIComponent(encodeURIComponent(u)),e.id?s&&(e.id=`hlsjscc${s}_${e.id}`):e.id=o$(e.startTime,e.endTime,u),e.endTime>0&&c.push(e)},h.onparsingerror=function(e){d=e},h.onflush=function(){d?o(d):l(c)},u.forEach(e=>{if(E)if(e.startsWith("X-TIMESTAMP-MAP=")){E=!1,v=!0,e.slice(16).split(",").forEach(e=>{e.startsWith("LOCAL:")?f=e.slice(6):e.startsWith("MPEGTS:")&&(p=parseInt(e.slice(7)))});try{g=oB(f)/1e3}catch(e){d=e}return}else""===e&&(E=!1);h.parse(e+"\n")}),h.flush()}_fallbackToIMSC1(e){let{frag:t,payload:i}=e,r=this.tracks[t.level];r.textCodec||oV(i,this.initPTS[t.cc],()=>{r.textCodec=oH,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=>oZ(i,e))}else{let r=this.tracks[t];if(!r)return;let a=r.default?"default":"subtitles"+t;i.trigger(tz.CUES_PARSED,{type:"subtitles",cues:e,track:a,subtitleTrack:r})}}onFragDecrypted(e,t){let{frag:i}=t;i.type===t0.SUBTITLE&&this.onFragLoaded(tz.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!==t0.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,cueC
28ache: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++)oZ(a,e[t])}delete t[i]})}}}onBufferFlushing(e,t){let{startOffset:i,endOffset:r,endOffsetSubtitles:a,type:s}=t,{media:n}=this;if(n&&!(n.currentTime<r)){if(!s||"video"===s){let{captionsTracks:e,cueCache:t}=this;Object.keys(e).forEach(t=>oJ(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&&oJ(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++],s=127&e[r++];if((0!==a||0!==s)&&(4&i)!=0){let e=3&i;(0===e||1===e)&&(t[e].push(a),t[e].push(s))}}return t}},audioStreamController:class extends na{constructor(e,t,i){super(e,t,i,"audio-stream-controller",t0.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(tz.LEVEL_LOADED,this.onLevelLoaded,this),e.on(tz.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(tz.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(tz.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(tz.BUFFER_RESET,this.onBufferReset,this),e.on(tz.BUFFER_CREATED,this.onBufferCreated,this),e.on(tz.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(tz.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(tz.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(tz.FRAG_LOADING,this.onFragLoading,this),e.on(tz.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){let{hls:e}=this;e&&(super.unregisterListeners(),e.off(tz.LEVEL_LOADED,this.onLevelLoaded,this),e.off(tz.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(tz.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(tz.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(tz.BUFFER_RESET,this.onBufferReset,this),e.off(tz.BUFFER_CREATED,this.onBufferCreated,this),e.off(tz.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(tz.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(tz.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(tz.FRAG_LOADING,this.onFragLoading,this),e.off(tz.FRAG_BUFFERED,this.onFragBuffered,this))}onInitPtsFound(e,t){let{frag:i,id:r,initPTS:a,timescale:s,trackId:n,timestampOffsets:l}=t;if(r===t0.MAIN){let e=i.cc,t=this.fragCurrent;if(this.initPTS=l,this.log(`InitPTS for cc: ${e} found from main: ${a/s} (${a}/${s}) trackId: ${n}`),this.mainAnchor=i,this.state===ni){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===s3&&this.tick()}}getLoadPosition(){var e;return!this.startFragRequested&&this.nextLoadPosition>=0&&(null==(e=this.switchingTrack)?void 0:e.flushImmediate)!==!1?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,s=aL(this.getLevelDetails(),a,this.getLoadPosition());s&&(this.log(`Syncing with main frag at ${s.start} cc ${s.cc}`),this.startFragRequested=!1,this.nextLoadPosition=s.start,this.resetLoadingState(),this.state===s3&&this.doTickIdle())}startLoad(e,t){if(!this.levels){this.startPosition=e,this.state=s2;return}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=s3,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 s3:this.doTickIdle();break;case s6:{let{levels:e,trackId:t}=this,i=null==e?void 0:e[t],r=null==i?void 0:i.details;
28if(r&&!this.waitForLive(i)){if(this.waitForCdnTuneIn(r))break;this.state=ni}break}case s8:this.checkRetryDate();break;case ni:{let e=this.waitingData;if(e){let{frag:t,part:i,cache:r,complete:a}=e,s=this.mainAnchor;if(void 0!==this.initPTS[t.cc]){this.waitingData=null,this.state=s5;let e={frag:t,part:i,payload:r.flush().buffer,networkDetails:null};this._handleFragmentLoadProgress(e),a&&super._handleFragmentLoadComplete(e)}else s&&s.cc!==e.frag.cc&&this.syncWithAnchor(s,e.frag)}else this.state=s3}}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,s=t.config;if(!this.buffering||!r&&!this.primaryPrefetch&&(this.startFragRequested||!s.startFragPrefetch)||!(null!=i&&i[a]))return;let n=i[a],l=n.details;if(!l||this.waitForLive(n)||this.waitForCdnTuneIn(l)){this.state=s6,this.startFragRequested=!1;return}let o=this.getBufferOutput();this.bufferFlushed&&o&&(this.bufferFlushed=!1,this.afterBufferFlushed(o,t1));let d=this.getFwdBufferInfo();if(null===d)return;if(!this.switchingTrack&&this._streamEnded(d,l)){t.trigger(tz.BUFFER_EOS,{type:"audio"}),this.state=ne;return}let h=d.len,u=t.maxBufferLength,c=l.fragments,m=c[0].start,f=this.getLoadPosition(),p=this.flushing||this.switchingTrack&&!this.switchingTrack.flushImmediate?f:d.end;if(this.switchingTrack&&r&&l.PTSKnown&&f<m&&f>=this.timelineOffset&&(d.end>m||d.nextStart)&&(this.log(`Alt audio track ahead of main track, seek to start of alt audio track ${f} -> ${m} + 0.05`),r.currentTime=m+.05),h>=u&&!this.switchingTrack&&p<c[c.length-1].start)return;let g=this.getNextFragment(p,l);if(g&&this.isLoopLoading(g,p)&&(g=this.getNextFragmentLoopLoading(g,l,d,t0.MAIN,u)),!g){this.bufferFlushed=!0;return}if(this.exceedsMaxBuffer(d,u,g))return;let v=(null==(e=this.mainFragLoading)?void 0:e.frag)||null;if(!this.audioOnly&&this.startFragRequested&&v&&t5(g)&&!g.endList&&(!l.live||!this.loadingParts&&p<this.hls.liveSyncPosition)&&("OK"===this.fragmentTracker.getState(v)&&(this.mainFragLoading=v=null),v&&t5(v))){if(g.start>v.end){let e=this.fragmentTracker.getFragAtPos(p,t0.MAIN);e&&e.end>v.end&&(v=e,this.mainFragLoading={frag:e,targetBufferTime:null})}if(g.start>v.end)return}this.loadFragment(g,n,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 au(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!==s2&&(this.setInterval(100),this.state=s3,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(tz.AUDIO_TRACK_LOADED,i))}onAudioTrackLoaded(e,t){var i,r;let{levels:a}=this,{details:s,id:n,groupId:l,track:o}=t;if(!a)return void this.warn(`Audio tracks reset while loading track ${n} "${o.name}" of "${l}"`);let d=this.mainDetails;if(!d||s.endCC>d.endCC||d.expired){this.cachedTrackLoadedData=t,this.state!==s2&&(this.state=s6);return}this.cachedTrackLoadedData=null,this.log(`Audio track ${n} "${o.name}" of "${l}" loaded [${s.startSN},${s.endSN}]${s.lastPartSn?`[part-${s.lastPartSn}-${s.lastPartIndex}]`:""},duration:${s.totalduration}`);let h=a[n],u=0;if(s.live||null!=(i=h.details)&&i.live){if(this.checkLiveUpdate(s),s.deltaUpdateFailed)return;h.details&&(u=this.alignPlaylists(s,h.details,null==(r=this.levelLastLoaded)?void 0:r.details)),s.alignedSliding||(sZ(d,s,this),u=s.fragmentStart)}h.details=s,this.levelLastLoaded=h,this.startFragRequested||this.setStartPosition(d,u),this.hls.trigger(tz.AUDIO_TRACK_UPDATED,{details:s,id:n,groupId:t.groupId}),this.state!==s6||this.waitForCdnTuneIn(s)||(this.state=s3),this.tick()}_handleFragmentLoadProgress(e){var t;let i=e.frag,{part:r,payload:a}=e,{config:s,trackId:n,levels:l}=this;if(!l)return void this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`);let o=l[n];if(!o)return void this.warn("Audio track is undefined on fragment load progress");let d=o.details;if(!d){this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(i.start);return}let h=s.defaultAudioCodec||o.audioCodec||"mp4a.40.2",u=this.transmuxer;u||(u=this.transmuxer=new lh(this.hls,t0.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=new az(i.level,i.sn,i.stats.chunkCount,a.byteLength,e,-1!==e,i.duration);u.push(a,m,h,"",i,r,d.totalduration,!1,t,c)}else{this.log(`Unknown video PTS for cc ${i.cc}, waiting for video PTS before demuxing audio frag ${i.sn} of [${d.startSN} ,${d.endSN}],track ${n}`);let{cache:e}=this.waitingData=this.waitingData||{frag:i,part:r,cache:new nl,complete:!1};e.push(new Uint8Array(a)),this.state!==s2&&(this.state=ni)}}_handleFragmentLoadComplete(e){if(this.waitingData){this.waitingData.complete=!0;return}super._handleFragmentLoadComplete(e)}onBufferReset(){this.mediaBuffer=null}onBufferCreated(e,t){this.bufferFlushed=this.flushing=!1;let i=t.tracks.audio;i&&(this.mediaBuffer=i.buffer||null)}onFragLoading(e,t){!this.audioOnly&&t.frag.type===t0.MAIN&&t5(t.frag)&&(this.mainFragLoading=t,this.state===s3&&this.tick())}onFragBuffered(e,t){let{frag:i,part:r}=t;if(i.type!==t0.AUDIO){this.audioOnly||i.type!==t0.MAIN||i.elementaryStreams.video||i.elementaryStreams.audiovideo||(this.audioOnly=!0,this.mainFragLoading=null);return}if(this.fragContextChanged(i))return void this.warn(`Fragment ${i.sn}${r?" p: "+r.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);if(t5(i)){let e=this.switchingTrack;e&&(this.bufferedTrack=e)}this.fragBufferedComplete(i,r),this.media&&this.tick()}getFwdBufferInfo(){let e=this.getBufferOutput();return super.getFwdBufferInfo(e,t0.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=nt;return}switch(t.details){case tY.FRAG_GAP:case tY.FRAG_PARSING_ERROR:case tY.FRAG_DECRYPT_ERROR:case tY.FRAG_LOAD_ERROR:case tY.FRAG_LOAD_TIMEOUT:case tY.KEY_LOAD_ERROR:case tY.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(t0.AUDIO,t);break;case tY.AUDIO_TRACK_LOAD_ERROR:case tY.AUDIO_TRACK_LOAD_TIMEOUT:case tY.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==s6||(null==(i=t.context)?void 0:i.type)!==tJ.AUDIO_TRACK||(this.state=s3);break;case tY.BUFFER_APPEND_NO_PROGRESS:if("audio"!==t.parent)return;t.frag&&(t.appendsWithoutProgress||0)>
28=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 tY.BUFFER_ADD_CODEC_ERROR:case tY.BUFFER_APPEND_ERROR:if("audio"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)||this.resetLoadingState();break;case tY.BUFFER_FULL_ERROR:if("audio"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,1/0,"audio"));break;case tY.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}onBufferFlushing(e,{type:t}){t!==t2&&(this.flushing=!0)}onBufferFlushed(e,{type:t}){if(t!==t2){this.flushing=!1,this.bufferFlushed=!0,this.state===ne&&(this.state=s3);let e=this.getBufferOutput();e&&(this.afterBufferFlushed(e,t),this.tick())}}_handleTransmuxComplete(e){var t;let i="audio",{hls:r}=this,{remuxResult:a,chunkMeta:s}=e,n=this.getCurrentContext(s);if(!n)return void this.resetWhenMissingContext(s);let{frag:l,part:o,level:d}=n,{details:h}=d,{audio:u,text:c,id3:m,initSegment:f}=a;if(this.fragContextChanged(l)||!h){this.fragmentTracker.removeFragment(l),null!=f&&f.tracks&&this.resetTransmuxer();return}if(this.state=s9,u&&this.switchingTrack&&!this.switchingTrack.flushImmediate){let{config:e}=this,t=e.nextAudioTrackBufferFlushForwardOffset,i=Math.max(this.getLoadPosition()+t,l.start);super.flushMainBuffer(i,1/0,t0.AUDIO)}if(null!=f&&f.tracks){let e=l.initSegment||l;if(this.unhandledEncryptionError(f,l))return;this._bufferInitSegment(d,f.tracks,e,s),r.trigger(tz.FRAG_PARSING_INIT_SEGMENT,{frag:e,id:i,tracks:f.tracks})}if(u){let{startPTS:e,endPTS:t,startDTS:i,endDTS:r}=u;o&&(o.elementaryStreams[t1]={startPTS:e,endPTS:t,startDTS:i,endDTS:r}),l.setElementaryStreamInfo(t1,e,t,i,r),this.bufferFragmentData(u,l,o,s)}if(null!=m&&null!=(t=m.samples)&&t.length){let e=ie({id:i,frag:l,details:h},m);r.trigger(tz.FRAG_PARSING_METADATA,e)}if(c){let e=ie({id:i,frag:l,details:h},c);r.trigger(tz.FRAG_PARSING_USERDATA,e)}}_bufferInitSegment(e,t,i,r){if(this.state!==s9||(t.video&&delete t.video,t.audiovideo&&delete t.audiovideo,!t.audio))return;let a=t.audio;a.id=t0.AUDIO;let s=e.audioCodec;this.log(`Init audio buffer, container:${a.container}, codecs[level/parsed]=[${s}/${a.codec}]`),(null==s?void 0:s.split(",").length)===1&&(a.levelCodec=s),this.hls.trigger(tz.BUFFER_CODECS,t);let n=a.initSegment;if(null!=n&&n.byteLength){let e={type:"audio",frag:i,part:null,chunkMeta:r,parent:i.type,data:n};this.hls.trigger(tz.BUFFER_APPENDING,e)}this.tickImmediate()}loadFragment(e,t,i){let r=this.fragmentTracker.getState(e);if(this.switchingTrack||r===aM||r===aP){var a;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=ni;let i=this.mainDetails;i&&i.fragmentStart!==t.details.fragmentStart&&sZ(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:s,channels:n}=this.bufferedTrack;aE({name:t,lang:i,assocLang:r,characteristics:a,audioCodec:s,channels:n},e,ay)||(aT(e.url,this.hls)?(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,1/0,"audio"),this.bufferedTrack=null):this.bufferedTrack=e)}}completeAudioSwitch(e){let{hls:t}=this;this.bufferedTrack=e,this.switchingTrack=null,t.trigger(tz.AUDIO_TRACK_SWITCHED,ii({},e))}get nextAudioTrack(){return this.nextTrackId}},audioTrackController:class extends lu{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(tz.MANIFEST_LOADING,this.onManifestLoading,this),e.on(tz.MANIFEST_PARSED,this.onManifestParsed,this),e.on(tz.LEVEL_LOADING,this.onLevelLoading,this),e.on(tz.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(tz.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(tz.ER
28ROR,this.onError,this)}unregisterListeners(){let{hls:e}=this;e.off(tz.MANIFEST_LOADING,this.onManifestLoading,this),e.off(tz.MANIFEST_PARSED,this.onManifestParsed,this),e.off(tz.LEVEL_LOADING,this.onLevelLoading,this),e.off(tz.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(tz.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(tz.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,s=this.tracksInGroup[i];if(!s||s.groupId!==r)return void this.warn(`Audio track with id:${i} and group:${r} not found in active group ${null==s?void 0:s.groupId}`);let n=s.details;s.details=t.details,this.log(`Audio track ${i} "${s.name}" lang:${s.lang} group:${r} loaded [${a.startSN}-${a.endSN}]`),i===this.trackId&&this.playlistLoaded(i,t,n)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){let t=this.hls.levels[e];if(!t)return;let i=t.audioGroups||null,r=this.groupIds,a=this.currentTrack;if(!i||(null==r?void 0:r.length)!==(null==i?void 0:i.length)||null!=i&&i.some(e=>(null==r?void 0:r.indexOf(e))===-1)){this.groupIds=i,this.trackId=-1,this.currentTrack=null;let e=this.tracks.filter(e=>aA(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=av(t,e,ay);if(i>-1)a=e[i];else{let e=av(t,this.tracks);a=this.tracks[e]}}let r=this.findTrackId(a);-1===r&&a&&(r=this.findTrackId(null)),this.log(`Updating audio tracks, ${e.length} track(s) found in group(s): ${null==i?void 0:i.join(",")}`),this.hls.trigger(tz.AUDIO_TRACKS_UPDATED,{audioTracks:e});let n=this.trackId;if(-1!==r&&-1===n)this.setAudioTrack(r);else if(e.length&&-1===n){var s;let t=Error(`No audio track selected for current audio group-ID(s): ${null==(s=this.groupIds)?void 0:s.join(",")} track count: ${e.length}`);this.warn(t.message),this.hls.trigger(tz.ERROR,{type:tj.MEDIA_ERROR,details:tY.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:t})}}}onError(e,t){!t.fatal&&t.context&&t.context.type===tJ.AUDIO_TRACK&&t.context.id===this.trackId&&aA(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 a=this.allAudioTracks;
28if(this.selectDefaultTrack=!1,a.length){let s=this.currentTrack;if(s&&aE(e,s,ay))return s;let n=av(e,this.tracksInGroup,ay);if(n>-1){let t=this.tracksInGroup[n];return this.setAudioTrack(n,"flushImmediate"in e&&e.flushImmediate),t}if(s){var i,r;let s,n,l,o,d,h,u=t.loadLevel;-1===u&&(u=t.firstAutoLevel);let c=(i=t.levels,s=i[r=u],(n=i.reduce((e,t,i)=>{let r=t.uri;return(e[r]||(e[r]=[])).push(i),e},{})[s.uri]).length>1&&(r=Math.max.apply(Math,n)),l=s.videoRange,o=s.frameRate,d=s.codecSet.substring(0,4),(h=ab(i,r,t=>{if(t.videoRange!==l||t.frameRate!==o||t.codecSet.substring(0,4)!==d)return!1;let i=t.audioGroups;return av(e,a.filter(e=>aA(e.groupId,i)),ay)>-1}))>-1?h:ab(i,r,t=>{let i=t.audioGroups;return av(e,a.filter(e=>aA(e.groupId,i)),ay)>-1}));if(-1===c)return null;t.nextLoadLevel=c}if(e.channels||e.audioCodec){let t=av(e,a);if(t>-1)return a[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],s=a.details&&!a.details.live;if(e===this.trackId&&a===r&&s||(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(tz.AUDIO_TRACK_SWITCHING,ii(ii({},a),{},{flushImmediate:t})),s))return;let n=this.switchParams(a.url,null==r?void 0:r.details,a.details);this.loadPlaylist(n)}findTrackId(e){let t=this.tracksInGroup;for(let i=0;i<t.length;i++){let r=t[i];if((!this.selectDefaultTrack||r.default)&&(!e||aE(e,r,ay)))return i}if(e){let{name:i,lang:r,assocLang:a,characteristics:s,audioCodec:n,channels:l}=e;for(let e=0;e<t.length;e++)if(aE({name:i,lang:r,assocLang:a,characteristics:s,audioCodec:n,channels:l},t[e],ay))return e;for(let i=0;i<t.length;i++){let r=t[i];if(lm(e.attrs,r.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return i}for(let i=0;i<t.length;i++){let r=t[i];if(lm(e.attrs,r.attrs,["LANGUAGE"]))return i}}return -1}loadPlaylist(e){super.loadPlaylist();let t=this.currentTrack;this.shouldLoadPlaylist(t)&&aT(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),s=e.details,n=null==s?void 0:s.age;this.log(`Loading audio-track ${i} "${e.name}" lang:${e.lang} group:${r}${(null==t?void 0:t.msn)!==void 0?" at sn "+t.msn+" part "+t.part:""}${n&&s.live?" age "+n.toFixed(1)+(s.type?" "+s.type:""):""} ${a}`),this.hls.trigger(tz.AUDIO_TRACK_LOADING,{url:a,id:i,groupId:r,deliveryDirectives:t||null,track:e})}},emeController:oS,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("r")),this.buffering=!0},this.onPlay=()=>{this.initialized||this.setPlayerState("s")},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1,this.setPlayerState("p")},this.onPause=()=>{this.media&&!this.media.ended&&this.setPlayerState("a")},this.onSeeking=()=>{this.initialized&&this.setPlayerState("k")},this.onSeeked=()=>{var e;this.initialized&&null!=(e=this.media)&&e.paused&&this.setPlayerState("a")},this.onRateChange=()=>{this.reporter&&this.media&&this.reporter.update({pr:this.media.playbackRate})},this.applyPlaylistData=e=>{try{this.apply(e,{ot:"m",su:!this.initialized})}catch(e){this.hls.logger.warn("Could not generate manifest CMCD data.",e)}},this.applyFragmentData=e=>{try{var t,i,r,a;let{frag:s,part:n}=e,l=this.hls.levels[s.level],o=this.getObjectType(s,l),d={d:1e3*(n||s).duration,ot:o};if("v"===o||"a"===o||"av"===o||null==o&&("main"===s.type||"audio"===s.type)){let e=l.bitrate/1e3;d.br=[e];let{cmcd:r}=this.config,a=null!=(t=null==r?void 0:r.rtpSafetyFactor)?t:5;if(d.rtp=100*Math.round(e*a/100),"av"===o||null==o&&"main"===s.type){let e=this.getTopBandwidth()/1e3;tK(e)&&(d.tb=[e]);let t=this.getLowestBandwidth()/1e3;tK(t)&&(d.lb=[t])}let n=this.getBufferLength(s);if(tK(n)){d.bl=[n];let e=(null==(i=this.media)?void 0:i.playbackRate)||1;d.dl=100*Math.round(n/e/100)}this.playheadLevel&&(d.pb=[this.playheadLevel.bitrate/1e3]);let h=this.hls.maxAutoLevel;if(h>=0){let e=this.hls.levels[h];e&&(d.tpb=[e.bitrate/1e3])}}let h=n?this.getNextPart(n):this.getNextFrag(s);null!=h&&h.url&&h.url!==s.url&&(h.byteRange.length>0?d.nor=[(r=h.url,a={r:`${h.byteRange[0]}-${h.byteRange[1]}`},new lk(r,a))]:d.nor=[h.url]),this.apply(e,d)}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,s=null==a||null==(r=a.eventTargets)?void 0:r.some(e=>{var t;return null==(t=e.events)?void 0:t.includes("rr")});if(this.reporter&&i.loading.first>0&&s)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;const 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;
28let r=i.version||1;if(this.reporter=new ov({sid:i.sessionId||this.hls.sessionId,cid:i.contentId,version:r,transmissionMode:!0===i.useHeaders?oh:od,enabledKeys:null!=(e=i.includeKeys)?e:[...r>=2?oo:l5],eventTargets:(null!=(t=i.eventTargets)?t:[]).map(e=>{let{includeKeys:t}=e;return ii(ii({},ir(e,oE)),{},{enabledKeys:null!=t?t:oo})})},i.loader),this.reporter.update({sf:"h",sta:this.playerState}),i.reporterCallback){let e=this.reporter;i.reporterCallback({updateCustomData:t=>{oy(t)&&e.update(t)},recordCustomEvent:(t,i={})=>{oy(i)&&e.recordEvent("ce",ii({cen:t},i))}})}this.reporter.start()}registerListeners(){let e=this.hls;e.on(tz.MANIFEST_LOADING,this.onManifestLoading,this),e.on(tz.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(tz.MEDIA_DETACHED,this.onMediaDetached,this),e.on(tz.MEDIA_ENDED,this.onMediaEnded,this),e.on(tz.ERROR,this.onError,this),e.on(tz.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(tz.LEVEL_SWITCHED,this.onLevelSwitched,this),e.on(tz.BUFFER_APPENDED,this.onBufferInfoChange,this),e.on(tz.BUFFER_FLUSHED,this.onBufferInfoChange,this)}unregisterListeners(){let e=this.hls;e.off(tz.MANIFEST_LOADING,this.onManifestLoading,this),e.off(tz.MEDIA_ATTA
28CHING,this.onMediaAttaching,this),e.off(tz.MEDIA_DETACHED,this.onMediaDetached,this),e.off(tz.MEDIA_ENDED,this.onMediaEnded,this),e.off(tz.ERROR,this.onError,this),e.off(tz.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(tz.LEVEL_SWITCHED,this.onLevelSwitched,this),e.off(tz.BUFFER_APPENDED,this.onBufferInfoChange,this),e.off(tz.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?"s":"d"),sJ(i,"waiting",this.onWaiting),sJ(i,"play",this.onPlay),sJ(i,"playing",this.onPlaying),sJ(i,"pause",this.onPause),sJ(i,"seeking",this.onSeeking),sJ(i,"seeked",this.onSeeked),sJ(i,"ratechange",this.onRateChange)}onMediaDetached(){let e=this.media;e&&(s0(e,"waiting",this.onWaiting),s0(e,"play",this.onPlay),s0(e,"playing",this.onPlaying),s0(e,"pause",this.onPause),s0(e,"seeking",this.onSeeking),s0(e,"seeked",this.onSeeked),s0(e,"ratechange",this.onRateChange),this.media=null)}onMediaEnded(e,t){this.setPlayerState("e")}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("d")}onError(e,t){t.fatal&&(this.setPlayerState("f"),this.reporter&&this.reporter.recordEvent("e",{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("bc",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?"ll":"l":"v"}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="i"===t.ot||"v"===t.ot||"av"===t.ot;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"tt";if("initSegment"===e.sn)return"i";if("audio"===i)return"a";if("main"===i){if(e.hasStreams){let t=e.elementaryStreams;if(t.audiovideo)return"av";if(t.video)return"v";if(t.audio)return"a"}if(t){let{audioCodec:e,videoCodec:i}=t;if(!this.hls.audioTracks.length){if(e&&i)return"av";if(e)return"a"}if(i)return"v"}}}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)}),tK(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();tK(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:s}=a;this.loader.load(e,r,ii(ii({},a),{},{onSuccess:(t,r,a,n)=>{s(t,r,a,n),i(e.url,t,r)}}))}}}},contentSteeringController:class extends iv{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(tz.MANIFEST_LOADING,this.onManifestLoading,this),e.on(tz.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(tz.MANIFEST_PARSED,this.onManifestParsed,this),e.on(tz.ER
28ROR,this.onError,this)}unregisterListeners(){let e=this.hls;e&&(e.off(tz.MANIFEST_LOADING,this.onManifestLoading,this),e.off(tz.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(tz.MANIFEST_PARSED,this.onManifestParsed,this),e.off(tz.ERROR,this.onError,this))}pathways(){return(this.levels||[]).reduce((e,t)=>(-1===e.indexOf(t.pathwayId)&&e.push(t.pathwayId),e),[])}get pathwayPriority(){return this._pathwayPriority}set pathwayPriority(e){this.updatePathwayPriority(e)}startLoad(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){let e=1e3*this.timeToLoad-(performance.now()-this.updated);if(e>0)return void this.scheduleRefresh(this.uri,e)}this.loadSteeringManifest(this.uri)}}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()}clearTimeout(){-1!==this.reloadTimer&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(e){let t=this.levels;t&&(this.levels=t.filter(t=>t!==e))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(e,t){let{contentSteering:i}=t;null!==i&&(this.pathwayId=i.pathwayId,this.uri=i.uri,this.started&&this.startLoad())}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}onError(e,t){let{errorAction:i}=t;if((null==i?void 0:i.action)===2&&1&i.flags){let e=this.levels,r=this._pathwayPriority,a=this.pathwayId;if(t.context){let{groupId:i,pathwayId:r,type:s}=t.context;i&&e?a=this.getPathwayForGroupId(i,s,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!==tY.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:e} priorities: ${am(r)} penalized: ${am(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){let t;this._pathwayPriority=e;let i=this.penalizedPathways,r=performance.now();
28Object.keys(i).forEach(e=>{r-i[e]>3e5&&delete i[e]});for(let r=0;r<e.length;r++){let a=e[r];if(a in i)continue;if(a===this.pathwayId)return;let s=this.hls.nextLoadLevel,n=this.hls.levels[s];if((t=this.getLevelsForPathway(a)).length>0){this.log(`Setting Pathway to "${a}"`),this.pathwayId=a,sj(t),this.hls.trigger(tz.LEVELS_UPDATED,{levels:t});let e=this.hls.levels[s];n&&e&&this.levels&&(e.attrs["STABLE-VARIANT-ID"]!==n.attrs["STABLE-VARIANT-ID"]&&e.bitrate!==n.bitrate&&this.log(`Unstable Pathways change from bitrate ${n.bitrate} to ${e.bitrate}`),this.hls.nextLoadLevel=s);break}}}getPathwayForGroupId(e,t,i){let r=this.getLevelsForPathway(i).concat(this.levels||[]);for(let i=0;i<r.length;i++)if(t===tJ.AUDIO_TRACK&&r[i].hasAudioGroup(e)||t===tJ.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":s,"URI-REPLACEMENT":n}=e;if(t.some(e=>e.pathwayId===a))return;let l=this.getLevelsForPathway(s).map(e=>{let t=new a5(e.attrs);t["PATHWAY-ID"]=a;let s=t.AUDIO&&`${t.AUDIO}_clone_${a}`,l=t.SUBTITLES&&`${t.SUBTITLES}_clone_${a}`;s&&(i[t.AUDIO]=s,t.AUDIO=s),l&&(r[t.SUBTITLES]=l,t.SUBTITLES=l);let o=oT(e.uri,t["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",n),d=new au({attrs:t,audioCodec:e.audioCodec,bitrate:e.bitrate,height:e.height,name:e.name,url:o,videoCodec:e.videoCodec,width:e.width});if(e.audioGroups)for(let t=1;t<e.audioGroups.length;t++)d.addGroupId("audio",`${e.audioGroups[t]}_clone_${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(...l),ob(this.audioTracks,i,n,a),ob(this.subtitleTracks,r,n,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(t){this.enabled=!1,this.log(`Failed to parse Steering Manifest URI: ${e}`);return}if("data:"!==t.protocol){let e=0|(this.hls.bandwidthEstimate||i.abrEwmaDefaultEstimate);an(t,"_HLS_pathway",this.pathwayId),an(t,"_HLS_throughput",""+e)}let a={type:tJ.STEERING_MANIFEST,responseType:"json",url:t.href},s=i.steeringManifestLoadPolicy.default,n=s.errorRetry||s.timeoutRetry||{},l={loadPolicy:s,timeout:s.maxLoadTimeMs,maxRetry:n.maxNumRetry||0,retryDelay:n.retryDelayMs||0,maxRetryDelay:n.maxRetryDelayMs||0};this.log(`Requesting steering manifest: ${t}`),this.loader.load(a,l,{onSuccess:(e,i,r,a)=>{this.log(`Loaded steering manifest: "${t}"`);let s=e.data;if((null==s?void 0:s.VERSION)!==1)return void this.log(`Steering VERSION ${s.VERSION} not supported!`);this.updated=performance.now(),this.timeToLoad=s.TTL;let{"RELOAD-URI":n,"PATHWAY-CLONES":l,"PATHWAY-PRIORITY":o}=s;if(n)try{this.uri=new self.URL(n,t).href}catch(e){this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${n}`);return}this.scheduleRefresh(this.uri||r.url),l&&this.clonePathways(l);let d={steeringManifest:s,url:t.toString()};this.hls.trigger(tz.STEERING_MANIFEST_LOADED,d),o&&this.updatePathwayPriority(o)},onError:(e,t,i,r)=>{if(this.log(`Error loading steering manifest: ${e.code} ${e.text} (${t.url})`),this.stopLoad(),410===e.code){this.enabled=!1,this.log(`Steering manifest ${t.url} no longer available`);return}let 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))}this.log(`Steering manifest ${t.url} rate limited`);return}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)}})}scheduleRefresh(e,t=1e3*this.timeToLoad){this.clearTimeout(),this.reloadTimer=self.setTimeout(()=>{var t;let i=null==(t=this.hls)?void 0:t.media;i&&!i.ended?this.loadSteeringManifest(e):this.scheduleRefresh(e,1e3*this.timeToLoad)},t)}},iframeController:class extends iv{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,n||(n=function(e){return class extends e{constructor(e,t,i,r){e.streamController||(e.streamController=de),super(e),this._url=t,this.streamController.setInitPts(i),this.streamController.initDetails=r}loadSource(){}loadMediaAt(e,t=di){if(e<0)return;let i=ii(ii({},di),t);this.loadingEnabled||this.startLoad(e),this.streamController.loadMediaAt(e,i)}}}(t)),l||(l=function(e){return class extends e{constructor(e,t,i,r){e.cmcdController=void 0,e.emeController=void 0,e.streamController||(e.streamController=dt),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 Error("Image I-Frame player does not accept HTMLMediaElements")}detachMedia(){}recoverMediaError(){}transferMedia(){return null}loadMediaAt(e){if(e<0)return null;this.loadingEnabled||this.startLoad(e),this.streamController.loadMediaAt(e)}}}(n)),this.hls=e,this.iframeInstances=[],this.registerListeners()}registerListeners(){let e=this.hls;e&&(e.on(tz.MANIFEST_LOADING,this.clearAsset,this),e.on(tz.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(tz.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(tz.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(tz.FRAG_BUFFERED,this.onFragBuffered,this),e.on(tz.DESTROYING,this.onDestroying,this))}unregisterListeners(){let e=this.hls;e&&(e.off(tz.MANIFEST_LOADING,this.clearAsset,this),e.off(tz.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(tz.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(tz.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(tz.FRAG_BUFFERED,this.onFragBuffered,this),e.off(tz.DESTROYING,this.onDestroying,this))}clearAsset(){this.stats=void 0,this.variableList=null,this.initPTS=[],this.iframeInstances.forEac
28h(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===t0.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=>{if(!e.loadingEnabled){var t;e.startLoad((null==(t=this.hls)||null==(t=t.media)?void 0:t.currentTime)||0)}})}createIFramePlayer(e){var t;return this.createInstance(n,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(l,i,e,"image-")}createInstance(e,t,i,r){let{hls:a}=this;if(!a)return null;let{url:s,userConfig:n,latestLevelDetails:l,loadLevelObj:o,loadLevel:d,bandwidthEstimate:h,sessionId:u}=a,{stats:c,variableList:m}=this;if(!(null!=t&&t.length)||!c||!s)return null;let f=`${r||""}iframe-player-${this.instanceCounter++}`,p=a.levels,g=o||p[d],v=a_(g,n.videoPreference),E=(null==g?void 0:g.pathwayId)||".",y=new e(ii(ii({},n),{},{loggerId:f,primarySessionId:u,videoPreference:v,abrEwmaDefaultEstimate:h,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),s,this.initPTS,l);return this.iframeInstances=this.iframeInstances.filter(e=>!e.url),this.iframeInstances.push(y),y.trigger(tz.MANIFEST_LOADED,{levels:t,contentSteering:{uri:"",pathwayId:E},sessionKeys:null,audioTracks:[],iframeVariants:[],sessionData:null,startTimeOffset:null,stats:c,networkDetails:null,url:s,variableList:m}),y}},interstitialsController:class extends iv{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=()=>{var e,t;let i=this.currentTime;if(void 0===i||this.playbackDisabled||!this.schedule)return;let r=i-this.timelinePos;if(Math.abs(r)<1/7056e5)return;let a=r<=-.01;-1!==this.timelinePos||this.effectivePlayingItem||this.checkStart(),this.timelinePos=i,this.bufferedPos=i;let s=this.playingItem;if(!s)return void this.checkBuffer();if(a&&this.schedule.resetErrorsInRange(i,i-r)&&this.updateSchedule(!0),this.checkBuffer(),a&&i<s.start||i>=s.end){let t=this.findItemIndex(s),r=this.schedule.findItemIndexAtTime(i);if(-1===r&&(r=t+(a?-1:1),this.log(`seeked ${a?"back ":""}to position not covered by schedule ${i} (resolving from ${t} to ${r})`)),!this.isInterstitial(s)&&null!=(e=this.media)&&e.paused&&(this.shouldPlay=!1),!a&&r>t){let e=this.schedule.findJumpRestrictedIndex(t+1,r);if(e>t)return void this.setSchedulePosition(e)}this.setSchedulePosition(r);return}let n=this.playingAsset;if(!n){if(this.playingLastItem&&this.isInterstitial(s)){let e=s.event.assetList[0];e&&(this.endedItem=this.playingItem,this.playingItem=null,this.setScheduleToAssetAtTime(i,e))}return}let l=n.timelineStart,o=n.duration||0;(a&&i<l||i>=l+o)&&(null!=(t=s.event)&&t.appendInPlace&&(this.clearAssetPlayers(s.event,s),this.flushFrontBuffer(i)),this.setScheduleToAssetAtTime(i,n))},this.onTimeupdate=()=>{let e=this.currentTime;if(void 0===e||this.playbackDisabled||(-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)=>
vendor: 1,536 bytes, lines 28-29
28{let i=this.schedule;if(!i)return;let r=this.playingItem,a=i.events||[],s=i.items||[],n=i.durations,l=e.map(e=>e.identifier),o=!!(a.length||l.length);(o||t)&&this.log(`INTERSTITIALS_UPDATED (${a.length}): ${a}
29Schedule: ${s.map(e=>dm(e))} pos: ${this.timelinePos}`),l.length&&this.log(`Removed events ${l}`);let d=null,h=null;r&&(d=this.updateItem(r,this.timelinePos),this.itemsMatch(r,d)?this.playingItem=d:this.waitingItem=null),this.waitingItem=this.updateItem(this.waitingItem);let u=this.bufferingItem;if(u&&(h=this.updateItem(u,this.bufferedPos),this.itemsMatch(u,h)?this.bufferingItem=h:u.event&&(this.bufferingItem=this.playingItem,this.clearInterstitial(u.event,null))),e.forEach(e=>{e.assetList.forEach(e=>{this.clearAssetPlayer(e.identifier,null)})}),this.playerQueue.forEach(e=>{if(e.interstitial.appendInPlace){let t=e.assetItem.timelineStart,i=e.timelineOffset-t;if(i)try{e.timelineOffset=t}catch(r){Math.abs(i)>.025&&this.warn(`${r} ("${e.assetId}" ${e.timelineOffset}->${t})`)}}}),o||t){if(this.hls.trigger(tz.INTERSTITIALS_UPDATED,{events:a.slice(0),schedule:s.slice(0),durations:n,removedIds:l}),this.isInterstitial(r)&&l.indexOf(r.event.identifier)>-1){this.warn(`Interstitial "${r.event.identifier}" removed while playing`),this.primaryFallback(r.event);return}r&&this.trimInPlace(d,r),u&&h!==d&&this.trimInPlace(h,u),this.checkBuffer()}},this.hls=e,this.HlsPlayerClass=t,this.assetListLoader=new df(e),this.schedule=new dc(this.onScheduleUpdate,e.logger),this.registerListeners()}registerListeners(){let e=this.hls;
29e&&(e.on(tz.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(tz.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(tz.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(tz.MANIFEST_LOADING,this.onManifestLoading,this),e.on(tz.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(tz.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(tz.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.on(tz.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(tz.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.on(tz.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.on(tz.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.on(tz.BUFFER_APPENDED,this.onBufferAppended,this),e.on(tz.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(tz.BUFFERED_TO_END,this.onBufferedToEnd,this),e.on(tz.MEDIA_ENDED,this.onMediaEnded,this),e.on(tz.ERROR,this.onError,this),e.on(tz.DESTROYING,this.onDestroying,this))}unregisterListeners(){let e=this.hls;e&&(e.off(tz.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(tz.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(tz.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(tz.MANIFEST_LOADING,this.onManifestLoading,this),e.off(tz.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(tz.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(tz.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.off(tz.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(tz.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.off(tz.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.off(tz.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.off(tz.BUFFER_CODECS,this.onBufferCodecs,this),e.off(tz.BUFFER_APPENDED,this.onBufferAppended,this),e.off(tz.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(tz.BUFFERED_TO_END,this.onBufferedToEnd,this),e.off(tz.MEDIA_ENDED,this.onMediaEnded,this),e.off(tz.ERROR,this.onError,this),e.off(tz.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){s0(e,"play",this.onPlay),s0(e,"pause",this.onPause),s0(e,"seeking",this.onSeeking),s0(e,"timeupdate",this.onTimeupdate)}onMediaAttaching(e,t){let i=this.media=t.media;sJ(i,"seeking",this.onSeeking),sJ(i,"timeupdate",this.onTimeupdate),sJ(i,"play",this.onPlay),sJ(i,"pause",this.onPause)}onMediaAttached(e,t){let i=this.effectivePlayingItem,r=this.detachedData;if(this.detachedData=null,null===i)this.checkStart();else if(!r){this.clearScheduleState();let e=this.findItemIndex(i);this.setSchedulePosition(e)}}clearScheduleState(){this.log("clear schedule state"),this.playingItem=this.bufferingItem=this.waitingItem=this.endedItem=this.playingAsset=this.endedAsset=this.bufferingAsset=null}onMediaDetaching(e,t){let i=!!t.transferMedia,r=this.media;if(this.media=null,!i&&(r&&this.removeMediaListeners(r),this.detachedData)){let e=this.getBufferingPlayer();e&&(this.log(`Removing schedule state for detachedData and ${e}`),this.playingAsset=this.endedAsset=this.bufferingAsset=this.bufferingItem=this.waitingItem=this.detachedData=null,e.detachMedia()),this.shouldPlay=!1}}get interstitialsManager(){if(!this.hls)return null;if(this.manager)return this.manager;let e=this,t=t=>t?e.getAssetPlayer(t.identifier):t,i=(i,a,s,n,l)=>{if(i){let o=i[a].start,d=i.event;if(d){if("playout"===a||d.timelineOccupancy!==dr.Point){let e=t(s);(null==e?void 0:e.interstitial)===d&&(o+=e.assetItem.startOffset+e[l])}}else o+=("bufferedPos"===n?r():e[n])-i.start;return o}return 0},r=()=>{let t=e.bufferedPos;return t===Number.MAX_VALUE?a("primary"):Math.max(t,0)},a=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=(r,a)=>{var s,n;let l=e.effectivePlayingItem;if(null!=l&&null!=(s=l.event)&&s.restrictions.skip||!e.schedule)return;e.log(`seek to ${r} "${a}"`);let o=e.effectivePlayingItem,d=e.schedule.findItemIndexAtTime(r,a),h=null==(n=e.schedule.items)?void 0:n[d],u=e.getBuffer
29ingPlayer(),c=null==u?void 0:u.interstitial,m=null==c?void 0:c.appendInPlace,f=o&&e.itemsMatch(o,h);if(o&&(m||f)){let s=t(e.playingAsset),n=(null==s?void 0:s.media)||e.primaryMedia;if(n){let t="primary"===a?n.currentTime:i(o,a,e.playingAsset,"timelinePos","currentTime"),l=r-t,d=(m?t:n.currentTime)+l;if(d>=0&&(!s||m||d<=s.duration)){n.currentTime=d;return}}}if(h){let t=r;if("primary"!==a){let e=r-h[a].start;t=h.start+e}let i=!e.isInterstitial(h);if((!e.isInterstitial(o)||o.event.appendInPlace)&&(i||h.event.appendInPlace)){let i=e.media||(m?null==u?void 0:u.media:null);i&&(i.currentTime=t)}else if(o){let s=e.findItemIndex(o);if(d>s){let t=e.schedule.findJumpRestrictedIndex(s+1,d);if(t>s)return void e.setSchedulePosition(t)}let n=0;if(i)e.timelinePos=t,e.checkBuffer();else{let e=h.event.assetList,t=r-(h[a]||h).start;for(let i=e.length;i--;){let r=e[i];if(r.duration&&t>=r.startOffset&&t<r.startOffset+r.duration){n=i;break}}}e.setSchedulePosition(d,n)}}},n=()=>{let t=e.effectivePlayingItem;if(e.isInterstitial(t))return t;let i=e.bufferingItem||e.waitingItem;return e.isInterstitial(i)?i:null},l={get bufferedEnd(){let t=e.bufferingItem||e.waitingItem,r=e.bufferingItem;if(r&&r===t){var o;return i(r,"playout",e.bufferingAsset,"bufferedPos","bufferedEnd")-r.playout.start||(null==(o=e.bufferingAsset)?void 0:o.startOffset)||0}return 0},get currentTime(){let t=n(),r=e.effectivePlayingItem;if(r&&r===t)return i(r,"playout",e.effectivePlayingAsset,"timelinePos","currentTime")-r.playout.start;return 0},set currentTime(time){let t=n(),i=e.effectivePlayingItem;i&&i===t&&s(time+i.playout.start,"playout")},get duration(){let e=n();if(e)return e.playout.end-e.playout.start;return 0},get assetPlayers(){var d;let t=null==(d=n())?void 0:d.event.assetList;if(t)return t.map(t=>e.getAssetPlayer(t.identifier));return[]},get playingIndex(){var h;let t=null==(h=n())?void 0:h.event;if(t&&e.effectivePlayingAsset)return t.findAssetIndex(e.effectivePlayingAsset);return -1},get scheduleItem(){return n()}};return this.manager={get events(){var u;return(null==(u=e.schedule)||null==(u=u.events)?void 0:u.slice(0))||[]},get schedule(){var c;return(null==(c=e.schedule)||null==(c=c.items)?void 0:c.slice(0))||[]},get interstitialPlayer(){if(n())return l;return null},get playerQueue(){return e.playerQueue.slice(0)},get bufferingAsset(){return e.bufferingAsset},get bufferingItem(){return e.bufferingItem||e.waitingItem},get bufferingIndex(){let t=e.bufferingItem||e.waitingItem;return e.findItemIndex(t)},get playingAsset(){return e.effectivePlayingAsset},get playingItem(){return e.effectivePlayingItem},get playingIndex(){let t=e.effectivePlayingItem;return e.findItemIndex(t)},primary:{get bufferedEnd(){return r()},get currentTime(){let t=e.timelinePos;return t>0?t:0},set currentTime(time){s(time,"primary")},get duration(){return a("primary")},get seekableStart(){return e.seekableStart}},integrated:{get bufferedEnd(){return i(e.bufferingItem||e.waitingItem,"integrated",e.bufferingAsset,"bufferedPos","bufferedEnd")},get currentTime(){return i(e.effectivePlayingItem,"integrated",e.effectivePlayingAsset,"timelinePos","currentTime")},set currentTime(time){s(time,"integrated")},get duration(){return a("integrated")},get seekableStart(){return((t,i)=>{var r,a;if(0!==t&&"primary"!==i&&null!=(r=e.schedule)&&r.length){let r=e.schedule.findItemIndexAtTime(t),s=null==(a=e.schedule.items)?void 0:a[r];if(s)return t+(s[i].start-s.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);i.appendInPlace?s(t.playout.start+t.event.duration+.001,"playout"):e.advanceAfterAssetEnded(i,r,1/0)}}}}get effectivePlayingItem(){return this.waitingItem||this.playingItem||this.endedItem}get effectivePlayingAsset(){return this.playingAsset||this.endedAsset}get playingLastItem(){var e;let t=this.playingItem,i=null==(e=this.schedule)?void 0:e.items;return!!this.playbackStarted&&!!t&&!!i&&this.findItemIndex(t)===i.length-1}get playbackStarted(){return null!==this.effectivePlayingItem}get currentTime(){var e,t;if(null===this.mediaSelection)return;let i=this.waitingItem||this.playingItem;if(this.isInterstitial(i)&&!i.event.appendInPlace)return;let r=this.media;!r&&null!=(e=this.bufferingItem)&&null!=(e=e.event)&&e.appendInPlace&&(r=this.primaryMedia);let a=null==(t=r)?void 0:t.currentTime;if(void 0!==a&&tK(a))return a}get primaryMedia(){var e;return this.media||(null==(e=this.detachedData)?void 0:e.media)||null}isInterstitial(e){return!!(null!=e&&e.event)}retreiveMediaSource(e,t){let i=this.getAssetPlayer(e);i&&this.transferMediaFromPlayer(i,t)}transferMediaFromPlayer(e,t){let i=e.interstitial.appendInPlace,r=e.media;if(i&&r===this.primaryMedia){if(this.bufferingAsset=null,(!t||this.isInterstitial(t)&&!t.event.appendInPlace)&&t&&r){this.detachedData={media:r};return}let i=e.transferMedia();this.log(`transfer MediaSource from ${e} ${am(i)}`),this.detachedData=i}else t&&r&&(this.shouldPlay||(this.shouldPlay=!r.paused))}transferMediaTo(e,t){var i,r;let a;if(e.media===t)return;let s=null,n=this.hls,l=e!==n,o=l&&e.interstitial.appendInPlace,d=null==(i=this.detachedData)?void 0:i.mediaSource;if(n.media)o&&(s=n.transferMedia(),this.detachedData=s),a="Primary";
29else{let e=this.getBufferingPlayer();e?(s=e.transferMedia(),this.detachedData=s,a=`${e}`):a=d?"detached MediaSource":"detached media"}if(!s){if(d)s=this.detachedData,this.log(`using detachedData: MediaSource ${am(s)}`);else if(!this.detachedData||n.media===t){let e=this.playerQueue;e.length>1&&e.forEach(e=>{if(l&&e.interstitial.appendInPlace!==o){let t=e.interstitial;this.clearInterstitial(e.interstitial,null),t.appendInPlace=!1,t.appendInPlace&&this.warn(`Could not change append strategy for queued assets ${t}`)}}),this.hls.detachMedia(),this.detachedData={media:t}}}let h=s&&"mediaSource"in s&&(null==(r=s.mediaSource)?void 0:r.readyState)!=="closed";if(this.log(`${h?"transfering MediaSource":"attaching media"} to ${l?e:"Primary"} from ${a} (media.currentTime: ${t.currentTime})`),!h&&!l)return void e.attachMedia(t);let u=h&&s?ii({},s):{media:t},c=this.schedule;if(c&&l){let t=e.assetId===c.assetIdAtEnd;u.overrides={duration:c.duration,endOfStream:t||!1===e.appendInPlace}}if(!h&&o){let t=e.assetItem.timelineStart;if(t){let i=e.hls,r=Math.max(this.timelinePos-t,Number.EPSILON);i.startPosition!==r&&(this.log(`Set ${e} startPosition: ${r}`),i.config.startPosition=r,i.loadingEnabled&&i.startLoad(r))}}e.attachMedia(u)}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(dg("checkStart (preroll)",r));let i=e.findEventIndex(t[0].identifier);this.setSchedulePosition(i)}else if(r>=0||!this.primaryLive){this.log(dg("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(dg("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=dd(i,r);if(i.isAssetPastPlayoutLimit(a)){if(this.schedule){var s;let t=this.getNextItemIndex(e,!0),i=null==(s=this.schedule.items)?void 0:s[t];i&&this.bufferedToItem(i)}}else this.bufferedToEvent(e,a)}livePrerollResumption(e,t){if(e.cue.pre&&this.primaryLive&&!tK(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=dd(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 s=e.resumeTime;this.timelinePos<s&&(this.log(dg("advanceAfterAssetEnded",s)),this.timelinePos=s,e.appendInPlace&&!i[a].event&&this.hls.startLoad(s+.01),this.checkBuffer(this.bufferedPos<s)),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),s=i.findAssetIndex(a,e);this.advanceAfterAssetEnded(a,t,s-1)}}setSchedulePosition(e,t){var i,r,a,s;let n=null==(i=this.schedule)?void 0:i.items;if(!n||this.playbackDisabled)return;let l=e>=0?n[e]:null;this.log(`setSchedulePosition ${e}, ${t} (${l?dm(l):l}) pos: ${this.timelinePos}`);let o=this.waitingItem||this.playingItem,d=this.playingLastItem;if(this.isInterstitial(o)){let i=o.event,h=this.playingAsset,u=null==h?void 0:h.identifier,c=u?this.getAssetPlayer(u):null;if(c&&u&&(!this.eventItemsMatch(o,l)||void 0!==t&&u!==i.assetList[t].identifier)){let t=i.findAssetIndex(h);if(this.log(`INTERSTITIAL_ASSET_ENDED ${t+1}/${i.assetList.length} ${dh(h)}`),this.endedAsset=h,this.playingAsset=null,this.hls.trigger(tz.INTERSTITIAL_ASSET_ENDED,{asset:h,assetListIndex:t,event:i,schedule:n.slice(0),scheduleIndex:e,player:c}),o!==this.playingItem){this.itemsMatch(o,this.playingItem)&&!this.playingAsset&&this.advanceAfterAssetEnded(i,this.findItemIndex(this.playingItem),t);return}this.retreiveMediaSource(u,l),c.media&&!(null!=(r=this.detachedData)&&r.mediaSource)&&c.detachMedia()}if(!this.eventItemsMatch(o,l)&&(this.endedItem=o,this.playingItem=this.waitingItem=null,this.log(`INTERSTITIAL_ENDED ${i} ${dm(o)}`),i.hasPlayed=!0,this.hls.trigger(tz.INTERSTITIAL_ENDED,{event:i,schedule:n.slice(0),scheduleIndex:e}),i.cue.once&&this.hls)){this.updateSchedule();let e=null==(a=this.schedule)?void 0:a.items;if(l&&e){let r=this.findItemIndex(l),a=this.livePrerollResumption(i);if(void 0!==a){let t=a,l=this.getNextItemIndex(o);if(!this.isInterstitial(n[l])){let e=null==(s=this.primaryDetails)?void 0:s.fragments;if(i.snapOptions.in&&e){let i=ak(null,e,a);i&&(t=Math.min(Math.max(n[l].start,ds(t,i)),n[l].end))}}if(this.log(dg("live join (preroll)",t)),this.timelinePos=t,l!==r&&(l||0===l))return void this.advanceSchedule(l,e,void 0,o,d)}this.advanceSchedule(r,e,t,o,d)}return}}this.advanceSchedule(e,n,t,o,d)}advanceSchedule(e,t,i,r,a){let s=this.schedule;if(!s)return;let n=t[e]||null,l=this.primaryMedia,o=this.playerQueue;if(o.length&&o.forEach(t=>{let i=t.interstitial,r=s.findEventIndex(i.identifier);(r<e||r>e+1)&&this.clearInterstitial(i,n)}),this.isInterstitial(n)){this.timelinePos=Math.min(Math.max(this.timelinePos,n.start),n.end);let a=n.event;if(void 0===i){i=a.cue.pre?0:s.findAssetIndex(a,this.timelinePos);
29let t=dd(a,i-1);if(a.isAssetPastPlayoutLimit(t)||a.appendInPlace&&this.timelinePos===n.end)return void this.advanceAfterAssetEnded(a,e,i);i=t}let o=this.waitingItem;this.assetsBuffered(n,l)||this.setBufferingItem(n);let d=this.preloadAssets(a,i);if(this.eventItemsMatch(n,o||r)||(this.waitingItem=n,this.log(`INTERSTITIAL_STARTED ${dm(n)} ${a.appendInPlace?"append in place":""}`),a.hasPlayed=!1,this.hls.trigger(tz.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),!l)return void this.log(`Waiting for attachMedia to start Interstitial ${a}`);this.waitingItem=this.endedItem=null,this.playingItem=n;let h=a.assetList[i];if(!h)return void this.advanceAfterAssetEnded(a,e,i||0);if(d||(d=this.getAssetPlayer(h.identifier)),null===d||d.destroyed){let e=a.assetList.length;this.warn(`asset ${i+1}/${e} player destroyed ${a}`),(d=this.createAssetPlayer(a,h,i)).loadSource()}if(!this.eventItemsMatch(n,this.bufferingItem)&&a.appendInPlace&&this.isAssetBuffered(h))return;this.startAssetPlayer(d,i,t,e,l),this.shouldPlay&&dp(d.media)}else n?(this.resumePrimary(n,e,r),this.shouldPlay&&dp(this.hls.media)):a&&this.isInterstitial(r)&&(this.endedItem=null,this.playingItem=r,r.event.appendInPlace||this.attachPrimary(s.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 ${dm(e)}`);let s=this.timelinePos;if(null!=(r=this.detachedData)&&r.mediaSource?this.primaryLive&&this.startLoadingPrimaryAt(s):((s<e.start||s>=e.end||s<this.seekableStart)&&(s=this.getPrimaryResumption(e,t),this.log(dg("resumePrimary",s)),this.timelinePos=s),this.attachPrimary(s,e)),!i)return;let n=null==(a=this.schedule)?void 0:a.items;n&&(this.log(`INTERSTITIALS_PRIMARY_RESUMED ${dm(e)}`),this.hls.trigger(tz.INTERSTITIALS_PRIMARY_RESUMED,{schedule:n.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 s=this.primaryDetails;if(s){let{fragmentStart:e,edge:t}=s;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:aZ.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(dg("attachPrimary",e)),this.timelinePos=e,this.startLoadingPrimaryAt(e,i))}startLoadingPrimaryAt(e,t){let i=this.hls,{loadingEnabled:r,bufferingEnabled:a,startPosition:s}=i,n=i.hasEnoughToStart;if(this.log(`Start loading primary @${e} bufferedPos: ${this.bufferedPos} startPosition: ${s} skip seek: ${t} has enough ${n} loadingEnabled: ${r} bufferingEnabled: ${a}`),!t&&n||!r||Math.abs(s-e)>.1){let r=this.primaryDetails;if(null!=r&&r.live&&e+.5>=r.edge){let t=this.bufferingItem;this.log(`Resume primary loading when live passes ${e} buffering item: ${t?dm(t):null}
29`),i.pauseBuffering(),this.bufferPastEdge=!0;return}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(tz.BUFFER_CODECS,this.onBufferCodecs,this),this.hls.on(tz.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=ii(ii({},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?dm(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(tz.BUFFERED_TO_END,void 0)}}}}else this.checkStart()}onAudioTrackUpdated(e,t){let i=this.hls.audioTracks[t.id],r=this.mediaSelection;if(!r){this.altSelection=ii(ii({},this.altSelection),{},{audio:i});return}let a=ii(ii({},r),{},{audio:i});this.mediaSelection=a}onSubtitleTrackUpdated(e,t){let i=this.hls.subtitleTracks[t.id],r=this.mediaSelection;if(!r){this.altSelection=ii(ii({},this.altSelection),{},{subtitles:i});return}let a=ii(ii({},r),{},{subtitles:i});this.mediaSelection=a}onAudioTrackSwitching(e,t){let i=ag(t);this.playerQueue.forEach(({hls:e})=>e&&(e.setAudioOption(t)||e.setAudioOption(i)))}onSubtitleTrackSwitch(e,t){let i=ag(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;return e&&r&&r[this.findItemIndex(e,t)]||null}trimInPlace(e,t){if(this.isInterstitial(e)&&e.event.appendInPlace&&t.end-e.end>.25){e.event.assetList.forEach((t,i)=>{e.event.isAssetPastPlayoutLimit(i)&&this.clearAssetPlayer(t.identifier,null)});let i=e.end+.25,r=aZ.bufferInfo(this.primaryMedia,i,0);(r.end>i||(r.nextStart||0)>i)&&(this.log(`trim buffered interstitial ${dm(e)} (was ${dm(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=aZ.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)){this.bufferedPos=e;return}let s=this.playingItem,n=this.findItemIndex(s),l=r.findItemIndexAtTime(e);
29if(this.bufferedPos<e){var o;let i=this.findItemIndex(a),r=Math.min(i+1,t.length-1),s=t[r];if((-1===l&&a&&e>=a.end||null!=(o=s.event)&&o.appendInPlace&&e+.01>=s.start)&&(l=r),this.isInterstitial(a)){let e=a.event;if(r-n>1&&!1===e.appendInPlace||0===e.assetList.length&&e.assetListLoader)return}if(this.bufferedPos=e,l>i&&l>n)this.bufferedToItem(s);else{let t=this.primaryDetails;this.primaryLive&&t&&e>t.edge-t.targetduration&&s.start<t.edge+this.hls.config.interstitialLiveLookAhead&&this.isInterstitial(s)&&this.preloadAssets(s.event,0)}}else i&&s&&!this.itemsMatch(s,a)&&(l===n?this.bufferedToItem(s):l===n+1&&this.bufferedToItem(t[l]))}assetsBuffered(e,t){return 0!==e.event.assetList.length&&!e.event.assetList.some(e=>{let i=this.getAssetPlayer(e.identifier);return!(null!=i&&i.bufferedInPlaceToEnd(t))})}setBufferingItem(e){let t=this.bufferingItem,i=this.schedule;if(!this.itemsMatch(e,t)&&i){let{items:r,events:a}=i;if(!r||!a)return t;let s=this.isInterstitial(e),n=this.getBufferingPlayer();this.bufferingItem=e,this.bufferedPos=Math.max(e.start,Math.min(e.end,this.timelinePos));let l=n?n.remaining:t?t.end-this.timelinePos:0;if(this.log(`INTERSTITIALS_BUFFERED_TO_BOUNDARY ${dm(e)}`+(t?` (${l.toFixed(2)} remaining)`:"")),!this.playbackDisabled)if(s){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(tz.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,s=e.cue.once;if(a){let a,s=e.timelineStart,l=this.playingItem,o=this.getBufferingPlayer();if(e.appendInPlace){var n;this.isInterstitial(l)||(null==l||null==(n=l.nextEvent)?void 0:n.identifier)!==e.identifier||this.flushFrontBuffer(s+.25)}let 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-s;e>0&&(a=Math.round(1e3*e)/1e3)}if(this.log(`Load interstitial asset ${t+1}/${i?1:r} ${e}${d?` live-start: ${d} start-offset: ${a} (timeline-start: ${s})`:""}`),i)return this.createAsset(e,0,0,s,e.duration,i);let h=this.assetListLoader.loadAssetList(e,a);h&&(e.assetListLoader=h)}else if(!s&&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(tz.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,s){let n={parentIdentifier:e.identifier,identifier:`${e.identifier}-${t+1}-${oN(s)}`,duration:a,startOffset:i,timelineStart:r,uri:s};return this.createAssetPlayer(e,n,t)}createAssetPlayer(e,t,i){let r=this.hls,a=r.userConfig,s=a_(r.loadLevelObj||r.levels[r.currentLevel],a.videoPreference),n=r.audioTracks[r.audioTrack],l=r.subtitleTracks[r.subtitleTrack],o=0;if(this.primaryLive||e.appendInPlace){let e=this.timelinePos-t.timelineStart;if(e>=0){let i=t.duration;i&&e<i&&(o=e)}}let d=t.identifier,h=ii(ii({},a),{}
29,{maxMaxBufferLength:Math.min(15,r.config.maxMaxBufferLength),autoStartLoad:!0,startFragPrefetch:!0,primarySessionId:r.sessionId,assetPlayerId:d,abrEwmaDefaultEstimate:r.bandwidthEstimate,interstitialsController:void 0,startPosition:o,liveDurationInfinity:!1,testBandwidth:!1,videoPreference:s,audioPreference:n||a.audioPreference,subtitlePreference:l||a.subtitlePreference});e.appendInPlace&&(e.appendInPlaceStarted=!0,t.timelineStart&&(h.timelineOffset=t.timelineStart));let u=h.cmcd;null!=u&&u.sessionId&&u.contentId&&(h.cmcd=ie({},u,{contentId:oN(t.uri)})),this.getAssetPlayer(d)&&this.warn(`Duplicate date range identifier ${e} and asset ${d}`);let c=new du(this.HlsPlayerClass,h,e,t);this.playerQueue.push(c),e.assetList[i]=t;let m=!0,f=r=>{if(r.live){let t=Error(`Interstitials MUST be VOD assets ${e}`),r={fatal:!0,type:tj.OTHER_ERROR,details:tY.INTERSTITIAL_ASSET_ITEM_ERROR,error:t},a=this.findEventIndex(e.identifier);this.handleAssetItemError(r,e,a,i,t.message);return}let a=r.edge-r.fragmentStart,s=t.duration;(m||null===s||a>s)&&(m=!1,this.log(`Interstitial asset "${d}" duration change ${s} > ${a}`),t.duration=a,this.updateSchedule())};c.on(tz.LEVEL_UPDATED,(e,{details:t})=>f(t)),c.on(tz.LEVEL_PTS_UPDATED,(e,{details:t})=>f(t)),c.on(tz.EVENT_CUE_ENTER,()=>this.onInterstitialCueEnter());let p=(e,t)=>{let i=this.getAssetPlayer(d);if(i&&t.tracks){i.off(tz.BUFFER_CODECS,p),i.tracks=t.tracks;let e=this.primaryMedia;this.bufferingAsset===i.assetItem&&e&&!i.media&&this.bufferAssetPlayer(i,e)}};c.on(tz.BUFFER_CODECS,p);let g=()=>{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)};c.on(tz.BUFFERED_TO_END,g);let v=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(tz.MEDIA_ENDED,v(i)),c.once(tz.PLAYOUT_LIMIT_REACHED,v(1/0)),c.on(tz.ERROR,(t,r)=>{if(!this.schedule)return;let a=this.getAssetPlayer(d);r.details===tY.BUFFER_STALLED_ERROR?null!=a&&a.appendInPlace?this.handleInPlaceStall(e):(this.onTimeupdate(),this.checkBuffer(!0)):r.details===tY.BUFFER_SEEK_OVER_HOLE||this.handleAssetItemError(r,e,this.findEventIndex(e.identifier),i,`Asset player error ${r.error} ${e}`)}),c.on(tz.DESTROYING,()=>{if(!this.getAssetPlayer(d)||!this.schedule)return;let t=Error(`Asset player destroyed unexpectedly ${d}`),r={fatal:!0,type:tj.OTHER_ERROR,details:tY.INTERSTITIAL_ASSET_ITEM_ERROR,error:t};this.handleAssetItemError(r,e,this.findEventIndex(e.identifier),i,t.message)}),this.log(`INTERSTITIAL_ASSET_PLAYER_CREATED ${dh(t)}`),this.hls.trigger(tz.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?dm(t):t}`),this.transferMediaFromPlayer(e,t),this.playerQueue.splice(i,1),e.destroy()}}emptyPlayerQueue(){let e;for(;e=this.playerQueue.pop();)e.destroy();this.playerQueue=[]}startAssetPlayer(e,t,i,r,a){let{interstitial:s,assetItem:n,assetId:l}=e,o=s.assetList.length,d=this.playingAsset;this.endedAsset=null,this.playingAsset=n,(null==d?void 0:d.identifier)!==l&&(d&&(this.clearAssetPlayer(d.identifier,i[r]),delete d.error),this.log(`INTERSTITIAL_ASSET_STARTED ${t+1}/${o} ${dh(n)}`),this.hls.trigger(tz.INTERSTITIAL_ASSET_STARTED,{asset:n,assetListIndex:t,event:s,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,s=this.getEventItem(r.identifier);if(!s)return;if(e.loadSource(),this.setBufferingItem(s),this.bufferingAsset=a,e.bufferedInPlaceToEnd(this.primaryMedia,e.currentTime))return void this.advanceAssetBuffering(s,a);
29let n=this.getBufferingPlayer();if(n===e)return;let l=r.appendInPlace;if(l&&(null==n?void 0:n.interstitial.appendInPlace)===!1)return;let o=(null==n?void 0:n.tracks)||(null==(i=this.detachedData)?void 0:i.tracks)||this.requiredTracks;if(l&&a!==this.playingAsset){if(!e.tracks)return void this.log(`Waiting for track info before buffering ${e}`);if(o&&!iS(o,e.tracks)){let t=Error(`Asset ${dh(a)} SourceBuffer tracks ('${Object.keys(e.tracks)}') are not compatible with primary content tracks ('${Object.keys(o)}')`),i={fatal:!0,type:tj.OTHER_ERROR,details:tY.INTERSTITIAL_ASSET_ITEM_ERROR,error:t},s=r.findAssetIndex(a);this.handleAssetItemError(i,r,this.findEventIndex(r.identifier),s,t.message);return}}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),s=e.assetList[a];if(s){let n=this.getAssetPlayer(s.identifier);if(n){let l=n.currentTime||r-s.timelineStart,o=n.duration-l;if(this.warn(`Stalled at ${l} of ${l+o} in ${n} ${e} (media.currentTime: ${r})`),l&&(o/i.playbackRate<.5||n.bufferedInPlaceToEnd(i,n.currentTime))&&n.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===tY.BUFFER_STALLED_ERROR)return;let s=t.assetList[r]||null;if(this.warn(`INTERSTITIAL_ASSET_ERROR ${s?dh(s):s} ${e.error}`),!this.schedule)return;let n=(null==s?void 0:s.identifier)||"",l=this.getAssetPlayerQueueIndex(n),o=this.playerQueue[l]||null,d=this.schedule.items,h=ie({},e,{fatal:!1,errorAction:aC(!0),asset:s,assetListIndex:r,event:t,schedule:d,scheduleIndex:i,player:o});if(this.hls.trigger(tz.INTERSTITIAL_ASSET_ERROR,h),!e.fatal)return;let u=this.playingAsset,c=this.bufferingAsset,m=Error(a);if(s&&(this.clearAssetPlayer(n,null),s.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==u?void 0:u.identifier)===n?this.advanceAfterAssetEnded(t,i,r):(null==c?void 0:c.identifier)===n&&this.isInterstitial(this.bufferingItem)&&this.advanceAssetBuffering(this.bufferingItem,c)}primaryFallback(e){let t=e.timelineStart,i=this.effectivePlayingItem,r=this.playingItem,a=this.seekableStart,s=this.hls.startPosition,n=this.timelinePos;if(this.isInterstitial(i)){this.log(`Fallback to primary from event "${e.identifier}" start: ${t} pos: ${n} playing: ${dm(i)} startPosition: ${s} seekableStart: ${a} error: ${e.error}`),-1===n&&(n=s),n=Math.max(n,a);let r=this.updateItem(i,n);this.itemsMatch(i,r)&&this.clearInterstitial(e,null),e.appendInPlace&&(this.attachPrimary(t,null),this.flushFrontBuffer(t))}else if(-1===n)return void this.checkStart();if(!this.schedule||!this.isInterstitial(r))return;let l=this.schedule.findItemIndexAtTime(n);this.setSchedulePosition(l)}onAssetListLoaded(e,t){var i,r;let a=t.event,s=a.identifier,n=t.assetListResponse.ASSETS;if(!(null!=(i=this.schedule)&&i.hasEvent(s)))return;let l=a.timelineStart,o=a.duration,d=0;n.forEach((e,t)=>{let i=parseFloat(e.DURATION);this.createAsset(a,t,d,l+d,i,e.URI),d+=i}),a.duration=d,this.log(`Loaded asset-list with duration: ${d} (was: ${o}) ${a}`);let h=this.waitingItem,u=(null==h?void 0:h.event.identifier)===s;this.updateSchedule();let c=null==(r=this.bufferingItem)?void 0:r.event;if(u){let e=this.findEventIndex(s),t=this.getEventItem(s);if(t){if(!this.playingItem&&this.timelinePos>t.end&&this.schedule.findItemIndexAtTime(this.timelinePos)!==e){a.error=Error(`Interstitial ${n.length?"no longer within playback range":"asset-list is empty"} ${this.timelinePos} ${a}`),this.log(a.error.message),this.updateSchedule(!0),this.primaryFallback(a);return}this.setBufferingItem(t)}this.setSchedulePosition(e)}else if((null==c?void 0:c.identifier)===s){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 tY.ASSET_LIST_PARSING_ERROR:case tY.ASSET_LIST_LOAD_ERROR:case tY.ASSET_LIST_LOAD_TIMEOUT:{let e=t.interstitial;e&&(this.updateSchedule(!0),this.primaryFallback(e));break}case tY.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)}}}}});class dq extends lu{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(tz.MANIFEST_LOADING,this.onManifestLoading,this),e.on(tz.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(tz.LEVEL_LOADED,this.onLevelLoaded,this),e.on(tz.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(tz.FRAG_BUFFERED,this.onFragBuffered,this),e.on(tz.ER
29ROR,this.onError,this)}_unregisterListeners(){let{hls:e}=this;e.off(tz.MANIFEST_LOADING,this.onManifestLoading,this),e.off(tz.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(tz.LEVEL_LOADED,this.onLevelLoaded,this),e.off(tz.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(tz.FRAG_BUFFERED,this.onFragBuffered,this),e.off(tz.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={},s={},n=!1,l=!1,o=!1,d=!1;t.levels.forEach(e=>{let t=e.attrs,h=dz(e,i),{audioCodec:u,videoCodec:c,imageCodec:m,width:f,height:p}=e;if(!h)return void this.log(`Some or all CODECS not supported "${t.CODECS}"`);n||(n=!!(f&&p)),l||(l=!!c),o||(o=!!u),d||(d=!!m);let{CODECS:g,"FRAME-RATE":v,"HDCP-LEVEL":E,"PATHWAY-ID":y,RESOLUTION:b,"VIDEO-RANGE":T}=t,A=`${y||"."}-`,S=`${A}${e.bitrate}-${b}-${v}-${g}-${T}-${E}`;if(a[S])if(a[S].uri===e.url||e.attrs["PATHWAY-ID"])e.iframes||(a[S].addGroupId("audio",t.AUDIO),a[S].addGroupId("text",t.SUBTITLES));else{let t=s[S]+=1;e.attrs["PATHWAY-ID"]=Array(t+1).join(".");let i=this.createLevel(e);a[S]=i,r.push(i)}else{let t=this.createLevel(e);a[S]=t,s[S]=1,r.push(t)}}),this.filterAndSortMediaOptions(r,t,n,l,o,d)}createLevel(e){let t=new au(e),i=e.supplemental;if(null!=i&&i.videoCodec&&!dY(i.videoCodec,this.hls.config.preferManagedMediaSource)){let e=Error(`SUPPLEMENTAL-CODECS not supported "${i.videoCodec}"`);this.log(e.message),t.supportedResult=ai(e,[])}return t}filterAndSortMediaOptions(e,t,i,r,a,s){var n,l;let o=[],d=[],h=e,u=(null==(n=t.stats)?void 0:n.parsing)||{},c=this.hls.config.preferManagedMediaSource;if((i||r)&&a&&(h=h.filter(({videoCodec:e,videoRange:t,width:i,height:r})=>{var a;return(!!e||!!(i&&r))&&!!(a=t)&&ao.indexOf(a)>-1})),r&&s&&(h=h.filter(e=>!e.imageCodec)),0===h.length){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: ${am(t.levels.map(e=>e.attrs.CODECS).filter((e,t,i)=>i.indexOf(e)===t))}`,this.warn(i),e+=` (${i})`);let r=Error(e);this.hls.trigger(tz.ERROR,{type:tj.MEDIA_ERROR,details:tY.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:r,reason:i})}}),u.end=performance.now();return}t.audioTracks&&dQ(o=t.audioTracks.filter(e=>!e.audioCodec||dj(e.audioCodec,c))),t.subtitles&&dQ(d=t.subtitles);let m=h.slice(0);h.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 ao.indexOf(e.videoRange)-ao.indexOf(t.videoRange);if(e.videoCodec!==t.videoCodec){let i=r1(e.videoCodec),r=r1(t.videoCodec);if(i!==r)return r-i}if(e.uri===t.uri&&e.codecSet!==t.codecSet){let i=r2(e.codecSet),r=r2(t.codecSet);if(i!==r)return r-i}return e.averageBitrate!==t.averageBitrate?e.averageBitrate-t.averageBitrate:0});let f=m[0];if(this.steering&&(h=this.steering.filterParsedLevels(h)).length!==m.length){for(let e=0;e<m.length;e++)if(m[e].pathwayId===h[0].pathwayId){f=m[e];break}}this._levels=h;for(let e=0;e<h.length;e++)if(h[e]===f){this._firstLevel=e;let t=f.bitrate,i=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${h.length} level(s) found, first bitrate: ${t}`),(null==(l=this.hls.userConfig)?void 0:l.abrEwmaDefaultEstimate)===void 0){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=>dz(e,c));this._iframeVariants=p;let g=a&&!r,v=this.hls.config,E=!!(v.audioStreamController&&v.audioTrackController),y={levels:h,audioTracks:o,subtitleTracks:d,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(tz.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=Error("invalid level idx"),r=e<0;
29if(this.hls.trigger(tz.ERROR,{type:tj.OTHER_ERROR,details:tY.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,s=t[e],n=s.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=s,i===e&&r&&a===n)return;this.log(`Switching to level ${e} (${s.height?s.height+"p ":""}${s.videoRange?s.videoRange+" ":""}${s.codecSet?s.codecSet+" ":""}@${s.bitrate})${n?" with Pathway "+n:""} from level ${i}${a?" with Pathway "+a:""}`);let l={level:e,attrs:s.attrs,details:s.details,bitrate:s.bitrate,averageBitrate:s.averageBitrate,maxBitrate:s.maxBitrate,realBitrate:s.realBitrate,width:s.width,height:s.height,codecSet:s.codecSet,audioCodec:s.audioCodec,videoCodec:s.videoCodec,audioGroups:s.audioGroups,subtitleGroups:s.subtitleGroups,loaded:s.loaded,loadError:s.loadError,fragmentError:s.fragmentError,name:s.name,id:s.id,uri:s.uri,url:s.url,urlId:0,audioGroupIds:s.audioGroupIds,textGroupIds:s.textGroupIds};this.hls.trigger(tz.LEVEL_SWITCHING,l);let o=s.details;if(!o||o.live){let e=this.switchParams(s.uri,null==r?void 0:r.details,o);this.loadPlaylist(e)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(e){this.manualLevelIndex=e,void 0===this._startLevel&&(this._startLevel=e),-1!==e&&(this.level=e)}get firstLevel(){return this._firstLevel}set firstLevel(e){this._firstLevel=e}get startLevel(){if(void 0===this._startLevel){let e=this.hls.config.startLevel;return void 0!==e?e:this.hls.firstAutoLevel}return this._startLevel}set startLevel(e){this._startLevel=e}get pathways(){return this.steering?this.steering.pathways():[]}get pathwayPriority(){return this.steering?this.steering.pathwayPriority:null}set pathwayPriority(e){if(this.steering){let t=this.steering.pathways(),i=e.filter(e=>-1!==t.indexOf(e));if(e.length<1)return void this.warn(`pathwayPriority ${e} should contain at least one pathway from list: ${t}`);this.steering.pathwayPriority=i}}onError(e,t){!t.fatal&&t.context&&t.context.type===tJ.LEVEL&&t.context.level===this.level&&this.checkRetry(t)}onFragBuffered(e,{frag:t}){if(t.type===t0.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,r;let{level:a,details:s}=t,n=t.levelInfo;if(!n){this.warn(`Invalid level index ${a}`),null!=(r=t.deliveryDirectives)&&r.skip&&(s.deltaUpdateFailed=!0);return}if(n===this.currentLevel||t.withoutMultiVariant){0===n.fragmentError&&(n.loadError=0);let e=n.details;e===t.details&&e.advanced&&(e=void 0),this.playlistLoaded(a,t,e)}else null!=(i=t.deliveryDirectives)&&i.skip&&(s.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"],s=e.details,n=null==s?void 0:s.age;this.log(`Loading level index ${r}${(null==t?void 0:t.msn)!==void 0?" at sn "+t.msn+" part "+t.part:""}${a?" Pathway "+a:""}${n&&s.live?" age "+n.toFixed(1)+(s.type?" "+s.type:""):""} ${i}`),this.hls.trigger(tz.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,s=1e3*i;if(this.lastABRSwitchTime>-1&&a<s)return void this.warn(`Preventing ABR level switch: ${t} -> ${e} (${Math.round(a)}ms < ${s}ms / ${i}s)`);this.lastABRSwitchTime=r,this.log(`Allowing ABR level switch: ${t} -> ${e} (${Math.round(a)}ms >= ${s}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.forEac
29h(e=>e.level=-1)),!1));sj(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(tz.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(tz.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:e,levels:this.levels,maxAutoLevel:t,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:i}))}}function dj(e,t){return rZ(e,"audio",t)}function dY(e,t){return rZ(e,"video",t)}function dz(e,t){let{audioCodec:i,videoCodec:r}=e;i&&(e.audioCodec=i=r5(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||!a.length)&&(!i||!!dj(i,t))&&(!r||!!dY(r,t))}function dQ(e){let t={};e.forEach(e=>{let i=e.groupId||"";e.id=t[i]=t[i]||0,t[i]++})}class dX extends iv{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=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(dZ(e,tY.KEY_LOAD_ERROR,t))}switch(r.method){case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":if("identity"===r.keyFormat)return this.loadKeyHTTP(e);return t?t.then(()=>this.loadKeyEME(e)):this.loadKeyEME(e);case"AES-128":case"AES-256":case"AES-256-CTR":return this.loadKeyHTTP(e);default:return Promise.reject(dZ(e,tY.KEY_LOAD_ERROR,Error(`Key supplied with unsupported METHOD: "${r.method}"`)))}}loadKeyEME(e){if(this.emeController&&this.config.emeEnabled){var t,i;if(!e.decryptdata.keyId&&null!=(t=e.initSegment)&&t.data){let t,r=(i=e.initSegment.data,t=[],rN(i,e=>t.push(e.subarray(8,24))),t);if(r.length){let t=r[0],i=e.decryptdata.uri;if(t.some(e=>0!==e))this.log(`Using keyId found in init segment ${iB(t)} keyUri: ${i}`),sT.setKeyIdForUri(i,t);else{let e=sT.addKeyIdForUri(i);this.log(`Patching empty keyId with ${iB(e)} keyUri: ${i}`),t=e}e.decryptdata.keyId=t}}return this.emeController.loadKey(e).then(()=>({frag:e,keyInfo:{decryptdata:e.decryptdata}}))}return Promise.reject(dZ(e,tY.KEY_LOAD_ERROR,Error(`emeEnabled with controller: ${this.emeController&&this.config.emeEnabled})`)))}loadKeyHTTP(e){let t=e.decryptdata,i=t.uri;if(!i)return Promise.reject(dZ(e,tY.KEY_LOAD_ERROR,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,ii(ii({},i),{},{frag:e})))}this.log(`Loading${t.keyId?" keyId: "+iB(t.keyId):""} URI: ${t.uri} from ${e.type} ${e.level}`);let a=this.config,s=new a.loader(a);e.keyLoader=s;let n=this.keyLoaderInfo[i]={decryptdata:t,keyLoadPromise:null,loader:s};return n.keyLoadPromise=new Promise((t,r)=>{let l={type:tJ.KEY,keyInfo:n,frag:e,responseType:"arraybuffer",url:i},o=a.keyLoadPolicy.default,d={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0};s.load(l,d,{onSuccess:(e,i,a,s)=>{let{frag:n,keyInfo:l,url:o}=a;if(!n.decryptdata||l!==this.keyLoaderInfo[o])return r(dZ(n,tY.KEY_LOAD_ERROR,Error("after key load, decryptdata unset or changed"),s));l.decryptdata.key=n.decryptdata.key=new Uint8Array(e.data),n.keyLoader=l.loader=l.keyLoadPromise=null,t({frag:n,keyInfo:l})},onError:(t,a,s,n)=>{this.resetLoader(a),r(dZ(e,tY.KEY_LOAD_ERROR,Error(`HTTP Error ${t.code} loading key ${t.text}`),s,ii({url:i,data:void 0},t)))},onTimeout:(t,i,a)=>{this.resetLoader(i),r(dZ(e,tY.KEY_LOAD_TIMEOUT,Error("key loading timed out"),a))},onAbort:(t,i,a)=>{this.resetLoader(i),r(dZ(e,tY.INTERNAL_ABORTED,Error("key loading aborted"),a))}})})}
29resetLoader(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 dZ(e,t=tY.KEY_LOAD_ERROR,i,r,a){return new aj({type:tj.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:a,error:i,networkDetails:r||null})}function dJ(e){let{type:t}=e;switch(t){case tJ.AUDIO_TRACK:return t0.AUDIO;case tJ.SUBTITLE_TRACK:return t0.SUBTITLE;default:return t0.MAIN}}function d0(e,t){let i=e.url;return(void 0===i||0===i.indexOf("data:"))&&(i=t.url),i}class d1{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(tz.MANIFEST_LOADING,this.onManifestLoading,this),e.on(tz.LEVEL_LOADING,this.onLevelLoading,this),e.on(tz.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(tz.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.on(tz.LEVELS_UPDATED,this.onLevelsUpdated,this)}unregisterListeners(){let{hls:e}=this;e.off(tz.MANIFEST_LOADING,this.onManifestLoading,this),e.off(tz.LEVEL_LOADING,this.onLevelLoading,this),e.off(tz.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(tz.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.off(tz.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:tJ.MANIFEST,url:i,deliveryDirectives:null,levelOrTrack:null})}onLevelLoading(e,t){let{id:i,level:r,pathwayId:a,url:s,deliveryDirectives:n,levelInfo:l}=t;this.load({id:i,level:r,pathwayId:a,responseType:"text",type:tJ.LEVEL,url:s,deliveryDirectives:n,levelOrTrack:l})}onAudioTrackLoading(e,t){let{id:i,groupId:r,url:a,deliveryDirectives:s,track:n}=t;this.load({id:i,groupId:r,level:null,responseType:"text",type:tJ.AUDIO_TRACK,url:a,deliveryDirectives:s,levelOrTrack:n})}onSubtitleTrackLoading(e,t){let{id:i,groupId:r,url:a,deliveryDirectives:s,track:n}=t;this.load({id:i,groupId:r,level:null,responseType:"text",type:tJ.SUBTITLE_TRACK,url:a,deliveryDirectives:s,levelOrTrack:n})}onLevelsUpdated(e,t){let i=this.loaders[tJ.LEVEL];if(i){let e=i.context;e&&!t.levels.some(t=>t===e.levelOrTrack)&&(i.abort(),delete this.loaders[tJ.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===tJ.MANIFEST?r.manifestLoadPolicy.default:ie({},r.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),a=this.createInternalLoader(e),tK(null==(t=e.deliveryDirectives)?void 0:t.part)){let t;if(e.type===tJ.LEVEL&&null!==e.level?t=this.hls.levels[e.level].details:e.type===tJ.AUDIO_TRACK&&null!==e.id?t=this.hls.audioTracks[e.id].details:e.type===tJ.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=ie({},i,{maxTimeToFirstByteMs:Math.min(t,i.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(t,i.maxTimeToFirstByteMs)})}}}let s=i.errorRetry||i.timeoutRetry||{},n={loadPolicy:i,timeout:i.maxLoadTimeMs,maxRetry:s.maxNumRetry||0,retryDelay:s.retryDelayMs||0,maxRetryDelay:s.maxRetryDelayMs||0};a.load(e,n,{onSuccess:(e,t,i,r)=>{let a=this.getInternalLoader(i);this.resetInternalLoader(i.type);let s=e.data;t.parsing.start=performance.now(),sI.isMediaPlaylist(s)||i.type!==tJ.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)}})}
29checkAutostartLoad(){if(!this.hls)return;let{config:{autoStartLoad:e,startPosition:t},forceStartLoad:i}=this.hls;(e||i)&&(this.hls.logger.log(`${e?"auto":"force"} startLoad with configured startPosition ${t}`),this.hls.startLoad(t))}handleMasterPlaylist(e,t,i,r){let a=this.hls,s=e.data,n=d0(e,i),l=sI.parseMasterPlaylist(s,n);if(l.playlistParsingError){t.parsing.end=performance.now(),this.handleManifestParsingError(e,i,l.playlistParsingError,r,t);return}let{contentSteering:o,levels:d,iframeVariants:h,sessionData:u,sessionKeys:c,startTimeOffset:m,variableList:f}=l;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 s=t.length;s--;){let n=t[s];rZ(n,"audio",i)?(e.audioCodec=r=r?`${r},${n}`:n,rQ.audio[r.substring(0,4)]=2,t.splice(s,1)):rZ(n,"video",i)&&(e.videoCodec=a=a?`${a},${n}`:n,rQ.video[a.substring(0,4)]=2,t.splice(s,1))}}});let{AUDIO:p=[],SUBTITLES:g,"CLOSED-CAPTIONS":v}=sI.parseMasterPlaylistMedia(s,n,l);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 a5({}),bitrate:0,url:""}))),a.trigger(tz.MANIFEST_LOADED,{levels:d,audioTracks:p,subtitles:g,iframeVariants:h,captions:v,contentSteering:o,url:n,stats:t,networkDetails:r,sessionData:u,sessionKeys:c,startTimeOffset:m,variableList:f})}handleTrackOrLevelPlaylist(e,t,i,r,a){let s=this.hls,{id:n,level:l,type:o}=i,d=d0(e,i),h=tK(l)?l:tK(n)?n:0,u=dJ(i),c=sI.parseLevelPlaylist(e.data,d,h,u,0,this.variableList);if(o===tJ.MANIFEST){let e={attrs:new a5({}),bitrate:0,details:c,name:"",url:d};c.requestScheduled=t.loading.start+sW(c,0),s.trigger(tz.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(tz.ERROR,{type:tj.NETWORK_ERROR,details:tY.MANIFEST_PARSING_ERROR,fatal:t.type===tJ.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 s=`A network ${i?"timeout":"error"+(r?" (status "+r.code+")":"")} occurred while loading ${e.type}`;e.type===tJ.LEVEL?s+=`: ${e.level} id: ${e.id}`:(e.type===tJ.AUDIO_TRACK||e.type===tJ.SUBTITLE_TRACK)&&(s+=` id: ${e.id} group-id: "${e.groupId}"`);let n=Error(s);this.hls.logger.warn(`[playlist-loader]: ${s}`);let l=tY.UNKNOWN,o=!1,d=this.getInternalLoader(e);switch(e.type){case tJ.MANIFEST:l=i?tY.MANIFEST_LOAD_TIMEOUT:tY.MANIFEST_LOAD_ERROR,o=!0;break;case tJ.LEVEL:l=i?tY.LEVEL_LOAD_TIMEOUT:tY.LEVEL_LOAD_ERROR,o=!1;break;case tJ.AUDIO_TRACK:l=i?tY.AUDIO_TRACK_LOAD_TIMEOUT:tY.AUDIO_TRACK_LOAD_ERROR,o=!1;break;case tJ.SUBTITLE_TRACK:l=i?tY.SUBTITLE_TRACK_LOAD_TIMEOUT:tY.SUBTITLE_LOAD_ERROR,o=!1}d&&this.resetInternalLoader(e.type);let h={type:tj.NETWORK_ERROR,details:l,fatal:o,url:e.url,loader:d,context:e,error:n,networkDetails:t,stats:a};if(r){let i=e.url;t&&"url"in t&&(i=t.url),h.response=ii({url:i,data:void 0},r)}this.hls.trigger(tz.ERROR,h)}handlePlaylistLoaded(e,t,i,r,a,s){let n=this.hls,{type:l,level:o,levelOrTrack:d,id:h,groupId:u,deliveryDirectives:c}=r,m=d0(t,r),f=dJ(r),p="number"==typeof r.level&&f===t0.MAIN?o:void 0;d&&"iframes"in d&&d.iframes&&!e.iframesOnly&&(e.playlistParsingError=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}`),!n.config.ignorePlaylistParsingErrors)return void n.trigger(tz.ERROR,{type:tj.NETWORK_ERROR,details:tY.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 s=e.playlistParsingError=Error("No Segments found in Playlist");
29n.trigger(tz.ERROR,{type:tj.NETWORK_ERROR,details:tY.LEVEL_EMPTY_ERROR,fatal:!1,url:m,error:s,reason:s.message,response:t,context:r,level:p,parent:f,networkDetails:a,stats:i});return}switch(e.live&&s&&(s.getCacheAge&&(e.ageHeader=s.getCacheAge()||0),(!s.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),l){case tJ.MANIFEST:case tJ.LEVEL:if(p)if(d){if(d!==n.levels[p]){let e=n.levels.indexOf(d);e>-1&&(p=e)}}else p=0;n.trigger(tz.LEVEL_LOADED,{details:e,levelInfo:d||n.levels[0],level:p||0,id:h||0,stats:i,networkDetails:a,deliveryDirectives:c,withoutMultiVariant:l===tJ.MANIFEST,context:r});break;case tJ.AUDIO_TRACK:n.trigger(tz.AUDIO_TRACK_LOADED,{details:e,track:d,id:h||0,groupId:u||"",stats:i,networkDetails:a,deliveryDirectives:c,context:r});break;case tJ.SUBTITLE_TRACK:n.trigger(tz.SUBTITLE_TRACK_LOADED,{details:e,track:d,id:h||0,groupId:u||"",stats:i,networkDetails:a,deliveryDirectives:c,context:r})}}}class d2{static get version(){return nh}static isMSESupported(){return o9()}static isSupported(){if(!o9())return!1;let e=i_();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(r0(t,"video")))||["mp4a.40.2","fLaC"].some(t=>e.isTypeSupported(r0(t,"audio"))))}static getMediaSource(){return i_()}static get Events(){return tz}static get MetadataSchema(){return nE}static get ErrorTypes(){return tj}static get ErrorDetails(){return tY}static get DefaultConfig(){return d2.defaultConfig?d2.defaultConfig:dV}static set DefaultConfig(e){d2.defaultConfig=e}constructor(e={}){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 nd,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.iframeC
29ontroller=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;const t=this.logger=function(e,t,i){let r=ib();if("object"==typeof console&&!0===e||"object"==typeof e){let a=["debug","log","info","warn","error"];a.forEach(t=>{r[t]=iT(t,e,i)});try{r.log(`Debug logs enabled for "${t}" in hls.js version 1.7.3`)}catch(e){return ib()}a.forEach(t=>{iA[t]=iT(t,e)})}else ie(iA,r);return r}(e.debug||!1,"Hls instance",e.loggerId||e.assetPlayerId),i=this.config=function(e,t,i){if((t.liveSyncDurationCount||t.liveMaxLatencyDurationCount)&&(t.liveSyncDuration||t.liveMaxLatencyDuration))throw Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==t.liveMaxLatencyDurationCount&&(void 0===t.liveSyncDurationCount||t.liveMaxLatencyDurationCount<=t.liveSyncDurationCount))throw Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==t.liveMaxLatencyDuration&&(void 0===t.liveSyncDuration||t.liveMaxLatencyDuration<=t.liveSyncDuration))throw Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');if(void 0!==t.liveMaxUnchangedPlaylistRefresh){let e=t.liveMaxUnchangedPlaylistRefresh,r=Math.max(2,Math.min(e,1/0));r!==e&&i.warn(`hls.js config: "liveMaxUnchangedPlaylistRefresh" clamped from ${e} to ${r}.`),t.liveMaxUnchangedPlaylistRefresh=r}let r=function e(t){return t&&"object"==typeof t?Array.isArray(t)?t.map(e):Object.keys(t).reduce((i,r)=>(i[r]=e(t[r]),i),{}):t}(e),a=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach(e=>{let s=`${"level"===e?"playlist":e}LoadPolicy`,n=void 0===t[s],l=[];a.forEach(i=>{let a=`${e}Loading${i}
29`,o=t[a];if(void 0!==o&&n){l.push(a);let e=r[s].default;switch(t[s]={default:e},i){case"TimeOut":e.maxLoadTimeMs=o,e.maxTimeToFirstByteMs=o;break;case"MaxRetry":e.errorRetry.maxNumRetry=o,e.timeoutRetry.maxNumRetry=o;break;case"RetryDelay":e.errorRetry.retryDelayMs=o,e.timeoutRetry.retryDelayMs=o;break;case"MaxRetryTimeout":e.errorRetry.maxRetryDelayMs=o,e.timeoutRetry.maxRetryDelayMs=o}}}),l.length&&i.warn(`hls.js config: "${l.join('", "')}" setting(s) are deprecated, use "${s}": ${am(t[s])}`)}),ii(ii({},r),t)}(d2.DefaultConfig,e,t);this.userConfig=e,i.progressive&&function(e,t){let i=e.loader;i!==d$&&i!==dK?(t.log("[config]: Custom loader detected, cannot enable progressive streaming"),e.progressive=!1):function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(e){}return!1}()&&(e.loader=d$,e.progressive=!0,e.enableSoftwareAES=!0,t.log("[config]: Progressive streaming enabled, using FetchLoader"))}(i,t);const{streamController:r,abrController:a,bufferController:s,capLevelController:n,errorController:l,fpsController:o,id3TrackController:d,iframeController:h,gapController:u}=i,c=new l(this),m=this.abrController=new a(this),f=new aO(this),p=i.interstitialsController,g=p?this.interstitialsController=new p(this,d2):null,v=s?this.bufferController=new s(this,f):null,E=n?this.capLevelController=new n(this):null,y=o?new o(this):null,b=i.cmcdController,T=b?this.cmcdController=new b(this):null,A=new d1(this),S=i.contentSteeringController,k=S?new S(this):null,R=this.levelController=new dq(this,k),L=d?new d(this):void 0,I=new dX(this.config,this.logger),w=this.streamController=new r(this,f,I),D=this.gapController=u?new u(this,f):void 0;E&&E.setStreamController(w);const C=[A,R,w];g&&C.splice(1,0,g),k&&C.splice(1,0,k),this.networkControllers=C;const M=[m];v&&M.push(v),D&&M.push(D),E&&M.push(E),y&&(y.setStreamController(w),M.push(y)),L&&M.push(L),M.push(f),this.audioTrackController=this.createController(i.audioTrackController,C);const x=i.audioStreamController;x&&C.push(this.audioStreamController=new x(this,f,I)),this.subtitleTrackController=this.createController(i.subtitleTrackController,C);const P=i.subtitleStreamController;P&&C.push(this.subtititleStreamController=new P(this,f,I)),this.createController(i.timelineController,M),I.emeController=this.emeController=this.createController(i.emeController,M),T&&M.push(T),this.latencyController=this.createController(i.latencyController,M),this.coreComponents=M,this.iframeC
29ontroller=h?new h(this,d2):void 0,C.push(c);const O=c.onErrorOut;"function"==typeof O&&this.on(tz.ERROR,O,c),this.on(tz.MANIFEST_LOADED,A.onManifestLoaded,A)}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===tz.ERROR;this.trigger(tz.ERROR,{type:tj.OTHER_ERROR,details:tY.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(tz.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=>
29e.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=Error(`attachMedia failed: invalid argument (${e})`);this.trigger(tz.ERROR,{type:tj.OTHER_ERROR,details:tY.ATTACH_MEDIA_ERROR,fatal:!0,error:t});return}this.logger.log("attachMedia"),this._media&&(this.logger.warn("media must be detached before attaching"),this.detachMedia());let t="media"in e,i=t?e.media:e,r=t?e:{media:i};this._media=i,this.trigger(tz.MEDIA_ATTACHING,r)}detachMedia(){this.logger.log("detachMedia");let e={};this.trigger(tz.MEDIA_DETACHING,e),this._media=null,this.trigger(tz.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(tz.MEDIA_DETACHING,i),this.trigger(tz.MEDIA_DETACHED,i),t}loadSource(e){var t;this.stopLoad();let i=this.media,r=this._url,a=this._url=tX.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(tz.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!==s2}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={[t0.MAIN]:this.streamController.inFlightFrag};return this.audioStreamController&&(e[t0.AUDIO]=this.audioStreamController.inFlightFrag),this.subtititleStreamController&&(e[t0.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=iw()),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){al.indexOf(e)>-1&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}get autoLevelEnabled(){return -1===this.levelController.manualLevel}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){let{levels:e,config:{minAutoBitrate:t}}=this;if(!e)return 0;let i=e.length;for(let r=0;r<i;r++)if(e[r].maxBitrate>=t)return r;return 0}get maxAutoLevel(){let e,{levels:t,autoLevelCapping:i,maxHdcpLevel:r}=this;if(e=-1===i&&null!=t&&t.length?t.length-1:i,r)for(let i=e;i--;){let e=t[i].attrs["HDCP-LEVEL"];if(e&&e<=r)return i}return e}get firstAutoLevel(){return this.abrController.firstAutoLevel}get nextAutoLevel(){return this.abrController.nextAutoLevel}set nextAutoLevel(e){this.abrController.nextAutoLevel=e}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}get 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}
29setSubtitleOption(e){var t;return(null==(t=this.subtitleTrackController)?void 0:t.setSubtitleOption(e))||null}get allAudioTracks(){let e=this.audioTrackController;return e?e.allAudioTracks:[]}get audioTracks(){let e=this.audioTrackController;return e?e.audioTracks:[]}get audioTrack(){let e=this.audioTrackController;return e?e.audioTrack:-1}set audioTrack(e){let t=this.audioTrackController;t&&(t.audioTrack=e)}get 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||[]}
29createIFramePlayer(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 ar(e,ap(t),navigator.mediaCapabilities)}}d2.defaultConfig=void 0;var d3="video",d4=e=>e===d3?"playback":e,d5=class e extends Error{constructor(t,i=e.MEDIA_ERR_CUSTOM,r,a){var s;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!=(s=e.defaultMessages[this.code])?s:"")}};d5.MEDIA_ERR_ABORTED=1,d5.MEDIA_ERR_NETWORK=2,d5.MEDIA_ERR_DECODE=3,d5.MEDIA_ERR_SRC_NOT_SUPPORTED=4,d5.MEDIA_ERR_ENCRYPTED=5,d5.MEDIA_ERR_CUSTOM=100,d5.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 d8=(e,t)=>null!=t&&e in t,d6={ANY:"any",MUTED:"muted"},d9="on-demand",d7="live",he="unknown",ht="native",hi={HEADER:"header",QUERY:"query",NONE:"none"},hr=Object.values(hi),ha={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},hs={HLS:ha.M3U8};Object.keys(hs),[...Object.values(ha)];var hn={code:"en"},hl=(e,t,i,r,a=e)=>{a.addEventListener(t,i,r),e.addEventListener("teardown",()=>{a.removeEventListener(t,i)},{once:!0})},ho=e=>{let t=e.indexOf("?");return t<0?[e]:[e.slice(0,t),e.slice(t)]},hd=e=>{let{type:t}=e;if(t){let e=t.toUpperCase();return d8(e,hs)?hs[e]:t}return hc(e)},hh=e=>"VOD"===e?d9:d7,hu=e=>"EVENT"===e?1/0:"VOD"===e?NaN:0,hc=e=>{let{src:t}=e;if(!t)return"";let i="";try{i=hf(t).pathname}catch{console.error("Invalid url when trying to infer mime type",t)}let r=i.lastIndexOf(".");if(r<0)return hg(e)?ha.M3U8:"";let a=i.slice(r+1).toUpperCase();return d8(a,ha)?ha[a]:""},hm=e=>{try{return new URL(e),!1}catch{return!0}},hf=(e,t)=>{var i;if(!hm(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&&hm(t.toString())&&(a=new URL(t,r)),new URL(e,a)},hp="mux.com",hg=({src:e,customDomain:t=hp})=>{let i;try{i=new URL(`${e}`)}catch{return!1}let r="https:"===i.protocol,a=i.hostname===`stream.${t}`.toLowerCase(),s=i.pathname.split("/"),n=2===s.length,l=!(null!=s&&s[1].includes("."));return r&&a&&n&&l},hv=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 hE(e,t=!0){var i;return new hy(t&&null!=(i=null==hn?void 0:hn[e])?i:e,t?hn.code:"en")}var hy=class{constructor(e,t=(e=>null!=(e=hn)?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}},hb=Object.values(d6),hT=e=>"boolean"==typeof e||"string"==typeof e&&hb.includes(e),hA=(e,t)=>{if(!t)return;let i=e.muted,r=()=>e.muted=i;switch(t){case d6.ANY:e.play().catch(()=>{e.muted=!0,e.play().catch(r)});break;case d6.MUTED:e.muted=!0,e.play().catch(r);break;default:e.play().catch(()=>{})}},h_=e=>"time"in e?e.time:e.startTime;function hS(e,t,i,r,a,s){let n=document.createElement("track");return n.kind=t,n.label=i,r&&(n.srclang=r),a&&(n.id=a),s&&(n.default=!0),n.track.mode=["subtitles","captions"].includes(t)?"disabled":"hidden",n.setAttribute("data-removeondestroy",""),e.append(n),n.track}function hk(e,t,i){var r;return null==(r=Array.from(e.querySelectorAll("track")).find(e=>e.track.label===t&&e.track.kind===i))?void 0:r.track}async function hR(e,t,i,r){let a=hk(e,i,r);return a||((a=hS(e,r,i)).mode="hidden",await new Promise(e=>setTimeout(()=>e(void 0),0))),"hidden"!==a.mode&&(a.mode="hidden"),[...t].sort((e,t)=>
29h_(t)-h_(e)).forEach(t=>{var i,s;let n=t.value,l=h_(t);if("endTime"in t&&null!=t.endTime)null==a||a.addCue(new VTTCue(l,t.endTime,"chapters"===r?n:JSON.stringify(null!=n?n:null)));else{let t=Array.prototype.findIndex.call(null==a?void 0:a.cues,e=>e.startTime>=l),o=null==(i=null==a?void 0:a.cues)?void 0:i[t],d=o?o.startTime:Number.isFinite(e.duration)?e.duration:Number.MAX_SAFE_INTEGER,h=null==(s=null==a?void 0:a.cues)?void 0:s[t-1];h&&(h.endTime=l),null==a||a.addCue(new VTTCue(l,d,"chapters"===r?n:JSON.stringify(null!=n?n:null)))}}),e.textTracks.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})),a}var hL="cuepoints",hI=Object.freeze({label:hL});async function hw(e,t,i=hI){return hR(e,t,i.label,"metadata")}var hD=e=>({time:e.startTime,value:JSON.parse(e.text)});function hC(e,t={label:hL}){var i,r;let a=hk(e,t.label,"metadata");if(!(null!=(i=null==a?void 0:a.activeCues)&&i.length))return;if(1===a.activeCues.length)return hD(a.activeCues[0]);let{currentTime:s}=e;return hD(Array.prototype.find.call(null!=(r=a.activeCues)?r:[],({startTime:e,endTime:t})=>e<=s&&t>s)||a.activeCues[0])}async function hM(e,t=hI){return new Promise(i=>{hl(e,"loadstart",async()=>{let r=await hw(e,[],t);hl(e,"cuechange",()=>{let t=hC(e);if(t){let i=new CustomEvent("cuepointchange",{composed:!0,bubbles:!0,detail:t});e.dispatchEvent(i)}},{},r),i(r)})})}var hx="chapters",hP=Object.freeze({label:hx}),hO=e=>({startTime:e.startTime,endTime:e.endTime,value:e.text});async function hN(e,t,i=hP){return hR(e,t,i.label,"chapters")}function hU(e,t={label:hx}){var i,r;let a=hk(e,t.label,"chapters");if(!(null!=(i=null==a?void 0:a.activeCues)&&i.length))return;if(1===a.activeCues.length)return hO(a.activeCues[0]);let{currentTime:s}=e;return hO(Array.prototype.find.call(null!=(r=a.activeCues)?r:[],({startTime:e,endTime:t})=>e<=s&&t>s)||a.activeCues[0])}async function hF(e,t=hP){return new Promise(i=>{hl(e,"loadstart",async()=>{let r=await hN(e,[],t);hl(e,"cuechange",()=>{let t=hU(e);if(t){let i=new CustomEvent("chapterchange",{composed:!0,bubbles:!0,detail:t});e.dispatchEvent(i)}},{},r),i(r)})})}var hB=(e,t,i,r,a=!1,s=!(e=>null==(e=globalThis.navigator)?void 0:e.onLine)())=>{var n,l,o,d;let h,u;if(s){let i=hE("Your device appears to be offline",a),r=d5.MEDIA_ERR_NETWORK,s=new d5(i,r,!1,void 0);return s.errorCategory=t,s.muxCode=2000002,s.data=e,s}let c="status"in e?e.status:e.code,m=Date.now(),f=d5.MEDIA_ERR_NETWORK;if(200===c)return;let p=d4(t),g=(h=d4(t),u=`${h}Token`,null!=(o=i.tokens)&&o[h]?null==(d=i.tokens)?void 0:d[h]:d8(u,i)?i[u]:void 0),v=t===d3?"v":"drm"===t?"d":void 0,[E]=ho(null!=(n=i.playbackId)?n:"");if(!c||!E)return;let y=hv(g);if(g&&!y){let i=new d5(hE("The {tokenNamePrefix}-token provided is invalid or malformed.",a).format({tokenNamePrefix:p}),f,!0,hE("Compact JWT string: {token}",a).format({token:g}));return i.errorCategory=t,i.muxCode=2412202,i.data=e,i}if(c>=500){let e=new d5("",f,null==r||r);return e.errorCategory=t,e.muxCode=2e6,e}if(403===c)if(y){if((({exp:e},t=Date.now())=>!e||1e3*e<t)(y,m)){let i={timeStyle:"medium",dateStyle:"medium"},r=new d5(hE("The video’s secured {tokenNamePrefix}-token has expired.",a).format({tokenNamePrefix:p}),f,!0,hE("Expired at: {expiredDate}. Current time: {currentDate}.",a).format({expiredDate:new Intl.DateTimeFormat("en",i).format(null!=(l=y.exp)?l:0),currentDate:new Intl.DateTimeFormat("en",i).format(m)}));return r.errorCategory=t,r.muxCode=2403210,r.data=e,r}if((({sub:e},t)=>e!==t)(y,E)){let i=new d5(hE("The video’s playback ID does not match the one encoded in the {tokenNamePrefix}-token.",a).format({tokenNamePrefix:p}),f,!0,hE("Specified playback ID: {playbackId} and the playback ID encoded in the {tokenNamePrefix}-token: {tokenPlaybackId}",a).format({tokenNamePrefix:p,playbackId:E,tokenPlaybackId:y.sub}));return i.errorCategory=t,i.muxCode=2403232,i.data=e,i}if((({aud:e},t)=>!e)(y,0)){let i=new d5(hE("The {tokenNamePrefix}-token is formatted with incorrect information.",a).format({tokenNamePrefix:p}),f,!0,hE("The {tokenNamePrefix}-token has no aud value. aud value should be {expectedAud}.",a).format({tokenNamePrefix:p,expectedAud:v}));return i.errorCategory=t,i.muxCode=2403221,i.data=e,i}if((({aud:e},t)=>e!==t)(y,v)){let i=new d5(hE("The {tokenNamePrefix}-token is formatted with incorrect information.",a).format({tokenNamePrefix:p}),f,!0,hE("The {tokenNamePrefix}-token has an incorrect aud value: {aud}. aud value should be {expectedAud}.",a).format({tokenNamePrefix:p,expectedAud:v,aud:y.aud}));return i.errorCategory=t,i.muxCode=2403222,i.data=e,i}}else{let i=new d5(hE("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:p,category:t}),f,null==r||r,hE("Specified playback ID: {playbackId}",a).format({playbackId:E}));return i.errorCategory=t,i.muxCode=2403201,i.data=e,i}if(412===c){let s=new d5(hE("This playback-id may belong to a live stream that is not currently active or an asset that is not ready.",a),f,null==r||r,hE("Specified playback ID: {playbackId}",a).format({playbackId:E}));return s.errorCategory=t,s.muxCode=2412e3,s.streamType=i.streamType===d7?"live":i.streamType===d9?"on-demand":"unknown",s.data=e,s}if(404===c){let i=new d5(hE("This URL or playback-id does not exist. You may have used an Asset ID or an ID from a different resource.",a),f,null==r||r,hE("Specified playback ID: {playbackId}",a).format({playbackId:E}));return i.errorCategory=t,i.muxCode=2404e3,i.data=e,i}
29if(400===c){let i=new d5(hE("The URL or playback-id was invalid. You may have used an invalid value as a playback-id."),f,null==r||r,hE("Specified playback ID: {playbackId}",a).format({playbackId:E}));return i.errorCategory=t,i.muxCode=24e5,i.data=e,i}let b=new d5("",f,null==r||r);return b.errorCategory=t,b.muxCode=2e6,b.data=e,b},h$=d2.DefaultConfig.capLevelController;h$||console.error("MinCapLevelController - hls.js DefaultConfig.capLevelController is unavailable");var hH={"720p":921600,"1080p":2073600,"1440p":4194304,"2160p":8294400},hG=class e extends h${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=hH[i.toLowerCase().trim()];if(!r)return super.getMaxLevel(e);let a=t.filter(e=>e.width*e.height<=r),s=a.findIndex(e=>e.width*e.height===r);if(-1!==s){let e=a[s];return t.findIndex(t=>t===e)}if(0===a.length)return 0;let n=a[a.length-1];return t.findIndex(e=>e===n)}getMaxLevel(t){if(void 0!==this.getMaxAutoResolution())return this.getMaxLevelCapped(t);let i=super.getMaxLevel(t),r=this.getValidLevels(t);if(!r[i])return i;let a=Math.min(r[i].width,r[i].height),s=e.minMaxResolution;return a>=s?i:h$.getMaxLevelByMediaSize(r,16/9*s,s)}};hG.minMaxResolution=720,hG.maxAutoResolution=new WeakMap;var hW,hK,hV,hq,hj,hY,hz,hQ,hX,hZ,hJ,h0,h1,h2,h3,h4,h5,h8,h6,h9,h7,ue,ut=e=>new TextDecoder("utf-16le").decode(e).replace("skd://","").slice(1),ui="fairplay",ur=/([A-Z0-9-]+)="?(.*?)"?(?:,|$)/g,ua=async(e,t)=>{if(t===ha.MP4)return{streamType:d9,targetLiveWindow:NaN,liveEdgeStartOffset:void 0,sessionData:void 0};if(t===ha.M3U8){let t=await fetch(e);if(!t.ok)return Promise.reject(t);let i=await t.text(),r=await ((e,t)=>{let i,r=e.split(`
30`).find((e,t,i)=>t>0&&i[t-1].startsWith("#EXT-X-STREAM-INF"));if(!r)return Promise.reject(Error("No media playlist URL found in multivariant playlist"));if(hm(r)&&!t)return Promise.reject(Error("masterPlaylistUrl is required to resolve relative media playlist URL"));try{i=hf(r,t)}catch(e){return Promise.reject(e)}return fetch(i).then(e=>200!==e.status?Promise.reject(e):e.text())})(i,t.url);return{...(e=>{let t=e.split(`
31`).filter(e=>e.startsWith("#EXT-X-SESSION-DATA"));if(!t.length)return{};let i={};for(let e of t){let t=Object.fromEntries([...e.matchAll(ur)].map(([,e,t])=>[e,t])),r=t["DATA-ID"];r&&(i[r]={...t})}return{sessionData:i}})(i),...(e=>{var t,i,r;let a=e.split(`
32`),s=null==(i=(null!=(t=a.find(e=>e.startsWith("#EXT-X-PLAYLIST-TYPE")))?t:"").split(":")[1])?void 0:i.trim(),n=hh(s),l=hu(s),o;if(n===d7){let e=a.find(e=>e.startsWith("#EXT-X-PART-INF"));if(e)o=2*e.split(":")[1].split("=")[1];else{let e=a.find(e=>e.startsWith("#EXT-X-TARGETDURATION")),t=null==(r=null==e?void 0:e.split(":"))?void 0:r[1];o=(null!=t?t:6)*3}}return{streamType:n,targetLiveWindow:l,liveEdgeStartOffset:o}})(r)}}return console.error(`Media type ${t} is an unrecognized or unsupported type for src ${e}.`),{streamType:void 0,targetLiveWindow:void 0,liveEdgeStartOffset:void 0,sessionData:void 0}},us=async(e,t,i=hd({src:e}))=>{var r,a,s,n;let{streamType:l,targetLiveWindow:o,liveEdgeStartOffset:d,sessionData:h}=await ua(e,i),u=null==h?void 0:h["com.apple.hls.chapters"];(null!=u&&u.URI||null!=u&&u.VALUE.toLocaleLowerCase().startsWith("http"))&&un(null!=(r=u.URI)?r:u.VALUE,t),(null!=(a=uh.get(t))?a:{}).liveEdgeStartOffset=d,(null!=(s=uh.get(t))?s:{}).targetLiveWindow=o,t.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),(null!=(n=uh.get(t))?n:{}).streamType=l,t.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},un=async(e,t)=>{var i,r;try{let a=await fetch(e);if(!a.ok)throw Error(`Failed to fetch Mux metadata: ${a.status} ${a.statusText}`);let s=await a.json(),n={};if(!(null!=(i=null==s?void 0:s[0])&&i.metadata))return;for(let e of s[0].metadata)e.key&&e.value&&(n[e.key]=e.value);(null!=(r=uh.get(t))?r:{}).metadata=n;let l=new CustomEvent("muxmetadata");t.dispatchEvent(l)}catch(e){console.error(e)}},ul=null!=(h8=null==(h5=null==globalThis?void 0:globalThis.navigator)?void 0:h5.userAgent)?h8:"",uo=null!=(h7=null==(h9=null==(h6=null==globalThis?void 0:globalThis.navigator)?void 0:h6.userAgentData)?void 0:h9.platform)?h7:"",ud=ul.toLowerCase().includes("android")||["x11","android"].some(e=>uo.toLowerCase().includes(e)),uh=new WeakMap,uu="mux.com",uc=null==(ue=d2.isSupported)?void 0:ue.call(d2),um=()=>{if("u">typeof window)return tG.utils.now()},uf=tG.utils.generateUUID,up=({playbackId:e,customDomain:t=uu,maxResolution:i,minResolution:r,renditionOrder:a,programStartTime:s,programEndTime:n,assetStartTime:l,assetEndTime:o,playbackToken:d,tokens:{playback:h=d}={},extraSourceParams:u={}}={})=>
32{if(!e)return;let[c,m=""]=ho(e),f=new URL(`https://stream.${t}/${c}.m3u8${m}`);return h||f.searchParams.has("token")?(f.searchParams.forEach((e,t)=>{"token"!=t&&f.searchParams.delete(t)}),h&&f.searchParams.set("token",h)):(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),s&&f.searchParams.set("program_start_time",`${s}`),n&&f.searchParams.set("program_end_time",`${n}`),l&&f.searchParams.set("asset_start_time",`${l}`),o&&f.searchParams.set("asset_end_time",`${o}`),Object.entries(u).forEach(([e,t])=>{null!=t&&f.searchParams.set(e,t)})),f.toString()},ug=e=>{if(!e)return;let[t]=e.split("?");return t||void 0},uv=e=>{if(!e||!e.startsWith("https://stream."))return;let[t]=new URL(e).pathname.slice(1).split(/\.m3u8|\//);return t||void 0},uE=e=>{var t;return null==(t=uh.get(e))?void 0:t.error},uy=e=>{var t,i;return null!=(i=null==(t=uh.get(e))?void 0:t.streamType)?i:he},ub=e=>{var t,i;return null!=(i=null==(t=uh.get(e))?void 0:t.seekable)?i:e.seekable},uT=.034,uA=(e,t,i=uT)=>e>t||((e,t,i=uT)=>Math.abs(e-t)<=i)(e,t,i),u_=(e,t)=>{var i,r,a;if(!t||!e.buffered.length)return;if(e.readyState>2)return!1;let s=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(!s||s.live)return;let{fragments:n}=s;if(!(null!=n&&n.length))return;if(e.currentTime<e.duration-(s.targetduration+.5))return!1;let l=n[n.length-1];if(e.currentTime<=l.start)return!1;let o=l.start+l.duration/2,d=e.buffered.start(e.buffered.length-1),h=e.buffered.end(e.buffered.length-1);return o>d&&o<h},uS=(e,t)=>e.ended||e.loop?e.ended:!!(t&&u_(e,t))||((e,t=uT)=>e.paused&&uA(e.currentTime,e.duration,t))(e),uk=(e,t,i)=>{var r,a,s;uL(t,i,e);let{metadata:n={}}=e,{view_session_id:l=uf()}=n,o=null!=(r=null==e?void 0:e.metadata)&&r.video_id?e.metadata.video_id:uN(e)&&null!=(s=null!=(a=ug(e.playbackId))?a:uv(e.src))?s:e.src;n.view_session_id=l,n.video_id=o,e.metadata=n,e.drmTypeCb=e=>{var i;null==(i=t.mux)||i.emit("hb",{view_drm_type:e})},e.fallbackToWebkitFairplay=async()=>{var i;let r=!t.paused,a=t.currentTime;e.useWebkitFairplay=!0;let s=e.muxDataKeepSession;e.muxDataKeepSession=!0;let n=null==(i=uh.get(t))?void 0:i.coreReference;uk(e,t,n),e.muxDataKeepSession=s,e.useWebkitFairplay=!1,r&&await t.play().then(()=>{t.currentTime=a}).catch(()=>{}),t.currentTime=a},uh.set(t,{retryCount:0});let d=uw(e,t),h=(({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 s=!1,n=!1,l=r.config.maxBufferLength,o=r.config.maxBufferSize,d=e=>{a(e);let t=null!=e?e:i.preload;n||"none"===t||("metadata"===t?(r.config.maxBufferLength=1,r.config.maxBufferSize=1):(r.config.maxBufferLength=l,r.config.maxBufferSize=o),h())},h=()=>{!s&&t&&(s=!0,r.loadSource(t))};return hl(i,"play",()=>{n=!0,r.config.maxBufferLength=l,r.config.maxBufferSize=o,h()},{once:!0}),d(e),d})(e,t,d);null!=e&&e.muxDataKeepSession&&null!=t&&t.mux&&!t.mux.deleted?d&&t.mux.addHLSJS({hlsjs:d,Hls:d?d2:void 0}):uF(e,t,d),uB(e,t,d),hM(t),hF(t);let u=((e,t,i)=>{let{autoplay:r}=e,a=!1,s=!1,n=hT(r)?r:!!r,l=()=>{a||hl(t,"playing",()=>{a=!0},{once:!0})};if(l(),hl(t,"loadstart",()=>{a=!1,l(),hA(t,n)},{once:!0}),hl(t,"loadstart",()=>{i||(s=e.streamType&&e.streamType!==he?e.streamType===d7:!Number.isFinite(t.duration)),hA(t,n)},{once:!0}),i&&i.once(d2.Events.LEVEL_LOADED,(t,i)=>{var r;s=e.streamType&&e.streamType!==he?e.streamType===d7:null!=(r=i.details.live)&&r}),!n){let r=()=>{!s||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&&hl(t,"play",()=>{"metadata"===t.preload?i.once(d2.Events.LEVEL_UPDATED,r):r()},{once:!0})}return e=>{a||hA(t,n=hT(e)?e:!!e)}})(e,t,d);((e,t,i)=>{let{minPreloadSegments:r}=e;if(null==r||r<=0||!i)return;let a=0,s=!1,n=t.playbackRate||1,l=()=>{0!==t.playbackRate&&(n=t.playbackRate,t.playbackRate=0)};t.playbackRate=0,hl(t,"ratechange",l);let o=(e,{frag:i})=>{s||"main"!==i.type||++a>=r&&(s=!0,t.removeEventListener("ratechange",l),t.playbackRate=n)};i.on(d2.Events.FRAG_BUFFERED,o),t.addEventListener("teardown",()=>{s||(s=!0,i.off(d2.Events.FRAG_BUFFERED,o),t.playbackRate=n)},{once:!0})})(e,t,d),((e,t,i)=>{let{initialEstimateSegments:r}=e;if(null==r||r<=0||!i)return;let a=0;i.on(d2.Events.FRAG_BUFFERED,(e,{frag:t})=>{"main"===t.type&&++a<r&&i.abrController.resetEstimator(i.config.abrEwmaDefaultEstimate)})})(e,0,d);let c={engine:d,setAutoplay:u,setPreload:h},m=uh.get(t);return m&&(m.coreReference=c),c},uR=new WeakMap,uL=(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",uH),e.removeEventListener("error",uW),e.removeEventListener("durationchange",u$),uh.delete(e),e.dispatchEvent(new Event("teardown")))};function uI(e,t){var i;let r=hd(e);if(r!==ha.M3U8)return!0;let a=!r||null==(i=t.canPlayType(r))||i,{preferPlayback:s}=e,n=uc&&("mse"===s||ud||!(/^((?!chrome|android).)*safari/i.test(ul)&&t.canPlayType("application/vnd.apple.mpegurl")));return a&&(s===ht||!n)}var uw=(e,t)=>{let{debug:i,streamType:r,startTime:a=-1,metadata:s,preferCmcd:n,_hlsConfig:l={},maxAutoResolution:o,initialBandwidthEstimateKbps:d}=e,h=hd(e)===ha.M3U8,u=uI(e,t);if(h&&!u&&uc){let h={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0,capLevelOnFPSDrop:!0,...null!=d?{abrEwmaDefaultEstimate:1e3*d}:{}}
32,u=uD(r),c=uC(e),m=[hi.QUERY,hi.HEADER].includes(n)?{useHeaders:n===hi.HEADER,sessionId:null==s?void 0:s.view_session_id,contentId:null==s?void 0:s.video_id}:void 0,f=uU(e,l),p=new d2({debug:i,startPosition:a,cmcd:m,xhrSetup:(e,t)=>{var i,r;if(n&&n!==hi.QUERY)return;let a=hf(t);if(!a.searchParams.has("CMCD"))return;let s=(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",s),e.open("GET",a)},...h,...f,...u,...c,...l});return f.capLevelController===hG&&void 0!==o&&hG.setMaxAutoResolution(p,o),p.on(d2.Events.MANIFEST_PARSED,async function(e,i){var r,a;let s=null==(r=i.sessionData)?void 0:r["com.apple.hls.chapters"];(null!=s&&s.URI||null!=s&&s.VALUE.toLocaleLowerCase().startsWith("http"))&&un(null!=(a=null==s?void 0:s.URI)?a:null==s?void 0:s.VALUE,t)}),p}},uD=e=>e===d7?{backBufferLength:8}:{},uC=e=>{let{tokens:{drm:t}={},playbackId:i,drmTypeCb:r}=e,a=ug(i);return t&&a?{emeEnabled:!0,drmSystems:{"com.apple.fps":{licenseUrl:uP(e,"fairplay"),serverCertificateUrl:uO(e,"fairplay")},"com.widevine.alpha":{licenseUrl:uP(e,"widevine")},"com.microsoft.playready":{licenseUrl:uP(e,"playready")}},requestMediaKeySystemAccessFunc:(e,t)=>("com.widevine.alpha"===e&&(t=[...t.map(e=>{var t;let i=null==(t=e.videoCapabilities)?void 0:t.map(e=>({...e,robustness:"HW_SECURE_ALL"}));return{...e,videoCapabilities:i}}),...t]),navigator.requestMediaKeySystemAccess(e,t).then(t=>{let i=e.includes("fps")?ui:e.includes("playready")?"playready":e.includes("widevine")?"widevine":void 0;return null==r||r(i),t}))}:{}},uM=async e=>{let t=await fetch(e);return 200!==t.status?Promise.reject(t):await t.arrayBuffer()},ux=async(e,t)=>{let i=await fetch(t,{method:"POST",headers:{"Content-type":"application/octet-stream"},body:e});return 200!==i.status?Promise.reject(i):new Uint8Array(await i.arrayBuffer())},uP=({playbackId:e,tokens:{drm:t}={},customDomain:i=uu},r)=>{let a=ug(e);return`https://license.${i.toLocaleLowerCase().endsWith(uu)?i:uu}/license/${r}/${a}?token=${t}`},uO=({playbackId:e,tokens:{drm:t}={},customDomain:i=uu},r)=>{let a=ug(e);return`https://license.${i.toLocaleLowerCase().endsWith(uu)?i:uu}/appcert/${r}/${a}?token=${t}`},uN=({playbackId:e,src:t,customDomain:i})=>{if(e)return!0;if("string"!=typeof t)return!1;let r=new URL(t,null==window?void 0:window.location.href).hostname.toLocaleLowerCase();return r.includes(uu)||!!i&&r.includes(i.toLocaleLowerCase())},uU=(e,t)=>{let i={};return i.capLevelToPlayerSize=e.capRenditionToPlayerSize,null==i.capLevelToPlayerSize?(i.capLevelController=hG,i.capLevelToPlayerSize=!0):i.capLevelController=lS,i},uF=(e,t,i)=>{var r;let{envKey:a,disableTracking:s,muxDataSDK:n=tG,muxDataSDKOptions:l={}}=e,o=uN(e),d=uh.get(t);if(d&&(d.muxDataDisableCookies=!!e.disableCookies),!s&&(a||o)){let{playerInitTime:s,playerSoftwareName:o,playerSoftwareVersion:d,beaconCollectionDomain:h,debug:u,disableCookies:c}=e,m={...e.metadata,video_title:(null==(r=null==e?void 0:e.metadata)?void 0:r.video_title)||void 0};n.monitor(t,{debug:u,beaconCollectionDomain:h,hlsjs:i,Hls:i?d2:void 0,automaticErrorTracking:!1,errorTranslator:t=>"string"!=typeof t.player_error_code&&("function"==typeof e.errorTranslator?e.errorTranslator(t):t),disableCookies:c,...l,data:{...a?{env_key:a}:{},player_software_name:o,player_software:o,player_software_version:d,player_init_time:s,...m}})}},uB=(e,t,i)=>{var r,a,s;let n=uI(e,t),{src:l,customDomain:o=uu}=e,d=()=>{t.ended||e.disablePseudoEnded||!uS(t,i)||(u_(t,i)?t.currentTime=t.buffered.end(t.buffered.length-1):t.dispatchEvent(new Event("ended")))},h,u,c=()=>{let e=ub(t),i,r;e.length>0&&(i=e.start(0),r=e.end(0)),(u!==r||h!==i)&&t.dispatchEvent(new CustomEvent("seekablechange",{composed:!0})),h=i,u=r};if(hl(t,"durationchange",c),t&&n){let i=hd(e);if("string"==typeof l){if(l.endsWith(".mp4")&&l.includes(o)){let e=uv(l);un(new URL(`https://stream.${o}/${e}/metadata.json`).toString(),t)}let s=()=>{if(uy(t)!==d7||Number.isFinite(t.duration))return;let e=setInterval(c,1e3);t.addEventListener("teardown",()=>{clearInterval(e)},{once:!0}),hl(t,"durationchange",()=>{Number.isFinite(t.duration)&&clearInterval(e)})},n=async()=>us(l,t,i).then(s).catch(i=>{if(i instanceof Response){let r=hB(i,d3,e);if(r)return void uG(t,r)}});if("none"===t.preload){let e=()=>{n(),t.removeEventListener("loadedmetadata",i)},i=()=>{n(),t.removeEventListener("play",e)};hl(t,"play",e,{once:!0}),hl(t,"loadedmetadata",i,{once:!0})}else n();null!=(r=e.tokens)&&r.drm?((e,t)=>{let i={mediaEl:t,getAppCertificate:()=>uM(uO(e,"fairplay")).catch(t=>{if(t instanceof Response){let i=hB(t,"drm",e);return console.error("mediaError",null==i?void 0:i.message,null==i?void 0:i.context),i?Promise.reject(i):Promise.reject(Error("Unexpected error in app cert request"))}return Promise.reject(t)}),getLicenseKey:t=>ux(t,uP(e,"fairplay")).catch(t=>{if(t instanceof Response){let i=hB(t,"drm",e);return console.error("mediaError",null==i?void 0:i.message,null==i?void 0:i.context),i?Promise.reject(i):Promise.reject(Error("Unexpected error in license key request"))}return Promise.reject(t)}),saveAndDispatchError:uG,drmTypeCb:()=>{var t;null==(t=e.drmTypeCb)||t.call(e,ui)}};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=new d5(hE("Cannot play DRM-protected content with current security configuration on this browser. Try playing in another browser."),d5.MEDIA_ERR_ENCRYPTED,!0);return t.errorCategory="drm",t.muxCode=5000005,r(e,t),()=>{}}let s=t(),n=null,l=t=>{(async()=>{try{var i,a;let r,n,l,h,u,c,m,f;e.webkitKeys||o();let p=await s;if(null===t.initData||null==p)return;let g=(i=t.initData,a=p,r=function(e){let t=new ArrayBuffer(2*e.length),i=new DataView(t);for(let t=0;t<e.length;t++)i.setUint16(2*t,e.charCodeAt(t),!0);return t}(ut(i)),n=new Uint8Array(i),l=new Uint8Array(r),h=new Uint8Array(a),u=new Uint8Array(n.byteLength+4+h.byteLength+4+l.byteLength),c=0,m=e=>{u.set(e,c),c+=e.byteLength},f=e=>{let t=new DataView(u.buffer),i=e.byteLength;t.setUint32(c,i,!0),c+=4,m(e)},m(n),f(l),f(h),u);d(g)}catch(t){console.error("Could not start encrypted playback due to exception",t),r(e,t)}})()},o=()=>{try{let t=new WebKitMediaKeys("com.apple.fps.1_0");e.webkitSetMediaKeys(t),a()}catch{let e=new d5("Cannot play DRM-protected content with current security configuration on this browser. Try playing in another browser.",d5.MEDIA_ERR_ENCRYPTED,!0);throw e.errorCategory="drm",e.muxCode=5000001,e}},d=t=>{let a=e.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=new d5(hE("The DRM Content Decryption Module system had an internal failure. Try reloading the page, updating your browser, or playing in another browser."),d5.MEDIA_ERR_ENCRYPTED,!0);a.errorCategory="drm",a.muxCode=5000005,r(e,a)},o=()=>{a.removeEventListener("webkitkeymessage",s),a.removeEventListener("webkitkeyerror",l),e.removeEventListener("teardown",o),"webkitCurrentPlaybackTargetIsWireless"in e&&e.removeEventListener("webkitcurrentplaybacktargetiswirelesschanged",o),n=null;try{a.close()}catch{}};"webkitCurrentPlaybackTargetIsWireless"in e&&e.addEventListener("webkitcurrentplaybacktargetiswirelesschanged",o,{once:!0}),a.addEventListener("webkitkeymessage",s),a.addEventListener("webkitkeyerror",l),e.addEventListener("teardown",o),n=o},h=()=>{e.removeEventListener("webkitneedkey",l),e.removeEventListener("teardown",h),null==n||n();try{e.webkitSetMediaKeys(null)}catch{}};return e.addEventListener("webkitneedkey",l),e.addEventListener("teardown",h,{once:!0})})(i);else{let t=(({mediaEl:e,getAppCertificate:t,getLicenseKey:i,saveAndDispatchError:r,drmTypeCb:a,fallbackToWebkitFairplay:s})=>{let n=null,l=async t=>{try{let i=t.initDataType;if("skd"!==i)return void console.error(`Received unexpected initialization data type "${i}"`);e.mediaKeys||await o(i);let r=t.initData;if(null==r)return void console.error(`Could not start encrypted playback due to missing initData in ${t.type} event`);await d(i,r)}catch(t){r(e,t);return}},o=async i=>{let s=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=new d5(hE("Cannot play DRM-protected content with current security configuration on this browser. Try playing in another browser."),d5.MEDIA_ERR_ENCRYPTED,!0);t.errorCategory="drm",t.muxCode=5000001,r(e,t)});if(!s)return;let n=await s.createMediaKeys();try{let e=await t();await n.setServerCertificate(e).catch(()=>{let e=hE("Your server certificate failed when attempting to set it. This may be an issue with a no longer valid certificate."),t=new d5(e,d5.MEDIA_ERR_ENCRYPTED,!0);return t.errorCategory="drm",t.muxCode=5000004,Promise.reject(t)})}catch(t){r(e,t);return}await e.setMediaKeys(n)},d=async(t,a)=>{let l=e.mediaKeys.createSession(),o=async t=>{let a=t.message,s=await i(a);try{await l.update(s)}catch{let t=new d5(hE("Failed to update DRM license. This may be an issue with the player or your protected content."),d5.MEDIA_ERR_ENCRYPTED,!0);t.errorCategory="drm",t.muxCode=5000003,r(e,t)}},d=()=>
32{l.keyStatuses.forEach(t=>{let i;"internal-error"===t?((i=new d5(hE("The DRM Content Decryption Module system had an internal failure. Try reloading the page, updating your browser, or playing in another browser."),d5.MEDIA_ERR_ENCRYPTED,!0)).errorCategory="drm",i.muxCode=5000005):("output-restricted"===t||"output-downscaled"===t)&&((i=new d5(hE("DRM playback is being attempted in an environment that is not sufficiently secure. User may see black screen."),d5.MEDIA_ERR_ENCRYPTED,!1)).errorCategory="drm",i.muxCode=5000006),i&&r(e,i)})};l.addEventListener("keystatuseschange",d),l.addEventListener("message",o);let h=async()=>{l.removeEventListener("keystatuseschange",d),l.removeEventListener("message",o),"webkitCurrentPlaybackTargetIsWireless"in e&&e.removeEventListener("webkitcurrentplaybacktargetiswirelesschanged",h),e.removeEventListener("teardown",h),await l.close().catch(e=>{console.warn("There was an error when closing EME session",e)}),n=null};"webkitCurrentPlaybackTargetIsWireless"in e&&e.addEventListener("webkitcurrentplaybacktargetiswirelesschanged",h,{once:!0}),e.addEventListener("teardown",h,{once:!0}),n=h,await l.generateRequest(t,a).catch(async t=>{if("NotSupportedError"===t.name&&"webkitCurrentPlaybackTargetIsWireless"in e&&e.webkitCurrentPlaybackTargetIsWireless)console.warn("Failed to generate a DRM license request. Attempting to fallback to Webkit DRM"),null==s||s();else{let e=new d5(hE("Failed to generate a DRM license request. This may be an issue with the player or your protected content."),d5.MEDIA_ERR_ENCRYPTED,!0);return e.errorCategory="drm",e.muxCode=5000002,console.error("Failed to generate license request",t),Promise.reject(e)}})},h=async()=>{e.removeEventListener("encrypted",l),e.removeEventListener("teardown",h),n&&await n(),await e.setMediaKeys(null).catch(()=>{})};return e.addEventListener("encrypted",l),e.addEventListener("teardown",h,{once:!0}),h})({fallbackToWebkitFairplay:async()=>{var i;await t(),null==(i=e.fallbackToWebkitFairplay)||i.call(e)},...i})}})(e,t):hl(t,"encrypted",()=>{let e=new d5(hE("Attempting to play DRM-protected content without providing a DRM token."),d5.MEDIA_ERR_ENCRYPTED,!0);e.errorCategory="drm",e.muxCode=5000002,uG(t,e)},{once:!0}),t.setAttribute("src",l),e.startTime&&((null!=(a=uh.get(t))?a:{}).startTime=e.startTime,t.addEventListener("durationchange",u$,{once:!0}))}else t.removeAttribute("src");t.addEventListener("error",uH),t.addEventListener("error",uW),t.addEventListener("emptied",()=>{t.querySelectorAll("track[data-removeondestroy]").forEach(e=>{e.remove()})},{once:!0}),hl(t,"pause",d),hl(t,"seeked",d),hl(t,"play",()=>{t.ended||uA(t.currentTime,t.duration)&&(t.currentTime=t.seekable.length?t.seekable.start(0):0)})}else if(i&&l){let r,a;i.once(d2.Events.LEVEL_LOADED,(e,r)=>{((e,t,i)=>{var r,a,s,n,l,o,d,h,u;let c,m,f,p,g,{streamType:v,targetLiveWindow:E,liveEdgeStartOffset:y,lowLatency:b}=(m=hh(c=e.type),f=hu(c),g=!!(null!=(u=e.partList)&&u.length),m===d7&&(p=g?2*e.partTarget:3*e.targetduration),{streamType:m,targetLiveWindow:f,liveEdgeStartOffset:p,lowLatency:g});if(v===d7){b?(i.config.backBufferLength=null!=(r=i.userConfig.backBufferLength)?r:4,i.config.maxFragLookUpTolerance=null!=(a=i.userConfig.maxFragLookUpTolerance)?a:.001,i.config.abrBandWidthUpFactor=null!=(s=i.userConfig.abrBandWidthUpFactor)?s:i.config.abrBandWidthFactor):i.config.backBufferLength=null!=(n=i.userConfig.backBufferLength)?n:8;let e=Object.freeze({get length(){return t.seekable.length},start:e=>t.seekable.start(e),end(e){var r;return e>this.length||e<0||Number.isFinite(t.duration)?t.seekable.end(e):null!=(r=i.liveSyncPosition)?r:t.seekable.end(e)}});(null!=(l=uh.get(t))?l:{}).seekable=e}(null!=(o=uh.get(t))?o:{}).liveEdgeStartOffset=y,(null!=(d=uh.get(t))?d:{}).targetLiveWindow=E,t.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),(null!=(h=uh.get(t))?h:{}).streamType=v,t.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))})(r.details,t,i),c(),uy(t)!==d7||Number.isFinite(t.duration)||(i.on(d2.Events.LEVEL_UPDATED,c),hl(t,"durationchange",()=>{Number.isFinite(t.duration)&&i.off(d2.Events.LEVELS_UPDATED,c)}))});let n=null!=(s=e.maxReconnectRetries)?s:0,o=n>0?(({hls:e,mediaEl:t,src:i,muxMediaState:r,saveAndDispatchError:a,maxRetries:s})=>{var n;
32let l,o=0,d=!1,h=!1,u=!1,c=()=>{null!=l&&(clearTimeout(l),l=void 0)},m=e=>(null==e?void 0:e.muxCode)===2000003,f=()=>{!u&&i?e.loadSource(i):e.startLoad(t.currentTime)},p=()=>{let e=r.get(t);!(null!=e&&e.networkError)||h||!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 d5(hE("Attempting to reconnect..."),d5.MEDIA_ERR_NETWORK,!1);i.errorCategory=d3,i.muxCode=2000003,e&&(e.error=i),t.dispatchEvent(new CustomEvent("error",{detail:i}))})(),(()=>{if(null==l&&!d){if(o>=s){let e;return d=!1,h=!0,c(),(e=new d5(hE("Network error, try reloading."),d5.MEDIA_ERR_NETWORK,!0)).errorCategory=d3,e.reload=!0,a(t,e)}d=!0,l=setTimeout(()=>{l=void 0,o+=1,f()},Math.min(1e3*2**o,3e4))}})())},g=()=>{let e=r.get(t);null!=e&&e.networkError&&(o=0,h=!1,c(),d=!0,f())};return null==(n=globalThis.addEventListener)||n.call(globalThis,"online",g),e.on(d2.Events.FRAG_BUFFERED,()=>{let e=r.get(t);e&&(e.networkError||m(e.error))&&(e.networkError=!1,d=!1,o=0,h=!1,c(),e.error&&(e.error=null,t.dispatchEvent(new Event("emptied"))))}),hl(t,"playing",()=>{let e=r.get(t);null!=e&&e.networkError&&(d=!1,o=0,h=!1,c(),e.error&&(e.error=null))}),hl(t,"waiting",p),t.addEventListener("teardown",()=>{var e;null==(e=globalThis.removeEventListener)||e.call(globalThis,"online",g),c()},{once:!0}),{handleHlsError:(e,i)=>{var a,s;let n;if(e.type!==d2.ErrorTypes.NETWORK_ERROR)return!1;let l=null!=(s=null==(a=e.response)?void 0:a.code)?s:0;return(2000002===i.muxCode||0===l||l>=500)&&!!e.fatal&&((n=r.get(t))&&(n.networkError=!0),d=!1,p(),!0)},onManifestLoaded:()=>{u=!0,d=!1,c()}}})({hls:i,mediaEl:t,src:l,muxMediaState:uh,saveAndDispatchError:uG,maxRetries:n}):void 0;i.on(d2.Events.ERROR,(r,a)=>{var s,n;let l=uK(a,e);if(2412e3===l.muxCode){let e=null!=(s=uh.get(t))?s:{},r=null!=(n=e.retryCount)?n:0;if(r<6){let s=0===r?5e3:6e4,n=new d5(`Retrying in ${s/1e3} seconds...`,l.code,l.fatal);Object.assign(n,l),uG(t,n);let o=setTimeout(()=>{e.retryCount=r+1,"manifestLoadError"===a.details&&a.url&&i.loadSource(a.url)},s);t.addEventListener("teardown",()=>clearTimeout(o),{once:!0});return}{e.retryCount=0;let i=new d5("Network error, try reloading.",l.code,l.fatal);Object.assign(i,l),i.reload=!0,uG(t,i);return}}null!=o&&o.handleHlsError(a,l)||uG(t,l)}),i.on(d2.Events.MANIFEST_LOADED,()=>{null==o||o.onManifestLoaded();let e=uh.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",uW),hl(t,"waiting",d),function(e,t){var i;if(!("videoTracks"in e))return;let r=new WeakMap;t.on(d2.Events.MANIFEST_PARSED,function(t,i){l();let a=e.addVideoTrack("main");for(let[e,t]of(a.selected=!0,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(d2.Events.AUDIO_TRACKS_UPDATED,function(t,i){for(let t of(n(),i.audioTracks)){let i=t.default?"main":"alternative",r=e.addAudioTrack(i,t.name,t.lang);r.id=`${t.id}`,t.default&&(r.enabled=!0)}});let 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(d2.Events.LEVELS_UPDATED,function(t,i){var a;let s=e.videoTracks[null!=(a=e.videoTracks.selectedIndex)?a:0];if(!s)return;let n=i.levels.map(e=>r.get(e));for(let t of e.videoRenditions)t.id&&!n.includes(t.id)&&s.removeRendition(t)});let s=e=>{let i=e.target.selectedIndex;i!=t.nextLevel&&(t.nextLevel=i)};null==(i=e.videoRenditions)||i.addEventListener("change",s);let n=()=>{for(let t of e.audioTracks)e.removeAudioTrack(t)},l=()=>{(()=>{for(let t of e.videoTracks)e.removeVideoTrack(t)})(),n()};t.once(d2.Events.DESTROYING,()=>{var t,i;l(),null==(t=e.audioTracks)||t.removeEventListener("change",a),null==(i=e.videoRenditions)||i.removeEventListener("change",s)})}(e,i),i.on(d2.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(e,{tracks:r})=>{r.forEach(e=>{var r,a;let s=null!=(r=e.subtitleTrack)?r:e.closedCaptions,n=i.subtitleTracks.findIndex(({lang:t,name:i,type:r})=>t==(null==s?void 0:s.lang)&&i===e.label&&r.toLowerCase()===e.kind),l=(null!=(a=e._id)?a:e.default)?"default":`${e.kind}${n}`;hS(t,e.kind,e.label,null==s?void 0:s.lang,l,e.default)})}),r=()=>{if(!i.subtitleTracks.length)return;let e=Array.from(t.textTracks).find(e=>e.id&&"showing"===e.mode&&["subtitles","captions"].includes(e.kind));if(!e)return;let r=i.subtitleTracks[i.subtitleTrack],a=r?r.default?"default":`${i.subtitleTracks[i.subtitleTrack].type.toLowerCase()}${i.subtitleTrack}`:void 0;if(i.subtitleTrack<0||(null==e?void 0:e.id)!==a){let t=i.subtitleTracks.findIndex(({lang:t,name:i,type:r,default:a})=>"default"===e.id&&a||t==e.language&&i===e.label&&r.toLowerCase()===e.kind);i.subtitleTrack=t}
32(null==e?void 0:e.id)===a&&e.cues&&Array.from(e.cues).forEach(t=>{e.addCue(t)})},t.textTracks.addEventListener("change",r),i.on(d2.Events.CUES_PARSED,(e,{track:i,cues:r})=>{let a=t.textTracks.getTrackById(i);if(!a)return;let s="disabled"===a.mode;s&&(a.mode="hidden"),r.forEach(e=>{var t;null!=(t=a.cues)&&t.getCueById(e.id)||a.addCue(e)}),s&&(a.mode="disabled")}),i.once(d2.Events.DESTROYING,()=>{t.textTracks.removeEventListener("change",r),t.querySelectorAll("track[data-removeondestroy]").forEach(e=>{e.remove()})}),a=()=>{Array.from(t.textTracks).forEach(e=>{var i,r;if(!["subtitles","caption"].includes(e.kind)&&("thumbnails"===e.label||"chapters"===e.kind)){if(!(null!=(i=e.cues)&&i.length)){let i="track";e.kind&&(i+=`[kind="${e.kind}"]`),e.label&&(i+=`[label="${e.label}"]`);let a=t.querySelector(i),s=null!=(r=null==a?void 0:a.getAttribute("src"))?r:"";null==a||a.removeAttribute("src"),setTimeout(()=>{null==a||a.setAttribute("src",s)},0)}"hidden"!==e.mode&&(e.mode="hidden")}})},i.once(d2.Events.MANIFEST_LOADED,a),i.once(d2.Events.MEDIA_ATTACHED,a),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 u$(e){var t;let i=e.target,r=null==(t=uh.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 uH(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 d5(i,r);if(t.src&&r===d5.MEDIA_ERR_SRC_NOT_SUPPORTED&&t.readyState===HTMLMediaElement.HAVE_NOTHING)return void setTimeout(()=>{var e;let i=null!=(e=uE(t))?e:t.error;(null==i?void 0:i.code)===d5.MEDIA_ERR_SRC_NOT_SUPPORTED&&uG(t,a)},500);if(t.src&&(r!==d5.MEDIA_ERR_DECODE||void 0!==r))try{let{status:e}=await fetch(t.src);a.data={response:{code:e}}}catch{}uG(t,a)}function uG(e,t){var i;t.fatal&&((null!=(i=uh.get(e))?i:{}).error=t,e.dispatchEvent(new CustomEvent("error",{detail:t})))}function uW(e){var t,i;if(!(e instanceof CustomEvent)||!(e.detail instanceof d5))return;let r=e.target,a=e.detail;a&&a.fatal&&((null!=(t=uh.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 uK=(e,t)=>{var i,r,a;e.fatal?console.error("getErrorFromHlsErrorData()",e):t.debug&&console.warn("getErrorFromHlsErrorData() (non-fatal)",e);let s={[d2.ErrorTypes.NETWORK_ERROR]:d5.MEDIA_ERR_NETWORK,[d2.ErrorTypes.MEDIA_ERROR]:d5.MEDIA_ERR_DECODE,[d2.ErrorTypes.KEY_SYSTEM_ERROR]:d5.MEDIA_ERR_ENCRYPTED},n,l=[d2.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,d2.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED].includes(e.details)?d5.MEDIA_ERR_NETWORK:s[e.type];if(l===d5.MEDIA_ERR_NETWORK&&e.response){let a=null!=(i=e.type===d2.ErrorTypes.KEY_SYSTEM_ERROR?"drm":e.type===d2.ErrorTypes.NETWORK_ERROR?d3:void 0)?i:d3;n=null!=(r=hB(e.response,a,t,e.fatal))?r:new d5("",l,e.fatal)}else l===d5.MEDIA_ERR_ENCRYPTED?e.details===d2.ErrorDetails.KEY_SYSTEM_NO_CONFIGURED_LICENSE?((n=new d5(hE("Attempting to play DRM-protected content without providing a DRM token."),d5.MEDIA_ERR_ENCRYPTED,e.fatal)).errorCategory="drm",n.muxCode=5000002):e.details===d2.ErrorDetails.KEY_SYSTEM_NO_ACCESS?((n=new d5(hE("Cannot play DRM-protected content with current security configuration on this browser. Try playing in another browser."),d5.MEDIA_ERR_ENCRYPTED,e.fatal)).errorCategory="drm",n.muxCode=5000001):e.details===d2.ErrorDetails.KEY_SYSTEM_NO_SESSION?((n=new d5(hE("Failed to generate a DRM license request. This may be an issue with the player or your protected content."),d5.MEDIA_ERR_ENCRYPTED,!0)).errorCategory="drm",n.muxCode=5000002):e.details===d2.ErrorDetails.KEY_SYSTEM_SESSION_UPDATE_FAILED?((n=new d5(hE("Failed to update DRM license. This may be an issue with the player or your protected content."),d5.MEDIA_ERR_ENCRYPTED,e.fatal)).errorCategory="drm",n.muxCode=5000003):e.details===d2.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED?((n=new d5(hE("Your server certificate failed when attempting to set it. This may be an issue with a no longer valid certificate."),d5.MEDIA_ERR_ENCRYPTED,e.fatal)).errorCategory="drm",n.muxCode=5000004):e.details===d2.ErrorDetails.KEY_SYSTEM_STATUS_INTERNAL_ERROR?((n=new d5(hE("The DRM Content Decryption Module system had an internal failure. Try reloading the page, updating your browser, or playing in another browser."),d5.MEDIA_ERR_ENCRYPTED,e.fatal)).errorCategory="drm",n.muxCode=5000005):e.details===d2.ErrorDetails.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED?((n=new d5(hE("DRM playback is being attempted in an environment that is not sufficiently secure. User may see black screen."),d5.MEDIA_ERR_ENCRYPTED,!1)).errorCategory="drm",n.muxCode=5000006):((n=new d5(e.error.message,d5.MEDIA_ERR_ENCRYPTED,e.fatal)).errorCategory="drm",n.muxCode=5e6):n=new d5("",l,e.fatal);return n.context||(n.context=`${e.url?`url: ${e.url}
33`:""}${e.response&&(e.response.code||e.response.text)?`response: ${e.response.code}, ${e.response.text}
34`:""}${e.reason?`failure reason: ${e.reason}
35`:""}${e.level?`level: ${e.level}
36`:""}${e.parent?`parent stream controller: ${e.parent}
37`:""}${e.buffer?`buffer length: ${e.buffer}
38`:""}${e.error?`error: ${e.error}
39`:""}${e.event?`event: ${e.event}
40`:""}${e.err?`error message: ${null==(a=e.err)?void 0:a.message}
41`:""}`),n.data=e,n};let uV=["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"],uq=["autopictureinpicture","disablepictureinpicture","disableremoteplayback","autoplay","controls","controlslist","crossorigin","loop","muted","playsinline","poster","preload","src"];function uj(e){return`
42    <style>
43      :host {
44        display: inline-flex;
45        line-height: 0;
46        flex-direction: column;
47        justify-content: end;
48      }
49
50      audio {
51        width: 100%;
52      }
53    </style>
54    <slot name="media">
55      <audio${uQ(e)}></audio>
56    </slot>
57    <slot></slot>
58  `}function uY(e){return`
59    <style>
60      :host {
61        display: inline-block;
62        line-height: 0;
63      }
64
65      video {
66        max-width: 100%;
67        max-height: 100%;
68        min-width: 100%;
69        min-height: 100%;
70        object-fit: var(--media-object-fit, contain);
71        object-position: var(--media-object-position, 50% 50%);
72      }
73
74      video::-webkit-media-text-track-container {
75        transform: var(--media-webkit-text-track-transform);
76        transition: var(--media-webkit-text-track-transition);
77      }
78    </style>
79    <slot name="media">
80      <video${uQ(e)}></video>
81    </slot>
82    <slot></slot>
83  `}function uz(e,{tag:t,is:i}){let r=globalThis.document?.createElement?.(t,{is:i}),a=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 class s extends e{static getTemplateHTML=t.endsWith("audio")?uj:uY;static shadowRootOptions={mode:"open"};static Events=uV;static #e=!1;static get observedAttributes(){return s.#t(),[...r?.constructor?.observedAttributes??[],...uq]}static #t(){if(this.#e)return;this.#e=!0;let e=new Set(this.observedAttributes);for(let t of(e.delete("muted"),a))if(!(t in this.prototype))if("function"==typeof r[t])this.prototype[t]=function(...e){return this.#i(),(()=>{if(this.call)return this.call(t,...e);let i=this.nativeEl?.[t];return i?.apply(this.nativeEl,e)})()};else{let i={get(){this.#i();let i=t.toLowerCase();if(e.has(i)){let e=this.getAttribute(i);return null!==e&&(""===e||e)}return this.get?.(t)??this.nativeEl?.[t]}};t!==t.toUpperCase()&&(i.set=function(i){this.#i();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)}}#r=!1;#a=null;#s=new Map;#n;#l;get;set;call;get nativeEl(){return this.#i(),this.#a??this.querySelector(":scope > [slot=media]")??this.querySelector(t)??this.shadowRoot?.querySelector(t)??null}set nativeEl(e){this.#a=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(){return this.getAttribute("preload")??this.nativeEl?.preload}set preload(e){this.setAttribute("preload",`${e}`)}#i(){this.#r||(this.#r=!0,this.init())}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)}for(let e of(this.nativeEl.muted=this.hasAttribute("muted"),a))this.#o(e);this.#d()}#d(){for(let e of(this.#n=new MutationObserver(this.#h.bind(this)),this.#l=()=>this.#u(),this.shadowRoot?.addEventListener("slotchange",this.#l),this.#u(),this.constructor.Events))this.shadowRoot?.addEventListener(e,this,!0)}handleEvent(e){e.target===this.nativeEl&&this.dispatchEvent(new CustomEvent(e.type,{detail:e.detail}))}#u(){let e=new Map(this.#s),t=this.shadowRoot?.querySelector("slot:not([name])");(t?.assignedElements({flatten:!0}).filter(e=>
83["track","source"].includes(e.localName))).forEach(t=>{e.delete(t);let i=this.#s.get(t);i||(i=t.cloneNode(),this.#s.set(t,i),this.#n?.observe(t,{attributes:!0})),this.nativeEl?.append(i),this.#c(i)}),e.forEach((e,t)=>{e.remove(),this.#s.delete(t)})}#h(e){for(let t of e)if("attributes"===t.type){let{target:e,attributeName:i}=t,r=this.#s.get(e);r&&i&&(r.setAttribute(i,e.getAttribute(i)??""),this.#c(r))}}#c(e){e&&"track"===e.localName&&e.default&&("chapters"===e.kind||"metadata"===e.kind)&&"disabled"===e.track.mode&&(e.track.mode="hidden")}#o(e){if(Object.prototype.hasOwnProperty.call(this,e)){let t=this[e];delete this[e],this[e]=t}}attributeChangedCallback(e,t,i){this.#i(),this.#m(e,t,i)}#m(e,t,i){["id","class"].includes(e)||!s.observedAttributes.includes(e)&&this.constructor.observedAttributes.includes(e)||(null===i?this.nativeEl?.removeAttribute(e):this.nativeEl?.getAttribute(e)!==i&&this.nativeEl?.setAttribute(e,i))}connectedCallback(){this.#i(),this.#l||this.#d()}disconnectedCallback(){for(let e of(this.#n?.disconnect(),this.#n=void 0,this.#l&&(this.shadowRoot?.removeEventListener("slotchange",this.#l),this.#l=void 0),this.constructor.Events))this.shadowRoot?.removeEventListener(e,this,!0);this.#s.forEach(e=>e.remove()),this.#s.clear(),this.#a=null}}}function uQ(e){let t="";for(let i in e){if(!uq.includes(i))continue;let r=e[i];""===r?t+=` ${i}`:t+=` ${i}="${r}"`}return t}let uX=uz(globalThis.HTMLElement??class{},{tag:"video"});uz(globalThis.HTMLElement??class{},{tag:"audio"});var uZ,uJ,u0,u1,u2,u3,u4,u5,u8,u6,u9,u7,ce,ct,ci=e=>{throw TypeError(e)},cr=(e,t,i)=>t.has(e)||ci("Cannot "+i),ca=(e,t,i)=>(cr(e,t,"read from private field"),i?i.call(e):t.get(e)),cs=(e,t,i)=>t.has(e)?ci("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,i),cn=(e,t,i,r)=>(cr(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i),cl=(e,t,i)=>(cr(e,t,"access private method"),i),co=(()=>{try{return"0.31.4"}catch{}return"UNKNOWN"})(),cd=`
84<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>`,ch={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"}
84,cu=Object.values(ch),cc="mux-video",cm=class extends uX{constructor(){super(),cs(this,u9),cs(this,uZ),cs(this,uJ),cs(this,u0,{}),cs(this,u1,{}),cs(this,u2),cs(this,u3),cs(this,u4),cs(this,u5),cs(this,u8,""),cs(this,u6,e=>{var t,i,r;let a=(i=this.nativeEl,null==(r=uh.get(i))?void 0:r.metadata),s=null!=(t=this.metadata)?t:{};this.metadata={...a,...s},(null==a?void 0:a["com.mux.video.branding"])==="mux-free-plan"&&(cn(this,u8,"default"),this.updateLogo())}),cs(this,ce),cn(this,uJ,um())}static get NAME(){return cc}static get VERSION(){return co}static get observedAttributes(){var e;return[...cu,...null!=(e=uX.observedAttributes)?e:[]]}static getLogoHTML(e){return e&&"false"!==e?"default"===e?cd:`<img part="logo" src="${e}" />`:""}static getTemplateHTML(e={}){var t;return`
85      ${uX.getTemplateHTML(e)}
86      <style>
87        :host {
88          position: relative;
89        }
90        slot[name="logo"] {
91          display: flex;
92          justify-content: end;
93          position: absolute;
94          top: 1rem;
95          right: 1rem;
96          opacity: 0;
97          transition: opacity 0.25s ease-in-out;
98          z-index: 1;
99        }
100        slot[name="logo"]:has([part="logo"]) {
101          opacity: 1;
102        }
103        slot[name="logo"] [part="logo"] {
104          width: 5rem;
105          pointer-events: none;
106          user-select: none;
107        }
108      </style>
109      <slot name="logo">
110        ${this.getLogoHTML(null!=(t=e[ch.LOGO])?t:"")}
111      </slot>
112    `}get preferCmcd(){var e;return null!=(e=this.getAttribute(ch.PREFER_CMCD))?e:void 0}set preferCmcd(e){e!==this.preferCmcd&&(e?hr.includes(e)?this.setAttribute(ch.PREFER_CMCD,e):console.warn(`Invalid value for preferCmcd. Must be one of ${hr.join()}`):this.removeAttribute(ch.PREFER_CMCD))}get playerInitTime(){return this.hasAttribute(ch.PLAYER_INIT_TIME)?+this.getAttribute(ch.PLAYER_INIT_TIME):ca(this,uJ)}set playerInitTime(e){e!=this.playerInitTime&&(null==e?this.removeAttribute(ch.PLAYER_INIT_TIME):this.setAttribute(ch.PLAYER_INIT_TIME,`${+e}`))}get playerSoftwareName(){var e;return null!=(e=ca(this,u4))?e:cc}set playerSoftwareName(e){cn(this,u4,e)}get playerSoftwareVersion(){var e;return null!=(e=ca(this,u3))?e:co}set playerSoftwareVersion(e){cn(this,u3,e)}get _hls(){var e;return null==(e=ca(this,u9,u7))?void 0:e.engine}get mux(){var e;return null==(e=this.nativeEl)?void 0:e.mux}get error(){var e;return null!=(e=uE(this.nativeEl))?e:null}get errorTranslator(){return ca(this,u5)}set errorTranslator(e){cn(this,u5,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(ch.TYPE))?e:void 0}set type(e){e!==this.type&&(e?this.setAttribute(ch.TYPE,e):this.removeAttribute(ch.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(ch.DEBUG)}set debug(e){e!==this.debug&&(e?this.setAttribute(ch.DEBUG,""):this.removeAttribute(ch.DEBUG))}get disableTracking(){return this.hasAttribute(ch.DISABLE_TRACKING)}set disableTracking(e){e!==this.disableTracking&&this.toggleAttribute(ch.DISABLE_TRACKING,!!e)}get disableCookies(){return this.hasAttribute(ch.DISABLE_COOKIES)}set disableCookies(e){e!==this.disableCookies&&(e?this.setAttribute(ch.DISABLE_COOKIES,""):this.removeAttribute(ch.DISABLE_COOKIES))}get disablePseudoEnded(){return this.hasAttribute(ch.DISABLE_PSEUDO_ENDED)}set disablePseudoEnded(e){e!==this.disablePseudoEnded&&(e?this.setAttribute(ch.DISABLE_PSEUDO_ENDED,""):this.removeAttribute(ch.DISABLE_PSEUDO_ENDED))}get maxReconnectRetries(){let e=this.getAttribute(ch.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(ch.MAX_RECONNECT_RETRIES):this.setAttribute(ch.MAX_RECONNECT_RETRIES,`${e}`))}get startTime(){let e=this.getAttribute(ch.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(ch.START_TIME):this.setAttribute(ch.START_TIME,`${e}`))}get initialBandwidthEstimateKbps(){let e=this.getAttribute(ch.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(ch.INITIAL_BANDWIDTH_ESTIMATE_KBPS):this.setAttribute(ch.INITIAL_BANDWIDTH_ESTIMATE_KBPS,`${e}`))}get initialEstimateSegments(){let e=this.getAttribute(ch.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(ch.INITIAL_ESTIMATE_SEGMENTS):this.setAttribute(ch.INITIAL_ESTIMATE_SEGMENTS,`${e}`))}get minPreloadSegments(){let e=this.getAttribute(ch.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(ch.MIN_PRELOAD_SEGMENTS):this.setAttribute(ch.MIN_PRELOAD_SEGMENTS,`${e}`))}get playbackId(){var e;return this.hasAttribute(ch.PLAYBACK_ID)?this.getAttribute(ch.PLAYBACK_ID):null!=(e=uv(this.src))?e:void 0}set playbackId(e){e!==this.playbackId&&(e?this.setAttribute(ch.PLAYBACK_ID,e):this.removeAttribute(ch.PLAYBACK_ID))}get maxResolution(){var e;return null!=(e=this.getAttribute(ch.MAX_RESOLUTION))?e:void 0}set maxResolution(e){e!==this.maxResolution&&(e?this.setAttribute(ch.MAX_RESOLUTION,e):this.removeAttribute(ch.MAX_RESOLUTION))}get minResolution(){var e;return null!=(e=this.getAttribute(ch.MIN_RESOLUTION))?e:void 0}set minResolution(e){e!==this.minResolution&&(e?this.setAttribute(ch.MIN_RESOLUTION,e):this.removeAttribute(ch.MIN_RESOLUTION))}get maxAutoResolution(){var e;return null!=(e=this.getAttribute(ch.MAX_AUTO_RESOLUTION))?e:void 0}set maxAutoResolution(e){null==e?this.removeAttribute(ch.MAX_AUTO_RESOLUTION):this.setAttribute(ch.MAX_AUTO_RESOLUTION,e)}get renditionOrder(){var e;return null!=(e=this.getAttribute(ch.RENDITION_ORDER))?e:void 0}set renditionOrder(e){e!==this.renditionOrder&&(e?this.setAttribute(ch.RENDITION_ORDER,e):this.removeAttribute(ch.RENDITION_ORDER))}get programStartTime(){let e=this.getAttribute(ch.PROGRAM_START_TIME);if(null==e)return;let t=+e;return Number.isNaN(t)?void 0:t}set programStartTime(e){null==e?this.removeAttribute(ch.PROGRAM_START_TIME):this.setAttribute(ch.PROGRAM_START_TIME,`${e}`)}get programEndTime(){let e=this.getAttribute(ch.PROGRAM_END_TIME);if(null==e)return;let t=+e;return Number.isNaN(t)?void 0:t}set programEndTime(e){null==e?this.removeAttribute(ch.PROGRAM_END_TIME):this.setAttribute(ch.PROGRAM_END_TIME,`${e}`)}get assetStartTime(){let e=this.getAttribute(ch.ASSET_START_TIME);if(null==e)return;let t=+e;return Number.isNaN(t)?void 0:t}set assetStartTime(e){null==e?this.removeAttribute(ch.ASSET_START_TIME):this.setAttribute(ch.ASSET_START_TIME,`${e}`)}get assetEndTime(){let e=this.getAttribute(ch.ASSET_END_TIME);if(null==e)return;let t=+e;return Number.isNaN(t)?void 0:t}set assetEndTime(e){null==e?this.removeAttribute(ch.ASSET_END_TIME):this.setAttribute(ch.ASSET_END_TIME,`${e}`)}get customDomain(){var e;return null!=(e=this.getAttribute(ch.CUSTOM_DOMAIN))?e:void 0}set customDomain(e){e!==this.customDomain&&(e?this.setAttribute(ch.CUSTOM_DOMAIN,e):this.removeAttribute(ch.CUSTOM_DOMAIN))}get capRenditionToPlayerSize(){var e;return(null==(e=this._hlsConfig)?void 0:e.capLevelToPlayerSize)!=null?this._hlsConfig.capLevelToPlayerSize:ca(this,ce)}set capRenditionToPlayerSize(e){cn(this,ce,e)}get drmToken(){var e;return null!=(e=this.getAttribute(ch.DRM_TOKEN))?e:void 0}
112set drmToken(e){e!==this.drmToken&&(e?this.setAttribute(ch.DRM_TOKEN,e):this.removeAttribute(ch.DRM_TOKEN))}get playbackToken(){var e,t,i,r;if(this.hasAttribute(ch.PLAYBACK_TOKEN))return null!=(e=this.getAttribute(ch.PLAYBACK_TOKEN))?e:void 0;if(this.hasAttribute(ch.PLAYBACK_ID)){let[,e]=ho(null!=(t=this.playbackId)?t:"");return null!=(i=new URLSearchParams(e).get("token"))?i:void 0}if(this.src)return null!=(r=new URLSearchParams(this.src).get("token"))?r:void 0}set playbackToken(e){e!==this.playbackToken&&(e?this.setAttribute(ch.PLAYBACK_TOKEN,e):this.removeAttribute(ch.PLAYBACK_TOKEN))}get tokens(){let e=this.getAttribute(ch.PLAYBACK_TOKEN),t=this.getAttribute(ch.DRM_TOKEN);return{...ca(this,u1),...null!=e?{playback:e}:{},...null!=t?{drm:t}:{}}}set tokens(e){cn(this,u1,null!=e?e:{})}get ended(){return uS(this.nativeEl,this._hls)}get envKey(){var e;return null!=(e=this.getAttribute(ch.ENV_KEY))?e:void 0}set envKey(e){e!==this.envKey&&(e?this.setAttribute(ch.ENV_KEY,e):this.removeAttribute(ch.ENV_KEY))}get beaconCollectionDomain(){var e;return null!=(e=this.getAttribute(ch.BEACON_COLLECTION_DOMAIN))?e:void 0}set beaconCollectionDomain(e){e!==this.beaconCollectionDomain&&(e?this.setAttribute(ch.BEACON_COLLECTION_DOMAIN,e):this.removeAttribute(ch.BEACON_COLLECTION_DOMAIN))}get streamType(){var e;return null!=(e=this.getAttribute(ch.STREAM_TYPE))?e:uy(this.nativeEl)}set streamType(e){e!==this.streamType&&(e?this.setAttribute(ch.STREAM_TYPE,e):this.removeAttribute(ch.STREAM_TYPE))}get targetLiveWindow(){var e,t,i;return this.hasAttribute(ch.TARGET_LIVE_WINDOW)?+this.getAttribute(ch.TARGET_LIVE_WINDOW):(e=this.nativeEl,null!=(i=null==(t=uh.get(e))?void 0:t.targetLiveWindow)?i:NaN)}set targetLiveWindow(e){e!=this.targetLiveWindow&&(null==e?this.removeAttribute(ch.TARGET_LIVE_WINDOW):this.setAttribute(ch.TARGET_LIVE_WINDOW,`${+e}`))}get liveEdgeStart(){var e,t;if(this.hasAttribute(ch.LIVE_EDGE_OFFSET)){let{liveEdgeOffset:i}=this,r=null!=(e=this.nativeEl.seekable.end(0))?e:0;return Math.max(null!=(t=this.nativeEl.seekable.start(0))?t:0,r-i)}return(e=>{var t;let i=null==(t=uh.get(e))?void 0:t.liveEdgeStartOffset;if("number"!=typeof i)return NaN;let r=ub(e);return r.length?r.end(r.length-1)-i:NaN})(this.nativeEl)}get liveEdgeOffset(){if(this.hasAttribute(ch.LIVE_EDGE_OFFSET))return+this.getAttribute(ch.LIVE_EDGE_OFFSET)}set liveEdgeOffset(e){e!=this.liveEdgeOffset&&(null==e?this.removeAttribute(ch.LIVE_EDGE_OFFSET):this.setAttribute(ch.LIVE_EDGE_OFFSET,`${+e}`))}get seekable(){return ub(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()."),hw(this.nativeEl,e)}get activeCuePoint(){return hC(this.nativeEl)}get cuePoints(){return function(e,t={label:hL}){let i=hk(e,t.label,"metadata");return null!=i&&i.cues?Array.from(i.cues,e=>hD(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()."),hN(this.nativeEl,e)}get activeChapter(){return hU(this.nativeEl)}get chapters(){return function(e,t={label:hx}){var i;let r=hk(e,t.label,"chapters");return null!=(i=null==r?void 0:r.cues)&&i.length?Array.from(r.cues,e=>hO(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(){var e,t;return e=this.nativeEl,(t=this._hls)&&t.playingDate?t.playingDate:new Date("function"==typeof e.getStartDate?e.getStartDate().getTime()+1e3*e.currentTime:NaN)}get preferPlayback(){let e=this.getAttribute(ch.PREFER_PLAYBACK);if("mse"===e||e===ht)return e}set preferPlayback(e){e!==this.preferPlayback&&("mse"===e||e===ht?this.setAttribute(ch.PREFER_PLAYBACK,e):this.removeAttribute(ch.PREFER_PLAYBACK))}get metadata(){return{...this.getAttributeNames().filter(e=>e.startsWith("metadata-")&&![ch.METADATA_URL].includes(e)).reduce((e,t)=>
112{let i=this.getAttribute(t);return null!=i&&(e[t.replace(/^metadata-/,"").replace(/-/g,"_")]=i),e},{}),...ca(this,u0)}}set metadata(e){cn(this,u0,null!=e?e:{}),this.mux&&this.mux.emit("hb",ca(this,u0))}get _hlsConfig(){return ca(this,u2)}set _hlsConfig(e){cn(this,u2,e)}get logo(){var e;return null!=(e=this.getAttribute(ch.LOGO))?e:ca(this,u8)}set logo(e){e?this.setAttribute(ch.LOGO,e):this.removeAttribute(ch.LOGO)}load(){uk(this,this.nativeEl,ca(this,u9,u7))}unload(){uL(this.nativeEl,ca(this,u9,u7),this)}attributeChangedCallback(e,t,i){var r,a;switch(uX.observedAttributes.includes(e)&&!["src","autoplay","preload"].includes(e)&&super.attributeChangedCallback(e,t,i),e){case ch.PLAYER_SOFTWARE_NAME:this.playerSoftwareName=null!=i?i:void 0;break;case ch.PLAYER_SOFTWARE_VERSION:this.playerSoftwareVersion=null!=i?i:void 0;break;case"src":{let e=!!t,r=!!i;!e&&r?cl(this,u9,ct).call(this):e&&!r?this.unload():e&&r&&(this.unload(),cl(this,u9,ct).call(this));break}case"autoplay":if(i===t)break;null==(r=ca(this,u9,u7))||r.setAutoplay(this.autoplay);break;case"preload":if(i===t)break;null==(a=ca(this,u9,u7))||a.setPreload(i);break;case ch.PLAYBACK_ID:case ch.CUSTOM_DOMAIN:case ch.MAX_RESOLUTION:case ch.MIN_RESOLUTION:case ch.RENDITION_ORDER:case ch.PROGRAM_START_TIME:case ch.PROGRAM_END_TIME:case ch.ASSET_START_TIME:case ch.ASSET_END_TIME:case ch.PLAYBACK_TOKEN:this.hasAttribute(ch.PLAYBACK_ID)&&(this.src=up(this));break;case ch.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 ch.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 ch.STREAM_TYPE:(null==i||i!==t)&&this.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}));break;case ch.TARGET_LIVE_WINDOW:(null==i||i!==t)&&this.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0,detail:this.targetLiveWindow}));break;case ch.LOGO:(null==i||i!==t)&&this.updateLogo();break;case ch.DISABLE_TRACKING:if(null==i||i!==t){let e=this.currentTime,t=this.paused;this.unload(),cl(this,u9,ct).call(this).then(()=>{this.currentTime=e,t||this.play()})}break;case ch.DISABLE_COOKIES:(null==i||i!==t)&&((e,t,i)=>{if(!t)return;let r=!!e.disableCookies,a=uh.get(t);!a||a.muxDataDisableCookies===r||(t&&(t.mux&&(t.mux.deleted||t.mux.destroy(),delete t.mux),uR.has(t)||uR.set(t,Promise.resolve().then(()=>{var r,a;uR.delete(t);let s=uh.get(t);s&&(!t.mux||t.mux.deleted)&&uF(e,t,null==(a=null!=(r=s.coreReference)?r:i)?void 0:a.engine)}))),r&&Promise.resolve().then(()=>{let t,i;e.disableCookies&&(t=new Date(0).toUTCString(),i=new Set(["muxData"]),document.cookie.split(";").forEach(e=>{let t=e.split("=")[0].trim();t.startsWith("muxData")&&i.add(t)}),i.forEach(e=>{document.cookie=`${e}=;expires=${t};path=/`}))}))})(this,this.nativeEl,ca(this,u9,u7));break;case ch.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"]');e&&(e.innerHTML=this.constructor.getLogoHTML(ca(this,u8)||this.logo))}connectedCallback(){var e,t;null==(e=super.connectedCallback)||e.call(this),null==(t=this.nativeEl)||t.addEventListener("muxmetadata",ca(this,u6)),this.nativeEl&&this.src&&!ca(this,u9,u7)&&cl(this,u9,ct).call(this)}disconnectedCallback(){var e,t;null==(e=this.nativeEl)||e.removeEventListener("muxmetadata",ca(this,u6)),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}))}};uZ=new WeakMap,uJ=new WeakMap,u0=new WeakMap,u1=new WeakMap,u2=new WeakMap,u3=new WeakMap,u4=new WeakMap,u5=new WeakMap,u8=new WeakMap,u6=new WeakMap,u9=new WeakSet,u7=function(){var e,t;return e=this.nativeEl,null==(t=uh.get(e))?void 0:t.coreReference},ce=new WeakMap,ct=async function(){ca(this,uZ)||(await cn(this,uZ,Promise.resolve()),cn(this,uZ,null),this.load())};let cf=new WeakMap;
112class cp extends Error{}class cg extends Error{}let cv=["application/x-mpegURL","application/vnd.apple.mpegurl","audio/mpegurl"];function cE(){return globalThis.cast?.framework?.CastContext.getInstance()}function cy(){return cE()?.getCurrentSession()}function cb(){return cy()?.getSessionObj().media[0]}function cT(e){return cE().setOptions({...cA(),...e})}function cA(){return{receiverApplicationId:"CC1AD845",autoJoinPolicy:"origin_scoped",androidReceiverCompatible:!1,language:"en-US",resumeSavedSession:!0}}function c_(e){if(!e)return;let t=e.match(/\.([a-zA-Z0-9]+)(?:\?.*)?$/);return t?t[1]:null}function cS(e){let t=e.split("\n").find(e=>!e.trim().startsWith("#")&&""!==e.trim());return t?.trim()}async function ck(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 cv.some(e=>t===e)}catch(e){return console.error("Error while trying to get the Content-Type of the manifest",e),!1}}async function cR(e){if(!e||e.startsWith("blob:"))return{videoFormat:void 0,audioFormat:void 0};try{let t=await (await fetch(e)).text(),i=t,r=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}(t);if(r.length>0){let t=new URL(r[0],e).toString();i=await (await fetch(t)).text()}let a=cS(i),s=c_(a),n=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]}}}(t),l=s;if(n)try{let t=new URL(n,e).toString(),i=await (await fetch(t)).text(),r=cS(i);l=c_(r)??s}catch(e){console.error("Error while trying to parse the audio rendition playlist",e)}return{videoFormat:s,audioFormat:l}}catch(e){return console.error("Error while trying to parse the manifest playlist",e),{videoFormat:void 0,audioFormat:void 0}}}let cL=new(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),cI=new WeakSet;c8=()=>{globalThis.chrome?.cast?.isAvailable?o||(o=cast.framework,cE().addEventListener(o.CastContextEventType.CAST_STATE_CHANGED,e=>{cL.forEach(t=>cf.get(t).onCastStateChanged?.(e))}),cE().addEventListener(o.CastContextEventType.SESSION_STATE_CHANGED,e=>{cL.forEach(t=>cf.get(t).onSessionStateChanged?.(e))}),cL.forEach(e=>cf.get(e).init?.())):console.debug("chrome.cast.isAvailable",globalThis.chrome?.cast?.isAvailable)},globalThis.chrome?.cast?.isAvailable?globalThis.cast?.framework?c8():customElements.whenDefined("google-cast-button").then(c8):globalThis.__onGCastApiAvailable=()=>{customElements.whenDefined("google-cast-button").then(c8)};let cw=0;class cD extends EventTarget{#f;#r;#p;#g;#v="disconnected";#E=!1;#y=new Set;#b=new WeakMap;#T=()=>this.#A();constructor(e){super(),this.#f=e,cL.add(this),cf.set(this,{init:()=>this.#i(),onCastStateChanged:()=>this.#_(),onSessionStateChanged:()=>this.#S(),getCastPlayer:()=>this.#k}),this.#i()}destroy(){this.#f?.textTracks?.removeEventListener("change",this.#T),this.#g&&this.#p?.controller&&Object.entries(this.#g).forEach(([e,t])=>{this.#p.controller.removeEventListener(e,t)}),this.#f&&cI.delete(this.#f),this.#r=!1}get #k(){if(cI.has(this.#f))return this.#p}get state(){return this.#v}async watchAvailability(e){if(this.#f.disableRemotePlayback)throw new cp("disableRemotePlayback attribute is present.");return this.#b.set(e,++cw),this.#y.add(e),queueMicrotask(()=>e(this.#R())),cw}async cancelWatchAvailability(e){if(this.#f.disableRemotePlayback)throw new cp("disableRemotePlayback attribute is present.");e?this.#y.delete(e):this.#y.clear()}async prompt(){if(this.#f.disableRemotePlayback)throw new cp("disableRemotePlayback attribute is present.");if(!globalThis.chrome?.cast?.isAvailable)throw new cg("The RemotePlayback API is disabled on this platform.");let e=cI.has(this.#f);cI.add(this.#f),cT(this.#f.castOptions),Object.entries(this.#g).forEach(([e,t])=>{this.#p.controller.addEventListener(e,t)});try{await cE().requestSession()}catch(t){if(e||cI.delete(this.#f),"cancel"===t)return;throw Error(t)}cf.get(this.#f)?.loadOnPrompt?.()}#L(){cI.has(this.#f)&&(Object.entries(this.#g).forEach(([e,t])=>{this.#p.controller.removeEventListener(e,t)}),cI.delete(this.#f),this.#f.muted=this.#p.isMuted,this.#f.currentTime=this.#p.savedPlayerState.currentTime,!1===this.#p.savedPlayerState.isPau
112sed&&this.#f.play())}#R(){let e=cE()?.getCastState();return e&&"NO_DEVICES_AVAILABLE"!==e}#_(){let e=cE().getCastState();if(cI.has(this.#f)&&"CONNECTING"===e&&(this.#v="connecting",this.dispatchEvent(new Event("connecting"))),!this.#E&&e?.includes("CONNECT"))for(let e of(this.#E=!0,this.#y))e(!0);else if(this.#E&&(!e||"NO_DEVICES_AVAILABLE"===e))for(let e of(this.#E=!1,this.#y))e(!1)}async #S(){let{SESSION_RESUMED:e}=o.SessionState;if(cE().getSessionState()===e&&this.#f.castSrc===cb()?.media.contentId){cI.add(this.#f),Object.entries(this.#g).forEach(([e,t])=>{this.#p.controller.addEventListener(e,t)});try{var t;await (t=new chrome.cast.media.GetStatusRequest,new Promise((e,i)=>{cb().getStatus(t,e,i)}))}catch(e){console.error(e)}this.#g[o.RemotePlayerEventType.IS_PAUSED_CHANGED](),this.#g[o.RemotePlayerEventType.PLAYER_STATE_CHANGED]()}}#i(){o&&!this.#r&&(this.#r=!0,cT(this.#f.castOptions),this.#f.textTracks.addEventListener("change",this.#T),this.#_(),this.#p=new o.RemotePlayer,new o.RemotePlayerController(this.#p),this.#g={[o.RemotePlayerEventType.IS_CONNECTED_CHANGED]:({value:e})=>{!0===e?(this.#v="connected",this.dispatchEvent(new Event("connect"))):(this.#L(),this.#v="disconnected",this.dispatchEvent(new Event("disconnect")))},[o.RemotePlayerEventType.DURATION_CHANGED]:()=>{this.#f.dispatchEvent(new Event("durationchange"))},[o.RemotePlayerEventType.VOLUME_LEVEL_CHANGED]:()=>{this.#f.dispatchEvent(new Event("volumechange"))},[o.RemotePlayerEventType.IS_MUTED_CHANGED]:()=>{this.#f.dispatchEvent(new Event("volumechange"))},[o.RemotePlayerEventType.CURRENT_TIME_CHANGED]:()=>{this.#k?.isMediaLoaded&&this.#f.dispatchEvent(new Event("timeupdate"))},[o.RemotePlayerEventType.VIDEO_INFO_CHANGED]:()=>{this.#f.dispatchEvent(new Event("resize"))},[o.RemotePlayerEventType.IS_PAUSED_CHANGED]:()=>{this.#f.dispatchEvent(new Event(this.paused?"pause":"play"))},[o.RemotePlayerEventType.PLAYER_STATE_CHANGED]:()=>{this.#k?.playerState!==chrome.cast.media.PlayerState.PAUSED&&this.#f.dispatchEvent(new Event({[chrome.cast.media.PlayerState.PLAYING]:"playing",[chrome.cast.media.PlayerState.BUFFERING]:"waiting",[chrome.cast.media.PlayerState.IDLE]:"emptied"}[this.#k?.playerState]))},[o.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED]:async()=>{this.#k?.isMediaLoaded&&(await Promise.resolve(),this.#I())}})}#I(){this.#A()}async #A(){let e;if(!this.#k)return;let t=(this.#p.mediaInfo?.tracks??[]).filter(({type:e})=>e===chrome.cast.media.TrackType.TEXT),i=[...this.#f.textTracks].filter(({kind:e})=>"subtitles"===e||"captions"===e),r=t.map(({language:e,name:t,trackId:r})=>{let{mode:a}=i.find(i=>i.language===e&&i.label===t)??{};return!!a&&{mode:a,trackId:r}}).filter(Boolean),a=r.filter(({mode:e})=>"showing"!==e).map(({trackId:e})=>e),s=r.find(({mode:e})=>"showing"===e),n=cy()?.getSessionObj().media[0]?.activeTrackIds??[],l=n;if(n.length&&(l=l.filter(e=>!a.includes(e))),s?.trackId&&(l=[...l,s.trackId]),e=l=[...new Set(l)],!(n.length===e.length&&n.every(t=>e.includes(t))))try{let e=new chrome.cast.media.EditTracksInfoRequest(l);await new Promise((t,i)=>{cb().editTracksInfo(e,t,i)})}catch(e){console.error(e)}}}let cC=e=>class extends e{static observedAttributes=[...e.observedAttributes??[],"cast-src","cast-content-type","cast-stream-type","cast-receiver"];#w={paused:!1};#D=cA();#C;#M;get remote(){if(this.#M)return this.#M;if(globalThis.chrome){if(!this.isConnected)return;return this.disableRemotePlayback||function(){let e="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1";if(globalThis.chrome?.cast||document.querySelector(`script[src="${e}"]`))return;let t=document.createElement("script");t.src=e,document.head.append(t)}(),cf.set(this,{loadOnPrompt:()=>this.#x()}),this.#M=new cD(this)}return super.remote}get #k(){return cf.get(this.#M)?.getCastPlayer?.()}disconnectedCallback(){this.#M?.destroy(),this.#M=null,cf.delete(this),super.disconnectedCallback?.()}attributeChangedCallback(e,t,i){if(super.attributeChangedCallback(e,t,i),"cast-receiver"===e&&i){this.#D.receiverApplicationId=i;return}if(this.#k)switch(e){case"cast-stream-type":case"cast-src":this.load()}}async #x(){this.#w.paused=super.paused,super.pause(),this.muted=super.muted;try{await this.load()}catch(e){console.error(e)}}async load(){if(!this.#k)return super.load();let e=new chrome.cast.media.MediaInfo(this.castSrc,this.castContentType);e.customData=this.castCustomData;let t=[...this.querySelectorAll("track")].filter(({kind:e,src:t})=>t&&("subtitles"===e||"captions"===e)),i=[],r=0;if(t.length&&(e.tracks=t.map(e=>{let t=++r;0===i.length&&"showing"===e.track.mode&&i.push(t);let a=new chrome.cast.media.Track(t,chrome.cast.media.TrackType.TEXT);return a.trackContentId=e.src,a.trackContentType="text/vtt",a.subtype="captions"===e.kind?chrome.cast.media.TextTrackType.CAPTIONS:chrome.cast.media.TextTrackType.SUBTITLES,a.name=e.label,a.language=e.srclang,a})),"live"===this.castStreamType?e.streamType=chrome.cast.media.StreamType.LIVE:e.streamType=chrome.cast.media.StreamType.BUFFERED,e.metadata=new chrome.cast.media.GenericMediaMetadata,e.metadata.title=this.title,e.metadata.images=[{url:this.poster}],await ck(this.castSrc)){e.contentType||(e.contentType="application/x-mpegURL");let{videoFormat:t,audioFormat:i}=await cR(this.castSrc);t?.includes("m4s")||t?.includes("mp4")||t?.includes("m4a")?(e.hlsSegmentFormat=chrome.cast.media.HlsSegmentFormat.FMP4,e.hlsVideoSegmentFormat=chrome.cast.media.HlsVideoSegmentFormat.FMP4):i?.includes("aac")?(e.hlsSegmentFormat=chrome.cast.media.HlsSegmentFormat.AAC,e.hlsVideoSegmentFormat=chrome.cast.media.HlsVideoSegmentFormat.MPEG2_TS):(t?.includes("ts")||i?.includes("ts"))&&(e.hlsSegmentFormat=chrome.cast.media.HlsSegmentFormat.TS,e.hlsVideoSegmentFormat=chrome.cast.media.HlsVideoSegmentFormat.MPEG2_TS)}let a=new chrome.cast.media.LoadRequest(e);a.currentTime=super.currentTime??0,a.autoplay=!this.#w.paused,a.activeTrackIds=i,await cy()?.loadMedia(a),this.dispatchEvent(new Event("volumechange"))}play(){if(this.#k){this.#k.isPaused&&this.#k.controller?.playOrPause();return}return super.play()}pause(){if(this.#k){this.#k.isPaused||this.#k.controller?.playOrPause();return}super.pause()}get castOptions(){return this.#D}get castReceiver(){return this.getAttribute("cast-receiver")??void 0}set castReceiver(e){this.castReceiver!=e&&this.setAttribute("cast-receiver",`${e}`)}get castSrc(){let e=this.currentSrc,t=e?.startsWith("blob:")?void 0:e;return this.getAttribute("cast-src")??this.querySelector("source")?.src??t??this.getAttribute("src")??void 0}set castSrc(e){this.castSrc!=e&&this.setAttribute("cast-src",`${e}`)}get castContentType(){return this.getAttribute("cast-content-type")??void 0}set castContentType(e){this.setAttribute("cast-content-type",`${e}`)}get castStreamType(){return this.getAttribute("cast-stream-type")??this.streamType??void 0}set castStreamType(e){this.setAttribute("cast-stream-type",`${e}`)}get castCustomData(){return this.#C}set castCustomData(e){let t=typeof e;["object","undefined"].includes(t)?this.#C=e:console.error(`castCustomData must be nullish or an object but value was of type ${t}`)}get readyState(){if(this.#k)switch(this.#k.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 this.#k?this.#k.isPaused:super.paused}get muted(){return this.#k?this.#k?.isMuted:super.muted}set muted(e){if(this.#k){(e&&!this.#k.isMuted||!e&&this.#k.isMuted)&&this.#k.controller?.muteOr
112Unmute();return}super.muted=e}get volume(){return this.#k?this.#k?.volumeLevel??1:super.volume}set volume(e){if(this.#k){this.#k.volumeLevel=+e,this.#k.controller?.setVolumeLevel();return}super.volume=e}get duration(){return this.#k&&this.#k?.isMediaLoaded?this.#k?.duration??NaN:super.duration}get currentTime(){return this.#k&&this.#k?.isMediaLoaded?this.#k?.currentTime??0:super.currentTime}set currentTime(e){if(this.#k){this.#k.currentTime=e,this.#k.controller?.seek();return}super.currentTime=e}};class cM extends Event{track;constructor(e,t){super(e),this.track=t.track}}let cx=new WeakMap;function cP(e){var t,i;let r;return cx.get(e)??(t=e,i={},(r=cx.get(t))||cx.set(t,r={}),Object.assign(r,i))}function cO(e,t){let i=e.videoTracks;cP(t).media=new WeakRef(e),cP(t).renditionSet||(cP(t).renditionSet=new Set);let r=cP(i).trackSet;r.add(t);let a=r.size-1;a in cU.prototype||Object.defineProperty(cU.prototype,a,{get(){return[...cP(this).trackSet][a]}}),queueMicrotask(()=>{i.dispatchEvent(new cM("addtrack",{track:t}))})}function cN(e){let t=cP(e).media?.deref()?.videoTracks;t&&(cP(t).trackSet.delete(e),queueMicrotask(()=>{t.dispatchEvent(new cM("removetrack",{track:e}))}))}
112class cU extends EventTarget{#P;#O;#N;constructor(){super(),cP(this).trackSet=new Set}get #U(){return cP(this).trackSet}[Symbol.iterator](){return this.#U.values()}get length(){return this.#U.size}getTrackById(e){return[...this.#U].find(t=>t.id===e)??null}get selectedIndex(){return[...this.#U].findIndex(e=>e.selected)}get onaddtrack(){return this.#P}set onaddtrack(e){this.#P&&(this.removeEventListener("addtrack",this.#P),this.#P=void 0),"function"==typeof e&&(this.#P=e,this.addEventListener("addtrack",e))}get onremovetrack(){return this.#O}set onremovetrack(e){this.#O&&(this.removeEventListener("removetrack",this.#O),this.#O=void 0),"function"==typeof e&&(this.#O=e,this.addEventListener("removetrack",e))}get onchange(){return this.#N}set onchange(e){this.#N&&(this.removeEventListener("change",this.#N),this.#N=void 0),"function"==typeof e&&(this.#N=e,this.addEventListener("change",e))}}class cF extends Event{rendition;constructor(e,t){super(e),this.rendition=t.rendition}}function cB(e){let t=cP(e).media?.deref();return t?[...t.videoTracks].filter(e=>e.selected).flatMap(e=>[...cP(e).renditionSet]):[]}class c$ extends EventTarget{#F;#B;#N;[Symbol.iterator](){return cB(this).values()}get length(){return cB(this).length}getRenditionById(e){return cB(this).find(t=>`${t.id}`==`${e}`)??null}get selectedIndex(){return cB(this).findIndex(e=>e.selected)}set selectedIndex(e){for(let[t,i]of cB(this).entries())i.selected=t===e}get onaddrendition(){return this.#F}set onaddrendition(e){this.#F&&(this.removeEventListener("addrendition",this.#F),this.#F=void 0),"function"==typeof e&&(this.#F=e,this.addEventListener("addrendition",e))}get onremoverendition(){return this.#B}set onremoverendition(e){this.#B&&(this.removeEventListener("removerendition",this.#B),this.#B=void 0),"function"==typeof e&&(this.#B=e,this.addEventListener("removerendition",e))}get onchange(){return this.#N}set onchange(e){this.#N&&(this.removeEventListener("change",this.#N),this.#N=void 0),"function"==typeof e&&(this.#N=e,this.addEventListener("change",e))}}class cH{src;id;width;height;bitrate;frameRate;codec;#$=!1;get selected(){return this.#$}set selected(e){if(this.#$!==e){var t;let i;this.#$=e,t=this,(i=cP(t).media?.deref()?.videoRenditions)&&!cP(i).changeRequested&&(cP(i).changeRequested=!0,queueMicrotask(()=>{delete cP(i).changeRequested,cP(t).track.selected&&i.dispatchEvent(new Event("change"))}))}}}class cG{id;kind;label="";language="";sourceBuffer;#$=!1;addRendition(e,t,i,r,a,s){var n;let l,o,d,h=new cH;return h.src=e,h.width=t,h.height=i,h.frameRate=s,h.bitrate=a,h.codec=r,n=this,l=cP(n).media?.deref()?.videoRenditions,cP(h).media=cP(n).media,cP(h).track=n,(o=cP(n).renditionSet).add(h),(d=o.size-1)in c$.prototype||Object.defineProperty(c$.prototype,d,{get(){return cB(this)[d]}}),queueMicrotask(()=>{l&&n.selected&&l.dispatchEvent(new cF("addrendition",{rendition:h}))}),h}removeRendition(e){let t,i;t=cP(e).media?.deref()?.videoRenditions,i=cP(e).track,cP(i).renditionSet.delete(e),queueMicrotask(()=>{let i=cP(e).track;t&&i.selected&&t.dispatchEvent(new cF("removerendition",{rendition:e}))})}get selected(){return this.#$}set selected(e){this.#$===e||(this.#$=e,!0===e&&function(e){let t=cP(e).media?.deref()?.videoTracks??[],i=!1;for(let r of t)r!==e&&(r.selected=!1,i=!0);if(i){if(cP(t).changeRequested)return;cP(t).changeRequested=!0,queueMicrotask(()=>{delete cP(t).changeRequested,t.dispatchEvent(new Event("change"))})}}(this))}}function cW(e){let t=cP(e).media?.deref();return t?[...t.audioTracks].filter(e=>e.enabled).flatMap(e=>[...cP(e).renditionSet]):[]}
112class cK extends EventTarget{#F;#B;#N;[Symbol.iterator](){return cW(this).values()}get length(){return cW(this).length}getRenditionById(e){return cW(this).find(t=>`${t.id}`==`${e}`)??null}get selectedIndex(){return cW(this).findIndex(e=>e.selected)}set selectedIndex(e){for(let[t,i]of cW(this).entries())i.selected=t===e}get onaddrendition(){return this.#F}set onaddrendition(e){this.#F&&(this.removeEventListener("addrendition",this.#F),this.#F=void 0),"function"==typeof e&&(this.#F=e,this.addEventListener("addrendition",e))}get onremoverendition(){return this.#B}set onremoverendition(e){this.#B&&(this.removeEventListener("removerendition",this.#B),this.#B=void 0),"function"==typeof e&&(this.#B=e,this.addEventListener("removerendition",e))}get onchange(){return this.#N}set onchange(e){this.#N&&(this.removeEventListener("change",this.#N),this.#N=void 0),"function"==typeof e&&(this.#N=e,this.addEventListener("change",e))}}class cV{src;id;bitrate;codec;#$=!1;get selected(){return this.#$}set selected(e){if(this.#$!==e){var t;let i;this.#$=e,t=this,(i=cP(t).media?.deref()?.audioRenditions)&&!cP(i).changeRequested&&(cP(i).changeRequested=!0,queueMicrotask(()=>{delete cP(i).changeRequested,cP(t).track.enabled&&i.dispatchEvent(new Event("change"))}))}}}function cq(e,t){let i=e.audioTracks;cP(t).media=new WeakRef(e),cP(t).renditionSet||(cP(t).renditionSet=new Set);let r=cP(i).trackSet;r.add(t);let a=r.size-1;a in cY.prototype||Object.defineProperty(cY.prototype,a,{get(){return[...cP(this).trackSet][a]}}),queueMicrotask(()=>{i.dispatchEvent(new cM("addtrack",{track:t}))})}function cj(e){let t=cP(e).media?.deref()?.audioTracks;t&&(cP(t).trackSet.delete(e),queueMicrotask(()=>{t.dispatchEvent(new cM("removetrack",{track:e}))}))}class cY extends EventTarget{#P;#O;#N;constructor(){super(),cP(this).trackSet=new Set}get #U(){return cP(this).trackSet}[Symbol.iterator](){return this.#U.values()}get length(){return this.#U.size}getTrackById(e){return[...this.#U].find(t=>t.id===e)??null}get onaddtrack(){return this.#P}set onaddtrack(e){this.#P&&(this.removeEventListener("addtrack",this.#P),this.#P=void 0),"function"==typeof e&&(this.#P=e,this.addEventListener("addtrack",e))}get onremovetrack(){return this.#O}set onremovetrack(e){this.#O&&(this.removeEventListener("removetrack",this.#O),this.#O=void 0),"function"==typeof e&&(this.#O=e,this.addEventListener("removetrack",e))}get onchange(){return this.#N}set onchange(e){this.#N&&(this.removeEventListener("change",this.#N),this.#N=void 0),"function"==typeof e&&(this.#N=e,this.addEventListener("change",e))}}class cz{id;kind;label="";language="";sourceBuffer;#H=!1;addRendition(e,t,i){var r;let a,s,n,l=new cV;return l.src=e,l.codec=t,l.bitrate=i,r=this,a=cP(r).media?.deref()?.audioRenditions,cP(l).media=cP(r).media,cP(l).track=r,(s=cP(r).renditionSet).add(l),(n=s.size-1)in cK.prototype||Object.defineProperty(cK.prototype,n,{get(){return cW(this)[n]}}),queueMicrotask(()=>{a&&r.enabled&&a.dispatchEvent(new cF("addrendition",{rendition:l}))}),l}removeRendition(e){let t,i;t=cP(e).media?.deref()?.audioRenditions,i=cP(e).track,cP(i).renditionSet.delete(e),queueMicrotask(()=>{let i=cP(e).track;t&&i.enabled&&t.dispatchEvent(new cF("removerendition",{rendition:e}))})}get enabled(){return this.#H}set enabled(e){if(this.#H!==e){let t;this.#H=e,(t=cP(this).media?.deref()?.audioTracks)&&!cP(t).changeRequested&&(cP(t).changeRequested=!0,queueMicrotask(()=>{delete cP(t).changeRequested,t.dispatchEvent(new Event("change"))}))}}}let cQ=cJ(globalThis.HTMLMediaElement,"video"),cX=cJ(globalThis.HTMLMediaElement,"audio");function cZ(e){if(!e?.prototype)return e;let t=cJ(e,"video");(!t||`${t}`.includes("[native code]"))&&Object.defineProperty(e.prototype,"videoTracks",{get(){var e=this;let t=cP(e).videoTracks;if(!t&&(t=new cU,cP(e).videoTracks=t,cQ)){let i=cQ.call(e.nativeEl??e);for(let t of i)cO(e,t);i.addEventListener("change",()=>{t.dispatchEvent(new Event("change"))}),i.addEventListener("addtrack",r=>{if([...t].some(e=>e instanceof cG)){for(let e of i)cN(e);return}cO(e,r.track)}),i.addEventListener("removetrack",e=>{cN(e.track)})}return t}});let i=cJ(e,"audio");(!i||`${i}`.includes("[native code]"))&&Object.defineProperty(e.prototype,"audioTracks",{get(){var e=this;let t=cP(e).audioTracks;
112if(!t&&(t=new cY,cP(e).audioTracks=t,cX)){let i=cX.call(e.nativeEl??e);for(let t of i)cq(e,t);i.addEventListener("change",()=>{t.dispatchEvent(new Event("change"))}),i.addEventListener("addtrack",r=>{if([...t].some(e=>e instanceof cz)){for(let e of i)cj(e);return}cq(e,r.track)}),i.addEventListener("removetrack",e=>{cj(e.track)})}return t}}),"addVideoTrack"in e.prototype||(e.prototype.addVideoTrack=function(e,t="",i=""){let r=new cG;return r.kind=e,r.label=t,r.language=i,cO(this,r),r}),"removeVideoTrack"in e.prototype||(e.prototype.removeVideoTrack=cN),"addAudioTrack"in e.prototype||(e.prototype.addAudioTrack=function(e,t="",i=""){let r=new cz;return r.kind=e,r.label=t,r.language=i,cq(this,r),r}),"removeAudioTrack"in e.prototype||(e.prototype.removeAudioTrack=cj),"videoRenditions"in e.prototype||Object.defineProperty(e.prototype,"videoRenditions",{get(){return r(this)}});let r=e=>{let t=cP(e).videoRenditions;return t||(cP(t=new c$).media=new WeakRef(e),cP(e).videoRenditions=t),t};"audioRenditions"in e.prototype||Object.defineProperty(e.prototype,"audioRenditions",{get(){return a(this)}});let a=e=>{let t=cP(e).audioRenditions;return t||(cP(t=new cK).media=new WeakRef(e),cP(e).audioRenditions=t),t};return e}function cJ(e,t){if(e?.prototype)return Object.getOwnPropertyDescriptor(e.prototype,`${t}Tracks`)?.get}var c0=e=>{throw TypeError(e)},c1=(e,t,i)=>t.has(e)||c0("Cannot "+i),c2=(e,t,i)=>(c1(e,t,"read from private field"),i?i.call(e):t.get(e)),c3=(e,t,i)=>t.has(e)?c0("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,i),c4=(e,t,i,r)=>(c1(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i),c5=class{addEventListener(){}removeEventListener(){}dispatchEvent(e){return!0}};"u"<typeof DocumentFragment&&(globalThis.DocumentFragment=class extends c5{});var c8,c6,c9=class extends c5{},c7=class{constructor(e,t={}){c3(this,c6),c4(this,c6,null==t?void 0:t.detail)}get detail(){return c2(this,c6)}initCustomEvent(){}};c6=new WeakMap;var me={document:{createElement:function(e,t){return new c9}},DocumentFragment,customElements:{get(e){},define(e,t,i){},getName:e=>null,upgrade(e){},whenDefined:e=>Promise.resolve(c9)},CustomEvent:c7,EventTarget:c5,HTMLElement:c9,HTMLVideoElement:class extends c5{}},mt="u"<typeof window||void 0===globalThis.customElements,mi=mt?me:globalThis;mt&&me.document;var mr,ma=class extends cC(cZ(cm)){constructor(){super(...arguments),c3(this,mr)}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=c2(this,mr))?e:this.muxCastCustomData}set castCustomData(e){c4(this,mr,e)}};mr=new WeakMap,mi.customElements.get("mux-video")||(mi.customElements.define("mux-video",ma),mi.MuxVideoElement=ma);let ms={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:"mediash
112owsubtitlesrequest",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"},mn={MEDIA_CHROME_ATTRIBUTES:"mediachromeattributes",MEDIA_CONTROLLER:"mediacontroller"},ml={MEDIA_AIRPLAY_UNAVAILABLE:"mediaAirplayUnavailable",MEDIA_AUDIO_TRACK_ENABLED:"mediaAudioTrackEnabled",MEDIA_AUDIO_TRACK_LIST:"mediaAudioTrackList",MEDIA_AUDIO_TRACK_UNAVAILABLE:"mediaAudioTrackUnavailable",MEDIA_BUFFERED:"mediaBuffered",MEDIA_CAST_UNAVAILABLE:"mediaCastUnavailable",MEDIA_CHAPTERS_CUES:"mediaChaptersCues",MEDIA_CURRENT_TIME:"mediaCurrentTime",MEDIA_DURATION:"mediaDuration",MEDIA_ENDED:"mediaEnded",MEDIA_ERROR:"mediaError",MEDIA_ERROR_CODE:"mediaErrorCode",MEDIA_ERROR_MESSAGE:"mediaErrorMessage",MEDIA_FULLSCREEN_UNAVAILABLE:"mediaFullscreenUnavailable",MEDIA_HAS_P
112LAYED:"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"},mo=Object.entries(ml),md=mo.reduce((e,[t,i])=>(e[t]=i.toLowerCase(),e),{}),mh=mo.reduce((e,[t,i])=>(e[t]=i.toLowerCase(),e),{USER_INACTIVE_CHANGE:"userinactivechange",BREAKPOINTS_CHANGE:"breakpointchange",BREAKPOINTS_COMPUTED:"breakpointscomputed"}),mu=Object.entries(mh).reduce((e,[t,i])=>{let r=md[t];return r&&(e[i]=r),e},{userinactivechange:"userinactive"}),mc=Object.entries(md).reduce((e,[t,i])=>{let r=mh[t];return r&&(e[i]=r),e},{userinactive:"userinactivechange"}),mm={SUBTITLES:"subtitles",CAPTIONS:"captions",DESCRIPTIONS:"descriptions",CHAPTERS:"chapters",METADATA:"metadata"},mf={DISABLED:"disabled",HIDDEN:"hidden",SHOWING:"showing"},mp={MOUSE:"mouse",PEN:"pen",TOUCH:"touch"},mg={UNAVAILABLE:"unavailable",UNSUPPORTED:"unsupported"},mv={LIVE:"live",ON_DEMAND:"on-demand",UNKNOWN:"unknown"},mE={INLINE:"inline",FULLSCREEN:"fullscreen",PICTURE_IN_PICTURE:"picture-in-picture"};function my(e){if(e){let{id:t,width:i,height:r}=e;return[t,i,r].filter(e=>null!=e).join(":")}}function mb(e){if(e){let[t,i,r]=e.split(":");return{id:t,width:+i,height:+r}}}function mT(e){if(e){let{id:t,kind:i,language:r,label:a}=e;return[t,i,r,a].filter(e=>null!=e).join(":")}}function mA(e){if(e){let[t,i,r,a]=e.split(":");return{id:t,kind:i,language:r,label:a}}}function m_(e){return"number"==typeof e&&!Number.isNaN(e)&&Number.isFinite(e)}function mS(e){return"string"==typeof e&&!isNaN(e)&&!isNaN(parseFloat(e))}e.s(["AttributeToStateChangeEventMap",0,mc,"AvailabilityStates",0,mg,"MediaStateChangeEvents",0,mh,"MediaStateReceiverAttributes",0,mn,"MediaUIAttributes",0,md,"MediaUIEvents",0,ms,"MediaUIProps",0,ml,"PointerTypes",0,mp,"ReadyStates",0,{HAVE_NOTHING:0,HAVE_METADATA:1,HAVE_CURRENT_DATA:2,HAVE_FUTURE_DATA:3,HAVE_ENOUGH_DATA:4},"StateChangeEventToAttributeMap",0,mu,"StreamTypes",0,mv,"TextTrackKinds",0,mm,"TextTrackModes",0,mf,"VolumeLevels",0,{HIGH:"high",MEDIUM:"medium",LOW:"low",OFF:"off"},"WebkitPresentationModes",0,mE],70573),e.i(70573);let mk=e=>new Promise(t=>setTimeout(t,e)),mR={en:{"Start airplay":"Start airplay","Stop airplay":"Stop airplay",Audio:"Audio",Captions:"Captions","Enable captions":"Enable captions","Disable captions":"Disable captions","Start casting":"Start casting","Stop casting":"Stop casting","Enter fullscreen mode":"Enter fullscreen mode","Exit fullscreen mode":"Exit fullscreen mode",Mute:"Mute",Unmute:"Unmute",Loop:"Loop","Enter picture in picture mode":"Enter picture in picture mode","Exit picture in picture mode":"Exit picture in picture mode",Play:"Play",Pause:"Pause","Playback rate":"Playback rate","Playback rate {playbackRate}":"Playback rate {playbackRate}",Quality:"Quality","Seek backward":"Seek backward","Seek forward":"Seek forward",Settings:"Settings",Auto:"Auto","audio player":"audio player","video player":"video player",volume:"volume",seek:"seek","closed captions":"closed captions","current playback rate":"current playback rate","playback time":"playback time","media loading":"media loading",settings:"settings","audio tracks":"audio tracks",quality:"quality",play:"play",pause:"pause",mute:"mute",unmute:"unmute","chapter: {chapterName}":"chapter: {chapterName}",live:"live",Off:"Off","start airplay":"start airplay","stop airplay":"stop airplay","start casting":"start casting","stop casting":"stop casting","enter fullscreen mode":"enter fullscreen mode","exit fullscreen mode":"exit fullscreen mode","enter picture in picture mode":"enter picture in picture mode","exit picture in picture mode":"exit picture in picture mode","seek to live":"seek to live","playing live":"playing live","seek back {seekOffset} seconds":"seek back {seekOffset} seconds","seek forward {seekOffset} seconds":"seek forward {seekOffset} seconds","Network Error":"Network Error","Decode Error":"Decode Error","S
112ource 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."}},mL=(null==(yS=globalThis.navigator)?void 0:yS.language)||"en",mI=(e,t={})=>(e=>{var t,i,r;let[a]=mL.split("-");return(null==(t=mR[mL])?void 0:t[e])||(null==(i=mR[a])?void 0:i[e])||(null==(r=mR.en)?void 0:r[e])||e})(e).replace(/\{(\w+)\}/g,(e,i)=>i in t?String(t[i]):`{${i}}`),mw=[{singular:"hour",plural:"hours"},{singular:"minute",plural:"minutes"},{singular:"second",plural:"seconds"}],mD=e=>{if(!m_(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)=>{let i;return e&&(i=1===e?mI(mw[t].singular):mI(mw[t].plural),`${e} ${i}`)}).filter(e=>e).join(", ");return i?mI("{time} remaining",{time:a}):a};function mC(e,t){let i=!1;e<0&&(i=!0,e=0-e);let r=Math.floor((e=e<0?0:e)%60),a=Math.floor(e/60%60),s=Math.floor(e/3600),n=Math.floor(t/60%60),l=Math.floor(t/3600);return(isNaN(e)||e===1/0)&&(s=a=r="0"),a=(((s=s>
1120||l>0?s+":":"")||n>=10)&&a<10?"0"+a:a)+":",(i?"-":"")+s+a+(r=r<10?"0"+r:r)}let mM=Object.freeze({length:0,start(e){let t=e>>>0;if(t>=this.length)throw new DOMException(`Failed to execute 'start' on 'TimeRanges': The index provided (${t}) is greater than or equal to the maximum bound (${this.length}).`);return 0},end(e){let t=e>>>0;if(t>=this.length)throw new DOMException(`Failed to execute 'end' on 'TimeRanges': The index provided (${t}) is greater than or equal to the maximum bound (${this.length}).`);return 0}});e.s(["emptyTimeRanges",0,mM,"formatAsTimePhrase",0,mD,"formatTime",0,mC,"serializeTimeRanges",0,function(e=mM){return Array.from(e).map((t,i)=>[Number(e.start(i).toFixed(3)),Number(e.end(i).toFixed(3))].join(":")).join(" ")}],50760),e.i(50760);class mx{addEventListener(){}removeEventListener(){}dispatchEvent(){return!0}}class mP extends mx{}class mO extends mP{constructor(){super(...arguments),this.role=null}}let mN={createElement:function(){return new mU.HTMLElement},createElementNS:function(){return new mU.HTMLElement},addEventListener(){},removeEventListener(){},dispatchEvent:e=>!1},mU={ResizeObserver:class{observe(){}unobserve(){}disconnect(){}},document:mN,Node:mP,Element:mO,HTMLElement:class extends mO{constructor(){super(...arguments),this.innerHTML=""}get content(){return new mU.DocumentFragment}},DocumentFragment:class extends mx{},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}}}}},mF="global"in globalThis&&(null==globalThis?void 0:globalThis.global)===globalThis||"u"<typeof window||void 0===window.customElements,mB=Object.keys(mU).every(e=>e in globalThis),m$=mF&&!mB?mU:globalThis,mH=mF&&!mB?mN:globalThis.document,mG=new WeakMap,mW=e=>{let t=mG.get(e);return t||mG.set(e,t=new Set),t},mK=new m$.ResizeObserver(e=>{for(let t of e)for(let e of mW(t.target))e(t)});function mV(e,t){mW(e).add(t),mK.observe(e)}function mq(e,t){let i=mW(e);i.delete(t),i.size||mK.unobserve(e)}function mj(e){let t={};for(let i of e)t[i.name]=i.value;return t}function mY(e){var t;return null!=(t=mz(e))?t:mJ(e,"media-controller")}function mz(e){var t;let{MEDIA_CONTROLLER:i}=mn,r=e.getAttribute(i);if(r)return null==(t=m1(e))?void 0:t.getElementById(r)}let mQ=(e,t,i=".value")=>{let r=e.querySelector(i);r&&(r.textContent=t)},mX=(e,t)=>{let i,r;return(i=`slot[name="${t}"]`,!(r=e.shadowRoot.querySelector(i))?[]:r.children)[0]},mZ=(e,t)=>!!e&&!!t&&(null!=e&&!!e.contains(t)||mZ(e,t.getRootNode().host)),mJ=(e,t)=>{if(!e)return null;let i=e.closest(t);return i||mJ(e.getRootNode().host,t)};function m0(e=document){var t;let i=null==e?void 0:e.activeElement;return i?null!=(t=m0(i.shadowRoot))?t:i:null}function m1(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 m2(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 m3(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||m4(e,t)}function m4(e,t){var i,r;let a=null!=(i=e.querySelectorAll("style:not([media])"))?i:[],s=null==a?void 0:a[a.length-1];if(!(null==s?void 0:s.sheet))return console.warn("Media Chrome: No style sheet found on style tag of",e),{style:{setProperty:()=>{},removeProperty:()=>"",getPropertyValue:()=>""}};let n=null==s?void 0:s.sheet.insertRule(`${t}{}`,s.sheet.cssRules.length);return null==(r=s.sheet.cssRules)?void 0:r[n]}function m5(e,t,i=NaN){let r=e.getAttribute(t);return null!=r?+r:i}function m8(e,t,i){let r=+i;if(null==i||Number.isNaN(r)){e.hasAttribute(t)&&e.removeAttribute(t);return}m5(e,t,void 0)!==r&&e.setAttribute(t,`${r}`)}function m6(e,t){return e.hasAttribute(t)}function m9(e,t,i){if(null==i){e.hasAttribute(t)&&e.removeAttribute(t);return}m6(e,t)!=i&&e.toggleAttribute(t,i)}function m7(e,t,i=null){var r;return null!=(r=e.getAttribute(t))?r:i}function fe(e,t,i){if(null==i){e.hasAttribute(t)&&e.removeAttribute(t);return}let r=`${i}`;m7(e,t,void 0)!==r&&e.setAttribute(t,r)}var ft=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},fi=(e,t,i)=>(ft(e,t,"read from private field"),i?i.call(e):t.get(e)),fr=(e,t,i,r)=>(ft(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i);class fa extends m$.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,yk,void 0),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);const e=mj(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e)}}static get observedAttributes(){return[mn.MEDIA_CONTROLLER,md.MEDIA_PAUSED]}attributeChangedCallback(e,t,i){var r,a,s,n,l;e===mn.MEDIA_CONTROLLER&&(t&&(null==(a=null==(r=fi(this,yk))?void 0:r.unassociateElement)||a.call(r,this),fr(this,yk,null)),i&&this.isConnected&&(fr(this,yk,null==(s=this.getRootNode())?void 0:s.getElementById(i)),null==(l=null==(n=fi(this,yk))?void 0:n.associateElement)||l.call(n,this)))}connectedCallback(){var e,t,i,r;let a;this.tabIndex=-1,this.setAttribute("aria-hidden","true"),fr(this,yk,(i=this,(a=i.getAttribute(mn.MEDIA_CONTROLLER))?null==(r=i.getRootNode())?void 0:r.getElementById(a):mJ(i,"media-controller"))),this.getAttribute(mn.MEDIA_CONTROLLER)&&(null==(t=null==(e=fi(this,yk))?void 0:e.associateElement)||t.call(e,this)),fi(this,yk)&&(fi(this,yk).addEventListener("pointerdown",this),fi(this,yk).addEventListener("click",this),fi(this,yk).hasAttribute("tabindex")||(fi(this,yk).tabIndex=0))}disconnectedCallback(){var e,t,i,r;this.getAttribute(mn.MEDIA_CONTROLLER)&&(null==(t=null==(e=fi(this,yk))?void 0:e.unassociateElement)||t.call(e,this)),null==(i=fi(this,yk))||i.removeEventListener("pointerdown",this),null==(r=fi(this,yk))||r.removeEventListener("click",this),fr(this,yk,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:s,height:n}=this.getBoundingClientRect(),l=t-r,o=i-a;if(l<0||o<0||l>s||o>n||0===s&&0===n)return;let d=this._pointerType||"mouse";if(this._pointerType=void 0,d===mp.TOUCH)return void this.handleTap(e);if(d===mp.MOUSE||d===mp.PEN)return void this.handleMouseClick(e)}}}get mediaPaused(){return m6(this,md.MEDIA_PAUSED)}set mediaPaused(e){m9(this,md.MEDIA_PAUSED,e)}handleTap(e){}handleMouseClick(e){let t=this.mediaPaused?ms.MEDIA_PLAY_REQUEST:ms.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new m$.CustomEvent(t,{composed:!0,bubbles:!0}))}}yk=new WeakMap,fa.shadowRootOptions={mode:"open"},fa.getTemplateHTML=function(e){return`
113    <style>
114      :host {
115        display: var(--media-control-display, var(--media-gesture-receiver-display, inline-block));
116        box-sizing: border-box;
117      }
118    </style>
119  `},m$.customElements.get("media-gesture-receiver")||m$.customElements.define("media-gesture-receiver",fa);var fs=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},fn=(e,t,i)=>(fs(e,t,"read from private field"),i?i.call(e):t.get(e)),fl=(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)},fo=(e,t,i,r)=>(fs(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i),fd=(e,t,i)=>(fs(e,t,"access private method"),i);let fh="audio",fu="autohide",fc="breakpoints",fm="gesturesdisabled",ff="keyboardcontrol",fp="noautohide",fg="userinactive",fv="autohideovercontrols",fE=Object.values(md);function fy(e,t){var i,r,a;if(!e.isConnected)return;let s=Object.fromEntries((null!=(i=e.getAttribute(fc))?i:"sm:384 md:576 lg:768 xl:960").split(/\s+/).map(e=>e.split(":"))),n=(r=s,a=t,Object.keys(r).filter(e=>a>=parseInt(r[e]))),l=!1;
119if(Object.keys(s).forEach(t=>{if(n.includes(t)){e.hasAttribute(`breakpoint${t}`)||(e.setAttribute(`breakpoint${t}`,""),l=!0);return}e.hasAttribute(`breakpoint${t}`)&&(e.removeAttribute(`breakpoint${t}`),l=!0)}),l){let t=new CustomEvent(mh.BREAKPOINTS_CHANGE,{detail:n});e.dispatchEvent(t)}e.breakpointsComputed||(e.breakpointsComputed=!0,e.dispatchEvent(new CustomEvent(mh.BREAKPOINTS_COMPUTED,{bubbles:!0,composed:!0})))}class fb extends m$.HTMLElement{constructor(){if(super(),fl(this,yP),fl(this,yN),fl(this,yF),fl(this,y$),fl(this,yG),fl(this,yR,void 0),fl(this,yL,0),fl(this,yI,null),fl(this,yw,null),fl(this,yD,void 0),this.breakpointsComputed=!1,fl(this,yC,e=>{let t=this.media;for(let i of e)if("childList"===i.type){for(let e of i.removedNodes){if("media"!=e.slot||i.target!=this)continue;let r=i.previousSibling&&i.previousSibling.previousElementSibling;if(r&&t){let t="media"!==r.slot;for(;null!==(r=r.previousSibling);)"media"==r.slot&&(t=!1);t&&this.mediaUnsetCallback(e)}else this.mediaUnsetCallback(e)}if(t)for(let e of i.addedNodes)e===t&&this.handleMediaUpdated(t)}}),fl(this,yM,!1),fl(this,yx,e=>{fn(this,yM)||(setTimeout(()=>{fy(e.target,e.contentRect.width),fo(this,yM,!1)},0),fo(this,yM,!0))}),fl(this,yK,void 0),fl(this,yV,()=>{if(!fn(this,yK).assignedElements({flatten:!0}).length){fn(this,yI)&&this.mediaUnsetCallback(fn(this,yI));return}this.handleMediaUpdated(this.media)}),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);const e=mj(this.attributes),t=this.constructor.getTemplateHTML(e);this.shadowRoot.setHTMLUnsafe?this.shadowRoot.setHTMLUnsafe(t):this.shadowRoot.innerHTML=t}fo(this,yR,new MutationObserver(fn(this,yC)))}static get observedAttributes(){return[fu,fm].concat(fE).filter(e=>![md.MEDIA_RENDITION_LIST,md.MEDIA_AUDIO_TRACK_LIST,md.MEDIA_CHAPTERS_CUES,md.MEDIA_WIDTH,md.MEDIA_HEIGHT,md.MEDIA_ERROR,md.MEDIA_ERROR_MESSAGE].includes(e))}attributeChangedCallback(e,t,i){e.toLowerCase()==fu&&(this.autohide=i)}get media(){let e=this.querySelector(":scope > [slot=media]");return(null==e?void 0:e.nodeName)=="SLOT"&&(e=e.assignedElements({flatten:!0})[0]),e}async handleMediaUpdated(e){e&&(fo(this,yI,e),e.localName.includes("-")&&await m$.customElements.whenDefined(e.localName),this.mediaSetCallback(e))}connectedCallback(){var e;fn(this,yR).observe(this,{childList:!0,subtree:!0}),mV(this,fn(this,yx));let t=null!=this.getAttribute(fh)?mI("audio player"):mI("video player");this.setAttribute("role","region"),this.setAttribute("aria-label",t),this.handleMediaUpdated(this.media),this.setAttribute(fg,""),fy(this,this.getBoundingClientRect().width);let i=this.querySelector(":scope > slot[slot=media]");i&&(fo(this,yK,i),fn(this,yK).addEventListener("slotchange",fn(this,yV))),this.addEventListener("pointerdown",this),this.addEventListener("pointermove",this),this.addEventListener("pointerup",this),this.addEventListener("mouseleave",this),this.addEventListener("keyup",this),null==(e=m$.window)||e.addEventListener("mouseup",this)}disconnectedCallback(){var e;mq(this,fn(this,yx)),clearTimeout(fn(this,yw)),fn(this,yR).disconnect(),this.media&&this.mediaUnsetCallback(this.media),null==(e=m$.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),fn(this,yK)&&(fn(this,yK).removeEventListener("slotchange",fn(this,yV)),fo(this,yK,null)),fo(this,yM,!1)}mediaSetCallback(e){}mediaUnsetCallback(e){fo(this,yI,null)}handleEvent(e){switch(e.type){case"pointerdown":fo(this,yL,e.timeStamp);break;case"pointermove":fd(this,yP,yO).call(this,e);break;case"pointerup":fd(this,yN,yU).call(this,e);break;case"mouseleave":fd(this,yF,yB).call(this);break;case"mouseup":this.removeAttribute(ff);break;case"keyup":fd(this,yG,yW).call(this),this.setAttribute(ff,"")}}set autohide(e){let t=Number(e);fo(this,yD,isNaN(t)?0:t)}get autohide(){return(void 0===fn(this,yD)?2:fn(this,yD)).toString()}get breakpoints(){return m7(this,fc)}set breakpoints(e){fe(this,fc,e)}get audio(){return m6(this,fh)}set audio(e){m9(this,fh,e)}get gesturesDisabled(){return m6(this,fm)}set gesturesDisabled(e){m9(this,fm,e)}get keyboardControl(){return m6(this,ff)}set keyboardControl(e){m9(this,ff,e)}get noAutohide(){return m6(this,fp)}set noAutohide(e){m9(this,fp,e)}get autohideOverControls(){return m6(this,fv)}set autohideOverControls(e){m9(this,fv,e)}get userInteractive(){return m6(this,fg)}set userInteractive(e){m9(this,fg,e)}}yR=new WeakMap,yL=new WeakMap,yI=new WeakMap,yw=new WeakMap,yD=new WeakMap,yC=new WeakMap,yM=new WeakMap,yx=new WeakMap,yP=new WeakSet,yO=function(e){if("mouse"!==e.pointerType&&e.timeStamp-fn(this,yL)<250)return;fd(this,y$,yH).call(this),clearTimeout(fn(this,yw));let t=this.hasAttribute(fv);([this,this.media].includes(e.target)||t)&&fd(this,yG,yW).call(this)},yN=new WeakSet,yU=function(e){if("touch"===e.pointerType){let t=!this.hasAttribute(fg);
119[this,this.media].includes(e.target)&&t?fd(this,yF,yB).call(this):fd(this,yG,yW).call(this)}else e.composedPath().some(e=>["media-play-button","media-fullscreen-button"].includes(null==e?void 0:e.localName))&&fd(this,yG,yW).call(this)},yF=new WeakSet,yB=function(){if(0>fn(this,yD)||this.hasAttribute(fg))return;this.setAttribute(fg,"");let e=new m$.CustomEvent(mh.USER_INACTIVE_CHANGE,{composed:!0,bubbles:!0,detail:!0});this.dispatchEvent(e)},y$=new WeakSet,yH=function(){if(!this.hasAttribute(fg))return;this.removeAttribute(fg);let e=new m$.CustomEvent(mh.USER_INACTIVE_CHANGE,{composed:!0,bubbles:!0,detail:!1});this.dispatchEvent(e)},yG=new WeakSet,yW=function(){fd(this,y$,yH).call(this),clearTimeout(fn(this,yw));let e=parseInt(this.autohide);e<0||fo(this,yw,setTimeout(()=>{fd(this,yF,yB).call(this)},1e3*e))},yK=new WeakMap,yV=new WeakMap,fb.shadowRootOptions={mode:"open"},fb.getTemplateHTML=function(e){return`
120    <style>
121      
122      :host([${md.MEDIA_IS_FULLSCREEN}]) ::slotted([slot=media]) {
123        outline: none;
124      }
125
126      :host {
127        box-sizing: border-box;
128        position: relative;
129        display: inline-block;
130        line-height: 0;
131        background-color: var(--media-background-color, #000);
132        overflow: hidden;
133      }
134
135      :host(:not([${fh}])) [part~=layer]:not([part~=media-layer]) {
136        position: absolute;
137        top: 0;
138        left: 0;
139        bottom: 0;
140        right: 0;
141        display: flex;
142        flex-flow: column nowrap;
143        align-items: start;
144        pointer-events: none;
145        background: none;
146      }
147
148      slot[name=media] {
149        display: var(--media-slot-display, contents);
150      }
151
152      
153      :host([${fh}]) slot[name=media] {
154        display: var(--media-slot-display, none);
155      }
156
157      
158      :host([${fh}]) [part~=layer][part~=gesture-layer] {
159        height: 0;
160        display: block;
161      }
162
163      
164      :host(:not([${fh}])[${fm}]) ::slotted([slot=gestures-chrome]),
165          :host(:not([${fh}])[${fm}]) media-gesture-receiver[slot=gestures-chrome] {
166        display: none;
167      }
168
169      
170      ::slotted(:not([slot=media]):not([slot=poster]):not(media-loading-indicator):not([role=dialog]):not([hidden])) {
171        pointer-events: auto;
172      }
173
174      :host(:not([${fh}])) *[part~=layer][part~=centered-layer] {
175        align-items: center;
176        justify-content: center;
177      }
178
179      :host(:not([${fh}])) ::slotted(media-gesture-receiver[slot=gestures-chrome]),
180      :host(:not([${fh}])) media-gesture-receiver[slot=gestures-chrome] {
181        align-self: stretch;
182        flex-grow: 1;
183      }
184
185      slot[name=middle-chrome] {
186        display: inline;
187        flex-grow: 1;
188        pointer-events: none;
189        background: none;
190      }
191
192      
193      ::slotted([slot=media]),
194      ::slotted([slot=poster]) {
195        width: 100%;
196        height: 100%;
197      }
198
199      
200      :host(:not([${fh}])) .spacer {
201        flex-grow: 1;
202      }
203
204      
205      :host(:-webkit-full-screen) {
206        
207        width: 100% !important;
208        height: 100% !important;
209      }
210
211      
212      ::slotted(:not([slot=media]):not([slot=poster]):not([${fp}]):not([hidden]):not([role=dialog])) {
213        opacity: 1;
214        transition: var(--media-control-transition-in, opacity 0.25s);
215      }
216
217      
218      :host([${fg}]:not([${md.MEDIA_PAUSED}]):not([${md.MEDIA_IS_AIRPLAYING}]):not([${md.MEDIA_IS_CASTING}]):not([${fh}])) ::slotted(:not([slot=media]):not([slot=poster]):not([${fp}]):not([role=dialog])) {
219        opacity: 0;
220        transition: var(--media-control-transition-out, opacity 1s);
221      }
222
223      :host([${fg}]:not([${fp}]):not([${md.MEDIA_PAUSED}]):not([${md.MEDIA_IS_CASTING}]):not([${fh}])) ::slotted([slot=media]) {
224        cursor: none;
225      }
226
227      :host([${fg}][${fv}]:not([${fp}]):not([${md.MEDIA_PAUSED}]):not([${md.MEDIA_IS_CASTING}]):not([${fh}])) * {
228        --media-cursor: none;
229        cursor: none;
230      }
231
232
233      ::slotted(media-control-bar)  {
234        align-self: stretch;
235      }
236
237      
238      :host(:not([${fh}])[${md.MEDIA_HAS_PLAYED}]) slot[name=poster] {
239        display: none;
240      }
241
242      ::slotted([role=dialog]) {
243        width: 100%;
244        height: 100%;
245        align-self: center;
246      }
247
248      ::slotted([role=menu]) {
249        align-self: end;
250      }
251    </style>
252
253    <slot name="media" part="layer media-layer"></slot>
254    <slot name="poster" part="layer poster-layer"></slot>
255    <slot name="gestures-chrome" part="layer gesture-layer">
256      <media-gesture-receiver slot="gestures-chrome">
257        <template shadowrootmode="${fa.shadowRootOptions.mode}">
258          ${fa.getTemplateHTML({})}
259        </template>
260      </media-gesture-receiver>
261    </slot>
262    <span part="layer vertical-layer">
263      <slot name="top-chrome" part="top chrome"></slot>
264      <slot name="middle-chrome" part="middle chrome"></slot>
265      <slot name="centered-chrome" part="layer centered-layer center centered chrome"></slot>
266      
267      <slot part="bottom chrome"></slot>
268    </span>
269    <slot name="dialog" part="layer dialog-layer"></slot>
270  `},m$.customElements.get("media-container")||m$.customElements.define("media-container",fb);var fT=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},fA=(e,t,i)=>(fT(e,t,"read from private field"),i?i.call(e):t.get(e)),f_=(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)},fS=(e,t,i,r)=>(fT(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i);class fk{constructor(e,t,{defaultValue:i}={defaultValue:void 0}){f_(this,yQ),f_(this,yq,void 0),f_(this,yj,void 0),f_(this,yY,void 0),f_(this,yz,new Set),fS(this,yq,e),fS(this,yj,t),fS(this,yY,new Set(i))}[Symbol.iterator](){return fA(this,yQ,yX).values()}get length(){return fA(this,yQ,yX).size}get value(){var e;return null!=(e=[...fA(this,yQ,yX)].join(" "))?e:""}set value(e){var t;e!==this.value&&(fS(this,yz,new Set),this.add(...null!=(t=null==e?void 0:e.split(" "))?t:[]))}toString(){return this.value}item(e){return[...fA(this,yQ,yX)][e]}values(){return fA(this,yQ,yX).values()}
270forEach(e,t){fA(this,yQ,yX).forEach(e,t)}add(...e){var t,i;e.forEach(e=>fA(this,yz).add(e)),(""!==this.value||(null==(t=fA(this,yq))?void 0:t.hasAttribute(`${fA(this,yj)}`)))&&(null==(i=fA(this,yq))||i.setAttribute(`${fA(this,yj)}`,`${this.value}`))}remove(...e){var t;e.forEach(e=>fA(this,yz).delete(e)),null==(t=fA(this,yq))||t.setAttribute(`${fA(this,yj)}`,`${this.value}`)}contains(e){return fA(this,yQ,yX).has(e)}toggle(e,t){if(void 0!==t)if(t)return this.add(e),!0;else return this.remove(e),!1;return this.contains(e)?(this.remove(e),!1):(this.add(e),!0)}replace(e,t){return this.remove(e),this.add(t),e===t}}yq=new WeakMap,yj=new WeakMap,yY=new WeakMap,yz=new WeakMap,yQ=new WeakSet,yX=function(){return fA(this,yz).size?fA(this,yz):fA(this,yY)};let fR=(e="")=>{let[t,i,r]=e.split(":"),a=r?decodeURIComponent(r):void 0;return{kind:"cc"===t?mm.CAPTIONS:mm.SUBTITLES,language:i,label:a}},fL=(e="",t={})=>((e="")=>e.split(/\s+/))(e).map(e=>{let i=fR(e);return{...t,...i}}),fI=e=>e?Array.isArray(e)?e.map(e=>"string"==typeof e?fR(e):e):"string"==typeof e?fL(e):[e]:[],fw=({kind:e,label:t,language:i}={kind:"subtitles"})=>t?`${"captions"===e?"cc":"sb"}:${i}:${encodeURIComponent(t)}`:i,fD=(e=[])=>Array.prototype.map.call(e,fw).join(" "),fC=e=>{let t=Object.entries(e).map(([e,t])=>i=>i[e]===t);return e=>t.every(t=>t(e))},fM=(e,t=[],i=[])=>{let r=fI(i).map(fC);Array.from(t).filter(e=>r.some(t=>t(e))).forEach(t=>{t.mode=e})},fx=(e,t=()=>!0)=>{if(!(null==e?void 0:e.textTracks))return[];let i="function"==typeof t?t:fC(t);return Array.from(e.textTracks).filter(i)},fP=e=>{var t;return!!(null==(t=e.mediaSubtitlesShowing)?void 0:t.length)||e.hasAttribute(md.MEDIA_SUBTITLES_SHOWING)},fO="exitFullscreen"in mH?"exitFullscreen":"webkitExitFullscreen"in mH?"webkitExitFullscreen":"webkitCancelFullScreen"in mH?"webkitCancelFullScreen":void 0,fN="fullscreenElement"in mH?"fullscreenElement":"webkitFullscreenElement"in mH?"webkitFullscreenElement":void 0,fU="fullscreenEnabled"in mH?"fullscreenEnabled":"webkitFullscreenEnabled"in mH?"webkitFullscreenEnabled":void 0,fF=()=>{var e;return d||(d=null==(e=null==mH?void 0:mH.createElement)?void 0:e.call(mH,"video"))},fB=async(e=fF())=>{if(!e)return!1;let t=e.volume;e.volume=t/2+.1;let i=new AbortController,r=await Promise.race([f$(e,i.signal),fH(e,t)]);return i.abort(),r},f$=(e,t)=>new Promise(i=>{e.addEventListener("volumechange",()=>i(!0),{signal:t})}),fH=async(e,t)=>{for(let i=0;i<10;i++){if(e.volume===t)return!1;await mk(10)}return e.volume!==t},fG=/.*Version\/.*Safari\/.*/.test(m$.navigator.userAgent),fW=(e=fF())=>(!m$.matchMedia("(display-mode: standalone)").matches||!fG)&&"function"==typeof(null==e?void 0:e.requestPictureInPicture),fK=(e=fF())=>(e=>{let{documentElement:t,media:i}=e;return!!(null==t?void 0:t[fU])||i&&"webkitSupportsFullscreen"in i})({documentElement:mH,media:e}),fV=fK(),fq=fW(),fj=!!m$.WebKitPlaybackTargetAvailabilityEvent,fY=!!m$.chrome,fz=e=>fx(e.media,e=>[mm.SUBTITLES,mm.CAPTIONS].includes(e.kind)).sort((e,t)=>e.kind>=t.kind?1:-1),fQ=e=>fx(e.media,e=>e.mode===mf.SHOWING&&[mm.SUBTITLES,mm.CAPTIONS].includes(e.kind)),fX=(e,t)=>{let i=fz(e),r=fQ(e),a=!!r.length;if(i.length){if(!1===t||a&&!0!==t)fM(mf.DISABLED,i,r);else if(!0===t||!a&&!1!==t){let t=i[0],{options:a}=e;if(!(null==a?void 0:a.noSubtitlesLangPref)){let e=m$.localStorage.getItem("media-chrome-pref-subtitles-lang"),r=e?[e,...m$.navigator.languages]:m$.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:s,label:n,kind:l}=t;fM(mf.DISABLED,i,r),fM(mf.SHOWING,i,[{language:s,label:n,kind:l}])}}},fZ=(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)?fJ(e,t):Object.entries(e).every(([e,i])=>e in t&&fZ(i,t[e])))),fJ=(e,t)=>{let i=Array.isArray(e),r=Array.isArray(t);return i===r&&(!i&&!r||e.length===t.length&&e.every((e,i)=>fZ(e,t[i])))},f0=Object.values(mv),f1=fB().then(e=>h=e),f2=async(...e)=>{await Promise.all(e.filter(e=>e).map(async e=>{if(!("localName"in e&&e instanceof m$.HTMLElement))return;let t=e.localName;if(!t.includes("-"))return;let i=m$.customElements.get(t);i&&e instanceof i||(await m$.customElements.whenDefined(t),m$.customElements.upgrade(e))}))},f3=new m$.DOMParser,f4={mediaError:{get(e,t){let{media:i}=e;if((null==t?void 0:t.type)!=="playing")return null==i?void 0:i.error},mediaEvents:["emptied","error","playing"]},mediaErrorCode:{get(e,t){var i;let{media:r}=e;if((null==t?void 0:t.type)!=="playing")return null==(i=null==r?void 0:r.error)?void 0:i.code},mediaEvents:["emptied","error","playing"]},mediaErrorMessage:{get(e,t){var i,r;let{media:a}=e;if((null==t?void 0:t.type)!=="playing")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!==m$.localStorage.getItem("media-chrome-pref-muted"),a=i.hasAttribute("muted");if(r){t&&m$.localStorage.removeItem("media-chrome-pref-muted");return}if(a&&!t)return;m$.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"===m$.localStorage.getItem("media-chrome-pref-muted");f4.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?m$.localStorage.removeItem("media-chrome-pref-volume"):i.hasAttribute("muted")||r||m$.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=m$.localStorage.getItem("media-chrome-pref-volume");if(null==r)return;f4.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&&m_(e)&&(i.currentTime=e)},mediaEvents:["timeupdate","loadedmetadata"]},mediaDuration:{get(e){let{media:t,options:{defaultDuration:i}={}}=e;return i&&(!t||!t.duration||Number.isNaN(t.duration)||!Number.isFinite(t.duration))?i:Number.isFinite(null==t?void 0:t.duration)?t.duration:NaN},mediaEvents:["durationchange","loadedmetadata","emptied"]},mediaLoading:{get(e){let{media:t}=e;return(null==t?void 0:t.readyState)<3},mediaEvents:["waiting","playing","emptied"]},mediaSeekable:{get(e){var t;let{media:i}=e;if(!(null==(t=null==i?void 0:i.seekable)?void 0:t.length))return;let r=i.seekable.start(0),a=i.seekable.end(i.seekable.length-1);if(r||a)return[Number(r.toFixed(3)),Number(a.toFixed(3))]},mediaEvents:["loadedmetadata","emptied","progress","seekablechange"]},mediaBuffered:{get(e){var t;let{media:i}=e,r=null!=(t=null==i?void 0:i.buffered)?t:[];return Array.from(r).map((e,t)=>[Number(r.start(t).toFixed(3)),Number(r.end(t).toFixed(3))])},mediaEvents:["progress","emptied"]},mediaStreamType:{get(e){let{media:t,options:{defaultStreamType:i}={}}=e,r=[mv.LIVE,mv.ON_DEMAND].includes(i)?i:void 0;if(!t)return r;let{streamType:a}=t;if(f0.includes(a))return a===mv.UNKNOWN?r:a;let s=t.duration;return s===1/0?mv.LIVE:Number.isFinite(s)?mv.ON_DEMAND:r}
270,mediaEvents:["emptied","durationchange","loadedmetadata","streamtypechange"]},mediaTargetLiveWindow:{get(e){let{media:t}=e;if(!t)return NaN;let{targetLiveWindow:i}=t,r=f4.mediaStreamType.get(e);return(null==i||Number.isNaN(i))&&r===mv.LIVE?0:i},mediaEvents:["emptied","durationchange","loadedmetadata","streamtypechange","targetlivewindowchange"]},mediaTimeIsLive:{get(e){let{media:t,options:{liveEdgeOffset:i=10}={}}=e;if(!t)return!1;if("number"==typeof t.liveEdgeStart)return!Number.isNaN(t.liveEdgeStart)&&t.currentTime>=t.liveEdgeStart;if(f4.mediaStreamType.get(e)!==mv.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=>fz(e).map(({kind:e,label:t,language:i})=>({kind:e,label:t,language:i})),mediaEvents:["loadstart"],textTracksEvents:["addtrack","removetrack"]},mediaSubtitlesShowing:{get:e=>fQ(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:s}=t;if(!a)return;let n=e=>{var i;s.defaultSubtitles&&(e&&![mm.CAPTIONS,mm.SUBTITLES].includes(null==(i=null==e?void 0:e.track)?void 0:i.kind)||fX(t,!0))};return a.addEventListener("loadstart",n),null==(i=a.textTracks)||i.addEventListener("addtrack",n),null==(r=a.textTracks)||r.addEventListener("removetrack",n),()=>{var e,t;a.removeEventListener("loadstart",n),null==(e=a.textTracks)||e.removeEventListener("addtrack",n),null==(t=a.textTracks)||t.removeEventListener("removetrack",n)}}]},mediaChaptersCues:{get(e){var t;let{media:i}=e;if(!i)return[];let[r]=fx(i,{kind:mm.CHAPTERS});return Array.from(null!=(t=null==r?void 0:r.cues)?t:[]).map(({text:e,startTime:t,endTime:i})=>({text:e&&f3.parseFromString(e,"text/html").body.textContent||e,startTime:t,endTime:i}))},mediaEvents:["loadstart","loadedmetadata"],textTracksEvents:["addtrack","removetrack","change"],stateOwnersUpdateHandlers:[(e,t)=>{var i;let{media:r}=t;if(!r)return;let a=r.querySelector('track[kind="chapters"][default][src]'),s=null==(i=r.shadowRoot)?void 0:i.querySelector(':is(video,audio) > track[kind="chapters"][default][src]');return null==a||a.addEventListener("load",e),null==s||s.addEventListener("load",e),()=>{null==a||a.removeEventListener("load",e),null==s||s.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)?void 0:t.includes("-"))&&mZ(r,a.pictureInPictureElement);if(a.pictureInPictureElement.localName.includes("-")){let e=a.pictureInPictureElement.shadowRoot;for(;null==e?void 0:e.pictureInPictureElement;){if(e.pictureInPictureElement===r)return!0;e=null==(i=e.pictureInPictureElement)?void 0:i.shadowRoot}}return!1},set(e,t){let{media:i}=t;if(i)if(e){if(!mH.pictureInPictureEnabled)return void console.warn("MediaChrome: Picture-in-picture is not enabled");if(!i.requestPictureInPicture)return void console.warn("MediaChrome: The current media does not support picture-in-picture");let e=()=>{console.warn("MediaChrome: The media is not ready for picture-in-picture. It must have a readyState > 0.")};i.requestPictureInPicture().catch(t=>{if(11===t.code){if(!i.src)return void console.warn("MediaChrome: The media is not ready for picture-in-picture. It must have a src set.");if(0===i.readyState&&"none"===i.preload){let t=()=>{i.removeEventListener("loadedmetadata",r),i.preload="none"},r=()=>{i.requestPictureInPicture().catch(e),t()};i.addEventListener("loadedmetadata",r),i.preload="metadata",setTimeout(()=>{0===i.readyState&&e(),t()},1e3)}else throw t}else throw t})}else mH.pictureInPictureElement&&mH.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?void 0:i.videoRenditions))return void console.warn("MediaController: Rendition selection not supported by this media.");let r=Array.prototype.findIndex.call(i.videoRenditions,t=>t.id==e);i.videoRenditions.selectedIndex!=r&&(i.videoRenditions.selectedIndex=r)},mediaEvents:["emptied"],videoRenditionsEvents:["addrendition","removerendition","change"]},mediaAudioTrackList:{get(e){var t;let{media:i}=e;return[...null!=(t=null==i?void 0:i.audioTracks)?t:[]]},mediaEvents:["emptied","loadstart"],audioTracksEvents:["addtrack","removetrack"]},mediaAudioTrackEnabled:{get(e){var t,i;let{media:r}=e;return null==(i=[...null!=(t=null==r?void 0:r.audioTracks)?t:[]].find(e=>e.enabled))?void 0:i.id},set(e,t){let{media:i}=t;if(!(null==i?void 0:i.audioTracks))return void console.warn("MediaChrome: Audio track selection not supported by this media.");
270for(let t of i.audioTracks)t.enabled=e==t.id},mediaEvents:["emptied"],audioTracksEvents:["addtrack","removetrack","change"]},mediaIsFullscreen:{get:e=>(e=>{var t;let{media:i,documentElement:r,fullscreenElement:a=i}=e;if(!i||!r)return!1;let s=(e=>{let{documentElement:t,media:i}=e,r=null==t?void 0:t[fN];return!r&&"webkitDisplayingFullscreen"in i&&"webkitPresentationMode"in i&&i.webkitDisplayingFullscreen&&i.webkitPresentationMode===mE.FULLSCREEN?i:r})(e);if(!s)return!1;if(s===a||s===i)return!0;if(s.localName.includes("-")){let e=s.shadowRoot;if(!(fN in e))return mZ(s,a);for(;null==e?void 0:e[fN];){if(e[fN]===a)return!0;e=null==(t=e[fN])?void 0:t.shadowRoot}}return!1})(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?void 0:i.webkitEnterFullscreen)?i.webkitEnterFullscreen():(null==i?void 0:i.requestFullscreen)&&i.requestFullscreen()}catch(e){console.error(e)}})(t),!i.detail||(null==(r=t.media)?void 0:r.inert)||null==(a=t.media)||a.focus()):(e=>{var t;let{documentElement:i}=e;if(fO){let e=null==(t=null==i?void 0:i[fO])?void 0:t.call(i);if(e instanceof Promise)return e.catch(()=>{})}})(t)},rootEvents:["fullscreenchange","webkitfullscreenchange"],mediaEvents:["webkitbeginfullscreen","webkitendfullscreen","webkitpresentationmodechanged"]},mediaIsCasting:{get(e){var t;let{media:i}=e;return!!(null==i?void 0:i.remote)&&(null==(t=i.remote)?void 0:t.state)!=="disconnected"&&"connected"===i.remote.state},set(e,t){var i,r;let{media:a}=t;if(a&&(!e||(null==(i=a.remote)?void 0:i.state)==="disconnected")&&(e||(null==(r=a.remote)?void 0:r.state)==="connected")){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&&m$.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(!fV||!fK(t))return mg.UNSUPPORTED}},mediaPipUnavailable:{get(e){let{media:t}=e;return fq&&fW(t)?(null==t?void 0:t.disablePictureInPicture)?mg.UNAVAILABLE:void 0:mg.UNSUPPORTED}},mediaVolumeUnavailable:{get(e){let{media:t}=e;if(!1===h||(null==t?void 0:t.volume)==void 0)return mg.UNSUPPORTED},stateOwnersUpdateHandlers:[e=>{null==h&&f1.then(t=>e(t?void 0:mg.UNSUPPORTED))}]},mediaCastUnavailable:{get(e,{availability:t="not-available"}={}){var i;let{media:r}=e;return fY&&(null==(i=null==r?void 0:r.remote)?void 0:i.state)?null!=t&&"available"!==t?mg.UNAVAILABLE:void 0:mg.UNSUPPORTED},stateOwnersUpdateHandlers:[(e,t)=>{var i;let{media:r}=t;if(r)return r.disableRemotePlayback||r.hasAttribute("disableremoteplayback")||null==(i=null==r?void 0:r.remote)||i.watchAvailability(t=>{e({availability:t?"available":"not-available"})}).catch(t=>{"NotSupportedError"===t.name?e({availability:null}):e({availability:"not-available"})}),()=>{var e;null==(e=null==r?void 0:r.remote)||e.cancelWatchAvailability().catch(()=>{})}}]},mediaAirplayUnavailable:{get:(e,t)=>fj?(null==t?void 0:t.availability)==="not-available"?mg.UNAVAILABLE:void 0:mg.UNSUPPORTED,mediaEvents:["webkitplaybacktargetavailabilitychanged"],stateOwnersUpdateHandlers:[(e,t)=>{var i;let{media:r}=t;if(r)return r.disableRemotePlayback||r.hasAttribute("disableremoteplayback")||null==(i=null==r?void 0:r.remote)||i.watchAvailability(t=>{e({availability:t?"available":"not-available"})}).catch(t=>{"NotSupportedError"===t.name?e({availability:null}):e({availability:"not-available"})}),()=>{var e;null==(e=null==r?void 0:r.remote)||e.cancelWatchAvailability().catch(()=>{})}}]},mediaRenditionUnavailable:{get(e){var t;let{media:i}=e;return(null==i?void 0:i.videoRenditions)?(null==(t=i.videoRenditions)?void 0:t.length)?void 0:mg.UNAVAILABLE:mg.UNSUPPORTED},mediaEvents:["emptied","loadstart"],videoRenditionsEvents:["addrendition","removerendition"]},mediaAudioTrackUnavailable:{get(e){var t,i;let{media:r}=e;return(null==r?void 0:r.audioTracks)?(null!=(i=null==(t=r.audioTracks)?void 0:t.length)?i:0)<=1?mg.UNAVAILABLE:void 0:mg.UNSUPPORTED},mediaEvents:["emptied","loadstart"],audioTracksEvents:["addtrack","removetrack"]},mediaLang:{get(e){let{options:{mediaLang:t}={}}=e;return null!=t?t:"en"}}},f5={[ms.MEDIA_PREVIEW_REQUEST](e,t,{detail:i}){var r,a,s;let n,l,{media:o}=t,d=null!=i?i:void 0;if(o&&null!=d){let[e]=fx(o,{kind:mm.METADATA,label:"thumbnails"}),t=Array.prototype.find.call(null!=(r=null==e?void 0:e.cues)?r:[],
270(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==o?void 0:o.querySelector('track[label="thumbnails"]'))?void 0:a.src,i=new URL(t.text,e);l=new URLSearchParams(i.hash).get("#xywh").split(",").map(e=>+e),n=i.href}}let h=e.mediaDuration.get(t),u=null==(s=e.mediaChaptersCues.get(t).find((e,t,i)=>t===i.length-1&&h===e.endTime?e.startTime<=d&&e.endTime>=d:e.startTime<=d&&e.endTime>d))?void 0:s.text;return null!=i&&null==u&&(u=""),{mediaPreviewTime:d,mediaPreviewImage:n,mediaPreviewCoords:l,mediaPreviewChapter:u}},[ms.MEDIA_PAUSE_REQUEST](e,t){e.mediaPaused.set(!0,t)},[ms.MEDIA_PLAY_REQUEST](e,t){var i,r,a,s;let n=e.mediaStreamType.get(t)===mv.LIVE,l=!(null==(i=t.options)?void 0:i.noAutoSeekToLive),o=e.mediaTargetLiveWindow.get(t)>0;if(n&&l&&!o){let i=null==(r=e.mediaSeekable.get(t))?void 0:r[1];if(i){let r=null!=(s=null==(a=t.options)?void 0:a.seekToLiveOffset)?s:0;e.mediaCurrentTime.set(i-r,t)}}e.mediaPaused.set(!1,t)},[ms.MEDIA_PLAYBACK_RATE_REQUEST](e,t,{detail:i}){e.mediaPlaybackRate.set(i,t)},[ms.MEDIA_MUTE_REQUEST](e,t){e.mediaMuted.set(!0,t)},[ms.MEDIA_UNMUTE_REQUEST](e,t){e.mediaVolume.get(t)||e.mediaVolume.set(.25,t),e.mediaMuted.set(!1,t)},[ms.MEDIA_LOOP_REQUEST](e,t,{detail:i}){let r=!!i;return e.mediaLoop.set(r,t),{mediaLoop:r}},[ms.MEDIA_VOLUME_REQUEST](e,t,{detail:i}){i&&e.mediaMuted.get(t)&&e.mediaMuted.set(!1,t),e.mediaVolume.set(i,t)},[ms.MEDIA_SEEK_REQUEST](e,t,{detail:i}){e.mediaCurrentTime.set(i,t)},[ms.MEDIA_SEEK_TO_LIVE_REQUEST](e,t){var i,r,a;let s=null==(i=e.mediaSeekable.get(t))?void 0:i[1];if(Number.isNaN(Number(s)))return;let n=null!=(a=null==(r=t.options)?void 0:r.seekToLiveOffset)?a:0;e.mediaCurrentTime.set(s-n,t)},[ms.MEDIA_SHOW_SUBTITLES_REQUEST](e,t,{detail:i}){var r;let{options:a}=t,s=fz(t),n=fI(i),l=null==(r=n[0])?void 0:r.language;l&&!a.noSubtitlesLangPref&&m$.localStorage.setItem("media-chrome-pref-subtitles-lang",l),fM(mf.SHOWING,s,n)},[ms.MEDIA_DISABLE_SUBTITLES_REQUEST](e,t,{detail:i}){let r=fz(t);fM(mf.DISABLED,r,null!=i?i:[])},[ms.MEDIA_TOGGLE_SUBTITLES_REQUEST](e,t,{detail:i}){fX(t,i)},[ms.MEDIA_RENDITION_REQUEST](e,t,{detail:i}){e.mediaRenditionSelected.set(i,t)},[ms.MEDIA_AUDIO_TRACK_REQUEST](e,t,{detail:i}){e.mediaAudioTrackEnabled.set(i,t)},[ms.MEDIA_ENTER_PIP_REQUEST](e,t){e.mediaIsFullscreen.get(t)&&e.mediaIsFullscreen.set(!1,t),e.mediaIsPip.set(!0,t)},[ms.MEDIA_EXIT_PIP_REQUEST](e,t){e.mediaIsPip.set(!1,t)},[ms.MEDIA_ENTER_FULLSCREEN_REQUEST](e,t,i){e.mediaIsPip.get(t)&&e.mediaIsPip.set(!1,t),e.mediaIsFullscreen.set(!0,t,i)},[ms.MEDIA_EXIT_FULLSCREEN_REQUEST](e,t){e.mediaIsFullscreen.set(!1,t)},[ms.MEDIA_ENTER_CAST_REQUEST](e,t){e.mediaIsFullscreen.get(t)&&e.mediaIsFullscreen.set(!1,t),e.mediaIsCasting.set(!0,t)},[ms.MEDIA_EXIT_CAST_REQUEST](e,t){e.mediaIsCasting.set(!1,t)},[ms.MEDIA_AIRPLAY_REQUEST](e,t){e.mediaIsAirplaying.set(!0,t)}};var f8=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},f6=(e,t,i)=>(f8(e,t,"read from private field"),i?i.call(e):t.get(e)),f9=(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)},f7=(e,t,i,r)=>(f8(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i),pe=(e,t,i)=>(f8(e,t,"access private method"),i);let pt=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Enter"," ","f","m","k","c","l","j",">","<","p"],pi="defaultsubtitles",pr="defaultstreamtype",pa="defaultduration",ps="fullscreenelement",pn="hotkeys",pl="keyboardbackwardseekoffset",po="keyboardforwardseekoffset",pd="keyboarddownvolumestep",ph="keyboardupvolumestep",pu="keysused",pc="lang",pm="loop",pf="liveedgeoffset",pp="noautoseektolive",pg="nodefaultstore",pv="nohotkeys",pE="nomutedpref",py="nosubtitleslangpref",pb="novolumepref",pT="seektoliveoffset";class pA extends fb{constructor(){super(),f9(this,y8),f9(this,y7),f9(this,bt),this.mediaStateReceivers=[],this.associatedElementSubscriptions=new Map,f9(this,yZ,new fk(this,pn)),f9(this,yJ,void 0),f9(this,y0,void 0),f9(this,y1,null),f9(this,y2,void 0),f9(this,y3,void 0),f9(this,y4,e=>{var t;null==(t=f6(this,y0))||t.dispatch(e)}),f9(this,y5,void 0),f9(this,y9,e=>{let{key:t,shiftKey:i}=e;i&&("/"===t||"?"===t)||pt.includes(t)?this.keyboardShortcutHandler(e):this.removeEventListener("keyup",f6(this,y9))}),this.associateElement(this);let e={};f7(this,y2,t=>{Object.entries(t).forEach(([t,i])=>{if(t in e&&e[t]===i)return;
270this.propagateMediaState(t,i);let r=t.toLowerCase(),a=new m$.CustomEvent(mc[r],{composed:!0,detail:i});this.dispatchEvent(a)}),e=t})}static get observedAttributes(){return super.observedAttributes.concat(pv,pn,pr,pi,pa,pE,pb,pc,pm,pf,pT,pp)}get mediaStore(){return f6(this,y0)}set mediaStore(e){var t,i;(f6(this,y0)&&(null==(t=f6(this,y3))||t.call(this),f7(this,y3,void 0)),f7(this,y0,e),f6(this,y0)||this.hasAttribute(pg))?f7(this,y3,null==(i=f6(this,y0))?void 0:i.subscribe(f6(this,y2))):pe(this,y8,y6).call(this)}get fullscreenElement(){var e;return null!=(e=f6(this,yJ))?e:this}set fullscreenElement(e){var t;this.hasAttribute(ps)&&this.removeAttribute(ps),f7(this,yJ,e),null==(t=f6(this,y0))||t.dispatch({type:"fullscreenelementchangerequest",detail:this.fullscreenElement})}get defaultSubtitles(){return m6(this,pi)}set defaultSubtitles(e){m9(this,pi,e)}get defaultStreamType(){return m7(this,pr)}set defaultStreamType(e){fe(this,pr,e)}get defaultDuration(){return m5(this,pa)}set defaultDuration(e){m8(this,pa,e)}get noHotkeys(){return m6(this,pv)}set noHotkeys(e){m9(this,pv,e)}get keysUsed(){return m7(this,pu)}set keysUsed(e){fe(this,pu,e)}get liveEdgeOffset(){return m5(this,pf)}set liveEdgeOffset(e){m8(this,pf,e)}get noAutoSeekToLive(){return m6(this,pp)}set noAutoSeekToLive(e){m9(this,pp,e)}get noVolumePref(){return m6(this,pb)}set noVolumePref(e){m9(this,pb,e)}get noMutedPref(){return m6(this,pE)}set noMutedPref(e){m9(this,pE,e)}get noSubtitlesLangPref(){return m6(this,py)}set noSubtitlesLangPref(e){m9(this,py,e)}get noDefaultStore(){return m6(this,pg)}set noDefaultStore(e){m9(this,pg,e)}get resolvedLang(){return(()=>{let[e]=mL.split("-");return mR[mL]?mL:mR[e]?e:"en"})()}attributeChangedCallback(e,t,i){var r,a,s,n,l,o,d,h,u,c,m,f;if(super.attributeChangedCallback(e,t,i),e===pv)i!==t&&""===i?(this.hasAttribute(pn)&&console.warn("Media Chrome: Both `hotkeys` and `nohotkeys` have been set. All hotkeys will be disabled."),this.disableHotkeys()):i!==t&&null===i&&this.enableHotkeys();else if(e===pn)f6(this,yZ).value=i;else if(e===pi&&i!==t)null==(r=f6(this,y0))||r.dispatch({type:"optionschangerequest",detail:{defaultSubtitles:this.hasAttribute(pi)}});else if(e===pr)null==(s=f6(this,y0))||s.dispatch({type:"optionschangerequest",detail:{defaultStreamType:null!=(a=this.getAttribute(pr))?a:void 0}});else if(e===pf&&i!==t)null==(n=f6(this,y0))||n.dispatch({type:"optionschangerequest",detail:{liveEdgeOffset:this.hasAttribute(pf)?+this.getAttribute(pf):void 0,seekToLiveOffset:this.hasAttribute(pT)?+this.getAttribute(pT):this.hasAttribute(pf)?+this.getAttribute(pf):void 0}});else if(e===pT&&i!==t)null==(l=f6(this,y0))||l.dispatch({type:"optionschangerequest",detail:{seekToLiveOffset:this.hasAttribute(pT)?+this.getAttribute(pT):this.hasAttribute(pf)?+this.getAttribute(pf):void 0}});else if(e===pp)null==(o=f6(this,y0))||o.dispatch({type:"optionschangerequest",detail:{noAutoSeekToLive:this.hasAttribute(pp)}});else if(e===ps){let e=i?null==(d=this.getRootNode())?void 0:d.getElementById(i):void 0;f7(this,yJ,e),null==(h=f6(this,y0))||h.dispatch({type:"fullscreenelementchangerequest",detail:this.fullscreenElement})}else e===pc&&i!==t?(mL=i,null==(u=f6(this,y0))||u.dispatch({type:"optionschangerequest",detail:{mediaLang:i}})):e===pm&&i!==t?null==(c=f6(this,y0))||c.dispatch({type:ms.MEDIA_LOOP_REQUEST,detail:null!=i}):e===pb&&i!==t?null==(m=f6(this,y0))||m.dispatch({type:"optionschangerequest",detail:{noVolumePref:this.hasAttribute(pb)}}):e===pE&&i!==t&&(null==(f=f6(this,y0))||f.dispatch({type:"optionschangerequest",detail:{noMutedPref:this.hasAttribute(pE)}}))}connectedCallback(){var e,t,i;this.associateElement(this),f6(this,y0)||this.hasAttribute(pg)||pe(this,y8,y6).call(this),null==(e=f6(this,y0))||e.dispatch({type:"documentelementchangerequest",detail:mH}),null==(t=f6(this,y0))||t.dispatch({type:"fullscreenelementchangerequest",detail:this.fullscreenElement}),super.connectedCallback(),f6(this,y0)&&!f6(this,y3)&&f7(this,y3,null==(i=f6(this,y0))?void 0:i.subscribe(f6(this,y2))),void 0!==f6(this,y5)&&f6(this,y0)&&this.media&&setTimeout(()=>{var e,t,i;(null==(t=null==(e=this.media)?void 0:e.textTracks)?void 0:t.length)&&(null==(i=f6(this,y0))||i.dispatch({type:ms.MEDIA_TOGGLE_SUBTITLES_REQUEST,detail:f6(this,y5)}))},0),this.hasAttribute(pv)?this.disableHotkeys():this.enableHotkeys()}disconnectedCallback(){var e,t,i,r,a,s;if(null==(e=super.disconnectedCallback)||e.call(this),this.disableHotkeys(),f6(this,y0)){let e=f6(this,y0).getState();f7(this,y5,!!(null==(t=e.mediaSubtitlesShowing)?void 0:t.length)),null==(i=f6(this,y0))||i.dispatch({type:"fullscreenelementchangerequest",detail:void 0}),null==(r=f6(this,y0))||r.dispatch({type:"documentelementchangerequest",detail:void 0}),null==(a=f6(this,y0))||a.dispatch({type:ms.MEDIA_TOGGLE_SUBTITLES_REQUEST,detail:!1})}f6(this,y3)&&(null==(s=f6(this,y3))||s.call(this),f7(this,y3,void 0)),this.unassociateElement(this),f6(this,y1)&&(f6(this,y1).remove(),f7(this,y1,null))}mediaSetCallback(e){var t;super.mediaSetCallback(e),null==(t=f6(this,y0))||t.dispatch({type:"mediaelementchangerequest",detail:e}),e.hasAttribute("tabindex")||(e.tabIndex=-1)}mediaUnsetCallback(e){var t;super.mediaUnsetCallback(e),null==(t=f6(this,y0))||t.dispatch({type:"mediaelementchangerequest",detail:void 0})}propagateMediaState(e,t){pC(this.mediaStateReceivers,e,t)}associateElement(e){if(!e)return;let{associatedElementSubscriptions:t}=this;if(t.has(e))return;let i=pM(e,this.registerMediaStateReceiver.bind(this),this.unregisterMediaStateReceiver.bind(this));
270Object.values(ms).forEach(t=>{e.addEventListener(t,f6(this,y4))}),t.set(e,i)}unassociateElement(e){if(!e)return;let{associatedElementSubscriptions:t}=this;t.has(e)&&(t.get(e)(),t.delete(e),Object.values(ms).forEach(t=>{e.removeEventListener(t,f6(this,y4))}))}registerMediaStateReceiver(e){if(!e)return;let t=this.mediaStateReceivers;!(t.indexOf(e)>-1)&&(t.push(e),f6(this,y0)&&Object.entries(f6(this,y0).getState()).forEach(([t,i])=>{pC([e],t,i)}))}unregisterMediaStateReceiver(e){let t=this.mediaStateReceivers,i=t.indexOf(e);i<0||t.splice(i,1)}enableHotkeys(){this.addEventListener("keydown",pe(this,y7,be))}disableHotkeys(){this.removeEventListener("keydown",pe(this,y7,be)),this.removeEventListener("keyup",f6(this,y9))}get hotkeys(){return f6(this,yZ)}set hotkeys(e){fe(this,pn,e)}keyboardShortcutHandler(e){var t,i,r,a,s,n,l,o,d;let h,u,c,m=e.target;if(!((null!=(r=null!=(i=null==(t=m.getAttribute(pu))?void 0:t.split(" "))?i:null==m?void 0:m.keysUsed)?r:[]).map(e=>"Space"===e?" ":e).filter(Boolean).includes(e.key)||f6(this,yZ).contains(`no${e.key.toLowerCase()}`)||" "===e.key&&f6(this,yZ).contains("nospace"))&&!(e.shiftKey&&("/"===e.key||"?"===e.key)&&f6(this,yZ).contains("noshift+/")))switch(e.key){case" ":case"k":h=f6(this,y0).getState().mediaPaused?ms.MEDIA_PLAY_REQUEST:ms.MEDIA_PAUSE_REQUEST,this.dispatchEvent(new m$.CustomEvent(h,{composed:!0,bubbles:!0}));break;case"m":h="off"===this.mediaStore.getState().mediaVolumeLevel?ms.MEDIA_UNMUTE_REQUEST:ms.MEDIA_MUTE_REQUEST,this.dispatchEvent(new m$.CustomEvent(h,{composed:!0,bubbles:!0}));break;case"f":h=this.mediaStore.getState().mediaIsFullscreen?ms.MEDIA_EXIT_FULLSCREEN_REQUEST:ms.MEDIA_ENTER_FULLSCREEN_REQUEST,this.dispatchEvent(new m$.CustomEvent(h,{composed:!0,bubbles:!0}));break;case"c":this.dispatchEvent(new m$.CustomEvent(ms.MEDIA_TOGGLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0}));break;case"ArrowLeft":case"j":{let e=this.hasAttribute(pl)?+this.getAttribute(pl):10;u=Math.max((null!=(a=this.mediaStore.getState().mediaCurrentTime)?a:0)-e,0),c=new m$.CustomEvent(ms.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:u}),this.dispatchEvent(c);break}case"ArrowRight":case"l":{let e=this.hasAttribute(po)?+this.getAttribute(po):10;u=Math.max((null!=(s=this.mediaStore.getState().mediaCurrentTime)?s:0)+e,0),c=new m$.CustomEvent(ms.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:u}),this.dispatchEvent(c);break}case"ArrowUp":{let e=this.hasAttribute(ph)?+this.getAttribute(ph):.025;u=Math.min((null!=(n=this.mediaStore.getState().mediaVolume)?n:1)+e,1),c=new m$.CustomEvent(ms.MEDIA_VOLUME_REQUEST,{composed:!0,bubbles:!0,detail:u}),this.dispatchEvent(c);break}case"ArrowDown":{let e=this.hasAttribute(pd)?+this.getAttribute(pd):.025;u=Math.max((null!=(l=this.mediaStore.getState().mediaVolume)?l:1)-e,0),c=new m$.CustomEvent(ms.MEDIA_VOLUME_REQUEST,{composed:!0,bubbles:!0,detail:u}),this.dispatchEvent(c);break}case"<":u=Math.max((null!=(o=this.mediaStore.getState().mediaPlaybackRate)?o:1)-.25,.25).toFixed(2),c=new m$.CustomEvent(ms.MEDIA_PLAYBACK_RATE_REQUEST,{composed:!0,bubbles:!0,detail:u}),this.dispatchEvent(c);break;case">":u=Math.min((null!=(d=this.mediaStore.getState().mediaPlaybackRate)?d:1)+.25,2).toFixed(2),c=new m$.CustomEvent(ms.MEDIA_PLAYBACK_RATE_REQUEST,{composed:!0,bubbles:!0,detail:u}),this.dispatchEvent(c);break;case"/":case"?":e.shiftKey&&pe(this,bt,bi).call(this);break;case"p":h=this.mediaStore.getState().mediaIsPip?ms.MEDIA_EXIT_PIP_REQUEST:ms.MEDIA_ENTER_PIP_REQUEST,c=new m$.CustomEvent(h,{composed:!0,bubbles:!0}),this.dispatchEvent(c)}}}yZ=new WeakMap,yJ=new WeakMap,y0=new WeakMap,y1=new WeakMap,y2=new WeakMap,y3=new WeakMap,y4=new WeakMap,y5=new WeakMap,y8=new WeakSet,y6=function(){var e;this.mediaStore=(({media:e,fullscreenElement:t,documentElement:i,stateMediator:r=f4,requestMap:a=f5,options:s={},monitorStateOwnersOnlyWithSubscriptions:n=!0})=>{let l,o=[],d={options:{...s}},h=Object.freeze({mediaPreviewTime:void 0,mediaPreviewImage:void 0,mediaPreviewCoords:void 0,mediaPreviewChapter:void 0}),u=e=>{void 0==e||fZ(e,h)||(h=Object.freeze({...h,...e}),o.forEach(e=>e(h)))},c=()=>{u(Object.entries(r).reduce((e,[t,{get:i}])=>(e[t]=i(d),e),{}))},m={},f=async(e,t)=>{var i,a,s,h,f,p,g,v,E,y,b,T,A,S,k,R;let L=!!l;if(l={...d,...null!=l?l:{},...e},L)return;await f2(...Object.values(e));let I=o.length>0&&0===t&&n,w=d.media!==l.media,D=(null==(i=d.media)?void 0:i.textTracks)!==(null==(a=l.media)?void 0:a.textTracks),C=(null==(s=d.media)?void 0:s.videoRenditions)!==(null==(h=l.media)?void 0:h.videoRenditions),M=(null==(f=d.media)?void 0:f.audioTracks)!==(null==(p=l.media)?void 0:p.audioTracks),x=(null==(g=d.media)?void 0:g.remote)!==(null==(v=l.media)?void 0:v.remote),P=d.documentElement!==l.documentElement,O=!!d.media&&(w||I),N=!!(null==(E=d.media)?void 0:E.textTracks)&&(D||I),U=!!(null==(y=d.media)?void 0:y.videoRenditions)&&(C||I),F=!!(null==(b=d.media)?void 0:b.audioTracks)&&(M||I),B=!!(null==(T=d.media)?void 0:T.remote)&&(x||I),$=!!d.documentElement&&(P||I),H=O||N||U||F||B||$,G=0===o.length&&1===t&&n,W=!!l.media&&(w||G),K=!!(null==(A=l.media)?void 0:A.textTracks)&&(D||G),V=!!(null==(S=l.media)?void 0:S.videoRenditions)&&(C||G),q=!!(null==(k=l.media)?void 0:k.audioTracks)&&(M||G),j=!!(null==(R=l.media)?void 0:R.remote)&&(x||G),Y=!!l.documentElement&&(P||G),z=W||K||V||q||j||Y;if(!(H||z)){Object.entries(l).forEach(([e,t])=>{d[e]=t}),c(),l=void 0;return}Object.entries(r).forEach(([e,{get:t,mediaEvents:i=[],textTracksEvents:r=[],videoRenditionsEvents:a=[],audioTracksEvents:s=[],remoteEvents:n=[],rootEvents:o=[],stateOwnersUpdateHandlers:h=[]}])=>{let c;m[e]||(m[e]={});let f=i=>{u({[e]:t(d,i)})};
270c=m[e].mediaEvents,i.forEach(t=>{c&&O&&(d.media.removeEventListener(t,c),m[e].mediaEvents=void 0),W&&(l.media.addEventListener(t,f),m[e].mediaEvents=f)}),c=m[e].textTracksEvents,r.forEach(t=>{var i,r;c&&N&&(null==(i=d.media.textTracks)||i.removeEventListener(t,c),m[e].textTracksEvents=void 0),K&&(null==(r=l.media.textTracks)||r.addEventListener(t,f),m[e].textTracksEvents=f)}),c=m[e].videoRenditionsEvents,a.forEach(t=>{var i,r;c&&U&&(null==(i=d.media.videoRenditions)||i.removeEventListener(t,c),m[e].videoRenditionsEvents=void 0),V&&(null==(r=l.media.videoRenditions)||r.addEventListener(t,f),m[e].videoRenditionsEvents=f)}),c=m[e].audioTracksEvents,s.forEach(t=>{var i,r;c&&F&&(null==(i=d.media.audioTracks)||i.removeEventListener(t,c),m[e].audioTracksEvents=void 0),q&&(null==(r=l.media.audioTracks)||r.addEventListener(t,f),m[e].audioTracksEvents=f)}),c=m[e].remoteEvents,n.forEach(t=>{var i,r;c&&B&&(null==(i=d.media.remote)||i.removeEventListener(t,c),m[e].remoteEvents=void 0),j&&(null==(r=l.media.remote)||r.addEventListener(t,f),m[e].remoteEvents=f)}),c=m[e].rootEvents,o.forEach(t=>{c&&$&&(d.documentElement.removeEventListener(t,c),m[e].rootEvents=void 0),Y&&(l.documentElement.addEventListener(t,f),m[e].rootEvents=f)});let p=m[e].stateOwnersUpdateHandlers;if(p&&H&&(Array.isArray(p)?p:[p]).forEach(e=>{"function"==typeof e&&e()}),z){let t=h.map(e=>e(f,l)).filter(e=>"function"==typeof e);m[e].stateOwnersUpdateHandlers=1===t.length?t[0]:t}else H&&(m[e].stateOwnersUpdateHandlers=void 0)}),Object.entries(l).forEach(([e,t])=>{d[e]=t}),c(),l=void 0};return f({media:e,fullscreenElement:t,documentElement:i,options:s}),{dispatch(e){let{type:t,detail:i}=e;a[t]&&null==h.mediaErrorCode?u(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:()=>h,subscribe:e=>(f({},o.length+1),o.push(e),e(h),()=>{let t=o.indexOf(e);t>=0&&(f({},o.length-1),o.splice(t,1))})}})({media:this.media,fullscreenElement:this.fullscreenElement,options:{defaultSubtitles:this.hasAttribute(pi),defaultDuration:this.hasAttribute(pa)?+this.getAttribute(pa):void 0,defaultStreamType:null!=(e=this.getAttribute(pr))?e:void 0,liveEdgeOffset:this.hasAttribute(pf)?+this.getAttribute(pf):void 0,seekToLiveOffset:this.hasAttribute(pT)?+this.getAttribute(pT):this.hasAttribute(pf)?+this.getAttribute(pf):void 0,noAutoSeekToLive:this.hasAttribute(pp),noVolumePref:this.hasAttribute(pb),noMutedPref:this.hasAttribute(pE),noSubtitlesLangPref:this.hasAttribute(py)}})},y9=new WeakMap,y7=new WeakSet,be=function(e){var t;let{metaKey:i,altKey:r,key:a,shiftKey:s}=e,n=s&&("/"===a||"?"===a);if(n&&(null==(t=f6(this,y1))?void 0:t.open)||i||r||!n&&!pt.includes(a))return void this.removeEventListener("keyup",f6(this,y9));let l=e.target,o=l instanceof HTMLElement&&("media-volume-range"===l.tagName.toLowerCase()||"media-time-range"===l.tagName.toLowerCase());![" ","ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(a)||f6(this,yZ).contains(`no${a.toLowerCase()}`)||" "===a&&f6(this,yZ).contains("nospace")||o||e.preventDefault(),this.addEventListener("keyup",f6(this,y9),{once:!0})}
270,bt=new WeakSet,bi=function(){f6(this,y1)||(f7(this,y1,mH.createElement("media-keyboard-shortcuts-dialog")),this.appendChild(f6(this,y1))),f6(this,y1).open=!0};let p_=Object.values(md),pS=Object.values(ml),pk=e=>{var t,i,r,a;let{observedAttributes:s}=e.constructor;!s&&(null==(t=e.nodeName)?void 0:t.includes("-"))&&(m$.customElements.upgrade(e),{observedAttributes:s}=e.constructor);let n=null==(a=null==(r=null==(i=null==e?void 0:e.getAttribute)?void 0:i.call(e,mn.MEDIA_CHROME_ATTRIBUTES))?void 0:r.split)?void 0:a.call(r,/\s+/);return Array.isArray(s||n)?(s||n).filter(e=>p_.includes(e)):[]},pR=e=>{var t,i;return(null==(t=e.nodeName)?void 0:t.includes("-"))&&m$.customElements.get(null==(i=e.nodeName)?void 0:i.toLowerCase())&&!(e instanceof m$.customElements.get(e.nodeName.toLowerCase()))&&m$.customElements.upgrade(e),pS.some(t=>t in e)||!!pk(e).length},pL=e=>{var t;return null==(t=null==e?void 0:e.join)?void 0:t.call(e,":")},pI={[md.MEDIA_SUBTITLES_LIST]:fD,[md.MEDIA_SUBTITLES_SHOWING]:fD,[md.MEDIA_SEEKABLE]:pL,[md.MEDIA_BUFFERED]:e=>null==e?void 0:e.map(pL).join(" "),[md.MEDIA_PREVIEW_COORDS]:e=>null==e?void 0:e.join(" "),[md.MEDIA_RENDITION_LIST]:function(e){return null==e?void 0:e.map(my).join(" ")},[md.MEDIA_AUDIO_TRACK_LIST]:function(e){return null==e?void 0:e.map(mT).join(" ")}},pw=async(e,t,i)=>{var r,a;if(e.isConnected||await mk(0),"boolean"==typeof i||null==i)return m9(e,t,i);if("number"==typeof i)return m8(e,t,i);if("string"==typeof i)return fe(e,t,i);if(Array.isArray(i)&&!i.length)return e.removeAttribute(t);let s=null!=(a=null==(r=pI[t])?void 0:r.call(pI,i))?a:i;return e.setAttribute(t,s)},pD=(e,t)=>{var i;if(null==(i=e.closest)?void 0:i.call(e,'*[slot="media"]'))return;let r=(e,t)=>{var i,r;pR(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=>pD(e,t))},a=null==e?void 0:e.nodeName.toLowerCase();a.includes("-")&&!pR(e)?m$.customElements.whenDefined(a).then(()=>{r(e,t)}):r(e,t)},pC=(e,t,i)=>{e.forEach(e=>{if(t in e){e[t]=i;return}let r=pk(e),a=t.toLowerCase();r.includes(a)&&pw(e,a,i)})},pM=(e,t,i)=>{pD(e,t);let r=e=>{var i;t(null!=(i=null==e?void 0:e.composedPath()[0])?i:e.target)},a=e=>{var t;i(null!=(t=null==e?void 0:e.composedPath()[0])?t:e.target)};e.addEventListener(ms.REGISTER_MEDIA_STATE_RECEIVER,r),e.addEventListener(ms.UNREGISTER_MEDIA_STATE_RECEIVER,a);let s=[],n=e=>{let r=e.target;"media"!==r.name&&(s.forEach(e=>pD(e,i)),(s=[...r.assignedElements({flatten:!0})]).forEach(e=>pD(e,t)))};e.addEventListener("slotchange",n);let l=new MutationObserver(e=>{e.forEach(e=>{let{addedNodes:r=[],removedNodes:a=[],type:s,target:n,attributeName:l}=e;"childList"===s?(Array.prototype.forEach.call(r,e=>pD(e,t)),Array.prototype.forEach.call(a,e=>pD(e,i))):"attributes"===s&&l===mn.MEDIA_CHROME_ATTRIBUTES&&(pR(n)?t(n):i(n))})});return l.observe(e,{childList:!0,attributes:!0,subtree:!0}),()=>{pD(e,i),e.removeEventListener("slotchange",n),l.disconnect(),e.removeEventListener(ms.REGISTER_MEDIA_STATE_RECEIVER,r),e.removeEventListener(ms.UNREGISTER_MEDIA_STATE_RECEIVER,a)}};m$.customElements.get("media-controller")||m$.customElements.define("media-controller",pA);let px="placement",pP="bounds";class pO extends m$.HTMLElement{constructor(){if(super(),this.updateXOffset=()=>{var e;if(!m2(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=mJ(this,"#"+this.bounds))?e:mY(this);if(!r)return;let{x:a,width:s}=r.getBoundingClientRect(),{x:n,width:l}=this.getBoundingClientRect(),o=i.getPropertyValue("--media-tooltip-offset-x"),d=o?parseFloat(o.replace("px","")):0,h=i.getPropertyValue("--media-tooltip-container-margin"),u=h?parseFloat(h.replace("px","")):0,c=n-a+d-u,m=n+l-(a+s)+d+u;c<0?this.style.setProperty("--media-tooltip-offset-x",`${c}px`):m>0?this.style.setProperty("--media-tooltip-offset-x",`${m}px`):this.style.removeProperty("--media-tooltip-offset-x")},!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);const e=mj(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e)}if(this.arrowEl=this.shadowRoot.querySelector("#arrow"),Object.prototype.hasOwnProperty.call(this,"placement")){const e=this.placement;delete this.placement,this.placement=e}}static get observedAttributes(){return[px,pP]}get placement(){return m7(this,px)}set placement(e){fe(this,px,e)}get bounds(){return m7(this,pP)}set bounds(e){fe(this,pP,e)}}pO.shadowRootOptions={mode:"open"},pO.getTemplateHTML=function(e){return`
271    <style>
272      :host {
273        --_tooltip-background-color: var(--media-tooltip-background-color, var(--media-secondary-color, rgba(20, 20, 30, .7)));
274        --_tooltip-background: var(--media-tooltip-background, var(--_tooltip-background-color));
275        --_tooltip-arrow-half-width: calc(var(--media-tooltip-arrow-width, 12px) / 2);
276        --_tooltip-arrow-height: var(--media-tooltip-arrow-height, 5px);
277        --_tooltip-arrow-background: var(--media-tooltip-arrow-color, var(--_tooltip-background-color));
278        position: relative;
279        pointer-events: none;
280        display: var(--media-tooltip-display, inline-flex);
281        justify-content: center;
282        align-items: center;
283        box-sizing: border-box;
284        z-index: var(--media-tooltip-z-index, 1);
285        background: var(--_tooltip-background);
286        color: var(--media-text-color, var(--media-primary-color, rgb(238 238 238)));
287        font: var(--media-font,
288          var(--media-font-weight, 400)
289          var(--media-font-size, 13px) /
290          var(--media-text-content-height, var(--media-control-height, 18px))
291          var(--media-font-family, helvetica neue, segoe ui, roboto, arial, sans-serif));
292        padding: var(--media-tooltip-padding, .35em .7em);
293        border: var(--media-tooltip-border, none);
294        border-radius: var(--media-tooltip-border-radius, 5px);
295        filter: var(--media-tooltip-filter, drop-shadow(0 0 4px rgba(0, 0, 0, .2)));
296        white-space: var(--media-tooltip-white-space, nowrap);
297      }
298
299      :host([hidden]) {
300        display: none;
301      }
302
303      img, svg {
304        display: inline-block;
305      }
306
307      #arrow {
308        position: absolute;
309        width: 0px;
310        height: 0px;
311        border-style: solid;
312        display: var(--media-tooltip-arrow-display, block);
313      }
314
315      :host(:not([placement])),
316      :host([placement="top"]) {
317        position: absolute;
318        bottom: calc(100% + var(--media-tooltip-distance, 12px));
319        left: 50%;
320        transform: translate(calc(-50% - var(--media-tooltip-offset-x, 0px)), 0
320);
321      }
322      :host(:not([placement])) #arrow,
323      :host([placement="top"]) #arrow {
324        top: 100%;
325        left: 50%;
326        border-width: var(--_tooltip-arrow-height) var(--_tooltip-arrow-half-width) 0 var(--_tooltip-arrow-half-width);
327        border-color: var(--_tooltip-arrow-background) transparent transparent transparent;
328        transform: translate(calc(-50% + var(--media-tooltip-offset-x, 0px)), 0);
329      }
330
331      :host([placement="right"]) {
332        position: absolute;
333        left: calc(100% + var(--media-tooltip-distance, 12px));
334        top: 50%;
335        transform: translate(0, -50%);
336      }
337      :host([placement="right"]) #arrow {
338        top: 50%;
339        right: 100%;
340        border-width: var(--_tooltip-arrow-half-width) var(--_tooltip-arrow-height) var(--_tooltip-arrow-half-width) 0;
341        border-color: transparent var(--_tooltip-arrow-background) transparent transparent;
342        transform: translate(0, -50%);
343      }
344
345      :host([placement="bottom"]) {
346        position: absolute;
347        top: calc(100% + var(--media-tooltip-distance, 12px));
348        left: 50%;
349        transform: translate(calc(-50% - var(--media-tooltip-offset-x, 0px)), 0);
350      }
351      :host([placement="bottom"]) #arrow {
352        bottom: 100%;
353        left: 50%;
354        border-width: 0 var(--_tooltip-arrow-half-width) var(--_tooltip-arrow-height) var(--_tooltip-arrow-half-width);
355        border-color: transparent transparent var(--_tooltip-arrow-background) transparent;
356        transform: translate(calc(-50% + var(--media-tooltip-offset-x, 0px)), 0);
357      }
358
359      :host([placement="left"]) {
360        position: absolute;
361        right: calc(100% + var(--media-tooltip-distance, 12px));
362        top: 50%;
363        transform: translate(0, -50%);
364      }
365      :host([placement="left"]) #arrow {
366        top: 50%;
367        left: 100%;
368        border-width: var(--_tooltip-arrow-half-width) 0 var(--_tooltip-arrow-half-width) var(--_tooltip-arrow-height);
369        border-color: transparent transparent transparent var(--_tooltip-arrow-background);
370        transform: translate(0, -50%);
371      }
372      
373      :host([placement="none"]) #arrow {
374        display: none;
375      }
376    </style>
377    <slot></slot>
378    <div id="arrow"></div>
379  `},m$.customElements.get("media-tooltip")||m$.customElements.define("media-tooltip",pO);var pN=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},pU=(e,t,i)=>(pN(e,t,"read from private field"),i?i.call(e):t.get(e)),pF=(e,t,i)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,i)},pB=(e,t,i,r)=>(pN(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i);let p$="tooltipplacement",pH="disabled",pG="notooltip";class pW extends m$.HTMLElement{constructor(){if(super(),pF(this,bo),pF(this,br,void 0),this.preventClick=!1,this.tooltipEl=null,pF(this,ba,e=>{this.preventClick||this.handleClick(e),setTimeout(pU(this,bs),0)}),pF(this,bs,()=>{var e,t;null==(t=null==(e=this.tooltipEl)?void 0:e.updateXOffset)||t.call(e)}),pF(this,bn,e=>{let{key:t}=e;this.keysUsed.includes(t)?this.preventClick||this.handleClick(e):this.removeEventListener("keyup",pU(this,bn))}),pF(this,bl,e=>{let{metaKey:t,altKey:i,key:r}=e;t||i||!this.keysUsed.includes(r)?this.removeEventListener("keyup",pU(this,bn)):this.addEventListener("keyup",pU(this,bn),{once:!0})}),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);const e=mj(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",p$,mn.MEDIA_CONTROLLER,md.MEDIA_LANG]}enable(){this.addEventListener("click",pU(this,ba)),this.addEventListener("keydown",pU(this,bl)),this.tabIndex=0}disable(){this.removeEventListener("click",pU(this,ba)),this.removeEventListener("keydown",pU(this,bl)),this.removeEventListener("keyup",pU(this,bn)),this.tabIndex=-1}attributeChangedCallback(e,t,i){var r,a,s,n,l;e===mn.MEDIA_CONTROLLER?(t&&(null==(a=null==(r=pU(this,br))?void 0:r.unassociateElement)||a.call(r,this),pB(this,br,null)),i&&this.isConnected&&(pB(this,br,null==(s=this.getRootNode())?void 0:s.getElementById(i)),null==(l=null==(n=pU(this,br))?void 0:n.associateElement)||l.call(n,this))):"disabled"===e&&i!==t?null==i?this.enable():this.disable():e===p$&&this.tooltipEl&&i!==t?this.tooltipEl.placement=i:e===md.MEDIA_LA
379NG&&(this.shadowRoot.querySelector('slot[name="tooltip-content"]').innerHTML=this.constructor.getTooltipContentHTML()),pU(this,bs).call(this)}connectedCallback(){var e,t,i;let{style:r}=m3(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(mn.MEDIA_CONTROLLER);a&&(pB(this,br,null==(e=this.getRootNode())?void 0:e.getElementById(a)),null==(i=null==(t=pU(this,br))?void 0:t.associateElement)||i.call(t,this)),m$.customElements.whenDefined("media-tooltip").then(()=>{var e,t;return(e=bo,t=bd,pN(this,e,"access private method"),t).call(this)})}disconnectedCallback(){var e,t;this.disable(),null==(t=null==(e=pU(this,br))?void 0:e.unassociateElement)||t.call(e,this),pB(this,br,null),this.removeEventListener("mouseenter",pU(this,bs)),this.removeEventListener("focus",pU(this,bs)),this.removeEventListener("click",pU(this,ba))}get keysUsed(){return["Enter"," "]}get tooltipPlacement(){return m7(this,p$)}set tooltipPlacement(e){fe(this,p$,e)}get mediaController(){return m7(this,mn.MEDIA_CONTROLLER)}set mediaController(e){fe(this,mn.MEDIA_CONTROLLER,e)}get disabled(){return m6(this,pH)}set disabled(e){m9(this,pH,e)}get noTooltip(){return m6(this,pG)}set noTooltip(e){m9(this,pG,e)}handleClick(e){}}br=new WeakMap,ba=new WeakMap,bs=new WeakMap,bn=new WeakMap,bl=new WeakMap,bo=new WeakSet,bd=function(){this.addEventListener("mouseenter",pU(this,bs)),this.addEventListener("focus",pU(this,bs)),this.addEventListener("click",pU(this,ba));let e=this.tooltipPlacement;e&&this.tooltipEl&&(this.tooltipEl.placement=e)},pW.shadowRootOptions={mode:"open"},pW.getTemplateHTML=function(e,t={}){return`
380    <style>
381      :host {
382        position: relative;
383        font: var(--media-font,
384          var(--media-font-weight, bold)
385          var(--media-font-size, 14px) /
386          var(--media-text-content-height, var(--media-control-height, 24px))
387          var(--media-font-family, helvetica neue, segoe ui, roboto, arial, sans-serif));
388        color: var(--media-text-color, var(--media-primary-color, rgb(238 238 238)));
389        background: var(--media-control-background, var(--media-secondary-color, rgb(20 20 30 / .7)));
390        padding: var(--media-button-padding, var(--media-control-padding, 10px));
391        justify-content: var(--media-button-justify-content, center);
392        display: inline-flex;
393        align-items: center;
394        vertical-align: middle;
395        box-sizing: border-box;
396        transition: background .15s linear;
397        pointer-events: auto;
398        cursor: var(--media-cursor, pointer);
399        -webkit-tap-highlight-color: transparent;
400      }
401
402      
403      :host(:focus-visible) {
404        box-shadow: var(--media-focus-box-shadow, inset 0 0 0 2px rgb(27 127 204 / .9));
405        outline: 0;
406      }
407      
408      :host(:where(:focus)) {
409        box-shadow: none;
410        outline: 0;
411      }
412
413      :host(:hover) {
414        background: var(--media-control-hover-background, rgba(50 50 70 / .7));
415      }
416
417      slot[name="icon"] {
418        display: inline-flex;
419        align-items: center;
420      }
421
422      svg, img, ::slotted(svg), ::slotted(img) {
423        width: var(--media-button-icon-width);
424        height: var(--media-button-icon-height, var(--media-control-height, 24px));
425        transform: var(--media-button-icon-transform);
426        transition: var(--media-button-icon-transition);
427        fill: var(--media-icon-color, var(--media-primary-color, rgb(238 238 238)));
428        vertical-align: middle;
429        max-width: 100%;
430        max-height: 100%;
431        min-width: 100%;
432      }
433
434      media-tooltip {
435        
436        max-width: 0;
437        overflow-x: clip;
438        opacity: 0;
439        transition: opacity .3s, max-width 0s 9s;
440      }
441
442      :host(:hover) media-tooltip,
443      :host(:focus-visible) media-tooltip {
444        max-width: 100vw;
445        opacity: 1;
446        transition: opacity .3s;
447      }
448
449      :host([notooltip]) slot[name="tooltip"] {
450        display: none;
451      }
452    </style>
453
454    ${this.getSlotTemplateHTML(e,t)}
455
456    <slot name="tooltip">
457      <media-tooltip part="tooltip" aria-hidden="true">
458        <template shadowrootmode="${pO.shadowRootOptions.mode}">
459          ${pO.getTemplateHTML({})}
460        </template>
461        <slot name="tooltip-content">
462          ${this.getTooltipContentHTML(e)}
463        </slot>
464      </media-tooltip>
465    </slot>
466  `},pW.getSlotTemplateHTML=function(e,t){return`
467    <slot></slot>
468  `},pW.getTooltipContentHTML=function(){return""},m$.customElements.get("media-chrome-button")||m$.customElements.define("media-chrome-button",pW);let pK=`<svg aria-hidden="true" viewBox="0 0 26 24">
469  <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"/>
470</svg>
471`,pV=e=>{let t=e.mediaIsAirplaying?mI("stop airplay"):mI("start airplay");e.setAttribute("aria-label",t)};class pq extends pW{static get observedAttributes(){return[...super.observedAttributes,md.MEDIA_IS_AIRPLAYING,md.MEDIA_AIRPLAY_UNAVAILABLE]}connectedCallback(){super.connectedCallback(),pV(this)}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===md.MEDIA_IS_AIRPLAYING&&pV(this)}get mediaIsAirplaying(){return m6(this,md.MEDIA_IS_AIRPLAYING)}set mediaIsAirplaying(e){m9(this,md.MEDIA_IS_AIRPLAYING,e)}get mediaAirplayUnavailable(){return m7(this,md.MEDIA_AIRPLAY_UNAVAILABLE)}set mediaAirplayUnavailable(e){fe(this,md.MEDIA_AIRPLAY_UNAVAILABLE,e)}handleClick(){let e=new m$.CustomEvent(ms.MEDIA_AIRPLAY_REQUEST,{composed:!0,bubbles:!0});this.dispatchEvent(e)}}pq.getSlotTemplateHTML=function(e){return`
472    <style>
473      :host([${md.MEDIA_IS_AIRPLAYING}]) slot[name=icon] slot:not([name=exit]) {
474        display: none !important;
475      }
476
477      
478      :host(:not([${md.MEDIA_IS_AIRPLAYING}])) slot[name=icon] slot:not([name=enter]) {
479        display: none !important;
480      }
481
482      :host([${md.MEDIA_IS_AIRPLAYING}]) slot[name=tooltip-enter],
483      :host(:not([${md.MEDIA_IS_AIRPLAYING}])) slot[name=tooltip-exit] {
484        display: none;
485      }
486    </style>
487
488    <slot name="icon">
489      <slot name="enter">${pK}</slot>
490      <slot name="exit">${pK}</slot>
491    </slot>
492  `},pq.getTooltipContentHTML=function(){return`
493    <slot name="tooltip-enter">${mI("start airplay")}</slot>
494    <slot name="tooltip-exit">${mI("stop airplay")}</slot>
495  `},m$.customElements.get("media-airplay-button")||m$.customElements.define("media-airplay-button",pq);let pj=`<svg aria-hidden="true" viewBox="0 0 26 24">
496  <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"/>
497</svg>`,pY=`<svg aria-hidden="true" viewBox="0 0 26 24">
498  <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.8
4981 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"/>
499</svg>`,pz=e=>{e.setAttribute("aria-checked",fP(e).toString())};class pQ extends pW{static get observedAttributes(){return[...super.observedAttributes,md.MEDIA_SUBTITLES_LIST,md.MEDIA_SUBTITLES_SHOWING]}connectedCallback(){super.connectedCallback(),this.setAttribute("role","button"),this.setAttribute("aria-label",mI("closed captions")),pz(this)}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===md.MEDIA_SUBTITLES_SHOWING&&pz(this)}get mediaSubtitlesList(){return pX(this,md.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){pZ(this,md.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return pX(this,md.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){pZ(this,md.MEDIA_SUBTITLES_SHOWING,e)}handleClick(){this.dispatchEvent(new m$.CustomEvent(ms.MEDIA_TOGGLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0}))}}pQ.getSlotTemplateHTML=function(e){return`
500    <style>
501      :host([aria-checked="true"]) slot[name=off] {
502        display: none !important;
503      }
504
505      
506      :host(:not([aria-checked="true"])) slot[name=on] {
507        display: none !important;
508      }
509
510      :host([aria-checked="true"]) slot[name=tooltip-enable],
511      :host(:not([aria-checked="true"])) slot[name=tooltip-disable] {
512        display: none;
513      }
514    </style>
515
516    <slot name="icon">
517      <slot name="on">${pj}</slot>
518      <slot name="off">${pY}</slot>
519    </slot>
520  `},pQ.getTooltipContentHTML=function(){return`
521    <slot name="tooltip-enable">${mI("Enable captions")}</slot>
522    <slot name="tooltip-disable">${mI("Disable captions")}</slot>
523  `};let pX=(e,t)=>{let i=e.getAttribute(t);return i?fL(i):[]},pZ=(e,t,i)=>{if(!(null==i?void 0:i.length))return void e.removeAttribute(t);let r=fD(i);e.getAttribute(t)!==r&&e.setAttribute(t,r)};m$.customElements.get("media-captions-button")||m$.customElements.define("media-captions-button",pQ);let pJ=e=>{let t=e.mediaIsCasting?mI("stop casting"):mI("start casting");e.setAttribute("aria-label",t)};class p0 extends pW{static get observedAttributes(){return[...super.observedAttributes,md.MEDIA_IS_CASTING,md.MEDIA_CAST_UNAVAILABLE]}connectedCallback(){super.connectedCallback(),pJ(this)}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===md.MEDIA_IS_CASTING&&pJ(this)}get mediaIsCasting(){return m6(this,md.MEDIA_IS_CASTING)}set mediaIsCasting(e){m9(this,md.MEDIA_IS_CASTING,e)}get mediaCastUnavailable(){return m7(this,md.MEDIA_CAST_UNAVAILABLE)}set mediaCastUnavailable(e){fe(this,md.MEDIA_CAST_UNAVAILABLE,e)}handleClick(){let e=this.mediaIsCasting?ms.MEDIA_EXIT_CAST_REQUEST:ms.MEDIA_ENTER_CAST_REQUEST;this.dispatchEvent(new m$.CustomEvent(e,{composed:!0,bubbles:!0}))}}p0.getSlotTemplateHTML=function(e){return`
524    <style>
525      :host([${md.MEDIA_IS_CASTING}]) slot[name=icon] slot:not([name=exit]) {
526        display: none !important;
527      }
528
529      
530      :host(:not([${md.MEDIA_IS_CASTING}])) slot[name=icon] slot:not([name=enter]) {
531        display: none !important;
532      }
533
534      :host([${md.MEDIA_IS_CASTING}]) slot[name=tooltip-enter],
535      :host(:not([${md.MEDIA_IS_CASTING}])) slot[name=tooltip-exit] {
536        display: none;
537      }
538    </style>
539
540    <slot name="icon">
541      <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>
542      <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>
543    </slot>
544  `},p0.getTooltipContentHTML=function(){return`
545    <slot name="tooltip-enter">${mI("Start casting")}</slot>
546    <slot name="tooltip-exit">${mI("Stop casting")}</slot>
547  `},m$.customElements.get("media-cast-button")||m$.customElements.define("media-cast-button",p0);var p1=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},p2=(e,t,i)=>(p1(e,t,"read from private field"),i?i.call(e):t.get(e)),p3=(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)},p4=(e,t,i,r)=>(p1(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i),p5=(e,t,i)=>(p1(e,t,"access private method"),i);let p8="open";class p6 extends m$.HTMLElement{constructor(){super(),p3(this,bm),p3(this,bp),p3(this,bv),p3(this,by),p3(this,bT),p3(this,b_),p3(this,bh,!1),p3(this,bu,null),p3(this,bc,null)}static get observedAttributes(){return[p8,"anchor"]}get open(){return m6(this,p8)}set open(e){m9(this,p8,e)}handleEvent(e){switch(e.type){case"invoke":p5(this,by,bb).call(this,e);break;case"focusout":p5(this,bT,bA).call(this,e);break;case"keydown":p5(this,b_,bS).call(this,e)}}connectedCallback(){p5(this,bm,bf).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){p5(this,bm,bf).call(this),e===p8&&i!==t&&(this.open?p5(this,bp,bg).call(this):p5(this,bv,bE).call(this))}focus(){p4(this,bu,m0());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;
547let i=this.querySelector('[autofocus], [tabindex]:not([tabindex="-1"]), [role="menu"]');null==i||i.focus()}get keysUsed(){return["Escape","Tab"]}}bh=new WeakMap,bu=new WeakMap,bc=new WeakMap,bm=new WeakSet,bf=function(){if(!p2(this,bh)&&(p4(this,bh,!0),!this.shadowRoot)){this.attachShadow(this.constructor.shadowRootOptions);let e=mj(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e),queueMicrotask(()=>{let{style:e}=m3(this.shadowRoot,":host");e.setProperty("transition","display .15s, visibility .15s, opacity .15s ease-in, transform .15s ease-in")})}},bp=new WeakSet,bg=function(){var e;null==(e=p2(this,bc))||e.setAttribute("aria-expanded","true"),this.dispatchEvent(new Event("open",{composed:!0,bubbles:!0})),this.addEventListener("transitionend",()=>this.focus(),{once:!0})},bv=new WeakSet,bE=function(){var e;null==(e=p2(this,bc))||e.setAttribute("aria-expanded","false"),this.dispatchEvent(new Event("close",{composed:!0,bubbles:!0}))},by=new WeakSet,bb=function(e){p4(this,bc,e.relatedTarget),mZ(this,e.relatedTarget)||(this.open=!this.open)},bT=new WeakSet,bA=function(e){var t;!mZ(this,e.relatedTarget)&&(null==(t=p2(this,bu))||t.focus(),p2(this,bc)&&p2(this,bc)!==e.relatedTarget&&this.open&&(this.open=!1))},b_=new WeakSet,bS=function(e){var t,i,r,a,s;let{key:n,ctrlKey:l,altKey:o,metaKey:d}=e;l||o||d||this.keysUsed.includes(n)&&(e.preventDefault(),e.stopPropagation(),"Tab"===n?(e.shiftKey?null==(i=null==(t=this.previousElementSibling)?void 0:t.focus)||i.call(t):null==(a=null==(r=this.nextElementSibling)?void 0:r.focus)||a.call(r),this.blur()):"Escape"===n&&(null==(s=p2(this,bu))||s.focus(),this.open=!1))},p6.shadowRootOptions={mode:"open"},p6.getTemplateHTML=function(e){return`
548    <style>
549      :host {
550        font: var(--media-font,
551          var(--media-font-weight, normal)
552          var(--media-font-size, 14px) /
553          var(--media-text-content-height, var(--media-control-height, 24px))
554          var(--media-font-family, helvetica neue, segoe ui, roboto, arial, sans-serif));
555        color: var(--media-text-color, var(--media-primary-color, rgb(238 238 238)));
556        display: var(--media-dialog-display, inline-flex);
557        justify-content: center;
558        align-items: center;
559        
560        transition-behavior: allow-discrete;
561        visibility: hidden;
562        opacity: 0;
563        transform: translateY(2px) scale(.99);
564        pointer-events: none;
565      }
566
567      :host([open]) {
568        transition: display .2s, visibility 0s, opacity .2s ease-out, transform .15s ease-out;
569        visibility: visible;
570        opacity: 1;
571        transform: translateY(0) scale(1);
572        pointer-events: auto;
573      }
574
575      #content {
576        display: flex;
577        position: relative;
578        box-sizing: border-box;
579        width: min(320px, 100%);
580        word-wrap: break-word;
581        max-height: 100%;
582        overflow: auto;
583        text-align: center;
584        line-height: 1.4;
585      }
586    </style>
587    ${this.getSlotTemplateHTML(e)}
588  `},p6.getSlotTemplateHTML=function(e){return`
589    <slot id="content"></slot>
590  `},m$.customElements.get("media-chrome-dialog")||m$.customElements.define("media-chrome-dialog",p6);var p9=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},p7=(e,t,i)=>(p9(e,t,"read from private field"),i?i.call(e):t.get(e)),ge=(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)},gt=(e,t,i,r)=>(p9(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i),gi=(e,t,i)=>(p9(e,t,"access private method"),i);class gr extends m$.HTMLElement{constructor(){if(super(),ge(this,bP),ge(this,bN),ge(this,bF),ge(this,b$),ge(this,bG),ge(this,bK),ge(this,bq),ge(this,bY),ge(this,bk,void 0),ge(this,bR,void 0),ge(this,bL,void 0),ge(this,bI,void 0),ge(this,bw,{}),ge(this,bD,[]),ge(this,bC,()=>{if(this.range.matches(":focus-visible")){let{style:e}=m3(this.shadowRoot,":host");e.setProperty("--_focus-visible-box-shadow","var(--_focus-box-shadow)")}}),ge(this,bM,()=>{let{style:e}=m3(this.shadowRoot,":host");e.removeProperty("--_focus-visible-box-shadow")}),ge(this,bx,()=>{let e=this.shadowRoot.querySelector("#segments-clipping");e&&e.parentNode.append(e)}),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);const e=mj(this.attributes),t=this.constructor.getTemplateHTML(e);this.shadowRoot.setHTMLUnsafe?this.shadowRoot.setHTMLUnsafe(t):this.shadowRoot.innerHTML=t}this.container=this.shadowRoot.querySelector("#container"),gt(this,bL,this.shadowRoot.querySelector("#startpoint")),gt(this,bI,this.shadowRoot.querySelector("#endpoint")),this.range=this.shadowRoot.querySelector("#range"),this.appearance=this.shadowRoot.querySelector("#appearance")}static get observedAttributes(){return["disabled","aria-disabled",mn.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,i){var r,a,s,n,l;e===mn.MEDIA_CONTROLLER?(t&&(null==(a=null==(r=p7(this,bk))?void 0:r.unassociateElement)||a.call(r,this),gt(this,bk,null)),i&&this.isConnected&&(gt(this,bk,null==(s=this.getRootNode())?void 0:s.getElementById(i)),null==(l=null==(n=p7(this,bk))?void 0:n.associateElement)||l.call(n,this))):("disabled"===e||"aria-disabled"===e&&t!==i)&&(null==i?(this.range.removeAttribute(e),gi(this,bN,bU).call(this)):(this.range.setAttribute(e,i),gi(this,bF,bB).call(this)))}connectedCallback(){var e,t,i;let{style:r}=m3(this.shadowRoot,":host");r.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`),p7(this,bw).pointer=m3(this.shadowRoot,"#pointer"),p7(this,bw).progress=m3(this.shadowRoot,"#progress"),p7(this,bw).thumb=m3(this.shadowRoot,'#thumb, ::slotted([slot="thumb"])'),p7(this,bw).activeSegment=m3(this.shadowRoot,"#segments-clipping rect:nth-child(0)");let a=this.getAttribute(mn.MEDIA_CONTROLLER);a&&(gt(this,bk,null==(e=this.getRootNode())?void 0:e.getElementById(a)),null==(i=null==(t=p7(this,bk))?void 0:t.associateElement)||i.call(t,this)),this.updateBar(),this.shadowRoot.addEventListener("focusin",p7(this,bC)
590),this.shadowRoot.addEventListener("focusout",p7(this,bM)),gi(this,bN,bU).call(this),mV(this.container,p7(this,bx))}disconnectedCallback(){var e,t;gi(this,bF,bB).call(this),null==(t=null==(e=p7(this,bk))?void 0:e.unassociateElement)||t.call(e,this),gt(this,bk,null),this.shadowRoot.removeEventListener("focusin",p7(this,bC)),this.shadowRoot.removeEventListener("focusout",p7(this,bM)),mq(this.container,p7(this,bx))}updatePointerBar(e){var t;null==(t=p7(this,bw).pointer)||t.style.setProperty("width",`${100*this.getPointerRatio(e)}%`)}updateBar(){var e,t;let i=100*this.range.valueAsNumber;null==(e=p7(this,bw).progress)||e.style.setProperty("width",`${i}%`),null==(t=p7(this,bw).thumb)||t.style.setProperty("left",`${i}%`)}updateSegments(e){let t=this.shadowRoot.querySelector("#segments-clipping");if(t.textContent="",this.container.classList.toggle("segments",!!(null==e?void 0:e.length)),!(null==e?void 0:e.length))return;let i=[...new Set([+this.range.min,...e.flatMap(e=>[e.start,e.end]),+this.range.max])];gt(this,bD,[...i]);let r=i.pop();for(let[e,a]of i.entries()){let[s,n]=[0===e,e===i.length-1],l=s?"calc(var(--segments-gap) / -1)":`${100*a}%`,o=n?r:i[e+1],d=`calc(${(o-a)*100}%${s||n?"":" - var(--segments-gap)"})`,h=mH.createElementNS("http://www.w3.org/2000/svg","rect"),u=m4(this.shadowRoot,`#segments-clipping rect:nth-child(${e+1})`);u.style.setProperty("x",l),u.style.setProperty("width",d),t.append(h)}}getPointerRatio(e){var t,i,r,a;let s,n,l;return t=e.clientX,i=e.clientY,r=p7(this,bL).getBoundingClientRect(),s=(a=p7(this,bI).getBoundingClientRect()).x-r.x,0==(l=s*s+(n=a.y-r.y)*n)?0:Math.max(0,Math.min(1,((t-r.x)*s+(i-r.y)*n)/l))}get dragging(){return this.hasAttribute("dragging")}handleEvent(e){switch(e.type){case"pointermove":gi(this,bY,bz).call(this,e);break;case"input":this.updateBar();break;case"pointerenter":gi(this,bG,bW).call(this,e);break;case"pointerdown":gi(this,b$,bH).call(this,e);break;case"pointerup":gi(this,bK,bV).call(this);break;case"pointerleave":gi(this,bq,bj).call(this)}}get keysUsed(){return["ArrowUp","ArrowRight","ArrowDown","ArrowLeft"]}}bk=new WeakMap,bR=new WeakMap,bL=new WeakMap,bI=new WeakMap,bw=new WeakMap,bD=new WeakMap,bC=new WeakMap,bM=new WeakMap,bx=new WeakMap,bP=new WeakSet,bO=function(e){let t=p7(this,bw).activeSegment;if(!t)return;let i=this.getPointerRatio(e),r=p7(this,bD).findIndex((e,t,r)=>{let a=r[t+1];return null!=a&&i>=e&&i<=a}),a=`#segments-clipping rect:nth-child(${r+1})`;t.selectorText==a&&t.style.transform||(t.selectorText=a,t.style.setProperty("transform","var(--media-range-segment-hover-transform, scaleY(2))"))},bN=new WeakSet,bU=function(){!this.hasAttribute("disabled")&&this.isConnected&&(this.addEventListener("input",this),this.addEventListener("pointerdown",this),this.addEventListener("pointerenter",this))},bF=new WeakSet,bB=function(){var e,t;this.removeEventListener("input",this),this.removeEventListener("pointerdown",this),this.removeEventListener("pointerenter",this),this.removeEventListener("pointerleave",this),null==(e=m$.window)||e.removeEventListener("pointerup",this),null==(t=m$.window)||t.removeEventListener("pointermove",this)},b$=new WeakSet,bH=function(e){var t;gt(this,bR,e.composedPath().includes(this.range)),null==(t=m$.window)||t.addEventListener("pointerup",this,{once:!0})},bG=new WeakSet,bW=function(e){var t;"mouse"!==e.pointerType&&gi(this,b$,bH).call(this,e),this.addEventListener("pointerleave",this,{once:!0}),null==(t=m$.window)||t.addEventListener("pointermove",this)},bK=new WeakSet,bV=function(){var e;null==(e=m$.window)||e.removeEventListener("pointerup",this),this.toggleAttribute("dragging",!1),this.range.disabled=this.hasAttribute("disabled")},bq=new WeakSet,bj=function(){var e,t;this.removeEventListener("pointerleave",this),null==(e=m$.window)||e.removeEventListener("pointermove",this),this.toggleAttribute("dragging",!1),this.range.disabled=this.hasAttribute("disabled"),null==(t=p7(this,bw).activeSegment)||t.style.removeProperty("transform")},bY=new WeakSet,bz=function(e){("pen"!==e.pointerType||0!==e.buttons)&&(this.toggleAttribute("dragging",1===e.buttons||"mouse"!==e.pointerType),this.updatePointerBar(e),gi(this,bP,bO).call(this,e),this.dragging&&("mouse"!==e.pointerType||!p7(this,bR))&&(this.range.disabled=!0,this.range.valueAsNumber=this.getPointerRatio(e),this.range.dispatchEvent(new Event("input",{bubbles:!0,composed:!0}))))},gr.shadowRootOptions={mode:"open"},gr.getTemplateHTML=function(e){return
vendor: 7,165 bytes, lines 590-826
590`
591    <style>
592      :host {
593        --_focus-box-shadow: var(--media-focus-box-shadow, inset 0 0 0 2px rgb(27 127 204 / .9));
594        --_media-range-padding: var(--media-range-padding, var(--media-control-padding, 10px));
595
596        box-shadow: var(--_focus-visible-box-shadow, none);
597        background: var(--media-control-background, var(--media-secondary-color, rgb(20 20 30 / .7)));
598        height: calc(var(--media-control-height, 24px) + 2 * var(--_media-range-padding));
599        display: inline-flex;
600        align-items: center;
601        
602        vertical-align: middle;
603        box-sizing: border-box;
604        position: relative;
605        width: 100px;
606        transition: background .15s linear;
607        cursor: var(--media-cursor, pointer);
608        pointer-events: auto;
609        touch-action: none; 
610      }
611
612      
613      input[type=range]:focus {
614        outline: 0;
615      }
616      input[type=range]:focus::-webkit-slider-runnable-track {
617        outline: 0;
618      }
619
620      :host(:hover) {
621        background: var(--media-control-hover-background, rgb(50 50 70 / .7));
622      }
623
624      #leftgap {
625        padding-left: var(--media-range-padding-left, var(--_media-range-padding));
626      }
627
628      #rightgap {
629        padding-right: var(--media-range-padding-right, var(--_media-range-padding));
630      }
631
632      #startpoint,
633      #endpoint {
634        position: absolute;
635      }
636
637      #endpoint {
638        right: 0;
639      }
640
641      #container {
642        
643        width: var(--media-range-track-width, 100%);
644        transform: translate(var(--media-range-track-translate-x, 0px), var(--media-range-track-translate-y, 0px));
645        position: relative;
646        height: 100%;
647        display: flex;
648        align-items: center;
649        min-width: 40px;
650      }
651
652      #range {
653        
654        display: var(--media-time-range-hover-display, block);
655        bottom: var(--media-time-range-hover-bottom, 0);
656        height: var(--media-time-range-hover-height, max(100% , 25px));
657        width: 100%;
658        position: absolute;
659        cursor: var(--media-cursor, pointer);
660
661        -webkit-appearance: none; 
662        -webkit-tap-highlight-color: transparent;
663        background: transparent; 
664        margin: 0;
665        z-index: 1;
666      }
667
668      @media (hover: hover) {
669        #range {
670          bottom: var(--media-time-range-hover-bottom, 0);
671          height: var(--media-time-range-hover-height, max(100%, 20px));
672        }
673      }
674
675      
676      
677      #range::-webkit-slider-thumb {
678        -webkit-appearance: none;
679        background: transparent;
680        width: .1px;
681        height: .1px;
682      }
683
684      
685      #range::-moz-range-thumb {
686        background: transparent;
687        border: transparent;
688        width: .1px;
689        height: .1px;
690      }
691
692      #appearance {
693        height: var(--media-range-track-height, 4px);
694        display: flex;
695        flex-direction: column;
696        justify-content: center;
697        width: 100%;
698        position: absolute;
699        
700        will-change: transform;
701      }
702
703      #track {
704        background: var(--media-range-track-background, rgb(255 255 255 / .2));
705        border-radius: var(--media-range-track-border-radius, 1px);
706        border: var(--media-range-track-border, none);
707        outline: var(--media-range-track-outline);
708        outline-offset: var(--media-range-track-outline-offset);
709        backdrop-filter: var(--media-range-track-backdrop-filter);
710        -webkit-backdrop-filter: var(--media-range-track-backdrop-filter);
711        box-shadow: var(--media-range-track-box-shadow, none);
712        position: absolute;
713        width: 100%;
714        height: 100%;
715        overflow: hidden;
716      }
717
718      #progress,
719      #pointer {
720        position: absolute;
721        height: 100%;
722        will-change: width;
723      }
724
725      #progress {
726        background: var(--media-range-bar-color, var(--media-primary-color, rgb(238 238 238)));
727        transition: var(--media-range-track-transition);
728      }
729
730      #pointer {
731        background: var(--media-range-track-pointer-background);
732        border-right: var(--media-range-track-pointer-border-right);
733        transition: visibility .25s, opacity .25s;
734        visibility: hidden;
735        opacity: 0;
736      }
737
738      @media (hover: hover) {
739        :host(:hover) #pointer {
740          transition: visibility .5s, opacity .5s;
741          visibility: visible;
742          opacity: 1;
743        }
744      }
745
746      #thumb,
747      ::slotted([slot=thumb]) {
748        width: var(--media-range-thumb-width, 10px);
749        height: var(--media-range-thumb-height, 10px);
750        transition: var(--media-range-thumb-transition);
751        transform: var(--media-range-thumb-transform, none);
752        opacity: var(--media-range-thumb-opacity, 1);
753        translate: -50%;
754        position: absolute;
755        left: 0;
756        cursor: var(--media-cursor, pointer);
757      }
758
759      #thumb {
760        border-radius: var(--media-range-thumb-border-radius, 10px);
761        background: var(--media-range-thumb-background, var(--media-primary-color, rgb(238 238 238)));
762        box-shadow: var(--media-range-thumb-box-shadow, 1px 1px 1px transparent);
763        border: var(--media-range-thumb-border, none);
764      }
765
766      :host([disabled]) #thumb {
767        background-color: #777;
768      }
769
770      .segments #appearance {
771        height: var(--media-range-segment-hover-height, 7px);
772      }
773
774      #track {
775        clip-path: url(#segments-clipping);
776      }
777
778      #segments {
779        --segments-gap: var(--media-range-segments-gap, 2px);
780        position: absolute;
781        width: 100%;
782        height: 100%;
783      }
784
785      #segments-clipping {
786        transform: translateX(calc(var(--segments-gap) / 2));
787      }
788
789      #segments-clipping:empty {
790        display: none;
791      }
792
793      #segments-clipping rect {
794        height: var(--media-range-track-height, 4px);
795        y: calc((var(--media-range-segment-hover-height, 7px) - var(--media-range-track-height, 4px)) / 2);
796        transition: var(--media-range-segment-transition, transform .1s ease-in-out);
797        transform: var(--media-range-segment-transform, scaleY(1));
798        transform-origin: center;
799      }
800
801      /* Visible label for accessibility - positioned off-screen but technically visible (Firefox requires visible labels) */
802      #range-label {
803        position: absolute;
804        left: -10000px;
805        background: var(--media-control-background, var(--media-secondary-color, rgb(20 20 30 / .7)));
806        pointer-events: none;
807      }
808    </style>
809    <div id="leftgap"></div>
810    <div id="container">
811      <div id="startpoint"></div>
812      <div id="endpoint"></div>
813      <div id="appearance">
814        <div id="track" part="track">
815          <div id="pointer"></div>
816          <div id="progress" part="progress"></div>
817        </div>
818        <slot name="thumb">
819          <div id="thumb" part="thumb"></div>
820        </slot>
821        <svg id="segments" aria-hidden="true"><clipPath id="segments-clipping"></clipPath></svg>
822      </div>
823        <input id="range" type="range" min="0" max="1" step="any" value="0">
824        <label for="range" id="range-label"></label>
825
826      ${this.getContainerTemplateHTML(
826e)}
827    </div>
828    <div id="rightgap"></div>
829  `},gr.getContainerTemplateHTML=function(e){return""},m$.customElements.get("media-chrome-range")||m$.customElements.define("media-chrome-range",gr);var ga=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},gs=(e,t,i)=>(ga(e,t,"read from private field"),i?i.call(e):t.get(e)),gn=(e,t,i,r)=>(ga(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i);class gl extends m$.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,bQ,void 0),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);const e=mj(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e)}}static get observedAttributes(){return[mn.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,i){var r,a,s,n,l;e===mn.MEDIA_CONTROLLER&&(t&&(null==(a=null==(r=gs(this,bQ))?void 0:r.unassociateElement)||a.call(r,this),gn(this,bQ,null)),i&&this.isConnected&&(gn(this,bQ,null==(s=this.getRootNode())?void 0:s.getElementById(i)),null==(l=null==(n=gs(this,bQ))?void 0:n.associateElement)||l.call(n,this)))}connectedCallback(){var e,t,i;let r=this.getAttribute(mn.MEDIA_CONTROLLER);r&&(gn(this,bQ,null==(e=this.getRootNode())?void 0:e.getElementById(r)),null==(i=null==(t=gs(this,bQ))?void 0:t.associateElement)||i.call(t,this))}disconnectedCallback(){var e,t;null==(t=null==(e=gs(this,bQ))?void 0:e.unassociateElement)||t.call(e,this),gn(this,bQ,null)}}bQ=new WeakMap,gl.shadowRootOptions={mode:"open"},gl.getTemplateHTML=function(e){return`
830    <style>
831      :host {
832        
833        box-sizing: border-box;
834        display: var(--media-control-display, var(--media-control-bar-display, inline-flex));
835        color: var(--media-text-color, var(--media-primary-color, rgb(238 238 238)));
836        --media-loading-indicator-icon-height: 44px;
837      }
838
839      ::slotted(media-time-range),
840      ::slotted(media-volume-range) {
841        min-height: 100%;
842      }
843
844      ::slotted(media-time-range),
845      ::slotted(media-clip-selector) {
846        flex-grow: 1;
847      }
848
849      ::slotted([role="menu"]) {
850        position: absolute;
851      }
852    </style>
853
854    <slot></slot>
855  `},m$.customElements.get("media-control-bar")||m$.customElements.define("media-control-bar",gl);var go=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},gd=(e,t,i)=>(go(e,t,"read from private field"),i?i.call(e):t.get(e)),gh=(e,t,i,r)=>(go(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i);class gu extends m$.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,bX,void 0),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);const e=mj(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e)}}static get observedAttributes(){return[mn.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,i){var r,a,s,n,l;e===mn.MEDIA_CONTROLLER&&(t&&(null==(a=null==(r=gd(this,bX))?void 0:r.unassociateElement)||a.call(r,this),gh(this,bX,null)),i&&this.isConnected&&(gh(this,bX,null==(s=this.getRootNode())?void 0:s.getElementById(i)),null==(l=null==(n=gd(this,bX))?void 0:n.associateElement)||l.call(n,this)))}connectedCallback(){var e,t,i;let{style:r}=m3(this.shadowRoot,":host");r.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`);let a=this.getAttribute(mn.MEDIA_CONTROLLER);a&&(gh(this,bX,null==(e=this.getRootNode())?void 0:e.getElementById(a)),null==(i=null==(t=gd(this,bX))?void 0:t.associateElement)||i.call(t,this))}disconnectedCallback(){var e,t;null==(t=null==(e=gd(this,bX))?void 0:e.unassociateElement)||t.call(e,this),gh(this,bX,null)}}bX=new WeakMap,gu.shadowRootOptions={mode:"open"},gu.getTemplateHTML=function(e,t={}){return`
856    <style>
857      :host {
858        font: var(--media-font,
859          var(--media-font-weight, normal)
860          var(--media-font-size, 14px) /
861          var(--media-text-content-height, var(--media-control-height, 24px))
862          var(--media-font-family, helvetica neue, segoe ui, roboto, arial, sans-serif));
863        color: var(--media-text-color, var(--media-primary-color, rgb(238 238 238)));
864        background: var(--media-text-background, var(--media-control-background, var(--media-secondary-color, rgb(20 20 30 / .7))));
865        padding: var(--media-control-padding, 10px);
866        display: inline-flex;
867        justify-content: center;
868        align-items: center;
869        vertical-align: middle;
870        box-sizing: border-box;
871        text-align: center;
872        pointer-events: auto;
873      }
874
875      
876      :host(:focus-visible) {
877        box-shadow: var(--media-focus-box-shadow, inset 0 0 0 2px rgb(27 127 204 / .9));
878        outline: 0;
879      }
880
881      
882      :host(:where(:focus)) {
883        box-shadow: none;
884        outline: 0;
885      }
886    </style>
887
888    ${this.getSlotTemplateHTML(e,t)}
889  `},gu.getSlotTemplateHTML=function(e,t){return`
890    <slot></slot>
891  `},m$.customElements.get("media-text-display")||m$.customElements.define("media-text-display",gu);var gc=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},gm=(e,t,i)=>(gc(e,t,"read from private field"),i?i.call(e):t.get(e));class gf extends gu{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,bZ,void 0),((e,t,i,r)=>(gc(e,t,"write to private field"),r?r.call(e,i):t.set(e,i)))(this,bZ,this.shadowRoot.querySelector("slot")),gm(this,bZ).textContent=mC(null!=(e=this.mediaDuration)?e:0)}static get observedAttributes(){return[...super.observedAttributes,md.MEDIA_DURATION]}attributeChangedCallback(e,t,i){e===md.MEDIA_DURATION&&(gm(this,bZ).textContent=mC(+i)),super.attributeChangedCallback(e,t,i)}get mediaDuration(){return m5(this,md.MEDIA_DURATION)}set mediaDuration(e){m8(this,md.MEDIA_DURATION,e)}}bZ=new WeakMap,gf.getSlotTemplateHTML=function(e,t){return`
892    <slot>${mC(t.mediaDuration)}</slot>
893  `},m$.customElements.get("media-duration-display")||m$.customElements.define("media-duration-display",gf);let gp={2:mI("Network Error"),3:mI("Decode Error"),4:mI("Source Not Supported"),5:mI("Encryption 
893Error")},gg={2:mI("A network error caused the media download to fail."),3:mI("A media error caused playback to be aborted. The media could be corrupt or your browser does not support this format."),4:mI("An unsupported error occurred. The server or network failed, or your browser does not support this format."),5:mI("The media is encrypted and there are no keys to decrypt it.")},gv=e=>{var t,i;return 1===e.code?null:{title:null!=(t=gp[e.code])?t:`Error ${e.code}`,message:null!=(i=gg[e.code])?i:e.message}};var gE=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)};function gy(e){var t;let{title:i,message:r}=null!=(t=gv(e))?t:{},a="";return i&&(a+=`<slot name="error-${e.code}-title"><h3>${i}</h3></slot>`),r&&(a+=`<slot name="error-${e.code}-message"><p>${r}</p></slot>`),a}let gb=[md.MEDIA_ERROR_CODE,md.MEDIA_ERROR_MESSAGE];class gT extends p6{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,bJ,null)}static get observedAttributes(){return[...super.observedAttributes,...gb]}formatErrorMessage(e){return this.constructor.formatErrorMessage(e)}attributeChangedCallback(e,t,i){var r;if(super.attributeChangedCallback(e,t,i),!gb.includes(e))return;let a=null!=(r=this.mediaError)?r:{code:this.mediaErrorCode,message:this.mediaErrorMessage};if(this.open=a.code&&null!==gv(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}=gv(a);e&&this.setAttribute("aria-label",e)}}get mediaError(){var e,t;return gE(this,e=bJ,"read from private field"),t?t.call(this):e.get(this)}set mediaError(e){var t,i;gE(this,t=bJ,"write to private field"),i?i.call(this,e):t.set(this,e)}get mediaErrorCode(){return m5(this,"mediaerrorcode")}set mediaErrorCode(e){m8(this,"mediaerrorcode",e)}get mediaErrorMessage(){return m7(this,"mediaerrormessage")}set mediaErrorMessage(e){fe(this,"mediaerrormessage",e)}}bJ=new WeakMap,gT.getSlotTemplateHTML=function(e){return`
894    <style>
895      :host {
896        background: rgb(20 20 30 / .8);
897      }
898
899      #content {
900        display: block;
901        padding: 1.2em 1.5em;
902      }
903
904      h3,
905      p {
906        margin-block: 0 .3em;
907      }
908    </style>
909    <slot name="error-${e.mediaerrorcode}" id="content">
910      ${gy({code:+e.mediaerrorcode,message:e.mediaerrormessage})}
911    </slot>
912  `},gT.formatErrorMessage=gy,m$.customElements.get("media-error-dialog")||m$.customElements.define("media-error-dialog",gT);var gA=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot read from private field");return i?i.call(e):t.get(e)},g_=(e,t,i)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,i)};class gS extends p6{constructor(){super(...arguments),g_(this,b0,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),s=r.includes(i);a&&!s&&(this.open=!1)}),g_(this,b1,e=>{if(!this.open)return;let t=e.shiftKey&&("/"===e.key||"?"===e.key);"Escape"!==e.key&&!t||e.ctrlKey||e.altKey||e.metaKey||(this.open=!1,e.preventDefault(),e.stopPropagation())})}connectedCallback(){super.connectedCallback(),this.open&&(this.addEventListener("click",gA(this,b0)),document.addEventListener("keydown",gA(this,b1)))}disconnectedCallback(){this.removeEventListener("click",gA(this,b0)),document.removeEventListener("keydown",gA(this,b1))}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),"open"===e&&(this.open?(this.addEventListener("click",gA(this,b0)),document.addEventListener("keydown",gA(this,b1))):(this.removeEventListener("click",gA(this,b0)),document.removeEventListener("keydown",gA(this,b1))))}}b0=new WeakMap,b1=new WeakMap,gS.getSlotTemplateHTML=function(e){let t;return`
913    <style>
914      :host {
915        position: fixed;
916        top: 0;
917        left: 0;
918        z-index: 9999;
919        background: rgb(20 20 30 / .8);
920        backdrop-filter: blur(10px);
921      }
922
923      #content {
924        display: block;
925        width: clamp(400px, 40vw, 700px);
926        max-width: 90vw;
927        text-align: left;
928      }
929
930      h2 {
931        margin: 0 0 1.5rem 0;
932        font-size: 1.5rem;
933        font-weight: 500;
934        text-align: center;
935      }
936
937      .shortcuts-table {
938        width: 100%;
939        border-collapse: collapse;
940      }
941
942      .shortcuts-table tr {
943        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
944      }
945
946      .shortcuts-table tr:last-child {
947        border-bottom: none;
948      }
949
950      .shortcuts-table td {
951        padding: 0.75rem 0.5rem;
952      }
953
954      .shortcuts-table td:first-child {
955        text-align: right;
956        padding-right: 1rem;
957        width: 40%;
958        min-width: 120px;
959      }
960
961      .shortcuts-table td:last-child {
962        padding-left: 1rem;
963      }
964
965      .key {
966        display: inline-block;
967        background: rgba(255, 255, 255, 0.15);
968        border: 1px solid rgba(255, 255, 255, 0.2);
969        border-radius: 4px;
970        padding: 0.25rem 0.5rem;
971        font-family: 'Courier New', monospace;
972        font-size: 0.9rem;
973        font-weight: 500;
974        min-width: 1.5rem;
975        text-align: center;
976        margin: 0 0.2rem;
977      }
978
979      .description {
980        color: rgba(255, 255, 255, 0.9);
981        font-size: 0.95rem;
982      }
983
984      .key-combo {
985        display: flex;
986        align-items: center;
987        justify-content: flex-end;
988        gap: 0.3rem;
989      }
990
991      .key-separator {
992        color: rgba(255, 255, 255, 0.5);
993        font-size: 0.9rem;
994      }
995    </style>
996    <slot id="content">
997      ${t=[{keys:["Space","k"],description:"Toggle Playback"},{keys:["m"],description:"Toggle mute"},{keys:["f"],description:"Toggle fullscreen"},{keys:["c"],description:"Toggle captions or subtitles, if available"},{keys:["p"],description:"Toggle Picture in Picture"},{keys:["←","j"],description:"Seek back 10s"},{keys:["→","l"],description:"Seek forward 10s"},{keys:["↑"],description:"Turn volume up"},{keys:["↓"],description:"Turn volume down"},{keys:["< (SHIFT+,)"],description:"Decrease playback rate"},{keys:["> (SHIFT+.)"],description:"Increase playback rate"}].map(({keys:e,description:t})=>{let i=e.map((e,t)=>t>0?`<span class="key-separator">or</span><span class="key">${e}</span>`:`<span class="key">${e}</span>`).join("");return`
998      <tr>
999        <td>
1000          <div class="key-combo">${i}</div>
1001        </td>
1002        <td class="description">${t}</td>
1003      </tr>
1004    `}).join(""),`
1005    <h2>Keyboard Shortcuts</h2>
1006    <table class="shortcuts-table">${t}</table>
1007  `}
1008    </slot>
1009  `},m$.customElements.get("media-keyboard-shortcuts-dialog")||m$.customElements.define("media-keyboard-shortcuts-dialog",gS);var gk=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)};let gR=`<svg aria-hidden="true" viewBox="0 0 26 24">
1010  <path d="M16 3v2.5h3.5V9H22V3h-6ZM4 9h2.5V5.5H10V3H4v6Zm15.5 9.5H16V21h6v-6h-2.5v3.5ZM6.5 15H4v6h6v-2.5H6.5V15Z"/>
1011</svg>`,gL=`<svg aria-hidden="true" viewBox="0 0 26 24">
1012  <path d="M18.5 6.5V3H16v6h6V6.5h-3.5ZM16 21h2.5v-3.5H22V15h-6v6ZM4 17.5h3.5V21H10v-6H4v2.5Zm3.5-11H4V9h6V3H7.5v3.5Z"/>
1013</svg>`,gI=e=>{let t=e.mediaIsFullscreen?mI("exit fullscreen mode"):mI("enter fullscreen mode");e.setAttribute("aria-label",t)};class gw extends pW{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,b2,null)}static get observedAttributes(){return[...super.observedAttributes,md.MEDIA_IS_FULLSCREEN,md.MEDIA_FULLSCREEN_UNAVAILABLE]}connectedCallback(){super.connectedCallback(),gI(this)}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===md.MEDIA_IS_FULLSCREEN&&gI(this)}get mediaFullscreenUnavailable(){return m7(this,md.MEDIA_FULLSCREEN_UNAVAILABLE)}set mediaFullscreenUnavailable(e){fe(this,md.MEDIA_FULLSCREEN_UNAVAILABLE,e)}get mediaIsFullscreen(){return m6(this,md.MEDIA_IS_FULLSCREEN)}set mediaIsFullscreen(e){m9(this,md.MEDIA_IS_FULLSCREEN,e)}handleClick(e){var t,i,r,a;gk(this,t=b2,"write to private field"),i?i.call(this,e):t.set(this,e);let s=(gk(this,r=b2,"read from private field"),(a?a.call(this):r.get(this))instanceof PointerEvent),n=this.mediaIsFullscreen?new m$.CustomEvent(ms.MEDIA_EXIT_FULLSCREEN_REQUEST,{composed:!0,bubbles:!0}):new m$.CustomEvent(ms.MEDIA_ENTER_FULLSCREEN_REQUEST,{composed:!0,bubbles:!0,detail:s});this.dispatchEvent(n)}}b2=new WeakMap,gw.getSlotTemplateHTML=function(e){return`
1014    <style>
1015      :host([${md.MEDIA_IS_FULLSCREEN}]) slot[name=icon] slot:not([name=exit]) {
1016        display: none !important;
1017      }
1018
1019      
1020      :host(:not([${md.MEDIA_IS_FULLSCREEN}])) slot[name=icon] slot:not([name=enter]) {
1021        display: none !important;
1022      }
1023
1024      :host([${md.MEDIA_IS_FULLSCREEN}]) slot[name=tooltip-enter],
1025      :host(:not([${md.MEDIA_IS_FULLSCREEN}])) slot[name=tooltip-exit] {
1026        display: none;
1027      }
1028    </style>
1029
1030    <slot name="icon">
1031      <slot name="enter">${gR}</slot>
1032      <slot name="exit">${gL}</slot>
1033    </slot>
1034  `},gw.getTooltipContentHTML=function(){return`
1035    <slot name="tooltip-enter">${mI("Enter fullscreen mode")}</slot>
1036    <slot name="tooltip-exit">${mI("Exit fullscreen mode")}</slot>
1037  `},m$.customElements.get("media-fullscreen-button")||m$.customElements.define("media-fullscreen-button",gw);let{MEDIA_TIME_IS_LIVE:gD,MEDIA_PAUSED:gC}=md,{MEDIA_SEEK_TO_LIVE_REQUEST:gM,MEDIA_PLAY_REQUEST:gx}=ms,gP=e=>{var t;let i=e.mediaPaused||!e.mediaTimeIsLive,r=i?mI("seek to live"):mI("playing live");e.setAttribute("aria-label",r);let a=null==(t=e.shadowRoot)?void 0:t.querySelector('slot[name="text"]');a&&(a.textContent=mI("live")),i?e.removeAttribute("aria-disabled"):e.setAttribute("aria-disabled","true")};class gO extends pW{static get observedAttributes(){return[...super.observedAttributes,gD,gC]}connectedCallback(){super.connectedCallback(),gP(this)}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),gP(this)}get mediaPaused(){return m6(this,md.MEDIA_PAUSED)}set mediaPaused(e){m9(this,md.MEDIA_PAUSED,e)}get mediaTimeIsLive(){return m6(this,md.MEDIA_TIME_IS_LIVE)}set mediaTimeIsLive(e){m9(this,md.MEDIA_TIME_IS_LIVE,e)}handleClick(){(this.mediaPaused||!this.mediaTimeIsLive)&&(this.dispatchEvent(new m$.CustomEvent(gM,{composed:!0,bubbles:!0})),this.hasAttribute(gC)&&this.dispatchEvent(new m$.CustomEvent(gx,{composed:!0,bubbles:!0})))}}gO.getSlotTemplateHTML=function(e){return`
1038    <style>
1039      :host { --media-tooltip-display: none; }
1040      
1041      slot[name=indicator] > *,
1042      :host ::slotted([slot=indicator]) {
1043        
1044        min-width: auto;
1045        fill: var(--media-live-button-icon-color, rgb(140, 140, 140));
1046        color: var(--media-live-button-icon-color, rgb(140, 140, 140));
1047      }
1048
1049      :host([${gD}]:not([${gC}])) slot[name=indicator] > *,
1050      :host([${gD}]:not([${gC}])) ::slotted([slot=indicator]) {
1051        fill: var(--media-live-button-indicator-color, rgb(255, 0, 0));
1052        color: var(--media-live-button-indicator-color, rgb(255, 0, 0));
1053      }
1054
1055      :host([${gD}]:not([${gC}])) {
1056        cursor: var(--media-cursor, not-allowed);
1057      }
1058
1059      slot[name=text]{
1060        text-transform: uppercase;
1061      }
1062
1063    </style>
1064
1065    <slot name="indicator"><svg viewBox="0 0 6 12" aria-hidden="true"><circle cx="3" cy="6" r="2"></circle></svg></slot>
1066    
1067    <slot name="spacer">&nbsp;</slot><slot name="text">${mI("live")}</slot>
1068  `},m$.customElements.get("media-live-button")||m$.customElements.define("media-live-button",gO);var gN=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},gU=(e,t,i)=>(gN(e,t,"read from private field"),i?i.call(e):t.get(e)),gF=(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)=>(gN(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i);let g$="loadingdelay",gH="noautohide",gG=`
1069<svg aria-hidden="true" viewBox="0 0 100 100">
1070  <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">
1071    <animateTransform
1072       attributeName="transform"
1073       attributeType="XML"
1074       type="rotate"
1075       dur="1s"
1076       from="0 50 50"
1077       to="360 50 50"
1078       repeatCount="indefinite" />
1079  </path>
1080</svg>
1081`;class gW extends m$.HTMLElement{constructor(){if(super(),gF(this,b3,void 0),gF(this,b4,500),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);const e=mj(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e)}}static get observedAttributes(){return[mn.MEDIA_CONTROLLER,md.MEDIA_PAUSED,md.MEDIA_LOADING,g$]}attributeChangedCallback(e,t,i){var r,a,s,n,l;e===g$&&t!==i?this.loadingDelay=Number(i):e===mn.MEDIA_CONTROLLER&&(t&&(null==(a=null==(r=gU(this,b3))?void 0:r.unassociateElement)||a.call(r,this),gB(this,b3,null)),i&&this.isConnected&&(gB(this,b3,null==(s=this.getRootNode())?void 0:s.getElementById(i)),null==(l=null==(n=gU(this,b3))?void 0:n.associateElement)||l.call(n,this)))}connectedCallback(){var e,t,i;let r=this.getAttribute(mn.MEDIA_CONTROLLER);r&&(gB(this,b3,null==(e=this.getRootNode())?void 0:e.getElementById(r)),null==(i=null==(t=gU(this,b3))?void 0:t.associateElement)||i.call(t,this))}disconnectedCallback(){var e,t;null==(t=null==(e=gU(this,b3))?void 0:e.unassociateElement)||t.call(e,this),gB(this,b3,null)}get loadingDelay(){return gU(this,b4)}set loadingDelay(e){gB(this,b4,e);let{style:t}=m3(this.shadowRoot,":host");t.setProperty("--_loading-indicator-delay",`var(--media-loading-indicator-transition-delay, ${e}ms)`)}get mediaPaused(){return m6(this,md.MEDIA_PAUSED)}set mediaPaused(e){m9(this,md.MEDIA_PAUSED,e)}get mediaLoading(){return m6(this,md.MEDIA_LOADING)}set mediaLoading(e){m9(this,md.MEDIA_LOADING,e)}get mediaController(){return m7(this,mn.MEDIA_CONTROLLER)}set mediaController(e){fe(this,mn.MEDIA_CONTROLLER,e)}get noAutohide(){return m6(this,gH)}set noAutohide(e){m9(this,gH,e)}}b3=new WeakMap,b4=new WeakMap,gW.shadowRootOptions={mode:"open"},gW.getTemplateHTML=function(e){return`
1082    <style>
1083      :host {
1084        display: var(--media-control-display, var(--media-loading-indicator-display, inline-block));
1085        vertical-align: middle;
1086        box-sizing: border-box;
1087        --_loading-indicator-delay: var(--media-loading-indicator-transition-delay, 500ms);
1088      }
1089
1090      #status {
1091        color: rgba(0,0,0,0);
1092        width: 0px;
1093        height: 0px;
1094      }
1095
1096      :host slot[name=icon] > *,
1097      :host ::slotted([slot=icon]) {
1098        opacity: var(--media-loading-indicator-opacity, 0);
1099        transition: opacity 0.15s;
1100      }
1101
1102      :host([${md.MEDIA_LOADING}]:not([${md.MEDIA_PAUSED}])) slot[name=icon] > *,
1103      :host([${md.MEDIA_LOADING}]:not([${md.MEDIA_PAUSED}])) ::slotted([slot=icon]) {
1104        opacity: var(--media-loading-indicator-opacity, 1);
1105        transition: opacity 0.15s var(--_loading-indicator-delay);
1106      }
1107
1108      :host #status {
1109        visibility: var(--media-loading-indicator-opacity, hidden);
1110        transition: visibility 0.15s;
1111      }
1112
1113      :host([${md.MEDIA_LOADING}]:not([${md.MEDIA_PAUSED}])) #status {
1114        visibility: var(--media-loading-indicator-opacity, visible);
1115        transition: visibility 0.15s var(--_loading-indicator-delay);
1116      }
1117
1118      svg, img, ::slotted(svg), ::slotted(img) {
1119        width: var(--media-loading-indicator-icon-width);
1120        height: var(--media-loading-indicator-icon-height, 100px);
1121        fill: var(--media-icon-color, var(--media-primary-color, rgb(238 238 238)));
1122        vertical-align: middle;
1123      }
1124    </style>
1125
1126    <slot name="icon">${gG}</slot>
1127    <div id="status" role="status" aria-live="polite">${mI("media loading")}</div>
1128  `},m$.customElements.get("media-loading-indicator")||m$.customElements.define("media-loading-indicator",gW);let gK=`<svg aria-hidden="true" viewBox="0 0 24 24">
1129  <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"/>
1130</svg>`,gV=`<svg aria-hidden="true" viewBox="0 0 24 24">
1131  <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"/>
1132</svg>`,gq=`<svg aria-hidden="true" viewBox="0 0 24 24">
1133  <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"/>
1134</svg>`,gj=e=>{let t="off"===e.mediaVolumeLevel?mI("unmute"):mI("mute");e.setAttribute("aria-label",t)};class gY extends pW{static get observedAttributes(){return[...super.observedAttributes,md.MEDIA_VOLUME_LEVEL]}connectedCallback(){super.connectedCallback(),gj(this)}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===md.MEDIA_VOLUME_LEVEL&&gj(this)}get mediaVolumeLevel(){return m7(this,md.MEDIA_VOLUME_LEVEL)}set mediaVolumeLevel(e){fe(this,md.MEDIA_VOLUME_LEVEL,e)}handleClick(){let e="off"===this.mediaVolumeLevel?ms.MEDIA_UNMUTE_REQUEST:ms.MEDIA_MUTE_REQUEST;this.dispatchEvent(new m$.CustomEvent(e,{composed:!0,bubbles:!0}))}}gY.getSlotTemplateHTML=function(e){return`
1135    <style>
1136      :host(:not([${md.MEDIA_VOLUME_LEVEL}])) slot[name=icon] slot:not([name=high]),
1137      :host([${md.MEDIA_VOLUME_LEVEL}=high]) slot[name=icon] slot:not([name=high]) {
1138        display: none !important;
1139      }
1140
1141      :host([${md.MEDIA_VOLUME_LEVEL}=off]) slot[name=icon] slot:not([name=off]) {
1142        display: none !important;
1143      }
1144
1145      :host([${md.MEDIA_VOLUME_LEVEL}=low]) slot[name=icon] slot:not([name=low]) {
1146        display: none !important;
1147      }
1148
1149      :host([${md.MEDIA_VOLUME_LEVEL}=medium]) slot[name=icon] slot:not([name=medium]) {
1150        display: none !important;
1151      }
1152
1153      :host(:not([${md.MEDIA_VOLUME_LEVEL}=off])) slot[name=tooltip-unmute],
1154      :host([${md.MEDIA_VOLUME_LEVEL}=off]) slot[name=tooltip-mute] {
1155        display: none;
1156      }
1157    </style>
1158
1159    <slot name="icon">
1160      <slot name="off">${gK}</slot>
1161      <slot name="low">${gV}</slot>
1162      <slot name="medium">${gV}</slot>
1163      <slot name="high">${gq}</slot>
1164    </slot>
1165  `},gY.getTooltipContentHTML=function(){return`
1166    <slot name="tooltip-mute">${mI("Mute")}</slot>
1167    <slot name="tooltip-unmute">${mI("Unmute")}</slot>
1168  `},m$.customElements.get("media-mute-button")||m$.customElements.define("media-mute-button",gY);let gz=`<svg aria-hidden="true" viewBox="0 0 28 24">
1169  <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"/>
1170</svg>`,gQ=e=>{let t=e.mediaIsPip?mI("exit picture in picture mode"):mI("enter picture in picture mode");e.setAttribute("aria-label",t)};class gX extends pW{static get observedAttributes(){return[...super.observedAttributes,md.MEDIA_IS_PIP,md.MEDIA_PIP_UNAVAILABLE]}connectedCallback(){super.connectedCallback(),gQ(this)}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===md.MEDIA_IS_PIP&&gQ(this)}get mediaPipUnavailable(){return m7(this,md.MEDIA_PIP_UNAVAILABLE)}set mediaPipUnavailable(e){fe(this,md.MEDIA_PIP_UNAVAILABLE,e)}get mediaIsPip(){return m6(this,md.MEDIA_IS_PIP)}set mediaIsPip(e){m9(this,md.MEDIA_IS_PIP,e)}handleClick(){let e=this.mediaIsPip?ms.MEDIA_EXIT_PIP_REQUEST:ms.MEDIA_ENTER_PIP_REQUEST;this.dispatchEvent(new m$.CustomEvent(e,{composed:!0,bubbles:!0}))}}gX.getSlotTemplateHTML=function(e){return`
1171    <style>
1172      :host([${md.MEDIA_IS_PIP}]) slot[name=icon] slot:not([name=exit]) {
1173        display: none !important;
1174      }
1175
1176      :host(:not([${md.MEDIA_IS_PIP}])) slot[name=icon] slot:not([name=enter]) {
1177        display: none !important;
1178      }
1179
1180      :host([${md.MEDIA_IS_PIP}]) slot[name=tooltip-enter],
1181      :host(:not([${md.MEDIA_IS_PIP}])) slot[name=tooltip-exit] {
1182        display: none;
1183      }
1184    </style>
1185
1186    <slot name="icon">
1187      <slot name="enter">${gz}</slot>
1188      <slot name="exit">${gz}</slot>
1189    </slot>
1190  `},gX.getTooltipContentHTML=function(){return`
1191    <slot name="tooltip-enter">${mI("Enter picture in picture mode")}</slot>
1192    <slot name="tooltip-exit">${mI("Exit picture in picture mode")}</slot>
1193  `},m$.customElements.get("media-pip-button")||m$.customElements.define("media-pip-button",gX);var gZ=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot read from private field");return i?i.call(e):t.get(e)};let gJ="rates",g0=[1,1.2,1.5,1.7,2];function g1(e){return Math.round(100*e)/100}class g2 extends pW{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,b5,new fk(this,gJ,{defaultValue:g0})),this.container=this.shadowRoot.querySelector('slot[name="icon"]'),this.container.innerHTML=`${g1(null!=(e=this.mediaPlaybackRate)?e:1)}x`}static get observedAttributes(){return[...super.observedAttributes,md.MEDIA_PLAYBACK_RATE,gJ]}
1193attributeChangedCallback(e,t,i){if(super.attributeChangedCallback(e,t,i),e===gJ&&(gZ(this,b5).value=i),e===md.MEDIA_PLAYBACK_RATE){let e=i?+i:NaN,t=g1(Number.isNaN(e)?1:e);this.container.innerHTML=`${t}x`,this.setAttribute("aria-label",mI("Playback rate {playbackRate}",{playbackRate:t}))}}get rates(){return gZ(this,b5)}set rates(e){e?Array.isArray(e)?gZ(this,b5).value=e.join(" "):"string"==typeof e&&(gZ(this,b5).value=e):gZ(this,b5).value=""}get mediaPlaybackRate(){return m5(this,md.MEDIA_PLAYBACK_RATE,1)}set mediaPlaybackRate(e){m8(this,md.MEDIA_PLAYBACK_RATE,e)}handleClick(){var e,t;let i=Array.from(gZ(this,b5).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 m$.CustomEvent(ms.MEDIA_PLAYBACK_RATE_REQUEST,{composed:!0,bubbles:!0,detail:r});this.dispatchEvent(a)}}b5=new WeakMap,g2.getSlotTemplateHTML=function(e){let t=e.mediaplaybackrate?g1(+e.mediaplaybackrate):1;return`
1194    <style>
1195      :host {
1196        min-width: 5ch;
1197        padding: var(--media-button-padding, var(--media-control-padding, 10px 5px));
1198      }
1199    </style>
1200    <slot name="icon">${t}x</slot>
1201  `},g2.getTooltipContentHTML=function(){return mI("Playback rate")},m$.customElements.get("media-playback-rate-button")||m$.customElements.define("media-playback-rate-button",g2);let g3=`<svg aria-hidden="true" viewBox="0 0 24 24">
1202  <path d="m6 21 15-9L6 3v18Z"/>
1203</svg>`,g4=`<svg aria-hidden="true" viewBox="0 0 24 24">
1204  <path d="M6 20h4V4H6v16Zm8-16v16h4V4h-4Z"/>
1205</svg>`,g5=e=>{let t=e.mediaPaused?mI("play"):mI("pause");e.setAttribute("aria-label",t)};class g8 extends pW{static get observedAttributes(){return[...super.observedAttributes,md.MEDIA_PAUSED,md.MEDIA_ENDED]}connectedCallback(){super.connectedCallback(),g5(this)}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),(e===md.MEDIA_PAUSED||e===md.MEDIA_LANG)&&g5(this)}get mediaPaused(){return m6(this,md.MEDIA_PAUSED)}set mediaPaused(e){m9(this,md.MEDIA_PAUSED,e)}handleClick(){let e=this.mediaPaused?ms.MEDIA_PLAY_REQUEST:ms.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new m$.CustomEvent(e,{composed:!0,bubbles:!0}))}}g8.getSlotTemplateHTML=function(e){return`
1206    <style>
1207      :host([${md.MEDIA_PAUSED}]) slot[name=pause],
1208      :host(:not([${md.MEDIA_PAUSED}])) slot[name=play] {
1209        display: none !important;
1210      }
1211
1212      :host([${md.MEDIA_PAUSED}]) slot[name=tooltip-pause],
1213      :host(:not([${md.MEDIA_PAUSED}])) slot[name=tooltip-play] {
1214        display: none;
1215      }
1216    </style>
1217
1218    <slot name="icon">
1219      <slot name="play">${g3}</slot>
1220      <slot name="pause">${g4}</slot>
1221    </slot>
1222  `},g8.getTooltipContentHTML=function(){return`
1223    <slot name="tooltip-play">${mI("Play")}</slot>
1224    <slot name="tooltip-pause">${mI("Pause")}</slot>
1225  `},m$.customElements.get("media-play-button")||m$.customElements.define("media-play-button",g8);let g6="placeholdersrc";class g9 extends m$.HTMLElement{static get observedAttributes(){return[g6,"src"]}constructor(){if(super(),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);const e=mj(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e)}this.image=this.shadowRoot.querySelector("#image")}attributeChangedCallback(e,t,i){if("src"===e&&(null==i?this.image.removeAttribute("src"):this.image.setAttribute("src",i)),e===g6)if(null==i)this.image.style.removeProperty("background-image");else{var r;r=this.image,r.style["background-image"]=`url('${i}')`}}get placeholderSrc(){return m7(this,g6)}set placeholderSrc(e){fe(this,"src",e)}get src(){return m7(this,"src")}set src(e){fe(this,"src",e)}}g9.shadowRootOptions={mode:"open"},g9.getTemplateHTML=function(e){return`
1226    <style>
1227      :host {
1228        pointer-events: none;
1229        display: var(--media-poster-image-display, inline-block);
1230        box-sizing: border-box;
1231      }
1232
1233      img {
1234        max-width: 100%;
1235        max-height: 100%;
1236        min-width: 100%;
1237        min-height: 100%;
1238        background-repeat: no-repeat;
1239        background-position: var(--media-poster-image-background-position, var(--media-object-position, center));
1240        background-size: var(--media-poster-image-background-size, var(--media-object-fit, contain));
1241        object-fit: var(--media-object-fit, contain);
1242        object-position: var(--media-object-position, center);
1243      }
1244    </style>
1245
1246    <img part="poster img" aria-hidden="true" id="image"/>
1247  `},m$.customElements.get("media-poster-image")||m$.customElements.define("media-poster-image",g9);var g7=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)};b8=new WeakMap,m$.customElements.get("media-preview-chapter-display")||m$.customElements.define("media-preview-chapter-display",class extends gu{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,b8,void 0),((e,t,i,r)=>(g7(e,t,"write to private field"),r?r.call(e,i):t.set(e,i)))(this,b8,this.shadowRoot.querySelector("slot"))}static get observedAttributes(){return[...super.observedAttributes,md.MEDIA_PREVIEW_CHAPTER,md.MEDIA_LA
1247NG]}attributeChangedCallback(e,t,i){if(super.attributeChangedCallback(e,t,i),(e===md.MEDIA_PREVIEW_CHAPTER||e===md.MEDIA_LANG)&&i!==t&&null!=i){var r;if((g7(this,b8,"read from private field"),r?r.call(this):b8.get(this)).textContent=i,""!==i){let e=mI("chapter: {chapterName}",{chapterName:i});this.setAttribute("aria-valuetext",e)}else this.removeAttribute("aria-valuetext")}}get mediaPreviewChapter(){return m7(this,md.MEDIA_PREVIEW_CHAPTER)}set mediaPreviewChapter(e){fe(this,md.MEDIA_PREVIEW_CHAPTER,e)}});var ve=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},vt=(e,t,i)=>(ve(e,t,"read from private field"),i?i.call(e):t.get(e)),vi=(e,t,i,r)=>(ve(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i);class vr extends m$.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,b6,void 0),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);const e=mj(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e)}}static get observedAttributes(){return[mn.MEDIA_CONTROLLER,md.MEDIA_PREVIEW_IMAGE,md.MEDIA_PREVIEW_COORDS]}connectedCallback(){var e,t,i;let r=this.getAttribute(mn.MEDIA_CONTROLLER);r&&(vi(this,b6,null==(e=this.getRootNode())?void 0:e.getElementById(r)),null==(i=null==(t=vt(this,b6))?void 0:t.associateElement)||i.call(t,this))}disconnectedCallback(){var e,t;null==(t=null==(e=vt(this,b6))?void 0:e.unassociateElement)||t.call(e,this),vi(this,b6,null)}attributeChangedCallback(e,t,i){var r,a,s,n,l;[md.MEDIA_PREVIEW_IMAGE,md.MEDIA_PREVIEW_COORDS].includes(e)&&this.update(),e===mn.MEDIA_CONTROLLER&&(t&&(null==(a=null==(r=vt(this,b6))?void 0:r.unassociateElement)||a.call(r,this),vi(this,b6,null)),i&&this.isConnected&&(vi(this,b6,null==(s=this.getRootNode())?void 0:s.getElementById(i)),null==(l=null==(n=vt(this,b6))?void 0:n.associateElement)||l.call(n,this)))}get mediaPreviewImage(){return m7(this,md.MEDIA_PREVIEW_IMAGE)}set mediaPreviewImage(e){fe(this,md.MEDIA_PREVIEW_IMAGE,e)}get mediaPreviewCoords(){let e=this.getAttribute(md.MEDIA_PREVIEW_COORDS);if(e)return e.split(/\s+/).map(e=>+e)}set mediaPreviewCoords(e){e?this.setAttribute(md.MEDIA_PREVIEW_COORDS,e.join(" ")):this.removeAttribute(md.MEDIA_PREVIEW_COORDS)}update(){let e,t,i=this.mediaPreviewCoords,r=this.mediaPreviewImage;if(!(i&&r))return;let[a,s,n,l]=i,o=r.split("#")[0],d=getComputedStyle(this),{maxWidth:h,maxHeight:u,minWidth:c,minHeight:m}=d;if("fill"===(d.getPropertyValue("--media-preview-thumbnail-object-fit").trim()||"contain")){let i=parseInt(h)/n,r=parseInt(u)/l,a=parseInt(c)/n,s=parseInt(m)/l;e=i<1?i:Math.max(i,a),t=r<1?r:Math.max(r,s)}else{let i=Math.min(parseInt(h)/n,parseInt(u)/l),r=Math.max(parseInt(c)/n,parseInt(m)/l),a=i<1?i:r>1?r:1;e=a,t=a}let{style:f}=m3(this.shadowRoot,":host"),p=m3(this.shadowRoot,"img").style,g=this.shadowRoot.querySelector("img"),v=1>Math.min(e,t)?"min":"max";f.setProperty(`${v}-width`,"initial","important"),f.setProperty(`${v}-height`,"initial","important"),f.width=`${n*e}px`,f.height=`${l*t}px`;let E=()=>{p.width=`${this.imgWidth*e}px`,p.height=`${this.imgHeight*t}px`,p.display="block"};g.src!==o&&(g.onload=()=>{this.imgWidth=g.naturalWidth,this.imgHeight=g.naturalHeight,E(),g.onload=null},g.src=o,E()),E(),p.transform=`translate(-${a*e}px, -${s*t}px)`}}b6=new WeakMap,vr.shadowRootOptions={mode:"open"},vr.getTemplateHTML=function(e){return`
1248    <style>
1249      :host {
1250        box-sizing: border-box;
1251        display: var(--media-control-display, var(--media-preview-thumbnail-display, inline-block));
1252        overflow: hidden;
1253      }
1254
1255      img {
1256        display: none;
1257        position: relative;
1258      }
1259    </style>
1260    <img crossorigin loading="eager" decoding="async">
1261  `},m$.customElements.get("media-preview-thumbnail")||m$.customElements.define("media-preview-thumbnail",vr);var va=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},vs=(e,t,i)=>(va(e,t,"read from private field"),i?i.call(e):t.get(e));b9=new WeakMap,m$.customElements.get("media-preview-time-display")||m$.customElements.define("media-preview-time-display",class extends gu{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,b9,void 0),((e,t,i,r)=>(va(e,t,"write to private field"),r?r.call(e,i):t.set(e,i)))(this,b9,this.shadowRoot.querySelector("slot")),vs(this,b9).textContent=mC(0)}static get observedAttributes(){return[...super.observedAttributes,md.MEDIA_PREVIEW_TIME]}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===md.MEDIA_PREVIEW_TIME&&null!=i&&(vs(this,b9).textContent=mC(parseFloat(i)))}get mediaPreviewTime(){return m5(this,md.MEDIA_PREVIEW_TIME)}set mediaPreviewTime(e){m8(this,md.MEDIA_PREVIEW_TIME,e)}});let vn="seekoffset";class vl extends pW{static get observedAttributes(){return[...super.observedAttributes,md.MEDIA_CURRENT_TIME,vn]}connectedCallback(){super.connectedCallback(),this.seekOffset=m5(this,vn,30)}attributeChangedCallback(e,t,i){var r;super.attributeChangedCallback(e,t,i),r=this.seekOffset,this.setAttribute("aria-label",mI("seek back {seekOffset} seconds",{seekOffset:r})),e===vn&&(this.seekOffset=m5(this,vn,30))}get seekOffset(){return m5(this,vn,30)}set seekOffset(e){m8(this,vn,e),this.setAttribute("aria-label",mI("seek back {seekOffset} seconds",{seekOffset:this.seekOffset})),mQ(mX(this,"icon"),this.seekOffset)}get mediaCurrentTime(){return m5(this,md.MEDIA_CURRENT_TIME,0)}set mediaCurrentTime(e){m8(this,md.MEDIA_CURRENT_TIME,e)}handleClick(){let e=Math.max(this.mediaCurrentTime-this.seekOffset,0),t=new m$.CustomEvent(ms.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)}}vl.getSlotTemplateHTML=function(e,t){let i;return`
1262    <slot name="icon">${i=t.seekOffset,`
1263  <svg aria-hidden="true" viewBox="0 0 20 24">
1264    <defs>
1265      <style>.text{font-size:8px;font-family:Arial-BoldMT, Arial;font-weight:700;}</style>
1266    </defs>
1267    <text class="text value" transform="translate(2.18 19.87)">${i}</text>
1268    <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"/>
1269  </svg>`}</slot>
1270  `},vl.getTooltipContentHTML=function(){return mI("Seek backward")},m$.customElements.get("media-seek-backward-button")||m$.customElements.define("media-seek-backward-button",vl);let vo="seekoffset";class vd extends pW{static get observedAttributes(){return[...super.observedAttributes,md.MEDIA_CURRENT_TIME,vo]}connectedCallback(){super.connectedCallback(),this.seekOffset=m5(this,vo,30)}attributeChangedCallback(e,t,i){var r;super.attributeChangedCallback(e,t,i),r=this.seekOffset,this.setAttribute("aria-label",mI("seek forward {seekOffset} seconds",{seekOffset:r})),e===vo&&(this.seekOffset=m5(this,vo,30))}get seekOffset(){return m5(this,vo,30)}set seekOffset(e){m8(this,vo,e),this.setAttribute("aria-label",mI("seek forward {seekOffset} seconds",{seekOffset:this.seekOffset})),mQ(mX(this,"icon"),this.seekOffset)}get mediaCurrentTime(){return m5(this,md.MEDIA_CURRENT_TIME,0)}set mediaCurrentTime(e){m8(this,md.MEDIA_CURRENT_TIME,e)}handleClick(){let e=this.mediaCurrentTime+this.seekOffset,t=new m$.CustomEvent(ms.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)}}vd.getSlotTemplateHTML=function(e,t){let i;return`
1271    <slot name="icon">${i=t.seekOffset,`
1272  <svg aria-hidden="true" viewBox="0 0 20 24">
1273    <defs>
1274      <style>.text{font-size:8px;font-family:Arial-BoldMT, Arial;font-weight:700;}</style>
1275    </defs>
1276    <text class="text value" transform="translate(8.9 19.87)">${i}</text>
1277    <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"/>
1278  </svg>`}</slot>
1279  `},vd.getTooltipContentHTML=function(){return mI("Seek forward")},m$.customElements.get("media-seek-forward-button")||m$.customElements.define("media-seek-forward-button",vd);var vh=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},vu=(e,t,i)=>(vh(e,t,"read from private field"),i?i.call(e):t.get(e)),vc=(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)},vm=(e,t,i,r)=>(vh(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i),vf=(e,t,i)=>(vh(e,t,"access private method"),i);let vp={REMAINING:"remaining",SHOW_DURATION:"showduration",NO_TOGGLE:"notoggle"},vg=[...Object.values(vp),md.MEDIA_CURRENT_TIME,md.MEDIA_DURATION,md.MEDIA_SEEKABLE],vv=["Enter"," "],vE="&nbsp;/&nbsp;",vy=(e,{timesSep:t=vE}={})=>{var i,r;let a=null!=(i=e.mediaCurrentTime)?i:0,[,s]=null!=(r=e.mediaSeekable)?r:[],n=0;Number.isFinite(e.mediaDuration)?n=e.mediaDuration:Number.isFinite(s)&&(n=s);let l=e.remaining?mC(0-(n-a)):mC(a);return e.showDuration?`${l}${t}${mC(n)}`:l};class vb extends gu{constructor(){super(),vc(this,Ti),vc(this,Ta),vc(this,Tn),vc(this,To),vc(this,b7,void 0),vc(this,Te,null),vc(this,Tt,e=>{let{metaKey:t,altKey:i,key:r}=e;t||i||!vv.includes(r)?this.removeEventListener("keyup",vu(this,Te)):this.addEventListener("keyup",vu(this,Te))}),vm(this,b7,this.shadowRoot.querySelector("slot")),vu(this,b7).innerHTML=`${vy(this)}`}static get observedAttributes(){return[...super.observedAttributes,...vg,"disabled"]}connectedCallback(){let{style:e}=m3(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",mI("playback time")),vf(this,Tn,Tl).call(this),super.connectedCallback()}toggleTimeDisplay(){this.noToggle||(this.hasAttribute("remaining")?this.removeAttribute("remaining"):this.setAttribute("remaining",""))}disconnectedCallback(){this.disable(),vf(this,Ta,Ts).call(this),super.disconnectedCallback()}attributeChangedCallback(e,t,i){this.setAttribute("aria-label",mI("playback time")),vg.includes(e)?this.update():"disabled"===e&&i!==t?null==i?vf(this,Tn,Tl).call(this):vf(this,To,Td).call(this):e===vp.NO_TOGGLE&&i!==t&&(this.noToggle?vf(this,To,Td).call(this):vf(this,Tn,Tl).call(this)),super.attributeChangedCallback(e,t,i)}enable(){this.noToggle||(this.tabIndex=0)}disable(){this.tabIndex=-1}get remaining(){return m6(this,vp.REMAINING)}set remaining(e){m9(this,vp.REMAINING,e)}get showDuration(){return m6(this,vp.SHOW_DURATION)}set showDuration(e){m9(this,vp.SHOW_DURATION,e)}get noToggle(){return m6(this,vp.NO_TOGGLE)}set noToggle(e){m9(this,vp.NO_TOGGLE,e)}get mediaDuration(){return m5(this,md.MEDIA_DURATION)}set mediaDuration(e){m8(this,md.MEDIA_DURATION,e)}get mediaCurrentTime(){return m5(this,md.MEDIA_CURRENT_TIME)}set mediaCurrentTime(e){m8(this,md.MEDIA_CURRENT_TIME,e)}get mediaSeekable(){let e=this.getAttribute(md.MEDIA_SEEKABLE);if(e)return e.split(":").map(e=>+e)}set mediaSeekable(e){null==e?this.removeAttribute(md.MEDIA_SEEKABLE):this.setAttribute(md.MEDIA_SEEKABLE,e.join(":"))}update(){let e=vy(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 e.setAttribute("aria-description",mI("video not loaded, unknown time."));let s=e.remaining?mD(0-(a-i)):mD(i);if(!e.showDuration)return e.setAttribute("aria-description",s);let n=mI("{currentTime} of {totalTime}",{currentTime:s,totalTime:mD(a)});e.setAttribute("aria-description",n)})(this),e!==vu(this,b7).innerHTML&&(vu(this,b7).innerHTML=e)}}b7=new WeakMap,Te=new WeakMap,Tt=new WeakMap,Ti=new WeakSet,Tr=function(){vu(this,Te)||(vm(this,Te,e=>{let{key:t}=e;vv.includes(t)?this.toggleTimeDisplay():this.removeEventListener("keyup",vu(this,Te))}),this.addEventListener("keydown",vu(this,Tt)),this.addEventListener("click",this.toggleTimeDisplay))},Ta=new WeakSet,Ts=function(){vu(this,Te)&&(this.removeEventListener("keyup",vu(this,Te)),this.removeEventListener("keydown",vu(this,Tt)),this.removeEventListener("click",this.toggleTimeDisplay),vm(this,Te,null))},Tn=new WeakSet,Tl=function(){this.noToggle||this.hasAttribute("disabled")||(this.setAttribute("role","button"),this.enable(),vf(this,Ti,Tr).call(this))},To=new WeakSet,Td=function(){this.removeAttribute("role"),this.disable(),vf(this,Ta,Ts).call(this)},vb.getSlotTemplateHTML=function(e,t){return`
1280    <slot>${vy(t)}</slot>
1281  `},m$.customElements.get("media-time-display")||m$.customElements.define("media-time-display",vb);var vT=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},vA=(e,t,i)=>(vT(e,t,"read from private field"),i?i.call(e):t.get(e)),v_=(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)},vS=(e,t,i,r)=>(vT(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i);class vk{constructor(e,t,i){v_(this,Th,void 0),v_(this,Tu,void 0),v_(this,Tc,void 0),v_(this,Tm,void 0),v_(this,Tf,void 0),v_(this,Tp,void 0),v_(this,Tg,void 0),v_(this,Tv,void 0),v_(this,TE,0),v_(this,Ty,(e=performance.now())=>{vS(this,TE,requestAnimationFrame(vA(this,Ty))),vS(this,Tm,performance.now()-vA(this,Tc));let t=1e3/this.fps;if(vA(this,Tm)>t){let i,r,a,s;vS(this,Tc,e-vA(this,Tm)%t);let n=1e3/((e-vA(this,Tu))/++(i=this,r=Tf,{set _(value){vS(i,r,value,a)},get _(){return vA(i,r,s)}})._),l=(e-vA(this,Tp))/1e3/this.duration,o=vA(this,Tg)+l*this.playbackRate;o-vA(this,Th).valueAsNumber>0?vS(this,Tv,this.playbackRate/this.duration/n):(vS(this,Tv,.995*vA(this,Tv)),o=vA(this,Th).valueAsNumber+vA
1281(this,Tv)),this.callback(o)}}),vS(this,Th,e),this.callback=t,this.fps=i}start(){0===vA(this,TE)&&(vS(this,Tc,performance.now()),vS(this,Tu,vA(this,Tc)),vS(this,Tf,0),vA(this,Ty).call(this))}stop(){0!==vA(this,TE)&&(cancelAnimationFrame(vA(this,TE)),vS(this,TE,0))}update({start:e,duration:t,playbackRate:i}){let r=e-vA(this,Th).valueAsNumber,a=Math.abs(t-this.duration);(r>0||r<-.03||a>=.5)&&this.callback(e),vS(this,Tg,e),vS(this,Tp,performance.now()),this.duration=t,this.playbackRate=i}}Th=new WeakMap,Tu=new WeakMap,Tc=new WeakMap,Tm=new WeakMap,Tf=new WeakMap,Tp=new WeakMap,Tg=new WeakMap,Tv=new WeakMap,TE=new WeakMap,Ty=new WeakMap;var vR=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},vL=(e,t,i)=>(vR(e,t,"read from private field"),i?i.call(e):t.get(e)),vI=(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)},vw=(e,t,i,r)=>(vR(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i),vD=(e,t,i)=>(vR(e,t,"access private method"),i);let vC=(e,t=e.mediaCurrentTime)=>{let i=Number.isFinite(e.mediaSeekableStart)?e.mediaSeekableStart:0,r=Number.isFinite(e.mediaDuration)?e.mediaDuration:e.mediaSeekableEnd;return Number.isNaN(r)?0:Math.max(0,Math.min((t-i)/(r-i),1))},vM=(e,t=e.range.valueAsNumber)=>{let i=Number.isFinite(e.mediaSeekableStart)?e.mediaSeekableStart:0,r=Number.isFinite(e.mediaDuration)?e.mediaDuration:e.mediaSeekableEnd;return Number.isNaN(r)?0:t*(r-i)+i};class vx extends gr{constructor(){super(),vI(this,TC),vI(this,TP),vI(this,TN),vI(this,TF),vI(this,T$),vI(this,TG),vI(this,TK),vI(this,Tb,null),vI(this,TT,void 0),vI(this,TA,void 0),vI(this,T_,void 0),vI(this,TS,void 0),vI(this,Tk,void 0),vI(this,TR,void 0),vI(this,TL,void 0),vI(this,TI,void 0),vI(this,Tw,void 0),vI(this,TD,()=>{vD(this,TC,TM).call(this)?vL(this,TT).start():vL(this,TT).stop()}),vI(this,Tx,e=>{!this.dragging&&(m_(e)&&(this.range.valueAsNumber=e),vL(this,Tw)||this.updateBar())}),this.shadowRoot.querySelector("#track").insertAdjacentHTML("afterbegin",'<div id="buffered" part="buffered"></div>'),vw(this,TA,this.shadowRoot.querySelectorAll('[part~="box"]')),vw(this,TS,this.shadowRoot.querySelector('[part~="preview-box"]')),vw(this,Tk,this.shadowRoot.querySelector('[part~="current-box"]'));const e=getComputedStyle(this);vw(this,TR,parseInt(e.getPropertyValue("--media-box-padding-left"))),vw(this,TL,parseInt(e.getPropertyValue("--media-box-padding-right"))),vw(this,TT,new vk(this.range,vL(this,Tx),60))}static get observedAttributes(){return[...super.observedAttributes,md.MEDIA_PAUSED,md.MEDIA_DURATION,md.MEDIA_SEEKABLE,md.MEDIA_CURRENT_TIME,md.MEDIA_PREVIEW_IMAGE,md.MEDIA_PREVIEW_TIME,md.MEDIA_PREVIEW_CHAPTER,md.MEDIA_BUFFERED,md.MEDIA_PLAYBACK_RATE,md.MEDIA_LOADING,md.MEDIA_ENDED]}connectedCallback(){var e;super.connectedCallback(),this.range.setAttribute("aria-label",mI("seek")),vL(this,TD).call(this),vw(this,Tb,this.getRootNode()),null==(e=vL(this,Tb))||e.addEventListener("transitionstart",this)}disconnectedCallback(){var e;super.disconnectedCallback(),vL(this,TT).stop(),null==(e=vL(this,Tb))||e.removeEventListener("transitionstart",this),vw(this,Tb,null)}attributeChangedCallback(e,t,i){if(super.attributeChangedCallback(e,t,i),t!=i){if(e===md.MEDIA_CURRENT_TIME||e===md.MEDIA_PAUSED||e===md.MEDIA_ENDED||e===md.MEDIA_LOADING||e===md.MEDIA_DURATION||e===md.MEDIA_SEEKABLE){let e,t,i,r;vL(this,TT).update({start:vC(this),duration:this.mediaSeekableEnd-this.mediaSeekableStart,playbackRate:this.mediaPlaybackRate}),vL(this,TD).call(this),e=this.range,t=mD(+vM(this)),i=mD(+this.mediaSeekableEnd),r=t&&i?mI("{currentTime} of {totalTime}",{currentTime:t,totalTime:i}):mI("video not loaded, unknown time."),e.setAttribute("aria-valuetext",r)}else e===md.MEDIA_BUFFERED&&this.updateBufferedBar();(e===md.MEDIA_DURATION||e===md.MEDIA_SEEKABLE)&&(this.mediaChaptersCues=vL(this,TI),this.updateBar())}}get mediaChaptersCues(){return vL(this,TI)}set mediaChaptersCues(e){var t;vw(this,TI,e),this.updateSegments(null==(t=vL(this,TI))?void 0:t.map(e=>({start:vC(this,e.startTime),end:vC(this,e.endTime)})))}get mediaPaused(){return m6(this,md.MEDIA_PAUSED)}set mediaPaused(e){m9(this,md.MEDIA_PAUSED,e)}get mediaLoading(){return m6(this,md.MEDIA_LOADING)}set mediaLoading(e){m9(this,md.MEDIA_LOADING,e)}get mediaDuration(){return m5(this,md.MEDIA_DURATION)}set mediaDuration(e){m8(this,md.MEDIA_DURATION,e)}get mediaCurrentTime(){return m5(this,md.MEDIA_CURRENT_TIME)}set mediaCurrentTime(e){m8(this,md.MEDIA_CURRENT_TIME,e)}get mediaPlaybackRate(){return m5(this,md.MEDIA_PLAYBACK_RATE,1)}set mediaPlaybackRate(e){m8(this,md.MEDIA_PLAYBACK_RATE,e)}get mediaBuffered(){let e=this.getAttribute(md.MEDIA_BUFFERED);return e?e.split(" ").map(e=>e.split(":").map(e=>+e)):[]}set mediaBuffered(e){if(!e)return void this.removeAttribute(md.MEDIA_BUFFERED);let t=e.map(e=>e.join(":")).join(" ");this.setAttribute(md.MEDIA_BUFFERED,t)}get mediaSeekable(){let e=this.getAttribute(md.MEDIA_SEEKABLE);if(e)return e.split(":").map(e=>+e)}set mediaSeekable(e){null==e?this.removeAttribute(md.MEDIA_SEEKABLE):this.setAttribute(md.MEDIA_SEEKABLE,e.join(":"))}get mediaSeekableEnd(){var e;let[,t=this.mediaDuration]=null!=(e=this.mediaSeekable)?e:[];return t}get mediaSeekableStart(){var e;let[t=0]=null!=(e=this.mediaSeekable)?e:[];return t}get mediaPreviewImage(){return m7(this,md.MEDIA_PREVIEW_IMAGE)}set mediaPreviewImage(e){fe(this,md.MEDIA_PREVIEW_IMAGE,e)}get mediaPreviewTime(){return m5(this,md.MEDIA_PREVIEW_TIME)}set mediaPreviewTime(e){m8(this,md.MEDIA_PREVIEW_TIME,e)}get mediaEnded(){return m6(this,md.MEDIA_ENDED)}set mediaEnded(e){m9(this,md.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=vC(this,a)}let{style:r}=m3(this.shadowRoot,"#buffered");r.setProperty("width",`${100*t}%`)}updateCurrentBox(){if(!this.shadowRoot.querySelector('slot[name="current"]').assignedElements().length)return;let e=m3(this.shadowRoot,"#current-rail"),t=m3(this.shadowRoot,'[part~="current-box"]'),i=vD(this,TP,TO).call(this,vL(this,Tk)),r=vD(this,TN,TU).call(this,i,this.range.valueAsNumber),a=vD(this,TF,TB).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":vD(this,TK,TV).call(this);break;case"pointermove":vD(this,T$,TH).call(this,e);break;case"pointerup":vL(this,Tw)&&vw(this,Tw,!1);break;case"pointerdown":vw(this,Tw,!0);break;case"pointerleave":vD(this,TG,TW).call(this,null);break;case"transitionstart":mZ(e.target,this)&&setTimeout(()=>
1281vL(this,TD).call(this),0)}}}Tb=new WeakMap,TT=new WeakMap,TA=new WeakMap,T_=new WeakMap,TS=new WeakMap,Tk=new WeakMap,TR=new WeakMap,TL=new WeakMap,TI=new WeakMap,Tw=new WeakMap,TD=new WeakMap,TC=new WeakSet,TM=function(){return this.isConnected&&!this.mediaPaused&&!this.mediaLoading&&!this.mediaEnded&&this.mediaSeekableEnd>0&&m2(this)},Tx=new WeakMap,TP=new WeakSet,TO=function(e){var t;let i=(null!=(t=this.getAttribute("bounds")?mJ(this,`#${this.getAttribute("bounds")}`):this.parentElement)?t:this).getBoundingClientRect(),r=this.range.getBoundingClientRect(),a=e.offsetWidth,s=-(r.left-i.left-a/2),n=i.right-r.left-a/2;return{box:{width:a,min:s,max:n},bounds:i,range:r}},TN=new WeakSet,TU=function(e,t){let i=`${100*t}%`,{width:r,min:a,max:s}=e.box;if(!r)return i;if(!Number.isNaN(a)){let e=`calc(1 / var(--_range-width) * 100 * ${a}% + var(--media-box-padding-left))`;i=`max(${e}, ${i})`}if(!Number.isNaN(s)){let e=`calc(1 / var(--_range-width) * 100 * ${s}% - var(--media-box-padding-right))`;i=`min(${i}, ${e})`}return i},TF=new WeakSet,TB=function(e,t){let{width:i,min:r,max:a}=e.box,s=t*e.range.width;if(s<r+vL(this,TR)){let t=e.range.left-e.bounds.left-vL(this,TR);return`${s-i/2+t}px`}if(s>a-vL(this,TL)){let t=e.bounds.right-e.range.right-vL(this,TL);return`${s+i/2-t-e.range.width}px`}return 0},T$=new WeakSet,TH=function(e){let t=[...vL(this,TA)].some(t=>e.composedPath().includes(t));if(!this.dragging&&(t||!e.composedPath().includes(this)))return void vD(this,TG,TW).call(this,null);let i=this.mediaSeekableEnd;if(!i)return;let r=m3(this.shadowRoot,"#preview-rail"),a=m3(this.shadowRoot,'[part~="preview-box"]'),s=vD(this,TP,TO).call(this,vL(this,TS)),n=(e.clientX-s.range.left)/s.range.width;n=Math.max(0,Math.min(1,n));let l=vD(this,TN,TU).call(this,s,n),o=vD(this,TF,TB).call(this,s,n);r.style.transform=`translateX(${l})`,r.style.setProperty("--_range-width",`${s.range.width}`),a.style.setProperty("--_box-shift",`${o}`),a.style.setProperty("--_box-width",`${s.box.width}px`),1>Math.abs(Math.round(vL(this,T_))-Math.round(n*i))&&n>.01&&n<.99||(vw(this,T_,n*i),vD(this,TG,TW).call(this,vL(this,T_)))},TG=new WeakSet,TW=function(e){this.dispatchEvent(new m$.CustomEvent(ms.MEDIA_PREVIEW_REQUEST,{composed:!0,bubbles:!0,detail:e}))},TK=new WeakSet,TV=function(){vL(this,TT).stop();let e=vM(this);this.dispatchEvent(new m$.CustomEvent(ms.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:e}))},vx.shadowRootOptions={mode:"open"},vx.getContainerTemplateHTML=function(e){return`
1282    <style>
1283      :host {
1284        --media-box-border-radius: 4px;
1285        --media-box-padding-left: 10px;
1286        --media-box-padding-right: 10px;
1287        --media-preview-border-radius: var(--media-box-border-radius);
1288        --media-box-arrow-offset: var(--media-box-border-radius);
1289        --_control-background: var(--media-control-background, var(--media-secondary-color, rgb(20 20 30 / .7)));
1290        --_preview-background: var(--media-preview-background, var(--_control-background));
1291
1292        
1293        contain: layout;
1294      }
1295
1296      #buffered {
1297        background: var(--media-time-range-buffered-color, rgb(255 255 255 / .4));
1298        position: absolute;
1299        height: 100%;
1300        will-change: width;
1301      }
1302
1303      #preview-rail,
1304      #current-rail {
1305        width: 100%;
1306        position: absolute;
1307        left: 0;
1308        bottom: 100%;
1309        pointer-events: none;
1310        will-change: transform;
1311      }
1312
1313      [part~="box"] {
1314        width: min-content;
1315        
1316        position: absolute;
1317        bottom: 100%;
1318        flex-direction: column;
1319        align-items: center;
1320        transform: translateX(-50%);
1321      }
1322
1323      [part~="current-box"] {
1324        display: var(--media-current-box-display, var(--media-box-display, flex));
1325        margin: var(--media-current-box-margin, var(--media-box-margin, 0 0 5px));
1326        visibility: hidden;
1327      }
1328
1329      [part~="preview-box"] {
1330        display: var(--media-preview-box-display, var(--media-box-display, flex));
1331        margin: var(--media-preview-box-margin, var(--media-box-margin, 0 0 5px));
1332        transition-property: var(--media-preview-transition-property, visibility, opacity);
1333        transition-duration: var(--media-preview-transition-duration-out, .25s);
1334        transition-delay: var(--media-preview-transition-delay-out, 0s);
1335        visibility: hidden;
1336        opacity: 0;
1337      }
1338
1339      :host(:is([${md.MEDIA_PREVIEW_IMAGE}], [${md.MEDIA_PREVIEW_TIME}])[dragging]) [part~="preview-box"] {
1340        transition-duration: var(--media-preview-transition-duration-in, .5s);
1341        transition-delay: var(--media-preview-transition-delay-in, .25s);
1342        visibility: visible;
1343        opacity: 1;
1344      }
1345
1346      @media (hover: hover) {
1347        :host(:is([${md.MEDIA_PREVIEW_IMAGE}], [${md.MEDIA_PREVIEW_TIME}]):hover) [part~="preview-box"] {
1348          transition-duration: var(--media-preview-transition-duration-in, .5s);
1349          transition-delay: var(--media-preview-transition-delay-in, .25s);
1350          visibility: visible;
1351          opacity: 1;
1352        }
1353      }
1354
1355      media-preview-thumbnail,
1356      ::slotted(media-preview-thumbnail) {
1357        visibility: hidden;
1358        
1359        transition: visibility 0s .25s;
1360        transition-delay: calc(var(--media-preview-transition-delay-out, 0s) + var(--media-preview-transition-duration-out, .25s));
1361        background: var(--media-preview-thumbnail-background, var(--_preview-background));
1362        box-shadow: var(--media-preview-thumbnail-box-shadow, 0 0 4px rgb(0 0 0 / .2));
1363        max-width: var(--media-preview-thumbnail-max-width, 180px);
1364        max-height: var(--media-preview-thumbnail-max-height, 160px);
1365        min-width: var(--media-preview-thumbnail-min-width, 120px);
1366        min-height: var(--media-preview-thumbnail-min-height, 80px);
1367        border: var(--media-preview-thumbnail-border);
1368        border-radius: var(--media-preview-thumbnail-border-radius,
1369          var(--media-preview-border-radius) var(--media-preview-border-radius) 0 0);
1370      }
1371
1372      :host([${md.MEDIA_PREVIEW_IMAGE}][dragging]) media-preview-thumbnail,
1373      :host([${md.MEDIA_PREVIEW_IMAGE}][dragging]) ::slotted(media-preview-thumbnail) {
1374        transition-delay: var(--media-preview-transition-delay-in, .25s);
1375        visibility: visible;
1376      }
1377
1378      @media (hover: hover) {
1379        :host([${md.MEDIA_PREVIEW_IMAGE}]:hover) media-preview-thumbnail,
1380        :host([${md.MEDIA_PREVIEW_IMAGE}]:hover) ::slotted(media-preview-thumbnail) {
1381          transition-delay: var(--media-preview-transition-delay-in, .25s);
1382          visibility: visible;
1383        }
1384
1385        :host([${md.MEDIA_PREVIEW_TIME}]:hover) {
1386          --media-time-range-hover-display: block;
1387        }
1388      }
1389
1390      media-preview-chapter-display,
1391      ::slotted(media-preview-chapter-display) {
1392        font-size: var(--media-font-size, 13px);
1393        line-height: 17px;
1394        min-width: 0;
1395        visibility: hidden;
1396        
1397        transition: min-width 0s, border-radius 0s, margin 0s, padding 0s, visibility 0s;
1398        transition-delay: calc(var(--media-preview-transition-delay-out, 0s) + var(--media-preview-transition-duration-out, .25s));
1399        background: var(--media-preview-chapter-background, var(--_preview-background));
1400        border-radius: var(--media-preview-chapter-border-radius,
1401          var(--media-preview-border-radius) var(--media-preview-border-radius)
1402          var(--media-preview-border-radius) var(--media-preview-border-radius));
1403        padding: var(--media-preview-chapter-padding, 3.5px 9px);
1404        margin: var(--media-preview-chapter-margin, 0 0 5px);
1405        text-shadow: var(--media-preview-chapter-text-shadow, 0 0 4px rgb(0 0 0 / .75));
1406      }
1407
1408      :host([${md.MEDIA_PREVIEW_IMAGE}]) media-preview-chapter-display,
1409      :host([${md.MEDIA_PREVIEW_IMAGE}]) ::slotted(media-preview-chapter-display) {
1410        transition-delay: var(--media-preview-transition-delay-in, .25s);
1411        border-radius: var(--media-preview-chapter-border-radius, 0);
1412        padding: var(--media-preview-chapter-padding, 3.5px 9px 0);
1413        margin: var(--media-preview-chapter-margin, 0);
1414        min-width: 100%;
1415      }
1416
1417      media-preview-chapter-display[${md.MEDIA_PREVIEW_CHAPTER}],
1418      ::slotted(media-preview-chapter-display[${md.MEDIA_PREVIEW_CHAPTER}]) {
1419        visibility: visible;
1420      }
1421
1422      media-preview-chapter-display:not([aria-valuetext]),
1423      ::slotted(media-preview-chapter-display:not([aria-valuetext])) {
1424        display: none;
1425      }
1426
1427      media-preview-time-display,
1428      ::slotted(media-preview-time-display),
1429      media-time-display,
1430      ::slotted(media-time-display) {
1431        font-size: var(--media-font-size, 13px);
1432        line-height: 17px;
1433        min-width: 0;
1434        
1435        transition: min-width 0s, border-radius 0s;
1436        transition-delay: calc(var(--media-preview-transition-delay-out, 0s) + var(--media-preview-transition-duration-out, .25s));
1437        background: var(--media-preview-time-background, var(--_preview-background));
1438        border-radius: var(--media-preview-time-border-radius,
1439          var(--media-preview-border-radius) var(--media-preview-border-radius)
1440          var(--media-preview-border-radius) var(--media-preview-border-radius));
1441        padding: var(--media-preview-time-padding, 3.5px 9px);
1442        margin: var(--media-preview-time-margin, 0);
1443        text-shadow: var(--media-preview-time-text-shadow, 0 0 4px rgb(0 0 0 / .75));
1444        transform: translateX(min(
1445          max(calc(50% - var(--_box-width) / 2),
1446          calc(var(--_box-shift, 0))),
1447          calc(var(--_box-width) / 2 - 50%)
1448        ));
1449      }
1450
1451      :host([${md.MEDIA_PREVIEW_IMAGE}]) media-preview-time-display,
1452      :host([${md.MEDIA_PREVIEW_IMAGE}]) ::slotted(media-preview-time-display) {
1453        transition-delay: var(--media-preview-transition-delay-in, .25s);
1454        border-radius: var(--media-preview-time-border-radius,
1455          0 0 var(--media-preview-border-radius) var(--media-preview-border-radius));
1456        min-width: 100%;
1457      }
1458
1459      :host([${md.MEDIA_PREVIEW_TIME}]:hover) {
1460        --media-time-range-hover-display: block;
1461      }
1462
1463      [part~="arrow"],
1464      ::slotted([part~="arrow"]) {
1465        display: var(--media-box-arrow-display, inline-block);
1466        transform: translateX(min(
1467          max(calc(50% - var(--_box-width) / 2 + var(--media-box-arrow-offset)),
1468          calc(var(--_box-shift, 0))),
1469          calc(var(--_box-width) / 2 - 50% - var(--media-box-arrow-offset))
1470        ));
1471        
1472        border-color: transparent;
1473        border-top-color: var(--media-box-arrow-background, var(--_control-background));
1474        border-width: var(--media-box-arrow-border-width,
1475          var(--media-box-arrow-height, 5px) var(--media-box-arrow-width, 6px) 0);
1476        border-style: solid;
1477        justify-content: center;
1478        height: 0;
1479      }
1480    </style>
1481    <div id="preview-rail">
1482      <slot name="preview" part="box preview-box">
1483        <media-preview-thumbnail>
1484          <template shadowrootmode="${vr.shadowRootOptions.mode}">
1485            ${vr.getTemplateHTML({})}
1486          </template>
1487        </media-preview-thumbnail>
1488        <media-preview-chapter-display></media-preview-chapter-display>
1489        <media-preview-time-display></media-preview-time-display>
1490        <slot name="preview-arrow"><div part="arrow"></div></slot>
1491      </slot>
1492    </div>
1493    <div id="current-rail">
1494      <slot name="current" part="box current-box">
1495        
1496      </slot>
1497    </div>
1498  `},m$.customElements.get("media-time-range")||m$.customElements.define("media-time-range",vx);var vP=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot read from private field");return i?i.call(e):t.get(e)};Tq=new WeakMap,m$.customElements.get("media-volume-range")||m$.customElements.define("media-volume-range",class extends gr{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,Tq,()=>{let e=this.range.value,t=new m$.CustomEvent(ms.MEDIA_VOLUME_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)})}static get observedAttributes(){return[...super.observedAttributes,md.MEDIA_VOLUME,md.MEDIA_MUTED,md.MEDIA_VOLUME_UNAVAILABLE]}connectedCallback(){super.connectedCallback(),this.range.setAttribute("aria-label",mI("volume")),this.range.addEventListener("input",vP(this,Tq))}disconnectedCallback(){this.range.removeEventListener("input",vP(this,Tq)),super.disconnectedCallback()}attributeChangedCallback(e,t,i){if(super.attributeChangedCallback(e,t,i),e===md.MEDIA_VOLUME||e===md.MEDIA_MUTED){let e;this.range.valueAsNumber=this.mediaMuted?0:this.mediaVolume,this.range.setAttribute("aria-valuetext",(e=this.range.valueAsNumber,`${Math.round(100*e)}%`)),this.updateBar()}}
1498get mediaVolume(){return m5(this,md.MEDIA_VOLUME,1)}set mediaVolume(e){m8(this,md.MEDIA_VOLUME,e)}get mediaMuted(){return m6(this,md.MEDIA_MUTED)}set mediaMuted(e){m9(this,md.MEDIA_MUTED,e)}get mediaVolumeUnavailable(){return m7(this,md.MEDIA_VOLUME_UNAVAILABLE)}set mediaVolumeUnavailable(e){fe(this,md.MEDIA_VOLUME_UNAVAILABLE,e)}});class vO extends pW{constructor(){super(...arguments),this.container=null}static get observedAttributes(){return[...super.observedAttributes,md.MEDIA_LOOP]}connectedCallback(){var e;super.connectedCallback(),this.container=(null==(e=this.shadowRoot)?void 0:e.querySelector("#icon"))||null,this.container&&(this.container.textContent=mI("Loop"))}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===md.MEDIA_LOOP&&this.container&&this.setAttribute("aria-checked",this.mediaLoop?"true":"false")}get mediaLoop(){return m6(this,md.MEDIA_LOOP)}set mediaLoop(e){m9(this,md.MEDIA_LOOP,e)}handleClick(){let e=!this.mediaLoop,t=new m$.CustomEvent(ms.MEDIA_LOOP_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)}}vO.getSlotTemplateHTML=function(e){return`
1499      <style>
1500        :host {
1501          min-width: 4ch;
1502          padding: var(--media-button-padding, var(--media-control-padding, 10px 5px));
1503          width: 100%;
1504          display: grid;
1505          grid-template-columns: 1fr auto;
1506          gap: 1rem;
1507          font-weight: var(--media-button-font-weight, normal);
1508        }
1509
1510        #checked-indicator {
1511          display: none;
1512        }
1513
1514        :host([${md.MEDIA_LOOP}]) #checked-indicator {
1515          display: block;
1516        }
1517      </style>
1518      
1519      <span id="icon">
1520     </span>
1521
1522      <div id="checked-indicator">
1523        <svg aria-hidden="true" viewBox="0 1 24 24" part="checked-indicator indicator">
1524          <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"/>
1525        </svg>
1526      </div>
1527    `},vO.getTooltipContentHTML=function(){return mI("Loop")},m$.customElements.get("media-loop-button")||m$.customElements.define("media-loop-button",vO);var vN=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},vU=(e,t,i)=>(vN(e,t,"read from private field"),i?i.call(e):t.get(e)),vF=(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)},vB=(e,t,i,r)=>(vN(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i);let v$={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 vY&&"boolean"==typeof r.element[r.attributeName]?r.booleanValue=t:"function"==typeof t&&r instanceof vY?r.element[r.attributeName]=t:r.value=t}}}};class vH extends m$.DocumentFragment{constructor(e,t,i=v$){var r;super(),vF(this,Tj,void 0),vF(this,TY,void 0),this.append(e.content.cloneNode(!0)),vB(this,Tj,vG(this)),vB(this,TY,i),null==(r=i.createCallback)||r.call(i,this,vU(this,Tj),t),i.processCallback(this,vU(this,Tj),t)}update(e){vU(this,TY).processCallback(this,vU(this,Tj),e)}}Tj=new WeakMap,TY=new WeakMap;let vG=(e,t=[])=>{let i,r;for(let a of e.attributes||[])if(a.value.includes("{{")){let s=new vj;for([i,r]of vK(a.value))if(i){let i=new vY(e,a.name,a.namespaceURI);s.append(i),t.push([r,i])}else s.append(r);a.value=s.toString()}for(let a of e.childNodes)if(1!==a.nodeType||a instanceof HTMLTemplateElement){let s=a.data;if(1===a.nodeType||s.includes("{{")){let n=[];if(s)for([i,r]of vK(s))if(i){let i=new vz(e);n.push(i),t.push([r,i])}else n.push(new Text(r));else if(a instanceof HTMLTemplateElement){let i=new vQ(e,a);n.push(i),t.push([i.expression,i])}a.replaceWith(...n.flatMap(e=>e.replacementNodes||[e]))}}else vG(a,t);return t},vW={},vK=e=>{let t="",i=0,r=vW[e],a=0,s;if(r)return r;for(r=[];s=e[a];a++)"{"===s&&"{"===e[a+1]&&"\\"!==e[a-1]&&e[a+2]&&1==++i?(t&&r.push([0,t]),t="",a++):"}"!==s||"}"!==e[a+1]||"\\"===e[a-1]||--i?t+=s||"":(r.push([1,t.trim()]),t="",a++);return t&&r.push([0,(i>0?"{{":"")+t]),vW[e]=r};class vV{get value(){return""}set value(e){}toString(){return this.value}}let vq=new WeakMap;class vj{constructor(){vF(this,Tz,[])}[Symbol.iterator](){return vU(this,Tz).values()}get length(){return vU(this,Tz).length}item(e){return vU(this,Tz)[e]}append(...e){for(let t of e)t instanceof vY&&vq.set(t,this),vU(this,Tz).push(t)}toString(){return vU(this,Tz).join("")}}Tz=new WeakMap;class vY extends vV{constructor(e,t,i){super(),vF(this,T0),vF(this,TQ,""),vF(this,TX,void 0),vF(this,TZ,void 0),vF(this,TJ,void 0),vB(this,TX,e),vB(this,TZ,t),vB(this,TJ,i)}get attributeName(){return vU(this,TZ)}get attributeNamespace(){return vU(this,TJ)}
1527get element(){return vU(this,TX)}get value(){return vU(this,TQ)}set value(e){vU(this,TQ)!==e&&(vB(this,TQ,e),vU(this,T0,T1)&&1!==vU(this,T0,T1).length?vU(this,TX).setAttributeNS(vU(this,TJ),vU(this,TZ),vU(this,T0,T1).toString()):null==e?vU(this,TX).removeAttributeNS(vU(this,TJ),vU(this,TZ)):vU(this,TX).setAttributeNS(vU(this,TJ),vU(this,TZ),e))}get booleanValue(){return vU(this,TX).hasAttributeNS(vU(this,TJ),vU(this,TZ))}set booleanValue(e){if(vU(this,T0,T1)&&1!==vU(this,T0,T1).length)throw new DOMException("Value is not fully templatized");this.value=e?"":null}}TQ=new WeakMap,TX=new WeakMap,TZ=new WeakMap,TJ=new WeakMap,T0=new WeakSet,T1=function(){return vq.get(this)};class vz extends vV{constructor(e,t){super(),vF(this,T2,void 0),vF(this,T3,void 0),vB(this,T2,e),vB(this,T3,t?[...t]:[new Text])}get replacementNodes(){return vU(this,T3)}get parentNode(){return vU(this,T2)}get nextSibling(){return vU(this,T3)[vU(this,T3).length-1].nextSibling}get previousSibling(){return vU(this,T3)[0].previousSibling}get value(){return vU(this,T3).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),vB(this,T3,function(e,t,i,r=null){let a=0,s,n,l,o=i.length,d=t.length;for(;a<o&&a<d&&t[a]==i[a];)a++;for(;a<o&&a<d&&i[o-1]==t[d-1];)r=i[--d,--o];if(a==d)for(;a<o;)e.insertBefore(i[a++],r);if(a==o)for(;a<d;)e.removeChild(t[a++]);else{for(s=t[a];a<o;)l=i[a++],n=s?s.nextSibling:r,s==l?s=n:a<o&&i[a]==n?(e.replaceChild(l,s),s=n):e.insertBefore(l,s);for(;s!=r;)n=s.nextSibling,e.removeChild(s),s=n}return i}(vU(this,T3)[0].parentNode,vU(this,T3),t,this.nextSibling))}}T2=new WeakMap,T3=new WeakMap;class vQ extends vz{constructor(e,t){const i=t.getAttribute("directive")||t.getAttribute("type");let 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}}let vX={string:e=>String(e)};class vZ{constructor(e){this.template=e,this.state=void 0}}let vJ=new WeakMap,v0=new WeakMap,v1={partial:(e,t)=>{t[e.expression]=new vZ(e.template)},if:(e,t)=>{var i;if(v5(e.expression,t))if(vJ.get(e)!==e.template){vJ.set(e,e.template);let i=new vH(e.template,t,v3);e.replace(i),v0.set(e,i)}else null==(i=v0.get(e))||i.update(t);else e.replace(""),vJ.delete(e),v0.delete(e)}},v2=Object.keys(v1),v3={processCallback(e,t,i){var r,a;if(i)for(let[e,s]of t){if(s instanceof vQ){if(!s.directive){let e=v2.find(e=>s.template.hasAttribute(e));e&&(s.directive=e,s.expression=s.template.getAttribute(e))}null==(r=v1[s.directive])||r.call(v1,s,i);continue}let t=v5(e,i);if(t instanceof vZ){vJ.get(s)!==t.template?(vJ.set(s,t.template),s.value=t=new vH(t.template,t.state,v3),v0.set(s,t)):null==(a=v0.get(s))||a.update(t.state);continue}t?(s instanceof vY&&s.attributeName.startsWith("aria-")&&(t=String(t)),s instanceof vY?"boolean"==typeof t?s.booleanValue=t:"function"==typeof t?s.element[s.attributeName]=t:s.value=t:(s.value=t,vJ.delete(s),v0.delete(s))):s instanceof vY?s.value=void 0:(s.value=void 0,vJ.delete(s),v0.delete(s))}}},v4={"!":e=>!e,"!!":e=>!!e,"==":(e,t)=>e==t,"!=":(e,t)=>e!=t,">":(e,t)=>e>t,">=":(e,t)=>
1527e>=t,"<":(e,t)=>e<t,"<=":(e,t)=>e<=t,"??":(e,t)=>null!=e?e:t,"|":(e,t)=>{var i;return null==(i=vX[t])?void 0:i.call(vX,e)}};function v5(e,t={}){var i,r,a,s,n,l,o;let d=(function(e,t){let i,r,a,s=[];for(;e;){for(let s in a=null,i=e.length,t)(r=t[s].exec(e))&&r.index<i&&(a={token:r[0],type:s,matches:r.slice(1)},i=r.index);i&&s.push({token:e.substr(0,i),type:void 0}),a&&s.push(a),e=e.substr(i+(a?a.token.length:0))}return s})(e,{boolean:/true|false/,number:/-?\d+\.?\d*/,string:/(["'])((?:\\.|[^\\])*?)\1/,operator:/[!=><][=!]?|\?\?|\|/,ws:/\s+/,param:/[$a-z_][$\w]*/i}).filter(({type:e})=>"ws"!==e);if(0===d.length||d.some(({type:e})=>!e))return v8(e);if((null==(i=d[0])?void 0:i.token)===">"){let i=t[null==(r=d[1])?void 0:r.token];if(!i)return v8(e);let l={...t};i.state=l;let o=d.slice(2);for(let e=0;e<o.length;e+=3){let i=null==(a=o[e])?void 0:a.token,r=null==(s=o[e+1])?void 0:s.token,d=null==(n=o[e+2])?void 0:n.token;i&&"="===r&&(l[i]=v9(d,t))}return i}if(1===d.length)return v6(d[0])?v9(d[0].token,t):v8(e);if(2===d.length){let i=v4[null==(l=d[0])?void 0:l.token];return i&&v6(d[1])?i(v9(d[1].token,t)):v8(e)}if(3===d.length){let i=null==(o=d[1])?void 0:o.token,r=v4[i];if(!r||!v6(d[0])||!v6(d[2]))return v8(e);let a=v9(d[0].token,t);return r(a,"|"===i?d[2].token:v9(d[2].token,t))}}function v8(e){return console.warn(`Warning: invalid expression \`${e}\``),!1}function v6({type:e}){return["number","boolean","string","param"].includes(e)}function v9(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):mS(e)?parseFloat(e):t[e]}var v7=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},Ee=(e,t,i)=>(v7(e,t,"read from private field"),i?i.call(e):t.get(e)),Et=(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)},Ei=(e,t,i,r)=>(v7(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i),Er=(e,t,i)=>(v7(e,t,"access private method"),i);let Ea={mediatargetlivewindow:"targetlivewindow",mediastreamtype:"streamtype"},Es=mH.createElement("template");Es.innerHTML=`
1528  <style>
1529    :host {
1530      display: inline-block;
1531      line-height: 0;
1532    }
1533
1534    media-controller {
1535      width: 100%;
1536      height: 100%;
1537    }
1538
1539    media-captions-button:not([mediasubtitleslist]),
1540    media-captions-menu:not([mediasubtitleslist]),
1541    media-captions-menu-button:not([mediasubtitleslist]),
1542    media-audio-track-menu[mediaaudiotrackunavailable],
1543    media-audio-track-menu-button[mediaaudiotrackunavailable],
1544    media-rendition-menu[mediarenditionunavailable],
1545    media-rendition-menu-button[mediarenditionunavailable],
1546    media-volume-range[mediavolumeunavailable],
1547    media-airplay-button[mediaairplayunavailable],
1548    media-fullscreen-button[mediafullscreenunavailable],
1549    media-cast-button[mediacastunavailable],
1550    media-pip-button[mediapipunavailable] {
1551      display: none;
1552    }
1553  </style>
1554`;class En extends m$.HTMLElement{constructor(){super(),Et(this,T9),Et(this,Ae),Et(this,T4,void 0),Et(this,T5,void 0),Et(this,T8,void 0),Et(this,T6,void 0),Et(this,Ai,void 0),this.shadowRoot?this.renderRoot=this.shadowRoot:(this.renderRoot=this.attachShadow({mode:"open"}),this.createRenderer()),Ei(this,T6,new MutationObserver(e=>{var t;(!this.mediaController||(null==(t=this.mediaController)?void 0:t.breakpointsComputed))&&e.some(e=>{let t=e.target;return t===this||"media-controller"===t.localName&&!!(Ea[e.attributeName]||e.attributeName.startsWith("breakpoint"))})&&this.render()})),Ei(this,Ai,this.render.bind(this)),Er(this,T9,T7).call(this,"template")}get mediaController(){return this.renderRoot.querySelector("media-controller")}get template(){var e;return null!=(e=Ee(this,T4))?e:this.constructor.template}set template(e){null===e?this.removeAttribute("template"):"string"==typeof e?this.setAttribute("template",e):e instanceof HTMLTemplateElement&&(Ei(this,T4,e),Ei(this,T8,null),this.createRenderer())}get props(){var e,t,i;let r=[...Array.from(null!=(t=null==(e=this.mediaController)?void 0:e.attributes)?t:[]).filter(({name:e})=>Ea[e]||e.startsWith("breakpoint")),...Array.from(this.attributes)],a={};for(let e of r){let t=null!=(i=Ea[e.name])?i:e.name.replace(/[-_]([a-z])/g,(e,t)=>t.toUpperCase()),{value:r}=e;null!=r?(mS(r)&&(r=parseFloat(r)),a[t]=""===r||r):a[t]=!1}return a}
1554attributeChangedCallback(e,t,i){"template"===e&&t!=i&&Er(this,Ae,At).call(this)}connectedCallback(){this.addEventListener(mh.BREAKPOINTS_COMPUTED,Ee(this,Ai)),Ee(this,T6).observe(this,{attributes:!0}),Ee(this,T6).observe(this.renderRoot,{attributes:!0,subtree:!0}),Er(this,Ae,At).call(this)}disconnectedCallback(){this.removeEventListener(mh.BREAKPOINTS_COMPUTED,Ee(this,Ai)),Ee(this,T6).disconnect()}createRenderer(){this.template instanceof HTMLTemplateElement&&this.template!==Ee(this,T5)&&(Ei(this,T5,this.template),this.renderer=new vH(this.template,this.props,this.constructor.processor),this.renderRoot.textContent="",this.renderRoot.append(Es.content.cloneNode(!0),this.renderer))}render(){var e;null==(e=this.renderer)||e.update(this.props)}}async function El(e){let t=await fetch(e);if(200!==t.status)throw Error(`Failed to load resource: the server responded with a status of ${t.status}`);return t.text()}function Eo(e){return e.split("-")[0]}T4=new WeakMap,T5=new WeakMap,T8=new WeakMap,T6=new WeakMap,T9=new WeakSet,T7=function(e){if(Object.prototype.hasOwnProperty.call(this,e)){let t=this[e];delete this[e],this[e]=t}},Ae=new WeakSet,At=function(){var e;let t=this.getAttribute("template");if(!t||t===Ee(this,T8))return;let i=this.getRootNode(),r=null==(e=null==i?void 0:i.getElementById)?void 0:e.call(i,t);if(r){Ei(this,T8,t),Ei(this,T4,r),this.createRenderer();return}(function(e){if(!/^(\/|\.\/|https?:\/\/)/.test(e))return!1;let t=/^https?:\/\//.test(e)?void 0:location.origin;try{new URL(e,t)}catch(e){return!1}return!0})(t)&&(Ei(this,T8,t),El(t).then(e=>{let t=mH.createElement("template");t.innerHTML=e,Ei(this,T4,t),this.createRenderer()}).catch(console.error))},Ai=new WeakMap,En.observedAttributes=["template"],En.processor=v3,m$.customElements.get("media-theme")||m$.customElements.define("media-theme",En);class Ed extends Event{constructor({action:e="auto",relatedTarget:t,...i}){super("invoke",i),this.action=e,this.relatedTarget=t}}class Eh extends Event{constructor({newState:e,oldState:t,...i}){super("toggle",i),this.newState=e,this.oldState=t}}var Eu=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},Ec=(e,t,i)=>(Eu(e,t,"read from private field"),i?i.call(e):t.get(e)),Em=(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)},Ef=(e,t,i,r)=>(Eu(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i),Ep=(e,t,i)=>(Eu(e,t,"access private method"),i);function Eg({type:e,text:t,value:i,checked:r}){let a=mH.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 s=mH.createElement("span");return s.textContent=t,a.append(s),a}function Ev(e,t){let i=e.querySelector(`:scope > [slot="${t}"]`);if((null==i?void 0:i.nodeName)=="SLOT"&&(i=i.assignedElements({flatten:!0})[0]),i)return i.cloneNode(!0);let r=e.shadowRoot.querySelector(`[name="${t}"] > svg`);return r?r.cloneNode(!0):""}let EE="style",Ey="hidden",Eb="disabled";class ET extends m$.HTMLElement{constructor(){if(super(),Em(this,Ah),Em(this,Ac),Em(this,Ap),Em(this,Av),Em(this,Ay),Em(this,AT),Em(this,Ak),Em(this,AL),Em(this,Aw),Em(this,AC),Em(this,Ax),Em(this,AO),Em(this,AU),Em(this,AB),Em(this,AH),Em(this,AW),Em(this,AV),Em(this,Aj),Em(this,Ar,null),Em(this,Aa,null),Em(this,As,null),Em(this,An,new Set),Em(this,Al,void 0),Em(this,Ao,!1),Em(this,Ad,null),Em(this,Af,()=>{let e=Ec(this,An),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}));Ef(this,An,t)}),Em(this,A_,()=>{Ep(this,Ak,AR).call(this),Ep(this,AL,AI).call(this,!1)}),Em(this,AS,()=>{Ep(this,Ak,AR).call(this)}),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);const e=mj(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e)}this.container=this.shadowRoot.querySelector("#container"),this.defaultSlot=this.shadowRoot.querySelector("slot:not([name])"),Ef(this,Al,new MutationObserver(Ec(this,Af)))}static get observedAttributes(){return[Eb,Ey,EE,"anchor",mn.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":Ep(this,Ah,Au).call(this,e);break;case"invoke":Ep(this,Av,AE).call(this,e);break;case"click":Ep(this,Aw,AD).call(this,e);break;case"toggle":Ep(this,Ax,AP).call(this,e);break;case"focusout":Ep(this,AU,AF).call(this,e);break;case"keydown":Ep(this,AB,A$).call(this,e)}}connectedCallback(){var e,t;Ec(this,Al).observe(this.defaultSlot,{childList:!0}),Ef(this,Ad,m4(this.shadowRoot,":host")),Ep(this,Ap,Ag).call(this),this.hasAttribute("disabled")||this.enable(),this.role||(this.role="menu"),Ef(this,Ar,mz(this)),null==(t=null==(e=Ec(this,Ar))?void 0:e.associateElement)||t.call(e,this),this.hidden||(mV(E_(this),Ec(this,A_)),mV(this,Ec(this,AS))),Ep(this,Ac,Am).call(this),this.shadowRoot.addEventListener("slotchange",this)}disconnectedCallback(){var e,t;Ec(this,Al).disconnect(),mq(E_(this),Ec(this,A_)),mq(this,Ec(this,AS)),this.disable(),null==(t=null==(e=Ec(this,Ar))?void 0:e.unassociateElement)||t.call(e,this),Ef(this,Ar,null),Ef(this,Aa,null),Ef(this,As,null),this.shadowRoot.removeEventListener("slotchange",this)}attributeChangedCallback(e,t,i){var r,a,s,n;e===Ey&&i!==t?(Ec(this,Ao)||Ef(this,Ao,!0),this.hidden?Ep(this,AT,AA).call(this):Ep(this,Ay,Ab).
1554call(this),this.dispatchEvent(new Eh({oldState:this.hidden?"open":"closed",newState:this.hidden?"closed":"open",bubbles:!0}))):e===mn.MEDIA_CONTROLLER?(t&&(null==(a=null==(r=Ec(this,Ar))?void 0:r.unassociateElement)||a.call(r,this),Ef(this,Ar,null)),i&&this.isConnected&&(Ef(this,Ar,mz(this)),null==(n=null==(s=Ec(this,Ar))?void 0:s.associateElement)||n.call(s,this))):e===Eb&&i!==t?null==i?this.enable():this.disable():e===EE&&i!==t&&Ep(this,Ap,Ag).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=m1(this))?void 0:e.querySelector(`#${this.anchor}`):null}get items(){return this.defaultSlot.assignedElements({flatten:!0}).filter(EA)}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&&Ep(this,Aj,AY).call(this,t)}focus(){if(Ef(this,Aa,m0()),this.items.length){Ep(this,AV,Aq).call(this,this.items[0]),this.items[0].focus();return}let e=this.querySelector('[autofocus], [tabindex]:not([tabindex="-1"]), [role="menu"]');null==e||e.focus()}handleSelect(e){var t;let i=Ep(this,AH,AG).call(this,e);i&&(Ep(this,Aj,AY).call(this,i,"checkbox"===i.type),Ec(this,As)&&!this.hidden&&(null==(t=Ec(this,Aa))||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,s=null!=(i=null!=(t=Ep(this,AH,AG).call(this,e))?t:Ep(this,AW,AK).call(this))?i:a[0],n=Math.max(0,a.indexOf(s));"ArrowDown"===r?n++:"ArrowUp"===r?n--:"Home"===e.key?n=0:"End"===e.key&&(n=a.length-1),n<0&&(n=a.length-1),n>a.length-1&&(n=0),Ep(this,AV,Aq).call(this,a[n]),a[n].focus()}}function EA(e){return["menuitem","menuitemradio","menuitemcheckbox"].includes(null==e?void 0:e.role)}function E_(e){var t;return null!=(t=e.getAttribute("bounds")?mJ(e,`#${e.getAttribute("bounds")}`):mY(e)||e.parentElement)?t:e}Ar=new WeakMap,Aa=new WeakMap,As=new WeakMap,An=new WeakMap,Al=new WeakMap,Ao=new WeakMap,Ad=new WeakMap,Ah=new WeakSet,Au=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)&&Ep(this,Ac,Am).call(this),t.name||Ec(this,Af).call(this)},Ac=new WeakSet,Am=function(){let e=this.shadowRoot.querySelector('slot[name="header"]');e.hidden=0===this.shadowRoot.querySelector('slot[name="title"]').assignedNodes().length&&0===e.assignedNodes().length},Af=new WeakMap,Ap=new WeakSet,Ag=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")},Av=new WeakSet,AE=function(e){Ef(this,As,e.relatedTarget),mZ(this,e.relatedTarget)||(this.hidden=!this.hidden)},Ay=new WeakSet,Ab=function(){var e;null==(e=Ec(this,As))||e.setAttribute("aria-expanded","true"),this.addEventListener("transitionend",()=>this.focus(),{once:!0}),mV(E_(this),Ec(this,A_)),mV(this,Ec(this,AS))},AT=new WeakSet,AA=function(){var e;null==(e=Ec(this,As))||e.setAttribute("aria-expanded","false"),mq(E_(this),Ec(this,A_)),mq(this,Ec(this,AS))},A_=new WeakMap,AS=new WeakMap,Ak=new WeakSet,AR=function(e){if(this.hasAttribute("mediacontroller")&&!this.anchor||this.hidden||!this.anchorElement)return;let{x:t,y:i}=function({anchor:e,floating:t,placement:i}){let{x:r,y:a}=function({anchor:e,floating:t},i){let r,a="x"==(["top","bottom"].includes(Eo(i))?"y":"x")?"y":"x",s="y"===a?"height":"width",n=Eo(i),l=e.x+e.width/2-t.width/2,o=e.y+e.height/2-t.height/2,d=e[s]/2-t[s]/2;switch(n){case"top":r={x:l,y:e.y-t.height};break;case"bottom":r={x:l,y:e.y+e.height};break;case"right":r={x:e.x+e.width,y:o};break;case"left":r={x:e.x-t.width,y:o};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}(function({anchor:e,floating:t}){var i,r,a;let s,n;return{anchor:(i=e,r=t.offsetParent,s=i.getBoundingClientRect(),n=null!=(a=null==r?void 0:r.getBoundingClientRect())?a:{x:0,y:0},{x:s.x-n.x,y:s.y-n.y,width:s.width,height:s.height}),floating:{x:0,y:0,width:t.offsetWidth,height:t.offsetHeight}}}({anchor:e,floating:t}),i);return{x:r,y:a}}({anchor:this.anchorElement,floating:this,placement:"top-start"});null!=e||(e=this.offsetWidth);let r=E_(this).getBoundingClientRect(),a=r.width-t-e,s=r.height-i-this.offsetHeight,{style:n}=Ec(this,Ad);n.setProperty("position","absolute"),n.setProperty("right",`${Math.max(0,a)}px`),n.setProperty("--_menu-bottom",`${s}px`);let l=getComputedStyle(this),o=n.getPropertyValue("--_menu-bottom")===l.bottom?s:parseFloat(l.bottom),d=r.height-o-parseFloat(l.marginBottom);this.style.setProperty("--_menu-max-height",`${d}px`)},AL=new WeakSet,AI=function(e){let t=this.querySelector('[role="menuitem"][aria-haspopup][aria-expanded="true"]'),i=null==t?void 0:t.querySelector('[role="menu"]'),{style:r}=Ec(this,Ad);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`),Ep(this,Ak,AR).call(this,r)}else this.style.removeProperty("min-width"),this.style.removeProperty("min-height"),Ep(this,Ak,AR).call(this);r.removeProperty("--media-menu-transition-in")},Aw=new WeakSet,AD=function(e){var t;if(e.stopPropagation(),e.composedPath().includes(Ec(this,AC,AM))){null==(t=Ec(this,Aa))||t.focu
1554s(),this.hidden=!0;return}let i=Ep(this,AH,AG).call(this,e);!i||i.hasAttribute("disabled")||(Ep(this,AV,Aq).call(this,i),this.handleSelect(e))},AC=new WeakSet,AM=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"]'))},Ax=new WeakSet,AP=function(e){if(e.target===this)return;Ep(this,AO,AN).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 Ed({relatedTarget:i})));for(let e of t)e.setAttribute("aria-expanded",`${!e.submenuElement.hidden}`);Ep(this,AL,AI).call(this,!0)},AO=new WeakSet,AN=function(){let e=this.querySelector('[role="menuitem"] > [role="menu"]:not([hidden])');this.container.classList.toggle("has-expanded",!!e)},AU=new WeakSet,AF=function(e){var t;mZ(this,e.relatedTarget)||(Ec(this,Ao)&&(null==(t=Ec(this,Aa))||t.focus()),Ec(this,As)&&Ec(this,As)!==e.relatedTarget&&!this.hidden&&(this.hidden=!0))},AB=new WeakSet,A$=function(e){var t,i,r,a,s;let{key:n,ctrlKey:l,altKey:o,metaKey:d}=e;if(!l&&!o&&!d&&this.keysUsed.includes(n))if(e.preventDefault(),e.stopPropagation(),"Tab"===n){if(Ec(this,Ao)){this.hidden=!0;return}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"===n?(null==(s=Ec(this,Aa))||s.focus(),Ec(this,Ao)&&(this.hidden=!0)):"Enter"===n||" "===n?this.handleSelect(e):this.handleMove(e)},AH=new WeakSet,AG=function(e){return e.composedPath().find(e=>["menuitemradio","menuitemcheckbox"].includes(e.role))},AW=new WeakSet,AK=function(){return this.items.find(e=>0===e.tabIndex)},AV=new WeakSet,Aq=function(e){for(let t of this.items)t.tabIndex=t===e?0:-1},Aj=new WeakSet,AY=function(e,t){let i=[...this.checkedItems];"radio"===e.type&&this.radioGroupItems.forEach(e=>e.checked=!1),t?e.checked=!e.checked:e.checked=!0,this.checkedItems.some((e,t)=>e!=i[t])&&this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))},ET.shadowRootOptions={mode:"open"},ET.getTemplateHTML=function(e){return`
1555    <style>
1556      :host {
1557        font: var(--media-font,
1558          var(--media-font-weight, normal)
1559          var(--media-font-size, 14px) /
1560          var(--media-text-content-height, var(--media-control-height, 24px))
1561          var(--media-font-family, helvetica neue, segoe ui, roboto, arial, sans-serif));
1562        color: var(--media-text-color, var(--media-primary-color, rgb(238 238 238)));
1563        --_menu-bg: rgb(20 20 30 / .8);
1564        background: var(--media-menu-background, var(--media-control-background, var(--media-secondary-color, var(--_menu-bg))));
1565        border-radius: var(--media-menu-border-radius);
1566        border: var(--media-menu-border, none);
1567        display: var(--media-menu-display, inline-flex) !important;
1568        
1569        transition: var(--media-menu-transition-in,
1570          visibility 0s,
1571          opacity .2s ease-out,
1572          transform .15s ease-out,
1573          left .2s ease-in-out,
1574          min-width .2s ease-in-out,
1575          min-height .2s ease-in-out
1576        ) !important;
1577        
1578        visibility: var(--media-menu-visibility, visible);
1579        opacity: var(--media-menu-opacity, 1);
1580        max-height: var(--media-menu-max-height, var(--_menu-max-height, 300px));
1581        transform: var(--media-menu-transform-in, translateY(0) scale(1));
1582        flex-direction: column;
1583        
1584        min-height: 0;
1585        position: relative;
1586        bottom: var(--_menu-bottom);
1587        box-sizing: border-box;
1588      } 
1589
1590      @-moz-document url-prefix() {
1591        :host{
1592          --_menu-bg: rgb(20 20 30);
1593        }
1594      }
1595
1596      :host([hidden]) {
1597        transition: var(--media-menu-transition-out,
1598          visibility .15s ease-in,
1599          opacity .15s ease-in,
1600          transform .15s ease-in
1601        ) !important;
1602        visibility: var(--media-menu-hidden-visibility, hidden);
1603        opacity: var(--media-menu-hidden-opacity, 0);
1604        max-height: var(--media-menu-hidden-max-height,
1605          var(--media-menu-max-height, var(--_menu-max-height, 300px)));
1606        transform: var(--media-menu-transform-out, translateY(2px) scale(.99));
1607        pointer-events: none;
1608      }
1609
1610      :host([slot="submenu"]) {
1611        background: none;
1612        width: 100%;
1613        min-height: 100%;
1614        position: absolute;
1615        bottom: 0;
1616        right: -100%;
1617      }
1618
1619      #container {
1620        display: flex;
1621        flex-direction: column;
1622        min-height: 0;
1623        transition: transform .2s ease-out;
1624        transform: translate(0, 0);
1625      }
1626
1627      #container.has-expanded {
1628        transition: transform .2s ease-in;
1629        transform: translate(-100%, 0);
1630      }
1631
1632      button {
1633        background: none;
1634        color: inherit;
1635        border: none;
1636        padding: 0;
1637        font: inherit;
1638        outline: inherit;
1639        display: inline-flex;
1640        align-items: center;
1641      }
1642
1643      slot[name="header"][hidden] {
1644        display: none;
1645      }
1646
1647      slot[name="header"] > *,
1648      slot[name="header"]::slotted(*) {
1649        padding: .4em .7em;
1650        border-bottom: 1px solid rgb(255 255 255 / .25);
1651        cursor: var(--media-cursor, default);
1652      }
1653
1654      slot[name="header"] > button[part~="back"],
1655      slot[name="header"]::slotted(button[part~="back"]) {
1656        cursor: var(--media-cursor, pointer);
1657      }
1658
1659      svg[part~="back"] {
1660        height: var(--media-menu-icon-height, var(--media-control-height, 24px));
1661        fill: var(--media-icon-color, var(--media-primary-color, rgb(238 238 238)));
1662        display: block;
1663        margin-right: .5ch;
1664      }
1665
1666      slot:not([name]) {
1667        gap: var(--media-menu-gap);
1668        flex-direction: var(--media-menu-flex-direction, column);
1669        overflow: var(--media-menu-overflow, hidden auto);
1670        display: flex;
1671        min-height: 0;
1672      }
1673
1674      :host([role="menu"]) slot:not([name]) {
1675        padding-block: .4em;
1676      }
1677
1678      slot:not([name])::slotted([role="menu"]) {
1679        background: none;
1680      }
1681
1682      media-chrome-menu-item > span {
1683        margin-right: .5ch;
1684        max-width: var(--media-menu-item-max-width);
1685        text-overflow: ellipsis;
1686        overflow: hidden;
1687      }
1688    </style>
1689    <style id="layout-row" media="width:0">
1690
1691      slot[name="header"] > *,
1692      slot[name="header"]::slotted(*) {
1693        padding: .4em .5em;
1694      }
1695
1696      slot:not([name]) {
1697        gap: var(--media-menu-gap, .25em);
1698        flex-direction: var(--media-menu-flex-direction, row);
1699        padding-inline: .5em;
1700      }
1701
1702      media-chrome-menu-item {
1703        padding: .3em .5em;
1704      }
1705
1706      media-chrome-menu-item[aria-checked="true"] {
1707        background: var(--media-menu-item-checked-background, rgb(255 255 255 / .2));
1708      }
1709
1710      
1711      media-chrome-menu-item::part(checked-indicator) {
1712        display: var(--media-menu-item-checked-indicator-display, none);
1713      }
1714    </style>
1715    <div id="container" part="container">
1716      <slot name="header" hidden>
1717        <button part="back button" aria-label="Back to previous menu">
1718          <slot name="back-icon">
1719            <svg aria-hidden="true" viewBox="0 0 20 24" part="back indicator">
1720              <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"/>
1721            </svg>
1722          </slot>
1723          <slot name="title"></slot>
1724        </button>
1725      </slot>
1726      <slot></slot>
1727    </div>
1728    <slot name="checked-indicator" hidden></slot>
1729  `},m$.customElements.get("media-chrome-menu")||m$.customElements.define("media-chrome-menu",ET);var ES=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},Ek=(e,t,i)=>(ES(e,t,"read from private field"),i?i.call(e):t.get(e)),ER=(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)=>(ES(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i),EI=(e,t,i)=>(ES(e,t,"access private method"),i);let Ew="type",ED="value",EC="checked",EM="disabled";class Ex extends m$.HTMLElement{constructor(){if(super(),ER(this,AX
1729),ER(this,AJ),ER(this,A1),ER(this,A8),ER(this,Az,!1),ER(this,AQ,void 0),ER(this,A3,()=>{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,s=mH.createElement("span");s.textContent=null!=a?a:"",i.replaceChildren(s)}),ER(this,A4,e=>{let{key:t}=e;this.keysUsed.includes(t)?this.handleClick(e):this.removeEventListener("keyup",Ek(this,A4))}),ER(this,A5,e=>{let{metaKey:t,altKey:i,key:r}=e;t||i||!this.keysUsed.includes(r)?this.removeEventListener("keyup",Ek(this,A4)):this.addEventListener("keyup",Ek(this,A4),{once:!0})}),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);const e=mj(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e)}}static get observedAttributes(){return[Ew,EM,EC,ED]}enable(){this.hasAttribute("tabindex")||this.setAttribute("tabindex","-1"),EP(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":EI(this,AX,AZ).call(this,e);break;case"click":this.handleClick(e);break;case"keydown":Ek(this,A5).call(this,e);break;case"keyup":Ek(this,A4).call(this,e)}}attributeChangedCallback(e,t,i){e===EC&&EP(this)&&!Ek(this,Az)?this.setAttribute("aria-checked",null!=i?"true":"false"):e===Ew&&i!==t?this.role="menuitem"+i:e===EM&&i!==t&&(null==i?this.enable():this.disable())}connectedCallback(){this.hasAttribute(EM)||this.enable(),this.role="menuitem"+this.type,EL(this,AQ,function e(t,i){if(!t)return null;let{host:r}=t.getRootNode();return!i&&r?e(t,r):(null==i?void 0:i.items)?i:e(i,null==i?void 0:i.parentNode)}(this,this.parentNode)),EI(this,A8,A6).call(this),this.submenuElement&&EI(this,AJ,A0).call(this),this.shadowRoot.addEventListener("slotchange",this)}disconnectedCallback(){this.disable(),EI(this,A8,A6).call(this),EL(this,AQ,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=m1(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(Ew))?e:""}set type(e){this.setAttribute(Ew,`${e}`)}get value(){var e;return null!=(e=this.getAttribute(ED))?e:this.text}set value(e){this.setAttribute(ED,e)}get text(){var e;return(null!=(e=this.textContent)?e:"").trim()}get checked(){if(EP(this))return"true"===this.getAttribute("aria-checked")}set checked(e){EP(this)&&(EL(this,Az,!0),this.setAttribute("aria-checked",e?"true":"false"),e?this.part.add("checked"):this.part.remove("checked"))}handleClick(e){!EP(this)&&this.invokeTargetElement&&mZ(this,e.target)&&this.invokeTargetElement.dispatchEvent(new Ed({relatedTarget:this}))}get keysUsed(){return["Enter"," "]}}function EP(e){return"radio"===e.type||"checkbox"===e.type}Az=new WeakMap,AQ=new WeakMap,AX=new WeakSet,AZ=function(e){let t=e.target;if(!(null==t?void 0:t.name))for(let e of t.assignedNodes({flatten:!0}))e instanceof Text&&""===e.textContent.trim()&&e.remove();"submenu"===t.name&&(this.submenuElement?EI(this,AJ,A0).call(this):EI(this,A1,A2).call(this))},AJ=new WeakSet,A0=async function(){this.setAttribute("aria-haspopup","menu"),this.setAttribute("aria-expanded",`${!this.submenuElement.hidden}`),this.submenuElement.addEventListener("change",Ek(this,A3)),this.submenuElement.addEventListener("addmenuitem",Ek(this,A3)),this.submenuElement.addEventListener("removemenuitem",Ek(this,A3)),Ek(this,A3).call(this)},A1=new WeakSet,A2=function(){this.removeAttribute("aria-haspopup"),this.removeAttribute("aria-expanded"),this.submenuElement.removeEventListener("change",Ek(this,A3)),this.submenuElement.removeEventListener("addmenuitem",Ek(this,A3)),this.submenuElement.removeEventListener("removemenuitem",Ek(this,A3)),Ek(this,A3).call(this)},A3=new WeakMap,A4=new WeakMap,A5=new WeakMap,A8=new WeakSet,A6=function(){var e;let t=null==(e=Ek(this,AQ))?void 0:e.radioGroupItems;if(!t)return;let i=t.filter(e=>"true"===e.getAttribute("aria-checked")).pop();
1729for(let e of(i||(i=t[0]),t))e.setAttribute("aria-checked","false");null==i||i.setAttribute("aria-checked","true")},Ex.shadowRootOptions={mode:"open"},Ex.getTemplateHTML=function(e){return`
1730    <style>
1731      :host {
1732        transition: var(--media-menu-item-transition,
1733          background .15s linear,
1734          opacity .2s ease-in-out
1735        );
1736        outline: var(--media-menu-item-outline, 0);
1737        outline-offset: var(--media-menu-item-outline-offset, -1px);
1738        cursor: var(--media-cursor, pointer);
1739        display: flex;
1740        align-items: center;
1741        align-self: stretch;
1742        justify-self: stretch;
1743        white-space: nowrap;
1744        white-space-collapse: collapse;
1745        text-wrap: nowrap;
1746        padding: .4em .8em .4em 1em;
1747      }
1748
1749      :host(:focus-visible) {
1750        box-shadow: var(--media-menu-item-focus-shadow, inset 0 0 0 2px rgb(27 127 204 / .9));
1751        outline: var(--media-menu-item-hover-outline, 0);
1752        outline-offset: var(--media-menu-item-hover-outline-offset,  var(--media-menu-item-outline-offset, -1px));
1753      }
1754
1755      :host(:hover) {
1756        cursor: var(--media-cursor, pointer);
1757        background: var(--media-menu-item-hover-background, rgb(92 92 102 / .5));
1758        outline: var(--media-menu-item-hover-outline);
1759        outline-offset: var(--media-menu-item-hover-outline-offset,  var(--media-menu-item-outline-offset, -1px));
1760      }
1761
1762      :host([aria-checked="true"]) {
1763        background: var(--media-menu-item-checked-background);
1764      }
1765
1766      :host([hidden]) {
1767        display: none;
1768      }
1769
1770      :host([disabled]) {
1771        pointer-events: none;
1772        color: rgba(255, 255, 255, .3);
1773      }
1774
1775      slot:not([name]) {
1776        width: 100%;
1777      }
1778
1779      slot:not([name="submenu"]) {
1780        display: inline-flex;
1781        align-items: center;
1782        transition: inherit;
1783        opacity: var(--media-menu-item-opacity, 1);
1784      }
1785
1786      slot[name="description"] {
1787        justify-content: end;
1788      }
1789
1790      slot[name="description"] > span {
1791        display: inline-block;
1792        margin-inline: 1em .2em;
1793        max-width: var(--media-menu-item-description-max-width, 100px);
1794        text-overflow: ellipsis;
1795        overflow: hidden;
1796        font-size: .8em;
1797        font-weight: 400;
1798        text-align: right;
1799        position: relative;
1800        top: .04em;
1801      }
1802
1803      slot[name="checked-indicator"] {
1804        display: none;
1805      }
1806
1807      :host(:is([role="menuitemradio"],[role="menuitemcheckbox"])) slot[name="checked-indicator"] {
1808        display: var(--media-menu-item-checked-indicator-display, inline-block);
1809      }
1810
1811      
1812      svg, img, ::slotted(svg), ::slotted(img) {
1813        height: var(--media-menu-item-icon-height, var(--media-control-height, 24px));
1814        fill: var(--media-icon-color, var(--media-primary-color, rgb(238 238 238)));
1815        display: block;
1816      }
1817
1818      
1819      [part~="indicator"],
1820      ::slotted([part~="indicator"]) {
1821        fill: var(--media-menu-item-indicator-fill,
1822          var(--media-icon-color, var(--media-primary-color, rgb(238 238 238))));
1823        height: var(--media-menu-item-indicator-height, 1.25em);
1824        margin-right: .5ch;
1825      }
1826
1827      [part~="checked-indicator"] {
1828        visibility: hidden;
1829      }
1830
1831      :host([aria-checked="true"]) [part~="checked-indicator"] {
1832        visibility: visible;
1833      }
1834    </style>
1835    <slot name="checked-indicator">
1836      <svg aria-hidden="true" viewBox="0 1 24 24" part="checked-indicator indicator">
1837        <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"/>
1838      </svg>
1839    </slot>
1840    <slot name="prefix"></slot>
1841    <slot></slot>
1842    <slot name="description"></slot>
1843    <slot name="suffix">
1844      ${this.getSuffixSlotInnerHTML(e)}
1845    </slot>
1846    <slot name="submenu"></slot>
1847  `},Ex.getSuffixSlotInnerHTML=function(e){return""},m$.customElements.get("media-chrome-menu-item")||m$.customElements.define("media-chrome-menu-item",Ex);class EO extends ET{get anchorElement(){return"auto"!==this.anchor?super.anchorElement:mY(this).querySelector("media-settings-menu-button")}}EO.getTemplateHTML=function(e){return`
1848    ${ET.getTemplateHTML(e)}
1849    <style>
1850      :host {
1851        --_menu-bg: rgb(20 20 30 / .8);
1852        background: var(--media-settings-menu-background,
1853            var(--media-menu-background,
1854              var(--media-control-background,
1855                var(--media-secondary-color, var(--_menu-bg)))));
1856        min-width: var(--media-settings-menu-min-width, 170px);
1857        border-radius: 2px 2px 0 0;
1858        overflow: hidden;
1859      }
1860
1861      @-moz-document url-prefix() {
1862        :host{
1863          --_menu-bg: rgb(20 20 30);
1864        }
1865      }
1866
1867      :host([role="menu"]) {
1868        
1869        justify-content: end;
1870      }
1871
1872      slot:not([name]) {
1873        justify-content: var(--media-settings-menu-justify-content);
1874        flex-direction: var(--media-settings-menu-flex-direction, column);
1875        overflow: visible;
1876      }
1877
1878      #container.has-expanded {
1879        --media-settings-menu-item-opacity: 0;
1880      }
1881    </style>
1882  `},m$.customElements.get("media-settings-menu")||m$.customElements.define("media-settings-menu",EO);
1882class EN extends Ex{}EN.shadowRootOptions={mode:"open"},EN.getTemplateHTML=function(e){return`
1883    ${Ex.getTemplateHTML.call(this,e)}
1884    <style>
1885      slot:not([name="submenu"]) {
1886        opacity: var(--media-settings-menu-item-opacity, var(--media-menu-item-opacity));
1887      }
1888
1889      :host([aria-expanded="true"]:hover) {
1890        background: transparent;
1891      }
1892    </style>
1893  `},EN.getSuffixSlotInnerHTML=function(e){return`
1894    <svg aria-hidden="true" viewBox="0 0 20 24">
1895      <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"/>
1896    </svg>
1897  `},m$.customElements.get("media-settings-menu-item")||m$.customElements.define("media-settings-menu-item",EN);class EU extends pW{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=m1(this))?void 0:e.querySelector(`#${this.invokeTarget}`):null}handleClick(){var e;null==(e=this.invokeTargetElement)||e.dispatchEvent(new Ed({relatedTarget:this}))}}m$.customElements.get("media-chrome-menu-button")||m$.customElements.define("media-chrome-menu-button",EU);class EF extends EU{static get observedAttributes(){return[...super.observedAttributes,"target"]}connectedCallback(){super.connectedCallback(),this.setAttribute("aria-label",mI("settings"))}get invokeTargetElement(){return void 0!=this.invokeTarget?super.invokeTargetElement:mY(this).querySelector("media-settings-menu")}}EF.getSlotTemplateHTML=function(){return`
1898    <style>
1899      :host([aria-expanded="true"]) slot[name=tooltip] {
1900        display: none;
1901      }
1902    </style>
1903    <slot name="icon">
1904      <svg aria-hidden="true" viewBox="0 0 24 24">
1905        <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"/>
1906      </svg>
1907    </slot>
1908  `},EF.getTooltipContentHTML=function(){return mI("Settings")},m$.customElements.get("media-settings-menu-button")||m$.customElements.define("media-settings-menu-button",EF);var EB=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},E$=(e,t,i)=>(EB(e,t,"read from private field"),i?i.call(e):t.get(e)),EH=(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)},EG=(e,t,i,r)=>(EB(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i),EW=(e,t,i)=>(EB(e,t,"access private method"),i);A9=new WeakMap,A7=new WeakMap,_e=new WeakSet,_t=function(){if(E$(this,A7)===JSON.stringify(this.mediaAudioTrackList))return;EG(this,A7,JSON.stringify(this.mediaAudioTrackList));let e=this.mediaAudioTrackList;for(let t of(this.defaultSlot.textContent="",e.sort((e,t)=>e.id.localeCompare(t.id,void 0,{numeric:!0})),e)){let e=Eg({type:"radio",text:this.formatMenuItemText(t.label,t),value:`${t.id}`,checked:t.enabled});
1908e.prepend(Ev(this,"checked-indicator")),this.defaultSlot.append(e)}},_i=new WeakSet,_r=function(){if(null==this.value)return;let e=new m$.CustomEvent(ms.MEDIA_AUDIO_TRACK_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(e)},m$.customElements.get("media-audio-track-menu")||m$.customElements.define("media-audio-track-menu",class extends ET{constructor(){super(...arguments),EH(this,_e),EH(this,_i),EH(this,A9,[]),EH(this,A7,void 0)}static get observedAttributes(){return[...super.observedAttributes,md.MEDIA_AUDIO_TRACK_LIST,md.MEDIA_AUDIO_TRACK_ENABLED,md.MEDIA_AUDIO_TRACK_UNAVAILABLE]}attributeChangedCallback(e,t,i){if(super.attributeChangedCallback(e,t,i),e===md.MEDIA_AUDIO_TRACK_ENABLED&&t!==i)this.value=i;else if(e===md.MEDIA_AUDIO_TRACK_LIST&&t!==i){var r;EG(this,A9,null==(r=null!=i?i:"")?void 0:r.split(/\s+/).map(mA)),EW(this,_e,_t).call(this)}}connectedCallback(){super.connectedCallback(),this.addEventListener("change",EW(this,_i,_r))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",EW(this,_i,_r))}get anchorElement(){var e;return"auto"!==this.anchor?super.anchorElement:null==(e=mY(this))?void 0:e.querySelector("media-audio-track-menu-button")}get mediaAudioTrackList(){return E$(this,A9)}set mediaAudioTrackList(e){EG(this,A9,e),EW(this,_e,_t).call(this)}get mediaAudioTrackEnabled(){var e;return null!=(e=m7(this,md.MEDIA_AUDIO_TRACK_ENABLED))?e:""}set mediaAudioTrackEnabled(e){fe(this,md.MEDIA_AUDIO_TRACK_ENABLED,e)}});let EK=`<svg aria-hidden="true" viewBox="0 0 24 24">
1909  <path d="M11 17H9.5V7H11v10Zm-3-3H6.5v-4H8v4Zm6-5h-1.5v6H14V9Zm3 7h-1.5V8H17v8Z"/>
1910  <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"/>
1911</svg>`,EV=e=>{let t=mI("Audio");e.setAttribute("aria-label",t)};class Eq extends EU{static get observedAttributes(){return[...super.observedAttributes,md.MEDIA_AUDIO_TRACK_ENABLED,md.MEDIA_AUDIO_TRACK_UNAVAILABLE]}connectedCallback(){super.connectedCallback(),EV(this)}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===md.MEDIA_LANG&&EV(this)}get invokeTargetElement(){var e;return void 0!=this.invokeTarget?super.invokeTargetElement:null==(e=mY(this))?void 0:e.querySelector("media-audio-track-menu")}get mediaAudioTrackEnabled(){var e;return null!=(e=m7(this,md.MEDIA_AUDIO_TRACK_ENABLED))?e:""}set mediaAudioTrackEnabled(e){fe(this,md.MEDIA_AUDIO_TRACK_ENABLED,e)}}Eq.getSlotTemplateHTML=function(){return`
1912    <style>
1913      :host([aria-expanded="true"]) slot[name=tooltip] {
1914        display: none;
1915      }
1916    </style>
1917    <slot name="icon">${EK}</slot>
1918  `},Eq.getTooltipContentHTML=function(){return mI("Audio")},m$.customElements.get("media-audio-track-menu-button")||m$.customElements.define("media-audio-track-menu-button",Eq);var Ej=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},EY=(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)},Ez=(e,t,i)=>(Ej(e,t,"access private method"),i);let EQ=`
1919  <svg aria-hidden="true" viewBox="0 0 26 24" part="captions-indicator indicator">
1920    <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"/>
1921  </svg>`;
1921class EX extends ET{constructor(){super(...arguments),EY(this,_s),EY(this,_l),EY(this,_a,void 0)}static get observedAttributes(){return[...super.observedAttributes,md.MEDIA_SUBTITLES_LIST,md.MEDIA_SUBTITLES_SHOWING]}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===md.MEDIA_SUBTITLES_LIST&&t!==i?Ez(this,_s,_n).call(this):e===md.MEDIA_SUBTITLES_SHOWING&&t!==i&&(this.value=i||"",Ez(this,_s,_n).call(this))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",Ez(this,_l,_o))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",Ez(this,_l,_o))}get anchorElement(){return"auto"!==this.anchor?super.anchorElement:mY(this).querySelector("media-captions-menu-button")}get mediaSubtitlesList(){return EZ(this,md.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){EJ(this,md.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return EZ(this,md.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){EJ(this,md.MEDIA_SUBTITLES_SHOWING,e)}}_a=new WeakMap,_s=new WeakSet,_n=function(){var e,t,i,r,a,s;let n=(Ej(this,t=_a,"read from private field"),(i?i.call(this):t.get(this))!==JSON.stringify(this.mediaSubtitlesList)),l=this.value!==this.getAttribute(md.MEDIA_SUBTITLES_SHOWING);if(!n&&!l)return;r=_a,a=JSON.stringify(this.mediaSubtitlesList),Ej(this,r,"write to private field"),s?s.call(this,a):r.set(this,a),this.defaultSlot.textContent="";let o=!this.value,d=Eg({type:"radio",text:this.formatMenuItemText(mI("Off")),value:"off",checked:o});for(let t of(d.prepend(Ev(this,"checked-indicator")),this.defaultSlot.append(d),this.mediaSubtitlesList)){let i=Eg({type:"radio",text:this.formatMenuItemText(t.label,t),value:fw(t),checked:this.value==fw(t)});i.prepend(Ev(this,"checked-indicator")),"captions"===(null!=(e=t.kind)?e:"subs")&&i.append(Ev(this,"captions-indicator")),this.defaultSlot.append(i)}},_l=new WeakSet,_o=function(){let e=this.mediaSubtitlesShowing,t=this.getAttribute(md.MEDIA_SUBTITLES_SHOWING),i=this.value!==t;if((null==e?void 0:e.length)&&i&&this.dispatchEvent(new m$.CustomEvent(ms.MEDIA_DISABLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:e})),!this.value||!i)return;let r=new m$.CustomEvent(ms.MEDIA_SHOW_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(r)},EX.getTemplateHTML=function(e){return`
1922    ${ET.getTemplateHTML(e)}
1923    <slot name="captions-indicator" hidden>${EQ}</slot>
1924  `};let EZ=(e,t)=>{let i=e.getAttribute(t);return i?fL(i):[]},EJ=(e,t,i)=>{if(!(null==i?void 0:i.length))return void e.removeAttribute(t);let r=fD(i);e.getAttribute(t)!==r&&e.setAttribute(t,r)};m$.customElements.get("media-captions-menu")||m$.customElements.define("media-captions-menu",EX);let E0=`<svg aria-hidden="true" viewBox="0 0 26 24">
1925  <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"/>
1926</svg>`,E1=`<svg aria-hidden="true" viewBox="0 0 26 24">
1927  <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.8
19271 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"/>
1928</svg>`,E2=e=>{e.setAttribute("data-captions-enabled",fP(e).toString())},E3=e=>{e.setAttribute("aria-label",mI("closed captions"))};class E4 extends EU{static get observedAttributes(){return[...super.observedAttributes,md.MEDIA_SUBTITLES_LIST,md.MEDIA_SUBTITLES_SHOWING,md.MEDIA_LANG]}connectedCallback(){super.connectedCallback(),E3(this),E2(this)}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===md.MEDIA_SUBTITLES_SHOWING?E2(this):e===md.MEDIA_LANG&&E3(this)}get invokeTargetElement(){var e;return void 0!=this.invokeTarget?super.invokeTargetElement:null==(e=mY(this))?void 0:e.querySelector("media-captions-menu")}get mediaSubtitlesList(){return E5(this,md.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){E8(this,md.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return E5(this,md.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){E8(this,md.MEDIA_SUBTITLES_SHOWING,e)}}E4.getSlotTemplateHTML=function(){return`
1929    <style>
1930      :host([data-captions-enabled="true"]) slot[name=off] {
1931        display: none !important;
1932      }
1933
1934      
1935      :host(:not([data-captions-enabled="true"])) slot[name=on] {
1936        display: none !important;
1937      }
1938
1939      :host([aria-expanded="true"]) slot[name=tooltip] {
1940        display: none;
1941      }
1942    </style>
1943
1944    <slot name="icon">
1945      <slot name="on">${E0}</slot>
1946      <slot name="off">${E1}</slot>
1947    </slot>
1948  `},E4.getTooltipContentHTML=function(){return mI("Captions")};let E5=(e,t)=>{let i=e.getAttribute(t);return i?fL(i):[]},E8=(e,t,i)=>{if(!(null==i?void 0:i.length))return void e.removeAttribute(t);let r=fD(i);e.getAttribute(t)!==r&&e.setAttribute(t,r)};m$.customElements.get("media-captions-menu-button")||m$.customElements.define("media-captions-menu-button",E4);var E6=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},E9=(e,t,i)=>(E6(e,t,"read from private field"),i?i.call(e):t.get(e)),E7=(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)},ye=(e,t,i)=>(E6(e,t,"access private method"),i);let yt="rates";_d=new WeakMap,_h=new WeakSet,_u=function(){this.defaultSlot.textContent="";let e=g1(this.mediaPlaybackRate),t=new Set(Array.from(E9(this,_d)).map(e=>g1(Number(e))));for(let i of(e>0&&!t.has(e)&&t.add(e),Array.from(t).sort((e,t)=>e-t))){let t=Eg({type:"radio",text:this.formatMenuItemText(`${i}x`,i),value:i.toString(),checked:e===i});t.prepend(Ev(this,"checked-indicator")),this.defaultSlot.append(t)}},_c=new WeakSet,_m=function(){if(!this.value)return;let e=new m$.CustomEvent(ms.MEDIA_PLAYBACK_RATE_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(e)},m$.customElements.get("media-playback-rate-menu")||m$.customElements.define("media-playback-rate-menu",class extends ET{constructor(){super(),E7(this,_h),E7(this,_c),E7(this,_d,new fk(this,yt,{defaultValue:g0})),ye(this,_h,_u).call(this)}static get observedAttributes(){return[...super.observedAttributes,md.MEDIA_PLAYBACK_RATE,yt]}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===md.MEDIA_PLAYBACK_RATE&&t!=i?(this.value=i,ye(this,_h,_u).call(this)):e===yt&&t!=i&&(E9(this,_d).value=i,ye(this,_h,_u).call(this))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",ye(this,_c,_m))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",ye(this,_c,_m))}get anchorElement(){return"auto"!==this.anchor?super.anchorElement:mY(this).querySelector("media-playback-rate-menu-button")}get rates(){return E9(this,_d)}set rates(e){e?Array.isArray(e)?E9(this,_d).value=e.join(" "):"str
1948ing"==typeof e&&(E9(this,_d).value=e):E9(this,_d).value="",ye(this,_h,_u).call(this)}get mediaPlaybackRate(){return m5(this,md.MEDIA_PLAYBACK_RATE,1)}set mediaPlaybackRate(e){m8(this,md.MEDIA_PLAYBACK_RATE,e)}});class yi extends EU{static get observedAttributes(){return[...super.observedAttributes,md.MEDIA_PLAYBACK_RATE]}constructor(){var e;super(),this.container=this.shadowRoot.querySelector('slot[name="icon"]'),this.container.innerHTML=`${g1(null!=(e=this.mediaPlaybackRate)?e:1)}x`}attributeChangedCallback(e,t,i){if(super.attributeChangedCallback(e,t,i),e===md.MEDIA_PLAYBACK_RATE){let e=i?+i:NaN,t=g1(Number.isNaN(e)?1:e);this.container.innerHTML=`${t}x`,this.setAttribute("aria-label",mI("Playback rate {playbackRate}",{playbackRate:t}))}}get invokeTargetElement(){return void 0!=this.invokeTarget?super.invokeTargetElement:mY(this).querySelector("media-playback-rate-menu")}get mediaPlaybackRate(){return m5(this,md.MEDIA_PLAYBACK_RATE,1)}set mediaPlaybackRate(e){m8(this,md.MEDIA_PLAYBACK_RATE,e)}}yi.getSlotTemplateHTML=function(e){let t=e.mediaplaybackrate?g1(+e.mediaplaybackrate):1;return`
1949    <style>
1950      :host {
1951        min-width: 5ch;
1952        padding: var(--media-button-padding, var(--media-control-padding, 10px 5px));
1953      }
1954
1955      :host([aria-expanded="true"]) slot {
1956        display: block;
1957      }
1958
1959      :host([aria-expanded="true"]) slot[name=tooltip] {
1960        display: none;
1961      }
1962    </style>
1963    <slot name="icon">${t}x</slot>
1964  `},yi.getTooltipContentHTML=function(){return mI("Playback rate")},m$.customElements.get("media-playback-rate-menu-button")||m$.customElements.define("media-playback-rate-menu-button",yi);var yr=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},ya=(e,t,i)=>(yr(e,t,"read from private field"),i?i.call(e):t.get(e)),ys=(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)},yn=(e,t,i,r)=>(yr(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i),yl=(e,t,i)=>(yr(e,t,"access private method"),i);_f=new WeakMap,_p=new WeakMap,_g=new WeakSet,_v=function(){let e,t=!this.mediaRenditionSelected;if(ya(this,_p).mediaRenditionList===JSON.stringify(this.mediaRenditionList)&&ya(this,_p).mediaHeight===this.mediaHeight&&ya(this,_p).mediaWidth===this.mediaWidth&&ya(this,_p).isAuto===t)return;ya(this,_p).mediaRenditionList=JSON.stringify(this.mediaRenditionList),ya(this,_p).mediaHeight=this.mediaHeight,ya(this,_p).mediaWidth=this.mediaWidth,ya(this,_p).isAuto=t;let i=this.mediaRenditionList.sort(this.compareRendition.bind(this)),r=i.find(e=>e.id===this.mediaRenditionSelected);for(let e of i)e.selected=e===r;for(let e of(this.defaultSlot.textContent="",i)){let i=Eg({type:"radio",text:this.formatRendition(e,{showBitrate:this.showRenditionBitrate(e)}),value:`${e.id}`,checked:e.selected&&!t});i.prepend(Ev(this,"checked-indicator")),this.defaultSlot.append(i)}let a=r&&this.showRenditionBitrate(r);t&&(r?e=this.formatMenuItemText(`${mI("Auto")} \u2022 ${this.formatRendition(r,{showBitrate:a})}`,r):this.mediaHeight>0&&this.mediaWidth>0&&(e=this.formatMenuItemText(`${mI("Auto")} (${Math.min(this.mediaWidth,this.mediaHeight)}p)`))),e||(e=this.formatMenuItemText(mI("Auto")));let s=Eg({type:"radio",text:e,value:"auto",checked:t});s.dataset.description=e,s.prepend(Ev(this,"checked-indicator")),this.defaultSlot.append(s)},_E=new WeakSet,_y=function(){if(null==this.value)return;let e=new m$.CustomEvent(ms.MEDIA_RENDITION_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(e)},m$.customElements.get("media-rendition-menu")||m$.customElements.define("media-rendition-menu",class extends ET{constructor(){super(...arguments),ys(this,_g),ys(this,_E),ys(this,_f,[]),ys(this,_p,{})}static get observedAttributes(){return[...super.observedAttributes,md.MEDIA_RENDITION_LIST,md.MEDIA_RENDITION_SELECTED,md.MEDIA_RENDITION_UNAVAILABLE,md.MEDIA_HEIGHT,md.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,r=`${t.toFixed(+(t<1))} Mbps`;return`${i} (${r})`}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 md.MEDIA_RENDITION_SELECTED:this.value=null!=i?i:"auto",yl(this,_g,_v).call(this);break;case md.MEDIA_RENDITION_LIST:yn(this,_f,null==i?void 0:i.split(/\s+/).map(mb)),yl(this,_g,_v).call(this);break;case md.MEDIA_HEIGHT:case md.MEDIA_WIDTH:yl(this,_g,_v).call(this)}}connectedCallback(){super.connectedCallback(),this.addEventListener("change",yl(this,_E,_y))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",yl(this,_E,_y))}get anchorElement(){return"auto"!==this.anchor?super.anchorElement:mY(this).querySelector("media-rendition-menu-button")}get mediaRenditionList(){return ya(this,_f)}set mediaRenditionList(e){yn(this,_f,e),yl(this,_g,_v).call(this)}get mediaRenditionSelected(){return m7(this,md.MEDIA_RENDITION_SELECTED)}set mediaRenditionSelected(e){fe(this,md.MEDIA_RENDITION_SELECTED,e)}get mediaHeight(){return m5(this,md.MEDIA_HEIGHT)}set mediaHeight(e){m8(this,md.MEDIA_HEIGHT,e)}get mediaWidth(){return m5(this,md.MEDIA_WIDTH)}set mediaWidth(e){m8(this,md.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)}});let yo=`<svg aria-hidden="true" viewBox="0 0 24 24">
1965  <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" />
1966</svg>`;
1966class yd extends EU{static get observedAttributes(){return[...super.observedAttributes,md.MEDIA_RENDITION_SELECTED,md.MEDIA_RENDITION_UNAVAILABLE,md.MEDIA_HEIGHT]}connectedCallback(){super.connectedCallback(),this.setAttribute("aria-label",mI("quality"))}get invokeTargetElement(){return void 0!=this.invokeTarget?super.invokeTargetElement:mY(this).querySelector("media-rendition-menu")}get mediaRenditionSelected(){return m7(this,md.MEDIA_RENDITION_SELECTED)}set mediaRenditionSelected(e){fe(this,md.MEDIA_RENDITION_SELECTED,e)}get mediaHeight(){return m5(this,md.MEDIA_HEIGHT)}set mediaHeight(e){m8(this,md.MEDIA_HEIGHT,e)}}yd.getSlotTemplateHTML=function(){return`
1967    <style>
1968      :host([aria-expanded="true"]) slot[name=tooltip] {
1969        display: none;
1970      }
1971    </style>
1972    <slot name="icon">${yo}</slot>
1973  `},yd.getTooltipContentHTML=function(){return mI("Quality")},m$.customElements.get("media-rendition-menu-button")||m$.customElements.define("media-rendition-menu-button",yd);var yh=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},yu=(e,t,i)=>(yh(e,t,"read from private field"),i?i.call(e):t.get(e)),yc=(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)},ym=(e,t,i,r)=>(yh(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i),yf=(e,t,i)=>(yh(e,t,"access private method"),i);class yp extends ET{constructor(){super(),yc(this,_T),yc(this,__),yc(this,_k),yc(this,_L),yc(this,_D),yc(this,_b,!1),yc(this,_w,e=>{let t=e.target,i=(null==t?void 0:t.nodeName)==="VIDEO",r=yf(this,_L,_I).call(this,t);(i||r)&&(yu(this,_b)?yf(this,__,_S).call(this):yf(this,_D,_C).call(this,e))}),yc(this,_M,e=>{let t=e.target,i=this.contains(t),r=2===e.button,a=(null==t?void 0:t.nodeName)==="VIDEO",s=yf(this,_L,_I).call(this,t);i||r&&(a||s)||yf(this,__,_S).call(this)}),yc(this,_x,e=>{"Escape"===e.key&&yf(this,__,_S).call(this)}),yc(this,_P,e=>{var t,i;let r=e.target;if(null==(t=r.matches)?void 0: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)}yf(this,__,_S).call(this)}),this.setAttribute("noautohide",""),yf(this,_T,_A).call(this)}connectedCallback(){super.connectedCallback(),mY(this).addEventListener("contextmenu",yu(this,_w)),this.addEventListener("click",yu(this,_P))}disconnectedCallback(){super.disconnectedCallback(),mY(this).removeEventListener("contextmenu",yu(this,_w)),this.removeEventListener("click",yu(this,_P)),document.removeEventListener("mousedown",yu(this,_M)),document.removeEventListener("keydown",yu(this,_x))}}_b=new WeakMap,_T=new WeakSet,_A=function(){this.hidden=!yu(this,_b)},__=new WeakSet,_S=function(){ym(this,_b,!1),yf(this,_T,_A).call(this)},_k=new WeakSet,_R=function(){document.querySelectorAll("media-context-menu").forEach(e=>{e!==this&&yf(e,__,_S).call(e)})},_L=new WeakSet,_I=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")))},_w=new WeakMap,_D=new WeakSet,_C=function(e){e.preventDefault(),yf(this,_k,_R).call(this),ym(this,_b,!0),this.style.position="fixed",this.style.left=`${e.clientX}px`,this.style.top=`${e.clientY}px`,yf(this,_T,_A).call(this),document.addEventListener("mousedown",yu(this,_M),{once:!0}),document.addEventListener("keydown",yu(this,_x),{once:!0})},_M=new WeakMap,_x=new WeakMap,_P=new WeakMap,yp.getTemplateHTML=function(e){return`
1974      ${ET.getTemplateHTML(e)}
1975      <style>
1976        :host {
1977          --_menu-bg: rgb(20 20 30 / .8);
1978          background: var(--media-settings-menu-background,
1979            var(--media-menu-background,
1980              var(--media-control-background,
1981                var(--media-secondary-color, var(--_menu-bg)))));
1982          min-width: var(--media-settings-menu-min-width, 170px);
1983          border-radius: 2px;
1984          overflow: hidden;
1985        }
1986      </style>
1987    `},m$.customElements.get("media-context-menu")||m$.customElements.define("media-context-menu",yp);
1987class yg extends Ex{}yg.shadowRootOptions={mode:"open"},yg.getTemplateHTML=function(e){return`
1988    ${Ex.getTemplateHTML.call(this,e)}
1989    <style>
1990        ::slotted(*) {
1991            color: var(--media-text-color, white);
1992            text-decoration: none;
1993            border: none;
1994            background: none;
1995            cursor: pointer;
1996            padding: 0;
1997            min-height: var(--media-control-height, 24px);
1998        }
1999    </style>
2000  `},m$.customElements.get("media-context-menu-item")||m$.customElements.define("media-context-menu-item",yg);var yv=e=>{throw TypeError(e)},yE=(e,t,i)=>t.has(e)||yv("Cannot "+i),yy=(e,t,i)=>(yE(e,t,"read from private field"),i?i.call(e):t.get(e)),yb=(e,t,i)=>t.has(e)?yv("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,i),yT=(e,t,i,r)=>(yE(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i),yA=(e,t,i)=>(yE(e,t,"access private method"),i),y_=class{addEventListener(){}removeEventListener(){}dispatchEvent(e){return!0}};"u"<typeof DocumentFragment&&(globalThis.DocumentFragment=class extends y_{});var yS,yk,yR,yL,yI,yw,yD,yC,yM,yx,yP,yO,yN,yU,yF,yB,y$,yH,yG,yW,yK,yV,yq,yj,yY,yz,yQ,yX,yZ,yJ,y0,y1,y2,y3,y4,y5,y8,y6,y9,y7,be,bt,bi,br,ba,bs,bn,bl,bo,bd,bh,bu,bc,bm,bf,bp,bg,bv,bE,by,bb,bT,bA,b_,bS,bk,bR,bL,bI,bw,bD,bC,bM,bx,bP,bO,bN,bU,bF,bB,b$,bH,bG,bW,bK,bV,bq,bj,bY,bz,bQ,bX,bZ,bJ,b0,b1,b2,b3,b4,b5,b8,b6,b9,b7,Te,Tt,Ti,Tr,Ta,Ts,Tn,Tl,To,Td,Th,Tu,Tc,Tm,Tf,Tp,Tg,Tv,TE,Ty,Tb,TT,TA,T_,TS,Tk,TR,TL,TI,Tw,TD,TC,TM,Tx,TP,TO,TN,TU,TF,TB,T$,TH,TG,TW,TK,TV,Tq,Tj,TY,Tz,TQ,TX,TZ,TJ,T0,T1,T2,T3,T4,T5,T8,T6,T9,T7,Ae,At,Ai,Ar,Aa,As,An,Al,Ao,Ad,Ah,Au,Ac,Am,Af,Ap,Ag,Av,AE,Ay,Ab,AT,AA,A_,AS,Ak,AR,AL,AI,Aw,AD,AC,AM,Ax,AP,AO,AN,AU,AF,AB,A$,AH,AG,AW,AK,AV,Aq,Aj,AY,Az,AQ,AX,AZ,AJ,A0,A1,A2,A3,A4,A5,A8,A6,A9,A7,_e,_t,_i,_r,_a,_s,_n,_l,_o,_d,_h,_u,_c,_m,_f,_p,_g,_v,_E,_y,_b,_T,_A,__,_S,_k,_R,_L,_I,_w,_D,_C,_M,_x,_P,_O,_N=class extends y_{},_U=class{constructor(e,t={}){yb(this,_O),yT(this,_O,null==t?void 0:t.detail)}get detail(){return yy(this,_O)}initCustomEvent(){}};_O=new WeakMap;var _F={document:{createElement:function(e,t){return new _N}},DocumentFragment,customElements:{get(e){},define(e,t,i){},getName:e=>null,upgrade(e){},whenDefined:e=>Promise.resolve(_N)},CustomEvent:_U,EventTarget:y_,HTMLElement:_N,HTMLVideoElement:class extends y_{}},_B="u"<typeof window||void 0===globalThis.customElements,_$=_B?_F:globalThis,_H=_B?_F.document:globalThis.document;function _G(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function _W(e){return e.replace(/[-_]([a-z])/g,(e,t)=>t.toUpperCase())}function _K(e){if(null==e)return;let t=+e;return Number.isNaN(t)?void 0:t}function _V(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 _q,_j,_Y,_z=(e,t)=>!!e&&!!t&&(!!e.contains(t)||_z(e,t.getRootNode().host)),_Q="mux.com",_X=(()=>{try{return"3.13.4"}catch{}return"UNKNOWN"})(),_Z=e=>{if(e){if([d7,d9].includes(e))return e;if(null!=e&&e.includes("live"))return d7}},_J={crossorigin:"crossOrigin",playsinline:"playsInline"},_0=class{constructor(e,t){yb(this,_q),yb(this,_j),yb(this,_Y,[]),yT(this,_q,e),yT(this,_j,t)}[Symbol.iterator](){return yy(this,_Y).values()}get length(){return yy(this,_Y).length}get value(){var e;return null!=(e=yy(this,_Y).join(" "))?e:""}set value(e){var t;e!==this.value&&(yT(this,_Y,[]),this.add(...null!=(t=null==e?void 0:e.split(" "))?t:[]))}toString(){return this.value}item(e){return yy(this,_Y)[e]}values(){return yy(this,_Y).values()}keys(){return yy(this,_Y).keys()}forEach(e){yy(this,_Y).forEach(e)}add(...e){var t,i;e.forEach(e=>{this.contains(e)||yy(this,_Y).push(e)}),(""!==this.value||null!=(t=yy(this,_q))&&t.hasAttribute(`${yy(this,_j)}`))&&null!=(i=yy(this,_q))&&i.setAttribute(`${yy(this,_j)}`,`${this.value}`)}remove(...e){var t;e.forEach(e=>{yy(this,_Y).splice(yy(this,_Y).indexOf(e),1)}),null==(t=yy(this,_q))||t.setAttribute(`${yy(this,_j)}`,`${this.value}`)}contains(e){return yy(this,_Y).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),
2000!0)}replace(e,t){this.remove(e),this.add(t)}};_q=new WeakMap,_j=new WeakMap,_Y=new WeakMap;var _1=`[mux-player ${_X}]`;function _2(...e){console.warn(_1,...e)}function _3(...e){console.error(_1,...e)}function _4(e){var t;let i=null!=(t=e.message)?t:"";e.context&&(i+=` ${e.context}`),e.file&&(i+=` ${hE("Read more: ")}
2001https://github.com/muxinc/elements/blob/main/errors/${e.file}`),_2(i)}var _5={AUTOPLAY:"autoplay",CROSSORIGIN:"crossorigin",LOOP:"loop",MUTED:"muted",PLAYSINLINE:"playsinline",PRELOAD:"preload"},_8={VOLUME:"volume",PLAYBACKRATE:"playbackrate",MUTED:"muted"},_6=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}}),_9=[...Object.values(_5).filter(e=>_5.PLAYSINLINE!==e),...Object.values(_8)];function _7(e,t){return e.media?e.media.getAttribute(t):e.getAttribute(t)}var Se=class extends _$.HTMLElement{static get observedAttributes(){return _9}constructor(){super()}attributeChangedCallback(e,t,i){var r,a;switch(e){case _8.MUTED:this.media&&(this.media.muted=null!=i,this.media.defaultMuted=null!=i);return;case _8.VOLUME:{let e=null!=(r=_K(i))?r:1;this.media&&(this.media.volume=e);return}case _8.PLAYBACKRATE:{let e=null!=(a=_K(i))?a:1;this.media&&(this.media.playbackRate=e,this.media.defaultPlaybackRate=e);return}}}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:_6}get seekable(){var e,t;return null!=(t=null==(e=this.media)?void 0:e.seekable)?t:_6}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=_K(this.getAttribute(_8.PLAYBACKRATE)))?e:1}set defaultPlaybackRate(e){null!=e?this.setAttribute(_8.PLAYBACKRATE,`${e}`):this.removeAttribute(_8.PLAYBACKRATE)}get crossOrigin(){return _7(this,_5.CROSSORIGIN)}set crossOrigin(e){this.setAttribute(_5.CROSSORIGIN,`${e}`)}get autoplay(){return null!=_7(this,_5.AUTOPLAY)}set autoplay(e){e?this.setAttribute(_5.AUTOPLAY,"string"==typeof e?e:""):this.removeAttribute(_5.AUTOPLAY)}get loop(){return null!=_7(this,_5.LOOP)}set loop(e){e?this.setAttribute(_5.LOOP,""):this.removeAttribute(_5.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!=_7(this,_5.MUTED)}set defaultMuted(e){e?this.setAttribute(_5.MUTED,""):this.removeAttribute(_5.MUTED)}
2001get playsInline(){return null!=_7(this,_5.PLAYSINLINE)}set playsInline(e){_3("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(_5.PRELOAD,e):this.removeAttribute(_5.PRELOAD)}},St=`:host {
2002  --media-control-display: var(--controls);
2003  --media-loading-indicator-display: var(--loading-indicator);
2004  --media-dialog-display: var(--dialog);
2005  --media-play-button-display: var(--play-button);
2006  --media-live-button-display: var(--live-button);
2007  --media-seek-backward-button-display: var(--seek-backward-button);
2008  --media-seek-forward-button-display: var(--seek-forward-button);
2009  --media-mute-button-display: var(--mute-button);
2010  --media-captions-button-display: var(--captions-button);
2011  --media-captions-menu-button-display: var(--captions-menu-button, var(--media-captions-button-display));
2012  --media-rendition-menu-button-display: var(--rendition-menu-button);
2013  --media-audio-track-menu-button-display: var(--audio-track-menu-button);
2014  --media-airplay-button-display: var(--airplay-button);
2015  --media-pip-button-display: var(--pip-button);
2016  --media-fullscreen-button-display: var(--fullscreen-button);
2017  --media-cast-button-display: var(--cast-button, var(--_cast-button-drm-display));
2018  --media-playback-rate-button-display: var(--playback-rate-button);
2019  --media-playback-rate-menu-button-display: var(--playback-rate-menu-button);
2020  --media-volume-range-display: var(--volume-range);
2021  --media-time-range-display: var(--time-range);
2022  --media-time-display-display: var(--time-display);
2023  --media-duration-display-display: var(--duration-display);
2024  --media-title-display-display: var(--title-display);
2025
2026  display: inline-block;
2027  line-height: 0;
2028  width: 100%;
2029}
2030
2031a {
2032  color: #fff;
2033  font-size: 0.9em;
2034  text-decoration: underline;
2035}
2036
2037media-theme {
2038  display: inline-block;
2039  line-height: 0;
2040  width: 100%;
2041  height: 100%;
2042  direction: ltr;
2043}
2044
2045media-poster-image {
2046  display: inline-block;
2047  line-height: 0;
2048  width: 100%;
2049  height: 100%;
2050}
2051
2052media-poster-image:not([src]):not([placeholdersrc]) {
2053  display: none;
2054}
2055
2056::part(top),
2057[part~='top'] {
2058  --media-control-display: var(--controls, var(--top-controls));
2059  --media-play-button-display: var(--play-button, var(--top-play-button));
2060  --media-live-button-display: var(--live-button, var(--top-live-button));
2061  --media-seek-backward-button-display: var(--seek-backward-button, var(--top-seek-backward-button));
2062  --media-seek-forward-button-display: var(--seek-forward-button, var(--top-seek-forward-button));
2063  --media-mute-button-display: var(--mute-button, var(--top-mute-button));
2064  --media-captions-button-display: var(--captions-button, var(--top-captions-button));
2065  --media-captions-menu-button-display: var(
2066    --captions-menu-button,
2067    var(--media-captions-button-display, var(--top-captions-menu-button))
2068  );
2069  --media-rendition-menu-button-display: var(--rendition-menu-button, var(--top-rendition-menu-button));
2070  --media-audio-track-menu-button-display: var(--audio-track-menu-button, var(--top-audio-track-menu-button));
2071  --media-airplay-button-display: var(--airplay-button, var(--top-airplay-button));
2072  --media-pip-button-display: var(--pip-button, var(--top-pip-button));
2073  --media-fullscreen-button-display: var(--fullscreen-button, var(--top-fullscreen-button));
2074  --media-cast-button-display: var(--cast-button, var(--top-cast-button, var(--_cast-button-drm-display)));
2075  --media-playback-rate-button-display: var(--playback-rate-button, var(--top-playback-rate-button));
2076  --media-playback-rate-menu-button-display: var(
2077    --captions-menu-button,
2078    var(--media-playback-rate-button-display, var(--top-playback-rate-menu-button))
2079  );
2080  --media-volume-range-display: var(--volume-range, var(--top-volume-range));
2081  --media-time-range-display: var(--time-range, var(--top-time-range));
2082  --media-time-display-display: var(--time-display, var(--top-time-display));
2083  --media-duration-display-display: var(--duration-display, var(--top-duration-display));
2084  --media-title-display-display: var(--title-display, var(--top-title-display));
2085}
2086
2087::part(center),
2088[part~='center'] {
2089  --media-control-display: var(--controls, var(--center-controls));
2090  --media-play-button-display: var(--play-button, var(--center-play-button));
2091  --media-live-button-display: var(--live-button, var(--center-live-button));
2092  --media-seek-backward-button-display: var(--seek-backward-button, var(--center-seek-backward-button));
2093  --media-seek-forward-button-display: var(--seek-forward-button, var(--center-seek-forward-button));
2094  --media-mute-button-display: var(--mute-button, var(--center-mute-button));
2095  --media-captions-button-display: var(--captions-button, var(--center-captions-button));
2096  --media-captions-menu-button-display: var(
2097    --captions-menu-button,
2098    var(--media-captions-button-display, var(--center-captions-menu-button))
2099  );
2100  --media-rendition-menu-button-display: var(--rendition-menu-button, var(--center-rendition-menu-button));
2101  --media-audio-track-menu-button-display: var(--audio-track-menu-button, var(--center-audio-track-menu-button));
2102  --media-airplay-button-display: var(--airplay-button, var(--center-airplay-button));
2103  --media-pip-button-display: var(--pip-button, var(--center-pip-button));
2104  --media-fullscreen-button-display: var(--fullscreen-button, var(--center-fullscreen-button));
2105  --media-cast-button-display: var(--cast-button, var(--center-cast-button, var(--_cast-button-drm-display)));
2106  --media-playback-rate-button-display: var(--playback-rate-button, var(--center-playback-rate-button));
2107  --media-playback-rate-menu-button-display: var(
2108    --playback-rate-menu-button,
2109    var(--media-playback-rate-button-display, var(--center-playback-rate-menu-button))
2110  );
2111  --media-volume-range-display: var(--volume-range, var(--center-volume-range));
2112  --media-time-range-display: var(--time-range, var(--center-time-range));
2113  --media-time-display-display: var(--time-display, var(--center-time-display));
2114  --media-duration-display-display: var(--duration-display, var(--center-duration-display));
2115}
2116
2117::part(bottom),
2118[part~='bottom'] {
2119  --media-control-display: var(--controls, var(--bottom-controls));
2120  --media-play-button-display: var(--play-button, var(--bottom-play-button));
2121  --media-live-button-display: var(--live-button, var(--bottom-live-button));
2122  --media-seek-backward-button-display: var(--seek-backward-button, var(--bottom-seek-backward-button));
2123  --media-seek-forward-button-display: var(--seek-forward-button, var(--bottom-seek-forward-button));
2124  --media-mute-button-display: var(--mute-button, var(--bottom-mute-button));
2125  --media-captions-button-display: var(--captions-button, var(--bottom-captions-button));
2126  --media-captions-menu-button-display: var(
2127    --captions-menu-button,
2128    var(--media-captions-button-display, var(--bottom-captions-menu-button))
2129  );
2130  --media-rendition-menu-button-display: var(--rendition-menu-button, var(--bottom-rendition-menu-button));
2131  --media-audio-track-menu-button-display: var(--audio-track-menu-button, var(--bottom-audio-track-menu-button));
2132  --media-airplay-button-display: var(--airplay-button, var(--bottom-airplay-button));
2133  --media-pip-button-display: var(--pip-button, var(--bottom-pip-button));
2134  --media-fullscreen-button-display: var(--fullscreen-button, var(--bottom-fullscreen-button));
2135  --media-cast-button-display: var(--cast-button, var(--bottom-cast-button, var(--_cast-button-drm-display)));
2136  --media-playback-rate-button-display: var(--playback-rate-button, var(--bottom-playback-rate-button));
2137  --media-playback-rate-menu-button-display: var(
2138    --playback-rate-menu-button,
2139    var(--media-playback-rate-button-display, var(--bottom-playback-rate-menu-button))
2140  );
2141  --media-volume-range-display: var(--volume-range, var(--bottom-volume-range));
2142  --media-time-range-display: var(--time-range, var(--bottom-time-range));
2143  --media-time-display-display: var(--time-display, var(--bottom-time-display));
2144  --media-duration-display-display: var(--duration-display, var(--bottom-duration-display));
2145  --media-title-display-display: var(--title-display, var(--bottom-title-display));
2146}
2147
2148:host([no-tooltips]) {
2149  --media-tooltip-display: none;
2150}
2151`,Si=new WeakMap,Sr=class e{constructor(e,t){this.element=e,this.type=t,this.element.addEventListener(this.type,this);let i=Si.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=Si.get(this.element);
2151e&&e.delete(this.type)}}static for(t){Si.has(t.element)||Si.set(t.element,new Map);let i=t.attributeName.slice(2),r=Si.get(t.element);return r&&r.has(i)?r.get(i):new e(t.element,i)}},Sa=new Map,Ss=new WeakMap,Sn=new WeakMap,Sl=class{constructor(e,t,i){this.strings=e,this.values=t,this.processor=i,this.stringsKey=this.strings.join("\x01")}get template(){if(Sa.has(this.stringsKey))return Sa.get(this.stringsKey);{let e=_H.createElement("template"),t=this.strings.length-1;return e.innerHTML=this.strings.reduce((e,i,r)=>e+i+(r<t?`{{ ${r} }}`:""),""),Sa.set(this.stringsKey,e),e}}renderInto(e){var t;let i=this.template;if(Ss.get(e)!==i){Ss.set(e,i);let t=new vH(i,this.values,this.processor);Sn.set(e,t),e instanceof vz?e.replace(...t.children):e.appendChild(t);return}let r=Sn.get(e);null==(t=null==r?void 0:r.update)||t.call(r,this.values)}},So={processCallback(e,t,i){var r;if(i)for(let[e,a]of t)e in i&&function(e,t){(function(e,t){if(e instanceof vY&&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 vY){let i=e.attributeNamespace;return t!==e.element.hasAttributeNS(i,e.attributeName)&&(e.booleanValue=t),!0}return!1}(e,t)||e instanceof vY&&e.attributeName.startsWith("on")&&(Sr.for(e).set(t),e.element.removeAttributeNS(e.attributeNamespace,e.attributeName),1)||!1===t&&e instanceof vz&&(e.replace(""),1)||t instanceof Sl&&e instanceof vz&&(t.renderInto(e),1)||t instanceof DocumentFragment&&e instanceof vz&&(t.childNodes.length&&e.replace(...t.childNodes),1)||function(e,t){if(e instanceof vY){let i=e.attributeNamespace,r=e.element.getAttributeNS(i,e.attributeName);return String(t)!==r&&(e.value=String(t))}e.value=String(t)}(e,t)}(a,null!=(r=i[e])?r:"")}};function Sd(e,...t){return new Sl(e,t,So)}var Sh=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(", "),Su=e=>e.charAt(0).toUpperCase()+e.slice(1),Sc=(e,t)=>{let i=(e=>{if(e.muxCode){if(2403210===e.muxCode)return"403-expired-token.md";if(2412202===e.muxCode)return"403-malformatted-token.md";if([2403222,2403221].includes(e.muxCode))return"403-incorrect-aud-value.md";if(2403232===e.muxCode)return"403-playback-id-mismatch.md";if(2403201===e.muxCode)return"missing-signed-tokens.md";if(2404e3===e.muxCode)return"404-not-found.md";if(2412e3===e.muxCode)return"412-not-playable.md"}if(e.code){if(e.code===d5.MEDIA_ERR_NETWORK)return"";if(e.code===d5.MEDIA_ERR_DECODE)return"media-decode-error.md";if(e.code===d5.MEDIA_ERR_SRC_NOT_SUPPORTED)return"media-src-not-supported.md"}return""})(e);return{message:e.message,context:e.context,file:i}},S
vendor: 8,359 bytes, lines 2151-2434
2151m=`<template id="media-theme-gerwig">
2152  <style>
2153    @keyframes pre-play-hide {
2154      0% {
2155        transform: scale(1);
2156        opacity: 1;
2157      }
2158
2159      30% {
2160        transform: scale(0.7);
2161      }
2162
2163      100% {
2164        transform: scale(1.5);
2165        opacity: 0;
2166      }
2167    }
2168
2169    :host {
2170      --_primary-color: var(--media-primary-color, #fff);
2171      --_secondary-color: var(--media-secondary-color, transparent);
2172      --_accent-color: var(--media-accent-color, #fa50b5);
2173      --_text-color: var(--media-text-color, #000);
2174
2175      --media-icon-color: var(--_primary-color);
2176      --media-control-background: var(--_secondary-color);
2177      --media-control-hover-background: var(--_accent-color);
2178      --media-time-buffered-color: rgba(255, 255, 255, 0.4);
2179      --media-preview-time-text-shadow: none;
2180      --media-control-height: 14px;
2181      --media-control-padding: 6px;
2182      --media-tooltip-container-margin: 6px;
2183      --media-tooltip-distance: 18px;
2184
2185      color: var(--_primary-color);
2186      display: inline-block;
2187      width: 100%;
2188      height: 100%;
2189    }
2190
2191    :host([audio]) {
2192      --_secondary-color: var(--media-secondary-color, black);
2193      --media-preview-time-text-shadow: none;
2194    }
2195
2196    :host([audio]) ::slotted([slot='media']) {
2197      height: 0px;
2198    }
2199
2200    :host([audio]) media-loading-indicator {
2201      display: none;
2202    }
2203
2204    :host([audio]) media-controller {
2205      background: transparent;
2206    }
2207
2208    :host([audio]) media-controller::part(vertical-layer) {
2209      background: transparent;
2210    }
2211
2212    :host([audio]) media-control-bar {
2213      width: 100%;
2214      background-color: var(--media-control-background);
2215    }
2216
2217    /*
2218     * 0.433s is the transition duration for VTT Regions.
2219     * Borrowed here, so the captions don't move too fast.
2220     */
2221    media-controller {
2222      --media-webkit-text-track-transform: translateY(0) scale(0.98);
2223      --media-webkit-text-track-transition: transform 0.433s ease-out 0.3s;
2224    }
2225    media-controller:is([mediapaused], :not([userinactive])) {
2226      --media-webkit-text-track-transform: translateY(-50px) scale(0.98);
2227      --media-webkit-text-track-transition: transform 0.15s ease;
2228    }
2229
2230    /*
2231     * CSS specific to iOS devices.
2232     * See: https://stackoverflow.com/questions/30102792/css-media-query-to-target-only-ios-devices/60220757#60220757
2233     */
2234    @supports (-webkit-touch-callout: none) {
2235      /* Disable subtitle adjusting for iOS Safari */
2236      media-controller[mediaisfullscreen] {
2237        --media-webkit-text-track-transform: unset;
2238        --media-webkit-text-track-transition: unset;
2239      }
2240    }
2241
2242    media-time-range {
2243      --media-box-padding-left: 6px;
2244      --media-box-padding-right: 6px;
2245      --media-range-bar-color: var(--_accent-color);
2246      --media-time-range-buffered-color: var(--_primary-color);
2247      --media-range-track-color: transparent;
2248      --media-range-track-background: rgba(255, 255, 255, 0.4);
2249      --media-range-thumb-background: radial-gradient(
2250        circle,
2251        #000 0%,
2252        #000 25%,
2253        var(--_accent-color) 25%,
2254        var(--_accent-color)
2255      );
2256      --media-range-thumb-width: 12px;
2257      --media-range-thumb-height: 12px;
2258      --media-range-thumb-transform: scale(0);
2259      --media-range-thumb-transition: transform 0.3s;
2260      --media-range-thumb-opacity: 1;
2261      --media-preview-background: var(--_primary-color);
2262      --media-box-arrow-background: var(--_primary-color);
2263      --media-preview-thumbnail-border: 5px solid var(--_primary-color);
2264      --media-preview-border-radius: 5px;
2265      --media-text-color: var(--_text-color);
2266      --media-control-hover-background: transparent;
2267      --media-preview-chapter-text-shadow: none;
2268      color: var(--_accent-color);
2269      padding: 0 6px;
2270    }
2271
2272    :host([audio]) media-time-range {
2273      --media-preview-time-padding: 1.5px 6px;
2274      --media-preview-box-margin: 0 0 -5px;
2275    }
2276
2277    media-time-range:hover {
2278      --media-range-thumb-transform: scale(1);
2279    }
2280
2281    media-preview-thumbnail {
2282      border-bottom-width: 0;
2283    }
2284
2285    [part~='menu'] {
2286      border-radius: 2px;
2287      border: 1px solid rgba(0, 0, 0, 0.1);
2288      bottom: 50px;
2289      padding: 2.5px 10px;
2290    }
2291
2292    [part~='menu']::part(indicator) {
2293      fill: var(--_accent-color);
2294    }
2295
2296    [part~='menu']::part(menu-item) {
2297      box-sizing: border-box;
2298      display: flex;
2299      align-items: center;
2300      padding: 6px 10px;
2301      min-height: 34px;
2302    }
2303
2304    [part~='menu']::part(checked) {
2305      font-weight: 700;
2306    }
2307
2308    media-captions-menu,
2309    media-rendition-menu,
2310    media-audio-track-menu,
2311    media-playback-rate-menu {
2312      position: absolute; /* ensure they don't take up space in DOM on load */
2313      --media-menu-background: var(--_primary-color);
2314      --media-menu-item-checked-background: transparent;
2315      --media-text-color: var(--_text-color);
2316      --media-menu-item-hover-background: transparent;
2317      --media-menu-item-hover-outline: var(--_accent-color) solid 1px;
2318    }
2319
2320    media-rendition-menu {
2321      min-width: 140px;
2322    }
2323
2324    /* The icon is a circle so make it 16px high instead of 14px for more balance. */
2325    media-audio-track-menu-button {
2326      --media-control-padding: 5px;
2327      --media-control-height: 16px;
2328    }
2329
2330    media-playback-rate-menu-button {
2331      --media-control-padding: 6px 3px;
2332      min-width: 4.4ch;
2333    }
2334
2335    media-playback-rate-menu {
2336      --media-menu-flex-direction: row;
2337      --media-menu-item-checked-background: var(--_accent-color);
2338      --media-menu-item-checked-indicator-display: none;
2339      margin-right: 6px;
2340      padding: 0;
2341      --media-menu-gap: 0.25em;
2342    }
2343
2344    media-playback-rate-menu[part~='menu']::part(menu-item) {
2345      padding: 6px 6px 6px 8px;
2346    }
2347
2348    media-playback-rate-menu[part~='menu']::part(checked) {
2349      color: #fff;
2350    }
2351
2352    :host(:not([audio])) media-time-range {
2353      /* Adding px is required here for calc() */
2354      --media-range-padding: 0px;
2355      background: transparent;
2356      z-index: 10;
2357      height: 10px;
2358      bottom: -3px;
2359      width: 100%;
2360    }
2361
2362    media-control-bar :is([role='button'], [role='switch'], button) {
2363      line-height: 0;
2364    }
2365
2366    media-control-bar :is([part*='button'], [part*='range'], [part*='display']) {
2367      border-radius: 3px;
2368    }
2369
2370    .spacer {
2371      flex-grow: 1;
2372      background-color: var(--media-control-background, rgba(20, 20, 30, 0.7));
2373    }
2374
2375    media-control-bar[slot~='top-chrome'] {
2376      min-height: 42px;
2377      pointer-events: none;
2378    }
2379
2380    media-control-bar {
2381      --gradient-steps:
2382        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%,
2383        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%,
2384        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%,
2385        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%;
2386    }
2387
2388    :host([title]) media-control-bar[slot='top-chrome']::before,
2389    :host([videotitle]) media-control-bar[slot='top-chrome']::before {
2390      content: '';
2391      position: absolute;
2392      width: 100%;
2393      padding-bottom: min(100px, 25%);
2394      background: linear-gradient(to top, var(--gradient-steps));
2395      opacity: 0.8;
2396      pointer-events: none;
2397    }
2398
2399    :host(:not([audio])) media-control-bar[part~='bottom']::before {
2400      content: '';
2401      position: absolute;
2402      width: 100%;
2403      bottom: 0;
2404      left: 0;
2405      padding-bottom: min(100px, 25%);
2406      background: linear-gradient(to bottom, var(--gradient-steps));
2407      opacity: 0.8;
2408      z-index: 1;
2409      pointer-events: none;
2410    }
2411
2412    media-control-bar[part~='bottom'] > * {
2413      z-index: 20;
2414    }
2415
2416    media-control-bar[part~='bottom'] {
2417      padding: 6px 6px;
2418    }
2419
2420    media-control-bar[slot~='top-chrome'] > * {
2421      --media-control-background: transparent;
2422      --media-control-hover-background: transparent;
2423      position: relative;
2424    }
2425
2426    media-controller::part(vertical-layer) {
2427      transition: background-color 1s;
2428    }
2429
2430    media-controller:is([mediapaused], :not([userinactive]))::part(vertical-layer) {
2431      background-color: var(--controls-backdrop-color, var(--controls, transparent));
2432      transition: background-color 0.25s;
2433    }
2434
vendor: 39,699 bytes, lines 2435-3283
2435    .center-controls {
2436      --media-button-icon-width: 100%;
2437      --media-button-icon-height: auto;
2438      --media-tooltip-display: none;
2439      pointer-events: none;
2440      width: 100%;
2441      display: flex;
2442      flex-flow: row;
2443      align-items: center;
2444      justify-content: center;
2445      paint-order: stroke;
2446      stroke: rgba(102, 102, 102, 1);
2447      stroke-width: 0.3px;
2448      text-shadow:
2449        0 0 2px rgb(0 0 0 / 0.25),
2450        0 0 6px rgb(0 0 0 / 0.25);
2451      filter: drop-shadow(0 0 2px rgb(0 0 0 / 0.25)) drop-shadow(0 0 6px rgb(0 0 0 / 0.25));
2452    }
2453
2454    .center-controls media-play-button {
2455      --media-control-background: transparent;
2456      --media-control-hover-background: transparent;
2457      --media-control-padding: 0;
2458      width: 40px;
2459    }
2460
2461    [breakpointsm] .center-controls media-play-button {
2462      width: 90px;
2463      height: 90px;
2464      border-radius: 50%;
2465      transition: background 0.4s;
2466      padding: 24px;
2467      --media-control-background: #000;
2468      --media-control-hover-background: var(--_accent-color);
2469    }
2470
2471    .center-controls media-seek-backward-button,
2472    .center-controls media-seek-forward-button {
2473      --media-control-background: transparent;
2474      --media-control-hover-background: transparent;
2475      padding: 0;
2476      margin: 0 20px;
2477      width: max(33px, min(8%, 40px));
2478      text-shadow:
2479        0 0 2px rgb(0 0 0 / 0.25),
2480        0 0 6px rgb(0 0 0 / 0.25);
2481    }
2482
2483    [breakpointsm]:not([audio]) .center-controls.pre-playback {
2484      display: grid;
2485      align-items: initial;
2486      justify-content: initial;
2487      height: 100%;
2488      overflow: hidden;
2489    }
2490
2491    [breakpointsm]:not([audio]) .center-controls.pre-playback media-play-button {
2492      place-self: var(--_pre-playback-place, center);
2493      grid-area: 1 / 1;
2494      margin: 16px;
2495    }
2496
2497    /* Show and hide controls or pre-playback state */
2498
2499    [breakpointsm]:is([mediahasplayed], :not([mediapaused])):not([audio])
2500      .center-controls.pre-playback
2501      media-play-button {
2502      /* Using \`forwards\` would lead to a laggy UI after the animation got in the end state */
2503      animation: 0.3s linear pre-play-hide;
2504      opacity: 0;
2505      pointer-events: none;
2506    }
2507
2508    .autoplay-unmute {
2509      --media-control-hover-background: transparent;
2510      width: 100%;
2511      display: flex;
2512      align-items: center;
2513      justify-content: center;
2514      filter: drop-shadow(0 0 2px rgb(0 0 0 / 0.25)) drop-shadow(0 0 6px rgb(0 0 0 / 0.25));
2515    }
2516
2517    .autoplay-unmute-btn {
2518      --media-control-height: 16px;
2519      border-radius: 8px;
2520      background: #000;
2521      color: var(--_primary-color);
2522      display: flex;
2523      align-items: center;
2524      padding: 8px 16px;
2525      font-size: 18px;
2526      font-weight: 500;
2527      cursor: pointer;
2528    }
2529
2530    .autoplay-unmute-btn:hover {
2531      background: var(--_accent-color);
2532    }
2533
2534    [breakpointsm] .autoplay-unmute-btn {
2535      --media-control-height: 30px;
2536      padding: 14px 24px;
2537      font-size: 26px;
2538    }
2539
2540    .autoplay-unmute-btn svg {
2541      margin: 0 6px 0 0;
2542    }
2543
2544    [breakpointsm] .autoplay-unmute-btn svg {
2545      margin: 0 10px 0 0;
2546    }
2547
2548    media-controller:not([audio]):not([mediahasplayed]) *:is(media-control-bar, media-time-range) {
2549      display: none;
2550    }
2551
2552    media-error-dialog:not([mediaerrorcode]) {
2553      opacity: 0;
2554    }
2555
2556    media-loading-indicator {
2557      --media-loading-icon-width: 100%;
2558      --media-button-icon-height: auto;
2559      display: var(--media-control-display, var(--media-loading-indicator-display, flex));
2560      pointer-events: none;
2561      position: absolute;
2562      width: min(15%, 150px);
2563      flex-flow: row;
2564      align-items: center;
2565      justify-content: center;
2566    }
2567
2568    /* Intentionally don't target the div for transition but the children
2569     of the div. Prevents messing with media-chrome's autohide feature. */
2570    media-loading-indicator + div * {
2571      transition: opacity 0.15s;
2572      opacity: 1;
2573    }
2574
2575    media-loading-indicator[medialoading]:not([mediapaused]) ~ div > * {
2576      opacity: 0;
2577      transition-delay: 400ms;
2578    }
2579
2580    media-volume-range {
2581      width: min(100%, 100px);
2582      --media-range-padding-left: 10px;
2583      --media-range-padding-right: 10px;
2584      --media-range-thumb-width: 12px;
2585      --media-range-thumb-height: 12px;
2586      --media-range-thumb-background: radial-gradient(
2587        circle,
2588        #000 0%,
2589        #000 25%,
2590        var(--_primary-color) 25%,
2591        var(--_primary-color)
2592      );
2593      --media-control-hover-background: none;
2594    }
2595
2596    media-time-display {
2597      white-space: nowrap;
2598    }
2599
2600    /* Generic style for explicitly disabled controls */
2601    media-control-bar[part~='bottom'] [disabled],
2602    media-control-bar[part~='bottom'] [aria-disabled='true'] {
2603      opacity: 60%;
2604      cursor: not-allowed;
2605    }
2606
2607    media-text-display {
2608      --media-font-size: 16px;
2609      --media-control-padding: 14px;
2610      font-weight: 500;
2611    }
2612
2613    media-play-button.animated *:is(g, path) {
2614      transition: all 0.3s;
2615    }
2616
2617    media-play-button.animated[mediapaused] .pause-icon-pt1 {
2618      opacity: 0;
2619    }
2620
2621    media-play-button.animated[mediapaused] .pause-icon-pt2 {
2622      transform-origin: center center;
2623      transform: scaleY(0);
2624    }
2625
2626    media-play-button.animated[mediapaused] .play-icon {
2627      clip-path: inset(0 0 0 0);
2628    }
2629
2630    media-play-button.animated:not([mediapaused]) .play-icon {
2631      clip-path: inset(0 0 0 100%);
2632    }
2633
2634    media-seek-forward-button,
2635    media-seek-backward-button {
2636      --media-font-weight: 400;
2637    }
2638
2639    .mute-icon {
2640      display: inline-block;
2641    }
2642
2643    .mute-icon :is(path, g) {
2644      transition: opacity 0.5s;
2645    }
2646
2647    .muted {
2648      opacity: 0;
2649    }
2650
2651    media-mute-button[mediavolumelevel='low'] :is(.volume-medium, .volume-high),
2652    media-mute-button[mediavolumelevel='medium'] :is(.volume-high) {
2653      opacity: 0;
2654    }
2655
2656    media-mute-button[mediavolumelevel='off'] .unmuted {
2657      opacity: 0;
2658    }
2659
2660    media-mute-button[mediavolumelevel='off'] .muted {
2661      opacity: 1;
2662    }
2663
2664    /**
2665     * Our defaults for these buttons are to hide them at small sizes
2666     * users can override this with CSS
2667     */
2668    media-controller:not([breakpointsm]):not([audio]) {
2669      --bottom-play-button: none;
2670      --bottom-seek-backward-button: none;
2671      --bottom-seek-forward-button: none;
2672      --bottom-time-display: none;
2673      --bottom-playback-rate-menu-button: none;
2674      --bottom-pip-button: none;
2675    }
2676
2677    [part='mux-badge'] {
2678      position: absolute;
2679      bottom: 10px;
2680      right: 10px;
2681      z-index: 2;
2682      opacity: 0.6;
2683      transition:
2684        opacity 0.2s ease-in-out,
2685        bottom 0.2s ease-in-out;
2686    }
2687
2688    [part='mux-badge']:hover {
2689      opacity: 1;
2690    }
2691
2692    [part='mux-badge'] a {
2693      font-size: 14px;
2694      font-family: var(--_font-family);
2695      color: var(--_primary-color);
2696      text-decoration: none;
2697      display: flex;
2698      align-items: center;
2699      gap: 5px;
2700    }
2701
2702    [part='mux-badge'] .mux-badge-text {
2703      transition: opacity 0.5s ease-in-out;
2704      opacity: 0;
2705    }
2706
2707    [part='mux-badge'] .mux-badge-logo {
2708      width: 40px;
2709      height: auto;
2710      display: inline-block;
2711    }
2712
2713    [part='mux-badge'] .mux-badge-logo svg {
2714      width: 100%;
2715      height: 100%;
2716      fill: white;
2717    }
2718
2719    media-controller:not([userinactive]):not([mediahasplayed]) [part='mux-badge'],
2720    media-controller:not([userinactive]) [part='mux-badge'],
2721    media-controller[mediahasplayed][mediapaused] [part='mux-badge'] {
2722      transition: bottom 0.1s ease-in-out;
2723    }
2724
2725    media-controller[userinactive]:not([mediapaused]) [part='mux-badge'] {
2726      transition: bottom 0.2s ease-in-out 0.62s;
2727    }
2728
2729    media-controller:not([userinactive]) [part='mux-badge'] .mux-badge-text,
2730    media-controller[mediahasplayed][mediapaused] [part='mux-badge'] .mux-badge-text {
2731      opacity: 1;
2732    }
2733
2734    media-controller[userinactive]:not([mediapaused]) [part='mux-badge'] .mux-badge-text {
2735      opacity: 0;
2736    }
2737
2738    media-controller[userinactive]:not([mediapaused]) [part='mux-badge'] {
2739      bottom: 10px;
2740    }
2741
2742    media-controller:not([userinactive]):not([mediahasplayed]) [part='mux-badge'] {
2743      bottom: 10px;
2744    }
2745
2746    media-controller:not([userinactive])[mediahasplayed] [part='mux-badge'],
2747    media-controller[mediahasplayed][mediapaused] [part='mux-badge'] {
2748      bottom: calc(28px + var(--media-control-height, 0px) + var(--media-control-padding, 0px) * 2);
2749    }
2750  </style>
2751
2752  <template partial="TitleDisplay">
2753    <template if="videotitle">
2754      <template if="videotitle != true">
2755        <media-text-display part="top title display" class="title-display">{{videotitle}}</media-text-display>
2756      </template>
2757    </template>
2758    <template if="!videotitle">
2759      <template if="title">
2760        <media-text-display part="top title display" class="title-display">{{title}}</media-text-display>
2761      </template>
2762    </template>
2763  </template>
2764
2765  <template partial="PlayButton">
2766    <media-play-button
2767      part="{{section ?? 'bottom'}} play button"
2768      disabled="{{disabled}}"
2769      aria-disabled="{{disabled}}"
2770      class="animated"
2771    >
2772      <svg aria-hidden="true" viewBox="0 0 18 14" slot="icon">
2773        <g class="play-icon">
2774          <path
2775            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"
2776          />
2777        </g>
2778        <g class="pause-icon">
2779          <path
2780            class="pause-icon-pt1"
2781            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"
2782          />
2783          <path
2784            class="pause-icon-pt2"
2785            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"
2786          />
2787        </g>
2788      </svg>
2789    </media-play-button>
2790  </template>
2791
2792  <template partial="PrePlayButton">
2793    <media-play-button
2794      part="{{section ?? 'center'}} play button pre-play"
2795      disabled="{{disabled}}"
2796      aria-disabled="{{disabled}}"
2797    >
2798      <svg aria-hidden="true" viewBox="0 0 18 14" slot="icon" style="transform: translate(3px, 0)">
2799        <path
2800          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"
2801        />
2802      </svg>
2803    </media-play-button>
2804  </template>
2805
2806  <template partial="SeekBackwardButton">
2807    <media-seek-backward-button
2808      seekoffset="{{backwardseekoffset}}"
2809      part="{{section ?? 'bottom'}} seek-backward button"
2810      disabled="{{disabled}}"
2811      aria-disabled="{{disabled}}"
2812    >
2813      <svg viewBox="0 0 22 14" aria-hidden="true" slot="icon">
2814        <path
2815          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"
2816        />
2817        <text transform="translate(6 12)" style="font-size: 14px; font-family: 'ArialMT', 'Arial'">
2818          {{backwardseekoffset}}
2819        </text>
2820      </svg>
2821    </media-seek-backward-button>
2822  </template>
2823
2824  <template partial="SeekForwardButton">
2825    <media-seek-forward-button
2826      seekoffset="{{forwardseekoffset}}"
2827      part="{{section ?? 'bottom'}} seek-forward button"
2828      disabled="{{disabled}}"
2829      aria-disabled="{{disabled}}"
2830    >
2831      <svg viewBox="0 0 22 14" aria-hidden="true" slot="icon">
2832        <g>
2833          <text transform="translate(-1 12)" style="font-size: 14px; font-family: 'ArialMT', 'Arial'">
2834            {{forwardseekoffset}}
2835          </text>
2836          <path
2837            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"
2838          />
2839        </g>
2840      </svg>
2841    </media-seek-forward-button>
2842  </template>
2843
2844  <template partial="MuteButton">
2845    <media-mute-button part="bottom mute button" disabled="{{disabled}}" aria-disabled="{{disabled}}">
2846      <svg viewBox="0 0 18 14" slot="icon" class="mute-icon" aria-hidden="true">
2847        <g class="unmuted">
2848          <path
2849            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"
2850          />
2851          <path
2852            class="volume-low"
2853            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"
2854          />
2855          <path
2856            class="volume-medium"
2857            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"
2858          />
2859          <path
2860            class="volume-high"
2861            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"
2862          />
2863        </g>
2864        <g class="muted">
2865          <path
2866            fill-rule="evenodd"
2867            clip-rule="evenodd"
2868            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"
2869          />
2870          <path
2871            fill-rule="evenodd"
2872            clip-rule="evenodd"
2873            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"
2874          />
2875        </g>
2876      </svg>
2877    </media-mute-button>
2878  </template>
2879
2880  <template partial="PipButton">
2881    <media-pip-button part="bottom pip button" disabled="{{disabled}}" aria-disabled="{{disabled}}">
2882      <svg viewBox="0 0 18 14" aria-hidden="true" slot="icon">
2883        <path
2884          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"
2885        />
2886        <path
2887          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"
2888        />
2889      </svg>
2890    </media-pip-button>
2891  </template>
2892
2893  <template partial="CaptionsMenu">
2894    <media-captions-menu-button part="bottom captions button">
2895      <svg aria-hidden="true" viewBox="0 0 18 14" slot="on">
2896        <path
2897          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"
2898        />
2899      </svg>
2900      <svg aria-hidden="true" viewBox="0 0 18 14" slot="off">
2901        <path
2902          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"
2903        />
2904        <path
2905          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"
2906        />
2907        <path
2908          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"
2909        />
2910      </svg>
2911    </media-captions-menu-button>
2912    <media-captions-menu
2913      hidden
2914      anchor="auto"
2915      part="bottom captions menu"
2916      disabled="{{disabled}}"
2917      aria-disabled="{{disabled}}"
2918      exportparts="menu-item"
2919    >
2920      <div slot="checked-indicator">
2921        <style>
2922          .indicator {
2923            position: relative;
2924            top: 1px;
2925            width: 0.9em;
2926            height: auto;
2927            fill: var(--_accent-color);
2928            margin-right: 5px;
2929          }
2930
2931          [aria-checked='false'] .indicator {
2932            display: none;
2933          }
2934        </style>
2935        <svg viewBox="0 0 14 18" class="indicator">
2936          <path
2937            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"
2938            fill-rule="evenodd"
2939          />
2940        </svg></div
2941    ></media-captions-menu>
2942  </template>
2943
2944  <template partial="AirplayButton">
2945    <media-airplay-button part="bottom airplay button" disabled="{{disabled}}" aria-disabled="{{disabled}}">
2946      <svg viewBox="0 0 18 14" aria-hidden="true" slot="icon">
2947        <path
2948          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"
2949        />
2950        <path
2951          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"
2952        />
2953      </svg>
2954    </media-airplay-button>
2955  </template>
2956
2957  <template partial="FullscreenButton">
2958    <media-fullscreen-button part="bottom fullscreen button" disabled="{{disabled}}" aria-disabled="{{disabled}}">
2959      <svg viewBox="0 0 18 14" aria-hidden="true" slot="enter">
2960        <path
2961          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"
2962        />
2963        <path
2964          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"
2965        />
2966        <path
2967          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"
2968        />
2969        <path
2970          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"
2971        />
2972      </svg>
2973      <svg viewBox="0 0 18 14" aria-hidden="true" slot="exit">
2974        <path
2975          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"
2976        />
2977        <path
2978          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"
2979        />
2980        <path
2981          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"
2982        />
2983        <path
2984          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"
2985        />
2986      </svg>
2987    </media-fullscreen-button>
2988  </template>
2989
2990  <template partial="CastButton">
2991    <media-cast-button part="bottom cast button" disabled="{{disabled}}" aria-disabled="{{disabled}}">
2992      <svg viewBox="0 0 18 14" aria-hidden="true" slot="enter">
2993        <path
2994          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"
2995        />
2996      </svg>
2997      <svg viewBox="0 0 18 14" aria-hidden="true" slot="exit">
2998        <path
2999          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"
3000        />
3001        <path d="M2.15002 5.634C5.18352 6.4207 7.57252 8.8151 8.35282 11.8499H15.8501V2.1499H2.15002V5.634Z" />
3002      </svg>
3003    </media-cast-button>
3004  </template>
3005
3006  <template partial="LiveButton">
3007    <media-live-button part="{{section ?? 'top'}} live button" disabled="{{disabled}}" aria-disabled="{{disabled}}">
3008      <span slot="text">Live</span>
3009    </media-live-button>
3010  </template>
3011
3012  <template partial="PlaybackRateMenu">
3013    <media-playback-rate-menu-button part="bottom playback-rate button"></media-playback-rate-menu-button>
3014    <media-playback-rate-menu
3015      hidden
3016      anchor="auto"
3017      rates="{{playbackrates}}"
3018      exportparts="menu-item"
3019      part="bottom playback-rate menu"
3020      disabled="{{disabled}}"
3021      aria-disabled="{{disabled}}"
3022    ></media-playback-rate-menu>
3023  </template>
3024
3025  <template partial="VolumeRange">
3026    <media-volume-range
3027      part="bottom volume range"
3028      disabled="{{disabled}}"
3029      aria-disabled="{{disabled}}"
3030    ></media-volume-range>
3031  </template>
3032
3033  <template partial="TimeDisplay">
3034    <media-time-display
3035      remaining="{{defaultshowremainingtime}}"
3036      showduration="{{!hideduration}}"
3037      part="bottom time display"
3038      disabled="{{disabled}}"
3039      aria-disabled="{{disabled}}"
3040    ></media-time-display>
3041  </template>
3042
3043  <template partial="TimeRange">
3044    <media-time-range part="bottom time range" disabled="{{disabled}}" aria-disabled="{{disabled}}" exportparts="thumb">
3045      <media-preview-thumbnail slot="preview"></media-preview-thumbnail>
3046      <media-preview-chapter-display slot="preview"></media-preview-chapter-display>
3047      <media-preview-time-display slot="preview"></media-preview-time-display>
3048      <div slot="preview" part="arrow"></div>
3049    </media-time-range>
3050  </template>
3051
3052  <template partial="AudioTrackMenu">
3053    <media-audio-track-menu-button part="bottom audio-track button">
3054      <svg aria-hidden="true" slot="icon" viewBox="0 0 18 16">
3055        <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" />
3056        <path
3057          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"
3058        />
3059      </svg>
3060    </media-audio-track-menu-button>
3061    <media-audio-track-menu
3062      hidden
3063      anchor="auto"
3064      part="bottom audio-track menu"
3065      disabled="{{disabled}}"
3066      aria-disabled="{{disabled}}"
3067      exportparts="menu-item"
3068    >
3069      <div slot="checked-indicator">
3070        <style>
3071          .indicator {
3072            position: relative;
3073            top: 1px;
3074            width: 0.9em;
3075            height: auto;
3076            fill: var(--_accent-color);
3077            margin-right: 5px;
3078          }
3079
3080          [aria-checked='false'] .indicator {
3081            display: none;
3082          }
3083        </style>
3084        <svg viewBox="0 0 14 18" class="indicator">
3085          <path
3086            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"
3087            fill-rule="evenodd"
3088          />
3089        </svg>
3090      </div>
3091    </media-audio-track-menu>
3092  </template>
3093
3094  <template partial="RenditionMenu">
3095    <media-rendition-menu-button part="bottom rendition button">
3096      <svg aria-hidden="true" slot="icon" viewBox="0 0 18 14">
3097        <path
3098          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"
3099        />
3100      </svg>
3101    </media-rendition-menu-button>
3102    <media-rendition-menu
3103      hidden
3104      anchor="auto"
3105      part="bottom rendition menu"
3106      disabled="{{disabled}}"
3107      aria-disabled="{{disabled}}"
3108    >
3109      <div slot="checked-indicator">
3110        <style>
3111          .indicator {
3112            position: relative;
3113            top: 1px;
3114            width: 0.9em;
3115            height: auto;
3116            fill: var(--_accent-color);
3117            margin-right: 5px;
3118          }
3119
3120          [aria-checked='false'] .indicator {
3121            opacity: 0;
3122          }
3123        </style>
3124        <svg viewBox="0 0 14 18" class="indicator">
3125          <path
3126            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"
3127            fill-rule="evenodd"
3128          />
3129        </svg>
3130      </div>
3131    </media-rendition-menu>
3132  </template>
3133
3134  <template partial="MuxBadge">
3135    <div part="mux-badge">
3136      <a href="https://www.mux.com/player" target="_blank">
3137        <span class="mux-badge-text">Powered by</span>
3138        <div class="mux-badge-logo">
3139          <svg
3140            viewBox="0 0 1600 500"
3141            style="fill-rule: evenodd; clip-rule: evenodd; stroke-linejoin: round; stroke-miterlimit: 2"
3142          >
3143            <g>
3144              <path
3145                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"
3146                style="fill-rule: nonzero"
3147              ></path>
3148              <path
3149                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"
3150                style="fill-rule: nonzero"
3151              ></path>
3152              <path
3153                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"
3154                style="fill-rule: nonzero"
3155              ></path>
3156            </g>
3157          </svg>
3158        </div>
3159      </a>
3160    </div>
3161  </template>
3162
3163  <media-controller
3164    part="controller"
3165    defaultstreamtype="{{defaultstreamtype ?? 'on-demand'}}"
3166    breakpoints="sm:470"
3167    gesturesdisabled="{{disabled}}"
3168    hotkeys="{{hotkeys}}"
3169    nohotkeys="{{nohotkeys}}"
3170    novolumepref="{{novolumepref}}"
3171    audio="{{audio}}"
3172    noautoseektolive="{{noautoseektolive}}"
3173    defaultsubtitles="{{defaultsubtitles}}"
3174    defaultduration="{{defaultduration ?? false}}"
3175    keyboardforwardseekoffset="{{forwardseekoffset}}"
3176    keyboardbackwardseekoffset="{{backwardseekoffset}}"
3177    exportparts="layer, media-layer, poster-layer, vertical-layer, centered-layer, gesture-layer"
3178    style="--_pre-playback-place:{{preplaybackplace ?? 'center'}}"
3179  >
3180    <slot name="media" slot="media"></slot>
3181    <slot name="poster" slot="poster"></slot>
3182
3183    <media-loading-indicator slot="centered-chrome" noautohide></media-loading-indicator>
3184
3185    <template if="!audio">
3186      <media-error-dialog slot="dialog" noautohide></media-error-dialog>
3187      <!-- Pre-playback UI -->
3188      <!-- same for both on-demand and live -->
3189      <div slot="centered-chrome" class="center-controls pre-playback">
3190        <template if="!breakpointsm">{{>PlayButton section="center"}}</template>
3191        <template if="breakpointsm">{{>PrePlayButton section="center"}}</template>
3192      </div>
3193
3194      <!-- Mux Badge -->
3195      <template if="proudlydisplaymuxbadge"> {{>MuxBadge}} </template>
3196
3197      <!-- Autoplay centered unmute button -->
3198      <!--
3199        todo: figure out how show this with available state variables
3200        needs to show when:
3201        - autoplay is enabled
3202        - playback has been successful
3203        - audio is muted
3204        - in place / instead of the pre-plaback play button
3205        - not to show again after user has interacted with this button
3206          - OR user has interacted with the mute button in the control bar
3207      -->
3208      <!--
3209        There should be a >MuteButton to the left of the "Unmute" text, but a templating bug
3210        makes it appear even if commented out in the markup, add it back when code is un-commented
3211      -->
3212      <!-- <div slot="centered-chrome" class="autoplay-unmute">
3213        <div role="button" class="autoplay-unmute-btn">Unmute</div>
3214      </div> -->
3215
3216      <template if="streamtype == 'on-demand'">
3217        <template if="breakpointsm">
3218          <media-control-bar part="control-bar top" slot="top-chrome">{{>TitleDisplay}} </media-control-bar>
3219        </template>
3220        {{>TimeRange}}
3221        <media-control-bar part="control-bar bottom">
3222          {{>PlayButton}} {{>SeekBackwardButton}} {{>SeekForwardButton}} {{>TimeDisplay}} {{>MuteButton}}
3223          {{>VolumeRange}}
3224          <div class="spacer"></div>
3225          {{>RenditionMenu}} {{>PlaybackRateMenu}} {{>AudioTrackMenu}} {{>CaptionsMenu}} {{>AirplayButton}}
3226          {{>CastButton}} {{>PipButton}} {{>FullscreenButton}}
3227        </media-control-bar>
3228      </template>
3229
3230      <template if="streamtype == 'live'">
3231        <media-control-bar part="control-bar top" slot="top-chrome">
3232          {{>LiveButton}}
3233          <template if="breakpointsm"> {{>TitleDisplay}} </template>
3234        </media-control-bar>
3235        <template if="targetlivewindow > 0">{{>TimeRange}}</template>
3236        <media-control-bar part="control-bar bottom">
3237          {{>PlayButton}}
3238          <template if="targetlivewindow > 0">{{>SeekBackwardButton}} {{>SeekForwardButton}}</template>
3239          {{>MuteButton}} {{>VolumeRange}}
3240          <div class="spacer"></div>
3241          {{>RenditionMenu}} {{>AudioTrackMenu}} {{>CaptionsMenu}} {{>AirplayButton}} {{>CastButton}} {{>PipButton}}
3242          {{>FullscreenButton}}
3243        </media-control-bar>
3244      </template>
3245    </template>
3246
3247    <template if="audio">
3248      <template if="streamtype == 'on-demand'">
3249        <template if="title">
3250          <media-control-bar part="control-bar top">{{>TitleDisplay}}</media-control-bar>
3251        </template>
3252        <media-control-bar part="control-bar bottom">
3253          {{>PlayButton}}
3254          <template if="breakpointsm"> {{>SeekBackwardButton}} {{>SeekForwardButton}} </template>
3255          {{>MuteButton}}
3256          <template if="breakpointsm">{{>VolumeRange}}</template>
3257          {{>TimeDisplay}} {{>TimeRange}}
3258          <template if="breakpointsm">{{>PlaybackRateMenu}}</template>
3259          {{>AirplayButton}} {{>CastButton}}
3260        </media-control-bar>
3261      </template>
3262
3263      <template if="streamtype == 'live'">
3264        <template if="title">
3265          <media-control-bar part="control-bar top">{{>TitleDisplay}}</media-control-bar>
3266        </template>
3267        <media-control-bar part="control-bar bottom">
3268          {{>PlayButton}} {{>LiveButton section="bottom"}} {{>MuteButton}}
3269          <template if="breakpointsm">
3270            {{>VolumeRange}}
3271            <template if="targetlivewindow > 0"> {{>SeekBackwardButton}} {{>SeekForwardButton}} </template>
3272          </template>
3273          <template if="targetlivewindow > 0"> {{>TimeDisplay}} {{>TimeRange}} </template>
3274          <template if="!targetlivewindow"><div class="spacer"></div></template>
3275          {{>AirplayButton}} {{>CastButton}}
3276        </media-control-bar>
3277      </template>
3278    </template>
3279
3280    <slot></slot>
3281  </media-controller>
3282</template>
3283`
3283,Sf=_H.createElement("template");"innerHTML"in Sf&&(Sf.innerHTML=Sm);var Sp,Sg,Sv=class extends En{};Sv.template=null==(Sg=null==(Sp=Sf.content)?void 0:Sp.children)?void 0:Sg[0],_$.customElements.get("media-theme-gerwig")||_$.customElements.define("media-theme-gerwig",Sv);var SE={SRC:"src",POSTER:"poster"},Sy={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"},Sb=["audio","backwardseekoffset","defaultduration","defaultshowremainingtime","defaultsubtitles","noautoseektolive","disabled","exportparts","forwardseekoffset","hideduration","hotkeys","nohotkeys","playbackrates","defaultstreamtype","streamtype","style","targetlivewindow","template","title","videotitle","novolumepref","nomutedpref","proudlydisplaymuxbadge"],ST=gT.formatErrorMessage;function SA(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)}gT.formatErrorMessage=e=>{var t,i;if(e instanceof d5){let r=((e,t=!1)=>({title:((e,t=!1)=>{var i,r;if(e.muxCode){let a=Su(null!=(i=e.errorCategory)?i:"video"),s=d4(null!=(r=e.errorCategory)?r:d3);if(2000002===e.muxCode)return hE("Your device appears to be offline",t);if(2000003===e.muxCode)return hE("Reconnecting...",t);if(2403210===e.muxCode)return hE("{category} URL has expired",t).format({category:a});if([2403232,2403222,2403221,2412202].includes(e.muxCode))return hE("{category} URL is formatted incorrectly",t).format({category:a});if(2403201===e.muxCode)return hE("Invalid {categoryName} URL",t).format({categoryName:s});if(2404e3===e.muxCode)return hE("{category} does not exist",t).format({category:a});if(2412e3===e.muxCode){let i="live"===e.streamType?"Live stream":"Video";return hE("{mediaType} is not currently available",t).format({mediaType:i})}}if(e.code){if(e.code===d5.MEDIA_ERR_NETWORK)return hE("Network Error",t);if(e.code===d5.MEDIA_ERR_DECODE)return hE("Media Error",t);if(e.code===d5.MEDIA_ERR_SRC_NOT_SUPPORTED)return hE("Source Not Supported",t)}return hE("Error",t)})(e,t).toString(),message:((e,t=!1)=>{var i,r;if(e.reload)return'Try again later or <a href="#" data-mux-reload style="color: #4a90e2;">click here to retry</a>';if(e.muxCode){let a=Su(null!=(i=e.errorCategory)?i:"video"),s=d4(null!=(r=e.errorCategory)?r:d3);return 2000002===e.muxCode?hE("Check your internet connection and try reloading this video.",t):2000003===e.muxCode?hE("Your connection was interrupted. Attempting to resume playback...",t):2403210===e.muxCode?hE("The video’s secured {tokenNamePrefix}-token has expired.",t).format({tokenNamePrefix:s}):2403232===e.muxCode?hE("The video’s playback ID does not match the one encoded in the {tokenNamePrefix}-token.",t).format({tokenNamePrefix:s}):2412202===e.muxCode?hE("{category} URL is formatted incorrectly",t).format({category:a}):[2403222,2403221].includes(e.muxCode)?hE("The {tokenNamePrefix}-token is formatted with incorrect information.",t).format({tokenNamePrefix:s}):[2403201,24e5].includes(e.muxCode)?hE("The video URL or {tokenNamePrefix}-token are formatted with incorrect or incomplete information.",t).format({tokenNamePrefix:s}):2404e3===e.muxCode?"":e.message}return e.code&&(e.code===d5.MEDIA_ERR_NETWORK||e.code===d5.MEDIA_ERR_DECODE||e.code===d5.MEDIA_ERR_SRC_NOT_SUPPORTED),e.message})(e,t).toString()}))(e,!1);return`
3284      ${null!=r&&r.title?`<h3>${r.title}</h3>`:""}
3285      ${null!=r&&r.message||null!=r&&r.linkUrl?`<p>
3286        ${null==r?void 0:r.message}
3287        ${null!=r&&r.linkUrl?`<a
3288              href="${r.linkUrl}"
3289              target="_blank"
3290              rel="external noopener"
3291              aria-label="${null!=(t=r.linkText)?t:""} ${hE("(opens in a new window)")}"
3292              >${null!=(i=r.linkText)?i:r.linkUrl}</a
3293            >`:""}
3294      </p>`:""}
3295    `}return ST(e)};var S_,SS,Sk,SR,SL,SI,Sw,SD,SC,SM,Sx,SP,SO,SN,SU,SF,SB,S$,SH,SG,SW,SK,SV,Sq,Sj=Object.values(ch),SY=Object.values(SE),Sz=Object.values(Sy),SQ="mux-
3295player",SX={isDialogOpen:!1},SZ={redundant_streams:!0},SJ=class extends Se{constructor(){super(),yb(this,SF),yb(this,S_),yb(this,SS,!1),yb(this,Sk,{}),yb(this,SR,!0),yb(this,SL,new _0(this,"hotkeys")),yb(this,SI),yb(this,Sw,()=>yA(this,SF,SG).call(this)),yb(this,SD,()=>yA(this,SF,SG).call(this)),yb(this,SC,()=>yA(this,SF,SG).call(this)),yb(this,SM,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())}),yb(this,Sx,e=>{var t;(null==(t=e.composedPath()[0])?void 0:t.localName)==="media-error-dialog"&&yA(this,SF,SH).call(this,{isDialogOpen:!1})}),yb(this,SP,e=>{var t;(null==(t=e.composedPath()[0])?void 0:t.localName)==="media-error-dialog"&&(_z(this,_H.activeElement)||e.preventDefault())}),yb(this,SO),yb(this,SN,{...SX}),yb(this,SU,e=>{var t;let i=null==(t=this.media)?void 0:t.error;if(!(i instanceof d5)){let{message:e,code:t}=null!=i?i:{};i=new d5(e,t)}if(!(null!=i&&i.fatal)){_2(i),i.data&&_2(`${i.name} data:`,i.data);return}let r=Sc(i,!1);r.message&&_4(r),_3(i),i.data&&_3(`${i.name} data:`,i.data),yA(this,SF,SH).call(this,{isDialogOpen:!0})}),yT(this,S_,um()),this.attachShadow({mode:"open"}),yA(this,SF,S$).call(this),this.isConnected&&yA(this,SF,SB).call(this)}static get NAME(){return SQ}static get VERSION(){return _X}static get observedAttributes(){var e;return[...null!=(e=Se.observedAttributes)?e:[],...SY,...Sj,...Sz]}setAttribute(e,t){super.setAttribute(e,t),e.startsWith("metadata-")&&this.media&&(this.media.metadata=SA(this))}removeAttribute(e){super.removeAttribute(e),e.startsWith("metadata-")&&this.media&&(this.media.metadata=SA(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(){yA(this,SF,SB).call(this);let e=this.media;e&&(e.metadata=SA(this))}disconnectedCallback(){var e,t,i,r,a,s,n,l,o,d;null==(e=yy(this,SI))||e.disconnect(),null==(t=this.media)||t.removeEventListener("streamtypechange",yy(this,Sw)),null==(i=this.media)||i.removeEventListener("loadstart",yy(this,SD)),this.removeEventListener("error",yy(this,SU)),this.removeEventListener("click",yy(this,SM)),null==(r=this.mediaTheme)||r.removeEventListener("close",yy(this,Sx)),null==(a=this.mediaTheme)||a.removeEventListener("focusin",yy(this,SP)),this.media&&(this.media.errorTranslator=void 0),null==(n=null==(s=this.media)?void 0:s.textTracks)||n.removeEventListener("addtrack",yy(this,SC)),null==(o=null==(l=this.media)?void 0:l.textTracks)||o.removeEventListener("removetrack",yy(this,SC)),null==(d=yy(this,SO))||d.call(this),yT(this,SO,void 0),yT(this,SS,!1)}attributeChangedCallback(e,t,i){var r;switch(yA(this,SF,SB).call(this),super.attributeChangedCallback(e,t,i),e){case Sy.HOTKEYS:yy(this,SL).value=i;break;case Sy.THUMBNAIL_TIME:null!=i&&this.tokens.thumbnail&&_2(hE("Use of thumbnail-time with thumbnail-token is currently unsupported. Ignore thumbnail-time.").toString());break;case Sy.THUMBNAIL_TOKEN:if(i){let e=hv(i);if(e){let{aud:t}=e;"t"!==t&&_2(hE("The {tokenNamePrefix}-token has an incorrect aud value: {aud}. aud value should be {expectedAud}.").format({aud:t,expectedAud:"t",tokenNamePrefix:"thumbnail"}))}}break;case Sy.STORYBOARD_TOKEN:if(i){let e=hv(i);if(e){let{aud:t}=e;"s"!==t&&_2(hE("The {tokenNamePrefix}-token has an incorrect aud value: {aud}. aud value should be {expectedAud}.").format({aud:t,expectedAud:"s",tokenNamePrefix:"storyboard"}))}}break;case Sy.DRM_TOKEN:if(i){let e=hv(i);if(e){let{aud:t}=e;"d"!==t&&_2(hE("The {tokenNamePrefix}-token has an incorrect aud value: {aud}. aud value should be {expectedAud}.").format({aud:t,expectedAud:"d",tokenNamePrefix:"drm"}))}}break;case ch.PLAYBACK_ID:null!=i&&i.includes("?token")&&_3(hE("The specificed playback ID {playbackId} contains a token which must be provided via the playback-token attribute.").format({playbackId:i}));break;case ch.STREAM_TYPE:i&&![d7,d9,he].includes(i)?["ll-live","live:dvr","ll-live:dvr"].includes(this.streamType)?this.targetLiveWindow=i.includes("dvr")?1/0:0:_4({file:"invalid-stream-type.md",message:hE("Invalid stream-type value supplied: `{streamType}`. Please provide stream-type as either: `on-demand` or `live`").format({streamType:this.streamType})}):i===d7?null==this.getAttribute(Sy.TARGET_LIVE_WINDOW)&&(this.targetLiveWindow=0):this.targetLiveWindow=NaN;break;case Sy.FULLSCREEN_ELEMENT:if(null!=i||i!==t){let e=_H.getElementById(i),t=null==e?void 0:e.querySelector("mux-player");this.mediaController&&e&&t&&(this.mediaController.fullscreenElement=e)}break;case ch.CAP_RENDITION_TO_PLAYER_SIZE:(null==i||i!==t)&&(this.capRenditionToPlayerSize=null!=i||void 0);break;case ch.MAX_RECONNECT_RETRIES:(null==i||i!==t)&&(this.maxReconnectRetries=Number(i))}[ch.PLAYBACK_ID,SE.SRC,Sy.PLAYBACK_TOKEN].includes(e)&&t!==i&&yT(this,SN,{...yy(this,SN),...SX}),yA(this,SF,SG).call(this,{[null!=(r=_J[e])?r:_W(e)]:i})}async requestFullscreen(e){var t;if(!(!this.mediaController||this.mediaController.hasAttribute(md.MEDIA_IS_FULLSCREEN)))return null==(t=this.mediaController)||t.dispatchEvent(new _$.CustomEvent(ms.MEDIA_ENTER_FULLSCREEN_REQUEST,{composed:!0,bubbles:!0})),new Promise((e,t)=>
3295{var i;null==(i=this.mediaController)||i.addEventListener(mh.MEDIA_IS_FULLSCREEN,()=>e(),{once:!0})})}async exitFullscreen(){var e;if(!(!this.mediaController||!this.mediaController.hasAttribute(md.MEDIA_IS_FULLSCREEN)))return null==(e=this.mediaController)||e.dispatchEvent(new _$.CustomEvent(ms.MEDIA_EXIT_FULLSCREEN_REQUEST,{composed:!0,bubbles:!0})),new Promise((e,t)=>{var i;null==(i=this.mediaController)||i.addEventListener(mh.MEDIA_IS_FULLSCREEN,()=>e(),{once:!0})})}get preferCmcd(){var e;return null!=(e=this.getAttribute(ch.PREFER_CMCD))?e:void 0}set preferCmcd(e){e!==this.preferCmcd&&(e?hr.includes(e)?this.setAttribute(ch.PREFER_CMCD,e):_2(`Invalid value for preferCmcd. Must be one of ${hr.join()}`):this.removeAttribute(ch.PREFER_CMCD))}get hasPlayed(){var e,t;return null!=(t=null==(e=this.mediaController)?void 0:e.hasAttribute(md.MEDIA_HAS_PLAYED))&&t}get inLiveWindow(){var e;return null==(e=this.mediaController)?void 0:e.hasAttribute(md.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(Sy.THEME))?e:"gerwig"}set theme(e){this.setAttribute(Sy.THEME,`${e}`)}get themeProps(){let e=this.mediaTheme;if(!e)return;let t={};for(let i of e.getAttributeNames()){if(Sb.includes(i))continue;let r=e.getAttribute(i);t[_W(i)]=""===r||r}return t}set themeProps(e){var t,i;yA(this,SF,SB).call(this);let r={...this.themeProps,...e};for(let a in r){if(Sb.includes(a))continue;let r=null==e?void 0:e[a];"boolean"==typeof r||null==r?null==(t=this.mediaTheme)||t.toggleAttribute(_G(a),!!r):null==(i=this.mediaTheme)||i.setAttribute(_G(a),r)}}get playbackId(){var e;return null!=(e=this.getAttribute(ch.PLAYBACK_ID))?e:void 0}set playbackId(e){e?this.setAttribute(ch.PLAYBACK_ID,e):this.removeAttribute(ch.PLAYBACK_ID)}get src(){var e,t;return this.playbackId?null!=(e=S0(this,SE.SRC))?e:void 0:null!=(t=this.getAttribute(SE.SRC))?t:void 0}set src(e){e?this.setAttribute(SE.SRC,e):this.removeAttribute(SE.SRC)}get poster(){var e;let t=this.getAttribute(SE.POSTER);if(null!=t)return t;let{tokens:i}=this;return i.playback&&!i.thumbnail?void _2("Missing expected thumbnail token. No poster image will be shown"):this.playbackId&&!this.audio?((e,{token:t,customDomain:i=_Q,thumbnailTime:r,programTime:a}={})=>{var s;let n=null==t?r:void 0,{aud:l}=null!=(s=hv(t))?s:{};if(!(t&&"t"!==l))return`https://image.${i}/${e}/thumbnail.webp${_V({token:t,time:n,program_time:a})}`})(this.playbackId,{customDomain:this.customDomain,thumbnailTime:null!=(e=this.thumbnailTime)?e:this.startTime,programTime:this.programStartTime,token:i.thumbnail}):void 0}set poster(e){e||""===e?this.setAttribute(SE.POSTER,e):this.removeAttribute(SE.POSTER)}get storyboardSrc(){var e;return null!=(e=this.getAttribute(Sy.STORYBOARD_SRC))?e:void 0}set storyboardSrc(e){e?this.setAttribute(Sy.STORYBOARD_SRC,e):this.removeAttribute(Sy.STORYBOARD_SRC)}get storyboard(){let{tokens:e}=this;return this.storyboardSrc&&!e.storyboard?this.storyboardSrc:this.audio||!this.playbackId||!this.streamType||[d7,he].includes(this.streamType)||e.playback&&!e.storyboard?void 0:((e,{token:t,customDomain:i=_Q,programStartTime:r,programEndTime:a}={})=>{var s;let{aud:n}=null!=(s=hv(t))?s:{};if(!(t&&"s"!==n))return`https://image.${i}/${e}/storyboard.vtt${_V({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(Sy.AUDIO)}set audio(e){e?this.setAttribute(Sy.AUDIO,""):this.removeAttribute(Sy.AUDIO)}get hotkeys(){return yy(this,SL)}get nohotkeys(){return this.hasAttribute(Sy.NOHOTKEYS)}set nohotkeys(e){e?this.setAttribute(Sy.NOHOTKEYS,""):this.removeAttribute(Sy.NOHOTKEYS)}get thumbnailTime(){return _K(this.getAttribute(Sy.THUMBNAIL_TIME))}set thumbnailTime(e){this.setAttribute(Sy.THUMBNAIL_TIME,`${e}`)}get videoTitle(){var e,t;return null!=(t=null!=(e=this.getAttribute(Sy.VIDEO_TITLE))?e:this.getAttribute(Sy.TITLE))?t:""}set videoTitle(e){e!==this.videoTitle&&(e?this.setAttribute(Sy.VIDEO_TITLE,e):this.removeAttribute(Sy.VIDEO_TITLE))}get placeholder(){var e;return null!=(e=S0(this,Sy.PLACEHOLDER))?e:""}set placeholder(e){this.setAttribute(Sy.PLACEHOLDER,`${e}`)}get primaryColor(){var e,t;let i=this.getAttribute(Sy.PRIMARY_COLOR);if(null!=i||this.mediaTheme&&(i=null==(t=null==(e=_$.getComputedStyle(this.mediaTheme))?void 0:e.getPropertyValue("--_primary-color"))?void 0:t.trim()))return i}set primaryColor(e){this.setAttribute(Sy.PRIMARY_COLOR,`${e}`)}get secondaryColor(){var e,t;let i=this.getAttribute(Sy.SECONDARY_COLOR);if(null!=i||this.mediaTheme&&(i=null==(t=null==(e=_$.getComputedStyle(this.mediaTheme))?void 0:e.getPropertyValue("--_secondary-color"))?void 0:t.trim()))return i}set secondaryColor(e){this.setAttribute(Sy.SECONDARY_COLOR,`${e}`)}get accentColor(){var e,t;let i=this.getAttribute(Sy.ACCENT_COLOR);if(null!=i||this.mediaTheme&&(i=null==(t=null==(e=_$.getComputedStyle(this.mediaTheme))?void 0:e.getPropertyValue("--_accent-color"))?void 0:t.trim()))return i}set accentColor(e){this.setAttribute(Sy.ACCENT_COLOR,`${e}`)}get defaultShowRemainingTime(){return this.hasAttribute(Sy.DEFAULT_SHOW_REMAINING_TIME)}set defaultShowRemainingTime(e){e?this.setAttribute(Sy.DEFAULT_SHOW_REMAINING_TIME,""):this.removeAttribute(Sy.DEFAULT_SHOW_REMAINING_TIME)}get playbackRates(){if(this.hasAttribute(Sy.PLAYBACK_RATES))return this.getAttribute(Sy.PLAYBACK_RATES).trim().split(/\s*,?\s+/).map(e=>Number(e)).filter(e=>!Number.isNaN(e)).sort((e,t)=>
3295e-t)}set playbackRates(e){e?this.setAttribute(Sy.PLAYBACK_RATES,e.join(" ")):this.removeAttribute(Sy.PLAYBACK_RATES)}get forwardSeekOffset(){var e;return null!=(e=_K(this.getAttribute(Sy.FORWARD_SEEK_OFFSET)))?e:10}set forwardSeekOffset(e){this.setAttribute(Sy.FORWARD_SEEK_OFFSET,`${e}`)}get backwardSeekOffset(){var e;return null!=(e=_K(this.getAttribute(Sy.BACKWARD_SEEK_OFFSET)))?e:10}set backwardSeekOffset(e){this.setAttribute(Sy.BACKWARD_SEEK_OFFSET,`${e}`)}get defaultHiddenCaptions(){return this.hasAttribute(Sy.DEFAULT_HIDDEN_CAPTIONS)}set defaultHiddenCaptions(e){e?this.setAttribute(Sy.DEFAULT_HIDDEN_CAPTIONS,""):this.removeAttribute(Sy.DEFAULT_HIDDEN_CAPTIONS)}get defaultDuration(){return _K(this.getAttribute(Sy.DEFAULT_DURATION))}set defaultDuration(e){null==e?this.removeAttribute(Sy.DEFAULT_DURATION):this.setAttribute(Sy.DEFAULT_DURATION,`${e}`)}get playerInitTime(){return this.hasAttribute(ch.PLAYER_INIT_TIME)?_K(this.getAttribute(ch.PLAYER_INIT_TIME)):yy(this,S_)}set playerInitTime(e){e!=this.playerInitTime&&(null==e?this.removeAttribute(ch.PLAYER_INIT_TIME):this.setAttribute(ch.PLAYER_INIT_TIME,`${+e}`))}get playerSoftwareName(){var e;return null!=(e=this.getAttribute(ch.PLAYER_SOFTWARE_NAME))?e:SQ}get playerSoftwareVersion(){var e;return null!=(e=this.getAttribute(ch.PLAYER_SOFTWARE_VERSION))?e:_X}get beaconCollectionDomain(){var e;return null!=(e=this.getAttribute(ch.BEACON_COLLECTION_DOMAIN))?e:void 0}set beaconCollectionDomain(e){e!==this.beaconCollectionDomain&&(e?this.setAttribute(ch.BEACON_COLLECTION_DOMAIN,e):this.removeAttribute(ch.BEACON_COLLECTION_DOMAIN))}get maxResolution(){var e;return null!=(e=this.getAttribute(ch.MAX_RESOLUTION))?e:void 0}set maxResolution(e){e!==this.maxResolution&&(e?this.setAttribute(ch.MAX_RESOLUTION,e):this.removeAttribute(ch.MAX_RESOLUTION))}get minResolution(){var e;return null!=(e=this.getAttribute(ch.MIN_RESOLUTION))?e:void 0}set minResolution(e){e!==this.minResolution&&(e?this.setAttribute(ch.MIN_RESOLUTION,e):this.removeAttribute(ch.MIN_RESOLUTION))}get maxAutoResolution(){var e;return null!=(e=this.getAttribute(ch.MAX_AUTO_RESOLUTION))?e:void 0}set maxAutoResolution(e){null==e?this.removeAttribute(ch.MAX_AUTO_RESOLUTION):this.setAttribute(ch.MAX_AUTO_RESOLUTION,e)}get renditionOrder(){var e;return null!=(e=this.getAttribute(ch.RENDITION_ORDER))?e:void 0}set renditionOrder(e){e!==this.renditionOrder&&(e?this.setAttribute(ch.RENDITION_ORDER,e):this.removeAttribute(ch.RENDITION_ORDER))}get programStartTime(){return _K(this.getAttribute(ch.PROGRAM_START_TIME))}set programStartTime(e){null==e?this.removeAttribute(ch.PROGRAM_START_TIME):this.setAttribute(ch.PROGRAM_START_TIME,`${e}`)}get programEndTime(){return _K(this.getAttribute(ch.PROGRAM_END_TIME))}set programEndTime(e){null==e?this.removeAttribute(ch.PROGRAM_END_TIME):this.setAttribute(ch.PROGRAM_END_TIME,`${e}`)}get assetStartTime(){return _K(this.getAttribute(ch.ASSET_START_TIME))}set assetStartTime(e){null==e?this.removeAttribute(ch.ASSET_START_TIME):this.setAttribute(ch.ASSET_START_TIME,`${e}`)}get assetEndTime(){return _K(this.getAttribute(ch.ASSET_END_TIME))}set assetEndTime(e){null==e?this.removeAttribute(ch.ASSET_END_TIME):this.setAttribute(ch.ASSET_END_TIME,`${e}`)}get extraSourceParams(){return this.hasAttribute(Sy.EXTRA_SOURCE_PARAMS)?[...new URLSearchParams(this.getAttribute(Sy.EXTRA_SOURCE_PARAMS)).entries()].reduce((e,[t,i])=>(e[t]=i,e),{}):SZ}set extraSourceParams(e){null==e?this.removeAttribute(Sy.EXTRA_SOURCE_PARAMS):this.setAttribute(Sy.EXTRA_SOURCE_PARAMS,new URLSearchParams(e).toString())}get customDomain(){var e;return null!=(e=this.getAttribute(ch.CUSTOM_DOMAIN))?e:void 0}set customDomain(e){e!==this.customDomain&&(e?this.setAttribute(ch.CUSTOM_DOMAIN,e):this.removeAttribute(ch.CUSTOM_DOMAIN))}get envKey(){var e;return null!=(e=S0(this,ch.ENV_KEY))?e:void 0}set envKey(e){this.setAttribute(ch.ENV_KEY,`${e}`)}get noVolumePref(){return this.hasAttribute(Sy.NO_VOLUME_PREF)}set noVolumePref(e){e?this.setAttribute(Sy.NO_VOLUME_PREF,""):this.removeAttribute(Sy.NO_VOLUME_PREF)}get noMutedPref(){return this.hasAttribute(Sy.NO_MUTED_PREF)}set noMutedPref(e){e?this.setAttribute(Sy.NO_MUTED_PREF,""):this.removeAttribute(Sy.NO_MUTED_PREF)}get debug(){return null!=S0(this,ch.DEBUG)}set debug(e){e?this.setAttribute(ch.DEBUG,""):this.removeAttribute(ch.DEBUG)}get disableTracking(){return null!=S0(this,ch.DISABLE_TRACKING)}set disableTracking(e){this.toggleAttribute(ch.DISABLE_TRACKING,!!e)}get disableCookies(){return null!=S0(this,ch.DISABLE_COOKIES)}set disableCookies(e){e?this.setAttribute(ch.DISABLE_COOKIES,""):this.removeAttribute(ch.DISABLE_COOKIES)}get streamType(){var e,t,i;return null!=(i=null!=(t=this.getAttribute(ch.STREAM_TYPE))?t:null==(e=this.media)?void 0:e.streamType)?i:he}set streamType(e){this.setAttribute(ch.STREAM_TYPE,`${e}`)}get defaultStreamType(){var e,t,i;return null!=(i=null!=(t=this.getAttribute(Sy.DEFAULT_STREAM_TYPE))?t:null==(e=this.mediaController)?void 0:e.getAttribute(Sy.DEFAULT_STREAM_TYPE))?i:d9}set defaultStreamType(e){e?this.setAttribute(Sy.DEFAULT_STREAM_TYPE,e):this.removeAttribute(Sy.DEFAULT_STREAM_TYPE)}get targetLiveWindow(){var e,t;return this.hasAttribute(Sy.TARGET_LIVE_WINDOW)?+this.getAttribute(Sy.TARGET_LIVE_WINDOW):null!=(t=null==(e=this.media)?void 0:e.targetLiveWindow)?t:NaN}
3295set targetLiveWindow(e){e==this.targetLiveWindow||Number.isNaN(e)&&Number.isNaN(this.targetLiveWindow)||(null==e?this.removeAttribute(Sy.TARGET_LIVE_WINDOW):this.setAttribute(Sy.TARGET_LIVE_WINDOW,`${+e}`))}get liveEdgeStart(){var e;return null==(e=this.media)?void 0:e.liveEdgeStart}get startTime(){return _K(S0(this,ch.START_TIME))}set startTime(e){this.setAttribute(ch.START_TIME,`${e}`)}get initialBandwidthEstimateKbps(){return _K(S0(this,ch.INITIAL_BANDWIDTH_ESTIMATE_KBPS))}set initialBandwidthEstimateKbps(e){null==e?this.removeAttribute(ch.INITIAL_BANDWIDTH_ESTIMATE_KBPS):this.setAttribute(ch.INITIAL_BANDWIDTH_ESTIMATE_KBPS,`${e}`)}get initialEstimateSegments(){return _K(S0(this,ch.INITIAL_ESTIMATE_SEGMENTS))}set initialEstimateSegments(e){null==e?this.removeAttribute(ch.INITIAL_ESTIMATE_SEGMENTS):this.setAttribute(ch.INITIAL_ESTIMATE_SEGMENTS,`${e}`)}get minPreloadSegments(){return _K(S0(this,ch.MIN_PRELOAD_SEGMENTS))}set minPreloadSegments(e){null==e?this.removeAttribute(ch.MIN_PRELOAD_SEGMENTS):this.setAttribute(ch.MIN_PRELOAD_SEGMENTS,`${e}`)}get preferPlayback(){let e=this.getAttribute(ch.PREFER_PLAYBACK);if("mse"===e||e===ht)return e}set preferPlayback(e){e!==this.preferPlayback&&("mse"===e||e===ht?this.setAttribute(ch.PREFER_PLAYBACK,e):this.removeAttribute(ch.PREFER_PLAYBACK))}get metadata(){var e;return null==(e=this.media)?void 0:e.metadata}set metadata(e){(yA(this,SF,SB).call(this),this.media)?this.media.metadata={...SA(this),...e}:_3("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){(yA(this,SF,SB).call(this),this.media)?this.media._hlsConfig=e:_3("underlying media element missing when trying to set _hlsConfig. _hlsConfig will not be set.")}async addCuePoints(e){var t;return(yA(this,SF,SB).call(this),this.media)?null==(t=this.media)?void 0:t.addCuePoints(e):void _3("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;return(yA(this,SF,SB).call(this),this.media)?null==(t=this.media)?void 0:t.addChapters(e):void _3("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(Sy.PLAYBACK_TOKEN),t=this.getAttribute(Sy.DRM_TOKEN),i=this.getAttribute(Sy.THUMBNAIL_TOKEN),r=this.getAttribute(Sy.STORYBOARD_TOKEN);return{...yy(this,Sk),...null!=e?{playback:e}:{},...null!=t?{drm:t}:{},...null!=i?{thumbnail:i}:{},...null!=r?{storyboard:r}:{}}}set tokens(e){yT(this,Sk,null!=e?e:{})}get playbackToken(){var e;return null!=(e=this.getAttribute(Sy.PLAYBACK_TOKEN))?e:void 0}set playbackToken(e){this.setAttribute(Sy.PLAYBACK_TOKEN,`${e}`)}get drmToken(){var e;return null!=(e=this.getAttribute(Sy.DRM_TOKEN))?e:void 0}set drmToken(e){this.setAttribute(Sy.DRM_TOKEN,`${e}`)}get thumbnailToken(){var e;return null!=(e=this.getAttribute(Sy.THUMBNAIL_TOKEN))?e:void 0}set thumbnailToken(e){this.setAttribute(Sy.THUMBNAIL_TOKEN,`${e}`)}get storyboardToken(){var e;return null!=(e=this.getAttribute(Sy.STORYBOARD_TOKEN))?e:void 0}set storyboardToken(e){this.setAttribute(Sy.STORYBOARD_TOKEN,`${e}`)}addTextTrack(e,t,i,r){var a;let s=null==(a=this.media)?void 0:a.nativeEl;if(s)return hS(s,e,t,i,r)}removeTextTrack(e){var t;let i=null==(t=this.media)?void 0:t.nativeEl;if(i){let t;return void(null==(t=Array.prototype.find.call(i.querySelectorAll("track"),t=>t.track===e))||t.remove())}}get textTracks(){var e;return null==(e=this.media)?void 0:e.textTracks}get castReceiver(){var e;return null!=(e=this.getAttribute(Sy.CAST_RECEIVER))?e:void 0}set castReceiver(e){e!==this.castReceiver&&(e?this.setAttribute(Sy.CAST_RECEIVER,e):this.removeAttribute(Sy.CAST_RECEIVER))}get castCustomData(){var e;return null==(e=this.media)?void 0:e.castCustomData}set castCustomData(e){this.media?this.media.castCustomData=e:_3("underlying media element missing when trying to set castCustomData. castCustomData will not be set.")}get noTooltips(){return this.hasAttribute(Sy.NO_TOOLTIPS)}set noTooltips(e){e?this.setAttribute(Sy.NO_TOOLTIPS,""):this.removeAttribute(Sy.NO_TOOLTIPS)}get proudlyDisplayMuxBadge(){return this.hasAttribute(Sy.PROUDLY_DISPLAY_MUX_BADGE)}set proudlyDisplayMuxBadge(e){e?this.setAttribute(Sy.PROUDLY_DISPLAY_MUX_BADGE,""):this.removeAttribute(Sy.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:_3("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:_3("underlying media element missing when trying to set maxReconnectRetries")}};function S0(e,t){return e.media?e.media.getAttribute(t):e.getAttribute(t)}S_=new WeakMap,SS=new WeakMap,Sk=new WeakMap,SR=new WeakMap,SL=new WeakMap,SI=new WeakMap,Sw=new WeakMap,SD=new WeakMap,SC=new WeakMap,SM=new WeakMap,Sx=new WeakMap,SP=new WeakMap,SO=new WeakMap,SN=new WeakMap,SU=new WeakMap,SF=new WeakSet,SB=function(){var e,t,i,r;if(!yy(this,SS)){yT(this,SS,!0),yA(this,SF,SG).call(this);try{if(customElements.upgrade(this.mediaTheme),!(this.mediaTheme instanceof _$.HTMLElement))throw""}catch{_3("<media-theme> failed to upgrade!")}try{customElements.upgrade(this.media)}catch{_3("underlying media element failed to upgrade!")}
3295try{if(customElements.upgrade(this.mediaController),!(this.mediaController instanceof pA))throw""}catch{_3("<media-controller> failed to upgrade!")}yA(this,SF,SW).call(this),yA(this,SF,SK).call(this),yA(this,SF,SV).call(this),yT(this,SR,null==(t=null==(e=this.mediaController)?void 0:e.hasAttribute(fg))||t),yA(this,SF,Sq).call(this),null==(i=this.media)||i.addEventListener("streamtypechange",yy(this,Sw)),null==(r=this.media)||r.addEventListener("loadstart",yy(this,SD)),this.media&&(this.media.metadata=SA(this))}},S$=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{}},SH=function(e){Object.assign(yy(this,SN),e),yA(this,SF,SG).call(this)},SG=function(e={}){var t,i,r,a,s,n,l,o,d,h,u,c,m,f,p,g,v,E,y,b,T,A,S,k,R,L,I,w,D,C,M,x,P,O,N,U,F,B,$,H,G,W,K,V,q,j,Y,z,Q,X,Z;let J,ee,et,ei;t={...yy(this,SN),...e},J={src:!this.playbackId&&this.src,playbackId:this.playbackId,hasSrc:!!this.playbackId||!!this.src||!!this.currentSrc,poster:this.poster,storyboard:(null==(i=this.media)?void 0:i.currentSrc)&&this.storyboard,storyboardSrc:this.getAttribute(Sy.STORYBOARD_SRC),fullscreenElement:this.getAttribute(Sy.FULLSCREEN_ELEMENT),placeholder:this.getAttribute("placeholder"),themeTemplate:function(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);
3295if(a&&a instanceof HTMLTemplateElement)return a;r.startsWith("media-theme-")||(r=`media-theme-${r}`);let s=_$.customElements.get(r);if(null!=s&&s.template)return s.template}}(this),thumbnailTime:!this.tokens.thumbnail&&this.thumbnailTime,autoplay:this.autoplay,crossOrigin:this.crossOrigin,loop:this.loop,noHotKeys:this.hasAttribute(Sy.NOHOTKEYS),hotKeys:this.getAttribute(Sy.HOTKEYS),muted:this.muted,paused:this.paused,preload:this.preload,envKey:this.envKey,preferCmcd:this.preferCmcd,debug:this.debug,disableTracking:this.disableTracking,disableCookies:this.disableCookies,tokens:this.tokens,beaconCollectionDomain:this.beaconCollectionDomain,maxResolution:this.maxResolution,minResolution:this.minResolution,maxAutoResolution:this.maxAutoResolution,programStartTime:this.programStartTime,programEndTime:this.programEndTime,assetStartTime:this.assetStartTime,assetEndTime:this.assetEndTime,renditionOrder:this.renditionOrder,metadata:this.metadata,playerInitTime:this.playerInitTime,playerSoftwareName:this.playerSoftwareName,playerSoftwareVersion:this.playerSoftwareVersion,startTime:this.startTime,initialBandwidthEstimateKbps:this.initialBandwidthEstimateKbps,initialEstimateSegments:this.initialEstimateSegments,minPreloadSegments:this.minPreloadSegments,preferPlayback:this.preferPlayback,audio:this.audio,defaultStreamType:this.defaultStreamType,targetLiveWindow:this.getAttribute(ch.TARGET_LIVE_WINDOW),streamType:_Z(this.getAttribute(ch.STREAM_TYPE)),primaryColor:this.getAttribute(Sy.PRIMARY_COLOR),secondaryColor:this.getAttribute(Sy.SECONDARY_COLOR),accentColor:this.getAttribute(Sy.ACCENT_COLOR),forwardSeekOffset:this.forwardSeekOffset,backwardSeekOffset:this.backwardSeekOffset,defaultHiddenCaptions:this.defaultHiddenCaptions,defaultDuration:this.defaultDuration,defaultShowRemainingTime:this.defaultShowRemainingTime,hideDuration:(ee=null==(s=this.mediaController)?void 0:s.querySelector("media-time-display"))&&"none"===getComputedStyle(ee).getPropertyValue("--media-duration-display-display").trim(),playbackRates:this.getAttribute(Sy.PLAYBACK_RATES),customDomain:null!=(r=this.getAttribute(ch.CUSTOM_DOMAIN))?r:void 0,title:this.getAttribute(Sy.TITLE),videoTitle:null!=(a=this.getAttribute(Sy.VIDEO_TITLE))?a:this.getAttribute(Sy.TITLE),novolumepref:this.hasAttribute(Sy.NO_VOLUME_PREF),nomutedpref:this.hasAttribute(Sy.NO_MUTED_PREF),proudlyDisplayMuxBadge:this.hasAttribute(Sy.PROUDLY_DISPLAY_MUX_BADGE),castReceiver:this.castReceiver,disablePseudoEnded:this.hasAttribute(Sy.DISABLE_PSEUDO_ENDED),maxReconnectRetries:this.maxReconnectRetries,capRenditionToPlayerSize:this.capRenditionToPlayerSize,...t,extraSourceParams:this.extraSourceParams},n=Sd`
3296  <style>
3297    ${(e=>{let{tokens:t}=e;return t.drm?":host(:not([cast-receiver])) { --_cast-button-drm-display: none; }":""})(J)}
3298    ${St}
3299  </style>
3300  ${o=J,Sd`
3301  <media-theme
3302    template="${o.themeTemplate||!1}"
3303    defaultstreamtype="${null!=(d=o.defaultStreamType)&&d}"
3304    hotkeys="${et=o.hotKeys?`${o.hotKeys}`:"","live"===_Z(o.streamType)&&(et+=" noarrowleft noarrowright"),et||!1}"
3305    nohotkeys="${o.noHotKeys||!o.hasSrc||!1}"
3306    noautoseektolive="${!!(null!=(h=o.streamType)&&h.includes(d7))&&0!==o.targetLiveWindow}"
3307    novolumepref="${o.novolumepref||!1}"
3308    nomutedpref="${o.nomutedpref||!1}"
3309    disabled="${!o.hasSrc||o.isDialogOpen}"
3310    audio="${null!=(u=o.audio)&&u}"
3311    style="${null!=(Z={"--media-primary-color":o.primaryColor,"--media-secondary-color":o.secondaryColor,"--media-accent-color":o.accentColor},ei="",Object.entries(Z).forEach(([e,t])=>{null!=t&&(ei+=`${_G(e)}: ${t}; `)}),c=ei?ei.trim():void 0)&&c}"
3312    defaultsubtitles="${!o.defaultHiddenCaptions}"
3313    forwardseekoffset="${null!=(m=o.forwardSeekOffset)&&m}"
3314    backwardseekoffset="${null!=(f=o.backwardSeekOffset)&&f}"
3315    playbackrates="${null!=(p=o.playbackRates)&&p}"
3316    defaultshowremainingtime="${null!=(g=o.defaultShowRemainingTime)&&g}"
3317    defaultduration="${null!=(v=o.defaultDuration)&&v}"
3318    hideduration="${null!=(E=o.hideDuration)&&E}"
3319    title="${null!=(y=o.title)&&y}"
3320    videotitle="${null!=(b=o.videoTitle)&&b}"
3321    proudlydisplaymuxbadge="${null!=(T=o.proudlyDisplayMuxBadge)&&T}"
3322    exportparts="${Sh}"
3323  >
3324    <mux-video
3325      slot="media"
3326      inert="${null!=(A=o.noHotKeys)&&A}"
3327      target-live-window="${null!=(S=o.targetLiveWindow)&&S}"
3328      stream-type="${null!=(k=_Z(o.streamType))&&k}"
3329      crossorigin="${null!=(R=o.crossOrigin)?R:""}"
3330      playsinline
3331      autoplay="${null!=(L=o.autoplay)&&L}"
3332      muted="${null!=(I=o.muted)&&I}"
3333      loop="${null!=(w=o.loop)&&w}"
3334      preload="${null!=(D=o.preload)&&D}"
3335      debug="${null!=(C=o.debug)&&C}"
3336      prefer-cmcd="${null!=(M=o.preferCmcd)&&M}"
3337      disable-tracking="${null!=(x=o.disableTracking)&&x}"
3338      disable-cookies="${null!=(P=o.disableCookies)&&P}"
3339      prefer-playback="${null!=(O=o.preferPlayback)&&O}"
3340      start-time="${null!=o.startTime&&o.startTime}"
3341      initial-bandwidth-estimate-kbps="${null!=o.initialBandwidthEstimateKbps&&o.initialBandwidthEstimateKbps}"
3342      initial-estimate-segments="${null!=o.initialEstimateSegments&&o.initialEstimateSegments}"
3343      min-preload-segments="${null!=o.minPreloadSegments&&o.minPreloadSegments}"
3344      beacon-collection-domain="${null!=(N=o.beaconCollectionDomain)&&N}"
3345      player-init-time="${null!=(U=o.playerInitTime)&&U}"
3346      player-software-name="${null!=(F=o.playerSoftwareName)&&F}"
3347      player-software-version="${null!=(B=o.playerSoftwareVersion)&&B}"
3348      env-key="${null!=($=o.envKey)&&$}"
3349      custom-domain="${null!=(H=o.customDomain)&&H}"
3350      src="${o.src?o.src:!!o.playbackId&&up(o)}"
3351      cast-src="${o.src?o.src:!!o.playbackId&&up(o)}"
3352      cast-receiver="${null!=(G=o.castReceiver)&&G}"
3353      drm-token="${null!=(K=null==(W=o.tokens)?void 0:W.drm)&&K}"
3354      playback-token="${null!=(q=null==(V=o.tokens)?void 0:V.playback)&&q}"
3355      exportparts="video"
3356      disable-pseudo-ended="${null!=(j=o.disablePseudoEnded)&&j}"
3357      max-reconnect-retries="${null!=(Y=o.maxReconnectRetries)&&Y}"
3358      max-auto-resolution="${null!=(z=o.maxAutoResolution)&&z}"
3359      cap-rendition-to-player-size="${null!=(Q=o.capRenditionToPlayerSize)&&Q}"
3360    >
3361      ${o.storyboard?Sd`<track label="thumbnails" default kind="metadata" src="${o.storyboard}" />`:Sd``}
3362      <slot></slot>
3363    </mux-video>
3364    <slot name="poster" slot="poster">
3365      <media-poster-image
3366        part="poster"
3367        exportparts="poster, img"
3368        src="${!!o.poster&&o.poster}"
3369        placeholdersrc="${null!=(X=o.placeholder)&&X}"
3370      ></media-poster-image>
3371    </slot>
3372  </media-theme>
3373`}
3374`,l=this.shadowRoot,n.renderInto(l)},SW=function(){let e=e=>{var t,i;if(!(null!=e&&e.startsWith("theme-")))return;let r=e.replace(/^theme-/,"");if(Sb.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)};yT(this,SI,new MutationObserver(t=>{for(let{attributeName:i}of t)e(i)})),yy(this,SI).observe(this,{attributes:!0}),this.getAttributeNames().forEach(e)},SK=function(){var e,t;this.addEventListener("error",yy(this,SU)),this.addEventListener("click",yy(this,SM)),null==(e=this.mediaTheme)||e.addEventListener("close",yy(this,Sx)),null==(t=this.mediaTheme)||t.addEventListener("focusin",yy(this,SP)),this.media&&(this.media.errorTranslator=(e={})=>{var t,i,r;if(!((null==(t=this.media)?void 0:t.error)instanceof d5))return e;let a=Sc(null==(i=this.media)?void 0:i.error,!1);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}})},SV=function(){var e,t,i,r;null==(t=null==(e=this.media)?void 0:e.textTracks)||t.addEventListener("addtrack",yy(this,SC)),null==(r=null==(i=this.media)?void 0:i.textTracks)||r.addEventListener("removetrack",yy(this,SC))},Sq=function(){var e,t;if(!/Firefox/i.test(navigator.userAgent))return;let i,r=new WeakMap,a=()=>this.streamType===d7&&!this.secondaryColor&&this.offsetWidth>=800,s=(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(`
3375`).length,a=-3;this.streamType===d7&&(a=-2);let s=a-t;if(e.line===s&&!i)return;r.has(e)||r.set(e,e.line),e.line=s}else setTimeout(()=>{e.line=r.get(e)||"auto"},500)})},n=()=>{var e,t;s(i,null!=(t=null==(e=this.mediaController)?void 0:e.hasAttribute(fg))&&t)},l=()=>{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",n)),null==(i=r)||i.addEventListener("cuechange",n),s(i,yy(this,SR))};l(),null==(e=this.textTracks)||e.addEventListener("change",l),null==(t=this.textTracks)||t.addEventListener("addtrack",l);let o=()=>{var e,t;let r=null==(t=null==(e=this.mediaController)?void 0:e.hasAttribute(fg))||t;yy(this,SR)!==r&&(yT(this,SR,r),s(i,yy(this,SR)))};this.addEventListener("userinactivechange",o),yT(this,SO,()=>{var e,t;null==i||i.removeEventListener("cuechange",n),null==(e=this.textTracks)||e.removeEventListener("change",l),null==(t=this.textTracks)||t.removeEventListener("addtrack",l),this.removeEventListener("userinactivechange",o)})};var S1=e=>{throw TypeError(e)},S2=(e,t,i)=>t.has(e)||S1("Cannot "+i),S3=class{addEventListener(){}removeEventListener(){}dispatchEvent(e){return!0}};"u"<typeof DocumentFragment&&(globalThis.DocumentFragment=class extends S3{});var S4,S5=class extends S3{},S8=class{constructor(e,t={}){((e,t,i)=>t.has(e)?S1("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,i))(this,S4),((e,t,i,r)=>(S2(e,t,"write to private field"),r?r.call(e,i):t.set(e,i)))(this,S4,null==t?void 0:t.detail)}get detail(){let e,t;return S2(this,e=S4,"read from private field"),t?t.call(this):e.get(this)}initCustomEvent(){}};S4=new WeakMap;var S6={document:{createElement:function(e,t){return new S5}},DocumentFragment,customElements:{get(e){},define(e,t,i){},getName:e=>null,upgrade(e){},whenDefined:e=>Promise.resolve(S5)},CustomEvent:S8,EventTarget:S3,HTMLElement:S5,HTMLVideoElement:class extends S3{}},S9="u"<typeof window||void 0===globalThis.customElements,S7=S9?S6:globalThis;S9&&S6.document,S7.customElements.get("mux-player")||(S7.customElements.define("mux-player",SJ),S7.MuxPlayerElement=SJ);var ke=parseInt(u.default.version)>
3375=19,kt={className:"class",classname:"class",htmlFor:"for",crossOrigin:"crossorigin",viewBox:"viewBox",playsInline:"playsinline",autoPlay:"autoplay",playbackRate:"playbackrate"};function ki(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}var kr=Object.prototype.hasOwnProperty,ka=(e,t,i)=>!((e,t)=>{if(Object.is(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;if(Array.isArray(e))return!!Array.isArray(t)&&e.length===t.length&&e.some((e,i)=>t[i]===e);let i=Object.keys(e),r=Object.keys(t);if(i.length!==r.length)return!1;for(let r=0;r<i.length;r++)if(!kr.call(t,i[r])||!Object.is(e[i[r]],t[i[r]]))return!1;return!0})(t,e[i]),ks=(e,t,i)=>{e[i]=t},kn=(e,t,i,r=ks,a=ka)=>(0,u.useEffect)(()=>{let s=null==i?void 0:i.current;s&&a(s,t,e)&&r(s,t,e)},[null==i?void 0:i.current,t]),kl=(()=>{try{return"3.13.4"}catch{}return"UNKNOWN"})(),ko=(e,t,i)=>(0,u.useEffect)(()=>{let r=null==t?void 0:t.current;if(r&&i)return r.addEventListener(e,i),()=>{r.removeEventListener(e,i)}},[null==t?void 0:t.current,i,e]),kd=u.default.forwardRef(({children:e,...t},i)=>u.default.createElement("mux-player",{suppressHydrationWarning:!0,...((e={})=>{let{ref:t,...i}=e;return Object.entries(i).reduce((e,[t,i])=>{let r=((e,t)=>{if(!(!ke&&"boolean"==typeof t&&!t)){let i,r;if(i=e,null!=(r=kt)&&i in r)return kt[e];if(void 0!==t)return/[A-Z]/.test(e)?e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`):e}})(t,i);if(!r)return e;let a=ke||"boolean"!=typeof i?i:"";return e[r]=a,e},{})})(t),ref:i},e)),kh="mux-player-react",ku=u.default.forwardRef((e,t)=>{var i;let r=(0,u.useRef)(null),a=function(...e){return u.useCallback(function(...e){return t=>{let i=!1,r=e.map(e=>{let r=ki(e,t);return i||"function"!=typeof r||(i=!0),r});if(i)return()=>{for(let t=0;t<r.length;t++){let i=r[t];"function"==typeof i?i():ki(e[t],null)}}}}(...e),e)}(r,t),[s]=((e,t)=>{var i;let{onAbort:r,onCanPlay:a,onCanPlayThrough:s,onEmptied:n,onLoadStart:l,onLoadedData:o,onLoadedMetadata:d,onProgress:h,onDurationChange:u,onVolumeChange:c,onRateChange:m,onResize:f,onWaiting:p,onPlay:g,onPlaying:v,onTimeUpdate:E,onPause:y,onSeeking:b,onSeeked:T,onStalled:A,onSuspend:S,onEnded:k,onError:R,onCuePointChange:L,onChapterChange:I,metadata:w,tokens:D,paused:C,playbackId:M,playbackRates:x,currentTime:P,themeProps:O,extraSourceParams:N,castCustomData:U,_hlsConfig:F,...B}=t;return kn("tokens",D,e),kn("playbackId",M,e),kn("playbackRates",x,e),kn("metadata",w,e),kn("disableCookies",null!=(i=t.disableCookies)&&i,e),kn("extraSourceParams",N,e),kn("_hlsConfig",F,e),kn("themeProps",O,e),kn("castCustomData",U,e),kn("paused",C,e,(e,t)=>{null!=t&&(t?e.pause():e.play())},(e,t,i)=>(!e.hasAttribute("autoplay")||!!e.hasPlayed)&&ka(e,t,i)),kn("currentTime",P,e,(e,t)=>{null!=t&&(e.currentTime=t)}),ko("abort",e,r),ko("canplay",e,a),ko("canplaythrough",e,s),ko("emptied",e,n),ko("loadstart",e,l),ko("loadeddata",e,o),ko("loadedmetadata",e,d),ko("progress",e,h),ko("durationchange",e,u),ko("volumechange",e,c),ko("ratechange",e,m),ko("resize",e,f),ko("waiting",e,p),ko("play",e,g),ko("playing",e,v),ko("timeupdate",e,E),ko("pause",e,y),ko("seeking",e,b),ko("seeked",e,T),ko("stalled",e,A),ko("suspend",e,S),ko("ended",e,k),ko("error",e,R),ko("cuepointchange",e,L),ko("chapterchange",e,I),[B]})(r,e),[n]=(0,u.useState)(null!=(i=e.playerInitTime)?i:um());return u.default.createElement(kd,{ref:a,defaultHiddenCaptions:e.defaultHiddenCaptions,playerSoftwareName:kh,playerSoftwareVersion:kl,playerInitTime:n,...s})});e.s(["default",0,ku,"playerSoftwareName",0,kh,"playerSoftwareVersion",0,kl],1646),e.i(1646),e.s(["MaxResolution",0,{upTo720p:"720p",upTo1080p:"1080p",upTo1440p:"1440p",upTo2160p:"2160p"},"MediaError",0,d5,"MinResolution",0,{noLessThan480p:"480p",noLessThan540p:"540p",noLessThan720p:"720p",noLessThan1080p:"1080p",noLessThan1440p:"1440p",noLessThan2160p:"2160p"},"RenditionOrder",0,{DESCENDING:"desc"},"default",0,ku,"generatePlayerInitTime",0,um,"playerSoftwareName",0,kh,"playerSoftwareVersion",0,kl],84141)}]);

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