12 |
- (globalThis.webpackChunksakurairo_scripts=globalThis.webpackChunksakurairo_scripts||[]).push([[9372],{9372:t=>{!function e(r){t.exports=function(){function t(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,i)}return r}function i(e){for(var r=1;r<arguments.length;r++){var i=null!=arguments[r]?arguments[r]:{};r%2?t(Object(i),!0).forEach((function(t){s(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):t(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function a(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,p(i.key),i)}}function n(t,e,r){return e&&a(t.prototype,e),r&&a(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function s(t,e,r){return(e=p(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function o(){return o=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t},o.apply(this,arguments)}function l(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,d(t,e)}function u(t){return u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},u(t)}function d(t,e){return d=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},d(t,e)}function h(){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(t){return!1}}function f(t,e,r){return f=h()?Reflect.construct.bind():function(t,e,r){var i=[null];i.push.apply(i,e);var a=new(Function.bind.apply(t,i));return r&&d(a,r.prototype),a},f.apply(null,arguments)}function c(t){return-1!==Function.toString.call(t).indexOf("[native code]")}function v(t){var e="function"==typeof Map?new Map:void 0;return v=function(t){if(null===t||!c(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return f(t,arguments,u(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),d(r,t)},v(t)}function g(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function m(t,e){if("object"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var i=r.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}function p(t){var e=m(t,"string");return"symbol"==typeof e?e:String(e)}function y(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var E={exports:{}};!function(t,e){var r,i,a,n,s;r=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,i=/^(?=([^\/?#]*))\1([^]*)$/,a=/(?:\/|^)\.(?=\/)/g,n=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,s={buildAbsoluteURL:function(t,e,r){if(r=r||{},t=t.trim(),!(e=e.trim())){if(!r.alwaysNormalize)return t;var a=s.parseURL(t);if(!a)throw new Error("Error trying to parse base URL.");return a.path=s.normalizePath(a.path),s.buildURLFromParts(a)}var n=s.parseURL(e);if(!n)throw new Error("Error trying to parse relative URL.");if(n.scheme)return r.alwaysNormalize?(n.path=s.normalizePath(n.path),s.buildURLFromParts(n)):e;var o=s.parseURL(t);if(!o)throw new Error("Error trying to parse base URL.");if(!o.netLoc&&o.path&&"/"!==o.path[0]){var l=i.exec(o.path);o.netLoc=l[1],o.path=l[2]}o.netLoc&&!o.path&&(o.path="/");var u={scheme:o.scheme,netLoc:n.netLoc,path:null,params:n.params,query:n.query,fragment:n.fragment};if(!n.netLoc&&(u.netLoc=o.netLoc,"/"!==n.path[0]))if(n.path){var d=o.path,h=d.substring(0,d.lastIndexOf("/")+1)+n.path;u.path=s.normalizePath(h)}else u.path=o.path,n.params||(u.params=o.params,n.query||(u.query=o.query));return null===u.path&&(u.path=r.alwaysNormalize?s.normalizePath(n.path):n.path),s.buildURLFromParts(u)},parseURL:function(t){var e=r.exec(t);return e?{scheme:e[1]||"",netLoc:e[2]||"",path:e[3]||"",params:e[4]||"",query:e[5]||"",fragment:e[6]||""}:null},normalizePath:function(t){for(t=t.split("").reverse().join("").replace(a,"");t.length!==(t=t.replace(n,"")).length;);return t.split("").reverse().join("")},buildURLFromParts:function(t){return t.scheme+t.netLoc+t.path+t.params+t.query+t.fragment}},t.exports=s}(E);var T=E.exports,L=Number.isFinite||function(t){return"number"==typeof t&&isFinite(t)},S=function(t){return t.MEDIA_ATTACHING="hlsMediaAttaching",t.MEDIA_ATTACHED="hlsMediaAttached",t.MEDIA_DETACHING="hlsMediaDetaching",t.MEDIA_DETACHED="hlsMediaDetached",t.BUFFER_RESET="hlsBufferReset",t.BUFFER_CODECS="hlsBufferCodecs",t.BUFFER_CREATED="hlsBufferCreated",t.BUFFER_APPENDING="hlsBufferAppending",t.BUFFER_APPENDED="hlsBufferAppended",t.BUFFER_EOS="hlsBufferEos",t.BUFFER_FLUSHING="hlsBufferFlushing",t.BUFFER_FLUSHED="hlsBufferFlushed",t.MANIFEST_LOADING="hlsManifestLoading",t.MANIFEST_LOADED="hlsManifestLoaded",t.MANIFEST_PARSED="hlsManifestParsed",t.LEVEL_SWITCHING="hlsLevelSwitching",t.LEVEL_SWITCHED="hlsLevelSwitched",t.LEVEL_LOADING="hlsLevelLoading",t.LEVEL_LOADED="hlsLevelLoaded",t.LEVEL_UPDATED="hlsLevelUpdated",t.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",t.LEVELS_UPDATED="hlsLevelsUpdated",t.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",t.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",t.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",t.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",t.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",t.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",t.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",t.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",t.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",t.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",t.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",t.CUES_PARSED="hlsCuesParsed",t.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",t.INIT_PTS_FOUND="hlsInitPtsFound",t.FRAG_LOADING="hlsFragLoading",t.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",t.FRAG_LOADED="hlsFragLoaded",t.FRAG_DECRYPTED="hlsFragDecrypted",t.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",t.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",t.FRAG_PARSING_METADATA="hlsFragParsingMetadata",t.FRAG_PARSED="hlsFragParsed",t.FRAG_BUFFERED="hlsFragBuffered",t.FRAG_CHANGED="hlsFragChanged",t.FPS_DROP="hlsFpsDrop",t.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",t.ERROR="hlsError",t.DESTROYING="hlsDestroying",t.KEY_LOADING="hlsKeyLoading",t.KEY_LOADED="hlsKeyLoaded",t.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",t.BACK_BUFFER_REACHED="hlsBackBufferReached",t}({}),A=function(t){return t.NETWORK_ERROR="networkError",t.MEDIA_ERROR="mediaError",t.KEY_SYSTEM_ERROR="keySystemError",t.MUX_ERROR="muxError",t.OTHER_ERROR="otherError",t}({}),R=function(t){return t.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",t.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",t.KEY_SYSTEM_NO_SESSION="keySystemNoSession",t.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",t.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",t.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",t.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",t.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",t.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",t.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",t.MANIFEST_LOAD_ERROR="manifestLoadError",t.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",t.MANIFEST_PARSING_ERROR="manifestParsingError",t.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",t.LEVEL_EMPTY_ERROR="levelEmptyError",t.LEVEL_LOAD_ERROR="levelLoadError",t.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",t.LEVEL_PARSING_ERROR="levelParsingError",t.LEVEL_SWITCH_ERROR="levelSwitchError",t.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",t.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",t.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",t.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",t.FRAG_LOAD_ERROR="fragLoadError",t.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",t.FRAG_DECRYPT_ERROR="fragDecryptError",t.FRAG_PARSING_ERROR="fragParsingError",t.FRAG_GAP="fragGap",t.REMUX_ALLOC_ERROR="remuxAllocError",t.KEY_LOAD_ERROR="keyLoadError",t.KEY_LOAD_TIMEOUT="keyLoadTimeOut",t.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",t.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",t.BUFFER_APPEND_ERROR="bufferAppendError",t.BUFFER_APPENDING_ERROR="bufferAppendingError",t.BUFFER_STALLED_ERROR="bufferStalledError",t.BUFFER_FULL_ERROR="bufferFullError",t.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",t.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",t.INTERNAL_EXCEPTION="internalException",t.INTERNAL_ABORTED="aborted",t.UNKNOWN="unknown",t}({}),b=function(){},D={trace:b,debug:b,log:b,warn:b,info:b,error:b},k=D;function I(t){var e=self.console[t];return e?e.bind(self.console,"["+t+"] >"):b}function _(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),i=1;i<e;i++)r[i-1]=arguments[i];r.forEach((function(e){k[e]=t[e]?t[e].bind(t):I(e)}))}function x(t,e){if(self.console&&!0===t||"object"==typeof t){_(t,"debug","log","info","warn","error");try{k.log('Debug logs enabled for "'+e+'" in hls.js version 1.4.12')}catch(t){k=D}}else k=D}var w=k,C=/^(\d+)x(\d+)$/,P=/(.+?)=(".*?"|.*?)(?:,|$)/g,O=function(){function t(e){for(var r in"string"==typeof e&&(e=t.parseAttrList(e)),e)e.hasOwnProperty(r)&&("X-"===r.substring(0,2)&&(this.clientAttrs=this.clientAttrs||[],this.clientAttrs.push(r)),this[r]=e[r])}var e=t.prototype;return e.decimalInteger=function(t){var e=parseInt(this[t],10);return e>Number.MAX_SAFE_INTEGER?1/0:e},e.hexadecimalInteger=function(t){if(this[t]){var e=(this[t]||"0x").slice(2);e=(1&e.length?"0":"")+e;for(var r=new Uint8Array(e.length/2),i=0;i<e.length/2;i++)r[i]=parseInt(e.slice(2*i,2*i+2),16);return r}return null},e.hexadecimalIntegerAsNumber=function(t){var e=parseInt(this[t],16);return e>Number.MAX_SAFE_INTEGER?1/0:e},e.decimalFloatingPoint=function(t){return parseFloat(this[t])},e.optionalFloat=function(t,e){var r=this[t];return r?parseFloat(r):e},e.enumeratedString=function(t){return this[t]},e.bool=function(t){return"YES"===this[t]},e.decimalResolution=function(t){var e=C.exec(this[t]);if(null!==e)return{width:parseInt(e[1],10),height:parseInt(e[2],10)}},t.parseAttrList=function(t){var e,r={},i='"';for(P.lastIndex=0;null!==(e=P.exec(t));){var a=e[2];0===a.indexOf(i)&&a.lastIndexOf(i)===a.length-1&&(a=a.slice(1,-1)),r[e[1].trim()]=a}return r},t}();function F(t){return"ID"!==t&&"CLASS"!==t&&"START-DATE"!==t&&"DURATION"!==t&&"END-DATE"!==t&&"END-ON-NEXT"!==t}function M(t){return"SCTE35-OUT"===t||"SCTE35-IN"===t}var N=function(){function t(t,e){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,e){var r=e.attr;for(var i in r)if(Object.prototype.hasOwnProperty.call(t,i)&&t[i]!==r[i]){w.warn('DATERANGE tag attribute: "'+i+'" does not match for tags with ID: "'+t.ID+'"'),this._badValueForSameId=i;break}t=o(new O({}),r,t)}if(this.attr=t,this._startDate=new Date(t["START-DATE"]),"END-DATE"in this.attr){var a=new Date(this.attr["END-DATE"]);L(a.getTime())&&(this._endDate=a)}}return n(t,[{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 t=this.duration;return null!==t?new Date(this._startDate.getTime()+1e3*t):null}},{key:"duration",get:function(){if("DURATION"in this.attr){var t=this.attr.decimalFloatingPoint("DURATION");if(L(t))return t}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&&L(this.startDate.getTime())&&(null===this.duration||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),t}(),B=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}},U={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"},G=function(){function t(t){var e;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=((e={})[U.AUDIO]=null,e[U.VIDEO]=null,e[U.AUDIOVIDEO]=null,e),this.baseurl=t}return t.prototype.setByteRange=function(t,e){var r=t.split("@",2),i=[];1===r.length?i[0]=e?e.byteRangeEndOffset:0:i[0]=parseInt(r[1]),i[1]=parseInt(r[0])+i[0],this._byteRange=i},n(t,[{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=T.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(t){this._url=t}}]),t}(),K=function(t){function e(e,r){var i;return(i=t.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 B,i.urlId=0,i.data=void 0,i.bitrateTest=!1,i.title=null,i.initSegment=null,i.endList=void 0,i.gap=void 0,i.type=e,i}l(e,t);var r=e.prototype;return r.setKeyFormat=function(t){if(this.levelkeys){var e=this.levelkeys[t];e&&!this._decryptdata&&(this._decryptdata=e.getDecryptData(this.sn))}},r.abortRequests=function(){var t,e;null==(t=this.loader)||t.abort(),null==(e=this.keyLoader)||e.abort()},r.setElementaryStreamInfo=function(t,e,r,i,a,n){void 0===n&&(n=!1);var s=this.elementaryStreams,o=s[t];o?(o.startPTS=Math.min(o.startPTS,e),o.endPTS=Math.max(o.endPTS,r),o.startDTS=Math.min(o.startDTS,i),o.endDTS=Math.max(o.endDTS,a)):s[t]={startPTS:e,endPTS:r,startDTS:i,endDTS:a,partial:n}},r.clearElementaryStreamInfo=function(){var t=this.elementaryStreams;t[U.AUDIO]=null,t[U.VIDEO]=null,t[U.AUDIOVIDEO]=null},n(e,[{key:"decryptdata",get:function(){if(!this.levelkeys&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){var t=this.levelkeys.identity;if(t)this._decryptdata=t.getDecryptData(this.sn);else{var e=Object.keys(this.levelkeys);if(1===e.length)return this._decryptdata=this.levelkeys[e[0]].getDecryptData(this.sn)}}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(null===this.programDateTime)return null;if(!L(this.programDateTime))return null;var t=L(this.duration)?this.duration:0;return this.programDateTime+1e3*t}},{key:"encrypted",get:function(){var t;if(null!=(t=this._decryptdata)&&t.encrypted)return!0;if(this.levelkeys){var e=Object.keys(this.levelkeys),r=e.length;if(r>1||1===r&&this.levelkeys[e[0]].encrypted)return!0}return!1}}]),e}(G),V=function(t){function e(e,r,i,a,n){var s;(s=t.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 B,s.duration=e.decimalFloatingPoint("DURATION"),s.gap=e.bool("GAP"),s.independent=e.bool("INDEPENDENT"),s.relurl=e.enumeratedString("URI"),s.fragment=r,s.index=a;var o=e.enumeratedString("BYTERANGE");return o&&s.setByteRange(o,n),n&&(s.fragOffset=n.fragOffset+n.duration),s}return l(e,t),n(e,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var t=this.elementaryStreams;return!!(t.audio||t.video||t.audiovideo)}}]),e}(G),H=10,W=function(){function t(t){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=t}return t.prototype.reloaded=function(t){if(!t)return this.advanced=!0,void(this.updated=!0);var e=this.lastPartSn-t.lastPartSn,r=this.lastPartIndex-t.lastPartIndex;this.updated=this.endSN!==t.endSN||!!r||!!e||!this.live,this.advanced=this.endSN>t.endSN||e>0||0===e&&r>0,this.updated||this.advanced?this.misses=Math.floor(.6*t.misses):this.misses=t.misses+1,this.availabilityDelay=t.availabilityDelay},n(t,[{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&L(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||H}},{key:"drift",get:function(){var t=this.driftEndTime-this.driftStartTime;return t>0?1e3*(this.driftEnd-this.driftStart)/t:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var t;return null!=(t=this.partList)&&t.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var t;return null!=(t=this.fragments)&&t.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 t;return null!=(t=this.partList)&&t.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var t;return null!=(t=this.partList)&&t.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),t}(),Y=y(void 0);function j(t,e,r){return Uint8Array.prototype.slice?t.slice(e,r):new Uint8Array(Array.prototype.slice.call(t,e,r))}var q,z=function(t,e){return e+10<=t.length&&73===t[e]&&68===t[e+1]&&51===t[e+2]&&t[e+3]<255&&t[e+4]<255&&t[e+6]<128&&t[e+7]<128&&t[e+8]<128&&t[e+9]<128},X=function(t,e){return e+10<=t.length&&51===t[e]&&68===t[e+1]&&73===t[e+2]&&t[e+3]<255&&t[e+4]<255&&t[e+6]<128&&t[e+7]<128&&t[e+8]<128&&t[e+9]<128},Q=function(t,e){for(var r=e,i=0;z(t,e);)i+=10,i+=$(t,e+6),X(t,e+10)&&(i+=10),e+=i;if(i>0)return t.subarray(r,r+i)},$=function(t,e){var r=0;return r=(127&t[e])<<21,r|=(127&t[e+1])<<14,r|=(127&t[e+2])<<7,r|=127&t[e+3]},Z=function(t,e){return z(t,e)&&$(t,e+6)+10<=t.length-e},J=function(t){for(var e=rt(t),r=0;r<e.length;r++){var i=e[r];if(tt(i))return ot(i)}},tt=function(t){return t&&"PRIV"===t.key&&"com.apple.streaming.transportStreamTimestamp"===t.info},et=function(t){var e=String.fromCharCode(t[0],t[1],t[2],t[3]),r=$(t,4),i=10;return{type:e,size:r,data:t.subarray(i,i+r)}},rt=function(t){for(var e=0,r=[];z(t,e);){for(var i=$(t,e+6),a=(e+=10)+i;e+8<a;){var n=et(t.subarray(e)),s=it(n);s&&r.push(s),e+=n.size+10}X(t,e)&&(e+=10)}return r},it=function(t){return"PRIV"===t.type?at(t):"W"===t.type[0]?st(t):nt(t)},at=function(t){if(!(t.size<2)){var e=lt(t.data,!0),r=new Uint8Array(t.data.subarray(e.length+1));return{key:t.type,info:e,data:r.buffer}}},nt=function(t){if(!(t.size<2)){if("TXXX"===t.type){var e=1,r=lt(t.data.subarray(e),!0);e+=r.length+1;var i=lt(t.data.subarray(e));return{key:t.type,info:r,data:i}}var a=lt(t.data.subarray(1));return{key:t.type,data:a}}},st=function(t){if("WXXX"===t.type){if(t.size<2)return;var e=1,r=lt(t.data.subarray(e),!0);e+=r.length+1;var i=lt(t.data.subarray(e));return{key:t.type,info:r,data:i}}var a=lt(t.data);return{key:t.type,data:a}},ot=function(t){if(8===t.data.byteLength){var e=new Uint8Array(t.data),r=1&e[3],i=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7];return i/=45,r&&(i+=47721858.84),Math.round(i)}},lt=function(t,e){void 0===e&&(e=!1);var r=ut();if(r){var i=r.decode(t);if(e){var a=i.indexOf("\0");return-1!==a?i.substring(0,a):i}return i.replace(/\0/g,"")}for(var n,s,o,l=t.length,u="",d=0;d<l;){if(0===(n=t[d++])&&e)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=t[d++],u+=String.fromCharCode((31&n)<<6|63&s);break;case 14:s=t[d++],o=t[d++],u+=String.fromCharCode((15&n)<<12|(63&s)<<6|(63&o)<<0)}}return u};function ut(){return q||void 0===self.TextDecoder||(q=new self.TextDecoder("utf-8")),q}var dt={hexDump:function(t){for(var e="",r=0;r<t.length;r++){var i=t[r].toString(16);i.length<2&&(i="0"+i),e+=i}return e}},ht=Math.pow(2,32)-1,ft=[].push,ct={video:1,audio:2,id3:3,text:4};function vt(t){return String.fromCharCode.apply(null,t)}function gt(t,e){var r=t[e]<<8|t[e+1];return r<0?65536+r:r}function mt(t,e){var r=pt(t,e);return r<0?4294967296+r:r}function pt(t,e){return t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3]}function yt(t,e,r){t[e]=r>>24,t[e+1]=r>>16&255,t[e+2]=r>>8&255,t[e+3]=255&r}function Et(t,e){var r=[];if(!e.length)return r;for(var i=t.byteLength,a=0;a<i;){var n=mt(t,a),s=n>1?a+n:i;if(vt(t.subarray(a+4,a+8))===e[0])if(1===e.length)r.push(t.subarray(a+8,s));else{var o=Et(t.subarray(a+8,s),e.slice(1));o.length&&ft.apply(r,o)}a=s}return r}function Tt(t){var e=[],r=t[0],i=8,a=mt(t,i);i+=4;var n=0,s=0;i+=0===r?8:16,i+=2;var o=t.length+s,l=gt(t,i);i+=2;for(var u=0;u<l;u++){var d=i,h=mt(t,d);d+=4;var f=2147483647&h;if(1==(2147483648&h)>>>31)return w.warn("SIDX has hierarchical references (not supported)"),null;var c=mt(t,d);d+=4,e.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:e}}function Lt(t){for(var e=[],r=Et(t,["moov","trak"]),i=0;i<r.length;i++){var a=r[i],n=Et(a,["tkhd"])[0];if(n){var s=n[0],o=0===s?12:20,l=mt(n,o),u=Et(a,["mdia","mdhd"])[0];if(u){var d=mt(u,o=0===(s=u[0])?12:20),h=Et(a,["mdia","hdlr"])[0];if(h){var f=vt(h.subarray(8,12)),c={soun:U.AUDIO,vide:U.VIDEO}[f];if(c){var v=Et(a,["mdia","minf","stbl","stsd"])[0],g=void 0;v&&(g=vt(v.subarray(12,16))),e[l]={timescale:d,type:c},e[c]={timescale:d,id:l,codec:g}}}}}}return Et(t,["moov","mvex","trex"]).forEach((function(t){var r=mt(t,4),i=e[r];i&&(i.default={duration:mt(t,12),flags:mt(t,20)})})),e}function St(t,e){if(!t||!e)return t;var r=e.keyId;return r&&e.isCommonEncryption&&Et(t,["moov","trak"]).forEach((function(t){var e=Et(t,["mdia","minf","stbl","stsd"])[0].subarray(8),i=Et(e,["enca"]),a=i.length>0;a||(i=Et(e,["encv"])),i.forEach((function(t){Et(a?t.subarray(28):t.subarray(78),["sinf"]).forEach((function(t){var e=At(t);if(e){var i=e.subarray(8,24);i.some((function(t){return 0!==t}))||(w.log("[eme] Patching keyId in 'enc"+(a?"a":"v")+">sinf>>tenc' box: "+dt.hexDump(i)+" -> "+dt.hexDump(r)),e.set(r,8))}}))}))})),t}function At(t){var e=Et(t,["schm"])[0];if(e){var r=vt(e.subarray(4,8));if("cbcs"===r||"cenc"===r)return Et(t,["schi","tenc"])[0]}return w.error("[eme] missing 'schm' box"),null}function Rt(t,e){return Et(e,["moof","traf"]).reduce((function(e,r){var i=Et(r,["tfdt"])[0],a=i[0],n=Et(r,["tfhd"]).reduce((function(e,r){var n=mt(r,4),s=t[n];if(s){var o=mt(i,4);if(1===a){if(o===ht)return w.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),e;o*=ht+1,o+=mt(i,8)}var l=o/(s.timescale||9e4);if(isFinite(l)&&(null===e||l<e))return l}return e}),null);return null!==n&&isFinite(n)&&(null===e||n<e)?n:e}),null)}function bt(t,e){for(var r=0,i=0,a=0,n=Et(t,["moof","traf"]),s=0;s<n.length;s++){var o=n[s],l=Et(o,["tfhd"])[0],u=e[mt(l,4)];if(u){var d=u.default,h=mt(l,0)|(null==d?void 0:d.flags),f=null==d?void 0:d.duration;8&h&&(f=mt(l,2&h?12:8));for(var c=u.timescale||9e4,v=Et(o,["trun"]),g=0;g<v.length;g++)!(r=Dt(v[g]))&&f&&(r=f*mt(v[g],4)),u.type===U.VIDEO?i+=r/c:u.type===U.AUDIO&&(a+=r/c)}}if(0===i&&0===a){for(var m=0,p=Et(t,["sidx"]),y=0;y<p.length;y++){var E=Tt(p[y]);null!=E&&E.references&&(m+=E.references.reduce((function(t,e){return t+e.info.duration||0}),0))}return m}return i||a}function Dt(t){var e=mt(t,0),r=8;1&e&&(r+=4),4&e&&(r+=4);for(var i=0,a=mt(t,4),n=0;n<a;n++)256&e&&(i+=mt(t,r),r+=4),512&e&&(r+=4),1024&e&&(r+=4),2048&e&&(r+=4);return i}function kt(t,e,r){Et(e,["moof","traf"]).forEach((function(e){Et(e,["tfhd"]).forEach((function(i){var a=mt(i,4),n=t[a];if(n){var s=n.timescale||9e4;Et(e,["tfdt"]).forEach((function(t){var e=t[0],i=mt(t,4);if(0===e)i-=r*s,yt(t,4,i=Math.max(i,0));else{i*=Math.pow(2,32),i+=mt(t,8),i-=r*s,i=Math.max(i,0);var a=Math.floor(i/(ht+1)),n=Math.floor(i%(ht+1));yt(t,4,a),yt(t,8,n)}}))}}))}))}function It(t){var e={valid:null,remainder:null},r=Et(t,["moof"]);if(!r)return e;if(r.length<2)return e.remainder=t,e;var i=r[r.length-1];return e.valid=j(t,0,i.byteOffset-8),e.remainder=j(t,i.byteOffset-8),e}function _t(t,e){var r=new Uint8Array(t.length+e.length);return r.set(t),r.set(e,t.length),r}function xt(t,e){var r=[],i=e.samples,a=e.timescale,n=e.id,s=!1;return Et(i,["moof"]).map((function(o){var l=o.byteOffset-8;Et(o,["traf"]).map((function(o){var u=Et(o,["tfdt"]).map((function(t){var e=t[0],r=mt(t,4);return 1===e&&(r*=Math.pow(2,32),r+=mt(t,8)),r/a}))[0];return void 0!==u&&(t=u),Et(o,["tfhd"]).map((function(u){var d=mt(u,4),h=16777215&mt(u,0),f=0,c=0!=(16&h),v=0,g=0!=(32&h),m=8;d===n&&(0!=(1&h)&&(m+=8),0!=(2&h)&&(m+=4),0!=(8&h)&&(f=mt(u,m),m+=4),c&&(v=mt(u,m),m+=4),g&&(m+=4),"video"===e.type&&(s=wt(e.codec)),Et(o,["trun"]).map((function(n){var o=n[0],u=16777215&mt(n,0),d=0!=(1&u),h=0,c=0!=(4&u),g=0!=(256&u),m=0,p=0!=(512&u),y=0,E=0!=(1024&u),T=0!=(2048&u),L=0,S=mt(n,4),A=8;d&&(h=mt(n,A),A+=4),c&&(A+=4);for(var R=h+l,b=0;b<S;b++){if(g?(m=mt(n,A),A+=4):m=f,p?(y=mt(n,A),A+=4):y=v,E&&(A+=4),T&&(L=0===o?mt(n,A):pt(n,A),A+=4),e.type===U.VIDEO)for(var D=0;D<y;){var k=mt(i,R);Ct(s,i[R+=4])&&Pt(i.subarray(R,R+k),s?2:1,t+L/a,r),R+=k,D+=k+4}t+=m/a}})))}))}))})),r}function wt(t){if(!t)return!1;var e=t.indexOf("."),r=e<0?t:t.substring(0,e);return"hvc1"===r||"hev1"===r||"dvh1"===r||"dvhe"===r}function Ct(t,e){if(t){var r=e>>1&63;return 39===r||40===r}return 6==(31&e)}function Pt(t,e,r,i){var a=Ot(t),n=0;n+=e;for(var s=0,o=0,l=!1,u=0;n<a.length;){s=0;do{if(n>=a.length)break;s+=u=a[n++]}while(255===u);o=0;do{if(n>=a.length)break;o+=u=a[n++]}while(255===u);var d=a.length-n;if(!l&&4===s&&n<a.length){if(l=!0,181===a[n++]){var h=gt(a,n);if(n+=2,49===h){var f=mt(a,n);if(n+=4,1195456820===f){var c=a[n++];if(3===c){var v=a[n++],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[n++]}i.push({type:c,payloadType:s,pts:r,bytes:p})}}}}}else if(5===s&&o<d){if(l=!0,o>16){for(var E=[],T=0;T<16;T++){var L=a[n++].toString(16);E.push(1==L.length?"0"+L:L),3!==T&&5!==T&&7!==T&&9!==T||E.push("-")}for(var S=o-16,A=new Uint8Array(S),R=0;R<S;R++)A[R]=a[n++];i.push({payloadType:s,pts:r,uuid:E.join(""),userData:lt(A),userDataBytes:A})}}else if(o<d)n+=o;else if(o>d)break}}function Ot(t){for(var e=t.byteLength,r=[],i=1;i<e-2;)0===t[i]&&0===t[i+1]&&3===t[i+2]?(r.push(i+2),i+=2):i++;if(0===r.length)return t;var a=e-r.length,n=new Uint8Array(a),s=0;for(i=0;i<a;s++,i++)s===r[0]&&(s++,r.shift()),n[i]=t[s];return n}function Ft(t){var e=t[0],r="",i="",a=0,n=0,s=0,o=0,l=0,u=0;if(0===e){for(;"\0"!==vt(t.subarray(u,u+1));)r+=vt(t.subarray(u,u+1)),u+=1;for(r+=vt(t.subarray(u,u+1)),u+=1;"\0"!==vt(t.subarray(u,u+1));)i+=vt(t.subarray(u,u+1)),u+=1;i+=vt(t.subarray(u,u+1)),u+=1,a=mt(t,12),n=mt(t,16),o=mt(t,20),l=mt(t,24),u=28}else if(1===e){a=mt(t,u+=4);var d=mt(t,u+=4),h=mt(t,u+=4);for(u+=4,s=Math.pow(2,32)*d+h,Number.isSafeInteger(s)||(s=Number.MAX_SAFE_INTEGER,w.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=mt(t,u),l=mt(t,u+=4),u+=4;"\0"!==vt(t.subarray(u,u+1));)r+=vt(t.subarray(u,u+1)),u+=1;for(r+=vt(t.subarray(u,u+1)),u+=1;"\0"!==vt(t.subarray(u,u+1));)i+=vt(t.subarray(u,u+1)),u+=1;i+=vt(t.subarray(u,u+1)),u+=1}return{schemeIdUri:r,value:i,timeScale:a,presentationTime:s,presentationTimeDelta:n,eventDuration:o,id:l,payload:t.subarray(u,t.byteLength)}}var Mt=function(){function t(t,e,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=t,this.uri=e,this.keyFormat=r,this.keyFormatVersions=i,this.iv=a,this.encrypted=!!t&&"NONE"!==t,this.isCommonEncryption=this.encrypted&&"AES-128"!==t}t.clearKeyUriToKeyIdMap=function(){};var e=t.prototype;return e.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},e.getDecryptData=function(e){if(!this.encrypted||!this.uri)return null;if("AES-128"===this.method&&this.uri&&!this.iv){"number"!=typeof e&&("AES-128"!==this.method||this.iv||w.warn('missing IV for initialization segment with method="'+this.method+'" - compliance issue'),e=0);var r=Nt(e);return new t(this.method,this.uri,"identity",this.keyFormatVersions,r)}return this},t}();function Nt(t){for(var e=new Uint8Array(16),r=12;r<16;r++)e[r]=t>>8*(15-r)&255;return e}function Bt(){if("undefined"!=typeof self)return self.MediaSource||self.WebKitMediaSource}var Ut={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dva1:!0,dvav:!0,dvh1:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}},Gt=Bt();function Kt(t,e){var r=Ut[e];return!!r&&!0===r[t.slice(0,4)]}function Vt(t,e){var r;return null!=(r=null==Gt?void 0:Gt.isTypeSupported((e||"video")+'/mp4;codecs="'+t+'"'))&&r}var Ht=/#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,Wt=/#EXT-X-MEDIA:(.*)/g,Yt=/^#EXT(?:INF|-X-TARGETDURATION):/m,jt=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),qt=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),zt=function(){function t(){}return t.findGroup=function(t,e){for(var r=0;r<t.length;r++){var i=t[r];if(i.id===e)return i}},t.convertAVC1ToAVCOTI=function(t){var e=t.split(".");if(e.length>2){var r=e.shift()+".";return r+=parseInt(e.shift()).toString(16),r+=("000"+parseInt(e.shift()).toString(16)).slice(-4)}return t},t.resolve=function(t,e){return T.buildAbsoluteURL(e,t,{alwaysNormalize:!0})},t.isMediaPlaylist=function(t){return Yt.test(t)},t.parseMasterPlaylist=function(e,r){var i,a={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:!1},n=[];for(Ht.lastIndex=0;null!=(i=Ht.exec(e));)if(i[1]){var s,o=new O(i[1]),l=i[2],u={attrs:o,bitrate:o.decimalInteger("AVERAGE-BANDWIDTH")||o.decimalInteger("BANDWIDTH"),name:o.NAME,url:t.resolve(l,r)},d=o.decimalResolution("RESOLUTION");d&&(u.width=d.width,u.height=d.height),$t((o.CODECS||"").split(/[ ,]+/).filter((function(t){return t})),u),u.videoCodec&&-1!==u.videoCodec.indexOf("avc1")&&(u.videoCodec=t.convertAVC1ToAVCOTI(u.videoCodec)),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 O(f),v=c["DATA-ID"];v&&(null===a.sessionData&&(a.sessionData={}),a.sessionData[v]=c);break;case"SESSION-KEY":var g=Xt(f,r);g.encrypted&&g.isSupported()?(null===a.sessionKeys&&(a.sessionKeys=[]),a.sessionKeys.push(g)):w.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+f+'"');break;case"DEFINE":break;case"CONTENT-STEERING":var m=new O(f);a.contentSteering={uri:t.resolve(m["SERVER-URI"],r),pathwayId:m["PATHWAY-ID"]||"."};break;case"START":a.startTimeOffset=Qt(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},t.parseMasterPlaylistMedia=function(e,r,i){var a,n={},s=i.levels,o={AUDIO:s.map((function(t){return{id:t.attrs.AUDIO,audioCodec:t.audioCodec}})),SUBTITLES:s.map((function(t){return{id:t.attrs.SUBTITLES,textCodec:t.textCodec}})),"CLOSED-CAPTIONS":[]},l=0;for(Wt.lastIndex=0;null!==(a=Wt.exec(e));){var u=new O(a[1]),d=u.TYPE;if(d){var h=o[d],f=n[d]||[];n[d]=f;var c={attrs:u,bitrate:0,id:l++,groupId:u["GROUP-ID"]||"",instreamId:u["INSTREAM-ID"],name:u.NAME||u.LANGUAGE||"",type:d,default:u.bool("DEFAULT"),autoselect:u.bool("AUTOSELECT"),forced:u.bool("FORCED"),lang:u.LANGUAGE,url:u.URI?t.resolve(u.URI,r):""};if(null!=h&&h.length){var v=t.findGroup(h,c.groupId)||h[0];Zt(c,v,"audioCodec"),Zt(c,v,"textCodec")}f.push(c)}}return n},t.parseLevelPlaylist=function(t,e,r,i,a,n){var s,l,u,d=new W(e),h=d.fragments,f=null,c=0,v=0,g=0,m=0,p=null,y=new K(i,e),E=-1,T=!1;for(jt.lastIndex=0,d.m3u8=t,d.hasVariableRefs=!1;null!==(s=jt.exec(t));){T&&(T=!1,(y=new K(i,e)).start=g,y.sn=c,y.cc=m,y.level=r,f&&(y.initSegment=f,y.rawProgramDateTime=f.rawProgramDateTime,f.rawProgramDateTime=null));var S=s[1];if(S){y.duration=parseFloat(S);var A=(" "+s[2]).slice(1);y.title=A||null,y.tagList.push(A?["INF",S,A]:["INF",S])}else if(s[3]){if(L(y.duration)){y.start=g,u&&re(y,u,d),y.sn=c,y.level=r,y.cc=m,y.urlId=a,h.push(y);var R=(" "+s[3]).slice(1);y.relurl=R,te(y,p),p=y,g+=y.duration,c++,v=0,T=!0}}else if(s[4]){var b=(" "+s[4]).slice(1);p?y.setByteRange(b,p):y.setByteRange(b)}else if(s[5])y.rawProgramDateTime=(" "+s[5]).slice(1),y.tagList.push(["PROGRAM-DATE-TIME",y.rawProgramDateTime]),-1===E&&(E=h.length);else{if(!(s=s[0].match(qt))){w.warn("No matches on slow regex match for level playlist!");continue}for(l=1;l<s.length&&void 0===s[l];l++);var D=(" "+s[l]).slice(1),k=(" "+s[l+1]).slice(1),I=s[l+2]?(" "+s[l+2]).slice(1):"";switch(D){case"PLAYLIST-TYPE":d.type=k.toUpperCase();break;case"MEDIA-SEQUENCE":c=d.startSN=parseInt(k);break;case"SKIP":var _=new O(k),x=_.decimalInteger("SKIPPED-SEGMENTS");if(L(x)){d.skippedSegments=x;for(var C=x;C--;)h.unshift(null);c+=x}var P=_.enumeratedString("RECENTLY-REMOVED-DATERANGES");P&&(d.recentlyRemovedDateranges=P.split("\t"));break;case"TARGETDURATION":d.targetduration=Math.max(parseInt(k),1);break;case"VERSION":d.version=parseInt(k);break;case"EXTM3U":case"DEFINE":break;case"ENDLIST":d.live=!1;break;case"#":(k||I)&&y.tagList.push(I?[k,I]:[k]);break;case"DISCONTINUITY":m++,y.tagList.push(["DIS"]);break;case"GAP":y.gap=!0,y.tagList.push([D]);break;case"BITRATE":y.tagList.push([D,k]);break;case"DATERANGE":var F=new O(k),M=new N(F,d.dateRanges[F.ID]);M.isValid||d.skippedSegments?d.dateRanges[M.id]=M:w.warn('Ignoring invalid DATERANGE tag: "'+k+'"'),y.tagList.push(["EXT-X-DATERANGE",k]);break;case"DISCONTINUITY-SEQUENCE":m=parseInt(k);break;case"KEY":var B=Xt(k,e);if(B.isSupported()){if("NONE"===B.method){u=void 0;break}u||(u={}),u[B.keyFormat]&&(u=o({},u)),u[B.keyFormat]=B}else w.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'+k+'"');break;case"START":d.startTimeOffset=Qt(k);break;case"MAP":var U=new O(k);if(y.duration){var G=new K(i,e);ee(G,U,r,u),f=G,y.initSegment=f,f.rawProgramDateTime&&!y.rawProgramDateTime&&(y.rawProgramDateTime=f.rawProgramDateTime)}else ee(y,U,r,u),f=y,T=!0;break;case"SERVER-CONTROL":var H=new O(k);d.canBlockReload=H.bool("CAN-BLOCK-RELOAD"),d.canSkipUntil=H.optionalFloat("CAN-SKIP-UNTIL",0),d.canSkipDateRanges=d.canSkipUntil>0&&H.bool("CAN-SKIP-DATERANGES"),d.partHoldBack=H.optionalFloat("PART-HOLD-BACK",0),d.holdBack=H.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var Y=new O(k);d.partTarget=Y.decimalFloatingPoint("PART-TARGET");break;case"PART":var j=d.partList;j||(j=d.partList=[]);var q=v>0?j[j.length-1]:void 0,z=v++,X=new O(k),Q=new V(X,y,e,z,q);j.push(Q),y.duration+=Q.duration;break;case"PRELOAD-HINT":var $=new O(k);d.preloadHint=$;break;case"RENDITION-REPORT":var Z=new O(k);d.renditionReports=d.renditionReports||[],d.renditionReports.push(Z);break;default:w.warn("line parsed but not handled: "+s)}}}p&&!p.relurl?(h.pop(),g-=p.duration,d.partList&&(d.fragmentHint=p)):d.partList&&(te(y,p),y.cc=m,d.fragmentHint=y,u&&re(y,u,d));var J=h.length,tt=h[0],et=h[J-1];if((g+=d.skippedSegments*d.targetduration)>0&&J&&et){d.averagetargetduration=g/J;var rt=et.sn;d.endSN="initSegment"!==rt?rt:0,d.live||(et.endList=!0),tt&&(d.startCC=tt.cc)}else d.endSN=0,d.startCC=0;return d.fragmentHint&&(g+=d.fragmentHint.duration),d.totalduration=g,d.endCC=m,E>0&&Jt(h,E),d},t}();function Xt(t,e,r){var i,a,n=new O(t),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&&w.error("Invalid IV: "+n.IV);var h=o?zt.resolve(o,e):"",f=(u||"1").split("/").map(Number).filter(Number.isFinite);return new Mt(s,h,d,f,l)}function Qt(t){var e=new O(t).decimalFloatingPoint("TIME-OFFSET");return L(e)?e:null}function $t(t,e){["video","audio","text"].forEach((function(r){var i=t.filter((function(t){return Kt(t,r)}));if(i.length){var a=i.filter((function(t){return 0===t.lastIndexOf("avc1",0)||0===t.lastIndexOf("mp4a",0)}));e[r+"Codec"]=a.length>0?a[0]:i[0],t=t.filter((function(t){return-1===i.indexOf(t)}))}})),e.unknownCodecs=t}function Zt(t,e,r){var i=e[r];i&&(t[r]=i)}function Jt(t,e){for(var r=t[e],i=e;i--;){var a=t[i];if(!a)return;a.programDateTime=r.programDateTime-1e3*a.duration,r=a}}function te(t,e){t.rawProgramDateTime?t.programDateTime=Date.parse(t.rawProgramDateTime):null!=e&&e.programDateTime&&(t.programDateTime=e.endProgramDateTime),L(t.programDateTime)||(t.programDateTime=null,t.rawProgramDateTime=null)}function ee(t,e,r,i){t.relurl=e.URI,e.BYTERANGE&&t.setByteRange(e.BYTERANGE),t.level=r,t.sn="initSegment",i&&(t.levelkeys=i),t.initSegment=null}function re(t,e,r){t.levelkeys=e;var i=r.encryptedFragments;i.length&&i[i.length-1].levelkeys===e||!Object.keys(e).some((function(t){return e[t].isCommonEncryption}))||i.push(t)}var ie={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},ae={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function ne(t){switch(t.type){case ie.AUDIO_TRACK:return ae.AUDIO;case ie.SUBTITLE_TRACK:return ae.SUBTITLE;default:return ae.MAIN}}function se(t,e){var r=t.url;return void 0!==r&&0!==r.indexOf("data:")||(r=e.url),r}var oe=function(){function t(t){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=t,this.registerListeners()}var e=t.prototype;return e.startLoad=function(t){},e.stopLoad=function(){this.destroyInternalLoaders()},e.registerListeners=function(){var t=this.hls;t.on(S.MANIFEST_LOADING,this.onManifestLoading,this),t.on(S.LEVEL_LOADING,this.onLevelLoading,this),t.on(S.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.on(S.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},e.unregisterListeners=function(){var t=this.hls;t.off(S.MANIFEST_LOADING,this.onManifestLoading,this),t.off(S.LEVEL_LOADING,this.onLevelLoading,this),t.off(S.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.off(S.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},e.createInternalLoader=function(t){var e=this.hls.config,r=e.pLoader,i=e.loader,a=new(r||i)(e);return this.loaders[t.type]=a,a},e.getInternalLoader=function(t){return this.loaders[t.type]},e.resetInternalLoader=function(t){this.loaders[t]&&delete this.loaders[t]},e.destroyInternalLoaders=function(){for(var t in this.loaders){var e=this.loaders[t];e&&e.destroy(),this.resetInternalLoader(t)}},e.destroy=function(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()},e.onManifestLoading=function(t,e){var r=e.url;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:ie.MANIFEST,url:r,deliveryDirectives:null})},e.onLevelLoading=function(t,e){var r=e.id,i=e.level,a=e.url,n=e.deliveryDirectives;this.load({id:r,level:i,responseType:"text",type:ie.LEVEL,url:a,deliveryDirectives:n})},e.onAudioTrackLoading=function(t,e){var r=e.id,i=e.groupId,a=e.url,n=e.deliveryDirectives;this.load({id:r,groupId:i,level:null,responseType:"text",type:ie.AUDIO_TRACK,url:a,deliveryDirectives:n})},e.onSubtitleTrackLoading=function(t,e){var r=e.id,i=e.groupId,a=e.url,n=e.deliveryDirectives;this.load({id:r,groupId:i,level:null,responseType:"text",type:ie.SUBTITLE_TRACK,url:a,deliveryDirectives:n})},e.load=function(t){var e,r,i,a=this,n=this.hls.config,s=this.getInternalLoader(t);if(s){var l=s.context;if(l&&l.url===t.url)return void w.trace("[playlist-loader]: playlist request ongoing");w.log("[playlist-loader]: aborting previous loader for type: "+t.type),s.abort()}if(r=t.type===ie.MANIFEST?n.manifestLoadPolicy.default:o({},n.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),s=this.createInternalLoader(t),null!=(e=t.deliveryDirectives)&&e.part&&(t.type===ie.LEVEL&&null!==t.level?i=this.hls.levels[t.level].details:t.type===ie.AUDIO_TRACK&&null!==t.id?i=this.hls.audioTracks[t.id].details:t.type===ie.SUBTITLE_TRACK&&null!==t.id&&(i=this.hls.subtitleTracks[t.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(t,e,r,i){var n=a.getInternalLoader(r);a.resetInternalLoader(r.type);var s=t.data;0===s.indexOf("#EXTM3U")?(e.parsing.start=performance.now(),zt.isMediaPlaylist(s)?a.handleTrackOrLevelPlaylist(t,e,r,i||null,n):a.handleMasterPlaylist(t,e,r,i)):a.handleManifestParsingError(t,r,new Error("no EXTM3U delimiter"),i||null,e)},onError:function(t,e,r,i){a.handleNetworkError(e,r,!1,t,i)},onTimeout:function(t,e,r){a.handleNetworkError(e,r,!0,void 0,t)}};s.load(t,c,v)},e.handleMasterPlaylist=function(t,e,r,i){var a=this.hls,n=t.data,s=se(t,r),o=zt.parseMasterPlaylist(n,s);if(o.playlistParsingError)this.handleManifestParsingError(t,r,o.playlistParsingError,i,e);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=zt.parseMasterPlaylistMedia(n,s,o),g=v.AUDIO,m=void 0===g?[]:g,p=v.SUBTITLES,y=v["CLOSED-CAPTIONS"];m.length&&(m.some((function(t){return!t.url}))||!u[0].audioCodec||u[0].attrs.AUDIO||(w.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 O({}),bitrate:0,url:""}))),a.trigger(S.MANIFEST_LOADED,{levels:u,audioTracks:m,subtitles:p,captions:y,contentSteering:l,url:s,stats:e,networkDetails:i,sessionData:d,sessionKeys:h,startTimeOffset:f,variableList:c})}},e.handleTrackOrLevelPlaylist=function(t,e,r,i,a){var n=this.hls,s=r.id,o=r.level,l=r.type,u=se(t,r),d=L(s)?s:0,h=L(o)?o:d,f=ne(r),c=zt.parseLevelPlaylist(t.data,u,h,f,d,this.variableList);if(l===ie.MANIFEST){var v={attrs:new O({}),bitrate:0,details:c,name:"",url:u};n.trigger(S.MANIFEST_LOADED,{levels:[v],audioTracks:[],url:u,stats:e,networkDetails:i,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}e.parsing.end=performance.now(),r.levelDetails=c,this.handlePlaylistLoaded(c,t,e,r,i,a)},e.handleManifestParsingError=function(t,e,r,i,a){this.hls.trigger(S.ERROR,{type:A.NETWORK_ERROR,details:R.MANIFEST_PARSING_ERROR,fatal:e.type===ie.MANIFEST,url:t.url,err:r,error:r,reason:r.message,response:t,context:e,networkDetails:i,stats:a})},e.handleNetworkError=function(t,e,r,a,n){void 0===r&&(r=!1);var s="A network "+(r?"timeout":"error"+(a?" (status "+a.code+")":""))+" occurred while loading "+t.type;t.type===ie.LEVEL?s+=": "+t.level+" id: "+t.id:t.type!==ie.AUDIO_TRACK&&t.type!==ie.SUBTITLE_TRACK||(s+=" id: "+t.id+' group-id: "'+t.groupId+'"');var o=new Error(s);w.warn("[playlist-loader]: "+s);var l=R.UNKNOWN,u=!1,d=this.getInternalLoader(t);switch(t.type){case ie.MANIFEST:l=r?R.MANIFEST_LOAD_TIMEOUT:R.MANIFEST_LOAD_ERROR,u=!0;break;case ie.LEVEL:l=r?R.LEVEL_LOAD_TIMEOUT:R.LEVEL_LOAD_ERROR,u=!1;break;case ie.AUDIO_TRACK:l=r?R.AUDIO_TRACK_LOAD_TIMEOUT:R.AUDIO_TRACK_LOAD_ERROR,u=!1;break;case ie.SUBTITLE_TRACK:l=r?R.SUBTITLE_TRACK_LOAD_TIMEOUT:R.SUBTITLE_LOAD_ERROR,u=!1}d&&this.resetInternalLoader(t.type);var h={type:A.NETWORK_ERROR,details:l,fatal:u,url:t.url,loader:d,context:t,error:o,networkDetails:e,stats:n};if(a){var f=(null==e?void 0:e.url)||t.url;h.response=i({url:f,data:void 0},a)}this.hls.trigger(S.ERROR,h)},e.handlePlaylistLoaded=function(t,e,r,i,a,n){var s=this.hls,o=i.type,l=i.level,u=i.id,d=i.groupId,h=i.deliveryDirectives,f=se(e,i),c=ne(i),v="number"==typeof i.level&&c===ae.MAIN?l:void 0;if(t.fragments.length){t.targetduration||(t.playlistParsingError=new Error("Missing Target Duration"));var g=t.playlistParsingError;if(g)s.trigger(S.ERROR,{type:A.NETWORK_ERROR,details:R.LEVEL_PARSING_ERROR,fatal:!1,url:f,error:g,reason:g.message,response:e,context:i,level:v,parent:c,networkDetails:a,stats:r});else switch(t.live&&n&&(n.getCacheAge&&(t.ageHeader=n.getCacheAge()||0),n.getCacheAge&&!isNaN(t.ageHeader)||(t.ageHeader=0)),o){case ie.MANIFEST:case ie.LEVEL:s.trigger(S.LEVEL_LOADED,{details:t,level:v||0,id:u||0,stats:r,networkDetails:a,deliveryDirectives:h});break;case ie.AUDIO_TRACK:s.trigger(S.AUDIO_TRACK_LOADED,{details:t,id:u||0,groupId:d||"",stats:r,networkDetails:a,deliveryDirectives:h});break;case ie.SUBTITLE_TRACK:s.trigger(S.SUBTITLE_TRACK_LOADED,{details:t,id:u||0,groupId:d||"",stats:r,networkDetails:a,deliveryDirectives:h})}}else{var m=new Error("No Segments found in Playlist");s.trigger(S.ERROR,{type:A.NETWORK_ERROR,details:R.LEVEL_EMPTY_ERROR,fatal:!1,url:f,error:m,reason:m.message,response:e,context:i,level:v,parent:c,networkDetails:a,stats:r})}},t}();function le(t,e){var r;try{r=new Event("addtrack")}catch(t){(r=document.createEvent("Event")).initEvent("addtrack",!1,!1)}r.track=t,e.dispatchEvent(r)}function ue(t){var e=t.mode;if("disabled"===e&&(t.mode="hidden"),t.cues)for(var r=t.cues.length;r--;)t.removeCue(t.cues[r]);"disabled"===e&&(t.mode=e)}function de(t,e,r,i){var a=t.mode;if("disabled"===a&&(t.mode="hidden"),t.cues&&t.cues.length>0)for(var n=fe(t.cues,e,r),s=0;s<n.length;s++)i&&!i(n[s])||t.removeCue(n[s]);"disabled"===a&&(t.mode=a)}function he(t,e){if(e<t[0].startTime)return 0;var r=t.length-1;if(e>t[r].endTime)return-1;for(var i=0,a=r;i<=a;){var n=Math.floor((a+i)/2);if(e<t[n].startTime)a=n-1;else{if(!(e>t[n].startTime&&i<r))return n;i=n+1}}return t[i].startTime-e<e-t[a].startTime?i:a}function fe(t,e,r){var i=[],a=he(t,e);if(a>-1)for(var n=a,s=t.length;n<s;n++){var o=t[n];if(o.startTime>=e&&o.endTime<=r)i.push(o);else if(o.startTime>r)return i}return i}var ce={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"},ve=.25;function ge(){if("undefined"!=typeof self)return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}var me=function(){var t=ge();try{new t(0,Number.POSITIVE_INFINITY,"")}catch(t){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();function pe(t,e){return t.getTime()/1e3-e}function ye(t){return Uint8Array.from(t.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var Ee=function(){function t(t){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=t,this._registerListeners()}var e=t.prototype;return e.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},e._registerListeners=function(){var t=this.hls;t.on(S.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(S.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(S.MANIFEST_LOADING,this.onManifestLoading,this),t.on(S.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.on(S.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(S.LEVEL_UPDATED,this.onLevelUpdated,this)},e._unregisterListeners=function(){var t=this.hls;t.off(S.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(S.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(S.MANIFEST_LOADING,this.onManifestLoading,this),t.off(S.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.off(S.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(S.LEVEL_UPDATED,this.onLevelUpdated,this)},e.onMediaAttached=function(t,e){this.media=e.media},e.onMediaDetaching=function(){this.id3Track&&(ue(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})},e.onManifestLoading=function(){this.dateRangeCuesAppended={}},e.createTrack=function(t){var e=this.getID3Track(t.textTracks);return e.mode="hidden",e},e.getID3Track=function(t){if(this.media){for(var e=0;e<t.length;e++){var r=t[e];if("metadata"===r.kind&&"id3"===r.label)return le(r,this.media),r}return this.media.addTextTrack("metadata","id3")}},e.onFragParsingMetadata=function(t,e){if(this.media){var r=this.hls.config,i=r.enableEmsgMetadataCues,a=r.enableID3MetadataCues;if(i||a){var n=e.samples;this.id3Track||(this.id3Track=this.createTrack(this.media));for(var s=ge(),o=0;o<n.length;o++){var l=n[o].type;if((l!==ce.emsg||i)&&a){var u=rt(n[o].data);if(u){var d=n[o].pts,h=d+n[o].duration;h>me&&(h=me),h-d<=0&&(h=d+ve);for(var f=0;f<u.length;f++){var c=u[f];if(!tt(c)){this.updateId3CueEnds(d,l);var v=new s(d,h,"");v.value=c,l&&(v.type=l),this.id3Track.addCue(v)}}}}}}}},e.updateId3CueEnds=function(t,e){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===e&&n.startTime<t&&n.endTime===me&&(n.endTime=t)}},e.onBufferFlushing=function(t,e){var r=e.startOffset,i=e.endOffset,a=e.type,n=this.id3Track,s=this.hls;if(s){var o=s.config,l=o.enableEmsgMetadataCues,u=o.enableID3MetadataCues;n&&(l||u)&&de(n,r,i,"audio"===a?function(t){return t.type===ce.audioId3&&u}:"video"===a?function(t){return t.type===ce.emsg&&l}:function(t){return t.type===ce.audioId3&&u||t.type===ce.emsg&&l})}},e.onLevelUpdated=function(t,e){var r=this,i=e.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(t){return!o.includes(t)})),u=function(){var t=l[d];Object.keys(a[t].cues).forEach((function(e){n.removeCue(a[t].cues[e])})),delete a[t]},d=l.length;d--;)u();var h=i.fragments[i.fragments.length-1];if(0!==o.length&&L(null==h?void 0:h.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var f=h.programDateTime/1e3-h.start,c=ge(),v=function(){var t=o[g],e=s[t],i=a[t],n=(null==i?void 0:i.cues)||{},l=(null==i?void 0:i.durationKnown)||!1,u=pe(e.startDate,f),d=me,h=e.endDate;if(h)d=pe(h,f),l=!0;else if(e.endOnNext&&!l){var v=o.reduce((function(t,r){var i=s[r];return i.class===e.class&&i.id!==r&&i.startDate>e.startDate&&t.push(i),t}),[]).sort((function(t,e){return t.startDate.getTime()-e.startDate.getTime()}))[0];v&&(d=pe(v.startDate,f),l=!0)}for(var m=Object.keys(e.attr),p=0;p<m.length;p++){var y=m[p];if(F(y)){var E=n[y];if(E)l&&!i.durationKnown&&(E.endTime=d);else{var T=e.attr[y];E=new c(u,d,""),M(y)&&(T=ye(T)),E.value={key:y,data:T},E.type=ce.dateRange,E.id=t,r.id3Track.addCue(E),n[y]=E}}}a[t]={cues:n,dateRange:e,durationKnown:l}},g=0;g<o.length;g++)v()}}},t}(),Te=function(){function t(t){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=t,this.config=t.config,this.registerListeners()}var e=t.prototype;return e.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},e.registerListeners=function(){this.hls.on(S.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(S.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(S.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(S.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(S.ERROR,this.onError,this)},e.unregisterListeners=function(){this.hls.off(S.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(S.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(S.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(S.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(S.ERROR,this.onError,this)},e.onMediaAttached=function(t,e){this.media=e.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},e.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},e.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},e.onLevelUpdated=function(t,e){var r=e.details;this.levelDetails=r,r.advanced&&this.timeupdate(),!r.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},e.onError=function(t,e){var r;e.details===R.BUFFER_STALLED_ERROR&&(this.stallCount++,null!=(r=this.levelDetails)&&r.live&&w.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},e.timeupdate=function(){var t=this.media,e=this.levelDetails;if(t&&e){this.currentTime=t.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){var s=this.targetLatency;if(null!==s){var o=r-s,l=o<Math.min(this.maxLatency,s+e.targetduration);if(e.live&&l&&o>.05&&this.forwardBufferLength>1){var u=Math.min(2,Math.max(1,n)),d=Math.round(2/(1+Math.exp(-.75*o-this.edgeStalled))*20)/20;t.playbackRate=Math.min(u,Math.max(1,d))}else 1!==t.playbackRate&&0!==t.playbackRate&&(t.playbackRate=1)}}}}},e.estimateLiveEdge=function(){var t=this.levelDetails;return null===t?null:t.edge+t.age},e.computeLatency=function(){var t=this.estimateLiveEdge();return null===t?null:t-this.currentTime},n(t,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var t=this.config,e=this.levelDetails;return void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:e?t.liveMaxLatencyDurationCount*e.targetduration:0}},{key:"targetLatency",get:function(){var t=this.levelDetails;if(null===t)return null;var e=t.holdBack,r=t.partHoldBack,i=t.targetduration,a=this.config,n=a.liveSyncDuration,s=a.liveSyncDurationCount,o=a.lowLatencyMode,l=this.hls.userConfig,u=o&&r||e;(l.liveSyncDuration||l.liveSyncDurationCount||0===u)&&(u=void 0!==n?n:s*i);var d=i,h=1;return u+Math.min(this.stallCount*h,d)}},{key:"liveSyncPosition",get:function(){var t=this.estimateLiveEdge(),e=this.targetLatency,r=this.levelDetails;if(null===t||null===e||null===r)return null;var i=r.edge,a=t-e-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 t=this.levelDetails;return null===t?1:t.drift}},{key:"edgeStalled",get:function(){var t=this.levelDetails;if(null===t)return 0;var e=3*(this.config.lowLatencyMode&&t.partTarget||t.targetduration);return Math.max(t.age-e,0)}},{key:"forwardBufferLength",get:function(){var t=this.media,e=this.levelDetails;if(!t||!e)return 0;var r=t.buffered.length;return(r?t.buffered.end(r-1):e.edge)-this.currentTime}}]),t}(),Le=["NONE","TYPE-0","TYPE-1",null],Se={No:"",Yes:"YES",v2:"v2"};function Ae(t,e){var r=t.canSkipUntil,i=t.canSkipDateRanges,a=t.endSN;return r&&(void 0!==e?e-a:0)<r?i?Se.v2:Se.Yes:Se.No}var Re=function(){function t(t,e,r){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=t,this.part=e,this.skip=r}return t.prototype.addDirectives=function(t){var e=new self.URL(t);return void 0!==this.msn&&e.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&e.searchParams.set("_HLS_part",this.part.toString()),this.skip&&e.searchParams.set("_HLS_skip",this.skip),e.href},t}(),be=function(){function t(t){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[t.url],this._attrs=[t.attrs],this.bitrate=t.bitrate,t.details&&(this.details=t.details),this.id=t.id||0,this.name=t.name,this.width=t.width||0,this.height=t.height||0,this.audioCodec=t.audioCodec,this.videoCodec=t.videoCodec,this.unknownCodecs=t.unknownCodecs,this.codecSet=[t.videoCodec,t.audioCodec].filter((function(t){return t})).join(",").replace(/\.[^.,]+/g,"")}return t.prototype.addFallback=function(t){this.url.push(t.url),this._attrs.push(t.attrs)},n(t,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"attrs",get:function(){return this._attrs[this._urlId]}},{key:"pathwayId",get:function(){return this.attrs["PATHWAY-ID"]||"."}},{key:"uri",get:function(){return this.url[this._urlId]||""}},{key:"urlId",get:function(){return this._urlId},set:function(t){var e=t%this.url.length;this._urlId!==e&&(this.fragmentError=0,this.loadError=0,this.details=void 0,this._urlId=e)}},{key:"audioGroupId",get:function(){var t;return null==(t=this.audioGroupIds)?void 0:t[this.urlId]}},{key:"textGroupId",get:function(){var t;return null==(t=this.textGroupIds)?void 0:t[this.urlId]}}]),t}();function De(t,e){var r=e.startPTS;if(L(r)){var i,a=0;e.sn>t.sn?(a=r-t.start,i=t):(a=t.start-r,i=e),i.duration!==a&&(i.duration=a)}else e.sn>t.sn?t.cc===e.cc&&t.minEndPTS?e.start=t.start+(t.minEndPTS-t.start):e.start=t.start+t.duration:e.start=Math.max(t.start-e.duration,0)}function ke(t,e,r,i,a,n){i-r<=0&&(w.warn("Fragment should have a positive duration",e),i=r+e.duration,n=a+e.duration);var s=r,o=i,l=e.startPTS,u=e.endPTS;if(L(l)){var d=Math.abs(l-r);L(e.deltaPTS)?e.deltaPTS=Math.max(d,e.deltaPTS):e.deltaPTS=d,s=Math.max(r,l),r=Math.min(r,l),a=Math.min(a,e.startDTS),o=Math.min(i,u),i=Math.max(i,u),n=Math.max(n,e.endDTS)}var h=r-e.start;0!==e.start&&(e.start=r),e.duration=i-e.start,e.startPTS=r,e.maxStartPTS=s,e.startDTS=a,e.endPTS=i,e.minEndPTS=o,e.endDTS=n;var f,c=e.sn;if(!t||c<t.startSN||c>t.endSN)return 0;var v=c-t.startSN,g=t.fragments;for(g[v]=e,f=v;f>0;f--)De(g[f],g[f-1]);for(f=v;f<g.length-1;f++)De(g[f],g[f+1]);return t.fragmentHint&&De(g[g.length-1],t.fragmentHint),t.PTSKnown=t.alignedSliding=!0,h}function Ie(t,e){for(var r=null,i=t.fragments,a=i.length-1;a>=0;a--){var n=i[a].initSegment;if(n){r=n;break}}t.fragmentHint&&delete t.fragmentHint.endPTS;var s,o=0;if(we(t,e,(function(t,i){t.relurl&&(o=t.cc-i.cc),L(t.startPTS)&&L(t.endPTS)&&(i.start=i.startPTS=t.startPTS,i.startDTS=t.startDTS,i.maxStartPTS=t.maxStartPTS,i.endPTS=t.endPTS,i.endDTS=t.endDTS,i.minEndPTS=t.minEndPTS,i.duration=t.endPTS-t.startPTS,i.duration&&(s=i),e.PTSKnown=e.alignedSliding=!0),i.elementaryStreams=t.elementaryStreams,i.loader=t.loader,i.stats=t.stats,i.urlId=t.urlId,t.initSegment&&(i.initSegment=t.initSegment,r=t.initSegment)})),r&&(e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments).forEach((function(t){var e;t.initSegment&&t.initSegment.relurl!==(null==(e=r)?void 0:e.relurl)||(t.initSegment=r)})),e.skippedSegments)if(e.deltaUpdateFailed=e.fragments.some((function(t){return!t})),e.deltaUpdateFailed){w.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var l=e.skippedSegments;l--;)e.fragments.shift();e.startSN=e.fragments[0].sn,e.startCC=e.fragments[0].cc}else e.canSkipDateRanges&&(e.dateRanges=_e(t.dateRanges,e.dateRanges,e.recentlyRemovedDateranges));var u=e.fragments;if(o){w.warn("discontinuity sliding from playlist, take drift into account");for(var d=0;d<u.length;d++)u[d].cc+=o}e.skippedSegments&&(e.startCC=e.fragments[0].cc),xe(t.partList,e.partList,(function(t,e){e.elementaryStreams=t.elementaryStreams,e.stats=t.stats})),s?ke(e,s,s.startPTS,s.endPTS,s.startDTS,s.endDTS):Ce(t,e),u.length&&(e.totalduration=e.edge-u[0].start),e.driftStartTime=t.driftStartTime,e.driftStart=t.driftStart;var h=e.advancedDateTime;if(e.advanced&&h){var f=e.edge;e.driftStart||(e.driftStartTime=h,e.driftStart=f),e.driftEndTime=h,e.driftEnd=f}else e.driftEndTime=t.driftEndTime,e.driftEnd=t.driftEnd,e.advancedDateTime=t.advancedDateTime}function _e(t,e,r){var i=o({},t);return r&&r.forEach((function(t){delete i[t]})),Object.keys(e).forEach((function(t){var r=new N(e[t].attr,i[t]);r.isValid?i[t]=r:w.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(e[t].attr)+'"')})),i}function xe(t,e,r){if(t&&e)for(var i=0,a=0,n=t.length;a<=n;a++){var s=t[a],o=e[a+i];s&&o&&s.index===o.index&&s.fragment.sn===o.fragment.sn?r(s,o):i--}}function we(t,e,r){for(var i=e.skippedSegments,a=Math.max(t.startSN,e.startSN)-e.startSN,n=(t.fragmentHint?1:0)+(i?e.endSN:Math.min(t.endSN,e.endSN))-e.startSN,s=e.startSN-t.startSN,o=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,l=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,u=a;u<=n;u++){var d=l[s+u],h=o[u];i&&!h&&u<i&&(h=e.fragments[u]=d),d&&h&&r(d,h)}}function Ce(t,e){var r=e.startSN+e.skippedSegments-t.startSN,i=t.fragments;r<0||r>=i.length||Pe(e,i[r].start)}function Pe(t,e){if(e){for(var r=t.fragments,i=t.skippedSegments;i<r.length;i++)r[i].start+=e;t.fragmentHint&&(t.fragmentHint.start+=e)}}function Oe(t,e){void 0===e&&(e=1/0);var r=1e3*t.targetduration;if(t.updated){var i=t.fragments,a=4;if(i.length&&r*a>e){var n=1e3*i[i.length-1].duration;n<r&&(r=n)}}else r/=2;return Math.round(r)}function Fe(t,e,r){if(null==t||!t.details)return null;var i=t.details,a=i.fragments[e-i.startSN];return a||((a=i.fragmentHint)&&a.sn===e?a:e<i.startSN&&r&&r.sn===e?r:null)}function Me(t,e,r){var i;return null!=t&&t.details?Ne(null==(i=t.details)?void 0:i.partList,e,r):null}function Ne(t,e,r){if(t)for(var i=t.length;i--;){var a=t[i];if(a.index===r&&a.fragment.sn===e)return a}return null}function Be(t){switch(t.details){case R.FRAG_LOAD_TIMEOUT:case R.KEY_LOAD_TIMEOUT:case R.LEVEL_LOAD_TIMEOUT:case R.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function Ue(t,e){var r=Be(e);return t.default[(r?"timeout":"error")+"Retry"]}function Ge(t,e){var r="linear"===t.backoff?1:Math.pow(2,e);return Math.min(r*t.retryDelayMs,t.maxRetryDelayMs)}function Ke(t){return i(i({},t),{errorRetry:null,timeoutRetry:null})}function Ve(t,e,r,i){return!!t&&e<t.maxNumRetry&&(He(i)||!!r)}function He(t){return 0===t&&!1===navigator.onLine||!!t&&(t<400||t>499)}var We={search:function(t,e){for(var r=0,i=t.length-1,a=null,n=null;r<=i;){var s=e(n=t[a=(r+i)/2|0]);if(s>0)r=a+1;else{if(!(s<0))return n;i=a-1}}return null}};function Ye(t,e,r){if(null===e||!Array.isArray(t)||!t.length||!L(e))return null;if(e<(t[0].programDateTime||0))return null;if(e>=(t[t.length-1].endProgramDateTime||0))return null;r=r||0;for(var i=0;i<t.length;++i){var a=t[i];if(ze(e,r,a))return a}return null}function je(t,e,r,i){void 0===r&&(r=0),void 0===i&&(i=0);var a=null;if(t?a=e[t.sn-e[0].sn+1]||null:0===r&&0===e[0].start&&(a=e[0]),a&&0===qe(r,i,a))return a;var n=We.search(e,qe.bind(null,r,i));return!n||n===t&&a?a:n}function qe(t,e,r){if(void 0===t&&(t=0),void 0===e&&(e=0),r.start<=t&&r.start+r.duration>t)return 0;var i=Math.min(e,r.duration+(r.deltaPTS?r.deltaPTS:0));return r.start+r.duration-i<=t?1:r.start-i>t&&r.start?-1:0}function ze(t,e,r){var i=1e3*Math.min(e,r.duration+(r.deltaPTS?r.deltaPTS:0));return(r.endProgramDateTime||0)-i>t}function Xe(t,e){return We.search(t,(function(t){return t.cc<e?1:t.cc>e?-1:0}))}var Qe=3e5,$e={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},Ze={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4},Je=function(){function t(t){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=t,this.log=w.log.bind(w,"[info]:"),this.warn=w.warn.bind(w,"[warning]:"),this.error=w.error.bind(w,"[error]:"),this.registerListeners()}var e=t.prototype;return e.registerListeners=function(){var t=this.hls;t.on(S.ERROR,this.onError,this),t.on(S.MANIFEST_LOADING,this.onManifestLoading,this),t.on(S.LEVEL_UPDATED,this.onLevelUpdated,this)},e.unregisterListeners=function(){var t=this.hls;t&&(t.off(S.ERROR,this.onError,this),t.off(S.ERROR,this.onErrorOut,this),t.off(S.MANIFEST_LOADING,this.onManifestLoading,this),t.off(S.LEVEL_UPDATED,this.onLevelUpdated,this))},e.destroy=function(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}},e.startLoad=function(t){this.playlistError=0},e.stopLoad=function(){},e.getVariantLevelIndex=function(t){return(null==t?void 0:t.type)===ae.MAIN?t.level:this.hls.loadLevel},e.onManifestLoading=function(){this.playlistError=0,this.penalizedRenditions={}},e.onLevelUpdated=function(){this.playlistError=0},e.onError=function(t,e){var r,i;if(!e.fatal){var a=this.hls,n=e.context;switch(e.details){case R.FRAG_LOAD_ERROR:case R.FRAG_LOAD_TIMEOUT:case R.KEY_LOAD_ERROR:case R.KEY_LOAD_TIMEOUT:return void(e.errorAction=this.getFragRetryOrSwitchAction(e));case R.FRAG_PARSING_ERROR:if(null!=(r=e.frag)&&r.gap)return void(e.errorAction={action:$e.DoNothing,flags:Ze.None});case R.FRAG_GAP:case R.FRAG_DECRYPT_ERROR:return e.errorAction=this.getFragRetryOrSwitchAction(e),void(e.errorAction.action=$e.SendAlternateToPenaltyBox);case R.LEVEL_EMPTY_ERROR:case R.LEVEL_PARSING_ERROR:var s,o,l=e.parent===ae.MAIN?e.level:a.loadLevel;return void(e.details===R.LEVEL_EMPTY_ERROR&&null!=(s=e.context)&&null!=(o=s.levelDetails)&&o.live?e.errorAction=this.getPlaylistRetryOrSwitchAction(e,l):(e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,l)));case R.LEVEL_LOAD_ERROR:case R.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==n?void 0:n.level)&&(e.errorAction=this.getPlaylistRetryOrSwitchAction(e,n.level)));case R.AUDIO_TRACK_LOAD_ERROR:case R.AUDIO_TRACK_LOAD_TIMEOUT:case R.SUBTITLE_LOAD_ERROR:case R.SUBTITLE_TRACK_LOAD_TIMEOUT:if(n){var u=a.levels[a.loadLevel];if(u&&(n.type===ie.AUDIO_TRACK&&n.groupId===u.audioGroupId||n.type===ie.SUBTITLE_TRACK&&n.groupId===u.textGroupId))return e.errorAction=this.getPlaylistRetryOrSwitchAction(e,a.loadLevel),e.errorAction.action=$e.SendAlternateToPenaltyBox,void(e.errorAction.flags=Ze.MoveAllAlternatesMatchingHost)}return;case R.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:var d=a.levels[a.loadLevel],h=null==d?void 0:d.attrs["HDCP-LEVEL"];return void(h&&(e.errorAction={action:$e.SendAlternateToPenaltyBox,flags:Ze.MoveAllAlternatesMatchingHDCP,hdcpLevel:h}));case R.BUFFER_ADD_CODEC_ERROR:case R.REMUX_ALLOC_ERROR:return void(e.errorAction=this.getLevelSwitchAction(e,null!=(i=e.level)?i:a.loadLevel));case R.INTERNAL_EXCEPTION:case R.BUFFER_APPENDING_ERROR:case R.BUFFER_APPEND_ERROR:case R.BUFFER_FULL_ERROR:case R.LEVEL_SWITCH_ERROR:case R.BUFFER_STALLED_ERROR:case R.BUFFER_SEEK_OVER_HOLE:case R.BUFFER_NUDGE_ON_STALL:return void(e.errorAction={action:$e.DoNothing,flags:Ze.None})}if(e.type===A.KEY_SYSTEM_ERROR){var f=this.getVariantLevelIndex(e.frag);return e.levelRetry=!1,void(e.errorAction=this.getLevelSwitchAction(e,f))}}},e.getPlaylistRetryOrSwitchAction=function(t,e){var r,i=Ue(this.hls.config.playlistLoadPolicy,t),a=this.playlistError++,n=null==(r=t.response)?void 0:r.code;if(Ve(i,a,Be(t),n))return{action:$e.RetryRequest,flags:Ze.None,retryConfig:i,retryCount:a};var s=this.getLevelSwitchAction(t,e);return i&&(s.retryConfig=i,s.retryCount=a),s},e.getFragRetryOrSwitchAction=function(t){var e=this.hls,r=this.getVariantLevelIndex(t.frag),i=e.levels[r],a=e.config,n=a.fragLoadPolicy,s=a.keyLoadPolicy,o=Ue(t.details.startsWith("key")?s:n,t),l=e.levels.reduce((function(t,e){return t+e.fragmentError}),0);if(i){var u;t.details!==R.FRAG_GAP&&i.fragmentError++;var d=null==(u=t.response)?void 0:u.code;if(Ve(o,l,Be(t),d))return{action:$e.RetryRequest,flags:Ze.None,retryConfig:o,retryCount:l}}var h=this.getLevelSwitchAction(t,r);return o&&(h.retryConfig=o,h.retryCount=l),h},e.getLevelSwitchAction=function(t,e){var r=this.hls;null==e&&(e=r.loadLevel);var i=this.hls.levels[e];if(i&&(i.loadError++,r.autoLevelEnabled)){for(var a,n,s=-1,o=r.levels,l=r.loadLevel,u=r.minAutoLevel,d=r.maxAutoLevel,h=null==(a=t.frag)?void 0:a.type,f=null!=(n=t.context)?n:{},c=f.type,v=f.groupId,g=o.length;g--;){var m=(g+l)%o.length;if(m!==l&&m>=u&&m<=d&&0===o[m].loadError){var p=o[m];if(t.details===R.FRAG_GAP&&t.frag){var y=o[m].details;if(y){var E=je(t.frag,y.fragments,t.frag.start);if(null!=E&&E.gap)continue}}else{if(c===ie.AUDIO_TRACK&&v===p.audioGroupId||c===ie.SUBTITLE_TRACK&&v===p.textGroupId)continue;if(h===ae.AUDIO&&i.audioGroupId===p.audioGroupId||h===ae.SUBTITLE&&i.textGroupId===p.textGroupId)continue}s=m;break}}if(s>-1&&r.loadLevel!==s)return t.levelRetry=!0,this.playlistError=0,{action:$e.SendAlternateToPenaltyBox,flags:Ze.None,nextAutoLevel:s}}return{action:$e.SendAlternateToPenaltyBox,flags:Ze.MoveAllAlternatesMatchingHost}},e.onErrorOut=function(t,e){var r;switch(null==(r=e.errorAction)?void 0:r.action){case $e.DoNothing:break;case $e.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(e),e.errorAction.resolved||e.details===R.FRAG_GAP||(e.fatal=!0)}e.fatal&&this.hls.stopLoad()},e.sendAlternateToPenaltyBox=function(t){var e=this.hls,r=t.errorAction;if(r){var i=r.flags,a=r.hdcpLevel,n=r.nextAutoLevel;switch(i){case Ze.None:this.switchLevel(t,n);break;case Ze.MoveAllAlternatesMatchingHost:r.resolved||(r.resolved=this.redundantFailover(t));break;case Ze.MoveAllAlternatesMatchingHDCP:a&&(e.maxHdcpLevel=Le[Le.indexOf(a)-1],r.resolved=!0),this.warn('Restricting playback to HDCP-LEVEL of "'+e.maxHdcpLevel+'" or lower')}r.resolved||this.switchLevel(t,n)}},e.switchLevel=function(t,e){void 0!==e&&t.errorAction&&(this.warn("switching to level "+e+" after "+t.details),this.hls.nextAutoLevel=e,t.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)},e.redundantFailover=function(t){var e=this,r=this.hls,i=this.penalizedRenditions,a=t.parent===ae.MAIN?t.level:r.loadLevel,n=r.levels[a],s=n.url.length,o=t.frag?t.frag.urlId:n.urlId;n.urlId!==o||t.frag&&!n.details||this.penalizeRendition(n,t);for(var l=function(){var l=(o+u)%s,d=i[l];if(!d||tr(d,t,i[o]))return e.warn("Switching to Redundant Stream "+(l+1)+"/"+s+': "'+n.url[l]+'" after '+t.details),e.playlistError=0,r.levels.forEach((function(t){t.urlId=l})),r.nextLoadLevel=a,{v:!0}},u=1;u<s;u++){var d=l();if("object"==typeof d)return d.v}return!1},e.penalizeRendition=function(t,e){var r=this.penalizedRenditions,i=r[t.urlId]||{lastErrorPerfMs:0,errors:[],details:void 0};i.lastErrorPerfMs=performance.now(),i.errors.push(e),i.details=t.details,r[t.urlId]=i},t}();function tr(t,e,r){if(performance.now()-t.lastErrorPerfMs>Qe)return!0;var i=t.details;if(e.details===R.FRAG_GAP&&i&&e.frag){var a=e.frag.start,n=je(null,i.fragments,a);if(n&&!n.gap)return!0}if(r&&t.errors.length<r.errors.length){var s=t.errors[t.errors.length-1];if(i&&s.frag&&e.frag&&Math.abs(s.frag.start-e.frag.start)>3*i.targetduration)return!0}return!1}var er,rr=function(t){function e(e,r){var i;return(i=t.call(this,e,"[level-controller]")||this)._levels=[],i._firstLevel=-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(e,t);var r=e.prototype;return r._registerListeners=function(){var t=this.hls;t.on(S.MANIFEST_LOADING,this.onManifestLoading,this),t.on(S.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(S.LEVEL_LOADED,this.onLevelLoaded,this),t.on(S.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(S.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(S.FRAG_LOADED,this.onFragLoaded,this),t.on(S.ERROR,this.onError,this)},r._unregisterListeners=function(){var t=this.hls;t.off(S.MANIFEST_LOADING,this.onManifestLoading,this),t.off(S.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(S.LEVEL_LOADED,this.onLevelLoaded,this),t.off(S.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(S.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(S.FRAG_LOADED,this.onFragLoaded,this),t.off(S.ERROR,this.onError,this)},r.destroy=function(){this._unregisterListeners(),this.steering=null,this.resetLevels(),t.prototype.destroy.call(this)},r.startLoad=function(){this._levels.forEach((function(t){t.loadError=0,t.fragmentError=0})),t.prototype.startLoad.call(this)},r.resetLevels=function(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[]},r.onManifestLoading=function(t,e){this.resetLevels()},r.onManifestLoaded=function(t,e){var r,i=[],a={};e.levels.forEach((function(t){var e,n=t.attrs;-1!==(null==(e=t.audioCodec)?void 0:e.indexOf("mp4a.40.34"))&&(er||(er=/chrome|firefox/i.test(navigator.userAgent)),er&&(t.audioCodec=void 0));var s=n.AUDIO,o=n.CODECS,l=n["FRAME-RATE"];n["PATHWAY-ID"];var u=n.RESOLUTION,d=n.SUBTITLES,h=t.bitrate+"-"+u+"-"+l+"-"+o;(r=a[h])?r.addFallback(t):(r=new be(t),a[h]=r,i.push(r)),ir(r,"audio",s),ir(r,"text",d)})),this.filterAndSortMediaOptions(i,e)},r.filterAndSortMediaOptions=function(t,e){var r=this,i=[],a=[],n=!1,s=!1,o=!1,l=t.filter((function(t){var e=t.audioCodec,r=t.videoCodec,i=t.width,a=t.height,l=t.unknownCodecs;return n||(n=!(!i||!a)),s||(s=!!r),o||(o=!!e),!(null!=l&&l.length)&&(!e||Vt(e,"audio"))&&(!r||Vt(r,"video"))}));if((n||s)&&o&&(l=l.filter((function(t){var e=t.videoCodec,r=t.width,i=t.height;return!!e||!(!r||!i)}))),0!==l.length){e.audioTracks&&ar(i=e.audioTracks.filter((function(t){return!t.audioCodec||Vt(t.audioCodec,"audio")}))),e.subtitles&&ar(a=e.subtitles);var u=l.slice(0);l.sort((function(t,e){return t.attrs["HDCP-LEVEL"]!==e.attrs["HDCP-LEVEL"]?(t.attrs["HDCP-LEVEL"]||"")>(e.attrs["HDCP-LEVEL"]||"")?1:-1:t.bitrate!==e.bitrate?t.bitrate-e.bitrate:t.attrs["FRAME-RATE"]!==e.attrs["FRAME-RATE"]?t.attrs.decimalFloatingPoint("FRAME-RATE")-e.attrs.decimalFloatingPoint("FRAME-RATE"):t.attrs.SCORE!==e.attrs.SCORE?t.attrs.decimalFloatingPoint("SCORE")-e.attrs.decimalFloatingPoint("SCORE"):n&&t.height!==e.height?t.height-e.height:0}));var d=u[0];if(this.steering&&(l=this.steering.filterParsedLevels(l)).length!==u.length)for(var h=0;h<u.length;h++)if(u[h].pathwayId===l[0].pathwayId){d=u[h];break}this._levels=l;for(var f=0;f<l.length;f++)if(l[f]===d){this._firstLevel=f,this.log("manifest loaded, "+l.length+" level(s) found, first bitrate: "+d.bitrate);break}var c=o&&!s,v={levels:l,audioTracks:i,subtitleTracks:a,sessionData:e.sessionData,sessionKeys:e.sessionKeys,firstLevel:this._firstLevel,stats:e.stats,audio:o,video:s,altAudio:!c&&i.some((function(t){return!!t.url}))};this.hls.trigger(S.MANIFEST_PARSED,v),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else Promise.resolve().then((function(){if(r.hls){var t=new Error("no level with compatible codecs found in manifest");r.hls.trigger(S.ERROR,{type:A.MEDIA_ERROR,details:R.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:e.url,error:t,reason:t.message})}}))},r.onError=function(t,e){!e.fatal&&e.context&&e.context.type===ie.LEVEL&&e.context.level===this.level&&this.checkRetry(e)},r.onFragLoaded=function(t,e){var r=e.frag;if(void 0!==r&&r.type===ae.MAIN){var i=this._levels[r.level];void 0!==i&&(i.loadError=0)}},r.onLevelLoaded=function(t,e){var r,i,a=e.level,n=e.details,s=this._levels[a];if(!s)return this.warn("Invalid level index "+a),void(null!=(i=e.deliveryDirectives)&&i.skip&&(n.deltaUpdateFailed=!0));a===this.currentLevelIndex?(0===s.fragmentError&&(s.loadError=0),this.playlistLoaded(a,e,s.details)):null!=(r=e.deliveryDirectives)&&r.skip&&(n.deltaUpdateFailed=!0)},r.onAudioTrackSwitched=function(t,e){var r=this.currentLevel;if(r){var i=this.hls.audioTracks[e.id].groupId;if(r.audioGroupIds&&r.audioGroupId!==i){for(var a=-1,n=0;n<r.audioGroupIds.length;n++)if(r.audioGroupIds[n]===i){a=n;break}-1!==a&&a!==r.urlId&&(r.urlId=a,this.canLoad&&this.startLoad())}}},r.loadPlaylist=function(e){t.prototype.loadPlaylist.call(this);var r=this.currentLevelIndex,i=this.currentLevel;if(i&&this.shouldLoadPlaylist(i)){var a=i.urlId,n=i.uri;if(e)try{n=e.addDirectives(n)}catch(t){this.warn("Could not construct new URL with HLS Delivery Directives: "+t)}var s=i.attrs["PATHWAY-ID"];this.log("Loading level index "+r+(void 0!==(null==e?void 0:e.msn)?" at sn "+e.msn+" part "+e.part:"")+" with"+(s?" Pathway "+s:"")+" URI "+(a+1)+"/"+i.url.length+" "+n),this.clearTimer(),this.hls.trigger(S.LEVEL_LOADING,{url:n,level:r,id:a,deliveryDirectives:e||null})}},r.removeLevel=function(t,e){var r=this,i=function(t,r){return r!==e},a=this._levels.filter((function(a,n){return n!==t||(a.url.length>1&&void 0!==e?(a.url=a.url.filter(i),a.audioGroupIds&&(a.audioGroupIds=a.audioGroupIds.filter(i)),a.textGroupIds&&(a.textGroupIds=a.textGroupIds.filter(i)),a.urlId=0,!0):(r.steering&&r.steering.removeLevel(a),!1))}));this.hls.trigger(S.LEVELS_UPDATED,{levels:a})},r.onLevelsUpdated=function(t,e){var r=e.levels;r.forEach((function(t,e){var r=t.details;null!=r&&r.fragments&&r.fragments.forEach((function(t){t.level=e}))})),this._levels=r},n(e,[{key:"levels",get:function(){return 0===this._levels.length?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(t){var e=this._levels;if(0!==e.length){if(t<0||t>=e.length){var r=new Error("invalid level idx"),i=t<0;if(this.hls.trigger(S.ERROR,{type:A.OTHER_ERROR,details:R.LEVEL_SWITCH_ERROR,level:t,fatal:i,error:r,reason:r.message}),i)return;t=Math.min(t,e.length-1)}var a=this.currentLevelIndex,n=this.currentLevel,s=n?n.attrs["PATHWAY-ID"]:void 0,l=e[t],u=l.attrs["PATHWAY-ID"];if(this.currentLevelIndex=t,this.currentLevel=l,a!==t||!l.details||!n||s!==u){this.log("Switching to level "+t+(u?" with Pathway "+u:"")+" from level "+a+(s?" with Pathway "+s:""));var d=o({},l,{level:t,maxBitrate:l.maxBitrate,attrs:l.attrs,uri:l.uri,urlId:l.urlId});delete d._attrs,delete d._urlId,this.hls.trigger(S.LEVEL_SWITCHING,d);var h=l.details;if(!h||h.live){var f=this.switchParams(l.uri,null==n?void 0:n.details);this.loadPlaylist(f)}}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(t){this.manualLevelIndex=t,void 0===this._startLevel&&(this._startLevel=t),-1!==t&&(this.level=t)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(t){this._firstLevel=t}},{key:"startLevel",get:function(){if(void 0===this._startLevel){var t=this.hls.config.startLevel;return void 0!==t?t:this._firstLevel}return this._startLevel},set:function(t){this._startLevel=t}},{key:"nextLoadLevel",get:function(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(t){this.level=t,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=t)}}]),e}(function(){function t(t,e){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=w.log.bind(w,e+":"),this.warn=w.warn.bind(w,e+":"),this.hls=t}var e=t.prototype;return e.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},e.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},e.startLoad=function(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()},e.stopLoad=function(){this.canLoad=!1,this.clearTimer()},e.switchParams=function(t,e){var r=null==e?void 0:e.renditionReports;if(r){for(var i=-1,a=0;a<r.length;a++){var n=r[a],s=void 0;try{s=new self.URL(n.URI,e.url).href}catch(t){w.warn("Could not construct new URL for Rendition Report: "+t),s=n.URI||""}if(s===t){i=a;break}s===t.substring(0,s.length)&&(i=a)}if(-1!==i){var o=r[i],l=parseInt(o["LAST-MSN"])||(null==e?void 0:e.lastPartSn),u=parseInt(o["LAST-PART"])||(null==e?void 0:e.lastPartIndex);if(this.hls.config.lowLatencyMode){var d=Math.min(e.age-e.partTarget,e.targetduration);u>=0&&d>e.partTarget&&(u+=1)}return new Re(l,u>=0?u:void 0,Se.No)}}},e.loadPlaylist=function(t){-1===this.requestScheduled&&(this.requestScheduled=self.performance.now())},e.shouldLoadPlaylist=function(t){return this.canLoad&&!!t&&!!t.url&&(!t.details||t.details.live)},e.shouldReloadPlaylist=function(t){return-1===this.timer&&-1===this.requestScheduled&&this.shouldLoadPlaylist(t)},e.playlistLoaded=function(t,e,r){var i=this,a=e.details,n=e.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 "+t+" "+(a.advanced?"REFRESHED "+a.lastPartSn+"-"+a.lastPartIndex:a.updated?"UPDATED":"MISSED")),r&&a.fragments.length>0&&Ie(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,e.deliveryDirectives,u,d),h||!g)return void this.loadPlaylist(l)}else(a.canBlockReload||a.canSkipUntil)&&(l=this.getDeliveryDirectives(a,e.deliveryDirectives,u,d));var T=this.hls.mainForwardBufferInfo,L=T?T.end-T.len:0,S=Oe(a,1e3*(a.edge-L));a.updated&&s>this.requestScheduled+S&&(this.requestScheduled=n.loading.start),void 0!==u&&a.canBlockReload?this.requestScheduled=n.loading.first+S-(1e3*a.partTarget||1e3):-1===this.requestScheduled||this.requestScheduled+S<s?this.requestScheduled=s:this.requestScheduled-s<=0&&(this.requestScheduled+=S);var A=this.requestScheduled-s;A=Math.max(0,A),this.log("reload live playlist "+t+" in "+Math.round(A)+" ms"),this.timer=self.setTimeout((function(){return i.loadPlaylist(l)}),A)}else this.clearTimer()},e.getDeliveryDirectives=function(t,e,r,i){var a=Ae(t,r);return null!=e&&e.skip&&t.deltaUpdateFailed&&(r=e.msn,i=e.part,a=Se.No),new Re(r,i,a)},e.checkRetry=function(t){var e=this,r=t.details,i=Be(t),a=t.errorAction,n=a||{},s=n.action,o=n.retryCount,l=void 0===o?0:o,u=n.retryConfig,d=!!a&&!!u&&(s===$e.RetryRequest||!a.resolved&&s===$e.SendAlternateToPenaltyBox);if(d){var h;if(this.requestScheduled=-1,l>=u.maxNumRetry)return!1;if(i&&null!=(h=t.context)&&h.deliveryDirectives)this.warn("Retrying playlist loading "+(l+1)+"/"+u.maxNumRetry+' after "'+r+'" without delivery-directives'),this.loadPlaylist();else{var f=Ge(u,l);this.timer=self.setTimeout((function(){return e.loadPlaylist()}),f),this.warn("Retrying playlist loading "+(l+1)+"/"+u.maxNumRetry+' after "'+r+'" in '+f+"ms")}t.levelRetry=!0,a.resolved=!0}return d},t}());function ir(t,e,r){r&&("audio"===e?(t.audioGroupIds||(t.audioGroupIds=[]),t.audioGroupIds[t.url.length-1]=r):"text"===e&&(t.textGroupIds||(t.textGroupIds=[]),t.textGroupIds[t.url.length-1]=r))}function ar(t){var e={};t.forEach((function(t){var r=t.groupId||"";t.id=e[r]=e[r]||0,e[r]++}))}var nr={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"},sr=function(){function t(t){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=t,this._registerListeners()}var e=t.prototype;return e._registerListeners=function(){var t=this.hls;t.on(S.BUFFER_APPENDED,this.onBufferAppended,this),t.on(S.FRAG_BUFFERED,this.onFragBuffered,this),t.on(S.FRAG_LOADED,this.onFragLoaded,this)},e._unregisterListeners=function(){var t=this.hls;t.off(S.BUFFER_APPENDED,this.onBufferAppended,this),t.off(S.FRAG_BUFFERED,this.onFragBuffered,this),t.off(S.FRAG_LOADED,this.onFragLoaded,this)},e.destroy=function(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null},e.getAppendedFrag=function(t,e){var r=this.activePartLists[e];if(r)for(var i=r.length;i--;){var a=r[i];if(!a)break;var n=a.end;if(a.start<=t&&null!==n&&t<=n)return a}return this.getBufferedFrag(t,e)},e.getBufferedFrag=function(t,e){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)===e&&n.buffered){var s=n.body;if(s.start<=t&&t<=s.end)return s}}return null},e.detectEvictedFragments=function(t,e,r,i){var a=this;this.timeRanges&&(this.timeRanges[t]=e);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[t];o&&o.time.some((function(t){var r=!a.isTimeBuffered(t.startPTS,t.endPTS,e);return r&&a.removeFragment(s.body),r}))}else s.body.type===r&&a.removeFragment(s.body)}))},e.detectPartialFragments=function(t){var e=this,r=this.timeRanges,i=t.frag,a=t.part;if(r&&"initSegment"!==i.sn){var n=lr(i),s=this.fragments[n];if(!(!s||s.buffered&&i.gap)){var o=!i.relurl;Object.keys(r).forEach((function(t){var n=i.elementaryStreams[t];if(n){var l=r[t],u=o||!0===n.partial;s.range[t]=e.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),or(s)||this.removeParts(i.sn-1,i.type)):this.removeFragment(s.body)}}},e.removeParts=function(t,e){var r=this.activePartLists[e];r&&(this.activePartLists[e]=r.filter((function(e){return e.fragment.sn>=t})))},e.fragBuffered=function(t,e){var r=lr(t),i=this.fragments[r];!i&&e&&(i=this.fragments[r]={body:t,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},t.gap&&(this.hasGaps=!0)),i&&(i.loaded=null,i.buffered=!0)},e.getBufferedTimes=function(t,e,r,i){for(var a={time:[],partial:r},n=t.start,s=t.end,o=t.minEndPTS||s,l=t.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)a.partial=!0,a.time.push({startPTS:Math.max(n,i.start(u)),endPTS:Math.min(s,i.end(u))});else if(s<=d)break}return a},e.getPartialFragment=function(t){var e,r,i,a=null,n=0,s=this.bufferPadding,o=this.fragments;return Object.keys(o).forEach((function(l){var u=o[l];u&&or(u)&&(r=u.body.start-s,i=u.body.end+s,t>=r&&t<=i&&(e=Math.min(t-r,i-t),n<=e&&(a=u.body,n=e)))})),a},e.isEndListAppended=function(t){var e=this.endListFragments[t];return void 0!==e&&(e.buffered||or(e))},e.getState=function(t){var e=lr(t),r=this.fragments[e];return r?r.buffered?or(r)?nr.PARTIAL:nr.OK:nr.APPENDING:nr.NOT_LOADED},e.isTimeBuffered=function(t,e,r){for(var i,a,n=0;n<r.length;n++){if(i=r.start(n)-this.bufferPadding,a=r.end(n)+this.bufferPadding,t>=i&&e<=a)return!0;if(e<=i)return!1}return!1},e.onFragLoaded=function(t,e){var r=e.frag,i=e.part;if("initSegment"!==r.sn&&!r.bitrateTest){var a=i?null:e,n=lr(r);this.fragments[n]={body:r,appendedPTS:null,loaded:a,buffered:!1,range:Object.create(null)}}},e.onBufferAppended=function(t,e){var r=this,i=e.frag,a=e.part,n=e.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(t){var e=n[t];r.detectEvictedFragments(t,e,s,a)}))}},e.onFragBuffered=function(t,e){this.detectPartialFragments(e)},e.hasFragment=function(t){var e=lr(t);return!!this.fragments[e]},e.hasParts=function(t){var e;return!(null==(e=this.activePartLists[t])||!e.length)},e.removeFragmentsInRange=function(t,e,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<e&&l.end>t&&(o.buffered||a)&&n.removeFragment(l)}}))},e.removeFragment=function(t){var e=lr(t);t.stats.loaded=0,t.clearElementaryStreamInfo();var r=this.activePartLists[t.type];if(r){var i=t.sn;this.activePartLists[t.type]=r.filter((function(t){return t.fragment.sn!==i}))}delete this.fragments[e],t.endList&&delete this.endListFragments[t.type]},e.removeAllFragments=function(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1},t}();function or(t){var e,r,i;return t.buffered&&(t.body.gap||(null==(e=t.range.video)?void 0:e.partial)||(null==(r=t.range.audio)?void 0:r.partial)||(null==(i=t.range.audiovideo)?void 0:i.partial))}function lr(t){return t.type+"_"+t.level+"_"+t.urlId+"_"+t.sn}var ur=Math.pow(2,17),dr=function(){function t(t){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=t}var e=t.prototype;return e.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},e.abort=function(){this.loader&&this.loader.abort()},e.load=function(t,e){var r=this,a=t.url;if(!a)return Promise.reject(new cr({type:A.NETWORK_ERROR,details:R.FRAG_LOAD_ERROR,fatal:!1,frag:t,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(),t.gap){if(t.tagList.some((function(t){return"GAP"===t[0]})))return void u(fr(t));t.gap=!1}var d=r.loader=t.loader=s?new s(n):new o(n),h=hr(t),f=Ke(n.fragLoadPolicy.default),c={loadPolicy:f,timeout:f.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===t.sn?1/0:ur};t.stats=d.stats,d.load(h,c,{onSuccess:function(e,i,a,n){r.resetLoader(t,d);var s=e.data;a.resetIV&&t.decryptdata&&(t.decryptdata.iv=new Uint8Array(s.slice(0,16)),s=s.slice(16)),l({frag:t,part:null,payload:s,networkDetails:n})},onError:function(e,n,s,o){r.resetLoader(t,d),u(new cr({type:A.NETWORK_ERROR,details:R.FRAG_LOAD_ERROR,fatal:!1,frag:t,response:i({url:a,data:void 0},e),error:new Error("HTTP Error "+e.code+" "+e.text),networkDetails:s,stats:o}))},onAbort:function(e,i,a){r.resetLoader(t,d),u(new cr({type:A.NETWORK_ERROR,details:R.INTERNAL_ABORTED,fatal:!1,frag:t,error:new Error("Aborted"),networkDetails:a,stats:e}))},onTimeout:function(e,i,a){r.resetLoader(t,d),u(new cr({type:A.NETWORK_ERROR,details:R.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,error:new Error("Timeout after "+c.timeout+"ms"),networkDetails:a,stats:e}))},onProgress:function(r,i,a,n){e&&e({frag:t,part:null,payload:a,networkDetails:n})}})}))},e.loadPart=function(t,e,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(),t.gap||e.gap)u(fr(t,e));else{var d=a.loader=t.loader=s?new s(n):new o(n),h=hr(t,e),f=Ke(n.fragLoadPolicy.default),c={loadPolicy:f,timeout:f.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:ur};e.stats=d.stats,d.load(h,c,{onSuccess:function(i,n,s,o){a.resetLoader(t,d),a.updateStatsFromPart(t,e);var u={frag:t,part:e,payload:i.data,networkDetails:o};r(u),l(u)},onError:function(r,n,s,o){a.resetLoader(t,d),u(new cr({type:A.NETWORK_ERROR,details:R.FRAG_LOAD_ERROR,fatal:!1,frag:t,part:e,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){t.stats.aborted=e.stats.aborted,a.resetLoader(t,d),u(new cr({type:A.NETWORK_ERROR,details:R.INTERNAL_ABORTED,fatal:!1,frag:t,part:e,error:new Error("Aborted"),networkDetails:n,stats:r}))},onTimeout:function(r,i,n){a.resetLoader(t,d),u(new cr({type:A.NETWORK_ERROR,details:R.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,part:e,error:new Error("Timeout after "+c.timeout+"ms"),networkDetails:n,stats:r}))}})}}))},e.updateStatsFromPart=function(t,e){var r=t.stats,i=e.stats,a=i.total;if(r.loaded+=i.loaded,a){var n=Math.round(t.duration/e.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},e.resetLoader=function(t,e){t.loader=null,this.loader===e&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),e.destroy()},t}();function hr(t,e){void 0===e&&(e=null);var r=e||t,i={frag:t,part:e,responseType:"arraybuffer",url:r.url,headers:{},rangeStart:0,rangeEnd:0},a=r.byteRangeStartOffset,n=r.byteRangeEndOffset;if(L(a)&&L(n)){var s,o=a,l=n;if("initSegment"===t.sn&&"AES-128"===(null==(s=t.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 fr(t,e){var r=new Error("GAP "+(t.gap?"tag":"attribute")+" found"),i={type:A.MEDIA_ERROR,details:R.FRAG_GAP,fatal:!1,frag:t,error:r,networkDetails:null};return e&&(i.part=e),(e||t).stats.aborted=!0,new cr(i)}var cr=function(t){function e(e){var r;return(r=t.call(this,e.error.message)||this).data=void 0,r.data=e,r}return l(e,t),e}(v(Error)),vr=function(){function t(t){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=t}var e=t.prototype;return e.abort=function(t){for(var e in this.keyUriToKeyInfo){var r=this.keyUriToKeyInfo[e].loader;if(r){if(t&&t!==r.context.frag.type)return;r.abort()}}},e.detach=function(){for(var t in this.keyUriToKeyInfo){var e=this.keyUriToKeyInfo[t];(e.mediaKeySessionContext||e.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[t]}},e.destroy=function(){for(var t in this.detach(),this.keyUriToKeyInfo){var e=this.keyUriToKeyInfo[t].loader;e&&e.destroy()}this.keyUriToKeyInfo={}},e.createKeyLoadError=function(t,e,r,i,a){return void 0===e&&(e=R.KEY_LOAD_ERROR),new cr({type:A.NETWORK_ERROR,details:e,fatal:!1,frag:t,response:a,error:r,networkDetails:i})},e.loadClear=function(t,e){var r=this;if(this.emeController&&this.config.emeEnabled)for(var i=t.sn,a=t.cc,n=function(){var t=e[s];if(a<=t.cc&&("initSegment"===i||"initSegment"===t.sn||i<t.sn))return r.emeController.selectKeySystemFormat(t).then((function(e){t.setKeyFormat(e)})),"break"},s=0;s<e.length&&"break"!==n();s++);},e.load=function(t){var e=this;return!t.decryptdata&&t.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(t).then((function(r){return e.loadInternal(t,r)})):this.loadInternal(t)},e.loadInternal=function(t,e){var r,i;e&&t.setKeyFormat(e);var a=t.decryptdata;if(!a){var n=new Error(e?"Expected frag.decryptdata to be defined after setting format "+e:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(t,R.KEY_LOAD_ERROR,n))}var s=a.uri;if(!s)return Promise.reject(this.createKeyLoadError(t,R.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:t,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(e){return a.key=e.keyInfo.decryptdata.key,{frag:t,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,t):this.loadKeyEME(l,t);case"AES-128":return this.loadKeyHTTP(l,t);default:return Promise.reject(this.createKeyLoadError(t,R.KEY_LOAD_ERROR,new Error('Key supplied with unsupported METHOD: "'+a.method+'"')))}},e.loadKeyEME=function(t,e){var r={frag:e,keyInfo:t};if(this.emeController&&this.config.emeEnabled){var i=this.emeController.loadKey(r);if(i)return(t.keyLoadPromise=i.then((function(e){return t.mediaKeySessionContext=e,r}))).catch((function(e){throw t.keyLoadPromise=null,e}))}return Promise.resolve(r)},e.loadKeyHTTP=function(t,e){var r=this,a=this.config,n=new(0,a.loader)(a);return e.keyLoader=t.loader=n,t.keyLoadPromise=new Promise((function(s,o){var l={keyInfo:t,frag:e,responseType:"arraybuffer",url:t.decryptdata.uri},u=a.keyLoadPolicy.default,d={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},h={onSuccess:function(t,e,i,a){var n=i.frag,l=i.keyInfo,u=i.url;if(!n.decryptdata||l!==r.keyUriToKeyInfo[u])return o(r.createKeyLoadError(n,R.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),a));l.decryptdata.key=n.decryptdata.key=new Uint8Array(t.data),n.keyLoader=null,l.loader=null,s({frag:n,keyInfo:l})},onError:function(t,a,n,s){r.resetLoader(a),o(r.createKeyLoadError(e,R.KEY_LOAD_ERROR,new Error("HTTP Error "+t.code+" loading key "+t.text),n,i({url:l.url,data:void 0},t)))},onTimeout:function(t,i,a){r.resetLoader(i),o(r.createKeyLoadError(e,R.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),a))},onAbort:function(t,i,a){r.resetLoader(i),o(r.createKeyLoadError(e,R.INTERNAL_ABORTED,new Error("key loading aborted"),a))}};n.load(l,d,h)}))},e.resetLoader=function(t){var e=t.frag,r=t.keyInfo,i=t.url,a=r.loader;e.keyLoader===a&&(e.keyLoader=null,r.loader=null),delete this.keyUriToKeyInfo[i],a&&a.destroy()},t}(),gr=function(){function t(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var e=t.prototype;return e.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},e.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},e.onHandlerDestroyed=function(){},e.hasInterval=function(){return!!this._tickInterval},e.hasNextTick=function(){return!!this._tickTimer},e.setInterval=function(t){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,t),!0)},e.clearInterval=function(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)},e.clearNextTick=function(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)},e.tick=function(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},e.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},e.doTick=function(){},t}(),mr={length:0,start:function(){return 0},end:function(){return 0}},pr=function(){function t(){}return t.isBuffered=function(e,r){try{if(e)for(var i=t.getBuffered(e),a=0;a<i.length;a++)if(r>=i.start(a)&&r<=i.end(a))return!0}catch(t){}return!1},t.bufferInfo=function(e,r,i){try{if(e){var a,n=t.getBuffered(e),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(t){}return{len:0,start:r,end:r,nextStart:void 0}},t.bufferedInfo=function(t,e,r){e=Math.max(0,e),t.sort((function(t,e){var r=t.start-e.start;return r||e.end-t.end}));var i=[];if(r)for(var a=0;a<t.length;a++){var n=i.length;if(n){var s=i[n-1].end;t[a].start-s<r?t[a].end>s&&(i[n-1].end=t[a].end):i.push(t[a])}else i.push(t[a])}else i=t;for(var o,l=0,u=e,d=e,h=0;h<i.length;h++){var f=i[h].start,c=i[h].end;if(e+r>=f&&e<c)u=f,l=(d=c)-e;else if(e+r<f){o=f;break}}return{len:l,start:u||0,end:d||0,nextStart:o}},t.getBuffered=function(t){try{return t.buffered}catch(t){return w.log("failed to get media.buffered",t),mr}},t}(),yr=function(t,e,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=Er(),this.buffering={audio:Er(),video:Er(),audiovideo:Er()},this.level=t,this.sn=e,this.id=r,this.size=i,this.part=a,this.partial=n};function Er(){return{start:0,executeStart:0,executeEnd:0,end:0}}function Tr(t,e){for(var r=null,i=0,a=t.length;i<a;i++){var n=t[i];if(n&&n.cc===e){r=n;break}}return r}function Lr(t,e,r){return!(!e.details||!(r.endCC>r.startCC||t&&t.cc<r.startCC))}function Sr(t,e,r){var i=t.fragments,a=e.fragments;if(a.length&&i.length){var n=Tr(i,a[0].cc);if(n&&(!n||n.startPTS))return n;w.log("No frag in previous level to align on")}else w.log("No fragments to align")}function Ar(t,e){if(t){var r=t.start+e;t.start=t.startPTS=r,t.endPTS=r+t.duration}}function Rr(t,e){for(var r=e.fragments,i=0,a=r.length;i<a;i++)Ar(r[i],t);e.fragmentHint&&Ar(e.fragmentHint,t),e.alignedSliding=!0}function br(t,e,r){e&&(Dr(t,r,e),!r.alignedSliding&&e.details&&kr(r,e.details),r.alignedSliding||!e.details||r.skippedSegments||Ce(e.details,r))}function Dr(t,e,r){if(Lr(t,r,e)){var i=Sr(r.details,e);i&&L(i.start)&&(w.log("Adjusting PTS using last level due to CC increase within current level "+e.url),Rr(i.start,e))}}function kr(t,e){if(e.fragments.length&&t.hasProgramDateTime&&e.hasProgramDateTime){var r=e.fragments[0].programDateTime,i=t.fragments[0].programDateTime,a=(i-r)/1e3+e.fragments[0].start;a&&L(a)&&(w.log("Adjusting PTS using programDateTime delta "+(i-r)+"ms, sliding:"+a.toFixed(3)+" "+t.url+" "),Rr(a,t))}}var Ir=function(){function t(t,e){this.subtle=void 0,this.aesIV=void 0,this.subtle=t,this.aesIV=e}return t.prototype.decrypt=function(t,e){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},e,t)},t}(),_r=function(){function t(t,e){this.subtle=void 0,this.key=void 0,this.subtle=t,this.key=e}return t.prototype.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},t}();function xr(t){var e=t.byteLength,r=e&&new DataView(t.buffer).getUint8(e-1);return r?j(t,0,e-r):t}var wr=function(){function t(){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 e=t.prototype;return e.uint8ArrayToUint32Array_=function(t){for(var e=new DataView(t),r=new Uint32Array(4),i=0;i<4;i++)r[i]=e.getUint32(4*i);return r},e.initTable=function(){var t=this.sBox,e=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,t[c]=m,e[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}},e.expandKey=function(t){for(var e=this.uint8ArrayToUint32Array_(t),r=!0,i=0;i<e.length&&r;)r=e[i]===this.key[i],i++;if(!r){this.key=e;var a=this.keySize=e.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]=e[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}},e.networkToHostOrderSwap=function(t){return t<<24|(65280&t)<<8|(16711680&t)>>8|t>>>24},e.decrypt=function(t,e,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,L=T[0],S=T[1],A=T[2],R=T[3],b=this.uint8ArrayToUint32Array_(r),D=b[0],k=b[1],I=b[2],_=b[3],x=new Int32Array(t),w=new Int32Array(x.length),C=this.networkToHostOrderSwap;e<x.length;){for(h=C(x[e]),f=C(x[e+1]),c=C(x[e+2]),v=C(x[e+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=L[o>>>24]^S[l>>16&255]^A[u>>8&255]^R[255&d]^y[g],a=L[l>>>24]^S[u>>16&255]^A[d>>8&255]^R[255&o]^y[g+1],n=L[u>>>24]^S[d>>16&255]^A[o>>8&255]^R[255&l]^y[g+2],s=L[d>>>24]^S[o>>16&255]^A[l>>8&255]^R[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],w[e]=C(i^D),w[e+1]=C(s^k),w[e+2]=C(n^I),w[e+3]=C(a^_),D=h,k=f,I=c,_=v,e+=4}return w.buffer},t}(),Cr=16,Pr=function(){function t(t,e){var r=(void 0===e?{}:e).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=t.enableSoftwareAES,this.removePKCS7Padding=i,i)try{var a=self.crypto;a&&(this.subtle=a.subtle||a.webkitSubtle)}catch(t){}null===this.subtle&&(this.useSoftware=!0)}var e=t.prototype;return e.destroy=function(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null},e.isSync=function(){return this.useSoftware},e.flush=function(){var t=this.currentResult,e=this.remainderData;if(!t||e)return this.reset(),null;var r=new Uint8Array(t);return this.reset(),this.removePKCS7Padding?xr(r):r},e.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},e.decrypt=function(t,e,r){var i=this;return this.useSoftware?new Promise((function(a,n){i.softwareDecrypt(new Uint8Array(t),e,r);var s=i.flush();s?a(s.buffer):n(new Error("[softwareDecrypt] Failed to decrypt data"))})):this.webCryptoDecrypt(new Uint8Array(t),e,r)},e.softwareDecrypt=function(t,e,r){var i=this.currentIV,a=this.currentResult,n=this.remainderData;this.logOnce("JS AES decrypt"),n&&(t=_t(n,t),this.remainderData=null);var s=this.getValidChunk(t);if(!s.length)return null;i&&(r=i);var o=this.softwareDecrypter;o||(o=this.softwareDecrypter=new wr),o.expandKey(e);var l=a;return this.currentResult=o.decrypt(s.buffer,0,r),this.currentIV=j(s,-16).buffer,l||null},e.webCryptoDecrypt=function(t,e,r){var i=this,a=this.subtle;return this.key===e&&this.fastAesKey||(this.key=e,this.fastAesKey=new _r(a,e)),this.fastAesKey.expandKey().then((function(e){return a?(i.logOnce("WebCrypto AES decrypt"),new Ir(a,new Uint8Array(r)).decrypt(t.buffer,e)):Promise.reject(new Error("web crypto not initialized"))})).catch((function(a){return w.warn("[decrypter]: WebCrypto Error, disable WebCrypto API, "+a.name+": "+a.message),i.onWebCryptoError(t,e,r)}))},e.onWebCryptoError=function(t,e,r){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(t,e,r);var i=this.flush();if(i)return i.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")},e.getValidChunk=function(t){var e=t,r=t.length-t.length%Cr;return r!==t.length&&(e=j(t,0,r),this.remainderData=j(t,r)),e},e.logOnce=function(t){this.logEnabled&&(w.log("[decrypter]: "+t),this.logEnabled=!1)},t}(),Or={toString:function(t){for(var e="",r=t.length,i=0;i<r;i++)e+="["+t.start(i).toFixed(3)+"-"+t.end(i).toFixed(3)+"]";return e}},Fr={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"},Mr=function(t){function e(e,r,i,a,n){var s;return(s=t.call(this)||this).hls=void 0,s.fragPrevious=null,s.fragCurrent=null,s.fragmentTracker=void 0,s.transmuxer=null,s._state=Fr.STOPPED,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=w.log.bind(w,a+":"),s.warn=w.warn.bind(w,a+":"),s.hls=e,s.fragmentLoader=new dr(e.config),s.keyLoader=i,s.fragmentTracker=r,s.config=e.config,s.decrypter=new Pr(e.config),e.on(S.MANIFEST_LOADED,s.onManifestLoaded,g(s)),s}l(e,t);var r=e.prototype;return r.doTick=function(){this.onTickEnd()},r.onTickEnd=function(){},r.startLoad=function(t){},r.stopLoad=function(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);var t=this.fragCurrent;null!=t&&t.loader&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=Fr.STOPPED},r._streamEnded=function(t,e){if(e.live||t.nextStart||!t.end||!this.media)return!1;var r=e.partList;if(null!=r&&r.length){var i=r[r.length-1];return pr.isBuffered(this.media,i.start+i.duration/2)}var a=e.fragments[e.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(a)},r.getLevelDetails=function(){var t;if(this.levels&&null!==this.levelLastLoaded)return null==(t=this.levels[this.levelLastLoaded])?void 0:t.details},r.onMediaAttached=function(t,e){var r=this.media=this.mediaBuffer=e.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===Fr.STOPPED&&this.startLoad(i.startPosition)},r.onMediaDetaching=function(){var t=this.media;null!=t&&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()},r.onMediaSeeking=function(){var t=this.config,e=this.fragCurrent,r=this.media,i=this.mediaBuffer,a=this.state,n=r?r.currentTime:0,s=pr.bufferInfo(i||r,n,t.maxBufferHole);if(this.log("media seeking to "+(L(n)?n.toFixed(3):n)+", state: "+a),this.state===Fr.ENDED)this.resetLoadingState();else if(e){var o=t.maxFragLookUpTolerance,l=e.start-o,u=e.start+e.duration+o;if(!s.len||u<s.start||l>s.end){var d=n>u;(n<l||d)&&(d&&e.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),e.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(t,e){this.startTimeOffset=e.startTimeOffset,this.initPTS=[]},r.onHandlerDestroying=function(){this.stopLoad(),t.prototype.onHandlerDestroying.call(this)},r.onHandlerDestroyed=function(){this.state=Fr.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,t.prototype.onHandlerDestroyed.call(this)},r.loadFragment=function(t,e,r){this._loadFragForPlayback(t,e,r)},r._loadFragForPlayback=function(t,e,r){var i=this,a=function(e){if(i.fragContextChanged(t))return i.warn("Fragment "+t.sn+(e.part?" p: "+e.part.index:"")+" of level "+t.level+" was dropped during download."),void i.fragmentTracker.removeFragment(t);t.stats.chunkCount++,i._handleFragmentLoadProgress(e)};this._doFragLoad(t,e,r,a).then((function(e){if(e){var r=i.state;i.fragContextChanged(t)?(r===Fr.FRAG_LOADING||!i.fragCurrent&&r===Fr.PARSING)&&(i.fragmentTracker.removeFragment(t),i.state=Fr.IDLE):("payload"in e&&(i.log("Loaded fragment "+t.sn+" of level "+t.level),i.hls.trigger(S.FRAG_LOADED,e)),i._handleFragmentLoadComplete(e))}})).catch((function(e){i.state!==Fr.STOPPED&&i.state!==Fr.ERROR&&(i.warn(e),i.resetFragmentLoading(t))}))},r.clearTrackerIfNeeded=function(t){var e,r=this.fragmentTracker;if(r.getState(t)===nr.APPENDING){var i=t.type,a=this.getFwdBufferInfo(this.mediaBuffer,i),n=Math.max(t.duration,a?a.len:this.config.maxBufferLength);this.reduceMaxBufferLength(n)&&r.removeFragment(t)}else 0===(null==(e=this.mediaBuffer)?void 0:e.buffered.length)?r.removeAllFragments():r.hasParts(t.type)&&(r.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type}),r.getState(t)===nr.PARTIAL&&r.removeFragment(t))},r.checkLiveUpdate=function(t){if(t.updated&&!t.live){var e=t.fragments[t.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type})}t.fragments[0]||(t.deltaUpdateFailed=!0)},r.flushMainBuffer=function(t,e,r){if(void 0===r&&(r=null),t-e){var i={startOffset:t,endOffset:e,type:r};this.hls.trigger(S.BUFFER_FLUSHING,i)}},r._loadInitSegment=function(t,e){var r=this;this._doFragLoad(t,e).then((function(e){if(!e||r.fragContextChanged(t)||!r.levels)throw new Error("init load aborted");return e})).then((function(e){var i=r.hls,a=e.payload,n=t.decryptdata;if(a&&a.byteLength>0&&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(e){throw i.trigger(S.ERROR,{type:A.MEDIA_ERROR,details:R.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:t}),e})).then((function(r){var a=self.performance.now();return i.trigger(S.FRAG_DECRYPTED,{frag:t,payload:r,stats:{tstart:s,tdecrypt:a}}),e.payload=r,e}))}return e})).then((function(i){var a=r.fragCurrent,n=r.hls;if(!r.levels)throw new Error("init load aborted, missing levels");var s=t.stats;r.state=Fr.IDLE,e.fragmentError=0,t.data=new Uint8Array(i.payload),s.parsing.start=s.buffering.start=self.performance.now(),s.parsing.end=s.buffering.end=self.performance.now(),i.frag===a&&n.trigger(S.FRAG_BUFFERED,{stats:s,frag:a,part:null,id:t.type}),r.tick()})).catch((function(e){r.state!==Fr.STOPPED&&r.state!==Fr.ERROR&&(r.warn(e),r.resetFragmentLoading(t))}))},r.fragContextChanged=function(t){var e=this.fragCurrent;return!t||!e||t.level!==e.level||t.sn!==e.sn||t.urlId!==e.urlId},r.fragBufferedComplete=function(t,e){var r,i,a,n,s=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+t.type+" sn: "+t.sn+(e?" part: "+e.index:"")+" of "+(this.playlistType===ae.MAIN?"level":"track")+" "+t.level+" (frag:["+(null!=(r=t.startPTS)?r:NaN).toFixed(3)+"-"+(null!=(i=t.endPTS)?i:NaN).toFixed(3)+"] > buffer:"+(s?Or.toString(pr.getBuffered(s)):"(detached)")+")"),this.state=Fr.IDLE,s&&(!this.loadedmetadata&&t.type==ae.MAIN&&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(t){var e=this.transmuxer;if(e){var r=t.frag,i=t.part,a=t.partsLoaded,n=!a||0===a.length||a.some((function(t){return!t})),s=new yr(r.level,r.sn,r.stats.chunkCount+1,0,i?i.index:-1,!n);e.flush(s)}},r._handleFragmentLoadProgress=function(t){},r._doFragLoad=function(t,e,r,i){var a,n=this;void 0===r&&(r=null);var s=null==e?void 0:e.details;if(!this.levels||!s)throw new Error("frag load aborted, missing level"+(s?"":" detail")+"s");var o=null;if(!t.encrypted||null!=(a=t.decryptdata)&&a.key?!t.encrypted&&s.encryptedFragments.length&&this.keyLoader.loadClear(t,s.encryptedFragments):(this.log("Loading key for "+t.sn+" of ["+s.startSN+"-"+s.endSN+"], "+("[stream-controller]"===this.logPrefix?"level":"track")+" "+t.level),this.state=Fr.KEY_LOADING,this.fragCurrent=t,o=this.keyLoader.load(t).then((function(t){if(!n.fragContextChanged(t.frag))return n.hls.trigger(S.KEY_LOADED,t),n.state===Fr.KEY_LOADING&&(n.state=Fr.IDLE),t})),this.hls.trigger(S.KEY_LOADING,{frag:t}),null===this.fragCurrent&&(o=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))),r=Math.max(t.start,r||0),this.config.lowLatencyMode&&"initSegment"!==t.sn){var l=s.partList;if(l&&i){r>t.end&&s.fragmentHint&&(t=s.fragmentHint);var u=this.getNextPart(l,t,r);if(u>-1){var d,h=l[u];return this.log("Loading part sn: "+t.sn+" p: "+h.index+" cc: "+t.cc+" of playlist ["+s.startSN+"-"+s.endSN+"] parts [0-"+u+"-"+(l.length-1)+"] "+("[stream-controller]"===this.logPrefix?"level":"track")+": "+t.level+", target: "+parseFloat(r.toFixed(3))),this.nextLoadPosition=h.start+h.duration,this.state=Fr.FRAG_LOADING,d=o?o.then((function(r){return!r||n.fragContextChanged(r.frag)?null:n.doFragPartsLoad(t,h,e,i)})).catch((function(t){return n.handleFragLoadError(t)})):this.doFragPartsLoad(t,h,e,i).catch((function(t){return n.handleFragLoadError(t)})),this.hls.trigger(S.FRAG_LOADING,{frag:t,part:h,targetBufferTime:r}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):d}if(!t.url||this.loadedEndOfParts(l,r))return Promise.resolve(null)}}this.log("Loading fragment "+t.sn+" cc: "+t.cc+" "+(s?"of ["+s.startSN+"-"+s.endSN+"] ":"")+("[stream-controller]"===this.logPrefix?"level":"track")+": "+t.level+", target: "+parseFloat(r.toFixed(3))),L(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=Fr.FRAG_LOADING;var f,c=this.config.progressive;return f=c&&o?o.then((function(e){return!e||n.fragContextChanged(null==e?void 0:e.frag)?null:n.fragmentLoader.load(t,i)})).catch((function(t){return n.handleFragLoadError(t)})):Promise.all([this.fragmentLoader.load(t,c?i:void 0),o]).then((function(t){var e=t[0];return!c&&e&&i&&i(e),e})).catch((function(t){return n.handleFragLoadError(t)})),this.hls.trigger(S.FRAG_LOADING,{frag:t,targetBufferTime:r}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):f},r.doFragPartsLoad=function(t,e,r,i){var a=this;return new Promise((function(n,s){var o,l=[],u=null==(o=r.details)?void 0:o.partList;!function e(o){a.fragmentLoader.loadPart(t,o,i).then((function(i){l[o.index]=i;var s=i.part;a.hls.trigger(S.FRAG_LOADED,i);var d=Me(r,t.sn,o.index+1)||Ne(u,t.sn,o.index+1);if(!d)return n({frag:t,part:s,partsLoaded:l});e(d)})).catch(s)}(e)}))},r.handleFragLoadError=function(t){if("data"in t){var e=t.data;t.data&&e.details===R.INTERNAL_ABORTED?this.handleFragLoadAborted(e.frag,e.part):this.hls.trigger(S.ERROR,e)}else this.hls.trigger(S.ERROR,{type:A.OTHER_ERROR,details:R.INTERNAL_EXCEPTION,err:t,error:t,fatal:!0});return null},r._handleTransmuxerFlush=function(t){var e=this.getCurrentContext(t);if(e&&this.state===Fr.PARSING){var r=e.frag,i=e.part,a=e.level,n=self.performance.now();r.stats.parsing.end=n,i&&(i.stats.parsing.end=n),this.updateLevelTiming(r,i,a,t.partial)}else this.fragCurrent||this.state===Fr.STOPPED||this.state===Fr.ERROR||(this.state=Fr.IDLE)},r.getCurrentContext=function(t){var e=this.levels,r=this.fragCurrent,i=t.level,a=t.sn,n=t.part;if(null==e||!e[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=e[i],o=n>-1?Me(s,a,n):null,l=o?o.fragment:Fe(s,a,r);return l?(r&&r!==l&&(l.stats=r.stats),{frag:l,part:o,level:s}):null},r.bufferFragmentData=function(t,e,r,i,a){var n;if(t&&this.state===Fr.PARSING){var s=t.data1,o=t.data2,l=s;if(s&&o&&(l=_t(s,o)),null!=(n=l)&&n.length){var u={type:t.type,frag:e,part:r,chunkMeta:i,parent:e.type,data:l};if(this.hls.trigger(S.BUFFER_APPENDING,u),t.dropped&&t.independent&&!r){if(a)return;this.flushBufferGap(e)}}}},r.flushBufferGap=function(t){var e=this.media;if(e)if(pr.isBuffered(e,e.currentTime)){var r=e.currentTime,i=pr.bufferInfo(e,r,0),a=t.duration,n=Math.min(2*this.config.maxFragLookUpTolerance,.25*a),s=Math.max(Math.min(t.start-n,i.end-n),r+n);t.start-s>n&&this.flushMainBuffer(s,t.start)}else this.flushMainBuffer(0,t.start)},r.getFwdBufferInfo=function(t,e){var r=this.getLoadPosition();return L(r)?this.getFwdBufferInfoAtPos(t,r,e):null},r.getFwdBufferInfoAtPos=function(t,e,r){var i=this.config.maxBufferHole,a=pr.bufferInfo(t,e,i);if(0===a.len&&void 0!==a.nextStart){var n=this.fragmentTracker.getBufferedFrag(e,r);if(n&&a.nextStart<n.end)return pr.bufferInfo(t,e,Math.max(a.nextStart,i))}return a},r.getMaxBufferLength=function(t){var e,r=this.config;return e=t?Math.max(8*r.maxBufferSize/t,r.maxBufferLength):r.maxBufferLength,Math.min(e,r.maxMaxBufferLength)},r.reduceMaxBufferLength=function(t){var e=this.config,r=t||e.maxBufferLength;return e.maxMaxBufferLength>=r&&(e.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+e.maxMaxBufferLength+"s"),!0)},r.getAppendedFrag=function(t,e){var r=this.fragmentTracker.getAppendedFrag(t,ae.MAIN);return r&&"fragment"in r?r.fragment:r},r.getNextFragment=function(t,e){var r=e.fragments,i=r.length;if(!i)return null;var a,n=this.config,s=r[0].start;if(e.live){var o=n.initialLiveManifestSize;if(i<o)return this.warn("Not enough fragments to start playback (have: "+i+", need: "+o+")"),null;e.PTSKnown||this.startFragRequested||-1!==this.startPosition||(a=this.getInitialLiveFragment(e,r),this.startPosition=a?this.hls.liveSyncPosition||a.start:t)}else t<=s&&(a=r[0]);if(!a){var l=n.lowLatencyMode?e.partEnd:e.fragmentEnd;a=this.getFragmentAtPosition(t,l,e)}return this.mapToInitFragWhenRequired(a)},r.isLoopLoading=function(t,e){var r=this.fragmentTracker.getState(t);return(r===nr.OK||r===nr.PARTIAL&&!!t.gap)&&this.nextLoadPosition>e},r.getNextFragmentLoopLoading=function(t,e,r,i,a){var n=t.gap,s=this.getNextFragment(this.nextLoadPosition,e);if(null===s)return s;if(t=s,n&&t&&!t.gap&&r.nextStart){var o=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,r.nextStart,i);if(null!==o&&r.len+o.len>=a)return this.log('buffer full after gaps in "'+i+'" playlist starting at sn: '+t.sn),null}return t},r.mapToInitFragWhenRequired=function(t){return null==t||!t.initSegment||null!=t&&t.initSegment.data||this.bitrateTest?t:t.initSegment},r.getNextPart=function(t,e,r){for(var i=-1,a=!1,n=!0,s=0,o=t.length;s<o;s++){var l=t[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===e&&(i=s),a=u}return i},r.loadedEndOfParts=function(t,e){var r=t[t.length-1];return r&&e>r.start&&r.loaded},r.getInitialLiveFragment=function(t,e){var r=this.fragPrevious,i=null;if(r){if(t.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+r.programDateTime),i=Ye(e,r.endProgramDateTime,this.config.maxFragLookUpTolerance)),!i){var a=r.sn+1;if(a>=t.startSN&&a<=t.endSN){var n=e[a-t.startSN];r.cc===n.cc&&(i=n,this.log("Live playlist, switching playlist, load frag with next SN: "+i.sn))}i||(i=Xe(e,r.cc))&&this.log("Live playlist, switching playlist, load frag with same CC: "+i.sn)}}else{var s=this.hls.liveSyncPosition;null!==s&&(i=this.getFragmentAtPosition(s,this.bitrateTest?t.fragmentEnd:t.edge,t))}return i},r.getFragmentAtPosition=function(t,e,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=t<e?je(n,s,t,t>e-u?0:u):s[s.length-1]){var f=i.sn-r.startSN,c=this.fragmentTracker.getState(i);if((c===nr.OK||c===nr.PARTIAL&&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)!==nr.OK?v:null}}return i},r.synchronizeToLiveEdge=function(t){var e=this.config,r=this.media;if(r){var i=this.hls.liveSyncPosition,a=r.currentTime,n=t.fragments[0].start,s=t.edge,o=a>=n-e.maxFragLookUpTolerance&&a<=s;if(null!==i&&r.duration>i&&(a<i||!o)){var l=void 0!==e.liveMaxLatencyDuration?e.liveMaxLatencyDuration:e.liveMaxLatencyDurationCount*t.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(t,e){var r=this.levels,i=this.levelLastLoaded,a=this.fragPrevious,n=null!==i?r[i]:null,s=t.fragments.length;if(!s)return this.warn("No fragments in live playlist"),0;var o=t.fragments[0].start,l=!e,u=t.alignedSliding&&L(o);if(l||!u&&!o){br(a,n,t);var d=t.fragments[0].start;return this.log("Live playlist sliding: "+d.toFixed(2)+" start-sn: "+(e?e.startSN:"na")+"->"+t.startSN+" prev-sn: "+(a?a.sn:"na")+" fragments: "+s),d}return o},r.waitForCdnTuneIn=function(t){var e=3;return t.live&&t.canBlockReload&&t.partTarget&&t.tuneInGoal>Math.max(t.partHoldBack,t.partTarget*e)},r.setStartPosition=function(t,e){var r=this.startPosition;if(r<e&&(r=-1),-1===r||-1===this.lastCurrentTime){var i=null!==this.startTimeOffset,a=i?this.startTimeOffset:t.startTimeOffset;null!==a&&L(a)?(r=e+a,a<0&&(r+=t.totalduration),r=Math.min(Math.max(e,r),e+t.totalduration),this.log("Start time offset "+a+" found in "+(i?"multivariant":"media")+" playlist, adjust startPosition to "+r),this.startPosition=r):t.live?r=this.hls.liveSyncPosition||e:this.startPosition=r=0,this.lastCurrentTime=r}this.nextLoadPosition=r},r.getLoadPosition=function(){var t=this.media,e=0;return this.loadedmetadata&&t?e=t.currentTime:this.nextLoadPosition&&(e=this.nextLoadPosition),e},r.handleFragLoadAborted=function(t,e){this.transmuxer&&"initSegment"!==t.sn&&t.stats.aborted&&(this.warn("Fragment "+t.sn+(e?" part "+e.index:"")+" of level "+t.level+" was aborted"),this.resetFragmentLoading(t))},r.resetFragmentLoading=function(t){this.fragCurrent&&(this.fragContextChanged(t)||this.state===Fr.FRAG_LOADING_WAITING_RETRY)||(this.state=Fr.IDLE)},r.onFragmentOrKeyLoadError=function(t,e){if(e.chunkMeta&&!e.frag){var r=this.getCurrentContext(e.chunkMeta);r&&(e.frag=r.frag)}var i=e.frag;if(i&&i.type===t&&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=e.details===R.FRAG_GAP;n&&this.fragmentTracker.fragBuffered(i,!0);var s=e.errorAction,o=s||{},l=o.action,u=o.retryCount,d=void 0===u?0:u,h=o.retryConfig;if(s&&l===$e.RetryRequest&&h){var f;this.resetStartWhenNotLoaded(null!=(f=this.levelLastLoaded)?f:i.level);var c=Ge(h,d);this.warn("Fragment "+i.sn+" of "+t+" "+i.level+" errored with "+e.details+", retrying loading "+(d+1)+"/"+h.maxNumRetry+" in "+c+"ms"),s.resolved=!0,this.retryDate=self.performance.now()+c,this.state=Fr.FRAG_LOADING_WAITING_RETRY}else h&&s?(this.resetFragmentErrors(t),d<h.maxNumRetry?n||(s.resolved=!0):w.warn(e.details+" reached or exceeded max retry ("+d+")")):(null==s?void 0:s.action)===$e.SendAlternateToPenaltyBox?this.state=Fr.WAITING_LEVEL:this.state=Fr.ERROR;this.tickImmediate()}},r.reduceLengthAndFlushBuffer=function(t){if(this.state===Fr.PARSING||this.state===Fr.PARSED){var e=t.parent,r=this.getFwdBufferInfo(this.mediaBuffer,e),i=r&&r.len>.5;i&&this.reduceMaxBufferLength(r.len);var a=!i;return a&&this.warn("Buffer full error while media.currentTime is not buffered, flush "+e+" buffer"),t.frag&&(this.fragmentTracker.removeFragment(t.frag),this.nextLoadPosition=t.frag.start),this.resetLoadingState(),a}return!1},r.resetFragmentErrors=function(t){t===ae.AUDIO&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==Fr.STOPPED&&(this.state=Fr.IDLE)},r.afterBufferFlushed=function(t,e,r){if(t){var i=pr.getBuffered(t);this.fragmentTracker.detectEvictedFragments(e,i,r),this.state===Fr.ENDED&&this.resetLoadingState()}},r.resetLoadingState=function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=Fr.IDLE},r.resetStartWhenNotLoaded=function(t){if(!this.loadedmetadata){this.startFragRequested=!1;var e=this.levels?this.levels[t].details:null;null!=e&&e.live?(this.startPosition=-1,this.setStartPosition(e,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},r.resetWhenMissingContext=function(t){var e;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(null!=(e=this.levelLastLoaded)?e:t.level),this.resetLoadingState()},r.removeUnbufferedFrags=function(t){void 0===t&&(t=0),this.fragmentTracker.removeFragmentsInRange(t,1/0,this.playlistType,!1,!0)},r.updateLevelTiming=function(t,e,r,i){var a,n=this,s=r.details;if(s){if(Object.keys(t.elementaryStreams).reduce((function(e,a){var o=t.elementaryStreams[a];if(o){var l=o.endPTS-o.startPTS;if(l<=0)return n.warn("Could not parse fragment "+t.sn+" "+a+" duration reliably ("+l+")"),e||!1;var u=i?0:ke(s,t,o.startPTS,o.endPTS,o.startDTS,o.endDTS);return n.hls.trigger(S.LEVEL_PTS_UPDATED,{details:s,level:r,drift:u,type:a,frag:t,start:o.startPTS,end:o.endPTS}),!0}return e}),!1))r.fragmentError=0;else if(null===(null==(a=this.transmuxer)?void 0:a.error)){var o=new Error("Found no media in fragment "+t.sn+" of level "+t.level+" resetting transmuxer to fallback to playlist timing");if(0===r.fragmentError&&(r.fragmentError++,t.gap=!0,this.fragmentTracker.removeFragment(t),this.fragmentTracker.fragBuffered(t,!0)),this.warn(o.message),this.hls.trigger(S.ERROR,{type:A.MEDIA_ERROR,details:R.FRAG_PARSING_ERROR,fatal:!1,error:o,frag:t,reason:"Found no media in msn "+t.sn+' of level "'+r.url+'"'}),!this.hls)return;this.resetTransmuxer()}this.state=Fr.PARSED,this.hls.trigger(S.FRAG_PARSED,{frag:t,part:e})}else this.warn("level.details undefined")},r.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},r.recoverWorkerError=function(t){var e,r,i;"demuxerWorker"===t.event&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded(null!=(e=null!=(r=this.levelLastLoaded)?r:null==(i=this.fragCurrent)?void 0:i.level)?e:0),this.resetLoadingState())},n(e,[{key:"state",get:function(){return this._state},set:function(t){var e=this._state;e!==t&&(this._state=t,this.log(e+"->"+t))}}]),e}(gr);function Nr(){return self.SourceBuffer||self.WebKitSourceBuffer}function Br(){var t=Bt();if(!t)return!1;var e=Nr(),r=t&&"function"==typeof t.isTypeSupported&&t.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),i=!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove;return!!r&&!!i}function Ur(){var t,e=Nr();return"function"==typeof(null==e||null==(t=e.prototype)?void 0:t.changeType)}function Gr(t,e){return void 0===t&&(t=""),void 0===e&&(e=9e4),{type:t,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}var Kr=function(){function t(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}var e=t.prototype;return e.resetInitSegment=function(t,e,r,i){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},e.resetTimeStamp=function(t){this.initPTS=t,this.resetContiguity()},e.resetContiguity=function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},e.canParse=function(t,e){return!1},e.appendFrame=function(t,e,r){},e.demux=function(t,e){this.cachedData&&(t=_t(this.cachedData,t),this.cachedData=null);var r,i=Q(t,0),a=i?i.length:0,n=this._audioTrack,s=this._id3Track,o=i?J(i):void 0,l=t.length;for((null===this.basePTS||0===this.frameIndex&&L(o))&&(this.basePTS=Vr(o,e,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:ce.audioId3,duration:Number.POSITIVE_INFINITY});a<l;){if(this.canParse(t,a)){var u=this.appendFrame(n,t,a);u?(this.frameIndex++,this.lastPTS=u.sample.pts,r=a+=u.length):a=l}else Z(t,a)?(i=Q(t,a),s.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:ce.audioId3,duration:Number.POSITIVE_INFINITY}),r=a+=i.length):a++;if(a===l&&r!==l){var d=j(t,r);this.cachedData?this.cachedData=_t(this.cachedData,d):this.cachedData=d}}return{audioTrack:n,videoTrack:Gr(),id3Track:s,textTrack:Gr()}},e.demuxSampleAes=function(t,e,r){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},e.flush=function(t){var e=this.cachedData;return e&&(this.cachedData=null,this.demux(e,0)),{audioTrack:this._audioTrack,videoTrack:Gr(),id3Track:this._id3Track,textTrack:Gr()}},e.destroy=function(){},t}(),Vr=function(t,e,r){return L(t)?90*t:9e4*e+(r?9e4*r.baseTime/r.timescale:0)};function Hr(t,e,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&e[r+2])>>>6);var h=(60&e[r+2])>>>2;if(!(h>d.length-1))return s=(1&e[r+2])<<2,s|=(192&e[r+3])>>>6,w.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};t.trigger(S.ERROR,{type:A.MEDIA_ERROR,details:R.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+h})}function Wr(t,e){return 255===t[e]&&240==(246&t[e+1])}function Yr(t,e){return 1&t[e+1]?7:9}function jr(t,e){return(3&t[e+3])<<11|t[e+4]<<3|(224&t[e+5])>>>5}function qr(t,e){return e+5<t.length}function zr(t,e){return e+1<t.length&&Wr(t,e)}function Xr(t,e){return qr(t,e)&&Wr(t,e)&&jr(t,e)<=t.length-e}function Qr(t,e){if(zr(t,e)){var r=Yr(t,e);if(e+r>=t.length)return!1;var i=jr(t,e);if(i<=r)return!1;var a=e+i;return a===t.length||zr(t,a)}return!1}function $r(t,e,r,i,a){if(!t.samplerate){var n=Hr(e,r,i,a);if(!n)return;t.config=n.config,t.samplerate=n.samplerate,t.channelCount=n.channelCount,t.codec=n.codec,t.manifestCodec=n.manifestCodec,w.log("parsed codec:"+t.codec+", rate:"+n.samplerate+", channels:"+n.channelCount)}}function Zr(t){return 9216e4/t}function Jr(t,e){var r=Yr(t,e);if(e+r<=t.length){var i=jr(t,e)-r;if(i>0)return{headerLength:r,frameLength:i}}}function ti(t,e,r,i,a){var n,s=i+a*Zr(t.samplerate),o=Jr(e,r);if(o){var l=o.frameLength,u=o.headerLength,d=u+l,h=Math.max(0,r+d-e.length);h?(n=new Uint8Array(d-u)).set(e.subarray(r+u,e.length),0):n=e.subarray(r+u,r+d);var f={unit:n,pts:s};return h||t.samples.push(f),{sample:f,length:d,missing:h}}var c=e.length-r;return(n=new Uint8Array(c)).set(e.subarray(r,e.length),0),{sample:{unit:n,pts:s},length:c,missing:-1}}var ei=function(t){function e(e,r){var i;return(i=t.call(this)||this).observer=void 0,i.config=void 0,i.observer=e,i.config=r,i}l(e,t);var r=e.prototype;return r.resetInitSegment=function(e,r,i,a){t.prototype.resetInitSegment.call(this,e,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}},e.probe=function(t){if(!t)return!1;for(var e=(Q(t,0)||[]).length,r=t.length;e<r;e++)if(Qr(t,e))return w.log("ADTS sync word found !"),!0;return!1},r.canParse=function(t,e){return Xr(t,e)},r.appendFrame=function(t,e,r){$r(t,this.observer,e,r,t.manifestCodec);var i=ti(t,e,r,this.basePTS,this.frameIndex);if(i&&0===i.missing)return i},e}(Kr),ri=/\/emsg[-/]ID3/i,ii=function(){function t(t,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 e=t.prototype;return e.resetTimeStamp=function(){},e.resetInitSegment=function(t,e,r,i){var a=this.videoTrack=Gr("video",1),n=this.audioTrack=Gr("audio",1),s=this.txtTrack=Gr("text",1);if(this.id3Track=Gr("id3",1),this.timeOffset=0,null!=t&&t.byteLength){var o=Lt(t);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=ct.text,a.sampleDuration=0,a.duration=n.duration=i}},e.resetContiguity=function(){this.remainderData=null},t.probe=function(t){return Et(t=t.length>16384?t.subarray(0,16384):t,["moof"]).length>0},e.demux=function(t,e){this.timeOffset=e;var r=t,i=this.videoTrack,a=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=_t(this.remainderData,t));var n=It(r);this.remainderData=n.remainder,i.samples=n.valid||new Uint8Array}else i.samples=r;var s=this.extractID3Track(i,e);return a.samples=xt(e,i),{videoTrack:i,audioTrack:this.audioTrack,id3Track:s,textTrack:this.txtTrack}},e.flush=function(){var t=this.timeOffset,e=this.videoTrack,r=this.txtTrack;e.samples=this.remainderData||new Uint8Array,this.remainderData=null;var i=this.extractID3Track(e,this.timeOffset);return r.samples=xt(t,e),{videoTrack:e,audioTrack:Gr(),id3Track:i,textTrack:Gr()}},e.extractID3Track=function(t,e){var r=this.id3Track;if(t.samples.length){var i=Et(t.samples,["emsg"]);i&&i.forEach((function(t){var i=Ft(t);if(ri.test(i.schemeIdUri)){var a=L(i.presentationTime)?i.presentationTime/i.timeScale:e+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:ce.emsg,duration:n})}}))}return r},e.demuxSampleAes=function(t,e,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},e.destroy=function(){},t}(),ai=null,ni=[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],si=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],oi=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],li=[0,1,1,4];function ui(t,e,r,i,a){if(!(r+24>e.length)){var n=di(e,r);if(n&&r+n.frameLength<=e.length){var s=i+a*(9e4*n.samplesPerFrame/n.sampleRate),o={unit:e.subarray(r,r+n.frameLength),pts:s,dts:s};return t.config=[],t.channelCount=n.channelCount,t.samplerate=n.sampleRate,t.samples.push(o),{sample:o,length:n.frameLength,missing:0}}}}function di(t,e){var r=t[e+1]>>3&3,i=t[e+1]>>1&3,a=t[e+2]>>4&15,n=t[e+2]>>2&3;if(1!==r&&0!==a&&15!==a&&3!==n){var s=t[e+2]>>1&1,o=t[e+3]>>6,l=1e3*ni[14*(3===r?3-i:3===i?3:4)+a-1],u=si[3*(3===r?0:2===r?1:2)+n],d=3===o?1:2,h=oi[r][i],f=li[i],c=8*h*f,v=Math.floor(h*l/u+s)*f;if(null===ai){var g=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);ai=g?parseInt(g[1]):0}return!!ai&&ai<=87&&2===i&&l>=224e3&&0===o&&(t[e+3]=128|t[e+3]),{sampleRate:u,channelCount:d,frameLength:v,samplesPerFrame:c}}}function hi(t,e){return 255===t[e]&&224==(224&t[e+1])&&0!=(6&t[e+1])}function fi(t,e){return e+1<t.length&&hi(t,e)}function ci(t,e){var r=4;return hi(t,e)&&r<=t.length-e}function vi(t,e){if(e+1<t.length&&hi(t,e)){var r=4,i=di(t,e),a=r;null!=i&&i.frameLength&&(a=i.frameLength);var n=e+a;return n===t.length||fi(t,n)}return!1}var gi=function(){function t(t){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=t,this.bytesAvailable=t.byteLength,this.word=0,this.bitsAvailable=0}var e=t.prototype;return e.loadWord=function(){var t=this.data,e=this.bytesAvailable,r=t.byteLength-e,i=new Uint8Array(4),a=Math.min(4,e);if(0===a)throw new Error("no bytes available");i.set(t.subarray(r,r+a)),this.word=new DataView(i.buffer).getUint32(0),this.bitsAvailable=8*a,this.bytesAvailable-=a},e.skipBits=function(t){var e;t=Math.min(t,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>t?(this.word<<=t,this.bitsAvailable-=t):(t-=this.bitsAvailable,t-=(e=t>>3)<<3,this.bytesAvailable-=e,this.loadWord(),this.word<<=t,this.bitsAvailable-=t)},e.readBits=function(t){var e=Math.min(this.bitsAvailable,t),r=this.word>>>32-e;if(t>32&&w.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=e,this.bitsAvailable>0)this.word<<=e;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return(e=t-e)>0&&this.bitsAvailable?r<<e|this.readBits(e):r},e.skipLZ=function(){var t;for(t=0;t<this.bitsAvailable;++t)if(0!=(this.word&2147483648>>>t))return this.word<<=t,this.bitsAvailable-=t,t;return this.loadWord(),t+this.skipLZ()},e.skipUEG=function(){this.skipBits(1+this.skipLZ())},e.skipEG=function(){this.skipBits(1+this.skipLZ())},e.readUEG=function(){var t=this.skipLZ();return this.readBits(t+1)-1},e.readEG=function(){var t=this.readUEG();return 1&t?1+t>>>1:-1*(t>>>1)},e.readBoolean=function(){return 1===this.readBits(1)},e.readUByte=function(){return this.readBits(8)},e.readUShort=function(){return this.readBits(16)},e.readUInt=function(){return this.readBits(32)},e.skipScalingList=function(t){for(var e=8,r=8,i=0;i<t;i++)0!==r&&(r=(e+this.readEG()+256)%256),e=0===r?e:r},e.readSPS=function(){var t,e,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(e=3!==m?8:12,r=0;r<e;r++)d()&&v(r<6?16:64)}c();var p=u();if(0===p)u();else if(1===p)for(h(1),f(),f(),t=u(),r=0;r<t;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 L=[1,1];if(d()&&d())switch(o()){case 1:L=[1,1];break;case 2:L=[12,11];break;case 3:L=[10,11];break;case 4:L=[16,11];break;case 5:L=[40,33];break;case 6:L=[24,11];break;case 7:L=[20,11];break;case 8:L=[32,11];break;case 9:L=[80,33];break;case 10:L=[18,11];break;case 11:L=[15,11];break;case 12:L=[64,33];break;case 13:L=[160,99];break;case 14:L=[4,3];break;case 15:L=[3,2];break;case 16:L=[2,1];break;case 255:L=[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:L}},e.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},t}(),mi=function(){function t(t,e,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new Pr(e,{removePKCS7Padding:!1})}var e=t.prototype;return e.decryptBuffer=function(t){return this.decrypter.decrypt(t,this.keyData.key.buffer,this.keyData.iv.buffer)},e.decryptAacSample=function(t,e,r){var i=this,a=t[e].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(t,e+1,r)}))}},e.decryptAacSamples=function(t,e,r){for(;;e++){if(e>=t.length)return void r();if(!(t[e].unit.length<32||(this.decryptAacSample(t,e,r),this.decrypter.isSync())))return}},e.getAvcEncryptedData=function(t){for(var e=16*Math.floor((t.length-48)/160)+16,r=new Int8Array(e),i=0,a=32;a<t.length-16;a+=160,i+=16)r.set(t.subarray(a,a+16),i);return r},e.getAvcDecryptedUnit=function(t,e){for(var r=new Uint8Array(e),i=0,a=32;a<t.length-16;a+=160,i+=16)t.set(r.subarray(i,i+16),a);return t},e.decryptAvcSample=function(t,e,r,i,a){var n=this,s=Ot(a.data),o=this.getAvcEncryptedData(s);this.decryptBuffer(o.buffer).then((function(o){a.data=n.getAvcDecryptedUnit(s,o),n.decrypter.isSync()||n.decryptAvcSamples(t,e,r+1,i)}))},e.decryptAvcSamples=function(t,e,r,i){if(t instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;e++,r=0){if(e>=t.length)return void i();for(var a=t[e].units;!(r>=a.length);r++){var n=a[r];if(!(n.data.length<=48||1!==n.type&&5!==n.type||(this.decryptAvcSample(t,e,r,i,n),this.decrypter.isSync())))return}}},t}(),pi=188,yi=function(){function t(t,e,r){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=t,this.config=e,this.typeSupported=r}t.probe=function(e){var r=t.syncOffset(e);return r>0&&w.warn("MPEG2-TS detected but first sync word found @ offset "+r),-1!==r},t.syncOffset=function(t){for(var e=t.length,r=Math.min(5*pi,t.length-pi)+1,i=0;i<r;){for(var a=!1,n=-1,s=0,o=i;o<e;o+=pi){if(71!==t[o]){if(s)return-1;break}if(s++,-1===n&&0!==(n=o)&&(r=Math.min(n+99*pi,t.length-pi)+1),a||(a=0===Ti(t,o)),a&&s>1&&(0===n&&s>2||o+pi>r))return n}i++}return-1},t.createTrack=function(t,e){return{container:"video"===t||"audio"===t?"video/mp2t":void 0,type:t,id:ct[t],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===t?e:void 0}};var e=t.prototype;return e.resetInitSegment=function(e,r,i,a){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=t.createTrack("video"),this._audioTrack=t.createTrack("audio",a),this._id3Track=t.createTrack("id3"),this._txtTrack=t.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=r,this.videoCodec=i,this._duration=a},e.resetTimeStamp=function(){},e.resetContiguity=function(){var t=this._audioTrack,e=this._avcTrack,r=this._id3Track;t&&(t.pesData=null),e&&(e.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null},e.demux=function(e,r,i,a){var n;void 0===i&&(i=!1),void 0===a&&(a=!1),i||(this.sampleAes=null);var s=this._avcTrack,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=e.length;if(this.remainderData&&(E=(e=_t(this.remainderData,e)).length,this.remainderData=null),E<pi&&!a)return this.remainderData=e,{audioTrack:o,videoTrack:s,id3Track:l,textTrack:u};var T=Math.max(0,t.syncOffset(e));(E-=(E-T)%pi)<e.byteLength&&!a&&(this.remainderData=new Uint8Array(e.buffer,E,e.buffer.byteLength-E));for(var L=0,b=T;b<E;b+=pi)if(71===e[b]){var D=!!(64&e[b+1]),k=Ti(e,b),I=void 0;if((48&e[b+3])>>4>1){if((I=b+5+e[b+4])===b+pi)continue}else I=b+4;switch(k){case d:D&&(h&&(n=Ai(h))&&this.parseAVCPES(s,u,n,!1),h={data:[],size:0}),h&&(h.data.push(e.subarray(I,b+pi)),h.size+=b+pi-I);break;case f:if(D){if(v&&(n=Ai(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(e.subarray(I,b+pi)),v.size+=b+pi-I);break;case c:D&&(g&&(n=Ai(g))&&this.parseID3PES(l,n),g={data:[],size:0}),g&&(g.data.push(e.subarray(I,b+pi)),g.size+=b+pi-I);break;case 0:D&&(I+=e[I]+1),y=this._pmtId=Li(e,I);break;case y:D&&(I+=e[I]+1);var _=Si(e,I,this.typeSupported,i);(d=_.avc)>0&&(s.pid=d),(f=_.audio)>0&&(o.pid=f,o.segmentCodec=_.segmentCodec),(c=_.id3)>0&&(l.pid=c),null===m||p||(w.warn("MPEG-TS PMT found at "+b+" after unknown PID '"+m+"'. Backtracking to sync byte @"+T+" to parse all TS packets."),m=null,b=T-188),p=this.pmtParsed=!0;break;case 17:case 8191:break;default:m=k}}else L++;if(L>0){var x=new Error("Found "+L+" TS packet/s that do not start with 0x47");this.observer.emit(S.ERROR,S.ERROR,{type:A.MEDIA_ERROR,details:R.FRAG_PARSING_ERROR,fatal:!1,error:x,reason:x.message})}s.pesData=h,o.pesData=v,l.pesData=g;var C={audioTrack:o,videoTrack:s,id3Track:l,textTrack:u};return a&&this.extractRemainingSamples(C),C},e.flush=function(){var t,e=this.remainderData;return this.remainderData=null,t=e?this.demux(e,-1,!1,!0):{videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t},e.extractRemainingSamples=function(t){var e,r=t.audioTrack,i=t.videoTrack,a=t.id3Track,n=t.textTrack,s=i.pesData,o=r.pesData,l=a.pesData;if(s&&(e=Ai(s))?(this.parseAVCPES(i,n,e,!0),i.pesData=null):i.pesData=s,o&&(e=Ai(o))){switch(r.segmentCodec){case"aac":this.parseAACPES(r,e);break;case"mp3":this.parseMPEGPES(r,e)}r.pesData=null}else null!=o&&o.size&&w.log("last AAC PES packet truncated,might overlap between fragments"),r.pesData=o;l&&(e=Ai(l))?(this.parseID3PES(a,e),a.pesData=null):a.pesData=l},e.demuxSampleAes=function(t,e,r){var i=this.demux(t,r,!0,!this.config.progressive),a=this.sampleAes=new mi(this.observer,this.config,e);return this.decrypt(i,a)},e.decrypt=function(t,e){return new Promise((function(r){var i=t.audioTrack,a=t.videoTrack;i.samples&&"aac"===i.segmentCodec?e.decryptAacSamples(i.samples,0,(function(){a.samples?e.decryptAvcSamples(a.samples,0,0,(function(){r(t)})):r(t)})):a.samples&&e.decryptAvcSamples(a.samples,0,0,(function(){r(t)}))}))},e.destroy=function(){this._duration=0},e.parseAVCPES=function(t,e,r,i){var a,n=this,s=this.parseAVCNALu(t,r.data),o=this.avcSample,l=!1;r.data=null,o&&s.length&&!t.audFound&&(Ri(o,t),o=this.avcSample=Ei(!1,r.pts,r.dts,"")),s.forEach((function(i){var s;switch(i.type){case 1:var u=!1;a=!0;var d,h=i.data;if(l&&h.length>4){var f=new gi(h).readSliceType();2!==f&&4!==f&&7!==f&&9!==f||(u=!0)}u&&null!=(d=o)&&d.frame&&!o.key&&(Ri(o,t),o=n.avcSample=null),o||(o=n.avcSample=Ei(!0,r.pts,r.dts,"")),o.frame=!0,o.key=u;break;case 5:a=!0,null!=(s=o)&&s.frame&&!o.key&&(Ri(o,t),o=n.avcSample=null),o||(o=n.avcSample=Ei(!0,r.pts,r.dts,"")),o.key=!0,o.frame=!0;break;case 6:a=!0,Pt(i.data,1,r.pts,e.samples);break;case 7:if(a=!0,l=!0,!t.sps){var c=i.data,v=new gi(c).readSPS();t.width=v.width,t.height=v.height,t.pixelRatio=v.pixelRatio,t.sps=[c],t.duration=n._duration;for(var g=c.subarray(1,4),m="avc1.",p=0;p<3;p++){var y=g[p].toString(16);y.length<2&&(y="0"+y),m+=y}t.codec=m}break;case 8:a=!0,t.pps||(t.pps=[i.data]);break;case 9:a=!1,t.audFound=!0,o&&Ri(o,t),o=n.avcSample=Ei(!1,r.pts,r.dts,"");break;case 12:a=!0;break;default:a=!1,o&&(o.debug+="unknown NAL "+i.type+" ")}o&&a&&o.units.push(i)})),i&&o&&(Ri(o,t),this.avcSample=null)},e.getLastNalUnit=function(t){var e,r,i=this.avcSample;if(i&&0!==i.units.length||(i=t[t.length-1]),null!=(e=i)&&e.units){var a=i.units;r=a[a.length-1]}return r},e.parseAVCNALu=function(t,e){var r,i,a=e.byteLength,n=t.naluState||0,s=n,o=[],l=0,u=-1,d=0;for(-1===n&&(u=0,d=31&e[0],n=0,l=1);l<a;)if(r=e[l++],n)if(1!==n)if(r)if(1===r){if(u>=0){var h={data:e.subarray(u,l-n-1),type:d};o.push(h)}else{var f=this.getLastNalUnit(t.samples);if(f&&(s&&l<=4-s&&f.state&&(f.data=f.data.subarray(0,f.data.byteLength-s)),(i=l-n-1)>0)){var c=new Uint8Array(f.data.byteLength+i);c.set(f.data,0),c.set(e.subarray(0,i),f.data.byteLength),f.data=c,f.state=0}}l<a?(u=l,d=31&e[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 v={data:e.subarray(u,a),type:d,state:n};o.push(v)}if(0===o.length){var g=this.getLastNalUnit(t.samples);if(g){var m=new Uint8Array(g.data.byteLength+e.byteLength);m.set(g.data,0),m.set(e,g.data.byteLength),g.data=m}}return t.naluState=n,o},e.parseAACPES=function(t,e){var r,i,a,n=0,s=this.aacOverFlow,o=e.data;if(s){this.aacOverFlow=null;var l=s.missing,u=s.sample.unit.byteLength;if(-1===l){var d=new Uint8Array(u+o.byteLength);d.set(s.sample.unit,0),d.set(o,u),o=d}else{var h=u-l;s.sample.unit.set(o.subarray(0,l),h),t.samples.push(s.sample),n=s.missing}}for(r=n,i=o.length;r<i-1&&!zr(o,r);r++);if(r!==n){var f,c=r<i-1;f=c?"AAC PES did not start with ADTS header,offset:"+r:"No ADTS header found in AAC PES";var v=new Error(f);if(w.warn("parsing error: "+f),this.observer.emit(S.ERROR,S.ERROR,{type:A.MEDIA_ERROR,details:R.FRAG_PARSING_ERROR,fatal:!1,levelRetry:c,error:v,reason:f}),!c)return}if($r(t,this.observer,o,r,this.audioCodec),void 0!==e.pts)a=e.pts;else{if(!s)return void w.warn("[tsdemuxer]: AAC PES unknown PTS");var g=Zr(t.samplerate);a=s.sample.pts+g}for(var m,p=0;r<i;){if(r+=(m=ti(t,o,r,a,p)).length,m.missing){this.aacOverFlow=m;break}for(p++;r<i-1&&!zr(o,r);r++);}},e.parseMPEGPES=function(t,e){var r=e.data,i=r.length,a=0,n=0,s=e.pts;if(void 0!==s)for(;n<i;)if(fi(r,n)){var o=ui(t,r,n,s,a);if(!o)break;n+=o.length,a++}else n++;else w.warn("[tsdemuxer]: MPEG PES unknown PTS")},e.parseID3PES=function(t,e){if(void 0!==e.pts){var r=o({},e,{type:this._avcTrack?ce.emsg:ce.audioId3,duration:Number.POSITIVE_INFINITY});t.samples.push(r)}else w.warn("[tsdemuxer]: ID3 PES unknown PTS")},t}();function Ei(t,e,r,i){return{key:t,frame:!1,pts:e,dts:r,units:[],debug:i,length:0}}function Ti(t,e){return((31&t[e+1])<<8)+t[e+2]}function Li(t,e){return(31&t[e+10])<<8|t[e+11]}function Si(t,e,r,i){var a={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},n=e+3+((15&t[e+1])<<8|t[e+2])-4;for(e+=12+((15&t[e+10])<<8|t[e+11]);e<n;){var s=Ti(t,e);switch(t[e]){case 207:if(!i){w.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:-1===a.audio&&(a.audio=s);break;case 21:-1===a.id3&&(a.id3=s);break;case 219:if(!i){w.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:-1===a.avc&&(a.avc=s);break;case 3:case 4:!0!==r.mpeg&&!0!==r.mp3?w.log("MPEG audio found, not supported in this browser"):-1===a.audio&&(a.audio=s,a.segmentCodec="mp3");break;case 36:w.warn("Unsupported HEVC stream type found")}e+=5+((15&t[e+3])<<8|t[e+4])}return a}function Ai(t){var e,r,i,a,n,s=0,o=t.data;if(!t||0===t.size)return null;for(;o[0].length<19&&o.length>1;){var l=new Uint8Array(o[0].length+o[1].length);l.set(o[0]),l.set(o[1],o[0].length),o[0]=l,o.splice(1,1)}if(1===((e=o[0])[0]<<16)+(e[1]<<8)+e[2]){if((r=(e[4]<<8)+e[5])&&r>t.size-6)return null;var u=e[7];192&u&&(a=536870912*(14&e[9])+4194304*(255&e[10])+16384*(254&e[11])+128*(255&e[12])+(254&e[13])/2,64&u?a-(n=536870912*(14&e[14])+4194304*(255&e[15])+16384*(254&e[16])+128*(255&e[17])+(254&e[18])/2)>54e5&&(w.warn(Math.round((a-n)/9e4)+"s delta between PTS and DTS, align them"),a=n):n=a);var d=(i=e[8])+9;if(t.size<=d)return null;t.size-=d;for(var h=new Uint8Array(t.size),f=0,c=o.length;f<c;f++){var v=(e=o[f]).byteLength;if(d){if(d>v){d-=v;continue}e=e.subarray(d),v-=d,d=0}h.set(e,s),s+=v}return r&&(r-=i+3),{data:h,pts:a,dts:n,len:r}}return null}function Ri(t,e){if(t.units.length&&t.frame){if(void 0===t.pts){var r=e.samples,i=r.length;if(!i)return void e.dropped++;var a=r[i-1];t.pts=a.pts,t.dts=a.dts}e.samples.push(t)}t.debug.length&&w.log(t.pts+"/"+t.dts+":"+t.debug)}var bi=function(t){function e(){return t.apply(this,arguments)||this}l(e,t);var r=e.prototype;return r.resetInitSegment=function(e,r,i,a){t.prototype.resetInitSegment.call(this,e,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}},e.probe=function(t){if(!t)return!1;for(var e=(Q(t,0)||[]).length,r=t.length;e<r;e++)if(vi(t,e))return w.log("MPEG Audio sync word found !"),!0;return!1},r.canParse=function(t,e){return ci(t,e)},r.appendFrame=function(t,e,r){if(null!==this.basePTS)return ui(t,e,r,this.basePTS,this.frameIndex)},e}(Kr),Di=function(){function t(){}return t.getSilentFrame=function(t,e){if("mp4a.40.2"===t){if(1===e)return new Uint8Array([0,200,0,128,35,128]);if(2===e)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===e)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===e)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===e)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===e)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===e)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===e)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===e)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])}},t}(),ki=Math.pow(2,32)-1,Ii=function(){function t(){}return t.init=function(){var e;for(e in t.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},t.types)t.types.hasOwnProperty(e)&&(t.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.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]);t.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]);t.STTS=t.STSC=t.STCO=n,t.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),t.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),t.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),t.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]);t.FTYP=t.box(t.types.ftyp,s,l,s,o),t.DINF=t.box(t.types.dinf,t.box(t.types.dref,a))},t.box=function(t){for(var e=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--;)e+=i[n].byteLength;var o=new Uint8Array(e);for(o[0]=e>>24&255,o[1]=e>>16&255,o[2]=e>>8&255,o[3]=255&e,o.set(t,4),n=0,e=8;n<s;n++)o.set(i[n],e),e+=i[n].byteLength;return o},t.hdlr=function(e){return t.box(t.types.hdlr,t.HDLR_TYPES[e])},t.mdat=function(e){return t.box(t.types.mdat,e)},t.mdhd=function(e,r){r*=e;var i=Math.floor(r/(ki+1)),a=Math.floor(r%(ki+1));return t.box(t.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,i>>24,i>>16&255,i>>8&255,255&i,a>>24,a>>16&255,a>>8&255,255&a,85,196,0,0]))},t.mdia=function(e){return t.box(t.types.mdia,t.mdhd(e.timescale,e.duration),t.hdlr(e.type),t.minf(e))},t.mfhd=function(e){return t.box(t.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e]))},t.minf=function(e){return"audio"===e.type?t.box(t.types.minf,t.box(t.types.smhd,t.SMHD),t.DINF,t.stbl(e)):t.box(t.types.minf,t.box(t.types.vmhd,t.VMHD),t.DINF,t.stbl(e))},t.moof=function(e,r,i){return t.box(t.types.moof,t.mfhd(e),t.traf(i,r))},t.moov=function(e){for(var r=e.length,i=[];r--;)i[r]=t.trak(e[r]);return t.box.apply(null,[t.types.moov,t.mvhd(e[0].timescale,e[0].duration)].concat(i).concat(t.mvex(e)))},t.mvex=function(e){for(var r=e.length,i=[];r--;)i[r]=t.trex(e[r]);return t.box.apply(null,[t.types.mvex].concat(i))},t.mvhd=function(e,r){r*=e;var i=Math.floor(r/(ki+1)),a=Math.floor(r%(ki+1)),n=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,i>>24,i>>16&255,i>>8&255,255&i,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 t.box(t.types.mvhd,n)},t.sdtp=function(e){var r,i,a=e.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 t.box(t.types.sdtp,n)},t.stbl=function(e){return t.box(t.types.stbl,t.stsd(e),t.box(t.types.stts,t.STTS),t.box(t.types.stsc,t.STSC),t.box(t.types.stsz,t.STSZ),t.box(t.types.stco,t.STCO))},t.avc1=function(e){var r,i,a,n=[],s=[];for(r=0;r<e.sps.length;r++)a=(i=e.sps[r]).byteLength,n.push(a>>>8&255),n.push(255&a),n=n.concat(Array.prototype.slice.call(i));for(r=0;r<e.pps.length;r++)a=(i=e.pps[r]).byteLength,s.push(a>>>8&255),s.push(255&a),s=s.concat(Array.prototype.slice.call(i));var o=t.box(t.types.avcC,new Uint8Array([1,n[3],n[4],n[5],255,224|e.sps.length].concat(n).concat([e.pps.length]).concat(s))),l=e.width,u=e.height,d=e.pixelRatio[0],h=e.pixelRatio[1];return t.box(t.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,t.box(t.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),t.box(t.types.pasp,new Uint8Array([d>>24,d>>16&255,d>>8&255,255&d,h>>24,h>>16&255,h>>8&255,255&h])))},t.esds=function(t){var e=t.config.length;return new Uint8Array([0,0,0,0,3,23+e,0,1,0,4,15+e,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([e]).concat(t.config).concat([6,1,2]))},t.mp4a=function(e){var r=e.samplerate;return t.box(t.types.mp4a,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,r>>8&255,255&r,0,0]),t.box(t.types.esds,t.esds(e)))},t.mp3=function(e){var r=e.samplerate;return t.box(t.types[".mp3"],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,r>>8&255,255&r,0,0]))},t.stsd=function(e){return"audio"===e.type?"mp3"===e.segmentCodec&&"mp3"===e.codec?t.box(t.types.stsd,t.STSD,t.mp3(e)):t.box(t.types.stsd,t.STSD,t.mp4a(e)):t.box(t.types.stsd,t.STSD,t.avc1(e))},t.tkhd=function(e){var r=e.id,i=e.duration*e.timescale,a=e.width,n=e.height,s=Math.floor(i/(ki+1)),o=Math.floor(i%(ki+1));return t.box(t.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]))},t.traf=function(e,r){var i=t.sdtp(e),a=e.id,n=Math.floor(r/(ki+1)),s=Math.floor(r%(ki+1));return t.box(t.types.traf,t.box(t.types.tfhd,new Uint8Array([0,0,0,0,a>>24,a>>16&255,a>>8&255,255&a])),t.box(t.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])),t.trun(e,i.length+16+20+8+16+8+8),i)},t.trak=function(e){return e.duration=e.duration||4294967295,t.box(t.types.trak,t.tkhd(e),t.mdia(e))},t.trex=function(e){var r=e.id;return t.box(t.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]))},t.trun=function(e,r){var i,a,n,s,o,l,u=e.samples||[],d=u.length,h=12+16*d,f=new Uint8Array(h);for(r+=8+h,f.set(["video"===e.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 t.box(t.types.trun,f)},t.initSegment=function(e){t.types||t.init();var r=t.moov(e),i=new Uint8Array(t.FTYP.byteLength+r.byteLength);return i.set(t.FTYP),i.set(r,t.FTYP.byteLength),i},t}();Ii.types=void 0,Ii.HDLR_TYPES=void 0,Ii.STTS=void 0,Ii.STSC=void 0,Ii.STCO=void 0,Ii.STSZ=void 0,Ii.VMHD=void 0,Ii.SMHD=void 0,Ii.STSD=void 0,Ii.FTYP=void 0,Ii.DINF=void 0;var _i=9e4;function xi(t,e,r,i){void 0===r&&(r=1),void 0===i&&(i=!1);var a=t*e*r;return i?Math.round(a):a}function wi(t,e){return void 0===e&&(e=!1),xi(t,1e3,1/_i,e)}var Ci=1e4,Pi=1024,Oi=1152,Fi=null,Mi=null,Ni=function(){function t(t,e,r,i){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=t,this.config=e,this.typeSupported=r,this.ISGenerated=!1,null===Fi){var a=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Fi=a?parseInt(a[1]):0}if(null===Mi){var n=navigator.userAgent.match(/Safari\/(\d+)/i);Mi=n?parseInt(n[1]):0}}var e=t.prototype;return e.destroy=function(){},e.resetTimeStamp=function(t){w.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=t},e.resetNextTimestamp=function(){w.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},e.resetInitSegment=function(){w.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},e.getVideoStartPts=function(t){var e=!1,r=t.reduce((function(t,r){var i=r.pts-t;return i<-4294967296?(e=!0,Bi(t,r.pts)):i>0?t:r.pts}),t[0].pts);return e&&w.debug("PTS rollover detected"),r},e.remux=function(t,e,r,i,a,n,s,o){var l,u,d,h,f,c,v=a,g=a,m=t.pid>-1,p=e.pid>-1,y=e.samples.length,E=t.samples.length>0,T=s&&y>0||y>1;if((!m||E)&&(!p||T)||this.ISGenerated||s){this.ISGenerated||(d=this.generateIS(t,e,a,n));var L,S=this.isVideoContiguous,A=-1;if(T&&(A=Ui(e.samples),!S&&this.config.forceKeyFrameOnDiscontinuity))if(c=!0,A>0){w.warn("[mp4-remuxer]: Dropped "+A+" out of "+y+" video samples due to a missing keyframe");var R=this.getVideoStartPts(e.samples);e.samples=e.samples.slice(A),e.dropped+=A,L=g+=(e.samples[0].pts-R)/e.inputTimeScale}else-1===A&&(w.warn("[mp4-remuxer]: No keyframe found out of "+y+" video samples"),c=!1);if(this.ISGenerated){if(E&&T){var b=this.getVideoStartPts(e.samples),D=(Bi(t.samples[0].pts,b)-b)/e.inputTimeScale;v+=Math.max(0,D),g+=Math.max(0,-D)}if(E){if(t.samplerate||(w.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),d=this.generateIS(t,e,a,n)),u=this.remuxAudio(t,v,this.isAudioContiguous,n,p||T||o===ae.AUDIO?g:void 0),T){var k=u?u.endPTS-u.startPTS:0;e.inputTimeScale||(w.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),d=this.generateIS(t,e,a,n)),l=this.remuxVideo(e,g,S,k)}}else T&&(l=this.remuxVideo(e,g,S,0));l&&(l.firstKeyFrame=A,l.independent=-1!==A,l.firstKeyFramePTS=L)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(f=Gi(r,a,this._initPTS,this._initDTS)),i.samples.length&&(h=Ki(i,a,this._initPTS))),{audio:u,video:l,initSegment:d,independent:c,text:h,id3:f}},e.generateIS=function(t,e,r,i){var a,n,s,o=t.samples,l=e.samples,u=this.typeSupported,d={},h=this._initPTS,f=!h||i,c="audio/mp4";if(f&&(a=n=1/0),t.config&&o.length&&(t.timescale=t.samplerate,"mp3"===t.segmentCodec&&(u.mpeg?(c="audio/mpeg",t.codec=""):u.mp3&&(t.codec="mp3")),d.audio={id:"audio",container:c,codec:t.codec,initSegment:"mp3"===t.segmentCodec&&u.mpeg?new Uint8Array(0):Ii.initSegment([t]),metadata:{channelCount:t.channelCount}},f&&(s=t.inputTimeScale,h&&s===h.timescale?f=!1:a=n=o[0].pts-Math.round(s*r))),e.sps&&e.pps&&l.length&&(e.timescale=e.inputTimeScale,d.video={id:"main",container:"video/mp4",codec:e.codec,initSegment:Ii.initSegment([e]),metadata:{width:e.width,height:e.height}},f))if(s=e.inputTimeScale,h&&s===h.timescale)f=!1;else{var v=this.getVideoStartPts(l),g=Math.round(s*r);n=Math.min(n,Bi(l[0].dts,v)-g),a=Math.min(a,v-g)}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}},e.remuxVideo=function(t,e,r,i){var a,n,s=t.inputTimeScale,l=t.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;r&&null!==f||(f=e*s-(l[0].pts-Bi(l[0].dts,l[0].pts)));for(var y=h.baseTime*s/h.timescale,E=0;E<d;E++){var T=l[E];T.pts=Bi(T.pts-y,f),T.dts=Bi(T.dts-y,f),T.dts<l[E>0?E-1:E].dts&&(p=!0)}p&&l.sort((function(t,e){var r=t.dts-e.dts,i=t.pts-e.pts;return r||i})),a=l[0].dts;var L=(n=l[l.length-1].dts)-a,b=L?Math.round(L/(d-1)):v||t.inputTimeScale/30;if(r){var D=a-f,k=D>b,I=D<-1;if((k||I)&&(k?w.warn("AVC: "+wi(D,!0)+" ms ("+D+"dts) hole between fragments detected, filling it"):w.warn("AVC: "+wi(-D,!0)+" ms ("+D+"dts) overlapping between fragments detected"),!I||f>=l[0].pts)){a=f;var _=l[0].pts-D;l[0].dts=a,l[0].pts=_,w.log("Video: First PTS/DTS adjusted: "+wi(_,!0)+"/"+wi(a,!0)+", delta: "+wi(D,!0)+" ms")}}a=Math.max(0,a);for(var x=0,C=0,P=0;P<d;P++){for(var O=l[P],F=O.units,M=F.length,N=0,B=0;B<M;B++)N+=F[B].data.length;C+=N,x+=M,O.length=N,O.dts=Math.max(O.dts,a),g=Math.min(O.pts,g),m=Math.max(O.pts,m)}n=l[d-1].dts;var U,G=C+4*x+8;try{U=new Uint8Array(G)}catch(t){return void this.observer.emit(S.ERROR,S.ERROR,{type:A.MUX_ERROR,details:R.REMUX_ALLOC_ERROR,fatal:!1,error:t,bytes:G,reason:"fail allocating video mdat "+G})}var K=new DataView(U.buffer);K.setUint32(0,G),U.set(Ii.types.mdat,4);for(var V=!1,H=Number.POSITIVE_INFINITY,W=Number.POSITIVE_INFINITY,Y=Number.NEGATIVE_INFINITY,j=Number.NEGATIVE_INFINITY,q=0;q<d;q++){for(var z=l[q],X=z.units,Q=0,$=0,Z=X.length;$<Z;$++){var J=X[$],tt=J.data,et=J.data.byteLength;K.setUint32(c,et),c+=4,U.set(tt,c),c+=et,Q+=4+et}var rt=void 0;if(q<d-1)v=l[q+1].dts-z.dts,rt=l[q+1].pts-z.pts;else{var it=this.config,at=q>0?z.dts-l[q-1].dts:b;if(rt=q>0?z.pts-l[q-1].pts:b,it.stretchShortVideoTrack&&null!==this.nextAudioPts){var nt=Math.floor(it.maxBufferHole*s),st=(i?g+i*s:this.nextAudioPts)-z.pts;st>nt?((v=st-at)<0?v=at:V=!0,w.log("[mp4-remuxer]: It is approximately "+st/90+" ms to the next segment; using duration "+v/90+" ms for the last video frame.")):v=at}else v=at}var ot=Math.round(z.pts-z.dts);H=Math.min(H,v),Y=Math.max(Y,v),W=Math.min(W,rt),j=Math.max(j,rt),u.push(new Hi(z.key,v,Q,ot))}if(u.length)if(Fi){if(Fi<70){var lt=u[0].flags;lt.dependsOn=2,lt.isNonSync=0}}else if(Mi&&j-W<Y-H&&b/Y<.025&&0===u[0].cts){w.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var ut=a,dt=0,ht=u.length;dt<ht;dt++){var ft=ut+u[dt].duration,ct=ut+u[dt].cts;if(dt<ht-1){var vt=ft+u[dt+1].cts;u[dt].duration=vt-ct}else u[dt].duration=dt?u[dt-1].duration:b;u[dt].cts=0,ut=ft}}v=V||!v?b:v,this.nextAvcDts=f=n+v,this.videoSampleDuration=v,this.isVideoContiguous=!0;var gt={data1:Ii.moof(t.sequenceNumber++,a,o({},t,{samples:u})),data2:U,startPTS:g/s,endPTS:(m+v)/s,startDTS:a/s,endDTS:f/s,type:"video",hasAudio:!1,hasVideo:!0,nb:u.length,dropped:t.dropped};return t.samples=[],t.dropped=0,gt},e.remuxAudio=function(t,e,r,i,a){var n=t.inputTimeScale,s=n/(t.samplerate?t.samplerate:n),l="aac"===t.segmentCodec?Pi:Oi,u=l*s,d=this._initPTS,h="mp3"===t.segmentCodec&&this.typeSupported.mpeg,f=[],c=void 0!==a,v=t.samples,g=h?0:8,m=this.nextAudioPts||-1,p=e*n,y=d.baseTime*n/d.timescale;if(this.isAudioContiguous=r=r||v.length&&m>0&&(i&&Math.abs(p-m)<9e3||Math.abs(Bi(v[0].pts-y,p)-m)<20*u),v.forEach((function(t){t.pts=Bi(t.pts-y,p)})),!r||m<0){if(v=v.filter((function(t){return t.pts>=0})),!v.length)return;m=0===a?0:i&&!c?Math.max(0,p):v[0].pts}if("aac"===t.segmentCodec)for(var E=this.config.maxAudioFramesDrift,T=0,L=m;T<v.length;T++){var b=v[T],D=b.pts,k=D-L,I=Math.abs(1e3*k/n);if(k<=-E*u&&c)0===T&&(w.warn("Audio frame @ "+(D/n).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*k/n)+" ms."),this.nextAudioPts=m=L=D);else if(k>=E*u&&I<Ci&&c){var _=Math.round(k/u);(L=D-_*u)<0&&(_--,L+=u),0===T&&(this.nextAudioPts=m=L),w.warn("[mp4-remuxer]: Injecting "+_+" audio frame @ "+(L/n).toFixed(3)+"s due to "+Math.round(1e3*k/n)+" ms gap.");for(var x=0;x<_;x++){var C=Math.max(L,0),P=Di.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);P||(w.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),P=b.unit.subarray()),v.splice(T,0,{unit:P,pts:C}),L+=u,T++}}b.pts=L,L+=u}for(var O,F=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 K=v[U],V=K.unit,H=K.pts;if(null!==M)f[U-1].duration=Math.round((H-M)/s);else{if(r&&"aac"===t.segmentCodec&&(H=m),F=H,!(N>0))return;N+=g;try{O=new Uint8Array(N)}catch(t){return void this.observer.emit(S.ERROR,S.ERROR,{type:A.MUX_ERROR,details:R.REMUX_ALLOC_ERROR,fatal:!1,error:t,bytes:N,reason:"fail allocating audio mdat "+N})}h||(new DataView(O.buffer).setUint32(0,N),O.set(Ii.types.mdat,4))}O.set(V,g);var W=V.byteLength;g+=W,f.push(new Hi(!0,l,W,0)),M=H}var Y=f.length;if(Y){var j=f[f.length-1];this.nextAudioPts=m=M+s*j.duration;var q=h?new Uint8Array(0):Ii.moof(t.sequenceNumber++,F/s,o({},t,{samples:f}));t.samples=[];var z=F/n,X=m/n,Q={data1:q,data2:O,startPTS:z,endPTS:X,startDTS:z,endDTS:X,type:"audio",hasAudio:!0,hasVideo:!1,nb:Y};return this.isAudioContiguous=!0,Q}},e.remuxEmptyAudio=function(t,e,r,i){var a=t.inputTimeScale,n=a/(t.samplerate?t.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=n*Pi,f=Math.ceil((d-u)/h),c=Di.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);if(w.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 t.samples=v,this.remuxAudio(t,e,r,!1)}w.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec")},t}();function Bi(t,e){var r;if(null===e)return t;for(r=e<t?-8589934592:8589934592;Math.abs(t-e)>4294967296;)t+=r;return t}function Ui(t){for(var e=0;e<t.length;e++)if(t[e].key)return e;return-1}function Gi(t,e,r,i){var a=t.samples.length;if(a){for(var n=t.inputTimeScale,s=0;s<a;s++){var o=t.samples[s];o.pts=Bi(o.pts-r.baseTime*n/r.timescale,e*n)/n,o.dts=Bi(o.dts-i.baseTime*n/i.timescale,e*n)/n}var l=t.samples;return t.samples=[],{samples:l}}}function Ki(t,e,r){var i=t.samples.length;if(i){for(var a=t.inputTimeScale,n=0;n<i;n++){var s=t.samples[n];s.pts=Bi(s.pts-r.baseTime*a/r.timescale,e*a)/a}t.samples.sort((function(t,e){return t.pts-e.pts}));var o=t.samples;return t.samples=[],{samples:o}}}var Vi,Hi=function(t,e,r,i){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=e,this.size=r,this.cts=i,this.flags=new Wi(t)},Wi=function(t){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=t?2:1,this.isNonSync=t?0:1},Yi=function(){function t(){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 e=t.prototype;return e.destroy=function(){},e.resetTimeStamp=function(t){this.initPTS=t,this.lastEndTime=null},e.resetNextTimestamp=function(){this.lastEndTime=null},e.resetInitSegment=function(t,e,r,i){this.audioCodec=e,this.videoCodec=r,this.generateInitSegment(St(t,i)),this.emitInitSegment=!0},e.generateInitSegment=function(t){var e=this.audioCodec,r=this.videoCodec;if(null==t||!t.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var i=this.initData=Lt(t);e||(e=qi(i.audio,U.AUDIO)),r||(r=qi(i.video,U.VIDEO));var a={};i.audio&&i.video?a.audiovideo={container:"video/mp4",codec:e+","+r,initSegment:t,id:"main"}:i.audio?a.audio={container:"audio/mp4",codec:e,initSegment:t,id:"audio"}:i.video?a.video={container:"video/mp4",codec:r,initSegment:t,id:"main"}:w.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=a},e.remux=function(t,e,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};L(u)||(u=this.lastEndTime=a||0);var h=e.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 w.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),d;this.emitInitSegment&&(f.tracks=this.initTracks,this.emitInitSegment=!1);var v=bt(h,c),g=Rt(c,h),m=null===g?a:g;(ji(l,m,a,v)||f.timescale!==l.timescale&&n)&&(f.initPTS=m-a,l&&1===l.timescale&&w.warn("Adjusting initPTS by "+(f.initPTS-l.baseTime)),this.initPTS=l={baseTime:f.initPTS,timescale:1});var p=t?m-l.baseTime/l.timescale:u,y=p+v;kt(c,h,l.baseTime/l.timescale),v>0?this.lastEndTime=y:(w.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var E=!!c.audio,T=!!c.video,S="";E&&(S+="audio"),T&&(S+="video");var A={data1:h,startPTS:p,startDTS:p,endPTS:y,endDTS:y,type:S,hasAudio:E,hasVideo:T,nb:1,dropped:0};return d.audio="audio"===A.type?A:void 0,d.video="audio"!==A.type?A:void 0,d.initSegment=f,d.id3=Gi(r,a,l,l),i.samples.length&&(d.text=Ki(i,a,l)),d},t}();function ji(t,e,r,i){if(null===t)return!0;var a=Math.max(i,1),n=e-t.baseTime/t.timescale;return Math.abs(n-r)>a}function qi(t,e){var r=null==t?void 0:t.codec;return r&&r.length>4?r:"hvc1"===r||"hev1"===r?"hvc1.1.6.L120.90":"av01"===r?"av01.0.04M.08":"avc1"===r||e===U.VIDEO?"avc1.42e01e":"mp4a.40.5"}try{Vi=self.performance.now.bind(self.performance)}catch(t){w.debug("Unable to use Performance API on this environment"),Vi="undefined"!=typeof self&&self.Date.now}var zi=[{demux:ii,remux:Yi},{demux:yi,remux:Ni},{demux:ei,remux:Ni},{demux:bi,remux:Ni}],Xi=function(){function t(t,e,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=t,this.typeSupported=e,this.config=r,this.vendor=i,this.id=a}var e=t.prototype;return e.configure=function(t){this.transmuxConfig=t,this.decrypter&&this.decrypter.reset()},e.push=function(t,e,r,i){var a=this,n=r.transmuxing;n.executeStart=Vi();var s=new Uint8Array(t),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,E=l.duration,T=l.initSegmentData,L=Qi(s,e);if(L&&"AES-128"===L.method){var b=this.getDecrypter();if(!b.isSync())return this.decryptionPromise=b.webCryptoDecrypt(s,L.key.buffer,L.iv.buffer).then((function(t){var e=a.push(t,null,r);return a.decryptionPromise=null,e})),this.decryptionPromise;var D=b.softwareDecrypt(s,L.key.buffer,L.iv.buffer);if(r.part>-1&&(D=b.flush()),!D)return n.executeEnd=Vi(),$i(r);s=new Uint8Array(D)}var k=this.needsProbing(h,f);if(k){var I=this.configureTransmuxer(s);if(I)return w.warn("[transmuxer] "+I.message),this.observer.emit(S.ERROR,S.ERROR,{type:A.MEDIA_ERROR,details:R.FRAG_PARSING_ERROR,fatal:!1,error:I,reason:I.message}),n.executeEnd=Vi(),$i(r)}(h||f||g||k)&&this.resetInitSegment(T,m,p,E,e),(h||g||k)&&this.resetInitialTimestamp(y),d||this.resetContiguity();var _=this.transmux(s,L,v,c,r),x=this.currentTransmuxState;return x.contiguous=!0,x.discontinuity=!1,x.trackSwitch=!1,n.executeEnd=Vi(),_},e.flush=function(t){var e=this,r=t.transmuxing;r.executeStart=Vi();var i=this.decrypter,a=this.currentTransmuxState,n=this.decryptionPromise;if(n)return n.then((function(){return e.flush(t)}));var s=[],o=a.timeOffset;if(i){var l=i.flush();l&&s.push(this.push(l,null,t))}var u=this.demuxer,d=this.remuxer;if(!u||!d)return r.executeEnd=Vi(),[$i(t)];var h=u.flush(o);return Zi(h)?h.then((function(r){return e.flushRemux(s,r,t),s})):(this.flushRemux(s,h,t),s)},e.flushRemux=function(t,e,r){var i=e.audioTrack,a=e.videoTrack,n=e.id3Track,s=e.textTrack,o=this.currentTransmuxState,l=o.accurateTimeOffset,u=o.timeOffset;w.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);t.push({remuxResult:d,chunkMeta:r}),r.transmuxing.executeEnd=Vi()},e.resetInitialTimestamp=function(t){var e=this.demuxer,r=this.remuxer;e&&r&&(e.resetTimeStamp(t),r.resetTimeStamp(t))},e.resetContiguity=function(){var t=this.demuxer,e=this.remuxer;t&&e&&(t.resetContiguity(),e.resetNextTimestamp())},e.resetInitSegment=function(t,e,r,i,a){var n=this.demuxer,s=this.remuxer;n&&s&&(n.resetInitSegment(t,e,r,i),s.resetInitSegment(t,e,r,a))},e.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},e.transmux=function(t,e,r,i,a){return e&&"SAMPLE-AES"===e.method?this.transmuxSampleAes(t,e,r,i,a):this.transmuxUnencrypted(t,r,i,a)},e.transmuxUnencrypted=function(t,e,r,i){var a=this.demuxer.demux(t,e,!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,e,r,!1,this.id),chunkMeta:i}},e.transmuxSampleAes=function(t,e,r,i,a){var n=this;return this.demuxer.demuxSampleAes(t,e,r).then((function(t){return{remuxResult:n.remuxer.remux(t.audioTrack,t.videoTrack,t.id3Track,t.textTrack,r,i,!1,n.id),chunkMeta:a}}))},e.configureTransmuxer=function(t){for(var e,r=this.config,i=this.observer,a=this.typeSupported,n=this.vendor,s=0,o=zi.length;s<o;s++)if(zi[s].demux.probe(t)){e=zi[s];break}if(!e)return new Error("Failed to find demuxer by probing fragment data");var l=this.demuxer,u=this.remuxer,d=e.remux,h=e.demux;u&&u instanceof d||(this.remuxer=new d(i,r,a,n)),l&&l instanceof h||(this.demuxer=new h(i,r,a),this.probe=h.probe)},e.needsProbing=function(t,e){return!this.demuxer||!this.remuxer||t||e},e.getDecrypter=function(){var t=this.decrypter;return t||(t=this.decrypter=new Pr(this.config)),t},t}();function Qi(t,e){var r=null;return t.byteLength>0&&null!=e&&null!=e.key&&null!==e.iv&&null!=e.method&&(r=e),r}var $i=function(t){return{remuxResult:{},chunkMeta:t}};function Zi(t){return"then"in t&&t.then instanceof Function}var Ji=function(t,e,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=t,this.videoCodec=e,this.initSegmentData=r,this.duration=i,this.defaultInitPts=a||null},ta=function(t,e,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=t,this.contiguous=e,this.accurateTimeOffset=r,this.trackSwitch=i,this.timeOffset=a,this.initSegmentChange=n},ea={exports:{}};!function(t){var e=Object.prototype.hasOwnProperty,r="~";function i(){}function a(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function n(t,e,i,n,s){if("function"!=typeof i)throw new TypeError("The listener must be a function");var o=new a(i,n||t,s),l=r?r+e:e;return t._events[l]?t._events[l].fn?t._events[l]=[t._events[l],o]:t._events[l].push(o):(t._events[l]=o,t._eventsCount++),t}function s(t,e){0==--t._eventsCount?t._events=new i:delete t._events[e]}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 t,i,a=[];if(0===this._eventsCount)return a;for(i in t=this._events)e.call(t,i)&&a.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?a.concat(Object.getOwnPropertySymbols(t)):a},o.prototype.listeners=function(t){var e=r?r+t:t,i=this._events[e];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(t){var e=r?r+t:t,i=this._events[e];return i?i.fn?1:i.length:0},o.prototype.emit=function(t,e,i,a,n,s){var o=r?r+t:t;if(!this._events[o])return!1;var l,u,d=this._events[o],h=arguments.length;if(d.fn){switch(d.once&&this.removeListener(t,d.fn,void 0,!0),h){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,e),!0;case 3:return d.fn.call(d.context,e,i),!0;case 4:return d.fn.call(d.context,e,i,a),!0;case 5:return d.fn.call(d.context,e,i,a,n),!0;case 6:return d.fn.call(d.context,e,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(t,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,e);break;case 3:d[u].fn.call(d[u].context,e,i);break;case 4:d[u].fn.call(d[u].context,e,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(t,e,r){return n(this,t,e,r,!1)},o.prototype.once=function(t,e,r){return n(this,t,e,r,!0)},o.prototype.removeListener=function(t,e,i,a){var n=r?r+t:t;if(!this._events[n])return this;if(!e)return s(this,n),this;var o=this._events[n];if(o.fn)o.fn!==e||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!==e||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(t){var e;return t?(e=r?r+t:t,this._events[e]&&s(this,e)):(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,t.exports=o}(ea);var ra=y(ea.exports);function ia(t){var e=new ra,r=function(e,r){t.postMessage({event:e,data:r})};e.on(S.FRAG_DECRYPTED,r),e.on(S.ERROR,r);var i=function(){var t=function(t){var e=function(e){r("workerLog",{logType:t,message:e})};w[t]=e};for(var e in w)t(e)};t.addEventListener("message",(function(a){var n=a.data;switch(n.cmd){case"init":var s=JSON.parse(n.config);t.transmuxer=new Xi(e,n.typeSupported,s,n.vendor,n.id),x(s.debug,n.id),i(),r("init",null);break;case"configure":t.transmuxer.configure(n.config);break;case"demux":var o=t.transmuxer.push(n.data,n.decryptdata,n.chunkMeta,n.state);Zi(o)?(t.transmuxer.async=!0,o.then((function(e){aa(t,e)})).catch((function(t){r(S.ERROR,{type:A.MEDIA_ERROR,details:R.FRAG_PARSING_ERROR,chunkMeta:n.chunkMeta,fatal:!1,error:t,err:t,reason:"transmuxer-worker push error"})}))):(t.transmuxer.async=!1,aa(t,o));break;case"flush":var l=n.chunkMeta,u=t.transmuxer.flush(l);Zi(u)||t.transmuxer.async?(Zi(u)||(u=Promise.resolve(u)),u.then((function(e){sa(t,e,l)})).catch((function(t){r(S.ERROR,{type:A.MEDIA_ERROR,details:R.FRAG_PARSING_ERROR,chunkMeta:n.chunkMeta,fatal:!1,error:t,err:t,reason:"transmuxer-worker flush error"})}))):sa(t,u,l)}}))}function aa(t,e){if(oa(e.remuxResult))return!1;var r=[],i=e.remuxResult,a=i.audio,n=i.video;return a&&na(r,a),n&&na(r,n),t.postMessage({event:"transmuxComplete",data:e},r),!0}function na(t,e){e.data1&&t.push(e.data1.buffer),e.data2&&t.push(e.data2.buffer)}function sa(t,e,r){e.reduce((function(e,r){return aa(t,r)||e}),!1)||t.postMessage({event:"transmuxComplete",data:e[0]}),t.postMessage({event:"flush",data:r})}function oa(t){return!(t.audio||t.video||t.text||t.id3||t.initSegment)}function la(){return!0}function ua(){var t=new self.Blob(["var exports={};var module={exports:exports};function define(f){f()};define.amd=true;("+e.toString()+")(true);"],{type:"text/javascript"}),r=self.URL.createObjectURL(t);return{worker:new self.Worker(r),objectURL:r}}function da(t){var e=new self.URL(t,self.location.href).href;return{worker:new self.Worker(e),scriptURL:e}}void 0!==r&&r&&ia(self);var ha=Bt()||{isTypeSupported:function(){return!1}},fa=function(){function t(t,e,r,i){var a=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 n=t.config;this.hls=t,this.id=e,this.useWorker=!!n.enableWorker,this.onTransmuxComplete=r,this.onFlush=i;var s=function(t,e){(e=e||{}).frag=a.frag,e.id=a.id,t===S.ERROR&&(a.error=e.error),a.hls.trigger(t,e)};this.observer=new ra,this.observer.on(S.FRAG_DECRYPTED,s),this.observer.on(S.ERROR,s);var o={mp4:ha.isTypeSupported("video/mp4"),mpeg:ha.isTypeSupported("audio/mpeg"),mp3:ha.isTypeSupported('audio/mp4; codecs="mp3"')},l=navigator.vendor;if(this.useWorker&&"undefined"!=typeof Worker&&(n.workerPath||la()))try{n.workerPath?(w.log("loading Web Worker "+n.workerPath+' for "'+e+'"'),this.workerContext=da(n.workerPath)):(w.log('injecting Web Worker for "'+e+'"'),this.workerContext=ua()),this.onwmsg=function(t){return a.onWorkerMessage(t)};var u=this.workerContext.worker;u.addEventListener("message",this.onwmsg),u.onerror=function(t){var r=new Error(t.message+" ("+t.filename+":"+t.lineno+")");n.enableWorker=!1,w.warn('Error in "'+e+'" Web Worker, fallback to inline'),a.hls.trigger(S.ERROR,{type:A.OTHER_ERROR,details:R.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:r})},u.postMessage({cmd:"init",typeSupported:o,vendor:l,id:e,config:JSON.stringify(n)})}catch(t){w.warn('Error setting up "'+e+'" Web Worker, fallback to inline',t),this.resetWorker(),this.error=null,this.transmuxer=new Xi(this.observer,o,n,l,e)}else this.transmuxer=new Xi(this.observer,o,n,l,e)}var e=t.prototype;return e.resetWorker=function(){if(this.workerContext){var t=this.workerContext,e=t.worker,r=t.objectURL;r&&self.URL.revokeObjectURL(r),e.removeEventListener("message",this.onwmsg),e.onerror=null,e.terminate(),this.workerContext=null}},e.destroy=function(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{var t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null)}var e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},e.push=function(t,e,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,L=0===E&&l.id>1&&l.id===(null==m?void 0:m.stats.chunkCount),S=!y&&(1===E||0===E&&(1===T||L&&T<=0)),A=self.performance.now();(y||E||0===a.stats.parsing.start)&&(a.stats.parsing.start=A),!n||!T&&S||(n.stats.parsing.start=A);var R=!(m&&(null==(d=a.initSegment)?void 0:d.url)===(null==(h=m.initSegment)?void 0:h.url)),b=new ta(p,S,o,y,v,R);if(!S||p||R){w.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: "+S+"\n accurateTimeOffset: "+o+"\n timeOffset: "+v+"\n initSegmentChange: "+R);var D=new Ji(r,i,e,s,u);this.configureTransmuxer(D)}if(this.frag=a,this.part=n,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:t,decryptdata:g,chunkMeta:l,state:b},t instanceof ArrayBuffer?[t]:[]);else if(c){var k=c.push(t,g,l,b);Zi(k)?(c.async=!0,k.then((function(t){f.handleTransmuxComplete(t)})).catch((function(t){f.transmuxerError(t,l,"transmuxer-interface push error")}))):(c.async=!1,this.handleTransmuxComplete(k))}},e.flush=function(t){var e=this;t.transmuxing.start=self.performance.now();var r=this.transmuxer;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:t});else if(r){var i=r.flush(t);Zi(i)||r.async?(Zi(i)||(i=Promise.resolve(i)),i.then((function(r){e.handleFlushResult(r,t)})).catch((function(r){e.transmuxerError(r,t,"transmuxer-interface flush error")}))):this.handleFlushResult(i,t)}},e.transmuxerError=function(t,e,r){this.hls&&(this.error=t,this.hls.trigger(S.ERROR,{type:A.MEDIA_ERROR,details:R.FRAG_PARSING_ERROR,chunkMeta:e,fatal:!1,error:t,err:t,reason:r}))},e.handleFlushResult=function(t,e){var r=this;t.forEach((function(t){r.handleTransmuxComplete(t)})),this.onFlush(e)},e.onWorkerMessage=function(t){var e=t.data,r=this.hls;switch(e.event){case"init":var i,a=null==(i=this.workerContext)?void 0:i.objectURL;a&&self.URL.revokeObjectURL(a);break;case"transmuxComplete":this.handleTransmuxComplete(e.data);break;case"flush":this.onFlush(e.data);break;case"workerLog":w[e.data.logType]&&w[e.data.logType](e.data.message);break;default:e.data=e.data||{},e.data.frag=this.frag,e.data.id=this.id,r.trigger(e.event,e.data)}},e.configureTransmuxer=function(t){var e=this.transmuxer;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:t}):e&&e.configure(t)},e.handleTransmuxComplete=function(t){t.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(t)},t}(),ca=250,va=2,ga=.1,ma=.05,pa=function(){function t(t,e,r,i){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=t,this.media=e,this.fragmentTracker=r,this.hls=i}var e=t.prototype;return e.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},e.poll=function(t,e){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===t){if(l||o)this.stalled=null;else if(!(i.paused&&!s||i.ended||0===i.playbackRate)&&pr.getBuffered(i).length){var u=pr.bufferInfo(i,n,0),d=u.len>0,h=u.nextStart||0;if(d||h){if(s){var f=u.len>va,c=!h||e&&e.start<=n||h-n>va&&!this.fragmentTracker.getPartialFragment(n);if(f||c)return;this.moved=!1}if(!this.moved&&null!==this.stalled){var v,g=Math.max(h,u.start||0)-n,m=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,p=(null==m||null==(v=m.details)?void 0:v.live)?2*m.details.targetduration:va,y=this.fragmentTracker.getPartialFragment(n);if(g>0&&(g<=p||y))return void this._trySkipBufferHole(y)}var E=self.performance.now();if(null!==a){var T=E-a;if(s||!(T>=ca)||(this._reportStall(u),this.media)){var L=pr.bufferInfo(i,n,r.maxBufferHole);this._tryFixBufferStall(L,T)}}else this.stalled=E}}}else if(this.moved=!0,null!==a){if(this.stallReported){var S=self.performance.now()-a;w.warn("playback not stuck anymore @"+n+", after "+Math.round(S)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}}},e._tryFixBufferStall=function(t,e){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;(t.len>r.maxBufferHole||t.nextStart&&t.nextStart-n<r.maxBufferHole)&&e>1e3*r.highBufferWatchdogPeriod&&(w.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},e._reportStall=function(t){var e=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(t)+")");w.warn(i.message),e.trigger(S.ERROR,{type:A.MEDIA_ERROR,details:R.BUFFER_STALLED_ERROR,fatal:!1,error:i,buffer:t.len})}},e._trySkipBufferHole=function(t){var e=this.config,r=this.hls,i=this.media;if(null===i)return 0;var a=i.currentTime,n=pr.bufferInfo(i,a,0),s=a<n.start?n.start:n.nextStart;if(s){var o=n.len<=e.maxBufferHole,l=n.len>0&&n.len<1&&i.readyState<3,u=s-a;if(u>0&&(o||l)){if(u>e.maxBufferHole){var d=this.fragmentTracker,h=!1;if(0===a){var f=d.getAppendedFrag(0,ae.MAIN);f&&s<f.end&&(h=!0)}if(!h){var c=t||d.getAppendedFrag(a,ae.MAIN);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+ma,a+ga);if(w.warn("skipping hole, adjusting currentTime from "+a+" to "+p),this.moved=!0,this.stalled=null,i.currentTime=p,t&&!t.gap){var y=new Error("fragment loaded with buffer holes, seeking from "+a+" to "+p);r.trigger(S.ERROR,{type:A.MEDIA_ERROR,details:R.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:y,reason:y.message,frag:t})}return p}}return 0},e._tryNudgeBuffer=function(){var t=this.config,e=this.hls,r=this.media,i=this.nudgeRetry;if(null!==r){var a=r.currentTime;if(this.nudgeRetry++,i<t.nudgeMaxRetry){var n=a+(i+1)*t.nudgeOffset,s=new Error("Nudging 'currentTime' from "+a+" to "+n);w.warn(s.message),r.currentTime=n,e.trigger(S.ERROR,{type:A.MEDIA_ERROR,details:R.BUFFER_NUDGE_ON_STALL,error:s,fatal:!1})}else{var o=new Error("Playhead still not moving while enough data buffered @"+a+" after "+t.nudgeMaxRetry+" nudges");w.error(o.message),e.trigger(S.ERROR,{type:A.MEDIA_ERROR,details:R.BUFFER_STALLED_ERROR,error:o,fatal:!0})}}},t}(),ya=100,Ea=function(t){function e(e,r,i){var a;return(a=t.call(this,e,r,i,"[stream-controller]",ae.MAIN)||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(e,t);var r=e.prototype;return r._registerListeners=function(){var t=this.hls;t.on(S.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(S.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(S.MANIFEST_LOADING,this.onManifestLoading,this),t.on(S.MANIFEST_PARSED,this.onManifestParsed,this),t.on(S.LEVEL_LOADING,this.onLevelLoading,this),t.on(S.LEVEL_LOADED,this.onLevelLoaded,this),t.on(S.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.on(S.ERROR,this.onError,this),t.on(S.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(S.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(S.BUFFER_CREATED,this.onBufferCreated,this),t.on(S.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(S.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(S.FRAG_BUFFERED,this.onFragBuffered,this)},r._unregisterListeners=function(){var t=this.hls;t.off(S.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(S.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(S.MANIFEST_LOADING,this.onManifestLoading,this),t.off(S.MANIFEST_PARSED,this.onManifestParsed,this),t.off(S.LEVEL_LOADED,this.onLevelLoaded,this),t.off(S.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.off(S.ERROR,this.onError,this),t.off(S.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(S.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(S.BUFFER_CREATED,this.onBufferCreated,this),t.off(S.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(S.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(S.FRAG_BUFFERED,this.onFragBuffered,this)},r.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},r.startLoad=function(t){if(this.levels){var e=this.lastCurrentTime,r=this.hls;if(this.stopLoad(),this.setInterval(ya),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.nextAutoLevel),this.level=r.nextLoadLevel=i,this.loadedmetadata=!1}e>0&&-1===t&&(this.log("Override startPosition with lastCurrentTime @"+e.toFixed(3)),t=e),this.state=Fr.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this._forceStartLoad=!0,this.state=Fr.STOPPED},r.stopLoad=function(){this._forceStartLoad=!1,t.prototype.stopLoad.call(this)},r.doTick=function(){switch(this.state){case Fr.WAITING_LEVEL:var t,e=this.levels,r=this.level,i=null==e||null==(t=e[r])?void 0:t.details;if(i&&(!i.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(i))break;this.state=Fr.IDLE;break}if(this.hls.nextLoadLevel!==this.level){this.state=Fr.IDLE;break}break;case Fr.FRAG_LOADING_WAITING_RETRY:var a,n=self.performance.now(),s=this.retryDate;(!s||n>=s||null!=(a=this.media)&&a.seeking)&&(this.resetStartWhenNotLoaded(this.level),this.state=Fr.IDLE)}this.state===Fr.IDLE&&this.doTickIdle(),this.onTickEnd()},r.onTickEnd=function(){t.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},r.doTickIdle=function(){var t=this.hls,e=this.levelLastLoaded,r=this.levels,i=this.media,a=t.config,n=t.nextLoadLevel;if(null!==e&&(i||!this.startFragRequested&&a.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)&&null!=r&&r[n]){var s=r[n],o=this.getMainFwdBufferInfo();if(null!==o){var l=this.getLevelDetails();if(l&&this._streamEnded(o,l)){var u={};return this.altAudio&&(u.type="video"),this.hls.trigger(S.BUFFER_EOS,u),void(this.state=Fr.ENDED)}t.loadLevel!==n&&-1===t.manualLevel&&this.log("Adapting to level "+n+" from level "+this.level),this.level=t.nextLoadLevel=n;var d=s.details;if(!d||this.state===Fr.WAITING_LEVEL||d.live&&this.levelLastLoaded!==n)return this.level=n,void(this.state=Fr.WAITING_LEVEL);var h=o.len,f=this.getMaxBufferLength(s.maxBitrate);if(!(h>=f)){this.backtrackFragment&&this.backtrackFragment.start>o.end&&(this.backtrackFragment=null);var c=this.backtrackFragment?this.backtrackFragment.start:o.end,v=this.getNextFragment(c,d);if(this.couldBacktrack&&!this.fragPrevious&&v&&"initSegment"!==v.sn&&this.fragmentTracker.getState(v)!==nr.OK){var g,m=(null!=(g=this.backtrackFragment)?g:v).sn-d.startSN,p=d.fragments[m-1];p&&v.cc===p.cc&&(v=p,this.fragmentTracker.removeFragment(p))}else this.backtrackFragment&&o.len&&(this.backtrackFragment=null);if(v&&this.isLoopLoading(v,c)){if(!v.gap){var y=this.audioOnly&&!this.altAudio?U.AUDIO:U.VIDEO,E=(y===U.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;E&&this.afterBufferFlushed(E,y,ae.MAIN)}v=this.getNextFragmentLoopLoading(v,d,o,ae.MAIN,f)}v&&(!v.initSegment||v.initSegment.data||this.bitrateTest||(v=v.initSegment),this.loadFragment(v,s,c))}}}},r.loadFragment=function(e,r,i){var a=this.fragmentTracker.getState(e);this.fragCurrent=e,a===nr.NOT_LOADED||a===nr.PARTIAL?"initSegment"===e.sn?this._loadInitSegment(e,r):this.bitrateTest?(this.log("Fragment "+e.sn+" of level "+e.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(e,r)):(this.startFragRequested=!0,t.prototype.loadFragment.call(this,e,r,i)):this.clearTrackerIfNeeded(e)},r.getBufferedFrag=function(t){return this.fragmentTracker.getBufferedFrag(t,ae.MAIN)},r.followingBufferedFrag=function(t){return t?this.getBufferedFrag(t.end+.5):null},r.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},r.nextLevelSwitch=function(){var t=this.levels,e=this.media;if(null!=e&&e.readyState){var r,i=this.getAppendedFrag(e.currentTime);i&&i.start>1&&this.flushMainBuffer(0,i.start-1);var a=this.getLevelDetails();if(null!=a&&a.live){var n=this.getMainFwdBufferInfo();if(!n||n.len<2*a.targetduration)return}if(!e.paused&&t){var s=t[this.hls.nextLoadLevel],o=this.fragLastKbps;r=o&&this.fragCurrent?this.fragCurrent.duration*s.maxBitrate/(1e3*o)+1:0}else r=0;var l=this.getBufferedFrag(e.currentTime+r);if(l){var u=this.followingBufferedFrag(l);if(u){this.abortCurrentFrag();var d=u.maxStartPTS?u.maxStartPTS:u.start,h=u.duration,f=Math.max(l.end,d+Math.min(Math.max(h-this.config.maxFragLookUpTolerance,.5*h),.75*h));this.flushMainBuffer(f,Number.POSITIVE_INFINITY)}}}},r.abortCurrentFrag=function(){var t=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,t&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.state){case Fr.KEY_LOADING:case Fr.FRAG_LOADING:case Fr.FRAG_LOADING_WAITING_RETRY:case Fr.PARSING:case Fr.PARSED:this.state=Fr.IDLE}this.nextLoadPosition=this.getLoadPosition()},r.flushMainBuffer=function(e,r){t.prototype.flushMainBuffer.call(this,e,r,this.altAudio?"video":null)},r.onMediaAttached=function(e,r){t.prototype.onMediaAttached.call(this,e,r);var i=r.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),i.addEventListener("playing",this.onvplaying),i.addEventListener("seeked",this.onvseeked),this.gapController=new pa(this.config,i,this.fragmentTracker,this.hls)},r.onMediaDetaching=function(){var e=this.media;e&&this.onvplaying&&this.onvseeked&&(e.removeEventListener("playing",this.onvplaying),e.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),t.prototype.onMediaDetaching.call(this)},r.onMediaPlaying=function(){this.tick()},r.onMediaSeeked=function(){var t=this.media,e=t?t.currentTime:null;L(e)&&this.log("Media seeked to "+e.toFixed(3));var r=this.getMainFwdBufferInfo();null!==r&&0!==r.len?this.tick():this.warn('Main forward buffer length on "seeked" event '+(r?r.len:"empty")+")")},r.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(S.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.levels=this.fragPlaying=this.backtrackFragment=null,this.altAudio=this.audioOnly=!1},r.onManifestParsed=function(t,e){var r,i=!1,a=!1;e.levels.forEach((function(t){(r=t.audioCodec)&&(-1!==r.indexOf("mp4a.40.2")&&(i=!0),-1!==r.indexOf("mp4a.40.5")&&(a=!0))})),this.audioCodecSwitch=i&&a&&!Ur(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=e.levels,this.startFragRequested=!1},r.onLevelLoading=function(t,e){var r=this.levels;if(r&&this.state===Fr.IDLE){var i=r[e.level];(!i.details||i.details.live&&this.levelLastLoaded!==e.level||this.waitForCdnTuneIn(i.details))&&(this.state=Fr.WAITING_LEVEL)}},r.onLevelLoaded=function(t,e){var r,i=this.levels,a=e.level,n=e.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!==Fr.FRAG_LOADING&&this.state!==Fr.FRAG_LOADING_WAITING_RETRY||l.level===e.level&&l.urlId===o.urlId||!l.loader||this.abortCurrentFrag();var u=0;if(n.live||null!=(r=o.details)&&r.live){if(this.checkLiveUpdate(n),n.deltaUpdateFailed)return;u=this.alignPlaylists(n,o.details)}if(o.details=n,this.levelLastLoaded=a,this.hls.trigger(S.LEVEL_UPDATED,{details:n,level:a}),this.state===Fr.WAITING_LEVEL){if(this.waitForCdnTuneIn(n))return;this.state=Fr.IDLE}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(t){var e,r=t.frag,i=t.part,a=t.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==(e=r.initSegment)?void 0:e.data,h=this._getAudioCodec(s),f=this.transmuxer=this.transmuxer||new fa(this.hls,ae.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),c=i?i.index:-1,v=-1!==c,g=new yr(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(t,e){var r=this.altAudio;if(!e.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var i=this.fragCurrent;i&&(this.log("Switching to main audio track, cancel main fragment load"),i.abortRequests(),this.fragmentTracker.removeFragment(i)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var a=this.hls;r&&(a.trigger(S.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),a.trigger(S.AUDIO_TRACK_SWITCHED,e)}},r.onAudioTrackSwitched=function(t,e){var r=e.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(t,e){var r,i,a=e.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(t,e){var r=e.frag,i=e.part;if(!r||r.type===ae.MAIN){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===Fr.PARSED&&(this.state=Fr.IDLE));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(t,e){var r;if(e.fatal)this.state=Fr.ERROR;else switch(e.details){case R.FRAG_GAP:case R.FRAG_PARSING_ERROR:case R.FRAG_DECRYPT_ERROR:case R.FRAG_LOAD_ERROR:case R.FRAG_LOAD_TIMEOUT:case R.KEY_LOAD_ERROR:case R.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(ae.MAIN,e);break;case R.LEVEL_LOAD_ERROR:case R.LEVEL_LOAD_TIMEOUT:case R.LEVEL_PARSING_ERROR:e.levelRetry||this.state!==Fr.WAITING_LEVEL||(null==(r=e.context)?void 0:r.type)!==ie.LEVEL||(this.state=Fr.IDLE);break;case R.BUFFER_FULL_ERROR:if(!e.parent||"main"!==e.parent)return;this.reduceLengthAndFlushBuffer(e)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case R.INTERNAL_EXCEPTION:this.recoverWorkerError(e)}},r.checkBuffer=function(){var t=this.media,e=this.gapController;if(t&&e&&t.readyState){if(this.loadedmetadata||!pr.getBuffered(t).length){var r=this.state!==Fr.IDLE?this.fragCurrent:null;e.poll(this.lastCurrentTime,r)}this.lastCurrentTime=t.currentTime}},r.onFragLoadEmergencyAborted=function(){this.state=Fr.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},r.onBufferFlushed=function(t,e){var r=e.type;if(r!==U.AUDIO||this.audioOnly&&!this.altAudio){var i=(r===U.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(i,r,ae.MAIN)}},r.onLevelsUpdated=function(t,e){this.levels=e.levels},r.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},r.seekToStartPos=function(){var t=this.media;if(t){var e=t.currentTime,r=this.startPosition;if(r>=0&&e<r){if(t.seeking)return void this.log("could not seek to "+r+", already seeking at "+e);var i=pr.getBuffered(t),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 "+e),t.currentTime=r}}},r._getAudioCodec=function(t){var e=this.config.defaultAudioCodec||t.audioCodec;return this.audioCodecSwap&&e&&(this.log("Swapping audio codec"),e=-1!==e.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),e},r._loadBitrateTestFrag=function(t,e){var r=this;t.bitrateTest=!0,this._doFragLoad(t,e).then((function(i){var a=r.hls;if(i&&!r.fragContextChanged(t)){e.fragmentError=0,r.state=Fr.IDLE,r.startFragRequested=!1,r.bitrateTest=!1;var n=t.stats;n.parsing.start=n.parsing.end=n.buffering.start=n.buffering.end=self.performance.now(),a.trigger(S.FRAG_LOADED,i),t.bitrateTest=!1}}))},r._handleTransmuxComplete=function(t){var e,r="main",i=this.hls,a=t.remuxResult,n=t.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=Fr.PARSING,c){if(null!=c&&c.tracks){var m=o.initSegment||o;this._bufferInitSegment(u,c.tracks,m,n),i.trigger(S.FRAG_PARSING_INIT_SEGMENT,{frag:m,id:r,tracks:c.tracks})}var p=c.initPTS,y=c.timescale;L(p)&&(this.initPTS[o.cc]={baseTime:p,timescale:y},i.trigger(S.INIT_PTS_FOUND,{frag:o,id:r,initPTS:p,timescale:y}))}if(d&&v&&"initSegment"!==o.sn){var E=v.fragments[o.sn-1-v.startSN],T=o.sn===v.startSN,A=!E||o.cc>E.cc;if(!1!==a.independent){var R=d.startPTS,b=d.endPTS,D=d.startDTS,k=d.endDTS;if(l)l.elementaryStreams[d.type]={startPTS:R,endPTS:b,startDTS:D,endDTS:k};else if(d.firstKeyFrame&&d.independent&&1===n.id&&!A&&(this.couldBacktrack=!0),d.dropped&&d.independent){var I=this.getMainFwdBufferInfo(),_=(I?I.end:this.getLoadPosition())+this.config.maxBufferHole,x=d.firstKeyFramePTS?d.firstKeyFramePTS:R;if(!T&&_<x-this.config.maxBufferHole&&!A)return void this.backtrack(o);A&&(o.gap=!0),o.setElementaryStreamInfo(d.type,o.start,b,o.start,k,!0)}o.setElementaryStreamInfo(d.type,R,b,D,k),this.backtrackFragment&&(this.backtrackFragment=o),this.bufferFragmentData(d,o,l,n,T||A)}else{if(!T&&!A)return void this.backtrack(o);o.gap=!0}}if(g){var w=g.startPTS,C=g.endPTS,P=g.startDTS,O=g.endDTS;l&&(l.elementaryStreams[U.AUDIO]={startPTS:w,endPTS:C,startDTS:P,endDTS:O}),o.setElementaryStreamInfo(U.AUDIO,w,C,P,O),this.bufferFragmentData(g,o,l,n)}if(v&&null!=f&&null!=(e=f.samples)&&e.length){var F={id:r,frag:o,details:v,samples:f.samples};i.trigger(S.FRAG_PARSING_METADATA,F)}if(v&&h){var M={id:r,frag:o,details:v,samples:h.samples};i.trigger(S.FRAG_PARSING_USERDATA,M)}}}else this.resetWhenMissingContext(n)},r._bufferInitSegment=function(t,e,r,i){var a=this;if(this.state===Fr.PARSING){this.audioOnly=!!e.audio&&!e.video,this.altAudio&&!this.audioOnly&&delete e.audio;var n=e.audio,s=e.video,o=e.audiovideo;if(n){var l=t.audioCodec,u=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(l&&(l=-1!==l.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),1!==n.metadata.channelCount&&-1===u.indexOf("firefox")&&(l="mp4a.40.5")),-1!==u.indexOf("android")&&"audio/mpeg"!==n.container&&(l="mp4a.40.2",this.log("Android: force audio codec to "+l)),t.audioCodec&&t.audioCodec!==l&&this.log('Swapping manifest audio codec "'+t.audioCodec+'" for "'+l+'"'),n.levelCodec=l,n.id="main",this.log("Init audio buffer, container:"+n.container+", codecs[selected/level/parsed]=["+(l||"")+"/"+(t.audioCodec||"")+"/"+n.codec+"]")}s&&(s.levelCodec=t.videoCodec,s.id="main",this.log("Init video buffer, container:"+s.container+", codecs[level/parsed]=["+(t.videoCodec||"")+"/"+s.codec+"]")),o&&this.log("Init audiovideo buffer, container:"+o.container+", codecs[level/parsed]=["+(t.attrs.CODECS||"")+"/"+o.codec+"]"),this.hls.trigger(S.BUFFER_CODECS,e),Object.keys(e).forEach((function(t){var n=e[t].initSegment;null!=n&&n.byteLength&&a.hls.trigger(S.BUFFER_APPENDING,{type:t,data:n,frag:r,part:null,chunkMeta:i,parent:r.type})})),this.tick()}},r.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,ae.MAIN)},r.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=Fr.IDLE},r.checkFragmentChanged=function(){var t=this.media,e=null;if(t&&t.readyState>1&&!1===t.seeking){var r=t.currentTime;if(pr.isBuffered(t,r)?e=this.getAppendedFrag(r):pr.isBuffered(t,r+.1)&&(e=this.getAppendedFrag(r+.1)),e){this.backtrackFragment=null;var i=this.fragPlaying,a=e.level;i&&e.sn===i.sn&&i.level===a&&e.urlId===i.urlId||(this.fragPlaying=e,this.hls.trigger(S.FRAG_CHANGED,{frag:e}),i&&i.level===a||this.hls.trigger(S.LEVEL_SWITCHED,{level:a}))}}},n(e,[{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 e=t.currentTime,r=this.currentFrag;if(r&&L(e)&&L(r.programDateTime)){var i=r.programDateTime+1e3*(e-r.start);return new Date(i)}}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}}]),e}(Mr),Ta=function(){function t(t,e,r){void 0===e&&(e=0),void 0===r&&(r=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=t,this.alpha_=t?Math.exp(Math.log(.5)/t):0,this.estimate_=e,this.totalWeight_=r}var e=t.prototype;return e.sample=function(t,e){var r=Math.pow(this.alpha_,t);this.estimate_=e*(1-r)+r*this.estimate_,this.totalWeight_+=t},e.getTotalWeight=function(){return this.totalWeight_},e.getEstimate=function(){if(this.alpha_){var t=1-Math.pow(this.alpha_,this.totalWeight_);if(t)return this.estimate_/t}return this.estimate_},t}(),La=function(){function t(t,e,r,i){void 0===i&&(i=100),this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=r,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new Ta(t),this.fast_=new Ta(e),this.defaultTTFB_=i,this.ttfb_=new Ta(t)}var e=t.prototype;return e.update=function(t,e){var r=this.slow_,i=this.fast_,a=this.ttfb_;r.halfLife!==t&&(this.slow_=new Ta(t,r.getEstimate(),r.getTotalWeight())),i.halfLife!==e&&(this.fast_=new Ta(e,i.getEstimate(),i.getTotalWeight())),a.halfLife!==t&&(this.ttfb_=new Ta(t,a.getEstimate(),a.getTotalWeight()))},e.sample=function(t,e){var r=(t=Math.max(t,this.minDelayMs_))/1e3,i=8*e/r;this.fast_.sample(r,i),this.slow_.sample(r,i)},e.sampleTTFB=function(t){var e=t/1e3,r=Math.sqrt(2)*Math.exp(-Math.pow(e,2)/2);this.ttfb_.sample(r,Math.max(t,5))},e.canEstimate=function(){return this.fast_.getTotalWeight()>=this.minWeight_},e.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},e.getEstimateTTFB=function(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_},e.destroy=function(){},t}(),Sa=function(){function t(t){this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=-1,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=t;var e=t.config;this.bwEstimator=new La(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate),this.registerListeners()}var e=t.prototype;return e.registerListeners=function(){var t=this.hls;t.on(S.FRAG_LOADING,this.onFragLoading,this),t.on(S.FRAG_LOADED,this.onFragLoaded,this),t.on(S.FRAG_BUFFERED,this.onFragBuffered,this),t.on(S.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(S.LEVEL_LOADED,this.onLevelLoaded,this)},e.unregisterListeners=function(){var t=this.hls;t.off(S.FRAG_LOADING,this.onFragLoading,this),t.off(S.FRAG_LOADED,this.onFragLoaded,this),t.off(S.FRAG_BUFFERED,this.onFragBuffered,this),t.off(S.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(S.LEVEL_LOADED,this.onLevelLoaded,this)},e.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},e.onFragLoading=function(t,e){var r,i=e.frag;this.ignoreFragment(i)||(this.fragCurrent=i,this.partCurrent=null!=(r=e.part)?r:null,this.clearTimer(),this.timer=self.setInterval(this.onCheck,100))},e.onLevelSwitching=function(t,e){this.clearTimer()},e.getTimeToLoadFrag=function(t,e,r,i){return t+r/e+(i?this.lastLevelLoadSec:0)},e.onLevelLoaded=function(t,e){var r=this.hls.config,i=e.stats,a=i.total,n=i.bwEstimate;L(a)&&L(n)&&(this.lastLevelLoadSec=8*a/n),e.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)},e._abandonRulesCheck=function(){var t=this.fragCurrent,e=this.partCurrent,r=this.hls,i=r.autoLevelEnabled,a=r.media;if(t&&a){var n=performance.now(),s=e?e.stats:t.stats,o=e?e.duration:t.duration,l=n-s.loading.start;if(s.aborted||s.loaded&&s.loaded===s.total||0===t.level)return this.clearTimer(),void(this._nextAutoLevel=-1);if(i&&!a.paused&&a.playbackRate&&a.readyState){var u=r.mainForwardBufferInfo;if(null!==u){var d=this.bwEstimator.getEstimateTTFB(),h=Math.abs(a.playbackRate);if(!(l<=Math.max(d,o/(2*h)*1e3))){var f=u.len/h;if(!(f>=2*o/h)){var c=s.loading.first?s.loading.first-s.loading.start:-1,v=s.loaded&&c>-1,g=this.bwEstimator.getEstimate(),m=r.levels,p=r.minAutoLevel,y=m[t.level],E=s.total||Math.max(s.loaded,Math.round(o*y.maxBitrate/8)),T=l-c;T<1&&v&&(T=Math.min(l,8*s.loaded/g));var A=v?1e3*s.loaded/T:0,R=A?(E-s.loaded)/A:8*E/g+d/1e3;if(!(R<=f)){var b,D=A?8*A:g,k=Number.POSITIVE_INFINITY;for(b=t.level-1;b>p;b--){var I=m[b].maxBitrate;if((k=this.getTimeToLoadFrag(d/1e3,D,o*I,!m[b].details))<f)break}k>=R||k>10*o||(r.nextLoadLevel=b,v?this.bwEstimator.sample(l-Math.min(d,c),s.loaded):this.bwEstimator.sampleTTFB(l),this.clearTimer(),w.warn("[abr] Fragment "+t.sn+(e?" part "+e.index:"")+" of level "+t.level+" is loading too slowly;\n Time to underbuffer: "+f.toFixed(3)+" s\n Estimated load time for current fragment: "+R.toFixed(3)+" s\n Estimated load time for down switch fragment: "+k.toFixed(3)+" s\n TTFB estimate: "+c+"\n Current BW estimate: "+(L(g)?(g/1024).toFixed(3):"Unknown")+" Kb/s\n New BW estimate: "+(this.bwEstimator.getEstimate()/1024).toFixed(3)+" Kb/s\n Aborting and switching to level "+b),t.loader&&(this.fragCurrent=this.partCurrent=null,t.abortRequests()),r.trigger(S.FRAG_LOAD_EMERGENCY_ABORTED,{frag:t,part:e,stats:s}))}}}}}}},e.onFragLoaded=function(t,e){var r=e.frag,i=e.part,a=i?i.stats:r.stats;if(r.type===ae.MAIN&&this.bwEstimator.sampleTTFB(a.loading.first-a.loading.start),!this.ignoreFragment(r)){if(this.clearTimer(),this.lastLoadedFragLevel=r.level,this._nextAutoLevel=-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(S.FRAG_BUFFERED,u),r.bitrateTest=!1}}},e.onFragBuffered=function(t,e){var r=e.frag,i=e.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.bwEstimator.getEstimate(),r.bitrateTest?this.bitrateTestDelay=n/1e3:this.bitrateTestDelay=0}},e.ignoreFragment=function(t){return t.type!==ae.MAIN||"initSegment"===t.sn},e.clearTimer=function(){self.clearInterval(this.timer)},e.getNextABRAutoLevel=function(){var t=this.fragCurrent,e=this.partCurrent,r=this.hls,i=r.maxAutoLevel,a=r.config,n=r.minAutoLevel,s=r.media,o=e?e.duration:t?t.duration:0,l=s&&0!==s.playbackRate?Math.abs(s.playbackRate):1,u=this.bwEstimator?this.bwEstimator.getEstimate():a.abrEwmaDefaultEstimate,d=r.mainForwardBufferInfo,h=(d?d.len:0)/l,f=this.findBestLevel(u,n,i,h,a.abrBandWidthFactor,a.abrBandWidthUpFactor);if(f>=0)return f;w.trace("[abr] "+(h?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var c=o?Math.min(o,a.maxStarvationDelay):a.maxStarvationDelay,v=a.abrBandWidthFactor,g=a.abrBandWidthUpFactor;if(!h){var m=this.bitrateTestDelay;m&&(c=(o?Math.min(o,a.maxLoadingDelay):a.maxLoadingDelay)-m,w.trace("[abr] bitrate test took "+Math.round(1e3*m)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*c)+" ms"),v=g=1)}return f=this.findBestLevel(u,n,i,h+c,v,g),Math.max(f,0)},e.findBestLevel=function(t,e,r,i,a,n){for(var s,o=this.fragCurrent,l=this.partCurrent,u=this.lastLoadedFragLevel,d=this.hls.levels,h=d[u],f=!(null==h||null==(s=h.details)||!s.live),c=null==h?void 0:h.codecSet,v=l?l.duration:o?o.duration:0,g=this.bwEstimator.getEstimateTTFB()/1e3,m=e,p=-1,y=r;y>=e;y--){var E=d[y];if(!E||c&&E.codecSet!==c)E&&(m=Math.min(y,m),p=Math.max(y,p));else{-1!==p&&w.trace("[abr] Skipped level(s) "+m+"-"+p+' with CODECS:"'+d[p].attrs.CODECS+'"; not compatible with "'+h.attrs.CODECS+'"');var T=E.details,S=(l?null==T?void 0:T.partTarget:null==T?void 0:T.averagetargetduration)||v,A=void 0;A=y<=u?a*t:n*t;var R=d[y].maxBitrate,b=this.getTimeToLoadFrag(g,A,R*S,void 0===T);if(w.trace("[abr] level:"+y+" adjustedbw-bitrate:"+Math.round(A-R)+" avgDuration:"+S.toFixed(1)+" maxFetchDuration:"+i.toFixed(1)+" fetchDuration:"+b.toFixed(1)),A>R&&(0===b||!L(b)||f&&!this.bitrateTestDelay||b<i))return y}}return-1},n(t,[{key:"nextAutoLevel",get:function(){var t=this._nextAutoLevel,e=this.bwEstimator;if(-1!==t&&!e.canEstimate())return t;var r=this.getNextABRAutoLevel();if(-1!==t){var i=this.hls.levels;if(i.length>Math.max(t,r)&&i[t].loadError<=i[r].loadError)return t}return-1!==t&&(r=Math.min(t,r)),r},set:function(t){this._nextAutoLevel=t}}]),t}(),Aa=function(){function t(t){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=t}var e=t.prototype;return e.append=function(t,e){var r=this.queues[e];r.push(t),1===r.length&&this.buffers[e]&&this.executeNext(e)},e.insertAbort=function(t,e){this.queues[e].unshift(t),this.executeNext(e)},e.appendBlocker=function(t){var e,r=new Promise((function(t){e=t})),i={execute:e,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(i,t),r},e.executeNext=function(t){var e=this.buffers,r=this.queues,i=e[t],a=r[t];if(a.length){var n=a[0];try{n.execute()}catch(e){w.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),n.onError(e),null!=i&&i.updating||(a.shift(),this.executeNext(t))}}},e.shiftAndExecuteNext=function(t){this.queues[t].shift(),this.executeNext(t)},e.current=function(t){return this.queues[t][0]},t}(),Ra=Bt(),ba=/([ha]vc.)(?:\.[^.,]+)+/,Da=function(){function t(t){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.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=function(){var t=e.media,r=e.mediaSource;w.log("[buffer-controller]: Media source opened"),t&&(t.removeEventListener("emptied",e._onMediaEmptied),e.updateMediaElementDuration(),e.hls.trigger(S.MEDIA_ATTACHED,{media:t})),r&&r.removeEventListener("sourceopen",e._onMediaSourceOpen),e.checkPendingTracks()},this._onMediaSourceClose=function(){w.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){w.log("[buffer-controller]: Media source ended")},this._onMediaEmptied=function(){var t=e.media,r=e._objectUrl;t&&t.src!==r&&w.error("Media element src was set while attaching MediaSource ("+r+" > "+t.src+")")},this.hls=t,this._initSourceBuffer(),this.registerListeners()}var e=t.prototype;return e.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},e.destroy=function(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null},e.registerListeners=function(){var t=this.hls;t.on(S.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(S.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(S.MANIFEST_LOADING,this.onManifestLoading,this),t.on(S.MANIFEST_PARSED,this.onManifestParsed,this),t.on(S.BUFFER_RESET,this.onBufferReset,this),t.on(S.BUFFER_APPENDING,this.onBufferAppending,this),t.on(S.BUFFER_CODECS,this.onBufferCodecs,this),t.on(S.BUFFER_EOS,this.onBufferEos,this),t.on(S.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(S.LEVEL_UPDATED,this.onLevelUpdated,this),t.on(S.FRAG_PARSED,this.onFragParsed,this),t.on(S.FRAG_CHANGED,this.onFragChanged,this)},e.unregisterListeners=function(){var t=this.hls;t.off(S.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(S.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(S.MANIFEST_LOADING,this.onManifestLoading,this),t.off(S.MANIFEST_PARSED,this.onManifestParsed,this),t.off(S.BUFFER_RESET,this.onBufferReset,this),t.off(S.BUFFER_APPENDING,this.onBufferAppending,this),t.off(S.BUFFER_CODECS,this.onBufferCodecs,this),t.off(S.BUFFER_EOS,this.onBufferEos,this),t.off(S.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(S.LEVEL_UPDATED,this.onLevelUpdated,this),t.off(S.FRAG_PARSED,this.onFragParsed,this),t.off(S.FRAG_CHANGED,this.onFragChanged,this)},e._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new Aa(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.lastMpegAudioChunk=null},e.onManifestLoading=function(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null},e.onManifestParsed=function(t,e){var r=2;e.audio&&!e.video||e.altAudio,r=1,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r,w.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},e.onMediaAttaching=function(t,e){var r=this.media=e.media;if(r&&Ra){var i=this.mediaSource=new Ra;i.addEventListener("sourceopen",this._onMediaSourceOpen),i.addEventListener("sourceended",this._onMediaSourceEnded),i.addEventListener("sourceclose",this._onMediaSourceClose),r.src=self.URL.createObjectURL(i),this._objectUrl=r.src,r.addEventListener("emptied",this._onMediaEmptied)}},e.onMediaDetaching=function(){var t=this.media,e=this.mediaSource,r=this._objectUrl;if(e){if(w.log("[buffer-controller]: media source detaching"),"open"===e.readyState)try{e.endOfStream()}catch(t){w.warn("[buffer-controller]: onMediaDetaching: "+t.message+" while calling endOfStream")}this.onBufferReset(),e.removeEventListener("sourceopen",this._onMediaSourceOpen),e.removeEventListener("sourceended",this._onMediaSourceEnded),e.removeEventListener("sourceclose",this._onMediaSourceClose),t&&(t.removeEventListener("emptied",this._onMediaEmptied),r&&self.URL.revokeObjectURL(r),t.src===r?(t.removeAttribute("src"),t.load()):w.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(S.MEDIA_DETACHED,void 0)},e.onBufferReset=function(){var t=this;this.getSourceBufferTypes().forEach((function(e){var r=t.sourceBuffer[e];try{r&&(t.removeBufferListeners(e),t.mediaSource&&t.mediaSource.removeSourceBuffer(r),t.sourceBuffer[e]=void 0)}catch(t){w.warn("[buffer-controller]: Failed to reset the "+e+" buffer",t)}})),this._initSourceBuffer()},e.onBufferCodecs=function(t,e){var r=this,i=this.getSourceBufferTypes().length;Object.keys(e).forEach((function(t){if(i){var a=r.tracks[t];if(a&&"function"==typeof a.buffer.changeType){var n=e[t],s=n.id,o=n.codec,l=n.levelCodec,u=n.container,d=n.metadata,h=(a.levelCodec||a.codec).replace(ba,"$1"),f=(l||o).replace(ba,"$1");if(h!==f){var c=u+";codecs="+(l||o);r.appendChangeType(t,c),w.log("[buffer-controller]: switching codec "+h+" to "+f),r.tracks[t]={buffer:a.buffer,codec:o,container:u,levelCodec:l,metadata:d,id:s}}}}else r.pendingTracks[t]=e[t]})),i||(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks())},e.appendChangeType=function(t,e){var r=this,i=this.operationQueue,a={execute:function(){var a=r.sourceBuffer[t];a&&(w.log("[buffer-controller]: changing "+t+" sourceBuffer type to "+e),a.changeType(e)),i.shiftAndExecuteNext(t)},onStart:function(){},onComplete:function(){},onError:function(e){w.warn("[buffer-controller]: Failed to change "+t+" SourceBuffer type",e)}};i.append(a,t)},e.onBufferAppending=function(t,e){var r=this,i=this.hls,a=this.operationQueue,n=this.tracks,s=e.data,o=e.type,l=e.frag,u=e.part,d=e.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 t=r.sourceBuffer[o];if(t){var e=p-t.timestampOffset;Math.abs(e)>=.1&&(w.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+p+" (delta: "+e+") sn: "+l.sn+")"),t.timestampOffset=p)}}r.appendExecutor(s,o)},onStart:function(){},onComplete:function(){var t=self.performance.now();h.executeEnd=h.end=t,0===c.first&&(c.first=t),v&&0===v.first&&(v.first=t);var e=r.sourceBuffer,i={};for(var a in e)i[a]=pr.getBuffered(e[a]);r.appendError=0,r.hls.trigger(S.BUFFER_APPENDED,{type:o,frag:l,part:u,chunkMeta:d,parent:l.type,timeRanges:i})},onError:function(t){w.error("[buffer-controller]: Error encountered while trying to append to the "+o+" SourceBuffer",t);var e={type:A.MEDIA_ERROR,parent:l.type,details:R.BUFFER_APPEND_ERROR,frag:l,part:u,chunkMeta:d,error:t,err:t,fatal:!1};t.code===DOMException.QUOTA_EXCEEDED_ERR?e.details=R.BUFFER_FULL_ERROR:(r.appendError++,e.details=R.BUFFER_APPEND_ERROR,r.appendError>i.config.appendErrorMaxRetry&&(w.error("[buffer-controller]: Failed "+i.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),e.fatal=!0)),i.trigger(S.ERROR,e)}};a.append(y,o)},e.onBufferFlushing=function(t,e){var r=this,i=this.operationQueue,a=function(t){return{execute:r.removeExecutor.bind(r,t,e.startOffset,e.endOffset),onStart:function(){},onComplete:function(){r.hls.trigger(S.BUFFER_FLUSHED,{type:t})},onError:function(e){w.warn("[buffer-controller]: Failed to remove from "+t+" SourceBuffer",e)}}};e.type?i.append(a(e.type),e.type):this.getSourceBufferTypes().forEach((function(t){i.append(a(t),t)}))},e.onFragParsed=function(t,e){var r=this,i=e.frag,a=e.part,n=[],s=a?a.elementaryStreams:i.elementaryStreams;s[U.AUDIOVIDEO]?n.push("audiovideo"):(s[U.AUDIO]&&n.push("audio"),s[U.VIDEO]&&n.push("video"));var o=function(){var t=self.performance.now();i.stats.buffering.end=t,a&&(a.stats.buffering.end=t);var e=a?a.stats:i.stats;r.hls.trigger(S.FRAG_BUFFERED,{frag:i,part:a,stats:e,id:i.type})};0===n.length&&w.warn("Fragments must have at least one ElementaryStreamType set. type: "+i.type+" level: "+i.level+" sn: "+i.sn),this.blockBuffers(o,n)},e.onFragChanged=function(t,e){this.flushBackBuffer()},e.onBufferEos=function(t,e){var r=this;this.getSourceBufferTypes().reduce((function(t,i){var a=r.sourceBuffer[i];return!a||e.type&&e.type!==i||(a.ending=!0,a.ended||(a.ended=!0,w.log("[buffer-controller]: "+i+" sourceBuffer now EOS"))),t&&!(a&&!a.ended)}),!0)&&(w.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers((function(){r.getSourceBufferTypes().forEach((function(t){var e=r.sourceBuffer[t];e&&(e.ending=!1)}));var t=r.mediaSource;t&&"open"===t.readyState?(w.log("[buffer-controller]: Calling mediaSource.endOfStream()"),t.endOfStream()):t&&w.info("[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: "+t.readyState)})))},e.onLevelUpdated=function(t,e){var r=e.details;r.fragments.length&&(this.details=r,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},e.flushBackBuffer=function(){var t=this.hls,e=this.details,r=this.media,i=this.sourceBuffer;if(r&&null!==e){var a=this.getSourceBufferTypes();if(a.length){var n=e.live&&null!==t.config.liveBackBufferLength?t.config.liveBackBufferLength:t.config.backBufferLength;if(L(n)&&!(n<0)){var s=r.currentTime,o=e.levelTargetDuration,l=Math.max(n,o),u=Math.floor(s/o)*o-l;a.forEach((function(r){var a=i[r];if(a){var n=pr.getBuffered(a);if(n.length>0&&u>n.start(0)){if(t.trigger(S.BACK_BUFFER_REACHED,{bufferEnd:u}),e.live)t.trigger(S.LIVE_BACK_BUFFER_REACHED,{bufferEnd:u});else if(a.ended&&n.end(n.length-1)-s<2*o)return void w.info("[buffer-controller]: Cannot flush "+r+" back buffer while SourceBuffer is in ended state");t.trigger(S.BUFFER_FLUSHING,{startOffset:0,endOffset:u,type:r})}}}))}}}},e.updateMediaElementDuration=function(){if(this.details&&this.media&&this.mediaSource&&"open"===this.mediaSource.readyState){var t=this.details,e=this.hls,r=this.media,i=this.mediaSource,a=t.fragments[0].start+t.totalduration,n=r.duration,s=L(i.duration)?i.duration:0;t.live&&e.config.liveDurationInfinity?(w.log("[buffer-controller]: Media Source duration is set to Infinity"),i.duration=1/0,this.updateSeekableRange(t)):(a>s&&a>n||!L(n))&&(w.log("[buffer-controller]: Updating Media Source duration to "+a.toFixed(3)),i.duration=a)}},e.updateSeekableRange=function(t){var e=this.mediaSource,r=t.fragments;if(r.length&&t.live&&null!=e&&e.setLiveSeekableRange){var i=Math.max(0,r[0].start),a=Math.max(i,i+t.totalduration);e.setLiveSeekableRange(i,a)}},e.checkPendingTracks=function(){var t=this.bufferCodecEventsExpected,e=this.operationQueue,r=this.pendingTracks,i=Object.keys(r).length;if(i&&!t||2===i){this.createSourceBuffers(r),this.pendingTracks={};var a=this.getSourceBufferTypes();if(a.length)this.hls.trigger(S.BUFFER_CREATED,{tracks:this.tracks}),a.forEach((function(t){e.executeNext(t)}));else{var n=new Error("could not create source buffer for media codec(s)");this.hls.trigger(S.ERROR,{type:A.MEDIA_ERROR,details:R.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:n,reason:n.message})}}},e.createSourceBuffers=function(t){var e=this.sourceBuffer,r=this.mediaSource;if(!r)throw Error("createSourceBuffers called when mediaSource was null");for(var i in t)if(!e[i]){var a=t[i];if(!a)throw Error("source buffer exists for track "+i+", however track does not");var n=a.levelCodec||a.codec,s=a.container+";codecs="+n;w.log("[buffer-controller]: creating sourceBuffer("+s+")");try{var o=e[i]=r.addSourceBuffer(s),l=i;this.addBufferListener(l,"updatestart",this._onSBUpdateStart),this.addBufferListener(l,"updateend",this._onSBUpdateEnd),this.addBufferListener(l,"error",this._onSBUpdateError),this.tracks[i]={buffer:o,codec:n,container:a.container,levelCodec:a.levelCodec,metadata:a.metadata,id:a.id}}catch(t){w.error("[buffer-controller]: error while trying to add sourceBuffer: "+t.message),this.hls.trigger(S.ERROR,{type:A.MEDIA_ERROR,details:R.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:t,mimeType:s})}}},e._onSBUpdateStart=function(t){this.operationQueue.current(t).onStart()},e._onSBUpdateEnd=function(t){var e=this.operationQueue;e.current(t).onComplete(),e.shiftAndExecuteNext(t)},e._onSBUpdateError=function(t,e){var r=new Error(t+" SourceBuffer error");w.error("[buffer-controller]: "+r,e),this.hls.trigger(S.ERROR,{type:A.MEDIA_ERROR,details:R.BUFFER_APPENDING_ERROR,error:r,fatal:!1});var i=this.operationQueue.current(t);i&&i.onError(e)},e.removeExecutor=function(t,e,r){var i=this.media,a=this.mediaSource,n=this.operationQueue,s=this.sourceBuffer[t];if(!i||!a||!s)return w.warn("[buffer-controller]: Attempting to remove from the "+t+" SourceBuffer, but it does not exist"),void n.shiftAndExecuteNext(t);var o=L(i.duration)?i.duration:1/0,l=L(a.duration)?a.duration:1/0,u=Math.max(0,e),d=Math.min(r,o,l);d>u&&!s.ending?(s.ended=!1,w.log("[buffer-controller]: Removing ["+u+","+d+"] from the "+t+" SourceBuffer"),s.remove(u,d)):n.shiftAndExecuteNext(t)},e.appendExecutor=function(t,e){var r=this.operationQueue,i=this.sourceBuffer[e];if(!i)return w.warn("[buffer-controller]: Attempting to append to the "+e+" SourceBuffer, but it does not exist"),void r.shiftAndExecuteNext(e);i.ended=!1,i.appendBuffer(t)},e.blockBuffers=function(t,e){var r=this;if(void 0===e&&(e=this.getSourceBufferTypes()),!e.length)return w.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),void Promise.resolve().then(t);var i=this.operationQueue,a=e.map((function(t){return i.appendBlocker(t)}));Promise.all(a).then((function(){t(),e.forEach((function(t){var e=r.sourceBuffer[t];null!=e&&e.updating||i.shiftAndExecuteNext(t)}))}))},e.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},e.addBufferListener=function(t,e,r){var i=this.sourceBuffer[t];if(i){var a=r.bind(this,t);this.listeners[t].push({event:e,listener:a}),i.addEventListener(e,a)}},e.removeBufferListeners=function(t){var e=this.sourceBuffer[t];e&&this.listeners[t].forEach((function(t){e.removeEventListener(t.event,t.listener)}))},t}(),ka=function(){function t(t){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=t,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var e=t.prototype;return e.setStreamController=function(t){this.streamController=t},e.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},e.registerListeners=function(){var t=this.hls;t.on(S.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.on(S.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(S.MANIFEST_PARSED,this.onManifestParsed,this),t.on(S.BUFFER_CODECS,this.onBufferCodecs,this),t.on(S.MEDIA_DETACHING,this.onMediaDetaching,this)},e.unregisterListener=function(){var t=this.hls;t.off(S.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.off(S.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(S.MANIFEST_PARSED,this.onManifestParsed,this),t.off(S.BUFFER_CODECS,this.onBufferCodecs,this),t.off(S.MEDIA_DETACHING,this.onMediaDetaching,this)},e.onFpsDropLevelCapping=function(t,e){var r=this.hls.levels[e.droppedLevel];this.isLevelAllowed(r)&&this.restrictedLevels.push({bitrate:r.bitrate,height:r.height,width:r.width})},e.onMediaAttaching=function(t,e){this.media=e.media instanceof HTMLVideoElement?e.media:null,this.clientRect=null},e.onManifestParsed=function(t,e){var r=this.hls;this.restrictedLevels=[],this.firstLevel=e.firstLevel,r.config.capLevelToPlayerSize&&e.video&&this.startCapping()},e.onBufferCodecs=function(t,e){this.hls.config.capLevelToPlayerSize&&e.video&&this.startCapping()},e.onMediaDetaching=function(){this.stopCapping()},e.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var t=this.hls.levels;if(t.length){var e=this.hls;e.autoLevelCapping=this.getMaxLevel(t.length-1),e.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=e.autoLevelCapping}}},e.getMaxLevel=function(e){var r=this,i=this.hls.levels;if(!i.length)return-1;var a=i.filter((function(t,i){return r.isLevelAllowed(t)&&i<=e}));return this.clientRect=null,t.getMaxLevelByMediaSize(a,this.mediaWidth,this.mediaHeight)},e.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},e.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},e.getDimensions=function(){if(this.clientRect)return this.clientRect;var t=this.media,e={width:0,height:0};if(t){var r=t.getBoundingClientRect();e.width=r.width,e.height=r.height,e.width||e.height||(e.width=r.right-r.left||t.width||0,e.height=r.bottom-r.top||t.height||0)}return this.clientRect=e,e},e.isLevelAllowed=function(t){return!this.restrictedLevels.some((function(e){return t.bitrate===e.bitrate&&t.width===e.width&&t.height===e.height}))},t.getMaxLevelByMediaSize=function(t,e,r){if(null==t||!t.length)return-1;for(var i=function(t,e){return!e||t.width!==e.width||t.height!==e.height},a=t.length-1,n=0;n<t.length;n+=1){var s=t[n];if((s.width>=e||s.height>=r)&&i(s,t[n+1])){a=n;break}}return a},n(t,[{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 t=1;if(!this.hls.config.ignoreDevicePixelRatio)try{t=self.devicePixelRatio}catch(t){}return t}}]),t}(),Ia=function(){function t(t){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=t,this.registerListeners()}var e=t.prototype;return e.setStreamController=function(t){this.streamController=t},e.registerListeners=function(){this.hls.on(S.MEDIA_ATTACHING,this.onMediaAttaching,this)},e.unregisterListeners=function(){this.hls.off(S.MEDIA_ATTACHING,this.onMediaAttaching,this)},e.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},e.onMediaAttaching=function(t,e){var r=this.hls.config;if(r.capLevelOnFPSDrop){var i=e.media instanceof self.HTMLVideoElement?e.media:null;this.media=i,i&&"function"==typeof i.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}},e.checkFPS=function(t,e,r){var i=performance.now();if(e){if(this.lastTime){var a=i-this.lastTime,n=r-this.lastDroppedFrames,s=e-this.lastDecodedFrames,o=1e3*n/a,l=this.hls;if(l.trigger(S.FPS_DROP,{currentDropped:n,currentDecoded:s,totalDroppedFrames:r}),o>0&&n>l.config.fpsDroppedMonitoringThreshold*s){var u=l.currentLevel;w.warn("drop FPS ratio greater than max allowed value for currentLevel: "+u),u>0&&(-1===l.autoLevelCapping||l.autoLevelCapping>=u)&&(u-=1,l.trigger(S.FPS_DROP_LEVEL_CAPPING,{level:u,droppedLevel:l.currentLevel}),l.autoLevelCapping=u,this.streamController.nextLevelSwitch())}}this.lastTime=i,this.lastDroppedFrames=r,this.lastDecodedFrames=e}},e.checkFPSInterval=function(){var t=this.media;if(t)if(this.isVideoPlaybackQualityAvailable){var e=t.getVideoPlaybackQuality();this.checkFPS(t,e.totalVideoFrames,e.droppedVideoFrames)}else this.checkFPS(t,t.webkitDecodedFrameCount,t.webkitDroppedFrameCount)},t}(),_a=/^age:\s*[\d.]+\s*$/im,xa=function(){function t(t){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=t&&t.xhrSetup||null,this.stats=new B,this.retryDelay=0}var e=t.prototype;return e.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},e.abortInternal=function(){var t=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),t&&(t.onreadystatechange=null,t.onprogress=null,4!==t.readyState&&(this.stats.aborted=!0,t.abort()))},e.abort=function(){var t;this.abortInternal(),null!=(t=this.callbacks)&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},e.load=function(t,e,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=t,this.config=e,this.callbacks=r,this.loadInternal()},e.loadInternal=function(){var t=this,e=this.config,r=this.context;if(e){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(!t.stats.aborted)return n(i,r.url)})).catch((function(t){return i.open("GET",r.url,!0),n(i,r.url)})).then((function(){t.stats.aborted||t.openAndSendXhr(i,r,e)})).catch((function(e){t.callbacks.onError({code:i.status,text:e.message},r,i,a)})):this.openAndSendXhr(i,r,e)}},e.openAndSendXhr=function(t,e,r){t.readyState||t.open("GET",e.url,!0);var i=this.context.headers,a=r.loadPolicy,n=a.maxTimeToFirstByteMs,s=a.maxLoadTimeMs;if(i)for(var o in i)t.setRequestHeader(o,i[o]);e.rangeEnd&&t.setRequestHeader("Range","bytes="+e.rangeStart+"-"+(e.rangeEnd-1)),t.onreadystatechange=this.readystatechange.bind(this),t.onprogress=this.loadprogress.bind(this),t.responseType=e.responseType,self.clearTimeout(this.requestTimeout),r.timeout=n&&L(n)?n:s,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.timeout),t.send()},e.readystatechange=function(){var t=this.context,e=this.loader,r=this.stats;if(t&&e){var i=e.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),e.onreadystatechange=null,e.onprogress=null;var n=e.status,s="text"!==e.responseType;if(n>=200&&n<300&&(s&&e.response||null!==e.responseText)){r.loading.end=Math.max(self.performance.now(),r.loading.first);var o=s?e.response:e.responseText,l="arraybuffer"===e.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,t,o,e),!this.callbacks)return;var d={url:e.responseURL,data:o,code:n};this.callbacks.onSuccess(d,r,t,e)}else{var h=a.loadPolicy.errorRetry;Ve(h,r.retry,!1,n)?this.retry(h):(w.error(n+" while loading "+t.url),this.callbacks.onError({code:n,text:e.statusText},t,e,r))}}}},e.loadtimeout=function(){var t,e=null==(t=this.config)?void 0:t.loadPolicy.timeoutRetry;if(Ve(e,this.stats.retry,!0))this.retry(e);else{w.warn("timeout while loading "+this.context.url);var r=this.callbacks;r&&(this.abortInternal(),r.onTimeout(this.stats,this.context,this.loader))}},e.retry=function(t){var e=this.context,r=this.stats;this.retryDelay=Ge(t,r.retry),r.retry++,w.warn((status?"HTTP Status "+status:"Timeout")+" while loading "+e.url+", retrying "+r.retry+"/"+t.maxNumRetry+" in "+this.retryDelay+"ms"),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)},e.loadprogress=function(t){var e=this.stats;e.loaded=t.loaded,t.lengthComputable&&(e.total=t.total)},e.getCacheAge=function(){var t=null;if(this.loader&&_a.test(this.loader.getAllResponseHeaders())){var e=this.loader.getResponseHeader("age");t=e?parseFloat(e):null}return t},e.getResponseHeader=function(t){return this.loader&&new RegExp("^"+t+":\\s*[\\d.]+\\s*$","im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(t):null},t}(),wa=function(){function t(){this.chunks=[],this.dataLength=0}var e=t.prototype;return e.push=function(t){this.chunks.push(t),this.dataLength+=t.length},e.flush=function(){var t,e=this.chunks,r=this.dataLength;return e.length?(t=1===e.length?e[0]:Ca(e,r),this.reset(),t):new Uint8Array(0)},e.reset=function(){this.chunks.length=0,this.dataLength=0},t}();function Ca(t,e){for(var r=new Uint8Array(e),i=0,a=0;a<t.length;a++){var n=t[a];r.set(n,i),i+=n.length}return r}function Pa(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(t){}return!1}var Oa=/(\d+)-(\d+)\/(\d+)/,Fa=function(){function t(t){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=t.fetchSetup||Ua,this.controller=new self.AbortController,this.stats=new B}var e=t.prototype;return e.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},e.abortInternal=function(){var t=this.response;null!=t&&t.ok||(this.stats.aborted=!0,this.controller.abort())},e.abort=function(){var t;this.abortInternal(),null!=(t=this.callbacks)&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},e.load=function(t,e,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=Ma(t,this.controller.signal),s=r.onProgress,o="arraybuffer"===t.responseType,l=o?"byteLength":"length",u=e.loadPolicy,d=u.maxTimeToFirstByteMs,h=u.maxLoadTimeMs;this.context=t,this.config=e,this.callbacks=r,this.request=this.fetchSetup(t,n),self.clearTimeout(this.requestTimeout),e.timeout=d&&L(d)?d:h,this.requestTimeout=self.setTimeout((function(){i.abortInternal(),r.onTimeout(a,t,i.response)}),e.timeout),self.fetch(this.request).then((function(n){i.response=i.loader=n;var l=Math.max(self.performance.now(),a.loading.start);if(self.clearTimeout(i.requestTimeout),e.timeout=h,i.requestTimeout=self.setTimeout((function(){i.abortInternal(),r.onTimeout(a,t,i.response)}),h-(l-a.loading.start)),!n.ok){var u=n.status,d=n.statusText;throw new Ga(d||"fetch, bad network response",u,n)}return a.loading.first=l,a.total=Ba(n.headers)||a.total,s&&L(e.highWaterMark)?i.loadProgressively(n,a,t,e.highWaterMark,s):o?n.arrayBuffer():"json"===t.responseType?n.json():n.text()})).then((function(n){var o=i.response;self.clearTimeout(i.requestTimeout),a.loading.end=Math.max(self.performance.now(),a.loading.first);var u=n[l];u&&(a.loaded=a.total=u);var d={url:o.url,data:n,code:o.status};s&&!L(e.highWaterMark)&&s(a,t,n,o),r.onSuccess(d,a,t,o)})).catch((function(e){if(self.clearTimeout(i.requestTimeout),!a.aborted){var n=e&&e.code||0,s=e?e.message:null;r.onError({code:n,text:s},t,e?e.details:null,a)}}))},e.getCacheAge=function(){var t=null;if(this.response){var e=this.response.headers.get("age");t=e?parseFloat(e):null}return t},e.getResponseHeader=function(t){return this.response?this.response.headers.get(t):null},e.loadProgressively=function(t,e,r,i,a){void 0===i&&(i=0);var n=new wa,s=t.body.getReader();return function o(){return s.read().then((function(s){if(s.done)return n.dataLength&&a(e,r,n.flush(),t),Promise.resolve(new ArrayBuffer(0));var l=s.value,u=l.length;return e.loaded+=u,u<i||n.dataLength?(n.push(l),n.dataLength>=i&&a(e,r,n.flush(),t)):a(e,r,l,t),o()})).catch((function(){return Promise.reject()}))}()},t}();function Ma(t,e){var r={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(o({},t.headers))};return t.rangeEnd&&r.headers.set("Range","bytes="+t.rangeStart+"-"+String(t.rangeEnd-1)),r}function Na(t){var e=Oa.exec(t);if(e)return parseInt(e[2])-parseInt(e[1])+1}function Ba(t){var e=t.get("Content-Range");if(e){var r=Na(e);if(L(r))return r}var i=t.get("Content-Length");if(i)return parseInt(i)}function Ua(t,e){return new self.Request(t.url,e)}var Ga=function(t){function e(e,r,i){var a;return(a=t.call(this,e)||this).code=void 0,a.details=void 0,a.code=r,a.details=i,a}return l(e,t),e}(v(Error)),Ka={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},Va=i(i({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,maxBufferSize:6e7,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:xa,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:Sa,bufferController:Da,capLevelController:ka,errorController:Je,fpsController:Ia,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:null,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,certLoadPolicy:{default:Ka},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:Ka},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},Ha()),{},{subtitleStreamController:void 0,subtitleTrackController:void 0,timelineController:void 0,audioStreamController:void 0,audioTrackController:void 0,emeController:void 0,cmcdController:void 0,contentSteeringController:void 0});function Ha(){return{cueHandler:Y,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 Wa(t,e){if((e.liveSyncDurationCount||e.liveMaxLatencyDurationCount)&&(e.liveSyncDuration||e.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==e.liveMaxLatencyDurationCount&&(void 0===e.liveSyncDurationCount||e.liveMaxLatencyDurationCount<=e.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==e.liveMaxLatencyDuration&&(void 0===e.liveSyncDuration||e.liveMaxLatencyDuration<=e.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');var r=Ya(t),a=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach((function(t){var i=("level"===t?"playlist":t)+"LoadPolicy",n=void 0===e[i],s=[];a.forEach((function(a){var o=t+"Loading"+a,l=e[o];if(void 0!==l&&n){s.push(o);var u=r[i].default;switch(e[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&&w.warn('hls.js config: "'+s.join('", "')+'" setting(s) are deprecated, use "'+i+'": '+JSON.stringify(e[i]))})),i(i({},r),e)}function Ya(t){return t&&"object"==typeof t?Array.isArray(t)?t.map(Ya):Object.keys(t).reduce((function(e,r){return e[r]=Ya(t[r]),e}),{}):t}function ja(t){var e=t.loader;e!==Fa&&e!==xa?(w.log("[config]: Custom loader detected, cannot enable progressive streaming"),t.progressive=!1):Pa()&&(t.loader=Fa,t.progressive=!0,t.enableSoftwareAES=!0,w.log("[config]: Progressive streaming enabled, using FetchLoader"))}var qa=function(){function t(e){void 0===e&&(e={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new ra,this._autoLevelCapping=void 0,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null,x(e.debug||!1,"Hls instance");var r=this.config=Wa(t.DefaultConfig,e);this.userConfig=e,this._autoLevelCapping=-1,r.progressive&&ja(r);var i=r.abrController,a=r.bufferController,n=r.capLevelController,s=r.errorController,o=r.fpsController,l=new s(this),u=this.abrController=new i(this),d=this.bufferController=new a(this),h=this.capLevelController=new n(this),f=new o(this),c=new oe(this),v=new Ee(this),g=r.contentSteeringController,m=g?new g(this):null,p=this.levelController=new rr(this,m),y=new sr(this),E=new vr(this.config),T=this.streamController=new Ea(this,y,E);h.setStreamController(T),f.setStreamController(T);var L=[c,p,T];m&&L.splice(1,0,m),this.networkControllers=L;var A=[u,d,h,f,v,y];this.audioTrackController=this.createController(r.audioTrackController,L);var R=r.audioStreamController;R&&L.push(new R(this,y,E)),this.subtitleTrackController=this.createController(r.subtitleTrackController,L);var b=r.subtitleStreamController;b&&L.push(new b(this,y,E)),this.createController(r.timelineController,A),E.emeController=this.emeController=this.createController(r.emeController,A),this.cmcdController=this.createController(r.cmcdController,A),this.latencyController=this.createController(Te,A),this.coreComponents=A,L.push(l);var D=l.onErrorOut;"function"==typeof D&&this.on(S.ERROR,D,l)}t.isSupported=function(){return Br()};var e=t.prototype;return e.createController=function(t,e){if(t){var r=new t(this);return e&&e.push(r),r}return null},e.on=function(t,e,r){void 0===r&&(r=this),this._emitter.on(t,e,r)},e.once=function(t,e,r){void 0===r&&(r=this),this._emitter.once(t,e,r)},e.removeAllListeners=function(t){this._emitter.removeAllListeners(t)},e.off=function(t,e,r,i){void 0===r&&(r=this),this._emitter.off(t,e,r,i)},e.listeners=function(t){return this._emitter.listeners(t)},e.emit=function(t,e,r){return this._emitter.emit(t,e,r)},e.trigger=function(t,e){if(this.config.debug)return this.emit(t,t,e);try{return this.emit(t,t,e)}catch(e){w.error("An internal error happened while handling event "+t+'. Error message: "'+e.message+'". Here is a stacktrace:',e),this.trigger(S.ERROR,{type:A.OTHER_ERROR,details:R.INTERNAL_EXCEPTION,fatal:!1,event:t,error:e})}return!1},e.listenerCount=function(t){return this._emitter.listenerCount(t)},e.destroy=function(){w.log("destroy"),this.trigger(S.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach((function(t){return t.destroy()})),this.networkControllers.length=0,this.coreComponents.forEach((function(t){return t.destroy()})),this.coreComponents.length=0;var t=this.config;t.xhrSetup=t.fetchSetup=void 0,this.userConfig=null},e.attachMedia=function(t){w.log("attachMedia"),this._media=t,this.trigger(S.MEDIA_ATTACHING,{media:t})},e.detachMedia=function(){w.log("detachMedia"),this.trigger(S.MEDIA_DETACHING,void 0),this._media=null},e.loadSource=function(t){this.stopLoad();var e=this.media,r=this.url,i=this.url=T.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});w.log("loadSource:"+i),e&&r&&(r!==i||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(e)),this.trigger(S.MANIFEST_LOADING,{url:t})},e.startLoad=function(t){void 0===t&&(t=-1),w.log("startLoad("+t+")"),this.networkControllers.forEach((function(e){e.startLoad(t)}))},e.stopLoad=function(){w.log("stopLoad"),this.networkControllers.forEach((function(t){t.stopLoad()}))},e.swapAudioCodec=function(){w.log("swapAudioCodec"),this.streamController.swapAudioCodec()},e.recoverMediaError=function(){w.log("recoverMediaError");var t=this._media;this.detachMedia(),t&&this.attachMedia(t)},e.removeLevel=function(t,e){void 0===e&&(e=0),this.levelController.removeLevel(t,e)},n(t,[{key:"levels",get:function(){var t=this.levelController.levels;return t||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(t){w.log("set currentLevel:"+t),this.loadLevel=t,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(t){w.log("set nextLevel:"+t),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(t){w.log("set loadLevel:"+t),this.levelController.manualLevel=t}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(t){this.levelController.nextLoadLevel=t}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(t){w.log("set firstLevel:"+t),this.levelController.firstLevel=t}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(t){w.log("set startLevel:"+t),-1!==t&&(t=Math.max(t,this.minAutoLevel)),this.levelController.startLevel=t}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(t){var e=!!t;e!==this.config.capLevelToPlayerSize&&(e?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=e)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(t){this._autoLevelCapping!==t&&(w.log("set autoLevelCapping:"+t),this._autoLevelCapping=t)}},{key:"bandwidthEstimate",get:function(){var t=this.abrController.bwEstimator;return t?t.getEstimate():NaN}},{key:"ttfbEstimate",get:function(){var t=this.abrController.bwEstimator;return t?t.getEstimateTTFB():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(t){Le.indexOf(t)>-1&&(this._maxHdcpLevel=t)}},{key:"autoLevelEnabled",get:function(){return-1===this.levelController.manualLevel}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var t=this.levels,e=this.config.minAutoBitrate;if(!t)return 0;for(var r=t.length,i=0;i<r;i++)if(t[i].maxBitrate>=e)return i;return 0}},{key:"maxAutoLevel",get:function(){var t,e=this.levels,r=this.autoLevelCapping,i=this.maxHdcpLevel;if(t=-1===r&&e&&e.length?e.length-1:r,i)for(var a=t;a--;){var n=e[a].attrs["HDCP-LEVEL"];if(n&&n<=i)return a}return t}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(t){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,t)}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"audioTracks",get:function(){var t=this.audioTrackController;return t?t.audioTracks:[]}},{key:"audioTrack",get:function(){var t=this.audioTrackController;return t?t.audioTrack:-1},set:function(t){var e=this.audioTrackController;e&&(e.audioTrack=t)}},{key:"subtitleTracks",get:function(){var t=this.subtitleTrackController;return t?t.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var t=this.subtitleTrackController;return t?t.subtitleTrack:-1},set:function(t){var e=this.subtitleTrackController;e&&(e.subtitleTrack=t)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var t=this.subtitleTrackController;return!!t&&t.subtitleDisplay},set:function(t){var e=this.subtitleTrackController;e&&(e.subtitleDisplay=t)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(t){this.config.lowLatencyMode=t}},{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.4.12"}},{key:"Events",get:function(){return S}},{key:"ErrorTypes",get:function(){return A}},{key:"ErrorDetails",get:function(){return R}},{key:"DefaultConfig",get:function(){return t.defaultConfig?t.defaultConfig:Va},set:function(e){t.defaultConfig=e}}]),t}();return qa.defaultConfig=void 0,qa}()}(!1)}}]);
- //# sourceMappingURL=9372.js.map
|