g){s-=g;continue}t=t.subarray(s),g-=s,s=0}n.set(t,d),d+=g}return r&&(r-=a+3),{data:n,pts:o,dts:l,len:r}}return null}},{key:"pushAccesUnit",value:function(e,t){if(e.units.length&&e.frame){var i=t.samples,r=i.length;!this.config.forceKeyFrameOnDiscontinuity||!0===e.key||t.sps&&(r||this.contiguous)?(e.id=r,i.push(e)):t.dropped++}e.debug.length&&u.logger.log(e.pts+"/"+e.dts+":"+e.debug)}},{key:"_parseAVCPES",value:function(e,t){var i,r,a,n=this,o=this._avcTrack,s=this._parseAVCNALu(e.data),u=this.avcSample;e.data=null,s.forEach(function(t){switch(t.type){case 1:r=!0,u.frame=!0;var s=t.data;if(s.length>4){var d=new l.default(s).readSliceType();2!==d&&4!==d&&7!==d&&9!==d||(u.key=!0)}break;case 5:r=!0,u||(u=n.avcSample=n._createAVCSample(!0,e.pts,e.dts,"")),u.key=!0,u.frame=!0;break;case 6:r=!0,(i=new l.default(n.discardEPB(t.data))).readUByte();for(var c=0,f=0,h=!1,v=0;!h&&i.bytesAvailable>1;){c=0;do{c+=v=i.readUByte()}while(255===v);f=0;do{f+=v=i.readUByte()}while(255===v);if(4===c&&0!==i.bytesAvailable){if(h=!0,181===i.readUByte()&&49===i.readUShort()&&1195456820===i.readUInt()&&3===i.readUByte()){var g=i.readUByte(),p=31&g,y=[g,i.readUByte()];for(a=0;a0){if(t.pts>=e[i-1].pts)e.push(t);else for(var r=i-1;r>=0;r--)if(t.pts=0)r={data:e.subarray(c,n-s-1),type:a},d.push(r);else{var f=this._getLastNalUnit();if(f&&(u&&n<=4-u&&f.state&&(f.data=f.data.subarray(0,f.data.byteLength-u)),(i=n-s-1)>0)){var h=new Uint8Array(f.data.byteLength+i);h.set(f.data,0),h.set(e.subarray(0,i),f.data.byteLength),f.data=h}}n=0&&s>=0&&(r={data:e.subarray(c,o),type:a,state:s},d.push(r)),0===d.length){var v=this._getLastNalUnit();if(v){var g=new Uint8Array(v.data.byteLength+e.byteLength);g.set(v.data,0),g.set(e,v.data.byteLength),v.data=g}}return l.naluState=s,d}},{key:"discardEPB",value:function(e){for(var t,i,r=e.byteLength,a=[],n=1;n1&&(u.logger.log("AAC: align PTS for overlapping frames by "+Math.round((T-m)/90)),m=T)}for(;l+5>>5,(i-=s)>0&&l+s+i<=f);)for(c=m+a*r,h={unit:y.subarray(l+s,l+s+i),pts:c,dts:c},p.samples.push(h),p.len+=i,l+=i+s,a++;l0;)o+=t}},{key:"_onMpegFrame",value:function(e,t,i,r,a,n){var o=n+a*(1152/i*1e3),l=this._audioTrack;l.config=[],l.channelCount=r,l.samplerate=i,l.duration=this._duration,l.samples.push({unit:e,pts:o,dts:o}),l.len+=e.length}},{key:"_onMpegNoise",value:function(e){u.logger.warn("mpeg audio has noise: "+e.length+" bytes")}},{key:"_parseMpeg",value:function(e,t,i,r,a){if(t+2>i)return-1;if(255===e[t]||!(224&~e[t+1])){if(t+24>i)return-1;var n=e[t+1]>>3&3,o=e[t+1]>>1&3,l=e[t+2]>>4&15,s=e[t+2]>>2&3,u=!!(2&e[t+2]);if(1!==n&&0!==l&&15!==l&&3!==s){var d=1e3*[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][14*(3===n?3-o:3===o?3:4)+l-1],c=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3][3*(3===n?0:2===n?1:2)+s],f=u?1:0,h=e[t+3]>>6==3?1:2,v=3===o?(3===n?12:6)*d/c+f<<2:(3===n?144:72)*d/c+f|0;return t+v>i?-1:(this._onMpegFrame&&this._onMpegFrame(e.subarray(t,t+v),d,c,h,r,a),v)}}for(var g=t+2;g=564&&71===e[0]&&71===e[188]&&71===e[376]}}]),e}();i.default=c},{22:22,26:26,29:29,31:31,33:33,51:51}],31:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.ErrorTypes={NETWORK_ERROR:"networkError",MEDIA_ERROR:"mediaError",MUX_ERROR:"muxError",OTHER_ERROR:"otherError"},i.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"}},{}],32:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a=function(){function e(e,t){for(var i=0;i1?i-1:0),a=1;a=i.start(r)&&t<=i.end(r))return!0;return!1},bufferInfo:function(e,t,i){if(e){var r,a=e.buffered,n=[];for(r=0;rd&&(s[u-1].end=e[l].end):s.push(e[l])}else s.push(e[l])}for(l=0,r=0,a=n=t;l=c&&t=0&&le.endSN)return 0;for(u=f-e.startSN,t=(d=e.fragments)[u],c=u;c>0;c--)a.updatePTS(d,c,c-1);for(c=u;ct?a.start+a.duration:Math.max(a.start-n.duration,0):i>t?(a.duration=o-a.start,a.duration<0&&r.logger.warn("negative duration computed for frag "+a.sn+",level "+a.level+", there should be some duration drift between playlist and fragment!")):(n.duration=a.start-o,n.duration<0&&r.logger.warn("negative duration computed for frag "+n.sn+",level "+n.level+", there should be some duration drift between playlist and fragment!"))}};t.exports=a},{51:51}],37:[function(e,t,i){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(i,"__esModule",{value:!0});var a=function(){function e(e,t){for(var i=0;i0&&void 0!==arguments[0]?arguments[0]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e);var r=e.DefaultConfig;if((i.liveSyncDurationCount||i.liveMaxLatencyDurationCount)&&(i.liveSyncDuration||i.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");for(var a in r)a in i||(i[a]=r[a]);if(void 0!==i.liveMaxLatencyDurationCount&&i.liveMaxLatencyDurationCount<=i.liveSyncDurationCount)throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be gt "liveSyncDurationCount"');if(void 0!==i.liveMaxLatencyDuration&&(i.liveMaxLatencyDuration<=i.liveSyncDuration||void 0===i.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be gt "liveSyncDuration"');(0,v.enableLogs)(i.debug),this.config=i,this._autoLevelCapping=-1;var n=this.observer=new g.default;n.trigger=function(e){for(var t=arguments.length,i=Array(t>1?t-1:0),r=1;r1?t-1:0),r=1;r0&&void 0!==arguments[0]?arguments[0]:-1;v.logger.log("startLoad("+e+")"),this.networkControllers.forEach(function(t){t.startLoad(e)})}},{key:"stopLoad",value:function(){v.logger.log("stopLoad"),this.networkControllers.forEach(function(e){e.stopLoad()})}},{key:"swapAudioCodec",value:function(){v.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()}},{key:"recoverMediaError",value:function(){v.logger.log("recoverMediaError");var e=this.media;this.detachMedia(),this.attachMedia(e)}},{key:"levels",get:function(){return this.levelController.levels}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(e){v.logger.log("set currentLevel:"+e),this.loadLevel=e,this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(e){v.logger.log("set nextLevel:"+e),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(e){v.logger.log("set loadLevel:"+e),this.levelController.manualLevel=e}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(e){this.levelController.nextLoadLevel=e}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(e){v.logger.log("set firstLevel:"+e),this.levelController.firstLevel=e}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(e){v.logger.log("set startLevel:"+e),-1!==e&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(e){v.logger.log("set autoLevelCapping:"+e),this._autoLevelCapping=e}},{key:"autoLevelEnabled",get:function(){return-1===this.levelController.manualLevel}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){for(var e=this.levels,t=this.config.minAutoBitrate,i=e?e.length:0,r=0;rt)return r;return 0}},{key:"maxAutoLevel",get:function(){var e=this.levels,t=this.autoLevelCapping;return-1===t&&e&&e.length?e.length-1:t}},{key:"nextAutoLevel",get:function(){var e=this;return Math.min(Math.max(e.abrController.nextAutoLevel,e.minAutoLevel),e.maxAutoLevel)},set:function(e){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,e)}},{key:"audioTracks",get:function(){var e=this.audioTrackController;return e?e.audioTracks:[]}},{key:"audioTrack",get:function(){var e=this.audioTrackController;return e?e.audioTrack:-1},set:function(e){var t=this.audioTrackController;t&&(t.audioTrack=e)}},{key:"liveSyncPosition",get:function(){return this.streamController.liveSyncPosition}},{key:"subtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTrack:-1},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}}]),e}();i.default=y},{1:1,11:11,12:12,13:13,2:2,31:31,33:33,39:39,4:4,40:40,41:41,51:51}],38:[function(e,t,i){"use strict";t.exports=e(37).default},{37:37}],39:[function(e,t,i){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(i,"__esModule",{value:!0});var a=function(){function e(e,t){for(var i=0;i>8*(15-i)&255;return t}},{key:"fragmentDecryptdataFromLevelkey",value:function(e,t){var i=e;return e&&e.method&&e.uri&&!e.iv&&((i=new g).method=e.method,i.baseuri=e.baseuri,i.reluri=e.reluri,i.iv=this.createInitializationVector(t)),i}},{key:"cloneObj",value:function(e){return JSON.parse(JSON.stringify(e))}},{key:"url",get:function(){return!this._url&&this.relurl&&(this._url=o.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 i=this.lastByteRangeEndOffset;e[0]=i||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}(),y=function(e){function t(e){a(this,t);var i=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,l.default.MANIFEST_LOADING,l.default.LEVEL_LOADING,l.default.AUDIO_TRACK_LOADING,l.default.SUBTITLE_TRACK_LOADING));return i.loaders={},i}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),n(t,[{key:"destroy",value:function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy()}this.loaders={},s.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 i=this.loaders[t.type];if(i){var r=i.context;if(r&&r.url===e)return void c.logger.trace("playlist request ongoing");c.logger.warn("abort previous loader for type:"+t.type),i.abort()}var a,n,o=this.hls.config,l=void 0,s=void 0,u=void 0,d=void 0;"manifest"===t.type?(l=o.manifestLoadingMaxRetry,s=o.manifestLoadingTimeOut,u=o.manifestLoadingRetryDelay,d=o.manifestLoadingMaxRetryTimeout):(l=o.levelLoadingMaxRetry,s=o.levelLoadingTimeOut,u=o.levelLoadingRetryDelay,d=o.levelLoadingMaxRetryTimeout,c.logger.log("loading playlist for "+t.type+" "+(t.level||t.id))),i=this.loaders[t.type]=t.loader=void 0!==o.pLoader?new o.pLoader(o):new o.loader(o),t.url=e,t.responseType="",a={timeout:s,maxRetry:l,retryDelay:u,maxRetryDelay:d},n={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)},i.load(t,a,n)}},{key:"resolve",value:function(e,t){return o.default.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}},{key:"parseMasterPlaylist",value:function(e,t){var i=[],r=void 0;for(f.lastIndex=0;null!=(r=f.exec(e));){var a={},n=a.attrs=new d.default(r[1]);a.url=this.resolve(r[2],t);var o=n.decimalResolution("RESOLUTION");o&&(a.width=o.width,a.height=o.height),a.bitrate=n.decimalInteger("AVERAGE-BANDWIDTH")||n.decimalInteger("BANDWIDTH"),a.name=n.NAME;var l=n.CODECS;if(l){l=l.split(/[ ,]+/);for(var s=0;s2?(t=i.shift()+".",t+=parseInt(i.shift()).toString(16),t+=("000"+parseInt(i.shift()).toString(16)).substr(-4)):t=e,t}},{key:"parseLevelPlaylist",value:function(e,t,i,r){var a,n,o=0,l=0,s={type:null,version:null,url:t,fragments:[],live:!0,startSN:0},u=new g,f=0,h=null,y=new p;for(v.lastIndex=0;null!==(a=v.exec(e));){var m=a[1];if(m){y.duration=parseFloat(m);var b=(" "+a[2]).slice(1);y.title=b||null,y.tagList.push(b?["INF",m,b]:["INF",m])}else if(a[3]){if(!isNaN(y.duration)){var _=o++;y.type=r,y.start=l,y.levelkey=u,y.sn=_,y.level=i,y.cc=f,y.baseurl=t,y.relurl=(" "+a[3]).slice(1),s.fragments.push(y),h=y,l+=y.duration,y=new p}}else if(a[4]){if(y.rawByteRange=(" "+a[4]).slice(1),h){var R=h.byteRangeEndOffset;R&&(y.lastByteRangeEndOffset=R)}}else if(a[5])y.rawProgramDateTime=(" "+a[5]).slice(1),y.tagList.push(["PROGRAM-DATE-TIME",y.rawProgramDateTime]);else{for(a=a[0].match(/(?:(?:#(EXTM3U))|(?:#EXT-X-(PLAYLIST-TYPE):(.+))|(?:#EXT-X-(MEDIA-SEQUENCE): *(\d+))|(?:#EXT-X-(TARGETDURATION): *(\d+))|(?:#EXT-X-(KEY):(.+))|(?:#EXT-X-(START):(.+))|(?:#EXT-X-(ENDLIST))|(?:#EXT-X-(DISCONTINUITY-SEQ)UENCE:(\d+))|(?:#EXT-X-(DIS)CONTINUITY))|(?:#EXT-X-(VERSION):(\d+))|(?:#EXT-X-(MAP):(.+))|(?:(#)(.*):(.*))|(?:(#)(.*))(?:.*)\r?\n?/),n=1;n=0&&(u.method=A,u.baseuri=t,u.reluri=x,u.key=null,u.iv=C));break;case"START":var S=w,O=new d.default(S).decimalFloatingPoint("TIME-OFFSET");isNaN(O)||(s.startTimeOffset=O);break;case"MAP":var L=new d.default(w);y.relurl=L.URI,y.rawByteRange=L.BYTERANGE,y.baseurl=t,y.level=i,y.type=r,y.sn="initSegment",s.initSegment=y,y=new p;break;default:c.logger.warn("line parsed but not handled: "+a)}}}return(y=h)&&!y.relurl&&(s.fragments.pop(),l-=y.duration),s.totalduration=l,s.averagetargetduration=l/s.fragments.length,s.endSN=o-1,s}},{key:"loadsuccess",value:function(e,t,i){var r=e.data,a=e.url,n=i.type,o=i.id,s=i.level,d=this.hls;if(this.loaders[n]=void 0,void 0!==a&&0!==a.indexOf("data:")||(a=i.url),t.tload=performance.now(),0===r.indexOf("#EXTM3U"))if(r.indexOf("#EXTINF:")>0){var f="audioTrack"!==n&&"subtitleTrack"!==n,h=isNaN(s)?isNaN(o)?0:o:s,v=this.parseLevelPlaylist(r,a,h,"audioTrack"===n?"audio":"subtitleTrack"===n?"subtitle":"main");v.tload=t.tload,"manifest"===n&&d.trigger(l.default.MANIFEST_LOADED,{levels:[{url:a,details:v}],audioTracks:[],url:a,stats:t}),t.tparsed=performance.now(),v.targetduration?f?d.trigger(l.default.LEVEL_LOADED,{details:v,level:s||0,id:o||0,stats:t}):"audioTrack"===n?d.trigger(l.default.AUDIO_TRACK_LOADED,{details:v,id:o,stats:t}):"subtitleTrack"===n&&d.trigger(l.default.SUBTITLE_TRACK_LOADED,{details:v,id:o,stats:t}):d.trigger(l.default.ERROR,{type:u.ErrorTypes.NETWORK_ERROR,details:u.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:!0,url:a,reason:"invalid targetduration"})}else{var g=this.parseMasterPlaylist(r,a);if(g.length){var p=this.parseMasterPlaylistMedia(r,a,"AUDIO"),y=this.parseMasterPlaylistMedia(r,a,"SUBTITLES");if(p.length){var m=!1;p.forEach(function(e){e.url||(m=!0)}),!1===m&&g[0].audioCodec&&!g[0].attrs.AUDIO&&(c.logger.log("audio codec signaled in quality level, but no embedded audio track signaled, create one"),p.unshift({type:"main",name:"main"}))}d.trigger(l.default.MANIFEST_LOADED,{levels:g,audioTracks:p,subtitles:y,url:a,stats:t})}else d.trigger(l.default.ERROR,{type:u.ErrorTypes.NETWORK_ERROR,details:u.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:!0,url:a,reason:"no level found in manifest"})}else d.trigger(l.default.ERROR,{type:u.ErrorTypes.NETWORK_ERROR,details:u.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:!0,url:a,reason:"no EXTM3U delimiter"})}},{key:"loaderror",value:function(e,t){var i,r,a=t.loader;switch(t.type){case"manifest":i=u.ErrorDetails.MANIFEST_LOAD_ERROR,r=!0;break;case"level":i=u.ErrorDetails.LEVEL_LOAD_ERROR,r=!1;break;case"audioTrack":i=u.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,r=!1}a&&(a.abort(),this.loaders[t.type]=void 0),this.hls.trigger(l.default.ERROR,{type:u.ErrorTypes.NETWORK_ERROR,details:i,fatal:r,url:a.url,loader:a,response:e,context:t})}},{key:"loadtimeout",value:function(e,t){var i,r,a=t.loader;switch(t.type){case"manifest":i=u.ErrorDetails.MANIFEST_LOAD_TIMEOUT,r=!0;break;case"level":i=u.ErrorDetails.LEVEL_LOAD_TIMEOUT,r=!1;break;case"audioTrack":i=u.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT,r=!1}a&&(a.abort(),this.loaders[t.type]=void 0),this.hls.trigger(l.default.ERROR,{type:u.ErrorTypes.NETWORK_ERROR,details:i,fatal:r,url:a.url,loader:a,context:t})}}]),t}(s.default);i.default=y},{2:2,31:31,32:32,33:33,45:45,51:51}],42:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var r=function(){function e(e,t){for(var i=0;i>24&255,t[1]=r>>16&255,t[2]=r>>8&255,t[3]=255&r,t.set(e,4),a=0,r=8;a>24&255,t>>16&255,t>>8&255,255&t,r>>24,r>>16&255,r>>8&255,255&r,n>>24,n>>16&255,n>>8&255,255&n,85,196,0,0]))}},{key:"mdia",value:function(t){return e.box(e.types.mdia,e.mdhd(t.timescale,t.duration),e.hdlr(t.type),e.minf(t))}},{key:"mfhd",value:function(t){return e.box(e.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))}},{key:"minf",value:function(t){return"audio"===t.type?e.box(e.types.minf,e.box(e.types.smhd,e.SMHD),e.DINF,e.stbl(t)):e.box(e.types.minf,e.box(e.types.vmhd,e.VMHD),e.DINF,e.stbl(t))}},{key:"moof",value:function(t,i,r){return e.box(e.types.moof,e.mfhd(t),e.traf(r,i))}},{key:"moov",value:function(t){for(var i=t.length,r=[];i--;)r[i]=e.trak(t[i]);return e.box.apply(null,[e.types.moov,e.mvhd(t[0].timescale,t[0].duration)].concat(r).concat(e.mvex(t)))}},{key:"mvex",value:function(t){for(var i=t.length,r=[];i--;)r[i]=e.trex(t[i]);return e.box.apply(null,[e.types.mvex].concat(r))}},{key:"mvhd",value:function(t,i){i*=t;var r=Math.floor(i/(a+1)),n=Math.floor(i%(a+1)),o=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,r>>24,r>>16&255,r>>8&255,255&r,n>>24,n>>16&255,n>>8&255,255&n,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return e.box(e.types.mvhd,o)}},{key:"sdtp",value:function(t){var i,r,a=t.samples||[],n=new Uint8Array(4+a.length);for(r=0;r>>8&255),n.push(255&a),n=n.concat(Array.prototype.slice.call(r));for(i=0;i>>8&255),o.push(255&a),o=o.concat(Array.prototype.slice.call(r));var l=e.box(e.types.avcC,new Uint8Array([1,n[3],n[4],n[5],255,224|t.sps.length].concat(n).concat([t.pps.length]).concat(o))),s=t.width,u=t.height,d=t.pixelRatio[0],c=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,s>>8&255,255&s,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]),l,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,c>>24,c>>16&255,c>>8&255,255&c])))}},{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 i=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,i>>8&255,255&i,0,0]),e.box(e.types.esds,e.esds(t)))}},{key:"mp3",value:function(t){var i=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,i>>8&255,255&i,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 i=t.id,r=t.duration*t.timescale,n=t.width,o=t.height,l=Math.floor(r/(a+1)),s=Math.floor(r%(a+1));return e.box(e.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,i>>24&255,i>>16&255,i>>8&255,255&i,0,0,0,0,l>>24,l>>16&255,l>>8&255,255&l,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,n>>8&255,255&n,0,0,o>>8&255,255&o,0,0]))}},{key:"traf",value:function(t,i){var r=e.sdtp(t),n=t.id,o=Math.floor(i/(a+1)),l=Math.floor(i%(a+1));return e.box(e.types.traf,e.box(e.types.tfhd,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,255&n])),e.box(e.types.tfdt,new Uint8Array([1,0,0,0,o>>24,o>>16&255,o>>8&255,255&o,l>>24,l>>16&255,l>>8&255,255&l])),e.trun(t,r.length+16+20+8+16+8+8),r)}},{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 i=t.id;return e.box(e.types.trex,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}},{key:"trun",value:function(t,i){var r,a,n,o,l,s,u=t.samples||[],d=u.length,c=12+16*d,f=new Uint8Array(c);for(i+=8+c,f.set([0,0,15,1,d>>>24&255,d>>>16&255,d>>>8&255,255&d,i>>>24&255,i>>>16&255,i>>>8&255,255&i],0),r=0;r>>24&255,n>>>16&255,n>>>8&255,255&n,o>>>24&255,o>>>16&255,o>>>8&255,255&o,l.isLeading<<2|l.dependsOn,l.isDependedOn<<6|l.hasRedundancy<<4|l.paddingValue<<1|l.isNonSync,61440&l.degradPrio,15&l.degradPrio,s>>>24&255,s>>>16&255,s>>>8&255,255&s],12+16*r);return e.box(e.types.trun,f)}},{key:"initSegment",value:function(t){e.types||e.init();var i,r=e.moov(t);return(i=new Uint8Array(e.FTYP.byteLength+r.byteLength)).set(e.FTYP),i.set(r,e.FTYP.byteLength),i}}]),e}();i.default=n},{}],43:[function(e,t,i){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(i,"__esModule",{value:!0});var a=function(){function e(e,t){for(var i=0;i-1&&n&&!n.match("CriOS"),this.ISGenerated=!1}return a(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,i,r,a,n,s){if(this.ISGenerated||this.generateIS(e,t,a),this.ISGenerated)if(e.samples.length){e.timescale||(l.logger.warn("regenerate InitSegment as audio detected"),this.generateIS(e,t,a));var u=this.remuxAudio(e,a,n,s);if(t.samples.length){var d=void 0;u&&(d=u.endPTS-u.startPTS),t.timescale||(l.logger.warn("regenerate InitSegment as video detected"),this.generateIS(e,t,a)),this.remuxVideo(t,a,n,d)}}else{var c=void 0;t.samples.length&&(c=this.remuxVideo(t,a,n)),c&&e.codec&&this.remuxEmptyAudio(e,a,n,c)}i.samples.length&&this.remuxID3(i,a),r.samples.length&&this.remuxText(r,a),this.observer.trigger(o.default.FRAG_PARSED)}},{key:"generateIS",value:function(e,t,i){var r,a,n=this.observer,d=e.samples,c=t.samples,f=this.typeSupported,h="audio/mp4",v={},g={tracks:v},p=void 0===this._initPTS;if(p&&(r=a=1/0),e.config&&d.length&&(e.timescale=e.samplerate,l.logger.log("audio sampling rate : "+e.samplerate),e.isAAC||(f.mpeg?(h="audio/mpeg",e.codec=""):f.mp3&&(e.codec="mp3")),v.audio={container:h,codec:e.codec,initSegment:!e.isAAC&&f.mpeg?new Uint8Array:s.default.initSegment([e]),metadata:{channelCount:e.channelCount}},p&&(r=a=d[0].pts-e.inputTimeScale*i)),t.sps&&t.pps&&c.length){var y=t.inputTimeScale;t.timescale=y,v.video={container:"video/mp4",codec:t.codec,initSegment:s.default.initSegment([t]),metadata:{width:t.width,height:t.height}},p&&(r=Math.min(r,c[0].pts-y*i),a=Math.min(a,c[0].dts-y*i),this.observer.trigger(o.default.INIT_PTS_FOUND,{initPTS:r}))}Object.keys(v).length?(n.trigger(o.default.FRAG_PARSING_INIT_SEGMENT,g),this.ISGenerated=!0,p&&(this._initPTS=r,this._initDTS=a)):n.trigger(o.default.ERROR,{type:u.ErrorTypes.MEDIA_ERROR,details:u.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"no audio/video samples found"})}},{key:"remuxVideo",value:function(e,t,i,r){var a,n,d,c,f,h,v,g=8,p=e.timescale,y=e.samples,m=[],b=y.length,_=this._PTSNormalize,R=this._initDTS;y.sort(function(e,t){var i=e.dts-t.dts,r=e.pts-t.pts;return i||r||e.id-t.id});var w,T=y.reduce(function(e,t){return Math.max(Math.min(e,t.pts-t.dts),-18e3)},0);if(T<0){l.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+Math.round(T/90)+" ms to overcome this issue");for(var k=0;k1?l.logger.log("AVC:"+A+" ms hole between fragments detected,filling it"):A<-1&&l.logger.log("AVC:"+-A+" ms overlapping between fragments detected"),f=w,y[0].dts=f+R,c=Math.max(c-A,w),y[0].pts=c+R,l.logger.log("Video/PTS/DTS adjusted: "+Math.round(c/90)+"/"+Math.round(f/90)+",delta:"+A+" ms")),E=y[y.length-1],v=Math.max(_(E.dts-R,w),0),h=Math.max(_(E.pts-R,w),0),h=Math.max(h,v);var x=this.isSafari;x&&(a=Math.round((v-f)/(y.length-1)));for(var C=0,S=0,O=0;O0?N-1:N].dts;if(Z.stretchShortVideoTrack){var X=Z.maxBufferHole,Y=Z.maxSeekHole,Q=Math.floor(Math.min(X,Y)*p),J=(r?c+r*p:this.nextAudioPts)-U.pts;J>Q?((a=J-K)<0&&(a=K),l.logger.log("It is approximately "+J/90+" ms to the next segment; using duration "+a/90+" ms for the last video frame.")):a=K}else a=K}G=Math.round(U.pts-U.dts)}m.push({size:j,duration:a,cts:G,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:U.key?2:1,isNonSync:U.key?0:1}})}this.nextAvcDts=v+a;var ee=e.dropped;if(e.len=0,e.nbNalu=0,e.dropped=0,m.length&&navigator.userAgent.toLowerCase().indexOf("chrome")>-1){var te=m[0].flags;te.dependsOn=2,te.isNonSync=0}e.samples=m,d=s.default.moof(e.sequenceNumber++,f,e),e.samples=[];var ie={data1:d,data2:n,startPTS:c/p,endPTS:(h+a)/p,startDTS:f/p,endDTS:this.nextAvcDts/p,type:"video",nb:m.length,dropped:ee};return this.observer.trigger(o.default.FRAG_PARSING_DATA,ie),ie}},{key:"remuxAudio",value:function(e,t,i,r){var a,d,c,f,h,v,g,p,y,m,b,_,R,w,T,k=e.inputTimeScale,E=k/e.timescale,A=(e.isAAC?1024:1152)*E,x=this._PTSNormalize,C=this._initDTS,S=!e.isAAC&&this.typeSupported.mpeg,O=S?0:8,L=[],D=[];if(e.samples.sort(function(e,t){return e.pts-t.pts}),D=e.samples,T=this.nextAudioPts,(i|=D.length&&T&&(r&&Math.abs(t-T/k)<.1||Math.abs(D[0].pts-T-C)<20*A))||(T=t*k),r&&e.isAAC)for(var I=0,P=T;I=A&&P){var F=Math.round(z/A);l.logger.warn("Injecting "+F+" audio frame @ "+(P/k).toFixed(3)+"s due to "+1e3*z/k+" ms gap.");for(var N=0;N0)G=Math.round((b-T)/A),l.logger.log(j+" ms hole between AAC samples detected,filling it"),G>0&&((R=n.default.getSilentFrame(e.manifestCodec||e.codec,e.channelCount))||(R=c.subarray()),e.len+=G*R.length);else if(j<-12){l.logger.log("drop overlapping AAC sample, expected/parsed/delta:"+(T/k).toFixed(3)+"s/"+(b/k).toFixed(3)+"s/"+-j+"ms"),e.len-=c.byteLength;continue}b=_=T}if(v=Math.max(0,b),g=Math.max(0,_),!(e.len>0))return;var q=S?e.len:e.len+8;try{f=new Uint8Array(q)}catch(e){return void this.observer.trigger(o.default.ERROR,{type:u.ErrorTypes.MUX_ERROR,details:u.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:q,reason:"fail allocating audio mdat "+q})}S||(new DataView(f.buffer).setUint32(0,q),f.set(s.default.types.mdat,4));for(var H=0;H=2&&(W=L[$-2].duration,d.duration=W),$){this.nextAudioPts=b+E*W,e.len=0,e.samples=L,h=S?new Uint8Array:s.default.moof(e.sequenceNumber++,g/E,e),e.samples=[];var Z={data1:h,data2:f,startPTS:v/k,endPTS:this.nextAudioPts/k,startDTS:g/k,endDTS:(_+E*W)/k,type:"audio",nb:$};return this.observer.trigger(o.default.FRAG_PARSING_DATA,Z),Z}return null}},{key:"remuxEmptyAudio",value:function(e,t,i,r){var a=e.inputTimeScale,o=a/(e.samplerate?e.samplerate:a),s=this.nextAudioPts,u=(void 0!==s?s:r.startDTS*a)+this._initDTS,d=r.endDTS*a+this._initDTS,c=1024*o,f=Math.ceil((d-u)/c),h=n.default.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(l.logger.warn("remux empty Audio"),h){for(var v=[],g=0;g4294967296;)e+=i;return e}}]),e}();i.default=d},{31:31,33:33,34:34,42:42,51:51}],44:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var r=function(){function e(e,t){for(var i=0;iNumber.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 i=new Uint8Array(t.length/2),r=0;rNumber.MAX_SAFE_INTEGER?1/0:t}},{key:"decimalFloatingPoint",value:function(e){return parseFloat(this[e])}},{key:"enumeratedString",value:function(e){return this[e]}},{key:"decimalResolution",value:function(e){var t=a.exec(this[e]);if(null!==t)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}}],[{key:"parseAttrList",value:function(e){var t,i={};for(n.lastIndex=0;null!==(t=n.exec(e));){var r=t[2];0===r.indexOf('"')&&r.lastIndexOf('"')===r.length-1&&(r=r.slice(1,-1)),i[t[1]]=r}return i}}]),e}();i.default=o},{}],46:[function(e,t,i){"use strict";t.exports={search:function(e,t){for(var i=0,r=e.length-1,a=null,n=null;i<=r;){var o=t(n=e[a=(i+r)/2|0]);if(o>0)i=a+1;else{if(!(o<0))return n;r=a-1}}return null}}},{}],47:[function(e,t,i){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(i,"__esModule",{value:!0});var a=function(){function e(e,t){for(var i=0;is&&(v.log("ERROR","Too large cursor position "+this.pos),this.pos=s)}},{key:"moveCursor",value:function(e){var t=this.pos+e;if(e>1)for(var i=this.pos+1;i=144&&this.backSpace();var t=o(e);this.pos>=s?v.log("ERROR","Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!"):(this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1))}},{key:"clearFromPos",value:function(e){var t;for(t=e;t0&&(i=e?"["+t.join(" | ")+"]":t.join("\n")),i}},{key:"getTextAndFormat",value:function(){return this.rows}}]),e}(),_=function(){function e(t,i){r(this,e),this.chNr=t,this.outputFilter=i,this.mode=null,this.verbose=0,this.displayedMemory=new b,this.nonDisplayedMemory=new b,this.lastOutputScreen=new b,this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}return a(e,[{key:"reset",value:function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.lastCueEndTime=null}},{key:"getHandler",value:function(){return this.outputFilter}},{key:"setHandler",value:function(e){this.outputFilter=e}},{key:"setPAC",value:function(e){this.writeScreen.setPAC(e)}},{key:"setBkgData",value:function(e){this.writeScreen.setBkgData(e)}},{key:"setMode",value:function(e){e!==this.mode&&(this.mode=e,v.log("INFO","MODE="+e),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)}},{key:"insertChars",value:function(e){for(var t=0;t=46,t.italics)t.foreground="white";else{var i=Math.floor(e/2)-16;t.foreground=["white","green","blue","cyan","red","yellow","magenta"][i]}v.log("INFO","MIDROW: "+JSON.stringify(t)),this.writeScreen.setPen(t)}},{key:"outputDataUpdate",value:function(){var e=v.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}(),R=function(){function e(t,i,a){r(this,e),this.field=t||1,this.outputs=[i,a],this.channels=[new _(1,i),new _(2,a)],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 a(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 i,r,a,n=!1;this.lastTime=e,v.setTime(e);for(var o=0;o ("+g([r,a])+")"),(i=this.parseCmd(r,a))||(i=this.parseMidrow(r,a)),i||(i=this.parsePAC(r,a)),i||(i=this.parseBackgroundAttributes(r,a)),!i&&(n=this.parseChars(r,a))&&(this.currChNr&&this.currChNr>=0?this.channels[this.currChNr-1].insertChars(n):v.log("WARNING","No channel found yet. TEXT-MODE?")),i?this.dataCounters.cmd+=2:n?this.dataCounters.char+=2:(this.dataCounters.other+=2,v.log("WARNING","Couldn't parse cleaned data "+g([r,a])+" orig: "+g([t[o],t[o+1]])))):this.dataCounters.padding+=2}},{key:"parseCmd",value:function(e,t){var i;if(!((20===e||28===e)&&32<=t&&t<=47||(23===e||31===e)&&33<=t&&t<=35))return!1;if(e===this.lastCmdA&&t===this.lastCmdB)return this.lastCmdA=null,this.lastCmdB=null,v.log("DEBUG","Repeated command ("+g([e,t])+") is dropped"),!0;i=20===e||23===e?1:2;var r=this.channels[i-1];return 20===e||28===e?32===t?r.ccRCL():33===t?r.ccBS():34===t?r.ccAOF():35===t?r.ccAON():36===t?r.ccDER():37===t?r.ccRU(2):38===t?r.ccRU(3):39===t?r.ccRU(4):40===t?r.ccFON():41===t?r.ccRDC():42===t?r.ccTR():43===t?r.ccRTD():44===t?r.ccEDM():45===t?r.ccCR():46===t?r.ccENM():47===t&&r.ccEOC():r.ccTO(t-32),this.lastCmdA=e,this.lastCmdB=t,this.currChNr=i,!0}},{key:"parseMidrow",value:function(e,t){var i=null;return(17===e||25===e)&&32<=t&&t<=47&&((i=17===e?1:2)!==this.currChNr?(v.log("ERROR","Mismatch channel in midrow parsing"),!1):(this.channels[i-1].ccMIDROW(t),v.log("DEBUG","MIDROW ("+g([e,t])+")"),!0))}},{key:"parsePAC",value:function(e,t){var i,r;if(!((17<=e&&e<=23||25<=e&&e<=31)&&64<=t&&t<=127||(16===e||24===e)&&64<=t&&t<=95))return!1;if(e===this.lastCmdA&&t===this.lastCmdB)return this.lastCmdA=null,this.lastCmdB=null,!0;i=e<=23?1:2,r=64<=t&&t<=95?1===i?u[e]:c[e]:1===i?d[e]:f[e];var a=this.interpretPAC(r,t);return this.channels[i-1].setPAC(a),this.lastCmdA=e,this.lastCmdB=t,this.currChNr=i,!0}},{key:"interpretPAC",value:function(e,t){var i,r={color:null,italics:!1,indent:null,underline:!1,row:e};return i=t>95?t-96:t-64,r.underline=!(1&~i),i<=13?r.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(i/2)]:i<=15?(r.italics=!0,r.color="white"):r.indent=4*Math.floor((i-16)/2),r}},{key:"parseChars",value:function(e,t){var i,r=null,a=null,n=null;(e>=25?(r=2,n=e-8):(r=1,n=e),17<=n&&n<=19)?(i=17===n?t+80:18===n?t+112:t+144,v.log("INFO","Special char '"+o(i)+"' in channel "+r),a=[i]):32<=e&&e<=127&&(a=0===t?[e]:[e,t]);if(a){var l=g(a);v.log("DEBUG","Char codes = "+l.join(",")),this.lastCmdA=null,this.lastCmdB=null}return a}},{key:"parseBackgroundAttributes",value:function(e,t){var i,r,a,n;return!(!((16===e||24===e)&&32<=t&&t<=47)&&!((23===e||31===e)&&45<=t&&t<=47)||(i={},16===e||24===e?(r=Math.floor((t-32)/2),i.background=h[r],t%2==1&&(i.background=i.background+"_semi")):45===t?i.background="transparent":(i.foreground="black",47===t&&(i.underline=!0)),a=e<24?1:2,n=this.channels[a-1],n.setBkgData(i),this.lastCmdA=null,this.lastCmdB=null,0))}},{key:"reset",value:function(){for(var e=0;e=16?s--:s++,navigator.userAgent.match(/Firefox\//)?o.line=c+1:o.line=c>7?c-2:c+1,o.align="left",o.position=Math.max(0,Math.min(100,s/32*100+(navigator.userAgent.match(/Firefox\//)?50:0))),e.addCue(o)}}};t.exports=a},{54:54}],49:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var r=function(){function e(e,t){for(var i=0;i=this.minWeight_}},{key:"getEstimate",value:function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}},{key:"destroy",value:function(){}}]),e}();i.default=n},{50:50}],50:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var r=function(){function e(e,t){for(var i=0;i "+t}(e,r[0])),t.apply(self.console,r)}:r}Object.defineProperty(i,"__esModule",{value:!0});var n="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},o={trace:r,debug:r,log:r,warn:r,info:r,error:r},l=o;i.enableLogs=function(e){if(!0===e||"object"===(void 0===e?"undefined":n(e))){!function(e){for(var t=arguments.length,i=Array(t>1?t-1:0),r=1;r100)throw new Error("Position must be between 0 and 100.");_=e,this.hasBeenReset=!0}})),Object.defineProperty(l,"positionAlign",i({},u,{get:function(){return R},set:function(e){var i=t(e);if(!i)throw new SyntaxError("An invalid or illegal string was specified.");R=i,this.hasBeenReset=!0}})),Object.defineProperty(l,"size",i({},u,{get:function(){return w},set:function(e){if(e<0||e>100)throw new Error("Size must be between 0 and 100.");w=e,this.hasBeenReset=!0}})),Object.defineProperty(l,"align",i({},u,{get:function(){return T},set:function(e){var i=t(e);if(!i)throw new SyntaxError("An invalid or illegal string was specified.");T=i,this.hasBeenReset=!0}})),l.displayState=void 0,s)return l}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 r.prototype.getCueAsHTML=function(){return window.WebVTT.convertCueToDOMTree(window,this.text)},r}()},{}],54:[function(e,t,i){"use strict";function r(){this.window=window,this.state="INITIAL",this.buffer="",this.decoder=new u,this.regionList=[]}function a(){this.values=Object.create(null)}function n(e,t,i,r){var a=r?e.split(r):[e];for(var n in a)if("string"==typeof a[n]){var o=a[n].split(i);2===o.length&&t(o[0],o[1])}}function o(e,t,i){function r(){var t=function(e){function t(e,t,i,r){return 3600*(0|e)+60*(0|t)+(0|i)+(0|r)/1e3}var i=e.match(/^(\d+):(\d{2})(:\d{2})?\.(\d{3})/);return i?i[3]?t(i[1],i[2],i[3].replace(":",""),i[4]):i[1]>59?t(i[1],i[2],0,i[4]):t(0,i[1],i[2],i[4]):null}(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=r(),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=r(),o(),function(e,t){var r=new a;n(e,function(e,t){switch(e){case"region":for(var a=i.length-1;a>=0;a--)if(i[a].id===t){r.set(e,i[a].region);break}break;case"vertical":r.alt(e,t,["rl","lr"]);break;case"line":var n=t.split(","),o=n[0];r.integer(e,o),r.percent(e,o)&&r.set("snapToLines",!1),r.alt(e,o,["auto"]),2===n.length&&r.alt("lineAlign",n[1],["start",c,"end"]);break;case"position":n=t.split(","),r.percent(e,n[0]),2===n.length&&r.alt("positionAlign",n[1],["start",c,"end","line-left","line-right","auto"]);break;case"size":r.percent(e,t);break;case"align":r.alt(e,t,["start",c,"end","left","right"])}},/:/,/\s/),t.region=r.get("region",null),t.vertical=r.get("vertical","");var o=r.get("line","auto");"auto"===o&&-1===d.line&&(o=-1),t.line=o,t.lineAlign=r.get("lineAlign","start"),t.snapToLines=r.get("snapToLines",!0),t.size=r.get("size",100),t.align=r.get("align",c);var l=r.get("position","auto");"auto"===l&&50===d.position&&(l="start"===t.align||"left"===t.align?0:"end"===t.align||"right"===t.align?100:50),t.position=l}(e,t)}function l(e){return e.replace(/
/gi,"\n")}Object.defineProperty(i,"__esModule",{value:!0}),i.fixLineBreaks=void 0;var s=function(e){return e&&e.__esModule?e:{default:e}}(e(53)),u=function(){return{decode:function(e){if(!e)return"";if("string"!=typeof e)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}};a.prototype={set:function(e,t){this.get(e)||""===t||(this.values[e]=t)},get:function(e,t,i){return i?this.has(e)?this.values[e]:t[i]:this.has(e)?this.values[e]:t},has:function(e){return e in this.values},alt:function(e,t,i){for(var r=0;r=0&&t<=100)&&(this.set(e,t),!0)}};var d=new s.default(0,0,0),c="middle"===d.align?"middle":"center";r.prototype={parse:function(e){function t(){var e=i.buffer,t=0;for(e=l(e);t0&&f.push(e)},g.onparsingerror=function(e){h=e},g.onflush=function(){h&&o?o(h):n(f)},l.forEach(function(e){if(v){if(e.startsWith("X-TIMESTAMP-MAP=")){v=!1,e.substr(16).split(",").forEach(function(e){e.startsWith("LOCAL:")?s=e.substr(6):e.startsWith("MPEGTS:")&&(u=parseInt(e.substr(7)))});try{u-=t=t<0?t+8589934592:t,d=function(e){var t=parseInt(e.substr(-3)),i=parseInt(e.substr(-6,2)),r=parseInt(e.substr(-9,2)),a=e.length>9?parseInt(e.substr(0,e.indexOf(":"))):0;return isNaN(t)||isNaN(i)||isNaN(r)||isNaN(a)?-1:(t+=1e3*i,t+=6e4*r,t+=36e5*a)}(s)/1e3,c=u/9e4,-1===d&&(h=new Error("Malformed X-TIMESTAMP-MAP: "+e))}catch(t){h=new Error("Malformed X-TIMESTAMP-MAP: "+e)}return}""===e&&(v=!1)}g.parse(e+"\n")}),g.flush()}};t.exports=a},{54:54}],56:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var r=function(){function e(e,t){for(var i=0;i=2)if(window.clearTimeout(this.requestTimeout),0===r.tfirst&&(r.tfirst=Math.max(performance.now(),r.trequest)),4===i){var l=t.status;if(l>=200&&l<300){r.tload=Math.max(r.tfirst,performance.now());var s=void 0,u=void 0;u="arraybuffer"===n.responseType?(s=t.response).byteLength:(s=t.responseText).length,r.loaded=r.total=u;var d={url:t.responseURL,data:s};this.callbacks.onSuccess(d,r,n)}else r.retry>=o.maxRetry||l>=400&&l<499?(a.logger.error(l+" while loading "+n.url),this.callbacks.onError({code:l,text:t.statusText},n)):(a.logger.warn(l+" while loading "+n.url+", retrying in "+this.retryDelay+"..."),this.destroy(),this.retryTimeout=window.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,o.maxRetryDelay),r.retry++)}else this.requestTimeout=window.setTimeout(this.loadtimeout.bind(this),o.timeout)}},{key:"loadtimeout",value:function(){a.logger.warn("timeout while loading "+this.context.url),this.callbacks.onTimeout(this.stats,this.context)}},{key:"loadprogress",value:function(e){var t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total);var i=this.callbacks.onProgress;i&&i(t,this.context,null)}}]),e}();i.default=n},{51:51}]},{},[38])(38)});