!function(e){if("object"==typeofexports&&"undefined"!=typeofmodule)module.exports=e();elseif("function"==typeofdefine&&define.amd)define([],e);else{vart;t="undefined"!=typeofwindow?window:"undefined"!=typeofglobal?global:"undefined"!=typeofself?self:this,t.Hls=e()}}(function(){returnfunctions(e,t,r){functioni(n,d){if(!t[n]){if(!e[n]){varl="function"==typeofrequire&&require;if(!d&&l)returnl(n,!0);if(a)returna(n,!0);varu=newError("Cannot find module '"+n+"'");throwu.code="MODULE_NOT_FOUND",u}varo=t[n]={exports:{}};e[n][0].call(o.exports,function(t){varr=e[n][1][t];returni(r?r:t)},o,o.exports,s,e,t,r)}returnt[n].exports}for(vara="function"==typeofrequire&&require,n=0;n<r.length;n++)i(r[n]);returni}({1:[function(s,n,o){functione(){this._events=this._events||{},this._maxListeners=this._maxListeners||void0}functiont(e){return"function"==typeofe}functiona(e){return"number"==typeofe}functionr(e){return"object"==typeofe&&null!==e}functioni(e){returnvoid0===e}n.exports=e,e.EventEmitter=e,e.prototype._events=void0,e.prototype._maxListeners=void0,e.defaultMaxListeners=10,e.prototype.setMaxListeners=function(e){if(!a(e)||0>e||isNaN(e))throwTypeError("n must be a positive number");returnthis._maxListeners=e,this},e.prototype.emit=function(l){vars,e,u,n,a,o;if(this._events||(this._events={}),"error"===l&&(!this._events.error||r(this._events.error)&&!this._events.error.length)){if(s=arguments[1],sinstanceofError)throws;throwTypeError('Uncaught, unspecified "error" event.')}if(e=this._events[l],i(e))return!1;if(t(e))switch(arguments.length){case1:e.call(this);break;case2:e.call(this,arguments[1]);break;case3:e.call(this,arguments[1],arguments[2]);break;default:n=Array.prototype.slice.call(arguments,1),e.apply(this,n)}elseif(r(e))for(n=Array.prototype.slice.call(arguments,1),o=e.slice(),u=o.length,a=0;u>a;a++)o[a].apply(this,n);return!0},e.prototype.addListener=function(n,a){vars;if(!t(a))throwTypeError("listener must be a function");returnthis._events||(this._events={}),this._events.newListener&&this.emit("newListener",n,t(a.listener)?a.listener:a),this._events[n]?r(this._events[n])?this._events[n].push(a):this._events[n]=[this._events[n],a]:this._events[n]=a,r(this._events[n])&&!this._events[n].warned&&(s=i(this._maxListeners)?e.defaultMaxListeners:this._maxListeners,s&&s>0&&this._events[n].length>s&&(this._events[n].warned=!0,"function"==typeofconsole.trace)),this},e.prototype.on=e.prototype.addListener,e.prototype.once=function(i,e){functionr(){this.removeListener(i,r),n||(n=!0,e.apply(this,arguments))}if(!t(e))throwTypeError("listener must be a function");varn=!1;returnr.listener=e,this.on(i,r),this},e.prototype.removeListener=function(n,i){vare,s,o,a;if(!t(i))throwTypeError("listener must be a function");if(!this._events||!this._events[n])returnthis;if(e=this._events[n],o=e.length,s=-1,e===i||t(e.listener)&&e.listener===i)deletethis._events[n],this._events.removeListener&&this.emit("removeListener",n,i);elseif(r(e)){for(a=o;a-->0;)if(e[a]===i||e[a].listener&&e[a].listener===i){s=a;break}if(0>s)returnthis;1===e.length?(e.length=0,deletethis._events[n]):e.splice(s,1),this._events.removeListener&&this.emit("removeListener",n,i)}returnthis},e.prototype.removeAllListeners=function(r){vari,e;if(!this._events)returnthis;if(!this._events.removeListener)return0===arguments.length?this._events={}:this._events[r]&&deletethis._events[r],this;if(0===arguments.length){for(iinthis._events)"removeListener"!==i&&this.removeAllListeners(i);returnthis.removeAllListeners("removeListener"),this._events={},this}if(e=this._events[r],t(e))this.removeListener(r,e);elseif(e)for(;e.length;)this.removeListener(r,e[e.length-1]);returndeletethis._events[r],this},e.prototype.listeners=function(e){varr;returnr=this._events&&this._events[e]?t(this._events[e])?[this._events[e]]:this._events[e].slice():[]},e.prototype.listenerCount=function(r){if(this._events){vare=this._events[r];if(t(e))return1;if(e)returne.length}return0},e.listenerCount=function(e,t){returne.listenerCount(t)}},{}]
this.state=e.PAUSED,this.hls.trigger(r.default.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY})}},{key:"immediateLevelSwitchEnd",value:function(){this.immediateSwitch=!1,this.media.currentTime-=1e-4,this.previouslyPaused||this.media.play()}},{key:"nextLevelSwitch",value:function(){varn,i,t;if(this.fragLoadIdx+=2*this.config.fragLoadingLoopThreshold,i=this.getBufferRange(this.media.currentTime),i&&i.start>1&&(this.state=e.PAUSED,this.hls.trigger(r.default.BUFFER_FLUSHING,{startOffset:0,endOffset:i.start-1})),this.media.paused)n=0;else{varo=this.hls.nextLoadLevel,l=this.levels[o],s=this.fragLastKbps;n=s&&this.fragCurrent?this.fragCurrent.duration*l.bitrate/(1e3*s)+1:0}if(t=this.getBufferRange(this.media.currentTime+n),t&&(t=this.followingBufferRange(t))){vara=this.fragCurrent;a&&a.loader&&a.loader.abort(),this.fragCurrent=null,this.state=e.PAUSED,this.hls.trigger(r.default.BUFFER_FLUSHING,{startOffset:t.start,endOffset:Number.POSITIVE_INFINITY})}}},{key:"onMediaAttached",value:function(t){vare=this.media=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),this.levels&&this.config.autoStartLoad&&this.hls.startLoad()}},{key:"onMediaDetaching",value:function(){vare=this.media;e&&e.ended&&(t.logger.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0);varr=this.levels;r&&r.forEach(function(e){e.details&&e.details.fragments.forEach(function(e){e.loadCounter=void0})}),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=null,this.loadedmetadata=!1,this.stopLoad()}},{key:"onMediaSeeking",value:function(){if(this.state===e.FRAG_LOADING){if(0===s.default.bufferInfo(this.media,this.media.currentTime,this.config.maxBufferHole).len){t.logger.log("seeking outside of buffer while fragment load in progress, cancel fragment load");varr=this.fragCurrent;r&&(r.loader&&r.loader.abort(),this.fragCurrent=null),this.fragPrevious=null,this.state=e.IDLE}}elsethis.state===e.ENDED&&(this.state=e.IDLE);this.media&&(this.lastCurrentTime=this.media.currentTime),void0!==this.fragLoadIdx&&(this.fragLoadIdx+=2*this.config.fragLoadingLoopThreshold),this.tick()}},{key:"onMediaSeeked",value:function(){this.tick()}},{key:"onMediaEnded",value:function(){t.logger.log("media ended"),this.startPosition=this.lastCurrentTime=0}},{key:"onManifestLoading",value:function(){t.logger.log("trigger BUFFER_RESET"),this.hls.trigger(r.default.BUFFER_RESET),this.bufferRange=[],this.stalled=!1}},{key:"onManifestParsed",value:function(r){vare,i=!1,n=!1;r.levels.forEach(function(t){e=t.audioCodec,e&&(-1!==e.indexOf("mp4a.40.2")&&(i=!0),-1!==e.indexOf("mp4a.40.5")&&(n=!0))}),this.audioCodecSwitch=i&&n,this.audioCodecSwitch&&t.logger.log("both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=r.levels,this.startLevelLoaded=!1,this.startFragRequested=!1,this.config.autoStartLoad&&this.hls.startLoad()}},{key:"onLevelLoaded",value:function(s){vari=s.details,n=s.level,o=this.levels[n],l=i.totalduration,a=0;if(t.logger.log("level "+n+" loaded ["+i.startSN+","+i.endSN+"],duration:"+l),this.levelLastLoaded=n,i.live){vard=o.details;d?(u.default.mergeDetails(d,i),a=i.fragments[0].start,i.PTSKnown?t.logger.log("live playlist sliding:"+a.toFixed(3)):t.logger.log("live playlist - outdated PTS, unknown sliding")):(i.PTSKnown=!1,t.logger.log("live playlist - first load, unknown sliding"))}elsei.PTSKnown=!1;if(o.details=i,this.hls.trigger(r.default.LEVEL_UPDATED,{details:i,level:n}),this.startFragRequested===!1){if(i.live){varf=void0!==this.config.liveSyncDuration?this.config.liveSyncDuration:this.config.liveSyncDurationCount*i.targetduration;this.startPosition=Math.max(0,a+l-f)}this.nextLoadPosition=this.startPos
switch(y){case1:e=[1,1];break;case2:e=[12,11];break;case3:e=[10,11];break;case4:e=[16,11];break;case5:e=[40,33];break;case6:e=[24,11];break;case7:e=[20,11];break;case8:e=[32,11];break;case9:e=[80,33];break;case10:e=[18,11];break;case11:e=[15,11];break;case12:e=[64,33];break;case13:e=[160,99];break;case14:e=[4,3];break;case15:e=[3,2];break;case16:e=[2,1];break;case255:e=[this.readUByte()<<8|this.readUByte(),this.readUByte()<<8|this.readUByte()]}e&&(c=e[0]/e[1])}return{width:Math.ceil((16*(n+1)-2*s-2*d)*c),height:(2-i)*(a+1)*16-(i?2:4)*(f+h)}}},{key:"readSliceType",value:function(){returnthis.readUByte(),this.readUEG(),this.readUEG()}}]),e}();e.default=a},{"../utils/logger":36}],18:[function(r,s,t){"use strict";functioni(e,t){if(!(einstanceoft))thrownewTypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});varn=function(){functione(i,r){for(vart=0;t<r.length;t++){vare=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"ine&&(e.writable=!0),Object.defineProperty(i,e.key,e)}}returnfunction(t,r,i){returnr&&e(t.prototype,r),i&&e(t,i),t}}(),e=r("../utils/logger"),a=function(){functiont(n){i(this,t),this._hasTimeStamp=!1;for(varl,u,d,f,h,s,o,a,r=0;;)if(o=this.readUTF(n,r,3),r+=3,"ID3"===o)r+=3,l=127&n[r++],u=127&n[r++],d=127&n[r++],f=127&n[r++],h=(l<<21)+(u<<14)+(d<<7)+f,s=r+h,this._parseID3Frames(n,r,s),r=s;else{if("3DI"!==o)returnr-=3,a=r,void(a&&(this.hasTimeStamp||e.logger.warn("ID3 tag found, but no timestamp"),this._length=a,this._payload=n.subarray(0,a)));r+=7,e.logger.log("3DI footer found, end: "+r)}}returnn(t,[{key:"readUTF",value:function(i,e,n){vart="",r=e,a=e+n;dot+=String.fromCharCode(i[r++]);while(a>r);returnt}},{key:"_parseID3Frames",value:function(r,t,a){for(varn,s,o,l,i;a>=t+8;)switch(n=this.readUTF(r,t,4),t+=4,s=r[t++]<<24+r[t++]<<16+r[t++]<<8+r[t++],l=r[t++]<<8+r[t++],o=t,n){case"PRIV":if("com.apple.streaming.transportStreamTimestamp"===this.readUTF(r,t,44)){t+=44,t+=4;varu=1&r[t++];this._hasTimeStamp=!0,i=((r[t++]<<23)+(r[t++]<<15)+(r[t++]<<7)+r[t++])/45,u&&(i+=47721858.84),i=Math.round(i),e.logger.trace("ID3 timestamp found: "+i),this._timeStamp=i}}}},{key:"hasTimeStamp",get:function(){returnthis._hasTimeStamp}},{key:"timeStamp",get:function(){returnthis._timeStamp}},{key:"length",get:function(){returnthis._length}},{key:"payload",get:function(){returnthis._payload}}]),t}();t.default=a},{"../utils/logger":36}],19:[function(t,v,n){"use strict";functioni(e){returne&&e.__esModule?e:{default:e}}functionu(e,t){if(!(einstanceoft))thrownewTypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});varf=function(){functione(i,r){for(vart=0;t<r.length;t++){vare=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"ine&&(e.writable=!0),Object.defineProperty(i,e.key,e)}}returnfunction(t,r,i){returnr&&e(t.prototype,r),i&&e(t,i),t}}(),h=t("./adts"),c=i(h),l=t("../events"),a=i(l),d=t("./exp-golomb"),s=i(d),e=t("../utils/logger"),r=t("../errors"),o=function(){functiont(e,r){u(this,t),this.observer=e,this.remuxerClass=r,this.lastCC=0,this.remuxer=newthis.remuxerClass(e)}returnf(t,[{key:"switchLevel",value:function(){this.pmtParsed=!1,this._pmtId=-1,this.lastAacPTS=null,this.aacOverFlow=null,this._avcTrack={container:"video/mp2t",type:"video",id:-1,sequenceNumber:0,samples:[],len:0,nbNalu:0},this._aacTrack={container:"video/mp2t",type:"audio",id:-1,sequenceNumber:0,samples:[],len:0},this._id3Track={type:"id3",id:-1,sequenceNumber:0,samples:[],len:0},this._txtTrack={type:"text",id:-1,sequenceNumber:0,samples:[],len:0},this.remuxer.switchLevel()}},{key:"insertDiscontinuity",value:function(){this.switchLevel(),this.remuxer.insertDiscontinuity()}},{key:"push",value:function(i,R,L,_,p,m,E,A){vars,o,l,t,d,u,y,n,c=i.length,b=this.remuxer.passthrough;this.audioCodec=R,this.videoCodec=L,this.timeOffset=_,this._duration=A,this.contiguous=!1,p!==this.lastCC?(e.logger.log("discontinuity detected"),this.insertDiscontinuity(),this.lastCC=p):m!==this.lastLevel?(e.logger.log("levelswitch
this.url=n,this.id=a,this.id2=s,null===this.id?(t=e.manifestLoadingMaxRetry,r=e.manifestLoadingTimeOut,i=e.manifestLoadingRetryDelay):(t=e.levelLoadingMaxRetry,r=e.levelLoadingTimeOut,i=e.levelLoadingRetryDelay),this.loader="undefined"!=typeofe.pLoader?newe.pLoader(e):newe.loader(e),this.loader.load(n,"",this.loadsuccess.bind(this),this.loaderror.bind(this),this.loadtimeout.bind(this),r,t,i)}},{key:"resolve",value:function(e,t){returnv.default.buildAbsoluteURL(t,e)}},{key:"parseMasterPlaylist",value:function(f,u){for(varl=[],i=void0,d=/#EXT-X-STREAM-INF:([^\n\r]*)[\r\n]+([^\r\n]+)/g;null!=(i=d.exec(f));){vare={},r=e.attrs=newn.default(i[1]);e.url=this.resolve(i[2],u);vars=r.decimalResolution("RESOLUTION");s&&(e.width=s.width,e.height=s.height),e.bitrate=r.decimalInteger("AVERAGE-BANDWIDTH")||r.decimalInteger("BANDWIDTH"),e.name=r.NAME;vart=r.CODECS;if(t){t=t.split(",");for(varo=0;o<t.length;o++){vara=t[o];-1!==a.indexOf("avc1")?e.videoCodec=this.avc1toavcoti(a):e.audioCodec=a}}l.push(e)}returnl}},{key:"avc1toavcoti",value:function(r){vare,t=r.split(".");returnt.length>2?(e=t.shift()+".",e+=parseInt(t.shift()).toString(16),e+=("000"+parseInt(t.shift()).toString(16)).substr(-4)):e=r,e}},{key:"cloneObj",value:function(e){returnJSON.parse(JSON.stringify(e))}},{key:"parseLevelPlaylist",value:function(L,l,A){vare,b,s,a,g=0,o=0,i={url:l,fragments:[],live:!0,startSN:0},r={method:null,key:null,iv:null,uri:null},E=0,f=null,t=null;for(b=/(?:#EXT-X-(MEDIA-SEQUENCE):(\d+))|(?:#EXT-X-(TARGETDURATION):(\d+))|(?:#EXT-X-(KEY):(.*))|(?:#EXT(INF):([\d\.]+)[^\r\n]*([\r\n]+[^#|\r\n]+)?)|(?:#EXT-X-(BYTERANGE):([\d]+[@[\d]*)]*[\r\n]+([^#|\r\n]+)?|(?:#EXT-X-(ENDLIST))|(?:#EXT-X-(DIS)CONTINUITY))|(?:#EXT-X-(PROGRAM-DATE-TIME):(.*))/g;null!==(e=b.exec(L));)switch(e.shift(),e=e.filter(function(e){returnvoid0!==e}),e[0]){case"MEDIA-SEQUENCE":g=i.startSN=parseInt(e[1]);break;case"TARGETDURATION":i.targetduration=parseFloat(e[1]);break;case"ENDLIST":i.live=!1;break;case"DIS":E++;break;case"BYTERANGE":varc=e[1].split("@");a=1===c.length?s:parseInt(c[1]),s=parseInt(c[0])+a,t&&!t.url&&(t.byteRangeStartOffset=a,t.byteRangeEndOffset=s,t.url=this.resolve(e[2],l));break;case"INF":varv=parseFloat(e[1]);if(!isNaN(v)){varu,m=g++;if(r.method&&r.uri&&!r.iv){u=this.cloneObj(r);for(vary=newUint8Array(16),d=12;16>d;d++)y[d]=m>>8*(15-d)&255;u.iv=y}elseu=r;vark=e[2]?this.resolve(e[2],l):null;t={url:k,duration:v,start:o,sn:m,level:A,cc:E,byteRangeStartOffset:a,byteRangeEndOffset:s,decryptdata:u,programDateTime:f},i.fragments.push(t),o+=v,a=null,f=null}break;case"KEY":varR=e[1],p=newn.default(R),h=p.enumeratedString("METHOD"),_=p.URI,T=p.hexadecimalInteger("IV");h&&(r={method:null,key:null,iv:null,uri:null},_&&"AES-128"===h&&(r.method=h,r.uri=this.resolve(_,l),r.key=null,r.iv=T));break;case"PROGRAM-DATE-TIME":f=newDate(Date.parse(e[1]))}returnt&&!t.url&&(i.fragments.pop(),o-=t.duration),i.totalduration=o,i.endSN=g-1,i}},{key:"loadsuccess",value:function(u,i){vars,o=u.currentTarget,a=o.responseText,r=o.responseURL,l=this.id,d=this.id2,n=this.hls;if(void0===r&&(r=this.url),i.tload=performance.now(),i.mtime=newDate(o.getResponseHeader("Last-Modified")),0===a.indexOf("#EXTM3U"))if(a.indexOf("#EXTINF:")>0)if(null===this.id)n.trigger(t.default.MANIFEST_LOADED,{levels:[{url:r}],url:r,stats:i});else{varf=this.parseLevelPlaylist(a,r,l);i.tparsed=performance.now(),n.trigger(t.default.LEVEL_LOADED,{details:f,level:l,id:d,stats:i})}elses=this.parseMasterPlaylist(a,r),s.length?n.trigger(t.default.MANIFEST_LOADED,{levels:s,url:r,stats:i}):n.trigger(t.default.ERROR,{type:e.ErrorTypes.NETWORK_ERROR,details:e.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:!0,url:r,reason:"no level found in manifest"});elsen.trigger(t.default.ERROR,{type:e.ErrorTypes.NETWORK_ERROR,details:e.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:!0,url:r,reason:"no EXTM3U delimiter"})}},{key:"loaderror",value:function(n){varr,i;null===this.id?(r=e.ErrorDetails.MANIFEST_LOAD_ERROR,i=!0):(r=e.ErrorDetails.LEVEL_LOAD_ERROR,i=!1),this.loader&&this.loader.abort(),this.hls.trigger(t.default