-
Notifications
You must be signed in to change notification settings - Fork 0
/
xgplayer-hls.js
1 lines (1 loc) · 285 KB
/
xgplayer-hls.js
1
window.HlsJsPlayer=function(e){var t={};function r(i){if(t[i])return t[i].exports;var a=t[i]={i:i,l:!1,exports:{}};return e[i].call(a.exports,a,a.exports,r),a.l=!0,a.exports}return r.m=e,r.c=t,r.d=function(e,t,i){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(r.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)r.d(i,a,function(t){return e[t]}.bind(null,a));return i},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=80)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.logger=t.enableLogs=void 0;var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a=r(7);function n(){}var o={trace:n,debug:n,log:n,warn:n,info:n,error:n},s=o;var l=(0,a.getSelfScope)();function u(e){for(var t=arguments.length,r=Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];r.forEach(function(t){s[t]=e[t]?e[t].bind(e):function(e){var t=l.console[e];return t?function(){for(var r=arguments.length,i=Array(r),a=0;a<r;a++)i[a]=arguments[a];i[0]&&(i[0]=function(e,t){return t="["+e+"] > "+t}(e,i[0])),t.apply(l.console,i)}:n}(t)})}t.enableLogs=function(e){if(!0===e||"object"===(void 0===e?"undefined":i(e))){u(e,"debug","log","info","warn","error");try{s.log()}catch(e){s=o}}else s=o},t.logger=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default={MEDIA_ATTACHING:"hlsMediaAttaching",MEDIA_ATTACHED:"hlsMediaAttached",MEDIA_DETACHING:"hlsMediaDetaching",MEDIA_DETACHED:"hlsMediaDetached",BUFFER_RESET:"hlsBufferReset",BUFFER_CODECS:"hlsBufferCodecs",BUFFER_CREATED:"hlsBufferCreated",BUFFER_APPENDING:"hlsBufferAppending",BUFFER_APPENDED:"hlsBufferAppended",BUFFER_EOS:"hlsBufferEos",BUFFER_FLUSHING:"hlsBufferFlushing",BUFFER_FLUSHED:"hlsBufferFlushed",MANIFEST_LOADING:"hlsManifestLoading",MANIFEST_LOADED:"hlsManifestLoaded",MANIFEST_PARSED:"hlsManifestParsed",LEVEL_SWITCHING:"hlsLevelSwitching",LEVEL_SWITCHED:"hlsLevelSwitched",LEVEL_LOADING:"hlsLevelLoading",LEVEL_LOADED:"hlsLevelLoaded",LEVEL_UPDATED:"hlsLevelUpdated",LEVEL_PTS_UPDATED:"hlsLevelPtsUpdated",AUDIO_TRACKS_UPDATED:"hlsAudioTracksUpdated",AUDIO_TRACK_SWITCHING:"hlsAudioTrackSwitching",AUDIO_TRACK_SWITCHED:"hlsAudioTrackSwitched",AUDIO_TRACK_LOADING:"hlsAudioTrackLoading",AUDIO_TRACK_LOADED:"hlsAudioTrackLoaded",SUBTITLE_TRACKS_UPDATED:"hlsSubtitleTracksUpdated",SUBTITLE_TRACK_SWITCH:"hlsSubtitleTrackSwitch",SUBTITLE_TRACK_LOADING:"hlsSubtitleTrackLoading",SUBTITLE_TRACK_LOADED:"hlsSubtitleTrackLoaded",SUBTITLE_FRAG_PROCESSED:"hlsSubtitleFragProcessed",INIT_PTS_FOUND:"hlsInitPtsFound",FRAG_LOADING:"hlsFragLoading",FRAG_LOAD_PROGRESS:"hlsFragLoadProgress",FRAG_LOAD_EMERGENCY_ABORTED:"hlsFragLoadEmergencyAborted",FRAG_LOADED:"hlsFragLoaded",FRAG_DECRYPTED:"hlsFragDecrypted",FRAG_PARSING_INIT_SEGMENT:"hlsFragParsingInitSegment",FRAG_PARSING_USERDATA:"hlsFragParsingUserdata",FRAG_PARSING_METADATA:"hlsFragParsingMetadata",FRAG_PARSING_DATA:"hlsFragParsingData",FRAG_PARSED:"hlsFragParsed",FRAG_BUFFERED:"hlsFragBuffered",FRAG_CHANGED:"hlsFragChanged",FPS_DROP:"hlsFpsDrop",FPS_DROP_LEVEL_CAPPING:"hlsFpsDropLevelCapping",ERROR:"hlsError",DESTROYING:"hlsDestroying",KEY_LOADING:"hlsKeyLoading",KEY_LOADED:"hlsKeyLoaded",STREAM_STATE_TRANSITION:"hlsStreamStateTransition"},e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.ErrorTypes={NETWORK_ERROR:"networkError",MEDIA_ERROR:"mediaError",KEY_SYSTEM_ERROR:"keySystemError",MUX_ERROR:"muxError",OTHER_ERROR:"otherError"},t.ErrorDetails={KEY_SYSTEM_NO_KEYS:"keySystemNoKeys",KEY_SYSTEM_NO_ACCESS:"keySystemNoAccess",KEY_SYSTEM_NO_SESSION:"keySystemNoSession",KEY_SYSTEM_LICENSE_REQUEST_FAILED:"keySystemLicenseRequestFailed",MANIFEST_LOAD_ERROR:"manifestLoadError",MANIFEST_LOAD_TIMEOUT:"manifestLoadTimeOut",MANIFEST_PARSING_ERROR:"manifestParsingError",MANIFEST_INCOMPATIBLE_CODECS_ERROR:"manifestIncompatibleCodecsError",LEVEL_LOAD_ERROR:"levelLoadError",LEVEL_LOAD_TIMEOUT:"levelLoadTimeOut",LEVEL_SWITCH_ERROR:"levelSwitchError",AUDIO_TRACK_LOAD_ERROR:"audioTrackLoadError",AUDIO_TRACK_LOAD_TIMEOUT:"audioTrackLoadTimeOut",FRAG_LOAD_ERROR:"fragLoadError",FRAG_LOAD_TIMEOUT:"fragLoadTimeOut",FRAG_DECRYPT_ERROR:"fragDecryptError",FRAG_PARSING_ERROR:"fragParsingError",REMUX_ALLOC_ERROR:"remuxAllocError",KEY_LOAD_ERROR:"keyLoadError",KEY_LOAD_TIMEOUT:"keyLoadTimeOut",BUFFER_ADD_CODEC_ERROR:"bufferAddCodecError",BUFFER_APPEND_ERROR:"bufferAppendError",BUFFER_APPENDING_ERROR:"bufferAppendingError",BUFFER_STALLED_ERROR:"bufferStalledError",BUFFER_FULL_ERROR:"bufferFullError",BUFFER_SEEK_OVER_HOLE:"bufferSeekOverHole",BUFFER_NUDGE_ON_STALL:"bufferNudgeOnStall",INTERNAL_EXCEPTION:"internalException"}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a=function(){function e(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,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),n=r(0),o=r(2),s=function(e){return e&&e.__esModule?e:{default:e}}(r(1));var l={hlsEventGeneric:!0,hlsHandlerDestroying:!0,hlsHandlerDestroyed:!0},u=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.hls=t,this.onEvent=this.onEvent.bind(this);for(var r=arguments.length,i=Array(r>1?r-1:0),a=1;a<r;a++)i[a-1]=arguments[a];this.handledEvents=i,this.useGenericHandler=!0,this.registerListeners()}return a(e,[{key:"destroy",value:function(){this.onHandlerDestroying(),this.unregisterListeners(),this.onHandlerDestroyed()}},{key:"onHandlerDestroying",value:function(){}},{key:"onHandlerDestroyed",value:function(){}},{key:"isEventHandler",value:function(){return"object"===i(this.handledEvents)&&this.handledEvents.length&&"function"==typeof this.onEvent}},{key:"registerListeners",value:function(){this.isEventHandler()&&this.handledEvents.forEach(function(e){if(l[e])throw new Error("Forbidden event-name: "+e);this.hls.on(e,this.onEvent)},this)}},{key:"unregisterListeners",value:function(){this.isEventHandler()&&this.handledEvents.forEach(function(e){this.hls.off(e,this.onEvent)},this)}},{key:"onEvent",value:function(e,t){this.onEventGeneric(e,t)}},{key:"onEventGeneric",value:function(e,t){try{(function(e,t){var r="on"+e.replace("hls","");if("function"!=typeof this[r])throw new Error("Event "+e+" has no generic handler in this "+this.constructor.name+" class (tried "+r+")");return this[r].bind(this,t)}).call(this,e,t).call()}catch(t){n.logger.error("An internal error happened while handling event "+e+'. Error message: "'+t.message+'". Here is a stacktrace:',t),this.hls.trigger(s.default.ERROR,{type:o.ErrorTypes.OTHER_ERROR,details:o.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:e,err:t})}}}]),e}();t.default=u,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(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,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}();t.BufferHelper=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return i(e,null,[{key:"isBuffered",value:function(e,t){try{if(e)for(var r=e.buffered,i=0;i<r.length;i++)if(t>=r.start(i)&&t<=r.end(i))return!0}catch(e){}return!1}},{key:"bufferInfo",value:function(e,t,r){try{if(e){var i=e.buffered,a=[],n=void 0;for(n=0;n<i.length;n++)a.push({start:i.start(n),end:i.end(n)});return this.bufferedInfo(a,t,r)}}catch(e){}return{len:0,start:t,end:t,nextStart:void 0}}},{key:"bufferedInfo",value:function(e,t,r){var i=[],a=void 0,n=void 0,o=void 0,s=void 0,l=void 0;for(e.sort(function(e,t){var r=e.start-t.start;return r||t.end-e.end}),l=0;l<e.length;l++){var u=i.length;if(u){var d=i[u-1].end;e[l].start-d<r?e[l].end>d&&(i[u-1].end=e[l].end):i.push(e[l])}else i.push(e[l])}for(l=0,a=0,n=o=t;l<i.length;l++){var f=i[l].start,c=i[l].end;if(t+r>=f&&t<c)n=f,a=(o=c)-t;else if(t+r<f){s=f;break}}return{len:a,start:n,end:o,nextStart:s}}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addGroupId=function(e,t,r){switch(t){case"audio":e.audioGroupIds||(e.audioGroupIds=[]),e.audioGroupIds.push(r);break;case"text":e.textGroupIds||(e.textGroupIds=[]),e.textGroupIds.push(r)}},t.updatePTS=a,t.updateFragPTSDTS=n,t.mergeDetails=function(e,t){t.initSegment&&e.initSegment&&(t.initSegment=e.initSegment);var r=0,a=void 0;if(o(e,t,function(e,i){r=e.cc-i.cc,Number.isFinite(e.startPTS)&&(i.start=i.startPTS=e.startPTS,i.endPTS=e.endPTS,i.duration=e.duration,i.backtracked=e.backtracked,i.dropped=e.dropped,a=i),t.PTSKnown=!0}),!t.PTSKnown)return;if(r){i.logger.log("discontinuity sliding from playlist, take drift into account");for(var l=t.fragments,u=0;u<l.length;u++)l[u].cc+=r}a?n(t,a,a.startPTS,a.endPTS,a.startDTS,a.endDTS):s(e,t);t.PTSKnown=e.PTSKnown},t.mergeSubtitlePlaylists=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=-1;o(e,t,function(e,t,r){t.start=e.start,i=r});var a=t.fragments;if(i<0)return void a.forEach(function(e){e.start+=r});for(var n=i+1;n<a.length;n++)a[n].start=a[n-1].start+a[n-1].duration},t.mapFragmentIntersection=o,t.adjustSliding=s,t.computeReloadInterval=function(e,t,r){var i=1e3*(t.averagetargetduration?t.averagetargetduration:t.targetduration),a=i/2;e&&t.endSN===e.endSN&&(i=a);r&&(i=Math.max(a,i-(window.performance.now()-r)));return Math.round(i)};var i=r(0);function a(e,t,r){var a=e[t],n=e[r],o=n.startPTS;Number.isFinite(o)?r>t?(a.duration=o-a.start,a.duration<0&&i.logger.warn("negative duration computed for frag "+a.sn+",level "+a.level+", there should be some duration drift between playlist and fragment!")):(n.duration=a.start-o,n.duration<0&&i.logger.warn("negative duration computed for frag "+n.sn+",level "+n.level+", there should be some duration drift between playlist and fragment!")):n.start=r>t?a.start+a.duration:Math.max(a.start-n.duration,0)}function n(e,t,r,i,n,o){var s=r;if(Number.isFinite(t.startPTS)){var l=Math.abs(t.startPTS-r);Number.isFinite(t.deltaPTS)?t.deltaPTS=Math.max(l,t.deltaPTS):t.deltaPTS=l,s=Math.max(r,t.startPTS),r=Math.min(r,t.startPTS),i=Math.max(i,t.endPTS),n=Math.min(n,t.startDTS),o=Math.max(o,t.endDTS)}var u=r-t.start;t.start=t.startPTS=r,t.maxStartPTS=s,t.endPTS=i,t.startDTS=n,t.endDTS=o,t.duration=i-r;var d=t.sn;if(!e||d<e.startSN||d>e.endSN)return 0;var f,c=void 0,h=void 0;for(f=d-e.startSN,(c=e.fragments)[f]=t,h=f;h>0;h--)a(c,h,h-1);for(h=f;h<c.length-1;h++)a(c,h,h+1);return e.PTSKnown=!0,u}function o(e,t,r){if(e&&t)for(var i=Math.max(e.startSN,t.startSN)-t.startSN,a=Math.min(e.endSN,t.endSN)-t.startSN,n=t.startSN-e.startSN,o=i;o<=a;o++){var s=e.fragments[n+o],l=t.fragments[o];if(!s||!l)break;r(s,l,o)}}function s(e,t){var r=t.startSN-e.startSN,i=e.fragments,a=t.fragments;if(!(r<0||r>i.length))for(var n=0;n<a.length;n++)a[n].start+=i[r].start}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FragmentTracker=t.FragmentState=void 0;var i=function(){function e(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,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),a=o(r(3)),n=o(r(1));function o(e){return e&&e.__esModule?e:{default:e}}var s=t.FragmentState={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"};t.FragmentTracker=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var r=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n.default.BUFFER_APPENDED,n.default.FRAG_BUFFERED,n.default.FRAG_LOADED));return r.bufferPadding=.2,r.fragments=Object.create(null),r.timeRanges=Object.create(null),r.config=e.config,r}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,a.default),i(t,[{key:"destroy",value:function(){this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.config=null,a.default.prototype.destroy.call(this),function e(t,r,i){null===t&&(t=Function.prototype);var a=Object.getOwnPropertyDescriptor(t,r);if(void 0===a){var n=Object.getPrototypeOf(t);return null===n?void 0:e(n,r,i)}if("value"in a)return a.value;var o=a.get;return void 0!==o?o.call(i):void 0}(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"destroy",this).call(this)}},{key:"getBufferedFrag",value:function(e,t){var r=this.fragments,i=Object.keys(r).filter(function(i){var a=r[i];if(a.body.type!==t)return!1;if(!a.buffered)return!1;var n=a.body;return n.startPTS<=e&&e<=n.endPTS});if(0===i.length)return null;var a=i.pop();return r[a].body}},{key:"detectEvictedFragments",value:function(e,t){var r=this,i=void 0,a=void 0;Object.keys(this.fragments).forEach(function(n){var o=r.fragments[n];if(!0===o.buffered){var s=o.range[e];if(s){i=s.time;for(var l=0;l<i.length;l++)if(a=i[l],!1===r.isTimeBuffered(a.startPTS,a.endPTS,t)){r.removeFragment(o.body);break}}}})}},{key:"detectPartialFragments",value:function(e){var t=this,r=this.getFragmentKey(e),i=this.fragments[r];i&&(i.buffered=!0,Object.keys(this.timeRanges).forEach(function(r){if(e.hasElementaryStream(r)){var a=t.timeRanges[r];i.range[r]=t.getBufferedTimes(e.startPTS,e.endPTS,a)}}))}},{key:"getBufferedTimes",value:function(e,t,r){for(var i=[],a=void 0,n=void 0,o=!1,s=0;s<r.length;s++){if(a=r.start(s)-this.bufferPadding,n=r.end(s)+this.bufferPadding,e>=a&&t<=n){i.push({startPTS:Math.max(e,r.start(s)),endPTS:Math.min(t,r.end(s))});break}if(e<n&&t>a)i.push({startPTS:Math.max(e,r.start(s)),endPTS:Math.min(t,r.end(s))}),o=!0;else if(t<=a)break}return{time:i,partial:o}}},{key:"getFragmentKey",value:function(e){return e.type+"_"+e.level+"_"+e.urlId+"_"+e.sn}},{key:"getPartialFragment",value:function(e){var t=this,r=void 0,i=void 0,a=void 0,n=null,o=0;return Object.keys(this.fragments).forEach(function(s){var l=t.fragments[s];t.isPartial(l)&&(i=l.body.startPTS-t.bufferPadding,a=l.body.endPTS+t.bufferPadding,e>=i&&e<=a&&(r=Math.min(e-i,a-e),o<=r&&(n=l.body,o=r)))}),n}},{key:"getState",value:function(e){var t=this.getFragmentKey(e),r=this.fragments[t],i=s.NOT_LOADED;return void 0!==r&&(i=r.buffered?!0===this.isPartial(r)?s.PARTIAL:s.OK:s.APPENDING),i}},{key:"isPartial",value:function(e){return!0===e.buffered&&(void 0!==e.range.video&&!0===e.range.video.partial||void 0!==e.range.audio&&!0===e.range.audio.partial)}},{key:"isTimeBuffered",value:function(e,t,r){for(var i=void 0,a=void 0,n=0;n<r.length;n++){if(i=r.start(n)-this.bufferPadding,a=r.end(n)+this.bufferPadding,e>=i&&t<=a)return!0;if(t<=i)return!1}return!1}},{key:"onFragLoaded",value:function(e){var t=e.frag;Number.isFinite(t.sn)&&!t.bitrateTest&&(this.fragments[this.getFragmentKey(t)]={body:t,range:Object.create(null),buffered:!1})}},{key:"onBufferAppended",value:function(e){var t=this;this.timeRanges=e.timeRanges,Object.keys(this.timeRanges).forEach(function(e){var r=t.timeRanges[e];t.detectEvictedFragments(e,r)})}},{key:"onFragBuffered",value:function(e){this.detectPartialFragments(e.frag)}},{key:"hasFragment",value:function(e){var t=this.getFragmentKey(e);return void 0!==this.fragments[t]}},{key:"removeFragment",value:function(e){var t=this.getFragmentKey(e);delete this.fragments[t]}},{key:"removeAllFragments",value:function(){this.fragments=Object.create(null)}}]),t}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getSelfScope=function(){return"undefined"==typeof window?self:window}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(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,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}();var a=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return i(e,null,[{key:"isHeader",value: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}},{key:"isFooter",value: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}},{key:"getID3Data",value:function(t,r){for(var i=r,a=0;e.isHeader(t,r);){a+=10,a+=e._readSize(t,r+6),e.isFooter(t,r+10)&&(a+=10),r+=a}if(a>0)return t.subarray(i,i+a)}},{key:"_readSize",value: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]}},{key:"getTimeStamp",value:function(t){for(var r=e.getID3Frames(t),i=0;i<r.length;i++){var a=r[i];if(e.isTimeStampFrame(a))return e._readTimeStamp(a)}}},{key:"isTimeStampFrame",value:function(e){return e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info}},{key:"_getFrameData",value:function(t){var r=String.fromCharCode(t[0],t[1],t[2],t[3]),i=e._readSize(t,4);return{type:r,size:i,data:t.subarray(10,10+i)}}},{key:"getID3Frames",value:function(t){for(var r=0,i=[];e.isHeader(t,r);){for(var a=e._readSize(t,r+6),n=(r+=10)+a;r+8<n;){var o=e._getFrameData(t.subarray(r)),s=e._decodeFrame(o);s&&i.push(s),r+=o.size+10}e.isFooter(t,r)&&(r+=10)}return i}},{key:"_decodeFrame",value:function(t){return"PRIV"===t.type?e._decodePrivFrame(t):"T"===t.type[0]?e._decodeTextFrame(t):"W"===t.type[0]?e._decodeURLFrame(t):void 0}},{key:"_readTimeStamp",value: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)}}},{key:"_decodePrivFrame",value:function(t){if(!(t.size<2)){var r=e._utf8ArrayToStr(t.data,!0),i=new Uint8Array(t.data.subarray(r.length+1));return{key:t.type,info:r,data:i.buffer}}}},{key:"_decodeTextFrame",value:function(t){if(!(t.size<2)){if("TXXX"===t.type){var r=1,i=e._utf8ArrayToStr(t.data.subarray(r));r+=i.length+1;var a=e._utf8ArrayToStr(t.data.subarray(r));return{key:t.type,info:i,data:a}}var n=e._utf8ArrayToStr(t.data.subarray(1));return{key:t.type,data:n}}}},{key:"_decodeURLFrame",value:function(t){if("WXXX"===t.type){if(t.size<2)return;var r=1,i=e._utf8ArrayToStr(t.data.subarray(r));r+=i.length+1;var a=e._utf8ArrayToStr(t.data.subarray(r));return{key:t.type,info:i,data:a}}var n=e._utf8ArrayToStr(t.data);return{key:t.type,data:n}}},{key:"_utf8ArrayToStr",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=e.length,i=void 0,a=void 0,n=void 0,o="",s=0;s<r;){if(0===(i=e[s++])&&t)return o;if(0!==i&&3!==i)switch(i>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:o+=String.fromCharCode(i);break;case 12:case 13:a=e[s++],o+=String.fromCharCode((31&i)<<6|63&a);break;case 14:a=e[s++],n=e[s++],o+=String.fromCharCode((15&i)<<12|(63&a)<<6|(63&n)<<0)}}return o}}]),e}(),n=a._utf8ArrayToStr;t.default=a,t.utf8ArrayToStr=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default={search:function(e,t){for(var r=0,i=e.length-1,a=null,n=null;r<=i;){var o=t(n=e[a=(r+i)/2|0]);if(o>0)r=a+1;else{if(!(o<0))return n;i=a-1}}return null}},e.exports=t.default},function(e,t,r){!function(t){var r=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/\?#]*\/)*.*?)??(;.*?)?(\?.*?)?(#.*?)?$/,i=/^([^\/?#]*)(.*)$/,a=/(?:\/|^)\.(?=\/)/g,n=/(?:\/|^)\.\.\/(?!\.\.\/).*?(?=\/)/g,o={buildAbsoluteURL:function(e,t,r){if(r=r||{},e=e.trim(),!(t=t.trim())){if(!r.alwaysNormalize)return e;var a=o.parseURL(e);if(!a)throw new Error("Error trying to parse base URL.");return a.path=o.normalizePath(a.path),o.buildURLFromParts(a)}var n=o.parseURL(t);if(!n)throw new Error("Error trying to parse relative URL.");if(n.scheme)return r.alwaysNormalize?(n.path=o.normalizePath(n.path),o.buildURLFromParts(n)):t;var s=o.parseURL(e);if(!s)throw new Error("Error trying to parse base URL.");if(!s.netLoc&&s.path&&"/"!==s.path[0]){var l=i.exec(s.path);s.netLoc=l[1],s.path=l[2]}s.netLoc&&!s.path&&(s.path="/");var u={scheme:s.scheme,netLoc:n.netLoc,path:null,params:n.params,query:n.query,fragment:n.fragment};if(!n.netLoc&&(u.netLoc=s.netLoc,"/"!==n.path[0]))if(n.path){var d=s.path,f=d.substring(0,d.lastIndexOf("/")+1)+n.path;u.path=o.normalizePath(f)}else u.path=s.path,n.params||(u.params=s.params,n.query||(u.query=s.query));return null===u.path&&(u.path=r.alwaysNormalize?o.normalizePath(n.path):n.path),o.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(a,"");e.length!==(e=e.replace(n,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}};e.exports=o}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.State=void 0;var i=function(){function e(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,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),a=function(e){return e&&e.__esModule?e:{default:e}}(r(17)),n=r(6),o=r(4),s=r(0);var l=t.State={STOPPED:"STOPPED",STARTING:"STARTING",IDLE:"IDLE",PAUSED:"PAUSED",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",BUFFER_FLUSHING:"BUFFER_FLUSHING",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},u=function(e){function t(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,a.default),i(t,[{key:"doTick",value:function(){}},{key:"startLoad",value:function(){}},{key:"stopLoad",value:function(){var e=this.fragCurrent;e&&(e.loader&&e.loader.abort(),this.fragmentTracker.removeFragment(e)),this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=l.STOPPED}},{key:"_streamEnded",value:function(e,t){var r=this.fragCurrent,i=this.fragmentTracker;if(!t.live&&r&&!r.backtracked&&r.sn===t.endSN&&!e.nextStart){var a=i.getState(r);return a===n.FragmentState.PARTIAL||a===n.FragmentState.OK}return!1}},{key:"onMediaSeeking",value:function(){var e=this.config,t=this.media,r=this.mediaBuffer,i=this.state,a=t?t.currentTime:null,n=o.BufferHelper.bufferInfo(r||t,a,this.config.maxBufferHole);if(Number.isFinite(a)&&s.logger.log("media seeking to "+a.toFixed(3)),i===l.FRAG_LOADING){var u=this.fragCurrent;if(0===n.len&&u){var d=e.maxFragLookUpTolerance,f=u.start-d,c=u.start+u.duration+d;a<f||a>c?(u.loader&&(s.logger.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),u.loader.abort()),this.fragCurrent=null,this.fragPrevious=null,this.state=l.IDLE):s.logger.log("seeking outside of buffer but within currently loaded fragment range")}}else i===l.ENDED&&(0===n.len&&(this.fragPrevious=null,this.fragCurrent=null),this.state=l.IDLE);t&&(this.lastCurrentTime=a),this.loadedmetadata||(this.nextLoadPosition=this.startPosition=a),this.tick()}},{key:"onMediaEnded",value:function(){this.startPosition=this.lastCurrentTime=0}},{key:"onHandlerDestroying",value:function(){this.stopLoad(),function e(t,r,i){null===t&&(t=Function.prototype);var a=Object.getOwnPropertyDescriptor(t,r);if(void 0===a){var n=Object.getPrototypeOf(t);return null===n?void 0:e(n,r,i)}if("value"in a)return a.value;var o=a.get;return void 0!==o?o.call(i):void 0}(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"onHandlerDestroying",this).call(this)}},{key:"onHandlerDestroyed",value:function(){this.state=l.STOPPED,this.fragmentTracker=null}}]),t}();t.default=u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getMediaSource=function(){if("undefined"!=typeof window)return window.MediaSource||window.WebKitMediaSource}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(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,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),a=d(r(69)),n=d(r(68)),o=d(r(67)),s=r(2),l=r(0),u=d(r(1));function d(e){return e&&e.__esModule?e:{default:e}}var f=(0,r(7).getSelfScope)(),c=function(){function e(t,r){var i=(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).removePKCS7Padding,a=void 0===i||i;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.logEnabled=!0,this.observer=t,this.config=r,this.removePKCS7Padding=a,a)try{var n=f.crypto;n&&(this.subtle=n.subtle||n.webkitSubtle)}catch(e){}this.disableWebCrypto=!this.subtle}return i(e,[{key:"isSync",value:function(){return this.disableWebCrypto&&this.config.enableSoftwareAES}},{key:"decrypt",value:function(e,t,r,i){var s=this;if(this.disableWebCrypto&&this.config.enableSoftwareAES){this.logEnabled&&(l.logger.log("JS AES decrypt"),this.logEnabled=!1);var u=this.decryptor;u||(this.decryptor=u=new o.default),u.expandKey(t),i(u.decrypt(e,0,r,this.removePKCS7Padding))}else{this.logEnabled&&(l.logger.log("WebCrypto AES decrypt"),this.logEnabled=!1);var d=this.subtle;this.key!==t&&(this.key=t,this.fastAesKey=new n.default(d,t)),this.fastAesKey.expandKey().then(function(n){new a.default(d,r).decrypt(e,n).catch(function(a){s.onWebCryptoError(a,e,t,r,i)}).then(function(e){i(e)})}).catch(function(a){s.onWebCryptoError(a,e,t,r,i)})}}},{key:"onWebCryptoError",value:function(e,t,r,i,a){this.config.enableSoftwareAES?(l.logger.log("WebCrypto Error, disable WebCrypto API"),this.disableWebCrypto=!0,this.logEnabled=!0,this.decrypt(t,r,i,a)):(l.logger.error("decrypting error : "+e.message),this.observer.trigger(u.default.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.FRAG_DECRYPT_ERROR,fatal:!0,reason:e.message}))}},{key:"destroy",value:function(){var e=this.decryptor;e&&(e.destroy(),this.decryptor=void 0)}}]),e}();t.default=c,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(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,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),a=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(r(10)),n=function(e){return e&&e.__esModule?e:{default:e}}(r(28));function o(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var s=function(){function e(){var t;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._url=null,this._byteRange=null,this._decryptdata=null,this.tagList=[],this.programDateTime=null,this.rawProgramDateTime=null,this._elementaryStreams=(o(t={},e.ElementaryStreamTypes.AUDIO,!1),o(t,e.ElementaryStreamTypes.VIDEO,!1),t)}return i(e,[{key:"addElementaryStream",value:function(e){this._elementaryStreams[e]=!0}},{key:"hasElementaryStream",value:function(e){return!0===this._elementaryStreams[e]}},{key:"createInitializationVector",value:function(e){for(var t=new Uint8Array(16),r=12;r<16;r++)t[r]=e>>8*(15-r)&255;return t}},{key:"fragmentDecryptdataFromLevelkey",value:function(e,t){var r=e;return e&&e.method&&e.uri&&!e.iv&&((r=new n.default).method=e.method,r.baseuri=e.baseuri,r.reluri=e.reluri,r.iv=this.createInitializationVector(t)),r}},{key:"url",get:function(){return!this._url&&this.relurl&&(this._url=a.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url},set:function(e){this._url=e}},{key:"byteRange",get:function(){if(!this._byteRange&&!this.rawByteRange)return[];if(this._byteRange)return this._byteRange;var e=[];if(this.rawByteRange){var t=this.rawByteRange.split("@",2);if(1===t.length){var r=this.lastByteRangeEndOffset;e[0]=r||0}else e[0]=parseInt(t[1]);e[1]=parseInt(t[0])+e[0],this._byteRange=e}return e}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"decryptdata",get:function(){return this._decryptdata||(this._decryptdata=this.fragmentDecryptdataFromLevelkey(this.levelkey,this.sn)),this._decryptdata}},{key:"endProgramDateTime",get:function(){if(!Number.isFinite(this.programDateTime))return null;var e=Number.isFinite(this.duration)?this.duration:0;return this.programDateTime+1e3*e}},{key:"encrypted",get:function(){return!(!this.decryptdata||null===this.decryptdata.uri||null!==this.decryptdata.key)}}],[{key:"ElementaryStreamTypes",get:function(){return{AUDIO:"audio",VIDEO:"video"}}}]),e}();t.default=s,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fixLineBreaks=void 0;var i=function(e){return e&&e.__esModule?e:{default:e}}(r(40));var a=function(){return{decode:function(e){if(!e)return"";if("string"!=typeof e)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}};function n(){this.window=window,this.state="INITIAL",this.buffer="",this.decoder=new a,this.regionList=[]}function o(){this.values=Object.create(null)}function s(e,t,r,i){var a=i?e.split(i):[e];for(var n in a)if("string"==typeof a[n]){var o=a[n].split(r);if(2===o.length)t(o[0],o[1])}}o.prototype={set:function(e,t){this.get(e)||""===t||(this.values[e]=t)},get:function(e,t,r){return r?this.has(e)?this.values[e]:t[r]:this.has(e)?this.values[e]:t},has:function(e){return e in this.values},alt:function(e,t,r){for(var i=0;i<r.length;++i)if(t===r[i]){this.set(e,t);break}},integer:function(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))},percent:function(e,t){return!!(t.match(/^([\d]{1,3})(\.[\d]*)?%$/)&&(t=parseFloat(t))>=0&&t<=100)&&(this.set(e,t),!0)}};var l=new i.default(0,0,0),u="middle"===l.align?"middle":"center";function d(e,t,r){var i=e;function a(){var t=function(e){function t(e,t,r,i){return 3600*(0|e)+60*(0|t)+(0|r)+(0|i)/1e3}var r=e.match(/^(\d+):(\d{2})(:\d{2})?\.(\d{3})/);return r?r[3]?t(r[1],r[2],r[3].replace(":",""),r[4]):r[1]>59?t(r[1],r[2],0,r[4]):t(0,r[1],r[2],r[4]):null}(e);if(null===t)throw new Error("Malformed timestamp: "+i);return e=e.replace(/^[^\sa-zA-Z-]+/,""),t}function n(){e=e.replace(/^\s+/,"")}if(n(),t.startTime=a(),n(),"--\x3e"!==e.substr(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+i);e=e.substr(3),n(),t.endTime=a(),n(),function(e,t){var i=new o;s(e,function(e,t){switch(e){case"region":for(var a=r.length-1;a>=0;a--)if(r[a].id===t){i.set(e,r[a].region);break}break;case"vertical":i.alt(e,t,["rl","lr"]);break;case"line":var n=t.split(","),o=n[0];i.integer(e,o),i.percent(e,o)&&i.set("snapToLines",!1),i.alt(e,o,["auto"]),2===n.length&&i.alt("lineAlign",n[1],["start",u,"end"]);break;case"position":n=t.split(","),i.percent(e,n[0]),2===n.length&&i.alt("positionAlign",n[1],["start",u,"end","line-left","line-right","auto"]);break;case"size":i.percent(e,t);break;case"align":i.alt(e,t,["start",u,"end","left","right"])}},/:/,/\s/),t.region=i.get("region",null),t.vertical=i.get("vertical","");var a=i.get("line","auto");"auto"===a&&-1===l.line&&(a=-1),t.line=a,t.lineAlign=i.get("lineAlign","start"),t.snapToLines=i.get("snapToLines",!0),t.size=i.get("size",100),t.align=i.get("align",u);var n=i.get("position","auto");"auto"===n&&50===l.position&&(n="start"===t.align||"left"===t.align?0:"end"===t.align||"right"===t.align?100:50),t.position=n}(e,t)}function f(e){return e.replace(/<br(?: \/)?>/gi,"\n")}n.prototype={parse:function(e){var t=this;function r(){var e=t.buffer,r=0;for(e=f(e);r<e.length&&"\r"!==e[r]&&"\n"!==e[r];)++r;var i=e.substr(0,r);return"\r"===e[r]&&++r,"\n"===e[r]&&++r,t.buffer=e.substr(r),i}function a(e){s(e,function(e,t){e},/:/)}e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));try{var n=void 0;if("INITIAL"===t.state){if(!/\r\n|\n/.test(t.buffer))return this;var o=(n=r()).match(/^()?WEBVTT([ \t].*)?$/);if(!o||!o[0])throw new Error("Malformed WebVTT signature.");t.state="HEADER"}for(var l=!1;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(l?l=!1:n=r(),t.state){case"HEADER":/:/.test(n)?a(n):n||(t.state="ID");continue;case"NOTE":n||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(n)){t.state="NOTE";break}if(!n)continue;if(t.cue=new i.default(0,0,""),t.state="CUE",-1===n.indexOf("--\x3e")){t.cue.id=n;continue}case"CUE":try{d(n,t.cue,t.regionList)}catch(e){t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":var u=-1!==n.indexOf("--\x3e");if(!n||u&&(l=!0)){t.oncue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}t.cue.text&&(t.cue.text+="\n"),t.cue.text+=n;continue;case"BADCUE":n||(t.state="ID");continue}}}catch(e){"CUETEXT"===t.state&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state="INITIAL"===t.state?"BADWEBVTT":"BADCUE"}return this},flush:function(){try{if(this.buffer+=this.decoder.decode(),(this.cue||"HEADER"===this.state)&&(this.buffer+="\n\n",this.parse()),"INITIAL"===this.state)throw new Error("Malformed WebVTT signature.")}catch(e){throw e}return this.onflush&&this.onflush(),this}},t.fixLineBreaks=f,t.default=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sendAddTrackEvent=function(e,t){var r=null;try{r=new window.Event("addtrack")}catch(e){(r=document.createEvent("Event")).initEvent("addtrack",!1,!1)}r.track=e,t.dispatchEvent(r)},t.clearCurrentCues=function(e){if(e&&e.cues)for(;e.cues.length>0;)e.removeCue(e.cues[0])}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(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,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),a=function(e){return e&&e.__esModule?e:{default:e}}(r(3));var n=function(e){function t(e){var r;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);for(var i=arguments.length,a=Array(i>1?i-1:0),n=1;n<i;n++)a[n-1]=arguments[n];var o=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(r=t.__proto__||Object.getPrototypeOf(t)).call.apply(r,[this,e].concat(a)));return o._tickInterval=null,o._tickTimer=null,o._tickCallCount=0,o._boundTick=o.tick.bind(o),o}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,a.default),i(t,[{key:"onHandlerDestroying",value:function(){this.clearNextTick(),this.clearInterval()}},{key:"hasInterval",value:function(){return!!this._tickInterval}},{key:"hasNextTick",value:function(){return!!this._tickTimer}},{key:"setInterval",value:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}(function(e){return!this._tickInterval&&(this._tickInterval=setInterval(this._boundTick,e),!0)})},{key:"clearInterval",value:function(e){function t(){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}(function(){return!!this._tickInterval&&(clearInterval(this._tickInterval),this._tickInterval=null,!0)})},{key:"clearNextTick",value:function(){return!!this._tickTimer&&(clearTimeout(this._tickTimer),this._tickTimer=null,!0)}},{key:"tick",value:function(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&(this.clearNextTick(),this._tickTimer=setTimeout(this._boundTick,0)),this._tickCallCount=0)}},{key:"doTick",value:function(){}}]),t}();t.default=n,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.findFragmentByPDT=function(e,t,r){if(!Array.isArray(e)||!e.length||!Number.isFinite(t))return null;if(t<e[0].programDateTime)return null;if(t>=e[e.length-1].endProgramDateTime)return null;r=r||0;for(var i=0;i<e.length;++i){var a=e[i];if(n(t,r,a))return a}return null},t.findFragmentByPTS=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=e?t[e.sn-t[0].sn+1]:null;if(o&&!a(r,n,o))return o;return i.default.search(t,a.bind(null,r,n))},t.fragmentWithinToleranceTest=a,t.pdtWithinToleranceTest=n;var i=function(e){return e&&e.__esModule?e:{default:e}}(r(9));function a(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments[2],i=Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return r.start+r.duration-i<=e?1:r.start-i>e&&r.start?-1:0}function n(e,t,r){var i=1e3*Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return r.endProgramDateTime-i>e}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.findFirstFragWithCC=n,t.findFragWithCC=function(e,t){return i.default.search(e,function(e){return e.cc<t?1:e.cc>t?-1:0})},t.shouldAlignOnDiscontinuities=o,t.findDiscontinuousReferenceFrag=s,t.adjustPts=l,t.alignStream=function(e,t,r){u(e,r,t),!r.PTSKnown&&t&&d(r,t.details)},t.alignDiscontinuities=u,t.alignPDT=d;var i=function(e){return e&&e.__esModule?e:{default:e}}(r(9)),a=r(0);function n(e,t){for(var r=null,i=0;i<e.length;i+=1){var a=e[i];if(a&&a.cc===t){r=a;break}}return r}function o(e,t,r){var i=!1;return t&&t.details&&r&&(r.endCC>r.startCC||e&&e.cc<r.startCC)&&(i=!0),i}function s(e,t){var r=e.fragments,i=t.fragments;if(i.length&&r.length){var o=n(r,i[0].cc);if(o&&(!o||o.startPTS))return o;a.logger.log("No frag in previous level to align on")}else a.logger.log("No fragments to align")}function l(e,t){t.fragments.forEach(function(t){if(t){var r=t.start+e;t.start=t.startPTS=r,t.endPTS=r+t.duration}}),t.PTSKnown=!0}function u(e,t,r){if(o(e,r,t)){var i=s(r.details,t);i&&(a.logger.log("Adjusting PTS using last level due to CC increase within current level"),l(i.start,t))}}function d(e,t){if(t&&t.fragments.length){if(!e.hasProgramDateTime||!t.hasProgramDateTime)return;var r=t.fragments[0].programDateTime,i=(e.fragments[0].programDateTime-r)/1e3+t.fragments[0].start;Number.isFinite(i)&&(a.logger.log("adjusting PTS using programDateTime delta, sliding:"+i.toFixed(3)),l(i,e))}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default={toString:function(e){for(var t="",r=e.length,i=0;i<r;i++)t+="["+e.start(i).toFixed(3)+","+e.end(i).toFixed(3)+"]";return t}},e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Observer=void 0;var i=function(){function e(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,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),a=r(57);t.Observer=function(e){function t(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,a.EventEmitter),i(t,[{key:"trigger",value:function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];this.emit.apply(this,[e,e].concat(r))}}]),t}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i={BitratesMap:[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],SamplingRateMap:[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],SamplesCoefficients:[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],BytesInSlot:[0,1,1,4],appendFrame:function(e,t,r,i,a){if(!(r+24>t.length)){var n=this.parseHeader(t,r);if(n&&r+n.frameLength<=t.length){var o=i+a*(9e4*n.samplesPerFrame/n.sampleRate),s={unit:t.subarray(r,r+n.frameLength),pts:o,dts:o};return e.config=[],e.channelCount=n.channelCount,e.samplerate=n.sampleRate,e.samples.push(s),e.len+=n.frameLength,{sample:s,length:n.frameLength}}}},parseHeader:function(e,t){var r=e[t+1]>>3&3,a=e[t+1]>>1&3,n=e[t+2]>>4&15,o=e[t+2]>>2&3,s=e[t+2]>>1&1;if(1!==r&&0!==n&&15!==n&&3!==o){var l=3===r?3-a:3===a?3:4,u=1e3*i.BitratesMap[14*l+n-1],d=3===r?0:2===r?1:2,f=i.SamplingRateMap[3*d+o],c=e[t+3]>>6==3?1:2,h=i.SamplesCoefficients[r][a],v=i.BytesInSlot[a],g=8*h*v;return{sampleRate:f,channelCount:c,frameLength:parseInt(h*u/f+s,10)*v,samplesPerFrame:g}}},isHeaderPattern:function(e,t){return 255===e[t]&&224==(224&e[t+1])&&0!=(6&e[t+1])},isHeader:function(e,t){return!!(t+1<e.length&&this.isHeaderPattern(e,t))},probe:function(e,t){if(t+1<e.length&&this.isHeaderPattern(e,t)){var r=this.parseHeader(e,t),i=4;r&&r.frameLength&&(i=r.frameLength);var a=t+i;if(a===e.length||a+1<e.length&&this.isHeaderPattern(e,a))return!0}return!1}};t.default=i,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getAudioConfig=o,t.isHeaderPattern=s,t.getHeaderLength=l,t.getFullFrameLength=u,t.isHeader=function(e,t){if(t+1<e.length&&s(e,t))return!0;return!1},t.probe=function(e,t){if(t+1<e.length&&s(e,t)){var r=l(e,t),i=r;t+5<e.length&&(i=u(e,t));var a=t+i;if(a===e.length||a+1<e.length&&s(e,a))return!0}return!1},t.initTrackConfig=function(e,t,r,a,n){if(!e.samplerate){var s=o(t,r,a,n);e.config=s.config,e.samplerate=s.samplerate,e.channelCount=s.channelCount,e.codec=s.codec,e.manifestCodec=s.manifestCodec,i.logger.log("parsed codec:"+e.codec+",rate:"+s.samplerate+",nb channel:"+s.channelCount)}},t.getFrameDuration=d,t.parseFrameHeader=f,t.appendFrame=function(e,t,r,i,a){var n=d(e.samplerate),o=f(t,r,i,a,n);if(o){var s=o.stamp,l=o.headerLength,u=o.frameLength,c={unit:t.subarray(r+l,r+l+u),pts:s,dts:s};return e.samples.push(c),e.len+=u,{sample:c,length:u+l}}return};var i=r(0),a=r(2),n=function(e){return e&&e.__esModule?e:{default:e}}(r(1));r(7);function o(e,t,r,o){var s,l=void 0,u=void 0,d=void 0,f=void 0,c=navigator.userAgent.toLowerCase(),h=o,v=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];if(l=1+((192&t[r+2])>>>6),!((s=(60&t[r+2])>>>2)>v.length-1))return d=(1&t[r+2])<<2,d|=(192&t[r+3])>>>6,i.logger.log("manifest codec:"+o+",ADTS data:type:"+l+",sampleingIndex:"+s+"["+v[s]+"Hz],channelConfig:"+d),/firefox/i.test(c)?s>=6?(l=5,f=new Array(4),u=s-3):(l=2,f=new Array(2),u=s):-1!==c.indexOf("android")?(l=2,f=new Array(2),u=s):(l=5,f=new Array(4),o&&(-1!==o.indexOf("mp4a.40.29")||-1!==o.indexOf("mp4a.40.5"))||!o&&s>=6?u=s-3:((o&&-1!==o.indexOf("mp4a.40.2")&&(s>=6&&1===d||/vivaldi/i.test(c))||!o&&1===d)&&(l=2,f=new Array(2)),u=s)),f[0]=l<<3,f[0]|=(14&s)>>1,f[1]|=(1&s)<<7,f[1]|=d<<3,5===l&&(f[1]|=(14&u)>>1,f[2]=(1&u)<<7,f[2]|=8,f[3]=0),{config:f,samplerate:v[s],channelCount:d,codec:"mp4a.40."+l,manifestCodec:h};e.trigger(n.default.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+s})}function s(e,t){return 255===e[t]&&240==(246&e[t+1])}function l(e,t){return 1&e[t+1]?7:9}function u(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function d(e){return 9216e4/e}function f(e,t,r,i,a){var n,o=void 0,s=e.length;if(n=l(e,t),o=u(e,t),(o-=n)>0&&t+n+o<=s)return{headerLength:n,frameLength:o,stamp:r+i*a}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(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,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),a=g(r(1)),n=r(2),o=g(r(13)),s=g(r(66)),l=g(r(29)),u=g(r(65)),d=g(r(62)),f=g(r(61)),c=g(r(58)),h=r(7),v=r(0);function g(e){return e&&e.__esModule?e:{default:e}}var p=(0,h.getSelfScope)(),y=void 0;try{y=p.performance.now.bind(p.performance)}catch(e){v.logger.debug("Unable to use Performance API on this environment"),y=p.Date.now}var m=function(){function e(t,r,i,a){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.observer=t,this.typeSupported=r,this.config=i,this.vendor=a}return i(e,[{key:"destroy",value:function(){var e=this.demuxer;e&&e.destroy()}},{key:"push",value:function(e,t,r,i,n,s,l,u,d,f,c,h){var v=this;if(e.byteLength>0&&null!=t&&null!=t.key&&"AES-128"===t.method){var g=this.decrypter;null==g&&(g=this.decrypter=new o.default(this.observer,this.config));var p=y();g.decrypt(e,t.key.buffer,t.iv.buffer,function(e){var o=y();v.observer.trigger(a.default.FRAG_DECRYPTED,{stats:{tstart:p,tdecrypt:o}}),v.pushDecrypted(new Uint8Array(e),t,new Uint8Array(r),i,n,s,l,u,d,f,c,h)})}else this.pushDecrypted(new Uint8Array(e),t,new Uint8Array(r),i,n,s,l,u,d,f,c,h)}},{key:"pushDecrypted",value:function(e,t,r,i,o,h,v,g,p,y,m,b){var E=this.demuxer;if(!E||(v||g)&&!this.probe(e)){for(var _=this.observer,T=this.typeSupported,S=this.config,k=[{demux:u.default,remux:f.default},{demux:l.default,remux:c.default},{demux:s.default,remux:f.default},{demux:d.default,remux:f.default}],R=0,A=k.length;R<A;R++){var w=k[R],O=w.demux.probe;if(O(e)){var L=this.remuxer=new w.remux(_,S,T,this.vendor);E=new w.demux(_,L,S,T),this.probe=O;break}}if(!E)return void _.trigger(a.default.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"});this.demuxer=E}var D=this.remuxer;(v||g)&&(E.resetInitSegment(r,i,o,y),D.resetInitSegment()),v&&(E.resetTimeStamp(b),D.resetTimeStamp(b)),"function"==typeof E.setDecryptData&&E.setDecryptData(t),E.append(e,h,p,m)}}]),e}();t.default=m,e.exports=t.default},function(e,t,r){"use strict";var i,a="object"==typeof Reflect?Reflect:null,n=a&&"function"==typeof a.apply?a.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};i=a&&"function"==typeof a.ownKeys?a.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var o=Number.isNaN||function(e){return e!=e};function s(){s.init.call(this)}e.exports=s,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var l=10;function u(e){return void 0===e._maxListeners?s.defaultMaxListeners:e._maxListeners}function d(e,t,r,i){var a,n,o;if("function"!=typeof r)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof r);if(void 0===(n=e._events)?(n=e._events=Object.create(null),e._eventsCount=0):(void 0!==n.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),n=e._events),o=n[t]),void 0===o)o=n[t]=r,++e._eventsCount;else if("function"==typeof o?o=n[t]=i?[r,o]:[o,r]:i?o.unshift(r):o.push(r),(a=u(e))>0&&o.length>a&&!o.warned){o.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");s.name="MaxListenersExceededWarning",s.emitter=e,s.type=t,s.count=o.length,function(e){console&&console.warn&&console.warn(e)}(s)}return e}function f(e,t,r){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},a=function(){for(var e=[],t=0;t<arguments.length;t++)e.push(arguments[t]);this.fired||(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,n(this.listener,this.target,e))}.bind(i);return a.listener=r,i.wrapFn=a,a}function c(e,t,r){var i=e._events;if(void 0===i)return[];var a=i[t];return void 0===a?[]:"function"==typeof a?r?[a.listener||a]:[a]:r?function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(a):v(a,a.length)}function h(e){var t=this._events;if(void 0!==t){var r=t[e];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function v(e,t){for(var r=new Array(t),i=0;i<t;++i)r[i]=e[i];return r}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return l},set:function(e){if("number"!=typeof e||e<0||o(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");l=e}}),s.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},s.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||o(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},s.prototype.getMaxListeners=function(){return u(this)},s.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var i="error"===e,a=this._events;if(void 0!==a)i=i&&void 0===a.error;else if(!i)return!1;if(i){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var s=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw s.context=o,s}var l=a[e];if(void 0===l)return!1;if("function"==typeof l)n(l,this,t);else{var u=l.length,d=v(l,u);for(r=0;r<u;++r)n(d[r],this,t)}return!0},s.prototype.addListener=function(e,t){return d(this,e,t,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(e,t){return d(this,e,t,!0)},s.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t);return this.on(e,f(this,e,t)),this},s.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t);return this.prependListener(e,f(this,e,t)),this},s.prototype.removeListener=function(e,t){var r,i,a,n,o;if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t);if(void 0===(i=this._events))return this;if(void 0===(r=i[e]))return this;if(r===t||r.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(a=-1,n=r.length-1;n>=0;n--)if(r[n]===t||r[n].listener===t){o=r[n].listener,a=n;break}if(a<0)return this;0===a?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,a),1===r.length&&(i[e]=r[0]),void 0!==i.removeListener&&this.emit("removeListener",e,o||t)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(e){var t,r,i;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[e]),this;if(0===arguments.length){var a,n=Object.keys(r);for(i=0;i<n.length;++i)"removeListener"!==(a=n[i])&&this.removeAllListeners(a);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(void 0!==t)for(i=t.length-1;i>=0;i--)this.removeListener(e,t[i]);return this},s.prototype.listeners=function(e){return c(this,e,!0)},s.prototype.rawListeners=function(e){return c(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):h.call(e,t)},s.prototype.listenerCount=h,s.prototype.eventNames=function(){return this._eventsCount>0?i(this._events):[]}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(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,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),a=(r(25),function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(r(70))),n=c(r(1)),o=c(r(24)),s=r(0),l=r(2),u=r(12),d=r(7),f=r(21);function c(e){return e&&e.__esModule?e:{default:e}}var h=(0,d.getSelfScope)(),v=(0,u.getMediaSource)(),g=function(){function e(t,r){var i=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.hls=t,this.id=r;var u=this.observer=new f.Observer,d=t.config,c=function(e,r){(r=r||{}).frag=i.frag,r.id=i.id,t.trigger(e,r)};u.on(n.default.FRAG_DECRYPTED,c),u.on(n.default.FRAG_PARSING_INIT_SEGMENT,c),u.on(n.default.FRAG_PARSING_DATA,c),u.on(n.default.FRAG_PARSED,c),u.on(n.default.ERROR,c),u.on(n.default.FRAG_PARSING_METADATA,c),u.on(n.default.FRAG_PARSING_USERDATA,c),u.on(n.default.INIT_PTS_FOUND,c);var g={mp4:v.isTypeSupported("video/mp4"),mpeg:v.isTypeSupported("audio/mpeg"),mp3:v.isTypeSupported('audio/mp4; codecs="mp3"')},p=navigator.vendor;if(d.enableWorker&&"undefined"!=typeof Worker){s.logger.log("demuxing in webworker");var y=void 0;try{y=this.w=a(56),this.onwmsg=this.onWorkerMessage.bind(this),y.addEventListener("message",this.onwmsg),y.onerror=function(e){t.trigger(n.default.ERROR,{type:l.ErrorTypes.OTHER_ERROR,details:l.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",err:{message:e.message+" ("+e.filename+":"+e.lineno+")"}})},y.postMessage({cmd:"init",typeSupported:g,vendor:p,id:r,config:JSON.stringify(d)})}catch(e){s.logger.warn("Error in worker:",e),s.logger.error("Error while initializing DemuxerWorker, fallback on DemuxerInline"),y&&h.URL.revokeObjectURL(y.objectURL),this.demuxer=new o.default(u,g,d,p),this.w=void 0}}else this.demuxer=new o.default(u,g,d,p)}return i(e,[{key:"destroy",value:function(){var e=this.w;if(e)e.removeEventListener("message",this.onwmsg),e.terminate(),this.w=null;else{var t=this.demuxer;t&&(t.destroy(),this.demuxer=null)}var r=this.observer;r&&(r.removeAllListeners(),this.observer=null)}},{key:"push",value:function(e,t,r,i,a,n,o,l){var u=this.w,d=Number.isFinite(a.startPTS)?a.startPTS:a.start,f=a.decryptdata,c=this.frag,h=!(c&&a.cc===c.cc),v=!(c&&a.level===c.level),g=c&&a.sn===c.sn+1,p=!v&&g;if(h&&s.logger.log(this.id+":discontinuity detected"),v&&s.logger.log(this.id+":switch detected"),this.frag=a,u)u.postMessage({cmd:"demux",data:e,decryptdata:f,initSegment:t,audioCodec:r,videoCodec:i,timeOffset:d,discontinuity:h,trackSwitch:v,contiguous:p,duration:n,accurateTimeOffset:o,defaultInitPTS:l},e instanceof ArrayBuffer?[e]:[]);else{var y=this.demuxer;y&&y.push(e,f,t,r,i,d,h,v,p,n,o,l)}}},{key:"onWorkerMessage",value:function(e){var t=e.data,r=this.hls;switch(t.event){case"init":h.URL.revokeObjectURL(this.w.objectURL);break;case n.default.FRAG_PARSING_DATA:t.data.data1=new Uint8Array(t.data1),t.data2&&(t.data.data2=new Uint8Array(t.data2));default:t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,r.trigger(t.event,t.data)}}}]),e}();t.default=g,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i={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,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,drac:!0,dvav:!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}};t.isCodecType=function(e,t){var r=i[t];return!!r&&!0===r[e.slice(0,4)]},t.isCodecSupportedInMp4=function(e,t){return window.MediaSource.isTypeSupported((t||"video")+'/mp4;codecs="'+e+'"')}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(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,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),a=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(r(10));var n=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.method=null,this.key=null,this.iv=null,this._uri=null}return i(e,[{key:"uri",get:function(){return!this._uri&&this.reluri&&(this._uri=a.buildAbsoluteURL(this.baseuri,this.reluri,{alwaysNormalize:!0})),this._uri}}]),e}();t.default=n,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(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,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),a=r(0),n=function(e){return e&&e.__esModule?e:{default:e}}(r(1));var o=Math.pow(2,32)-1,s=function(){function e(t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.observer=t,this.remuxer=r}return i(e,[{key:"resetTimeStamp",value:function(e){this.initPTS=e}},{key:"resetInitSegment",value:function(t,r,i,a){if(t&&t.byteLength){var o=this.initData=e.parseInitSegment(t);null==r&&(r="mp4a.40.5"),null==i&&(i="avc1.42e01e");var s={};o.audio&&o.video?s.audiovideo={container:"video/mp4",codec:r+","+i,initSegment:a?t:null}:(o.audio&&(s.audio={container:"audio/mp4",codec:r,initSegment:a?t:null}),o.video&&(s.video={container:"video/mp4",codec:i,initSegment:a?t:null})),this.observer.trigger(n.default.FRAG_PARSING_INIT_SEGMENT,{tracks:s})}else r&&(this.audioCodec=r),i&&(this.videoCodec=i)}},{key:"append",value:function(t,r,i,a){var o=this.initData;o||(this.resetInitSegment(t,this.audioCodec,this.videoCodec,!1),o=this.initData);var s,l=this.initPTS;if(void 0===l){var u=e.getStartDTS(o,t);this.initPTS=l=u-r,this.observer.trigger(n.default.INIT_PTS_FOUND,{initPTS:l})}e.offsetStartDTS(o,t,l),s=e.getStartDTS(o,t),this.remuxer.remux(o.audio,o.video,null,null,s,i,a,t)}},{key:"destroy",value:function(){}}],[{key:"probe",value:function(t){return e.findBox({data:t,start:0,end:Math.min(t.length,16384)},["moof"]).length>0}},{key:"bin2str",value:function(e){return String.fromCharCode.apply(null,e)}},{key:"readUint16",value:function(e,t){e.data&&(t+=e.start,e=e.data);var r=e[t]<<8|e[t+1];return r<0?65536+r:r}},{key:"readUint32",value:function(e,t){e.data&&(t+=e.start,e=e.data);var r=e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3];return r<0?4294967296+r:r}},{key:"writeUint32",value:function(e,t,r){e.data&&(t+=e.start,e=e.data),e[t]=r>>24,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r}},{key:"findBox",value:function(t,r){var i=[],a=void 0,n=void 0,o=void 0,s=void 0,l=void 0,u=void 0,d=void 0;if(t.data?(u=t.start,s=t.end,t=t.data):(u=0,s=t.byteLength),!r.length)return null;for(a=u;a<s;)n=e.readUint32(t,a),o=e.bin2str(t.subarray(a+4,a+8)),d=n>1?a+n:s,o===r[0]&&(1===r.length?i.push({data:t,start:a+8,end:d}):(l=e.findBox({data:t,start:a+8,end:d},r.slice(1))).length&&(i=i.concat(l))),a=d;return i}},{key:"parseSegmentIndex",value:function(t){var r=e.findBox(t,["moov"])[0],i=r?r.end:null,a=0,n=e.findBox(t,["sidx"]),o=void 0;if(!n||!n[0])return null;o=[];var s=(n=n[0]).data[0];a=0===s?8:16;var l=e.readUint32(n,a);a+=4;a+=0===s?8:16,a+=2;var u=n.end+0,d=e.readUint16(n,a);a+=2;for(var f=0;f<d;f++){var c=a,h=e.readUint32(n,c);c+=4;var v=2147483647&h;if(1===(2147483648&h)>>>31)return void console.warn("SIDX has hierarchical references (not supported)");var g=e.readUint32(n,c);c+=4,o.push({referenceSize:v,subsegmentDuration:g,info:{duration:g/l,start:u,end:u+v-1}}),u+=v,a=c+=4}return{earliestPresentationTime:0,timescale:l,version:s,referencesCount:d,references:o,moovEndOffset:i}}},{key:"parseInitSegment",value:function(t){var r=[];return e.findBox(t,["moov","trak"]).forEach(function(t){var i=e.findBox(t,["tkhd"])[0];if(i){var n=i.data[i.start],o=0===n?12:20,s=e.readUint32(i,o),l=e.findBox(t,["mdia","mdhd"])[0];if(l){o=0===(n=l.data[l.start])?12:20;var u=e.readUint32(l,o),d=e.findBox(t,["mdia","hdlr"])[0];if(d){var f={soun:"audio",vide:"video"}[e.bin2str(d.data.subarray(d.start+8,d.start+12))];if(f){var c=e.findBox(t,["mdia","minf","stbl","stsd"]);if(c.length){c=c[0];var h=e.bin2str(c.data.subarray(c.start+12,c.start+16));a.logger.log("MP4Demuxer:"+f+":"+h+" found")}r[s]={timescale:u,type:f},r[f]={timescale:u,id:s}}}}}}),r}},{key:"getStartDTS",value:function(t,r){var i,a,n=void 0;return n=e.findBox(r,["moof","traf"]),i=[].concat.apply([],n.map(function(r){return e.findBox(r,["tfhd"]).map(function(i){var a,n;return a=e.readUint32(i,4),n=t[a].timescale||9e4,e.findBox(r,["tfdt"]).map(function(t){var r,i=void 0;return r=t.data[t.start],i=e.readUint32(t,4),1===r&&(i*=Math.pow(2,32),i+=e.readUint32(t,8)),i})[0]/n})})),a=Math.min.apply(null,i),isFinite(a)?a:0}},{key:"offsetStartDTS",value:function(t,r,i){e.findBox(r,["moof","traf"]).map(function(r){return e.findBox(r,["tfhd"]).map(function(a){var n=e.readUint32(a,4),s=t[n].timescale||9e4;e.findBox(r,["tfdt"]).map(function(t){var r=t.data[t.start],a=e.readUint32(t,4);if(0===r)e.writeUint32(t,4,a-i*s);else{a*=Math.pow(2,32),a+=e.readUint32(t,8),a-=i*s,a=Math.max(a,0);var n=Math.floor(a/(o+1)),l=Math.floor(a%(o+1));e.writeUint32(t,4,n),e.writeUint32(t,8,l)}})})})}}]),e}();t.default=s,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(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,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),a=d(r(1)),n=d(r(3)),o=r(2),s=r(0),l=d(r(29)),u=d(r(76));function d(e){return e&&e.__esModule?e:{default:e}}var f=window.performance,c={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},h={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"},v=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var r=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,a.default.MANIFEST_LOADING,a.default.LEVEL_LOADING,a.default.AUDIO_TRACK_LOADING,a.default.SUBTITLE_TRACK_LOADING));return r.loaders={},r}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,n.default),i(t,[{key:"createInternalLoader",value:function(e){var t=this.hls.config,r=t.pLoader,i=t.loader,a=new(r||i)(t);return e.loader=a,this.loaders[e.type]=a,a}},{key:"getInternalLoader",value:function(e){return this.loaders[e.type]}},{key:"resetInternalLoader",value:function(e){this.loaders[e]&&delete this.loaders[e]}},{key:"destroyInternalLoaders",value:function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}}},{key:"destroy",value:function(){this.destroyInternalLoaders(),function e(t,r,i){null===t&&(t=Function.prototype);var a=Object.getOwnPropertyDescriptor(t,r);if(void 0===a){var n=Object.getPrototypeOf(t);return null===n?void 0:e(n,r,i)}if("value"in a)return a.value;var o=a.get;return void 0!==o?o.call(i):void 0}(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"destroy",this).call(this)}},{key:"onManifestLoading",value:function(e){this.load(e.url,{type:c.MANIFEST,level:0,id:null})}},{key:"onLevelLoading",value:function(e){this.load(e.url,{type:c.LEVEL,level:e.level,id:e.id})}},{key:"onAudioTrackLoading",value:function(e){this.load(e.url,{type:c.AUDIO_TRACK,level:null,id:e.id})}},{key:"onSubtitleTrackLoading",value:function(e){this.load(e.url,{type:c.SUBTITLE_TRACK,level:null,id:e.id})}},{key:"load",value:function(e,t){var r=this.hls.config;s.logger.debug("Loading playlist of type "+t.type+", level: "+t.level+", id: "+t.id);var i=this.getInternalLoader(t);if(i){var a=i.context;if(a&&a.url===e)return s.logger.trace("playlist request ongoing"),!1;s.logger.warn("aborting previous loader for type: "+t.type),i.abort()}var n=void 0,o=void 0,l=void 0,u=void 0;switch(t.type){case c.MANIFEST:n=r.manifestLoadingMaxRetry,o=r.manifestLoadingTimeOut,l=r.manifestLoadingRetryDelay,u=r.manifestLoadingMaxRetryTimeout;break;case c.LEVEL:n=0,o=r.levelLoadingTimeOut;break;default:n=r.levelLoadingMaxRetry,o=r.levelLoadingTimeOut,l=r.levelLoadingRetryDelay,u=r.levelLoadingMaxRetryTimeout}i=this.createInternalLoader(t),t.url=e,t.responseType=t.responseType||"";var d={timeout:o,maxRetry:n,retryDelay:l,maxRetryDelay:u},f={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};return s.logger.debug("Calling internal loader delegate for URL: "+e),i.load(t,d,f),!0}},{key:"loadsuccess",value:function(e,t,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;if(r.isSidxRequest)return this._handleSidxRequest(e,r),void this._handlePlaylistLoaded(e,t,r,i);this.resetInternalLoader(r.type);var a=e.data;t.tload=f.now(),0===a.indexOf("#EXTM3U")?a.indexOf("#EXTINF:")>0||a.indexOf("#EXT-X-TARGETDURATION:")>0?this._handleTrackOrLevelPlaylist(e,t,r,i):this._handleMasterPlaylist(e,t,r,i):this._handleManifestParsingError(e,r,"no EXTM3U delimiter",i)}},{key:"loaderror",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this._handleNetworkError(t,r,!1,e)}},{key:"loadtimeout",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this._handleNetworkError(t,r,!0)}},{key:"_handleMasterPlaylist",value:function(e,r,i,n){var o=this.hls,l=e.data,d=t.getResponseUrl(e,i),f=u.default.parseMasterPlaylist(l,d);if(f.length){var c=f.map(function(e){return{id:e.attrs.AUDIO,codec:e.audioCodec}}),h=u.default.parseMasterPlaylistMedia(l,d,"AUDIO",c),v=u.default.parseMasterPlaylistMedia(l,d,"SUBTITLES");if(h.length){var g=!1;h.forEach(function(e){e.url||(g=!0)}),!1===g&&f[0].audioCodec&&!f[0].attrs.AUDIO&&(s.logger.log("audio codec signaled in quality level, but no embedded audio track signaled, create one"),h.unshift({type:"main",name:"main"}))}o.trigger(a.default.MANIFEST_LOADED,{levels:f,audioTracks:h,subtitles:v,url:d,stats:r,networkDetails:n})}else this._handleManifestParsingError(e,i,"no level found in manifest",n)}},{key:"_handleTrackOrLevelPlaylist",value:function(e,r,i,n){var o=this.hls,s=i.id,l=i.level,d=i.type,h=t.getResponseUrl(e,i),v=Number.isFinite(s)?s:0,g=Number.isFinite(l)?l:v,p=t.mapContextToLevelType(i),y=u.default.parseLevelPlaylist(e.data,h,g,p,v);if(y.tload=r.tload,d===c.MANIFEST){var m={url:h,details:y};o.trigger(a.default.MANIFEST_LOADED,{levels:[m],audioTracks:[],url:h,stats:r,networkDetails:n})}if(r.tparsed=f.now(),y.needSidxRanges){var b=y.initSegment.url;this.load(b,{isSidxRequest:!0,type:d,level:l,levelDetails:y,id:s,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer"})}else i.levelDetails=y,this._handlePlaylistLoaded(e,r,i,n)}},{key:"_handleSidxRequest",value:function(e,t){var r=l.default.parseSegmentIndex(new Uint8Array(e.data));if(r){var i=r.references,a=t.levelDetails;i.forEach(function(e,t){var r=e.info,i=a.fragments[t];0===i.byteRange.length&&(i.rawByteRange=String(1+r.end-r.start)+"@"+String(r.start))}),a.initSegment.rawByteRange=String(r.moovEndOffset)+"@0"}}},{key:"_handleManifestParsingError",value:function(e,t,r,i){this.hls.trigger(a.default.ERROR,{type:o.ErrorTypes.NETWORK_ERROR,details:o.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:!0,url:e.url,reason:r,networkDetails:i})}},{key:"_handleNetworkError",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;s.logger.info("A network error occured while loading a "+e.type+"-type playlist");var n=void 0,l=void 0,u=this.getInternalLoader(e);switch(e.type){case c.MANIFEST:n=r?o.ErrorDetails.MANIFEST_LOAD_TIMEOUT:o.ErrorDetails.MANIFEST_LOAD_ERROR,l=!0;break;case c.LEVEL:n=r?o.ErrorDetails.LEVEL_LOAD_TIMEOUT:o.ErrorDetails.LEVEL_LOAD_ERROR,l=!1;break;case c.AUDIO_TRACK:n=r?o.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:o.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,l=!1;break;default:l=!1}u&&(u.abort(),this.resetInternalLoader(e.type));var d={type:o.ErrorTypes.NETWORK_ERROR,details:n,fatal:l,url:u.url,loader:u,context:e,networkDetails:t};i&&(d.response=i),this.hls.trigger(a.default.ERROR,d)}},{key:"_handlePlaylistLoaded",value:function(e,r,i,n){var o=i.type,s=i.level,l=i.id,u=i.levelDetails;if(u.targetduration)if(t.canHaveQualityLevels(i.type))this.hls.trigger(a.default.LEVEL_LOADED,{details:u,level:s||0,id:l||0,stats:r,networkDetails:n});else switch(o){case c.AUDIO_TRACK:this.hls.trigger(a.default.AUDIO_TRACK_LOADED,{details:u,id:l,stats:r,networkDetails:n});break;case c.SUBTITLE_TRACK:this.hls.trigger(a.default.SUBTITLE_TRACK_LOADED,{details:u,id:l,stats:r,networkDetails:n})}else this._handleManifestParsingError(e,i,"invalid target duration",n)}}],[{key:"canHaveQualityLevels",value:function(e){return e!==c.AUDIO_TRACK&&e!==c.SUBTITLE_TRACK}},{key:"mapContextToLevelType",value:function(e){switch(e.type){case c.AUDIO_TRACK:return h.AUDIO;case c.SUBTITLE_TRACK:return h.SUBTITLE;default:return h.MAIN}}},{key:"getResponseUrl",value:function(e,t){var r=e.url;return void 0!==r&&0!==r.indexOf("data:")||(r=t.url),r}},{key:"ContextType",get:function(){return c}},{key:"LevelType",get:function(){return h}}]),t}();t.default=v,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i={getBrowserVersion:function(){var e=navigator.userAgent;if(e.toLowerCase().indexOf("mobile")>-1)return"Unknown";if(e.indexOf("Firefox")>-1)return"Firefox "+e.match(/firefox\/[\d.]+/gi)[0].match(/[\d]+/)[0];if(e.indexOf("Edge")>-1)return"Edge "+e.match(/edge\/[\d.]+/gi)[0].match(/[\d]+/)[0];if(e.indexOf("rv:11")>-1)return"IE 11";if(e.indexOf("Opera")>-1||e.indexOf("OPR")>-1){if(e.indexOf("Opera")>-1)return"Opera "+e.match(/opera\/[\d.]+/gi)[0].match(/[\d]+/)[0];if(e.indexOf("OPR")>-1)return"Opera "+e.match(/opr\/[\d.]+/gi)[0].match(/[\d]+/)[0]}else{if(e.indexOf("Chrome")>-1)return"Chrome "+e.match(/chrome\/[\d.]+/gi)[0].match(/[\d]+/)[0];if(e.indexOf("Safari")>-1)return"Safari "+e.match(/safari\/[\d.]+/gi)[0].match(/[\d]+/)[0];if(!(e.indexOf("MSIE")>-1||e.indexOf("Trident")>-1))return"Unknown";if(e.indexOf("MSIE")>-1)return"IE "+e.match(/msie [\d.]+/gi)[0].match(/[\d]+/)[0];if(e.indexOf("Trident")>-1){var t=e.match(/trident\/[\d.]+/gi)[0].match(/[\d]+/)[0];return"IE "+(parseInt(t)+4)}}}};t.default=i,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i="undefined"!=typeof window&&window.navigator&&window.navigator.requestMediaKeySystemAccess?window.navigator.requestMediaKeySystemAccess.bind(window.navigator):null;t.requestMediaKeySystemAccess=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(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,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),a=l(r(3)),n=l(r(1)),o=r(2),s=r(0);function l(e){return e&&e.__esModule?e:{default:e}}var u=window.XMLHttpRequest,d="com.widevine.alpha",f="com.microsoft.playready",c=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var r=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n.default.MEDIA_ATTACHED,n.default.MANIFEST_PARSED));return r._widevineLicenseUrl=e.config.widevineLicenseUrl,r._licenseXhrSetup=e.config.licenseXhrSetup,r._emeEnabled=e.config.emeEnabled,r._requestMediaKeySystemAccess=e.config.requestMediaKeySystemAccessFunc,r._mediaKeysList=[],r._media=null,r._hasSetMediaKeys=!1,r._isMediaEncrypted=!1,r._requestLicenseFailureCount=0,r}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,a.default),i(t,[{key:"getLicenseServerUrl",value:function(e){var t=void 0;switch(e){case d:t=this._widevineLicenseUrl;break;default:t=null}return t||(s.logger.error('No license server URL configured for key-system "'+e+'"'),this.hls.trigger(n.default.ERROR,{type:o.ErrorTypes.KEY_SYSTEM_ERROR,details:o.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})),t}},{key:"_attemptKeySystemAccess",value:function(e,t,r){var i=this,a=function(e,t,r){switch(e){case d:return function(e,t,r){var i={videoCapabilities:[]};return t.forEach(function(e){i.videoCapabilities.push({contentType:'video/mp4; codecs="'+e+'"'})}),[i]}(0,r);default:throw Error("Unknown key-system: "+e)}}(e,0,r);a?(s.logger.log("Requesting encrypted media key-system access"),this.requestMediaKeySystemAccess(e,a).then(function(t){i._onMediaKeySystemAccessObtained(e,t)}).catch(function(t){s.logger.error('Failed to obtain key-system "'+e+'" access:',t)})):s.logger.warn("Can not create config for key-system (maybe because platform is not supported):",e)}},{key:"_onMediaKeySystemAccessObtained",value:function(e,t){var r=this;s.logger.log('Access for key-system "'+e+'" obtained');var i={mediaKeys:null,mediaKeysSession:null,mediaKeysSessionInitialized:!1,mediaKeySystemAccess:t,mediaKeySystemDomain:e};this._mediaKeysList.push(i),t.createMediaKeys().then(function(t){i.mediaKeys=t,s.logger.log('Media-keys created for key-system "'+e+'"'),r._onMediaKeysCreated()}).catch(function(e){s.logger.error("Failed to create media-keys:",e)})}},{key:"_onMediaKeysCreated",value:function(){var e=this;this._mediaKeysList.forEach(function(t){t.mediaKeysSession||(t.mediaKeysSession=t.mediaKeys.createSession(),e._onNewMediaKeySession(t.mediaKeysSession))})}},{key:"_onNewMediaKeySession",value:function(e){var t=this;s.logger.log("New key-system session "+e.sessionId),e.addEventListener("message",function(r){t._onKeySessionMessage(e,r.message)},!1)}},{key:"_onKeySessionMessage",value:function(e,t){s.logger.log("Got EME message event, creating license request"),this._requestLicense(t,function(t){s.logger.log("Received license data, updating key-session"),e.update(t)})}},{key:"_onMediaEncrypted",value:function(e,t){s.logger.log('Media is encrypted using "'+e+'" init data type'),this._isMediaEncrypted=!0,this._mediaEncryptionInitDataType=e,this._mediaEncryptionInitData=t,this._attemptSetMediaKeys(),this._generateRequestWithPreferredKeySession()}},{key:"_attemptSetMediaKeys",value:function(){if(!this._hasSetMediaKeys){var e=this._mediaKeysList[0];if(!e||!e.mediaKeys)return s.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),void this.hls.trigger(n.default.ERROR,{type:o.ErrorTypes.KEY_SYSTEM_ERROR,details:o.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});s.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(e.mediaKeys),this._hasSetMediaKeys=!0}}},{key:"_generateRequestWithPreferredKeySession",value:function(){var e=this,t=this._mediaKeysList[0];if(!t)return s.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),void this.hls.trigger(n.default.ERROR,{type:o.ErrorTypes.KEY_SYSTEM_ERROR,details:o.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});if(t.mediaKeysSessionInitialized)s.logger.warn("Key-Session already initialized but requested again");else{var r=t.mediaKeysSession;r||(s.logger.error("Fatal: Media is encrypted but no key-session existing"),this.hls.trigger(n.default.ERROR,{type:o.ErrorTypes.KEY_SYSTEM_ERROR,details:o.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0}));var i=this._mediaEncryptionInitDataType,a=this._mediaEncryptionInitData;s.logger.log('Generating key-session request for "'+i+'" init data type'),t.mediaKeysSessionInitialized=!0,r.generateRequest(i,a).then(function(){s.logger.debug("Key-session generation succeeded")}).catch(function(t){s.logger.error("Error generating key-session request:",t),e.hls.trigger(n.default.ERROR,{type:o.ErrorTypes.KEY_SYSTEM_ERROR,details:o.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})})}}},{key:"_createLicenseXhr",value:function(e,t,r){var i=new u,a=this._licenseXhrSetup;try{if(a)try{a(i,e)}catch(t){i.open("POST",e,!0),a(i,e)}i.readyState||i.open("POST",e,!0)}catch(e){return s.logger.error("Error setting up key-system license XHR",e),void this.hls.trigger(n.default.ERROR,{type:o.ErrorTypes.KEY_SYSTEM_ERROR,details:o.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}return i.responseType="arraybuffer",i.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,i,e,t,r),i}},{key:"_onLicenseRequestReadyStageChange",value:function(e,t,r,i){switch(e.readyState){case 4:if(200===e.status)this._requestLicenseFailureCount=0,s.logger.log("License request succeeded"),i(e.response);else{if(s.logger.error("License Request XHR failed ("+t+"). Status: "+e.status+" ("+e.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount<=3){var a=3-this._requestLicenseFailureCount+1;return s.logger.warn("Retrying license request, "+a+" attempts left"),void this._requestLicense(r,i)}this.hls.trigger(n.default.ERROR,{type:o.ErrorTypes.KEY_SYSTEM_ERROR,details:o.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}}}},{key:"_generateLicenseRequestChallenge",value:function(e,t){var r=void 0;return e.mediaKeySystemDomain===f?s.logger.error("PlayReady is not supported (yet)"):e.mediaKeySystemDomain===d?r=t:s.logger.error("Unsupported key-system:",e.mediaKeySystemDomain),r}},{key:"_requestLicense",value:function(e,t){s.logger.log("Requesting content license for key-system");var r=this._mediaKeysList[0];if(!r)return s.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),void this.hls.trigger(n.default.ERROR,{type:o.ErrorTypes.KEY_SYSTEM_ERROR,details:o.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});var i=this.getLicenseServerUrl(r.mediaKeySystemDomain),a=this._createLicenseXhr(i,e,t);s.logger.log("Sending license request to URL: "+i),a.send(this._generateLicenseRequestChallenge(r,e))}},{key:"onMediaAttached",value:function(e){var t=this;if(this._emeEnabled){var r=e.media;this._media=r,r.addEventListener("encrypted",function(e){t._onMediaEncrypted(e.initDataType,e.initData)})}}},{key:"onManifestParsed",value:function(e){if(this._emeEnabled){var t=e.levels.map(function(e){return e.audioCodec}),r=e.levels.map(function(e){return e.videoCodec});this._attemptKeySystemAccess(d,t,r)}}},{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}]),t}();t.default=c,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SubtitleStreamController=void 0;var i=function(){function e(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,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),a=h(r(1)),n=r(0),o=h(r(13)),s=r(4),l=r(18),u=r(6),d=r(11),f=h(d),c=r(5);function h(e){return e&&e.__esModule?e:{default:e}}var v=window.performance;t.SubtitleStreamController=function(e){function t(e,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var i=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,a.default.MEDIA_ATTACHED,a.default.MEDIA_DETACHING,a.default.ERROR,a.default.KEY_LOADED,a.default.FRAG_LOADED,a.default.SUBTITLE_TRACKS_UPDATED,a.default.SUBTITLE_TRACK_SWITCH,a.default.SUBTITLE_TRACK_LOADED,a.default.SUBTITLE_FRAG_PROCESSED,a.default.LEVEL_UPDATED));return i.fragmentTracker=r,i.config=e.config,i.state=d.State.STOPPED,i.tracks=[],i.tracksBuffered=[],i.currentTrackId=-1,i.decrypter=new o.default(e,e.config),i.lastAVStart=0,i._onMediaSeeking=i.onMediaSeeking.bind(i),i}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,f.default),i(t,[{key:"onSubtitleFragProcessed",value:function(e){var t=e.frag,r=e.success;if(this.fragPrevious=t,this.state=d.State.IDLE,r){var i=this.tracksBuffered[this.currentTrackId];if(i){for(var a=void 0,n=t.start,o=0;o<i.length;o++)if(n>=i[o].start&&n<=i[o].end){a=i[o];break}var s=t.start+t.duration;a?a.end=s:(a={start:n,end:s},i.push(a))}}}},{key:"onMediaAttached",value:function(e){var t=e.media;this.media=t,t.addEventListener("seeking",this._onMediaSeeking),this.state=d.State.IDLE}},{key:"onMediaDetaching",value:function(){this.media.removeEventListener("seeking",this._onMediaSeeking),this.media=null,this.state=d.State.STOPPED}},{key:"onError",value:function(e){var t=e.frag;t&&"subtitle"===t.type&&(this.state=d.State.IDLE)}},{key:"onSubtitleTracksUpdated",value:function(e){var t=this;n.logger.log("subtitle tracks updated"),this.tracksBuffered=[],this.tracks=e.subtitleTracks,this.tracks.forEach(function(e){t.tracksBuffered[e.id]=[]})}},{key:"onSubtitleTrackSwitch",value:function(e){if(this.currentTrackId=e.id,this.tracks&&-1!==this.currentTrackId){var t=this.tracks[this.currentTrackId];t&&t.details&&this.setInterval(500)}else this.clearInterval()}},{key:"onSubtitleTrackLoaded",value:function(e){var t=e.id,r=e.details,i=this.currentTrackId,a=this.tracks,n=a[i];t>=a.length||t!==i||!n||(r.live&&(0,c.mergeSubtitlePlaylists)(n.details,r,this.lastAVStart),n.details=r,this.setInterval(500))}},{key:"onKeyLoaded",value:function(){this.state===d.State.KEY_LOADING&&(this.state=d.State.IDLE)}},{key:"onFragLoaded",value:function(e){var t=this.fragCurrent,r=e.frag.decryptdata,i=e.frag,n=this.hls;if(this.state===d.State.FRAG_LOADING&&t&&"subtitle"===e.frag.type&&t.sn===e.frag.sn&&e.payload.byteLength>0&&r&&r.key&&"AES-128"===r.method){var o=v.now();this.decrypter.decrypt(e.payload,r.key.buffer,r.iv.buffer,function(e){var t=v.now();n.trigger(a.default.FRAG_DECRYPTED,{frag:i,payload:e,stats:{tstart:o,tdecrypt:t}})})}}},{key:"onLevelUpdated",value:function(e){var t=e.details.fragments;this.lastAVStart=t.length?t[0].start:0}},{key:"doTick",value:function(){if(this.media)switch(this.state){case d.State.IDLE:var e=this.config,t=this.currentTrackId,r=this.fragmentTracker,i=this.media,o=this.tracks;if(!o||!o[t]||!o[t].details)break;var f=e.maxBufferHole,c=e.maxFragLookUpTolerance,h=Math.min(e.maxBufferLength,e.maxMaxBufferLength),v=s.BufferHelper.bufferedInfo(this._getBuffered(),i.currentTime,f),g=v.end,p=v.len,y=o[t].details,m=y.fragments,b=m.length,E=m[b-1].start+m[b-1].duration;if(p>h)return;var _=void 0,T=this.fragPrevious;g<E?(T&&y.hasProgramDateTime&&(_=(0,l.findFragmentByPDT)(m,T.endProgramDateTime,c)),_||(_=(0,l.findFragmentByPTS)(T,m,g,c))):_=m[b-1],_&&_.encrypted?(n.logger.log("Loading key for "+_.sn),this.state=d.State.KEY_LOADING,this.hls.trigger(a.default.KEY_LOADING,{frag:_})):_&&r.getState(_)===u.FragmentState.NOT_LOADED&&(this.fragCurrent=_,this.state=d.State.FRAG_LOADING,this.hls.trigger(a.default.FRAG_LOADING,{frag:_}))}else this.state=d.State.IDLE}},{key:"stopLoad",value:function(){this.lastAVStart=0,function e(t,r,i){null===t&&(t=Function.prototype);var a=Object.getOwnPropertyDescriptor(t,r);if(void 0===a){var n=Object.getPrototypeOf(t);return null===n?void 0:e(n,r,i)}if("value"in a)return a.value;var o=a.get;return void 0!==o?o.call(i):void 0}(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"stopLoad",this).call(this)}},{key:"_getBuffered",value:function(){return this.tracksBuffered[this.currentTrackId]||[]}},{key:"onMediaSeeking",value:function(){this.fragPrevious=null}}]),t}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(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,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),a=l(r(1)),n=l(r(3)),o=r(0),s=r(5);function l(e){return e&&e.__esModule?e:{default:e}}var u=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var r=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,a.default.MEDIA_ATTACHED,a.default.MEDIA_DETACHING,a.default.MANIFEST_LOADED,a.default.SUBTITLE_TRACK_LOADED));return r.tracks=[],r.trackId=-1,r.media=null,r.stopped=!0,r.subtitleDisplay=!0,r}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,n.default),i(t,[{key:"destroy",value:function(){n.default.prototype.destroy.call(this)}},{key:"onMediaAttached",value:function(e){var t=this;this.media=e.media,this.media&&(this.queuedDefaultTrack&&(this.subtitleTrack=this.queuedDefaultTrack,delete this.queuedDefaultTrack),this.trackChangeListener=this._onTextTracksChanged.bind(this),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.subtitlePollingInterval=setInterval(function(){t.trackChangeListener()},500):this.media.textTracks.addEventListener("change",this.trackChangeListener))}},{key:"onMediaDetaching",value:function(){this.media&&(this.useTextTrackPolling?clearInterval(this.subtitlePollingInterval):this.media.textTracks.removeEventListener("change",this.trackChangeListener),this.media=null)}},{key:"onManifestLoaded",value:function(e){var t=this,r=e.subtitles||[];this.tracks=r,this.hls.trigger(a.default.SUBTITLE_TRACKS_UPDATED,{subtitleTracks:r}),r.forEach(function(e){e.default&&(t.media?t.subtitleTrack=e.id:t.queuedDefaultTrack=e.id)})}},{key:"onSubtitleTrackLoaded",value:function(e){var t=this,r=e.id,i=e.details,a=this.trackId,n=this.tracks,l=n[a];if(r>=n.length||r!==a||!l||this.stopped)this._clearReloadTimer();else if(o.logger.log("subtitle track "+r+" loaded"),i.live){var u=(0,s.computeReloadInterval)(l.details,i,e.stats.trequest);o.logger.log("Reloading live subtitle playlist in "+u+"ms"),this.timer=setTimeout(function(){t._loadCurrentTrack()},u)}else this._clearReloadTimer()}},{key:"startLoad",value:function(){this.stopped=!1,this._loadCurrentTrack()}},{key:"stopLoad",value:function(){this.stopped=!0,this._clearReloadTimer()}},{key:"_clearReloadTimer",value:function(){this.timer&&(clearTimeout(this.timer),this.timer=null)}},{key:"_loadCurrentTrack",value:function(){var e=this.trackId,t=this.tracks,r=this.hls,i=t[e];e<0||!i||i.details&&!i.details.live||(o.logger.log("Loading subtitle track "+e),r.trigger(a.default.SUBTITLE_TRACK_LOADING,{url:i.url,id:e}))}},{key:"_toggleTrackModes",value:function(e){var t=this.media,r=this.subtitleDisplay,i=this.trackId;if(t){var a=d(t.textTracks);if(-1===e)[].slice.call(a).forEach(function(e){e.mode="disabled"});else{var n=a[i];n&&(n.mode="disabled")}var o=a[e];o&&(o.mode=r?"showing":"hidden")}}},{key:"_setSubtitleTrackInternal",value:function(e){var t=this.hls,r=this.tracks;!Number.isFinite(e)||e<-1||e>=r.length||(this.trackId=e,o.logger.log("Switching to subtitle track "+e),t.trigger(a.default.SUBTITLE_TRACK_SWITCH,{id:e}),this._loadCurrentTrack())}},{key:"_onTextTracksChanged",value:function(){if(this.media){for(var e=-1,t=d(this.media.textTracks),r=0;r<t.length;r++)if("hidden"===t[r].mode)e=r;else if("showing"===t[r].mode){e=r;break}this.subtitleTrack=e}}},{key:"subtitleTracks",get:function(){return this.tracks}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(e){this.trackId!==e&&(this._toggleTrackModes(e),this._setSubtitleTrackInternal(e))}}]),t}();function d(e){for(var t=[],r=0;r<e.length;r++){var i=e[r];"subtitles"===i.kind&&i.label&&t.push(e[r])}return t}t.default=u,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(e){return e&&e.__esModule?e:{default:e}}(r(15)),a=r(8);var n=function(e,t,r){return e.substr(r||0,t.length)===t},o=function(e){for(var t=5381,r=e.length;r;)t=33*t^e.charCodeAt(--r);return(t>>>0).toString()},s={parse:function(e,t,r,s,l,u){var d=(0,a.utf8ArrayToStr)(new Uint8Array(e)).trim().replace(/\r\n|\n\r|\n|\r/g,"\n").split("\n"),f="00:00.000",c=0,h=0,v=0,g=[],p=void 0,y=!0,m=new i.default;m.oncue=function(e){var t=r[s],i=r.ccOffset;t&&t.new&&(void 0!==h?i=r.ccOffset=t.start:function(e,t,r){var i=e[t],a=e[i.prevCC];if(!a||!a.new&&i.new)return e.ccOffset=e.presentationOffset=i.start,void(i.new=!1);for(;a&&a.new;)e.ccOffset+=i.start-a.start,i.new=!1,a=e[(i=a).prevCC];e.presentationOffset=r}(r,s,v)),v&&(i=v-r.presentationOffset),e.startTime+=i-h,e.endTime+=i-h,e.id=o(e.startTime.toString())+o(e.endTime.toString())+o(e.text),e.text=decodeURIComponent(encodeURIComponent(e.text)),e.endTime>0&&g.push(e)},m.onparsingerror=function(e){p=e},m.onflush=function(){p&&u?u(p):l(g)},d.forEach(function(e){if(y){if(n(e,"X-TIMESTAMP-MAP=")){y=!1,e.substr(16).split(",").forEach(function(e){n(e,"LOCAL:")?f=e.substr(6):n(e,"MPEGTS:")&&(c=parseInt(e.substr(7)))});try{t+(9e4*r[s].start||0)<0&&(t+=8589934592),c-=t,h=function(e){var t=parseInt(e.substr(-3)),r=parseInt(e.substr(-6,2)),i=parseInt(e.substr(-9,2)),a=e.length>9?parseInt(e.substr(0,e.indexOf(":"))):0;return Number.isFinite(t)&&Number.isFinite(r)&&Number.isFinite(i)&&Number.isFinite(a)?(t+=1e3*r,t+=6e4*i,t+=36e5*a):-1}(f)/1e3,v=c/9e4,-1===h&&(p=new Error("Malformed X-TIMESTAMP-MAP: "+e))}catch(t){p=new Error("Malformed X-TIMESTAMP-MAP: "+e)}return}""===e&&(y=!1)}m.parse(e+"\n")}),m.flush()}};t.default=s,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(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,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}();var a=function(){function e(t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.timelineController=t,this.trackName=r,this.startTime=null,this.endTime=null,this.screen=null}return i(e,[{key:"dispatchCue",value:function(){null!==this.startTime&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen),this.startTime=null)}},{key:"newCue",value:function(e,t,r){(null===this.startTime||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)}}]),e}();t.default=a,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(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,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}();function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var n={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},o=function(e){var t=e;return n.hasOwnProperty(e)&&(t=n[e]),String.fromCharCode(t)},s=15,l=100,u={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},d={17:2,18:4,21:6,22:8,23:10,19:13,20:15},f={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},c={25:2,26:4,29:6,30:8,31:10,27:13,28:15},h=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],v={verboseFilter:{DATA:3,DEBUG:3,INFO:2,WARNING:2,TEXT:1,ERROR:0},time:null,verboseLevel:0,setTime:function(e){this.time=e},log:function(e,t){this.verboseFilter[e];this.verboseLevel}},g=function(e){for(var t=[],r=0;r<e.length;r++)t.push(e[r].toString(16));return t},p=function(){function e(t,r,i,n,o){a(this,e),this.foreground=t||"white",this.underline=r||!1,this.italics=i||!1,this.background=n||"black",this.flash=o||!1}return i(e,[{key:"reset",value:function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}},{key:"setStyles",value:function(e){for(var t=["foreground","underline","italics","background","flash"],r=0;r<t.length;r++){var i=t[r];e.hasOwnProperty(i)&&(this[i]=e[i])}}},{key:"isDefault",value:function(){return"white"===this.foreground&&!this.underline&&!this.italics&&"black"===this.background&&!this.flash}},{key:"equals",value:function(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash}},{key:"copy",value:function(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash}},{key:"toString",value:function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}}]),e}(),y=function(){function e(t,r,i,n,o,s){a(this,e),this.uchar=t||" ",this.penState=new p(r,i,n,o,s)}return i(e,[{key:"reset",value:function(){this.uchar=" ",this.penState.reset()}},{key:"setChar",value:function(e,t){this.uchar=e,this.penState.copy(t)}},{key:"setPenState",value:function(e){this.penState.copy(e)}},{key:"equals",value:function(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)}},{key:"copy",value:function(e){this.uchar=e.uchar,this.penState.copy(e.penState)}},{key:"isEmpty",value:function(){return" "===this.uchar&&this.penState.isDefault()}}]),e}(),m=function(){function e(){a(this,e),this.chars=[];for(var t=0;t<l;t++)this.chars.push(new y);this.pos=0,this.currPenState=new p}return i(e,[{key:"equals",value:function(e){for(var t=!0,r=0;r<l;r++)if(!this.chars[r].equals(e.chars[r])){t=!1;break}return t}},{key:"copy",value:function(e){for(var t=0;t<l;t++)this.chars[t].copy(e.chars[t])}},{key:"isEmpty",value:function(){for(var e=!0,t=0;t<l;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e}},{key:"setCursor",value:function(e){this.pos!==e&&(this.pos=e),this.pos<0?(v.log("ERROR","Negative cursor position "+this.pos),this.pos=0):this.pos>l&&(v.log("ERROR","Too large cursor position "+this.pos),this.pos=l)}},{key:"moveCursor",value:function(e){var t=this.pos+e;if(e>1)for(var r=this.pos+1;r<t+1;r++)this.chars[r].setPenState(this.currPenState);this.setCursor(t)}},{key:"backSpace",value:function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}},{key:"insertChar",value:function(e){e>=144&&this.backSpace();var t=o(e);this.pos>=l?v.log("ERROR","Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!"):(this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1))}},{key:"clearFromPos",value:function(e){var t=void 0;for(t=e;t<l;t++)this.chars[t].reset()}},{key:"clear",value:function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}},{key:"clearToEndOfRow",value:function(){this.clearFromPos(this.pos)}},{key:"getTextString",value:function(){for(var e=[],t=!0,r=0;r<l;r++){var i=this.chars[r].uchar;" "!==i&&(t=!1),e.push(i)}return t?"":e.join("")}},{key:"setPenStyles",value:function(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)}}]),e}(),b=function(){function e(){a(this,e),this.rows=[];for(var t=0;t<s;t++)this.rows.push(new m);this.currRow=s-1,this.nrRollUpRows=null,this.reset()}return i(e,[{key:"reset",value:function(){for(var e=0;e<s;e++)this.rows[e].clear();this.currRow=s-1}},{key:"equals",value:function(e){for(var t=!0,r=0;r<s;r++)if(!this.rows[r].equals(e.rows[r])){t=!1;break}return t}},{key:"copy",value:function(e){for(var t=0;t<s;t++)this.rows[t].copy(e.rows[t])}},{key:"isEmpty",value:function(){for(var e=!0,t=0;t<s;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e}},{key:"backSpace",value:function(){this.rows[this.currRow].backSpace()}},{key:"clearToEndOfRow",value:function(){this.rows[this.currRow].clearToEndOfRow()}},{key:"insertChar",value:function(e){this.rows[this.currRow].insertChar(e)}},{key:"setPen",value:function(e){this.rows[this.currRow].setPenStyles(e)}},{key:"moveCursor",value:function(e){this.rows[this.currRow].moveCursor(e)}},{key:"setCursor",value:function(e){v.log("INFO","setCursor: "+e),this.rows[this.currRow].setCursor(e)}},{key:"setPAC",value:function(e){v.log("INFO","pacData = "+JSON.stringify(e));var t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(var r=0;r<s;r++)this.rows[r].clear();var i=this.currRow+1-this.nrRollUpRows,a=this.lastOutputScreen;if(a){var n=a.rows[i].cueStartTime;if(n&&n<v.time)for(var o=0;o<this.nrRollUpRows;o++)this.rows[t-this.nrRollUpRows+o+1].copy(a.rows[i+o])}}this.currRow=t;var l=this.rows[this.currRow];if(null!==e.indent){var u=e.indent,d=Math.max(u-1,0);l.setCursor(e.indent),e.color=l.chars[d].penState.foreground}var f={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(f)}},{key:"setBkgData",value:function(e){v.log("INFO","bkgData = "+JSON.stringify(e)),this.backSpace(),this.setPen(e),this.insertChar(32)}},{key:"setRollUpRows",value:function(e){this.nrRollUpRows=e}},{key:"rollUp",value:function(){if(null!==this.nrRollUpRows){v.log("TEXT",this.getDisplayText());var e=this.currRow+1-this.nrRollUpRows,t=this.rows.splice(e,1)[0];t.clear(),this.rows.splice(this.currRow,0,t),v.log("INFO","Rolling up")}else v.log("DEBUG","roll_up but nrRollUpRows not set yet")}},{key:"getDisplayText",value:function(e){e=e||!1;for(var t=[],r="",i=-1,a=0;a<s;a++){var n=this.rows[a].getTextString();n&&(i=a+1,e?t.push("Row "+i+": '"+n+"'"):t.push(n.trim()))}return t.length>0&&(r=e?"["+t.join(" | ")+"]":t.join("\n")),r}},{key:"getTextAndFormat",value:function(){return this.rows}}]),e}(),E=function(){function e(t,r){a(this,e),this.chNr=t,this.outputFilter=r,this.mode=null,this.verbose=0,this.displayedMemory=new b,this.nonDisplayedMemory=new b,this.lastOutputScreen=new b,this.currRollUpRow=this.displayedMemory.rows[s-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}return i(e,[{key:"reset",value:function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.currRollUpRow=this.displayedMemory.rows[s-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.lastCueEndTime=null}},{key:"getHandler",value:function(){return this.outputFilter}},{key:"setHandler",value:function(e){this.outputFilter=e}},{key:"setPAC",value:function(e){this.writeScreen.setPAC(e)}},{key:"setBkgData",value:function(e){this.writeScreen.setBkgData(e)}},{key:"setMode",value:function(e){e!==this.mode&&(this.mode=e,v.log("INFO","MODE="+e),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)}},{key:"insertChars",value:function(e){for(var t=0;t<e.length;t++)this.writeScreen.insertChar(e[t]);var r=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";v.log("INFO",r+": "+this.writeScreen.getDisplayText(!0)),"MODE_PAINT-ON"!==this.mode&&"MODE_ROLL-UP"!==this.mode||(v.log("TEXT","DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())}},{key:"ccRCL",value:function(){v.log("INFO","RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}},{key:"ccBS",value:function(){v.log("INFO","BS - BackSpace"),"MODE_TEXT"!==this.mode&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}},{key:"ccAOF",value:function(){}},{key:"ccAON",value:function(){}},{key:"ccDER",value:function(){v.log("INFO","DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}},{key:"ccRU",value:function(e){v.log("INFO","RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)}},{key:"ccFON",value:function(){v.log("INFO","FON - Flash On"),this.writeScreen.setPen({flash:!0})}},{key:"ccRDC",value:function(){v.log("INFO","RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}},{key:"ccTR",value:function(){v.log("INFO","TR"),this.setMode("MODE_TEXT")}},{key:"ccRTD",value:function(){v.log("INFO","RTD"),this.setMode("MODE_TEXT")}},{key:"ccEDM",value:function(){v.log("INFO","EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}},{key:"ccCR",value:function(){v.log("CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}},{key:"ccENM",value:function(){v.log("INFO","ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}},{key:"ccEOC",value:function(){if(v.log("INFO","EOC - End Of Caption"),"MODE_POP-ON"===this.mode){var e=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,v.log("TEXT","DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)}},{key:"ccTO",value:function(e){v.log("INFO","TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)}},{key:"ccMIDROW",value:function(e){var t={flash:!1};if(t.underline=e%2==1,t.italics=e>=46,t.italics)t.foreground="white";else{var r=Math.floor(e/2)-16;t.foreground=["white","green","blue","cyan","red","yellow","magenta"][r]}v.log("INFO","MIDROW: "+JSON.stringify(t)),this.writeScreen.setPen(t)}},{key:"outputDataUpdate",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=v.time;null!==t&&this.outputFilter&&(null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue&&(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),!0===e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue()),this.cueStartTime=this.displayedMemory.isEmpty()?null:t):this.cueStartTime=t,this.lastOutputScreen.copy(this.displayedMemory))}},{key:"cueSplitAtTime",value:function(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))}}]),e}(),_=function(){function e(t,r,i){a(this,e),this.field=t||1,this.outputs=[r,i],this.channels=[new E(1,r),new E(2,i)],this.currChNr=-1,this.lastCmdA=null,this.lastCmdB=null,this.bufferedData=[],this.startTime=null,this.lastTime=null,this.dataCounters={padding:0,char:0,cmd:0,other:0}}return i(e,[{key:"getHandler",value:function(e){return this.channels[e].getHandler()}},{key:"setHandler",value:function(e,t){this.channels[e].setHandler(t)}},{key:"addData",value:function(e,t){var r=void 0,i=void 0,a=void 0,n=!1;this.lastTime=e,v.setTime(e);for(var o=0;o<t.length;o+=2)if(i=127&t[o],a=127&t[o+1],0!==i||0!==a){if(v.log("DATA","["+g([t[o],t[o+1]])+"] -> ("+g([i,a])+")"),(r=this.parseCmd(i,a))||(r=this.parseMidrow(i,a)),r||(r=this.parsePAC(i,a)),r||(r=this.parseBackgroundAttributes(i,a)),!r)if(n=this.parseChars(i,a))if(this.currChNr&&this.currChNr>=0)this.channels[this.currChNr-1].insertChars(n);else v.log("WARNING","No channel found yet. TEXT-MODE?");r?this.dataCounters.cmd+=2:n?this.dataCounters.char+=2:(this.dataCounters.other+=2,v.log("WARNING","Couldn't parse cleaned data "+g([i,a])+" orig: "+g([t[o],t[o+1]])))}else this.dataCounters.padding+=2}},{key:"parseCmd",value:function(e,t){var r=null;if(!((20===e||28===e)&&t>=32&&t<=47)&&!((23===e||31===e)&&t>=33&&t<=35))return!1;if(e===this.lastCmdA&&t===this.lastCmdB)return this.lastCmdA=null,this.lastCmdB=null,v.log("DEBUG","Repeated command ("+g([e,t])+") is dropped"),!0;r=20===e||23===e?1:2;var i=this.channels[r-1];return 20===e||28===e?32===t?i.ccRCL():33===t?i.ccBS():34===t?i.ccAOF():35===t?i.ccAON():36===t?i.ccDER():37===t?i.ccRU(2):38===t?i.ccRU(3):39===t?i.ccRU(4):40===t?i.ccFON():41===t?i.ccRDC():42===t?i.ccTR():43===t?i.ccRTD():44===t?i.ccEDM():45===t?i.ccCR():46===t?i.ccENM():47===t&&i.ccEOC():i.ccTO(t-32),this.lastCmdA=e,this.lastCmdB=t,this.currChNr=r,!0}},{key:"parseMidrow",value:function(e,t){var r=null;return(17===e||25===e)&&t>=32&&t<=47&&((r=17===e?1:2)!==this.currChNr?(v.log("ERROR","Mismatch channel in midrow parsing"),!1):(this.channels[r-1].ccMIDROW(t),v.log("DEBUG","MIDROW ("+g([e,t])+")"),!0))}},{key:"parsePAC",value:function(e,t){var r,i=null;if(!((e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127)&&!((16===e||24===e)&&t>=64&&t<=95))return!1;if(e===this.lastCmdA&&t===this.lastCmdB)return this.lastCmdA=null,this.lastCmdB=null,!0;r=e<=23?1:2,i=t>=64&&t<=95?1===r?u[e]:f[e]:1===r?d[e]:c[e];var a=this.interpretPAC(i,t);return this.channels[r-1].setPAC(a),this.lastCmdA=e,this.lastCmdB=t,this.currChNr=r,!0}},{key:"interpretPAC",value:function(e,t){var r=t,i={color:null,italics:!1,indent:null,underline:!1,row:e};return r=t>95?t-96:t-64,i.underline=1==(1&r),r<=13?i.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(i.italics=!0,i.color="white"):i.indent=4*Math.floor((r-16)/2),i}},{key:"parseChars",value:function(e,t){var r=null,i=null,a=null;if(e>=25?(r=2,a=e-8):(r=1,a=e),a>=17&&a<=19){var n=t;n=17===a?t+80:18===a?t+112:t+144,v.log("INFO","Special char '"+o(n)+"' in channel "+r),i=[n]}else e>=32&&e<=127&&(i=0===t?[e]:[e,t]);if(i){var s=g(i);v.log("DEBUG","Char codes = "+s.join(",")),this.lastCmdA=null,this.lastCmdB=null}return i}},{key:"parseBackgroundAttributes",value:function(e,t){var r,i=void 0,a=void 0;return((16===e||24===e)&&t>=32&&t<=47||(23===e||31===e)&&t>=45&&t<=47)&&(i={},16===e||24===e?(a=Math.floor((t-32)/2),i.background=h[a],t%2==1&&(i.background=i.background+"_semi")):45===t?i.background="transparent":(i.foreground="black",47===t&&(i.underline=!0)),r=e<24?1:2,this.channels[r-1].setBkgData(i),this.lastCmdA=null,this.lastCmdB=null,!0)}},{key:"reset",value:function(){for(var e=0;e<this.channels.length;e++)this.channels[e]&&this.channels[e].reset();this.lastCmdA=null,this.lastCmdB=null}},{key:"cueSplitAtTime",value:function(e){for(var t=0;t<this.channels.length;t++)this.channels[t]&&this.channels[t].cueSplitAtTime(e)}}]),e}();t.default=_,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(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,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),a=f(r(1)),n=f(r(3)),o=f(r(38)),s=f(r(37)),l=f(r(36)),u=r(0),d=r(16);function f(e){return e&&e.__esModule?e:{default:e}}function c(e,t){return e&&e.label===t.name&&!(e.textTrack1||e.textTrack2)}function h(e,t,r,i){return Math.min(t,i)-Math.max(e,r)}var v=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var r=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,a.default.MEDIA_ATTACHING,a.default.MEDIA_DETACHING,a.default.FRAG_PARSING_USERDATA,a.default.FRAG_DECRYPTED,a.default.MANIFEST_LOADING,a.default.MANIFEST_LOADED,a.default.FRAG_LOADED,a.default.LEVEL_SWITCHING,a.default.INIT_PTS_FOUND));if(r.hls=e,r.config=e.config,r.enabled=!0,r.Cues=e.config.cueHandler,r.textTracks=[],r.tracks=[],r.unparsedVttFrags=[],r.initPTS=[],r.cueRanges=[],r.captionsTracks={},r.captionsProperties={textTrack1:{label:r.config.captionsTextTrack1Label,languageCode:r.config.captionsTextTrack1LanguageCode},textTrack2:{label:r.config.captionsTextTrack2Label,languageCode:r.config.captionsTextTrack2LanguageCode}},r.config.enableCEA708Captions){var i=new s.default(r,"textTrack1"),n=new s.default(r,"textTrack2");r.cea608Parser=new o.default(0,i,n)}return r}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,n.default),i(t,[{key:"addCues",value:function(e,t,r,i){for(var a=this.cueRanges,n=!1,o=a.length;o--;){var s=a[o],l=h(s[0],s[1],t,r);if(l>=0&&(s[0]=Math.min(s[0],t),s[1]=Math.max(s[1],r),n=!0,l/(r-t)>.5))return}n||a.push([t,r]),this.Cues.newCue(this.captionsTracks[e],t,r,i)}},{key:"onInitPtsFound",value:function(e){var t=this;if("main"===e.id&&(this.initPTS[e.frag.cc]=e.initPTS),this.unparsedVttFrags.length){var r=this.unparsedVttFrags;this.unparsedVttFrags=[],r.forEach(function(e){t.onFragLoaded(e)})}}},{key:"getExistingTrack",value:function(e){var t=this.media;if(t)for(var r=0;r<t.textTracks.length;r++){var i=t.textTracks[r];if(i[e])return i}return null}},{key:"createCaptionsTrack",value:function(e){var t=this.captionsProperties[e],r=t.label,i=t.languageCode,a=this.captionsTracks;if(!a[e]){var n=this.getExistingTrack(e);if(n)a[e]=n,(0,d.clearCurrentCues)(a[e]),(0,d.sendAddTrackEvent)(a[e],this.media);else{var o=this.createTextTrack("captions",r,i);o&&(o[e]=!0,a[e]=o)}}}},{key:"createTextTrack",value:function(e,t,r){var i=this.media;if(i)return i.addTextTrack(e,t,r)}},{key:"destroy",value:function(){n.default.prototype.destroy.call(this)}},{key:"onMediaAttaching",value:function(e){this.media=e.media,this._cleanTracks()}},{key:"onMediaDetaching",value:function(){var e=this.captionsTracks;Object.keys(e).forEach(function(t){(0,d.clearCurrentCues)(e[t]),delete e[t]})}},{key:"onManifestLoading",value:function(){this.lastSn=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}},this._cleanTracks()}},{key:"_cleanTracks",value:function(){var e=this.media;if(e){var t=e.textTracks;if(t)for(var r=0;r<t.length;r++)(0,d.clearCurrentCues)(t[r])}}},{key:"onManifestLoaded",value:function(e){var t=this;if(this.textTracks=[],this.unparsedVttFrags=this.unparsedVttFrags||[],this.initPTS=[],this.cueRanges=[],this.config.enableWebVTT){this.tracks=e.subtitles||[];var r=this.media?this.media.textTracks:[];this.tracks.forEach(function(e,i){var a=void 0;if(i<r.length){for(var n=null,o=0;o<r.length;o++)if(c(r[o],e)){n=r[o];break}n&&(a=n)}a||(a=t.createTextTrack("subtitles",e.name,e.lang)),e.default?a.mode=t.hls.subtitleDisplay?"showing":"hidden":a.mode="disabled",t.textTracks.push(a)})}}},{key:"onLevelSwitching",value:function(){this.enabled="NONE"!==this.hls.currentLevel.closedCaptions}},{key:"onFragLoaded",value:function(e){var t=e.frag,r=e.payload;if("main"===t.type){var i=t.sn;if(i!==this.lastSn+1){var n=this.cea608Parser;n&&n.reset()}this.lastSn=i}else if("subtitle"===t.type)if(r.byteLength){if(!Number.isFinite(this.initPTS[t.cc]))return this.unparsedVttFrags.push(e),void(this.initPTS.length&&this.hls.trigger(a.default.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t}));var o=t.decryptdata;null!=o&&null!=o.key&&"AES-128"===o.method||this._parseVTTs(t,r)}else this.hls.trigger(a.default.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t})}},{key:"_parseVTTs",value:function(e,t){var r=this.vttCCs;r[e.cc]||(r[e.cc]={start:e.start,prevCC:this.prevCC,new:!0},this.prevCC=e.cc);var i=this.textTracks,n=this.hls;l.default.parse(t,this.initPTS[e.cc],r,e.cc,function(t){var r=i[e.level];"disabled"!==r.mode?(t.forEach(function(e){if(!r.cues.getCueById(e.id))try{r.addCue(e)}catch(i){var t=new window.TextTrackCue(e.startTime,e.endTime,e.text);t.id=e.id,r.addCue(t)}}),n.trigger(a.default.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})):n.trigger(a.default.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e})},function(t){u.logger.log("Failed to parse VTT cue: "+t),n.trigger(a.default.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e})})}},{key:"onFragDecrypted",value:function(e){var t=e.payload,r=e.frag;if("subtitle"===r.type){if(!Number.isFinite(this.initPTS[r.cc]))return void this.unparsedVttFrags.push(e);this._parseVTTs(r,t)}}},{key:"onFragParsingUserdata",value:function(e){if(this.enabled&&this.config.enableCEA708Captions)for(var t=0;t<e.samples.length;t++){var r=this.extractCea608Data(e.samples[t].bytes);this.cea608Parser.addData(e.samples[t].pts,r)}}},{key:"extractCea608Data",value:function(e){for(var t=31&e[0],r=2,i=void 0,a=void 0,n=void 0,o=[],s=0;s<t;s++)i=e[r++],a=127&e[r++],n=127&e[r++],0===a&&0===n||0!=(4&i)&&0===(3&i)&&(o.push(a),o.push(n));return o}}]),t}();t.default=v,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(){if("undefined"!=typeof window&&window.VTTCue)return window.VTTCue;var e="auto",t={"":!0,lr:!0,rl:!0},r={start:!0,middle:!0,end:!0,left:!0,right:!0};function i(e){return"string"==typeof e&&(!!r[e.toLowerCase()]&&e.toLowerCase())}function a(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)e[i]=r[i]}return e}function n(r,n,o){var s=this,l=function(){if("undefined"!=typeof navigator)return/MSIE\s8\.0/.test(navigator.userAgent)}(),u={};l?s=document.createElement("custom"):u.enumerable=!0,s.hasBeenReset=!1;var d="",f=!1,c=r,h=n,v=o,g=null,p="",y=!0,m="auto",b="start",E=50,_="middle",T=50,S="middle";if(Object.defineProperty(s,"id",a({},u,{get:function(){return d},set:function(e){d=""+e}})),Object.defineProperty(s,"pauseOnExit",a({},u,{get:function(){return f},set:function(e){f=!!e}})),Object.defineProperty(s,"startTime",a({},u,{get:function(){return c},set:function(e){if("number"!=typeof e)throw new TypeError("Start time must be set to a number.");c=e,this.hasBeenReset=!0}})),Object.defineProperty(s,"endTime",a({},u,{get:function(){return h},set:function(e){if("number"!=typeof e)throw new TypeError("End time must be set to a number.");h=e,this.hasBeenReset=!0}})),Object.defineProperty(s,"text",a({},u,{get:function(){return v},set:function(e){v=""+e,this.hasBeenReset=!0}})),Object.defineProperty(s,"region",a({},u,{get:function(){return g},set:function(e){g=e,this.hasBeenReset=!0}})),Object.defineProperty(s,"vertical",a({},u,{get:function(){return p},set:function(e){var r=function(e){return"string"==typeof e&&!!t[e.toLowerCase()]&&e.toLowerCase()}(e);if(!1===r)throw new SyntaxError("An invalid or illegal string was specified.");p=r,this.hasBeenReset=!0}})),Object.defineProperty(s,"snapToLines",a({},u,{get:function(){return y},set:function(e){y=!!e,this.hasBeenReset=!0}})),Object.defineProperty(s,"line",a({},u,{get:function(){return m},set:function(t){if("number"!=typeof t&&t!==e)throw new SyntaxError("An invalid number or illegal string was specified.");m=t,this.hasBeenReset=!0}})),Object.defineProperty(s,"lineAlign",a({},u,{get:function(){return b},set:function(e){var t=i(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");b=t,this.hasBeenReset=!0}})),Object.defineProperty(s,"position",a({},u,{get:function(){return E},set:function(e){if(e<0||e>100)throw new Error("Position must be between 0 and 100.");E=e,this.hasBeenReset=!0}})),Object.defineProperty(s,"positionAlign",a({},u,{get:function(){return _},set:function(e){var t=i(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");_=t,this.hasBeenReset=!0}})),Object.defineProperty(s,"size",a({},u,{get:function(){return T},set:function(e){if(e<0||e>100)throw new Error("Size must be between 0 and 100.");T=e,this.hasBeenReset=!0}})),Object.defineProperty(s,"align",a({},u,{get:function(){return S},set:function(e){var t=i(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");S=t,this.hasBeenReset=!0}})),s.displayState=void 0,l)return s}return n.prototype.getCueAsHTML=function(){return window.WebVTT.convertCueToDOMTree(window,this.text)},n}(),e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.newCue=function(e,t,r,a){for(var n=void 0,o=void 0,s=void 0,l=void 0,u=void 0,d=window.VTTCue||window.TextTrackCue,f=0;f<a.rows.length;f++)if(n=a.rows[f],s=!0,l=0,u="",!n.isEmpty()){for(var c=0;c<n.chars.length;c++)n.chars[c].uchar.match(/\s/)&&s?l++:(u+=n.chars[c].uchar,s=!1);n.cueStartTime=t,t===r&&(r+=1e-4),o=new d(t,r,(0,i.fixLineBreaks)(u.trim())),l>=16?l--:l++,navigator.userAgent.match(/Firefox\//)?o.line=f+1:o.line=f>7?f-2:f+1,o.align="left",o.position=Math.max(0,Math.min(100,l/32*100+(navigator.userAgent.match(/Firefox\//)?50:0))),e.addCue(o)}};var i=r(15)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(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,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),a=y(r(9)),n=r(4),o=y(r(26)),s=y(r(1)),l=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(r(5)),u=y(r(20)),d=r(2),f=r(0),c=r(19),h=r(6),v=y(r(14)),g=r(11),p=y(g);function y(e){return e&&e.__esModule?e:{default:e}}var m=window.performance,b=function(e){function t(e,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var i=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,s.default.MEDIA_ATTACHED,s.default.MEDIA_DETACHING,s.default.AUDIO_TRACKS_UPDATED,s.default.AUDIO_TRACK_SWITCHING,s.default.AUDIO_TRACK_LOADED,s.default.KEY_LOADED,s.default.FRAG_LOADED,s.default.FRAG_PARSING_INIT_SEGMENT,s.default.FRAG_PARSING_DATA,s.default.FRAG_PARSED,s.default.ERROR,s.default.BUFFER_RESET,s.default.BUFFER_CREATED,s.default.BUFFER_APPENDED,s.default.BUFFER_FLUSHED,s.default.INIT_PTS_FOUND));return i.fragmentTracker=r,i.config=e.config,i.audioCodecSwap=!1,i._state=g.State.STOPPED,i.initPTS=[],i.waitingFragment=null,i.videoTrackCC=null,i}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,p.default),i(t,[{key:"onInitPtsFound",value:function(e){var t=e.id,r=e.frag.cc,i=e.initPTS;"main"===t&&(this.initPTS[r]=i,this.videoTrackCC=r,f.logger.log("InitPTS for cc: "+r+" found from video track: "+i),this.state===g.State.WAITING_INIT_PTS&&this.tick())}},{key:"startLoad",value:function(e){if(this.tracks){var t=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),this.fragLoadError=0,t>0&&-1===e?(f.logger.log("audio:override startPosition with lastCurrentTime @"+t.toFixed(3)),this.state=g.State.IDLE):(this.lastCurrentTime=this.startPosition?this.startPosition:e,this.state=g.State.STARTING),this.nextLoadPosition=this.startPosition=this.lastCurrentTime,this.tick()}else this.startPosition=e,this.state=g.State.STOPPED}},{key:"doTick",value:function(){var e=void 0,t=void 0,r=void 0,i=this.hls,o=i.config;switch(this.state){case g.State.ERROR:case g.State.PAUSED:case g.State.BUFFER_FLUSHING:break;case g.State.STARTING:this.state=g.State.WAITING_TRACK,this.loadedmetadata=!1;break;case g.State.IDLE:var l=this.tracks;if(!l)break;if(!this.media&&(this.startFragRequested||!o.startFragPrefetch))break;if(this.loadedmetadata)e=this.media.currentTime;else if(void 0===(e=this.nextLoadPosition))break;var u=this.mediaBuffer?this.mediaBuffer:this.media,d=this.videoBuffer?this.videoBuffer:this.media,v=n.BufferHelper.bufferInfo(u,e,o.maxBufferHole),p=n.BufferHelper.bufferInfo(d,e,o.maxBufferHole),y=v.len,b=v.end,E=this.fragPrevious,_=Math.min(o.maxBufferLength,o.maxMaxBufferLength),T=Math.max(_,p.len),S=this.audioSwitch,k=this.trackId;if((y<T||S)&&k<l.length){if(void 0===(r=l[k].details)){this.state=g.State.WAITING_TRACK;break}if(!S&&this._streamEnded(v,r))return this.hls.trigger(s.default.BUFFER_EOS,{type:"audio"}),void(this.state=g.State.ENDED);var R=r.fragments,A=R.length,w=R[0].start,O=R[A-1].start+R[A-1].duration,L=void 0;if(S)if(r.live&&!r.PTSKnown)f.logger.log("switching audiotrack, live stream, unknown PTS,load first fragment"),b=0;else if(b=e,r.PTSKnown&&e<w){if(!(v.end>w||v.nextStart))return;f.logger.log("alt audio track ahead of main track, seek to start of alt audio track"),this.media.currentTime=w+.05}if(r.initSegment&&!r.initSegment.data)L=r.initSegment;else if(b<=w){if(L=R[0],null!==this.videoTrackCC&&L.cc!==this.videoTrackCC&&(L=(0,c.findFragWithCC)(R,this.videoTrackCC)),r.live&&L.loadIdx&&L.loadIdx===this.fragLoadIdx){var D=v.nextStart?v.nextStart:w;return f.logger.log("no alt audio available @currentTime:"+this.media.currentTime+", seeking @"+(D+.05)),void(this.media.currentTime=D+.05)}}else{var P=void 0,I=o.maxFragLookUpTolerance,C=E?R[E.sn-R[0].sn+1]:void 0,x=function(e){var t=Math.min(I,e.duration);return e.start+e.duration-t<=b?1:e.start-t>b&&e.start?-1:0};b<O?(b>O-I&&(I=0),P=C&&!x(C)?C:a.default.search(R,x)):P=R[A-1],P&&(L=P,w=P.start,E&&L.level===E.level&&L.sn===E.sn&&(L.sn<r.endSN?(L=R[L.sn+1-r.startSN],f.logger.log("SN just loaded, load next one: "+L.sn)):L=null))}L&&(L.encrypted?(f.logger.log("Loading key for "+L.sn+" of ["+r.startSN+" ,"+r.endSN+"],track "+k),this.state=g.State.KEY_LOADING,i.trigger(s.default.KEY_LOADING,{frag:L})):(f.logger.log("Loading "+L.sn+", cc: "+L.cc+" of ["+r.startSN+" ,"+r.endSN+"],track "+k+", currentTime:"+e+",bufferEnd:"+b.toFixed(3)),this.fragCurrent=L,(S||this.fragmentTracker.getState(L)===h.FragmentState.NOT_LOADED)&&(this.startFragRequested=!0,Number.isFinite(L.sn)&&(this.nextLoadPosition=L.start+L.duration),i.trigger(s.default.FRAG_LOADING,{frag:L}),this.state=g.State.FRAG_LOADING)))}break;case g.State.WAITING_TRACK:(t=this.tracks[this.trackId])&&t.details&&(this.state=g.State.IDLE);break;case g.State.FRAG_LOADING_WAITING_RETRY:var M=m.now(),F=this.retryDate,N=(u=this.media)&&u.seeking;(!F||M>=F||N)&&(f.logger.log("audioStreamController: retryDate reached, switch back to IDLE state"),this.state=g.State.IDLE);break;case g.State.WAITING_INIT_PTS:var U=this.videoTrackCC;if(void 0===this.initPTS[U])break;var B=this.waitingFragment;if(B){var G=B.frag.cc;U!==G?(t=this.tracks[this.trackId]).details&&t.details.live&&(f.logger.warn("Waiting fragment CC ("+G+") does not match video track CC ("+U+")"),this.waitingFragment=null,this.state=g.State.IDLE):(this.state=g.State.FRAG_LOADING,this.onFragLoaded(this.waitingFragment),this.waitingFragment=null)}else this.state=g.State.IDLE;break;case g.State.STOPPED:case g.State.FRAG_LOADING:case g.State.PARSING:case g.State.PARSED:case g.State.ENDED:}}},{key:"onMediaAttached",value:function(e){var t=this.media=this.mediaBuffer=e.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),t.addEventListener("seeking",this.onvseeking),t.addEventListener("ended",this.onvended);var r=this.config;this.tracks&&r.autoStartLoad&&this.startLoad(r.startPosition)}},{key:"onMediaDetaching",value:function(){var e=this.media;e&&e.ended&&(f.logger.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),e&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvseeked=this.onvended=null),this.media=this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1,this.stopLoad()}},{key:"onAudioTracksUpdated",value:function(e){f.logger.log("audio tracks updated"),this.tracks=e.audioTracks}},{key:"onAudioTrackSwitching",value:function(e){var t=!!e.url;this.trackId=e.id,this.fragCurrent=null,this.state=g.State.PAUSED,this.waitingFragment=null,t?this.setInterval(100):this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),t&&(this.audioSwitch=!0,this.state=g.State.IDLE),this.tick()}},{key:"onAudioTrackLoaded",value:function(e){var t=e.details,r=e.id,i=this.tracks[r],a=t.totalduration,n=0;if(f.logger.log("track "+r+" loaded ["+t.startSN+","+t.endSN+"],duration:"+a),t.live){var o=i.details;o&&t.fragments.length>0?(l.mergeDetails(o,t),n=t.fragments[0].start,t.PTSKnown?f.logger.log("live audio playlist sliding:"+n.toFixed(3)):f.logger.log("live audio playlist - outdated PTS, unknown sliding")):(t.PTSKnown=!1,f.logger.log("live audio playlist - first load, unknown sliding"))}else t.PTSKnown=!1;if(i.details=t,!this.startFragRequested){if(-1===this.startPosition){var s=t.startTimeOffset;Number.isFinite(s)?(f.logger.log("start time offset found in playlist, adjust startPosition to "+s),this.startPosition=s):this.startPosition=0}this.nextLoadPosition=this.startPosition}this.state===g.State.WAITING_TRACK&&(this.state=g.State.IDLE),this.tick()}},{key:"onKeyLoaded",value:function(){this.state===g.State.KEY_LOADING&&(this.state=g.State.IDLE,this.tick())}},{key:"onFragLoaded",value:function(e){var t=this.fragCurrent,r=e.frag;if(this.state===g.State.FRAG_LOADING&&t&&"audio"===r.type&&r.level===t.level&&r.sn===t.sn){var i=this.tracks[this.trackId],a=i.details,n=a.totalduration,l=t.level,u=t.sn,d=t.cc,c=this.config.defaultAudioCodec||i.audioCodec||"mp4a.40.2",h=this.stats=e.stats;if("initSegment"===u)this.state=g.State.IDLE,h.tparsed=h.tbuffered=m.now(),a.initSegment.data=e.payload,this.hls.trigger(s.default.FRAG_BUFFERED,{stats:h,frag:t,id:"audio"}),this.tick();else{this.state=g.State.PARSING,this.appended=!1,this.demuxer||(this.demuxer=new o.default(this.hls,"audio"));var v=this.initPTS[d],p=a.initSegment?a.initSegment.data:[];if(a.initSegment||void 0!==v){this.pendingBuffering=!0,f.logger.log("Demuxing "+u+" of ["+a.startSN+" ,"+a.endSN+"],track "+l);this.demuxer.push(e.payload,p,c,null,t,n,!1,v)}else f.logger.log("unknown video PTS for continuity counter "+d+", waiting for video PTS before demuxing audio frag "+u+" of ["+a.startSN+" ,"+a.endSN+"],track "+l),this.waitingFragment=e,this.state=g.State.WAITING_INIT_PTS}}this.fragLoadError=0}},{key:"onFragParsingInitSegment",value:function(e){var t=this.fragCurrent,r=e.frag;if(t&&"audio"===e.id&&r.sn===t.sn&&r.level===t.level&&this.state===g.State.PARSING){var i=e.tracks,a=void 0;if(i.video&&delete i.video,a=i.audio){a.levelCodec=a.codec,a.id=e.id,this.hls.trigger(s.default.BUFFER_CODECS,i),f.logger.log("audio track:audio,container:"+a.container+",codecs[level/parsed]=["+a.levelCodec+"/"+a.codec+"]");var n=a.initSegment;if(n){var o={type:"audio",data:n,parent:"audio",content:"initSegment"};this.audioSwitch?this.pendingData=[o]:(this.appended=!0,this.pendingBuffering=!0,this.hls.trigger(s.default.BUFFER_APPENDING,o))}this.tick()}}}},{key:"onFragParsingData",value:function(e){var t=this,r=this.fragCurrent,i=e.frag;if(r&&"audio"===e.id&&"audio"===e.type&&i.sn===r.sn&&i.level===r.level&&this.state===g.State.PARSING){var a=this.trackId,n=this.tracks[a],o=this.hls;Number.isFinite(e.endPTS)||(e.endPTS=e.startPTS+r.duration,e.endDTS=e.startDTS+r.duration),r.addElementaryStream(v.default.ElementaryStreamTypes.AUDIO),f.logger.log("parsed "+e.type+",PTS:["+e.startPTS.toFixed(3)+","+e.endPTS.toFixed(3)+"],DTS:["+e.startDTS.toFixed(3)+"/"+e.endDTS.toFixed(3)+"],nb:"+e.nb),l.updateFragPTSDTS(n.details,r,e.startPTS,e.endPTS);var u=this.audioSwitch,c=this.media,h=!1;if(u&&c)if(c.readyState){var p=c.currentTime;f.logger.log("switching audio track : currentTime:"+p),p>=e.startPTS&&(f.logger.log("switching audio track : flushing all audio"),this.state=g.State.BUFFER_FLUSHING,o.trigger(s.default.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),h=!0,this.audioSwitch=!1,o.trigger(s.default.AUDIO_TRACK_SWITCHED,{id:a}))}else this.audioSwitch=!1,o.trigger(s.default.AUDIO_TRACK_SWITCHED,{id:a});var y=this.pendingData;if(!y)return f.logger.warn("Apparently attempt to enqueue media payload without codec initialization data upfront"),void o.trigger(s.default.ERROR,{type:d.ErrorTypes.MEDIA_ERROR,details:null,fatal:!0});this.audioSwitch||([e.data1,e.data2].forEach(function(t){t&&t.length&&y.push({type:e.type,data:t,parent:"audio",content:"data"})}),!h&&y.length&&(y.forEach(function(e){t.state===g.State.PARSING&&(t.pendingBuffering=!0,t.hls.trigger(s.default.BUFFER_APPENDING,e))}),this.pendingData=[],this.appended=!0)),this.tick()}}},{key:"onFragParsed",value:function(e){var t=this.fragCurrent,r=e.frag;t&&"audio"===e.id&&r.sn===t.sn&&r.level===t.level&&this.state===g.State.PARSING&&(this.stats.tparsed=m.now(),this.state=g.State.PARSED,this._checkAppendedParsed())}},{key:"onBufferReset",value:function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1}},{key:"onBufferCreated",value:function(e){var t=e.tracks.audio;t&&(this.mediaBuffer=t.buffer,this.loadedmetadata=!0),e.tracks.video&&(this.videoBuffer=e.tracks.video.buffer)}},{key:"onBufferAppended",value:function(e){if("audio"===e.parent){var t=this.state;t!==g.State.PARSING&&t!==g.State.PARSED||(this.pendingBuffering=e.pending>0,this._checkAppendedParsed())}}},{key:"_checkAppendedParsed",value:function(){if(!(this.state!==g.State.PARSED||this.appended&&this.pendingBuffering)){var e=this.fragCurrent,t=this.stats,r=this.hls;if(e){this.fragPrevious=e,t.tbuffered=m.now(),r.trigger(s.default.FRAG_BUFFERED,{stats:t,frag:e,id:"audio"});var i=this.mediaBuffer?this.mediaBuffer:this.media;f.logger.log("audio buffered : "+u.default.toString(i.buffered)),this.audioSwitch&&this.appended&&(this.audioSwitch=!1,r.trigger(s.default.AUDIO_TRACK_SWITCHED,{id:this.trackId})),this.state=g.State.IDLE}this.tick()}}},{key:"onError",value:function(e){var t=e.frag;if(!t||"audio"===t.type)switch(e.details){case d.ErrorDetails.FRAG_LOAD_ERROR:case d.ErrorDetails.FRAG_LOAD_TIMEOUT:var r=e.frag;if(r&&"audio"!==r.type)break;if(!e.fatal){var i=this.fragLoadError;i?i++:i=1;var a=this.config;if(i<=a.fragLoadingMaxRetry){this.fragLoadError=i;var o=Math.min(Math.pow(2,i-1)*a.fragLoadingRetryDelay,a.fragLoadingMaxRetryTimeout);f.logger.warn("AudioStreamController: frag loading failed, retry in "+o+" ms"),this.retryDate=m.now()+o,this.state=g.State.FRAG_LOADING_WAITING_RETRY}else f.logger.error("AudioStreamController: "+e.details+" reaches max retry, redispatch as fatal ..."),e.fatal=!0,this.state=g.State.ERROR}break;case d.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case d.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:case d.ErrorDetails.KEY_LOAD_ERROR:case d.ErrorDetails.KEY_LOAD_TIMEOUT:this.state!==g.State.ERROR&&(this.state=e.fatal?g.State.ERROR:g.State.IDLE,f.logger.warn("AudioStreamController: "+e.details+" while loading frag, now switching to "+this.state+" state ..."));break;case d.ErrorDetails.BUFFER_FULL_ERROR:if("audio"===e.parent&&(this.state===g.State.PARSING||this.state===g.State.PARSED)){var l=this.mediaBuffer,u=this.media.currentTime;if(l&&n.BufferHelper.isBuffered(l,u)&&n.BufferHelper.isBuffered(l,u+.5)){var c=this.config;c.maxMaxBufferLength>=c.maxBufferLength&&(c.maxMaxBufferLength/=2,f.logger.warn("AudioStreamController: reduce max buffer length to "+c.maxMaxBufferLength+"s")),this.state=g.State.IDLE}else f.logger.warn("AudioStreamController: buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,this.state=g.State.BUFFER_FLUSHING,this.hls.trigger(s.default.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"})}}}},{key:"onBufferFlushed",value:function(){var e=this,t=this.pendingData;t&&t.length?(f.logger.log("AudioStreamController: appending pending audio data after buffer flushed"),t.forEach(function(t){e.hls.trigger(s.default.BUFFER_APPENDING,t)}),this.appended=!0,this.pendingData=[],this.state=g.State.PARSED):(this.state=g.State.IDLE,this.fragPrevious=null,this.tick())}},{key:"state",set:function(e){if(this.state!==e){var t=this.state;this._state=e,f.logger.log("audio stream:"+t+"->"+e)}},get:function(){return this._state}}]),t}();t.default=b,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(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,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),a=l(r(1)),n=l(r(17)),o=r(0),s=r(2);function l(e){return e&&e.__esModule?e:{default:e}}var u=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var r=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,a.default.MANIFEST_LOADING,a.default.MANIFEST_PARSED,a.default.AUDIO_TRACK_LOADED,a.default.AUDIO_TRACK_SWITCHED,a.default.LEVEL_LOADED,a.default.ERROR));return r._trackId=-1,r._selectDefaultTrack=!0,r.tracks=[],r.trackIdBlacklist=Object.create(null),r.audioGroupId=null,r}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,n.default),i(t,[{key:"onManifestLoading",value:function(){this.tracks=[],this._trackId=-1,this._selectDefaultTrack=!0}},{key:"onManifestParsed",value:function(e){var t=this.tracks=e.audioTracks||[];this.hls.trigger(a.default.AUDIO_TRACKS_UPDATED,{audioTracks:t})}},{key:"onAudioTrackLoaded",value:function(e){if(e.id>=this.tracks.length)o.logger.warn("Invalid audio track id:",e.id);else{if(o.logger.log("audioTrack "+e.id+" loaded"),this.tracks[e.id].details=e.details,e.details.live&&!this.hasInterval()){var t=1e3*e.details.targetduration;this.setInterval(t)}!e.details.live&&this.hasInterval()&&this.clearInterval()}}},{key:"onAudioTrackSwitched",value:function(e){var t=this.tracks[e.id].groupId;t&&this.audioGroupId!==t&&(this.audioGroupId=t)}},{key:"onLevelLoaded",value:function(e){var t=this.hls.levels[e.level];if(t.audioGroupIds){var r=t.audioGroupIds[t.urlId];this.audioGroupId!==r&&(this.audioGroupId=r,this._selectInitialAudioTrack())}}},{key:"onError",value:function(e){e.type===s.ErrorTypes.NETWORK_ERROR&&(e.fatal&&this.clearInterval(),e.details===s.ErrorDetails.AUDIO_TRACK_LOAD_ERROR&&(o.logger.warn("Network failure on audio-track id:",e.context.id),this._handleLoadError()))}},{key:"_setAudioTrack",value:function(e){if(this._trackId===e&&this.tracks[this._trackId].details)o.logger.debug("Same id as current audio-track passed, and track details available -> no-op");else if(e<0||e>=this.tracks.length)o.logger.warn("Invalid id passed to audio-track controller");else{var t=this.tracks[e];o.logger.log("Now switching to audio-track index "+e),this.clearInterval(),this._trackId=e;var r=t.url,i=t.type,n=t.id;this.hls.trigger(a.default.AUDIO_TRACK_SWITCHING,{id:n,type:i,url:r}),this._loadTrackDetailsIfNeeded(t)}}},{key:"doTick",value:function(){this._updateTrack(this._trackId)}},{key:"_selectInitialAudioTrack",value:function(){var e=this,t=this.tracks;if(t.length){var r=this.tracks[this._trackId],i=null;if(r&&(i=r.name),this._selectDefaultTrack){var n=t.filter(function(e){return e.default});n.length?t=n:o.logger.warn("No default audio tracks defined")}var l=!1,u=function(){t.forEach(function(t){l||e.audioGroupId&&t.groupId!==e.audioGroupId||i&&i!==t.name||(e._setAudioTrack(t.id),l=!0)})};u(),l||(i=null,u()),l||(o.logger.error("No track found for running audio group-ID: "+this.audioGroupId),this.hls.trigger(a.default.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))}}},{key:"_needsTrackLoading",value:function(e){var t=e.details,r=e.url;return!(t&&!t.live)&&!!r}},{key:"_loadTrackDetailsIfNeeded",value:function(e){if(this._needsTrackLoading(e)){var t=e.url,r=e.id;o.logger.log("loading audio-track playlist for id: "+r),this.hls.trigger(a.default.AUDIO_TRACK_LOADING,{url:t,id:r})}}},{key:"_updateTrack",value:function(e){if(!(e<0||e>=this.tracks.length)){this.clearInterval(),this._trackId=e,o.logger.log("trying to update audio-track "+e);var t=this.tracks[e];this._loadTrackDetailsIfNeeded(t)}}},{key:"_handleLoadError",value:function(){this.trackIdBlacklist[this._trackId]=!0;var e=this._trackId,t=this.tracks[e],r=t.name,i=t.language,a=t.groupId;o.logger.warn("Loading failed on audio track id: "+e+", group-id: "+a+', name/language: "'+r+'" / "'+i+'"');for(var n=e,s=0;s<this.tracks.length;s++){if(!this.trackIdBlacklist[s])if(this.tracks[s].name===r){n=s;break}}n!==e?(o.logger.log("Attempting audio-track fallback id:",n,"group-id:",this.tracks[n].groupId),this._setAudioTrack(n)):o.logger.warn('No fallback audio-track found for name/language: "'+r+'" / "'+i+'"')}},{key:"audioTracks",get:function(){return this.tracks}},{key:"audioTrack",get:function(){return this._trackId},set:function(e){this._setAudioTrack(e),this._selectDefaultTrack=!1}}]),t}();t.default=u,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(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,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),a=r(0);var n=window,o=n.performance,s=n.XMLHttpRequest,l=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),t&&t.xhrSetup&&(this.xhrSetup=t.xhrSetup)}return i(e,[{key:"destroy",value:function(){this.abort(),this.loader=null}},{key:"abort",value:function(){var e=this.loader;e&&4!==e.readyState&&(this.stats.aborted=!0,e.abort()),window.clearTimeout(this.requestTimeout),this.requestTimeout=null,window.clearTimeout(this.retryTimeout),this.retryTimeout=null}},{key:"load",value:function(e,t,r){this.context=e,this.config=t,this.callbacks=r,this.stats={trequest:o.now(),retry:0},this.retryDelay=t.retryDelay,this.loadInternal()}},{key:"loadInternal",value:function(){var e=void 0,t=this.context;e=this.loader=new s;var r=this.stats;r.tfirst=0,r.loaded=0;var i=this.xhrSetup;try{if(i)try{i(e,t.url)}catch(r){e.open("GET",t.url,!0),i(e,t.url)}e.readyState||e.open("GET",t.url,!0)}catch(r){return void this.callbacks.onError({code:e.status,text:r.message},t,e)}t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,this.requestTimeout=window.setTimeout(this.loadtimeout.bind(this),this.config.timeout),e.send()}},{key:"readystatechange",value:function(e){var t=e.currentTarget,r=t.readyState,i=this.stats,n=this.context,s=this.config;if(!i.aborted&&r>=2)if(window.clearTimeout(this.requestTimeout),0===i.tfirst&&(i.tfirst=Math.max(o.now(),i.trequest)),4===r){var l=t.status;if(l>=200&&l<300){i.tload=Math.max(i.tfirst,o.now());var u=void 0,d=void 0;d="arraybuffer"===n.responseType?(u=t.response).byteLength:(u=t.responseText).length,i.loaded=i.total=d;var f={url:t.responseURL,data:u};this.callbacks.onSuccess(f,i,n,t)}else i.retry>=s.maxRetry||l>=400&&l<499?(a.logger.error(l+" while loading "+n.url),this.callbacks.onError({code:l,text:t.statusText},n,t)):(a.logger.warn(l+" while loading "+n.url+", retrying in "+this.retryDelay+"..."),this.destroy(),this.retryTimeout=window.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,s.maxRetryDelay),i.retry++)}else this.requestTimeout=window.setTimeout(this.loadtimeout.bind(this),s.timeout)}},{key:"loadtimeout",value:function(){a.logger.warn("timeout while loading "+this.context.url),this.callbacks.onTimeout(this.stats,this.context,null)}},{key:"loadprogress",value:function(e){var t=e.currentTarget,r=this.stats;r.loaded=e.loaded,e.lengthComputable&&(r.total=e.total);var i=this.callbacks.onProgress;i&&i(r,this.context,null,t)}}]),e}();t.default=l,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(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,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),a=s(r(1)),n=s(r(3)),o=r(0);function s(e){return e&&e.__esModule?e:{default:e}}var l=window.performance,u=function(e){function t(e){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,a.default.MEDIA_ATTACHING))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,n.default),i(t,[{key:"destroy",value:function(){this.timer&&clearInterval(this.timer),this.isVideoPlaybackQualityAvailable=!1}},{key:"onMediaAttaching",value:function(e){var t=this.hls.config;t.capLevelOnFPSDrop&&("function"==typeof(this.video=e.media instanceof window.HTMLVideoElement?e.media:null).getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),clearInterval(this.timer),this.timer=setInterval(this.checkFPSInterval.bind(this),t.fpsDroppedMonitoringPeriod))}},{key:"checkFPS",value:function(e,t,r){var i=l.now();if(t){if(this.lastTime){var n=i-this.lastTime,s=r-this.lastDroppedFrames,u=t-this.lastDecodedFrames,d=1e3*s/n,f=this.hls;if(f.trigger(a.default.FPS_DROP,{currentDropped:s,currentDecoded:u,totalDroppedFrames:r}),d>0&&s>f.config.fpsDroppedMonitoringThreshold*u){var c=f.currentLevel;o.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+c),c>0&&(-1===f.autoLevelCapping||f.autoLevelCapping>=c)&&(c-=1,f.trigger(a.default.FPS_DROP_LEVEL_CAPPING,{level:c,droppedLevel:f.currentLevel}),f.autoLevelCapping=c,f.streamController.nextLevelSwitch())}}this.lastTime=i,this.lastDroppedFrames=r,this.lastDecodedFrames=t}}},{key:"checkFPSInterval",value:function(){var e=this.video;if(e)if(this.isVideoPlaybackQualityAvailable){var t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}}]),t}();t.default=u,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(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,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),a=o(r(1)),n=o(r(3));function o(e){return e&&e.__esModule?e:{default:e}}var s=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var r=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,a.default.FPS_DROP_LEVEL_CAPPING,a.default.MEDIA_ATTACHING,a.default.MANIFEST_PARSED,a.default.BUFFER_CODECS,a.default.MEDIA_DETACHING));return r.autoLevelCapping=Number.POSITIVE_INFINITY,r.firstLevel=null,r.levels=[],r.media=null,r.restrictedLevels=[],r.timer=null,r}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,n.default),i(t,[{key:"destroy",value:function(){this.hls.config.capLevelToPlayerSize&&(this.media=null,this._stopCapping())}},{key:"onFpsDropLevelCapping",value:function(e){t.isLevelAllowed(e.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(e.droppedLevel)}},{key:"onMediaAttaching",value:function(e){this.media=e.media instanceof window.HTMLVideoElement?e.media:null}},{key:"onManifestParsed",value:function(e){var t=this.hls;this.restrictedLevels=[],this.levels=e.levels,this.firstLevel=e.firstLevel,t.config.capLevelToPlayerSize&&e.video&&this._startCapping()}},{key:"onBufferCodecs",value:function(e){this.hls.config.capLevelToPlayerSize&&e.video&&this._startCapping()}},{key:"onLevelsUpdated",value:function(e){this.levels=e.levels}},{key:"onMediaDetaching",value:function(){this._stopCapping()}},{key:"detectPlayerSize",value:function(){if(this.media){var e=this.levels?this.levels.length:0;if(e){var t=this.hls;t.autoLevelCapping=this.getMaxLevel(e-1),t.autoLevelCapping>this.autoLevelCapping&&t.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}}},{key:"getMaxLevel",value:function(e){var r=this;if(!this.levels)return-1;var i=this.levels.filter(function(i,a){return t.isLevelAllowed(a,r.restrictedLevels)&&a<=e});return t.getMaxLevelByMediaSize(i,this.mediaWidth,this.mediaHeight)}},{key:"_startCapping",value:function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),clearInterval(this.timer),this.timer=setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())}},{key:"_stopCapping",value:function(){this.restrictedLevels=[],this.firstLevel=null,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(this.timer=clearInterval(this.timer),this.timer=null)}},{key:"mediaWidth",get:function(){var e=void 0,r=this.media;return r&&(e=r.width||r.clientWidth||r.offsetWidth,e*=t.contentScaleFactor),e}},{key:"mediaHeight",get:function(){var e=void 0,r=this.media;return r&&(e=r.height||r.clientHeight||r.offsetHeight,e*=t.contentScaleFactor),e}}],[{key:"isLevelAllowed",value:function(e){return-1===(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[]).indexOf(e)}},{key:"getMaxLevelByMediaSize",value:function(e,t,r){if(!e||e&&!e.length)return-1;for(var i=function(e,t){return!t||(e.width!==t.width||e.height!==t.height)},a=e.length-1,n=0;n<e.length;n+=1){var o=e[n];if((o.width>=t||o.height>=r)&&i(o,e[n+1])){a=n;break}}return a}},{key:"contentScaleFactor",get:function(){var e=1;try{e=window.devicePixelRatio}catch(e){}return e}}]),t}();t.default=s,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(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,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),a=l(r(1)),n=l(r(3)),o=r(0),s=r(2);function l(e){return e&&e.__esModule?e:{default:e}}var u=(0,r(12).getMediaSource)(),d=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var r=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,a.default.MEDIA_ATTACHING,a.default.MEDIA_DETACHING,a.default.MANIFEST_PARSED,a.default.BUFFER_RESET,a.default.BUFFER_APPENDING,a.default.BUFFER_CODECS,a.default.BUFFER_EOS,a.default.BUFFER_FLUSHING,a.default.LEVEL_PTS_UPDATED,a.default.LEVEL_UPDATED));return r._msDuration=null,r._levelDuration=null,r._levelTargetDuration=10,r._live=null,r._objectUrl=null,r.bufferCodecEventsExpected=0,r.onsbue=r.onSBUpdateEnd.bind(r),r.onsbe=r.onSBUpdateError.bind(r),r.pendingTracks={},r.tracks={},r}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,n.default),i(t,[{key:"destroy",value:function(){n.default.prototype.destroy.call(this)}},{key:"onLevelPtsUpdated",value:function(e){var t=e.type,r=this.tracks.audio;if("audio"===t&&r&&"audio/mpeg"===r.container){var i=this.sourceBuffer.audio;if(Math.abs(i.timestampOffset-e.start)>.1){var a=i.updating;try{i.abort()}catch(e){o.logger.warn("can not abort audio buffer: "+e)}a?this.audioTimestampOffset=e.start:(o.logger.warn("change mpeg audio timestamp offset from "+i.timestampOffset+" to "+e.start),i.timestampOffset=e.start)}}}},{key:"onManifestParsed",value:function(e){this.bufferCodecEventsExpected=e.altAudio?2:1,o.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")}},{key:"onMediaAttaching",value:function(e){var t=this.media=e.media;if(t){var r=this.mediaSource=new u;this.onmso=this.onMediaSourceOpen.bind(this),this.onmse=this.onMediaSourceEnded.bind(this),this.onmsc=this.onMediaSourceClose.bind(this),r.addEventListener("sourceopen",this.onmso),r.addEventListener("sourceended",this.onmse),r.addEventListener("sourceclose",this.onmsc),t.src=window.URL.createObjectURL(r),this._objectUrl=t.src}}},{key:"onMediaDetaching",value:function(){o.logger.log("media source detaching");var e=this.mediaSource;if(e){if("open"===e.readyState)try{e.endOfStream()}catch(e){o.logger.warn("onMediaDetaching:"+e.message+" while calling endOfStream")}e.removeEventListener("sourceopen",this.onmso),e.removeEventListener("sourceended",this.onmse),e.removeEventListener("sourceclose",this.onmsc),this.media&&(window.URL.revokeObjectURL(this._objectUrl),this.media.src===this._objectUrl?(this.media.removeAttribute("src"),this.media.load()):o.logger.warn("media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.pendingTracks={},this.tracks={},this.sourceBuffer={},this.flushRange=[],this.segments=[],this.appended=0}this.onmso=this.onmse=this.onmsc=null,this.hls.trigger(a.default.MEDIA_DETACHED)}},{key:"onMediaSourceOpen",value:function(){o.logger.log("media source opened"),this.hls.trigger(a.default.MEDIA_ATTACHED,{media:this.media});var e=this.mediaSource;e&&e.removeEventListener("sourceopen",this.onmso),this.checkPendingTracks()}},{key:"checkPendingTracks",value:function(){var e=this.bufferCodecEventsExpected,t=this.pendingTracks,r=Object.keys(t).length;(r&&!e||2===r)&&(this.createSourceBuffers(t),this.pendingTracks={},this.doAppending())}},{key:"onMediaSourceClose",value:function(){o.logger.log("media source closed")}},{key:"onMediaSourceEnded",value:function(){o.logger.log("media source ended")}},{key:"onSBUpdateEnd",value:function(){if(this.audioTimestampOffset){var e=this.sourceBuffer.audio;o.logger.warn("change mpeg audio timestamp offset from "+e.timestampOffset+" to "+this.audioTimestampOffset),e.timestampOffset=this.audioTimestampOffset,delete this.audioTimestampOffset}this._needsFlush&&this.doFlush(),this._needsEos&&this.checkEos(),this.appending=!1;var t=this.parent,r=this.segments.reduce(function(e,r){return r.parent===t?e+1:e},0),i={},n=this.sourceBuffer;for(var s in n)i[s]=n[s].buffered;if(!1===this._paused&&i.video&&i.video.length>0&&i.audio&&i.audio.length>0)if(i.video.end(0)-i.video.start(0)>1&&i.audio.end(0)-i.audio.start(0)>1){var l=Math.max(i.video.start(0),i.audio.start(0));this.media.currentTime=l,this.media.play(),delete this._paused}else{var u=Math.max(i.video.end(0),i.audio.end(0));this.media.currentTime=u,this.media.play()}this.hls.trigger(a.default.BUFFER_APPENDED,{parent:t,pending:r,timeRanges:i}),this._needsFlush||this.doAppending(),this.updateMediaElementDuration(),0===r&&this.flushLiveBackBuffer()}},{key:"onSBUpdateError",value:function(e){o.logger.error("sourceBuffer error:",e),this.hls.trigger(a.default.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1})}},{key:"onBufferReset",value:function(){var e=this.sourceBuffer;for(var t in e){var r=e[t];try{this.mediaSource.removeSourceBuffer(r),r.removeEventListener("updateend",this.onsbue),r.removeEventListener("error",this.onsbe)}catch(e){}}this.sourceBuffer={},this.flushRange=[],this.segments=[],this.appended=0}},{key:"onBufferCodecs",value:function(e){var t=this;Object.keys(e).forEach(function(r){t.pendingTracks[r]=e[r]});var r=this.mediaSource;this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),r&&"open"===r.readyState&&this.checkPendingTracks()}},{key:"createSourceBuffers",value:function(e){var t=this.sourceBuffer,r=this.mediaSource;for(var i in e)if(!t[i]){var n=e[i],l=n.levelCodec||n.codec,d=n.container+";codecs="+l;o.logger.log("creating sourceBuffer("+d+")");try{var f=t[i]=r.addSourceBuffer(d);f.addEventListener("updateend",this.onsbue),f.addEventListener("error",this.onsbe),this.tracks[i]={codec:l,container:n.container},n.buffer=f}catch(e){if(22==e.code){o.logger.log("Found new track, try to rebuild"),this._paused=!1;var c=this.mediaSource=new u;this.onmso=this.onMediaSourceOpen.bind(this),this.onmse=this.onMediaSourceEnded.bind(this),this.onmsc=this.onMediaSourceClose.bind(this);for(var h=0;h<Object.keys(this.tracks).length;h++){var v=this.tracks[Object.keys(this.tracks)[h]];this.pendingTracks[Object.keys(this.tracks)[h]]=v}this.tracks={},this.sourceBuffer={},c.addEventListener("sourceopen",this.onmso),c.addEventListener("sourceended",this.onmse),c.addEventListener("sourceclose",this.onmsc),this.media.src=window.URL.createObjectURL(c),this._objectUrl=media.src}else o.logger.error("error while trying to add sourceBuffer:"+e.message),this.hls.trigger(a.default.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,err:e,mimeType:d})}}this.hls.trigger(a.default.BUFFER_CREATED,{tracks:e})}},{key:"onBufferAppending",value:function(e){this._needsFlush||(this.segments?this.segments.push(e):this.segments=[e],this.doAppending())}},{key:"onBufferAppendFail",value:function(e){o.logger.error("sourceBuffer error:",e.event),this.hls.trigger(a.default.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1})}},{key:"onBufferEos",value:function(e){var t=this.sourceBuffer,r=e.type;for(var i in t)r&&i!==r||t[i].ended||(t[i].ended=!0,o.logger.log(i+" sourceBuffer now EOS"));this.checkEos()}},{key:"checkEos",value:function(){var e=this.sourceBuffer,t=this.mediaSource;if(t&&"open"===t.readyState){for(var r in e){var i=e[r];if(!i.ended)return;if(i.updating)return void(this._needsEos=!0)}o.logger.log("all media data are available, signal endOfStream() to MediaSource and stop loading fragment");try{t.endOfStream()}catch(e){o.logger.warn("exception while calling mediaSource.endOfStream()")}this._needsEos=!1}else this._needsEos=!1}},{key:"onBufferFlushing",value:function(e){this.flushRange.push({start:e.startOffset,end:e.endOffset,type:e.type}),this.flushBufferCounter=0,this.doFlush()}},{key:"flushLiveBackBuffer",value:function(){if(this._live){var e=this.hls.config.liveBackBufferLength;if(isFinite(e)&&!(e<0))for(var t=this.media.currentTime,r=this.sourceBuffer,i=Object.keys(r),a=t-Math.max(e,this._levelTargetDuration),n=i.length-1;n>=0;n--){var o=i[n],s=r[o].buffered;s.length>0&&a>s.start(0)&&this.removeBufferRange(o,r[o],0,a)}}}},{key:"onLevelUpdated",value:function(e){var t=e.details;t.fragments.length>0&&(this._levelDuration=t.totalduration+t.fragments[0].start,this._levelTargetDuration=t.averagetargetduration||t.targetduration||10,this._live=t.live,this.updateMediaElementDuration())}},{key:"updateMediaElementDuration",value:function(){var e,t=this.hls.config;if(null!==this._levelDuration&&this.media&&this.mediaSource&&this.sourceBuffer&&0!==this.media.readyState&&"open"===this.mediaSource.readyState){for(var r in this.sourceBuffer)if(!0===this.sourceBuffer[r].updating)return;e=this.media.duration,null===this._msDuration&&(this._msDuration=this.mediaSource.duration),!0===this._live&&!0===t.liveDurationInfinity?(o.logger.log("Media Source duration is set to Infinity"),this._msDuration=this.mediaSource.duration=1/0):(this._levelDuration>this._msDuration&&this._levelDuration>e||!Number.isFinite(e))&&(o.logger.log("Updating Media Source duration to "+this._levelDuration.toFixed(3)),this._msDuration=this.mediaSource.duration=this._levelDuration)}}},{key:"doFlush",value:function(){for(;this.flushRange.length;){var e=this.flushRange[0];if(!this.flushBuffer(e.start,e.end,e.type))return void(this._needsFlush=!0);this.flushRange.shift(),this.flushBufferCounter=0}if(0===this.flushRange.length){this._needsFlush=!1;var t=0,r=this.sourceBuffer;try{for(var i in r)t+=r[i].buffered.length}catch(e){o.logger.error("error while accessing sourceBuffer.buffered")}this.appended=t,this.hls.trigger(a.default.BUFFER_FLUSHED)}}},{key:"doAppending",value:function(){var e=this.hls,t=this.segments,r=this.sourceBuffer;if(Object.keys(r).length){if(this.media.error)return this.segments=[],void o.logger.error("trying to append although a media error occured, flush segment and abort");if(this.appending)return;if(t&&t.length){var i=t.shift();try{var n=r[i.type];n?n.updating?t.unshift(i):(n.ended=!1,this.parent=i.parent,n.appendBuffer(i.data),this.appendError=0,this.appended++,this.appending=!0):this.onSBUpdateEnd()}catch(r){o.logger.error("error while trying to append buffer:"+r.message),t.unshift(i);var l={type:s.ErrorTypes.MEDIA_ERROR,parent:i.parent};22!==r.code?(this.appendError?this.appendError++:this.appendError=1,l.details=s.ErrorDetails.BUFFER_APPEND_ERROR,this.appendError>e.config.appendErrorMaxRetry?(o.logger.log("fail "+e.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),this.segments=[],l.fatal=!0,e.trigger(a.default.ERROR,l)):(l.fatal=!1,e.trigger(a.default.ERROR,l))):(this.segments=[],l.details=s.ErrorDetails.BUFFER_FULL_ERROR,l.fatal=!1,e.trigger(a.default.ERROR,l))}}}}},{key:"flushBuffer",value:function(e,t,r){var i=void 0,a=this.sourceBuffer;if(Object.keys(a).length){if(o.logger.log("flushBuffer,pos/start/end: "+this.media.currentTime.toFixed(3)+"/"+e+"/"+t),this.flushBufferCounter<this.appended){for(var n in a)if(!r||n===r){if((i=a[n]).ended=!1,i.updating)return o.logger.warn("cannot flush, sb updating in progress"),!1;if(this.removeBufferRange(n,i,e,t))return this.flushBufferCounter++,!1}}else o.logger.warn("abort flushing too many retries");o.logger.log("buffer flushed")}return!0}},{key:"removeBufferRange",value:function(e,t,r,i){try{for(var a=0;a<t.buffered.length;a++){var n=t.buffered.start(a),s=t.buffered.end(a),l=Math.max(n,r),u=Math.min(s,i);if(Math.min(u,s)-l>.5)return o.logger.log("sb remove "+e+" ["+l+","+u+"], of ["+n+","+s+"], pos:"+this.media.currentTime),t.remove(l,u),!0}}catch(e){o.logger.warn("removeBufferRange failed",e)}return!1}}]),t}();t.default=d,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(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,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}();var a=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.alpha_=t?Math.exp(Math.log(.5)/t):0,this.estimate_=0,this.totalWeight_=0}return i(e,[{key:"sample",value:function(e,t){var r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e}},{key:"getTotalWeight",value:function(){return this.totalWeight_}},{key:"getEstimate",value:function(){if(this.alpha_){var e=1-Math.pow(this.alpha_,this.totalWeight_);return this.estimate_/e}return this.estimate_}}]),e}();t.default=a,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(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,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),a=function(e){return e&&e.__esModule?e:{default:e}}(r(48));var n=function(){function e(t,r,i,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.hls=t,this.defaultEstimate_=n,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new a.default(r),this.fast_=new a.default(i)}return i(e,[{key:"sample",value:function(e,t){var r=8e3*t/(e=Math.max(e,this.minDelayMs_)),i=e/1e3;this.fast_.sample(i,r),this.slow_.sample(i,r)}},{key:"canEstimate",value:function(){var e=this.fast_;return e&&e.getTotalWeight()>=this.minWeight_}},{key:"getEstimate",value:function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}},{key:"destroy",value:function(){}}]),e}();t.default=n,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(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,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),a=d(r(1)),n=d(r(3)),o=r(4),s=r(2),l=r(0),u=d(r(49));function d(e){return e&&e.__esModule?e:{default:e}}var f=window.performance,c=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var r=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,a.default.FRAG_LOADING,a.default.FRAG_LOADED,a.default.FRAG_BUFFERED,a.default.ERROR));return r.lastLoadedFragLevel=0,r._nextAutoLevel=-1,r.hls=e,r.timer=null,r._bwEstimator=null,r.onCheck=r._abandonRulesCheck.bind(r),r}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,n.default),i(t,[{key:"destroy",value:function(){this.clearTimer(),n.default.prototype.destroy.call(this)}},{key:"onFragLoading",value:function(e){var t=e.frag;if("main"===t.type&&(this.timer||(this.fragCurrent=t,this.timer=setInterval(this.onCheck,100)),!this._bwEstimator)){var r=this.hls,i=r.config,a=t.level,n=void 0,o=void 0;r.levels[a].details.live?(n=i.abrEwmaFastLive,o=i.abrEwmaSlowLive):(n=i.abrEwmaFastVoD,o=i.abrEwmaSlowVoD),this._bwEstimator=new u.default(r,o,n,i.abrEwmaDefaultEstimate)}}},{key:"_abandonRulesCheck",value:function(){var e=this.hls,t=e.media,r=this.fragCurrent;if(r){var i=r.loader,n=e.minAutoLevel;if(!i||i.stats&&i.stats.aborted)return l.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),void(this._nextAutoLevel=-1);var s=i.stats;if(t&&s&&(!t.paused&&0!==t.playbackRate||!t.readyState)&&r.autoLevel&&r.level){var u=f.now()-s.trequest,d=Math.abs(t.playbackRate);if(u>500*r.duration/d){var c=e.levels,h=Math.max(1,s.bw?s.bw/8:1e3*s.loaded/u),v=c[r.level],g=v.realBitrate?Math.max(v.realBitrate,v.bitrate):v.bitrate,p=s.total?s.total:Math.max(s.loaded,Math.round(r.duration*g/8)),y=t.currentTime,m=(p-s.loaded)/h,b=(o.BufferHelper.bufferInfo(t,y,e.config.maxBufferHole).end-y)/d;if(b<2*r.duration/d&&m>b){var E=void 0,_=void 0;for(_=r.level-1;_>n;_--){var T=c[_].realBitrate?Math.max(c[_].realBitrate,c[_].bitrate):c[_].bitrate;if((E=r.duration*T/(6.4*h))<b)break}E<m&&(l.logger.warn("loading too slow, abort fragment loading and switch to level "+_+":fragLoadedDelay["+_+"]<fragLoadedDelay["+(r.level-1)+"];bufferStarvationDelay:"+E.toFixed(1)+"<"+m.toFixed(1)+":"+b.toFixed(1)),e.nextLoadLevel=_,this._bwEstimator.sample(u,s.loaded),i.abort(),this.clearTimer(),e.trigger(a.default.FRAG_LOAD_EMERGENCY_ABORTED,{frag:r,stats:s}))}}}}}},{key:"onFragLoaded",value:function(e){var t=e.frag;if("main"===t.type&&Number.isFinite(t.sn)){if(this.clearTimer(),this.lastLoadedFragLevel=t.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var r=this.hls.levels[t.level],i=(r.loaded?r.loaded.bytes:0)+e.stats.loaded,a=(r.loaded?r.loaded.duration:0)+e.frag.duration;r.loaded={bytes:i,duration:a},r.realBitrate=Math.round(8*i/a)}if(e.frag.bitrateTest){var n=e.stats;n.tparsed=n.tbuffered=n.tload,this.onFragBuffered(e)}}}},{key:"onFragBuffered",value:function(e){var t=e.stats,r=e.frag;if(!0!==t.aborted&&"main"===r.type&&Number.isFinite(r.sn)&&(!r.bitrateTest||t.tload===t.tbuffered)){var i=t.tparsed-t.trequest;l.logger.log("latency/loading/parsing/append/kbps:"+Math.round(t.tfirst-t.trequest)+"/"+Math.round(t.tload-t.tfirst)+"/"+Math.round(t.tparsed-t.tload)+"/"+Math.round(t.tbuffered-t.tparsed)+"/"+Math.round(8*t.loaded/(t.tbuffered-t.trequest))),this._bwEstimator.sample(i,t.loaded),t.bwEstimate=this._bwEstimator.getEstimate(),r.bitrateTest?this.bitrateTestDelay=i/1e3:this.bitrateTestDelay=0}}},{key:"onError",value:function(e){switch(e.details){case s.ErrorDetails.FRAG_LOAD_ERROR:case s.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer()}}},{key:"clearTimer",value:function(){clearInterval(this.timer),this.timer=null}},{key:"_findBestLevel",value:function(e,t,r,i,a,n,o,s,u){for(var d=a;d>=i;d--){var f=u[d];if(f){var c=f.details,h=c?c.totalduration/c.fragments.length:t,v=!!c&&c.live,g=void 0;g=d<=e?o*r:s*r;var p=u[d].realBitrate?Math.max(u[d].realBitrate,u[d].bitrate):u[d].bitrate,y=p*h/g;if(l.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+d+"/"+Math.round(g)+"/"+p+"/"+h+"/"+n+"/"+y),g>p&&(!y||v&&!this.bitrateTestDelay||y<n))return d}}return-1}},{key:"nextAutoLevel",get:function(){var e=this._nextAutoLevel,t=this._bwEstimator;if(!(-1===e||t&&t.canEstimate()))return e;var r=this._nextABRAutoLevel;return-1!==e&&(r=Math.min(e,r)),r},set:function(e){this._nextAutoLevel=e}},{key:"_nextABRAutoLevel",get:function(){var e=this.hls,t=e.maxAutoLevel,r=e.levels,i=e.config,a=e.minAutoLevel,n=e.media,s=this.lastLoadedFragLevel,u=this.fragCurrent?this.fragCurrent.duration:0,d=n?n.currentTime:0,f=n&&0!==n.playbackRate?Math.abs(n.playbackRate):1,c=this._bwEstimator?this._bwEstimator.getEstimate():i.abrEwmaDefaultEstimate,h=(o.BufferHelper.bufferInfo(n,d,i.maxBufferHole).end-d)/f,v=this._findBestLevel(s,u,c,a,t,h,i.abrBandWidthFactor,i.abrBandWidthUpFactor,r);if(v>=0)return v;l.logger.trace("rebuffering expected to happen, lets try to find a quality level minimizing the rebuffering");var g=u?Math.min(u,i.maxStarvationDelay):i.maxStarvationDelay,p=i.abrBandWidthFactor,y=i.abrBandWidthUpFactor;if(0===h){var m=this.bitrateTestDelay;if(m)g=(u?Math.min(u,i.maxLoadingDelay):i.maxLoadingDelay)-m,l.logger.trace("bitrate test took "+Math.round(1e3*m)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*g)+" ms"),p=y=1}return v=this._findBestLevel(s,u,c,a,t,h+g,p,y,r),Math.max(v,0)}}]),t}();t.default=c,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.hlsDefaultConfig=void 0;var i=p(r(50)),a=p(r(47)),n=p(r(46)),o=p(r(45)),s=p(r(44)),l=p(r(43)),u=p(r(42)),d=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(r(41)),f=p(r(39)),c=p(r(35)),h=r(34),v=p(r(33)),g=r(32);function p(e){return e&&e.__esModule?e:{default:e}}var y=t.hlsDefaultConfig={autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,initialLiveManifestSize:1,maxBufferLength:30,maxBufferSize:6e7,maxBufferHole:.5,lowBufferWatchdogPeriod:.5,highBufferWatchdogPeriod:3,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,liveDurationInfinity:!1,liveBackBufferLength:1/0,maxMaxBufferLength:600,enableWorker:!0,enableSoftwareAES:!0,manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,startLevel:void 0,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:s.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,abrController:i.default,bufferController:a.default,capLevelController:n.default,fpsController:o.default,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,requestMediaKeySystemAccessFunc:g.requestMediaKeySystemAccess};y.subtitleStreamController=h.SubtitleStreamController,y.subtitleTrackController=c.default,y.timelineController=f.default,y.cueHandler=d,y.enableCEA708Captions=!0,y.enableWebVTT=!0,y.captionsTextTrack1Label="English",y.captionsTextTrack1LanguageCode="en",y.captionsTextTrack2Label="Spanish",y.captionsTextTrack2LanguageCode="es",y.audioStreamController=u.default,y.audioTrackController=l.default,y.emeController=v.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isSupported=function(){var e=(0,i.getMediaSource)(),t=window.SourceBuffer||window.WebKitSourceBuffer,r=e&&"function"==typeof e.isTypeSupported&&e.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),a=!t||t.prototype&&"function"==typeof t.prototype.appendBuffer&&"function"==typeof t.prototype.remove;return!!r&&!!a};var i=r(12)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(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,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),a=l(r(1)),n=l(r(3)),o=l(r(8)),s=r(16);function l(e){return e&&e.__esModule?e:{default:e}}var u=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var r=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,a.default.MEDIA_ATTACHED,a.default.MEDIA_DETACHING,a.default.FRAG_PARSING_METADATA));return r.id3Track=void 0,r.media=void 0,r}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,n.default),i(t,[{key:"destroy",value:function(){n.default.prototype.destroy.call(this)}},{key:"onMediaAttached",value:function(e){this.media=e.media,this.media}},{key:"onMediaDetaching",value:function(){(0,s.clearCurrentCues)(this.id3Track),this.id3Track=void 0,this.media=void 0}},{key:"getID3Track",value:function(e){for(var t=0;t<e.length;t++){var r=e[t];if("metadata"===r.kind&&"id3"===r.label)return(0,s.sendAddTrackEvent)(r,this.media),r}return this.media.addTextTrack("metadata","id3")}},{key:"onFragParsingMetadata",value:function(e){var t=e.frag,r=e.samples;this.id3Track||(this.id3Track=this.getID3Track(this.media.textTracks),this.id3Track.mode="hidden");for(var i=window.WebKitDataCue||window.VTTCue||window.TextTrackCue,a=0;a<r.length;a++){var n=o.default.getID3Frames(r[a].data);if(n){var s=r[a].pts,l=a<r.length-1?r[a+1].pts:t.endPTS;s===l&&(l+=1e-4);for(var u=0;u<n.length;u++){var d=n[u];if(!o.default.isTimeStampFrame(d)){var f=new i(s,l,"");f.value=d,this.id3Track.addCue(f)}}}}}}]),t}();t.default=u,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a=function(){function e(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,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),n=f(r(1)),o=f(r(3)),s=r(0),l=r(2),u=r(27),d=r(5);function f(e){return e&&e.__esModule?e:{default:e}}window.performance;var c=void 0,h=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var r=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n.default.MANIFEST_LOADED,n.default.LEVEL_LOADED,n.default.AUDIO_TRACK_SWITCHED,n.default.FRAG_LOADED,n.default.ERROR));return r.canload=!1,r.currentLevelIndex=null,r.manualLevelIndex=-1,r.timer=null,c=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),r}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,o.default),a(t,[{key:"onHandlerDestroying",value:function(){this.clearTimer(),this.manualLevelIndex=-1}},{key:"clearTimer",value:function(){null!==this.timer&&(clearTimeout(this.timer),this.timer=null)}},{key:"startLoad",value:function(){var e=this._levels;this.canload=!0,this.levelRetryCount=0,e&&e.forEach(function(e){e.loadError=0;var t=e.details;t&&t.live&&(e.details=void 0)}),null!==this.timer&&this.loadLevel()}},{key:"stopLoad",value:function(){this.canload=!1}},{key:"onManifestLoaded",value:function(e){var t=[],r=[],i=void 0,a={},o=null,f=!1,h=!1;if(e.levels.forEach(function(e){var r=e.attrs;e.loadError=0,e.fragmentError=!1,f=f||!!e.videoCodec,h=h||!!e.audioCodec,c&&e.audioCodec&&-1!==e.audioCodec.indexOf("mp4a.40.34")&&(e.audioCodec=void 0),(o=a[e.bitrate])?o.url.push(e.url):(e.url=[e.url],e.urlId=0,a[e.bitrate]=e,t.push(e)),r&&(r.AUDIO&&(h=!0,(0,d.addGroupId)(o||e,"audio",r.AUDIO)),r.SUBTITLES&&(0,d.addGroupId)(o||e,"text",r.SUBTITLES))}),f&&h&&(t=t.filter(function(e){return!!e.videoCodec})),t=t.filter(function(e){var t=e.audioCodec,r=e.videoCodec;return(!t||(0,u.isCodecSupportedInMp4)(t,"audio"))&&(!r||(0,u.isCodecSupportedInMp4)(r,"video"))}),e.audioTracks&&(r=e.audioTracks.filter(function(e){return!e.audioCodec||(0,u.isCodecSupportedInMp4)(e.audioCodec,"audio")})).forEach(function(e,t){e.id=t}),t.length>0){i=t[0].bitrate,t.sort(function(e,t){return e.bitrate-t.bitrate}),this._levels=t;for(var v=0;v<t.length;v++)if(t[v].bitrate===i){this._firstLevel=v,s.logger.log("manifest loaded,"+t.length+" level(s) found, first bitrate:"+i);break}this.hls.trigger(n.default.MANIFEST_PARSED,{levels:t,audioTracks:r,firstLevel:this._firstLevel,stats:e.stats,audio:h,video:f,altAudio:r.some(function(e){return!!e.url})})}else this.hls.trigger(n.default.ERROR,{type:l.ErrorTypes.MEDIA_ERROR,details:l.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:this.hls.url,reason:"no level with compatible codecs found in manifest"})}},{key:"setLevelInternal",value:function(e){var t=this._levels,r=this.hls;if(e>=0&&e<t.length){if(this.clearTimer(),this.currentLevelIndex!==e){s.logger.log("switching to level "+e),this.currentLevelIndex=e;var i=t[e];i.level=e,r.trigger(n.default.LEVEL_SWITCHING,i)}var a=t[e],o=a.details;if(!o||o.live){var u=a.urlId;r.trigger(n.default.LEVEL_LOADING,{url:a.url[u],level:e,id:u})}}else r.trigger(n.default.ERROR,{type:l.ErrorTypes.OTHER_ERROR,details:l.ErrorDetails.LEVEL_SWITCH_ERROR,level:e,fatal:!1,reason:"invalid level idx"})}},{key:"onError",value:function(e){if(e.fatal)e.type===l.ErrorTypes.NETWORK_ERROR&&this.clearTimer();else{var t=!1,r=!1,i=void 0;switch(e.details){case l.ErrorDetails.FRAG_LOAD_ERROR:case l.ErrorDetails.FRAG_LOAD_TIMEOUT:case l.ErrorDetails.KEY_LOAD_ERROR:case l.ErrorDetails.KEY_LOAD_TIMEOUT:i=e.frag.level,r=!0;break;case l.ErrorDetails.LEVEL_LOAD_ERROR:case l.ErrorDetails.LEVEL_LOAD_TIMEOUT:i=e.context.level,t=!0;break;case l.ErrorDetails.REMUX_ALLOC_ERROR:i=e.level,t=!0}void 0!==i&&this.recoverLevel(e,i,t,r)}}},{key:"recoverLevel",value:function(e,t,r,i){var a=this,n=this.hls.config,o=e.details,l=this._levels[t],u=void 0,d=void 0,f=void 0;if(l.loadError++,l.fragmentError=i,r){if(!(this.levelRetryCount+1<=n.levelLoadingMaxRetry))return s.logger.error("level controller, cannot recover from "+o+" error"),this.currentLevelIndex=null,this.clearTimer(),void(e.fatal=!0);d=Math.min(Math.pow(2,this.levelRetryCount)*n.levelLoadingRetryDelay,n.levelLoadingMaxRetryTimeout),this.timer=setTimeout(function(){return a.loadLevel()},d),e.levelRetry=!0,this.levelRetryCount++,s.logger.warn("level controller, "+o+", retry in "+d+" ms, current retry count is "+this.levelRetryCount)}(r||i)&&((u=l.url.length)>1&&l.loadError<u?(l.urlId=(l.urlId+1)%u,l.details=void 0,s.logger.warn("level controller, "+o+" for level "+t+": switching to redundant URL-id "+l.urlId)):-1===this.manualLevelIndex?(f=0===t?this._levels.length-1:t-1,s.logger.warn("level controller, "+o+": switch to "+f),this.hls.nextAutoLevel=this.currentLevelIndex=f):i&&(s.logger.warn("level controller, "+o+": reload a fragment"),this.currentLevelIndex=null))}},{key:"onFragLoaded",value:function(e){var t=e.frag;if(void 0!==t&&"main"===t.type){var r=this._levels[t.level];void 0!==r&&(r.fragmentError=!1,r.loadError=0,this.levelRetryCount=0)}}},{key:"onLevelLoaded",value:function(e){var t=this,r=e.level,i=e.details;if(r===this.currentLevelIndex){var a=this._levels[r];if(a.fragmentError||(a.loadError=0,this.levelRetryCount=0),i.live){var n=(0,d.computeReloadInterval)(a.details,i,e.stats.trequest);s.logger.log("live playlist, reload in "+Math.round(n)+" ms"),this.timer=setTimeout(function(){return t.loadLevel()},n)}else this.clearTimer()}}},{key:"onAudioTrackSwitched",value:function(e){var t=this.hls.audioTracks[e.id].groupId,r=this.hls.levels[this.currentLevelIndex];if(r&&r.audioGroupIds){for(var i=-1,a=0;a<r.audioGroupIds.length;a++)if(r.audioGroupIds[a]===t){i=a;break}i!==r.urlId&&(r.urlId=i,this.startLoad())}}},{key:"loadLevel",value:function(){if(s.logger.debug("call to loadLevel"),null!==this.currentLevelIndex&&this.canload){var e=this._levels[this.currentLevelIndex];if("object"===(void 0===e?"undefined":i(e))&&e.url.length>0){var t=this.currentLevelIndex,r=e.urlId,a=e.url[r];s.logger.log("Attempt loading level index "+t+" with URL-id "+r),this.hls.trigger(n.default.LEVEL_LOADING,{url:a,level:t,id:r})}}}},{key:"levels",get:function(){return this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(e){var t=this._levels;t&&(e=Math.min(e,t.length-1),this.currentLevelIndex===e&&t[e].details||this.setLevelInternal(e))}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(e){this.manualLevelIndex=e,void 0===this._startLevel&&(this._startLevel=e),-1!==e&&(this.level=e)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(e){this._firstLevel=e}},{key:"startLevel",get:function(){if(void 0===this._startLevel){var e=this.hls.config.startLevel;return void 0!==e?e:this._firstLevel}return this._startLevel},set:function(e){this._startLevel=e}},{key:"nextLoadLevel",get:function(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(e){this.level=e,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=e)}}]),t}();t.default=h,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(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,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),a=r(4),n=r(2),o=function(e){return e&&e.__esModule?e:{default:e}}(r(1)),s=r(0);var l=function(){function e(t,r,i,a){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.config=t,this.media=r,this.fragmentTracker=i,this.hls=a,this.stallReported=!1}return i(e,[{key:"poll",value:function(e,t){var r=this.config,i=this.media,n=i.currentTime,o=window.performance.now();if(n!==e)return this.stallReported&&(s.logger.warn("playback not stuck anymore @"+n+", after "+Math.round(o-this.stalled)+"ms"),this.stallReported=!1),this.stalled=null,void(this.nudgeRetry=0);if(!(i.ended||!i.buffered.length||i.readyState>2||i.seeking&&a.BufferHelper.isBuffered(i,n))){var l=o-this.stalled,u=a.BufferHelper.bufferInfo(i,n,r.maxBufferHole);this.stalled?(l>=1e3&&this._reportStall(u.len),this._tryFixBufferStall(u,l)):this.stalled=o}}},{key:"_tryFixBufferStall",value:function(e,t){var r=this.config,i=this.fragmentTracker,a=this.media.currentTime,n=i.getPartialFragment(a);n&&this._trySkipBufferHole(n),e.len>.5&&t>1e3*r.highBufferWatchdogPeriod&&(this.stalled=null,this._tryNudgeBuffer())}},{key:"_reportStall",value:function(e){var t=this.hls,r=this.media;this.stallReported||(this.stallReported=!0,s.logger.warn("Playback stalling at @"+r.currentTime+" due to low buffer"),t.trigger(o.default.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:e}))}},{key:"_trySkipBufferHole",value:function(e){for(var t=this.hls,r=this.media,i=r.currentTime,a=0,l=0;l<r.buffered.length;l++){var u=r.buffered.start(l);if(i>=a&&i<u)return r.currentTime=Math.max(u,r.currentTime+.1),s.logger.warn("skipping hole, adjusting currentTime from "+i+" to "+r.currentTime),this.stalled=null,void t.trigger(o.default.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+i+" to "+r.currentTime,frag:e});a=r.buffered.end(l)}}},{key:"_tryNudgeBuffer",value:function(){var e=this.config,t=this.hls,r=this.media,i=r.currentTime,a=(this.nudgeRetry||0)+1;if(this.nudgeRetry=a,a<e.nudgeMaxRetry){var l=i+a*e.nudgeOffset;s.logger.log("adjust currentTime from "+i+" to "+l),r.currentTime=l,t.trigger(o.default.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else s.logger.error("still stuck in high buffer @"+i+" after "+e.nudgeMaxRetry+", raise fatal error"),t.trigger(o.default.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})}}]),e}();t.default=l,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=s(r(24)),a=s(r(1)),n=r(0),o=r(25);function s(e){return e&&e.__esModule?e:{default:e}}t.default=function(e){var t=new o.EventEmitter;t.trigger=function(e){for(var r=arguments.length,i=Array(r>1?r-1:0),a=1;a<r;a++)i[a-1]=arguments[a];t.emit.apply(t,[e,e].concat(i))},t.off=function(e){for(var r=arguments.length,i=Array(r>1?r-1:0),a=1;a<r;a++)i[a-1]=arguments[a];t.removeListener.apply(t,[e].concat(i))};var r=function(t,r){e.postMessage({event:t,data:r})};e.addEventListener("message",function(a){var o=a.data;switch(o.cmd){case"init":var s=JSON.parse(o.config);e.demuxer=new i.default(t,o.typeSupported,s,o.vendor),(0,n.enableLogs)(s.debug),r("init",null);break;case"demux":e.demuxer.push(o.data,o.decryptdata,o.initSegment,o.audioCodec,o.videoCodec,o.timeOffset,o.discontinuity,o.trackSwitch,o.contiguous,o.duration,o.accurateTimeOffset,o.defaultInitPTS)}}),t.on(a.default.FRAG_DECRYPTED,r),t.on(a.default.FRAG_PARSING_INIT_SEGMENT,r),t.on(a.default.FRAG_PARSED,r),t.on(a.default.ERROR,r),t.on(a.default.FRAG_PARSING_METADATA,r),t.on(a.default.FRAG_PARSING_USERDATA,r),t.on(a.default.INIT_PTS_FOUND,r),t.on(a.default.FRAG_PARSING_DATA,function(t,r){var i=[],a={event:t,data:r};r.data1&&(a.data1=r.data1.buffer,i.push(r.data1.buffer),delete r.data1),r.data2&&(a.data2=r.data2.buffer,i.push(r.data2.buffer),delete r.data2),e.postMessage(a,i)})},e.exports=t.default},function(e,t,r){"use strict";var i=Object.prototype.hasOwnProperty,a="~";function n(){}function o(e,t,r,i,n){if("function"!=typeof r)throw new TypeError("The listener must be a function");var o=new function(e,t,r){this.fn=e,this.context=t,this.once=r||!1}(r,i||e,n),s=a?a+t:t;return e._events[s]?e._events[s].fn?e._events[s]=[e._events[s],o]:e._events[s].push(o):(e._events[s]=o,e._eventsCount++),e}function s(e,t){0==--e._eventsCount?e._events=new n:delete e._events[t]}function l(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(a=!1)),l.prototype.eventNames=function(){var e,t,r=[];if(0===this._eventsCount)return r;for(t in e=this._events)i.call(e,t)&&r.push(a?t.slice(1):t);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(e)):r},l.prototype.listeners=function(e){var t=a?a+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var i=0,n=r.length,o=new Array(n);i<n;i++)o[i]=r[i].fn;return o},l.prototype.listenerCount=function(e){var t=a?a+e:e,r=this._events[t];return r?r.fn?1:r.length:0},l.prototype.emit=function(e,t,r,i,n,o){var s=a?a+e:e;if(!this._events[s])return!1;var l,u,d=this._events[s],f=arguments.length;if(d.fn){switch(d.once&&this.removeListener(e,d.fn,void 0,!0),f){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,t),!0;case 3:return d.fn.call(d.context,t,r),!0;case 4:return d.fn.call(d.context,t,r,i),!0;case 5:return d.fn.call(d.context,t,r,i,n),!0;case 6:return d.fn.call(d.context,t,r,i,n,o),!0}for(u=1,l=new Array(f-1);u<f;u++)l[u-1]=arguments[u];d.fn.apply(d.context,l)}else{var c,h=d.length;for(u=0;u<h;u++)switch(d[u].once&&this.removeListener(e,d[u].fn,void 0,!0),f){case 1:d[u].fn.call(d[u].context);break;case 2:d[u].fn.call(d[u].context,t);break;case 3:d[u].fn.call(d[u].context,t,r);break;case 4:d[u].fn.call(d[u].context,t,r,i);break;default:if(!l)for(c=1,l=new Array(f-1);c<f;c++)l[c-1]=arguments[c];d[u].fn.apply(d[u].context,l)}}return!0},l.prototype.on=function(e,t,r){return o(this,e,t,r,!1)},l.prototype.once=function(e,t,r){return o(this,e,t,r,!0)},l.prototype.removeListener=function(e,t,r,i){var n=a?a+e:e;if(!this._events[n])return this;if(!t)return s(this,n),this;var o=this._events[n];if(o.fn)o.fn!==t||i&&!o.once||r&&o.context!==r||s(this,n);else{for(var l=0,u=[],d=o.length;l<d;l++)(o[l].fn!==t||i&&!o[l].once||r&&o[l].context!==r)&&u.push(o[l]);u.length?this._events[n]=1===u.length?u[0]:u:s(this,n)}return this},l.prototype.removeAllListeners=function(e){var t;return e?(t=a?a+e:e,this._events[t]&&s(this,t)):(this._events=new n,this._eventsCount=0),this},l.prototype.off=l.prototype.removeListener,l.prototype.addListener=l.prototype.on,l.prefixed=a,l.EventEmitter=l,e.exports=l},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(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,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),a=function(e){return e&&e.__esModule?e:{default:e}}(r(1));var n=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.observer=t}return i(e,[{key:"destroy",value:function(){}},{key:"resetTimeStamp",value:function(){}},{key:"resetInitSegment",value:function(){}},{key:"remux",value:function(e,t,r,i,n,o,s,l){var u=this.observer,d="";e&&(d+="audio"),t&&(d+="video"),u.trigger(a.default.FRAG_PARSING_DATA,{data1:l,startPTS:n,startDTS:n,type:d,hasAudio:!!e,hasVideo:!!t,nb:1,dropped:0}),u.trigger(a.default.FRAG_PARSED)}}]),e}();t.default=n,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(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,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}();var a=Math.pow(2,32)-1,n=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return i(e,null,[{key:"init",value:function(){e.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:[]};var t=void 0;for(t in e.types)e.types.hasOwnProperty(t)&&(e.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);var r=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),i=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);e.HDLR_TYPES={video:r,audio:i};var a=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),n=new Uint8Array([0,0,0,0,0,0,0,0]);e.STTS=e.STSC=e.STCO=n,e.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),e.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),e.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),e.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var o=new Uint8Array([105,115,111,109]),s=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);e.FTYP=e.box(e.types.ftyp,o,l,o,s),e.DINF=e.box(e.types.dinf,e.box(e.types.dref,a))}},{key:"box",value:function(e){for(var t=Array.prototype.slice.call(arguments,1),r=8,i=t.length,a=i,n=void 0;i--;)r+=t[i].byteLength;for((n=new Uint8Array(r))[0]=r>>24&255,n[1]=r>>16&255,n[2]=r>>8&255,n[3]=255&r,n.set(e,4),i=0,r=8;i<a;i++)n.set(t[i],r),r+=t[i].byteLength;return n}},{key:"hdlr",value:function(t){return e.box(e.types.hdlr,e.HDLR_TYPES[t])}},{key:"mdat",value:function(t){return e.box(e.types.mdat,t)}},{key:"mdhd",value:function(t,r){r*=t;var i=Math.floor(r/(a+1)),n=Math.floor(r%(a+1));return e.box(e.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,i>>24,i>>16&255,i>>8&255,255&i,n>>24,n>>16&255,n>>8&255,255&n,85,196,0,0]))}},{key:"mdia",value:function(t){return e.box(e.types.mdia,e.mdhd(t.timescale,t.duration),e.hdlr(t.type),e.minf(t))}},{key:"mfhd",value:function(t){return e.box(e.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))}},{key:"minf",value:function(t){return"audio"===t.type?e.box(e.types.minf,e.box(e.types.smhd,e.SMHD),e.DINF,e.stbl(t)):e.box(e.types.minf,e.box(e.types.vmhd,e.VMHD),e.DINF,e.stbl(t))}},{key:"moof",value:function(t,r,i){return e.box(e.types.moof,e.mfhd(t),e.traf(i,r))}},{key:"moov",value:function(t){for(var r=t.length,i=[];r--;)i[r]=e.trak(t[r]);return e.box.apply(null,[e.types.moov,e.mvhd(t[0].timescale,t[0].duration)].concat(i).concat(e.mvex(t)))}},{key:"mvex",value:function(t){for(var r=t.length,i=[];r--;)i[r]=e.trex(t[r]);return e.box.apply(null,[e.types.mvex].concat(i))}},{key:"mvhd",value:function(t,r){r*=t;var i=Math.floor(r/(a+1)),n=Math.floor(r%(a+1)),o=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,i>>24,i>>16&255,i>>8&255,255&i,n>>24,n>>16&255,n>>8&255,255&n,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return e.box(e.types.mvhd,o)}},{key:"sdtp",value:function(t){var r=t.samples||[],i=new Uint8Array(4+r.length),a=void 0,n=void 0;for(n=0;n<r.length;n++)a=r[n].flags,i[n+4]=a.dependsOn<<4|a.isDependedOn<<2|a.hasRedundancy;return e.box(e.types.sdtp,i)}},{key:"stbl",value:function(t){return e.box(e.types.stbl,e.stsd(t),e.box(e.types.stts,e.STTS),e.box(e.types.stsc,e.STSC),e.box(e.types.stsz,e.STSZ),e.box(e.types.stco,e.STCO))}},{key:"avc1",value:function(t){var r=[],i=[],a=void 0,n=void 0,o=void 0;for(a=0;a<t.sps.length;a++)o=(n=t.sps[a]).byteLength,r.push(o>>>8&255),r.push(255&o),r=r.concat(Array.prototype.slice.call(n));for(a=0;a<t.pps.length;a++)o=(n=t.pps[a]).byteLength,i.push(o>>>8&255),i.push(255&o),i=i.concat(Array.prototype.slice.call(n));var s=e.box(e.types.avcC,new Uint8Array([1,r[3],r[4],r[5],255,224|t.sps.length].concat(r).concat([t.pps.length]).concat(i))),l=t.width,u=t.height,d=t.pixelRatio[0],f=t.pixelRatio[1];return e.box(e.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,l>>8&255,255&l,u>>8&255,255&u,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),s,e.box(e.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),e.box(e.types.pasp,new Uint8Array([d>>24,d>>16&255,d>>8&255,255&d,f>>24,f>>16&255,f>>8&255,255&f])))}},{key:"esds",value:function(e){var t=e.config.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e.config).concat([6,1,2]))}},{key:"mp4a",value:function(t){var r=t.samplerate;return e.box(e.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,r>>8&255,255&r,0,0]),e.box(e.types.esds,e.esds(t)))}},{key:"mp3",value:function(t){var r=t.samplerate;return e.box(e.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,r>>8&255,255&r,0,0]))}},{key:"stsd",value:function(t){return"audio"===t.type?t.isAAC||"mp3"!==t.codec?e.box(e.types.stsd,e.STSD,e.mp4a(t)):e.box(e.types.stsd,e.STSD,e.mp3(t)):e.box(e.types.stsd,e.STSD,e.avc1(t))}},{key:"tkhd",value:function(t){var r=t.id,i=t.duration*t.timescale,n=t.width,o=t.height,s=Math.floor(i/(a+1)),l=Math.floor(i%(a+1));return e.box(e.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,r>>24&255,r>>16&255,r>>8&255,255&r,0,0,0,0,s>>24,s>>16&255,s>>8&255,255&s,l>>24,l>>16&255,l>>8&255,255&l,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,n>>8&255,255&n,0,0,o>>8&255,255&o,0,0]))}},{key:"traf",value:function(t,r){var i=e.sdtp(t),n=t.id,o=Math.floor(r/(a+1)),s=Math.floor(r%(a+1));return e.box(e.types.traf,e.box(e.types.tfhd,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,255&n])),e.box(e.types.tfdt,new Uint8Array([1,0,0,0,o>>24,o>>16&255,o>>8&255,255&o,s>>24,s>>16&255,s>>8&255,255&s])),e.trun(t,i.length+16+20+8+16+8+8),i)}},{key:"trak",value:function(t){return t.duration=t.duration||4294967295,e.box(e.types.trak,e.tkhd(t),e.mdia(t))}},{key:"trex",value:function(t){var r=t.id;return e.box(e.types.trex,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}},{key:"trun",value:function(t,r){var i=t.samples||[],a=i.length,n=12+16*a,o=new Uint8Array(n),s=void 0,l=void 0,u=void 0,d=void 0,f=void 0,c=void 0;for(r+=8+n,o.set([0,0,15,1,a>>>24&255,a>>>16&255,a>>>8&255,255&a,r>>>24&255,r>>>16&255,r>>>8&255,255&r],0),s=0;s<a;s++)u=(l=i[s]).duration,d=l.size,f=l.flags,c=l.cts,o.set([u>>>24&255,u>>>16&255,u>>>8&255,255&u,d>>>24&255,d>>>16&255,d>>>8&255,255&d,f.isLeading<<2|f.dependsOn,f.isDependedOn<<6|f.hasRedundancy<<4|f.paddingValue<<1|f.isNonSync,61440&f.degradPrio,15&f.degradPrio,c>>>24&255,c>>>16&255,c>>>8&255,255&c],12+16*s);return e.box(e.types.trun,o)}},{key:"initSegment",value:function(t){e.types||e.init();var r=e.moov(t),i=void 0;return(i=new Uint8Array(e.FTYP.byteLength+r.byteLength)).set(e.FTYP),i.set(r,e.FTYP.byteLength),i}}]),e}();t.default=n,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(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,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}();var a=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return i(e,null,[{key:"getSilentFrame",value:function(e,t){switch(e){case"mp4a.40.2":if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(6===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(1===t)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(3===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}return null}}]),e}();t.default=a,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(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,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),a=u(r(60)),n=u(r(59)),o=u(r(1)),s=r(2),l=r(0);function u(e){return e&&e.__esModule?e:{default:e}}var d=function(){function e(t,r,i,a){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.observer=t,this.config=r,this.typeSupported=i;var n=navigator.userAgent;this.isSafari=a&&a.indexOf("Apple")>-1&&n&&!n.match("CriOS"),this.ISGenerated=!1}return i(e,[{key:"destroy",value:function(){}},{key:"resetTimeStamp",value:function(e){this._initPTS=this._initDTS=e}},{key:"resetInitSegment",value:function(){this.ISGenerated=!1}},{key:"remux",value:function(e,t,r,i,a,n,s){if(this.ISGenerated||this.generateIS(e,t,a),this.ISGenerated){var u=e.samples.length,d=t.samples.length,f=a,c=a;if(u&&d){var h=(e.samples[0].pts-t.samples[0].pts)/t.inputTimeScale;f+=Math.max(0,h),c+=Math.max(0,-h)}if(u){e.timescale||(l.logger.warn("regenerate InitSegment as audio detected"),this.generateIS(e,t,a));var v=this.remuxAudio(e,f,n,s);if(d){var g=void 0;v&&(g=v.endPTS-v.startPTS),t.timescale||(l.logger.warn("regenerate InitSegment as video detected"),this.generateIS(e,t,a)),this.remuxVideo(t,c,n,g,s)}}else if(d){var p=this.remuxVideo(t,c,n,0,s);p&&e.codec&&this.remuxEmptyAudio(e,f,n,p)}}r.samples.length&&this.remuxID3(r,a),i.samples.length&&this.remuxText(i,a),this.observer.trigger(o.default.FRAG_PARSED)}},{key:"generateIS",value:function(e,t,r){var i=this.observer,a=e.samples,u=t.samples,d=this.typeSupported,f="audio/mp4",c={},h={tracks:c},v=void 0===this._initPTS,g=void 0,p=void 0;if(v&&(g=p=1/0),e.config&&a.length&&(e.timescale=e.samplerate,l.logger.log("audio sampling rate : "+e.samplerate),e.isAAC||(d.mpeg?(f="audio/mpeg",e.codec=""):d.mp3&&(e.codec="mp3")),c.audio={container:f,codec:e.codec,initSegment:!e.isAAC&&d.mpeg?new Uint8Array:n.default.initSegment([e]),metadata:{channelCount:e.channelCount}},v&&(g=p=a[0].pts-e.inputTimeScale*r)),t.sps&&t.pps&&u.length){var y=t.inputTimeScale;t.timescale=y,c.video={container:"video/mp4",codec:t.codec,initSegment:n.default.initSegment([t]),metadata:{width:t.width,height:t.height}},v&&(g=Math.min(g,u[0].pts-y*r),p=Math.min(p,u[0].dts-y*r),this.observer.trigger(o.default.INIT_PTS_FOUND,{initPTS:g}))}Object.keys(c).length?(i.trigger(o.default.FRAG_PARSING_INIT_SEGMENT,h),this.ISGenerated=!0,v&&(this._initPTS=g,this._initDTS=p)):i.trigger(o.default.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"no audio/video samples found"})}},{key:"remuxVideo",value:function(e,t,r,i,a){var u,d,f,c=8,h=void 0,v=void 0,g=void 0,p=void 0,y=e.timescale,m=e.samples,b=[],E=m.length,_=this._PTSNormalize,T=this._initPTS,S=this.nextAvcDts,k=this.isSafari;if(0!==E){k&&(r|=m.length&&S&&(a&&Math.abs(t-S/y)<.1||Math.abs(m[0].pts-S-T)<y/5)),r||(S=t*y),m.forEach(function(e){e.pts=_(e.pts-T,S),e.dts=_(e.dts-T,S)}),m.sort(function(e,t){var r=e.dts-t.dts,i=e.pts-t.pts;return r||i||e.id-t.id});var R=m.reduce(function(e,t){return Math.max(Math.min(e,t.pts-t.dts),-18e3)},0);if(R<0){l.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+Math.round(R/90)+" ms to overcome this issue");for(var A=0;A<m.length;A++)m[A].dts+=R}var w=m[0];p=Math.max(w.dts,0),g=Math.max(w.pts,0);var O=Math.round((p-S)/90);r&&O&&(O>1?l.logger.log("AVC:"+O+" ms hole between fragments detected,filling it"):O<-1&&l.logger.log("AVC:"+-O+" ms overlapping between fragments detected"),p=S,m[0].dts=p,g=Math.max(g-O,S),m[0].pts=g,l.logger.log("Video/PTS/DTS adjusted: "+Math.round(g/90)+"/"+Math.round(p/90)+",delta:"+O+" ms")),w=m[m.length-1],f=Math.max(w.dts,0),d=Math.max(w.pts,0,f),k&&(h=Math.round((f-p)/(m.length-1)));for(var L=0,D=0,P=0;P<E;P++){for(var I=m[P],C=I.units,x=C.length,M=0,F=0;F<x;F++)M+=C[F].data.length;D+=M,L+=x,I.length=M,I.dts=k?p+P*h:Math.max(I.dts,p),I.pts=Math.max(I.pts,I.dts)}var N=D+4*L+8;try{v=new Uint8Array(N)}catch(e){return void this.observer.trigger(o.default.ERROR,{type:s.ErrorTypes.MUX_ERROR,details:s.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:N,reason:"fail allocating video mdat "+N})}var U=new DataView(v.buffer);U.setUint32(0,N),v.set(n.default.types.mdat,4);for(var B=0;B<E;B++){for(var G=m[B],j=G.units,K=0,H=void 0,V=0,W=j.length;V<W;V++){var Y=j[V],q=Y.data,X=Y.data.byteLength;U.setUint32(c,X),c+=4,v.set(q,c),c+=X,K+=4+X}if(k)H=Math.max(0,h*Math.round((G.pts-G.dts)/h));else{if(B<E-1)h=m[B+1].dts-G.dts;else{var z=this.config,Q=G.dts-m[B>0?B-1:B].dts;if(z.stretchShortVideoTrack){var J=z.maxBufferHole,$=Math.floor(J*y),Z=(i?g+i*y:this.nextAudioPts)-G.pts;Z>$?((h=Z-Q)<0&&(h=Q),l.logger.log("It is approximately "+Z/90+" ms to the next segment; using duration "+h/90+" ms for the last video frame.")):h=Q}else h=Q}H=Math.round(G.pts-G.dts)}b.push({size:K,duration:h,cts:H,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:G.key?2:1,isNonSync:G.key?0:1}})}this.nextAvcDts=f+h;var ee=e.dropped;if(e.len=0,e.nbNalu=0,e.dropped=0,b.length&&navigator.userAgent.toLowerCase().indexOf("chrome")>-1){var te=b[0].flags;te.dependsOn=2,te.isNonSync=0}e.samples=b,u=n.default.moof(e.sequenceNumber++,p,e),e.samples=[];var re={data1:u,data2:v,startPTS:g/y,endPTS:(d+h)/y,startDTS:p/y,endDTS:this.nextAvcDts/y,type:"video",hasAudio:!1,hasVideo:!0,nb:b.length,dropped:ee};return this.observer.trigger(o.default.FRAG_PARSING_DATA,re),re}}},{key:"remuxAudio",value:function(e,t,r,i){var u=e.inputTimeScale,d=e.timescale,f=u/d,c=(e.isAAC?1024:1152)*f,h=this._PTSNormalize,v=this._initPTS,g=!e.isAAC&&this.typeSupported.mpeg,p=void 0,y=void 0,m=void 0,b=void 0,E=void 0,_=void 0,T=void 0,S=e.samples,k=[],R=this.nextAudioPts;if(r|=S.length&&R&&(i&&Math.abs(t-R/u)<.1||Math.abs(S[0].pts-R-v)<20*c),S.forEach(function(e){e.pts=e.dts=h(e.pts-v,t*u)}),0!==(S=S.filter(function(e){return e.pts>=0})).length){if(r||(R=i?t*u:S[0].pts),e.isAAC)for(var A=this.config.maxAudioFramesDrift,w=0,O=R;w<S.length;){var L,D=S[w];L=D.pts-O;var P=Math.abs(1e3*L/u);if(L<=-A*c)l.logger.warn("Dropping 1 audio frame @ "+(O/u).toFixed(3)+"s due to "+Math.round(P)+" ms overlap."),S.splice(w,1),e.len-=D.unit.length;else if(L>=A*c&&P<1e4&&O){var I=Math.round(L/c);l.logger.warn("Injecting "+I+" audio frame @ "+(O/u).toFixed(3)+"s due to "+Math.round(1e3*L/u)+" ms gap.");for(var C=0;C<I;C++){var x=Math.max(O,0);(m=a.default.getSilentFrame(e.manifestCodec||e.codec,e.channelCount))||(l.logger.log("Unable to get silent frame for given audio codec; duplicating last frame instead."),m=D.unit.subarray()),S.splice(w,0,{unit:m,pts:x,dts:x}),e.len+=m.length,O+=c,w++}D.pts=D.dts=O,O+=c,w++}else Math.abs(L),D.pts=D.dts=O,O+=c,w++}for(var M=0,F=S.length;M<F;M++){var N=S[M],U=N.unit,B=N.pts;if(void 0!==T)y.duration=Math.round((B-T)/f);else{var G=Math.round(1e3*(B-R)/u),j=0;if(r&&e.isAAC&&G){if(G>0&&G<1e4)j=Math.round((B-R)/c),l.logger.log(G+" ms hole between AAC samples detected,filling it"),j>0&&((m=a.default.getSilentFrame(e.manifestCodec||e.codec,e.channelCount))||(m=U.subarray()),e.len+=j*m.length);else if(G<-12){l.logger.log("drop overlapping AAC sample, expected/parsed/delta:"+(R/u).toFixed(3)+"s/"+(B/u).toFixed(3)+"s/"+-G+"ms"),e.len-=U.byteLength;continue}B=R}if(_=B,!(e.len>0))return;var K=g?e.len:e.len+8;p=g?0:8;try{b=new Uint8Array(K)}catch(e){return void this.observer.trigger(o.default.ERROR,{type:s.ErrorTypes.MUX_ERROR,details:s.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:K,reason:"fail allocating audio mdat "+K})}g||(new DataView(b.buffer).setUint32(0,K),b.set(n.default.types.mdat,4));for(var H=0;H<j;H++)(m=a.default.getSilentFrame(e.manifestCodec||e.codec,e.channelCount))||(l.logger.log("Unable to get silent frame for given audio codec; duplicating this frame instead."),m=U.subarray()),b.set(m,p),p+=m.byteLength,y={size:m.byteLength,cts:0,duration:1024,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:1}},k.push(y)}b.set(U,p);var V=U.byteLength;p+=V,y={size:V,cts:0,duration:0,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:1}},k.push(y),T=B}var W=0,Y=k.length;if(Y>=2&&(W=k[Y-2].duration,y.duration=W),Y){this.nextAudioPts=R=T+f*W,e.len=0,e.samples=k,E=g?new Uint8Array:n.default.moof(e.sequenceNumber++,_/f,e),e.samples=[];var q=_/u,X=R/u,z={data1:E,data2:b,startPTS:q,endPTS:X,startDTS:q,endDTS:X,type:"audio",hasAudio:!0,hasVideo:!1,nb:Y};return this.observer.trigger(o.default.FRAG_PARSING_DATA,z),z}return null}}},{key:"remuxEmptyAudio",value:function(e,t,r,i){var n=e.inputTimeScale,o=n/(e.samplerate?e.samplerate:n),s=this.nextAudioPts,u=(void 0!==s?s:i.startDTS*n)+this._initDTS,d=i.endDTS*n+this._initDTS,f=1024*o,c=Math.ceil((d-u)/f),h=a.default.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(l.logger.warn("remux empty Audio"),h){for(var v=[],g=0;g<c;g++){var p=u+g*f;v.push({unit:h,pts:p,dts:p}),e.len+=h.length}e.samples=v,this.remuxAudio(e,t,r)}else l.logger.trace("Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec!")}},{key:"remuxID3",value:function(e){var t=e.samples.length,r=void 0,i=e.inputTimeScale,a=this._initPTS,n=this._initDTS;if(t){for(var s=0;s<t;s++)(r=e.samples[s]).pts=(r.pts-a)/i,r.dts=(r.dts-n)/i;this.observer.trigger(o.default.FRAG_PARSING_METADATA,{samples:e.samples})}e.samples=[]}},{key:"remuxText",value:function(e){e.samples.sort(function(e,t){return e.pts-t.pts});var t=e.samples.length,r=void 0,i=e.inputTimeScale,a=this._initPTS;if(t){for(var n=0;n<t;n++)(r=e.samples[n]).pts=(r.pts-a)/i;this.observer.trigger(o.default.FRAG_PARSING_USERDATA,{samples:e.samples})}e.samples=[]}},{key:"_PTSNormalize",value:function(e,t){var r=void 0;if(void 0===t)return e;for(r=t<e?-8589934592:8589934592;Math.abs(e-t)>4294967296;)e+=r;return e}}]),e}();t.default=d,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(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,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),a=s(r(8)),n=r(0),o=s(r(22));function s(e){return e&&e.__esModule?e:{default:e}}var l=function(){function e(t,r,i){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.observer=t,this.config=i,this.remuxer=r}return i(e,[{key:"resetInitSegment",value:function(e,t,r,i){this._audioTrack={container:"audio/mpeg",type:"audio",id:-1,sequenceNumber:0,isAAC:!1,samples:[],len:0,manifestCodec:t,duration:i,inputTimeScale:9e4}}},{key:"resetTimeStamp",value:function(){}},{key:"append",value:function(e,t,r,i){for(var n=a.default.getID3Data(e,0),s=a.default.getTimeStamp(n),l=s?90*s:9e4*t,u=n.length,d=e.length,f=0,c=0,h=this._audioTrack,v=[{pts:l,dts:l,data:n}];u<d;)if(o.default.isHeader(e,u)){var g=o.default.appendFrame(h,e,u,l,f);if(!g)break;u+=g.length,c=g.sample.pts,f++}else a.default.isHeader(e,u)?(n=a.default.getID3Data(e,u),v.push({pts:c,dts:c,data:n}),u+=n.length):u++;this.remuxer.remux(h,{samples:[]},{samples:v,inputTimeScale:9e4},{samples:[]},t,r,i)}},{key:"destroy",value:function(){}}],[{key:"probe",value:function(e){var t=void 0,r=void 0,i=a.default.getID3Data(e,0);if(i&&void 0!==a.default.getTimeStamp(i))for(t=i.length,r=Math.min(e.length-1,t+100);t<r;t++)if(o.default.probe(e,t))return n.logger.log("MPEG Audio sync word found !"),!0;return!1}}]),e}();t.default=l,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(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,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),a=function(e){return e&&e.__esModule?e:{default:e}}(r(13));var n=function(){function e(t,r,i,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.decryptdata=i,this.discardEPB=n,this.decrypter=new a.default(t,r,{removePKCS7Padding:!1})}return i(e,[{key:"decryptBuffer",value:function(e,t){this.decrypter.decrypt(e,this.decryptdata.key.buffer,this.decryptdata.iv.buffer,t)}},{key:"decryptAacSample",value:function(e,t,r,i){var a=e[t].unit,n=a.subarray(16,a.length-a.length%16),o=n.buffer.slice(n.byteOffset,n.byteOffset+n.length),s=this;this.decryptBuffer(o,function(n){n=new Uint8Array(n),a.set(n,16),i||s.decryptAacSamples(e,t+1,r)})}},{key:"decryptAacSamples",value:function(e,t,r){for(;;t++){if(t>=e.length)return void r();if(!(e[t].unit.length<32)){var i=this.decrypter.isSync();if(this.decryptAacSample(e,t,r,i),!i)return}}}},{key:"getAvcEncryptedData",value:function(e){for(var t=16*Math.floor((e.length-48)/160)+16,r=new Int8Array(t),i=0,a=32;a<=e.length-16;a+=160,i+=16)r.set(e.subarray(a,a+16),i);return r}},{key:"getAvcDecryptedUnit",value:function(e,t){t=new Uint8Array(t);for(var r=0,i=32;i<=e.length-16;i+=160,r+=16)e.set(t.subarray(r,r+16),i);return e}},{key:"decryptAvcSample",value:function(e,t,r,i,a,n){var o=this.discardEPB(a.data),s=this.getAvcEncryptedData(o),l=this;this.decryptBuffer(s.buffer,function(s){a.data=l.getAvcDecryptedUnit(o,s),n||l.decryptAvcSamples(e,t,r+1,i)})}},{key:"decryptAvcSamples",value:function(e,t,r,i){for(;;t++,r=0){if(t>=e.length)return void i();for(var a=e[t].units;!(r>=a.length);r++){var n=a[r];if(!(n.length<=48||1!==n.type&&5!==n.type)){var o=this.decrypter.isSync();if(this.decryptAvcSample(e,t,r,i,n,o),!o)return}}}}}]),e}();t.default=n,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(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,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),a=r(0);var n=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.data=t,this.bytesAvailable=t.byteLength,this.word=0,this.bitsAvailable=0}return i(e,[{key:"loadWord",value:function(){var e=this.data,t=this.bytesAvailable,r=e.byteLength-t,i=new Uint8Array(4),a=Math.min(4,t);if(0===a)throw new Error("no bytes available");i.set(e.subarray(r,r+a)),this.word=new DataView(i.buffer).getUint32(0),this.bitsAvailable=8*a,this.bytesAvailable-=a}},{key:"skipBits",value:function(e){var t=void 0;this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,e-=(t=e>>3)>>3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}},{key:"readBits",value:function(e){var t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;return e>32&&a.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0?this.word<<=t:this.bytesAvailable>0&&this.loadWord(),(t=e-t)>0&&this.bitsAvailable?r<<t|this.readBits(t):r}},{key:"skipLZ",value:function(){var e=void 0;for(e=0;e<this.bitsAvailable;++e)if(0!=(this.word&2147483648>>>e))return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}},{key:"skipUEG",value:function(){this.skipBits(1+this.skipLZ())}},{key:"skipEG",value:function(){this.skipBits(1+this.skipLZ())}},{key:"readUEG",value:function(){var e=this.skipLZ();return this.readBits(e+1)-1}},{key:"readEG",value:function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}},{key:"readBoolean",value:function(){return 1===this.readBits(1)}},{key:"readUByte",value:function(){return this.readBits(8)}},{key:"readUShort",value:function(){return this.readBits(16)}},{key:"readUInt",value:function(){return this.readBits(32)}},{key:"skipScalingList",value:function(e){var t=8,r=8,i=void 0;for(i=0;i<e;i++)0!==r&&(r=(t+this.readEG()+256)%256),t=0===r?t:r}},{key:"readSPS",value:function(){var e,t,r,i,a=0,n=0,o=0,s=0,l=void 0,u=void 0,d=void 0,f=this.readUByte.bind(this),c=this.readBits.bind(this),h=this.readUEG.bind(this),v=this.readBoolean.bind(this),g=this.skipBits.bind(this),p=this.skipEG.bind(this),y=this.skipUEG.bind(this),m=this.skipScalingList.bind(this);if(f(),e=f(),c(5),g(3),f(),y(),100===e||110===e||122===e||244===e||44===e||83===e||86===e||118===e||128===e){var b=h();if(3===b&&g(1),y(),y(),g(1),v())for(u=3!==b?8:12,d=0;d<u;d++)v()&&m(d<6?16:64)}y();var E=h();if(0===E)h();else if(1===E)for(g(1),p(),p(),l=h(),d=0;d<l;d++)p();y(),g(1),t=h(),r=h(),0===(i=c(1))&&g(1),g(1),v()&&(a=h(),n=h(),o=h(),s=h());var _=[1,1];if(v()&&v())switch(f()){case 1:_=[1,1];break;case 2:_=[12,11];break;case 3:_=[10,11];break;case 4:_=[16,11];break;case 5:_=[40,33];break;case 6:_=[24,11];break;case 7:_=[20,11];break;case 8:_=[32,11];break;case 9:_=[80,33];break;case 10:_=[18,11];break;case 11:_=[15,11];break;case 12:_=[64,33];break;case 13:_=[160,99];break;case 14:_=[4,3];break;case 15:_=[3,2];break;case 16:_=[2,1];break;case 255:_=[f()<<8|f(),f()<<8|f()]}return{width:Math.ceil(16*(t+1)-2*a-2*n),height:(2-i)*(r+1)*16-(i?2:4)*(o+s),pixelRatio:_}}},{key:"readSliceType",value:function(){return this.readUByte(),this.readUEG(),this.readUEG()}}]),e}();t.default=n,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(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,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),a=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(r(23)),n=f(r(22)),o=f(r(1)),s=f(r(64)),l=f(r(63)),u=r(0),d=r(2);function f(e){return e&&e.__esModule?e:{default:e}}var c={video:1,audio:2,id3:3,text:4},h=function(){function e(t,r,i,a){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.observer=t,this.config=i,this.typeSupported=a,this.remuxer=r,this.sampleAes=null}return i(e,[{key:"setDecryptData",value:function(e){null!=e&&null!=e.key&&"SAMPLE-AES"===e.method?this.sampleAes=new l.default(this.observer,this.config,e,this.discardEPB):this.sampleAes=null}},{key:"resetInitSegment",value:function(t,r,i,a){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=e.createTrack("video",a),this._audioTrack=e.createTrack("audio",a),this._id3Track=e.createTrack("id3",a),this._txtTrack=e.createTrack("text",a),this.aacOverFlow=null,this.aacLastPTS=null,this.avcSample=null,this.audioCodec=r,this.videoCodec=i,this._duration=a}},{key:"resetTimeStamp",value:function(){}},{key:"append",value:function(t,r,i,a){var n=void 0,s=t.length,l=void 0,f=void 0,c=void 0,h=void 0,v=!1;this.contiguous=i;var g=this.pmtParsed,p=this._avcTrack,y=this._audioTrack,m=this._id3Track,b=p.pid,E=y.pid,_=m.pid,T=this._pmtId,S=p.pesData,k=y.pesData,R=m.pesData,A=this._parsePAT,w=this._parsePMT,O=this._parsePES,L=this._parseAVCPES.bind(this),D=this._parseAACPES.bind(this),P=this._parseMPEGPES.bind(this),I=this._parseID3PES.bind(this),C=e._syncOffset(t);for(s-=(s+C)%188,n=C;n<s;n+=188)if(71===t[n]){if(l=!!(64&t[n+1]),f=((31&t[n+1])<<8)+t[n+2],(48&t[n+3])>>4>1){if((c=n+5+t[n+4])===n+188)continue}else c=n+4;switch(f){case b:l&&(S&&(h=O(S))&&void 0!==h.pts&&L(h,!1),S={data:[],size:0}),S&&(S.data.push(t.subarray(c,n+188)),S.size+=n+188-c);break;case E:l&&(k&&(h=O(k))&&void 0!==h.pts&&(y.isAAC?D(h):P(h)),k={data:[],size:0}),k&&(k.data.push(t.subarray(c,n+188)),k.size+=n+188-c);break;case _:l&&(R&&(h=O(R))&&void 0!==h.pts&&I(h),R={data:[],size:0}),R&&(R.data.push(t.subarray(c,n+188)),R.size+=n+188-c);break;case 0:l&&(c+=t[c]+1),T=this._pmtId=A(t,c);break;case T:l&&(c+=t[c]+1);var x=w(t,c,!0===this.typeSupported.mpeg||!0===this.typeSupported.mp3,null!=this.sampleAes);(b=x.avc)>0&&(p.pid=b),(E=x.audio)>0&&(y.pid=E,y.isAAC=x.isAAC),(_=x.id3)>0&&(m.pid=_),v&&!g&&(u.logger.log("reparse from beginning"),v=!1,n=C-188),g=this.pmtParsed=!0;break;case 17:case 8191:break;default:v=!0}}else this.observer.trigger(o.default.ERROR,{type:d.ErrorTypes.MEDIA_ERROR,details:d.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});S&&(h=O(S))&&void 0!==h.pts?(L(h,!0),p.pesData=null):p.pesData=S,k&&(h=O(k))&&void 0!==h.pts?(y.isAAC?D(h):P(h),y.pesData=null):(k&&k.size&&u.logger.log("last AAC PES packet truncated,might overlap between fragments"),y.pesData=k),R&&(h=O(R))&&void 0!==h.pts?(I(h),m.pesData=null):m.pesData=R,null==this.sampleAes?this.remuxer.remux(y,p,m,this._txtTrack,r,i,a):this.decryptAndRemux(y,p,m,this._txtTrack,r,i,a)}},{key:"decryptAndRemux",value:function(e,t,r,i,a,n,o){if(e.samples&&e.isAAC){var s=this;this.sampleAes.decryptAacSamples(e.samples,0,function(){s.decryptAndRemuxAvc(e,t,r,i,a,n,o)})}else this.decryptAndRemuxAvc(e,t,r,i,a,n,o)}},{key:"decryptAndRemuxAvc",value:function(e,t,r,i,a,n,o){if(t.samples){var s=this;this.sampleAes.decryptAvcSamples(t.samples,0,0,function(){s.remuxer.remux(e,t,r,i,a,n,o)})}else this.remuxer.remux(e,t,r,i,a,n,o)}},{key:"destroy",value:function(){this._initPTS=this._initDTS=void 0,this._duration=0}},{key:"_parsePAT",value:function(e,t){return(31&e[t+10])<<8|e[t+11]}},{key:"_parsePMT",value:function(e,t,r,i){var a,n=void 0,o={audio:-1,avc:-1,id3:-1,isAAC:!0};for(a=t+3+((15&e[t+1])<<8|e[t+2])-4,t+=12+((15&e[t+10])<<8|e[t+11]);t<a;){switch(n=(31&e[t+1])<<8|e[t+2],e[t]){case 207:if(!i){u.logger.log("unkown stream type:"+e[t]);break}case 15:-1===o.audio&&(o.audio=n);break;case 21:-1===o.id3&&(o.id3=n);break;case 219:if(!i){u.logger.log("unkown stream type:"+e[t]);break}case 27:-1===o.avc&&(o.avc=n);break;case 3:case 4:r?-1===o.audio&&(o.audio=n,o.isAAC=!1):u.logger.log("MPEG audio found, not supported in this browser for now");break;case 36:u.logger.warn("HEVC stream type found, not supported for now");break;default:u.logger.log("unkown stream type:"+e[t])}t+=5+((15&e[t+3])<<8|e[t+4])}return o}},{key:"_parsePES",value:function(e){var t=0,r=void 0,i=void 0,a=void 0,n=void 0,o=void 0,s=void 0,l=void 0,d=void 0,f=e.data;if(!e||0===e.size)return null;for(;f[0].length<19&&f.length>1;){var c=new Uint8Array(f[0].length+f[1].length);c.set(f[0]),c.set(f[1],f[0].length),f[0]=c,f.splice(1,1)}if(1===((r=f[0])[0]<<16)+(r[1]<<8)+r[2]){if((a=(r[4]<<8)+r[5])&&a>e.size-6)return null;192&(i=r[7])&&((s=536870912*(14&r[9])+4194304*(255&r[10])+16384*(254&r[11])+128*(255&r[12])+(254&r[13])/2)>4294967295&&(s-=8589934592),64&i?((l=536870912*(14&r[14])+4194304*(255&r[15])+16384*(254&r[16])+128*(255&r[17])+(254&r[18])/2)>4294967295&&(l-=8589934592),s-l>54e5&&(u.logger.warn(Math.round((s-l)/9e4)+"s delta between PTS and DTS, align them"),s=l)):l=s),d=(n=r[8])+9,e.size-=d,o=new Uint8Array(e.size);for(var h=0,v=f.length;h<v;h++){var g=(r=f[h]).byteLength;if(d){if(d>g){d-=g;continue}r=r.subarray(d),g-=d,d=0}o.set(r,t),t+=g}return a&&(a-=n+3),{data:o,pts:s,dts:l,len:a}}return null}},{key:"pushAccesUnit",value:function(e,t){if(e.units.length&&e.frame){var r=t.samples,i=r.length;!this.config.forceKeyFrameOnDiscontinuity||!0===e.key||t.sps&&(i||this.contiguous)?(e.id=i,r.push(e)):t.dropped++}e.debug.length&&u.logger.log(e.pts+"/"+e.dts+":"+e.debug)}},{key:"_parseAVCPES",value:function(e,t){var r=this,i=this._avcTrack,a=this._parseAVCNALu(e.data),n=void 0,o=this.avcSample,l=void 0,u=!1,d=void 0,f=this.pushAccesUnit.bind(this),c=function(e,t,r,i){return{key:e,pts:t,dts:r,units:[],debug:i}};e.data=null,o&&a.length&&!i.audFound&&(f(o,i),o=this.avcSample=c(!1,e.pts,e.dts,"")),a.forEach(function(t){switch(t.type){case 1:l=!0,o||(o=r.avcSample=c(!0,e.pts,e.dts,"")),o.frame=!0;var a=t.data;if(u&&a.length>4){var h=new s.default(a).readSliceType();2!==h&&4!==h&&7!==h&&9!==h||(o.key=!0)}break;case 5:l=!0,o||(o=r.avcSample=c(!0,e.pts,e.dts,"")),o.key=!0,o.frame=!0;break;case 6:l=!0,(n=new s.default(r.discardEPB(t.data))).readUByte();for(var v=0,g=0,p=!1,y=0;!p&&n.bytesAvailable>1;){v=0;do{v+=y=n.readUByte()}while(255===y);g=0;do{g+=y=n.readUByte()}while(255===y);if(4===v&&0!==n.bytesAvailable){if(p=!0,181===n.readUByte())if(49===n.readUShort())if(1195456820===n.readUInt())if(3===n.readUByte()){var m=n.readUByte(),b=31&m,E=[m,n.readUByte()];for(d=0;d<b;d++)E.push(n.readUByte()),E.push(n.readUByte()),E.push(n.readUByte());r._insertSampleInOrder(r._txtTrack.samples,{type:3,pts:e.pts,bytes:E})}}else if(g<n.bytesAvailable)for(d=0;d<g;d++)n.readUByte()}break;case 7:if(l=!0,u=!0,!i.sps){var _=(n=new s.default(t.data)).readSPS();i.width=_.width,i.height=_.height,i.pixelRatio=_.pixelRatio,i.sps=[t.data],i.duration=r._duration;var T=t.data.subarray(1,4),S="avc1.";for(d=0;d<3;d++){var k=T[d].toString(16);k.length<2&&(k="0"+k),S+=k}i.codec=S}break;case 8:l=!0,i.pps||(i.pps=[t.data]);break;case 9:l=!1,i.audFound=!0,o&&f(o,i),o=r.avcSample=c(!1,e.pts,e.dts,"");break;case 12:l=!1;break;default:l=!1,o&&(o.debug+="unknown NAL "+t.type+" ")}o&&l&&o.units.push(t)}),t&&o&&(f(o,i),this.avcSample=null)}},{key:"_insertSampleInOrder",value:function(e,t){var r=e.length;if(r>0){if(t.pts>=e[r-1].pts)e.push(t);else for(var i=r-1;i>=0;i--)if(t.pts<e[i].pts){e.splice(i,0,t);break}}else e.push(t)}},{key:"_getLastNalUnit",value:function(){var e=this.avcSample,t=void 0;if(!e||0===e.units.length){var r=this._avcTrack.samples;e=r[r.length-1]}if(e){var i=e.units;t=i[i.length-1]}return t}},{key:"_parseAVCNALu",value:function(e){var t=0,r=e.byteLength,i=void 0,a=void 0,n=this._avcTrack,o=n.naluState||0,s=o,l=[],u=void 0,d=-1,f=void 0;for(-1===o&&(d=0,f=31&e[0],o=0,t=1);t<r;)if(i=e[t++],o)if(1!==o)if(i)if(1===i){if(d>=0)u={data:e.subarray(d,t-o-1),type:f},l.push(u);else{var c=this._getLastNalUnit();if(c&&(s&&t<=4-s&&c.state&&(c.data=c.data.subarray(0,c.data.byteLength-s)),(a=t-o-1)>0)){var h=new Uint8Array(c.data.byteLength+a);h.set(c.data,0),h.set(e.subarray(0,a),c.data.byteLength),c.data=h}}t<r?(d=t,f=31&e[t],o=0):o=-1}else o=0;else o=3;else o=i?0:2;else o=i?0:1;if(d>=0&&o>=0&&(u={data:e.subarray(d,r),type:f,state:o},l.push(u)),0===l.length){var v=this._getLastNalUnit();if(v){var g=new Uint8Array(v.data.byteLength+e.byteLength);g.set(v.data,0),g.set(e,v.data.byteLength),v.data=g}}return n.naluState=o,l}},{key:"discardEPB",value:function(e){for(var t,r=e.byteLength,i=[],a=1,n=void 0;a<r-2;)0===e[a]&&0===e[a+1]&&3===e[a+2]?(i.push(a+2),a+=2):a++;if(0===i.length)return e;t=r-i.length,n=new Uint8Array(t);var o=0;for(a=0;a<t;o++,a++)o===i[0]&&(o++,i.shift()),n[a]=e[o];return n}},{key:"_parseAACPES",value:function(e){var t,r,i=this._audioTrack,n=e.data,s=e.pts,l=this.aacOverFlow,f=this.aacLastPTS,c=void 0,h=void 0,v=void 0;if(l){var g=new Uint8Array(l.byteLength+n.byteLength);g.set(l,0),g.set(n,l.byteLength),n=g}for(h=0,r=n.length;h<r-1&&!a.isHeader(n,h);h++);if(h){var p=void 0,y=void 0;if(h<r-1?(p="AAC PES did not start with ADTS header,offset:"+h,y=!1):(p="no ADTS header found in AAC PES",y=!0),u.logger.warn("parsing error:"+p),this.observer.trigger(o.default.ERROR,{type:d.ErrorTypes.MEDIA_ERROR,details:d.ErrorDetails.FRAG_PARSING_ERROR,fatal:y,reason:p}),y)return}if(a.initTrackConfig(i,this.observer,n,h,this.audioCodec),c=0,t=a.getFrameDuration(i.samplerate),l&&f){var m=f+t;Math.abs(m-s)>1&&(u.logger.log("AAC: align PTS for overlapping frames by "+Math.round((m-s)/90)),s=m)}for(;h<r;)if(a.isHeader(n,h)&&h+5<r){var b=a.appendFrame(i,n,h,s,c);if(!b)break;h+=b.length,v=b.sample.pts,c++}else h++;l=h<r?n.subarray(h,r):null,this.aacOverFlow=l,this.aacLastPTS=v}},{key:"_parseMPEGPES",value:function(e){for(var t=e.data,r=t.length,i=0,a=0,o=e.pts;a<r;)if(n.default.isHeader(t,a)){var s=n.default.appendFrame(this._audioTrack,t,a,o,i);if(!s)break;a+=s.length,i++}else a++}},{key:"_parseID3PES",value:function(e){this._id3Track.samples.push(e)}}],[{key:"probe",value:function(t){var r=e._syncOffset(t);return!(r<0)&&(r&&u.logger.warn("MPEG2-TS detected but first sync word found @ offset "+r+", junk ahead ?"),!0)}},{key:"_syncOffset",value:function(e){for(var t=Math.min(1e3,e.length-564),r=0;r<t;){if(71===e[r]&&71===e[r+188]&&71===e[r+376])return r;r++}return-1}},{key:"createTrack",value:function(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:c[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],len:0,dropped:"video"===e?0:void 0,isAAC:"audio"===e||void 0,duration:"audio"===e?t:void 0}}}]),e}();t.default=h,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(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,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),a=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(r(23)),n=r(0),o=function(e){return e&&e.__esModule?e:{default:e}}(r(8));var s=function(){function e(t,r,i){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.observer=t,this.config=i,this.remuxer=r}return i(e,[{key:"resetInitSegment",value:function(e,t,r,i){this._audioTrack={container:"audio/adts",type:"audio",id:0,sequenceNumber:0,isAAC:!0,samples:[],len:0,manifestCodec:t,duration:i,inputTimeScale:9e4}}},{key:"resetTimeStamp",value:function(){}},{key:"append",value:function(e,t,r,i){for(var s=this._audioTrack,l=o.default.getID3Data(e,0)||[],u=o.default.getTimeStamp(l),d=Number.isFinite(u)?90*u:9e4*t,f=0,c=d,h=e.length,v=l.length,g=[{pts:c,dts:c,data:l}];v<h-1;)if(a.isHeader(e,v)&&v+5<h){a.initTrackConfig(s,this.observer,e,v,s.manifestCodec);var p=a.appendFrame(s,e,v,d,f);if(!p){n.logger.log("Unable to parse AAC frame");break}v+=p.length,c=p.sample.pts,f++}else o.default.isHeader(e,v)?(l=o.default.getID3Data(e,v),g.push({pts:c,dts:c,data:l}),v+=l.length):v++;this.remuxer.remux(s,{samples:[]},{samples:g,inputTimeScale:9e4},{samples:[]},t,r,i)}},{key:"destroy",value:function(){}}],[{key:"probe",value:function(e){if(!e)return!1;for(var t=(o.default.getID3Data(e,0)||[]).length,r=e.length;t<r;t++)if(a.probe(e,t))return n.logger.log("ADTS sync word found !"),!0;return!1}}]),e}();t.default=s,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(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,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}();function a(e){var t=e.byteLength,r=t&&new DataView(e).getUint8(t-1);return r?e.slice(0,t-r):e}t.removePadding=a;var n=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.initTable()}return i(e,[{key:"uint8ArrayToUint32Array_",value:function(e){for(var t=new DataView(e),r=new Uint32Array(4),i=0;i<4;i++)r[i]=t.getUint32(4*i);return r}},{key:"initTable",value:function(){var e=this.sBox,t=this.invSBox,r=this.subMix,i=r[0],a=r[1],n=r[2],o=r[3],s=this.invSubMix,l=s[0],u=s[1],d=s[2],f=s[3],c=new Uint32Array(256),h=0,v=0,g=0;for(g=0;g<256;g++)c[g]=g<128?g<<1:g<<1^283;for(g=0;g<256;g++){var p=v^v<<1^v<<2^v<<3^v<<4;p=p>>>8^255&p^99,e[h]=p,t[p]=h;var y=c[h],m=c[y],b=c[m],E=257*c[p]^16843008*p;i[h]=E<<24|E>>>8,a[h]=E<<16|E>>>16,n[h]=E<<8|E>>>24,o[h]=E,E=16843009*b^65537*m^257*y^16843008*h,l[p]=E<<24|E>>>8,u[p]=E<<16|E>>>16,d[p]=E<<8|E>>>24,f[p]=E,h?(h=y^c[c[c[b^y]]],v^=c[c[v]]):h=v=1}}},{key:"expandKey",value:function(e){for(var t=this.uint8ArrayToUint32Array_(e),r=!0,i=0;i<t.length&&r;)r=t[i]===this.key[i],i++;if(!r){this.key=t;var a=this.keySize=t.length;if(4!==a&&6!==a&&8!==a)throw new Error("Invalid aes key size="+a);var n=this.ksRows=4*(a+6+1),o=void 0,s=void 0,l=this.keySchedule=new Uint32Array(n),u=this.invKeySchedule=new Uint32Array(n),d=this.sBox,f=this.rcon,c=this.invSubMix,h=c[0],v=c[1],g=c[2],p=c[3],y=void 0,m=void 0;for(o=0;o<n;o++)o<a?y=l[o]=t[o]:(m=y,o%a==0?(m=d[(m=m<<8|m>>>24)>>>24]<<24|d[m>>>16&255]<<16|d[m>>>8&255]<<8|d[255&m],m^=f[o/a|0]<<24):a>6&&o%a==4&&(m=d[m>>>24]<<24|d[m>>>16&255]<<16|d[m>>>8&255]<<8|d[255&m]),l[o]=y=(l[o-a]^m)>>>0);for(s=0;s<n;s++)o=n-s,m=3&s?l[o]:l[o-4],u[s]=s<4||o<=4?m:h[d[m>>>24]]^v[d[m>>>16&255]]^g[d[m>>>8&255]]^p[d[255&m]],u[s]=u[s]>>>0}}},{key:"networkToHostOrderSwap",value:function(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24}},{key:"decrypt",value:function(e,t,r,i){for(var n=this.keySize+6,o=this.invKeySchedule,s=this.invSBox,l=this.invSubMix,u=l[0],d=l[1],f=l[2],c=l[3],h=this.uint8ArrayToUint32Array_(r),v=h[0],g=h[1],p=h[2],y=h[3],m=new Int32Array(e),b=new Int32Array(m.length),E=void 0,_=void 0,T=void 0,S=void 0,k=void 0,R=void 0,A=void 0,w=void 0,O=void 0,L=void 0,D=void 0,P=void 0,I=void 0,C=void 0,x=this.networkToHostOrderSwap;t<m.length;){for(O=x(m[t]),L=x(m[t+1]),D=x(m[t+2]),P=x(m[t+3]),k=O^o[0],R=P^o[1],A=D^o[2],w=L^o[3],I=4,C=1;C<n;C++)E=u[k>>>24]^d[R>>16&255]^f[A>>8&255]^c[255&w]^o[I],_=u[R>>>24]^d[A>>16&255]^f[w>>8&255]^c[255&k]^o[I+1],T=u[A>>>24]^d[w>>16&255]^f[k>>8&255]^c[255&R]^o[I+2],S=u[w>>>24]^d[k>>16&255]^f[R>>8&255]^c[255&A]^o[I+3],k=E,R=_,A=T,w=S,I+=4;E=s[k>>>24]<<24^s[R>>16&255]<<16^s[A>>8&255]<<8^s[255&w]^o[I],_=s[R>>>24]<<24^s[A>>16&255]<<16^s[w>>8&255]<<8^s[255&k]^o[I+1],T=s[A>>>24]<<24^s[w>>16&255]<<16^s[k>>8&255]<<8^s[255&R]^o[I+2],S=s[w>>>24]<<24^s[k>>16&255]<<16^s[R>>8&255]<<8^s[255&A]^o[I+3],I+=3,b[t]=x(E^v),b[t+1]=x(S^g),b[t+2]=x(T^p),b[t+3]=x(_^y),v=O,g=L,p=D,y=P,t+=4}return i?a(b.buffer):b.buffer}},{key:"destroy",value:function(){this.key=void 0,this.keySize=void 0,this.ksRows=void 0,this.sBox=void 0,this.invSBox=void 0,this.subMix=void 0,this.invSubMix=void 0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.rcon=void 0}}]),e}();t.default=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(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,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}();var a=function(){function e(t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.subtle=t,this.key=r}return i(e,[{key:"expandKey",value:function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])}}]),e}();t.default=a,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(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,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}();var a=function(){function e(t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.subtle=t,this.aesIV=r}return i(e,[{key:"decrypt",value:function(e,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e)}}]),e}();t.default=a,e.exports=t.default},function(e,t,r){function i(e){var t={};function r(i){if(t[i])return t[i].exports;var a=t[i]={i:i,l:!1,exports:{}};return e[i].call(a.exports,a,a.exports,r),a.l=!0,a.exports}r.m=e,r.c=t,r.i=function(e){return e},r.d=function(e,t,i){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:i})},r.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="/",r.oe=function(e){throw console.error(e),e};var i=r(r.s=ENTRY_MODULE);return i.default||i}var a="[\\.|\\-|\\+|\\w|/|@]+",n="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+a+").*?\\)";function o(e){return(e+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function s(e){return!isNaN(1*e)}function l(e,t,i){var l={};l[i]=[];var u=t.toString(),d=u.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!d)return l;for(var f,c=d[1],h=new RegExp("(\\\\n|\\W)"+o(c)+n,"g");f=h.exec(u);)"dll-reference"!==f[3]&&l[i].push(f[3]);for(h=new RegExp("\\("+o(c)+'\\("(dll-reference\\s('+a+'))"\\)\\)'+n,"g");f=h.exec(u);)e[f[2]]||(l[i].push(f[1]),e[f[2]]=r(f[1]).m),l[f[2]]=l[f[2]]||[],l[f[2]].push(f[4]);for(var v=Object.keys(l),g=0;g<v.length;g++)for(var p=0;p<l[v[g]].length;p++)s(l[v[g]][p])&&(l[v[g]][p]=1*l[v[g]][p]);return l}function u(e){return Object.keys(e).reduce(function(t,r){return t||e[r].length>0},!1)}e.exports=function(e,t){t=t||{};var a={main:r.m},n=t.all?{main:Object.keys(a.main)}:function(e,t){for(var r={main:[t]},i={main:[]},a={main:{}};u(r);)for(var n=Object.keys(r),o=0;o<n.length;o++){var s=n[o],d=r[s].pop();if(a[s]=a[s]||{},!a[s][d]&&e[s][d]){a[s][d]=!0,i[s]=i[s]||[],i[s].push(d);for(var f=l(e,e[s][d],s),c=Object.keys(f),h=0;h<c.length;h++)r[c[h]]=r[c[h]]||[],r[c[h]]=r[c[h]].concat(f[c[h]])}}return i}(a,e),o="";Object.keys(n).filter(function(e){return"main"!==e}).forEach(function(e){for(var t=0;n[e][t];)t++;n[e].push(t),a[e][t]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",o=o+"var "+e+" = ("+i.toString().replace("ENTRY_MODULE",JSON.stringify(t))+")({"+n[e].map(function(t){return JSON.stringify(t)+": "+a[e][t].toString()}).join(",")+"});\n"}),o=o+"new (("+i.toString().replace("ENTRY_MODULE",JSON.stringify(e))+")({"+n.main.map(function(e){return JSON.stringify(e)+": "+a.main[e].toString()}).join(",")+"}))(self);";var s=new window.Blob([o],{type:"text/javascript"});if(t.bare)return s;var d=(window.URL||window.webkitURL||window.mozURL||window.msURL).createObjectURL(s),f=new window.Worker(d);return f.objectURL=d,f}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(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,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),a=E(r(9)),n=r(4),o=E(r(26)),s=E(r(1)),l=r(6),u=E(r(14)),d=E(r(30)),f=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(r(5)),c=E(r(20)),h=r(2),v=r(0),g=r(19),p=r(18),y=E(r(55)),m=r(11),b=E(m);function E(e){return e&&e.__esModule?e:{default:e}}var _=function(e){function t(e,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var i=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,s.default.MEDIA_ATTACHED,s.default.MEDIA_DETACHING,s.default.MANIFEST_LOADING,s.default.MANIFEST_PARSED,s.default.LEVEL_LOADED,s.default.KEY_LOADED,s.default.FRAG_LOADED,s.default.FRAG_LOAD_EMERGENCY_ABORTED,s.default.FRAG_PARSING_INIT_SEGMENT,s.default.FRAG_PARSING_DATA,s.default.FRAG_PARSED,s.default.ERROR,s.default.AUDIO_TRACK_SWITCHING,s.default.AUDIO_TRACK_SWITCHED,s.default.BUFFER_CREATED,s.default.BUFFER_APPENDED,s.default.BUFFER_FLUSHED));return i.fragmentTracker=r,i.config=e.config,i.audioCodecSwap=!1,i._state=m.State.STOPPED,i.stallReported=!1,i.gapController=null,i}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,b.default),i(t,[{key:"startLoad",value:function(e){if(this.levels){var t=this.lastCurrentTime,r=this.hls;if(this.stopLoad(),this.setInterval(100),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var i=r.startLevel;-1===i&&(i=0,this.bitrateTest=!0),this.level=r.nextLoadLevel=i,this.loadedmetadata=!1}t>0&&-1===e&&(v.logger.log("override startPosition with lastCurrentTime @"+t.toFixed(3)),e=t),this.state=m.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this.forceStartLoad=!0,this.state=m.State.STOPPED}},{key:"stopLoad",value:function(){this.forceStartLoad=!1,function e(t,r,i){null===t&&(t=Function.prototype);var a=Object.getOwnPropertyDescriptor(t,r);if(void 0===a){var n=Object.getPrototypeOf(t);return null===n?void 0:e(n,r,i)}if("value"in a)return a.value;var o=a.get;return void 0!==o?o.call(i):void 0}(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"stopLoad",this).call(this)}},{key:"doTick",value:function(){switch(this.state){case m.State.BUFFER_FLUSHING:this.fragLoadError=0;break;case m.State.IDLE:this._doTickIdle();break;case m.State.WAITING_LEVEL:var e=this.levels[this.level];e&&e.details&&(this.state=m.State.IDLE);break;case m.State.FRAG_LOADING_WAITING_RETRY:var t=window.performance.now(),r=this.retryDate;(!r||t>=r||this.media&&this.media.seeking)&&(v.logger.log("mediaController: retryDate reached, switch back to IDLE state"),this.state=m.State.IDLE);break;case m.State.ERROR:case m.State.STOPPED:case m.State.FRAG_LOADING:case m.State.PARSING:case m.State.PARSED:case m.State.ENDED:}this._checkBuffer(),this._checkFragmentChanged()}},{key:"_doTickIdle",value:function(){var e=this.hls,t=e.config,r=this.media;if(void 0!==this.levelLastLoaded&&(r||!this.startFragRequested&&t.startFragPrefetch)){var i=void 0;i=this.loadedmetadata?r.currentTime:this.nextLoadPosition;var a=e.nextLoadLevel,o=this.levels[a];if(o){var l=o.bitrate,u=void 0;u=l?Math.max(8*t.maxBufferSize/l,t.maxBufferLength):t.maxBufferLength,u=Math.min(u,t.maxMaxBufferLength);var d=n.BufferHelper.bufferInfo(this.mediaBuffer?this.mediaBuffer:r,i,t.maxBufferHole),f=d.len;if(!(f>=u)){v.logger.trace("buffer length of "+f.toFixed(3)+" is below max of "+u.toFixed(3)+". checking for more payload ..."),this.level=e.nextLoadLevel=a;var c=o.details;if(!c||c.live&&this.levelLastLoaded!==a)this.state=m.State.WAITING_LEVEL;else{if(this._streamEnded(d,c)){var h={};return this.altAudio&&(h.type="video"),this.hls.trigger(s.default.BUFFER_EOS,h),void(this.state=m.State.ENDED)}this._fetchPayloadOrEos(i,d,c)}}}}}},{key:"_fetchPayloadOrEos",value:function(e,t,r){var i=this.fragPrevious,a=this.level,n=r.fragments,o=n.length;if(0!==o){var s=n[0].start,l=n[o-1].start+n[o-1].duration,u=t.end,d=void 0;if(r.initSegment&&!r.initSegment.data)d=r.initSegment;else if(r.live){var f=this.config.initialLiveManifestSize;if(o<f)return void v.logger.warn("Can not start playback of a level, reason: not enough fragments "+o+" < "+f);if(null===(d=this._ensureFragmentAtLivePoint(r,u,s,l,i,n,o)))return}else u<s&&(d=n[0]);d||(d=this._findFragment(s,i,o,n,u,l,r)),d&&(d.encrypted?(v.logger.log("Loading key for "+d.sn+" of ["+r.startSN+" ,"+r.endSN+"],level "+a),this._loadKey(d)):(v.logger.log("Loading "+d.sn+" of ["+r.startSN+" ,"+r.endSN+"],level "+a+", currentTime:"+e.toFixed(3)+",bufferEnd:"+u.toFixed(3)),this._loadFragment(d)))}}},{key:"_ensureFragmentAtLivePoint",value:function(e,t,r,i,n,o,s){var l=this.hls.config,u=this.media,d=void 0,f=void 0!==l.liveMaxLatencyDuration?l.liveMaxLatencyDuration:l.liveMaxLatencyDurationCount*e.targetduration;if(t<Math.max(r-l.maxFragLookUpTolerance,i-f)){var c=this.liveSyncPosition=this.computeLivePosition(r,e);v.logger.log("buffer end: "+t.toFixed(3)+" is located too far from the end of live sliding playlist, reset currentTime to : "+c.toFixed(3)),t=c,u&&u.readyState&&u.duration>c&&(u.currentTime=c),this.nextLoadPosition=c}if(e.PTSKnown&&t>i&&u&&u.readyState)return null;if(this.startFragRequested&&!e.PTSKnown){if(n)if(e.hasProgramDateTime)v.logger.log("live playlist, switching playlist, load frag with same PDT: "+n.programDateTime),d=(0,p.findFragmentByPDT)(o,n.endProgramDateTime,l.maxFragLookUpTolerance);else{var h=n.sn+1;if(h>=e.startSN&&h<=e.endSN){var g=o[h-e.startSN];n.cc===g.cc&&(d=g,v.logger.log("live playlist, switching playlist, load frag with next SN: "+d.sn))}d||(d=a.default.search(o,function(e){return n.cc-e.cc}))&&v.logger.log("live playlist, switching playlist, load frag with same CC: "+d.sn)}d||(d=o[Math.min(s-1,Math.round(s/2))],v.logger.log("live playlist, switching playlist, unknown, load middle frag : "+d.sn))}return d}},{key:"_findFragment",value:function(e,t,r,i,a,n,o){var s=this.hls.config,l=void 0;if(a<n){var u=a>n-s.maxFragLookUpTolerance?0:s.maxFragLookUpTolerance;l=(0,p.findFragmentByPTS)(t,i,a,u)}else l=i[r-1];if(l){var d=l.sn-o.startSN,f=t&&l.level===t.level,c=i[d-1],h=i[d+1];if(t&&l.sn===t.sn)if(f&&!l.backtracked)if(l.sn<o.endSN){var g=t.deltaPTS;g&&g>s.maxBufferHole&&t.dropped&&d?(l=c,v.logger.warn("SN just loaded, with large PTS gap between audio and video, maybe frag is not starting with a keyframe ? load previous one to try to overcome this")):(l=h,v.logger.log("SN just loaded, load next one: "+l.sn,l))}else l=null;else l.backtracked&&(h&&h.backtracked?(v.logger.warn("Already backtracked from fragment "+h.sn+", will not backtrack to fragment "+l.sn+". Loading fragment "+h.sn),l=h):(v.logger.warn("Loaded fragment with dropped frames, backtracking 1 segment to find a keyframe"),l.dropped=0,c?(l=c).backtracked=!0:d&&(l=null)))}return l}},{key:"_loadKey",value:function(e){this.state=m.State.KEY_LOADING,this.hls.trigger(s.default.KEY_LOADING,{frag:e})}},{key:"_loadFragment",value:function(e){var t=this.fragmentTracker.getState(e);this.fragCurrent=e,this.startFragRequested=!0,Number.isFinite(e.sn)&&!e.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),e.backtracked||t===l.FragmentState.NOT_LOADED||t===l.FragmentState.PARTIAL?(e.autoLevel=this.hls.autoLevelEnabled,e.bitrateTest=this.bitrateTest,this.hls.trigger(s.default.FRAG_LOADING,{frag:e}),this.demuxer||(this.demuxer=new o.default(this.hls,"main")),this.state=m.State.FRAG_LOADING):t===l.FragmentState.APPENDING&&this._reduceMaxBufferLength(e.duration)&&this.fragmentTracker.removeFragment(e)}},{key:"getBufferedFrag",value:function(e){return this.fragmentTracker.getBufferedFrag(e,d.default.LevelType.MAIN)}},{key:"followingBufferedFrag",value:function(e){return e?this.getBufferedFrag(e.endPTS+.5):null}},{key:"_checkFragmentChanged",value:function(){var e=void 0,t=void 0,r=this.media;if(r&&r.readyState&&!1===r.seeking&&((t=r.currentTime)>this.lastCurrentTime&&(this.lastCurrentTime=t),n.BufferHelper.isBuffered(r,t)?e=this.getBufferedFrag(t):n.BufferHelper.isBuffered(r,t+.1)&&(e=this.getBufferedFrag(t+.1)),e)){var i=e;if(i!==this.fragPlaying){this.hls.trigger(s.default.FRAG_CHANGED,{frag:i});var a=i.level;this.fragPlaying&&this.fragPlaying.level===a||this.hls.trigger(s.default.LEVEL_SWITCHED,{level:a}),this.fragPlaying=i}}}},{key:"immediateLevelSwitch",value:function(){if(v.logger.log("immediateLevelSwitch"),!this.immediateSwitch){this.immediateSwitch=!0;var e=this.media,t=void 0;e?(t=e.paused,e.pause()):t=!0,this.previouslyPaused=t}var r=this.fragCurrent;r&&r.loader&&r.loader.abort(),this.fragCurrent=null,this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}},{key:"immediateLevelSwitchEnd",value:function(){var e=this.media;e&&e.buffered.length&&(this.immediateSwitch=!1,n.BufferHelper.isBuffered(e,e.currentTime)&&(e.currentTime-=1e-4),this.previouslyPaused||e.play())}},{key:"nextLevelSwitch",value:function(){var e=this.media;if(e&&e.readyState){var t,r=void 0,i=void 0;if((t=this.getBufferedFrag(e.currentTime))&&t.startPTS>1&&this.flushMainBuffer(0,t.startPTS-1),e.paused)r=0;else{var a=this.hls.nextLoadLevel,n=this.levels[a],o=this.fragLastKbps;r=o&&this.fragCurrent?this.fragCurrent.duration*n.bitrate/(1e3*o)+1:0}if((i=this.getBufferedFrag(e.currentTime+r))&&(i=this.followingBufferedFrag(i))){var s=this.fragCurrent;s&&s.loader&&s.loader.abort(),this.fragCurrent=null,this.flushMainBuffer(i.maxStartPTS,Number.POSITIVE_INFINITY)}}}},{key:"flushMainBuffer",value:function(e,t){this.state=m.State.BUFFER_FLUSHING;var r={startOffset:e,endOffset:t};this.altAudio&&(r.type="video"),this.hls.trigger(s.default.BUFFER_FLUSHING,r)}},{key:"onMediaAttached",value:function(e){var t=this.media=this.mediaBuffer=e.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),this.onvended=this.onMediaEnded.bind(this),t.addEventListener("seeking",this.onvseeking),t.addEventListener("seeked",this.onvseeked),t.addEventListener("ended",this.onvended);var r=this.config;this.levels&&r.autoStartLoad&&this.hls.startLoad(r.startPosition),this.gapController=new y.default(r,t,this.fragmentTracker,this.hls)}},{key:"onMediaDetaching",value:function(){var e=this.media;e&&e.ended&&(v.logger.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0);var t=this.levels;t&&t.forEach(function(e){e.details&&e.details.fragments.forEach(function(e){e.backtracked=void 0})}),e&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("seeked",this.onvseeked),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvseeked=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.stopLoad()}},{key:"onMediaSeeked",value:function(){var e=this.media,t=e?e.currentTime:void 0;Number.isFinite(t)&&v.logger.log("media seeked to "+t.toFixed(3)),this.tick()}},{key:"onManifestLoading",value:function(){v.logger.log("trigger BUFFER_RESET"),this.hls.trigger(s.default.BUFFER_RESET),this.fragmentTracker.removeAllFragments(),this.stalled=!1,this.startPosition=this.lastCurrentTime=0}},{key:"onManifestParsed",value:function(e){var t=!1,r=!1,i=void 0;e.levels.forEach(function(e){(i=e.audioCodec)&&(-1!==i.indexOf("mp4a.40.2")&&(t=!0),-1!==i.indexOf("mp4a.40.5")&&(r=!0))}),this.audioCodecSwitch=t&&r,this.audioCodecSwitch&&v.logger.log("both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=e.levels,this.startFragRequested=!1;var a=this.config;(a.autoStartLoad||this.forceStartLoad)&&this.hls.startLoad(a.startPosition)}},{key:"onLevelLoaded",value:function(e){var t=e.details,r=e.level,i=this.levels[this.levelLastLoaded],a=this.levels[r],n=t.totalduration,o=0;if(v.logger.log("level "+r+" loaded ["+t.startSN+","+t.endSN+"],duration:"+n),t.live){var l=a.details;l&&t.fragments.length>0?(f.mergeDetails(l,t),o=t.fragments[0].start,this.liveSyncPosition=this.computeLivePosition(o,l),t.PTSKnown&&Number.isFinite(o)?v.logger.log("live playlist sliding:"+o.toFixed(3)):(v.logger.log("live playlist - outdated PTS, unknown sliding"),(0,g.alignStream)(this.fragPrevious,i,t))):(v.logger.log("live playlist - first load, unknown sliding"),t.PTSKnown=!1,(0,g.alignStream)(this.fragPrevious,i,t))}else t.PTSKnown=!1;if(a.details=t,this.levelLastLoaded=r,this.hls.trigger(s.default.LEVEL_UPDATED,{details:t,level:r}),!1===this.startFragRequested){if(-1===this.startPosition||-1===this.lastCurrentTime){var u=t.startTimeOffset;Number.isFinite(u)?(u<0&&(v.logger.log("negative start time offset "+u+", count from end of last fragment"),u=o+n+u),v.logger.log("start time offset found in playlist, adjust startPosition to "+u),this.startPosition=u):t.live?(this.startPosition=this.computeLivePosition(o,t),v.logger.log("configure startPosition to "+this.startPosition)):this.startPosition=0,this.lastCurrentTime=this.startPosition}this.nextLoadPosition=this.startPosition}this.state===m.State.WAITING_LEVEL&&(this.state=m.State.IDLE),this.tick()}},{key:"onKeyLoaded",value:function(){this.state===m.State.KEY_LOADING&&(this.state=m.State.IDLE,this.tick())}},{key:"onFragLoaded",value:function(e){var t=this.fragCurrent,r=this.hls,i=this.levels,a=this.media,n=e.frag;if(this.state===m.State.FRAG_LOADING&&t&&"main"===n.type&&n.level===t.level&&n.sn===t.sn){var l=e.stats,u=i[t.level],d=u.details;if(this.bitrateTest=!1,this.stats=l,v.logger.log("Loaded "+t.sn+" of ["+d.startSN+" ,"+d.endSN+"],level "+t.level),n.bitrateTest&&r.nextLoadLevel)this.state=m.State.IDLE,this.startFragRequested=!1,l.tparsed=l.tbuffered=window.performance.now(),r.trigger(s.default.FRAG_BUFFERED,{stats:l,frag:t,id:"main"}),this.tick();else if("initSegment"===n.sn)this.state=m.State.IDLE,l.tparsed=l.tbuffered=window.performance.now(),d.initSegment.data=e.payload,r.trigger(s.default.FRAG_BUFFERED,{stats:l,frag:t,id:"main"}),this.tick();else{v.logger.log("Parsing "+t.sn+" of ["+d.startSN+" ,"+d.endSN+"],level "+t.level+", cc "+t.cc),this.state=m.State.PARSING,this.pendingBuffering=!0,this.appended=!1,n.bitrateTest&&(n.bitrateTest=!1,this.fragmentTracker.onFragLoaded({frag:n}));var f=!(a&&a.seeking)&&(d.PTSKnown||!d.live),c=d.initSegment?d.initSegment.data:[],h=this._getAudioCodec(u);(this.demuxer=this.demuxer||new o.default(this.hls,"main")).push(e.payload,c,h,u.videoCodec,t,d.totalduration,f)}}this.fragLoadError=0}},{key:"onFragParsingInitSegment",value:function(e){var t=this.fragCurrent,r=e.frag;if(t&&"main"===e.id&&r.sn===t.sn&&r.level===t.level&&this.state===m.State.PARSING){var i=e.tracks,a=void 0,n=void 0;if(i.audio&&this.altAudio&&delete i.audio,n=i.audio){var o=this.levels[this.level].audioCodec,l=navigator.userAgent.toLowerCase();o&&this.audioCodecSwap&&(v.logger.log("swapping playlist audio codec"),o=-1!==o.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),this.audioCodecSwitch&&1!==n.metadata.channelCount&&-1===l.indexOf("firefox")&&(o="mp4a.40.5"),-1!==l.indexOf("android")&&"audio/mpeg"!==n.container&&(o="mp4a.40.2",v.logger.log("Android: force audio codec to "+o)),n.levelCodec=o,n.id=e.id}for(a in(n=i.video)&&(n.levelCodec=this.levels[this.level].videoCodec,n.id=e.id),this.hls.trigger(s.default.BUFFER_CODECS,i),i){n=i[a],v.logger.log("main track:"+a+",container:"+n.container+",codecs[level/parsed]=["+n.levelCodec+"/"+n.codec+"]");var u=n.initSegment;u&&(this.appended=!0,this.pendingBuffering=!0,this.hls.trigger(s.default.BUFFER_APPENDING,{type:a,data:u,parent:"main",content:"initSegment"}))}this.tick()}}},{key:"onFragParsingData",value:function(e){var t=this,r=this.fragCurrent,i=e.frag;if(r&&"main"===e.id&&i.sn===r.sn&&i.level===r.level&&("audio"!==e.type||!this.altAudio)&&this.state===m.State.PARSING){var a=this.levels[this.level],n=r;if(Number.isFinite(e.endPTS)||(e.endPTS=e.startPTS+r.duration,e.endDTS=e.startDTS+r.duration),!0===e.hasAudio&&n.addElementaryStream(u.default.ElementaryStreamTypes.AUDIO),!0===e.hasVideo&&n.addElementaryStream(u.default.ElementaryStreamTypes.VIDEO),v.logger.log("Parsed "+e.type+",PTS:["+e.startPTS.toFixed(3)+","+e.endPTS.toFixed(3)+"],DTS:["+e.startDTS.toFixed(3)+"/"+e.endDTS.toFixed(3)+"],nb:"+e.nb+",dropped:"+(e.dropped||0)),"video"===e.type)if(n.dropped=e.dropped,n.dropped)if(n.backtracked)v.logger.warn("Already backtracked on this fragment, appending with the gap",n.sn);else{var o=a.details;if(!o||n.sn!==o.startSN)return v.logger.warn("missing video frame(s), backtracking fragment",n.sn),this.fragmentTracker.removeFragment(n),n.backtracked=!0,this.nextLoadPosition=e.startPTS,this.state=m.State.IDLE,this.fragPrevious=n,void this.tick();v.logger.warn("missing video frame(s) on first frag, appending with gap",n.sn)}else n.backtracked=!1;var l=f.updateFragPTSDTS(a.details,n,e.startPTS,e.endPTS,e.startDTS,e.endDTS),d=this.hls;d.trigger(s.default.LEVEL_PTS_UPDATED,{details:a.details,level:this.level,drift:l,type:e.type,start:e.startPTS,end:e.endPTS}),[e.data1,e.data2].forEach(function(r){r&&r.length&&t.state===m.State.PARSING&&(t.appended=!0,t.pendingBuffering=!0,d.trigger(s.default.BUFFER_APPENDING,{type:e.type,data:r,parent:"main",content:"data"}))}),this.tick()}}},{key:"onFragParsed",value:function(e){var t=this.fragCurrent,r=e.frag;t&&"main"===e.id&&r.sn===t.sn&&r.level===t.level&&this.state===m.State.PARSING&&(this.stats.tparsed=window.performance.now(),this.state=m.State.PARSED,this._checkAppendedParsed())}},{key:"onAudioTrackSwitching",value:function(e){var t=!!e.url,r=e.id;if(!t){if(this.mediaBuffer!==this.media){v.logger.log("switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var i=this.fragCurrent;i.loader&&(v.logger.log("switching to main audio track, cancel main fragment load"),i.loader.abort()),this.fragCurrent=null,this.fragPrevious=null,this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),this.state=m.State.IDLE}var a=this.hls;a.trigger(s.default.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),a.trigger(s.default.AUDIO_TRACK_SWITCHED,{id:r}),this.altAudio=!1}}},{key:"onAudioTrackSwitched",value:function(e){var t=e.id,r=!!this.hls.audioTracks[t].url;if(r){var i=this.videoBuffer;i&&this.mediaBuffer!==i&&(v.logger.log("switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=i)}this.altAudio=r,this.tick()}},{key:"onBufferCreated",value:function(e){var t=e.tracks,r=void 0,i=void 0,a=!1;for(var n in t){var o=t[n];"main"===o.id?(i=n,r=o,"video"===n&&(this.videoBuffer=t[n].buffer)):a=!0}a&&r?(v.logger.log("alternate track found, use "+i+".buffered to schedule main fragment loading"),this.mediaBuffer=r.buffer):this.mediaBuffer=this.media}},{key:"onBufferAppended",value:function(e){if("main"===e.parent){var t=this.state;t!==m.State.PARSING&&t!==m.State.PARSED||(this.pendingBuffering=e.pending>0,this._checkAppendedParsed())}}},{key:"_checkAppendedParsed",value:function(){if(!(this.state!==m.State.PARSED||this.appended&&this.pendingBuffering)){var e=this.fragCurrent;if(e){var t=this.mediaBuffer?this.mediaBuffer:this.media;v.logger.log("main buffered : "+c.default.toString(t.buffered)),this.fragPrevious=e;var r=this.stats;r.tbuffered=window.performance.now(),this.fragLastKbps=Math.round(8*r.total/(r.tbuffered-r.tfirst)),this.hls.trigger(s.default.FRAG_BUFFERED,{stats:r,frag:e,id:"main"}),this.state=m.State.IDLE}this.tick()}}},{key:"onError",value:function(e){var t=e.frag||this.fragCurrent;if(!t||"main"===t.type){var r=!!this.media&&n.BufferHelper.isBuffered(this.media,this.media.currentTime)&&n.BufferHelper.isBuffered(this.media,this.media.currentTime+.5);switch(e.details){case h.ErrorDetails.FRAG_LOAD_ERROR:case h.ErrorDetails.FRAG_LOAD_TIMEOUT:case h.ErrorDetails.KEY_LOAD_ERROR:case h.ErrorDetails.KEY_LOAD_TIMEOUT:if(!e.fatal)if(this.fragLoadError+1<=this.config.fragLoadingMaxRetry){var i=Math.min(Math.pow(2,this.fragLoadError)*this.config.fragLoadingRetryDelay,this.config.fragLoadingMaxRetryTimeout);v.logger.warn("mediaController: frag loading failed, retry in "+i+" ms"),this.retryDate=window.performance.now()+i,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.fragLoadError++,this.state=m.State.FRAG_LOADING_WAITING_RETRY}else v.logger.error("mediaController: "+e.details+" reaches max retry, redispatch as fatal ..."),e.fatal=!0,this.state=m.State.ERROR;break;case h.ErrorDetails.LEVEL_LOAD_ERROR:case h.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==m.State.ERROR&&(e.fatal?(this.state=m.State.ERROR,v.logger.warn("streamController: "+e.details+",switch to "+this.state+" state ...")):e.levelRetry||this.state!==m.State.WAITING_LEVEL||(this.state=m.State.IDLE));break;case h.ErrorDetails.BUFFER_FULL_ERROR:"main"!==e.parent||this.state!==m.State.PARSING&&this.state!==m.State.PARSED||(r?(this._reduceMaxBufferLength(this.config.maxBufferLength),this.state=m.State.IDLE):(v.logger.warn("buffer full error also media.currentTime is not buffered, flush everything"),this.fragCurrent=null,this.flushMainBuffer(0,Number.POSITIVE_INFINITY)))}}}},{key:"_reduceMaxBufferLength",value:function(e){var t=this.config;return t.maxMaxBufferLength>=e&&(t.maxMaxBufferLength/=2,v.logger.warn("main:reduce max buffer length to "+t.maxMaxBufferLength+"s"),!0)}},{key:"_checkBuffer",value:function(){var e=this.media;if(e&&0!==e.readyState){var t=(this.mediaBuffer?this.mediaBuffer:e).buffered;!this.loadedmetadata&&t.length?(this.loadedmetadata=!0,this._seekToStartPos()):this.immediateSwitch?this.immediateLevelSwitchEnd():this.gapController.poll(this.lastCurrentTime,t)}}},{key:"onFragLoadEmergencyAborted",value:function(){this.state=m.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tick()}},{key:"onBufferFlushed",value:function(){var e=this.mediaBuffer?this.mediaBuffer:this.media;e&&this.fragmentTracker.detectEvictedFragments(u.default.ElementaryStreamTypes.VIDEO,e.buffered),this.state=m.State.IDLE,this.fragPrevious=null}},{key:"swapAudioCodec",value:function(){this.audioCodecSwap=!this.audioCodecSwap}},{key:"computeLivePosition",value:function(e,t){var r=void 0!==this.config.liveSyncDuration?this.config.liveSyncDuration:this.config.liveSyncDurationCount*t.targetduration;return e+Math.max(0,t.totalduration-r)}},{key:"_seekToStartPos",value:function(){var e=this.media,t=e.currentTime,r=e.seeking?t:this.startPosition;t!==r&&(v.logger.log("target start position not buffered, seek to buffered.start(0) "+r+" from current time "+t+" "),e.currentTime=r)}},{key:"_getAudioCodec",value:function(e){var t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&(v.logger.log("swapping playlist audio codec"),t&&(t=-1!==t.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5")),t}},{key:"state",set:function(e){if(this.state!==e){var t=this.state;this._state=e,v.logger.log("main stream:"+t+"->"+e),this.hls.trigger(s.default.STREAM_STATE_TRANSITION,{previousState:t,nextState:e})}},get:function(){return this._state}},{key:"currentLevel",get:function(){var e=this.media;if(e){var t=this.getBufferedFrag(e.currentTime);if(t)return t.level}return-1}},{key:"nextBufferedFrag",get:function(){var e=this.media;return e?this.followingBufferedFrag(this.getBufferedFrag(e.currentTime)):null}},{key:"nextLevel",get:function(){var e=this.nextBufferedFrag;return e?e.level:-1}},{key:"liveSyncPosition",get:function(){return this._liveSyncPosition},set:function(e){this._liveSyncPosition=e}}]),t}();t.default=_,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(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,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),a=l(r(1)),n=l(r(3)),o=r(2),s=r(0);function l(e){return e&&e.__esModule?e:{default:e}}var u=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var r=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,a.default.KEY_LOADING));return r.loaders={},r.decryptkey=null,r.decrypturl=null,r}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,n.default),i(t,[{key:"destroy",value:function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy()}this.loaders={},n.default.prototype.destroy.call(this)}},{key:"onKeyLoading",value:function(e){var t=e.frag,r=t.type,i=this.loaders[r],n=t.decryptdata,o=n.uri;if(o!==this.decrypturl||null===this.decryptkey){var l=this.hls.config;i&&(s.logger.warn("abort previous key loader for type:"+r),i.abort()),t.loader=this.loaders[r]=new l.loader(l),this.decrypturl=o,this.decryptkey=null;var u,d,f;u={url:o,frag:t,responseType:"arraybuffer"},d={timeout:l.fragLoadingTimeOut,maxRetry:0,retryDelay:l.fragLoadingRetryDelay,maxRetryDelay:l.fragLoadingMaxRetryTimeout},f={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)},t.loader.load(u,d,f)}else this.decryptkey&&(n.key=this.decryptkey,this.hls.trigger(a.default.KEY_LOADED,{frag:t}))}},{key:"loadsuccess",value:function(e,t,r){var i=r.frag;this.decryptkey=i.decryptdata.key=new Uint8Array(e.data),i.loader=void 0,this.loaders[i.type]=void 0,this.hls.trigger(a.default.KEY_LOADED,{frag:i})}},{key:"loaderror",value:function(e,t){var r=t.frag,i=r.loader;i&&i.abort(),this.loaders[t.type]=void 0,this.hls.trigger(a.default.ERROR,{type:o.ErrorTypes.NETWORK_ERROR,details:o.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:r,response:e})}},{key:"loadtimeout",value:function(e,t){var r=t.frag,i=r.loader;i&&i.abort(),this.loaders[t.type]=void 0,this.hls.trigger(a.default.ERROR,{type:o.ErrorTypes.NETWORK_ERROR,details:o.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:r})}}]),t}();t.default=u,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(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,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),a=l(r(1)),n=l(r(3)),o=r(2),s=r(0);function l(e){return e&&e.__esModule?e:{default:e}}var u=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var r=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,a.default.FRAG_LOADING));return r.loaders={},r}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,n.default),i(t,[{key:"destroy",value:function(){var e=this.loaders;for(var r in e){var i=e[r];i&&i.destroy()}this.loaders={},function e(t,r,i){null===t&&(t=Function.prototype);var a=Object.getOwnPropertyDescriptor(t,r);if(void 0===a){var n=Object.getPrototypeOf(t);return null===n?void 0:e(n,r,i)}if("value"in a)return a.value;var o=a.get;return void 0!==o?o.call(i):void 0}(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"destroy",this).call(this)}},{key:"onFragLoading",value:function(e){var t=e.frag,r=t.type,i=this.loaders,a=this.hls.config,n=a.fLoader,o=a.loader;t.loaded=0;var l=i[r];l&&(s.logger.warn("abort previous fragment loader for type: "+r),l.abort()),l=i[r]=t.loader=a.fLoader?new n(a):new o(a);var u,d,f=void 0;f={url:t.url,frag:t,responseType:"arraybuffer",progressData:!1};var c=t.byteRangeStartOffset,h=t.byteRangeEndOffset;Number.isFinite(c)&&Number.isFinite(h)&&(f.rangeStart=c,f.rangeEnd=h),u={timeout:a.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:a.fragLoadingMaxRetryTimeout},d={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this),onProgress:this.loadprogress.bind(this)},l.load(f,u,d)}},{key:"loadsuccess",value:function(e,t,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,n=e.data,o=r.frag;o.loader=void 0,this.loaders[o.type]=void 0,this.hls.trigger(a.default.FRAG_LOADED,{payload:n,frag:o,stats:t,networkDetails:i})}},{key:"loaderror",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=t.frag,n=i.loader;n&&n.abort(),this.loaders[i.type]=void 0,this.hls.trigger(a.default.ERROR,{type:o.ErrorTypes.NETWORK_ERROR,details:o.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:t.frag,response:e,networkDetails:r})}},{key:"loadtimeout",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=t.frag,n=i.loader;n&&n.abort(),this.loaders[i.type]=void 0,this.hls.trigger(a.default.ERROR,{type:o.ErrorTypes.NETWORK_ERROR,details:o.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t.frag,networkDetails:r})}},{key:"loadprogress",value:function(e,t,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,n=t.frag;n.loaded=e.loaded,this.hls.trigger(a.default.FRAG_LOAD_PROGRESS,{frag:n,stats:e,networkDetails:i})}}]),t}();t.default=u,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(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,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}();var a=/^(\d+)x(\d+)$/,n=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,o=function(){function e(t){for(var r in function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),"string"==typeof t&&(t=e.parseAttrList(t)),t)t.hasOwnProperty(r)&&(this[r]=t[r])}return i(e,[{key:"decimalInteger",value:function(e){var t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t}},{key:"hexadecimalInteger",value: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}},{key:"hexadecimalIntegerAsNumber",value:function(e){var t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t}},{key:"decimalFloatingPoint",value:function(e){return parseFloat(this[e])}},{key:"enumeratedString",value:function(e){return this[e]}},{key:"decimalResolution",value:function(e){var t=a.exec(this[e]);if(null!==t)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}}],[{key:"parseAttrList",value:function(e){var t=void 0,r={};for(n.lastIndex=0;null!==(t=n.exec(e));){var i=t[2];0===i.indexOf('"')&&i.lastIndexOf('"')===i.length-1&&(i=i.slice(1,-1)),r[t[1]]=i}return r}}]),e}();t.default=o,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(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,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}();var a=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.endCC=0,this.endSN=0,this.fragments=[],this.initSegment=null,this.live=!0,this.needSidxRanges=!1,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=t,this.version=null}return i(e,[{key:"hasProgramDateTime",get:function(){return!(!this.fragments[0]||!Number.isFinite(this.fragments[0].programDateTime))}}]),e}();t.default=a,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(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,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),a=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(r(10)),n=f(r(14)),o=f(r(75)),s=f(r(28)),l=f(r(74)),u=r(0),d=r(27);function f(e){return e&&e.__esModule?e:{default:e}}var c=/#EXT-X-STREAM-INF:([^\n\r]*)[\r\n]+([^\r\n]+)/g,h=/#EXT-X-MEDIA:(.*)/g,v=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/|(?!#)([\S+ ?]+)/.source,/|#EXT-X-BYTERANGE:*(.+)/.source,/|#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/|#.*/.source].join(""),"g"),g=/(?:(?:#(EXTM3U))|(?:#EXT-X-(PLAYLIST-TYPE):(.+))|(?:#EXT-X-(MEDIA-SEQUENCE): *(\d+))|(?:#EXT-X-(TARGETDURATION): *(\d+))|(?:#EXT-X-(KEY):(.+))|(?:#EXT-X-(START):(.+))|(?:#EXT-X-(ENDLIST))|(?:#EXT-X-(DISCONTINUITY-SEQ)UENCE:(\d+))|(?:#EXT-X-(DIS)CONTINUITY))|(?:#EXT-X-(VERSION):(\d+))|(?:#EXT-X-(MAP):(.+))|(?:(#)([^:]*):(.*))|(?:(#)(.*))(?:.*)\r?\n?/,p=/\.(mp4|m4s|m4v|m4a)$/i,y=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return i(e,null,[{key:"findGroup",value:function(e,t){if(!e)return null;for(var r=null,i=0;i<e.length;i++){var a=e[i];a.id===t&&(r=a)}return r}},{key:"convertAVC1ToAVCOTI",value:function(e){var t=void 0,r=e.split(".");return r.length>2?(t=r.shift()+".",t+=parseInt(r.shift()).toString(16),t+=("000"+parseInt(r.shift()).toString(16)).substr(-4)):t=e,t}},{key:"resolve",value:function(e,t){return a.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}},{key:"parseMasterPlaylist",value:function(t,r){var i=[],a=void 0;function n(e,t){["video","audio"].forEach(function(r){var i=e.filter(function(e){return(0,d.isCodecType)(e,r)});if(i.length){var a=i.filter(function(e){return 0===e.lastIndexOf("avc1",0)||0===e.lastIndexOf("mp4a",0)});t[r+"Codec"]=a.length>0?a[0]:i[0],e=e.filter(function(e){return-1===i.indexOf(e)})}}),t.unknownCodecs=e}for(c.lastIndex=0;null!=(a=c.exec(t));){var o={},s=o.attrs=new l.default(a[1]);o.url=e.resolve(a[2],r);var u=s.decimalResolution("RESOLUTION");u&&(o.width=u.width,o.height=u.height),o.bitrate=s.decimalInteger("AVERAGE-BANDWIDTH")||s.decimalInteger("BANDWIDTH"),o.name=s.NAME,n([].concat((s.CODECS||"").split(/[ ,]+/)),o),o.videoCodec&&-1!==o.videoCodec.indexOf("avc1")&&(o.videoCodec=e.convertAVC1ToAVCOTI(o.videoCodec)),i.push(o)}return i}},{key:"parseMasterPlaylistMedia",value:function(t,r,i){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],n=void 0,o=[],s=0;for(h.lastIndex=0;null!==(n=h.exec(t));){var u={},d=new l.default(n[1]);if(d.TYPE===i){if(u.groupId=d["GROUP-ID"],u.name=d.NAME,u.type=i,u.default="YES"===d.DEFAULT,u.autoselect="YES"===d.AUTOSELECT,u.forced="YES"===d.FORCED,d.URI&&(u.url=e.resolve(d.URI,r)),u.lang=d.LANGUAGE,u.name||(u.name=u.lang),a.length){var f=e.findGroup(a,u.groupId);u.audioCodec=f?f.codec:a[0].codec}u.id=s++,o.push(u)}}return o}},{key:"parseLevelPlaylist",value:function(e,t,r,i,a){var d=0,f=0,c=new o.default(t),h=new s.default,y=0,b=null,E=new n.default,_=void 0,T=void 0,S=null;for(v.lastIndex=0;null!==(_=v.exec(e));){var k=_[1];if(k){E.duration=parseFloat(k);var R=(" "+_[2]).slice(1);E.title=R||null,E.tagList.push(R?["INF",k,R]:["INF",k])}else if(_[3]){if(Number.isFinite(E.duration)){var A=d++;E.type=i,E.start=f,E.levelkey=h,E.sn=A,E.level=r,E.cc=y,E.urlId=a,E.baseurl=t,E.relurl=(" "+_[3]).slice(1),m(E,b),c.fragments.push(E),b=E,f+=E.duration,E=new n.default}}else if(_[4]){if(E.rawByteRange=(" "+_[4]).slice(1),b){var w=b.byteRangeEndOffset;w&&(E.lastByteRangeEndOffset=w)}}else if(_[5])E.rawProgramDateTime=(" "+_[5]).slice(1),E.tagList.push(["PROGRAM-DATE-TIME",E.rawProgramDateTime]),null===S&&(S=c.fragments.length);else{for(_=_[0].match(g),T=1;T<_.length&&void 0===_[T];T++);var O=(" "+_[T+1]).slice(1),L=(" "+_[T+2]).slice(1);switch(_[T]){case"#":E.tagList.push(L?[O,L]:[O]);break;case"PLAYLIST-TYPE":c.type=O.toUpperCase();break;case"MEDIA-SEQUENCE":d=c.startSN=parseInt(O);break;case"TARGETDURATION":c.targetduration=parseFloat(O);break;case"VERSION":c.version=parseInt(O);break;case"EXTM3U":break;case"ENDLIST":c.live=!1;break;case"DIS":y++,E.tagList.push(["DIS"]);break;case"DISCONTINUITY-SEQ":y=parseInt(O);break;case"KEY":var D=O,P=new l.default(D),I=P.enumeratedString("METHOD"),C=P.URI,x=P.hexadecimalInteger("IV");I&&(h=new s.default,C&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(I)>=0&&(h.method=I,h.baseuri=t,h.reluri=C,h.key=null,h.iv=x));break;case"START":var M=O,F=new l.default(M).decimalFloatingPoint("TIME-OFFSET");Number.isFinite(F)&&(c.startTimeOffset=F);break;case"MAP":var N=new l.default(O);E.relurl=N.URI,E.rawByteRange=N.BYTERANGE,E.baseurl=t,E.level=r,E.type=i,E.sn="initSegment",c.initSegment=E,(E=new n.default).rawProgramDateTime=c.initSegment.rawProgramDateTime;break;default:u.logger.warn("line parsed but not handled: "+_)}}}return(E=b)&&!E.relurl&&(c.fragments.pop(),f-=E.duration),c.totalduration=f,c.averagetargetduration=f/c.fragments.length,c.endSN=d-1,c.startCC=c.fragments[0]?c.fragments[0].cc:0,c.endCC=y,!c.initSegment&&c.fragments.length&&c.fragments.every(function(e){return p.test(e.relurl)})&&(u.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),(E=new n.default).relurl=c.fragments[0].relurl,E.baseurl=t,E.level=r,E.type=i,E.sn="initSegment",c.initSegment=E,c.needSidxRanges=!0),S&&function(e,t){for(var r=e[t],i=t-1;i>=0;i--){var a=e[i];a.programDateTime=r.programDateTime-1e3*a.duration,r=a}}(c.fragments,S),c}}]),e}();function m(e,t){e.rawProgramDateTime?e.programDateTime=Date.parse(e.rawProgramDateTime):t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime),Number.isFinite(e.programDateTime)||(e.programDateTime=null,e.rawProgramDateTime=null)}t.default=y,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(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,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),a=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(r(10)),n=r(2),o=m(r(30)),s=m(r(73)),l=m(r(72)),u=r(6),d=m(r(71)),f=m(r(54)),c=m(r(53)),h=r(52),v=r(0),g=r(51),p=m(r(1)),y=r(21);function m(e){return e&&e.__esModule?e:{default:e}}var b=function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var r=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this)),i=t.DefaultConfig;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");for(var a in i)a in e||(e[a]=i[a]);if(void 0!==e.liveMaxLatencyDurationCount&&e.liveMaxLatencyDurationCount<=e.liveSyncDurationCount)throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be gt "liveSyncDurationCount"');if(void 0!==e.liveMaxLatencyDuration&&(e.liveMaxLatencyDuration<=e.liveSyncDuration||void 0===e.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be gt "liveSyncDuration"');(0,v.enableLogs)(e.debug),r.config=e,r._autoLevelCapping=-1;var n=r.abrController=new e.abrController(r),h=new e.bufferController(r),g=new e.capLevelController(r),p=new e.fpsController(r),y=new o.default(r),m=new s.default(r),b=new l.default(r),E=new c.default(r),_=r.levelController=new f.default(r),T=new u.FragmentTracker(r),S=[_,r.streamController=new d.default(r,T)],k=e.audioStreamController;k&&S.push(new k(r,T)),r.networkControllers=S;var R=[y,m,b,n,h,g,p,E,T];if(k=e.audioTrackController){var A=new k(r);r.audioTrackController=A,R.push(A)}if(k=e.subtitleTrackController){var w=new k(r);r.subtitleTrackController=w,S.push(w)}if(k=e.emeController){var O=new k(r);r.emeController=O,R.push(O)}return(k=e.subtitleStreamController)&&S.push(new k(r,T)),(k=e.timelineController)&&R.push(new k(r)),r.coreComponents=R,r}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,y.Observer),i(t,null,[{key:"isSupported",value:function(){return(0,h.isSupported)()}},{key:"version",get:function(){return __VERSION__}},{key:"Events",get:function(){return p.default}},{key:"ErrorTypes",get:function(){return n.ErrorTypes}},{key:"ErrorDetails",get:function(){return n.ErrorDetails}},{key:"DefaultConfig",get:function(){return t.defaultConfig?t.defaultConfig:g.hlsDefaultConfig},set:function(e){t.defaultConfig=e}}]),i(t,[{key:"destroy",value:function(){v.logger.log("destroy"),this.trigger(p.default.DESTROYING),this.detachMedia(),this.coreComponents.concat(this.networkControllers).forEach(function(e){e.destroy()}),this.url=null,this.removeAllListeners(),this._autoLevelCapping=-1}},{key:"attachMedia",value:function(e){v.logger.log("attachMedia"),this.media=e,this.trigger(p.default.MEDIA_ATTACHING,{media:e})}},{key:"detachMedia",value:function(){v.logger.log("detachMedia"),this.trigger(p.default.MEDIA_DETACHING),this.media=null}},{key:"loadSource",value:function(e){e=a.buildAbsoluteURL(window.location.href,e,{alwaysNormalize:!0}),v.logger.log("loadSource:"+e),this.url=e,this.trigger(p.default.MANIFEST_LOADING,{url:e})}},{key:"startLoad",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1;v.logger.log("startLoad("+e+")"),this.networkControllers.forEach(function(t){t.startLoad(e)})}},{key:"stopLoad",value:function(){v.logger.log("stopLoad"),this.networkControllers.forEach(function(e){e.stopLoad()})}},{key:"swapAudioCodec",value:function(){v.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()}},{key:"recoverMediaError",value:function(){v.logger.log("recoverMediaError");var e=this.media;this.detachMedia(),this.attachMedia(e)}},{key:"levels",get:function(){return this.levelController.levels}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(e){v.logger.log("set currentLevel:"+e),this.loadLevel=e,this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(e){v.logger.log("set nextLevel:"+e),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(e){v.logger.log("set loadLevel:"+e),this.levelController.manualLevel=e}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(e){this.levelController.nextLoadLevel=e}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(e){v.logger.log("set firstLevel:"+e),this.levelController.firstLevel=e}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(e){v.logger.log("set startLevel:"+e);-1!==e&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(e){v.logger.log("set autoLevelCapping:"+e),this._autoLevelCapping=e}},{key:"autoLevelEnabled",get:function(){return-1===this.levelController.manualLevel}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){for(var e=this.levels,t=this.config.minAutoBitrate,r=e?e.length:0,i=0;i<r;i++){if((e[i].realBitrate?Math.max(e[i].realBitrate,e[i].bitrate):e[i].bitrate)>t)return i}return 0}},{key:"maxAutoLevel",get:function(){var e=this.levels,t=this.autoLevelCapping;return-1===t&&e&&e.length?e.length-1:t}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(e){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,e)}},{key:"audioTracks",get:function(){var e=this.audioTrackController;return e?e.audioTracks:[]}},{key:"audioTrack",get:function(){var e=this.audioTrackController;return e?e.audioTrack:-1},set:function(e){var t=this.audioTrackController;t&&(t.audioTrack=e)}},{key:"liveSyncPosition",get:function(){return this.streamController.liveSyncPosition}},{key:"subtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTrack:-1},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}},{key:"subtitleDisplay",get:function(){var e=this.subtitleTrackController;return!!e&&e.subtitleDisplay},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}}]),t}();t.default=b,e.exports=t.default},function(e,t){e.exports=window.Player},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(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,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),a=s(r(78)),n=s(r(77)),o=s(r(31));function s(e){return e&&e.__esModule?e:{default:e}}function l(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}var u=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var r=l(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));r.hlsOpts=e.hlsOpts||{};var i=a.default.util,s=r;if(r.browser=o.default.getBrowserVersion(),void 0===s.config.useHls){if("mobile"===a.default.sniffer.device&&"MacIntel"!==navigator.platform&&"Win32"!==navigator.platform||r.browser.indexOf("Safari")>-1)return l(r)}else if(!s.config.useHls)return l(r);Number.isFinite=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)};var u=void 0;return u=new n.default(r.hlsOpts),r.hls=u,Object.defineProperty(s,"src",{get:function(){return s.currentSrc},set:function(e){i.removeClass(s.root,"xgplayer-is-live");var t=document.querySelector(".xgplayer-live");t&&t.parentNode.removeChild(t);var r=s.paused;s.hls.stopLoad(),s.hls.detachMedia(),s.hls.destroy(),s.hls=new n.default(s.hlsOpts),s.register(e),r?s.hls.loadSource(e):(s.pause(),s.once("pause",function(){s.hls.loadSource(e)}),s.once("canplay",function(){var e=s.video.play();void 0!==e&&e&&e.catch(function(e){})})),s.hls.attachMedia(s.video),s.once("canplay",function(){s.currentTime=0})},configurable:!0}),r.register(r.config.url),r.once("complete",function(){if(u.attachMedia(s.video),s.once("canplay",function(){var e=s.video.play();void 0!==e&&e&&e.catch(function(e){})}),s.config.isLive&&(i.addClass(s.root,"xgplayer-is-live"),!i.findDom(s.root,".xgplayer-live"))){var e=i.createDom("xg-live","正在直播",{},"xgplayer-live");s.controls.appendChild(e)}}),r.once("destroy",function(){u.stopLoad()}),r}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,a.default),i(t,[{key:"register",value:function(e){var t=this.hls,r=a.default.util,i=this;t.on(n.default.Events.MEDIA_ATTACHED,function(){t.loadSource(e)}),t.on(n.default.Events.LEVEL_LOADED,function(e,a){if(!t.inited&&(t.inited=!0,a&&a.details&&a.details.live&&(r.addClass(i.root,"xgplayer-is-live"),!r.findDom(i.root,".xgplayer-live")))){var n=r.createDom("xg-live","正在直播",{},"xgplayer-live");i.controls.appendChild(n)}}),t.on(n.default.Events.ERROR,function(e,r){if(i.emit("HLS_ERROR",{errorType:r.type,errorDetails:r.details,errorFatal:r.fatal}),r.fatal)switch(r.type){case n.default.ErrorTypes.NETWORK_ERROR:t.startLoad();break;case n.default.ErrorTypes.MEDIA_ERROR:t.recoverMediaError();break;default:i.emit("error",r)}}),this._statistics()}},{key:"_statistics",value:function(){var e={speed:0,playerType:"HlsPlayer"},t={videoDataRate:0,audioDataRate:0},r=this.hls,i=this;r.on(n.default.Events.FRAG_LOAD_PROGRESS,function(t,r){e.speed=r.stats.loaded/1e3}),r.on(n.default.Events.FRAG_PARSING_DATA,function(e,r){"video"===r.type&&(t.fps=parseInt(r.nb/(r.endPTS-r.startPTS)))}),r.on(n.default.Events.FRAG_PARSING_INIT_SEGMENT,function(e,r){if(t.hasAudio=!(!r.tracks||!r.tracks.audio),t.hasVideo=!(!r.tracks||!r.tracks.audio),t.hasAudio){var a=r.tracks.audio;t.audioChannelCount=a.metadata&&a.metadata.channelCount?a.metadata.channelCount:0,t.audioCodec=a.codec}if(t.hasVideo){var n=r.tracks.video;t.videoCodec=n.codec,t.width=n.metadata&&n.metadata.width?n.metadata.width:0,t.height=n.metadata&&n.metadata.height?n.metadata.height:0}t.duration=r.frag&&r.frag.duration?r.frag.duration:0,t.level=r.frag&&r.frag.level?r.frag.level:0,(t.videoCodec||t.audioCodec)&&(t.mimeType='video/hls; codecs="'+t.videoCodec+";"+t.audioCodec+'"'),i.mediainfo=t,i.emit("media_info",t)}),this._statisticsTimmer=setInterval(function(){i.emit("statistics_info",e),e.speed=0},1e3)}},{key:"destroy",value:function(){(function e(t,r,i){null===t&&(t=Function.prototype);var a=Object.getOwnPropertyDescriptor(t,r);if(void 0===a){var n=Object.getPrototypeOf(t);return null===n?void 0:e(n,r,i)}if("value"in a)return a.value;var o=a.get;return void 0!==o?o.call(i):void 0})(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"destroy",this).call(this),clearInterval(this._statisticsTimmer)}}]),t}();u.isSupported=n.default.isSupported,t.default=u,e.exports=t.default},function(e,t,r){e.exports=r(79)}]);