forked from video-dev/hls.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hls.light.min.js
6 lines (6 loc) · 168 KB
/
hls.light.min.js
1
2
3
4
5
6
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.Hls=e()}}(function(){var e;return function e(t,r,a){function i(o,s){if(!r[o]){if(!t[o]){var l="function"==typeof require&&require;if(!s&&l)return l(o,!0);if(n)return n(o,!0);var u=new Error("Cannot find module '"+o+"'");throw u.code="MODULE_NOT_FOUND",u}var d=r[o]={exports:{}};t[o][0].call(d.exports,function(e){var r=t[o][1][e];return i(r?r:e)},d,d.exports,e,t,r,a)}return r[o].exports}for(var n="function"==typeof require&&require,o=0;o<a.length;o++)i(a[o]);return i}({1:[function(e,t,r){function a(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function i(e){return"function"==typeof e}function n(e){return"number"==typeof e}function o(e){return"object"==typeof e&&null!==e}function s(e){return void 0===e}t.exports=a,a.EventEmitter=a,a.prototype._events=void 0,a.prototype._maxListeners=void 0,a.defaultMaxListeners=10,a.prototype.setMaxListeners=function(e){if(!n(e)||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},a.prototype.emit=function(e){var t,r,a,n,l,u;if(this._events||(this._events={}),"error"===e&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if((t=arguments[1])instanceof Error)throw t;var d=new Error('Uncaught, unspecified "error" event. ('+t+")");throw d.context=t,d}if(r=this._events[e],s(r))return!1;if(i(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:n=Array.prototype.slice.call(arguments,1),r.apply(this,n)}else if(o(r))for(n=Array.prototype.slice.call(arguments,1),u=r.slice(),a=u.length,l=0;l<a;l++)u[l].apply(this,n);return!0},a.prototype.addListener=function(e,t){var r;if(!i(t))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,i(t.listener)?t.listener:t),this._events[e]?o(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,o(this._events[e])&&!this._events[e].warned&&(r=s(this._maxListeners)?a.defaultMaxListeners:this._maxListeners)&&r>0&&this._events[e].length>r&&(this._events[e].warned=!0,console.trace),this},a.prototype.on=a.prototype.addListener,a.prototype.once=function(e,t){function r(){this.removeListener(e,r),a||(a=!0,t.apply(this,arguments))}if(!i(t))throw TypeError("listener must be a function");var a=!1;return r.listener=t,this.on(e,r),this},a.prototype.removeListener=function(e,t){var r,a,n,s;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(r=this._events[e],n=r.length,a=-1,r===t||i(r.listener)&&r.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(o(r)){for(s=n;s-- >0;)if(r[s]===t||r[s].listener&&r[s].listener===t){a=s;break}if(a<0)return this;1===r.length?(r.length=0,delete this._events[e]):r.splice(a,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},a.prototype.removeAllListeners=function(e){var t,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[e],i(r))this.removeListener(e,r);else if(r)for(;r.length;)this.removeListener(e,r[r.length-1]);return delete this._events[e],this},a.prototype.listeners=function(e){return this._events&&this._events[e]?i(this._events[e])?[this._events[e]]:this._events[e].slice():[]},a.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(i(t))return 1;if(t)return t.length}return 0},a.listenerCount=function(e,t){return e.listenerCount(t)}},{}],2:[function(t,r,a){!function(t){var i=/^((?:[^\/;?#]+:)?)(\/\/[^\/\;?#]*)?(.*?)??(;.*?)?(\?.*?)?(#.*?)?$/,n=/^([^\/;?#]*)(.*)$/,o={buildAbsoluteURL:function(e,t,r){if(r=r||{},e=e.trim(),!(t=t.trim())){if(!r.alwaysNormalize)return e;var a=this.parseURL(e);if(!s)throw new Error("Error trying to parse base URL.");return a.path=o.normalizePath(a.path),o.buildURLFromParts(a)}var i=this.parseURL(t);if(!i)throw new Error("Error trying to parse relative URL.");if(i.scheme)return r.alwaysNormalize?(i.path=o.normalizePath(i.path),o.buildURLFromParts(i)):t;var s=this.parseURL(e);if(!s)throw new Error("Error trying to parse base URL.");if(!s.netLoc&&s.path&&"/"!==s.path[0]){var l=n.exec(s.path);s.netLoc=l[1],s.path=l[2]}s.netLoc&&!s.path&&(s.path="/");var u={scheme:s.scheme,netLoc:i.netLoc,path:null,params:i.params,query:i.query,fragment:i.fragment};if(!i.netLoc&&(u.netLoc=s.netLoc,"/"!==i.path[0]))if(i.path){var d=s.path,f=d.substring(0,d.lastIndexOf("/")+1)+i.path;u.path=o.normalizePath(f)}else u.path=s.path,i.params||(u.params=s.params,i.query||(u.query=s.query));return null===u.path&&(u.path=r.alwaysNormalize?o.normalizePath(i.path):i.path),o.buildURLFromParts(u)},parseURL:function(e){var t=i.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(/(?:\/|^)\.(?=\/)/g,"");e.length!==(e=e.replace(/(?:\/|^)\.\.\/(?!\.\.\/).*?(?=\/)/g,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}};"object"==typeof a&&"object"==typeof r?r.exports=o:"function"==typeof e&&e.amd?e([],function(){return o}):"object"==typeof a?a.URLToolkit=o:t.URLToolkit=o}(this)},{}],3:[function(e,t,r){var a=arguments[3],i=arguments[4],n=arguments[5],o=JSON.stringify;t.exports=function(e,t){function r(e){p[e]=!0;for(var t in i[e][1]){var a=i[e][1][t];p[a]||r(a)}}for(var s,l=Object.keys(n),u=0,d=l.length;u<d;u++){var f=l[u],c=n[f].exports;if(c===e||c&&c.default===e){s=f;break}}if(!s){s=Math.floor(Math.pow(16,8)*Math.random()).toString(16);for(var h={},u=0,d=l.length;u<d;u++){var f=l[u];h[f]=f}i[s]=[Function(["require","module","exports"],"("+e+")(self)"),h]}var v=Math.floor(Math.pow(16,8)*Math.random()).toString(16),g={};g[s]=s,i[v]=[Function(["require"],"var f = require("+o(s)+");(f.default ? f.default : f)(self);"),g];var p={};r(v);var y="("+a+")({"+Object.keys(p).map(function(e){return o(e)+":["+i[e][0]+","+o(i[e][1])+"]"}).join(",")+"},{},["+o(v)+"])",m=window.URL||window.webkitURL||window.mozURL||window.msURL,b=new Blob([y],{type:"text/javascript"});if(t&&t.bare)return b;var E=m.createObjectURL(b),_=new Worker(E);return _.objectURL=E,_}},{}],4:[function(e,t,r){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(r,"__esModule",{value:!0}),r.hlsDefaultConfig=void 0;var i=e(5),n=a(i),o=e(6),s=a(o),l=e(7),u=a(l),d=e(8),f=a(d),c=e(48),h=a(c);r.hlsDefaultConfig={autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,initialLiveManifestSize:1,maxBufferLength:30,maxBufferSize:6e7,maxBufferHole:.5,maxSeekHole:2,lowBufferWatchdogPeriod:.5,highBufferWatchdogPeriod:3,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 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,fragLoadingLoopThreshold:3,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:h.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,fetchSetup:void 0,abrController:n.default,bufferController:s.default,capLevelController:u.default,fpsController:f.default,stretchShortVideoTrack:!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}},{48:48,5:5,6:6,7:7,8:8}],5:[function(e,t,r){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(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}function o(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)}Object.defineProperty(r,"__esModule",{value:!0});var s=function(){function e(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),l=e(30),u=a(l),d=e(29),f=a(d),c=e(32),h=a(c),v=e(28),g=e(46),p=e(44),y=a(p),m=function(e){function t(e){i(this,t);var r=n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,u.default.FRAG_LOADING,u.default.FRAG_LOADED,u.default.FRAG_BUFFERED,u.default.ERROR));return r.lastLoadedFragLevel=0,r._nextAutoLevel=-1,r.hls=e,r.onCheck=r._abandonRulesCheck.bind(r),r}return o(t,e),s(t,[{key:"destroy",value:function(){this.clearTimer(),f.default.prototype.destroy.call(this)}},{key:"onFragLoading",value:function(e){var t=e.frag;if("main"===t.type){if(this.timer||(this.timer=setInterval(this.onCheck,100)),!this._bwEstimator){var r=this.hls,a=e.frag.level,i=r.levels[a].details.live,n=r.config,o=void 0,s=void 0;i?(o=n.abrEwmaFastLive,s=n.abrEwmaSlowLive):(o=n.abrEwmaFastVoD,s=n.abrEwmaSlowVoD),this._bwEstimator=new y.default(r,s,o,n.abrEwmaDefaultEstimate)}this.fragCurrent=t}}},{key:"_abandonRulesCheck",value:function(){var e=this.hls,t=e.media,r=this.fragCurrent,a=r.loader,i=e.minAutoLevel;if(!a||a.stats&&a.stats.aborted)return g.logger.warn("frag loader destroy or aborted, disarm abandonRules"),void this.clearTimer();var n=a.stats;if(t&&(!t.paused&&0!==t.playbackRate||!t.readyState)&&r.autoLevel&&r.level){var o=performance.now()-n.trequest,s=Math.abs(t.playbackRate);if(o>500*r.duration/s){var l=e.levels,d=Math.max(1,n.bw?n.bw/8:1e3*n.loaded/o),f=l[r.level],c=f.realBitrate?Math.max(f.realBitrate,f.bitrate):f.bitrate,v=n.total?n.total:Math.max(n.loaded,Math.round(r.duration*c/8)),p=t.currentTime,y=(v-n.loaded)/d,m=(h.default.bufferInfo(t,p,e.config.maxBufferHole).end-p)/s;if(m<2*r.duration/s&&y>m){var b=void 0,E=void 0;for(E=r.level-1;E>i;E--){var _=l[E].realBitrate?Math.max(l[E].realBitrate,l[E].bitrate):l[E].bitrate;if((b=r.duration*_/(6.4*d))<m)break}b<y&&(g.logger.warn("loading too slow, abort fragment loading and switch to level "+E+":fragLoadedDelay["+E+"]<fragLoadedDelay["+(r.level-1)+"];bufferStarvationDelay:"+b.toFixed(1)+"<"+y.toFixed(1)+":"+m.toFixed(1)),e.nextLoadLevel=E,this._bwEstimator.sample(o,n.loaded),a.abort(),this.clearTimer(),e.trigger(u.default.FRAG_LOAD_EMERGENCY_ABORTED,{frag:r,stats:n}))}}}}},{key:"onFragLoaded",value:function(e){var t=e.frag;if("main"===t.type&&!isNaN(t.sn)){if(this.clearTimer(),this.lastLoadedFragLevel=t.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var r=this.hls.levels[t.level],a=(r.loaded?r.loaded.bytes:0)+e.stats.loaded,i=(r.loaded?r.loaded.duration:0)+e.frag.duration;r.loaded={bytes:a,duration:i},r.realBitrate=Math.round(8*a/i)}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(!(t.aborted===!0||1!==r.loadCounter||"main"!==r.type||isNaN(r.sn)||r.bitrateTest&&t.tload!==t.tbuffered)){var a=t.tparsed-t.trequest;g.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(a,t.loaded),t.bwEstimate=this._bwEstimator.getEstimate(),r.bitrateTest?this.bitrateTestDelay=a/1e3:this.bitrateTestDelay=0}}},{key:"onError",value:function(e){switch(e.details){case v.ErrorDetails.FRAG_LOAD_ERROR:case v.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer()}}},{key:"clearTimer",value:function(){this.timer&&(clearInterval(this.timer),this.timer=null)}},{key:"_findBestLevel",value:function(e,t,r,a,i,n,o,s,l){for(var u=i;u>=a;u--){var d=l[u],f=d.details,c=f?f.totalduration/f.fragments.length:t,h=!!f&&f.live,v=void 0;v=u<=e?o*r:s*r;var p=l[u].realBitrate?Math.max(l[u].realBitrate,l[u].bitrate):l[u].bitrate,y=p*c/v;if(g.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+u+"/"+Math.round(v)+"/"+p+"/"+c+"/"+n+"/"+y),v>p&&(!y||h&&!this.bitrateTestDelay||y<n))return u}return-1}},{key:"nextAutoLevel",get:function(){var e=this._nextAutoLevel,t=this._bwEstimator;if(!(e===-1||t&&t.canEstimate()))return e;var r=this._nextABRAutoLevel;return e!==-1&&(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,a=e.config,i=e.minAutoLevel,n=e.media,o=this.lastLoadedFragLevel,s=this.fragCurrent?this.fragCurrent.duration:0,l=n?n.currentTime:0,u=n&&0!==n.playbackRate?Math.abs(n.playbackRate):1,d=this._bwEstimator?this._bwEstimator.getEstimate():a.abrEwmaDefaultEstimate,f=(h.default.bufferInfo(n,l,a.maxBufferHole).end-l)/u,c=this._findBestLevel(o,s,d,i,t,f,a.abrBandWidthFactor,a.abrBandWidthUpFactor,r);if(c>=0)return c;g.logger.trace("rebuffering expected to happen, lets try to find a quality level minimizing the rebuffering");var v=s?Math.min(s,a.maxStarvationDelay):a.maxStarvationDelay,p=a.abrBandWidthFactor,y=a.abrBandWidthUpFactor;if(0===f){var m=this.bitrateTestDelay;if(m){v=(s?Math.min(s,a.maxLoadingDelay):a.maxLoadingDelay)-m,g.logger.trace("bitrate test took "+Math.round(1e3*m)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*v)+" ms"),p=y=1}}return c=this._findBestLevel(o,s,d,i,t,f+v,p,y,r),Math.max(c,0)}}]),t}(f.default);r.default=m},{28:28,29:29,30:30,32:32,44:44,46:46}],6:[function(e,t,r){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(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}function o(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)}Object.defineProperty(r,"__esModule",{value:!0});var s=function(){function e(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),l=e(30),u=a(l),d=e(29),f=a(d),c=e(46),h=e(28),v=function(e){function t(e){i(this,t);var r=n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,u.default.MEDIA_ATTACHING,u.default.MEDIA_DETACHING,u.default.MANIFEST_PARSED,u.default.BUFFER_RESET,u.default.BUFFER_APPENDING,u.default.BUFFER_CODECS,u.default.BUFFER_EOS,u.default.BUFFER_FLUSHING,u.default.LEVEL_PTS_UPDATED,u.default.LEVEL_UPDATED));return r._msDuration=null,r._levelDuration=null,r.onsbue=r.onSBUpdateEnd.bind(r),r.onsbe=r.onSBUpdateError.bind(r),r.pendingTracks={},r.tracks={},r}return o(t,e),s(t,[{key:"destroy",value:function(){f.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 a=this.sourceBuffer.audio;if(Math.abs(a.timestampOffset-e.start)>.1){var i=a.updating;try{a.abort()}catch(e){i=!0,c.logger.warn("can not abort audio buffer: "+e)}i?this.audioTimestampOffset=e.start:(c.logger.warn("change mpeg audio timestamp offset from "+a.timestampOffset+" to "+e.start),a.timestampOffset=e.start)}}}},{key:"onManifestParsed",value:function(e){var t=e.audio,r=e.video,a=0;e.altAudio&&(t||r)&&(a=(t?1:0)+(r?1:0),c.logger.log(a+" sourceBuffer(s) expected")),this.sourceBufferNb=a}},{key:"onMediaAttaching",value:function(e){var t=this.media=e.media;if(t){var r=this.mediaSource=new MediaSource;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=URL.createObjectURL(r)}}},{key:"onMediaDetaching",value:function(){c.logger.log("media source detaching");var e=this.mediaSource;if(e){if("open"===e.readyState)try{e.endOfStream()}catch(e){c.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&&(URL.revokeObjectURL(this.media.src),this.media.removeAttribute("src"),this.media.load()),this.mediaSource=null,this.media=null,this.pendingTracks={},this.tracks={},this.sourceBuffer={},this.flushRange=[],this.segments=[],this.appended=0}this.onmso=this.onmse=this.onmsc=null,this.hls.trigger(u.default.MEDIA_DETACHED)}},{key:"onMediaSourceOpen",value:function(){c.logger.log("media source opened"),this.hls.trigger(u.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.pendingTracks,t=Object.keys(e).length;t&&(this.sourceBufferNb<=t||0===this.sourceBufferNb)&&(this.createSourceBuffers(e),this.pendingTracks={},this.doAppending())}},{key:"onMediaSourceClose",value:function(){c.logger.log("media source closed")}},{key:"onMediaSourceEnded",value:function(){c.logger.log("media source ended")}},{key:"onSBUpdateEnd",value:function(){if(this.audioTimestampOffset){var e=this.sourceBuffer.audio;c.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);this.hls.trigger(u.default.BUFFER_APPENDED,{parent:t,pending:r}),this._needsFlush||this.doAppending(),this.updateMediaElementDuration()}},{key:"onSBUpdateError",value:function(e){c.logger.error("sourceBuffer error:",e),this.hls.trigger(u.default.ERROR,{type:h.ErrorTypes.MEDIA_ERROR,details:h.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){if(0===Object.keys(this.sourceBuffer).length){for(var t in e)this.pendingTracks[t]=e[t];var r=this.mediaSource;r&&"open"===r.readyState&&this.checkPendingTracks()}}},{key:"createSourceBuffers",value:function(e){var t=this.sourceBuffer,r=this.mediaSource;for(var a in e)if(!t[a]){var i=e[a],n=i.levelCodec||i.codec,o=i.container+";codecs="+n;c.logger.log("creating sourceBuffer("+o+")");try{var s=t[a]=r.addSourceBuffer(o);s.addEventListener("updateend",this.onsbue),s.addEventListener("error",this.onsbe),this.tracks[a]={codec:n,container:i.container},i.buffer=s}catch(e){c.logger.error("error while trying to add sourceBuffer:"+e.message),this.hls.trigger(u.default.ERROR,{type:h.ErrorTypes.MEDIA_ERROR,details:h.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,err:e,mimeType:o})}}this.hls.trigger(u.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){c.logger.error("sourceBuffer error:",e.event),this.hls.trigger(u.default.ERROR,{type:h.ErrorTypes.MEDIA_ERROR,details:h.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1})}},{key:"onBufferEos",value:function(e){var t=this.sourceBuffer,r=e.type;for(var a in t)r&&a!==r||t[a].ended||(t[a].ended=!0,c.logger.log(a+" sourceBuffer now EOS"));this.checkEos()}},{key:"checkEos",value:function(){var e=this.sourceBuffer,t=this.mediaSource;if(!t||"open"!==t.readyState)return void(this._needsEos=!1);for(var r in e){var a=e[r];if(!a.ended)return;if(a.updating)return void(this._needsEos=!0)}c.logger.log("all media data available, signal endOfStream() to MediaSource and stop loading fragment");try{t.endOfStream()}catch(e){c.logger.warn("exception while calling mediaSource.endOfStream()")}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:"onLevelUpdated",value:function(e){var t=e.details;0!==t.fragments.length&&(this._levelDuration=t.totalduration+t.fragments[0].start,this.updateMediaElementDuration())}},{key:"updateMediaElementDuration",value:function(){var e=this.media,t=this.mediaSource,r=this.sourceBuffer,a=this._levelDuration;if(null!==a&&e&&t&&r&&0!==e.readyState&&"open"===t.readyState){for(var i in r)if(r[i].updating)return;null===this._msDuration&&(this._msDuration=t.duration);var n=e.duration;(a>this._msDuration&&a>n||n===1/0||isNaN(n))&&(c.logger.log("Updating mediasource duration to "+a.toFixed(3)),this._msDuration=t.duration=a)}}},{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 a in r)t+=r[a].buffered.length}catch(e){c.logger.error("error while accessing sourceBuffer.buffered")}this.appended=t,this.hls.trigger(u.default.BUFFER_FLUSHED)}}},{key:"doAppending",value:function(){var e=this.hls,t=this.sourceBuffer,r=this.segments;if(Object.keys(t).length){if(this.media.error)return this.segments=[],void c.logger.error("trying to append although a media error occured, flush segment and abort");if(this.appending)return;if(r&&r.length){var a=r.shift();try{var i=a.type,n=t[i];n?n.updating?r.unshift(a):(n.ended=!1,this.parent=a.parent,n.appendBuffer(a.data),this.appendError=0,this.appended++,this.appending=!0):this.onSBUpdateEnd()}catch(t){c.logger.error("error while trying to append buffer:"+t.message),r.unshift(a);var o={type:h.ErrorTypes.MEDIA_ERROR,parent:a.parent};if(22===t.code)return this.segments=[],o.details=h.ErrorDetails.BUFFER_FULL_ERROR,o.fatal=!1,void e.trigger(u.default.ERROR,o);if(this.appendError?this.appendError++:this.appendError=1,o.details=h.ErrorDetails.BUFFER_APPEND_ERROR,this.appendError>e.config.appendErrorMaxRetry)return c.logger.log("fail "+e.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),r=[],o.fatal=!0,void e.trigger(u.default.ERROR,o);o.fatal=!1,e.trigger(u.default.ERROR,o)}}}}},{key:"flushBuffer",value:function(e,t,r){var a,i,n,o,s,l,u=this.sourceBuffer;if(Object.keys(u).length){if(c.logger.log("flushBuffer,pos/start/end: "+this.media.currentTime.toFixed(3)+"/"+e+"/"+t),this.flushBufferCounter<this.appended){for(var d in u)if(!r||d===r){if(a=u[d],a.ended=!1,a.updating)return c.logger.warn("cannot flush, sb updating in progress"),!1;try{for(i=0;i<a.buffered.length;i++)if(n=a.buffered.start(i),o=a.buffered.end(i),navigator.userAgent.toLowerCase().indexOf("firefox")!==-1&&t===Number.POSITIVE_INFINITY?(s=e,l=t):(s=Math.max(n,e),l=Math.min(o,t)),Math.min(l,o)-s>.5)return this.flushBufferCounter++,c.logger.log("flush "+d+" ["+s+","+l+"], of ["+n+","+o+"], pos:"+this.media.currentTime),a.remove(s,l),!1}catch(e){c.logger.warn("exception while accessing sourcebuffer, it might have been removed from MediaSource")}}}else c.logger.warn("abort flushing too many retries");c.logger.log("buffer flushed")}return!0}}]),t}(f.default);r.default=v},{28:28,29:29,30:30,46:46}],7:[function(e,t,r){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(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}function o(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)}Object.defineProperty(r,"__esModule",{value:!0});var s=function(){function e(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),l=e(30),u=a(l),d=e(29),f=a(d),c=function(e){function t(e){return i(this,t),n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,u.default.FPS_DROP_LEVEL_CAPPING,u.default.MEDIA_ATTACHING,u.default.MANIFEST_PARSED))}return o(t,e),s(t,[{key:"destroy",value:function(){this.hls.config.capLevelToPlayerSize&&(this.media=this.restrictedLevels=null,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(this.timer=clearInterval(this.timer)))}},{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 HTMLVideoElement?e.media:null}},{key:"onManifestParsed",value:function(e){var t=this.hls;this.restrictedLevels=[],t.config.capLevelToPlayerSize&&(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.levels=e.levels,t.firstLevel=this.getMaxLevel(e.firstLevel),clearInterval(this.timer),this.timer=setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())}},{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 a=this.levels.filter(function(a,i){return t.isLevelAllowed(i,r.restrictedLevels)&&i<=e});return t.getMaxLevelByMediaSize(a,this.mediaWidth,this.mediaHeight)}},{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(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[]).indexOf(e)===-1}},{key:"getMaxLevelByMediaSize",value:function(e,t,r){if(!e||e&&!e.length)return-1;for(var a=e.length-1,i=0;i<e.length;i+=1){var n=e[i];if((n.width>=t||n.height>=r)&&function(e,t){return!t||(e.width!==t.width||e.height!==t.height)}(n,e[i+1])){a=i;break}}return a}},{key:"contentScaleFactor",get:function(){var e=1;try{e=window.devicePixelRatio}catch(e){}return e}}]),t}(f.default);r.default=c},{29:29,30:30}],8:[function(e,t,r){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(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}function o(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)}Object.defineProperty(r,"__esModule",{value:!0});var s=function(){function e(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),l=e(30),u=a(l),d=e(29),f=a(d),c=e(46),h=function(e){function t(e){return i(this,t),n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,u.default.MEDIA_ATTACHING))}return o(t,e),s(t,[{key:"destroy",value:function(){this.timer&&clearInterval(this.timer),this.isVideoPlaybackQualityAvailable=!1}},{key:"onMediaAttaching",value:function(e){var t=this.hls.config;if(t.capLevelOnFPSDrop){"function"==typeof(this.video=e.media instanceof 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 a=performance.now();if(t){if(this.lastTime){var i=a-this.lastTime,n=r-this.lastDroppedFrames,o=t-this.lastDecodedFrames,s=1e3*n/i,l=this.hls;if(l.trigger(u.default.FPS_DROP,{currentDropped:n,currentDecoded:o,totalDroppedFrames:r}),s>0&&n>l.config.fpsDroppedMonitoringThreshold*o){var d=l.currentLevel;c.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+d),d>0&&(l.autoLevelCapping===-1||l.autoLevelCapping>=d)&&(d-=1,l.trigger(u.default.FPS_DROP_LEVEL_CAPPING,{level:d,droppedLevel:l.currentLevel}),l.autoLevelCapping=d,l.streamController.nextLevelSwitch())}}this.lastTime=a,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}(f.default);r.default=h},{29:29,30:30,46:46}],9:[function(e,t,r){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(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}function o(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)}Object.defineProperty(r,"__esModule",{value:!0});var s=function(){function e(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}
}(),l=e(30),u=a(l),d=e(29),f=a(d),c=e(22),h=a(c),v=function(e){function t(e){i(this,t);var r=n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,u.default.MEDIA_ATTACHED,u.default.MEDIA_DETACHING,u.default.FRAG_PARSING_METADATA));return r.id3Track=void 0,r.media=void 0,r}return o(t,e),s(t,[{key:"destroy",value:function(){f.default.prototype.destroy.call(this)}},{key:"onMediaAttached",value:function(e){this.media=e.media,this.media&&(this.id3Track=this.media.addTextTrack("metadata","id3"),this.id3Track.mode="hidden")}},{key:"onMediaDetaching",value:function(){this.media=void 0}},{key:"onFragParsingMetadata",value:function(e){for(var t=e.frag,r=e.samples,a=window.WebKitDataCue||window.VTTCue||window.TextTrackCue,i=0;i<r.length;i++){var n=h.default.getID3Frames(r[i].data);if(n){var o=r[i].pts,s=i<r.length-1?r[i+1].pts:t.endPTS;o===s&&(s+=1e-4);for(var l=0;l<n.length;l++){var u=n[l];if(!h.default.isTimeStampFrame(u)){var d=new a(o,s,"");d.value=u,this.id3Track.addCue(d)}}}}}}]),t}(f.default);r.default=v},{22:22,29:29,30:30}],10:[function(e,t,r){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(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}function o(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)}Object.defineProperty(r,"__esModule",{value:!0});var s=function(){function e(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),l=e(30),u=a(l),d=e(29),f=a(d),c=e(46),h=e(28),v=e(32),g=a(v),p=function(e){function t(e){i(this,t);var r=n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,u.default.MANIFEST_LOADED,u.default.LEVEL_LOADED,u.default.FRAG_LOADED,u.default.ERROR));return r.ontick=r.tick.bind(r),r._manualLevel=-1,r}return o(t,e),s(t,[{key:"destroy",value:function(){this.timer&&(clearTimeout(this.timer),this.timer=null),this._manualLevel=-1}},{key:"startLoad",value:function(){this.canload=!0;var e=this._levels;e&&e.forEach(function(e){e.loadError=0;var t=e.details;t&&t.live&&(e.details=void 0)}),this.timer&&this.tick()}},{key:"stopLoad",value:function(){this.canload=!1}},{key:"onManifestLoaded",value:function(e){var t,r=[],a=[],i={},n=!1,o=!1,s=this.hls,l=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),d=function(e,t){return MediaSource.isTypeSupported(e+"/mp4;codecs="+t)};if(e.levels.forEach(function(e){e.videoCodec&&(n=!0),l&&e.audioCodec&&e.audioCodec.indexOf("mp4a.40.34")!==-1&&(e.audioCodec=void 0),(e.audioCodec||e.attrs&&e.attrs.AUDIO)&&(o=!0);var t=i[e.bitrate];void 0===t?(i[e.bitrate]=r.length,e.url=[e.url],e.urlId=0,r.push(e)):r[t].url.push(e.url)}),n&&o?r.forEach(function(e){e.videoCodec&&a.push(e)}):a=r,a=a.filter(function(e){var t=e.audioCodec,r=e.videoCodec;return(!t||d("audio",t))&&(!r||d("video",r))}),a.length){t=a[0].bitrate,a.sort(function(e,t){return e.bitrate-t.bitrate}),this._levels=a;for(var f=0;f<a.length;f++)if(a[f].bitrate===t){this._firstLevel=f,c.logger.log("manifest loaded,"+a.length+" level(s) found, first bitrate:"+t);break}s.trigger(u.default.MANIFEST_PARSED,{levels:a,firstLevel:this._firstLevel,stats:e.stats,audio:o,video:n,altAudio:e.audioTracks.length>0})}else s.trigger(u.default.ERROR,{type:h.ErrorTypes.MEDIA_ERROR,details:h.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:s.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.timer&&(clearTimeout(this.timer),this.timer=null),this._level!==e){c.logger.log("switching to level "+e),this._level=e;var a=t[e];a.level=e,r.trigger(u.default.LEVEL_SWITCH,a),r.trigger(u.default.LEVEL_SWITCHING,a)}var i=t[e],n=i.details;if(!n||n.live===!0){var o=i.urlId;r.trigger(u.default.LEVEL_LOADING,{url:i.url[o],level:e,id:o})}}else r.trigger(u.default.ERROR,{type:h.ErrorTypes.OTHER_ERROR,details:h.ErrorDetails.LEVEL_SWITCH_ERROR,level:e,fatal:!1,reason:"invalid level idx"})}},{key:"onError",value:function(e){if(!e.fatal){var t=e.details,r=this.hls,a=void 0,i=void 0,n=!1;switch(t){case h.ErrorDetails.FRAG_LOAD_ERROR:case h.ErrorDetails.FRAG_LOAD_TIMEOUT:case h.ErrorDetails.FRAG_LOOP_LOADING_ERROR:case h.ErrorDetails.KEY_LOAD_ERROR:case h.ErrorDetails.KEY_LOAD_TIMEOUT:a=e.frag.level;break;case h.ErrorDetails.LEVEL_LOAD_ERROR:case h.ErrorDetails.LEVEL_LOAD_TIMEOUT:a=e.context.level,n=!0;break;case h.ErrorDetails.REMUX_ALLOC_ERROR:a=e.level}if(void 0!==a){i=this._levels[a],i.loadError?i.loadError++:i.loadError=1;var o=i.url.length;if(o>1&&i.loadError<o)i.urlId=(i.urlId+1)%o,i.details=void 0,c.logger.warn("level controller,"+t+" for level "+a+": switching to redundant stream id "+i.urlId);else{if(this._manualLevel===-1&&a)c.logger.warn("level controller,"+t+": switch-down for next fragment"),r.nextAutoLevel=Math.max(0,a-1);else if(i&&i.details&&i.details.live)c.logger.warn("level controller,"+t+" on live stream, discard"),n&&(this._level=void 0);else if(t===h.ErrorDetails.LEVEL_LOAD_ERROR||t===h.ErrorDetails.LEVEL_LOAD_TIMEOUT){var s=r.media,l=s&&g.default.isBuffered(s,s.currentTime)&&g.default.isBuffered(s,s.currentTime+.5);if(l){var u=r.config.levelLoadingRetryDelay;c.logger.warn("level controller,"+t+", but media buffered, retry in "+u+"ms"),this.timer=setTimeout(this.ontick,u),e.levelRetry=!0}else c.logger.error("cannot recover "+t+" error"),this._level=void 0,this.timer&&(clearTimeout(this.timer),this.timer=null),e.fatal=!0}}}}}},{key:"onFragLoaded",value:function(e){var t=e.frag;if(t&&"main"===t.type){var r=this._levels[t.level];r&&(r.loadError=0)}}},{key:"onLevelLoaded",value:function(e){var t=e.level;if(t===this._level){var r=this._levels[t];r.loadError=0;var a=e.details;if(a.live){var i=1e3*(a.averagetargetduration?a.averagetargetduration:a.targetduration),n=r.details;n&&a.endSN===n.endSN&&(i/=2,c.logger.log("same live playlist, reload twice faster")),i-=performance.now()-e.stats.trequest,i=Math.max(1e3,Math.round(i)),c.logger.log("live playlist, reload in "+i+" ms"),this.timer=setTimeout(this.ontick,i)}else this.timer=null}}},{key:"tick",value:function(){var e=this._level;if(void 0!==e&&this.canload){var t=this._levels[e];if(t&&t.url){var r=t.urlId;this.hls.trigger(u.default.LEVEL_LOADING,{url:t.url[r],level:e,id:r})}}}},{key:"levels",get:function(){return this._levels}},{key:"level",get:function(){return this._level},set:function(e){var t=this._levels;t&&t.length>e&&(this._level===e&&void 0!==t[e].details||this.setLevelInternal(e))}},{key:"manualLevel",get:function(){return this._manualLevel},set:function(e){this._manualLevel=e,void 0===this._startLevel&&(this._startLevel=e),e!==-1&&(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 this._manualLevel!==-1?this._manualLevel:this.hls.nextAutoLevel},set:function(e){this.level=e,this._manualLevel===-1&&(this.hls.nextAutoLevel=e)}}]),t}(f.default);r.default=p},{28:28,29:29,30:30,32:32,46:46}],11:[function(e,t,r){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(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}function o(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)}Object.defineProperty(r,"__esModule",{value:!0});var s=function(){function e(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),l=e(43),u=a(l),d=e(32),f=a(d),c=e(20),h=a(c),v=e(30),g=a(v),p=e(29),y=a(p),m=e(33),b=a(m),E=e(47),_=a(E),R=e(28),T=e(46),A={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_LEVEL:"WAITING_LEVEL",PARSING:"PARSING",PARSED:"PARSED",BUFFER_FLUSHING:"BUFFER_FLUSHING",ENDED:"ENDED",ERROR:"ERROR"},S=function(e){function t(e){i(this,t);var r=n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,g.default.MEDIA_ATTACHED,g.default.MEDIA_DETACHING,g.default.MANIFEST_LOADING,g.default.MANIFEST_PARSED,g.default.LEVEL_LOADED,g.default.KEY_LOADED,g.default.FRAG_LOADED,g.default.FRAG_LOAD_EMERGENCY_ABORTED,g.default.FRAG_PARSING_INIT_SEGMENT,g.default.FRAG_PARSING_DATA,g.default.FRAG_PARSED,g.default.ERROR,g.default.AUDIO_TRACK_SWITCHING,g.default.AUDIO_TRACK_SWITCHED,g.default.BUFFER_CREATED,g.default.BUFFER_APPENDED,g.default.BUFFER_FLUSHED));return r.config=e.config,r.audioCodecSwap=!1,r.ticks=0,r._state=A.STOPPED,r.ontick=r.tick.bind(r),r}return o(t,e),s(t,[{key:"destroy",value:function(){this.stopLoad(),this.timer&&(clearInterval(this.timer),this.timer=null),y.default.prototype.destroy.call(this),this.state=A.STOPPED}},{key:"startLoad",value:function(e){if(this.levels){var t=this.lastCurrentTime,r=this.hls;if(this.stopLoad(),this.timer||(this.timer=setInterval(this.ontick,100)),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var a=r.startLevel;a===-1&&(a=0,this.bitrateTest=!0),this.level=r.nextLoadLevel=a,this.loadedmetadata=!1}t>0&&e===-1&&(T.logger.log("override startPosition with lastCurrentTime @"+t.toFixed(3)),e=t),this.state=A.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this.forceStartLoad=!0,this.state=A.STOPPED}},{key:"stopLoad",value:function(){var e=this.fragCurrent;e&&(e.loader&&e.loader.abort(),this.fragCurrent=null),this.fragPrevious=null,this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),this.state=A.STOPPED,this.forceStartLoad=!1}},{key:"tick",value:function(){1===++this.ticks&&(this.doTick(),this.ticks>1&&setTimeout(this.tick,1),this.ticks=0)}},{key:"doTick",value:function(){switch(this.state){case A.ERROR:break;case A.BUFFER_FLUSHING:this.fragLoadError=0;break;case A.IDLE:this._doTickIdle();break;case A.WAITING_LEVEL:var e=this.levels[this.level];e&&e.details&&(this.state=A.IDLE);break;case A.FRAG_LOADING_WAITING_RETRY:var t=performance.now(),r=this.retryDate;(!r||t>=r||this.media&&this.media.seeking)&&(T.logger.log("mediaController: retryDate reached, switch back to IDLE state"),this.state=A.IDLE);break;case A.ERROR:case A.STOPPED:case A.FRAG_LOADING:case A.PARSING:case A.PARSED:case A.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 a=void 0;a=this.loadedmetadata?r.currentTime:this.nextLoadPosition;var i=e.nextLoadLevel,n=this.levels[i];if(n){var o=n.bitrate,s=void 0;s=o?Math.max(8*t.maxBufferSize/o,t.maxBufferLength):t.maxBufferLength,s=Math.min(s,t.maxMaxBufferLength);var l=f.default.bufferInfo(this.mediaBuffer?this.mediaBuffer:r,a,t.maxBufferHole),u=l.len;if(!(u>=s)){T.logger.trace("buffer length of "+u.toFixed(3)+" is below max of "+s.toFixed(3)+". checking for more payload ..."),this.level=e.nextLoadLevel=i;var d=n.details;if(void 0===d||d.live&&this.levelLastLoaded!==i)return void(this.state=A.WAITING_LEVEL);var c=this.fragPrevious;if(!d.live&&c&&c.sn===d.endSN&&u&&!l.nextStart){if(Math.min(r.duration,c.start+c.duration)-Math.max(l.end,c.start)<=Math.max(.2,c.duration)){var h={};return this.altAudio&&(h.type="video"),this.hls.trigger(g.default.BUFFER_EOS,h),void(this.state=A.ENDED)}}this._fetchPayloadOrEos(a,l,d)}}}}},{key:"_fetchPayloadOrEos",value:function(e,t,r){var a=this.fragPrevious,i=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 T.logger.warn("Can not start playback of a level, reason: not enough fragments "+o+" < "+f);if(null===(d=this._ensureFragmentAtLivePoint(r,u,s,l,a,n,o)))return}else u<s&&(d=n[0]);d||(d=this._findFragment(s,a,o,n,u,l,r)),d&&this._loadFragmentOrKey(d,i,r,e,u)}}},{key:"_ensureFragmentAtLivePoint",value:function(e,t,r,a,i,n,o){var s=this.hls.config,l=this.media,u=void 0,d=void 0!==s.liveMaxLatencyDuration?s.liveMaxLatencyDuration:s.liveMaxLatencyDurationCount*e.targetduration;if(t<Math.max(r-s.maxFragLookUpTolerance,a-d)){var f=this.liveSyncPosition=this.computeLivePosition(r,e);T.logger.log("buffer end: "+t.toFixed(3)+" is located too far from the end of live sliding playlist, reset currentTime to : "+f.toFixed(3)),t=f,l&&l.readyState&&l.duration>f&&(l.currentTime=f)}if(e.PTSKnown&&t>a&&l&&l.readyState)return null;if(this.startFragRequested&&!e.PTSKnown){if(i){var c=i.sn+1;c>=e.startSN&&c<=e.endSN&&(u=n[c-e.startSN],T.logger.log("live playlist, switching playlist, load frag with next SN: "+u.sn))}u||(u=n[Math.min(o-1,Math.round(o/2))],T.logger.log("live playlist, switching playlist, unknown, load middle frag : "+u.sn))}return u}},{key:"_findFragment",value:function(e,t,r,a,i,n,o){var s=this.hls.config,l=void 0,d=void 0,f=s.maxFragLookUpTolerance,c=t?a[t.sn-a[0].sn+1]:void 0,h=function(e){var t=Math.min(f,e.duration);return e.start+e.duration-t<=i?1:e.start-t>i&&e.start?-1:0};if(i<n?(i>n-f&&(f=0),d=c&&!h(c)?c:u.default.search(a,h)):d=a[r-1],d){l=d;var v=l.sn-o.startSN,g=t&&l.level===t.level,p=a[v-1],y=a[v+1];if(t&&l.sn===t.sn)if(g&&!l.backtracked)if(l.sn<o.endSN){var m=t.deltaPTS;m&&m>s.maxBufferHole&&t.dropped&&v?(l=p,T.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"),t.loadCounter--):(l=y,T.logger.log("SN just loaded, load next one: "+l.sn))}else l=null;else l.backtracked&&(y&&y.backtracked?(T.logger.warn("Already backtracked from fragment "+y.sn+", will not backtrack to fragment "+l.sn+". Loading fragment "+y.sn),l=y):(T.logger.warn("Loaded fragment with dropped frames, backtracking 1 segment to find a keyframe"),l.dropped=0,p?(p.loadCounter&&p.loadCounter--,l=p,l.backtracked=!0):l=null))}return l}},{key:"_loadFragmentOrKey",value:function(e,t,r,a,i){var n=this.hls,o=n.config;if(!e.decryptdata||null==e.decryptdata.uri||null!=e.decryptdata.key){if(T.logger.log("Loading "+e.sn+" of ["+r.startSN+" ,"+r.endSN+"],level "+t+", currentTime:"+a.toFixed(3)+",bufferEnd:"+i.toFixed(3)),void 0!==this.fragLoadIdx?this.fragLoadIdx++:this.fragLoadIdx=0,e.loadCounter){e.loadCounter++;var s=o.fragLoadingLoopThreshold;if(e.loadCounter>s&&Math.abs(this.fragLoadIdx-e.loadIdx)<s)return void n.trigger(g.default.ERROR,{type:R.ErrorTypes.MEDIA_ERROR,details:R.ErrorDetails.FRAG_LOOP_LOADING_ERROR,fatal:!1,frag:e})}else e.loadCounter=1;return e.loadIdx=this.fragLoadIdx,this.fragCurrent=e,this.startFragRequested=!0,isNaN(e.sn)||(this.nextLoadPosition=e.start+e.duration),e.autoLevel=n.autoLevelEnabled,e.bitrateTest=this.bitrateTest,n.trigger(g.default.FRAG_LOADING,{frag:e}),this.demuxer||(this.demuxer=new h.default(n,"main")),void(this.state=A.FRAG_LOADING)}T.logger.log("Loading key for "+e.sn+" of ["+r.startSN+" ,"+r.endSN+"],level "+t),this.state=A.KEY_LOADING,n.trigger(g.default.KEY_LOADING,{frag:e})}},{key:"getBufferedFrag",value:function(e){return u.default.search(this._bufferedFrags,function(t){return e<t.startPTS?-1:e>t.endPTS?1:0})}},{key:"followingBufferedFrag",value:function(e){return e?this.getBufferedFrag(e.endPTS+.5):null}},{key:"_checkFragmentChanged",value:function(){var e,t,r=this.media;if(r&&r.readyState&&r.seeking===!1&&(t=r.currentTime,t>r.playbackRate*this.lastCurrentTime&&(this.lastCurrentTime=t),f.default.isBuffered(r,t)?e=this.getBufferedFrag(t):f.default.isBuffered(r,t+.1)&&(e=this.getBufferedFrag(t+.1)),e)){var a=e;if(a!==this.fragPlaying){this.hls.trigger(g.default.FRAG_CHANGED,{frag:a});var i=a.level;this.fragPlaying&&this.fragPlaying.level===i||this.hls.trigger(g.default.LEVEL_SWITCHED,{level:i}),this.fragPlaying=a}}}},{key:"immediateLevelSwitch",value:function(){if(T.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.fragLoadIdx+=2*this.config.fragLoadingLoopThreshold,this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}},{key:"immediateLevelSwitchEnd",value:function(){var e=this.media;e&&e.buffered.length&&(this.immediateSwitch=!1,f.default.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=void 0,r=void 0,a=void 0;if(this.fragLoadIdx+=2*this.config.fragLoadingLoopThreshold,r=this.getBufferedFrag(e.currentTime),r&&r.startPTS>1&&this.flushMainBuffer(0,r.startPTS-1),e.paused)t=0;else{var i=this.hls.nextLoadLevel,n=this.levels[i],o=this.fragLastKbps;t=o&&this.fragCurrent?this.fragCurrent.duration*n.bitrate/(1e3*o)+1:0}if((a=this.getBufferedFrag(e.currentTime+t))&&(a=this.followingBufferedFrag(a))){var s=this.fragCurrent;s&&s.loader&&s.loader.abort(),this.fragCurrent=null,this.flushMainBuffer(a.startPTS,Number.POSITIVE_INFINITY)}}}},{key:"flushMainBuffer",value:function(e,t){this.state=A.BUFFER_FLUSHING;var r={startOffset:e,endOffset:t};this.altAudio&&(r.type="video"),this.hls.trigger(g.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)}},{key:"onMediaDetaching",value:function(){var e=this.media;e&&e.ended&&(T.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.loadCounter=void 0,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:"onMediaSeeking",value:function(){var e=this.media,t=e?e.currentTime:void 0,r=this.config;isNaN(t)||T.logger.log("media seeking to "+t.toFixed(3));var a=this.mediaBuffer?this.mediaBuffer:e,i=f.default.bufferInfo(a,t,this.config.maxBufferHole);if(this.state===A.FRAG_LOADING){var n=this.fragCurrent;if(0===i.len&&n){var o=r.maxFragLookUpTolerance,s=n.start-o,l=n.start+n.duration+o;t<s||t>l?(n.loader&&(T.logger.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),n.loader.abort()),this.fragCurrent=null,this.fragPrevious=null,this.state=A.IDLE):T.logger.log("seeking outside of buffer but within currently loaded fragment range")}}else this.state===A.ENDED&&(0===i.len&&(this.fragPrevious=0),this.state=A.IDLE);e&&(this.lastCurrentTime=t),this.state!==A.FRAG_LOADING&&void 0!==this.fragLoadIdx&&(this.fragLoadIdx+=2*r.fragLoadingLoopThreshold),this.loadedmetadata||(this.nextLoadPosition=this.startPosition=t),this.tick()}},{key:"onMediaSeeked",value:function(){var e=this.media,t=e?e.currentTime:void 0;isNaN(t)||T.logger.log("media seeked to "+t.toFixed(3)),this.tick()}},{key:"onMediaEnded",value:function(){T.logger.log("media ended"),this.startPosition=this.lastCurrentTime=0}},{key:"onManifestLoading",value:function(){T.logger.log("trigger BUFFER_RESET"),this.hls.trigger(g.default.BUFFER_RESET),this._bufferedFrags=[],this.stalled=!1,this.startPosition=this.lastCurrentTime=0}},{key:"onManifestParsed",value:function(e){var t,r=!1,a=!1;e.levels.forEach(function(e){(t=e.audioCodec)&&(t.indexOf("mp4a.40.2")!==-1&&(r=!0),t.indexOf("mp4a.40.5")!==-1&&(a=!0))}),this.audioCodecSwitch=r&&a,this.audioCodecSwitch&&T.logger.log("both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=e.levels,this.startLevelLoaded=!1,this.startFragRequested=!1;var i=this.config;(i.autoStartLoad||this.forceStartLoad)&&this.hls.startLoad(i.startPosition)}},{key:"onLevelLoaded",value:function(e){var t=e.details,r=e.level,a=this.levels[r],i=t.totalduration,n=0;if(T.logger.log("level "+r+" loaded ["+t.startSN+","+t.endSN+"],duration:"+i),this.levelLastLoaded=r,t.live){var o=a.details;o&&t.fragments.length>0?(b.default.mergeDetails(o,t),n=t.fragments[0].start,this.liveSyncPosition=this.computeLivePosition(n,o),t.PTSKnown?T.logger.log("live playlist sliding:"+n.toFixed(3)):T.logger.log("live playlist - outdated PTS, unknown sliding")):(t.PTSKnown=!1,T.logger.log("live playlist - first load, unknown sliding"))}else t.PTSKnown=!1;if(a.details=t,this.hls.trigger(g.default.LEVEL_UPDATED,{details:t,level:r}),this.startFragRequested===!1){if(this.startPosition===-1||this.lastCurrentTime===-1){var s=t.startTimeOffset;isNaN(s)?t.live?(this.startPosition=this.computeLivePosition(n,t),T.logger.log("configure startPosition to "+this.startPosition)):this.startPosition=0:(s<0&&(T.logger.log("negative start time offset "+s+", count from end of last fragment"),s=n+i+s),T.logger.log("start time offset found in playlist, adjust startPosition to "+s),this.startPosition=s),this.lastCurrentTime=this.startPosition}this.nextLoadPosition=this.startPosition}this.state===A.WAITING_LEVEL&&(this.state=A.IDLE),this.tick()}},{key:"onKeyLoaded",value:function(){this.state===A.KEY_LOADING&&(this.state=A.IDLE,this.tick())}},{key:"onFragLoaded",value:function(e){var t=this.fragCurrent,r=e.frag;if(this.state===A.FRAG_LOADING&&t&&"main"===r.type&&r.level===t.level&&r.sn===t.sn){var a=e.stats,i=this.levels[t.level],n=i.details;if(T.logger.log("Loaded "+t.sn+" of ["+n.startSN+" ,"+n.endSN+"],level "+t.level),this.bitrateTest=!1,this.stats=a,r.bitrateTest===!0&&this.hls.nextLoadLevel)this.state=A.IDLE,this.startFragRequested=!1,a.tparsed=a.tbuffered=performance.now(),this.hls.trigger(g.default.FRAG_BUFFERED,{stats:a,frag:t,id:"main"}),this.tick();else if("initSegment"===r.sn)this.state=A.IDLE,a.tparsed=a.tbuffered=performance.now(),n.initSegment.data=e.payload,this.hls.trigger(g.default.FRAG_BUFFERED,{stats:a,frag:t,id:"main"}),this.tick();else{this.state=A.PARSING;var o=n.totalduration,s=t.level,l=t.sn,u=this.config.defaultAudioCodec||i.audioCodec;this.audioCodecSwap&&(T.logger.log("swapping playlist audio codec"),void 0===u&&(u=this.lastAudioCodec),u&&(u=u.indexOf("mp4a.40.5")!==-1?"mp4a.40.2":"mp4a.40.5")),this.pendingBuffering=!0,this.appended=!1,T.logger.log("Parsing "+l+" of ["+n.startSN+" ,"+n.endSN+"],level "+s+", cc "+t.cc);var d=this.demuxer;d||(d=this.demuxer=new h.default(this.hls,"main"));var f=this.media,c=f&&f.seeking,v=!c&&(n.PTSKnown||!n.live),p=n.initSegment?n.initSegment.data:[];d.push(e.payload,p,u,i.videoCodec,t,o,v,void 0)}}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===A.PARSING){var a,i,n=e.tracks;if(n.audio&&this.altAudio&&delete n.audio,i=n.audio){var o=this.levels[this.level].audioCodec,s=navigator.userAgent.toLowerCase();o&&this.audioCodecSwap&&(T.logger.log("swapping playlist audio codec"),o=o.indexOf("mp4a.40.5")!==-1?"mp4a.40.2":"mp4a.40.5"),this.audioCodecSwitch&&1!==i.metadata.channelCount&&s.indexOf("firefox")===-1&&(o="mp4a.40.5"),s.indexOf("android")!==-1&&"audio/mpeg"!==i.container&&(o="mp4a.40.2",T.logger.log("Android: force audio codec to "+o)),i.levelCodec=o,i.id=e.id}i=n.video,i&&(i.levelCodec=this.levels[this.level].videoCodec,i.id=e.id),this.hls.trigger(g.default.BUFFER_CODECS,n);for(a in n){i=n[a],T.logger.log("main track:"+a+",container:"+i.container+",codecs[level/parsed]=["+i.levelCodec+"/"+i.codec+"]");var l=i.initSegment;l&&(this.appended=!0,this.pendingBuffering=!0,this.hls.trigger(g.default.BUFFER_APPENDING,{type:a,data:l,parent:"main",content:"initSegment"}))}this.tick()}}},{key:"onFragParsingData",value:function(e){var t=this,r=this.fragCurrent,a=e.frag;if(r&&"main"===e.id&&a.sn===r.sn&&a.level===r.level&&("audio"!==e.type||!this.altAudio)&&this.state===A.PARSING){var i=this.levels[this.level],n=r;if(isNaN(e.endPTS)&&(e.endPTS=e.startPTS+r.duration,e.endDTS=e.startDTS+r.duration),T.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)return T.logger.warn("missing video frame(s), backtracking fragment"),n.backtracked=!0,this.nextLoadPosition=e.startPTS,this.state=A.IDLE,this.fragPrevious=n,void this.tick();T.logger.warn("Already backtracked on this fragment, appending with the gap")}else n.backtracked=!1;var o=b.default.updateFragPTSDTS(i.details,n,e.startPTS,e.endPTS,e.startDTS,e.endDTS),s=this.hls;s.trigger(g.default.LEVEL_PTS_UPDATED,{details:i.details,level:this.level,drift:o,type:e.type,start:e.startPTS,end:e.endPTS}),[e.data1,e.data2].forEach(function(r){r&&r.length&&t.state===A.PARSING&&(t.appended=!0,t.pendingBuffering=!0,s.trigger(g.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===A.PARSING&&(this.stats.tparsed=performance.now(),this.state=A.PARSED,this._checkAppendedParsed())}},{key:"onAudioTrackSwitching",value:function(e){var t=!!e.url,r=e.id;if(!t){if(this.mediaBuffer!==this.media){T.logger.log("switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var a=this.fragCurrent;a.loader&&(T.logger.log("switching to main audio track, cancel main fragment load"),a.loader.abort()),this.fragCurrent=null,this.fragPrevious=null,this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),this.state=A.IDLE}var i=this.hls;i.trigger(g.default.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),i.trigger(g.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 a=this.videoBuffer;a&&this.mediaBuffer!==a&&(T.logger.log("switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=a)}this.altAudio=r,this.tick()}},{key:"onBufferCreated",value:function(e){var t=e.tracks,r=void 0,a=void 0,i=!1;for(var n in t){var o=t[n];"main"===o.id?(a=n,r=o,"video"===n&&(this.videoBuffer=t[n].buffer)):i=!0}i&&r?(T.logger.log("alternate track found, use "+a+".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!==A.PARSING&&t!==A.PARSED||(this.pendingBuffering=e.pending>0,this._checkAppendedParsed())}}},{key:"_checkAppendedParsed",value:function(){if(!(this.state!==A.PARSED||this.appended&&this.pendingBuffering)){var e=this.fragCurrent;if(e){var t=this.mediaBuffer?this.mediaBuffer:this.media;T.logger.log("main buffered : "+_.default.toString(t.buffered));var r=this._bufferedFrags.filter(function(e){return f.default.isBuffered(t,(e.startPTS+e.endPTS)/2)});r.push(e),this._bufferedFrags=r.sort(function(e,t){return e.startPTS-t.startPTS}),this.fragPrevious=e;var a=this.stats;a.tbuffered=performance.now(),this.fragLastKbps=Math.round(8*a.total/(a.tbuffered-a.tfirst)),this.hls.trigger(g.default.FRAG_BUFFERED,{stats:a,frag:e,id:"main"}),this.state=A.IDLE}this.tick()}}},{key:"onError",value:function(e){var t=e.frag||this.fragCurrent;if(!t||"main"===t.type){var r=this.media,a=r&&f.default.isBuffered(r,r.currentTime)&&f.default.isBuffered(r,r.currentTime+.5);switch(e.details){case R.ErrorDetails.FRAG_LOAD_ERROR:case R.ErrorDetails.FRAG_LOAD_TIMEOUT:case R.ErrorDetails.KEY_LOAD_ERROR:case R.ErrorDetails.KEY_LOAD_TIMEOUT:if(!e.fatal){var i=this.fragLoadError;i?i++:i=1;var n=this.config;if(i<=n.fragLoadingMaxRetry||a||t.autoLevel&&t.level){this.fragLoadError=i,t.loadCounter=0;var o=Math.min(Math.pow(2,i-1)*n.fragLoadingRetryDelay,n.fragLoadingMaxRetryTimeout);T.logger.warn("mediaController: frag loading failed, retry in "+o+" ms"),this.retryDate=performance.now()+o,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.state=A.FRAG_LOADING_WAITING_RETRY}else T.logger.error("mediaController: "+e.details+" reaches max retry, redispatch as fatal ..."),e.fatal=!0,this.state=A.ERROR}break;case R.ErrorDetails.FRAG_LOOP_LOADING_ERROR:e.fatal||(a?(this._reduceMaxBufferLength(t.duration),this.state=A.IDLE):t.autoLevel&&0!==t.level||(e.fatal=!0,this.state=A.ERROR));break;case R.ErrorDetails.LEVEL_LOAD_ERROR:case R.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==A.ERROR&&(e.fatal?(this.state=A.ERROR,T.logger.warn("streamController: "+e.details+",switch to "+this.state+" state ...")):e.levelRetry||this.state!==A.WAITING_LEVEL||(this.state=A.IDLE));break;case R.ErrorDetails.BUFFER_FULL_ERROR:"main"!==e.parent||this.state!==A.PARSING&&this.state!==A.PARSED||(a?(this._reduceMaxBufferLength(this.config.maxBufferLength),this.state=A.IDLE):(T.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;t.maxMaxBufferLength>=e&&(t.maxMaxBufferLength/=2,T.logger.warn("main:reduce max buffer length to "+t.maxMaxBufferLength+"s"),this.fragLoadIdx+=2*t.fragLoadingLoopThreshold)}},{key:"_checkBuffer",value:function(){var e=this.media,t=this.config;if(e&&e.readyState){var r=e.currentTime,a=this.mediaBuffer?this.mediaBuffer:e,i=a.buffered;if(!this.loadedmetadata&&i.length){this.loadedmetadata=!0;var n=e.seeking?r:this.startPosition,o=f.default.isBuffered(a,n),s=i.start(0);(r!==n||!o&&Math.abs(n-s)<t.maxSeekHole)&&(T.logger.log("target start position:"+n),o||(n=s,T.logger.log("target start position not buffered, seek to buffered.start(0) "+n)),T.logger.log("adjust currentTime from "+r+" to "+n),e.currentTime=n)}else if(this.immediateSwitch)this.immediateLevelSwitchEnd();else{var l=f.default.bufferInfo(e,r,0),u=!(e.paused||e.ended||0===e.buffered.length),d=r!==this.lastCurrentTime;if(d)this.stallReported&&(T.logger.warn("playback not stuck anymore @"+r+", after "+Math.round(performance.now()-this.stalled)+"ms"),this.stallReported=!1),this.stalled=void 0,this.nudgeRetry=0;else if(u){var c=performance.now(),h=this.hls;if(this.stalled){var v=c-this.stalled,p=l.len,y=this.nudgeRetry||0;if(p<=.5&&v>1e3*t.lowBufferWatchdogPeriod){this.stallReported||(this.stallReported=!0,T.logger.warn("playback stalling in low buffer @"+r),h.trigger(g.default.ERROR,{
type:R.ErrorTypes.MEDIA_ERROR,details:R.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:p}));var m=l.nextStart,b=m-r;if(m&&b<t.maxSeekHole&&b>0){this.nudgeRetry=++y;var E=y*t.nudgeOffset;T.logger.log("adjust currentTime from "+e.currentTime+" to next buffered @ "+m+" + nudge "+E),e.currentTime=m+E,this.stalled=void 0,h.trigger(g.default.ERROR,{type:R.ErrorTypes.MEDIA_ERROR,details:R.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,hole:m+E-r})}}else if(p>.5&&v>1e3*t.highBufferWatchdogPeriod)if(this.stallReported||(this.stallReported=!0,T.logger.warn("playback stalling in high buffer @"+r),h.trigger(g.default.ERROR,{type:R.ErrorTypes.MEDIA_ERROR,details:R.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:p})),this.stalled=void 0,this.nudgeRetry=++y,y<t.nudgeMaxRetry){var _=e.currentTime,A=_+y*t.nudgeOffset;T.logger.log("adjust currentTime from "+_+" to "+A),e.currentTime=A,h.trigger(g.default.ERROR,{type:R.ErrorTypes.MEDIA_ERROR,details:R.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else T.logger.error("still stuck in high buffer @"+r+" after "+t.nudgeMaxRetry+", raise fatal error"),h.trigger(g.default.ERROR,{type:R.ErrorTypes.MEDIA_ERROR,details:R.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})}else this.stalled=c,this.stallReported=!1}}}}},{key:"onFragLoadEmergencyAborted",value:function(){this.state=A.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tick()}},{key:"onBufferFlushed",value:function(){var e=this.mediaBuffer?this.mediaBuffer:this.media;this._bufferedFrags=this._bufferedFrags.filter(function(t){return f.default.isBuffered(e,(t.startPTS+t.endPTS)/2)}),this.fragLoadIdx+=2*this.config.fragLoadingLoopThreshold,this.state=A.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:"state",set:function(e){if(this.state!==e){var t=this.state;this._state=e,T.logger.log("main stream:"+t+"->"+e),this.hls.trigger(g.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}(y.default);r.default=S},{20:20,28:28,29:29,30:30,32:32,33:33,43:43,46:46,47:47}],12:[function(e,t,r){"use strict";function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__esModule",{value:!0});var i=function(){function e(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),n=function(){function e(t,r){a(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}();r.default=n},{}],13:[function(e,t,r){"use strict";function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__esModule",{value:!0});var i=function(){function e(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),n=function(){function e(){a(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),a=0;a<4;a++)r[a]=t.getUint32(4*a);return r}},{key:"initTable",value:function(){var e=this.sBox,t=this.invSBox,r=this.subMix,a=r[0],i=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;a[h]=E<<24|E>>>8,i[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,a=0;a<t.length&&r;)r=t[a]===this.key[a],a++;if(!r){this.key=t;var i=this.keySize=t.length;if(4!==i&&6!==i&&8!==i)throw new Error("Invalid aes key size="+i);var n=this.ksRows=4*(i+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<i?y=l[o]=t[o]:(m=y,o%i==0?(m=m<<8|m>>>24,m=d[m>>>24]<<24|d[m>>>16&255]<<16|d[m>>>8&255]<<8|d[255&m],m^=f[o/i|0]<<24):i>6&&o%i==4&&(m=d[m>>>24]<<24|d[m>>>16&255]<<16|d[m>>>8&255]<<8|d[255&m]),l[o]=y=(l[o-i]^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){for(var a,i,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,R=void 0,T=void 0,A=void 0,S=void 0,k=void 0,L=void 0,w=void 0,D=void 0,O=void 0,P=void 0,x=this.networkToHostOrderSwap;t<m.length;){for(w=x(m[t]),D=x(m[t+1]),O=x(m[t+2]),P=x(m[t+3]),A=w^o[0],S=P^o[1],k=O^o[2],L=D^o[3],a=4,i=1;i<n;i++)E=u[A>>>24]^d[S>>16&255]^f[k>>8&255]^c[255&L]^o[a],_=u[S>>>24]^d[k>>16&255]^f[L>>8&255]^c[255&A]^o[a+1],R=u[k>>>24]^d[L>>16&255]^f[A>>8&255]^c[255&S]^o[a+2],T=u[L>>>24]^d[A>>16&255]^f[S>>8&255]^c[255&k]^o[a+3],A=E,S=_,k=R,L=T,a+=4;E=s[A>>>24]<<24^s[S>>16&255]<<16^s[k>>8&255]<<8^s[255&L]^o[a],_=s[S>>>24]<<24^s[k>>16&255]<<16^s[L>>8&255]<<8^s[255&A]^o[a+1],R=s[k>>>24]<<24^s[L>>16&255]<<16^s[A>>8&255]<<8^s[255&S]^o[a+2],T=s[L>>>24]<<24^s[A>>16&255]<<16^s[S>>8&255]<<8^s[255&k]^o[a+3],a+=3,b[t]=x(E^v),b[t+1]=x(T^g),b[t+2]=x(R^p),b[t+3]=x(_^y),v=w,g=D,p=O,y=P,t+=4}return 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}();r.default=n},{}],14:[function(e,t,r){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__esModule",{value:!0});var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),o=e(12),s=a(o),l=e(15),u=a(l),d=e(13),f=a(d),c=e(28),h=e(46),v=function(){function e(t,r){i(this,e),this.observer=t,this.config=r,this.logEnabled=!0;try{var a=crypto?crypto:self.crypto;this.subtle=a.subtle||a.webkitSubtle}catch(e){}this.disableWebCrypto=!this.subtle}return n(e,[{key:"isSync",value:function(){return this.disableWebCrypto&&this.config.enableSoftwareAES}},{key:"decrypt",value:function(e,t,r,a){var i=this;if(this.disableWebCrypto&&this.config.enableSoftwareAES){this.logEnabled&&(h.logger.log("JS AES decrypt"),this.logEnabled=!1);var n=this.decryptor;n||(this.decryptor=n=new f.default),n.expandKey(t),a(n.decrypt(e,0,r))}else{this.logEnabled&&(h.logger.log("WebCrypto AES decrypt"),this.logEnabled=!1);var o=this.subtle;this.key!==t&&(this.key=t,this.fastAesKey=new u.default(o,t)),this.fastAesKey.expandKey().then(function(n){new s.default(o,r).decrypt(e,n).catch(function(n){i.onWebCryptoError(n,e,t,r,a)}).then(function(e){a(e)})}).catch(function(n){i.onWebCryptoError(n,e,t,r,a)})}}},{key:"onWebCryptoError",value:function(e,t,r,a,i){this.config.enableSoftwareAES?(h.logger.log("WebCrypto Error, disable WebCrypto API"),this.disableWebCrypto=!0,this.logEnabled=!0,this.decrypt(t,r,a,i)):(h.logger.error("decrypting error : "+e.message),this.observer.trigger(Event.ERROR,{type:c.ErrorTypes.MEDIA_ERROR,details:c.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}();r.default=v},{12:12,13:13,15:15,28:28,46:46}],15:[function(e,t,r){"use strict";function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__esModule",{value:!0});var i=function(){function e(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),n=function(){function e(t,r){a(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}();r.default=n},{}],16:[function(e,t,r){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__esModule",{value:!0});var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),o=e(17),s=a(o),l=e(46),u=e(22),d=a(u),f=function(){function e(t,r,a){i(this,e),this.observer=t,this.config=a,this.remuxer=r}return n(e,[{key:"resetInitSegment",value:function(e,t,r,a){this._audioTrack={container:"audio/adts",type:"audio",id:-1,sequenceNumber:0,isAAC:!0,samples:[],len:0,manifestCodec:t,duration:a,inputTimeScale:9e4}}},{key:"resetTimeStamp",value:function(){}},{key:"append",value:function(e,t,r,a){for(var i=this._audioTrack,n=d.default.getID3Data(e,0),o=90*d.default.getTimeStamp(n),u=0,f=o,c=e.length,h=n.length,v=[{pts:f,dts:f,data:n}];h<c-1;)if(s.default.isHeader(e,h)&&h+5<c){s.default.initTrackConfig(i,this.observer,e,h,i.manifestCodec);var g=s.default.appendFrame(i,e,h,o,u);if(!g){l.logger.log("Unable to parse AAC frame");break}h+=g.length,f=g.sample.pts,u++}else d.default.isHeader(e,h)?(n=d.default.getID3Data(e,h),v.push({pts:f,dts:f,data:n}),h+=n.length):h++;this.remuxer.remux(i,{samples:[]},{samples:v,inputTimeScale:9e4},{samples:[]},t,r,a)}},{key:"destroy",value:function(){}}],[{key:"probe",value:function(e){var t,r,a=d.default.getID3Data(e,0);if(a&&void 0!==d.default.getTimeStamp(a))for(t=a.length,r=Math.min(e.length-1,t+100);t<r;t++)if(s.default.isHeader(e,t))return!0;return!1}}]),e}();r.default=f},{17:17,22:22,46:46}],17:[function(e,t,r){"use strict";var a=e(46),i=e(28),n={getAudioConfig:function(e,t,r,n){var o,s,l,u,d,f=navigator.userAgent.toLowerCase(),c=n,h=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];return o=1+((192&t[r+2])>>>6),(s=(60&t[r+2])>>>2)>h.length-1?void e.trigger(Event.ERROR,{type:i.ErrorTypes.MEDIA_ERROR,details:i.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+s}):(u=(1&t[r+2])<<2,u|=(192&t[r+3])>>>6,a.logger.log("manifest codec:"+n+",ADTS data:type:"+o+",sampleingIndex:"+s+"["+h[s]+"Hz],channelConfig:"+u),/firefox/i.test(f)?s>=6?(o=5,d=new Array(4),l=s-3):(o=2,d=new Array(2),l=s):f.indexOf("android")!==-1?(o=2,d=new Array(2),l=s):(o=5,d=new Array(4),n&&(n.indexOf("mp4a.40.29")!==-1||n.indexOf("mp4a.40.5")!==-1)||!n&&s>=6?l=s-3:((n&&n.indexOf("mp4a.40.2")!==-1&&s>=6&&1===u||!n&&1===u)&&(o=2,d=new Array(2)),l=s)),d[0]=o<<3,d[0]|=(14&s)>>1,d[1]|=(1&s)<<7,d[1]|=u<<3,5===o&&(d[1]|=(14&l)>>1,d[2]=(1&l)<<7,d[2]|=8,d[3]=0),{config:d,samplerate:h[s],channelCount:u,codec:"mp4a.40."+o,manifestCodec:c})},isHeader:function(e,t){return t+1<e.length&&255===e[t]&&240==(246&e[t+1])},initTrackConfig:function(e,t,r,i,n){if(!e.samplerate){var o=this.getAudioConfig(t,r,i,n);e.config=o.config,e.samplerate=o.samplerate,e.channelCount=o.channelCount,e.codec=o.codec,e.manifestCodec=o.manifestCodec,a.logger.log("parsed codec:"+e.codec+",rate:"+o.samplerate+",nb channel:"+o.channelCount)}},getFrameDuration:function(e){return 9216e4/e},appendFrame:function(e,t,r,a,i){var n=this.getFrameDuration(e.samplerate),o=this.parseFrameHeader(t,r,a,i,n);if(o){var s=o.stamp,l=o.headerLength,u=o.frameLength,d={unit:t.subarray(r+l,r+l+u),pts:s,dts:s};return e.samples.push(d),e.len+=u,{sample:d,length:u+l}}},parseFrameHeader:function(e,t,r,a,i){var n,o,s,l=e.length;if(n=1&e[t+1]?7:9,o=(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5,(o-=n)>0&&t+n+o<=l)return s=r+a*i,{headerLength:n,frameLength:o,stamp:s}}};t.exports=n},{28:28,46:46}],18:[function(e,t,r){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__esModule",{value:!0});var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),o=e(30),s=a(o),l=e(28),u=e(14),d=a(u),f=e(16),c=a(f),h=e(24),v=a(h),g=e(27),p=a(g),y=e(23),m=a(y),b=e(40),E=a(b),_=e(41),R=a(_),T=function(){function e(t,r,a,n){i(this,e),this.observer=t,this.typeSupported=r,this.config=a,this.vendor=n}return n(e,[{key:"destroy",value:function(){var e=this.demuxer;e&&e.destroy()}},{key:"push",value:function(e,t,r,a,i,n,o,l,u,f,c,h){if(e.byteLength>0&&null!=t&&null!=t.key&&"AES-128"===t.method){var v=this.decrypter;null==v&&(v=this.decrypter=new d.default(this.observer,this.config));var g,p=this;try{g=performance.now()}catch(e){g=Date.now()}v.decrypt(e,t.key.buffer,t.iv.buffer,function(e){var d;try{d=performance.now()}catch(e){d=Date.now()}p.observer.trigger(s.default.FRAG_DECRYPTED,{stats:{tstart:g,tdecrypt:d}}),p.pushDecrypted(new Uint8Array(e),t,new Uint8Array(r),a,i,n,o,l,u,f,c,h)})}else this.pushDecrypted(new Uint8Array(e),t,new Uint8Array(r),a,i,n,o,l,u,f,c,h)}},{key:"pushDecrypted",value:function(e,t,r,a,i,n,o,u,d,f,h,g){var y=this.demuxer;if(!y||o&&!this.probe(e)){var b=this.observer,_=this.typeSupported,T=this.config,A=[{demux:p.default,remux:E.default},{demux:m.default,remux:E.default},{demux:c.default,remux:E.default},{demux:v.default,remux:R.default}];for(var S in A){var k=A[S],L=k.demux.probe;if(L(e)){var w=this.remuxer=new k.remux(b,T,_,this.vendor);y=new k.demux(b,w,T,_),this.probe=L;break}}if(!y)return void b.trigger(s.default.ERROR,{type:l.ErrorTypes.MEDIA_ERROR,details:l.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"});this.demuxer=y}var D=this.remuxer;(o||u)&&(y.resetInitSegment(r,a,i,f),D.resetInitSegment()),o&&(y.resetTimeStamp(g),D.resetTimeStamp(g)),"function"==typeof y.setDecryptData&&y.setDecryptData(t),y.append(e,n,d,h)}}]),e}();r.default=T},{14:14,16:16,23:23,24:24,27:27,28:28,30:30,40:40,41:41}],19:[function(e,t,r){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(r,"__esModule",{value:!0});var i=e(18),n=a(i),o=e(30),s=a(o),l=e(46),u=e(1),d=a(u),f=function(e){var t=new d.default;t.trigger=function(e){for(var r=arguments.length,a=Array(r>1?r-1:0),i=1;i<r;i++)a[i-1]=arguments[i];t.emit.apply(t,[e,e].concat(a))},t.off=function(e){for(var r=arguments.length,a=Array(r>1?r-1:0),i=1;i<r;i++)a[i-1]=arguments[i];t.removeListener.apply(t,[e].concat(a))};var r=function(t,r){e.postMessage({event:t,data:r})};e.addEventListener("message",function(a){var i=a.data;switch(i.cmd){case"init":var o=JSON.parse(i.config);e.demuxer=new n.default(t,i.typeSupported,o,i.vendor);try{(0,l.enableLogs)(o.debug===!0)}catch(e){}r("init",null);break;case"demux":e.demuxer.push(i.data,i.decryptdata,i.initSegment,i.audioCodec,i.videoCodec,i.timeOffset,i.discontinuity,i.trackSwitch,i.contiguous,i.duration,i.accurateTimeOffset,i.defaultInitPTS)}}),t.on(s.default.FRAG_DECRYPTED,r),t.on(s.default.FRAG_PARSING_INIT_SEGMENT,r),t.on(s.default.FRAG_PARSED,r),t.on(s.default.ERROR,r),t.on(s.default.FRAG_PARSING_METADATA,r),t.on(s.default.FRAG_PARSING_USERDATA,r),t.on(s.default.INIT_PTS_FOUND,r),t.on(s.default.FRAG_PARSING_DATA,function(t,r){var a=[],i={event:t,data:r};r.data1&&(i.data1=r.data1.buffer,a.push(r.data1.buffer),delete r.data1),r.data2&&(i.data2=r.data2.buffer,a.push(r.data2.buffer),delete r.data2),e.postMessage(i,a)})};r.default=f},{1:1,18:18,30:30,46:46}],20:[function(e,t,r){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__esModule",{value:!0});var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),o=e(30),s=a(o),l=e(18),u=a(l),d=e(19),f=a(d),c=e(46),h=e(28),v=e(1),g=a(v),p=function(){function t(r,a){i(this,t),this.hls=r,this.id=a;var n=this.observer=new g.default,o=r.config;n.trigger=function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),a=1;a<t;a++)r[a-1]=arguments[a];n.emit.apply(n,[e,e].concat(r))},n.off=function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),a=1;a<t;a++)r[a-1]=arguments[a];n.removeListener.apply(n,[e].concat(r))};var l=function(e,t){t=t||{},t.frag=this.frag,t.id=this.id,r.trigger(e,t)}.bind(this);n.on(s.default.FRAG_DECRYPTED,l),n.on(s.default.FRAG_PARSING_INIT_SEGMENT,l),n.on(s.default.FRAG_PARSING_DATA,l),n.on(s.default.FRAG_PARSED,l),n.on(s.default.ERROR,l),n.on(s.default.FRAG_PARSING_METADATA,l),n.on(s.default.FRAG_PARSING_USERDATA,l),n.on(s.default.INIT_PTS_FOUND,l);var d={mp4:MediaSource.isTypeSupported("video/mp4"),mpeg:MediaSource.isTypeSupported("audio/mpeg"),mp3:MediaSource.isTypeSupported('audio/mp4; codecs="mp3"')},v=navigator.vendor;if(o.enableWorker&&"undefined"!=typeof Worker){c.logger.log("demuxing in webworker");var p=void 0;try{var y=e(3);p=this.w=y(f.default),this.onwmsg=this.onWorkerMessage.bind(this),p.addEventListener("message",this.onwmsg),p.onerror=function(e){r.trigger(s.default.ERROR,{type:h.ErrorTypes.OTHER_ERROR,details:h.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",err:{message:e.message+" ("+e.filename+":"+e.lineno+")"}})},p.postMessage({cmd:"init",typeSupported:d,vendor:v,id:a,config:JSON.stringify(o)})}catch(e){c.logger.error("error while initializing DemuxerWorker, fallback on DemuxerInline"),p&&URL.revokeObjectURL(p.objectURL),this.demuxer=new u.default(n,d,o,v),this.w=void 0}}else this.demuxer=new u.default(n,d,o,v)}return n(t,[{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,a,i,n,o,s){var l=this.w,u=isNaN(i.startDTS)?i.start:i.startDTS,d=i.decryptdata,f=this.frag,h=!(f&&i.cc===f.cc),v=!(f&&i.level===f.level),g=f&&i.sn===f.sn+1,p=!v&&g;if(h&&c.logger.log(this.id+":discontinuity detected"),v&&c.logger.log(this.id+":switch detected"),this.frag=i,l)l.postMessage({cmd:"demux",data:e,decryptdata:d,initSegment:t,audioCodec:r,videoCodec:a,timeOffset:u,discontinuity:h,trackSwitch:v,contiguous:p,duration:n,accurateTimeOffset:o,defaultInitPTS:s},[e]);else{var y=this.demuxer;y&&y.push(e,d,t,r,a,u,h,v,p,n,o,s)}}},{key:"onWorkerMessage",value:function(e){var t=e.data,r=this.hls;switch(t.event){case"init":URL.revokeObjectURL(this.w.objectURL);break;case s.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)}}}]),t}();r.default=p},{1:1,18:18,19:19,28:28,3:3,30:30,46:46}],21:[function(e,t,r){"use strict";function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__esModule",{value:!0});var i=function(){function e(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),n=e(46),o=function(){function e(t){a(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,a=new Uint8Array(4),i=Math.min(4,t);if(0===i)throw new Error("no bytes available");a.set(e.subarray(r,r+i)),this.word=new DataView(a.buffer).getUint32(0),this.bitsAvailable=8*i,this.bytesAvailable-=i}},{key:"skipBits",value:function(e){var t;this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,t=e>>3,e-=t>>3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}},{key:"readBits",value:function(e){var t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;return e>32&&n.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,t>0&&this.bitsAvailable?r<<t|this.readBits(t):r}},{key:"skipLZ",value:function(){var e;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,r,a=8,i=8;for(t=0;t<e;t++)0!==i&&(r=this.readEG(),i=(a+r+256)%256),a=0===i?a:i}},{key:"readSPS",value:function(){var e,t,r,a,i,n,o,s=0,l=0,u=0,d=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(n=3!==b?8:12,o=0;o<n;o++)v()&&m(o<6?16:64)}y();var E=h();if(0===E)h();else if(1===E)for(g(1),p(),p(),t=h(),o=0;o<t;o++)p();y(),g(1),r=h(),a=h(),i=c(1),0===i&&g(1),g(1),v()&&(s=h(),l=h(),u=h(),d=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*(r+1)-2*s-2*l),height:(2-i)*(a+1)*16-(i?2:4)*(u+d),pixelRatio:_}}},{key:"readSliceType",value:function(){return this.readUByte(),this.readUEG(),this.readUEG()}}]),e}();r.default=o},{46:46}],22:[function(e,t,r){"use strict";function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__esModule",{value:!0});var i=function(){function e(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),n=function(){function e(){a(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 a=r,i=0;e.isHeader(t,r);){i+=10;i+=e._readSize(t,r+6),e.isFooter(t,r+10)&&(i+=10),r+=i}if(i>0)return t.subarray(a,a+i)}},{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),a=0;a<r.length;a++){var i=r[a];if(e.isTimeStampFrame(i))return e._readTimeStamp(i)}}},{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]),a=e._readSize(t,4);return{type:r,size:a,data:t.subarray(10,10+a)}}},{key:"getID3Frames",value:function(t){for(var r=0,a=[];e.isHeader(t,r);){var i=e._readSize(t,r+6);r+=10;for(var n=r+i;r+8<n;){var o=e._getFrameData(t.subarray(r)),s=e._decodeFrame(o);s&&a.push(s),r+=o.size+10}e.isFooter(t,r)&&(r+=10)}return a}},{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],a=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return a/=45,r&&(a+=47721858.84),Math.round(a)}}},{key:"_decodePrivFrame",value:function(t){if(!(t.size<2)){var r=e._utf8ArrayToStr(t.data),a=new Uint8Array(t.data.subarray(r.length+1));return{key:t.type,info:r,data:a.buffer}}}},{key:"_decodeTextFrame",value:function(t){if(!(t.size<2)){if("TXXX"===t.type){var r=1,a=e._utf8ArrayToStr(t.data.subarray(r));r+=a.length+1;var i=e._utf8ArrayToStr(t.data.subarray(r));return{key:t.type,info:a,data:i}}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,a=e._utf8ArrayToStr(t.data.subarray(r));r+=a.length+1;var i=e._utf8ArrayToStr(t.data.subarray(r));return{key:t.type,info:a,data:i}}var n=e._utf8ArrayToStr(t.data);return{key:t.type,data:n}}},{key:"_utf8ArrayToStr",value:function(e){for(var t=void 0,r=void 0,a="",i=0,n=e.length;i<n;){var o=e[i++];switch(o>>4){case 0:return a;case 1:case 2:case 3:case 4:case 5:case 6:case 7:a+=String.fromCharCode(o);break;case 12:case 13:t=e[i++],a+=String.fromCharCode((31&o)<<6|63&t);break;case 14:t=e[i++],r=e[i++],a+=String.fromCharCode((15&o)<<12|(63&t)<<6|(63&r)<<0)}}return a}}]),e}();r.default=n},{}],23:[function(e,t,r){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__esModule",{value:!0});var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),o=e(22),s=a(o),l=e(25),u=a(l),d=function(){function e(t,r,a){i(this,e),this.observer=t,this.config=a,this.remuxer=r}return n(e,[{key:"resetInitSegment",value:function(e,t,r,a){this._audioTrack={container:"audio/mpeg",type:"audio",id:-1,sequenceNumber:0,isAAC:!1,samples:[],len:0,manifestCodec:t,duration:a,inputTimeScale:9e4}}},{key:"resetTimeStamp",value:function(){}},{key:"append",value:function(e,t,r,a){for(var i=s.default.getID3Data(e,0),n=90*s.default.getTimeStamp(i),o=i.length,l=e.length,d=0,f=0,c=this._audioTrack,h=[{pts:n,dts:n,data:i}];o<l;)if(u.default.isHeader(e,o)){var v=u.default.appendFrame(c,e,o,n,d);if(!v)break;o+=v.length,f=v.sample.pts,d++}else s.default.isHeader(e,o)?(i=s.default.getID3Data(e,o),h.push({pts:f,dts:f,data:i}),o+=i.length):o++;this.remuxer.remux(c,{samples:[]},{samples:h,inputTimeScale:9e4},{samples:[]},t,r,a)}},{key:"destroy",value:function(){}}],[{key:"probe",value:function(e){var t,r,a=s.default.getID3Data(e,0);if(a&&void 0!==s.default.getTimeStamp(a))for(t=a.length,r=Math.min(e.length-1,t+100);t<r;t++)if(u.default.isHeader(e,t))return!0;return!1}}]),e}();r.default=d},{22:22,25:25}],24:[function(e,t,r){"use strict";function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__esModule",{value:!0});var i=function(){function e(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),n=e(30),o=function(e){return e&&e.__esModule?e:{default:e}}(n),s=Math.pow(2,32)-1,l=function(){function e(t,r){a(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,a,i){if(t&&t.byteLength){var n=this.initData=e.parseInitSegment(t),s={};n.audio&&(s.audio={container:"audio/mp4",codec:r,initSegment:i?t:null}),n.video&&(s.video={container:"video/mp4",codec:a,initSegment:i?t:null}),this.observer.trigger(o.default.FRAG_PARSING_INIT_SEGMENT,{tracks:s})}else r&&(this.audioCodec=r),a&&(this.videoCodec=a)}},{key:"append",value:function(t,r,a,i){var n=this.initData;n||(this.resetInitSegment(t,this.audioCodec,this.videoCodec),n=this.initData);var s=void 0,l=this.initPTS;if(void 0===l){var u=e.getStartDTS(n,t);this.initPTS=l=u-r,this.observer.trigger(o.default.INIT_PTS_FOUND,{initPTS:l})}e.offsetStartDTS(n,t,l),s=e.getStartDTS(n,t),this.remuxer.remux(n.audio,n.video,null,null,s,a,i,t)}},{key:"destroy",value:function(){}}],[{key:"probe",value:function(t){if(t.length>=8){var r=e.bin2str(t.subarray(4,8));return["moof","ftyp","styp"].indexOf(r)>=0}return!1}},{key:"bin2str",value:function(e){return String.fromCharCode.apply(null,e)}},{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 a,i,n,o,s,l,u,d=[];if(t.data?(l=t.start,o=t.end,t=t.data):(l=0,o=t.byteLength),!r.length)return null;for(a=l;a<o;)i=e.readUint32(t,a),n=e.bin2str(t.subarray(a+4,a+8)),u=i>1?a+i:o,n===r[0]&&(1===r.length?d.push({data:t,start:a+8,end:u}):(s=e.findBox({data:t,start:a+8,end:u},r.slice(1)),s.length&&(d=d.concat(s)))),a=u;return d}},{key:"parseInitSegment",value:function(t){var r=[];return e.findBox(t,["moov","trak"]).forEach(function(t){var a=e.findBox(t,["tkhd"])[0];if(a){var i=a.data[a.start],n=0===i?12:20,o=e.readUint32(a,n),s=e.findBox(t,["mdia","mdhd"])[0];if(s){i=s.data[s.start],n=0===i?12:20;var l=e.readUint32(s,n),u=e.findBox(t,["mdia","hdlr"])[0];if(u){var d=e.bin2str(u.data.subarray(u.start+8,u.start+12)),f={soun:"audio",
vide:"video"}[d];f&&(r[o]={timescale:l,type:f},r[f]={timescale:l,id:o})}}}}),r}},{key:"getStartDTS",value:function(t,r){var a,i,n;return a=e.findBox(r,["moof","traf"]),i=[].concat.apply([],a.map(function(r){return e.findBox(r,["tfhd"]).map(function(a){var i,n,o;return i=e.readUint32(a,4),n=t[i].timescale||9e4,o=e.findBox(r,["tfdt"]).map(function(t){var r,a;return r=t.data[t.start],a=e.readUint32(t,4),1===r&&(a*=Math.pow(2,32),a+=e.readUint32(t,8)),a})[0],(o=o||1/0)/n})})),n=Math.min.apply(null,i),isFinite(n)?n:0}},{key:"offsetStartDTS",value:function(t,r,a){e.findBox(r,["moof","traf"]).map(function(r){return e.findBox(r,["tfhd"]).map(function(i){var n=e.readUint32(i,4),o=t[n].timescale||9e4;e.findBox(r,["tfdt"]).map(function(t){var r=t.data[t.start],i=e.readUint32(t,4);if(0===r)e.writeUint32(t,4,i-a*o);else{i*=Math.pow(2,32),i+=e.readUint32(t,8),i-=a*o;var n=Math.floor(i/(s+1)),l=Math.floor(i%(s+1));e.writeUint32(t,4,n),e.writeUint32(t,8,l)}})})})}}]),e}();r.default=l},{30:30}],25:[function(e,t,r){"use strict";var a={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],appendFrame:function(e,t,r,a,i){if(!(r+24>t.length)){var n=this.parseHeader(t,r);if(n&&r+n.frameLength<=t.length){var o=10368e4/n.sampleRate,s=a+i*o,l={unit:t.subarray(r,r+n.frameLength),pts:s,dts:s};return e.config=[],e.channelCount=n.channelCount,e.samplerate=n.sampleRate,e.samples.push(l),e.len+=n.frameLength,{sample:l,length:n.frameLength}}}},parseHeader:function(e,t){var r=e[t+1]>>3&3,i=e[t+1]>>1&3,n=e[t+2]>>4&15,o=e[t+2]>>2&3,s=!!(2&e[t+2]);if(1!==r&&0!==n&&15!==n&&3!==o){var l=3===r?3-i:3===i?3:4,u=1e3*a.BitratesMap[14*l+n-1],d=3===r?0:2===r?1:2,f=a.SamplingRateMap[3*d+o],c=s?1:0;return{sampleRate:f,channelCount:e[t+3]>>6==3?1:2,frameLength:3===i?(3===r?12:6)*u/f+c<<2:(3===r?144:72)*u/f+c|0}}},isHeader:function(e,t){return t+1<e.length&&255===e[t]&&224==(224&e[t+1])&&0!=(6&e[t+1])}};t.exports=a},{}],26:[function(e,t,r){"use strict";function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__esModule",{value:!0});var i=function(){function e(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),n=e(14),o=function(e){return e&&e.__esModule?e:{default:e}}(n),s=function(){function e(t,r,i,n){a(this,e),this.decryptdata=i,this.discardEPB=n,this.decrypter=new o.default(t,r)}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,a){var i=e[t].unit,n=i.subarray(16,i.length-i.length%16),o=n.buffer.slice(n.byteOffset,n.byteOffset+n.length),s=this;this.decryptBuffer(o,function(n){n=new Uint8Array(n),i.set(n,16),a||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 a=this.decrypter.isSync();if(this.decryptAacSample(e,t,r,a),!a)return}}}},{key:"getAvcEncryptedData",value:function(e){for(var t=16*Math.floor((e.length-48)/160)+16,r=new Int8Array(t),a=0,i=32;i<=e.length-16;i+=160,a+=16)r.set(e.subarray(i,i+16),a);return r}},{key:"getAvcDecryptedUnit",value:function(e,t){t=new Uint8Array(t);for(var r=0,a=32;a<=e.length-16;a+=160,r+=16)e.set(t.subarray(r,r+16),a);return e}},{key:"decryptAvcSample",value:function(e,t,r,a,i,n){var o=this.discardEPB(i.data),s=this.getAvcEncryptedData(o),l=this;this.decryptBuffer(s.buffer,function(s){i.data=l.getAvcDecryptedUnit(o,s),n||l.decryptAvcSamples(e,t,r+1,a)})}},{key:"decryptAvcSamples",value:function(e,t,r,a){for(;;t++,r=0){if(t>=e.length)return void a();for(var i=e[t].units;!(r>=i.length);r++){var n=i[r];if(!(n.length<=48||1!==n.type&&5!==n.type)){var o=this.decrypter.isSync();if(this.decryptAvcSample(e,t,r,a,n,o),!o)return}}}}}]),e}();r.default=s},{14:14}],27:[function(e,t,r){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__esModule",{value:!0});var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),o=e(17),s=a(o),l=e(25),u=a(l),d=e(30),f=a(d),c=e(21),h=a(c),v=e(26),g=a(v),p=e(46),y=e(28),m=function(){function e(t,r,a,n){i(this,e),this.observer=t,this.config=a,this.typeSupported=n,this.remuxer=r,this.sampleAes=null}return n(e,[{key:"setDecryptData",value:function(e){null!=e&&null!=e.key&&"SAMPLE-AES"===e.method?this.sampleAes=new g.default(this.observer,this.config,e,this.discardEPB):this.sampleAes=null}},{key:"resetInitSegment",value:function(e,t,r,a){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack={container:"video/mp2t",type:"video",id:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],len:0,dropped:0},this._audioTrack={container:"video/mp2t",type:"audio",id:-1,inputTimeScale:9e4,duration:a,sequenceNumber:0,samples:[],len:0,isAAC:!0},this._id3Track={type:"id3",id:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],len:0},this._txtTrack={type:"text",id:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],len:0},this.aacOverFlow=null,this.aacLastPTS=null,this.avcSample=null,this.audioCodec=t,this.videoCodec=r,this._duration=a}},{key:"resetTimeStamp",value:function(){}},{key:"append",value:function(e,t,r,a){var i,n,o,s,l,u=e.length,d=!1;this.contiguous=r;var c=this.pmtParsed,h=this._avcTrack,v=this._audioTrack,g=this._id3Track,m=h.id,b=v.id,E=g.id,_=this._pmtId,R=h.pesData,T=v.pesData,A=g.pesData,S=this._parsePAT,k=this._parsePMT,L=this._parsePES,w=this._parseAVCPES.bind(this),D=this._parseAACPES.bind(this),O=this._parseMPEGPES.bind(this),P=this._parseID3PES.bind(this);for(u-=u%188,i=0;i<u;i+=188)if(71===e[i]){if(n=!!(64&e[i+1]),o=((31&e[i+1])<<8)+e[i+2],(48&e[i+3])>>4>1){if((s=i+5+e[i+4])===i+188)continue}else s=i+4;switch(o){case m:n&&(R&&(l=L(R))&&w(l,!1),R={data:[],size:0}),R&&(R.data.push(e.subarray(s,i+188)),R.size+=i+188-s);break;case b:n&&(T&&(l=L(T))&&(v.isAAC?D(l):O(l)),T={data:[],size:0}),T&&(T.data.push(e.subarray(s,i+188)),T.size+=i+188-s);break;case E:n&&(A&&(l=L(A))&&P(l),A={data:[],size:0}),A&&(A.data.push(e.subarray(s,i+188)),A.size+=i+188-s);break;case 0:n&&(s+=e[s]+1),_=this._pmtId=S(e,s);break;case _:n&&(s+=e[s]+1);var x=k(e,s,this.typeSupported.mpeg===!0||this.typeSupported.mp3===!0,null!=this.sampleAes);m=x.avc,m>0&&(h.id=m),b=x.audio,b>0&&(v.id=b,v.isAAC=x.isAAC),E=x.id3,E>0&&(g.id=E),d&&!c&&(p.logger.log("reparse from beginning"),d=!1,i=-188),c=this.pmtParsed=!0;break;case 17:case 8191:break;default:d=!0}}else this.observer.trigger(f.default.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});R&&(l=L(R))?(w(l,!0),h.pesData=null):h.pesData=R,T&&(l=L(T))?(v.isAAC?D(l):O(l),v.pesData=null):(T&&T.size&&p.logger.log("last AAC PES packet truncated,might overlap between fragments"),v.pesData=T),A&&(l=L(A))?(P(l),g.pesData=null):g.pesData=A,null==this.sampleAes?this.remuxer.remux(v,h,g,this._txtTrack,t,r,a):this.decryptAndRemux(v,h,g,this._txtTrack,t,r,a)}},{key:"decryptAndRemux",value:function(e,t,r,a,i,n,o){if(e.samples&&e.isAAC){var s=this;this.sampleAes.decryptAacSamples(e.samples,0,function(){s.decryptAndRemuxAvc(e,t,r,a,i,n,o)})}else this.decryptAndRemuxAvc(e,t,r,a,i,n,o)}},{key:"decryptAndRemuxAvc",value:function(e,t,r,a,i,n,o){if(t.samples){var s=this;this.sampleAes.decryptAvcSamples(t.samples,0,0,function(){s.remuxer.remux(e,t,r,a,i,n,o)})}else this.remuxer.remux(e,t,r,a,i,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,a){var i,n,o,s,l={audio:-1,avc:-1,id3:-1,isAAC:!0};for(i=(15&e[t+1])<<8|e[t+2],n=t+3+i-4,o=(15&e[t+10])<<8|e[t+11],t+=12+o;t<n;){switch(s=(31&e[t+1])<<8|e[t+2],e[t]){case 207:if(!a){p.logger.log("unkown stream type:"+e[t]);break}case 15:l.audio===-1&&(l.audio=s);break;case 21:l.id3===-1&&(l.id3=s);break;case 219:if(!a){p.logger.log("unkown stream type:"+e[t]);break}case 27:l.avc===-1&&(l.avc=s);break;case 3:case 4:r?l.audio===-1&&(l.audio=s,l.isAAC=!1):p.logger.log("MPEG audio found, not supported in this browser for now");break;case 36:p.logger.warn("HEVC stream type found, not supported for now");break;default:p.logger.log("unkown stream type:"+e[t])}t+=5+((15&e[t+3])<<8|e[t+4])}return l}},{key:"_parsePES",value:function(e){var t,r,a,i,n,o,s,l,u=0,d=e.data;if(!e||0===e.size)return null;for(;d[0].length<19&&d.length>1;){var f=new Uint8Array(d[0].length+d[1].length);f.set(d[0]),f.set(d[1],d[0].length),d[0]=f,d.splice(1,1)}if(t=d[0],1===(t[0]<<16)+(t[1]<<8)+t[2]){if((a=(t[4]<<8)+t[5])&&a>e.size-6)return null;r=t[7],192&r&&(o=536870912*(14&t[9])+4194304*(255&t[10])+16384*(254&t[11])+128*(255&t[12])+(254&t[13])/2,o>4294967295&&(o-=8589934592),64&r?(s=536870912*(14&t[14])+4194304*(255&t[15])+16384*(254&t[16])+128*(255&t[17])+(254&t[18])/2,s>4294967295&&(s-=8589934592),o-s>54e5&&(p.logger.warn(Math.round((o-s)/9e4)+"s delta between PTS and DTS, align them"),o=s)):s=o),i=t[8],l=i+9,e.size-=l,n=new Uint8Array(e.size);for(var c=0,h=d.length;c<h;c++){t=d[c];var v=t.byteLength;if(l){if(l>v){l-=v;continue}t=t.subarray(l),v-=l,l=0}n.set(t,u),u+=v}return a&&(a-=i+3),{data:n,pts:o,dts:s,len:a}}return null}},{key:"pushAccesUnit",value:function(e,t){if(e.units.length&&e.frame){var r=t.samples,a=r.length;!this.config.forceKeyFrameOnDiscontinuity||e.key===!0||t.sps&&(a||this.contiguous)?(e.id=a,r.push(e)):t.dropped++}e.debug.length&&p.logger.log(e.pts+"/"+e.dts+":"+e.debug)}},{key:"_parseAVCPES",value:function(e,t){var r,a,i,n=this,o=this._avcTrack,s=this._parseAVCNALu(e.data),l=this.avcSample;e.data=null,s.forEach(function(t){switch(t.type){case 1:a=!0,l.frame=!0;var s=t.data;if(s.length>4){var u=new h.default(s).readSliceType();2!==u&&4!==u&&7!==u&&9!==u||(l.key=!0)}break;case 5:a=!0,l||(l=n.avcSample=n._createAVCSample(!0,e.pts,e.dts,"")),l.key=!0,l.frame=!0;break;case 6:a=!0,r=new h.default(n.discardEPB(t.data)),r.readUByte();for(var d=0,f=0,c=!1,v=0;!c&&r.bytesAvailable>1;){d=0;do{v=r.readUByte(),d+=v}while(255===v);f=0;do{v=r.readUByte(),f+=v}while(255===v);if(4===d&&0!==r.bytesAvailable){c=!0;if(181===r.readUByte()){if(49===r.readUShort()){if(1195456820===r.readUInt()){if(3===r.readUByte()){var g=r.readUByte(),p=r.readUByte(),y=31&g,m=[g,p];for(i=0;i<y;i++)m.push(r.readUByte()),m.push(r.readUByte()),m.push(r.readUByte());n._insertSampleInOrder(n._txtTrack.samples,{type:3,pts:e.pts,bytes:m})}}}}}else if(f<r.bytesAvailable)for(i=0;i<f;i++)r.readUByte()}break;case 7:if(a=!0,!o.sps){r=new h.default(t.data);var b=r.readSPS();o.width=b.width,o.height=b.height,o.pixelRatio=b.pixelRatio,o.sps=[t.data],o.duration=n._duration;var E=t.data.subarray(1,4),_="avc1.";for(i=0;i<3;i++){var R=E[i].toString(16);R.length<2&&(R="0"+R),_+=R}o.codec=_}break;case 8:a=!0,o.pps||(o.pps=[t.data]);break;case 9:a=!1,l&&n.pushAccesUnit(l,o),l=n.avcSample=n._createAVCSample(!1,e.pts,e.dts,"");break;case 12:a=!1;break;default:a=!1,l&&(l.debug+="unknown NAL "+t.type+" ")}if(l&&a){l.units.push(t)}}),t&&l&&(this.pushAccesUnit(l,o),this.avcSample=null)}},{key:"_createAVCSample",value:function(e,t,r,a){return{key:e,pts:t,dts:r,units:[],debug:a}}},{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 a=r-1;a>=0;a--)if(t.pts<e[a].pts){e.splice(a,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,a=r.samples;e=a[a.length-1]}if(e){var i=e.units;t=i[i.length-1]}return t}},{key:"_parseAVCNALu",value:function(e){var t,r,a,i,n,o=0,s=e.byteLength,l=this._avcTrack,u=l.naluState||0,d=u,f=[],c=-1;for(u===-1&&(c=0,n=31&e[0],u=0,o=1);o<s;)if(t=e[o++],u)if(1!==u)if(t)if(1===t){if(c>=0)a={data:e.subarray(c,o-u-1),type:n},f.push(a);else{var h=this._getLastNalUnit();if(h&&(d&&o<=4-d&&h.state&&(h.data=h.data.subarray(0,h.data.byteLength-d)),(r=o-u-1)>0)){var v=new Uint8Array(h.data.byteLength+r);v.set(h.data,0),v.set(e.subarray(0,r),h.data.byteLength),h.data=v}}o<s?(i=31&e[o],c=o,n=i,u=0):u=-1}else u=0;else u=3;else u=t?0:2;else u=t?0:1;if(c>=0&&u>=0&&(a={data:e.subarray(c,s),type:n,state:u},f.push(a)),0===f.length){var g=this._getLastNalUnit();if(g){var p=new Uint8Array(g.data.byteLength+e.byteLength);p.set(g.data,0),p.set(e,g.data.byteLength),g.data=p}}return l.naluState=u,f}},{key:"discardEPB",value:function(e){for(var t,r,a=e.byteLength,i=[],n=1;n<a-2;)0===e[n]&&0===e[n+1]&&3===e[n+2]?(i.push(n+2),n+=2):n++;if(0===i.length)return e;t=a-i.length,r=new Uint8Array(t);var o=0;for(n=0;n<t;o++,n++)o===i[0]&&(o++,i.shift()),r[n]=e[o];return r}},{key:"_parseAACPES",value:function(e){var t,r,a,i,n,o=this._audioTrack,l=e.data,u=e.pts,d=this.aacOverFlow,c=this.aacLastPTS;if(d){var h=new Uint8Array(d.byteLength+l.byteLength);h.set(d,0),h.set(l,d.byteLength),l=h}for(a=0,n=l.length;a<n-1&&!s.default.isHeader(l,a);a++);if(a){var v,g;if(a<n-1?(v="AAC PES did not start with ADTS header,offset:"+a,g=!1):(v="no ADTS header found in AAC PES",g=!0),p.logger.warn("parsing error:"+v),this.observer.trigger(f.default.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.ErrorDetails.FRAG_PARSING_ERROR,fatal:g,reason:v}),g)return}if(s.default.initTrackConfig(o,this.observer,l,a,this.audioCodec),r=0,t=s.default.getFrameDuration(o.samplerate),d&&c){var m=c+t;Math.abs(m-u)>1&&(p.logger.log("AAC: align PTS for overlapping frames by "+Math.round((m-u)/90)),u=m)}for(;a<n;)if(s.default.isHeader(l,a)&&a+5<n){var b=s.default.appendFrame(o,l,a,u,r);if(!b)break;a+=b.length,i=b.sample.pts,r++}else a++;d=a<n?l.subarray(a,n):null,this.aacOverFlow=d,this.aacLastPTS=i}},{key:"_parseMPEGPES",value:function(e){for(var t=e.data,r=t.length,a=0,i=0,n=e.pts;i<r;)if(u.default.isHeader(t,i)){var o=u.default.appendFrame(this._audioTrack,t,i,n,a);if(!o)break;i+=o.length,a++}else i++}},{key:"_parseID3PES",value:function(e){this._id3Track.samples.push(e)}}],[{key:"probe",value:function(e){return e.length>=564&&71===e[0]&&71===e[188]&&71===e[376]}}]),e}();r.default=m},{17:17,21:21,25:25,26:26,28:28,30:30,46:46}],28:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});r.ErrorTypes={NETWORK_ERROR:"networkError",MEDIA_ERROR:"mediaError",MUX_ERROR:"muxError",OTHER_ERROR:"otherError"},r.ErrorDetails={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_LOOP_LOADING_ERROR:"fragLoopLoadingError",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",WEBVTT_EXCEPTION:"webVTTException"}},{}],29:[function(e,t,r){"use strict";function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__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},n=function(){function e(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),o=e(46),s=e(28),l=e(30),u=function(e){return e&&e.__esModule?e:{default:e}}(l),d=function(){function e(t){a(this,e),this.hls=t,this.onEvent=this.onEvent.bind(this);for(var r=arguments.length,i=Array(r>1?r-1:0),n=1;n<r;n++)i[n-1]=arguments[n];this.handledEvents=i,this.useGenericHandler=!0,this.registerListeners()}return n(e,[{key:"destroy",value:function(){this.unregisterListeners()}},{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("hlsEventGeneric"===e)throw new Error("Forbidden event name: "+e);this.hls.on(e,this.onEvent)}.bind(this))}},{key:"unregisterListeners",value:function(){this.isEventHandler()&&this.handledEvents.forEach(function(e){this.hls.off(e,this.onEvent)}.bind(this))}},{key:"onEvent",value:function(e,t){this.onEventGeneric(e,t)}},{key:"onEventGeneric",value:function(e,t){var r=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)};try{r.call(this,e,t).call()}catch(t){o.logger.error("internal error happened while processing "+e+":"+t.message),this.hls.trigger(u.default.ERROR,{type:s.ErrorTypes.OTHER_ERROR,details:s.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:e,err:t})}}}]),e}();r.default=d},{28:28,30:30,46:46}],30:[function(e,t,r){"use strict";t.exports={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_SWITCH:"hlsLevelSwitch",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_SWITCH:"hlsAudioTrackSwitch",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"}},{}],31:[function(e,t,r){"use strict";function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__esModule",{value:!0});var i=function(){function e(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),n=function(){function e(){a(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}();r.default=n},{}],32:[function(e,t,r){"use strict";var a={isBuffered:function(e,t){if(e)for(var r=e.buffered,a=0;a<r.length;a++)if(t>=r.start(a)&&t<=r.end(a))return!0;return!1},bufferInfo:function(e,t,r){if(e){var a,i=e.buffered,n=[];for(a=0;a<i.length;a++)n.push({start:i.start(a),end:i.end(a)});return this.bufferedInfo(n,t,r)}return{len:0,start:t,end:t,nextStart:void 0}},bufferedInfo:function(e,t,r){var a,i,n,o,s,l=[];for(e.sort(function(e,t){var r=e.start-t.start;return r?r:t.end-e.end}),s=0;s<e.length;s++){var u=l.length;if(u){var d=l[u-1].end;e[s].start-d<r?e[s].end>d&&(l[u-1].end=e[s].end):l.push(e[s])}else l.push(e[s])}for(s=0,a=0,i=n=t;s<l.length;s++){var f=l[s].start,c=l[s].end;if(t+r>=f&&t<c)i=f,n=c,a=n-t;else if(t+r<f){o=f;break}}return{len:a,start:i,end:n,nextStart:o}}};t.exports=a},{}],33:[function(e,t,r){"use strict";var a=e(46),i={mergeDetails:function(e,t){var r,n=Math.max(e.startSN,t.startSN)-t.startSN,o=Math.min(e.endSN,t.endSN)-t.startSN,s=t.startSN-e.startSN,l=e.fragments,u=t.fragments,d=0;if(o<n)return void(t.PTSKnown=!1);for(var f=n;f<=o;f++){var c=l[s+f],h=u[f];h&&c&&(d=c.cc-h.cc,isNaN(c.startPTS)||(h.start=h.startPTS=c.startPTS,h.endPTS=c.endPTS,h.duration=c.duration,h.backtracked=c.backtracked,h.dropped=c.dropped,r=h))}if(d)for(a.logger.log("discontinuity sliding from playlist, take drift into account"),f=0;f<u.length;f++)u[f].cc+=d;if(r)i.updateFragPTSDTS(t,r,r.startPTS,r.endPTS,r.startDTS,r.endDTS);else if(s>=0&&s<l.length){var v=l[s].start;for(f=0;f<u.length;f++)u[f].start+=v}t.PTSKnown=e.PTSKnown},updateFragPTSDTS:function(e,t,r,a,n,o){if(!isNaN(t.startPTS)){var s=Math.abs(t.startPTS-r);isNaN(t.deltaPTS)?t.deltaPTS=s:t.deltaPTS=Math.max(s,t.deltaPTS),r=Math.min(r,t.startPTS),a=Math.max(a,t.endPTS),n=Math.min(n,t.startDTS),o=Math.max(o,t.endDTS)}var l=r-t.start;t.start=t.startPTS=r,t.endPTS=a,t.startDTS=n,t.endDTS=o,t.duration=a-r;var u=t.sn;if(!e||u<e.startSN||u>e.endSN)return 0;var d,f,c;for(d=u-e.startSN,f=e.fragments,t=f[d],c=d;c>0;c--)i.updatePTS(f,c,c-1);for(c=d;c<f.length-1;c++)i.updatePTS(f,c,c+1);return e.PTSKnown=!0,l},updatePTS:function(e,t,r){var i=e[t],n=e[r],o=n.startPTS;isNaN(o)?n.start=r>t?i.start+i.duration:Math.max(i.start-n.duration,0):r>t?(i.duration=o-i.start,i.duration<0&&a.logger.warn("negative duration computed for frag "+i.sn+",level "+i.level+", there should be some duration drift between playlist and fragment!")):(n.duration=i.start-o,n.duration<0&&a.logger.warn("negative duration computed for frag "+n.sn+",level "+n.level+", there should be some duration drift between playlist and fragment!"))}};t.exports=i},{46:46}],34:[function(e,t,r){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__esModule",{value:!0});var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),o=e(2),s=a(o),l=e(30),u=a(l),d=e(28),f=e(38),c=a(f),h=e(36),v=a(h),g=e(37),p=a(g),y=e(11),m=a(y),b=e(10),E=a(b),_=e(9),R=a(_),T=e(46),A=e(1),S=a(A),k=e(4),L=function(){function e(){var t=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};i(this,e);var a=e.DefaultConfig;if((r.liveSyncDurationCount||r.liveMaxLatencyDurationCount)&&(r.liveSyncDuration||r.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");for(var n in a)n in r||(r[n]=a[n]);if(void 0!==r.liveMaxLatencyDurationCount&&r.liveMaxLatencyDurationCount<=r.liveSyncDurationCount)throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be gt "liveSyncDurationCount"');if(void 0!==r.liveMaxLatencyDuration&&(r.liveMaxLatencyDuration<=r.liveSyncDuration||void 0===r.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be gt "liveSyncDuration"');(0,T.enableLogs)(r.debug),this.config=r,this._autoLevelCapping=-1;var o=this.observer=new S.default;o.trigger=function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),a=1;a<t;a++)r[a-1]=arguments[a];o.emit.apply(o,[e,e].concat(r))},o.off=function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),a=1;a<t;a++)r[a-1]=arguments[a];o.removeListener.apply(o,[e].concat(r))},this.on=o.on.bind(o),this.off=o.off.bind(o),this.trigger=o.trigger.bind(o);var s=this.abrController=new r.abrController(this),l=new r.bufferController(this),u=new r.capLevelController(this),d=new r.fpsController(this),f=new c.default(this),h=new v.default(this),g=new p.default(this),y=new R.default(this),b=this.levelController=new E.default(this),_=this.streamController=new m.default(this),A=[b,_],k=r.audioStreamController;k&&A.push(new k(this)),this.networkControllers=A;var L=[f,h,g,s,l,u,d,y];if(k=r.audioTrackController){var w=new k(this);this.audioTrackController=w,L.push(w)}if(k=r.subtitleTrackController){var D=new k(this);this.subtitleTrackController=D,L.push(D)}[r.subtitleStreamController,r.timelineController].forEach(function(e){e&&L.push(new e(t))}),this.coreComponents=L}return n(e,null,[{key:"isSupported",value:function(){var e=window.MediaSource=window.MediaSource||window.WebKitMediaSource,t=window.SourceBuffer=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}},{key:"version",get:function(){return"0.7.9"}},{key:"Events",get:function(){return u.default}},{key:"ErrorTypes",get:function(){return d.ErrorTypes}},{key:"ErrorDetails",get:function(){return d.ErrorDetails}},{key:"DefaultConfig",get:function(){return e.defaultConfig?e.defaultConfig:k.hlsDefaultConfig},set:function(t){e.defaultConfig=t}}]),n(e,[{key:"destroy",value:function(){T.logger.log("destroy"),this.trigger(u.default.DESTROYING),this.detachMedia(),this.coreComponents.concat(this.networkControllers).forEach(function(e){e.destroy()}),this.url=null,this.observer.removeAllListeners(),this._autoLevelCapping=-1}},{key:"attachMedia",value:function(e){T.logger.log("attachMedia"),this.media=e,this.trigger(u.default.MEDIA_ATTACHING,{media:e})}},{key:"detachMedia",value:function(){T.logger.log("detachMedia"),this.trigger(u.default.MEDIA_DETACHING),this.media=null}},{key:"loadSource",value:function(e){e=s.default.buildAbsoluteURL(window.location.href,e,{alwaysNormalize:!0}),T.logger.log("loadSource:"+e),this.url=e,this.trigger(u.default.MANIFEST_LOADING,{url:e})}},{key:"startLoad",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1;T.logger.log("startLoad("+e+")"),this.networkControllers.forEach(function(t){t.startLoad(e)})}},{key:"stopLoad",value:function(){T.logger.log("stopLoad"),this.networkControllers.forEach(function(e){e.stopLoad()})}},{key:"swapAudioCodec",value:function(){T.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()}},{key:"recoverMediaError",value:function(){T.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){T.logger.log("set currentLevel:"+e),this.loadLevel=e,this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(e){T.logger.log("set nextLevel:"+e),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(e){T.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){T.logger.log("set firstLevel:"+e),this.levelController.firstLevel=e}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(e){T.logger.log("set startLevel:"+e);var t=this;e!==-1&&(e=Math.max(e,t.minAutoLevel)),t.levelController.startLevel=e}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(e){T.logger.log("set autoLevelCapping:"+e),this._autoLevelCapping=e}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){for(var e=this,t=e.levels,r=e.config.minAutoBitrate,a=t?t.length:0,i=0;i<a;i++){if((t[i].realBitrate?Math.max(t[i].realBitrate,t[i].bitrate):t[i].bitrate)>r)return i}return 0}},{key:"maxAutoLevel",get:function(){var e=this,t=e.levels,r=e.autoLevelCapping;return r===-1&&t&&t.length?t.length-1:r}},{key:"nextAutoLevel",get:function(){var e=this;return Math.min(Math.max(e.abrController.nextAutoLevel,e.minAutoLevel),e.maxAutoLevel)},set:function(e){var t=this;t.abrController.nextAutoLevel=Math.max(t.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)}}]),e}();r.default=L},{1:1,10:10,11:11,2:2,28:28,30:30,36:36,37:37,38:38,4:4,46:46,9:9}],35:[function(e,t,r){"use strict";t.exports=e(34).default},{34:34}],36:[function(e,t,r){"use strict";function a(e){
return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(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}function o(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)}Object.defineProperty(r,"__esModule",{value:!0});var s=function(){function e(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),l=e(30),u=a(l),d=e(29),f=a(d),c=e(28),h=e(46),v=function(e){function t(e){i(this,t);var r=n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,u.default.FRAG_LOADING));return r.loaders={},r}return o(t,e),s(t,[{key:"destroy",value:function(){var e=this.loaders;for(var t in e){var r=e[t];r&&r.destroy()}this.loaders={},f.default.prototype.destroy.call(this)}},{key:"onFragLoading",value:function(e){var t=e.frag,r=t.type,a=this.loaders[r],i=this.hls.config;t.loaded=0,a&&(h.logger.warn("abort previous fragment loader for type:"+r),a.abort()),a=this.loaders[r]=t.loader=void 0!==i.fLoader?new i.fLoader(i):new i.loader(i);var n=void 0,o=void 0,s=void 0;n={url:t.url,frag:t,responseType:"arraybuffer",progressData:!1};var l=t.byteRangeStartOffset,u=t.byteRangeEndOffset;isNaN(l)||isNaN(u)||(n.rangeStart=l,n.rangeEnd=u),o={timeout:i.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:i.fragLoadingMaxRetryTimeout},s={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this),onProgress:this.loadprogress.bind(this)},a.load(n,o,s)}},{key:"loadsuccess",value:function(e,t,r){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=e.data,n=r.frag;n.loader=void 0,this.loaders[n.type]=void 0,this.hls.trigger(u.default.FRAG_LOADED,{payload:i,frag:n,stats:t,networkDetails:a})}},{key:"loaderror",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=t.loader;a&&a.abort(),this.loaders[t.type]=void 0,this.hls.trigger(u.default.ERROR,{type:c.ErrorTypes.NETWORK_ERROR,details:c.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,a=t.loader;a&&a.abort(),this.loaders[t.type]=void 0,this.hls.trigger(u.default.ERROR,{type:c.ErrorTypes.NETWORK_ERROR,details:c.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t.frag,networkDetails:r})}},{key:"loadprogress",value:function(e,t,r){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=t.frag;i.loaded=e.loaded,this.hls.trigger(u.default.FRAG_LOAD_PROGRESS,{frag:i,stats:e,networkDetails:a})}}]),t}(f.default);r.default=v},{28:28,29:29,30:30,46:46}],37:[function(e,t,r){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(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}function o(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)}Object.defineProperty(r,"__esModule",{value:!0});var s=function(){function e(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),l=e(30),u=a(l),d=e(29),f=a(d),c=e(28),h=e(46),v=function(e){function t(e){i(this,t);var r=n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,u.default.KEY_LOADING));return r.loaders={},r.decryptkey=null,r.decrypturl=null,r}return o(t,e),s(t,[{key:"destroy",value:function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy()}this.loaders={},f.default.prototype.destroy.call(this)}},{key:"onKeyLoading",value:function(e){var t=e.frag,r=t.type,a=this.loaders[r],i=t.decryptdata,n=i.uri;if(n!==this.decrypturl||null===this.decryptkey){var o=this.hls.config;a&&(h.logger.warn("abort previous key loader for type:"+r),a.abort()),t.loader=this.loaders[r]=new o.loader(o),this.decrypturl=n,this.decryptkey=null;var s=void 0,l=void 0,d=void 0;s={url:n,frag:t,responseType:"arraybuffer"},l={timeout:o.fragLoadingTimeOut,maxRetry:o.fragLoadingMaxRetry,retryDelay:o.fragLoadingRetryDelay,maxRetryDelay:o.fragLoadingMaxRetryTimeout},d={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)},t.loader.load(s,l,d)}else this.decryptkey&&(i.key=this.decryptkey,this.hls.trigger(u.default.KEY_LOADED,{frag:t}))}},{key:"loadsuccess",value:function(e,t,r){var a=r.frag;this.decryptkey=a.decryptdata.key=new Uint8Array(e.data),a.loader=void 0,this.loaders[a.type]=void 0,this.hls.trigger(u.default.KEY_LOADED,{frag:a})}},{key:"loaderror",value:function(e,t){var r=t.frag,a=r.loader;a&&a.abort(),this.loaders[t.type]=void 0,this.hls.trigger(u.default.ERROR,{type:c.ErrorTypes.NETWORK_ERROR,details:c.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:r,response:e})}},{key:"loadtimeout",value:function(e,t){var r=t.frag,a=r.loader;a&&a.abort(),this.loaders[t.type]=void 0,this.hls.trigger(u.default.ERROR,{type:c.ErrorTypes.NETWORK_ERROR,details:c.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:r})}}]),t}(f.default);r.default=v},{28:28,29:29,30:30,46:46}],38:[function(e,t,r){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function i(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}function n(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)}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__esModule",{value:!0});var s=function(){function e(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),l=e(2),u=a(l),d=e(30),f=a(d),c=e(29),h=a(c),v=e(28),g=e(42),p=a(g),y=e(46),m=/#EXT-X-STREAM-INF:([^\n\r]*)[\r\n]+([^\r\n]+)/g,b=/#EXT-X-MEDIA:(.*)/g,E=new RegExp([/#EXTINF:(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/|(?!#)(\S+)/.source,/|#EXT-X-BYTERANGE:*(.+)/.source,/|#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/|#.*/.source].join(""),"g"),_=function(){function e(){o(this,e),this.method=null,this.key=null,this.iv=null,this._uri=null}return s(e,[{key:"uri",get:function(){return!this._uri&&this.reluri&&(this._uri=u.default.buildAbsoluteURL(this.baseuri,this.reluri,{alwaysNormalize:!0})),this._uri}}]),e}(),R=function(){function e(){o(this,e),this._url=null,this._byteRange=null,this._decryptdata=null,this.tagList=[]}return s(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 _,r.method=e.method,r.baseuri=e.baseuri,r.reluri=e.reluri,r.iv=this.createInitializationVector(t)),r}},{key:"cloneObj",value:function(e){return JSON.parse(JSON.stringify(e))}},{key:"url",get:function(){return!this._url&&this.relurl&&(this._url=u.default.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url},set:function(e){this._url=e}},{key:"programDateTime",get:function(){return!this._programDateTime&&this.rawProgramDateTime&&(this._programDateTime=new Date(Date.parse(this.rawProgramDateTime))),this._programDateTime}},{key:"byteRange",get:function(){if(!this._byteRange){var e=this._byteRange=[];if(this.rawByteRange){var t=this.rawByteRange.split("@",2);if(1===t.length){var r=this.lastByteRangeEndOffset;e[0]=r?r:0}else e[0]=parseInt(t[1]);e[1]=parseInt(t[0])+e[0]}}return this._byteRange}},{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}}]),e}(),T=function(e){function t(e){o(this,t);var r=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,f.default.MANIFEST_LOADING,f.default.LEVEL_LOADING,f.default.AUDIO_TRACK_LOADING,f.default.SUBTITLE_TRACK_LOADING));return r.loaders={},r}return n(t,e),s(t,[{key:"destroy",value:function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy()}this.loaders={},h.default.prototype.destroy.call(this)}},{key:"onManifestLoading",value:function(e){this.load(e.url,{type:"manifest"})}},{key:"onLevelLoading",value:function(e){this.load(e.url,{type:"level",level:e.level,id:e.id})}},{key:"onAudioTrackLoading",value:function(e){this.load(e.url,{type:"audioTrack",id:e.id})}},{key:"onSubtitleTrackLoading",value:function(e){this.load(e.url,{type:"subtitleTrack",id:e.id})}},{key:"load",value:function(e,t){var r=this.loaders[t.type];if(r){var a=r.context;if(a&&a.url===e)return void y.logger.trace("playlist request ongoing");y.logger.warn("abort previous loader for type:"+t.type),r.abort()}var i=this.hls.config,n=void 0,o=void 0,s=void 0,l=void 0;"manifest"===t.type?(n=i.manifestLoadingMaxRetry,o=i.manifestLoadingTimeOut,s=i.manifestLoadingRetryDelay,l=i.manifestLoadingMaxRetryTimeout):(n=i.levelLoadingMaxRetry,o=i.levelLoadingTimeOut,s=i.levelLoadingRetryDelay,l=i.levelLoadingMaxRetryTimeout,y.logger.log("loading playlist for "+t.type+" "+(t.level||t.id))),r=this.loaders[t.type]=t.loader=void 0!==i.pLoader?new i.pLoader(i):new i.loader(i),t.url=e,t.responseType="";var u=void 0,d=void 0;u={timeout:o,maxRetry:n,retryDelay:s,maxRetryDelay:l},d={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)},r.load(t,u,d)}},{key:"resolve",value:function(e,t){return u.default.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}},{key:"parseMasterPlaylist",value:function(e,t){var r=[],a=void 0;for(m.lastIndex=0;null!=(a=m.exec(e));){var i={},n=i.attrs=new p.default(a[1]);i.url=this.resolve(a[2],t);var o=n.decimalResolution("RESOLUTION");o&&(i.width=o.width,i.height=o.height),i.bitrate=n.decimalInteger("AVERAGE-BANDWIDTH")||n.decimalInteger("BANDWIDTH"),i.name=n.NAME;var s=n.CODECS;if(s){s=s.split(/[ ,]+/);for(var l=0;l<s.length;l++){var u=s[l];u.indexOf("avc1")!==-1?i.videoCodec=this.avc1toavcoti(u):u.indexOf("hvc1")!==-1?i.videoCodec=u:i.audioCodec=u}}r.push(i)}return r}},{key:"parseMasterPlaylistMedia",value:function(e,t,r){var a=void 0,i=[],n=0;for(b.lastIndex=0;null!=(a=b.exec(e));){var o={},s=new p.default(a[1]);s.TYPE===r&&(o.groupId=s["GROUP-ID"],o.name=s.NAME,o.type=r,o.default="YES"===s.DEFAULT,o.autoselect="YES"===s.AUTOSELECT,o.forced="YES"===s.FORCED,s.URI&&(o.url=this.resolve(s.URI,t)),o.lang=s.LANGUAGE,o.name||(o.name=o.lang),o.id=n++,i.push(o))}return i}},{key:"avc1toavcoti",value:function(e){var t,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:"parseLevelPlaylist",value:function(e,t,r,a){var i,n,o=0,s=0,l={type:null,version:null,url:t,fragments:[],live:!0,startSN:0},u=new _,d=0,f=null,c=new R;for(E.lastIndex=0;null!==(i=E.exec(e));){var h=i[1];if(h){c.duration=parseFloat(h);var v=(" "+i[2]).slice(1);c.title=v?v:null,c.tagList.push(v?["INF",h,v]:["INF",h])}else if(i[3]){if(!isNaN(c.duration)){var g=o++;c.type=a,c.start=s,c.levelkey=u,c.sn=g,c.level=r,c.cc=d,c.baseurl=t,c.relurl=(" "+i[3]).slice(1),l.fragments.push(c),f=c,s+=c.duration,c=new R}}else if(i[4]){if(c.rawByteRange=(" "+i[4]).slice(1),f){var m=f.byteRangeEndOffset;m&&(c.lastByteRangeEndOffset=m)}}else if(i[5])c.rawProgramDateTime=(" "+i[5]).slice(1),c.tagList.push(["PROGRAM-DATE-TIME",c.rawProgramDateTime]);else{for(i=i[0].match(/(?:(?:#(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?/),n=1;n<i.length&&void 0===i[n];n++);var b=(" "+i[n+1]).slice(1),T=(" "+i[n+2]).slice(1);switch(i[n]){case"#":c.tagList.push(T?[b,T]:[b]);break;case"PLAYLIST-TYPE":l.type=b.toUpperCase();break;case"MEDIA-SEQUENCE":o=l.startSN=parseInt(b);break;case"TARGETDURATION":l.targetduration=parseFloat(b);break;case"VERSION":l.version=parseInt(b);break;case"EXTM3U":break;case"ENDLIST":l.live=!1;break;case"DIS":d++,c.tagList.push(["DIS"]);break;case"DISCONTINUITY-SEQ":d=parseInt(b);break;case"KEY":var A=b,S=new p.default(A),k=S.enumeratedString("METHOD"),L=S.URI,w=S.hexadecimalInteger("IV");k&&(u=new _,L&&["AES-128","SAMPLE-AES"].indexOf(k)>=0&&(u.method=k,u.baseuri=t,u.reluri=L,u.key=null,u.iv=w));break;case"START":var D=b,O=new p.default(D),P=O.decimalFloatingPoint("TIME-OFFSET");isNaN(P)||(l.startTimeOffset=P);break;case"MAP":var x=new p.default(b);c.relurl=x.URI,c.rawByteRange=x.BYTERANGE,c.baseurl=t,c.level=r,c.type=a,c.sn="initSegment",l.initSegment=c,c=new R;break;default:y.logger.warn("line parsed but not handled: "+i)}}}return c=f,c&&!c.relurl&&(l.fragments.pop(),s-=c.duration),l.totalduration=s,l.averagetargetduration=s/l.fragments.length,l.endSN=o-1,l}},{key:"loadsuccess",value:function(e,t,r){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=e.data,n=e.url,o=r.type,s=r.id,l=r.level,u=this.hls;if(this.loaders[o]=void 0,void 0!==n&&0!==n.indexOf("data:")||(n=r.url),t.tload=performance.now(),0===i.indexOf("#EXTM3U"))if(i.indexOf("#EXTINF:")>0){var d="audioTrack"!==o&&"subtitleTrack"!==o,c=isNaN(l)?isNaN(s)?0:s:l,h=this.parseLevelPlaylist(i,n,c,"audioTrack"===o?"audio":"subtitleTrack"===o?"subtitle":"main");h.tload=t.tload,"manifest"===o&&u.trigger(f.default.MANIFEST_LOADED,{levels:[{url:n,details:h}],audioTracks:[],url:n,stats:t,networkDetails:a}),t.tparsed=performance.now(),h.targetduration?d?u.trigger(f.default.LEVEL_LOADED,{details:h,level:l||0,id:s||0,stats:t,networkDetails:a}):"audioTrack"===o?u.trigger(f.default.AUDIO_TRACK_LOADED,{details:h,id:s,stats:t,networkDetails:a}):"subtitleTrack"===o&&u.trigger(f.default.SUBTITLE_TRACK_LOADED,{details:h,id:s,stats:t,networkDetails:a}):u.trigger(f.default.ERROR,{type:v.ErrorTypes.NETWORK_ERROR,details:v.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:!0,url:n,reason:"invalid targetduration",networkDetails:a})}else{var g=this.parseMasterPlaylist(i,n);if(g.length){var p=this.parseMasterPlaylistMedia(i,n,"AUDIO"),m=this.parseMasterPlaylistMedia(i,n,"SUBTITLES");if(p.length){var b=!1;p.forEach(function(e){e.url||(b=!0)}),b===!1&&g[0].audioCodec&&!g[0].attrs.AUDIO&&(y.logger.log("audio codec signaled in quality level, but no embedded audio track signaled, create one"),p.unshift({type:"main",name:"main"}))}u.trigger(f.default.MANIFEST_LOADED,{levels:g,audioTracks:p,subtitles:m,url:n,stats:t,networkDetails:a})}else u.trigger(f.default.ERROR,{type:v.ErrorTypes.NETWORK_ERROR,details:v.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:!0,url:n,reason:"no level found in manifest",networkDetails:a})}else u.trigger(f.default.ERROR,{type:v.ErrorTypes.NETWORK_ERROR,details:v.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:!0,url:n,reason:"no EXTM3U delimiter",networkDetails:a})}},{key:"loaderror",value:function(e,t){var r,a,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=t.loader;switch(t.type){case"manifest":r=v.ErrorDetails.MANIFEST_LOAD_ERROR,a=!0;break;case"level":r=v.ErrorDetails.LEVEL_LOAD_ERROR,a=!1;break;case"audioTrack":r=v.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,a=!1}n&&(n.abort(),this.loaders[t.type]=void 0),this.hls.trigger(f.default.ERROR,{type:v.ErrorTypes.NETWORK_ERROR,details:r,fatal:a,url:n.url,loader:n,response:e,context:t,networkDetails:i})}},{key:"loadtimeout",value:function(e,t){var r,a,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=t.loader;switch(t.type){case"manifest":r=v.ErrorDetails.MANIFEST_LOAD_TIMEOUT,a=!0;break;case"level":r=v.ErrorDetails.LEVEL_LOAD_TIMEOUT,a=!1;break;case"audioTrack":r=v.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT,a=!1}n&&(n.abort(),this.loaders[t.type]=void 0),this.hls.trigger(f.default.ERROR,{type:v.ErrorTypes.NETWORK_ERROR,details:r,fatal:a,url:n.url,loader:n,context:t,networkDetails:i})}}]),t}(h.default);r.default=T},{2:2,28:28,29:29,30:30,42:42,46:46}],39:[function(e,t,r){"use strict";function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__esModule",{value:!0});var i=function(){function e(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),n=Math.pow(2,32)-1,o=function(){function e(){a(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;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]),a=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:a};var i=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,i))}},{key:"box",value:function(e){for(var t,r=Array.prototype.slice.call(arguments,1),a=8,i=r.length,n=i;i--;)a+=r[i].byteLength;for(t=new Uint8Array(a),t[0]=a>>24&255,t[1]=a>>16&255,t[2]=a>>8&255,t[3]=255&a,t.set(e,4),i=0,a=8;i<n;i++)t.set(r[i],a),a+=r[i].byteLength;return t}},{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 a=Math.floor(r/(n+1)),i=Math.floor(r%(n+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,a>>24,a>>16&255,a>>8&255,255&a,i>>24,i>>16&255,i>>8&255,255&i,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,a){return e.box(e.types.moof,e.mfhd(t),e.traf(a,r))}},{key:"moov",value:function(t){for(var r=t.length,a=[];r--;)a[r]=e.trak(t[r]);return e.box.apply(null,[e.types.moov,e.mvhd(t[0].timescale,t[0].duration)].concat(a).concat(e.mvex(t)))}},{key:"mvex",value:function(t){for(var r=t.length,a=[];r--;)a[r]=e.trex(t[r]);return e.box.apply(null,[e.types.mvex].concat(a))}},{key:"mvhd",value:function(t,r){r*=t;var a=Math.floor(r/(n+1)),i=Math.floor(r%(n+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,a>>24,a>>16&255,a>>8&255,255&a,i>>24,i>>16&255,i>>8&255,255&i,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return e.box(e.types.mvhd,o)}},{key:"sdtp",value:function(t){var r,a,i=t.samples||[],n=new Uint8Array(4+i.length);for(a=0;a<i.length;a++)r=i[a].flags,n[a+4]=r.dependsOn<<4|r.isDependedOn<<2|r.hasRedundancy;return e.box(e.types.sdtp,n)}},{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,a,i,n=[],o=[];for(r=0;r<t.sps.length;r++)a=t.sps[r],i=a.byteLength,n.push(i>>>8&255),n.push(255&i),n=n.concat(Array.prototype.slice.call(a));for(r=0;r<t.pps.length;r++)a=t.pps[r],i=a.byteLength,o.push(i>>>8&255),o.push(255&i),o=o.concat(Array.prototype.slice.call(a));var s=e.box(e.types.avcC,new Uint8Array([1,n[3],n[4],n[5],255,224|t.sps.length].concat(n).concat([t.pps.length]).concat(o))),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,a=t.duration*t.timescale,i=t.width,o=t.height,s=Math.floor(a/(n+1)),l=Math.floor(a%(n+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,i>>8&255,255&i,0,0,o>>8&255,255&o,0,0]))}},{key:"traf",value:function(t,r){var a=e.sdtp(t),i=t.id,o=Math.floor(r/(n+1)),s=Math.floor(r%(n+1));return e.box(e.types.traf,e.box(e.types.tfhd,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i])),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,a.length+16+20+8+16+8+8),a)}},{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 a,i,n,o,s,l,u=t.samples||[],d=u.length,f=12+16*d,c=new Uint8Array(f);for(r+=8+f,c.set([0,0,15,1,d>>>24&255,d>>>16&255,d>>>8&255,255&d,r>>>24&255,r>>>16&255,r>>>8&255,255&r],0),a=0;a<d;a++)i=u[a],n=i.duration,o=i.size,s=i.flags,l=i.cts,c.set([n>>>24&255,n>>>16&255,n>>>8&255,255&n,o>>>24&255,o>>>16&255,o>>>8&255,255&o,s.isLeading<<2|s.dependsOn,s.isDependedOn<<6|s.hasRedundancy<<4|s.paddingValue<<1|s.isNonSync,61440&s.degradPrio,15&s.degradPrio,l>>>24&255,l>>>16&255,l>>>8&255,255&l],12+16*a);return e.box(e.types.trun,c)}},{key:"initSegment",value:function(t){e.types||e.init();var r,a=e.moov(t);return r=new Uint8Array(e.FTYP.byteLength+a.byteLength),r.set(e.FTYP),r.set(a,e.FTYP.byteLength),r}}]),e}();r.default=o},{}],40:[function(e,t,r){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__esModule",{value:!0});var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),o=e(31),s=a(o),l=e(30),u=a(l),d=e(46),f=e(39),c=a(f),h=e(28),v=function(){function e(t,r,a,n){i(this,e),this.observer=t,this.config=r,this.typeSupported=a;var o=navigator.userAgent;this.isSafari=n&&n.indexOf("Apple")>-1&&o&&!o.match("CriOS"),this.ISGenerated=!1}return n(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,a,i,n,o){if(this.ISGenerated||this.generateIS(e,t,i),this.ISGenerated)if(e.samples.length){e.timescale||(d.logger.warn("regenerate InitSegment as audio detected"),this.generateIS(e,t,i));var s=this.remuxAudio(e,i,n,o);if(t.samples.length){var l=void 0;s&&(l=s.endPTS-s.startPTS),t.timescale||(d.logger.warn("regenerate InitSegment as video detected"),this.generateIS(e,t,i)),this.remuxVideo(t,i,n,l,o)}}else{var f=void 0;t.samples.length&&(f=this.remuxVideo(t,i,n,o)),f&&e.codec&&this.remuxEmptyAudio(e,i,n,f)}r.samples.length&&this.remuxID3(r,i),a.samples.length&&this.remuxText(a,i),this.observer.trigger(u.default.FRAG_PARSED)}},{key:"generateIS",value:function(e,t,r){var a,i,n=this.observer,o=e.samples,s=t.samples,l=this.typeSupported,f="audio/mp4",v={},g={tracks:v},p=void 0===this._initPTS;if(p&&(a=i=1/0),e.config&&o.length&&(e.timescale=e.samplerate,d.logger.log("audio sampling rate : "+e.samplerate),e.isAAC||(l.mpeg?(f="audio/mpeg",e.codec=""):l.mp3&&(e.codec="mp3")),v.audio={container:f,codec:e.codec,initSegment:!e.isAAC&&l.mpeg?new Uint8Array:c.default.initSegment([e]),metadata:{channelCount:e.channelCount}},p&&(a=i=o[0].pts-e.inputTimeScale*r)),t.sps&&t.pps&&s.length){var y=t.inputTimeScale;t.timescale=y,v.video={container:"video/mp4",codec:t.codec,initSegment:c.default.initSegment([t]),metadata:{width:t.width,height:t.height}},p&&(a=Math.min(a,s[0].pts-y*r),i=Math.min(i,s[0].dts-y*r),this.observer.trigger(u.default.INIT_PTS_FOUND,{initPTS:a}))}Object.keys(v).length?(n.trigger(u.default.FRAG_PARSING_INIT_SEGMENT,g),this.ISGenerated=!0,p&&(this._initPTS=a,this._initDTS=i)):n.trigger(u.default.ERROR,{type:h.ErrorTypes.MEDIA_ERROR,details:h.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"no audio/video samples found"})}},{key:"remuxVideo",value:function(e,t,r,a,i){var n,o,s,l,f,v,g,p=8,y=e.timescale,m=e.samples,b=[],E=m.length,_=this._PTSNormalize,R=this._initDTS,T=this.nextAvcDts,A=this.isSafari;A&&(r|=m.length&&T&&(i&&Math.abs(t-T/y)<.1||Math.abs(m[0].pts-T-R)<y/5)),r||(T=t*y),m.forEach(function(e){e.pts=_(e.pts-R,T),e.dts=_(e.dts-R,T)}),m.sort(function(e,t){var r=e.dts-t.dts,a=e.pts-t.pts;return r?r:a?a:e.id-t.id});var S=m.reduce(function(e,t){return Math.max(Math.min(e,t.pts-t.dts),-18e3)},0);if(S<0){d.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+Math.round(S/90)+" ms to overcome this issue");for(var k=0;k<m.length;k++)m[k].dts+=S}var L=m[0];f=Math.max(L.dts,0),l=Math.max(L.pts,0);var w=Math.round((f-T)/90);r&&w&&(w>1?d.logger.log("AVC:"+w+" ms hole between fragments detected,filling it"):w<-1&&d.logger.log("AVC:"+-w+" ms overlapping between fragments detected"),f=T,m[0].dts=f,l=Math.max(l-w,T),m[0].pts=l,d.logger.log("Video/PTS/DTS adjusted: "+Math.round(l/90)+"/"+Math.round(f/90)+",delta:"+w+" ms")),L=m[m.length-1],g=Math.max(L.dts,0),v=Math.max(L.pts,0,g),A&&(n=Math.round((g-f)/(m.length-1)));for(var D=0,O=0,P=0;P<E;P++){for(var x=m[P],I=x.units,M=I.length,F=0,C=0;C<M;C++)F+=I[C].data.length;O+=F,D+=M,x.length=F,x.dts=A?f+P*n:Math.max(x.dts,f),x.pts=Math.max(x.pts,x.dts)}var N=O+4*D+8;try{o=new Uint8Array(N)}catch(e){return void this.observer.trigger(u.default.ERROR,{type:h.ErrorTypes.MUX_ERROR,details:h.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:N,reason:"fail allocating video mdat "+N})}var U=new DataView(o.buffer);U.setUint32(0,N),o.set(c.default.types.mdat,4);for(var B=0;B<E;B++){for(var G=m[B],j=G.units,H=0,V=void 0,W=0,K=j.length;W<K;W++){var z=j[W],Y=z.data,X=z.data.byteLength;U.setUint32(p,X),p+=4,o.set(Y,p),p+=X,H+=4+X}if(A)V=Math.max(0,n*Math.round((G.pts-G.dts)/n));else{if(B<E-1)n=m[B+1].dts-G.dts;else{var q=this.config,Q=G.dts-m[B>0?B-1:B].dts;if(q.stretchShortVideoTrack){var Z=q.maxBufferHole,J=q.maxSeekHole,$=Math.floor(Math.min(Z,J)*y),ee=(a?l+a*y:this.nextAudioPts)-G.pts;ee>$?(n=ee-Q,n<0&&(n=Q),d.logger.log("It is approximately "+ee/90+" ms to the next segment; using duration "+n/90+" ms for the last video frame.")):n=Q}else n=Q}V=Math.round(G.pts-G.dts)}b.push({size:H,duration:n,cts:V,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:G.key?2:1,isNonSync:G.key?0:1}})}this.nextAvcDts=g+n;var te=e.dropped;if(e.len=0,e.nbNalu=0,e.dropped=0,b.length&&navigator.userAgent.toLowerCase().indexOf("chrome")>-1){var re=b[0].flags;re.dependsOn=2,re.isNonSync=0}e.samples=b,s=c.default.moof(e.sequenceNumber++,f,e),e.samples=[];var ae={data1:s,data2:o,startPTS:l/y,endPTS:(v+n)/y,startDTS:f/y,endDTS:this.nextAvcDts/y,type:"video",nb:b.length,dropped:te};return this.observer.trigger(u.default.FRAG_PARSING_DATA,ae),ae}},{key:"remuxAudio",value:function(e,t,r,a){var i,n,o,l,f,v,g,p=e.inputTimeScale,y=e.timescale,m=p/y,b=e.isAAC?1024:1152,E=b*m,_=this._PTSNormalize,R=this._initDTS,T=!e.isAAC&&this.typeSupported.mpeg,A=e.samples,S=[],k=this.nextAudioPts;if(r|=A.length&&k&&(a&&Math.abs(t-k/p)<.1||Math.abs(A[0].pts-k-R)<20*E),r||(k=t*p),A.forEach(function(e){e.pts=e.dts=_(e.pts-R,k)}),A.sort(function(e,t){return e.pts-t.pts}),a&&e.isAAC)for(var L=0,w=k;L<A.length;){var D,O=A[L],P=O.pts;D=P-w;var x=Math.abs(1e3*D/p);if(D<=-E)d.logger.warn("Dropping 1 audio frame @ "+(w/p).toFixed(3)+"s due to "+x+" ms overlap."),A.splice(L,1),e.len-=O.unit.length;else if(D>=E&&x<1e4&&w){var I=Math.round(D/E);d.logger.warn("Injecting "+I+" audio frame @ "+(w/p).toFixed(3)+"s due to "+Math.round(1e3*D/p)+" ms gap.");for(var M=0;M<I;M++){var F=Math.max(w,0);o=s.default.getSilentFrame(e.manifestCodec||e.codec,e.channelCount),o||(d.logger.log("Unable to get silent frame for given audio codec; duplicating last frame instead."),o=O.unit.subarray()),A.splice(L,0,{unit:o,pts:F,dts:F}),e.len+=o.length,w+=E,L++}O.pts=O.dts=w,w+=E,L++}else Math.abs(D),O.pts=O.dts=w,w+=E,L++}for(var C=0,N=A.length;C<N;C++){var U=A[C],B=U.unit,G=U.pts;if(void 0!==g)n.duration=Math.round((G-g)/m);else{var j=Math.round(1e3*(G-k)/p),H=0;if(r&&e.isAAC&&j){if(j>0&&j<1e4)H=Math.round((G-k)/E),d.logger.log(j+" ms hole between AAC samples detected,filling it"),H>0&&(o=s.default.getSilentFrame(e.manifestCodec||e.codec,e.channelCount),o||(o=B.subarray()),e.len+=H*o.length);else if(j<-12){
d.logger.log("drop overlapping AAC sample, expected/parsed/delta:"+(k/p).toFixed(3)+"s/"+(G/p).toFixed(3)+"s/"+-j+"ms"),e.len-=B.byteLength;continue}G=k}if(v=Math.max(0,G),!(e.len>0))return;var V=T?e.len:e.len+8;i=T?0:8;try{l=new Uint8Array(V)}catch(e){return void this.observer.trigger(u.default.ERROR,{type:h.ErrorTypes.MUX_ERROR,details:h.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:V,reason:"fail allocating audio mdat "+V})}if(!T){new DataView(l.buffer).setUint32(0,V),l.set(c.default.types.mdat,4)}for(var W=0;W<H;W++)o=s.default.getSilentFrame(e.manifestCodec||e.codec,e.channelCount),o||(d.logger.log("Unable to get silent frame for given audio codec; duplicating this frame instead."),o=B.subarray()),l.set(o,i),i+=o.byteLength,n={size:o.byteLength,cts:0,duration:1024,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:1}},S.push(n)}l.set(B,i);var K=B.byteLength;i+=K,n={size:K,cts:0,duration:0,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:1}},S.push(n),g=G}var z=0,Y=S.length;if(Y>=2&&(z=S[Y-2].duration,n.duration=z),Y){this.nextAudioPts=k=g+m*z,e.len=0,e.samples=S,f=T?new Uint8Array:c.default.moof(e.sequenceNumber++,v/m,e),e.samples=[];var X=v/p,q=k/p,Q={data1:f,data2:l,startPTS:X,endPTS:q,startDTS:X,endDTS:q,type:"audio",nb:Y};return this.observer.trigger(u.default.FRAG_PARSING_DATA,Q),Q}return null}},{key:"remuxEmptyAudio",value:function(e,t,r,a){var i=e.inputTimeScale,n=e.samplerate?e.samplerate:i,o=i/n,l=this.nextAudioPts,u=(void 0!==l?l:a.startDTS*i)+this._initDTS,f=a.endDTS*i+this._initDTS,c=1024*o,h=Math.ceil((f-u)/c),v=s.default.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(d.logger.warn("remux empty Audio"),!v)return void d.logger.trace("Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec!");for(var g=[],p=0;p<h;p++){var y=u+p*c;g.push({unit:v,pts:y,dts:y}),e.len+=v.length}e.samples=g,this.remuxAudio(e,t,r)}},{key:"remuxID3",value:function(e,t){var r,a=e.samples.length,i=e.inputTimeScale,n=this._initPTS,o=this._initDTS;if(a){for(var s=0;s<a;s++)r=e.samples[s],r.pts=(r.pts-n)/i,r.dts=(r.dts-o)/i;this.observer.trigger(u.default.FRAG_PARSING_METADATA,{samples:e.samples})}e.samples=[],t=t}},{key:"remuxText",value:function(e,t){e.samples.sort(function(e,t){return e.pts-t.pts});var r,a=e.samples.length,i=e.inputTimeScale,n=this._initPTS;if(a){for(var o=0;o<a;o++)r=e.samples[o],r.pts=(r.pts-n)/i;this.observer.trigger(u.default.FRAG_PARSING_USERDATA,{samples:e.samples})}e.samples=[],t=t}},{key:"_PTSNormalize",value:function(e,t){var r;if(void 0===t)return e;for(r=t<e?-8589934592:8589934592;Math.abs(e-t)>4294967296;)e+=r;return e}}]),e}();r.default=v},{28:28,30:30,31:31,39:39,46:46}],41:[function(e,t,r){"use strict";function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__esModule",{value:!0});var i=function(){function e(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),n=e(30),o=function(e){return e&&e.__esModule?e:{default:e}}(n),s=function(){function e(t){a(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,a,i,n,s,l){var u=this.observer,d="";e&&(d+="audio"),t&&(d+="video"),u.trigger(o.default.FRAG_PARSING_DATA,{data1:l,startPTS:i,startDTS:i,type:d,nb:1,dropped:0}),u.trigger(o.default.FRAG_PARSED)}}]),e}();r.default=s},{30:30}],42:[function(e,t,r){"use strict";function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__esModule",{value:!0});var i=function(){function e(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),n=/^(\d+)x(\d+)$/,o=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,s=function(){function e(t){a(this,e),"string"==typeof t&&(t=e.parseAttrList(t));for(var r in 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),a=0;a<t.length/2;a++)r[a]=parseInt(t.slice(2*a,2*a+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=n.exec(this[e]);if(null!==t)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}}],[{key:"parseAttrList",value:function(e){var t,r={};for(o.lastIndex=0;null!==(t=o.exec(e));){var a=t[2];0===a.indexOf('"')&&a.lastIndexOf('"')===a.length-1&&(a=a.slice(1,-1)),r[t[1]]=a}return r}}]),e}();r.default=s},{}],43:[function(e,t,r){"use strict";var a={search:function(e,t){for(var r=0,a=e.length-1,i=null,n=null;r<=a;){i=(r+a)/2|0,n=e[i];var o=t(n);if(o>0)r=i+1;else{if(!(o<0))return n;a=i-1}}return null}};t.exports=a},{}],44:[function(e,t,r){"use strict";function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__esModule",{value:!0});var i=function(){function e(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),n=e(45),o=function(e){return e&&e.__esModule?e:{default:e}}(n),s=function(){function e(t,r,i,n){a(this,e),this.hls=t,this.defaultEstimate_=n,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new o.default(r),this.fast_=new o.default(i)}return i(e,[{key:"sample",value:function(e,t){e=Math.max(e,this.minDelayMs_);var r=8e3*t/e,a=e/1e3;this.fast_.sample(a,r),this.slow_.sample(a,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}();r.default=s},{45:45}],45:[function(e,t,r){"use strict";function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__esModule",{value:!0});var i=function(){function e(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),n=function(){function e(t){a(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}();r.default=n},{}],46:[function(e,t,r){"use strict";function a(){}function i(e,t){return t="["+e+"] > "+t}function n(e){var t=self.console[e];return t?function(){for(var r=arguments.length,a=Array(r),n=0;n<r;n++)a[n]=arguments[n];a[0]&&(a[0]=i(e,a[0])),t.apply(self.console,a)}:a}function o(e){for(var t=arguments.length,r=Array(t>1?t-1:0),a=1;a<t;a++)r[a-1]=arguments[a];r.forEach(function(t){u[t]=e[t]?e[t].bind(e):n(t)})}Object.defineProperty(r,"__esModule",{value:!0});var s="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},l={trace:a,debug:a,log:a,warn:a,info:a,error:a},u=l;r.enableLogs=function(e){if(e===!0||"object"===(void 0===e?"undefined":s(e))){o(e,"debug","log","info","warn","error");try{u.log()}catch(e){u=l}}else u=l},r.logger=u},{}],47:[function(e,t,r){"use strict";var a={toString:function(e){for(var t="",r=e.length,a=0;a<r;a++)t+="["+e.start(a).toFixed(3)+","+e.end(a).toFixed(3)+"]";return t}};t.exports=a},{}],48:[function(e,t,r){"use strict";function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__esModule",{value:!0});var i=function(){function e(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),n=e(46),o=function(){function e(t){a(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:performance.now(),retry:0},this.retryDelay=t.retryDelay,this.loadInternal()}},{key:"loadInternal",value:function(){var e,t=this.context;e="undefined"!=typeof XDomainRequest?this.loader=new XDomainRequest:this.loader=new XMLHttpRequest;var r=this.stats;r.tfirst=0,r.loaded=0;var a=this.xhrSetup;try{if(a)try{a(e,t.url)}catch(r){e.open("GET",t.url,!0),a(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,a=this.stats,i=this.context,o=this.config;if(!a.aborted&&r>=2)if(window.clearTimeout(this.requestTimeout),0===a.tfirst&&(a.tfirst=Math.max(performance.now(),a.trequest)),4===r){var s=t.status;if(s>=200&&s<300){a.tload=Math.max(a.tfirst,performance.now());var l=void 0,u=void 0;"arraybuffer"===i.responseType?(l=t.response,u=l.byteLength):(l=t.responseText,u=l.length),a.loaded=a.total=u;var d={url:t.responseURL,data:l};this.callbacks.onSuccess(d,a,i,t)}else a.retry>=o.maxRetry||s>=400&&s<499?(n.logger.error(s+" while loading "+i.url),this.callbacks.onError({code:s,text:t.statusText},i,t)):(n.logger.warn(s+" while loading "+i.url+", retrying in "+this.retryDelay+"..."),this.destroy(),this.retryTimeout=window.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,o.maxRetryDelay),a.retry++)}else this.requestTimeout=window.setTimeout(this.loadtimeout.bind(this),o.timeout)}},{key:"loadtimeout",value:function(){n.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 a=this.callbacks.onProgress;a&&a(r,this.context,null,t)}}]),e}();r.default=o},{46:46}]},{},[35])(35)});