/** * videojs-hlsjs-plugin * v1.0.16 * 2022-01-30 * www.streamroot.io * Copyright 2018 **/ !function(r){var i={};function a(e){if(i[e])return i[e].exports;var t=i[e]={i:e,l:!1,exports:{}};return r[e].call(t.exports,t,t.exports,a),t.l=!0,t.exports}a.m=r,a.c=i,a.d=function(e,t,r){a.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(t,e){if(1&e&&(t=a(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(a.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)a.d(r,i,function(e){return t[e]}.bind(null,i));return r},a.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(t,"a",t),t},a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.p="",a(a.s=0)}([function(e,t,r){"use strict";var r=r(1),r=(window.videojs&&(r.registerConfigPlugin(window.videojs),r.registerSourceHandler(window.videojs)),{register:r.registerSourceHandler}),i="hlsSourceHandler";window[i]||(window[i]=r)},function(e,t,r){"use strict";var C="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},I=r(2);function i(e){var t=this;e&&(t.srOptions_||(t.srOptions_={}),t.srOptions_.hlsjsConfig||(t.srOptions_.hlsjsConfig=e.hlsjsConfig),t.srOptions_.captionConfig||(t.srOptions_.captionConfig=e.captionConfig))}e.exports={registerSourceHandler:function(D){var e,O={};function r(f,a){a.name_="StreamrootHlsjs";var n,s=a.el(),i={},g=null,o=null,l=null,p=null,d=null,u=null,c=D(a.options_.playerId),h=c.qualityLevels&&c.qualityLevels(),m=(h&&c.hlsQualitySelector&&(a.hls={}),!1);function v(e){1===i[I.ErrorTypes.MEDIA_ERROR]?n.recoverMediaError():2===i[I.ErrorTypes.MEDIA_ERROR]?(n.swapAudioCodec(),n.recoverMediaError()):2>>8^255&n^99,t[c[n]=r]),o=t[s],l=t[o],d=257*t[n]^16843008*n;h[r]=d<<24|d>>>8,f[r]=d<<16|d>>>16,g[r]=d<<8|d>>>24,p[r]=d,m[n]=(d=16843009*l^65537*o^257*s^16843008*r)<<24|d>>>8,v[n]=d<<16|d>>>16,y[n]=d<<8|d>>>24,E[n]=d,r?(r=s^t[t[t[l^s]]],i^=t[t[i]]):r=i=1}},t.expandKey=function(e){for(var t=this.uint8ArrayToUint32Array_(e),u=!0,r=0;r>>5}function v(e,t){return!!(t+1>>6),d=(60&t[r+2])>>>2;if(!(o.length-1>>6,K.logger.log("manifest codec:"+i+",ADTS data:type:"+l+",sampleingIndex:"+d+"["+o[d]+"Hz],channelConfig:"+a),t=/firefox/i.test(s)?6<=d?(l=5,n=new Array(4),d-3):(l=2,n=new Array(2),d):-1!==s.indexOf("android")?(l=2,n=new Array(2),d):(l=5,n=new Array(4),i&&(-1!==i.indexOf("mp4a.40.29")||-1!==i.indexOf("mp4a.40.5"))||!i&&6<=d?d-3:((i&&-1!==i.indexOf("mp4a.40.2")&&(6<=d&&1==a||/vivaldi/i.test(s))||!i&&1==a)&&(l=2,n=new Array(2)),d)),n[0]=l<<3,n[0]|=(14&d)>>1,n[1]|=(1&d)<<7,n[1]|=a<<3,5===l&&(n[1]|=(14&t)>>1,n[2]=(1&t)<<7,n[2]|=8,n[3]=0),{config:n,samplerate:o[d],channelCount:a,codec:"mp4a.40."+l,manifestCodec:u};e.trigger(G.default.ERROR,{type:j.ErrorTypes.MEDIA_ERROR,details:j.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+d})}(t,r,i,a),e.config=t.config,e.samplerate=t.samplerate,e.channelCount=t.channelCount,e.codec=t.codec,e.manifestCodec=t.manifestCodec,K.logger.log("parsed codec:"+e.codec+",rate:"+t.samplerate+",nb channel:"+t.channelCount))}function h(e){return 9216e4/e}function E(e,t,r,i,a){var n,i=function(e,t,r,i,a){var n=e.length,s=l(e,t),e=d(e,t);if(0<(e-=s)&&t+s+e<=n)return{headerLength:s,frameLength:e,stamp:r+i*a}}(t,r,i,a,h(e.samplerate));if(i)return a=i.stamp,n=i.headerLength,i=i.frameLength,t={unit:t.subarray(r+n,r+n+i),pts:a,dts:a},e.samples.push(t),{sample:t,length:i+n}}var A=t("./src/demux/id3.js"),_=function(){function e(e,t,r){this.observer=e,this.config=r,this.remuxer=t}var t=e.prototype;return t.resetInitSegment=function(e,t,r,i){this._audioTrack={container:"audio/adts",type:"audio",id:0,sequenceNumber:0,isAAC:!0,samples:[],len:0,manifestCodec:t,duration:i,inputTimeScale:9e4}},t.resetTimeStamp=function(){},e.probe=function(e){if(!e)return!1;for(var t=(A.default.getID3Data(e,0)||[]).length,r=e.length;tt.length))return n=this.parseHeader(t,r),n&&r+n.frameLength<=t.length?(i=i+a*(9e4*n.samplesPerFrame/n.sampleRate),a={unit:t.subarray(r,r+n.frameLength),pts:i,dts:i},e.config=[],e.channelCount=n.channelCount,e.samplerate=n.sampleRate,e.samples.push(a),{sample:a,length:n.frameLength}):void 0},parseHeader:function(e,t){var r=e[t+1]>>3&3,i=e[t+1]>>1&3,a=e[t+2]>>4&15,n=e[t+2]>>2&3,s=e[t+2]>>1&1;if(1!=r&&0!=a&&15!=a&&3!=n)return a=1e3*o.BitratesMap[14*(3==r?3-i:3==i?3:4)+a-1],n=o.SamplingRateMap[3*(3==r?0:2==r?1:2)+n],e=e[t+3]>>6==3?1:2,i=8*(t=o.SamplesCoefficients[r][i])*(r=o.BytesInSlot[i]),{sampleRate:n,channelCount:e,frameLength:parseInt(t*a/n+s,10)*r,samplesPerFrame:i}},isHeaderPattern:function(e,t){return 255===e[t]&&224==(224&e[t+1])&&0!=(6&e[t+1])},isHeader:function(e,t){return!!(t+1e||(e=(e-=this.bitsAvailable)-((t=e>>3)>>3),this.bytesAvailable-=t,this.loadWord()),this.word<<=e,this.bitsAvailable-=e},t.readBits=function(e){var t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;return 32>>e))return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()},t.skipUEG=function(){this.skipBits(1+this.skipLZ())},t.skipEG=function(){this.skipBits(1+this.skipLZ())},t.readUEG=function(){var e=this.skipLZ();return this.readBits(e+1)-1},t.readEG=function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)},t.readBoolean=function(){return 1===this.readBits(1)},t.readUByte=function(){return this.readBits(8)},t.readUShort=function(){return this.readBits(16)},t.readUInt=function(){return this.readBits(32)},t.skipScalingList=function(e){for(var t=8,r=8,i=0;i=e.length)return void r();if(!(e[t].unit.length<32)){var i=this.decrypter.isSync();if(this.decryptAacSample(e,t,r,i),!i)return}}},t.getAvcEncryptedData=function(e){for(var t=16*Math.floor((e.length-48)/160)+16,r=new Int8Array(t),i=0,a=32;a<=e.length-16;a+=160,i+=16)r.set(e.subarray(a,a+16),i);return r},t.getAvcDecryptedUnit=function(e,t){t=new Uint8Array(t);for(var r=0,i=32;i<=e.length-16;i+=160,r+=16)e.set(t.subarray(r,r+16),i);return e},t.decryptAvcSample=function(t,r,i,a,n,s){var o=this.discardEPB(n.data),e=this.getAvcEncryptedData(o),l=this;this.decryptBuffer(e.buffer,function(e){n.data=l.getAvcDecryptedUnit(o,e),s||l.decryptAvcSamples(t,r,i+1,a)})},t.decryptAvcSamples=function(e,t,r,i){for(;;t++,r=0){if(t>=e.length)return void i();for(var a=e[t].units;!(r>=a.length);r++){var n=a[r];if(!(n.length<=48||1!==n.type&&5!==n.type)){var s=this.decrypter.isSync();if(this.decryptAvcSample(e,t,r,i,n,s),!s)return}}}},e}(),u={video:1,audio:2,id3:3,text:4},L=function(){function C(e,t,r,i){this.observer=e,this.config=r,this.typeSupported=i,this.remuxer=t,this.sampleAes=null}var e=C.prototype;return e.setDecryptData=function(e){null!=e&&null!=e.key&&"SAMPLE-AES"===e.method?this.sampleAes=new s(this.observer,this.config,e,this.discardEPB):this.sampleAes=null},C.probe=function(e){e=C._syncOffset(e);return!(e<0)&&(e&&K.logger.warn("MPEG2-TS detected but first sync word found @ offset "+e+", junk ahead ?"),!0)},C._syncOffset=function(e){for(var t=Math.min(1e3,e.length-564),r=0;r>4){if((r=t+5+e[t+4])===t+188)continue}else r=t+4;switch(g){case y:f&&(o&&(i=R(o))&&A(i,!1),o={data:[],size:0}),o&&(o.data.push(e.subarray(r,t+188)),o.size+=t+188-r);break;case E:f&&(l&&(i=R(l))&&(n.isAAC?k:L)(i),l={data:[],size:0}),l&&(l.data.push(e.subarray(r,t+188)),l.size+=t+188-r);break;case T:f&&(d&&(i=R(d))&&w(i),d={data:[],size:0}),d&&(d.data.push(e.subarray(r,t+188)),d.size+=t+188-r);break;case 0:f&&(r+=e[r]+1),b=this._pmtId=S(e,r);break;case b:f&&(r+=e[r]+1);var O=_(e,r,!0===this.typeSupported.mpeg||!0===this.typeSupported.mp3,null!=this.sampleAes);0<(y=O.avc)&&(a.pid=y),0<(E=O.audio)&&(n.pid=E,n.isAAC=O.isAAC),0<(T=O.id3)&&(s.pid=T),m&&!v&&(K.logger.log("reparse from beginning"),m=!1,t=D-188),v=this.pmtParsed=!0;break;case 17:case 8191:break;default:m=!0}}else this.observer.trigger(G.default.ERROR,{type:j.ErrorTypes.MEDIA_ERROR,details:j.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});o&&(i=R(o))?(A(i,!0),a.pesData=null):a.pesData=o,l&&(i=R(l))?((n.isAAC?k:L)(i),n.pesData=null):(l&&l.size&&K.logger.log("last AAC PES packet truncated,might overlap between fragments"),n.pesData=l),d&&(i=R(d))?(w(i),s.pesData=null):s.pesData=d,null==this.sampleAes?this.remuxer.remux(n,a,s,this._txtTrack,u,c,h):this.decryptAndRemux(n,a,s,this._txtTrack,u,c,h)},e.decryptAndRemux=function(e,t,r,i,a,n,s){var o;e.samples&&e.isAAC?(o=this).sampleAes.decryptAacSamples(e.samples,0,function(){o.decryptAndRemuxAvc(e,t,r,i,a,n,s)}):this.decryptAndRemuxAvc(e,t,r,i,a,n,s)},e.decryptAndRemuxAvc=function(e,t,r,i,a,n,s){var o;t.samples?(o=this).sampleAes.decryptAvcSamples(t.samples,0,0,function(){o.remuxer.remux(e,t,r,i,a,n,s)}):this.remuxer.remux(e,t,r,i,a,n,s)},e.destroy=function(){this._initPTS=this._initDTS=void 0,this._duration=0},e._parsePAT=function(e,t){return(31&e[t+10])<<8|e[t+11]},e._parsePMT=function(e,t,r,i){var a,n={audio:-1,avc:-1,id3:-1,isAAC:!0},s=t+3+((15&e[t+1])<<8|e[t+2])-4;for(t+=12+((15&e[t+10])<<8|e[t+11]);te.size-6)return null;if(192&(r=l[7])&&(4294967295<(i=536870912*(14&l[9])+4194304*(255&l[10])+16384*(254&l[11])+128*(255&l[12])+(254&l[13])/2)&&(i-=8589934592),64&r?(4294967295<(a=536870912*(14&l[14])+4194304*(255&l[15])+16384*(254&l[16])+128*(255&l[17])+(254&l[18])/2)&&(a-=8589934592),54e5=e[r-1].pts)e.push(t);else for(var i=r-1;0<=i;i--)if(t.pts>24&255,t[1]=i>>16&255,t[2]=i>>8&255,t[3]=255&i,t.set(e,4),a=0,i=8;a>24&255,e>>16&255,e>>8&255,255&e,r>>24,r>>16&255,r>>8&255,255&r,t>>24,t>>16&255,t>>8&255,255&t,85,196,0,0]))},c.mdia=function(e){return c.box(c.types.mdia,c.mdhd(e.timescale,e.duration),c.hdlr(e.type),c.minf(e))},c.mfhd=function(e){return c.box(c.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e]))},c.minf=function(e){return"audio"===e.type?c.box(c.types.minf,c.box(c.types.smhd,c.SMHD),c.DINF,c.stbl(e)):c.box(c.types.minf,c.box(c.types.vmhd,c.VMHD),c.DINF,c.stbl(e))},c.moof=function(e,t,r){return c.box(c.types.moof,c.mfhd(e),c.traf(r,t))},c.moov=function(e){for(var t=e.length,r=[];t--;)r[t]=c.trak(e[t]);return c.box.apply(null,[c.types.moov,c.mvhd(e[0].timescale,e[0].duration)].concat(r).concat(c.mvex(e)))},c.mvex=function(e){for(var t=e.length,r=[];t--;)r[t]=c.trex(e[t]);return c.box.apply(null,[c.types.mvex].concat(r))},c.mvhd=function(e,t){t*=e;var r=Math.floor(t/(1+n)),t=Math.floor(t%(1+n)),e=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,r>>24,r>>16&255,r>>8&255,255&r,t>>24,t>>16&255,t>>8&255,255&t,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 c.box(c.types.mvhd,e)},c.sdtp=function(e){for(var t,r=e.samples||[],i=new Uint8Array(4+r.length),a=0;a>>8&255),i.push(255&r),i=i.concat(Array.prototype.slice.call(t));for(n=0;n>>8&255),a.push(255&r),a=a.concat(Array.prototype.slice.call(t));var u=c.box(c.types.avcC,new Uint8Array([1,i[3],i[4],i[5],255,224|e.sps.length].concat(i).concat([e.pps.length]).concat(a))),s=e.width,o=e.height,l=e.pixelRatio[0],d=e.pixelRatio[1];return c.box(c.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,o>>8&255,255&o,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]),u,c.box(c.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),c.box(c.types.pasp,new Uint8Array([l>>24,l>>16&255,l>>8&255,255&l,d>>24,d>>16&255,d>>8&255,255&d])))},c.esds=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]))},c.mp4a=function(e){var t=e.samplerate;return c.box(c.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,t>>8&255,255&t,0,0]),c.box(c.types.esds,c.esds(e)))},c.mp3=function(e){var t=e.samplerate;return c.box(c.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,t>>8&255,255&t,0,0]))},c.stsd=function(e){return"audio"===e.type?e.isAAC||"mp3"!==e.codec?c.box(c.types.stsd,c.STSD,c.mp4a(e)):c.box(c.types.stsd,c.STSD,c.mp3(e)):c.box(c.types.stsd,c.STSD,c.avc1(e))},c.tkhd=function(e){var t=e.id,r=e.duration*e.timescale,i=e.width,e=e.height,a=Math.floor(r/(1+n)),r=Math.floor(r%(1+n));return c.box(c.types.tkhd,new Uint8Array([1,0,0,7,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,0,0,0,0,a>>24,a>>16&255,a>>8&255,255&a,r>>24,r>>16&255,r>>8&255,255&r,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,e>>8&255,255&e,0,0]))},c.traf=function(e,t){var r=c.sdtp(e),i=e.id,a=Math.floor(t/(1+n)),t=Math.floor(t%(1+n));return c.box(c.types.traf,c.box(c.types.tfhd,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i])),c.box(c.types.tfdt,new Uint8Array([1,0,0,0,a>>24,a>>16&255,a>>8&255,255&a,t>>24,t>>16&255,t>>8&255,255&t])),c.trun(e,r.length+16+20+8+16+8+8),r)},c.trak=function(e){return e.duration=e.duration||4294967295,c.box(c.types.trak,c.tkhd(e),c.mdia(e))},c.trex=function(e){e=e.id;return c.box(c.types.trex,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},c.trun=function(e,t){var r,i,a,n,s,o=e.samples||[],l=o.length,e=12+16*l,d=new Uint8Array(e);for(d.set([0,0,15,1,l>>>24&255,l>>>16&255,l>>>8&255,255&l,(t+=8+e)>>>24&255,t>>>16&255,t>>>8&255,255&t],0),r=0;r>>24&255,i>>>16&255,i>>>8&255,255&i,a>>>24&255,a>>>16&255,a>>>8&255,255&a,n.isLeading<<2|n.dependsOn,n.isDependedOn<<6|n.hasRedundancy<<4|n.paddingValue<<1|n.isNonSync,61440&n.degradPrio,15&n.degradPrio,s>>>24&255,s>>>16&255,s>>>8&255,255&s],12+16*r);return c.box(c.types.trun,d)},c.initSegment=function(e){c.types||c.init();var e=c.moov(e),t=new Uint8Array(c.FTYP.byteLength+e.byteLength);return t.set(c.FTYP),t.set(e,c.FTYP.byteLength),t},c}();function c(e,t,r,i){e=e*t*(r=void 0===r?1:r);return(i=void 0===i?!1:i)?Math.round(e):e}function V(e,t){return c(e,1e3,1/9e4,t=void 0===t?!1:t)}function f(e,t){return c(e,9e4,1/(t=void 0===t?1:t))}var T,U=f(10),Y=f(.2),D=function(){function e(e,t,r,i){this.observer=e,this.config=t,this.typeSupported=r;e=navigator.userAgent;this.isSafari=i&&-1>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:l+=String.fromCharCode(a);break;case 12:case 13:n=e[d++],l+=String.fromCharCode((31&a)<<6|63&n);break;case 14:n=e[d++],s=e[d++],l+=String.fromCharCode((15&a)<<12|(63&n)<<6|(63&s)<<0)}}return l},o}();var i=r._utf8ArrayToStr;t.default=r},"./src/demux/mp4demuxer.js":function(e,t,r){"use strict";r.r(t);var n=r("./src/utils/logger.js"),o=r("./src/events.js"),s=Math.pow(2,32)-1;t.default=function(){function h(e,t){this.observer=e,this.remuxer=t}var e=h.prototype;return e.resetTimeStamp=function(e){this.initPTS=e},e.resetInitSegment=function(e,t,r,i){var a,n;e&&e.byteLength?(null==t&&(t="mp4a.40.5"),null==r&&(r="avc1.42e01e"),n={},(a=this.initData=h.parseInitSegment(e)).audio&&a.video?n.audiovideo={container:"video/mp4",codec:t+","+r,initSegment:i?e:null}:(a.audio&&(n.audio={container:"audio/mp4",codec:t,initSegment:i?e:null}),a.video&&(n.video={container:"video/mp4",codec:r,initSegment:i?e:null})),this.observer.trigger(o.default.FRAG_PARSING_INIT_SEGMENT,{tracks:n})):(t&&(this.audioCodec=t),r&&(this.videoCodec=r))},h.probe=function(e){return 0>24,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r},h.findBox=function(e,t){var r,i,a,n,s,o=[];if(e.data?(n=e.start,i=e.end,e=e.data):(n=0,i=e.byteLength),!t.length)return null;for(r=n;r>>31)return;l=h.readUint32(i,o+=4);o+=4,a.push({referenceSize:d,subsegmentDuration:l,info:{duration:l/n,start:s,end:s+d-1}}),s+=d,r=o+=4}return{earliestPresentationTime:0,timescale:n,version:e,referencesCount:u,references:a,moovEndOffset:t}},h.parseInitSegment=function(e){var a=[];return h.findBox(e,["moov","trak"]).forEach(function(e){var t,r,i=h.findBox(e,["tkhd"])[0];i&&(r=i.data[i.start],i=h.readUint32(i,0===r?12:20),(t=h.findBox(e,["mdia","mdhd"])[0])&&(r=t.data[t.start],t=h.readUint32(t,0===r?12:20),!(r=h.findBox(e,["mdia","hdlr"])[0])||(r={soun:"audio",vide:"video"}[h.bin2str(r.data.subarray(r.start+8,r.start+12))])&&((e=h.findBox(e,["mdia","minf","stbl","stsd"])).length&&(e=e[0],e=h.bin2str(e.data.subarray(e.start+12,e.start+16)),n.logger.log("MP4Demuxer:"+r+":"+e+" found")),a[i]={timescale:t,type:r},a[r]={timescale:t,id:i})))}),a},h.getStartDTS=function(r,e){e=h.findBox(e,["moof","traf"]),e=[].concat.apply([],e.map(function(t){return h.findBox(t,["tfhd"]).map(function(e){e=h.readUint32(e,4),e=r[e].timescale||9e4;return h.findBox(t,["tfdt"]).map(function(e){var t=e.data[e.start],r=h.readUint32(e,4);return r=1===t?(r*=Math.pow(2,32))+h.readUint32(e,8):r})[0]/e})})),e=Math.min.apply(null,e);return isFinite(e)?e:0},h.offsetStartDTS=function(r,e,a){h.findBox(e,["moof","traf"]).map(function(t){return h.findBox(t,["tfhd"]).map(function(e){var e=h.readUint32(e,4),i=r[e].timescale||9e4;h.findBox(t,["tfdt"]).map(function(e){var t=e.data[e.start],r=h.readUint32(e,4);0===t?h.writeUint32(e,4,r-a*i):(r=(r=(r*=Math.pow(2,32))+h.readUint32(e,8))-a*i,r=Math.max(r,0),t=Math.floor(r/(1+s)),r=Math.floor(r%(1+s)),h.writeUint32(e,4,t),h.writeUint32(e,8,r))})})})},e.append=function(e,t,r,i){var a=this.initData;a||(this.resetInitSegment(e,this.audioCodec,this.videoCodec,!1),a=this.initData);var n,s=this.initPTS;void 0===s&&(n=h.getStartDTS(a,e),this.initPTS=s=n-t,this.observer.trigger(o.default.INIT_PTS_FOUND,{initPTS:s})),h.offsetStartDTS(a,e,s),n=h.getStartDTS(a,e),this.remuxer.remux(a.audio,a.video,null,null,n,r,i,e)},e.destroy=function(){},h}()},"./src/errors.ts":function(e,t,r){"use strict";var i,a;r.r(t),r.d(t,"ErrorTypes",function(){return i}),r.d(t,"ErrorDetails",function(){return a}),(r=i=i||{}).NETWORK_ERROR="networkError",r.MEDIA_ERROR="mediaError",r.KEY_SYSTEM_ERROR="keySystemError",r.MUX_ERROR="muxError",r.OTHER_ERROR="otherError",(t=a=a||{}).KEY_SYSTEM_NO_KEYS="keySystemNoKeys",t.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",t.KEY_SYSTEM_NO_SESSION="keySystemNoSession",t.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",t.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",t.MANIFEST_LOAD_ERROR="manifestLoadError",t.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",t.MANIFEST_PARSING_ERROR="manifestParsingError",t.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",t.LEVEL_LOAD_ERROR="levelLoadError",t.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",t.LEVEL_SWITCH_ERROR="levelSwitchError",t.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",t.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",t.FRAG_LOAD_ERROR="fragLoadError",t.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",t.FRAG_DECRYPT_ERROR="fragDecryptError",t.FRAG_PARSING_ERROR="fragParsingError",t.REMUX_ALLOC_ERROR="remuxAllocError",t.KEY_LOAD_ERROR="keyLoadError",t.KEY_LOAD_TIMEOUT="keyLoadTimeOut",t.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",t.BUFFER_APPEND_ERROR="bufferAppendError",t.BUFFER_APPENDING_ERROR="bufferAppendingError",t.BUFFER_STALLED_ERROR="bufferStalledError",t.BUFFER_FULL_ERROR="bufferFullError",t.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",t.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",t.INTERNAL_EXCEPTION="internalException"},"./src/events.js":function(e,t,r){"use strict";r.r(t);t.default={MEDIA_ATTACHING:"hlsMediaAttaching",MEDIA_ATTACHED:"hlsMediaAttached",MEDIA_DETACHING:"hlsMediaDetaching",MEDIA_DETACHED:"hlsMediaDetached",BUFFER_RESET:"hlsBufferReset",BUFFER_CODECS:"hlsBufferCodecs",BUFFER_CREATED:"hlsBufferCreated",BUFFER_APPENDING:"hlsBufferAppending",BUFFER_APPENDED:"hlsBufferAppended",BUFFER_EOS:"hlsBufferEos",BUFFER_FLUSHING:"hlsBufferFlushing",BUFFER_FLUSHED:"hlsBufferFlushed",MANIFEST_LOADING:"hlsManifestLoading",MANIFEST_LOADED:"hlsManifestLoaded",MANIFEST_PARSED:"hlsManifestParsed",LEVEL_SWITCHING:"hlsLevelSwitching",LEVEL_SWITCHED:"hlsLevelSwitched",LEVEL_LOADING:"hlsLevelLoading",LEVEL_LOADED:"hlsLevelLoaded",LEVEL_UPDATED:"hlsLevelUpdated",LEVEL_PTS_UPDATED:"hlsLevelPtsUpdated",AUDIO_TRACKS_UPDATED:"hlsAudioTracksUpdated",AUDIO_TRACK_SWITCHING:"hlsAudioTrackSwitching",AUDIO_TRACK_SWITCHED:"hlsAudioTrackSwitched",AUDIO_TRACK_LOADING:"hlsAudioTrackLoading",AUDIO_TRACK_LOADED:"hlsAudioTrackLoaded",SUBTITLE_TRACKS_UPDATED:"hlsSubtitleTracksUpdated",SUBTITLE_TRACK_SWITCH:"hlsSubtitleTrackSwitch",SUBTITLE_TRACK_LOADING:"hlsSubtitleTrackLoading",SUBTITLE_TRACK_LOADED:"hlsSubtitleTrackLoaded",SUBTITLE_FRAG_PROCESSED:"hlsSubtitleFragProcessed",INIT_PTS_FOUND:"hlsInitPtsFound",FRAG_LOADING:"hlsFragLoading",FRAG_LOAD_PROGRESS:"hlsFragLoadProgress",FRAG_LOAD_EMERGENCY_ABORTED:"hlsFragLoadEmergencyAborted",FRAG_LOADED:"hlsFragLoaded",FRAG_DECRYPTED:"hlsFragDecrypted",FRAG_PARSING_INIT_SEGMENT:"hlsFragParsingInitSegment",FRAG_PARSING_USERDATA:"hlsFragParsingUserdata",FRAG_PARSING_METADATA:"hlsFragParsingMetadata",FRAG_PARSING_DATA:"hlsFragParsingData",FRAG_PARSED:"hlsFragParsed",FRAG_BUFFERED:"hlsFragBuffered",FRAG_CHANGED:"hlsFragChanged",FPS_DROP:"hlsFpsDrop",FPS_DROP_LEVEL_CAPPING:"hlsFpsDropLevelCapping",ERROR:"hlsError",DESTROYING:"hlsDestroying",KEY_LOADING:"hlsKeyLoading",KEY_LOADED:"hlsKeyLoaded",STREAM_STATE_TRANSITION:"hlsStreamStateTransition",LIVE_BACK_BUFFER_REACHED:"hlsLiveBackBufferReached"}},"./src/hls.ts":function(t,r,e){"use strict";e.r(r);var f,s,i={},a=(e.r(i),e.d(i,"newCue",function(){return ht}),e("./node_modules/url-toolkit/src/url-toolkit.js")),d=e("./src/errors.ts"),w=e("./src/polyfills/number-isFinite.js"),E=e("./src/events.js"),D=e("./src/utils/logger.js"),o={hlsEventGeneric:!0,hlsHandlerDestroying:!0,hlsHandlerDestroyed:!0},n=function(){function e(e){this.hls=void 0,this.handledEvents=void 0,this.useGenericHandler=void 0,this.hls=e,this.onEvent=this.onEvent.bind(this);for(var t=arguments.length,r=new Array(1>8*(15-r)&255;return t},i.setDecryptDataFromLevelKey=function(e,t){var r=e;return e&&e.method&&e.uri&&!e.iv&&((r=new O(e.baseuri,e.reluri)).method=e.method,r.iv=this.createInitializationVector(t)),r},i=e,(t=[{key:"url",get:function(){return!this._url&&this.relurl&&(this._url=Object(a.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url},set:function(e){this._url=e}},{key:"byteRange",get:function(){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.levelkey||this._decryptdata?(!this._decryptdata&&this.levelkey&&("number"!=typeof(e=this.sn)&&(this.levelkey&&"AES-128"===this.levelkey.method&&!this.levelkey.iv&&D.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),e=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,e)),this._decryptdata):null;var e}},{key:"endProgramDateTime",get:function(){if(null===this.programDateTime)return null;if(!Object(w.isFiniteNumber)(this.programDateTime))return null;var e=Object(w.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+1e3*e}},{key:"encrypted",get:function(){return!(!this.decryptdata||null===this.decryptdata.uri||null!==this.decryptdata.key)}}])&&g(i.prototype,t),r&&g(i,r),e}();function m(e,t){for(var r=0;rNumber.MAX_SAFE_INTEGER?1/0:e},e.hexadecimalInteger=function(e){if(this[e]){for(var t=(1&(t=(this[e]||"0x").slice(2)).length?"0":"")+t,r=new Uint8Array(t.length/2),i=0;iNumber.MAX_SAFE_INTEGER?1/0:e},e.decimalFloatingPoint=function(e){return parseFloat(this[e])},e.enumeratedString=function(e){return this[e]},e.decimalResolution=function(e){e=v.exec(this[e]);if(null!==e)return{width:parseInt(e[1],10),height:parseInt(e[2],10)}},r.parseAttrList=function(e){var t,r={};for(y.lastIndex=0;null!==(t=y.exec(e));){var i=t[2];0===i.indexOf('"')&&i.lastIndexOf('"')===i.length-1&&(i=i.slice(1,-1)),r[t[1]]=i}return r},r}(),b={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}};function S(e,t){return MediaSource.isTypeSupported((t||"video")+'/mp4;codecs="'+e+'"')}var _=/#EXT-X-STREAM-INF:([^\n\r]*)[\r\n]+([^\r\n]+)/g,R=/#EXT-X-MEDIA:(.*)/g,P=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/|(?!#)([\S+ ?]+)/.source,/|#EXT-X-BYTERANGE:*(.+)/.source,/|#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/|#.*/.source].join(""),"g"),F=/(?:(?:#(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?/,M=/\.(mp4|m4s|m4v|m4a)$/i,A=function(){function l(){}return l.findGroup=function(e,t){for(var r=0;r=r.start(i)&&t<=r.end(i))return!0}catch(e){}return!1},e.bufferInfo=function(e,t,r){try{if(e){for(var i=e.buffered,a=[],n=0;nn&&(i[s-1].end=e[a].end):i.push(e[a])):i.push(e[a])}else i=e;for(var o,u=0,c=t,h=t,l=0;le.endSN)return 0;for(a=l-e.startSN,(s=e.fragments)[a]=t,o=a;0u.length))for(var d=0;dr.startCC||e&&e.cce}(t,r,a))return a}return null}function he(e,t,r,i){void 0===r&&(r=0),void 0===i&&(i=0);e=e?t[e.sn-t[0].sn+1]:null;return e&&!fe(r,i,e)?e:V.search(t,fe.bind(null,r,i))}function fe(e,t,r){void 0===e&&(e=0),void 0===t&&(t=0);t=Math.min(t,r.duration+(r.deltaPTS||0));return r.start+r.duration-t<=e?1:r.start-t>e&&r.start?-1:0}var ge=function(){function e(e,t,r,i){this.config=e,this.media=t,this.fragmentTracker=r,this.hls=i,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1}var t=e.prototype;return t.poll=function(e){var t=this.config,r=this.media,i=this.stalled,a=r.currentTime,n=r.seeking,s=this.seeking&&!n,o=!this.seeking&&n;if(this.seeking=n,a!==e)return this.moved=!0,void(null!==i&&(this.stallReported&&(e=self.performance.now()-i,D.logger.warn("playback not stuck anymore @"+a+", after "+Math.round(e)+"ms"),this.stallReported=!1),this.stalled=null,this.nudgeRetry=0));if((o||s)&&(this.stalled=null),!r.paused&&!r.ended&&0!==r.playbackRate&&r.buffered.length){e=Y.bufferInfo(r,a,0),o=0r.maxBufferHole&&t>1e3*r.highBufferWatchdogPeriod&&(D.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},t._reportStall=function(e){var t=this.hls,r=this.media;this.stallReported||(this.stallReported=!0,D.logger.warn("Playback stalling at @"+r.currentTime+" due to low buffer"),t.trigger(E.default.ERROR,{type:d.ErrorTypes.MEDIA_ERROR,details:d.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:e}))},t._trySkipBufferHole=function(e){for(var t=this.config,r=this.hls,i=this.media,a=i.currentTime,n=0,s=0;s=n&&ad&&d>l.currentTime&&(D.logger.log("buffer end: "+t.toFixed(3)+" is located too far from the end of live sliding playlist, reset currentTime to : "+d.toFixed(3)),l.currentTime=d),this.nextLoadPosition=d),e.PTSKnown&&i=e.startSN&&r<=e.endSN&&(d=n[r-e.startSN],a.cc===d.cc&&D.logger.log("live playlist, switching playlist, load frag with next SN: "+(s=d).sn)),s||(s=V.search(n,function(e){return a.cc-e.cc}))&&D.logger.log("live playlist, switching playlist, load frag with same CC: "+s.sn))),s||(s=n[Math.min(u-1,Math.round(u/2))],D.logger.log("live playlist, switching playlist, unknown, load middle frag : "+s.sn))),s)},a._findFragment=function(e,t,r,i,a,n,s){var o,l=this.hls.config;return(a=an-l.maxFragLookUpTolerance?0:l.maxFragLookUpTolerance):i[r-1])&&(n=a.sn-s.startSN,r=t&&a.level===t.level,o=i[n-1],i=i[1+n],t&&a.sn===t.sn&&(r&&!a.backtracked?a.snl.maxBufferHole&&t.dropped&&n?(a=o,D.logger.warn("Previous fragment was dropped with large PTS gap between audio and video. Maybe fragment is not starting with a keyframe? Loading previous one to try to overcome this")):D.logger.log("Re-loading fragment with SN: "+(a=i).sn):a=null:a.backtracked&&(i&&i.backtracked?(D.logger.warn("Already backtracked from fragment "+i.sn+", will not backtrack to fragment "+a.sn+". Loading fragment "+i.sn),a=i):(D.logger.warn("Loaded fragment with dropped frames, backtracking 1 segment to find a keyframe"),a.dropped=0,o?(a=o).backtracked=!0:n&&(a=null))))),a},a._loadKey=function(e){this.state=ye,this.hls.trigger(E.default.KEY_LOADING,{frag:e})},a._loadFragment=function(e){var t=this.fragmentTracker.getState(e);"initSegment"!==(this.fragCurrent=e).sn&&(this.startFragRequested=!0),Object(w.isFiniteNumber)(e.sn)&&!e.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),e.backtracked||t===B||t===j?(e.autoLevel=this.hls.autoLevelEnabled,e.bitrateTest=this.bitrateTest,this.hls.trigger(E.default.FRAG_LOADING,{frag:e}),this.demuxer||(this.demuxer=new ee(this.hls,"main")),this.state=Ee):t===G&&this._reduceMaxBufferLength(e.duration)&&this.fragmentTracker.removeFragment(e)},a.getBufferedFrag=function(e){return this.fragmentTracker.getBufferedFrag(e,s.MAIN)},a.followingBufferedFrag=function(e){return e?this.getBufferedFrag(e.endPTS+.5):null},a._checkFragmentChanged=function(){var e,t,r=this.media;r&&r.readyState&&!1===r.seeking&&((t=r.currentTime)>this.lastCurrentTime&&(this.lastCurrentTime=t),Y.isBuffered(r,t)?e=this.getBufferedFrag(t):Y.isBuffered(r,t+.1)&&(e=this.getBufferedFrag(t+.1)),!e||(r=e)!==this.fragPlaying&&(this.hls.trigger(E.default.FRAG_CHANGED,{frag:r}),t=r.level,this.fragPlaying&&this.fragPlaying.level===t||this.hls.trigger(E.default.LEVEL_SWITCHED,{level:t}),this.fragPlaying=r))},a.immediateLevelSwitch=function(){D.logger.log("immediateLevelSwitch"),this.immediateSwitch||(this.immediateSwitch=!0,(t=this.media)?(e=t.paused,t.pause()):e=!0,this.previouslyPaused=e);var e,t=this.fragCurrent;t&&t.loader&&t.loader.abort(),this.fragCurrent=null,this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},a.immediateLevelSwitchEnd=function(){var e=this.media;e&&e.buffered.length&&(this.immediateSwitch=!1,Y.isBuffered(e,e.currentTime)&&(e.currentTime-=1e-4),this.previouslyPaused||e.play())},a.nextLevelSwitch=function(){var e,t,r=this.media;r&&r.readyState&&((t=this.getBufferedFrag(r.currentTime))&&1=e&&(t.maxMaxBufferLength/=2,D.logger.warn("main:reduce max buffer length to "+t.maxMaxBufferLength+"s"),!0)},a._checkBuffer=function(){var e=this.media;e&&0!==e.readyState&&(e=(this.mediaBuffer||e).buffered,!this.loadedmetadata&&e.length?(this.loadedmetadata=!0,this._seekToStartPos()):this.immediateSwitch?this.immediateLevelSwitchEnd():this.gapController.poll(this.lastCurrentTime,e))},a.onFragLoadEmergencyAborted=function(){this.state=T,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tick()},a.onBufferFlushed=function(){var e=this.mediaBuffer||this.media;e&&this.fragmentTracker.detectEvictedFragments(h.VIDEO,e.buffered),this.state=T,this.fragPrevious=null},a.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},a._seekToStartPos=function(){var e=this.media,t=e.currentTime,r=e.seeking?t:this.startPosition;t!==r&&0<=r&&(D.logger.log("target start position not buffered, seek to buffered.start(0) "+r+" from current time "+t+" "),e.currentTime=r)},a._getAudioCodec=function(e){e=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&(D.logger.log("swapping playlist audio codec"),e=e&&(-1!==e.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5")),e},t=e,(a=[{key:"state",set:function(e){var t;this.state!==e&&(t=this.state,this._state=e,D.logger.log("main stream-controller: "+t+"->"+e),this.hls.trigger(E.default.STREAM_STATE_TRANSITION,{previousState:t,nextState:e}))},get:function(){return this._state}},{key:"currentLevel",get:function(){var e=this.media;if(e){e=this.getBufferedFrag(e.currentTime);if(e)return e.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}}])&&De(t.prototype,a),r&&De(t,r),e}(Q);function Ce(e,t){for(var r=0;re[e.length-1].endTime)return e[e.length-1];for(var r=0,i=e.length-1;r<=i;){var a=Math.floor((i+r)/2);if(te[a].endTime))return e[a];r=a+1}}return e[r].endTime-t=this.minWeight_},t.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},t.destroy=function(){},e}();function Ge(e,t){for(var r=0;r500*r.duration/c){var s=e.levels,h=Math.max(1,a.bw?a.bw/8:1e3*a.loaded/n),o=s[r.level],o=o.realBitrate?Math.max(o.realBitrate,o.bitrate):o.bitrate,o=a.total||Math.max(a.loaded,Math.round(r.duration*o/8)),f=t.currentTime,o=(o-a.loaded)/h,l=(Y.bufferInfo(t,f,e.config.maxBufferHole).end-f)/c;if(l<2*r.duration/c&&ls.start(0)&&this.removeBufferRange(o,l,0,a)&&this.hls.trigger(E.default.LIVE_BACK_BUFFER_REACHED,{bufferEnd:a})}else D.logger.error("flushLiveBackBuffer called without attaching media")}},i.onLevelUpdated=function(e){e=e.details;0this._msDuration&&this._levelDuration>e||!Object(w.isFiniteNumber)(e))&&(D.logger.log("Updating Media Source duration to "+this._levelDuration.toFixed(3)),this._msDuration=this.mediaSource.duration=this._levelDuration)}},i.doFlush=function(){for(;this.flushRange.length;){var e=this.flushRange[0];if(!this.flushBuffer(e.start,e.end,e.type))return void(this._needsFlush=!0);this.flushRange.shift(),this.flushBufferCounter=0}if(0===this.flushRange.length){this._needsFlush=!1;var t=0,r=this.sourceBuffer;try{for(var i in r){var a=r[i];a&&(t+=a.buffered.length)}}catch(e){D.logger.error("error while accessing sourceBuffer.buffered")}this.appended=t,this.hls.trigger(E.default.BUFFER_FLUSHED)}},i.doAppending=function(){var t=this.config,r=this.hls,i=this.segments,a=this.sourceBuffer;if(Object.keys(a).length){if(!this.media||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){var n=i.shift();if(n)try{var e=a[n.type];if(!e)return void this._onSBUpdateEnd();if(e.updating)return void i.unshift(n);e.ended=!1,this.parent=n.parent,e.appendBuffer(n.data),this.appendError=0,this.appended++,this.appending=!0}catch(e){D.logger.error("error while trying to append buffer:"+e.message),i.unshift(n);a={type:d.ErrorTypes.MEDIA_ERROR,parent:n.parent,details:"",fatal:!1};22===e.code?(this.segments=[],a.details=d.ErrorDetails.BUFFER_FULL_ERROR):(this.appendError++,a.details=d.ErrorDetails.BUFFER_APPEND_ERROR,this.appendError>t.appendErrorMaxRetry&&(D.logger.log("fail "+t.appendErrorMaxRetry+" times to append segment in sourceBuffer"),this.segments=[],a.fatal=!0)),r.trigger(E.default.ERROR,a)}}}},i.flushBuffer=function(e,t,r){var i=this.sourceBuffer;if(!Object.keys(i).length)return!0;var a="null";if(this.media&&(a=this.media.currentTime.toFixed(3)),D.logger.log("flushBuffer,pos/start/end: "+a+"/"+e+"/"+t),this.flushBufferCounter>=this.appended)return D.logger.warn("abort flushing too many retries"),!0;a=i[r];if(a){if(a.ended=!1,a.updating)return D.logger.warn("cannot flush, sb updating in progress"),!1;if(this.removeBufferRange(r,a,e,t))return this.flushBufferCounter++,!1}return D.logger.log("buffer flushed"),!0},i.removeBufferRange=function(e,t,r,i){try{for(var a=0;athis.autoLevelCapping&&t.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping)},i.getMaxLevel=function(r){var i=this;if(!this.levels)return-1;var e=this.levels.filter(function(e,t){return a.isLevelAllowed(t,i.restrictedLevels)&&t<=r});return a.getMaxLevelByMediaSize(e,this.mediaWidth,this.mediaHeight)},i.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),clearInterval(this.timer),this.timer=setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},i.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=null,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(this.timer=clearInterval(this.timer),this.timer=null)},a.isLevelAllowed=function(e,t){return-1===(t=void 0===t?[]:t).indexOf(e)},a.getMaxLevelByMediaSize=function(e,t,r){if(!e||!e.length)return-1;for(var i,a=e.length-1,n=0;n=t||s.height>=r)&&(s=s,!(i=e[n+1])||(s.width!==i.width||s.height!==i.height))){a=n;break}}return a},e=a,i=[{key:"contentScaleFactor",get:function(){var e=1;try{e=window.devicePixelRatio}catch(e){}return e}}],(r=[{key:"mediaWidth",get:function(){var e,t=this.media;return t&&(e=t.width||t.clientWidth||t.offsetWidth,e*=a.contentScaleFactor),e}},{key:"mediaHeight",get:function(){var e,t=this.media;return t&&(e=t.height||t.clientHeight||t.offsetHeight,e*=a.contentScaleFactor),e}}])&&Ye(e.prototype,r),i&&Ye(e,i),a}(n);var qe=window.performance,ze=function(t){var e;function r(e){return t.call(this,e,E.default.MEDIA_ATTACHING)||this}e=t,(i=r).prototype=Object.create(e.prototype),(i.prototype.constructor=i).__proto__=e;var i=r.prototype;return i.destroy=function(){this.timer&&clearInterval(this.timer),this.isVideoPlaybackQualityAvailable=!1},i.onMediaAttaching=function(e){var t=this.hls.config;t.capLevelOnFPSDrop&&("function"==typeof(this.video=e.media instanceof window.HTMLVideoElement?e.media:null).getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),clearInterval(this.timer),this.timer=setInterval(this.checkFPSInterval.bind(this),t.fpsDroppedMonitoringPeriod))},i.checkFPS=function(e,t,r){var i,a,n,s,o=qe.now();t&&(this.lastTime&&(s=o-this.lastTime,i=r-this.lastDroppedFrames,a=t-this.lastDecodedFrames,s=1e3*i/s,(n=this.hls).trigger(E.default.FPS_DROP,{currentDropped:i,currentDecoded:a,totalDroppedFrames:r}),0n.config.fpsDroppedMonitoringThreshold*a&&(s=n.currentLevel,D.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+s),0=s)&&(n.trigger(E.default.FPS_DROP_LEVEL_CAPPING,{level:s-=1,droppedLevel:n.currentLevel}),n.autoLevelCapping=s,n.streamController.nextLevelSwitch()))),this.lastTime=o,this.lastDroppedFrames=r,this.lastDecodedFrames=t)},i.checkFPSInterval=function(){var e,t=this.video;t&&(this.isVideoPlaybackQualityAvailable?(e=t.getVideoPlaybackQuality(),this.checkFPS(t,e.totalVideoFrames,e.droppedVideoFrames)):this.checkFPS(t,t.webkitDecodedFrameCount,t.webkitDroppedFrameCount))},r}(n),Xe=window,Qe=Xe.performance,$e=Xe.XMLHttpRequest,Xe=function(){function e(e){e&&e.xhrSetup&&(this.xhrSetup=e.xhrSetup)}var t=e.prototype;return t.destroy=function(){this.abort(),this.loader=null},t.abort=function(){var e=this.loader;e&&4!==e.readyState&&(this.stats.aborted=!0,e.abort()),window.clearTimeout(this.requestTimeout),this.requestTimeout=null,window.clearTimeout(this.retryTimeout),this.retryTimeout=null},t.load=function(e,t,r){this.context=e,this.config=t,this.callbacks=r,this.stats={trequest:Qe.now(),retry:0},this.retryDelay=t.retryDelay,this.loadInternal()},t.loadInternal=function(){var t=this.context,r=this.loader=new $e,i=this.stats,i=(i.tfirst=0,i.loaded=0,this.xhrSetup);try{if(i)try{i(r,t.url)}catch(e){r.open("GET",t.url,!0),i(r,t.url)}r.readyState||r.open("GET",t.url,!0)}catch(e){return void this.callbacks.onError({code:r.status,text:e.message},t,r)}t.rangeEnd&&r.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),r.onreadystatechange=this.readystatechange.bind(this),r.onprogress=this.loadprogress.bind(this),r.responseType=t.responseType,this.requestTimeout=window.setTimeout(this.loadtimeout.bind(this),this.config.timeout),r.send()},t.readystatechange=function(e){var t,r,e=e.currentTarget,i=e.readyState,a=this.stats,n=this.context,s=this.config;a.aborted||2<=i&&(window.clearTimeout(this.requestTimeout),0===a.tfirst&&(a.tfirst=Math.max(Qe.now(),a.trequest)),4===i?200<=(i=e.status)&&i<300?(a.tload=Math.max(a.tfirst,Qe.now()),r="arraybuffer"===n.responseType?(t=e.response).byteLength:(t=e.responseText).length,a.loaded=a.total=r,r={url:e.responseURL,data:t},this.callbacks.onSuccess(r,a,n,e)):a.retry>=s.maxRetry||400<=i&&i<499?(D.logger.error(i+" while loading "+n.url),this.callbacks.onError({code:i,text:e.statusText},n,e)):(D.logger.warn(i+" while loading "+n.url+", retrying in "+this.retryDelay+"..."),this.destroy(),this.retryTimeout=window.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,s.maxRetryDelay),a.retry++):this.requestTimeout=window.setTimeout(this.loadtimeout.bind(this),s.timeout))},t.loadtimeout=function(){D.logger.warn("timeout while loading "+this.context.url),this.callbacks.onTimeout(this.stats,this.context,null)},t.loadprogress=function(e){var t=e.currentTarget,r=this.stats,e=(r.loaded=e.loaded,e.lengthComputable&&(r.total=e.total),this.callbacks.onProgress);e&&e(r,this.context,null,t)},e}();function Je(e,t){for(var r=0;r=this.tracks.length?D.logger.warn("Invalid audio track id:",e.id):(D.logger.log("audioTrack "+e.id+" loaded"),this.tracks[e.id].details=e.details,e.details.live&&!this.hasInterval()&&(t=1e3*e.details.targetduration,this.setInterval(t)),!e.details.live&&this.hasInterval()&&this.clearInterval())},a.onAudioTrackSwitched=function(e){e=this.tracks[e.id].groupId;e&&this.audioGroupId!==e&&(this.audioGroupId=e)},a.onLevelLoaded=function(e){this._selectAudioGroup(e.level)},a.onError=function(e){e.type===d.ErrorTypes.NETWORK_ERROR&&(e.fatal&&this.clearInterval(),e.details===d.ErrorDetails.AUDIO_TRACK_LOAD_ERROR&&(D.logger.warn("Network failure on audio-track id:",e.context.id),this._handleLoadError()))},a._setAudioTrack=function(e){var t,r,i;this._trackId===e&&this.tracks[this._trackId].details?D.logger.debug("Same id as current audio-track passed, and track details available -> no-op"):e<0||e>=this.tracks.length?D.logger.warn("Invalid id passed to audio-track controller"):(t=this.tracks[e],D.logger.log("Now switching to audio-track index "+e),this.clearInterval(),this._trackId=e,e=t.url,r=t.type,i=t.id,this.hls.trigger(E.default.AUDIO_TRACK_SWITCHING,{id:i,type:r,url:e}),this._loadTrackDetailsIfNeeded(t))},a.doTick=function(){this._updateTrack(this._trackId)},a._selectAudioGroup=function(e){var e=this.hls.levels[e];e&&e.audioGroupIds&&(e=e.audioGroupIds[e.urlId],this.audioGroupId!==e&&(this.audioGroupId=e,this._selectInitialAudioTrack()))},a._selectInitialAudioTrack=function(){var t,r,e,i=this,a=this.tracks;a.length&&(e=this.tracks[this._trackId],t=null,e&&(t=e.name),this._selectDefaultTrack&&((e=a.filter(function(e){return e.default})).length?a=e:D.logger.warn("No default audio tracks defined")),r=!1,(e=function(){a.forEach(function(e){r||i.audioGroupId&&e.groupId!==i.audioGroupId||t&&t!==e.name||(i._setAudioTrack(e.id),r=!0)})})(),r||(t=null,e()),r||(D.logger.error("No track found for running audio group-ID: "+this.audioGroupId),this.hls.trigger(E.default.ERROR,{type:d.ErrorTypes.MEDIA_ERROR,details:d.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0})))},a._needsTrackLoading=function(e){var t=e.details,e=e.url;return!(t&&!t.live)&&!!e},a._loadTrackDetailsIfNeeded=function(e){var t;this._needsTrackLoading(e)&&(t=e.url,e=e.id,D.logger.log("loading audio-track playlist for id: "+e),this.hls.trigger(E.default.AUDIO_TRACK_LOADING,{url:t,id:e}))},a._updateTrack=function(e){e<0||e>=this.tracks.length||(this.clearInterval(),this._trackId=e,D.logger.log("trying to update audio-track "+e),e=this.tracks[e],this._loadTrackDetailsIfNeeded(e))},a._handleLoadError=function(){this.trackIdBlacklist[this._trackId]=!0;for(var e=this._trackId,t=this.tracks[e],r=t.name,i=t.language,t=t.groupId,a=(D.logger.warn("Loading failed on audio track id: "+e+", group-id: "+t+', name/language: "'+r+'" / "'+i+'"'),e),n=0;nr||i.nextStart))return;D.logger.log("alt audio track ahead of main track, seek to start of alt audio track"),this.media.currentTime=r+.05}if(t.initSegment&&!t.initSegment.data)d=t.initSegment;else if(n<=r){var d=a[0];if(null!==this.videoTrackCC&&d.cc!==this.videoTrackCC&&(c=this.videoTrackCC,d=V.search(a,function(e){return e.ccc?-1:0})),t.live&&d.loadIdx&&d.loadIdx===this.fragLoadIdx)return i=i.nextStart||r,D.logger.log("no alt audio available @currentTime:"+this.media.currentTime+", seeking @"+(i+.05)),void(this.media.currentTime=i+.05)}else{var v=f.maxFragLookUpTolerance,i=s?a[s.sn-a[0].sn+1]:void 0,y=function(e){var t=Math.min(v,e.duration);return e.start+e.duration-t<=n?1:e.start-t>n&&e.start?-1:0},l=n=t.startPTS&&(D.logger.log("switching audio track : flushing all audio"),this.state=Re,n.trigger(E.default.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),this.audioSwitch=!(s=!0),n.trigger(E.default.AUDIO_TRACK_SWITCHED,{id:i}))):(this.audioSwitch=!1,n.trigger(E.default.AUDIO_TRACK_SWITCHED,{id:i}))),this.pendingData);if(!o)return D.logger.warn("Apparently attempt to enqueue media payload without codec initialization data upfront"),void n.trigger(E.default.ERROR,{type:d.ErrorTypes.MEDIA_ERROR,details:null,fatal:!0});this.audioSwitch||([t.data1,t.data2].forEach(function(e){e&&e.length&&o.push({type:t.type,data:e,parent:"audio",content:"data"})}),!s&&o.length&&(o.forEach(function(e){r.state===Se&&(r.pendingBuffering=!0,r.hls.trigger(E.default.BUFFER_APPENDING,e))}),this.pendingData=[],this.appended=!0)),this.tick()}},a.onFragParsed=function(e){var t=this.fragCurrent,r=e.frag;t&&"audio"===e.id&&r.sn===t.sn&&r.level===t.level&&this.state===Se&&(this.stats.tparsed=tt.now(),this.state=_e,this._checkAppendedParsed())},a.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},a.onBufferCreated=function(e){var t=e.tracks.audio;t&&(this.mediaBuffer=t.buffer,this.loadedmetadata=!0),e.tracks.video&&(this.videoBuffer=e.tracks.video.buffer)},a.onBufferAppended=function(e){var t;"audio"===e.parent&&((t=this.state)!==Se&&t!==_e||(this.pendingBuffering=0=r.maxBufferLength&&(r.maxMaxBufferLength/=2,D.logger.warn("AudioStreamController: reduce max buffer length to "+r.maxMaxBufferLength+"s")),this.state=T):(D.logger.warn("AudioStreamController: buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,this.state=Re,this.hls.trigger(E.default.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"})))}},a.onBufferFlushed=function(){var t=this,e=this.pendingData;e&&e.length?(D.logger.log("AudioStreamController: appending pending audio data after buffer flushed"),e.forEach(function(e){t.hls.trigger(E.default.BUFFER_APPENDING,e)}),this.appended=!0,this.pendingData=[],this.state=_e):(this.state=T,this.fragPrevious=null,this.tick())},t=e,(a=[{key:"state",set:function(e){var t;this.state!==e&&(t=this.state,this._state=e,D.logger.log("audio stream:"+t+"->"+e))},get:function(){return this._state}}])&&Ze(t.prototype,a),r&&Ze(t,r),e}(Q),it=function(){if("undefined"!=typeof window&&window.VTTCue)return window.VTTCue;var E={"":!0,lr:!0,rl:!0},t={start:!0,middle:!0,end:!0,left:!0,right:!0};function T(e){return"string"==typeof e&&(!!t[e.toLowerCase()]&&e.toLowerCase())}function b(e){for(var t=1;t/gi,"\n")}at.prototype={parse:function(e){var i=this;function t(){for(var e=0,t=ut(t=i.buffer);e>>0).toString()}var vt={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},yt=100,Et={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},Tt={17:2,18:4,21:6,22:8,23:10,19:13,20:15},bt={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},St={25:2,26:4,29:6,30:8,31:10,27:13,28:15},_t=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],l=((xt={ERROR:0,0:"ERROR",TEXT:1,1:"TEXT",WARNING:2,2:"WARNING",INFO:2})[2]="INFO",xt[xt.DEBUG=3]="DEBUG",xt[xt.DATA=3]="DATA",{verboseFilter:{DATA:3,DEBUG:3,INFO:2,WARNING:2,TEXT:1,ERROR:0},time:null,verboseLevel:0,setTime:function(e){this.time=e},log:function(e,t){this.verboseFilter[e];this.verboseLevel}}),Rt=function(){function e(e,t,r,i,a){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=e||"white",this.underline=t||!1,this.italics=r||!1,this.background=i||"black",this.flash=a||!1}var t=e.prototype;return t.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},t.setStyles=function(e){for(var t=["foreground","underline","italics","background","flash"],r=0;ryt&&(l.log("ERROR","Too large cursor position "+this.pos),this.pos=yt)},t.moveCursor=function(e){var t=this.pos+e;if(1=yt?l.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))},t.clearFromPos=function(e){for(var t=e;t ("+gt([n,s])+")"),(r=(r=(r=(r=this.parseCmd(n,s))||this.parseMidrow(n,s))||this.parsePAC(n,s))||this.parseBackgroundAttributes(n,s))||(i=this.parseChars(n,s))&&(this.currChNr&&0<=this.currChNr?this.channels[this.currChNr-1].insertChars(i):l.log("WARNING","No channel found yet. TEXT-MODE?")),r?this.dataCounters.cmd+=2:i?this.dataCounters.char+=2:(this.dataCounters.other+=2,l.log("WARNING","Couldn't parse cleaned data "+gt([n,s])+" orig: "+gt([t[a],t[a+1]])))):this.dataCounters.padding+=2}},t.parseCmd=function(e,t){var r=null;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,l.log("DEBUG","Repeated command ("+gt([e,t])+") is dropped"),!0;var r=20===e||23===e?1:2,i=this.channels[r-1];return 20===e||28===e?32===t?i.ccRCL():33===t?i.ccBS():34===t?i.ccAOF():35===t?i.ccAON():36===t?i.ccDER():37===t?i.ccRU(2):38===t?i.ccRU(3):39===t?i.ccRU(4):40===t?i.ccFON():41===t?i.ccRDC():42===t?i.ccTR():43===t?i.ccRTD():44===t?i.ccEDM():45===t?i.ccCR():46===t?i.ccENM():47===t&&i.ccEOC():i.ccTO(t-32),this.lastCmdA=e,this.lastCmdB=t,this.currChNr=r,!0},t.parseMidrow=function(e,t){var r=null;return(17===e||25===e)&&32<=t&&t<=47&&((r=17===e?1:2)!==this.currChNr?(l.log("ERROR","Mismatch channel in midrow parsing"),!1):(this.channels[r-1].ccMIDROW(t),l.log("DEBUG","MIDROW ("+gt([e,t])+")"),!0))},t.parsePAC=function(e,t){var r=null;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);var i=e<=23?1:2,r=(64<=t&&t<=95?1==i?Et:bt:1==i?Tt:St)[e],r=this.interpretPAC(r,t);return this.channels[i-1].setPAC(r),this.lastCmdA=e,this.lastCmdB=t,this.currChNr=i,!0},t.interpretPAC=function(e,t){var r=t,e={color:null,italics:!1,indent:null,underline:!1,row:e},r=95e)&&(this.startTime=e),this.endTime=t,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)},e}(),Ct={parse:function(e,t,i,a,c,h){var r,e=Object(Pe.utf8ArrayToStr)(new Uint8Array(e)).trim().replace(/\r\n|\n\r|\n|\r/g,"\n").split("\n"),f="00:00.000",n=0,s=0,o=0,g=[],l=!0,d=!1,u=new ct;u.oncue=function(e){var t=i[a],r=i.ccOffset;t&&t.new&&(void 0!==s?r=i.ccOffset=t.start:function(e,t,r){var i=e[t],a=e[i.prevCC];if(!a||!a.new&&i.new)return e.ccOffset=e.presentationOffset=i.start,i.new=!1;for(;a&&a.new;)e.ccOffset+=i.start-a.start,i.new=!1,a=e[(i=a).prevCC];e.presentationOffset=r}(i,a,o)),o&&(r=o-i.presentationOffset),d&&(e.startTime+=r-s,e.endTime+=r-s),e.id=mt(e.startTime.toString())+mt(e.endTime.toString())+mt(e.text),e.text=decodeURIComponent(encodeURIComponent(e.text)),0=n.length||r!==a||!s||this.stopped?this._clearReloadTimer():(D.logger.log("subtitle track "+r+" loaded"),i.live?(n=se(s.details,i,e.stats.trequest),D.logger.log("Reloading live subtitle playlist in "+n+"ms"),this.timer=setTimeout(function(){t._loadCurrentTrack()},n)):this._clearReloadTimer())},a.startLoad=function(){this.stopped=!1,this._loadCurrentTrack()},a.stopLoad=function(){this.stopped=!0,this._clearReloadTimer()},a._clearReloadTimer=function(){this.timer&&(clearTimeout(this.timer),this.timer=null)},a._loadCurrentTrack=function(){var e=this.trackId,t=this.tracks,r=this.hls,t=t[e];e<0||!t||t.details&&!t.details.live||(D.logger.log("Loading subtitle track "+e),r.trigger(E.default.SUBTITLE_TRACK_LOADING,{url:t.url,id:e}))},a._toggleTrackModes=function(e){var t=this.media,r=this.subtitleDisplay,i=this.trackId;t&&(t=Ft(t.textTracks),-1===e?[].slice.call(t).forEach(function(e){e.mode="disabled"}):(i=t[i])&&(i.mode="disabled"),(i=t[e])&&(i.mode=r?"showing":"hidden"))},a._setSubtitleTrackInternal=function(e){var t=this.hls,r=this.tracks;!Object(w.isFiniteNumber)(e)||e<-1||e>=r.length||(this.trackId=e,D.logger.log("Switching to subtitle track "+e),t.trigger(E.default.SUBTITLE_TRACK_SWITCH,{id:e}),this._loadCurrentTrack())},a._onTextTracksChanged=function(){if(this.media){for(var e=-1,t=Ft(this.media.textTracks),r=0;r=r[n].start&&a<=r[n].end){i=r[n];break}e=t.start+t.duration;i?i.end=e:r.push(i={start:a,end:e})}}},r.onMediaAttached=function(e){e=e.media;(this.media=e).addEventListener("seeking",this._onMediaSeeking),this.state=T},r.onMediaDetaching=function(){var t=this;this.media&&(this.media.removeEventListener("seeking",this._onMediaSeeking),this.fragmentTracker.removeAllFragments(),this.currentTrackId=-1,this.tracks.forEach(function(e){t.tracksBuffered[e.id]=[]}),this.media=null,this.state=pe)},r.onError=function(e){e=e.frag;e&&"subtitle"===e.type&&(this.state=T)},r.onSubtitleTracksUpdated=function(e){var t=this;D.logger.log("subtitle tracks updated"),this.tracksBuffered=[],this.tracks=e.subtitleTracks,this.tracks.forEach(function(e){t.tracksBuffered[e.id]=[]})},r.onSubtitleTrackSwitch=function(e){this.currentTrackId=e.id,this.tracks&&this.tracks.length&&-1!==this.currentTrackId?(e=this.tracks[this.currentTrackId])&&e.details&&this.setInterval(500):this.clearInterval()},r.onSubtitleTrackLoaded=function(e){var t=e.id,e=e.details,r=this.currentTrackId,i=this.tracks,a=i[r];if(!(t>=i.length||t!==r)&&a){if(e.live){var i=a.details,t=e,n=this.lastAVStart,s=(void 0===n&&(n=0),-1),o=(ne(i,t,function(e,t,r){t.start=e.start,s=r}),t.fragments);if(s<0)o.forEach(function(e){e.start+=n});else for(var l=s+1;l "+t)),s.apply(o.console,i)}:r}var s=function(e){if(o.console&&!0===e||"object"==typeof e){!function(t){for(var e=arguments.length,r=new Array(1