@tianfeng98/hls.js
Version:
HLS.js is a JavaScript library that supports playing MPEG-TS and HEVC encoded HLS streams in browsers with support for MSE.
1 lines • 412 kB
JavaScript
!function e(t){var r,i;r=this,i=function(){"use strict";function r(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}function i(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?r(Object(i),!0).forEach((function(t){var r,n,a;r=e,n=t,a=i[t],(n=g(n))in r?Object.defineProperty(r,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):r[n]=a})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):r(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function n(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,g(i.key),i)}}function a(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function s(){return s=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},s.apply(this,arguments)}function o(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,u(e,t)}function l(e){return l=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},l(e)}function u(e,t){return u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},u(e,t)}function d(e,t,r){return d=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}()?Reflect.construct.bind():function(e,t,r){var i=[null];i.push.apply(i,t);var n=new(Function.bind.apply(e,i));return r&&u(n,r.prototype),n},d.apply(null,arguments)}function h(e){var t="function"==typeof Map?new Map:void 0;return h=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,i)}function i(){return d(e,arguments,l(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),u(i,e)},h(e)}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}function f(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return c(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?c(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function g(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}function v(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var m={exports:{}};!function(e,t){var r,i,n,a,s;r=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,i=/^(?=([^\/?#]*))\1([^]*)$/,n=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,s={buildAbsoluteURL:function(e,t,r){if(r=r||{},e=e.trim(),!(t=t.trim())){if(!r.alwaysNormalize)return e;var n=s.parseURL(e);if(!n)throw new Error("Error trying to parse base URL.");return n.path=s.normalizePath(n.path),s.buildURLFromParts(n)}var a=s.parseURL(t);if(!a)throw new Error("Error trying to parse relative URL.");if(a.scheme)return r.alwaysNormalize?(a.path=s.normalizePath(a.path),s.buildURLFromParts(a)):t;var o=s.parseURL(e);if(!o)throw new Error("Error trying to parse base URL.");if(!o.netLoc&&o.path&&"/"!==o.path[0]){var l=i.exec(o.path);o.netLoc=l[1],o.path=l[2]}o.netLoc&&!o.path&&(o.path="/");var u={scheme:o.scheme,netLoc:a.netLoc,path:null,params:a.params,query:a.query,fragment:a.fragment};if(!a.netLoc&&(u.netLoc=o.netLoc,"/"!==a.path[0]))if(a.path){var d=o.path,h=d.substring(0,d.lastIndexOf("/")+1)+a.path;u.path=s.normalizePath(h)}else u.path=o.path,a.params||(u.params=o.params,a.query||(u.query=o.query));return null===u.path&&(u.path=r.alwaysNormalize?s.normalizePath(a.path):a.path),s.buildURLFromParts(u)},parseURL:function(e){var t=r.exec(e);return t?{scheme:t[1]||"",netLoc:t[2]||"",path:t[3]||"",params:t[4]||"",query:t[5]||"",fragment:t[6]||""}:null},normalizePath:function(e){for(e=e.split("").reverse().join("").replace(n,"");e.length!==(e=e.replace(a,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}},e.exports=s}(m);var p=m.exports,y=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},E=function(e){return e.MEDIA_ATTACHING="hlsMediaAttaching",e.MEDIA_ATTACHED="hlsMediaAttached",e.MEDIA_DETACHING="hlsMediaDetaching",e.MEDIA_DETACHED="hlsMediaDetached",e.BUFFER_RESET="hlsBufferReset",e.BUFFER_CODECS="hlsBufferCodecs",e.BUFFER_CREATED="hlsBufferCreated",e.BUFFER_APPENDING="hlsBufferAppending",e.BUFFER_APPENDED="hlsBufferAppended",e.BUFFER_EOS="hlsBufferEos",e.BUFFER_FLUSHING="hlsBufferFlushing",e.BUFFER_FLUSHED="hlsBufferFlushed",e.MANIFEST_LOADING="hlsManifestLoading",e.MANIFEST_LOADED="hlsManifestLoaded",e.MANIFEST_PARSED="hlsManifestParsed",e.LEVEL_SWITCHING="hlsLevelSwitching",e.LEVEL_SWITCHED="hlsLevelSwitched",e.LEVEL_LOADING="hlsLevelLoading",e.LEVEL_LOADED="hlsLevelLoaded",e.LEVEL_UPDATED="hlsLevelUpdated",e.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",e.LEVELS_UPDATED="hlsLevelsUpdated",e.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",e.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",e.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",e.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",e.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",e.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",e.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",e.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",e.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",e.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",e.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",e.CUES_PARSED="hlsCuesParsed",e.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",e.INIT_PTS_FOUND="hlsInitPtsFound",e.FRAG_LOADING="hlsFragLoading",e.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",e.FRAG_LOADED="hlsFragLoaded",e.FRAG_DECRYPTED="hlsFragDecrypted",e.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",e.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",e.FRAG_PARSING_METADATA="hlsFragParsingMetadata",e.FRAG_PARSED="hlsFragParsed",e.FRAG_BUFFERED="hlsFragBuffered",e.FRAG_CHANGED="hlsFragChanged",e.FPS_DROP="hlsFpsDrop",e.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",e.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",e.ERROR="hlsError",e.DESTROYING="hlsDestroying",e.KEY_LOADING="hlsKeyLoading",e.KEY_LOADED="hlsKeyLoaded",e.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",e.BACK_BUFFER_REACHED="hlsBackBufferReached",e.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",e}({}),T=function(e){return e.NETWORK_ERROR="networkError",e.MEDIA_ERROR="mediaError",e.KEY_SYSTEM_ERROR="keySystemError",e.MUX_ERROR="muxError",e.OTHER_ERROR="otherError",e}({}),S=function(e){return e.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",e.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",e.KEY_SYSTEM_NO_SESSION="keySystemNoSession",e.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",e.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",e.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",e.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",e.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",e.MANIFEST_LOAD_ERROR="manifestLoadError",e.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",e.MANIFEST_PARSING_ERROR="manifestParsingError",e.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",e.LEVEL_EMPTY_ERROR="levelEmptyError",e.LEVEL_LOAD_ERROR="levelLoadError",e.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",e.LEVEL_PARSING_ERROR="levelParsingError",e.LEVEL_SWITCH_ERROR="levelSwitchError",e.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",e.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",e.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",e.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",e.FRAG_LOAD_ERROR="fragLoadError",e.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",e.FRAG_DECRYPT_ERROR="fragDecryptError",e.FRAG_PARSING_ERROR="fragParsingError",e.FRAG_GAP="fragGap",e.REMUX_ALLOC_ERROR="remuxAllocError",e.KEY_LOAD_ERROR="keyLoadError",e.KEY_LOAD_TIMEOUT="keyLoadTimeOut",e.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",e.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",e.BUFFER_APPEND_ERROR="bufferAppendError",e.BUFFER_APPENDING_ERROR="bufferAppendingError",e.BUFFER_STALLED_ERROR="bufferStalledError",e.BUFFER_FULL_ERROR="bufferFullError",e.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",e.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",e.INTERNAL_EXCEPTION="internalException",e.INTERNAL_ABORTED="aborted",e.UNKNOWN="unknown",e}({}),L=function(){},R={trace:L,debug:L,log:L,warn:L,info:L,error:L},A=R;function b(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];r.forEach((function(t){A[t]=e[t]?e[t].bind(e):function(e){var t=self.console[e];return t?t.bind(self.console,"["+e+"] >"):L}(t)}))}function k(e,t){if(self.console&&!0===e||"object"==typeof e){b(e,"debug","log","info","warn","error");try{A.log('Debug logs enabled for "'+t+'" in hls.js version 1.0.1')}catch(e){A=R}}else A=R}var D=A,_=/^(\d+)x(\d+)$/,I=/(.+?)=(".*?"|.*?)(?:,|$)/g,w=function(){function e(t){"string"==typeof t&&(t=e.parseAttrList(t)),s(this,t)}var t=e.prototype;return t.decimalInteger=function(e){var t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t},t.hexadecimalInteger=function(e){if(this[e]){var t=(this[e]||"0x").slice(2);t=(1&t.length?"0":"")+t;for(var r=new Uint8Array(t.length/2),i=0;i<t.length/2;i++)r[i]=parseInt(t.slice(2*i,2*i+2),16);return r}return null},t.hexadecimalIntegerAsNumber=function(e){var t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t},t.decimalFloatingPoint=function(e){return parseFloat(this[e])},t.optionalFloat=function(e,t){var r=this[e];return r?parseFloat(r):t},t.enumeratedString=function(e){return this[e]},t.bool=function(e){return"YES"===this[e]},t.decimalResolution=function(e){var t=_.exec(this[e]);if(null!==t)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}},e.parseAttrList=function(e){var t,r={};for(I.lastIndex=0;null!==(t=I.exec(e));){var i=t[2];0===i.indexOf('"')&&i.lastIndexOf('"')===i.length-1&&(i=i.slice(1,-1)),r[t[1].trim()]=i}return r},a(e,[{key:"clientAttrs",get:function(){return Object.keys(this).filter((function(e){return"X-"===e.substring(0,2)}))}}]),e}();function C(e){return"SCTE35-OUT"===e||"SCTE35-IN"===e}var P=function(){function e(e,t){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,t){var r=t.attr;for(var i in r)if(Object.prototype.hasOwnProperty.call(e,i)&&e[i]!==r[i]){D.warn('DATERANGE tag attribute: "'+i+'" does not match for tags with ID: "'+e.ID+'"'),this._badValueForSameId=i;break}e=s(new w({}),r,e)}if(this.attr=e,this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){var n=new Date(this.attr["END-DATE"]);y(n.getTime())&&(this._endDate=n)}}return a(e,[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){if(this._endDate)return this._endDate;var e=this.duration;return null!==e?new Date(this._startDate.getTime()+1e3*e):null}},{key:"duration",get:function(){if("DURATION"in this.attr){var e=this.attr.decimalFloatingPoint("DURATION");if(y(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}},{key:"endOnNext",get:function(){return this.attr.bool("END-ON-NEXT")}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&y(this.startDate.getTime())&&(null===this.duration||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),e}(),x=function(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}},F="audio",M="video",O="audiovideo",N=function(){function e(e){var t;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=((t={})[F]=null,t[M]=null,t[O]=null,t),this.baseurl=e}return e.prototype.setByteRange=function(e,t){var r,i=e.split("@",2);r=1===i.length?(null==t?void 0:t.byteRangeEndOffset)||0:parseInt(i[1]),this._byteRange=[r,parseInt(i[0])+r]},a(e,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=p.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(e){this._url=e}}]),e}(),U=function(e){function t(t,r){var i;return(i=e.call(this,r)||this)._decryptdata=null,i.rawProgramDateTime=null,i.programDateTime=null,i.tagList=[],i.duration=0,i.sn=0,i.levelkeys=void 0,i.type=void 0,i.loader=null,i.keyLoader=null,i.level=-1,i.cc=0,i.startPTS=void 0,i.endPTS=void 0,i.startDTS=void 0,i.endDTS=void 0,i.start=0,i.deltaPTS=void 0,i.maxStartPTS=void 0,i.minEndPTS=void 0,i.stats=new x,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=t,i}o(t,e);var r=t.prototype;return r.setKeyFormat=function(e){if(this.levelkeys){var t=this.levelkeys[e];t&&!this._decryptdata&&(this._decryptdata=t.getDecryptData(this.sn))}},r.abortRequests=function(){var e,t;null==(e=this.loader)||e.abort(),null==(t=this.keyLoader)||t.abort()},r.setElementaryStreamInfo=function(e,t,r,i,n,a){void 0===a&&(a=!1);var s=this.elementaryStreams,o=s[e];o?(o.startPTS=Math.min(o.startPTS,t),o.endPTS=Math.max(o.endPTS,r),o.startDTS=Math.min(o.startDTS,i),o.endDTS=Math.max(o.endDTS,n)):s[e]={startPTS:t,endPTS:r,startDTS:i,endDTS:n,partial:a}},r.clearElementaryStreamInfo=function(){var e=this.elementaryStreams;e[F]=null,e[M]=null,e[O]=null},a(t,[{key:"decryptdata",get:function(){if(!this.levelkeys&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){var e=this.levelkeys.identity;if(e)this._decryptdata=e.getDecryptData(this.sn);else{var t=Object.keys(this.levelkeys);if(1===t.length)return this._decryptdata=this.levelkeys[t[0]].getDecryptData(this.sn)}}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(null===this.programDateTime)return null;if(!y(this.programDateTime))return null;var e=y(this.duration)?this.duration:0;return this.programDateTime+1e3*e}},{key:"encrypted",get:function(){var e;if(null!=(e=this._decryptdata)&&e.encrypted)return!0;if(this.levelkeys){var t=Object.keys(this.levelkeys),r=t.length;if(r>1||1===r&&this.levelkeys[t[0]].encrypted)return!0}return!1}}]),t}(N),B=function(e){function t(t,r,i,n,a){var s;(s=e.call(this,i)||this).fragOffset=0,s.duration=0,s.gap=!1,s.independent=!1,s.relurl=void 0,s.fragment=void 0,s.index=void 0,s.stats=new x,s.duration=t.decimalFloatingPoint("DURATION"),s.gap=t.bool("GAP"),s.independent=t.bool("INDEPENDENT"),s.relurl=t.enumeratedString("URI"),s.fragment=r,s.index=n;var o=t.enumeratedString("BYTERANGE");return o&&s.setByteRange(o,a),a&&(s.fragOffset=a.fragOffset+a.duration),s}return o(t,e),a(t,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var e=this.elementaryStreams;return!!(e.audio||e.video||e.audiovideo)}}]),t}(N),G=function(){function e(e){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=e}return e.prototype.reloaded=function(e){if(!e)return this.advanced=!0,void(this.updated=!0);var t=this.lastPartSn-e.lastPartSn,r=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!r||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||0===t&&r>0,this.updated||this.advanced?this.misses=Math.floor(.6*e.misses):this.misses=e.misses+1,this.availabilityDelay=e.availabilityDelay},a(e,[{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&y(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||10}},{key:"drift",get:function(){var e=this.driftEndTime-this.driftStartTime;return e>0?1e3*(this.driftEnd-this.driftStart)/e:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var e;return null!=(e=this.fragments)&&e.length?this.fragments[this.fragments.length-1].end:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),e}();function K(e){return Uint8Array.from(atob(e),(function(e){return e.charCodeAt(0)}))}function H(e){var t,r,i=e.split(":"),n=null;if("data"===i[0]&&2===i.length){var a=i[1].split(";"),s=a[a.length-1].split(",");if(2===s.length){var o="base64"===s[0],l=s[1];o?(a.splice(-1,1),n=K(l)):(t=V(l).subarray(0,16),(r=new Uint8Array(16)).set(t,16-t.length),n=r)}}return n}function V(e){return Uint8Array.from(unescape(encodeURIComponent(e)),(function(e){return e.charCodeAt(0)}))}var Y="undefined"!=typeof self?self:void 0,W={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},j="org.w3.clearkey",q="com.apple.streamingkeydelivery",X="com.microsoft.playready",z="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function Q(e){switch(e){case q:return W.FAIRPLAY;case X:return W.PLAYREADY;case z:return W.WIDEVINE;case j:return W.CLEARKEY}}var $="edef8ba979d64acea3c827dcd51d21ed";function J(e){switch(e){case W.FAIRPLAY:return q;case W.PLAYREADY:return X;case W.WIDEVINE:return z;case W.CLEARKEY:return j}}function Z(e){var t=e.drmSystems,r=e.widevineLicenseUrl,i=t?[W.FAIRPLAY,W.WIDEVINE,W.PLAYREADY,W.CLEARKEY].filter((function(e){return!!t[e]})):[];return!i[W.WIDEVINE]&&r&&i.push(W.WIDEVINE),i}var ee,te=null!=Y&&null!=(ee=Y.navigator)&&ee.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;function re(e,t,r){return Uint8Array.prototype.slice?e.slice(t,r):new Uint8Array(Array.prototype.slice.call(e,t,r))}var ie,ne=function(e,t){return t+10<=e.length&&73===e[t]&&68===e[t+1]&&51===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128},ae=function(e,t){return t+10<=e.length&&51===e[t]&&68===e[t+1]&&73===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128},se=function(e,t){for(var r=t,i=0;ne(e,t);)i+=10,i+=oe(e,t+6),ae(e,t+10)&&(i+=10),t+=i;if(i>0)return e.subarray(r,r+i)},oe=function(e,t){var r=0;return r=(127&e[t])<<21,r|=(127&e[t+1])<<14,r|=(127&e[t+2])<<7,r|=127&e[t+3]},le=function(e,t){return ne(e,t)&&oe(e,t+6)+10<=e.length-t},ue=function(e){for(var t=ce(e),r=0;r<t.length;r++){var i=t[r];if(de(i))return pe(i)}},de=function(e){return e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info},he=function(e){var t=String.fromCharCode(e[0],e[1],e[2],e[3]),r=oe(e,4);return{type:t,size:r,data:e.subarray(10,10+r)}},ce=function(e){for(var t=0,r=[];ne(e,t);){for(var i=oe(e,t+6),n=(t+=10)+i;t+8<n;){var a=he(e.subarray(t)),s=fe(a);s&&r.push(s),t+=a.size+10}ae(e,t)&&(t+=10)}return r},fe=function(e){return"PRIV"===e.type?ge(e):"W"===e.type[0]?me(e):ve(e)},ge=function(e){if(!(e.size<2)){var t=ye(e.data,!0),r=new Uint8Array(e.data.subarray(t.length+1));return{key:e.type,info:t,data:r.buffer}}},ve=function(e){if(!(e.size<2)){if("TXXX"===e.type){var t=1,r=ye(e.data.subarray(t),!0);t+=r.length+1;var i=ye(e.data.subarray(t));return{key:e.type,info:r,data:i}}var n=ye(e.data.subarray(1));return{key:e.type,data:n}}},me=function(e){if("WXXX"===e.type){if(e.size<2)return;var t=1,r=ye(e.data.subarray(t),!0);t+=r.length+1;var i=ye(e.data.subarray(t));return{key:e.type,info:r,data:i}}var n=ye(e.data);return{key:e.type,data:n}},pe=function(e){if(8===e.data.byteLength){var t=new Uint8Array(e.data),r=1&t[3],i=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return i/=45,r&&(i+=47721858.84),Math.round(i)}},ye=function(e,t){void 0===t&&(t=!1);var r=Ee();if(r){var i=r.decode(e);if(t){var n=i.indexOf("\0");return-1!==n?i.substring(0,n):i}return i.replace(/\0/g,"")}for(var a,s,o,l=e.length,u="",d=0;d<l;){if(0===(a=e[d++])&&t)return u;if(0!==a&&3!==a)switch(a>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:u+=String.fromCharCode(a);break;case 12:case 13:s=e[d++],u+=String.fromCharCode((31&a)<<6|63&s);break;case 14:s=e[d++],o=e[d++],u+=String.fromCharCode((15&a)<<12|(63&s)<<6|(63&o)<<0)}}return u};function Ee(){return ie||void 0===self.TextDecoder||(ie=new self.TextDecoder("utf-8")),ie}var Te=function(e){for(var t="",r=0;r<e.length;r++){var i=e[r].toString(16);i.length<2&&(i="0"+i),t+=i}return t},Se=Math.pow(2,32)-1,Le=[].push,Re={video:1,audio:2,id3:3,text:4};function Ae(e){return String.fromCharCode.apply(null,e)}function be(e,t){var r=e[t]<<8|e[t+1];return r<0?65536+r:r}function ke(e,t){var r=De(e,t);return r<0?4294967296+r:r}function De(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function _e(e,t,r){e[t]=r>>24,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r}function Ie(e,t){var r=[];if(!t.length)return r;for(var i=e.byteLength,n=0;n<i;){var a=ke(e,n),s=a>1?n+a:i;if(Ae(e.subarray(n+4,n+8))===t[0])if(1===t.length)r.push(e.subarray(n+8,s));else{var o=Ie(e.subarray(n+8,s),t.slice(1));o.length&&Le.apply(r,o)}n=s}return r}function we(e){var t=[],r=e[0],i=8,n=ke(e,i);i+=4,i+=0===r?8:16,i+=2;var a=e.length+0,s=be(e,i);i+=2;for(var o=0;o<s;o++){var l=i,u=ke(e,l);l+=4;var d=2147483647&u;if(1==(2147483648&u)>>>31)return D.warn("SIDX has hierarchical references (not supported)"),null;var h=ke(e,l);l+=4,t.push({referenceSize:d,subsegmentDuration:h,info:{duration:h/n,start:a,end:a+d-1}}),a+=d,i=l+=4}return{earliestPresentationTime:0,timescale:n,version:r,referencesCount:s,references:t}}function Ce(e){for(var t=[],r=Ie(e,["moov","trak"]),n=0;n<r.length;n++){var a=r[n],s=Ie(a,["tkhd"])[0];if(s){var o=s[0],l=ke(s,0===o?12:20),u=Ie(a,["mdia","mdhd"])[0];if(u){var d=ke(u,0===(o=u[0])?12:20),h=Ie(a,["mdia","hdlr"])[0];if(h){var c=Ae(h.subarray(8,12)),f={soun:F,vide:M}[c];if(f){var g=Pe(Ie(a,["mdia","minf","stbl","stsd"])[0]);t[l]={timescale:d,type:f},t[f]=i({timescale:d,id:l},g)}}}}}return Ie(e,["moov","mvex","trex"]).forEach((function(e){var r=ke(e,4),i=t[r];i&&(i.default={duration:ke(e,12),flags:ke(e,20)})})),t}function Pe(e){var t=e.subarray(8),r=t.subarray(86),i=Ae(t.subarray(4,8)),n=i,a="enca"===i||"encv"===i;if(a){var s=Ie(t,[i])[0];Ie(s.subarray("enca"===i?28:78),["sinf"]).forEach((function(e){var t=Ie(e,["schm"])[0];if(t){var r=Ae(t.subarray(4,8));if("cbcs"===r||"cenc"===r){var i=Ie(e,["frma"])[0];i&&(n=Ae(i))}}}))}switch(n){case"avc1":case"avc2":case"avc3":case"avc4":n+="."+xe(e[111])+xe(e[112])+xe(e[113]);break;case"mp4a":var o=Ie(t,[i])[0],l=Ie(o.subarray(28),["esds"])[0];l&&l.length>12&&0!==l[11]&&(n+="."+xe(l[11]),n+="."+(l[12]>>>2&63).toString(16).toUpperCase());break;case"hvc1":case"hev1":var u=Ie(r,["hvcC"])[0],d=u[1],h=["","A","B","C"][d>>6],c=31&d,f=ke(u,2),g=(32&d)>>5?"H":"L",v=u[12],m=u.subarray(6,12);n+="."+h+c,n+="."+f.toString(16).toUpperCase(),n+="."+g+v;for(var p="",y=m.length;y--;){var E=m[y];(E||p)&&(p="."+E.toString(16).toUpperCase()+p)}n+=p;break;case"dvh1":case"dvhe":var T=Ie(r,["dvcC"])[0],S=T[2]>>1&127,L=T[2]<<5&32|T[3]>>3&31;n+="."+Fe(S)+"."+Fe(L);break;case"vp09":var R=Ie(r,["vpcC"])[0],A=R[4],b=R[5],k=R[6]>>4&15;n+="."+Fe(A)+"."+Fe(b)+"."+Fe(k);break;case"av01":var D=Ie(r,["av1C"])[0],_=D[1]>>>5,I=31&D[1],w=D[2]>>>7?"H":"M",C=(64&D[2])>>6,P=(32&D[2])>>5,x=2===_&&C?P?12:10:C?10:8,F=(16&D[2])>>4,M=(8&D[2])>>3,O=(4&D[2])>>2,N=3&D[2];n+="."+_+"."+Fe(I)+w+"."+Fe(x)+"."+F+"."+M+O+N+"."+Fe(1)+"."+Fe(1)+"."+Fe(1)+".0"}return{codec:n,encrypted:a}}function xe(e){return("0"+e.toString(16).toUpperCase()).slice(-2)}function Fe(e){return(e<10?"0":"")+e}function Me(e){var t=Ie(e,["schm"])[0];if(t){var r=Ae(t.subarray(4,8));if("cbcs"===r||"cenc"===r)return Ie(e,["schi","tenc"])[0]}return D.error("[eme] missing 'schm' box"),null}function Oe(e){var t=ke(e,0),r=8;1&t&&(r+=4),4&t&&(r+=4);for(var i=0,n=ke(e,4),a=0;a<n;a++)256&t&&(i+=ke(e,r),r+=4),512&t&&(r+=4),1024&t&&(r+=4),2048&t&&(r+=4);return i}function Ne(e,t){var r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}function Ue(e,t){var r=[],i=t.samples,n=t.timescale,a=t.id,s=!1;return Ie(i,["moof"]).map((function(o){var l=o.byteOffset-8;Ie(o,["traf"]).map((function(o){var u=Ie(o,["tfdt"]).map((function(e){var t=e[0],r=ke(e,4);return 1===t&&(r*=Math.pow(2,32),r+=ke(e,8)),r/n}))[0];return void 0!==u&&(e=u),Ie(o,["tfhd"]).map((function(u){var d=ke(u,4),h=16777215&ke(u,0),c=0,f=0!=(16&h),g=0,v=0!=(32&h),m=8;d===a&&(0!=(1&h)&&(m+=8),0!=(2&h)&&(m+=4),0!=(8&h)&&(c=ke(u,m),m+=4),f&&(g=ke(u,m),m+=4),v&&(m+=4),"video"===t.type&&(s=function(e){if(!e)return!1;var t=e.indexOf("."),r=t<0?e:e.substring(0,t);return"hvc1"===r||"hev1"===r||"dvh1"===r||"dvhe"===r}(t.codec)),Ie(o,["trun"]).map((function(a){var o=a[0],u=16777215&ke(a,0),d=0!=(1&u),h=0,f=0!=(4&u),v=0!=(256&u),m=0,p=0!=(512&u),y=0,E=0!=(1024&u),T=0!=(2048&u),S=0,L=ke(a,4),R=8;d&&(h=ke(a,R),R+=4),f&&(R+=4);for(var A=h+l,b=0;b<L;b++){if(v?(m=ke(a,R),R+=4):m=c,p?(y=ke(a,R),R+=4):y=g,E&&(R+=4),T&&(S=0===o?ke(a,R):De(a,R),R+=4),t.type===M)for(var k=0;k<y;){var D=ke(i,A);Be(s,i[A+=4])&&Ge(i.subarray(A,A+D),s?2:1,e+S/n,r),A+=D,k+=D+4}e+=m/n}})))}))}))})),r}function Be(e,t){if(e){var r=t>>1&63;return 39===r||40===r}return 6==(31&t)}function Ge(e,t,r,i){var n=Ke(e),a=0;a+=t;for(var s=0,o=0,l=!1,u=0;a<n.length;){s=0;do{if(a>=n.length)break;s+=u=n[a++]}while(255===u);o=0;do{if(a>=n.length)break;o+=u=n[a++]}while(255===u);var d=n.length-a;if(!l&&4===s&&a<n.length){if(l=!0,181===n[a++]){var h=be(n,a);if(a+=2,49===h){var c=ke(n,a);if(a+=4,1195456820===c){var f=n[a++];if(3===f){var g=n[a++],v=64&g,m=v?2+3*(31&g):0,p=new Uint8Array(m);if(v){p[0]=g;for(var y=1;y<m;y++)p[y]=n[a++]}i.push({type:f,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 S=n[a++].toString(16);E.push(1==S.length?"0"+S:S),3!==T&&5!==T&&7!==T&&9!==T||E.push("-")}for(var L=o-16,R=new Uint8Array(L),A=0;A<L;A++)R[A]=n[a++];i.push({payloadType:s,pts:r,uuid:E.join(""),userData:ye(R),userDataBytes:R})}}else if(o<d)a+=o;else if(o>d)break}}function Ke(e){for(var t=e.byteLength,r=[],i=1;i<t-2;)0===e[i]&&0===e[i+1]&&3===e[i+2]?(r.push(i+2),i+=2):i++;if(0===r.length)return e;var n=t-r.length,a=new Uint8Array(n),s=0;for(i=0;i<n;s++,i++)s===r[0]&&(s++,r.shift()),a[i]=e[s];return a}function He(e,t,r){if(16!==e.byteLength)throw new RangeError("Invalid system id");var i,n,a;if(t){i=1,n=new Uint8Array(16*t.length);for(var s=0;s<t.length;s++){var o=t[s];if(16!==o.byteLength)throw new RangeError("Invalid key");n.set(o,16*s)}}else i=0,n=new Uint8Array;i>0?(a=new Uint8Array(4),t.length>0&&new DataView(a.buffer).setUint32(0,t.length,!1)):a=new Uint8Array;var l=new Uint8Array(4);return r&&r.byteLength>0&&new DataView(l.buffer).setUint32(0,r.byteLength,!1),function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];for(var n=r.length,a=8,s=n;s--;)a+=r[s].byteLength;var o=new Uint8Array(a);for(o[0]=a>>24&255,o[1]=a>>16&255,o[2]=a>>8&255,o[3]=255&a,o.set(e,4),s=0,a=8;s<n;s++)o.set(r[s],a),a+=r[s].byteLength;return o}([112,115,115,104],new Uint8Array([i,0,0,0]),e,a,n,l,r||new Uint8Array)}var Ve={},Ye=function(){function e(e,t,r,i,n){void 0===i&&(i=[1]),void 0===n&&(n=null),this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=e,this.uri=t,this.keyFormat=r,this.keyFormatVersions=i,this.iv=n,this.encrypted=!!e&&"NONE"!==e,this.isCommonEncryption=this.encrypted&&"AES-128"!==e}e.clearKeyUriToKeyIdMap=function(){Ve={}};var t=e.prototype;return t.isSupported=function(){if(this.method){if("AES-128"===this.method||"NONE"===this.method)return!0;if("identity"===this.keyFormat)return"SAMPLE-AES"===this.method;switch(this.keyFormat){case q:case z:case X:case j:return-1!==["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)}}return!1},t.getDecryptData=function(t){if(!this.encrypted||!this.uri)return null;if("AES-128"===this.method&&this.uri&&!this.iv){"number"!=typeof t&&("AES-128"!==this.method||this.iv||D.warn('missing IV for initialization segment with method="'+this.method+'" - compliance issue'),t=0);var r=function(e){for(var t=new Uint8Array(16),r=12;r<16;r++)t[r]=e>>8*(15-r)&255;return t}(t);return new e(this.method,this.uri,"identity",this.keyFormatVersions,r)}var i=H(this.uri);if(i)switch(this.keyFormat){case z:this.pssh=i,i.length>=22&&(this.keyId=i.subarray(i.length-22,i.length-6));break;case X:var n=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=He(n,null,i);var a=new Uint16Array(i.buffer,i.byteOffset,i.byteLength/2),s=String.fromCharCode.apply(null,Array.from(a)),o=s.substring(s.indexOf("<"),s.length),l=(new DOMParser).parseFromString(o,"text/xml").getElementsByTagName("KID")[0];if(l){var u=l.childNodes[0]?l.childNodes[0].nodeValue:l.getAttribute("VALUE");if(u){var d=K(u).subarray(0,16);!function(e){var t=function(e,t,r){var i=e[t];e[t]=e[r],e[r]=i};t(e,0,3),t(e,1,2),t(e,4,5),t(e,6,7)}(d),this.keyId=d}}break;default:var h=i.subarray(0,16);if(16!==h.length){var c=new Uint8Array(16);c.set(h,16-h.length),h=c}this.keyId=h}if(!this.keyId||16!==this.keyId.byteLength){var f=Ve[this.uri];if(!f){var g=Object.keys(Ve).length%Number.MAX_SAFE_INTEGER;f=new Uint8Array(16),new DataView(f.buffer,12,4).setUint32(0,g),Ve[this.uri]=f}this.keyId=f}return this},e}(),We=/\{\$([a-zA-Z0-9-_]+)\}/g;function je(e){return We.test(e)}function qe(e,t,r){if(null!==e.variableList||e.hasVariableRefs)for(var i=r.length;i--;){var n=r[i],a=t[n];a&&(t[n]=Xe(e,a))}}function Xe(e,t){if(null!==e.variableList||e.hasVariableRefs){var r=e.variableList;return t.replace(We,(function(t){var i=t.substring(2,t.length-1),n=null==r?void 0:r[i];return void 0===n?(e.playlistParsingError||(e.playlistParsingError=new Error('Missing preceding EXT-X-DEFINE tag for Variable Reference: "'+i+'"')),t):n}))}return t}function ze(e,t,r){var i,n,a=e.variableList;if(a||(e.variableList=a={}),"QUERYPARAM"in t){i=t.QUERYPARAM;try{var s=new self.URL(r).searchParams;if(!s.has(i))throw new Error('"'+i+'" does not match any query parameter in URI: "'+r+'"');n=s.get(i)}catch(t){e.playlistParsingError||(e.playlistParsingError=new Error("EXT-X-DEFINE QUERYPARAM: "+t.message))}}else i=t.NAME,n=t.VALUE;i in a?e.playlistParsingError||(e.playlistParsingError=new Error('EXT-X-DEFINE duplicate Variable Name declarations: "'+i+'"')):a[i]=n||""}function Qe(e,t,r){var i=t.IMPORT;if(r&&i in r){var n=e.variableList;n||(e.variableList=n={}),n[i]=r[i]}else e.playlistParsingError||(e.playlistParsingError=new Error('EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "'+i+'"'))}function $e(e){if(void 0===e&&(e=!0),"undefined"!=typeof self)return(e||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}var Je={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv60:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1}};function Ze(e,t,r){return void 0===r&&(r=!0),!e.split(",").some((function(e){return!et(e,t,r)}))}function et(e,t,r){var i;void 0===r&&(r=!0);var n=$e(r);return null!=(i=null==n?void 0:n.isTypeSupported(tt(e,t)))&&i}function tt(e,t){return t+'/mp4;codecs="'+e+'"'}function rt(e){return e.split(",").reduce((function(e,t){var r=Je.video[t];return r?(2*r+e)/(e?3:2):(Je.audio[t]+e)/(e?2:1)}),0)}var it={},nt=/flac|opus/i;function at(e,t){return void 0===t&&(t=!0),e.replace(nt,(function(e){return function(e,t){if(void 0===t&&(t=!0),it[e])return it[e];for(var r={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"]}[e],i=0;i<r.length;i++)if(et(r[i],"audio",t))return it[e]=r[i],r[i];return e}(e.toLowerCase(),t)}))}function st(e,t){return e&&"mp4a"!==e?e:t}var ot=/#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,lt=/#EXT-X-MEDIA:(.*)/g,ut=/^#EXT(?:INF|-X-TARGETDURATION):/m,dt=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),ht=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("|")),ct=function(){function e(){}return e.findGroup=function(e,t){for(var r=0;r<e.length;r++){var i=e[r];if(i.id===t)return i}},e.convertAVC1ToAVCOTI=function(e){var t=e.split(".");if(t.length>2){var r=t.shift()+".";return r+=parseInt(t.shift()).toString(16),r+=("000"+parseInt(t.shift()).toString(16)).slice(-4)}return e},e.resolve=function(e,t){return p.buildAbsoluteURL(t,e,{alwaysNormalize:!0})},e.isMediaPlaylist=function(e){return ut.test(e)},e.parseMasterPlaylist=function(t,r){var i,n={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:je(t)},a=[];for(ot.lastIndex=0;null!=(i=ot.exec(t));)if(i[1]){var s,o=new w(i[1]);qe(n,o,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);var l=Xe(n,i[2]),u={attrs:o,bitrate:o.decimalInteger("BANDWIDTH")||o.decimalInteger("AVERAGE-BANDWIDTH"),name:o.NAME,url:e.resolve(l,r)},d=o.decimalResolution("RESOLUTION");d&&(u.width=d.width,u.height=d.height),vt((o.CODECS||"").split(/[ ,]+/).filter((function(e){return e})),u),u.videoCodec&&-1!==u.videoCodec.indexOf("avc1")&&(u.videoCodec=e.convertAVC1ToAVCOTI(u.videoCodec)),null!=(s=u.unknownCodecs)&&s.length||a.push(u),n.levels.push(u)}else if(i[3]){var h=i[3],c=i[4];switch(h){case"SESSION-DATA":var f=new w(c);qe(n,f,["DATA-ID","LANGUAGE","VALUE","URI"]);var g=f["DATA-ID"];g&&(null===n.sessionData&&(n.sessionData={}),n.sessionData[g]=f);break;case"SESSION-KEY":var v=ft(c,r,n);v.encrypted&&v.isSupported()?(null===n.sessionKeys&&(n.sessionKeys=[]),n.sessionKeys.push(v)):D.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+c+'"');break;case"DEFINE":var m=new w(c);qe(n,m,["NAME","VALUE","QUERYPARAM"]),ze(n,m,r);break;case"CONTENT-STEERING":var p=new w(c);qe(n,p,["SERVER-URI","PATHWAY-ID"]),n.contentSteering={uri:e.resolve(p["SERVER-URI"],r),pathwayId:p["PATHWAY-ID"]||"."};break;case"START":n.startTimeOffset=gt(c)}}var y=a.length>0&&a.length<n.levels.length;return n.levels=y?a:n.levels,0===n.levels.length&&(n.playlistParsingError=new Error("no levels found in manifest")),n},e.parseMasterPlaylistMedia=function(t,r,i){var n,a={},s=i.levels,o={AUDIO:s.map((function(e){return{id:e.attrs.AUDIO,audioCodec:e.audioCodec}})),SUBTITLES:s.map((function(e){return{id:e.attrs.SUBTITLES,textCodec:e.textCodec}})),"CLOSED-CAPTIONS":[]},l=0;for(lt.lastIndex=0;null!==(n=lt.exec(t));){var u=new w(n[1]),d=u.TYPE;if(d){var h=o[d],c=a[d]||[];a[d]=c,qe(i,u,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);var f=u.LANGUAGE,g=u.CHANNELS,v=u.CHARACTERISTICS,m=u["INSTREAM-ID"],p={attrs:u,bitrate:0,id:l++,groupId:u["GROUP-ID"]||"",name:u.NAME||f||"",type:d,default:u.bool("DEFAULT"),autoselect:u.bool("AUTOSELECT"),forced:u.bool("FORCED"),lang:f,url:u.URI?e.resolve(u.URI,r):""};if(g&&(p.channels=g),v&&(p.characteristics=v),m&&(p.instreamId=m),null!=h&&h.length){var y=e.findGroup(h,p.groupId)||h[0];mt(p,y,"audioCodec"),mt(p,y,"textCodec")}c.push(p)}}return a},e.parseLevelPlaylist=function(e,t,r,i,n,a){var o,l,u,d=new G(t),h=d.fragments,c=null,f=0,g=0,v=0,m=0,p=null,E=new U(i,t),T=-1,S=!1,L=null;for(dt.lastIndex=0,d.m3u8=e,d.hasVariableRefs=je(e);null!==(o=dt.exec(e));){S&&(S=!1,(E=new U(i,t)).start=v,E.sn=f,E.cc=m,E.level=r,c&&(E.initSegment=c,E.rawProgramDateTime=c.rawProgramDateTime,c.rawProgramDateTime=null,L&&(E.setByteRange(L),L=null)));var R=o[1];if(R){E.duration=parseFloat(R);var A=(" "+o[2]).slice(1);E.title=A||null,E.tagList.push(A?["INF",R,A]:["INF",R])}else if(o[3]){if(y(E.duration)){E.start=v,u&&Et(E,u,d),E.sn=f,E.level=r,E.cc=m,E.urlId=n,h.push(E);var b=(" "+o[3]).slice(1);E.relurl=Xe(d,b),pt(E,p),p=E,v+=E.duration,f++,g=0,S=!0}}else if(o[4]){var k=(" "+o[4]).slice(1);p?E.setByteRange(k,p):E.setByteRange(k)}else if(o[5])E.rawProgramDateTime=(" "+o[5]).slice(1),E.tagList.push(["PROGRAM-DATE-TIME",E.rawProgramDateTime]),-1===T&&(T=h.length);else{if(!(o=o[0].match(ht))){D.warn("No matches on slow regex match for level playlist!");continue}for(l=1;l<o.length&&void 0===o[l];l++);var _=(" "+o[l]).slice(1),I=(" "+o[l+1]).slice(1),C=o[l+2]?(" "+o[l+2]).slice(1):"";switch(_){case"PLAYLIST-TYPE":d.type=I.toUpperCase();break;case"MEDIA-SEQUENCE":f=d.startSN=parseInt(I);break;case"SKIP":var x=new w(I);qe(d,x,["RECENTLY-REMOVED-DATERANGES"]);var F=x.decimalInteger("SKIPPED-SEGMENTS");if(y(F)){d.skippedSegments=F;for(var M=F;M--;)h.unshift(null);f+=F}var O=x.enumeratedString("RECENTLY-REMOVED-DATERANGES");O&&(d.recentlyRemovedDateranges=O.split("\t"));break;case"TARGETDURATION":d.targetduration=Math.max(parseInt(I),1);break;case"VERSION":d.version=parseInt(I);break;case"EXTM3U":break;case"ENDLIST":d.live=!1;break;case"#":(I||C)&&E.tagList.push(C?[I,C]:[I]);break;case"DISCONTINUITY":m++,E.tagList.push(["DIS"]);break;case"GAP":E.gap=!0,E.tagList.push([_]);break;case"BITRATE":E.tagList.push([_,I]);break;case"DATERANGE":var N=new w(I);qe(d,N,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),qe(d,N,N.clientAttrs);var K=new P(N,d.dateRanges[N.ID]);K.isValid||d.skippedSegments?d.dateRanges[K.id]=K:D.warn('Ignoring invalid DATERANGE tag: "'+I+'"'),E.tagList.push(["EXT-X-DATERANGE",I]);break;case"DEFINE":var H=new w(I);qe(d,H,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in H?Qe(d,H,a):ze(d,H,t);break;case"DISCONTINUITY-SEQUENCE":m=parseInt(I);break;case"KEY":var V=ft(I,t,d);if(V.isSupported()){if("NONE"===V.method){u=void 0;break}u||(u={}),u[V.keyFormat]&&(u=s({},u)),u[V.keyFormat]=V}else D.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'+I+'"');break;case"START":d.startTimeOffset=gt(I);break;case"MAP":var Y=new w(I);if(qe(d,Y,["BYTERANGE","URI"]),E.duration){var W=new U(i,t);yt(W,Y,r,u),c=W,E.initSegment=c,c.rawProgramDateTime&&!E.rawProgramDateTime&&(E.rawProgramDateTime=c.rawProgramDateTime)}else{var j=E.byteRangeEndOffset;if(j){var q=E.byteRangeStartOffset;L=j-q+"@"+q}else L=null;yt(E,Y,r,u),c=E,S=!0}break;case"SERVER-CONTROL":var X=new w(I);d.canBlockReload=X.bool("CAN-BLOCK-RELOAD"),d.canSkipUntil=X.optionalFloat("CAN-SKIP-UNTIL",0),d.canSkipDateRanges=d.canSkipUntil>0&&X.bool("CAN-SKIP-DATERANGES"),d.partHoldBack=X.optionalFloat("PART-HOLD-BACK",0),d.holdBack=X.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var z=new w(I);d.partTarget=z.decimalFloatingPoint("PART-TARGET");break;case"PART":var Q=d.partList;Q||(Q=d.partList=[]);var $=g>0?Q[Q.length-1]:void 0,J=g++,Z=new w(I);qe(d,Z,["BYTERANGE","URI"]);var ee=new B(Z,E,t,J,$);Q.push(ee),E.duration+=ee.duration;break;case"PRELOAD-HINT":var te=new w(I);qe(d,te,["URI"]),d.preloadHint=te;break;case"RENDITION-REPORT":var re=new w(I);qe(d,re,["URI"]),d.renditionReports=d.renditionReports||[],d.renditionReports.push(re);break;default:D.warn("line parsed but not handled: "+o)}}}p&&!p.relurl?(h.pop(),v-=p.duration,d.partList&&(d.fragmentHint=p)):d.partList&&(pt(E,p),E.cc=m,d.fragmentHint=E,u&&Et(E,u,d));var ie=h.length,ne=h[0],ae=h[ie-1];if((v+=d.skippedSegments*d.targetduration)>0&&ie&&ae){d.averagetargetduration=v/ie;var se=ae.sn;d.endSN="initSegment"!==se?se:0,d.live||(ae.endList=!0),ne&&(d.startCC=ne.cc)}else d.endSN=0,d.startCC=0;return d.fragmentHint&&(v+=d.fragmentHint.duration),d.totalduration=v,d.endCC=m,T>0&&function(e,t){for(var r=e[t],i=t;i--;){var n=e[i];if(!n)return;n.programDateTime=r.programDateTime-1e3*n.duration,r=n}}(h,T),d},e}();function ft(e,t,r){var i,n,a=new w(e);qe(r,a,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);var s=null!=(i=a.METHOD)?i:"",o=a.URI,l=a.hexadecimalInteger("IV"),u=a.KEYFORMATVERSIONS,d=null!=(n=a.KEYFORMAT)?n:"identity";o&&a.IV&&!l&&D.error("Invalid IV: "+a.IV);var h=o?ct.resolve(o,t):"",c=(u||"1").split("/").map(Number).filter(Number.isFinite);return new Ye(s,h,d,c,l)}function gt(e){var t=new w(e).decimalFloatingPoint("TIME-OFFSET");return y(t)?t:null}function vt(e,t){["video","audio","text"].forEach((function(r){var i=e.filter((function(e){return function(e,t){var r=Je[t];return!!r&&!!r[e.slice(0,4)]}(e,r)}));i.length&&(t[r+"Codec"]=i.join(","),e=e.filter((function(e){return-1===i.indexOf(e)})))})),t.unknownCodecs=e}function mt(e,t,r){var i=t[r];i&&(e[r]=i)}function pt(e,t){e.rawProgramDateTime?e.programDateTime=Date.parse(e.rawProgramDateTime):null!=t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime),y(e.programDateTime)||(e.programDateTime=null,e.rawProgramDateTime=null)}function yt(e,t,r,i){e.relurl=t.URI,t.BYTERANGE&&e.setByteRange(t.BYTERANGE),e.level=r,e.sn="initSegment",i&&(e.levelkeys=i),e.initSegment=null}function Et(e,t,r){e.levelkeys=t;var i=r.encryptedFragments;i.length&&i[i.length-1].levelkeys===t||!Object.keys(t).some((function(e){return t[e].isCommonEncryption}))||i.push(e)}var Tt="manifest",St="level",Lt="audioTrack",Rt="subtitleTrack",At="main",bt="audio",kt="subtitle";function Dt(e){switch(e.type){case Lt:return bt;case Rt:return kt;default:return At}}function _t(e,t){var r=e.url;return void 0!==r&&0!==r.indexOf("data:")||(r=t.url),r}var It=function(){function e(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=e,this.registerListeners()}var t=e.prototype;return t.startLoad=function(e){},t.stopLoad=function(){this.destroyInternalLoaders()},t.registerListeners=function(){var e=this.hls;e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.LEVEL_LOADING,this.onLevelLoading,this),e.on(E.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(E.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},t.unregisterListeners=function(){var e=this.hls;e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.LEVEL_LOADING,this.onLevelLoading,this),e.off(E.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(E.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},t.createInternalLoader=function(e){var t=this.hls.config,r=t.pLoader,i=t.loader,n=new(r||i)(t);return this.loaders[e.type]=n,n},t.getInternalLoader=function(e){return this.loaders[e.type]},t.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},t.destroyInternalLoaders=function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}},t.destroy=function(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()},t.onManifestLoading=function(e,t){var r=t.url;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:Tt,url:r,deliveryDirectives:null})},t.onLevelLoading=function(e,t){var r=t.id,i=t.level,n=t.url,a=t.deliveryDirectives;this.load({id:r,level:i,responseType:"text",type:St,url:n,deliveryDirectives:a})},t.onAudioTrackLoading=function(e,t){var r=t.id,i=t.groupId,n=t.url,a=t.deliveryDirectives;this.load({id:r,groupId:i,level:null,responseType:"text",type:Lt,url:n,deliveryDirectives:a})},t.onSubtitleTrackLoading=function(e,t){var r=t.id,i=t.groupId,n=t.url,a=t.deliveryDirectives;this.load({id:r,groupId:i,level:null,responseType:"text",type:Rt,url:n,deliveryDirectives:a})},t.load=function(e){var t,r,i,n=this,a=this.hls.config,o=this.getInternalLoader(e);if(o){var l=o.context;if(l&&l.url===e.url)return void D.trace("[playlist-loader]: playlist request ongoing");D.log("[playlist-loader]: aborting previous loader for type: "+e.type),o.abort()}if(r=e.type===Tt?a.manifestLoadPolicy.default:s({},a.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),o=this.createInternalLoader(e),y(null==(t=e.deliveryDirectives)?void 0:t.part)&&(e.type===St&&null!==e.level?i=this.hls.levels[e.level].details:e.type===Lt&&null!==e.id?i=this.hls.audioTracks[e.id].details:e.type===Rt&&null!==e.id&&(i=this.hls.subtitleTracks[e.id].details),i)){var u=i.partTarget,d=i.targetduration;if(u&&d){var h=1e3*Math.max(3*u,.8*d);r=s({},r,{maxTimeToFirstByteMs:Math.min(h,r.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(h,r.maxTimeToFirstByteMs)})}}var c=r.errorRetry||r.timeoutRetry||{},f={loadPolicy:r,timeout:r.maxLoadTimeMs,maxRetry:c.maxNumRetry||0,retryDelay:c.retryDelayMs||0,maxRetryDelay:c.maxRetryDelayMs||0},g={onSuccess:function(e,t,r,i){var a=n.getInternalLoader(r);n.resetInternalLoader(r.type);var s=e.data;0===s.indexOf("#EXTM3U")?(t.parsing.start=performance.now(),ct.isMediaPlaylist(s)?n.handleTrackOrLevelPlaylist(e,t,r,i||null,a):n.handleMasterPlaylist(e,t,r,i)):n.handleManifestParsingError(e,r,new Error("no EXTM3U delimiter"),i||null,t)},onError:function(e,t,r,i){n.handleNetworkError(t,r,!1,e,i)},onTimeout:function(e,t,r){n.handleNetworkError(t,r,!0,void 0,e)}};o.load(e,f,g)},t.handleMasterPlaylist=function(e,t,r,i){var n=this.hls,a=e.data,s=_t(e,r),o=ct.parseMasterPlaylist(a,s);if(o.playlistParsingError)this.handleManifestParsingError(e,r,o.playlistParsingError,i,t);else{var l=o.contentSteering,u=o.levels,d=o.sessionData,h=o.sessionKeys,c=o.startTimeOffset,f=o.variableList;this.variableList=f;var g=ct.parseMasterPlaylistMedia(a,s,o),v=g.AUDIO,m=void 0===v?[]:v,p=g.SUBTITLES,y=g["CLOSED-CAPTIONS"];m.length&&(m.some((function(e){return!e.url}))||!u[0].audioCodec||u[0].attrs.AUDIO||(D.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),m.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new w({}),bitrate:0,url:""}))),n.trigger(E.MANIFEST_LOADED,{levels:u,audioTracks:m,subtitles:p,captions:y,contentSteering:l,url:s,stats:t,networkDetails:i,sessionData:d,sessionKeys:h,startTimeOffset:c,variableList:f})}},t.handleTrackOrLevelPlaylist=function(e,t,r,i,n){var a=this.hls,s=r.id,o=r.level,l=r.type,u=_t(e,r),d=y(s)?s:0,h=y(o)?o:d,c=Dt(r),f=ct.parseLevelPlaylist(e.data,u,h,c,d,this.variableList);if(l===Tt){var g={attrs:new w({}),bitrate:0,details:f,name:"",url:u};a.trigger(E.MANIFEST_LOADED,{levels:[g],audioTracks:[],ur