define(["exports"],(function(t){"use strict";function e(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var r,i,n,a,s,o={exports:{}};r=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,i=/^(?=([^\/?#]*))\1([^]*)$/,n=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,o.exports=s={buildAbsoluteURL:function(t,e,r){if(r=r||{},t=t.trim(),!(e=e.trim())){if(!r.alwaysNormalize)return t;var n=s.parseURL(t);if(!n)throw new Error("Error trying to parse base URL.");return n.path=s.normalizePath(n.path),s.buildURLFromParts(n)}var a=s.parseURL(e);if(!a)throw new Error("Error trying to parse relative URL.");if(a.scheme)return r.alwaysNormalize?(a.path=s.normalizePath(a.path),s.buildURLFromParts(a)):e;var o=s.parseURL(t);if(!o)throw new Error("Error trying to parse base URL.");if(!o.netLoc&&o.path&&"/"!==o.path[0]){var l=i.exec(o.path);o.netLoc=l[1],o.path=l[2]}o.netLoc&&!o.path&&(o.path="/");var u={scheme:o.scheme,netLoc:a.netLoc,path:null,params:a.params,query:a.query,fragment:a.fragment};if(!a.netLoc&&(u.netLoc=o.netLoc,"/"!==a.path[0]))if(a.path){var h=o.path,d=h.substring(0,h.lastIndexOf("/")+1)+a.path;u.path=s.normalizePath(d)}else u.path=o.path,a.params||(u.params=o.params,a.query||(u.query=o.query));return null===u.path&&(u.path=r.alwaysNormalize?s.normalizePath(a.path):a.path),s.buildURLFromParts(u)},parseURL:function(t){var e=r.exec(t);return e?{scheme:e[1]||"",netLoc:e[2]||"",path:e[3]||"",params:e[4]||"",query:e[5]||"",fragment:e[6]||""}:null},normalizePath:function(t){for(t=t.split("").reverse().join("").replace(n,"");t.length!==(t=t.replace(a,"")).length;);return t.split("").reverse().join("")},buildURLFromParts:function(t){return t.scheme+t.netLoc+t.path+t.params+t.query+t.fragment}};var l=o.exports;function u(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,i)}return r}function h(t){for(var e=arguments,r=1;r"):m}function S(t,e){if(self.console&&!0===t||"object"==typeof t){!function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];e.forEach((function(e){T[e]=t[e]?t[e].bind(t):E(e)}))}(t,"debug","log","info","warn","error");try{T.log('Debug logs enabled for "'+e+'" in hls.js version 1.4.2')}catch(t){T=y}}else T=y}var L=T,b=/^(\d+)x(\d+)$/,A=/(.+?)=(".*?"|.*?)(?:,|$)/g,R=function t(e){for(var r in"string"==typeof e&&(e=t.parseAttrList(e)),e)e.hasOwnProperty(r)&&("X-"===r.substring(0,2)&&(this.clientAttrs=this.clientAttrs||[],this.clientAttrs.push(r)),this[r]=e[r])};function k(t){return"SCTE35-OUT"===t||"SCTE35-IN"===t}R.prototype.decimalInteger=function(t){var e=parseInt(this[t],10);return e>Number.MAX_SAFE_INTEGER?1/0:e},R.prototype.hexadecimalInteger=function(t){if(this[t]){var e=(this[t]||"0x").slice(2);e=(1&e.length?"0":"")+e;for(var r=new Uint8Array(e.length/2),i=0;iNumber.MAX_SAFE_INTEGER?1/0:e},R.prototype.decimalFloatingPoint=function(t){return parseFloat(this[t])},R.prototype.optionalFloat=function(t,e){var r=this[t];return r?parseFloat(r):e},R.prototype.enumeratedString=function(t){return this[t]},R.prototype.bool=function(t){return"YES"===this[t]},R.prototype.decimalResolution=function(t){var e=b.exec(this[t]);if(null!==e)return{width:parseInt(e[1],10),height:parseInt(e[2],10)}},R.parseAttrList=function(t){var e,r={};for(A.lastIndex=0;null!==(e=A.exec(t));){var i=e[2];0===i.indexOf('"')&&i.lastIndexOf('"')===i.length-1&&(i=i.slice(1,-1)),r[e[1].trim()]=i}return r};var D=function(t,e){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,e){var r=e.attr;for(var i in r)if(Object.prototype.hasOwnProperty.call(t,i)&&t[i]!==r[i]){L.warn('DATERANGE tag attribute: "'+i+'" does not match for tags with ID: "'+t.ID+'"'),this._badValueForSameId=i;break}t=c(new R({}),r,t)}if(this.attr=t,this._startDate=new Date(t["START-DATE"]),"END-DATE"in this.attr){var n=new Date(this.attr["END-DATE"]);f(n.getTime())&&(this._endDate=n)}},I={id:{configurable:!0},class:{configurable:!0},startDate:{configurable:!0},endDate:{configurable:!0},duration:{configurable:!0},plannedDuration:{configurable:!0},endOnNext:{configurable:!0},isValid:{configurable:!0}};I.id.get=function(){return this.attr.ID},I.class.get=function(){return this.attr.CLASS},I.startDate.get=function(){return this._startDate},I.endDate.get=function(){if(this._endDate)return this._endDate;var t=this.duration;return null!==t?new Date(this._startDate.getTime()+1e3*t):null},I.duration.get=function(){if("DURATION"in this.attr){var t=this.attr.decimalFloatingPoint("DURATION");if(f(t))return t}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null},I.plannedDuration.get=function(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null},I.endOnNext.get=function(){return this.attr.bool("END-ON-NEXT")},I.isValid.get=function(){return!!this.id&&!this._badValueForSameId&&f(this.startDate.getTime())&&(null===this.duration||this.duration>=0)&&(!this.endOnNext||!!this.class)},Object.defineProperties(D.prototype,I);var w=function(){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}},_="audio",C="video",P="audiovideo",x=function(t){var e;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=((e={})[_]=null,e[C]=null,e[P]=null,e),this.baseurl=t},F={byteRange:{configurable:!0},byteRangeStartOffset:{configurable:!0},byteRangeEndOffset:{configurable:!0},url:{configurable:!0}};x.prototype.setByteRange=function(t,e){var r=t.split("@",2),i=[];1===r.length?i[0]=e?e.byteRangeEndOffset:0:i[0]=parseInt(r[1]),i[1]=parseInt(r[0])+i[0],this._byteRange=i},F.byteRange.get=function(){return this._byteRange?this._byteRange:[]},F.byteRangeStartOffset.get=function(){return this.byteRange[0]},F.byteRangeEndOffset.get=function(){return this.byteRange[1]},F.url.get=function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=l.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},F.url.set=function(t){this._url=t},Object.defineProperties(x.prototype,F);var O=function(t){function e(e,r){t.call(this,r),this._decryptdata=null,this.rawProgramDateTime=null,this.programDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.stats=new w,this.urlId=0,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.type=e}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={decryptdata:{configurable:!0},end:{configurable:!0},endProgramDateTime:{configurable:!0},encrypted:{configurable:!0}};return r.decryptdata.get=function(){if(!this.levelkeys&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){var t=this.levelkeys.identity;if(t)this._decryptdata=t.getDecryptData(this.sn);else{var e=Object.keys(this.levelkeys);if(1===e.length)return this._decryptdata=this.levelkeys[e[0]].getDecryptData(this.sn)}}return this._decryptdata},r.end.get=function(){return this.start+this.duration},r.endProgramDateTime.get=function(){if(null===this.programDateTime)return null;if(!f(this.programDateTime))return null;var t=f(this.duration)?this.duration:0;return this.programDateTime+1e3*t},r.encrypted.get=function(){var t;if(null!=(t=this._decryptdata)&&t.encrypted)return!0;if(this.levelkeys){var e=Object.keys(this.levelkeys),r=e.length;if(r>1||1===r&&this.levelkeys[e[0]].encrypted)return!0}return!1},e.prototype.setKeyFormat=function(t){if(this.levelkeys){var e=this.levelkeys[t];e&&!this._decryptdata&&(this._decryptdata=e.getDecryptData(this.sn))}},e.prototype.abortRequests=function(){var t,e;null==(t=this.loader)||t.abort(),null==(e=this.keyLoader)||e.abort()},e.prototype.setElementaryStreamInfo=function(t,e,r,i,n,a){void 0===a&&(a=!1);var s=this.elementaryStreams,o=s[t];o?(o.startPTS=Math.min(o.startPTS,e),o.endPTS=Math.max(o.endPTS,r),o.startDTS=Math.min(o.startDTS,i),o.endDTS=Math.max(o.endDTS,n)):s[t]={startPTS:e,endPTS:r,startDTS:i,endDTS:n,partial:a}},e.prototype.clearElementaryStreamInfo=function(){var t=this.elementaryStreams;t[_]=null,t[C]=null,t[P]=null},Object.defineProperties(e.prototype,r),e}(x),M=function(t){function e(e,r,i,n,a){t.call(this,i),this.fragOffset=0,this.duration=0,this.gap=!1,this.independent=!1,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.stats=new w,this.duration=e.decimalFloatingPoint("DURATION"),this.gap=e.bool("GAP"),this.independent=e.bool("INDEPENDENT"),this.relurl=e.enumeratedString("URI"),this.fragment=r,this.index=n;var s=e.enumeratedString("BYTERANGE");s&&this.setByteRange(s,a),a&&(this.fragOffset=a.fragOffset+a.duration)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={start:{configurable:!0},end:{configurable:!0},loaded:{configurable:!0}};return r.start.get=function(){return this.fragment.start+this.fragOffset},r.end.get=function(){return this.start+this.duration},r.loaded.get=function(){var t=this.elementaryStreams;return!!(t.audio||t.video||t.audiovideo)},Object.defineProperties(e.prototype,r),e}(x),N=function(t){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=t},U={hasProgramDateTime:{configurable:!0},levelTargetDuration:{configurable:!0},drift:{configurable:!0},edge:{configurable:!0},partEnd:{configurable:!0},fragmentEnd:{configurable:!0},age:{configurable:!0},lastPartIndex:{configurable:!0},lastPartSn:{configurable:!0}};function B(t){return Uint8Array.from(atob(t),(function(t){return t.charCodeAt(0)}))}function G(t){var e,r,i=t.split(":"),n=null;if("data"===i[0]&&2===i.length){var a=i[1].split(";"),s=a[a.length-1].split(",");if(2===s.length){var o="base64"===s[0],l=s[1];o?(a.splice(-1,1),n=B(l)):(e=K(l).subarray(0,16),(r=new Uint8Array(16)).set(e,16-e.length),n=r)}}return n}function K(t){return Uint8Array.from(unescape(encodeURIComponent(t)),(function(t){return t.charCodeAt(0)}))}N.prototype.reloaded=function(t){if(!t)return this.advanced=!0,void(this.updated=!0);var e=this.lastPartSn-t.lastPartSn,r=this.lastPartIndex-t.lastPartIndex;this.updated=this.endSN!==t.endSN||!!r||!!e,this.advanced=this.endSN>t.endSN||e>0||0===e&&r>0,this.updated||this.advanced?this.misses=Math.floor(.6*t.misses):this.misses=t.misses+1,this.availabilityDelay=t.availabilityDelay},U.hasProgramDateTime.get=function(){return!!this.fragments.length&&f(this.fragments[this.fragments.length-1].programDateTime)},U.levelTargetDuration.get=function(){return this.averagetargetduration||this.targetduration||10},U.drift.get=function(){var t=this.driftEndTime-this.driftStartTime;return t>0?1e3*(this.driftEnd-this.driftStart)/t:1},U.edge.get=function(){return this.partEnd||this.fragmentEnd},U.partEnd.get=function(){var t;return null!=(t=this.partList)&&t.length?this.partList[this.partList.length-1].end:this.fragmentEnd},U.fragmentEnd.get=function(){var t;return null!=(t=this.fragments)&&t.length?this.fragments[this.fragments.length-1].end:0},U.age.get=function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0},U.lastPartIndex.get=function(){var t;return null!=(t=this.partList)&&t.length?this.partList[this.partList.length-1].index:-1},U.lastPartSn.get=function(){var t;return null!=(t=this.partList)&&t.length?this.partList[this.partList.length-1].fragment.sn:this.endSN},Object.defineProperties(N.prototype,U);var H={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},V="org.w3.clearkey",Y="com.apple.streamingkeydelivery",W="com.microsoft.playready",j="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function q(t){switch(t){case Y:return H.FAIRPLAY;case W:return H.PLAYREADY;case j:return H.WIDEVINE;case V:return H.CLEARKEY}}var X="edef8ba979d64acea3c827dcd51d21ed";function z(t){switch(t){case H.FAIRPLAY:return Y;case H.PLAYREADY:return W;case H.WIDEVINE:return j;case H.CLEARKEY:return V}}function Q(t){var e=t.drmSystems,r=t.widevineLicenseUrl,i=e?[H.FAIRPLAY,H.WIDEVINE,H.PLAYREADY,H.CLEARKEY].filter((function(t){return!!e[t]})):[];return!i[H.WIDEVINE]&&r&&i.push(H.WIDEVINE),i}var $="undefined"!=typeof self&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;function J(t,e,r){return Uint8Array.prototype.slice?t.slice(e,r):new Uint8Array(Array.prototype.slice.call(t,e,r))}var Z,tt=function(t,e){return e+10<=t.length&&73===t[e]&&68===t[e+1]&&51===t[e+2]&&t[e+3]<255&&t[e+4]<255&&t[e+6]<128&&t[e+7]<128&&t[e+8]<128&&t[e+9]<128},et=function(t,e){return e+10<=t.length&&51===t[e]&&68===t[e+1]&&73===t[e+2]&&t[e+3]<255&&t[e+4]<255&&t[e+6]<128&&t[e+7]<128&&t[e+8]<128&&t[e+9]<128},rt=function(t,e){for(var r=e,i=0;tt(t,e);){i+=10,i+=it(t,e+6),et(t,e+10)&&(i+=10),e+=i}if(i>0)return t.subarray(r,r+i)},it=function(t,e){var r=0;return r=(127&t[e])<<21,r|=(127&t[e+1])<<14,r|=(127&t[e+2])<<7,r|=127&t[e+3]},nt=function(t,e){return tt(t,e)&&it(t,e+6)+10<=t.length-e},at=function(t){return t&&"PRIV"===t.key&&"com.apple.streaming.transportStreamTimestamp"===t.info},st=function(t){var e=String.fromCharCode(t[0],t[1],t[2],t[3]),r=it(t,4);return{type:e,size:r,data:t.subarray(10,10+r)}},ot=function(t){for(var e=0,r=[];tt(t,e);){for(var i=it(t,e+6),n=(e+=10)+i;e+8>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:u+=String.fromCharCode(a);break;case 12:case 13:s=t[h++],u+=String.fromCharCode((31&a)<<6|63&s);break;case 14:s=t[h++],o=t[h++],u+=String.fromCharCode((15&a)<<12|(63&s)<<6|(63&o)<<0)}}return u};function pt(){return Z||void 0===self.TextDecoder||(Z=new self.TextDecoder("utf-8")),Z}var gt=function(t){for(var e="",r=0;r>24,t[e+1]=r>>16&255,t[e+2]=r>>8&255,t[e+3]=255&r}function At(t,e){var r=[];if(!e.length)return r;for(var i=t.byteLength,n=0;n1?n+a:i;if(Tt(t.subarray(n+4,n+8))===e[0])if(1===e.length)r.push(t.subarray(n+8,s));else{var o=At(t.subarray(n+8,s),e.slice(1));o.length&&mt.apply(r,o)}n=s}return r}function Rt(t){var e=[],r=t[0],i=8,n=St(t,i);i+=4;i+=0===r?8:16,i+=2;var a=t.length+0,s=Et(t,i);i+=2;for(var o=0;o>>31)return L.warn("SIDX has hierarchical references (not supported)"),null;var d=St(t,l);l+=4,e.push({referenceSize:h,subsegmentDuration:d,info:{duration:d/n,start:a,end:a+h-1}}),a+=h,i=l+=4}return{earliestPresentationTime:0,timescale:n,version:r,referencesCount:s,references:e}}function kt(t){for(var e=[],r=At(t,["moov","trak"]),i=0;i>1&63;return 39===r||40===r}return 6===(31&e)}function Pt(t,e,r,i){var n=xt(t),a=0;a+=e;for(var s=0,o=0,l=!1,u=0;a=n.length)break;s+=u=n[a++]}while(255===u);o=0;do{if(a>=n.length)break;o+=u=n[a++]}while(255===u);var h=n.length-a;if(!l&&4===s&&a16){for(var T=[],E=0;E<16;E++){var S=n[a++].toString(16);T.push(1==S.length?"0"+S:S),3!==E&&5!==E&&7!==E&&9!==E||T.push("-")}for(var L=o-16,b=new Uint8Array(L),A=0;Ah)break}}function xt(t){for(var e=t.byteLength,r=[],i=1;i0?(a=new Uint8Array(4),e.length>0&&new DataView(a.buffer).setUint32(0,e.length,!1)):a=new Uint8Array;var l=new Uint8Array(4);return r&&r.byteLength>0&&new DataView(l.buffer).setUint32(0,r.byteLength,!1),function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];for(var i=e.length,n=8,a=i;a--;)n+=e[a].byteLength;var s=new Uint8Array(n);for(s[0]=n>>24&255,s[1]=n>>16&255,s[2]=n>>8&255,s[3]=255&n,s.set(t,4),a=0,n=8;a>8*(15-r)&255;return e}(t);return new Mt(this.method,this.uri,"identity",this.keyFormatVersions,e)}var r=G(this.uri);if(r)switch(this.keyFormat){case j:this.pssh=r,r.length>=22&&(this.keyId=r.subarray(r.length-22,r.length-6));break;case W:var i=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=Ft(i,null,r);var n=new Uint16Array(r.buffer,r.byteOffset,r.byteLength/2),a=String.fromCharCode.apply(null,Array.from(n)),s=a.substring(a.indexOf("<"),a.length),o=(new DOMParser).parseFromString(s,"text/xml").getElementsByTagName("KID")[0];if(o){var l=o.childNodes[0]?o.childNodes[0].nodeValue:o.getAttribute("VALUE");if(l){var u=B(l).subarray(0,16);!function(t){var e=function(t,e,r){var i=t[e];t[e]=t[r],t[r]=i};e(t,0,3),e(t,1,2),e(t,4,5),e(t,6,7)}(u),this.keyId=u}}break;default:var h=r.subarray(0,16);if(16!==h.length){var d=new Uint8Array(16);d.set(h,16-h.length),h=d}this.keyId=h}if(!this.keyId||16!==this.keyId.byteLength){var c=Ot[this.uri];if(!c){var f=Object.keys(Ot).length%Number.MAX_SAFE_INTEGER;c=new Uint8Array(16),new DataView(c.buffer,12,4).setUint32(0,f),Ot[this.uri]=c}this.keyId=c}return this};var Nt=/\{\$([a-zA-Z0-9-_]+)\}/g;function Ut(t){return Nt.test(t)}function Bt(t,e,r){if(null!==t.variableList||t.hasVariableRefs)for(var i=r.length;i--;){var n=r[i],a=e[n];a&&(e[n]=Gt(t,a))}}function Gt(t,e){if(null!==t.variableList||t.hasVariableRefs){var r=t.variableList;return e.replace(Nt,(function(e){var i=e.substring(2,e.length-1),n=null==r?void 0:r[i];return void 0===n?(t.playlistParsingError||(t.playlistParsingError=new Error('Missing preceding EXT-X-DEFINE tag for Variable Reference: "'+i+'"')),e):n}))}return e}function Kt(t,e,r){var i,n,a=t.variableList;if(a||(t.variableList=a={}),"QUERYPARAM"in e){i=e.QUERYPARAM;try{var s=new self.URL(r).searchParams;if(!s.has(i))throw new Error('"'+i+'" does not match any query parameter in URI: "'+r+'"');n=s.get(i)}catch(e){t.playlistParsingError||(t.playlistParsingError=new Error("EXT-X-DEFINE QUERYPARAM: "+e.message))}}else i=e.NAME,n=e.VALUE;i in a?t.playlistParsingError||(t.playlistParsingError=new Error('EXT-X-DEFINE duplicate Variable Name declarations: "'+i+'"')):a[i]=n||""}function Ht(t,e,r){var i=e.IMPORT;if(r&&i in r){var n=t.variableList;n||(t.variableList=n={}),n[i]=r[i]}else t.playlistParsingError||(t.playlistParsingError=new Error('EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "'+i+'"'))}function Vt(){if("undefined"!=typeof self)return self.MediaSource||self.WebKitMediaSource}var Yt={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dva1:!0,dvav:!0,dvh1:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}},Wt=Vt();function jt(t,e){var r;return null!=(r=null==Wt?void 0:Wt.isTypeSupported((e||"video")+'/mp4;codecs="'+t+'"'))&&r}var qt=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,Xt=/#EXT-X-MEDIA:(.*)/g,zt=/^#EXT(?:INF|-X-TARGETDURATION):/m,Qt=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),$t=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),Jt=function(){};function Zt(t,e,r){var i,n,a=new R(t);Bt(r,a,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);var s=null!=(i=a.METHOD)?i:"",o=a.URI,l=a.hexadecimalInteger("IV"),u=a.KEYFORMATVERSIONS,h=null!=(n=a.KEYFORMAT)?n:"identity";o&&a.IV&&!l&&L.error("Invalid IV: "+a.IV);var d=o?Jt.resolve(o,e):"",c=(u||"1").split("/").map(Number).filter(Number.isFinite);return new Mt(s,d,h,c,l)}function te(t){var e=new R(t).decimalFloatingPoint("TIME-OFFSET");return f(e)?e:null}function ee(t,e){["video","audio","text"].forEach((function(r){var i=t.filter((function(t){return function(t,e){var r=Yt[e];return!!r&&!0===r[t.slice(0,4)]}(t,r)}));if(i.length){var n=i.filter((function(t){return 0===t.lastIndexOf("avc1",0)||0===t.lastIndexOf("mp4a",0)}));e[r+"Codec"]=n.length>0?n[0]:i[0],t=t.filter((function(t){return-1===i.indexOf(t)}))}})),e.unknownCodecs=t}function re(t,e,r){var i=e[r];i&&(t[r]=i)}function ie(t,e){t.rawProgramDateTime?t.programDateTime=Date.parse(t.rawProgramDateTime):null!=e&&e.programDateTime&&(t.programDateTime=e.endProgramDateTime),f(t.programDateTime)||(t.programDateTime=null,t.rawProgramDateTime=null)}function ne(t,e,r,i){t.relurl=e.URI,e.BYTERANGE&&t.setByteRange(e.BYTERANGE),t.level=r,t.sn="initSegment",i&&(t.levelkeys=i),t.initSegment=null}function ae(t,e,r){t.levelkeys=e;var i=r.encryptedFragments;i.length&&i[i.length-1].levelkeys===e||!Object.keys(e).some((function(t){return e[t].isCommonEncryption}))||i.push(t)}Jt.findGroup=function(t,e){for(var r=0;r2){var r=e.shift()+".";return r+=parseInt(e.shift()).toString(16),r+=("000"+parseInt(e.shift()).toString(16)).slice(-4)}return t},Jt.resolve=function(t,e){return l.buildAbsoluteURL(e,t,{alwaysNormalize:!0})},Jt.isMediaPlaylist=function(t){return zt.test(t)},Jt.parseMasterPlaylist=function(t,e){var r,i={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:Ut(t)},n=[];for(qt.lastIndex=0;null!=(r=qt.exec(t));)if(r[1]){var a,s=new R(r[1]);Bt(i,s,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);var o=Gt(i,r[2]),l={attrs:s,bitrate:s.decimalInteger("AVERAGE-BANDWIDTH")||s.decimalInteger("BANDWIDTH"),name:s.NAME,url:Jt.resolve(o,e)},u=s.decimalResolution("RESOLUTION");u&&(l.width=u.width,l.height=u.height),ee((s.CODECS||"").split(/[ ,]+/).filter((function(t){return t})),l),l.videoCodec&&-1!==l.videoCodec.indexOf("avc1")&&(l.videoCodec=Jt.convertAVC1ToAVCOTI(l.videoCodec)),null!=(a=l.unknownCodecs)&&a.length||n.push(l),i.levels.push(l)}else if(r[3]){var h=r[3],d=r[4];switch(h){case"SESSION-DATA":var c=new R(d);Bt(i,c,["DATA-ID","LANGUAGE","VALUE","URI"]);var f=c["DATA-ID"];f&&(null===i.sessionData&&(i.sessionData={}),i.sessionData[f]=c);break;case"SESSION-KEY":var p=Zt(d,e,i);p.encrypted&&p.isSupported()?(null===i.sessionKeys&&(i.sessionKeys=[]),i.sessionKeys.push(p)):L.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+d+'"');break;case"DEFINE":var g=new R(d);Bt(i,g,["NAME","VALUE","QUERYPARAM"]),Kt(i,g,e);break;case"CONTENT-STEERING":var v=new R(d);Bt(i,v,["SERVER-URI","PATHWAY-ID"]),i.contentSteering={uri:Jt.resolve(v["SERVER-URI"],e),pathwayId:v["PATHWAY-ID"]||"."};break;case"START":i.startTimeOffset=te(d)}}var m=n.length>0&&n.length0&&W.bool("CAN-SKIP-DATERANGES"),u.partHoldBack=W.optionalFloat("PART-HOLD-BACK",0),u.holdBack=W.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var j=new R(_);u.partTarget=j.decimalFloatingPoint("PART-TARGET");break;case"PART":var q=u.partList;q||(q=u.partList=[]);var X=g>0?q[q.length-1]:void 0,z=g++,Q=new R(_);Bt(u,Q,["BYTERANGE","URI"]);var $=new M(Q,T,e,z,X);q.push($),T.duration+=$.duration;break;case"PRELOAD-HINT":var J=new R(_);Bt(u,J,["URI"]),u.preloadHint=J;break;case"RENDITION-REPORT":var Z=new R(_);Bt(u,Z,["URI"]),u.renditionReports=u.renditionReports||[],u.renditionReports.push(Z);break;default:L.warn("line parsed but not handled: "+s)}}}y&&!y.relurl?(h.pop(),v-=y.duration,u.partList&&(u.fragmentHint=y)):u.partList&&(ie(T,y),T.cc=m,u.fragmentHint=T,l&&ae(T,l,u));var tt=h.length,et=h[0],rt=h[tt-1];if((v+=u.skippedSegments*u.targetduration)>0&&tt&&rt){u.averagetargetduration=v/tt;var it=rt.sn;u.endSN="initSegment"!==it?it:0,u.live||(rt.endList=!0),et&&(u.startCC=et.cc)}else u.endSN=0,u.startCC=0;return u.fragmentHint&&(v+=u.fragmentHint.duration),u.totalduration=v,u.endCC=m,E>0&&function(t,e){for(var r=t[e],i=e;i--;){var n=t[i];if(!n)return;n.programDateTime=r.programDateTime-1e3*n.duration,r=n}}(h,E),u};var se="manifest",oe="level",le="audioTrack",ue="subtitleTrack",he="main",de="audio",ce="subtitle";function fe(t){switch(t.type){case le:return de;case ue:return ce;default:return he}}function pe(t,e){var r=t.url;return void 0!==r&&0!==r.indexOf("data:")||(r=e.url),r}var ge=function(t){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=t,this.registerListeners()};function ve(t,e){var r;try{r=new Event("addtrack")}catch(t){(r=document.createEvent("Event")).initEvent("addtrack",!1,!1)}r.track=t,e.dispatchEvent(r)}function me(t,e){var r=t.mode;if("disabled"===r&&(t.mode="hidden"),t.cues&&!t.cues.getCueById(e.id))try{if(t.addCue(e),!t.cues.getCueById(e.id))throw new Error("addCue is failed for: "+e)}catch(r){L.debug("[texttrack-utils]: "+r);var i=new self.TextTrackCue(e.startTime,e.endTime,e.text);i.id=e.id,t.addCue(i)}"disabled"===r&&(t.mode=r)}function ye(t){var e=t.mode;if("disabled"===e&&(t.mode="hidden"),t.cues)for(var r=t.cues.length;r--;)t.removeCue(t.cues[r]);"disabled"===e&&(t.mode=e)}function Te(t,e,r,i){var n=t.mode;if("disabled"===n&&(t.mode="hidden"),t.cues&&t.cues.length>0)for(var a=function(t,e,r){var i=[],n=function(t,e){if(et[r].endTime)return-1;var i=0,n=r;for(;i<=n;){var a=Math.floor((n+i)/2);if(et[a].startTime&&i-1)for(var a=n,s=t.length;a=e&&o.endTime<=r)i.push(o);else if(o.startTime>r)return i}return i}(t.cues,e,r),s=0;sAe&&(d=Ae),d-h<=0&&(d=h+.25);for(var c=0;ci.startDate&&t.push(r),t}),[]).sort((function(t,e){return t.startDate.getTime()-e.startDate.getTime()}))[0];g&&(d=Re(g.startDate,c),u=!0)}for(var v,m,y=Object.keys(i.attr),T=0;T.05&&this.forwardBufferLength>1){var u=Math.min(2,Math.max(1,a)),h=Math.round(2/(1+Math.exp(-.75*o-this.edgeStalled))*20)/20;t.playbackRate=Math.min(u,Math.max(1,h))}else 1!==t.playbackRate&&0!==t.playbackRate&&(t.playbackRate=1)}}}}},De.prototype.estimateLiveEdge=function(){var t=this.levelDetails;return null===t?null:t.edge+t.age},De.prototype.computeLatency=function(){var t=this.estimateLiveEdge();return null===t?null:t-this.currentTime},Object.defineProperties(De.prototype,Ie);var we=["NONE","TYPE-0","TYPE-1",null],_e="",Ce="YES",Pe="v2";var xe=function(t,e,r){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=t,this.part=e,this.skip=r};xe.prototype.addDirectives=function(t){var e=new self.URL(t);return void 0!==this.msn&&e.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&e.searchParams.set("_HLS_part",this.part.toString()),this.skip&&e.searchParams.set("_HLS_skip",this.skip),e.href};var Fe=function(t){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[t.url],this._attrs=[t.attrs],this.bitrate=t.bitrate,t.details&&(this.details=t.details),this.id=t.id||0,this.name=t.name,this.width=t.width||0,this.height=t.height||0,this.audioCodec=t.audioCodec,this.videoCodec=t.videoCodec,this.unknownCodecs=t.unknownCodecs,this.codecSet=[t.videoCodec,t.audioCodec].filter((function(t){return t})).join(",").replace(/\.[^.,]+/g,"")},Oe={maxBitrate:{configurable:!0},attrs:{configurable:!0},pathwayId:{configurable:!0},uri:{configurable:!0},urlId:{configurable:!0},audioGroupId:{configurable:!0},textGroupId:{configurable:!0}};function Me(t,e){var r=e.startPTS;if(f(r)){var i,n=0;e.sn>t.sn?(n=r-t.start,i=t):(n=t.start-r,i=e),i.duration!==n&&(i.duration=n)}else if(e.sn>t.sn){t.cc===e.cc&&t.minEndPTS?e.start=t.start+(t.minEndPTS-t.start):e.start=t.start+t.duration}else e.start=Math.max(t.start-e.duration,0)}function Ne(t,e,r,i,n,a){i-r<=0&&(L.warn("Fragment should have a positive duration",e),i=r+e.duration,a=n+e.duration);var s=r,o=i,l=e.startPTS,u=e.endPTS;if(f(l)){var h=Math.abs(l-r);f(e.deltaPTS)?e.deltaPTS=Math.max(h,e.deltaPTS):e.deltaPTS=h,s=Math.max(r,l),r=Math.min(r,l),n=Math.min(n,e.startDTS),o=Math.min(i,u),i=Math.max(i,u),a=Math.max(a,e.endDTS)}var d=r-e.start;0!==e.start&&(e.start=r),e.duration=i-e.start,e.startPTS=r,e.maxStartPTS=s,e.startDTS=n,e.endPTS=i,e.minEndPTS=o,e.endDTS=a;var c,p=e.sn;if(!t||pt.endSN)return 0;var g=p-t.startSN,v=t.fragments;for(v[g]=e,c=g;c>0;c--)Me(v[c],v[c-1]);for(c=g;c=0;n--){var a=i[n].initSegment;if(a){r=a;break}}t.fragmentHint&&delete t.fragmentHint.endPTS;var s,o=0;(function(t,e,r){for(var i=e.skippedSegments,n=Math.max(t.startSN,e.startSN)-e.startSN,a=(t.fragmentHint?1:0)+(i?e.endSN:Math.min(t.endSN,e.endSN))-e.startSN,s=e.startSN-t.startSN,o=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,l=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,u=n;u<=a;u++){var h=l[s+u],d=o[u];i&&!d&&u=i.length||Ge(e,i[r].start)}function Ge(t,e){if(e){for(var r=t.fragments,i=t.skippedSegments;i499)}(i)||!!r)}Oe.maxBitrate.get=function(){return Math.max(this.realBitrate,this.bitrate)},Oe.attrs.get=function(){return this._attrs[this._urlId]},Oe.pathwayId.get=function(){return this.attrs["PATHWAY-ID"]||"."},Oe.uri.get=function(){return this.url[this._urlId]||""},Oe.urlId.get=function(){return this._urlId},Oe.urlId.set=function(t){var e=t%this.url.length;this._urlId!==e&&(this.fragmentError=0,this.loadError=0,this.details=void 0,this._urlId=e)},Oe.audioGroupId.get=function(){var t;return null==(t=this.audioGroupIds)?void 0:t[this.urlId]},Oe.textGroupId.get=function(){var t;return null==(t=this.textGroupIds)?void 0:t[this.urlId]},Fe.prototype.addFallback=function(t){this.url.push(t.url),this._attrs.push(t.attrs)},Object.defineProperties(Fe.prototype,Oe);var Xe=function(t,e){for(var r=0,i=t.length-1,n=null,a=null;r<=i;){var s=e(a=t[n=(r+i)/2|0]);if(s>0)r=n+1;else{if(!(s<0))return a;i=n-1}}return null};function ze(t,e,r,i){void 0===r&&(r=0),void 0===i&&(i=0);var n=null;if(t?n=e[t.sn-e[0].sn+1]||null:0===r&&0===e[0].start&&(n=e[0]),n&&0===Qe(r,i,n))return n;var a=Xe(e,Qe.bind(null,r,i));return!a||a===t&&n?n:a}function Qe(t,e,r){if(void 0===t&&(t=0),void 0===e&&(e=0),r.start<=t&&r.start+r.duration>t)return 0;var i=Math.min(e,r.duration+(r.deltaPTS?r.deltaPTS:0));return r.start+r.duration-i<=t?1:r.start-i>t&&r.start?-1:0}function $e(t,e,r){var i=1e3*Math.min(e,r.duration+(r.deltaPTS?r.deltaPTS:0));return(r.endProgramDateTime||0)-i>t}var Je=3e5,Ze=0,tr=2,er=5,rr=0,ir=1,nr=2,ar=function(t){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=t,this.log=L.log.bind(L,"[info]:"),this.warn=L.warn.bind(L,"[warning]:"),this.error=L.error.bind(L,"[error]:"),this.registerListeners()};ar.prototype.registerListeners=function(){var t=this.hls;t.on(p.ERROR,this.onError,this),t.on(p.MANIFEST_LOADING,this.onManifestLoading,this)},ar.prototype.unregisterListeners=function(){var t=this.hls;t&&(t.off(p.ERROR,this.onError,this),t.off(p.ERROR,this.onErrorOut,this),t.off(p.MANIFEST_LOADING,this.onManifestLoading,this))},ar.prototype.destroy=function(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}},ar.prototype.startLoad=function(t){this.playlistError=0},ar.prototype.stopLoad=function(){},ar.prototype.getVariantLevelIndex=function(t){return(null==t?void 0:t.type)===he?t.level:this.hls.loadLevel},ar.prototype.onManifestLoading=function(){this.playlistError=0,this.penalizedRenditions={}},ar.prototype.onError=function(t,e){var r;if(!e.fatal){var i=this.hls,n=e.context;switch(e.details){case v.FRAG_LOAD_ERROR:case v.FRAG_LOAD_TIMEOUT:case v.KEY_LOAD_ERROR:case v.KEY_LOAD_TIMEOUT:return void(e.errorAction=this.getFragRetryOrSwitchAction(e));case v.FRAG_GAP:case v.FRAG_PARSING_ERROR:case v.FRAG_DECRYPT_ERROR:return e.errorAction=this.getFragRetryOrSwitchAction(e),void(e.errorAction.action=tr);case v.LEVEL_EMPTY_ERROR:case v.LEVEL_PARSING_ERROR:var a,s,o=e.parent===he?e.level:i.loadLevel;return void(e.details===v.LEVEL_EMPTY_ERROR&&null!=(a=e.context)&&null!=(s=a.levelDetails)&&s.live?e.errorAction=this.getPlaylistRetryOrSwitchAction(e,o):(e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,o)));case v.LEVEL_LOAD_ERROR:case v.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==n?void 0:n.level)&&(e.errorAction=this.getPlaylistRetryOrSwitchAction(e,n.level)));case v.AUDIO_TRACK_LOAD_ERROR:case v.AUDIO_TRACK_LOAD_TIMEOUT:case v.SUBTITLE_LOAD_ERROR:case v.SUBTITLE_TRACK_LOAD_TIMEOUT:if(n){var l=i.levels[i.loadLevel];if(l&&(n.type===le&&n.groupId===l.audioGroupId||n.type===ue&&n.groupId===l.textGroupId))return e.errorAction=this.getPlaylistRetryOrSwitchAction(e,i.loadLevel),e.errorAction.action=tr,void(e.errorAction.flags=ir)}return;case v.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:var u=i.levels[i.loadLevel],h=null==u?void 0:u.attrs["HDCP-LEVEL"];return void(h&&(e.errorAction={action:tr,flags:nr,hdcpLevel:h}));case v.BUFFER_ADD_CODEC_ERROR:case v.REMUX_ALLOC_ERROR:return void(e.errorAction=this.getLevelSwitchAction(e,null!=(r=e.level)?r:i.loadLevel));case v.INTERNAL_EXCEPTION:case v.BUFFER_APPENDING_ERROR:case v.BUFFER_APPEND_ERROR:case v.BUFFER_FULL_ERROR:case v.LEVEL_SWITCH_ERROR:case v.BUFFER_STALLED_ERROR:case v.BUFFER_SEEK_OVER_HOLE:case v.BUFFER_NUDGE_ON_STALL:return void(e.errorAction={action:Ze,flags:rr})}if(e.type===g.KEY_SYSTEM_ERROR){var d=this.getVariantLevelIndex(e.frag);return e.levelRetry=!1,void(e.errorAction=this.getLevelSwitchAction(e,d))}}},ar.prototype.getPlaylistRetryOrSwitchAction=function(t,e){var r,i=Ye(this.hls.config.playlistLoadPolicy,t),n=this.playlistError++,a=null==(r=t.response)?void 0:r.code;if(qe(i,n,Ve(t),a))return{action:er,flags:rr,retryConfig:i,retryCount:n};var s=this.getLevelSwitchAction(t,e);return i&&(s.retryConfig=i,s.retryCount=n),s},ar.prototype.getFragRetryOrSwitchAction=function(t){var e=this.hls,r=this.getVariantLevelIndex(t.frag),i=e.levels[r],n=e.config,a=n.fragLoadPolicy,s=n.keyLoadPolicy,o=Ye(t.details.startsWith("key")?s:a,t),l=e.levels.reduce((function(t,e){return t+e.fragmentError}),0);if(i){var u;t.details!==v.FRAG_GAP&&i.fragmentError++;var h=null==(u=t.response)?void 0:u.code;if(qe(o,l,Ve(t),h))return{action:er,flags:rr,retryConfig:o,retryCount:l}}var d=this.getLevelSwitchAction(t,r);return o&&(d.retryConfig=o,d.retryCount=l),d},ar.prototype.getLevelSwitchAction=function(t,e){var r=this.hls;null==e&&(e=r.loadLevel);var i=this.hls.levels[e];if(i&&(i.loadError++,r.autoLevelEnabled)){for(var n,a,s=-1,o=r.levels,l=null==(n=t.frag)?void 0:n.type,u=null!=(a=t.context)?a:{},h=u.type,d=u.groupId,c=o.length;c--;){var f=(c+r.loadLevel)%o.length;if(f!==r.loadLevel&&0===o[f].loadError){var p=o[f];if(t.details===v.FRAG_GAP&&t.frag){var g=o[f].details;if(g){var m=ze(t.frag,g.fragments,t.frag.start);if(null!=m&&m.gap)continue}}else{if(h===le&&d===p.audioGroupId||h===ue&&d===p.textGroupId)continue;if(l===de&&i.audioGroupId===p.audioGroupId||l===ce&&i.textGroupId===p.textGroupId)continue}s=f;break}}if(s>-1&&r.loadLevel!==s)return t.levelRetry=!0,{action:tr,flags:rr,nextAutoLevel:s}}return{action:tr,flags:ir}},ar.prototype.onErrorOut=function(t,e){var r;switch(null==(r=e.errorAction)?void 0:r.action){case Ze:break;case tr:this.sendAlternateToPenaltyBox(e),e.errorAction.resolved||e.details===v.FRAG_GAP||(e.fatal=!0)}e.fatal&&this.hls.stopLoad()},ar.prototype.sendAlternateToPenaltyBox=function(t){var e=this.hls,r=t.errorAction;if(r){var i=r.flags,n=r.hdcpLevel,a=r.nextAutoLevel;switch(i){case rr:this.switchLevel(t,a);break;case ir:r.resolved||(r.resolved=this.redundantFailover(t));break;case nr:n&&(e.maxHdcpLevel=we[we.indexOf(n)-1],r.resolved=!0),this.warn('Restricting playback to HDCP-LEVEL of "'+e.maxHdcpLevel+'" or lower')}r.resolved||this.switchLevel(t,a)}},ar.prototype.switchLevel=function(t,e){void 0!==e&&t.errorAction&&(this.warn("switching to level "+e+" after "+t.details),this.hls.nextAutoLevel=e,t.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)},ar.prototype.redundantFailover=function(t){var e=this,r=this.hls,i=this.penalizedRenditions,n=t.parent===he?t.level:r.loadLevel,a=r.levels[n],s=a.url.length,o=t.frag?t.frag.urlId:a.urlId;a.urlId!==o||t.frag&&!a.details||this.penalizeRendition(a,t);for(var l=function(l){var u=(o+l)%s,h=i[u];if(!h||function(t,e,r){if(performance.now()-t.lastErrorPerfMs>Je)return!0;var i=t.details;if(e.details===v.FRAG_GAP&&i&&e.frag){var n=e.frag.start,a=ze(null,i.fragments,n);if(a&&!a.gap)return!0}if(r&&t.errors.length3*i.targetduration)return!0}return!1}(h,t,i[o]))return e.warn("Switching to Redundant Stream "+(u+1)+"/"+s+': "'+a.url[u]+'" after '+t.details),e.playlistError=0,r.levels.forEach((function(t){t.urlId=u})),r.nextLoadLevel=n,{v:!0}},u=1;u=0&&h>e.partTarget&&(u+=1)}return new xe(l,u>=0?u:void 0,_e)}}},or.prototype.loadPlaylist=function(t){-1===this.requestScheduled&&(this.requestScheduled=self.performance.now())},or.prototype.shouldLoadPlaylist=function(t){return this.canLoad&&!!t&&!!t.url&&(!t.details||t.details.live)},or.prototype.shouldReloadPlaylist=function(t){return-1===this.timer&&-1===this.requestScheduled&&this.shouldLoadPlaylist(t)},or.prototype.playlistLoaded=function(t,e,r){var i=this,n=e.details,a=e.stats,s=self.performance.now(),o=a.loading.first?Math.max(0,s-a.loading.first):0;if(n.advancedDateTime=Date.now()-o,n.live||null!=r&&r.live){if(n.reloaded(r),r&&this.log("live playlist "+t+" "+(n.advanced?"REFRESHED "+n.lastPartSn+"-"+n.lastPartIndex:"MISSED")),r&&n.fragments.length>0&&Ue(r,n),!this.canLoad||!n.live)return;var l,u=void 0,h=void 0;if(n.canBlockReload&&n.endSN&&n.advanced){var d=this.hls.config.lowLatencyMode,c=n.lastPartSn,f=n.endSN,p=n.lastPartIndex,g=c===f;-1!==p?(u=g?f+1:c,h=g?d?0:p:p+1):u=f+1;var v=n.age,m=v+n.ageHeader,y=Math.min(m-n.partTarget,1.5*n.targetduration);if(y>0){if(r&&y>r.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+r.tuneInGoal+" to: "+y+" with playlist age: "+n.age),y=0;else{var T=Math.floor(y/n.targetduration);if(u+=T,void 0!==h)h+=Math.round(y%n.targetduration/n.partTarget);this.log("CDN Tune-in age: "+n.ageHeader+"s last advanced "+v.toFixed(2)+"s goal: "+y+" skip sn "+T+" to part "+h)}n.tuneInGoal=y}if(l=this.getDeliveryDirectives(n,e.deliveryDirectives,u,h),d||!g)return void this.loadPlaylist(l)}else n.canBlockReload&&(l=this.getDeliveryDirectives(n,e.deliveryDirectives,u,h));var E=this.hls.mainForwardBufferInfo,S=E?E.end-E.len:0,L=function(t,e){void 0===e&&(e=1/0);var r=1e3*t.targetduration;if(t.updated){var i=t.fragments;if(i.length&&4*r>e){var n=1e3*i[i.length-1].duration;nthis.requestScheduled+L&&(this.requestScheduled=a.loading.start),void 0!==u&&n.canBlockReload?this.requestScheduled=a.loading.first+L-(1e3*n.partTarget||1e3):-1===this.requestScheduled||this.requestScheduled+L(e.attrs["HDCP-LEVEL"]||"")?1:-1:t.bitrate!==e.bitrate?t.bitrate-e.bitrate:t.attrs["FRAME-RATE"]!==e.attrs["FRAME-RATE"]?t.attrs.decimalFloatingPoint("FRAME-RATE")-e.attrs.decimalFloatingPoint("FRAME-RATE"):t.attrs.SCORE!==e.attrs.SCORE?t.attrs.decimalFloatingPoint("SCORE")-e.attrs.decimalFloatingPoint("SCORE"):a&&t.height!==e.height?t.height-e.height:0}));var h=u[0];if(this.steering&&(l=this.steering.filterParsedLevels(l)).length!==u.length)for(var d=0;d=e.length){var r=new Error("invalid level idx"),i=t<0;if(this.hls.trigger(p.ERROR,{type:g.OTHER_ERROR,details:v.LEVEL_SWITCH_ERROR,level:t,fatal:i,error:r,reason:r.message}),i)return;t=Math.min(t,e.length-1)}var n=this.currentLevelIndex,a=this.currentLevel,s=a?a.attrs["PATHWAY-ID"]:void 0,o=e[t],l=o.attrs["PATHWAY-ID"];if(this.currentLevelIndex=t,this.currentLevel=o,n!==t||!o.details||!a||s!==l){this.log("Switching to level "+t+(l?" with Pathway "+l:"")+" from level "+n+(s?" with Pathway "+s:""));var u=c({},o,{level:t,maxBitrate:o.maxBitrate,attrs:o.attrs,uri:o.uri,urlId:o.urlId});delete u._attrs,delete u._urlId,this.hls.trigger(p.LEVEL_SWITCHING,u);var h=o.details;if(!h||h.live){var d=this.switchParams(o.uri,null==a?void 0:a.details);this.loadPlaylist(d)}}}},r.manualLevel.get=function(){return this.manualLevelIndex},r.manualLevel.set=function(t){this.manualLevelIndex=t,void 0===this._startLevel&&(this._startLevel=t),-1!==t&&(this.level=t)},r.firstLevel.get=function(){return this._firstLevel},r.firstLevel.set=function(t){this._firstLevel=t},r.startLevel.get=function(){if(void 0===this._startLevel){var t=this.hls.config.startLevel;return void 0!==t?t:this._firstLevel}return this._startLevel},r.startLevel.set=function(t){this._startLevel=t},e.prototype.onError=function(t,e){!e.fatal&&e.context&&e.context.type===oe&&e.context.level===this.level&&this.checkRetry(e)},e.prototype.onFragLoaded=function(t,e){var r=e.frag;if(void 0!==r&&r.type===he){var i=this._levels[r.level];void 0!==i&&(i.loadError=0)}},e.prototype.onLevelLoaded=function(t,e){var r,i,n=e.level,a=e.details,s=this._levels[n];if(!s)return this.warn("Invalid level index "+n),void(null!=(i=e.deliveryDirectives)&&i.skip&&(a.deltaUpdateFailed=!0));n===this.currentLevelIndex?(0===s.fragmentError&&(s.loadError=0),this.playlistLoaded(n,e,s.details)):null!=(r=e.deliveryDirectives)&&r.skip&&(a.deltaUpdateFailed=!0)},e.prototype.onAudioTrackSwitched=function(t,e){var r=this.currentLevel;if(r){var i=this.hls.audioTracks[e.id].groupId;if(r.audioGroupIds&&r.audioGroupId!==i){for(var n=-1,a=0;a1&&void 0!==e?(n.url=n.url.filter(i),n.audioGroupIds&&(n.audioGroupIds=n.audioGroupIds.filter(i)),n.textGroupIds&&(n.textGroupIds=n.textGroupIds.filter(i)),n.urlId=0,!0):(r.steering&&r.steering.removeLevel(n),!1))}));this.hls.trigger(p.LEVELS_UPDATED,{levels:n})},e.prototype.onLevelsUpdated=function(t,e){var r=e.levels;r.forEach((function(t,e){var r=t.details;null!=r&&r.fragments&&r.fragments.forEach((function(t){t.level=e}))})),this._levels=r},Object.defineProperties(e.prototype,r),e}(or);function ur(t,e,r){r&&("audio"===e?(t.audioGroupIds||(t.audioGroupIds=[]),t.audioGroupIds[t.url.length-1]=r):"text"===e&&(t.textGroupIds||(t.textGroupIds=[]),t.textGroupIds[t.url.length-1]=r))}function hr(t){var e={};t.forEach((function(t){var r=t.groupId||"";t.id=e[r]=e[r]||0,e[r]++}))}var dr="NOT_LOADED",cr="APPENDING",fr="PARTIAL",pr="OK",gr=function(t){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=t,this._registerListeners()};function vr(t){var e,r,i;return t.buffered&&(t.body.gap||(null==(e=t.range.video)?void 0:e.partial)||(null==(r=t.range.audio)?void 0:r.partial)||(null==(i=t.range.audiovideo)?void 0:i.partial))}function mr(t){return t.type+"_"+t.level+"_"+t.urlId+"_"+t.sn}gr.prototype._registerListeners=function(){var t=this.hls;t.on(p.BUFFER_APPENDED,this.onBufferAppended,this),t.on(p.FRAG_BUFFERED,this.onFragBuffered,this),t.on(p.FRAG_LOADED,this.onFragLoaded,this)},gr.prototype._unregisterListeners=function(){var t=this.hls;t.off(p.BUFFER_APPENDED,this.onBufferAppended,this),t.off(p.FRAG_BUFFERED,this.onFragBuffered,this),t.off(p.FRAG_LOADED,this.onFragLoaded,this)},gr.prototype.destroy=function(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null},gr.prototype.getAppendedFrag=function(t,e){var r=this.activePartLists[e];if(r)for(var i=r.length;i--;){var n=r[i];if(!n)break;var a=n.end;if(n.start<=t&&null!==a&&t<=a)return n}return this.getBufferedFrag(t,e)},gr.prototype.getBufferedFrag=function(t,e){for(var r=this.fragments,i=Object.keys(r),n=i.length;n--;){var a=r[i[n]];if((null==a?void 0:a.body.type)===e&&a.buffered){var s=a.body;if(s.start<=t&&t<=s.end)return s}}return null},gr.prototype.detectEvictedFragments=function(t,e,r,i){var n=this;this.timeRanges&&(this.timeRanges[t]=e);var a=(null==i?void 0:i.fragment.sn)||0;Object.keys(this.fragments).forEach((function(i){var s=n.fragments[i];if(s&&!(a>=s.body.sn))if(s.buffered||s.loaded){var o=s.range[t];o&&o.time.some((function(t){var r=!n.isTimeBuffered(t.startPTS,t.endPTS,e);return r&&n.removeFragment(s.body),r}))}else s.body.type===r&&n.removeFragment(s.body)}))},gr.prototype.detectPartialFragments=function(t){var e=this,r=this.timeRanges,i=t.frag,n=t.part;if(r&&"initSegment"!==i.sn){var a=mr(i),s=this.fragments[a];if(s){var o=!i.relurl;Object.keys(r).forEach((function(t){var a=i.elementaryStreams[t];if(a){var l=r[t],u=o||!0===a.partial;s.range[t]=e.getBufferedTimes(i,n,u,l)}})),s.loaded=null,Object.keys(s.range).length?(s.buffered=!0,s.body.endList&&(this.endListFragments[s.body.type]=s),vr(s)||this.removeParts(i.sn-1,i.type)):this.removeFragment(s.body)}}},gr.prototype.removeParts=function(t,e){var r=this.activePartLists[e];r&&(this.activePartLists[e]=r.filter((function(e){return e.fragment.sn>=t})))},gr.prototype.fragBuffered=function(t,e){var r=mr(t),i=this.fragments[r];!i&&e&&(i=this.fragments[r]={body:t,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},t.gap&&(this.hasGaps=!0)),i&&(i.loaded=null,i.buffered=!0)},gr.prototype.getBufferedTimes=function(t,e,r,i){for(var n={time:[],partial:r},a=t.start,s=t.end,o=t.minEndPTS||s,l=t.maxStartPTS||a,u=0;u=h&&o<=d){n.time.push({startPTS:Math.max(a,i.start(u)),endPTS:Math.min(s,i.end(u))});break}if(ah)n.partial=!0,n.time.push({startPTS:Math.max(a,i.start(u)),endPTS:Math.min(s,i.end(u))});else if(s<=h)break}return n},gr.prototype.getPartialFragment=function(t){var e,r,i,n=null,a=0,s=this.bufferPadding,o=this.fragments;return Object.keys(o).forEach((function(l){var u=o[l];u&&vr(u)&&(r=u.body.start-s,i=u.body.end+s,t>=r&&t<=i&&(e=Math.min(t-r,i-t),a<=e&&(n=u.body,a=e)))})),n},gr.prototype.isEndListAppended=function(t){var e=this.endListFragments[t];return void 0!==e&&(e.buffered||vr(e))},gr.prototype.getState=function(t){var e=mr(t),r=this.fragments[e];return r?r.buffered?vr(r)?fr:pr:cr:dr},gr.prototype.isTimeBuffered=function(t,e,r){for(var i,n,a=0;a=i&&e<=n)return!0;if(e<=i)return!1}return!1},gr.prototype.onFragLoaded=function(t,e){var r=e.frag,i=e.part;if("initSegment"!==r.sn&&!r.bitrateTest){var n=i?null:e,a=mr(r);this.fragments[a]={body:r,appendedPTS:null,loaded:n,buffered:!1,range:Object.create(null)}}},gr.prototype.onBufferAppended=function(t,e){var r=this,i=e.frag,n=e.part,a=e.timeRanges;if("initSegment"!==i.sn){var s=i.type;if(n){var o=this.activePartLists[s];o||(this.activePartLists[s]=o=[]),o.push(n)}this.timeRanges=a,Object.keys(a).forEach((function(t){var e=a[t];r.detectEvictedFragments(t,e,s,n)}))}},gr.prototype.onFragBuffered=function(t,e){this.detectPartialFragments(e)},gr.prototype.hasFragment=function(t){var e=mr(t);return!!this.fragments[e]},gr.prototype.hasParts=function(t){var e;return!(null==(e=this.activePartLists[t])||!e.length)},gr.prototype.removeFragmentsInRange=function(t,e,r,i,n){var a=this;i&&!this.hasGaps||Object.keys(this.fragments).forEach((function(s){var o=a.fragments[s];if(o){var l=o.body;l.type!==r||i&&!l.gap||l.startt&&(o.buffered||n)&&a.removeFragment(l)}}))},gr.prototype.removeFragment=function(t){var e=mr(t);t.stats.loaded=0,t.clearElementaryStreamInfo();var r=this.activePartLists[t.type];if(r){var i=t.sn;this.activePartLists[t.type]=r.filter((function(t){return t.fragment.sn!==i}))}delete this.fragments[e],t.endList&&delete this.endListFragments[t.type]},gr.prototype.removeAllFragments=function(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1};var yr=Math.pow(2,17),Tr=function(t){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=t};function Er(t,e){void 0===e&&(e=null);var r=e||t,i={frag:t,part:e,responseType:"arraybuffer",url:r.url,headers:{},rangeStart:0,rangeEnd:0},n=r.byteRangeStartOffset,a=r.byteRangeEndOffset;if(f(n)&&f(a)){var s,o=n,l=a;if("initSegment"===t.sn&&"AES-128"===(null==(s=t.decryptdata)?void 0:s.method)){var u=a-n;u%16&&(l=a+(16-u%16)),0!==n&&(i.resetIV=!0,o=n-16)}i.rangeStart=o,i.rangeEnd=l}return i}function Sr(t,e){var r=new Error("GAP "+(t.gap?"tag":"attribute")+" found"),i={type:g.MEDIA_ERROR,details:v.FRAG_GAP,fatal:!1,frag:t,error:r,networkDetails:null};return e&&(i.part=e),(e||t).stats.aborted=!0,new Lr(i)}Tr.prototype.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},Tr.prototype.abort=function(){this.loader&&this.loader.abort()},Tr.prototype.load=function(t,e){var r=this,i=t.url;if(!i)return Promise.reject(new Lr({type:g.NETWORK_ERROR,details:v.FRAG_LOAD_ERROR,fatal:!1,frag:t,error:new Error("Fragment does not have a "+(i?"part list":"url")),networkDetails:null}));this.abort();var n=this.config,a=n.fLoader,s=n.loader;return new Promise((function(o,l){if(r.loader&&r.loader.destroy(),t.gap)l(Sr(t));else{var u=r.loader=t.loader=a?new a(n):new s(n),d=Er(t),c=je(n.fragLoadPolicy.default),f={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===t.sn?1/0:yr};t.stats=u.stats,u.load(d,f,{onSuccess:function(e,i,n,a){r.resetLoader(t,u);var s=e.data;n.resetIV&&t.decryptdata&&(t.decryptdata.iv=new Uint8Array(s.slice(0,16)),s=s.slice(16)),o({frag:t,part:null,payload:s,networkDetails:a})},onError:function(e,n,a,s){r.resetLoader(t,u),l(new Lr({type:g.NETWORK_ERROR,details:v.FRAG_LOAD_ERROR,fatal:!1,frag:t,response:h({url:i,data:void 0},e),error:new Error("HTTP Error "+e.code+" "+e.text),networkDetails:a,stats:s}))},onAbort:function(e,i,n){r.resetLoader(t,u),l(new Lr({type:g.NETWORK_ERROR,details:v.INTERNAL_ABORTED,fatal:!1,frag:t,error:new Error("Aborted"),networkDetails:n,stats:e}))},onTimeout:function(e,i,n){r.resetLoader(t,u),l(new Lr({type:g.NETWORK_ERROR,details:v.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,error:new Error("Timeout after "+f.timeout+"ms"),networkDetails:n,stats:e}))},onProgress:function(r,i,n,a){e&&e({frag:t,part:null,payload:n,networkDetails:a})}})}}))},Tr.prototype.loadPart=function(t,e,r){var i=this;this.abort();var n=this.config,a=n.fLoader,s=n.loader;return new Promise((function(o,l){if(i.loader&&i.loader.destroy(),t.gap||e.gap)l(Sr(t,e));else{var u=i.loader=t.loader=a?new a(n):new s(n),d=Er(t,e),c=je(n.fragLoadPolicy.default),f={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:yr};e.stats=u.stats,u.load(d,f,{onSuccess:function(n,a,s,l){i.resetLoader(t,u),i.updateStatsFromPart(t,e);var h={frag:t,part:e,payload:n.data,networkDetails:l};r(h),o(h)},onError:function(r,n,a,s){i.resetLoader(t,u),l(new Lr({type:g.NETWORK_ERROR,details:v.FRAG_LOAD_ERROR,fatal:!1,frag:t,part:e,response:h({url:d.url,data:void 0},r),error:new Error("HTTP Error "+r.code+" "+r.text),networkDetails:a,stats:s}))},onAbort:function(r,n,a){t.stats.aborted=e.stats.aborted,i.resetLoader(t,u),l(new Lr({type:g.NETWORK_ERROR,details:v.INTERNAL_ABORTED,fatal:!1,frag:t,part:e,error:new Error("Aborted"),networkDetails:a,stats:r}))},onTimeout:function(r,n,a){i.resetLoader(t,u),l(new Lr({type:g.NETWORK_ERROR,details:v.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,part:e,error:new Error("Timeout after "+f.timeout+"ms"),networkDetails:a,stats:r}))}})}}))},Tr.prototype.updateStatsFromPart=function(t,e){var r=t.stats,i=e.stats,n=i.total;if(r.loaded+=i.loaded,n){var a=Math.round(t.duration/e.duration),s=Math.min(Math.round(r.loaded/n),a),o=(a-s)*Math.round(r.loaded/s);r.total=r.loaded+o}else r.total=Math.max(r.loaded,r.total);var l=r.loading,u=i.loading;l.start?l.first+=u.first-u.start:(l.start=u.start,l.first=u.first),l.end=u.end},Tr.prototype.resetLoader=function(t,e){t.loader=null,this.loader===e&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),e.destroy()};var Lr=function(t){function e(e){t.call(this,e.error.message),this.data=void 0,this.data=e}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(Error),br=function(t){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=t};br.prototype.abort=function(t){for(var e in this.keyUriToKeyInfo){var r=this.keyUriToKeyInfo[e].loader;if(r){if(t&&t!==r.context.frag.type)return;r.abort()}}},br.prototype.detach=function(){for(var t in this.keyUriToKeyInfo){var e=this.keyUriToKeyInfo[t];(e.mediaKeySessionContext||e.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[t]}},br.prototype.destroy=function(){for(var t in this.detach(),this.keyUriToKeyInfo){var e=this.keyUriToKeyInfo[t].loader;e&&e.destroy()}this.keyUriToKeyInfo={}},br.prototype.createKeyLoadError=function(t,e,r,i,n){return void 0===e&&(e=v.KEY_LOAD_ERROR),new Lr({type:g.NETWORK_ERROR,details:e,fatal:!1,frag:t,response:n,error:r,networkDetails:i})},br.prototype.loadClear=function(t,e){var r=this;if(this.emeController&&this.config.emeEnabled)for(var i=t.sn,n=t.cc,a=function(t){var a=e[t];if(n<=a.cc&&("initSegment"===i||"initSegment"===a.sn||i1&&this.tickImmediate(),this._tickCallCount=0)},Ar.prototype.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},Ar.prototype.doTick=function(){};var Rr={length:0,start:function(){return 0},end:function(){return 0}},kr=function(){};kr.isBuffered=function(t,e){try{if(t)for(var r=kr.getBuffered(t),i=0;i=r.start(i)&&e<=r.end(i))return!0}catch(t){}return!1},kr.bufferInfo=function(t,e,r){try{if(t){var i,n=kr.getBuffered(t),a=[];for(i=0;is&&(i[a-1].end=t[n].end):i.push(t[n])}else i.push(t[n])}else i=t;for(var o,l=0,u=e,h=e,d=0;d=c&&er.startCC||t&&t.cc>>8^255&v^99,t[f]=v,e[v]=f;var m=c[f],y=c[m],T=c[y],E=257*c[v]^16843008*v;i[f]=E<<24|E>>>8,n[f]=E<<16|E>>>16,a[f]=E<<8|E>>>24,s[f]=E,E=16843009*T^65537*y^257*m^16843008*f,l[v]=E<<24|E>>>8,u[v]=E<<16|E>>>16,h[v]=E<<8|E>>>24,d[v]=E,f?(f=m^c[c[c[T^m]]],p^=c[c[p]]):f=p=1}},Or.prototype.expandKey=function(t){for(var e=this.uint8ArrayToUint32Array_(t),r=!0,i=0;io.end){var d=s>h;(s0&&a&&a.key&&a.iv&&"AES-128"===a.method){var s=self.performance.now();return r.decrypter.decrypt(new Uint8Array(n),a.key.buffer,a.iv.buffer).catch((function(e){throw i.trigger(p.ERROR,{type:g.MEDIA_ERROR,details:v.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:t}),e})).then((function(r){var n=self.performance.now();return i.trigger(p.FRAG_DECRYPTED,{frag:t,payload:r,stats:{tstart:s,tdecrypt:n}}),e.payload=r,e}))}return e})).then((function(i){var n=r,a=n.fragCurrent,s=n.hls;if(!n.levels)throw new Error("init load aborted, missing levels");var o=t.stats;r.state=Br,e.fragmentError=0,t.data=new Uint8Array(i.payload),o.parsing.start=o.buffering.start=self.performance.now(),o.parsing.end=o.buffering.end=self.performance.now(),i.frag===a&&s.trigger(p.FRAG_BUFFERED,{stats:o,frag:a,part:null,id:t.type}),r.tick()})).catch((function(e){r.state!==Ur&&r.state!==qr&&(r.warn(e),r.resetFragmentLoading(t))}))},e.prototype.fragContextChanged=function(t){var e=this.fragCurrent;return!t||!e||t.level!==e.level||t.sn!==e.sn||t.urlId!==e.urlId},e.prototype.fragBufferedComplete=function(t,e){var r,i,n,a,s=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+t.type+" sn: "+t.sn+(e?" part: "+e.index:"")+" of "+(this.playlistType===he?"level":"track")+" "+t.level+" (frag:["+(null!=(r=t.startPTS)?r:NaN).toFixed(3)+"-"+(null!=(i=t.endPTS)?i:NaN).toFixed(3)+"] > buffer:"+(s?Nr(kr.getBuffered(s)):"(detached)")+")"),this.state=Br,s&&(!this.loadedmetadata&&t.type==he&&s.buffered.length&&(null==(n=this.fragCurrent)?void 0:n.sn)===(null==(a=this.fragPrevious)?void 0:a.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},e.prototype.seekToStartPos=function(){},e.prototype._handleFragmentLoadComplete=function(t){var e=this.transmuxer;if(e){var r=t.frag,i=t.part,n=t.partsLoaded,a=!n||0===n.length||n.some((function(t){return!t})),s=new Dr(r.level,r.sn,r.stats.chunkCount+1,0,i?i.index:-1,!a);e.flush(s)}},e.prototype._handleFragmentLoadProgress=function(t){},e.prototype._doFragLoad=function(t,e,r,i){var n,a=this;void 0===r&&(r=null);var s=null==e?void 0:e.details;if(!this.levels||!s)throw new Error("frag load aborted, missing level"+(s?"":" detail")+"s");var o=null;if(!t.encrypted||null!=(n=t.decryptdata)&&n.key?!t.encrypted&&s.encryptedFragments.length&&this.keyLoader.loadClear(t,s.encryptedFragments):(this.log("Loading key for "+t.sn+" of ["+s.startSN+"-"+s.endSN+"], "+("[stream-controller]"===this.logPrefix?"level":"track")+" "+t.level),this.state=Gr,this.fragCurrent=t,o=this.keyLoader.load(t).then((function(t){if(!a.fragContextChanged(t.frag))return a.hls.trigger(p.KEY_LOADED,t),a.state===Gr&&(a.state=Br),t})),this.hls.trigger(p.KEY_LOADING,{frag:t}),null===this.fragCurrent&&(o=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))),r=Math.max(t.start,r||0),this.config.lowLatencyMode&&"initSegment"!==t.sn){var l=s.partList;if(l&&i){r>t.end&&s.fragmentHint&&(t=s.fragmentHint);var u=this.getNextPart(l,t,r);if(u>-1){var h,d=l[u];return this.log("Loading part sn: "+t.sn+" p: "+d.index+" cc: "+t.cc+" of playlist ["+s.startSN+"-"+s.endSN+"] parts [0-"+u+"-"+(l.length-1)+"] "+("[stream-controller]"===this.logPrefix?"level":"track")+": "+t.level+", target: "+parseFloat(r.toFixed(3))),this.nextLoadPosition=d.start+d.duration,this.state=Kr,h=o?o.then((function(r){return!r||a.fragContextChanged(r.frag)?null:a.doFragPartsLoad(t,d,e,i)})).catch((function(t){return a.handleFragLoadError(t)})):this.doFragPartsLoad(t,d,e,i).catch((function(t){return a.handleFragLoadError(t)})),this.hls.trigger(p.FRAG_LOADING,{frag:t,part:d,targetBufferTime:r}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):h}if(!t.url||this.loadedEndOfParts(l,r))return Promise.resolve(null)}}this.log("Loading fragment "+t.sn+" cc: "+t.cc+" "+(s?"of ["+s.startSN+"-"+s.endSN+"] ":"")+("[stream-controller]"===this.logPrefix?"level":"track")+": "+t.level+", target: "+parseFloat(r.toFixed(3))),f(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=Kr;var c,g=this.config.progressive;return c=g&&o?o.then((function(e){return!e||a.fragContextChanged(null==e?void 0:e.frag)?null:a.fragmentLoader.load(t,i)})).catch((function(t){return a.handleFragLoadError(t)})):Promise.all([this.fragmentLoader.load(t,g?i:void 0),o]).then((function(t){var e=t[0];return!g&&e&&i&&i(e),e})).catch((function(t){return a.handleFragLoadError(t)})),this.hls.trigger(p.FRAG_LOADING,{frag:t,targetBufferTime:r}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):c},e.prototype.doFragPartsLoad=function(t,e,r,i){var n=this;return new Promise((function(a,s){var o,l=[],u=null==(o=r.details)?void 0:o.partList,h=function(e){n.fragmentLoader.loadPart(t,e,i).then((function(i){l[e.index]=i;var s=i.part;n.hls.trigger(p.FRAG_LOADED,i);var o=Ke(r,t.sn,e.index+1)||He(u,t.sn,e.index+1);if(!o)return a({frag:t,part:s,partsLoaded:l});h(o)})).catch(s)};h(e)}))},e.prototype.handleFragLoadError=function(t){if("data"in t){var e=t.data;t.data&&e.details===v.INTERNAL_ABORTED?this.handleFragLoadAborted(e.frag,e.part):this.hls.trigger(p.ERROR,e)}else this.hls.trigger(p.ERROR,{type:g.OTHER_ERROR,details:v.INTERNAL_EXCEPTION,err:t,error:t,fatal:!0});return null},e.prototype._handleTransmuxerFlush=function(t){var e=this.getCurrentContext(t);if(e&&this.state===Yr){var r=e.frag,i=e.part,n=e.level,a=self.performance.now();r.stats.parsing.end=a,i&&(i.stats.parsing.end=a),this.updateLevelTiming(r,i,n,t.partial)}else this.fragCurrent||this.state===Ur||this.state===qr||(this.state=Br)},e.prototype.getCurrentContext=function(t){var e=this.levels,r=this.fragCurrent,i=t.level,n=t.sn,a=t.part;if(null==e||!e[i])return this.warn("Levels object was unset while buffering fragment "+n+" of level "+i+". The current chunk will not be buffered."),null;var s=e[i],o=a>-1?Ke(s,n,a):null,l=o?o.fragment:function(t,e,r){if(null==t||!t.details)return null;var i=t.details,n=i.fragments[e-i.startSN];return n||((n=i.fragmentHint)&&n.sn===e?n:ea&&this.flushMainBuffer(s,t.start)}else this.flushMainBuffer(0,t.start)},e.prototype.getFwdBufferInfo=function(t,e){var r=this.getLoadPosition();return f(r)?this.getFwdBufferInfoAtPos(t,r,e):null},e.prototype.getFwdBufferInfoAtPos=function(t,e,r){var i=this.config.maxBufferHole,n=kr.bufferInfo(t,e,i);if(0===n.len&&void 0!==n.nextStart){var a=this.fragmentTracker.getBufferedFrag(e,r);if(a&&n.nextStart=r&&(e.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+e.maxMaxBufferLength+"s"),!0)},e.prototype.getAppendedFrag=function(t,e){var r=this.fragmentTracker.getAppendedFrag(t,he);return r&&"fragment"in r?r.fragment:r},e.prototype.getNextFragment=function(t,e){var r=e.fragments,i=r.length;if(!i)return null;var n,a=this.config,s=r[0].start;if(e.live){var o=a.initialLiveManifestSize;if(ie},e.prototype.getNextFragmentLoopLoading=function(t,e,r,i,n){var a=t.gap,s=this.getNextFragment(this.nextLoadPosition,e);if(null===s)return s;if(t=s,a&&t&&!t.gap&&r.nextStart){var o=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,r.nextStart,i);if(null!==o&&r.len+o.len>=n)return this.log('buffer full after gaps in "'+i+'" playlist starting at sn: '+t.sn),null}return t},e.prototype.mapToInitFragWhenRequired=function(t){return null==t||!t.initSegment||null!=t&&t.initSegment.data||this.bitrateTest?t:t.initSegment},e.prototype.getNextPart=function(t,e,r){for(var i=-1,n=!1,a=!0,s=0,o=t.length;s-1&&rr.start&&r.loaded},e.prototype.getInitialLiveFragment=function(t,e){var r=this.fragPrevious,i=null;if(r){if(t.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+r.programDateTime),i=function(t,e,r){if(null===e||!Array.isArray(t)||!t.length||!f(e))return null;if(e<(t[0].programDateTime||0))return null;if(e>=(t[t.length-1].endProgramDateTime||0))return null;r=r||0;for(var i=0;i=t.startSN&&n<=t.endSN){var a=e[n-t.startSN];r.cc===a.cc&&(i=a,this.log("Live playlist, switching playlist, load frag with next SN: "+i.sn))}i||(i=function(t,e){return Xe(t,(function(t){return t.cce?-1:0}))}(e,r.cc))&&this.log("Live playlist, switching playlist, load frag with same CC: "+i.sn)}}else{var s=this.hls.liveSyncPosition;null!==s&&(i=this.getFragmentAtPosition(s,this.bitrateTest?t.fragmentEnd:t.edge,t))}return i},e.prototype.getFragmentAtPosition=function(t,e,r){var i,n=this.config,a=this.fragPrevious,s=r.fragments,o=r.endSN,l=r.fragmentHint,u=n.maxFragLookUpTolerance,h=r.partList,d=!!(n.lowLatencyMode&&null!=h&&h.length&&l);(d&&l&&!this.bitrateTest&&(s=s.concat(l),o=l.sn),te-u?0:u):i=s[s.length-1];if(i){var c=i.sn-r.startSN,f=this.fragmentTracker.getState(i);if((f===pr||f===fr&&i.gap)&&(a=i),a&&i.sn===a.sn&&(!d||h[0].fragment.sn>i.sn))if(a&&i.level===a.level){var p=s[c+1];i=i.sn=a-e.maxFragLookUpTolerance&&n<=s;if(null!==i&&r.duration>i&&(n"+t.startSN+" prev-sn: "+(a?a.sn:"na")+" fragments: "+o),d}return l},e.prototype.waitForCdnTuneIn=function(t){return t.live&&t.canBlockReload&&t.partTarget&&t.tuneInGoal>Math.max(t.partHoldBack,3*t.partTarget)},e.prototype.setStartPosition=function(t,e){var r=this.startPosition;if(r "+(null==(n=this.fragCurrent)?void 0:n.url))}else{var a=e.details===v.FRAG_GAP;a&&this.fragmentTracker.fragBuffered(i,!0);var s=e.errorAction,o=s||{},l=o.action,u=o.retryCount;void 0===u&&(u=0);var h=o.retryConfig;if(s&&l===er&&h){this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition);var d=We(h,u);this.warn("Fragment "+i.sn+" of "+t+" "+i.level+" errored with "+e.details+", retrying loading "+(u+1)+"/"+h.maxNumRetry+" in "+d+"ms"),s.resolved=!0,this.retryDate=self.performance.now()+d,this.state=Hr}else h&&s?(this.resetFragmentErrors(t),u.5;i&&this.reduceMaxBufferLength(r.len);var n=!i;return n&&this.warn("Buffer full error while media.currentTime is not buffered, flush "+e+" buffer"),t.frag&&(this.fragmentTracker.removeFragment(t.frag),this.nextLoadPosition=t.frag.start),this.resetLoadingState(),n}return!1},e.prototype.resetFragmentErrors=function(t){t===de&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==Ur&&(this.state=Br)},e.prototype.afterBufferFlushed=function(t,e,r){if(t){var i=kr.getBuffered(t);this.fragmentTracker.detectEvictedFragments(e,i,r),this.state===jr&&this.resetLoadingState()}},e.prototype.resetLoadingState=function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=Br},e.prototype.resetStartWhenNotLoaded=function(t){if(!this.loadedmetadata){this.startFragRequested=!1;var e=this.levels?this.levels[t].details:null;null!=e&&e.live?(this.startPosition=-1,this.setStartPosition(e,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},e.prototype.resetWhenMissingContext=function(t){this.warn("The loading context changed while buffering fragment "+t.sn+" of level "+t.level+". This chunk will not be buffered."),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(t.level),this.resetLoadingState()},e.prototype.removeUnbufferedFrags=function(t){void 0===t&&(t=0),this.fragmentTracker.removeFragmentsInRange(t,1/0,this.playlistType,!1,!0)},e.prototype.updateLevelTiming=function(t,e,r,i){var n,a=this,s=r.details;if(s){if(Object.keys(t.elementaryStreams).reduce((function(e,n){var o=t.elementaryStreams[n];if(o){var l=o.endPTS-o.startPTS;if(l<=0)return a.warn("Could not parse fragment "+t.sn+" "+n+" duration reliably ("+l+")"),e||!1;var u=i?0:Ne(s,t,o.startPTS,o.endPTS,o.startDTS,o.endDTS);return a.hls.trigger(p.LEVEL_PTS_UPDATED,{details:s,level:r,drift:u,type:n,frag:t,start:o.startPTS,end:o.endPTS}),!0}return e}),!1))r.fragmentError=0;else if(null===(null==(n=this.transmuxer)?void 0:n.error)){var o=new Error("Found no media in fragment "+t.sn+" of level "+r.id+" resetting transmuxer to fallback to playlist timing");if(this.warn(o.message),this.hls.trigger(p.ERROR,{type:g.MEDIA_ERROR,details:v.FRAG_PARSING_ERROR,fatal:!1,error:o,frag:t,reason:"Found no media in msn "+t.sn+' of level "'+r.url+'"'}),!this.hls)return;this.resetTransmuxer()}this.state=Wr,this.hls.trigger(p.FRAG_PARSED,{frag:t,part:e})}else this.warn("level.details undefined")},e.prototype.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},e.prototype.recoverWorkerError=function(t){"demuxerWorker"===t.event&&(this.resetTransmuxer(),this.resetLoadingState())},r.state.set=function(t){var e=this._state;e!==t&&(this._state=t,this.log(e+"->"+t))},r.state.get=function(){return this._state},Object.defineProperties(e.prototype,r),e}(Ar);function $r(){return self.SourceBuffer||self.WebKitSourceBuffer}function Jr(t,e){return void 0===t&&(t=""),void 0===e&&(e=9e4),{type:t,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}var Zr=function(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null};Zr.prototype.resetInitSegment=function(t,e,r,i){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},Zr.prototype.resetTimeStamp=function(t){this.initPTS=t,this.resetContiguity()},Zr.prototype.resetContiguity=function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},Zr.prototype.canParse=function(t,e){return!1},Zr.prototype.appendFrame=function(t,e,r){},Zr.prototype.demux=function(t,e){this.cachedData&&(t=wt(this.cachedData,t),this.cachedData=null);var r,i=rt(t,0),n=i?i.length:0,a=this._audioTrack,s=this._id3Track,o=i?function(t){for(var e=ot(t),r=0;r0&&s.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:Ee,duration:Number.POSITIVE_INFINITY});n>>5}function ni(t,e){return e+1=t.length)return!1;var i=ii(t,e);if(i<=r)return!1;var n=e+i;return n===t.length||ni(t,n)}return!1}function si(t,e,r,i,n){if(!t.samplerate){var a=function(t,e,r,i){var n,a,s,o,l=navigator.userAgent.toLowerCase(),u=i,h=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];n=1+((192&e[r+2])>>>6);var d=(60&e[r+2])>>>2;if(!(d>h.length-1))return s=(1&e[r+2])<<2,s|=(192&e[r+3])>>>6,L.log("manifest codec:"+i+", ADTS type:"+n+", samplingIndex:"+d),/firefox/i.test(l)?d>=6?(n=5,o=new Array(4),a=d-3):(n=2,o=new Array(2),a=d):-1!==l.indexOf("android")?(n=2,o=new Array(2),a=d):(n=5,o=new Array(4),i&&(-1!==i.indexOf("mp4a.40.29")||-1!==i.indexOf("mp4a.40.5"))||!i&&d>=6?a=d-3:((i&&-1!==i.indexOf("mp4a.40.2")&&(d>=6&&1===s||/vivaldi/i.test(l))||!i&&1===s)&&(n=2,o=new Array(2)),a=d)),o[0]=n<<3,o[0]|=(14&d)>>1,o[1]|=(1&d)<<7,o[1]|=s<<3,5===n&&(o[1]|=(14&a)>>1,o[2]=(1&a)<<7,o[2]|=8,o[3]=0),{config:o,samplerate:h[d],channelCount:s,codec:"mp4a.40."+n,manifestCodec:u};t.trigger(p.ERROR,{type:g.MEDIA_ERROR,details:v.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+d})}(e,r,i,n);if(!a)return;t.config=a.config,t.samplerate=a.samplerate,t.channelCount=a.channelCount,t.codec=a.codec,t.manifestCodec=a.manifestCodec,L.log("parsed codec:"+t.codec+", rate:"+a.samplerate+", channels:"+a.channelCount)}}function oi(t){return 9216e4/t}function li(t,e,r,i,n){var a,s=i+n*oi(t.samplerate),o=function(t,e){var r=ri(t,e);if(e+r<=t.length){var i=ii(t,e)-r;if(i>0)return{headerLength:r,frameLength:i}}}(e,r);if(o){var l=o.frameLength,u=o.headerLength,h=u+l,d=Math.max(0,r+h-e.length);d?(a=new Uint8Array(h-u)).set(e.subarray(r+u,e.length),0):a=e.subarray(r+u,r+h);var c={unit:a,pts:s};return d||t.samples.push(c),{sample:c,length:h,missing:d}}var f=e.length-r;return(a=new Uint8Array(f)).set(e.subarray(r,e.length),0),{sample:{unit:a,pts:s},length:f,missing:-1}}var ui=function(t){function e(e,r){t.call(this),this.observer=void 0,this.config=void 0,this.observer=e,this.config=r}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.resetInitSegment=function(e,r,i,n){t.prototype.resetInitSegment.call(this,e,r,i,n),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:r,duration:n,inputTimeScale:9e4,dropped:0}},e.probe=function(t){if(!t)return!1;for(var e=(rt(t,0)||[]).length,r=t.length;e16384?t.subarray(0,16384):t,["moof"]).length>0},di.prototype.demux=function(t,e){this.timeOffset=e;var r=t,i=this.videoTrack,n=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=wt(this.remainderData,t));var a=function(t){var e={valid:null,remainder:null},r=At(t,["moof"]);if(!r)return e;if(r.length<2)return e.remainder=t,e;var i=r[r.length-1];return e.valid=J(t,0,i.byteOffset-8),e.remainder=J(t,i.byteOffset-8),e}(r);this.remainderData=a.remainder,i.samples=a.valid||new Uint8Array}else i.samples=r;var s=this.extractID3Track(i,e);return n.samples=_t(e,i),{videoTrack:i,audioTrack:this.audioTrack,id3Track:s,textTrack:this.txtTrack}},di.prototype.flush=function(){var t=this.timeOffset,e=this.videoTrack,r=this.txtTrack;e.samples=this.remainderData||new Uint8Array,this.remainderData=null;var i=this.extractID3Track(e,this.timeOffset);return r.samples=_t(t,e),{videoTrack:e,audioTrack:Jr(),id3Track:i,textTrack:Jr()}},di.prototype.extractID3Track=function(t,e){var r=this.id3Track;if(t.samples.length){var i=At(t.samples,["emsg"]);i&&i.forEach((function(t){var i=function(t){var e=t[0],r="",i="",n=0,a=0,s=0,o=0,l=0,u=0;if(0===e){for(;"\0"!==Tt(t.subarray(u,u+1));)r+=Tt(t.subarray(u,u+1)),u+=1;for(r+=Tt(t.subarray(u,u+1)),u+=1;"\0"!==Tt(t.subarray(u,u+1));)i+=Tt(t.subarray(u,u+1)),u+=1;i+=Tt(t.subarray(u,u+1)),u+=1,n=St(t,12),a=St(t,16),o=St(t,20),l=St(t,24),u=28}else if(1===e){n=St(t,u+=4);var h=St(t,u+=4),d=St(t,u+=4);for(u+=4,s=Math.pow(2,32)*h+d,Number.isSafeInteger(s)||(s=Number.MAX_SAFE_INTEGER,L.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=St(t,u),l=St(t,u+=4),u+=4;"\0"!==Tt(t.subarray(u,u+1));)r+=Tt(t.subarray(u,u+1)),u+=1;for(r+=Tt(t.subarray(u,u+1)),u+=1;"\0"!==Tt(t.subarray(u,u+1));)i+=Tt(t.subarray(u,u+1)),u+=1;i+=Tt(t.subarray(u,u+1)),u+=1}return{schemeIdUri:r,value:i,timeScale:n,presentationTime:s,presentationTimeDelta:a,eventDuration:o,id:l,payload:t.subarray(u,t.byteLength)}}(t);if(hi.test(i.schemeIdUri)){var n=f(i.presentationTime)?i.presentationTime/i.timeScale:e+i.presentationTimeDelta/i.timeScale,a=4294967295===i.eventDuration?Number.POSITIVE_INFINITY:i.eventDuration/i.timeScale;a<=.001&&(a=Number.POSITIVE_INFINITY);var s=i.payload;r.samples.push({data:s,len:s.byteLength,dts:n,pts:n,type:Le,duration:a})}}))}return r},di.prototype.demuxSampleAes=function(t,e,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},di.prototype.destroy=function(){};var ci=null,fi=[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],pi=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],gi=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],vi=[0,1,1,4];function mi(t,e,r,i,n){if(!(r+24>e.length)){var a=yi(e,r);if(a&&r+a.frameLength<=e.length){var s=i+n*(9e4*a.samplesPerFrame/a.sampleRate),o={unit:e.subarray(r,r+a.frameLength),pts:s,dts:s};return t.config=[],t.channelCount=a.channelCount,t.samplerate=a.sampleRate,t.samples.push(o),{sample:o,length:a.frameLength,missing:0}}}}function yi(t,e){var r=t[e+1]>>3&3,i=t[e+1]>>1&3,n=t[e+2]>>4&15,a=t[e+2]>>2&3;if(1!==r&&0!==n&&15!==n&&3!==a){var s=t[e+2]>>1&1,o=t[e+3]>>6,l=1e3*fi[14*(3===r?3-i:3===i?3:4)+n-1],u=pi[3*(3===r?0:2===r?1:2)+a],h=3===o?1:2,d=gi[r][i],c=vi[i],f=8*d*c,p=Math.floor(d*l/u+s)*c;if(null===ci){var g=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);ci=g?parseInt(g[1]):0}return!!ci&&ci<=87&&2===i&&l>=224e3&&0===o&&(t[e+3]=128|t[e+3]),{sampleRate:u,channelCount:h,frameLength:p,samplesPerFrame:f}}}function Ti(t,e){return 255===t[e]&&224==(224&t[e+1])&&0!=(6&t[e+1])}function Ei(t,e){return e+1t?(this.word<<=t,this.bitsAvailable-=t):(t-=this.bitsAvailable,t-=(e=t>>3)<<3,this.bytesAvailable-=e,this.loadWord(),this.word<<=t,this.bitsAvailable-=t)},Li.prototype.readBits=function(t){var e=Math.min(this.bitsAvailable,t),r=this.word>>>32-e;if(t>32&&L.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=e,this.bitsAvailable>0)this.word<<=e;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return(e=t-e)>0&&this.bitsAvailable?r<>>t))return this.word<<=t,this.bitsAvailable-=t,t;return this.loadWord(),t+this.skipLZ()},Li.prototype.skipUEG=function(){this.skipBits(1+this.skipLZ())},Li.prototype.skipEG=function(){this.skipBits(1+this.skipLZ())},Li.prototype.readUEG=function(){var t=this.skipLZ();return this.readBits(t+1)-1},Li.prototype.readEG=function(){var t=this.readUEG();return 1&t?1+t>>>1:-1*(t>>>1)},Li.prototype.readBoolean=function(){return 1===this.readBits(1)},Li.prototype.readUByte=function(){return this.readBits(8)},Li.prototype.readUShort=function(){return this.readBits(16)},Li.prototype.readUInt=function(){return this.readBits(32)},Li.prototype.skipScalingList=function(t){for(var e=8,r=8,i=0;i=t.length)return void r();if(!(t[e].unit.length<32)&&(this.decryptAacSample(t,e,r),!this.decrypter.isSync()))return}},bi.prototype.getAvcEncryptedData=function(t){for(var e=16*Math.floor((t.length-48)/160)+16,r=new Int8Array(e),i=0,n=32;n=t.length)return void i();for(var n=t[e].units;!(r>=n.length);r++){var a=n[r];if(!(a.data.length<=48||1!==a.type&&5!==a.type||(this.decryptAvcSample(t,e,r,i,a),this.decrypter.isSync())))return}}};var Ai=188,Ri=function(t,e,r){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=t,this.config=e,this.typeSupported=r};function ki(t,e,r,i){return{key:t,frame:!1,pts:e,dts:r,units:[],debug:i,length:0}}function Di(t,e){return((31&t[e+1])<<8)+t[e+2]}function Ii(t,e){return(31&t[e+10])<<8|t[e+11]}function wi(t,e,r,i){var n={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},a=e+3+((15&t[e+1])<<8|t[e+2])-4;for(e+=12+((15&t[e+10])<<8|t[e+11]);e1;){var l=new Uint8Array(o[0].length+o[1].length);l.set(o[0]),l.set(o[1],o[0].length),o[0]=l,o.splice(1,1)}if(1===((e=o[0])[0]<<16)+(e[1]<<8)+e[2]){if((r=(e[4]<<8)+e[5])&&r>t.size-6)return null;var u=e[7];192&u&&(n=536870912*(14&e[9])+4194304*(255&e[10])+16384*(254&e[11])+128*(255&e[12])+(254&e[13])/2,64&u?n-(a=536870912*(14&e[14])+4194304*(255&e[15])+16384*(254&e[16])+128*(255&e[17])+(254&e[18])/2)>54e5&&(L.warn(Math.round((n-a)/9e4)+"s delta between PTS and DTS, align them"),n=a):a=n);var h=(i=e[8])+9;if(t.size<=h)return null;t.size-=h;for(var d=new Uint8Array(t.size),c=0,f=o.length;cp){h-=p;continue}e=e.subarray(h),p-=h,h=0}d.set(e,s),s+=p}return r&&(r-=i+3),{data:d,pts:n,dts:a,len:r}}return null}function Ci(t,e){if(t.units.length&&t.frame){if(void 0===t.pts){var r=e.samples,i=r.length;if(!i)return void e.dropped++;var n=r[i-1];t.pts=n.pts,t.dts=n.dts}e.samples.push(t)}t.debug.length&&L.log(t.pts+"/"+t.dts+":"+t.debug)}Ri.probe=function(t){var e=Ri.syncOffset(t);return e>0&&L.warn("MPEG2-TS detected but first sync word found @ offset "+e),-1!==e},Ri.syncOffset=function(t){for(var e=t.length,r=Math.min(940,t.length-Ai)+1,i=0;ir)return i;i++}return-1},Ri.createTrack=function(t,e){return{container:"video"===t||"audio"===t?"video/mp2t":void 0,type:t,id:yt[t],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===t?e:void 0}},Ri.prototype.resetInitSegment=function(t,e,r,i){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=Ri.createTrack("video"),this._audioTrack=Ri.createTrack("audio",i),this._id3Track=Ri.createTrack("id3"),this._txtTrack=Ri.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=e,this.videoCodec=r,this._duration=i},Ri.prototype.resetTimeStamp=function(){},Ri.prototype.resetContiguity=function(){var t=this,e=t._audioTrack,r=t._avcTrack,i=t._id3Track;e&&(e.pesData=null),r&&(r.pesData=null),i&&(i.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null},Ri.prototype.demux=function(t,e,r,i){var n;void 0===r&&(r=!1),void 0===i&&(i=!1),r||(this.sampleAes=null);var a=this._avcTrack,s=this._audioTrack,o=this._id3Track,l=this._txtTrack,u=a.pid,h=a.pesData,d=s.pid,c=o.pid,f=s.pesData,m=o.pesData,y=null,T=this.pmtParsed,E=this._pmtId,S=t.length;if(this.remainderData&&(S=(t=wt(this.remainderData,t)).length,this.remainderData=null),S>4>1){if((I=R+5+t[R+4])===R+Ai)continue}else I=R+4;switch(D){case u:k&&(h&&(n=_i(h))&&this.parseAVCPES(a,l,n,!1),h={data:[],size:0}),h&&(h.data.push(t.subarray(I,R+Ai)),h.size+=R+Ai-I);break;case d:if(k){if(f&&(n=_i(f)))switch(s.segmentCodec){case"aac":this.parseAACPES(s,n);break;case"mp3":this.parseMPEGPES(s,n)}f={data:[],size:0}}f&&(f.data.push(t.subarray(I,R+Ai)),f.size+=R+Ai-I);break;case c:k&&(m&&(n=_i(m))&&this.parseID3PES(o,n),m={data:[],size:0}),m&&(m.data.push(t.subarray(I,R+Ai)),m.size+=R+Ai-I);break;case 0:k&&(I+=t[I]+1),E=this._pmtId=Ii(t,I);break;case E:k&&(I+=t[I]+1);var w=wi(t,I,this.typeSupported,r);(u=w.avc)>0&&(a.pid=u),(d=w.audio)>0&&(s.pid=d,s.segmentCodec=w.segmentCodec),(c=w.id3)>0&&(o.pid=c),null===y||T||(L.warn("MPEG-TS PMT found at "+R+" after unknown PID '"+y+"'. Backtracking to sync byte @"+b+" to parse all TS packets."),y=null,R=b-188),T=this.pmtParsed=!0;break;case 17:case 8191:break;default:y=D}}else A++;if(A>0){var _=new Error("Found "+A+" TS packet/s that do not start with 0x47");this.observer.emit(p.ERROR,p.ERROR,{type:g.MEDIA_ERROR,details:v.FRAG_PARSING_ERROR,fatal:!1,error:_,reason:_.message})}a.pesData=h,s.pesData=f,o.pesData=m;var C={audioTrack:s,videoTrack:a,id3Track:o,textTrack:l};return i&&this.extractRemainingSamples(C),C},Ri.prototype.flush=function(){var t,e=this.remainderData;return this.remainderData=null,t=e?this.demux(e,-1,!1,!0):{videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t},Ri.prototype.extractRemainingSamples=function(t){var e,r=t.audioTrack,i=t.videoTrack,n=t.id3Track,a=t.textTrack,s=i.pesData,o=r.pesData,l=n.pesData;if(s&&(e=_i(s))?(this.parseAVCPES(i,a,e,!0),i.pesData=null):i.pesData=s,o&&(e=_i(o))){switch(r.segmentCodec){case"aac":this.parseAACPES(r,e);break;case"mp3":this.parseMPEGPES(r,e)}r.pesData=null}else null!=o&&o.size&&L.log("last AAC PES packet truncated,might overlap between fragments"),r.pesData=o;l&&(e=_i(l))?(this.parseID3PES(n,e),n.pesData=null):n.pesData=l},Ri.prototype.demuxSampleAes=function(t,e,r){var i=this.demux(t,r,!0,!this.config.progressive),n=this.sampleAes=new bi(this.observer,this.config,e);return this.decrypt(i,n)},Ri.prototype.decrypt=function(t,e){return new Promise((function(r){var i=t.audioTrack,n=t.videoTrack;i.samples&&"aac"===i.segmentCodec?e.decryptAacSamples(i.samples,0,(function(){n.samples?e.decryptAvcSamples(n.samples,0,0,(function(){r(t)})):r(t)})):n.samples&&e.decryptAvcSamples(n.samples,0,0,(function(){r(t)}))}))},Ri.prototype.destroy=function(){this._duration=0},Ri.prototype.parseAVCPES=function(t,e,r,i){var n,a=this,s=this.parseAVCNALu(t,r.data),o=this.avcSample,l=!1;r.data=null,o&&s.length&&!t.audFound&&(Ci(o,t),o=this.avcSample=ki(!1,r.pts,r.dts,"")),s.forEach((function(i){switch(i.type){case 1:n=!0,o||(o=a.avcSample=ki(!0,r.pts,r.dts,"")),o.frame=!0;var s=i.data;if(l&&s.length>4){var u=new Li(s).readSliceType();2!==u&&4!==u&&7!==u&&9!==u||(o.key=!0)}break;case 5:n=!0,o||(o=a.avcSample=ki(!0,r.pts,r.dts,"")),o.key=!0,o.frame=!0;break;case 6:n=!0,Pt(i.data,1,r.pts,e.samples);break;case 7:if(n=!0,l=!0,!t.sps){var h=i.data,d=new Li(h).readSPS();t.width=d.width,t.height=d.height,t.pixelRatio=d.pixelRatio,t.sps=[h],t.duration=a._duration;for(var c=h.subarray(1,4),f="avc1.",p=0;p<3;p++){var g=c[p].toString(16);g.length<2&&(g="0"+g),f+=g}t.codec=f}break;case 8:n=!0,t.pps||(t.pps=[i.data]);break;case 9:n=!1,t.audFound=!0,o&&Ci(o,t),o=a.avcSample=ki(!1,r.pts,r.dts,"");break;case 12:n=!0;break;default:n=!1,o&&(o.debug+="unknown NAL "+i.type+" ")}o&&n&&o.units.push(i)})),i&&o&&(Ci(o,t),this.avcSample=null)},Ri.prototype.getLastNalUnit=function(t){var e,r,i=this.avcSample;if(i&&0!==i.units.length||(i=t[t.length-1]),null!=(e=i)&&e.units){var n=i.units;r=n[n.length-1]}return r},Ri.prototype.parseAVCNALu=function(t,e){var r,i,n=e.byteLength,a=t.naluState||0,s=a,o=[],l=0,u=-1,h=0;for(-1===a&&(u=0,h=31&e[0],a=0,l=1);l=0){var d={data:e.subarray(u,l-a-1),type:h};o.push(d)}else{var c=this.getLastNalUnit(t.samples);if(c&&(s&&l<=4-s&&c.state&&(c.data=c.data.subarray(0,c.data.byteLength-s)),(i=l-a-1)>0)){var f=new Uint8Array(c.data.byteLength+i);f.set(c.data,0),f.set(e.subarray(0,i),c.data.byteLength),c.data=f,c.state=0}}l=0&&a>=0){var p={data:e.subarray(u,n),type:h,state:a};o.push(p)}if(0===o.length){var g=this.getLastNalUnit(t.samples);if(g){var v=new Uint8Array(g.data.byteLength+e.byteLength);v.set(g.data,0),v.set(e,g.data.byteLength),g.data=v}}return t.naluState=a,o},Ri.prototype.parseAACPES=function(t,e){var r,i,n,a=0,s=this.aacOverFlow,o=e.data;if(s){this.aacOverFlow=null;var l=s.missing,u=s.sample.unit.byteLength;if(-1===l){var h=new Uint8Array(u+o.byteLength);h.set(s.sample.unit,0),h.set(o,u),o=h}else{var d=u-l;s.sample.unit.set(o.subarray(0,l),d),t.samples.push(s.sample),a=s.missing}}for(r=a,i=o.length;r0;)e[r]=arguments[r+1];for(var i=8,n=e.length,a=n;n--;)i+=e[n].byteLength;var s=new Uint8Array(i);for(s[0]=i>>24&255,s[1]=i>>16&255,s[2]=i>>8&255,s[3]=255&i,s.set(t,4),n=0,i=8;n>24&255,t>>16&255,t>>8&255,255&t,r>>24,r>>16&255,r>>8&255,255&r,i>>24,i>>16&255,i>>8&255,255&i,85,196,0,0]))},Oi.mdia=function(t){return Oi.box(Oi.types.mdia,Oi.mdhd(t.timescale,t.duration),Oi.hdlr(t.type),Oi.minf(t))},Oi.mfhd=function(t){return Oi.box(Oi.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))},Oi.minf=function(t){return"audio"===t.type?Oi.box(Oi.types.minf,Oi.box(Oi.types.smhd,Oi.SMHD),Oi.DINF,Oi.stbl(t)):Oi.box(Oi.types.minf,Oi.box(Oi.types.vmhd,Oi.VMHD),Oi.DINF,Oi.stbl(t))},Oi.moof=function(t,e,r){return Oi.box(Oi.types.moof,Oi.mfhd(t),Oi.traf(r,e))},Oi.moov=function(t){for(var e=t.length,r=[];e--;)r[e]=Oi.trak(t[e]);return Oi.box.apply(null,[Oi.types.moov,Oi.mvhd(t[0].timescale,t[0].duration)].concat(r).concat(Oi.mvex(t)))},Oi.mvex=function(t){for(var e=t.length,r=[];e--;)r[e]=Oi.trex(t[e]);return Oi.box.apply(null,[Oi.types.mvex].concat(r))},Oi.mvhd=function(t,e){e*=t;var r=Math.floor(e/(Fi+1)),i=Math.floor(e%(Fi+1)),n=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,r>>24,r>>16&255,r>>8&255,255&r,i>>24,i>>16&255,i>>8&255,255&i,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 Oi.box(Oi.types.mvhd,n)},Oi.sdtp=function(t){var e,r,i=t.samples||[],n=new Uint8Array(4+i.length);for(e=0;e>>8&255),n.push(255&i),n=n.concat(Array.prototype.slice.call(r));for(e=0;e>>8&255),a.push(255&i),a=a.concat(Array.prototype.slice.call(r));var s=Oi.box(Oi.types.avcC,new Uint8Array([1,n[3],n[4],n[5],255,224|t.sps.length].concat(n).concat([t.pps.length]).concat(a))),o=t.width,l=t.height,u=t.pixelRatio[0],h=t.pixelRatio[1];return Oi.box(Oi.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,o>>8&255,255&o,l>>8&255,255&l,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),s,Oi.box(Oi.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),Oi.box(Oi.types.pasp,new Uint8Array([u>>24,u>>16&255,u>>8&255,255&u,h>>24,h>>16&255,h>>8&255,255&h])))},Oi.esds=function(t){var e=t.config.length;return new Uint8Array([0,0,0,0,3,23+e,0,1,0,4,15+e,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([e]).concat(t.config).concat([6,1,2]))},Oi.mp4a=function(t){var e=t.samplerate;return Oi.box(Oi.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,e>>8&255,255&e,0,0]),Oi.box(Oi.types.esds,Oi.esds(t)))},Oi.mp3=function(t){var e=t.samplerate;return Oi.box(Oi.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,e>>8&255,255&e,0,0]))},Oi.stsd=function(t){return"audio"===t.type?"mp3"===t.segmentCodec&&"mp3"===t.codec?Oi.box(Oi.types.stsd,Oi.STSD,Oi.mp3(t)):Oi.box(Oi.types.stsd,Oi.STSD,Oi.mp4a(t)):Oi.box(Oi.types.stsd,Oi.STSD,Oi.avc1(t))},Oi.tkhd=function(t){var e=t.id,r=t.duration*t.timescale,i=t.width,n=t.height,a=Math.floor(r/(Fi+1)),s=Math.floor(r%(Fi+1));return Oi.box(Oi.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,0,0,0,0,a>>24,a>>16&255,a>>8&255,255&a,s>>24,s>>16&255,s>>8&255,255&s,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,i>>8&255,255&i,0,0,n>>8&255,255&n,0,0]))},Oi.traf=function(t,e){var r=Oi.sdtp(t),i=t.id,n=Math.floor(e/(Fi+1)),a=Math.floor(e%(Fi+1));return Oi.box(Oi.types.traf,Oi.box(Oi.types.tfhd,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i])),Oi.box(Oi.types.tfdt,new Uint8Array([1,0,0,0,n>>24,n>>16&255,n>>8&255,255&n,a>>24,a>>16&255,a>>8&255,255&a])),Oi.trun(t,r.length+16+20+8+16+8+8),r)},Oi.trak=function(t){return t.duration=t.duration||4294967295,Oi.box(Oi.types.trak,Oi.tkhd(t),Oi.mdia(t))},Oi.trex=function(t){var e=t.id;return Oi.box(Oi.types.trex,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},Oi.trun=function(t,e){var r,i,n,a,s,o,l=t.samples||[],u=l.length,h=12+16*u,d=new Uint8Array(h);for(e+=8+h,d.set(["video"===t.type?1:0,0,15,1,u>>>24&255,u>>>16&255,u>>>8&255,255&u,e>>>24&255,e>>>16&255,e>>>8&255,255&e],0),r=0;r>>24&255,n>>>16&255,n>>>8&255,255&n,a>>>24&255,a>>>16&255,a>>>8&255,255&a,s.isLeading<<2|s.dependsOn,s.isDependedOn<<6|s.hasRedundancy<<4|s.paddingValue<<1|s.isNonSync,61440&s.degradPrio,15&s.degradPrio,o>>>24&255,o>>>16&255,o>>>8&255,255&o],12+16*r);return Oi.box(Oi.types.trun,d)},Oi.initSegment=function(t){Oi.types||Oi.init();var e=Oi.moov(t),r=new Uint8Array(Oi.FTYP.byteLength+e.byteLength);return r.set(Oi.FTYP),r.set(e,Oi.FTYP.byteLength),r},Oi.types=void 0,Oi.HDLR_TYPES=void 0,Oi.STTS=void 0,Oi.STSC=void 0,Oi.STCO=void 0,Oi.STSZ=void 0,Oi.VMHD=void 0,Oi.SMHD=void 0,Oi.STSD=void 0,Oi.FTYP=void 0,Oi.DINF=void 0;function Mi(t,e,r,i){void 0===r&&(r=1),void 0===i&&(i=!1);var n=t*e*r;return i?Math.round(n):n}function Ni(t,e){return void 0===e&&(e=!1),Mi(t,1e3,1/9e4,e)}var Ui=null,Bi=null,Gi=function(t,e,r,i){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=t,this.config=e,this.typeSupported=r,this.ISGenerated=!1,null===Ui){var n=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Ui=n?parseInt(n[1]):0}if(null===Bi){var a=navigator.userAgent.match(/Safari\/(\d+)/i);Bi=a?parseInt(a[1]):0}};function Ki(t,e){var r;if(null===e)return t;for(r=e4294967296;)t+=r;return t}function Hi(t,e,r,i){var n=t.samples.length;if(n){for(var a=t.inputTimeScale,s=0;s0?t:r.pts}),t[0].pts);return e&&L.debug("PTS rollover detected"),r},Gi.prototype.remux=function(t,e,r,i,n,a,s,o){var l,u,h,d,c,f,p=n,g=n,v=t.pid>-1,m=e.pid>-1,y=e.samples.length,T=t.samples.length>0,E=s&&y>0||y>1;if((!v||T)&&(!m||E)||this.ISGenerated||s){this.ISGenerated||(h=this.generateIS(t,e,n,a));var S,b=this.isVideoContiguous,A=-1;if(E&&(A=function(t){for(var e=0;e0){L.warn("[mp4-remuxer]: Dropped "+A+" out of "+y+" video samples due to a missing keyframe");var R=this.getVideoStartPts(e.samples);e.samples=e.samples.slice(A),e.dropped+=A,S=g+=(e.samples[0].pts-R)/e.inputTimeScale}else-1===A&&(L.warn("[mp4-remuxer]: No keyframe found out of "+y+" video samples"),f=!1);if(this.ISGenerated){if(T&&E){var k=this.getVideoStartPts(e.samples),D=(Ki(t.samples[0].pts,k)-k)/e.inputTimeScale;p+=Math.max(0,D),g+=Math.max(0,-D)}if(T){if(t.samplerate||(L.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),h=this.generateIS(t,e,n,a)),u=this.remuxAudio(t,p,this.isAudioContiguous,a,m||E||o===de?g:void 0),E){var I=u?u.endPTS-u.startPTS:0;e.inputTimeScale||(L.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),h=this.generateIS(t,e,n,a)),l=this.remuxVideo(e,g,b,I)}}else E&&(l=this.remuxVideo(e,g,b,0));l&&(l.firstKeyFrame=A,l.independent=-1!==A,l.firstKeyFramePTS=S)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(c=Hi(r,n,this._initPTS,this._initDTS)),i.samples.length&&(d=Vi(i,n,this._initPTS))),{audio:u,video:l,initSegment:h,independent:f,text:d,id3:c}},Gi.prototype.generateIS=function(t,e,r,i){var n,a,s,o=t.samples,l=e.samples,u=this.typeSupported,h={},d=this._initPTS,c=!d||i,f="audio/mp4";if(c&&(n=a=1/0),t.config&&o.length){switch(t.timescale=t.samplerate,t.segmentCodec){case"mp3":u.mpeg?(f="audio/mpeg",t.codec=""):u.mp3&&(t.codec="mp3")}h.audio={id:"audio",container:f,codec:t.codec,initSegment:"mp3"===t.segmentCodec&&u.mpeg?new Uint8Array(0):Oi.initSegment([t]),metadata:{channelCount:t.channelCount}},c&&(s=t.inputTimeScale,d&&s===d.timescale?c=!1:n=a=o[0].pts-Math.round(s*r))}if(e.sps&&e.pps&&l.length&&(e.timescale=e.inputTimeScale,h.video={id:"main",container:"video/mp4",codec:e.codec,initSegment:Oi.initSegment([e]),metadata:{width:e.width,height:e.height}},c))if(s=e.inputTimeScale,d&&s===d.timescale)c=!1;else{var p=this.getVideoStartPts(l),g=Math.round(s*r);a=Math.min(a,Ki(l[0].dts,p)-g),n=Math.min(n,p-g)}if(Object.keys(h).length)return this.ISGenerated=!0,c?(this._initPTS={baseTime:n,timescale:s},this._initDTS={baseTime:a,timescale:s}):n=s=void 0,{tracks:h,initPTS:n,timescale:s}},Gi.prototype.remuxVideo=function(t,e,r,i){var n,a,s=t.inputTimeScale,o=t.samples,l=[],u=o.length,h=this._initPTS,d=this.nextAvcDts,f=8,m=this.videoSampleDuration,y=Number.POSITIVE_INFINITY,T=Number.NEGATIVE_INFINITY,E=!1;r&&null!==d||(d=e*s-(o[0].pts-Ki(o[0].dts,o[0].pts)));for(var S=h.baseTime*s/h.timescale,b=0;b0?b-1:b].dts&&(E=!0)}E&&o.sort((function(t,e){var r=t.dts-e.dts,i=t.pts-e.pts;return r||i})),n=o[0].dts;var R=(a=o[o.length-1].dts)-n,k=R?Math.round(R/(u-1)):m||t.inputTimeScale/30;if(r){var D=n-d,I=D>k,w=D<-1;if((I||w)&&(I?L.warn("AVC: "+Ni(D,!0)+" ms ("+D+"dts) hole between fragments detected, filling it"):L.warn("AVC: "+Ni(-D,!0)+" ms ("+D+"dts) overlapping between fragments detected"),!w||d>o[0].pts)){n=d;var _=o[0].pts-D;o[0].dts=n,o[0].pts=_,L.log("Video: First PTS/DTS adjusted: "+Ni(_,!0)+"/"+Ni(n,!0)+", delta: "+Ni(D,!0)+" ms")}}n=Math.max(0,n);for(var C=0,P=0,x=0;x0?X.dts-o[q-1].dts:k;if(rt=q>0?X.pts-o[q-1].pts:k,it.stretchShortVideoTrack&&null!==this.nextAudioPts){var at=Math.floor(it.maxBufferHole*s),st=(i?y+i*s:this.nextAudioPts)-X.pts;st>at?((m=st-nt)<0?m=nt:H=!0,L.log("[mp4-remuxer]: It is approximately "+st/90+" ms to the next segment; using duration "+m/90+" ms for the last video frame.")):m=nt}else m=nt}var ot=Math.round(X.pts-X.dts);V=Math.min(V,m),W=Math.max(W,m),Y=Math.min(Y,rt),j=Math.max(j,rt),l.push(new Wi(X.key,m,Q,ot))}if(l.length)if(Ui){if(Ui<70){var lt=l[0].flags;lt.dependsOn=2,lt.isNonSync=0}}else if(Bi&&j-Y0&&(i&&Math.abs(E-T)<9e3||Math.abs(Ki(m[0].pts-S,E)-T)<20*l),m.forEach((function(t){t.pts=Ki(t.pts-S,E)})),!r||T<0){if(!(m=m.filter((function(t){return t.pts>=0}))).length)return;T=0===n?0:i&&!f?Math.max(0,E):m[0].pts}if("aac"===t.segmentCodec)for(var b=this.config.maxAudioFramesDrift,A=0,R=T;A=b*l&&w<1e4&&f){var _=Math.round(I/l);(R=D-_*l)<0&&(_--,R+=l),0===A&&(this.nextAudioPts=T=R),L.warn("[mp4-remuxer]: Injecting "+_+" audio frame @ "+(R/a).toFixed(3)+"s due to "+Math.round(1e3*I/a)+" ms gap.");for(var C=0;C<_;C++){var P=Math.max(R,0),x=xi.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);x||(L.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),x=k.unit.subarray()),m.splice(A,0,{unit:x,pts:P}),R+=l,A++}}k.pts=R,R+=l}for(var F,O=null,M=null,N=0,U=m.length;U--;)N+=m[U].unit.byteLength;for(var B=0,G=m.length;B0))return;N+=y;try{F=new Uint8Array(N)}catch(t){return void this.observer.emit(p.ERROR,p.ERROR,{type:g.MUX_ERROR,details:v.REMUX_ALLOC_ERROR,fatal:!1,error:t,bytes:N,reason:"fail allocating audio mdat "+N})}h||(new DataView(F.buffer).setUint32(0,N),F.set(Oi.types.mdat,4))}F.set(H,y);var Y=H.byteLength;y+=Y,d.push(new Wi(!0,o,Y,0)),M=V}var W=d.length;if(W){var j=d[d.length-1];this.nextAudioPts=T=M+s*j.duration;var q=h?new Uint8Array(0):Oi.moof(t.sequenceNumber++,O/s,c({},t,{samples:d}));t.samples=[];var X=O/a,z=T/a,Q={data1:q,data2:F,startPTS:X,endPTS:z,startDTS:X,endDTS:z,type:"audio",hasAudio:!0,hasVideo:!1,nb:W};return this.isAudioContiguous=!0,Q}},Gi.prototype.remuxEmptyAudio=function(t,e,r,i){var n=t.inputTimeScale,a=n/(t.samplerate?t.samplerate:n),s=this.nextAudioPts,o=this._initDTS,l=9e4*o.baseTime/o.timescale,u=(null!==s?s:i.startDTS*n)+l,h=i.endDTS*n+l,d=1024*a,c=Math.ceil((h-u)/d),f=xi.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);if(L.warn("[mp4-remuxer]: remux empty Audio"),f){for(var p=[],g=0;g4?r:"hvc1"===r||"hev1"===r?"hvc1.1.6.L120.90":"av01"===r?"av01.0.04M.08":"avc1"===r||e===C?"avc1.42e01e":"mp4a.40.5"}qi.prototype.destroy=function(){},qi.prototype.resetTimeStamp=function(t){this.initPTS=t,this.lastEndTime=null},qi.prototype.resetNextTimestamp=function(){this.lastEndTime=null},qi.prototype.resetInitSegment=function(t,e,r,i){this.audioCodec=e,this.videoCodec=r,this.generateInitSegment(function(t,e){if(!t||!e)return t;var r=e.keyId;return r&&e.isCommonEncryption&&At(t,["moov","trak"]).forEach((function(t){var e=At(t,["mdia","minf","stbl","stsd"])[0].subarray(8),i=At(e,["enca"]),n=i.length>0;n||(i=At(e,["encv"])),i.forEach((function(t){At(n?t.subarray(28):t.subarray(78),["sinf"]).forEach((function(t){var e=Dt(t);if(e){var i=e.subarray(8,24);i.some((function(t){return 0!==t}))||(L.log("[eme] Patching keyId in 'enc"+(n?"a":"v")+">sinf>>tenc' box: "+gt(i)+" -> "+gt(r)),e.set(r,8))}}))}))})),t}(t,i)),this.emitInitSegment=!0},qi.prototype.generateInitSegment=function(t){var e=this.audioCodec,r=this.videoCodec;if(null==t||!t.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var i=this.initData=kt(t);e||(e=Xi(i.audio,_)),r||(r=Xi(i.video,C));var n={};i.audio&&i.video?n.audiovideo={container:"video/mp4",codec:e+","+r,initSegment:t,id:"main"}:i.audio?n.audio={container:"audio/mp4",codec:e,initSegment:t,id:"audio"}:i.video?n.video={container:"video/mp4",codec:r,initSegment:t,id:"main"}:L.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=n},qi.prototype.remux=function(t,e,r,i,n,a){var s,o,l=this.initPTS,u=this.lastEndTime,h={audio:void 0,video:void 0,text:i,id3:r,initSegment:void 0};f(u)||(u=this.lastEndTime=n||0);var d=e.samples;if(null==d||!d.length)return h;var c={initPTS:void 0,timescale:1},p=this.initData;if(null!=(s=p)&&s.length||(this.generateInitSegment(d),p=this.initData),null==(o=p)||!o.length)return L.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),h;this.emitInitSegment&&(c.tracks=this.initTracks,this.emitInitSegment=!1);var g=function(t,e){for(var r=0,i=0,n=0,a=At(t,["moof","traf"]),s=0;sn}(l,m,n,g)||c.timescale!==l.timescale&&a)&&(c.initPTS=m-n,l&&1===l.timescale&&L.warn("Adjusting initPTS by "+(c.initPTS-l.baseTime)),this.initPTS=l={baseTime:c.initPTS,timescale:1});var y=t?m-l.baseTime/l.timescale:u,T=y+g;!function(t,e,r){At(e,["moof","traf"]).forEach((function(e){At(e,["tfhd"]).forEach((function(i){var n=St(i,4),a=t[n];if(a){var s=a.timescale||9e4;At(e,["tfdt"]).forEach((function(t){var e=t[0],i=St(t,4);if(0===e)i-=r*s,bt(t,4,i=Math.max(i,0));else{i*=Math.pow(2,32),i+=St(t,8),i-=r*s,i=Math.max(i,0);var n=Math.floor(i/(vt+1)),a=Math.floor(i%(vt+1));bt(t,4,n),bt(t,8,a)}}))}}))}))}(p,d,l.baseTime/l.timescale),g>0?this.lastEndTime=T:(L.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var E=!!p.audio,S=!!p.video,b="";E&&(b+="audio"),S&&(b+="video");var A={data1:d,startPTS:y,startDTS:y,endPTS:T,endDTS:T,type:b,hasAudio:E,hasVideo:S,nb:1,dropped:0};return h.audio="audio"===A.type?A:void 0,h.video="audio"!==A.type?A:void 0,h.initSegment=c,h.id3=Hi(r,n,l,l),i.samples.length&&(h.text=Vi(i,n,l)),h};try{Yi=self.performance.now.bind(self.performance)}catch(t){L.debug("Unable to use Performance API on this environment"),Yi="undefined"!=typeof self&&self.Date.now}var zi=[{demux:di,remux:qi},{demux:Ri,remux:Gi},{demux:ui,remux:Gi},{demux:Pi,remux:Gi}],Qi=function(t,e,r,i,n){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=t,this.typeSupported=e,this.config=r,this.vendor=i,this.id=n};Qi.prototype.configure=function(t){this.transmuxConfig=t,this.decrypter&&this.decrypter.reset()},Qi.prototype.push=function(t,e,r,i){var n=this,a=r.transmuxing;a.executeStart=Yi();var s=new Uint8Array(t),o=this.currentTransmuxState,l=this.transmuxConfig;i&&(this.currentTransmuxState=i);var u=i||o,h=u.contiguous,d=u.discontinuity,c=u.trackSwitch,f=u.accurateTimeOffset,m=u.timeOffset,y=u.initSegmentChange,T=l.audioCodec,E=l.videoCodec,S=l.defaultInitPts,b=l.duration,A=l.initSegmentData,R=function(t,e){var r=null;t.byteLength>0&&null!=e&&null!=e.key&&null!==e.iv&&null!=e.method&&(r=e);return r}(s,e);if(R&&"AES-128"===R.method){var k=this.getDecrypter();if(!k.isSync())return this.decryptionPromise=k.webCryptoDecrypt(s,R.key.buffer,R.iv.buffer).then((function(t){var e=n.push(t,null,r);return n.decryptionPromise=null,e})),this.decryptionPromise;var D=k.softwareDecrypt(s,R.key.buffer,R.iv.buffer);if(r.part>-1&&(D=k.flush()),!D)return a.executeEnd=Yi(),$i(r);s=new Uint8Array(D)}var I=this.needsProbing(d,c);if(I){var w=this.configureTransmuxer(s);if(w)return L.warn("[transmuxer] "+w.message),this.observer.emit(p.ERROR,p.ERROR,{type:g.MEDIA_ERROR,details:v.FRAG_PARSING_ERROR,fatal:!1,error:w,reason:w.message}),a.executeEnd=Yi(),$i(r)}(d||c||y||I)&&this.resetInitSegment(A,T,E,b,e),(d||y||I)&&this.resetInitialTimestamp(S),h||this.resetContiguity();var _=this.transmux(s,R,m,f,r),C=this.currentTransmuxState;return C.contiguous=!0,C.discontinuity=!1,C.trackSwitch=!1,a.executeEnd=Yi(),_},Qi.prototype.flush=function(t){var e=this,r=t.transmuxing;r.executeStart=Yi();var i=this,n=i.decrypter,a=i.currentTransmuxState,s=i.decryptionPromise;if(s)return s.then((function(){return e.flush(t)}));var o=[],l=a.timeOffset;if(n){var u=n.flush();u&&o.push(this.push(u,null,t))}var h=this.demuxer,d=this.remuxer;if(!h||!d)return r.executeEnd=Yi(),[$i(t)];var c=h.flush(l);return Ji(c)?c.then((function(r){return e.flushRemux(o,r,t),o})):(this.flushRemux(o,c,t),o)},Qi.prototype.flushRemux=function(t,e,r){var i=e.audioTrack,n=e.videoTrack,a=e.id3Track,s=e.textTrack,o=this.currentTransmuxState,l=o.accurateTimeOffset,u=o.timeOffset;L.log("[transmuxer.ts]: Flushed fragment "+r.sn+(r.part>-1?" p: "+r.part:"")+" of level "+r.level);var h=this.remuxer.remux(i,n,a,s,u,l,!0,this.id);t.push({remuxResult:h,chunkMeta:r}),r.transmuxing.executeEnd=Yi()},Qi.prototype.resetInitialTimestamp=function(t){var e=this.demuxer,r=this.remuxer;e&&r&&(e.resetTimeStamp(t),r.resetTimeStamp(t))},Qi.prototype.resetContiguity=function(){var t=this.demuxer,e=this.remuxer;t&&e&&(t.resetContiguity(),e.resetNextTimestamp())},Qi.prototype.resetInitSegment=function(t,e,r,i,n){var a=this.demuxer,s=this.remuxer;a&&s&&(a.resetInitSegment(t,e,r,i),s.resetInitSegment(t,e,r,n))},Qi.prototype.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},Qi.prototype.transmux=function(t,e,r,i,n){return e&&"SAMPLE-AES"===e.method?this.transmuxSampleAes(t,e,r,i,n):this.transmuxUnencrypted(t,r,i,n)},Qi.prototype.transmuxUnencrypted=function(t,e,r,i){var n=this.demuxer.demux(t,e,!1,!this.config.progressive),a=n.audioTrack,s=n.videoTrack,o=n.id3Track,l=n.textTrack;return{remuxResult:this.remuxer.remux(a,s,o,l,e,r,!1,this.id),chunkMeta:i}},Qi.prototype.transmuxSampleAes=function(t,e,r,i,n){var a=this;return this.demuxer.demuxSampleAes(t,e,r).then((function(t){return{remuxResult:a.remuxer.remux(t.audioTrack,t.videoTrack,t.id3Track,t.textTrack,r,i,!1,a.id),chunkMeta:n}}))},Qi.prototype.configureTransmuxer=function(t){for(var e,r=this,i=r.config,n=r.observer,a=r.typeSupported,s=r.vendor,o=0,l=zi.length;o1&&l.id===(null==v?void 0:v.stats.chunkCount),b=!y&&(1===T||0===T&&(1===E||S&&E<=0)),A=self.performance.now();(y||T||0===n.stats.parsing.start)&&(n.stats.parsing.start=A),!a||!E&&b||(a.stats.parsing.start=A);var R=!(v&&(null==(h=n.initSegment)?void 0:h.url)===(null==(d=v.initSegment)?void 0:d.url)),k=new tn(m,b,o,y,p,R);if(!b||m||R){L.log("[transmuxer-interface, "+n.type+"]: Starting new transmux session for sn: "+l.sn+" p: "+l.part+" level: "+l.level+" id: "+l.id+"\n discontinuity: "+m+"\n trackSwitch: "+y+"\n contiguous: "+b+"\n accurateTimeOffset: "+o+"\n timeOffset: "+p+"\n initSegmentChange: "+R);var D=new Zi(r,i,e,s,u);this.configureTransmuxer(D)}if(this.frag=n,this.part=a,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:t,decryptdata:g,chunkMeta:l,state:k},t instanceof ArrayBuffer?[t]:[]);else if(f){var I=f.push(t,g,l,k);Ji(I)?(f.async=!0,I.then((function(t){c.handleTransmuxComplete(t)})).catch((function(t){c.transmuxerError(t,l,"transmuxer-interface push error")}))):(f.async=!1,this.handleTransmuxComplete(I))}},an.prototype.flush=function(t){var e=this;t.transmuxing.start=self.performance.now();var r=this.transmuxer;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:t});else if(r){var i=r.flush(t);Ji(i)||r.async?(Ji(i)||(i=Promise.resolve(i)),i.then((function(r){e.handleFlushResult(r,t)})).catch((function(r){e.transmuxerError(r,t,"transmuxer-interface flush error")}))):this.handleFlushResult(i,t)}},an.prototype.transmuxerError=function(t,e,r){this.hls&&(this.error=t,this.hls.trigger(p.ERROR,{type:g.MEDIA_ERROR,details:v.FRAG_PARSING_ERROR,chunkMeta:e,fatal:!1,error:t,err:t,reason:r}))},an.prototype.handleFlushResult=function(t,e){var r=this;t.forEach((function(t){r.handleTransmuxComplete(t)})),this.onFlush(e)},an.prototype.onWorkerMessage=function(t){var e=t.data,r=this.hls;switch(e.event){case"init":var i,n=null==(i=this.workerContext)?void 0:i.objectURL;n&&self.URL.revokeObjectURL(n);break;case"transmuxComplete":this.handleTransmuxComplete(e.data);break;case"flush":this.onFlush(e.data);break;case"workerLog":L[e.data.logType]&&L[e.data.logType](e.data.message);break;default:e.data=e.data||{},e.data.frag=this.frag,e.data.id=this.id,r.trigger(e.event,e.data)}},an.prototype.configureTransmuxer=function(t){var e=this.transmuxer;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:t}):e&&e.configure(t)},an.prototype.handleTransmuxComplete=function(t){t.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(t)};var sn=function(t,e,r,i){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=t,this.media=e,this.fragmentTracker=r,this.hls=i};sn.prototype.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},sn.prototype.poll=function(t,e){var r=this,i=r.config,n=r.media,a=r.stalled;if(null!==n){var s=n.currentTime,o=n.seeking,l=this.seeking&&!o,u=!this.seeking&&o;if(this.seeking=o,s===t){if(u||l)this.stalled=null;else if(!(n.paused&&!o||n.ended||0===n.playbackRate)&&kr.getBuffered(n).length){var h=kr.bufferInfo(n,s,0),d=h.len>0,c=h.nextStart||0;if(d||c){if(o){var f=h.len>2,p=!c||e&&e.start<=s||c-s>2&&!this.fragmentTracker.getPartialFragment(s);if(f||p)return;this.moved=!1}if(!this.moved&&null!==this.stalled){var g,v=Math.max(c,h.start||0)-s,m=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,y=(null==m||null==(g=m.details)?void 0:g.live)?2*m.details.targetduration:2,T=this.fragmentTracker.getPartialFragment(s);if(v>0&&(v<=y||T))return void this._trySkipBufferHole(T)}var E=self.performance.now();if(null!==a){var S=E-a;if(o||!(S>=250)||(this._reportStall(h),this.media)){var b=kr.bufferInfo(n,s,i.maxBufferHole);this._tryFixBufferStall(b,S)}}else this.stalled=E}}}else if(this.moved=!0,null!==a){if(this.stallReported){var A=self.performance.now()-a;L.warn("playback not stuck anymore @"+s+", after "+Math.round(A)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}}},sn.prototype._tryFixBufferStall=function(t,e){var r=this,i=r.config,n=r.fragmentTracker,a=r.media;if(null!==a){var s=a.currentTime,o=n.getPartialFragment(s);if(o)if(this._trySkipBufferHole(o)||!this.media)return;(t.len>i.maxBufferHole||t.nextStart&&t.nextStart-s1e3*i.highBufferWatchdogPeriod&&(L.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},sn.prototype._reportStall=function(t){var e=this,r=e.hls,i=e.media;if(!e.stallReported&&i){this.stallReported=!0;var n=new Error("Playback stalling at @"+i.currentTime+" due to low buffer ("+JSON.stringify(t)+")");L.warn(n.message),r.trigger(p.ERROR,{type:g.MEDIA_ERROR,details:v.BUFFER_STALLED_ERROR,fatal:!1,error:n,buffer:t.len})}},sn.prototype._trySkipBufferHole=function(t){var e=this,r=e.config,i=e.hls,n=e.media;if(null===n)return 0;var a=n.currentTime,s=kr.bufferInfo(n,a,0),o=a0&&s.len<1&&n.readyState<3,h=o-a;if(h>0&&(l||u)){if(h>r.maxBufferHole){var d=this.fragmentTracker,c=!1;if(0===a){var f=d.getAppendedFrag(0,he);f&&o1?(i=0,this.bitrateTest=!0):i=r.nextAutoLevel),this.level=r.nextLoadLevel=i,this.loadedmetadata=!1}e>0&&-1===t&&(this.log("Override startPosition with lastCurrentTime @"+e.toFixed(3)),t=e),this.state=Br,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this._forceStartLoad=!0,this.state=Ur},e.prototype.stopLoad=function(){this._forceStartLoad=!1,t.prototype.stopLoad.call(this)},e.prototype.doTick=function(){switch(this.state){case zr:var t,e=this.levels,r=this.level,i=null==e||null==(t=e[r])?void 0:t.details;if(i&&(!i.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(i))break;this.state=Br;break}break;case Hr:var n,a=self.performance.now(),s=this.retryDate;(!s||a>=s||null!=(n=this.media)&&n.seeking)&&(this.resetStartWhenNotLoaded(this.level),this.state=Br)}this.state===Br&&this.doTickIdle(),this.onTickEnd()},e.prototype.onTickEnd=function(){t.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},e.prototype.doTickIdle=function(){var t=this,e=t.hls,r=t.levelLastLoaded,i=t.levels,n=t.media,a=e.config,s=e.nextLoadLevel;if(null!==r&&(n||!this.startFragRequested&&a.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)&&null!=i&&i[s]){var o=i[s],l=this.getMainFwdBufferInfo();if(null!==l){var u=this.getLevelDetails();if(u&&this._streamEnded(l,u)){var h={};return this.altAudio&&(h.type="video"),this.hls.trigger(p.BUFFER_EOS,h),void(this.state=jr)}e.loadLevel!==s&&-1===e.manualLevel&&this.log("Adapting to level "+s+" from level "+this.level),this.level=e.nextLoadLevel=s;var d=o.details;if(!d||this.state===zr||d.live&&this.levelLastLoaded!==s)return this.level=s,void(this.state=zr);var c=l.len,f=this.getMaxBufferLength(o.maxBitrate);if(!(c>=f)){this.backtrackFragment&&this.backtrackFragment.start>l.end&&(this.backtrackFragment=null);var g=this.backtrackFragment?this.backtrackFragment.start:l.end,v=this.getNextFragment(g,d);if(this.couldBacktrack&&!this.fragPrevious&&v&&"initSegment"!==v.sn&&this.fragmentTracker.getState(v)!==pr){var m,y=(null!=(m=this.backtrackFragment)?m:v).sn-d.startSN,T=d.fragments[y-1];T&&v.cc===T.cc&&(v=T,this.fragmentTracker.removeFragment(T))}else this.backtrackFragment&&l.len&&(this.backtrackFragment=null);if(v&&this.isLoopLoading(v,g)){if(!v.gap){var E=this.audioOnly&&!this.altAudio?_:C,S=(E===C?this.videoBuffer:this.mediaBuffer)||this.media;S&&this.afterBufferFlushed(S,E,he)}v=this.getNextFragmentLoopLoading(v,d,l,he,f)}v&&(!v.initSegment||v.initSegment.data||this.bitrateTest||(v=v.initSegment),this.loadFragment(v,o,g))}}}},e.prototype.loadFragment=function(e,r,i){var n=this.fragmentTracker.getState(e);this.fragCurrent=e,n===dr||n===fr?"initSegment"===e.sn?this._loadInitSegment(e,r):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,r)):(this.startFragRequested=!0,t.prototype.loadFragment.call(this,e,r,i)):this.clearTrackerIfNeeded(e)},e.prototype.getBufferedFrag=function(t){return this.fragmentTracker.getBufferedFrag(t,he)},e.prototype.followingBufferedFrag=function(t){return t?this.getBufferedFrag(t.end+.5):null},e.prototype.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},e.prototype.nextLevelSwitch=function(){var t=this.levels,e=this.media;if(null!=e&&e.readyState){var r,i=this.getAppendedFrag(e.currentTime);i&&i.start>1&&this.flushMainBuffer(0,i.start-1);var n=this.getLevelDetails();if(null!=n&&n.live){var a=this.getMainFwdBufferInfo();if(!a||a.len<2*n.targetduration)return}if(!e.paused&&t){var s=t[this.hls.nextLoadLevel],o=this.fragLastKbps;r=o&&this.fragCurrent?this.fragCurrent.duration*s.maxBitrate/(1e3*o)+1:0}else r=0;var l=this.getBufferedFrag(e.currentTime+r);if(l){var u=this.followingBufferedFrag(l);if(u){this.abortCurrentFrag();var h=u.maxStartPTS?u.maxStartPTS:u.start,d=u.duration,c=Math.max(l.end,h+Math.min(Math.max(d-this.config.maxFragLookUpTolerance,.5*d),.75*d));this.flushMainBuffer(c,Number.POSITIVE_INFINITY)}}}},e.prototype.abortCurrentFrag=function(){var t=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,t&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.state){case Gr:case Kr:case Hr:case Yr:case Wr:this.state=Br}this.nextLoadPosition=this.getLoadPosition()},e.prototype.flushMainBuffer=function(e,r){t.prototype.flushMainBuffer.call(this,e,r,this.altAudio?"video":null)},e.prototype.onMediaAttached=function(e,r){t.prototype.onMediaAttached.call(this,e,r);var i=r.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),i.addEventListener("playing",this.onvplaying),i.addEventListener("seeked",this.onvseeked),this.gapController=new sn(this.config,i,this.fragmentTracker,this.hls)},e.prototype.onMediaDetaching=function(){var e=this.media;e&&this.onvplaying&&this.onvseeked&&(e.removeEventListener("playing",this.onvplaying),e.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),t.prototype.onMediaDetaching.call(this)},e.prototype.onMediaPlaying=function(){this.tick()},e.prototype.onMediaSeeked=function(){var t=this.media,e=t?t.currentTime:null;f(e)&&this.log("Media seeked to "+e.toFixed(3));var r=this.getMainFwdBufferInfo();null!==r&&0!==r.len?this.tick():this.warn('Main forward buffer length on "seeked" event '+(r?r.len:"empty")+")")},e.prototype.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(p.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.levels=this.fragPlaying=this.backtrackFragment=null,this.altAudio=this.audioOnly=!1},e.prototype.onManifestParsed=function(t,e){var r,i,n,a=!1,s=!1;e.levels.forEach((function(t){(r=t.audioCodec)&&(-1!==r.indexOf("mp4a.40.2")&&(a=!0),-1!==r.indexOf("mp4a.40.5")&&(s=!0))})),this.audioCodecSwitch=a&&s&&!("function"==typeof(null==(n=$r())||null==(i=n.prototype)?void 0:i.changeType)),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=e.levels,this.startFragRequested=!1},e.prototype.onLevelLoading=function(t,e){var r=this.levels;if(r&&this.state===Br){var i=r[e.level];(!i.details||i.details.live&&this.levelLastLoaded!==e.level||this.waitForCdnTuneIn(i.details))&&(this.state=zr)}},e.prototype.onLevelLoaded=function(t,e){var r,i=this.levels,n=e.level,a=e.details,s=a.totalduration;if(i){this.log("Level "+n+" loaded ["+a.startSN+","+a.endSN+"]"+(a.lastPartSn?"[part-"+a.lastPartSn+"-"+a.lastPartIndex+"]":"")+", cc ["+a.startCC+", "+a.endCC+"] duration:"+s);var o=i[n],l=this.fragCurrent;!l||this.state!==Kr&&this.state!==Hr||l.level===e.level&&l.urlId===o.urlId||!l.loader||this.abortCurrentFrag();var u=0;if(a.live||null!=(r=o.details)&&r.live){if(a.fragments[0]||(a.deltaUpdateFailed=!0),a.deltaUpdateFailed)return;u=this.alignPlaylists(a,o.details)}if(o.details=a,this.levelLastLoaded=n,this.hls.trigger(p.LEVEL_UPDATED,{details:a,level:n}),this.state===zr){if(this.waitForCdnTuneIn(a))return;this.state=Br}this.startFragRequested?a.live&&this.synchronizeToLiveEdge(a):this.setStartPosition(a,u),this.tick()}else this.warn("Levels were reset while loading level "+n)},e.prototype._handleFragmentLoadProgress=function(t){var e,r=t.frag,i=t.part,n=t.payload,a=this.levels;if(a){var s=a[r.level],o=s.details;if(!o)return this.warn("Dropping fragment "+r.sn+" of level "+r.level+" after level details were reset"),void this.fragmentTracker.removeFragment(r);var l=s.videoCodec,u=o.PTSKnown||!o.live,h=null==(e=r.initSegment)?void 0:e.data,d=this._getAudioCodec(s),c=this.transmuxer=this.transmuxer||new an(this.hls,he,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),f=i?i.index:-1,p=-1!==f,g=new Dr(r.level,r.sn,r.stats.chunkCount,n.byteLength,f,p),v=this.initPTS[r.cc];c.push(n,h,d,l,r,i,o.totalduration,u,g,v)}else this.warn("Levels were reset while fragment load was in progress. Fragment "+r.sn+" of level "+r.level+" will not be buffered")},e.prototype.onAudioTrackSwitching=function(t,e){var r=this.altAudio;if(!!!e.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var i=this.fragCurrent;i&&(this.log("Switching to main audio track, cancel main fragment load"),i.abortRequests(),this.fragmentTracker.removeFragment(i)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var n=this.hls;r&&(n.trigger(p.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),n.trigger(p.AUDIO_TRACK_SWITCHED,e)}},e.prototype.onAudioTrackSwitched=function(t,e){var r=e.id,i=!!this.hls.audioTracks[r].url;if(i){var n=this.videoBuffer;n&&this.mediaBuffer!==n&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=n)}this.altAudio=i,this.tick()},e.prototype.onBufferCreated=function(t,e){var r,i,n=e.tracks,a=!1;for(var s in n){var o=n[s];if("main"===o.id){if(i=s,r=o,"video"===s){var l=n[s];l&&(this.videoBuffer=l.buffer)}}else a=!0}a&&r?(this.log("Alternate track found, use "+i+".buffered to schedule main fragment loading"),this.mediaBuffer=r.buffer):this.mediaBuffer=this.media},e.prototype.onFragBuffered=function(t,e){var r=e.frag,i=e.part;if(!r||r.type===he){if(this.fragContextChanged(r))return this.warn("Fragment "+r.sn+(i?" p: "+i.index:"")+" of level "+r.level+" finished buffering, but was aborted. state: "+this.state),void(this.state===Wr&&(this.state=Br));var n=i?i.stats:r.stats;this.fragLastKbps=Math.round(8*n.total/(n.buffering.end-n.loading.first)),"initSegment"!==r.sn&&(this.fragPrevious=r),this.fragBufferedComplete(r,i)}},e.prototype.onError=function(t,e){var r;if(e.fatal)this.state=qr;else switch(e.details){case v.FRAG_GAP:case v.FRAG_PARSING_ERROR:case v.FRAG_DECRYPT_ERROR:case v.FRAG_LOAD_ERROR:case v.FRAG_LOAD_TIMEOUT:case v.KEY_LOAD_ERROR:case v.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(he,e);break;case v.LEVEL_LOAD_ERROR:case v.LEVEL_LOAD_TIMEOUT:case v.LEVEL_PARSING_ERROR:e.levelRetry||this.state!==zr||(null==(r=e.context)?void 0:r.type)!==oe||(this.state=Br);break;case v.BUFFER_FULL_ERROR:if(!e.parent||"main"!==e.parent)return;this.reduceLengthAndFlushBuffer(e)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case v.INTERNAL_EXCEPTION:this.recoverWorkerError(e)}},e.prototype.checkBuffer=function(){var t=this.media,e=this.gapController;if(t&&e&&t.readyState){if(this.loadedmetadata||!kr.getBuffered(t).length){var r=this.state!==Br?this.fragCurrent:null;e.poll(this.lastCurrentTime,r)}this.lastCurrentTime=t.currentTime}},e.prototype.onFragLoadEmergencyAborted=function(){this.state=Br,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},e.prototype.onBufferFlushed=function(t,e){var r=e.type;if(r!==_||this.audioOnly&&!this.altAudio){var i=(r===C?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(i,r,he)}},e.prototype.onLevelsUpdated=function(t,e){this.levels=e.levels},e.prototype.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},e.prototype.seekToStartPos=function(){var t=this.media;if(t){var e=t.currentTime,r=this.startPosition;if(r>=0&&e0&&(n1&&!1===t.seeking){var r=t.currentTime;if(kr.isBuffered(t,r)?e=this.getAppendedFrag(r):kr.isBuffered(t,r+.1)&&(e=this.getAppendedFrag(r+.1)),e){this.backtrackFragment=null;var i=this.fragPlaying,n=e.level;i&&e.sn===i.sn&&i.level===n&&e.urlId===i.urlId||(this.fragPlaying=e,this.hls.trigger(p.FRAG_CHANGED,{frag:e}),i&&i.level===n||this.hls.trigger(p.LEVEL_SWITCHED,{level:n}))}}},r.nextLevel.get=function(){var t=this.nextBufferedFrag;return t?t.level:-1},r.currentFrag.get=function(){var t=this.media;return t?this.fragPlaying||this.getAppendedFrag(t.currentTime):null},r.currentProgramDateTime.get=function(){var t=this.media;if(t){var e=t.currentTime,r=this.currentFrag;if(r&&f(e)&&f(r.programDateTime)){var i=r.programDateTime+1e3*(e-r.start);return new Date(i)}}return null},r.currentLevel.get=function(){var t=this.currentFrag;return t?t.level:-1},r.nextBufferedFrag.get=function(){var t=this.currentFrag;return t?this.followingBufferedFrag(t):null},r.forceStartLoad.get=function(){return this._forceStartLoad},Object.defineProperties(e.prototype,r),e}(Qr),ln=function(t,e,r){void 0===e&&(e=0),void 0===r&&(r=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=t,this.alpha_=t?Math.exp(Math.log(.5)/t):0,this.estimate_=e,this.totalWeight_=r};ln.prototype.sample=function(t,e){var r=Math.pow(this.alpha_,t);this.estimate_=e*(1-r)+r*this.estimate_,this.totalWeight_+=t},ln.prototype.getTotalWeight=function(){return this.totalWeight_},ln.prototype.getEstimate=function(){if(this.alpha_){var t=1-Math.pow(this.alpha_,this.totalWeight_);if(t)return this.estimate_/t}return this.estimate_};var un=function(t,e,r,i){void 0===i&&(i=100),this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=r,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new ln(t),this.fast_=new ln(e),this.defaultTTFB_=i,this.ttfb_=new ln(t)};un.prototype.update=function(t,e){var r=this,i=r.slow_,n=r.fast_,a=r.ttfb_;i.halfLife!==t&&(this.slow_=new ln(t,i.getEstimate(),i.getTotalWeight())),n.halfLife!==e&&(this.fast_=new ln(e,n.getEstimate(),n.getTotalWeight())),a.halfLife!==t&&(this.ttfb_=new ln(t,a.getEstimate(),a.getTotalWeight()))},un.prototype.sample=function(t,e){var r=(t=Math.max(t,this.minDelayMs_))/1e3,i=8*e/r;this.fast_.sample(r,i),this.slow_.sample(r,i)},un.prototype.sampleTTFB=function(t){var e=t/1e3,r=Math.sqrt(2)*Math.exp(-Math.pow(e,2)/2);this.ttfb_.sample(r,Math.max(t,5))},un.prototype.canEstimate=function(){return this.fast_.getTotalWeight()>=this.minWeight_},un.prototype.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},un.prototype.getEstimateTTFB=function(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_},un.prototype.destroy=function(){};var hn=function(t){this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=-1,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=t;var e=t.config;this.bwEstimator=new un(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate),this.registerListeners()},dn={nextAutoLevel:{configurable:!0}};hn.prototype.registerListeners=function(){var t=this.hls;t.on(p.FRAG_LOADING,this.onFragLoading,this),t.on(p.FRAG_LOADED,this.onFragLoaded,this),t.on(p.FRAG_BUFFERED,this.onFragBuffered,this),t.on(p.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(p.LEVEL_LOADED,this.onLevelLoaded,this)},hn.prototype.unregisterListeners=function(){var t=this.hls;t.off(p.FRAG_LOADING,this.onFragLoading,this),t.off(p.FRAG_LOADED,this.onFragLoaded,this),t.off(p.FRAG_BUFFERED,this.onFragBuffered,this),t.off(p.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(p.LEVEL_LOADED,this.onLevelLoaded,this)},hn.prototype.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},hn.prototype.onFragLoading=function(t,e){var r,i=e.frag;this.ignoreFragment(i)||(this.fragCurrent=i,this.partCurrent=null!=(r=e.part)?r:null,this.clearTimer(),this.timer=self.setInterval(this.onCheck,100))},hn.prototype.onLevelSwitching=function(t,e){this.clearTimer()},hn.prototype.getTimeToLoadFrag=function(t,e,r,i){return t+r/e+(i?this.lastLevelLoadSec:0)},hn.prototype.onLevelLoaded=function(t,e){var r=this.hls.config,i=e.stats,n=i.total,a=i.bwEstimate;f(n)&&f(a)&&(this.lastLevelLoadSec=8*n/a),e.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)},hn.prototype._abandonRulesCheck=function(){var t=this,e=t.fragCurrent,r=t.partCurrent,i=t.hls,n=i.autoLevelEnabled,a=i.media;if(e&&a){var s=performance.now(),o=r?r.stats:e.stats,l=r?r.duration:e.duration,u=s-o.loading.start;if(o.aborted||o.loaded&&o.loaded===o.total||0===e.level)return this.clearTimer(),void(this._nextAutoLevel=-1);if(n&&!a.paused&&a.playbackRate&&a.readyState){var h=i.mainForwardBufferInfo;if(null!==h){var d=this.bwEstimator.getEstimateTTFB(),c=Math.abs(a.playbackRate);if(!(u<=Math.max(d,l/(2*c)*1e3))){var g=h.len/c;if(!(g>=2*l/c)){var v=o.loading.first?o.loading.first-o.loading.start:-1,m=o.loaded&&v>-1,y=this.bwEstimator.getEstimate(),T=i.levels,E=i.minAutoLevel,S=T[e.level],b=o.total||Math.max(o.loaded,Math.round(l*S.maxBitrate/8)),A=u-v;A<1&&m&&(A=Math.min(u,8*o.loaded/y));var R=m?1e3*o.loaded/A:0,k=R?(b-o.loaded)/R:8*b/y+d/1e3;if(!(k<=g)){var D,I=R?8*R:y,w=Number.POSITIVE_INFINITY;for(D=e.level-1;D>E;D--){var _=T[D].maxBitrate;if((w=this.getTimeToLoadFrag(d/1e3,I,l*_,!T[D].details))=k||w>10*l||(i.nextLoadLevel=D,m?this.bwEstimator.sample(u-Math.min(d,v),o.loaded):this.bwEstimator.sampleTTFB(u),this.clearTimer(),L.warn("[abr] Fragment "+e.sn+(r?" part "+r.index:"")+" of level "+e.level+" is loading too slowly;\n Time to underbuffer: "+g.toFixed(3)+" s\n Estimated load time for current fragment: "+k.toFixed(3)+" s\n Estimated load time for down switch fragment: "+w.toFixed(3)+" s\n TTFB estimate: "+v+"\n Current BW estimate: "+(f(y)?(y/1024).toFixed(3):"Unknown")+" Kb/s\n New BW estimate: "+(this.bwEstimator.getEstimate()/1024).toFixed(3)+" Kb/s\n Aborting and switching to level "+D),e.loader&&(this.fragCurrent=this.partCurrent=null,e.abortRequests()),i.trigger(p.FRAG_LOAD_EMERGENCY_ABORTED,{frag:e,part:r,stats:o}))}}}}}}},hn.prototype.onFragLoaded=function(t,e){var r=e.frag,i=e.part,n=i?i.stats:r.stats;if(r.type===he&&this.bwEstimator.sampleTTFB(n.loading.first-n.loading.start),!this.ignoreFragment(r)){if(this.clearTimer(),this.lastLoadedFragLevel=r.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var a=i?i.duration:r.duration,s=this.hls.levels[r.level],o=(s.loaded?s.loaded.bytes:0)+n.loaded,l=(s.loaded?s.loaded.duration:0)+a;s.loaded={bytes:o,duration:l},s.realBitrate=Math.round(8*o/l)}if(r.bitrateTest){var u={stats:n,frag:r,part:i,id:r.type};this.onFragBuffered(p.FRAG_BUFFERED,u),r.bitrateTest=!1}}},hn.prototype.onFragBuffered=function(t,e){var r=e.frag,i=e.part,n=null!=i&&i.stats.loaded?i.stats:r.stats;if(!n.aborted&&!this.ignoreFragment(r)){var a=n.parsing.end-n.loading.start-Math.min(n.loading.first-n.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(a,n.loaded),n.bwEstimate=this.bwEstimator.getEstimate(),r.bitrateTest?this.bitrateTestDelay=a/1e3:this.bitrateTestDelay=0}},hn.prototype.ignoreFragment=function(t){return t.type!==he||"initSegment"===t.sn},hn.prototype.clearTimer=function(){self.clearInterval(this.timer)},dn.nextAutoLevel.get=function(){var t=this._nextAutoLevel,e=this.bwEstimator;if(-1!==t&&!e.canEstimate())return t;var r=this.getNextABRAutoLevel();if(-1!==t){var i=this.hls.levels;if(i.length>Math.max(t,r)&&i[t].loadError<=i[r].loadError)return t}return-1!==t&&(r=Math.min(t,r)),r},hn.prototype.getNextABRAutoLevel=function(){var t=this,e=t.fragCurrent,r=t.partCurrent,i=t.hls,n=i.maxAutoLevel,a=i.config,s=i.minAutoLevel,o=i.media,l=r?r.duration:e?e.duration:0,u=o&&0!==o.playbackRate?Math.abs(o.playbackRate):1,h=this.bwEstimator?this.bwEstimator.getEstimate():a.abrEwmaDefaultEstimate,d=i.mainForwardBufferInfo,c=(d?d.len:0)/u,f=this.findBestLevel(h,s,n,c,a.abrBandWidthFactor,a.abrBandWidthUpFactor);if(f>=0)return f;L.trace("[abr] "+(c?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var p=l?Math.min(l,a.maxStarvationDelay):a.maxStarvationDelay,g=a.abrBandWidthFactor,v=a.abrBandWidthUpFactor;if(!c){var m=this.bitrateTestDelay;if(m)p=(l?Math.min(l,a.maxLoadingDelay):a.maxLoadingDelay)-m,L.trace("[abr] bitrate test took "+Math.round(1e3*m)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*p)+" ms"),g=v=1}return f=this.findBestLevel(h,s,n,c+p,g,v),Math.max(f,0)},hn.prototype.findBestLevel=function(t,e,r,i,n,a){for(var s,o=this,l=o.fragCurrent,u=o.partCurrent,h=o.lastLoadedFragLevel,d=this.hls.levels,c=d[h],p=!(null==c||null==(s=c.details)||!s.live),g=null==c?void 0:c.codecSet,v=u?u.duration:l?l.duration:0,m=this.bwEstimator.getEstimateTTFB()/1e3,y=e,T=-1,E=r;E>=e;E--){var S=d[E];if(!S||g&&S.codecSet!==g)S&&(y=Math.min(E,y),T=Math.max(E,T));else{-1!==T&&L.trace("[abr] Skipped level(s) "+y+"-"+T+' with CODECS:"'+d[T].attrs.CODECS+'"; not compatible with "'+c.attrs.CODECS+'"');var b=S.details,A=(u?null==b?void 0:b.partTarget:null==b?void 0:b.averagetargetduration)||v,R=void 0;R=E<=h?n*t:a*t;var k=d[E].maxBitrate,D=this.getTimeToLoadFrag(m,R,k*A,void 0===b);if(L.trace("[abr] level:"+E+" adjustedbw-bitrate:"+Math.round(R-k)+" avgDuration:"+A.toFixed(1)+" maxFetchDuration:"+i.toFixed(1)+" fetchDuration:"+D.toFixed(1)),R>k&&(0===D||!f(D)||p&&!this.bitrateTestDelay||D0&&-1===t?(this.log("Override startPosition with lastCurrentTime @"+e.toFixed(3)),t=e,this.state=Br):(this.loadedmetadata=!1,this.state=Vr),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()},e.prototype.doTick=function(){switch(this.state){case Br:this.doTickIdle();break;case Vr:var e,r=this.levels,i=this.trackId,n=null==r||null==(e=r[i])?void 0:e.details;if(n){if(this.waitForCdnTuneIn(n))break;this.state=Xr}break;case Hr:var a,s=performance.now(),o=this.retryDate;(!o||s>=o||null!=(a=this.media)&&a.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=Br);break;case Xr:var l=this.waitingData;if(l){var u=l.frag,h=l.part,d=l.cache,c=l.complete;if(void 0!==this.initPTS[u.cc]){this.waitingData=null,this.waitingVideoCC=-1,this.state=Kr;var f={frag:u,part:h,payload:d.flush(),networkDetails:null};this._handleFragmentLoadProgress(f),c&&t.prototype._handleFragmentLoadComplete.call(this,f)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log("Waiting fragment cc ("+u.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var p=this.getLoadPosition(),g=kr.bufferInfo(this.mediaBuffer,p,this.config.maxBufferHole);Qe(g.end,this.config.maxFragLookUpTolerance,u)<0&&(this.log("Waiting fragment cc ("+u.cc+") @ "+u.start+" cancelled because another fragment at "+g.end+" is needed"),this.clearWaitingFragment())}}else this.state=Br}this.onTickEnd()},e.prototype.clearWaitingFragment=function(){var t=this.waitingData;t&&(this.fragmentTracker.removeFragment(t.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=Br)},e.prototype.resetLoadingState=function(){this.clearWaitingFragment(),t.prototype.resetLoadingState.call(this)},e.prototype.onTickEnd=function(){var t=this.media;null!=t&&t.readyState&&(this.lastCurrentTime=t.currentTime)},e.prototype.doTickIdle=function(){var t=this,e=t.hls,r=t.levels,i=t.media,n=t.trackId,a=e.config;if(null!=r&&r[n]&&(i||!this.startFragRequested&&a.startFragPrefetch)){var s=r[n],o=s.details;if(!o||o.live&&this.levelLastLoaded!==n||this.waitForCdnTuneIn(o))this.state=Vr;else{var l=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&l&&(this.bufferFlushed=!1,this.afterBufferFlushed(l,_,de));var u=this.getFwdBufferInfo(l,de);if(null!==u){var h=this.bufferedTrack,d=this.switchingTrack;if(!d&&this._streamEnded(u,o))return e.trigger(p.BUFFER_EOS,{type:"audio"}),void(this.state=jr);var c=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,he),f=u.len,g=this.getMaxBufferLength(null==c?void 0:c.len);if(!(f>=g)||d){var v=o.fragments[0].start,m=u.end;if(d&&i){var y=this.getLoadPosition();h&&d.attrs!==h.attrs&&(m=y),o.PTSKnown&&yv||u.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),i.currentTime=v+.05)}var T=this.getNextFragment(m,o),E=!1;if(T&&this.isLoopLoading(T,m)&&(E=!!T.gap,T=this.getNextFragmentLoopLoading(T,o,u,he,g)),T){var S=c&&T.start>c.end+o.targetduration;if(S||(null==c||!c.len)&&u.len){var L=this.getAppendedFrag(T.start,he);if(null===L)return;if(E||(E=!!L.gap||!!S&&0===c.len),S&&!E||E&&u.nextStart&&u.nextStart=e.length)this.warn("Invalid id passed to audio-track controller");else{this.clearTimer();var r=this.currentTrack;e[this.trackId];var i=e[t],n=i.groupId,a=i.name;if(this.log("Switching to audio-track "+t+' "'+a+'" lang:'+i.lang+" group:"+n),this.trackId=t,this.currentTrack=i,this.selectDefaultTrack=!1,this.hls.trigger(p.AUDIO_TRACK_SWITCHING,h({},i)),!i.details||i.details.live){var s=this.switchParams(i.url,null==r?void 0:r.details);this.loadPlaylist(s)}}},e.prototype.selectInitialTrack=function(){var t=this.tracksInGroup,e=this.findTrackId(this.currentTrack)|this.findTrackId(null);if(-1!==e)this.setAudioTrack(e);else{var r=new Error("No track found for running audio group-ID: "+this.groupId+" track count: "+t.length);this.warn(r.message),this.hls.trigger(p.ERROR,{type:g.MEDIA_ERROR,details:v.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:r})}},e.prototype.findTrackId=function(t){for(var e=this.tracksInGroup,r=0;r=n[o].start&&s<=n[o].end){a=n[o];break}var l=r.start+r.duration;a?a.end=l:(a={start:s,end:l},n.push(a)),this.fragmentTracker.fragBuffered(r)}}},e.prototype.onBufferFlushing=function(t,e){var r=e.startOffset,i=e.endOffset;if(0===r&&i!==Number.POSITIVE_INFINITY){var n=this.currentTrackId,a=this.levels;if(!a.length||!a[n]||!a[n].details)return;var s=i-a[n].details.targetduration;if(s<=0)return;e.endOffsetSubtitles=Math.max(0,s),this.tracksBuffered.forEach((function(t){for(var e=0;e=s.length||n!==a)&&o){this.mediaBuffer=this.mediaBufferTimeRanges;var l=0;if(i.live||null!=(r=o.details)&&r.live){var u=this.mainDetails;if(i.deltaUpdateFailed||!u)return;var h=u.fragments[0];o.details?0===(l=this.alignPlaylists(i,o.details))&&h&&Ge(i,l=h.start):i.hasProgramDateTime&&u.hasProgramDateTime?(Pr(i,u),l=i.fragments[0].start):h&&Ge(i,l=h.start)}if(o.details=i,this.levelLastLoaded=n,this.startFragRequested||!this.mainDetails&&i.live||this.setStartPosition(o.details,l),this.tick(),i.live&&!this.fragCurrent&&this.media&&this.state===Br)ze(null,i.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),o.details=void 0)}}},e.prototype._handleFragmentLoadComplete=function(t){var e=this,r=t.frag,i=t.payload,n=r.decryptdata,a=this.hls;if(!this.fragContextChanged(r)&&i&&i.byteLength>0&&n&&n.key&&n.iv&&"AES-128"===n.method){var s=performance.now();this.decrypter.decrypt(new Uint8Array(i),n.key.buffer,n.iv.buffer).catch((function(t){throw a.trigger(p.ERROR,{type:g.MEDIA_ERROR,details:v.FRAG_DECRYPT_ERROR,fatal:!1,error:t,reason:t.message,frag:r}),t})).then((function(t){var e=performance.now();a.trigger(p.FRAG_DECRYPTED,{frag:r,payload:t,stats:{tstart:s,tdecrypt:e}})})).catch((function(t){e.warn(t.name+": "+t.message),e.state=Br}))}},e.prototype.doTick=function(){if(this.media){if(this.state===Br){var t=this.currentTrackId,e=this.levels,r=e[t];if(!e.length||!r||!r.details)return;var i=r.details,n=i.targetduration,a=this.config,s=this.getLoadPosition(),o=kr.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],s-n,a.maxBufferHole),l=o.end,u=o.len,h=this.getFwdBufferInfo(this.media,he);if(u>this.getMaxBufferLength(null==h?void 0:h.len)+n)return;var d=i.fragments,c=d.length,f=i.edge,p=null,g=this.fragPrevious;if(l>>=0)>i-1)throw new DOMException("Failed to execute '"+e+"' on 'TimeRanges': The index provided ("+r+") is greater than the maximum bound ("+i+")");return t[r][e]};this.buffered={get length(){return t.length},end:function(r){return e("end",r,t.length)},start:function(r){return e("start",r,t.length)}}},Tn=function(t){function e(e){var r=this;t.call(this,e,"[subtitle-track-controller]"),this.media=null,this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0,this.queuedDefaultTrack=-1,this.trackChangeListener=function(){return r.onTextTracksChanged()},this.asyncPollTrackChange=function(){return r.pollTrackChange(0)},this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.registerListeners()}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={subtitleDisplay:{configurable:!0},subtitleTracks:{configurable:!0},subtitleTrack:{configurable:!0}};return e.prototype.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,t.prototype.destroy.call(this)},r.subtitleDisplay.get=function(){return this._subtitleDisplay},r.subtitleDisplay.set=function(t){this._subtitleDisplay=t,this.trackId>-1&&this.toggleTrackModes(this.trackId)},e.prototype.registerListeners=function(){var t=this.hls;t.on(p.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(p.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(p.MANIFEST_LOADING,this.onManifestLoading,this),t.on(p.MANIFEST_PARSED,this.onManifestParsed,this),t.on(p.LEVEL_LOADING,this.onLevelLoading,this),t.on(p.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(p.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(p.ERROR,this.onError,this)},e.prototype.unregisterListeners=function(){var t=this.hls;t.off(p.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(p.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(p.MANIFEST_LOADING,this.onManifestLoading,this),t.off(p.MANIFEST_PARSED,this.onManifestParsed,this),t.off(p.LEVEL_LOADING,this.onLevelLoading,this),t.off(p.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(p.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(p.ERROR,this.onError,this)},e.prototype.onMediaAttached=function(t,e){this.media=e.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))},e.prototype.pollTrackChange=function(t){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,t)},e.prototype.onMediaDetaching=function(){this.media&&(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),En(this.media.textTracks).forEach((function(t){ye(t)})),this.subtitleTrack=-1,this.media=null)},e.prototype.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},e.prototype.onManifestParsed=function(t,e){this.tracks=e.subtitleTracks},e.prototype.onSubtitleTrackLoaded=function(t,e){var r=e.id,i=e.details,n=this.trackId,a=this.tracksInGroup[n];if(a){var s=a.details;a.details=e.details,this.log("subtitle track "+r+" loaded ["+i.startSN+"-"+i.endSN+"]"),r===this.trackId&&this.playlistLoaded(r,e,s)}else this.warn("Invalid subtitle track id "+r)},e.prototype.onLevelLoading=function(t,e){this.switchLevel(e.level)},e.prototype.onLevelSwitching=function(t,e){this.switchLevel(e.level)},e.prototype.switchLevel=function(t){var e=this.hls.levels[t];if(null!=e&&e.textGroupIds){var r=e.textGroupIds[e.urlId],i=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;if(this.groupId!==r){var n=this.tracks.filter((function(t){return!r||t.groupId===r}));this.tracksInGroup=n;var a=this.findTrackId(null==i?void 0:i.name)||this.findTrackId();this.groupId=r||null;var s={subtitleTracks:n};this.log("Updating subtitle tracks, "+n.length+' track(s) found in "'+r+'" group-id'),this.hls.trigger(p.SUBTITLE_TRACKS_UPDATED,s),-1!==a&&this.setSubtitleTrack(a,i)}else this.shouldReloadPlaylist(i)&&this.setSubtitleTrack(this.trackId,i)}},e.prototype.findTrackId=function(t){for(var e=this.tracksInGroup,r=0;r=i.length)){this.clearTimer();var n=i[t];if(this.log("Switching to subtitle-track "+t+(n?' "'+n.name+'" lang:'+n.lang+" group:"+n.groupId:"")),this.trackId=t,n){var a=n.id,s=n.groupId;void 0===s&&(s="");var o=n.name,l=n.type,u=n.url;this.hls.trigger(p.SUBTITLE_TRACK_SWITCH,{id:a,groupId:s,name:o,type:l,url:u});var h=this.switchParams(n.url,null==e?void 0:e.details);this.loadPlaylist(h)}else this.hls.trigger(p.SUBTITLE_TRACK_SWITCH,{id:t})}}else this.queuedDefaultTrack=t},e.prototype.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),this.media&&this.hls.config.renderTextTracksNatively){for(var t=-1,e=En(this.media.textTracks),r=0;r "+r.src+")")},this.hls=t,this._initSourceBuffer(),this.registerListeners()};An.prototype.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},An.prototype.destroy=function(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null},An.prototype.registerListeners=function(){var t=this.hls;t.on(p.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(p.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(p.MANIFEST_LOADING,this.onManifestLoading,this),t.on(p.MANIFEST_PARSED,this.onManifestParsed,this),t.on(p.BUFFER_RESET,this.onBufferReset,this),t.on(p.BUFFER_APPENDING,this.onBufferAppending,this),t.on(p.BUFFER_CODECS,this.onBufferCodecs,this),t.on(p.BUFFER_EOS,this.onBufferEos,this),t.on(p.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(p.LEVEL_UPDATED,this.onLevelUpdated,this),t.on(p.FRAG_PARSED,this.onFragParsed,this),t.on(p.FRAG_CHANGED,this.onFragChanged,this)},An.prototype.unregisterListeners=function(){var t=this.hls;t.off(p.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(p.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(p.MANIFEST_LOADING,this.onManifestLoading,this),t.off(p.MANIFEST_PARSED,this.onManifestParsed,this),t.off(p.BUFFER_RESET,this.onBufferReset,this),t.off(p.BUFFER_APPENDING,this.onBufferAppending,this),t.off(p.BUFFER_CODECS,this.onBufferCodecs,this),t.off(p.BUFFER_EOS,this.onBufferEos,this),t.off(p.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(p.LEVEL_UPDATED,this.onLevelUpdated,this),t.off(p.FRAG_PARSED,this.onFragParsed,this),t.off(p.FRAG_CHANGED,this.onFragChanged,this)},An.prototype._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new Sn(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.lastMpegAudioChunk=null},An.prototype.onManifestLoading=function(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null},An.prototype.onManifestParsed=function(t,e){var r=2;(e.audio&&!e.video||!e.altAudio)&&(r=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r,L.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},An.prototype.onMediaAttaching=function(t,e){var r=this.media=e.media;if(r&&Ln){var i=this.mediaSource=new Ln;i.addEventListener("sourceopen",this._onMediaSourceOpen),i.addEventListener("sourceended",this._onMediaSourceEnded),i.addEventListener("sourceclose",this._onMediaSourceClose),r.src=self.URL.createObjectURL(i),this._objectUrl=r.src,r.addEventListener("emptied",this._onMediaEmptied)}},An.prototype.onMediaDetaching=function(){var t=this,e=t.media,r=t.mediaSource,i=t._objectUrl;if(r){if(L.log("[buffer-controller]: media source detaching"),"open"===r.readyState)try{r.endOfStream()}catch(t){L.warn("[buffer-controller]: onMediaDetaching: "+t.message+" while calling endOfStream")}this.onBufferReset(),r.removeEventListener("sourceopen",this._onMediaSourceOpen),r.removeEventListener("sourceended",this._onMediaSourceEnded),r.removeEventListener("sourceclose",this._onMediaSourceClose),e&&(e.removeEventListener("emptied",this._onMediaEmptied),i&&self.URL.revokeObjectURL(i),e.src===i?(e.removeAttribute("src"),e.load()):L.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(p.MEDIA_DETACHED,void 0)},An.prototype.onBufferReset=function(){var t=this;this.getSourceBufferTypes().forEach((function(e){var r=t.sourceBuffer[e];try{r&&(t.removeBufferListeners(e),t.mediaSource&&t.mediaSource.removeSourceBuffer(r),t.sourceBuffer[e]=void 0)}catch(t){L.warn("[buffer-controller]: Failed to reset the "+e+" buffer",t)}})),this._initSourceBuffer()},An.prototype.onBufferCodecs=function(t,e){var r=this,i=this.getSourceBufferTypes().length;Object.keys(e).forEach((function(t){if(i){var n=r.tracks[t];if(n&&"function"==typeof n.buffer.changeType){var a=e[t],s=a.id,o=a.codec,l=a.levelCodec,u=a.container,h=a.metadata,d=(n.levelCodec||n.codec).replace(bn,"$1"),c=(l||o).replace(bn,"$1");if(d!==c){var f=u+";codecs="+(l||o);r.appendChangeType(t,f),L.log("[buffer-controller]: switching codec "+d+" to "+c),r.tracks[t]={buffer:n.buffer,codec:o,container:u,levelCodec:l,metadata:h,id:s}}}}else r.pendingTracks[t]=e[t]})),i||(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks())},An.prototype.appendChangeType=function(t,e){var r=this,i=this.operationQueue,n={execute:function(){var n=r.sourceBuffer[t];n&&(L.log("[buffer-controller]: changing "+t+" sourceBuffer type to "+e),n.changeType(e)),i.shiftAndExecuteNext(t)},onStart:function(){},onComplete:function(){},onError:function(e){L.warn("[buffer-controller]: Failed to change "+t+" SourceBuffer type",e)}};i.append(n,t)},An.prototype.onBufferAppending=function(t,e){var r=this,i=this,n=i.hls,a=i.operationQueue,s=i.tracks,o=e.data,l=e.type,u=e.frag,h=e.part,d=e.chunkMeta,c=d.buffering[l],f=self.performance.now();c.start=f;var m=u.stats.buffering,y=h?h.stats.buffering:null;0===m.start&&(m.start=f),y&&0===y.start&&(y.start=f);var T=s.audio,E=!1;"audio"===l&&"audio/mpeg"===(null==T?void 0:T.container)&&(E=!this.lastMpegAudioChunk||1===d.id||this.lastMpegAudioChunk.sn!==d.sn,this.lastMpegAudioChunk=d);var S=u.start,b={execute:function(){if(c.executeStart=self.performance.now(),E){var t=r.sourceBuffer[l];if(t){var e=S-t.timestampOffset;Math.abs(e)>=.1&&(L.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+S+" (delta: "+e+") sn: "+u.sn+")"),t.timestampOffset=S)}}r.appendExecutor(o,l)},onStart:function(){},onComplete:function(){var t=self.performance.now();c.executeEnd=c.end=t,0===m.first&&(m.first=t),y&&0===y.first&&(y.first=t);var e=r.sourceBuffer,i={};for(var n in e)i[n]=kr.getBuffered(e[n]);r.appendError=0,r.hls.trigger(p.BUFFER_APPENDED,{type:l,frag:u,part:h,chunkMeta:d,parent:u.type,timeRanges:i})},onError:function(t){L.error("[buffer-controller]: Error encountered while trying to append to the "+l+" SourceBuffer",t);var e={type:g.MEDIA_ERROR,parent:u.type,details:v.BUFFER_APPEND_ERROR,frag:u,part:h,chunkMeta:d,error:t,err:t,fatal:!1};t.code===DOMException.QUOTA_EXCEEDED_ERR?e.details=v.BUFFER_FULL_ERROR:(r.appendError++,e.details=v.BUFFER_APPEND_ERROR,r.appendError>n.config.appendErrorMaxRetry&&(L.error("[buffer-controller]: Failed "+n.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),e.fatal=!0)),n.trigger(p.ERROR,e)}};a.append(b,l)},An.prototype.onBufferFlushing=function(t,e){var r=this,i=this.operationQueue,n=function(t){return{execute:r.removeExecutor.bind(r,t,e.startOffset,e.endOffset),onStart:function(){},onComplete:function(){r.hls.trigger(p.BUFFER_FLUSHED,{type:t})},onError:function(e){L.warn("[buffer-controller]: Failed to remove from "+t+" SourceBuffer",e)}}};e.type?i.append(n(e.type),e.type):this.getSourceBufferTypes().forEach((function(t){i.append(n(t),t)}))},An.prototype.onFragParsed=function(t,e){var r=this,i=e.frag,n=e.part,a=[],s=n?n.elementaryStreams:i.elementaryStreams;s[P]?a.push("audiovideo"):(s[_]&&a.push("audio"),s[C]&&a.push("video"));0===a.length&&L.warn("Fragments must have at least one ElementaryStreamType set. type: "+i.type+" level: "+i.level+" sn: "+i.sn),this.blockBuffers((function(){var t=self.performance.now();i.stats.buffering.end=t,n&&(n.stats.buffering.end=t);var e=n?n.stats:i.stats;r.hls.trigger(p.FRAG_BUFFERED,{frag:i,part:n,stats:e,id:i.type})}),a)},An.prototype.onFragChanged=function(t,e){this.flushBackBuffer()},An.prototype.onBufferEos=function(t,e){var r=this;this.getSourceBufferTypes().reduce((function(t,i){var n=r.sourceBuffer[i];return!n||e.type&&e.type!==i||(n.ending=!0,n.ended||(n.ended=!0,L.log("[buffer-controller]: "+i+" sourceBuffer now EOS"))),t&&!(n&&!n.ended)}),!0)&&(L.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers((function(){r.getSourceBufferTypes().forEach((function(t){var e=r.sourceBuffer[t];e&&(e.ending=!1)}));var t=r.mediaSource;t&&"open"===t.readyState?(L.log("[buffer-controller]: Calling mediaSource.endOfStream()"),t.endOfStream()):t&&L.info("[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: "+t.readyState)})))},An.prototype.onLevelUpdated=function(t,e){var r=e.details;r.fragments.length&&(this.details=r,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},An.prototype.flushBackBuffer=function(){var t=this,e=t.hls,r=t.details,i=t.media,n=t.sourceBuffer;if(i&&null!==r){var a=this.getSourceBufferTypes();if(a.length){var s=r.live&&null!==e.config.liveBackBufferLength?e.config.liveBackBufferLength:e.config.backBufferLength;if(f(s)&&!(s<0)){var o=i.currentTime,l=r.levelTargetDuration,u=Math.max(s,l),h=Math.floor(o/l)*l-u;a.forEach((function(t){var i=n[t];if(i){var a=kr.getBuffered(i);if(a.length>0&&h>a.start(0)){if(e.trigger(p.BACK_BUFFER_REACHED,{bufferEnd:h}),r.live)e.trigger(p.LIVE_BACK_BUFFER_REACHED,{bufferEnd:h});else if(i.ended&&a.end(a.length-1)-o<2*l)return void L.info("[buffer-controller]: Cannot flush "+t+" back buffer while SourceBuffer is in ended state");e.trigger(p.BUFFER_FLUSHING,{startOffset:0,endOffset:h,type:t})}}}))}}}},An.prototype.updateMediaElementDuration=function(){if(this.details&&this.media&&this.mediaSource&&"open"===this.mediaSource.readyState){var t=this,e=t.details,r=t.hls,i=t.media,n=t.mediaSource,a=e.fragments[0].start+e.totalduration,s=i.duration,o=f(n.duration)?n.duration:0;e.live&&r.config.liveDurationInfinity?(L.log("[buffer-controller]: Media Source duration is set to Infinity"),n.duration=1/0,this.updateSeekableRange(e)):(a>o&&a>s||!f(s))&&(L.log("[buffer-controller]: Updating Media Source duration to "+a.toFixed(3)),n.duration=a)}},An.prototype.updateSeekableRange=function(t){var e=this.mediaSource,r=t.fragments;if(r.length&&t.live&&null!=e&&e.setLiveSeekableRange){var i=Math.max(0,r[0].start),n=Math.max(i,i+t.totalduration);e.setLiveSeekableRange(i,n)}},An.prototype.checkPendingTracks=function(){var t=this,e=t.bufferCodecEventsExpected,r=t.operationQueue,i=t.pendingTracks,n=Object.keys(i).length;if(n&&!e||2===n){this.createSourceBuffers(i),this.pendingTracks={};var a=this.getSourceBufferTypes();if(a.length)this.hls.trigger(p.BUFFER_CREATED,{tracks:this.tracks}),a.forEach((function(t){r.executeNext(t)}));else{var s=new Error("could not create source buffer for media codec(s)");this.hls.trigger(p.ERROR,{type:g.MEDIA_ERROR,details:v.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:s,reason:s.message})}}},An.prototype.createSourceBuffers=function(t){var e=this.sourceBuffer,r=this.mediaSource;if(!r)throw Error("createSourceBuffers called when mediaSource was null");for(var i in t)if(!e[i]){var n=t[i];if(!n)throw Error("source buffer exists for track "+i+", however track does not");var a=n.levelCodec||n.codec,s=n.container+";codecs="+a;L.log("[buffer-controller]: creating sourceBuffer("+s+")");try{var o=e[i]=r.addSourceBuffer(s),l=i;this.addBufferListener(l,"updatestart",this._onSBUpdateStart),this.addBufferListener(l,"updateend",this._onSBUpdateEnd),this.addBufferListener(l,"error",this._onSBUpdateError),this.tracks[i]={buffer:o,codec:a,container:n.container,levelCodec:n.levelCodec,metadata:n.metadata,id:n.id}}catch(t){L.error("[buffer-controller]: error while trying to add sourceBuffer: "+t.message),this.hls.trigger(p.ERROR,{type:g.MEDIA_ERROR,details:v.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:t,mimeType:s})}}},An.prototype._onSBUpdateStart=function(t){this.operationQueue.current(t).onStart()},An.prototype._onSBUpdateEnd=function(t){var e=this.operationQueue;e.current(t).onComplete(),e.shiftAndExecuteNext(t)},An.prototype._onSBUpdateError=function(t,e){var r=new Error(t+" SourceBuffer error");L.error("[buffer-controller]: "+r,e),this.hls.trigger(p.ERROR,{type:g.MEDIA_ERROR,details:v.BUFFER_APPENDING_ERROR,error:r,fatal:!1});var i=this.operationQueue.current(t);i&&i.onError(e)},An.prototype.removeExecutor=function(t,e,r){var i=this,n=i.media,a=i.mediaSource,s=i.operationQueue,o=i.sourceBuffer[t];if(!n||!a||!o)return L.warn("[buffer-controller]: Attempting to remove from the "+t+" SourceBuffer, but it does not exist"),void s.shiftAndExecuteNext(t);var l=f(n.duration)?n.duration:1/0,u=f(a.duration)?a.duration:1/0,h=Math.max(0,e),d=Math.min(r,l,u);d>h&&!o.ending?(o.ended=!1,L.log("[buffer-controller]: Removing ["+h+","+d+"] from the "+t+" SourceBuffer"),o.remove(h,d)):s.shiftAndExecuteNext(t)},An.prototype.appendExecutor=function(t,e){var r=this.operationQueue,i=this.sourceBuffer[e];if(!i)return L.warn("[buffer-controller]: Attempting to append to the "+e+" SourceBuffer, but it does not exist"),void r.shiftAndExecuteNext(e);i.ended=!1,i.appendBuffer(t)},An.prototype.blockBuffers=function(t,e){var r=this;if(void 0===e&&(e=this.getSourceBufferTypes()),!e.length)return L.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),void Promise.resolve().then(t);var i=this.operationQueue,n=e.map((function(t){return i.appendBlocker(t)}));Promise.all(n).then((function(){t(),e.forEach((function(t){var e=r.sourceBuffer[t];null!=e&&e.updating||i.shiftAndExecuteNext(t)}))}))},An.prototype.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},An.prototype.addBufferListener=function(t,e,r){var i=this.sourceBuffer[t];if(i){var n=r.bind(this,t);this.listeners[t].push({event:e,listener:n}),i.addEventListener(e,n)}},An.prototype.removeBufferListeners=function(t){var e=this.sourceBuffer[t];e&&this.listeners[t].forEach((function(t){e.removeEventListener(t.event,t.listener)}))};var Rn={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},kn=function(t){var e=t;return Rn.hasOwnProperty(t)&&(e=Rn[t]),String.fromCharCode(e)},Dn=15,In=100,wn={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},_n={17:2,18:4,21:6,22:8,23:10,19:13,20:15},Cn={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},Pn={25:2,26:4,29:6,30:8,31:10,27:13,28:15},xn=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],Fn=function(){this.time=null,this.verboseLevel=0};Fn.prototype.log=function(t,e){if(this.verboseLevel>=t){var r="function"==typeof e?e():e;L.log(this.time+" ["+t+"] "+r)}};var On=function(t){for(var e=[],r=0;rIn&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=In)},Un.prototype.moveCursor=function(t){var e=this.pos+t;if(t>1)for(var r=this.pos+1;r=144&&this.backSpace();var r=kn(t);this.pos>=In?this.logger.log(0,(function(){return"Cannot insert "+t.toString(16)+" ("+r+") at position "+e.pos+". Skipping it!"})):(this.chars[this.pos].setChar(r,this.currPenState),this.moveCursor(1))},Un.prototype.clearFromPos=function(t){var e;for(e=t;e0&&(r=t?"["+e.join(" | ")+"]":e.join("\n")),r},Bn.prototype.getTextAndFormat=function(){return this.rows};var Gn=function(t,e,r){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=t,this.outputFilter=e,this.mode=null,this.verbose=0,this.displayedMemory=new Bn(r),this.nonDisplayedMemory=new Bn(r),this.lastOutputScreen=new Bn(r),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=r};Gn.prototype.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},Gn.prototype.getHandler=function(){return this.outputFilter},Gn.prototype.setHandler=function(t){this.outputFilter=t},Gn.prototype.setPAC=function(t){this.writeScreen.setPAC(t)},Gn.prototype.setBkgData=function(t){this.writeScreen.setBkgData(t)},Gn.prototype.setMode=function(t){t!==this.mode&&(this.mode=t,this.logger.log(2,(function(){return"MODE="+t})),"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=t)},Gn.prototype.insertChars=function(t){for(var e=this,r=0;r=46,e.italics)e.foreground="white";else{var r=Math.floor(t/2)-16;e.foreground=["white","green","blue","cyan","red","yellow","magenta"][r]}this.logger.log(2,"MIDROW: "+JSON.stringify(e)),this.writeScreen.setPen(e)},Gn.prototype.outputDataUpdate=function(t){void 0===t&&(t=!1);var e=this.logger.time;null!==e&&this.outputFilter&&(null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,e,this.lastOutputScreen),t&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:e):this.cueStartTime=e,this.lastOutputScreen.copy(this.displayedMemory))},Gn.prototype.cueSplitAtTime=function(t){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,t,this.displayedMemory),this.cueStartTime=t))};var Kn=function(t,e,r){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var i=new Fn;this.channels=[null,new Gn(t,e,i),new Gn(t+1,r,i)],this.cmdHistory={a:null,b:null},this.logger=i};function Hn(t,e,r){r.a=t,r.b=e}function Vn(t,e,r){return r.a===t&&r.b===e}Kn.prototype.getHandler=function(t){return this.channels[t].getHandler()},Kn.prototype.setHandler=function(t,e){this.channels[t].setHandler(e)},Kn.prototype.addData=function(t,e){var r,i,n,a=!1;this.logger.time=t;for(var s=0;s ("+On([i,n])+")"),(r=this.parseCmd(i,n))||(r=this.parseMidrow(i,n)),r||(r=this.parsePAC(i,n)),r||(r=this.parseBackgroundAttributes(i,n)),!r&&(a=this.parseChars(i,n))){var o=this.currentChannel;if(o&&o>0)this.channels[o].insertChars(a);else this.logger.log(2,"No channel found yet. TEXT-MODE?")}r||a||this.logger.log(2,"Couldn't parse cleaned data "+On([i,n])+" orig: "+On([e[s],e[s+1]]))}},Kn.prototype.parseCmd=function(t,e){var r=this.cmdHistory;if(!((20===t||28===t||21===t||29===t)&&e>=32&&e<=47)&&!((23===t||31===t)&&e>=33&&e<=35))return!1;if(Vn(t,e,r))return Hn(null,null,r),this.logger.log(3,"Repeated command ("+On([t,e])+") is dropped"),!0;var i=20===t||21===t||23===t?1:2,n=this.channels[i];return 20===t||21===t||28===t||29===t?32===e?n.ccRCL():33===e?n.ccBS():34===e?n.ccAOF():35===e?n.ccAON():36===e?n.ccDER():37===e?n.ccRU(2):38===e?n.ccRU(3):39===e?n.ccRU(4):40===e?n.ccFON():41===e?n.ccRDC():42===e?n.ccTR():43===e?n.ccRTD():44===e?n.ccEDM():45===e?n.ccCR():46===e?n.ccENM():47===e&&n.ccEOC():n.ccTO(e-32),Hn(t,e,r),this.currentChannel=i,!0},Kn.prototype.parseMidrow=function(t,e){var r=0;if((17===t||25===t)&&e>=32&&e<=47){if((r=17===t?1:2)!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;var i=this.channels[r];return!!i&&(i.ccMIDROW(e),this.logger.log(3,"MIDROW ("+On([t,e])+")"),!0)}return!1},Kn.prototype.parsePAC=function(t,e){var r,i=this.cmdHistory;if(!((t>=17&&t<=23||t>=25&&t<=31)&&e>=64&&e<=127)&&!((16===t||24===t)&&e>=64&&e<=95))return!1;if(Vn(t,e,i))return Hn(null,null,i),!0;var n=t<=23?1:2;r=e>=64&&e<=95?1===n?wn[t]:Cn[t]:1===n?_n[t]:Pn[t];var a=this.channels[n];return!!a&&(a.setPAC(this.interpretPAC(r,e)),Hn(t,e,i),this.currentChannel=n,!0)},Kn.prototype.interpretPAC=function(t,e){var r,i={color:null,italics:!1,indent:null,underline:!1,row:t};return r=e>95?e-96:e-64,i.underline=1==(1&r),r<=13?i.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(i.italics=!0,i.color="white"):i.indent=4*Math.floor((r-16)/2),i},Kn.prototype.parseChars=function(t,e){var r,i,n=null,a=null;(t>=25?(r=2,a=t-8):(r=1,a=t),a>=17&&a<=19)?(i=17===a?e+80:18===a?e+112:e+144,this.logger.log(2,"Special char '"+kn(i)+"' in channel "+r),n=[i]):t>=32&&t<=127&&(n=0===e?[t]:[t,e]);if(n){var s=On(n);this.logger.log(3,"Char codes = "+s.join(",")),Hn(t,e,this.cmdHistory)}return n},Kn.prototype.parseBackgroundAttributes=function(t,e){var r;if(!((16===t||24===t)&&e>=32&&e<=47)&&!((23===t||31===t)&&e>=45&&e<=47))return!1;var i={};16===t||24===t?(r=Math.floor((e-32)/2),i.background=xn[r],e%2==1&&(i.background=i.background+"_semi")):45===e?i.background="transparent":(i.foreground="black",47===e&&(i.underline=!0));var n=t<=23?1:2;return this.channels[n].setBkgData(i),Hn(t,e,this.cmdHistory),!0},Kn.prototype.reset=function(){for(var t=0;tt)&&(this.startTime=t),this.endTime=e,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)},Yn.prototype.reset=function(){this.cueRanges=[],this.startTime=null};var Wn=function(){if("undefined"!=typeof self&&self.VTTCue)return self.VTTCue;var t=["","lr","rl"],e=["start","middle","end","left","right"];function r(t,e){if("string"!=typeof e)return!1;if(!Array.isArray(t))return!1;var r=e.toLowerCase();return!!~t.indexOf(r)&&r}function i(t){return r(e,t)}function n(t){for(var e=arguments,r=[],i=arguments.length-1;i-- >0;)r[i]=arguments[i+1];for(var n=1;n100)throw new Error("Position must be between 0 and 100.");T=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"positionAlign",n({},l,{get:function(){return E},set:function(t){var e=i(t);if(!e)throw new SyntaxError("An invalid or illegal string was specified.");E=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"size",n({},l,{get:function(){return S},set:function(t){if(t<0||t>100)throw new Error("Size must be between 0 and 100.");S=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"align",n({},l,{get:function(){return L},set:function(t){var e=i(t);if(!e)throw new SyntaxError("An invalid or illegal string was specified.");L=e,this.hasBeenReset=!0}})),o.displayState=void 0}return a.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},a}(),jn=function(){};function qn(t){function e(t,e,r,i){return 3600*(0|t)+60*(0|e)+(0|r)+parseFloat(i||0)}var r=t.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return r?parseFloat(r[2])>59?e(r[2],r[3],0,r[4]):e(r[1],r[2],r[3],r[4]):null}jn.prototype.decode=function(t,e){if(!t)return"";if("string"!=typeof t)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(t))};var Xn=function(){this.values=Object.create(null)};function zn(t,e,r,i){var n=i?t.split(i):[t];for(var a in n)if("string"==typeof n[a]){var s=n[a].split(r);if(2===s.length)e(s[0],s[1])}}Xn.prototype.set=function(t,e){this.get(t)||""===e||(this.values[t]=e)},Xn.prototype.get=function(t,e,r){return r?this.has(t)?this.values[t]:e[r]:this.has(t)?this.values[t]:e},Xn.prototype.has=function(t){return t in this.values},Xn.prototype.alt=function(t,e,r){for(var i=0;i=0&&r<=100)return this.set(t,r),!0}return!1};var Qn=new Wn(0,0,""),$n="middle"===Qn.align?"middle":"center";function Jn(t,e,r){var i=t;function n(){var e=qn(t);if(null===e)throw new Error("Malformed timestamp: "+i);return t=t.replace(/^[^\sa-zA-Z-]+/,""),e}function a(){t=t.replace(/^\s+/,"")}if(a(),e.startTime=n(),a(),"--\x3e"!==t.slice(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+i);t=t.slice(3),a(),e.endTime=n(),a(),function(t,e){var i=new Xn;zn(t,(function(t,e){var n;switch(t){case"region":for(var a=r.length-1;a>=0;a--)if(r[a].id===e){i.set(t,r[a].region);break}break;case"vertical":i.alt(t,e,["rl","lr"]);break;case"line":n=e.split(","),i.integer(t,n[0]),i.percent(t,n[0])&&i.set("snapToLines",!1),i.alt(t,n[0],["auto"]),2===n.length&&i.alt("lineAlign",n[1],["start",$n,"end"]);break;case"position":n=e.split(","),i.percent(t,n[0]),2===n.length&&i.alt("positionAlign",n[1],["start",$n,"end","line-left","line-right","auto"]);break;case"size":i.percent(t,e);break;case"align":i.alt(t,e,["start",$n,"end","left","right"])}}),/:/,/\s/),e.region=i.get("region",null),e.vertical=i.get("vertical","");var n=i.get("line","auto");"auto"===n&&-1===Qn.line&&(n=-1),e.line=n,e.lineAlign=i.get("lineAlign","start"),e.snapToLines=i.get("snapToLines",!0),e.size=i.get("size",100),e.align=i.get("align",$n);var a=i.get("position","auto");"auto"===a&&50===Qn.position&&(a="start"===e.align||"left"===e.align?0:"end"===e.align||"right"===e.align?100:50),e.position=a}(t,e)}function Zn(t){return t.replace(//gi,"\n")}var ta=function(){this.state="INITIAL",this.buffer="",this.decoder=new jn,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0};ta.prototype.parse=function(t){var e=this;function r(){var t=e.buffer,r=0;for(t=Zn(t);r>>0).toString()};function na(t,e,r){return ia(t.toString())+ia(e.toString())+ia(r)}function aa(t,e,r,i,n,a,s){var o,l,u,h=new ta,d=ft(new Uint8Array(t)).trim().replace(ea,"\n").split("\n"),c=[],p=(o=e.baseTime,void 0===(l=e.timescale)&&(l=1),Mi(o,9e4,1/l)),g="00:00.000",v=0,m=0,y=!0;h.oncue=function(t){var e=r[i],a=r.ccOffset,s=(v-p)/9e4;null!=e&&e.new&&(void 0!==m?a=r.ccOffset=e.start:function(t,e,r){var i=t[e],n=t[i.prevCC];if(!n||!n.new&&i.new)return t.ccOffset=t.presentationOffset=i.start,void(i.new=!1);for(;null!=(a=n)&&a.new;){var a;t.ccOffset+=i.start-n.start,i.new=!1,n=t[(i=n).prevCC]}t.presentationOffset=r}(r,i,s)),s&&(a=s-r.presentationOffset);var o=t.endTime-t.startTime,l=Ki(9e4*(t.startTime+a-m),9e4*n)/9e4;t.startTime=Math.max(l,0),t.endTime=Math.max(l+o,0);var u=t.text.trim();t.text=decodeURIComponent(encodeURIComponent(u)),t.id||(t.id=na(t.startTime,t.endTime,u)),t.endTime>0&&c.push(t)},h.onparsingerror=function(t){u=t},h.onflush=function(){u?s(u):a(c)},d.forEach((function(t){if(y){if(ra(t,"X-TIMESTAMP-MAP=")){y=!1,t.slice(16).split(",").forEach((function(t){ra(t,"LOCAL:")?g=t.slice(6):ra(t,"MPEGTS:")&&(v=parseInt(t.slice(7)))}));try{m=function(t){var e=parseInt(t.slice(-3)),r=parseInt(t.slice(-6,-4)),i=parseInt(t.slice(-9,-7)),n=t.length>9?parseInt(t.substring(0,t.indexOf(":"))):0;if(!(f(e)&&f(r)&&f(i)&&f(n)))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+t);return e+=1e3*r,e+=6e4*i,e+36e5*n}(g)/1e3}catch(t){u=t}return}""===t&&(y=!1)}h.parse(t+"\n")})),h.flush()}var sa="stpp.ttml.im1t",oa=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,la=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,ua={left:"start",center:"center",right:"end",start:"start",end:"end"};function ha(t,e,r,i){var n=At(new Uint8Array(t),["mdat"]);if(0!==n.length){var a,s,o,l,u=n.map((function(t){return ft(t)})),h=(a=e.baseTime,s=1,void 0===(o=e.timescale)&&(o=1),void 0===l&&(l=!1),Mi(a,s,1/o,l));try{u.forEach((function(t){return r(function(t,e){var r=(new DOMParser).parseFromString(t,"text/xml").getElementsByTagName("tt")[0];if(!r)throw new Error("Invalid ttml");var i={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},n=Object.keys(i).reduce((function(t,e){return t[e]=r.getAttribute("ttp:"+e)||i[e],t}),{}),a="preserve"!==r.getAttribute("xml:space"),s=ca(da(r,"styling","style")),o=ca(da(r,"layout","region")),l=da(r,"body","[begin]");return[].map.call(l,(function(t){var r=fa(t,a);if(!r||!t.hasAttribute("begin"))return null;var i=va(t.getAttribute("begin"),n),l=va(t.getAttribute("dur"),n),u=va(t.getAttribute("end"),n);if(null===i)throw ga(t);if(null===u){if(null===l)throw ga(t);u=i+l}var h=new Wn(i-e,u-e,r);h.id=na(h.startTime,h.endTime,h.text);var d=function(t,e,r){var i="http://www.w3.org/ns/ttml#styling",n=null,a=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],s=null!=t&&t.hasAttribute("style")?t.getAttribute("style"):null;s&&r.hasOwnProperty(s)&&(n=r[s]);return a.reduce((function(r,a){var s=pa(e,i,a)||pa(t,i,a)||pa(n,i,a);return s&&(r[a]=s),r}),{})}(o[t.getAttribute("region")],s[t.getAttribute("style")],s),f=d.textAlign;if(f){var p=ua[f];p&&(h.lineAlign=p),h.align=f}return c(h,d),h})).filter((function(t){return null!==t}))}(t,h))}))}catch(t){i(t)}}else i(new Error("Could not parse IMSC1 mdat"))}function da(t,e,r){var i=t.getElementsByTagName(e)[0];return i?[].slice.call(i.querySelectorAll(r)):[]}function ca(t){return t.reduce((function(t,e){var r=e.getAttribute("xml:id");return r&&(t[r]=e),t}),{})}function fa(t,e){return[].slice.call(t.childNodes).reduce((function(t,r,i){var n;return"br"===r.nodeName&&i?t+"\n":null!=(n=r.childNodes)&&n.length?fa(r,e):e?t+r.textContent.trim().replace(/\s+/g," "):t+r.textContent}),"")}function pa(t,e,r){return t&&t.hasAttributeNS(e,r)?t.getAttributeNS(e,r):null}function ga(t){return new Error("Could not parse ttml timestamp "+t)}function va(t,e){if(!t)return null;var r=qn(t);return null===r&&(oa.test(t)?r=function(t,e){var r=oa.exec(t),i=(0|r[4])+(0|r[5])/e.subFrameRate;return 3600*(0|r[1])+60*(0|r[2])+(0|r[3])+i/e.frameRate}(t,e):la.test(t)&&(r=function(t,e){var r=la.exec(t),i=Number(r[1]);switch(r[2]){case"h":return 3600*i;case"m":return 60*i;case"ms":return 1e3*i;case"f":return i/e.frameRate;case"t":return i/e.tickRate}return i}(t,e))),r}var ma=function(t){if(this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this.captionsProperties=void 0,this.hls=t,this.config=t.config,this.Cues=t.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},this.config.enableCEA708Captions){var e=new Yn(this,"textTrack1"),r=new Yn(this,"textTrack2"),i=new Yn(this,"textTrack3"),n=new Yn(this,"textTrack4");this.cea608Parser1=new Kn(1,e,r),this.cea608Parser2=new Kn(3,i,n)}t.on(p.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(p.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(p.MANIFEST_LOADING,this.onManifestLoading,this),t.on(p.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(p.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(p.FRAG_LOADING,this.onFragLoading,this),t.on(p.FRAG_LOADED,this.onFragLoaded,this),t.on(p.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.on(p.FRAG_DECRYPTED,this.onFragDecrypted,this),t.on(p.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(p.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.on(p.BUFFER_FLUSHING,this.onBufferFlushing,this)};function ya(t,e){return!!t&&t.label===e.name&&!(t.textTrack1||t.textTrack2)}ma.prototype.destroy=function(){var t=this.hls;t.off(p.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(p.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(p.MANIFEST_LOADING,this.onManifestLoading,this),t.off(p.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(p.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(p.FRAG_LOADING,this.onFragLoading,this),t.off(p.FRAG_LOADED,this.onFragLoaded,this),t.off(p.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.off(p.FRAG_DECRYPTED,this.onFragDecrypted,this),t.off(p.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(p.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.off(p.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},ma.prototype.addCues=function(t,e,r,i,n){for(var a,s,o,l,u=!1,h=n.length;h--;){var d=n[h],c=(a=d[0],s=d[1],o=e,l=r,Math.min(s,l)-Math.max(a,o));if(c>=0&&(d[0]=Math.min(d[0],e),d[1]=Math.max(d[1],r),u=!0,c/(r-e)>.5))return}if(u||n.push([e,r]),this.config.renderTextTracksNatively){var f=this.captionsTracks[t];this.Cues.newCue(f,e,r,i)}else{var g=this.Cues.newCue(null,e,r,i);this.hls.trigger(p.CUES_PARSED,{type:"captions",cues:g,track:t})}},ma.prototype.onInitPtsFound=function(t,e){var r=this,i=e.frag,n=e.id,a=e.initPTS,s=e.timescale,o=this.unparsedVttFrags;"main"===n&&(this.initPTS[i.cc]={baseTime:a,timescale:s}),o.length&&(this.unparsedVttFrags=[],o.forEach((function(t){r.onFragLoaded(p.FRAG_LOADED,t)})))},ma.prototype.getExistingTrack=function(t){var e=this.media;if(e)for(var r=0;r0&&this.mediaWidth>0){var t=this.hls.levels;if(t.length){var e=this.hls;e.autoLevelCapping=this.getMaxLevel(t.length-1),e.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=e.autoLevelCapping}}},Ta.prototype.getMaxLevel=function(t){var e=this,r=this.hls.levels;if(!r.length)return-1;var i=r.filter((function(r,i){return e.isLevelAllowed(r)&&i<=t}));return this.clientRect=null,Ta.getMaxLevelByMediaSize(i,this.mediaWidth,this.mediaHeight)},Ta.prototype.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},Ta.prototype.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},Ta.prototype.getDimensions=function(){if(this.clientRect)return this.clientRect;var t=this.media,e={width:0,height:0};if(t){var r=t.getBoundingClientRect();e.width=r.width,e.height=r.height,e.width||e.height||(e.width=r.right-r.left||t.width||0,e.height=r.bottom-r.top||t.height||0)}return this.clientRect=e,e},Ea.mediaWidth.get=function(){return this.getDimensions().width*this.contentScaleFactor},Ea.mediaHeight.get=function(){return this.getDimensions().height*this.contentScaleFactor},Ea.contentScaleFactor.get=function(){var t=1;if(!this.hls.config.ignoreDevicePixelRatio)try{t=self.devicePixelRatio}catch(t){}return t},Ta.prototype.isLevelAllowed=function(t){return!this.restrictedLevels.some((function(e){return t.bitrate===e.bitrate&&t.width===e.width&&t.height===e.height}))},Ta.getMaxLevelByMediaSize=function(t,e,r){if(null==t||!t.length)return-1;for(var i,n,a=t.length-1,s=0;s=e||o.height>=r)&&(i=o,!(n=t[s+1])||i.width!==n.width||i.height!==n.height)){a=s;break}}return a},Object.defineProperties(Ta.prototype,Ea);var Sa=function(t){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=t,this.registerListeners()};Sa.prototype.setStreamController=function(t){this.streamController=t},Sa.prototype.registerListeners=function(){this.hls.on(p.MEDIA_ATTACHING,this.onMediaAttaching,this)},Sa.prototype.unregisterListeners=function(){this.hls.off(p.MEDIA_ATTACHING,this.onMediaAttaching,this)},Sa.prototype.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},Sa.prototype.onMediaAttaching=function(t,e){var r=this.hls.config;if(r.capLevelOnFPSDrop){var i=e.media instanceof self.HTMLVideoElement?e.media:null;this.media=i,i&&"function"==typeof i.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}},Sa.prototype.checkFPS=function(t,e,r){var i=performance.now();if(e){if(this.lastTime){var n=i-this.lastTime,a=r-this.lastDroppedFrames,s=e-this.lastDecodedFrames,o=1e3*a/n,l=this.hls;if(l.trigger(p.FPS_DROP,{currentDropped:a,currentDecoded:s,totalDroppedFrames:r}),o>0&&a>l.config.fpsDroppedMonitoringThreshold*s){var u=l.currentLevel;L.warn("drop FPS ratio greater than max allowed value for currentLevel: "+u),u>0&&(-1===l.autoLevelCapping||l.autoLevelCapping>=u)&&(u-=1,l.trigger(p.FPS_DROP_LEVEL_CAPPING,{level:u,droppedLevel:l.currentLevel}),l.autoLevelCapping=u,this.streamController.nextLevelSwitch())}}this.lastTime=i,this.lastDroppedFrames=r,this.lastDecodedFrames=e}},Sa.prototype.checkFPSInterval=function(){var t=this.media;if(t)if(this.isVideoPlaybackQualityAvailable){var e=t.getVideoPlaybackQuality();this.checkFPS(t,e.totalVideoFrames,e.droppedVideoFrames)}else this.checkFPS(t,t.webkitDecodedFrameCount,t.webkitDroppedFrameCount)};var La="[eme]",ba=function t(e){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=t.CDMCleanupPromise?[t.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=L.debug.bind(L,La),this.log=L.log.bind(L,La),this.warn=L.warn.bind(L,La),this.error=L.error.bind(L,La),this.hls=e,this.config=e.config,this.registerListeners()};ba.prototype.destroy=function(){this.unregisterListeners(),this.onMediaDetached();var t=this.config;t.requestMediaKeySystemAccessFunc=null,t.licenseXhrSetup=t.licenseResponseCallback=void 0,t.drmSystems=t.drmSystemOptions={},this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null,this.config=null},ba.prototype.registerListeners=function(){this.hls.on(p.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(p.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(p.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(p.MANIFEST_LOADED,this.onManifestLoaded,this)},ba.prototype.unregisterListeners=function(){this.hls.off(p.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(p.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(p.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(p.MANIFEST_LOADED,this.onManifestLoaded,this)},ba.prototype.getLicenseServerUrl=function(t){var e=this.config,r=e.drmSystems,i=e.widevineLicenseUrl,n=r[t];if(n)return n.licenseUrl;if(t===H.WIDEVINE&&i)return i;throw new Error('no license server URL configured for key-system "'+t+'"')},ba.prototype.getServerCertificateUrl=function(t){var e=this.config.drmSystems[t];if(e)return e.serverCertificateUrl;this.log('No Server Certificate in config.drmSystems["'+t+'"]')},ba.prototype.attemptKeySystemAccess=function(t){var e=this,r=this.hls.levels,i=function(t,e,r){return!!t&&r.indexOf(t)===e},n=r.map((function(t){return t.audioCodec})).filter(i),a=r.map((function(t){return t.videoCodec})).filter(i);return n.length+a.length===0&&a.push("avc1.42e01e"),new Promise((function(r,i){var s=function(t){var o=t.shift();e.getMediaKeysPromise(o,n,a).then((function(t){return r({keySystem:o,mediaKeys:t})})).catch((function(e){t.length?s(t):i(e instanceof Aa?e:new Aa({type:g.KEY_SYSTEM_ERROR,details:v.KEY_SYSTEM_NO_ACCESS,error:e,fatal:!0},e.message))}))};s(t)}))},ba.prototype.requestMediaKeySystemAccess=function(t,e){var r=this.config.requestMediaKeySystemAccessFunc;if("function"!=typeof r){var i="Configured requestMediaKeySystemAccess is not a function "+r;return null===$&&"http:"===self.location.protocol&&(i="navigator.requestMediaKeySystemAccess is not available over insecure protocol "+location.protocol),Promise.reject(new Error(i))}return r(t,e)},ba.prototype.getMediaKeysPromise=function(t,e,r){var i=this,n=function(t,e,r,i){var n;switch(t){case H.FAIRPLAY:n=["cenc","sinf"];break;case H.WIDEVINE:case H.PLAYREADY:n=["cenc"];break;case H.CLEARKEY:n=["cenc","keyids"];break;default:throw new Error("Unknown key-system: "+t)}return function(t,e,r,i){return[{initDataTypes:t,persistentState:i.persistentState||"not-allowed",distinctiveIdentifier:i.distinctiveIdentifier||"not-allowed",sessionTypes:i.sessionTypes||[i.sessionType||"temporary"],audioCapabilities:e.map((function(t){return{contentType:'audio/mp4; codecs="'+t+'"',robustness:i.audioRobustness||"",encryptionScheme:i.audioEncryptionScheme||null}})),videoCapabilities:r.map((function(t){return{contentType:'video/mp4; codecs="'+t+'"',robustness:i.videoRobustness||"",encryptionScheme:i.videoEncryptionScheme||null}}))}]}(n,e,r,i)}(t,e,r,this.config.drmSystemOptions),a=this.keySystemAccessPromises[t],s=null==a?void 0:a.keySystemAccess;if(!s){this.log('Requesting encrypted media "'+t+'" key-system access with config: '+JSON.stringify(n)),s=this.requestMediaKeySystemAccess(t,n);var o=this.keySystemAccessPromises[t]={keySystemAccess:s};return s.catch((function(e){i.log('Failed to obtain access to key-system "'+t+'": '+e)})),s.then((function(e){i.log('Access for key-system "'+e.keySystem+'" obtained');var r=i.fetchServerCertificate(t);return i.log('Create media-keys for "'+t+'"'),o.mediaKeys=e.createMediaKeys().then((function(e){return i.log('Media-keys created for "'+t+'"'),r.then((function(r){return r?i.setMediaKeysServerCertificate(e,t,r):e}))})),o.mediaKeys.catch((function(e){i.error('Failed to create media-keys for "'+t+'"}: '+e)})),o.mediaKeys}))}return s.then((function(){return a.mediaKeys}))},ba.prototype.createMediaKeySessionContext=function(t){var e=t.decryptdata,r=t.keySystem,i=t.mediaKeys;this.log('Creating key-system session "'+r+'" keyId: '+gt(e.keyId||[]));var n=i.createSession(),a={decryptdata:e,keySystem:r,mediaKeys:i,mediaKeysSession:n,keyStatus:"status-pending"};return this.mediaKeySessions.push(a),a},ba.prototype.renewKeySession=function(t){var e=t.decryptdata;if(e.pssh){var r=this.createMediaKeySessionContext(t),i=this.getKeyIdString(e);this.keyIdToKeySessionPromise[i]=this.generateRequestWithPreferredKeySession(r,"cenc",e.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(t)},ba.prototype.getKeyIdString=function(t){if(!t)throw new Error("Could not read keyId of undefined decryptdata");if(null===t.keyId)throw new Error("keyId is null");return gt(t.keyId)},ba.prototype.updateKeySession=function(t,e){var r,i=t.mediaKeysSession;return this.log('Updating key-session "'+i.sessionId+'" for keyID '+gt((null==(r=t.decryptdata)?void 0:r.keyId)||[])+"\n } (data length: "+(e?e.byteLength:e)+")"),i.update(e)},ba.prototype.selectKeySystemFormat=function(t){var e=Object.keys(t.levelkeys||{});return this.keyFormatPromise||(this.log("Selecting key-system from fragment (sn: "+t.sn+" "+t.type+": "+t.level+") key formats "+e.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(e)),this.keyFormatPromise},ba.prototype.getKeyFormatPromise=function(t){var e=this;return new Promise((function(r,i){var n=Q(e.config),a=t.map(q).filter((function(t){return!!t&&-1!==n.indexOf(t)}));return e.getKeySystemSelectionPromise(a).then((function(t){var e=t.keySystem,n=z(e);n?r(n):i(new Error('Unable to find format for key-system "'+e+'"'))})).catch(i)}))},ba.prototype.loadKey=function(t){var e=this,r=t.keyInfo.decryptdata,i=this.getKeyIdString(r),n="(keyId: "+i+' format: "'+r.keyFormat+'" method: '+r.method+" uri: "+r.uri+")";this.log("Starting session for key "+n);var a=this.keyIdToKeySessionPromise[i];return a||(a=this.keyIdToKeySessionPromise[i]=this.getKeySystemForKeyPromise(r).then((function(i){var a=i.keySystem,s=i.mediaKeys;return e.throwIfDestroyed(),e.log("Handle encrypted media sn: "+t.frag.sn+" "+t.frag.type+": "+t.frag.level+" using key "+n),e.attemptSetMediaKeys(a,s).then((function(){e.throwIfDestroyed();var t=e.createMediaKeySessionContext({keySystem:a,mediaKeys:s,decryptdata:r});return e.generateRequestWithPreferredKeySession(t,"cenc",r.pssh,"playlist-key")}))}))).catch((function(t){return e.handleError(t)})),a},ba.prototype.throwIfDestroyed=function(t){if(!this.hls)throw new Error("invalid state")},ba.prototype.handleError=function(t){this.hls&&(this.error(t.message),t instanceof Aa?this.hls.trigger(p.ERROR,t.data):this.hls.trigger(p.ERROR,{type:g.KEY_SYSTEM_ERROR,details:v.KEY_SYSTEM_NO_KEYS,error:t,fatal:!0}))},ba.prototype.getKeySystemForKeyPromise=function(t){var e=this.getKeyIdString(t),r=this.keyIdToKeySessionPromise[e];if(!r){var i=q(t.keyFormat),n=i?[i]:Q(this.config);return this.attemptKeySystemAccess(n)}return r},ba.prototype.getKeySystemSelectionPromise=function(t){if(t.length||(t=Q(this.config)),0===t.length)throw new Aa({type:g.KEY_SYSTEM_ERROR,details:v.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},"Missing key-system license configuration options "+JSON.stringify({drmSystems:this.config.drmSystems}));return this.attemptKeySystemAccess(t)},ba.prototype._onMediaEncrypted=function(t){var e=this,r=t.initDataType,i=t.initData;if(this.debug('"'+t.type+'" event: init data type: "'+r+'"'),null!==i){var n,a;if("sinf"===r&&this.config.drmSystems[H.FAIRPLAY]){var s=Tt(new Uint8Array(i));try{var o=B(JSON.parse(s).sinf),l=Dt(new Uint8Array(o));if(!l)return;n=l.subarray(8,24),a=H.FAIRPLAY}catch(t){return void this.warn('Failed to parse sinf "encrypted" event message initData')}}else{var u=function(t){if(!(t instanceof ArrayBuffer)||t.byteLength<32)return null;var e={version:0,systemId:"",kids:null,data:null},r=new DataView(t),i=r.getUint32(0);if(t.byteLength!==i&&i>44)return null;if(1886614376!==r.getUint32(4))return null;if(e.version=r.getUint32(8)>>>24,e.version>1)return null;e.systemId=gt(new Uint8Array(t,12,16));var n=r.getUint32(28);if(0===e.version){if(i-32d||o.status>=400&&o.status<500)a(new Aa({type:g.KEY_SYSTEM_ERROR,details:v.KEY_SYSTEM_LICENSE_REQUEST_FAILED,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{var c=d-r._requestLicenseFailureCount+1;r.warn("Retrying license request, "+c+" attempts left"),r.requestLicense(t,e).then(n,a)}}},t.licenseXhr&&t.licenseXhr.readyState!==XMLHttpRequest.DONE&&t.licenseXhr.abort(),t.licenseXhr=o,r.setupLicenseXHR(o,s,t,e).then((function(t){var e=t.xhr,r=t.licenseChallenge;e.send(r)}))}))},ba.prototype.onMediaAttached=function(t,e){if(this.config.emeEnabled){var r=e.media;this.media=r,r.addEventListener("encrypted",this.onMediaEncrypted),r.addEventListener("waitingforkey",this.onWaitingForKey)}},ba.prototype.onMediaDetached=function(){var t=this,e=this.media,r=this.mediaKeySessions;e&&(e.removeEventListener("encrypted",this.onMediaEncrypted),e.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},Mt.clearKeyUriToKeyIdMap();var i=r.length;ba.CDMCleanupPromise=Promise.all(r.map((function(e){return t.removeSession(e)})).concat(null==e?void 0:e.setMediaKeys(null).catch((function(r){t.log("Could not clear media keys: "+r+". media.src: "+(null==e?void 0:e.src))})))).then((function(){i&&(t.log("finished closing key sessions and clearing media keys"),r.length=0)})).catch((function(r){t.log("Could not close sessions and clear media keys: "+r+". media.src: "+(null==e?void 0:e.src))}))},ba.prototype.onManifestLoading=function(){this.keyFormatPromise=null},ba.prototype.onManifestLoaded=function(t,e){var r=e.sessionKeys;if(r&&this.config.emeEnabled&&!this.keyFormatPromise){var i=r.reduce((function(t,e){return-1===t.indexOf(e.keyFormat)&&t.push(e.keyFormat),t}),[]);this.log("Selecting key-system from session-keys "+i.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(i)}},ba.prototype.removeSession=function(t){var e=this,r=t.mediaKeysSession,i=t.licenseXhr;if(r){this.log("Remove licenses and keys and close session "+r.sessionId),r.onmessage=null,r.onkeystatuseschange=null,i&&i.readyState!==XMLHttpRequest.DONE&&i.abort(),t.mediaKeysSession=t.decryptdata=t.licenseXhr=void 0;var n=this.mediaKeySessions.indexOf(t);return n>-1&&this.mediaKeySessions.splice(n,1),r.remove().catch((function(t){e.log("Could not remove session: "+t)})).then((function(){return r.close()})).catch((function(t){e.log("Could not close session: "+t)}))}},ba.CDMCleanupPromise=void 0;var Aa=function(t){function e(e,r){t.call(this,r),this.data=void 0,e.error||(e.error=new t(r)),this.data=e,e.err=e.error}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(Error),Ra="m",ka="a",Da="v",Ia="av",wa="i",_a="tt",Ca=function t(e){var r=this;this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=function(){r.initialized&&(r.starved=!0),r.buffering=!0},this.onPlaying=function(){r.initialized||(r.initialized=!0),r.buffering=!1},this.applyPlaylistData=function(t){try{r.apply(t,{ot:Ra,su:!r.initialized})}catch(t){L.warn("Could not generate manifest CMCD data.",t)}},this.applyFragmentData=function(t){try{var e=t.frag,i=r.hls.levels[e.level],n=r.getObjectType(e),a={d:1e3*e.duration,ot:n};n!==Da&&n!==ka&&n!=Ia||(a.br=i.bitrate/1e3,a.tb=r.getTopBandwidth(n)/1e3,a.bl=r.getBufferLength(n)),r.apply(t,a)}catch(t){L.warn("Could not generate segment CMCD data.",t)}},this.hls=e;var i=this.config=e.config,n=i.cmcd;null!=n&&(i.pLoader=this.createPlaylistLoader(),i.fLoader=this.createFragmentLoader(),this.sid=n.sessionId||t.uuid(),this.cid=n.contentId,this.useHeaders=!0===n.useHeaders,this.registerListeners())};Ca.prototype.registerListeners=function(){var t=this.hls;t.on(p.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(p.MEDIA_DETACHED,this.onMediaDetached,this),t.on(p.BUFFER_CREATED,this.onBufferCreated,this)},Ca.prototype.unregisterListeners=function(){var t=this.hls;t.off(p.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(p.MEDIA_DETACHED,this.onMediaDetached,this),t.off(p.BUFFER_CREATED,this.onBufferCreated,this)},Ca.prototype.destroy=function(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},Ca.prototype.onMediaAttached=function(t,e){this.media=e.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},Ca.prototype.onMediaDetached=function(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)},Ca.prototype.onBufferCreated=function(t,e){var r,i;this.audioBuffer=null==(r=e.tracks.audio)?void 0:r.buffer,this.videoBuffer=null==(i=e.tracks.video)?void 0:i.buffer},Ca.prototype.createData=function(){var t;return{v:1,sf:"h",sid:this.sid,cid:this.cid,pr:null==(t=this.media)?void 0:t.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},Ca.prototype.apply=function(t,e){void 0===e&&(e={}),c(e,this.createData());var r=e.ot===wa||e.ot===Da||e.ot===Ia;if(this.starved&&r&&(e.bs=!0,e.su=!0,this.starved=!1),null==e.su&&(e.su=this.buffering),this.useHeaders){var i=Ca.toHeaders(e);if(!Object.keys(i).length)return;t.headers||(t.headers={}),c(t.headers,i)}else{var n=Ca.toQuery(e);if(!n)return;t.url=Ca.appendQueryToUri(t.url,n)}},Ca.prototype.getObjectType=function(t){var e=t.type;return"subtitle"===e?_a:"initSegment"===t.sn?wa:"audio"===e?ka:"main"===e?this.hls.audioTracks.length?Da:Ia:void 0},Ca.prototype.getTopBandwidth=function(t){var e,r=0,i=this.hls;if(t===ka)e=i.audioTracks;else{var n=i.maxAutoLevel,a=n>-1?n+1:i.levels.length;e=i.levels.slice(0,a)}for(var s=0,o=e;sr&&(r=l.bitrate)}return r>0?r:NaN},Ca.prototype.getBufferLength=function(t){var e=this.hls.media,r=t===ka?this.audioBuffer:this.videoBuffer;return r&&e?1e3*kr.bufferInfo(r,e.currentTime,this.config.maxBufferHole).len:NaN},Ca.prototype.createPlaylistLoader=function(){var t=this.config.pLoader,e=this.applyPlaylistData,r=t||this.config.loader;return function(){function t(t){this.loader=void 0,this.loader=new r(t)}var i={stats:{configurable:!0},context:{configurable:!0}};return i.stats.get=function(){return this.loader.stats},i.context.get=function(){return this.loader.context},t.prototype.destroy=function(){this.loader.destroy()},t.prototype.abort=function(){this.loader.abort()},t.prototype.load=function(t,r,i){e(t),this.loader.load(t,r,i)},Object.defineProperties(t.prototype,i),t}()},Ca.prototype.createFragmentLoader=function(){var t=this.config.fLoader,e=this.applyFragmentData,r=t||this.config.loader;return function(){function t(t){this.loader=void 0,this.loader=new r(t)}var i={stats:{configurable:!0},context:{configurable:!0}};return i.stats.get=function(){return this.loader.stats},i.context.get=function(){return this.loader.context},t.prototype.destroy=function(){this.loader.destroy()},t.prototype.abort=function(){this.loader.abort()},t.prototype.load=function(t,r,i){e(t),this.loader.load(t,r,i)},Object.defineProperties(t.prototype,i),t}()},Ca.uuid=function(){var t=URL.createObjectURL(new Blob),e=t.toString();return URL.revokeObjectURL(t),e.slice(e.lastIndexOf("/")+1)},Ca.serialize=function(t){for(var e=[],r=function(t){return!Number.isNaN(t)&&null!=t&&""!==t&&!1!==t},i=function(t){return Math.round(t)},n=function(t){return 100*i(t/100)},a={br:i,d:i,bl:n,dl:n,mtp:n,nor:function(t){return encodeURIComponent(t)},rtp:n,tb:i},s=0,o=Object.keys(t||{}).sort();s1&&(this.updatePathwayPriority(i),r.resolved=this.pathwayId!==n)}},Pa.prototype.filterParsedLevels=function(t){this.levels=t;var e=this.getLevelsForPathway(this.pathwayId);if(0===e.length){var r=t[0].pathwayId;this.log("No levels found in Pathway "+this.pathwayId+'. Setting initial Pathway to "'+r+'"'),e=this.getLevelsForPathway(r),this.pathwayId=r}return e.length!==t.length?(this.log("Found "+e.length+"/"+t.length+' levels in Pathway "'+this.pathwayId+'"'),e):t},Pa.prototype.getLevelsForPathway=function(t){return null===this.levels?[]:this.levels.filter((function(e){return t===e.pathwayId}))},Pa.prototype.updatePathwayPriority=function(t){var e;this.pathwayPriority=t;var r=this.penalizedPathways,i=performance.now();Object.keys(r).forEach((function(t){i-r[t]>3e5&&delete r[t]}));for(var n=0;n0){this.log('Setting Pathway to "'+a+'"'),this.pathwayId=a,this.hls.trigger(p.LEVELS_UPDATED,{levels:e});var l=this.hls.levels[s];o&&l&&this.levels&&(l.attrs["STABLE-VARIANT-ID"]!==o.attrs["STABLE-VARIANT-ID"]&&l.bitrate!==o.bitrate&&this.log("Unstable Pathways change from bitrate "+o.bitrate+" to "+l.bitrate),this.hls.nextLoadLevel=s);break}}}},Pa.prototype.clonePathways=function(t){var e=this,r=this.levels;if(r){var i={},n={};t.forEach((function(t){var a=t.ID,s=t["BASE-ID"],o=t["URI-REPLACEMENT"];if(!r.some((function(t){return t.pathwayId===a}))){var l=e.getLevelsForPathway(s).map((function(t){var e=c({},t);e.details=void 0,e.url=Fa(t.uri,t.attrs["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",o);var r=new R(t.attrs);r["PATHWAY-ID"]=a;var s=r.AUDIO&&r.AUDIO+"_clone_"+a,l=r.SUBTITLES&&r.SUBTITLES+"_clone_"+a;s&&(i[r.AUDIO]=s,r.AUDIO=s),l&&(n[r.SUBTITLES]=l,r.SUBTITLES=l),e.attrs=r;var u=new Fe(e);return ur(u,"audio",s),ur(u,"text",l),u}));r.push.apply(r,l),xa(e.audioTracks,i,o,a),xa(e.subtitleTracks,n,o,a)}}))}},Pa.prototype.loadSteeringManifest=function(t){var e,r=this,i=this.hls.config,n=i.loader;this.loader&&this.loader.destroy(),this.loader=new n(i);try{e=new self.URL(t)}catch(e){return this.enabled=!1,void this.log("Failed to parse Steering Manifest URI: "+t)}if("data:"!==e.protocol){var a=0|(this.hls.bandwidthEstimate||i.abrEwmaDefaultEstimate);e.searchParams.set("_HLS_pathway",this.pathwayId),e.searchParams.set("_HLS_throughput",""+a)}var s={responseType:"json",url:e.href},o=i.steeringManifestLoadPolicy.default,l=o.errorRetry||o.timeoutRetry||{},u={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:l.maxNumRetry||0,retryDelay:l.retryDelayMs||0,maxRetryDelay:l.maxRetryDelayMs||0},h={onSuccess:function(t,i,n,a){r.log('Loaded steering manifest: "'+e+'"');var s=t.data;if(1===s.VERSION){r.updated=performance.now(),r.timeToLoad=s.TTL;var o=s["RELOAD-URI"],l=s["PATHWAY-CLONES"],u=s["PATHWAY-PRIORITY"];if(o)try{r.uri=new self.URL(o,e).href}catch(t){return r.enabled=!1,void r.log("Failed to parse Steering Manifest RELOAD-URI: "+o)}r.scheduleRefresh(r.uri||n.url),l&&r.clonePathways(l),u&&r.updatePathwayPriority(u)}else r.log("Steering VERSION "+s.VERSION+" not supported!")},onError:function(t,e,i,n){if(r.log("Error loading steering manifest: "+t.code+" "+t.text+" ("+e.url+")"),r.stopLoad(),410===t.code)return r.enabled=!1,void r.log("Steering manifest "+e.url+" no longer available");var a=1e3*r.timeToLoad;if(429!==t.code)r.scheduleRefresh(r.uri||e.url,a);else{var s=r.loader;if("function"==typeof(null==s?void 0:s.getResponseHeader)){var o=s.getResponseHeader("Retry-After");o&&(a=1e3*parseFloat(o))}r.log("Steering manifest "+e.url+" rate limited")}},onTimeout:function(t,e,i){r.log("Timeout loading steering manifest ("+e.url+")"),r.scheduleRefresh(r.uri||e.url)}};this.log("Requesting steering manifest: "+e),this.loader.load(s,u,h)},Pa.prototype.scheduleRefresh=function(t,e){var r=this;void 0===e&&(e=1e3*this.timeToLoad),self.clearTimeout(this.reloadTimer),this.reloadTimer=self.setTimeout((function(){r.loadSteeringManifest(t)}),e)};var Oa=/^age:\s*[\d.]+\s*$/im,Ma=function(t){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=t&&t.xhrSetup||null,this.stats=new w,this.retryDelay=0};Ma.prototype.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},Ma.prototype.abortInternal=function(){var t=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),t&&(t.onreadystatechange=null,t.onprogress=null,4!==t.readyState&&(this.stats.aborted=!0,t.abort()))},Ma.prototype.abort=function(){var t;this.abortInternal(),null!=(t=this.callbacks)&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},Ma.prototype.load=function(t,e,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=t,this.config=e,this.callbacks=r,this.loadInternal()},Ma.prototype.loadInternal=function(){var t=this,e=this.config,r=this.context;if(e){var i=this.loader=new self.XMLHttpRequest,n=this.stats;n.loading.first=0,n.loaded=0;var a=this.xhrSetup;a?Promise.resolve().then((function(){if(!t.stats.aborted)return a(i,r.url)})).catch((function(t){return i.open("GET",r.url,!0),a(i,r.url)})).then((function(){t.stats.aborted||t.openAndSendXhr(i,r,e)})).catch((function(e){t.callbacks.onError({code:i.status,text:e.message},r,i,n)})):this.openAndSendXhr(i,r,e)}},Ma.prototype.openAndSendXhr=function(t,e,r){t.readyState||t.open("GET",e.url,!0);var i=this.context.headers,n=r.loadPolicy,a=n.maxTimeToFirstByteMs,s=n.maxLoadTimeMs;if(i)for(var o in i)t.setRequestHeader(o,i[o]);e.rangeEnd&&t.setRequestHeader("Range","bytes="+e.rangeStart+"-"+(e.rangeEnd-1)),t.onreadystatechange=this.readystatechange.bind(this),t.onprogress=this.loadprogress.bind(this),t.responseType=e.responseType,self.clearTimeout(this.requestTimeout),r.timeout=a&&f(a)?a:s,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.timeout),t.send()},Ma.prototype.readystatechange=function(){var t=this,e=t.context,r=t.loader,i=t.stats;if(e&&r){var n=r.readyState,a=this.config;if(!i.aborted&&n>=2&&(0===i.loading.first&&(i.loading.first=Math.max(self.performance.now(),i.loading.start),a.timeout!==a.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),a.timeout=a.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),a.loadPolicy.maxLoadTimeMs-(i.loading.first-i.loading.start)))),4===n)){self.clearTimeout(this.requestTimeout),r.onreadystatechange=null,r.onprogress=null;var s=r.status,o="text"!==r.responseType;if(s>=200&&s<300&&(o&&r.response||null!==r.responseText)){i.loading.end=Math.max(self.performance.now(),i.loading.first);var l=o?r.response:r.responseText,u="arraybuffer"===r.responseType?l.byteLength:l.length;if(i.loaded=i.total=u,i.bwEstimate=8e3*i.total/(i.loading.end-i.loading.first),!this.callbacks)return;var h=this.callbacks.onProgress;if(h&&h(i,e,l,r),!this.callbacks)return;var d={url:r.responseURL,data:l,code:s};this.callbacks.onSuccess(d,i,e,r)}else{var c=a.loadPolicy.errorRetry;qe(c,i.retry,!1,s)?this.retry(c):(L.error(s+" while loading "+e.url),this.callbacks.onError({code:s,text:r.statusText},e,r,i))}}}},Ma.prototype.loadtimeout=function(){var t,e=null==(t=this.config)?void 0:t.loadPolicy.timeoutRetry;if(qe(e,this.stats.retry,!0))this.retry(e);else{L.warn("timeout while loading "+this.context.url);var r=this.callbacks;r&&(this.abortInternal(),r.onTimeout(this.stats,this.context,this.loader))}},Ma.prototype.retry=function(t){var e=this.context,r=this.stats;this.retryDelay=We(t,r.retry),r.retry++,L.warn((status?"HTTP Status "+status:"Timeout")+" while loading "+e.url+", retrying "+r.retry+"/"+t.maxNumRetry+" in "+this.retryDelay+"ms"),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)},Ma.prototype.loadprogress=function(t){var e=this.stats;e.loaded=t.loaded,t.lengthComputable&&(e.total=t.total)},Ma.prototype.getCacheAge=function(){var t=null;if(this.loader&&Oa.test(this.loader.getAllResponseHeaders())){var e=this.loader.getResponseHeader("age");t=e?parseFloat(e):null}return t},Ma.prototype.getResponseHeader=function(t){return this.loader&&new RegExp("^"+t+":\\s*[\\d.]+\\s*$","im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(t):null};var Na=/(\d+)-(\d+)\/(\d+)/,Ua=function(t){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=t.fetchSetup||Ba,this.controller=new self.AbortController,this.stats=new w};function Ba(t,e){return new self.Request(t.url,e)}Ua.prototype.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},Ua.prototype.abortInternal=function(){var t=this.response;null!=t&&t.ok||(this.stats.aborted=!0,this.controller.abort())},Ua.prototype.abort=function(){var t;this.abortInternal(),null!=(t=this.callbacks)&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},Ua.prototype.load=function(t,e,r){var i=this,n=this.stats;if(n.loading.start)throw new Error("Loader can only be used once.");n.loading.start=self.performance.now();var a=function(t,e){var r={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(c({},t.headers))};t.rangeEnd&&r.headers.set("Range","bytes="+t.rangeStart+"-"+String(t.rangeEnd-1));return r}(t,this.controller.signal),s=r.onProgress,o="arraybuffer"===t.responseType,l=o?"byteLength":"length",u=e.loadPolicy,h=u.maxTimeToFirstByteMs,d=u.maxLoadTimeMs;this.context=t,this.config=e,this.callbacks=r,this.request=this.fetchSetup(t,a),self.clearTimeout(this.requestTimeout),e.timeout=h&&f(h)?h:d,this.requestTimeout=self.setTimeout((function(){i.abortInternal(),r.onTimeout(n,t,i.response)}),e.timeout),self.fetch(this.request).then((function(a){i.response=i.loader=a;var l=Math.max(self.performance.now(),n.loading.start);if(self.clearTimeout(i.requestTimeout),e.timeout=d,i.requestTimeout=self.setTimeout((function(){i.abortInternal(),r.onTimeout(n,t,i.response)}),d-(l-n.loading.start)),!a.ok){var u=a.status,h=a.statusText;throw new Ga(h||"fetch, bad network response",u,a)}return n.loading.first=l,n.total=function(t){var e=t.get("Content-Range");if(e){var r=function(t){var e=Na.exec(t);if(e)return parseInt(e[2])-parseInt(e[1])+1}(e);if(f(r))return r}var i=t.get("Content-Length");if(i)return parseInt(i)}(a.headers)||n.total,s&&f(e.highWaterMark)?i.loadProgressively(a,n,t,e.highWaterMark,s):o?a.arrayBuffer():"json"===t.responseType?a.json():a.text()})).then((function(a){var o=i.response;self.clearTimeout(i.requestTimeout),n.loading.end=Math.max(self.performance.now(),n.loading.first);var u=a[l];u&&(n.loaded=n.total=u);var h={url:o.url,data:a,code:o.status};s&&!f(e.highWaterMark)&&s(n,t,a,o),r.onSuccess(h,n,t,o)})).catch((function(e){if(self.clearTimeout(i.requestTimeout),!n.aborted){var a=e&&e.code||0,s=e?e.message:null;r.onError({code:a,text:s},t,e?e.details:null,n)}}))},Ua.prototype.getCacheAge=function(){var t=null;if(this.response){var e=this.response.headers.get("age");t=e?parseFloat(e):null}return t},Ua.prototype.getResponseHeader=function(t){return this.response?this.response.headers.get(t):null},Ua.prototype.loadProgressively=function(t,e,r,i,n){void 0===i&&(i=0);var a=new cn,s=t.body.getReader(),o=function(){return s.read().then((function(s){if(s.done)return a.dataLength&&n(e,r,a.flush(),t),Promise.resolve(new ArrayBuffer(0));var l=s.value,u=l.length;return e.loaded+=u,u=i&&n(e,r,a.flush(),t)):n(e,r,l,t),o()})).catch((function(){return Promise.reject()}))};return o()};var Ga=function(t){function e(e,r,i){t.call(this,e),this.code=void 0,this.details=void 0,this.code=r,this.details=i}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(Error),Ka=/\s/,Ha=h(h({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,maxBufferSize:6e7,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:Ma,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:hn,bufferController:An,capLevelController:Ta,errorController:ar,fpsController:Sa,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:$,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!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}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},{cueHandler:{newCue:function(t,e,r,i){for(var n,a,s,o,l,u=[],h=self.VTTCue||self.TextTrackCue,d=0;d=16?o--:o++;var p=Zn(l.trim()),g=na(e,r,p);null!=t&&null!=(c=t.cues)&&c.getCueById(g)||((a=new h(e,r,p)).id=g,a.line=d+1,a.align="left",a.position=10+Math.min(80,10*Math.floor(8*o/32)),u.push(a))}return t&&u.length&&(u.sort((function(t,e){return"auto"===t.line||"auto"===e.line?0:t.line>8&&e.line>8?e.line-t.line:t.line-e.line})),u.forEach((function(e){return me(t,e)}))),u}},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:mn,subtitleTrackController:Tn,timelineController:ma,audioStreamController:fn,audioTrackController:pn,emeController:ba,cmcdController:Ca,contentSteeringController:Pa});function Va(t){return t&&"object"==typeof t?Array.isArray(t)?t.map(Va):Object.keys(t).reduce((function(e,r){return e[r]=Va(t[r]),e}),{}):t}function Ya(t){var e=t.loader;e!==Ua&&e!==Ma?(L.log("[config]: Custom loader detected, cannot enable progressive streaming"),t.progressive=!1):function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(t){}return!1}()&&(t.loader=Ua,t.progressive=!0,t.enableSoftwareAES=!0,L.log("[config]: Progressive streaming enabled, using FetchLoader"))}var Wa=function t(e){void 0===e&&(e={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new rn,this._autoLevelCapping=void 0,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null,S(e.debug||!1,"Hls instance");var r=this.config=function(t,e){if((e.liveSyncDurationCount||e.liveMaxLatencyDurationCount)&&(e.liveSyncDuration||e.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==e.liveMaxLatencyDurationCount&&(void 0===e.liveSyncDurationCount||e.liveMaxLatencyDurationCount<=e.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==e.liveMaxLatencyDuration&&(void 0===e.liveSyncDuration||e.liveMaxLatencyDuration<=e.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');var r=Va(t),i=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach((function(t){var n=("level"===t?"playlist":t)+"LoadPolicy",a=void 0===e[n],s=[];i.forEach((function(i){var o=t+"Loading"+i,l=e[o];if(void 0!==l&&a){s.push(o);var u=r[n].default;switch(e[n]={default:u},i){case"TimeOut":u.maxLoadTimeMs=l,u.maxTimeToFirstByteMs=l;break;case"MaxRetry":u.errorRetry.maxNumRetry=l,u.timeoutRetry.maxNumRetry=l;break;case"RetryDelay":u.errorRetry.retryDelayMs=l,u.timeoutRetry.retryDelayMs=l;break;case"MaxRetryTimeout":u.errorRetry.maxRetryDelayMs=l,u.timeoutRetry.maxRetryDelayMs=l}}})),s.length&&L.warn('hls.js config: "'+s.join('", "')+'" setting(s) are deprecated, use "'+n+'": '+JSON.stringify(e[n]))})),h(h({},r),e)}(t.DefaultConfig,e);this.userConfig=e,this._autoLevelCapping=-1,r.progressive&&Ya(r);var i=r.abrController,n=r.bufferController,a=r.capLevelController,s=r.errorController,o=r.fpsController,l=new s(this),u=this.abrController=new i(this),d=this.bufferController=new n(this),c=this.capLevelController=new a(this),f=new o(this),g=new ge(this),v=new ke(this),m=r.contentSteeringController,y=m?new m(this):null,T=this.levelController=new lr(this,y),E=new gr(this),b=new br(this.config),A=this.streamController=new on(this,E,b);c.setStreamController(A),f.setStreamController(A);var R=[g,T,A];y&&R.splice(1,0,y),this.networkControllers=R;var k=[u,d,c,f,v,E];this.audioTrackController=this.createController(r.audioTrackController,R);var D=r.audioStreamController;D&&R.push(new D(this,E,b)),this.subtitleTrackController=this.createController(r.subtitleTrackController,R);var I=r.subtitleStreamController;I&&R.push(new I(this,E,b)),this.createController(r.timelineController,k),b.emeController=this.emeController=this.createController(r.emeController,k),this.cmcdController=this.createController(r.cmcdController,k),this.latencyController=this.createController(De,k),this.coreComponents=k,R.push(l);var w=l.onErrorOut;"function"==typeof w&&this.on(p.ERROR,w,l)},ja={levels:{configurable:!0},currentLevel:{configurable:!0},nextLevel:{configurable:!0},loadLevel:{configurable:!0},nextLoadLevel:{configurable:!0},firstLevel:{configurable:!0},startLevel:{configurable:!0},capLevelToPlayerSize:{configurable:!0},autoLevelCapping:{configurable:!0},bandwidthEstimate:{configurable:!0},ttfbEstimate:{configurable:!0},maxHdcpLevel:{configurable:!0},autoLevelEnabled:{configurable:!0},manualLevel:{configurable:!0},minAutoLevel:{configurable:!0},maxAutoLevel:{configurable:!0},nextAutoLevel:{configurable:!0},playingDate:{configurable:!0},mainForwardBufferInfo:{configurable:!0},audioTracks:{configurable:!0},audioTrack:{configurable:!0},subtitleTracks:{configurable:!0},subtitleTrack:{configurable:!0},media:{configurable:!0},subtitleDisplay:{configurable:!0},lowLatencyMode:{configurable:!0},liveSyncPosition:{configurable:!0},latency:{configurable:!0},maxLatency:{configurable:!0},targetLatency:{configurable:!0},drift:{configurable:!0},forceStartLoad:{configurable:!0}},qa={version:{configurable:!0},Events:{configurable:!0},ErrorTypes:{configurable:!0},ErrorDetails:{configurable:!0},DefaultConfig:{configurable:!0}};qa.version.get=function(){return"1.4.2"},Wa.isSupported=function(){return function(){var t=Vt();if(!t)return!1;var e=$r(),r=t&&"function"==typeof t.isTypeSupported&&t.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),i=!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove;return!!r&&!!i}()},qa.Events.get=function(){return p},qa.ErrorTypes.get=function(){return g},qa.ErrorDetails.get=function(){return v},qa.DefaultConfig.get=function(){return Wa.defaultConfig?Wa.defaultConfig:Ha},qa.DefaultConfig.set=function(t){Wa.defaultConfig=t},Wa.prototype.createController=function(t,e){if(t){var r=new t(this);return e&&e.push(r),r}return null},Wa.prototype.on=function(t,e,r){void 0===r&&(r=this),this._emitter.on(t,e,r)},Wa.prototype.once=function(t,e,r){void 0===r&&(r=this),this._emitter.once(t,e,r)},Wa.prototype.removeAllListeners=function(t){this._emitter.removeAllListeners(t)},Wa.prototype.off=function(t,e,r,i){void 0===r&&(r=this),this._emitter.off(t,e,r,i)},Wa.prototype.listeners=function(t){return this._emitter.listeners(t)},Wa.prototype.emit=function(t,e,r){return this._emitter.emit(t,e,r)},Wa.prototype.trigger=function(t,e){if(this.config.debug)return this.emit(t,t,e);try{return this.emit(t,t,e)}catch(e){L.error("An internal error happened while handling event "+t+'. Error message: "'+e.message+'". Here is a stacktrace:',e),this.trigger(p.ERROR,{type:g.OTHER_ERROR,details:v.INTERNAL_EXCEPTION,fatal:!1,event:t,error:e})}return!1},Wa.prototype.listenerCount=function(t){return this._emitter.listenerCount(t)},Wa.prototype.destroy=function(){L.log("destroy"),this.trigger(p.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach((function(t){return t.destroy()})),this.networkControllers.length=0,this.coreComponents.forEach((function(t){return t.destroy()})),this.coreComponents.length=0;var t=this.config;t.xhrSetup=t.fetchSetup=void 0,this.userConfig=null},Wa.prototype.attachMedia=function(t){L.log("attachMedia"),this._media=t,this.trigger(p.MEDIA_ATTACHING,{media:t})},Wa.prototype.detachMedia=function(){L.log("detachMedia"),this.trigger(p.MEDIA_DETACHING,void 0),this._media=null},Wa.prototype.loadSource=function(t){this.stopLoad();var e=this.media,r=this.url,i=this.url=l.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});L.log("loadSource:"+i),e&&r&&(r!==i||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(e)),this.trigger(p.MANIFEST_LOADING,{url:t})},Wa.prototype.startLoad=function(t){void 0===t&&(t=-1),L.log("startLoad("+t+")"),this.networkControllers.forEach((function(e){e.startLoad(t)}))},Wa.prototype.stopLoad=function(){L.log("stopLoad"),this.networkControllers.forEach((function(t){t.stopLoad()}))},Wa.prototype.swapAudioCodec=function(){L.log("swapAudioCodec"),this.streamController.swapAudioCodec()},Wa.prototype.recoverMediaError=function(){L.log("recoverMediaError");var t=this._media;this.detachMedia(),t&&this.attachMedia(t)},Wa.prototype.removeLevel=function(t,e){void 0===e&&(e=0),this.levelController.removeLevel(t,e)},ja.levels.get=function(){var t=this.levelController.levels;return t||[]},ja.currentLevel.get=function(){return this.streamController.currentLevel},ja.currentLevel.set=function(t){L.log("set currentLevel:"+t),this.loadLevel=t,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()},ja.nextLevel.get=function(){return this.streamController.nextLevel},ja.nextLevel.set=function(t){L.log("set nextLevel:"+t),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()},ja.loadLevel.get=function(){return this.levelController.level},ja.loadLevel.set=function(t){L.log("set loadLevel:"+t),this.levelController.manualLevel=t},ja.nextLoadLevel.get=function(){return this.levelController.nextLoadLevel},ja.nextLoadLevel.set=function(t){this.levelController.nextLoadLevel=t},ja.firstLevel.get=function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},ja.firstLevel.set=function(t){L.log("set firstLevel:"+t),this.levelController.firstLevel=t},ja.startLevel.get=function(){return this.levelController.startLevel},ja.startLevel.set=function(t){L.log("set startLevel:"+t),-1!==t&&(t=Math.max(t,this.minAutoLevel)),this.levelController.startLevel=t},ja.capLevelToPlayerSize.get=function(){return this.config.capLevelToPlayerSize},ja.capLevelToPlayerSize.set=function(t){var e=!!t;e!==this.config.capLevelToPlayerSize&&(e?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=e)},ja.autoLevelCapping.get=function(){return this._autoLevelCapping},ja.bandwidthEstimate.get=function(){var t=this.abrController.bwEstimator;return t?t.getEstimate():NaN},ja.ttfbEstimate.get=function(){var t=this.abrController.bwEstimator;return t?t.getEstimateTTFB():NaN},ja.autoLevelCapping.set=function(t){this._autoLevelCapping!==t&&(L.log("set autoLevelCapping:"+t),this._autoLevelCapping=t)},ja.maxHdcpLevel.get=function(){return this._maxHdcpLevel},ja.maxHdcpLevel.set=function(t){we.indexOf(t)>-1&&(this._maxHdcpLevel=t)},ja.autoLevelEnabled.get=function(){return-1===this.levelController.manualLevel},ja.manualLevel.get=function(){return this.levelController.manualLevel},ja.minAutoLevel.get=function(){var t=this.levels,e=this.config.minAutoBitrate;if(!t)return 0;for(var r=t.length,i=0;i=e)return i;return 0},ja.maxAutoLevel.get=function(){var t,e=this,r=e.levels,i=e.autoLevelCapping,n=e.maxHdcpLevel;if(t=-1===i&&r&&r.length?r.length-1:i,n)for(var a=t;a--;){var s=r[a].attrs["HDCP-LEVEL"];if(s&&s<=n)return a}return t},ja.nextAutoLevel.get=function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},ja.nextAutoLevel.set=function(t){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,t)},ja.playingDate.get=function(){return this.streamController.currentProgramDateTime},ja.mainForwardBufferInfo.get=function(){return this.streamController.getMainFwdBufferInfo()},ja.audioTracks.get=function(){var t=this.audioTrackController;return t?t.audioTracks:[]},ja.audioTrack.get=function(){var t=this.audioTrackController;return t?t.audioTrack:-1},ja.audioTrack.set=function(t){var e=this.audioTrackController;e&&(e.audioTrack=t)},ja.subtitleTracks.get=function(){var t=this.subtitleTrackController;return t?t.subtitleTracks:[]},ja.subtitleTrack.get=function(){var t=this.subtitleTrackController;return t?t.subtitleTrack:-1},ja.media.get=function(){return this._media},ja.subtitleTrack.set=function(t){var e=this.subtitleTrackController;e&&(e.subtitleTrack=t)},ja.subtitleDisplay.get=function(){var t=this.subtitleTrackController;return!!t&&t.subtitleDisplay},ja.subtitleDisplay.set=function(t){var e=this.subtitleTrackController;e&&(e.subtitleDisplay=t)},ja.lowLatencyMode.get=function(){return this.config.lowLatencyMode},ja.lowLatencyMode.set=function(t){this.config.lowLatencyMode=t},ja.liveSyncPosition.get=function(){return this.latencyController.liveSyncPosition},ja.latency.get=function(){return this.latencyController.latency},ja.maxLatency.get=function(){return this.latencyController.maxLatency},ja.targetLatency.get=function(){return this.latencyController.targetLatency},ja.drift.get=function(){return this.latencyController.drift},ja.forceStartLoad.get=function(){return this.streamController.forceStartLoad},Object.defineProperties(Wa.prototype,ja),Object.defineProperties(Wa,qa),Wa.defaultConfig=void 0,t.default=Wa}));