lemon-mse 0.2.7 → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- package/dist/es/a.d.ts +3105 -0
- package/dist/es/flv.d.ts +587 -0
- package/dist/es/flv.js +6 -1
- package/dist/es/hls.d.ts +3 -0
- package/dist/es/hls.js +14 -1
- package/dist/es/index.d.ts +4 -0
- package/dist/es/index.js +19 -1
- package/dist/flv.js +24 -0
- package/dist/hls.js +32 -0
- package/dist/index.js +37 -0
- package/dist/lemon.css +1 -1
- package/dist/lemon.js +1 -1
- package/dist/webmssdk.es5.js +2 -0
- package/package.json +7 -9
package/dist/es/hls.js
CHANGED
@@ -1 +1,14 @@
|
|
1
|
-
var e={539:e=>{!function t(r){e.exports=function(){function e(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}function i(t){for(var r=1;r<arguments.length;r++){var i=null!=arguments[r]?arguments[r]:{};r%2?e(Object(i),!0).forEach((function(e){var r,n,s;r=t,n=e,s=i[e],(n=a(n))in r?Object.defineProperty(r,n,{value:s,enumerable:!0,configurable:!0,writable:!0}):r[n]=s})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):e(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}function a(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}function n(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,a(i.key),i)}}function s(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function o(){return o=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},o.apply(this,arguments)}function l(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,d(e,t)}function u(e){return u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},u(e)}function d(e,t){return d=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},d(e,t)}function h(e,t,r){return h=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}()?Reflect.construct.bind():function(e,t,r){var i=[null];i.push.apply(i,t);var a=new(Function.bind.apply(e,i));return r&&d(a,r.prototype),a},h.apply(null,arguments)}function f(e){var t="function"==typeof Map?new Map:void 0;return f=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return h(e,arguments,u(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),d(r,e)},f(e)}function c(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var v={exports:{}};!function(e){var t,r,i,a,n;t=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,r=/^(?=([^\/?#]*))\1([^]*)$/,i=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,n={buildAbsoluteURL:function(e,t,i){if(i=i||{},e=e.trim(),!(t=t.trim())){if(!i.alwaysNormalize)return e;var a=n.parseURL(e);if(!a)throw new Error("Error trying to parse base URL.");return a.path=n.normalizePath(a.path),n.buildURLFromParts(a)}var s=n.parseURL(t);if(!s)throw new Error("Error trying to parse relative URL.");if(s.scheme)return i.alwaysNormalize?(s.path=n.normalizePath(s.path),n.buildURLFromParts(s)):t;var o=n.parseURL(e);if(!o)throw new Error("Error trying to parse base URL.");if(!o.netLoc&&o.path&&"/"!==o.path[0]){var l=r.exec(o.path);o.netLoc=l[1],o.path=l[2]}o.netLoc&&!o.path&&(o.path="/");var u={scheme:o.scheme,netLoc:s.netLoc,path:null,params:s.params,query:s.query,fragment:s.fragment};if(!s.netLoc&&(u.netLoc=o.netLoc,"/"!==s.path[0]))if(s.path){var d=o.path,h=d.substring(0,d.lastIndexOf("/")+1)+s.path;u.path=n.normalizePath(h)}else u.path=o.path,s.params||(u.params=o.params,s.query||(u.query=o.query));return null===u.path&&(u.path=i.alwaysNormalize?n.normalizePath(s.path):s.path),n.buildURLFromParts(u)},parseURL:function(e){var r=t.exec(e);return r?{scheme:r[1]||"",netLoc:r[2]||"",path:r[3]||"",params:r[4]||"",query:r[5]||"",fragment:r[6]||""}:null},normalizePath:function(e){for(e=e.split("").reverse().join("").replace(i,"");e.length!==(e=e.replace(a,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}},e.exports=n}(v);var g=v.exports,m=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},p=Number.isSafeInteger||function(e){return"number"==typeof e&&Math.abs(e)<=y},y=Number.MAX_SAFE_INTEGER||9007199254740991,E=function(e){return e.MEDIA_ATTACHING="hlsMediaAttaching",e.MEDIA_ATTACHED="hlsMediaAttached",e.MEDIA_DETACHING="hlsMediaDetaching",e.MEDIA_DETACHED="hlsMediaDetached",e.BUFFER_RESET="hlsBufferReset",e.BUFFER_CODECS="hlsBufferCodecs",e.BUFFER_CREATED="hlsBufferCreated",e.BUFFER_APPENDING="hlsBufferAppending",e.BUFFER_APPENDED="hlsBufferAppended",e.BUFFER_EOS="hlsBufferEos",e.BUFFER_FLUSHING="hlsBufferFlushing",e.BUFFER_FLUSHED="hlsBufferFlushed",e.MANIFEST_LOADING="hlsManifestLoading",e.MANIFEST_LOADED="hlsManifestLoaded",e.MANIFEST_PARSED="hlsManifestParsed",e.LEVEL_SWITCHING="hlsLevelSwitching",e.LEVEL_SWITCHED="hlsLevelSwitched",e.LEVEL_LOADING="hlsLevelLoading",e.LEVEL_LOADED="hlsLevelLoaded",e.LEVEL_UPDATED="hlsLevelUpdated",e.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",e.LEVELS_UPDATED="hlsLevelsUpdated",e.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",e.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",e.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",e.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",e.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",e.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",e.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",e.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",e.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",e.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",e.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",e.CUES_PARSED="hlsCuesParsed",e.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",e.INIT_PTS_FOUND="hlsInitPtsFound",e.FRAG_LOADING="hlsFragLoading",e.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",e.FRAG_LOADED="hlsFragLoaded",e.FRAG_DECRYPTED="hlsFragDecrypted",e.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",e.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",e.FRAG_PARSING_METADATA="hlsFragParsingMetadata",e.FRAG_PARSED="hlsFragParsed",e.FRAG_BUFFERED="hlsFragBuffered",e.FRAG_CHANGED="hlsFragChanged",e.FPS_DROP="hlsFpsDrop",e.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",e.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",e.ERROR="hlsError",e.DESTROYING="hlsDestroying",e.KEY_LOADING="hlsKeyLoading",e.KEY_LOADED="hlsKeyLoaded",e.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",e.BACK_BUFFER_REACHED="hlsBackBufferReached",e.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",e}({}),T=function(e){return e.NETWORK_ERROR="networkError",e.MEDIA_ERROR="mediaError",e.KEY_SYSTEM_ERROR="keySystemError",e.MUX_ERROR="muxError",e.OTHER_ERROR="otherError",e}({}),S=function(e){return e.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",e.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",e.KEY_SYSTEM_NO_SESSION="keySystemNoSession",e.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",e.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",e.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",e.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",e.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",e.MANIFEST_LOAD_ERROR="manifestLoadError",e.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",e.MANIFEST_PARSING_ERROR="manifestParsingError",e.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",e.LEVEL_EMPTY_ERROR="levelEmptyError",e.LEVEL_LOAD_ERROR="levelLoadError",e.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",e.LEVEL_PARSING_ERROR="levelParsingError",e.LEVEL_SWITCH_ERROR="levelSwitchError",e.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",e.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",e.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",e.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",e.FRAG_LOAD_ERROR="fragLoadError",e.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",e.FRAG_DECRYPT_ERROR="fragDecryptError",e.FRAG_PARSING_ERROR="fragParsingError",e.FRAG_GAP="fragGap",e.REMUX_ALLOC_ERROR="remuxAllocError",e.KEY_LOAD_ERROR="keyLoadError",e.KEY_LOAD_TIMEOUT="keyLoadTimeOut",e.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",e.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",e.BUFFER_APPEND_ERROR="bufferAppendError",e.BUFFER_APPENDING_ERROR="bufferAppendingError",e.BUFFER_STALLED_ERROR="bufferStalledError",e.BUFFER_FULL_ERROR="bufferFullError",e.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",e.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",e.INTERNAL_EXCEPTION="internalException",e.INTERNAL_ABORTED="aborted",e.UNKNOWN="unknown",e}({}),L=function(){},R={trace:L,debug:L,log:L,warn:L,info:L,error:L},A=R;function b(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];r.forEach((function(t){A[t]=e[t]?e[t].bind(e):function(e){var t=self.console[e];return t?t.bind(self.console,"["+e+"] >"):L}(t)}))}function D(e,t){if("object"==typeof console&&!0===e||"object"==typeof e){b(e,"debug","log","info","warn","error");try{A.log('Debug logs enabled for "'+t+'" in hls.js version 1.5.17')}catch(e){A=R}}else A=R}var k=A,_=/^(\d+)x(\d+)$/,x=/(.+?)=(".*?"|.*?)(?:,|$)/g,w=function(){function e(t){"string"==typeof t&&(t=e.parseAttrList(t)),o(this,t)}var t=e.prototype;return t.decimalInteger=function(e){var t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t},t.hexadecimalInteger=function(e){if(this[e]){var t=(this[e]||"0x").slice(2);t=(1&t.length?"0":"")+t;for(var r=new Uint8Array(t.length/2),i=0;i<t.length/2;i++)r[i]=parseInt(t.slice(2*i,2*i+2),16);return r}return null},t.hexadecimalIntegerAsNumber=function(e){var t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t},t.decimalFloatingPoint=function(e){return parseFloat(this[e])},t.optionalFloat=function(e,t){var r=this[e];return r?parseFloat(r):t},t.enumeratedString=function(e){return this[e]},t.bool=function(e){return"YES"===this[e]},t.decimalResolution=function(e){var t=_.exec(this[e]);if(null!==t)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}},e.parseAttrList=function(e){var t,r={};for(x.lastIndex=0;null!==(t=x.exec(e));){var i=t[2];0===i.indexOf('"')&&i.lastIndexOf('"')===i.length-1&&(i=i.slice(1,-1)),r[t[1].trim()]=i}return r},s(e,[{key:"clientAttrs",get:function(){return Object.keys(this).filter((function(e){return"X-"===e.substring(0,2)}))}}]),e}();function C(e){return"SCTE35-OUT"===e||"SCTE35-IN"===e}var I=function(){function e(e,t){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,t){var r=t.attr;for(var i in r)if(Object.prototype.hasOwnProperty.call(e,i)&&e[i]!==r[i]){k.warn('DATERANGE tag attribute: "'+i+'" does not match for tags with ID: "'+e.ID+'"'),this._badValueForSameId=i;break}e=o(new w({}),r,e)}if(this.attr=e,this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){var a=new Date(this.attr["END-DATE"]);m(a.getTime())&&(this._endDate=a)}}return s(e,[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){if(this._endDate)return this._endDate;var e=this.duration;return null!==e?new Date(this._startDate.getTime()+1e3*e):null}},{key:"duration",get:function(){if("DURATION"in this.attr){var e=this.attr.decimalFloatingPoint("DURATION");if(m(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}},{key:"endOnNext",get:function(){return this.attr.bool("END-ON-NEXT")}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&m(this.startDate.getTime())&&(null===this.duration||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),e}(),P=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}},F="audio",O="video",M="audiovideo",N=function(){function e(e){var t;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=((t={})[F]=null,t[O]=null,t[M]=null,t),this.baseurl=e}return e.prototype.setByteRange=function(e,t){var r,i=e.split("@",2);r=1===i.length?(null==t?void 0:t.byteRangeEndOffset)||0:parseInt(i[1]),this._byteRange=[r,parseInt(i[0])+r]},s(e,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=g.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(e){this._url=e}}]),e}(),B=function(e){function t(t,r){var i;return(i=e.call(this,r)||this)._decryptdata=null,i.rawProgramDateTime=null,i.programDateTime=null,i.tagList=[],i.duration=0,i.sn=0,i.levelkeys=void 0,i.type=void 0,i.loader=null,i.keyLoader=null,i.level=-1,i.cc=0,i.startPTS=void 0,i.endPTS=void 0,i.startDTS=void 0,i.endDTS=void 0,i.start=0,i.deltaPTS=void 0,i.maxStartPTS=void 0,i.minEndPTS=void 0,i.stats=new P,i.data=void 0,i.bitrateTest=!1,i.title=null,i.initSegment=null,i.endList=void 0,i.gap=void 0,i.urlId=0,i.type=t,i}l(t,e);var r=t.prototype;return r.setKeyFormat=function(e){if(this.levelkeys){var t=this.levelkeys[e];t&&!this._decryptdata&&(this._decryptdata=t.getDecryptData(this.sn))}},r.abortRequests=function(){var e,t;null==(e=this.loader)||e.abort(),null==(t=this.keyLoader)||t.abort()},r.setElementaryStreamInfo=function(e,t,r,i,a,n){void 0===n&&(n=!1);var s=this.elementaryStreams,o=s[e];o?(o.startPTS=Math.min(o.startPTS,t),o.endPTS=Math.max(o.endPTS,r),o.startDTS=Math.min(o.startDTS,i),o.endDTS=Math.max(o.endDTS,a)):s[e]={startPTS:t,endPTS:r,startDTS:i,endDTS:a,partial:n}},r.clearElementaryStreamInfo=function(){var e=this.elementaryStreams;e[F]=null,e[O]=null,e[M]=null},s(t,[{key:"decryptdata",get:function(){if(!this.levelkeys&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){var e=this.levelkeys.identity;if(e)this._decryptdata=e.getDecryptData(this.sn);else{var t=Object.keys(this.levelkeys);if(1===t.length)return this._decryptdata=this.levelkeys[t[0]].getDecryptData(this.sn)}}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(null===this.programDateTime)return null;if(!m(this.programDateTime))return null;var e=m(this.duration)?this.duration:0;return this.programDateTime+1e3*e}},{key:"encrypted",get:function(){var e;if(null!=(e=this._decryptdata)&&e.encrypted)return!0;if(this.levelkeys){var t=Object.keys(this.levelkeys),r=t.length;if(r>1||1===r&&this.levelkeys[t[0]].encrypted)return!0}return!1}}]),t}(N),U=function(e){function t(t,r,i,a,n){var s;(s=e.call(this,i)||this).fragOffset=0,s.duration=0,s.gap=!1,s.independent=!1,s.relurl=void 0,s.fragment=void 0,s.index=void 0,s.stats=new P,s.duration=t.decimalFloatingPoint("DURATION"),s.gap=t.bool("GAP"),s.independent=t.bool("INDEPENDENT"),s.relurl=t.enumeratedString("URI"),s.fragment=r,s.index=a;var o=t.enumeratedString("BYTERANGE");return o&&s.setByteRange(o,n),n&&(s.fragOffset=n.fragOffset+n.duration),s}return l(t,e),s(t,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var e=this.elementaryStreams;return!!(e.audio||e.video||e.audiovideo)}}]),t}(N),G=function(){function e(e){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.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=e}return e.prototype.reloaded=function(e){if(!e)return this.advanced=!0,void(this.updated=!0);var t=this.lastPartSn-e.lastPartSn,r=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!r||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||0===t&&r>0,this.updated||this.advanced?this.misses=Math.floor(.6*e.misses):this.misses=e.misses+1,this.availabilityDelay=e.availabilityDelay},s(e,[{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&m(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||10}},{key:"drift",get:function(){var e=this.driftEndTime-this.driftStartTime;return e>0?1e3*(this.driftEnd-this.driftStart)/e:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var e;return null!=(e=this.fragments)&&e.length?this.fragments[this.fragments.length-1].end:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),e}(),H=c(void 0);function V(e,t,r){return Uint8Array.prototype.slice?e.slice(t,r):new Uint8Array(Array.prototype.slice.call(e,t,r))}var K,j=function(e,t){return t+10<=e.length&&73===e[t]&&68===e[t+1]&&51===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128},W=function(e,t){return t+10<=e.length&&51===e[t]&&68===e[t+1]&&73===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128},Y=function(e,t){for(var r=t,i=0;j(e,t);)i+=10,i+=q(e,t+6),W(e,t+10)&&(i+=10),t+=i;if(i>0)return e.subarray(r,r+i)},q=function(e,t){var r=0;return r=(127&e[t])<<21,r|=(127&e[t+1])<<14,(r|=(127&e[t+2])<<7)|127&e[t+3]},z=function(e,t){return j(e,t)&&q(e,t+6)+10<=e.length-t},X=function(e){for(var t=$(e),r=0;r<t.length;r++){var i=t[r];if(Q(i))return ie(i)}},Q=function(e){return e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info},J=function(e){var t=String.fromCharCode(e[0],e[1],e[2],e[3]),r=q(e,4);return{type:t,size:r,data:e.subarray(10,10+r)}},$=function(e){for(var t=0,r=[];j(e,t);){for(var i=q(e,t+6),a=(t+=10)+i;t+8<a;){var n=J(e.subarray(t)),s=Z(n);s&&r.push(s),t+=n.size+10}W(e,t)&&(t+=10)}return r},Z=function(e){return"PRIV"===e.type?ee(e):"W"===e.type[0]?re(e):te(e)},ee=function(e){if(!(e.size<2)){var t=ae(e.data,!0),r=new Uint8Array(e.data.subarray(t.length+1));return{key:e.type,info:t,data:r.buffer}}},te=function(e){if(!(e.size<2)){if("TXXX"===e.type){var t=1,r=ae(e.data.subarray(t),!0);t+=r.length+1;var i=ae(e.data.subarray(t));return{key:e.type,info:r,data:i}}var a=ae(e.data.subarray(1));return{key:e.type,data:a}}},re=function(e){if("WXXX"===e.type){if(e.size<2)return;var t=1,r=ae(e.data.subarray(t),!0);t+=r.length+1;var i=ae(e.data.subarray(t));return{key:e.type,info:r,data:i}}var a=ae(e.data);return{key:e.type,data:a}},ie=function(e){if(8===e.data.byteLength){var t=new Uint8Array(e.data),r=1&t[3],i=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return i/=45,r&&(i+=47721858.84),Math.round(i)}},ae=function(e,t){void 0===t&&(t=!1);var r=ne();if(r){var i=r.decode(e);if(t){var a=i.indexOf("\0");return-1!==a?i.substring(0,a):i}return i.replace(/\0/g,"")}for(var n,s,o,l=e.length,u="",d=0;d<l;){if(0===(n=e[d++])&&t)return u;if(0!==n&&3!==n)switch(n>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:u+=String.fromCharCode(n);break;case 12:case 13:s=e[d++],u+=String.fromCharCode((31&n)<<6|63&s);break;case 14:s=e[d++],o=e[d++],u+=String.fromCharCode((15&n)<<12|(63&s)<<6|63&o)}}return u};function ne(){if(!navigator.userAgent.includes("PlayStation 4"))return K||void 0===self.TextDecoder||(K=new self.TextDecoder("utf-8")),K}var se=function(e){for(var t="",r=0;r<e.length;r++){var i=e[r].toString(16);i.length<2&&(i="0"+i),t+=i}return t},oe=Math.pow(2,32)-1,le=[].push,ue={video:1,audio:2,id3:3,text:4};function de(e){return String.fromCharCode.apply(null,e)}function he(e,t){var r=e[t]<<8|e[t+1];return r<0?65536+r:r}function fe(e,t){var r=ve(e,t);return r<0?4294967296+r:r}function ce(e,t){var r=fe(e,t);return(r*=Math.pow(2,32))+fe(e,t+4)}function ve(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function ge(e,t,r){e[t]=r>>24,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r}function me(e,t){var r=[];if(!t.length)return r;for(var i=e.byteLength,a=0;a<i;){var n=fe(e,a),s=n>1?a+n:i;if(de(e.subarray(a+4,a+8))===t[0])if(1===t.length)r.push(e.subarray(a+8,s));else{var o=me(e.subarray(a+8,s),t.slice(1));o.length&&le.apply(r,o)}a=s}return r}function pe(e){var t=[],r=e[0],i=8,a=fe(e,i);i+=4;var n=0,s=0;0===r?(n=fe(e,i),s=fe(e,i+4),i+=8):(n=ce(e,i),s=ce(e,i+8),i+=16),i+=2;var o=e.length+s,l=he(e,i);i+=2;for(var u=0;u<l;u++){var d=i,h=fe(e,d);d+=4;var f=2147483647&h;if(1==(2147483648&h)>>>31)return k.warn("SIDX has hierarchical references (not supported)"),null;var c=fe(e,d);d+=4,t.push({referenceSize:f,subsegmentDuration:c,info:{duration:c/a,start:o,end:o+f-1}}),o+=f,i=d+=4}return{earliestPresentationTime:n,timescale:a,version:r,referencesCount:l,references:t}}function ye(e){for(var t=[],r=me(e,["moov","trak"]),a=0;a<r.length;a++){var n=r[a],s=me(n,["tkhd"])[0];if(s){var o=s[0],l=fe(s,0===o?12:20),u=me(n,["mdia","mdhd"])[0];if(u){var d=fe(u,0===(o=u[0])?12:20),h=me(n,["mdia","hdlr"])[0];if(h){var f=de(h.subarray(8,12)),c={soun:F,vide:O}[f];if(c){var v=Ee(me(n,["mdia","minf","stbl","stsd"])[0]);t[l]={timescale:d,type:c},t[c]=i({timescale:d,id:l},v)}}}}}return me(e,["moov","mvex","trex"]).forEach((function(e){var r=fe(e,4),i=t[r];i&&(i.default={duration:fe(e,12),flags:fe(e,20)})})),t}function Ee(e){var t=e.subarray(8),r=t.subarray(86),i=de(t.subarray(4,8)),a=i,n="enca"===i||"encv"===i;if(n){var s=me(t,[i])[0];me(s.subarray("enca"===i?28:78),["sinf"]).forEach((function(e){var t=me(e,["schm"])[0];if(t){var r=de(t.subarray(4,8));if("cbcs"===r||"cenc"===r){var i=me(e,["frma"])[0];i&&(a=de(i))}}}))}switch(a){case"avc1":case"avc2":case"avc3":case"avc4":var o=me(r,["avcC"])[0];a+="."+Se(o[1])+Se(o[2])+Se(o[3]);break;case"mp4a":var l=me(t,[i])[0],u=me(l.subarray(28),["esds"])[0];if(u&&u.length>12){var d=4;if(3!==u[d++])break;d=Te(u,d),d+=2;var h=u[d++];if(128&h&&(d+=2),64&h&&(d+=u[d++]),4!==u[d++])break;d=Te(u,d);var f=u[d++];if(64!==f)break;if(a+="."+Se(f),d+=12,5!==u[d++])break;d=Te(u,d);var c=u[d++],v=(248&c)>>3;31===v&&(v+=1+((7&c)<<3)+((224&u[d])>>5)),a+="."+v}break;case"hvc1":case"hev1":var g=me(r,["hvcC"])[0],m=g[1],p=["","A","B","C"][m>>6],y=31&m,E=fe(g,2),T=(32&m)>>5?"H":"L",S=g[12],L=g.subarray(6,12);a+="."+p+y,a+="."+E.toString(16).toUpperCase(),a+="."+T+S;for(var R="",A=L.length;A--;){var b=L[A];(b||R)&&(R="."+b.toString(16).toUpperCase()+R)}a+=R;break;case"dvh1":case"dvhe":var D=me(r,["dvcC"])[0],k=D[2]>>1&127,_=D[2]<<5&32|D[3]>>3&31;a+="."+Le(k)+"."+Le(_);break;case"vp09":var x=me(r,["vpcC"])[0],w=x[4],C=x[5],I=x[6]>>4&15;a+="."+Le(w)+"."+Le(C)+"."+Le(I);break;case"av01":var P=me(r,["av1C"])[0],F=P[1]>>>5,O=31&P[1],M=P[2]>>>7?"H":"M",N=(64&P[2])>>6,B=(32&P[2])>>5,U=2===F&&N?B?12:10:N?10:8,G=(16&P[2])>>4,H=(8&P[2])>>3,V=(4&P[2])>>2,K=3&P[2];a+="."+F+"."+Le(O)+M+"."+Le(U)+"."+G+"."+H+V+K+"."+Le(1)+"."+Le(1)+"."+Le(1)+".0"}return{codec:a,encrypted:n}}function Te(e,t){for(var r=t+5;128&e[t++]&&t<r;);return t}function Se(e){return("0"+e.toString(16).toUpperCase()).slice(-2)}function Le(e){return(e<10?"0":"")+e}function Re(e,t){if(!e||!t)return e;var r=t.keyId;return r&&t.isCommonEncryption&&me(e,["moov","trak"]).forEach((function(e){var t=me(e,["mdia","minf","stbl","stsd"])[0].subarray(8),i=me(t,["enca"]),a=i.length>0;a||(i=me(t,["encv"])),i.forEach((function(e){me(a?e.subarray(28):e.subarray(78),["sinf"]).forEach((function(e){var t=function(e){var t=me(e,["schm"])[0];if(t){var r=de(t.subarray(4,8));if("cbcs"===r||"cenc"===r)return me(e,["schi","tenc"])[0]}return null}(e);if(t){var i=t.subarray(8,24);i.some((function(e){return 0!==e}))||(k.log("[eme] Patching keyId in 'enc"+(a?"a":"v")+">sinf>>tenc' box: "+se(i)+" -> "+se(r)),t.set(r,8))}}))}))})),e}function Ae(e){var t=fe(e,0),r=8;1&t&&(r+=4),4&t&&(r+=4);for(var i=0,a=fe(e,4),n=0;n<a;n++)256&t&&(i+=fe(e,r),r+=4),512&t&&(r+=4),1024&t&&(r+=4),2048&t&&(r+=4);return i}function be(e,t){var r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}function De(e,t){var r=[],i=t.samples,a=t.timescale,n=t.id,s=!1;return me(i,["moof"]).map((function(o){var l=o.byteOffset-8;me(o,["traf"]).map((function(o){var u=me(o,["tfdt"]).map((function(e){var t=e[0],r=fe(e,4);return 1===t&&(r*=Math.pow(2,32),r+=fe(e,8)),r/a}))[0];return void 0!==u&&(e=u),me(o,["tfhd"]).map((function(u){var d=fe(u,4),h=16777215&fe(u,0),f=0,c=!!(16&h),v=0,g=!!(32&h),m=8;d===n&&(!!(1&h)&&(m+=8),!!(2&h)&&(m+=4),!!(8&h)&&(f=fe(u,m),m+=4),c&&(v=fe(u,m),m+=4),g&&(m+=4),"video"===t.type&&(s=function(e){if(!e)return!1;var t=e.indexOf("."),r=t<0?e:e.substring(0,t);return"hvc1"===r||"hev1"===r||"dvh1"===r||"dvhe"===r}(t.codec)),me(o,["trun"]).map((function(n){var o=n[0],u=16777215&fe(n,0),d=!!(1&u),h=0,c=!!(4&u),g=!!(256&u),m=0,p=!!(512&u),y=0,E=!!(1024&u),T=!!(2048&u),S=0,L=fe(n,4),R=8;d&&(h=fe(n,R),R+=4),c&&(R+=4);for(var A=h+l,b=0;b<L;b++){if(g?(m=fe(n,R),R+=4):m=f,p?(y=fe(n,R),R+=4):y=v,E&&(R+=4),T&&(S=0===o?fe(n,R):ve(n,R),R+=4),t.type===O)for(var D=0;D<y;){var k=fe(i,A);ke(s,i[A+=4])&&_e(i.subarray(A,A+k),s?2:1,e+S/a,r),A+=k,D+=k+4}e+=m/a}})))}))}))})),r}function ke(e,t){if(e){var r=t>>1&63;return 39===r||40===r}return 6==(31&t)}function _e(e,t,r,i){var a=xe(e),n=0;n+=t;for(var s=0,o=0,l=0;n<a.length;){s=0;do{if(n>=a.length)break;s+=l=a[n++]}while(255===l);o=0;do{if(n>=a.length)break;o+=l=a[n++]}while(255===l);var u=a.length-n,d=n;if(o<u)n+=o;else if(o>u){k.error("Malformed SEI payload. "+o+" is too small, only "+u+" bytes left to parse.");break}if(4===s){if(181===a[d++]){var h=he(a,d);if(d+=2,49===h){var f=fe(a,d);if(d+=4,1195456820===f){var c=a[d++];if(3===c){var v=a[d++],g=64&v,m=g?2+3*(31&v):0,p=new Uint8Array(m);if(g){p[0]=v;for(var y=1;y<m;y++)p[y]=a[d++]}i.push({type:c,payloadType:s,pts:r,bytes:p})}}}}}else if(5===s&&o>16){for(var E=[],T=0;T<16;T++){var S=a[d++].toString(16);E.push(1==S.length?"0"+S:S),3!==T&&5!==T&&7!==T&&9!==T||E.push("-")}for(var L=o-16,R=new Uint8Array(L),A=0;A<L;A++)R[A]=a[d++];i.push({payloadType:s,pts:r,uuid:E.join(""),userData:ae(R),userDataBytes:R})}}}function xe(e){for(var t=e.byteLength,r=[],i=1;i<t-2;)0===e[i]&&0===e[i+1]&&3===e[i+2]?(r.push(i+2),i+=2):i++;if(0===r.length)return e;var a=t-r.length,n=new Uint8Array(a),s=0;for(i=0;i<a;s++,i++)s===r[0]&&(s++,r.shift()),n[i]=e[s];return n}var we=function(){function e(e,t,r,i,a){void 0===i&&(i=[1]),void 0===a&&(a=null),this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=e,this.uri=t,this.keyFormat=r,this.keyFormatVersions=i,this.iv=a,this.encrypted=!!e&&"NONE"!==e,this.isCommonEncryption=this.encrypted&&"AES-128"!==e}e.clearKeyUriToKeyIdMap=function(){};var t=e.prototype;return t.isSupported=function(){if(this.method){if("AES-128"===this.method||"NONE"===this.method)return!0;if("identity"===this.keyFormat)return"SAMPLE-AES"===this.method}return!1},t.getDecryptData=function(t){if(!this.encrypted||!this.uri)return null;if("AES-128"===this.method&&this.uri&&!this.iv){"number"!=typeof t&&("AES-128"!==this.method||this.iv||k.warn('missing IV for initialization segment with method="'+this.method+'" - compliance issue'),t=0);var r=function(e){for(var t=new Uint8Array(16),r=12;r<16;r++)t[r]=e>>8*(15-r)&255;return t}(t);return new e(this.method,this.uri,"identity",this.keyFormatVersions,r)}return this},e}();function Ce(e){if(void 0===e&&(e=!0),"undefined"!=typeof self)return(e||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}var Ie={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv60:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1}};function Pe(e,t,r){return void 0===r&&(r=!0),!e.split(",").some((function(e){return!Fe(e,t,r)}))}function Fe(e,t,r){var i;void 0===r&&(r=!0);var a=Ce(r);return null!=(i=null==a?void 0:a.isTypeSupported(Oe(e,t)))&&i}function Oe(e,t){return t+'/mp4;codecs="'+e+'"'}function Me(e){if(e){var t=e.substring(0,4);return Ie.video[t]}return 2}function Ne(e){return e.split(",").reduce((function(e,t){var r=Ie.video[t];return r?(2*r+e)/(e?3:2):(Ie.audio[t]+e)/(e?2:1)}),0)}var Be={};var Ue=/flac|opus/i;function Ge(e,t){return void 0===t&&(t=!0),e.replace(Ue,(function(e){return function(e,t){if(void 0===t&&(t=!0),Be[e])return Be[e];for(var r={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"]}[e],i=0;i<r.length;i++)if(Fe(r[i],"audio",t))return Be[e]=r[i],r[i];return e}(e.toLowerCase(),t)}))}function He(e,t){return e&&"mp4a"!==e?e:t?t.split(",")[0]:t}var Ve=/#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,Ke=/#EXT-X-MEDIA:(.*)/g,je=/^#EXT(?:INF|-X-TARGETDURATION):/m,We=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),Ye=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|INDEPENDENT-SEGMENTS)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),qe=function(){function e(){}return e.findGroup=function(e,t){for(var r=0;r<e.length;r++){var i=e[r];if(i.id===t)return i}},e.resolve=function(e,t){return g.buildAbsoluteURL(t,e,{alwaysNormalize:!0})},e.isMediaPlaylist=function(e){return je.test(e)},e.parseMasterPlaylist=function(t,r){var i,a={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:!1},n=[];for(Ve.lastIndex=0;null!=(i=Ve.exec(t));)if(i[1]){var s,o=new w(i[1]),l=i[2],u={attrs:o,bitrate:o.decimalInteger("BANDWIDTH")||o.decimalInteger("AVERAGE-BANDWIDTH"),name:o.NAME,url:e.resolve(l,r)},d=o.decimalResolution("RESOLUTION");d&&(u.width=d.width,u.height=d.height),Qe(o.CODECS,u),null!=(s=u.unknownCodecs)&&s.length||n.push(u),a.levels.push(u)}else if(i[3]){var h=i[3],f=i[4];switch(h){case"SESSION-DATA":var c=new w(f),v=c["DATA-ID"];v&&(null===a.sessionData&&(a.sessionData={}),a.sessionData[v]=c);break;case"SESSION-KEY":var g=ze(f,r);g.encrypted&&g.isSupported()?(null===a.sessionKeys&&(a.sessionKeys=[]),a.sessionKeys.push(g)):k.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+f+'"');break;case"DEFINE":break;case"CONTENT-STEERING":var m=new w(f);a.contentSteering={uri:e.resolve(m["SERVER-URI"],r),pathwayId:m["PATHWAY-ID"]||"."};break;case"START":a.startTimeOffset=Xe(f)}}var p=n.length>0&&n.length<a.levels.length;return a.levels=p?n:a.levels,0===a.levels.length&&(a.playlistParsingError=new Error("no levels found in manifest")),a},e.parseMasterPlaylistMedia=function(t,r,i){var a,n={},s=i.levels,o={AUDIO:s.map((function(e){return{id:e.attrs.AUDIO,audioCodec:e.audioCodec}})),SUBTITLES:s.map((function(e){return{id:e.attrs.SUBTITLES,textCodec:e.textCodec}})),"CLOSED-CAPTIONS":[]},l=0;for(Ke.lastIndex=0;null!==(a=Ke.exec(t));){var u=new w(a[1]),d=u.TYPE;if(d){var h=o[d],f=n[d]||[];n[d]=f;var c=u.LANGUAGE,v=u["ASSOC-LANGUAGE"],g=u.CHANNELS,m=u.CHARACTERISTICS,p=u["INSTREAM-ID"],y={attrs:u,bitrate:0,id:l++,groupId:u["GROUP-ID"]||"",name:u.NAME||c||"",type:d,default:u.bool("DEFAULT"),autoselect:u.bool("AUTOSELECT"),forced:u.bool("FORCED"),lang:c,url:u.URI?e.resolve(u.URI,r):""};if(v&&(y.assocLang=v),g&&(y.channels=g),m&&(y.characteristics=m),p&&(y.instreamId=p),null!=h&&h.length){var E=e.findGroup(h,y.groupId)||h[0];Je(y,E,"audioCodec"),Je(y,E,"textCodec")}f.push(y)}}return n},e.parseLevelPlaylist=function(e,t,r,i,a,n){var s,l,u,d=new G(t),h=d.fragments,f=null,c=0,v=0,g=0,p=0,y=null,E=new B(i,t),T=-1,S=!1,L=null;for(We.lastIndex=0,d.m3u8=e,d.hasVariableRefs=!1;null!==(s=We.exec(e));){S&&(S=!1,(E=new B(i,t)).start=g,E.sn=c,E.cc=p,E.level=r,f&&(E.initSegment=f,E.rawProgramDateTime=f.rawProgramDateTime,f.rawProgramDateTime=null,L&&(E.setByteRange(L),L=null)));var R=s[1];if(R){E.duration=parseFloat(R);var A=(" "+s[2]).slice(1);E.title=A||null,E.tagList.push(A?["INF",R,A]:["INF",R])}else if(s[3]){if(m(E.duration)){E.start=g,u&&et(E,u,d),E.sn=c,E.level=r,E.cc=p,h.push(E);var b=(" "+s[3]).slice(1);E.relurl=b,$e(E,y),y=E,g+=E.duration,c++,v=0,S=!0}}else if(s[4]){var D=(" "+s[4]).slice(1);y?E.setByteRange(D,y):E.setByteRange(D)}else if(s[5])E.rawProgramDateTime=(" "+s[5]).slice(1),E.tagList.push(["PROGRAM-DATE-TIME",E.rawProgramDateTime]),-1===T&&(T=h.length);else{if(!(s=s[0].match(Ye))){k.warn("No matches on slow regex match for level playlist!");continue}for(l=1;l<s.length&&void 0===s[l];l++);var _=(" "+s[l]).slice(1),x=(" "+s[l+1]).slice(1),C=s[l+2]?(" "+s[l+2]).slice(1):"";switch(_){case"PLAYLIST-TYPE":d.type=x.toUpperCase();break;case"MEDIA-SEQUENCE":c=d.startSN=parseInt(x);break;case"SKIP":var P=new w(x),F=P.decimalInteger("SKIPPED-SEGMENTS");if(m(F)){d.skippedSegments=F;for(var O=F;O--;)h.unshift(null);c+=F}var M=P.enumeratedString("RECENTLY-REMOVED-DATERANGES");M&&(d.recentlyRemovedDateranges=M.split("\t"));break;case"TARGETDURATION":d.targetduration=Math.max(parseInt(x),1);break;case"VERSION":d.version=parseInt(x);break;case"INDEPENDENT-SEGMENTS":case"EXTM3U":case"DEFINE":break;case"ENDLIST":d.live=!1;break;case"#":(x||C)&&E.tagList.push(C?[x,C]:[x]);break;case"DISCONTINUITY":p++,E.tagList.push(["DIS"]);break;case"GAP":E.gap=!0,E.tagList.push([_]);break;case"BITRATE":E.tagList.push([_,x]);break;case"DATERANGE":var N=new w(x),H=new I(N,d.dateRanges[N.ID]);H.isValid||d.skippedSegments?d.dateRanges[H.id]=H:k.warn('Ignoring invalid DATERANGE tag: "'+x+'"'),E.tagList.push(["EXT-X-DATERANGE",x]);break;case"DISCONTINUITY-SEQUENCE":p=parseInt(x);break;case"KEY":var V=ze(x,t);if(V.isSupported()){if("NONE"===V.method){u=void 0;break}u||(u={}),u[V.keyFormat]&&(u=o({},u)),u[V.keyFormat]=V}else k.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'+x+'"');break;case"START":d.startTimeOffset=Xe(x);break;case"MAP":var K=new w(x);if(E.duration){var j=new B(i,t);Ze(j,K,r,u),f=j,E.initSegment=f,f.rawProgramDateTime&&!E.rawProgramDateTime&&(E.rawProgramDateTime=f.rawProgramDateTime)}else{var W=E.byteRangeEndOffset;if(W){var Y=E.byteRangeStartOffset;L=W-Y+"@"+Y}else L=null;Ze(E,K,r,u),f=E,S=!0}break;case"SERVER-CONTROL":var q=new w(x);d.canBlockReload=q.bool("CAN-BLOCK-RELOAD"),d.canSkipUntil=q.optionalFloat("CAN-SKIP-UNTIL",0),d.canSkipDateRanges=d.canSkipUntil>0&&q.bool("CAN-SKIP-DATERANGES"),d.partHoldBack=q.optionalFloat("PART-HOLD-BACK",0),d.holdBack=q.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var z=new w(x);d.partTarget=z.decimalFloatingPoint("PART-TARGET");break;case"PART":var X=d.partList;X||(X=d.partList=[]);var Q=v>0?X[X.length-1]:void 0,J=v++,$=new w(x),Z=new U($,E,t,J,Q);X.push(Z),E.duration+=Z.duration;break;case"PRELOAD-HINT":var ee=new w(x);d.preloadHint=ee;break;case"RENDITION-REPORT":var te=new w(x);d.renditionReports=d.renditionReports||[],d.renditionReports.push(te);break;default:k.warn("line parsed but not handled: "+s)}}}y&&!y.relurl?(h.pop(),g-=y.duration,d.partList&&(d.fragmentHint=y)):d.partList&&($e(E,y),E.cc=p,d.fragmentHint=E,u&&et(E,u,d));var re=h.length,ie=h[0],ae=h[re-1];if((g+=d.skippedSegments*d.targetduration)>0&&re&&ae){d.averagetargetduration=g/re;var ne=ae.sn;d.endSN="initSegment"!==ne?ne:0,d.live||(ae.endList=!0),ie&&(d.startCC=ie.cc)}else d.endSN=0,d.startCC=0;return d.fragmentHint&&(g+=d.fragmentHint.duration),d.totalduration=g,d.endCC=p,T>0&&function(e,t){for(var r=e[t],i=t;i--;){var a=e[i];if(!a)return;a.programDateTime=r.programDateTime-1e3*a.duration,r=a}}(h,T),d},e}();function ze(e,t,r){var i,a,n=new w(e),s=null!=(i=n.METHOD)?i:"",o=n.URI,l=n.hexadecimalInteger("IV"),u=n.KEYFORMATVERSIONS,d=null!=(a=n.KEYFORMAT)?a:"identity";o&&n.IV&&!l&&k.error("Invalid IV: "+n.IV);var h=o?qe.resolve(o,t):"",f=(u||"1").split("/").map(Number).filter(Number.isFinite);return new we(s,h,d,f,l)}function Xe(e){var t=new w(e).decimalFloatingPoint("TIME-OFFSET");return m(t)?t:null}function Qe(e,t){var r=(e||"").split(/[ ,]+/).filter((function(e){return e}));["video","audio","text"].forEach((function(e){var i=r.filter((function(t){return function(e,t){var r=Ie[t];return!!r&&!!r[e.slice(0,4)]}(t,e)}));i.length&&(t[e+"Codec"]=i.join(","),r=r.filter((function(e){return-1===i.indexOf(e)})))})),t.unknownCodecs=r}function Je(e,t,r){var i=t[r];i&&(e[r]=i)}function $e(e,t){e.rawProgramDateTime?e.programDateTime=Date.parse(e.rawProgramDateTime):null!=t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime),m(e.programDateTime)||(e.programDateTime=null,e.rawProgramDateTime=null)}function Ze(e,t,r,i){e.relurl=t.URI,t.BYTERANGE&&e.setByteRange(t.BYTERANGE),e.level=r,e.sn="initSegment",i&&(e.levelkeys=i),e.initSegment=null}function et(e,t,r){e.levelkeys=t;var i=r.encryptedFragments;i.length&&i[i.length-1].levelkeys===t||!Object.keys(t).some((function(e){return t[e].isCommonEncryption}))||i.push(e)}var tt="manifest",rt="level",it="audioTrack",at="subtitleTrack",nt="main",st="audio",ot="subtitle";function lt(e){switch(e.type){case it:return st;case at:return ot;default:return nt}}function ut(e,t){var r=e.url;return void 0!==r&&0!==r.indexOf("data:")||(r=t.url),r}var dt=function(){function e(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=e,this.registerListeners()}var t=e.prototype;return t.startLoad=function(e){},t.stopLoad=function(){this.destroyInternalLoaders()},t.registerListeners=function(){var e=this.hls;e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.LEVEL_LOADING,this.onLevelLoading,this),e.on(E.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(E.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},t.unregisterListeners=function(){var e=this.hls;e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.LEVEL_LOADING,this.onLevelLoading,this),e.off(E.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(E.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},t.createInternalLoader=function(e){var t=this.hls.config,r=t.pLoader,i=t.loader,a=new(r||i)(t);return this.loaders[e.type]=a,a},t.getInternalLoader=function(e){return this.loaders[e.type]},t.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},t.destroyInternalLoaders=function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}},t.destroy=function(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()},t.onManifestLoading=function(e,t){var r=t.url;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:tt,url:r,deliveryDirectives:null})},t.onLevelLoading=function(e,t){var r=t.id,i=t.level,a=t.pathwayId,n=t.url,s=t.deliveryDirectives;this.load({id:r,level:i,pathwayId:a,responseType:"text",type:rt,url:n,deliveryDirectives:s})},t.onAudioTrackLoading=function(e,t){var r=t.id,i=t.groupId,a=t.url,n=t.deliveryDirectives;this.load({id:r,groupId:i,level:null,responseType:"text",type:it,url:a,deliveryDirectives:n})},t.onSubtitleTrackLoading=function(e,t){var r=t.id,i=t.groupId,a=t.url,n=t.deliveryDirectives;this.load({id:r,groupId:i,level:null,responseType:"text",type:at,url:a,deliveryDirectives:n})},t.load=function(e){var t,r,i,a=this,n=this.hls.config,s=this.getInternalLoader(e);if(s){var l=s.context;if(l&&l.url===e.url&&l.level===e.level)return void k.trace("[playlist-loader]: playlist request ongoing");k.log("[playlist-loader]: aborting previous loader for type: "+e.type),s.abort()}if(r=e.type===tt?n.manifestLoadPolicy.default:o({},n.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),s=this.createInternalLoader(e),m(null==(t=e.deliveryDirectives)?void 0:t.part)&&(e.type===rt&&null!==e.level?i=this.hls.levels[e.level].details:e.type===it&&null!==e.id?i=this.hls.audioTracks[e.id].details:e.type===at&&null!==e.id&&(i=this.hls.subtitleTracks[e.id].details),i)){var u=i.partTarget,d=i.targetduration;if(u&&d){var h=1e3*Math.max(3*u,.8*d);r=o({},r,{maxTimeToFirstByteMs:Math.min(h,r.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(h,r.maxTimeToFirstByteMs)})}}var f=r.errorRetry||r.timeoutRetry||{},c={loadPolicy:r,timeout:r.maxLoadTimeMs,maxRetry:f.maxNumRetry||0,retryDelay:f.retryDelayMs||0,maxRetryDelay:f.maxRetryDelayMs||0},v={onSuccess:function(e,t,r,i){var n=a.getInternalLoader(r);a.resetInternalLoader(r.type);var s=e.data;0===s.indexOf("#EXTM3U")?(t.parsing.start=performance.now(),qe.isMediaPlaylist(s)?a.handleTrackOrLevelPlaylist(e,t,r,i||null,n):a.handleMasterPlaylist(e,t,r,i)):a.handleManifestParsingError(e,r,new Error("no EXTM3U delimiter"),i||null,t)},onError:function(e,t,r,i){a.handleNetworkError(t,r,!1,e,i)},onTimeout:function(e,t,r){a.handleNetworkError(t,r,!0,void 0,e)}};s.load(e,c,v)},t.handleMasterPlaylist=function(e,t,r,i){var a=this.hls,n=e.data,s=ut(e,r),o=qe.parseMasterPlaylist(n,s);if(o.playlistParsingError)this.handleManifestParsingError(e,r,o.playlistParsingError,i,t);else{var l=o.contentSteering,u=o.levels,d=o.sessionData,h=o.sessionKeys,f=o.startTimeOffset,c=o.variableList;this.variableList=c;var v=qe.parseMasterPlaylistMedia(n,s,o),g=v.AUDIO,m=void 0===g?[]:g,p=v.SUBTITLES,y=v["CLOSED-CAPTIONS"];m.length&&(m.some((function(e){return!e.url}))||!u[0].audioCodec||u[0].attrs.AUDIO||(k.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),m.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new w({}),bitrate:0,url:""}))),a.trigger(E.MANIFEST_LOADED,{levels:u,audioTracks:m,subtitles:p,captions:y,contentSteering:l,url:s,stats:t,networkDetails:i,sessionData:d,sessionKeys:h,startTimeOffset:f,variableList:c})}},t.handleTrackOrLevelPlaylist=function(e,t,r,i,a){var n=this.hls,s=r.id,o=r.level,l=r.type,u=ut(e,r),d=m(o)?o:m(s)?s:0,h=lt(r),f=qe.parseLevelPlaylist(e.data,u,d,h,0,this.variableList);if(l===tt){var c={attrs:new w({}),bitrate:0,details:f,name:"",url:u};n.trigger(E.MANIFEST_LOADED,{levels:[c],audioTracks:[],url:u,stats:t,networkDetails:i,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),r.levelDetails=f,this.handlePlaylistLoaded(f,e,t,r,i,a)},t.handleManifestParsingError=function(e,t,r,i,a){this.hls.trigger(E.ERROR,{type:T.NETWORK_ERROR,details:S.MANIFEST_PARSING_ERROR,fatal:t.type===tt,url:e.url,err:r,error:r,reason:r.message,response:e,context:t,networkDetails:i,stats:a})},t.handleNetworkError=function(e,t,r,a,n){void 0===r&&(r=!1);var s="A network "+(r?"timeout":"error"+(a?" (status "+a.code+")":""))+" occurred while loading "+e.type;e.type===rt?s+=": "+e.level+" id: "+e.id:e.type!==it&&e.type!==at||(s+=" id: "+e.id+' group-id: "'+e.groupId+'"');var o=new Error(s);k.warn("[playlist-loader]: "+s);var l=S.UNKNOWN,u=!1,d=this.getInternalLoader(e);switch(e.type){case tt:l=r?S.MANIFEST_LOAD_TIMEOUT:S.MANIFEST_LOAD_ERROR,u=!0;break;case rt:l=r?S.LEVEL_LOAD_TIMEOUT:S.LEVEL_LOAD_ERROR,u=!1;break;case it:l=r?S.AUDIO_TRACK_LOAD_TIMEOUT:S.AUDIO_TRACK_LOAD_ERROR,u=!1;break;case at:l=r?S.SUBTITLE_TRACK_LOAD_TIMEOUT:S.SUBTITLE_LOAD_ERROR,u=!1}d&&this.resetInternalLoader(e.type);var h={type:T.NETWORK_ERROR,details:l,fatal:u,url:e.url,loader:d,context:e,error:o,networkDetails:t,stats:n};if(a){var f=(null==t?void 0:t.url)||e.url;h.response=i({url:f,data:void 0},a)}this.hls.trigger(E.ERROR,h)},t.handlePlaylistLoaded=function(e,t,r,i,a,n){var s=this.hls,o=i.type,l=i.level,u=i.id,d=i.groupId,h=i.deliveryDirectives,f=ut(t,i),c=lt(i),v="number"==typeof i.level&&c===nt?l:void 0;if(e.fragments.length){e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));var g=e.playlistParsingError;if(g)s.trigger(E.ERROR,{type:T.NETWORK_ERROR,details:S.LEVEL_PARSING_ERROR,fatal:!1,url:f,error:g,reason:g.message,response:t,context:i,level:v,parent:c,networkDetails:a,stats:r});else switch(e.live&&n&&(n.getCacheAge&&(e.ageHeader=n.getCacheAge()||0),n.getCacheAge&&!isNaN(e.ageHeader)||(e.ageHeader=0)),o){case tt:case rt:s.trigger(E.LEVEL_LOADED,{details:e,level:v||0,id:u||0,stats:r,networkDetails:a,deliveryDirectives:h});break;case it:s.trigger(E.AUDIO_TRACK_LOADED,{details:e,id:u||0,groupId:d||"",stats:r,networkDetails:a,deliveryDirectives:h});break;case at:s.trigger(E.SUBTITLE_TRACK_LOADED,{details:e,id:u||0,groupId:d||"",stats:r,networkDetails:a,deliveryDirectives:h})}}else{var m=new Error("No Segments found in Playlist");s.trigger(E.ERROR,{type:T.NETWORK_ERROR,details:S.LEVEL_EMPTY_ERROR,fatal:!1,url:f,error:m,reason:m.message,response:t,context:i,level:v,parent:c,networkDetails:a,stats:r})}},e}();function ht(e,t){var r;try{r=new Event("addtrack")}catch(e){(r=document.createEvent("Event")).initEvent("addtrack",!1,!1)}r.track=e,t.dispatchEvent(r)}function ft(e,t,r,i){var a=e.mode;if("disabled"===a&&(e.mode="hidden"),e.cues&&e.cues.length>0)for(var n=function(e,t,r){var i=[],a=function(e,t){if(t<e[0].startTime)return 0;var r=e.length-1;if(t>e[r].endTime)return-1;for(var i=0,a=r;i<=a;){var n=Math.floor((a+i)/2);if(t<e[n].startTime)a=n-1;else{if(!(t>e[n].startTime&&i<r))return n;i=n+1}}return e[i].startTime-t<t-e[a].startTime?i:a}(e,t);if(a>-1)for(var n=a,s=e.length;n<s;n++){var o=e[n];if(o.startTime>=t&&o.endTime<=r)i.push(o);else if(o.startTime>r)return i}return i}(e.cues,t,r),s=0;s<n.length;s++)i&&!i(n[s])||e.removeCue(n[s]);"disabled"===a&&(e.mode=a)}var ct="org.id3",vt="com.apple.quicktime.HLS",gt="https://aomedia.org/emsg/ID3";function mt(){if("undefined"!=typeof self)return self.VTTCue||self.TextTrackCue}function pt(e,t,r,a,n){var s=new e(t,r,"");try{s.value=a,n&&(s.type=n)}catch(o){s=new e(t,r,JSON.stringify(n?i({type:n},a):a))}return s}var yt=function(){var e=mt();try{e&&new e(0,Number.POSITIVE_INFINITY,"")}catch(e){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();function Et(e,t){return e.getTime()/1e3-t}var Tt=function(){function e(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=e,this._registerListeners()}var t=e.prototype;return t.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},t._registerListeners=function(){var e=this.hls;e.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(E.LEVEL_UPDATED,this.onLevelUpdated,this)},t._unregisterListeners=function(){var e=this.hls;e.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(E.LEVEL_UPDATED,this.onLevelUpdated,this)},t.onMediaAttached=function(e,t){this.media=t.media},t.onMediaDetaching=function(){this.id3Track&&(function(e){var t=e.mode;if("disabled"===t&&(e.mode="hidden"),e.cues)for(var r=e.cues.length;r--;)e.removeCue(e.cues[r]);"disabled"===t&&(e.mode=t)}(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})},t.onManifestLoading=function(){this.dateRangeCuesAppended={}},t.createTrack=function(e){var t=this.getID3Track(e.textTracks);return t.mode="hidden",t},t.getID3Track=function(e){if(this.media){for(var t=0;t<e.length;t++){var r=e[t];if("metadata"===r.kind&&"id3"===r.label)return ht(r,this.media),r}return this.media.addTextTrack("metadata","id3")}},t.onFragParsingMetadata=function(e,t){if(this.media){var r=this.hls.config,i=r.enableEmsgMetadataCues,a=r.enableID3MetadataCues;if(i||a){var n=t.samples;this.id3Track||(this.id3Track=this.createTrack(this.media));var s=mt();if(s)for(var o=0;o<n.length;o++){var l=n[o].type;if((l!==gt||i)&&a){var u=$(n[o].data);if(u){var d=n[o].pts,h=d+n[o].duration;h>yt&&(h=yt),h-d<=0&&(h=d+.25);for(var f=0;f<u.length;f++){var c=u[f];if(!Q(c)){this.updateId3CueEnds(d,l);var v=pt(s,d,h,c,l);v&&this.id3Track.addCue(v)}}}}}}}},t.updateId3CueEnds=function(e,t){var r,i=null==(r=this.id3Track)?void 0:r.cues;if(i)for(var a=i.length;a--;){var n=i[a];n.type===t&&n.startTime<e&&n.endTime===yt&&(n.endTime=e)}},t.onBufferFlushing=function(e,t){var r=t.startOffset,i=t.endOffset,a=t.type,n=this.id3Track,s=this.hls;if(s){var o=s.config,l=o.enableEmsgMetadataCues,u=o.enableID3MetadataCues;n&&(l||u)&&ft(n,r,i,"audio"===a?function(e){return e.type===ct&&u}:"video"===a?function(e){return e.type===gt&&l}:function(e){return e.type===ct&&u||e.type===gt&&l})}},t.onLevelUpdated=function(e,t){var r=this,i=t.details;if(this.media&&i.hasProgramDateTime&&this.hls.config.enableDateRangeMetadataCues){var a=this.dateRangeCuesAppended,n=this.id3Track,s=i.dateRanges,o=Object.keys(s);if(n)for(var l=Object.keys(a).filter((function(e){return!o.includes(e)})),u=function(){var e=l[d];Object.keys(a[e].cues).forEach((function(t){n.removeCue(a[e].cues[t])})),delete a[e]},d=l.length;d--;)u();var h=i.fragments[i.fragments.length-1];if(0!==o.length&&m(null==h?void 0:h.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var f=h.programDateTime/1e3-h.start,c=mt(),v=function(){var e,t,i=o[g],n=s[i],l=Et(n.startDate,f),u=a[i],d=(null==u?void 0:u.cues)||{},h=(null==u?void 0:u.durationKnown)||!1,v=yt,m=n.endDate;if(m)v=Et(m,f),h=!0;else if(n.endOnNext&&!h){var p=o.reduce((function(e,t){if(t!==n.id){var r=s[t];if(r.class===n.class&&r.startDate>n.startDate&&(!e||n.startDate<e.startDate))return r}return e}),null);p&&(v=Et(p.startDate,f),h=!0)}for(var y=Object.keys(n.attr),E=0;E<y.length;E++){var T=y[E];if("ID"!==(t=T)&&"CLASS"!==t&&"START-DATE"!==t&&"DURATION"!==t&&"END-DATE"!==t&&"END-ON-NEXT"!==t){var S=d[T];if(S)h&&!u.durationKnown&&(S.endTime=v);else if(c){var L=n.attr[T];C(T)&&(e=L,L=Uint8Array.from(e.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer);var R=pt(c,l,v,{key:T,data:L},vt);R&&(R.id=i,r.id3Track.addCue(R),d[T]=R)}}}a[i]={cues:d,dateRange:n,durationKnown:h}},g=0;g<o.length;g++)v()}}},e}(),St=function(){function e(e){var t=this;this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=function(){return t.timeupdate()},this.hls=e,this.config=e.config,this.registerListeners()}var t=e.prototype;return t.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},t.registerListeners=function(){this.hls.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(E.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(E.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(E.ERROR,this.onError,this)},t.unregisterListeners=function(){this.hls.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(E.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(E.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(E.ERROR,this.onError,this)},t.onMediaAttached=function(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},t.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},t.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},t.onLevelUpdated=function(e,t){var r=t.details;this.levelDetails=r,r.advanced&&this.timeupdate(),!r.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},t.onError=function(e,t){var r;t.details===S.BUFFER_STALLED_ERROR&&(this.stallCount++,null!=(r=this.levelDetails)&&r.live&&k.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},t.timeupdate=function(){var e=this.media,t=this.levelDetails;if(e&&t){this.currentTime=e.currentTime;var r=this.computeLatency();if(null!==r){this._latency=r;var i=this.config,a=i.lowLatencyMode,n=i.maxLiveSyncPlaybackRate;if(a&&1!==n&&t.live){var s=this.targetLatency;if(null!==s){var o=r-s;if(o<Math.min(this.maxLatency,s+t.targetduration)&&o>.05&&this.forwardBufferLength>1){var l=Math.min(2,Math.max(1,n)),u=Math.round(2/(1+Math.exp(-.75*o-this.edgeStalled))*20)/20;e.playbackRate=Math.min(l,Math.max(1,u))}else 1!==e.playbackRate&&0!==e.playbackRate&&(e.playbackRate=1)}}}}},t.estimateLiveEdge=function(){var e=this.levelDetails;return null===e?null:e.edge+e.age},t.computeLatency=function(){var e=this.estimateLiveEdge();return null===e?null:e-this.currentTime},s(e,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var e=this.config,t=this.levelDetails;return void 0!==e.liveMaxLatencyDuration?e.liveMaxLatencyDuration:t?e.liveMaxLatencyDurationCount*t.targetduration:0}},{key:"targetLatency",get:function(){var e=this.levelDetails;if(null===e)return null;var t=e.holdBack,r=e.partHoldBack,i=e.targetduration,a=this.config,n=a.liveSyncDuration,s=a.liveSyncDurationCount,o=a.lowLatencyMode,l=this.hls.userConfig,u=o&&r||t;(l.liveSyncDuration||l.liveSyncDurationCount||0===u)&&(u=void 0!==n?n:s*i);var d=i;return u+Math.min(1*this.stallCount,d)}},{key:"liveSyncPosition",get:function(){var e=this.estimateLiveEdge(),t=this.targetLatency,r=this.levelDetails;if(null===e||null===t||null===r)return null;var i=r.edge,a=e-t-this.edgeStalled,n=i-r.totalduration,s=i-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(n,a),s)}},{key:"drift",get:function(){var e=this.levelDetails;return null===e?1:e.drift}},{key:"edgeStalled",get:function(){var e=this.levelDetails;if(null===e)return 0;var t=3*(this.config.lowLatencyMode&&e.partTarget||e.targetduration);return Math.max(e.age-t,0)}},{key:"forwardBufferLength",get:function(){var e=this.media,t=this.levelDetails;if(!e||!t)return 0;var r=e.buffered.length;return(r?e.buffered.end(r-1):t.edge)-this.currentTime}}]),e}(),Lt=["NONE","TYPE-0","TYPE-1",null];var Rt=["SDR","PQ","HLG"];var At="",bt="YES",Dt="v2";function kt(e){var t=e.canSkipUntil,r=e.canSkipDateRanges,i=e.age;return t&&i<t/2?r?Dt:bt:At}var _t=function(){function e(e,t,r){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=r}return e.prototype.addDirectives=function(e){var t=new self.URL(e);return void 0!==this.msn&&t.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href},e}(),xt=function(){function e(e){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=void 0,this._urlId=0,this.url=[e.url],this._attrs=[e.attrs],this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.frameRate=e.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=e.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.codecSet=[e.videoCodec,e.audioCodec].filter((function(e){return!!e})).map((function(e){return e.substring(0,4)})).join(","),this.addGroupId("audio",e.attrs.AUDIO),this.addGroupId("text",e.attrs.SUBTITLES)}var t=e.prototype;return t.hasAudioGroup=function(e){return wt(this._audioGroups,e)},t.hasSubtitleGroup=function(e){return wt(this._subtitleGroups,e)},t.addGroupId=function(e,t){if(t)if("audio"===e){var r=this._audioGroups;r||(r=this._audioGroups=[]),-1===r.indexOf(t)&&r.push(t)}else if("text"===e){var i=this._subtitleGroups;i||(i=this._subtitleGroups=[]),-1===i.indexOf(t)&&i.push(t)}},t.addFallback=function(){},s(e,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"averageBitrate",get:function(){return this._avgBitrate||this.realBitrate||this.bitrate}},{key:"attrs",get:function(){return this._attrs[0]}},{key:"codecs",get:function(){return this.attrs.CODECS||""}},{key:"pathwayId",get:function(){return this.attrs["PATHWAY-ID"]||"."}},{key:"videoRange",get:function(){return this.attrs["VIDEO-RANGE"]||"SDR"}},{key:"score",get:function(){return this.attrs.optionalFloat("SCORE",0)}},{key:"uri",get:function(){return this.url[0]||""}},{key:"audioGroups",get:function(){return this._audioGroups}},{key:"subtitleGroups",get:function(){return this._subtitleGroups}},{key:"urlId",get:function(){return 0},set:function(e){}},{key:"audioGroupIds",get:function(){return this.audioGroups?[this.audioGroupId]:void 0}},{key:"textGroupIds",get:function(){return this.subtitleGroups?[this.textGroupId]:void 0}},{key:"audioGroupId",get:function(){var e;return null==(e=this.audioGroups)?void 0:e[0]}},{key:"textGroupId",get:function(){var e;return null==(e=this.subtitleGroups)?void 0:e[0]}}]),e}();function wt(e,t){return!(!t||!e)&&-1!==e.indexOf(t)}function Ct(e,t){var r=t.startPTS;if(m(r)){var i,a=0;t.sn>e.sn?(a=r-e.start,i=e):(a=e.start-r,i=t),i.duration!==a&&(i.duration=a)}else t.sn>e.sn?e.cc===t.cc&&e.minEndPTS?t.start=e.start+(e.minEndPTS-e.start):t.start=e.start+e.duration:t.start=Math.max(e.start-t.duration,0)}function It(e,t,r,i,a,n){i-r<=0&&(k.warn("Fragment should have a positive duration",t),i=r+t.duration,n=a+t.duration);var s=r,o=i,l=t.startPTS,u=t.endPTS;if(m(l)){var d=Math.abs(l-r);m(t.deltaPTS)?t.deltaPTS=Math.max(d,t.deltaPTS):t.deltaPTS=d,s=Math.max(r,l),r=Math.min(r,l),a=Math.min(a,t.startDTS),o=Math.min(i,u),i=Math.max(i,u),n=Math.max(n,t.endDTS)}var h=r-t.start;0!==t.start&&(t.start=r),t.duration=i-t.start,t.startPTS=r,t.maxStartPTS=s,t.startDTS=a,t.endPTS=i,t.minEndPTS=o,t.endDTS=n;var f,c=t.sn;if(!e||c<e.startSN||c>e.endSN)return 0;var v=c-e.startSN,g=e.fragments;for(g[v]=t,f=v;f>0;f--)Ct(g[f],g[f-1]);for(f=v;f<g.length-1;f++)Ct(g[f],g[f+1]);return e.fragmentHint&&Ct(g[g.length-1],e.fragmentHint),e.PTSKnown=e.alignedSliding=!0,h}function Pt(e,t){for(var r=null,i=e.fragments,a=i.length-1;a>=0;a--){var n=i[a].initSegment;if(n){r=n;break}}e.fragmentHint&&delete e.fragmentHint.endPTS;var s,l,u,d,h,f=0;if(function(e,t,r){for(var i=t.skippedSegments,a=Math.max(e.startSN,t.startSN)-t.startSN,n=(e.fragmentHint?1:0)+(i?t.endSN:Math.min(e.endSN,t.endSN))-t.startSN,s=t.startSN-e.startSN,o=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,l=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,u=a;u<=n;u++){var d=l[s+u],h=o[u];i&&!h&&u<i&&(h=t.fragments[u]=d),d&&h&&r(d,h)}}(e,t,(function(e,i){e.relurl&&(f=e.cc-i.cc),m(e.startPTS)&&m(e.endPTS)&&(i.start=i.startPTS=e.startPTS,i.startDTS=e.startDTS,i.maxStartPTS=e.maxStartPTS,i.endPTS=e.endPTS,i.endDTS=e.endDTS,i.minEndPTS=e.minEndPTS,i.duration=e.endPTS-e.startPTS,i.duration&&(s=i),t.PTSKnown=t.alignedSliding=!0),i.elementaryStreams=e.elementaryStreams,i.loader=e.loader,i.stats=e.stats,e.initSegment&&(i.initSegment=e.initSegment,r=e.initSegment)})),r&&(t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments).forEach((function(e){var t;!e||e.initSegment&&e.initSegment.relurl!==(null==(t=r)?void 0:t.relurl)||(e.initSegment=r)})),t.skippedSegments)if(t.deltaUpdateFailed=t.fragments.some((function(e){return!e})),t.deltaUpdateFailed){k.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var c=t.skippedSegments;c--;)t.fragments.shift();t.startSN=t.fragments[0].sn,t.startCC=t.fragments[0].cc}else t.canSkipDateRanges&&(t.dateRanges=(l=e.dateRanges,u=t.dateRanges,d=t.recentlyRemovedDateranges,h=o({},l),d&&d.forEach((function(e){delete h[e]})),Object.keys(u).forEach((function(e){var t=new I(u[e].attr,h[e]);t.isValid?h[e]=t:k.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(u[e].attr)+'"')})),h));var v=t.fragments;if(f){k.warn("discontinuity sliding from playlist, take drift into account");for(var g=0;g<v.length;g++)v[g].cc+=f}t.skippedSegments&&(t.startCC=t.fragments[0].cc),function(e,t,r){if(e&&t)for(var i=0,a=0,n=e.length;a<=n;a++){var s=e[a],o=t[a+i];s&&o&&s.index===o.index&&s.fragment.sn===o.fragment.sn?r(s,o):i--}}(e.partList,t.partList,(function(e,t){t.elementaryStreams=e.elementaryStreams,t.stats=e.stats})),s?It(t,s,s.startPTS,s.endPTS,s.startDTS,s.endDTS):Ft(e,t),v.length&&(t.totalduration=t.edge-v[0].start),t.driftStartTime=e.driftStartTime,t.driftStart=e.driftStart;var p=t.advancedDateTime;if(t.advanced&&p){var y=t.edge;t.driftStart||(t.driftStartTime=p,t.driftStart=y),t.driftEndTime=p,t.driftEnd=y}else t.driftEndTime=e.driftEndTime,t.driftEnd=e.driftEnd,t.advancedDateTime=e.advancedDateTime}function Ft(e,t){var r=t.startSN+t.skippedSegments-e.startSN,i=e.fragments;r<0||r>=i.length||function(e,t){if(t){for(var r=e.fragments,i=e.skippedSegments;i<r.length;i++)r[i].start+=t;e.fragmentHint&&(e.fragmentHint.start+=t)}}(t,i[r].start)}function Ot(e,t,r){var i;return null!=e&&e.details?Mt(null==(i=e.details)?void 0:i.partList,t,r):null}function Mt(e,t,r){if(e)for(var i=e.length;i--;){var a=e[i];if(a.index===r&&a.fragment.sn===t)return a}return null}function Nt(e){e.forEach((function(e,t){var r=e.details;null!=r&&r.fragments&&r.fragments.forEach((function(e){e.level=t}))}))}function Bt(e){switch(e.details){case S.FRAG_LOAD_TIMEOUT:case S.KEY_LOAD_TIMEOUT:case S.LEVEL_LOAD_TIMEOUT:case S.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function Ut(e,t){var r=Bt(t);return e.default[(r?"timeout":"error")+"Retry"]}function Gt(e,t){var r="linear"===e.backoff?1:Math.pow(2,t);return Math.min(r*e.retryDelayMs,e.maxRetryDelayMs)}function Ht(e){return i(i({},e),{errorRetry:null,timeoutRetry:null})}function Vt(e,t,r,i){if(!e)return!1;var a=null==i?void 0:i.code,n=t<e.maxNumRetry&&(function(e){return 0===e&&!1===navigator.onLine||!!e&&(e<400||e>499)}(a)||!!r);return e.shouldRetry?e.shouldRetry(e,t,r,i,n):n}var Kt=function(e,t){for(var r=0,i=e.length-1,a=null,n=null;r<=i;){var s=t(n=e[a=(r+i)/2|0]);if(s>0)r=a+1;else{if(!(s<0))return n;i=a-1}}return null};function jt(e,t,r,i,a){void 0===r&&(r=0),void 0===i&&(i=0),void 0===a&&(a=.005);var n=null;if(e){n=t[e.sn-t[0].sn+1]||null;var s=e.endDTS-r;s>0&&s<15e-7&&(r+=15e-7)}else 0===r&&0===t[0].start&&(n=t[0]);if(n&&((!e||e.level===n.level)&&0===Wt(r,i,n)||function(e,t,r){if(t&&0===t.start&&t.level<e.level&&(t.endPTS||0)>0){var i=t.tagList.reduce((function(e,t){return"INF"===t[0]&&(e+=parseFloat(t[1])),e}),r);return e.start<=i}return!1}(n,e,Math.min(a,i))))return n;var o=Kt(t,Wt.bind(null,r,i));return!o||o===e&&n?n:o}function Wt(e,t,r){if(void 0===e&&(e=0),void 0===t&&(t=0),r.start<=e&&r.start+r.duration>e)return 0;var i=Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return r.start+r.duration-i<=e?1:r.start-i>e&&r.start?-1:0}function Yt(e,t,r){var i=1e3*Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return(r.endProgramDateTime||0)-i>e}var qt=0,zt=2,Xt=3,Qt=5,Jt=0,$t=1,Zt=2,er=function(){function e(e){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=e,this.log=k.log.bind(k,"[info]:"),this.warn=k.warn.bind(k,"[warning]:"),this.error=k.error.bind(k,"[error]:"),this.registerListeners()}var t=e.prototype;return t.registerListeners=function(){var e=this.hls;e.on(E.ERROR,this.onError,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.LEVEL_UPDATED,this.onLevelUpdated,this)},t.unregisterListeners=function(){var e=this.hls;e&&(e.off(E.ERROR,this.onError,this),e.off(E.ERROR,this.onErrorOut,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.LEVEL_UPDATED,this.onLevelUpdated,this))},t.destroy=function(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}},t.startLoad=function(e){},t.stopLoad=function(){this.playlistError=0},t.getVariantLevelIndex=function(e){return(null==e?void 0:e.type)===nt?e.level:this.hls.loadLevel},t.onManifestLoading=function(){this.playlistError=0,this.penalizedRenditions={}},t.onLevelUpdated=function(){this.playlistError=0},t.onError=function(e,t){var r,i;if(!t.fatal){var a=this.hls,n=t.context;switch(t.details){case S.FRAG_LOAD_ERROR:case S.FRAG_LOAD_TIMEOUT:case S.KEY_LOAD_ERROR:case S.KEY_LOAD_TIMEOUT:return void(t.errorAction=this.getFragRetryOrSwitchAction(t));case S.FRAG_PARSING_ERROR:if(null!=(r=t.frag)&&r.gap)return void(t.errorAction={action:qt,flags:Jt});case S.FRAG_GAP:case S.FRAG_DECRYPT_ERROR:return t.errorAction=this.getFragRetryOrSwitchAction(t),void(t.errorAction.action=zt);case S.LEVEL_EMPTY_ERROR:case S.LEVEL_PARSING_ERROR:var s,o,l=t.parent===nt?t.level:a.loadLevel;return void(t.details===S.LEVEL_EMPTY_ERROR&&null!=(s=t.context)&&null!=(o=s.levelDetails)&&o.live?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,l):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,l)));case S.LEVEL_LOAD_ERROR:case S.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==n?void 0:n.level)&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.level)));case S.AUDIO_TRACK_LOAD_ERROR:case S.AUDIO_TRACK_LOAD_TIMEOUT:case S.SUBTITLE_LOAD_ERROR:case S.SUBTITLE_TRACK_LOAD_TIMEOUT:if(n){var u=a.levels[a.loadLevel];if(u&&(n.type===it&&u.hasAudioGroup(n.groupId)||n.type===at&&u.hasSubtitleGroup(n.groupId)))return t.errorAction=this.getPlaylistRetryOrSwitchAction(t,a.loadLevel),t.errorAction.action=zt,void(t.errorAction.flags=$t)}return;case S.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:var d=a.levels[a.loadLevel],h=null==d?void 0:d.attrs["HDCP-LEVEL"];return void(h?t.errorAction={action:zt,flags:Zt,hdcpLevel:h}:this.keySystemError(t));case S.BUFFER_ADD_CODEC_ERROR:case S.REMUX_ALLOC_ERROR:case S.BUFFER_APPEND_ERROR:return void(t.errorAction=this.getLevelSwitchAction(t,null!=(i=t.level)?i:a.loadLevel));case S.INTERNAL_EXCEPTION:case S.BUFFER_APPENDING_ERROR:case S.BUFFER_FULL_ERROR:case S.LEVEL_SWITCH_ERROR:case S.BUFFER_STALLED_ERROR:case S.BUFFER_SEEK_OVER_HOLE:case S.BUFFER_NUDGE_ON_STALL:return void(t.errorAction={action:qt,flags:Jt})}t.type===T.KEY_SYSTEM_ERROR&&this.keySystemError(t)}},t.keySystemError=function(e){var t=this.getVariantLevelIndex(e.frag);e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,t)},t.getPlaylistRetryOrSwitchAction=function(e,t){var r=Ut(this.hls.config.playlistLoadPolicy,e),i=this.playlistError++;if(Vt(r,i,Bt(e),e.response))return{action:Qt,flags:Jt,retryConfig:r,retryCount:i};var a=this.getLevelSwitchAction(e,t);return r&&(a.retryConfig=r,a.retryCount=i),a},t.getFragRetryOrSwitchAction=function(e){var t=this.hls,r=this.getVariantLevelIndex(e.frag),i=t.levels[r],a=t.config,n=a.fragLoadPolicy,s=a.keyLoadPolicy,o=Ut(e.details.startsWith("key")?s:n,e),l=t.levels.reduce((function(e,t){return e+t.fragmentError}),0);if(i&&(e.details!==S.FRAG_GAP&&i.fragmentError++,Vt(o,l,Bt(e),e.response)))return{action:Qt,flags:Jt,retryConfig:o,retryCount:l};var u=this.getLevelSwitchAction(e,r);return o&&(u.retryConfig=o,u.retryCount=l),u},t.getLevelSwitchAction=function(e,t){var r=this.hls;null==t&&(t=r.loadLevel);var i=this.hls.levels[t];if(i){var a,n,s=e.details;i.loadError++,s===S.BUFFER_APPEND_ERROR&&i.fragmentError++;var o=-1,l=r.levels,u=r.loadLevel,d=r.minAutoLevel,h=r.maxAutoLevel;r.autoLevelEnabled||(r.loadLevel=-1);for(var f,c=null==(a=e.frag)?void 0:a.type,v=(c===st&&s===S.FRAG_PARSING_ERROR||"audio"===e.sourceBufferName&&(s===S.BUFFER_ADD_CODEC_ERROR||s===S.BUFFER_APPEND_ERROR))&&l.some((function(e){var t=e.audioCodec;return i.audioCodec!==t})),g="video"===e.sourceBufferName&&(s===S.BUFFER_ADD_CODEC_ERROR||s===S.BUFFER_APPEND_ERROR)&&l.some((function(e){var t=e.codecSet,r=e.audioCodec;return i.codecSet!==t&&i.audioCodec===r})),m=null!=(n=e.context)?n:{},p=m.type,y=m.groupId,E=function(){var t=(T+u)%l.length;if(t!==u&&t>=d&&t<=h&&0===l[t].loadError){var r,a,n=l[t];if(s===S.FRAG_GAP&&c===nt&&e.frag){var f=l[t].details;if(f){var m=jt(e.frag,f.fragments,e.frag.start);if(null!=m&&m.gap)return 0}}else{if(p===it&&n.hasAudioGroup(y)||p===at&&n.hasSubtitleGroup(y))return 0;if(c===st&&null!=(r=i.audioGroups)&&r.some((function(e){return n.hasAudioGroup(e)}))||c===ot&&null!=(a=i.subtitleGroups)&&a.some((function(e){return n.hasSubtitleGroup(e)}))||v&&i.audioCodec===n.audioCodec||!v&&i.audioCodec!==n.audioCodec||g&&i.codecSet===n.codecSet)return 0}return o=t,1}},T=l.length;T--&&(0===(f=E())||1!==f););if(o>-1&&r.loadLevel!==o)return e.levelRetry=!0,this.playlistError=0,{action:zt,flags:Jt,nextAutoLevel:o}}return{action:zt,flags:$t}},t.onErrorOut=function(e,t){var r;switch(null==(r=t.errorAction)?void 0:r.action){case qt:break;case zt:this.sendAlternateToPenaltyBox(t),t.errorAction.resolved||t.details===S.FRAG_GAP?/MediaSource readyState: ended/.test(t.error.message)&&(this.warn('MediaSource ended after "'+t.sourceBufferName+'" sourceBuffer append error. Attempting to recover from media error.'),this.hls.recoverMediaError()):t.fatal=!0}t.fatal&&this.hls.stopLoad()},t.sendAlternateToPenaltyBox=function(e){var t=this.hls,r=e.errorAction;if(r){var i=r.flags,a=r.hdcpLevel,n=r.nextAutoLevel;switch(i){case Jt:this.switchLevel(e,n);break;case Zt:a&&(t.maxHdcpLevel=Lt[Lt.indexOf(a)-1],r.resolved=!0),this.warn('Restricting playback to HDCP-LEVEL of "'+t.maxHdcpLevel+'" or lower')}r.resolved||this.switchLevel(e,n)}},t.switchLevel=function(e,t){void 0!==t&&e.errorAction&&(this.warn("switching to level "+t+" after "+e.details),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)},e}(),tr=function(){function e(e,t){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=k.log.bind(k,t+":"),this.warn=k.warn.bind(k,t+":"),this.hls=e}var t=e.prototype;return t.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},t.clearTimer=function(){-1!==this.timer&&(self.clearTimeout(this.timer),this.timer=-1)},t.startLoad=function(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()},t.stopLoad=function(){this.canLoad=!1,this.clearTimer()},t.switchParams=function(e,t,r){var i=null==t?void 0:t.renditionReports;if(i){for(var a=-1,n=0;n<i.length;n++){var s=i[n],o=void 0;try{o=new self.URL(s.URI,t.url).href}catch(e){k.warn("Could not construct new URL for Rendition Report: "+e),o=s.URI||""}if(o===e){a=n;break}o===e.substring(0,o.length)&&(a=n)}if(-1!==a){var l=i[a],u=parseInt(l["LAST-MSN"])||(null==t?void 0:t.lastPartSn),d=parseInt(l["LAST-PART"])||(null==t?void 0:t.lastPartIndex);if(this.hls.config.lowLatencyMode){var h=Math.min(t.age-t.partTarget,t.targetduration);d>=0&&h>t.partTarget&&(d+=1)}var f=r&&kt(r);return new _t(u,d>=0?d:void 0,f)}}},t.loadPlaylist=function(e){-1===this.requestScheduled&&(this.requestScheduled=self.performance.now())},t.shouldLoadPlaylist=function(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)},t.shouldReloadPlaylist=function(e){return-1===this.timer&&-1===this.requestScheduled&&this.shouldLoadPlaylist(e)},t.playlistLoaded=function(e,t,r){var i=this,a=t.details,n=t.stats,s=self.performance.now(),o=n.loading.first?Math.max(0,s-n.loading.first):0;if(a.advancedDateTime=Date.now()-o,a.live||null!=r&&r.live){if(a.reloaded(r),r&&this.log("live playlist "+e+" "+(a.advanced?"REFRESHED "+a.lastPartSn+"-"+a.lastPartIndex:a.updated?"UPDATED":"MISSED")),r&&a.fragments.length>0&&Pt(r,a),!this.canLoad||!a.live)return;var l,u=void 0,d=void 0;if(a.canBlockReload&&a.endSN&&a.advanced){var h=this.hls.config.lowLatencyMode,f=a.lastPartSn,c=a.endSN,v=a.lastPartIndex,g=f===c;-1!==v?(u=g?c+1:f,d=g?h?0:v:v+1):u=c+1;var m=a.age,p=m+a.ageHeader,y=Math.min(p-a.partTarget,1.5*a.targetduration);if(y>0){if(r&&y>r.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+r.tuneInGoal+" to: "+y+" with playlist age: "+a.age),y=0;else{var E=Math.floor(y/a.targetduration);u+=E,void 0!==d&&(d+=Math.round(y%a.targetduration/a.partTarget)),this.log("CDN Tune-in age: "+a.ageHeader+"s last advanced "+m.toFixed(2)+"s goal: "+y+" skip sn "+E+" to part "+d)}a.tuneInGoal=y}if(l=this.getDeliveryDirectives(a,t.deliveryDirectives,u,d),h||!g)return void this.loadPlaylist(l)}else(a.canBlockReload||a.canSkipUntil)&&(l=this.getDeliveryDirectives(a,t.deliveryDirectives,u,d));var T=this.hls.mainForwardBufferInfo,S=T?T.end-T.len:0,L=function(e,t){void 0===t&&(t=1/0);var r=1e3*e.targetduration;if(e.updated){var i=e.fragments;if(i.length&&4*r>t){var a=1e3*i[i.length-1].duration;a<r&&(r=a)}}else r/=2;return Math.round(r)}(a,1e3*(a.edge-S));a.updated&&s>this.requestScheduled+L&&(this.requestScheduled=n.loading.start),void 0!==u&&a.canBlockReload?this.requestScheduled=n.loading.first+L-(1e3*a.partTarget||1e3):-1===this.requestScheduled||this.requestScheduled+L<s?this.requestScheduled=s:this.requestScheduled-s<=0&&(this.requestScheduled+=L);var R=this.requestScheduled-s;R=Math.max(0,R),this.log("reload live playlist "+e+" in "+Math.round(R)+" ms"),this.timer=self.setTimeout((function(){return i.loadPlaylist(l)}),R)}else this.clearTimer()},t.getDeliveryDirectives=function(e,t,r,i){var a=kt(e);return null!=t&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,i=t.part,a=At),new _t(r,i,a)},t.checkRetry=function(e){var t=this,r=e.details,i=Bt(e),a=e.errorAction,n=a||{},s=n.action,o=n.retryCount,l=void 0===o?0:o,u=n.retryConfig,d=!!a&&!!u&&(s===Qt||!a.resolved&&s===zt);if(d){var h;if(this.requestScheduled=-1,l>=u.maxNumRetry)return!1;if(i&&null!=(h=e.context)&&h.deliveryDirectives)this.warn("Retrying playlist loading "+(l+1)+"/"+u.maxNumRetry+' after "'+r+'" without delivery-directives'),this.loadPlaylist();else{var f=Gt(u,l);this.timer=self.setTimeout((function(){return t.loadPlaylist()}),f),this.warn("Retrying playlist loading "+(l+1)+"/"+u.maxNumRetry+' after "'+r+'" in '+f+"ms")}e.levelRetry=!0,a.resolved=!0}return d},e}(),rr=function(){function e(e,t,r){void 0===t&&(t=0),void 0===r&&(r=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=r}var t=e.prototype;return t.sample=function(e,t){var r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e},t.getTotalWeight=function(){return this.totalWeight_},t.getEstimate=function(){if(this.alpha_){var e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_},e}(),ir=function(){function e(e,t,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 rr(e),this.fast_=new rr(t),this.defaultTTFB_=i,this.ttfb_=new rr(e)}var t=e.prototype;return t.update=function(e,t){var r=this.slow_,i=this.fast_,a=this.ttfb_;r.halfLife!==e&&(this.slow_=new rr(e,r.getEstimate(),r.getTotalWeight())),i.halfLife!==t&&(this.fast_=new rr(t,i.getEstimate(),i.getTotalWeight())),a.halfLife!==e&&(this.ttfb_=new rr(e,a.getEstimate(),a.getTotalWeight()))},t.sample=function(e,t){var r=(e=Math.max(e,this.minDelayMs_))/1e3,i=8*t/r;this.fast_.sample(r,i),this.slow_.sample(r,i)},t.sampleTTFB=function(e){var t=e/1e3,r=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(r,Math.max(e,5))},t.canEstimate=function(){return this.fast_.getTotalWeight()>=this.minWeight_},t.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},t.getEstimateTTFB=function(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_},t.destroy=function(){},e}();function ar(e,t){var r=!1,i=[];return e&&(r="SDR"!==e,i=[e]),t&&(i=t.allowedVideoRanges||Rt.slice(0),i=(r=void 0!==t.preferHDR?t.preferHDR:function(){if("function"==typeof matchMedia){var e=matchMedia("(dynamic-range: high)"),t=matchMedia("bad query");if(e.media!==t.media)return!0===e.matches}return!1}())?i.filter((function(e){return"SDR"!==e})):["SDR"]),{preferHDR:r,allowedVideoRanges:i}}function nr(e,t){k.log('[abr] start candidates with "'+e+'" ignored because '+t)}var sr=function(){function e(e){var t=this;this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=-1,this.firstSelection=-1,this._nextAutoLevel=-1,this.nextAutoLevelKey="",this.audioTracksByGroup=null,this.codecTiers=null,this.timer=-1,this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this._abandonRulesCheck=function(){var e=t.fragCurrent,r=t.partCurrent,i=t.hls,a=i.autoLevelEnabled,n=i.media;if(e&&n){var s=performance.now(),o=r?r.stats:e.stats,l=r?r.duration:e.duration,u=s-o.loading.start,d=i.minAutoLevel;if(o.aborted||o.loaded&&o.loaded===o.total||e.level<=d)return t.clearTimer(),void(t._nextAutoLevel=-1);if(a&&!n.paused&&n.playbackRate&&n.readyState){var h=i.mainForwardBufferInfo;if(null!==h){var f=t.bwEstimator.getEstimateTTFB(),c=Math.abs(n.playbackRate);if(!(u<=Math.max(f,l/(2*c)*1e3))){var v=h.len/c,g=o.loading.first?o.loading.first-o.loading.start:-1,p=o.loaded&&g>-1,y=t.getBwEstimate(),T=i.levels,S=T[e.level],L=o.total||Math.max(o.loaded,Math.round(l*S.averageBitrate/8)),R=p?u-g:u;R<1&&p&&(R=Math.min(u,8*o.loaded/y));var A=p?1e3*o.loaded/R:0,b=A?(L-o.loaded)/A:8*L/y+f/1e3;if(!(b<=v)){var D,_=A?8*A:y,x=Number.POSITIVE_INFINITY;for(D=e.level-1;D>d;D--){var w=T[D].maxBitrate;if((x=t.getTimeToLoadFrag(f/1e3,_,l*w,!T[D].details))<v)break}if(!(x>=b||x>10*l)){i.nextLoadLevel=i.nextAutoLevel=D,p?t.bwEstimator.sample(u-Math.min(f,g),o.loaded):t.bwEstimator.sampleTTFB(u);var C=T[D].maxBitrate;t.getBwEstimate()*t.hls.config.abrBandWidthUpFactor>C&&t.resetEstimator(C),t.clearTimer(),k.warn("[abr] Fragment "+e.sn+(r?" part "+r.index:"")+" of level "+e.level+" is loading too slowly;\n Time to underbuffer: "+v.toFixed(3)+" s\n Estimated load time for current fragment: "+b.toFixed(3)+" s\n Estimated load time for down switch fragment: "+x.toFixed(3)+" s\n TTFB estimate: "+(0|g)+" ms\n Current BW estimate: "+(m(y)?0|y:"Unknown")+" bps\n New BW estimate: "+(0|t.getBwEstimate())+" bps\n Switching to level "+D+" @ "+(0|C)+" bps"),i.trigger(E.FRAG_LOAD_EMERGENCY_ABORTED,{frag:e,part:r,stats:o})}}}}}}},this.hls=e,this.bwEstimator=this.initEstimator(),this.registerListeners()}var t=e.prototype;return t.resetEstimator=function(e){e&&(k.log("setting initial bwe to "+e),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()},t.initEstimator=function(){var e=this.hls.config;return new ir(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)},t.registerListeners=function(){var e=this.hls;e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.FRAG_LOADING,this.onFragLoading,this),e.on(E.FRAG_LOADED,this.onFragLoaded,this),e.on(E.FRAG_BUFFERED,this.onFragBuffered,this),e.on(E.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(E.LEVEL_LOADED,this.onLevelLoaded,this),e.on(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(E.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(E.ERROR,this.onError,this)},t.unregisterListeners=function(){var e=this.hls;e&&(e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.FRAG_LOADING,this.onFragLoading,this),e.off(E.FRAG_LOADED,this.onFragLoaded,this),e.off(E.FRAG_BUFFERED,this.onFragBuffered,this),e.off(E.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(E.LEVEL_LOADED,this.onLevelLoaded,this),e.off(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(E.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(E.ERROR,this.onError,this))},t.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=null,this.fragCurrent=this.partCurrent=null},t.onManifestLoading=function(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()},t.onLevelsUpdated=function(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null},t.onMaxAutoLevelUpdated=function(){this.firstSelection=-1,this.nextAutoLevelKey=""},t.onFragLoading=function(e,t){var r,i=t.frag;this.ignoreFragment(i)||(i.bitrateTest||(this.fragCurrent=i,this.partCurrent=null!=(r=t.part)?r:null),this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100))},t.onLevelSwitching=function(e,t){this.clearTimer()},t.onError=function(e,t){if(!t.fatal)switch(t.details){case S.BUFFER_ADD_CODEC_ERROR:case S.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case S.FRAG_LOAD_TIMEOUT:var r=t.frag,i=this.fragCurrent,a=this.partCurrent;if(r&&i&&r.sn===i.sn&&r.level===i.level){var n=performance.now(),s=a?a.stats:r.stats,o=n-s.loading.start,l=s.loading.first?s.loading.first-s.loading.start:-1;if(s.loaded&&l>-1){var u=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(o-Math.min(u,l),s.loaded)}else this.bwEstimator.sampleTTFB(o)}}},t.getTimeToLoadFrag=function(e,t,r,i){return e+r/t+(i?this.lastLevelLoadSec:0)},t.onLevelLoaded=function(e,t){var r=this.hls.config,i=t.stats.loading,a=i.end-i.start;m(a)&&(this.lastLevelLoadSec=a/1e3),t.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)},t.onFragLoaded=function(e,t){var r=t.frag,i=t.part,a=i?i.stats:r.stats;if(r.type===nt&&this.bwEstimator.sampleTTFB(a.loading.first-a.loading.start),!this.ignoreFragment(r)){if(this.clearTimer(),r.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){var n=i?i.duration:r.duration,s=this.hls.levels[r.level],o=(s.loaded?s.loaded.bytes:0)+a.loaded,l=(s.loaded?s.loaded.duration:0)+n;s.loaded={bytes:o,duration:l},s.realBitrate=Math.round(8*o/l)}if(r.bitrateTest){var u={stats:a,frag:r,part:i,id:r.type};this.onFragBuffered(E.FRAG_BUFFERED,u),r.bitrateTest=!1}else this.lastLoadedFragLevel=r.level}},t.onFragBuffered=function(e,t){var r=t.frag,i=t.part,a=null!=i&&i.stats.loaded?i.stats:r.stats;if(!a.aborted&&!this.ignoreFragment(r)){var n=a.parsing.end-a.loading.start-Math.min(a.loading.first-a.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(n,a.loaded),a.bwEstimate=this.getBwEstimate(),r.bitrateTest?this.bitrateTestDelay=n/1e3:this.bitrateTestDelay=0}},t.ignoreFragment=function(e){return e.type!==nt||"initSegment"===e.sn},t.clearTimer=function(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)},t.getAutoLevelKey=function(){return this.getBwEstimate()+"_"+this.getStarvationDelay().toFixed(2)},t.getNextABRAutoLevel=function(){var e=this.fragCurrent,t=this.partCurrent,r=this.hls,i=r.maxAutoLevel,a=r.config,n=r.minAutoLevel,s=t?t.duration:e?e.duration:0,o=this.getBwEstimate(),l=this.getStarvationDelay(),u=a.abrBandWidthFactor,d=a.abrBandWidthUpFactor;if(l){var h=this.findBestLevel(o,n,i,l,0,u,d);if(h>=0)return h}var f=s?Math.min(s,a.maxStarvationDelay):a.maxStarvationDelay;if(!l){var c=this.bitrateTestDelay;c&&(f=(s?Math.min(s,a.maxLoadingDelay):a.maxLoadingDelay)-c,k.info("[abr] bitrate test took "+Math.round(1e3*c)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*f)+" ms"),u=d=1)}var v=this.findBestLevel(o,n,i,l,f,u,d);if(k.info("[abr] "+(l?"rebuffering expected":"buffer is empty")+", optimal quality level "+v),v>-1)return v;var g=r.levels[n],m=r.levels[r.loadLevel];return(null==g?void 0:g.bitrate)<(null==m?void 0:m.bitrate)?n:r.loadLevel},t.getStarvationDelay=function(){var e=this.hls,t=e.media;if(!t)return 1/0;var r=t&&0!==t.playbackRate?Math.abs(t.playbackRate):1,i=e.mainForwardBufferInfo;return(i?i.len:0)/r},t.getBwEstimate=function(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate},t.findBestLevel=function(e,t,r,i,a,n,s){var o,l=this,u=i+a,d=this.lastLoadedFragLevel,h=-1===d?this.hls.firstLevel:d,f=this.fragCurrent,c=this.partCurrent,v=this.hls,g=v.levels,p=v.allAudioTracks,y=v.loadLevel,E=v.config;if(1===g.length)return 0;var T,S=g[h],L=!(null==S||null==(o=S.details)||!o.live),R=-1===y||-1===d,A="SDR",b=(null==S?void 0:S.frameRate)||0,D=E.audioPreference,_=E.videoPreference;this.audioTracksByGroup||(this.audioTracksByGroup=function(e){return e.reduce((function(e,t){var r=e.groups[t.groupId];r||(r=e.groups[t.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),r.tracks.push(t);var i=t.channels||"2";return r.channels[i]=(r.channels[i]||0)+1,r.hasDefault=r.hasDefault||t.default,r.hasAutoSelect=r.hasAutoSelect||t.autoselect,r.hasDefault&&(e.hasDefaultAudio=!0),r.hasAutoSelect&&(e.hasAutoSelectAudio=!0),e}),{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}(p));if(R){if(-1!==this.firstSelection)return this.firstSelection;var x=function(e,t,r,i,a){for(var n=Object.keys(e),s=null==i?void 0:i.channels,o=null==i?void 0:i.audioCodec,l=s&&2===parseInt(s),u=!0,d=!1,h=1/0,f=1/0,c=1/0,v=0,g=[],p=ar(t,a),y=p.preferHDR,E=p.allowedVideoRanges,T=function(){var t=e[n[S]];u=t.channels[2]>0,h=Math.min(h,t.minHeight),f=Math.min(f,t.minFramerate),c=Math.min(c,t.minBitrate);var r=E.filter((function(e){return t.videoRanges[e]>0}));r.length>0&&(d=!0,g=r)},S=n.length;S--;)T();h=m(h)?h:0,f=m(f)?f:0;var L=Math.max(1080,h),R=Math.max(30,f);return c=m(c)?c:r,r=Math.max(c,r),d||(t=void 0,g=[]),{codecSet:n.reduce((function(t,i){var a=e[i];if(i===t)return t;if(a.minBitrate>r)return nr(i,"min bitrate of "+a.minBitrate+" > current estimate of "+r),t;if(!a.hasDefaultAudio)return nr(i,"no renditions with default or auto-select sound found"),t;if(o&&i.indexOf(o.substring(0,4))%5!=0)return nr(i,'audio codec preference "'+o+'" not found'),t;if(s&&!l){if(!a.channels[s])return nr(i,"no renditions with "+s+" channel sound found (channels options: "+Object.keys(a.channels)+")"),t}else if((!o||l)&&u&&0===a.channels[2])return nr(i,"no renditions with stereo sound found"),t;return a.minHeight>L?(nr(i,"min resolution of "+a.minHeight+" > maximum of "+L),t):a.minFramerate>R?(nr(i,"min framerate of "+a.minFramerate+" > maximum of "+R),t):g.some((function(e){return a.videoRanges[e]>0}))?a.maxScore<v?(nr(i,"max score of "+a.maxScore+" < selected max of "+v),t):t&&(Ne(i)>=Ne(t)||a.fragmentError>e[t].fragmentError)?t:(v=a.maxScore,i):(nr(i,"no variants with VIDEO-RANGE of "+JSON.stringify(g)+" found"),t)}),void 0),videoRanges:g,preferHDR:y,minFramerate:f,minBitrate:c}}(this.codecTiers||(this.codecTiers=function(e,t,r,i){return e.slice(r,i+1).reduce((function(e,t){if(!t.codecSet)return e;var r=t.audioGroups,i=e[t.codecSet];i||(e[t.codecSet]=i={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!r,fragmentError:0}),i.minBitrate=Math.min(i.minBitrate,t.bitrate);var a=Math.min(t.height,t.width);return i.minHeight=Math.min(i.minHeight,a),i.minFramerate=Math.min(i.minFramerate,t.frameRate),i.maxScore=Math.max(i.maxScore,t.score),i.fragmentError+=t.fragmentError,i.videoRanges[t.videoRange]=(i.videoRanges[t.videoRange]||0)+1,e}),{})}(g,0,t,r)),A,e,D,_),w=x.codecSet,C=x.videoRanges,I=x.minFramerate,P=x.minBitrate,F=x.preferHDR;T=w,A=F?C[C.length-1]:C[0],b=I,e=Math.max(e,P),k.log("[abr] picked start tier "+JSON.stringify(x))}else T=null==S?void 0:S.codecSet,A=null==S?void 0:S.videoRange;for(var O,M=c?c.duration:f?f.duration:0,N=this.bwEstimator.getEstimateTTFB()/1e3,B=[],U=function(){var t,o=g[G],f=G>h;if(!o)return 0;if(T&&o.codecSet!==T||A&&o.videoRange!==A||f&&b>o.frameRate||!f&&b>0&&b<o.frameRate||o.supportedResult&&(null==(t=o.supportedResult.decodingInfoResults)||!t[0].smooth))return B.push(G),0;var v,p=o.details,E=(c?null==p?void 0:p.partTarget:null==p?void 0:p.averagetargetduration)||M;v=f?s*e:n*e;var D=M&&i>=2*M&&0===a?g[G].averageBitrate:g[G].maxBitrate,_=l.getTimeToLoadFrag(N,v,D*E,void 0===p);if(v>=D&&(G===d||0===o.loadError&&0===o.fragmentError)&&(_<=N||!m(_)||L&&!l.bitrateTestDelay||_<u)){var x=l.forcedAutoLevel;return G===y||-1!==x&&x===y||(B.length&&k.trace("[abr] Skipped level(s) "+B.join(",")+" of "+r+' max with CODECS and VIDEO-RANGE:"'+g[B[0]].codecs+'" '+g[B[0]].videoRange+'; not compatible with "'+S.codecs+'" '+A),k.info("[abr] switch candidate:"+h+"->"+G+" adjustedbw("+Math.round(v)+")-bitrate="+Math.round(v-D)+" ttfb:"+N.toFixed(1)+" avgDuration:"+E.toFixed(1)+" maxFetchDuration:"+u.toFixed(1)+" fetchDuration:"+_.toFixed(1)+" firstSelection:"+R+" codecSet:"+T+" videoRange:"+A+" hls.loadLevel:"+y)),R&&(l.firstSelection=G),{v:G}}},G=r;G>=t;G--)if(0!==(O=U())&&O)return O.v;return-1},s(e,[{key:"firstAutoLevel",get:function(){var e=this.hls,t=e.maxAutoLevel,r=e.minAutoLevel,i=this.getBwEstimate(),a=this.hls.config.maxStarvationDelay,n=this.findBestLevel(i,r,t,0,a,1,1);if(n>-1)return n;var s=this.hls.firstLevel,o=Math.min(Math.max(s,r),t);return k.warn("[abr] Could not find best starting auto level. Defaulting to first in playlist "+s+" clamped to "+o),o}},{key:"forcedAutoLevel",get:function(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}},{key:"nextAutoLevel",get:function(){var e=this.forcedAutoLevel,t=this.bwEstimator.canEstimate(),r=this.lastLoadedFragLevel>-1;if(!(-1===e||t&&r&&this.nextAutoLevelKey!==this.getAutoLevelKey()))return e;var i=t&&r?this.getNextABRAutoLevel():this.firstAutoLevel;if(-1!==e){var a=this.hls.levels;if(a.length>Math.max(e,i)&&a[e].loadError<=a[i].loadError)return e}return this._nextAutoLevel=i,this.nextAutoLevelKey=this.getAutoLevelKey(),i},set:function(e){var t=this.hls,r=t.maxAutoLevel,i=t.minAutoLevel,a=Math.min(Math.max(e,i),r);this._nextAutoLevel!==a&&(this.nextAutoLevelKey="",this._nextAutoLevel=a)}}]),e}(),or={length:0,start:function(){return 0},end:function(){return 0}},lr=function(){function e(){}return e.isBuffered=function(t,r){try{if(t)for(var i=e.getBuffered(t),a=0;a<i.length;a++)if(r>=i.start(a)&&r<=i.end(a))return!0}catch(e){}return!1},e.bufferInfo=function(t,r,i){try{if(t){var a,n=e.getBuffered(t),s=[];for(a=0;a<n.length;a++)s.push({start:n.start(a),end:n.end(a)});return this.bufferedInfo(s,r,i)}}catch(e){}return{len:0,start:r,end:r,nextStart:void 0}},e.bufferedInfo=function(e,t,r){t=Math.max(0,t),e.sort((function(e,t){return e.start-t.start||t.end-e.end}));var i=[];if(r)for(var a=0;a<e.length;a++){var n=i.length;if(n){var s=i[n-1].end;e[a].start-s<r?e[a].end>s&&(i[n-1].end=e[a].end):i.push(e[a])}else i.push(e[a])}else i=e;for(var o,l=0,u=t,d=t,h=0;h<i.length;h++){var f=i[h].start,c=i[h].end;if(t+r>=f&&t<c)u=f,l=(d=c)-t;else if(t+r<f){o=f;break}}return{len:l,start:u||0,end:d||0,nextStart:o}},e.getBuffered=function(e){try{return e.buffered}catch(e){return k.log("failed to get media.buffered",e),or}},e}(),ur=function(){function e(e){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=e}var t=e.prototype;return t.append=function(e,t,r){var i=this.queues[t];i.push(e),1!==i.length||r||this.executeNext(t)},t.insertAbort=function(e,t){this.queues[t].unshift(e),this.executeNext(t)},t.appendBlocker=function(e){var t,r=new Promise((function(e){t=e})),i={execute:t,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(i,e),r},t.executeNext=function(e){var t=this.queues[e];if(t.length){var r=t[0];try{r.execute()}catch(t){k.warn('[buffer-operation-queue]: Exception executing "'+e+'" SourceBuffer operation: '+t),r.onError(t);var i=this.buffers[e];null!=i&&i.updating||this.shiftAndExecuteNext(e)}}},t.shiftAndExecuteNext=function(e){this.queues[e].shift(),this.executeNext(e)},t.current=function(e){return this.queues[e][0]},e}(),dr=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,hr=function(){function e(e){var t=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendSource=void 0,this.appendErrors={audio:0,video:0,audiovideo:0},this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this.log=void 0,this.warn=void 0,this.error=void 0,this._onEndStreaming=function(e){t.hls&&t.hls.pauseBuffering()},this._onStartStreaming=function(e){t.hls&&t.hls.resumeBuffering()},this._onMediaSourceOpen=function(){var e=t.media,r=t.mediaSource;t.log("Media source opened"),e&&(e.removeEventListener("emptied",t._onMediaEmptied),t.updateMediaElementDuration(),t.hls.trigger(E.MEDIA_ATTACHED,{media:e,mediaSource:r})),r&&r.removeEventListener("sourceopen",t._onMediaSourceOpen),t.checkPendingTracks()},this._onMediaSourceClose=function(){t.log("Media source closed")},this._onMediaSourceEnded=function(){t.log("Media source ended")},this._onMediaEmptied=function(){var e=t.mediaSrc,r=t._objectUrl;e!==r&&k.error("Media element src was set while attaching MediaSource ("+r+" > "+e+")")},this.hls=e;var r,i="[buffer-controller]";this.appendSource=(r=Ce(e.config.preferManagedMediaSource),"undefined"!=typeof self&&r===self.ManagedMediaSource),this.log=k.log.bind(k,i),this.warn=k.warn.bind(k,i),this.error=k.error.bind(k,i),this._initSourceBuffer(),this.registerListeners()}var t=e.prototype;return t.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},t.destroy=function(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null,this.hls=null},t.registerListeners=function(){var e=this.hls;e.on(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_PARSED,this.onManifestParsed,this),e.on(E.BUFFER_RESET,this.onBufferReset,this),e.on(E.BUFFER_APPENDING,this.onBufferAppending,this),e.on(E.BUFFER_CODECS,this.onBufferCodecs,this),e.on(E.BUFFER_EOS,this.onBufferEos,this),e.on(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(E.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(E.FRAG_PARSED,this.onFragParsed,this),e.on(E.FRAG_CHANGED,this.onFragChanged,this)},t.unregisterListeners=function(){var e=this.hls;e.off(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_PARSED,this.onManifestParsed,this),e.off(E.BUFFER_RESET,this.onBufferReset,this),e.off(E.BUFFER_APPENDING,this.onBufferAppending,this),e.off(E.BUFFER_CODECS,this.onBufferCodecs,this),e.off(E.BUFFER_EOS,this.onBufferEos,this),e.off(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(E.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(E.FRAG_PARSED,this.onFragParsed,this),e.off(E.FRAG_CHANGED,this.onFragChanged,this)},t._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new ur(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.appendErrors={audio:0,video:0,audiovideo:0},this.lastMpegAudioChunk=null},t.onManifestLoading=function(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null},t.onManifestParsed=function(e,t){t.audio&&!t.video||t.altAudio,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=1,this.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},t.onMediaAttaching=function(e,t){var r=this.media=t.media,i=Ce(this.appendSource);if(r&&i){var a,n=this.mediaSource=new i;this.log("created media source: "+(null==(a=n.constructor)?void 0:a.name)),n.addEventListener("sourceopen",this._onMediaSourceOpen),n.addEventListener("sourceended",this._onMediaSourceEnded),n.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(n.addEventListener("startstreaming",this._onStartStreaming),n.addEventListener("endstreaming",this._onEndStreaming));var s=this._objectUrl=self.URL.createObjectURL(n);if(this.appendSource)try{r.removeAttribute("src");var o=self.ManagedMediaSource;r.disableRemotePlayback=r.disableRemotePlayback||o&&n instanceof o,fr(r),function(e,t){var r=self.document.createElement("source");r.type="video/mp4",r.src=t,e.appendChild(r)}(r,s),r.load()}catch(e){r.src=s}else r.src=s;r.addEventListener("emptied",this._onMediaEmptied)}},t.onMediaDetaching=function(){var e=this.media,t=this.mediaSource,r=this._objectUrl;if(t){if(this.log("media source detaching"),"open"===t.readyState)try{t.endOfStream()}catch(e){this.warn("onMediaDetaching: "+e.message+" while calling endOfStream")}this.onBufferReset(),t.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("sourceended",this._onMediaSourceEnded),t.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(t.removeEventListener("startstreaming",this._onStartStreaming),t.removeEventListener("endstreaming",this._onEndStreaming)),e&&(e.removeEventListener("emptied",this._onMediaEmptied),r&&self.URL.revokeObjectURL(r),this.mediaSrc===r?(e.removeAttribute("src"),this.appendSource&&fr(e),e.load()):this.warn("media|source.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(E.MEDIA_DETACHED,void 0)},t.onBufferReset=function(){var e=this;this.getSourceBufferTypes().forEach((function(t){e.resetBuffer(t)})),this._initSourceBuffer()},t.resetBuffer=function(e){var t=this.sourceBuffer[e];try{var r;t&&(this.removeBufferListeners(e),this.sourceBuffer[e]=void 0,null!=(r=this.mediaSource)&&r.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(t))}catch(t){this.warn("onBufferReset "+e,t)}},t.onBufferCodecs=function(e,t){var r=this,i=this.getSourceBufferTypes().length,a=Object.keys(t);if(a.forEach((function(e){if(i){var a=r.tracks[e];if(a&&"function"==typeof a.buffer.changeType){var n,s=t[e],o=s.id,l=s.codec,u=s.levelCodec,d=s.container,h=s.metadata,f=He(a.codec,a.levelCodec),c=null==f?void 0:f.replace(dr,"$1"),v=He(l,u),g=null==(n=v)?void 0:n.replace(dr,"$1");if(v&&c!==g){"audio"===e.slice(0,5)&&(v=Ge(v,r.appendSource));var m=d+";codecs="+v;r.appendChangeType(e,m),r.log("switching codec "+f+" to "+v),r.tracks[e]={buffer:a.buffer,codec:l,container:d,levelCodec:u,metadata:h,id:o}}}}else r.pendingTracks[e]=t[e]})),!i){var n=Math.max(this.bufferCodecEventsExpected-1,0);this.bufferCodecEventsExpected!==n&&(this.log(n+" bufferCodec event(s) expected "+a.join(",")),this.bufferCodecEventsExpected=n),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks()}},t.appendChangeType=function(e,t){var r=this,i=this.operationQueue,a={execute:function(){var a=r.sourceBuffer[e];a&&(r.log("changing "+e+" sourceBuffer type to "+t),a.changeType(t)),i.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(t){r.warn("Failed to change "+e+" SourceBuffer type",t)}};i.append(a,e,!!this.pendingTracks[e])},t.onBufferAppending=function(e,t){var r=this,i=this.hls,a=this.operationQueue,n=this.tracks,s=t.data,o=t.type,l=t.frag,u=t.part,d=t.chunkMeta,h=d.buffering[o],f=self.performance.now();h.start=f;var c=l.stats.buffering,v=u?u.stats.buffering:null;0===c.start&&(c.start=f),v&&0===v.start&&(v.start=f);var g=n.audio,m=!1;"audio"===o&&"audio/mpeg"===(null==g?void 0:g.container)&&(m=!this.lastMpegAudioChunk||1===d.id||this.lastMpegAudioChunk.sn!==d.sn,this.lastMpegAudioChunk=d);var p=l.start,y={execute:function(){if(h.executeStart=self.performance.now(),m){var e=r.sourceBuffer[o];if(e){var t=p-e.timestampOffset;Math.abs(t)>=.1&&(r.log("Updating audio SourceBuffer timestampOffset to "+p+" (delta: "+t+") sn: "+l.sn+")"),e.timestampOffset=p)}}r.appendExecutor(s,o)},onStart:function(){},onComplete:function(){var e=self.performance.now();h.executeEnd=h.end=e,0===c.first&&(c.first=e),v&&0===v.first&&(v.first=e);var t=r.sourceBuffer,i={};for(var a in t)i[a]=lr.getBuffered(t[a]);r.appendErrors[o]=0,"audio"===o||"video"===o?r.appendErrors.audiovideo=0:(r.appendErrors.audio=0,r.appendErrors.video=0),r.hls.trigger(E.BUFFER_APPENDED,{type:o,frag:l,part:u,chunkMeta:d,parent:l.type,timeRanges:i})},onError:function(e){var t={type:T.MEDIA_ERROR,parent:l.type,details:S.BUFFER_APPEND_ERROR,sourceBufferName:o,frag:l,part:u,chunkMeta:d,error:e,err:e,fatal:!1};if(e.code===DOMException.QUOTA_EXCEEDED_ERR)t.details=S.BUFFER_FULL_ERROR;else{var a=++r.appendErrors[o];t.details=S.BUFFER_APPEND_ERROR,r.warn("Failed "+a+"/"+i.config.appendErrorMaxRetry+' times to append segment in "'+o+'" sourceBuffer'),a>=i.config.appendErrorMaxRetry&&(t.fatal=!0)}i.trigger(E.ERROR,t)}};a.append(y,o,!!this.pendingTracks[o])},t.onBufferFlushing=function(e,t){var r=this,i=this.operationQueue,a=function(e){return{execute:r.removeExecutor.bind(r,e,t.startOffset,t.endOffset),onStart:function(){},onComplete:function(){r.hls.trigger(E.BUFFER_FLUSHED,{type:e})},onError:function(t){r.warn("Failed to remove from "+e+" SourceBuffer",t)}}};t.type?i.append(a(t.type),t.type):this.getSourceBufferTypes().forEach((function(e){i.append(a(e),e)}))},t.onFragParsed=function(e,t){var r=this,i=t.frag,a=t.part,n=[],s=a?a.elementaryStreams:i.elementaryStreams;s[M]?n.push("audiovideo"):(s[F]&&n.push("audio"),s[O]&&n.push("video"));0===n.length&&this.warn("Fragments must have at least one ElementaryStreamType set. type: "+i.type+" level: "+i.level+" sn: "+i.sn),this.blockBuffers((function(){var e=self.performance.now();i.stats.buffering.end=e,a&&(a.stats.buffering.end=e);var t=a?a.stats:i.stats;r.hls.trigger(E.FRAG_BUFFERED,{frag:i,part:a,stats:t,id:i.type})}),n)},t.onFragChanged=function(e,t){this.trimBuffers()},t.onBufferEos=function(e,t){var r=this;this.getSourceBufferTypes().reduce((function(e,i){var a=r.sourceBuffer[i];return!a||t.type&&t.type!==i||(a.ending=!0,a.ended||(a.ended=!0,r.log(i+" sourceBuffer now EOS"))),e&&!(a&&!a.ended)}),!0)&&(this.log("Queueing mediaSource.endOfStream()"),this.blockBuffers((function(){r.getSourceBufferTypes().forEach((function(e){var t=r.sourceBuffer[e];t&&(t.ending=!1)}));var e=r.mediaSource;e&&"open"===e.readyState?(r.log("Calling mediaSource.endOfStream()"),e.endOfStream()):e&&r.log("Could not call mediaSource.endOfStream(). mediaSource.readyState: "+e.readyState)})))},t.onLevelUpdated=function(e,t){var r=t.details;r.fragments.length&&(this.details=r,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},t.trimBuffers=function(){var e=this.hls,t=this.details,r=this.media;if(r&&null!==t&&this.getSourceBufferTypes().length){var i=e.config,a=r.currentTime,n=t.levelTargetDuration,s=t.live&&null!==i.liveBackBufferLength?i.liveBackBufferLength:i.backBufferLength;if(m(s)&&s>0){var o=Math.max(s,n),l=Math.floor(a/n)*n-o;this.flushBackBuffer(a,n,l)}if(m(i.frontBufferFlushThreshold)&&i.frontBufferFlushThreshold>0){var u=Math.max(i.maxBufferLength,i.frontBufferFlushThreshold),d=Math.max(u,n),h=Math.floor(a/n)*n+d;this.flushFrontBuffer(a,n,h)}}},t.flushBackBuffer=function(e,t,r){var i=this,a=this.details,n=this.sourceBuffer;this.getSourceBufferTypes().forEach((function(s){var o=n[s];if(o){var l=lr.getBuffered(o);if(l.length>0&&r>l.start(0)){if(i.hls.trigger(E.BACK_BUFFER_REACHED,{bufferEnd:r}),null!=a&&a.live)i.hls.trigger(E.LIVE_BACK_BUFFER_REACHED,{bufferEnd:r});else if(o.ended&&l.end(l.length-1)-e<2*t)return void i.log("Cannot flush "+s+" back buffer while SourceBuffer is in ended state");i.hls.trigger(E.BUFFER_FLUSHING,{startOffset:0,endOffset:r,type:s})}}}))},t.flushFrontBuffer=function(e,t,r){var i=this,a=this.sourceBuffer;this.getSourceBufferTypes().forEach((function(n){var s=a[n];if(s){var o=lr.getBuffered(s),l=o.length;if(l<2)return;var u=o.start(l-1),d=o.end(l-1);if(r>u||e>=u&&e<=d)return;if(s.ended&&e-d<2*t)return void i.log("Cannot flush "+n+" front buffer while SourceBuffer is in ended state");i.hls.trigger(E.BUFFER_FLUSHING,{startOffset:u,endOffset:1/0,type:n})}}))},t.updateMediaElementDuration=function(){if(this.details&&this.media&&this.mediaSource&&"open"===this.mediaSource.readyState){var e=this.details,t=this.hls,r=this.media,i=this.mediaSource,a=e.fragments[0].start+e.totalduration,n=r.duration,s=m(i.duration)?i.duration:0;e.live&&t.config.liveDurationInfinity?(i.duration=1/0,this.updateSeekableRange(e)):(a>s&&a>n||!m(n))&&(this.log("Updating Media Source duration to "+a.toFixed(3)),i.duration=a)}},t.updateSeekableRange=function(e){var t=this.mediaSource,r=e.fragments;if(r.length&&e.live&&null!=t&&t.setLiveSeekableRange){var i=Math.max(0,r[0].start),a=Math.max(i,i+e.totalduration);this.log("Media Source duration is set to "+t.duration+". Setting seekable range to "+i+"-"+a+"."),t.setLiveSeekableRange(i,a)}},t.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,t=this.operationQueue,r=this.pendingTracks,i=Object.keys(r).length;if(i&&(!e||2===i||"audiovideo"in r)){this.createSourceBuffers(r),this.pendingTracks={};var a=this.getSourceBufferTypes();if(a.length)this.hls.trigger(E.BUFFER_CREATED,{tracks:this.tracks}),a.forEach((function(e){t.executeNext(e)}));else{var n=new Error("could not create source buffer for media codec(s)");this.hls.trigger(E.ERROR,{type:T.MEDIA_ERROR,details:S.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:n,reason:n.message})}}},t.createSourceBuffers=function(e){var t=this,r=this.sourceBuffer,i=this.mediaSource;if(!i)throw Error("createSourceBuffers called when mediaSource was null");var a=function(a){if(!r[a]){var n,s=e[a];if(!s)throw Error("source buffer exists for track "+a+", however track does not");var o=-1===(null==(n=s.levelCodec)?void 0:n.indexOf(","))?s.levelCodec:s.codec;o&&"audio"===a.slice(0,5)&&(o=Ge(o,t.appendSource));var l=s.container+";codecs="+o;t.log("creating sourceBuffer("+l+")");try{var u=r[a]=i.addSourceBuffer(l),d=a;t.addBufferListener(d,"updatestart",t._onSBUpdateStart),t.addBufferListener(d,"updateend",t._onSBUpdateEnd),t.addBufferListener(d,"error",t._onSBUpdateError),t.appendSource&&t.addBufferListener(d,"bufferedchange",(function(e,r){var i=r.removedRanges;null!=i&&i.length&&t.hls.trigger(E.BUFFER_FLUSHED,{type:a})})),t.tracks[a]={buffer:u,codec:o,container:s.container,levelCodec:s.levelCodec,metadata:s.metadata,id:s.id}}catch(e){t.error("error while trying to add sourceBuffer: "+e.message),t.hls.trigger(E.ERROR,{type:T.MEDIA_ERROR,details:S.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:e,sourceBufferName:a,mimeType:l})}}};for(var n in e)a(n)},t._onSBUpdateStart=function(e){this.operationQueue.current(e).onStart()},t._onSBUpdateEnd=function(e){var t;if("closed"!==(null==(t=this.mediaSource)?void 0:t.readyState)){var r=this.operationQueue;r.current(e).onComplete(),r.shiftAndExecuteNext(e)}else this.resetBuffer(e)},t._onSBUpdateError=function(e,t){var r,i=new Error(e+" SourceBuffer error. MediaSource readyState: "+(null==(r=this.mediaSource)?void 0:r.readyState));this.error(""+i,t),this.hls.trigger(E.ERROR,{type:T.MEDIA_ERROR,details:S.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:i,fatal:!1});var a=this.operationQueue.current(e);a&&a.onError(i)},t.removeExecutor=function(e,t,r){var i=this.media,a=this.mediaSource,n=this.operationQueue,s=this.sourceBuffer[e];if(!i||!a||!s)return this.warn("Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),void n.shiftAndExecuteNext(e);var o=m(i.duration)?i.duration:1/0,l=m(a.duration)?a.duration:1/0,u=Math.max(0,t),d=Math.min(r,o,l);d>u&&(!s.ending||s.ended)?(s.ended=!1,this.log("Removing ["+u+","+d+"] from the "+e+" SourceBuffer"),s.remove(u,d)):n.shiftAndExecuteNext(e)},t.appendExecutor=function(e,t){var r=this.sourceBuffer[t];if(r)r.ended=!1,r.appendBuffer(e);else if(!this.pendingTracks[t])throw new Error("Attempting to append to the "+t+" SourceBuffer, but it does not exist")},t.blockBuffers=function(e,t){var r=this;if(void 0===t&&(t=this.getSourceBufferTypes()),!t.length)return this.log("Blocking operation requested, but no SourceBuffers exist"),void Promise.resolve().then(e);var i=this.operationQueue,a=t.map((function(e){return i.appendBlocker(e)}));Promise.all(a).then((function(){e(),t.forEach((function(e){var t=r.sourceBuffer[e];null!=t&&t.updating||i.shiftAndExecuteNext(e)}))}))},t.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},t.addBufferListener=function(e,t,r){var i=this.sourceBuffer[e];if(i){var a=r.bind(this,e);this.listeners[e].push({event:t,listener:a}),i.addEventListener(t,a)}},t.removeBufferListeners=function(e){var t=this.sourceBuffer[e];t&&this.listeners[e].forEach((function(e){t.removeEventListener(e.event,e.listener)}))},s(e,[{key:"mediaSrc",get:function(){var e,t,r=(null==(e=this.media)||null==(t=e.querySelector)?void 0:t.call(e,"source"))||this.media;return null==r?void 0:r.src}}]),e}();function fr(e){var t=e.querySelectorAll("source");[].slice.call(t).forEach((function(t){e.removeChild(t)}))}var cr=function(){function e(e){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=e,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var t=e.prototype;return t.setStreamController=function(e){this.streamController=e},t.destroy=function(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},t.registerListeners=function(){var e=this.hls;e.on(E.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(E.MANIFEST_PARSED,this.onManifestParsed,this),e.on(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(E.BUFFER_CODECS,this.onBufferCodecs,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this)},t.unregisterListener=function(){var e=this.hls;e.off(E.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(E.MANIFEST_PARSED,this.onManifestParsed,this),e.off(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(E.BUFFER_CODECS,this.onBufferCodecs,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this)},t.onFpsDropLevelCapping=function(e,t){var r=this.hls.levels[t.droppedLevel];this.isLevelAllowed(r)&&this.restrictedLevels.push({bitrate:r.bitrate,height:r.height,width:r.width})},t.onMediaAttaching=function(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()},t.onManifestParsed=function(e,t){var r=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,r.config.capLevelToPlayerSize&&t.video&&this.startCapping()},t.onLevelsUpdated=function(e,t){this.timer&&m(this.autoLevelCapping)&&this.detectPlayerSize()},t.onBufferCodecs=function(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()},t.onMediaDetaching=function(){this.stopCapping()},t.detectPlayerSize=function(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0)return void(this.clientRect=null);var e=this.hls.levels;if(e.length){var t=this.hls,r=this.getMaxLevel(e.length-1);r!==this.autoLevelCapping&&k.log("Setting autoLevelCapping to "+r+": "+e[r].height+"p@"+e[r].bitrate+" for media "+this.mediaWidth+"x"+this.mediaHeight),t.autoLevelCapping=r,t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}},t.getMaxLevel=function(t){var r=this,i=this.hls.levels;if(!i.length)return-1;var a=i.filter((function(e,i){return r.isLevelAllowed(e)&&i<=t}));return this.clientRect=null,e.getMaxLevelByMediaSize(a,this.mediaWidth,this.mediaHeight)},t.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},t.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},t.getDimensions=function(){if(this.clientRect)return this.clientRect;var e=this.media,t={width:0,height:0};if(e){var r=e.getBoundingClientRect();t.width=r.width,t.height=r.height,t.width||t.height||(t.width=r.right-r.left||e.width||0,t.height=r.bottom-r.top||e.height||0)}return this.clientRect=t,t},t.isLevelAllowed=function(e){return!this.restrictedLevels.some((function(t){return e.bitrate===t.bitrate&&e.width===t.width&&e.height===t.height}))},e.getMaxLevelByMediaSize=function(e,t,r){if(null==e||!e.length)return-1;for(var i=e.length-1,a=Math.max(t,r),n=0;n<e.length;n+=1){var s=e[n];if((s.width>=a||s.height>=a)&&(o=s,!(l=e[n+1])||o.width!==l.width||o.height!==l.height)){i=n;break}}var o,l;return i},s(e,[{key:"mediaWidth",get:function(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function(){var e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch(e){}return e}}]),e}(),vr=function(){function e(e){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=e,this.registerListeners()}var t=e.prototype;return t.setStreamController=function(e){this.streamController=e},t.registerListeners=function(){this.hls.on(E.MEDIA_ATTACHING,this.onMediaAttaching,this)},t.unregisterListeners=function(){this.hls.off(E.MEDIA_ATTACHING,this.onMediaAttaching,this)},t.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},t.onMediaAttaching=function(e,t){var r=this.hls.config;if(r.capLevelOnFPSDrop){var i=t.media instanceof self.HTMLVideoElement?t.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)}},t.checkFPS=function(e,t,r){var i=performance.now();if(t){if(this.lastTime){var a=i-this.lastTime,n=r-this.lastDroppedFrames,s=t-this.lastDecodedFrames,o=1e3*n/a,l=this.hls;if(l.trigger(E.FPS_DROP,{currentDropped:n,currentDecoded:s,totalDroppedFrames:r}),o>0&&n>l.config.fpsDroppedMonitoringThreshold*s){var u=l.currentLevel;k.warn("drop FPS ratio greater than max allowed value for currentLevel: "+u),u>0&&(-1===l.autoLevelCapping||l.autoLevelCapping>=u)&&(u-=1,l.trigger(E.FPS_DROP_LEVEL_CAPPING,{level:u,droppedLevel:l.currentLevel}),l.autoLevelCapping=u,this.streamController.nextLevelSwitch())}}this.lastTime=i,this.lastDroppedFrames=r,this.lastDecodedFrames=t}},t.checkFPSInterval=function(){var e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){var t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)},e}(),gr=function(){function e(e){this.hls=void 0,this.log=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this.pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=e,this.log=k.log.bind(k,"[content-steering]:"),this.registerListeners()}var t=e.prototype;return t.registerListeners=function(){var e=this.hls;e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(E.MANIFEST_PARSED,this.onManifestParsed,this),e.on(E.ERROR,this.onError,this)},t.unregisterListeners=function(){var e=this.hls;e&&(e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(E.MANIFEST_PARSED,this.onManifestParsed,this),e.off(E.ERROR,this.onError,this))},t.startLoad=function(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){var e=1e3*this.timeToLoad-(performance.now()-this.updated);if(e>0)return void this.scheduleRefresh(this.uri,e)}this.loadSteeringManifest(this.uri)}},t.stopLoad=function(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()},t.clearTimeout=function(){-1!==this.reloadTimer&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)},t.destroy=function(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null},t.removeLevel=function(e){var t=this.levels;t&&(this.levels=t.filter((function(t){return t!==e})))},t.onManifestLoading=function(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null},t.onManifestLoaded=function(e,t){var r=t.contentSteering;null!==r&&(this.pathwayId=r.pathwayId,this.uri=r.uri,this.started&&this.startLoad())},t.onManifestParsed=function(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks},t.onError=function(e,t){var r=t.errorAction;if((null==r?void 0:r.action)===zt&&r.flags===$t){var i=this.levels,a=this.pathwayPriority,n=this.pathwayId;if(t.context){var s=t.context,o=s.groupId,l=s.pathwayId,u=s.type;o&&i?n=this.getPathwayForGroupId(o,u,n):l&&(n=l)}n in this.penalizedPathways||(this.penalizedPathways[n]=performance.now()),!a&&i&&(a=i.reduce((function(e,t){return-1===e.indexOf(t.pathwayId)&&e.push(t.pathwayId),e}),[])),a&&a.length>1&&(this.updatePathwayPriority(a),r.resolved=this.pathwayId!==n),r.resolved||k.warn("Could not resolve "+t.details+' ("'+t.error.message+'") with content-steering for Pathway: '+n+" levels: "+(i?i.length:i)+" priorities: "+JSON.stringify(a)+" penalized: "+JSON.stringify(this.penalizedPathways))}},t.filterParsedLevels=function(e){this.levels=e;var t=this.getLevelsForPathway(this.pathwayId);if(0===t.length){var r=e[0].pathwayId;this.log("No levels found in Pathway "+this.pathwayId+'. Setting initial Pathway to "'+r+'"'),t=this.getLevelsForPathway(r),this.pathwayId=r}return t.length!==e.length&&this.log("Found "+t.length+"/"+e.length+' levels in Pathway "'+this.pathwayId+'"'),t},t.getLevelsForPathway=function(e){return null===this.levels?[]:this.levels.filter((function(t){return e===t.pathwayId}))},t.updatePathwayPriority=function(e){var t;this.pathwayPriority=e;var r=this.penalizedPathways,i=performance.now();Object.keys(r).forEach((function(e){i-r[e]>3e5&&delete r[e]}));for(var a=0;a<e.length;a++){var n=e[a];if(!(n in r)){if(n===this.pathwayId)return;var s=this.hls.nextLoadLevel,o=this.hls.levels[s];if((t=this.getLevelsForPathway(n)).length>0){this.log('Setting Pathway to "'+n+'"'),this.pathwayId=n,Nt(t),this.hls.trigger(E.LEVELS_UPDATED,{levels:t});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}}}},t.getPathwayForGroupId=function(e,t,r){for(var i=this.getLevelsForPathway(r).concat(this.levels||[]),a=0;a<i.length;a++)if(t===it&&i[a].hasAudioGroup(e)||t===at&&i[a].hasSubtitleGroup(e))return i[a].pathwayId;return r},t.clonePathways=function(e){var t=this,r=this.levels;if(r){var i={},a={};e.forEach((function(e){var n=e.ID,s=e["BASE-ID"],o=e["URI-REPLACEMENT"];if(!r.some((function(e){return e.pathwayId===n}))){var l=t.getLevelsForPathway(s).map((function(e){var t=new w(e.attrs);t["PATHWAY-ID"]=n;var r=t.AUDIO&&t.AUDIO+"_clone_"+n,s=t.SUBTITLES&&t.SUBTITLES+"_clone_"+n;r&&(i[t.AUDIO]=r,t.AUDIO=r),s&&(a[t.SUBTITLES]=s,t.SUBTITLES=s);var l=pr(e.uri,t["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",o),u=new xt({attrs:t,audioCodec:e.audioCodec,bitrate:e.bitrate,height:e.height,name:e.name,url:l,videoCodec:e.videoCodec,width:e.width});if(e.audioGroups)for(var d=1;d<e.audioGroups.length;d++)u.addGroupId("audio",e.audioGroups[d]+"_clone_"+n);if(e.subtitleGroups)for(var h=1;h<e.subtitleGroups.length;h++)u.addGroupId("text",e.subtitleGroups[h]+"_clone_"+n);return u}));r.push.apply(r,l),mr(t.audioTracks,i,o,n),mr(t.subtitleTracks,a,o,n)}}))}},t.loadSteeringManifest=function(e){var t,r=this,i=this.hls.config,a=i.loader;this.loader&&this.loader.destroy(),this.loader=new a(i);try{t=new self.URL(e)}catch(t){return this.enabled=!1,void this.log("Failed to parse Steering Manifest URI: "+e)}if("data:"!==t.protocol){var n=0|(this.hls.bandwidthEstimate||i.abrEwmaDefaultEstimate);t.searchParams.set("_HLS_pathway",this.pathwayId),t.searchParams.set("_HLS_throughput",""+n)}var s={responseType:"json",url:t.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},d={onSuccess:function(e,i,a,n){r.log('Loaded steering manifest: "'+t+'"');var s=e.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,t).href}catch(e){return r.enabled=!1,void r.log("Failed to parse Steering Manifest RELOAD-URI: "+o)}r.scheduleRefresh(r.uri||a.url),l&&r.clonePathways(l);var d={steeringManifest:s,url:t.toString()};r.hls.trigger(E.STEERING_MANIFEST_LOADED,d),u&&r.updatePathwayPriority(u)}else r.log("Steering VERSION "+s.VERSION+" not supported!")},onError:function(e,t,i,a){if(r.log("Error loading steering manifest: "+e.code+" "+e.text+" ("+t.url+")"),r.stopLoad(),410===e.code)return r.enabled=!1,void r.log("Steering manifest "+t.url+" no longer available");var n=1e3*r.timeToLoad;if(429!==e.code)r.scheduleRefresh(r.uri||t.url,n);else{var s=r.loader;if("function"==typeof(null==s?void 0:s.getResponseHeader)){var o=s.getResponseHeader("Retry-After");o&&(n=1e3*parseFloat(o))}r.log("Steering manifest "+t.url+" rate limited")}},onTimeout:function(e,t,i){r.log("Timeout loading steering manifest ("+t.url+")"),r.scheduleRefresh(r.uri||t.url)}};this.log("Requesting steering manifest: "+t),this.loader.load(s,u,d)},t.scheduleRefresh=function(e,t){var r=this;void 0===t&&(t=1e3*this.timeToLoad),this.clearTimeout(),this.reloadTimer=self.setTimeout((function(){var t,i=null==(t=r.hls)?void 0:t.media;!i||i.ended?r.scheduleRefresh(e,1e3*r.timeToLoad):r.loadSteeringManifest(e)}),t)},e}();function mr(e,t,r,i){e&&Object.keys(t).forEach((function(a){var n=e.filter((function(e){return e.groupId===a})).map((function(e){var n=o({},e);return n.details=void 0,n.attrs=new w(n.attrs),n.url=n.attrs.URI=pr(e.url,e.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",r),n.groupId=n.attrs["GROUP-ID"]=t[a],n.attrs["PATHWAY-ID"]=i,n}));e.push.apply(e,n)}))}function pr(e,t,r,i){var a,n=i.HOST,s=i.PARAMS,o=i[r];t&&(a=null==o?void 0:o[t])&&(e=a);var l=new self.URL(e);return n&&!a&&(l.host=n),s&&Object.keys(s).sort().forEach((function(e){e&&l.searchParams.set(e,s[e])})),l.href}var yr=/^age:\s*[\d.]+\s*$/im,Er=function(){function e(e){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=null,this.loader=null,this.stats=void 0,this.xhrSetup=e&&e.xhrSetup||null,this.stats=new P,this.retryDelay=0}var t=e.prototype;return t.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null},t.abortInternal=function(){var e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,4!==e.readyState&&(this.stats.aborted=!0,e.abort()))},t.abort=function(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},t.load=function(e,t,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=r,this.loadInternal()},t.loadInternal=function(){var e=this,t=this.config,r=this.context;if(t&&r){var i=this.loader=new self.XMLHttpRequest,a=this.stats;a.loading.first=0,a.loaded=0,a.aborted=!1;var n=this.xhrSetup;n?Promise.resolve().then((function(){if(e.loader===i&&!e.stats.aborted)return n(i,r.url)})).catch((function(t){if(e.loader===i&&!e.stats.aborted)return i.open("GET",r.url,!0),n(i,r.url)})).then((function(){e.loader!==i||e.stats.aborted||e.openAndSendXhr(i,r,t)})).catch((function(t){e.callbacks.onError({code:i.status,text:t.message},r,i,a)})):this.openAndSendXhr(i,r,t)}},t.openAndSendXhr=function(e,t,r){e.readyState||e.open("GET",t.url,!0);var i=t.headers,a=r.loadPolicy,n=a.maxTimeToFirstByteMs,s=a.maxLoadTimeMs;if(i)for(var o in i)e.setRequestHeader(o,i[o]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),r.timeout=n&&m(n)?n:s,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.timeout),e.send()},t.readystatechange=function(){var e=this.context,t=this.loader,r=this.stats;if(e&&t){var i=t.readyState,a=this.config;if(!r.aborted&&i>=2&&(0===r.loading.first&&(r.loading.first=Math.max(self.performance.now(),r.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-(r.loading.first-r.loading.start)))),4===i)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;var n=t.status,s="text"!==t.responseType;if(n>=200&&n<300&&(s&&t.response||null!==t.responseText)){r.loading.end=Math.max(self.performance.now(),r.loading.first);var o=s?t.response:t.responseText,l="arraybuffer"===t.responseType?o.byteLength:o.length;if(r.loaded=r.total=l,r.bwEstimate=8e3*r.total/(r.loading.end-r.loading.first),!this.callbacks)return;var u=this.callbacks.onProgress;if(u&&u(r,e,o,t),!this.callbacks)return;var d={url:t.responseURL,data:o,code:n};this.callbacks.onSuccess(d,r,e,t)}else{var h=a.loadPolicy.errorRetry;Vt(h,r.retry,!1,{url:e.url,data:void 0,code:n})?this.retry(h):(k.error(n+" while loading "+e.url),this.callbacks.onError({code:n,text:t.statusText},e,t,r))}}}},t.loadtimeout=function(){if(this.config){var e=this.config.loadPolicy.timeoutRetry;if(Vt(e,this.stats.retry,!0))this.retry(e);else{var t;k.warn("timeout while loading "+(null==(t=this.context)?void 0:t.url));var r=this.callbacks;r&&(this.abortInternal(),r.onTimeout(this.stats,this.context,this.loader))}}},t.retry=function(e){var t=this.context,r=this.stats;this.retryDelay=Gt(e,r.retry),r.retry++,k.warn((status?"HTTP Status "+status:"Timeout")+" while loading "+(null==t?void 0:t.url)+", retrying "+r.retry+"/"+e.maxNumRetry+" in "+this.retryDelay+"ms"),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)},t.loadprogress=function(e){var t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)},t.getCacheAge=function(){var e=null;if(this.loader&&yr.test(this.loader.getAllResponseHeaders())){var t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e},t.getResponseHeader=function(e){return this.loader&&new RegExp("^"+e+":\\s*[\\d.]+\\s*$","im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null},e}(),Tr=function(){function e(){this.chunks=[],this.dataLength=0}var t=e.prototype;return t.push=function(e){this.chunks.push(e),this.dataLength+=e.length},t.flush=function(){var e,t=this.chunks,r=this.dataLength;return t.length?(e=1===t.length?t[0]:function(e,t){for(var r=new Uint8Array(t),i=0,a=0;a<e.length;a++){var n=e[a];r.set(n,i),i+=n.length}return r}(t,r),this.reset(),e):new Uint8Array(0)},t.reset=function(){this.chunks.length=0,this.dataLength=0},e}();var Sr=/(\d+)-(\d+)\/(\d+)/,Lr=function(){function e(e){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=null,this.response=null,this.controller=void 0,this.context=null,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=e.fetchSetup||Rr,this.controller=new self.AbortController,this.stats=new P}var t=e.prototype;return t.destroy=function(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null},t.abortInternal=function(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())},t.abort=function(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},t.load=function(e,t,r){var i=this,a=this.stats;if(a.loading.start)throw new Error("Loader can only be used once.");a.loading.start=self.performance.now();var n=function(e,t){var r={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(o({},e.headers))};return e.rangeEnd&&r.headers.set("Range","bytes="+e.rangeStart+"-"+String(e.rangeEnd-1)),r}(e,this.controller.signal),s=r.onProgress,l="arraybuffer"===e.responseType,u=l?"byteLength":"length",d=t.loadPolicy,h=d.maxTimeToFirstByteMs,f=d.maxLoadTimeMs;this.context=e,this.config=t,this.callbacks=r,this.request=this.fetchSetup(e,n),self.clearTimeout(this.requestTimeout),t.timeout=h&&m(h)?h:f,this.requestTimeout=self.setTimeout((function(){i.abortInternal(),r.onTimeout(a,e,i.response)}),t.timeout),self.fetch(this.request).then((function(n){i.response=i.loader=n;var o=Math.max(self.performance.now(),a.loading.start);if(self.clearTimeout(i.requestTimeout),t.timeout=f,i.requestTimeout=self.setTimeout((function(){i.abortInternal(),r.onTimeout(a,e,i.response)}),f-(o-a.loading.start)),!n.ok){var u=n.status,d=n.statusText;throw new br(d||"fetch, bad network response",u,n)}return a.loading.first=o,a.total=function(e){var t=e.get("Content-Range");if(t){var r=function(e){var t=Sr.exec(e);if(t)return parseInt(t[2])-parseInt(t[1])+1}(t);if(m(r))return r}var i=e.get("Content-Length");if(i)return parseInt(i)}(n.headers)||a.total,s&&m(t.highWaterMark)?i.loadProgressively(n,a,e,t.highWaterMark,s):l?n.arrayBuffer():"json"===e.responseType?n.json():n.text()})).then((function(n){var o=i.response;if(!o)throw new Error("loader destroyed");self.clearTimeout(i.requestTimeout),a.loading.end=Math.max(self.performance.now(),a.loading.first);var l=n[u];l&&(a.loaded=a.total=l);var d={url:o.url,data:n,code:o.status};s&&!m(t.highWaterMark)&&s(a,e,n,o),r.onSuccess(d,a,e,o)})).catch((function(t){if(self.clearTimeout(i.requestTimeout),!a.aborted){var n=t&&t.code||0,s=t?t.message:null;r.onError({code:n,text:s},e,t?t.details:null,a)}}))},t.getCacheAge=function(){var e=null;if(this.response){var t=this.response.headers.get("age");e=t?parseFloat(t):null}return e},t.getResponseHeader=function(e){return this.response?this.response.headers.get(e):null},t.loadProgressively=function(e,t,r,i,a){void 0===i&&(i=0);var n=new Tr,s=e.body.getReader();return function o(){return s.read().then((function(s){if(s.done)return n.dataLength&&a(t,r,n.flush(),e),Promise.resolve(new ArrayBuffer(0));var l=s.value,u=l.length;return t.loaded+=u,u<i||n.dataLength?(n.push(l),n.dataLength>=i&&a(t,r,n.flush(),e)):a(t,r,l,e),o()})).catch((function(){return Promise.reject()}))}()},e}();function Rr(e,t){return new self.Request(e.url,t)}var Ar,br=function(e){function t(t,r,i){var a;return(a=e.call(this,t)||this).code=void 0,a.details=void 0,a.code=r,a.details=i,a}return l(t,e),t}(f(Error)),Dr=i(i({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold: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:Er,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:sr,bufferController:hr,capLevelController:cr,errorController:er,fpsController:vr,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:null,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,useMediaCapabilities:!1,certLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null}},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},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:H,enableWebVTT:!1,enableIMSC1:!1,enableCEA708Captions:!1,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:void 0,subtitleTrackController:void 0,timelineController:void 0,audioStreamController:void 0,audioTrackController:void 0,emeController:void 0,cmcdController:void 0,contentSteeringController:gr});function kr(e){return e&&"object"==typeof e?Array.isArray(e)?e.map(kr):Object.keys(e).reduce((function(t,r){return t[r]=kr(e[r]),t}),{}):e}function _r(e){var t=e.loader;t!==Lr&&t!==Er?(k.log("[config]: Custom loader detected, cannot enable progressive streaming"),e.progressive=!1):function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(e){}return!1}()&&(e.loader=Lr,e.progressive=!0,e.enableSoftwareAES=!0,k.log("[config]: Progressive streaming enabled, using FetchLoader"))}var xr=function(e){function t(t,r){var i;return(i=e.call(this,t,"[level-controller]")||this)._levels=[],i._firstLevel=-1,i._maxAutoLevel=-1,i._startLevel=void 0,i.currentLevel=null,i.currentLevelIndex=-1,i.manualLevelIndex=-1,i.steering=void 0,i.onParsedComplete=void 0,i.steering=r,i._registerListeners(),i}l(t,e);var r=t.prototype;return r._registerListeners=function(){var e=this.hls;e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(E.LEVEL_LOADED,this.onLevelLoaded,this),e.on(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(E.FRAG_BUFFERED,this.onFragBuffered,this),e.on(E.ERROR,this.onError,this)},r._unregisterListeners=function(){var e=this.hls;e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(E.LEVEL_LOADED,this.onLevelLoaded,this),e.off(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(E.FRAG_BUFFERED,this.onFragBuffered,this),e.off(E.ERROR,this.onError,this)},r.destroy=function(){this._unregisterListeners(),this.steering=null,this.resetLevels(),e.prototype.destroy.call(this)},r.stopLoad=function(){this._levels.forEach((function(e){e.loadError=0,e.fragmentError=0})),e.prototype.stopLoad.call(this)},r.resetLevels=function(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1},r.onManifestLoading=function(e,t){this.resetLevels()},r.onManifestLoaded=function(e,t){var r=this.hls.config.preferManagedMediaSource,i=[],a={},n={},s=!1,o=!1,l=!1;t.levels.forEach((function(e){var t,u,d=e.attrs,h=e.audioCodec,f=e.videoCodec;-1!==(null==(t=h)?void 0:t.indexOf("mp4a.40.34"))&&(Ar||(Ar=/chrome|firefox/i.test(navigator.userAgent)),Ar&&(e.audioCodec=h=void 0)),h&&(e.audioCodec=h=Ge(h,r)),0===(null==(u=f)?void 0:u.indexOf("avc1"))&&(f=e.videoCodec=function(e){for(var t=e.split(","),r=0;r<t.length;r++){var i=t[r].split(".");if(i.length>2){var a=i.shift()+".";a+=parseInt(i.shift()).toString(16),a+=("000"+parseInt(i.shift()).toString(16)).slice(-4),t[r]=a}}return t.join(",")}(f));var c=e.width,v=e.height,g=e.unknownCodecs;if(s||(s=!(!c||!v)),o||(o=!!f),l||(l=!!h),!(null!=g&&g.length||h&&!Pe(h,"audio",r)||f&&!Pe(f,"video",r))){var m=d.CODECS,p=d["FRAME-RATE"],y=d["HDCP-LEVEL"],E=d["PATHWAY-ID"],T=d.RESOLUTION,S=d["VIDEO-RANGE"],L=(E||".")+"-"+e.bitrate+"-"+T+"-"+p+"-"+m+"-"+S+"-"+y;if(a[L])if(a[L].uri===e.url||e.attrs["PATHWAY-ID"])a[L].addGroupId("audio",d.AUDIO),a[L].addGroupId("text",d.SUBTITLES);else{var R=n[L]+=1;e.attrs["PATHWAY-ID"]=new Array(R+1).join(".");var A=new xt(e);a[L]=A,i.push(A)}else{var b=new xt(e);a[L]=b,n[L]=1,i.push(b)}}})),this.filterAndSortMediaOptions(i,t,s,o,l)},r.filterAndSortMediaOptions=function(e,t,r,i,a){var n=this,s=[],o=[],l=e;if((r||i)&&a&&(l=l.filter((function(e){var t,r=e.videoCodec,i=e.videoRange,a=e.width,n=e.height;return(!!r||!(!a||!n))&&(!!(t=i)&&Rt.indexOf(t)>-1)}))),0!==l.length){if(t.audioTracks){var u=this.hls.config.preferManagedMediaSource;wr(s=t.audioTracks.filter((function(e){return!e.audioCodec||Pe(e.audioCodec,"audio",u)})))}t.subtitles&&wr(o=t.subtitles);var d=l.slice(0);l.sort((function(e,t){if(e.attrs["HDCP-LEVEL"]!==t.attrs["HDCP-LEVEL"])return(e.attrs["HDCP-LEVEL"]||"")>(t.attrs["HDCP-LEVEL"]||"")?1:-1;if(r&&e.height!==t.height)return e.height-t.height;if(e.frameRate!==t.frameRate)return e.frameRate-t.frameRate;if(e.videoRange!==t.videoRange)return Rt.indexOf(e.videoRange)-Rt.indexOf(t.videoRange);if(e.videoCodec!==t.videoCodec){var i=Me(e.videoCodec),a=Me(t.videoCodec);if(i!==a)return a-i}if(e.uri===t.uri&&e.codecSet!==t.codecSet){var n=Ne(e.codecSet),s=Ne(t.codecSet);if(n!==s)return s-n}return e.averageBitrate!==t.averageBitrate?e.averageBitrate-t.averageBitrate:0}));var h=d[0];if(this.steering&&(l=this.steering.filterParsedLevels(l)).length!==d.length)for(var f=0;f<d.length;f++)if(d[f].pathwayId===l[0].pathwayId){h=d[f];break}this._levels=l;for(var c=0;c<l.length;c++)if(l[c]===h){var v;this._firstLevel=c;var g=h.bitrate,m=this.hls.bandwidthEstimate;if(this.log("manifest loaded, "+l.length+" level(s) found, first bitrate: "+g),void 0===(null==(v=this.hls.userConfig)?void 0:v.abrEwmaDefaultEstimate)){var p=Math.min(g,this.hls.config.abrEwmaDefaultEstimateMax);p>m&&m===Dr.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=p)}break}var y=a&&!i,L={levels:l,audioTracks:s,subtitleTracks:o,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:a,video:i,altAudio:!y&&s.some((function(e){return!!e.url}))};this.hls.trigger(E.MANIFEST_PARSED,L),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else Promise.resolve().then((function(){if(n.hls){t.levels.length&&n.warn("One or more CODECS in variant not supported: "+JSON.stringify(t.levels[0].attrs));var e=new Error("no level with compatible codecs found in manifest");n.hls.trigger(E.ERROR,{type:T.MEDIA_ERROR,details:S.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:e,reason:e.message})}}))},r.onError=function(e,t){!t.fatal&&t.context&&t.context.type===rt&&t.context.level===this.level&&this.checkRetry(t)},r.onFragBuffered=function(e,t){var r=t.frag;if(void 0!==r&&r.type===nt){var i=r.elementaryStreams;if(!Object.keys(i).some((function(e){return!!i[e]})))return;var a=this._levels[r.level];null!=a&&a.loadError&&(this.log("Resetting level error count of "+a.loadError+" on frag buffered"),a.loadError=0)}},r.onLevelLoaded=function(e,t){var r,i,a=t.level,n=t.details,s=this._levels[a];if(!s)return this.warn("Invalid level index "+a),void(null!=(i=t.deliveryDirectives)&&i.skip&&(n.deltaUpdateFailed=!0));a===this.currentLevelIndex?(0===s.fragmentError&&(s.loadError=0),this.playlistLoaded(a,t,s.details)):null!=(r=t.deliveryDirectives)&&r.skip&&(n.deltaUpdateFailed=!0)},r.loadPlaylist=function(t){e.prototype.loadPlaylist.call(this);var r=this.currentLevelIndex,i=this.currentLevel;if(i&&this.shouldLoadPlaylist(i)){var a=i.uri;if(t)try{a=t.addDirectives(a)}catch(e){this.warn("Could not construct new URL with HLS Delivery Directives: "+e)}var n=i.attrs["PATHWAY-ID"];this.log("Loading level index "+r+(void 0!==(null==t?void 0:t.msn)?" at sn "+t.msn+" part "+t.part:"")+" with"+(n?" Pathway "+n:"")+" "+a),this.clearTimer(),this.hls.trigger(E.LEVEL_LOADING,{url:a,level:r,pathwayId:i.attrs["PATHWAY-ID"],id:0,deliveryDirectives:t||null})}},r.removeLevel=function(e){var t,r=this,i=this._levels.filter((function(t,i){return i!==e||(r.steering&&r.steering.removeLevel(t),t===r.currentLevel&&(r.currentLevel=null,r.currentLevelIndex=-1,t.details&&t.details.fragments.forEach((function(e){return e.level=-1}))),!1)}));Nt(i),this._levels=i,this.currentLevelIndex>-1&&null!=(t=this.currentLevel)&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.hls.trigger(E.LEVELS_UPDATED,{levels:i})},r.onLevelsUpdated=function(e,t){var r=t.levels;this._levels=r},r.checkMaxAutoUpdated=function(){var e=this.hls,t=e.autoLevelCapping,r=e.maxAutoLevel,i=e.maxHdcpLevel;this._maxAutoLevel!==r&&(this._maxAutoLevel=r,this.hls.trigger(E.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:t,levels:this.levels,maxAutoLevel:r,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:i}))},s(t,[{key:"levels",get:function(){return 0===this._levels.length?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(e){var t=this._levels;if(0!==t.length){if(e<0||e>=t.length){var r=new Error("invalid level idx"),i=e<0;if(this.hls.trigger(E.ERROR,{type:T.OTHER_ERROR,details:S.LEVEL_SWITCH_ERROR,level:e,fatal:i,error:r,reason:r.message}),i)return;e=Math.min(e,t.length-1)}var a=this.currentLevelIndex,n=this.currentLevel,s=n?n.attrs["PATHWAY-ID"]:void 0,o=t[e],l=o.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=o,a!==e||!o.details||!n||s!==l){this.log("Switching to level "+e+" ("+(o.height?o.height+"p ":"")+(o.videoRange?o.videoRange+" ":"")+(o.codecSet?o.codecSet+" ":"")+"@"+o.bitrate+")"+(l?" with Pathway "+l:"")+" from level "+a+(s?" with Pathway "+s:""));var u={level:e,attrs:o.attrs,details:o.details,bitrate:o.bitrate,averageBitrate:o.averageBitrate,maxBitrate:o.maxBitrate,realBitrate:o.realBitrate,width:o.width,height:o.height,codecSet:o.codecSet,audioCodec:o.audioCodec,videoCodec:o.videoCodec,audioGroups:o.audioGroups,subtitleGroups:o.subtitleGroups,loaded:o.loaded,loadError:o.loadError,fragmentError:o.fragmentError,name:o.name,id:o.id,uri:o.uri,url:o.url,urlId:0,audioGroupIds:o.audioGroupIds,textGroupIds:o.textGroupIds};this.hls.trigger(E.LEVEL_SWITCHING,u);var d=o.details;if(!d||d.live){var h=this.switchParams(o.uri,null==n?void 0:n.details,d);this.loadPlaylist(h)}}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(e){this.manualLevelIndex=e,void 0===this._startLevel&&(this._startLevel=e),-1!==e&&(this.level=e)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(e){this._firstLevel=e}},{key:"startLevel",get:function(){if(void 0===this._startLevel){var e=this.hls.config.startLevel;return void 0!==e?e:this.hls.firstAutoLevel}return this._startLevel},set:function(e){this._startLevel=e}},{key:"nextLoadLevel",get:function(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(e){this.level=e,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=e)}}]),t}(tr);function wr(e){var t={};e.forEach((function(e){var r=e.groupId||"";e.id=t[r]=t[r]||0,t[r]++}))}var Cr="NOT_LOADED",Ir="APPENDING",Pr="PARTIAL",Fr="OK",Or=function(){function e(e){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=e,this._registerListeners()}var t=e.prototype;return t._registerListeners=function(){var e=this.hls;e.on(E.BUFFER_APPENDED,this.onBufferAppended,this),e.on(E.FRAG_BUFFERED,this.onFragBuffered,this),e.on(E.FRAG_LOADED,this.onFragLoaded,this)},t._unregisterListeners=function(){var e=this.hls;e.off(E.BUFFER_APPENDED,this.onBufferAppended,this),e.off(E.FRAG_BUFFERED,this.onFragBuffered,this),e.off(E.FRAG_LOADED,this.onFragLoaded,this)},t.destroy=function(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null},t.getAppendedFrag=function(e,t){var r=this.activePartLists[t];if(r)for(var i=r.length;i--;){var a=r[i];if(!a)break;var n=a.end;if(a.start<=e&&null!==n&&e<=n)return a}return this.getBufferedFrag(e,t)},t.getBufferedFrag=function(e,t){for(var r=this.fragments,i=Object.keys(r),a=i.length;a--;){var n=r[i[a]];if((null==n?void 0:n.body.type)===t&&n.buffered){var s=n.body;if(s.start<=e&&e<=s.end)return s}}return null},t.detectEvictedFragments=function(e,t,r,i){var a=this;this.timeRanges&&(this.timeRanges[e]=t);var n=(null==i?void 0:i.fragment.sn)||-1;Object.keys(this.fragments).forEach((function(i){var s=a.fragments[i];if(s&&!(n>=s.body.sn))if(s.buffered||s.loaded){var o=s.range[e];o&&o.time.some((function(e){var r=!a.isTimeBuffered(e.startPTS,e.endPTS,t);return r&&a.removeFragment(s.body),r}))}else s.body.type===r&&a.removeFragment(s.body)}))},t.detectPartialFragments=function(e){var t=this,r=this.timeRanges,i=e.frag,a=e.part;if(r&&"initSegment"!==i.sn){var n=Nr(i),s=this.fragments[n];if(!(!s||s.buffered&&i.gap)){var o=!i.relurl;Object.keys(r).forEach((function(e){var n=i.elementaryStreams[e];if(n){var l=r[e],u=o||!0===n.partial;s.range[e]=t.getBufferedTimes(i,a,u,l)}})),s.loaded=null,Object.keys(s.range).length?(s.buffered=!0,(s.body.endList=i.endList||s.body.endList)&&(this.endListFragments[s.body.type]=s),Mr(s)||this.removeParts(i.sn-1,i.type)):this.removeFragment(s.body)}}},t.removeParts=function(e,t){var r=this.activePartLists[t];r&&(this.activePartLists[t]=r.filter((function(t){return t.fragment.sn>=e})))},t.fragBuffered=function(e,t){var r=Nr(e),i=this.fragments[r];!i&&t&&(i=this.fragments[r]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),i&&(i.loaded=null,i.buffered=!0)},t.getBufferedTimes=function(e,t,r,i){for(var a={time:[],partial:r},n=e.start,s=e.end,o=e.minEndPTS||s,l=e.maxStartPTS||n,u=0;u<i.length;u++){var d=i.start(u)-this.bufferPadding,h=i.end(u)+this.bufferPadding;if(l>=d&&o<=h){a.time.push({startPTS:Math.max(n,i.start(u)),endPTS:Math.min(s,i.end(u))});break}if(n<h&&s>d){var f=Math.max(n,i.start(u)),c=Math.min(s,i.end(u));c>f&&(a.partial=!0,a.time.push({startPTS:f,endPTS:c}))}else if(s<=d)break}return a},t.getPartialFragment=function(e){var t,r,i,a=null,n=0,s=this.bufferPadding,o=this.fragments;return Object.keys(o).forEach((function(l){var u=o[l];u&&Mr(u)&&(r=u.body.start-s,i=u.body.end+s,e>=r&&e<=i&&(t=Math.min(e-r,i-e),n<=t&&(a=u.body,n=t)))})),a},t.isEndListAppended=function(e){var t=this.endListFragments[e];return void 0!==t&&(t.buffered||Mr(t))},t.getState=function(e){var t=Nr(e),r=this.fragments[t];return r?r.buffered?Mr(r)?Pr:Fr:Ir:Cr},t.isTimeBuffered=function(e,t,r){for(var i,a,n=0;n<r.length;n++){if(i=r.start(n)-this.bufferPadding,a=r.end(n)+this.bufferPadding,e>=i&&t<=a)return!0;if(t<=i)return!1}return!1},t.onFragLoaded=function(e,t){var r=t.frag,i=t.part;if("initSegment"!==r.sn&&!r.bitrateTest){var a=i?null:t,n=Nr(r);this.fragments[n]={body:r,appendedPTS:null,loaded:a,buffered:!1,range:Object.create(null)}}},t.onBufferAppended=function(e,t){var r=this,i=t.frag,a=t.part,n=t.timeRanges;if("initSegment"!==i.sn){var s=i.type;if(a){var o=this.activePartLists[s];o||(this.activePartLists[s]=o=[]),o.push(a)}this.timeRanges=n,Object.keys(n).forEach((function(e){var t=n[e];r.detectEvictedFragments(e,t,s,a)}))}},t.onFragBuffered=function(e,t){this.detectPartialFragments(t)},t.hasFragment=function(e){var t=Nr(e);return!!this.fragments[t]},t.hasParts=function(e){var t;return!(null==(t=this.activePartLists[e])||!t.length)},t.removeFragmentsInRange=function(e,t,r,i,a){var n=this;i&&!this.hasGaps||Object.keys(this.fragments).forEach((function(s){var o=n.fragments[s];if(o){var l=o.body;l.type!==r||i&&!l.gap||l.start<t&&l.end>e&&(o.buffered||a)&&n.removeFragment(l)}}))},t.removeFragment=function(e){var t=Nr(e);e.stats.loaded=0,e.clearElementaryStreamInfo();var r=this.activePartLists[e.type];if(r){var i=e.sn;this.activePartLists[e.type]=r.filter((function(e){return e.fragment.sn!==i}))}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]},t.removeAllFragments=function(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1},e}();function Mr(e){var t,r,i;return e.buffered&&(e.body.gap||(null==(t=e.range.video)?void 0:t.partial)||(null==(r=e.range.audio)?void 0:r.partial)||(null==(i=e.range.audiovideo)?void 0:i.partial))}function Nr(e){return e.type+"_"+e.level+"_"+e.sn}var Br=Math.pow(2,17),Ur=function(){function e(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}var t=e.prototype;return t.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},t.abort=function(){this.loader&&this.loader.abort()},t.load=function(e,t){var r=this,a=e.url;if(!a)return Promise.reject(new Vr({type:T.NETWORK_ERROR,details:S.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error("Fragment does not have a "+(a?"part list":"url")),networkDetails:null}));this.abort();var n=this.config,s=n.fLoader,o=n.loader;return new Promise((function(l,u){if(r.loader&&r.loader.destroy(),e.gap){if(e.tagList.some((function(e){return"GAP"===e[0]})))return void u(Hr(e));e.gap=!1}var d=r.loader=e.loader=s?new s(n):new o(n),h=Gr(e),f=Ht(n.fragLoadPolicy.default),c={loadPolicy:f,timeout:f.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===e.sn?1/0:Br};e.stats=d.stats,d.load(h,c,{onSuccess:function(t,i,a,n){r.resetLoader(e,d);var s=t.data;a.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(s.slice(0,16)),s=s.slice(16)),l({frag:e,part:null,payload:s,networkDetails:n})},onError:function(t,n,s,o){r.resetLoader(e,d),u(new Vr({type:T.NETWORK_ERROR,details:S.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:i({url:a,data:void 0},t),error:new Error("HTTP Error "+t.code+" "+t.text),networkDetails:s,stats:o}))},onAbort:function(t,i,a){r.resetLoader(e,d),u(new Vr({type:T.NETWORK_ERROR,details:S.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:a,stats:t}))},onTimeout:function(t,i,a){r.resetLoader(e,d),u(new Vr({type:T.NETWORK_ERROR,details:S.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error("Timeout after "+c.timeout+"ms"),networkDetails:a,stats:t}))},onProgress:function(r,i,a,n){t&&t({frag:e,part:null,payload:a,networkDetails:n})}})}))},t.loadPart=function(e,t,r){var a=this;this.abort();var n=this.config,s=n.fLoader,o=n.loader;return new Promise((function(l,u){if(a.loader&&a.loader.destroy(),e.gap||t.gap)u(Hr(e,t));else{var d=a.loader=e.loader=s?new s(n):new o(n),h=Gr(e,t),f=Ht(n.fragLoadPolicy.default),c={loadPolicy:f,timeout:f.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:Br};t.stats=d.stats,d.load(h,c,{onSuccess:function(i,n,s,o){a.resetLoader(e,d),a.updateStatsFromPart(e,t);var u={frag:e,part:t,payload:i.data,networkDetails:o};r(u),l(u)},onError:function(r,n,s,o){a.resetLoader(e,d),u(new Vr({type:T.NETWORK_ERROR,details:S.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:i({url:h.url,data:void 0},r),error:new Error("HTTP Error "+r.code+" "+r.text),networkDetails:s,stats:o}))},onAbort:function(r,i,n){e.stats.aborted=t.stats.aborted,a.resetLoader(e,d),u(new Vr({type:T.NETWORK_ERROR,details:S.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:n,stats:r}))},onTimeout:function(r,i,n){a.resetLoader(e,d),u(new Vr({type:T.NETWORK_ERROR,details:S.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error("Timeout after "+c.timeout+"ms"),networkDetails:n,stats:r}))}})}}))},t.updateStatsFromPart=function(e,t){var r=e.stats,i=t.stats,a=i.total;if(r.loaded+=i.loaded,a){var n=Math.round(e.duration/t.duration),s=Math.min(Math.round(r.loaded/a),n),o=(n-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},t.resetLoader=function(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()},e}();function Gr(e,t){void 0===t&&(t=null);var r=t||e,i={frag:e,part:t,responseType:"arraybuffer",url:r.url,headers:{},rangeStart:0,rangeEnd:0},a=r.byteRangeStartOffset,n=r.byteRangeEndOffset;if(m(a)&&m(n)){var s,o=a,l=n;if("initSegment"===e.sn&&"AES-128"===(null==(s=e.decryptdata)?void 0:s.method)){var u=n-a;u%16&&(l=n+(16-u%16)),0!==a&&(i.resetIV=!0,o=a-16)}i.rangeStart=o,i.rangeEnd=l}return i}function Hr(e,t){var r=new Error("GAP "+(e.gap?"tag":"attribute")+" found"),i={type:T.MEDIA_ERROR,details:S.FRAG_GAP,fatal:!1,frag:e,error:r,networkDetails:null};return t&&(i.part=t),(t||e).stats.aborted=!0,new Vr(i)}var Vr=function(e){function t(t){var r;return(r=e.call(this,t.error.message)||this).data=void 0,r.data=t,r}return l(t,e),t}(f(Error)),Kr=function(){function e(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}var t=e.prototype;return t.abort=function(e){for(var t in this.keyUriToKeyInfo){var r=this.keyUriToKeyInfo[t].loader;if(r){var i;if(e&&e!==(null==(i=r.context)?void 0:i.frag.type))return;r.abort()}}},t.detach=function(){for(var e in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}},t.destroy=function(){for(var e in this.detach(),this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}},t.createKeyLoadError=function(e,t,r,i,a){return void 0===t&&(t=S.KEY_LOAD_ERROR),new Vr({type:T.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:a,error:r,networkDetails:i})},t.loadClear=function(e,t){var r=this;if(this.emeController&&this.config.emeEnabled)for(var i=e.sn,a=e.cc,n=function(){var e=t[s];if(a<=e.cc&&("initSegment"===i||"initSegment"===e.sn||i<e.sn))return r.emeController.selectKeySystemFormat(e).then((function(t){e.setKeyFormat(t)})),1},s=0;s<t.length&&!n();s++);},t.load=function(e){var t=this;return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then((function(r){return t.loadInternal(e,r)})):this.loadInternal(e)},t.loadInternal=function(e,t){var r,i;t&&e.setKeyFormat(t);var a=e.decryptdata;if(!a){var n=new Error(t?"Expected frag.decryptdata to be defined after setting format "+t:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(e,S.KEY_LOAD_ERROR,n))}var s=a.uri;if(!s)return Promise.reject(this.createKeyLoadError(e,S.KEY_LOAD_ERROR,new Error('Invalid key URI: "'+s+'"')));var o,l=this.keyUriToKeyInfo[s];if(null!=(r=l)&&r.decryptdata.key)return a.key=l.decryptdata.key,Promise.resolve({frag:e,keyInfo:l});if(null!=(i=l)&&i.keyLoadPromise)switch(null==(o=l.mediaKeySessionContext)?void 0:o.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return l.keyLoadPromise.then((function(t){return a.key=t.keyInfo.decryptdata.key,{frag:e,keyInfo:l}}))}switch(l=this.keyUriToKeyInfo[s]={decryptdata:a,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},a.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return"identity"===a.keyFormat?this.loadKeyHTTP(l,e):this.loadKeyEME(l,e);case"AES-128":return this.loadKeyHTTP(l,e);default:return Promise.reject(this.createKeyLoadError(e,S.KEY_LOAD_ERROR,new Error('Key supplied with unsupported METHOD: "'+a.method+'"')))}},t.loadKeyEME=function(e,t){var r={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){var i=this.emeController.loadKey(r);if(i)return(e.keyLoadPromise=i.then((function(t){return e.mediaKeySessionContext=t,r}))).catch((function(t){throw e.keyLoadPromise=null,t}))}return Promise.resolve(r)},t.loadKeyHTTP=function(e,t){var r=this,a=this.config,n=new(0,a.loader)(a);return t.keyLoader=e.loader=n,e.keyLoadPromise=new Promise((function(s,o){var l={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},u=a.keyLoadPolicy.default,d={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},h={onSuccess:function(e,t,i,a){var n=i.frag,l=i.keyInfo,u=i.url;if(!n.decryptdata||l!==r.keyUriToKeyInfo[u])return o(r.createKeyLoadError(n,S.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),a));l.decryptdata.key=n.decryptdata.key=new Uint8Array(e.data),n.keyLoader=null,l.loader=null,s({frag:n,keyInfo:l})},onError:function(e,a,n,s){r.resetLoader(a),o(r.createKeyLoadError(t,S.KEY_LOAD_ERROR,new Error("HTTP Error "+e.code+" loading key "+e.text),n,i({url:l.url,data:void 0},e)))},onTimeout:function(e,i,a){r.resetLoader(i),o(r.createKeyLoadError(t,S.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),a))},onAbort:function(e,i,a){r.resetLoader(i),o(r.createKeyLoadError(t,S.INTERNAL_ABORTED,new Error("key loading aborted"),a))}};n.load(l,d,h)}))},t.resetLoader=function(e){var t=e.frag,r=e.keyInfo,i=e.url,a=r.loader;t.keyLoader===a&&(t.keyLoader=null,r.loader=null),delete this.keyUriToKeyInfo[i],a&&a.destroy()},e}(),jr=function(){function e(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var t=e.prototype;return t.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},t.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},t.onHandlerDestroyed=function(){},t.hasInterval=function(){return!!this._tickInterval},t.hasNextTick=function(){return!!this._tickTimer},t.setInterval=function(e){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)},t.clearInterval=function(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)},t.clearNextTick=function(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)},t.tick=function(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},t.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},t.doTick=function(){},e}(),Wr=function(e,t,r,i,a,n){void 0===i&&(i=0),void 0===a&&(a=-1),void 0===n&&(n=!1),this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing={start:0,executeStart:0,executeEnd:0,end:0},this.buffering={audio:{start:0,executeStart:0,executeEnd:0,end:0},video:{start:0,executeStart:0,executeEnd:0,end:0},audiovideo:{start:0,executeStart:0,executeEnd:0,end:0}},this.level=e,this.sn=t,this.id=r,this.size=i,this.part=a,this.partial=n};function Yr(e,t){for(var r=0,i=e.length;r<i;r++){var a;if((null==(a=e[r])?void 0:a.cc)===t)return e[r]}return null}function qr(e,t){if(e){var r=e.start+t;e.start=e.startPTS=r,e.endPTS=r+e.duration}}function zr(e,t){for(var r=t.fragments,i=0,a=r.length;i<a;i++)qr(r[i],e);t.fragmentHint&&qr(t.fragmentHint,e),t.alignedSliding=!0}function Xr(e,t,r){t&&(function(e,t,r){if(function(e,t,r){return!(!t||!(r.endCC>r.startCC||e&&e.cc<r.startCC))}(e,r,t)){var i=function(e,t){var r=e.fragments,i=t.fragments;if(i.length&&r.length){var a=Yr(r,i[0].cc);if(a&&(!a||a.startPTS))return a;k.log("No frag in previous level to align on")}else k.log("No fragments to align")}(r,t);i&&m(i.start)&&(k.log("Adjusting PTS using last level due to CC increase within current level "+t.url),zr(i.start,t))}}(e,r,t),!r.alignedSliding&&t&&function(e,t){if(e.hasProgramDateTime&&t.hasProgramDateTime){var r=e.fragments,i=t.fragments;if(r.length&&i.length){var a,n,s=Math.min(t.endCC,e.endCC);t.startCC<s&&e.startCC<s&&(a=Yr(i,s),n=Yr(r,s)),a&&n||(n=Yr(r,(a=i[Math.floor(i.length/2)]).cc)||r[Math.floor(r.length/2)]);var o=a.programDateTime,l=n.programDateTime;o&&l&&zr((l-o)/1e3-(n.start-a.start),e)}}}(r,t),r.alignedSliding||!t||r.skippedSegments||Ft(t,r))}var Qr=function(){function e(e,t){this.subtle=void 0,this.aesIV=void 0,this.subtle=e,this.aesIV=t}return e.prototype.decrypt=function(e,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e)},e}(),Jr=function(){function e(e,t){this.subtle=void 0,this.key=void 0,this.subtle=e,this.key=t}return e.prototype.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},e}();var $r=function(){function e(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}var t=e.prototype;return t.uint8ArrayToUint32Array_=function(e){for(var t=new DataView(e),r=new Uint32Array(4),i=0;i<4;i++)r[i]=t.getUint32(4*i);return r},t.initTable=function(){var e=this.sBox,t=this.invSBox,r=this.subMix,i=r[0],a=r[1],n=r[2],s=r[3],o=this.invSubMix,l=o[0],u=o[1],d=o[2],h=o[3],f=new Uint32Array(256),c=0,v=0,g=0;for(g=0;g<256;g++)f[g]=g<128?g<<1:g<<1^283;for(g=0;g<256;g++){var m=v^v<<1^v<<2^v<<3^v<<4;m=m>>>8^255&m^99,e[c]=m,t[m]=c;var p=f[c],y=f[p],E=f[y],T=257*f[m]^16843008*m;i[c]=T<<24|T>>>8,a[c]=T<<16|T>>>16,n[c]=T<<8|T>>>24,s[c]=T,T=16843009*E^65537*y^257*p^16843008*c,l[m]=T<<24|T>>>8,u[m]=T<<16|T>>>16,d[m]=T<<8|T>>>24,h[m]=T,c?(c=p^f[f[f[E^p]]],v^=f[f[v]]):c=v=1}},t.expandKey=function(e){for(var t=this.uint8ArrayToUint32Array_(e),r=!0,i=0;i<t.length&&r;)r=t[i]===this.key[i],i++;if(!r){this.key=t;var a=this.keySize=t.length;if(4!==a&&6!==a&&8!==a)throw new Error("Invalid aes key size="+a);var n,s,o,l,u=this.ksRows=4*(a+6+1),d=this.keySchedule=new Uint32Array(u),h=this.invKeySchedule=new Uint32Array(u),f=this.sBox,c=this.rcon,v=this.invSubMix,g=v[0],m=v[1],p=v[2],y=v[3];for(n=0;n<u;n++)n<a?o=d[n]=t[n]:(l=o,n%a==0?(l=f[(l=l<<8|l>>>24)>>>24]<<24|f[l>>>16&255]<<16|f[l>>>8&255]<<8|f[255&l],l^=c[n/a|0]<<24):a>6&&n%a==4&&(l=f[l>>>24]<<24|f[l>>>16&255]<<16|f[l>>>8&255]<<8|f[255&l]),d[n]=o=(d[n-a]^l)>>>0);for(s=0;s<u;s++)n=u-s,l=3&s?d[n]:d[n-4],h[s]=s<4||n<=4?l:g[f[l>>>24]]^m[f[l>>>16&255]]^p[f[l>>>8&255]]^y[f[255&l]],h[s]=h[s]>>>0}},t.networkToHostOrderSwap=function(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24},t.decrypt=function(e,t,r){for(var i,a,n,s,o,l,u,d,h,f,c,v,g,m,p=this.keySize+6,y=this.invKeySchedule,E=this.invSBox,T=this.invSubMix,S=T[0],L=T[1],R=T[2],A=T[3],b=this.uint8ArrayToUint32Array_(r),D=b[0],k=b[1],_=b[2],x=b[3],w=new Int32Array(e),C=new Int32Array(w.length),I=this.networkToHostOrderSwap;t<w.length;){for(h=I(w[t]),f=I(w[t+1]),c=I(w[t+2]),v=I(w[t+3]),o=h^y[0],l=v^y[1],u=c^y[2],d=f^y[3],g=4,m=1;m<p;m++)i=S[o>>>24]^L[l>>16&255]^R[u>>8&255]^A[255&d]^y[g],a=S[l>>>24]^L[u>>16&255]^R[d>>8&255]^A[255&o]^y[g+1],n=S[u>>>24]^L[d>>16&255]^R[o>>8&255]^A[255&l]^y[g+2],s=S[d>>>24]^L[o>>16&255]^R[l>>8&255]^A[255&u]^y[g+3],o=i,l=a,u=n,d=s,g+=4;i=E[o>>>24]<<24^E[l>>16&255]<<16^E[u>>8&255]<<8^E[255&d]^y[g],a=E[l>>>24]<<24^E[u>>16&255]<<16^E[d>>8&255]<<8^E[255&o]^y[g+1],n=E[u>>>24]<<24^E[d>>16&255]<<16^E[o>>8&255]<<8^E[255&l]^y[g+2],s=E[d>>>24]<<24^E[o>>16&255]<<16^E[l>>8&255]<<8^E[255&u]^y[g+3],C[t]=I(i^D),C[t+1]=I(s^k),C[t+2]=I(n^_),C[t+3]=I(a^x),D=h,k=f,_=c,x=v,t+=4}return C.buffer},e}(),Zr=function(){function e(e,t){var r=(void 0===t?{}:t).removePKCS7Padding,i=void 0===r||r;if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.useSoftware=e.enableSoftwareAES,this.removePKCS7Padding=i,i)try{var a=self.crypto;a&&(this.subtle=a.subtle||a.webkitSubtle)}catch(e){}this.useSoftware=!this.subtle}var t=e.prototype;return t.destroy=function(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null},t.isSync=function(){return this.useSoftware},t.flush=function(){var e=this.currentResult,t=this.remainderData;if(!e||t)return this.reset(),null;var r,i,a,n=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?(i=(r=n).byteLength,(a=i&&new DataView(r.buffer).getUint8(i-1))?V(r,0,i-a):r):n},t.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},t.decrypt=function(e,t,r){var i=this;return this.useSoftware?new Promise((function(a,n){i.softwareDecrypt(new Uint8Array(e),t,r);var s=i.flush();s?a(s.buffer):n(new Error("[softwareDecrypt] Failed to decrypt data"))})):this.webCryptoDecrypt(new Uint8Array(e),t,r)},t.softwareDecrypt=function(e,t,r){var i=this.currentIV,a=this.currentResult,n=this.remainderData;this.logOnce("JS AES decrypt"),n&&(e=be(n,e),this.remainderData=null);var s=this.getValidChunk(e);if(!s.length)return null;i&&(r=i);var o=this.softwareDecrypter;o||(o=this.softwareDecrypter=new $r),o.expandKey(t);var l=a;return this.currentResult=o.decrypt(s.buffer,0,r),this.currentIV=V(s,-16).buffer,l||null},t.webCryptoDecrypt=function(e,t,r){var i=this;if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,t,r));this.key=t,this.fastAesKey=new Jr(this.subtle,t)}return this.fastAesKey.expandKey().then((function(t){return i.subtle?(i.logOnce("WebCrypto AES decrypt"),new Qr(i.subtle,new Uint8Array(r)).decrypt(e.buffer,t)):Promise.reject(new Error("web crypto not initialized"))})).catch((function(a){return k.warn("[decrypter]: WebCrypto Error, disable WebCrypto API, "+a.name+": "+a.message),i.onWebCryptoError(e,t,r)}))},t.onWebCryptoError=function(e,t,r){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,r);var i=this.flush();if(i)return i.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")},t.getValidChunk=function(e){var t=e,r=e.length-e.length%16;return r!==e.length&&(t=V(e,0,r),this.remainderData=V(e,r)),t},t.logOnce=function(e){this.logEnabled&&(k.log("[decrypter]: "+e),this.logEnabled=!1)},e}(),ei=function(e){for(var t="",r=e.length,i=0;i<r;i++)t+="["+e.start(i).toFixed(3)+"-"+e.end(i).toFixed(3)+"]";return t},ti="STOPPED",ri="IDLE",ii="KEY_LOADING",ai="FRAG_LOADING",ni="FRAG_LOADING_WAITING_RETRY",si="PARSING",oi="PARSED",li="ENDED",ui="ERROR",di="WAITING_LEVEL",hi=function(e){function t(t,r,i,a,n){var s;return(s=e.call(this)||this).hls=void 0,s.fragPrevious=null,s.fragCurrent=null,s.fragmentTracker=void 0,s.transmuxer=null,s._state=ti,s.playlistType=void 0,s.media=null,s.mediaBuffer=null,s.config=void 0,s.bitrateTest=!1,s.lastCurrentTime=0,s.nextLoadPosition=0,s.startPosition=0,s.startTimeOffset=null,s.loadedmetadata=!1,s.retryDate=0,s.levels=null,s.fragmentLoader=void 0,s.keyLoader=void 0,s.levelLastLoaded=null,s.startFragRequested=!1,s.decrypter=void 0,s.initPTS=[],s.onvseeking=null,s.onvended=null,s.logPrefix="",s.log=void 0,s.warn=void 0,s.playlistType=n,s.logPrefix=a,s.log=k.log.bind(k,a+":"),s.warn=k.warn.bind(k,a+":"),s.hls=t,s.fragmentLoader=new Ur(t.config),s.keyLoader=i,s.fragmentTracker=r,s.config=t.config,s.decrypter=new Zr(t.config),t.on(E.MANIFEST_LOADED,s.onManifestLoaded,function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(s)),s}l(t,e);var r=t.prototype;return r.doTick=function(){this.onTickEnd()},r.onTickEnd=function(){},r.startLoad=function(e){},r.stopLoad=function(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);var e=this.fragCurrent;null!=e&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=ti},r._streamEnded=function(e,t){if(t.live||e.nextStart||!e.end||!this.media)return!1;var r=t.partList;if(null!=r&&r.length){var i=r[r.length-1];return lr.isBuffered(this.media,i.start+i.duration/2)}var a=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(a)},r.getLevelDetails=function(){var e;if(this.levels&&null!==this.levelLastLoaded)return null==(e=this.levelLastLoaded)?void 0:e.details},r.onMediaAttached=function(e,t){var r=this.media=this.mediaBuffer=t.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),r.addEventListener("seeking",this.onvseeking),r.addEventListener("ended",this.onvended);var i=this.config;this.levels&&i.autoStartLoad&&this.state===ti&&this.startLoad(i.startPosition)},r.onMediaDetaching=function(){var e=this.media;null!=e&&e.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),e&&this.onvseeking&&this.onvended&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},r.onMediaSeeking=function(){var e=this.config,t=this.fragCurrent,r=this.media,i=this.mediaBuffer,a=this.state,n=r?r.currentTime:0,s=lr.bufferInfo(i||r,n,e.maxBufferHole);if(this.log("media seeking to "+(m(n)?n.toFixed(3):n)+", state: "+a),this.state===li)this.resetLoadingState();else if(t){var o=e.maxFragLookUpTolerance,l=t.start-o,u=t.start+t.duration+o;if(!s.len||u<s.start||l>s.end){var d=n>u;(n<l||d)&&(d&&t.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),t.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}r&&(this.fragmentTracker.removeFragmentsInRange(n,1/0,this.playlistType,!0),this.lastCurrentTime=n),this.loadedmetadata||s.len||(this.nextLoadPosition=this.startPosition=n),this.tickImmediate()},r.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},r.onManifestLoaded=function(e,t){this.startTimeOffset=t.startTimeOffset,this.initPTS=[]},r.onHandlerDestroying=function(){this.hls.off(E.MANIFEST_LOADED,this.onManifestLoaded,this),this.stopLoad(),e.prototype.onHandlerDestroying.call(this),this.hls=null},r.onHandlerDestroyed=function(){this.state=ti,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,e.prototype.onHandlerDestroyed.call(this)},r.loadFragment=function(e,t,r){this._loadFragForPlayback(e,t,r)},r._loadFragForPlayback=function(e,t,r){var i=this;this._doFragLoad(e,t,r,(function(t){if(i.fragContextChanged(e))return i.warn("Fragment "+e.sn+(t.part?" p: "+t.part.index:"")+" of level "+e.level+" was dropped during download."),void i.fragmentTracker.removeFragment(e);e.stats.chunkCount++,i._handleFragmentLoadProgress(t)})).then((function(t){if(t){var r=i.state;i.fragContextChanged(e)?(r===ai||!i.fragCurrent&&r===si)&&(i.fragmentTracker.removeFragment(e),i.state=ri):("payload"in t&&(i.log("Loaded fragment "+e.sn+" of level "+e.level),i.hls.trigger(E.FRAG_LOADED,t)),i._handleFragmentLoadComplete(t))}})).catch((function(t){i.state!==ti&&i.state!==ui&&(i.warn("Frag error: "+((null==t?void 0:t.message)||t)),i.resetFragmentLoading(e))}))},r.clearTrackerIfNeeded=function(e){var t,r=this.fragmentTracker;if(r.getState(e)===Ir){var i=e.type,a=this.getFwdBufferInfo(this.mediaBuffer,i),n=Math.max(e.duration,a?a.len:this.config.maxBufferLength),s=this.backtrackFragment;(1==(s?e.sn-s.sn:0)||this.reduceMaxBufferLength(n,e.duration))&&r.removeFragment(e)}else 0===(null==(t=this.mediaBuffer)?void 0:t.buffered.length)?r.removeAllFragments():r.hasParts(e.type)&&(r.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),r.getState(e)===Pr&&r.removeFragment(e))},r.checkLiveUpdate=function(e){if(e.updated&&!e.live){var t=e.fragments[e.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type})}e.fragments[0]||(e.deltaUpdateFailed=!0)},r.flushMainBuffer=function(e,t,r){if(void 0===r&&(r=null),e-t){var i={startOffset:e,endOffset:t,type:r};this.hls.trigger(E.BUFFER_FLUSHING,i)}},r._loadInitSegment=function(e,t){var r=this;this._doFragLoad(e,t).then((function(t){if(!t||r.fragContextChanged(e)||!r.levels)throw new Error("init load aborted");return t})).then((function(t){var i=r.hls,a=t.payload,n=e.decryptdata;if(a&&a.byteLength>0&&null!=n&&n.key&&n.iv&&"AES-128"===n.method){var s=self.performance.now();return r.decrypter.decrypt(new Uint8Array(a),n.key.buffer,n.iv.buffer).catch((function(t){throw i.trigger(E.ERROR,{type:T.MEDIA_ERROR,details:S.FRAG_DECRYPT_ERROR,fatal:!1,error:t,reason:t.message,frag:e}),t})).then((function(a){var n=self.performance.now();return i.trigger(E.FRAG_DECRYPTED,{frag:e,payload:a,stats:{tstart:s,tdecrypt:n}}),t.payload=a,r.completeInitSegmentLoad(t)}))}return r.completeInitSegmentLoad(t)})).catch((function(t){r.state!==ti&&r.state!==ui&&(r.warn(t),r.resetFragmentLoading(e))}))},r.completeInitSegmentLoad=function(e){if(!this.levels)throw new Error("init load aborted, missing levels");var t=e.frag.stats;this.state=ri,e.frag.data=new Uint8Array(e.payload),t.parsing.start=t.buffering.start=self.performance.now(),t.parsing.end=t.buffering.end=self.performance.now(),this.tick()},r.fragContextChanged=function(e){var t=this.fragCurrent;return!e||!t||e.sn!==t.sn||e.level!==t.level},r.fragBufferedComplete=function(e,t){var r,i,a,n,s=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log("Buffered "+e.type+" sn: "+e.sn+(t?" part: "+t.index:"")+" of "+(this.playlistType===nt?"level":"track")+" "+e.level+" (frag:["+(null!=(r=e.startPTS)?r:NaN).toFixed(3)+"-"+(null!=(i=e.endPTS)?i:NaN).toFixed(3)+"] > buffer:"+(s?ei(lr.getBuffered(s)):"(detached)")+")"),"initSegment"!==e.sn){var o;if(e.type!==ot){var l=e.elementaryStreams;if(!Object.keys(l).some((function(e){return!!l[e]})))return void(this.state=ri)}var u=null==(o=this.levels)?void 0:o[e.level];null!=u&&u.fragmentError&&(this.log("Resetting level fragment error count of "+u.fragmentError+" on frag buffered"),u.fragmentError=0)}this.state=ri,s&&(!this.loadedmetadata&&e.type==nt&&s.buffered.length&&(null==(a=this.fragCurrent)?void 0:a.sn)===(null==(n=this.fragPrevious)?void 0:n.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},r.seekToStartPos=function(){},r._handleFragmentLoadComplete=function(e){var t=this.transmuxer;if(t){var r=e.frag,i=e.part,a=e.partsLoaded,n=!a||0===a.length||a.some((function(e){return!e})),s=new Wr(r.level,r.sn,r.stats.chunkCount+1,0,i?i.index:-1,!n);t.flush(s)}},r._handleFragmentLoadProgress=function(e){},r._doFragLoad=function(e,t,r,i){var a,n=this;void 0===r&&(r=null);var s=null==t?void 0:t.details;if(!this.levels||!s)throw new Error("frag load aborted, missing level"+(s?"":" detail")+"s");var o=null;if(!e.encrypted||null!=(a=e.decryptdata)&&a.key?!e.encrypted&&s.encryptedFragments.length&&this.keyLoader.loadClear(e,s.encryptedFragments):(this.log("Loading key for "+e.sn+" of ["+s.startSN+"-"+s.endSN+"], "+("[stream-controller]"===this.logPrefix?"level":"track")+" "+e.level),this.state=ii,this.fragCurrent=e,o=this.keyLoader.load(e).then((function(e){if(!n.fragContextChanged(e.frag))return n.hls.trigger(E.KEY_LOADED,e),n.state===ii&&(n.state=ri),e})),this.hls.trigger(E.KEY_LOADING,{frag:e}),null===this.fragCurrent&&(o=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))),r=Math.max(e.start,r||0),this.config.lowLatencyMode&&"initSegment"!==e.sn){var l=s.partList;if(l&&i){r>e.end&&s.fragmentHint&&(e=s.fragmentHint);var u=this.getNextPart(l,e,r);if(u>-1){var d,h=l[u];return this.log("Loading part sn: "+e.sn+" p: "+h.index+" cc: "+e.cc+" of playlist ["+s.startSN+"-"+s.endSN+"] parts [0-"+u+"-"+(l.length-1)+"] "+("[stream-controller]"===this.logPrefix?"level":"track")+": "+e.level+", target: "+parseFloat(r.toFixed(3))),this.nextLoadPosition=h.start+h.duration,this.state=ai,d=o?o.then((function(r){return!r||n.fragContextChanged(r.frag)?null:n.doFragPartsLoad(e,h,t,i)})).catch((function(e){return n.handleFragLoadError(e)})):this.doFragPartsLoad(e,h,t,i).catch((function(e){return n.handleFragLoadError(e)})),this.hls.trigger(E.FRAG_LOADING,{frag:e,part:h,targetBufferTime:r}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):d}if(!e.url||this.loadedEndOfParts(l,r))return Promise.resolve(null)}}this.log("Loading fragment "+e.sn+" cc: "+e.cc+" "+(s?"of ["+s.startSN+"-"+s.endSN+"] ":"")+("[stream-controller]"===this.logPrefix?"level":"track")+": "+e.level+", target: "+parseFloat(r.toFixed(3))),m(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=ai;var f,c=this.config.progressive;return f=c&&o?o.then((function(t){return!t||n.fragContextChanged(null==t?void 0:t.frag)?null:n.fragmentLoader.load(e,i)})).catch((function(e){return n.handleFragLoadError(e)})):Promise.all([this.fragmentLoader.load(e,c?i:void 0),o]).then((function(e){var t=e[0];return!c&&t&&i&&i(t),t})).catch((function(e){return n.handleFragLoadError(e)})),this.hls.trigger(E.FRAG_LOADING,{frag:e,targetBufferTime:r}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):f},r.doFragPartsLoad=function(e,t,r,i){var a=this;return new Promise((function(n,s){var o,l=[],u=null==(o=r.details)?void 0:o.partList;!function t(o){a.fragmentLoader.loadPart(e,o,i).then((function(i){l[o.index]=i;var s=i.part;a.hls.trigger(E.FRAG_LOADED,i);var d=Ot(r,e.sn,o.index+1)||Mt(u,e.sn,o.index+1);if(!d)return n({frag:e,part:s,partsLoaded:l});t(d)})).catch(s)}(t)}))},r.handleFragLoadError=function(e){if("data"in e){var t=e.data;e.data&&t.details===S.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(E.ERROR,t)}else this.hls.trigger(E.ERROR,{type:T.OTHER_ERROR,details:S.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null},r._handleTransmuxerFlush=function(e){var t=this.getCurrentContext(e);if(t&&this.state===si){var r=t.frag,i=t.part,a=t.level,n=self.performance.now();r.stats.parsing.end=n,i&&(i.stats.parsing.end=n),this.updateLevelTiming(r,i,a,e.partial)}else this.fragCurrent||this.state===ti||this.state===ui||(this.state=ri)},r.getCurrentContext=function(e){var t=this.levels,r=this.fragCurrent,i=e.level,a=e.sn,n=e.part;if(null==t||!t[i])return this.warn("Levels object was unset while buffering fragment "+a+" of level "+i+". The current chunk will not be buffered."),null;var s=t[i],o=n>-1?Ot(s,a,n):null,l=o?o.fragment:function(e,t,r){if(null==e||!e.details)return null;var i=e.details,a=i.fragments[t-i.startSN];return a||((a=i.fragmentHint)&&a.sn===t?a:t<i.startSN&&r&&r.sn===t?r:null)}(s,a,r);return l?(r&&r!==l&&(l.stats=r.stats),{frag:l,part:o,level:s}):null},r.bufferFragmentData=function(e,t,r,i,a){var n;if(e&&this.state===si){var s=e.data1,o=e.data2,l=s;if(s&&o&&(l=be(s,o)),null!=(n=l)&&n.length){var u={type:e.type,frag:t,part:r,chunkMeta:i,parent:t.type,data:l};if(this.hls.trigger(E.BUFFER_APPENDING,u),e.dropped&&e.independent&&!r){if(a)return;this.flushBufferGap(t)}}}},r.flushBufferGap=function(e){var t=this.media;if(t)if(lr.isBuffered(t,t.currentTime)){var r=t.currentTime,i=lr.bufferInfo(t,r,0),a=e.duration,n=Math.min(2*this.config.maxFragLookUpTolerance,.25*a),s=Math.max(Math.min(e.start-n,i.end-n),r+n);e.start-s>n&&this.flushMainBuffer(s,e.start)}else this.flushMainBuffer(0,e.start)},r.getFwdBufferInfo=function(e,t){var r=this.getLoadPosition();return m(r)?this.getFwdBufferInfoAtPos(e,r,t):null},r.getFwdBufferInfoAtPos=function(e,t,r){var i=this.config.maxBufferHole,a=lr.bufferInfo(e,t,i);if(0===a.len&&void 0!==a.nextStart){var n=this.fragmentTracker.getBufferedFrag(t,r);if(n&&a.nextStart<n.end)return lr.bufferInfo(e,t,Math.max(a.nextStart,i))}return a},r.getMaxBufferLength=function(e){var t,r=this.config;return t=e?Math.max(8*r.maxBufferSize/e,r.maxBufferLength):r.maxBufferLength,Math.min(t,r.maxMaxBufferLength)},r.reduceMaxBufferLength=function(e,t){var r=this.config,i=Math.max(Math.min(e-t,r.maxBufferLength),t),a=Math.max(e-3*t,r.maxMaxBufferLength/2,i);return a>=i&&(r.maxMaxBufferLength=a,this.warn("Reduce max buffer length to "+a+"s"),!0)},r.getAppendedFrag=function(e,t){var r=this.fragmentTracker.getAppendedFrag(e,nt);return r&&"fragment"in r?r.fragment:r},r.getNextFragment=function(e,t){var r=t.fragments,i=r.length;if(!i)return null;var a,n=this.config,s=r[0].start;if(t.live){var o=n.initialLiveManifestSize;if(i<o)return this.warn("Not enough fragments to start playback (have: "+i+", need: "+o+")"),null;(!t.PTSKnown&&!this.startFragRequested&&-1===this.startPosition||e<s)&&(a=this.getInitialLiveFragment(t,r),this.startPosition=this.nextLoadPosition=a?this.hls.liveSyncPosition||a.start:e)}else e<=s&&(a=r[0]);if(!a){var l=n.lowLatencyMode?t.partEnd:t.fragmentEnd;a=this.getFragmentAtPosition(e,l,t)}return this.mapToInitFragWhenRequired(a)},r.isLoopLoading=function(e,t){var r=this.fragmentTracker.getState(e);return(r===Fr||r===Pr&&!!e.gap)&&this.nextLoadPosition>t},r.getNextFragmentLoopLoading=function(e,t,r,i,a){var n=e.gap,s=this.getNextFragment(this.nextLoadPosition,t);if(null===s)return s;if(e=s,n&&e&&!e.gap&&r.nextStart){var o=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,r.nextStart,i);if(null!==o&&r.len+o.len>=a)return this.log('buffer full after gaps in "'+i+'" playlist starting at sn: '+e.sn),null}return e},r.mapToInitFragWhenRequired=function(e){return null==e||!e.initSegment||null!=e&&e.initSegment.data||this.bitrateTest?e:e.initSegment},r.getNextPart=function(e,t,r){for(var i=-1,a=!1,n=!0,s=0,o=e.length;s<o;s++){var l=e[s];if(n=n&&!l.independent,i>-1&&r<l.start)break;var u=l.loaded;u?i=-1:(a||l.independent||n)&&l.fragment===t&&(i=s),a=u}return i},r.loadedEndOfParts=function(e,t){var r=e[e.length-1];return r&&t>r.start&&r.loaded},r.getInitialLiveFragment=function(e,t){var r=this.fragPrevious,i=null;if(r){if(e.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+r.programDateTime),i=function(e,t,r){if(null===t||!Array.isArray(e)||!e.length||!m(t))return null;if(t<(e[0].programDateTime||0))return null;if(t>=(e[e.length-1].endProgramDateTime||0))return null;r=r||0;for(var i=0;i<e.length;++i){var a=e[i];if(Yt(t,r,a))return a}return null}(t,r.endProgramDateTime,this.config.maxFragLookUpTolerance)),!i){var a=r.sn+1;if(a>=e.startSN&&a<=e.endSN){var n=t[a-e.startSN];r.cc===n.cc&&(i=n,this.log("Live playlist, switching playlist, load frag with next SN: "+i.sn))}i||(i=function(e,t){return Kt(e,(function(e){return e.cc<t?1:e.cc>t?-1:0}))}(t,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?e.fragmentEnd:e.edge,e))}return i},r.getFragmentAtPosition=function(e,t,r){var i,a=this.config,n=this.fragPrevious,s=r.fragments,o=r.endSN,l=r.fragmentHint,u=a.maxFragLookUpTolerance,d=r.partList,h=!!(a.lowLatencyMode&&null!=d&&d.length&&l);if(h&&l&&!this.bitrateTest&&(s=s.concat(l),o=l.sn),i=e<t?jt(n,s,e,e>t-u?0:u):s[s.length-1]){var f=i.sn-r.startSN,c=this.fragmentTracker.getState(i);if((c===Fr||c===Pr&&i.gap)&&(n=i),n&&i.sn===n.sn&&(!h||d[0].fragment.sn>i.sn)&&n&&i.level===n.level){var v=s[f+1];i=i.sn<o&&this.fragmentTracker.getState(v)!==Fr?v:null}}return i},r.synchronizeToLiveEdge=function(e){var t=this.config,r=this.media;if(r){var i=this.hls.liveSyncPosition,a=r.currentTime,n=e.fragments[0].start,s=e.edge,o=a>=n-t.maxFragLookUpTolerance&&a<=s;if(null!==i&&r.duration>i&&(a<i||!o)){var l=void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;(!o&&r.readyState<4||a<s-l)&&(this.loadedmetadata||(this.nextLoadPosition=i),r.readyState&&(this.warn("Playback: "+a.toFixed(3)+" is located too far from the end of live sliding playlist: "+s+", reset currentTime to : "+i.toFixed(3)),r.currentTime=i))}}},r.alignPlaylists=function(e,t,r){var i=e.fragments.length;if(!i)return this.warn("No fragments in live playlist"),0;var a=e.fragments[0].start,n=!t,s=e.alignedSliding&&m(a);if(n||!s&&!a){var o=this.fragPrevious;Xr(o,r,e);var l=e.fragments[0].start;return this.log("Live playlist sliding: "+l.toFixed(2)+" start-sn: "+(t?t.startSN:"na")+"->"+e.startSN+" prev-sn: "+(o?o.sn:"na")+" fragments: "+i),l}return a},r.waitForCdnTuneIn=function(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,3*e.partTarget)},r.setStartPosition=function(e,t){var r=this.startPosition;if(r<t&&(r=-1),-1===r||-1===this.lastCurrentTime){var i=null!==this.startTimeOffset,a=i?this.startTimeOffset:e.startTimeOffset;null!==a&&m(a)?(r=t+a,a<0&&(r+=e.totalduration),r=Math.min(Math.max(t,r),t+e.totalduration),this.log("Start time offset "+a+" found in "+(i?"multivariant":"media")+" playlist, adjust startPosition to "+r),this.startPosition=r):e.live?r=this.hls.liveSyncPosition||t:this.startPosition=r=0,this.lastCurrentTime=r}this.nextLoadPosition=r},r.getLoadPosition=function(){var e=this.media,t=0;return this.loadedmetadata&&e?t=e.currentTime:this.nextLoadPosition&&(t=this.nextLoadPosition),t},r.handleFragLoadAborted=function(e,t){this.transmuxer&&"initSegment"!==e.sn&&e.stats.aborted&&(this.warn("Fragment "+e.sn+(t?" part "+t.index:"")+" of level "+e.level+" was aborted"),this.resetFragmentLoading(e))},r.resetFragmentLoading=function(e){this.fragCurrent&&(this.fragContextChanged(e)||this.state===ni)||(this.state=ri)},r.onFragmentOrKeyLoadError=function(e,t){if(t.chunkMeta&&!t.frag){var r=this.getCurrentContext(t.chunkMeta);r&&(t.frag=r.frag)}var i=t.frag;if(i&&i.type===e&&this.levels)if(this.fragContextChanged(i)){var a;this.warn("Frag load error must match current frag to retry "+i.url+" > "+(null==(a=this.fragCurrent)?void 0:a.url))}else{var n=t.details===S.FRAG_GAP;n&&this.fragmentTracker.fragBuffered(i,!0);var s=t.errorAction,o=s||{},l=o.action,u=o.retryCount,d=void 0===u?0:u,h=o.retryConfig;if(s&&l===Qt&&h){this.resetStartWhenNotLoaded(this.levelLastLoaded);var f=Gt(h,d);this.warn("Fragment "+i.sn+" of "+e+" "+i.level+" errored with "+t.details+", retrying loading "+(d+1)+"/"+h.maxNumRetry+" in "+f+"ms"),s.resolved=!0,this.retryDate=self.performance.now()+f,this.state=ni}else if(h&&s){if(this.resetFragmentErrors(e),!(d<h.maxNumRetry))return void k.warn(t.details+" reached or exceeded max retry ("+d+")");n||l===Xt||(s.resolved=!0)}else(null==s?void 0:s.action)===zt?this.state=di:this.state=ui;this.tickImmediate()}},r.reduceLengthAndFlushBuffer=function(e){if(this.state===si||this.state===oi){var t=e.frag,r=e.parent,i=this.getFwdBufferInfo(this.mediaBuffer,r),a=i&&i.len>.5;a&&this.reduceMaxBufferLength(i.len,(null==t?void 0:t.duration)||10);var n=!a;return n&&this.warn("Buffer full error while media.currentTime is not buffered, flush "+r+" buffer"),t&&(this.fragmentTracker.removeFragment(t),this.nextLoadPosition=t.start),this.resetLoadingState(),n}return!1},r.resetFragmentErrors=function(e){e===st&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==ti&&(this.state=ri)},r.afterBufferFlushed=function(e,t,r){if(e){var i=lr.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,i,r),this.state===li&&this.resetLoadingState()}},r.resetLoadingState=function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=ri},r.resetStartWhenNotLoaded=function(e){if(!this.loadedmetadata){this.startFragRequested=!1;var t=e?e.details:null;null!=t&&t.live?(this.startPosition=-1,this.setStartPosition(t,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},r.resetWhenMissingContext=function(e){this.warn("The loading context changed while buffering fragment "+e.sn+" of level "+e.level+". This chunk will not be buffered."),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState()},r.removeUnbufferedFrags=function(e){void 0===e&&(e=0),this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)},r.updateLevelTiming=function(e,t,r,i){var a,n=this,s=r.details;if(s){if(!Object.keys(e.elementaryStreams).reduce((function(t,a){var o=e.elementaryStreams[a];if(o){var l=o.endPTS-o.startPTS;if(l<=0)return n.warn("Could not parse fragment "+e.sn+" "+a+" duration reliably ("+l+")"),t||!1;var u=i?0:It(s,e,o.startPTS,o.endPTS,o.startDTS,o.endDTS);return n.hls.trigger(E.LEVEL_PTS_UPDATED,{details:s,level:r,drift:u,type:a,frag:e,start:o.startPTS,end:o.endPTS}),!0}return t}),!1)&&null===(null==(a=this.transmuxer)?void 0:a.error)){var o=new Error("Found no media in fragment "+e.sn+" of level "+e.level+" resetting transmuxer to fallback to playlist timing");if(0===r.fragmentError&&(r.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)),this.warn(o.message),this.hls.trigger(E.ERROR,{type:T.MEDIA_ERROR,details:S.FRAG_PARSING_ERROR,fatal:!1,error:o,frag:e,reason:"Found no media in msn "+e.sn+' of level "'+r.url+'"'}),!this.hls)return;this.resetTransmuxer()}this.state=oi,this.hls.trigger(E.FRAG_PARSED,{frag:e,part:t})}else this.warn("level.details undefined")},r.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},r.recoverWorkerError=function(e){"demuxerWorker"===e.event&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState())},s(t,[{key:"state",get:function(){return this._state},set:function(e){var t=this._state;t!==e&&(this._state=e,this.log(t+"->"+e))}}]),t}(jr);function fi(){return self.SourceBuffer||self.WebKitSourceBuffer}function ci(){if(!Ce())return!1;var e=fi();return!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove}function vi(e,t){return void 0===e&&(e=""),void 0===t&&(t=9e4),{type:e,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}var gi=function(){function e(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}var t=e.prototype;return t.resetInitSegment=function(e,t,r,i){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},t.resetTimeStamp=function(e){this.initPTS=e,this.resetContiguity()},t.resetContiguity=function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},t.canParse=function(e,t){return!1},t.appendFrame=function(e,t,r){},t.demux=function(e,t){this.cachedData&&(e=be(this.cachedData,e),this.cachedData=null);var r,i=Y(e,0),a=i?i.length:0,n=this._audioTrack,s=this._id3Track,o=i?X(i):void 0,l=e.length;for((null===this.basePTS||0===this.frameIndex&&m(o))&&(this.basePTS=mi(o,t,this.initPTS),this.lastPTS=this.basePTS),null===this.lastPTS&&(this.lastPTS=this.basePTS),i&&i.length>0&&s.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:ct,duration:Number.POSITIVE_INFINITY});a<l;){if(this.canParse(e,a)){var u=this.appendFrame(n,e,a);u?(this.frameIndex++,this.lastPTS=u.sample.pts,r=a+=u.length):a=l}else z(e,a)?(i=Y(e,a),s.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:ct,duration:Number.POSITIVE_INFINITY}),r=a+=i.length):a++;if(a===l&&r!==l){var d=V(e,r);this.cachedData?this.cachedData=be(this.cachedData,d):this.cachedData=d}}return{audioTrack:n,videoTrack:vi(),id3Track:s,textTrack:vi()}},t.demuxSampleAes=function(e,t,r){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},t.flush=function(e){var t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:vi(),id3Track:this._id3Track,textTrack:vi()}},t.destroy=function(){},e}(),mi=function(e,t,r){return m(e)?90*e:9e4*t+(r?9e4*r.baseTime/r.timescale:0)};function pi(e,t){return 255===e[t]&&240==(246&e[t+1])}function yi(e,t){return 1&e[t+1]?7:9}function Ei(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function Ti(e,t){return t+1<e.length&&pi(e,t)}function Si(e,t){if(Ti(e,t)){var r=yi(e,t);if(t+r>=e.length)return!1;var i=Ei(e,t);if(i<=r)return!1;var a=t+i;return a===e.length||Ti(e,a)}return!1}function Li(e,t,r,i,a){if(!e.samplerate){var n=function(e,t,r,i){var a,n,s,o,l=navigator.userAgent.toLowerCase(),u=i,d=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];a=1+((192&t[r+2])>>>6);var h=(60&t[r+2])>>>2;if(!(h>d.length-1))return s=(1&t[r+2])<<2,s|=(192&t[r+3])>>>6,k.log("manifest codec:"+i+", ADTS type:"+a+", samplingIndex:"+h),/firefox/i.test(l)?h>=6?(a=5,o=new Array(4),n=h-3):(a=2,o=new Array(2),n=h):-1!==l.indexOf("android")?(a=2,o=new Array(2),n=h):(a=5,o=new Array(4),i&&(-1!==i.indexOf("mp4a.40.29")||-1!==i.indexOf("mp4a.40.5"))||!i&&h>=6?n=h-3:((i&&-1!==i.indexOf("mp4a.40.2")&&(h>=6&&1===s||/vivaldi/i.test(l))||!i&&1===s)&&(a=2,o=new Array(2)),n=h)),o[0]=a<<3,o[0]|=(14&h)>>1,o[1]|=(1&h)<<7,o[1]|=s<<3,5===a&&(o[1]|=(14&n)>>1,o[2]=(1&n)<<7,o[2]|=8,o[3]=0),{config:o,samplerate:d[h],channelCount:s,codec:"mp4a.40."+a,manifestCodec:u};var f=new Error("invalid ADTS sampling index:"+h);e.emit(E.ERROR,E.ERROR,{type:T.MEDIA_ERROR,details:S.FRAG_PARSING_ERROR,fatal:!0,error:f,reason:f.message})}(t,r,i,a);if(!n)return;e.config=n.config,e.samplerate=n.samplerate,e.channelCount=n.channelCount,e.codec=n.codec,e.manifestCodec=n.manifestCodec,k.log("parsed codec:"+e.codec+", rate:"+n.samplerate+", channels:"+n.channelCount)}}function Ri(e){return 9216e4/e}function Ai(e,t,r,i,a){var n,s=i+a*Ri(e.samplerate),o=function(e,t){var r=yi(e,t);if(t+r<=e.length){var i=Ei(e,t)-r;if(i>0)return{headerLength:r,frameLength:i}}}(t,r);if(o){var l=o.frameLength,u=o.headerLength,d=u+l,h=Math.max(0,r+d-t.length);h?(n=new Uint8Array(d-u)).set(t.subarray(r+u,t.length),0):n=t.subarray(r+u,r+d);var f={unit:n,pts:s};return h||e.samples.push(f),{sample:f,length:d,missing:h}}var c=t.length-r;return(n=new Uint8Array(c)).set(t.subarray(r,t.length),0),{sample:{unit:n,pts:s},length:c,missing:-1}}var bi=null,Di=[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],ki=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],_i=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],xi=[0,1,1,4];function wi(e,t,r,i,a){if(!(r+24>t.length)){var n=Ci(t,r);if(n&&r+n.frameLength<=t.length){var s=i+a*(9e4*n.samplesPerFrame/n.sampleRate),o={unit:t.subarray(r,r+n.frameLength),pts:s,dts:s};return e.config=[],e.channelCount=n.channelCount,e.samplerate=n.sampleRate,e.samples.push(o),{sample:o,length:n.frameLength,missing:0}}}}function Ci(e,t){var r=e[t+1]>>3&3,i=e[t+1]>>1&3,a=e[t+2]>>4&15,n=e[t+2]>>2&3;if(1!==r&&0!==a&&15!==a&&3!==n){var s=e[t+2]>>1&1,o=e[t+3]>>6,l=1e3*Di[14*(3===r?3-i:3===i?3:4)+a-1],u=ki[3*(3===r?0:2===r?1:2)+n],d=3===o?1:2,h=_i[r][i],f=xi[i],c=8*h*f,v=Math.floor(h*l/u+s)*f;if(null===bi){var g=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);bi=g?parseInt(g[1]):0}return!!bi&&bi<=87&&2===i&&l>=224e3&&0===o&&(e[t+3]=128|e[t+3]),{sampleRate:u,channelCount:d,frameLength:v,samplesPerFrame:c}}}function Ii(e,t){return!(255!==e[t]||224&~e[t+1]||!(6&e[t+1]))}function Pi(e,t){return t+1<e.length&&Ii(e,t)}function Fi(e,t){if(t+1<e.length&&Ii(e,t)){var r=Ci(e,t),i=4;null!=r&&r.frameLength&&(i=r.frameLength);var a=t+i;return a===e.length||Pi(e,a)}return!1}var Oi=function(e){function t(t,r){var i;return(i=e.call(this)||this).observer=void 0,i.config=void 0,i.observer=t,i.config=r,i}l(t,e);var r=t.prototype;return r.resetInitSegment=function(t,r,i,a){e.prototype.resetInitSegment.call(this,t,r,i,a),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:r,duration:a,inputTimeScale:9e4,dropped:0}},t.probe=function(e){if(!e)return!1;var t=Y(e,0),r=(null==t?void 0:t.length)||0;if(Fi(e,r))return!1;for(var i=e.length;r<i;r++)if(Si(e,r))return k.log("ADTS sync word found !"),!0;return!1},r.canParse=function(e,t){return function(e,t){return function(e,t){return t+5<e.length}(e,t)&&pi(e,t)&&Ei(e,t)<=e.length-t}(e,t)},r.appendFrame=function(e,t,r){Li(e,this.observer,t,r,e.manifestCodec);var i=Ai(e,t,r,this.basePTS,this.frameIndex);if(i&&0===i.missing)return i},t}(gi),Mi=/\/emsg[-/]ID3/i,Ni=function(){function e(e,t){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=t}var t=e.prototype;return t.resetTimeStamp=function(){},t.resetInitSegment=function(e,t,r,i){var a=this.videoTrack=vi("video",1),n=this.audioTrack=vi("audio",1),s=this.txtTrack=vi("text",1);if(this.id3Track=vi("id3",1),this.timeOffset=0,null!=e&&e.byteLength){var o=ye(e);if(o.video){var l=o.video,u=l.id,d=l.timescale,h=l.codec;a.id=u,a.timescale=s.timescale=d,a.codec=h}if(o.audio){var f=o.audio,c=f.id,v=f.timescale,g=f.codec;n.id=c,n.timescale=v,n.codec=g}s.id=ue.text,a.sampleDuration=0,a.duration=n.duration=i}},t.resetContiguity=function(){this.remainderData=null},e.probe=function(e){return function(e){for(var t=e.byteLength,r=0;r<t;){var i=fe(e,r);if(i>8&&109===e[r+4]&&111===e[r+5]&&111===e[r+6]&&102===e[r+7])return!0;r=i>1?r+i:t}return!1}(e)},t.demux=function(e,t){this.timeOffset=t;var r=e,i=this.videoTrack,a=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=be(this.remainderData,e));var n=function(e){var t={valid:null,remainder:null},r=me(e,["moof"]);if(r.length<2)return t.remainder=e,t;var i=r[r.length-1];return t.valid=V(e,0,i.byteOffset-8),t.remainder=V(e,i.byteOffset-8),t}(r);this.remainderData=n.remainder,i.samples=n.valid||new Uint8Array}else i.samples=r;var s=this.extractID3Track(i,t);return a.samples=De(t,i),{videoTrack:i,audioTrack:this.audioTrack,id3Track:s,textTrack:this.txtTrack}},t.flush=function(){var e=this.timeOffset,t=this.videoTrack,r=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;var i=this.extractID3Track(t,this.timeOffset);return r.samples=De(e,t),{videoTrack:t,audioTrack:vi(),id3Track:i,textTrack:vi()}},t.extractID3Track=function(e,t){var r=this.id3Track;if(e.samples.length){var i=me(e.samples,["emsg"]);i&&i.forEach((function(e){var i=function(e){var t=e[0],r="",i="",a=0,n=0,s=0,o=0,l=0,u=0;if(0===t){for(;"\0"!==de(e.subarray(u,u+1));)r+=de(e.subarray(u,u+1)),u+=1;for(r+=de(e.subarray(u,u+1)),u+=1;"\0"!==de(e.subarray(u,u+1));)i+=de(e.subarray(u,u+1)),u+=1;i+=de(e.subarray(u,u+1)),u+=1,a=fe(e,12),n=fe(e,16),o=fe(e,20),l=fe(e,24),u=28}else if(1===t){a=fe(e,u+=4);var d=fe(e,u+=4),h=fe(e,u+=4);for(u+=4,s=Math.pow(2,32)*d+h,p(s)||(s=Number.MAX_SAFE_INTEGER,k.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=fe(e,u),l=fe(e,u+=4),u+=4;"\0"!==de(e.subarray(u,u+1));)r+=de(e.subarray(u,u+1)),u+=1;for(r+=de(e.subarray(u,u+1)),u+=1;"\0"!==de(e.subarray(u,u+1));)i+=de(e.subarray(u,u+1)),u+=1;i+=de(e.subarray(u,u+1)),u+=1}return{schemeIdUri:r,value:i,timeScale:a,presentationTime:s,presentationTimeDelta:n,eventDuration:o,id:l,payload:e.subarray(u,e.byteLength)}}(e);if(Mi.test(i.schemeIdUri)){var a=m(i.presentationTime)?i.presentationTime/i.timeScale:t+i.presentationTimeDelta/i.timeScale,n=4294967295===i.eventDuration?Number.POSITIVE_INFINITY:i.eventDuration/i.timeScale;n<=.001&&(n=Number.POSITIVE_INFINITY);var s=i.payload;r.samples.push({data:s,len:s.byteLength,dts:a,pts:a,type:gt,duration:n})}}))}return r},t.demuxSampleAes=function(e,t,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},t.destroy=function(){},e}(),Bi=function(){function e(){this.VideoSample=null}var t=e.prototype;return t.createVideoSample=function(e,t,r,i){return{key:e,frame:!1,pts:t,dts:r,units:[],debug:i,length:0}},t.getLastNalUnit=function(e){var t,r,i=this.VideoSample;if(i&&0!==i.units.length||(i=e[e.length-1]),null!=(t=i)&&t.units){var a=i.units;r=a[a.length-1]}return r},t.pushAccessUnit=function(e,t){if(e.units.length&&e.frame){if(void 0===e.pts){var r=t.samples,i=r.length;if(!i)return void t.dropped++;var a=r[i-1];e.pts=a.pts,e.dts=a.dts}t.samples.push(e)}e.debug.length&&k.log(e.pts+"/"+e.dts+":"+e.debug)},e}(),Ui=function(){function e(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}var t=e.prototype;return t.loadWord=function(){var e=this.data,t=this.bytesAvailable,r=e.byteLength-t,i=new Uint8Array(4),a=Math.min(4,t);if(0===a)throw new Error("no bytes available");i.set(e.subarray(r,r+a)),this.word=new DataView(i.buffer).getUint32(0),this.bitsAvailable=8*a,this.bytesAvailable-=a},t.skipBits=function(e){var t;e=Math.min(e,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,e-=(t=e>>3)<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)},t.readBits=function(e){var t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;if(e>32&&k.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return(t=e-t)>0&&this.bitsAvailable?r<<t|this.readBits(t):r},t.skipLZ=function(){var e;for(e=0;e<this.bitsAvailable;++e)if(this.word&2147483648>>>e)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()},t.skipUEG=function(){this.skipBits(1+this.skipLZ())},t.skipEG=function(){this.skipBits(1+this.skipLZ())},t.readUEG=function(){var e=this.skipLZ();return this.readBits(e+1)-1},t.readEG=function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)},t.readBoolean=function(){return 1===this.readBits(1)},t.readUByte=function(){return this.readBits(8)},t.readUShort=function(){return this.readBits(16)},t.readUInt=function(){return this.readBits(32)},t.skipScalingList=function(e){for(var t=8,r=8,i=0;i<e;i++)0!==r&&(r=(t+this.readEG()+256)%256),t=0===r?t:r},t.readSPS=function(){var e,t,r,i=0,a=0,n=0,s=0,o=this.readUByte.bind(this),l=this.readBits.bind(this),u=this.readUEG.bind(this),d=this.readBoolean.bind(this),h=this.skipBits.bind(this),f=this.skipEG.bind(this),c=this.skipUEG.bind(this),v=this.skipScalingList.bind(this);o();var g=o();if(l(5),h(3),o(),c(),100===g||110===g||122===g||244===g||44===g||83===g||86===g||118===g||128===g){var m=u();if(3===m&&h(1),c(),c(),h(1),d())for(t=3!==m?8:12,r=0;r<t;r++)d()&&v(r<6?16:64)}c();var p=u();if(0===p)u();else if(1===p)for(h(1),f(),f(),e=u(),r=0;r<e;r++)f();c(),h(1);var y=u(),E=u(),T=l(1);0===T&&h(1),h(1),d()&&(i=u(),a=u(),n=u(),s=u());var S=[1,1];if(d()&&d())switch(o()){case 1:S=[1,1];break;case 2:S=[12,11];break;case 3:S=[10,11];break;case 4:S=[16,11];break;case 5:S=[40,33];break;case 6:S=[24,11];break;case 7:S=[20,11];break;case 8:S=[32,11];break;case 9:S=[80,33];break;case 10:S=[18,11];break;case 11:S=[15,11];break;case 12:S=[64,33];break;case 13:S=[160,99];break;case 14:S=[4,3];break;case 15:S=[3,2];break;case 16:S=[2,1];break;case 255:S=[o()<<8|o(),o()<<8|o()]}return{width:Math.ceil(16*(y+1)-2*i-2*a),height:(2-T)*(E+1)*16-(T?2:4)*(n+s),pixelRatio:S}},t.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},e}(),Gi=function(e){function t(){return e.apply(this,arguments)||this}l(t,e);var r=t.prototype;return r.parseAVCPES=function(e,t,r,i,a){var n,s=this,o=this.parseAVCNALu(e,r.data),l=this.VideoSample,u=!1;r.data=null,l&&o.length&&!e.audFound&&(this.pushAccessUnit(l,e),l=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts,"")),o.forEach((function(i){var o;switch(i.type){case 1:var d=!1;n=!0;var h,f=i.data;if(u&&f.length>4){var c=new Ui(f).readSliceType();2!==c&&4!==c&&7!==c&&9!==c||(d=!0)}d&&null!=(h=l)&&h.frame&&!l.key&&(s.pushAccessUnit(l,e),l=s.VideoSample=null),l||(l=s.VideoSample=s.createVideoSample(!0,r.pts,r.dts,"")),l.frame=!0,l.key=d;break;case 5:n=!0,null!=(o=l)&&o.frame&&!l.key&&(s.pushAccessUnit(l,e),l=s.VideoSample=null),l||(l=s.VideoSample=s.createVideoSample(!0,r.pts,r.dts,"")),l.key=!0,l.frame=!0;break;case 6:n=!0,_e(i.data,1,r.pts,t.samples);break;case 7:var v,g;n=!0,u=!0;var m=i.data,p=new Ui(m).readSPS();if(!e.sps||e.width!==p.width||e.height!==p.height||(null==(v=e.pixelRatio)?void 0:v[0])!==p.pixelRatio[0]||(null==(g=e.pixelRatio)?void 0:g[1])!==p.pixelRatio[1]){e.width=p.width,e.height=p.height,e.pixelRatio=p.pixelRatio,e.sps=[m],e.duration=a;for(var y=m.subarray(1,4),E="avc1.",T=0;T<3;T++){var S=y[T].toString(16);S.length<2&&(S="0"+S),E+=S}e.codec=E}break;case 8:n=!0,e.pps=[i.data];break;case 9:n=!0,e.audFound=!0,l&&s.pushAccessUnit(l,e),l=s.VideoSample=s.createVideoSample(!1,r.pts,r.dts,"");break;case 12:n=!0;break;default:n=!1,l&&(l.debug+="unknown NAL "+i.type+" ")}l&&n&&l.units.push(i)})),i&&l&&(this.pushAccessUnit(l,e),this.VideoSample=null)},r.parseAVCNALu=function(e,t){var r,i,a=t.byteLength,n=e.naluState||0,s=n,o=[],l=0,u=-1,d=0;for(-1===n&&(u=0,d=31&t[0],n=0,l=1);l<a;)if(r=t[l++],n)if(1!==n)if(r)if(1===r){if(i=l-n-1,u>=0){var h={data:t.subarray(u,i),type:d};o.push(h)}else{var f=this.getLastNalUnit(e.samples);f&&(s&&l<=4-s&&f.state&&(f.data=f.data.subarray(0,f.data.byteLength-s)),i>0&&(f.data=be(f.data,t.subarray(0,i)),f.state=0))}l<a?(u=l,d=31&t[l],n=0):n=-1}else n=0;else n=3;else n=r?0:2;else n=r?0:1;if(u>=0&&n>=0){var c={data:t.subarray(u,a),type:d,state:n};o.push(c)}if(0===o.length){var v=this.getLastNalUnit(e.samples);v&&(v.data=be(v.data,t))}return e.naluState=n,o},t}(Bi),Hi=function(){function e(e,t,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new Zr(t,{removePKCS7Padding:!1})}var t=e.prototype;return t.decryptBuffer=function(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer)},t.decryptAacSample=function(e,t,r){var i=this,a=e[t].unit;if(!(a.length<=16)){var n=a.subarray(16,a.length-a.length%16),s=n.buffer.slice(n.byteOffset,n.byteOffset+n.length);this.decryptBuffer(s).then((function(n){var s=new Uint8Array(n);a.set(s,16),i.decrypter.isSync()||i.decryptAacSamples(e,t+1,r)}))}},t.decryptAacSamples=function(e,t,r){for(;;t++){if(t>=e.length)return void r();if(!(e[t].unit.length<32||(this.decryptAacSample(e,t,r),this.decrypter.isSync())))return}},t.getAvcEncryptedData=function(e){for(var t=16*Math.floor((e.length-48)/160)+16,r=new Int8Array(t),i=0,a=32;a<e.length-16;a+=160,i+=16)r.set(e.subarray(a,a+16),i);return r},t.getAvcDecryptedUnit=function(e,t){for(var r=new Uint8Array(t),i=0,a=32;a<e.length-16;a+=160,i+=16)e.set(r.subarray(i,i+16),a);return e},t.decryptAvcSample=function(e,t,r,i,a){var n=this,s=xe(a.data),o=this.getAvcEncryptedData(s);this.decryptBuffer(o.buffer).then((function(o){a.data=n.getAvcDecryptedUnit(s,o),n.decrypter.isSync()||n.decryptAvcSamples(e,t,r+1,i)}))},t.decryptAvcSamples=function(e,t,r,i){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,r=0){if(t>=e.length)return void i();for(var a=e[t].units;!(r>=a.length);r++){var n=a[r];if(!(n.data.length<=48||1!==n.type&&5!==n.type||(this.decryptAvcSample(e,t,r,i,n),this.decrypter.isSync())))return}}},e}(),Vi=188,Ki=function(){function e(e,t,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._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=e,this.config=t,this.typeSupported=r,this.videoParser=new Gi}e.probe=function(t){var r=e.syncOffset(t);return r>0&&k.warn("MPEG2-TS detected but first sync word found @ offset "+r),-1!==r},e.syncOffset=function(e){for(var t=e.length,r=Math.min(940,t-Vi)+1,i=0;i<r;){for(var a=!1,n=-1,s=0,o=i;o<t;o+=Vi){if(71!==e[o]||t-o!==Vi&&71!==e[o+Vi]){if(s)return-1;break}if(s++,-1===n&&0!==(n=o)&&(r=Math.min(n+18612,e.length-Vi)+1),a||(a=0===ji(e,o)),a&&s>1&&(0===n&&s>2||o+Vi>r))return n}i++}return-1},e.createTrack=function(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:ue[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===e?t:void 0}};var t=e.prototype;return t.resetInitSegment=function(t,r,i,a){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=e.createTrack("video"),this._audioTrack=e.createTrack("audio",a),this._id3Track=e.createTrack("id3"),this._txtTrack=e.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.remainderData=null,this.audioCodec=r,this.videoCodec=i,this._duration=a},t.resetTimeStamp=function(){},t.resetContiguity=function(){var e=this._audioTrack,t=this._videoTrack,r=this._id3Track;e&&(e.pesData=null),t&&(t.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.remainderData=null},t.demux=function(t,r,i,a){var n;void 0===i&&(i=!1),void 0===a&&(a=!1),i||(this.sampleAes=null);var s=this._videoTrack,o=this._audioTrack,l=this._id3Track,u=this._txtTrack,d=s.pid,h=s.pesData,f=o.pid,c=l.pid,v=o.pesData,g=l.pesData,m=null,p=this.pmtParsed,y=this._pmtId,E=t.length;if(this.remainderData&&(E=(t=be(this.remainderData,t)).length,this.remainderData=null),E<Vi&&!a)return this.remainderData=t,{audioTrack:o,videoTrack:s,id3Track:l,textTrack:u};var T=Math.max(0,e.syncOffset(t));(E-=(E-T)%Vi)<t.byteLength&&!a&&(this.remainderData=new Uint8Array(t.buffer,E,t.buffer.byteLength-E));for(var S=0,L=T;L<E;L+=Vi)if(71===t[L]){var R=!!(64&t[L+1]),A=ji(t,L),b=void 0;if((48&t[L+3])>>4>1){if((b=L+5+t[L+4])===L+Vi)continue}else b=L+4;switch(A){case d:R&&(h&&(n=Xi(h))&&this.videoParser.parseAVCPES(s,u,n,!1,this._duration),h={data:[],size:0}),h&&(h.data.push(t.subarray(b,L+Vi)),h.size+=L+Vi-b);break;case f:if(R){if(v&&(n=Xi(v)))switch(o.segmentCodec){case"aac":this.parseAACPES(o,n);break;case"mp3":this.parseMPEGPES(o,n)}v={data:[],size:0}}v&&(v.data.push(t.subarray(b,L+Vi)),v.size+=L+Vi-b);break;case c:R&&(g&&(n=Xi(g))&&this.parseID3PES(l,n),g={data:[],size:0}),g&&(g.data.push(t.subarray(b,L+Vi)),g.size+=L+Vi-b);break;case 0:R&&(b+=t[b]+1),y=this._pmtId=Wi(t,b);break;case y:R&&(b+=t[b]+1);var D=Yi(t,b,this.typeSupported,i,this.observer);(d=D.videoPid)>0&&(s.pid=d,s.segmentCodec=D.segmentVideoCodec),(f=D.audioPid)>0&&(o.pid=f,o.segmentCodec=D.segmentAudioCodec),(c=D.id3Pid)>0&&(l.pid=c),null===m||p||(k.warn("MPEG-TS PMT found at "+L+" after unknown PID '"+m+"'. Backtracking to sync byte @"+T+" to parse all TS packets."),m=null,L=T-188),p=this.pmtParsed=!0;break;case 17:case 8191:break;default:m=A}}else S++;S>0&&qi(this.observer,new Error("Found "+S+" TS packet/s that do not start with 0x47")),s.pesData=h,o.pesData=v,l.pesData=g;var _={audioTrack:o,videoTrack:s,id3Track:l,textTrack:u};return a&&this.extractRemainingSamples(_),_},t.flush=function(){var e,t=this.remainderData;return this.remainderData=null,e=t?this.demux(t,-1,!1,!0):{videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(e),this.sampleAes?this.decrypt(e,this.sampleAes):e},t.extractRemainingSamples=function(e){var t,r=e.audioTrack,i=e.videoTrack,a=e.id3Track,n=e.textTrack,s=i.pesData,o=r.pesData,l=a.pesData;if(s&&(t=Xi(s))?(this.videoParser.parseAVCPES(i,n,t,!0,this._duration),i.pesData=null):i.pesData=s,o&&(t=Xi(o))){switch(r.segmentCodec){case"aac":this.parseAACPES(r,t);break;case"mp3":this.parseMPEGPES(r,t)}r.pesData=null}else null!=o&&o.size&&k.log("last AAC PES packet truncated,might overlap between fragments"),r.pesData=o;l&&(t=Xi(l))?(this.parseID3PES(a,t),a.pesData=null):a.pesData=l},t.demuxSampleAes=function(e,t,r){var i=this.demux(e,r,!0,!this.config.progressive),a=this.sampleAes=new Hi(this.observer,this.config,t);return this.decrypt(i,a)},t.decrypt=function(e,t){return new Promise((function(r){var i=e.audioTrack,a=e.videoTrack;i.samples&&"aac"===i.segmentCodec?t.decryptAacSamples(i.samples,0,(function(){a.samples?t.decryptAvcSamples(a.samples,0,0,(function(){r(e)})):r(e)})):a.samples&&t.decryptAvcSamples(a.samples,0,0,(function(){r(e)}))}))},t.destroy=function(){this._duration=0},t.parseAACPES=function(e,t){var r,i,a,n=0,s=this.aacOverFlow,o=t.data;if(s){this.aacOverFlow=null;var l=s.missing,u=s.sample.unit.byteLength;if(-1===l)o=be(s.sample.unit,o);else{var d=u-l;s.sample.unit.set(o.subarray(0,l),d),e.samples.push(s.sample),n=s.missing}}for(r=n,i=o.length;r<i-1&&!Ti(o,r);r++);if(r!==n){var h,f=r<i-1;if(h=f?"AAC PES did not start with ADTS header,offset:"+r:"No ADTS header found in AAC PES",qi(this.observer,new Error(h),f),!f)return}if(Li(e,this.observer,o,r,this.audioCodec),void 0!==t.pts)a=t.pts;else{if(!s)return void k.warn("[tsdemuxer]: AAC PES unknown PTS");var c=Ri(e.samplerate);a=s.sample.pts+c}for(var v,g=0;r<i;){if(r+=(v=Ai(e,o,r,a,g)).length,v.missing){this.aacOverFlow=v;break}for(g++;r<i-1&&!Ti(o,r);r++);}},t.parseMPEGPES=function(e,t){var r=t.data,i=r.length,a=0,n=0,s=t.pts;if(void 0!==s)for(;n<i;)if(Pi(r,n)){var o=wi(e,r,n,s,a);if(!o)break;n+=o.length,a++}else n++;else k.warn("[tsdemuxer]: MPEG PES unknown PTS")},t.parseAC3PES=function(e,t){},t.parseID3PES=function(e,t){if(void 0!==t.pts){var r=o({},t,{type:this._videoTrack?gt:ct,duration:Number.POSITIVE_INFINITY});e.samples.push(r)}else k.warn("[tsdemuxer]: ID3 PES unknown PTS")},e}();function ji(e,t){return((31&e[t+1])<<8)+e[t+2]}function Wi(e,t){return(31&e[t+10])<<8|e[t+11]}function Yi(e,t,r,i,a){var n={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},s=t+3+((15&e[t+1])<<8|e[t+2])-4;for(t+=12+((15&e[t+10])<<8|e[t+11]);t<s;){var o=ji(e,t),l=(15&e[t+3])<<8|e[t+4];switch(e[t]){case 207:if(!i){zi("ADTS AAC");break}case 15:-1===n.audioPid&&(n.audioPid=o);break;case 21:-1===n.id3Pid&&(n.id3Pid=o);break;case 219:if(!i){zi("H.264");break}case 27:-1===n.videoPid&&(n.videoPid=o,n.segmentVideoCodec="avc");break;case 3:case 4:r.mpeg||r.mp3?-1===n.audioPid&&(n.audioPid=o,n.segmentAudioCodec="mp3"):k.log("MPEG audio found, not supported in this browser");break;case 193:if(!i){zi("AC-3");break}case 129:k.warn("AC-3 in M2TS support not included in build");break;case 6:if(-1===n.audioPid&&l>0)for(var u=t+5,d=l;d>2;){106===e[u]&&k.warn("AC-3 in M2TS support not included in build");var h=e[u+1]+2;u+=h,d-=h}break;case 194:case 135:return qi(a,new Error("Unsupported EC-3 in M2TS found")),n;case 36:return qi(a,new Error("Unsupported HEVC in M2TS found")),n}t+=l+5}return n}function qi(e,t,r){k.warn("parsing error: "+t.message),e.emit(E.ERROR,E.ERROR,{type:T.MEDIA_ERROR,details:S.FRAG_PARSING_ERROR,fatal:!1,levelRetry:r,error:t,reason:t.message})}function zi(e){k.log(e+" with AES-128-CBC encryption found in unencrypted stream")}function Xi(e){var t,r,i,a,n,s=0,o=e.data;if(!e||0===e.size)return null;for(;o[0].length<19&&o.length>1;)o[0]=be(o[0],o[1]),o.splice(1,1);if(1===((t=o[0])[0]<<16)+(t[1]<<8)+t[2]){if((r=(t[4]<<8)+t[5])&&r>e.size-6)return null;var l=t[7];192&l&&(a=536870912*(14&t[9])+4194304*(255&t[10])+16384*(254&t[11])+128*(255&t[12])+(254&t[13])/2,64&l?a-(n=536870912*(14&t[14])+4194304*(255&t[15])+16384*(254&t[16])+128*(255&t[17])+(254&t[18])/2)>54e5&&(k.warn(Math.round((a-n)/9e4)+"s delta between PTS and DTS, align them"),a=n):n=a);var u=(i=t[8])+9;if(e.size<=u)return null;e.size-=u;for(var d=new Uint8Array(e.size),h=0,f=o.length;h<f;h++){var c=(t=o[h]).byteLength;if(u){if(u>c){u-=c;continue}t=t.subarray(u),c-=u,u=0}d.set(t,s),s+=c}return r&&(r-=i+3),{data:d,pts:a,dts:n,len:r}}return null}var Qi=function(e){function t(){return e.apply(this,arguments)||this}l(t,e);var r=t.prototype;return r.resetInitSegment=function(t,r,i,a){e.prototype.resetInitSegment.call(this,t,r,i,a),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:r,duration:a,inputTimeScale:9e4,dropped:0}},t.probe=function(e){if(!e)return!1;var t=Y(e,0),r=(null==t?void 0:t.length)||0;if(t&&11===e[r]&&119===e[r+1]&&void 0!==X(t)&&function(e,t){var r=0,i=5;t+=i;for(var a=new Uint32Array(1),n=new Uint32Array(1),s=new Uint8Array(1);i>0;){s[0]=e[t];var o=Math.min(i,8),l=8-o;n[0]=4278190080>>>24+l<<l,a[0]=(s[0]&n[0])>>l,r=r?r<<o|a[0]:a[0],t+=1,i-=o}return r}(e,r)<=16)return!1;for(var i=e.length;r<i;r++)if(Fi(e,r))return k.log("MPEG Audio sync word found !"),!0;return!1},r.canParse=function(e,t){return function(e,t){return Ii(e,t)&&4<=e.length-t}(e,t)},r.appendFrame=function(e,t,r){if(null!==this.basePTS)return wi(e,t,r,this.basePTS,this.frameIndex)},t}(gi),Ji=function(){function e(){}return e.getSilentFrame=function(e,t){if("mp4a.40.2"===e){if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(6===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(1===t)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(3===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}},e}(),$i=Math.pow(2,32)-1,Zi=function(){function e(){}return e.init=function(){var t;for(t in e.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],dac3:[],"ac-3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},e.types)e.types.hasOwnProperty(t)&&(e.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);var r=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),i=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);e.HDLR_TYPES={video:r,audio:i};var a=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),n=new Uint8Array([0,0,0,0,0,0,0,0]);e.STTS=e.STSC=e.STCO=n,e.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),e.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),e.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),e.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var s=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);e.FTYP=e.box(e.types.ftyp,s,l,s,o),e.DINF=e.box(e.types.dinf,e.box(e.types.dref,a))},e.box=function(e){for(var t=8,r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++)i[a-1]=arguments[a];for(var n=i.length,s=n;n--;)t+=i[n].byteLength;var o=new Uint8Array(t);for(o[0]=t>>24&255,o[1]=t>>16&255,o[2]=t>>8&255,o[3]=255&t,o.set(e,4),n=0,t=8;n<s;n++)o.set(i[n],t),t+=i[n].byteLength;return o},e.hdlr=function(t){return e.box(e.types.hdlr,e.HDLR_TYPES[t])},e.mdat=function(t){return e.box(e.types.mdat,t)},e.mdhd=function(t,r){r*=t;var i=Math.floor(r/($i+1)),a=Math.floor(r%($i+1));return e.box(e.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,i>>24,i>>16&255,i>>8&255,255&i,a>>24,a>>16&255,a>>8&255,255&a,85,196,0,0]))},e.mdia=function(t){return e.box(e.types.mdia,e.mdhd(t.timescale,t.duration),e.hdlr(t.type),e.minf(t))},e.mfhd=function(t){return e.box(e.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))},e.minf=function(t){return"audio"===t.type?e.box(e.types.minf,e.box(e.types.smhd,e.SMHD),e.DINF,e.stbl(t)):e.box(e.types.minf,e.box(e.types.vmhd,e.VMHD),e.DINF,e.stbl(t))},e.moof=function(t,r,i){return e.box(e.types.moof,e.mfhd(t),e.traf(i,r))},e.moov=function(t){for(var r=t.length,i=[];r--;)i[r]=e.trak(t[r]);return e.box.apply(null,[e.types.moov,e.mvhd(t[0].timescale,t[0].duration)].concat(i).concat(e.mvex(t)))},e.mvex=function(t){for(var r=t.length,i=[];r--;)i[r]=e.trex(t[r]);return e.box.apply(null,[e.types.mvex].concat(i))},e.mvhd=function(t,r){r*=t;var i=Math.floor(r/($i+1)),a=Math.floor(r%($i+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,i>>24,i>>16&255,i>>8&255,255&i,a>>24,a>>16&255,a>>8&255,255&a,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return e.box(e.types.mvhd,n)},e.sdtp=function(t){var r,i,a=t.samples||[],n=new Uint8Array(4+a.length);for(r=0;r<a.length;r++)i=a[r].flags,n[r+4]=i.dependsOn<<4|i.isDependedOn<<2|i.hasRedundancy;return e.box(e.types.sdtp,n)},e.stbl=function(t){return e.box(e.types.stbl,e.stsd(t),e.box(e.types.stts,e.STTS),e.box(e.types.stsc,e.STSC),e.box(e.types.stsz,e.STSZ),e.box(e.types.stco,e.STCO))},e.avc1=function(t){var r,i,a,n=[],s=[];for(r=0;r<t.sps.length;r++)a=(i=t.sps[r]).byteLength,n.push(a>>>8&255),n.push(255&a),n=n.concat(Array.prototype.slice.call(i));for(r=0;r<t.pps.length;r++)a=(i=t.pps[r]).byteLength,s.push(a>>>8&255),s.push(255&a),s=s.concat(Array.prototype.slice.call(i));var o=e.box(e.types.avcC,new Uint8Array([1,n[3],n[4],n[5],255,224|t.sps.length].concat(n).concat([t.pps.length]).concat(s))),l=t.width,u=t.height,d=t.pixelRatio[0],h=t.pixelRatio[1];return e.box(e.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,l>>8&255,255&l,u>>8&255,255&u,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),o,e.box(e.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),e.box(e.types.pasp,new Uint8Array([d>>24,d>>16&255,d>>8&255,255&d,h>>24,h>>16&255,h>>8&255,255&h])))},e.esds=function(e){var t=e.config.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e.config).concat([6,1,2]))},e.audioStsd=function(e){var t=e.samplerate;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,255&t,0,0])},e.mp4a=function(t){return e.box(e.types.mp4a,e.audioStsd(t),e.box(e.types.esds,e.esds(t)))},e.mp3=function(t){return e.box(e.types[".mp3"],e.audioStsd(t))},e.ac3=function(t){return e.box(e.types["ac-3"],e.audioStsd(t),e.box(e.types.dac3,t.config))},e.stsd=function(t){return"audio"===t.type?"mp3"===t.segmentCodec&&"mp3"===t.codec?e.box(e.types.stsd,e.STSD,e.mp3(t)):"ac3"===t.segmentCodec?e.box(e.types.stsd,e.STSD,e.ac3(t)):e.box(e.types.stsd,e.STSD,e.mp4a(t)):e.box(e.types.stsd,e.STSD,e.avc1(t))},e.tkhd=function(t){var r=t.id,i=t.duration*t.timescale,a=t.width,n=t.height,s=Math.floor(i/($i+1)),o=Math.floor(i%($i+1));return e.box(e.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,r>>24&255,r>>16&255,r>>8&255,255&r,0,0,0,0,s>>24,s>>16&255,s>>8&255,255&s,o>>24,o>>16&255,o>>8&255,255&o,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,a>>8&255,255&a,0,0,n>>8&255,255&n,0,0]))},e.traf=function(t,r){var i=e.sdtp(t),a=t.id,n=Math.floor(r/($i+1)),s=Math.floor(r%($i+1));return e.box(e.types.traf,e.box(e.types.tfhd,new Uint8Array([0,0,0,0,a>>24,a>>16&255,a>>8&255,255&a])),e.box(e.types.tfdt,new Uint8Array([1,0,0,0,n>>24,n>>16&255,n>>8&255,255&n,s>>24,s>>16&255,s>>8&255,255&s])),e.trun(t,i.length+16+20+8+16+8+8),i)},e.trak=function(t){return t.duration=t.duration||4294967295,e.box(e.types.trak,e.tkhd(t),e.mdia(t))},e.trex=function(t){var r=t.id;return e.box(e.types.trex,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},e.trun=function(t,r){var i,a,n,s,o,l,u=t.samples||[],d=u.length,h=12+16*d,f=new Uint8Array(h);for(r+=8+h,f.set(["video"===t.type?1:0,0,15,1,d>>>24&255,d>>>16&255,d>>>8&255,255&d,r>>>24&255,r>>>16&255,r>>>8&255,255&r],0),i=0;i<d;i++)n=(a=u[i]).duration,s=a.size,o=a.flags,l=a.cts,f.set([n>>>24&255,n>>>16&255,n>>>8&255,255&n,s>>>24&255,s>>>16&255,s>>>8&255,255&s,o.isLeading<<2|o.dependsOn,o.isDependedOn<<6|o.hasRedundancy<<4|o.paddingValue<<1|o.isNonSync,61440&o.degradPrio,15&o.degradPrio,l>>>24&255,l>>>16&255,l>>>8&255,255&l],12+16*i);return e.box(e.types.trun,f)},e.initSegment=function(t){e.types||e.init();var r=e.moov(t);return be(e.FTYP,r)},e}();Zi.types=void 0,Zi.HDLR_TYPES=void 0,Zi.STTS=void 0,Zi.STSC=void 0,Zi.STCO=void 0,Zi.STSZ=void 0,Zi.VMHD=void 0,Zi.SMHD=void 0,Zi.STSD=void 0,Zi.FTYP=void 0,Zi.DINF=void 0;function ea(e,t){return void 0===t&&(t=!1),function(e,t,r,i){void 0===r&&(r=1),void 0===i&&(i=!1);var a=e*t*r;return i?Math.round(a):a}(e,1e3,1/9e4,t)}var ta=null,ra=null,ia=function(){function e(e,t,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.videoTrackConfig=void 0,this.observer=e,this.config=t,this.typeSupported=r,this.ISGenerated=!1,null===ta){var a=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);ta=a?parseInt(a[1]):0}if(null===ra){var n=navigator.userAgent.match(/Safari\/(\d+)/i);ra=n?parseInt(n[1]):0}}var t=e.prototype;return t.destroy=function(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null},t.resetTimeStamp=function(e){k.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e},t.resetNextTimestamp=function(){k.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},t.resetInitSegment=function(){k.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0},t.getVideoStartPts=function(e){var t=!1,r=e.reduce((function(e,r){var i=r.pts-e;return i<-4294967296?(t=!0,aa(e,r.pts)):i>0?e:r.pts}),e[0].pts);return t&&k.debug("PTS rollover detected"),r},t.remux=function(e,t,r,i,a,n,s,o){var l,u,d,h,f,c,v=a,g=a,m=e.pid>-1,p=t.pid>-1,y=t.samples.length,E=e.samples.length>0,T=s&&y>0||y>1;if((!m||E)&&(!p||T)||this.ISGenerated||s){if(this.ISGenerated){var S,L,R,A,b=this.videoTrackConfig;!b||t.width===b.width&&t.height===b.height&&(null==(S=t.pixelRatio)?void 0:S[0])===(null==(L=b.pixelRatio)?void 0:L[0])&&(null==(R=t.pixelRatio)?void 0:R[1])===(null==(A=b.pixelRatio)?void 0:A[1])||this.resetInitSegment()}else d=this.generateIS(e,t,a,n);var D,_=this.isVideoContiguous,x=-1;if(T&&(x=function(e){for(var t=0;t<e.length;t++)if(e[t].key)return t;return-1}(t.samples),!_&&this.config.forceKeyFrameOnDiscontinuity))if(c=!0,x>0){k.warn("[mp4-remuxer]: Dropped "+x+" out of "+y+" video samples due to a missing keyframe");var w=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(x),t.dropped+=x,D=g+=(t.samples[0].pts-w)/t.inputTimeScale}else-1===x&&(k.warn("[mp4-remuxer]: No keyframe found out of "+y+" video samples"),c=!1);if(this.ISGenerated){if(E&&T){var C=this.getVideoStartPts(t.samples),I=(aa(e.samples[0].pts,C)-C)/t.inputTimeScale;v+=Math.max(0,I),g+=Math.max(0,-I)}if(E){if(e.samplerate||(k.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),d=this.generateIS(e,t,a,n)),u=this.remuxAudio(e,v,this.isAudioContiguous,n,p||T||o===st?g:void 0),T){var P=u?u.endPTS-u.startPTS:0;t.inputTimeScale||(k.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),d=this.generateIS(e,t,a,n)),l=this.remuxVideo(t,g,_,P)}}else T&&(l=this.remuxVideo(t,g,_,0));l&&(l.firstKeyFrame=x,l.independent=-1!==x,l.firstKeyFramePTS=D)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(f=na(r,a,this._initPTS,this._initDTS)),i.samples.length&&(h=sa(i,a,this._initPTS))),{audio:u,video:l,initSegment:d,independent:c,text:h,id3:f}},t.generateIS=function(e,t,r,i){var a,n,s,o=e.samples,l=t.samples,u=this.typeSupported,d={},h=this._initPTS,f=!h||i,c="audio/mp4";if(f&&(a=n=1/0),e.config&&o.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":u.mpeg?(c="audio/mpeg",e.codec=""):u.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3"}d.audio={id:"audio",container:c,codec:e.codec,initSegment:"mp3"===e.segmentCodec&&u.mpeg?new Uint8Array(0):Zi.initSegment([e]),metadata:{channelCount:e.channelCount}},f&&(s=e.inputTimeScale,h&&s===h.timescale?f=!1:a=n=o[0].pts-Math.round(s*r))}if(t.sps&&t.pps&&l.length){if(t.timescale=t.inputTimeScale,d.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:Zi.initSegment([t]),metadata:{width:t.width,height:t.height}},f)if(s=t.inputTimeScale,h&&s===h.timescale)f=!1;else{var v=this.getVideoStartPts(l),g=Math.round(s*r);n=Math.min(n,aa(l[0].dts,v)-g),a=Math.min(a,v-g)}this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(d).length)return this.ISGenerated=!0,f?(this._initPTS={baseTime:a,timescale:s},this._initDTS={baseTime:n,timescale:s}):a=s=void 0,{tracks:d,initPTS:a,timescale:s}},t.remuxVideo=function(e,t,r,i){var a,n,s=e.inputTimeScale,l=e.samples,u=[],d=l.length,h=this._initPTS,f=this.nextAvcDts,c=8,v=this.videoSampleDuration,g=Number.POSITIVE_INFINITY,m=Number.NEGATIVE_INFINITY,p=!1;if(!r||null===f){var y=t*s,L=l[0].pts-aa(l[0].dts,l[0].pts);ta&&null!==f&&Math.abs(y-L-f)<15e3?r=!0:f=y-L}for(var R=h.baseTime*s/h.timescale,A=0;A<d;A++){var b=l[A];b.pts=aa(b.pts-R,f),b.dts=aa(b.dts-R,f),b.dts<l[A>0?A-1:A].dts&&(p=!0)}p&&l.sort((function(e,t){var r=e.dts-t.dts,i=e.pts-t.pts;return r||i})),a=l[0].dts;var D=l[l.length-1].dts-a,_=D?Math.round(D/(d-1)):v||e.inputTimeScale/30;if(r){var x=a-f,w=x>_,C=x<-1;if((w||C)&&(w?k.warn("AVC: "+ea(x,!0)+" ms ("+x+"dts) hole between fragments detected at "+t.toFixed(3)):k.warn("AVC: "+ea(-x,!0)+" ms ("+x+"dts) overlapping between fragments detected at "+t.toFixed(3)),!C||f>=l[0].pts||ta)){a=f;var I=l[0].pts-x;if(w)l[0].dts=a,l[0].pts=I;else for(var P=0;P<l.length&&!(l[P].dts>I);P++)l[P].dts-=x,l[P].pts-=x;k.log("Video: Initial PTS/DTS adjusted: "+ea(I,!0)+"/"+ea(a,!0)+", delta: "+ea(x,!0)+" ms")}}for(var F=0,O=0,M=a=Math.max(0,a),N=0;N<d;N++){for(var B=l[N],U=B.units,G=U.length,H=0,V=0;V<G;V++)H+=U[V].data.length;O+=H,F+=G,B.length=H,B.dts<M?(B.dts=M,M+=_/4|0||1):M=B.dts,g=Math.min(B.pts,g),m=Math.max(B.pts,m)}n=l[d-1].dts;var K,j=O+4*F+8;try{K=new Uint8Array(j)}catch(e){return void this.observer.emit(E.ERROR,E.ERROR,{type:T.MUX_ERROR,details:S.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:j,reason:"fail allocating video mdat "+j})}var W=new DataView(K.buffer);W.setUint32(0,j),K.set(Zi.types.mdat,4);for(var Y=!1,q=Number.POSITIVE_INFINITY,z=Number.POSITIVE_INFINITY,X=Number.NEGATIVE_INFINITY,Q=Number.NEGATIVE_INFINITY,J=0;J<d;J++){for(var $=l[J],Z=$.units,ee=0,te=0,re=Z.length;te<re;te++){var ie=Z[te],ae=ie.data,ne=ie.data.byteLength;W.setUint32(c,ne),c+=4,K.set(ae,c),c+=ne,ee+=4+ne}var se=void 0;if(J<d-1)v=l[J+1].dts-$.dts,se=l[J+1].pts-$.pts;else{var oe=this.config,le=J>0?$.dts-l[J-1].dts:_;if(se=J>0?$.pts-l[J-1].pts:_,oe.stretchShortVideoTrack&&null!==this.nextAudioPts){var ue=Math.floor(oe.maxBufferHole*s),de=(i?g+i*s:this.nextAudioPts)-$.pts;de>ue?((v=de-le)<0?v=le:Y=!0,k.log("[mp4-remuxer]: It is approximately "+de/90+" ms to the next segment; using duration "+v/90+" ms for the last video frame.")):v=le}else v=le}var he=Math.round($.pts-$.dts);q=Math.min(q,v),X=Math.max(X,v),z=Math.min(z,se),Q=Math.max(Q,se),u.push(new oa($.key,v,ee,he))}if(u.length)if(ta){if(ta<70){var fe=u[0].flags;fe.dependsOn=2,fe.isNonSync=0}}else if(ra&&Q-z<X-q&&_/X<.025&&0===u[0].cts){k.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var ce=a,ve=0,ge=u.length;ve<ge;ve++){var me=ce+u[ve].duration,pe=ce+u[ve].cts;if(ve<ge-1){var ye=me+u[ve+1].cts;u[ve].duration=ye-pe}else u[ve].duration=ve?u[ve-1].duration:_;u[ve].cts=0,ce=me}}v=Y||!v?_:v,this.nextAvcDts=f=n+v,this.videoSampleDuration=v,this.isVideoContiguous=!0;var Ee={data1:Zi.moof(e.sequenceNumber++,a,o({},e,{samples:u})),data2:K,startPTS:g/s,endPTS:(m+v)/s,startDTS:a/s,endDTS:f/s,type:"video",hasAudio:!1,hasVideo:!0,nb:u.length,dropped:e.dropped};return e.samples=[],e.dropped=0,Ee},t.getSamplesPerFrame=function(e){switch(e.segmentCodec){case"mp3":return 1152;case"ac3":return 1536;default:return 1024}},t.remuxAudio=function(e,t,r,i,a){var n=e.inputTimeScale,s=n/(e.samplerate?e.samplerate:n),l=this.getSamplesPerFrame(e),u=l*s,d=this._initPTS,h="mp3"===e.segmentCodec&&this.typeSupported.mpeg,f=[],c=void 0!==a,v=e.samples,g=h?0:8,m=this.nextAudioPts||-1,p=t*n,y=d.baseTime*n/d.timescale;if(this.isAudioContiguous=r=r||v.length&&m>0&&(i&&Math.abs(p-m)<9e3||Math.abs(aa(v[0].pts-y,p)-m)<20*u),v.forEach((function(e){e.pts=aa(e.pts-y,p)})),!r||m<0){if(v=v.filter((function(e){return e.pts>=0})),!v.length)return;m=0===a?0:i&&!c?Math.max(0,p):v[0].pts}if("aac"===e.segmentCodec)for(var L=this.config.maxAudioFramesDrift,R=0,A=m;R<v.length;R++){var b=v[R],D=b.pts,_=D-A,x=Math.abs(1e3*_/n);if(_<=-L*u&&c)0===R&&(k.warn("Audio frame @ "+(D/n).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*_/n)+" ms."),this.nextAudioPts=m=A=D);else if(_>=L*u&&x<1e4&&c){var w=Math.round(_/u);(A=D-w*u)<0&&(w--,A+=u),0===R&&(this.nextAudioPts=m=A),k.warn("[mp4-remuxer]: Injecting "+w+" audio frame @ "+(A/n).toFixed(3)+"s due to "+Math.round(1e3*_/n)+" ms gap.");for(var C=0;C<w;C++){var I=Math.max(A,0),P=Ji.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);P||(k.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),P=b.unit.subarray()),v.splice(R,0,{unit:P,pts:I}),A+=u,R++}}b.pts=A,A+=u}for(var F,O=null,M=null,N=0,B=v.length;B--;)N+=v[B].unit.byteLength;for(var U=0,G=v.length;U<G;U++){var H=v[U],V=H.unit,K=H.pts;if(null!==M)f[U-1].duration=Math.round((K-M)/s);else{if(r&&"aac"===e.segmentCodec&&(K=m),O=K,!(N>0))return;N+=g;try{F=new Uint8Array(N)}catch(e){return void this.observer.emit(E.ERROR,E.ERROR,{type:T.MUX_ERROR,details:S.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:N,reason:"fail allocating audio mdat "+N})}h||(new DataView(F.buffer).setUint32(0,N),F.set(Zi.types.mdat,4))}F.set(V,g);var j=V.byteLength;g+=j,f.push(new oa(!0,l,j,0)),M=K}var W=f.length;if(W){var Y=f[f.length-1];this.nextAudioPts=m=M+s*Y.duration;var q=h?new Uint8Array(0):Zi.moof(e.sequenceNumber++,O/s,o({},e,{samples:f}));e.samples=[];var z=O/n,X=m/n,Q={data1:q,data2:F,startPTS:z,endPTS:X,startDTS:z,endDTS:X,type:"audio",hasAudio:!0,hasVideo:!1,nb:W};return this.isAudioContiguous=!0,Q}},t.remuxEmptyAudio=function(e,t,r,i){var a=e.inputTimeScale,n=a/(e.samplerate?e.samplerate:a),s=this.nextAudioPts,o=this._initDTS,l=9e4*o.baseTime/o.timescale,u=(null!==s?s:i.startDTS*a)+l,d=i.endDTS*a+l,h=1024*n,f=Math.ceil((d-u)/h),c=Ji.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(k.warn("[mp4-remuxer]: remux empty Audio"),c){for(var v=[],g=0;g<f;g++){var m=u+g*h;v.push({unit:c,pts:m,dts:m})}return e.samples=v,this.remuxAudio(e,t,r,!1)}k.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec")},e}();function aa(e,t){var r;if(null===t)return e;for(r=t<e?-8589934592:8589934592;Math.abs(e-t)>4294967296;)e+=r;return e}function na(e,t,r,i){var a=e.samples.length;if(a){for(var n=e.inputTimeScale,s=0;s<a;s++){var o=e.samples[s];o.pts=aa(o.pts-r.baseTime*n/r.timescale,t*n)/n,o.dts=aa(o.dts-i.baseTime*n/i.timescale,t*n)/n}var l=e.samples;return e.samples=[],{samples:l}}}function sa(e,t,r){var i=e.samples.length;if(i){for(var a=e.inputTimeScale,n=0;n<i;n++){var s=e.samples[n];s.pts=aa(s.pts-r.baseTime*a/r.timescale,t*a)/a}e.samples.sort((function(e,t){return e.pts-t.pts}));var o=e.samples;return e.samples=[],{samples:o}}}var oa=function(e,t,r,i){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=t,this.size=r,this.cts=i,this.flags={isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:e?2:1,isNonSync:e?0:1}},la=function(){function e(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null}var t=e.prototype;return t.destroy=function(){},t.resetTimeStamp=function(e){this.initPTS=e,this.lastEndTime=null},t.resetNextTimestamp=function(){this.lastEndTime=null},t.resetInitSegment=function(e,t,r,i){this.audioCodec=t,this.videoCodec=r,this.generateInitSegment(Re(e,i)),this.emitInitSegment=!0},t.generateInitSegment=function(e){var t=this.audioCodec,r=this.videoCodec;if(null==e||!e.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var i=this.initData=ye(e);i.audio&&(t=ua(i.audio,F)),i.video&&(r=ua(i.video,O));var a={};i.audio&&i.video?a.audiovideo={container:"video/mp4",codec:t+","+r,initSegment:e,id:"main"}:i.audio?a.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:i.video?a.video={container:"video/mp4",codec:r,initSegment:e,id:"main"}:k.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=a},t.remux=function(e,t,r,i,a,n){var s,o,l=this.initPTS,u=this.lastEndTime,d={audio:void 0,video:void 0,text:i,id3:r,initSegment:void 0};m(u)||(u=this.lastEndTime=a||0);var h=t.samples;if(null==h||!h.length)return d;var f={initPTS:void 0,timescale:1},c=this.initData;if(null!=(s=c)&&s.length||(this.generateInitSegment(h),c=this.initData),null==(o=c)||!o.length)return k.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),d;this.emitInitSegment&&(f.tracks=this.initTracks,this.emitInitSegment=!1);var v=function(e,t){for(var r=0,i=0,a=0,n=me(e,["moof","traf"]),s=0;s<n.length;s++){var o=n[s],l=me(o,["tfhd"])[0],u=t[fe(l,4)];if(u){var d=u.default,h=fe(l,0)|(null==d?void 0:d.flags),f=null==d?void 0:d.duration;8&h&&(f=fe(l,2&h?12:8));for(var c=u.timescale||9e4,v=me(o,["trun"]),g=0;g<v.length;g++)!(r=Ae(v[g]))&&f&&(r=f*fe(v[g],4)),u.type===O?i+=r/c:u.type===F&&(a+=r/c)}}if(0===i&&0===a){for(var p=1/0,y=0,E=0,T=me(e,["sidx"]),S=0;S<T.length;S++){var L=pe(T[S]);if(null!=L&&L.references){p=Math.min(p,L.earliestPresentationTime/L.timescale);var R=L.references.reduce((function(e,t){return e+t.info.duration||0}),0);E=(y=Math.max(y,R+L.earliestPresentationTime/L.timescale))-p}}if(E&&m(E))return E}return i||a}(h,c),g=function(e,t){return me(t,["moof","traf"]).reduce((function(t,r){var i=me(r,["tfdt"])[0],a=i[0],n=me(r,["tfhd"]).reduce((function(t,r){var n=fe(r,4),s=e[n];if(s){var o=fe(i,4);if(1===a){if(o===oe)return k.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),t;o*=oe+1,o+=fe(i,8)}var l=o/(s.timescale||9e4);if(m(l)&&(null===t||l<t))return l}return t}),null);return null!==n&&m(n)&&(null===t||n<t)?n:t}),null)}(c,h),p=null===g?a:g;(function(e,t,r,i){if(null===e)return!0;var a=Math.max(i,1),n=t-e.baseTime/e.timescale;return Math.abs(n-r)>a}(l,p,a,v)||f.timescale!==l.timescale&&n)&&(f.initPTS=p-a,l&&1===l.timescale&&k.warn("Adjusting initPTS by "+(f.initPTS-l.baseTime)),this.initPTS=l={baseTime:f.initPTS,timescale:1});var y=e?p-l.baseTime/l.timescale:u,E=y+v;(function(e,t,r){me(t,["moof","traf"]).forEach((function(t){me(t,["tfhd"]).forEach((function(i){var a=fe(i,4),n=e[a];if(n){var s=n.timescale||9e4;me(t,["tfdt"]).forEach((function(e){var t=e[0],i=r*s;if(i){var a=fe(e,4);if(0===t)a-=i,ge(e,4,a=Math.max(a,0));else{a*=Math.pow(2,32),a+=fe(e,8),a-=i,a=Math.max(a,0);var n=Math.floor(a/(oe+1)),o=Math.floor(a%(oe+1));ge(e,4,n),ge(e,8,o)}}}))}}))}))})(c,h,l.baseTime/l.timescale),v>0?this.lastEndTime=E:(k.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var T=!!c.audio,S=!!c.video,L="";T&&(L+="audio"),S&&(L+="video");var R={data1:h,startPTS:y,startDTS:y,endPTS:E,endDTS:E,type:L,hasAudio:T,hasVideo:S,nb:1,dropped:0};return d.audio="audio"===R.type?R:void 0,d.video="audio"!==R.type?R:void 0,d.initSegment=f,d.id3=na(r,a,l,l),i.samples.length&&(d.text=sa(i,a,l)),d},e}();function ua(e,t){var r=null==e?void 0:e.codec;if(r&&r.length>4)return r;if(t===F){if("ec-3"===r||"ac-3"===r||"alac"===r)return r;if("fLaC"===r||"Opus"===r)return Ge(r,!1);var i="mp4a.40.5";return k.info('Parsed audio codec "'+r+'" or audio object type not handled. Using "'+i+'"'),i}return k.warn('Unhandled video codec "'+r+'"'),"hvc1"===r||"hev1"===r?"hvc1.1.6.L120.90":"av01"===r?"av01.0.04M.08":"avc1.42e01e"}var da,ha="undefined"!=typeof self?self:void 0;try{da=self.performance.now.bind(self.performance)}catch(e){k.debug("Unable to use Performance API on this environment"),da=null==ha?void 0:ha.Date.now}var fa=[{demux:Ni,remux:la},{demux:Ki,remux:ia},{demux:Oi,remux:ia},{demux:Qi,remux:ia}],ca=function(){function e(e,t,r,i,a){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=e,this.typeSupported=t,this.config=r,this.vendor=i,this.id=a}var t=e.prototype;return t.configure=function(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()},t.push=function(e,t,r,i){var a=this,n=r.transmuxing;n.executeStart=da();var s=new Uint8Array(e),o=this.currentTransmuxState,l=this.transmuxConfig;i&&(this.currentTransmuxState=i);var u=i||o,d=u.contiguous,h=u.discontinuity,f=u.trackSwitch,c=u.accurateTimeOffset,v=u.timeOffset,g=u.initSegmentChange,m=l.audioCodec,p=l.videoCodec,y=l.defaultInitPts,L=l.duration,R=l.initSegmentData,A=function(e,t){var r=null;return e.byteLength>0&&null!=(null==t?void 0:t.key)&&null!==t.iv&&null!=t.method&&(r=t),r}(s,t);if(A&&"AES-128"===A.method){var b=this.getDecrypter();if(!b.isSync())return this.decryptionPromise=b.webCryptoDecrypt(s,A.key.buffer,A.iv.buffer).then((function(e){var t=a.push(e,null,r);return a.decryptionPromise=null,t})),this.decryptionPromise;var D=b.softwareDecrypt(s,A.key.buffer,A.iv.buffer);if(r.part>-1&&(D=b.flush()),!D)return n.executeEnd=da(),va(r);s=new Uint8Array(D)}var _=this.needsProbing(h,f);if(_){var x=this.configureTransmuxer(s);if(x)return k.warn("[transmuxer] "+x.message),this.observer.emit(E.ERROR,E.ERROR,{type:T.MEDIA_ERROR,details:S.FRAG_PARSING_ERROR,fatal:!1,error:x,reason:x.message}),n.executeEnd=da(),va(r)}(h||f||g||_)&&this.resetInitSegment(R,m,p,L,t),(h||g||_)&&this.resetInitialTimestamp(y),d||this.resetContiguity();var w=this.transmux(s,A,v,c,r),C=this.currentTransmuxState;return C.contiguous=!0,C.discontinuity=!1,C.trackSwitch=!1,n.executeEnd=da(),w},t.flush=function(e){var t=this,r=e.transmuxing;r.executeStart=da();var i=this.decrypter,a=this.currentTransmuxState,n=this.decryptionPromise;if(n)return n.then((function(){return t.flush(e)}));var s=[],o=a.timeOffset;if(i){var l=i.flush();l&&s.push(this.push(l,null,e))}var u=this.demuxer,d=this.remuxer;if(!u||!d)return r.executeEnd=da(),[va(e)];var h=u.flush(o);return ga(h)?h.then((function(r){return t.flushRemux(s,r,e),s})):(this.flushRemux(s,h,e),s)},t.flushRemux=function(e,t,r){var i=t.audioTrack,a=t.videoTrack,n=t.id3Track,s=t.textTrack,o=this.currentTransmuxState,l=o.accurateTimeOffset,u=o.timeOffset;k.log("[transmuxer.ts]: Flushed fragment "+r.sn+(r.part>-1?" p: "+r.part:"")+" of level "+r.level);var d=this.remuxer.remux(i,a,n,s,u,l,!0,this.id);e.push({remuxResult:d,chunkMeta:r}),r.transmuxing.executeEnd=da()},t.resetInitialTimestamp=function(e){var t=this.demuxer,r=this.remuxer;t&&r&&(t.resetTimeStamp(e),r.resetTimeStamp(e))},t.resetContiguity=function(){var e=this.demuxer,t=this.remuxer;e&&t&&(e.resetContiguity(),t.resetNextTimestamp())},t.resetInitSegment=function(e,t,r,i,a){var n=this.demuxer,s=this.remuxer;n&&s&&(n.resetInitSegment(e,t,r,i),s.resetInitSegment(e,t,r,a))},t.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},t.transmux=function(e,t,r,i,a){return t&&"SAMPLE-AES"===t.method?this.transmuxSampleAes(e,t,r,i,a):this.transmuxUnencrypted(e,r,i,a)},t.transmuxUnencrypted=function(e,t,r,i){var a=this.demuxer.demux(e,t,!1,!this.config.progressive),n=a.audioTrack,s=a.videoTrack,o=a.id3Track,l=a.textTrack;return{remuxResult:this.remuxer.remux(n,s,o,l,t,r,!1,this.id),chunkMeta:i}},t.transmuxSampleAes=function(e,t,r,i,a){var n=this;return this.demuxer.demuxSampleAes(e,t,r).then((function(e){return{remuxResult:n.remuxer.remux(e.audioTrack,e.videoTrack,e.id3Track,e.textTrack,r,i,!1,n.id),chunkMeta:a}}))},t.configureTransmuxer=function(e){for(var t,r=this.config,i=this.observer,a=this.typeSupported,n=this.vendor,s=0,o=fa.length;s<o;s++){var l;if(null!=(l=fa[s].demux)&&l.probe(e)){t=fa[s];break}}if(!t)return new Error("Failed to find demuxer by probing fragment data");var u=this.demuxer,d=this.remuxer,h=t.remux,f=t.demux;d&&d instanceof h||(this.remuxer=new h(i,r,a,n)),u&&u instanceof f||(this.demuxer=new f(i,r,a),this.probe=f.probe)},t.needsProbing=function(e,t){return!this.demuxer||!this.remuxer||e||t},t.getDecrypter=function(){var e=this.decrypter;return e||(e=this.decrypter=new Zr(this.config)),e},e}();var va=function(e){return{remuxResult:{},chunkMeta:e}};function ga(e){return"then"in e&&e.then instanceof Function}var ma=function(e,t,r,i,a){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=e,this.videoCodec=t,this.initSegmentData=r,this.duration=i,this.defaultInitPts=a||null},pa=function(e,t,r,i,a,n){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=e,this.contiguous=t,this.accurateTimeOffset=r,this.trackSwitch=i,this.timeOffset=a,this.initSegmentChange=n},ya={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,r="~";function i(){}function a(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function n(e,t,i,n,s){if("function"!=typeof i)throw new TypeError("The listener must be a function");var o=new a(i,n||e,s),l=r?r+t:t;return e._events[l]?e._events[l].fn?e._events[l]=[e._events[l],o]:e._events[l].push(o):(e._events[l]=o,e._eventsCount++),e}function s(e,t){0==--e._eventsCount?e._events=new i:delete e._events[t]}function o(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(r=!1)),o.prototype.eventNames=function(){var e,i,a=[];if(0===this._eventsCount)return a;for(i in e=this._events)t.call(e,i)&&a.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?a.concat(Object.getOwnPropertySymbols(e)):a},o.prototype.listeners=function(e){var t=r?r+e:e,i=this._events[t];if(!i)return[];if(i.fn)return[i.fn];for(var a=0,n=i.length,s=new Array(n);a<n;a++)s[a]=i[a].fn;return s},o.prototype.listenerCount=function(e){var t=r?r+e:e,i=this._events[t];return i?i.fn?1:i.length:0},o.prototype.emit=function(e,t,i,a,n,s){var o=r?r+e:e;if(!this._events[o])return!1;var l,u,d=this._events[o],h=arguments.length;if(d.fn){switch(d.once&&this.removeListener(e,d.fn,void 0,!0),h){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,t),!0;case 3:return d.fn.call(d.context,t,i),!0;case 4:return d.fn.call(d.context,t,i,a),!0;case 5:return d.fn.call(d.context,t,i,a,n),!0;case 6:return d.fn.call(d.context,t,i,a,n,s),!0}for(u=1,l=new Array(h-1);u<h;u++)l[u-1]=arguments[u];d.fn.apply(d.context,l)}else{var f,c=d.length;for(u=0;u<c;u++)switch(d[u].once&&this.removeListener(e,d[u].fn,void 0,!0),h){case 1:d[u].fn.call(d[u].context);break;case 2:d[u].fn.call(d[u].context,t);break;case 3:d[u].fn.call(d[u].context,t,i);break;case 4:d[u].fn.call(d[u].context,t,i,a);break;default:if(!l)for(f=1,l=new Array(h-1);f<h;f++)l[f-1]=arguments[f];d[u].fn.apply(d[u].context,l)}}return!0},o.prototype.on=function(e,t,r){return n(this,e,t,r,!1)},o.prototype.once=function(e,t,r){return n(this,e,t,r,!0)},o.prototype.removeListener=function(e,t,i,a){var n=r?r+e:e;if(!this._events[n])return this;if(!t)return s(this,n),this;var o=this._events[n];if(o.fn)o.fn!==t||a&&!o.once||i&&o.context!==i||s(this,n);else{for(var l=0,u=[],d=o.length;l<d;l++)(o[l].fn!==t||a&&!o[l].once||i&&o[l].context!==i)&&u.push(o[l]);u.length?this._events[n]=1===u.length?u[0]:u:s(this,n)}return this},o.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&s(this,t)):(this._events=new i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=r,o.EventEmitter=o,e.exports=o}(ya);var Ea=c(ya.exports);function Ta(e,t){if(!((r=t.remuxResult).audio||r.video||r.text||r.id3||r.initSegment))return!1;var r,i=[],a=t.remuxResult,n=a.audio,s=a.video;return n&&Sa(i,n),s&&Sa(i,s),e.postMessage({event:"transmuxComplete",data:t},i),!0}function Sa(e,t){t.data1&&e.push(t.data1.buffer),t.data2&&e.push(t.data2.buffer)}function La(e,t,r){t.reduce((function(t,r){return Ta(e,r)||t}),!1)||e.postMessage({event:"transmuxComplete",data:t[0]}),e.postMessage({event:"flush",data:r})}void 0!==r&&r&&function(e){var t=new Ea,r=function(t,r){e.postMessage({event:t,data:r})};t.on(E.FRAG_DECRYPTED,r),t.on(E.ERROR,r),e.addEventListener("message",(function(i){var a=i.data;switch(a.cmd){case"init":var n=JSON.parse(a.config);e.transmuxer=new ca(t,a.typeSupported,n,"",a.id),D(n.debug,a.id),function(){var e=function(e){k[e]=function(t){r("workerLog",{logType:e,message:t})}};for(var t in k)e(t)}(),r("init",null);break;case"configure":e.transmuxer.configure(a.config);break;case"demux":var s=e.transmuxer.push(a.data,a.decryptdata,a.chunkMeta,a.state);ga(s)?(e.transmuxer.async=!0,s.then((function(t){Ta(e,t)})).catch((function(e){r(E.ERROR,{type:T.MEDIA_ERROR,details:S.FRAG_PARSING_ERROR,chunkMeta:a.chunkMeta,fatal:!1,error:e,err:e,reason:"transmuxer-worker push error"})}))):(e.transmuxer.async=!1,Ta(e,s));break;case"flush":var o=a.chunkMeta,l=e.transmuxer.flush(o);ga(l)||e.transmuxer.async?(ga(l)||(l=Promise.resolve(l)),l.then((function(t){La(e,t,o)})).catch((function(e){r(E.ERROR,{type:T.MEDIA_ERROR,details:S.FRAG_PARSING_ERROR,chunkMeta:a.chunkMeta,fatal:!1,error:e,err:e,reason:"transmuxer-worker flush error"})}))):La(e,l,o)}}))}(self);var Ra=function(){function e(e,r,i,a){var n=this;this.error=null,this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;var s=e.config;this.hls=e,this.id=r,this.useWorker=!!s.enableWorker,this.onTransmuxComplete=i,this.onFlush=a;var o=function(e,t){(t=t||{}).frag=n.frag,t.id=n.id,e===E.ERROR&&(n.error=t.error),n.hls.trigger(e,t)};this.observer=new Ea,this.observer.on(E.FRAG_DECRYPTED,o),this.observer.on(E.ERROR,o);var l,u,d,h,f=Ce(s.preferManagedMediaSource)||{isTypeSupported:function(){return!1}},c={mpeg:f.isTypeSupported("audio/mpeg"),mp3:f.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:!1};if(this.useWorker&&"undefined"!=typeof Worker&&(s.workerPath,1))try{s.workerPath?(k.log("loading Web Worker "+s.workerPath+' for "'+r+'"'),this.workerContext=(d=s.workerPath,h=new self.URL(d,self.location.href).href,{worker:new self.Worker(h),scriptURL:h})):(k.log('injecting Web Worker for "'+r+'"'),this.workerContext=(l=new self.Blob(["var exports={};var module={exports:exports};function define(f){f()};define.amd=true;("+t.toString()+")(true);"],{type:"text/javascript"}),u=self.URL.createObjectURL(l),{worker:new self.Worker(u),objectURL:u})),this.onwmsg=function(e){return n.onWorkerMessage(e)};var v=this.workerContext.worker;v.addEventListener("message",this.onwmsg),v.onerror=function(e){var t=new Error(e.message+" ("+e.filename+":"+e.lineno+")");s.enableWorker=!1,k.warn('Error in "'+r+'" Web Worker, fallback to inline'),n.hls.trigger(E.ERROR,{type:T.OTHER_ERROR,details:S.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:t})},v.postMessage({cmd:"init",typeSupported:c,vendor:"",id:r,config:JSON.stringify(s)})}catch(e){k.warn('Error setting up "'+r+'" Web Worker, fallback to inline',e),this.resetWorker(),this.error=null,this.transmuxer=new ca(this.observer,c,s,"",r)}else this.transmuxer=new ca(this.observer,c,s,"",r)}var r=e.prototype;return r.resetWorker=function(){if(this.workerContext){var e=this.workerContext,t=e.worker,r=e.objectURL;r&&self.URL.revokeObjectURL(r),t.removeEventListener("message",this.onwmsg),t.onerror=null,t.terminate(),this.workerContext=null}},r.destroy=function(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{var e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}var t=this.observer;t&&t.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},r.push=function(e,t,r,i,a,n,s,o,l,u){var d,h,f=this;l.transmuxing.start=self.performance.now();var c=this.transmuxer,v=n?n.start:a.start,g=a.decryptdata,m=this.frag,p=!(m&&a.cc===m.cc),y=!(m&&l.level===m.level),E=m?l.sn-m.sn:-1,T=this.part?l.part-this.part.index:-1,S=0===E&&l.id>1&&l.id===(null==m?void 0:m.stats.chunkCount),L=!y&&(1===E||0===E&&(1===T||S&&T<=0)),R=self.performance.now();(y||E||0===a.stats.parsing.start)&&(a.stats.parsing.start=R),!n||!T&&L||(n.stats.parsing.start=R);var A=!(m&&(null==(d=a.initSegment)?void 0:d.url)===(null==(h=m.initSegment)?void 0:h.url)),b=new pa(p,L,o,y,v,A);if(!L||p||A){k.log("[transmuxer-interface, "+a.type+"]: Starting new transmux session for sn: "+l.sn+" p: "+l.part+" level: "+l.level+" id: "+l.id+"\n discontinuity: "+p+"\n trackSwitch: "+y+"\n contiguous: "+L+"\n accurateTimeOffset: "+o+"\n timeOffset: "+v+"\n initSegmentChange: "+A);var D=new ma(r,i,t,s,u);this.configureTransmuxer(D)}if(this.frag=a,this.part=n,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:g,chunkMeta:l,state:b},e instanceof ArrayBuffer?[e]:[]);else if(c){var _=c.push(e,g,l,b);ga(_)?(c.async=!0,_.then((function(e){f.handleTransmuxComplete(e)})).catch((function(e){f.transmuxerError(e,l,"transmuxer-interface push error")}))):(c.async=!1,this.handleTransmuxComplete(_))}},r.flush=function(e){var t=this;e.transmuxing.start=self.performance.now();var r=this.transmuxer;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:e});else if(r){var i=r.flush(e);ga(i)||r.async?(ga(i)||(i=Promise.resolve(i)),i.then((function(r){t.handleFlushResult(r,e)})).catch((function(r){t.transmuxerError(r,e,"transmuxer-interface flush error")}))):this.handleFlushResult(i,e)}},r.transmuxerError=function(e,t,r){this.hls&&(this.error=e,this.hls.trigger(E.ERROR,{type:T.MEDIA_ERROR,details:S.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,fatal:!1,error:e,err:e,reason:r}))},r.handleFlushResult=function(e,t){var r=this;e.forEach((function(e){r.handleTransmuxComplete(e)})),this.onFlush(t)},r.onWorkerMessage=function(e){var t=e.data;if(null!=t&&t.event){var r=this.hls;if(this.hls)switch(t.event){case"init":var i,a=null==(i=this.workerContext)?void 0:i.objectURL;a&&self.URL.revokeObjectURL(a);break;case"transmuxComplete":this.handleTransmuxComplete(t.data);break;case"flush":this.onFlush(t.data);break;case"workerLog":k[t.data.logType]&&k[t.data.logType](t.data.message);break;default:t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,r.trigger(t.event,t.data)}}else k.warn("worker message received with no "+(t?"event name":"data"))},r.configureTransmuxer=function(e){var t=this.transmuxer;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:e}):t&&t.configure(e)},r.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},e}(),Aa=function(){function e(e,t,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=e,this.media=t,this.fragmentTracker=r,this.hls=i}var t=e.prototype;return t.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},t.poll=function(e,t){var r=this.config,i=this.media,a=this.stalled;if(null!==i){var n=i.currentTime,s=i.seeking,o=this.seeking&&!s,l=!this.seeking&&s;if(this.seeking=s,n===e)if(l||o)this.stalled=null;else if(i.paused&&!s||i.ended||0===i.playbackRate||!lr.getBuffered(i).length)this.nudgeRetry=0;else{var u=lr.bufferInfo(i,n,0),d=u.nextStart||0;if(s){var h=u.len>2,f=!d||t&&t.start<=n||d-n>2&&!this.fragmentTracker.getPartialFragment(n);if(h||f)return;this.moved=!1}if(!this.moved&&null!==this.stalled){var c;if(!(u.len>0||d))return;var v=Math.max(d,u.start||0)-n,g=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,m=(null==g||null==(c=g.details)?void 0:c.live)?2*g.details.targetduration:2,p=this.fragmentTracker.getPartialFragment(n);if(v>0&&(v<=m||p))return void(i.paused||this._trySkipBufferHole(p))}var y=self.performance.now();if(null!==a){var E=y-a;if(s||!(E>=250)||(this._reportStall(u),this.media)){var T=lr.bufferInfo(i,n,r.maxBufferHole);this._tryFixBufferStall(T,E)}}else this.stalled=y}else if(this.moved=!0,s||(this.nudgeRetry=0),null!==a){if(this.stallReported){var S=self.performance.now()-a;k.warn("playback not stuck anymore @"+n+", after "+Math.round(S)+"ms"),this.stallReported=!1}this.stalled=null}}},t._tryFixBufferStall=function(e,t){var r=this.config,i=this.fragmentTracker,a=this.media;if(null!==a){var n=a.currentTime,s=i.getPartialFragment(n);if(s&&(this._trySkipBufferHole(s)||!this.media))return;(e.len>r.maxBufferHole||e.nextStart&&e.nextStart-n<r.maxBufferHole)&&t>1e3*r.highBufferWatchdogPeriod&&(k.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},t._reportStall=function(e){var t=this.hls,r=this.media;if(!this.stallReported&&r){this.stallReported=!0;var i=new Error("Playback stalling at @"+r.currentTime+" due to low buffer ("+JSON.stringify(e)+")");k.warn(i.message),t.trigger(E.ERROR,{type:T.MEDIA_ERROR,details:S.BUFFER_STALLED_ERROR,fatal:!1,error:i,buffer:e.len})}},t._trySkipBufferHole=function(e){var t=this.config,r=this.hls,i=this.media;if(null===i)return 0;var a=i.currentTime,n=lr.bufferInfo(i,a,0),s=a<n.start?n.start:n.nextStart;if(s){var o=n.len<=t.maxBufferHole,l=n.len>0&&n.len<1&&i.readyState<3,u=s-a;if(u>0&&(o||l)){if(u>t.maxBufferHole){var d=this.fragmentTracker,h=!1;if(0===a){var f=d.getAppendedFrag(0,nt);f&&s<f.end&&(h=!0)}if(!h){var c=e||d.getAppendedFrag(a,nt);if(c){for(var v=!1,g=c.end;g<s;){var m=d.getPartialFragment(g);if(!m){v=!0;break}g+=m.duration}if(v)return 0}}}var p=Math.max(s+.05,a+.1);if(k.warn("skipping hole, adjusting currentTime from "+a+" to "+p),this.moved=!0,this.stalled=null,i.currentTime=p,e&&!e.gap){var y=new Error("fragment loaded with buffer holes, seeking from "+a+" to "+p);r.trigger(E.ERROR,{type:T.MEDIA_ERROR,details:S.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:y,reason:y.message,frag:e})}return p}}return 0},t._tryNudgeBuffer=function(){var e=this.config,t=this.hls,r=this.media,i=this.nudgeRetry;if(null!==r){var a=r.currentTime;if(this.nudgeRetry++,i<e.nudgeMaxRetry){var n=a+(i+1)*e.nudgeOffset,s=new Error("Nudging 'currentTime' from "+a+" to "+n);k.warn(s.message),r.currentTime=n,t.trigger(E.ERROR,{type:T.MEDIA_ERROR,details:S.BUFFER_NUDGE_ON_STALL,error:s,fatal:!1})}else{var o=new Error("Playhead still not moving while enough data buffered @"+a+" after "+e.nudgeMaxRetry+" nudges");k.error(o.message),t.trigger(E.ERROR,{type:T.MEDIA_ERROR,details:S.BUFFER_STALLED_ERROR,error:o,fatal:!0})}}},e}(),ba=function(e){function t(t,r,i){var a;return(a=e.call(this,t,r,i,"[stream-controller]",nt)||this).audioCodecSwap=!1,a.gapController=null,a.level=-1,a._forceStartLoad=!1,a.altAudio=!1,a.audioOnly=!1,a.fragPlaying=null,a.onvplaying=null,a.onvseeked=null,a.fragLastKbps=0,a.couldBacktrack=!1,a.backtrackFragment=null,a.audioCodecSwitch=!1,a.videoBuffer=null,a._registerListeners(),a}l(t,e);var r=t.prototype;return r._registerListeners=function(){var e=this.hls;e.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_PARSED,this.onManifestParsed,this),e.on(E.LEVEL_LOADING,this.onLevelLoading,this),e.on(E.LEVEL_LOADED,this.onLevelLoaded,this),e.on(E.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(E.ERROR,this.onError,this),e.on(E.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(E.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(E.BUFFER_CREATED,this.onBufferCreated,this),e.on(E.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(E.FRAG_BUFFERED,this.onFragBuffered,this)},r._unregisterListeners=function(){var e=this.hls;e.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_PARSED,this.onManifestParsed,this),e.off(E.LEVEL_LOADED,this.onLevelLoaded,this),e.off(E.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(E.ERROR,this.onError,this),e.off(E.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(E.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(E.BUFFER_CREATED,this.onBufferCreated,this),e.off(E.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(E.FRAG_BUFFERED,this.onFragBuffered,this)},r.onHandlerDestroying=function(){this._unregisterListeners(),e.prototype.onHandlerDestroying.call(this)},r.startLoad=function(e){if(this.levels){var t=this.lastCurrentTime,r=this.hls;if(this.stopLoad(),this.setInterval(100),this.level=-1,!this.startFragRequested){var i=r.startLevel;-1===i&&(r.config.testBandwidth&&this.levels.length>1?(i=0,this.bitrateTest=!0):i=r.firstAutoLevel),r.nextLoadLevel=i,this.level=r.loadLevel,this.loadedmetadata=!1}t>0&&-1===e&&(this.log("Override startPosition with lastCurrentTime @"+t.toFixed(3)),e=t),this.state=ri,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this._forceStartLoad=!0,this.state=ti},r.stopLoad=function(){this._forceStartLoad=!1,e.prototype.stopLoad.call(this)},r.doTick=function(){switch(this.state){case di:var e=this.levels,t=this.level,r=null==e?void 0:e[t],i=null==r?void 0:r.details;if(i&&(!i.live||this.levelLastLoaded===r)){if(this.waitForCdnTuneIn(i))break;this.state=ri;break}if(this.hls.nextLoadLevel!==this.level){this.state=ri;break}break;case ni:var a,n=self.performance.now(),s=this.retryDate;if(!s||n>=s||null!=(a=this.media)&&a.seeking){var o=this.levels,l=this.level,u=null==o?void 0:o[l];this.resetStartWhenNotLoaded(u||null),this.state=ri}}this.state===ri&&this.doTickIdle(),this.onTickEnd()},r.onTickEnd=function(){e.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},r.doTickIdle=function(){var e=this.hls,t=this.levelLastLoaded,r=this.levels,i=this.media;if(null!==t&&(i||!this.startFragRequested&&e.config.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)){var a=e.nextLoadLevel;if(null!=r&&r[a]){var n=r[a],s=this.getMainFwdBufferInfo();if(null!==s){var o=this.getLevelDetails();if(o&&this._streamEnded(s,o)){var l={};return this.altAudio&&(l.type="video"),this.hls.trigger(E.BUFFER_EOS,l),void(this.state=li)}e.loadLevel!==a&&-1===e.manualLevel&&this.log("Adapting to level "+a+" from level "+this.level),this.level=e.nextLoadLevel=a;var u=n.details;if(!u||this.state===di||u.live&&this.levelLastLoaded!==n)return this.level=a,void(this.state=di);var d=s.len,h=this.getMaxBufferLength(n.maxBitrate);if(!(d>=h)){this.backtrackFragment&&this.backtrackFragment.start>s.end&&(this.backtrackFragment=null);var f=this.backtrackFragment?this.backtrackFragment.start:s.end,c=this.getNextFragment(f,u);if(this.couldBacktrack&&!this.fragPrevious&&c&&"initSegment"!==c.sn&&this.fragmentTracker.getState(c)!==Fr){var v,g=(null!=(v=this.backtrackFragment)?v:c).sn-u.startSN,m=u.fragments[g-1];m&&c.cc===m.cc&&(c=m,this.fragmentTracker.removeFragment(m))}else this.backtrackFragment&&s.len&&(this.backtrackFragment=null);if(c&&this.isLoopLoading(c,f)){if(!c.gap){var p=this.audioOnly&&!this.altAudio?F:O,y=(p===O?this.videoBuffer:this.mediaBuffer)||this.media;y&&this.afterBufferFlushed(y,p,nt)}c=this.getNextFragmentLoopLoading(c,u,s,nt,h)}c&&(!c.initSegment||c.initSegment.data||this.bitrateTest||(c=c.initSegment),this.loadFragment(c,n,f))}}}}},r.loadFragment=function(t,r,i){var a=this.fragmentTracker.getState(t);this.fragCurrent=t,a===Cr||a===Pr?"initSegment"===t.sn?this._loadInitSegment(t,r):this.bitrateTest?(this.log("Fragment "+t.sn+" of level "+t.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(t,r)):(this.startFragRequested=!0,e.prototype.loadFragment.call(this,t,r,i)):this.clearTrackerIfNeeded(t)},r.getBufferedFrag=function(e){return this.fragmentTracker.getBufferedFrag(e,nt)},r.followingBufferedFrag=function(e){return e?this.getBufferedFrag(e.end+.5):null},r.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},r.nextLevelSwitch=function(){var e=this.levels,t=this.media;if(null!=t&&t.readyState){var r,i=this.getAppendedFrag(t.currentTime);i&&i.start>1&&this.flushMainBuffer(0,i.start-1);var a=this.getLevelDetails();if(null!=a&&a.live){var n=this.getMainFwdBufferInfo();if(!n||n.len<2*a.targetduration)return}if(!t.paused&&e){var s=e[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(t.currentTime+r);if(l){var u=this.followingBufferedFrag(l);if(u){this.abortCurrentFrag();var d=u.maxStartPTS?u.maxStartPTS:u.start,h=u.duration,f=Math.max(l.end,d+Math.min(Math.max(h-this.config.maxFragLookUpTolerance,h*(this.couldBacktrack?.5:.125)),h*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(f,Number.POSITIVE_INFINITY)}}}},r.abortCurrentFrag=function(){var e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case ii:case ai:case ni:case si:case oi:this.state=ri}this.nextLoadPosition=this.getLoadPosition()},r.flushMainBuffer=function(t,r){e.prototype.flushMainBuffer.call(this,t,r,this.altAudio?"video":null)},r.onMediaAttached=function(t,r){e.prototype.onMediaAttached.call(this,t,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 Aa(this.config,i,this.fragmentTracker,this.hls)},r.onMediaDetaching=function(){var t=this.media;t&&this.onvplaying&&this.onvseeked&&(t.removeEventListener("playing",this.onvplaying),t.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),e.prototype.onMediaDetaching.call(this)},r.onMediaPlaying=function(){this.tick()},r.onMediaSeeked=function(){var e=this.media,t=e?e.currentTime:null;m(t)&&this.log("Media seeked to "+t.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")+")")},r.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(E.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=this.fragLastKbps=0,this.levels=this.fragPlaying=this.backtrackFragment=this.levelLastLoaded=null,this.altAudio=this.audioOnly=this.startFragRequested=!1},r.onManifestParsed=function(e,t){var r,i,a=!1,n=!1;t.levels.forEach((function(e){var t=e.audioCodec;t&&(a=a||-1!==t.indexOf("mp4a.40.2"),n=n||-1!==t.indexOf("mp4a.40.5"))})),this.audioCodecSwitch=a&&n&&!("function"==typeof(null==(i=fi())||null==(r=i.prototype)?void 0:r.changeType)),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1},r.onLevelLoading=function(e,t){var r=this.levels;if(r&&this.state===ri){var i=r[t.level];(!i.details||i.details.live&&this.levelLastLoaded!==i||this.waitForCdnTuneIn(i.details))&&(this.state=di)}},r.onLevelLoaded=function(e,t){var r,i=this.levels,a=t.level,n=t.details,s=n.totalduration;if(i){this.log("Level "+a+" loaded ["+n.startSN+","+n.endSN+"]"+(n.lastPartSn?"[part-"+n.lastPartSn+"-"+n.lastPartIndex+"]":"")+", cc ["+n.startCC+", "+n.endCC+"] duration:"+s);var o=i[a],l=this.fragCurrent;!l||this.state!==ai&&this.state!==ni||l.level!==t.level&&l.loader&&this.abortCurrentFrag();var u=0;if(n.live||null!=(r=o.details)&&r.live){var d;if(this.checkLiveUpdate(n),n.deltaUpdateFailed)return;u=this.alignPlaylists(n,o.details,null==(d=this.levelLastLoaded)?void 0:d.details)}if(o.details=n,this.levelLastLoaded=o,this.hls.trigger(E.LEVEL_UPDATED,{details:n,level:a}),this.state===di){if(this.waitForCdnTuneIn(n))return;this.state=ri}this.startFragRequested?n.live&&this.synchronizeToLiveEdge(n):this.setStartPosition(n,u),this.tick()}else this.warn("Levels were reset while loading level "+a)},r._handleFragmentLoadProgress=function(e){var t,r=e.frag,i=e.part,a=e.payload,n=this.levels;if(n){var s=n[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,d=null==(t=r.initSegment)?void 0:t.data,h=this._getAudioCodec(s),f=this.transmuxer=this.transmuxer||new Ra(this.hls,nt,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),c=i?i.index:-1,v=-1!==c,g=new Wr(r.level,r.sn,r.stats.chunkCount,a.byteLength,c,v),m=this.initPTS[r.cc];f.push(a,d,h,l,r,i,o.totalduration,u,g,m)}else this.warn("Levels were reset while fragment load was in progress. Fragment "+r.sn+" of level "+r.level+" will not be buffered")},r.onAudioTrackSwitching=function(e,t){var r=this.altAudio;if(!t.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 a=this.hls;r&&(a.trigger(E.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),a.trigger(E.AUDIO_TRACK_SWITCHED,t)}},r.onAudioTrackSwitched=function(e,t){var r=t.id,i=!!this.hls.audioTracks[r].url;if(i){var a=this.videoBuffer;a&&this.mediaBuffer!==a&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=a)}this.altAudio=i,this.tick()},r.onBufferCreated=function(e,t){var r,i,a=t.tracks,n=!1;for(var s in a){var o=a[s];if("main"===o.id){if(i=s,r=o,"video"===s){var l=a[s];l&&(this.videoBuffer=l.buffer)}}else n=!0}n&&r?(this.log("Alternate track found, use "+i+".buffered to schedule main fragment loading"),this.mediaBuffer=r.buffer):this.mediaBuffer=this.media},r.onFragBuffered=function(e,t){var r=t.frag,i=t.part;if(!r||r.type===nt){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===oi&&(this.state=ri));var a=i?i.stats:r.stats;this.fragLastKbps=Math.round(8*a.total/(a.buffering.end-a.loading.first)),"initSegment"!==r.sn&&(this.fragPrevious=r),this.fragBufferedComplete(r,i)}},r.onError=function(e,t){var r;if(t.fatal)this.state=ui;else switch(t.details){case S.FRAG_GAP:case S.FRAG_PARSING_ERROR:case S.FRAG_DECRYPT_ERROR:case S.FRAG_LOAD_ERROR:case S.FRAG_LOAD_TIMEOUT:case S.KEY_LOAD_ERROR:case S.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(nt,t);break;case S.LEVEL_LOAD_ERROR:case S.LEVEL_LOAD_TIMEOUT:case S.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==di||(null==(r=t.context)?void 0:r.type)!==rt||(this.state=ri);break;case S.BUFFER_APPEND_ERROR:case S.BUFFER_FULL_ERROR:if(!t.parent||"main"!==t.parent)return;if(t.details===S.BUFFER_APPEND_ERROR)return void this.resetLoadingState();this.reduceLengthAndFlushBuffer(t)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case S.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}},r.checkBuffer=function(){var e=this.media,t=this.gapController;if(e&&t&&e.readyState){if(this.loadedmetadata||!lr.getBuffered(e).length){var r=this.state!==ri?this.fragCurrent:null;t.poll(this.lastCurrentTime,r)}this.lastCurrentTime=e.currentTime}},r.onFragLoadEmergencyAborted=function(){this.state=ri,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},r.onBufferFlushed=function(e,t){var r=t.type;if(r!==F||this.audioOnly&&!this.altAudio){var i=(r===O?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(i,r,nt),this.tick()}},r.onLevelsUpdated=function(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level),this.levels=t.levels},r.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},r.seekToStartPos=function(){var e=this.media;if(e){var t=e.currentTime,r=this.startPosition;if(r>=0&&t<r){if(e.seeking)return void this.log("could not seek to "+r+", already seeking at "+t);var i=lr.getBuffered(e),a=(i.length?i.start(0):0)-r;a>0&&(a<this.config.maxBufferHole||a<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+a+" to match buffer start"),r+=a,this.startPosition=r),this.log("seek to target start position "+r+" from current time "+t),e.currentTime=r}}},r._getAudioCodec=function(e){var t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t=-1!==t.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),t},r._loadBitrateTestFrag=function(e,t){var r=this;e.bitrateTest=!0,this._doFragLoad(e,t).then((function(i){var a=r.hls;if(i&&!r.fragContextChanged(e)){t.fragmentError=0,r.state=ri,r.startFragRequested=!1,r.bitrateTest=!1;var n=e.stats;n.parsing.start=n.parsing.end=n.buffering.start=n.buffering.end=self.performance.now(),a.trigger(E.FRAG_LOADED,i),e.bitrateTest=!1}}))},r._handleTransmuxComplete=function(e){var t,r="main",i=this.hls,a=e.remuxResult,n=e.chunkMeta,s=this.getCurrentContext(n);if(s){var o=s.frag,l=s.part,u=s.level,d=a.video,h=a.text,f=a.id3,c=a.initSegment,v=u.details,g=this.altAudio?void 0:a.audio;if(this.fragContextChanged(o))this.fragmentTracker.removeFragment(o);else{if(this.state=si,c){if(null!=c&&c.tracks){var p=o.initSegment||o;this._bufferInitSegment(u,c.tracks,p,n),i.trigger(E.FRAG_PARSING_INIT_SEGMENT,{frag:p,id:r,tracks:c.tracks})}var y=c.initPTS,T=c.timescale;m(y)&&(this.initPTS[o.cc]={baseTime:y,timescale:T},i.trigger(E.INIT_PTS_FOUND,{frag:o,id:r,initPTS:y,timescale:T}))}if(d&&v&&"initSegment"!==o.sn){var S=v.fragments[o.sn-1-v.startSN],L=o.sn===v.startSN,R=!S||o.cc>S.cc;if(!1!==a.independent){var A=d.startPTS,b=d.endPTS,D=d.startDTS,k=d.endDTS;if(l)l.elementaryStreams[d.type]={startPTS:A,endPTS:b,startDTS:D,endDTS:k};else if(d.firstKeyFrame&&d.independent&&1===n.id&&!R&&(this.couldBacktrack=!0),d.dropped&&d.independent){var _=this.getMainFwdBufferInfo(),x=(_?_.end:this.getLoadPosition())+this.config.maxBufferHole,w=d.firstKeyFramePTS?d.firstKeyFramePTS:A;if(!L&&x<w-this.config.maxBufferHole&&!R)return void this.backtrack(o);R&&(o.gap=!0),o.setElementaryStreamInfo(d.type,o.start,b,o.start,k,!0)}else L&&A>2&&(o.gap=!0);o.setElementaryStreamInfo(d.type,A,b,D,k),this.backtrackFragment&&(this.backtrackFragment=o),this.bufferFragmentData(d,o,l,n,L||R)}else{if(!L&&!R)return void this.backtrack(o);o.gap=!0}}if(g){var C=g.startPTS,I=g.endPTS,P=g.startDTS,O=g.endDTS;l&&(l.elementaryStreams[F]={startPTS:C,endPTS:I,startDTS:P,endDTS:O}),o.setElementaryStreamInfo(F,C,I,P,O),this.bufferFragmentData(g,o,l,n)}if(v&&null!=f&&null!=(t=f.samples)&&t.length){var M={id:r,frag:o,details:v,samples:f.samples};i.trigger(E.FRAG_PARSING_METADATA,M)}if(v&&h){var N={id:r,frag:o,details:v,samples:h.samples};i.trigger(E.FRAG_PARSING_USERDATA,N)}}}else this.resetWhenMissingContext(n)},r._bufferInitSegment=function(e,t,r,i){var a=this;if(this.state===si){this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&delete t.audio;var n=t.audio,s=t.video,o=t.audiovideo;if(n){var l=e.audioCodec,u=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){l&&(l=-1!==l.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5");var d=n.metadata;d&&"channelCount"in d&&1!==(d.channelCount||1)&&-1===u.indexOf("firefox")&&(l="mp4a.40.5")}l&&-1!==l.indexOf("mp4a.40.5")&&-1!==u.indexOf("android")&&"audio/mpeg"!==n.container&&(l="mp4a.40.2",this.log("Android: force audio codec to "+l)),e.audioCodec&&e.audioCodec!==l&&this.log('Swapping manifest audio codec "'+e.audioCodec+'" for "'+l+'"'),n.levelCodec=l,n.id="main",this.log("Init audio buffer, container:"+n.container+", codecs[selected/level/parsed]=["+(l||"")+"/"+(e.audioCodec||"")+"/"+n.codec+"]")}s&&(s.levelCodec=e.videoCodec,s.id="main",this.log("Init video buffer, container:"+s.container+", codecs[level/parsed]=["+(e.videoCodec||"")+"/"+s.codec+"]")),o&&this.log("Init audiovideo buffer, container:"+o.container+", codecs[level/parsed]=["+e.codecs+"/"+o.codec+"]"),this.hls.trigger(E.BUFFER_CODECS,t),Object.keys(t).forEach((function(e){var n=t[e].initSegment;null!=n&&n.byteLength&&a.hls.trigger(E.BUFFER_APPENDING,{type:e,data:n,frag:r,part:null,chunkMeta:i,parent:r.type})})),this.tickImmediate()}},r.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,nt)},r.backtrack=function(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=ri},r.checkFragmentChanged=function(){var e=this.media,t=null;if(e&&e.readyState>1&&!1===e.seeking){var r=e.currentTime;if(lr.isBuffered(e,r)?t=this.getAppendedFrag(r):lr.isBuffered(e,r+.1)&&(t=this.getAppendedFrag(r+.1)),t){this.backtrackFragment=null;var i=this.fragPlaying,a=t.level;i&&t.sn===i.sn&&i.level===a||(this.fragPlaying=t,this.hls.trigger(E.FRAG_CHANGED,{frag:t}),i&&i.level===a||this.hls.trigger(E.LEVEL_SWITCHED,{level:a}))}}},s(t,[{key:"nextLevel",get:function(){var e=this.nextBufferedFrag;return e?e.level:-1}},{key:"currentFrag",get:function(){var e=this.media;return e?this.fragPlaying||this.getAppendedFrag(e.currentTime):null}},{key:"currentProgramDateTime",get:function(){var e=this.media;if(e){var t=e.currentTime,r=this.currentFrag;if(r&&m(t)&&m(r.programDateTime)){var i=r.programDateTime+1e3*(t-r.start);return new Date(i)}}return null}},{key:"currentLevel",get:function(){var e=this.currentFrag;return e?e.level:-1}},{key:"nextBufferedFrag",get:function(){var e=this.currentFrag;return e?this.followingBufferedFrag(e):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),t}(hi),Da=function(){function e(t){void 0===t&&(t={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this.started=!1,this._emitter=new Ea,this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null,this.triggeringException=void 0,D(t.debug||!1,"Hls instance");var r=this.config=function(e,t){if((t.liveSyncDurationCount||t.liveMaxLatencyDurationCount)&&(t.liveSyncDuration||t.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==t.liveMaxLatencyDurationCount&&(void 0===t.liveSyncDurationCount||t.liveMaxLatencyDurationCount<=t.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==t.liveMaxLatencyDuration&&(void 0===t.liveSyncDuration||t.liveMaxLatencyDuration<=t.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');var r=kr(e),a=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach((function(e){var i=("level"===e?"playlist":e)+"LoadPolicy",n=void 0===t[i],s=[];a.forEach((function(a){var o=e+"Loading"+a,l=t[o];if(void 0!==l&&n){s.push(o);var u=r[i].default;switch(t[i]={default:u},a){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&&k.warn('hls.js config: "'+s.join('", "')+'" setting(s) are deprecated, use "'+i+'": '+JSON.stringify(t[i]))})),i(i({},r),t)}(e.DefaultConfig,t);this.userConfig=t,r.progressive&&_r(r);var a=r.abrController,n=r.bufferController,s=r.capLevelController,o=r.errorController,l=r.fpsController,u=new o(this),d=this.abrController=new a(this),h=this.bufferController=new n(this),f=this.capLevelController=new s(this),c=new l(this),v=new dt(this),g=new Tt(this),m=r.contentSteeringController,p=m?new m(this):null,y=this.levelController=new xr(this,p),T=new Or(this),S=new Kr(this.config),L=this.streamController=new ba(this,T,S);f.setStreamController(L),c.setStreamController(L);var R=[v,y,L];p&&R.splice(1,0,p),this.networkControllers=R;var A=[d,h,f,c,g,T];this.audioTrackController=this.createController(r.audioTrackController,R);var b=r.audioStreamController;b&&R.push(new b(this,T,S)),this.subtitleTrackController=this.createController(r.subtitleTrackController,R);var _=r.subtitleStreamController;_&&R.push(new _(this,T,S)),this.createController(r.timelineController,A),S.emeController=this.emeController=this.createController(r.emeController,A),this.cmcdController=this.createController(r.cmcdController,A),this.latencyController=this.createController(St,A),this.coreComponents=A,R.push(u);var x=u.onErrorOut;"function"==typeof x&&this.on(E.ERROR,x,u)}e.isMSESupported=function(){return ci()},e.isSupported=function(){return function(){if(!ci())return!1;var e=Ce();return"function"==typeof(null==e?void 0:e.isTypeSupported)&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some((function(t){return e.isTypeSupported(Oe(t,"video"))}))||["mp4a.40.2","fLaC"].some((function(t){return e.isTypeSupported(Oe(t,"audio"))})))}()},e.getMediaSource=function(){return Ce()};var t=e.prototype;return t.createController=function(e,t){if(e){var r=new e(this);return t&&t.push(r),r}return null},t.on=function(e,t,r){void 0===r&&(r=this),this._emitter.on(e,t,r)},t.once=function(e,t,r){void 0===r&&(r=this),this._emitter.once(e,t,r)},t.removeAllListeners=function(e){this._emitter.removeAllListeners(e)},t.off=function(e,t,r,i){void 0===r&&(r=this),this._emitter.off(e,t,r,i)},t.listeners=function(e){return this._emitter.listeners(e)},t.emit=function(e,t,r){return this._emitter.emit(e,t,r)},t.trigger=function(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(t){if(k.error("An internal error happened while handling event "+e+'. Error message: "'+t.message+'". Here is a stacktrace:',t),!this.triggeringException){this.triggeringException=!0;var r=e===E.ERROR;this.trigger(E.ERROR,{type:T.OTHER_ERROR,details:S.INTERNAL_EXCEPTION,fatal:r,event:e,error:t}),this.triggeringException=!1}}return!1},t.listenerCount=function(e){return this._emitter.listenerCount(e)},t.destroy=function(){k.log("destroy"),this.trigger(E.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach((function(e){return e.destroy()})),this.networkControllers.length=0,this.coreComponents.forEach((function(e){return e.destroy()})),this.coreComponents.length=0;var e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null},t.attachMedia=function(e){k.log("attachMedia"),this._media=e,this.trigger(E.MEDIA_ATTACHING,{media:e})},t.detachMedia=function(){k.log("detachMedia"),this.trigger(E.MEDIA_DETACHING,void 0),this._media=null},t.loadSource=function(e){this.stopLoad();var t=this.media,r=this.url,i=this.url=g.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,k.log("loadSource:"+i),t&&r&&(r!==i||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(E.MANIFEST_LOADING,{url:e})},t.startLoad=function(e){void 0===e&&(e=-1),k.log("startLoad("+e+")"),this.started=!0,this.networkControllers.forEach((function(t){t.startLoad(e)}))},t.stopLoad=function(){k.log("stopLoad"),this.started=!1,this.networkControllers.forEach((function(e){e.stopLoad()}))},t.resumeBuffering=function(){this.started&&this.networkControllers.forEach((function(e){"fragmentLoader"in e&&e.startLoad(-1)}))},t.pauseBuffering=function(){this.networkControllers.forEach((function(e){"fragmentLoader"in e&&e.stopLoad()}))},t.swapAudioCodec=function(){k.log("swapAudioCodec"),this.streamController.swapAudioCodec()},t.recoverMediaError=function(){k.log("recoverMediaError");var e=this._media;this.detachMedia(),e&&this.attachMedia(e)},t.removeLevel=function(e){this.levelController.removeLevel(e)},t.setAudioOption=function(e){var t;return null==(t=this.audioTrackController)?void 0:t.setAudioOption(e)},t.setSubtitleOption=function(e){var t;return null==(t=this.subtitleTrackController)||t.setSubtitleOption(e),null},s(e,[{key:"levels",get:function(){return this.levelController.levels||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(e){k.log("set currentLevel:"+e),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(e){k.log("set nextLevel:"+e),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(e){k.log("set loadLevel:"+e),this.levelController.manualLevel=e}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(e){this.levelController.nextLoadLevel=e}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(e){k.log("set firstLevel:"+e),this.levelController.firstLevel=e}},{key:"startLevel",get:function(){var e=this.levelController.startLevel;return-1===e&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e},set:function(e){k.log("set startLevel:"+e),-1!==e&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(e){var t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(e){this._autoLevelCapping!==e&&(k.log("set autoLevelCapping:"+e),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}},{key:"bandwidthEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimate():NaN},set:function(e){this.abrController.resetEstimator(e)}},{key:"ttfbEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimateTTFB():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(e){(function(e){return Lt.indexOf(e)>-1})(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}},{key:"autoLevelEnabled",get:function(){return-1===this.levelController.manualLevel}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var e=this.levels,t=this.config.minAutoBitrate;if(!e)return 0;for(var r=e.length,i=0;i<r;i++)if(e[i].maxBitrate>=t)return i;return 0}},{key:"maxAutoLevel",get:function(){var e,t=this.levels,r=this.autoLevelCapping,i=this.maxHdcpLevel;if(e=-1===r&&null!=t&&t.length?t.length-1:r,i)for(var a=e;a--;){var n=t[a].attrs["HDCP-LEVEL"];if(n&&n<=i)return a}return e}},{key:"firstAutoLevel",get:function(){return this.abrController.firstAutoLevel}},{key:"nextAutoLevel",get:function(){return this.abrController.nextAutoLevel},set:function(e){this.abrController.nextAutoLevel=e}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"allAudioTracks",get:function(){var e=this.audioTrackController;return e?e.allAudioTracks:[]}},{key:"audioTracks",get:function(){var e=this.audioTrackController;return e?e.audioTracks:[]}},{key:"audioTrack",get:function(){var e=this.audioTrackController;return e?e.audioTrack:-1},set:function(e){var t=this.audioTrackController;t&&(t.audioTrack=e)}},{key:"allSubtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}},{key:"subtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTrack:-1},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var e=this.subtitleTrackController;return!!e&&e.subtitleDisplay},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(e){this.config.lowLatencyMode=e}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}],[{key:"version",get:function(){return"1.5.17"}},{key:"Events",get:function(){return E}},{key:"ErrorTypes",get:function(){return T}},{key:"ErrorDetails",get:function(){return S}},{key:"DefaultConfig",get:function(){return e.defaultConfig?e.defaultConfig:Dr},set:function(t){e.defaultConfig=t}}]),e}();return Da.defaultConfig=void 0,Da}()}(!1)}},t={};function r(i){var a=t[i];if(void 0!==a)return a.exports;var n=t[i]={exports:{}};return e[i](n,n.exports,r),n.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var i in t)r.o(t,i)&&!r.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var i={};r.d(i,{c:()=>n.a});var a=r(539),n=r.n(a),s=i.c;export{s as Hls};
|
1
|
+
var uo=Object.create;var Vi=Object.defineProperty;var fo=Object.getOwnPropertyDescriptor;var ho=Object.getOwnPropertyNames;var co=Object.getPrototypeOf,vo=Object.prototype.hasOwnProperty;var go=(ve,he)=>()=>(he||ve((he={exports:{}}).exports,he),he.exports);var mo=(ve,he,Se,ne)=>{if(he&&typeof he=="object"||typeof he=="function")for(let Ne of ho(he))!vo.call(ve,Ne)&&Ne!==Se&&Vi(ve,Ne,{get:()=>he[Ne],enumerable:!(ne=fo(he,Ne))||ne.enumerable});return ve};var po=(ve,he,Se)=>(Se=ve!=null?uo(co(ve)):{},mo(he||!ve||!ve.__esModule?Vi(Se,"default",{value:ve,enumerable:!0}):Se,ve));var Wi=go((Ki,ir)=>{(function ve(he){(function(Se,ne){typeof Ki=="object"&&typeof ir<"u"?ir.exports=ne():typeof define=="function"&&define.amd?define(ne):(Se=typeof globalThis<"u"?globalThis:Se||self,Se.Hls=ne())})(this,function(){"use strict";function Se(a,n){var i=Object.keys(a);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(a);n&&(e=e.filter(function(t){return Object.getOwnPropertyDescriptor(a,t).enumerable})),i.push.apply(i,e)}return i}function ne(a){for(var n=1;n<arguments.length;n++){var i=arguments[n]!=null?arguments[n]:{};n%2?Se(Object(i),!0).forEach(function(e){Yi(a,e,i[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(i)):Se(Object(i)).forEach(function(e){Object.defineProperty(a,e,Object.getOwnPropertyDescriptor(i,e))})}return a}function Ne(a,n){if(typeof a!="object"||!a)return a;var i=a[Symbol.toPrimitive];if(i!==void 0){var e=i.call(a,n||"default");if(typeof e!="object")return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(a)}function nr(a){var n=Ne(a,"string");return typeof n=="symbol"?n:String(n)}function ar(a,n){for(var i=0;i<n.length;i++){var e=n[i];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(a,nr(e.key),e)}}function ge(a,n,i){return n&&ar(a.prototype,n),i&&ar(a,i),Object.defineProperty(a,"prototype",{writable:!1}),a}function Yi(a,n,i){return n=nr(n),n in a?Object.defineProperty(a,n,{value:i,enumerable:!0,configurable:!0,writable:!0}):a[n]=i,a}function xe(){return xe=Object.assign?Object.assign.bind():function(a){for(var n=1;n<arguments.length;n++){var i=arguments[n];for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&(a[e]=i[e])}return a},xe.apply(this,arguments)}function _e(a,n){a.prototype=Object.create(n.prototype),a.prototype.constructor=a,je(a,n)}function St(a){return St=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},St(a)}function je(a,n){return je=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},je(a,n)}function qi(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Qe(a,n,i){return qi()?Qe=Reflect.construct.bind():Qe=function(t,r,s){var o=[null];o.push.apply(o,r);var l=Function.bind.apply(t,o),u=new l;return s&&je(u,s.prototype),u},Qe.apply(null,arguments)}function ji(a){try{return Function.toString.call(a).indexOf("[native code]")!==-1}catch{return typeof a=="function"}}function Ze(a){var n=typeof Map=="function"?new Map:void 0;return Ze=function(e){if(e===null||!ji(e))return e;if(typeof e!="function")throw new TypeError("Super expression must either be null or a function");if(typeof n<"u"){if(n.has(e))return n.get(e);n.set(e,t)}function t(){return Qe(e,arguments,St(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),je(t,e)},Ze(a)}function Xi(a){if(a===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function sr(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var or={exports:{}};(function(a,n){(function(i){var e=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,t=/^(?=([^\/?#]*))\1([^]*)$/,r=/(?:\/|^)\.(?=\/)/g,s=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,o={buildAbsoluteURL:function(l,u,d){if(d=d||{},l=l.trim(),u=u.trim(),!u){if(!d.alwaysNormalize)return l;var f=o.parseURL(l);if(!f)throw new Error("Error trying to parse base URL.");return f.path=o.normalizePath(f.path),o.buildURLFromParts(f)}var h=o.parseURL(u);if(!h)throw new Error("Error trying to parse relative URL.");if(h.scheme)return d.alwaysNormalize?(h.path=o.normalizePath(h.path),o.buildURLFromParts(h)):u;var c=o.parseURL(l);if(!c)throw new Error("Error trying to parse base URL.");if(!c.netLoc&&c.path&&c.path[0]!=="/"){var v=t.exec(c.path);c.netLoc=v[1],c.path=v[2]}c.netLoc&&!c.path&&(c.path="/");var g={scheme:c.scheme,netLoc:h.netLoc,path:null,params:h.params,query:h.query,fragment:h.fragment};if(!h.netLoc&&(g.netLoc=c.netLoc,h.path[0]!=="/"))if(!h.path)g.path=c.path,h.params||(g.params=c.params,h.query||(g.query=c.query));else{var m=c.path,p=m.substring(0,m.lastIndexOf("/")+1)+h.path;g.path=o.normalizePath(p)}return g.path===null&&(g.path=d.alwaysNormalize?o.normalizePath(h.path):h.path),o.buildURLFromParts(g)},parseURL:function(l){var u=e.exec(l);return u?{scheme:u[1]||"",netLoc:u[2]||"",path:u[3]||"",params:u[4]||"",query:u[5]||"",fragment:u[6]||""}:null},normalizePath:function(l){for(l=l.split("").reverse().join("").replace(r,"");l.length!==(l=l.replace(s,"")).length;);return l.split("").reverse().join("")},buildURLFromParts:function(l){return l.scheme+l.netLoc+l.path+l.params+l.query+l.fragment}};a.exports=o})()})(or);var Lt=or.exports,M=Number.isFinite||function(a){return typeof a=="number"&&isFinite(a)},zi=Number.isSafeInteger||function(a){return typeof a=="number"&&Math.abs(a)<=$i},$i=Number.MAX_SAFE_INTEGER||9007199254740991,x=function(a){return a.MEDIA_ATTACHING="hlsMediaAttaching",a.MEDIA_ATTACHED="hlsMediaAttached",a.MEDIA_DETACHING="hlsMediaDetaching",a.MEDIA_DETACHED="hlsMediaDetached",a.BUFFER_RESET="hlsBufferReset",a.BUFFER_CODECS="hlsBufferCodecs",a.BUFFER_CREATED="hlsBufferCreated",a.BUFFER_APPENDING="hlsBufferAppending",a.BUFFER_APPENDED="hlsBufferAppended",a.BUFFER_EOS="hlsBufferEos",a.BUFFER_FLUSHING="hlsBufferFlushing",a.BUFFER_FLUSHED="hlsBufferFlushed",a.MANIFEST_LOADING="hlsManifestLoading",a.MANIFEST_LOADED="hlsManifestLoaded",a.MANIFEST_PARSED="hlsManifestParsed",a.LEVEL_SWITCHING="hlsLevelSwitching",a.LEVEL_SWITCHED="hlsLevelSwitched",a.LEVEL_LOADING="hlsLevelLoading",a.LEVEL_LOADED="hlsLevelLoaded",a.LEVEL_UPDATED="hlsLevelUpdated",a.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",a.LEVELS_UPDATED="hlsLevelsUpdated",a.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",a.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",a.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",a.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",a.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",a.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",a.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",a.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",a.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",a.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",a.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",a.CUES_PARSED="hlsCuesParsed",a.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",a.INIT_PTS_FOUND="hlsInitPtsFound",a.FRAG_LOADING="hlsFragLoading",a.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",a.FRAG_LOADED="hlsFragLoaded",a.FRAG_DECRYPTED="hlsFragDecrypted",a.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",a.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",a.FRAG_PARSING_METADATA="hlsFragParsingMetadata",a.FRAG_PARSED="hlsFragParsed",a.FRAG_BUFFERED="hlsFragBuffered",a.FRAG_CHANGED="hlsFragChanged",a.FPS_DROP="hlsFpsDrop",a.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",a.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",a.ERROR="hlsError",a.DESTROYING="hlsDestroying",a.KEY_LOADING="hlsKeyLoading",a.KEY_LOADED="hlsKeyLoaded",a.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",a.BACK_BUFFER_REACHED="hlsBackBufferReached",a.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",a}({}),V=function(a){return a.NETWORK_ERROR="networkError",a.MEDIA_ERROR="mediaError",a.KEY_SYSTEM_ERROR="keySystemError",a.MUX_ERROR="muxError",a.OTHER_ERROR="otherError",a}({}),D=function(a){return a.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",a.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",a.KEY_SYSTEM_NO_SESSION="keySystemNoSession",a.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",a.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",a.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",a.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",a.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",a.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",a.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",a.MANIFEST_LOAD_ERROR="manifestLoadError",a.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",a.MANIFEST_PARSING_ERROR="manifestParsingError",a.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",a.LEVEL_EMPTY_ERROR="levelEmptyError",a.LEVEL_LOAD_ERROR="levelLoadError",a.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",a.LEVEL_PARSING_ERROR="levelParsingError",a.LEVEL_SWITCH_ERROR="levelSwitchError",a.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",a.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",a.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",a.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",a.FRAG_LOAD_ERROR="fragLoadError",a.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",a.FRAG_DECRYPT_ERROR="fragDecryptError",a.FRAG_PARSING_ERROR="fragParsingError",a.FRAG_GAP="fragGap",a.REMUX_ALLOC_ERROR="remuxAllocError",a.KEY_LOAD_ERROR="keyLoadError",a.KEY_LOAD_TIMEOUT="keyLoadTimeOut",a.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",a.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",a.BUFFER_APPEND_ERROR="bufferAppendError",a.BUFFER_APPENDING_ERROR="bufferAppendingError",a.BUFFER_STALLED_ERROR="bufferStalledError",a.BUFFER_FULL_ERROR="bufferFullError",a.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",a.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",a.INTERNAL_EXCEPTION="internalException",a.INTERNAL_ABORTED="aborted",a.UNKNOWN="unknown",a}({}),Be=function(){},At={trace:Be,debug:Be,log:Be,warn:Be,info:Be,error:Be},Xe=At;function Qi(a){var n=self.console[a];return n?n.bind(self.console,"["+a+"] >"):Be}function Zi(a){for(var n=arguments.length,i=new Array(n>1?n-1:0),e=1;e<n;e++)i[e-1]=arguments[e];i.forEach(function(t){Xe[t]=a[t]?a[t].bind(a):Qi(t)})}function lr(a,n){if(typeof console=="object"&&a===!0||typeof a=="object"){Zi(a,"debug","log","info","warn","error");try{Xe.log('Debug logs enabled for "'+n+'" in hls.js version 1.5.17')}catch{Xe=At}}else Xe=At}var R=Xe,Ji=/^(\d+)x(\d+)$/,ur=/(.+?)=(".*?"|.*?)(?:,|$)/g,ae=function(){function a(i){typeof i=="string"&&(i=a.parseAttrList(i)),xe(this,i)}var n=a.prototype;return n.decimalInteger=function(e){var t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t},n.hexadecimalInteger=function(e){if(this[e]){var t=(this[e]||"0x").slice(2);t=(t.length&1?"0":"")+t;for(var r=new Uint8Array(t.length/2),s=0;s<t.length/2;s++)r[s]=parseInt(t.slice(s*2,s*2+2),16);return r}else return null},n.hexadecimalIntegerAsNumber=function(e){var t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t},n.decimalFloatingPoint=function(e){return parseFloat(this[e])},n.optionalFloat=function(e,t){var r=this[e];return r?parseFloat(r):t},n.enumeratedString=function(e){return this[e]},n.bool=function(e){return this[e]==="YES"},n.decimalResolution=function(e){var t=Ji.exec(this[e]);if(t!==null)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}},a.parseAttrList=function(e){var t,r={},s='"';for(ur.lastIndex=0;(t=ur.exec(e))!==null;){var o=t[2];o.indexOf(s)===0&&o.lastIndexOf(s)===o.length-1&&(o=o.slice(1,-1));var l=t[1].trim();r[l]=o}return r},ge(a,[{key:"clientAttrs",get:function(){return Object.keys(this).filter(function(e){return e.substring(0,2)==="X-"})}}]),a}();function en(a){return a!=="ID"&&a!=="CLASS"&&a!=="START-DATE"&&a!=="DURATION"&&a!=="END-DATE"&&a!=="END-ON-NEXT"}function tn(a){return a==="SCTE35-OUT"||a==="SCTE35-IN"}var fr=function(){function a(n,i){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,i){var e=i.attr;for(var t in e)if(Object.prototype.hasOwnProperty.call(n,t)&&n[t]!==e[t]){R.warn('DATERANGE tag attribute: "'+t+'" does not match for tags with ID: "'+n.ID+'"'),this._badValueForSameId=t;break}n=xe(new ae({}),e,n)}if(this.attr=n,this._startDate=new Date(n["START-DATE"]),"END-DATE"in this.attr){var r=new Date(this.attr["END-DATE"]);M(r.getTime())&&(this._endDate=r)}}return ge(a,[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){if(this._endDate)return this._endDate;var i=this.duration;return i!==null?new Date(this._startDate.getTime()+i*1e3):null}},{key:"duration",get:function(){if("DURATION"in this.attr){var i=this.attr.decimalFloatingPoint("DURATION");if(M(i))return i}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}},{key:"endOnNext",get:function(){return this.attr.bool("END-ON-NEXT")}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&M(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),a}(),Je=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:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"},dr=function(){function a(i){var e;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(e={},e[$.AUDIO]=null,e[$.VIDEO]=null,e[$.AUDIOVIDEO]=null,e),this.baseurl=i}var n=a.prototype;return n.setByteRange=function(e,t){var r=e.split("@",2),s;r.length===1?s=t?.byteRangeEndOffset||0:s=parseInt(r[1]),this._byteRange=[s,parseInt(r[0])+s]},ge(a,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Lt.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(e){this._url=e}}]),a}(),Rt=function(a){_e(n,a);function n(e,t){var r;return r=a.call(this,t)||this,r._decryptdata=null,r.rawProgramDateTime=null,r.programDateTime=null,r.tagList=[],r.duration=0,r.sn=0,r.levelkeys=void 0,r.type=void 0,r.loader=null,r.keyLoader=null,r.level=-1,r.cc=0,r.startPTS=void 0,r.endPTS=void 0,r.startDTS=void 0,r.endDTS=void 0,r.start=0,r.deltaPTS=void 0,r.maxStartPTS=void 0,r.minEndPTS=void 0,r.stats=new Je,r.data=void 0,r.bitrateTest=!1,r.title=null,r.initSegment=null,r.endList=void 0,r.gap=void 0,r.urlId=0,r.type=e,r}var i=n.prototype;return i.setKeyFormat=function(t){if(this.levelkeys){var r=this.levelkeys[t];r&&!this._decryptdata&&(this._decryptdata=r.getDecryptData(this.sn))}},i.abortRequests=function(){var t,r;(t=this.loader)==null||t.abort(),(r=this.keyLoader)==null||r.abort()},i.setElementaryStreamInfo=function(t,r,s,o,l,u){u===void 0&&(u=!1);var d=this.elementaryStreams,f=d[t];if(!f){d[t]={startPTS:r,endPTS:s,startDTS:o,endDTS:l,partial:u};return}f.startPTS=Math.min(f.startPTS,r),f.endPTS=Math.max(f.endPTS,s),f.startDTS=Math.min(f.startDTS,o),f.endDTS=Math.max(f.endDTS,l)},i.clearElementaryStreamInfo=function(){var t=this.elementaryStreams;t[$.AUDIO]=null,t[$.VIDEO]=null,t[$.AUDIOVIDEO]=null},ge(n,[{key:"decryptdata",get:function(){var t=this.levelkeys;if(!t&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){var r=this.levelkeys.identity;if(r)this._decryptdata=r.getDecryptData(this.sn);else{var s=Object.keys(this.levelkeys);if(s.length===1)return this._decryptdata=this.levelkeys[s[0]].getDecryptData(this.sn)}}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null||!M(this.programDateTime))return null;var t=M(this.duration)?this.duration:0;return this.programDateTime+t*1e3}},{key:"encrypted",get:function(){var t;if((t=this._decryptdata)!=null&&t.encrypted)return!0;if(this.levelkeys){var r=Object.keys(this.levelkeys),s=r.length;if(s>1||s===1&&this.levelkeys[r[0]].encrypted)return!0}return!1}}]),n}(dr),rn=function(a){_e(n,a);function n(i,e,t,r,s){var o;o=a.call(this,t)||this,o.fragOffset=0,o.duration=0,o.gap=!1,o.independent=!1,o.relurl=void 0,o.fragment=void 0,o.index=void 0,o.stats=new Je,o.duration=i.decimalFloatingPoint("DURATION"),o.gap=i.bool("GAP"),o.independent=i.bool("INDEPENDENT"),o.relurl=i.enumeratedString("URI"),o.fragment=e,o.index=r;var l=i.enumeratedString("BYTERANGE");return l&&o.setByteRange(l,s),s&&(o.fragOffset=s.fragOffset+s.duration),o}return ge(n,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var e=this.elementaryStreams;return!!(e.audio||e.video||e.audiovideo)}}]),n}(dr),nn=10,an=function(){function a(i){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=i}var n=a.prototype;return n.reloaded=function(e){if(!e){this.advanced=!0,this.updated=!0;return}var t=this.lastPartSn-e.lastPartSn,r=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!r||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||t===0&&r>0,this.updated||this.advanced?this.misses=Math.floor(e.misses*.6):this.misses=e.misses+1,this.availabilityDelay=e.availabilityDelay},ge(a,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?M(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||nn}},{key:"drift",get:function(){var e=this.driftEndTime-this.driftStartTime;if(e>0){var t=this.driftEnd-this.driftStart;return t*1e3/e}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var e;return(e=this.fragments)!=null&&e.length?this.fragments[this.fragments.length-1].end:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),a}(),sn=void 0,on=sr(sn);function Ue(a,n,i){return Uint8Array.prototype.slice?a.slice(n,i):new Uint8Array(Array.prototype.slice.call(a,n,i))}var bt=function(n,i){return i+10<=n.length&&n[i]===73&&n[i+1]===68&&n[i+2]===51&&n[i+3]<255&&n[i+4]<255&&n[i+6]<128&&n[i+7]<128&&n[i+8]<128&&n[i+9]<128},hr=function(n,i){return i+10<=n.length&&n[i]===51&&n[i+1]===68&&n[i+2]===73&&n[i+3]<255&&n[i+4]<255&&n[i+6]<128&&n[i+7]<128&&n[i+8]<128&&n[i+9]<128},et=function(n,i){for(var e=i,t=0;bt(n,i);){t+=10;var r=tt(n,i+6);t+=r,hr(n,i+10)&&(t+=10),i+=t}if(t>0)return n.subarray(e,e+t)},tt=function(n,i){var e=0;return e=(n[i]&127)<<21,e|=(n[i+1]&127)<<14,e|=(n[i+2]&127)<<7,e|=n[i+3]&127,e},ln=function(n,i){return bt(n,i)&&tt(n,i+6)+10<=n.length-i},cr=function(n){for(var i=gr(n),e=0;e<i.length;e++){var t=i[e];if(vr(t))return vn(t)}},vr=function(n){return n&&n.key==="PRIV"&&n.info==="com.apple.streaming.transportStreamTimestamp"},un=function(n){var i=String.fromCharCode(n[0],n[1],n[2],n[3]),e=tt(n,4),t=10;return{type:i,size:e,data:n.subarray(t,t+e)}},gr=function(n){for(var i=0,e=[];bt(n,i);){var t=tt(n,i+6);i+=10;for(var r=i+t;i+8<r;){var s=un(n.subarray(i)),o=fn(s);o&&e.push(o),i+=s.size+10}hr(n,i)&&(i+=10)}return e},fn=function(n){return n.type==="PRIV"?dn(n):n.type[0]==="W"?cn(n):hn(n)},dn=function(n){if(!(n.size<2)){var i=Me(n.data,!0),e=new Uint8Array(n.data.subarray(i.length+1));return{key:n.type,info:i,data:e.buffer}}},hn=function(n){if(!(n.size<2)){if(n.type==="TXXX"){var i=1,e=Me(n.data.subarray(i),!0);i+=e.length+1;var t=Me(n.data.subarray(i));return{key:n.type,info:e,data:t}}var r=Me(n.data.subarray(1));return{key:n.type,data:r}}},cn=function(n){if(n.type==="WXXX"){if(n.size<2)return;var i=1,e=Me(n.data.subarray(i),!0);i+=e.length+1;var t=Me(n.data.subarray(i));return{key:n.type,info:e,data:t}}var r=Me(n.data);return{key:n.type,data:r}},vn=function(n){if(n.data.byteLength===8){var i=new Uint8Array(n.data),e=i[3]&1,t=(i[4]<<23)+(i[5]<<15)+(i[6]<<7)+i[7];return t/=45,e&&(t+=4772185884e-2),Math.round(t)}},Me=function(n,i){i===void 0&&(i=!1);var e=gn();if(e){var t=e.decode(n);if(i){var r=t.indexOf("\0");return r!==-1?t.substring(0,r):t}return t.replace(/\0/g,"")}for(var s=n.length,o,l,u,d="",f=0;f<s;){if(o=n[f++],o===0&&i)return d;if(o===0||o===3)continue;switch(o>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:d+=String.fromCharCode(o);break;case 12:case 13:l=n[f++],d+=String.fromCharCode((o&31)<<6|l&63);break;case 14:l=n[f++],u=n[f++],d+=String.fromCharCode((o&15)<<12|(l&63)<<6|(u&63)<<0);break}}return d},It;function gn(){if(!navigator.userAgent.includes("PlayStation 4"))return!It&&typeof self.TextDecoder<"u"&&(It=new self.TextDecoder("utf-8")),It}var mr={hexDump:function(n){for(var i="",e=0;e<n.length;e++){var t=n[e].toString(16);t.length<2&&(t="0"+t),i+=t}return i}},rt=Math.pow(2,32)-1,mn=[].push,pr={video:1,audio:2,id3:3,text:4};function oe(a){return String.fromCharCode.apply(null,a)}function yr(a,n){var i=a[n]<<8|a[n+1];return i<0?65536+i:i}function N(a,n){var i=xr(a,n);return i<0?4294967296+i:i}function Er(a,n){var i=N(a,n);return i*=Math.pow(2,32),i+=N(a,n+4),i}function xr(a,n){return a[n]<<24|a[n+1]<<16|a[n+2]<<8|a[n+3]}function _t(a,n,i){a[n]=i>>24,a[n+1]=i>>16&255,a[n+2]=i>>8&255,a[n+3]=i&255}function pn(a){for(var n=a.byteLength,i=0;i<n;){var e=N(a,i);if(e>8&&a[i+4]===109&&a[i+5]===111&&a[i+6]===111&&a[i+7]===102)return!0;i=e>1?i+e:n}return!1}function G(a,n){var i=[];if(!n.length)return i;for(var e=a.byteLength,t=0;t<e;){var r=N(a,t),s=oe(a.subarray(t+4,t+8)),o=r>1?t+r:e;if(s===n[0])if(n.length===1)i.push(a.subarray(t+8,o));else{var l=G(a.subarray(t+8,o),n.slice(1));l.length&&mn.apply(i,l)}t=o}return i}function yn(a){var n=[],i=a[0],e=8,t=N(a,e);e+=4;var r=0,s=0;i===0?(r=N(a,e),s=N(a,e+4),e+=8):(r=Er(a,e),s=Er(a,e+8),e+=16),e+=2;var o=a.length+s,l=yr(a,e);e+=2;for(var u=0;u<l;u++){var d=e,f=N(a,d);d+=4;var h=f&2147483647,c=(f&2147483648)>>>31;if(c===1)return R.warn("SIDX has hierarchical references (not supported)"),null;var v=N(a,d);d+=4,n.push({referenceSize:h,subsegmentDuration:v,info:{duration:v/t,start:o,end:o+h-1}}),o+=h,d+=4,e=d}return{earliestPresentationTime:r,timescale:t,version:i,referencesCount:l,references:n}}function Tr(a){for(var n=[],i=G(a,["moov","trak"]),e=0;e<i.length;e++){var t=i[e],r=G(t,["tkhd"])[0];if(r){var s=r[0],o=N(r,s===0?12:20),l=G(t,["mdia","mdhd"])[0];if(l){s=l[0];var u=N(l,s===0?12:20),d=G(t,["mdia","hdlr"])[0];if(d){var f=oe(d.subarray(8,12)),h={soun:$.AUDIO,vide:$.VIDEO}[f];if(h){var c=G(t,["mdia","minf","stbl","stsd"])[0],v=En(c);n[o]={timescale:u,type:h},n[h]=ne({timescale:u,id:o},v)}}}}}var g=G(a,["moov","mvex","trex"]);return g.forEach(function(m){var p=N(m,4),y=n[p];y&&(y.default={duration:N(m,12),flags:N(m,20)})}),n}function En(a){var n=a.subarray(8),i=n.subarray(86),e=oe(n.subarray(4,8)),t=e,r=e==="enca"||e==="encv";if(r){var s=G(n,[e])[0],o=s.subarray(e==="enca"?28:78),l=G(o,["sinf"]);l.forEach(function(Ee){var ce=G(Ee,["schm"])[0];if(ce){var ue=oe(ce.subarray(4,8));if(ue==="cbcs"||ue==="cenc"){var Ve=G(Ee,["frma"])[0];Ve&&(t=oe(Ve))}}})}switch(t){case"avc1":case"avc2":case"avc3":case"avc4":{var u=G(i,["avcC"])[0];t+="."+it(u[1])+it(u[2])+it(u[3]);break}case"mp4a":{var d=G(n,[e])[0],f=G(d.subarray(28),["esds"])[0];if(f&&f.length>12){var h=4;if(f[h++]!==3)break;h=Dt(f,h),h+=2;var c=f[h++];if(c&128&&(h+=2),c&64&&(h+=f[h++]),f[h++]!==4)break;h=Dt(f,h);var v=f[h++];if(v===64)t+="."+it(v);else break;if(h+=12,f[h++]!==5)break;h=Dt(f,h);var g=f[h++],m=(g&248)>>3;m===31&&(m+=1+((g&7)<<3)+((f[h]&224)>>5)),t+="."+m}break}case"hvc1":case"hev1":{var p=G(i,["hvcC"])[0],y=p[1],E=["","A","B","C"][y>>6],S=y&31,L=N(p,2),_=(y&32)>>5?"H":"L",A=p[12],T=p.subarray(6,12);t+="."+E+S,t+="."+L.toString(16).toUpperCase(),t+="."+_+A;for(var b="",I=T.length;I--;){var P=T[I];if(P||b){var C=P.toString(16).toUpperCase();b="."+C+b}}t+=b;break}case"dvh1":case"dvhe":{var w=G(i,["dvcC"])[0],O=w[2]>>1&127,F=w[2]<<5&32|w[3]>>3&31;t+="."+De(O)+"."+De(F);break}case"vp09":{var H=G(i,["vpcC"])[0],U=H[4],W=H[5],K=H[6]>>4&15;t+="."+De(U)+"."+De(W)+"."+De(K);break}case"av01":{var B=G(i,["av1C"])[0],Q=B[1]>>>5,j=B[1]&31,J=B[2]>>>7?"H":"M",ee=(B[2]&64)>>6,re=(B[2]&32)>>5,Z=Q===2&&ee?re?12:10:ee?10:8,X=(B[2]&16)>>4,Fe=(B[2]&8)>>3,Te=(B[2]&4)>>2,te=B[2]&3,me=1,pe=1,ie=1,z=0;t+="."+Q+"."+De(j)+J+"."+De(Z)+"."+X+"."+Fe+Te+te+"."+De(me)+"."+De(pe)+"."+De(ie)+"."+z;break}}return{codec:t,encrypted:r}}function Dt(a,n){for(var i=n+5;a[n++]&128&&n<i;);return n}function it(a){return("0"+a.toString(16).toUpperCase()).slice(-2)}function De(a){return(a<10?"0":"")+a}function xn(a,n){if(!a||!n)return a;var i=n.keyId;if(i&&n.isCommonEncryption){var e=G(a,["moov","trak"]);e.forEach(function(t){var r=G(t,["mdia","minf","stbl","stsd"])[0],s=r.subarray(8),o=G(s,["enca"]),l=o.length>0;l||(o=G(s,["encv"])),o.forEach(function(u){var d=l?u.subarray(28):u.subarray(78),f=G(d,["sinf"]);f.forEach(function(h){var c=Tn(h);if(c){var v=c.subarray(8,24);v.some(function(g){return g!==0})||(R.log("[eme] Patching keyId in 'enc"+(l?"a":"v")+">sinf>>tenc' box: "+mr.hexDump(v)+" -> "+mr.hexDump(i)),c.set(i,8))}})})})}return a}function Tn(a){var n=G(a,["schm"])[0];if(n){var i=oe(n.subarray(4,8));if(i==="cbcs"||i==="cenc")return G(a,["schi","tenc"])[0]}return null}function Sn(a,n){return G(n,["moof","traf"]).reduce(function(i,e){var t=G(e,["tfdt"])[0],r=t[0],s=G(e,["tfhd"]).reduce(function(o,l){var u=N(l,4),d=a[u];if(d){var f=N(t,4);if(r===1){if(f===rt)return R.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),o;f*=rt+1,f+=N(t,8)}var h=d.timescale||9e4,c=f/h;if(M(c)&&(o===null||c<o))return c}return o},null);return s!==null&&M(s)&&(i===null||s<i)?s:i},null)}function Ln(a,n){for(var i=0,e=0,t=0,r=G(a,["moof","traf"]),s=0;s<r.length;s++){var o=r[s],l=G(o,["tfhd"])[0],u=N(l,4),d=n[u];if(d){var f=d.default,h=N(l,0)|f?.flags,c=f?.duration;h&8&&(h&2?c=N(l,12):c=N(l,8));for(var v=d.timescale||9e4,g=G(o,["trun"]),m=0;m<g.length;m++){if(i=An(g[m]),!i&&c){var p=N(g[m],4);i=c*p}d.type===$.VIDEO?e+=i/v:d.type===$.AUDIO&&(t+=i/v)}}}if(e===0&&t===0){for(var y=1/0,E=0,S=0,L=G(a,["sidx"]),_=0;_<L.length;_++){var A=yn(L[_]);if(A!=null&&A.references){y=Math.min(y,A.earliestPresentationTime/A.timescale);var T=A.references.reduce(function(b,I){return b+I.info.duration||0},0);E=Math.max(E,T+A.earliestPresentationTime/A.timescale),S=E-y}}if(S&&M(S))return S}return e||t}function An(a){var n=N(a,0),i=8;n&1&&(i+=4),n&4&&(i+=4);for(var e=0,t=N(a,4),r=0;r<t;r++){if(n&256){var s=N(a,i);e+=s,i+=4}n&512&&(i+=4),n&1024&&(i+=4),n&2048&&(i+=4)}return e}function Rn(a,n,i){G(n,["moof","traf"]).forEach(function(e){G(e,["tfhd"]).forEach(function(t){var r=N(t,4),s=a[r];if(s){var o=s.timescale||9e4;G(e,["tfdt"]).forEach(function(l){var u=l[0],d=i*o;if(d){var f=N(l,4);if(u===0)f-=d,f=Math.max(f,0),_t(l,4,f);else{f*=Math.pow(2,32),f+=N(l,8),f-=d,f=Math.max(f,0);var h=Math.floor(f/(rt+1)),c=Math.floor(f%(rt+1));_t(l,4,h),_t(l,8,c)}}})}})})}function bn(a){var n={valid:null,remainder:null},i=G(a,["moof"]);if(i.length<2)return n.remainder=a,n;var e=i[i.length-1];return n.valid=Ue(a,0,e.byteOffset-8),n.remainder=Ue(a,e.byteOffset-8),n}function Le(a,n){var i=new Uint8Array(a.length+n.length);return i.set(a),i.set(n,a.length),i}function Sr(a,n){var i=[],e=n.samples,t=n.timescale,r=n.id,s=!1,o=G(e,["moof"]);return o.map(function(l){var u=l.byteOffset-8,d=G(l,["traf"]);d.map(function(f){var h=G(f,["tfdt"]).map(function(c){var v=c[0],g=N(c,4);return v===1&&(g*=Math.pow(2,32),g+=N(c,8)),g/t})[0];return h!==void 0&&(a=h),G(f,["tfhd"]).map(function(c){var v=N(c,4),g=N(c,0)&16777215,m=(g&1)!==0,p=(g&2)!==0,y=(g&8)!==0,E=0,S=(g&16)!==0,L=0,_=(g&32)!==0,A=8;v===r&&(m&&(A+=8),p&&(A+=4),y&&(E=N(c,A),A+=4),S&&(L=N(c,A),A+=4),_&&(A+=4),n.type==="video"&&(s=In(n.codec)),G(f,["trun"]).map(function(T){var b=T[0],I=N(T,0)&16777215,P=(I&1)!==0,C=0,w=(I&4)!==0,O=(I&256)!==0,F=0,H=(I&512)!==0,U=0,W=(I&1024)!==0,K=(I&2048)!==0,B=0,Q=N(T,4),j=8;P&&(C=N(T,j),j+=4),w&&(j+=4);for(var J=C+u,ee=0;ee<Q;ee++){if(O?(F=N(T,j),j+=4):F=E,H?(U=N(T,j),j+=4):U=L,W&&(j+=4),K&&(b===0?B=N(T,j):B=xr(T,j),j+=4),n.type===$.VIDEO)for(var re=0;re<U;){var Z=N(e,J);if(J+=4,_n(s,e[J])){var X=e.subarray(J,J+Z);Lr(X,s?2:1,a+B/t,i)}J+=Z,re+=Z+4}a+=F/t}}))})})}),i}function In(a){if(!a)return!1;var n=a.indexOf("."),i=n<0?a:a.substring(0,n);return i==="hvc1"||i==="hev1"||i==="dvh1"||i==="dvhe"}function _n(a,n){if(a){var i=n>>1&63;return i===39||i===40}else{var e=n&31;return e===6}}function Lr(a,n,i,e){var t=Ar(a),r=0;r+=n;for(var s=0,o=0,l=0;r<t.length;){s=0;do{if(r>=t.length)break;l=t[r++],s+=l}while(l===255);o=0;do{if(r>=t.length)break;l=t[r++],o+=l}while(l===255);var u=t.length-r,d=r;if(o<u)r+=o;else if(o>u){R.error("Malformed SEI payload. "+o+" is too small, only "+u+" bytes left to parse.");break}if(s===4){var f=t[d++];if(f===181){var h=yr(t,d);if(d+=2,h===49){var c=N(t,d);if(d+=4,c===1195456820){var v=t[d++];if(v===3){var g=t[d++],m=31&g,p=64&g,y=p?2+m*3:0,E=new Uint8Array(y);if(p){E[0]=g;for(var S=1;S<y;S++)E[S]=t[d++]}e.push({type:v,payloadType:s,pts:i,bytes:E})}}}}}else if(s===5&&o>16){for(var L=[],_=0;_<16;_++){var A=t[d++].toString(16);L.push(A.length==1?"0"+A:A),(_===3||_===5||_===7||_===9)&&L.push("-")}for(var T=o-16,b=new Uint8Array(T),I=0;I<T;I++)b[I]=t[d++];e.push({payloadType:s,pts:i,uuid:L.join(""),userData:Me(b),userDataBytes:b})}}}function Ar(a){for(var n=a.byteLength,i=[],e=1;e<n-2;)a[e]===0&&a[e+1]===0&&a[e+2]===3?(i.push(e+2),e+=2):e++;if(i.length===0)return a;var t=n-i.length,r=new Uint8Array(t),s=0;for(e=0;e<t;s++,e++)s===i[0]&&(s++,i.shift()),r[e]=a[s];return r}function Dn(a){var n=a[0],i="",e="",t=0,r=0,s=0,o=0,l=0,u=0;if(n===0){for(;oe(a.subarray(u,u+1))!=="\0";)i+=oe(a.subarray(u,u+1)),u+=1;for(i+=oe(a.subarray(u,u+1)),u+=1;oe(a.subarray(u,u+1))!=="\0";)e+=oe(a.subarray(u,u+1)),u+=1;e+=oe(a.subarray(u,u+1)),u+=1,t=N(a,12),r=N(a,16),o=N(a,20),l=N(a,24),u=28}else if(n===1){u+=4,t=N(a,u),u+=4;var d=N(a,u);u+=4;var f=N(a,u);for(u+=4,s=Math.pow(2,32)*d+f,zi(s)||(s=Number.MAX_SAFE_INTEGER,R.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=N(a,u),u+=4,l=N(a,u),u+=4;oe(a.subarray(u,u+1))!=="\0";)i+=oe(a.subarray(u,u+1)),u+=1;for(i+=oe(a.subarray(u,u+1)),u+=1;oe(a.subarray(u,u+1))!=="\0";)e+=oe(a.subarray(u,u+1)),u+=1;e+=oe(a.subarray(u,u+1)),u+=1}var h=a.subarray(u,a.byteLength);return{schemeIdUri:i,value:e,timeScale:t,presentationTime:s,presentationTimeDelta:r,eventDuration:o,id:l,payload:h}}var Cn=function(){a.clearKeyUriToKeyIdMap=function(){};function a(i,e,t,r,s){r===void 0&&(r=[1]),s===void 0&&(s=null),this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=i,this.uri=e,this.keyFormat=t,this.keyFormatVersions=r,this.iv=s,this.encrypted=i?i!=="NONE":!1,this.isCommonEncryption=this.encrypted&&i!=="AES-128"}var n=a.prototype;return n.isSupported=function(){if(this.method){if(this.method==="AES-128"||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES"}return!1},n.getDecryptData=function(e){if(!this.encrypted||!this.uri)return null;if(this.method==="AES-128"&&this.uri&&!this.iv){typeof e!="number"&&(this.method==="AES-128"&&!this.iv&&R.warn('missing IV for initialization segment with method="'+this.method+'" - compliance issue'),e=0);var t=Pn(e),r=new a(this.method,this.uri,"identity",this.keyFormatVersions,t);return r}return this},a}();function Pn(a){for(var n=new Uint8Array(16),i=12;i<16;i++)n[i]=a>>8*(15-i)&255;return n}function Ge(a){if(a===void 0&&(a=!0),!(typeof self>"u")){var n=(a||!self.MediaSource)&&self.ManagedMediaSource;return n||self.MediaSource||self.WebKitMediaSource}}function wn(a){return typeof self<"u"&&a===self.ManagedMediaSource}var nt={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv60:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1}};function kn(a,n){var i=nt[n];return!!i&&!!i[a.slice(0,4)]}function Ct(a,n,i){return i===void 0&&(i=!0),!a.split(",").some(function(e){return!Rr(e,n,i)})}function Rr(a,n,i){var e;i===void 0&&(i=!0);var t=Ge(i);return(e=t?.isTypeSupported(Pt(a,n)))!=null?e:!1}function Pt(a,n){return n+'/mp4;codecs="'+a+'"'}function br(a){if(a){var n=a.substring(0,4);return nt.video[n]}return 2}function at(a){return a.split(",").reduce(function(n,i){var e=nt.video[i];return e?(e*2+n)/(n?3:2):(nt.audio[i]+n)/(n?2:1)},0)}var wt={};function Fn(a,n){if(n===void 0&&(n=!0),wt[a])return wt[a];for(var i={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"]}[a],e=0;e<i.length;e++)if(Rr(i[e],"audio",n))return wt[a]=i[e],i[e];return a}var Mn=/flac|opus/i;function st(a,n){return n===void 0&&(n=!0),a.replace(Mn,function(i){return Fn(i.toLowerCase(),n)})}function Ir(a,n){return a&&a!=="mp4a"?a:n&&n.split(",")[0]}function On(a){for(var n=a.split(","),i=0;i<n.length;i++){var e=n[i].split(".");if(e.length>2){var t=e.shift()+".";t+=parseInt(e.shift()).toString(16),t+=("000"+parseInt(e.shift()).toString(16)).slice(-4),n[i]=t}}return n.join(",")}var _r=/#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,Dr=/#EXT-X-MEDIA:(.*)/g,Nn=/^#EXT(?:INF|-X-TARGETDURATION):/m,Cr=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),Bn=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|INDEPENDENT-SEGMENTS)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),ze=function(){function a(){}return a.findGroup=function(i,e){for(var t=0;t<i.length;t++){var r=i[t];if(r.id===e)return r}},a.resolve=function(i,e){return Lt.buildAbsoluteURL(e,i,{alwaysNormalize:!0})},a.isMediaPlaylist=function(i){return Nn.test(i)},a.parseMasterPlaylist=function(i,e){var t=!1,r={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:t},s=[];_r.lastIndex=0;for(var o;(o=_r.exec(i))!=null;)if(o[1]){var l,u=new ae(o[1]),d=o[2],f={attrs:u,bitrate:u.decimalInteger("BANDWIDTH")||u.decimalInteger("AVERAGE-BANDWIDTH"),name:u.NAME,url:a.resolve(d,e)},h=u.decimalResolution("RESOLUTION");h&&(f.width=h.width,f.height=h.height),Un(u.CODECS,f),(l=f.unknownCodecs)!=null&&l.length||s.push(f),r.levels.push(f)}else if(o[3]){var c=o[3],v=o[4];switch(c){case"SESSION-DATA":{var g=new ae(v),m=g["DATA-ID"];m&&(r.sessionData===null&&(r.sessionData={}),r.sessionData[m]=g);break}case"SESSION-KEY":{var p=Pr(v,e);p.encrypted&&p.isSupported()?(r.sessionKeys===null&&(r.sessionKeys=[]),r.sessionKeys.push(p)):R.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+v+'"');break}case"DEFINE":break;case"CONTENT-STEERING":{var y=new ae(v);r.contentSteering={uri:a.resolve(y["SERVER-URI"],e),pathwayId:y["PATHWAY-ID"]||"."};break}case"START":{r.startTimeOffset=wr(v);break}}}var E=s.length>0&&s.length<r.levels.length;return r.levels=E?s:r.levels,r.levels.length===0&&(r.playlistParsingError=new Error("no levels found in manifest")),r},a.parseMasterPlaylistMedia=function(i,e,t){var r,s={},o=t.levels,l={AUDIO:o.map(function(L){return{id:L.attrs.AUDIO,audioCodec:L.audioCodec}}),SUBTITLES:o.map(function(L){return{id:L.attrs.SUBTITLES,textCodec:L.textCodec}}),"CLOSED-CAPTIONS":[]},u=0;for(Dr.lastIndex=0;(r=Dr.exec(i))!==null;){var d=new ae(r[1]),f=d.TYPE;if(f){var h=l[f],c=s[f]||[];s[f]=c;var v=d.LANGUAGE,g=d["ASSOC-LANGUAGE"],m=d.CHANNELS,p=d.CHARACTERISTICS,y=d["INSTREAM-ID"],E={attrs:d,bitrate:0,id:u++,groupId:d["GROUP-ID"]||"",name:d.NAME||v||"",type:f,default:d.bool("DEFAULT"),autoselect:d.bool("AUTOSELECT"),forced:d.bool("FORCED"),lang:v,url:d.URI?a.resolve(d.URI,e):""};if(g&&(E.assocLang=g),m&&(E.channels=m),p&&(E.characteristics=p),y&&(E.instreamId=y),h!=null&&h.length){var S=a.findGroup(h,E.groupId)||h[0];kr(E,S,"audioCodec"),kr(E,S,"textCodec")}c.push(E)}}return s},a.parseLevelPlaylist=function(i,e,t,r,s,o){var l=new an(e),u=l.fragments,d=null,f=0,h=0,c=0,v=0,g=null,m=new Rt(r,e),p,y,E,S=-1,L=!1,_=null;for(Cr.lastIndex=0,l.m3u8=i,l.hasVariableRefs=!1;(p=Cr.exec(i))!==null;){L&&(L=!1,m=new Rt(r,e),m.start=c,m.sn=f,m.cc=v,m.level=t,d&&(m.initSegment=d,m.rawProgramDateTime=d.rawProgramDateTime,d.rawProgramDateTime=null,_&&(m.setByteRange(_),_=null)));var A=p[1];if(A){m.duration=parseFloat(A);var T=(" "+p[2]).slice(1);m.title=T||null,m.tagList.push(T?["INF",A,T]:["INF",A])}else if(p[3]){if(M(m.duration)){m.start=c,E&&Or(m,E,l),m.sn=f,m.level=t,m.cc=v,u.push(m);var b=(" "+p[3]).slice(1);m.relurl=b,Fr(m,g),g=m,c+=m.duration,f++,h=0,L=!0}}else if(p[4]){var I=(" "+p[4]).slice(1);g?m.setByteRange(I,g):m.setByteRange(I)}else if(p[5])m.rawProgramDateTime=(" "+p[5]).slice(1),m.tagList.push(["PROGRAM-DATE-TIME",m.rawProgramDateTime]),S===-1&&(S=u.length);else{if(p=p[0].match(Bn),!p){R.warn("No matches on slow regex match for level playlist!");continue}for(y=1;y<p.length&&!(typeof p[y]<"u");y++);var P=(" "+p[y]).slice(1),C=(" "+p[y+1]).slice(1),w=p[y+2]?(" "+p[y+2]).slice(1):"";switch(P){case"PLAYLIST-TYPE":l.type=C.toUpperCase();break;case"MEDIA-SEQUENCE":f=l.startSN=parseInt(C);break;case"SKIP":{var O=new ae(C),F=O.decimalInteger("SKIPPED-SEGMENTS");if(M(F)){l.skippedSegments=F;for(var H=F;H--;)u.unshift(null);f+=F}var U=O.enumeratedString("RECENTLY-REMOVED-DATERANGES");U&&(l.recentlyRemovedDateranges=U.split(" "));break}case"TARGETDURATION":l.targetduration=Math.max(parseInt(C),1);break;case"VERSION":l.version=parseInt(C);break;case"INDEPENDENT-SEGMENTS":case"EXTM3U":break;case"ENDLIST":l.live=!1;break;case"#":(C||w)&&m.tagList.push(w?[C,w]:[C]);break;case"DISCONTINUITY":v++,m.tagList.push(["DIS"]);break;case"GAP":m.gap=!0,m.tagList.push([P]);break;case"BITRATE":m.tagList.push([P,C]);break;case"DATERANGE":{var W=new ae(C),K=new fr(W,l.dateRanges[W.ID]);K.isValid||l.skippedSegments?l.dateRanges[K.id]=K:R.warn('Ignoring invalid DATERANGE tag: "'+C+'"'),m.tagList.push(["EXT-X-DATERANGE",C]);break}case"DEFINE":break;case"DISCONTINUITY-SEQUENCE":v=parseInt(C);break;case"KEY":{var B=Pr(C,e);if(B.isSupported()){if(B.method==="NONE"){E=void 0;break}E||(E={}),E[B.keyFormat]&&(E=xe({},E)),E[B.keyFormat]=B}else R.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'+C+'"');break}case"START":l.startTimeOffset=wr(C);break;case"MAP":{var Q=new ae(C);if(m.duration){var j=new Rt(r,e);Mr(j,Q,t,E),d=j,m.initSegment=d,d.rawProgramDateTime&&!m.rawProgramDateTime&&(m.rawProgramDateTime=d.rawProgramDateTime)}else{var J=m.byteRangeEndOffset;if(J){var ee=m.byteRangeStartOffset;_=J-ee+"@"+ee}else _=null;Mr(m,Q,t,E),d=m,L=!0}break}case"SERVER-CONTROL":{var re=new ae(C);l.canBlockReload=re.bool("CAN-BLOCK-RELOAD"),l.canSkipUntil=re.optionalFloat("CAN-SKIP-UNTIL",0),l.canSkipDateRanges=l.canSkipUntil>0&&re.bool("CAN-SKIP-DATERANGES"),l.partHoldBack=re.optionalFloat("PART-HOLD-BACK",0),l.holdBack=re.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var Z=new ae(C);l.partTarget=Z.decimalFloatingPoint("PART-TARGET");break}case"PART":{var X=l.partList;X||(X=l.partList=[]);var Fe=h>0?X[X.length-1]:void 0,Te=h++,te=new ae(C),me=new rn(te,m,e,Te,Fe);X.push(me),m.duration+=me.duration;break}case"PRELOAD-HINT":{var pe=new ae(C);l.preloadHint=pe;break}case"RENDITION-REPORT":{var ie=new ae(C);l.renditionReports=l.renditionReports||[],l.renditionReports.push(ie);break}default:R.warn("line parsed but not handled: "+p);break}}}g&&!g.relurl?(u.pop(),c-=g.duration,l.partList&&(l.fragmentHint=g)):l.partList&&(Fr(m,g),m.cc=v,l.fragmentHint=m,E&&Or(m,E,l));var z=u.length,Ee=u[0],ce=u[z-1];if(c+=l.skippedSegments*l.targetduration,c>0&&z&&ce){l.averagetargetduration=c/z;var ue=ce.sn;l.endSN=ue!=="initSegment"?ue:0,l.live||(ce.endList=!0),Ee&&(l.startCC=Ee.cc)}else l.endSN=0,l.startCC=0;return l.fragmentHint&&(c+=l.fragmentHint.duration),l.totalduration=c,l.endCC=v,S>0&&Gn(u,S),l},a}();function Pr(a,n,i){var e,t,r=new ae(a),s=(e=r.METHOD)!=null?e:"",o=r.URI,l=r.hexadecimalInteger("IV"),u=r.KEYFORMATVERSIONS,d=(t=r.KEYFORMAT)!=null?t:"identity";o&&r.IV&&!l&&R.error("Invalid IV: "+r.IV);var f=o?ze.resolve(o,n):"",h=(u||"1").split("/").map(Number).filter(Number.isFinite);return new Cn(s,f,d,h,l)}function wr(a){var n=new ae(a),i=n.decimalFloatingPoint("TIME-OFFSET");return M(i)?i:null}function Un(a,n){var i=(a||"").split(/[ ,]+/).filter(function(e){return e});["video","audio","text"].forEach(function(e){var t=i.filter(function(r){return kn(r,e)});t.length&&(n[e+"Codec"]=t.join(","),i=i.filter(function(r){return t.indexOf(r)===-1}))}),n.unknownCodecs=i}function kr(a,n,i){var e=n[i];e&&(a[i]=e)}function Gn(a,n){for(var i=a[n],e=n;e--;){var t=a[e];if(!t)return;t.programDateTime=i.programDateTime-t.duration*1e3,i=t}}function Fr(a,n){a.rawProgramDateTime?a.programDateTime=Date.parse(a.rawProgramDateTime):n!=null&&n.programDateTime&&(a.programDateTime=n.endProgramDateTime),M(a.programDateTime)||(a.programDateTime=null,a.rawProgramDateTime=null)}function Mr(a,n,i,e){a.relurl=n.URI,n.BYTERANGE&&a.setByteRange(n.BYTERANGE),a.level=i,a.sn="initSegment",e&&(a.levelkeys=e),a.initSegment=null}function Or(a,n,i){a.levelkeys=n;var e=i.encryptedFragments;(!e.length||e[e.length-1].levelkeys!==n)&&Object.keys(n).some(function(t){return n[t].isCommonEncryption})&&e.push(a)}var Y={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},q={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function Nr(a){var n=a.type;switch(n){case Y.AUDIO_TRACK:return q.AUDIO;case Y.SUBTITLE_TRACK:return q.SUBTITLE;default:return q.MAIN}}function kt(a,n){var i=a.url;return(i===void 0||i.indexOf("data:")===0)&&(i=n.url),i}var Hn=function(){function a(i){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=i,this.registerListeners()}var n=a.prototype;return n.startLoad=function(e){},n.stopLoad=function(){this.destroyInternalLoaders()},n.registerListeners=function(){var e=this.hls;e.on(x.MANIFEST_LOADING,this.onManifestLoading,this),e.on(x.LEVEL_LOADING,this.onLevelLoading,this),e.on(x.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(x.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},n.unregisterListeners=function(){var e=this.hls;e.off(x.MANIFEST_LOADING,this.onManifestLoading,this),e.off(x.LEVEL_LOADING,this.onLevelLoading,this),e.off(x.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(x.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},n.createInternalLoader=function(e){var t=this.hls.config,r=t.pLoader,s=t.loader,o=r||s,l=new o(t);return this.loaders[e.type]=l,l},n.getInternalLoader=function(e){return this.loaders[e.type]},n.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},n.destroyInternalLoaders=function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}},n.destroy=function(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()},n.onManifestLoading=function(e,t){var r=t.url;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:Y.MANIFEST,url:r,deliveryDirectives:null})},n.onLevelLoading=function(e,t){var r=t.id,s=t.level,o=t.pathwayId,l=t.url,u=t.deliveryDirectives;this.load({id:r,level:s,pathwayId:o,responseType:"text",type:Y.LEVEL,url:l,deliveryDirectives:u})},n.onAudioTrackLoading=function(e,t){var r=t.id,s=t.groupId,o=t.url,l=t.deliveryDirectives;this.load({id:r,groupId:s,level:null,responseType:"text",type:Y.AUDIO_TRACK,url:o,deliveryDirectives:l})},n.onSubtitleTrackLoading=function(e,t){var r=t.id,s=t.groupId,o=t.url,l=t.deliveryDirectives;this.load({id:r,groupId:s,level:null,responseType:"text",type:Y.SUBTITLE_TRACK,url:o,deliveryDirectives:l})},n.load=function(e){var t,r=this,s=this.hls.config,o=this.getInternalLoader(e);if(o){var l=o.context;if(l&&l.url===e.url&&l.level===e.level){R.trace("[playlist-loader]: playlist request ongoing");return}R.log("[playlist-loader]: aborting previous loader for type: "+e.type),o.abort()}var u;if(e.type===Y.MANIFEST?u=s.manifestLoadPolicy.default:u=xe({},s.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),o=this.createInternalLoader(e),M((t=e.deliveryDirectives)==null?void 0:t.part)){var d;if(e.type===Y.LEVEL&&e.level!==null?d=this.hls.levels[e.level].details:e.type===Y.AUDIO_TRACK&&e.id!==null?d=this.hls.audioTracks[e.id].details:e.type===Y.SUBTITLE_TRACK&&e.id!==null&&(d=this.hls.subtitleTracks[e.id].details),d){var f=d.partTarget,h=d.targetduration;if(f&&h){var c=Math.max(f*3,h*.8)*1e3;u=xe({},u,{maxTimeToFirstByteMs:Math.min(c,u.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(c,u.maxTimeToFirstByteMs)})}}}var v=u.errorRetry||u.timeoutRetry||{},g={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:v.maxNumRetry||0,retryDelay:v.retryDelayMs||0,maxRetryDelay:v.maxRetryDelayMs||0},m={onSuccess:function(y,E,S,L){var _=r.getInternalLoader(S);r.resetInternalLoader(S.type);var A=y.data;if(A.indexOf("#EXTM3U")!==0){r.handleManifestParsingError(y,S,new Error("no EXTM3U delimiter"),L||null,E);return}E.parsing.start=performance.now(),ze.isMediaPlaylist(A)?r.handleTrackOrLevelPlaylist(y,E,S,L||null,_):r.handleMasterPlaylist(y,E,S,L)},onError:function(y,E,S,L){r.handleNetworkError(E,S,!1,y,L)},onTimeout:function(y,E,S){r.handleNetworkError(E,S,!0,void 0,y)}};o.load(e,g,m)},n.handleMasterPlaylist=function(e,t,r,s){var o=this.hls,l=e.data,u=kt(e,r),d=ze.parseMasterPlaylist(l,u);if(d.playlistParsingError){this.handleManifestParsingError(e,r,d.playlistParsingError,s,t);return}var f=d.contentSteering,h=d.levels,c=d.sessionData,v=d.sessionKeys,g=d.startTimeOffset,m=d.variableList;this.variableList=m;var p=ze.parseMasterPlaylistMedia(l,u,d),y=p.AUDIO,E=y===void 0?[]:y,S=p.SUBTITLES,L=p["CLOSED-CAPTIONS"];if(E.length){var _=E.some(function(A){return!A.url});!_&&h[0].audioCodec&&!h[0].attrs.AUDIO&&(R.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),E.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new ae({}),bitrate:0,url:""}))}o.trigger(x.MANIFEST_LOADED,{levels:h,audioTracks:E,subtitles:S,captions:L,contentSteering:f,url:u,stats:t,networkDetails:s,sessionData:c,sessionKeys:v,startTimeOffset:g,variableList:m})},n.handleTrackOrLevelPlaylist=function(e,t,r,s,o){var l=this.hls,u=r.id,d=r.level,f=r.type,h=kt(e,r),c=0,v=M(d)?d:M(u)?u:0,g=Nr(r),m=ze.parseLevelPlaylist(e.data,h,v,g,c,this.variableList);if(f===Y.MANIFEST){var p={attrs:new ae({}),bitrate:0,details:m,name:"",url:h};l.trigger(x.MANIFEST_LOADED,{levels:[p],audioTracks:[],url:h,stats:t,networkDetails:s,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),r.levelDetails=m,this.handlePlaylistLoaded(m,e,t,r,s,o)},n.handleManifestParsingError=function(e,t,r,s,o){this.hls.trigger(x.ERROR,{type:V.NETWORK_ERROR,details:D.MANIFEST_PARSING_ERROR,fatal:t.type===Y.MANIFEST,url:e.url,err:r,error:r,reason:r.message,response:e,context:t,networkDetails:s,stats:o})},n.handleNetworkError=function(e,t,r,s,o){r===void 0&&(r=!1);var l="A network "+(r?"timeout":"error"+(s?" (status "+s.code+")":""))+" occurred while loading "+e.type;e.type===Y.LEVEL?l+=": "+e.level+" id: "+e.id:(e.type===Y.AUDIO_TRACK||e.type===Y.SUBTITLE_TRACK)&&(l+=" id: "+e.id+' group-id: "'+e.groupId+'"');var u=new Error(l);R.warn("[playlist-loader]: "+l);var d=D.UNKNOWN,f=!1,h=this.getInternalLoader(e);switch(e.type){case Y.MANIFEST:d=r?D.MANIFEST_LOAD_TIMEOUT:D.MANIFEST_LOAD_ERROR,f=!0;break;case Y.LEVEL:d=r?D.LEVEL_LOAD_TIMEOUT:D.LEVEL_LOAD_ERROR,f=!1;break;case Y.AUDIO_TRACK:d=r?D.AUDIO_TRACK_LOAD_TIMEOUT:D.AUDIO_TRACK_LOAD_ERROR,f=!1;break;case Y.SUBTITLE_TRACK:d=r?D.SUBTITLE_TRACK_LOAD_TIMEOUT:D.SUBTITLE_LOAD_ERROR,f=!1;break}h&&this.resetInternalLoader(e.type);var c={type:V.NETWORK_ERROR,details:d,fatal:f,url:e.url,loader:h,context:e,error:u,networkDetails:t,stats:o};if(s){var v=t?.url||e.url;c.response=ne({url:v,data:void 0},s)}this.hls.trigger(x.ERROR,c)},n.handlePlaylistLoaded=function(e,t,r,s,o,l){var u=this.hls,d=s.type,f=s.level,h=s.id,c=s.groupId,v=s.deliveryDirectives,g=kt(t,s),m=Nr(s),p=typeof s.level=="number"&&m===q.MAIN?f:void 0;if(!e.fragments.length){var y=new Error("No Segments found in Playlist");u.trigger(x.ERROR,{type:V.NETWORK_ERROR,details:D.LEVEL_EMPTY_ERROR,fatal:!1,url:g,error:y,reason:y.message,response:t,context:s,level:p,parent:m,networkDetails:o,stats:r});return}e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));var E=e.playlistParsingError;if(E){u.trigger(x.ERROR,{type:V.NETWORK_ERROR,details:D.LEVEL_PARSING_ERROR,fatal:!1,url:g,error:E,reason:E.message,response:t,context:s,level:p,parent:m,networkDetails:o,stats:r});return}switch(e.live&&l&&(l.getCacheAge&&(e.ageHeader=l.getCacheAge()||0),(!l.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),d){case Y.MANIFEST:case Y.LEVEL:u.trigger(x.LEVEL_LOADED,{details:e,level:p||0,id:h||0,stats:r,networkDetails:o,deliveryDirectives:v});break;case Y.AUDIO_TRACK:u.trigger(x.AUDIO_TRACK_LOADED,{details:e,id:h||0,groupId:c||"",stats:r,networkDetails:o,deliveryDirectives:v});break;case Y.SUBTITLE_TRACK:u.trigger(x.SUBTITLE_TRACK_LOADED,{details:e,id:h||0,groupId:c||"",stats:r,networkDetails:o,deliveryDirectives:v});break}},a}();function Vn(a,n){var i;try{i=new Event("addtrack")}catch{i=document.createEvent("Event"),i.initEvent("addtrack",!1,!1)}i.track=a,n.dispatchEvent(i)}function Kn(a){var n=a.mode;if(n==="disabled"&&(a.mode="hidden"),a.cues)for(var i=a.cues.length;i--;)a.removeCue(a.cues[i]);n==="disabled"&&(a.mode=n)}function Wn(a,n,i,e){var t=a.mode;if(t==="disabled"&&(a.mode="hidden"),a.cues&&a.cues.length>0)for(var r=qn(a.cues,n,i),s=0;s<r.length;s++)(!e||e(r[s]))&&a.removeCue(r[s]);t==="disabled"&&(a.mode=t)}function Yn(a,n){if(n<a[0].startTime)return 0;var i=a.length-1;if(n>a[i].endTime)return-1;for(var e=0,t=i;e<=t;){var r=Math.floor((t+e)/2);if(n<a[r].startTime)t=r-1;else if(n>a[r].startTime&&e<i)e=r+1;else return r}return a[e].startTime-n<n-a[t].startTime?e:t}function qn(a,n,i){var e=[],t=Yn(a,n);if(t>-1)for(var r=t,s=a.length;r<s;r++){var o=a[r];if(o.startTime>=n&&o.endTime<=i)e.push(o);else if(o.startTime>i)return e}return e}var Ae={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"},jn=.25;function Ft(){if(!(typeof self>"u"))return self.VTTCue||self.TextTrackCue}function Br(a,n,i,e,t){var r=new a(n,i,"");try{r.value=e,t&&(r.type=t)}catch{r=new a(n,i,JSON.stringify(t?ne({type:t},e):e))}return r}var ot=function(){var a=Ft();try{a&&new a(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();function Mt(a,n){return a.getTime()/1e3-n}function Xn(a){return Uint8Array.from(a.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var zn=function(){function a(i){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=i,this._registerListeners()}var n=a.prototype;return n.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},n._registerListeners=function(){var e=this.hls;e.on(x.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(x.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(x.MANIFEST_LOADING,this.onManifestLoading,this),e.on(x.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(x.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(x.LEVEL_UPDATED,this.onLevelUpdated,this)},n._unregisterListeners=function(){var e=this.hls;e.off(x.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(x.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(x.MANIFEST_LOADING,this.onManifestLoading,this),e.off(x.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(x.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(x.LEVEL_UPDATED,this.onLevelUpdated,this)},n.onMediaAttached=function(e,t){this.media=t.media},n.onMediaDetaching=function(){this.id3Track&&(Kn(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})},n.onManifestLoading=function(){this.dateRangeCuesAppended={}},n.createTrack=function(e){var t=this.getID3Track(e.textTracks);return t.mode="hidden",t},n.getID3Track=function(e){if(this.media){for(var t=0;t<e.length;t++){var r=e[t];if(r.kind==="metadata"&&r.label==="id3")return Vn(r,this.media),r}return this.media.addTextTrack("metadata","id3")}},n.onFragParsingMetadata=function(e,t){if(this.media){var r=this.hls.config,s=r.enableEmsgMetadataCues,o=r.enableID3MetadataCues;if(!(!s&&!o)){var l=t.samples;this.id3Track||(this.id3Track=this.createTrack(this.media));var u=Ft();if(u)for(var d=0;d<l.length;d++){var f=l[d].type;if(!(f===Ae.emsg&&!s||!o)){var h=gr(l[d].data);if(h){var c=l[d].pts,v=c+l[d].duration;v>ot&&(v=ot);var g=v-c;g<=0&&(v=c+jn);for(var m=0;m<h.length;m++){var p=h[m];if(!vr(p)){this.updateId3CueEnds(c,f);var y=Br(u,c,v,p,f);y&&this.id3Track.addCue(y)}}}}}}}},n.updateId3CueEnds=function(e,t){var r,s=(r=this.id3Track)==null?void 0:r.cues;if(s)for(var o=s.length;o--;){var l=s[o];l.type===t&&l.startTime<e&&l.endTime===ot&&(l.endTime=e)}},n.onBufferFlushing=function(e,t){var r=t.startOffset,s=t.endOffset,o=t.type,l=this.id3Track,u=this.hls;if(u){var d=u.config,f=d.enableEmsgMetadataCues,h=d.enableID3MetadataCues;if(l&&(f||h)){var c;o==="audio"?c=function(g){return g.type===Ae.audioId3&&h}:o==="video"?c=function(g){return g.type===Ae.emsg&&f}:c=function(g){return g.type===Ae.audioId3&&h||g.type===Ae.emsg&&f},Wn(l,r,s,c)}}},n.onLevelUpdated=function(e,t){var r=this,s=t.details;if(!(!this.media||!s.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)){var o=this.dateRangeCuesAppended,l=this.id3Track,u=s.dateRanges,d=Object.keys(u);if(l)for(var f=Object.keys(o).filter(function(E){return!d.includes(E)}),h=function(){var S=f[c];Object.keys(o[S].cues).forEach(function(L){l.removeCue(o[S].cues[L])}),delete o[S]},c=f.length;c--;)h();var v=s.fragments[s.fragments.length-1];if(!(d.length===0||!M(v?.programDateTime))){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var g=v.programDateTime/1e3-v.start,m=Ft(),p=function(){var S=d[y],L=u[S],_=Mt(L.startDate,g),A=o[S],T=A?.cues||{},b=A?.durationKnown||!1,I=ot,P=L.endDate;if(P)I=Mt(P,g),b=!0;else if(L.endOnNext&&!b){var C=d.reduce(function(K,B){if(B!==L.id){var Q=u[B];if(Q.class===L.class&&Q.startDate>L.startDate&&(!K||L.startDate<K.startDate))return Q}return K},null);C&&(I=Mt(C.startDate,g),b=!0)}for(var w=Object.keys(L.attr),O=0;O<w.length;O++){var F=w[O];if(en(F)){var H=T[F];if(H)b&&!A.durationKnown&&(H.endTime=I);else if(m){var U=L.attr[F];tn(F)&&(U=Xn(U));var W=Br(m,_,I,{key:F,data:U},Ae.dateRange);W&&(W.id=S,r.id3Track.addCue(W),T[F]=W)}}}o[S]={cues:T,dateRange:L,durationKnown:b}},y=0;y<d.length;y++)p()}}},a}(),$n=function(){function a(i){var e=this;this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=function(){return e.timeupdate()},this.hls=i,this.config=i.config,this.registerListeners()}var n=a.prototype;return n.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},n.registerListeners=function(){this.hls.on(x.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(x.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(x.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(x.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(x.ERROR,this.onError,this)},n.unregisterListeners=function(){this.hls.off(x.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(x.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(x.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(x.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(x.ERROR,this.onError,this)},n.onMediaAttached=function(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},n.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},n.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},n.onLevelUpdated=function(e,t){var r=t.details;this.levelDetails=r,r.advanced&&this.timeupdate(),!r.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},n.onError=function(e,t){var r;t.details===D.BUFFER_STALLED_ERROR&&(this.stallCount++,(r=this.levelDetails)!=null&&r.live&&R.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},n.timeupdate=function(){var e=this.media,t=this.levelDetails;if(!(!e||!t)){this.currentTime=e.currentTime;var r=this.computeLatency();if(r!==null){this._latency=r;var s=this.config,o=s.lowLatencyMode,l=s.maxLiveSyncPlaybackRate;if(!(!o||l===1||!t.live)){var u=this.targetLatency;if(u!==null){var d=r-u,f=Math.min(this.maxLatency,u+t.targetduration),h=d<f;if(h&&d>.05&&this.forwardBufferLength>1){var c=Math.min(2,Math.max(1,l)),v=Math.round(2/(1+Math.exp(-.75*d-this.edgeStalled))*20)/20;e.playbackRate=Math.min(c,Math.max(1,v))}else e.playbackRate!==1&&e.playbackRate!==0&&(e.playbackRate=1)}}}}},n.estimateLiveEdge=function(){var e=this.levelDetails;return e===null?null:e.edge+e.age},n.computeLatency=function(){var e=this.estimateLiveEdge();return e===null?null:e-this.currentTime},ge(a,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var e=this.config,t=this.levelDetails;return e.liveMaxLatencyDuration!==void 0?e.liveMaxLatencyDuration:t?e.liveMaxLatencyDurationCount*t.targetduration:0}},{key:"targetLatency",get:function(){var e=this.levelDetails;if(e===null)return null;var t=e.holdBack,r=e.partHoldBack,s=e.targetduration,o=this.config,l=o.liveSyncDuration,u=o.liveSyncDurationCount,d=o.lowLatencyMode,f=this.hls.userConfig,h=d&&r||t;(f.liveSyncDuration||f.liveSyncDurationCount||h===0)&&(h=l!==void 0?l:u*s);var c=s,v=1;return h+Math.min(this.stallCount*v,c)}},{key:"liveSyncPosition",get:function(){var e=this.estimateLiveEdge(),t=this.targetLatency,r=this.levelDetails;if(e===null||t===null||r===null)return null;var s=r.edge,o=e-t-this.edgeStalled,l=s-r.totalduration,u=s-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(l,o),u)}},{key:"drift",get:function(){var e=this.levelDetails;return e===null?1:e.drift}},{key:"edgeStalled",get:function(){var e=this.levelDetails;if(e===null)return 0;var t=(this.config.lowLatencyMode&&e.partTarget||e.targetduration)*3;return Math.max(e.age-t,0)}},{key:"forwardBufferLength",get:function(){var e=this.media,t=this.levelDetails;if(!e||!t)return 0;var r=e.buffered.length;return(r?e.buffered.end(r-1):t.edge)-this.currentTime}}]),a}(),Ot=["NONE","TYPE-0","TYPE-1",null];function Qn(a){return Ot.indexOf(a)>-1}var lt=["SDR","PQ","HLG"];function Zn(a){return!!a&<.indexOf(a)>-1}var ut={No:"",Yes:"YES",v2:"v2"};function Ur(a){var n=a.canSkipUntil,i=a.canSkipDateRanges,e=a.age,t=e<n/2;return n&&t?i?ut.v2:ut.Yes:ut.No}var Gr=function(){function a(i,e,t){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=i,this.part=e,this.skip=t}var n=a.prototype;return n.addDirectives=function(e){var t=new self.URL(e);return this.msn!==void 0&&t.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href},a}(),Nt=function(){function a(i){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=void 0,this._urlId=0,this.url=[i.url],this._attrs=[i.attrs],this.bitrate=i.bitrate,i.details&&(this.details=i.details),this.id=i.id||0,this.name=i.name,this.width=i.width||0,this.height=i.height||0,this.frameRate=i.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=i.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=i.audioCodec,this.videoCodec=i.videoCodec,this.codecSet=[i.videoCodec,i.audioCodec].filter(function(e){return!!e}).map(function(e){return e.substring(0,4)}).join(","),this.addGroupId("audio",i.attrs.AUDIO),this.addGroupId("text",i.attrs.SUBTITLES)}var n=a.prototype;return n.hasAudioGroup=function(e){return Hr(this._audioGroups,e)},n.hasSubtitleGroup=function(e){return Hr(this._subtitleGroups,e)},n.addGroupId=function(e,t){if(t){if(e==="audio"){var r=this._audioGroups;r||(r=this._audioGroups=[]),r.indexOf(t)===-1&&r.push(t)}else if(e==="text"){var s=this._subtitleGroups;s||(s=this._subtitleGroups=[]),s.indexOf(t)===-1&&s.push(t)}}},n.addFallback=function(){},ge(a,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"averageBitrate",get:function(){return this._avgBitrate||this.realBitrate||this.bitrate}},{key:"attrs",get:function(){return this._attrs[0]}},{key:"codecs",get:function(){return this.attrs.CODECS||""}},{key:"pathwayId",get:function(){return this.attrs["PATHWAY-ID"]||"."}},{key:"videoRange",get:function(){return this.attrs["VIDEO-RANGE"]||"SDR"}},{key:"score",get:function(){return this.attrs.optionalFloat("SCORE",0)}},{key:"uri",get:function(){return this.url[0]||""}},{key:"audioGroups",get:function(){return this._audioGroups}},{key:"subtitleGroups",get:function(){return this._subtitleGroups}},{key:"urlId",get:function(){return 0},set:function(e){}},{key:"audioGroupIds",get:function(){return this.audioGroups?[this.audioGroupId]:void 0}},{key:"textGroupIds",get:function(){return this.subtitleGroups?[this.textGroupId]:void 0}},{key:"audioGroupId",get:function(){var e;return(e=this.audioGroups)==null?void 0:e[0]}},{key:"textGroupId",get:function(){var e;return(e=this.subtitleGroups)==null?void 0:e[0]}}]),a}();function Hr(a,n){return!n||!a?!1:a.indexOf(n)!==-1}function Bt(a,n){var i=n.startPTS;if(M(i)){var e=0,t;n.sn>a.sn?(e=i-a.start,t=a):(e=a.start-i,t=n),t.duration!==e&&(t.duration=e)}else if(n.sn>a.sn){var r=a.cc===n.cc;r&&a.minEndPTS?n.start=a.start+(a.minEndPTS-a.start):n.start=a.start+a.duration}else n.start=Math.max(a.start-n.duration,0)}function Vr(a,n,i,e,t,r){var s=e-i;s<=0&&(R.warn("Fragment should have a positive duration",n),e=i+n.duration,r=t+n.duration);var o=i,l=e,u=n.startPTS,d=n.endPTS;if(M(u)){var f=Math.abs(u-i);M(n.deltaPTS)?n.deltaPTS=Math.max(f,n.deltaPTS):n.deltaPTS=f,o=Math.max(i,u),i=Math.min(i,u),t=Math.min(t,n.startDTS),l=Math.min(e,d),e=Math.max(e,d),r=Math.max(r,n.endDTS)}var h=i-n.start;n.start!==0&&(n.start=i),n.duration=e-n.start,n.startPTS=i,n.maxStartPTS=o,n.startDTS=t,n.endPTS=e,n.minEndPTS=l,n.endDTS=r;var c=n.sn;if(!a||c<a.startSN||c>a.endSN)return 0;var v,g=c-a.startSN,m=a.fragments;for(m[g]=n,v=g;v>0;v--)Bt(m[v],m[v-1]);for(v=g;v<m.length-1;v++)Bt(m[v],m[v+1]);return a.fragmentHint&&Bt(m[m.length-1],a.fragmentHint),a.PTSKnown=a.alignedSliding=!0,h}function Jn(a,n){for(var i=null,e=a.fragments,t=e.length-1;t>=0;t--){var r=e[t].initSegment;if(r){i=r;break}}a.fragmentHint&&delete a.fragmentHint.endPTS;var s=0,o;if(ra(a,n,function(v,g){v.relurl&&(s=v.cc-g.cc),M(v.startPTS)&&M(v.endPTS)&&(g.start=g.startPTS=v.startPTS,g.startDTS=v.startDTS,g.maxStartPTS=v.maxStartPTS,g.endPTS=v.endPTS,g.endDTS=v.endDTS,g.minEndPTS=v.minEndPTS,g.duration=v.endPTS-v.startPTS,g.duration&&(o=g),n.PTSKnown=n.alignedSliding=!0),g.elementaryStreams=v.elementaryStreams,g.loader=v.loader,g.stats=v.stats,v.initSegment&&(g.initSegment=v.initSegment,i=v.initSegment)}),i){var l=n.fragmentHint?n.fragments.concat(n.fragmentHint):n.fragments;l.forEach(function(v){var g;v&&(!v.initSegment||v.initSegment.relurl===((g=i)==null?void 0:g.relurl))&&(v.initSegment=i)})}if(n.skippedSegments)if(n.deltaUpdateFailed=n.fragments.some(function(v){return!v}),n.deltaUpdateFailed){R.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var u=n.skippedSegments;u--;)n.fragments.shift();n.startSN=n.fragments[0].sn,n.startCC=n.fragments[0].cc}else n.canSkipDateRanges&&(n.dateRanges=ea(a.dateRanges,n.dateRanges,n.recentlyRemovedDateranges));var d=n.fragments;if(s){R.warn("discontinuity sliding from playlist, take drift into account");for(var f=0;f<d.length;f++)d[f].cc+=s}n.skippedSegments&&(n.startCC=n.fragments[0].cc),ta(a.partList,n.partList,function(v,g){g.elementaryStreams=v.elementaryStreams,g.stats=v.stats}),o?Vr(n,o,o.startPTS,o.endPTS,o.startDTS,o.endDTS):Kr(a,n),d.length&&(n.totalduration=n.edge-d[0].start),n.driftStartTime=a.driftStartTime,n.driftStart=a.driftStart;var h=n.advancedDateTime;if(n.advanced&&h){var c=n.edge;n.driftStart||(n.driftStartTime=h,n.driftStart=c),n.driftEndTime=h,n.driftEnd=c}else n.driftEndTime=a.driftEndTime,n.driftEnd=a.driftEnd,n.advancedDateTime=a.advancedDateTime}function ea(a,n,i){var e=xe({},a);return i&&i.forEach(function(t){delete e[t]}),Object.keys(n).forEach(function(t){var r=new fr(n[t].attr,e[t]);r.isValid?e[t]=r:R.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(n[t].attr)+'"')}),e}function ta(a,n,i){if(a&&n)for(var e=0,t=0,r=a.length;t<=r;t++){var s=a[t],o=n[t+e];s&&o&&s.index===o.index&&s.fragment.sn===o.fragment.sn?i(s,o):e--}}function ra(a,n,i){for(var e=n.skippedSegments,t=Math.max(a.startSN,n.startSN)-n.startSN,r=(a.fragmentHint?1:0)+(e?n.endSN:Math.min(a.endSN,n.endSN))-n.startSN,s=n.startSN-a.startSN,o=n.fragmentHint?n.fragments.concat(n.fragmentHint):n.fragments,l=a.fragmentHint?a.fragments.concat(a.fragmentHint):a.fragments,u=t;u<=r;u++){var d=l[s+u],f=o[u];e&&!f&&u<e&&(f=n.fragments[u]=d),d&&f&&i(d,f)}}function Kr(a,n){var i=n.startSN+n.skippedSegments-a.startSN,e=a.fragments;i<0||i>=e.length||ia(n,e[i].start)}function ia(a,n){if(n){for(var i=a.fragments,e=a.skippedSegments;e<i.length;e++)i[e].start+=n;a.fragmentHint&&(a.fragmentHint.start+=n)}}function na(a,n){n===void 0&&(n=1/0);var i=1e3*a.targetduration;if(a.updated){var e=a.fragments,t=4;if(e.length&&i*t>n){var r=e[e.length-1].duration*1e3;r<i&&(i=r)}}else i/=2;return Math.round(i)}function aa(a,n,i){if(!(a!=null&&a.details))return null;var e=a.details,t=e.fragments[n-e.startSN];return t||(t=e.fragmentHint,t&&t.sn===n)?t:n<e.startSN&&i&&i.sn===n?i:null}function Wr(a,n,i){var e;return a!=null&&a.details?Yr((e=a.details)==null?void 0:e.partList,n,i):null}function Yr(a,n,i){if(a)for(var e=a.length;e--;){var t=a[e];if(t.index===i&&t.fragment.sn===n)return t}return null}function qr(a){a.forEach(function(n,i){var e=n.details;e!=null&&e.fragments&&e.fragments.forEach(function(t){t.level=i})})}function ft(a){switch(a.details){case D.FRAG_LOAD_TIMEOUT:case D.KEY_LOAD_TIMEOUT:case D.LEVEL_LOAD_TIMEOUT:case D.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function jr(a,n){var i=ft(n);return a.default[(i?"timeout":"error")+"Retry"]}function Ut(a,n){var i=a.backoff==="linear"?1:Math.pow(2,n);return Math.min(i*a.retryDelayMs,a.maxRetryDelayMs)}function Xr(a){return ne(ne({},a),{errorRetry:null,timeoutRetry:null})}function dt(a,n,i,e){if(!a)return!1;var t=e?.code,r=n<a.maxNumRetry&&(sa(t)||!!i);return a.shouldRetry?a.shouldRetry(a,n,i,e,r):r}function sa(a){return a===0&&navigator.onLine===!1||!!a&&(a<400||a>499)}var zr={search:function(n,i){for(var e=0,t=n.length-1,r=null,s=null;e<=t;){r=(e+t)/2|0,s=n[r];var o=i(s);if(o>0)e=r+1;else if(o<0)t=r-1;else return s}return null}};function oa(a,n,i){if(n===null||!Array.isArray(a)||!a.length||!M(n))return null;var e=a[0].programDateTime;if(n<(e||0))return null;var t=a[a.length-1].endProgramDateTime;if(n>=(t||0))return null;i=i||0;for(var r=0;r<a.length;++r){var s=a[r];if(ua(n,i,s))return s}return null}function $r(a,n,i,e,t){i===void 0&&(i=0),e===void 0&&(e=0),t===void 0&&(t=.005);var r=null;if(a){r=n[a.sn-n[0].sn+1]||null;var s=a.endDTS-i;s>0&&s<15e-7&&(i+=15e-7)}else i===0&&n[0].start===0&&(r=n[0]);if(r&&((!a||a.level===r.level)&&Qr(i,e,r)===0||la(r,a,Math.min(t,e))))return r;var o=zr.search(n,Qr.bind(null,i,e));return o&&(o!==a||!r)?o:r}function la(a,n,i){if(n&&n.start===0&&n.level<a.level&&(n.endPTS||0)>0){var e=n.tagList.reduce(function(t,r){return r[0]==="INF"&&(t+=parseFloat(r[1])),t},i);return a.start<=e}return!1}function Qr(a,n,i){if(a===void 0&&(a=0),n===void 0&&(n=0),i.start<=a&&i.start+i.duration>a)return 0;var e=Math.min(n,i.duration+(i.deltaPTS?i.deltaPTS:0));return i.start+i.duration-e<=a?1:i.start-e>a&&i.start?-1:0}function ua(a,n,i){var e=Math.min(n,i.duration+(i.deltaPTS?i.deltaPTS:0))*1e3,t=i.endProgramDateTime||0;return t-e>a}function fa(a,n){return zr.search(a,function(i){return i.cc<n?1:i.cc>n?-1:0})}var fe={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},Re={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4},da=function(){function a(i){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=i,this.log=R.log.bind(R,"[info]:"),this.warn=R.warn.bind(R,"[warning]:"),this.error=R.error.bind(R,"[error]:"),this.registerListeners()}var n=a.prototype;return n.registerListeners=function(){var e=this.hls;e.on(x.ERROR,this.onError,this),e.on(x.MANIFEST_LOADING,this.onManifestLoading,this),e.on(x.LEVEL_UPDATED,this.onLevelUpdated,this)},n.unregisterListeners=function(){var e=this.hls;e&&(e.off(x.ERROR,this.onError,this),e.off(x.ERROR,this.onErrorOut,this),e.off(x.MANIFEST_LOADING,this.onManifestLoading,this),e.off(x.LEVEL_UPDATED,this.onLevelUpdated,this))},n.destroy=function(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}},n.startLoad=function(e){},n.stopLoad=function(){this.playlistError=0},n.getVariantLevelIndex=function(e){return e?.type===q.MAIN?e.level:this.hls.loadLevel},n.onManifestLoading=function(){this.playlistError=0,this.penalizedRenditions={}},n.onLevelUpdated=function(){this.playlistError=0},n.onError=function(e,t){var r,s;if(!t.fatal){var o=this.hls,l=t.context;switch(t.details){case D.FRAG_LOAD_ERROR:case D.FRAG_LOAD_TIMEOUT:case D.KEY_LOAD_ERROR:case D.KEY_LOAD_TIMEOUT:t.errorAction=this.getFragRetryOrSwitchAction(t);return;case D.FRAG_PARSING_ERROR:if((r=t.frag)!=null&&r.gap){t.errorAction={action:fe.DoNothing,flags:Re.None};return}case D.FRAG_GAP:case D.FRAG_DECRYPT_ERROR:{t.errorAction=this.getFragRetryOrSwitchAction(t),t.errorAction.action=fe.SendAlternateToPenaltyBox;return}case D.LEVEL_EMPTY_ERROR:case D.LEVEL_PARSING_ERROR:{var u,d,f=t.parent===q.MAIN?t.level:o.loadLevel;t.details===D.LEVEL_EMPTY_ERROR&&((u=t.context)!=null&&(d=u.levelDetails)!=null&&d.live)?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,f):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,f))}return;case D.LEVEL_LOAD_ERROR:case D.LEVEL_LOAD_TIMEOUT:typeof l?.level=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,l.level));return;case D.AUDIO_TRACK_LOAD_ERROR:case D.AUDIO_TRACK_LOAD_TIMEOUT:case D.SUBTITLE_LOAD_ERROR:case D.SUBTITLE_TRACK_LOAD_TIMEOUT:if(l){var h=o.levels[o.loadLevel];if(h&&(l.type===Y.AUDIO_TRACK&&h.hasAudioGroup(l.groupId)||l.type===Y.SUBTITLE_TRACK&&h.hasSubtitleGroup(l.groupId))){t.errorAction=this.getPlaylistRetryOrSwitchAction(t,o.loadLevel),t.errorAction.action=fe.SendAlternateToPenaltyBox,t.errorAction.flags=Re.MoveAllAlternatesMatchingHost;return}}return;case D.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{var c=o.levels[o.loadLevel],v=c?.attrs["HDCP-LEVEL"];v?t.errorAction={action:fe.SendAlternateToPenaltyBox,flags:Re.MoveAllAlternatesMatchingHDCP,hdcpLevel:v}:this.keySystemError(t)}return;case D.BUFFER_ADD_CODEC_ERROR:case D.REMUX_ALLOC_ERROR:case D.BUFFER_APPEND_ERROR:t.errorAction=this.getLevelSwitchAction(t,(s=t.level)!=null?s:o.loadLevel);return;case D.INTERNAL_EXCEPTION:case D.BUFFER_APPENDING_ERROR:case D.BUFFER_FULL_ERROR:case D.LEVEL_SWITCH_ERROR:case D.BUFFER_STALLED_ERROR:case D.BUFFER_SEEK_OVER_HOLE:case D.BUFFER_NUDGE_ON_STALL:t.errorAction={action:fe.DoNothing,flags:Re.None};return}t.type===V.KEY_SYSTEM_ERROR&&this.keySystemError(t)}},n.keySystemError=function(e){var t=this.getVariantLevelIndex(e.frag);e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,t)},n.getPlaylistRetryOrSwitchAction=function(e,t){var r=this.hls,s=jr(r.config.playlistLoadPolicy,e),o=this.playlistError++,l=dt(s,o,ft(e),e.response);if(l)return{action:fe.RetryRequest,flags:Re.None,retryConfig:s,retryCount:o};var u=this.getLevelSwitchAction(e,t);return s&&(u.retryConfig=s,u.retryCount=o),u},n.getFragRetryOrSwitchAction=function(e){var t=this.hls,r=this.getVariantLevelIndex(e.frag),s=t.levels[r],o=t.config,l=o.fragLoadPolicy,u=o.keyLoadPolicy,d=jr(e.details.startsWith("key")?u:l,e),f=t.levels.reduce(function(v,g){return v+g.fragmentError},0);if(s){e.details!==D.FRAG_GAP&&s.fragmentError++;var h=dt(d,f,ft(e),e.response);if(h)return{action:fe.RetryRequest,flags:Re.None,retryConfig:d,retryCount:f}}var c=this.getLevelSwitchAction(e,r);return d&&(c.retryConfig=d,c.retryCount=f),c},n.getLevelSwitchAction=function(e,t){var r=this.hls;t==null&&(t=r.loadLevel);var s=this.hls.levels[t];if(s){var o,l,u=e.details;s.loadError++,u===D.BUFFER_APPEND_ERROR&&s.fragmentError++;var d=-1,f=r.levels,h=r.loadLevel,c=r.minAutoLevel,v=r.maxAutoLevel;r.autoLevelEnabled||(r.loadLevel=-1);for(var g=(o=e.frag)==null?void 0:o.type,m=g===q.AUDIO&&u===D.FRAG_PARSING_ERROR||e.sourceBufferName==="audio"&&(u===D.BUFFER_ADD_CODEC_ERROR||u===D.BUFFER_APPEND_ERROR),p=m&&f.some(function(I){var P=I.audioCodec;return s.audioCodec!==P}),y=e.sourceBufferName==="video"&&(u===D.BUFFER_ADD_CODEC_ERROR||u===D.BUFFER_APPEND_ERROR),E=y&&f.some(function(I){var P=I.codecSet,C=I.audioCodec;return s.codecSet!==P&&s.audioCodec===C}),S=(l=e.context)!=null?l:{},L=S.type,_=S.groupId,A=function(){var P=(b+h)%f.length;if(P!==h&&P>=c&&P<=v&&f[P].loadError===0){var C,w,O=f[P];if(u===D.FRAG_GAP&&g===q.MAIN&&e.frag){var F=f[P].details;if(F){var H=$r(e.frag,F.fragments,e.frag.start);if(H!=null&&H.gap)return 0}}else{if(L===Y.AUDIO_TRACK&&O.hasAudioGroup(_)||L===Y.SUBTITLE_TRACK&&O.hasSubtitleGroup(_))return 0;if(g===q.AUDIO&&(C=s.audioGroups)!=null&&C.some(function(U){return O.hasAudioGroup(U)})||g===q.SUBTITLE&&(w=s.subtitleGroups)!=null&&w.some(function(U){return O.hasSubtitleGroup(U)})||p&&s.audioCodec===O.audioCodec||!p&&s.audioCodec!==O.audioCodec||E&&s.codecSet===O.codecSet)return 0}return d=P,1}},T,b=f.length;b--&&(T=A(),!(T!==0&&T===1)););if(d>-1&&r.loadLevel!==d)return e.levelRetry=!0,this.playlistError=0,{action:fe.SendAlternateToPenaltyBox,flags:Re.None,nextAutoLevel:d}}return{action:fe.SendAlternateToPenaltyBox,flags:Re.MoveAllAlternatesMatchingHost}},n.onErrorOut=function(e,t){var r;switch((r=t.errorAction)==null?void 0:r.action){case fe.DoNothing:break;case fe.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(t),!t.errorAction.resolved&&t.details!==D.FRAG_GAP?t.fatal=!0:/MediaSource readyState: ended/.test(t.error.message)&&(this.warn('MediaSource ended after "'+t.sourceBufferName+'" sourceBuffer append error. Attempting to recover from media error.'),this.hls.recoverMediaError());break}if(t.fatal){this.hls.stopLoad();return}},n.sendAlternateToPenaltyBox=function(e){var t=this.hls,r=e.errorAction;if(r){var s=r.flags,o=r.hdcpLevel,l=r.nextAutoLevel;switch(s){case Re.None:this.switchLevel(e,l);break;case Re.MoveAllAlternatesMatchingHDCP:o&&(t.maxHdcpLevel=Ot[Ot.indexOf(o)-1],r.resolved=!0),this.warn('Restricting playback to HDCP-LEVEL of "'+t.maxHdcpLevel+'" or lower');break}r.resolved||this.switchLevel(e,l)}},n.switchLevel=function(e,t){t!==void 0&&e.errorAction&&(this.warn("switching to level "+t+" after "+e.details),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)},a}(),ha=function(){function a(i,e){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=R.log.bind(R,e+":"),this.warn=R.warn.bind(R,e+":"),this.hls=i}var n=a.prototype;return n.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},n.clearTimer=function(){this.timer!==-1&&(self.clearTimeout(this.timer),this.timer=-1)},n.startLoad=function(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()},n.stopLoad=function(){this.canLoad=!1,this.clearTimer()},n.switchParams=function(e,t,r){var s=t?.renditionReports;if(s){for(var o=-1,l=0;l<s.length;l++){var u=s[l],d=void 0;try{d=new self.URL(u.URI,t.url).href}catch(m){R.warn("Could not construct new URL for Rendition Report: "+m),d=u.URI||""}if(d===e){o=l;break}else d===e.substring(0,d.length)&&(o=l)}if(o!==-1){var f=s[o],h=parseInt(f["LAST-MSN"])||t?.lastPartSn,c=parseInt(f["LAST-PART"])||t?.lastPartIndex;if(this.hls.config.lowLatencyMode){var v=Math.min(t.age-t.partTarget,t.targetduration);c>=0&&v>t.partTarget&&(c+=1)}var g=r&&Ur(r);return new Gr(h,c>=0?c:void 0,g)}}},n.loadPlaylist=function(e){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())},n.shouldLoadPlaylist=function(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)},n.shouldReloadPlaylist=function(e){return this.timer===-1&&this.requestScheduled===-1&&this.shouldLoadPlaylist(e)},n.playlistLoaded=function(e,t,r){var s=this,o=t.details,l=t.stats,u=self.performance.now(),d=l.loading.first?Math.max(0,u-l.loading.first):0;if(o.advancedDateTime=Date.now()-d,o.live||r!=null&&r.live){if(o.reloaded(r),r&&this.log("live playlist "+e+" "+(o.advanced?"REFRESHED "+o.lastPartSn+"-"+o.lastPartIndex:o.updated?"UPDATED":"MISSED")),r&&o.fragments.length>0&&Jn(r,o),!this.canLoad||!o.live)return;var f,h=void 0,c=void 0;if(o.canBlockReload&&o.endSN&&o.advanced){var v=this.hls.config.lowLatencyMode,g=o.lastPartSn,m=o.endSN,p=o.lastPartIndex,y=p!==-1,E=g===m,S=v?0:p;y?(h=E?m+1:g,c=E?S:p+1):h=m+1;var L=o.age,_=L+o.ageHeader,A=Math.min(_-o.partTarget,o.targetduration*1.5);if(A>0){if(r&&A>r.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+r.tuneInGoal+" to: "+A+" with playlist age: "+o.age),A=0;else{var T=Math.floor(A/o.targetduration);if(h+=T,c!==void 0){var b=Math.round(A%o.targetduration/o.partTarget);c+=b}this.log("CDN Tune-in age: "+o.ageHeader+"s last advanced "+L.toFixed(2)+"s goal: "+A+" skip sn "+T+" to part "+c)}o.tuneInGoal=A}if(f=this.getDeliveryDirectives(o,t.deliveryDirectives,h,c),v||!E){this.loadPlaylist(f);return}}else(o.canBlockReload||o.canSkipUntil)&&(f=this.getDeliveryDirectives(o,t.deliveryDirectives,h,c));var I=this.hls.mainForwardBufferInfo,P=I?I.end-I.len:0,C=(o.edge-P)*1e3,w=na(o,C);o.updated&&u>this.requestScheduled+w&&(this.requestScheduled=l.loading.start),h!==void 0&&o.canBlockReload?this.requestScheduled=l.loading.first+w-(o.partTarget*1e3||1e3):this.requestScheduled===-1||this.requestScheduled+w<u?this.requestScheduled=u:this.requestScheduled-u<=0&&(this.requestScheduled+=w);var O=this.requestScheduled-u;O=Math.max(0,O),this.log("reload live playlist "+e+" in "+Math.round(O)+" ms"),this.timer=self.setTimeout(function(){return s.loadPlaylist(f)},O)}else this.clearTimer()},n.getDeliveryDirectives=function(e,t,r,s){var o=Ur(e);return t!=null&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,s=t.part,o=ut.No),new Gr(r,s,o)},n.checkRetry=function(e){var t=this,r=e.details,s=ft(e),o=e.errorAction,l=o||{},u=l.action,d=l.retryCount,f=d===void 0?0:d,h=l.retryConfig,c=!!o&&!!h&&(u===fe.RetryRequest||!o.resolved&&u===fe.SendAlternateToPenaltyBox);if(c){var v;if(this.requestScheduled=-1,f>=h.maxNumRetry)return!1;if(s&&(v=e.context)!=null&&v.deliveryDirectives)this.warn("Retrying playlist loading "+(f+1)+"/"+h.maxNumRetry+' after "'+r+'" without delivery-directives'),this.loadPlaylist();else{var g=Ut(h,f);this.timer=self.setTimeout(function(){return t.loadPlaylist()},g),this.warn("Retrying playlist loading "+(f+1)+"/"+h.maxNumRetry+' after "'+r+'" in '+g+"ms")}e.levelRetry=!0,o.resolved=!0}return c},a}(),Ke=function(){function a(i,e,t){e===void 0&&(e=0),t===void 0&&(t=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=i,this.alpha_=i?Math.exp(Math.log(.5)/i):0,this.estimate_=e,this.totalWeight_=t}var n=a.prototype;return n.sample=function(e,t){var r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e},n.getTotalWeight=function(){return this.totalWeight_},n.getEstimate=function(){if(this.alpha_){var e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_},a}(),ca=function(){function a(i,e,t,r){r===void 0&&(r=100),this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=t,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new Ke(i),this.fast_=new Ke(e),this.defaultTTFB_=r,this.ttfb_=new Ke(i)}var n=a.prototype;return n.update=function(e,t){var r=this.slow_,s=this.fast_,o=this.ttfb_;r.halfLife!==e&&(this.slow_=new Ke(e,r.getEstimate(),r.getTotalWeight())),s.halfLife!==t&&(this.fast_=new Ke(t,s.getEstimate(),s.getTotalWeight())),o.halfLife!==e&&(this.ttfb_=new Ke(e,o.getEstimate(),o.getTotalWeight()))},n.sample=function(e,t){e=Math.max(e,this.minDelayMs_);var r=8*t,s=e/1e3,o=r/s;this.fast_.sample(s,o),this.slow_.sample(s,o)},n.sampleTTFB=function(e){var t=e/1e3,r=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(r,Math.max(e,5))},n.canEstimate=function(){return this.fast_.getTotalWeight()>=this.minWeight_},n.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},n.getEstimateTTFB=function(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_},n.destroy=function(){},a}();function va(){if(typeof matchMedia=="function"){var a=matchMedia("(dynamic-range: high)"),n=matchMedia("bad query");if(a.media!==n.media)return a.matches===!0}return!1}function ga(a,n){var i=!1,e=[];return a&&(i=a!=="SDR",e=[a]),n&&(e=n.allowedVideoRanges||lt.slice(0),i=n.preferHDR!==void 0?n.preferHDR:va(),i?e=e.filter(function(t){return t!=="SDR"}):e=["SDR"]),{preferHDR:i,allowedVideoRanges:e}}function ma(a,n,i,e,t){for(var r=Object.keys(a),s=e?.channels,o=e?.audioCodec,l=s&&parseInt(s)===2,u=!0,d=!1,f=1/0,h=1/0,c=1/0,v=0,g=[],m=ga(n,t),p=m.preferHDR,y=m.allowedVideoRanges,E=function(){var b=a[r[S]];u=b.channels[2]>0,f=Math.min(f,b.minHeight),h=Math.min(h,b.minFramerate),c=Math.min(c,b.minBitrate);var I=y.filter(function(P){return b.videoRanges[P]>0});I.length>0&&(d=!0,g=I)},S=r.length;S--;)E();f=M(f)?f:0,h=M(h)?h:0;var L=Math.max(1080,f),_=Math.max(30,h);c=M(c)?c:i,i=Math.max(c,i),d||(n=void 0,g=[]);var A=r.reduce(function(T,b){var I=a[b];if(b===T)return T;if(I.minBitrate>i)return Pe(b,"min bitrate of "+I.minBitrate+" > current estimate of "+i),T;if(!I.hasDefaultAudio)return Pe(b,"no renditions with default or auto-select sound found"),T;if(o&&b.indexOf(o.substring(0,4))%5!==0)return Pe(b,'audio codec preference "'+o+'" not found'),T;if(s&&!l){if(!I.channels[s])return Pe(b,"no renditions with "+s+" channel sound found (channels options: "+Object.keys(I.channels)+")"),T}else if((!o||l)&&u&&I.channels[2]===0)return Pe(b,"no renditions with stereo sound found"),T;return I.minHeight>L?(Pe(b,"min resolution of "+I.minHeight+" > maximum of "+L),T):I.minFramerate>_?(Pe(b,"min framerate of "+I.minFramerate+" > maximum of "+_),T):g.some(function(P){return I.videoRanges[P]>0})?I.maxScore<v?(Pe(b,"max score of "+I.maxScore+" < selected max of "+v),T):T&&(at(b)>=at(T)||I.fragmentError>a[T].fragmentError)?T:(v=I.maxScore,b):(Pe(b,"no variants with VIDEO-RANGE of "+JSON.stringify(g)+" found"),T)},void 0);return{codecSet:A,videoRanges:g,preferHDR:p,minFramerate:h,minBitrate:c}}function Pe(a,n){R.log('[abr] start candidates with "'+a+'" ignored because '+n)}function pa(a){return a.reduce(function(n,i){var e=n.groups[i.groupId];e||(e=n.groups[i.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),e.tracks.push(i);var t=i.channels||"2";return e.channels[t]=(e.channels[t]||0)+1,e.hasDefault=e.hasDefault||i.default,e.hasAutoSelect=e.hasAutoSelect||i.autoselect,e.hasDefault&&(n.hasDefaultAudio=!0),e.hasAutoSelect&&(n.hasAutoSelectAudio=!0),n},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function ya(a,n,i,e){return a.slice(i,e+1).reduce(function(t,r){if(!r.codecSet)return t;var s=r.audioGroups,o=t[r.codecSet];o||(t[r.codecSet]=o={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!s,fragmentError:0}),o.minBitrate=Math.min(o.minBitrate,r.bitrate);var l=Math.min(r.height,r.width);return o.minHeight=Math.min(o.minHeight,l),o.minFramerate=Math.min(o.minFramerate,r.frameRate),o.maxScore=Math.max(o.maxScore,r.score),o.fragmentError+=r.fragmentError,o.videoRanges[r.videoRange]=(o.videoRanges[r.videoRange]||0)+1,t},{})}var Ea=function(){function a(i){var e=this;this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=-1,this.firstSelection=-1,this._nextAutoLevel=-1,this.nextAutoLevelKey="",this.audioTracksByGroup=null,this.codecTiers=null,this.timer=-1,this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this._abandonRulesCheck=function(){var t=e.fragCurrent,r=e.partCurrent,s=e.hls,o=s.autoLevelEnabled,l=s.media;if(!(!t||!l)){var u=performance.now(),d=r?r.stats:t.stats,f=r?r.duration:t.duration,h=u-d.loading.start,c=s.minAutoLevel;if(d.aborted||d.loaded&&d.loaded===d.total||t.level<=c){e.clearTimer(),e._nextAutoLevel=-1;return}if(!(!o||l.paused||!l.playbackRate||!l.readyState)){var v=s.mainForwardBufferInfo;if(v!==null){var g=e.bwEstimator.getEstimateTTFB(),m=Math.abs(l.playbackRate);if(!(h<=Math.max(g,1e3*(f/(m*2))))){var p=v.len/m,y=d.loading.first?d.loading.first-d.loading.start:-1,E=d.loaded&&y>-1,S=e.getBwEstimate(),L=s.levels,_=L[t.level],A=d.total||Math.max(d.loaded,Math.round(f*_.averageBitrate/8)),T=E?h-y:h;T<1&&E&&(T=Math.min(h,d.loaded*8/S));var b=E?d.loaded*1e3/T:0,I=b?(A-d.loaded)/b:A*8/S+g/1e3;if(!(I<=p)){var P=b?b*8:S,C=Number.POSITIVE_INFINITY,w;for(w=t.level-1;w>c;w--){var O=L[w].maxBitrate;if(C=e.getTimeToLoadFrag(g/1e3,P,f*O,!L[w].details),C<p)break}if(!(C>=I)&&!(C>f*10)){s.nextLoadLevel=s.nextAutoLevel=w,E?e.bwEstimator.sample(h-Math.min(g,y),d.loaded):e.bwEstimator.sampleTTFB(h);var F=L[w].maxBitrate;e.getBwEstimate()*e.hls.config.abrBandWidthUpFactor>F&&e.resetEstimator(F),e.clearTimer(),R.warn("[abr] Fragment "+t.sn+(r?" part "+r.index:"")+" of level "+t.level+` is loading too slowly;
|
2
|
+
Time to underbuffer: `+p.toFixed(3)+` s
|
3
|
+
Estimated load time for current fragment: `+I.toFixed(3)+` s
|
4
|
+
Estimated load time for down switch fragment: `+C.toFixed(3)+` s
|
5
|
+
TTFB estimate: `+(y|0)+` ms
|
6
|
+
Current BW estimate: `+(M(S)?S|0:"Unknown")+` bps
|
7
|
+
New BW estimate: `+(e.getBwEstimate()|0)+` bps
|
8
|
+
Switching to level `+w+" @ "+(F|0)+" bps"),s.trigger(x.FRAG_LOAD_EMERGENCY_ABORTED,{frag:t,part:r,stats:d})}}}}}}},this.hls=i,this.bwEstimator=this.initEstimator(),this.registerListeners()}var n=a.prototype;return n.resetEstimator=function(e){e&&(R.log("setting initial bwe to "+e),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()},n.initEstimator=function(){var e=this.hls.config;return new ca(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)},n.registerListeners=function(){var e=this.hls;e.on(x.MANIFEST_LOADING,this.onManifestLoading,this),e.on(x.FRAG_LOADING,this.onFragLoading,this),e.on(x.FRAG_LOADED,this.onFragLoaded,this),e.on(x.FRAG_BUFFERED,this.onFragBuffered,this),e.on(x.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(x.LEVEL_LOADED,this.onLevelLoaded,this),e.on(x.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(x.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(x.ERROR,this.onError,this)},n.unregisterListeners=function(){var e=this.hls;e&&(e.off(x.MANIFEST_LOADING,this.onManifestLoading,this),e.off(x.FRAG_LOADING,this.onFragLoading,this),e.off(x.FRAG_LOADED,this.onFragLoaded,this),e.off(x.FRAG_BUFFERED,this.onFragBuffered,this),e.off(x.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(x.LEVEL_LOADED,this.onLevelLoaded,this),e.off(x.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(x.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(x.ERROR,this.onError,this))},n.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=null,this.fragCurrent=this.partCurrent=null},n.onManifestLoading=function(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()},n.onLevelsUpdated=function(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null},n.onMaxAutoLevelUpdated=function(){this.firstSelection=-1,this.nextAutoLevelKey=""},n.onFragLoading=function(e,t){var r=t.frag;if(!this.ignoreFragment(r)){if(!r.bitrateTest){var s;this.fragCurrent=r,this.partCurrent=(s=t.part)!=null?s:null}this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100)}},n.onLevelSwitching=function(e,t){this.clearTimer()},n.onError=function(e,t){if(!t.fatal)switch(t.details){case D.BUFFER_ADD_CODEC_ERROR:case D.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case D.FRAG_LOAD_TIMEOUT:{var r=t.frag,s=this.fragCurrent,o=this.partCurrent;if(r&&s&&r.sn===s.sn&&r.level===s.level){var l=performance.now(),u=o?o.stats:r.stats,d=l-u.loading.start,f=u.loading.first?u.loading.first-u.loading.start:-1,h=u.loaded&&f>-1;if(h){var c=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(d-Math.min(c,f),u.loaded)}else this.bwEstimator.sampleTTFB(d)}break}}},n.getTimeToLoadFrag=function(e,t,r,s){var o=e+r/t,l=s?this.lastLevelLoadSec:0;return o+l},n.onLevelLoaded=function(e,t){var r=this.hls.config,s=t.stats.loading,o=s.end-s.start;M(o)&&(this.lastLevelLoadSec=o/1e3),t.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)},n.onFragLoaded=function(e,t){var r=t.frag,s=t.part,o=s?s.stats:r.stats;if(r.type===q.MAIN&&this.bwEstimator.sampleTTFB(o.loading.first-o.loading.start),!this.ignoreFragment(r)){if(this.clearTimer(),r.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){var l=s?s.duration:r.duration,u=this.hls.levels[r.level],d=(u.loaded?u.loaded.bytes:0)+o.loaded,f=(u.loaded?u.loaded.duration:0)+l;u.loaded={bytes:d,duration:f},u.realBitrate=Math.round(8*d/f)}if(r.bitrateTest){var h={stats:o,frag:r,part:s,id:r.type};this.onFragBuffered(x.FRAG_BUFFERED,h),r.bitrateTest=!1}else this.lastLoadedFragLevel=r.level}},n.onFragBuffered=function(e,t){var r=t.frag,s=t.part,o=s!=null&&s.stats.loaded?s.stats:r.stats;if(!o.aborted&&!this.ignoreFragment(r)){var l=o.parsing.end-o.loading.start-Math.min(o.loading.first-o.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(l,o.loaded),o.bwEstimate=this.getBwEstimate(),r.bitrateTest?this.bitrateTestDelay=l/1e3:this.bitrateTestDelay=0}},n.ignoreFragment=function(e){return e.type!==q.MAIN||e.sn==="initSegment"},n.clearTimer=function(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)},n.getAutoLevelKey=function(){return this.getBwEstimate()+"_"+this.getStarvationDelay().toFixed(2)},n.getNextABRAutoLevel=function(){var e=this.fragCurrent,t=this.partCurrent,r=this.hls,s=r.maxAutoLevel,o=r.config,l=r.minAutoLevel,u=t?t.duration:e?e.duration:0,d=this.getBwEstimate(),f=this.getStarvationDelay(),h=o.abrBandWidthFactor,c=o.abrBandWidthUpFactor;if(f){var v=this.findBestLevel(d,l,s,f,0,h,c);if(v>=0)return v}var g=u?Math.min(u,o.maxStarvationDelay):o.maxStarvationDelay;if(!f){var m=this.bitrateTestDelay;if(m){var p=u?Math.min(u,o.maxLoadingDelay):o.maxLoadingDelay;g=p-m,R.info("[abr] bitrate test took "+Math.round(1e3*m)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*g)+" ms"),h=c=1}}var y=this.findBestLevel(d,l,s,f,g,h,c);if(R.info("[abr] "+(f?"rebuffering expected":"buffer is empty")+", optimal quality level "+y),y>-1)return y;var E=r.levels[l],S=r.levels[r.loadLevel];return E?.bitrate<S?.bitrate?l:r.loadLevel},n.getStarvationDelay=function(){var e=this.hls,t=e.media;if(!t)return 1/0;var r=t&&t.playbackRate!==0?Math.abs(t.playbackRate):1,s=e.mainForwardBufferInfo;return(s?s.len:0)/r},n.getBwEstimate=function(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate},n.findBestLevel=function(e,t,r,s,o,l,u){var d,f=this,h=s+o,c=this.lastLoadedFragLevel,v=c===-1?this.hls.firstLevel:c,g=this.fragCurrent,m=this.partCurrent,p=this.hls,y=p.levels,E=p.allAudioTracks,S=p.loadLevel,L=p.config;if(y.length===1)return 0;var _=y[v],A=!!(_!=null&&(d=_.details)!=null&&d.live),T=S===-1||c===-1,b,I="SDR",P=_?.frameRate||0,C=L.audioPreference,w=L.videoPreference,O=this.audioTracksByGroup||(this.audioTracksByGroup=pa(E));if(T){if(this.firstSelection!==-1)return this.firstSelection;var F=this.codecTiers||(this.codecTiers=ya(y,O,t,r)),H=ma(F,I,e,C,w),U=H.codecSet,W=H.videoRanges,K=H.minFramerate,B=H.minBitrate,Q=H.preferHDR;b=U,I=Q?W[W.length-1]:W[0],P=K,e=Math.max(e,B),R.log("[abr] picked start tier "+JSON.stringify(H))}else b=_?.codecSet,I=_?.videoRange;for(var j=m?m.duration:g?g.duration:0,J=this.bwEstimator.getEstimateTTFB()/1e3,ee=[],re=function(){var Te,te=y[X],me=X>v;if(!te)return 0;if(b&&te.codecSet!==b||I&&te.videoRange!==I||me&&P>te.frameRate||!me&&P>0&&P<te.frameRate||te.supportedResult&&!((Te=te.supportedResult.decodingInfoResults)!=null&&Te[0].smooth))return ee.push(X),0;var pe=te.details,ie=(m?pe?.partTarget:pe?.averagetargetduration)||j,z;me?z=u*e:z=l*e;var Ee=j&&s>=j*2&&o===0?y[X].averageBitrate:y[X].maxBitrate,ce=f.getTimeToLoadFrag(J,z,Ee*ie,pe===void 0),ue=z>=Ee&&(X===c||te.loadError===0&&te.fragmentError===0)&&(ce<=J||!M(ce)||A&&!f.bitrateTestDelay||ce<h);if(ue){var Ve=f.forcedAutoLevel;return X!==S&&(Ve===-1||Ve!==S)&&(ee.length&&R.trace("[abr] Skipped level(s) "+ee.join(",")+" of "+r+' max with CODECS and VIDEO-RANGE:"'+y[ee[0]].codecs+'" '+y[ee[0]].videoRange+'; not compatible with "'+_.codecs+'" '+I),R.info("[abr] switch candidate:"+v+"->"+X+" adjustedbw("+Math.round(z)+")-bitrate="+Math.round(z-Ee)+" ttfb:"+J.toFixed(1)+" avgDuration:"+ie.toFixed(1)+" maxFetchDuration:"+h.toFixed(1)+" fetchDuration:"+ce.toFixed(1)+" firstSelection:"+T+" codecSet:"+b+" videoRange:"+I+" hls.loadLevel:"+S)),T&&(f.firstSelection=X),{v:X}}},Z,X=r;X>=t;X--)if(Z=re(),Z!==0&&Z)return Z.v;return-1},ge(a,[{key:"firstAutoLevel",get:function(){var e=this.hls,t=e.maxAutoLevel,r=e.minAutoLevel,s=this.getBwEstimate(),o=this.hls.config.maxStarvationDelay,l=this.findBestLevel(s,r,t,0,o,1,1);if(l>-1)return l;var u=this.hls.firstLevel,d=Math.min(Math.max(u,r),t);return R.warn("[abr] Could not find best starting auto level. Defaulting to first in playlist "+u+" clamped to "+d),d}},{key:"forcedAutoLevel",get:function(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}},{key:"nextAutoLevel",get:function(){var e=this.forcedAutoLevel,t=this.bwEstimator,r=t.canEstimate(),s=this.lastLoadedFragLevel>-1;if(e!==-1&&(!r||!s||this.nextAutoLevelKey===this.getAutoLevelKey()))return e;var o=r&&s?this.getNextABRAutoLevel():this.firstAutoLevel;if(e!==-1){var l=this.hls.levels;if(l.length>Math.max(e,o)&&l[e].loadError<=l[o].loadError)return e}return this._nextAutoLevel=o,this.nextAutoLevelKey=this.getAutoLevelKey(),o},set:function(e){var t=this.hls,r=t.maxAutoLevel,s=t.minAutoLevel,o=Math.min(Math.max(e,s),r);this._nextAutoLevel!==o&&(this.nextAutoLevelKey="",this._nextAutoLevel=o)}}]),a}(),xa={length:0,start:function(){return 0},end:function(){return 0}},se=function(){function a(){}return a.isBuffered=function(i,e){try{if(i){for(var t=a.getBuffered(i),r=0;r<t.length;r++)if(e>=t.start(r)&&e<=t.end(r))return!0}}catch{}return!1},a.bufferInfo=function(i,e,t){try{if(i){var r=a.getBuffered(i),s=[],o;for(o=0;o<r.length;o++)s.push({start:r.start(o),end:r.end(o)});return this.bufferedInfo(s,e,t)}}catch{}return{len:0,start:e,end:e,nextStart:void 0}},a.bufferedInfo=function(i,e,t){e=Math.max(0,e),i.sort(function(m,p){var y=m.start-p.start;return y||p.end-m.end});var r=[];if(t)for(var s=0;s<i.length;s++){var o=r.length;if(o){var l=r[o-1].end;i[s].start-l<t?i[s].end>l&&(r[o-1].end=i[s].end):r.push(i[s])}else r.push(i[s])}else r=i;for(var u=0,d,f=e,h=e,c=0;c<r.length;c++){var v=r[c].start,g=r[c].end;if(e+t>=v&&e<g)f=v,h=g,u=h-e;else if(e+t<v){d=v;break}}return{len:u,start:f||0,end:h||0,nextStart:d}},a.getBuffered=function(i){try{return i.buffered}catch(e){return R.log("failed to get media.buffered",e),xa}},a}(),Ta=function(){function a(i){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=i}var n=a.prototype;return n.append=function(e,t,r){var s=this.queues[t];s.push(e),s.length===1&&!r&&this.executeNext(t)},n.insertAbort=function(e,t){var r=this.queues[t];r.unshift(e),this.executeNext(t)},n.appendBlocker=function(e){var t,r=new Promise(function(o){t=o}),s={execute:t,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(s,e),r},n.executeNext=function(e){var t=this.queues[e];if(t.length){var r=t[0];try{r.execute()}catch(o){R.warn('[buffer-operation-queue]: Exception executing "'+e+'" SourceBuffer operation: '+o),r.onError(o);var s=this.buffers[e];s!=null&&s.updating||this.shiftAndExecuteNext(e)}}},n.shiftAndExecuteNext=function(e){this.queues[e].shift(),this.executeNext(e)},n.current=function(e){return this.queues[e][0]},a}(),Zr=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,Sa=function(){function a(i){var e=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendSource=void 0,this.appendErrors={audio:0,video:0,audiovideo:0},this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this.log=void 0,this.warn=void 0,this.error=void 0,this._onEndStreaming=function(r){e.hls&&e.hls.pauseBuffering()},this._onStartStreaming=function(r){e.hls&&e.hls.resumeBuffering()},this._onMediaSourceOpen=function(){var r=e.media,s=e.mediaSource;e.log("Media source opened"),r&&(r.removeEventListener("emptied",e._onMediaEmptied),e.updateMediaElementDuration(),e.hls.trigger(x.MEDIA_ATTACHED,{media:r,mediaSource:s})),s&&s.removeEventListener("sourceopen",e._onMediaSourceOpen),e.checkPendingTracks()},this._onMediaSourceClose=function(){e.log("Media source closed")},this._onMediaSourceEnded=function(){e.log("Media source ended")},this._onMediaEmptied=function(){var r=e.mediaSrc,s=e._objectUrl;r!==s&&R.error("Media element src was set while attaching MediaSource ("+s+" > "+r+")")},this.hls=i;var t="[buffer-controller]";this.appendSource=wn(Ge(i.config.preferManagedMediaSource)),this.log=R.log.bind(R,t),this.warn=R.warn.bind(R,t),this.error=R.error.bind(R,t),this._initSourceBuffer(),this.registerListeners()}var n=a.prototype;return n.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},n.destroy=function(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null,this.hls=null},n.registerListeners=function(){var e=this.hls;e.on(x.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(x.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(x.MANIFEST_LOADING,this.onManifestLoading,this),e.on(x.MANIFEST_PARSED,this.onManifestParsed,this),e.on(x.BUFFER_RESET,this.onBufferReset,this),e.on(x.BUFFER_APPENDING,this.onBufferAppending,this),e.on(x.BUFFER_CODECS,this.onBufferCodecs,this),e.on(x.BUFFER_EOS,this.onBufferEos,this),e.on(x.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(x.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(x.FRAG_PARSED,this.onFragParsed,this),e.on(x.FRAG_CHANGED,this.onFragChanged,this)},n.unregisterListeners=function(){var e=this.hls;e.off(x.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(x.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(x.MANIFEST_LOADING,this.onManifestLoading,this),e.off(x.MANIFEST_PARSED,this.onManifestParsed,this),e.off(x.BUFFER_RESET,this.onBufferReset,this),e.off(x.BUFFER_APPENDING,this.onBufferAppending,this),e.off(x.BUFFER_CODECS,this.onBufferCodecs,this),e.off(x.BUFFER_EOS,this.onBufferEos,this),e.off(x.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(x.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(x.FRAG_PARSED,this.onFragParsed,this),e.off(x.FRAG_CHANGED,this.onFragChanged,this)},n._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new Ta(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.appendErrors={audio:0,video:0,audiovideo:0},this.lastMpegAudioChunk=null},n.onManifestLoading=function(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null},n.onManifestParsed=function(e,t){var r=2;t.audio&&!t.video||t.altAudio,r=1,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r,this.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},n.onMediaAttaching=function(e,t){var r=this.media=t.media,s=Ge(this.appendSource);if(r&&s){var o,l=this.mediaSource=new s;this.log("created media source: "+((o=l.constructor)==null?void 0:o.name)),l.addEventListener("sourceopen",this._onMediaSourceOpen),l.addEventListener("sourceended",this._onMediaSourceEnded),l.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(l.addEventListener("startstreaming",this._onStartStreaming),l.addEventListener("endstreaming",this._onEndStreaming));var u=this._objectUrl=self.URL.createObjectURL(l);if(this.appendSource)try{r.removeAttribute("src");var d=self.ManagedMediaSource;r.disableRemotePlayback=r.disableRemotePlayback||d&&l instanceof d,Jr(r),La(r,u),r.load()}catch{r.src=u}else r.src=u;r.addEventListener("emptied",this._onMediaEmptied)}},n.onMediaDetaching=function(){var e=this.media,t=this.mediaSource,r=this._objectUrl;if(t){if(this.log("media source detaching"),t.readyState==="open")try{t.endOfStream()}catch(s){this.warn("onMediaDetaching: "+s.message+" while calling endOfStream")}this.onBufferReset(),t.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("sourceended",this._onMediaSourceEnded),t.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(t.removeEventListener("startstreaming",this._onStartStreaming),t.removeEventListener("endstreaming",this._onEndStreaming)),e&&(e.removeEventListener("emptied",this._onMediaEmptied),r&&self.URL.revokeObjectURL(r),this.mediaSrc===r?(e.removeAttribute("src"),this.appendSource&&Jr(e),e.load()):this.warn("media|source.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(x.MEDIA_DETACHED,void 0)},n.onBufferReset=function(){var e=this;this.getSourceBufferTypes().forEach(function(t){e.resetBuffer(t)}),this._initSourceBuffer()},n.resetBuffer=function(e){var t=this.sourceBuffer[e];try{if(t){var r;this.removeBufferListeners(e),this.sourceBuffer[e]=void 0,(r=this.mediaSource)!=null&&r.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(t)}}catch(s){this.warn("onBufferReset "+e,s)}},n.onBufferCodecs=function(e,t){var r=this,s=this.getSourceBufferTypes().length,o=Object.keys(t);if(o.forEach(function(u){if(s){var d=r.tracks[u];if(d&&typeof d.buffer.changeType=="function"){var f,h=t[u],c=h.id,v=h.codec,g=h.levelCodec,m=h.container,p=h.metadata,y=Ir(d.codec,d.levelCodec),E=y?.replace(Zr,"$1"),S=Ir(v,g),L=(f=S)==null?void 0:f.replace(Zr,"$1");if(S&&E!==L){u.slice(0,5)==="audio"&&(S=st(S,r.appendSource));var _=m+";codecs="+S;r.appendChangeType(u,_),r.log("switching codec "+y+" to "+S),r.tracks[u]={buffer:d.buffer,codec:v,container:m,levelCodec:g,metadata:p,id:c}}}}else r.pendingTracks[u]=t[u]}),!s){var l=Math.max(this.bufferCodecEventsExpected-1,0);this.bufferCodecEventsExpected!==l&&(this.log(l+" bufferCodec event(s) expected "+o.join(",")),this.bufferCodecEventsExpected=l),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks()}},n.appendChangeType=function(e,t){var r=this,s=this.operationQueue,o={execute:function(){var u=r.sourceBuffer[e];u&&(r.log("changing "+e+" sourceBuffer type to "+t),u.changeType(t)),s.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(u){r.warn("Failed to change "+e+" SourceBuffer type",u)}};s.append(o,e,!!this.pendingTracks[e])},n.onBufferAppending=function(e,t){var r=this,s=this.hls,o=this.operationQueue,l=this.tracks,u=t.data,d=t.type,f=t.frag,h=t.part,c=t.chunkMeta,v=c.buffering[d],g=self.performance.now();v.start=g;var m=f.stats.buffering,p=h?h.stats.buffering:null;m.start===0&&(m.start=g),p&&p.start===0&&(p.start=g);var y=l.audio,E=!1;d==="audio"&&y?.container==="audio/mpeg"&&(E=!this.lastMpegAudioChunk||c.id===1||this.lastMpegAudioChunk.sn!==c.sn,this.lastMpegAudioChunk=c);var S=f.start,L={execute:function(){if(v.executeStart=self.performance.now(),E){var A=r.sourceBuffer[d];if(A){var T=S-A.timestampOffset;Math.abs(T)>=.1&&(r.log("Updating audio SourceBuffer timestampOffset to "+S+" (delta: "+T+") sn: "+f.sn+")"),A.timestampOffset=S)}}r.appendExecutor(u,d)},onStart:function(){},onComplete:function(){var A=self.performance.now();v.executeEnd=v.end=A,m.first===0&&(m.first=A),p&&p.first===0&&(p.first=A);var T=r.sourceBuffer,b={};for(var I in T)b[I]=se.getBuffered(T[I]);r.appendErrors[d]=0,d==="audio"||d==="video"?r.appendErrors.audiovideo=0:(r.appendErrors.audio=0,r.appendErrors.video=0),r.hls.trigger(x.BUFFER_APPENDED,{type:d,frag:f,part:h,chunkMeta:c,parent:f.type,timeRanges:b})},onError:function(A){var T={type:V.MEDIA_ERROR,parent:f.type,details:D.BUFFER_APPEND_ERROR,sourceBufferName:d,frag:f,part:h,chunkMeta:c,error:A,err:A,fatal:!1};if(A.code===DOMException.QUOTA_EXCEEDED_ERR)T.details=D.BUFFER_FULL_ERROR;else{var b=++r.appendErrors[d];T.details=D.BUFFER_APPEND_ERROR,r.warn("Failed "+b+"/"+s.config.appendErrorMaxRetry+' times to append segment in "'+d+'" sourceBuffer'),b>=s.config.appendErrorMaxRetry&&(T.fatal=!0)}s.trigger(x.ERROR,T)}};o.append(L,d,!!this.pendingTracks[d])},n.onBufferFlushing=function(e,t){var r=this,s=this.operationQueue,o=function(u){return{execute:r.removeExecutor.bind(r,u,t.startOffset,t.endOffset),onStart:function(){},onComplete:function(){r.hls.trigger(x.BUFFER_FLUSHED,{type:u})},onError:function(f){r.warn("Failed to remove from "+u+" SourceBuffer",f)}}};t.type?s.append(o(t.type),t.type):this.getSourceBufferTypes().forEach(function(l){s.append(o(l),l)})},n.onFragParsed=function(e,t){var r=this,s=t.frag,o=t.part,l=[],u=o?o.elementaryStreams:s.elementaryStreams;u[$.AUDIOVIDEO]?l.push("audiovideo"):(u[$.AUDIO]&&l.push("audio"),u[$.VIDEO]&&l.push("video"));var d=function(){var h=self.performance.now();s.stats.buffering.end=h,o&&(o.stats.buffering.end=h);var c=o?o.stats:s.stats;r.hls.trigger(x.FRAG_BUFFERED,{frag:s,part:o,stats:c,id:s.type})};l.length===0&&this.warn("Fragments must have at least one ElementaryStreamType set. type: "+s.type+" level: "+s.level+" sn: "+s.sn),this.blockBuffers(d,l)},n.onFragChanged=function(e,t){this.trimBuffers()},n.onBufferEos=function(e,t){var r=this,s=this.getSourceBufferTypes().reduce(function(o,l){var u=r.sourceBuffer[l];return u&&(!t.type||t.type===l)&&(u.ending=!0,u.ended||(u.ended=!0,r.log(l+" sourceBuffer now EOS"))),o&&!!(!u||u.ended)},!0);s&&(this.log("Queueing mediaSource.endOfStream()"),this.blockBuffers(function(){r.getSourceBufferTypes().forEach(function(l){var u=r.sourceBuffer[l];u&&(u.ending=!1)});var o=r.mediaSource;if(!o||o.readyState!=="open"){o&&r.log("Could not call mediaSource.endOfStream(). mediaSource.readyState: "+o.readyState);return}r.log("Calling mediaSource.endOfStream()"),o.endOfStream()}))},n.onLevelUpdated=function(e,t){var r=t.details;r.fragments.length&&(this.details=r,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},n.trimBuffers=function(){var e=this.hls,t=this.details,r=this.media;if(!(!r||t===null)){var s=this.getSourceBufferTypes();if(s.length){var o=e.config,l=r.currentTime,u=t.levelTargetDuration,d=t.live&&o.liveBackBufferLength!==null?o.liveBackBufferLength:o.backBufferLength;if(M(d)&&d>0){var f=Math.max(d,u),h=Math.floor(l/u)*u-f;this.flushBackBuffer(l,u,h)}if(M(o.frontBufferFlushThreshold)&&o.frontBufferFlushThreshold>0){var c=Math.max(o.maxBufferLength,o.frontBufferFlushThreshold),v=Math.max(c,u),g=Math.floor(l/u)*u+v;this.flushFrontBuffer(l,u,g)}}}},n.flushBackBuffer=function(e,t,r){var s=this,o=this.details,l=this.sourceBuffer,u=this.getSourceBufferTypes();u.forEach(function(d){var f=l[d];if(f){var h=se.getBuffered(f);if(h.length>0&&r>h.start(0)){if(s.hls.trigger(x.BACK_BUFFER_REACHED,{bufferEnd:r}),o!=null&&o.live)s.hls.trigger(x.LIVE_BACK_BUFFER_REACHED,{bufferEnd:r});else if(f.ended&&h.end(h.length-1)-e<t*2){s.log("Cannot flush "+d+" back buffer while SourceBuffer is in ended state");return}s.hls.trigger(x.BUFFER_FLUSHING,{startOffset:0,endOffset:r,type:d})}}})},n.flushFrontBuffer=function(e,t,r){var s=this,o=this.sourceBuffer,l=this.getSourceBufferTypes();l.forEach(function(u){var d=o[u];if(d){var f=se.getBuffered(d),h=f.length;if(h<2)return;var c=f.start(h-1),v=f.end(h-1);if(r>c||e>=c&&e<=v)return;if(d.ended&&e-v<2*t){s.log("Cannot flush "+u+" front buffer while SourceBuffer is in ended state");return}s.hls.trigger(x.BUFFER_FLUSHING,{startOffset:c,endOffset:1/0,type:u})}})},n.updateMediaElementDuration=function(){if(!(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")){var e=this.details,t=this.hls,r=this.media,s=this.mediaSource,o=e.fragments[0].start+e.totalduration,l=r.duration,u=M(s.duration)?s.duration:0;e.live&&t.config.liveDurationInfinity?(s.duration=1/0,this.updateSeekableRange(e)):(o>u&&o>l||!M(l))&&(this.log("Updating Media Source duration to "+o.toFixed(3)),s.duration=o)}},n.updateSeekableRange=function(e){var t=this.mediaSource,r=e.fragments,s=r.length;if(s&&e.live&&t!=null&&t.setLiveSeekableRange){var o=Math.max(0,r[0].start),l=Math.max(o,o+e.totalduration);this.log("Media Source duration is set to "+t.duration+". Setting seekable range to "+o+"-"+l+"."),t.setLiveSeekableRange(o,l)}},n.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,t=this.operationQueue,r=this.pendingTracks,s=Object.keys(r).length;if(s&&(!e||s===2||"audiovideo"in r)){this.createSourceBuffers(r),this.pendingTracks={};var o=this.getSourceBufferTypes();if(o.length)this.hls.trigger(x.BUFFER_CREATED,{tracks:this.tracks}),o.forEach(function(u){t.executeNext(u)});else{var l=new Error("could not create source buffer for media codec(s)");this.hls.trigger(x.ERROR,{type:V.MEDIA_ERROR,details:D.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:l,reason:l.message})}}},n.createSourceBuffers=function(e){var t=this,r=this.sourceBuffer,s=this.mediaSource;if(!s)throw Error("createSourceBuffers called when mediaSource was null");var o=function(d){if(!r[d]){var f,h=e[d];if(!h)throw Error("source buffer exists for track "+d+", however track does not");var c=((f=h.levelCodec)==null?void 0:f.indexOf(","))===-1?h.levelCodec:h.codec;c&&d.slice(0,5)==="audio"&&(c=st(c,t.appendSource));var v=h.container+";codecs="+c;t.log("creating sourceBuffer("+v+")");try{var g=r[d]=s.addSourceBuffer(v),m=d;t.addBufferListener(m,"updatestart",t._onSBUpdateStart),t.addBufferListener(m,"updateend",t._onSBUpdateEnd),t.addBufferListener(m,"error",t._onSBUpdateError),t.appendSource&&t.addBufferListener(m,"bufferedchange",function(p,y){var E=y.removedRanges;E!=null&&E.length&&t.hls.trigger(x.BUFFER_FLUSHED,{type:d})}),t.tracks[d]={buffer:g,codec:c,container:h.container,levelCodec:h.levelCodec,metadata:h.metadata,id:h.id}}catch(p){t.error("error while trying to add sourceBuffer: "+p.message),t.hls.trigger(x.ERROR,{type:V.MEDIA_ERROR,details:D.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:p,sourceBufferName:d,mimeType:v})}}};for(var l in e)o(l)},n._onSBUpdateStart=function(e){var t=this.operationQueue,r=t.current(e);r.onStart()},n._onSBUpdateEnd=function(e){var t;if(((t=this.mediaSource)==null?void 0:t.readyState)==="closed"){this.resetBuffer(e);return}var r=this.operationQueue,s=r.current(e);s.onComplete(),r.shiftAndExecuteNext(e)},n._onSBUpdateError=function(e,t){var r,s=new Error(e+" SourceBuffer error. MediaSource readyState: "+((r=this.mediaSource)==null?void 0:r.readyState));this.error(""+s,t),this.hls.trigger(x.ERROR,{type:V.MEDIA_ERROR,details:D.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:s,fatal:!1});var o=this.operationQueue.current(e);o&&o.onError(s)},n.removeExecutor=function(e,t,r){var s=this.media,o=this.mediaSource,l=this.operationQueue,u=this.sourceBuffer,d=u[e];if(!s||!o||!d){this.warn("Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),l.shiftAndExecuteNext(e);return}var f=M(s.duration)?s.duration:1/0,h=M(o.duration)?o.duration:1/0,c=Math.max(0,t),v=Math.min(r,f,h);v>c&&(!d.ending||d.ended)?(d.ended=!1,this.log("Removing ["+c+","+v+"] from the "+e+" SourceBuffer"),d.remove(c,v)):l.shiftAndExecuteNext(e)},n.appendExecutor=function(e,t){var r=this.sourceBuffer[t];if(!r){if(!this.pendingTracks[t])throw new Error("Attempting to append to the "+t+" SourceBuffer, but it does not exist");return}r.ended=!1,r.appendBuffer(e)},n.blockBuffers=function(e,t){var r=this;if(t===void 0&&(t=this.getSourceBufferTypes()),!t.length){this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);return}var s=this.operationQueue,o=t.map(function(l){return s.appendBlocker(l)});Promise.all(o).then(function(){e(),t.forEach(function(l){var u=r.sourceBuffer[l];u!=null&&u.updating||s.shiftAndExecuteNext(l)})})},n.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},n.addBufferListener=function(e,t,r){var s=this.sourceBuffer[e];if(s){var o=r.bind(this,e);this.listeners[e].push({event:t,listener:o}),s.addEventListener(t,o)}},n.removeBufferListeners=function(e){var t=this.sourceBuffer[e];t&&this.listeners[e].forEach(function(r){t.removeEventListener(r.event,r.listener)})},ge(a,[{key:"mediaSrc",get:function(){var e,t,r=((e=this.media)==null||(t=e.querySelector)==null?void 0:t.call(e,"source"))||this.media;return r?.src}}]),a}();function Jr(a){var n=a.querySelectorAll("source");[].slice.call(n).forEach(function(i){a.removeChild(i)})}function La(a,n){var i=self.document.createElement("source");i.type="video/mp4",i.src=n,a.appendChild(i)}var Aa=function(){function a(i){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=i,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var n=a.prototype;return n.setStreamController=function(e){this.streamController=e},n.destroy=function(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},n.registerListeners=function(){var e=this.hls;e.on(x.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(x.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(x.MANIFEST_PARSED,this.onManifestParsed,this),e.on(x.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(x.BUFFER_CODECS,this.onBufferCodecs,this),e.on(x.MEDIA_DETACHING,this.onMediaDetaching,this)},n.unregisterListener=function(){var e=this.hls;e.off(x.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(x.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(x.MANIFEST_PARSED,this.onManifestParsed,this),e.off(x.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(x.BUFFER_CODECS,this.onBufferCodecs,this),e.off(x.MEDIA_DETACHING,this.onMediaDetaching,this)},n.onFpsDropLevelCapping=function(e,t){var r=this.hls.levels[t.droppedLevel];this.isLevelAllowed(r)&&this.restrictedLevels.push({bitrate:r.bitrate,height:r.height,width:r.width})},n.onMediaAttaching=function(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()},n.onManifestParsed=function(e,t){var r=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,r.config.capLevelToPlayerSize&&t.video&&this.startCapping()},n.onLevelsUpdated=function(e,t){this.timer&&M(this.autoLevelCapping)&&this.detectPlayerSize()},n.onBufferCodecs=function(e,t){var r=this.hls;r.config.capLevelToPlayerSize&&t.video&&this.startCapping()},n.onMediaDetaching=function(){this.stopCapping()},n.detectPlayerSize=function(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0){this.clientRect=null;return}var e=this.hls.levels;if(e.length){var t=this.hls,r=this.getMaxLevel(e.length-1);r!==this.autoLevelCapping&&R.log("Setting autoLevelCapping to "+r+": "+e[r].height+"p@"+e[r].bitrate+" for media "+this.mediaWidth+"x"+this.mediaHeight),t.autoLevelCapping=r,t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}},n.getMaxLevel=function(e){var t=this,r=this.hls.levels;if(!r.length)return-1;var s=r.filter(function(o,l){return t.isLevelAllowed(o)&&l<=e});return this.clientRect=null,a.getMaxLevelByMediaSize(s,this.mediaWidth,this.mediaHeight)},n.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},n.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},n.getDimensions=function(){if(this.clientRect)return this.clientRect;var e=this.media,t={width:0,height:0};if(e){var r=e.getBoundingClientRect();t.width=r.width,t.height=r.height,!t.width&&!t.height&&(t.width=r.right-r.left||e.width||0,t.height=r.bottom-r.top||e.height||0)}return this.clientRect=t,t},n.isLevelAllowed=function(e){var t=this.restrictedLevels;return!t.some(function(r){return e.bitrate===r.bitrate&&e.width===r.width&&e.height===r.height})},a.getMaxLevelByMediaSize=function(e,t,r){if(!(e!=null&&e.length))return-1;for(var s=function(h,c){return c?h.width!==c.width||h.height!==c.height:!0},o=e.length-1,l=Math.max(t,r),u=0;u<e.length;u+=1){var d=e[u];if((d.width>=l||d.height>=l)&&s(d,e[u+1])){o=u;break}}return o},ge(a,[{key:"mediaWidth",get:function(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function(){var e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch{}return e}}]),a}(),Ra=function(){function a(i){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=i,this.registerListeners()}var n=a.prototype;return n.setStreamController=function(e){this.streamController=e},n.registerListeners=function(){this.hls.on(x.MEDIA_ATTACHING,this.onMediaAttaching,this)},n.unregisterListeners=function(){this.hls.off(x.MEDIA_ATTACHING,this.onMediaAttaching,this)},n.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},n.onMediaAttaching=function(e,t){var r=this.hls.config;if(r.capLevelOnFPSDrop){var s=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=s,s&&typeof s.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}},n.checkFPS=function(e,t,r){var s=performance.now();if(t){if(this.lastTime){var o=s-this.lastTime,l=r-this.lastDroppedFrames,u=t-this.lastDecodedFrames,d=1e3*l/o,f=this.hls;if(f.trigger(x.FPS_DROP,{currentDropped:l,currentDecoded:u,totalDroppedFrames:r}),d>0&&l>f.config.fpsDroppedMonitoringThreshold*u){var h=f.currentLevel;R.warn("drop FPS ratio greater than max allowed value for currentLevel: "+h),h>0&&(f.autoLevelCapping===-1||f.autoLevelCapping>=h)&&(h=h-1,f.trigger(x.FPS_DROP_LEVEL_CAPPING,{level:h,droppedLevel:f.currentLevel}),f.autoLevelCapping=h,this.streamController.nextLevelSwitch())}}this.lastTime=s,this.lastDroppedFrames=r,this.lastDecodedFrames=t}},n.checkFPSInterval=function(){var e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){var t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)},a}(),ba=3e5,Ia=function(){function a(i){this.hls=void 0,this.log=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this.pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=i,this.log=R.log.bind(R,"[content-steering]:"),this.registerListeners()}var n=a.prototype;return n.registerListeners=function(){var e=this.hls;e.on(x.MANIFEST_LOADING,this.onManifestLoading,this),e.on(x.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(x.MANIFEST_PARSED,this.onManifestParsed,this),e.on(x.ERROR,this.onError,this)},n.unregisterListeners=function(){var e=this.hls;e&&(e.off(x.MANIFEST_LOADING,this.onManifestLoading,this),e.off(x.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(x.MANIFEST_PARSED,this.onManifestParsed,this),e.off(x.ERROR,this.onError,this))},n.startLoad=function(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){var e=this.timeToLoad*1e3-(performance.now()-this.updated);if(e>0){this.scheduleRefresh(this.uri,e);return}}this.loadSteeringManifest(this.uri)}},n.stopLoad=function(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()},n.clearTimeout=function(){this.reloadTimer!==-1&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)},n.destroy=function(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null},n.removeLevel=function(e){var t=this.levels;t&&(this.levels=t.filter(function(r){return r!==e}))},n.onManifestLoading=function(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null},n.onManifestLoaded=function(e,t){var r=t.contentSteering;r!==null&&(this.pathwayId=r.pathwayId,this.uri=r.uri,this.started&&this.startLoad())},n.onManifestParsed=function(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks},n.onError=function(e,t){var r=t.errorAction;if(r?.action===fe.SendAlternateToPenaltyBox&&r.flags===Re.MoveAllAlternatesMatchingHost){var s=this.levels,o=this.pathwayPriority,l=this.pathwayId;if(t.context){var u=t.context,d=u.groupId,f=u.pathwayId,h=u.type;d&&s?l=this.getPathwayForGroupId(d,h,l):f&&(l=f)}l in this.penalizedPathways||(this.penalizedPathways[l]=performance.now()),!o&&s&&(o=s.reduce(function(c,v){return c.indexOf(v.pathwayId)===-1&&c.push(v.pathwayId),c},[])),o&&o.length>1&&(this.updatePathwayPriority(o),r.resolved=this.pathwayId!==l),r.resolved||R.warn("Could not resolve "+t.details+' ("'+t.error.message+'") with content-steering for Pathway: '+l+" levels: "+(s&&s.length)+" priorities: "+JSON.stringify(o)+" penalized: "+JSON.stringify(this.penalizedPathways))}},n.filterParsedLevels=function(e){this.levels=e;var t=this.getLevelsForPathway(this.pathwayId);if(t.length===0){var r=e[0].pathwayId;this.log("No levels found in Pathway "+this.pathwayId+'. Setting initial Pathway to "'+r+'"'),t=this.getLevelsForPathway(r),this.pathwayId=r}return t.length!==e.length&&this.log("Found "+t.length+"/"+e.length+' levels in Pathway "'+this.pathwayId+'"'),t},n.getLevelsForPathway=function(e){return this.levels===null?[]:this.levels.filter(function(t){return e===t.pathwayId})},n.updatePathwayPriority=function(e){this.pathwayPriority=e;var t,r=this.penalizedPathways,s=performance.now();Object.keys(r).forEach(function(h){s-r[h]>ba&&delete r[h]});for(var o=0;o<e.length;o++){var l=e[o];if(!(l in r)){if(l===this.pathwayId)return;var u=this.hls.nextLoadLevel,d=this.hls.levels[u];if(t=this.getLevelsForPathway(l),t.length>0){this.log('Setting Pathway to "'+l+'"'),this.pathwayId=l,qr(t),this.hls.trigger(x.LEVELS_UPDATED,{levels:t});var f=this.hls.levels[u];d&&f&&this.levels&&(f.attrs["STABLE-VARIANT-ID"]!==d.attrs["STABLE-VARIANT-ID"]&&f.bitrate!==d.bitrate&&this.log("Unstable Pathways change from bitrate "+d.bitrate+" to "+f.bitrate),this.hls.nextLoadLevel=u);break}}}},n.getPathwayForGroupId=function(e,t,r){for(var s=this.getLevelsForPathway(r).concat(this.levels||[]),o=0;o<s.length;o++)if(t===Y.AUDIO_TRACK&&s[o].hasAudioGroup(e)||t===Y.SUBTITLE_TRACK&&s[o].hasSubtitleGroup(e))return s[o].pathwayId;return r},n.clonePathways=function(e){var t=this,r=this.levels;if(r){var s={},o={};e.forEach(function(l){var u=l.ID,d=l["BASE-ID"],f=l["URI-REPLACEMENT"];if(!r.some(function(c){return c.pathwayId===u})){var h=t.getLevelsForPathway(d).map(function(c){var v=new ae(c.attrs);v["PATHWAY-ID"]=u;var g=v.AUDIO&&v.AUDIO+"_clone_"+u,m=v.SUBTITLES&&v.SUBTITLES+"_clone_"+u;g&&(s[v.AUDIO]=g,v.AUDIO=g),m&&(o[v.SUBTITLES]=m,v.SUBTITLES=m);var p=ti(c.uri,v["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",f),y=new Nt({attrs:v,audioCodec:c.audioCodec,bitrate:c.bitrate,height:c.height,name:c.name,url:p,videoCodec:c.videoCodec,width:c.width});if(c.audioGroups)for(var E=1;E<c.audioGroups.length;E++)y.addGroupId("audio",c.audioGroups[E]+"_clone_"+u);if(c.subtitleGroups)for(var S=1;S<c.subtitleGroups.length;S++)y.addGroupId("text",c.subtitleGroups[S]+"_clone_"+u);return y});r.push.apply(r,h),ei(t.audioTracks,s,f,u),ei(t.subtitleTracks,o,f,u)}})}},n.loadSteeringManifest=function(e){var t=this,r=this.hls.config,s=r.loader;this.loader&&this.loader.destroy(),this.loader=new s(r);var o;try{o=new self.URL(e)}catch{this.enabled=!1,this.log("Failed to parse Steering Manifest URI: "+e);return}if(o.protocol!=="data:"){var l=(this.hls.bandwidthEstimate||r.abrEwmaDefaultEstimate)|0;o.searchParams.set("_HLS_pathway",this.pathwayId),o.searchParams.set("_HLS_throughput",""+l)}var u={responseType:"json",url:o.href},d=r.steeringManifestLoadPolicy.default,f=d.errorRetry||d.timeoutRetry||{},h={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:f.maxNumRetry||0,retryDelay:f.retryDelayMs||0,maxRetryDelay:f.maxRetryDelayMs||0},c={onSuccess:function(g,m,p,y){t.log('Loaded steering manifest: "'+o+'"');var E=g.data;if(E.VERSION!==1){t.log("Steering VERSION "+E.VERSION+" not supported!");return}t.updated=performance.now(),t.timeToLoad=E.TTL;var S=E["RELOAD-URI"],L=E["PATHWAY-CLONES"],_=E["PATHWAY-PRIORITY"];if(S)try{t.uri=new self.URL(S,o).href}catch{t.enabled=!1,t.log("Failed to parse Steering Manifest RELOAD-URI: "+S);return}t.scheduleRefresh(t.uri||p.url),L&&t.clonePathways(L);var A={steeringManifest:E,url:o.toString()};t.hls.trigger(x.STEERING_MANIFEST_LOADED,A),_&&t.updatePathwayPriority(_)},onError:function(g,m,p,y){if(t.log("Error loading steering manifest: "+g.code+" "+g.text+" ("+m.url+")"),t.stopLoad(),g.code===410){t.enabled=!1,t.log("Steering manifest "+m.url+" no longer available");return}var E=t.timeToLoad*1e3;if(g.code===429){var S=t.loader;if(typeof S?.getResponseHeader=="function"){var L=S.getResponseHeader("Retry-After");L&&(E=parseFloat(L)*1e3)}t.log("Steering manifest "+m.url+" rate limited");return}t.scheduleRefresh(t.uri||m.url,E)},onTimeout:function(g,m,p){t.log("Timeout loading steering manifest ("+m.url+")"),t.scheduleRefresh(t.uri||m.url)}};this.log("Requesting steering manifest: "+o),this.loader.load(u,h,c)},n.scheduleRefresh=function(e,t){var r=this;t===void 0&&(t=this.timeToLoad*1e3),this.clearTimeout(),this.reloadTimer=self.setTimeout(function(){var s,o=(s=r.hls)==null?void 0:s.media;if(o&&!o.ended){r.loadSteeringManifest(e);return}r.scheduleRefresh(e,r.timeToLoad*1e3)},t)},a}();function ei(a,n,i,e){a&&Object.keys(n).forEach(function(t){var r=a.filter(function(s){return s.groupId===t}).map(function(s){var o=xe({},s);return o.details=void 0,o.attrs=new ae(o.attrs),o.url=o.attrs.URI=ti(s.url,s.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",i),o.groupId=o.attrs["GROUP-ID"]=n[t],o.attrs["PATHWAY-ID"]=e,o});a.push.apply(a,r)})}function ti(a,n,i,e){var t=e.HOST,r=e.PARAMS,s=e[i],o;n&&(o=s?.[n],o&&(a=o));var l=new self.URL(a);return t&&!o&&(l.host=t),r&&Object.keys(r).sort().forEach(function(u){u&&l.searchParams.set(u,r[u])}),l.href}var _a=/^age:\s*[\d.]+\s*$/im,ri=function(){function a(i){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=null,this.loader=null,this.stats=void 0,this.xhrSetup=i&&i.xhrSetup||null,this.stats=new Je,this.retryDelay=0}var n=a.prototype;return n.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null},n.abortInternal=function(){var e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,e.readyState!==4&&(this.stats.aborted=!0,e.abort()))},n.abort=function(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},n.load=function(e,t,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=r,this.loadInternal()},n.loadInternal=function(){var e=this,t=this.config,r=this.context;if(!(!t||!r)){var s=this.loader=new self.XMLHttpRequest,o=this.stats;o.loading.first=0,o.loaded=0,o.aborted=!1;var l=this.xhrSetup;l?Promise.resolve().then(function(){if(!(e.loader!==s||e.stats.aborted))return l(s,r.url)}).catch(function(u){if(!(e.loader!==s||e.stats.aborted))return s.open("GET",r.url,!0),l(s,r.url)}).then(function(){e.loader!==s||e.stats.aborted||e.openAndSendXhr(s,r,t)}).catch(function(u){e.callbacks.onError({code:s.status,text:u.message},r,s,o)}):this.openAndSendXhr(s,r,t)}},n.openAndSendXhr=function(e,t,r){e.readyState||e.open("GET",t.url,!0);var s=t.headers,o=r.loadPolicy,l=o.maxTimeToFirstByteMs,u=o.maxLoadTimeMs;if(s)for(var d in s)e.setRequestHeader(d,s[d]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),r.timeout=l&&M(l)?l:u,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.timeout),e.send()},n.readystatechange=function(){var e=this.context,t=this.loader,r=this.stats;if(!(!e||!t)){var s=t.readyState,o=this.config;if(!r.aborted&&s>=2&&(r.loading.first===0&&(r.loading.first=Math.max(self.performance.now(),r.loading.start),o.timeout!==o.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),o.timeout=o.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),o.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start)))),s===4)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;var l=t.status,u=t.responseType!=="text";if(l>=200&&l<300&&(u&&t.response||t.responseText!==null)){r.loading.end=Math.max(self.performance.now(),r.loading.first);var d=u?t.response:t.responseText,f=t.responseType==="arraybuffer"?d.byteLength:d.length;if(r.loaded=r.total=f,r.bwEstimate=r.total*8e3/(r.loading.end-r.loading.first),!this.callbacks)return;var h=this.callbacks.onProgress;if(h&&h(r,e,d,t),!this.callbacks)return;var c={url:t.responseURL,data:d,code:l};this.callbacks.onSuccess(c,r,e,t)}else{var v=o.loadPolicy.errorRetry,g=r.retry,m={url:e.url,data:void 0,code:l};dt(v,g,!1,m)?this.retry(v):(R.error(l+" while loading "+e.url),this.callbacks.onError({code:l,text:t.statusText},e,t,r))}}}},n.loadtimeout=function(){if(this.config){var e=this.config.loadPolicy.timeoutRetry,t=this.stats.retry;if(dt(e,t,!0))this.retry(e);else{var r;R.warn("timeout while loading "+((r=this.context)==null?void 0:r.url));var s=this.callbacks;s&&(this.abortInternal(),s.onTimeout(this.stats,this.context,this.loader))}}},n.retry=function(e){var t=this.context,r=this.stats;this.retryDelay=Ut(e,r.retry),r.retry++,R.warn((status?"HTTP Status "+status:"Timeout")+" while loading "+t?.url+", retrying "+r.retry+"/"+e.maxNumRetry+" in "+this.retryDelay+"ms"),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)},n.loadprogress=function(e){var t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)},n.getCacheAge=function(){var e=null;if(this.loader&&_a.test(this.loader.getAllResponseHeaders())){var t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e},n.getResponseHeader=function(e){return this.loader&&new RegExp("^"+e+":\\s*[\\d.]+\\s*$","im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null},a}(),Da=function(){function a(){this.chunks=[],this.dataLength=0}var n=a.prototype;return n.push=function(e){this.chunks.push(e),this.dataLength+=e.length},n.flush=function(){var e=this.chunks,t=this.dataLength,r;if(e.length)e.length===1?r=e[0]:r=Ca(e,t);else return new Uint8Array(0);return this.reset(),r},n.reset=function(){this.chunks.length=0,this.dataLength=0},a}();function Ca(a,n){for(var i=new Uint8Array(n),e=0,t=0;t<a.length;t++){var r=a[t];i.set(r,e),e+=r.length}return i}function Pa(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var wa=/(\d+)-(\d+)\/(\d+)/,ii=function(){function a(i){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=null,this.response=null,this.controller=void 0,this.context=null,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=i.fetchSetup||Oa,this.controller=new self.AbortController,this.stats=new Je}var n=a.prototype;return n.destroy=function(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null},n.abortInternal=function(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())},n.abort=function(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},n.load=function(e,t,r){var s=this,o=this.stats;if(o.loading.start)throw new Error("Loader can only be used once.");o.loading.start=self.performance.now();var l=ka(e,this.controller.signal),u=r.onProgress,d=e.responseType==="arraybuffer",f=d?"byteLength":"length",h=t.loadPolicy,c=h.maxTimeToFirstByteMs,v=h.maxLoadTimeMs;this.context=e,this.config=t,this.callbacks=r,this.request=this.fetchSetup(e,l),self.clearTimeout(this.requestTimeout),t.timeout=c&&M(c)?c:v,this.requestTimeout=self.setTimeout(function(){s.abortInternal(),r.onTimeout(o,e,s.response)},t.timeout),self.fetch(this.request).then(function(g){s.response=s.loader=g;var m=Math.max(self.performance.now(),o.loading.start);if(self.clearTimeout(s.requestTimeout),t.timeout=v,s.requestTimeout=self.setTimeout(function(){s.abortInternal(),r.onTimeout(o,e,s.response)},v-(m-o.loading.start)),!g.ok){var p=g.status,y=g.statusText;throw new Na(y||"fetch, bad network response",p,g)}return o.loading.first=m,o.total=Ma(g.headers)||o.total,u&&M(t.highWaterMark)?s.loadProgressively(g,o,e,t.highWaterMark,u):d?g.arrayBuffer():e.responseType==="json"?g.json():g.text()}).then(function(g){var m=s.response;if(!m)throw new Error("loader destroyed");self.clearTimeout(s.requestTimeout),o.loading.end=Math.max(self.performance.now(),o.loading.first);var p=g[f];p&&(o.loaded=o.total=p);var y={url:m.url,data:g,code:m.status};u&&!M(t.highWaterMark)&&u(o,e,g,m),r.onSuccess(y,o,e,m)}).catch(function(g){if(self.clearTimeout(s.requestTimeout),!o.aborted){var m=g&&g.code||0,p=g?g.message:null;r.onError({code:m,text:p},e,g?g.details:null,o)}})},n.getCacheAge=function(){var e=null;if(this.response){var t=this.response.headers.get("age");e=t?parseFloat(t):null}return e},n.getResponseHeader=function(e){return this.response?this.response.headers.get(e):null},n.loadProgressively=function(e,t,r,s,o){s===void 0&&(s=0);var l=new Da,u=e.body.getReader(),d=function f(){return u.read().then(function(h){if(h.done)return l.dataLength&&o(t,r,l.flush(),e),Promise.resolve(new ArrayBuffer(0));var c=h.value,v=c.length;return t.loaded+=v,v<s||l.dataLength?(l.push(c),l.dataLength>=s&&o(t,r,l.flush(),e)):o(t,r,c,e),f()}).catch(function(){return Promise.reject()})};return d()},a}();function ka(a,n){var i={method:"GET",mode:"cors",credentials:"same-origin",signal:n,headers:new self.Headers(xe({},a.headers))};return a.rangeEnd&&i.headers.set("Range","bytes="+a.rangeStart+"-"+String(a.rangeEnd-1)),i}function Fa(a){var n=wa.exec(a);if(n)return parseInt(n[2])-parseInt(n[1])+1}function Ma(a){var n=a.get("Content-Range");if(n){var i=Fa(n);if(M(i))return i}var e=a.get("Content-Length");if(e)return parseInt(e)}function Oa(a,n){return new self.Request(a.url,n)}var Na=function(a){_e(n,a);function n(i,e,t){var r;return r=a.call(this,i)||this,r.code=void 0,r.details=void 0,r.code=e,r.details=t,r}return n}(Ze(Error)),Ba={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},ni=ne(ne({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,maxBufferSize:60*1e3*1e3,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:ri,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:Ea,bufferController:Sa,capLevelController:Aa,errorController:da,fpsController:Ra,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:null,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,useMediaCapabilities:!1,certLoadPolicy:{default:Ba},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},Ua()),{},{subtitleStreamController:void 0,subtitleTrackController:void 0,timelineController:void 0,audioStreamController:void 0,audioTrackController:void 0,emeController:void 0,cmcdController:void 0,contentSteeringController:Ia});function Ua(){return{cueHandler:on,enableWebVTT:!1,enableIMSC1:!1,enableCEA708Captions:!1,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function Ga(a,n){if((n.liveSyncDurationCount||n.liveMaxLatencyDurationCount)&&(n.liveSyncDuration||n.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(n.liveMaxLatencyDurationCount!==void 0&&(n.liveSyncDurationCount===void 0||n.liveMaxLatencyDurationCount<=n.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(n.liveMaxLatencyDuration!==void 0&&(n.liveSyncDuration===void 0||n.liveMaxLatencyDuration<=n.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');var i=Gt(a),e=["manifest","level","frag"],t=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return e.forEach(function(r){var s=(r==="level"?"playlist":r)+"LoadPolicy",o=n[s]===void 0,l=[];t.forEach(function(u){var d=r+"Loading"+u,f=n[d];if(f!==void 0&&o){l.push(d);var h=i[s].default;switch(n[s]={default:h},u){case"TimeOut":h.maxLoadTimeMs=f,h.maxTimeToFirstByteMs=f;break;case"MaxRetry":h.errorRetry.maxNumRetry=f,h.timeoutRetry.maxNumRetry=f;break;case"RetryDelay":h.errorRetry.retryDelayMs=f,h.timeoutRetry.retryDelayMs=f;break;case"MaxRetryTimeout":h.errorRetry.maxRetryDelayMs=f,h.timeoutRetry.maxRetryDelayMs=f;break}}}),l.length&&R.warn('hls.js config: "'+l.join('", "')+'" setting(s) are deprecated, use "'+s+'": '+JSON.stringify(n[s]))}),ne(ne({},i),n)}function Gt(a){return a&&typeof a=="object"?Array.isArray(a)?a.map(Gt):Object.keys(a).reduce(function(n,i){return n[i]=Gt(a[i]),n},{}):a}function Ha(a){var n=a.loader;if(n!==ii&&n!==ri)R.log("[config]: Custom loader detected, cannot enable progressive streaming"),a.progressive=!1;else{var i=Pa();i&&(a.loader=ii,a.progressive=!0,a.enableSoftwareAES=!0,R.log("[config]: Progressive streaming enabled, using FetchLoader"))}}var Ht,Va=function(a){_e(n,a);function n(e,t){var r;return r=a.call(this,e,"[level-controller]")||this,r._levels=[],r._firstLevel=-1,r._maxAutoLevel=-1,r._startLevel=void 0,r.currentLevel=null,r.currentLevelIndex=-1,r.manualLevelIndex=-1,r.steering=void 0,r.onParsedComplete=void 0,r.steering=t,r._registerListeners(),r}var i=n.prototype;return i._registerListeners=function(){var t=this.hls;t.on(x.MANIFEST_LOADING,this.onManifestLoading,this),t.on(x.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(x.LEVEL_LOADED,this.onLevelLoaded,this),t.on(x.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(x.FRAG_BUFFERED,this.onFragBuffered,this),t.on(x.ERROR,this.onError,this)},i._unregisterListeners=function(){var t=this.hls;t.off(x.MANIFEST_LOADING,this.onManifestLoading,this),t.off(x.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(x.LEVEL_LOADED,this.onLevelLoaded,this),t.off(x.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(x.FRAG_BUFFERED,this.onFragBuffered,this),t.off(x.ERROR,this.onError,this)},i.destroy=function(){this._unregisterListeners(),this.steering=null,this.resetLevels(),a.prototype.destroy.call(this)},i.stopLoad=function(){var t=this._levels;t.forEach(function(r){r.loadError=0,r.fragmentError=0}),a.prototype.stopLoad.call(this)},i.resetLevels=function(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1},i.onManifestLoading=function(t,r){this.resetLevels()},i.onManifestLoaded=function(t,r){var s=this.hls.config.preferManagedMediaSource,o=[],l={},u={},d=!1,f=!1,h=!1;r.levels.forEach(function(c){var v,g,m=c.attrs,p=c.audioCodec,y=c.videoCodec;((v=p)==null?void 0:v.indexOf("mp4a.40.34"))!==-1&&(Ht||(Ht=/chrome|firefox/i.test(navigator.userAgent)),Ht&&(c.audioCodec=p=void 0)),p&&(c.audioCodec=p=st(p,s)),((g=y)==null?void 0:g.indexOf("avc1"))===0&&(y=c.videoCodec=On(y));var E=c.width,S=c.height,L=c.unknownCodecs;if(d||(d=!!(E&&S)),f||(f=!!y),h||(h=!!p),!(L!=null&&L.length||p&&!Ct(p,"audio",s)||y&&!Ct(y,"video",s))){var _=m.CODECS,A=m["FRAME-RATE"],T=m["HDCP-LEVEL"],b=m["PATHWAY-ID"],I=m.RESOLUTION,P=m["VIDEO-RANGE"],C=(b||".")+"-",w=""+C+c.bitrate+"-"+I+"-"+A+"-"+_+"-"+P+"-"+T;if(l[w])if(l[w].uri!==c.url&&!c.attrs["PATHWAY-ID"]){var F=u[w]+=1;c.attrs["PATHWAY-ID"]=new Array(F+1).join(".");var H=new Nt(c);l[w]=H,o.push(H)}else l[w].addGroupId("audio",m.AUDIO),l[w].addGroupId("text",m.SUBTITLES);else{var O=new Nt(c);l[w]=O,u[w]=1,o.push(O)}}}),this.filterAndSortMediaOptions(o,r,d,f,h)},i.filterAndSortMediaOptions=function(t,r,s,o,l){var u=this,d=[],f=[],h=t;if((s||o)&&l&&(h=h.filter(function(T){var b=T.videoCodec,I=T.videoRange,P=T.width,C=T.height;return(!!b||!!(P&&C))&&Zn(I)})),h.length===0){Promise.resolve().then(function(){if(u.hls){r.levels.length&&u.warn("One or more CODECS in variant not supported: "+JSON.stringify(r.levels[0].attrs));var T=new Error("no level with compatible codecs found in manifest");u.hls.trigger(x.ERROR,{type:V.MEDIA_ERROR,details:D.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:r.url,error:T,reason:T.message})}});return}if(r.audioTracks){var c=this.hls.config.preferManagedMediaSource;d=r.audioTracks.filter(function(T){return!T.audioCodec||Ct(T.audioCodec,"audio",c)}),ai(d)}r.subtitles&&(f=r.subtitles,ai(f));var v=h.slice(0);h.sort(function(T,b){if(T.attrs["HDCP-LEVEL"]!==b.attrs["HDCP-LEVEL"])return(T.attrs["HDCP-LEVEL"]||"")>(b.attrs["HDCP-LEVEL"]||"")?1:-1;if(s&&T.height!==b.height)return T.height-b.height;if(T.frameRate!==b.frameRate)return T.frameRate-b.frameRate;if(T.videoRange!==b.videoRange)return lt.indexOf(T.videoRange)-lt.indexOf(b.videoRange);if(T.videoCodec!==b.videoCodec){var I=br(T.videoCodec),P=br(b.videoCodec);if(I!==P)return P-I}if(T.uri===b.uri&&T.codecSet!==b.codecSet){var C=at(T.codecSet),w=at(b.codecSet);if(C!==w)return w-C}return T.averageBitrate!==b.averageBitrate?T.averageBitrate-b.averageBitrate:0});var g=v[0];if(this.steering&&(h=this.steering.filterParsedLevels(h),h.length!==v.length)){for(var m=0;m<v.length;m++)if(v[m].pathwayId===h[0].pathwayId){g=v[m];break}}this._levels=h;for(var p=0;p<h.length;p++)if(h[p]===g){var y;this._firstLevel=p;var E=g.bitrate,S=this.hls.bandwidthEstimate;if(this.log("manifest loaded, "+h.length+" level(s) found, first bitrate: "+E),((y=this.hls.userConfig)==null?void 0:y.abrEwmaDefaultEstimate)===void 0){var L=Math.min(E,this.hls.config.abrEwmaDefaultEstimateMax);L>S&&S===ni.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=L)}break}var _=l&&!o,A={levels:h,audioTracks:d,subtitleTracks:f,sessionData:r.sessionData,sessionKeys:r.sessionKeys,firstLevel:this._firstLevel,stats:r.stats,audio:l,video:o,altAudio:!_&&d.some(function(T){return!!T.url})};this.hls.trigger(x.MANIFEST_PARSED,A),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)},i.onError=function(t,r){r.fatal||!r.context||r.context.type===Y.LEVEL&&r.context.level===this.level&&this.checkRetry(r)},i.onFragBuffered=function(t,r){var s=r.frag;if(s!==void 0&&s.type===q.MAIN){var o=s.elementaryStreams;if(!Object.keys(o).some(function(u){return!!o[u]}))return;var l=this._levels[s.level];l!=null&&l.loadError&&(this.log("Resetting level error count of "+l.loadError+" on frag buffered"),l.loadError=0)}},i.onLevelLoaded=function(t,r){var s,o=r.level,l=r.details,u=this._levels[o];if(!u){var d;this.warn("Invalid level index "+o),(d=r.deliveryDirectives)!=null&&d.skip&&(l.deltaUpdateFailed=!0);return}o===this.currentLevelIndex?(u.fragmentError===0&&(u.loadError=0),this.playlistLoaded(o,r,u.details)):(s=r.deliveryDirectives)!=null&&s.skip&&(l.deltaUpdateFailed=!0)},i.loadPlaylist=function(t){a.prototype.loadPlaylist.call(this);var r=this.currentLevelIndex,s=this.currentLevel;if(s&&this.shouldLoadPlaylist(s)){var o=s.uri;if(t)try{o=t.addDirectives(o)}catch(u){this.warn("Could not construct new URL with HLS Delivery Directives: "+u)}var l=s.attrs["PATHWAY-ID"];this.log("Loading level index "+r+(t?.msn!==void 0?" at sn "+t.msn+" part "+t.part:"")+" with"+(l?" Pathway "+l:"")+" "+o),this.clearTimer(),this.hls.trigger(x.LEVEL_LOADING,{url:o,level:r,pathwayId:s.attrs["PATHWAY-ID"],id:0,deliveryDirectives:t||null})}},i.removeLevel=function(t){var r=this,s,o=this._levels.filter(function(l,u){return u!==t?!0:(r.steering&&r.steering.removeLevel(l),l===r.currentLevel&&(r.currentLevel=null,r.currentLevelIndex=-1,l.details&&l.details.fragments.forEach(function(d){return d.level=-1})),!1)});qr(o),this._levels=o,this.currentLevelIndex>-1&&(s=this.currentLevel)!=null&&s.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.hls.trigger(x.LEVELS_UPDATED,{levels:o})},i.onLevelsUpdated=function(t,r){var s=r.levels;this._levels=s},i.checkMaxAutoUpdated=function(){var t=this.hls,r=t.autoLevelCapping,s=t.maxAutoLevel,o=t.maxHdcpLevel;this._maxAutoLevel!==s&&(this._maxAutoLevel=s,this.hls.trigger(x.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:r,levels:this.levels,maxAutoLevel:s,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:o}))},ge(n,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(t){var r=this._levels;if(r.length!==0){if(t<0||t>=r.length){var s=new Error("invalid level idx"),o=t<0;if(this.hls.trigger(x.ERROR,{type:V.OTHER_ERROR,details:D.LEVEL_SWITCH_ERROR,level:t,fatal:o,error:s,reason:s.message}),o)return;t=Math.min(t,r.length-1)}var l=this.currentLevelIndex,u=this.currentLevel,d=u?u.attrs["PATHWAY-ID"]:void 0,f=r[t],h=f.attrs["PATHWAY-ID"];if(this.currentLevelIndex=t,this.currentLevel=f,!(l===t&&f.details&&u&&d===h)){this.log("Switching to level "+t+" ("+(f.height?f.height+"p ":"")+(f.videoRange?f.videoRange+" ":"")+(f.codecSet?f.codecSet+" ":"")+"@"+f.bitrate+")"+(h?" with Pathway "+h:"")+" from level "+l+(d?" with Pathway "+d:""));var c={level:t,attrs:f.attrs,details:f.details,bitrate:f.bitrate,averageBitrate:f.averageBitrate,maxBitrate:f.maxBitrate,realBitrate:f.realBitrate,width:f.width,height:f.height,codecSet:f.codecSet,audioCodec:f.audioCodec,videoCodec:f.videoCodec,audioGroups:f.audioGroups,subtitleGroups:f.subtitleGroups,loaded:f.loaded,loadError:f.loadError,fragmentError:f.fragmentError,name:f.name,id:f.id,uri:f.uri,url:f.url,urlId:0,audioGroupIds:f.audioGroupIds,textGroupIds:f.textGroupIds};this.hls.trigger(x.LEVEL_SWITCHING,c);var v=f.details;if(!v||v.live){var g=this.switchParams(f.uri,u?.details,v);this.loadPlaylist(g)}}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(t){this.manualLevelIndex=t,this._startLevel===void 0&&(this._startLevel=t),t!==-1&&(this.level=t)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(t){this._firstLevel=t}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var t=this.hls.config.startLevel;return t!==void 0?t:this.hls.firstAutoLevel}return this._startLevel},set:function(t){this._startLevel=t}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(t){this.level=t,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=t)}}]),n}(ha);function ai(a){var n={};a.forEach(function(i){var e=i.groupId||"";i.id=n[e]=n[e]||0,n[e]++})}var ye={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"},Ka=function(){function a(i){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=i,this._registerListeners()}var n=a.prototype;return n._registerListeners=function(){var e=this.hls;e.on(x.BUFFER_APPENDED,this.onBufferAppended,this),e.on(x.FRAG_BUFFERED,this.onFragBuffered,this),e.on(x.FRAG_LOADED,this.onFragLoaded,this)},n._unregisterListeners=function(){var e=this.hls;e.off(x.BUFFER_APPENDED,this.onBufferAppended,this),e.off(x.FRAG_BUFFERED,this.onFragBuffered,this),e.off(x.FRAG_LOADED,this.onFragLoaded,this)},n.destroy=function(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null},n.getAppendedFrag=function(e,t){var r=this.activePartLists[t];if(r)for(var s=r.length;s--;){var o=r[s];if(!o)break;var l=o.end;if(o.start<=e&&l!==null&&e<=l)return o}return this.getBufferedFrag(e,t)},n.getBufferedFrag=function(e,t){for(var r=this.fragments,s=Object.keys(r),o=s.length;o--;){var l=r[s[o]];if(l?.body.type===t&&l.buffered){var u=l.body;if(u.start<=e&&e<=u.end)return u}}return null},n.detectEvictedFragments=function(e,t,r,s){var o=this;this.timeRanges&&(this.timeRanges[e]=t);var l=s?.fragment.sn||-1;Object.keys(this.fragments).forEach(function(u){var d=o.fragments[u];if(d&&!(l>=d.body.sn)){if(!d.buffered&&!d.loaded){d.body.type===r&&o.removeFragment(d.body);return}var f=d.range[e];f&&f.time.some(function(h){var c=!o.isTimeBuffered(h.startPTS,h.endPTS,t);return c&&o.removeFragment(d.body),c})}})},n.detectPartialFragments=function(e){var t=this,r=this.timeRanges,s=e.frag,o=e.part;if(!(!r||s.sn==="initSegment")){var l=We(s),u=this.fragments[l];if(!(!u||u.buffered&&s.gap)){var d=!s.relurl;if(Object.keys(r).forEach(function(h){var c=s.elementaryStreams[h];if(c){var v=r[h],g=d||c.partial===!0;u.range[h]=t.getBufferedTimes(s,o,g,v)}}),u.loaded=null,Object.keys(u.range).length){u.buffered=!0;var f=u.body.endList=s.endList||u.body.endList;f&&(this.endListFragments[u.body.type]=u),ht(u)||this.removeParts(s.sn-1,s.type)}else this.removeFragment(u.body)}}},n.removeParts=function(e,t){var r=this.activePartLists[t];r&&(this.activePartLists[t]=r.filter(function(s){return s.fragment.sn>=e}))},n.fragBuffered=function(e,t){var r=We(e),s=this.fragments[r];!s&&t&&(s=this.fragments[r]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),s&&(s.loaded=null,s.buffered=!0)},n.getBufferedTimes=function(e,t,r,s){for(var o={time:[],partial:r},l=e.start,u=e.end,d=e.minEndPTS||u,f=e.maxStartPTS||l,h=0;h<s.length;h++){var c=s.start(h)-this.bufferPadding,v=s.end(h)+this.bufferPadding;if(f>=c&&d<=v){o.time.push({startPTS:Math.max(l,s.start(h)),endPTS:Math.min(u,s.end(h))});break}else if(l<v&&u>c){var g=Math.max(l,s.start(h)),m=Math.min(u,s.end(h));m>g&&(o.partial=!0,o.time.push({startPTS:g,endPTS:m}))}else if(u<=c)break}return o},n.getPartialFragment=function(e){var t=null,r,s,o,l=0,u=this.bufferPadding,d=this.fragments;return Object.keys(d).forEach(function(f){var h=d[f];h&&ht(h)&&(s=h.body.start-u,o=h.body.end+u,e>=s&&e<=o&&(r=Math.min(e-s,o-e),l<=r&&(t=h.body,l=r)))}),t},n.isEndListAppended=function(e){var t=this.endListFragments[e];return t!==void 0&&(t.buffered||ht(t))},n.getState=function(e){var t=We(e),r=this.fragments[t];return r?r.buffered?ht(r)?ye.PARTIAL:ye.OK:ye.APPENDING:ye.NOT_LOADED},n.isTimeBuffered=function(e,t,r){for(var s,o,l=0;l<r.length;l++){if(s=r.start(l)-this.bufferPadding,o=r.end(l)+this.bufferPadding,e>=s&&t<=o)return!0;if(t<=s)return!1}return!1},n.onFragLoaded=function(e,t){var r=t.frag,s=t.part;if(!(r.sn==="initSegment"||r.bitrateTest)){var o=s?null:t,l=We(r);this.fragments[l]={body:r,appendedPTS:null,loaded:o,buffered:!1,range:Object.create(null)}}},n.onBufferAppended=function(e,t){var r=this,s=t.frag,o=t.part,l=t.timeRanges;if(s.sn!=="initSegment"){var u=s.type;if(o){var d=this.activePartLists[u];d||(this.activePartLists[u]=d=[]),d.push(o)}this.timeRanges=l,Object.keys(l).forEach(function(f){var h=l[f];r.detectEvictedFragments(f,h,u,o)})}},n.onFragBuffered=function(e,t){this.detectPartialFragments(t)},n.hasFragment=function(e){var t=We(e);return!!this.fragments[t]},n.hasParts=function(e){var t;return!!((t=this.activePartLists[e])!=null&&t.length)},n.removeFragmentsInRange=function(e,t,r,s,o){var l=this;s&&!this.hasGaps||Object.keys(this.fragments).forEach(function(u){var d=l.fragments[u];if(d){var f=d.body;f.type!==r||s&&!f.gap||f.start<t&&f.end>e&&(d.buffered||o)&&l.removeFragment(f)}})},n.removeFragment=function(e){var t=We(e);e.stats.loaded=0,e.clearElementaryStreamInfo();var r=this.activePartLists[e.type];if(r){var s=e.sn;this.activePartLists[e.type]=r.filter(function(o){return o.fragment.sn!==s})}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]},n.removeAllFragments=function(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1},a}();function ht(a){var n,i,e;return a.buffered&&(a.body.gap||((n=a.range.video)==null?void 0:n.partial)||((i=a.range.audio)==null?void 0:i.partial)||((e=a.range.audiovideo)==null?void 0:e.partial))}function We(a){return a.type+"_"+a.level+"_"+a.sn}var si=Math.pow(2,17),Wa=function(){function a(i){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=i}var n=a.prototype;return n.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},n.abort=function(){this.loader&&this.loader.abort()},n.load=function(e,t){var r=this,s=e.url;if(!s)return Promise.reject(new we({type:V.NETWORK_ERROR,details:D.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error("Fragment does not have a "+(s?"part list":"url")),networkDetails:null}));this.abort();var o=this.config,l=o.fLoader,u=o.loader;return new Promise(function(d,f){if(r.loader&&r.loader.destroy(),e.gap)if(e.tagList.some(function(m){return m[0]==="GAP"})){f(li(e));return}else e.gap=!1;var h=r.loader=e.loader=l?new l(o):new u(o),c=oi(e),v=Xr(o.fragLoadPolicy.default),g={loadPolicy:v,timeout:v.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:si};e.stats=h.stats,h.load(c,g,{onSuccess:function(p,y,E,S){r.resetLoader(e,h);var L=p.data;E.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(L.slice(0,16)),L=L.slice(16)),d({frag:e,part:null,payload:L,networkDetails:S})},onError:function(p,y,E,S){r.resetLoader(e,h),f(new we({type:V.NETWORK_ERROR,details:D.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:ne({url:s,data:void 0},p),error:new Error("HTTP Error "+p.code+" "+p.text),networkDetails:E,stats:S}))},onAbort:function(p,y,E){r.resetLoader(e,h),f(new we({type:V.NETWORK_ERROR,details:D.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:E,stats:p}))},onTimeout:function(p,y,E){r.resetLoader(e,h),f(new we({type:V.NETWORK_ERROR,details:D.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error("Timeout after "+g.timeout+"ms"),networkDetails:E,stats:p}))},onProgress:function(p,y,E,S){t&&t({frag:e,part:null,payload:E,networkDetails:S})}})})},n.loadPart=function(e,t,r){var s=this;this.abort();var o=this.config,l=o.fLoader,u=o.loader;return new Promise(function(d,f){if(s.loader&&s.loader.destroy(),e.gap||t.gap){f(li(e,t));return}var h=s.loader=e.loader=l?new l(o):new u(o),c=oi(e,t),v=Xr(o.fragLoadPolicy.default),g={loadPolicy:v,timeout:v.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:si};t.stats=h.stats,h.load(c,g,{onSuccess:function(p,y,E,S){s.resetLoader(e,h),s.updateStatsFromPart(e,t);var L={frag:e,part:t,payload:p.data,networkDetails:S};r(L),d(L)},onError:function(p,y,E,S){s.resetLoader(e,h),f(new we({type:V.NETWORK_ERROR,details:D.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:ne({url:c.url,data:void 0},p),error:new Error("HTTP Error "+p.code+" "+p.text),networkDetails:E,stats:S}))},onAbort:function(p,y,E){e.stats.aborted=t.stats.aborted,s.resetLoader(e,h),f(new we({type:V.NETWORK_ERROR,details:D.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:E,stats:p}))},onTimeout:function(p,y,E){s.resetLoader(e,h),f(new we({type:V.NETWORK_ERROR,details:D.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error("Timeout after "+g.timeout+"ms"),networkDetails:E,stats:p}))}})})},n.updateStatsFromPart=function(e,t){var r=e.stats,s=t.stats,o=s.total;if(r.loaded+=s.loaded,o){var l=Math.round(e.duration/t.duration),u=Math.min(Math.round(r.loaded/o),l),d=l-u,f=d*Math.round(r.loaded/u);r.total=r.loaded+f}else r.total=Math.max(r.loaded,r.total);var h=r.loading,c=s.loading;h.start?h.first+=c.first-c.start:(h.start=c.start,h.first=c.first),h.end=c.end},n.resetLoader=function(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()},a}();function oi(a,n){n===void 0&&(n=null);var i=n||a,e={frag:a,part:n,responseType:"arraybuffer",url:i.url,headers:{},rangeStart:0,rangeEnd:0},t=i.byteRangeStartOffset,r=i.byteRangeEndOffset;if(M(t)&&M(r)){var s,o=t,l=r;if(a.sn==="initSegment"&&((s=a.decryptdata)==null?void 0:s.method)==="AES-128"){var u=r-t;u%16&&(l=r+(16-u%16)),t!==0&&(e.resetIV=!0,o=t-16)}e.rangeStart=o,e.rangeEnd=l}return e}function li(a,n){var i=new Error("GAP "+(a.gap?"tag":"attribute")+" found"),e={type:V.MEDIA_ERROR,details:D.FRAG_GAP,fatal:!1,frag:a,error:i,networkDetails:null};return n&&(e.part=n),(n||a).stats.aborted=!0,new we(e)}var we=function(a){_e(n,a);function n(i){var e;return e=a.call(this,i.error.message)||this,e.data=void 0,e.data=i,e}return n}(Ze(Error)),Ya=function(){function a(i){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=i}var n=a.prototype;return n.abort=function(e){for(var t in this.keyUriToKeyInfo){var r=this.keyUriToKeyInfo[t].loader;if(r){var s;if(e&&e!==((s=r.context)==null?void 0:s.frag.type))return;r.abort()}}},n.detach=function(){for(var e in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}},n.destroy=function(){this.detach();for(var e in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}},n.createKeyLoadError=function(e,t,r,s,o){return t===void 0&&(t=D.KEY_LOAD_ERROR),new we({type:V.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:o,error:r,networkDetails:s})},n.loadClear=function(e,t){var r=this;if(this.emeController&&this.config.emeEnabled)for(var s=e.sn,o=e.cc,l=function(){var f=t[u];if(o<=f.cc&&(s==="initSegment"||f.sn==="initSegment"||s<f.sn))return r.emeController.selectKeySystemFormat(f).then(function(h){f.setKeyFormat(h)}),1},u=0;u<t.length&&!l();u++);},n.load=function(e){var t=this;return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then(function(r){return t.loadInternal(e,r)}):this.loadInternal(e)},n.loadInternal=function(e,t){var r,s;t&&e.setKeyFormat(t);var o=e.decryptdata;if(!o){var l=new Error(t?"Expected frag.decryptdata to be defined after setting format "+t:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(e,D.KEY_LOAD_ERROR,l))}var u=o.uri;if(!u)return Promise.reject(this.createKeyLoadError(e,D.KEY_LOAD_ERROR,new Error('Invalid key URI: "'+u+'"')));var d=this.keyUriToKeyInfo[u];if((r=d)!=null&&r.decryptdata.key)return o.key=d.decryptdata.key,Promise.resolve({frag:e,keyInfo:d});if((s=d)!=null&&s.keyLoadPromise){var f;switch((f=d.mediaKeySessionContext)==null?void 0:f.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return d.keyLoadPromise.then(function(h){return o.key=h.keyInfo.decryptdata.key,{frag:e,keyInfo:d}})}}switch(d=this.keyUriToKeyInfo[u]={decryptdata:o,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},o.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return o.keyFormat==="identity"?this.loadKeyHTTP(d,e):this.loadKeyEME(d,e);case"AES-128":return this.loadKeyHTTP(d,e);default:return Promise.reject(this.createKeyLoadError(e,D.KEY_LOAD_ERROR,new Error('Key supplied with unsupported METHOD: "'+o.method+'"')))}},n.loadKeyEME=function(e,t){var r={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){var s=this.emeController.loadKey(r);if(s)return(e.keyLoadPromise=s.then(function(o){return e.mediaKeySessionContext=o,r})).catch(function(o){throw e.keyLoadPromise=null,o})}return Promise.resolve(r)},n.loadKeyHTTP=function(e,t){var r=this,s=this.config,o=s.loader,l=new o(s);return t.keyLoader=e.loader=l,e.keyLoadPromise=new Promise(function(u,d){var f={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},h=s.keyLoadPolicy.default,c={loadPolicy:h,timeout:h.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},v={onSuccess:function(m,p,y,E){var S=y.frag,L=y.keyInfo,_=y.url;if(!S.decryptdata||L!==r.keyUriToKeyInfo[_])return d(r.createKeyLoadError(S,D.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),E));L.decryptdata.key=S.decryptdata.key=new Uint8Array(m.data),S.keyLoader=null,L.loader=null,u({frag:S,keyInfo:L})},onError:function(m,p,y,E){r.resetLoader(p),d(r.createKeyLoadError(t,D.KEY_LOAD_ERROR,new Error("HTTP Error "+m.code+" loading key "+m.text),y,ne({url:f.url,data:void 0},m)))},onTimeout:function(m,p,y){r.resetLoader(p),d(r.createKeyLoadError(t,D.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),y))},onAbort:function(m,p,y){r.resetLoader(p),d(r.createKeyLoadError(t,D.INTERNAL_ABORTED,new Error("key loading aborted"),y))}};l.load(f,c,v)})},n.resetLoader=function(e){var t=e.frag,r=e.keyInfo,s=e.url,o=r.loader;t.keyLoader===o&&(t.keyLoader=null,r.loader=null),delete this.keyUriToKeyInfo[s],o&&o.destroy()},a}(),qa=function(){function a(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var n=a.prototype;return n.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},n.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},n.onHandlerDestroyed=function(){},n.hasInterval=function(){return!!this._tickInterval},n.hasNextTick=function(){return!!this._tickTimer},n.setInterval=function(e){return this._tickInterval?!1:(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)},n.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},n.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},n.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},n.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},n.doTick=function(){},a}(),ui=function(n,i,e,t,r,s){t===void 0&&(t=0),r===void 0&&(r=-1),s===void 0&&(s=!1),this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing=ct(),this.buffering={audio:ct(),video:ct(),audiovideo:ct()},this.level=n,this.sn=i,this.id=e,this.size=t,this.part=r,this.partial=s};function ct(){return{start:0,executeStart:0,executeEnd:0,end:0}}function vt(a,n){for(var i=0,e=a.length;i<e;i++){var t;if(((t=a[i])==null?void 0:t.cc)===n)return a[i]}return null}function ja(a,n,i){return!!(n&&(i.endCC>i.startCC||a&&a.cc<i.startCC))}function Xa(a,n){var i=a.fragments,e=n.fragments;if(!e.length||!i.length){R.log("No fragments to align");return}var t=vt(i,e[0].cc);if(!t||t&&!t.startPTS){R.log("No frag in previous level to align on");return}return t}function fi(a,n){if(a){var i=a.start+n;a.start=a.startPTS=i,a.endPTS=i+a.duration}}function di(a,n){for(var i=n.fragments,e=0,t=i.length;e<t;e++)fi(i[e],a);n.fragmentHint&&fi(n.fragmentHint,a),n.alignedSliding=!0}function za(a,n,i){n&&($a(a,i,n),!i.alignedSliding&&n&&Qa(i,n),!i.alignedSliding&&n&&!i.skippedSegments&&Kr(n,i))}function $a(a,n,i){if(ja(a,i,n)){var e=Xa(i,n);e&&M(e.start)&&(R.log("Adjusting PTS using last level due to CC increase within current level "+n.url),di(e.start,n))}}function Qa(a,n){if(!(!a.hasProgramDateTime||!n.hasProgramDateTime)){var i=a.fragments,e=n.fragments;if(!(!i.length||!e.length)){var t,r,s=Math.min(n.endCC,a.endCC);n.startCC<s&&a.startCC<s&&(t=vt(e,s),r=vt(i,s)),(!t||!r)&&(t=e[Math.floor(e.length/2)],r=vt(i,t.cc)||i[Math.floor(i.length/2)]);var o=t.programDateTime,l=r.programDateTime;if(!(!o||!l)){var u=(l-o)/1e3-(r.start-t.start);di(u,a)}}}}var Za=function(){function a(i,e){this.subtle=void 0,this.aesIV=void 0,this.subtle=i,this.aesIV=e}var n=a.prototype;return n.decrypt=function(e,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e)},a}(),Ja=function(){function a(i,e){this.subtle=void 0,this.key=void 0,this.subtle=i,this.key=e}var n=a.prototype;return n.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},a}();function es(a){var n=a.byteLength,i=n&&new DataView(a.buffer).getUint8(n-1);return i?Ue(a,0,n-i):a}var ts=function(){function a(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}var n=a.prototype;return n.uint8ArrayToUint32Array_=function(e){for(var t=new DataView(e),r=new Uint32Array(4),s=0;s<4;s++)r[s]=t.getUint32(s*4);return r},n.initTable=function(){var e=this.sBox,t=this.invSBox,r=this.subMix,s=r[0],o=r[1],l=r[2],u=r[3],d=this.invSubMix,f=d[0],h=d[1],c=d[2],v=d[3],g=new Uint32Array(256),m=0,p=0,y=0;for(y=0;y<256;y++)y<128?g[y]=y<<1:g[y]=y<<1^283;for(y=0;y<256;y++){var E=p^p<<1^p<<2^p<<3^p<<4;E=E>>>8^E&255^99,e[m]=E,t[E]=m;var S=g[m],L=g[S],_=g[L],A=g[E]*257^E*16843008;s[m]=A<<24|A>>>8,o[m]=A<<16|A>>>16,l[m]=A<<8|A>>>24,u[m]=A,A=_*16843009^L*65537^S*257^m*16843008,f[E]=A<<24|A>>>8,h[E]=A<<16|A>>>16,c[E]=A<<8|A>>>24,v[E]=A,m?(m=S^g[g[g[_^S]]],p^=g[g[p]]):m=p=1}},n.expandKey=function(e){for(var t=this.uint8ArrayToUint32Array_(e),r=!0,s=0;s<t.length&&r;)r=t[s]===this.key[s],s++;if(!r){this.key=t;var o=this.keySize=t.length;if(o!==4&&o!==6&&o!==8)throw new Error("Invalid aes key size="+o);var l=this.ksRows=(o+6+1)*4,u,d,f=this.keySchedule=new Uint32Array(l),h=this.invKeySchedule=new Uint32Array(l),c=this.sBox,v=this.rcon,g=this.invSubMix,m=g[0],p=g[1],y=g[2],E=g[3],S,L;for(u=0;u<l;u++){if(u<o){S=f[u]=t[u];continue}L=S,u%o===0?(L=L<<8|L>>>24,L=c[L>>>24]<<24|c[L>>>16&255]<<16|c[L>>>8&255]<<8|c[L&255],L^=v[u/o|0]<<24):o>6&&u%o===4&&(L=c[L>>>24]<<24|c[L>>>16&255]<<16|c[L>>>8&255]<<8|c[L&255]),f[u]=S=(f[u-o]^L)>>>0}for(d=0;d<l;d++)u=l-d,d&3?L=f[u]:L=f[u-4],d<4||u<=4?h[d]=L:h[d]=m[c[L>>>24]]^p[c[L>>>16&255]]^y[c[L>>>8&255]]^E[c[L&255]],h[d]=h[d]>>>0}},n.networkToHostOrderSwap=function(e){return e<<24|(e&65280)<<8|(e&16711680)>>8|e>>>24},n.decrypt=function(e,t,r){for(var s=this.keySize+6,o=this.invKeySchedule,l=this.invSBox,u=this.invSubMix,d=u[0],f=u[1],h=u[2],c=u[3],v=this.uint8ArrayToUint32Array_(r),g=v[0],m=v[1],p=v[2],y=v[3],E=new Int32Array(e),S=new Int32Array(E.length),L,_,A,T,b,I,P,C,w,O,F,H,U,W,K=this.networkToHostOrderSwap;t<E.length;){for(w=K(E[t]),O=K(E[t+1]),F=K(E[t+2]),H=K(E[t+3]),b=w^o[0],I=H^o[1],P=F^o[2],C=O^o[3],U=4,W=1;W<s;W++)L=d[b>>>24]^f[I>>16&255]^h[P>>8&255]^c[C&255]^o[U],_=d[I>>>24]^f[P>>16&255]^h[C>>8&255]^c[b&255]^o[U+1],A=d[P>>>24]^f[C>>16&255]^h[b>>8&255]^c[I&255]^o[U+2],T=d[C>>>24]^f[b>>16&255]^h[I>>8&255]^c[P&255]^o[U+3],b=L,I=_,P=A,C=T,U=U+4;L=l[b>>>24]<<24^l[I>>16&255]<<16^l[P>>8&255]<<8^l[C&255]^o[U],_=l[I>>>24]<<24^l[P>>16&255]<<16^l[C>>8&255]<<8^l[b&255]^o[U+1],A=l[P>>>24]<<24^l[C>>16&255]<<16^l[b>>8&255]<<8^l[I&255]^o[U+2],T=l[C>>>24]<<24^l[b>>16&255]<<16^l[I>>8&255]<<8^l[P&255]^o[U+3],S[t]=K(L^g),S[t+1]=K(T^m),S[t+2]=K(A^p),S[t+3]=K(_^y),g=w,m=O,p=F,y=H,t=t+4}return S.buffer},a}(),rs=16,Vt=function(){function a(i,e){var t=e===void 0?{}:e,r=t.removePKCS7Padding,s=r===void 0?!0:r;if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.useSoftware=i.enableSoftwareAES,this.removePKCS7Padding=s,s)try{var o=self.crypto;o&&(this.subtle=o.subtle||o.webkitSubtle)}catch{}this.useSoftware=!this.subtle}var n=a.prototype;return n.destroy=function(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null},n.isSync=function(){return this.useSoftware},n.flush=function(){var e=this.currentResult,t=this.remainderData;if(!e||t)return this.reset(),null;var r=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?es(r):r},n.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},n.decrypt=function(e,t,r){var s=this;return this.useSoftware?new Promise(function(o,l){s.softwareDecrypt(new Uint8Array(e),t,r);var u=s.flush();u?o(u.buffer):l(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,r)},n.softwareDecrypt=function(e,t,r){var s=this.currentIV,o=this.currentResult,l=this.remainderData;this.logOnce("JS AES decrypt"),l&&(e=Le(l,e),this.remainderData=null);var u=this.getValidChunk(e);if(!u.length)return null;s&&(r=s);var d=this.softwareDecrypter;d||(d=this.softwareDecrypter=new ts),d.expandKey(t);var f=o;return this.currentResult=d.decrypt(u.buffer,0,r),this.currentIV=Ue(u,-16).buffer,f||null},n.webCryptoDecrypt=function(e,t,r){var s=this;if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,t,r));this.key=t,this.fastAesKey=new Ja(this.subtle,t)}return this.fastAesKey.expandKey().then(function(o){if(!s.subtle)return Promise.reject(new Error("web crypto not initialized"));s.logOnce("WebCrypto AES decrypt");var l=new Za(s.subtle,new Uint8Array(r));return l.decrypt(e.buffer,o)}).catch(function(o){return R.warn("[decrypter]: WebCrypto Error, disable WebCrypto API, "+o.name+": "+o.message),s.onWebCryptoError(e,t,r)})},n.onWebCryptoError=function(e,t,r){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,r);var s=this.flush();if(s)return s.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")},n.getValidChunk=function(e){var t=e,r=e.length-e.length%rs;return r!==e.length&&(t=Ue(e,0,r),this.remainderData=Ue(e,r)),t},n.logOnce=function(e){this.logEnabled&&(R.log("[decrypter]: "+e),this.logEnabled=!1)},a}(),is={toString:function(n){for(var i="",e=n.length,t=0;t<e;t++)i+="["+n.start(t).toFixed(3)+"-"+n.end(t).toFixed(3)+"]";return i}},k={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},ns=function(a){_e(n,a);function n(e,t,r,s,o){var l;return l=a.call(this)||this,l.hls=void 0,l.fragPrevious=null,l.fragCurrent=null,l.fragmentTracker=void 0,l.transmuxer=null,l._state=k.STOPPED,l.playlistType=void 0,l.media=null,l.mediaBuffer=null,l.config=void 0,l.bitrateTest=!1,l.lastCurrentTime=0,l.nextLoadPosition=0,l.startPosition=0,l.startTimeOffset=null,l.loadedmetadata=!1,l.retryDate=0,l.levels=null,l.fragmentLoader=void 0,l.keyLoader=void 0,l.levelLastLoaded=null,l.startFragRequested=!1,l.decrypter=void 0,l.initPTS=[],l.onvseeking=null,l.onvended=null,l.logPrefix="",l.log=void 0,l.warn=void 0,l.playlistType=o,l.logPrefix=s,l.log=R.log.bind(R,s+":"),l.warn=R.warn.bind(R,s+":"),l.hls=e,l.fragmentLoader=new Wa(e.config),l.keyLoader=r,l.fragmentTracker=t,l.config=e.config,l.decrypter=new Vt(e.config),e.on(x.MANIFEST_LOADED,l.onManifestLoaded,Xi(l)),l}var i=n.prototype;return i.doTick=function(){this.onTickEnd()},i.onTickEnd=function(){},i.startLoad=function(t){},i.stopLoad=function(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);var t=this.fragCurrent;t!=null&&t.loader&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=k.STOPPED},i._streamEnded=function(t,r){if(r.live||t.nextStart||!t.end||!this.media)return!1;var s=r.partList;if(s!=null&&s.length){var o=s[s.length-1],l=se.isBuffered(this.media,o.start+o.duration/2);return l}var u=r.fragments[r.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(u)},i.getLevelDetails=function(){if(this.levels&&this.levelLastLoaded!==null){var t;return(t=this.levelLastLoaded)==null?void 0:t.details}},i.onMediaAttached=function(t,r){var s=this.media=this.mediaBuffer=r.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),s.addEventListener("seeking",this.onvseeking),s.addEventListener("ended",this.onvended);var o=this.config;this.levels&&o.autoStartLoad&&this.state===k.STOPPED&&this.startLoad(o.startPosition)},i.onMediaDetaching=function(){var t=this.media;t!=null&&t.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),t&&this.onvseeking&&this.onvended&&(t.removeEventListener("seeking",this.onvseeking),t.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},i.onMediaSeeking=function(){var t=this.config,r=this.fragCurrent,s=this.media,o=this.mediaBuffer,l=this.state,u=s?s.currentTime:0,d=se.bufferInfo(o||s,u,t.maxBufferHole);if(this.log("media seeking to "+(M(u)?u.toFixed(3):u)+", state: "+l),this.state===k.ENDED)this.resetLoadingState();else if(r){var f=t.maxFragLookUpTolerance,h=r.start-f,c=r.start+r.duration+f;if(!d.len||c<d.start||h>d.end){var v=u>c;(u<h||v)&&(v&&r.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),r.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}s&&(this.fragmentTracker.removeFragmentsInRange(u,1/0,this.playlistType,!0),this.lastCurrentTime=u),!this.loadedmetadata&&!d.len&&(this.nextLoadPosition=this.startPosition=u),this.tickImmediate()},i.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},i.onManifestLoaded=function(t,r){this.startTimeOffset=r.startTimeOffset,this.initPTS=[]},i.onHandlerDestroying=function(){this.hls.off(x.MANIFEST_LOADED,this.onManifestLoaded,this),this.stopLoad(),a.prototype.onHandlerDestroying.call(this),this.hls=null},i.onHandlerDestroyed=function(){this.state=k.STOPPED,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,a.prototype.onHandlerDestroyed.call(this)},i.loadFragment=function(t,r,s){this._loadFragForPlayback(t,r,s)},i._loadFragForPlayback=function(t,r,s){var o=this,l=function(d){if(o.fragContextChanged(t)){o.warn("Fragment "+t.sn+(d.part?" p: "+d.part.index:"")+" of level "+t.level+" was dropped during download."),o.fragmentTracker.removeFragment(t);return}t.stats.chunkCount++,o._handleFragmentLoadProgress(d)};this._doFragLoad(t,r,s,l).then(function(u){if(u){var d=o.state;if(o.fragContextChanged(t)){(d===k.FRAG_LOADING||!o.fragCurrent&&d===k.PARSING)&&(o.fragmentTracker.removeFragment(t),o.state=k.IDLE);return}"payload"in u&&(o.log("Loaded fragment "+t.sn+" of level "+t.level),o.hls.trigger(x.FRAG_LOADED,u)),o._handleFragmentLoadComplete(u)}}).catch(function(u){o.state===k.STOPPED||o.state===k.ERROR||(o.warn("Frag error: "+(u?.message||u)),o.resetFragmentLoading(t))})},i.clearTrackerIfNeeded=function(t){var r,s=this.fragmentTracker,o=s.getState(t);if(o===ye.APPENDING){var l=t.type,u=this.getFwdBufferInfo(this.mediaBuffer,l),d=Math.max(t.duration,u?u.len:this.config.maxBufferLength),f=this.backtrackFragment,h=f?t.sn-f.sn:0;(h===1||this.reduceMaxBufferLength(d,t.duration))&&s.removeFragment(t)}else((r=this.mediaBuffer)==null?void 0:r.buffered.length)===0?s.removeAllFragments():s.hasParts(t.type)&&(s.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type}),s.getState(t)===ye.PARTIAL&&s.removeFragment(t))},i.checkLiveUpdate=function(t){if(t.updated&&!t.live){var r=t.fragments[t.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:r,part:null,stats:r.stats,id:r.type})}t.fragments[0]||(t.deltaUpdateFailed=!0)},i.flushMainBuffer=function(t,r,s){if(s===void 0&&(s=null),!!(t-r)){var o={startOffset:t,endOffset:r,type:s};this.hls.trigger(x.BUFFER_FLUSHING,o)}},i._loadInitSegment=function(t,r){var s=this;this._doFragLoad(t,r).then(function(o){if(!o||s.fragContextChanged(t)||!s.levels)throw new Error("init load aborted");return o}).then(function(o){var l=s.hls,u=o.payload,d=t.decryptdata;if(u&&u.byteLength>0&&d!=null&&d.key&&d.iv&&d.method==="AES-128"){var f=self.performance.now();return s.decrypter.decrypt(new Uint8Array(u),d.key.buffer,d.iv.buffer).catch(function(h){throw l.trigger(x.ERROR,{type:V.MEDIA_ERROR,details:D.FRAG_DECRYPT_ERROR,fatal:!1,error:h,reason:h.message,frag:t}),h}).then(function(h){var c=self.performance.now();return l.trigger(x.FRAG_DECRYPTED,{frag:t,payload:h,stats:{tstart:f,tdecrypt:c}}),o.payload=h,s.completeInitSegmentLoad(o)})}return s.completeInitSegmentLoad(o)}).catch(function(o){s.state===k.STOPPED||s.state===k.ERROR||(s.warn(o),s.resetFragmentLoading(t))})},i.completeInitSegmentLoad=function(t){var r=this.levels;if(!r)throw new Error("init load aborted, missing levels");var s=t.frag.stats;this.state=k.IDLE,t.frag.data=new Uint8Array(t.payload),s.parsing.start=s.buffering.start=self.performance.now(),s.parsing.end=s.buffering.end=self.performance.now(),this.tick()},i.fragContextChanged=function(t){var r=this.fragCurrent;return!t||!r||t.sn!==r.sn||t.level!==r.level},i.fragBufferedComplete=function(t,r){var s,o,l,u,d=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log("Buffered "+t.type+" sn: "+t.sn+(r?" part: "+r.index:"")+" of "+(this.playlistType===q.MAIN?"level":"track")+" "+t.level+" (frag:["+((s=t.startPTS)!=null?s:NaN).toFixed(3)+"-"+((o=t.endPTS)!=null?o:NaN).toFixed(3)+"] > buffer:"+(d?is.toString(se.getBuffered(d)):"(detached)")+")"),t.sn!=="initSegment"){var f;if(t.type!==q.SUBTITLE){var h=t.elementaryStreams;if(!Object.keys(h).some(function(v){return!!h[v]})){this.state=k.IDLE;return}}var c=(f=this.levels)==null?void 0:f[t.level];c!=null&&c.fragmentError&&(this.log("Resetting level fragment error count of "+c.fragmentError+" on frag buffered"),c.fragmentError=0)}this.state=k.IDLE,d&&(!this.loadedmetadata&&t.type==q.MAIN&&d.buffered.length&&((l=this.fragCurrent)==null?void 0:l.sn)===((u=this.fragPrevious)==null?void 0:u.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},i.seekToStartPos=function(){},i._handleFragmentLoadComplete=function(t){var r=this.transmuxer;if(r){var s=t.frag,o=t.part,l=t.partsLoaded,u=!l||l.length===0||l.some(function(f){return!f}),d=new ui(s.level,s.sn,s.stats.chunkCount+1,0,o?o.index:-1,!u);r.flush(d)}},i._handleFragmentLoadProgress=function(t){},i._doFragLoad=function(t,r,s,o){var l,u=this;s===void 0&&(s=null);var d=r?.details;if(!this.levels||!d)throw new Error("frag load aborted, missing level"+(d?"":" detail")+"s");var f=null;if(t.encrypted&&!((l=t.decryptdata)!=null&&l.key)?(this.log("Loading key for "+t.sn+" of ["+d.startSN+"-"+d.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+t.level),this.state=k.KEY_LOADING,this.fragCurrent=t,f=this.keyLoader.load(t).then(function(y){if(!u.fragContextChanged(y.frag))return u.hls.trigger(x.KEY_LOADED,y),u.state===k.KEY_LOADING&&(u.state=k.IDLE),y}),this.hls.trigger(x.KEY_LOADING,{frag:t}),this.fragCurrent===null&&(f=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))):!t.encrypted&&d.encryptedFragments.length&&this.keyLoader.loadClear(t,d.encryptedFragments),s=Math.max(t.start,s||0),this.config.lowLatencyMode&&t.sn!=="initSegment"){var h=d.partList;if(h&&o){s>t.end&&d.fragmentHint&&(t=d.fragmentHint);var c=this.getNextPart(h,t,s);if(c>-1){var v=h[c];this.log("Loading part sn: "+t.sn+" p: "+v.index+" cc: "+t.cc+" of playlist ["+d.startSN+"-"+d.endSN+"] parts [0-"+c+"-"+(h.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+t.level+", target: "+parseFloat(s.toFixed(3))),this.nextLoadPosition=v.start+v.duration,this.state=k.FRAG_LOADING;var g;return f?g=f.then(function(y){return!y||u.fragContextChanged(y.frag)?null:u.doFragPartsLoad(t,v,r,o)}).catch(function(y){return u.handleFragLoadError(y)}):g=this.doFragPartsLoad(t,v,r,o).catch(function(y){return u.handleFragLoadError(y)}),this.hls.trigger(x.FRAG_LOADING,{frag:t,part:v,targetBufferTime:s}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):g}else if(!t.url||this.loadedEndOfParts(h,s))return Promise.resolve(null)}}this.log("Loading fragment "+t.sn+" cc: "+t.cc+" "+(d?"of ["+d.startSN+"-"+d.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+t.level+", target: "+parseFloat(s.toFixed(3))),M(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=k.FRAG_LOADING;var m=this.config.progressive,p;return m&&f?p=f.then(function(y){return!y||u.fragContextChanged(y?.frag)?null:u.fragmentLoader.load(t,o)}).catch(function(y){return u.handleFragLoadError(y)}):p=Promise.all([this.fragmentLoader.load(t,m?o:void 0),f]).then(function(y){var E=y[0];return!m&&E&&o&&o(E),E}).catch(function(y){return u.handleFragLoadError(y)}),this.hls.trigger(x.FRAG_LOADING,{frag:t,targetBufferTime:s}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):p},i.doFragPartsLoad=function(t,r,s,o){var l=this;return new Promise(function(u,d){var f,h=[],c=(f=s.details)==null?void 0:f.partList,v=function g(m){l.fragmentLoader.loadPart(t,m,o).then(function(p){h[m.index]=p;var y=p.part;l.hls.trigger(x.FRAG_LOADED,p);var E=Wr(s,t.sn,m.index+1)||Yr(c,t.sn,m.index+1);if(E)g(E);else return u({frag:t,part:y,partsLoaded:h})}).catch(d)};v(r)})},i.handleFragLoadError=function(t){if("data"in t){var r=t.data;t.data&&r.details===D.INTERNAL_ABORTED?this.handleFragLoadAborted(r.frag,r.part):this.hls.trigger(x.ERROR,r)}else this.hls.trigger(x.ERROR,{type:V.OTHER_ERROR,details:D.INTERNAL_EXCEPTION,err:t,error:t,fatal:!0});return null},i._handleTransmuxerFlush=function(t){var r=this.getCurrentContext(t);if(!r||this.state!==k.PARSING){!this.fragCurrent&&this.state!==k.STOPPED&&this.state!==k.ERROR&&(this.state=k.IDLE);return}var s=r.frag,o=r.part,l=r.level,u=self.performance.now();s.stats.parsing.end=u,o&&(o.stats.parsing.end=u),this.updateLevelTiming(s,o,l,t.partial)},i.getCurrentContext=function(t){var r=this.levels,s=this.fragCurrent,o=t.level,l=t.sn,u=t.part;if(!(r!=null&&r[o]))return this.warn("Levels object was unset while buffering fragment "+l+" of level "+o+". The current chunk will not be buffered."),null;var d=r[o],f=u>-1?Wr(d,l,u):null,h=f?f.fragment:aa(d,l,s);return h?(s&&s!==h&&(h.stats=s.stats),{frag:h,part:f,level:d}):null},i.bufferFragmentData=function(t,r,s,o,l){var u;if(!(!t||this.state!==k.PARSING)){var d=t.data1,f=t.data2,h=d;if(d&&f&&(h=Le(d,f)),!!((u=h)!=null&&u.length)){var c={type:t.type,frag:r,part:s,chunkMeta:o,parent:r.type,data:h};if(this.hls.trigger(x.BUFFER_APPENDING,c),t.dropped&&t.independent&&!s){if(l)return;this.flushBufferGap(r)}}}},i.flushBufferGap=function(t){var r=this.media;if(r){if(!se.isBuffered(r,r.currentTime)){this.flushMainBuffer(0,t.start);return}var s=r.currentTime,o=se.bufferInfo(r,s,0),l=t.duration,u=Math.min(this.config.maxFragLookUpTolerance*2,l*.25),d=Math.max(Math.min(t.start-u,o.end-u),s+u);t.start-d>u&&this.flushMainBuffer(d,t.start)}},i.getFwdBufferInfo=function(t,r){var s=this.getLoadPosition();return M(s)?this.getFwdBufferInfoAtPos(t,s,r):null},i.getFwdBufferInfoAtPos=function(t,r,s){var o=this.config.maxBufferHole,l=se.bufferInfo(t,r,o);if(l.len===0&&l.nextStart!==void 0){var u=this.fragmentTracker.getBufferedFrag(r,s);if(u&&l.nextStart<u.end)return se.bufferInfo(t,r,Math.max(l.nextStart,o))}return l},i.getMaxBufferLength=function(t){var r=this.config,s;return t?s=Math.max(8*r.maxBufferSize/t,r.maxBufferLength):s=r.maxBufferLength,Math.min(s,r.maxMaxBufferLength)},i.reduceMaxBufferLength=function(t,r){var s=this.config,o=Math.max(Math.min(t-r,s.maxBufferLength),r),l=Math.max(t-r*3,s.maxMaxBufferLength/2,o);return l>=o?(s.maxMaxBufferLength=l,this.warn("Reduce max buffer length to "+l+"s"),!0):!1},i.getAppendedFrag=function(t,r){var s=this.fragmentTracker.getAppendedFrag(t,q.MAIN);return s&&"fragment"in s?s.fragment:s},i.getNextFragment=function(t,r){var s=r.fragments,o=s.length;if(!o)return null;var l=this.config,u=s[0].start,d;if(r.live){var f=l.initialLiveManifestSize;if(o<f)return this.warn("Not enough fragments to start playback (have: "+o+", need: "+f+")"),null;(!r.PTSKnown&&!this.startFragRequested&&this.startPosition===-1||t<u)&&(d=this.getInitialLiveFragment(r,s),this.startPosition=this.nextLoadPosition=d?this.hls.liveSyncPosition||d.start:t)}else t<=u&&(d=s[0]);if(!d){var h=l.lowLatencyMode?r.partEnd:r.fragmentEnd;d=this.getFragmentAtPosition(t,h,r)}return this.mapToInitFragWhenRequired(d)},i.isLoopLoading=function(t,r){var s=this.fragmentTracker.getState(t);return(s===ye.OK||s===ye.PARTIAL&&!!t.gap)&&this.nextLoadPosition>r},i.getNextFragmentLoopLoading=function(t,r,s,o,l){var u=t.gap,d=this.getNextFragment(this.nextLoadPosition,r);if(d===null)return d;if(t=d,u&&t&&!t.gap&&s.nextStart){var f=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,s.nextStart,o);if(f!==null&&s.len+f.len>=l)return this.log('buffer full after gaps in "'+o+'" playlist starting at sn: '+t.sn),null}return t},i.mapToInitFragWhenRequired=function(t){return t!=null&&t.initSegment&&!(t!=null&&t.initSegment.data)&&!this.bitrateTest?t.initSegment:t},i.getNextPart=function(t,r,s){for(var o=-1,l=!1,u=!0,d=0,f=t.length;d<f;d++){var h=t[d];if(u=u&&!h.independent,o>-1&&s<h.start)break;var c=h.loaded;c?o=-1:(l||h.independent||u)&&h.fragment===r&&(o=d),l=c}return o},i.loadedEndOfParts=function(t,r){var s=t[t.length-1];return s&&r>s.start&&s.loaded},i.getInitialLiveFragment=function(t,r){var s=this.fragPrevious,o=null;if(s){if(t.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+s.programDateTime),o=oa(r,s.endProgramDateTime,this.config.maxFragLookUpTolerance)),!o){var l=s.sn+1;if(l>=t.startSN&&l<=t.endSN){var u=r[l-t.startSN];s.cc===u.cc&&(o=u,this.log("Live playlist, switching playlist, load frag with next SN: "+o.sn))}o||(o=fa(r,s.cc),o&&this.log("Live playlist, switching playlist, load frag with same CC: "+o.sn))}}else{var d=this.hls.liveSyncPosition;d!==null&&(o=this.getFragmentAtPosition(d,this.bitrateTest?t.fragmentEnd:t.edge,t))}return o},i.getFragmentAtPosition=function(t,r,s){var o=this.config,l=this.fragPrevious,u=s.fragments,d=s.endSN,f=s.fragmentHint,h=o.maxFragLookUpTolerance,c=s.partList,v=!!(o.lowLatencyMode&&c!=null&&c.length&&f);v&&f&&!this.bitrateTest&&(u=u.concat(f),d=f.sn);var g;if(t<r){var m=t>r-h?0:h;g=$r(l,u,t,m)}else g=u[u.length-1];if(g){var p=g.sn-s.startSN,y=this.fragmentTracker.getState(g);if((y===ye.OK||y===ye.PARTIAL&&g.gap)&&(l=g),l&&g.sn===l.sn&&(!v||c[0].fragment.sn>g.sn)){var E=l&&g.level===l.level;if(E){var S=u[p+1];g.sn<d&&this.fragmentTracker.getState(S)!==ye.OK?g=S:g=null}}}return g},i.synchronizeToLiveEdge=function(t){var r=this.config,s=this.media;if(s){var o=this.hls.liveSyncPosition,l=s.currentTime,u=t.fragments[0].start,d=t.edge,f=l>=u-r.maxFragLookUpTolerance&&l<=d;if(o!==null&&s.duration>o&&(l<o||!f)){var h=r.liveMaxLatencyDuration!==void 0?r.liveMaxLatencyDuration:r.liveMaxLatencyDurationCount*t.targetduration;(!f&&s.readyState<4||l<d-h)&&(this.loadedmetadata||(this.nextLoadPosition=o),s.readyState&&(this.warn("Playback: "+l.toFixed(3)+" is located too far from the end of live sliding playlist: "+d+", reset currentTime to : "+o.toFixed(3)),s.currentTime=o))}}},i.alignPlaylists=function(t,r,s){var o=t.fragments.length;if(!o)return this.warn("No fragments in live playlist"),0;var l=t.fragments[0].start,u=!r,d=t.alignedSliding&&M(l);if(u||!d&&!l){var f=this.fragPrevious;za(f,s,t);var h=t.fragments[0].start;return this.log("Live playlist sliding: "+h.toFixed(2)+" start-sn: "+(r?r.startSN:"na")+"->"+t.startSN+" prev-sn: "+(f?f.sn:"na")+" fragments: "+o),h}return l},i.waitForCdnTuneIn=function(t){var r=3;return t.live&&t.canBlockReload&&t.partTarget&&t.tuneInGoal>Math.max(t.partHoldBack,t.partTarget*r)},i.setStartPosition=function(t,r){var s=this.startPosition;if(s<r&&(s=-1),s===-1||this.lastCurrentTime===-1){var o=this.startTimeOffset!==null,l=o?this.startTimeOffset:t.startTimeOffset;l!==null&&M(l)?(s=r+l,l<0&&(s+=t.totalduration),s=Math.min(Math.max(r,s),r+t.totalduration),this.log("Start time offset "+l+" found in "+(o?"multivariant":"media")+" playlist, adjust startPosition to "+s),this.startPosition=s):t.live?s=this.hls.liveSyncPosition||r:this.startPosition=s=0,this.lastCurrentTime=s}this.nextLoadPosition=s},i.getLoadPosition=function(){var t=this.media,r=0;return this.loadedmetadata&&t?r=t.currentTime:this.nextLoadPosition&&(r=this.nextLoadPosition),r},i.handleFragLoadAborted=function(t,r){this.transmuxer&&t.sn!=="initSegment"&&t.stats.aborted&&(this.warn("Fragment "+t.sn+(r?" part "+r.index:"")+" of level "+t.level+" was aborted"),this.resetFragmentLoading(t))},i.resetFragmentLoading=function(t){(!this.fragCurrent||!this.fragContextChanged(t)&&this.state!==k.FRAG_LOADING_WAITING_RETRY)&&(this.state=k.IDLE)},i.onFragmentOrKeyLoadError=function(t,r){if(r.chunkMeta&&!r.frag){var s=this.getCurrentContext(r.chunkMeta);s&&(r.frag=s.frag)}var o=r.frag;if(!(!o||o.type!==t||!this.levels)){if(this.fragContextChanged(o)){var l;this.warn("Frag load error must match current frag to retry "+o.url+" > "+((l=this.fragCurrent)==null?void 0:l.url));return}var u=r.details===D.FRAG_GAP;u&&this.fragmentTracker.fragBuffered(o,!0);var d=r.errorAction,f=d||{},h=f.action,c=f.retryCount,v=c===void 0?0:c,g=f.retryConfig;if(d&&h===fe.RetryRequest&&g){this.resetStartWhenNotLoaded(this.levelLastLoaded);var m=Ut(g,v);this.warn("Fragment "+o.sn+" of "+t+" "+o.level+" errored with "+r.details+", retrying loading "+(v+1)+"/"+g.maxNumRetry+" in "+m+"ms"),d.resolved=!0,this.retryDate=self.performance.now()+m,this.state=k.FRAG_LOADING_WAITING_RETRY}else if(g&&d)if(this.resetFragmentErrors(t),v<g.maxNumRetry)!u&&h!==fe.RemoveAlternatePermanently&&(d.resolved=!0);else{R.warn(r.details+" reached or exceeded max retry ("+v+")");return}else d?.action===fe.SendAlternateToPenaltyBox?this.state=k.WAITING_LEVEL:this.state=k.ERROR;this.tickImmediate()}},i.reduceLengthAndFlushBuffer=function(t){if(this.state===k.PARSING||this.state===k.PARSED){var r=t.frag,s=t.parent,o=this.getFwdBufferInfo(this.mediaBuffer,s),l=o&&o.len>.5;l&&this.reduceMaxBufferLength(o.len,r?.duration||10);var u=!l;return u&&this.warn("Buffer full error while media.currentTime is not buffered, flush "+s+" buffer"),r&&(this.fragmentTracker.removeFragment(r),this.nextLoadPosition=r.start),this.resetLoadingState(),u}return!1},i.resetFragmentErrors=function(t){t===q.AUDIO&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==k.STOPPED&&(this.state=k.IDLE)},i.afterBufferFlushed=function(t,r,s){if(t){var o=se.getBuffered(t);this.fragmentTracker.detectEvictedFragments(r,o,s),this.state===k.ENDED&&this.resetLoadingState()}},i.resetLoadingState=function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=k.IDLE},i.resetStartWhenNotLoaded=function(t){if(!this.loadedmetadata){this.startFragRequested=!1;var r=t?t.details:null;r!=null&&r.live?(this.startPosition=-1,this.setStartPosition(r,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},i.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(this.levelLastLoaded),this.resetLoadingState()},i.removeUnbufferedFrags=function(t){t===void 0&&(t=0),this.fragmentTracker.removeFragmentsInRange(t,1/0,this.playlistType,!1,!0)},i.updateLevelTiming=function(t,r,s,o){var l=this,u,d=s.details;if(!d){this.warn("level.details undefined");return}var f=Object.keys(t.elementaryStreams).reduce(function(c,v){var g=t.elementaryStreams[v];if(g){var m=g.endPTS-g.startPTS;if(m<=0)return l.warn("Could not parse fragment "+t.sn+" "+v+" duration reliably ("+m+")"),c||!1;var p=o?0:Vr(d,t,g.startPTS,g.endPTS,g.startDTS,g.endDTS);return l.hls.trigger(x.LEVEL_PTS_UPDATED,{details:d,level:s,drift:p,type:v,frag:t,start:g.startPTS,end:g.endPTS}),!0}return c},!1);if(!f&&((u=this.transmuxer)==null?void 0:u.error)===null){var h=new Error("Found no media in fragment "+t.sn+" of level "+t.level+" resetting transmuxer to fallback to playlist timing");if(s.fragmentError===0&&(s.fragmentError++,t.gap=!0,this.fragmentTracker.removeFragment(t),this.fragmentTracker.fragBuffered(t,!0)),this.warn(h.message),this.hls.trigger(x.ERROR,{type:V.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!1,error:h,frag:t,reason:"Found no media in msn "+t.sn+' of level "'+s.url+'"'}),!this.hls)return;this.resetTransmuxer()}this.state=k.PARSED,this.hls.trigger(x.FRAG_PARSED,{frag:t,part:r})},i.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},i.recoverWorkerError=function(t){t.event==="demuxerWorker"&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState())},ge(n,[{key:"state",get:function(){return this._state},set:function(t){var r=this._state;r!==t&&(this._state=t,this.log(r+"->"+t))}}]),n}(qa);function hi(){return self.SourceBuffer||self.WebKitSourceBuffer}function ci(){var a=Ge();if(!a)return!1;var n=hi();return!n||n.prototype&&typeof n.prototype.appendBuffer=="function"&&typeof n.prototype.remove=="function"}function as(){if(!ci())return!1;var a=Ge();return typeof a?.isTypeSupported=="function"&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(function(n){return a.isTypeSupported(Pt(n,"video"))})||["mp4a.40.2","fLaC"].some(function(n){return a.isTypeSupported(Pt(n,"audio"))}))}function ss(){var a,n=hi();return typeof(n==null||(a=n.prototype)==null?void 0:a.changeType)=="function"}function Ce(a,n){return a===void 0&&(a=""),n===void 0&&(n=9e4),{type:a,id:-1,pid:-1,inputTimeScale:n,sequenceNumber:-1,samples:[],dropped:0}}var vi=function(){function a(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}var n=a.prototype;return n.resetInitSegment=function(e,t,r,s){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},n.resetTimeStamp=function(e){this.initPTS=e,this.resetContiguity()},n.resetContiguity=function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},n.canParse=function(e,t){return!1},n.appendFrame=function(e,t,r){},n.demux=function(e,t){this.cachedData&&(e=Le(this.cachedData,e),this.cachedData=null);var r=et(e,0),s=r?r.length:0,o,l=this._audioTrack,u=this._id3Track,d=r?cr(r):void 0,f=e.length;for((this.basePTS===null||this.frameIndex===0&&M(d))&&(this.basePTS=os(d,t,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),r&&r.length>0&&u.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:Ae.audioId3,duration:Number.POSITIVE_INFINITY});s<f;){if(this.canParse(e,s)){var h=this.appendFrame(l,e,s);h?(this.frameIndex++,this.lastPTS=h.sample.pts,s+=h.length,o=s):s=f}else ln(e,s)?(r=et(e,s),u.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:Ae.audioId3,duration:Number.POSITIVE_INFINITY}),s+=r.length,o=s):s++;if(s===f&&o!==f){var c=Ue(e,o);this.cachedData?this.cachedData=Le(this.cachedData,c):this.cachedData=c}}return{audioTrack:l,videoTrack:Ce(),id3Track:u,textTrack:Ce()}},n.demuxSampleAes=function(e,t,r){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},n.flush=function(e){var t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:Ce(),id3Track:this._id3Track,textTrack:Ce()}},n.destroy=function(){},a}(),os=function(n,i,e){if(M(n))return n*90;var t=e?e.baseTime*9e4/e.timescale:0;return i*9e4+t};function ls(a,n,i,e){var t,r,s,o,l=navigator.userAgent.toLowerCase(),u=e,d=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];t=((n[i+2]&192)>>>6)+1;var f=(n[i+2]&60)>>>2;if(f>d.length-1){var h=new Error("invalid ADTS sampling index:"+f);a.emit(x.ERROR,x.ERROR,{type:V.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!0,error:h,reason:h.message});return}return s=(n[i+2]&1)<<2,s|=(n[i+3]&192)>>>6,R.log("manifest codec:"+e+", ADTS type:"+t+", samplingIndex:"+f),/firefox/i.test(l)?f>=6?(t=5,o=new Array(4),r=f-3):(t=2,o=new Array(2),r=f):l.indexOf("android")!==-1?(t=2,o=new Array(2),r=f):(t=5,o=new Array(4),e&&(e.indexOf("mp4a.40.29")!==-1||e.indexOf("mp4a.40.5")!==-1)||!e&&f>=6?r=f-3:((e&&e.indexOf("mp4a.40.2")!==-1&&(f>=6&&s===1||/vivaldi/i.test(l))||!e&&s===1)&&(t=2,o=new Array(2)),r=f)),o[0]=t<<3,o[0]|=(f&14)>>1,o[1]|=(f&1)<<7,o[1]|=s<<3,t===5&&(o[1]|=(r&14)>>1,o[2]=(r&1)<<7,o[2]|=8,o[3]=0),{config:o,samplerate:d[f],channelCount:s,codec:"mp4a.40."+t,manifestCodec:u}}function gi(a,n){return a[n]===255&&(a[n+1]&246)===240}function mi(a,n){return a[n+1]&1?7:9}function Kt(a,n){return(a[n+3]&3)<<11|a[n+4]<<3|(a[n+5]&224)>>>5}function us(a,n){return n+5<a.length}function gt(a,n){return n+1<a.length&&gi(a,n)}function fs(a,n){return us(a,n)&&gi(a,n)&&Kt(a,n)<=a.length-n}function ds(a,n){if(gt(a,n)){var i=mi(a,n);if(n+i>=a.length)return!1;var e=Kt(a,n);if(e<=i)return!1;var t=n+e;return t===a.length||gt(a,t)}return!1}function pi(a,n,i,e,t){if(!a.samplerate){var r=ls(n,i,e,t);if(!r)return;a.config=r.config,a.samplerate=r.samplerate,a.channelCount=r.channelCount,a.codec=r.codec,a.manifestCodec=r.manifestCodec,R.log("parsed codec:"+a.codec+", rate:"+r.samplerate+", channels:"+r.channelCount)}}function yi(a){return 1024*9e4/a}function hs(a,n){var i=mi(a,n);if(n+i<=a.length){var e=Kt(a,n)-i;if(e>0)return{headerLength:i,frameLength:e}}}function Ei(a,n,i,e,t){var r=yi(a.samplerate),s=e+t*r,o=hs(n,i),l;if(o){var u=o.frameLength,d=o.headerLength,f=d+u,h=Math.max(0,i+f-n.length);h?(l=new Uint8Array(f-d),l.set(n.subarray(i+d,n.length),0)):l=n.subarray(i+d,i+f);var c={unit:l,pts:s};return h||a.samples.push(c),{sample:c,length:f,missing:h}}var v=n.length-i;l=new Uint8Array(v),l.set(n.subarray(i,n.length),0);var g={unit:l,pts:s};return{sample:g,length:v,missing:-1}}var mt=null,cs=[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],vs=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],gs=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],ms=[0,1,1,4];function xi(a,n,i,e,t){if(!(i+24>n.length)){var r=Ti(n,i);if(r&&i+r.frameLength<=n.length){var s=r.samplesPerFrame*9e4/r.sampleRate,o=e+t*s,l={unit:n.subarray(i,i+r.frameLength),pts:o,dts:o};return a.config=[],a.channelCount=r.channelCount,a.samplerate=r.sampleRate,a.samples.push(l),{sample:l,length:r.frameLength,missing:0}}}}function Ti(a,n){var i=a[n+1]>>3&3,e=a[n+1]>>1&3,t=a[n+2]>>4&15,r=a[n+2]>>2&3;if(i!==1&&t!==0&&t!==15&&r!==3){var s=a[n+2]>>1&1,o=a[n+3]>>6,l=i===3?3-e:e===3?3:4,u=cs[l*14+t-1]*1e3,d=i===3?0:i===2?1:2,f=vs[d*3+r],h=o===3?1:2,c=gs[i][e],v=ms[e],g=c*8*v,m=Math.floor(c*u/f+s)*v;if(mt===null){var p=navigator.userAgent||"",y=p.match(/Chrome\/(\d+)/i);mt=y?parseInt(y[1]):0}var E=!!mt&&mt<=87;return E&&e===2&&u>=224e3&&o===0&&(a[n+3]=a[n+3]|128),{sampleRate:f,channelCount:h,frameLength:m,samplesPerFrame:g}}}function Wt(a,n){return a[n]===255&&(a[n+1]&224)===224&&(a[n+1]&6)!==0}function Si(a,n){return n+1<a.length&&Wt(a,n)}function ps(a,n){var i=4;return Wt(a,n)&&i<=a.length-n}function Li(a,n){if(n+1<a.length&&Wt(a,n)){var i=4,e=Ti(a,n),t=i;e!=null&&e.frameLength&&(t=e.frameLength);var r=n+t;return r===a.length||Si(a,r)}return!1}var ys=function(a){_e(n,a);function n(e,t){var r;return r=a.call(this)||this,r.observer=void 0,r.config=void 0,r.observer=e,r.config=t,r}var i=n.prototype;return i.resetInitSegment=function(t,r,s,o){a.prototype.resetInitSegment.call(this,t,r,s,o),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:r,duration:o,inputTimeScale:9e4,dropped:0}},n.probe=function(t){if(!t)return!1;var r=et(t,0),s=r?.length||0;if(Li(t,s))return!1;for(var o=t.length;s<o;s++)if(ds(t,s))return R.log("ADTS sync word found !"),!0;return!1},i.canParse=function(t,r){return fs(t,r)},i.appendFrame=function(t,r,s){pi(t,this.observer,r,s,t.manifestCodec);var o=Ei(t,r,s,this.basePTS,this.frameIndex);if(o&&o.missing===0)return o},n}(vi),Es=/\/emsg[-/]ID3/i,xs=function(){function a(i,e){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=e}var n=a.prototype;return n.resetTimeStamp=function(){},n.resetInitSegment=function(e,t,r,s){var o=this.videoTrack=Ce("video",1),l=this.audioTrack=Ce("audio",1),u=this.txtTrack=Ce("text",1);if(this.id3Track=Ce("id3",1),this.timeOffset=0,!!(e!=null&&e.byteLength)){var d=Tr(e);if(d.video){var f=d.video,h=f.id,c=f.timescale,v=f.codec;o.id=h,o.timescale=u.timescale=c,o.codec=v}if(d.audio){var g=d.audio,m=g.id,p=g.timescale,y=g.codec;l.id=m,l.timescale=p,l.codec=y}u.id=pr.text,o.sampleDuration=0,o.duration=l.duration=s}},n.resetContiguity=function(){this.remainderData=null},a.probe=function(e){return pn(e)},n.demux=function(e,t){this.timeOffset=t;var r=e,s=this.videoTrack,o=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=Le(this.remainderData,e));var l=bn(r);this.remainderData=l.remainder,s.samples=l.valid||new Uint8Array}else s.samples=r;var u=this.extractID3Track(s,t);return o.samples=Sr(t,s),{videoTrack:s,audioTrack:this.audioTrack,id3Track:u,textTrack:this.txtTrack}},n.flush=function(){var e=this.timeOffset,t=this.videoTrack,r=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;var s=this.extractID3Track(t,this.timeOffset);return r.samples=Sr(e,t),{videoTrack:t,audioTrack:Ce(),id3Track:s,textTrack:Ce()}},n.extractID3Track=function(e,t){var r=this.id3Track;if(e.samples.length){var s=G(e.samples,["emsg"]);s&&s.forEach(function(o){var l=Dn(o);if(Es.test(l.schemeIdUri)){var u=M(l.presentationTime)?l.presentationTime/l.timeScale:t+l.presentationTimeDelta/l.timeScale,d=l.eventDuration===4294967295?Number.POSITIVE_INFINITY:l.eventDuration/l.timeScale;d<=.001&&(d=Number.POSITIVE_INFINITY);var f=l.payload;r.samples.push({data:f,len:f.byteLength,dts:u,pts:u,type:Ae.emsg,duration:d})}})}return r},n.demuxSampleAes=function(e,t,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},n.destroy=function(){},a}(),Ts=function(n,i){var e=0,t=5;i+=t;for(var r=new Uint32Array(1),s=new Uint32Array(1),o=new Uint8Array(1);t>0;){o[0]=n[i];var l=Math.min(t,8),u=8-l;s[0]=4278190080>>>24+u<<u,r[0]=(o[0]&s[0])>>u,e=e?e<<l|r[0]:r[0],i+=1,t-=l}return e},Ss=function(){function a(){this.VideoSample=null}var n=a.prototype;return n.createVideoSample=function(e,t,r,s){return{key:e,frame:!1,pts:t,dts:r,units:[],debug:s,length:0}},n.getLastNalUnit=function(e){var t,r=this.VideoSample,s;if((!r||r.units.length===0)&&(r=e[e.length-1]),(t=r)!=null&&t.units){var o=r.units;s=o[o.length-1]}return s},n.pushAccessUnit=function(e,t){if(e.units.length&&e.frame){if(e.pts===void 0){var r=t.samples,s=r.length;if(s){var o=r[s-1];e.pts=o.pts,e.dts=o.dts}else{t.dropped++;return}}t.samples.push(e)}e.debug.length&&R.log(e.pts+"/"+e.dts+":"+e.debug)},a}(),Ai=function(){function a(i){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=i,this.bytesAvailable=i.byteLength,this.word=0,this.bitsAvailable=0}var n=a.prototype;return n.loadWord=function(){var e=this.data,t=this.bytesAvailable,r=e.byteLength-t,s=new Uint8Array(4),o=Math.min(4,t);if(o===0)throw new Error("no bytes available");s.set(e.subarray(r,r+o)),this.word=new DataView(s.buffer).getUint32(0),this.bitsAvailable=o*8,this.bytesAvailable-=o},n.skipBits=function(e){var t;e=Math.min(e,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,t=e>>3,e-=t<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)},n.readBits=function(e){var t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;if(e>32&&R.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");return t=e-t,t>0&&this.bitsAvailable?r<<t|this.readBits(t):r},n.skipLZ=function(){var e;for(e=0;e<this.bitsAvailable;++e)if(this.word&2147483648>>>e)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()},n.skipUEG=function(){this.skipBits(1+this.skipLZ())},n.skipEG=function(){this.skipBits(1+this.skipLZ())},n.readUEG=function(){var e=this.skipLZ();return this.readBits(e+1)-1},n.readEG=function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)},n.readBoolean=function(){return this.readBits(1)===1},n.readUByte=function(){return this.readBits(8)},n.readUShort=function(){return this.readBits(16)},n.readUInt=function(){return this.readBits(32)},n.skipScalingList=function(e){for(var t=8,r=8,s,o=0;o<e;o++)r!==0&&(s=this.readEG(),r=(t+s+256)%256),t=r===0?t:r},n.readSPS=function(){var e=0,t=0,r=0,s=0,o,l,u,d=this.readUByte.bind(this),f=this.readBits.bind(this),h=this.readUEG.bind(this),c=this.readBoolean.bind(this),v=this.skipBits.bind(this),g=this.skipEG.bind(this),m=this.skipUEG.bind(this),p=this.skipScalingList.bind(this);d();var y=d();if(f(5),v(3),d(),m(),y===100||y===110||y===122||y===244||y===44||y===83||y===86||y===118||y===128){var E=h();if(E===3&&v(1),m(),m(),v(1),c())for(l=E!==3?8:12,u=0;u<l;u++)c()&&(u<6?p(16):p(64))}m();var S=h();if(S===0)h();else if(S===1)for(v(1),g(),g(),o=h(),u=0;u<o;u++)g();m(),v(1);var L=h(),_=h(),A=f(1);A===0&&v(1),v(1),c()&&(e=h(),t=h(),r=h(),s=h());var T=[1,1];if(c()&&c()){var b=d();switch(b){case 1:T=[1,1];break;case 2:T=[12,11];break;case 3:T=[10,11];break;case 4:T=[16,11];break;case 5:T=[40,33];break;case 6:T=[24,11];break;case 7:T=[20,11];break;case 8:T=[32,11];break;case 9:T=[80,33];break;case 10:T=[18,11];break;case 11:T=[15,11];break;case 12:T=[64,33];break;case 13:T=[160,99];break;case 14:T=[4,3];break;case 15:T=[3,2];break;case 16:T=[2,1];break;case 255:{T=[d()<<8|d(),d()<<8|d()];break}}}return{width:Math.ceil((L+1)*16-e*2-t*2),height:(2-A)*(_+1)*16-(A?2:4)*(r+s),pixelRatio:T}},n.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},a}(),Ls=function(a){_e(n,a);function n(){return a.apply(this,arguments)||this}var i=n.prototype;return i.parseAVCPES=function(t,r,s,o,l){var u=this,d=this.parseAVCNALu(t,s.data),f=this.VideoSample,h,c=!1;s.data=null,f&&d.length&&!t.audFound&&(this.pushAccessUnit(f,t),f=this.VideoSample=this.createVideoSample(!1,s.pts,s.dts,"")),d.forEach(function(v){var g;switch(v.type){case 1:{var m=!1;h=!0;var p=v.data;if(c&&p.length>4){var y=new Ai(p).readSliceType();(y===2||y===4||y===7||y===9)&&(m=!0)}if(m){var E;(E=f)!=null&&E.frame&&!f.key&&(u.pushAccessUnit(f,t),f=u.VideoSample=null)}f||(f=u.VideoSample=u.createVideoSample(!0,s.pts,s.dts,"")),f.frame=!0,f.key=m;break}case 5:h=!0,(g=f)!=null&&g.frame&&!f.key&&(u.pushAccessUnit(f,t),f=u.VideoSample=null),f||(f=u.VideoSample=u.createVideoSample(!0,s.pts,s.dts,"")),f.key=!0,f.frame=!0;break;case 6:{h=!0,Lr(v.data,1,s.pts,r.samples);break}case 7:{var S,L;h=!0,c=!0;var _=v.data,A=new Ai(_),T=A.readSPS();if(!t.sps||t.width!==T.width||t.height!==T.height||((S=t.pixelRatio)==null?void 0:S[0])!==T.pixelRatio[0]||((L=t.pixelRatio)==null?void 0:L[1])!==T.pixelRatio[1]){t.width=T.width,t.height=T.height,t.pixelRatio=T.pixelRatio,t.sps=[_],t.duration=l;for(var b=_.subarray(1,4),I="avc1.",P=0;P<3;P++){var C=b[P].toString(16);C.length<2&&(C="0"+C),I+=C}t.codec=I}break}case 8:h=!0,t.pps=[v.data];break;case 9:h=!0,t.audFound=!0,f&&u.pushAccessUnit(f,t),f=u.VideoSample=u.createVideoSample(!1,s.pts,s.dts,"");break;case 12:h=!0;break;default:h=!1,f&&(f.debug+="unknown NAL "+v.type+" ");break}if(f&&h){var w=f.units;w.push(v)}}),o&&f&&(this.pushAccessUnit(f,t),this.VideoSample=null)},i.parseAVCNALu=function(t,r){var s=r.byteLength,o=t.naluState||0,l=o,u=[],d=0,f,h,c,v=-1,g=0;for(o===-1&&(v=0,g=r[0]&31,o=0,d=1);d<s;){if(f=r[d++],!o){o=f?0:1;continue}if(o===1){o=f?0:2;continue}if(!f)o=3;else if(f===1){if(h=d-o-1,v>=0){var m={data:r.subarray(v,h),type:g};u.push(m)}else{var p=this.getLastNalUnit(t.samples);p&&(l&&d<=4-l&&p.state&&(p.data=p.data.subarray(0,p.data.byteLength-l)),h>0&&(p.data=Le(p.data,r.subarray(0,h)),p.state=0))}d<s?(c=r[d]&31,v=d,g=c,o=0):o=-1}else o=0}if(v>=0&&o>=0){var y={data:r.subarray(v,s),type:g,state:o};u.push(y)}if(u.length===0){var E=this.getLastNalUnit(t.samples);E&&(E.data=Le(E.data,r))}return t.naluState=o,u},n}(Ss),As=function(){function a(i,e,t){this.keyData=void 0,this.decrypter=void 0,this.keyData=t,this.decrypter=new Vt(e,{removePKCS7Padding:!1})}var n=a.prototype;return n.decryptBuffer=function(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer)},n.decryptAacSample=function(e,t,r){var s=this,o=e[t].unit;if(!(o.length<=16)){var l=o.subarray(16,o.length-o.length%16),u=l.buffer.slice(l.byteOffset,l.byteOffset+l.length);this.decryptBuffer(u).then(function(d){var f=new Uint8Array(d);o.set(f,16),s.decrypter.isSync()||s.decryptAacSamples(e,t+1,r)})}},n.decryptAacSamples=function(e,t,r){for(;;t++){if(t>=e.length){r();return}if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,r),!this.decrypter.isSync()))return}},n.getAvcEncryptedData=function(e){for(var t=Math.floor((e.length-48)/160)*16+16,r=new Int8Array(t),s=0,o=32;o<e.length-16;o+=160,s+=16)r.set(e.subarray(o,o+16),s);return r},n.getAvcDecryptedUnit=function(e,t){for(var r=new Uint8Array(t),s=0,o=32;o<e.length-16;o+=160,s+=16)e.set(r.subarray(s,s+16),o);return e},n.decryptAvcSample=function(e,t,r,s,o){var l=this,u=Ar(o.data),d=this.getAvcEncryptedData(u);this.decryptBuffer(d.buffer).then(function(f){o.data=l.getAvcDecryptedUnit(u,f),l.decrypter.isSync()||l.decryptAvcSamples(e,t,r+1,s)})},n.decryptAvcSamples=function(e,t,r,s){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,r=0){if(t>=e.length){s();return}for(var o=e[t].units;!(r>=o.length);r++){var l=o[r];if(!(l.data.length<=48||l.type!==1&&l.type!==5)&&(this.decryptAvcSample(e,t,r,s,l),!this.decrypter.isSync()))return}}},a}(),le=188,Rs=function(){function a(i,e,t){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._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=i,this.config=e,this.typeSupported=t,this.videoParser=new Ls}a.probe=function(e){var t=a.syncOffset(e);return t>0&&R.warn("MPEG2-TS detected but first sync word found @ offset "+t),t!==-1},a.syncOffset=function(e){for(var t=e.length,r=Math.min(le*5,t-le)+1,s=0;s<r;){for(var o=!1,l=-1,u=0,d=s;d<t;d+=le)if(e[d]===71&&(t-d===le||e[d+le]===71)){if(u++,l===-1&&(l=d,l!==0&&(r=Math.min(l+le*99,e.length-le)+1)),o||(o=Yt(e,d)===0),o&&u>1&&(l===0&&u>2||d+le>r))return l}else{if(u)return-1;break}s++}return-1},a.createTrack=function(e,t){return{container:e==="video"||e==="audio"?"video/mp2t":void 0,type:e,id:pr[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:e==="audio"?t:void 0}};var n=a.prototype;return n.resetInitSegment=function(e,t,r,s){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=a.createTrack("video"),this._audioTrack=a.createTrack("audio",s),this._id3Track=a.createTrack("id3"),this._txtTrack=a.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=r,this._duration=s},n.resetTimeStamp=function(){},n.resetContiguity=function(){var e=this._audioTrack,t=this._videoTrack,r=this._id3Track;e&&(e.pesData=null),t&&(t.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.remainderData=null},n.demux=function(e,t,r,s){r===void 0&&(r=!1),s===void 0&&(s=!1),r||(this.sampleAes=null);var o,l=this._videoTrack,u=this._audioTrack,d=this._id3Track,f=this._txtTrack,h=l.pid,c=l.pesData,v=u.pid,g=d.pid,m=u.pesData,p=d.pesData,y=null,E=this.pmtParsed,S=this._pmtId,L=e.length;if(this.remainderData&&(e=Le(this.remainderData,e),L=e.length,this.remainderData=null),L<le&&!s)return this.remainderData=e,{audioTrack:u,videoTrack:l,id3Track:d,textTrack:f};var _=Math.max(0,a.syncOffset(e));L-=(L-_)%le,L<e.byteLength&&!s&&(this.remainderData=new Uint8Array(e.buffer,L,e.buffer.byteLength-L));for(var A=0,T=_;T<L;T+=le)if(e[T]===71){var b=!!(e[T+1]&64),I=Yt(e,T),P=(e[T+3]&48)>>4,C=void 0;if(P>1){if(C=T+5+e[T+4],C===T+le)continue}else C=T+4;switch(I){case h:b&&(c&&(o=Ye(c))&&this.videoParser.parseAVCPES(l,f,o,!1,this._duration),c={data:[],size:0}),c&&(c.data.push(e.subarray(C,T+le)),c.size+=T+le-C);break;case v:if(b){if(m&&(o=Ye(m)))switch(u.segmentCodec){case"aac":this.parseAACPES(u,o);break;case"mp3":this.parseMPEGPES(u,o);break}m={data:[],size:0}}m&&(m.data.push(e.subarray(C,T+le)),m.size+=T+le-C);break;case g:b&&(p&&(o=Ye(p))&&this.parseID3PES(d,o),p={data:[],size:0}),p&&(p.data.push(e.subarray(C,T+le)),p.size+=T+le-C);break;case 0:b&&(C+=e[C]+1),S=this._pmtId=bs(e,C);break;case S:{b&&(C+=e[C]+1);var w=Is(e,C,this.typeSupported,r,this.observer);h=w.videoPid,h>0&&(l.pid=h,l.segmentCodec=w.segmentVideoCodec),v=w.audioPid,v>0&&(u.pid=v,u.segmentCodec=w.segmentAudioCodec),g=w.id3Pid,g>0&&(d.pid=g),y!==null&&!E&&(R.warn("MPEG-TS PMT found at "+T+" after unknown PID '"+y+"'. Backtracking to sync byte @"+_+" to parse all TS packets."),y=null,T=_-188),E=this.pmtParsed=!0;break}case 17:case 8191:break;default:y=I;break}}else A++;A>0&&pt(this.observer,new Error("Found "+A+" TS packet/s that do not start with 0x47")),l.pesData=c,u.pesData=m,d.pesData=p;var O={audioTrack:u,videoTrack:l,id3Track:d,textTrack:f};return s&&this.extractRemainingSamples(O),O},n.flush=function(){var e=this.remainderData;this.remainderData=null;var t;return e?t=this.demux(e,-1,!1,!0):t={videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t},n.extractRemainingSamples=function(e){var t=e.audioTrack,r=e.videoTrack,s=e.id3Track,o=e.textTrack,l=r.pesData,u=t.pesData,d=s.pesData,f;if(l&&(f=Ye(l))?(this.videoParser.parseAVCPES(r,o,f,!0,this._duration),r.pesData=null):r.pesData=l,u&&(f=Ye(u))){switch(t.segmentCodec){case"aac":this.parseAACPES(t,f);break;case"mp3":this.parseMPEGPES(t,f);break}t.pesData=null}else u!=null&&u.size&&R.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=u;d&&(f=Ye(d))?(this.parseID3PES(s,f),s.pesData=null):s.pesData=d},n.demuxSampleAes=function(e,t,r){var s=this.demux(e,r,!0,!this.config.progressive),o=this.sampleAes=new As(this.observer,this.config,t);return this.decrypt(s,o)},n.decrypt=function(e,t){return new Promise(function(r){var s=e.audioTrack,o=e.videoTrack;s.samples&&s.segmentCodec==="aac"?t.decryptAacSamples(s.samples,0,function(){o.samples?t.decryptAvcSamples(o.samples,0,0,function(){r(e)}):r(e)}):o.samples&&t.decryptAvcSamples(o.samples,0,0,function(){r(e)})})},n.destroy=function(){this._duration=0},n.parseAACPES=function(e,t){var r=0,s=this.aacOverFlow,o=t.data;if(s){this.aacOverFlow=null;var l=s.missing,u=s.sample.unit.byteLength;if(l===-1)o=Le(s.sample.unit,o);else{var d=u-l;s.sample.unit.set(o.subarray(0,l),d),e.samples.push(s.sample),r=s.missing}}var f,h;for(f=r,h=o.length;f<h-1&&!gt(o,f);f++);if(f!==r){var c,v=f<h-1;if(v?c="AAC PES did not start with ADTS header,offset:"+f:c="No ADTS header found in AAC PES",pt(this.observer,new Error(c),v),!v)return}pi(e,this.observer,o,f,this.audioCodec);var g;if(t.pts!==void 0)g=t.pts;else if(s){var m=yi(e.samplerate);g=s.sample.pts+m}else{R.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var p=0,y;f<h;)if(y=Ei(e,o,f,g,p),f+=y.length,y.missing){this.aacOverFlow=y;break}else for(p++;f<h-1&&!gt(o,f);f++);},n.parseMPEGPES=function(e,t){var r=t.data,s=r.length,o=0,l=0,u=t.pts;if(u===void 0){R.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;l<s;)if(Si(r,l)){var d=xi(e,r,l,u,o);if(d)l+=d.length,o++;else break}else l++},n.parseAC3PES=function(e,t){},n.parseID3PES=function(e,t){if(t.pts===void 0){R.warn("[tsdemuxer]: ID3 PES unknown PTS");return}var r=xe({},t,{type:this._videoTrack?Ae.emsg:Ae.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(r)},a}();function Yt(a,n){return((a[n+1]&31)<<8)+a[n+2]}function bs(a,n){return(a[n+10]&31)<<8|a[n+11]}function Is(a,n,i,e,t){var r={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},s=(a[n+1]&15)<<8|a[n+2],o=n+3+s-4,l=(a[n+10]&15)<<8|a[n+11];for(n+=12+l;n<o;){var u=Yt(a,n),d=(a[n+3]&15)<<8|a[n+4];switch(a[n]){case 207:if(!e){qt("ADTS AAC");break}case 15:r.audioPid===-1&&(r.audioPid=u);break;case 21:r.id3Pid===-1&&(r.id3Pid=u);break;case 219:if(!e){qt("H.264");break}case 27:r.videoPid===-1&&(r.videoPid=u,r.segmentVideoCodec="avc");break;case 3:case 4:!i.mpeg&&!i.mp3?R.log("MPEG audio found, not supported in this browser"):r.audioPid===-1&&(r.audioPid=u,r.segmentAudioCodec="mp3");break;case 193:if(!e){qt("AC-3");break}case 129:R.warn("AC-3 in M2TS support not included in build");break;case 6:if(r.audioPid===-1&&d>0)for(var f=n+5,h=d;h>2;){var c=a[f];switch(c){case 106:R.warn("AC-3 in M2TS support not included in build");break}var v=a[f+1]+2;f+=v,h-=v}break;case 194:case 135:return pt(t,new Error("Unsupported EC-3 in M2TS found")),r;case 36:return pt(t,new Error("Unsupported HEVC in M2TS found")),r}n+=d+5}return r}function pt(a,n,i){R.warn("parsing error: "+n.message),a.emit(x.ERROR,x.ERROR,{type:V.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!1,levelRetry:i,error:n,reason:n.message})}function qt(a){R.log(a+" with AES-128-CBC encryption found in unencrypted stream")}function Ye(a){var n=0,i,e,t,r,s,o=a.data;if(!a||a.size===0)return null;for(;o[0].length<19&&o.length>1;)o[0]=Le(o[0],o[1]),o.splice(1,1);i=o[0];var l=(i[0]<<16)+(i[1]<<8)+i[2];if(l===1){if(e=(i[4]<<8)+i[5],e&&e>a.size-6)return null;var u=i[7];u&192&&(r=(i[9]&14)*536870912+(i[10]&255)*4194304+(i[11]&254)*16384+(i[12]&255)*128+(i[13]&254)/2,u&64?(s=(i[14]&14)*536870912+(i[15]&255)*4194304+(i[16]&254)*16384+(i[17]&255)*128+(i[18]&254)/2,r-s>60*9e4&&(R.warn(Math.round((r-s)/9e4)+"s delta between PTS and DTS, align them"),r=s)):s=r),t=i[8];var d=t+9;if(a.size<=d)return null;a.size-=d;for(var f=new Uint8Array(a.size),h=0,c=o.length;h<c;h++){i=o[h];var v=i.byteLength;if(d)if(d>v){d-=v;continue}else i=i.subarray(d),v-=d,d=0;f.set(i,n),n+=v}return e&&(e-=t+3),{data:f,pts:r,dts:s,len:e}}return null}var _s=function(a){_e(n,a);function n(){return a.apply(this,arguments)||this}var i=n.prototype;return i.resetInitSegment=function(t,r,s,o){a.prototype.resetInitSegment.call(this,t,r,s,o),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:r,duration:o,inputTimeScale:9e4,dropped:0}},n.probe=function(t){if(!t)return!1;var r=et(t,0),s=r?.length||0;if(r&&t[s]===11&&t[s+1]===119&&cr(r)!==void 0&&Ts(t,s)<=16)return!1;for(var o=t.length;s<o;s++)if(Li(t,s))return R.log("MPEG Audio sync word found !"),!0;return!1},i.canParse=function(t,r){return ps(t,r)},i.appendFrame=function(t,r,s){if(this.basePTS!==null)return xi(t,r,s,this.basePTS,this.frameIndex)},n}(vi),Ri=function(){function a(){}return a.getSilentFrame=function(i,e){switch(i){case"mp4a.40.2":if(e===1)return new Uint8Array([0,200,0,128,35,128]);if(e===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(e===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(e===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(e===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(e===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(e===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(e===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(e===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}},a}(),Oe=Math.pow(2,32)-1,de=function(){function a(){}return a.init=function(){a.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],dac3:[],"ac-3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};var i;for(i in a.types)a.types.hasOwnProperty(i)&&(a.types[i]=[i.charCodeAt(0),i.charCodeAt(1),i.charCodeAt(2),i.charCodeAt(3)]);var e=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),t=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);a.HDLR_TYPES={video:e,audio:t};var r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),s=new Uint8Array([0,0,0,0,0,0,0,0]);a.STTS=a.STSC=a.STCO=s,a.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),a.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),a.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),a.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var o=new Uint8Array([105,115,111,109]),l=new Uint8Array([97,118,99,49]),u=new Uint8Array([0,0,0,1]);a.FTYP=a.box(a.types.ftyp,o,u,o,l),a.DINF=a.box(a.types.dinf,a.box(a.types.dref,r))},a.box=function(i){for(var e=8,t=arguments.length,r=new Array(t>1?t-1:0),s=1;s<t;s++)r[s-1]=arguments[s];for(var o=r.length,l=o;o--;)e+=r[o].byteLength;var u=new Uint8Array(e);for(u[0]=e>>24&255,u[1]=e>>16&255,u[2]=e>>8&255,u[3]=e&255,u.set(i,4),o=0,e=8;o<l;o++)u.set(r[o],e),e+=r[o].byteLength;return u},a.hdlr=function(i){return a.box(a.types.hdlr,a.HDLR_TYPES[i])},a.mdat=function(i){return a.box(a.types.mdat,i)},a.mdhd=function(i,e){e*=i;var t=Math.floor(e/(Oe+1)),r=Math.floor(e%(Oe+1));return a.box(a.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,i>>24&255,i>>16&255,i>>8&255,i&255,t>>24,t>>16&255,t>>8&255,t&255,r>>24,r>>16&255,r>>8&255,r&255,85,196,0,0]))},a.mdia=function(i){return a.box(a.types.mdia,a.mdhd(i.timescale,i.duration),a.hdlr(i.type),a.minf(i))},a.mfhd=function(i){return a.box(a.types.mfhd,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,i&255]))},a.minf=function(i){return i.type==="audio"?a.box(a.types.minf,a.box(a.types.smhd,a.SMHD),a.DINF,a.stbl(i)):a.box(a.types.minf,a.box(a.types.vmhd,a.VMHD),a.DINF,a.stbl(i))},a.moof=function(i,e,t){return a.box(a.types.moof,a.mfhd(i),a.traf(t,e))},a.moov=function(i){for(var e=i.length,t=[];e--;)t[e]=a.trak(i[e]);return a.box.apply(null,[a.types.moov,a.mvhd(i[0].timescale,i[0].duration)].concat(t).concat(a.mvex(i)))},a.mvex=function(i){for(var e=i.length,t=[];e--;)t[e]=a.trex(i[e]);return a.box.apply(null,[a.types.mvex].concat(t))},a.mvhd=function(i,e){e*=i;var t=Math.floor(e/(Oe+1)),r=Math.floor(e%(Oe+1)),s=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,i>>24&255,i>>16&255,i>>8&255,i&255,t>>24,t>>16&255,t>>8&255,t&255,r>>24,r>>16&255,r>>8&255,r&255,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 a.box(a.types.mvhd,s)},a.sdtp=function(i){var e=i.samples||[],t=new Uint8Array(4+e.length),r,s;for(r=0;r<e.length;r++)s=e[r].flags,t[r+4]=s.dependsOn<<4|s.isDependedOn<<2|s.hasRedundancy;return a.box(a.types.sdtp,t)},a.stbl=function(i){return a.box(a.types.stbl,a.stsd(i),a.box(a.types.stts,a.STTS),a.box(a.types.stsc,a.STSC),a.box(a.types.stsz,a.STSZ),a.box(a.types.stco,a.STCO))},a.avc1=function(i){var e=[],t=[],r,s,o;for(r=0;r<i.sps.length;r++)s=i.sps[r],o=s.byteLength,e.push(o>>>8&255),e.push(o&255),e=e.concat(Array.prototype.slice.call(s));for(r=0;r<i.pps.length;r++)s=i.pps[r],o=s.byteLength,t.push(o>>>8&255),t.push(o&255),t=t.concat(Array.prototype.slice.call(s));var l=a.box(a.types.avcC,new Uint8Array([1,e[3],e[4],e[5],255,224|i.sps.length].concat(e).concat([i.pps.length]).concat(t))),u=i.width,d=i.height,f=i.pixelRatio[0],h=i.pixelRatio[1];return a.box(a.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,u>>8&255,u&255,d>>8&255,d&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),l,a.box(a.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),a.box(a.types.pasp,new Uint8Array([f>>24,f>>16&255,f>>8&255,f&255,h>>24,h>>16&255,h>>8&255,h&255])))},a.esds=function(i){var e=i.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(i.config).concat([6,1,2]))},a.audioStsd=function(i){var e=i.samplerate;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,i.channelCount,0,16,0,0,0,0,e>>8&255,e&255,0,0])},a.mp4a=function(i){return a.box(a.types.mp4a,a.audioStsd(i),a.box(a.types.esds,a.esds(i)))},a.mp3=function(i){return a.box(a.types[".mp3"],a.audioStsd(i))},a.ac3=function(i){return a.box(a.types["ac-3"],a.audioStsd(i),a.box(a.types.dac3,i.config))},a.stsd=function(i){return i.type==="audio"?i.segmentCodec==="mp3"&&i.codec==="mp3"?a.box(a.types.stsd,a.STSD,a.mp3(i)):i.segmentCodec==="ac3"?a.box(a.types.stsd,a.STSD,a.ac3(i)):a.box(a.types.stsd,a.STSD,a.mp4a(i)):a.box(a.types.stsd,a.STSD,a.avc1(i))},a.tkhd=function(i){var e=i.id,t=i.duration*i.timescale,r=i.width,s=i.height,o=Math.floor(t/(Oe+1)),l=Math.floor(t%(Oe+1));return a.box(a.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,e&255,0,0,0,0,o>>24,o>>16&255,o>>8&255,o&255,l>>24,l>>16&255,l>>8&255,l&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,r>>8&255,r&255,0,0,s>>8&255,s&255,0,0]))},a.traf=function(i,e){var t=a.sdtp(i),r=i.id,s=Math.floor(e/(Oe+1)),o=Math.floor(e%(Oe+1));return a.box(a.types.traf,a.box(a.types.tfhd,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,r&255])),a.box(a.types.tfdt,new Uint8Array([1,0,0,0,s>>24,s>>16&255,s>>8&255,s&255,o>>24,o>>16&255,o>>8&255,o&255])),a.trun(i,t.length+16+20+8+16+8+8),t)},a.trak=function(i){return i.duration=i.duration||4294967295,a.box(a.types.trak,a.tkhd(i),a.mdia(i))},a.trex=function(i){var e=i.id;return a.box(a.types.trex,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},a.trun=function(i,e){var t=i.samples||[],r=t.length,s=12+16*r,o=new Uint8Array(s),l,u,d,f,h,c;for(e+=8+s,o.set([i.type==="video"?1:0,0,15,1,r>>>24&255,r>>>16&255,r>>>8&255,r&255,e>>>24&255,e>>>16&255,e>>>8&255,e&255],0),l=0;l<r;l++)u=t[l],d=u.duration,f=u.size,h=u.flags,c=u.cts,o.set([d>>>24&255,d>>>16&255,d>>>8&255,d&255,f>>>24&255,f>>>16&255,f>>>8&255,f&255,h.isLeading<<2|h.dependsOn,h.isDependedOn<<6|h.hasRedundancy<<4|h.paddingValue<<1|h.isNonSync,h.degradPrio&61440,h.degradPrio&15,c>>>24&255,c>>>16&255,c>>>8&255,c&255],12+16*l);return a.box(a.types.trun,o)},a.initSegment=function(i){a.types||a.init();var e=a.moov(i),t=Le(a.FTYP,e);return t},a}();de.types=void 0,de.HDLR_TYPES=void 0,de.STTS=void 0,de.STSC=void 0,de.STCO=void 0,de.STSZ=void 0,de.VMHD=void 0,de.SMHD=void 0,de.STSD=void 0,de.FTYP=void 0,de.DINF=void 0;var Ds=9e4;function Cs(a,n,i,e){i===void 0&&(i=1),e===void 0&&(e=!1);var t=a*n*i;return e?Math.round(t):t}function $e(a,n){return n===void 0&&(n=!1),Cs(a,1e3,1/Ds,n)}var Ps=10*1e3,bi=1024,ws=1152,ks=1536,qe=null,jt=null,Xt=function(){function a(i,e,t,r){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.videoTrackConfig=void 0,this.observer=i,this.config=e,this.typeSupported=t,this.ISGenerated=!1,qe===null){var s=navigator.userAgent||"",o=s.match(/Chrome\/(\d+)/i);qe=o?parseInt(o[1]):0}if(jt===null){var l=navigator.userAgent.match(/Safari\/(\d+)/i);jt=l?parseInt(l[1]):0}}var n=a.prototype;return n.destroy=function(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null},n.resetTimeStamp=function(e){R.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e},n.resetNextTimestamp=function(){R.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},n.resetInitSegment=function(){R.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0},n.getVideoStartPts=function(e){var t=!1,r=e.reduce(function(s,o){var l=o.pts-s;return l<-4294967296?(t=!0,be(s,o.pts)):l>0?s:o.pts},e[0].pts);return t&&R.debug("PTS rollover detected"),r},n.remux=function(e,t,r,s,o,l,u,d){var f,h,c,v,g,m,p=o,y=o,E=e.pid>-1,S=t.pid>-1,L=t.samples.length,_=e.samples.length>0,A=u&&L>0||L>1,T=(!E||_)&&(!S||A)||this.ISGenerated||u;if(T){if(this.ISGenerated){var b,I,P,C,w=this.videoTrackConfig;w&&(t.width!==w.width||t.height!==w.height||((b=t.pixelRatio)==null?void 0:b[0])!==((I=w.pixelRatio)==null?void 0:I[0])||((P=t.pixelRatio)==null?void 0:P[1])!==((C=w.pixelRatio)==null?void 0:C[1]))&&this.resetInitSegment()}else c=this.generateIS(e,t,o,l);var O=this.isVideoContiguous,F=-1,H;if(A&&(F=Fs(t.samples),!O&&this.config.forceKeyFrameOnDiscontinuity))if(m=!0,F>0){R.warn("[mp4-remuxer]: Dropped "+F+" out of "+L+" video samples due to a missing keyframe");var U=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(F),t.dropped+=F,y+=(t.samples[0].pts-U)/t.inputTimeScale,H=y}else F===-1&&(R.warn("[mp4-remuxer]: No keyframe found out of "+L+" video samples"),m=!1);if(this.ISGenerated){if(_&&A){var W=this.getVideoStartPts(t.samples),K=be(e.samples[0].pts,W)-W,B=K/t.inputTimeScale;p+=Math.max(0,B),y+=Math.max(0,-B)}if(_){if(e.samplerate||(R.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),c=this.generateIS(e,t,o,l)),h=this.remuxAudio(e,p,this.isAudioContiguous,l,S||A||d===q.AUDIO?y:void 0),A){var Q=h?h.endPTS-h.startPTS:0;t.inputTimeScale||(R.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),c=this.generateIS(e,t,o,l)),f=this.remuxVideo(t,y,O,Q)}}else A&&(f=this.remuxVideo(t,y,O,0));f&&(f.firstKeyFrame=F,f.independent=F!==-1,f.firstKeyFramePTS=H)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(g=Ii(r,o,this._initPTS,this._initDTS)),s.samples.length&&(v=_i(s,o,this._initPTS))),{audio:h,video:f,initSegment:c,independent:m,text:v,id3:g}},n.generateIS=function(e,t,r,s){var o=e.samples,l=t.samples,u=this.typeSupported,d={},f=this._initPTS,h=!f||s,c="audio/mp4",v,g,m;if(h&&(v=g=1/0),e.config&&o.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":u.mpeg?(c="audio/mpeg",e.codec=""):u.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3";break}d.audio={id:"audio",container:c,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&u.mpeg?new Uint8Array(0):de.initSegment([e]),metadata:{channelCount:e.channelCount}},h&&(m=e.inputTimeScale,!f||m!==f.timescale?v=g=o[0].pts-Math.round(m*r):h=!1)}if(t.sps&&t.pps&&l.length){if(t.timescale=t.inputTimeScale,d.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:de.initSegment([t]),metadata:{width:t.width,height:t.height}},h)if(m=t.inputTimeScale,!f||m!==f.timescale){var p=this.getVideoStartPts(l),y=Math.round(m*r);g=Math.min(g,be(l[0].dts,p)-y),v=Math.min(v,p-y)}else h=!1;this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(d).length)return this.ISGenerated=!0,h?(this._initPTS={baseTime:v,timescale:m},this._initDTS={baseTime:g,timescale:m}):v=m=void 0,{tracks:d,initPTS:v,timescale:m}},n.remuxVideo=function(e,t,r,s){var o=e.inputTimeScale,l=e.samples,u=[],d=l.length,f=this._initPTS,h=this.nextAvcDts,c=8,v=this.videoSampleDuration,g,m,p=Number.POSITIVE_INFINITY,y=Number.NEGATIVE_INFINITY,E=!1;if(!r||h===null){var S=t*o,L=l[0].pts-be(l[0].dts,l[0].pts);qe&&h!==null&&Math.abs(S-L-h)<15e3?r=!0:h=S-L}for(var _=f.baseTime*o/f.timescale,A=0;A<d;A++){var T=l[A];T.pts=be(T.pts-_,h),T.dts=be(T.dts-_,h),T.dts<l[A>0?A-1:A].dts&&(E=!0)}E&&l.sort(function(Tt,Hi){var oo=Tt.dts-Hi.dts,lo=Tt.pts-Hi.pts;return oo||lo}),g=l[0].dts,m=l[l.length-1].dts;var b=m-g,I=b?Math.round(b/(d-1)):v||e.inputTimeScale/30;if(r){var P=g-h,C=P>I,w=P<-1;if((C||w)&&(C?R.warn("AVC: "+$e(P,!0)+" ms ("+P+"dts) hole between fragments detected at "+t.toFixed(3)):R.warn("AVC: "+$e(-P,!0)+" ms ("+P+"dts) overlapping between fragments detected at "+t.toFixed(3)),!w||h>=l[0].pts||qe)){g=h;var O=l[0].pts-P;if(C)l[0].dts=g,l[0].pts=O;else for(var F=0;F<l.length&&!(l[F].dts>O);F++)l[F].dts-=P,l[F].pts-=P;R.log("Video: Initial PTS/DTS adjusted: "+$e(O,!0)+"/"+$e(g,!0)+", delta: "+$e(P,!0)+" ms")}}g=Math.max(0,g);for(var H=0,U=0,W=g,K=0;K<d;K++){for(var B=l[K],Q=B.units,j=Q.length,J=0,ee=0;ee<j;ee++)J+=Q[ee].data.length;U+=J,H+=j,B.length=J,B.dts<W?(B.dts=W,W+=I/4|0||1):W=B.dts,p=Math.min(B.pts,p),y=Math.max(B.pts,y)}m=l[d-1].dts;var re=U+4*H+8,Z;try{Z=new Uint8Array(re)}catch(Tt){this.observer.emit(x.ERROR,x.ERROR,{type:V.MUX_ERROR,details:D.REMUX_ALLOC_ERROR,fatal:!1,error:Tt,bytes:re,reason:"fail allocating video mdat "+re});return}var X=new DataView(Z.buffer);X.setUint32(0,re),Z.set(de.types.mdat,4);for(var Fe=!1,Te=Number.POSITIVE_INFINITY,te=Number.POSITIVE_INFINITY,me=Number.NEGATIVE_INFINITY,pe=Number.NEGATIVE_INFINITY,ie=0;ie<d;ie++){for(var z=l[ie],Ee=z.units,ce=0,ue=0,Ve=Ee.length;ue<Ve;ue++){var Oi=Ee[ue],Js=Oi.data,er=Oi.data.byteLength;X.setUint32(c,er),c+=4,Z.set(Js,c),c+=er,ce+=4+er}var Et=void 0;if(ie<d-1)v=l[ie+1].dts-z.dts,Et=l[ie+1].pts-z.pts;else{var Ni=this.config,xt=ie>0?z.dts-l[ie-1].dts:I;if(Et=ie>0?z.pts-l[ie-1].pts:I,Ni.stretchShortVideoTrack&&this.nextAudioPts!==null){var eo=Math.floor(Ni.maxBufferHole*o),tr=(s?p+s*o:this.nextAudioPts)-z.pts;tr>eo?(v=tr-xt,v<0?v=xt:Fe=!0,R.log("[mp4-remuxer]: It is approximately "+tr/90+" ms to the next segment; using duration "+v/90+" ms for the last video frame.")):v=xt}else v=xt}var to=Math.round(z.pts-z.dts);Te=Math.min(Te,v),me=Math.max(me,v),te=Math.min(te,Et),pe=Math.max(pe,Et),u.push(new Di(z.key,v,ce,to))}if(u.length){if(qe){if(qe<70){var Bi=u[0].flags;Bi.dependsOn=2,Bi.isNonSync=0}}else if(jt&&pe-te<me-Te&&I/me<.025&&u[0].cts===0){R.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var rr=g,Ie=0,Ui=u.length;Ie<Ui;Ie++){var Gi=rr+u[Ie].duration,ro=rr+u[Ie].cts;if(Ie<Ui-1){var io=Gi+u[Ie+1].cts;u[Ie].duration=io-ro}else u[Ie].duration=Ie?u[Ie-1].duration:I;u[Ie].cts=0,rr=Gi}}}v=Fe||!v?I:v,this.nextAvcDts=h=m+v,this.videoSampleDuration=v,this.isVideoContiguous=!0;var no=de.moof(e.sequenceNumber++,g,xe({},e,{samples:u})),ao="video",so={data1:no,data2:Z,startPTS:p/o,endPTS:(y+v)/o,startDTS:g/o,endDTS:h/o,type:ao,hasAudio:!1,hasVideo:!0,nb:u.length,dropped:e.dropped};return e.samples=[],e.dropped=0,so},n.getSamplesPerFrame=function(e){switch(e.segmentCodec){case"mp3":return ws;case"ac3":return ks;default:return bi}},n.remuxAudio=function(e,t,r,s,o){var l=e.inputTimeScale,u=e.samplerate?e.samplerate:l,d=l/u,f=this.getSamplesPerFrame(e),h=f*d,c=this._initPTS,v=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,g=[],m=o!==void 0,p=e.samples,y=v?0:8,E=this.nextAudioPts||-1,S=t*l,L=c.baseTime*l/c.timescale;if(this.isAudioContiguous=r=r||p.length&&E>0&&(s&&Math.abs(S-E)<9e3||Math.abs(be(p[0].pts-L,S)-E)<20*h),p.forEach(function(ue){ue.pts=be(ue.pts-L,S)}),!r||E<0){if(p=p.filter(function(ue){return ue.pts>=0}),!p.length)return;o===0?E=0:s&&!m?E=Math.max(0,S):E=p[0].pts}if(e.segmentCodec==="aac")for(var _=this.config.maxAudioFramesDrift,A=0,T=E;A<p.length;A++){var b=p[A],I=b.pts,P=I-T,C=Math.abs(1e3*P/l);if(P<=-_*h&&m)A===0&&(R.warn("Audio frame @ "+(I/l).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*P/l)+" ms."),this.nextAudioPts=E=T=I);else if(P>=_*h&&C<Ps&&m){var w=Math.round(P/h);T=I-w*h,T<0&&(w--,T+=h),A===0&&(this.nextAudioPts=E=T),R.warn("[mp4-remuxer]: Injecting "+w+" audio frame @ "+(T/l).toFixed(3)+"s due to "+Math.round(1e3*P/l)+" ms gap.");for(var O=0;O<w;O++){var F=Math.max(T,0),H=Ri.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);H||(R.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),H=b.unit.subarray()),p.splice(A,0,{unit:H,pts:F}),T+=h,A++}}b.pts=T,T+=h}for(var U=null,W=null,K,B=0,Q=p.length;Q--;)B+=p[Q].unit.byteLength;for(var j=0,J=p.length;j<J;j++){var ee=p[j],re=ee.unit,Z=ee.pts;if(W!==null){var X=g[j-1];X.duration=Math.round((Z-W)/d)}else if(r&&e.segmentCodec==="aac"&&(Z=E),U=Z,B>0){B+=y;try{K=new Uint8Array(B)}catch(ue){this.observer.emit(x.ERROR,x.ERROR,{type:V.MUX_ERROR,details:D.REMUX_ALLOC_ERROR,fatal:!1,error:ue,bytes:B,reason:"fail allocating audio mdat "+B});return}if(!v){var Fe=new DataView(K.buffer);Fe.setUint32(0,B),K.set(de.types.mdat,4)}}else return;K.set(re,y);var Te=re.byteLength;y+=Te,g.push(new Di(!0,f,Te,0)),W=Z}var te=g.length;if(te){var me=g[g.length-1];this.nextAudioPts=E=W+d*me.duration;var pe=v?new Uint8Array(0):de.moof(e.sequenceNumber++,U/d,xe({},e,{samples:g}));e.samples=[];var ie=U/l,z=E/l,Ee="audio",ce={data1:pe,data2:K,startPTS:ie,endPTS:z,startDTS:ie,endDTS:z,type:Ee,hasAudio:!0,hasVideo:!1,nb:te};return this.isAudioContiguous=!0,ce}},n.remuxEmptyAudio=function(e,t,r,s){var o=e.inputTimeScale,l=e.samplerate?e.samplerate:o,u=o/l,d=this.nextAudioPts,f=this._initDTS,h=f.baseTime*9e4/f.timescale,c=(d!==null?d:s.startDTS*o)+h,v=s.endDTS*o+h,g=u*bi,m=Math.ceil((v-c)/g),p=Ri.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(R.warn("[mp4-remuxer]: remux empty Audio"),!p){R.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var y=[],E=0;E<m;E++){var S=c+E*g;y.push({unit:p,pts:S,dts:S})}return e.samples=y,this.remuxAudio(e,t,r,!1)},a}();function be(a,n){var i;if(n===null)return a;for(n<a?i=-8589934592:i=8589934592;Math.abs(a-n)>4294967296;)a+=i;return a}function Fs(a){for(var n=0;n<a.length;n++)if(a[n].key)return n;return-1}function Ii(a,n,i,e){var t=a.samples.length;if(t){for(var r=a.inputTimeScale,s=0;s<t;s++){var o=a.samples[s];o.pts=be(o.pts-i.baseTime*r/i.timescale,n*r)/r,o.dts=be(o.dts-e.baseTime*r/e.timescale,n*r)/r}var l=a.samples;return a.samples=[],{samples:l}}}function _i(a,n,i){var e=a.samples.length;if(e){for(var t=a.inputTimeScale,r=0;r<e;r++){var s=a.samples[r];s.pts=be(s.pts-i.baseTime*t/i.timescale,n*t)/t}a.samples.sort(function(l,u){return l.pts-u.pts});var o=a.samples;return a.samples=[],{samples:o}}}var Di=function(n,i,e,t){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=i,this.size=e,this.cts=t,this.flags={isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:n?2:1,isNonSync:n?0:1}},Ms=function(){function a(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null}var n=a.prototype;return n.destroy=function(){},n.resetTimeStamp=function(e){this.initPTS=e,this.lastEndTime=null},n.resetNextTimestamp=function(){this.lastEndTime=null},n.resetInitSegment=function(e,t,r,s){this.audioCodec=t,this.videoCodec=r,this.generateInitSegment(xn(e,s)),this.emitInitSegment=!0},n.generateInitSegment=function(e){var t=this.audioCodec,r=this.videoCodec;if(!(e!=null&&e.byteLength)){this.initTracks=void 0,this.initData=void 0;return}var s=this.initData=Tr(e);s.audio&&(t=Ci(s.audio,$.AUDIO)),s.video&&(r=Ci(s.video,$.VIDEO));var o={};s.audio&&s.video?o.audiovideo={container:"video/mp4",codec:t+","+r,initSegment:e,id:"main"}:s.audio?o.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:s.video?o.video={container:"video/mp4",codec:r,initSegment:e,id:"main"}:R.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=o},n.remux=function(e,t,r,s,o,l){var u,d,f=this.initPTS,h=this.lastEndTime,c={audio:void 0,video:void 0,text:s,id3:r,initSegment:void 0};M(h)||(h=this.lastEndTime=o||0);var v=t.samples;if(!(v!=null&&v.length))return c;var g={initPTS:void 0,timescale:1},m=this.initData;if((u=m)!=null&&u.length||(this.generateInitSegment(v),m=this.initData),!((d=m)!=null&&d.length))return R.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),c;this.emitInitSegment&&(g.tracks=this.initTracks,this.emitInitSegment=!1);var p=Ln(v,m),y=Sn(m,v),E=y===null?o:y;(Os(f,E,o,p)||g.timescale!==f.timescale&&l)&&(g.initPTS=E-o,f&&f.timescale===1&&R.warn("Adjusting initPTS by "+(g.initPTS-f.baseTime)),this.initPTS=f={baseTime:g.initPTS,timescale:1});var S=e?E-f.baseTime/f.timescale:h,L=S+p;Rn(m,v,f.baseTime/f.timescale),p>0?this.lastEndTime=L:(R.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var _=!!m.audio,A=!!m.video,T="";_&&(T+="audio"),A&&(T+="video");var b={data1:v,startPTS:S,startDTS:S,endPTS:L,endDTS:L,type:T,hasAudio:_,hasVideo:A,nb:1,dropped:0};return c.audio=b.type==="audio"?b:void 0,c.video=b.type!=="audio"?b:void 0,c.initSegment=g,c.id3=Ii(r,o,f,f),s.samples.length&&(c.text=_i(s,o,f)),c},a}();function Os(a,n,i,e){if(a===null)return!0;var t=Math.max(e,1),r=n-a.baseTime/a.timescale;return Math.abs(r-i)>t}function Ci(a,n){var i=a?.codec;if(i&&i.length>4)return i;if(n===$.AUDIO){if(i==="ec-3"||i==="ac-3"||i==="alac")return i;if(i==="fLaC"||i==="Opus"){var e=!1;return st(i,e)}var t="mp4a.40.5";return R.info('Parsed audio codec "'+i+'" or audio object type not handled. Using "'+t+'"'),t}return R.warn('Unhandled video codec "'+i+'"'),i==="hvc1"||i==="hev1"?"hvc1.1.6.L120.90":i==="av01"?"av01.0.04M.08":"avc1.42e01e"}var Pi=typeof self<"u"?self:void 0,ke;try{ke=self.performance.now.bind(self.performance)}catch{R.debug("Unable to use Performance API on this environment"),ke=Pi?.Date.now}var zt=[{demux:xs,remux:Ms},{demux:Rs,remux:Xt},{demux:ys,remux:Xt},{demux:_s,remux:Xt}],$t=function(){function a(i,e,t,r,s){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=i,this.typeSupported=e,this.config=t,this.vendor=r,this.id=s}var n=a.prototype;return n.configure=function(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()},n.push=function(e,t,r,s){var o=this,l=r.transmuxing;l.executeStart=ke();var u=new Uint8Array(e),d=this.currentTransmuxState,f=this.transmuxConfig;s&&(this.currentTransmuxState=s);var h=s||d,c=h.contiguous,v=h.discontinuity,g=h.trackSwitch,m=h.accurateTimeOffset,p=h.timeOffset,y=h.initSegmentChange,E=f.audioCodec,S=f.videoCodec,L=f.defaultInitPts,_=f.duration,A=f.initSegmentData,T=Ns(u,t);if(T&&T.method==="AES-128"){var b=this.getDecrypter();if(b.isSync()){var I=b.softwareDecrypt(u,T.key.buffer,T.iv.buffer),P=r.part>-1;if(P&&(I=b.flush()),!I)return l.executeEnd=ke(),Qt(r);u=new Uint8Array(I)}else return this.decryptionPromise=b.webCryptoDecrypt(u,T.key.buffer,T.iv.buffer).then(function(H){var U=o.push(H,null,r);return o.decryptionPromise=null,U}),this.decryptionPromise}var C=this.needsProbing(v,g);if(C){var w=this.configureTransmuxer(u);if(w)return R.warn("[transmuxer] "+w.message),this.observer.emit(x.ERROR,x.ERROR,{type:V.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!1,error:w,reason:w.message}),l.executeEnd=ke(),Qt(r)}(v||g||y||C)&&this.resetInitSegment(A,E,S,_,t),(v||y||C)&&this.resetInitialTimestamp(L),c||this.resetContiguity();var O=this.transmux(u,T,p,m,r),F=this.currentTransmuxState;return F.contiguous=!0,F.discontinuity=!1,F.trackSwitch=!1,l.executeEnd=ke(),O},n.flush=function(e){var t=this,r=e.transmuxing;r.executeStart=ke();var s=this.decrypter,o=this.currentTransmuxState,l=this.decryptionPromise;if(l)return l.then(function(){return t.flush(e)});var u=[],d=o.timeOffset;if(s){var f=s.flush();f&&u.push(this.push(f,null,e))}var h=this.demuxer,c=this.remuxer;if(!h||!c)return r.executeEnd=ke(),[Qt(e)];var v=h.flush(d);return He(v)?v.then(function(g){return t.flushRemux(u,g,e),u}):(this.flushRemux(u,v,e),u)},n.flushRemux=function(e,t,r){var s=t.audioTrack,o=t.videoTrack,l=t.id3Track,u=t.textTrack,d=this.currentTransmuxState,f=d.accurateTimeOffset,h=d.timeOffset;R.log("[transmuxer.ts]: Flushed fragment "+r.sn+(r.part>-1?" p: "+r.part:"")+" of level "+r.level);var c=this.remuxer.remux(s,o,l,u,h,f,!0,this.id);e.push({remuxResult:c,chunkMeta:r}),r.transmuxing.executeEnd=ke()},n.resetInitialTimestamp=function(e){var t=this.demuxer,r=this.remuxer;!t||!r||(t.resetTimeStamp(e),r.resetTimeStamp(e))},n.resetContiguity=function(){var e=this.demuxer,t=this.remuxer;!e||!t||(e.resetContiguity(),t.resetNextTimestamp())},n.resetInitSegment=function(e,t,r,s,o){var l=this.demuxer,u=this.remuxer;!l||!u||(l.resetInitSegment(e,t,r,s),u.resetInitSegment(e,t,r,o))},n.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},n.transmux=function(e,t,r,s,o){var l;return t&&t.method==="SAMPLE-AES"?l=this.transmuxSampleAes(e,t,r,s,o):l=this.transmuxUnencrypted(e,r,s,o),l},n.transmuxUnencrypted=function(e,t,r,s){var o=this.demuxer.demux(e,t,!1,!this.config.progressive),l=o.audioTrack,u=o.videoTrack,d=o.id3Track,f=o.textTrack,h=this.remuxer.remux(l,u,d,f,t,r,!1,this.id);return{remuxResult:h,chunkMeta:s}},n.transmuxSampleAes=function(e,t,r,s,o){var l=this;return this.demuxer.demuxSampleAes(e,t,r).then(function(u){var d=l.remuxer.remux(u.audioTrack,u.videoTrack,u.id3Track,u.textTrack,r,s,!1,l.id);return{remuxResult:d,chunkMeta:o}})},n.configureTransmuxer=function(e){for(var t=this.config,r=this.observer,s=this.typeSupported,o=this.vendor,l,u=0,d=zt.length;u<d;u++){var f;if((f=zt[u].demux)!=null&&f.probe(e)){l=zt[u];break}}if(!l)return new Error("Failed to find demuxer by probing fragment data");var h=this.demuxer,c=this.remuxer,v=l.remux,g=l.demux;(!c||!(c instanceof v))&&(this.remuxer=new v(r,t,s,o)),(!h||!(h instanceof g))&&(this.demuxer=new g(r,t,s),this.probe=g.probe)},n.needsProbing=function(e,t){return!this.demuxer||!this.remuxer||e||t},n.getDecrypter=function(){var e=this.decrypter;return e||(e=this.decrypter=new Vt(this.config)),e},a}();function Ns(a,n){var i=null;return a.byteLength>0&&n?.key!=null&&n.iv!==null&&n.method!=null&&(i=n),i}var Qt=function(n){return{remuxResult:{},chunkMeta:n}};function He(a){return"then"in a&&a.then instanceof Function}var Bs=function(n,i,e,t,r){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=n,this.videoCodec=i,this.initSegmentData=e,this.duration=t,this.defaultInitPts=r||null},Us=function(n,i,e,t,r,s){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=n,this.contiguous=i,this.accurateTimeOffset=e,this.trackSwitch=t,this.timeOffset=r,this.initSegmentChange=s},wi={exports:{}};(function(a){var n=Object.prototype.hasOwnProperty,i="~";function e(){}Object.create&&(e.prototype=Object.create(null),new e().__proto__||(i=!1));function t(l,u,d){this.fn=l,this.context=u,this.once=d||!1}function r(l,u,d,f,h){if(typeof d!="function")throw new TypeError("The listener must be a function");var c=new t(d,f||l,h),v=i?i+u:u;return l._events[v]?l._events[v].fn?l._events[v]=[l._events[v],c]:l._events[v].push(c):(l._events[v]=c,l._eventsCount++),l}function s(l,u){--l._eventsCount===0?l._events=new e:delete l._events[u]}function o(){this._events=new e,this._eventsCount=0}o.prototype.eventNames=function(){var u=[],d,f;if(this._eventsCount===0)return u;for(f in d=this._events)n.call(d,f)&&u.push(i?f.slice(1):f);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(d)):u},o.prototype.listeners=function(u){var d=i?i+u:u,f=this._events[d];if(!f)return[];if(f.fn)return[f.fn];for(var h=0,c=f.length,v=new Array(c);h<c;h++)v[h]=f[h].fn;return v},o.prototype.listenerCount=function(u){var d=i?i+u:u,f=this._events[d];return f?f.fn?1:f.length:0},o.prototype.emit=function(u,d,f,h,c,v){var g=i?i+u:u;if(!this._events[g])return!1;var m=this._events[g],p=arguments.length,y,E;if(m.fn){switch(m.once&&this.removeListener(u,m.fn,void 0,!0),p){case 1:return m.fn.call(m.context),!0;case 2:return m.fn.call(m.context,d),!0;case 3:return m.fn.call(m.context,d,f),!0;case 4:return m.fn.call(m.context,d,f,h),!0;case 5:return m.fn.call(m.context,d,f,h,c),!0;case 6:return m.fn.call(m.context,d,f,h,c,v),!0}for(E=1,y=new Array(p-1);E<p;E++)y[E-1]=arguments[E];m.fn.apply(m.context,y)}else{var S=m.length,L;for(E=0;E<S;E++)switch(m[E].once&&this.removeListener(u,m[E].fn,void 0,!0),p){case 1:m[E].fn.call(m[E].context);break;case 2:m[E].fn.call(m[E].context,d);break;case 3:m[E].fn.call(m[E].context,d,f);break;case 4:m[E].fn.call(m[E].context,d,f,h);break;default:if(!y)for(L=1,y=new Array(p-1);L<p;L++)y[L-1]=arguments[L];m[E].fn.apply(m[E].context,y)}}return!0},o.prototype.on=function(u,d,f){return r(this,u,d,f,!1)},o.prototype.once=function(u,d,f){return r(this,u,d,f,!0)},o.prototype.removeListener=function(u,d,f,h){var c=i?i+u:u;if(!this._events[c])return this;if(!d)return s(this,c),this;var v=this._events[c];if(v.fn)v.fn===d&&(!h||v.once)&&(!f||v.context===f)&&s(this,c);else{for(var g=0,m=[],p=v.length;g<p;g++)(v[g].fn!==d||h&&!v[g].once||f&&v[g].context!==f)&&m.push(v[g]);m.length?this._events[c]=m.length===1?m[0]:m:s(this,c)}return this},o.prototype.removeAllListeners=function(u){var d;return u?(d=i?i+u:u,this._events[d]&&s(this,d)):(this._events=new e,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=i,o.EventEmitter=o,a.exports=o})(wi);var Gs=wi.exports,Zt=sr(Gs);typeof he<"u"&&he&&Hs(self);function Hs(a){var n=new Zt,i=function(r,s){a.postMessage({event:r,data:s})};n.on(x.FRAG_DECRYPTED,i),n.on(x.ERROR,i);var e=function(){var r=function(l){var u=function(f){i("workerLog",{logType:l,message:f})};R[l]=u};for(var s in R)r(s)};a.addEventListener("message",function(t){var r=t.data;switch(r.cmd){case"init":{var s=JSON.parse(r.config);a.transmuxer=new $t(n,r.typeSupported,s,"",r.id),lr(s.debug,r.id),e(),i("init",null);break}case"configure":{a.transmuxer.configure(r.config);break}case"demux":{var o=a.transmuxer.push(r.data,r.decryptdata,r.chunkMeta,r.state);He(o)?(a.transmuxer.async=!0,o.then(function(f){Jt(a,f)}).catch(function(f){i(x.ERROR,{type:V.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,chunkMeta:r.chunkMeta,fatal:!1,error:f,err:f,reason:"transmuxer-worker push error"})})):(a.transmuxer.async=!1,Jt(a,o));break}case"flush":{var l=r.chunkMeta,u=a.transmuxer.flush(l),d=He(u);d||a.transmuxer.async?(He(u)||(u=Promise.resolve(u)),u.then(function(f){Fi(a,f,l)}).catch(function(f){i(x.ERROR,{type:V.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,chunkMeta:r.chunkMeta,fatal:!1,error:f,err:f,reason:"transmuxer-worker flush error"})})):Fi(a,u,l);break}}})}function Jt(a,n){if(Vs(n.remuxResult))return!1;var i=[],e=n.remuxResult,t=e.audio,r=e.video;return t&&ki(i,t),r&&ki(i,r),a.postMessage({event:"transmuxComplete",data:n},i),!0}function ki(a,n){n.data1&&a.push(n.data1.buffer),n.data2&&a.push(n.data2.buffer)}function Fi(a,n,i){var e=n.reduce(function(t,r){return Jt(a,r)||t},!1);e||a.postMessage({event:"transmuxComplete",data:n[0]}),a.postMessage({event:"flush",data:i})}function Vs(a){return!a.audio&&!a.video&&!a.text&&!a.id3&&!a.initSegment}function Ks(){return typeof ve=="function"}function Ws(){var a=new self.Blob(["var exports={};var module={exports:exports};function define(f){f()};define.amd=true;("+ve.toString()+")(true);"],{type:"text/javascript"}),n=self.URL.createObjectURL(a),i=new self.Worker(n);return{worker:i,objectURL:n}}function Ys(a){var n=new self.URL(a,self.location.href).href,i=new self.Worker(n);return{worker:i,scriptURL:n}}var qs=function(){function a(i,e,t,r){var s=this;this.error=null,this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;var o=i.config;this.hls=i,this.id=e,this.useWorker=!!o.enableWorker,this.onTransmuxComplete=t,this.onFlush=r;var l=function(v,g){g=g||{},g.frag=s.frag,g.id=s.id,v===x.ERROR&&(s.error=g.error),s.hls.trigger(v,g)};this.observer=new Zt,this.observer.on(x.FRAG_DECRYPTED,l),this.observer.on(x.ERROR,l);var u=Ge(o.preferManagedMediaSource)||{isTypeSupported:function(){return!1}},d={mpeg:u.isTypeSupported("audio/mpeg"),mp3:u.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:!1};if(this.useWorker&&typeof Worker<"u"){var f=o.workerPath||Ks();if(f){try{o.workerPath?(R.log("loading Web Worker "+o.workerPath+' for "'+e+'"'),this.workerContext=Ys(o.workerPath)):(R.log('injecting Web Worker for "'+e+'"'),this.workerContext=Ws()),this.onwmsg=function(c){return s.onWorkerMessage(c)};var h=this.workerContext.worker;h.addEventListener("message",this.onwmsg),h.onerror=function(c){var v=new Error(c.message+" ("+c.filename+":"+c.lineno+")");o.enableWorker=!1,R.warn('Error in "'+e+'" Web Worker, fallback to inline'),s.hls.trigger(x.ERROR,{type:V.OTHER_ERROR,details:D.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:v})},h.postMessage({cmd:"init",typeSupported:d,vendor:"",id:e,config:JSON.stringify(o)})}catch(c){R.warn('Error setting up "'+e+'" Web Worker, fallback to inline',c),this.resetWorker(),this.error=null,this.transmuxer=new $t(this.observer,d,o,"",e)}return}}this.transmuxer=new $t(this.observer,d,o,"",e)}var n=a.prototype;return n.resetWorker=function(){if(this.workerContext){var e=this.workerContext,t=e.worker,r=e.objectURL;r&&self.URL.revokeObjectURL(r),t.removeEventListener("message",this.onwmsg),t.onerror=null,t.terminate(),this.workerContext=null}},n.destroy=function(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{var e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}var t=this.observer;t&&t.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},n.push=function(e,t,r,s,o,l,u,d,f,h){var c,v,g=this;f.transmuxing.start=self.performance.now();var m=this.transmuxer,p=l?l.start:o.start,y=o.decryptdata,E=this.frag,S=!(E&&o.cc===E.cc),L=!(E&&f.level===E.level),_=E?f.sn-E.sn:-1,A=this.part?f.part-this.part.index:-1,T=_===0&&f.id>1&&f.id===E?.stats.chunkCount,b=!L&&(_===1||_===0&&(A===1||T&&A<=0)),I=self.performance.now();(L||_||o.stats.parsing.start===0)&&(o.stats.parsing.start=I),l&&(A||!b)&&(l.stats.parsing.start=I);var P=!(E&&((c=o.initSegment)==null?void 0:c.url)===((v=E.initSegment)==null?void 0:v.url)),C=new Us(S,b,d,L,p,P);if(!b||S||P){R.log("[transmuxer-interface, "+o.type+"]: Starting new transmux session for sn: "+f.sn+" p: "+f.part+" level: "+f.level+" id: "+f.id+`
|
9
|
+
discontinuity: `+S+`
|
10
|
+
trackSwitch: `+L+`
|
11
|
+
contiguous: `+b+`
|
12
|
+
accurateTimeOffset: `+d+`
|
13
|
+
timeOffset: `+p+`
|
14
|
+
initSegmentChange: `+P);var w=new Bs(r,s,t,u,h);this.configureTransmuxer(w)}if(this.frag=o,this.part=l,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:y,chunkMeta:f,state:C},e instanceof ArrayBuffer?[e]:[]);else if(m){var O=m.push(e,y,f,C);He(O)?(m.async=!0,O.then(function(F){g.handleTransmuxComplete(F)}).catch(function(F){g.transmuxerError(F,f,"transmuxer-interface push error")})):(m.async=!1,this.handleTransmuxComplete(O))}},n.flush=function(e){var t=this;e.transmuxing.start=self.performance.now();var r=this.transmuxer;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:e});else if(r){var s=r.flush(e),o=He(s);o||r.async?(He(s)||(s=Promise.resolve(s)),s.then(function(l){t.handleFlushResult(l,e)}).catch(function(l){t.transmuxerError(l,e,"transmuxer-interface flush error")})):this.handleFlushResult(s,e)}},n.transmuxerError=function(e,t,r){this.hls&&(this.error=e,this.hls.trigger(x.ERROR,{type:V.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,fatal:!1,error:e,err:e,reason:r}))},n.handleFlushResult=function(e,t){var r=this;e.forEach(function(s){r.handleTransmuxComplete(s)}),this.onFlush(t)},n.onWorkerMessage=function(e){var t=e.data;if(!(t!=null&&t.event)){R.warn("worker message received with no "+(t?"event name":"data"));return}var r=this.hls;if(this.hls)switch(t.event){case"init":{var s,o=(s=this.workerContext)==null?void 0:s.objectURL;o&&self.URL.revokeObjectURL(o);break}case"transmuxComplete":{this.handleTransmuxComplete(t.data);break}case"flush":{this.onFlush(t.data);break}case"workerLog":R[t.data.logType]&&R[t.data.logType](t.data.message);break;default:{t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,r.trigger(t.event,t.data);break}}},n.configureTransmuxer=function(e){var t=this.transmuxer;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:e}):t&&t.configure(e)},n.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},a}(),js=250,yt=2,Xs=.1,zs=.05,$s=function(){function a(i,e,t,r){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=i,this.media=e,this.fragmentTracker=t,this.hls=r}var n=a.prototype;return n.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},n.poll=function(e,t){var r=this.config,s=this.media,o=this.stalled;if(s!==null){var l=s.currentTime,u=s.seeking,d=this.seeking&&!u,f=!this.seeking&&u;if(this.seeking=u,l!==e){if(this.moved=!0,u||(this.nudgeRetry=0),o!==null){if(this.stallReported){var h=self.performance.now()-o;R.warn("playback not stuck anymore @"+l+", after "+Math.round(h)+"ms"),this.stallReported=!1}this.stalled=null}return}if(f||d){this.stalled=null;return}if(s.paused&&!u||s.ended||s.playbackRate===0||!se.getBuffered(s).length){this.nudgeRetry=0;return}var c=se.bufferInfo(s,l,0),v=c.nextStart||0;if(u){var g=c.len>yt,m=!v||t&&t.start<=l||v-l>yt&&!this.fragmentTracker.getPartialFragment(l);if(g||m)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var p,y=c.len>0;if(!y&&!v)return;var E=Math.max(v,c.start||0)-l,S=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,L=S==null||(p=S.details)==null?void 0:p.live,_=L?S.details.targetduration*2:yt,A=this.fragmentTracker.getPartialFragment(l);if(E>0&&(E<=_||A)){s.paused||this._trySkipBufferHole(A);return}}var T=self.performance.now();if(o===null){this.stalled=T;return}var b=T-o;if(!(!u&&b>=js&&(this._reportStall(c),!this.media))){var I=se.bufferInfo(s,l,r.maxBufferHole);this._tryFixBufferStall(I,b)}}},n._tryFixBufferStall=function(e,t){var r=this.config,s=this.fragmentTracker,o=this.media;if(o!==null){var l=o.currentTime,u=s.getPartialFragment(l);if(u){var d=this._trySkipBufferHole(u);if(d||!this.media)return}(e.len>r.maxBufferHole||e.nextStart&&e.nextStart-l<r.maxBufferHole)&&t>r.highBufferWatchdogPeriod*1e3&&(R.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},n._reportStall=function(e){var t=this.hls,r=this.media,s=this.stallReported;if(!s&&r){this.stallReported=!0;var o=new Error("Playback stalling at @"+r.currentTime+" due to low buffer ("+JSON.stringify(e)+")");R.warn(o.message),t.trigger(x.ERROR,{type:V.MEDIA_ERROR,details:D.BUFFER_STALLED_ERROR,fatal:!1,error:o,buffer:e.len})}},n._trySkipBufferHole=function(e){var t=this.config,r=this.hls,s=this.media;if(s===null)return 0;var o=s.currentTime,l=se.bufferInfo(s,o,0),u=o<l.start?l.start:l.nextStart;if(u){var d=l.len<=t.maxBufferHole,f=l.len>0&&l.len<1&&s.readyState<3,h=u-o;if(h>0&&(d||f)){if(h>t.maxBufferHole){var c=this.fragmentTracker,v=!1;if(o===0){var g=c.getAppendedFrag(0,q.MAIN);g&&u<g.end&&(v=!0)}if(!v){var m=e||c.getAppendedFrag(o,q.MAIN);if(m){for(var p=!1,y=m.end;y<u;){var E=c.getPartialFragment(y);if(E)y+=E.duration;else{p=!0;break}}if(p)return 0}}}var S=Math.max(u+zs,o+Xs);if(R.warn("skipping hole, adjusting currentTime from "+o+" to "+S),this.moved=!0,this.stalled=null,s.currentTime=S,e&&!e.gap){var L=new Error("fragment loaded with buffer holes, seeking from "+o+" to "+S);r.trigger(x.ERROR,{type:V.MEDIA_ERROR,details:D.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:L,reason:L.message,frag:e})}return S}}return 0},n._tryNudgeBuffer=function(){var e=this.config,t=this.hls,r=this.media,s=this.nudgeRetry;if(r!==null){var o=r.currentTime;if(this.nudgeRetry++,s<e.nudgeMaxRetry){var l=o+(s+1)*e.nudgeOffset,u=new Error("Nudging 'currentTime' from "+o+" to "+l);R.warn(u.message),r.currentTime=l,t.trigger(x.ERROR,{type:V.MEDIA_ERROR,details:D.BUFFER_NUDGE_ON_STALL,error:u,fatal:!1})}else{var d=new Error("Playhead still not moving while enough data buffered @"+o+" after "+e.nudgeMaxRetry+" nudges");R.error(d.message),t.trigger(x.ERROR,{type:V.MEDIA_ERROR,details:D.BUFFER_STALLED_ERROR,error:d,fatal:!0})}}},a}(),Qs=100,Zs=function(a){_e(n,a);function n(e,t,r){var s;return s=a.call(this,e,t,r,"[stream-controller]",q.MAIN)||this,s.audioCodecSwap=!1,s.gapController=null,s.level=-1,s._forceStartLoad=!1,s.altAudio=!1,s.audioOnly=!1,s.fragPlaying=null,s.onvplaying=null,s.onvseeked=null,s.fragLastKbps=0,s.couldBacktrack=!1,s.backtrackFragment=null,s.audioCodecSwitch=!1,s.videoBuffer=null,s._registerListeners(),s}var i=n.prototype;return i._registerListeners=function(){var t=this.hls;t.on(x.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(x.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(x.MANIFEST_LOADING,this.onManifestLoading,this),t.on(x.MANIFEST_PARSED,this.onManifestParsed,this),t.on(x.LEVEL_LOADING,this.onLevelLoading,this),t.on(x.LEVEL_LOADED,this.onLevelLoaded,this),t.on(x.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.on(x.ERROR,this.onError,this),t.on(x.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(x.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(x.BUFFER_CREATED,this.onBufferCreated,this),t.on(x.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(x.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(x.FRAG_BUFFERED,this.onFragBuffered,this)},i._unregisterListeners=function(){var t=this.hls;t.off(x.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(x.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(x.MANIFEST_LOADING,this.onManifestLoading,this),t.off(x.MANIFEST_PARSED,this.onManifestParsed,this),t.off(x.LEVEL_LOADED,this.onLevelLoaded,this),t.off(x.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.off(x.ERROR,this.onError,this),t.off(x.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(x.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(x.BUFFER_CREATED,this.onBufferCreated,this),t.off(x.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(x.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(x.FRAG_BUFFERED,this.onFragBuffered,this)},i.onHandlerDestroying=function(){this._unregisterListeners(),a.prototype.onHandlerDestroying.call(this)},i.startLoad=function(t){if(this.levels){var r=this.lastCurrentTime,s=this.hls;if(this.stopLoad(),this.setInterval(Qs),this.level=-1,!this.startFragRequested){var o=s.startLevel;o===-1&&(s.config.testBandwidth&&this.levels.length>1?(o=0,this.bitrateTest=!0):o=s.firstAutoLevel),s.nextLoadLevel=o,this.level=s.loadLevel,this.loadedmetadata=!1}r>0&&t===-1&&(this.log("Override startPosition with lastCurrentTime @"+r.toFixed(3)),t=r),this.state=k.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this._forceStartLoad=!0,this.state=k.STOPPED},i.stopLoad=function(){this._forceStartLoad=!1,a.prototype.stopLoad.call(this)},i.doTick=function(){switch(this.state){case k.WAITING_LEVEL:{var t=this.levels,r=this.level,s=t?.[r],o=s?.details;if(o&&(!o.live||this.levelLastLoaded===s)){if(this.waitForCdnTuneIn(o))break;this.state=k.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=k.IDLE;break}break}case k.FRAG_LOADING_WAITING_RETRY:{var l,u=self.performance.now(),d=this.retryDate;if(!d||u>=d||(l=this.media)!=null&&l.seeking){var f=this.levels,h=this.level,c=f?.[h];this.resetStartWhenNotLoaded(c||null),this.state=k.IDLE}}break}this.state===k.IDLE&&this.doTickIdle(),this.onTickEnd()},i.onTickEnd=function(){a.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},i.doTickIdle=function(){var t=this.hls,r=this.levelLastLoaded,s=this.levels,o=this.media;if(!(r===null||!o&&(this.startFragRequested||!t.config.startFragPrefetch))&&!(this.altAudio&&this.audioOnly)){var l=t.nextLoadLevel;if(s!=null&&s[l]){var u=s[l],d=this.getMainFwdBufferInfo();if(d!==null){var f=this.getLevelDetails();if(f&&this._streamEnded(d,f)){var h={};this.altAudio&&(h.type="video"),this.hls.trigger(x.BUFFER_EOS,h),this.state=k.ENDED;return}t.loadLevel!==l&&t.manualLevel===-1&&this.log("Adapting to level "+l+" from level "+this.level),this.level=t.nextLoadLevel=l;var c=u.details;if(!c||this.state===k.WAITING_LEVEL||c.live&&this.levelLastLoaded!==u){this.level=l,this.state=k.WAITING_LEVEL;return}var v=d.len,g=this.getMaxBufferLength(u.maxBitrate);if(!(v>=g)){this.backtrackFragment&&this.backtrackFragment.start>d.end&&(this.backtrackFragment=null);var m=this.backtrackFragment?this.backtrackFragment.start:d.end,p=this.getNextFragment(m,c);if(this.couldBacktrack&&!this.fragPrevious&&p&&p.sn!=="initSegment"&&this.fragmentTracker.getState(p)!==ye.OK){var y,E=((y=this.backtrackFragment)!=null?y:p).sn,S=E-c.startSN,L=c.fragments[S-1];L&&p.cc===L.cc&&(p=L,this.fragmentTracker.removeFragment(L))}else this.backtrackFragment&&d.len&&(this.backtrackFragment=null);if(p&&this.isLoopLoading(p,m)){var _=p.gap;if(!_){var A=this.audioOnly&&!this.altAudio?$.AUDIO:$.VIDEO,T=(A===$.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;T&&this.afterBufferFlushed(T,A,q.MAIN)}p=this.getNextFragmentLoopLoading(p,c,d,q.MAIN,g)}p&&(p.initSegment&&!p.initSegment.data&&!this.bitrateTest&&(p=p.initSegment),this.loadFragment(p,u,m))}}}}},i.loadFragment=function(t,r,s){var o=this.fragmentTracker.getState(t);this.fragCurrent=t,o===ye.NOT_LOADED||o===ye.PARTIAL?t.sn==="initSegment"?this._loadInitSegment(t,r):this.bitrateTest?(this.log("Fragment "+t.sn+" of level "+t.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(t,r)):(this.startFragRequested=!0,a.prototype.loadFragment.call(this,t,r,s)):this.clearTrackerIfNeeded(t)},i.getBufferedFrag=function(t){return this.fragmentTracker.getBufferedFrag(t,q.MAIN)},i.followingBufferedFrag=function(t){return t?this.getBufferedFrag(t.end+.5):null},i.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},i.nextLevelSwitch=function(){var t=this.levels,r=this.media;if(r!=null&&r.readyState){var s,o=this.getAppendedFrag(r.currentTime);o&&o.start>1&&this.flushMainBuffer(0,o.start-1);var l=this.getLevelDetails();if(l!=null&&l.live){var u=this.getMainFwdBufferInfo();if(!u||u.len<l.targetduration*2)return}if(!r.paused&&t){var d=this.hls.nextLoadLevel,f=t[d],h=this.fragLastKbps;h&&this.fragCurrent?s=this.fragCurrent.duration*f.maxBitrate/(1e3*h)+1:s=0}else s=0;var c=this.getBufferedFrag(r.currentTime+s);if(c){var v=this.followingBufferedFrag(c);if(v){this.abortCurrentFrag();var g=v.maxStartPTS?v.maxStartPTS:v.start,m=v.duration,p=Math.max(c.end,g+Math.min(Math.max(m-this.config.maxFragLookUpTolerance,m*(this.couldBacktrack?.5:.125)),m*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(p,Number.POSITIVE_INFINITY)}}}},i.abortCurrentFrag=function(){var t=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,t&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.state){case k.KEY_LOADING:case k.FRAG_LOADING:case k.FRAG_LOADING_WAITING_RETRY:case k.PARSING:case k.PARSED:this.state=k.IDLE;break}this.nextLoadPosition=this.getLoadPosition()},i.flushMainBuffer=function(t,r){a.prototype.flushMainBuffer.call(this,t,r,this.altAudio?"video":null)},i.onMediaAttached=function(t,r){a.prototype.onMediaAttached.call(this,t,r);var s=r.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),s.addEventListener("playing",this.onvplaying),s.addEventListener("seeked",this.onvseeked),this.gapController=new $s(this.config,s,this.fragmentTracker,this.hls)},i.onMediaDetaching=function(){var t=this.media;t&&this.onvplaying&&this.onvseeked&&(t.removeEventListener("playing",this.onvplaying),t.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),a.prototype.onMediaDetaching.call(this)},i.onMediaPlaying=function(){this.tick()},i.onMediaSeeked=function(){var t=this.media,r=t?t.currentTime:null;M(r)&&this.log("Media seeked to "+r.toFixed(3));var s=this.getMainFwdBufferInfo();if(s===null||s.len===0){this.warn('Main forward buffer length on "seeked" event '+(s?s.len:"empty")+")");return}this.tick()},i.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(x.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=this.fragLastKbps=0,this.levels=this.fragPlaying=this.backtrackFragment=this.levelLastLoaded=null,this.altAudio=this.audioOnly=this.startFragRequested=!1},i.onManifestParsed=function(t,r){var s=!1,o=!1;r.levels.forEach(function(l){var u=l.audioCodec;u&&(s=s||u.indexOf("mp4a.40.2")!==-1,o=o||u.indexOf("mp4a.40.5")!==-1)}),this.audioCodecSwitch=s&&o&&!ss(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=r.levels,this.startFragRequested=!1},i.onLevelLoading=function(t,r){var s=this.levels;if(!(!s||this.state!==k.IDLE)){var o=s[r.level];(!o.details||o.details.live&&this.levelLastLoaded!==o||this.waitForCdnTuneIn(o.details))&&(this.state=k.WAITING_LEVEL)}},i.onLevelLoaded=function(t,r){var s,o=this.levels,l=r.level,u=r.details,d=u.totalduration;if(!o){this.warn("Levels were reset while loading level "+l);return}this.log("Level "+l+" loaded ["+u.startSN+","+u.endSN+"]"+(u.lastPartSn?"[part-"+u.lastPartSn+"-"+u.lastPartIndex+"]":"")+", cc ["+u.startCC+", "+u.endCC+"] duration:"+d);var f=o[l],h=this.fragCurrent;h&&(this.state===k.FRAG_LOADING||this.state===k.FRAG_LOADING_WAITING_RETRY)&&h.level!==r.level&&h.loader&&this.abortCurrentFrag();var c=0;if(u.live||(s=f.details)!=null&&s.live){var v;if(this.checkLiveUpdate(u),u.deltaUpdateFailed)return;c=this.alignPlaylists(u,f.details,(v=this.levelLastLoaded)==null?void 0:v.details)}if(f.details=u,this.levelLastLoaded=f,this.hls.trigger(x.LEVEL_UPDATED,{details:u,level:l}),this.state===k.WAITING_LEVEL){if(this.waitForCdnTuneIn(u))return;this.state=k.IDLE}this.startFragRequested?u.live&&this.synchronizeToLiveEdge(u):this.setStartPosition(u,c),this.tick()},i._handleFragmentLoadProgress=function(t){var r,s=t.frag,o=t.part,l=t.payload,u=this.levels;if(!u){this.warn("Levels were reset while fragment load was in progress. Fragment "+s.sn+" of level "+s.level+" will not be buffered");return}var d=u[s.level],f=d.details;if(!f){this.warn("Dropping fragment "+s.sn+" of level "+s.level+" after level details were reset"),this.fragmentTracker.removeFragment(s);return}var h=d.videoCodec,c=f.PTSKnown||!f.live,v=(r=s.initSegment)==null?void 0:r.data,g=this._getAudioCodec(d),m=this.transmuxer=this.transmuxer||new qs(this.hls,q.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),p=o?o.index:-1,y=p!==-1,E=new ui(s.level,s.sn,s.stats.chunkCount,l.byteLength,p,y),S=this.initPTS[s.cc];m.push(l,v,g,h,s,o,f.totalduration,c,E,S)},i.onAudioTrackSwitching=function(t,r){var s=this.altAudio,o=!!r.url;if(!o){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var l=this.fragCurrent;l&&(this.log("Switching to main audio track, cancel main fragment load"),l.abortRequests(),this.fragmentTracker.removeFragment(l)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var u=this.hls;s&&(u.trigger(x.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),u.trigger(x.AUDIO_TRACK_SWITCHED,r)}},i.onAudioTrackSwitched=function(t,r){var s=r.id,o=!!this.hls.audioTracks[s].url;if(o){var l=this.videoBuffer;l&&this.mediaBuffer!==l&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=l)}this.altAudio=o,this.tick()},i.onBufferCreated=function(t,r){var s=r.tracks,o,l,u=!1;for(var d in s){var f=s[d];if(f.id==="main"){if(l=d,o=f,d==="video"){var h=s[d];h&&(this.videoBuffer=h.buffer)}}else u=!0}u&&o?(this.log("Alternate track found, use "+l+".buffered to schedule main fragment loading"),this.mediaBuffer=o.buffer):this.mediaBuffer=this.media},i.onFragBuffered=function(t,r){var s=r.frag,o=r.part;if(!(s&&s.type!==q.MAIN)){if(this.fragContextChanged(s)){this.warn("Fragment "+s.sn+(o?" p: "+o.index:"")+" of level "+s.level+" finished buffering, but was aborted. state: "+this.state),this.state===k.PARSED&&(this.state=k.IDLE);return}var l=o?o.stats:s.stats;this.fragLastKbps=Math.round(8*l.total/(l.buffering.end-l.loading.first)),s.sn!=="initSegment"&&(this.fragPrevious=s),this.fragBufferedComplete(s,o)}},i.onError=function(t,r){var s;if(r.fatal){this.state=k.ERROR;return}switch(r.details){case D.FRAG_GAP:case D.FRAG_PARSING_ERROR:case D.FRAG_DECRYPT_ERROR:case D.FRAG_LOAD_ERROR:case D.FRAG_LOAD_TIMEOUT:case D.KEY_LOAD_ERROR:case D.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(q.MAIN,r);break;case D.LEVEL_LOAD_ERROR:case D.LEVEL_LOAD_TIMEOUT:case D.LEVEL_PARSING_ERROR:!r.levelRetry&&this.state===k.WAITING_LEVEL&&((s=r.context)==null?void 0:s.type)===Y.LEVEL&&(this.state=k.IDLE);break;case D.BUFFER_APPEND_ERROR:case D.BUFFER_FULL_ERROR:if(!r.parent||r.parent!=="main")return;if(r.details===D.BUFFER_APPEND_ERROR){this.resetLoadingState();return}this.reduceLengthAndFlushBuffer(r)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case D.INTERNAL_EXCEPTION:this.recoverWorkerError(r);break}},i.checkBuffer=function(){var t=this.media,r=this.gapController;if(!(!t||!r||!t.readyState)){if(this.loadedmetadata||!se.getBuffered(t).length){var s=this.state!==k.IDLE?this.fragCurrent:null;r.poll(this.lastCurrentTime,s)}this.lastCurrentTime=t.currentTime}},i.onFragLoadEmergencyAborted=function(){this.state=k.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},i.onBufferFlushed=function(t,r){var s=r.type;if(s!==$.AUDIO||this.audioOnly&&!this.altAudio){var o=(s===$.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(o,s,q.MAIN),this.tick()}},i.onLevelsUpdated=function(t,r){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level),this.levels=r.levels},i.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},i.seekToStartPos=function(){var t=this.media;if(t){var r=t.currentTime,s=this.startPosition;if(s>=0&&r<s){if(t.seeking){this.log("could not seek to "+s+", already seeking at "+r);return}var o=se.getBuffered(t),l=o.length?o.start(0):0,u=l-s;u>0&&(u<this.config.maxBufferHole||u<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+u+" to match buffer start"),s+=u,this.startPosition=s),this.log("seek to target start position "+s+" from current time "+r),t.currentTime=s}}},i._getAudioCodec=function(t){var r=this.config.defaultAudioCodec||t.audioCodec;return this.audioCodecSwap&&r&&(this.log("Swapping audio codec"),r.indexOf("mp4a.40.5")!==-1?r="mp4a.40.2":r="mp4a.40.5"),r},i._loadBitrateTestFrag=function(t,r){var s=this;t.bitrateTest=!0,this._doFragLoad(t,r).then(function(o){var l=s.hls;if(!(!o||s.fragContextChanged(t))){r.fragmentError=0,s.state=k.IDLE,s.startFragRequested=!1,s.bitrateTest=!1;var u=t.stats;u.parsing.start=u.parsing.end=u.buffering.start=u.buffering.end=self.performance.now(),l.trigger(x.FRAG_LOADED,o),t.bitrateTest=!1}})},i._handleTransmuxComplete=function(t){var r,s="main",o=this.hls,l=t.remuxResult,u=t.chunkMeta,d=this.getCurrentContext(u);if(!d){this.resetWhenMissingContext(u);return}var f=d.frag,h=d.part,c=d.level,v=l.video,g=l.text,m=l.id3,p=l.initSegment,y=c.details,E=this.altAudio?void 0:l.audio;if(this.fragContextChanged(f)){this.fragmentTracker.removeFragment(f);return}if(this.state=k.PARSING,p){if(p!=null&&p.tracks){var S=f.initSegment||f;this._bufferInitSegment(c,p.tracks,S,u),o.trigger(x.FRAG_PARSING_INIT_SEGMENT,{frag:S,id:s,tracks:p.tracks})}var L=p.initPTS,_=p.timescale;M(L)&&(this.initPTS[f.cc]={baseTime:L,timescale:_},o.trigger(x.INIT_PTS_FOUND,{frag:f,id:s,initPTS:L,timescale:_}))}if(v&&y&&f.sn!=="initSegment"){var A=y.fragments[f.sn-1-y.startSN],T=f.sn===y.startSN,b=!A||f.cc>A.cc;if(l.independent!==!1){var I=v.startPTS,P=v.endPTS,C=v.startDTS,w=v.endDTS;if(h)h.elementaryStreams[v.type]={startPTS:I,endPTS:P,startDTS:C,endDTS:w};else if(v.firstKeyFrame&&v.independent&&u.id===1&&!b&&(this.couldBacktrack=!0),v.dropped&&v.independent){var O=this.getMainFwdBufferInfo(),F=(O?O.end:this.getLoadPosition())+this.config.maxBufferHole,H=v.firstKeyFramePTS?v.firstKeyFramePTS:I;if(!T&&F<H-this.config.maxBufferHole&&!b){this.backtrack(f);return}else b&&(f.gap=!0);f.setElementaryStreamInfo(v.type,f.start,P,f.start,w,!0)}else T&&I>yt&&(f.gap=!0);f.setElementaryStreamInfo(v.type,I,P,C,w),this.backtrackFragment&&(this.backtrackFragment=f),this.bufferFragmentData(v,f,h,u,T||b)}else if(T||b)f.gap=!0;else{this.backtrack(f);return}}if(E){var U=E.startPTS,W=E.endPTS,K=E.startDTS,B=E.endDTS;h&&(h.elementaryStreams[$.AUDIO]={startPTS:U,endPTS:W,startDTS:K,endDTS:B}),f.setElementaryStreamInfo($.AUDIO,U,W,K,B),this.bufferFragmentData(E,f,h,u)}if(y&&m!=null&&(r=m.samples)!=null&&r.length){var Q={id:s,frag:f,details:y,samples:m.samples};o.trigger(x.FRAG_PARSING_METADATA,Q)}if(y&&g){var j={id:s,frag:f,details:y,samples:g.samples};o.trigger(x.FRAG_PARSING_USERDATA,j)}},i._bufferInitSegment=function(t,r,s,o){var l=this;if(this.state===k.PARSING){this.audioOnly=!!r.audio&&!r.video,this.altAudio&&!this.audioOnly&&delete r.audio;var u=r.audio,d=r.video,f=r.audiovideo;if(u){var h=t.audioCodec,c=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){h&&(h.indexOf("mp4a.40.5")!==-1?h="mp4a.40.2":h="mp4a.40.5");var v=u.metadata;v&&"channelCount"in v&&(v.channelCount||1)!==1&&c.indexOf("firefox")===-1&&(h="mp4a.40.5")}h&&h.indexOf("mp4a.40.5")!==-1&&c.indexOf("android")!==-1&&u.container!=="audio/mpeg"&&(h="mp4a.40.2",this.log("Android: force audio codec to "+h)),t.audioCodec&&t.audioCodec!==h&&this.log('Swapping manifest audio codec "'+t.audioCodec+'" for "'+h+'"'),u.levelCodec=h,u.id="main",this.log("Init audio buffer, container:"+u.container+", codecs[selected/level/parsed]=["+(h||"")+"/"+(t.audioCodec||"")+"/"+u.codec+"]")}d&&(d.levelCodec=t.videoCodec,d.id="main",this.log("Init video buffer, container:"+d.container+", codecs[level/parsed]=["+(t.videoCodec||"")+"/"+d.codec+"]")),f&&this.log("Init audiovideo buffer, container:"+f.container+", codecs[level/parsed]=["+t.codecs+"/"+f.codec+"]"),this.hls.trigger(x.BUFFER_CODECS,r),Object.keys(r).forEach(function(g){var m=r[g],p=m.initSegment;p!=null&&p.byteLength&&l.hls.trigger(x.BUFFER_APPENDING,{type:g,data:p,frag:s,part:null,chunkMeta:o,parent:s.type})}),this.tickImmediate()}},i.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,q.MAIN)},i.backtrack=function(t){this.couldBacktrack=!0,this.backtrackFragment=t,this.resetTransmuxer(),this.flushBufferGap(t),this.fragmentTracker.removeFragment(t),this.fragPrevious=null,this.nextLoadPosition=t.start,this.state=k.IDLE},i.checkFragmentChanged=function(){var t=this.media,r=null;if(t&&t.readyState>1&&t.seeking===!1){var s=t.currentTime;if(se.isBuffered(t,s)?r=this.getAppendedFrag(s):se.isBuffered(t,s+.1)&&(r=this.getAppendedFrag(s+.1)),r){this.backtrackFragment=null;var o=this.fragPlaying,l=r.level;(!o||r.sn!==o.sn||o.level!==l)&&(this.fragPlaying=r,this.hls.trigger(x.FRAG_CHANGED,{frag:r}),(!o||o.level!==l)&&this.hls.trigger(x.LEVEL_SWITCHED,{level:l}))}}},ge(n,[{key:"nextLevel",get:function(){var t=this.nextBufferedFrag;return t?t.level:-1}},{key:"currentFrag",get:function(){var t=this.media;return t?this.fragPlaying||this.getAppendedFrag(t.currentTime):null}},{key:"currentProgramDateTime",get:function(){var t=this.media;if(t){var r=t.currentTime,s=this.currentFrag;if(s&&M(r)&&M(s.programDateTime)){var o=s.programDateTime+(r-s.start)*1e3;return new Date(o)}}return null}},{key:"currentLevel",get:function(){var t=this.currentFrag;return t?t.level:-1}},{key:"nextBufferedFrag",get:function(){var t=this.currentFrag;return t?this.followingBufferedFrag(t):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),n}(ns),Mi=function(){a.isMSESupported=function(){return ci()},a.isSupported=function(){return as()},a.getMediaSource=function(){return Ge()};function a(i){i===void 0&&(i={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this.started=!1,this._emitter=new Zt,this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null,this.triggeringException=void 0,lr(i.debug||!1,"Hls instance");var e=this.config=Ga(a.DefaultConfig,i);this.userConfig=i,e.progressive&&Ha(e);var t=e.abrController,r=e.bufferController,s=e.capLevelController,o=e.errorController,l=e.fpsController,u=new o(this),d=this.abrController=new t(this),f=this.bufferController=new r(this),h=this.capLevelController=new s(this),c=new l(this),v=new Hn(this),g=new zn(this),m=e.contentSteeringController,p=m?new m(this):null,y=this.levelController=new Va(this,p),E=new Ka(this),S=new Ya(this.config),L=this.streamController=new Zs(this,E,S);h.setStreamController(L),c.setStreamController(L);var _=[v,y,L];p&&_.splice(1,0,p),this.networkControllers=_;var A=[d,f,h,c,g,E];this.audioTrackController=this.createController(e.audioTrackController,_);var T=e.audioStreamController;T&&_.push(new T(this,E,S)),this.subtitleTrackController=this.createController(e.subtitleTrackController,_);var b=e.subtitleStreamController;b&&_.push(new b(this,E,S)),this.createController(e.timelineController,A),S.emeController=this.emeController=this.createController(e.emeController,A),this.cmcdController=this.createController(e.cmcdController,A),this.latencyController=this.createController($n,A),this.coreComponents=A,_.push(u);var I=u.onErrorOut;typeof I=="function"&&this.on(x.ERROR,I,u)}var n=a.prototype;return n.createController=function(e,t){if(e){var r=new e(this);return t&&t.push(r),r}return null},n.on=function(e,t,r){r===void 0&&(r=this),this._emitter.on(e,t,r)},n.once=function(e,t,r){r===void 0&&(r=this),this._emitter.once(e,t,r)},n.removeAllListeners=function(e){this._emitter.removeAllListeners(e)},n.off=function(e,t,r,s){r===void 0&&(r=this),this._emitter.off(e,t,r,s)},n.listeners=function(e){return this._emitter.listeners(e)},n.emit=function(e,t,r){return this._emitter.emit(e,t,r)},n.trigger=function(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(s){if(R.error("An internal error happened while handling event "+e+'. Error message: "'+s.message+'". Here is a stacktrace:',s),!this.triggeringException){this.triggeringException=!0;var r=e===x.ERROR;this.trigger(x.ERROR,{type:V.OTHER_ERROR,details:D.INTERNAL_EXCEPTION,fatal:r,event:e,error:s}),this.triggeringException=!1}}return!1},n.listenerCount=function(e){return this._emitter.listenerCount(e)},n.destroy=function(){R.log("destroy"),this.trigger(x.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 e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null},n.attachMedia=function(e){R.log("attachMedia"),this._media=e,this.trigger(x.MEDIA_ATTACHING,{media:e})},n.detachMedia=function(){R.log("detachMedia"),this.trigger(x.MEDIA_DETACHING,void 0),this._media=null},n.loadSource=function(e){this.stopLoad();var t=this.media,r=this.url,s=this.url=Lt.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,R.log("loadSource:"+s),t&&r&&(r!==s||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(x.MANIFEST_LOADING,{url:e})},n.startLoad=function(e){e===void 0&&(e=-1),R.log("startLoad("+e+")"),this.started=!0,this.networkControllers.forEach(function(t){t.startLoad(e)})},n.stopLoad=function(){R.log("stopLoad"),this.started=!1,this.networkControllers.forEach(function(e){e.stopLoad()})},n.resumeBuffering=function(){this.started&&this.networkControllers.forEach(function(e){"fragmentLoader"in e&&e.startLoad(-1)})},n.pauseBuffering=function(){this.networkControllers.forEach(function(e){"fragmentLoader"in e&&e.stopLoad()})},n.swapAudioCodec=function(){R.log("swapAudioCodec"),this.streamController.swapAudioCodec()},n.recoverMediaError=function(){R.log("recoverMediaError");var e=this._media;this.detachMedia(),e&&this.attachMedia(e)},n.removeLevel=function(e){this.levelController.removeLevel(e)},n.setAudioOption=function(e){var t;return(t=this.audioTrackController)==null?void 0:t.setAudioOption(e)},n.setSubtitleOption=function(e){var t;return(t=this.subtitleTrackController)==null||t.setSubtitleOption(e),null},ge(a,[{key:"levels",get:function(){var e=this.levelController.levels;return e||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(e){R.log("set currentLevel:"+e),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(e){R.log("set nextLevel:"+e),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(e){R.log("set loadLevel:"+e),this.levelController.manualLevel=e}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(e){this.levelController.nextLoadLevel=e}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(e){R.log("set firstLevel:"+e),this.levelController.firstLevel=e}},{key:"startLevel",get:function(){var e=this.levelController.startLevel;return e===-1&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e},set:function(e){R.log("set startLevel:"+e),e!==-1&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(e){var t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(e){this._autoLevelCapping!==e&&(R.log("set autoLevelCapping:"+e),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}},{key:"bandwidthEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimate():NaN},set:function(e){this.abrController.resetEstimator(e)}},{key:"ttfbEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimateTTFB():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(e){Qn(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var e=this.levels,t=this.config.minAutoBitrate;if(!e)return 0;for(var r=e.length,s=0;s<r;s++)if(e[s].maxBitrate>=t)return s;return 0}},{key:"maxAutoLevel",get:function(){var e=this.levels,t=this.autoLevelCapping,r=this.maxHdcpLevel,s;if(t===-1&&e!=null&&e.length?s=e.length-1:s=t,r)for(var o=s;o--;){var l=e[o].attrs["HDCP-LEVEL"];if(l&&l<=r)return o}return s}},{key:"firstAutoLevel",get:function(){return this.abrController.firstAutoLevel}},{key:"nextAutoLevel",get:function(){return this.abrController.nextAutoLevel},set:function(e){this.abrController.nextAutoLevel=e}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"allAudioTracks",get:function(){var e=this.audioTrackController;return e?e.allAudioTracks:[]}},{key:"audioTracks",get:function(){var e=this.audioTrackController;return e?e.audioTracks:[]}},{key:"audioTrack",get:function(){var e=this.audioTrackController;return e?e.audioTrack:-1},set:function(e){var t=this.audioTrackController;t&&(t.audioTrack=e)}},{key:"allSubtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}},{key:"subtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTrack:-1},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var e=this.subtitleTrackController;return e?e.subtitleDisplay:!1},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(e){this.config.lowLatencyMode=e}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}],[{key:"version",get:function(){return"1.5.17"}},{key:"Events",get:function(){return x}},{key:"ErrorTypes",get:function(){return V}},{key:"ErrorDetails",get:function(){return D}},{key:"DefaultConfig",get:function(){return a.defaultConfig?a.defaultConfig:ni},set:function(e){a.defaultConfig=e}}]),a}();return Mi.defaultConfig=void 0,Mi})})(!1)});var yo=po(Wi(),1);var export_Hls=yo.default;export{export_Hls as Hls};
|