From dd1c3b42255a0f585b10668cf867e2777c41e4fb Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 2 Sep 2017 16:37:04 -0400 Subject: [PATCH] 3.2.30.5 --- dashboard-ui/bower_components/hlsjs/dist/hls.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dashboard-ui/bower_components/hlsjs/dist/hls.min.js b/dashboard-ui/bower_components/hlsjs/dist/hls.min.js index fb3f4ab967..8ef0539fcc 100644 --- a/dashboard-ui/bower_components/hlsjs/dist/hls.min.js +++ b/dashboard-ui/bower_components/hlsjs/dist/hls.min.js @@ -1 +1 @@ -!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).Hls=e()}}(function(){return function e(t,r,a){function i(s,o){if(!r[s]){if(!t[s]){var l="function"==typeof require&&require;if(!o&&l)return l(s,!0);if(n)return n(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var d=r[s]={exports:{}};t[s][0].call(d.exports,function(e){var r=t[s][1][e];return i(r||e)},d,d.exports,e,t,r,a)}return r[s].exports}for(var n="function"==typeof require&&require,s=0;s0&&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,o;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(s(r)){for(o=n;o-- >0;)if(r[o]===t||r[o].listener&&r[o].listener===t){a=o;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(e,t,r){!function(e){var a=/^((?:[^\/;?#]+:)?)(\/\/[^\/\;?#]*)?(.*?)??(;.*?)?(\?.*?)?(#.*?)?$/,i=/^([^\/;?#]*)(.*)$/,n=/(?:\/|^)\.(?=\/)/g,s=/(?:\/|^)\.\.\/(?!\.\.\/).*?(?=\/)/g,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 n=this.parseURL(t);if(!n)throw new Error("Error trying to parse relative URL.");if(n.scheme)return r.alwaysNormalize?(n.path=o.normalizePath(n.path),o.buildURLFromParts(n)):t;var s=this.parseURL(e);if(!s)throw new Error("Error trying to parse base URL.");if(!s.netLoc&&s.path&&"/"!==s.path[0]){var l=i.exec(s.path);s.netLoc=l[1],s.path=l[2]}s.netLoc&&!s.path&&(s.path="/");var u={scheme:s.scheme,netLoc:n.netLoc,path:null,params:n.params,query:n.query,fragment:n.fragment};if(!n.netLoc&&(u.netLoc=s.netLoc,"/"!==n.path[0]))if(n.path){var d=s.path,f=d.substring(0,d.lastIndexOf("/")+1)+n.path;u.path=o.normalizePath(f)}else u.path=s.path,n.params||(u.params=s.params,n.query||(u.query=s.query));return null===u.path&&(u.path=r.alwaysNormalize?o.normalizePath(n.path):n.path),o.buildURLFromParts(u)},parseURL:function(e){var t=a.exec(e);return t?{scheme:t[1]||"",netLoc:t[2]||"",path:t[3]||"",params:t[4]||"",query:t[5]||"",fragment:t[6]||""}:null},normalizePath:function(e){for(e=e.split("").reverse().join("").replace(n,"");e.length!==(e=e.replace(s,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}};"object"==typeof r&&"object"==typeof t?t.exports=o:"object"==typeof r?r.URLToolkit=o:e.URLToolkit=o}(this)},{}],3:[function(e,t,r){var a=arguments[3],i=arguments[4],n=arguments[5],s=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 o,l=Object.keys(n),u=0,d=l.length;u500*r.duration/o){var u=e.levels,f=Math.max(1,n.bw?n.bw/8:1e3*n.loaded/s),h=u[r.level],g=h.realBitrate?Math.max(h.realBitrate,h.bitrate):h.bitrate,v=n.total?n.total:Math.max(n.loaded,Math.round(r.duration*g/8)),p=t.currentTime,y=(v-n.loaded)/f,m=(d.default.bufferInfo(t,p,e.config.maxBufferHole).end-p)/o;if(m<2*r.duration/o&&y>m){var E=void 0,b=void 0;for(b=r.level-1;b>i;b--){var T=u[b].realBitrate?Math.max(u[b].realBitrate,u[b].bitrate):u[b].bitrate;if((E=r.duration*T/(6.4*f))=a;u--){var d=l[u].details,f=d?d.totalduration/d.fragments.length:t,h=!!d&&d.live,g=void 0;g=u<=e?s*r:o*r;var v=l[u].realBitrate?Math.max(l[u].realBitrate,l[u].bitrate):l[u].bitrate,p=v*f/g;if(c.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+u+"/"+Math.round(g)+"/"+v+"/"+f+"/"+n+"/"+p),g>v&&(!p||h&&!this.bitrateTestDelay||p=0)return g;c.logger.trace("rebuffering expected to happen, lets try to find a quality level minimizing the rebuffering");var v=o?Math.min(o,a.maxStarvationDelay):a.maxStarvationDelay,p=a.abrBandWidthFactor,y=a.abrBandWidthUpFactor;if(0===h){var m=this.bitrateTestDelay;m&&(v=(o?Math.min(o,a.maxLoadingDelay):a.maxLoadingDelay)-m,c.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 g=this._findBestLevel(s,o,f,i,t,h+v,p,y,r),Math.max(g,0)}}]),t}(u.default);r.default=g},{33:33,34:34,35:35,37:37,52:52,54:54}],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 s(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 o=function(){function e(e,t){for(var r=0;r0&&-1===e?(p.logger.log("audio:override startPosition with lastCurrentTime @"+t.toFixed(3)),this.state=m.IDLE):(this.lastCurrentTime=this.startPosition?this.startPosition:e,this.state=m.STARTING),this.nextLoadPosition=this.startPosition=this.lastCurrentTime,this.tick()}else this.startPosition=e,this.state=m.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=m.STOPPED}},{key:"tick",value:function(){1===++this.ticks&&(this.doTick(),this.ticks>1&&setTimeout(this.tick,1),this.ticks=0)}},{key:"doTick",value:function(){var e,t,r,a=this.hls,i=a.config;switch(this.state){case m.ERROR:case m.PAUSED:case m.BUFFER_FLUSHING:break;case m.STARTING:this.state=m.WAITING_TRACK,this.loadedmetadata=!1;break;case m.IDLE:var n=this.tracks;if(!n)break;if(!this.media&&(this.startFragRequested||!i.startFragPrefetch))break;if(this.loadedmetadata)e=this.media.currentTime;else if(void 0===(e=this.nextLoadPosition))break;var s=this.mediaBuffer?this.mediaBuffer:this.media,o=u.default.bufferInfo(s,e,i.maxBufferHole),d=o.len,c=o.end,h=this.fragPrevious,g=i.maxMaxBufferLength,E=this.audioSwitch,b=this.trackId;if((d_||o.nextStart))return;p.logger.log("alt audio track ahead of main track, seek to start of alt audio track"),this.media.currentTime=_+.05}if(r.initSegment&&!r.initSegment.data)S=r.initSegment;else if(c<=_){if(S=T[0],null!==this.videoTrackCC&&S.cc!==this.videoTrackCC&&(S=(0,y.findFragWithCC)(T,this.videoTrackCC)),r.live&&S.loadIdx&&S.loadIdx===this.fragLoadIdx){var A=o.nextStart?o.nextStart:_;return p.logger.log("no alt audio available @currentTime:"+this.media.currentTime+", seeking @"+(A+.05)),void(this.media.currentTime=A+.05)}}else{var L=void 0,w=i.maxFragLookUpTolerance,D=h?T[h.sn-T[0].sn+1]:void 0,O=function(e){var t=Math.min(w,e.duration);return e.start+e.duration-t<=c?1:e.start-t>c&&e.start?-1:0};cR-w&&(w=0),L=D&&!O(D)?D:l.default.search(T,O)):L=T[k-1],L&&(S=L,_=L.start,h&&S.level===h.level&&S.sn===h.sn&&(S.snI&&Math.abs(this.fragLoadIdx-S.loadIdx)=C||x)&&(p.logger.log("audioStreamController: retryDate reached, switch back to IDLE state"),this.state=m.IDLE);break;case m.WAITING_INIT_PTS:var F=this.videoTrackCC;if(void 0===this.initPTS[F])break;var M=this.waitingFragment;if(M){var N=M.frag.cc;F!==N?(t=this.tracks[this.trackId]).details&&t.details.live&&(p.logger.warn("Waiting fragment CC ("+N+") does not match video track CC ("+F+")"),this.waitingFragment=null,this.state=m.IDLE):(this.state=m.FRAG_LOADING,this.onFragLoaded(this.waitingFragment),this.waitingFragment=null)}else this.state=m.IDLE;break;case m.STOPPED:case m.FRAG_LOADING:case m.PARSING:case m.PARSED:case m.ENDED:}}},{key:"onMediaAttached",value:function(e){var t=this.media=this.mediaBuffer=e.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),t.addEventListener("seeking",this.onvseeking),t.addEventListener("ended",this.onvended);var r=this.config;this.tracks&&r.autoStartLoad&&this.startLoad(r.startPosition)}},{key:"onMediaDetaching",value:function(){var e=this.media;e&&e.ended&&(p.logger.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0);var t=this.tracks;t&&t.forEach(function(e){e.details&&e.details.fragments.forEach(function(e){e.loadCounter=void 0})}),e&&(e.removeEventListener("seeking",this.onvseeking),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(){this.state===m.ENDED&&(this.state=m.IDLE),this.media&&(this.lastCurrentTime=this.media.currentTime),void 0!==this.fragLoadIdx&&(this.fragLoadIdx+=2*this.config.fragLoadingLoopThreshold),this.tick()}},{key:"onMediaEnded",value:function(){this.startPosition=this.lastCurrentTime=0}},{key:"onAudioTracksUpdated",value:function(e){p.logger.log("audio tracks updated"),this.tracks=e.audioTracks}},{key:"onAudioTrackSwitching",value:function(e){var t=!!e.url;this.trackId=e.id,this.fragCurrent=null,this.state=m.PAUSED,this.waitingFragment=null,t?this.timer||(this.timer=setInterval(this.ontick,100)):this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),t&&(this.audioSwitch=!0,this.state=m.IDLE,void 0!==this.fragLoadIdx&&(this.fragLoadIdx+=2*this.config.fragLoadingLoopThreshold)),this.tick()}},{key:"onAudioTrackLoaded",value:function(e){var t=e.details,r=e.id,a=this.tracks[r],i=t.totalduration,n=0;if(p.logger.log("track "+r+" loaded ["+t.startSN+","+t.endSN+"],duration:"+i),t.live){var s=a.details;s&&t.fragments.length>0?(h.default.mergeDetails(s,t),n=t.fragments[0].start,t.PTSKnown?p.logger.log("live audio playlist sliding:"+n.toFixed(3)):p.logger.log("live audio playlist - outdated PTS, unknown sliding")):(t.PTSKnown=!1,p.logger.log("live audio playlist - first load, unknown sliding"))}else t.PTSKnown=!1;if(a.details=t,!this.startFragRequested){if(-1===this.startPosition){var o=t.startTimeOffset;isNaN(o)?this.startPosition=0:(p.logger.log("start time offset found in playlist, adjust startPosition to "+o),this.startPosition=o)}this.nextLoadPosition=this.startPosition}this.state===m.WAITING_TRACK&&(this.state=m.IDLE),this.tick()}},{key:"onKeyLoaded",value:function(){this.state===m.KEY_LOADING&&(this.state=m.IDLE,this.tick())}},{key:"onFragLoaded",value:function(e){var t=this.fragCurrent,r=e.frag;if(this.state===m.FRAG_LOADING&&t&&"audio"===r.type&&r.level===t.level&&r.sn===t.sn){var a=this.tracks[this.trackId],i=a.details,n=i.totalduration,s=t.level,o=t.sn,l=t.cc,u=this.config.defaultAudioCodec||a.audioCodec||"mp4a.40.2",c=this.stats=e.stats;if("initSegment"===o)this.state=m.IDLE,c.tparsed=c.tbuffered=performance.now(),i.initSegment.data=e.payload,this.hls.trigger(f.default.FRAG_BUFFERED,{stats:c,frag:t,id:"audio"}),this.tick();else{this.state=m.PARSING,this.appended=!1,this.demuxer||(this.demuxer=new d.default(this.hls,"audio"));var h=this.initPTS[l],g=i.initSegment?i.initSegment.data:[];if(i.initSegment||void 0!==h){this.pendingBuffering=!0,p.logger.log("Demuxing "+o+" of ["+i.startSN+" ,"+i.endSN+"],track "+s);this.demuxer.push(e.payload,g,u,null,t,n,!1,h)}else p.logger.log("unknown video PTS for continuity counter "+l+", waiting for video PTS before demuxing audio frag "+o+" of ["+i.startSN+" ,"+i.endSN+"],track "+s),this.waitingFragment=e,this.state=m.WAITING_INIT_PTS}}this.fragLoadError=0}},{key:"onFragParsingInitSegment",value:function(e){var t=this.fragCurrent,r=e.frag;if(t&&"audio"===e.id&&r.sn===t.sn&&r.level===t.level&&this.state===m.PARSING){var a=e.tracks,i=void 0;if(a.video&&delete a.video,i=a.audio){i.levelCodec=i.codec,i.id=e.id,this.hls.trigger(f.default.BUFFER_CODECS,a),p.logger.log("audio track:audio,container:"+i.container+",codecs[level/parsed]=["+i.levelCodec+"/"+i.codec+"]");var n=i.initSegment;if(n){var s={type:"audio",data:n,parent:"audio",content:"initSegment"};this.audioSwitch?this.pendingData=[s]:(this.appended=!0,this.pendingBuffering=!0,this.hls.trigger(f.default.BUFFER_APPENDING,s))}this.tick()}}}},{key:"onFragParsingData",value:function(e){var t=this,r=this.fragCurrent,a=e.frag;if(r&&"audio"===e.id&&"audio"===e.type&&a.sn===r.sn&&a.level===r.level&&this.state===m.PARSING){var i=this.trackId,n=this.tracks[i],s=this.hls;isNaN(e.endPTS)&&(e.endPTS=e.startPTS+r.duration,e.endDTS=e.startDTS+r.duration),p.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),h.default.updateFragPTSDTS(n.details,r,e.startPTS,e.endPTS);var o=this.audioSwitch,l=this.media,u=!1;if(o&&l)if(l.readyState){var d=l.currentTime;p.logger.log("switching audio track : currentTime:"+d),d>=e.startPTS&&(p.logger.log("switching audio track : flushing all audio"),this.state=m.BUFFER_FLUSHING,s.trigger(f.default.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),u=!0,this.audioSwitch=!1,s.trigger(f.default.AUDIO_TRACK_SWITCHED,{id:i}))}else this.audioSwitch=!1,s.trigger(f.default.AUDIO_TRACK_SWITCHED,{id:i});var c=this.pendingData;this.audioSwitch||([e.data1,e.data2].forEach(function(t){t&&t.length&&c.push({type:e.type,data:t,parent:"audio",content:"data"})}),!u&&c.length&&(c.forEach(function(e){t.state===m.PARSING&&(t.pendingBuffering=!0,t.hls.trigger(f.default.BUFFER_APPENDING,e))}),this.pendingData=[],this.appended=!0)),this.tick()}}},{key:"onFragParsed",value:function(e){var t=this.fragCurrent,r=e.frag;t&&"audio"===e.id&&r.sn===t.sn&&r.level===t.level&&this.state===m.PARSING&&(this.stats.tparsed=performance.now(),this.state=m.PARSED,this._checkAppendedParsed())}},{key:"onBufferCreated",value:function(e){var t=e.tracks.audio;t&&(this.mediaBuffer=t.buffer,this.loadedmetadata=!0)}},{key:"onBufferAppended",value:function(e){if("audio"===e.parent){var t=this.state;t!==m.PARSING&&t!==m.PARSED||(this.pendingBuffering=e.pending>0,this._checkAppendedParsed())}}},{key:"_checkAppendedParsed",value:function(){if(!(this.state!==m.PARSED||this.appended&&this.pendingBuffering)){var e=this.fragCurrent,t=this.stats,r=this.hls;if(e){this.fragPrevious=e,t.tbuffered=performance.now(),r.trigger(f.default.FRAG_BUFFERED,{stats:t,frag:e,id:"audio"});var a=this.mediaBuffer?this.mediaBuffer:this.media;p.logger.log("audio buffered : "+g.default.toString(a.buffered)),this.audioSwitch&&this.appended&&(this.audioSwitch=!1,r.trigger(f.default.AUDIO_TRACK_SWITCHED,{id:this.trackId})),this.state=m.IDLE}this.tick()}}},{key:"onError",value:function(e){var t=e.frag;if(!t||"audio"===t.type)switch(e.details){case v.ErrorDetails.FRAG_LOAD_ERROR:case v.ErrorDetails.FRAG_LOAD_TIMEOUT:if(!e.fatal){var r=this.fragLoadError;r?r++:r=1;var a=this.config;if(r<=a.fragLoadingMaxRetry){this.fragLoadError=r,t.loadCounter=0;var i=Math.min(Math.pow(2,r-1)*a.fragLoadingRetryDelay,a.fragLoadingMaxRetryTimeout);p.logger.warn("audioStreamController: frag loading failed, retry in "+i+" ms"),this.retryDate=performance.now()+i,this.state=m.FRAG_LOADING_WAITING_RETRY}else p.logger.error("audioStreamController: "+e.details+" reaches max retry, redispatch as fatal ..."),e.fatal=!0,this.state=m.ERROR}break;case v.ErrorDetails.FRAG_LOOP_LOADING_ERROR:case v.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case v.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:case v.ErrorDetails.KEY_LOAD_ERROR:case v.ErrorDetails.KEY_LOAD_TIMEOUT:this.state!==m.ERROR&&(this.state=e.fatal?m.ERROR:m.IDLE,p.logger.warn("audioStreamController: "+e.details+" while loading frag,switch to "+this.state+" state ..."));break;case v.ErrorDetails.BUFFER_FULL_ERROR:if("audio"===e.parent&&(this.state===m.PARSING||this.state===m.PARSED)){var n=this.mediaBuffer,s=this.media.currentTime;if(n&&u.default.isBuffered(n,s)&&u.default.isBuffered(n,s+.5)){var o=this.config;o.maxMaxBufferLength>=o.maxBufferLength&&(o.maxMaxBufferLength/=2,p.logger.warn("audio:reduce max buffer length to "+o.maxMaxBufferLength+"s"),this.fragLoadIdx+=2*o.fragLoadingLoopThreshold),this.state=m.IDLE}else p.logger.warn("buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,this.state=m.BUFFER_FLUSHING,this.hls.trigger(f.default.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"})}}}},{key:"onBufferFlushed",value:function(){var e=this,t=this.pendingData;t&&t.length?(p.logger.log("appending pending audio data on Buffer Flushed"),t.forEach(function(t){e.hls.trigger(f.default.BUFFER_APPENDING,t)}),this.appended=!0,this.pendingData=[],this.state=m.PARSED):(this.state=m.IDLE,this.fragPrevious=null,this.tick())}},{key:"state",set:function(e){if(this.state!==e){var t=this.state;this._state=e,p.logger.log("audio stream:"+t+"->"+e)}},get:function(){return this._state}}]),t}(c.default);r.default=E},{25:25,33:33,34:34,35:35,37:37,38:38,48:48,51:51,54:54,55:55}],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 s(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 o=function(){function e(e,t){for(var r=0;r1&&setTimeout(this.tick,1),this.ticks=0)}},{key:"doTick",value:function(){this.updateTrack(this.trackId)}},{key:"onError",value:function(e){e.fatal&&e.type===f.ErrorTypes.NETWORK_ERROR&&this.cleanTimer()}},{key:"onManifestLoading",value:function(){this.tracks=[],this.trackId=-1}},{key:"onManifestLoaded",value:function(e){var t=this,r=e.audioTracks||[],a=!1;this.tracks=r,this.hls.trigger(l.default.AUDIO_TRACKS_UPDATED,{audioTracks:r});var i=0;r.forEach(function(e){if(e.default&&!a)return t.audioTrack=i,void(a=!0);i++}),!1===a&&r.length&&(d.logger.log("no default audio track defined, use first audio track as default"),this.audioTrack=0)}},{key:"onAudioTrackLoaded",value:function(e){e.id=0&&e=0&&e.1){var i=a.updating;try{a.abort()}catch(e){i=!0,d.logger.warn("can not abort audio buffer: "+e)}i?this.audioTimestampOffset=e.start:(d.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||e.levels.length&&e.audio,a=0;e.altAudio&&(t||r)&&(a=(t?1:0)+(r?1:0),d.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(){d.logger.log("media source detaching");var e=this.mediaSource;if(e){if("open"===e.readyState)try{e.endOfStream()}catch(e){d.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(l.default.MEDIA_DETACHED)}},{key:"onMediaSourceOpen",value:function(){d.logger.log("media source opened"),this.hls.trigger(l.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(){d.logger.log("media source closed")}},{key:"onMediaSourceEnded",value:function(){d.logger.log("media source ended")}},{key:"onSBUpdateEnd",value:function(){if(this.audioTimestampOffset){var e=this.sourceBuffer.audio;d.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(l.default.BUFFER_APPENDED,{parent:t,pending:r}),this._needsFlush||this.doAppending(),this.updateMediaElementDuration()}},{key:"onSBUpdateError",value:function(e){d.logger.error("sourceBuffer error:",e),this.hls.trigger(l.default.ERROR,{type:f.ErrorTypes.MEDIA_ERROR,details:f.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,s=i.container+";codecs="+n;d.logger.log("creating sourceBuffer("+s+")");try{var o=t[a]=r.addSourceBuffer(s);o.addEventListener("updateend",this.onsbue),o.addEventListener("error",this.onsbe),this.tracks[a]={codec:n,container:i.container},i.buffer=o}catch(e){d.logger.error("error while trying to add sourceBuffer:"+e.message),this.hls.trigger(l.default.ERROR,{type:f.ErrorTypes.MEDIA_ERROR,details:f.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,err:e,mimeType:s})}}this.hls.trigger(l.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){d.logger.error("sourceBuffer error:",e.event),this.hls.trigger(l.default.ERROR,{type:f.ErrorTypes.MEDIA_ERROR,details:f.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,d.logger.log(a+" sourceBuffer now EOS"));this.checkEos()}},{key:"checkEos",value:function(){var e=this.sourceBuffer,t=this.mediaSource;if(t&&"open"===t.readyState){for(var r in e){var a=e[r];if(!a.ended)return;if(a.updating)return void(this._needsEos=!0)}d.logger.log("all media data available, signal endOfStream() to MediaSource and stop loading fragment");try{t.endOfStream()}catch(e){d.logger.warn("exception while calling mediaSource.endOfStream()")}this._needsEos=!1}else this._needsEos=!1}},{key:"onBufferFlushing",value:function(e){this.flushRange.push({start:e.startOffset,end:e.endOffset,type:e.type}),this.flushBufferCounter=0,this.doFlush()}},{key:"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))&&(d.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){d.logger.error("error while accessing sourceBuffer.buffered")}this.appended=t,this.hls.trigger(l.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 d.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=t[a.type];i?i.updating?r.unshift(a):(i.ended=!1,this.parent=a.parent,i.appendBuffer(a.data),this.appendError=0,this.appended++,this.appending=!0):this.onSBUpdateEnd()}catch(t){d.logger.error("error while trying to append buffer:"+t.message),r.unshift(a);var n={type:f.ErrorTypes.MEDIA_ERROR,parent:a.parent};if(22===t.code)return this.segments=[],n.details=f.ErrorDetails.BUFFER_FULL_ERROR,n.fatal=!1,void e.trigger(l.default.ERROR,n);if(this.appendError?this.appendError++:this.appendError=1,n.details=f.ErrorDetails.BUFFER_APPEND_ERROR,this.appendError>e.config.appendErrorMaxRetry)return d.logger.log("fail "+e.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),r=[],n.fatal=!0,void e.trigger(l.default.ERROR,n);n.fatal=!1,e.trigger(l.default.ERROR,n)}}}}},{key:"flushBuffer",value:function(e,t,r){var a,i,n,s,o,l,u=this.sourceBuffer;if(Object.keys(u).length){if(d.logger.log("flushBuffer,pos/start/end: "+this.media.currentTime.toFixed(3)+"/"+e+"/"+t),this.flushBufferCounter.5)return this.flushBufferCounter++,d.logger.log("flush "+f+" ["+o+","+l+"], of ["+n+","+s+"], pos:"+this.media.currentTime),a.remove(o,l),!1}catch(e){d.logger.warn("exception while accessing sourcebuffer, it might have been removed from MediaSource")}}}else d.logger.warn("abort flushing too many retries");d.logger.log("buffer flushed")}return!0}}]),t}(u.default);r.default=c},{33:33,34:34,35:35,54:54}],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 s(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 o=function(){function e(e,t){for(var r=0;rthis.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-1===(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[]).indexOf(e)}},{key:"getMaxLevelByMediaSize",value:function(e,t,r){if(!e||e&&!e.length)return-1;for(var a=e.length-1,i=0;i=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}(a(e(34)).default);r.default=u},{34:34,35:35}],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 s(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 o=function(){function e(e,t){for(var r=0;r0&&n>u.config.fpsDroppedMonitoringThreshold*s){var f=u.currentLevel;d.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+f),f>0&&(-1===u.autoLevelCapping||u.autoLevelCapping>=f)&&(f-=1,u.trigger(l.default.FPS_DROP_LEVEL_CAPPING,{level:f,droppedLevel:u.currentLevel}),u.autoLevelCapping=f,u.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}(u.default);r.default=f},{34:34,35:35,54:54}],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 s(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 o=function(){function e(e,t){for(var r=0;r0})}else o.trigger(l.default.ERROR,{type:f.ErrorTypes.MEDIA_ERROR,details:f.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:o.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&&e1&&i.loadErrore&&(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),-1!==e&&(this.level=e)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(e){this._firstLevel=e}},{key:"startLevel",get:function(){if(void 0===this._startLevel){var e=this.hls.config.startLevel;return void 0!==e?e:this._firstLevel}return this._startLevel},set:function(e){this._startLevel=e}},{key:"nextLoadLevel",get:function(){return-1!==this._manualLevel?this._manualLevel:this.hls.nextAutoLevel},set:function(e){this.level=e,-1===this._manualLevel&&(this.hls.nextAutoLevel=e)}}]),t}(u.default);r.default=h},{33:33,34:34,35:35,37:37,54:54}],13:[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 s(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 o=function(){function e(e,t){for(var r=0;r0&&-1===e&&(p.logger.log("override startPosition with lastCurrentTime @"+t.toFixed(3)),e=t),this.state=y.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this.forceStartLoad=!0,this.state=y.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=y.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 y.ERROR:break;case y.BUFFER_FLUSHING:this.fragLoadError=0;break;case y.IDLE:this._doTickIdle();break;case y.WAITING_LEVEL:var e=this.levels[this.level];e&&e.details&&(this.state=y.IDLE);break;case y.FRAG_LOADING_WAITING_RETRY:var t=performance.now(),r=this.retryDate;(!r||t>=r||this.media&&this.media.seeking)&&(p.logger.log("mediaController: retryDate reached, switch back to IDLE state"),this.state=y.IDLE);break;case y.ERROR:case y.STOPPED:case y.FRAG_LOADING:case y.PARSING:case y.PARSED:case y.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 s=n.bitrate,o=void 0;o=s?Math.max(8*t.maxBufferSize/s,t.maxBufferLength):t.maxBufferLength,o=Math.min(o,t.maxMaxBufferLength);var l=u.default.bufferInfo(this.mediaBuffer?this.mediaBuffer:r,a,t.maxBufferHole),d=l.len;if(!(d>=o)){p.logger.trace("buffer length of "+d.toFixed(3)+" is below max of "+o.toFixed(3)+". checking for more payload ..."),this.level=e.nextLoadLevel=i;var c=n.details;if(void 0===c||c.live&&this.levelLastLoaded!==i)this.state=y.WAITING_LEVEL;else{var h=this.fragPrevious;if(!c.live&&h&&h.sn===c.endSN&&d&&!l.nextStart&&Math.min(r.duration,h.start+h.duration)-Math.max(l.end,h.start)<=Math.max(.2,h.duration)){var g={};return this.altAudio&&(g.type="video"),this.hls.trigger(f.default.BUFFER_EOS,g),void(this.state=y.ENDED)}this._fetchPayloadOrEos(a,l,c)}}}}}},{key:"_fetchPayloadOrEos",value:function(e,t,r){var a=this.fragPrevious,i=this.level,n=r.fragments,s=n.length;if(0!==s){var o=n[0].start,l=n[s-1].start+n[s-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(sc&&(u.currentTime=c),this.nextLoadPosition=c}if(e.PTSKnown&&t>a&&u&&u.readyState)return null;if(this.startFragRequested&&!e.PTSKnown){if(i){var h=i.sn+1;if(h>=e.startSN&&h<=e.endSN){var g=n[h-e.startSN];i.cc===g.cc&&(d=g,p.logger.log("live playlist, switching playlist, load frag with next SN: "+d.sn))}d||(d=l.default.search(n,function(e){return i.cc-e.cc}))&&p.logger.log("live playlist, switching playlist, load frag with same CC: "+d.sn)}d||(d=n[Math.min(s-1,Math.round(s/2))],p.logger.log("live playlist, switching playlist, unknown, load middle frag : "+d.sn))}return d}},{key:"_findFragment",value:function(e,t,r,a,i,n,s){var o=this.hls.config,u=void 0,d=void 0,f=o.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(in-f&&(f=0),d=c&&!h(c)?c:l.default.search(a,h)):d=a[r-1],d){var g=(u=d).sn-s.startSN,v=t&&u.level===t.level,y=a[g-1],m=a[g+1];if(t&&u.sn===t.sn)if(v&&!u.backtracked)if(u.sno.maxBufferHole&&t.dropped&&g?(u=y,p.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--):(u=m,p.logger.log("SN just loaded, load next one: "+u.sn))}else u=null;else u.backtracked&&(m&&m.backtracked?(p.logger.warn("Already backtracked from fragment "+m.sn+", will not backtrack to fragment "+u.sn+". Loading fragment "+m.sn),u=m):(p.logger.warn("Loaded fragment with dropped frames, backtracking 1 segment to find a keyframe"),u.dropped=0,y?(y.loadCounter&&y.loadCounter--,(u=y).backtracked=!0):g&&(u=null)))}return u}},{key:"_loadFragmentOrKey",value:function(e,t,r,a,i){var n=this.hls,s=n.config;if(!e.decryptdata||null==e.decryptdata.uri||null!=e.decryptdata.key){if(p.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 o=s.fragLoadingLoopThreshold;if(e.loadCounter>o&&Math.abs(this.fragLoadIdx-e.loadIdx)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&&!1===r.seeking&&((t=r.currentTime)>r.playbackRate*this.lastCurrentTime&&(this.lastCurrentTime=t),u.default.isBuffered(r,t)?e=this.getBufferedFrag(t):u.default.isBuffered(r,t+.1)&&(e=this.getBufferedFrag(t+.1)),e)){var a=e;if(a!==this.fragPlaying){this.hls.trigger(f.default.FRAG_CHANGED,{frag:a});var i=a.level;this.fragPlaying&&this.fragPlaying.level===i||this.hls.trigger(f.default.LEVEL_SWITCHED,{level:i}),this.fragPlaying=a}}}},{key:"immediateLevelSwitch",value:function(){if(p.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,u.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.startPTS>1&&this.flushMainBuffer(0,r.startPTS-1),e.paused)t=0;else{var i=this.hls.nextLoadLevel,n=this.levels[i],s=this.fragLastKbps;t=s&&this.fragCurrent?this.fragCurrent.duration*n.bitrate/(1e3*s)+1:0}if((a=this.getBufferedFrag(e.currentTime+t))&&(a=this.followingBufferedFrag(a))){var o=this.fragCurrent;o&&o.loader&&o.loader.abort(),this.fragCurrent=null,this.flushMainBuffer(a.maxStartPTS,Number.POSITIVE_INFINITY)}}}},{key:"flushMainBuffer",value:function(e,t){this.state=y.BUFFER_FLUSHING;var r={startOffset:e,endOffset:t};this.altAudio&&(r.type="video"),this.hls.trigger(f.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&&(p.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)||p.logger.log("media seeking to "+t.toFixed(3));var a=this.mediaBuffer?this.mediaBuffer:e,i=u.default.bufferInfo(a,t,this.config.maxBufferHole);if(this.state===y.FRAG_LOADING){var n=this.fragCurrent;if(0===i.len&&n){var s=r.maxFragLookUpTolerance,o=n.start-s,l=n.start+n.duration+s;tl?(n.loader&&(p.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=y.IDLE):p.logger.log("seeking outside of buffer but within currently loaded fragment range")}}else this.state===y.ENDED&&(0===i.len&&(this.fragPrevious=0),this.state=y.IDLE);e&&(this.lastCurrentTime=t),this.state!==y.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)||p.logger.log("media seeked to "+t.toFixed(3)),this.tick()}},{key:"onMediaEnded",value:function(){p.logger.log("media ended"),this.startPosition=this.lastCurrentTime=0}},{key:"onManifestLoading",value:function(){p.logger.log("trigger BUFFER_RESET"),this.hls.trigger(f.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)&&(-1!==t.indexOf("mp4a.40.2")&&(r=!0),-1!==t.indexOf("mp4a.40.5")&&(a=!0))}),this.audioCodecSwitch=r&&a,this.audioCodecSwitch&&p.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(p.logger.log("level "+r+" loaded ["+t.startSN+","+t.endSN+"],duration:"+i),this.levelLastLoaded=r,t.live){var s=a.details;s&&t.fragments.length>0?(h.default.mergeDetails(s,t),n=t.fragments[0].start,this.liveSyncPosition=this.computeLivePosition(n,s),t.PTSKnown?p.logger.log("live playlist sliding:"+n.toFixed(3)):p.logger.log("live playlist - outdated PTS, unknown sliding")):(t.PTSKnown=!1,p.logger.log("live playlist - first load, unknown sliding"))}else t.PTSKnown=!1;if(a.details=t,this.hls.trigger(f.default.LEVEL_UPDATED,{details:t,level:r}),!1===this.startFragRequested){if(-1===this.startPosition||-1===this.lastCurrentTime){var o=t.startTimeOffset;isNaN(o)?t.live?(this.startPosition=this.computeLivePosition(n,t),p.logger.log("configure startPosition to "+this.startPosition)):this.startPosition=0:(o<0&&(p.logger.log("negative start time offset "+o+", count from end of last fragment"),o=n+i+o),p.logger.log("start time offset found in playlist, adjust startPosition to "+o),this.startPosition=o),this.lastCurrentTime=this.startPosition}this.nextLoadPosition=this.startPosition}this.state===y.WAITING_LEVEL&&(this.state=y.IDLE),this.tick()}},{key:"onKeyLoaded",value:function(){this.state===y.KEY_LOADING&&(this.state=y.IDLE,this.tick())}},{key:"onFragLoaded",value:function(e){var t=this.fragCurrent,r=e.frag;if(this.state===y.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(p.logger.log("Loaded "+t.sn+" of ["+n.startSN+" ,"+n.endSN+"],level "+t.level),this.bitrateTest=!1,this.stats=a,!0===r.bitrateTest&&this.hls.nextLoadLevel)this.state=y.IDLE,this.startFragRequested=!1,a.tparsed=a.tbuffered=performance.now(),this.hls.trigger(f.default.FRAG_BUFFERED,{stats:a,frag:t,id:"main"}),this.tick();else if("initSegment"===r.sn)this.state=y.IDLE,a.tparsed=a.tbuffered=performance.now(),n.initSegment.data=e.payload,this.hls.trigger(f.default.FRAG_BUFFERED,{stats:a,frag:t,id:"main"}),this.tick();else{this.state=y.PARSING;var s=n.totalduration,o=t.level,l=t.sn,u=this.config.defaultAudioCodec||i.audioCodec;this.audioCodecSwap&&(p.logger.log("swapping playlist audio codec"),void 0===u&&(u=this.lastAudioCodec),u&&(u=-1!==u.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5")),this.pendingBuffering=!0,this.appended=!1,p.logger.log("Parsing "+l+" of ["+n.startSN+" ,"+n.endSN+"],level "+o+", cc "+t.cc);var c=this.demuxer;c||(c=this.demuxer=new d.default(this.hls,"main"));var h=this.media,g=!(h&&h.seeking)&&(n.PTSKnown||!n.live),v=n.initSegment?n.initSegment.data:[];c.push(e.payload,v,u,i.videoCodec,t,s,g,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===y.PARSING){var a,i,n=e.tracks;if(n.audio&&this.altAudio&&delete n.audio,i=n.audio){var s=this.levels[this.level].audioCodec,o=navigator.userAgent.toLowerCase();s&&this.audioCodecSwap&&(p.logger.log("swapping playlist audio codec"),s=-1!==s.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),this.audioCodecSwitch&&1!==i.metadata.channelCount&&-1===o.indexOf("firefox")&&(s="mp4a.40.5"),-1!==o.indexOf("android")&&"audio/mpeg"!==i.container&&(s="mp4a.40.2",p.logger.log("Android: force audio codec to "+s)),i.levelCodec=s,i.id=e.id}(i=n.video)&&(i.levelCodec=this.levels[this.level].videoCodec,i.id=e.id),this.hls.trigger(f.default.BUFFER_CODECS,n);for(a in n){i=n[a],p.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(f.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===y.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),p.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 p.logger.warn("missing video frame(s), backtracking fragment"),n.backtracked=!0,this.nextLoadPosition=e.startPTS,this.state=y.IDLE,this.fragPrevious=n,void this.tick();p.logger.warn("Already backtracked on this fragment, appending with the gap")}else n.backtracked=!1;var s=h.default.updateFragPTSDTS(i.details,n,e.startPTS,e.endPTS,e.startDTS,e.endDTS),o=this.hls;o.trigger(f.default.LEVEL_PTS_UPDATED,{details:i.details,level:this.level,drift:s,type:e.type,start:e.startPTS,end:e.endPTS}),[e.data1,e.data2].forEach(function(r){r&&r.length&&t.state===y.PARSING&&(t.appended=!0,t.pendingBuffering=!0,o.trigger(f.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===y.PARSING&&(this.stats.tparsed=performance.now(),this.state=y.PARSED,this._checkAppendedParsed())}},{key:"onAudioTrackSwitching",value:function(e){var t=!!e.url,r=e.id;if(!t){if(this.mediaBuffer!==this.media){p.logger.log("switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var a=this.fragCurrent;a.loader&&(p.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=y.IDLE}var i=this.hls;i.trigger(f.default.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),i.trigger(f.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&&(p.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 s=t[n];"main"===s.id?(a=n,r=s,"video"===n&&(this.videoBuffer=t[n].buffer)):i=!0}i&&r?(p.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!==y.PARSING&&t!==y.PARSED||(this.pendingBuffering=e.pending>0,this._checkAppendedParsed())}}},{key:"_checkAppendedParsed",value:function(){if(!(this.state!==y.PARSED||this.appended&&this.pendingBuffering)){var e=this.fragCurrent;if(e){var t=this.mediaBuffer?this.mediaBuffer:this.media;p.logger.log("main buffered : "+g.default.toString(t.buffered));var r=this._bufferedFrags.filter(function(e){return u.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(f.default.FRAG_BUFFERED,{stats:a,frag:e,id:"main"}),this.state=y.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&&u.default.isBuffered(r,r.currentTime)&&u.default.isBuffered(r,r.currentTime+.5);switch(e.details){case v.ErrorDetails.FRAG_LOAD_ERROR:case v.ErrorDetails.FRAG_LOAD_TIMEOUT:case v.ErrorDetails.KEY_LOAD_ERROR:case v.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 s=Math.min(Math.pow(2,i-1)*n.fragLoadingRetryDelay,n.fragLoadingMaxRetryTimeout);p.logger.warn("mediaController: frag loading failed, retry in "+s+" ms"),this.retryDate=performance.now()+s,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.state=y.FRAG_LOADING_WAITING_RETRY}else p.logger.error("mediaController: "+e.details+" reaches max retry, redispatch as fatal ..."),e.fatal=!0,this.state=y.ERROR}break;case v.ErrorDetails.FRAG_LOOP_LOADING_ERROR:e.fatal||(a?(this._reduceMaxBufferLength(t.duration),this.state=y.IDLE):t.autoLevel&&0!==t.level||(e.fatal=!0,this.state=y.ERROR));break;case v.ErrorDetails.LEVEL_LOAD_ERROR:case v.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==y.ERROR&&(e.fatal?(this.state=y.ERROR,p.logger.warn("streamController: "+e.details+",switch to "+this.state+" state ...")):e.levelRetry||this.state!==y.WAITING_LEVEL||(this.state=y.IDLE));break;case v.ErrorDetails.BUFFER_FULL_ERROR:"main"!==e.parent||this.state!==y.PARSING&&this.state!==y.PARSED||(a?(this._reduceMaxBufferLength(this.config.maxBufferLength),this.state=y.IDLE):(p.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,p.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,s=u.default.isBuffered(a,n),o=i.start(0);(r!==n||!s&&Math.abs(n-o)1e3*t.lowBufferWatchdogPeriod){this.stallReported||(this.stallReported=!0,p.logger.warn("playback stalling in low buffer @"+r),h.trigger(f.default.ERROR,{type:v.ErrorTypes.MEDIA_ERROR,details:v.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:y}));var E=l.nextStart,b=E-r;if(E&&b0){this.nudgeRetry=++m;var T=m*t.nudgeOffset;p.logger.log("adjust currentTime from "+e.currentTime+" to next buffered @ "+E+" + nudge "+T),e.currentTime=E+T,this.stalled=void 0,h.trigger(f.default.ERROR,{type:v.ErrorTypes.MEDIA_ERROR,details:v.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,hole:E+T-r})}}else if(y>.5&&g>1e3*t.highBufferWatchdogPeriod)if(this.stallReported||(this.stallReported=!0,p.logger.warn("playback stalling in high buffer @"+r),h.trigger(f.default.ERROR,{type:v.ErrorTypes.MEDIA_ERROR,details:v.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:y})),this.stalled=void 0,this.nudgeRetry=++m,m"+e),this.hls.trigger(f.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}(c.default);r.default=m},{25:25,33:33,34:34,35:35,37:37,38:38,48:48,54:54,55:55}],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")}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 s(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 o=function(){function e(e,t){for(var r=0;r-1&&this.vttFragQueues[this.currentTrackId].length){var e=this.currentlyProcessing=this.vttFragQueues[this.currentTrackId].shift();this.hls.trigger(l.default.FRAG_LOADING,{frag:e})}}},{key:"onSubtitleFragProcessed",value:function(e){e.success&&this.vttFragSNsProcessed[e.frag.trackId].push(e.frag.sn),this.currentlyProcessing=null,this.nextFrag()}},{key:"onError",value:function(e){var t=e.frag;t&&"subtitle"!==t.type||this.currentlyProcessing&&(this.currentlyProcessing=null,this.nextFrag())}},{key:"onSubtitleTracksUpdated",value:function(e){var t=this;d.logger.log("subtitle tracks updated"),this.tracks=e.subtitleTracks,this.clearVttFragQueues(),this.vttFragSNsProcessed={},this.tracks.forEach(function(e){t.vttFragSNsProcessed[e.id]=[]})}},{key:"onSubtitleTrackSwitch",value:function(e){this.currentTrackId=e.id,this.clearVttFragQueues()}},{key:"onSubtitleTrackLoaded",value:function(e){var t=this.vttFragSNsProcessed[e.id],r=this.vttFragQueues[e.id],a=this.currentlyProcessing?this.currentlyProcessing.sn:-1,i=function(e){return t.indexOf(e.sn)>-1},n=function(e){return r.some(function(t){return t.sn===e.sn})};e.details.fragments.forEach(function(t){i(t)||t.sn===a||n(t)||(t.trackId=e.id,r.push(t))}),this.nextFrag()}}]),t}(u.default);r.default=f},{34:34,35:35,54:54}],15:[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 s(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){for(var t=[],r=0;r=0&&e0;)e.removeCue(e.cues[0])}function l(e,t){return e&&e.label===t.name&&!(e.textTrack1||e.textTrack2)}function u(e,t,r,a){return Math.min(t,a)-Math.max(e,r)}Object.defineProperty(r,"__esModule",{value:!0});var d=function(){function e(e,t){for(var r=0;r=0&&(o[0]=Math.min(o[0],t),o[1]=Math.max(o[1],r),n=!0,l/(r-t)>.5))return}n||i.push([t,r]),this.Cues.newCue(this[e],t,r,a)}},{key:"onInitPtsFound",value:function(e){var t=this;void 0===this.initPTS&&(this.initPTS=e.initPTS),this.unparsedVttFrags.length&&(this.unparsedVttFrags.forEach(function(e){t.onFragLoaded(e)}),this.unparsedVttFrags=[])}},{key:"getExistingTrack",value:function(e){var t=this.media;if(t)for(var r=0;r>>8^255&p^99,e[h]=p,t[p]=h;var y=c[h],m=c[y],E=c[m],b=257*c[p]^16843008*p;a[h]=b<<24|b>>>8,i[h]=b<<16|b>>>16,n[h]=b<<8|b>>>24,s[h]=b,b=16843009*E^65537*m^257*y^16843008*h,l[p]=b<<24|b>>>8,u[p]=b<<16|b>>>16,d[p]=b<<8|b>>>24,f[p]=b,h?(h=y^c[c[c[E^y]]],g^=c[c[g]]):h=g=1}}},{key:"expandKey",value:function(e){for(var t=this.uint8ArrayToUint32Array_(e),r=!0,a=0;a>8|e>>>24}},{key:"decrypt",value:function(e,t,r){for(var a,i,n=this.keySize+6,s=this.invKeySchedule,o=this.invSBox,l=this.invSubMix,u=l[0],d=l[1],f=l[2],c=l[3],h=this.uint8ArrayToUint32Array_(r),g=h[0],v=h[1],p=h[2],y=h[3],m=new Int32Array(e),E=new Int32Array(m.length),b=void 0,T=void 0,k=void 0,_=void 0,R=void 0,S=void 0,A=void 0,L=void 0,w=void 0,D=void 0,O=void 0,I=void 0,P=this.networkToHostOrderSwap;t>>24]^d[S>>16&255]^f[A>>8&255]^c[255&L]^s[a],T=u[S>>>24]^d[A>>16&255]^f[L>>8&255]^c[255&R]^s[a+1],k=u[A>>>24]^d[L>>16&255]^f[R>>8&255]^c[255&S]^s[a+2],_=u[L>>>24]^d[R>>16&255]^f[S>>8&255]^c[255&A]^s[a+3],R=b,S=T,A=k,L=_,a+=4;b=o[R>>>24]<<24^o[S>>16&255]<<16^o[A>>8&255]<<8^o[255&L]^s[a],T=o[S>>>24]<<24^o[A>>16&255]<<16^o[L>>8&255]<<8^o[255&R]^s[a+1],k=o[A>>>24]<<24^o[L>>16&255]<<16^o[R>>8&255]<<8^o[255&S]^s[a+2],_=o[L>>>24]<<24^o[R>>16&255]<<16^o[S>>8&255]<<8^o[255&A]^s[a+3],a+=3,E[t]=P(b^g),E[t+1]=P(_^v),E[t+2]=P(k^p),E[t+3]=P(T^y),g=w,v=D,p=O,y=I,t+=4}return E.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},{}],19:[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>>6),!((o=(60&t[r+2])>>>2)>h.length-1))return u=(1&t[r+2])<<2,u|=(192&t[r+3])>>>6,a.logger.log("manifest codec:"+n+",ADTS data:type:"+s+",sampleingIndex:"+o+"["+h[o]+"Hz],channelConfig:"+u),/firefox/i.test(f)?o>=6?(s=5,d=new Array(4),l=o-3):(s=2,d=new Array(2),l=o):-1!==f.indexOf("android")?(s=2,d=new Array(2),l=o):(s=5,d=new Array(4),n&&(-1!==n.indexOf("mp4a.40.29")||-1!==n.indexOf("mp4a.40.5"))||!n&&o>=6?l=o-3:((n&&-1!==n.indexOf("mp4a.40.2")&&(o>=6&&1===u||/vivaldi/i.test(f))||!n&&1===u)&&(s=2,d=new Array(2)),l=o)),d[0]=s<<3,d[0]|=(14&o)>>1,d[1]|=(1&o)<<7,d[1]|=u<<3,5===s&&(d[1]|=(14&l)>>1,d[2]=(1&l)<<7,d[2]|=8,d[3]=0),{config:d,samplerate:h[o],channelCount:u,codec:"mp4a.40."+s,manifestCodec:c};e.trigger(Event.ERROR,{type:i.ErrorTypes.MEDIA_ERROR,details:i.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+o})},isHeaderPattern:function(e,t){return 255===e[t]&&240==(246&e[t+1])},getHeaderLength:function(e,t){return 1&e[t+1]?7:9},getFullFrameLength:function(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5},isHeader:function(e,t){return!!(t+10&&t+n+s<=l)return o=r+a*i,{headerLength:n,frameLength:s,stamp:o}}};t.exports=n},{33:33,54:54}],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;r0&&null!=t&&null!=t.key&&"AES-128"===t.method){var g=this.decrypter;null==g&&(g=this.decrypter=new l.default(this.observer,this.config));var v,p=this;try{v=performance.now()}catch(e){v=Date.now()}g.decrypt(e,t.key.buffer,t.iv.buffer,function(e){var l;try{l=performance.now()}catch(e){l=Date.now()}p.observer.trigger(s.default.FRAG_DECRYPTED,{stats:{tstart:v,tdecrypt:l}}),p.pushDecrypted(new Uint8Array(e),t,new Uint8Array(r),a,i,n,o,u,d,f,c,h)})}else this.pushDecrypted(new Uint8Array(e),t,new Uint8Array(r),a,i,n,o,u,d,f,c,h)}},{key:"pushDecrypted",value:function(e,t,r,a,i,n,l,v,p,y,m,E){var b=this.demuxer;if(!b||l&&!this.probe(e)){for(var T=this.observer,k=this.typeSupported,_=this.config,R=[{demux:u.default,remux:h.default},{demux:c.default,remux:h.default},{demux:f.default,remux:h.default},{demux:d.default,remux:g.default}],S=0,A=R.length;S1?r-1:0),i=1;i1?r-1:0),i=1;i1?t-1:0),a=1;a1?t-1:0),a=1;ae?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,e-=(t=e>>3)>>3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}},{key:"readBits",value:function(e){var t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;return e>32&&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)>0&&this.bitsAvailable?r<>>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=8,a=8;for(t=0;t0)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>4){case 0:return a;case 1:case 2:case 3:case 4:case 5:case 6:case 7:a+=String.fromCharCode(s);break;case 12:case 13:t=e[i++],a+=String.fromCharCode((31&s)<<6|63&t);break;case 14:t=e[i++],r=e[i++],a+=String.fromCharCode((15&s)<<12|(63&t)<<6|(63&r)<<0)}}return a}}]),e}();r.default=n},{}],28:[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=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,s,o,l,u,d=[];if(t.data?(l=t.start,s=t.end,t=t.data):(l=0,s=t.byteLength),!r.length)return null;for(a=l;a1?a+i:s,n===r[0]&&(1===r.length?d.push({data:t,start:a+8,end:u}):(o=e.findBox({data:t,start:a+8,end:u},r.slice(1))).length&&(d=d.concat(o))),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,s=e.readUint32(a,n),o=e.findBox(t,["mdia","mdhd"])[0];if(o){n=0===(i=o.data[o.start])?12:20;var l=e.readUint32(o,n),u=e.findBox(t,["mdia","hdlr"])[0];if(u){var d={soun:"audio",vide:"video"}[e.bin2str(u.data.subarray(u.start+8,u.start+12))];d&&(r[s]={timescale:l,type:d},r[d]={timescale:l,id:s})}}}}),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,s;return i=e.readUint32(a,4),n=t[i].timescale||9e4,s=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],(s=s||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=o},{35:35}],30:[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 s=a+i*(10368e4/n.sampleRate),o={unit:t.subarray(r,r+n.frameLength),pts:s,dts:s};return e.config=[],e.channelCount=n.channelCount,e.samplerate=n.sampleRate,e.samples.push(o),e.len+=n.frameLength,{sample:o,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,s=e[t+2]>>2&3,o=!!(2&e[t+2]);if(1!==r&&0!==n&&15!==n&&3!==s){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+s],c=o?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}}},isHeaderPattern:function(e,t){return 255===e[t]&&224==(224&e[t+1])&&0!=(6&e[t+1])},isHeader:function(e,t){return!!(t+1=e.length)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 s=this.discardEPB(i.data),o=this.getAvcEncryptedData(s),l=this;this.decryptBuffer(o.buffer,function(o){i.data=l.getAvcDecryptedUnit(s,o),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 s=this.decrypter.isSync();if(this.decryptAvcSample(e,t,r,a,n,s),!s)return}}}}}]),e}();r.default=s},{19:19}],32:[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>4>1){if((o=i+5+e[i+4])===i+188)continue}else o=i+4;switch(s){case m:n&&(k&&(u=L(k))&&w(u,!1),k={data:[],size:0}),k&&(k.data.push(e.subarray(o,i+188)),k.size+=i+188-o);break;case E:n&&(_&&(u=L(_))&&(p.isAAC?D(u):O(u)),_={data:[],size:0}),_&&(_.data.push(e.subarray(o,i+188)),_.size+=i+188-o);break;case b:n&&(R&&(u=L(R))&&I(u),R={data:[],size:0}),R&&(R.data.push(e.subarray(o,i+188)),R.size+=i+188-o);break;case 0:n&&(o+=e[o]+1),T=this._pmtId=S(e,o);break;case T:n&&(o+=e[o]+1);var P=A(e,o,!0===this.typeSupported.mpeg||!0===this.typeSupported.mp3,null!=this.sampleAes);(m=P.avc)>0&&(v.id=m),(E=P.audio)>0&&(p.id=E,p.isAAC=P.isAAC),(b=P.id3)>0&&(y.id=b),h&&!g&&(f.logger.log("reparse from beginning"),h=!1,i=-188),g=this.pmtParsed=!0;break;case 17:case 8191:break;default:h=!0}}else this.observer.trigger(l.default.ERROR,{type:c.ErrorTypes.MEDIA_ERROR,details:c.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});k&&(u=L(k))?(w(u,!0),v.pesData=null):v.pesData=k,_&&(u=L(_))?(p.isAAC?D(u):O(u),p.pesData=null):(_&&_.size&&f.logger.log("last AAC PES packet truncated,might overlap between fragments"),p.pesData=_),R&&(u=L(R))?(I(u),y.pesData=null):y.pesData=R,null==this.sampleAes?this.remuxer.remux(p,v,y,this._txtTrack,t,r,a):this.decryptAndRemux(p,v,y,this._txtTrack,t,r,a)}},{key:"decryptAndRemux",value:function(e,t,r,a,i,n,s){if(e.samples&&e.isAAC){var o=this;this.sampleAes.decryptAacSamples(e.samples,0,function(){o.decryptAndRemuxAvc(e,t,r,a,i,n,s)})}else this.decryptAndRemuxAvc(e,t,r,a,i,n,s)}},{key:"decryptAndRemuxAvc",value:function(e,t,r,a,i,n,s){if(t.samples){var o=this;this.sampleAes.decryptAvcSamples(t.samples,0,0,function(){o.remuxer.remux(e,t,r,a,i,n,s)})}else this.remuxer.remux(e,t,r,a,i,n,s)}},{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,s={audio:-1,avc:-1,id3:-1,isAAC:!0};for(i=t+3+((15&e[t+1])<<8|e[t+2])-4,t+=12+((15&e[t+10])<<8|e[t+11]);t1;){var c=new Uint8Array(d[0].length+d[1].length);c.set(d[0]),c.set(d[1],d[0].length),d[0]=c,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;192&(r=t[7])&&((s=536870912*(14&t[9])+4194304*(255&t[10])+16384*(254&t[11])+128*(255&t[12])+(254&t[13])/2)>4294967295&&(s-=8589934592),64&r?((o=536870912*(14&t[14])+4194304*(255&t[15])+16384*(254&t[16])+128*(255&t[17])+(254&t[18])/2)>4294967295&&(o-=8589934592),s-o>54e5&&(f.logger.warn(Math.round((s-o)/9e4)+"s delta between PTS and DTS, align them"),s=o)):o=s),l=(i=t[8])+9,e.size-=l,n=new Uint8Array(e.size);for(var h=0,g=d.length;hv){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:s,dts:o,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||!0===e.key||t.sps&&(a||this.contiguous)?(e.id=a,r.push(e)):t.dropped++}e.debug.length&&f.logger.log(e.pts+"/"+e.dts+":"+e.debug)}},{key:"_parseAVCPES",value:function(e,t){var r,a,i,n=this,s=this._avcTrack,o=this._parseAVCNALu(e.data),l=this.avcSample,d=!1,f=this.pushAccesUnit.bind(this),c=function(e,t,r,a){return{key:e,pts:t,dts:r,units:[],debug:a}};e.data=null,l&&o.length&&(f(l,s),l=this.avcSample=c(!1,e.pts,e.dts,"")),o.forEach(function(t){switch(t.type){case 1:a=!0,l.frame=!0;var o=t.data;if(d&&o.length>4){var h=new u.default(o).readSliceType();2!==h&&4!==h&&7!==h&&9!==h||(l.key=!0)}break;case 5:a=!0,l||(l=n.avcSample=c(!0,e.pts,e.dts,"")),l.key=!0,l.frame=!0;break;case 6:a=!0,(r=new u.default(n.discardEPB(t.data))).readUByte();for(var g=0,v=0,p=!1,y=0;!p&&r.bytesAvailable>1;){g=0;do{g+=y=r.readUByte()}while(255===y);v=0;do{v+=y=r.readUByte()}while(255===y);if(4===g&&0!==r.bytesAvailable){if(p=!0,181===r.readUByte()&&49===r.readUShort()&&1195456820===r.readUInt()&&3===r.readUByte()){var m=r.readUByte(),E=31&m,b=[m,r.readUByte()];for(i=0;i0){if(t.pts>=e[r-1].pts)e.push(t);else for(var a=r-1;a>=0;a--)if(t.pts=0)a={data:e.subarray(f,n-l-1),type:i},d.push(a);else{var c=this._getLastNalUnit();if(c&&(u&&n<=4-u&&c.state&&(c.data=c.data.subarray(0,c.data.byteLength-u)),(r=n-l-1)>0)){var h=new Uint8Array(c.data.byteLength+r);h.set(c.data,0),h.set(e.subarray(0,r),c.data.byteLength),c.data=h}}n=0&&l>=0&&(a={data:e.subarray(f,s),type:i,state:l},d.push(a)),0===d.length){var g=this._getLastNalUnit();if(g){var v=new Uint8Array(g.data.byteLength+e.byteLength);v.set(g.data,0),v.set(e,g.data.byteLength),g.data=v}}return o.naluState=l,d}},{key:"discardEPB",value:function(e){for(var t,r,a=e.byteLength,i=[],n=1;n1&&(f.logger.log("AAC: align PTS for overlapping frames by "+Math.round((m-d)/90)),d=m)}for(;a=564&&71===e[0]&&71===e[188]&&71===e[376]}}]),e}();r.default=h},{22:22,26:26,30:30,31:31,33:33,35:35,54:54}],33:[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"}},{}],34:[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;r1?r-1:0),n=1;n=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;ad&&(l[u-1].end=e[o].end):l.push(e[o])}else l.push(e[o])}for(o=0,a=0,i=n=t;o=f&&t=0&&oe.endSN)return 0;var f,c,h;for(f=d-e.startSN,(c=e.fragments)[f]=t,h=f;h>0;h--)i.updatePTS(c,h,h-1);for(h=f;ht?i.start+i.duration:Math.max(i.start-n.duration,0):r>t?(i.duration=s-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-s,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},{54:54}],39:[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;r0&&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,v.enableLogs)(r.debug),this.config=r,this._autoLevelCapping=-1;var s=this.observer=new p.default;s.trigger=function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),a=1;a1?t-1:0),a=1;a0&&void 0!==arguments[0]?arguments[0]:-1;v.logger.log("startLoad("+e+")"),this.networkControllers.forEach(function(t){t.startLoad(e)})}},{key:"stopLoad",value:function(){v.logger.log("stopLoad"),this.networkControllers.forEach(function(e){e.stopLoad()})}},{key:"swapAudioCodec",value:function(){v.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()}},{key:"recoverMediaError",value:function(){v.logger.log("recoverMediaError");var e=this.media;this.detachMedia(),this.attachMedia(e)}},{key:"levels",get:function(){return this.levelController.levels}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(e){v.logger.log("set currentLevel:"+e),this.loadLevel=e,this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(e){v.logger.log("set nextLevel:"+e),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(e){v.logger.log("set loadLevel:"+e),this.levelController.manualLevel=e}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(e){this.levelController.nextLoadLevel=e}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(e){v.logger.log("set firstLevel:"+e),this.levelController.firstLevel=e}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(e){v.logger.log("set startLevel:"+e);var t=this;-1!==e&&(e=Math.max(e,t.minAutoLevel)),t.levelController.startLevel=e}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(e){v.logger.log("set autoLevelCapping:"+e),this._autoLevelCapping=e}},{key:"autoLevelEnabled",get:function(){return-1===this.levelController.manualLevel}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){for(var e=this,t=e.levels,r=e.config.minAutoBitrate,a=t?t.length:0,i=0;ir)return i;return 0}},{key:"maxAutoLevel",get:function(){var e=this,t=e.levels,r=e.autoLevelCapping;return-1===r&&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=m},{1:1,11:11,12:12,13:13,2:2,33:33,35:35,4:4,41:41,42:42,43:43,54:54}],40:[function(e,t,r){"use strict";t.exports=e(39).default},{39:39}],41:[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 s(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 o=function(){function e(e,t){for(var r=0;r3&&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(l.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(l.default.ERROR,{type:d.ErrorTypes.NETWORK_ERROR,details:d.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(l.default.ERROR,{type:d.ErrorTypes.NETWORK_ERROR,details:d.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(l.default.FRAG_LOAD_PROGRESS,{frag:i,stats:e,networkDetails:a})}}]),t}(u.default);r.default=c},{33:33,34:34,35:35,54:54}],42:[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 s(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 o=function(){function e(e,t){for(var r=0;r>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 m).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=l.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||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}(),b=function(e){function t(e){s(this,t);var r=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,u.default.MANIFEST_LOADING,u.default.LEVEL_LOADING,u.default.AUDIO_TRACK_LOADING,u.default.SUBTITLE_TRACK_LOADING));return r.loaders={},r}return n(t,e),o(t,[{key:"destroy",value:function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy()}this.loaders={},d.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 h.logger.trace("playlist request ongoing");h.logger.warn("abort previous loader for type:"+t.type),r.abort()}var i=this.hls.config,n=void 0,s=void 0,o=void 0,l=void 0;"manifest"===t.type?(n=i.manifestLoadingMaxRetry,s=i.manifestLoadingTimeOut,o=i.manifestLoadingRetryDelay,l=i.manifestLoadingMaxRetryTimeout):(n=i.levelLoadingMaxRetry,s=i.levelLoadingTimeOut,o=i.levelLoadingRetryDelay,l=i.levelLoadingMaxRetryTimeout,h.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:s,maxRetry:n,retryDelay:o,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 l.default.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}},{key:"parseMasterPlaylist",value:function(e,t){var r=[],a=void 0;for(g.lastIndex=0;null!=(a=g.exec(e));){var i={},n=i.attrs=new c.default(a[1]);i.url=this.resolve(a[2],t);var s=n.decimalResolution("RESOLUTION");s&&(i.width=s.width,i.height=s.height),i.bitrate=n.decimalInteger("AVERAGE-BANDWIDTH")||n.decimalInteger("BANDWIDTH"),i.name=n.NAME;var o=n.CODECS;if(o){o=o.split(/[ ,]+/);for(var l=0;l3&&void 0!==arguments[3]?arguments[3]:null,i=void 0,n=[],s=0;for(v.lastIndex=0;null!=(i=v.exec(e));){var o={},l=new c.default(i[1]);l.TYPE===r&&(o.groupId=l["GROUP-ID"],o.name=l.NAME,o.type=r,o.default="YES"===l.DEFAULT,o.autoselect="YES"===l.AUTOSELECT,o.forced="YES"===l.FORCED,l.URI&&(o.url=this.resolve(l.URI,t)),o.lang=l.LANGUAGE,o.name||(o.name=o.lang),a&&(o.audioCodec=a),o.id=s++,n.push(o))}return n}},{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,s=0,o=0,l={type:null,version:null,url:t,fragments:[],live:!0,startSN:0},u=new m,d=0,f=null,g=new E;for(p.lastIndex=0;null!==(i=p.exec(e));){var v=i[1];if(v){g.duration=parseFloat(v);var b=(" "+i[2]).slice(1);g.title=b||null,g.tagList.push(b?["INF",v,b]:["INF",v])}else if(i[3]){if(!isNaN(g.duration)){var T=s++;g.type=a,g.start=o,g.levelkey=u,g.sn=T,g.level=r,g.cc=d,g.baseurl=t,g.relurl=(" "+i[3]).slice(1),l.fragments.push(g),f=g,o+=g.duration,g=new E}}else if(i[4]){if(g.rawByteRange=(" "+i[4]).slice(1),f){var k=f.byteRangeEndOffset;k&&(g.lastByteRangeEndOffset=k)}}else if(i[5])g.rawProgramDateTime=(" "+i[5]).slice(1),g.tagList.push(["PROGRAM-DATE-TIME",g.rawProgramDateTime]);else{for(i=i[0].match(y),n=1;n=0&&(u.method=L,u.baseuri=t,u.reluri=w,u.key=null,u.iv=D));break;case"START":var O=_,I=new c.default(O).decimalFloatingPoint("TIME-OFFSET");isNaN(I)||(l.startTimeOffset=I);break;case"MAP":var P=new c.default(_);g.relurl=P.URI,g.rawByteRange=P.BYTERANGE,g.baseurl=t,g.level=r,g.type=a,g.sn="initSegment",l.initSegment=g,g=new E;break;default:h.logger.warn("line parsed but not handled: "+i)}}}return(g=f)&&!g.relurl&&(l.fragments.pop(),o-=g.duration),l.totalduration=o,l.averagetargetduration=o/l.fragments.length,l.endSN=s-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,s=r.type,o=r.id,l=r.level,d=this.hls;if(this.loaders[s]=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 c="audioTrack"!==s&&"subtitleTrack"!==s,g=isNaN(l)?isNaN(o)?0:o:l,v=this.parseLevelPlaylist(i,n,g,"audioTrack"===s?"audio":"subtitleTrack"===s?"subtitle":"main");v.tload=t.tload,"manifest"===s&&d.trigger(u.default.MANIFEST_LOADED,{levels:[{url:n,details:v}],audioTracks:[],url:n,stats:t,networkDetails:a}),t.tparsed=performance.now(),v.targetduration?c?d.trigger(u.default.LEVEL_LOADED,{details:v,level:l||0,id:o||0,stats:t,networkDetails:a}):"audioTrack"===s?d.trigger(u.default.AUDIO_TRACK_LOADED,{details:v,id:o,stats:t,networkDetails:a}):"subtitleTrack"===s&&d.trigger(u.default.SUBTITLE_TRACK_LOADED,{details:v,id:o,stats:t,networkDetails:a}):d.trigger(u.default.ERROR,{type:f.ErrorTypes.NETWORK_ERROR,details:f.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:!0,url:n,reason:"invalid targetduration",networkDetails:a})}else{var p=this.parseMasterPlaylist(i,n);if(p.length){var y=this.parseMasterPlaylistMedia(i,n,"AUDIO",p[0].audioCodec),m=this.parseMasterPlaylistMedia(i,n,"SUBTITLES");if(y.length){var E=!1;y.forEach(function(e){e.url||(E=!0)}),!1===E&&p[0].audioCodec&&!p[0].attrs.AUDIO&&(h.logger.log("audio codec signaled in quality level, but no embedded audio track signaled, create one"),y.unshift({type:"main",name:"main"}))}d.trigger(u.default.MANIFEST_LOADED,{levels:p,audioTracks:y,subtitles:m,url:n,stats:t,networkDetails:a})}else d.trigger(u.default.ERROR,{type:f.ErrorTypes.NETWORK_ERROR,details:f.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:!0,url:n,reason:"no level found in manifest",networkDetails:a})}else d.trigger(u.default.ERROR,{type:f.ErrorTypes.NETWORK_ERROR,details:f.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=f.ErrorDetails.MANIFEST_LOAD_ERROR,a=!0;break;case"level":r=f.ErrorDetails.LEVEL_LOAD_ERROR,a=!1;break;case"audioTrack":r=f.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,a=!1}n&&(n.abort(),this.loaders[t.type]=void 0),this.hls.trigger(u.default.ERROR,{type:f.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=f.ErrorDetails.MANIFEST_LOAD_TIMEOUT,a=!0;break;case"level":r=f.ErrorDetails.LEVEL_LOAD_TIMEOUT,a=!1;break;case"audioTrack":r=f.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT,a=!1}n&&(n.abort(),this.loaders[t.type]=void 0),this.hls.trigger(u.default.ERROR,{type:f.ErrorTypes.NETWORK_ERROR,details:r,fatal:a,url:n.url,loader:n,context:t,networkDetails:i})}}]),t}(d.default);r.default=b},{2:2,33:33,34:34,35:35,47:47,54:54}],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>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>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)),s=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,s)}},{key:"sdtp",value:function(t){var r,a,i=t.samples||[],n=new Uint8Array(4+i.length);for(a=0;a>>8&255),n.push(255&i),n=n.concat(Array.prototype.slice.call(a));for(r=0;r>>8&255),s.push(255&i),s=s.concat(Array.prototype.slice.call(a));var o=e.box(e.types.avcC,new Uint8Array([1,n[3],n[4],n[5],255,224|t.sps.length].concat(n).concat([t.pps.length]).concat(s))),l=t.width,u=t.height,d=t.pixelRatio[0],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]),o,e.box(e.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),e.box(e.types.pasp,new Uint8Array([d>>24,d>>16&255,d>>8&255,255&d,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,s=t.height,o=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,o>>24,o>>16&255,o>>8&255,255&o,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,s>>8&255,255&s,0,0]))}},{key:"traf",value:function(t,r){var a=e.sdtp(t),i=t.id,s=Math.floor(r/(n+1)),o=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,s>>24,s>>16&255,s>>8&255,255&s,o>>24,o>>16&255,o>>8&255,255&o])),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,s,o,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>>24&255,n>>>16&255,n>>>8&255,255&n,s>>>24&255,s>>>16&255,s>>>8&255,255&s,o.isLeading<<2|o.dependsOn,o.isDependedOn<<6|o.hasRedundancy<<4|o.paddingValue<<1|o.isNonSync,61440&o.degradPrio,15&o.degradPrio,l>>>24&255,l>>>16&255,l>>>8&255,255&l],12+16*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)).set(e.FTYP),r.set(a,e.FTYP.byteLength),r}}]),e}();r.default=s},{}],45:[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-1&&s&&!s.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,s){if(this.ISGenerated){if(s){var u=this._initPTS,d=this._PTSNormalize,f=e.inputTimeScale||t.inputTimeScale,c=1/0,h=1/0,g=e.samples;if(g.length&&(c=h=d(g[0].pts-f*i,u)),(g=t.samples).length){var v=g[0];c=Math.min(c,d(v.pts-f*i,u)),h=Math.min(h,d(v.dts-f*i,u))}if(c!==1/0){var p=u-c;Math.abs(p)>10*f&&(l.logger.warn("timestamp inconsistency, "+(p/f).toFixed(3)+"s delta against expected value: missing discontinuity ? reset initPTS/initDTS"),this._initPTS=c,this._initDTS=h,this.observer.trigger(o.default.INIT_PTS_FOUND,{initPTS:c}))}}}else this.generateIS(e,t,i);if(this.ISGenerated)if(e.samples.length){e.timescale||(l.logger.warn("regenerate InitSegment as audio detected"),this.generateIS(e,t,i));var y=this.remuxAudio(e,i,n,s);if(t.samples.length){var m=void 0;y&&(m=y.endPTS-y.startPTS),t.timescale||(l.logger.warn("regenerate InitSegment as video detected"),this.generateIS(e,t,i)),this.remuxVideo(t,i,n,m,s)}}else{var E=void 0;t.samples.length&&(E=this.remuxVideo(t,i,n,s)),E&&e.codec&&this.remuxEmptyAudio(e,i,n,E)}r.samples.length&&this.remuxID3(r,i),a.samples.length&&this.remuxText(a,i),this.observer.trigger(o.default.FRAG_PARSED)}},{key:"generateIS",value:function(e,t,r){var a,i,n=this.observer,s=e.samples,f=t.samples,c=this.typeSupported,h="audio/mp4",g={},v={tracks:g},p=void 0===this._initPTS;if(p&&(a=i=1/0),e.config&&s.length&&(e.timescale=e.samplerate,l.logger.log("audio sampling rate : "+e.samplerate),e.isAAC||(c.mpeg?(h="audio/mpeg",e.codec=""):c.mp3&&(e.codec="mp3")),g.audio={container:h,codec:e.codec,initSegment:!e.isAAC&&c.mpeg?new Uint8Array:u.default.initSegment([e]),metadata:{channelCount:e.channelCount}},p&&(a=i=s[0].pts-e.inputTimeScale*r)),t.sps&&t.pps&&f.length){var y=t.inputTimeScale;t.timescale=y,g.video={container:"video/mp4",codec:t.codec,initSegment:u.default.initSegment([t]),metadata:{width:t.width,height:t.height}},p&&(a=Math.min(a,f[0].pts-y*r),i=Math.min(i,f[0].dts-y*r),this.observer.trigger(o.default.INIT_PTS_FOUND,{initPTS:a}))}Object.keys(g).length?(n.trigger(o.default.FRAG_PARSING_INIT_SEGMENT,v),this.ISGenerated=!0,p&&(this._initPTS=a,this._initDTS=i)):n.trigger(o.default.ERROR,{type:d.ErrorTypes.MEDIA_ERROR,details:d.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"no audio/video samples found"})}},{key:"remuxVideo",value:function(e,t,r,a,i){var n,s,f,c,h,g,v,p=8,y=e.timescale,m=e.samples,E=[],b=m.length,T=this._PTSNormalize,k=this._initDTS,_=this.nextAvcDts,R=this.isSafari;R&&(r|=m.length&&_&&(i&&Math.abs(t-_/y)<.1||Math.abs(m[0].pts-_-k)1?l.logger.log("AVC:"+w+" ms hole between fragments detected,filling it"):w<-1&&l.logger.log("AVC:"+-w+" ms overlapping between fragments detected"),h=_,m[0].dts=h,c=Math.max(c-w,_),m[0].pts=c,l.logger.log("Video/PTS/DTS adjusted: "+Math.round(c/90)+"/"+Math.round(h/90)+",delta:"+w+" ms")),L=m[m.length-1],v=Math.max(L.dts,0),g=Math.max(L.pts,0,v),R&&(n=Math.round((v-h)/(m.length-1)));for(var D=0,O=0,I=0;I0?B-1:B].dts;if(q.stretchShortVideoTrack){var J=q.maxBufferHole,Z=q.maxSeekHole,$=Math.floor(Math.min(J,Z)*y),ee=(a?c+a*y:this.nextAudioPts)-G.pts;ee>$?((n=ee-Q)<0&&(n=Q),l.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}W=Math.round(G.pts-G.dts)}E.push({size:H,duration:n,cts:W,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:G.key?2:1,isNonSync:G.key?0:1}})}this.nextAvcDts=v+n;var te=e.dropped;if(e.len=0,e.nbNalu=0,e.dropped=0,E.length&&navigator.userAgent.toLowerCase().indexOf("chrome")>-1){var re=E[0].flags;re.dependsOn=2,re.isNonSync=0}e.samples=E,f=u.default.moof(e.sequenceNumber++,h,e),e.samples=[];var ae={data1:f,data2:s,startPTS:c/y,endPTS:(g+n)/y,startDTS:h/y,endDTS:this.nextAvcDts/y,type:"video",nb:E.length,dropped:te};return this.observer.trigger(o.default.FRAG_PARSING_DATA,ae),ae}},{key:"remuxAudio",value:function(e,t,r,a){var i,n,f,c,h,g,v,p=e.inputTimeScale,y=p/e.timescale,m=(e.isAAC?1024:1152)*y,E=this._PTSNormalize,b=this._initDTS,T=!e.isAAC&&this.typeSupported.mpeg,k=e.samples,_=[],R=this.nextAudioPts;if((r|=k.length&&R&&(a&&Math.abs(t-R/p)<.1||Math.abs(k[0].pts-R-b)<20*m))||(R=t*p),k.forEach(function(e){e.pts=e.dts=E(e.pts-b,R)}),k.sort(function(e,t){return e.pts-t.pts}),a&&e.isAAC)for(var S=0,A=R;S=m&&D<1e4&&A){var O=Math.round(L/m);l.logger.warn("Injecting "+O+" audio frame @ "+(A/p).toFixed(3)+"s due to "+Math.round(1e3*L/p)+" ms gap.");for(var I=0;I0&&U<1e4)B=Math.round((N-R)/m),l.logger.log(U+" ms hole between AAC samples detected,filling it"),B>0&&((f=s.default.getSilentFrame(e.manifestCodec||e.codec,e.channelCount))||(f=M.subarray()),e.len+=B*f.length);else if(U<-12){l.logger.log("drop overlapping AAC sample, expected/parsed/delta:"+(R/p).toFixed(3)+"s/"+(N/p).toFixed(3)+"s/"+-U+"ms"),e.len-=M.byteLength;continue}N=R}if(g=Math.max(0,N),!(e.len>0))return;var G=T?e.len:e.len+8;i=T?0:8;try{c=new Uint8Array(G)}catch(e){return void this.observer.trigger(o.default.ERROR,{type:d.ErrorTypes.MUX_ERROR,details:d.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:G,reason:"fail allocating audio mdat "+G})}T||(new DataView(c.buffer).setUint32(0,G),c.set(u.default.types.mdat,4));for(var j=0;j=2&&(W=_[K-2].duration,n.duration=W),K){this.nextAudioPts=R=v+y*W,e.len=0,e.samples=_,h=T?new Uint8Array:u.default.moof(e.sequenceNumber++,g/y,e),e.samples=[];var V=g/p,Y=R/p,z={data1:h,data2:c,startPTS:V,endPTS:Y,startDTS:V,endDTS:Y,type:"audio",nb:K};return this.observer.trigger(o.default.FRAG_PARSING_DATA,z),z}return null}},{key:"remuxEmptyAudio",value:function(e,t,r,a){var i=e.inputTimeScale,n=i/(e.samplerate?e.samplerate:i),o=this.nextAudioPts,u=(void 0!==o?o:a.startDTS*i)+this._initDTS,d=a.endDTS*i+this._initDTS,f=1024*n,c=Math.ceil((d-u)/f),h=s.default.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(l.logger.warn("remux empty Audio"),h){for(var g=[],v=0;v4294967296;)e+=r;return e}}]),e}();r.default=f},{33:33,35:35,36:36,44:44,54:54}],46:[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;rNumber.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;aNumber.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(s.lastIndex=0;null!==(t=s.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=o},{}],48:[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;){var s=t(n=e[i=(r+a)/2|0]);if(s>0)r=i+1;else{if(!(s<0))return n;a=i-1}}return null}};t.exports=a},{}],49:[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;rl&&(g.log("ERROR","Too large cursor position "+this.pos),this.pos=l)}},{key:"moveCursor",value:function(e){var t=this.pos+e;if(e>1)for(var r=this.pos+1;r=144&&this.backSpace();var t=s(e);this.pos>=l?g.log("ERROR","Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!"):(this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1))}},{key:"clearFromPos",value:function(e){var t;for(t=e;t0&&(r=e?"["+t.join(" | ")+"]":t.join("\n")),r}},{key:"getTextAndFormat",value:function(){return this.rows}}]),e}(),b=function(){function e(t,r){a(this,e),this.chNr=t,this.outputFilter=r,this.mode=null,this.verbose=0,this.displayedMemory=new E,this.nonDisplayedMemory=new E,this.lastOutputScreen=new E,this.currRollUpRow=this.displayedMemory.rows[o-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}return i(e,[{key:"reset",value:function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.currRollUpRow=this.displayedMemory.rows[o-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.lastCueEndTime=null}},{key:"getHandler",value:function(){return this.outputFilter}},{key:"setHandler",value:function(e){this.outputFilter=e}},{key:"setPAC",value:function(e){this.writeScreen.setPAC(e)}},{key:"setBkgData",value:function(e){this.writeScreen.setBkgData(e)}},{key:"setMode",value:function(e){e!==this.mode&&(this.mode=e,g.log("INFO","MODE="+e),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)}},{key:"insertChars",value:function(e){for(var t=0;t=46,t.italics)t.foreground="white";else{var r=Math.floor(e/2)-16,a=["white","green","blue","cyan","red","yellow","magenta"];t.foreground=a[r]}g.log("INFO","MIDROW: "+JSON.stringify(t)),this.writeScreen.setPen(t)}},{key:"outputDataUpdate",value:function(){var e=g.time;null!==e&&this.outputFilter&&(this.outputFilter.updateData&&this.outputFilter.updateData(e,this.displayedMemory),null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.lastOutputScreen),this.cueStartTime=this.displayedMemory.isEmpty()?null:e):this.cueStartTime=e,this.lastOutputScreen.copy(this.displayedMemory))}},{key:"cueSplitAtTime",value:function(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))}}]),e}(),T=function(){function e(t,r,i){a(this,e),this.field=t||1,this.outputs=[r,i],this.channels=[new b(1,r),new b(2,i)],this.currChNr=-1,this.lastCmdA=null,this.lastCmdB=null,this.bufferedData=[],this.startTime=null,this.lastTime=null,this.dataCounters={padding:0,char:0,cmd:0,other:0}}return i(e,[{key:"getHandler",value:function(e){return this.channels[e].getHandler()}},{key:"setHandler",value:function(e,t){this.channels[e].setHandler(t)}},{key:"addData",value:function(e,t){var r,a,i,n=!1;this.lastTime=e,g.setTime(e);for(var s=0;s ("+v([a,i])+")"),(r=this.parseCmd(a,i))||(r=this.parseMidrow(a,i)),r||(r=this.parsePAC(a,i)),r||(r=this.parseBackgroundAttributes(a,i)),r||(n=this.parseChars(a,i))&&(this.currChNr&&this.currChNr>=0?this.channels[this.currChNr-1].insertChars(n):g.log("WARNING","No channel found yet. TEXT-MODE?")),r?this.dataCounters.cmd+=2:n?this.dataCounters.char+=2:(this.dataCounters.other+=2,g.log("WARNING","Couldn't parse cleaned data "+v([a,i])+" orig: "+v([t[s],t[s+1]])))):this.dataCounters.padding+=2}},{key:"parseCmd",value:function(e,t){var r=null,a=(20===e||28===e)&&32<=t&&t<=47,i=(23===e||31===e)&&33<=t&&t<=35;if(!a&&!i)return!1;if(e===this.lastCmdA&&t===this.lastCmdB)return this.lastCmdA=null,this.lastCmdB=null,g.log("DEBUG","Repeated command ("+v([e,t])+") is dropped"),!0;r=20===e||23===e?1:2;var n=this.channels[r-1];return 20===e||28===e?32===t?n.ccRCL():33===t?n.ccBS():34===t?n.ccAOF():35===t?n.ccAON():36===t?n.ccDER():37===t?n.ccRU(2):38===t?n.ccRU(3):39===t?n.ccRU(4):40===t?n.ccFON():41===t?n.ccRDC():42===t?n.ccTR():43===t?n.ccRTD():44===t?n.ccEDM():45===t?n.ccCR():46===t?n.ccENM():47===t&&n.ccEOC():n.ccTO(t-32),this.lastCmdA=e,this.lastCmdB=t,this.currChNr=r,!0}},{key:"parseMidrow",value:function(e,t){var r=null;return(17===e||25===e)&&32<=t&&t<=47&&((r=17===e?1:2)!==this.currChNr?(g.log("ERROR","Mismatch channel in midrow parsing"),!1):(this.channels[r-1].ccMIDROW(t),g.log("DEBUG","MIDROW ("+v([e,t])+")"),!0))}},{key:"parsePAC",value:function(e,t){var r=null,a=null,i=(17<=e&&e<=23||25<=e&&e<=31)&&64<=t&&t<=127,n=(16===e||24===e)&&64<=t&&t<=95;if(!i&&!n)return!1;if(e===this.lastCmdA&&t===this.lastCmdB)return this.lastCmdA=null,this.lastCmdB=null,!0;r=e<=23?1:2,a=64<=t&&t<=95?1===r?u[e]:f[e]:1===r?d[e]:c[e];var s=this.interpretPAC(a,t);return this.channels[r-1].setPAC(s),this.lastCmdA=e,this.lastCmdB=t,this.currChNr=r,!0}},{key:"interpretPAC",value:function(e,t){var r=t,a={color:null,italics:!1,indent:null,underline:!1,row:e};return r=t>95?t-96:t-64,a.underline=1==(1&r),r<=13?a.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(a.italics=!0,a.color="white"):a.indent=4*Math.floor((r-16)/2),a}},{key:"parseChars",value:function(e,t){var r=null,a=null,i=null;if(e>=25?(r=2,i=e-8):(r=1,i=e),17<=i&&i<=19){var n=t;n=17===i?t+80:18===i?t+112:t+144,g.log("INFO","Special char '"+s(n)+"' in channel "+r),a=[n]}else 32<=e&&e<=127&&(a=0===t?[e]:[e,t]);if(a){var o=v(a);g.log("DEBUG","Char codes = "+o.join(",")),this.lastCmdA=null,this.lastCmdB=null}return a}},{key:"parseBackgroundAttributes",value:function(e,t){var r,a,i,n=(16===e||24===e)&&32<=t&&t<=47,s=(23===e||31===e)&&45<=t&&t<=47;return!(!n&&!s)&&(r={},16===e||24===e?(a=Math.floor((t-32)/2),r.background=h[a],t%2==1&&(r.background=r.background+"_semi")):45===t?r.background="transparent":(r.foreground="black",47===t&&(r.underline=!0)),i=e<24?1:2,this.channels[i-1].setBkgData(r),this.lastCmdA=null,this.lastCmdB=null,!0)}},{key:"reset",value:function(){for(var e=0;e=16?l--:l++,navigator.userAgent.match(/Firefox\//)?s.line=f+1:s.line=f>7?f-2:f+1,s.align="left",s.position=Math.max(0,Math.min(100,l/32*100+(navigator.userAgent.match(/Firefox\//)?50:0))),e.addCue(s)}}};t.exports=i},{57:57}],51:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.findFragWithCC=function(e,t){return a.default.search(e,function(e){return e.cct?-1:0})};var a=function(e){return e&&e.__esModule?e:{default:e}}(e(48))},{48:48}],52:[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=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},{53:53}],53:[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}function n(e){var t=self.console[e];return t?function(){for(var r=arguments.length,a=Array(r),n=0;n1?t-1:0),a=1;a100)throw new Error("Position must be between 0 and 100.");b=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"positionAlign",r({},u,{get:function(){return T},set:function(e){var r=t(e);if(!r)throw new SyntaxError("An invalid or illegal string was specified.");T=r,this.hasBeenReset=!0}})),Object.defineProperty(o,"size",r({},u,{get:function(){return k},set:function(e){if(e<0||e>100)throw new Error("Size must be between 0 and 100.");k=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"align",r({},u,{get:function(){return _},set:function(e){var r=t(e);if(!r)throw new SyntaxError("An invalid or illegal string was specified.");_=r,this.hasBeenReset=!0}})),o.displayState=void 0,l)return o}if("undefined"!=typeof window&&window.VTTCue)return window.VTTCue;var i="auto",n={"":!0,lr:!0,rl:!0},s={start:!0,middle:!0,end:!0,left:!0,right:!0};return a.prototype.getCueAsHTML=function(){return window.WebVTT.convertCueToDOMTree(window,this.text)},a}()},{}],57:[function(e,t,r){"use strict";function a(){this.window=window,this.state="INITIAL",this.buffer="",this.decoder=new d,this.regionList=[]}function i(e){function t(e,t,r,a){return 3600*(0|e)+60*(0|t)+(0|r)+(0|a)/1e3}var r=e.match(/^(\d+):(\d{2})(:\d{2})?\.(\d{3})/);return r?r[3]?t(r[1],r[2],r[3].replace(":",""),r[4]):r[1]>59?t(r[1],r[2],0,r[4]):t(0,r[1],r[2],r[4]):null}function n(){this.values=Object.create(null)}function s(e,t,r,a){var i=a?e.split(a):[e];for(var n in i)if("string"==typeof i[n]){var s=i[n].split(r);2===s.length&&t(s[0],s[1])}}function o(e,t,r){function a(){var t=i(e);if(null===t)throw new Error("Malformed timestamp: "+l);return e=e.replace(/^[^\sa-zA-Z-]+/,""),t}function o(){e=e.replace(/^\s+/,"")}var l=e;if(o(),t.startTime=a(),o(),"--\x3e"!==e.substr(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+l);e=e.substr(3),o(),t.endTime=a(),o(),function(e,t){var a=new n;s(e,function(e,t){switch(e){case"region":for(var i=r.length-1;i>=0;i--)if(r[i].id===t){a.set(e,r[i].region);break}break;case"vertical":a.alt(e,t,["rl","lr"]);break;case"line":var n=t.split(","),s=n[0];a.integer(e,s),a.percent(e,s)&&a.set("snapToLines",!1),a.alt(e,s,["auto"]),2===n.length&&a.alt("lineAlign",n[1],["start",c,"end"]);break;case"position":n=t.split(","),a.percent(e,n[0]),2===n.length&&a.alt("positionAlign",n[1],["start",c,"end","line-left","line-right","auto"]);break;case"size":a.percent(e,t);break;case"align":a.alt(e,t,["start",c,"end","left","right"])}},/:/,/\s/),t.region=a.get("region",null),t.vertical=a.get("vertical","");var i=a.get("line","auto");"auto"===i&&-1===f.line&&(i=-1),t.line=i,t.lineAlign=a.get("lineAlign","start"),t.snapToLines=a.get("snapToLines",!0),t.size=a.get("size",100),t.align=a.get("align",c);var o=a.get("position","auto");"auto"===o&&50===f.position&&(o="start"===t.align||"left"===t.align?0:"end"===t.align||"right"===t.align?100:50),t.position=o}(e,t)}function l(e){return e.replace(//gi,"\n")}Object.defineProperty(r,"__esModule",{value:!0}),r.fixLineBreaks=void 0;var u=function(e){return e&&e.__esModule?e:{default:e}}(e(56)),d=function(){return{decode:function(e){if(!e)return"";if("string"!=typeof e)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}};n.prototype={set:function(e,t){this.get(e)||""===t||(this.values[e]=t)},get:function(e,t,r){return r?this.has(e)?this.values[e]:t[r]:this.has(e)?this.values[e]:t},has:function(e){return e in this.values},alt:function(e,t,r){for(var a=0;a=0&&t<=100)&&(this.set(e,t),!0)}};var f=new u.default(0,0,0),c="middle"===f.align?"middle":"center";a.prototype={parse:function(e){function t(){var e=r.buffer,t=0;for(e=l(e);t9?parseInt(e.substr(0,e.indexOf(":"))):0;return isNaN(t)||isNaN(r)||isNaN(a)||isNaN(i)?-1:(t+=1e3*r,t+=6e4*a,t+=36e5*i)},s=function(e){for(var t=5381,r=e.length;r;)t=33*t^e.charCodeAt(--r);return(t>>>0).toString()},o=function(e,t,r){var a=e[t],i=e[a.prevCC];if(!i||!i.new&&a.new)return e.ccOffset=e.presentationOffset=a.start,void(a.new=!1);for(;i&&i.new;)e.ccOffset+=a.start-i.start,a.new=!1,i=e[(a=i).prevCC];e.presentationOffset=r},l={parse:function(e,t,r,l,u,d){var f=/\r\n|\n\r|\n|\r/g,c=String.fromCharCode.apply(null,new Uint8Array(e)).trim().replace(f,"\n").split("\n"),h="00:00.000",g=0,v=0,p=0,y=[],m=void 0,E=!0,b=new a.default;b.oncue=function(e){var t=r[l],a=r.ccOffset;t&&t.new&&(void 0!==v?a=r.ccOffset=t.start:o(r,l,p)),p&&(a=p+r.ccOffset-r.presentationOffset),e.startTime+=a-v,e.endTime+=a-v,e.id=s(e.startTime)+s(e.endTime)+s(e.text),e.text=decodeURIComponent(escape(e.text)),e.endTime>0&&y.push(e)},b.onparsingerror=function(e){m=e},b.onflush=function(){m&&d?d(m):u(y)},c.forEach(function(e){if(E){if(i(e,"X-TIMESTAMP-MAP=")){E=!1,e.substr(16).split(",").forEach(function(e){i(e,"LOCAL:")?h=e.substr(6):i(e,"MPEGTS:")&&(g=parseInt(e.substr(7)))});try{g-=t=t<0?t+8589934592:t,v=n(h)/1e3,p=g/9e4,-1===v&&(m=new Error("Malformed X-TIMESTAMP-MAP: "+e))}catch(t){m=new Error("Malformed X-TIMESTAMP-MAP: "+e)}return}""===e&&(E=!1)}b.parse(e+"\n")}),b.flush()}};t.exports=l},{57:57}],59:[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=2)if(window.clearTimeout(this.requestTimeout),0===a.tfirst&&(a.tfirst=Math.max(performance.now(),a.trequest)),4===r){var o=t.status;if(o>=200&&o<300){a.tload=Math.max(a.tfirst,performance.now());var l=void 0,u=void 0;u="arraybuffer"===i.responseType?(l=t.response).byteLength:(l=t.responseText).length,a.loaded=a.total=u;var d={url:t.responseURL,data:l};this.callbacks.onSuccess(d,a,i,t)}else a.retry>=s.maxRetry||o>=400&&o<499?(n.logger.error(o+" while loading "+i.url),this.callbacks.onError({code:o,text:t.statusText},i,t)):(n.logger.warn(o+" 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,s.maxRetryDelay),a.retry++)}else this.requestTimeout=window.setTimeout(this.loadtimeout.bind(this),s.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=s},{54:54}]},{},[40])(40)}); +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Hls=e():t.Hls=e()}(this,function(){return function(t){function e(i){if(r[i])return r[i].exports;var a=r[i]={i:i,l:!1,exports:{}};return t[i].call(a.exports,a,a.exports,e),a.l=!0,a.exports}var r={};return e.m=t,e.c=r,e.d=function(t,r,i){e.o(t,r)||Object.defineProperty(t,r,{configurable:!1,enumerable:!0,get:i})},e.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="../dist/",e(e.s=7)}([function(t,e,r){"use strict";function i(){}function a(t,e){return e="["+t+"] > "+e}function n(t){var e=self.console[t];return e?function(){for(var r=arguments.length,i=Array(r),n=0;n1?e-1:0),i=1;i0)return e.subarray(i,i+a)},t._readSize=function(t,e){var r=0;return r=(127&t[e])<<21,r|=(127&t[e+1])<<14,r|=(127&t[e+2])<<7,r|=127&t[e+3]},t.getTimeStamp=function(e){for(var r=t.getID3Frames(e),i=0;i>4){case 0:return i;case 1:case 2:case 3:case 4:case 5:case 6:case 7:i+=String.fromCharCode(o);break;case 12:case 13:e=t[a++],i+=String.fromCharCode((31&o)<<6|63&e);break;case 14:e=t[a++],r=t[a++],i+=String.fromCharCode((15&o)<<12|(63&e)<<6|(63&r)<<0)}}return i},t}();e.a=a},function(t,e){function r(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function i(t){return"function"==typeof t}function a(t){return"number"==typeof t}function n(t){return"object"==typeof t&&null!==t}function o(t){return void 0===t}t.exports=r,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._maxListeners=void 0,r.defaultMaxListeners=10,r.prototype.setMaxListeners=function(t){if(!a(t)||t<0||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},r.prototype.emit=function(t){var e,r,a,s,l,u;if(this._events||(this._events={}),"error"===t&&(!this._events.error||n(this._events.error)&&!this._events.error.length)){if((e=arguments[1])instanceof Error)throw e;var d=new Error('Uncaught, unspecified "error" event. ('+e+")");throw d.context=e,d}if(r=this._events[t],o(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:s=Array.prototype.slice.call(arguments,1),r.apply(this,s)}else if(n(r))for(s=Array.prototype.slice.call(arguments,1),u=r.slice(),a=u.length,l=0;l0&&this._events[t].length>a&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace()),this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(t,e){function r(){this.removeListener(t,r),a||(a=!0,e.apply(this,arguments))}if(!i(e))throw TypeError("listener must be a function");var a=!1;return r.listener=e,this.on(t,r),this},r.prototype.removeListener=function(t,e){var r,a,o,s;if(!i(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(r=this._events[t],o=r.length,a=-1,r===e||i(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(n(r)){for(s=o;s-- >0;)if(r[s]===e||r[s].listener&&r[s].listener===e){a=s;break}if(a<0)return this;1===r.length?(r.length=0,delete this._events[t]):r.splice(a,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},r.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[t],i(r))this.removeListener(t,r);else if(r)for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},r.prototype.listeners=function(t){return this._events&&this._events[t]?i(this._events[t])?[this._events[t]]:this._events[t].slice():[]},r.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(i(e))return 1;if(e)return e.length}return 0},r.listenerCount=function(t,e){return t.listenerCount(e)}},function(t,e,r){!function(e){var r=/^((?:[^\/;?#]+:)?)(\/\/[^\/\;?#]*)?(.*?)??(;.*?)?(\?.*?)?(#.*?)?$/,i=/^([^\/;?#]*)(.*)$/,a=/(?:\/|^)\.(?=\/)/g,n=/(?:\/|^)\.\.\/(?!\.\.\/).*?(?=\/)/g,o={buildAbsoluteURL:function(t,e,r){if(r=r||{},t=t.trim(),!(e=e.trim())){if(!r.alwaysNormalize)return t;var a=this.parseURL(t);if(!s)throw new Error("Error trying to parse base URL.");return a.path=o.normalizePath(a.path),o.buildURLFromParts(a)}var n=this.parseURL(e);if(!n)throw new Error("Error trying to parse relative URL.");if(n.scheme)return r.alwaysNormalize?(n.path=o.normalizePath(n.path),o.buildURLFromParts(n)):e;var s=this.parseURL(t);if(!s)throw new Error("Error trying to parse base URL.");if(!s.netLoc&&s.path&&"/"!==s.path[0]){var l=i.exec(s.path);s.netLoc=l[1],s.path=l[2]}s.netLoc&&!s.path&&(s.path="/");var u={scheme:s.scheme,netLoc:n.netLoc,path:null,params:n.params,query:n.query,fragment:n.fragment};if(!n.netLoc&&(u.netLoc=s.netLoc,"/"!==n.path[0]))if(n.path){var d=s.path,h=d.substring(0,d.lastIndexOf("/")+1)+n.path;u.path=o.normalizePath(h)}else u.path=s.path,n.params||(u.params=s.params,n.query||(u.query=s.query));return null===u.path&&(u.path=r.alwaysNormalize?o.normalizePath(n.path):n.path),o.buildURLFromParts(u)},parseURL:function(t){var e=r.exec(t);return e?{scheme:e[1]||"",netLoc:e[2]||"",path:e[3]||"",params:e[4]||"",query:e[5]||"",fragment:e[6]||""}:null},normalizePath:function(t){for(t=t.split("").reverse().join("").replace(a,"");t.length!==(t=t.replace(n,"")).length;);return t.split("").reverse().join("")},buildURLFromParts:function(t){return t.scheme+t.netLoc+t.path+t.params+t.query+t.fragment}};t.exports=o}()},function(t,e,r){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e,r,i){var a,n,o,s,l,u=navigator.userAgent.toLowerCase(),d=i,h=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];return a=1+((192&e[r+2])>>>6),(n=(60&e[r+2])>>>2)>h.length-1?void t.trigger(Event.ERROR,{type:I.b.MEDIA_ERROR,details:I.a.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+n}):(s=(1&e[r+2])<<2,s|=(192&e[r+3])>>>6,N.b.log("manifest codec:"+i+",ADTS data:type:"+a+",sampleingIndex:"+n+"["+h[n]+"Hz],channelConfig:"+s),/firefox/i.test(u)?n>=6?(a=5,l=new Array(4),o=n-3):(a=2,l=new Array(2),o=n):-1!==u.indexOf("android")?(a=2,l=new Array(2),o=n):(a=5,l=new Array(4),i&&(-1!==i.indexOf("mp4a.40.29")||-1!==i.indexOf("mp4a.40.5"))||!i&&n>=6?o=n-3:((i&&-1!==i.indexOf("mp4a.40.2")&&(n>=6&&1===s||/vivaldi/i.test(u))||!i&&1===s)&&(a=2,l=new Array(2)),o=n)),l[0]=a<<3,l[0]|=(14&n)>>1,l[1]|=(1&n)<<7,l[1]|=s<<3,5===a&&(l[1]|=(14&o)>>1,l[2]=(1&o)<<7,l[2]|=8,l[3]=0),{config:l,samplerate:h[n],channelCount:s,codec:"mp4a.40."+a,manifestCodec:d})}function l(t,e){return 255===t[e]&&240==(246&t[e+1])}function u(t,e){return 1&t[e+1]?7:9}function d(t,e){return(3&t[e+3])<<11|t[e+4]<<3|(224&t[e+5])>>>5}function h(t,e){return!!(e+10&&e+n+o<=l)return s=r+i*a,{headerLength:n,frameLength:o,stamp:s}}function v(t,e,r,i,a){var n=p(t.samplerate),o=g(e,r,i,a,n);if(o){var s=o.stamp,l=o.headerLength,u=o.frameLength,d={unit:e.subarray(r+l,r+l+u),pts:s,dts:s};return t.samples.push(d),t.len+=u,{sample:d,length:u+l}}}function m(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function y(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function b(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function E(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function T(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function R(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function S(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function A(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function L(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function w(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var D=r(1),I=r(2),k=function(){function t(e,r){i(this,t),this.subtle=e,this.aesIV=r}return t.prototype.decrypt=function(t,e){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},e,t)},t}(),O=k,C=function(){function t(e,r){a(this,t),this.subtle=e,this.key=r}return t.prototype.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},t}(),P=C,x=function(){function t(){n(this,t),this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.initTable()}return t.prototype.uint8ArrayToUint32Array_=function(t){for(var e=new DataView(t),r=new Uint32Array(4),i=0;i<4;i++)r[i]=e.getUint32(4*i);return r},t.prototype.initTable=function(){var t=this.sBox,e=this.invSBox,r=this.subMix,i=r[0],a=r[1],n=r[2],o=r[3],s=this.invSubMix,l=s[0],u=s[1],d=s[2],h=s[3],c=new Uint32Array(256),f=0,p=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 v=p^p<<1^p<<2^p<<3^p<<4;v=v>>>8^255&v^99,t[f]=v,e[v]=f;var m=c[f],y=c[m],b=c[y],E=257*c[v]^16843008*v;i[f]=E<<24|E>>>8,a[f]=E<<16|E>>>16,n[f]=E<<8|E>>>24,o[f]=E,E=16843009*b^65537*y^257*m^16843008*f,l[v]=E<<24|E>>>8,u[v]=E<<16|E>>>16,d[v]=E<<8|E>>>24,h[v]=E,f?(f=m^c[c[c[b^m]]],p^=c[c[p]]):f=p=1}},t.prototype.expandKey=function(t){for(var e=this.uint8ArrayToUint32Array_(t),r=!0,i=0;i=8){return["moof","ftyp","styp"].indexOf(t.bin2str(e.subarray(4,8)))>=0}return!1},t.bin2str=function(t){return String.fromCharCode.apply(null,t)},t.readUint32=function(t,e){t.data&&(e+=t.start,t=t.data);var r=t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3];return r<0?4294967296+r:r},t.writeUint32=function(t,e,r){t.data&&(e+=t.start,t=t.data),t[e]=r>>24,t[e+1]=r>>16&255,t[e+2]=r>>8&255,t[e+3]=255&r},t.findBox=function(e,r){var i,a,n,o,s,l,u,d=[];if(e.data?(l=e.start,o=e.end,e=e.data):(l=0,o=e.byteLength),!r.length)return null;for(i=l;i1?i+a:o,n===r[0]&&(1===r.length?d.push({data:e,start:i+8,end:u}):(s=t.findBox({data:e,start:i+8,end:u},r.slice(1)),s.length&&(d=d.concat(s)))),i=u;return d},t.parseInitSegment=function(e){var r=[];return t.findBox(e,["moov","trak"]).forEach(function(e){var i=t.findBox(e,["tkhd"])[0];if(i){var a=i.data[i.start],n=0===a?12:20,o=t.readUint32(i,n),s=t.findBox(e,["mdia","mdhd"])[0];if(s){a=s.data[s.start],n=0===a?12:20;var l=t.readUint32(s,n),u=t.findBox(e,["mdia","hdlr"])[0];if(u){var d=t.bin2str(u.data.subarray(u.start+8,u.start+12)),h={soun:"audio",vide:"video"}[d];h&&(r[o]={timescale:l,type:h},r[h]={timescale:l,id:o})}}}}),r},t.getStartDTS=function(e,r){var i,a,n;return i=t.findBox(r,["moof","traf"]),a=[].concat.apply([],i.map(function(r){return t.findBox(r,["tfhd"]).map(function(i){var a,n;return a=t.readUint32(i,4),n=e[a].timescale||9e4,t.findBox(r,["tfdt"]).map(function(e){var r,i;return r=e.data[e.start],i=t.readUint32(e,4),1===r&&(i*=Math.pow(2,32),i+=t.readUint32(e,8)),i})[0]/n})})),n=Math.min.apply(null,a),isFinite(n)?n:0},t.offsetStartDTS=function(e,r,i){t.findBox(r,["moof","traf"]).map(function(r){return t.findBox(r,["tfhd"]).map(function(a){var n=t.readUint32(a,4),o=e[n].timescale||9e4;t.findBox(r,["tfdt"]).map(function(e){var r=e.data[e.start],a=t.readUint32(e,4);if(0===r)t.writeUint32(e,4,a-i*o);else{a*=Math.pow(2,32),a+=t.readUint32(e,8),a-=i*o;var n=Math.floor(a/(j+1)),s=Math.floor(a%(j+1));t.writeUint32(e,4,n),t.writeUint32(e,8,s)}})})})},t.prototype.append=function(e,r,i,a){var n=this.initData;n||(this.resetInitSegment(e,this.audioCodec,this.videoCodec),n=this.initData);var o=void 0,s=this.initPTS;if(void 0===s){var l=t.getStartDTS(n,e);this.initPTS=s=l-r,this.observer.trigger(D.a.INIT_PTS_FOUND,{initPTS:s})}t.offsetStartDTS(n,e,s),o=t.getStartDTS(n,e),this.remuxer.remux(n.audio,n.video,null,null,o,i,a,e)},t.prototype.destroy=function(){},t}(),W=K,V={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(t,e,r,i,a){if(!(r+24>e.length)){var n=this.parseHeader(e,r);if(n&&r+n.frameLength<=e.length){var o=10368e4/n.sampleRate,s=i+a*o,l={unit:e.subarray(r,r+n.frameLength),pts:s,dts:s};return t.config=[],t.channelCount=n.channelCount,t.samplerate=n.sampleRate,t.samples.push(l),t.len+=n.frameLength,{sample:l,length:n.frameLength}}}},parseHeader:function(t,e){var r=t[e+1]>>3&3,i=t[e+1]>>1&3,a=t[e+2]>>4&15,n=t[e+2]>>2&3,o=!!(2&t[e+2]);if(1!==r&&0!==a&&15!==a&&3!==n){var s=3===r?3-i:3===i?3:4,l=1e3*V.BitratesMap[14*s+a-1],u=3===r?0:2===r?1:2,d=V.SamplingRateMap[3*u+n],h=o?1:0;return{sampleRate:d,channelCount:t[e+3]>>6==3?1:2,frameLength:3===i?(3===r?12:6)*l/d+h<<2:(3===r?144:72)*l/d+h|0}}},isHeaderPattern:function(t,e){return 255===t[e]&&224==(224&t[e+1])&&0!=(6&t[e+1])},isHeader:function(t,e){return!!(e+1t?(this.word<<=t,this.bitsAvailable-=t):(t-=this.bitsAvailable,e=t>>3,t-=e>>3,this.bytesAvailable-=e,this.loadWord(),this.word<<=t,this.bitsAvailable-=t)},t.prototype.readBits=function(t){var e=Math.min(this.bitsAvailable,t),r=this.word>>>32-e;return t>32&&N.b.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=e,this.bitsAvailable>0?this.word<<=e:this.bytesAvailable>0&&this.loadWord(),e=t-e,e>0&&this.bitsAvailable?r<>>t))return this.word<<=t,this.bitsAvailable-=t,t;return this.loadWord(),t+this.skipLZ()},t.prototype.skipUEG=function(){this.skipBits(1+this.skipLZ())},t.prototype.skipEG=function(){this.skipBits(1+this.skipLZ())},t.prototype.readUEG=function(){var t=this.skipLZ();return this.readBits(t+1)-1},t.prototype.readEG=function(){var t=this.readUEG();return 1&t?1+t>>>1:-1*(t>>>1)},t.prototype.readBoolean=function(){return 1===this.readBits(1)},t.prototype.readUByte=function(){return this.readBits(8)},t.prototype.readUShort=function(){return this.readBits(16)},t.prototype.readUInt=function(){return this.readBits(32)},t.prototype.skipScalingList=function(t){var e,r,i=8,a=8;for(e=0;e=t.length)return void r();if(!(t[e].unit.length<32)){var i=this.decrypter.isSync();if(this.decryptAacSample(t,e,r,i),!i)return}}},t.prototype.getAvcEncryptedData=function(t){for(var e=16*Math.floor((t.length-48)/160)+16,r=new Int8Array(e),i=0,a=32;a<=t.length-16;a+=160,i+=16)r.set(t.subarray(a,a+16),i);return r},t.prototype.getAvcDecryptedUnit=function(t,e){e=new Uint8Array(e);for(var r=0,i=32;i<=t.length-16;i+=160,r+=16)t.set(e.subarray(r,r+16),i);return t},t.prototype.decryptAvcSample=function(t,e,r,i,a,n){var o=this.discardEPB(a.data),s=this.getAvcEncryptedData(o),l=this;this.decryptBuffer(s.buffer,function(s){a.data=l.getAvcDecryptedUnit(o,s),n||l.decryptAvcSamples(t,e,r+1,i)})},t.prototype.decryptAvcSamples=function(t,e,r,i){for(;;e++,r=0){if(e>=t.length)return void i();for(var a=t[e].units;!(r>=a.length);r++){var n=a[r];if(!(n.length<=48||1!==n.type&&5!==n.type)){var o=this.decrypter.isSync();if(this.decryptAvcSample(t,e,r,i,n,o),!o)return}}}},t}(),Q=q,J=function(){function t(e,r,i,a){T(this,t),this.observer=e,this.config=i,this.typeSupported=a,this.remuxer=r,this.sampleAes=null}return t.prototype.setDecryptData=function(t){null!=t&&null!=t.key&&"SAMPLE-AES"===t.method?this.sampleAes=new Q(this.observer,this.config,t,this.discardEPB):this.sampleAes=null},t.probe=function(t){return t.length>=564&&71===t[0]&&71===t[188]&&71===t[376]},t.prototype.resetInitSegment=function(t,e,r,i){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:i,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=e,this.videoCodec=r,this._duration=i},t.prototype.resetTimeStamp=function(){},t.prototype.append=function(t,e,r,i){var a,n,o,s,l,u=t.length,d=!1;this.contiguous=r;var h=this.pmtParsed,c=this._avcTrack,f=this._audioTrack,p=this._id3Track,g=c.id,v=f.id,m=p.id,y=this._pmtId,b=c.pesData,E=f.pesData,T=p.pesData,R=this._parsePAT,S=this._parsePMT,A=this._parsePES,_=this._parseAVCPES.bind(this),L=this._parseAACPES.bind(this),w=this._parseMPEGPES.bind(this),k=this._parseID3PES.bind(this);for(u-=u%188,a=0;a>4>1){if((s=a+5+t[a+4])===a+188)continue}else s=a+4;switch(o){case g:n&&(b&&(l=A(b))&&_(l,!1),b={data:[],size:0}),b&&(b.data.push(t.subarray(s,a+188)),b.size+=a+188-s);break;case v:n&&(E&&(l=A(E))&&(f.isAAC?L(l):w(l)),E={data:[],size:0}),E&&(E.data.push(t.subarray(s,a+188)),E.size+=a+188-s);break;case m:n&&(T&&(l=A(T))&&k(l),T={data:[],size:0}),T&&(T.data.push(t.subarray(s,a+188)),T.size+=a+188-s);break;case 0:n&&(s+=t[s]+1),y=this._pmtId=R(t,s);break;case y:n&&(s+=t[s]+1);var O=S(t,s,!0===this.typeSupported.mpeg||!0===this.typeSupported.mp3,null!=this.sampleAes);g=O.avc,g>0&&(c.id=g),v=O.audio,v>0&&(f.id=v,f.isAAC=O.isAAC),m=O.id3,m>0&&(p.id=m),d&&!h&&(N.b.log("reparse from beginning"),d=!1,a=-188),h=this.pmtParsed=!0;break;case 17:case 8191:break;default:d=!0}}else this.observer.trigger(D.a.ERROR,{type:I.b.MEDIA_ERROR,details:I.a.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});b&&(l=A(b))?(_(l,!0),c.pesData=null):c.pesData=b,E&&(l=A(E))?(f.isAAC?L(l):w(l),f.pesData=null):(E&&E.size&&N.b.log("last AAC PES packet truncated,might overlap between fragments"),f.pesData=E),T&&(l=A(T))?(k(l),p.pesData=null):p.pesData=T,null==this.sampleAes?this.remuxer.remux(f,c,p,this._txtTrack,e,r,i):this.decryptAndRemux(f,c,p,this._txtTrack,e,r,i)},t.prototype.decryptAndRemux=function(t,e,r,i,a,n,o){if(t.samples&&t.isAAC){var s=this;this.sampleAes.decryptAacSamples(t.samples,0,function(){s.decryptAndRemuxAvc(t,e,r,i,a,n,o)})}else this.decryptAndRemuxAvc(t,e,r,i,a,n,o)},t.prototype.decryptAndRemuxAvc=function(t,e,r,i,a,n,o){if(e.samples){var s=this;this.sampleAes.decryptAvcSamples(e.samples,0,0,function(){s.remuxer.remux(t,e,r,i,a,n,o)})}else this.remuxer.remux(t,e,r,i,a,n,o)},t.prototype.destroy=function(){this._initPTS=this._initDTS=void 0,this._duration=0},t.prototype._parsePAT=function(t,e){return(31&t[e+10])<<8|t[e+11]},t.prototype._parsePMT=function(t,e,r,i){var a,n,o,s,l={audio:-1,avc:-1,id3:-1,isAAC:!0};for(a=(15&t[e+1])<<8|t[e+2],n=e+3+a-4,o=(15&t[e+10])<<8|t[e+11],e+=12+o;e1;){var h=new Uint8Array(d[0].length+d[1].length);h.set(d[0]),h.set(d[1],d[0].length),d[0]=h,d.splice(1,1)}if(e=d[0],1===(e[0]<<16)+(e[1]<<8)+e[2]){if((i=(e[4]<<8)+e[5])&&i>t.size-6)return null;r=e[7],192&r&&(o=536870912*(14&e[9])+4194304*(255&e[10])+16384*(254&e[11])+128*(255&e[12])+(254&e[13])/2,o>4294967295&&(o-=8589934592),64&r?(s=536870912*(14&e[14])+4194304*(255&e[15])+16384*(254&e[16])+128*(255&e[17])+(254&e[18])/2,s>4294967295&&(s-=8589934592),o-s>54e5&&(N.b.warn(Math.round((o-s)/9e4)+"s delta between PTS and DTS, align them"),o=s)):s=o),a=e[8],l=a+9,t.size-=l,n=new Uint8Array(t.size);for(var c=0,f=d.length;cp){l-=p;continue}e=e.subarray(l),p-=l,l=0}n.set(e,u),u+=p}return i&&(i-=a+3),{data:n,pts:o,dts:s,len:i}}return null},t.prototype.pushAccesUnit=function(t,e){if(t.units.length&&t.frame){var r=e.samples,i=r.length;!this.config.forceKeyFrameOnDiscontinuity||!0===t.key||e.sps&&(i||this.contiguous)?(t.id=i,r.push(t)):e.dropped++}t.debug.length&&N.b.log(t.pts+"/"+t.dts+":"+t.debug)},t.prototype._parseAVCPES=function(t,e){var r,i,a,n=this,o=this._avcTrack,s=this._parseAVCNALu(t.data),l=this.avcSample,u=!1,d=this.pushAccesUnit.bind(this),h=function(t,e,r,i){return{key:t,pts:e,dts:r,units:[],debug:i}};t.data=null,l&&s.length&&(d(l,o),l=this.avcSample=h(!1,t.pts,t.dts,"")),s.forEach(function(e){switch(e.type){case 1:i=!0,l.frame=!0;var s=e.data;if(u&&s.length>4){var c=new X(s).readSliceType();2!==c&&4!==c&&7!==c&&9!==c||(l.key=!0)}break;case 5:i=!0,l||(l=n.avcSample=h(!0,t.pts,t.dts,"")),l.key=!0,l.frame=!0;break;case 6:i=!0,r=new X(n.discardEPB(e.data)),r.readUByte();for(var f=0,p=0,g=!1,v=0;!g&&r.bytesAvailable>1;){f=0;do{v=r.readUByte(),f+=v}while(255===v);p=0;do{v=r.readUByte(),p+=v}while(255===v);if(4===f&&0!==r.bytesAvailable){g=!0;if(181===r.readUByte()){if(49===r.readUShort()){if(1195456820===r.readUInt()){if(3===r.readUByte()){var m=r.readUByte(),y=r.readUByte(),b=31&m,E=[m,y];for(a=0;a0){if(e.pts>=t[r-1].pts)t.push(e);else for(var i=r-1;i>=0;i--)if(e.pts=0)i={data:t.subarray(c,o-u-1),type:n},h.push(i);else{var f=this._getLastNalUnit();if(f&&(d&&o<=4-d&&f.state&&(f.data=f.data.subarray(0,f.data.byteLength-d)),(r=o-u-1)>0)){var p=new Uint8Array(f.data.byteLength+r);p.set(f.data,0),p.set(t.subarray(0,r),f.data.byteLength),f.data=p}}o=0&&u>=0&&(i={data:t.subarray(c,s),type:n,state:u},h.push(i)),0===h.length){var g=this._getLastNalUnit();if(g){var v=new Uint8Array(g.data.byteLength+t.byteLength);v.set(g.data,0),v.set(t,g.data.byteLength),g.data=v}}return l.naluState=u,h},t.prototype.discardEPB=function(t){for(var e,r,i=t.byteLength,a=[],n=1;n1&&(N.b.log("AAC: align PTS for overlapping frames by "+Math.round((y-l)/90)),l=y)}for(;i>24&255,e[1]=i>>16&255,e[2]=i>>8&255,e[3]=255&i,e.set(t,4),a=0,i=8;a>24&255,e>>16&255,e>>8&255,255&e,i>>24,i>>16&255,i>>8&255,255&i,a>>24,a>>16&255,a>>8&255,255&a,85,196,0,0]))},t.mdia=function(e){return t.box(t.types.mdia,t.mdhd(e.timescale,e.duration),t.hdlr(e.type),t.minf(e))},t.mfhd=function(e){return t.box(t.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e]))},t.minf=function(e){return"audio"===e.type?t.box(t.types.minf,t.box(t.types.smhd,t.SMHD),t.DINF,t.stbl(e)):t.box(t.types.minf,t.box(t.types.vmhd,t.VMHD),t.DINF,t.stbl(e))},t.moof=function(e,r,i){return t.box(t.types.moof,t.mfhd(e),t.traf(i,r))},t.moov=function(e){for(var r=e.length,i=[];r--;)i[r]=t.trak(e[r]);return t.box.apply(null,[t.types.moov,t.mvhd(e[0].timescale,e[0].duration)].concat(i).concat(t.mvex(e)))},t.mvex=function(e){for(var r=e.length,i=[];r--;)i[r]=t.trex(e[r]);return t.box.apply(null,[t.types.mvex].concat(i))},t.mvhd=function(e,r){r*=e;var i=Math.floor(r/(it+1)),a=Math.floor(r%(it+1)),n=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,i>>24,i>>16&255,i>>8&255,255&i,a>>24,a>>16&255,a>>8&255,255&a,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return t.box(t.types.mvhd,n)},t.sdtp=function(e){var r,i,a=e.samples||[],n=new Uint8Array(4+a.length);for(i=0;i>>8&255),n.push(255&a),n=n.concat(Array.prototype.slice.call(i));for(r=0;r>>8&255),o.push(255&a),o=o.concat(Array.prototype.slice.call(i));var s=t.box(t.types.avcC,new Uint8Array([1,n[3],n[4],n[5],255,224|e.sps.length].concat(n).concat([e.pps.length]).concat(o))),l=e.width,u=e.height,d=e.pixelRatio[0],h=e.pixelRatio[1];return t.box(t.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,l>>8&255,255&l,u>>8&255,255&u,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),s,t.box(t.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),t.box(t.types.pasp,new Uint8Array([d>>24,d>>16&255,d>>8&255,255&d,h>>24,h>>16&255,h>>8&255,255&h])))},t.esds=function(t){var e=t.config.length;return new Uint8Array([0,0,0,0,3,23+e,0,1,0,4,15+e,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([e]).concat(t.config).concat([6,1,2]))},t.mp4a=function(e){var r=e.samplerate;return t.box(t.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,r>>8&255,255&r,0,0]),t.box(t.types.esds,t.esds(e)))},t.mp3=function(e){var r=e.samplerate;return t.box(t.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,r>>8&255,255&r,0,0]))},t.stsd=function(e){return"audio"===e.type?e.isAAC||"mp3"!==e.codec?t.box(t.types.stsd,t.STSD,t.mp4a(e)):t.box(t.types.stsd,t.STSD,t.mp3(e)):t.box(t.types.stsd,t.STSD,t.avc1(e))},t.tkhd=function(e){var r=e.id,i=e.duration*e.timescale,a=e.width,n=e.height,o=Math.floor(i/(it+1)),s=Math.floor(i%(it+1));return t.box(t.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,r>>24&255,r>>16&255,r>>8&255,255&r,0,0,0,0,o>>24,o>>16&255,o>>8&255,255&o,s>>24,s>>16&255,s>>8&255,255&s,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,a>>8&255,255&a,0,0,n>>8&255,255&n,0,0]))},t.traf=function(e,r){var i=t.sdtp(e),a=e.id,n=Math.floor(r/(it+1)),o=Math.floor(r%(it+1));return t.box(t.types.traf,t.box(t.types.tfhd,new Uint8Array([0,0,0,0,a>>24,a>>16&255,a>>8&255,255&a])),t.box(t.types.tfdt,new Uint8Array([1,0,0,0,n>>24,n>>16&255,n>>8&255,255&n,o>>24,o>>16&255,o>>8&255,255&o])),t.trun(e,i.length+16+20+8+16+8+8),i)},t.trak=function(e){return e.duration=e.duration||4294967295,t.box(t.types.trak,t.tkhd(e),t.mdia(e))},t.trex=function(e){var r=e.id;return t.box(t.types.trex,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},t.trun=function(e,r){var i,a,n,o,s,l,u=e.samples||[],d=u.length,h=12+16*d,c=new Uint8Array(h);for(r+=8+h,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),i=0;i>>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*i);return t.box(t.types.trun,c)},t.initSegment=function(e){t.types||t.init();var r,i=t.moov(e);return r=new Uint8Array(t.FTYP.byteLength+i.byteLength),r.set(t.FTYP),r.set(i,t.FTYP.byteLength),r},t}(),nt=at,ot=function(){function t(e,r,i,a){_(this,t),this.observer=e,this.config=r,this.typeSupported=i;var n=navigator.userAgent;this.isSafari=a&&a.indexOf("Apple")>-1&&n&&!n.match("CriOS"),this.ISGenerated=!1}return t.prototype.destroy=function(){},t.prototype.resetTimeStamp=function(t){this._initPTS=this._initDTS=t},t.prototype.resetInitSegment=function(){this.ISGenerated=!1},t.prototype.remux=function(t,e,r,i,a,n,o){if(this.ISGenerated||this.generateIS(t,e,a),this.ISGenerated)if(t.samples.length){t.timescale||(N.b.warn("regenerate InitSegment as audio detected"),this.generateIS(t,e,a));var s=this.remuxAudio(t,a,n,o);if(e.samples.length){var l=void 0;s&&(l=s.endPTS-s.startPTS),e.timescale||(N.b.warn("regenerate InitSegment as video detected"),this.generateIS(t,e,a)),this.remuxVideo(e,a,n,l,o)}}else{var u=void 0;e.samples.length&&(u=this.remuxVideo(e,a,n,o)),u&&t.codec&&this.remuxEmptyAudio(t,a,n,u)}r.samples.length&&this.remuxID3(r,a),i.samples.length&&this.remuxText(i,a),this.observer.trigger(D.a.FRAG_PARSED)},t.prototype.generateIS=function(t,e,r){var i,a,n=this.observer,o=t.samples,s=e.samples,l=this.typeSupported,u="audio/mp4",d={},h={tracks:d},c=void 0===this._initPTS;if(c&&(i=a=1/0),t.config&&o.length&&(t.timescale=t.samplerate,N.b.log("audio sampling rate : "+t.samplerate),t.isAAC||(l.mpeg?(u="audio/mpeg",t.codec=""):l.mp3&&(t.codec="mp3")),d.audio={container:u,codec:t.codec,initSegment:!t.isAAC&&l.mpeg?new Uint8Array:nt.initSegment([t]),metadata:{channelCount:t.channelCount}},c&&(i=a=o[0].pts-t.inputTimeScale*r)),e.sps&&e.pps&&s.length){var f=e.inputTimeScale;e.timescale=f,d.video={container:"video/mp4",codec:e.codec,initSegment:nt.initSegment([e]),metadata:{width:e.width,height:e.height}},c&&(i=Math.min(i,s[0].pts-f*r),a=Math.min(a,s[0].dts-f*r),this.observer.trigger(D.a.INIT_PTS_FOUND,{initPTS:i}))}Object.keys(d).length?(n.trigger(D.a.FRAG_PARSING_INIT_SEGMENT,h),this.ISGenerated=!0,c&&(this._initPTS=i,this._initDTS=a)):n.trigger(D.a.ERROR,{type:I.b.MEDIA_ERROR,details:I.a.FRAG_PARSING_ERROR,fatal:!1,reason:"no audio/video samples found"})},t.prototype.remuxVideo=function(t,e,r,i,a){var n,o,s,l,u,d,h,c=8,f=t.timescale,p=t.samples,g=[],v=p.length,m=this._PTSNormalize,y=this._initDTS,b=this.nextAvcDts,E=this.isSafari;E&&(r|=p.length&&b&&(a&&Math.abs(e-b/f)<.1||Math.abs(p[0].pts-b-y)1?N.b.log("AVC:"+A+" ms hole between fragments detected,filling it"):A<-1&&N.b.log("AVC:"+-A+" ms overlapping between fragments detected"),u=b,p[0].dts=u,l=Math.max(l-A,b),p[0].pts=l,N.b.log("Video/PTS/DTS adjusted: "+Math.round(l/90)+"/"+Math.round(u/90)+",delta:"+A+" ms")),S=p[p.length-1],h=Math.max(S.dts,0),d=Math.max(S.pts,0,h),E&&(n=Math.round((h-u)/(p.length-1)));for(var _=0,L=0,w=0;w0?U-1:U].dts;if(X.stretchShortVideoTrack){var Q=X.maxBufferHole,J=X.maxSeekHole,$=Math.floor(Math.min(Q,J)*f),Z=(i?l+i*f:this.nextAudioPts)-B.pts;Z>$?(n=Z-q,n<0&&(n=q),N.b.log("It is approximately "+Z/90+" ms to the next segment; using duration "+n/90+" ms for the last video frame.")):n=q}else n=q}j=Math.round(B.pts-B.dts)}g.push({size:H,duration:n,cts:j,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:B.key?2:1,isNonSync:B.key?0:1}})}this.nextAvcDts=h+n;var tt=t.dropped;if(t.len=0,t.nbNalu=0,t.dropped=0,g.length&&navigator.userAgent.toLowerCase().indexOf("chrome")>-1){var et=g[0].flags;et.dependsOn=2,et.isNonSync=0}t.samples=g,s=nt.moof(t.sequenceNumber++,u,t),t.samples=[];var rt={data1:s,data2:o,startPTS:l/f,endPTS:(d+n)/f,startDTS:u/f,endDTS:this.nextAvcDts/f,type:"video",nb:g.length,dropped:tt};return this.observer.trigger(D.a.FRAG_PARSING_DATA,rt),rt},t.prototype.remuxAudio=function(t,e,r,i){var a,n,o,s,l,u,d,h=t.inputTimeScale,c=t.timescale,f=h/c,p=t.isAAC?1024:1152,g=p*f,v=this._PTSNormalize,m=this._initDTS,y=!t.isAAC&&this.typeSupported.mpeg,b=t.samples,E=[],T=this.nextAudioPts;if(r|=b.length&&T&&(i&&Math.abs(e-T/h)<.1||Math.abs(b[0].pts-T-m)<20*g),r||(T=e*h),b.forEach(function(t){t.pts=t.dts=v(t.pts-m,T)}),b.sort(function(t,e){return t.pts-e.pts}),i&&t.isAAC)for(var R=0,S=T;R=g&&w<1e4&&S){var k=Math.round(A/g);N.b.warn("Injecting "+k+" audio frame @ "+(S/h).toFixed(3)+"s due to "+Math.round(1e3*A/h)+" ms gap.");for(var O=0;O0&&B<1e4)G=Math.round((U-T)/g),N.b.log(B+" ms hole between AAC samples detected,filling it"),G>0&&(o=rt.getSilentFrame(t.manifestCodec||t.codec,t.channelCount),o||(o=M.subarray()),t.len+=G*o.length);else if(B<-12){N.b.log("drop overlapping AAC sample, expected/parsed/delta:"+(T/h).toFixed(3)+"s/"+(U/h).toFixed(3)+"s/"+-B+"ms"),t.len-=M.byteLength;continue}U=T}if(u=Math.max(0,U),!(t.len>0))return;var H=y?t.len:t.len+8;a=y?0:8;try{s=new Uint8Array(H)}catch(t){return void this.observer.trigger(D.a.ERROR,{type:I.b.MUX_ERROR,details:I.a.REMUX_ALLOC_ERROR,fatal:!1,bytes:H,reason:"fail allocating audio mdat "+H})}if(!y){new DataView(s.buffer).setUint32(0,H),s.set(nt.types.mdat,4)}for(var j=0;j=2&&(W=E[V-2].duration,n.duration=W),V){this.nextAudioPts=T=d+f*W,t.len=0,t.samples=E,l=y?new Uint8Array:nt.moof(t.sequenceNumber++,u/f,t),t.samples=[];var Y=u/h,z=T/h,X={data1:l,data2:s,startPTS:Y,endPTS:z,startDTS:Y,endDTS:z,type:"audio",nb:V};return this.observer.trigger(D.a.FRAG_PARSING_DATA,X),X}return null},t.prototype.remuxEmptyAudio=function(t,e,r,i){var a=t.inputTimeScale,n=t.samplerate?t.samplerate:a,o=a/n,s=this.nextAudioPts,l=(void 0!==s?s:i.startDTS*a)+this._initDTS,u=i.endDTS*a+this._initDTS,d=1024*o,h=Math.ceil((u-l)/d),c=rt.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);if(N.b.warn("remux empty Audio"),!c)return void N.b.trace("Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec!");for(var f=[],p=0;p4294967296;)t+=r;return t},t}(),st=ot,lt=function(){function t(e){L(this,t),this.observer=e}return t.prototype.destroy=function(){},t.prototype.resetTimeStamp=function(){},t.prototype.resetInitSegment=function(){},t.prototype.remux=function(t,e,r,i,a,n,o,s){var l=this.observer,u="";t&&(u+="audio"),e&&(u+="video"),l.trigger(D.a.FRAG_PARSING_DATA,{data1:s,startPTS:a,startDTS:a,type:u,nb:1,dropped:0}),l.trigger(D.a.FRAG_PARSED)},t}(),ut=lt,dt=function(){function t(e,r,i,a){w(this,t),this.observer=e,this.typeSupported=r,this.config=i,this.vendor=a}return t.prototype.destroy=function(){var t=this.demuxer;t&&t.destroy()},t.prototype.push=function(t,e,r,i,a,n,o,s,l,u,d,h){if(t.byteLength>0&&null!=e&&null!=e.key&&"AES-128"===e.method){var c=this.decrypter;null==c&&(c=this.decrypter=new U(this.observer,this.config));var f,p=this;try{f=performance.now()}catch(t){f=Date.now()}c.decrypt(t,e.key.buffer,e.iv.buffer,function(t){var c;try{c=performance.now()}catch(t){c=Date.now()}p.observer.trigger(D.a.FRAG_DECRYPTED,{stats:{tstart:f,tdecrypt:c}}),p.pushDecrypted(new Uint8Array(t),e,new Uint8Array(r),i,a,n,o,s,l,u,d,h)})}else this.pushDecrypted(new Uint8Array(t),e,new Uint8Array(r),i,a,n,o,s,l,u,d,h)},t.prototype.pushDecrypted=function(t,e,r,i,a,n,o,s,l,u,d,h){var c=this.demuxer;if(!c||o&&!this.probe(t)){for(var f=this.observer,p=this.typeSupported,g=this.config,v=[{demux:H,remux:st},{demux:tt,remux:st},{demux:$,remux:st},{demux:W,remux:ut}],m=0,y=v.length;me?i.start+i.duration:Math.max(i.start-a.duration,0):r>e?(i.duration=n-i.start,i.duration<0&&It.b.warn("negative duration computed for frag "+i.sn+",level "+i.level+", there should be some duration drift between playlist and fragment!")):(a.duration=i.start-n,a.duration<0&&It.b.warn("negative duration computed for frag "+a.sn+",level "+a.level+", there should be some duration drift between playlist and fragment!"))}function y(t,e,r,i,a,n){if(!isNaN(e.startPTS)){var o=Math.abs(e.startPTS-r);isNaN(e.deltaPTS)?e.deltaPTS=o:e.deltaPTS=Math.max(o,e.deltaPTS),r=Math.min(r,e.startPTS),i=Math.max(i,e.endPTS),a=Math.min(a,e.startDTS),n=Math.max(n,e.endDTS)}var s=r-e.start;e.start=e.startPTS=r,e.endPTS=i,e.startDTS=a,e.endDTS=n,e.duration=i-r;var l=e.sn;if(!t||lt.endSN)return 0;var u,d,h;for(u=l-t.startSN,d=t.fragments,d[u]=e,h=u;h>0;h--)m(d,h,h-1);for(h=u;h=0&&ne?-1:0})}function R(t,e,r){var i=!1;return e&&e.details&&r&&(r.endCC>r.startCC||t&&t.cc59?e(r[1],r[2],0,r[4]):e(0,r[1],r[2],r[4]):null}function at(){this.values=Object.create(null)}function nt(t,e,r,i){var a=i?t.split(i):[t];for(var n in a)if("string"==typeof a[n]){var o=a[n].split(r);if(2===o.length){var s=o[0],l=o[1];e(s,l)}}}function ot(t,e,r){function i(){var e=it(t);if(null===e)throw new Error("Malformed timestamp: "+n);return t=t.replace(/^[^\sa-zA-Z-]+/,""),e}function a(){t=t.replace(/^\s+/,"")}var n=t;if(a(),e.startTime=i(),a(),"--\x3e"!==t.substr(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+n);t=t.substr(3),a(),e.endTime=i(),a(),function(t,e){var i=new at;nt(t,function(t,e){switch(t){case"region":for(var a=r.length-1;a>=0;a--)if(r[a].id===e){i.set(t,r[a].region);break}break;case"vertical":i.alt(t,e,["rl","lr"]);break;case"line":var n=e.split(","),o=n[0];i.integer(t,o),i.percent(t,o)&&i.set("snapToLines",!1),i.alt(t,o,["auto"]),2===n.length&&i.alt("lineAlign",n[1],["start",Ye,"end"]);break;case"position":n=e.split(","),i.percent(t,n[0]),2===n.length&&i.alt("positionAlign",n[1],["start",Ye,"end","line-left","line-right","auto"]);break;case"size":i.percent(t,e);break;case"align":i.alt(t,e,["start",Ye,"end","left","right"])}},/:/,/\s/),e.region=i.get("region",null),e.vertical=i.get("vertical","");var a=i.get("line","auto");"auto"===a&&-1===Ve.line&&(a=-1),e.line=a,e.lineAlign=i.get("lineAlign","start"),e.snapToLines=i.get("snapToLines",!0),e.size=i.get("size",100),e.align=i.get("align",Ye);var n=i.get("position","auto");"auto"===n&&50===Ve.position&&(n="start"===e.align||"left"===e.align?0:"end"===e.align||"right"===e.align?100:50),e.position=n}(t,e)}function st(t){return t.replace(//gi,"\n")}function lt(t,e,r,i){for(var a,n,o,s,l,u=window.VTTCue||window.TextTrackCue,d=0;d=16?s--:s++,navigator.userAgent.match(/Firefox\//)?n.line=d+1:n.line=d>7?d-2:d+1,n.align="left",n.position=Math.max(0,Math.min(100,s/32*100+(navigator.userAgent.match(/Firefox\//)?50:0))),t.addCue(n)}}function ut(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function dt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function ht(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function ct(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function ft(t){if(t&&t.cues)for(;t.cues.length>0;)t.removeCue(t.cues[0])}function pt(t,e){return t&&t.label===e.name&&!(t.textTrack1||t.textTrack2)}function gt(t,e,r,i){return Math.min(e,i)-Math.max(t,r)}function vt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function mt(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function yt(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function bt(t){for(var e=[],r=0;r1?r-1:0),n=1;nNumber.MAX_SAFE_INTEGER?1/0:e},t.prototype.hexadecimalInteger=function(t){if(this[t]){var e=(this[t]||"0x").slice(2);e=(1&e.length?"0":"")+e;for(var r=new Uint8Array(e.length/2),i=0;iNumber.MAX_SAFE_INTEGER?1/0:e},t.prototype.decimalFloatingPoint=function(t){return parseFloat(this[t])},t.prototype.enumeratedString=function(t){return this[t]},t.prototype.decimalResolution=function(t){var e=Pt.exec(this[t]);if(null!==e)return{width:parseInt(e[1],10),height:parseInt(e[2],10)}},t.parseAttrList=function(t){var e,r={};for(xt.lastIndex=0;null!==(e=xt.exec(t));){var i=e[2];0===i.indexOf('"')&&i.lastIndexOf('"')===i.length-1&&(i=i.slice(1,-1)),r[e[1]]=i}return r},t}(),Nt=Ft,Mt={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,drac:!0,dvav:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0}},Ut=function(){function t(t,e){for(var r=0;r>8*(15-r)&255;return e},t.prototype.fragmentDecryptdataFromLevelkey=function(t,e){var r=t;return t&&t.method&&t.uri&&!t.iv&&(r=new Kt,r.method=t.method,r.baseuri=t.baseuri,r.reluri=t.reluri,r.iv=this.createInitializationVector(e)),r},t.prototype.cloneObj=function(t){return JSON.parse(JSON.stringify(t))},Ut(t,[{key:"url",get:function(){return!this._url&&this.relurl&&(this._url=Lt.a.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url},set:function(t){this._url=t}},{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 t=this._byteRange=[];if(this.rawByteRange){var e=this.rawByteRange.split("@",2);if(1===e.length){var r=this.lastByteRangeEndOffset;t[0]=r||0}else t[0]=parseInt(e[1]);t[1]=parseInt(e[0])+t[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}}]),t}(),Vt=function(t){function e(r){u(this,e);var i=s(this,t.call(this,r,wt.a.MANIFEST_LOADING,wt.a.LEVEL_LOADING,wt.a.AUDIO_TRACK_LOADING,wt.a.SUBTITLE_TRACK_LOADING));return i.loaders={},i}return l(e,t),e.prototype.destroy=function(){for(var t in this.loaders){var e=this.loaders[t];e&&e.destroy()}this.loaders={},Ct.prototype.destroy.call(this)},e.prototype.onManifestLoading=function(t){this.load(t.url,{type:"manifest"})},e.prototype.onLevelLoading=function(t){this.load(t.url,{type:"level",level:t.level,id:t.id})},e.prototype.onAudioTrackLoading=function(t){this.load(t.url,{type:"audioTrack",id:t.id})},e.prototype.onSubtitleTrackLoading=function(t){this.load(t.url,{type:"subtitleTrack",id:t.id})},e.prototype.load=function(t,e){var r=this.loaders[e.type];if(r){var i=r.context;if(i&&i.url===t)return void It.b.trace("playlist request ongoing");It.b.warn("abort previous loader for type:"+e.type),r.abort()}var a=this.hls.config,n=void 0,o=void 0,s=void 0,l=void 0;"manifest"===e.type?(n=a.manifestLoadingMaxRetry,o=a.manifestLoadingTimeOut,s=a.manifestLoadingRetryDelay,l=a.manifestLoadingMaxRetryTimeout):(n=a.levelLoadingMaxRetry,o=a.levelLoadingTimeOut,s=a.levelLoadingRetryDelay,l=a.levelLoadingMaxRetryTimeout,It.b.log("loading playlist for "+e.type+" "+(e.level||e.id))),r=this.loaders[e.type]=e.loader=void 0!==a.pLoader?new a.pLoader(a):new a.loader(a),e.url=t,e.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(e,u,d)},e.prototype.resolve=function(t,e){return Lt.a.buildAbsoluteURL(e,t,{alwaysNormalize:!0})},e.prototype.parseMasterPlaylist=function(t,e){var r=[],i=void 0;for(Bt.lastIndex=0;null!=(i=Bt.exec(t));){var a={},o=a.attrs=new Nt(i[1]);a.url=this.resolve(i[2],e);var s=o.decimalResolution("RESOLUTION");s&&(a.width=s.width,a.height=s.height),a.bitrate=o.decimalInteger("AVERAGE-BANDWIDTH")||o.decimalInteger("BANDWIDTH"),a.name=o.NAME,function(t,e){["video","audio"].forEach(function(r){var i=t.filter(function(t){return n(t,r)});if(i.length){var a=i.filter(function(t){return 0===t.lastIndexOf("avc1",0)||0===t.lastIndexOf("mp4a",0)});e[r+"Codec"]=a.length>0?a[0]:i[0],t=t.filter(function(t){return-1===i.indexOf(t)})}}),e.unknownCodecs=t}([].concat((o.CODECS||"").split(/[ ,]+/)),a),a.videoCodec&&-1!==a.videoCodec.indexOf("avc1")&&(a.videoCodec=this.avc1toavcoti(a.videoCodec)),r.push(a)}return r},e.prototype.parseMasterPlaylistMedia=function(t,e,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,a=void 0,n=[],o=0;for(Gt.lastIndex=0;null!=(a=Gt.exec(t));){var s={},l=new Nt(a[1]);l.TYPE===r&&(s.groupId=l["GROUP-ID"],s.name=l.NAME,s.type=r,s.default="YES"===l.DEFAULT,s.autoselect="YES"===l.AUTOSELECT,s.forced="YES"===l.FORCED,l.URI&&(s.url=this.resolve(l.URI,e)),s.lang=l.LANGUAGE,s.name||(s.name=s.lang),i&&(s.audioCodec=i),s.id=o++,n.push(s))}return n},e.prototype.avc1toavcoti=function(t){var e,r=t.split(".");return r.length>2?(e=r.shift()+".",e+=parseInt(r.shift()).toString(16),e+=("000"+parseInt(r.shift()).toString(16)).substr(-4)):e=t,e},e.prototype.parseLevelPlaylist=function(t,e,r,i){var a,n,o=0,s=0,l={type:null,version:null,url:e,fragments:[],live:!0,startSN:0},u=new Kt,d=0,h=null,c=new Wt;for(Ht.lastIndex=0;null!==(a=Ht.exec(t));){var f=a[1];if(f){c.duration=parseFloat(f);var p=(" "+a[2]).slice(1);c.title=p||null,c.tagList.push(p?["INF",f,p]:["INF",f])}else if(a[3]){if(!isNaN(c.duration)){var g=o++;c.type=i,c.start=s,c.levelkey=u,c.sn=g,c.level=r,c.cc=d,c.baseurl=e,c.relurl=(" "+a[3]).slice(1),l.fragments.push(c),h=c,s+=c.duration,c=new Wt}}else if(a[4]){if(c.rawByteRange=(" "+a[4]).slice(1),h){var v=h.byteRangeEndOffset;v&&(c.lastByteRangeEndOffset=v)}}else if(a[5])c.rawProgramDateTime=(" "+a[5]).slice(1),c.tagList.push(["PROGRAM-DATE-TIME",c.rawProgramDateTime]),void 0===l.programDateTime&&(l.programDateTime=new Date(new Date(Date.parse(a[5]))-1e3*s));else{for(a=a[0].match(jt),n=1;n=0&&(u.method=T,u.baseuri=e,u.reluri=R,u.key=null,u.iv=S));break;case"START":var A=m,_=new Nt(A),L=_.decimalFloatingPoint("TIME-OFFSET");isNaN(L)||(l.startTimeOffset=L);break;case"MAP":var w=new Nt(m);c.relurl=w.URI,c.rawByteRange=w.BYTERANGE,c.baseurl=e,c.level=r,c.type=i,c.sn="initSegment",l.initSegment=c,c=new Wt;break;default:It.b.warn("line parsed but not handled: "+a)}}}return c=h,c&&!c.relurl&&(l.fragments.pop(),s-=c.duration),l.totalduration=s,l.averagetargetduration=s/l.fragments.length,l.endSN=o-1,l.startCC=l.fragments[0]?l.fragments[0].cc:0,l.endCC=d,l},e.prototype.loadsuccess=function(t,e,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,a=t.data,n=t.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),e.tload=performance.now(),0===a.indexOf("#EXTM3U"))if(a.indexOf("#EXTINF:")>0){var d="audioTrack"!==o&&"subtitleTrack"!==o,h=isNaN(l)?isNaN(s)?0:s:l,c=this.parseLevelPlaylist(a,n,h,"audioTrack"===o?"audio":"subtitleTrack"===o?"subtitle":"main");c.tload=e.tload,"manifest"===o&&u.trigger(wt.a.MANIFEST_LOADED,{levels:[{url:n,details:c}],audioTracks:[],url:n,stats:e,networkDetails:i}),e.tparsed=performance.now(),c.targetduration?d?u.trigger(wt.a.LEVEL_LOADED,{details:c,level:l||0,id:s||0,stats:e,networkDetails:i}):"audioTrack"===o?u.trigger(wt.a.AUDIO_TRACK_LOADED,{details:c,id:s,stats:e,networkDetails:i}):"subtitleTrack"===o&&u.trigger(wt.a.SUBTITLE_TRACK_LOADED,{details:c,id:s,stats:e,networkDetails:i}):u.trigger(wt.a.ERROR,{type:Dt.b.NETWORK_ERROR,details:Dt.a.MANIFEST_PARSING_ERROR,fatal:!0,url:n,reason:"invalid targetduration",networkDetails:i})}else{var f=this.parseMasterPlaylist(a,n);if(f.length){var p=this.parseMasterPlaylistMedia(a,n,"AUDIO",f[0].audioCodec),g=this.parseMasterPlaylistMedia(a,n,"SUBTITLES");if(p.length){var v=!1;p.forEach(function(t){t.url||(v=!0)}),!1===v&&f[0].audioCodec&&!f[0].attrs.AUDIO&&(It.b.log("audio codec signaled in quality level, but no embedded audio track signaled, create one"),p.unshift({type:"main",name:"main"}))}u.trigger(wt.a.MANIFEST_LOADED,{levels:f,audioTracks:p,subtitles:g,url:n,stats:e,networkDetails:i})}else u.trigger(wt.a.ERROR,{type:Dt.b.NETWORK_ERROR,details:Dt.a.MANIFEST_PARSING_ERROR,fatal:!0,url:n,reason:"no level found in manifest",networkDetails:i})}else u.trigger(wt.a.ERROR,{type:Dt.b.NETWORK_ERROR,details:Dt.a.MANIFEST_PARSING_ERROR,fatal:!0,url:n,reason:"no EXTM3U delimiter",networkDetails:i})},e.prototype.loaderror=function(t,e){var r,i,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=e.loader;switch(e.type){case"manifest":r=Dt.a.MANIFEST_LOAD_ERROR,i=!0;break;case"level":r=Dt.a.LEVEL_LOAD_ERROR,i=!1;break;case"audioTrack":r=Dt.a.AUDIO_TRACK_LOAD_ERROR,i=!1}n&&(n.abort(),this.loaders[e.type]=void 0),this.hls.trigger(wt.a.ERROR,{type:Dt.b.NETWORK_ERROR,details:r,fatal:i,url:n.url,loader:n,response:t,context:e,networkDetails:a})},e.prototype.loadtimeout=function(t,e){var r,i,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=e.loader;switch(e.type){case"manifest":r=Dt.a.MANIFEST_LOAD_TIMEOUT,i=!0;break;case"level":r=Dt.a.LEVEL_LOAD_TIMEOUT,i=!1;break;case"audioTrack":r=Dt.a.AUDIO_TRACK_LOAD_TIMEOUT,i=!1}n&&(n.abort(),this.loaders[e.type]=void 0),this.hls.trigger(wt.a.ERROR,{type:Dt.b.NETWORK_ERROR,details:r,fatal:i,url:n.url,loader:n,context:e,networkDetails:a})},e}(Ct),Yt=Vt,zt=function(t){function e(r){d(this,e);var i=h(this,t.call(this,r,wt.a.FRAG_LOADING));return i.loaders={},i}return c(e,t),e.prototype.destroy=function(){var t=this.loaders;for(var e in t){var r=t[e];r&&r.destroy()}this.loaders={},Ct.prototype.destroy.call(this)},e.prototype.onFragLoading=function(t){var e=t.frag,r=e.type,i=this.loaders[r],a=this.hls.config;e.loaded=0,i&&(It.b.warn("abort previous fragment loader for type:"+r),i.abort()),i=this.loaders[r]=e.loader=void 0!==a.fLoader?new a.fLoader(a):new a.loader(a);var n=void 0,o=void 0,s=void 0;n={url:e.url,frag:e,responseType:"arraybuffer",progressData:!1};var l=e.byteRangeStartOffset,u=e.byteRangeEndOffset;isNaN(l)||isNaN(u)||(n.rangeStart=l,n.rangeEnd=u),o={timeout:a.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:a.fragLoadingMaxRetryTimeout},s={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this),onProgress:this.loadprogress.bind(this)},i.load(n,o,s)},e.prototype.loadsuccess=function(t,e,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,a=t.data,n=r.frag;n.loader=void 0,this.loaders[n.type]=void 0,this.hls.trigger(wt.a.FRAG_LOADED,{payload:a,frag:n,stats:e,networkDetails:i})},e.prototype.loaderror=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=e.loader;i&&i.abort(),this.loaders[e.type]=void 0,this.hls.trigger(wt.a.ERROR,{type:Dt.b.NETWORK_ERROR,details:Dt.a.FRAG_LOAD_ERROR,fatal:!1,frag:e.frag,response:t,networkDetails:r})},e.prototype.loadtimeout=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=e.loader;i&&i.abort(),this.loaders[e.type]=void 0,this.hls.trigger(wt.a.ERROR,{type:Dt.b.NETWORK_ERROR,details:Dt.a.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e.frag,networkDetails:r})},e.prototype.loadprogress=function(t,e,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,a=e.frag;a.loaded=t.loaded,this.hls.trigger(wt.a.FRAG_LOAD_PROGRESS,{frag:a,stats:t,networkDetails:i})},e}(Ct),Xt=zt,qt=function(t){function e(r){f(this,e);var i=p(this,t.call(this,r,wt.a.KEY_LOADING));return i.loaders={},i.decryptkey=null,i.decrypturl=null,i}return g(e,t),e.prototype.destroy=function(){for(var t in this.loaders){var e=this.loaders[t];e&&e.destroy()}this.loaders={},Ct.prototype.destroy.call(this)},e.prototype.onKeyLoading=function(t){var e=t.frag,r=e.type,i=this.loaders[r],a=e.decryptdata,n=a.uri;if(n!==this.decrypturl||null===this.decryptkey){var o=this.hls.config;i&&(It.b.warn("abort previous key loader for type:"+r),i.abort()),e.loader=this.loaders[r]=new o.loader(o),this.decrypturl=n,this.decryptkey=null;var s=void 0,l=void 0,u=void 0;s={url:n,frag:e,responseType:"arraybuffer"},l={timeout:o.fragLoadingTimeOut,maxRetry:o.fragLoadingMaxRetry,retryDelay:o.fragLoadingRetryDelay,maxRetryDelay:o.fragLoadingMaxRetryTimeout},u={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)},e.loader.load(s,l,u)}else this.decryptkey&&(a.key=this.decryptkey,this.hls.trigger(wt.a.KEY_LOADED,{frag:e}))},e.prototype.loadsuccess=function(t,e,r){var i=r.frag;this.decryptkey=i.decryptdata.key=new Uint8Array(t.data),i.loader=void 0,this.loaders[i.type]=void 0,this.hls.trigger(wt.a.KEY_LOADED,{frag:i})},e.prototype.loaderror=function(t,e){var r=e.frag,i=r.loader;i&&i.abort(),this.loaders[e.type]=void 0,this.hls.trigger(wt.a.ERROR,{type:Dt.b.NETWORK_ERROR,details:Dt.a.KEY_LOAD_ERROR,fatal:!1,frag:r,response:t})},e.prototype.loadtimeout=function(t,e){var r=e.frag,i=r.loader;i&&i.abort(),this.loaders[e.type]=void 0,this.hls.trigger(wt.a.ERROR,{type:Dt.b.NETWORK_ERROR,details:Dt.a.KEY_LOAD_TIMEOUT,fatal:!1,frag:r})},e}(Ct),Qt=qt,Jt={search:function(t,e){for(var r=0,i=t.length-1,a=null,n=null;r<=i;){a=(r+i)/2|0,n=t[a];var o=e(n);if(o>0)r=a+1;else{if(!(o<0))return n;i=a-1}}return null}},$t=Jt,Zt={isBuffered:function(t,e){if(t)for(var r=t.buffered,i=0;i=r.start(i)&&e<=r.end(i))return!0;return!1},bufferInfo:function(t,e,r){if(t){var i,a=t.buffered,n=[];for(i=0;id&&(l[u-1].end=t[s].end):l.push(t[s])}else l.push(t[s])}for(s=0,i=0,a=n=e;s=h&&e1?e-1:0),a=1;a1?e-1:0),a=1;a0&&-1===t&&(It.b.log("override startPosition with lastCurrentTime @"+e.toFixed(3)),t=e),this.state=he.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this.forceStartLoad=!0,this.state=he.STOPPED},e.prototype.stopLoad=function(){var t=this.fragCurrent;t&&(t.loader&&t.loader.abort(),this.fragCurrent=null),this.fragPrevious=null,this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),this.state=he.STOPPED,this.forceStartLoad=!1},e.prototype.tick=function(){1===++this.ticks&&(this.doTick(),this.ticks>1&&setTimeout(this.tick,1),this.ticks=0)},e.prototype.doTick=function(){switch(this.state){case he.ERROR:break;case he.BUFFER_FLUSHING:this.fragLoadError=0;break;case he.IDLE:this._doTickIdle();break;case he.WAITING_LEVEL:var t=this.levels[this.level];t&&t.details&&(this.state=he.IDLE);break;case he.FRAG_LOADING_WAITING_RETRY:var e=performance.now(),r=this.retryDate;(!r||e>=r||this.media&&this.media.seeking)&&(It.b.log("mediaController: retryDate reached, switch back to IDLE state"),this.state=he.IDLE);break;case he.ERROR:case he.STOPPED:case he.FRAG_LOADING:case he.PARSING:case he.PARSED:case he.ENDED:}this._checkBuffer(),this._checkFragmentChanged()},e.prototype._doTickIdle=function(){var t=this.hls,e=t.config,r=this.media;if(void 0===this.levelLastLoaded||r||!this.startFragRequested&&e.startFragPrefetch){var i=void 0;i=this.loadedmetadata?r.currentTime:this.nextLoadPosition;var a=t.nextLoadLevel,n=this.levels[a];if(n){var o=n.bitrate,s=void 0;s=o?Math.max(8*e.maxBufferSize/o,e.maxBufferLength):e.maxBufferLength,s=Math.min(s,e.maxMaxBufferLength);var l=te.bufferInfo(this.mediaBuffer?this.mediaBuffer:r,i,e.maxBufferHole),u=l.len;if(!(u>=s)){It.b.trace("buffer length of "+u.toFixed(3)+" is below max of "+s.toFixed(3)+". checking for more payload ..."),this.level=t.nextLoadLevel=a;var d=n.details;if(void 0===d||d.live&&this.levelLastLoaded!==a)return void(this.state=he.WAITING_LEVEL);var h=this.fragPrevious;if(!d.live&&h&&h.sn===d.endSN&&u&&!l.nextStart){if(Math.min(r.duration,h.start+h.duration)-Math.max(l.end,h.start)<=Math.max(.2,h.duration)){var c={};return this.altAudio&&(c.type="video"),this.hls.trigger(wt.a.BUFFER_EOS,c),void(this.state=he.ENDED)}}this._fetchPayloadOrEos(i,l,d)}}}},e.prototype._fetchPayloadOrEos=function(t,e,r){var i=this.fragPrevious,a=this.level,n=r.fragments,o=n.length;if(0!==o){var s=n[0].start,l=n[o-1].start+n[o-1].duration,u=e.end,d=void 0;if(r.initSegment&&!r.initSegment.data)d=r.initSegment;else if(r.live){var h=this.config.initialLiveManifestSize;if(oh&&(l.currentTime=h),this.nextLoadPosition=h}if(t.PTSKnown&&e>i&&l&&l.readyState)return null;if(this.startFragRequested&&!t.PTSKnown){if(a){var c=a.sn+1;if(c>=t.startSN&&c<=t.endSN){var f=n[c-t.startSN];a.cc===f.cc&&(u=f,It.b.log("live playlist, switching playlist, load frag with next SN: "+u.sn))}u||(u=$t.search(n,function(t){return a.cc-t.cc}))&&It.b.log("live playlist, switching playlist, load frag with same CC: "+u.sn)}u||(u=n[Math.min(o-1,Math.round(o/2))],It.b.log("live playlist, switching playlist, unknown, load middle frag : "+u.sn))}return u},e.prototype._findFragment=function(t,e,r,i,a,n,o){var s=this.hls.config,l=void 0,u=void 0,d=s.maxFragLookUpTolerance,h=e?i[e.sn-i[0].sn+1]:void 0,c=function(t){var e=Math.min(d,t.duration);return t.start+t.duration-e<=a?1:t.start-e>a&&t.start?-1:0};if(an-d&&(d=0),u=h&&!c(h)?h:$t.search(i,c)):u=i[r-1],u){l=u;var f=l.sn-o.startSN,p=e&&l.level===e.level,g=i[f-1],v=i[f+1];if(e&&l.sn===e.sn)if(p&&!l.backtracked)if(l.sns.maxBufferHole&&e.dropped&&f?(l=g,It.b.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"),e.loadCounter--):(l=v,It.b.log("SN just loaded, load next one: "+l.sn))}else l=null;else l.backtracked&&(v&&v.backtracked?(It.b.warn("Already backtracked from fragment "+v.sn+", will not backtrack to fragment "+l.sn+". Loading fragment "+v.sn),l=v):(It.b.warn("Loaded fragment with dropped frames, backtracking 1 segment to find a keyframe"),l.dropped=0,g?(g.loadCounter&&g.loadCounter--,l=g,l.backtracked=!0):f&&(l=null)))}return l},e.prototype._loadFragmentOrKey=function(t,e,r,i,a){var n=this.hls,o=n.config;if(!t.decryptdata||null==t.decryptdata.uri||null!=t.decryptdata.key){if(It.b.log("Loading "+t.sn+" of ["+r.startSN+" ,"+r.endSN+"],level "+e+", currentTime:"+i.toFixed(3)+",bufferEnd:"+a.toFixed(3)),void 0!==this.fragLoadIdx?this.fragLoadIdx++:this.fragLoadIdx=0,t.loadCounter){t.loadCounter++;var s=o.fragLoadingLoopThreshold;if(t.loadCounter>s&&Math.abs(this.fragLoadIdx-t.loadIdx)e.endPTS?1:0})},e.prototype.followingBufferedFrag=function(t){return t?this.getBufferedFrag(t.endPTS+.5):null},e.prototype._checkFragmentChanged=function(){var t,e,r=this.media;if(r&&r.readyState&&!1===r.seeking&&(e=r.currentTime,e>r.playbackRate*this.lastCurrentTime&&(this.lastCurrentTime=e),te.isBuffered(r,e)?t=this.getBufferedFrag(e):te.isBuffered(r,e+.1)&&(t=this.getBufferedFrag(e+.1)),t)){var i=t;if(i!==this.fragPlaying){this.hls.trigger(wt.a.FRAG_CHANGED,{frag:i});var a=i.level;this.fragPlaying&&this.fragPlaying.level===a||this.hls.trigger(wt.a.LEVEL_SWITCHED,{level:a}),this.fragPlaying=i}}},e.prototype.immediateLevelSwitch=function(){if(It.b.log("immediateLevelSwitch"),!this.immediateSwitch){this.immediateSwitch=!0;var t=this.media,e=void 0;t?(e=t.paused,t.pause()):e=!0,this.previouslyPaused=e}var r=this.fragCurrent;r&&r.loader&&r.loader.abort(),this.fragCurrent=null,void 0!==this.fragLoadIdx&&(this.fragLoadIdx+=2*this.config.fragLoadingLoopThreshold),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},e.prototype.immediateLevelSwitchEnd=function(){var t=this.media;t&&t.buffered.length&&(this.immediateSwitch=!1,te.isBuffered(t,t.currentTime)&&(t.currentTime-=1e-4),this.previouslyPaused||t.play())},e.prototype.nextLevelSwitch=function(){var t=this.media;if(t&&t.readyState){var e=void 0,r=void 0,i=void 0;if(this.fragLoadIdx+=2*this.config.fragLoadingLoopThreshold,r=this.getBufferedFrag(t.currentTime),r&&r.startPTS>1&&this.flushMainBuffer(0,r.startPTS-1),t.paused)e=0;else{var a=this.hls.nextLoadLevel,n=this.levels[a],o=this.fragLastKbps;e=o&&this.fragCurrent?this.fragCurrent.duration*n.bitrate/(1e3*o)+1:0}if((i=this.getBufferedFrag(t.currentTime+e))&&(i=this.followingBufferedFrag(i))){var s=this.fragCurrent;s&&s.loader&&s.loader.abort(),this.fragCurrent=null,this.flushMainBuffer(i.maxStartPTS,Number.POSITIVE_INFINITY)}}},e.prototype.flushMainBuffer=function(t,e){this.state=he.BUFFER_FLUSHING;var r={startOffset:t,endOffset:e};this.altAudio&&(r.type="video"),this.hls.trigger(wt.a.BUFFER_FLUSHING,r)},e.prototype.onMediaAttached=function(t){var e=this.media=this.mediaBuffer=t.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),this.onvended=this.onMediaEnded.bind(this),e.addEventListener("seeking",this.onvseeking),e.addEventListener("seeked",this.onvseeked),e.addEventListener("ended",this.onvended);var r=this.config;this.levels&&r.autoStartLoad&&this.hls.startLoad(r.startPosition)},e.prototype.onMediaDetaching=function(){var t=this.media;t&&t.ended&&(It.b.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0);var e=this.levels;e&&e.forEach(function(t){t.details&&t.details.fragments.forEach(function(t){t.loadCounter=void 0,t.backtracked=void 0})}),t&&(t.removeEventListener("seeking",this.onvseeking),t.removeEventListener("seeked",this.onvseeked),t.removeEventListener("ended",this.onvended),this.onvseeking=this.onvseeked=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.stopLoad()},e.prototype.onMediaSeeking=function(){var t=this.media,e=t?t.currentTime:void 0,r=this.config;isNaN(e)||It.b.log("media seeking to "+e.toFixed(3));var i=this.mediaBuffer?this.mediaBuffer:t,a=te.bufferInfo(i,e,this.config.maxBufferHole);if(this.state===he.FRAG_LOADING){var n=this.fragCurrent;if(0===a.len&&n){var o=r.maxFragLookUpTolerance,s=n.start-o,l=n.start+n.duration+o;el?(n.loader&&(It.b.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),n.loader.abort()),this.fragCurrent=null,this.fragPrevious=null,this.state=he.IDLE):It.b.log("seeking outside of buffer but within currently loaded fragment range")}}else this.state===he.ENDED&&(0===a.len&&(this.fragPrevious=0),this.state=he.IDLE);t&&(this.lastCurrentTime=e),this.state!==he.FRAG_LOADING&&void 0!==this.fragLoadIdx&&(this.fragLoadIdx+=2*r.fragLoadingLoopThreshold),this.loadedmetadata||(this.nextLoadPosition=this.startPosition=e),this.tick()},e.prototype.onMediaSeeked=function(){var t=this.media,e=t?t.currentTime:void 0;isNaN(e)||It.b.log("media seeked to "+e.toFixed(3)),this.tick()},e.prototype.onMediaEnded=function(){It.b.log("media ended"),this.startPosition=this.lastCurrentTime=0},e.prototype.onManifestLoading=function(){It.b.log("trigger BUFFER_RESET"),this.hls.trigger(wt.a.BUFFER_RESET),this._bufferedFrags=[],this.stalled=!1,this.startPosition=this.lastCurrentTime=0},e.prototype.onManifestParsed=function(t){var e,r=!1,i=!1;t.levels.forEach(function(t){(e=t.audioCodec)&&(-1!==e.indexOf("mp4a.40.2")&&(r=!0),-1!==e.indexOf("mp4a.40.5")&&(i=!0))}),this.audioCodecSwitch=r&&i,this.audioCodecSwitch&&It.b.log("both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startLevelLoaded=!1,this.startFragRequested=!1;var a=this.config;(a.autoStartLoad||this.forceStartLoad)&&this.hls.startLoad(a.startPosition)},e.prototype.onLevelLoaded=function(t){var e=t.details,r=t.level,i=this.levels[this.levelLastLoaded],a=this.levels[r],n=e.totalduration,o=0;if(It.b.log("level "+r+" loaded ["+e.startSN+","+e.endSN+"],duration:"+n),e.live){var s=a.details;s&&e.fragments.length>0?(b(s,e),o=e.fragments[0].start,this.liveSyncPosition=this.computeLivePosition(o,s),e.PTSKnown?It.b.log("live playlist sliding:"+o.toFixed(3)):(It.b.log("live playlist - outdated PTS, unknown sliding"),_(this.fragPrevious,i,e))):(It.b.log("live playlist - first load, unknown sliding"),e.PTSKnown=!1,_(this.fragPrevious,i,e))}else e.PTSKnown=!1;if(a.details=e,this.levelLastLoaded=r,this.hls.trigger(wt.a.LEVEL_UPDATED,{details:e,level:r}),!1===this.startFragRequested){if(-1===this.startPosition||-1===this.lastCurrentTime){var l=e.startTimeOffset;isNaN(l)?e.live?(this.startPosition=this.computeLivePosition(o,e),It.b.log("configure startPosition to "+this.startPosition)):this.startPosition=0:(l<0&&(It.b.log("negative start time offset "+l+", count from end of last fragment"),l=o+n+l),It.b.log("start time offset found in playlist, adjust startPosition to "+l),this.startPosition=l),this.lastCurrentTime=this.startPosition}this.nextLoadPosition=this.startPosition}this.state===he.WAITING_LEVEL&&(this.state=he.IDLE),this.tick()},e.prototype.onKeyLoaded=function(){this.state===he.KEY_LOADING&&(this.state=he.IDLE,this.tick())},e.prototype.onFragLoaded=function(t){var e=this.fragCurrent,r=t.frag;if(this.state===he.FRAG_LOADING&&e&&"main"===r.type&&r.level===e.level&&r.sn===e.sn){var i=t.stats,a=this.levels[e.level],n=a.details;if(It.b.log("Loaded "+e.sn+" of ["+n.startSN+" ,"+n.endSN+"],level "+e.level),this.bitrateTest=!1,this.stats=i,!0===r.bitrateTest&&this.hls.nextLoadLevel)this.state=he.IDLE,this.startFragRequested=!1,i.tparsed=i.tbuffered=performance.now(),this.hls.trigger(wt.a.FRAG_BUFFERED,{stats:i,frag:e,id:"main"}),this.tick();else if("initSegment"===r.sn)this.state=he.IDLE,i.tparsed=i.tbuffered=performance.now(),n.initSegment.data=t.payload,this.hls.trigger(wt.a.FRAG_BUFFERED,{stats:i,frag:e,id:"main"}),this.tick();else{this.state=he.PARSING;var o=n.totalduration,s=e.level,l=e.sn,u=this.config.defaultAudioCodec||a.audioCodec;this.audioCodecSwap&&(It.b.log("swapping playlist audio codec"),void 0===u&&(u=this.lastAudioCodec),u&&(u=-1!==u.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5")),this.pendingBuffering=!0,this.appended=!1,It.b.log("Parsing "+l+" of ["+n.startSN+" ,"+n.endSN+"],level "+s+", cc "+e.cc);var d=this.demuxer;d||(d=this.demuxer=new se(this.hls,"main"));var h=this.media,c=h&&h.seeking,f=!c&&(n.PTSKnown||!n.live),p=n.initSegment?n.initSegment.data:[];d.push(t.payload,p,u,a.videoCodec,e,o,f,void 0)}}this.fragLoadError=0},e.prototype.onFragParsingInitSegment=function(t){var e=this.fragCurrent,r=t.frag;if(e&&"main"===t.id&&r.sn===e.sn&&r.level===e.level&&this.state===he.PARSING){var i,a,n=t.tracks;if(n.audio&&this.altAudio&&delete n.audio,a=n.audio){var o=this.levels[this.level].audioCodec,s=navigator.userAgent.toLowerCase();o&&this.audioCodecSwap&&(It.b.log("swapping playlist audio codec"),o=-1!==o.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),this.audioCodecSwitch&&1!==a.metadata.channelCount&&-1===s.indexOf("firefox")&&(o="mp4a.40.5"),-1!==s.indexOf("android")&&"audio/mpeg"!==a.container&&(o="mp4a.40.2",It.b.log("Android: force audio codec to "+o)),a.levelCodec=o,a.id=t.id}a=n.video,a&&(a.levelCodec=this.levels[this.level].videoCodec,a.id=t.id),this.hls.trigger(wt.a.BUFFER_CODECS,n);for(i in n){a=n[i],It.b.log("main track:"+i+",container:"+a.container+",codecs[level/parsed]=["+a.levelCodec+"/"+a.codec+"]");var l=a.initSegment;l&&(this.appended=!0,this.pendingBuffering=!0,this.hls.trigger(wt.a.BUFFER_APPENDING,{type:i,data:l,parent:"main",content:"initSegment"}))}this.tick()}},e.prototype.onFragParsingData=function(t){var e=this,r=this.fragCurrent,i=t.frag;if(r&&"main"===t.id&&i.sn===r.sn&&i.level===r.level&&("audio"!==t.type||!this.altAudio)&&this.state===he.PARSING){var a=this.levels[this.level],n=r;if(isNaN(t.endPTS)&&(t.endPTS=t.startPTS+r.duration,t.endDTS=t.startDTS+r.duration),It.b.log("Parsed "+t.type+",PTS:["+t.startPTS.toFixed(3)+","+t.endPTS.toFixed(3)+"],DTS:["+t.startDTS.toFixed(3)+"/"+t.endDTS.toFixed(3)+"],nb:"+t.nb+",dropped:"+(t.dropped||0)),"video"===t.type)if(n.dropped=t.dropped,n.dropped){if(!n.backtracked)return It.b.warn("missing video frame(s), backtracking fragment"),n.backtracked=!0,this.nextLoadPosition=t.startPTS,this.state=he.IDLE,this.fragPrevious=n,void this.tick();It.b.warn("Already backtracked on this fragment, appending with the gap")}else n.backtracked=!1;var o=y(a.details,n,t.startPTS,t.endPTS,t.startDTS,t.endDTS),s=this.hls;s.trigger(wt.a.LEVEL_PTS_UPDATED,{details:a.details,level:this.level,drift:o,type:t.type,start:t.startPTS,end:t.endPTS}),[t.data1,t.data2].forEach(function(r){r&&r.length&&e.state===he.PARSING&&(e.appended=!0,e.pendingBuffering=!0,s.trigger(wt.a.BUFFER_APPENDING,{type:t.type,data:r,parent:"main",content:"data"}))}),this.tick()}},e.prototype.onFragParsed=function(t){var e=this.fragCurrent,r=t.frag;e&&"main"===t.id&&r.sn===e.sn&&r.level===e.level&&this.state===he.PARSING&&(this.stats.tparsed=performance.now(),this.state=he.PARSED,this._checkAppendedParsed())},e.prototype.onAudioTrackSwitching=function(t){var e=!!t.url,r=t.id;if(!e){if(this.mediaBuffer!==this.media){It.b.log("switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var i=this.fragCurrent;i.loader&&(It.b.log("switching to main audio track, cancel main fragment load"),i.loader.abort()),this.fragCurrent=null,this.fragPrevious=null,this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),this.state=he.IDLE}var a=this.hls;a.trigger(wt.a.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),a.trigger(wt.a.AUDIO_TRACK_SWITCHED,{id:r}),this.altAudio=!1}},e.prototype.onAudioTrackSwitched=function(t){var e=t.id,r=!!this.hls.audioTracks[e].url;if(r){var i=this.videoBuffer;i&&this.mediaBuffer!==i&&(It.b.log("switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=i)}this.altAudio=r,this.tick()},e.prototype.onBufferCreated=function(t){var e=t.tracks,r=void 0,i=void 0,a=!1;for(var n in e){var o=e[n];"main"===o.id?(i=n,r=o,"video"===n&&(this.videoBuffer=e[n].buffer)):a=!0}a&&r?(It.b.log("alternate track found, use "+i+".buffered to schedule main fragment loading"),this.mediaBuffer=r.buffer):this.mediaBuffer=this.media},e.prototype.onBufferAppended=function(t){if("main"===t.parent){var e=this.state;e!==he.PARSING&&e!==he.PARSED||(this.pendingBuffering=t.pending>0,this._checkAppendedParsed())}},e.prototype._checkAppendedParsed=function(){if(!(this.state!==he.PARSED||this.appended&&this.pendingBuffering)){var t=this.fragCurrent;if(t){var e=this.mediaBuffer?this.mediaBuffer:this.media;It.b.log("main buffered : "+ue.toString(e.buffered));var r=this._bufferedFrags.filter(function(t){return te.isBuffered(e,(t.startPTS+t.endPTS)/2)});r.push(t),this._bufferedFrags=r.sort(function(t,e){return t.startPTS-e.startPTS}),this.fragPrevious=t;var i=this.stats;i.tbuffered=performance.now(),this.fragLastKbps=Math.round(8*i.total/(i.tbuffered-i.tfirst)),this.hls.trigger(wt.a.FRAG_BUFFERED,{stats:i,frag:t,id:"main"}),this.state=he.IDLE}this.tick()}},e.prototype.onError=function(t){var e=t.frag||this.fragCurrent;if(!e||"main"===e.type){var r=this.media,i=r&&te.isBuffered(r,r.currentTime)&&te.isBuffered(r,r.currentTime+.5);switch(t.details){case Dt.a.FRAG_LOAD_ERROR:case Dt.a.FRAG_LOAD_TIMEOUT:case Dt.a.KEY_LOAD_ERROR:case Dt.a.KEY_LOAD_TIMEOUT:if(!t.fatal){var a=this.fragLoadError;a?a++:a=1;var n=this.config;if(a<=n.fragLoadingMaxRetry||i||e.autoLevel&&e.level){this.fragLoadError=a,e.loadCounter=0;var o=Math.min(Math.pow(2,a-1)*n.fragLoadingRetryDelay,n.fragLoadingMaxRetryTimeout);It.b.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=he.FRAG_LOADING_WAITING_RETRY}else It.b.error("mediaController: "+t.details+" reaches max retry, redispatch as fatal ..."),t.fatal=!0,this.state=he.ERROR}break;case Dt.a.FRAG_LOOP_LOADING_ERROR:t.fatal||(i?(this._reduceMaxBufferLength(e.duration),this.state=he.IDLE):e.autoLevel&&0!==e.level||(t.fatal=!0,this.state=he.ERROR));break;case Dt.a.LEVEL_LOAD_ERROR:case Dt.a.LEVEL_LOAD_TIMEOUT:this.state!==he.ERROR&&(t.fatal?(this.state=he.ERROR,It.b.warn("streamController: "+t.details+",switch to "+this.state+" state ...")):t.levelRetry||this.state!==he.WAITING_LEVEL||(this.state=he.IDLE));break;case Dt.a.BUFFER_FULL_ERROR:"main"!==t.parent||this.state!==he.PARSING&&this.state!==he.PARSED||(i?(this._reduceMaxBufferLength(this.config.maxBufferLength),this.state=he.IDLE):(It.b.warn("buffer full error also media.currentTime is not buffered, flush everything"),this.fragCurrent=null,this.flushMainBuffer(0,Number.POSITIVE_INFINITY)))}}},e.prototype._reduceMaxBufferLength=function(t){var e=this.config;e.maxMaxBufferLength>=t&&(e.maxMaxBufferLength/=2,It.b.warn("main:reduce max buffer length to "+e.maxMaxBufferLength+"s"),this.fragLoadIdx+=2*e.fragLoadingLoopThreshold)},e.prototype._checkBuffer=function(){var t=this.media,e=this.config;if(t&&t.readyState){var r=t.currentTime,i=this.mediaBuffer?this.mediaBuffer:t,a=i.buffered;if(!this.loadedmetadata&&a.length){this.loadedmetadata=!0;var n=t.seeking?r:this.startPosition,o=te.isBuffered(i,n),s=a.start(0);(r!==n||!o&&Math.abs(n-s)1e3*e.lowBufferWatchdogPeriod){this.stallReported||(this.stallReported=!0,It.b.warn("playback stalling in low buffer @"+r),c.trigger(wt.a.ERROR,{type:Dt.b.MEDIA_ERROR,details:Dt.a.BUFFER_STALLED_ERROR,fatal:!1,buffer:p}));var v=l.nextStart,m=v-r;if(v&&m0){this.nudgeRetry=++g;var y=g*e.nudgeOffset;It.b.log("adjust currentTime from "+t.currentTime+" to next buffered @ "+v+" + nudge "+y),t.currentTime=v+y,this.stalled=void 0,c.trigger(wt.a.ERROR,{type:Dt.b.MEDIA_ERROR,details:Dt.a.BUFFER_SEEK_OVER_HOLE,fatal:!1,hole:v+y-r})}}else if(p>.5&&f>1e3*e.highBufferWatchdogPeriod)if(this.stallReported||(this.stallReported=!0,It.b.warn("playback stalling in high buffer @"+r),c.trigger(wt.a.ERROR,{type:Dt.b.MEDIA_ERROR,details:Dt.a.BUFFER_STALLED_ERROR,fatal:!1,buffer:p})),this.stalled=void 0,this.nudgeRetry=++g,g"+t),this.hls.trigger(wt.a.STREAM_STATE_TRANSITION,{previousState:e,nextState:t})}},get:function(){return this._state}},{key:"currentLevel",get:function(){var t=this.media;if(t){var e=this.getBufferedFrag(t.currentTime);if(e)return e.level}return-1}},{key:"nextBufferedFrag",get:function(){var t=this.media;return t?this.followingBufferedFrag(this.getBufferedFrag(t.currentTime)):null}},{key:"nextLevel",get:function(){var t=this.nextBufferedFrag;return t?t.level:-1}},{key:"liveSyncPosition",get:function(){return this._liveSyncPosition},set:function(t){this._liveSyncPosition=t}}]),e}(Ct),fe=ce,pe=function(){function t(t,e){for(var r=0;r0})}else l.trigger(wt.a.ERROR,{type:Dt.b.MEDIA_ERROR,details:Dt.a.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:l.url,reason:"no level with compatible codecs found in manifest"})},e.prototype.setLevelInternal=function(t){var e=this._levels,r=this.hls;if(t>=0&&t1&&a.loadErrort&&(this._level===t&&void 0!==e[t].details||this.setLevelInternal(t))}},{key:"manualLevel",get:function(){return this._manualLevel},set:function(t){this._manualLevel=t,void 0===this._startLevel&&(this._startLevel=t),-1!==t&&(this.level=t)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(t){this._firstLevel=t}},{key:"startLevel",get:function(){if(void 0===this._startLevel){var t=this.hls.config.startLevel;return void 0!==t?t:this._firstLevel}return this._startLevel},set:function(t){this._startLevel=t}},{key:"nextLoadLevel",get:function(){return-1!==this._manualLevel?this._manualLevel:this.hls.nextAutoLevel},set:function(t){this.level=t,-1===this._manualLevel&&(this.hls.nextAutoLevel=t)}}]),e}(Ct),ve=ge,me=r(3),ye=function(t){function e(r){C(this,e);var i=P(this,t.call(this,r,wt.a.MEDIA_ATTACHED,wt.a.MEDIA_DETACHING,wt.a.FRAG_PARSING_METADATA));return i.id3Track=void 0,i.media=void 0,i}return x(e,t),e.prototype.destroy=function(){Ct.prototype.destroy.call(this)},e.prototype.onMediaAttached=function(t){this.media=t.media,this.media&&(this.id3Track=this.media.addTextTrack("metadata","id3"),this.id3Track.mode="hidden")},e.prototype.onMediaDetaching=function(){this.media=void 0},e.prototype.onFragParsingMetadata=function(t){for(var e=t.frag,r=t.samples,i=window.WebKitDataCue||window.VTTCue||window.TextTrackCue,a=0;a=this.minWeight_},t.prototype.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},t.prototype.destroy=function(){},t}(),Se=Re,Ae=function(){function t(t,e){for(var r=0;r500*r.duration/s){var l=t.levels,u=Math.max(1,n.bw?n.bw/8:1e3*n.loaded/o),d=l[r.level],h=d.realBitrate?Math.max(d.realBitrate,d.bitrate):d.bitrate,c=n.total?n.total:Math.max(n.loaded,Math.round(r.duration*h/8)),f=e.currentTime,p=(c-n.loaded)/u,g=(te.bufferInfo(e,f,t.config.maxBufferHole).end-f)/s;if(g<2*r.duration/s&&p>g){var v=void 0,m=void 0;for(m=r.level-1;m>a;m--){var y=l[m].realBitrate?Math.max(l[m].realBitrate,l[m].bitrate):l[m].bitrate;if((v=r.duration*y/(6.4*u))=i;u--){var d=l[u],h=d.details,c=h?h.totalduration/h.fragments.length:e,f=!!h&&h.live,p=void 0;p=u<=t?o*r:s*r;var g=l[u].realBitrate?Math.max(l[u].realBitrate,l[u].bitrate):l[u].bitrate,v=g*c/p;if(It.b.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+u+"/"+Math.round(p)+"/"+g+"/"+c+"/"+n+"/"+v),p>g&&(!v||f&&!this.bitrateTestDelay||v=0)return c;It.b.trace("rebuffering expected to happen, lets try to find a quality level minimizing the rebuffering");var f=s?Math.min(s,i.maxStarvationDelay):i.maxStarvationDelay,p=i.abrBandWidthFactor,g=i.abrBandWidthUpFactor;if(0===h){var v=this.bitrateTestDelay;if(v){f=(s?Math.min(s,i.maxLoadingDelay):i.maxLoadingDelay)-v,It.b.trace("bitrate test took "+Math.round(1e3*v)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*f)+" ms"),p=g=1}}return c=this._findBestLevel(o,s,d,a,e,h+f,p,g,r),Math.max(c,0)}}]),e}(Ct),Le=_e,we=function(t){function e(r){G(this,e);var i=H(this,t.call(this,r,wt.a.MEDIA_ATTACHING,wt.a.MEDIA_DETACHING,wt.a.MANIFEST_PARSED,wt.a.BUFFER_RESET,wt.a.BUFFER_APPENDING,wt.a.BUFFER_CODECS,wt.a.BUFFER_EOS,wt.a.BUFFER_FLUSHING,wt.a.LEVEL_PTS_UPDATED,wt.a.LEVEL_UPDATED));return i._msDuration=null,i._levelDuration=null,i.onsbue=i.onSBUpdateEnd.bind(i),i.onsbe=i.onSBUpdateError.bind(i),i.pendingTracks={},i.tracks={},i}return j(e,t),e.prototype.destroy=function(){Ct.prototype.destroy.call(this)},e.prototype.onLevelPtsUpdated=function(t){var e=t.type,r=this.tracks.audio;if("audio"===e&&r&&"audio/mpeg"===r.container){var i=this.sourceBuffer.audio;if(Math.abs(i.timestampOffset-t.start)>.1){var a=i.updating;try{i.abort()}catch(t){a=!0,It.b.warn("can not abort audio buffer: "+t)}a?this.audioTimestampOffset=t.start:(It.b.warn("change mpeg audio timestamp offset from "+i.timestampOffset+" to "+t.start),i.timestampOffset=t.start)}}},e.prototype.onManifestParsed=function(t){var e=t.audio,r=t.video||t.levels.length&&t.audio,i=0;t.altAudio&&(e||r)&&(i=(e?1:0)+(r?1:0),It.b.log(i+" sourceBuffer(s) expected")),this.sourceBufferNb=i},e.prototype.onMediaAttaching=function(t){var e=this.media=t.media;if(e){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),e.src=URL.createObjectURL(r)}},e.prototype.onMediaDetaching=function(){It.b.log("media source detaching");var t=this.mediaSource;if(t){if("open"===t.readyState)try{t.endOfStream()}catch(t){It.b.warn("onMediaDetaching:"+t.message+" while calling endOfStream")}t.removeEventListener("sourceopen",this.onmso),t.removeEventListener("sourceended",this.onmse),t.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(wt.a.MEDIA_DETACHED)},e.prototype.onMediaSourceOpen=function(){It.b.log("media source opened"),this.hls.trigger(wt.a.MEDIA_ATTACHED,{media:this.media});var t=this.mediaSource;t&&t.removeEventListener("sourceopen",this.onmso),this.checkPendingTracks()},e.prototype.checkPendingTracks=function(){var t=this.pendingTracks,e=Object.keys(t).length;e&&(this.sourceBufferNb<=e||0===this.sourceBufferNb)&&(this.createSourceBuffers(t),this.pendingTracks={},this.doAppending())},e.prototype.onMediaSourceClose=function(){It.b.log("media source closed")},e.prototype.onMediaSourceEnded=function(){It.b.log("media source ended")},e.prototype.onSBUpdateEnd=function(){if(this.audioTimestampOffset){var t=this.sourceBuffer.audio;It.b.warn("change mpeg audio timestamp offset from "+t.timestampOffset+" to "+this.audioTimestampOffset),t.timestampOffset=this.audioTimestampOffset,delete this.audioTimestampOffset}this._needsFlush&&this.doFlush(),this._needsEos&&this.checkEos(),this.appending=!1;var e=this.parent,r=this.segments.reduce(function(t,r){return r.parent===e?t+1:t},0);this.hls.trigger(wt.a.BUFFER_APPENDED,{parent:e,pending:r}),this._needsFlush||this.doAppending(),this.updateMediaElementDuration()},e.prototype.onSBUpdateError=function(t){It.b.error("sourceBuffer error:",t),this.hls.trigger(wt.a.ERROR,{type:Dt.b.MEDIA_ERROR,details:Dt.a.BUFFER_APPENDING_ERROR,fatal:!1})},e.prototype.onBufferReset=function(){var t=this.sourceBuffer;for(var e in t){var r=t[e];try{this.mediaSource.removeSourceBuffer(r),r.removeEventListener("updateend",this.onsbue),r.removeEventListener("error",this.onsbe)}catch(t){}}this.sourceBuffer={},this.flushRange=[],this.segments=[],this.appended=0},e.prototype.onBufferCodecs=function(t){if(0===Object.keys(this.sourceBuffer).length){for(var e in t)this.pendingTracks[e]=t[e];var r=this.mediaSource;r&&"open"===r.readyState&&this.checkPendingTracks()}},e.prototype.createSourceBuffers=function(t){var e=this.sourceBuffer,r=this.mediaSource;for(var i in t)if(!e[i]){var a=t[i],n=a.levelCodec||a.codec,o=a.container+";codecs="+n;It.b.log("creating sourceBuffer("+o+")");try{var s=e[i]=r.addSourceBuffer(o);s.addEventListener("updateend",this.onsbue),s.addEventListener("error",this.onsbe),this.tracks[i]={codec:n,container:a.container},a.buffer=s}catch(t){It.b.error("error while trying to add sourceBuffer:"+t.message),this.hls.trigger(wt.a.ERROR,{type:Dt.b.MEDIA_ERROR,details:Dt.a.BUFFER_ADD_CODEC_ERROR,fatal:!1,err:t,mimeType:o})}}this.hls.trigger(wt.a.BUFFER_CREATED,{tracks:t})},e.prototype.onBufferAppending=function(t){this._needsFlush||(this.segments?this.segments.push(t):this.segments=[t],this.doAppending())},e.prototype.onBufferAppendFail=function(t){It.b.error("sourceBuffer error:",t.event),this.hls.trigger(wt.a.ERROR,{type:Dt.b.MEDIA_ERROR,details:Dt.a.BUFFER_APPENDING_ERROR,fatal:!1})},e.prototype.onBufferEos=function(t){var e=this.sourceBuffer,r=t.type;for(var i in e)r&&i!==r||e[i].ended||(e[i].ended=!0,It.b.log(i+" sourceBuffer now EOS"));this.checkEos()},e.prototype.checkEos=function(){var t=this.sourceBuffer,e=this.mediaSource;if(!e||"open"!==e.readyState)return void(this._needsEos=!1);for(var r in t){var i=t[r];if(!i.ended)return;if(i.updating)return void(this._needsEos=!0)}It.b.log("all media data available, signal endOfStream() to MediaSource and stop loading fragment");try{e.endOfStream()}catch(t){It.b.warn("exception while calling mediaSource.endOfStream()")}this._needsEos=!1},e.prototype.onBufferFlushing=function(t){this.flushRange.push({start:t.startOffset,end:t.endOffset,type:t.type}),this.flushBufferCounter=0,this.doFlush()},e.prototype.onLevelUpdated=function(t){var e=t.details;0!==e.fragments.length&&(this._levelDuration=e.totalduration+e.fragments[0].start,this.updateMediaElementDuration())},e.prototype.updateMediaElementDuration=function(){var t=this.media,e=this.mediaSource,r=this.sourceBuffer,i=this._levelDuration;if(null!==i&&t&&e&&r&&0!==t.readyState&&"open"===e.readyState){for(var a in r)if(r[a].updating)return;null===this._msDuration&&(this._msDuration=e.duration);var n=t.duration;(i>this._msDuration&&i>n||n===1/0||isNaN(n))&&(It.b.log("Updating mediasource duration to "+i.toFixed(3)),this._msDuration=e.duration=i)}},e.prototype.doFlush=function(){for(;this.flushRange.length;){var t=this.flushRange[0];if(!this.flushBuffer(t.start,t.end,t.type))return void(this._needsFlush=!0);this.flushRange.shift(),this.flushBufferCounter=0}if(0===this.flushRange.length){this._needsFlush=!1;var e=0,r=this.sourceBuffer;try{for(var i in r)e+=r[i].buffered.length}catch(t){It.b.error("error while accessing sourceBuffer.buffered")}this.appended=e,this.hls.trigger(wt.a.BUFFER_FLUSHED)}},e.prototype.doAppending=function(){var t=this.hls,e=this.sourceBuffer,r=this.segments;if(Object.keys(e).length){if(this.media.error)return this.segments=[],void It.b.error("trying to append although a media error occured, flush segment and abort");if(this.appending)return;if(r&&r.length){var i=r.shift();try{var a=i.type,n=e[a];n?n.updating?r.unshift(i):(n.ended=!1,this.parent=i.parent,n.appendBuffer(i.data),this.appendError=0,this.appended++,this.appending=!0):this.onSBUpdateEnd()}catch(e){It.b.error("error while trying to append buffer:"+e.message),r.unshift(i);var o={type:Dt.b.MEDIA_ERROR,parent:i.parent};if(22===e.code)return this.segments=[],o.details=Dt.a.BUFFER_FULL_ERROR,o.fatal=!1,void t.trigger(wt.a.ERROR,o);if(this.appendError?this.appendError++:this.appendError=1,o.details=Dt.a.BUFFER_APPEND_ERROR,this.appendError>t.config.appendErrorMaxRetry)return It.b.log("fail "+t.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),r=[],o.fatal=!0,void t.trigger(wt.a.ERROR,o);o.fatal=!1,t.trigger(wt.a.ERROR,o)}}}},e.prototype.flushBuffer=function(t,e,r){var i,a,n,o,s,l,u=this.sourceBuffer;if(Object.keys(u).length){if(It.b.log("flushBuffer,pos/start/end: "+this.media.currentTime.toFixed(3)+"/"+t+"/"+e),this.flushBufferCounter.5)return this.flushBufferCounter++,It.b.log("flush "+d+" ["+s+","+l+"], of ["+n+","+o+"], pos:"+this.media.currentTime),i.remove(s,l),!1}catch(t){It.b.warn("exception while accessing sourcebuffer, it might have been removed from MediaSource")}}}else It.b.warn("abort flushing too many retries");It.b.log("buffer flushed")}return!0},e}(Ct),De=we,Ie=function(){function t(t,e){for(var r=0;rthis.autoLevelCapping&&e.streamController.nextLevelSwitch(),this.autoLevelCapping=e.autoLevelCapping}}},e.prototype.getMaxLevel=function(t){var r=this;if(!this.levels)return-1;var i=this.levels.filter(function(i,a){return e.isLevelAllowed(a,r.restrictedLevels)&&a<=t});return e.getMaxLevelByMediaSize(i,this.mediaWidth,this.mediaHeight)},e.isLevelAllowed=function(t){return-1===(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[]).indexOf(t)},e.getMaxLevelByMediaSize=function(t,e,r){if(!t||t&&!t.length)return-1;for(var i=t.length-1,a=0;a=e||n.height>=r)&&function(t,e){return!e||(t.width!==e.width||t.height!==e.height)}(n,t[a+1])){i=a;break}}return i},Ie(e,[{key:"mediaWidth",get:function(){var t=void 0,r=this.media;return r&&(t=r.width||r.clientWidth||r.offsetWidth,t*=e.contentScaleFactor),t}},{key:"mediaHeight",get:function(){var t=void 0,r=this.media;return r&&(t=r.height||r.clientHeight||r.offsetHeight,t*=e.contentScaleFactor),t}}],[{key:"contentScaleFactor",get:function(){var t=1;try{t=window.devicePixelRatio}catch(t){}return t}}]),e}(Ct),Oe=ke,Ce=function(t){function e(r){return Y(this,e),z(this,t.call(this,r,wt.a.MEDIA_ATTACHING))}return X(e,t),e.prototype.destroy=function(){this.timer&&clearInterval(this.timer),this.isVideoPlaybackQualityAvailable=!1},e.prototype.onMediaAttaching=function(t){var e=this.hls.config;if(e.capLevelOnFPSDrop){"function"==typeof(this.video=t.media instanceof HTMLVideoElement?t.media:null).getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),clearInterval(this.timer),this.timer=setInterval(this.checkFPSInterval.bind(this),e.fpsDroppedMonitoringPeriod)}},e.prototype.checkFPS=function(t,e,r){var i=performance.now();if(e){if(this.lastTime){var a=i-this.lastTime,n=r-this.lastDroppedFrames,o=e-this.lastDecodedFrames,s=1e3*n/a,l=this.hls;if(l.trigger(wt.a.FPS_DROP,{currentDropped:n,currentDecoded:o,totalDroppedFrames:r}),s>0&&n>l.config.fpsDroppedMonitoringThreshold*o){var u=l.currentLevel;It.b.warn("drop FPS ratio greater than max allowed value for currentLevel: "+u),u>0&&(-1===l.autoLevelCapping||l.autoLevelCapping>=u)&&(u-=1,l.trigger(wt.a.FPS_DROP_LEVEL_CAPPING,{level:u,droppedLevel:l.currentLevel}),l.autoLevelCapping=u,l.streamController.nextLevelSwitch())}}this.lastTime=i,this.lastDroppedFrames=r,this.lastDecodedFrames=e}},e.prototype.checkFPSInterval=function(){var t=this.video;if(t)if(this.isVideoPlaybackQualityAvailable){var e=t.getVideoPlaybackQuality();this.checkFPS(t,e.totalVideoFrames,e.droppedVideoFrames)}else this.checkFPS(t,t.webkitDecodedFrameCount,t.webkitDroppedFrameCount)},e}(Ct),Pe=Ce,xe=function(){function t(e){q(this,t),e&&e.xhrSetup&&(this.xhrSetup=e.xhrSetup)}return t.prototype.destroy=function(){this.abort(),this.loader=null},t.prototype.abort=function(){var t=this.loader;t&&4!==t.readyState&&(this.stats.aborted=!0,t.abort()),window.clearTimeout(this.requestTimeout),this.requestTimeout=null,window.clearTimeout(this.retryTimeout),this.retryTimeout=null},t.prototype.load=function(t,e,r){this.context=t,this.config=e,this.callbacks=r,this.stats={trequest:performance.now(),retry:0},this.retryDelay=e.retryDelay,this.loadInternal()},t.prototype.loadInternal=function(){var t,e=this.context;t="undefined"!=typeof XDomainRequest?this.loader=new XDomainRequest:this.loader=new XMLHttpRequest;var r=this.stats;r.tfirst=0,r.loaded=0;var i=this.xhrSetup;try{if(i)try{i(t,e.url)}catch(r){t.open("GET",e.url,!0),i(t,e.url)}t.readyState||t.open("GET",e.url,!0)}catch(r){return void this.callbacks.onError({code:t.status,text:r.message},e,t)}e.rangeEnd&&t.setRequestHeader("Range","bytes="+e.rangeStart+"-"+(e.rangeEnd-1)),t.onreadystatechange=this.readystatechange.bind(this),t.onprogress=this.loadprogress.bind(this),t.responseType=e.responseType,this.requestTimeout=window.setTimeout(this.loadtimeout.bind(this),this.config.timeout),t.send()},t.prototype.readystatechange=function(t){var e=t.currentTarget,r=e.readyState,i=this.stats,a=this.context,n=this.config;if(!i.aborted&&r>=2)if(window.clearTimeout(this.requestTimeout),0===i.tfirst&&(i.tfirst=Math.max(performance.now(),i.trequest)),4===r){var o=e.status;if(o>=200&&o<300){i.tload=Math.max(i.tfirst,performance.now());var s=void 0,l=void 0;"arraybuffer"===a.responseType?(s=e.response,l=s.byteLength):(s=e.responseText,l=s.length),i.loaded=i.total=l;var u={url:e.responseURL,data:s};this.callbacks.onSuccess(u,i,a,e)}else i.retry>=n.maxRetry||o>=400&&o<499?(It.b.error(o+" while loading "+a.url),this.callbacks.onError({code:o,text:e.statusText},a,e)):(It.b.warn(o+" while loading "+a.url+", retrying in "+this.retryDelay+"..."),this.destroy(),this.retryTimeout=window.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,n.maxRetryDelay),i.retry++)}else this.requestTimeout=window.setTimeout(this.loadtimeout.bind(this),n.timeout)},t.prototype.loadtimeout=function(){It.b.warn("timeout while loading "+this.context.url),this.callbacks.onTimeout(this.stats,this.context,null)},t.prototype.loadprogress=function(t){var e=t.currentTarget,r=this.stats;r.loaded=t.loaded,t.lengthComputable&&(r.total=t.total);var i=this.callbacks.onProgress;i&&i(r,this.context,null,e)},t}(),Fe=xe,Ne=function(){function t(t,e){for(var r=0;r1&&setTimeout(this.tick,1),this.ticks=0)},e.prototype.doTick=function(){this.updateTrack(this.trackId)},e.prototype.onError=function(t){t.fatal&&t.type===Dt.b.NETWORK_ERROR&&this.cleanTimer()},e.prototype.onManifestLoading=function(){this.tracks=[],this.trackId=-1},e.prototype.onManifestLoaded=function(t){var e=this,r=t.audioTracks||[],i=!1;this.tracks=r,this.hls.trigger(wt.a.AUDIO_TRACKS_UPDATED,{audioTracks:r});var a=0;r.forEach(function(t){if(t.default&&!i)return e.audioTrack=a,void(i=!0);a++}),!1===i&&r.length&&(It.b.log("no default audio track defined, use first audio track as default"),this.audioTrack=0)},e.prototype.onAudioTrackLoaded=function(t){t.id=0&&t=0&&t0&&-1===t?(It.b.log("audio:override startPosition with lastCurrentTime @"+e.toFixed(3)),this.state=Ge.IDLE):(this.lastCurrentTime=this.startPosition?this.startPosition:t,this.state=Ge.STARTING),this.nextLoadPosition=this.startPosition=this.lastCurrentTime,this.tick()}else this.startPosition=t,this.state=Ge.STOPPED},e.prototype.stopLoad=function(){var t=this.fragCurrent;t&&(t.loader&&t.loader.abort(),this.fragCurrent=null),this.fragPrevious=null,this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),this.state=Ge.STOPPED},e.prototype.tick=function(){1===++this.ticks&&(this.doTick(),this.ticks>1&&setTimeout(this.tick,1),this.ticks=0)},e.prototype.doTick=function(){var t,e,r,i=this.hls,a=i.config;switch(this.state){case Ge.ERROR:case Ge.PAUSED:case Ge.BUFFER_FLUSHING:break;case Ge.STARTING:this.state=Ge.WAITING_TRACK,this.loadedmetadata=!1;break;case Ge.IDLE:var n=this.tracks;if(!n)break;if(!this.media&&(this.startFragRequested||!a.startFragPrefetch))break;if(this.loadedmetadata)t=this.media.currentTime;else if(void 0===(t=this.nextLoadPosition))break;var o=this.mediaBuffer?this.mediaBuffer:this.media,s=te.bufferInfo(o,t,a.maxBufferHole),l=s.len,u=s.end,d=this.fragPrevious,h=a.maxMaxBufferLength,c=this.audioSwitch,f=this.trackId;if((lv||s.nextStart))return;It.b.log("alt audio track ahead of main track, seek to start of alt audio track"),this.media.currentTime=v+.05}if(r.initSegment&&!r.initSegment.data)y=r.initSegment;else if(u<=v){if(y=p[0],null!==this.videoTrackCC&&y.cc!==this.videoTrackCC&&(y=T(p,this.videoTrackCC)),r.live&&y.loadIdx&&y.loadIdx===this.fragLoadIdx){var b=s.nextStart?s.nextStart:v;return It.b.log("no alt audio available @currentTime:"+this.media.currentTime+", seeking @"+(b+.05)),void(this.media.currentTime=b+.05)}}else{var E=void 0,R=a.maxFragLookUpTolerance,S=d?p[d.sn-p[0].sn+1]:void 0,A=function(t){var e=Math.min(R,t.duration);return t.start+t.duration-e<=u?1:t.start-e>u&&t.start?-1:0};um-R&&(R=0),E=S&&!A(S)?S:$t.search(p,A)):E=p[g-1],E&&(y=E,v=E.start,d&&y.level===d.level&&y.sn===d.sn&&(y.sn_&&Math.abs(this.fragLoadIdx-y.loadIdx)<_)return void i.trigger(wt.a.ERROR,{type:Dt.b.MEDIA_ERROR,details:Dt.a.FRAG_LOOP_LOADING_ERROR,fatal:!1,frag:y})}else y.loadCounter=1;y.loadIdx=this.fragLoadIdx,this.fragCurrent=y,this.startFragRequested=!0,isNaN(y.sn)||(this.nextLoadPosition=y.start+y.duration),i.trigger(wt.a.FRAG_LOADING,{frag:y}),this.state=Ge.FRAG_LOADING}}break;case Ge.WAITING_TRACK:e=this.tracks[this.trackId],e&&e.details&&(this.state=Ge.IDLE);break;case Ge.FRAG_LOADING_WAITING_RETRY:var L=performance.now(),w=this.retryDate;o=this.media;var D=o&&o.seeking;(!w||L>=w||D)&&(It.b.log("audioStreamController: retryDate reached, switch back to IDLE state"),this.state=Ge.IDLE);break;case Ge.WAITING_INIT_PTS:var I=this.videoTrackCC;if(void 0===this.initPTS[I])break;var k=this.waitingFragment;if(k){var O=k.frag.cc;I!==O?(e=this.tracks[this.trackId],e.details&&e.details.live&&(It.b.warn("Waiting fragment CC ("+O+") does not match video track CC ("+I+")"),this.waitingFragment=null,this.state=Ge.IDLE)):(this.state=Ge.FRAG_LOADING,this.onFragLoaded(this.waitingFragment),this.waitingFragment=null)}else this.state=Ge.IDLE;break;case Ge.STOPPED:case Ge.FRAG_LOADING:case Ge.PARSING:case Ge.PARSED:case Ge.ENDED:}},e.prototype.onMediaAttached=function(t){var e=this.media=this.mediaBuffer=t.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),e.addEventListener("seeking",this.onvseeking),e.addEventListener("ended",this.onvended);var r=this.config;this.tracks&&r.autoStartLoad&&this.startLoad(r.startPosition)},e.prototype.onMediaDetaching=function(){var t=this.media;t&&t.ended&&(It.b.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0);var e=this.tracks;e&&e.forEach(function(t){t.details&&t.details.fragments.forEach(function(t){t.loadCounter=void 0})}),t&&(t.removeEventListener("seeking",this.onvseeking),t.removeEventListener("ended",this.onvended),this.onvseeking=this.onvseeked=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.stopLoad()},e.prototype.onMediaSeeking=function(){this.state===Ge.ENDED&&(this.state=Ge.IDLE),this.media&&(this.lastCurrentTime=this.media.currentTime),void 0!==this.fragLoadIdx&&(this.fragLoadIdx+=2*this.config.fragLoadingLoopThreshold),this.tick()},e.prototype.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},e.prototype.onAudioTracksUpdated=function(t){It.b.log("audio tracks updated"),this.tracks=t.audioTracks},e.prototype.onAudioTrackSwitching=function(t){var e=!!t.url;this.trackId=t.id,this.fragCurrent=null,this.state=Ge.PAUSED,this.waitingFragment=null,e?this.timer||(this.timer=setInterval(this.ontick,100)):this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),e&&(this.audioSwitch=!0,this.state=Ge.IDLE,void 0!==this.fragLoadIdx&&(this.fragLoadIdx+=2*this.config.fragLoadingLoopThreshold)),this.tick()},e.prototype.onAudioTrackLoaded=function(t){var e=t.details,r=t.id,i=this.tracks[r],a=e.totalduration,n=0;if(It.b.log("track "+r+" loaded ["+e.startSN+","+e.endSN+"],duration:"+a),e.live){var o=i.details;o&&e.fragments.length>0?(b(o,e),n=e.fragments[0].start,e.PTSKnown?It.b.log("live audio playlist sliding:"+n.toFixed(3)):It.b.log("live audio playlist - outdated PTS, unknown sliding")):(e.PTSKnown=!1,It.b.log("live audio playlist - first load, unknown sliding"))}else e.PTSKnown=!1;if(i.details=e,!this.startFragRequested){if(-1===this.startPosition){var s=e.startTimeOffset;isNaN(s)?this.startPosition=0:(It.b.log("start time offset found in playlist, adjust startPosition to "+s),this.startPosition=s)}this.nextLoadPosition=this.startPosition}this.state===Ge.WAITING_TRACK&&(this.state=Ge.IDLE),this.tick()},e.prototype.onKeyLoaded=function(){this.state===Ge.KEY_LOADING&&(this.state=Ge.IDLE,this.tick())},e.prototype.onFragLoaded=function(t){var e=this.fragCurrent,r=t.frag;if(this.state===Ge.FRAG_LOADING&&e&&"audio"===r.type&&r.level===e.level&&r.sn===e.sn){var i=this.tracks[this.trackId],a=i.details,n=a.totalduration,o=e.level,s=e.sn,l=e.cc,u=this.config.defaultAudioCodec||i.audioCodec||"mp4a.40.2",d=this.stats=t.stats;if("initSegment"===s)this.state=Ge.IDLE,d.tparsed=d.tbuffered=performance.now(),a.initSegment.data=t.payload,this.hls.trigger(wt.a.FRAG_BUFFERED,{stats:d,frag:e,id:"audio"}),this.tick();else{this.state=Ge.PARSING,this.appended=!1,this.demuxer||(this.demuxer=new se(this.hls,"audio"));var h=this.initPTS[l],c=a.initSegment?a.initSegment.data:[];if(a.initSegment||void 0!==h){this.pendingBuffering=!0,It.b.log("Demuxing "+s+" of ["+a.startSN+" ,"+a.endSN+"],track "+o);this.demuxer.push(t.payload,c,u,null,e,n,!1,h)}else It.b.log("unknown video PTS for continuity counter "+l+", waiting for video PTS before demuxing audio frag "+s+" of ["+a.startSN+" ,"+a.endSN+"],track "+o),this.waitingFragment=t,this.state=Ge.WAITING_INIT_PTS}}this.fragLoadError=0},e.prototype.onFragParsingInitSegment=function(t){var e=this.fragCurrent,r=t.frag;if(e&&"audio"===t.id&&r.sn===e.sn&&r.level===e.level&&this.state===Ge.PARSING){var i=t.tracks,a=void 0;if(i.video&&delete i.video,a=i.audio){a.levelCodec=a.codec,a.id=t.id,this.hls.trigger(wt.a.BUFFER_CODECS,i),It.b.log("audio track:audio,container:"+a.container+",codecs[level/parsed]=["+a.levelCodec+"/"+a.codec+"]");var n=a.initSegment;if(n){var o={type:"audio",data:n,parent:"audio",content:"initSegment"};this.audioSwitch?this.pendingData=[o]:(this.appended=!0,this.pendingBuffering=!0,this.hls.trigger(wt.a.BUFFER_APPENDING,o))}this.tick()}}},e.prototype.onFragParsingData=function(t){var e=this,r=this.fragCurrent,i=t.frag;if(r&&"audio"===t.id&&"audio"===t.type&&i.sn===r.sn&&i.level===r.level&&this.state===Ge.PARSING){var a=this.trackId,n=this.tracks[a],o=this.hls;isNaN(t.endPTS)&&(t.endPTS=t.startPTS+r.duration,t.endDTS=t.startDTS+r.duration),It.b.log("parsed "+t.type+",PTS:["+t.startPTS.toFixed(3)+","+t.endPTS.toFixed(3)+"],DTS:["+t.startDTS.toFixed(3)+"/"+t.endDTS.toFixed(3)+"],nb:"+t.nb),y(n.details,r,t.startPTS,t.endPTS);var s=this.audioSwitch,l=this.media,u=!1;if(s&&l)if(l.readyState){var d=l.currentTime;It.b.log("switching audio track : currentTime:"+d),d>=t.startPTS&&(It.b.log("switching audio track : flushing all audio"),this.state=Ge.BUFFER_FLUSHING,o.trigger(wt.a.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),u=!0,this.audioSwitch=!1,o.trigger(wt.a.AUDIO_TRACK_SWITCHED,{id:a}))}else this.audioSwitch=!1,o.trigger(wt.a.AUDIO_TRACK_SWITCHED,{id:a});var h=this.pendingData;this.audioSwitch||([t.data1,t.data2].forEach(function(e){e&&e.length&&h.push({type:t.type,data:e,parent:"audio",content:"data"})}),!u&&h.length&&(h.forEach(function(t){e.state===Ge.PARSING&&(e.pendingBuffering=!0,e.hls.trigger(wt.a.BUFFER_APPENDING,t))}),this.pendingData=[],this.appended=!0)),this.tick()}},e.prototype.onFragParsed=function(t){var e=this.fragCurrent,r=t.frag;e&&"audio"===t.id&&r.sn===e.sn&&r.level===e.level&&this.state===Ge.PARSING&&(this.stats.tparsed=performance.now(),this.state=Ge.PARSED,this._checkAppendedParsed())},e.prototype.onBufferCreated=function(t){var e=t.tracks.audio;e&&(this.mediaBuffer=e.buffer,this.loadedmetadata=!0)},e.prototype.onBufferAppended=function(t){if("audio"===t.parent){var e=this.state;e!==Ge.PARSING&&e!==Ge.PARSED||(this.pendingBuffering=t.pending>0,this._checkAppendedParsed())}},e.prototype._checkAppendedParsed=function(){if(!(this.state!==Ge.PARSED||this.appended&&this.pendingBuffering)){var t=this.fragCurrent,e=this.stats,r=this.hls;if(t){this.fragPrevious=t,e.tbuffered=performance.now(),r.trigger(wt.a.FRAG_BUFFERED,{stats:e,frag:t,id:"audio"});var i=this.mediaBuffer?this.mediaBuffer:this.media;It.b.log("audio buffered : "+ue.toString(i.buffered)),this.audioSwitch&&this.appended&&(this.audioSwitch=!1,r.trigger(wt.a.AUDIO_TRACK_SWITCHED,{id:this.trackId})),this.state=Ge.IDLE}this.tick()}},e.prototype.onError=function(t){var e=t.frag;if(!e||"audio"===e.type)switch(t.details){case Dt.a.FRAG_LOAD_ERROR:case Dt.a.FRAG_LOAD_TIMEOUT:if(!t.fatal){var r=this.fragLoadError;r?r++:r=1;var i=this.config;if(r<=i.fragLoadingMaxRetry){this.fragLoadError=r,e.loadCounter=0;var a=Math.min(Math.pow(2,r-1)*i.fragLoadingRetryDelay,i.fragLoadingMaxRetryTimeout);It.b.warn("audioStreamController: frag loading failed, retry in "+a+" ms"),this.retryDate=performance.now()+a,this.state=Ge.FRAG_LOADING_WAITING_RETRY}else It.b.error("audioStreamController: "+t.details+" reaches max retry, redispatch as fatal ..."),t.fatal=!0,this.state=Ge.ERROR}break;case Dt.a.FRAG_LOOP_LOADING_ERROR:case Dt.a.AUDIO_TRACK_LOAD_ERROR:case Dt.a.AUDIO_TRACK_LOAD_TIMEOUT:case Dt.a.KEY_LOAD_ERROR:case Dt.a.KEY_LOAD_TIMEOUT:this.state!==Ge.ERROR&&(this.state=t.fatal?Ge.ERROR:Ge.IDLE,It.b.warn("audioStreamController: "+t.details+" while loading frag,switch to "+this.state+" state ..."));break;case Dt.a.BUFFER_FULL_ERROR:if("audio"===t.parent&&(this.state===Ge.PARSING||this.state===Ge.PARSED)){var n=this.mediaBuffer,o=this.media.currentTime;if(n&&te.isBuffered(n,o)&&te.isBuffered(n,o+.5)){var s=this.config;s.maxMaxBufferLength>=s.maxBufferLength&&(s.maxMaxBufferLength/=2,It.b.warn("audio:reduce max buffer length to "+s.maxMaxBufferLength+"s"),this.fragLoadIdx+=2*s.fragLoadingLoopThreshold),this.state=Ge.IDLE}else It.b.warn("buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,this.state=Ge.BUFFER_FLUSHING,this.hls.trigger(wt.a.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"})}}},e.prototype.onBufferFlushed=function(){var t=this,e=this.pendingData;e&&e.length?(It.b.log("appending pending audio data on Buffer Flushed"),e.forEach(function(e){t.hls.trigger(wt.a.BUFFER_APPENDING,e)}),this.appended=!0,this.pendingData=[],this.state=Ge.PARSED):(this.state=Ge.IDLE,this.fragPrevious=null,this.tick())},Be(e,[{key:"state",set:function(t){if(this.state!==t){var e=this.state;this._state=t,It.b.log("audio stream:"+e+"->"+t)}},get:function(){return this._state}}]),e}(Ct),je=He,Ke=function(){function t(t){return"string"==typeof t&&(!!n[t.toLowerCase()]&&t.toLowerCase())}function e(t){return"string"==typeof t&&(!!o[t.toLowerCase()]&&t.toLowerCase())}function r(t){for(var e=1;e100)throw new Error("Position must be between 0 and 100.");E=t,this.hasBeenReset=!0}})),Object.defineProperty(s,"positionAlign",r({},u,{get:function(){return T},set:function(t){var r=e(t);if(!r)throw new SyntaxError("An invalid or illegal string was specified.");T=r,this.hasBeenReset=!0}})),Object.defineProperty(s,"size",r({},u,{get:function(){return R},set:function(t){if(t<0||t>100)throw new Error("Size must be between 0 and 100.");R=t,this.hasBeenReset=!0}})),Object.defineProperty(s,"align",r({},u,{get:function(){return S},set:function(t){var r=e(t);if(!r)throw new SyntaxError("An invalid or illegal string was specified.");S=r,this.hasBeenReset=!0}})),s.displayState=void 0,l)return s}if("undefined"!=typeof window&&window.VTTCue)return window.VTTCue;var a="auto",n={"":!0,lr:!0,rl:!0},o={start:!0,middle:!0,end:!0,left:!0,right:!0};return i.prototype.getCueAsHTML=function(){return window.WebVTT.convertCueToDOMTree(window,this.text)},i}(),We=function(){return{decode:function(t){if(!t)return"";if("string"!=typeof t)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(t))}}};at.prototype={set:function(t,e){this.get(t)||""===e||(this.values[t]=e)},get:function(t,e,r){return r?this.has(t)?this.values[t]:e[r]:this.has(t)?this.values[t]:e},has:function(t){return t in this.values},alt:function(t,e,r){for(var i=0;i=0&&e<=100)&&(this.set(t,e),!0)}};var Ve=new Ke(0,0,0),Ye="middle"===Ve.align?"middle":"center";rt.prototype={parse:function(t){function e(){var t=r.buffer,e=0;for(t=st(t);e=r&&console.log(this.time+" ["+t+"] "+e)}},ar=function(t){for(var e=[],r=0;rJe&&(ir.log("ERROR","Too large cursor position "+this.pos),this.pos=Je)},t.prototype.moveCursor=function(t){var e=this.pos+t;if(t>1)for(var r=this.pos+1;r=144&&this.backSpace();var e=qe(t);if(this.pos>=Je)return void ir.log("ERROR","Cannot insert "+t.toString(16)+" ("+e+") at position "+this.pos+". Skipping it!");this.chars[this.pos].setChar(e,this.currPenState),this.moveCursor(1)},t.prototype.clearFromPos=function(t){var e;for(e=t;e0&&(r=t?"["+e.join(" | ")+"]":e.join("\n")),r},t.prototype.getTextAndFormat=function(){return this.rows},t}(),ur=function(){function t(e,r){ut(this,t),this.chNr=e,this.outputFilter=r,this.mode=null,this.verbose=0,this.displayedMemory=new lr,this.nonDisplayedMemory=new lr,this.lastOutputScreen=new lr,this.currRollUpRow=this.displayedMemory.rows[Qe-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}return t.prototype.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.currRollUpRow=this.displayedMemory.rows[Qe-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.lastCueEndTime=null},t.prototype.getHandler=function(){return this.outputFilter},t.prototype.setHandler=function(t){this.outputFilter=t},t.prototype.setPAC=function(t){this.writeScreen.setPAC(t)},t.prototype.setBkgData=function(t){this.writeScreen.setBkgData(t)},t.prototype.setMode=function(t){t!==this.mode&&(this.mode=t,ir.log("INFO","MODE="+t),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=t)},t.prototype.insertChars=function(t){for(var e=0;e=46,e.italics)e.foreground="white";else{var r=Math.floor(t/2)-16,i=["white","green","blue","cyan","red","yellow","magenta"];e.foreground=i[r]}ir.log("INFO","MIDROW: "+JSON.stringify(e)),this.writeScreen.setPen(e)},t.prototype.outputDataUpdate=function(){var t=ir.time;null!==t&&this.outputFilter&&(this.outputFilter.updateData&&this.outputFilter.updateData(t,this.displayedMemory),null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),this.cueStartTime=this.displayedMemory.isEmpty()?null:t):this.cueStartTime=t,this.lastOutputScreen.copy(this.displayedMemory))},t.prototype.cueSplitAtTime=function(t){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,t,this.displayedMemory),this.cueStartTime=t))},t}(),dr=function(){function t(e,r,i){ut(this,t),this.field=e||1,this.outputs=[r,i],this.channels=[new ur(1,r),new ur(2,i)],this.currChNr=-1,this.lastCmdA=null,this.lastCmdB=null,this.bufferedData=[],this.startTime=null,this.lastTime=null,this.dataCounters={padding:0,char:0,cmd:0,other:0}}return t.prototype.getHandler=function(t){return this.channels[t].getHandler()},t.prototype.setHandler=function(t,e){this.channels[t].setHandler(e)},t.prototype.addData=function(t,e){var r,i,a,n=!1;this.lastTime=t,ir.setTime(t);for(var o=0;o ("+ar([i,a])+")"),r=this.parseCmd(i,a),r||(r=this.parseMidrow(i,a)),r||(r=this.parsePAC(i,a)),r||(r=this.parseBackgroundAttributes(i,a)),!r&&(n=this.parseChars(i,a)))if(this.currChNr&&this.currChNr>=0){var s=this.channels[this.currChNr-1];s.insertChars(n)}else ir.log("WARNING","No channel found yet. TEXT-MODE?");r?this.dataCounters.cmd+=2:n?this.dataCounters.char+=2:(this.dataCounters.other+=2,ir.log("WARNING","Couldn't parse cleaned data "+ar([i,a])+" orig: "+ar([e[o],e[o+1]])))}else this.dataCounters.padding+=2},t.prototype.parseCmd=function(t,e){var r=null,i=(20===t||28===t)&&32<=e&&e<=47,a=(23===t||31===t)&&33<=e&&e<=35;if(!i&&!a)return!1;if(t===this.lastCmdA&&e===this.lastCmdB)return this.lastCmdA=null,this.lastCmdB=null,ir.log("DEBUG","Repeated command ("+ar([t,e])+") is dropped"),!0;r=20===t||23===t?1:2;var n=this.channels[r-1];return 20===t||28===t?32===e?n.ccRCL():33===e?n.ccBS():34===e?n.ccAOF():35===e?n.ccAON():36===e?n.ccDER():37===e?n.ccRU(2):38===e?n.ccRU(3):39===e?n.ccRU(4):40===e?n.ccFON():41===e?n.ccRDC():42===e?n.ccTR():43===e?n.ccRTD():44===e?n.ccEDM():45===e?n.ccCR():46===e?n.ccENM():47===e&&n.ccEOC():n.ccTO(e-32),this.lastCmdA=t,this.lastCmdB=e,this.currChNr=r,!0},t.prototype.parseMidrow=function(t,e){var r=null;if((17===t||25===t)&&32<=e&&e<=47){if((r=17===t?1:2)!==this.currChNr)return ir.log("ERROR","Mismatch channel in midrow parsing"),!1;return this.channels[r-1].ccMIDROW(e),ir.log("DEBUG","MIDROW ("+ar([t,e])+")"),!0}return!1},t.prototype.parsePAC=function(t,e){var r=null,i=null,a=(17<=t&&t<=23||25<=t&&t<=31)&&64<=e&&e<=127,n=(16===t||24===t)&&64<=e&&e<=95;if(!a&&!n)return!1;if(t===this.lastCmdA&&e===this.lastCmdB)return this.lastCmdA=null,this.lastCmdB=null,!0;r=t<=23?1:2,i=64<=e&&e<=95?1===r?$e[t]:tr[t]:1===r?Ze[t]:er[t];var o=this.interpretPAC(i,e);return this.channels[r-1].setPAC(o),this.lastCmdA=t,this.lastCmdB=e,this.currChNr=r,!0},t.prototype.interpretPAC=function(t,e){var r=e,i={color:null,italics:!1,indent:null,underline:!1,row:t};return r=e>95?e-96:e-64,i.underline=1==(1&r),r<=13?i.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(i.italics=!0,i.color="white"):i.indent=4*Math.floor((r-16)/2),i},t.prototype.parseChars=function(t,e){var r=null,i=null,a=null;if(t>=25?(r=2,a=t-8):(r=1,a=t),17<=a&&a<=19){var n=e;n=17===a?e+80:18===a?e+112:e+144,ir.log("INFO","Special char '"+qe(n)+"' in channel "+r),i=[n]}else 32<=t&&t<=127&&(i=0===e?[t]:[t,e]);if(i){var o=ar(i);ir.log("DEBUG","Char codes = "+o.join(",")),this.lastCmdA=null,this.lastCmdB=null}return i},t.prototype.parseBackgroundAttributes=function(t,e){var r,i,a,n,o=(16===t||24===t)&&32<=e&&e<=47,s=(23===t||31===t)&&45<=e&&e<=47;return!(!o&&!s)&&(r={},16===t||24===t?(i=Math.floor((e-32)/2),r.background=rr[i],e%2==1&&(r.background=r.background+"_semi")):45===e?r.background="transparent":(r.foreground="black",47===e&&(r.underline=!0)),a=t<24?1:2,n=this.channels[a-1],n.setBkgData(r),this.lastCmdA=null,this.lastCmdB=null,!0)},t.prototype.reset=function(){for(var t=0;t9?parseInt(t.substr(0,t.indexOf(":"))):0;return isNaN(e)||isNaN(r)||isNaN(i)||isNaN(a)?-1:(e+=1e3*r,e+=6e4*i,e+=36e5*a)},pr=function(t){for(var e=5381,r=t.length;r;)e=33*e^t.charCodeAt(--r);return(e>>>0).toString()},gr=function(t,e,r){var i=t[e],a=t[i.prevCC];if(!a||!a.new&&i.new)return t.ccOffset=t.presentationOffset=i.start,void(i.new=!1);for(;a&&a.new;)t.ccOffset+=i.start-a.start,i.new=!1,i=a,a=t[i.prevCC];t.presentationOffset=r},vr={parse:function(t,e,r,i,a,n){var o=/\r\n|\n\r|\n|\r/g,s=String.fromCharCode.apply(null,new Uint8Array(t)).trim().replace(o,"\n").split("\n"),l="00:00.000",u=0,d=0,h=0,c=[],f=void 0,p=!0,g=new ze;g.oncue=function(t){var e=r[i],a=r.ccOffset;e&&e.new&&(void 0!==d?a=r.ccOffset=e.start:gr(r,i,h)),h&&(a=h+r.ccOffset-r.presentationOffset),t.startTime+=a-d,t.endTime+=a-d,t.id=pr(t.startTime)+pr(t.endTime)+pr(t.text),t.text=decodeURIComponent(escape(t.text)),t.endTime>0&&c.push(t)},g.onparsingerror=function(t){f=t},g.onflush=function(){if(f&&n)return void n(f);a(c)},s.forEach(function(t){if(p){if(cr(t,"X-TIMESTAMP-MAP=")){p=!1,t.substr(16).split(",").forEach(function(t){cr(t,"LOCAL:")?l=t.substr(6):cr(t,"MPEGTS:")&&(u=parseInt(t.substr(7)))});try{e=e<0?e+8589934592:e,u-=e,d=fr(l)/1e3,h=u/9e4,-1===d&&(f=new Error("Malformed X-TIMESTAMP-MAP: "+t))}catch(e){f=new Error("Malformed X-TIMESTAMP-MAP: "+t)}return}""===t&&(p=!1)}g.parse(t+"\n")}),g.flush()}},mr=vr,yr=function(t){function e(r){dt(this,e);var i=ht(this,t.call(this,r,wt.a.MEDIA_ATTACHING,wt.a.MEDIA_DETACHING,wt.a.FRAG_PARSING_USERDATA,wt.a.MANIFEST_LOADING,wt.a.MANIFEST_LOADED,wt.a.FRAG_LOADED,wt.a.LEVEL_SWITCHING,wt.a.INIT_PTS_FOUND));if(i.hls=r,i.config=r.config,i.enabled=!0,i.Cues=r.config.cueHandler,i.textTracks=[],i.tracks=[],i.unparsedVttFrags=[],i.initPTS=void 0,i.cueRanges=[],i.config.enableCEA708Captions){var a=i,n=function(t,e){var r=null;try{r=new window.Event("addtrack")}catch(t){r=document.createEvent("Event"),r.initEvent("addtrack",!1,!1)}r.track=t,e.dispatchEvent(r)},o={newCue:function(t,e,r){if(!a.textTrack1){var i=a.getExistingTrack("1");if(i)a.textTrack1=i,ft(a.textTrack1),n(a.textTrack1,a.media);else{var o=a.createTextTrack("captions",a.config.captionsTextTrack1Label,a.config.captionsTextTrack1LanguageCode);o&&(o.textTrack1=!0,a.textTrack1=o)}}a.addCues("textTrack1",t,e,r)}},s={newCue:function(t,e,r){if(!a.textTrack2){var i=a.getExistingTrack("2");if(i)a.textTrack2=i,ft(a.textTrack2),n(a.textTrack2,a.media);else{var o=a.createTextTrack("captions",a.config.captionsTextTrack2Label,a.config.captionsTextTrack1LanguageCode);o&&(o.textTrack2=!0,a.textTrack2=o)}}a.addCues("textTrack2",t,e,r)}};i.cea608Parser=new hr(0,o,s)}return i}return ct(e,t),e.prototype.addCues=function(t,e,r,i){for(var a=this.cueRanges,n=!1,o=a.length;o--;){var s=a[o],l=gt(s[0],s[1],e,r);if(l>=0&&(s[0]=Math.min(s[0],e),s[1]=Math.max(s[1],r),n=!0,l/(r-e)>.5))return}n||a.push([e,r]),this.Cues.newCue(this[t],e,r,i)},e.prototype.onInitPtsFound=function(t){var e=this;void 0===this.initPTS&&(this.initPTS=t.initPTS),this.unparsedVttFrags.length&&(this.unparsedVttFrags.forEach(function(t){e.onFragLoaded(t)}),this.unparsedVttFrags=[])},e.prototype.getExistingTrack=function(t){var e=this.media;if(e)for(var r=0;r=0&&t-1&&this.vttFragQueues[this.currentTrackId].length){var t=this.currentlyProcessing=this.vttFragQueues[this.currentTrackId].shift();this.hls.trigger(wt.a.FRAG_LOADING,{frag:t})}},e.prototype.onSubtitleFragProcessed=function(t){t.success&&this.vttFragSNsProcessed[t.frag.trackId].push(t.frag.sn),this.currentlyProcessing=null,this.nextFrag()},e.prototype.onError=function(t){var e=t.frag;e&&"subtitle"!==e.type||this.currentlyProcessing&&(this.currentlyProcessing=null,this.nextFrag())},e.prototype.onSubtitleTracksUpdated=function(t){var e=this;It.b.log("subtitle tracks updated"),this.tracks=t.subtitleTracks,this.clearVttFragQueues(),this.vttFragSNsProcessed={},this.tracks.forEach(function(t){e.vttFragSNsProcessed[t.id]=[]})},e.prototype.onSubtitleTrackSwitch=function(t){this.currentTrackId=t.id,this.clearVttFragQueues()},e.prototype.onSubtitleTrackLoaded=function(t){var e=this.vttFragSNsProcessed[t.id],r=this.vttFragQueues[t.id],i=this.currentlyProcessing?this.currentlyProcessing.sn:-1,a=function(t){return e.indexOf(t.sn)>-1},n=function(t){return r.some(function(e){return e.sn===t.sn})};t.details.fragments.forEach(function(e){a(e)||e.sn===i||n(e)||(e.trackId=t.id,r.push(e))}),this.nextFrag()},e}(Ct),Ar=Sr,_r={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:.2,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:Fe,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,fetchSetup:void 0,abrController:Le,bufferController:De,capLevelController:Oe,fpsController:Pe,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};_r.subtitleStreamController=Ar,_r.subtitleTrackController=Rr,_r.timelineController=br,_r.cueHandler=At,_r.enableCEA708Captions=!0,_r.enableWebVTT=!0,_r.captionsTextTrack1Label="English",_r.captionsTextTrack1LanguageCode="en",_r.captionsTextTrack2Label="Spanish",_r.captionsTextTrack2LanguageCode="es",_r.audioStreamController=je,_r.audioTrackController=Ue;var Lr=function(){function t(t,e){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:{};St(this,t);var i=t.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 a in i)a in r||(r[a]=i[a]);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"');Object(It.a)(r.debug),this.config=r,this._autoLevelCapping=-1;var n=this.observer=new ie.a;n.trigger=function(t){for(var e=arguments.length,r=Array(e>1?e-1:0),i=1;i1?e-1:0),i=1;i0&&void 0!==arguments[0]?arguments[0]:-1;It.b.log("startLoad("+t+")"),this.networkControllers.forEach(function(e){e.startLoad(t)})},t.prototype.stopLoad=function(){It.b.log("stopLoad"),this.networkControllers.forEach(function(t){t.stopLoad()})},t.prototype.swapAudioCodec=function(){It.b.log("swapAudioCodec"),this.streamController.swapAudioCodec()},t.prototype.recoverMediaError=function(){It.b.log("recoverMediaError");var t=this.media;this.detachMedia(),this.attachMedia(t)},Lr(t,[{key:"levels",get:function(){return this.levelController.levels}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(t){It.b.log("set currentLevel:"+t),this.loadLevel=t,this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(t){It.b.log("set nextLevel:"+t),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(t){It.b.log("set loadLevel:"+t),this.levelController.manualLevel=t}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(t){this.levelController.nextLoadLevel=t}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(t){It.b.log("set firstLevel:"+t),this.levelController.firstLevel=t}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(t){It.b.log("set startLevel:"+t);var e=this;-1!==t&&(t=Math.max(t,e.minAutoLevel)),e.levelController.startLevel=t}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(t){It.b.log("set autoLevelCapping:"+t),this._autoLevelCapping=t}},{key:"autoLevelEnabled",get:function(){return-1===this.levelController.manualLevel}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){for(var t=this,e=t.levels,r=t.config.minAutoBitrate,i=e?e.length:0,a=0;ar)return a}return 0}},{key:"maxAutoLevel",get:function(){var t=this,e=t.levels,r=t.autoLevelCapping;return-1===r&&e&&e.length?e.length-1:r}},{key:"nextAutoLevel",get:function(){var t=this;return Math.min(Math.max(t.abrController.nextAutoLevel,t.minAutoLevel),t.maxAutoLevel)},set:function(t){var e=this;e.abrController.nextAutoLevel=Math.max(e.minAutoLevel,t)}},{key:"audioTracks",get:function(){var t=this.audioTrackController;return t?t.audioTracks:[]}},{key:"audioTrack",get:function(){var t=this.audioTrackController;return t?t.audioTrack:-1},set:function(t){var e=this.audioTrackController;e&&(e.audioTrack=t)}},{key:"liveSyncPosition",get:function(){return this.streamController.liveSyncPosition}},{key:"subtitleTracks",get:function(){var t=this.subtitleTrackController;return t?t.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var t=this.subtitleTrackController;return t?t.subtitleTrack:-1},set:function(t){var e=this.subtitleTrackController;e&&(e.subtitleTrack=t)}}]),t}();e.default=wr},function(t,e,r){function i(t){function e(i){if(r[i])return r[i].exports;var a=r[i]={i:i,l:!1,exports:{}};return t[i].call(a.exports,a,a.exports,e),a.l=!0,a.exports}var r={};e.m=t,e.c=r,e.i=function(t){return t},e.d=function(t,r,i){e.o(t,r)||Object.defineProperty(t,r,{configurable:!1,enumerable:!0,get:i})},e.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="/",e.oe=function(t){throw console.error(t),t};var i=e(e.s=ENTRY_MODULE);return i.default||i}function a(t){return(t+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function n(t){var e=[],r=t.toString(),i=r.match(/^function\s?\(\w+,\s*\w+,\s*(\w+)\)/);if(!i)return e;for(var n,o=i[1],s=new RegExp("(\\\\n|\\W)"+a(o)+"\\((/\\*.*?\\*/)?s?.*?([\\.|\\-|\\w|/|@]+).*?\\)","g");n=s.exec(r);)e.push(n[3]);return e}function o(t,e){for(var r=[e],i=[],a={};r.length;){var o=r.pop();if(!a[o]&&t[o]){a[o]=!0,i.push(o);var s=n(t[o]);r=r.concat(s)}}return i}t.exports=function(t,e){e=e||{};var a=r.m,n=e.all?Object.keys(a):o(a,t),s="("+i.toString().replace("ENTRY_MODULE",JSON.stringify(t))+")({"+n.map(function(t){return JSON.stringify(t)+": "+a[t].toString()}).join(",")+"})(self);",l=new window.Blob([s],{type:"text/javascript"});if(e.bare)return l;var u=window.URL||window.webkitURL||window.mozURL||window.msURL,d=u.createObjectURL(l),h=new window.Worker(d);return h.objectURL=d,h}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=r(6),a=r(1),n=r(0),o=r(4),s=r.n(o),l=function(t){var e=new s.a;e.trigger=function(t){for(var r=arguments.length,i=Array(r>1?r-1:0),a=1;a1?r-1:0),a=1;a