diff --git a/ui/jessibuca-pro.js b/ui/jessibuca-pro.js index 1c789d2..7d58116 100644 --- a/ui/jessibuca-pro.js +++ b/ui/jessibuca-pro.js @@ -36,4 +36,4 @@ `:""} - `),Object.defineProperty(i,"$poster",{value:r.$container.querySelector(".jessibuca-poster")}),Object.defineProperty(i,"$loading",{value:r.$container.querySelector(".jessibuca-loading")}),Object.defineProperty(i,"$play",{value:r.$container.querySelector(".jessibuca-play")}),Object.defineProperty(i,"$playBig",{value:r.$container.querySelector(".jessibuca-play-big")}),Object.defineProperty(i,"$pause",{value:r.$container.querySelector(".jessibuca-pause")}),Object.defineProperty(i,"$controls",{value:r.$container.querySelector(".jessibuca-controls")}),Object.defineProperty(i,"$fullscreen",{value:r.$container.querySelector(".jessibuca-fullscreen")}),Object.defineProperty(i,"$fullscreen",{value:r.$container.querySelector(".jessibuca-fullscreen")}),Object.defineProperty(i,"$volume",{value:r.$container.querySelector(".jessibuca-volume")}),Object.defineProperty(i,"$volumePanelWrap",{value:r.$container.querySelector(".jessibuca-volume-panel-wrap")}),Object.defineProperty(i,"$volumePanelText",{value:r.$container.querySelector(".jessibuca-volume-panel-text")}),Object.defineProperty(i,"$volumePanel",{value:r.$container.querySelector(".jessibuca-volume-panel")}),Object.defineProperty(i,"$volumeHandle",{value:r.$container.querySelector(".jessibuca-volume-panel-handle")}),Object.defineProperty(i,"$volumeOn",{value:r.$container.querySelector(".jessibuca-icon-audio")}),Object.defineProperty(i,"$volumeOff",{value:r.$container.querySelector(".jessibuca-icon-mute")}),Object.defineProperty(i,"$fullscreen",{value:r.$container.querySelector(".jessibuca-fullscreen")}),Object.defineProperty(i,"$fullscreenExit",{value:r.$container.querySelector(".jessibuca-fullscreen-exit")}),Object.defineProperty(i,"$record",{value:r.$container.querySelector(".jessibuca-record")}),Object.defineProperty(i,"$recordStop",{value:r.$container.querySelector(".jessibuca-record-stop")}),Object.defineProperty(i,"$screenshot",{value:r.$container.querySelector(".jessibuca-screenshot")}),Object.defineProperty(i,"$speed",{value:r.$container.querySelector(".jessibuca-speed")}),Re(e,this),t=this,Object.defineProperty(t,"controlsRect",{get:()=>t.$controls.getBoundingClientRect()});{var a=e,o=this;const h=a["events"]["proxy"];function l(e){var{bottom:t,height:r}=o.$volumePanel.getBoundingClientRect(),i=o.$volumeHandle.getBoundingClientRect()["height"];return g(t-e.y-i/2,0,r-i/2)/(r-i)}h(window,["click","contextmenu"],e=>{-1{setTimeout(()=>{a.resize()},300)}),h(o.$controls,"click",e=>{e.stopPropagation()}),h(o.$pause,"click",e=>{a.pause()}),h(o.$play,"click",e=>{a.play()}),h(o.$playBig,"click",e=>{a.play()}),h(o.$volume,"mouseover",()=>{o.$volumePanelWrap.classList.add("jessibuca-volume-panel-wrap-show")}),h(o.$volume,"mouseout",()=>{o.$volumePanelWrap.classList.remove("jessibuca-volume-panel-wrap-show")}),h(o.$volumeOn,"click",e=>{e.stopPropagation(),p(o.$volumeOn,"display","none"),p(o.$volumeOff,"display","block"),a.lastVolume=a.volume,a.volume=0}),h(o.$volumeOff,"click",e=>{e.stopPropagation(),p(o.$volumeOn,"display","block"),p(o.$volumeOff,"display","none"),a.volume=a.lastVolume||.5}),h(o.$screenshot,"click",e=>{e.stopPropagation(),a.video.screenshot()}),h(o.$volumePanel,"click",e=>{e.stopPropagation(),a.volume=l(e)}),h(o.$volumeHandle,"mousedown",()=>{o.isVolumeDroging=!0}),h(o.$volumeHandle,"mousemove",e=>{o.isVolumeDroging&&(a.volume=l(e))}),h(document,"mouseup",()=>{o.isVolumeDroging&&(o.isVolumeDroging=!1)}),h(o.$record,"click",e=>{e.stopPropagation(),a.recording=!0}),h(o.$recordStop,"click",e=>{e.stopPropagation(),a.recording=!1}),h(o.$fullscreen,"click",e=>{e.stopPropagation(),a.fullscreen=!0}),h(o.$fullscreenExit,"click",e=>{e.stopPropagation(),a.fullscreen=!1}),a._opt.hasControl&&a._opt.controlAutoHide&&(h(a.$container,"mouseover",()=>{a.fullscreen||p(o.$controls,"display","block")}),h(a.$container,"mouseout",()=>{p(o.$controls,"display","none")}))}if(e._opt.hotKey){var d=e,u=this;const f=d["events"]["proxy"],A={};function c(e,t){A[e]?A[e].push(t):A[e]=[t]}c(27,()=>{d.fullscreen&&(d.fullscreen=!1)}),c(38,()=>{d.volume+=.05}),c(40,()=>{d.volume-=.05}),f(window,"keydown",e=>{if(u.isFocus){const u=document.activeElement.tagName.toUpperCase(),t=document.activeElement.getAttribute("contenteditable");if("INPUT"!==u&&"TEXTAREA"!==u&&""!==t&&"true"!==t){const u=A[e.keyCode];u&&(e.preventDefault(),u.forEach(e=>e()))}}})}this.player.debug.log("Control","init")}destroy(){this.$poster&&this.player.$container.removeChild(this.$poster),this.$loading&&this.player.$container.removeChild(this.$loading),this.$controls&&this.player.$container.removeChild(this.$controls),this.$playBig&&this.player.$container.removeChild(this.$playBig),this.player.debug.log("control","destroy")}autoSize(){const e=this.player,t=(e.$container.style.padding="0 0",e.width),r=e.height,i=t/r,n=e.video.$videoElement.width/e.video.$videoElement.height;if(i>n){const i=(t-r*n)/2;e.$container.style.padding=`0 ${i}px`}else{const i=(r-t/n)/2;e.$container.style.padding=i+"px 0"}}}A(".jessibuca-container{position:relative;width:100%;height:100%;overflow:hidden}.jessibuca-container.jessibuca-fullscreen-web{position:fixed;z-index:9999;left:0;top:0;right:0;bottom:0;width:100vw!important;height:100vh!important;background:#000}");class L{static init(){for(var e in L.types={avc1:[],avcC:[],hvc1:[],hvcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},L.types)L.types.hasOwnProperty(e)&&(L.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);let t=L.constants={};t.FTYP=new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]),t.STSD_PREFIX=new Uint8Array([0,0,0,0,0,0,0,1]),t.STTS=new Uint8Array([0,0,0,0,0,0,0,0]),t.STSC=t.STCO=t.STTS,t.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),t.HDLR_VIDEO=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),t.HDLR_AUDIO=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]),t.DREF=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),t.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),t.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])}static box(e){let t=8,r=null,i=Array.prototype.slice.call(arguments,1),n=i.length;for(let e=0;e>>24&255,r[1]=t>>>16&255,r[2]=t>>>8&255,r[3]=255&t,r.set(e,4);let s=8;for(let e=0;e>>24&255,e>>>16&255,e>>>8&255,255&e,t>>>24&255,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]))}static trak(e){return L.box(L.types.trak,L.tkhd(e),L.mdia(e))}static tkhd(e){var t=e.id,r=e.duration,i=e.presentWidth,e=e.presentHeight;return L.box(L.types.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t,0,0,0,0,r>>>24&255,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]))}static mdia(e){return L.box(L.types.mdia,L.mdhd(e),L.hdlr(e),L.minf(e))}static mdhd(e){var t=e.timescale,e=e.duration;return L.box(L.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t,e>>>24&255,e>>>16&255,e>>>8&255,255&e,85,196,0,0]))}static hdlr(e){e="audio"===e.type?L.constants.HDLR_AUDIO:L.constants.HDLR_VIDEO;return L.box(L.types.hdlr,e)}static minf(e){var t="audio"===e.type?L.box(L.types.smhd,L.constants.SMHD):L.box(L.types.vmhd,L.constants.VMHD);return L.box(L.types.minf,t,L.dinf(),L.stbl(e))}static dinf(){return L.box(L.types.dinf,L.box(L.types.dref,L.constants.DREF))}static stbl(e){return L.box(L.types.stbl,L.stsd(e),L.box(L.types.stts,L.constants.STTS),L.box(L.types.stsc,L.constants.STSC),L.box(L.types.stsz,L.constants.STSZ),L.box(L.types.stco,L.constants.STCO))}static stsd(e){return"audio"===e.type?L.box(L.types.stsd,L.constants.STSD_PREFIX,L.mp4a(e)):"avc"===e.videoType?L.box(L.types.stsd,L.constants.STSD_PREFIX,L.avc1(e)):L.box(L.types.stsd,L.constants.STSD_PREFIX,L.hvc1(e))}static mp4a(e){var t=e.channelCount,r=e.audioSampleRate,t=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t,0,16,0,0,0,0,r>>>8&255,255&r,0,0]);return L.box(L.types.mp4a,t,L.esds(e))}static esds(e){var e=e.config||[],t=e.length,t=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).concat([6,1,2]));return L.box(L.types.esds,t)}static avc1(e){var t=e.avcc,r=e.codecWidth,e=e.codecHeight,r=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,r>>>8&255,255&r,e>>>8&255,255&e,0,72,0,0,0,72,0,0,0,0,0,0,0,1,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,0,0,0,0,0,0,24,255,255]);return L.box(L.types.avc1,r,L.box(L.types.avcC,t))}static hvc1(e){var t=e.avcc,r=e.codecWidth,e=e.codecHeight,r=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,r>>>8&255,255&r,e>>>8&255,255&e,0,72,0,0,0,72,0,0,0,0,0,0,0,1,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,0,0,0,0,0,0,24,255,255]);return L.box(L.types.hvc1,r,L.box(L.types.hvcC,t))}static mvex(e){return L.box(L.types.mvex,L.trex(e))}static trex(e){e=e.id,e=new Uint8Array([0,0,0,0,e>>>24&255,e>>>16&255,e>>>8&255,255&e,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return L.box(L.types.trex,e)}static moof(e,t){return L.box(L.types.moof,L.mfhd(e.sequenceNumber),L.traf(e,t))}static mfhd(e){e=new Uint8Array([0,0,0,0,e>>>24&255,e>>>16&255,e>>>8&255,255&e]);return L.box(L.types.mfhd,e)}static traf(e,t){var r=e.id,r=L.box(L.types.tfhd,new Uint8Array([0,0,0,0,r>>>24&255,r>>>16&255,r>>>8&255,255&r])),t=L.box(L.types.tfdt,new Uint8Array([0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t])),i=L.sdtp(e),e=L.trun(e,i.byteLength+16+16+8+16+8+8);return L.box(L.types.traf,r,t,e,i)}static sdtp(e){let t=new Uint8Array(5),r=e.flags;return t[4]=r.isLeading<<6|r.dependsOn<<4|r.isDependedOn<<2|r.hasRedundancy,L.box(L.types.sdtp,t)}static trun(e,t){let r=new Uint8Array(28);t+=36,r.set([0,0,15,1,0,0,0,1,t>>>24&255,t>>>16&255,t>>>8&255,255&t],0);var t=e.duration,i=e.size,n=e.flags,e=e.cts;return r.set([t>>>24&255,t>>>16&255,t>>>8&255,255&t,i>>>24&255,i>>>16&255,i>>>8&255,255&i,n.isLeading<<2|n.dependsOn,n.isDependedOn<<6|n.hasRedundancy<<4|n.isNonSync,0,0,e>>>24&255,e>>>16&255,e>>>8&255,255&e],12),L.box(L.types.trun,r)}static mdat(e){return L.box(L.types.mdat,e)}}L.init();class ke{constructor(e){this.TAG="ExpGolomb",this._buffer=e,this._buffer_index=0,this._total_bytes=e.byteLength,this._total_bits=8*e.byteLength,this._current_word=0,this._current_word_bits_left=0}destroy(){this._buffer=null}_fillCurrentWord(){let e=this._total_bytes-this._buffer_index,t=Math.min(4,e),r=new Uint8Array(4);r.set(this._buffer.subarray(this._buffer_index,this._buffer_index+t)),this._current_word=new DataView(r.buffer).getUint32(0,!1),this._buffer_index+=t,this._current_word_bits_left=8*t}readBits(e){if(e<=this._current_word_bits_left)return t=this._current_word>>>32-e,this._current_word<<=e,this._current_word_bits_left-=e,t;var t=this._current_word_bits_left?this._current_word:0,e=(t>>>=32-this._current_word_bits_left,e-this._current_word_bits_left),e=(this._fillCurrentWord(),Math.min(e,this._current_word_bits_left)),r=this._current_word>>>32-e;return this._current_word<<=e,this._current_word_bits_left-=e,t<>>e))return this._current_word<<=e,this._current_word_bits_left-=e,e;return this._fillCurrentWord(),e+this._skipLeadingZero()}readUEG(){var e=this._skipLeadingZero();return this.readBits(e+1)-1}readSEG(){var e=this.readUEG();return 1&e?e+1>>>1:-1*(e>>>1)}}class I{static _ebsp2rbsp(e){let t=e,r=t.byteLength,i=new Uint8Array(r),n=0;for(let e=0;e{this.mediaSourceOpen=!0,this.player.emit(u.mseSourceOpen)}),t(this.mediaSource,"sourceclose",()=>{this.player.emit(u.mseSourceClose)}),e.debug.log("MediaSource","init")}destroy(){this.stop(),this.bufferList=[],this.mediaSource=null,this.mediaSourceOpen=!1,this.sourceBuffer=null,this.hasInit=!1,this.isInitInfo=!1,this.sequenceNumber=0,this.cacheTrack=null,this.timeInit=!1,this.off(),this.player.debug.log("MediaSource","destroy")}get state(){return this.mediaSource.readyState}get isStateOpen(){return"open"===this.state}get isStateClosed(){return"closed"===this.state}get isStateEnded(){return"ended"===this.state}get duration(){return this.mediaSource.duration}set duration(e){this.mediaSource.duration=e}decodeVideo(e,t,r){const i=this.player;var n;this.hasInit?this._decodeVideo(e,t,r):r&&0===e[1]&&(n=15&e[0],i.video.updateVideoInfo({encTypeCode:n}),12==n?this.emit(h.mediaSourceH265NotSupport):(i._times.decodeStart||(i._times.decodeStart=l()),this._decodeConfigurationRecord(e,t,r,n),this.hasInit=!0))}_doDecode(){var e=this.bufferList.shift();e&&this._decodeVideo(e.payload,e.ts,e.isIframe)}_decodeConfigurationRecord(e,t,r,i){let n=e.slice(5),s={};7===i?s=function(i){const n={},s=new DataView(i.buffer);var e=s.getUint8(0),t=s.getUint8(1);if(s.getUint8(2),s.getUint8(3),1===e&&0!==t){e=1+(3&s.getUint8(4));if(3==e||4==e){var a=31&s.getUint8(5);if(0!=a){let r=6;for(let t=0;tthis.cacheTrack.dts){let e=8+this.cacheTrack.size,t=new Uint8Array(e),r=(t[0]=e>>>24&255,t[1]=e>>>16&255,t[2]=e>>>8&255,t[3]=255&e,t.set(L.types.mdat,4),t.set(this.cacheTrack.data,8),this.cacheTrack.duration=a-this.cacheTrack.dts,L.moof(this.cacheTrack,this.cacheTrack.dts)),i=new Uint8Array(r.byteLength+t.byteLength);i.set(r,0),i.set(t,r.byteLength),this.appendBuffer(i.buffer),s.handleRender(),s.updateStats({fps:!0,ts:n,buf:s.demux.delay}),s._times.videoStart||(s._times.videoStart=l(),s.handlePlayToRenderTimes())}else s.debug.log("MediaSource","timeInit set false , cacheTrack = {}"),this.timeInit=!1,this.cacheTrack={};this.cacheTrack.id=1,this.cacheTrack.sequenceNumber=++this.sequenceNumber,this.cacheTrack.size=r,this.cacheTrack.dts=a,this.cacheTrack.cts=0,this.cacheTrack.isKeyframe=t,this.cacheTrack.data=e,this.cacheTrack.flags={isLeading:0,dependsOn:t?2:1,isDependedOn:t?1:0,hasRedundancy:0,isNonSync:t?0:1},this.timeInit||1!==i.buffered.length||(s.debug.log("MediaSource","timeInit set true"),this.timeInit=!0,i.currentTime=i.buffered.end(0)),!this.isInitInfo&&0{this.player.emit(u.mseSourceBufferError,e)})),!1===this.sourceBuffer.updating&&this.isStateOpen?this.sourceBuffer.appendBuffer(e):this.isStateClosed?this.player.emit(u.mseSourceBufferError,"mediaSource is not attached to video or mediaSource is closed"):this.isStateEnded?this.player.emit(u.mseSourceBufferError,"mediaSource is closed"):!0===this.sourceBuffer.updating&&this.player.emit(u.mseSourceBufferBusy)}stop(){this.isStateOpen&&this.sourceBuffer&&this.sourceBuffer.abort(),this.endOfStream()}dropSourceBuffer(e){const t=this.player.video.$videoElement;this.dropping=e,0"undefined"!=typeof navigator&&parseFloat((""+(/CPU.*OS ([0-9_]{3,4})[0-9_]{0,1}|(CPU like).*AppleWebKit.*Mobile/i.exec(navigator.userAgent)||[0,""])[1]).replace("undefined","3_2").replace("_",".").replace("_",""))<10&&!window.MSStream,Ie=()=>"wakeLock"in navigator;class xe{constructor(e){if(this.player=e,this.enabled=!1,Ie()){this._wakeLock=null;const e=()=>{null!==this._wakeLock&&"visible"===document.visibilityState&&this.enable()};document.addEventListener("visibilitychange",e),document.addEventListener("fullscreenchange",e)}else x()?this.noSleepTimer=null:(this.noSleepVideo=document.createElement("video"),this.noSleepVideo.setAttribute("title","No Sleep"),this.noSleepVideo.setAttribute("playsinline",""),this._addSourceToVideo(this.noSleepVideo,"webm","data:video/webm;base64,GkXfowEAAAAAAAAfQoaBAUL3gQFC8oEEQvOBCEKChHdlYm1Ch4EEQoWBAhhTgGcBAAAAAAAVkhFNm3RALE27i1OrhBVJqWZTrIHfTbuMU6uEFlSua1OsggEwTbuMU6uEH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QFVV1XVdV5YBqqqqruu6sgxQVdd1XVmWZQCu67qyLMsCAAAOHAAAAoygk4wqi7DRhAsPQKEhKwKAKAAAwBimFFPKMCYhpBAaxiSEFEImJaXSUqogpFJSKRWEVEoqJaOUUmopVRBSKamUCkIqJZVSAADYgQMA2IGFUGjISgAgDwCAMEYpxhhzTiKkFGPOOScRUoox55yTSjHmnHPOSSkZc8w556SUzjnnnHNSSuacc845KaVzzjnnnJRSSuecc05KKSWEzkEnpZTSOeecEwAAVOAAABBgo8jmBCNBhYasBABSAQAMjmNZmuZ5omialiRpmud5niiapiZJmuZ5nieKqsnzPE8URdE0VZXneZ4oiqJpqirXFUXTNE1VVV2yLIqmaZqq6rowTdNUVdd1XZimaaqq67oubFtVVdV1ZRm2raqq6rqyDFzXdWXZloEsu67s2rIAAPAEBwCgAhtWRzgpGgssNGQlAJABAEAYg5BCCCFlEEIKIYSUUggJAAAYcAAACDChDBQashIASAUAAIyx1lprrbXWQGettdZaa62AzFprrbXWWmuttdZaa6211lJrrbXWWmuttdZaa6211lprrbXWWmuttdZaa6211lprrbXWWmuttdZaa6211lprrbXWWmstpZRSSimllFJKKaWUUkoppZRSSgUA+lU4APg/2LA6wknRWGChISsBgHAAAMAYpRhzDEIppVQIMeacdFRai7FCiDHnJKTUWmzFc85BKCGV1mIsnnMOQikpxVZjUSmEUlJKLbZYi0qho5JSSq3VWIwxqaTWWoutxmKMSSm01FqLMRYjbE2ptdhqq7EYY2sqLbQYY4zFCF9kbC2m2moNxggjWywt1VprMMYY3VuLpbaaizE++NpSLDHWXAAAd4MDAESCjTOsJJ0VjgYXGrISAAgJACAQUooxxhhzzjnnpFKMOeaccw5CCKFUijHGnHMOQgghlIwx5pxzEEIIIYRSSsaccxBCCCGEkFLqnHMQQgghhBBKKZ1zDkIIIYQQQimlgxBCCCGEEEoopaQUQgghhBBCCKmklEIIIYRSQighlZRSCCGEEEIpJaSUUgohhFJCCKGElFJKKYUQQgillJJSSimlEkoJJYQSUikppRRKCCG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ABhYL/QACIBDmAYAAKOFggHPgA6jmYEB4wAxAgABEBAAGAAYWC/0AAiAQ5gGAACjhYIB5IAOo4WCAfqADqOZgQILADECAAEQEAAYABhYL/QACIBDmAYAAKOFggIPgA6jhYICJIAOo5mBAjMAMQIAARAQABgAGFgv9AAIgEOYBgAAo4WCAjqADqOFggJPgA6jmYECWwAxAgABEBAAGAAYWC/0AAiAQ5gGAACjhYICZIAOo4WCAnqADqOZgQKDADECAAEQEAAYABhYL/QACIBDmAYAAKOFggKPgA6jhYICpIAOo5mBAqsAMQIAARAQABgAGFgv9AAIgEOYBgAAo4WCArqADqOFggLPgA6jmIEC0wARAgABEBAUYABhYL/QACIBDmAYAKOFggLkgA6jhYIC+oAOo5mBAvsAMQIAARAQABgAGFgv9AAIgEOYBgAAo4WCAw+ADqOZgQMjADECAAEQEAAYABhYL/QACIBDmAYAAKOFggMkgA6jhYIDOoAOo5mBA0sAMQIAARAQABgAGFgv9AAIgEOYBgAAo4WCA0+ADqOFggNkgA6jmYEDcwAxAgABEBAAGAAYWC/0AAiAQ5gGAACjhYIDeoAOo4WCA4+ADqOZgQObADECAAEQEAAYABhYL/QACIBDmAYAAKOFggOkgA6jhYIDuoAOo5mBA8MAMQIAARAQABgAGFgv9AAIgEOYBgAAo4WCA8+ADqOFggPkgA6jhYID+oAOo4WCBA+ADhxTu2sBAAAAAAAAEbuPs4EDt4r3gQHxghEr8IEK"),this._addSourceToVideo(this.noSleepVideo,"mp4","data:video/mp4;base64,AAAAHGZ0eXBNNFYgAAACAGlzb21pc28yYXZjMQAAAAhmcmVlAAAGF21kYXTeBAAAbGliZmFhYyAxLjI4AABCAJMgBDIARwAAArEGBf//rdxF6b3m2Ui3lizYINkj7u94MjY0IC0gY29yZSAxNDIgcjIgOTU2YzhkOCAtIEguMjY0L01QRUctNCBBVkMgY29kZWMgLSBDb3B5bGVmdCAyMDAzLTIwMTQgLSBodHRwOi8vd3d3LnZpZGVvbGFuLm9yZy94MjY0Lmh0bWwgLSB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AAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAACMc3RjbwAAAAAAAAAfAAAALAAAA1UAAANyAAADhgAAA6IAAAO+AAAD0QAAA+0AAAQAAAAEHAAABC8AAARLAAAEZwAABHoAAASWAAAEqQAABMUAAATYAAAE9AAABRAAAAUjAAAFPwAABVIAAAVuAAAFgQAABZ0AAAWwAAAFzAAABegAAAX7AAAGFwAAAGJ1ZHRhAAAAWm1ldGEAAAAAAAAAIWhkbHIAAAAAAAAAAG1kaXJhcHBsAAAAAAAAAAAAAAAALWlsc3QAAAAlqXRvbwAAAB1kYXRhAAAAAQAAAABMYXZmNTUuMzMuMTAw"),this.noSleepVideo.addEventListener("loadedmetadata",()=>{this.noSleepVideo.duration<=1?this.noSleepVideo.setAttribute("loop",""):this.noSleepVideo.addEventListener("timeupdate",()=>{.5{this._wakeLock=e,this.enabled=!0,t.log("wakeLock","Wake Lock active."),this._wakeLock.addEventListener("release",()=>{t.log("wakeLock","Wake Lock released.")})}).catch(e=>{throw this.enabled=!1,t.error("wakeLock",e.name+", "+e.message),e}):x()?(this.disable(),this.noSleepTimer=window.setInterval(()=>{document.hidden||(window.location.href=window.location.href.split("#")[0],window.setTimeout(window.stop,0))},15e3),this.enabled=!0,Promise.resolve()):this.noSleepVideo.play().then(e=>(this.enabled=!0,e)).catch(e=>{throw this.enabled=!1,e})}disable(){const e=this.player.debug;Ie()?(this._wakeLock&&this._wakeLock.release(),this._wakeLock=null):x()?this.noSleepTimer&&(e.warn("wakeLock","NoSleep now disabled for older iOS devices."),window.clearInterval(this.noSleepTimer),this.noSleepTimer=null):this.noSleepVideo.pause(),this.enabled=!1}}var O=(m=v(function(e,t){"undefined"!=typeof window&&(e.exports=function(){return r={"./node_modules/eventemitter3/index.js":function(e,t,r){var i=Object.prototype.hasOwnProperty,f="~";function n(){}function s(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function a(e,t,r,i,n){if("function"!=typeof r)throw new TypeError("The listener must be a function");r=new s(r,i||e,n),i=f?f+t:t;return e._events[i]?e._events[i].fn?e._events[i]=[e._events[i],r]:e._events[i].push(r):(e._events[i]=r,e._eventsCount++),e}function l(e,t){0==--e._eventsCount?e._events=new n:delete e._events[t]}function o(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(f=!1)),o.prototype.eventNames=function(){var e,t,r=[];if(0===this._eventsCount)return r;for(t in e=this._events)i.call(e,t)&&r.push(f?t.slice(1):t);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(e)):r},o.prototype.listeners=function(e){var e=f?f+e:e,t=this._events[e];if(!t)return[];if(t.fn)return[t.fn];for(var r=0,i=t.length,n=new Array(i);rs||t.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),r.currentTime=s+.05)),this.getNextFragment(i,n));a?"identity"!==(null==(e=a.decryptdata)?void 0:e.keyFormat)||null!=(t=a.decryptdata)&&t.key?this.loadFragment(a,n,i):this.loadKey(a,n):this.bufferFlushed=!0}}}}},E.getMaxBufferLength=function(){var e=b.prototype.getMaxBufferLength.call(this),t=this.getFwdBufferInfo(this.videoBuffer||this.media,u.PlaylistLevelType.MAIN);return null===t?e:Math.max(e,t.len)},E.onMediaDetaching=function(){this.videoBuffer=null,b.prototype.onMediaDetaching.call(this)},E.onAudioTracksUpdated=function(e,t){t=t.audioTracks;this.resetTransmuxer(),this.levels=t.map(function(e){return new i.Level(e)})},E.onAudioTrackSwitching=function(e,t){var r=!!t.url,t=(this.trackId=t.id,this.fragCurrent);null!=t&&t.loader&&t.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),r?this.setInterval(100):this.resetTransmuxer(),r?(this.audioSwitch=!0,this.state=h.State.IDLE):this.state=h.State.STOPPED,this.tick()},E.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},E.onLevelLoaded=function(e,t){this.mainDetails=t.details},E.onAudioTrackLoaded=function(e,t){var r=this.levels,i=t.details,t=t.id;if(r){this.log("Track "+t+" loaded ["+i.startSN+","+i.endSN+"],duration:"+i.totalduration);var r=r[t],n=0;if(i.live||null!=(s=r.details)&&s.live){var s=this.mainDetails;if(i.fragments[0]||(i.deltaUpdateFailed=!0),i.deltaUpdateFailed||!s)return;n=!r.details&&i.hasProgramDateTime&&s.hasProgramDateTime?(Object(l.alignMediaPlaylistByPDT)(i,s),i.fragments[0].start):this.alignPlaylists(i,r.details)}r.details=i,this.levelLastLoaded=t,this.startFragRequested||!this.mainDetails&&i.live||this.setStartPosition(r.details,n),this.state!==h.State.WAITING_TRACK||this.waitForCdnTuneIn(i)||(this.state=h.State.IDLE),this.tick()}else this.warn("Audio tracks were reset while loading level "+t)},E._handleFragmentLoadProgress=function(e){var t,r,i,n,s=e.frag,a=e.part,e=e.payload,o=this.config,l=this.trackId,d=this.levels;d?(d=d[l],console.assert(d,"Audio track is defined on fragment load progress"),t=d.details,console.assert(t,"Audio track details are defined on fragment load progress"),o=o.defaultAudioCodec||d.audioCodec||"mp4a.40.2",d=(d=this.transmuxer)||(this.transmuxer=new g.default(this.hls,u.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this))),r=this.initPTS[s.cc],i=null==(i=s.initSegment)?void 0:i.data,void 0!==r?(n=a?a.index:-1,n=new p.ChunkMetadata(s.level,s.sn,s.stats.chunkCount,e.byteLength,n,-1!==n),d.push(e,i,o,"",s,a,t.totalduration,!1,n,r)):(m.logger.log("Unknown video PTS for cc "+s.cc+", waiting for video PTS before demuxing audio frag "+s.sn+" of ["+t.startSN+" ,"+t.endSN+"],track "+l),(this.waitingData=this.waitingData||{frag:s,part:a,cache:new c.default,complete:!1}).cache.push(new Uint8Array(e)),this.waitingVideoCC=this.videoTrackCC,this.state=h.State.WAITING_INIT_PTS)):this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+s.sn+" of level "+s.level+" will not be buffered")},E._handleFragmentLoadComplete=function(e){this.waitingData?this.waitingData.complete=!0:b.prototype._handleFragmentLoadComplete.call(this,e)},E.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},E.onBufferCreated=function(e,t){var r=t.tracks.audio;r&&(this.mediaBuffer=r.buffer),t.tracks.video&&(this.videoBuffer=t.tracks.video.buffer)},E.onFragBuffered=function(e,t){var r=t.frag,t=t.part;r.type===u.PlaylistLevelType.AUDIO&&(this.fragContextChanged(r)?this.warn("Fragment "+r.sn+(t?" p: "+t.index:"")+" of level "+r.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch):("initSegment"!==r.sn&&(this.fragPrevious=r,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(f.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(r,t)))},E.onError=function(e,t){switch(t.details){case d.ErrorDetails.FRAG_LOAD_ERROR:case d.ErrorDetails.FRAG_LOAD_TIMEOUT:case d.ErrorDetails.KEY_LOAD_ERROR:case d.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(u.PlaylistLevelType.AUDIO,t);break;case d.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case d.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==h.State.ERROR&&this.state!==h.State.STOPPED&&(this.state=t.fatal?h.State.ERROR:h.State.IDLE,this.warn(t.details+" while loading frag, switching to "+this.state+" state"));break;case d.ErrorDetails.BUFFER_FULL_ERROR:var r,i;"audio"!==t.parent||this.state!==h.State.PARSING&&this.state!==h.State.PARSED||(r=!0,(r=(i=this.getFwdBufferInfo(this.mediaBuffer,u.PlaylistLevelType.AUDIO))&&.5=o.length?this.warn("Invalid id passed to audio-track controller"):(this.clearTimer(),t=o[this.trackId],this.log("Now switching to audio-track index "+e),r=(o=o[e]).id,i=void 0===(i=o.groupId)?"":i,n=o.name,s=o.type,a=o.url,this.trackId=e,this.trackName=n,this.selectDefaultTrack=!1,this.hls.trigger(l.Events.AUDIO_TRACK_SWITCHING,{id:r,groupId:i,name:n,type:s,url:a}),o.details&&!o.details.live||(e=this.switchParams(o.url,null==t?void 0:t.details),this.loadPlaylist(e)))},n.selectInitialTrack=function(){var e=this.tracksInGroup,e=(console.assert(e.length,"Initial audio track should be selected when tracks are known"),this.trackName),e=this.findTrackId(e)||this.findTrackId();-1!==e?this.setAudioTrack(e):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(l.Events.ERROR,{type:i.ErrorTypes.MEDIA_ERROR,details:i.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},n.findTrackId=function(e){for(var t=this.tracksInGroup,r=0;rt.partTarget&&(n+=1)),Object(o.isFiniteNumber)(s))return new l.HlsUrlParameters(s,Object(o.isFiniteNumber)(n)?n:void 0,l.HlsSkip.No)}}},t.loadPlaylist=function(e){},t.shouldLoadTrack=function(e){return this.canLoad&&e&&!!e.url&&(!e.details||e.details.live)},t.playlistLoaded=function(e,t,r){var i=this,n=t.details,s=t.stats,a=s.loading.end?Math.max(0,self.performance.now()-s.loading.end):0;if(n.advancedDateTime=Date.now()-a,n.live||null!=r&&r.live){if(n.reloaded(r),r&&this.log("live playlist "+e+" "+(n.advanced?"REFRESHED "+n.lastPartSn+"-"+n.lastPartIndex:"MISSED")),r&&0r.tuneInGoal?(this.warn("CDN Tune-in goal increased from: "+r.tuneInGoal+" to: "+c+" with playlist age: "+n.age),c=0):(a+=h=Math.floor(c/n.targetduration),void 0!==l&&(l+=Math.round(c%n.targetduration/n.partTarget)),this.log("CDN Tune-in age: "+n.ageHeader+"s last advanced "+u.toFixed(2)+"s goal: "+c+" skip sn "+h+" to part "+l)),n.tuneInGoal=c),o=this.getDeliveryDirectives(n,t.deliveryDirectives,a,l),d||!f)return void this.loadPlaylist(o)}else o=this.getDeliveryDirectives(n,t.deliveryDirectives,a,l);r=Object(A.computeReloadInterval)(n,s);void 0!==a&&n.canBlockReload&&(r-=n.partTarget||1),this.log("reload live playlist "+e+" in "+Math.round(r)+" ms"),this.timer=self.setTimeout(function(){return i.loadPlaylist(o)},r)}}else this.clearTimer()},t.getDeliveryDirectives=function(e,t,r,i){var n=Object(l.getSkipValue)(e,r);return null!=t&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,i=t.part,n=l.HlsSkip.No),new l.HlsUrlParameters(r,i,n)},t.retryLoadingOrFail=function(e){var t,r=this,i=this.hls.config,n=this.retryCount=t.endSN&&!e.nextStart){e=t.partList;if(null!=e&&e.length)return t=e[e.length-1],a.BufferHelper.isBuffered(this.media,t.start+t.duration/2);e=i.getState(r);return e===c.FragmentState.PARTIAL||e===c.FragmentState.OK}return!1},t.onMediaAttached=function(e,t){t=this.media=this.mediaBuffer=t.media,this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),t.addEventListener("seeking",this.onvseeking),t.addEventListener("ended",this.onvended),t=this.config;this.levels&&t.autoStartLoad&&this.state===E.STOPPED&&this.startLoad(t.startPosition)},t.onMediaDetaching=function(){var e=this.media;null!=e&&e.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),e&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},t.onMediaSeeking=function(){var e=this.config,t=this.fragCurrent,r=this.media,i=this.mediaBuffer,n=this.state,s=r?r.currentTime:0,i=a.BufferHelper.bufferInfo(i||r,s,e.maxBufferHole);this.log("media seeking to "+(Object(l.isFiniteNumber)(s)?s.toFixed(3):s)+", state: "+n),n===E.ENDED?this.resetLoadingState():t&&!i.len&&(n=e.maxFragLookUpTolerance,e=t.start-n,n=s>t.start+t.duration+n,(se.end&&t.fragmentHint&&(e=t.fragmentHint);var a,o=this.getNextPart(s,e,r);if(-1r&&this.flushMainBuffer(i,e.start)):this.flushMainBuffer(0,e.start))},t.getFwdBufferInfo=function(e,t){var r=this.config,i=this.getLoadPosition();if(!Object(l.isFiniteNumber)(i))return null;var n=a.BufferHelper.bufferInfo(e,i,r.maxBufferHole);if(0===n.len&&void 0!==n.nextStart){t=this.fragmentTracker.getBufferedFrag(i,t);if(t&&n.nextStart=e&&(t.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+t.maxMaxBufferLength+"s"),!0)},t.getNextFragment=function(e,t){var r=t.fragments,i=r.length;if(!i)return null;var n,s=this.config,a=r[0].start;if(t.live){var o=s.initialLiveManifestSize;if(ie.start&&e.loaded},t.getInitialLiveFragment=function(e,t){var r,i=this.fragPrevious,n=null;return i?(e.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+i.programDateTime),n=Object(f.findFragmentByPDT)(t,i.endProgramDateTime,this.config.maxFragLookUpTolerance)),n||((r=i.sn+1)>=e.startSN&&r<=e.endSN&&(r=t[r-e.startSN],i.cc===r.cc&&this.log("Live playlist, switching playlist, load frag with next SN: "+(n=r).sn)),n||(n=Object(f.findFragWithCC)(t,i.cc))&&this.log("Live playlist, switching playlist, load frag with same CC: "+n.sn))):null!==(r=this.hls.liveSyncPosition)&&(n=this.getFragmentAtPosition(r,this.bitrateTest?e.fragmentEnd:e.edge,e)),n},t.getFragmentAtPosition=function(e,t,r){var i,n=this.config,s=this.fragPrevious,a=r.fragments,o=r.endSN,l=r.fragmentHint,d=n.maxFragLookUpTolerance,n=!!(n.lowLatencyMode&&r.partList&&l);if(n&&l&&!this.bitrateTest&&(a=a.concat(l),o=l.sn),i=e=n-s.maxFragLookUpTolerance&&r<=i,null!==t&&a.duration>t&&(r"+e.startSN+" prev-sn: "+(n?n.sn:"na")+" fragments: "+i),a):s},t.waitForCdnTuneIn=function(e){return e.live&&e.canBlockReload&&e.tuneInGoal>Math.max(e.partHoldBack,3*e.partTarget)},t.setStartPosition=function(e,t){var r,i=this.startPosition;-1!==(i=i"+e))}}]),S);function S(e,t,r){var i;return(i=b.call(this)||this).hls=void 0,i.fragPrevious=null,i.fragCurrent=null,i.fragmentTracker=void 0,i.transmuxer=null,i._state=E.STOPPED,i.media=void 0,i.mediaBuffer=void 0,i.config=void 0,i.bitrateTest=!1,i.lastCurrentTime=0,i.nextLoadPosition=0,i.startPosition=0,i.loadedmetadata=!1,i.fragLoadError=0,i.retryDate=0,i.levels=null,i.fragmentLoader=void 0,i.levelLastLoaded=null,i.startFragRequested=!1,i.decrypter=void 0,i.initPTS=[],i.onvseeking=null,i.onvended=null,i.logPrefix="",i.log=void 0,i.warn=void 0,i.logPrefix=r,i.log=n.logger.log.bind(n.logger,r+":"),i.warn=n.logger.warn.bind(n.logger,r+":"),i.hls=e,i.fragmentLoader=new A.default(e.config),i.fragmentTracker=t,i.config=e.config,i.decrypter=new g.default(e,e.config),e.on(h.Events.KEY_LOADED,i.onKeyLoaded,function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(i)),i}},"./src/controller/buffer-controller.ts":function(e,t,r){r.r(t),r.d(t,"default",function(){return s});var l=r("./src/polyfills/number.ts"),g=r("./src/events.ts"),p=r("./src/utils/logger.ts"),m=r("./src/errors.ts"),v=r("./src/utils/buffer-helper.ts"),t=r("./src/utils/mediasource-helper.ts"),a=r("./src/loader/fragment.ts"),i=r("./src/controller/buffer-operation-queue.ts"),n=Object(t.getMediaSource)(),d=/([ha]vc.)(?:\.[^.,]+)+/,s=((r=o.prototype).hasSourceTypes=function(){return 0r.config.appendErrorMaxRetry&&(p.logger.error("[buffer-controller]: Failed "+r.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),t.fatal=!0)),r.trigger(g.Events.ERROR,t)}},o)},r.onBufferFlushing=function(e,r){function t(t){return{execute:i.removeExecutor.bind(i,t,r.startOffset,r.endOffset),onStart:function(){},onComplete:function(){i.hls.trigger(g.Events.BUFFER_FLUSHED,{type:t})},onError:function(e){p.logger.warn("[buffer-controller]: Failed to remove from "+t+" SourceBuffer",e)}}}var i=this,n=this.operationQueue;r.type?n.append(t(r.type),r.type):this.getSourceBufferTypes().forEach(function(e){n.append(t(e),e)})},r.onFragParsed=function(e,t){var r=this,i=t.frag,n=t.part,t=[],s=(n||i).elementaryStreams;s[a.ElementaryStreamTypes.AUDIOVIDEO]?t.push("audiovideo"):(s[a.ElementaryStreamTypes.AUDIO]&&t.push("audio"),s[a.ElementaryStreamTypes.VIDEO]&&t.push("video")),0===t.length&&p.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+i.type+" level: "+i.level+" sn: "+i.sn),this.blockBuffers(function(){var e=self.performance.now(),e=(i.stats.buffering.end=e,n&&(n.stats.buffering.end=e),(n||i).stats);r.hls.trigger(g.Events.FRAG_BUFFERED,{frag:i,part:n,stats:e,id:i.type})},t)},r.onFragChanged=function(e,t){this.flushBackBuffer()},r.onBufferEos=function(e,i){var n=this;this.getSourceBufferTypes().reduce(function(e,t){var r=n.sourceBuffer[t];return i.type&&i.type!==t||r&&!r.ended&&(r.ended=!0,p.logger.log("[buffer-controller]: "+t+" sourceBuffer now EOS")),e&&!(r&&!r.ended)},!0)&&this.blockBuffers(function(){var e=n.mediaSource;e&&"open"===e.readyState&&e.endOfStream()})},r.onLevelUpdated=function(e,t){t=t.details;t.fragments.length&&(this.details=t,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},r.flushBackBuffer=function(){var e,t,r,i,n=this.hls,s=this.details,a=this.media,o=this.sourceBuffer;a&&null!==s&&(e=this.getSourceBufferTypes()).length&&(r=s.live&&null!==n.config.liveBackBufferLength?n.config.liveBackBufferLength:n.config.backBufferLength,!Object(l.isFiniteNumber)(r)||r<0||(a=a.currentTime,t=s.levelTargetDuration,r=Math.max(r,t),i=Math.floor(a/t)*t-r,e.forEach(function(e){var t=o[e];t&&0<(t=v.BufferHelper.getBuffered(t)).length&&i>t.start(0)&&(n.trigger(g.Events.BACK_BUFFER_REACHED,{bufferEnd:i}),s.live&&n.trigger(g.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:i}),n.trigger(g.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:i,type:e}))})))},r.updateMediaElementDuration=function(){var e,t,r,i,n,s;this.details&&this.media&&this.mediaSource&&"open"===this.mediaSource.readyState&&(e=this.details,t=this.hls,n=this.media,r=this.mediaSource,i=e.fragments[0].start+e.totalduration,n=n.duration,s=Object(l.isFiniteNumber)(r.duration)?r.duration:0,e.live&&t.config.liveDurationInfinity?(p.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),r.duration=1/0,this.updateSeekableRange(e)):(sthis.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping))},r.getMaxLevel=function(r){var i=this,e=this.hls.levels;if(!e.length)return-1;e=e.filter(function(e,t){return a.isLevelAllowed(t,i.restrictedLevels)&&t<=r});return this.clientRect=null,a.getMaxLevelByMediaSize(e,this.mediaWidth,this.mediaHeight)},r.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},r.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},r.getDimensions=function(){if(this.clientRect)return this.clientRect;var e,t=this.media,r={width:0,height:0};return t&&(e=t.getBoundingClientRect(),r.width=e.width,r.height=e.height,r.width||r.height||(r.width=e.right-e.left||t.width||0,r.height=e.bottom-e.top||t.height||0)),this.clientRect=r},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,n=e.length-1,s=0;s=t||a.height>=r)&&(!(i=e[s+1])||a.width!==i.width||a.height!==i.height)){n=s;break}}return n},r=[{key:"contentScaleFactor",get:function(){var e=1;try{e=self.devicePixelRatio}catch(e){}return e}}],n((s=a).prototype,[{key:"mediaWidth",get:function(){return this.getDimensions().width*a.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*a.contentScaleFactor}}]),n(s,r);var s=a;function a(e){this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.hls=void 0,this.streamController=void 0,this.clientRect=void 0,this.hls=e,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}t.default=s},"./src/controller/cmcd-controller.ts":function(e,t,r){r.r(t),r.d(t,"default",function(){return h});var i=r("./src/events.ts"),a=r("./src/types/cmcd.ts"),n=r("./src/utils/buffer-helper.ts"),o=r("./src/utils/logger.ts");function s(e,t){for(var r=0;r=e.length?{done:!0}:{done:!1,value:e[r++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);rt&&(t=n.bitrate)}return 0s.config.fpsDroppedMonitoringThreshold*n&&(a=s.currentLevel,d.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+a),0=a)&&(s.trigger(l.Events.FPS_DROP_LEVEL_CAPPING,{level:--a,droppedLevel:s.currentLevel}),s.autoLevelCapping=a,this.streamController.nextLevelSwitch()))),this.lastTime=o,this.lastDroppedFrames=r,this.lastDecodedFrames=t)},r.checkFPSInterval=function(){var e,t=this.media;t&&(this.isVideoPlaybackQualityAvailable?(e=t.getVideoPlaybackQuality(),this.checkFPS(t,e.totalVideoFrames,e.droppedVideoFrames)):this.checkFPS(t,t.webkitDecodedFrameCount,t.webkitDroppedFrameCount))},t.default=i},"./src/controller/fragment-finders.ts":function(e,t,r){r.r(t),r.d(t,"findFragmentByPDT",function(){return i}),r.d(t,"findFragmentByPTS",function(){return n}),r.d(t,"fragmentWithinToleranceTest",function(){return o}),r.d(t,"pdtWithinToleranceTest",function(){return l}),r.d(t,"findFragWithCC",function(){return d});var s=r("./src/polyfills/number.ts"),a=r("./src/utils/binary-search.ts");function i(e,t,r){if(null===t||!Array.isArray(e)||!e.length||!Object(s.isFiniteNumber)(t))return null;if(t<(e[0].programDateTime||0))return null;if(t>=(e[e.length-1].endProgramDateTime||0))return null;r=r||0;for(var i=0;ie&&r.start?-1:0}function l(e,t,r){t=1e3*Math.min(t,r.duration+(r.deltaPTS||0));return(r.endProgramDateTime||0)-t>e}function d(e,t){return a.default.search(e,function(e){return e.cct?-1:0})}},"./src/controller/fragment-tracker.ts":function(e,t,r){r.r(t),r.d(t,"FragmentState",function(){return i}),r.d(t,"FragmentTracker",function(){return s});var i,n=r("./src/events.ts"),o=r("./src/types/loader.ts"),s=((t=i=i||{}).NOT_LOADED="NOT_LOADED",t.BACKTRACKED="BACKTRACKED",t.APPENDING="APPENDING",t.PARTIAL="PARTIAL",t.OK="OK",(r=a.prototype)._registerListeners=function(){var e=this.hls;e.on(n.Events.BUFFER_APPENDED,this.onBufferAppended,this),e.on(n.Events.FRAG_BUFFERED,this.onFragBuffered,this),e.on(n.Events.FRAG_LOADED,this.onFragLoaded,this)},r._unregisterListeners=function(){var e=this.hls;e.off(n.Events.BUFFER_APPENDED,this.onBufferAppended,this),e.off(n.Events.FRAG_BUFFERED,this.onFragBuffered,this),e.off(n.Events.FRAG_LOADED,this.onFragLoaded,this)},r.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},r.getAppendedFrag=function(e,t){if(t===o.PlaylistLevelType.MAIN){var r=this.activeFragment,i=this.activeParts;if(!r)return null;if(i)for(var n=i.length;n--;){var s=i[n],a=s?s.end:r.appendedPTS;if(s.start<=e&&void 0!==a&&e<=a)return 9t&&n.removeFragment(e))})},r.removeFragment=function(e){var t=d(e);e.stats.loaded=0,e.clearElementaryStreamInfo(),delete this.fragments[t]},r.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},a);function a(e){this.activeFragment=null,this.activeParts=null,this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hls=e,this._registerListeners()}function l(e){var t;return e.buffered&&(null!=(t=e.range.video)&&t.partial||null!=(t=e.range.audio)&&t.partial)}function d(e){return e.type+"_"+e.level+"_"+e.urlId+"_"+e.sn}},"./src/controller/gap-controller.ts":function(e,t,r){r.r(t),r.d(t,"STALL_MINIMUM_DURATION_MS",function(){return f}),r.d(t,"MAX_START_GAP_JUMP",function(){return A}),r.d(t,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return g}),r.d(t,"SKIP_BUFFER_RANGE_START",function(){return p}),r.d(t,"default",function(){return i});var d=r("./src/utils/buffer-helper.ts"),u=r("./src/errors.ts"),c=r("./src/events.ts"),h=r("./src/utils/logger.ts"),f=250,A=2,g=.1,p=.05,i=((t=n.prototype).destroy=function(){this.hls=this.fragmentTracker=this.media=null},t.poll=function(e){var t=this.config,r=this.media,i=this.stalled,n=r.currentTime,s=r.seeking,a=this.seeking&&!s,o=!this.seeking&&s;if(this.seeking=s,n===e){if((o||a)&&(this.stalled=null),!r.paused&&!r.ended&&0!==r.playbackRate&&d.BufferHelper.getBuffered(r).length){e=d.BufferHelper.bufferInfo(r,n,0),o=0A,l=!a||Ar.maxBufferHole&&t>1e3*r.highBufferWatchdogPeriod&&(h.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,h.logger.warn("Playback stalling at @"+r.currentTime+" due to low buffer (buffer="+e+")"),t.trigger(c.Events.ERROR,{type:u.ErrorTypes.MEDIA_ERROR,details:u.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:e}))},t._trySkipBufferHole=function(e){for(var t=this.config,r=this.hls,i=this.media,n=i.currentTime,s=0,a=d.BufferHelper.getBuffered(i),o=0;o=s&&nthis.hls.config.fragLoadingMaxRetry&&(i=t.frag.level)):i=t.frag.level);break;case g.ErrorDetails.LEVEL_LOAD_ERROR:case g.ErrorDetails.LEVEL_LOAD_TIMEOUT:r&&(r.deliveryDirectives&&(a=!1),i=r.level),s=!0;break;case g.ErrorDetails.REMUX_ALLOC_ERROR:i=t.level,s=!0}void 0!==i&&this.recoverLevel(t,i,s,a)}}},t.recoverLevel=function(e,t,r,i){var n=e.details,s=this._levels[t];if(s.loadError++,r){if(!this.retryLoadingOrFail(e))return void(this.currentLevelIndex=-1);e.levelRetry=!0}i&&(1<(r=s.url.length)&&s.loadError=t.length){var r=e<0;if(this.hls.trigger(A.Events.ERROR,{type:g.ErrorTypes.OTHER_ERROR,details:g.ErrorDetails.LEVEL_SWITCH_ERROR,level:e,fatal:r,reason:"invalid level idx"}),r)return;e=Math.min(e,t.length-1)}this.clearTimer();var r=this.currentLevelIndex,i=t[r],t=t[e],r=(this.log("switching to level "+e+" from "+r),n({},t,{level:this.currentLevelIndex=e,maxBitrate:t.maxBitrate,uri:t.uri,urlId:t.urlId})),e=(delete r._urlId,this.hls.trigger(A.Events.LEVEL_SWITCHING,r),t.details);e&&!e.live||(r=this.switchParams(t.uri,null==i?void 0:i.details),this.loadPlaylist(r))}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(e){this.manualLevelIndex=e,void 0===this._startLevel&&(this._startLevel=e),-1!==e&&(this.level=e)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(e){this._firstLevel=e}},{key:"startLevel",get:function(){var e;return void 0===this._startLevel?void 0!==(e=this.hls.config.startLevel)?e:this._firstLevel:this._startLevel},set:function(e){this._startLevel=e}},{key:"nextLoadLevel",get:function(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(e){this.level=e,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=e)}}]),d);function d(e){return(e=l.call(this,e,"[level-controller]")||this)._levels=[],e._firstLevel=-1,e._startLevel=void 0,e.currentLevelIndex=-1,e.manualLevelIndex=-1,e.onParsedComplete=void 0,e._registerListeners(),e}},"./src/controller/level-helper.ts":function(e,t,r){r.r(t),r.d(t,"addGroupId",function(){return i}),r.d(t,"assignTrackIdsByGroup",function(){return n}),r.d(t,"updatePTS",function(){return s}),r.d(t,"updateFragPTSDTS",function(){return p}),r.d(t,"mergeDetails",function(){return a}),r.d(t,"mapPartIntersection",function(){return m}),r.d(t,"mapFragmentIntersection",function(){return v}),r.d(t,"adjustSliding",function(){return y}),r.d(t,"addSliding",function(){return o}),r.d(t,"computeReloadInterval",function(){return l}),r.d(t,"getFragmentWithSN",function(){return d}),r.d(t,"getPartWith",function(){return u});var f=r("./src/polyfills/number.ts"),A=r("./src/utils/logger.ts");function i(e,t,r){switch(t){case"audio":e.audioGroupIds||(e.audioGroupIds=[]),e.audioGroupIds.push(r);break;case"text":e.textGroupIds||(e.textGroupIds=[]),e.textGroupIds.push(r)}}function n(e){var r={};e.forEach(function(e){var t=e.groupId||"";e.id=r[t]=r[t]||0,r[t]++})}function s(e,t,r){g(e[t],e[r])}function g(e,t){var r,i=t.startPTS;Object(f.isFiniteNumber)(i)?(r=0,(i=t.sn>e.sn?(r=i-e.start,e):(r=e.start-i,t)).duration!==r&&(i.duration=r)):t.sn>e.sn?e.cc===t.cc&&e.minEndPTS?t.start=e.start+(e.minEndPTS-e.start):t.start=e.start+e.duration:t.start=Math.max(e.start-t.duration,0)}function p(e,t,r,i,n,s){i-r<=0&&(A.logger.warn("Fragment should have a positive duration",t),i=r+t.duration,s=n+t.duration);var a=r,o=i,l=t.startPTS,d=t.endPTS,u=(Object(f.isFiniteNumber)(l)&&(u=Math.abs(l-r),Object(f.isFiniteNumber)(t.deltaPTS)?t.deltaPTS=Math.max(u,t.deltaPTS):t.deltaPTS=u,a=Math.max(r,l),r=Math.min(r,l),n=Math.min(n,t.startDTS),o=Math.min(i,d),i=Math.max(i,d),s=Math.max(s,t.endDTS)),t.duration=i-r,r-t.start);t.appendedPTS=i,t.start=t.startPTS=r,t.maxStartPTS=a,t.startDTS=n,t.endPTS=i,t.minEndPTS=o,t.endDTS=s;var c,l=t.sn;if(!e||le.endSN)return 0;var d=l-e.startSN,h=e.fragments;for(h[d]=t,c=d;0=e.length||o(t,e[r].start)}function o(e,t){if(t){for(var r=e.fragments,i=e.skippedSegments;i=this.getMaxBufferLength(t.maxBitrate))){if(this._streamEnded(r,n))return e={},this.altAudio&&(e.type="video"),this.hls.trigger(p.Events.BUFFER_EOS,e),void(this.state=g.State.ENDED);s=r.end,t=this.getNextFragment(s,n);!this.couldBacktrack||this.fragPrevious||!t||"initSegment"===t.sn||1<(e=t.sn-n.startSN)&&(t=n.fragments[e-1],this.fragmentTracker.removeFragment(t)),t&&this.fragmentTracker.getState(t)===a.FragmentState.OK&&this.nextLoadPosition>s&&(r=this.audioOnly&&!this.altAudio?m.ElementaryStreamTypes.AUDIO:m.ElementaryStreamTypes.VIDEO,this.afterBufferFlushed(i,r,c.PlaylistLevelType.MAIN),t=this.getNextFragment(this.nextLoadPosition,n)),t&&("identity"!==(null==(e=(t=!t.initSegment||t.initSegment.data||this.bitrateTest?t:t.initSegment).decryptdata)?void 0:e.keyFormat)||null!=(i=t.decryptdata)&&i.key?this.loadFragment(t,n,s):this.loadKey(t,n))}}}},r.loadFragment=function(e,t,r){var i=this.fragmentTracker.getState(e);if(this.fragCurrent=e,i===a.FragmentState.BACKTRACKED){var n=this.fragmentTracker.getBacktrackData(e);if(n)return this._handleFragmentLoadProgress(n),void this._handleFragmentLoadComplete(n);i=a.FragmentState.NOT_LOADED}i===a.FragmentState.NOT_LOADED||i===a.FragmentState.PARTIAL?"initSegment"===e.sn?this._loadInitSegment(e):this.bitrateTest?(e.bitrateTest=!0,this.log("Fragment "+e.sn+" of level "+e.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(e)):(this.startFragRequested=!0,v.prototype.loadFragment.call(this,e,t,r)):i===a.FragmentState.APPENDING?this.reduceMaxBufferLength(e.duration)&&this.fragmentTracker.removeFragment(e):0===(null==(n=this.media)?void 0:n.buffered.length)&&this.fragmentTracker.removeAllFragments()},r.getAppendedFrag=function(e){e=this.fragmentTracker.getAppendedFrag(e,c.PlaylistLevelType.MAIN);return e&&"fragment"in e?e.fragment:e},r.getBufferedFrag=function(e){return this.fragmentTracker.getBufferedFrag(e,c.PlaylistLevelType.MAIN)},r.followingBufferedFrag=function(e){return e?this.getBufferedFrag(e.end+.5):null},r.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},r.nextLevelSwitch=function(){var e,t=this.levels,r=this.media;null!=r&&r.readyState&&((e=this.getAppendedFrag(r.currentTime))&&1=i[a].start&&s<=i[a].end){n=i[a];break}t=r.start+r.duration;n?n.end=t:i.push(n={start:s,end:t}),this.fragmentTracker.fragBuffered(r)}}},r.onBufferFlushing=function(e,t){var r,i,n,s=t.startOffset,a=t.endOffset;0===s&&a!==Number.POSITIVE_INFINITY&&(r=this.currentTrackId,(i=this.levels).length&&i[r]&&i[r].details&&((n=a-i[r].details.targetduration)<=0||(t.endOffsetSubtitles=Math.max(0,n),this.tracksBuffered.forEach(function(e){for(var t=0;t=n.length||t!==i)&&s){if(this.mediaBuffer=this.mediaBufferTimeRanges,r.live||null!=(n=s.details)&&n.live){i=this.mainDetails;if(r.deltaUpdateFailed||!i)return;n=i.fragments[0];s.details?0===this.alignPlaylists(r,s.details)&&n&&Object(o.addSliding)(r,n.start):r.hasProgramDateTime&&i.hasProgramDateTime?Object(a.alignMediaPlaylistByPDT)(r,i):n&&Object(o.addSliding)(r,n.start)}s.details=r,this.levelLastLoaded=t,this.tick(),!r.live||this.fragCurrent||!this.media||this.state!==c.State.IDLE||Object(d.findFragmentByPTS)(null,r.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),s.details=void 0)}}},r._handleFragmentLoadComplete=function(e){var r,i=e.frag,e=e.payload,t=i.decryptdata,n=this.hls;!this.fragContextChanged(i)&&e&&0this.getMaxBufferLength()+s||(console.assert(e,"Subtitle track details are defined on idle subtitle stream controller tick"),s=(n=e.fragments).length,o=e.edge,a=this.fragPrevious,r=o.length||(this.clearTimer(),r=o[e],this.log("Switching to subtitle track "+e),this.trackId=e,r?(o=r.id,i=r.groupId,n=r.name,s=r.type,a=r.url,this.hls.trigger(l.Events.SUBTITLE_TRACK_SWITCH,{id:o,groupId:void 0===i?"":i,name:n,type:s,url:a}),o=this.switchParams(r.url,null==t?void 0:t.details),this.loadPlaylist(o)):this.hls.trigger(l.Events.SUBTITLE_TRACK_SWITCH,{id:e}))):this.queuedDefaultTrack=e},n.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),this.media&&this.hls.config.renderTextTracksNatively){for(var e=-1,t=c(this.media.textTracks),r=0;r>>8^255&g^99,c[t[g]=h]),m=c[p],v=c[m],y=257*c[g]^16843008*g;i[h]=y<<24|y>>>8,n[h]=y<<16|y>>>16,s[h]=y<<8|y>>>24,a[h]=y,o[g]=(y=16843009*v^65537*m^257*p^16843008*h)<<24|y>>>8,l[g]=y<<16|y>>>16,d[g]=y<<8|y>>>24,u[g]=y,h?(h=p^c[c[c[v^p]]],f^=c[c[f]]):h=f=1}},t.expandKey=function(e){for(var t=this.uint8ArrayToUint32Array_(e),r=!0,i=0;i>>6),u=(60&t[r+2])>>>2;if(!(l.length-1>>6,c.logger.log("manifest codec:"+i+", ADTS type:"+d+", samplingIndex:"+u),t=/firefox/i.test(a)?6<=u?(d=5,s=new Array(4),u-3):(d=2,s=new Array(2),u):-1!==a.indexOf("android")?(d=2,s=new Array(2),u):(d=5,s=new Array(4),i&&(-1!==i.indexOf("mp4a.40.29")||-1!==i.indexOf("mp4a.40.5"))||!i&&6<=u?u-3:((i&&-1!==i.indexOf("mp4a.40.2")&&(6<=u&&1==n||/vivaldi/i.test(a))||!i&&1==n)&&(d=2,s=new Array(2)),u)),s[0]=d<<3,s[0]|=(14&u)>>1,s[1]|=(1&u)<<7,s[1]|=n<<3,5===d&&(s[1]|=(14&t)>>1,s[2]=(1&t)<<7,s[2]|=8,s[3]=0),{config:s,samplerate:l[u],channelCount:n,codec:"mp4a.40."+d,manifestCodec:o};e.trigger(f.Events.ERROR,{type:h.ErrorTypes.MEDIA_ERROR,details:h.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+u})}function i(e,t){return 255===e[t]&&240==(246&e[t+1])}function a(e,t){return 1&e[t+1]?7:9}function o(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function n(e,t){return t+5=e.length)return!1;var i=o(e,t);if(i<=r)return!1;r=t+i;return r===e.length||l(e,r)}return!1}function A(e,t,r,i,n){e.samplerate||(t=s(t,r,i,n))&&(e.config=t.config,e.samplerate=t.samplerate,e.channelCount=t.channelCount,e.codec=t.codec,e.manifestCodec=t.manifestCodec,c.logger.log("parsed codec:"+e.codec+", rate:"+t.samplerate+", channels:"+t.channelCount))}function g(e){return 9216e4/e}function p(e,t,r,i,n){var s=a(e,t),e=o(e,t);if(0<(e-=s))return{headerLength:s,frameLength:e,stamp:r+i*n}}function m(e,t,r,i,n){var s,a,o,i=p(t,r,i,n,g(e.samplerate));if(i)return n=i.frameLength,a=i.headerLength,i=i.stamp,n=a+n,(o=Math.max(0,r+n-t.length))?(s=new Uint8Array(n-a)).set(t.subarray(r+a,t.length),0):s=t.subarray(r+a,r+n),t={unit:s,pts:i},o||e.samples.push(t),{sample:t,length:n,missing:o}}},"./src/demux/base-audio-demuxer.ts":function(e,t,r){r.r(t),r.d(t,"initPTSFn",function(){return g});var i=r("./src/polyfills/number.ts"),c=r("./src/demux/id3.ts"),h=r("./src/demux/dummy-demuxed-track.ts"),f=r("./src/utils/mp4-tools.ts"),A=r("./src/utils/typed-array.ts");(r=n.prototype).resetInitSegment=function(e,t,r){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},r.resetTimeStamp=function(){},r.resetContiguity=function(){},r.canParse=function(e,t){return!1},r.appendFrame=function(e,t,r){},r.demux=function(e,t){this.cachedData&&(e=Object(f.appendUint8Array)(this.cachedData,e),this.cachedData=null);var r,i,n,s=c.getID3Data(e,0),a=s?s.length:0,o=this._audioTrack,l=this._id3Track,d=s?c.getTimeStamp(s):void 0,u=e.length;for(0!==this.frameIndex&&null!==this.initPTS||(this.initPTS=g(d,t)),s&&0e||(e=(e-=this.bitsAvailable)-((t=e>>3)>>3),this.bytesAvailable-=t,this.loadWord()),this.word<<=e,this.bitsAvailable-=e},r.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()},r.skipUEG=function(){this.skipBits(1+this.skipLZ())},r.skipEG=function(){this.skipBits(1+this.skipLZ())},r.readUEG=function(){var e=this.skipLZ();return this.readBits(e+1)-1},r.readEG=function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)},r.readBoolean=function(){return 1===this.readBits(1)},r.readUByte=function(){return this.readBits(8)},r.readUShort=function(){return this.readBits(16)},r.readUInt=function(){return this.readBits(32)},r.skipScalingList=function(e){for(var t=8,r=8,i=0;i>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:l+=String.fromCharCode(n);break;case 12:case 13:s=e[d++],l+=String.fromCharCode((31&n)<<6|63&s);break;case 14:s=e[d++],a=e[d++],l+=String.fromCharCode((15&n)<<12|(63&s)<<6|(63&a)<<0)}}return l},y={decodeTextFrame:g}},"./src/demux/mp3demuxer.ts":function(e,t,r){r.r(t);var i=r("./src/demux/base-audio-demuxer.ts"),n=r("./src/demux/id3.ts"),s=r("./src/utils/logger.ts"),a=r("./src/demux/mpegaudio.ts");function o(e,t){return(o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}l=i.default,r=l,(i=d).prototype=Object.create(r.prototype),o(i.prototype.constructor=i,r),(i=d.prototype).resetInitSegment=function(e,t,r){l.prototype.resetInitSegment.call(this,e,t,r),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!1,samples:[],manifestCodec:e,duration:r,inputTimeScale:9e4,dropped:0}},d.probe=function(e){if(!e)return!1;for(var t=(n.getID3Data(e,0)||[]).length,r=e.length;tt.length)){var s=a(t,r);if(s&&r+s.frameLength<=t.length)return i=i+n*(9e4*s.samplesPerFrame/s.sampleRate),n={unit:t.subarray(r,r+s.frameLength),pts:i,dts:i},e.config=[],e.channelCount=s.channelCount,e.samplerate=s.sampleRate,e.samples.push(n),{sample:n,length:s.frameLength,missing:0}}}function a(e,t){var r,i,n,s,a,o=e[t+1]>>3&3,l=e[t+1]>>1&3,d=e[t+2]>>4&15,u=e[t+2]>>2&3;if(1!=o&&0!=d&&15!=d&&3!=u)return a=e[t+2]>>1&1,r=e[t+3]>>6,d=1e3*h[14*(3==o?3-l:3==l?3:4)+d-1],u=f[3*(3==o?0:2==o?1:2)+u],i=3==r?1:2,s=8*(o=A[o][l])*(n=g[l]),o=Math.floor(o*d/u+a)*n,null===c&&(a=(navigator.userAgent||"").match(/Chrome\/(\d+)/i),c=a?parseInt(a[1]):0),c&&c<=87&&2==l&&224e3<=d&&0==r&&(e[t+3]=128|e[t+3]),{sampleRate:u,channelCount:i,frameLength:o,samplesPerFrame:s}}function n(e,t){return 255===e[t]&&224==(224&e[t+1])&&0!=(6&e[t+1])}function s(e,t){return t+1=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}}},r.getAvcEncryptedData=function(e){for(var t=16*Math.floor((e.length-48)/160)+16,r=new Int8Array(t),i=0,n=32;n=e.length)return void i();for(var n=e[t].units;!(r>=n.length);r++){var s=n[r];if(!(s.data.length<=48||1!==s.type&&5!==s.type)){var a=this.decrypter.isSync();if(this.decryptAvcSample(e,t,r,i,s,a),!a)return}}}},t.default=n},"./src/demux/transmuxer-interface.ts":function(e,t,r){r.r(t),r.d(t,"default",function(){return i});var l=r("./node_modules/webworkify-webpack/index.js"),d=r("./src/events.ts"),T=r("./src/demux/transmuxer.ts"),S=r("./src/utils/logger.ts"),u=r("./src/errors.ts"),t=r("./src/utils/mediasource-helper.ts"),c=r("./node_modules/eventemitter3/index.js"),h=Object(t.getMediaSource)()||{isTypeSupported:function(){return!1}},i=((r=n.prototype).destroy=function(){var e=this.worker,e=(e?(e.removeEventListener("message",this.onwmsg),e.terminate(),this.worker=null):(e=this.transmuxer)&&(e.destroy(),this.transmuxer=null),this.observer);e&&e.removeAllListeners(),this.observer=null},r.push=function(e,t,r,i,n,s,a,o,l,d){var u=this,c=(l.transmuxing.start=self.performance.now(),this.transmuxer),h=this.worker,f=(s||n).start,A=n.decryptdata,g=this.frag,p=!(g&&n.cc===g.cc),m=!(g&&l.level===g.level),v=g?l.sn-g.sn:-1,y=this.part?l.part-this.part.index:1,b=!m&&(1==v||0==v&&1==y),E=self.performance.now(),E=((m||v||0===n.stats.parsing.start)&&(n.stats.parsing.start=E),!s||!y&&b||(s.stats.parsing.start=E),!(g&&(null==(v=n.initSegment)?void 0:v.url)===(null==(y=g.initSegment)?void 0:y.url))),v=new T.TransmuxState(p,b,o,m,f,E);b&&!p&&!E||(S.logger.log("[transmuxer-interface, "+n.type+"]: Starting new transmux session for sn: "+l.sn+" p: "+l.part+" level: "+l.level+" id: "+l.id+"\n discontinuity: "+p+"\n trackSwitch: "+m+"\n contiguous: "+b+"\n accurateTimeOffset: "+o+"\n timeOffset: "+f+"\n initSegmentChange: "+E),g=new T.TransmuxConfig(r,i,t,a,d),this.configureTransmuxer(g)),this.frag=n,this.part=s,h?h.postMessage({cmd:"demux",data:e,decryptdata:A,chunkMeta:l,state:v},e instanceof ArrayBuffer?[e]:[]):c&&(y=c.push(e,A,l,v),Object(T.isPromise)(y)?y.then(function(e){u.handleTransmuxComplete(e)}):this.handleTransmuxComplete(y))},r.flush=function(t){var r=this,e=(t.transmuxing.start=self.performance.now(),this.transmuxer),i=this.worker;i?i.postMessage({cmd:"flush",chunkMeta:t}):e&&(i=e.flush(t),Object(T.isPromise)(i)?i.then(function(e){r.handleFlushResult(e,t)}):this.handleFlushResult(i,t))},r.handleFlushResult=function(e,t){var r=this;e.forEach(function(e){r.handleTransmuxComplete(e)}),this.onFlush(t)},r.onWorkerMessage=function(e){var t=e.data,r=this.hls;switch(t.event){case"init":self.URL.revokeObjectURL(this.worker.objectURL);break;case"transmuxComplete":this.handleTransmuxComplete(t.data);break;case"flush":this.onFlush(t.data);break;default:t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,r.trigger(t.event,t.data)}},r.configureTransmuxer=function(e){var t=this.worker,r=this.transmuxer;t?t.postMessage({cmd:"configure",config:e}):r&&r.configure(e)},r.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},n);function n(r,e,t,i){function n(e,t){(t=t||{}).frag=a.frag,t.id=a.id,r.trigger(e,t)}var s,a=this,t=(this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.worker=void 0,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.hls=r,this.id=e,this.onTransmuxComplete=t,this.onFlush=i,r.config),i=(this.observer=new c.EventEmitter,this.observer.on(d.Events.FRAG_DECRYPTED,n),this.observer.on(d.Events.ERROR,n),{mp4:h.isTypeSupported("video/mp4"),mpeg:h.isTypeSupported("audio/mpeg"),mp3:h.isTypeSupported('audio/mp4; codecs="mp3"')}),o=navigator.vendor;if(t.enableWorker&&"undefined"!=typeof Worker){S.logger.log("demuxing in webworker");try{s=this.worker=l("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),s.addEventListener("message",this.onwmsg),s.onerror=function(e){r.trigger(d.Events.ERROR,{type:u.ErrorTypes.OTHER_ERROR,details:u.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(e.message+" ("+e.filename+":"+e.lineno+")")})},s.postMessage({cmd:"init",typeSupported:i,vendor:o,id:e,config:JSON.stringify(t)})}catch(r){S.logger.warn("Error in worker:",r),S.logger.error("Error while initializing DemuxerWorker, fallback to inline"),s&&self.URL.revokeObjectURL(s.objectURL),this.transmuxer=new T.default(this.observer,i,t,o,e),this.worker=null}}else this.transmuxer=new T.default(this.observer,i,t,o,e)}},"./src/demux/transmuxer-worker.ts":function(e,t,r){r.r(t),r.d(t,"default",function(){return n});var o=r("./src/demux/transmuxer.ts"),i=r("./src/events.ts"),l=r("./src/utils/logger.ts"),d=r("./node_modules/eventemitter3/index.js");function n(n){function s(e,t){n.postMessage({event:e,data:t})}var a=new d.EventEmitter;a.on(i.Events.FRAG_DECRYPTED,s),a.on(i.Events.ERROR,s),n.addEventListener("message",function(e){var t=e.data;switch(t.cmd){case"init":var r=JSON.parse(t.config);n.transmuxer=new o.default(a,t.typeSupported,r,t.vendor,t.id),Object(l.enableLogs)(r.debug),s("init",null);break;case"configure":n.transmuxer.configure(t.config);break;case"demux":r=n.transmuxer.push(t.data,t.decryptdata,t.chunkMeta,t.state);Object(o.isPromise)(r)?r.then(function(e){u(n,e)}):u(n,r);break;case"flush":var i=t.chunkMeta,r=n.transmuxer.flush(i);Object(o.isPromise)(r)?r.then(function(e){c(n,e,i)}):c(n,r,i)}})}function u(e,t){var r,i,n;((r=t.remuxResult).audio||r.video||r.text||r.id3||r.initSegment)&&(r=[],i=(n=t.remuxResult).audio,n=n.video,i&&s(r,i),n&&s(r,n),e.postMessage({event:"transmuxComplete",data:t},r))}function s(e,t){t.data1&&e.push(t.data1.buffer),t.data2&&e.push(t.data2.buffer)}function c(t,e,r){e.forEach(function(e){u(t,e)}),t.postMessage({event:"flush",data:r})}},"./src/demux/transmuxer.ts":function(e,t,r){r.r(t),r.d(t,"default",function(){return c}),r.d(t,"isPromise",function(){return f}),r.d(t,"TransmuxConfig",function(){return A}),r.d(t,"TransmuxState",function(){return g});var v,l=r("./src/events.ts"),d=r("./src/errors.ts"),i=r("./src/crypt/decrypter.ts"),t=r("./src/demux/aacdemuxer.ts"),m=r("./src/demux/mp4demuxer.ts"),n=r("./src/demux/tsdemuxer.ts"),s=r("./src/demux/mp3demuxer.ts"),a=r("./src/remux/mp4-remuxer.ts"),y=r("./src/remux/passthrough-remuxer.ts"),o=r("./src/demux/chunk-cache.ts"),b=r("./src/utils/mp4-tools.ts"),E=r("./src/utils/logger.ts");try{v=self.performance.now.bind(self.performance)}catch(e){E.logger.debug("Unable to use Performance API on this environment"),v=self.Date.now}var T=[{demux:n.default,remux:a.default},{demux:m.default,remux:y.default},{demux:t.default,remux:a.default},{demux:s.default,remux:a.default}],u=1024,c=(T.forEach(function(e){e=e.demux;u=Math.max(u,e.minProbeByteLength)}),(r=h.prototype).configure=function(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()},r.push=function(e,t,r,i){var n=this,s=r.transmuxing,e=(s.executeStart=v(),new Uint8Array(e)),a=this.cache,o=this.config,l=this.currentTransmuxState,d=this.transmuxConfig,t=(i&&(this.currentTransmuxState=i),u=null,u=0>4){if((w=E+5+e[E+4])===E+188)continue}else w=E+4;switch(S){case l:T&&(d&&(n=F(d))&&this.parseAVCPES(n,!1),d={data:[],size:0}),d&&(d.data.push(e.subarray(w,E+188)),d.size+=E+188-w);break;case u:T&&(h&&(n=F(h))&&(a.isAAC?this.parseAACPES(n):this.parseMPEGPES(n)),h={data:[],size:0}),h&&(h.data.push(e.subarray(w,E+188)),h.size+=E+188-w);break;case c:T&&(f&&(n=F(f))&&this.parseID3PES(n),f={data:[],size:0}),f&&(f.data.push(e.subarray(w,E+188)),f.size+=E+188-w);break;case 0:T&&(w+=e[w]+1),p=this._pmtId=(31&(R=e)[(y=w)+10])<<8|R[y+11];break;case p:T&&(w+=e[w]+1);var R=function(e,t,r,i){var 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;var l=t[7],d=(192&l&&(i=536870912*(14&t[9])+4194304*(255&t[10])+16384*(254&t[11])+128*(255&t[12])+(254&t[13])/2,64&l?54e5=e[r-1].pts)e.push(t);else for(var i=r-1;0<=i;i--)if(t.ptst)return i;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(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.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:"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)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var e=this.subtitleTrackController;return!!e&&e.subtitleDisplay},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(e){this.config.lowLatencyMode=e}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}]),o(r,t);var l=E;function E(e){void 0===e&&(e={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new b.EventEmitter,this._autoLevelCapping=void 0,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null;var t=this.config=Object(y.mergeConfig)(E.DefaultConfig,e),e=(this.userConfig=e,Object(v.enableLogs)(t.debug),this._autoLevelCapping=-1,t.progressive&&Object(y.enableStreamingMode)(t),t.abrController),r=t.bufferController,i=t.capLevelController,n=t.fpsController,e=this.abrController=new e(this),r=this.bufferController=new r(this),i=this.capLevelController=new i(this),n=new n(this),s=new c.default(this),a=new h.default(this),o=new f.default(this),l=this.levelController=new g.default(this),d=new p.FragmentTracker(this),u=this.streamController=new m.default(this,d),l=(i.setStreamController(u),n.setStreamController(u),[l,u]),u=(this.networkControllers=l,[s,a,e,r,i,n,o,d]);this.audioTrackController=this.createController(t.audioTrackController,null,l),this.createController(t.audioStreamController,d,l),this.subtitleTrackController=this.createController(t.subtitleTrackController,null,l),this.createController(t.subtitleStreamController,d,l),this.createController(t.timelineController,null,u),this.emeController=this.createController(t.emeController,null,u),this.cmcdController=this.createController(t.cmcdController,null,u),this.latencyController=this.createController(A.default,null,u),this.coreComponents=u}l.defaultConfig=void 0},"./src/is-supported.ts":function(e,t,r){r.r(t),r.d(t,"isSupported",function(){return s}),r.d(t,"changeTypeSupported",function(){return a});var i=r("./src/utils/mediasource-helper.ts");function n(){return self.SourceBuffer||self.WebKitSourceBuffer}function s(){var e=Object(i.getMediaSource)();if(!e)return!1;var t=n(),e=e&&"function"==typeof e.isTypeSupported&&e.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),t=!t||t.prototype&&"function"==typeof t.prototype.appendBuffer&&"function"==typeof t.prototype.remove;return!!e&&!!t}function a(){var e=n();return"function"==typeof(null==e||null==(e=e.prototype)?void 0:e.changeType)}},"./src/loader/fragment-loader.ts":function(e,t,r){r.r(t),r.d(t,"default",function(){return l}),r.d(t,"LoadError",function(){return g});var i=r("./src/polyfills/number.ts"),h=r("./src/errors.ts");function n(e){var r="function"==typeof Map?new Map:void 0;return(n=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(e))return r.get(e);r.set(e,t)}function t(){return s(e,arguments,o(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),a(t,e)})(e)}function s(e,t,r){return(s=function(){if("undefined"==typeof Reflect||!Reflect.construct)return;if(Reflect.construct.sham)return;if("function"==typeof Proxy)return 1;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),1}catch(e){return}}()?Reflect.construct:function(e,t,r){var i=[null],t=(i.push.apply(i,t),new(Function.bind.apply(e,i)));return r&&a(t,r.prototype),t}).apply(null,arguments)}function a(e,t){return(a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function o(e){return(o=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var f=Math.pow(2,17),l=((t=d.prototype).destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},t.abort=function(){this.loader&&this.loader.abort()},t.load=function(a,o){var l=this,e=a.url;if(!e)return Promise.reject(new g({type:h.ErrorTypes.NETWORK_ERROR,details:h.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:a,networkDetails:null},"Fragment does not have a "+(e?"part list":"url")));this.abort();var r=this.config,d=r.fLoader,u=r.loader;return new Promise(function(n,i){l.loader&&l.loader.destroy();var s=l.loader=a.loader=new(d||u)(r),e=A(a),t={timeout:r.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:r.fragLoadingMaxRetryTimeout,highWaterMark:f};a.stats=s.stats,s.load(e,t,{onSuccess:function(e,t,r,i){l.resetLoader(a,s),n({frag:a,part:null,payload:e.data,networkDetails:i})},onError:function(e,t,r){l.resetLoader(a,s),i(new g({type:h.ErrorTypes.NETWORK_ERROR,details:h.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:a,response:e,networkDetails:r}))},onAbort:function(e,t,r){l.resetLoader(a,s),i(new g({type:h.ErrorTypes.NETWORK_ERROR,details:h.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:a,networkDetails:r}))},onTimeout:function(e,t,r){l.resetLoader(a,s),i(new g({type:h.ErrorTypes.NETWORK_ERROR,details:h.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:a,networkDetails:r}))},onProgress:function(e,t,r,i){o&&o({frag:a,part:null,payload:r,networkDetails:i})}})})},t.loadPart=function(a,o,l){var d=this,r=(this.abort(),this.config),u=r.fLoader,c=r.loader;return new Promise(function(n,i){d.loader&&d.loader.destroy();var s=d.loader=a.loader=new(u||c)(r),e=A(a,o),t={timeout:r.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:r.fragLoadingMaxRetryTimeout,highWaterMark:f};o.stats=s.stats,s.load(e,t,{onSuccess:function(e,t,r,i){d.resetLoader(a,s),d.updateStatsFromPart(a,o);e={frag:a,part:o,payload:e.data,networkDetails:i};l(e),n(e)},onError:function(e,t,r){d.resetLoader(a,s),i(new g({type:h.ErrorTypes.NETWORK_ERROR,details:h.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:a,part:o,response:e,networkDetails:r}))},onAbort:function(e,t,r){a.stats.aborted=o.stats.aborted,d.resetLoader(a,s),i(new g({type:h.ErrorTypes.NETWORK_ERROR,details:h.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:a,part:o,networkDetails:r}))},onTimeout:function(e,t,r){d.resetLoader(a,s),i(new g({type:h.ErrorTypes.NETWORK_ERROR,details:h.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:a,part:o,networkDetails:r}))}})})},t.updateStatsFromPart=function(e,t){var r=e.stats,i=t.stats,n=i.total,e=(r.loaded+=i.loaded,n?(n=((e=Math.round(e.duration/t.duration))-(t=Math.min(Math.round(r.loaded/n),e)))*Math.round(r.loaded/t),r.total=r.loaded+n):r.total=Math.max(r.loaded,r.total),r.loading),t=i.loading;e.start?e.first+=t.first-t.start:(e.start=t.start,e.first=t.first),e.end=t.end},t.resetLoader=function(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()},d);function d(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}function A(e,t){var r=(t=void 0===t?null:t)||e,e={frag:e,part:t,responseType:"arraybuffer",url:r.url,headers:{},rangeStart:0,rangeEnd:0},t=r.byteRangeStartOffset,r=r.byteRangeEndOffset;return Object(i.isFiniteNumber)(t)&&Object(i.isFiniteNumber)(r)&&(e.rangeStart=t,e.rangeEnd=r),e}u=n(Error),r=u,(t=c).prototype=Object.create(r.prototype),a(t.prototype.constructor=t,r);var u,g=c;function c(e){for(var t,r=arguments.length,i=new Array(1>8*(15-r)&255;return t},r.setDecryptDataFromLevelKey=function(e,t){var r=e;return"AES-128"===(null==e?void 0:e.method)&&e.uri&&!e.iv&&((r=o.LevelKey.fromURI(e.uri)).method=e.method,r.iv=this.createInitializationVector(t),r.keyFormat="identity"),r},r.setElementaryStreamInfo=function(e,t,r,i,n,s){void 0===s&&(s=!1);var a=this.elementaryStreams,o=a[e];o?(o.startPTS=Math.min(o.startPTS,t),o.endPTS=Math.max(o.endPTS,r),o.startDTS=Math.min(o.startDTS,i),o.endDTS=Math.max(o.endDTS,n)):a[e]={startPTS:t,endPTS:r,startDTS:i,endDTS:n,partial:s}},r.clearElementaryStreamInfo=function(){var e=this.elementaryStreams;e[i.AUDIO]=null,e[i.VIDEO]=null,e[i.AUDIOVIDEO]=null},h(y,[{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&&a.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:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(null===this.programDateTime)return null;if(!Object(n.isFiniteNumber)(this.programDateTime))return null;var e=Object(n.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+1e3*e}},{key:"encrypted",get:function(){var e;return!(null==(e=this.decryptdata)||!e.keyFormat||!this.decryptdata.uri)}}]),y),m=(d(v,f=g),h(v,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var e=this.elementaryStreams;return!!(e.audio||e.video||e.audiovideo)}}]),v);function v(e,t,r,i,n){(r=f.call(this,r)||this).fragOffset=0,r.duration=0,r.gap=!1,r.independent=!1,r.relurl=void 0,r.fragment=void 0,r.index=void 0,r.stats=new l.LoadStats,r.duration=e.decimalFloatingPoint("DURATION"),r.gap=e.bool("GAP"),r.independent=e.bool("INDEPENDENT"),r.relurl=e.enumeratedString("URI"),r.fragment=t,r.index=i;t=e.enumeratedString("BYTERANGE");return t&&r.setByteRange(t,n),n&&(r.fragOffset=n.fragOffset+n.duration),r}function y(e,t){return(t=A.call(this,t)||this)._decryptdata=null,t.rawProgramDateTime=null,t.programDateTime=null,t.tagList=[],t.duration=0,t.sn=0,t.levelkey=void 0,t.type=void 0,t.loader=null,t.level=-1,t.cc=0,t.startPTS=void 0,t.endPTS=void 0,t.appendedPTS=void 0,t.startDTS=void 0,t.endDTS=void 0,t.start=0,t.deltaPTS=void 0,t.maxStartPTS=void 0,t.minEndPTS=void 0,t.stats=new l.LoadStats,t.urlId=0,t.data=void 0,t.bitrateTest=!1,t.title=null,t.initSegment=null,t.type=e,t}function b(e){var t;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=((t={})[i.AUDIO]=null,t[i.VIDEO]=null,t[i.AUDIOVIDEO]=null,t),this.baseurl=e}},"./src/loader/key-loader.ts":function(e,t,r){r.r(t),r.d(t,"default",function(){return n});var a=r("./src/events.ts"),i=r("./src/errors.ts"),o=r("./src/utils/logger.ts"),n=((t=s.prototype)._registerListeners=function(){this.hls.on(a.Events.KEY_LOADING,this.onKeyLoading,this)},t._unregisterListeners=function(){this.hls.off(a.Events.KEY_LOADING,this.onKeyLoading)},t.destroy=function(){for(var e in this._unregisterListeners(),this.loaders){e=this.loaders[e];e&&e.destroy()}this.loaders={}},t.onKeyLoading=function(e,t){var r,i,t=t.frag,n=t.type,s=this.loaders[n];t.decryptdata?(r=t.decryptdata.uri)!==this.decrypturl||null===this.decryptkey?(i=this.hls.config,s&&(o.logger.warn("abort previous key loader for type:"+n),s.abort()),r?(s=i.loader,n=t.loader=this.loaders[n]=new s(i),this.decrypturl=r,this.decryptkey=null,s={url:r,frag:t,responseType:"arraybuffer"},r={timeout:i.fragLoadingTimeOut,maxRetry:0,retryDelay:i.fragLoadingRetryDelay,maxRetryDelay:i.fragLoadingMaxRetryTimeout,highWaterMark:0},i={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)},n.load(s,r,i)):o.logger.warn("key uri is falsy")):this.decryptkey&&(t.decryptdata.key=this.decryptkey,this.hls.trigger(a.Events.KEY_LOADED,{frag:t})):o.logger.warn("Missing decryption data on fragment in onKeyLoading")},t.loadsuccess=function(e,t,r){r=r.frag;r.decryptdata?(this.decryptkey=r.decryptdata.key=new Uint8Array(e.data),r.loader=null,delete this.loaders[r.type],this.hls.trigger(a.Events.KEY_LOADED,{frag:r})):o.logger.error("after key load, decryptdata unset")},t.loaderror=function(e,t){var t=t.frag,r=t.loader;r&&r.abort(),delete this.loaders[t.type],this.hls.trigger(a.Events.ERROR,{type:i.ErrorTypes.NETWORK_ERROR,details:i.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:t,response:e})},t.loadtimeout=function(e,t){var t=t.frag,r=t.loader;r&&r.abort(),delete this.loaders[t.type],this.hls.trigger(a.Events.ERROR,{type:i.ErrorTypes.NETWORK_ERROR,details:i.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:t})},s);function s(e){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=e,this._registerListeners()}},"./src/loader/level-details.ts":function(e,t,r){r.r(t),r.d(t,"LevelDetails",function(){return s});var i=r("./src/polyfills/number.ts");function n(e,t){for(var r=0;re.endSN||0>24&255,o[1]=t>>16&255,o[2]=t>>8&255,o[3]=255&t,o.set(e,4),s=0,t=8;s>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+s)),t=Math.floor(t%(1+s)),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),n=0;n>>8&255),i.push(255&r),i=i.concat(Array.prototype.slice.call(t));for(s=0;s>>8&255),n.push(255&r),n=n.concat(Array.prototype.slice.call(t));var a=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(n))),o=e.width,l=e.height,d=e.pixelRatio[0],u=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,o>>8&255,255&o,l>>8&255,255&l,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]),a,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([d>>24,d>>16&255,d>>8&255,255&d,u>>24,u>>16&255,u>>8&255,255&u])))},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,n=Math.floor(r/(1+s)),r=Math.floor(r%(1+s));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,n>>24,n>>16&255,n>>8&255,255&n,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,n=Math.floor(t/(1+s)),t=Math.floor(t%(1+s));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,n>>24,n>>16&255,n>>8&255,255&n,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,n,s,a,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,n>>>24&255,n>>>16&255,n>>>8&255,255&n,s.isLeading<<2|s.dependsOn,s.isDependedOn<<6|s.hasRedundancy<<4|s.paddingValue<<1|s.isNonSync,61440&s.degradPrio,15&s.degradPrio,a>>>24&255,a>>>16&255,a>>>8&255,255&a],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(){}r.types=void 0,r.HDLR_TYPES=void 0,r.STTS=void 0,r.STSC=void 0,r.STCO=void 0,r.STSZ=void 0,r.VMHD=void 0,r.SMHD=void 0,r.STSD=void 0,r.FTYP=void 0,r.DINF=void 0,t.default=r},"./src/remux/mp4-remuxer.ts":function(e,t,r){r.r(t),r.d(t,"default",function(){return i}),r.d(t,"normalizePts",function(){return Z});var h=r("./src/polyfills/number.ts"),M=r("./src/remux/aac-helper.ts"),W=r("./src/remux/mp4-generator.ts"),K=r("./src/events.ts"),Y=r("./src/errors.ts"),Q=r("./src/utils/logger.ts"),T=r("./src/types/loader.ts"),z=r("./src/utils/timescale-conversion.ts");function q(){return(q=Object.assign||function(e){for(var t=1;tm.pts&&(A=Math.max(Math.min(A,m.pts-m.dts),-18e3)),m.dtsNumber.MAX_SAFE_INTEGER?1/0:e},r.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},r.decimalFloatingPoint=function(e){return parseFloat(this[e])},r.optionalFloat=function(e,t){e=this[e];return e?parseFloat(e):t},r.enumeratedString=function(e){return this[e]},r.bool=function(e){return"YES"===this[e]},r.decimalResolution=function(e){e=i.exec(this[e]);if(null!==e)return{width:parseInt(e[1],10),height:parseInt(e[2],10)}},a.parseAttrList=function(e){var t,r={};for(n.lastIndex=0;null!==(t=n.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},a);function a(e){for(var t in e="string"==typeof e?a.parseAttrList(e):e)e.hasOwnProperty(t)&&(this[t]=e[t])}},"./src/utils/binary-search.ts":function(e,t,r){r.r(t),t.default={search:function(e,t){for(var r,i,n=0,s=e.length-1;n<=s;){var a=t(i=e[r=(n+s)/2|0]);if(0=r.start(i)&&t<=r.end(i))return!0}catch(e){}return!1},a.bufferInfo=function(e,t,r){try{if(e){for(var i=a.getBuffered(e),n=[],s=0;ss&&(i[a-1].end=e[n].end):i.push(e[n])):i.push(e[n])}else i=e;for(var o,l=0,d=t,u=t,c=0;c=e&&i.logger.log(this.time+" ["+e+"] "+t)},k),p=((r=D.prototype).reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},r.setStyles=function(e){for(var t=["foreground","underline","italics","background","flash"],r=0;ra&&(this.logger.log(d.DEBUG,"Too large cursor position "+this.pos),this.pos=a)},r.moveCursor=function(e){var t=this.pos+e;if(1=a?this.logger.log(d.ERROR,"Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!"):(this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1))},r.clearFromPos=function(e){for(var t=e;t ("+l([a,o])+")"),!(r=(r=(r=(r=this.parseCmd(a,o))?r:this.parseMidrow(a,o))||this.parsePAC(a,o))||this.parseBackgroundAttributes(a,o))&&(i=this.parseChars(a,o))&&((s=this.currentChannel)&&0r.startCC||e&&e.cc=this.minWeight_},r.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},r.destroy=function(){},t.default=i},"./src/utils/ewma.ts":function(e,t,r){function i(e,t,r){void 0===t&&(t=0),void 0===r&&(r=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=r}r.r(t),(r=i.prototype).sample=function(e,t){var r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e},r.getTotalWeight=function(){return this.totalWeight_},r.getEstimate=function(){if(this.alpha_){var e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_},t.default=i},"./src/utils/fetch-loader.ts":function(e,t,r){r.r(t),r.d(t,"fetchSupported",function(){return l});var c=r("./src/polyfills/number.ts"),i=r("./src/loader/load-stats.ts"),d=r("./src/demux/chunk-cache.ts");function n(e){var r="function"==typeof Map?new Map:void 0;return(n=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(e))return r.get(e);r.set(e,t)}function t(){return s(e,arguments,o(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),a(t,e)})(e)}function s(e,t,r){return(s=function(){if("undefined"==typeof Reflect||!Reflect.construct)return;if(Reflect.construct.sham)return;if("function"==typeof Proxy)return 1;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),1}catch(e){return}}()?Reflect.construct:function(e,t,r){var i=[null],t=(i.push.apply(i,t),new(Function.bind.apply(e,i)));return r&&a(t,r.prototype),t}).apply(null,arguments)}function a(e,t){return(a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function o(e){return(o=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function h(){return(h=Object.assign||function(e){for(var t=1;t=a&&o(n,s,l.flush(),i)):o(n,s,e,i),r()}).catch(function(){return Promise.reject()})}()};r=u;function u(e){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=e.fetchSetup||f,this.controller=new self.AbortController,this.stats=new i.LoadStats}function f(e,t){return new self.Request(e.url,t)}A=n(Error),p=A,(g=v).prototype=Object.create(p.prototype),a(g.prototype.constructor=g,p);var A,g,p,m=v;function v(e,t,r){return(e=A.call(this,e)||this).code=void 0,e.details=void 0,e.code=t,e.details=r,e}t.default=r},"./src/utils/imsc1-ttml-parser.ts":function(e,t,r){r.r(t),r.d(t,"IMSC1_CODEC",function(){return i}),r.d(t,"parseIMSC1",function(){return n});var a=r("./src/utils/mp4-tools.ts"),o=r("./src/utils/vttparser.ts"),f=r("./src/utils/vttcue.ts"),l=r("./src/demux/id3.ts"),d=r("./src/utils/timescale-conversion.ts"),A=r("./src/utils/webvtt-parser.ts");function g(){return(g=Object.assign||function(e){for(var t=1;t"):n)})}(e,"debug","log","info","warn","error");try{s.log()}catch(e){s=i}}else s=i}var o=i},"./src/utils/mediakeys-helper.ts":function(e,t,r){r.r(t),r.d(t,"KeySystems",function(){return i}),r.d(t,"requestMediaKeySystemAccess",function(){return n}),(r=i=i||{}).WIDEVINE="com.widevine.alpha",r.PLAYREADY="com.microsoft.playready";var i,n="undefined"!=typeof self&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null},"./src/utils/mediasource-helper.ts":function(e,t,r){function i(){return self.MediaSource||self.WebKitMediaSource}r.r(t),r.d(t,"getMediaSource",function(){return i})},"./src/utils/mp4-tools.ts":function(e,t,r){r.r(t),r.d(t,"bin2str",function(){return u}),r.d(t,"readUint16",function(){return h}),r.d(t,"readUint32",function(){return m}),r.d(t,"writeUint32",function(){return a}),r.d(t,"findBox",function(){return v}),r.d(t,"parseSegmentIndex",function(){return y}),r.d(t,"parseInitSegment",function(){return n}),r.d(t,"getStartDTS",function(){return o}),r.d(t,"getDuration",function(){return l}),r.d(t,"computeRawDurationFromSamples",function(){return b}),r.d(t,"offsetStartDTS",function(){return c}),r.d(t,"segmentValidRange",function(){return f}),r.d(t,"appendUint8Array",function(){return A});var i=r("./src/utils/typed-array.ts"),p=r("./src/loader/fragment.ts"),s=Math.pow(2,32)-1,d=[].push;function u(e){return String.fromCharCode.apply(null,e)}function h(e,t){"data"in e&&(t+=e.start,e=e.data);e=e[t]<<8|e[t+1];return e<0?65536+e:e}function m(e,t){"data"in e&&(t+=e.start,e=e.data);e=e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3];return e<0?4294967296+e:e}function a(e,t,r){"data"in e&&(t+=e.start,e=e.data),e[t]=r>>24,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r}function v(e,t){var r,i,n=[];if(!t.length)return n;for(var s=("data"in e?(r=e.data,i=e.start,e.end):(i=0,(r=e).byteLength)),a=i;a>>31)return console.warn("SIDX has hierarchical references (not supported)"),null;u=m(i,d);d+=4,r.push({referenceSize:c,subsegmentDuration:u,info:{duration:u/s,start:a,end:a+c-1}}),a+=c,n=d+=4}return{earliestPresentationTime:0,timescale:s,version:e,referencesCount:o,references:r,moovEndOffset:t}}function n(e){for(var r=[],t=v(e,["moov","trak"]),i=0;ie)&&(this.startTime=e),this.endTime=t,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)},r.reset=function(){this.cueRanges=[],this.startTime=null};var i=n;function n(e,t){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=e,this.trackName=t}},"./src/utils/texttrack-utils.ts":function(e,t,r){r.r(t),r.d(t,"sendAddTrackEvent",function(){return i}),r.d(t,"addCueToTrack",function(){return s}),r.d(t,"clearCurrentCues",function(){return a}),r.d(t,"removeCuesInRange",function(){return o}),r.d(t,"getCuesInRange",function(){return l});var n=r("./src/utils/logger.ts");function i(e,t){var r;try{r=new Event("addtrack")}catch(e){(r=document.createEvent("Event")).initEvent("addtrack",!1,!1)}r.track=e,t.dispatchEvent(r)}function s(e,t){var r=e.mode;if("disabled"===r&&(e.mode="hidden"),e.cues&&!e.cues.getCueById(t.id))try{if(e.addCue(t),!e.cues.getCueById(t.id))throw new Error("addCue is failed for: "+t)}catch(r){n.logger.debug("[texttrack-utils]: "+r);var i=new self.TextTrackCue(t.startTime,t.endTime,t.text);i.id=t.id,e.addCue(i)}"disabled"===r&&(e.mode=r)}function a(e){var t=e.mode;if("disabled"===t&&(e.mode="hidden"),e.cues)for(var r=e.cues.length;r--;)e.removeCue(e.cues[r]);"disabled"===t&&(e.mode=t)}function o(e,t,r){var i=e.mode;if("disabled"===i&&(e.mode="hidden"),e.cues&&0e[r].endTime)return-1;for(var i=0,n=r;i<=n;){var s=Math.floor((n+i)/2);if(te[s].startTime&&i=t&&o.endTime<=r)i.push(o);else if(o.startTime>r)return i}return i}},"./src/utils/time-ranges.ts":function(e,t,r){r.r(t),t.default={toString:function(e){for(var t="",r=e.length,i=0;i/gi,"\n")}(r=A.prototype).parse=function(e){var i=this;function t(){for(var e=0,t=f(t=i.buffer);e>>0).toString()};function w(e,t,r){return i(e.toString())+i(t.toString())+i(r)}function n(e,t,r,n,s,a,i,o){var l,d=new v.VTTParser,e=Object(y.utf8ArrayToStr)(new Uint8Array(e)).trim().replace(T,"\n").split("\n"),u=[],c=Object(b.toMpegTsClockFromTimescale)(t,r),h="00:00.000",f=0,A=0,g=!0,p=!1;d.oncue=function(e){var t=n[s],r=n.ccOffset,i=(f-c)/9e4,r=(null!=t&&t.new&&(void 0!==A?r=n.ccOffset=t.start:function(e,t){var r,i=e[s],n=e[i.prevCC];if(!n||!n.new&&i.new)return e.ccOffset=e.presentationOffset=i.start,i.new=!1;for(;null!=(r=n)&&r.new;)e.ccOffset+=i.start-n.start,i.new=!1,n=e[(i=n).prevCC];e.presentationOffset=t}(n,i)),i&&(r=i-n.presentationOffset),p&&(t=e.endTime-e.startTime,i=Object(E.normalizePts)(9e4*(e.startTime+r-A),9e4*a)/9e4,e.startTime=i,e.endTime=i+t),e.text.trim());e.text=decodeURIComponent(encodeURIComponent(r)),e.id||(e.id=w(e.startTime,e.endTime,r)),0=e.maxRetry||400<=t&&t<499?(o.logger.error(t+" while loading "+n.url),this.callbacks.onError({code:t,text:s.statusText},n,s)):(o.logger.warn(t+" while loading "+n.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,e.maxRetryDelay),a.retry++)):(self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),e.timeout))))},r.loadtimeout=function(){o.logger.warn("timeout while loading "+this.context.url);var e=this.callbacks;e&&(this.abortInternal(),e.onTimeout(this.stats,this.context,this.loader))},r.loadprogress=function(e){var t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)},r.getCacheAge=function(){var e,t=null;return t=this.loader&&n.test(this.loader.getAllResponseHeaders())?(e=this.loader.getResponseHeader("age"))?parseFloat(e):null:t},t.default=s}},i={},n.m=r,n.c=i,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/dist/",n(n.s="./src/hls.ts").default;function n(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,n),t.l=!0,t.exports}var r,i}())}))&&m.__esModule&&Object.prototype.hasOwnProperty.call(m,"default")?m.default:m;class Oe extends b{constructor(e){super(),(this.player=e)._opt,this.hls=new O({}),this._initHls(),this._bindEvents(),this.player.debug.log("HlsDecoder","init")}destroy(){this.hls.destroy(),this.hls=null,this.player.debug.log("HlsDecoder","destroy")}_initHls(){this.hls.attachMedia(this.player.video.$videoElement)}_bindEvents(){const t=this.player,e=this.player.events["proxy"],r=this.hls,i=t.video.$videoElement;this.hls.on(O.Events.ERROR,(e,t)=>{if(t.fatal)switch(t.type){case O.ErrorTypes.NETWORK_ERROR:console.log("fatal network error encountered, try to recover"),this.hls.startLoad();break;case O.ErrorTypes.MEDIA_ERROR:console.log("fatal media error encountered, try to recover"),this.hls.recoverMediaError()}}),e(i,"timeupdate",e=>{this.hls&&(e=parseInt(e.timeStamp,10),t.handleRender(),console.log("hls.liveSyncPosition",r.liveSyncPosition),t.updateStats({ts:e}),t.emit(u.kBps,(r.bandwidthEstimate/8/1024).toFixed(2)),t.emit(u.videoTimeUpdate,e))}),this.hls.on(O.Events.MEDIA_ATTACHING,()=>{console.log("MEDIA_ATTACHING")}),this.hls.on(O.Events.MEDIA_ATTACHED,()=>{console.log("MEDIA_ATTACHED")}),this.hls.on(O.Events.MEDIA_DETACHING,()=>{console.log("MEDIA_DETACHING")}),this.hls.on(O.Events.MEDIA_DETACHED,()=>{console.log("MEDIA_DETACHED")}),this.hls.on(O.Events.BUFFER_RESET,()=>{console.log("BUFFER_RESET")}),this.hls.on(O.Events.BUFFER_CODECS,()=>{console.log("BUFFER_CODECS")}),this.hls.on(O.Events.BUFFER_CREATED,()=>{console.log("BUFFER_CREATED")}),this.hls.on(O.Events.BUFFER_APPENDING,()=>{console.log("BUFFER_APPENDING")}),this.hls.on(O.Events.BUFFER_APPENDED,()=>{console.log("BUFFER_APPENDED")}),this.hls.on(O.Events.BUFFER_EOS,()=>{console.log("fired when the stream is finished and we want to notify the media buffer that there will be no more data")}),this.hls.on(O.Events.BUFFER_FLUSHING,()=>{console.log("fired when the media buffer should be flushed")}),this.hls.on(O.Events.BUFFER_FLUSHED,()=>{console.log("fired when the media buffer has been flushed")}),this.hls.on(O.Events.MANIFEST_LOADING,()=>{console.log("MANIFEST_LOADING 开始加载playlist m3u8资源")}),this.hls.on(O.Events.MANIFEST_LOADED,(e,t)=>{console.log("MANIFEST_LOADED playlist m3u8文件加载完成",t)}),this.hls.on(O.Events.MANIFEST_PARSED,()=>{console.log("MANIFEST_PARSED playlist m3u8解析完成"),t._times.demuxStart||(t._times.demuxStart=l())}),this.hls.on(O.Events.LEVEL_LOADING,()=>{console.log("LEVEL_LOADING 加载特定码率的m3u8文件")}),this.hls.on(O.Events.LEVEL_LOADED,(e,t)=>{console.log("LEVEL_LOADED 特定码率的m3u8文件解析完成,拿到该码率对应的ts列表")}),this.hls.on(O.Events.FRAG_LOADING,()=>{console.log("FRAG_LOADING 开始加载某个ts分片文件,开始根据ts片下载时间预估带宽")}),this.hls.on(O.Events.FRAG_LOADED,()=>{console.log("FRAG_LOADED ts分片文件加载成功,开始转码"),t._times.decodeStart||(t._times.decodeStart=l())}),this.hls.on(O.Events.BUFFER_APPENDING,()=>{console.log("BUFFER_APPENDING 视频流赋给video标签"),t._times.videoStart||(t._times.videoStart=l(),t.handlePlayToRenderTimes())}),this.hls.on(O.Events.FRAG_LOADED,()=>{console.log("FRAG_LOADED")}),this.hls.on(O.Events.FRAG_DECRYPTED,()=>{console.log(" fired when a fragment decryption is completed")}),this.hls.on(O.Events.KEY_LOADING,()=>{console.log(" fired when a decryption key loading starts")}),this.hls.on(O.Events.KEY_LOADING,()=>{console.log(" fired when a fragment decryption is completed")}),this.hls.on(O.Events.FPS_DROP,e=>{console.log("FPS_DROP",e)}),this.hls.on(O.Events.FPS_DROP_LEVEL_CAPPING,e=>{console.log("FPS_DROP_LEVEL_CAPPING",e)})}loadSource(r){return new Promise((e,t)=>{this.hls.on(O.Events.MEDIA_ATTACHED,()=>{this.hls.loadSource(r),e()})})}}class Be extends b{constructor(e){super(),this.player=e,this.rtcPeerConnection=null,this.videoStream=null,this._initRtcPeerConnection(),this.player.debug.log("WebrtcDecoder","init")}destroy(){this.rtcPeerConnection&&(this.rtcPeerConnection.close(),this.rtcPeerConnection=null),this.videoStream=null,this.player.video.$videoElement.srcObject=null,this.player.debug.log("WebrtcDecoder","destroy")}_initRtcPeerConnection(){const t=new RTCPeerConnection,r=this.player;t.addTransceiver("video",{direction:"recvonly"}),t.addTransceiver("audio",{direction:"recvonly"}),t.onsignalingstatechange=e=>{console.log("onsignalingstatechange",e)},t.oniceconnectionstatechange=e=>{console.log("oniceconnectionstatechange",t.iceConnectionState)},t.onicecandidate=e=>{console.log("onicecandidate",e)},t.ontrack=e=>{const t=r.video.$videoElement;console.log("ontrack",e),"video"===e.track.kind&&(e=e.streams[0],t.srcObject=e,this.videoStream=e)},t.onconnectionstatechange=e=>{r.debug.log("webrtcLoader","sdp connect status "+t.connectionState),t.connectionState},this.rtcPeerConnection=t}loadSource(n){return new Promise((t,r)=>{const i=this.rtcPeerConnection;i.createOffer().then(e=>{i.setLocalDescription(e),e=e.sdp,fetch(n,{method:"POST",mode:"cors",cache:"no-cache",credentials:"include",redirect:"follow",referrerPolicy:"no-referrer",headers:{"Content-Type":"application/sdp"},body:e}).then(e=>{e.text().then(e=>{this.player.debug.log("webrtcLoader","getWebRtcRemoteSdp response"),i.setRemoteDescription(new RTCSessionDescription({type:"answer",sdp:e})),t()}).catch(()=>{r()})}).catch(e=>{console.error(e),r(e)})}).catch(e=>{r(e)})})}}class _e extends b{constructor(e,t){super(),this.$container=e,this._opt=Object.assign({},M,t),this.debug=new ee(this),this._opt.isHls||this._opt.isWebrtc||(this._opt.useWCS&&(this._opt.useWCS="VideoEncoder"in window),this._opt.useMSE&&(this._opt.useMSE=window.MediaSource&&window.MediaSource.isTypeSupported(Q))),this._opt.useMSE?(this._opt.useWCS&&this.debug.log("Player","useWCS set true->false"),this._opt.forceNoOffscreen||this.debug.log("Player","forceNoOffscreen set false->true"),this._opt.useWCS=!1,this._opt.forceNoOffscreen=!0):this._opt.useWCS,this._opt.forceNoOffscreen||("undefined"==typeof OffscreenCanvas?(this._opt.forceNoOffscreen=!0,this._opt.useOffscreen=!1):this._opt.useOffscreen=!0),this._opt.hasAudio||(this._opt.operateBtns.audio=!1),this._opt.hasControl=this._hasControl(),this._loading=!1,this._playing=!1,this._hasLoaded=!1,this._checkHeartTimeout=null,this._checkLoadingTimeout=null,this._startBpsTime=null,this._isPlayingBeforePageHidden=!1,this._stats={buf:0,fps:0,abps:0,vbps:0,ts:0},this._times={playInitStart:"",playStart:"",streamStart:"",streamResponse:"",demuxStart:"",decodeStart:"",videoStart:"",playTimestamp:"",streamTimestamp:"",streamResponseTimestamp:"",demuxTimestamp:"",decodeTimestamp:"",videoTimestamp:"",allTimestamp:""},this._videoTimestamp=0,this._audioTimestamp=0,r=this,Object.defineProperty(r,"rect",{get:()=>{const e=r.$container.getBoundingClientRect();return e.width=Math.max(e.width,r.$container.clientWidth),e.height=Math.max(e.height,r.$container.clientHeight),e}}),["bottom","height","left","right","top","width"].forEach(e=>{Object.defineProperty(r,e,{get:()=>r.rect[e]})}),this.events=new te(this),this.video=new ne(this),this._opt.hasAudio&&(this.audio=new oe(this)),this.recorder=new pe(this),this._opt.isHls?(this.hls=new Oe(this),this.loaded=!0):this._opt.isWebrtc?(this.webrtc=new Be(this),this.loaded=!0):this._onlyMseOrWcsVideo()?this.loaded=!0:this.decoderWorker=new me(this),this.stream=null,this.demux=null,this._opt.useWCS&&(this.webcodecsDecoder=new we(this)),this._opt.useMSE&&(this.mseDecoder=new Le(this)),this.control=new De(this),this.keepScreenOn=new xe(this);var r,i=this;try{const s=()=>{i.emit(c.fullscreen,i.fullscreen),i.fullscreen&&!i._opt.useMSE||i.resize()};y.on("change",s),i.events.destroys.push(()=>{y.off("change",s)})}catch(i){}if(i.on(u.decoderWorkerInit,()=>{i.debug.log("player","has loaded"),i.loaded=!0}),i.on(u.play,()=>{i.loading=!1}),i.on(u.fullscreen,e=>{if(e)try{y.request(i.$container).then(()=>{}).catch(e=>{i.webFullscreen=!0})}catch(e){i.webFullscreen=!0}else try{y.exit().then(()=>{}).catch(()=>{i.webFullscreen=!1})}catch(e){i.webFullscreen=!1}}),i.on(u.webFullscreen,e=>{e?i.$container.classList.add("jessibuca-fullscreen-web"):i.$container.classList.remove("jessibuca-fullscreen-web")}),i.on(u.resize,()=>{i.video.resize()}),i._opt.debug){const a=[u.timeUpdate];Object.keys(u).forEach(t=>{i.on(u[t],e=>{a.includes(t)||i.debug.log("player events",u[t],e)})}),Object.keys(h).forEach(t=>{i.on(h[t],e=>{i.debug.log("player event error",h[t],e)})})}{var n=this;const{_opt:o,debug:l,events:{proxy:d}}=n;o.supportDblclickFullscreen&&d(n.$container,"dblclick",()=>{n.fullscreen=!n.fullscreen}),d(document,"visibilitychange",()=>{o.hiddenAutoPause&&(l.log("visibilitychange",document.visibilityState,n._isPlayingBeforePageHidden),"visible"===document.visibilityState?n._isPlayingBeforePageHidden&&n.play():(n._isPlayingBeforePageHidden=n.playing,n.playing&&n.pause()))}),d(window,"fullscreenchange",()=>{null!==n.keepScreenOn&&"visible"===document.visibilityState&&n.enableWakeLock()})}this._opt.useWCS&&this.debug.log("Player","use WCS"),this._opt.useMSE&&this.debug.log("Player","use MSE"),this._opt.useOffscreen&&this.debug.log("Player","use offscreen"),this._opt.isHls&&this.debug.log("Player","use hls"),this._opt.isWebrtc&&this.debug.log("Player","use webrtc"),this.debug.log("Player options",this._opt)}destroy(){this._loading=!1,this._playing=!1,this._hasLoaded=!1,this._times={playInitStart:"",playStart:"",streamStart:"",streamResponse:"",demuxStart:"",decodeStart:"",videoStart:"",playTimestamp:"",streamTimestamp:"",streamResponseTimestamp:"",demuxTimestamp:"",decodeTimestamp:"",videoTimestamp:"",allTimestamp:""},this.decoderWorker&&(this.decoderWorker.destroy(),this.decoderWorker=null),this.video&&(this.video.destroy(),this.video=null),this.audio&&(this.audio.destroy(),this.audio=null),this.stream&&(this.stream.destroy(),this.stream=null),this.recorder&&(this.recorder.destroy(),this.recorder=null),this.control&&(this.control.destroy(),this.control=null),this.webcodecsDecoder&&(this.webcodecsDecoder.destroy(),this.webcodecsDecoder=null),this.mseDecoder&&(this.mseDecoder.destroy(),this.mseDecoder=null),this.demux&&(this.demux.destroy(),this.demux=null),this.hls&&(this.hls.destroy(),this.hls=null),this.events&&(this.events.destroy(),this.events=null),this.clearCheckHeartTimeout(),this.clearCheckLoadingTimeout(),this.releaseWakeLock(),this.keepScreenOn=null,this.resetStats(),this._audioTimestamp=0,this._videoTimestamp=0,this.emit("destroy"),this.off(),this.debug.log("play","destroy end")}set fullscreen(e){f()?(this.emit(u.webFullscreen,e),setTimeout(()=>{this.updateOption({rotate:e?270:0}),this.resize()},10)):this.emit(u.fullscreen,e)}get fullscreen(){return document.isFullScreen||document.mozIsFullScreen||document.webkitIsFullScreen||this.webFullscreen}set webFullscreen(e){this.emit(u.webFullscreen,e)}get webFullscreen(){return this.$container.classList.contains("jessibuca-fullscreen-web")}set loaded(e){this._hasLoaded=e}get loaded(){return this._hasLoaded||this._opt.isHls||this._opt.isWebrtc}set playing(e){e&&(this.loading=!1),this.playing!==e&&(this._playing=e,this.emit(u.playing,e),this.emit(u.volumechange,this.volume),e?this.emit(u.play):this.emit(u.pause))}get playing(){return this._playing}get volume(){return this.audio&&this.audio.volume||0}set volume(e){this.audio&&this.audio.setVolume(e)}set loading(e){this.loading!==e&&(this._loading=e,this.emit(u.loading,this._loading))}get loading(){return this._loading}set recording(e){e?this.playing&&this.recorder.startRecord():this.recorder.stopRecordAndSave()}get recording(){return this.recorder&&this.recorder.recording}set audioTimestamp(e){null!==e&&(this._audioTimestamp=e)}get audioTimestamp(){return this._audioTimestamp}set videoTimestamp(e){null!==e&&(this._videoTimestamp=e,this._opt.useWCS||this._opt.useMSE||this.audioTimestamp&&this.videoTimestamp&&this.audio&&this.audio.emit(u.videoSyncAudio,{audioTimestamp:this.audioTimestamp,videoTimestamp:this.videoTimestamp,diff:this.audioTimestamp-this.videoTimestamp}))}get videoTimestamp(){return this._videoTimestamp}updateOption(e){this._opt=Object.assign({},this._opt,e)}init(){return new Promise((e,t)=>{this.stream||(this.stream=new fe(this)),this._opt.isHls?(this.hls||(this.hls=new Oe(this),this.loaded=!0),e()):this._opt.isWebrtc?(this.webrtc||(this.webrtc=new Be(this),this.loaded=!0),e()):(this.demux||(this.demux=new Se(this)),this._opt.useWCS&&!this.webcodecsDecoder&&(this.webcodecsDecoder=new we(this)),this._opt.useMSE&&!this.mseDecoder&&(this.mseDecoder=new Le(this)),this.decoderWorker||this._onlyMseOrWcsVideo()?e():(this.decoderWorker=new me(this),this.once(u.decoderWorkerInit,()=>{e()})))})}play(r){return new Promise((e,t)=>{if(!r&&!this._opt.url)return t();this.loading=!0,this.playing=!1,this._times.playInitStart=l(),r=r||this._opt.url,this._opt.url=r,this.clearCheckHeartTimeout(),this.init().then(()=>{this._times.playStart=l(),this._opt.isNotMute&&this.mute(!1),this.webcodecsDecoder&&this.webcodecsDecoder.once(h.webcodecsH265NotSupport,()=>{this.emit(h.webcodecsH265NotSupport),this._opt.autoWasm||this.emit(u.error,h.webcodecsH265NotSupport)}),this.mseDecoder&&this.mseDecoder.once(h.mediaSourceH265NotSupport,()=>{this.emit(h.mediaSourceH265NotSupport),this._opt.autoWasm||this.emit(u.error,h.mediaSourceH265NotSupport)}),this.enableWakeLock(),this.checkLoadingTimeout(),this.stream.once(h.fetchError,e=>{t(e)}),this.stream.once(h.websocketError,e=>{t(e)}),this.stream.once(h.hlsError,e=>{t(e)}),this.stream.once(u.streamSuccess,()=>{e(),this._times.streamResponse=l(),this.video.play()}),this.stream.fetchStream(r)}).catch(e=>{t(e)})})}close(){return new Promise((e,t)=>{this._close().then(()=>{this.video.clearView(),e()})})}_close(){return new Promise((e,t)=>{this.stream&&(this.stream.destroy(),this.stream=null),this.demux&&(this.demux.destroy(),this.demux=null),this.decoderWorker&&(this.decoderWorker.destroy(),this.decoderWorker=null),this.webcodecsDecoder&&(this.webcodecsDecoder.destroy(),this.webcodecsDecoder=null),this.mseDecoder&&(this.mseDecoder.destroy(),this.mseDecoder=null),this.hls&&(this.hls.destroy(),this.hls=null),this.webrtc&&(this.webrtc.destroy(),this.webrtc=null),this.clearCheckHeartTimeout(),this.clearCheckLoadingTimeout(),this.playing=!1,this.loading=!1,this.recording=!1,this.audio&&this.audio.pause(),this.video&&this.video.pause(),this.releaseWakeLock(),this.resetStats(),this._audioTimestamp=0,this._videoTimestamp=0,this._times={playInitStart:"",playStart:"",streamStart:"",streamResponse:"",demuxStart:"",decodeStart:"",videoStart:"",playTimestamp:"",streamTimestamp:"",streamResponseTimestamp:"",demuxTimestamp:"",decodeTimestamp:"",videoTimestamp:"",allTimestamp:""},setTimeout(()=>{e()},0)})}pause(e){return e?this.close():this._close()}mute(e){this.audio&&this.audio.mute(e)}resize(){this.video.resize()}startRecord(e,t){this.recording||(this.recorder.setFileName(e,t),this.recording=!0)}stopRecordAndSave(){this.recording&&(this.recording=!1)}_hasControl(){let e=!1,t=!1;return Object.keys(this._opt.operateBtns).forEach(e=>{this._opt.operateBtns[e]&&(t=!0)}),e=this._opt.showBandwidth||this._opt.text||t?!0:e}_onlyMseOrWcsVideo(){return!1===this._opt.hasAudio&&(this._opt.useMSE||this._opt.useWCS&&!this._opt.useOffscreen)}useWasmDecode(){return!1===this._opt.useMSE&&!1===this._opt.useWCS}canVideoTrackWritter(){var e=this._opt;return!e.isHls&&!e.isWebrtc&&(e.useWCS&&!e.useOffscreen&&e.wcsUseVideoRender||this.useWasmDecode())}checkHeart(){this.clearCheckHeartTimeout(),this.checkHeartTimeout()}checkHeartTimeout(){this._checkHeartTimeout=setTimeout(()=>{this.pause(!1).then(()=>{this.emit(u.timeout,u.delayTimeout),this.emit(u.delayTimeout)})},1e3*this._opt.heartTimeout)}clearCheckHeartTimeout(){this._checkHeartTimeout&&(clearTimeout(this._checkHeartTimeout),this._checkHeartTimeout=null)}checkLoadingTimeout(){this._checkLoadingTimeout=setTimeout(()=>{this.pause(!1).then(()=>{this.emit(u.timeout,u.loadingTimeout),this.emit(u.loadingTimeout)})},1e3*this._opt.loadingTimeout)}clearCheckLoadingTimeout(){this._checkLoadingTimeout&&(clearTimeout(this._checkLoadingTimeout),this._checkLoadingTimeout=null)}handleRender(){this.loading&&(this.emit(u.start),this.loading=!1,this.clearCheckLoadingTimeout()),this.playing||(this.playing=!0),this.checkHeart()}updateStats(e){e=e||{},this._startBpsTime||(this._startBpsTime=l()),o(e.ts)&&(this._stats.ts=e.ts),o(e.buf)&&(this._stats.buf=e.buf),e.fps&&(this._stats.fps+=1),e.abps&&(this._stats.abps+=e.abps),e.vbps&&(this._stats.vbps+=e.vbps);e=l();e-this._startBpsTime<1e3||(this.emit(u.stats,this._stats),this.emit(u.performance,function(e){let t=0;return 24<=e?t=2:15<=e&&(t=1),t}(this._stats.fps)),this._stats.fps=0,this._stats.abps=0,this._stats.vbps=0,this._startBpsTime=e)}resetStats(){this._startBpsTime=null,this._stats={buf:0,fps:0,abps:0,vbps:0,ts:0}}enableWakeLock(){this._opt.keepScreenOn&&this.keepScreenOn.enable()}releaseWakeLock(){this._opt.keepScreenOn&&this.keepScreenOn.disable()}handlePlayToRenderTimes(){const e=this._times;e.playTimestamp=e.playStart-e.playInitStart,e.streamTimestamp=e.streamStart-e.playStart,e.streamResponseTimestamp=e.streamResponse-e.streamStart,e.demuxTimestamp=e.demuxStart-e.streamResponse,e.decodeTimestamp=e.decodeStart-e.demuxStart,e.videoTimestamp=e.videoStart-e.decodeStart,e.allTimestamp=e.videoStart-e.playInitStart,this.emit(u.playToRenderTimes,e)}}class Fe extends b{constructor(e){super();let t=e,r=e.container;if(!(r="string"==typeof e.container?document.querySelector(e.container):r))throw new Error("Jessibuca need container option");r.classList.add("jessibuca-container"),delete t.container,o(t.videoBuffer)&&(t.videoBuffer=1e3*Number(t.videoBuffer)),o(t.timeout)&&(n(t.loadingTimeout)&&(t.loadingTimeout=t.timeout),n(t.heartTimeout)&&(t.heartTimeout=t.timeout)),this._opt=t,this.$container=r,this._loadingTimeoutReplayTimes=0,this._heartTimeoutReplayTimes=0,this.events=new te(this)}destroy(){this.events&&(this.events.destroy(),this.events=null),this.player&&(this.player.destroy(),this.player=null),this.$container=null,this._opt=null,this._loadingTimeoutReplayTimes=0,this._heartTimeoutReplayTimes=0,this.off()}_initPlayer(e,t){this.player=new _e(e,t),this._bindEvents()}_resetPlayer(){var e=0{this.player.on(c[t],e=>{this.emit(t,e)})})}setDebug(e){this.player.updateOption({isDebug:!!e})}mute(){this.player.mute(!0)}cancelMute(){this.player.mute(!1)}setVolume(e){this.player.volume=e}audioResume(){this.player.audio&&this.player.audio.audioEnabled(!0)}setTimeout(e){e=Number(e),this.player.updateOption({timeout:e,loadingTimeout:e,heartTimeout:e})}setScaleMode(e){let t={isFullResize:!1,isResize:!1};switch(e=Number(e)){case 0:t.isFullResize=!1,t.isResize=!1;break;case 1:t.isFullResize=!1,t.isResize=!0;break;case 2:t.isFullResize=!0,t.isResize=!0}this.player.updateOption(t),this.resize()}pause(){return this.player.pause()}close(){return this._opt.url="",this.player.close()}clearView(){this.player.video.clearView()}play(r){return new Promise((e,t)=>{if(!r&&!this._opt.url)return this.emit(u.error,h.playError),void t();if(r){if(!this._opt.url)return this._play(r);r===this._opt.url?this.player.playing?e():(this.clearView(),this.player.play(this._opt.url).then(()=>{e()}).catch(()=>{this.player.pause().then(()=>{t()})})):this.player.pause().then(()=>(this.clearView(),this._play(r))).catch(()=>{t()})}else this.player.play(this._opt.url).then(()=>{e()}).catch(()=>{this.player.pause().then(()=>{t()})})})}_play(l){return new Promise((e,t)=>{var r=0===(this._opt.url=l).indexOf("http"),i=0===l.indexOf("webrtc"),n=0===l.indexOf("wt"),s=!i&&-1!==l.indexOf(".m3u8"),a=!i&&-1!==l.indexOf(".flv"),o=r?s?3:2:n?5:i?4:1,r=r&&!s||a||this._opt.isFlv?d:s?"hls":i?"webrtc":n?P:"m7s";if(!o||!r)return t(`play protocol is ${o}, demuxType is `+r);this._initPlayer(this.$container,Object.assign(this._opt,{protocol:o,demuxType:r,isHls:s,isWebrtc:i})),this.player.once(h.mediaSourceH265NotSupport,()=>{this.close().then(()=>{this.player._opt.autoWasm&&(this.player.debug.log("Jessibuca","auto wasm [mse-> wasm] reset player and play"),this._resetPlayer({useMSE:!1}),this.play(l).then(()=>{this.player.debug.log("Jessibuca","auto wasm [mse-> wasm] reset player and play success")}).catch(()=>{this.player.debug.log("Jessibuca","auto wasm [mse-> wasm] reset player and play error")}))})}),this.player.once(h.webcodecsH265NotSupport,()=>{this.close().then(()=>{this.player._opt.autoWasm&&(this.player.debug.log("Jessibuca","auto wasm [wcs-> wasm] reset player and play"),this._resetPlayer({useWCS:!1}),this.play(l).then(()=>{this.player.debug.log("Jessibuca","auto wasm [wcs-> wasm] reset player and play success")}).catch(()=>{this.player.debug.log("Jessibuca","auto wasm [wcs-> wasm] reset player and play error")}))})}),this.player.once(h.wasmDecodeError,()=>{this.player._opt.wasmDecodeErrorReplay&&this.close().then(()=>{this.player.debug.log("Jessibuca","wasm decode error and reset player and play"),this._resetPlayer({useWCS:!1}),this.play(l).then(()=>{this.player.debug.log("Jessibuca","wasm decode error and reset player and play success")}).catch(()=>{this.player.debug.log("Jessibuca","wasm decode error and reset player and play error")})})}),this.player.once(u.delayTimeout,()=>{this.player._opt.heartTimeoutReplay&&this._heartTimeoutReplayTimes{this._heartTimeoutReplayTimes=0}).catch(()=>{}))}),this.player.once(u.loadingTimeout,()=>{this.player._opt.loadingTimeoutReplay&&this._loadingTimeoutReplayTimes{this._loadingTimeoutReplayTimes=0}).catch(()=>{}))}),this.hasLoaded()?this.player.play(l).then(()=>{e()}).catch(()=>{this.player.pause().then(()=>{t()})}):this.player.once(u.decoderWorkerInit,()=>{this.player.play(l).then(()=>{e()}).catch(()=>{this.player.pause().then(()=>{t()})})})})}resize(){this.player.resize()}setBufferTime(e){e=Number(e),this.player.updateOption({videoBuffer:1e3*e}),this.player.decoderWorker&&this.player.decoderWorker.updateWorkConfig({key:"videoBuffer",value:1e3*e})}setRotate(e){e=parseInt(e,10),this._opt.rotate!==e&&-1!==[0,90,270].indexOf(e)&&(this.player.updateOption({rotate:e}),this.resize())}hasLoaded(){return this.player.loaded}setKeepScreenOn(){this.player.updateOption({keepScreenOn:!0})}setFullscreen(e){e=!!e;this.player.fullscreen!==e&&(this.player.fullscreen=e)}screenshot(e,t,r,i){return this.player.video.screenshot(e,t,r,i)}startRecord(r,i){return new Promise((e,t)=>{this.player.playing?(this.player.startRecord(r,i),e()):t()})}stopRecordAndSave(){this.player.recording&&this.player.stopRecordAndSave()}isPlaying(){return this.player.playing}isMute(){return!this.player.audio||this.player.audio.isMute}isRecording(){return this.player.recorder.recording}}var Pe="http:"===window.location.protocol?"ws:":"wss:",B=window.location.hostname,Me=window.location.pathname.replace("/preview/",""),F=function(){var e=window.location.search,t={};if(-1!=e.indexOf("?"))for(var r=e.substr(1).split("&"),i=0;i'),new Fe({container:document.querySelector(".jessibuca-pro-wrap"),showBandwidth:!0,debug:"true"===F.debug}).play(e).then(()=>{console.log("play success")}).catch(e=>{console.error("play error",e)}))}}); + `),Object.defineProperty(i,"$poster",{value:r.$container.querySelector(".jessibuca-poster")}),Object.defineProperty(i,"$loading",{value:r.$container.querySelector(".jessibuca-loading")}),Object.defineProperty(i,"$play",{value:r.$container.querySelector(".jessibuca-play")}),Object.defineProperty(i,"$playBig",{value:r.$container.querySelector(".jessibuca-play-big")}),Object.defineProperty(i,"$pause",{value:r.$container.querySelector(".jessibuca-pause")}),Object.defineProperty(i,"$controls",{value:r.$container.querySelector(".jessibuca-controls")}),Object.defineProperty(i,"$fullscreen",{value:r.$container.querySelector(".jessibuca-fullscreen")}),Object.defineProperty(i,"$fullscreen",{value:r.$container.querySelector(".jessibuca-fullscreen")}),Object.defineProperty(i,"$volume",{value:r.$container.querySelector(".jessibuca-volume")}),Object.defineProperty(i,"$volumePanelWrap",{value:r.$container.querySelector(".jessibuca-volume-panel-wrap")}),Object.defineProperty(i,"$volumePanelText",{value:r.$container.querySelector(".jessibuca-volume-panel-text")}),Object.defineProperty(i,"$volumePanel",{value:r.$container.querySelector(".jessibuca-volume-panel")}),Object.defineProperty(i,"$volumeHandle",{value:r.$container.querySelector(".jessibuca-volume-panel-handle")}),Object.defineProperty(i,"$volumeOn",{value:r.$container.querySelector(".jessibuca-icon-audio")}),Object.defineProperty(i,"$volumeOff",{value:r.$container.querySelector(".jessibuca-icon-mute")}),Object.defineProperty(i,"$fullscreen",{value:r.$container.querySelector(".jessibuca-fullscreen")}),Object.defineProperty(i,"$fullscreenExit",{value:r.$container.querySelector(".jessibuca-fullscreen-exit")}),Object.defineProperty(i,"$record",{value:r.$container.querySelector(".jessibuca-record")}),Object.defineProperty(i,"$recordStop",{value:r.$container.querySelector(".jessibuca-record-stop")}),Object.defineProperty(i,"$screenshot",{value:r.$container.querySelector(".jessibuca-screenshot")}),Object.defineProperty(i,"$speed",{value:r.$container.querySelector(".jessibuca-speed")}),Re(e,this),t=this,Object.defineProperty(t,"controlsRect",{get:()=>t.$controls.getBoundingClientRect()});{var a=e,o=this;const h=a["events"]["proxy"];function l(e){var{bottom:t,height:r}=o.$volumePanel.getBoundingClientRect(),i=o.$volumeHandle.getBoundingClientRect()["height"];return g(t-e.y-i/2,0,r-i/2)/(r-i)}h(window,["click","contextmenu"],e=>{-1{setTimeout(()=>{a.resize()},300)}),h(o.$controls,"click",e=>{e.stopPropagation()}),h(o.$pause,"click",e=>{a.pause()}),h(o.$play,"click",e=>{a.play()}),h(o.$playBig,"click",e=>{a.play()}),h(o.$volume,"mouseover",()=>{o.$volumePanelWrap.classList.add("jessibuca-volume-panel-wrap-show")}),h(o.$volume,"mouseout",()=>{o.$volumePanelWrap.classList.remove("jessibuca-volume-panel-wrap-show")}),h(o.$volumeOn,"click",e=>{e.stopPropagation(),p(o.$volumeOn,"display","none"),p(o.$volumeOff,"display","block"),a.lastVolume=a.volume,a.volume=0}),h(o.$volumeOff,"click",e=>{e.stopPropagation(),p(o.$volumeOn,"display","block"),p(o.$volumeOff,"display","none"),a.volume=a.lastVolume||.5}),h(o.$screenshot,"click",e=>{e.stopPropagation(),a.video.screenshot()}),h(o.$volumePanel,"click",e=>{e.stopPropagation(),a.volume=l(e)}),h(o.$volumeHandle,"mousedown",()=>{o.isVolumeDroging=!0}),h(o.$volumeHandle,"mousemove",e=>{o.isVolumeDroging&&(a.volume=l(e))}),h(document,"mouseup",()=>{o.isVolumeDroging&&(o.isVolumeDroging=!1)}),h(o.$record,"click",e=>{e.stopPropagation(),a.recording=!0}),h(o.$recordStop,"click",e=>{e.stopPropagation(),a.recording=!1}),h(o.$fullscreen,"click",e=>{e.stopPropagation(),a.fullscreen=!0}),h(o.$fullscreenExit,"click",e=>{e.stopPropagation(),a.fullscreen=!1}),a._opt.hasControl&&a._opt.controlAutoHide&&(h(a.$container,"mouseover",()=>{a.fullscreen||p(o.$controls,"display","block")}),h(a.$container,"mouseout",()=>{p(o.$controls,"display","none")}))}if(e._opt.hotKey){var d=e,u=this;const f=d["events"]["proxy"],A={};function c(e,t){A[e]?A[e].push(t):A[e]=[t]}c(27,()=>{d.fullscreen&&(d.fullscreen=!1)}),c(38,()=>{d.volume+=.05}),c(40,()=>{d.volume-=.05}),f(window,"keydown",e=>{if(u.isFocus){const u=document.activeElement.tagName.toUpperCase(),t=document.activeElement.getAttribute("contenteditable");if("INPUT"!==u&&"TEXTAREA"!==u&&""!==t&&"true"!==t){const u=A[e.keyCode];u&&(e.preventDefault(),u.forEach(e=>e()))}}})}this.player.debug.log("Control","init")}destroy(){this.$poster&&this.player.$container.removeChild(this.$poster),this.$loading&&this.player.$container.removeChild(this.$loading),this.$controls&&this.player.$container.removeChild(this.$controls),this.$playBig&&this.player.$container.removeChild(this.$playBig),this.player.debug.log("control","destroy")}autoSize(){const e=this.player,t=(e.$container.style.padding="0 0",e.width),r=e.height,i=t/r,n=e.video.$videoElement.width/e.video.$videoElement.height;if(i>n){const i=(t-r*n)/2;e.$container.style.padding=`0 ${i}px`}else{const i=(r-t/n)/2;e.$container.style.padding=i+"px 0"}}}A(".jessibuca-container{position:relative;width:100%;height:100%;overflow:hidden}.jessibuca-container.jessibuca-fullscreen-web{position:fixed;z-index:9999;left:0;top:0;right:0;bottom:0;width:100vw!important;height:100vh!important;background:#000}");class L{static init(){for(var e in L.types={avc1:[],avcC:[],hvc1:[],hvcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},L.types)L.types.hasOwnProperty(e)&&(L.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);let t=L.constants={};t.FTYP=new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]),t.STSD_PREFIX=new Uint8Array([0,0,0,0,0,0,0,1]),t.STTS=new Uint8Array([0,0,0,0,0,0,0,0]),t.STSC=t.STCO=t.STTS,t.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),t.HDLR_VIDEO=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),t.HDLR_AUDIO=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]),t.DREF=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),t.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),t.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])}static box(e){let t=8,r=null,i=Array.prototype.slice.call(arguments,1),n=i.length;for(let e=0;e>>24&255,r[1]=t>>>16&255,r[2]=t>>>8&255,r[3]=255&t,r.set(e,4);let s=8;for(let e=0;e>>24&255,e>>>16&255,e>>>8&255,255&e,t>>>24&255,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]))}static trak(e){return L.box(L.types.trak,L.tkhd(e),L.mdia(e))}static tkhd(e){var t=e.id,r=e.duration,i=e.presentWidth,e=e.presentHeight;return L.box(L.types.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t,0,0,0,0,r>>>24&255,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]))}static mdia(e){return L.box(L.types.mdia,L.mdhd(e),L.hdlr(e),L.minf(e))}static mdhd(e){var t=e.timescale,e=e.duration;return L.box(L.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t,e>>>24&255,e>>>16&255,e>>>8&255,255&e,85,196,0,0]))}static hdlr(e){e="audio"===e.type?L.constants.HDLR_AUDIO:L.constants.HDLR_VIDEO;return L.box(L.types.hdlr,e)}static minf(e){var t="audio"===e.type?L.box(L.types.smhd,L.constants.SMHD):L.box(L.types.vmhd,L.constants.VMHD);return L.box(L.types.minf,t,L.dinf(),L.stbl(e))}static dinf(){return L.box(L.types.dinf,L.box(L.types.dref,L.constants.DREF))}static stbl(e){return L.box(L.types.stbl,L.stsd(e),L.box(L.types.stts,L.constants.STTS),L.box(L.types.stsc,L.constants.STSC),L.box(L.types.stsz,L.constants.STSZ),L.box(L.types.stco,L.constants.STCO))}static stsd(e){return"audio"===e.type?L.box(L.types.stsd,L.constants.STSD_PREFIX,L.mp4a(e)):"avc"===e.videoType?L.box(L.types.stsd,L.constants.STSD_PREFIX,L.avc1(e)):L.box(L.types.stsd,L.constants.STSD_PREFIX,L.hvc1(e))}static mp4a(e){var t=e.channelCount,r=e.audioSampleRate,t=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t,0,16,0,0,0,0,r>>>8&255,255&r,0,0]);return L.box(L.types.mp4a,t,L.esds(e))}static esds(e){var e=e.config||[],t=e.length,t=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).concat([6,1,2]));return L.box(L.types.esds,t)}static avc1(e){var t=e.avcc,r=e.codecWidth,e=e.codecHeight,r=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,r>>>8&255,255&r,e>>>8&255,255&e,0,72,0,0,0,72,0,0,0,0,0,0,0,1,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,0,0,0,0,0,0,24,255,255]);return L.box(L.types.avc1,r,L.box(L.types.avcC,t))}static hvc1(e){var t=e.avcc,r=e.codecWidth,e=e.codecHeight,r=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,r>>>8&255,255&r,e>>>8&255,255&e,0,72,0,0,0,72,0,0,0,0,0,0,0,1,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,0,0,0,0,0,0,24,255,255]);return L.box(L.types.hvc1,r,L.box(L.types.hvcC,t))}static mvex(e){return L.box(L.types.mvex,L.trex(e))}static trex(e){e=e.id,e=new Uint8Array([0,0,0,0,e>>>24&255,e>>>16&255,e>>>8&255,255&e,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return L.box(L.types.trex,e)}static moof(e,t){return L.box(L.types.moof,L.mfhd(e.sequenceNumber),L.traf(e,t))}static mfhd(e){e=new Uint8Array([0,0,0,0,e>>>24&255,e>>>16&255,e>>>8&255,255&e]);return L.box(L.types.mfhd,e)}static traf(e,t){var r=e.id,r=L.box(L.types.tfhd,new Uint8Array([0,0,0,0,r>>>24&255,r>>>16&255,r>>>8&255,255&r])),t=L.box(L.types.tfdt,new Uint8Array([0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t])),i=L.sdtp(e),e=L.trun(e,i.byteLength+16+16+8+16+8+8);return L.box(L.types.traf,r,t,e,i)}static sdtp(e){let t=new Uint8Array(5),r=e.flags;return t[4]=r.isLeading<<6|r.dependsOn<<4|r.isDependedOn<<2|r.hasRedundancy,L.box(L.types.sdtp,t)}static trun(e,t){let r=new Uint8Array(28);t+=36,r.set([0,0,15,1,0,0,0,1,t>>>24&255,t>>>16&255,t>>>8&255,255&t],0);var t=e.duration,i=e.size,n=e.flags,e=e.cts;return r.set([t>>>24&255,t>>>16&255,t>>>8&255,255&t,i>>>24&255,i>>>16&255,i>>>8&255,255&i,n.isLeading<<2|n.dependsOn,n.isDependedOn<<6|n.hasRedundancy<<4|n.isNonSync,0,0,e>>>24&255,e>>>16&255,e>>>8&255,255&e],12),L.box(L.types.trun,r)}static mdat(e){return L.box(L.types.mdat,e)}}L.init();class ke{constructor(e){this.TAG="ExpGolomb",this._buffer=e,this._buffer_index=0,this._total_bytes=e.byteLength,this._total_bits=8*e.byteLength,this._current_word=0,this._current_word_bits_left=0}destroy(){this._buffer=null}_fillCurrentWord(){let e=this._total_bytes-this._buffer_index,t=Math.min(4,e),r=new Uint8Array(4);r.set(this._buffer.subarray(this._buffer_index,this._buffer_index+t)),this._current_word=new DataView(r.buffer).getUint32(0,!1),this._buffer_index+=t,this._current_word_bits_left=8*t}readBits(e){if(e<=this._current_word_bits_left)return t=this._current_word>>>32-e,this._current_word<<=e,this._current_word_bits_left-=e,t;var t=this._current_word_bits_left?this._current_word:0,e=(t>>>=32-this._current_word_bits_left,e-this._current_word_bits_left),e=(this._fillCurrentWord(),Math.min(e,this._current_word_bits_left)),r=this._current_word>>>32-e;return this._current_word<<=e,this._current_word_bits_left-=e,t<>>e))return this._current_word<<=e,this._current_word_bits_left-=e,e;return this._fillCurrentWord(),e+this._skipLeadingZero()}readUEG(){var e=this._skipLeadingZero();return this.readBits(e+1)-1}readSEG(){var e=this.readUEG();return 1&e?e+1>>>1:-1*(e>>>1)}}class I{static _ebsp2rbsp(e){let t=e,r=t.byteLength,i=new Uint8Array(r),n=0;for(let e=0;e{this.mediaSourceOpen=!0,this.player.emit(u.mseSourceOpen)}),t(this.mediaSource,"sourceclose",()=>{this.player.emit(u.mseSourceClose)}),e.debug.log("MediaSource","init")}destroy(){this.stop(),this.bufferList=[],this.mediaSource=null,this.mediaSourceOpen=!1,this.sourceBuffer=null,this.hasInit=!1,this.isInitInfo=!1,this.sequenceNumber=0,this.cacheTrack=null,this.timeInit=!1,this.off(),this.player.debug.log("MediaSource","destroy")}get state(){return this.mediaSource.readyState}get isStateOpen(){return"open"===this.state}get isStateClosed(){return"closed"===this.state}get isStateEnded(){return"ended"===this.state}get duration(){return this.mediaSource.duration}set duration(e){this.mediaSource.duration=e}decodeVideo(e,t,r){const i=this.player;var n;this.hasInit?this._decodeVideo(e,t,r):r&&0===e[1]&&(n=15&e[0],i.video.updateVideoInfo({encTypeCode:n}),12==n?this.emit(h.mediaSourceH265NotSupport):(i._times.decodeStart||(i._times.decodeStart=l()),this._decodeConfigurationRecord(e,t,r,n),this.hasInit=!0))}_doDecode(){var e=this.bufferList.shift();e&&this._decodeVideo(e.payload,e.ts,e.isIframe)}_decodeConfigurationRecord(e,t,r,i){let n=e.slice(5),s={};7===i?s=function(i){const n={},s=new DataView(i.buffer);var e=s.getUint8(0),t=s.getUint8(1);if(s.getUint8(2),s.getUint8(3),1===e&&0!==t){e=1+(3&s.getUint8(4));if(3==e||4==e){var a=31&s.getUint8(5);if(0!=a){let r=6;for(let t=0;tthis.cacheTrack.dts){let e=8+this.cacheTrack.size,t=new Uint8Array(e),r=(t[0]=e>>>24&255,t[1]=e>>>16&255,t[2]=e>>>8&255,t[3]=255&e,t.set(L.types.mdat,4),t.set(this.cacheTrack.data,8),this.cacheTrack.duration=a-this.cacheTrack.dts,L.moof(this.cacheTrack,this.cacheTrack.dts)),i=new Uint8Array(r.byteLength+t.byteLength);i.set(r,0),i.set(t,r.byteLength),this.appendBuffer(i.buffer),s.handleRender(),s.updateStats({fps:!0,ts:n,buf:s.demux.delay}),s._times.videoStart||(s._times.videoStart=l(),s.handlePlayToRenderTimes())}else s.debug.log("MediaSource","timeInit set false , cacheTrack = {}"),this.timeInit=!1,this.cacheTrack={};this.cacheTrack.id=1,this.cacheTrack.sequenceNumber=++this.sequenceNumber,this.cacheTrack.size=r,this.cacheTrack.dts=a,this.cacheTrack.cts=0,this.cacheTrack.isKeyframe=t,this.cacheTrack.data=e,this.cacheTrack.flags={isLeading:0,dependsOn:t?2:1,isDependedOn:t?1:0,hasRedundancy:0,isNonSync:t?0:1},this.timeInit||1!==i.buffered.length||(s.debug.log("MediaSource","timeInit set true"),this.timeInit=!0,i.currentTime=i.buffered.end(0)),!this.isInitInfo&&0{this.player.emit(u.mseSourceBufferError,e)})),!1===this.sourceBuffer.updating&&this.isStateOpen?this.sourceBuffer.appendBuffer(e):this.isStateClosed?this.player.emit(u.mseSourceBufferError,"mediaSource is not attached to video or mediaSource is closed"):this.isStateEnded?this.player.emit(u.mseSourceBufferError,"mediaSource is closed"):!0===this.sourceBuffer.updating&&this.player.emit(u.mseSourceBufferBusy)}stop(){this.isStateOpen&&this.sourceBuffer&&this.sourceBuffer.abort(),this.endOfStream()}dropSourceBuffer(e){const t=this.player.video.$videoElement;this.dropping=e,0"undefined"!=typeof navigator&&parseFloat((""+(/CPU.*OS ([0-9_]{3,4})[0-9_]{0,1}|(CPU like).*AppleWebKit.*Mobile/i.exec(navigator.userAgent)||[0,""])[1]).replace("undefined","3_2").replace("_",".").replace("_",""))<10&&!window.MSStream,xe=()=>"wakeLock"in navigator;class Oe{constructor(e){if(this.player=e,this.enabled=!1,xe()){this._wakeLock=null;const e=()=>{null!==this._wakeLock&&"visible"===document.visibilityState&&this.enable()};document.addEventListener("visibilitychange",e),document.addEventListener("fullscreenchange",e)}else Ie()?this.noSleepTimer=null:(this.noSleepVideo=document.createElement("video"),this.noSleepVideo.setAttribute("title","No Sleep"),this.noSleepVideo.setAttribute("playsinline",""),this._addSourceToVideo(this.noSleepVideo,"webm","data:video/webm;base64,GkXfowEAAAAAAAAfQoaBAUL3gQFC8oEEQvOBCEKChHdlYm1Ch4EEQoWBAhhTgGcBAAAAAAAVkhFNm3RALE27i1OrhBVJqWZTrIHfTbuMU6uEFlSua1OsggEwTbuMU6uEHFO7a1OsghV17AEAAAAAAACkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmAQAAAAAAAEUq17GDD0JATYCNTGF2ZjU1LjMzLjEwMFdBjUxhdmY1NS4zMy4xMDBzpJBlrrXf3DCDVB8KcgbMpcr+RImIQJBgAAAAAAAWVK5rAQAAAAAAD++uAQAAAAAAADLXgQFzxYEBnIEAIrWcg3VuZIaFVl9WUDiDgQEj44OEAmJaAOABAAAAAAAABrCBsLqBkK4BAAAAAAAPq9eBAnPFgQKcgQAitZyDdW5khohBX1ZPUkJJU4OBAuEBAAAAAAAAEZ+BArWIQ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AABAAAABwAAAAIAAAABAAAACAAAAAEAAAABAAAACQAAAAIAAAABAAAACgAAAAEAAAABAAAACwAAAAIAAAABAAAADQAAAAEAAAABAAAADgAAAAIAAAABAAAADwAAAAEAAAABAAAAEAAAAAIAAAABAAAAEQAAAAEAAAABAAAAEgAAAAIAAAABAAAAFAAAAAEAAAABAAAAFQAAAAIAAAABAAAAFgAAAAEAAAABAAAAFwAAAAIAAAABAAAAGAAAAAEAAAABAAAAGQAAAAIAAAABAAAAGgAAAAEAAAABAAAAGwAAAAIAAAABAAAAHQAAAAEAAAABAAAAHgAAAAIAAAABAAAAHwAAAAQAAAABAAAA4HN0c3oAAAAAAAAAAAAAADMAAAAaAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAACMc3RjbwAAAAAAAAAfAAAALAAAA1UAAANyAAADhgAAA6IAAAO+AAAD0QAAA+0AAAQAAAAEHAAABC8AAARLAAAEZwAABHoAAASWAAAEqQAABMUAAATYAAAE9AAABRAAAAUjAAAFPwAABVIAAAVuAAAFgQAABZ0AAAWwAAAFzAAABegAAAX7AAAGFwAAAGJ1ZHRhAAAAWm1ldGEAAAAAAAAAIWhkbHIAAAAAAAAAAG1kaXJhcHBsAAAAAAAAAAAAAAAALWlsc3QAAAAlqXRvbwAAAB1kYXRhAAAAAQAAAABMYXZmNTUuMzMuMTAw"),this.noSleepVideo.addEventListener("loadedmetadata",()=>{this.noSleepVideo.duration<=1?this.noSleepVideo.setAttribute("loop",""):this.noSleepVideo.addEventListener("timeupdate",()=>{.5{this._wakeLock=e,this.enabled=!0,t.log("wakeLock","Wake Lock active."),this._wakeLock.addEventListener("release",()=>{t.log("wakeLock","Wake Lock released.")})}).catch(e=>{throw this.enabled=!1,t.error("wakeLock",e.name+", "+e.message),e}):Ie()?(this.disable(),this.noSleepTimer=window.setInterval(()=>{document.hidden||(window.location.href=window.location.href.split("#")[0],window.setTimeout(window.stop,0))},15e3),this.enabled=!0,Promise.resolve()):this.noSleepVideo.play().then(e=>(this.enabled=!0,e)).catch(e=>{throw this.enabled=!1,e})}disable(){const e=this.player.debug;xe()?(this._wakeLock&&this._wakeLock.release(),this._wakeLock=null):Ie()?this.noSleepTimer&&(e.warn("wakeLock","NoSleep now disabled for older iOS devices."),window.clearInterval(this.noSleepTimer),this.noSleepTimer=null):this.noSleepVideo.pause(),this.enabled=!1}}var x=(m=v(function(e,t){"undefined"!=typeof window&&(e.exports=function(){return r={"./node_modules/eventemitter3/index.js":function(e,t,r){var i=Object.prototype.hasOwnProperty,f="~";function n(){}function s(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function a(e,t,r,i,n){if("function"!=typeof r)throw new TypeError("The listener must be a function");r=new s(r,i||e,n),i=f?f+t:t;return e._events[i]?e._events[i].fn?e._events[i]=[e._events[i],r]:e._events[i].push(r):(e._events[i]=r,e._eventsCount++),e}function l(e,t){0==--e._eventsCount?e._events=new n:delete e._events[t]}function o(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(f=!1)),o.prototype.eventNames=function(){var e,t,r=[];if(0===this._eventsCount)return r;for(t in e=this._events)i.call(e,t)&&r.push(f?t.slice(1):t);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(e)):r},o.prototype.listeners=function(e){var e=f?f+e:e,t=this._events[e];if(!t)return[];if(t.fn)return[t.fn];for(var r=0,i=t.length,n=new Array(i);rs||t.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),r.currentTime=s+.05)),this.getNextFragment(i,n));a?"identity"!==(null==(e=a.decryptdata)?void 0:e.keyFormat)||null!=(t=a.decryptdata)&&t.key?this.loadFragment(a,n,i):this.loadKey(a,n):this.bufferFlushed=!0}}}}},E.getMaxBufferLength=function(){var e=b.prototype.getMaxBufferLength.call(this),t=this.getFwdBufferInfo(this.videoBuffer||this.media,u.PlaylistLevelType.MAIN);return null===t?e:Math.max(e,t.len)},E.onMediaDetaching=function(){this.videoBuffer=null,b.prototype.onMediaDetaching.call(this)},E.onAudioTracksUpdated=function(e,t){t=t.audioTracks;this.resetTransmuxer(),this.levels=t.map(function(e){return new i.Level(e)})},E.onAudioTrackSwitching=function(e,t){var r=!!t.url,t=(this.trackId=t.id,this.fragCurrent);null!=t&&t.loader&&t.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),r?this.setInterval(100):this.resetTransmuxer(),r?(this.audioSwitch=!0,this.state=h.State.IDLE):this.state=h.State.STOPPED,this.tick()},E.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},E.onLevelLoaded=function(e,t){this.mainDetails=t.details},E.onAudioTrackLoaded=function(e,t){var r=this.levels,i=t.details,t=t.id;if(r){this.log("Track "+t+" loaded ["+i.startSN+","+i.endSN+"],duration:"+i.totalduration);var r=r[t],n=0;if(i.live||null!=(s=r.details)&&s.live){var s=this.mainDetails;if(i.fragments[0]||(i.deltaUpdateFailed=!0),i.deltaUpdateFailed||!s)return;n=!r.details&&i.hasProgramDateTime&&s.hasProgramDateTime?(Object(l.alignMediaPlaylistByPDT)(i,s),i.fragments[0].start):this.alignPlaylists(i,r.details)}r.details=i,this.levelLastLoaded=t,this.startFragRequested||!this.mainDetails&&i.live||this.setStartPosition(r.details,n),this.state!==h.State.WAITING_TRACK||this.waitForCdnTuneIn(i)||(this.state=h.State.IDLE),this.tick()}else this.warn("Audio tracks were reset while loading level "+t)},E._handleFragmentLoadProgress=function(e){var t,r,i,n,s=e.frag,a=e.part,e=e.payload,o=this.config,l=this.trackId,d=this.levels;d?(d=d[l],console.assert(d,"Audio track is defined on fragment load progress"),t=d.details,console.assert(t,"Audio track details are defined on fragment load progress"),o=o.defaultAudioCodec||d.audioCodec||"mp4a.40.2",d=(d=this.transmuxer)||(this.transmuxer=new g.default(this.hls,u.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this))),r=this.initPTS[s.cc],i=null==(i=s.initSegment)?void 0:i.data,void 0!==r?(n=a?a.index:-1,n=new p.ChunkMetadata(s.level,s.sn,s.stats.chunkCount,e.byteLength,n,-1!==n),d.push(e,i,o,"",s,a,t.totalduration,!1,n,r)):(m.logger.log("Unknown video PTS for cc "+s.cc+", waiting for video PTS before demuxing audio frag "+s.sn+" of ["+t.startSN+" ,"+t.endSN+"],track "+l),(this.waitingData=this.waitingData||{frag:s,part:a,cache:new c.default,complete:!1}).cache.push(new Uint8Array(e)),this.waitingVideoCC=this.videoTrackCC,this.state=h.State.WAITING_INIT_PTS)):this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+s.sn+" of level "+s.level+" will not be buffered")},E._handleFragmentLoadComplete=function(e){this.waitingData?this.waitingData.complete=!0:b.prototype._handleFragmentLoadComplete.call(this,e)},E.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},E.onBufferCreated=function(e,t){var r=t.tracks.audio;r&&(this.mediaBuffer=r.buffer),t.tracks.video&&(this.videoBuffer=t.tracks.video.buffer)},E.onFragBuffered=function(e,t){var r=t.frag,t=t.part;r.type===u.PlaylistLevelType.AUDIO&&(this.fragContextChanged(r)?this.warn("Fragment "+r.sn+(t?" p: "+t.index:"")+" of level "+r.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch):("initSegment"!==r.sn&&(this.fragPrevious=r,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(f.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(r,t)))},E.onError=function(e,t){switch(t.details){case d.ErrorDetails.FRAG_LOAD_ERROR:case d.ErrorDetails.FRAG_LOAD_TIMEOUT:case d.ErrorDetails.KEY_LOAD_ERROR:case d.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(u.PlaylistLevelType.AUDIO,t);break;case d.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case d.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==h.State.ERROR&&this.state!==h.State.STOPPED&&(this.state=t.fatal?h.State.ERROR:h.State.IDLE,this.warn(t.details+" while loading frag, switching to "+this.state+" state"));break;case d.ErrorDetails.BUFFER_FULL_ERROR:var r,i;"audio"!==t.parent||this.state!==h.State.PARSING&&this.state!==h.State.PARSED||(r=!0,(r=(i=this.getFwdBufferInfo(this.mediaBuffer,u.PlaylistLevelType.AUDIO))&&.5=o.length?this.warn("Invalid id passed to audio-track controller"):(this.clearTimer(),t=o[this.trackId],this.log("Now switching to audio-track index "+e),r=(o=o[e]).id,i=void 0===(i=o.groupId)?"":i,n=o.name,s=o.type,a=o.url,this.trackId=e,this.trackName=n,this.selectDefaultTrack=!1,this.hls.trigger(l.Events.AUDIO_TRACK_SWITCHING,{id:r,groupId:i,name:n,type:s,url:a}),o.details&&!o.details.live||(e=this.switchParams(o.url,null==t?void 0:t.details),this.loadPlaylist(e)))},n.selectInitialTrack=function(){var e=this.tracksInGroup,e=(console.assert(e.length,"Initial audio track should be selected when tracks are known"),this.trackName),e=this.findTrackId(e)||this.findTrackId();-1!==e?this.setAudioTrack(e):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(l.Events.ERROR,{type:i.ErrorTypes.MEDIA_ERROR,details:i.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},n.findTrackId=function(e){for(var t=this.tracksInGroup,r=0;rt.partTarget&&(n+=1)),Object(o.isFiniteNumber)(s))return new l.HlsUrlParameters(s,Object(o.isFiniteNumber)(n)?n:void 0,l.HlsSkip.No)}}},t.loadPlaylist=function(e){},t.shouldLoadTrack=function(e){return this.canLoad&&e&&!!e.url&&(!e.details||e.details.live)},t.playlistLoaded=function(e,t,r){var i=this,n=t.details,s=t.stats,a=s.loading.end?Math.max(0,self.performance.now()-s.loading.end):0;if(n.advancedDateTime=Date.now()-a,n.live||null!=r&&r.live){if(n.reloaded(r),r&&this.log("live playlist "+e+" "+(n.advanced?"REFRESHED "+n.lastPartSn+"-"+n.lastPartIndex:"MISSED")),r&&0r.tuneInGoal?(this.warn("CDN Tune-in goal increased from: "+r.tuneInGoal+" to: "+c+" with playlist age: "+n.age),c=0):(a+=h=Math.floor(c/n.targetduration),void 0!==l&&(l+=Math.round(c%n.targetduration/n.partTarget)),this.log("CDN Tune-in age: "+n.ageHeader+"s last advanced "+u.toFixed(2)+"s goal: "+c+" skip sn "+h+" to part "+l)),n.tuneInGoal=c),o=this.getDeliveryDirectives(n,t.deliveryDirectives,a,l),d||!f)return void this.loadPlaylist(o)}else o=this.getDeliveryDirectives(n,t.deliveryDirectives,a,l);r=Object(A.computeReloadInterval)(n,s);void 0!==a&&n.canBlockReload&&(r-=n.partTarget||1),this.log("reload live playlist "+e+" in "+Math.round(r)+" ms"),this.timer=self.setTimeout(function(){return i.loadPlaylist(o)},r)}}else this.clearTimer()},t.getDeliveryDirectives=function(e,t,r,i){var n=Object(l.getSkipValue)(e,r);return null!=t&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,i=t.part,n=l.HlsSkip.No),new l.HlsUrlParameters(r,i,n)},t.retryLoadingOrFail=function(e){var t,r=this,i=this.hls.config,n=this.retryCount=t.endSN&&!e.nextStart){e=t.partList;if(null!=e&&e.length)return t=e[e.length-1],a.BufferHelper.isBuffered(this.media,t.start+t.duration/2);e=i.getState(r);return e===c.FragmentState.PARTIAL||e===c.FragmentState.OK}return!1},t.onMediaAttached=function(e,t){t=this.media=this.mediaBuffer=t.media,this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),t.addEventListener("seeking",this.onvseeking),t.addEventListener("ended",this.onvended),t=this.config;this.levels&&t.autoStartLoad&&this.state===E.STOPPED&&this.startLoad(t.startPosition)},t.onMediaDetaching=function(){var e=this.media;null!=e&&e.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),e&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},t.onMediaSeeking=function(){var e=this.config,t=this.fragCurrent,r=this.media,i=this.mediaBuffer,n=this.state,s=r?r.currentTime:0,i=a.BufferHelper.bufferInfo(i||r,s,e.maxBufferHole);this.log("media seeking to "+(Object(l.isFiniteNumber)(s)?s.toFixed(3):s)+", state: "+n),n===E.ENDED?this.resetLoadingState():t&&!i.len&&(n=e.maxFragLookUpTolerance,e=t.start-n,n=s>t.start+t.duration+n,(se.end&&t.fragmentHint&&(e=t.fragmentHint);var a,o=this.getNextPart(s,e,r);if(-1r&&this.flushMainBuffer(i,e.start)):this.flushMainBuffer(0,e.start))},t.getFwdBufferInfo=function(e,t){var r=this.config,i=this.getLoadPosition();if(!Object(l.isFiniteNumber)(i))return null;var n=a.BufferHelper.bufferInfo(e,i,r.maxBufferHole);if(0===n.len&&void 0!==n.nextStart){t=this.fragmentTracker.getBufferedFrag(i,t);if(t&&n.nextStart=e&&(t.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+t.maxMaxBufferLength+"s"),!0)},t.getNextFragment=function(e,t){var r=t.fragments,i=r.length;if(!i)return null;var n,s=this.config,a=r[0].start;if(t.live){var o=s.initialLiveManifestSize;if(ie.start&&e.loaded},t.getInitialLiveFragment=function(e,t){var r,i=this.fragPrevious,n=null;return i?(e.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+i.programDateTime),n=Object(f.findFragmentByPDT)(t,i.endProgramDateTime,this.config.maxFragLookUpTolerance)),n||((r=i.sn+1)>=e.startSN&&r<=e.endSN&&(r=t[r-e.startSN],i.cc===r.cc&&this.log("Live playlist, switching playlist, load frag with next SN: "+(n=r).sn)),n||(n=Object(f.findFragWithCC)(t,i.cc))&&this.log("Live playlist, switching playlist, load frag with same CC: "+n.sn))):null!==(r=this.hls.liveSyncPosition)&&(n=this.getFragmentAtPosition(r,this.bitrateTest?e.fragmentEnd:e.edge,e)),n},t.getFragmentAtPosition=function(e,t,r){var i,n=this.config,s=this.fragPrevious,a=r.fragments,o=r.endSN,l=r.fragmentHint,d=n.maxFragLookUpTolerance,n=!!(n.lowLatencyMode&&r.partList&&l);if(n&&l&&!this.bitrateTest&&(a=a.concat(l),o=l.sn),i=e=n-s.maxFragLookUpTolerance&&r<=i,null!==t&&a.duration>t&&(r"+e.startSN+" prev-sn: "+(n?n.sn:"na")+" fragments: "+i),a):s},t.waitForCdnTuneIn=function(e){return e.live&&e.canBlockReload&&e.tuneInGoal>Math.max(e.partHoldBack,3*e.partTarget)},t.setStartPosition=function(e,t){var r,i=this.startPosition;-1!==(i=i"+e))}}]),S);function S(e,t,r){var i;return(i=b.call(this)||this).hls=void 0,i.fragPrevious=null,i.fragCurrent=null,i.fragmentTracker=void 0,i.transmuxer=null,i._state=E.STOPPED,i.media=void 0,i.mediaBuffer=void 0,i.config=void 0,i.bitrateTest=!1,i.lastCurrentTime=0,i.nextLoadPosition=0,i.startPosition=0,i.loadedmetadata=!1,i.fragLoadError=0,i.retryDate=0,i.levels=null,i.fragmentLoader=void 0,i.levelLastLoaded=null,i.startFragRequested=!1,i.decrypter=void 0,i.initPTS=[],i.onvseeking=null,i.onvended=null,i.logPrefix="",i.log=void 0,i.warn=void 0,i.logPrefix=r,i.log=n.logger.log.bind(n.logger,r+":"),i.warn=n.logger.warn.bind(n.logger,r+":"),i.hls=e,i.fragmentLoader=new A.default(e.config),i.fragmentTracker=t,i.config=e.config,i.decrypter=new g.default(e,e.config),e.on(h.Events.KEY_LOADED,i.onKeyLoaded,function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(i)),i}},"./src/controller/buffer-controller.ts":function(e,t,r){r.r(t),r.d(t,"default",function(){return s});var l=r("./src/polyfills/number.ts"),g=r("./src/events.ts"),p=r("./src/utils/logger.ts"),m=r("./src/errors.ts"),v=r("./src/utils/buffer-helper.ts"),t=r("./src/utils/mediasource-helper.ts"),a=r("./src/loader/fragment.ts"),i=r("./src/controller/buffer-operation-queue.ts"),n=Object(t.getMediaSource)(),d=/([ha]vc.)(?:\.[^.,]+)+/,s=((r=o.prototype).hasSourceTypes=function(){return 0r.config.appendErrorMaxRetry&&(p.logger.error("[buffer-controller]: Failed "+r.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),t.fatal=!0)),r.trigger(g.Events.ERROR,t)}},o)},r.onBufferFlushing=function(e,r){function t(t){return{execute:i.removeExecutor.bind(i,t,r.startOffset,r.endOffset),onStart:function(){},onComplete:function(){i.hls.trigger(g.Events.BUFFER_FLUSHED,{type:t})},onError:function(e){p.logger.warn("[buffer-controller]: Failed to remove from "+t+" SourceBuffer",e)}}}var i=this,n=this.operationQueue;r.type?n.append(t(r.type),r.type):this.getSourceBufferTypes().forEach(function(e){n.append(t(e),e)})},r.onFragParsed=function(e,t){var r=this,i=t.frag,n=t.part,t=[],s=(n||i).elementaryStreams;s[a.ElementaryStreamTypes.AUDIOVIDEO]?t.push("audiovideo"):(s[a.ElementaryStreamTypes.AUDIO]&&t.push("audio"),s[a.ElementaryStreamTypes.VIDEO]&&t.push("video")),0===t.length&&p.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+i.type+" level: "+i.level+" sn: "+i.sn),this.blockBuffers(function(){var e=self.performance.now(),e=(i.stats.buffering.end=e,n&&(n.stats.buffering.end=e),(n||i).stats);r.hls.trigger(g.Events.FRAG_BUFFERED,{frag:i,part:n,stats:e,id:i.type})},t)},r.onFragChanged=function(e,t){this.flushBackBuffer()},r.onBufferEos=function(e,i){var n=this;this.getSourceBufferTypes().reduce(function(e,t){var r=n.sourceBuffer[t];return i.type&&i.type!==t||r&&!r.ended&&(r.ended=!0,p.logger.log("[buffer-controller]: "+t+" sourceBuffer now EOS")),e&&!(r&&!r.ended)},!0)&&this.blockBuffers(function(){var e=n.mediaSource;e&&"open"===e.readyState&&e.endOfStream()})},r.onLevelUpdated=function(e,t){t=t.details;t.fragments.length&&(this.details=t,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},r.flushBackBuffer=function(){var e,t,r,i,n=this.hls,s=this.details,a=this.media,o=this.sourceBuffer;a&&null!==s&&(e=this.getSourceBufferTypes()).length&&(r=s.live&&null!==n.config.liveBackBufferLength?n.config.liveBackBufferLength:n.config.backBufferLength,!Object(l.isFiniteNumber)(r)||r<0||(a=a.currentTime,t=s.levelTargetDuration,r=Math.max(r,t),i=Math.floor(a/t)*t-r,e.forEach(function(e){var t=o[e];t&&0<(t=v.BufferHelper.getBuffered(t)).length&&i>t.start(0)&&(n.trigger(g.Events.BACK_BUFFER_REACHED,{bufferEnd:i}),s.live&&n.trigger(g.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:i}),n.trigger(g.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:i,type:e}))})))},r.updateMediaElementDuration=function(){var e,t,r,i,n,s;this.details&&this.media&&this.mediaSource&&"open"===this.mediaSource.readyState&&(e=this.details,t=this.hls,n=this.media,r=this.mediaSource,i=e.fragments[0].start+e.totalduration,n=n.duration,s=Object(l.isFiniteNumber)(r.duration)?r.duration:0,e.live&&t.config.liveDurationInfinity?(p.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),r.duration=1/0,this.updateSeekableRange(e)):(sthis.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping))},r.getMaxLevel=function(r){var i=this,e=this.hls.levels;if(!e.length)return-1;e=e.filter(function(e,t){return a.isLevelAllowed(t,i.restrictedLevels)&&t<=r});return this.clientRect=null,a.getMaxLevelByMediaSize(e,this.mediaWidth,this.mediaHeight)},r.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},r.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},r.getDimensions=function(){if(this.clientRect)return this.clientRect;var e,t=this.media,r={width:0,height:0};return t&&(e=t.getBoundingClientRect(),r.width=e.width,r.height=e.height,r.width||r.height||(r.width=e.right-e.left||t.width||0,r.height=e.bottom-e.top||t.height||0)),this.clientRect=r},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,n=e.length-1,s=0;s=t||a.height>=r)&&(!(i=e[s+1])||a.width!==i.width||a.height!==i.height)){n=s;break}}return n},r=[{key:"contentScaleFactor",get:function(){var e=1;try{e=self.devicePixelRatio}catch(e){}return e}}],n((s=a).prototype,[{key:"mediaWidth",get:function(){return this.getDimensions().width*a.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*a.contentScaleFactor}}]),n(s,r);var s=a;function a(e){this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.hls=void 0,this.streamController=void 0,this.clientRect=void 0,this.hls=e,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}t.default=s},"./src/controller/cmcd-controller.ts":function(e,t,r){r.r(t),r.d(t,"default",function(){return h});var i=r("./src/events.ts"),a=r("./src/types/cmcd.ts"),n=r("./src/utils/buffer-helper.ts"),o=r("./src/utils/logger.ts");function s(e,t){for(var r=0;r=e.length?{done:!0}:{done:!1,value:e[r++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);rt&&(t=n.bitrate)}return 0s.config.fpsDroppedMonitoringThreshold*n&&(a=s.currentLevel,d.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+a),0=a)&&(s.trigger(l.Events.FPS_DROP_LEVEL_CAPPING,{level:--a,droppedLevel:s.currentLevel}),s.autoLevelCapping=a,this.streamController.nextLevelSwitch()))),this.lastTime=o,this.lastDroppedFrames=r,this.lastDecodedFrames=t)},r.checkFPSInterval=function(){var e,t=this.media;t&&(this.isVideoPlaybackQualityAvailable?(e=t.getVideoPlaybackQuality(),this.checkFPS(t,e.totalVideoFrames,e.droppedVideoFrames)):this.checkFPS(t,t.webkitDecodedFrameCount,t.webkitDroppedFrameCount))},t.default=i},"./src/controller/fragment-finders.ts":function(e,t,r){r.r(t),r.d(t,"findFragmentByPDT",function(){return i}),r.d(t,"findFragmentByPTS",function(){return n}),r.d(t,"fragmentWithinToleranceTest",function(){return o}),r.d(t,"pdtWithinToleranceTest",function(){return l}),r.d(t,"findFragWithCC",function(){return d});var s=r("./src/polyfills/number.ts"),a=r("./src/utils/binary-search.ts");function i(e,t,r){if(null===t||!Array.isArray(e)||!e.length||!Object(s.isFiniteNumber)(t))return null;if(t<(e[0].programDateTime||0))return null;if(t>=(e[e.length-1].endProgramDateTime||0))return null;r=r||0;for(var i=0;ie&&r.start?-1:0}function l(e,t,r){t=1e3*Math.min(t,r.duration+(r.deltaPTS||0));return(r.endProgramDateTime||0)-t>e}function d(e,t){return a.default.search(e,function(e){return e.cct?-1:0})}},"./src/controller/fragment-tracker.ts":function(e,t,r){r.r(t),r.d(t,"FragmentState",function(){return i}),r.d(t,"FragmentTracker",function(){return s});var i,n=r("./src/events.ts"),o=r("./src/types/loader.ts"),s=((t=i=i||{}).NOT_LOADED="NOT_LOADED",t.BACKTRACKED="BACKTRACKED",t.APPENDING="APPENDING",t.PARTIAL="PARTIAL",t.OK="OK",(r=a.prototype)._registerListeners=function(){var e=this.hls;e.on(n.Events.BUFFER_APPENDED,this.onBufferAppended,this),e.on(n.Events.FRAG_BUFFERED,this.onFragBuffered,this),e.on(n.Events.FRAG_LOADED,this.onFragLoaded,this)},r._unregisterListeners=function(){var e=this.hls;e.off(n.Events.BUFFER_APPENDED,this.onBufferAppended,this),e.off(n.Events.FRAG_BUFFERED,this.onFragBuffered,this),e.off(n.Events.FRAG_LOADED,this.onFragLoaded,this)},r.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},r.getAppendedFrag=function(e,t){if(t===o.PlaylistLevelType.MAIN){var r=this.activeFragment,i=this.activeParts;if(!r)return null;if(i)for(var n=i.length;n--;){var s=i[n],a=s?s.end:r.appendedPTS;if(s.start<=e&&void 0!==a&&e<=a)return 9t&&n.removeFragment(e))})},r.removeFragment=function(e){var t=d(e);e.stats.loaded=0,e.clearElementaryStreamInfo(),delete this.fragments[t]},r.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},a);function a(e){this.activeFragment=null,this.activeParts=null,this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hls=e,this._registerListeners()}function l(e){var t;return e.buffered&&(null!=(t=e.range.video)&&t.partial||null!=(t=e.range.audio)&&t.partial)}function d(e){return e.type+"_"+e.level+"_"+e.urlId+"_"+e.sn}},"./src/controller/gap-controller.ts":function(e,t,r){r.r(t),r.d(t,"STALL_MINIMUM_DURATION_MS",function(){return f}),r.d(t,"MAX_START_GAP_JUMP",function(){return A}),r.d(t,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return g}),r.d(t,"SKIP_BUFFER_RANGE_START",function(){return p}),r.d(t,"default",function(){return i});var d=r("./src/utils/buffer-helper.ts"),u=r("./src/errors.ts"),c=r("./src/events.ts"),h=r("./src/utils/logger.ts"),f=250,A=2,g=.1,p=.05,i=((t=n.prototype).destroy=function(){this.hls=this.fragmentTracker=this.media=null},t.poll=function(e){var t=this.config,r=this.media,i=this.stalled,n=r.currentTime,s=r.seeking,a=this.seeking&&!s,o=!this.seeking&&s;if(this.seeking=s,n===e){if((o||a)&&(this.stalled=null),!r.paused&&!r.ended&&0!==r.playbackRate&&d.BufferHelper.getBuffered(r).length){e=d.BufferHelper.bufferInfo(r,n,0),o=0A,l=!a||Ar.maxBufferHole&&t>1e3*r.highBufferWatchdogPeriod&&(h.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,h.logger.warn("Playback stalling at @"+r.currentTime+" due to low buffer (buffer="+e+")"),t.trigger(c.Events.ERROR,{type:u.ErrorTypes.MEDIA_ERROR,details:u.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:e}))},t._trySkipBufferHole=function(e){for(var t=this.config,r=this.hls,i=this.media,n=i.currentTime,s=0,a=d.BufferHelper.getBuffered(i),o=0;o=s&&nthis.hls.config.fragLoadingMaxRetry&&(i=t.frag.level)):i=t.frag.level);break;case g.ErrorDetails.LEVEL_LOAD_ERROR:case g.ErrorDetails.LEVEL_LOAD_TIMEOUT:r&&(r.deliveryDirectives&&(a=!1),i=r.level),s=!0;break;case g.ErrorDetails.REMUX_ALLOC_ERROR:i=t.level,s=!0}void 0!==i&&this.recoverLevel(t,i,s,a)}}},t.recoverLevel=function(e,t,r,i){var n=e.details,s=this._levels[t];if(s.loadError++,r){if(!this.retryLoadingOrFail(e))return void(this.currentLevelIndex=-1);e.levelRetry=!0}i&&(1<(r=s.url.length)&&s.loadError=t.length){var r=e<0;if(this.hls.trigger(A.Events.ERROR,{type:g.ErrorTypes.OTHER_ERROR,details:g.ErrorDetails.LEVEL_SWITCH_ERROR,level:e,fatal:r,reason:"invalid level idx"}),r)return;e=Math.min(e,t.length-1)}this.clearTimer();var r=this.currentLevelIndex,i=t[r],t=t[e],r=(this.log("switching to level "+e+" from "+r),n({},t,{level:this.currentLevelIndex=e,maxBitrate:t.maxBitrate,uri:t.uri,urlId:t.urlId})),e=(delete r._urlId,this.hls.trigger(A.Events.LEVEL_SWITCHING,r),t.details);e&&!e.live||(r=this.switchParams(t.uri,null==i?void 0:i.details),this.loadPlaylist(r))}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(e){this.manualLevelIndex=e,void 0===this._startLevel&&(this._startLevel=e),-1!==e&&(this.level=e)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(e){this._firstLevel=e}},{key:"startLevel",get:function(){var e;return void 0===this._startLevel?void 0!==(e=this.hls.config.startLevel)?e:this._firstLevel:this._startLevel},set:function(e){this._startLevel=e}},{key:"nextLoadLevel",get:function(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(e){this.level=e,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=e)}}]),d);function d(e){return(e=l.call(this,e,"[level-controller]")||this)._levels=[],e._firstLevel=-1,e._startLevel=void 0,e.currentLevelIndex=-1,e.manualLevelIndex=-1,e.onParsedComplete=void 0,e._registerListeners(),e}},"./src/controller/level-helper.ts":function(e,t,r){r.r(t),r.d(t,"addGroupId",function(){return i}),r.d(t,"assignTrackIdsByGroup",function(){return n}),r.d(t,"updatePTS",function(){return s}),r.d(t,"updateFragPTSDTS",function(){return p}),r.d(t,"mergeDetails",function(){return a}),r.d(t,"mapPartIntersection",function(){return m}),r.d(t,"mapFragmentIntersection",function(){return v}),r.d(t,"adjustSliding",function(){return y}),r.d(t,"addSliding",function(){return o}),r.d(t,"computeReloadInterval",function(){return l}),r.d(t,"getFragmentWithSN",function(){return d}),r.d(t,"getPartWith",function(){return u});var f=r("./src/polyfills/number.ts"),A=r("./src/utils/logger.ts");function i(e,t,r){switch(t){case"audio":e.audioGroupIds||(e.audioGroupIds=[]),e.audioGroupIds.push(r);break;case"text":e.textGroupIds||(e.textGroupIds=[]),e.textGroupIds.push(r)}}function n(e){var r={};e.forEach(function(e){var t=e.groupId||"";e.id=r[t]=r[t]||0,r[t]++})}function s(e,t,r){g(e[t],e[r])}function g(e,t){var r,i=t.startPTS;Object(f.isFiniteNumber)(i)?(r=0,(i=t.sn>e.sn?(r=i-e.start,e):(r=e.start-i,t)).duration!==r&&(i.duration=r)):t.sn>e.sn?e.cc===t.cc&&e.minEndPTS?t.start=e.start+(e.minEndPTS-e.start):t.start=e.start+e.duration:t.start=Math.max(e.start-t.duration,0)}function p(e,t,r,i,n,s){i-r<=0&&(A.logger.warn("Fragment should have a positive duration",t),i=r+t.duration,s=n+t.duration);var a=r,o=i,l=t.startPTS,d=t.endPTS,u=(Object(f.isFiniteNumber)(l)&&(u=Math.abs(l-r),Object(f.isFiniteNumber)(t.deltaPTS)?t.deltaPTS=Math.max(u,t.deltaPTS):t.deltaPTS=u,a=Math.max(r,l),r=Math.min(r,l),n=Math.min(n,t.startDTS),o=Math.min(i,d),i=Math.max(i,d),s=Math.max(s,t.endDTS)),t.duration=i-r,r-t.start);t.appendedPTS=i,t.start=t.startPTS=r,t.maxStartPTS=a,t.startDTS=n,t.endPTS=i,t.minEndPTS=o,t.endDTS=s;var c,l=t.sn;if(!e||le.endSN)return 0;var d=l-e.startSN,h=e.fragments;for(h[d]=t,c=d;0=e.length||o(t,e[r].start)}function o(e,t){if(t){for(var r=e.fragments,i=e.skippedSegments;i=this.getMaxBufferLength(t.maxBitrate))){if(this._streamEnded(r,n))return e={},this.altAudio&&(e.type="video"),this.hls.trigger(p.Events.BUFFER_EOS,e),void(this.state=g.State.ENDED);s=r.end,t=this.getNextFragment(s,n);!this.couldBacktrack||this.fragPrevious||!t||"initSegment"===t.sn||1<(e=t.sn-n.startSN)&&(t=n.fragments[e-1],this.fragmentTracker.removeFragment(t)),t&&this.fragmentTracker.getState(t)===a.FragmentState.OK&&this.nextLoadPosition>s&&(r=this.audioOnly&&!this.altAudio?m.ElementaryStreamTypes.AUDIO:m.ElementaryStreamTypes.VIDEO,this.afterBufferFlushed(i,r,c.PlaylistLevelType.MAIN),t=this.getNextFragment(this.nextLoadPosition,n)),t&&("identity"!==(null==(e=(t=!t.initSegment||t.initSegment.data||this.bitrateTest?t:t.initSegment).decryptdata)?void 0:e.keyFormat)||null!=(i=t.decryptdata)&&i.key?this.loadFragment(t,n,s):this.loadKey(t,n))}}}},r.loadFragment=function(e,t,r){var i=this.fragmentTracker.getState(e);if(this.fragCurrent=e,i===a.FragmentState.BACKTRACKED){var n=this.fragmentTracker.getBacktrackData(e);if(n)return this._handleFragmentLoadProgress(n),void this._handleFragmentLoadComplete(n);i=a.FragmentState.NOT_LOADED}i===a.FragmentState.NOT_LOADED||i===a.FragmentState.PARTIAL?"initSegment"===e.sn?this._loadInitSegment(e):this.bitrateTest?(e.bitrateTest=!0,this.log("Fragment "+e.sn+" of level "+e.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(e)):(this.startFragRequested=!0,v.prototype.loadFragment.call(this,e,t,r)):i===a.FragmentState.APPENDING?this.reduceMaxBufferLength(e.duration)&&this.fragmentTracker.removeFragment(e):0===(null==(n=this.media)?void 0:n.buffered.length)&&this.fragmentTracker.removeAllFragments()},r.getAppendedFrag=function(e){e=this.fragmentTracker.getAppendedFrag(e,c.PlaylistLevelType.MAIN);return e&&"fragment"in e?e.fragment:e},r.getBufferedFrag=function(e){return this.fragmentTracker.getBufferedFrag(e,c.PlaylistLevelType.MAIN)},r.followingBufferedFrag=function(e){return e?this.getBufferedFrag(e.end+.5):null},r.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},r.nextLevelSwitch=function(){var e,t=this.levels,r=this.media;null!=r&&r.readyState&&((e=this.getAppendedFrag(r.currentTime))&&1=i[a].start&&s<=i[a].end){n=i[a];break}t=r.start+r.duration;n?n.end=t:i.push(n={start:s,end:t}),this.fragmentTracker.fragBuffered(r)}}},r.onBufferFlushing=function(e,t){var r,i,n,s=t.startOffset,a=t.endOffset;0===s&&a!==Number.POSITIVE_INFINITY&&(r=this.currentTrackId,(i=this.levels).length&&i[r]&&i[r].details&&((n=a-i[r].details.targetduration)<=0||(t.endOffsetSubtitles=Math.max(0,n),this.tracksBuffered.forEach(function(e){for(var t=0;t=n.length||t!==i)&&s){if(this.mediaBuffer=this.mediaBufferTimeRanges,r.live||null!=(n=s.details)&&n.live){i=this.mainDetails;if(r.deltaUpdateFailed||!i)return;n=i.fragments[0];s.details?0===this.alignPlaylists(r,s.details)&&n&&Object(o.addSliding)(r,n.start):r.hasProgramDateTime&&i.hasProgramDateTime?Object(a.alignMediaPlaylistByPDT)(r,i):n&&Object(o.addSliding)(r,n.start)}s.details=r,this.levelLastLoaded=t,this.tick(),!r.live||this.fragCurrent||!this.media||this.state!==c.State.IDLE||Object(d.findFragmentByPTS)(null,r.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),s.details=void 0)}}},r._handleFragmentLoadComplete=function(e){var r,i=e.frag,e=e.payload,t=i.decryptdata,n=this.hls;!this.fragContextChanged(i)&&e&&0this.getMaxBufferLength()+s||(console.assert(e,"Subtitle track details are defined on idle subtitle stream controller tick"),s=(n=e.fragments).length,o=e.edge,a=this.fragPrevious,r=o.length||(this.clearTimer(),r=o[e],this.log("Switching to subtitle track "+e),this.trackId=e,r?(o=r.id,i=r.groupId,n=r.name,s=r.type,a=r.url,this.hls.trigger(l.Events.SUBTITLE_TRACK_SWITCH,{id:o,groupId:void 0===i?"":i,name:n,type:s,url:a}),o=this.switchParams(r.url,null==t?void 0:t.details),this.loadPlaylist(o)):this.hls.trigger(l.Events.SUBTITLE_TRACK_SWITCH,{id:e}))):this.queuedDefaultTrack=e},n.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),this.media&&this.hls.config.renderTextTracksNatively){for(var e=-1,t=c(this.media.textTracks),r=0;r>>8^255&g^99,c[t[g]=h]),m=c[p],v=c[m],y=257*c[g]^16843008*g;i[h]=y<<24|y>>>8,n[h]=y<<16|y>>>16,s[h]=y<<8|y>>>24,a[h]=y,o[g]=(y=16843009*v^65537*m^257*p^16843008*h)<<24|y>>>8,l[g]=y<<16|y>>>16,d[g]=y<<8|y>>>24,u[g]=y,h?(h=p^c[c[c[v^p]]],f^=c[c[f]]):h=f=1}},t.expandKey=function(e){for(var t=this.uint8ArrayToUint32Array_(e),r=!0,i=0;i>>6),u=(60&t[r+2])>>>2;if(!(l.length-1>>6,c.logger.log("manifest codec:"+i+", ADTS type:"+d+", samplingIndex:"+u),t=/firefox/i.test(a)?6<=u?(d=5,s=new Array(4),u-3):(d=2,s=new Array(2),u):-1!==a.indexOf("android")?(d=2,s=new Array(2),u):(d=5,s=new Array(4),i&&(-1!==i.indexOf("mp4a.40.29")||-1!==i.indexOf("mp4a.40.5"))||!i&&6<=u?u-3:((i&&-1!==i.indexOf("mp4a.40.2")&&(6<=u&&1==n||/vivaldi/i.test(a))||!i&&1==n)&&(d=2,s=new Array(2)),u)),s[0]=d<<3,s[0]|=(14&u)>>1,s[1]|=(1&u)<<7,s[1]|=n<<3,5===d&&(s[1]|=(14&t)>>1,s[2]=(1&t)<<7,s[2]|=8,s[3]=0),{config:s,samplerate:l[u],channelCount:n,codec:"mp4a.40."+d,manifestCodec:o};e.trigger(f.Events.ERROR,{type:h.ErrorTypes.MEDIA_ERROR,details:h.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+u})}function i(e,t){return 255===e[t]&&240==(246&e[t+1])}function a(e,t){return 1&e[t+1]?7:9}function o(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function n(e,t){return t+5=e.length)return!1;var i=o(e,t);if(i<=r)return!1;r=t+i;return r===e.length||l(e,r)}return!1}function A(e,t,r,i,n){e.samplerate||(t=s(t,r,i,n))&&(e.config=t.config,e.samplerate=t.samplerate,e.channelCount=t.channelCount,e.codec=t.codec,e.manifestCodec=t.manifestCodec,c.logger.log("parsed codec:"+e.codec+", rate:"+t.samplerate+", channels:"+t.channelCount))}function g(e){return 9216e4/e}function p(e,t,r,i,n){var s=a(e,t),e=o(e,t);if(0<(e-=s))return{headerLength:s,frameLength:e,stamp:r+i*n}}function m(e,t,r,i,n){var s,a,o,i=p(t,r,i,n,g(e.samplerate));if(i)return n=i.frameLength,a=i.headerLength,i=i.stamp,n=a+n,(o=Math.max(0,r+n-t.length))?(s=new Uint8Array(n-a)).set(t.subarray(r+a,t.length),0):s=t.subarray(r+a,r+n),t={unit:s,pts:i},o||e.samples.push(t),{sample:t,length:n,missing:o}}},"./src/demux/base-audio-demuxer.ts":function(e,t,r){r.r(t),r.d(t,"initPTSFn",function(){return g});var i=r("./src/polyfills/number.ts"),c=r("./src/demux/id3.ts"),h=r("./src/demux/dummy-demuxed-track.ts"),f=r("./src/utils/mp4-tools.ts"),A=r("./src/utils/typed-array.ts");(r=n.prototype).resetInitSegment=function(e,t,r){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},r.resetTimeStamp=function(){},r.resetContiguity=function(){},r.canParse=function(e,t){return!1},r.appendFrame=function(e,t,r){},r.demux=function(e,t){this.cachedData&&(e=Object(f.appendUint8Array)(this.cachedData,e),this.cachedData=null);var r,i,n,s=c.getID3Data(e,0),a=s?s.length:0,o=this._audioTrack,l=this._id3Track,d=s?c.getTimeStamp(s):void 0,u=e.length;for(0!==this.frameIndex&&null!==this.initPTS||(this.initPTS=g(d,t)),s&&0e||(e=(e-=this.bitsAvailable)-((t=e>>3)>>3),this.bytesAvailable-=t,this.loadWord()),this.word<<=e,this.bitsAvailable-=e},r.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()},r.skipUEG=function(){this.skipBits(1+this.skipLZ())},r.skipEG=function(){this.skipBits(1+this.skipLZ())},r.readUEG=function(){var e=this.skipLZ();return this.readBits(e+1)-1},r.readEG=function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)},r.readBoolean=function(){return 1===this.readBits(1)},r.readUByte=function(){return this.readBits(8)},r.readUShort=function(){return this.readBits(16)},r.readUInt=function(){return this.readBits(32)},r.skipScalingList=function(e){for(var t=8,r=8,i=0;i>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:l+=String.fromCharCode(n);break;case 12:case 13:s=e[d++],l+=String.fromCharCode((31&n)<<6|63&s);break;case 14:s=e[d++],a=e[d++],l+=String.fromCharCode((15&n)<<12|(63&s)<<6|(63&a)<<0)}}return l},y={decodeTextFrame:g}},"./src/demux/mp3demuxer.ts":function(e,t,r){r.r(t);var i=r("./src/demux/base-audio-demuxer.ts"),n=r("./src/demux/id3.ts"),s=r("./src/utils/logger.ts"),a=r("./src/demux/mpegaudio.ts");function o(e,t){return(o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}l=i.default,r=l,(i=d).prototype=Object.create(r.prototype),o(i.prototype.constructor=i,r),(i=d.prototype).resetInitSegment=function(e,t,r){l.prototype.resetInitSegment.call(this,e,t,r),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!1,samples:[],manifestCodec:e,duration:r,inputTimeScale:9e4,dropped:0}},d.probe=function(e){if(!e)return!1;for(var t=(n.getID3Data(e,0)||[]).length,r=e.length;tt.length)){var s=a(t,r);if(s&&r+s.frameLength<=t.length)return i=i+n*(9e4*s.samplesPerFrame/s.sampleRate),n={unit:t.subarray(r,r+s.frameLength),pts:i,dts:i},e.config=[],e.channelCount=s.channelCount,e.samplerate=s.sampleRate,e.samples.push(n),{sample:n,length:s.frameLength,missing:0}}}function a(e,t){var r,i,n,s,a,o=e[t+1]>>3&3,l=e[t+1]>>1&3,d=e[t+2]>>4&15,u=e[t+2]>>2&3;if(1!=o&&0!=d&&15!=d&&3!=u)return a=e[t+2]>>1&1,r=e[t+3]>>6,d=1e3*h[14*(3==o?3-l:3==l?3:4)+d-1],u=f[3*(3==o?0:2==o?1:2)+u],i=3==r?1:2,s=8*(o=A[o][l])*(n=g[l]),o=Math.floor(o*d/u+a)*n,null===c&&(a=(navigator.userAgent||"").match(/Chrome\/(\d+)/i),c=a?parseInt(a[1]):0),c&&c<=87&&2==l&&224e3<=d&&0==r&&(e[t+3]=128|e[t+3]),{sampleRate:u,channelCount:i,frameLength:o,samplesPerFrame:s}}function n(e,t){return 255===e[t]&&224==(224&e[t+1])&&0!=(6&e[t+1])}function s(e,t){return t+1=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}}},r.getAvcEncryptedData=function(e){for(var t=16*Math.floor((e.length-48)/160)+16,r=new Int8Array(t),i=0,n=32;n=e.length)return void i();for(var n=e[t].units;!(r>=n.length);r++){var s=n[r];if(!(s.data.length<=48||1!==s.type&&5!==s.type)){var a=this.decrypter.isSync();if(this.decryptAvcSample(e,t,r,i,s,a),!a)return}}}},t.default=n},"./src/demux/transmuxer-interface.ts":function(e,t,r){r.r(t),r.d(t,"default",function(){return i});var l=r("./node_modules/webworkify-webpack/index.js"),d=r("./src/events.ts"),T=r("./src/demux/transmuxer.ts"),S=r("./src/utils/logger.ts"),u=r("./src/errors.ts"),t=r("./src/utils/mediasource-helper.ts"),c=r("./node_modules/eventemitter3/index.js"),h=Object(t.getMediaSource)()||{isTypeSupported:function(){return!1}},i=((r=n.prototype).destroy=function(){var e=this.worker,e=(e?(e.removeEventListener("message",this.onwmsg),e.terminate(),this.worker=null):(e=this.transmuxer)&&(e.destroy(),this.transmuxer=null),this.observer);e&&e.removeAllListeners(),this.observer=null},r.push=function(e,t,r,i,n,s,a,o,l,d){var u=this,c=(l.transmuxing.start=self.performance.now(),this.transmuxer),h=this.worker,f=(s||n).start,A=n.decryptdata,g=this.frag,p=!(g&&n.cc===g.cc),m=!(g&&l.level===g.level),v=g?l.sn-g.sn:-1,y=this.part?l.part-this.part.index:1,b=!m&&(1==v||0==v&&1==y),E=self.performance.now(),E=((m||v||0===n.stats.parsing.start)&&(n.stats.parsing.start=E),!s||!y&&b||(s.stats.parsing.start=E),!(g&&(null==(v=n.initSegment)?void 0:v.url)===(null==(y=g.initSegment)?void 0:y.url))),v=new T.TransmuxState(p,b,o,m,f,E);b&&!p&&!E||(S.logger.log("[transmuxer-interface, "+n.type+"]: Starting new transmux session for sn: "+l.sn+" p: "+l.part+" level: "+l.level+" id: "+l.id+"\n discontinuity: "+p+"\n trackSwitch: "+m+"\n contiguous: "+b+"\n accurateTimeOffset: "+o+"\n timeOffset: "+f+"\n initSegmentChange: "+E),g=new T.TransmuxConfig(r,i,t,a,d),this.configureTransmuxer(g)),this.frag=n,this.part=s,h?h.postMessage({cmd:"demux",data:e,decryptdata:A,chunkMeta:l,state:v},e instanceof ArrayBuffer?[e]:[]):c&&(y=c.push(e,A,l,v),Object(T.isPromise)(y)?y.then(function(e){u.handleTransmuxComplete(e)}):this.handleTransmuxComplete(y))},r.flush=function(t){var r=this,e=(t.transmuxing.start=self.performance.now(),this.transmuxer),i=this.worker;i?i.postMessage({cmd:"flush",chunkMeta:t}):e&&(i=e.flush(t),Object(T.isPromise)(i)?i.then(function(e){r.handleFlushResult(e,t)}):this.handleFlushResult(i,t))},r.handleFlushResult=function(e,t){var r=this;e.forEach(function(e){r.handleTransmuxComplete(e)}),this.onFlush(t)},r.onWorkerMessage=function(e){var t=e.data,r=this.hls;switch(t.event){case"init":self.URL.revokeObjectURL(this.worker.objectURL);break;case"transmuxComplete":this.handleTransmuxComplete(t.data);break;case"flush":this.onFlush(t.data);break;default:t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,r.trigger(t.event,t.data)}},r.configureTransmuxer=function(e){var t=this.worker,r=this.transmuxer;t?t.postMessage({cmd:"configure",config:e}):r&&r.configure(e)},r.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},n);function n(r,e,t,i){function n(e,t){(t=t||{}).frag=a.frag,t.id=a.id,r.trigger(e,t)}var s,a=this,t=(this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.worker=void 0,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.hls=r,this.id=e,this.onTransmuxComplete=t,this.onFlush=i,r.config),i=(this.observer=new c.EventEmitter,this.observer.on(d.Events.FRAG_DECRYPTED,n),this.observer.on(d.Events.ERROR,n),{mp4:h.isTypeSupported("video/mp4"),mpeg:h.isTypeSupported("audio/mpeg"),mp3:h.isTypeSupported('audio/mp4; codecs="mp3"')}),o=navigator.vendor;if(t.enableWorker&&"undefined"!=typeof Worker){S.logger.log("demuxing in webworker");try{s=this.worker=l("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),s.addEventListener("message",this.onwmsg),s.onerror=function(e){r.trigger(d.Events.ERROR,{type:u.ErrorTypes.OTHER_ERROR,details:u.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(e.message+" ("+e.filename+":"+e.lineno+")")})},s.postMessage({cmd:"init",typeSupported:i,vendor:o,id:e,config:JSON.stringify(t)})}catch(r){S.logger.warn("Error in worker:",r),S.logger.error("Error while initializing DemuxerWorker, fallback to inline"),s&&self.URL.revokeObjectURL(s.objectURL),this.transmuxer=new T.default(this.observer,i,t,o,e),this.worker=null}}else this.transmuxer=new T.default(this.observer,i,t,o,e)}},"./src/demux/transmuxer-worker.ts":function(e,t,r){r.r(t),r.d(t,"default",function(){return n});var o=r("./src/demux/transmuxer.ts"),i=r("./src/events.ts"),l=r("./src/utils/logger.ts"),d=r("./node_modules/eventemitter3/index.js");function n(n){function s(e,t){n.postMessage({event:e,data:t})}var a=new d.EventEmitter;a.on(i.Events.FRAG_DECRYPTED,s),a.on(i.Events.ERROR,s),n.addEventListener("message",function(e){var t=e.data;switch(t.cmd){case"init":var r=JSON.parse(t.config);n.transmuxer=new o.default(a,t.typeSupported,r,t.vendor,t.id),Object(l.enableLogs)(r.debug),s("init",null);break;case"configure":n.transmuxer.configure(t.config);break;case"demux":r=n.transmuxer.push(t.data,t.decryptdata,t.chunkMeta,t.state);Object(o.isPromise)(r)?r.then(function(e){u(n,e)}):u(n,r);break;case"flush":var i=t.chunkMeta,r=n.transmuxer.flush(i);Object(o.isPromise)(r)?r.then(function(e){c(n,e,i)}):c(n,r,i)}})}function u(e,t){var r,i,n;((r=t.remuxResult).audio||r.video||r.text||r.id3||r.initSegment)&&(r=[],i=(n=t.remuxResult).audio,n=n.video,i&&s(r,i),n&&s(r,n),e.postMessage({event:"transmuxComplete",data:t},r))}function s(e,t){t.data1&&e.push(t.data1.buffer),t.data2&&e.push(t.data2.buffer)}function c(t,e,r){e.forEach(function(e){u(t,e)}),t.postMessage({event:"flush",data:r})}},"./src/demux/transmuxer.ts":function(e,t,r){r.r(t),r.d(t,"default",function(){return c}),r.d(t,"isPromise",function(){return f}),r.d(t,"TransmuxConfig",function(){return A}),r.d(t,"TransmuxState",function(){return g});var v,l=r("./src/events.ts"),d=r("./src/errors.ts"),i=r("./src/crypt/decrypter.ts"),t=r("./src/demux/aacdemuxer.ts"),m=r("./src/demux/mp4demuxer.ts"),n=r("./src/demux/tsdemuxer.ts"),s=r("./src/demux/mp3demuxer.ts"),a=r("./src/remux/mp4-remuxer.ts"),y=r("./src/remux/passthrough-remuxer.ts"),o=r("./src/demux/chunk-cache.ts"),b=r("./src/utils/mp4-tools.ts"),E=r("./src/utils/logger.ts");try{v=self.performance.now.bind(self.performance)}catch(e){E.logger.debug("Unable to use Performance API on this environment"),v=self.Date.now}var T=[{demux:n.default,remux:a.default},{demux:m.default,remux:y.default},{demux:t.default,remux:a.default},{demux:s.default,remux:a.default}],u=1024,c=(T.forEach(function(e){e=e.demux;u=Math.max(u,e.minProbeByteLength)}),(r=h.prototype).configure=function(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()},r.push=function(e,t,r,i){var n=this,s=r.transmuxing,e=(s.executeStart=v(),new Uint8Array(e)),a=this.cache,o=this.config,l=this.currentTransmuxState,d=this.transmuxConfig,t=(i&&(this.currentTransmuxState=i),u=null,u=0>4){if((w=E+5+e[E+4])===E+188)continue}else w=E+4;switch(S){case l:T&&(d&&(n=F(d))&&this.parseAVCPES(n,!1),d={data:[],size:0}),d&&(d.data.push(e.subarray(w,E+188)),d.size+=E+188-w);break;case u:T&&(h&&(n=F(h))&&(a.isAAC?this.parseAACPES(n):this.parseMPEGPES(n)),h={data:[],size:0}),h&&(h.data.push(e.subarray(w,E+188)),h.size+=E+188-w);break;case c:T&&(f&&(n=F(f))&&this.parseID3PES(n),f={data:[],size:0}),f&&(f.data.push(e.subarray(w,E+188)),f.size+=E+188-w);break;case 0:T&&(w+=e[w]+1),p=this._pmtId=(31&(R=e)[(y=w)+10])<<8|R[y+11];break;case p:T&&(w+=e[w]+1);var R=function(e,t,r,i){var 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;var l=t[7],d=(192&l&&(i=536870912*(14&t[9])+4194304*(255&t[10])+16384*(254&t[11])+128*(255&t[12])+(254&t[13])/2,64&l?54e5=e[r-1].pts)e.push(t);else for(var i=r-1;0<=i;i--)if(t.ptst)return i;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(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.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:"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)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var e=this.subtitleTrackController;return!!e&&e.subtitleDisplay},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(e){this.config.lowLatencyMode=e}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}]),o(r,t);var l=E;function E(e){void 0===e&&(e={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new b.EventEmitter,this._autoLevelCapping=void 0,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null;var t=this.config=Object(y.mergeConfig)(E.DefaultConfig,e),e=(this.userConfig=e,Object(v.enableLogs)(t.debug),this._autoLevelCapping=-1,t.progressive&&Object(y.enableStreamingMode)(t),t.abrController),r=t.bufferController,i=t.capLevelController,n=t.fpsController,e=this.abrController=new e(this),r=this.bufferController=new r(this),i=this.capLevelController=new i(this),n=new n(this),s=new c.default(this),a=new h.default(this),o=new f.default(this),l=this.levelController=new g.default(this),d=new p.FragmentTracker(this),u=this.streamController=new m.default(this,d),l=(i.setStreamController(u),n.setStreamController(u),[l,u]),u=(this.networkControllers=l,[s,a,e,r,i,n,o,d]);this.audioTrackController=this.createController(t.audioTrackController,null,l),this.createController(t.audioStreamController,d,l),this.subtitleTrackController=this.createController(t.subtitleTrackController,null,l),this.createController(t.subtitleStreamController,d,l),this.createController(t.timelineController,null,u),this.emeController=this.createController(t.emeController,null,u),this.cmcdController=this.createController(t.cmcdController,null,u),this.latencyController=this.createController(A.default,null,u),this.coreComponents=u}l.defaultConfig=void 0},"./src/is-supported.ts":function(e,t,r){r.r(t),r.d(t,"isSupported",function(){return s}),r.d(t,"changeTypeSupported",function(){return a});var i=r("./src/utils/mediasource-helper.ts");function n(){return self.SourceBuffer||self.WebKitSourceBuffer}function s(){var e=Object(i.getMediaSource)();if(!e)return!1;var t=n(),e=e&&"function"==typeof e.isTypeSupported&&e.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),t=!t||t.prototype&&"function"==typeof t.prototype.appendBuffer&&"function"==typeof t.prototype.remove;return!!e&&!!t}function a(){var e=n();return"function"==typeof(null==e||null==(e=e.prototype)?void 0:e.changeType)}},"./src/loader/fragment-loader.ts":function(e,t,r){r.r(t),r.d(t,"default",function(){return l}),r.d(t,"LoadError",function(){return g});var i=r("./src/polyfills/number.ts"),h=r("./src/errors.ts");function n(e){var r="function"==typeof Map?new Map:void 0;return(n=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(e))return r.get(e);r.set(e,t)}function t(){return s(e,arguments,o(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),a(t,e)})(e)}function s(e,t,r){return(s=function(){if("undefined"==typeof Reflect||!Reflect.construct)return;if(Reflect.construct.sham)return;if("function"==typeof Proxy)return 1;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),1}catch(e){return}}()?Reflect.construct:function(e,t,r){var i=[null],t=(i.push.apply(i,t),new(Function.bind.apply(e,i)));return r&&a(t,r.prototype),t}).apply(null,arguments)}function a(e,t){return(a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function o(e){return(o=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var f=Math.pow(2,17),l=((t=d.prototype).destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},t.abort=function(){this.loader&&this.loader.abort()},t.load=function(a,o){var l=this,e=a.url;if(!e)return Promise.reject(new g({type:h.ErrorTypes.NETWORK_ERROR,details:h.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:a,networkDetails:null},"Fragment does not have a "+(e?"part list":"url")));this.abort();var r=this.config,d=r.fLoader,u=r.loader;return new Promise(function(n,i){l.loader&&l.loader.destroy();var s=l.loader=a.loader=new(d||u)(r),e=A(a),t={timeout:r.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:r.fragLoadingMaxRetryTimeout,highWaterMark:f};a.stats=s.stats,s.load(e,t,{onSuccess:function(e,t,r,i){l.resetLoader(a,s),n({frag:a,part:null,payload:e.data,networkDetails:i})},onError:function(e,t,r){l.resetLoader(a,s),i(new g({type:h.ErrorTypes.NETWORK_ERROR,details:h.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:a,response:e,networkDetails:r}))},onAbort:function(e,t,r){l.resetLoader(a,s),i(new g({type:h.ErrorTypes.NETWORK_ERROR,details:h.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:a,networkDetails:r}))},onTimeout:function(e,t,r){l.resetLoader(a,s),i(new g({type:h.ErrorTypes.NETWORK_ERROR,details:h.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:a,networkDetails:r}))},onProgress:function(e,t,r,i){o&&o({frag:a,part:null,payload:r,networkDetails:i})}})})},t.loadPart=function(a,o,l){var d=this,r=(this.abort(),this.config),u=r.fLoader,c=r.loader;return new Promise(function(n,i){d.loader&&d.loader.destroy();var s=d.loader=a.loader=new(u||c)(r),e=A(a,o),t={timeout:r.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:r.fragLoadingMaxRetryTimeout,highWaterMark:f};o.stats=s.stats,s.load(e,t,{onSuccess:function(e,t,r,i){d.resetLoader(a,s),d.updateStatsFromPart(a,o);e={frag:a,part:o,payload:e.data,networkDetails:i};l(e),n(e)},onError:function(e,t,r){d.resetLoader(a,s),i(new g({type:h.ErrorTypes.NETWORK_ERROR,details:h.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:a,part:o,response:e,networkDetails:r}))},onAbort:function(e,t,r){a.stats.aborted=o.stats.aborted,d.resetLoader(a,s),i(new g({type:h.ErrorTypes.NETWORK_ERROR,details:h.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:a,part:o,networkDetails:r}))},onTimeout:function(e,t,r){d.resetLoader(a,s),i(new g({type:h.ErrorTypes.NETWORK_ERROR,details:h.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:a,part:o,networkDetails:r}))}})})},t.updateStatsFromPart=function(e,t){var r=e.stats,i=t.stats,n=i.total,e=(r.loaded+=i.loaded,n?(n=((e=Math.round(e.duration/t.duration))-(t=Math.min(Math.round(r.loaded/n),e)))*Math.round(r.loaded/t),r.total=r.loaded+n):r.total=Math.max(r.loaded,r.total),r.loading),t=i.loading;e.start?e.first+=t.first-t.start:(e.start=t.start,e.first=t.first),e.end=t.end},t.resetLoader=function(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()},d);function d(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}function A(e,t){var r=(t=void 0===t?null:t)||e,e={frag:e,part:t,responseType:"arraybuffer",url:r.url,headers:{},rangeStart:0,rangeEnd:0},t=r.byteRangeStartOffset,r=r.byteRangeEndOffset;return Object(i.isFiniteNumber)(t)&&Object(i.isFiniteNumber)(r)&&(e.rangeStart=t,e.rangeEnd=r),e}u=n(Error),r=u,(t=c).prototype=Object.create(r.prototype),a(t.prototype.constructor=t,r);var u,g=c;function c(e){for(var t,r=arguments.length,i=new Array(1>8*(15-r)&255;return t},r.setDecryptDataFromLevelKey=function(e,t){var r=e;return"AES-128"===(null==e?void 0:e.method)&&e.uri&&!e.iv&&((r=o.LevelKey.fromURI(e.uri)).method=e.method,r.iv=this.createInitializationVector(t),r.keyFormat="identity"),r},r.setElementaryStreamInfo=function(e,t,r,i,n,s){void 0===s&&(s=!1);var a=this.elementaryStreams,o=a[e];o?(o.startPTS=Math.min(o.startPTS,t),o.endPTS=Math.max(o.endPTS,r),o.startDTS=Math.min(o.startDTS,i),o.endDTS=Math.max(o.endDTS,n)):a[e]={startPTS:t,endPTS:r,startDTS:i,endDTS:n,partial:s}},r.clearElementaryStreamInfo=function(){var e=this.elementaryStreams;e[i.AUDIO]=null,e[i.VIDEO]=null,e[i.AUDIOVIDEO]=null},h(y,[{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&&a.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:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(null===this.programDateTime)return null;if(!Object(n.isFiniteNumber)(this.programDateTime))return null;var e=Object(n.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+1e3*e}},{key:"encrypted",get:function(){var e;return!(null==(e=this.decryptdata)||!e.keyFormat||!this.decryptdata.uri)}}]),y),m=(d(v,f=g),h(v,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var e=this.elementaryStreams;return!!(e.audio||e.video||e.audiovideo)}}]),v);function v(e,t,r,i,n){(r=f.call(this,r)||this).fragOffset=0,r.duration=0,r.gap=!1,r.independent=!1,r.relurl=void 0,r.fragment=void 0,r.index=void 0,r.stats=new l.LoadStats,r.duration=e.decimalFloatingPoint("DURATION"),r.gap=e.bool("GAP"),r.independent=e.bool("INDEPENDENT"),r.relurl=e.enumeratedString("URI"),r.fragment=t,r.index=i;t=e.enumeratedString("BYTERANGE");return t&&r.setByteRange(t,n),n&&(r.fragOffset=n.fragOffset+n.duration),r}function y(e,t){return(t=A.call(this,t)||this)._decryptdata=null,t.rawProgramDateTime=null,t.programDateTime=null,t.tagList=[],t.duration=0,t.sn=0,t.levelkey=void 0,t.type=void 0,t.loader=null,t.level=-1,t.cc=0,t.startPTS=void 0,t.endPTS=void 0,t.appendedPTS=void 0,t.startDTS=void 0,t.endDTS=void 0,t.start=0,t.deltaPTS=void 0,t.maxStartPTS=void 0,t.minEndPTS=void 0,t.stats=new l.LoadStats,t.urlId=0,t.data=void 0,t.bitrateTest=!1,t.title=null,t.initSegment=null,t.type=e,t}function b(e){var t;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=((t={})[i.AUDIO]=null,t[i.VIDEO]=null,t[i.AUDIOVIDEO]=null,t),this.baseurl=e}},"./src/loader/key-loader.ts":function(e,t,r){r.r(t),r.d(t,"default",function(){return n});var a=r("./src/events.ts"),i=r("./src/errors.ts"),o=r("./src/utils/logger.ts"),n=((t=s.prototype)._registerListeners=function(){this.hls.on(a.Events.KEY_LOADING,this.onKeyLoading,this)},t._unregisterListeners=function(){this.hls.off(a.Events.KEY_LOADING,this.onKeyLoading)},t.destroy=function(){for(var e in this._unregisterListeners(),this.loaders){e=this.loaders[e];e&&e.destroy()}this.loaders={}},t.onKeyLoading=function(e,t){var r,i,t=t.frag,n=t.type,s=this.loaders[n];t.decryptdata?(r=t.decryptdata.uri)!==this.decrypturl||null===this.decryptkey?(i=this.hls.config,s&&(o.logger.warn("abort previous key loader for type:"+n),s.abort()),r?(s=i.loader,n=t.loader=this.loaders[n]=new s(i),this.decrypturl=r,this.decryptkey=null,s={url:r,frag:t,responseType:"arraybuffer"},r={timeout:i.fragLoadingTimeOut,maxRetry:0,retryDelay:i.fragLoadingRetryDelay,maxRetryDelay:i.fragLoadingMaxRetryTimeout,highWaterMark:0},i={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)},n.load(s,r,i)):o.logger.warn("key uri is falsy")):this.decryptkey&&(t.decryptdata.key=this.decryptkey,this.hls.trigger(a.Events.KEY_LOADED,{frag:t})):o.logger.warn("Missing decryption data on fragment in onKeyLoading")},t.loadsuccess=function(e,t,r){r=r.frag;r.decryptdata?(this.decryptkey=r.decryptdata.key=new Uint8Array(e.data),r.loader=null,delete this.loaders[r.type],this.hls.trigger(a.Events.KEY_LOADED,{frag:r})):o.logger.error("after key load, decryptdata unset")},t.loaderror=function(e,t){var t=t.frag,r=t.loader;r&&r.abort(),delete this.loaders[t.type],this.hls.trigger(a.Events.ERROR,{type:i.ErrorTypes.NETWORK_ERROR,details:i.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:t,response:e})},t.loadtimeout=function(e,t){var t=t.frag,r=t.loader;r&&r.abort(),delete this.loaders[t.type],this.hls.trigger(a.Events.ERROR,{type:i.ErrorTypes.NETWORK_ERROR,details:i.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:t})},s);function s(e){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=e,this._registerListeners()}},"./src/loader/level-details.ts":function(e,t,r){r.r(t),r.d(t,"LevelDetails",function(){return s});var i=r("./src/polyfills/number.ts");function n(e,t){for(var r=0;re.endSN||0>24&255,o[1]=t>>16&255,o[2]=t>>8&255,o[3]=255&t,o.set(e,4),s=0,t=8;s>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+s)),t=Math.floor(t%(1+s)),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),n=0;n>>8&255),i.push(255&r),i=i.concat(Array.prototype.slice.call(t));for(s=0;s>>8&255),n.push(255&r),n=n.concat(Array.prototype.slice.call(t));var a=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(n))),o=e.width,l=e.height,d=e.pixelRatio[0],u=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,o>>8&255,255&o,l>>8&255,255&l,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]),a,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([d>>24,d>>16&255,d>>8&255,255&d,u>>24,u>>16&255,u>>8&255,255&u])))},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,n=Math.floor(r/(1+s)),r=Math.floor(r%(1+s));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,n>>24,n>>16&255,n>>8&255,255&n,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,n=Math.floor(t/(1+s)),t=Math.floor(t%(1+s));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,n>>24,n>>16&255,n>>8&255,255&n,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,n,s,a,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,n>>>24&255,n>>>16&255,n>>>8&255,255&n,s.isLeading<<2|s.dependsOn,s.isDependedOn<<6|s.hasRedundancy<<4|s.paddingValue<<1|s.isNonSync,61440&s.degradPrio,15&s.degradPrio,a>>>24&255,a>>>16&255,a>>>8&255,255&a],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(){}r.types=void 0,r.HDLR_TYPES=void 0,r.STTS=void 0,r.STSC=void 0,r.STCO=void 0,r.STSZ=void 0,r.VMHD=void 0,r.SMHD=void 0,r.STSD=void 0,r.FTYP=void 0,r.DINF=void 0,t.default=r},"./src/remux/mp4-remuxer.ts":function(e,t,r){r.r(t),r.d(t,"default",function(){return i}),r.d(t,"normalizePts",function(){return Z});var h=r("./src/polyfills/number.ts"),M=r("./src/remux/aac-helper.ts"),W=r("./src/remux/mp4-generator.ts"),K=r("./src/events.ts"),Y=r("./src/errors.ts"),Q=r("./src/utils/logger.ts"),T=r("./src/types/loader.ts"),z=r("./src/utils/timescale-conversion.ts");function q(){return(q=Object.assign||function(e){for(var t=1;tm.pts&&(A=Math.max(Math.min(A,m.pts-m.dts),-18e3)),m.dtsNumber.MAX_SAFE_INTEGER?1/0:e},r.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},r.decimalFloatingPoint=function(e){return parseFloat(this[e])},r.optionalFloat=function(e,t){e=this[e];return e?parseFloat(e):t},r.enumeratedString=function(e){return this[e]},r.bool=function(e){return"YES"===this[e]},r.decimalResolution=function(e){e=i.exec(this[e]);if(null!==e)return{width:parseInt(e[1],10),height:parseInt(e[2],10)}},a.parseAttrList=function(e){var t,r={};for(n.lastIndex=0;null!==(t=n.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},a);function a(e){for(var t in e="string"==typeof e?a.parseAttrList(e):e)e.hasOwnProperty(t)&&(this[t]=e[t])}},"./src/utils/binary-search.ts":function(e,t,r){r.r(t),t.default={search:function(e,t){for(var r,i,n=0,s=e.length-1;n<=s;){var a=t(i=e[r=(n+s)/2|0]);if(0=r.start(i)&&t<=r.end(i))return!0}catch(e){}return!1},a.bufferInfo=function(e,t,r){try{if(e){for(var i=a.getBuffered(e),n=[],s=0;ss&&(i[a-1].end=e[n].end):i.push(e[n])):i.push(e[n])}else i=e;for(var o,l=0,d=t,u=t,c=0;c=e&&i.logger.log(this.time+" ["+e+"] "+t)},k),p=((r=D.prototype).reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},r.setStyles=function(e){for(var t=["foreground","underline","italics","background","flash"],r=0;ra&&(this.logger.log(d.DEBUG,"Too large cursor position "+this.pos),this.pos=a)},r.moveCursor=function(e){var t=this.pos+e;if(1=a?this.logger.log(d.ERROR,"Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!"):(this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1))},r.clearFromPos=function(e){for(var t=e;t ("+l([a,o])+")"),!(r=(r=(r=(r=this.parseCmd(a,o))?r:this.parseMidrow(a,o))||this.parsePAC(a,o))||this.parseBackgroundAttributes(a,o))&&(i=this.parseChars(a,o))&&((s=this.currentChannel)&&0r.startCC||e&&e.cc=this.minWeight_},r.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},r.destroy=function(){},t.default=i},"./src/utils/ewma.ts":function(e,t,r){function i(e,t,r){void 0===t&&(t=0),void 0===r&&(r=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=r}r.r(t),(r=i.prototype).sample=function(e,t){var r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e},r.getTotalWeight=function(){return this.totalWeight_},r.getEstimate=function(){if(this.alpha_){var e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_},t.default=i},"./src/utils/fetch-loader.ts":function(e,t,r){r.r(t),r.d(t,"fetchSupported",function(){return l});var c=r("./src/polyfills/number.ts"),i=r("./src/loader/load-stats.ts"),d=r("./src/demux/chunk-cache.ts");function n(e){var r="function"==typeof Map?new Map:void 0;return(n=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(e))return r.get(e);r.set(e,t)}function t(){return s(e,arguments,o(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),a(t,e)})(e)}function s(e,t,r){return(s=function(){if("undefined"==typeof Reflect||!Reflect.construct)return;if(Reflect.construct.sham)return;if("function"==typeof Proxy)return 1;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),1}catch(e){return}}()?Reflect.construct:function(e,t,r){var i=[null],t=(i.push.apply(i,t),new(Function.bind.apply(e,i)));return r&&a(t,r.prototype),t}).apply(null,arguments)}function a(e,t){return(a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function o(e){return(o=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function h(){return(h=Object.assign||function(e){for(var t=1;t=a&&o(n,s,l.flush(),i)):o(n,s,e,i),r()}).catch(function(){return Promise.reject()})}()};r=u;function u(e){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=e.fetchSetup||f,this.controller=new self.AbortController,this.stats=new i.LoadStats}function f(e,t){return new self.Request(e.url,t)}A=n(Error),p=A,(g=v).prototype=Object.create(p.prototype),a(g.prototype.constructor=g,p);var A,g,p,m=v;function v(e,t,r){return(e=A.call(this,e)||this).code=void 0,e.details=void 0,e.code=t,e.details=r,e}t.default=r},"./src/utils/imsc1-ttml-parser.ts":function(e,t,r){r.r(t),r.d(t,"IMSC1_CODEC",function(){return i}),r.d(t,"parseIMSC1",function(){return n});var a=r("./src/utils/mp4-tools.ts"),o=r("./src/utils/vttparser.ts"),f=r("./src/utils/vttcue.ts"),l=r("./src/demux/id3.ts"),d=r("./src/utils/timescale-conversion.ts"),A=r("./src/utils/webvtt-parser.ts");function g(){return(g=Object.assign||function(e){for(var t=1;t"):n)})}(e,"debug","log","info","warn","error");try{s.log()}catch(e){s=i}}else s=i}var o=i},"./src/utils/mediakeys-helper.ts":function(e,t,r){r.r(t),r.d(t,"KeySystems",function(){return i}),r.d(t,"requestMediaKeySystemAccess",function(){return n}),(r=i=i||{}).WIDEVINE="com.widevine.alpha",r.PLAYREADY="com.microsoft.playready";var i,n="undefined"!=typeof self&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null},"./src/utils/mediasource-helper.ts":function(e,t,r){function i(){return self.MediaSource||self.WebKitMediaSource}r.r(t),r.d(t,"getMediaSource",function(){return i})},"./src/utils/mp4-tools.ts":function(e,t,r){r.r(t),r.d(t,"bin2str",function(){return u}),r.d(t,"readUint16",function(){return h}),r.d(t,"readUint32",function(){return m}),r.d(t,"writeUint32",function(){return a}),r.d(t,"findBox",function(){return v}),r.d(t,"parseSegmentIndex",function(){return y}),r.d(t,"parseInitSegment",function(){return n}),r.d(t,"getStartDTS",function(){return o}),r.d(t,"getDuration",function(){return l}),r.d(t,"computeRawDurationFromSamples",function(){return b}),r.d(t,"offsetStartDTS",function(){return c}),r.d(t,"segmentValidRange",function(){return f}),r.d(t,"appendUint8Array",function(){return A});var i=r("./src/utils/typed-array.ts"),p=r("./src/loader/fragment.ts"),s=Math.pow(2,32)-1,d=[].push;function u(e){return String.fromCharCode.apply(null,e)}function h(e,t){"data"in e&&(t+=e.start,e=e.data);e=e[t]<<8|e[t+1];return e<0?65536+e:e}function m(e,t){"data"in e&&(t+=e.start,e=e.data);e=e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3];return e<0?4294967296+e:e}function a(e,t,r){"data"in e&&(t+=e.start,e=e.data),e[t]=r>>24,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r}function v(e,t){var r,i,n=[];if(!t.length)return n;for(var s=("data"in e?(r=e.data,i=e.start,e.end):(i=0,(r=e).byteLength)),a=i;a>>31)return console.warn("SIDX has hierarchical references (not supported)"),null;u=m(i,d);d+=4,r.push({referenceSize:c,subsegmentDuration:u,info:{duration:u/s,start:a,end:a+c-1}}),a+=c,n=d+=4}return{earliestPresentationTime:0,timescale:s,version:e,referencesCount:o,references:r,moovEndOffset:t}}function n(e){for(var r=[],t=v(e,["moov","trak"]),i=0;ie)&&(this.startTime=e),this.endTime=t,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)},r.reset=function(){this.cueRanges=[],this.startTime=null};var i=n;function n(e,t){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=e,this.trackName=t}},"./src/utils/texttrack-utils.ts":function(e,t,r){r.r(t),r.d(t,"sendAddTrackEvent",function(){return i}),r.d(t,"addCueToTrack",function(){return s}),r.d(t,"clearCurrentCues",function(){return a}),r.d(t,"removeCuesInRange",function(){return o}),r.d(t,"getCuesInRange",function(){return l});var n=r("./src/utils/logger.ts");function i(e,t){var r;try{r=new Event("addtrack")}catch(e){(r=document.createEvent("Event")).initEvent("addtrack",!1,!1)}r.track=e,t.dispatchEvent(r)}function s(e,t){var r=e.mode;if("disabled"===r&&(e.mode="hidden"),e.cues&&!e.cues.getCueById(t.id))try{if(e.addCue(t),!e.cues.getCueById(t.id))throw new Error("addCue is failed for: "+t)}catch(r){n.logger.debug("[texttrack-utils]: "+r);var i=new self.TextTrackCue(t.startTime,t.endTime,t.text);i.id=t.id,e.addCue(i)}"disabled"===r&&(e.mode=r)}function a(e){var t=e.mode;if("disabled"===t&&(e.mode="hidden"),e.cues)for(var r=e.cues.length;r--;)e.removeCue(e.cues[r]);"disabled"===t&&(e.mode=t)}function o(e,t,r){var i=e.mode;if("disabled"===i&&(e.mode="hidden"),e.cues&&0e[r].endTime)return-1;for(var i=0,n=r;i<=n;){var s=Math.floor((n+i)/2);if(te[s].startTime&&i=t&&o.endTime<=r)i.push(o);else if(o.startTime>r)return i}return i}},"./src/utils/time-ranges.ts":function(e,t,r){r.r(t),t.default={toString:function(e){for(var t="",r=e.length,i=0;i/gi,"\n")}(r=A.prototype).parse=function(e){var i=this;function t(){for(var e=0,t=f(t=i.buffer);e>>0).toString()};function w(e,t,r){return i(e.toString())+i(t.toString())+i(r)}function n(e,t,r,n,s,a,i,o){var l,d=new v.VTTParser,e=Object(y.utf8ArrayToStr)(new Uint8Array(e)).trim().replace(T,"\n").split("\n"),u=[],c=Object(b.toMpegTsClockFromTimescale)(t,r),h="00:00.000",f=0,A=0,g=!0,p=!1;d.oncue=function(e){var t=n[s],r=n.ccOffset,i=(f-c)/9e4,r=(null!=t&&t.new&&(void 0!==A?r=n.ccOffset=t.start:function(e,t){var r,i=e[s],n=e[i.prevCC];if(!n||!n.new&&i.new)return e.ccOffset=e.presentationOffset=i.start,i.new=!1;for(;null!=(r=n)&&r.new;)e.ccOffset+=i.start-n.start,i.new=!1,n=e[(i=n).prevCC];e.presentationOffset=t}(n,i)),i&&(r=i-n.presentationOffset),p&&(t=e.endTime-e.startTime,i=Object(E.normalizePts)(9e4*(e.startTime+r-A),9e4*a)/9e4,e.startTime=i,e.endTime=i+t),e.text.trim());e.text=decodeURIComponent(encodeURIComponent(r)),e.id||(e.id=w(e.startTime,e.endTime,r)),0=e.maxRetry||400<=t&&t<499?(o.logger.error(t+" while loading "+n.url),this.callbacks.onError({code:t,text:s.statusText},n,s)):(o.logger.warn(t+" while loading "+n.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,e.maxRetryDelay),a.retry++)):(self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),e.timeout))))},r.loadtimeout=function(){o.logger.warn("timeout while loading "+this.context.url);var e=this.callbacks;e&&(this.abortInternal(),e.onTimeout(this.stats,this.context,this.loader))},r.loadprogress=function(e){var t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)},r.getCacheAge=function(){var e,t=null;return t=this.loader&&n.test(this.loader.getAllResponseHeaders())?(e=this.loader.getResponseHeader("age"))?parseFloat(e):null:t},t.default=s}},i={},n.m=r,n.c=i,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/dist/",n(n.s="./src/hls.ts").default;function n(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,n),t.l=!0,t.exports}var r,i}())}))&&m.__esModule&&Object.prototype.hasOwnProperty.call(m,"default")?m.default:m;class Be extends b{constructor(e){super(),(this.player=e)._opt,this.hls=new x({}),this._initHls(),this._bindEvents(),this.player.debug.log("HlsDecoder","init")}destroy(){this.hls.destroy(),this.hls=null,this.player.debug.log("HlsDecoder","destroy")}_initHls(){this.hls.attachMedia(this.player.video.$videoElement)}_bindEvents(){const t=this.player,e=this.player.events["proxy"],r=this.hls,i=t.video.$videoElement;this.hls.on(x.Events.ERROR,(e,t)=>{if(t.fatal)switch(t.type){case x.ErrorTypes.NETWORK_ERROR:console.log("fatal network error encountered, try to recover"),this.hls.startLoad();break;case x.ErrorTypes.MEDIA_ERROR:console.log("fatal media error encountered, try to recover"),this.hls.recoverMediaError()}}),e(i,"timeupdate",e=>{this.hls&&(e=parseInt(e.timeStamp,10),t.handleRender(),console.log("hls.liveSyncPosition",r.liveSyncPosition),t.updateStats({ts:e}),t.emit(u.kBps,(r.bandwidthEstimate/8/1024).toFixed(2)),t.emit(u.videoTimeUpdate,e))}),this.hls.on(x.Events.MEDIA_ATTACHING,()=>{console.log("MEDIA_ATTACHING")}),this.hls.on(x.Events.MEDIA_ATTACHED,()=>{console.log("MEDIA_ATTACHED")}),this.hls.on(x.Events.MEDIA_DETACHING,()=>{console.log("MEDIA_DETACHING")}),this.hls.on(x.Events.MEDIA_DETACHED,()=>{console.log("MEDIA_DETACHED")}),this.hls.on(x.Events.BUFFER_RESET,()=>{console.log("BUFFER_RESET")}),this.hls.on(x.Events.BUFFER_CODECS,()=>{console.log("BUFFER_CODECS")}),this.hls.on(x.Events.BUFFER_CREATED,()=>{console.log("BUFFER_CREATED")}),this.hls.on(x.Events.BUFFER_APPENDING,()=>{console.log("BUFFER_APPENDING")}),this.hls.on(x.Events.BUFFER_APPENDED,()=>{console.log("BUFFER_APPENDED")}),this.hls.on(x.Events.BUFFER_EOS,()=>{console.log("fired when the stream is finished and we want to notify the media buffer that there will be no more data")}),this.hls.on(x.Events.BUFFER_FLUSHING,()=>{console.log("fired when the media buffer should be flushed")}),this.hls.on(x.Events.BUFFER_FLUSHED,()=>{console.log("fired when the media buffer has been flushed")}),this.hls.on(x.Events.MANIFEST_LOADING,()=>{console.log("MANIFEST_LOADING 开始加载playlist m3u8资源")}),this.hls.on(x.Events.MANIFEST_LOADED,(e,t)=>{console.log("MANIFEST_LOADED playlist m3u8文件加载完成",t)}),this.hls.on(x.Events.MANIFEST_PARSED,()=>{console.log("MANIFEST_PARSED playlist m3u8解析完成"),t._times.demuxStart||(t._times.demuxStart=l())}),this.hls.on(x.Events.LEVEL_LOADING,()=>{console.log("LEVEL_LOADING 加载特定码率的m3u8文件")}),this.hls.on(x.Events.LEVEL_LOADED,(e,t)=>{console.log("LEVEL_LOADED 特定码率的m3u8文件解析完成,拿到该码率对应的ts列表")}),this.hls.on(x.Events.FRAG_LOADING,()=>{console.log("FRAG_LOADING 开始加载某个ts分片文件,开始根据ts片下载时间预估带宽")}),this.hls.on(x.Events.FRAG_LOADED,()=>{console.log("FRAG_LOADED ts分片文件加载成功,开始转码"),t._times.decodeStart||(t._times.decodeStart=l())}),this.hls.on(x.Events.BUFFER_APPENDING,()=>{console.log("BUFFER_APPENDING 视频流赋给video标签"),t._times.videoStart||(t._times.videoStart=l(),t.handlePlayToRenderTimes())}),this.hls.on(x.Events.FRAG_LOADED,()=>{console.log("FRAG_LOADED")}),this.hls.on(x.Events.FRAG_DECRYPTED,()=>{console.log(" fired when a fragment decryption is completed")}),this.hls.on(x.Events.KEY_LOADING,()=>{console.log(" fired when a decryption key loading starts")}),this.hls.on(x.Events.KEY_LOADING,()=>{console.log(" fired when a fragment decryption is completed")}),this.hls.on(x.Events.FPS_DROP,e=>{console.log("FPS_DROP",e)}),this.hls.on(x.Events.FPS_DROP_LEVEL_CAPPING,e=>{console.log("FPS_DROP_LEVEL_CAPPING",e)})}loadSource(r){return new Promise((e,t)=>{this.hls.on(x.Events.MEDIA_ATTACHED,()=>{this.hls.loadSource(r),e()})})}}class _e extends b{constructor(e){super(),this.player=e,this.rtcPeerConnection=null,this.videoStream=null,this._initRtcPeerConnection(),this.player.debug.log("WebrtcDecoder","init")}destroy(){this.rtcPeerConnection&&(this.rtcPeerConnection.close(),this.rtcPeerConnection=null),this.videoStream=null,this.player.video.$videoElement.srcObject=null,this.player.debug.log("WebrtcDecoder","destroy")}_initRtcPeerConnection(){const t=new RTCPeerConnection,r=this.player;t.addTransceiver("video",{direction:"recvonly"}),t.addTransceiver("audio",{direction:"recvonly"}),t.onsignalingstatechange=e=>{console.log("onsignalingstatechange",e)},t.oniceconnectionstatechange=e=>{console.log("oniceconnectionstatechange",t.iceConnectionState)},t.onicecandidate=e=>{console.log("onicecandidate",e)},t.ontrack=e=>{const t=r.video.$videoElement;console.log("ontrack",e),"video"===e.track.kind&&(e=e.streams[0],t.srcObject=e,this.videoStream=e)},t.onconnectionstatechange=e=>{r.debug.log("webrtcLoader","sdp connect status "+t.connectionState),t.connectionState},this.rtcPeerConnection=t}loadSource(n){return new Promise((t,r)=>{const i=this.rtcPeerConnection;i.createOffer().then(e=>{i.setLocalDescription(e),e=e.sdp,fetch(n,{method:"POST",mode:"cors",cache:"no-cache",credentials:"include",redirect:"follow",referrerPolicy:"no-referrer",headers:{"Content-Type":"application/sdp"},body:e}).then(e=>{e.text().then(e=>{this.player.debug.log("webrtcLoader","getWebRtcRemoteSdp response"),i.setRemoteDescription(new RTCSessionDescription({type:"answer",sdp:e})),t()}).catch(()=>{r()})}).catch(e=>{console.error(e),r(e)})}).catch(e=>{r(e)})})}}class Fe extends b{constructor(e,t){super(),this.$container=e,this._opt=Object.assign({},M,t),this.debug=new ee(this),this._opt.isHls||this._opt.isWebrtc||(this._opt.useWCS&&(this._opt.useWCS="VideoEncoder"in window),this._opt.useMSE&&(this._opt.useMSE=window.MediaSource&&window.MediaSource.isTypeSupported(Q))),this._opt.useMSE?(this._opt.useWCS&&this.debug.log("Player","useWCS set true->false"),this._opt.forceNoOffscreen||this.debug.log("Player","forceNoOffscreen set false->true"),this._opt.useWCS=!1,this._opt.forceNoOffscreen=!0):this._opt.useWCS,this._opt.forceNoOffscreen||("undefined"==typeof OffscreenCanvas?(this._opt.forceNoOffscreen=!0,this._opt.useOffscreen=!1):this._opt.useOffscreen=!0),this._opt.hasAudio||(this._opt.operateBtns.audio=!1),this._opt.hasControl=this._hasControl(),this._loading=!1,this._playing=!1,this._hasLoaded=!1,this._checkHeartTimeout=null,this._checkLoadingTimeout=null,this._startBpsTime=null,this._isPlayingBeforePageHidden=!1,this._stats={buf:0,fps:0,abps:0,vbps:0,ts:0},this._times={playInitStart:"",playStart:"",streamStart:"",streamResponse:"",demuxStart:"",decodeStart:"",videoStart:"",playTimestamp:"",streamTimestamp:"",streamResponseTimestamp:"",demuxTimestamp:"",decodeTimestamp:"",videoTimestamp:"",allTimestamp:""},this._videoTimestamp=0,this._audioTimestamp=0,r=this,Object.defineProperty(r,"rect",{get:()=>{const e=r.$container.getBoundingClientRect();return e.width=Math.max(e.width,r.$container.clientWidth),e.height=Math.max(e.height,r.$container.clientHeight),e}}),["bottom","height","left","right","top","width"].forEach(e=>{Object.defineProperty(r,e,{get:()=>r.rect[e]})}),this.events=new te(this),this.video=new ne(this),this._opt.hasAudio&&(this.audio=new oe(this)),this.recorder=new pe(this),this._opt.isHls?(this.hls=new Be(this),this.loaded=!0):this._opt.isWebrtc?(this.webrtc=new _e(this),this.loaded=!0):this._onlyMseOrWcsVideo()?this.loaded=!0:this.decoderWorker=new me(this),this.stream=null,this.demux=null,this._opt.useWCS&&(this.webcodecsDecoder=new we(this)),this._opt.useMSE&&(this.mseDecoder=new Le(this)),this.control=new De(this),this.keepScreenOn=new Oe(this);var r,i=this;try{const s=()=>{i.emit(c.fullscreen,i.fullscreen),i.fullscreen&&!i._opt.useMSE||i.resize()};y.on("change",s),i.events.destroys.push(()=>{y.off("change",s)})}catch(i){}if(i.on(u.decoderWorkerInit,()=>{i.debug.log("player","has loaded"),i.loaded=!0}),i.on(u.play,()=>{i.loading=!1}),i.on(u.fullscreen,e=>{if(e)try{y.request(i.$container).then(()=>{}).catch(e=>{i.webFullscreen=!0})}catch(e){i.webFullscreen=!0}else try{y.exit().then(()=>{}).catch(()=>{i.webFullscreen=!1})}catch(e){i.webFullscreen=!1}}),i.on(u.webFullscreen,e=>{e?i.$container.classList.add("jessibuca-fullscreen-web"):i.$container.classList.remove("jessibuca-fullscreen-web")}),i.on(u.resize,()=>{i.video.resize()}),i._opt.debug){const a=[u.timeUpdate];Object.keys(u).forEach(t=>{i.on(u[t],e=>{a.includes(t)||i.debug.log("player events",u[t],e)})}),Object.keys(h).forEach(t=>{i.on(h[t],e=>{i.debug.log("player event error",h[t],e)})})}{var n=this;const{_opt:o,debug:l,events:{proxy:d}}=n;o.supportDblclickFullscreen&&d(n.$container,"dblclick",()=>{n.fullscreen=!n.fullscreen}),d(document,"visibilitychange",()=>{o.hiddenAutoPause&&(l.log("visibilitychange",document.visibilityState,n._isPlayingBeforePageHidden),"visible"===document.visibilityState?n._isPlayingBeforePageHidden&&n.play():(n._isPlayingBeforePageHidden=n.playing,n.playing&&n.pause()))}),d(window,"fullscreenchange",()=>{null!==n.keepScreenOn&&"visible"===document.visibilityState&&n.enableWakeLock()})}this._opt.useWCS&&this.debug.log("Player","use WCS"),this._opt.useMSE&&this.debug.log("Player","use MSE"),this._opt.useOffscreen&&this.debug.log("Player","use offscreen"),this._opt.isHls&&this.debug.log("Player","use hls"),this._opt.isWebrtc&&this.debug.log("Player","use webrtc"),this.debug.log("Player options",this._opt)}destroy(){this._loading=!1,this._playing=!1,this._hasLoaded=!1,this._times={playInitStart:"",playStart:"",streamStart:"",streamResponse:"",demuxStart:"",decodeStart:"",videoStart:"",playTimestamp:"",streamTimestamp:"",streamResponseTimestamp:"",demuxTimestamp:"",decodeTimestamp:"",videoTimestamp:"",allTimestamp:""},this.decoderWorker&&(this.decoderWorker.destroy(),this.decoderWorker=null),this.video&&(this.video.destroy(),this.video=null),this.audio&&(this.audio.destroy(),this.audio=null),this.stream&&(this.stream.destroy(),this.stream=null),this.recorder&&(this.recorder.destroy(),this.recorder=null),this.control&&(this.control.destroy(),this.control=null),this.webcodecsDecoder&&(this.webcodecsDecoder.destroy(),this.webcodecsDecoder=null),this.mseDecoder&&(this.mseDecoder.destroy(),this.mseDecoder=null),this.demux&&(this.demux.destroy(),this.demux=null),this.hls&&(this.hls.destroy(),this.hls=null),this.events&&(this.events.destroy(),this.events=null),this.clearCheckHeartTimeout(),this.clearCheckLoadingTimeout(),this.releaseWakeLock(),this.keepScreenOn=null,this.resetStats(),this._audioTimestamp=0,this._videoTimestamp=0,this.emit("destroy"),this.off(),this.debug.log("play","destroy end")}set fullscreen(e){f()?(this.emit(u.webFullscreen,e),setTimeout(()=>{this.updateOption({rotate:e?270:0}),this.resize()},10)):this.emit(u.fullscreen,e)}get fullscreen(){return document.isFullScreen||document.mozIsFullScreen||document.webkitIsFullScreen||this.webFullscreen}set webFullscreen(e){this.emit(u.webFullscreen,e)}get webFullscreen(){return this.$container.classList.contains("jessibuca-fullscreen-web")}set loaded(e){this._hasLoaded=e}get loaded(){return this._hasLoaded||this._opt.isHls||this._opt.isWebrtc}set playing(e){e&&(this.loading=!1),this.playing!==e&&(this._playing=e,this.emit(u.playing,e),this.emit(u.volumechange,this.volume),e?this.emit(u.play):this.emit(u.pause))}get playing(){return this._playing}get volume(){return this.audio&&this.audio.volume||0}set volume(e){this.audio&&this.audio.setVolume(e)}set loading(e){this.loading!==e&&(this._loading=e,this.emit(u.loading,this._loading))}get loading(){return this._loading}set recording(e){e?this.playing&&this.recorder.startRecord():this.recorder.stopRecordAndSave()}get recording(){return this.recorder&&this.recorder.recording}set audioTimestamp(e){null!==e&&(this._audioTimestamp=e)}get audioTimestamp(){return this._audioTimestamp}set videoTimestamp(e){null!==e&&(this._videoTimestamp=e,this._opt.useWCS||this._opt.useMSE||this.audioTimestamp&&this.videoTimestamp&&this.audio&&this.audio.emit(u.videoSyncAudio,{audioTimestamp:this.audioTimestamp,videoTimestamp:this.videoTimestamp,diff:this.audioTimestamp-this.videoTimestamp}))}get videoTimestamp(){return this._videoTimestamp}updateOption(e){this._opt=Object.assign({},this._opt,e)}init(){return new Promise((e,t)=>{this.stream||(this.stream=new fe(this)),this._opt.isHls?(this.hls||(this.hls=new Be(this),this.loaded=!0),e()):this._opt.isWebrtc?(this.webrtc||(this.webrtc=new _e(this),this.loaded=!0),e()):(this.demux||(this.demux=new Se(this)),this._opt.useWCS&&!this.webcodecsDecoder&&(this.webcodecsDecoder=new we(this)),this._opt.useMSE&&!this.mseDecoder&&(this.mseDecoder=new Le(this)),this.decoderWorker||this._onlyMseOrWcsVideo()?e():(this.decoderWorker=new me(this),this.once(u.decoderWorkerInit,()=>{e()})))})}play(r){return new Promise((e,t)=>{if(!r&&!this._opt.url)return t();this.loading=!0,this.playing=!1,this._times.playInitStart=l(),r=r||this._opt.url,this._opt.url=r,this.clearCheckHeartTimeout(),this.init().then(()=>{this._times.playStart=l(),this._opt.isNotMute&&this.mute(!1),this.webcodecsDecoder&&this.webcodecsDecoder.once(h.webcodecsH265NotSupport,()=>{this.emit(h.webcodecsH265NotSupport),this._opt.autoWasm||this.emit(u.error,h.webcodecsH265NotSupport)}),this.mseDecoder&&this.mseDecoder.once(h.mediaSourceH265NotSupport,()=>{this.emit(h.mediaSourceH265NotSupport),this._opt.autoWasm||this.emit(u.error,h.mediaSourceH265NotSupport)}),this.enableWakeLock(),this.checkLoadingTimeout(),this.stream.once(h.fetchError,e=>{t(e)}),this.stream.once(h.websocketError,e=>{t(e)}),this.stream.once(h.hlsError,e=>{t(e)}),this.stream.once(u.streamSuccess,()=>{e(),this._times.streamResponse=l(),this.video.play()}),this.stream.fetchStream(r)}).catch(e=>{t(e)})})}close(){return new Promise((e,t)=>{this._close().then(()=>{this.video.clearView(),e()})})}_close(){return new Promise((e,t)=>{this.stream&&(this.stream.destroy(),this.stream=null),this.demux&&(this.demux.destroy(),this.demux=null),this.decoderWorker&&(this.decoderWorker.destroy(),this.decoderWorker=null),this.webcodecsDecoder&&(this.webcodecsDecoder.destroy(),this.webcodecsDecoder=null),this.mseDecoder&&(this.mseDecoder.destroy(),this.mseDecoder=null),this.hls&&(this.hls.destroy(),this.hls=null),this.webrtc&&(this.webrtc.destroy(),this.webrtc=null),this.clearCheckHeartTimeout(),this.clearCheckLoadingTimeout(),this.playing=!1,this.loading=!1,this.recording=!1,this.audio&&this.audio.pause(),this.video&&this.video.pause(),this.releaseWakeLock(),this.resetStats(),this._audioTimestamp=0,this._videoTimestamp=0,this._times={playInitStart:"",playStart:"",streamStart:"",streamResponse:"",demuxStart:"",decodeStart:"",videoStart:"",playTimestamp:"",streamTimestamp:"",streamResponseTimestamp:"",demuxTimestamp:"",decodeTimestamp:"",videoTimestamp:"",allTimestamp:""},setTimeout(()=>{e()},0)})}pause(e){return e?this.close():this._close()}mute(e){this.audio&&this.audio.mute(e)}resize(){this.video.resize()}startRecord(e,t){this.recording||(this.recorder.setFileName(e,t),this.recording=!0)}stopRecordAndSave(){this.recording&&(this.recording=!1)}_hasControl(){let e=!1,t=!1;return Object.keys(this._opt.operateBtns).forEach(e=>{this._opt.operateBtns[e]&&(t=!0)}),e=this._opt.showBandwidth||this._opt.text||t?!0:e}_onlyMseOrWcsVideo(){return!1===this._opt.hasAudio&&(this._opt.useMSE||this._opt.useWCS&&!this._opt.useOffscreen)}useWasmDecode(){return!1===this._opt.useMSE&&!1===this._opt.useWCS}canVideoTrackWritter(){var e=this._opt;return!e.isHls&&!e.isWebrtc&&(e.useWCS&&!e.useOffscreen&&e.wcsUseVideoRender||this.useWasmDecode())}checkHeart(){this.clearCheckHeartTimeout(),this.checkHeartTimeout()}checkHeartTimeout(){this._checkHeartTimeout=setTimeout(()=>{this.pause(!1).then(()=>{this.emit(u.timeout,u.delayTimeout),this.emit(u.delayTimeout)})},1e3*this._opt.heartTimeout)}clearCheckHeartTimeout(){this._checkHeartTimeout&&(clearTimeout(this._checkHeartTimeout),this._checkHeartTimeout=null)}checkLoadingTimeout(){this._checkLoadingTimeout=setTimeout(()=>{this.pause(!1).then(()=>{this.emit(u.timeout,u.loadingTimeout),this.emit(u.loadingTimeout)})},1e3*this._opt.loadingTimeout)}clearCheckLoadingTimeout(){this._checkLoadingTimeout&&(clearTimeout(this._checkLoadingTimeout),this._checkLoadingTimeout=null)}handleRender(){this.loading&&(this.emit(u.start),this.loading=!1,this.clearCheckLoadingTimeout()),this.playing||(this.playing=!0),this.checkHeart()}updateStats(e){e=e||{},this._startBpsTime||(this._startBpsTime=l()),o(e.ts)&&(this._stats.ts=e.ts),o(e.buf)&&(this._stats.buf=e.buf),e.fps&&(this._stats.fps+=1),e.abps&&(this._stats.abps+=e.abps),e.vbps&&(this._stats.vbps+=e.vbps);e=l();e-this._startBpsTime<1e3||(this.emit(u.stats,this._stats),this.emit(u.performance,function(e){let t=0;return 24<=e?t=2:15<=e&&(t=1),t}(this._stats.fps)),this._stats.fps=0,this._stats.abps=0,this._stats.vbps=0,this._startBpsTime=e)}resetStats(){this._startBpsTime=null,this._stats={buf:0,fps:0,abps:0,vbps:0,ts:0}}enableWakeLock(){this._opt.keepScreenOn&&this.keepScreenOn.enable()}releaseWakeLock(){this._opt.keepScreenOn&&this.keepScreenOn.disable()}handlePlayToRenderTimes(){const e=this._times;e.playTimestamp=e.playStart-e.playInitStart,e.streamTimestamp=e.streamStart-e.playStart,e.streamResponseTimestamp=e.streamResponse-e.streamStart,e.demuxTimestamp=e.demuxStart-e.streamResponse,e.decodeTimestamp=e.decodeStart-e.demuxStart,e.videoTimestamp=e.videoStart-e.decodeStart,e.allTimestamp=e.videoStart-e.playInitStart,this.emit(u.playToRenderTimes,e)}}class Pe extends b{constructor(e){super();let t=e,r=e.container;if(!(r="string"==typeof e.container?document.querySelector(e.container):r))throw new Error("Jessibuca need container option");r.classList.add("jessibuca-container"),delete t.container,o(t.videoBuffer)&&(t.videoBuffer=1e3*Number(t.videoBuffer)),o(t.timeout)&&(n(t.loadingTimeout)&&(t.loadingTimeout=t.timeout),n(t.heartTimeout)&&(t.heartTimeout=t.timeout)),this._opt=t,this.$container=r,this._loadingTimeoutReplayTimes=0,this._heartTimeoutReplayTimes=0,this.events=new te(this)}destroy(){this.events&&(this.events.destroy(),this.events=null),this.player&&(this.player.destroy(),this.player=null),this.$container=null,this._opt=null,this._loadingTimeoutReplayTimes=0,this._heartTimeoutReplayTimes=0,this.off()}_initPlayer(e,t){this.player=new Fe(e,t),this._bindEvents()}_resetPlayer(){var e=0{this.player.on(c[t],e=>{this.emit(t,e)})})}setDebug(e){this.player.updateOption({isDebug:!!e})}mute(){this.player.mute(!0)}cancelMute(){this.player.mute(!1)}setVolume(e){this.player.volume=e}audioResume(){this.player.audio&&this.player.audio.audioEnabled(!0)}setTimeout(e){e=Number(e),this.player.updateOption({timeout:e,loadingTimeout:e,heartTimeout:e})}setScaleMode(e){let t={isFullResize:!1,isResize:!1};switch(e=Number(e)){case 0:t.isFullResize=!1,t.isResize=!1;break;case 1:t.isFullResize=!1,t.isResize=!0;break;case 2:t.isFullResize=!0,t.isResize=!0}this.player.updateOption(t),this.resize()}pause(){return this.player.pause()}close(){return this._opt.url="",this.player.close()}clearView(){this.player.video.clearView()}play(r){return new Promise((e,t)=>{if(!r&&!this._opt.url)return this.emit(u.error,h.playError),void t();if(r){if(!this._opt.url)return this._play(r);r===this._opt.url?this.player.playing?e():(this.clearView(),this.player.play(this._opt.url).then(()=>{e()}).catch(()=>{this.player.pause().then(()=>{t()})})):this.player.pause().then(()=>(this.clearView(),this._play(r))).catch(()=>{t()})}else this.player.play(this._opt.url).then(()=>{e()}).catch(()=>{this.player.pause().then(()=>{t()})})})}_play(l){return new Promise((e,t)=>{var r=0===(this._opt.url=l).indexOf("http"),i=0===l.indexOf("webrtc"),n=0===l.indexOf("wt"),s=!i&&-1!==l.indexOf(".m3u8"),a=!i&&-1!==l.indexOf(".flv"),o=r?s?3:2:n?5:i?4:1,r=r&&!s||a||this._opt.isFlv?d:s?"hls":i?"webrtc":n?P:"m7s";if(!o||!r)return t(`play protocol is ${o}, demuxType is `+r);this._initPlayer(this.$container,Object.assign(this._opt,{protocol:o,demuxType:r,isHls:s,isWebrtc:i})),this.player.once(h.mediaSourceH265NotSupport,()=>{this.close().then(()=>{this.player._opt.autoWasm&&(this.player.debug.log("Jessibuca","auto wasm [mse-> wasm] reset player and play"),this._resetPlayer({useMSE:!1}),this.play(l).then(()=>{this.player.debug.log("Jessibuca","auto wasm [mse-> wasm] reset player and play success")}).catch(()=>{this.player.debug.log("Jessibuca","auto wasm [mse-> wasm] reset player and play error")}))})}),this.player.once(h.webcodecsH265NotSupport,()=>{this.close().then(()=>{this.player._opt.autoWasm&&(this.player.debug.log("Jessibuca","auto wasm [wcs-> wasm] reset player and play"),this._resetPlayer({useWCS:!1}),this.play(l).then(()=>{this.player.debug.log("Jessibuca","auto wasm [wcs-> wasm] reset player and play success")}).catch(()=>{this.player.debug.log("Jessibuca","auto wasm [wcs-> wasm] reset player and play error")}))})}),this.player.once(h.wasmDecodeError,()=>{this.player._opt.wasmDecodeErrorReplay&&this.close().then(()=>{this.player.debug.log("Jessibuca","wasm decode error and reset player and play"),this._resetPlayer({useWCS:!1}),this.play(l).then(()=>{this.player.debug.log("Jessibuca","wasm decode error and reset player and play success")}).catch(()=>{this.player.debug.log("Jessibuca","wasm decode error and reset player and play error")})})}),this.player.once(u.delayTimeout,()=>{this.player._opt.heartTimeoutReplay&&this._heartTimeoutReplayTimes{this._heartTimeoutReplayTimes=0}).catch(()=>{}))}),this.player.once(u.loadingTimeout,()=>{this.player._opt.loadingTimeoutReplay&&this._loadingTimeoutReplayTimes{this._loadingTimeoutReplayTimes=0}).catch(()=>{}))}),this.hasLoaded()?this.player.play(l).then(()=>{e()}).catch(()=>{this.player.pause().then(()=>{t()})}):this.player.once(u.decoderWorkerInit,()=>{this.player.play(l).then(()=>{e()}).catch(()=>{this.player.pause().then(()=>{t()})})})})}resize(){this.player.resize()}setBufferTime(e){e=Number(e),this.player.updateOption({videoBuffer:1e3*e}),this.player.decoderWorker&&this.player.decoderWorker.updateWorkConfig({key:"videoBuffer",value:1e3*e})}setRotate(e){e=parseInt(e,10),this._opt.rotate!==e&&-1!==[0,90,270].indexOf(e)&&(this.player.updateOption({rotate:e}),this.resize())}hasLoaded(){return this.player.loaded}setKeepScreenOn(){this.player.updateOption({keepScreenOn:!0})}setFullscreen(e){e=!!e;this.player.fullscreen!==e&&(this.player.fullscreen=e)}screenshot(e,t,r,i){return this.player.video.screenshot(e,t,r,i)}startRecord(r,i){return new Promise((e,t)=>{this.player.playing?(this.player.startRecord(r,i),e()):t()})}stopRecordAndSave(){this.player.recording&&this.player.stopRecordAndSave()}isPlaying(){return this.player.playing}isMute(){return!this.player.audio||this.player.audio.isMute}isRecording(){return this.player.recorder.recording}}var Me="http:"===window.location.protocol?"ws:":"wss:";let O=window.location.port;""!==O&&(O=":"+O);var B=window.location.hostname,Ue=window.location.pathname.replace("/preview/",""),F=function(){var e=window.location.search,t={};if(-1!=e.indexOf("?"))for(var r=e.substr(1).split("&"),i=0;i'),new Pe({container:document.querySelector(".jessibuca-pro-wrap"),showBandwidth:!0,debug:"true"===F.debug}).play(e).then(()=>{console.log("play success")}).catch(e=>{console.error("play error",e)}))}});