"use strict";(self.__LOADABLE_LOADED_CHUNKS__=self.__LOADABLE_LOADED_CHUNKS__||[]).push([[5817],{39364:(e,t,i)=>{i.d(t,{A:()=>d});var r=i(6753),n=i(51223);function a(e,t){for(var i=0;ie.length)&&(t=e.length);for(var i=0,r=new Array(t);i0&&!Number.isNaN(e)}},{key:"findFirstAudioSample",value:function(t){return t&&0!==t.length?e.sortAudioSamples(t)[0]:null}},{key:"findFirstVideoSample",value:function(e){if(!e.length)return null;for(var t=o(e).sort((function(e,t){return e.dts-t.dts})),i=0,r=t.length;i=1e3||t-e>=1e3}},{key:"detectAudioLargeGap",value:function(e,t){if(null!==e)return e-t>=1e3||t-e>=1e3}},{key:"doFixLargeGap",value:function(e,t){for(var i=0,r=e.length;i2*s.refSampleDuration&&h<10*s.refSampleDuration){for(var p=Math.floor(h/s.refSampleDuration),v=0;v2*s.refSampleDuration&&!this._videoLargeGap&&(this._videoLargeGap=-1*h,e.doFixLargeGap(a,-1*h))}for(var g=a.length,m=1;m1e4&&(_.dts=b.dts+s.refSampleDuration,_.pts=b.pts+s.refSampleDuration)}var k=a.pop();if(a.length&&(a[a.length-1].duration=k.dts-a[a.length-1].dts),g<4){var A=a[a.length-1],S=(A=A||k).options&&A.options.duration,T=s.refSampleDuration;if(S&&T&&S/T>5)for(var w=A.pts,D=A.dts,R=0;R<3;R++){D+=T,w+=T;var B=Object.assign({},A,{dts:D,pts:w});2===R&&(B.duration=S),a.push(B)}k=null}if(this.videoLastSample){var L=this.videoLastSample;L.duration=d.dts-L.dts,a.unshift(this.videoLastSample)}this.videoLastSample=k,a[a.length-1]&&(this.lastVideoDts=a[a.length-1].dts),this.videoTrack.samples=a}}},{key:"_appendSampleForLastSegment",value:function(e){e&&this.videoLastSample&&this.videoTrack.samples.push(this.videoLastSample)}},{key:"doFixAudio",value:function(t,i){var r=this,a=this.audioTrack,o=a.samples,u=a.meta;if(o&&o.length){this.fixAudioRefSampleDuration(u);for(var c=0,d=o.length;cu.refSampleDuration&&E<10*u.refSampleDuration){for(var k=Math.floor((g.dts-b)/u.refSampleDuration),A=0;A=y&&h<1e4&&v){for(var D=Math.ceil(h/y),R=0;Rthis.nextAudioDts?B:this.nextAudioDts,pts:B>this.nextAudioDts?B:this.nextAudioDts,datasize:v.byteLength,filtered:0,data:v};this.filledAudioSamples.push({dts:L.dts,size:L.data.byteLength}),this.audioTrack.samples.unshift(L),m=L}this.emit(l.DETECT_AUDIO_GAP,h,D)}else w0?(m.dts=this.nextAudioDts,m.pts=this.nextAudioDts):h<0&&w=10*y){var I=Math.round(x/y);if(I>1e3)break;n.A.warn(this.TAG,"inject ".concat(I," audio frame for ").concat(x," ms gap"));for(var P=0;P=1&&(e.duration+=1,r.audioUnsyncTime-=1)}));var V=o[o.length-1];this.lastAudioDts=V.dts;var N=V.duration;this.lastAudioSamplesLen=p,this.nextAudioDts=this.lastAudioDts+(N||y),this.lastAudioOriginDts=V.originDts,this.audioTrack.samples=e.sortAudioSamples(o)}}},{key:"fixChangeStreamVideo",value:function(e){n.A.log(this.TAG,"fixChangeStreamVideo(), changeIdx=",e);var t=this.videoTrack.samples,i=0===e?this.lastVideoDts?this.lastVideoDts:this.getStreamChangeStart(t[0]):t[e-1].dts,r=t[e].dts,a=Math.abs(i-r)<=1e4;if(this.emit(l.DETECT_CHANGE_STREAM,"video",r),a)return t[e].options?t[e].options.isContinue=!0:t[e].options={isContinue:!0},!1;this.emit(l.DETECT_CHANGE_STREAM_DISCONTINUE,"video",{prevDts:i,curDts:r});var s,o=t.slice(0,e),u=t.slice(e),c=t[e];return this._videoLargeGap=0,this.videoLastSample=null,this.lastVideoDts=null,s=c.options&&void 0!==c.options.start?c.options.start:i-this.videoDtsBase,this.videoTrack.samples=t.slice(0,e),this.doFixVideo(!1),this.videoTrack.samples=t.slice(e),this.doFixVideo(!1,s),this.videoTrack.samples=o.concat(u),!0}},{key:"fixChangeStreamAudio",value:function(e){n.A.log(this.TAG,"fixChangeStreamAudio(), changeIdx=",e);var t=this.audioTrack.samples,i=0===e?this.lastAudioDts:t[e-1].dts,r=t[e].dts,a=Math.abs(i-r)<=1e4;if(this.emit(l.DETECT_CHANGE_STREAM,"audio",r),a)return t[e].options?t[e].options.isContinue=!0:t[e].options={isContinue:!0},!1;this.emit(l.DETECT_CHANGE_STREAM_DISCONTINUE,"audio",{prevDts:i,curDts:r}),this._audioLargeGap=0;var s=this.nextAudioDts;this.nextAudioDts=null;var o,u=t.slice(0,e),c=t.slice(e),d=t[e];return d.options&&void 0!==d.options.start?o=d.options.start:(o=s,d.options.isContinue=!0),this.audioTrack.samples=u,this.doFixAudio(!1),this.audioTrack.samples=c,this.doFixAudio(!1,o),this.audioTrack.samples=u.concat(c),!0}},{key:"getFirstSample",value:function(){var t=this.videoTrack.samples,i=this.audioTrack.samples,r=!1,n=!1;return!this._firstVideoSample&&t.length&&(this._firstVideoSample=e.findFirstVideoSample(t),this.removeInvalidSamples(),r=!0),!this._firstAudioSample&&i.length&&(this._firstAudioSample=e.findFirstAudioSample(i),this.removeInvalidSamples(),n=!0),{isFirstVideoSamples:r,isFirstAudioSamples:n}}},{key:"fixVideoRefSampleDuration",value:function(t,i){if(t){var r=this.allVideoSamplesCount,n=this._firstVideoSample.dts,a=this.filledVideoSamples.length;if(e.isRefSampleDurationValid(t.refSampleDuration)){if(t.refSampleDuration&&i.length>=5){var s=(i[i.length-1].dts-i[0].dts)/(i.length-1);if(s>0&&s<1e3){var o=Math.floor(Math.abs(t.refSampleDuration-s)<=5?t.refSampleDuration:s);e.isRefSampleDurationValid(o)&&(t.refSampleDuration=o)}}}else if(i.length>=1){var u=i[i.length-1].dts,c=Math.floor((u-n)/(r+a-1));e.isRefSampleDurationValid(c)&&(t.refSampleDuration=c)}e.isRefSampleDurationValid(t.refSampleDuration)||(t.refSampleDuration=66)}}},{key:"fixAudioRefSampleDuration",value:function(e){e&&(e.refSampleDuration=1024*e.timescale/e.sampleRate)}},{key:"recordSamplesCount",value:function(){var e=this.audioTrack,t=this.videoTrack;this.allAudioSamplesCount+=e.samples.length,this.allVideoSamplesCount+=t.samples.length}},{key:"removeInvalidSamples",value:function(){var e=this.audioTrack.samples[0],t=this.videoTrack.samples[0];e&&(this.audioTrack.samples=this.audioTrack.samples.filter((function(t,i){return t===e||t.dts>=e.dts}))),t&&(this.videoTrack.samples=this.videoTrack.samples.filter((function(e,i){return e===t||e.dts>=t.dts})))}},{key:"getStreamChangeStart",value:function(e){return e.options&&e.options.start?e.options.start-this.dtsBase:1/0}},{key:"tracks",get:function(){return this._context.getInstance("TRACKS")}},{key:"audioTrack",get:function(){return this.tracks&&this.tracks.audioTrack?this.tracks.audioTrack:{samples:[],meta:{}}}},{key:"videoTrack",get:function(){return this.tracks&&this.tracks.videoTrack?this.tracks.videoTrack:{samples:[],meta:{}}}},{key:"dtsBase",get:function(){var e=this._context.getInstance("MP4_REMUXER");return e?e._dtsBase:0}},{key:"audioDtsBase",get:function(){var e=this._context.getInstance("MP4_REMUXER");return e&&null!==e._audioDtsBase?e._audioDtsBase:this.dtsBase}},{key:"videoDtsBase",get:function(){var e=this._context.getInstance("MP4_REMUXER");return e&&null!==e._videoDtsBase?e._videoDtsBase:this.dtsBase}}])&&c(t.prototype,i),r&&c(t,r),e}()},43507:(e,t,i)=>{i.d(t,{A:()=>d});var r=i(65907),n=i(96865);function a(e,t){for(var i=0;ie.length)&&(t=e.length);for(var i=0,r=new Array(t);i100&&t.emit(l.DETECT_LARGE_GAP,"video",e)},get:function(){return t.___videoLargeGap||0}},_audioLargeGap:{set:function(e){t.___audioLargeGap=e,Math.abs(e)>100&&t.emit(l.DETECT_LARGE_GAP,"audio",e)},get:function(){return t.___audioLargeGap||0}}}),this.audioUnsyncTime=0}var t,i,r;return t=e,r=[{key:"sortAudioSamples",value:function(e){return 1===e.length?e:o(e).sort((function(e,t){return e.dts-t.dts}))}},{key:"isRefSampleDurationValid",value:function(e){return e&&e>0&&!Number.isNaN(e)}},{key:"findFirstAudioSample",value:function(t){return t&&0!==t.length?e.sortAudioSamples(t)[0]:null}},{key:"findFirstVideoSample",value:function(e){if(!e.length)return null;for(var t=o(e).sort((function(e,t){return e.dts-t.dts})),i=0,r=t.length;i=1e4||t-e>=1e4}},{key:"detectAudioLargeGap",value:function(e,t){if(null!==e)return e-t>=5e3||t-e>=5e3}},{key:"doFixLargeGap",value:function(e,t){for(var i=0,r=e.length;i2*s.refSampleDuration&&p<10*s.refSampleDuration){for(var v=Math.floor(p/s.refSampleDuration),y=0;y2*s.refSampleDuration&&!this._videoLargeGap&&(this._videoLargeGap=-1*p,this.doFixLargeVideoGap(a,-1*p))}var m=a.pop();if(a.length&&(a[a.length-1].duration=m.dts-a[a.length-1].dts),this.videoLastSample){var _=this.videoLastSample;_.duration=d.dts-_.dts,a.unshift(this.videoLastSample)}this.videoLastSample=m,a[a.length-1]&&(this.lastVideoDuration=a[a.length-1].duration,this.lastVideoDts=a[a.length-1].dts),this.videoTrack.samples=a}}},{key:"doFixAudio",value:function(t,i){var r=this,a=this.audioTrack,o=a.samples,u=a.meta;if(o&&o.length){this.fixAudioRefSampleDuration(u);for(var c=0,d=o.length;cu.refSampleDuration&&k<10*u.refSampleDuration){for(var A=Math.floor((g.dts-E)/u.refSampleDuration),S=0;S=y&&h<1e4&&v){for(var R=Math.ceil(h/y),B=0;Bthis.nextAudioDts?L:this.nextAudioDts,pts:L>this.nextAudioDts?L:this.nextAudioDts,datasize:v.byteLength,filtered:0,data:v};this.filledAudioSamples.push({dts:O.dts,size:O.data.byteLength}),this.audioTrack.samples.unshift(O),m=O}this.emit(l.DETECT_AUDIO_GAP,h,R)}else D0?(m.dts=this.nextAudioDts,m.pts=this.nextAudioDts):h<0&&D=10*y){var P=Math.round(I/y);if(P>1e3)break;n.A.warn(this.TAG,"inject ".concat(P," audio frame for ").concat(I," ms gap"));for(var M=0;M=1&&(e.duration+=1,r.audioUnsyncTime-=1)}));var N=o[o.length-1];this.lastAudioDts=N.dts;var j=N.duration;this.lastAudioSamplesLen=p,this.nextAudioDts=this.lastAudioDts+(j||y),this.lastAudioOriginDts=N.originDts,this.audioTrack.samples=e.sortAudioSamples(o),this.audioLastSample=N}}},{key:"fixChangeStreamVideo",value:function(e){n.A.log(this.TAG,"fixChangeStreamVideo(), changeIdx=",e);var t=this.videoTrack,i=t.samples,r=t.meta,a=0===e&&this.lastVideoDuration?this.lastVideoDuration:r.refSampleDuration,s=0===e?this.lastVideoDts?this.lastVideoDts:this.getStreamChangeStart(i[0]):i[e-1].dts,o=i[e].dts,u=Math.abs(s-o)<=1e4;if(this.emit(l.DETECT_CHANGE_STREAM,"video",o),u)return i[e].options?i[e].options.isContinue=!0:i[e].options={isContinue:!0},!1;this.emit(l.DETECT_CHANGE_STREAM_DISCONTINUE,"video",{prevDts:s,curDts:o,duration:a});var c,d=i.slice(0,e),f=i.slice(e),h=i[e];return this._videoLargeGap=0,this.videoLastSample=null,this.lastVideoDts=null,this.lastVideoDuration=null,c=h.options&&void 0!==h.options.start?h.options.start:s-this.videoDtsBase,this.videoTrack.samples=i.slice(0,e),this.doFixVideo(!1),this.videoTrack.samples=i.slice(e),this.doFixVideo(!1,c),this.videoTrack.samples=d.concat(f),!0}},{key:"fixChangeStreamAudio",value:function(e){n.A.log(this.TAG,"fixChangeStreamAudio(), changeIdx=",e);var t=this.audioTrack,i=t.samples,r=t.meta,a=0===e?this.lastAudioDts:i[e-1].dts,s=i[e].dts,o=Math.abs(a-s)<=1e4;if(this.emit(l.DETECT_CHANGE_STREAM,"audio",s),o)return i[e].options?i[e].options.isContinue=!0:i[e].options={isContinue:!0},!1;this.emit(l.DETECT_CHANGE_STREAM_DISCONTINUE,"audio",{prevDts:a,curDts:s,duration:r.refSampleDuration}),this._audioLargeGap=0;var u=this.nextAudioDts;this.nextAudioDts=null;var c,d=i.slice(0,e),f=i.slice(e),h=i[e];return h.options&&void 0!==h.options.start?c=h.options.start:(c=u,h.options.isContinue=!0),this.audioTrack.samples=d,this.doFixAudio(!1),this.audioTrack.samples=f,this.doFixAudio(!1,c),this.audioTrack.samples=d.concat(f),!0}},{key:"getFirstSample",value:function(){var t=this.videoTrack.samples,i=this.audioTrack.samples,r=!1,n=!1;return!this._firstVideoSample&&t.length&&(this._firstVideoSample=e.findFirstVideoSample(t),this.removeInvalidSamples(),r=!0),!this._firstAudioSample&&i.length&&(this._firstAudioSample=e.findFirstAudioSample(i),this.removeInvalidSamples(),n=!0),{isFirstVideoSamples:r,isFirstAudioSamples:n}}},{key:"fixVideoRefSampleDuration",value:function(t,i){if(t){var r=this.allVideoSamplesCount,n=this._firstVideoSample.dts,a=this.filledVideoSamples.length;if(e.isRefSampleDurationValid(t.refSampleDuration)){if(t.refSampleDuration&&i.length>=5){var s=(i[i.length-1].dts-i[0].dts)/(i.length-1);if(s>0&&s<1e3){var o=Math.floor(Math.abs(t.refSampleDuration-s)<=5?t.refSampleDuration:s);e.isRefSampleDurationValid(o)&&(t.refSampleDuration=o)}}}else if(i.length>=1){var u=i[i.length-1].dts;if(Math.abs(u-n)<100*i.length){var c=Math.floor((u-n)/(r+a-1));e.isRefSampleDurationValid(c)&&(t.refSampleDuration=c)}}e.isRefSampleDurationValid(t.refSampleDuration)||(t.refSampleDuration=66)}}},{key:"fixAudioRefSampleDuration",value:function(e){e&&(e.refSampleDuration=1024*e.timescale/e.sampleRate)}},{key:"recordSamplesCount",value:function(){var e=this.audioTrack,t=this.videoTrack;this.allAudioSamplesCount+=e.samples.length,this.allVideoSamplesCount+=t.samples.length}},{key:"removeInvalidSamples",value:function(){var e=this.audioTrack.samples[0],t=this.videoTrack.samples[0];e&&(this.audioTrack.samples=this.audioTrack.samples.filter((function(t,i){return t===e||t.dts>=e.dts}))),t&&(this.videoTrack.samples=this.videoTrack.samples.filter((function(e,i){return e===t||e.dts>=t.dts})))}},{key:"getStreamChangeStart",value:function(e){return e.options&&e.options.start?e.options.start-this.dtsBase:1/0}},{key:"doFixLargeVideoGap",value:function(e,t){for(var i=0,r=e.length;i1e6&&(this._videoLargeGap=t=this._audioLargeGap,n.dts+=t,n.pts&&(n.pts+=t))}}},{key:"tracks",get:function(){return this._context.getInstance("TRACKS")}},{key:"audioTrack",get:function(){return this.tracks&&this.tracks.audioTrack?this.tracks.audioTrack:{samples:[],meta:{}}}},{key:"videoTrack",get:function(){return this.tracks&&this.tracks.videoTrack?this.tracks.videoTrack:{samples:[],meta:{}}}},{key:"dtsBase",get:function(){var e=this._context.getInstance("MP4_REMUXER");return e?e._dtsBase:0}},{key:"audioDtsBase",get:function(){var e=this._context.getInstance("MP4_REMUXER");return e&&null!==e._audioDtsBase?e._audioDtsBase:this.dtsBase}},{key:"videoDtsBase",get:function(){var e=this._context.getInstance("MP4_REMUXER");return e&&null!==e._videoDtsBase?e._videoDtsBase:this.dtsBase}}])&&c(t.prototype,i),r&&c(t,r),e}()},23557:(e,t,i)=>{function r(e,t){for(var i=0;in});const n=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._baseURL="",this._list={},this._ts={},this.version=0,this.sequence=-1,this.targetduration=0,this.duration=0,this.fragLength=0,this._lastget=void 0,this.end=!1,this.autoclear=t.autoclear||!1,this.logger=t.logger,this.downloadedUrls=[],this._avgSegmentDuration=4}var t,i;return t=e,(i=[{key:"list",get:function(){return this._list}},{key:"baseURL",get:function(){return this._baseURL},set:function(e){this.baseURL!==e&&(this.clear(),this._baseURL=e)}},{key:"avgSegmentDuration",get:function(){return this._avgSegmentDuration}},{key:"push",value:function(e,t,i,r,n,a){this._ts[e]||(this._ts[e]={duration:t,downloaded:!1,downloading:!1,start:this.duration,discontinue:!!i,id:r,cc:n,isLast:a||!1},this._list[this.duration]=e,this.duration+=t,this.fragLength+=1)}},{key:"deleteFrag",value:function(e){this._ts[e]&&(this._ts[e].start>this._lastget.time&&(this._lastget={duration:this._ts[e].duration,time:this._ts[e].start,downloaded:!1,downloading:!1,url:e,id:this._ts[e].id}),delete this._list[this._ts[e].start],delete this._ts[e],this.fragLength-=1)}},{key:"_calcAvgFrgmentDuration",value:function(e){if(!e.frags)return e.targetduration;var t=e.frags.length;return Math.floor(e.duration/t/1e3)}},{key:"pushM3U8",value:function(e,t){if(!e)throw new Error("No m3u8 data received.");if(this.version=e.version,this.targetduration=e.targetduration,this._avgSegmentDuration=Math.min(this.targetduration,this._calcAvgFrgmentDuration(e)),e.encrypt&&!this.encrypt&&(this.encrypt=e.encrypt),this.end=e.end||!1,e.sequence||(e.sequence=0),!(e.sequence>this.sequence))throw new Error("Old m3u8 file received, ".concat(e.sequence));var i=e.frags.length;this.logger&&this.logger.log("PLAYLIST","new playlist [".concat(e.sequence,", ").concat(e.sequence+i-1,"]")),this.sequence=e.sequence;for(var r=[],n=0;n=this.duration)){i=i.sort((function(e,t){return parseFloat(e)-parseFloat(t)}));for(var r=0;r=parseInt(i[r]);r++){var n=this._list[i[r]];t={url:n,downloaded:this._ts[n].downloaded,downloading:this._ts[n].downloading,time:parseInt(i[r]),duration:parseInt(this._ts[n].duration),id:this._ts[n].id,cc:this._ts[n].cc,isLast:this._ts[n].isLast},this.autoclear&&this._lastget&&(delete this._ts[this._lastget.url],delete this._list[this._lastget.time]),this._lastget=t}return t&&this.downloadedUrls.push(t.url),t}}},{key:"getLastDownloadedTs",value:function(){for(var e,t=Object.keys(this._list).sort((function(e,t){return Number(e)-Number(t)})),i=0;i{function r(e,t){for(var i=0;is});var a=function e(){n(this,e),this.mimetype="",this.init=null,this.data=[],this.bufferDuration=0};const s=function(){function e(){n(this,e),this.sources={}}var t,i;return t=e,(i=[{key:"getSource",value:function(e){return this.sources[e]}},{key:"createSource",value:function(e){return this.sources[e]=new a,this.sources[e]}},{key:"clear",value:function(){this.sources={}}},{key:"destroy",value:function(){this.clear()}}])&&r(t.prototype,i),e}()},4192:(e,t,i)=>{function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function n(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&a(e,t)}function a(e,t){return a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},a(e,t)}function s(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var i,n=o(e);if(t){var a=o(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return function(e,t){return!t||"object"!==r(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}(this,i)}}function o(e){return o=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},o(e)}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(e,t){for(var i=0;id,Dc:()=>h,IT:()=>f});var d=function(){function e(){u(this,e),this.id=-1,this.sequenceNumber=0,this.samples=[],this.droppedSamples=[],this.length=0}return l(e,[{key:"reset",value:function(){this.sequenceNumber=0,this.samples=[],this.length=0}},{key:"destroy",value:function(){this.reset(),this.id=-1}}]),e}(),f=function(e){n(i,e);var t=s(i);function i(){var e;return u(this,i),(e=t.call(this)).TAG="AudioTrack",e.type="audio",e}return i}(d),h=function(e){n(i,e);var t=s(i);function i(){var e;return u(this,i),(e=t.call(this)).TAG="VideoTrack",e.type="video",e.dropped=0,e.sequenceNumber=0,e}return l(i,[{key:"reset",value:function(){this.sequenceNumber=0,this.samples=[],this.length=0,this.dropped=0}}]),i}(d)},79214:(e,t,i)=>{function r(e,t){for(var i=0;in});const n=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.length=t||0,this.historyLen=t||0,this.array=[],this.offset=0}var t,i;return t=e,(i=[{key:"push",value:function(e){this.array.push(e),this.length+=e.byteLength,this.historyLen+=e.byteLength}},{key:"shift",value:function(e){if(this.array.length<1)return new Uint8Array(0);if(void 0===e)return this._shiftBuffer();if(this.offset+e===this.array[0].length){var t=this.array[0].slice(this.offset,this.offset+e);return this.offset=0,this.array.shift(),this.length-=e,t}if(this.offset+e0&&e>0;){if(this.offset+e{function r(e,t){for(var i=0;is});var a=function e(){n(this,e),this.mimetype="",this.init=null,this.data=[],this.bufferDuration=0};const s=function(){function e(){n(this,e),this.sources={}}var t,i;return t=e,(i=[{key:"getSource",value:function(e){return this.sources[e]}},{key:"createSource",value:function(e){return this.sources[e]=new a,this.sources[e]}},{key:"clear",value:function(){this.sources={}}},{key:"destroy",value:function(){this.clear()}}])&&r(t.prototype,i),e}()},4682:(e,t,i)=>{function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function n(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&a(e,t)}function a(e,t){return a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},a(e,t)}function s(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var i,n=o(e);if(t){var a=o(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return function(e,t){return!t||"object"!==r(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}(this,i)}}function o(e){return o=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},o(e)}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(e,t){for(var i=0;id,Dc:()=>h,IT:()=>f});var d=function(){function e(){u(this,e),this.id=-1,this.sequenceNumber=0,this.samples=[],this.droppedSamples=[],this.length=0}return l(e,[{key:"reset",value:function(){this.sequenceNumber=0,this.samples=[],this.length=0}},{key:"destroy",value:function(){this.reset(),this.id=-1}}]),e}(),f=function(e){n(i,e);var t=s(i);function i(){var e;return u(this,i),(e=t.call(this)).TAG="AudioTrack",e.type="audio",e}return i}(d),h=function(e){n(i,e);var t=s(i);function i(){var e;return u(this,i),(e=t.call(this)).TAG="VideoTrack",e.type="video",e.dropped=0,e.sequenceNumber=0,e}return l(i,[{key:"reset",value:function(){this.sequenceNumber=0,this.samples=[],this.length=0,this.dropped=0}}]),i}(d)},55384:(e,t,i)=>{function r(e,t){for(var i=0;in});const n=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.length=t||0,this.historyLen=t||0,this.array=[],this.offset=0}var t,i;return t=e,(i=[{key:"push",value:function(e){this.array.push(e),this.length+=e.byteLength,this.historyLen+=e.byteLength}},{key:"shift",value:function(e){if(this.array.length<1)return new Uint8Array(0);if(void 0===e)return this._shiftBuffer();if(this.offset+e===this.array[0].length){var t=this.array[0].slice(this.offset,this.offset+e);return this.offset=0,this.array.shift(),this.length-=e,t}if(this.offset+e0&&e>0;){if(this.offset+e{function r(e,t){for(var i=0;is});var n=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e);var i=Object.assign({},e.getDefault(),t);this.id=i.id,this.url=i.url,this.start=i.start,this.duration=i.duration,this.discontinue=i.discontinue,this.cc=i.cc}var t,i;return t=e,i=[{key:"getDefault",value:function(){return{id:-1,url:"",start:-1,duration:-1,discontinue:!1,cc:-1}}}],null&&r(t.prototype,null),i&&r(t,i),e}();function a(e,t){for(var i=0;i1&&void 0!==arguments[1]?arguments[1]:"",r={duration:0};if(!t||!t.includes("#EXTM3U"))throw new Error("Invalid m3u8 file");var n=t.split(/\r|\n/);n=n.filter((function(e){return e}));var a=n.shift();if(!a.match("#EXTM3U"))throw new Error('Invalid m3u8 file: not "#EXTM3U"');a=n.shift();for(var s=!1,o=0;a;){var u=a.match(/#(.[A-Z|-]*):(.*)/),c=a.match(/#(.[A-Z|-]*)/);if(c&&u&&u.length>2)switch(u[1]){case"EXT-X-VERSION":r.version=parseInt(u[2]);break;case"EXT-X-MEDIA-SEQUENCE":r.sequence=parseInt(u[2]);break;case"EXT-X-TARGETDURATION":r.targetduration=parseFloat(u[2]);break;case"EXTINF":o=e.parseFrag(u,n,r,i,s,o),s=!1;break;case"EXT-X-KEY":e.parseDecrypt(u[2],r)}if(c&&c.length>1)switch(c[1]){case"EXT-X-DISCONTINUITY":s=!0;break;case"EXT-X-ENDLIST":r.frags[r.frags.length-1].isLast=!0,r.end=!0}a=n[o++]}return r}},{key:"parseFrag",value:function(t,i,r,a,s,o){r.frags||(r.frags=[]);var u=new n({start:r.duration,duration:parseInt(1e3*parseFloat(t[2]))});if(u.duration<200)return o;r.duration+=u.duration;var c=i[o++];if((c.match(/#(.*):(.*)/)||c.match(/^#/))&&(c=i[o++]),c.length>0&&"/"===c.charAt(0)&&a.match(/.*\/\/.*\.\w+/g)&&(a=a.match(/.*\/\/.*\.\w+/g)[0]),c.match(/.*:\/\/.*/)){var l=e.isHTTPS;!e.envisHttps&&!(e.envisHttps=l(window.location.href))||l(c)||(c=c.replace("http:","https:")),u.url=c}else u.url=a+c;if(u.discontinue=s,r.frags.length){var d=r.frags[r.frags.length-1];u.id=d.id+1,u.cc=s?d.cc+1:d.cc}else u.id=r.sequence||1,u.cc=0;return r.frags.push(u),o}},{key:"parseURL",value:function(e){var t="",i=e.match(/(.*\/).*\.m3u8/);if(i&&i.length>0)for(var r=0;rt.length&&(t=i[r]);return t}},{key:"parseDecrypt",value:function(e,t){t.encrypt={};var i=e.split(",");for(var r in i){var n=i[r];if(n.match(/METHOD=(.*)/)&&(t.encrypt.method=n.match(/METHOD=(.*)/)[1]),n.match(/URI="(.*)"/)&&(t.encrypt.uri=n.match(/URI="(.*)"/)[1]),n.match(/IV=0x(.*)/)){var a=n.match(/IV=0x(.*)/)[1],s=Math.ceil(a.length/2);t.encrypt.ivb=new Uint8Array(s);for(var o=s-1;o>=0;o--){var u=parseInt(a.substr(2*o,2),16);t.encrypt.ivb[o]=u}t.encrypt.iv=a}}}},{key:"isHTTPS",value:function(e){return/^https:\/\//i.test(e)}}],null&&a(t.prototype,null),i&&a(t,i),e}()},70867:(e,t,i)=>{i.d(t,{A:()=>ae});var r=i(6753),n=i(4192),a=i(42990),s=i.n(a),o=i(51223);function u(e,t){for(var i=0;i0&&e.readByte(this.dataview,r)}},{key:"readUint8",value:function(){return e.readByte(this.dataview,1)}},{key:"readUint16",value:function(){return e.readByte(this.dataview,2)}},{key:"readUint24",value:function(){return e.readByte(this.dataview,3)}},{key:"readUint32",value:function(){return e.readByte(this.dataview,4)}},{key:"readUint64",value:function(){return e.readByte(this.dataview,8)}},{key:"readInt8",value:function(){return e.readByte(this.dataview,1,!0)}},{key:"readInt16",value:function(){return e.readByte(this.dataview,2,!0)}},{key:"readInt32",value:function(){return e.readByte(this.dataview,4,!0)}},{key:"writeUint32",value:function(e){return new Uint8Array([e>>>24&255,e>>>16&255,e>>>8&255,255&e])}}])&&u(t.prototype,i),r&&u(t,r),e}();function l(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function d(e,t){for(var i=0;i>>32-t;if(e>32)throw new Error("Cannot read more than 32 bits at a time");return this._currentWordBitsLeft-=t,this._currentWordBitsLeft>0?this._currentWord<<=t:this._totalBytes-this._bufferIndex>0&&this._fillCurrentWord(),(t=e-t)>0&&this._currentWordBitsLeft?i<>>e)return this._currentWord<<=e,this._currentWordBitsLeft-=e,e;return this._fillCurrentWord(),e+this._skipLeadingZero()}},{key:"readUEG",value:function(){var e=this._skipLeadingZero();return this.readBits(e+1)-1}},{key:"readSEG",value:function(){var e=this.readUEG();return 1&e?e+1>>>1:-1*(e>>>1)}},{key:"readSliceType",value:function(){return this.readByte(),this.readUEG(),this.readUEG()}}])&&b(t.prototype,i),e}();function k(e,t){for(var i=0;i=2&&3===t[a]&&0===t[a-1]&&0===t[a-2]||(r[n]=t[a],n++);return new Uint8Array(r.buffer,0,n)}},{key:"parseSPS",value:function(t){var i=e._ebsp2rbsp(t),r=new E(i);r.readByte();var n=r.readByte();r.readByte();var a=r.readByte();r.readUEG();var s=e.getProfileString(n),o=e.getLevelString(a),u=1,c=420,l=8;if((100===n||110===n||122===n||244===n||44===n||83===n||86===n||118===n||128===n||138===n||144===n)&&(3===(u=r.readUEG())&&r.readBits(1),u<=3&&(c=[0,420,422,444][u]),l=r.readUEG()+8,r.readUEG(),r.readBits(1),r.readBool()))for(var d=3!==u?8:12,f=0;f0&&L<16?(S=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2][L-1],T=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1][L-1]):255===L&&(S=r.readByte()<<8|r.readByte(),T=r.readByte()<<8|r.readByte())}if(r.readBool()&&r.readBool(),r.readBool()&&(r.readBits(4),r.readBool()&&r.readBits(24)),r.readBool()&&(r.readUEG(),r.readUEG()),r.readBool()){var O=r.readBits(32),U=r.readBits(32);D=r.readBool(),w=(R=U)/(B=2*O)}}var C=1;1===S&&1===T||(C=S/T);var x=0,I=0;0===u?(x=1,I=2-m):(x=3===u?1:2,I=(1===u?2:1)*(2-m));var P=16*(y+1),M=16*(g+1)*(2-m);P-=(_+b)*x,M-=(k+A)*I;var G=Math.ceil(P*C);return r.destroy(),r=null,{profile_string:s,level_string:o,bit_depth:l,chroma_format:c,chroma_format_string:e.getChromaFormatString(c),frame_rate:{fixed:D,fps:w,fps_den:B,fps_num:R},par_ratio:{width:S,height:T},codec_size:{width:P,height:M},present_size:{width:G,height:M}}}},{key:"_skipScalingList",value:function(e,t){for(var i=8,r=8,n=0;n=1?w.EBSP2SODB(w.EBSP2RBSP(e.slice(1))):null}},{key:"parse",value:function(t){var i=e._resolveNalu(t),r=e.switchPayloadType(i),n=r.payloadType,a=r.offset,s=i.slice(a);return 5===n?e.user_data_unregistered(s):{code:n,content:s}}},{key:"switchPayloadType",value:function(e){for(var t=new DataView(e.buffer),i=0,r=0;255===t.getUint8(r);)r++,i+=255;return{payloadType:i+=t.getUint8(r++),offset:r}}},{key:"getPayloadLength",value:function(e){for(var t=new DataView(e.buffer),i=0,r=0;255===t.getUint8(r);)r++,i+=255;return{payloadLength:i+=t.getUint8(r++),offset:r}}},{key:"user_data_unregistered",value:function(t){var i=e.getPayloadLength(t),r=i.payloadLength,n=i.offset;if(r<16)return{uuid:"",content:null};var a=t.slice(n);return{code:5,uuid:R(a.slice(0,16)),content:R(a.slice(16,r))}}}],null&&D(t.prototype,null),i&&D(t,i),e}();function L(e,t){for(var i=0;i=r))break;var n=t.buffer.slice(t.position,t.position+4);t.skip(4);var a=new Uint8Array(t.buffer.slice(t.position,t.position+r));t.skip(r);var s={header:n,body:a};e.analyseNal(s),s.type<=9&&0!==s.type&&i.push(s)}return i}},{key:"analyseNal",value:function(e){var t=31&e.body[0];switch(e.type=t,t){case 1:e.ndr=!0;break;case 5:e.idr=!0;break;case 6:try{e.sei=B.parse(e.body)}catch(e){}break;case 7:e.sps=S.parseSPS(e.body);break;case 8:e.pps=!0}}},{key:"getHeaderPositionAnnexB",value:function(e){for(var t=e.position,i=0,r=e.length;3!==i&&4!==i&&t>>8&255,255&e.byteLength]),r),r+=2,i.set(e,r),i[r+=e.byteLength]=1,r++,i.set(new Uint8Array([t.byteLength>>>8&255,255&t.byteLength]),r),r+=2,i.set(t,r),i}}],null&&L(t.prototype,null),i&&L(t,i),e}();function U(e,t){for(var i=0;i>>32-t;if(e>32)throw new Error("Cannot read more than 32 bits at a time");return this._currentWordBitsLeft-=t,this._currentWordBitsLeft>0?this._currentWord<<=t:this._totalBytes-this._bufferIndex>0&&this._fillCurrentWord(),(t=e-t)>0&&this._currentWordBitsLeft?i<>>e)return this._currentWord<<=e,this._currentWordBitsLeft-=e,e;return this._fillCurrentWord(),e+this._skipLeadingZero()}},{key:"readUEG",value:function(){var e=this._skipLeadingZero();return this.readBits(e+1)-1}},{key:"readSEG",value:function(){var e=this.readUEG();return 1&e?e+1>>>1:-1*(e>>>1)}},{key:"readSliceType",value:function(){return this.readByte(),this.readUEG(),this.readUEG()}}])&&U(t.prototype,i),e}();function x(e,t){for(var i=0;i=2&&3===t[a]&&0===t[a-1]&&0===t[a-2]||(r[n]=t[a],n++);return new Uint8Array(r.buffer,0,n)}},{key:"parseSPS",value:function(t){var i,r,n,a,s,o,u=e._ebsp2rbsp(t),c=new C(u),l=0,d=0,f=0,h=0,p=0,v=0,y=0,g=0,m=0;return c.readByte(),c.readByte(),c.readBits(4),i=c.readBits(3),c.readBits(1),o=e._readProfileTierLevel(c,i),c.readUEG(),3===(r=c.readUEG())&&(l=c.readBits(1)),d=c.readUEG(),f=c.readUEG(),1===(n=c.readBits(1))&&(h=c.readUEG(),p=c.readUEG(),v=c.readUEG(),y=c.readUEG()),a=c.readUEG(),s=c.readUEG(),1===n&&(d-=(g=1!==r&&2!==r||0!==l?1:2)*p+g*h,f-=(m=1===r&&0===l?2:1)*y+m*v),c.destroy(),c=null,{width:d,height:f,general_profile_space:o.general_profile_space,general_tier_flag:o.general_tier_flag,general_profile_idc:o.general_profile_idc,general_level_idc:o.general_level_idc,chromaFormatIdc:r,bitDepthLumaMinus8:a,bitDepthChromaMinus8:s}}},{key:"_readProfileTierLevel",value:function(e,t){var i,r,n,a;i=e.readBits(2)||0,r=e.readBits(1)||0,n=e.readBits(5)||0,e.readBits(16),e.readBits(16),e.readBits(1),e.readBits(1),e.readBits(1),e.readBits(1),e.readBits(16),e.readBits(16),e.readBits(12),a=e.readBits(8)||0;for(var s=[],o=[],u=0;u0&&e.readBits(2*(8-t));for(var c=0;c=1?G.EBSP2SODB(G.EBSP2RBSP(e.slice(1))):null}},{key:"parse",value:function(t){var i=e._resolveNalu(t),r=e.switchPayloadType(i),n=r.payloadType,a=r.offset,s=i.slice(a);return 5===n?e.user_data_unregistered(s):{code:n,content:s}}},{key:"switchPayloadType",value:function(e){for(var t=new DataView(e.buffer),i=0,r=0;255===t.getUint8(r);)r++,i+=255;return{payloadType:i+=t.getUint8(r++),offset:r}}},{key:"getPayloadLength",value:function(e){for(var t=new DataView(e.buffer),i=0,r=0;255===t.getUint8(r);)r++,i+=255;return{payloadLength:i+=t.getUint8(r++),offset:r}}},{key:"user_data_unregistered",value:function(t){var i=e.getPayloadLength(t),r=i.payloadLength,n=i.offset;if(r<16)return{uuid:"",content:null};var a=t.slice(n);return{code:5,uuid:N(a.slice(0,16)),content:N(a.slice(16,r))}}}],null&&V(t.prototype,null),i&&V(t,i),e}();function F(e,t){for(var i=0;i=r))break;var n=t.buffer.slice(t.position,t.position+4);t.skip(4);var a=new Uint8Array(t.buffer.slice(t.position,t.position+r));t.skip(r);var s={header:n,body:a};try{e.analyseNal(s)}catch(e){continue}s.type<=40&&i.push(s)}return i}},{key:"analyseNal",value:function(e){var t=e.body[0]>>>1&63;switch(e.type=t,t){case 0:e.slice_trail_n=!0;break;case 1:e.slice_trail_r=!0;break;case 2:e.slice_tsa_n=!0;break;case 3:e.slice_tsa_r=!0,e.key=!0;break;case 4:e.slice_stsa_n=!0;break;case 5:e.slice_stsa_r=!0,e.key=!0;break;case 6:e.slice_radl_n=!0;break;case 7:e.slice_radl_r=!0,e.key=!0;break;case 8:e.slice_rasl_n=!0;break;case 9:e.slice_rasl_r=!0,e.key=!0;break;case 16:e.slice_bla_w_lp=!0;break;case 17:e.slice_bla_w_radl=!0;break;case 18:e.slice_bla_n_lp=!0;break;case 19:e.slice_idl_w_radl=!0,e.key=!0;break;case 20:e.slice_idr_n_lp=!0,e.key=!0;break;case 21:e.slice_cra_nut=!0,e.key=!0;break;case 32:e.vps=!0;break;case 33:e.sps=P.parseSPS(e.body);break;case 34:e.pps=!0;break;case 35:default:break;case 36:e.aud=!0;break;case 37:e.eob=!0;break;case 38:e.fd=!0;break;case 39:try{e.sei=j.parse(e.body.slice(1))}catch(e){}break;case 40:e.sei=j.parse(e.body.slice(1))}}},{key:"getHeaderPositionAnnexB",value:function(e){for(var t=e.position,i=0,r=e.length;3!==i&&4!==i&&t>>5}},{key:"parseFrameHeader",value:function(t,i,r,n,a){var s,o,u=t.length;if(s=e.getHeaderLength(t,i),o=e.getFullFrameLength(t,i),(o-=s)>0&&i+s+o<=u)return{headerLength:s,frameLength:o,stamp:r+n*a}}},{key:"appendFrame",value:function(t,i,r,n,a){var s=e.getFrameDuration(t),o=e.parseFrameHeader(i,r,n,a,s);if(o){var u=o.stamp,c=o.headerLength,l=o.frameLength;return{sample:{unit:i.subarray(r+c,r+c+l),pts:u,dts:u},length:l+c}}}}],null&&z(t.prototype,null),i&&z(t,i),e}();function X(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,r=new Array(t);i=1&&71!==t.array[0][t.offset];)t.shift(1);if(!(t.length<188)){var a=t.shift(188),s=new c(a.buffer),l={};u.read(s,l,r);var d=n[l.header.pid];l.pes?(l.pes.codec=l.header.codec,l.pes.streamType=l.header.streamType,n[l.header.pid]||(n[l.header.pid]=[]),n[l.header.pid].push(l.pes),l.pes.ES.buffer=[l.pes.ES.buffer]):d&&d[d.length-1].ES.buffer.push(l.payload.stream)}}for(var f=Object.assign({},e),h=Object.assign({},e),p=i&&this._hasVideoMeta&&!this._hasAudioMeta,v=i&&this._hasAudioMeta&&!this._hasVideoMeta,y=0;y=9)){var k=E.body.byteLength;E.idr&&(m=!0),E.pps||E.sps||E.sei||(y.set(new Uint8Array([k>>>24&255,k>>>16&255,k>>>8&255,255&k]),g),g+=4,y.set(E.body,g),g+=k)}}var A=parseInt(e.dts/90),S=parseInt(e.pts/90);c.length&&c.forEach((function(e){e.dts=A,i.emit(u.EVENTS.SEI_PARSED,e)}));var T=new _({dts:A,pts:S,cts:S-A,originDts:e.dts,purePts:e.purePts,isKeyframe:m,data:y,nals:r,options:t,firstInGop:m,gopId:m?++this.gopId:this.gopId});this.emit(u.EVENTS.VIDEO_SAMPLE_PARSED,T)}},{key:"pushVideoSampleHEVC",value:function(e,t){var i=this,r=$.getNalunits(e.ES.buffer);r=r.filter((function(e){return e.body&&e.body.length}));var n=new p;n.streamType=36;for(var a=0,s=!1,o=!1,c=!1,l=[],d=!1,f=!1,h=!1,v=!1,y=0;y40)){if(S.vps){if(d)continue;d=!0}else if(S.sps){if(f)continue;f=!0}else if(S.pps){if(h)continue;h=!0}else if(S.key);else if(0===S.type);else if(35===S.type)continue;var T=S.body.byteLength;S.key&&(k=!0),b.set(new Uint8Array([T>>>24&255,T>>>16&255,T>>>8&255,255&T]),E),E+=4,b.set(S.body,E),E+=T}}var w=parseInt(e.dts/90),D=parseInt(e.pts/90);l&&l.forEach((function(e){e.dts=w,i.emit(u.EVENTS.SEI_PARSED,e)}));var R=new _({dts:w,pts:D,cts:D-w,originDts:e.dts,purePts:e.purePts,isKeyframe:k,data:b,nals:r,options:t,firstInGop:v,gopId:v?++this.gopId:this.gopId});this.emit(u.EVENTS.VIDEO_SAMPLE_PARSED,R)}},{key:"destroy",value:function(){this.removeAllListeners(),this.configs={},this.demuxing=!1,this.pat=[],this.pmt=[],this._hasVideoMeta=!1,this._hasAudioMeta=!1}}],r=[{key:"EVENTS",get:function(){return{DEMUX_COMPLETE:"DEMUX_COMPLETE",METADATA_PARSED:"METADATA_PARSED",VIDEO_SAMPLE_PARSED:"VIDEO_SAMPLE_PARSED",AUDIO_SAMPLE_PARSED:"AUDIO_SAMPLES_PARSED",SEI_PARSED:"SEI_PARSED"}}},{key:"compareArray",value:function(e,t,i){var r=0,n=0;if("Uint8Array"===i?(r=e.byteLength,n=t.byteLength):"Array"===i&&(r=e.length,n=t.length),r!==n)return!1;for(var a=0;a0){var d=o[0].streamType;u.Media(e,t,d)}else t.unknownPIDs=!0}}}},{key:"readHeader",value:function(e,t){var i={};i.sync=e.readUint8();var r=e.readUint16();i.error=r>>>15,i.payload=r>>>14&1,i.priority=r>>>13&1,i.pid=8191&r,r=e.readUint8(),i.scrambling=r>>6&3,i.adaptation=r>>4&3,i.continuity=15&r,i.packet=0===i.pid?"PAT":"MEDIA",t.header=i}},{key:"PAT",value:function(e,t,i){var r={},n=e.readUint8();e.skip(n),n=e.readUint8(),r.tabelID=n,n=e.readUint16(),r.error=n>>>7,r.zero=n>>>6&1,r.sectionLength=4095&n,r.streamID=e.readUint16(),r.current=1&e.readUint8(),r.sectionNumber=e.readUint8(),r.lastSectionNumber=e.readUint8();for(var a=(r.sectionLength-9)/4,s=[],o=0;o0&&(i.pat=i.pat.concat(s)),r.list=s,r.program=e.readUint16(),r.pid=8191&e.readUint16(),t.payload=r}},{key:"PMT",value:function(e,t,i){t.header.packet="PMT";var r=e.position;r+=e.getUint8(r);var n=(r+=1)+3+((15&e.getUint8(r+1))<<8|e.getUint8(r+2))-4;r+=12+((15&e.getUint8(r+10))<<8|e.getUint8(r+11));for(var a=[];r0)){var u=e.readUint8();n.discontinue=u>>>7,n.access=u>>>6&1,n.priority=u>>>5&1,n.PCR=u>>>4&1,n.OPCR=u>>>3&1,n.splicePoint=u>>>2&1,n.transportPrivate=u>>>1&1,n.adaptationField=1&u;var l=e.position;if(1===n.PCR&&(n.programClockBase=e.readUint32()<<1,u=e.readUint16(),n.programClockBase|=u>>>15,n.programClockExtension=511&u),1===n.OPCR&&(n.originProgramClockBase=e.readUint32()<<1,u=e.readUint16(),n.originProgramClockBase+=u>>>15,n.originProgramClockExtension=511&u),1===n.splicePoint&&(n.spliceCountdown=e.readUint8()),1===n.transportPrivate)for(var d=e.readUint8(),f=[],h=0;h>>6&1,m=v>>>5&1;1==v>>>7&&(v=e.readUint16(),n.ltwValid=v>>>15,n.ltwOffset=61439&v),1===g&&(v=e.readUint24(),n.piecewiseRate=4194303&v),1===m&&(v=e.readInt8(),n.spliceType=v>>>4,n.dtsNextAU1=v>>>1&7,n.marker1=1&v,v=e.readUint16(),n.dtsNextAU2=v>>>1,n.marker2=1&v,v=e.readUint16(),n.dtsNextAU3=v),e.skip(p-1-(e.position-y))}var _=n.adaptationLength-1-(e.position-l);e.skip(_)}n.stream=new c(e.buffer.slice(e.position)),t.payload=n}},{key:"PES",value:function(e){var t={},i=e.payload.stream;if(1!==i.readUint24())t.ES={},t.ES.buffer=i;else{var r=i.readUint8();r>=224&&r<=239&&(t.type="video"),r>=192&&r<=223&&(t.type="audio");var n=i.readUint16();if(t.packetLength=n,"video"!==t.type&&"audio"!==t.type)throw new Error("format is not supported");var a=i.readUint8();if(2!=a>>>6)throw new Error("error when parse pes header");a=i.readUint8(),t.ptsDTSFlag=a>>>6,t.escrFlag=a>>>5&1,t.esRateFlag=a>>>4&1,t.dsmFlag=a>>>3&1,t.additionalFlag=a>>>2&1,t.crcFlag=a>>>1&1,t.extensionFlag=1&a,t.pesHeaderLength=i.readUint8();var s=t.pesHeaderLength,o=[];o.push(i.readUint8()),o.push(i.readUint8()),o.push(i.readUint8()),o.push(i.readUint8()),o.push(i.readUint8());var c=536870912*(14&o[0])+4194304*(255&o[1])+16384*(254&o[2])+128*(255&o[3])+(254&o[4])/2;if(t.purePts=c,i.dataview.position-=5,o=[],a=i.readUint8(),o.push(a>>>1&7),a=i.readUint16(),o.push(a>>>1),a=i.readUint16(),o.push(a>>>1),t.pts=o[0]<<30|o[1]<<15|o[2],s-=5,"video"===t.type&&(t.dts=t.pts),3===t.ptsDTSFlag){var l=[];a=i.readUint8(),l.push(a>>>1&7),a=i.readUint16(),l.push(a>>>1),a=i.readUint16(),l.push(a>>>1),t.dts=l[0]<<30|l[1]<<15|l[2],s-=5}if(1===t.escrFlag){var d=[],f=[];a=i.readUint8(),d.push(a>>>3&7),d.push(3&a),a=i.readUint16(),d.push(a>>>13),d.push(3&a),a=i.readUint16(),d.push(a>>>13),f.push(3&a),a=i.readUint8(),f.push(a>>>1),t.escr=300*(d[0]<<30|d[1]<<28|d[2]<<15|d[3]<<13|d[4])+(f[0]<<7|f[1]),s-=6}if(1===t.esRateFlag&&(a=i.readUint24(),t.esRate=a>>>1&4194303,s-=3),1===t.dsmFlag)throw new Error("not support DSM_trick_mode");if(1===t.additionalFlag&&(a=i.readUint8(),t.additionalCopyInfo=127&a,s-=1),1===t.crcFlag&&(t.pesCRC=i.readUint16(),s-=2),1===t.extensionFlag)throw new Error("not support extension");s>0&&i.skip(s),t.dts>t.pts&&(t.dts=t.pts),t.ES=u.ES(i,t.type,e.header.streamType)}return t}},{key:"ES",value:function(e,t,i){var r={};if("video"===t)r.buffer=e;else{if("audio"!==t)throw new Error("ES ".concat(t," is not supported"));15!==i&&17!==i||(r=u.parseADTSHeader(e)),r.buffer=e}return r}},{key:"parseADTSHeader",value:function(e){var t={},i=e.readUint16();if(i>>>4!=4095)throw new Error("aac ES parse Error");return t.id=i>>>3&1?"MPEG-2":"MPEG-4",t.layer=i>>>1&3,t.absent=1&i,i=e.readUint16(),t.audioObjectType=1+(i>>>14&3),t.profile=t.audioObjectType-1,t.frequencyIndex=i>>>10&15,t.frequence=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350][t.frequencyIndex],t.channel=i>>>6&7,t.frameLength=(3&i)<<11|e.readUint16()>>>5,u.getAudioConfig(t),e.skip(1),t.buffer=e,t}},{key:"TSDT",value:function(e,t,i){t.payload={}}},{key:"CAT",value:function(e,t,i){var r={};r.tableID=e.readUint8();var n=e.readUint16();r.sectionIndicator=n>>>7,r.sectionLength=4095&n,e.skip(2),n=e.readUint8(),r.version=n>>>3,r.currentNextIndicator=1&n,r.sectionNumber=e.readUint8(),r.lastSectionNumber=e.readUint8();for(var a=(this.sectionLength-9)/4,s=[],o=0;o=8?(e.audioObjectType=5,t=new Array(4),i=e.frequencyIndex-3):(e.audioObjectType=2,t=new Array(2),i=e.frequencyIndex):-1!==r.indexOf("android")?(e.audioObjectType=2,t=new Array(2),i=e.frequencyIndex):(e.audioObjectType=5,t=new Array(4),e.frequencyIndex>=6?i=e.frequencyIndex-3:(1===e.channel&&(e.audioObjectType=2,t=new Array(2)),i=e.frequencyIndex)),t[0]=e.audioObjectType<<3,t[0]|=(14&e.frequencyIndex)>>1,t[1]=(1&e.frequencyIndex)<<7,t[1]|=e.channel<<3,5===e.audioObjectType&&(t[1]|=(14&i)>>1,t[2]=(1&i)<<7,t[2]|=8,t[3]=0),e.audioConfig=t}}],i&&K(t.prototype,i),r&&K(t,r),u}(s());const te=ee;function ie(e,t){for(var i=0;i{i.d(t,{A:()=>S});var r=i(6753),n=i(51223),a=i(42990),s=i.n(a),o=i(23722),u=i.n(o);function c(e,t){for(var i=0;i>24,e>>16&255,e>>8&255,255&e])}},{key:"readAsInt",value:function(e){var t="";return e.forEach((function(e){t+=e.toString(16).padStart(2,"0")})),parseInt(t,16)}}],i&&c(t.prototype,i),r&&c(t,r),e}();function d(e){return function(e){if(Array.isArray(e))return f(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return f(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?f(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function f(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,r=new Array(t);i2?n-2:0),s=2;s>16&255,t>>8&255,255&t])}},{key:"ftyp",value:function(){return e.initBox(24,"ftyp",new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]))}},{key:"ftypHEVC",value:function(){return e.initBox(24,"ftyp",new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,100,97,115,104]))}},{key:"moov",value:function(t){var i,r=t.type,n=t.meta,a=8,s=e.mvhd(n.duration,n.timescale);i="video"===r?e.videoTrak(n):e.audioTrak(n);var o=e.mvex(n.duration,n.timescale||1e3,n.id);return[s,i,o].forEach((function(e){a+=e.byteLength})),e.initBox(a,"moov",s,i,o)}},{key:"mvhd",value:function(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3,r=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i,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]);return e.initBox(8+r.length,"mvhd",new Uint8Array(r))}},{key:"videoTrak",value:function(t){var i=8,r=e.tkhd({id:1,duration:t.duration,timescale:t.timescale||1e3,width:t.presentWidth,height:t.presentHeight,type:"video"}),n=e.mdia({type:"video",timescale:t.timescale||1e3,duration:t.duration,avcc:t.avcc,vvcC:t.vvcC,hvcCConfigParsed:t.hvcCConfigParsed,parRatio:t.parRatio,width:t.presentWidth,height:t.presentHeight,streamType:t.streamType});return[r,n].forEach((function(e){i+=e.byteLength})),e.initBox(i,"trak",r,n)}},{key:"audioTrak",value:function(t){var i=8,r=e.tkhd({id:2,duration:t.duration,timescale:t.timescale||1e3,width:0,height:0,type:"audio"}),n=e.mdia({type:"audio",timescale:t.timescale||1e3,duration:t.duration,channelCount:t.channelCount,samplerate:t.sampleRate,config:t.config});return[r,n].forEach((function(e){i+=e.byteLength})),e.initBox(i,"trak",r,n)}},{key:"tkhd",value:function(t){var i=t.id,r=t.duration,n=t.width,a=t.height,s=new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i,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,n>>>8&255,255&n,0,0,a>>>8&255,255&a,0,0]);return e.initBox(8+s.byteLength,"tkhd",s)}},{key:"edts",value:function(t){var i=new l,r=t.duration,n=t.mediaTime;return i.write(e.size(36),e.type("edts")),i.write(e.size(28),e.type("elst")),i.write(new Uint8Array([0,0,0,1,r>>24&255,r>>16&255,r>>8&255,255&r,n>>24&255,n>>16&255,n>>8&255,255&n,0,0,0,1])),i.buffer}},{key:"mdia",value:function(t){var i=8,r=e.mdhd(t.timescale,t.duration),n=e.hdlr(t.type),a=e.minf(t);return[r,n,a].forEach((function(e){i+=e.byteLength})),e.initBox(i,"mdia",r,n,a)}},{key:"mdhd",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1e3,i=arguments.length>1?arguments[1]:void 0,r=new Uint8Array([0,0,0,0,0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t,i>>>24&255,i>>>16&255,i>>>8&255,255&i,85,196,0,0]);return e.initBox(12+r.byteLength,"mdhd",e.extension(0,0),r)}},{key:"hdlr",value:function(t){var i=[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];return"audio"===t&&(i.splice.apply(i,[8,4].concat([115,111,117,110])),i.splice.apply(i,[24,13].concat([83,111,117,110,100,72,97,110,100,108,101,114,0]))),e.initBox(8+i.length,"hdlr",new Uint8Array(i))}},{key:"minf",value:function(t){var i=8,r="video"===t.type?e.vmhd():e.smhd(),n=e.dinf(),a=e.stbl(t);return[r,n,a].forEach((function(e){i+=e.byteLength})),e.initBox(i,"minf",r,n,a)}},{key:"vmhd",value:function(){return e.initBox(20,"vmhd",new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]))}},{key:"smhd",value:function(){return e.initBox(16,"smhd",new Uint8Array([0,0,0,0,0,0,0,0]))}},{key:"dinf",value:function(){var t=new l;return t.write(e.size(36),e.type("dinf"),e.size(28),e.type("dref"),new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1])),t.buffer}},{key:"stbl",value:function(t){var i=8,r=e.stsd(t),n=e.stts(),a=e.stsc(),s=e.stsz(),o=e.stco();return[r,n,a,s,o].forEach((function(e){i+=e.byteLength})),e.initBox(i,"stbl",r,n,a,s,o)}},{key:"stsd",value:function(t){var i;return i="audio"===t.type?e.mp4a(t):36===t.streamType||t.vvcC?e.hvc1vvc1(t):e.avc1(t),e.initBox(16+i.byteLength,"stsd",e.extension(0,0),new Uint8Array([0,0,0,1]),i)}},{key:"mp4a",value:function(t){var i=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,t.samplerate>>8&255,255&t.samplerate,0,0]),r=e.esds(t.config);return e.initBox(8+i.byteLength+r.byteLength,"mp4a",i,r)}},{key:"esds",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[43,146,8,0],i=t.length,r=new l,n=new Uint8Array([0,0,0,0,3,23+i,0,1,0,4,15+i,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([i]).concat(t).concat([6,1,2]));return r.write(e.size(8+n.byteLength),e.type("esds"),n),r.buffer}},{key:"avc1",value:function(t){var i=new l,r=t.width,n=t.height,a=t.parRatio.width,s=t.parRatio.height,o=t.avcc,u=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,n>>8&255,255&n,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]),c=new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192]),d=new Uint8Array([a>>24,a>>16&255,a>>8&255,255&a,s>>24,s>>16&255,s>>8&255,255&s]);return i.write(e.size(40+u.byteLength+o.byteLength+c.byteLength),e.type("avc1"),u,e.size(8+o.byteLength),e.type("avcC"),o,e.size(20),e.type("btrt"),c,e.size(16),e.type("pasp"),d),i.buffer}},{key:"hvc1vvc1",value:function(t){var i=new l,r=[0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,t.width>>8&255,255&t.width,t.height>>8&255,255&t.height,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,17,17],n=!!t.vvcC,a=n?e.vvcC(t):e.hvcC(t),s=[e.type(n?"vvc1":"hvc1"),new Uint8Array(r)].concat(d(a));t.parRatio&&s.push.apply(s,d(e.pasp(t.parRatio)));var o=4+s.reduce((function(e,t){return e+t.byteLength}),0);return s.unshift(e.size(o)),i.write.apply(i,d(s)),i.buffer}},{key:"hvcC",value:function(t){var i;if(t.hvcCConfigParsed){var r=t.hvcCConfigParsed,n=r.vpsArr,a=r.spsArr,s=r.ppsArr,o=r.hvcC,u=o.generalProfileCompatibilityFlags,c=o.generalConstraintIndicatorFlags,l=(n.length&&1)+(a.length&&1)+(s.length&&1);i=[1,o.generalProfileSpace<<6|o.generalTierFlag<<5|o.generalProfileIdc,u>>>24,u>>>16,u>>>8,u,c[0],c[1],c[2],c[3],c[4],c[5],o.generalLevelIdc,240,0,252,252|o.chromaFormatIdc,248|o.bitDepthLumaMinus8,248|o.bitDepthChromaMinus8,0,0,o.numTemporalLayers<<3|o.temporalIdNested<<2|3,l];var f=function(e){var t;i.push(e.length>>8,e.length),(t=i).push.apply(t,d(e))};n.length&&(i.push(160,0,n.length),n.forEach(f)),a.length&&(i.push(161,0,a.length),a.forEach(f)),s.length&&(i.push(162,0,s.length),s.forEach(f))}else i=[1,1,96,0,0,0,144,0,0,0,0,0,93,240,0,252,253,248,248,0,0,15,3,160,0,1,0,24,64,1,12,1,255,255,1,96,0,0,3,0,144,0,0,3,0,0,3,0,93,153,152,9,161,0,1,0,45,66,1,1,1,96,0,0,3,0,144,0,0,3,0,0,3,0,93,160,2,128,128,45,22,89,153,164,147,43,154,128,128,128,130,0,0,3,0,2,0,0,3,0,50,16,162,0,1,0,7,68,1,193,114,180,98,64];return[e.size(8+i.length),e.type("hvcC"),new Uint8Array(i)]}},{key:"vvcC",value:function(t){var i=t.vvcC;return[e.size(8+i.byteLength),e.type("vvcC"),i]}},{key:"fiel",value:function(){return[e.size(10),e.type("fiel"),new Uint8Array([1,0])]}},{key:"pasp",value:function(t){if(t.width&&t.height){var i=t.width,r=t.height;return[e.size(16),e.type("pasp"),new Uint8Array([i>>24,i>>16&255,i>>8&255,255&i,r>>24,r>>16&255,r>>8&255,255&r])]}return[]}},{key:"stts",value:function(){var t=new Uint8Array([0,0,0,0,0,0,0,0]);return e.initBox(16,"stts",t)}},{key:"stsc",value:function(){var t=new Uint8Array([0,0,0,0,0,0,0,0]);return e.initBox(16,"stsc",t)}},{key:"stco",value:function(){var t=new Uint8Array([0,0,0,0,0,0,0,0]);return e.initBox(16,"stco",t)}},{key:"stsz",value:function(){var t=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]);return e.initBox(20,"stsz",t)}},{key:"mvex",value:function(t){var i=arguments.length>2?arguments[2]:void 0,r=new l,n=l.writeUint32(t);return r.write(e.size(56),e.type("mvex"),e.size(16),e.type("mehd"),e.extension(0,0),n,e.trex(i)),r.buffer}},{key:"trex",value:function(t){var i=new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return e.initBox(8+i.byteLength,"trex",i)}},{key:"moof",value:function(t){var i=8,r=e.mfhd(),n=e.traf(t);return[r,n].forEach((function(e){i+=e.byteLength})),e.initBox(i,"moof",r,n)}},{key:"mfhd",value:function(){var t=l.writeUint32(e.sequence);return e.sequence+=1,e.initBox(16,"mfhd",e.extension(0,0),t)}},{key:"traf",value:function(t){var i=8,r=e.tfhd(t.id),n=e.tfdt(t.time),a=e.sdtp(t),s=e.trun(t,a.byteLength);return[r,n,s,a].forEach((function(e){i+=e.byteLength})),e.initBox(i,"traf",r,n,s,a)}},{key:"tfhd",value:function(t){var i=l.writeUint32(t);return e.initBox(16,"tfhd",e.extension(0,0),i)}},{key:"tfdt",value:function(t){return e.initBox(16,"tfdt",e.extension(0,0),l.writeUint32(t))}},{key:"trun",value:function(t,i){var r=new l,n=l.writeUint32(t.samples.length),a=l.writeUint32(92+16*t.samples.length+i);return r.write(e.size(20+16*t.samples.length),e.type("trun"),new Uint8Array([0,0,15,1]),n,a),t.samples.forEach((function(e){var t=e.flags;r.write(new Uint8Array([e.duration>>>24&255,e.duration>>>16&255,e.duration>>>8&255,255&e.duration,e.size>>>24&255,e.size>>>16&255,e.size>>>8&255,255&e.size,t.isLeading<<2|t.dependsOn,t.isDependedOn<<6|t.hasRedundancy<<4|t.isNonSync,0,0,e.cts>>>24&255,e.cts>>>16&255,e.cts>>>8&255,255&e.cts]))})),r.buffer}},{key:"sdtp",value:function(t){var i=new l;return i.write(e.size(12+t.samples.length),e.type("sdtp"),e.extension(0,0)),t.samples.forEach((function(e){var t=e.flags,r=t.isLeading<<6|t.dependsOn<<4|t.isDependedOn<<2|t.hasRedundancy;i.write(new Uint8Array([r]))})),i.buffer}},{key:"mdat",value:function(t){var i=new l,r=8;t.samples.forEach((function(e){r+=e.size})),i.write(e.size(r),e.type("mdat"));var n=new Uint8Array(r),a=0;return n.set(i.buffer,a),a+=8,t.samples.forEach((function(e){e.buffer.forEach((function(e){n.set(e,a),a+=e.byteLength}))})),n}}],null&&h(t.prototype,null),i&&h(t,i),e}();p.type=function(e){return new Uint8Array([e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)])},p.sequence=1;const v=p;function y(e){return y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},y(e)}function g(e,t){for(var i=0;i0;){var h=r.shift(),p=h.isKeyframe,y=h.options;if(!this.isFirstVideo&&y&&y.meta){s=this.remuxInitSegment("video",y.meta),y.meta=null,r.unshift(h),y.isContinue||(this._videoDtsBase=0);break}var g=Math.max(0,h.dts-this.videoDtsBase);-1===a&&(a=g);var m=void 0,_=void 0;void 0!==h.pts&&(m=(_=h.pts-this._dtsBase)-g),void 0!==h.cts&&(_=h.cts+g,m=h.cts);var b,E={buffer:[],size:0};b=h.duration?h.duration:r.length>=1?r[0].dts-this.videoDtsBase-g:o.length>=1?o[o.length-1].duration:this._videoMeta.refSampleDuration,this.videoAllDuration+=b,n.A.long&&n.A.log(this.TAG,"video dts ".concat(g),"pts ".concat(_),"cts: ".concat(m),p,"originDts ".concat(h.originDts),"duration ".concat(b),f),b>=0&&(c.samples.push(E),E.buffer.push(h.data),E.size+=h.data.byteLength,o.push({dts:g,cts:m,pts:_,data:h.data,size:h.data.byteLength,isKeyframe:p,duration:b,flags:{isLeading:0,dependsOn:p||this.forceFirstIDR&&f?2:1,isDependedOn:p?1:0,hasRedundancy:0,isNonSync:p||this.forceFirstIDR&&f?0:1},originDts:g,type:"video"}),f=!1,this.mp4Durations[_]=b,this.mp4Durations.keys.push(_)),p&&this.emit(u.EVENTS.RANDOM_ACCESS_POINT,_)}if(this.mp4Durations.keys.length>1e4){var k=this.mp4Durations;this.mp4Durations={},this.mp4Durations.keys=k.keys.slice(-100),this.mp4Durations.keys.forEach((function(e){t.mp4Durations[e]=k[e]}))}o.length&&n.A.log(this.TAG,"remux to mp4 video:",[a/1e3,o[o.length-1].dts/1e3]);var A=new l;if(o.length&&i.meta){var S=v.moof({id:i.meta.id,time:a,samples:o}),T=v.mdat(c);A.write(S,T),this.segmentRemuxed("video",A,o[o.length-1].pts-o[0].pts)}if(s&&(this.segmentRemuxed("video",s),r.length))return i.samples=r,this.remuxVideo(i);this.isFirstVideo=!1,this.emit(u.EVENTS.TRACK_REMUXED,"video",A),i.samples=[],i.length=0}}}},{key:"remuxAudio",value:function(e){var t=(e||{}).samples,i=-1,r=[],a=null,s={samples:[]};if(t&&t.length){for(var o=1e4,c=!1;t.length&&o-- >0;){var d=t.shift(),f=d.data,h=d.options;if(!this.isFirstAudio&&h&&h.meta){a=this.remuxInitSegment("audio",h.meta),h.meta=null,t.unshift(d),h.isContinue||(this._audioDtsBase=0);break}var p=Math.max(0,d.dts-this.audioDtsBase),y=d.originDts;c||(i=p,c=!0);var g;g=d.duration?d.duration:this._audioMeta.refSampleDurationFixed?this._audioMeta.refSampleDurationFixed:t.length>=1?t[0].dts-this.audioDtsBase-p:r.length>=1?r[r.length-1].duration:this._audioMeta.refSampleDuration,n.A.long&&n.A.log(this.TAG,"audio dts ".concat(p),"pts ".concat(p),"originDts ".concat(y),"duration ".concat(g)),this.audioAllDuration+=g;var m={dts:p,pts:p,cts:0,size:f.byteLength,duration:d.duration?d.duration:g,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0,isNonSync:0},isKeyframe:!0,originDts:y,type:"audio"},_={buffer:[],size:0};g>=0&&(_.buffer.push(f),_.size+=f.byteLength,s.samples.push(_),r.push(m))}var b=new l;if(r.length&&e.meta){n.A.log(this.TAG,"remux to mp4 audio:",[i/1e3,r[r.length-1].dts/1e3]);var E=v.moof({id:e.meta.id,time:i,samples:r}),k=v.mdat(s);b.write(E,k),this.segmentRemuxed("audio",b,r[r.length-1].dts-r[0].dts)}if(a&&(this.segmentRemuxed("audio",a),t.length))return e.samples=t,this.remuxAudio(e);this.isFirstAudio=!1,this.emit(u.EVENTS.TRACK_REMUXED,"audio",b),e.samples=[],e.length=0}}},{key:"segmentRemuxed",value:function(e,t,i){this.emit(u.EVENTS.MEDIA_SEGMENT,e,t,i)}},{key:"videoDtsBase",get:function(){return null!==this._videoDtsBase?this._videoDtsBase:this._dtsBase},set:function(e){this._videoDtsBase=e}},{key:"audioDtsBase",get:function(){return null!==this._audioDtsBase?this._audioDtsBase:this._dtsBase}}])&&g(t.prototype,i),r&&g(t,r),u}(s());function E(e,t){for(var i=0;i0&&void 0!==arguments[0]?arguments[0]:0;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.TAG="Mp4Remuxer",this._curTime=t,this.remuxer||this.initRemuxer()}var t,i;return t=e,(i=[{key:"init",value:function(){this.on(k.REMUX_MEDIA,this.remux.bind(this)),this.on(k.REMUX_METADATA,this.onMetaDataReady.bind(this)),this.on(k.DETECT_CHANGE_STREAM,this.resetDtsBase.bind(this)),this.on(k.DETECT_FRAG_ID_DISCONTINUE,this.seek.bind(this)),this.on(A.SEEK,this.seek.bind(this))}},{key:"initRemuxer",value:function(){this.remuxer=new b({audioMeta:null,videoMeta:null,curTime:this._curTime}),this.remuxer.on(b.EVENTS.MEDIA_SEGMENT,this.writeToSource.bind(this)),this.remuxer.on(b.EVENTS.TRACK_REMUXED,this.onTrackRemuxed.bind(this))}},{key:"remux",value:function(){if(this.remuxer)try{this.remuxer._videoMeta||(this.remuxer._videoMeta=this.videoMeta,this.remuxer._audioMeta=this.audioMeta);var e=this._context.getInstance("TRACKS"),t=e.audioTrack,i=e.videoTrack;this.remuxer.remux(t,i)}catch(e){this.emit(k.REMUX_ERROR,this.TAG,e)}}},{key:"resetDtsBase",value:function(){this.remuxer&&this.remuxer.resetDtsBase()}},{key:"seek",value:function(e){this.remuxer&&this.remuxer.seek(e)}},{key:"onMetaDataReady",value:function(e,t){var i;this.remuxer||this.initRemuxer(),i="audio"===e?this._context.getInstance("TRACKS").audioTrack:this._context.getInstance("TRACKS").videoTrack;var r=this._context.getInstance("PRE_SOURCE_BUFFER"),n=r.getSource(e);n||(n=r.createSource(e)),n.mimetype=i.meta.codec,n.init=this.remuxer.remuxInitSegment(e,i.meta),t&&this.writeToSource(e,n.init,0),this.emit(k.INIT_SEGMENT,e)}},{key:"onTrackRemuxed",value:function(e){this.emit(k.MEDIA_SEGMENT,e)}},{key:"writeToSource",value:function(e,t,i){var r=this._context.getInstance("PRE_SOURCE_BUFFER"),n=r.getSource(e);n||(n=r.createSource(e)),n.data.push(t),i&&(n.bufferDuration=i+(n.bufferDuration||0))}},{key:"videoMeta",get:function(){return this._context.getInstance("TRACKS").videoTrack.meta}},{key:"audioMeta",get:function(){return this._context.getInstance("TRACKS").audioTrack.meta}},{key:"destroy",value:function(){this.remuxer&&this.remuxer.destroy(),this.remuxer=null}}])&&E(t.prototype,i),e}()},25202:(e,t,i)=>{i.d(t,{A:()=>Be});var r=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.filtered=-1,this.tagType=-1,this.datasize=-1,this.dts=-1};function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var i=0;i0&&e.readByte(this.dataview,r)}},{key:"readUint8",value:function(){return e.readByte(this.dataview,1)}},{key:"readUint16",value:function(){return e.readByte(this.dataview,2)}},{key:"readUint24",value:function(){return e.readByte(this.dataview,3)}},{key:"readUint32",value:function(){return e.readByte(this.dataview,4)}},{key:"readUint64",value:function(){return e.readByte(this.dataview,8)}},{key:"readInt8",value:function(){return e.readByte(this.dataview,1,!0)}},{key:"readInt16",value:function(){return e.readByte(this.dataview,2,!0)}},{key:"readInt32",value:function(){return e.readByte(this.dataview,4,!0)}},{key:"writeUint32",value:function(e){return new Uint8Array([e>>>24&255,e>>>16&255,e>>>8&255,255&e])}}])&&d(t.prototype,i),r&&d(t,r),e}();function h(e,t){for(var i=0;i>>32-t;if(e>32)throw new Error("Cannot read more than 32 bits at a time");return this._currentWordBitsLeft-=t,this._currentWordBitsLeft>0?this._currentWord<<=t:this._totalBytes-this._bufferIndex>0&&this._fillCurrentWord(),(t=e-t)>0&&this._currentWordBitsLeft?i<>>e)return this._currentWord<<=e,this._currentWordBitsLeft-=e,e;return this._fillCurrentWord(),e+this._skipLeadingZero()}},{key:"readUEG",value:function(){var e=this._skipLeadingZero();return this.readBits(e+1)-1}},{key:"readSEG",value:function(){var e=this.readUEG();return 1&e?e+1>>>1:-1*(e>>>1)}},{key:"readSliceType",value:function(){return this.readByte(),this.readUEG(),this.readUEG()}}])&&h(t.prototype,i),e}();function v(e,t){for(var i=0;i=2&&3===t[a]&&0===t[a-1]&&0===t[a-2]||(r[n]=t[a],n++);return new Uint8Array(r.buffer,0,n)}},{key:"parseSPS",value:function(t){var i=e._ebsp2rbsp(t),r=new p(i);r.readByte();var n=r.readByte();r.readByte();var a=r.readByte();r.readUEG();var s=e.getProfileString(n),o=e.getLevelString(a),u=1,c=420,l=8;if((100===n||110===n||122===n||244===n||44===n||83===n||86===n||118===n||128===n||138===n||144===n)&&(3===(u=r.readUEG())&&r.readBits(1),u<=3&&(c=[0,420,422,444][u]),l=r.readUEG()+8,r.readUEG(),r.readBits(1),r.readBool()))for(var d=3!==u?8:12,f=0;f0&&L<16?(S=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2][L-1],T=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1][L-1]):255===L&&(S=r.readByte()<<8|r.readByte(),T=r.readByte()<<8|r.readByte())}if(r.readBool()&&r.readBool(),r.readBool()&&(r.readBits(4),r.readBool()&&r.readBits(24)),r.readBool()&&(r.readUEG(),r.readUEG()),r.readBool()){var O=r.readBits(32),U=r.readBits(32);D=r.readBool(),w=(R=U)/(B=2*O)}}var C=1;1===S&&1===T||(C=S/T);var x=0,I=0;0===u?(x=1,I=2-_):(x=3===u?1:2,I=(1===u?2:1)*(2-_));var P=16*(g+1),M=16*(m+1)*(2-_);P-=(b+E)*x,M-=(k+A)*I;var G=Math.ceil(P*C);return r.destroy(),r=null,{profile_string:s,level_string:o,bit_depth:l,chroma_format:c,chroma_format_string:e.getChromaFormatString(c),frame_rate:{fixed:D,fps:w,fps_den:B,fps_num:R},par_ratio:{width:S,height:T},codec_size:{width:P,height:M},present_size:{width:G,height:M}}}},{key:"_skipScalingList",value:function(e,t){for(var i=8,r=8,n=0;n=1?_.EBSP2SODB(_.EBSP2RBSP(e.slice(1))):null}},{key:"parse",value:function(t){var i=e._resolveNalu(t),r=e.switchPayloadType(i),n=r.payloadType,a=r.offset,s=i.slice(a);if(5===n)return e.user_data_unregistered(s);var o=e.getPayloadLength(s),u=o.payloadLength,c=o.offset;return{code:n,content:s.slice(c),size:u}}},{key:"switchPayloadType",value:function(e){for(var t=new DataView(e.buffer),i=0,r=0;255===t.getUint8(r);)r++,i+=255;return{payloadType:i+=t.getUint8(r++),offset:r}}},{key:"getPayloadLength",value:function(e){for(var t=new DataView(e.buffer),i=0,r=0;255===t.getUint8(r);)r++,i+=255;return{payloadLength:i+=t.getUint8(r++),offset:r}}},{key:"user_data_unregistered",value:function(t){var i=e.getPayloadLength(t),r=i.payloadLength,n=i.offset;if(r<16)return{uuid:"",content:null};var a=t.slice(n);return{code:5,uuid:E(a.slice(0,16)),content:E(a.slice(16,r)),size:r}}}],null&&b(t.prototype,null),i&&b(t,i),e}();function A(e,t){for(var i=0;i=r))break;var n=t.buffer.slice(t.position,t.position+4);t.skip(4);var a=new Uint8Array(t.buffer.slice(t.position,t.position+r));t.skip(r);var s={header:n,body:a};e.analyseNal(s),s.type<=9&&0!==s.type&&i.push(s)}return i}},{key:"analyseNal",value:function(e){var t=31&e.body[0];switch(e.type=t,t){case 1:e.ndr=!0;break;case 5:e.idr=!0;break;case 6:try{e.sei=k.parse(e.body)}catch(e){}break;case 7:e.sps=g.parseSPS(e.body);break;case 8:e.pps=!0}}},{key:"getHeaderPositionAnnexB",value:function(e){for(var t=e.position,i=0,r=e.length;3!==i&&4!==i&&t>>8&255,255&e.byteLength]),r),r+=2,i.set(e,r),i[r+=e.byteLength]=1,r++,i.set(new Uint8Array([t.byteLength>>>8&255,255&t.byteLength]),r),r+=2,i.set(t,r),i}}],null&&A(t.prototype,null),i&&A(t,i),e}();const T=S;function w(e,t){for(var i=0;i>>32-t;if(e>32)throw new Error("Cannot read more than 32 bits at a time");return this._currentWordBitsLeft-=t,this._currentWordBitsLeft>0?this._currentWord<<=t:this._totalBytes-this._bufferIndex>0&&this._fillCurrentWord(),(t=e-t)>0&&this._currentWordBitsLeft?i<>>e)return this._currentWord<<=e,this._currentWordBitsLeft-=e,e;return this._fillCurrentWord(),e+this._skipLeadingZero()}},{key:"readUEG",value:function(){var e=this._skipLeadingZero();return this.readBits(e+1)-1}},{key:"readSEG",value:function(){var e=this.readUEG();return 1&e?e+1>>>1:-1*(e>>>1)}},{key:"readSliceType",value:function(){return this.readByte(),this.readUEG(),this.readUEG()}}])&&w(t.prototype,i),e}();function R(e,t){for(var i=0;i=2&&3===t[a]&&0===t[a-1]&&0===t[a-2]||(r[n]=t[a],n++);return new Uint8Array(r.buffer,0,n)}},{key:"parseSPS",value:function(t){var i,r,n,a,s,o,u=e._ebsp2rbsp(t),c=new D(u),l=0,d=0,f=0,h=0,p=0,v=0,y=0,g=0,m=0;return c.readByte(),c.readByte(),c.readBits(4),i=c.readBits(3),c.readBits(1),o=e._readProfileTierLevel(c,i),c.readUEG(),3===(r=c.readUEG())&&(l=c.readBits(1)),d=c.readUEG(),f=c.readUEG(),1===(n=c.readBits(1))&&(h=c.readUEG(),p=c.readUEG(),v=c.readUEG(),y=c.readUEG()),a=c.readUEG(),s=c.readUEG(),1===n&&(d-=(g=1!==r&&2!==r||0!==l?1:2)*p+g*h,f-=(m=1===r&&0===l?2:1)*y+m*v),c.destroy(),c=null,{width:d,height:f,general_profile_space:o.general_profile_space,general_tier_flag:o.general_tier_flag,general_profile_idc:o.general_profile_idc,general_level_idc:o.general_level_idc,chromaFormatIdc:r,bitDepthLumaMinus8:a,bitDepthChromaMinus8:s}}},{key:"_readProfileTierLevel",value:function(e,t){var i,r,n,a;i=e.readBits(2)||0,r=e.readBits(1)||0,n=e.readBits(5)||0,e.readBits(16),e.readBits(16),e.readBits(1),e.readBits(1),e.readBits(1),e.readBits(1),e.readBits(16),e.readBits(16),e.readBits(12),a=e.readBits(8)||0;for(var s=[],o=[],u=0;u0&&e.readBits(2*(8-t));for(var c=0;c=1?U.EBSP2SODB(U.EBSP2RBSP(e.slice(1))):null}},{key:"parse",value:function(t){var i=e._resolveNalu(t),r=e.switchPayloadType(i),n=r.payloadType,a=r.offset,s=i.slice(a);if(5===n)return e.user_data_unregistered(s);var o=e.getPayloadLength(s),u=o.payloadLength,c=o.offset;return{code:n,content:s.slice(c),size:u}}},{key:"switchPayloadType",value:function(e){for(var t=new DataView(e.buffer),i=0,r=0;255===t.getUint8(r);)r++,i+=255;return{payloadType:i+=t.getUint8(r++),offset:r}}},{key:"getPayloadLength",value:function(e){for(var t=new DataView(e.buffer),i=0,r=0;255===t.getUint8(r);)r++,i+=255;return{payloadLength:i+=t.getUint8(r++),offset:r}}},{key:"user_data_unregistered",value:function(t){var i=e.getPayloadLength(t),r=i.payloadLength,n=i.offset;if(r<16)return{uuid:"",content:null};var a=t.slice(n);return{code:5,uuid:x(a.slice(0,16)),content:x(a.slice(16,r)),size:r}}}],null&&C(t.prototype,null),i&&C(t,i),e}();function P(e,t){for(var i=0;i=r))break;var n=t.buffer.slice(t.position,t.position+4);t.skip(4);var a=new Uint8Array(t.buffer.slice(t.position,t.position+r));t.skip(r);var s={header:n,body:a};try{e.analyseNal(s)}catch(e){continue}s.type<=40&&i.push(s)}return i}},{key:"analyseNal",value:function(e){var t=e.body[0]>>>1&63;switch(e.type=t,t){case 0:e.slice_trail_n=!0;break;case 1:e.slice_trail_r=!0;break;case 2:e.slice_tsa_n=!0;break;case 3:e.slice_tsa_r=!0,e.key=!0;break;case 4:e.slice_stsa_n=!0;break;case 5:e.slice_stsa_r=!0,e.key=!0;break;case 6:e.slice_radl_n=!0;break;case 7:e.slice_radl_r=!0,e.key=!0;break;case 8:e.slice_rasl_n=!0;break;case 9:e.slice_rasl_r=!0,e.key=!0;break;case 16:e.slice_bla_w_lp=!0;break;case 17:e.slice_bla_w_radl=!0;break;case 18:e.slice_bla_n_lp=!0;break;case 19:e.slice_idl_w_radl=!0,e.key=!0;break;case 20:e.slice_idr_n_lp=!0,e.key=!0;break;case 21:e.slice_cra_nut=!0,e.key=!0;break;case 32:e.vps=!0;break;case 33:e.sps=L.parseSPS(e.body);break;case 34:e.pps=!0;break;case 35:default:break;case 36:e.aud=!0;break;case 37:e.eob=!0;break;case 38:e.fd=!0;break;case 39:try{e.sei=I.parse(e.body.slice(1))}catch(e){}break;case 40:e.sei=I.parse(e.body.slice(1))}}},{key:"getHeaderPositionAnnexB",value:function(e){for(var t=e.position,i=0,r=e.length;3!==i&&4!==i&&t=128){i.push(String.fromCharCode(65535&s)),n+=2;continue}}}else if(r[n]<240){if(e._checkContinuation(r,n,2)){var o=(15&r[n])<<12|(63&r[n+1])<<6|63&r[n+2];if(o>=2048&&55296!=(63488&o)){i.push(String.fromCharCode(65535&o)),n+=3;continue}}}else if(r[n]<248&&e._checkContinuation(r,n,3)){var u=(7&r[n])<<18|(63&r[n+1])<<12|(63&r[n+2])<<6|63&r[n+3];if(u>65536&&u<1114112){u-=65536,i.push(String.fromCharCode(u>>>10|55296)),i.push(String.fromCharCode(1023&u|56320)),n+=4;continue}}i.push(String.fromCharCode(65533)),++n}return i.join("")}},{key:"_checkContinuation",value:function(e,t,i){var r=e;if(t+i0?z.decode(new Uint8Array(e,this.readOffset+2,i)):"";var r=i+2;return this.readOffset+=r,{data:t,bodySize:i+2}}},{key:"parseDate",value:function(e,t){var i=new DataView(e,this.readOffset,t),r=i.getFloat64(0,!X);return r+=60*i.getInt16(8,!X)*1e3,this.readOffset+=10,{data:new Date(r),bodySize:10}}},{key:"parseObject",value:function(e,t){var i=this.parseString(e,t),r=this.parseValue(e,t-i.bodySize);return{data:{name:i.data,value:r.data},bodySize:i.bodySize+r.bodySize,isObjEnd:r.isObjEnd}}},{key:"parseLongString",value:function(e){var t,i=new DataView(e,this.readOffset).getUint32(0,!X);return t=i>0?z.decode(new Uint8Array(e,this.readOffset+2,i)):"",this.readOffset+=i+4,{data:t,bodySize:i+4}}},{key:"parseValue",value:function(e,t){var i=new ArrayBuffer;i=e instanceof ArrayBuffer?e:e.buffer;var r=new DataView(i,this.readOffset,t),n=!1,a=r.getUint8(0),s=1;this.readOffset+=1;var o=null;switch(a){case 0:o=r.getFloat64(1,!X),this.readOffset+=8,s+=8;break;case 1:o=!!r.getUint8(1),this.readOffset+=1,s+=1;break;case 2:var u=this.parseString(i);o=u.data,s+=u.bodySize;break;case 3:o={};var c=0;for(16777215&r.getUint32(t-4,!X)&&(c=3);se)this._word<<=e,this._bitsAvailable-=e;else{e-=this._bitsAvailable;var t=Math.floor(e/8);e-=8*t,this._bytesAvailable-=t,this._loadWord(),this._word<<=e,this._bitsAvailable-=e}}},{key:"readBits",value:function(e){if(e>32)throw new Error("Cannot read more than 32 bits");var t=Math.min(this._bitsAvailable,e),i=this._word>>>32-t;return this._bitsAvailable-=t,this._bitsAvailable>0?this._word<<=t:this._bytesAvailable>0&&this._loadWord(),(t=e-t)>0&&this._bitsAvailable?i<>>e)return this._word<<=e,this._bitsAvailable-=e,e;return this._loadWord(),e+this.skipLZ()}},{key:"skipUEG",value:function(){this.skipBits(1+this.skipLZ())}},{key:"readUEG",value:function(){var e=this.skipLZ();return this.readBits(e+1)-1}},{key:"readEG",value:function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}},{key:"readBool",value:function(){return 1===this.readBits(1)}},{key:"readUByte",value:function(){return this.readBits(8)}},{key:"skipScalingList",value:function(e){for(var t=8,i=8,r=0;r1&&void 0!==arguments[1]?arguments[1]:{};if(!(t.length<23)){i=i||{};for(var r,n,a,s,o,u=1+(3&t[21]),c=[],l=[],d=[],f=23,h=t[22],p=0;p1&&void 0!==arguments[1]?arguments[1]:{};i=i||{};var r=new J(t);r.readUByte(),r.readUByte(),r.readBits(4);var n=r.readBits(3);i.numTemporalLayers=Math.max(n+1,i.numTemporalLayers||0),i.temporalIdNested=r.readBits(1),e._parseProfileTierLevel(r,n,i),r.readUEG();var a=i.chromaFormatIdc=r.readUEG(),s=420;a<=3&&(s=[0,420,422,444][a]);var o=0;3===a&&(o=r.readBits(1));var u,c,l,d,f=r.readUEG(),h=r.readUEG(),p=r.readBits(1);return 1===p&&(u=r.readUEG(),c=r.readUEG(),l=r.readUEG(),d=r.readUEG()),i.bitDepthLumaMinus8=r.readUEG(),i.bitDepthChromaMinus8=r.readUEG(),1===p&&(f-=(1!==a&&2!==a||0!==o?1:2)*(c+u),h-=(1===a&&0===o?2:1)*(d+l)),{codec:"hev1.1.6.L93.B0",width:f,height:h,chromaFormat:s,hvcC:i}}},{key:"_parseProfileTierLevel",value:function(e,t,i){var r=i.generalTierFlag||0;i.generalProfileSpace=e.readBits(2),i.generalTierFlag=Math.max(e.readBits(1),r),i.generalProfileIdc=Math.max(e.readBits(5),i.generalProfileIdc||0),i.generalProfileCompatibilityFlags=e.readBits(32),i.generalConstraintIndicatorFlags=[e.readBits(8),e.readBits(8),e.readBits(8),e.readBits(8),e.readBits(8),e.readBits(8)];var n=e.readBits(8);r0&&e.readBits(2*(8-t));for(var u=0;u>this._numHeldBits-e&(1<1){e.streamRead1Bytes();for(var h=0,p=t-2;p>=0;--p)h|=e.extractBits(1)<1;++v)e.extractBits(1);for(var y=t-2;y>=0;--y)h&1<=i))break;var r=e.buffer.slice(e.position,e.position+4);e.skip(4);var n=new Uint8Array(e.buffer.slice(e.position,e.position+i));e.skip(i),t.push({header:r,body:n})}return t}},{key:"analyseNal",value:function(e){var t=(248&e.body[1])>>3;switch(e.type=t,t){case 23:case 24:try{e.sei=se.parse(e.body.slice(1))}catch(e){}break;case 7:case 8:e.key=!0;break;case 14:e.vps=!0;break;case 15:e.sps=!0;break;case 16:e.pps=!0;break;case 17:e.aps=!0}}},{key:"removeEPB",value:function(e){for(var t=e.byteLength,i=[],r=1;r=0;--p)d[p]=t.readBits(1);for(;!t.byteAligned();)t.readBits(1);for(var v=l;v>=0;--v)d[v]&&(f[v]=t.readUByte());if(i)for(var y=t.readUByte(),g=0;g0)}else{if(this._decryptor&&!this._decryptorReady)return;if(e.length<13)return;var r=e.shift(13);this.parseFlvHeader(r),this.demux(e)}}},{key:"parseFlvHeader",value:function(e){if(!d.isFlvFile(e))throw new Error("invalid flv file,".concat(e.join(",")));this._headerParsed=!0;var t=e[4]>>>2==1,i=!(1&~e[4]);this.emit(d.EVENTS.FILE_HEADER_PARSED,{hasVideo:i,hasAudio:t})}},{key:"_parseFlvTag",value:function(e){var t=e.toInt(1,3);if(e.length<11+t+4)return null;var i=this._parseFlvTagHeader(e);if(i&&(this._processTagData(i,e),!this._datasizeValidator(i.datasize,e)))throw new Error("TAG length error at "+i.datasize);return i}},{key:"_parseFlvTagHeader",value:function(e){var t=0,i=new r,n=e.toInt(t,1);if(t+=1,i.filtered=(32&n)>>>5,i.tagType=31&n,i.datasize=e.toInt(t,3),t+=3,8!==i.tagType&&9!==i.tagType&&11!==i.tagType&&18!==i.tagType)throw e&&e.length>0&&e.shift(1),new Error("tagType "+i.tagType);if(e.length0&&(a+=16777216*s),i.dts=a,e.shift(3),i}},{key:"_processTagData",value:function(e,t){switch(e.tagType){case 18:this._parseScriptData(e,t);break;case 8:this._parseAudioTag(e,t);break;case 9:this._parseVideoData(e,t);break;case 11:t.shift(3);break;default:t.shift(1)}}},{key:"_parseScriptData",value:function(e,t){e.data=t.shift(e.datasize);var i=(new q).resolve(e.data,e.data.length);if(this._onMetaData=i?i.onMetaData:void 0,this.emit(d.EVENTS.SCRIPT_TAG_PARSED,this._onMetaData),!this._isEncrypt){var r=this._onMetaData.encrypt_method;if(r){if("SAMPLE-AES"!==r)throw new Error("invalid encrypt method: ".concat(r));if(!this._cfg.keyStr)throw new Error("no decrypt key found");this._isEncrypt=1}}}},{key:"_aacSequenceHeaderParser",value:function(e){var t,i,r={hasSpecificConfig:!0};r.objectType=e[1]>>>3,r.originObjectType=r.objectType,r.sampleRateIndex=(7&e[1])<<1|e[2]>>>7,r.audiosamplerate=this._switchAudioSampleRate(r.sampleRateIndex),r.channelCount=(120&e[2])>>>3,r.frameLength=(4&e[2])>>>2,r.dependsOnCoreCoder=(2&e[2])>>>1,r.extensionFlagIndex=1&e[2];var n=r.sampleRateIndex;return this._userAgent&&-1!==this._userAgent.indexOf("firefox")?r.sampleRateIndex>=8?(r.objectType=5,i=new Array(4),t=n-3):(r.objectType=2,i=new Array(2),t=n):this._userAgent&&-1!==this._userAgent.indexOf("android")||this._userAgent&&-1!==this._userAgent.indexOf("iphone")?(r.objectType=2,i=new Array(2),t=n):(r.objectType=5,t=r.sampleRateIndex,i=new Array(4),r.sampleRateIndex>=6?t=r.sampleRateIndex-3:1===r.channelCount&&(r.objectType=2,i=new Array(2),t=r.sampleRateIndex)),r.codec="mp4a.40.".concat(r.objectType),i[0]=r.objectType<<3,i[0]|=(15&r.sampleRateIndex)>>>1,i[1]=(15&r.sampleRateIndex)<<7,i[1]|=(15&r.channelCount)<<3,5===r.objectType&&(i[1]|=(15&t)>>>1,i[2]=(1&t)<<7,i[2]|=8,i[3]=0),r.config=i,r}},{key:"_parseAudioTag",value:function(e,t){var i=new o,r=t.shift(1)[0];e.data=t.shift(e.datasize-1);var n=(240&r)>>>4;if(10!==n)throw new Error("invalid audio format: ".concat(n));10===n&&(i.sampleRate=this._switchAudioSamplingFrequency(r),i.sampleRateIndex=(12&r)>>>2,i.frameLenth=(2&r)>>>1,i.channelCount=1&r,i.refSampleDuration=Math.floor(1024/i.audioSampleRate*i.timescale));var a=i.audioSampleRate,s=i.sampleRateIndex,u=i.refSampleDuration;if(0===e.data[0]){var c=this._aacSequenceHeaderParser(e.data);a=c.audiosamplerate||i.audioSampleRate,s=c.sampleRateIndex||i.sampleRateIndex,u=Math.floor(1024/a*i.timescale),i.channelCount=c.channelCount,i.sampleRate=a,i.sampleRateIndex=s,i.refSampleDuration=u,i.duration=this._onMetaData?this._onMetaData.duration*i.timescale:0,i.config=c.config,i.objectType=c.objectType,i.originObjectType=c.originObjectType,this.emit(d.EVENTS.AUDIO_META_PARSED,i),this._audioMetaParsed=!0}else{if(!this._audioMetaParsed&&!this.foundAudioMetaFromScriptTag)throw new Error("flv stream without audio metadata detected");e.data=e.data.slice(1,e.data.length),this._isEncrypt&&this._decryptor&&(e.data=this._decryptor.decryptAudio(e.data)),this.emit(d.EVENTS.AUDIO_SAMPLE_PARSED,e)}}},{key:"_parseVideoData",value:function(e,t){var i=t.shift(1)[0],r=new l(e),n=(240&i)>>>4;r.isKeyframe=1===n;var a=15&i;if(e.avcPacketType=t.shift(1)[0],r.cts=t.toInt(0,3),r.cts=r.cts<<8>>8,t.shift(3),7!==a&&12!==a&&14!==a)throw new Error("video codeid is ".concat(a));var s,o=12===a,u=14===a,c=t.shift(e.datasize-5);if(0===c[4]&&0===c[5]&&0===c[6]&&1===c[7]){for(var h=0,p=0;p<4;p++)h=256*h+c[p];h-=4,(c=c.slice(4,c.length))[3]=h%256,h=(h-c[3])/256,c[2]=h%256,h=(h-c[2])/256,c[1]=h%256,c[0]=(h-c[1])/256}if(c.length)if(r.data=c,0===e.avcPacketType)(s=o?this._hevcSequenceHeaderParser(c):u?this._vvcSequenceHeaderParser(c):this._avcSequenceHeaderParser(c)).codecID=a,this._videoRecentMetadata=s,this._vSeqHeaderIndex++,this.emit(d.EVENTS.VIDEO_META_PARSED,s);else{for(var v=new f(c.buffer),y=u?ue.getAvccNals(v):o?ge.getHvccNals(v):ve.getAvccNals(v),g=o?me:_e,m=!1,_=0;_10&&this.emit(d.EVENTS.VIDEO_SEI_PARSED,Object.assign(b.sei,{dts:e.dts})),g&&g.indexOf(b.type)>-1&&(r.firstInGop=!0,this._gopId++)}this._isEncrypt&&this._decryptor&&(r.data=this._doDecryptNals(y,o)),m||this._checkAppendMetadataNals(r),r.gopId=this._gopId,r.nals=y,this.emit(d.EVENTS.VIDEO_SAMPLE_PARSED,r)}}},{key:"_doDecryptNals",value:function(e,t){for(var i=0,r=[],n=0;n>>1&63:31&a.body[0];(t&&be.includes(s)||!t&&Ee.includes(s))&&(a.body=Z(a.body),a.body=this._decryptor.decryptVideo(a.body));var o=a.body.length;a.header=new Uint8Array([o>>24,o>>16,o>>8,o]),r.push(a.header),r.push(a.body),i+=o+4}var u=new Uint8Array(i),c=0;return r.forEach((function(e){u.set(e,c),c+=e.length})),u}},{key:"_checkAppendMetadataNals",value:function(e){if(this._vSeqHeaderIndex>1&&this._videoRecentMetadata&&e.firstInGop){var t,i,r,n=this._videoRecentMetadata.hvcCConfigParsed;n?(t=n.vpsArr[n.vpsArr.length-1],i=n.spsArr[n.spsArr.length-1],r=n.ppsArr[n.ppsArr.length-1]):(t=this._videoRecentMetadata.vps,i=this._videoRecentMetadata.sps,r=this._videoRecentMetadata.pps);var a=[t?[0,0,t.length>>8,t.length%256]:0,t,[0,0,i.length>>8,i.length%256],i,[0,0,r.length>>8,r.length%256],r,e.data].filter(Boolean),s=a.reduce((function(e,t){return e+t.length}),0),o=new Uint8Array(s),u=0;a.forEach((function(e){o.set(e,u),u+=e.length})),this._videoRecentMetadata=null,e.data=o}}},{key:"_avcSequenceHeaderParser",value:function(e){var t,i=0,r=new u;r.configurationVersion=e[0],r.avcProfileIndication=e[1],r.profileCompatibility=e[2],r.avcLevelIndication=e[3]/10,r.nalUnitLength=1+(3&e[4]);var n=31&e[5];i=6;for(var a={},s=0;s>>6,i.hevcTierFlag=(32&e[1])>>>5,i.hevcProfileIdc=31&e[1],i.hevcProfileCompatibilityFlags=[e[2],e[3],e[4],e[5]],i.hevcConstraintIndicatorFlags=[e[6],e[7],e[8],e[9],e[10],e[11]],i.hevcLevelIdc=e[12],i.minSpatialSegmentationIdc=e[13]&15+e[14]<<4,i.parallelismType=3&e[15],i.chromaFormat=3&e[16],i.bitDepthLumaMinus8=7&e[17],i.bitDepthChromaMinus8=7&e[18],i.avgFrameRate=256*e[19]+e[20],i.constantFrameRate=(192&e[21])>>>6,i.numTemporalLayers=(56&e[21])>>>3,i.temporalIdNested=(4&e[21])>>>2,i.lengthSizeMinusOne=3&e[21];var n=e[22];r=23;for(var a,s,o,c={},l=0,d=0,f=0,h=!1,p=!1,v=!1,y=0;y>>2]}},{key:"_switchAudioChannel",value:function(e){return[1,2][1&e]}},{key:"_datasizeValidator",value:function(e,t){var i=t.toInt(0,4);return t.shift(4),i===e+11}},{key:"destroy",value:function(){de(he(d.prototype),"removeAllListeners",this).call(this),this._decryptor&&(this._decryptor.destroy(),this._decryptor=null)}}],n=[{key:"EVENTS",get:function(){return{FILE_HEADER_PARSED:"FILE_HEADER_PARSED",SCRIPT_TAG_PARSED:"SCRIPT_TAG_PARSED",AUDIO_META_PARSED:"AUDIO_META_PARSED",VIDEO_META_PARSED:"VIDEO_META_PARSED",VIDEO_SAMPLE_PARSED:"VIDEO_SAMPLE_PARSED",AUDIO_SAMPLE_PARSED:"AUDIO_SAMPLE_PARSED",VIDEO_SEI_PARSED:"VIDEO_SEI_PARSED",PARSE_ERROR:"PARSE_ERROR"}}},{key:"isFlvFile",value:function(e){return!(70!==e[0]||76!==e[1]||86!==e[2]||1!==e[3])}},{key:"getPlayType",value:function(e){var t={hasVideo:!1,hasAudio:!1};return!0&e&&(t.hasVideo=!0),!0&e&&(t.hasAudio=!0),t}}],i&&le(t.prototype,i),n&&le(t,n),d}(Y());const Ae=ke;var Se=i(4682);function Te(e,t){for(var i=0;i0&&void 0!==arguments[0]?arguments[0]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.TAG="FLV_DEMUXER",this._cfg=t,this._firstFragmentLoaded=!1,this._trackNum=0,this._hasScript=!1,this._videoMetaChange=!1,this._audioMetaChange=!1,this._hasVideoSequence=!1,this._hasAudioSequence=!1,this._onMetaData=null,this.demuxer=new Ae(t)}var t,i,r;return t=e,r=[{key:"getPlayType",value:function(e){var t={hasVideo:!1,hasAudio:!1};return!0&e&&(t.hasVideo=!0),!0&e&&(t.hasAudio=!0),t}}],(i=[{key:"init",value:function(){this.on(we.DEMUX_START,this.demux.bind(this)),this.demuxer.on(De.FILE_HEADER_PARSED,this.handleFileHeaderParsed.bind(this)),this.demuxer.on(De.SCRIPT_TAG_PARSED,this.handleScriptTagParsed.bind(this)),this.demuxer.on(De.AUDIO_META_PARSED,this.handleAudioMetaParsed.bind(this)),this.demuxer.on(De.VIDEO_META_PARSED,this.handleVideoMetaParsed.bind(this)),this.demuxer.on(De.VIDEO_SAMPLE_PARSED,this.handleVideoSampleParsed.bind(this)),this.demuxer.on(De.AUDIO_SAMPLE_PARSED,this.handleAudioSampleParsed.bind(this)),this.demuxer.on(De.VIDEO_SEI_PARSED,this.handleSeiParsed.bind(this)),this.demuxer.on(De.VIDEO_SEI_PARSED,this.handleSeiParsed.bind(this)),this.demuxer.on(De.PARSE_ERROR,this.handlePraseError.bind(this))}},{key:"handleAudioMetaParsed",value:function(e){this._cfg.onlyVideo||this.tracks&&this.tracks.audioTrack&&(this._context.mediaInfo.hasAudio=!0,this.tracks.audioTrack.meta=e,this.tracks.audioTrack.hasSpecificConfig=!0,e.channelCount?this._hasAudioSequence?this.emit(we.AUDIO_METADATA_CHANGE,"audio"):this.emit(we.METADATA_PARSED,"audio"):this._context.mediaInfo.hasAudio=!1)}},{key:"handleVideoMetaParsed",value:function(e){this._cfg.onlyAudio||this.tracks&&this.tracks.videoTrack&&(this._onMetaData&&this._onMetaData.framerate&&e.frameRate&&(e.frameRate.fps=this._onMetaData.framerate),this._context.mediaInfo.hasVideo=!0,this.tracks.videoTrack.meta=e,this.tracks.videoTrack.hasSpecificConfig=!0,this._hasVideoSequence?this.emit(we.VIDEO_METADATA_CHANGE,"video"):(this.emit(we.METADATA_PARSED,"video"),this._hasVideoSequence=!0))}},{key:"handleSeiParsed",value:function(e){this.emit(we.SEI_PARSED,e)}},{key:"handleVideoSampleParsed",value:function(e){this._cfg.onlyAudio||this.tracks&&this.tracks.videoTrack&&(e.isKeyframe&&this.emit(we.ISKEYFRAME,e.dts+e.cts,e.cts),this.tracks.videoTrack.samples.push(e))}},{key:"handleAudioSampleParsed",value:function(e){var t;this._cfg.onlyVideo||this.tracks&&this.tracks.audioTrack&&null!==(t=this.tracks.audioTrack)&&void 0!==t&&t.meta.channelCount&&this.tracks.audioTrack.samples.push(e)}},{key:"handleScriptTagParsed",value:function(e){if(e){this._onMetaData=e;var t=this.tracks,i=t.videoTrack,r=t.audioTrack;if(this._context.mediaInfo.duration=e.duration,"boolean"==typeof e.hasAudio&&(this._context.mediaInfo.hsaAudio=!this._cfg.onlyVideo&&e.hasAudio),"boolean"==typeof e.hasVideo&&(this._context.mediaInfo.hasVideo=!this._cfg.onlyAudio&&e.hasVideo),this.emit(we.MEDIA_INFO),this._hasScript=!0,r&&!r.hasSpecificConfig){var n=r.meta;switch(e.audiosamplerate&&(n.sampleRate=e.audiosamplerate),e.audiochannels&&(n.channelCount=e.audiochannels),e.audiosamplerate){case 44100:n.sampleRateIndex=4;break;case 22050:n.sampleRateIndex=7;break;case 11025:n.sampleRateIndex=10}}if(i&&!i.hasSpecificConfig){var a=i.meta;if("number"==typeof e.framerate){var s=Math.floor(1e3*e.framerate);if(s>0){var o=s/1e3;a.frameRate||(a.frameRate={}),a.frameRate.fixed=!0,a.frameRate.fps=o,a.frameRate.fps_num=s,a.frameRate.fps_den=1e3}}}}}},{key:"handleFileHeaderParsed",value:function(e){var t=e.hasVideo,i=e.hasAudio;this._context.mediaInfo.hasVideo=!this._cfg.onlyAudio&&t,this._context.mediaInfo.hasAudio=!this._cfg.onlyVideo&&i,this.initVideoTrack(),this.initAudioTrack()}},{key:"handlePraseError",value:function(e){this.emit(we.DEMUX_ERROR,this.TAG,e)}},{key:"demux",value:function(){if(this.loaderBuffer){try{this.demuxer.demux(this.loaderBuffer)}catch(e){return void this.emit(we.DEMUX_ERROR,this.TAG,e)}this.emit(we.DEMUX_COMPLETE)}}},{key:"initVideoTrack",value:function(){this._trackNum++;var e=new Se.Dc;e.meta=new u,e.id=e.meta.id=this._trackNum,this.tracks.videoTrack=e}},{key:"initAudioTrack",value:function(){this._trackNum++;var e=new Se.IT;e.meta=new o,e.id=e.meta.id=this._trackNum,this.tracks.audioTrack=e}},{key:"loaderBuffer",get:function(){var e=this._context.getInstance("LOADER_BUFFER");if(e)return e;this.emit(we.DEMUX_ERROR,this.TAG,new Error("no found loaderBuffer"))}},{key:"tracks",get:function(){return this._context.getInstance("TRACKS")}},{key:"logger",get:function(){return this._context.getInstance("LOGGER")}},{key:"destroy",value:function(){this.demuxer&&this.demuxer.destroy()}}])&&Te(t.prototype,i),r&&Te(t,r),e}();const Be=Re},57759:(e,t,i)=>{i.d(t,{A:()=>S});var r=i(65907),n=i(96865),a=i(42990),s=i.n(a),o=i(23722),u=i.n(o);function c(e,t){for(var i=0;i>24,e>>16&255,e>>8&255,255&e])}},{key:"readAsInt",value:function(e){var t="";return e.forEach((function(e){t+=e.toString(16).padStart(2,"0")})),parseInt(t,16)}}],i&&c(t.prototype,i),r&&c(t,r),e}();function d(e){return function(e){if(Array.isArray(e))return f(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return f(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?f(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function f(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,r=new Array(t);i2?n-2:0),s=2;s>16&255,t>>8&255,255&t])}},{key:"ftyp",value:function(){return e.initBox(24,"ftyp",new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]))}},{key:"ftypHEVC",value:function(){return e.initBox(24,"ftyp",new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,100,97,115,104]))}},{key:"moov",value:function(t){var i,r=t.type,n=t.meta,a=8,s=e.mvhd(n.duration,n.timescale);i="video"===r?e.videoTrak(n):e.audioTrak(n);var o=e.mvex(n.duration,n.timescale||1e3,n.id);return[s,i,o].forEach((function(e){a+=e.byteLength})),e.initBox(a,"moov",s,i,o)}},{key:"mvhd",value:function(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3,r=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i,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]);return e.initBox(8+r.length,"mvhd",new Uint8Array(r))}},{key:"videoTrak",value:function(t){var i=8,r=e.tkhd({id:1,duration:t.duration,timescale:t.timescale||1e3,width:t.presentWidth,height:t.presentHeight,type:"video"}),n=e.mdia({type:"video",timescale:t.timescale||1e3,duration:t.duration,avcc:t.avcc,vvcC:t.vvcC,hvcCConfigParsed:t.hvcCConfigParsed,parRatio:t.parRatio,width:t.presentWidth,height:t.presentHeight,streamType:t.streamType});return[r,n].forEach((function(e){i+=e.byteLength})),e.initBox(i,"trak",r,n)}},{key:"audioTrak",value:function(t){var i=8,r=e.tkhd({id:2,duration:t.duration,timescale:t.timescale||1e3,width:0,height:0,type:"audio"}),n=e.mdia({type:"audio",timescale:t.timescale||1e3,duration:t.duration,channelCount:t.channelCount,samplerate:t.sampleRate,config:t.config});return[r,n].forEach((function(e){i+=e.byteLength})),e.initBox(i,"trak",r,n)}},{key:"tkhd",value:function(t){var i=t.id,r=t.duration,n=t.width,a=t.height,s=new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i,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,n>>>8&255,255&n,0,0,a>>>8&255,255&a,0,0]);return e.initBox(8+s.byteLength,"tkhd",s)}},{key:"edts",value:function(t){var i=new l,r=t.duration,n=t.mediaTime;return i.write(e.size(36),e.type("edts")),i.write(e.size(28),e.type("elst")),i.write(new Uint8Array([0,0,0,1,r>>24&255,r>>16&255,r>>8&255,255&r,n>>24&255,n>>16&255,n>>8&255,255&n,0,0,0,1])),i.buffer}},{key:"mdia",value:function(t){var i=8,r=e.mdhd(t.timescale,t.duration),n=e.hdlr(t.type),a=e.minf(t);return[r,n,a].forEach((function(e){i+=e.byteLength})),e.initBox(i,"mdia",r,n,a)}},{key:"mdhd",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1e3,i=arguments.length>1?arguments[1]:void 0,r=new Uint8Array([0,0,0,0,0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t,i>>>24&255,i>>>16&255,i>>>8&255,255&i,85,196,0,0]);return e.initBox(12+r.byteLength,"mdhd",e.extension(0,0),r)}},{key:"hdlr",value:function(t){var i=[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];return"audio"===t&&(i.splice.apply(i,[8,4].concat([115,111,117,110])),i.splice.apply(i,[24,13].concat([83,111,117,110,100,72,97,110,100,108,101,114,0]))),e.initBox(8+i.length,"hdlr",new Uint8Array(i))}},{key:"minf",value:function(t){var i=8,r="video"===t.type?e.vmhd():e.smhd(),n=e.dinf(),a=e.stbl(t);return[r,n,a].forEach((function(e){i+=e.byteLength})),e.initBox(i,"minf",r,n,a)}},{key:"vmhd",value:function(){return e.initBox(20,"vmhd",new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]))}},{key:"smhd",value:function(){return e.initBox(16,"smhd",new Uint8Array([0,0,0,0,0,0,0,0]))}},{key:"dinf",value:function(){var t=new l;return t.write(e.size(36),e.type("dinf"),e.size(28),e.type("dref"),new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1])),t.buffer}},{key:"stbl",value:function(t){var i=8,r=e.stsd(t),n=e.stts(),a=e.stsc(),s=e.stsz(),o=e.stco();return[r,n,a,s,o].forEach((function(e){i+=e.byteLength})),e.initBox(i,"stbl",r,n,a,s,o)}},{key:"stsd",value:function(t){var i;return i="audio"===t.type?e.mp4a(t):36===t.streamType||t.vvcC?e.hvc1vvc1(t):e.avc1(t),e.initBox(16+i.byteLength,"stsd",e.extension(0,0),new Uint8Array([0,0,0,1]),i)}},{key:"mp4a",value:function(t){var i=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,t.samplerate>>8&255,255&t.samplerate,0,0]),r=e.esds(t.config);return e.initBox(8+i.byteLength+r.byteLength,"mp4a",i,r)}},{key:"esds",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[43,146,8,0],i=t.length,r=new l,n=new Uint8Array([0,0,0,0,3,23+i,0,1,0,4,15+i,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([i]).concat(t).concat([6,1,2]));return r.write(e.size(8+n.byteLength),e.type("esds"),n),r.buffer}},{key:"avc1",value:function(t){var i=new l,r=t.width,n=t.height,a=t.parRatio.width,s=t.parRatio.height,o=t.avcc,u=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,n>>8&255,255&n,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]),c=new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192]),d=new Uint8Array([a>>24,a>>16&255,a>>8&255,255&a,s>>24,s>>16&255,s>>8&255,255&s]);return i.write(e.size(40+u.byteLength+o.byteLength+c.byteLength),e.type("avc1"),u,e.size(8+o.byteLength),e.type("avcC"),o,e.size(20),e.type("btrt"),c,e.size(16),e.type("pasp"),d),i.buffer}},{key:"hvc1vvc1",value:function(t){var i=new l,r=[0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,t.width>>8&255,255&t.width,t.height>>8&255,255&t.height,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,17,17],n=!!t.vvcC,a=n?e.vvcC(t):e.hvcC(t),s=[e.type(n?"vvc1":"hvc1"),new Uint8Array(r)].concat(d(a));t.parRatio&&s.push.apply(s,d(e.pasp(t.parRatio)));var o=4+s.reduce((function(e,t){return e+t.byteLength}),0);return s.unshift(e.size(o)),i.write.apply(i,d(s)),i.buffer}},{key:"hvcC",value:function(t){var i;if(t.hvcCConfigParsed){var r=t.hvcCConfigParsed,n=r.vpsArr,a=r.spsArr,s=r.ppsArr,o=r.hvcC,u=o.generalProfileCompatibilityFlags,c=o.generalConstraintIndicatorFlags,l=(n.length&&1)+(a.length&&1)+(s.length&&1);i=[1,o.generalProfileSpace<<6|o.generalTierFlag<<5|o.generalProfileIdc,u>>>24,u>>>16,u>>>8,u,c[0],c[1],c[2],c[3],c[4],c[5],o.generalLevelIdc,240,0,252,252|o.chromaFormatIdc,248|o.bitDepthLumaMinus8,248|o.bitDepthChromaMinus8,0,0,o.numTemporalLayers<<3|o.temporalIdNested<<2|3,l];var f=function(e){var t;i.push(e.length>>8,e.length),(t=i).push.apply(t,d(e))};n.length&&(i.push(160,0,n.length),n.forEach(f)),a.length&&(i.push(161,0,a.length),a.forEach(f)),s.length&&(i.push(162,0,s.length),s.forEach(f))}else i=[1,1,96,0,0,0,144,0,0,0,0,0,93,240,0,252,253,248,248,0,0,15,3,160,0,1,0,24,64,1,12,1,255,255,1,96,0,0,3,0,144,0,0,3,0,0,3,0,93,153,152,9,161,0,1,0,45,66,1,1,1,96,0,0,3,0,144,0,0,3,0,0,3,0,93,160,2,128,128,45,22,89,153,164,147,43,154,128,128,128,130,0,0,3,0,2,0,0,3,0,50,16,162,0,1,0,7,68,1,193,114,180,98,64];return[e.size(8+i.length),e.type("hvcC"),new Uint8Array(i)]}},{key:"vvcC",value:function(t){var i=t.vvcC;return[e.size(8+i.byteLength),e.type("vvcC"),i]}},{key:"fiel",value:function(){return[e.size(10),e.type("fiel"),new Uint8Array([1,0])]}},{key:"pasp",value:function(t){if(t.width&&t.height){var i=t.width,r=t.height;return[e.size(16),e.type("pasp"),new Uint8Array([i>>24,i>>16&255,i>>8&255,255&i,r>>24,r>>16&255,r>>8&255,255&r])]}return[]}},{key:"stts",value:function(){var t=new Uint8Array([0,0,0,0,0,0,0,0]);return e.initBox(16,"stts",t)}},{key:"stsc",value:function(){var t=new Uint8Array([0,0,0,0,0,0,0,0]);return e.initBox(16,"stsc",t)}},{key:"stco",value:function(){var t=new Uint8Array([0,0,0,0,0,0,0,0]);return e.initBox(16,"stco",t)}},{key:"stsz",value:function(){var t=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]);return e.initBox(20,"stsz",t)}},{key:"mvex",value:function(t){var i=arguments.length>2?arguments[2]:void 0,r=new l,n=l.writeUint32(t);return r.write(e.size(56),e.type("mvex"),e.size(16),e.type("mehd"),e.extension(0,0),n,e.trex(i)),r.buffer}},{key:"trex",value:function(t){var i=new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return e.initBox(8+i.byteLength,"trex",i)}},{key:"moof",value:function(t){var i=8,r=e.mfhd(),n=e.traf(t);return[r,n].forEach((function(e){i+=e.byteLength})),e.initBox(i,"moof",r,n)}},{key:"mfhd",value:function(){var t=l.writeUint32(e.sequence);return e.sequence+=1,e.initBox(16,"mfhd",e.extension(0,0),t)}},{key:"traf",value:function(t){var i=8,r=e.tfhd(t.id),n=e.tfdt(t.time),a=e.sdtp(t),s=e.trun(t,a.byteLength);return[r,n,s,a].forEach((function(e){i+=e.byteLength})),e.initBox(i,"traf",r,n,s,a)}},{key:"tfhd",value:function(t){var i=l.writeUint32(t);return e.initBox(16,"tfhd",e.extension(0,0),i)}},{key:"tfdt",value:function(t){return e.initBox(16,"tfdt",e.extension(0,0),l.writeUint32(t))}},{key:"trun",value:function(t,i){var r=new l,n=l.writeUint32(t.samples.length),a=l.writeUint32(92+16*t.samples.length+i);return r.write(e.size(20+16*t.samples.length),e.type("trun"),new Uint8Array([0,0,15,1]),n,a),t.samples.forEach((function(e){var t=e.flags;r.write(new Uint8Array([e.duration>>>24&255,e.duration>>>16&255,e.duration>>>8&255,255&e.duration,e.size>>>24&255,e.size>>>16&255,e.size>>>8&255,255&e.size,t.isLeading<<2|t.dependsOn,t.isDependedOn<<6|t.hasRedundancy<<4|t.isNonSync,0,0,e.cts>>>24&255,e.cts>>>16&255,e.cts>>>8&255,255&e.cts]))})),r.buffer}},{key:"sdtp",value:function(t){var i=new l;return i.write(e.size(12+t.samples.length),e.type("sdtp"),e.extension(0,0)),t.samples.forEach((function(e){var t=e.flags,r=t.isLeading<<6|t.dependsOn<<4|t.isDependedOn<<2|t.hasRedundancy;i.write(new Uint8Array([r]))})),i.buffer}},{key:"mdat",value:function(t){var i=new l,r=8;t.samples.forEach((function(e){r+=e.size})),i.write(e.size(r),e.type("mdat"));var n=new Uint8Array(r),a=0;return n.set(i.buffer,a),a+=8,t.samples.forEach((function(e){e.buffer.forEach((function(e){n.set(e,a),a+=e.byteLength}))})),n}}],null&&h(t.prototype,null),i&&h(t,i),e}();p.type=function(e){return new Uint8Array([e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)])},p.sequence=1;const v=p;function y(e){return y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},y(e)}function g(e,t){for(var i=0;i0;){var h=r.shift(),p=h.isKeyframe,y=h.options;if(!this.isFirstVideo&&y&&y.meta){s=this.remuxInitSegment("video",y.meta),y.meta=null,r.unshift(h),y.isContinue||(this._videoDtsBase=0);break}var g=Math.max(0,h.dts-this.videoDtsBase);-1===a&&(a=g);var m=void 0,_=void 0;void 0!==h.pts&&(m=(_=h.pts-this._dtsBase)-g),void 0!==h.cts&&(_=h.cts+g,m=h.cts);var b,E={buffer:[],size:0};b=h.duration?h.duration:r.length>=1?r[0].dts-this.videoDtsBase-g:o.length>=1?o[o.length-1].duration:this._videoMeta.refSampleDuration,this.videoAllDuration+=b,n.A.long&&n.A.log(this.TAG,"video dts ".concat(g),"pts ".concat(_),"cts: ".concat(m),p,"originDts ".concat(h.originDts),"duration ".concat(b),f),b>=0&&(c.samples.push(E),E.buffer.push(h.data),E.size+=h.data.byteLength,o.push({dts:g,cts:m,pts:_,data:h.data,size:h.data.byteLength,isKeyframe:p,duration:b,flags:{isLeading:0,dependsOn:p||this.forceFirstIDR&&f?2:1,isDependedOn:p?1:0,hasRedundancy:0,isNonSync:p||this.forceFirstIDR&&f?0:1},originDts:g,type:"video"}),f=!1,this.mp4Durations[_]=b,this.mp4Durations.keys.push(_)),p&&this.emit(u.EVENTS.RANDOM_ACCESS_POINT,_)}if(this.mp4Durations.keys.length>1e4){var k=this.mp4Durations;this.mp4Durations={},this.mp4Durations.keys=k.keys.slice(-100),this.mp4Durations.keys.forEach((function(e){t.mp4Durations[e]=k[e]}))}o.length&&n.A.log(this.TAG,"remux to mp4 video:",[a/1e3,o[o.length-1].dts/1e3]);var A=new l;if(o.length&&i.meta){var S=v.moof({id:i.meta.id,time:a,samples:o}),T=v.mdat(c);A.write(S,T),this.segmentRemuxed("video",A,o[o.length-1].pts-o[0].pts)}if(s&&(this.segmentRemuxed("video",s),r.length))return i.samples=r,this.remuxVideo(i);this.isFirstVideo=!1,this.emit(u.EVENTS.TRACK_REMUXED,"video",A),i.samples=[],i.length=0}}}},{key:"remuxAudio",value:function(e){var t=(e||{}).samples,i=-1,r=[],a=null,s={samples:[]};if(t&&t.length){for(var o=1e4,c=!1;t.length&&o-- >0;){var d=t.shift(),f=d.data,h=d.options;if(!this.isFirstAudio&&h&&h.meta){a=this.remuxInitSegment("audio",h.meta),h.meta=null,t.unshift(d),h.isContinue||(this._audioDtsBase=0);break}var p=Math.max(0,d.dts-this.audioDtsBase),y=d.originDts;c||(i=p,c=!0);var g;g=d.duration?d.duration:this._audioMeta.refSampleDurationFixed?this._audioMeta.refSampleDurationFixed:t.length>=1?t[0].dts-this.audioDtsBase-p:r.length>=1?r[r.length-1].duration:this._audioMeta.refSampleDuration,n.A.long&&n.A.log(this.TAG,"audio dts ".concat(p),"pts ".concat(p),"originDts ".concat(y),"duration ".concat(g)),this.audioAllDuration+=g;var m={dts:p,pts:p,cts:0,size:f.byteLength,duration:d.duration?d.duration:g,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0,isNonSync:0},isKeyframe:!0,originDts:y,type:"audio"},_={buffer:[],size:0};g>=0&&(_.buffer.push(f),_.size+=f.byteLength,s.samples.push(_),r.push(m))}var b=new l;if(r.length&&e.meta){n.A.log(this.TAG,"remux to mp4 audio:",[i/1e3,r[r.length-1].dts/1e3]);var E=v.moof({id:e.meta.id,time:i,samples:r}),k=v.mdat(s);b.write(E,k),this.segmentRemuxed("audio",b,r[r.length-1].dts-r[0].dts)}if(a&&(this.segmentRemuxed("audio",a),t.length))return e.samples=t,this.remuxAudio(e);this.isFirstAudio=!1,this.emit(u.EVENTS.TRACK_REMUXED,"audio",b),e.samples=[],e.length=0}}},{key:"segmentRemuxed",value:function(e,t,i){this.emit(u.EVENTS.MEDIA_SEGMENT,e,t,i)}},{key:"videoDtsBase",get:function(){return null!==this._videoDtsBase?this._videoDtsBase:this._dtsBase},set:function(e){this._videoDtsBase=e}},{key:"audioDtsBase",get:function(){return null!==this._audioDtsBase?this._audioDtsBase:this._dtsBase}}])&&g(t.prototype,i),r&&g(t,r),u}(s());function E(e,t){for(var i=0;i0&&void 0!==arguments[0]?arguments[0]:0;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.TAG="Mp4Remuxer",this._curTime=t,this.remuxer||this.initRemuxer()}var t,i;return t=e,(i=[{key:"init",value:function(){this.on(k.REMUX_MEDIA,this.remux.bind(this)),this.on(k.REMUX_METADATA,this.onMetaDataReady.bind(this)),this.on(k.DETECT_CHANGE_STREAM,this.resetDtsBase.bind(this)),this.on(k.DETECT_FRAG_ID_DISCONTINUE,this.seek.bind(this)),this.on(A.SEEK,this.seek.bind(this))}},{key:"initRemuxer",value:function(){this.remuxer=new b({audioMeta:null,videoMeta:null,curTime:this._curTime}),this.remuxer.on(b.EVENTS.MEDIA_SEGMENT,this.writeToSource.bind(this)),this.remuxer.on(b.EVENTS.TRACK_REMUXED,this.onTrackRemuxed.bind(this))}},{key:"remux",value:function(){if(this.remuxer&&this.videoTrack)try{this.remuxer._videoMeta||(this.remuxer._videoMeta=this.videoMeta,this.remuxer._audioMeta=this.audioMeta);var e=this._context.getInstance("TRACKS"),t=e.audioTrack,i=e.videoTrack;this.remuxer.remux(t,i)}catch(e){console.log(e),this.emit(k.REMUX_ERROR,this.TAG,e)}}},{key:"resetDtsBase",value:function(){this.remuxer&&this.remuxer.resetDtsBase()}},{key:"seek",value:function(e){this.remuxer&&this.remuxer.seek(e)}},{key:"onMetaDataReady",value:function(e,t){var i;this.remuxer||this.initRemuxer(),i="audio"===e?this._context.getInstance("TRACKS").audioTrack:this._context.getInstance("TRACKS").videoTrack;var r=this._context.getInstance("PRE_SOURCE_BUFFER"),n=r.getSource(e);n||(n=r.createSource(e)),n.mimetype=i.meta.codec,n.init=this.remuxer.remuxInitSegment(e,i.meta),t&&this.writeToSource(e,n.init,0),this.emit(k.INIT_SEGMENT,e)}},{key:"onTrackRemuxed",value:function(e){this.emit(k.MEDIA_SEGMENT,e)}},{key:"writeToSource",value:function(e,t,i){var r=this._context.getInstance("PRE_SOURCE_BUFFER"),n=r.getSource(e);n||(n=r.createSource(e)),n.data.push(t),i&&(n.bufferDuration=i+(n.bufferDuration||0))}},{key:"videoTrack",get:function(){return this._context.getInstance("TRACKS").videoTrack}},{key:"audioTrack",get:function(){return this._context.getInstance("TRACKS").audioTrack}},{key:"videoMeta",get:function(){return this.videoTrack.meta}},{key:"audioMeta",get:function(){return this.audioTrack.meta}},{key:"destroy",value:function(){this.remuxer&&this.remuxer.destroy(),this.remuxer=null}}])&&E(t.prototype,i),e}()},51223:(e,t,i)=>{function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,r=new Array(t);ia});const a=new(function(){function e(){var t=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e);try{var i=/xgd=(\d)/.exec(document.cookie);this._status=!!i,this._level=i&&i[1]}catch(e){this._status=!1}["group","groupEnd","log","warn","error","trace"].forEach((function(e){t[e]=function(i,n,a,s,o,u,c,l,d,f){var h,p;if(t._status){var v=i,y=[n,a,s,o,u,c,l,d,f].filter((function(e){return void 0!==e}));(h=console)[e].apply(h,["["+v+"]:"].concat(function(e){if(Array.isArray(e))return r(e)}(p=y)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(p)||function(e,t){if(e){if("string"==typeof e)return r(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?r(e,t):void 0}}(p)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()))}}}))}var t,i;return t=e,(i=[{key:"enable",get:function(){return this._status}},{key:"long",get:function(){return"2"===this._level}}])&&n(t.prototype,i),e}())},78082:(e,t,i)=>{function r(){var e,t=!1,i=!1;try{var r=new(window.AudioContext||window.webkitAudioContext);r.close(),r=null,t=!0}catch(e){}try{for(var n=document.createElement("canvas"),a=["webgl","experimental-webgl","moz-webgl","webkit-3d"],s=0;sr})},14242:(e,t,i)=>{i.d(t,{A:()=>g});var r=i(6753);function n(e,t){for(var i=0;i2&&void 0!==arguments[2]?arguments[2]:[];h(this,e),this._emitter=new(u()),this._emitter.off||(this._emitter.off=this._emitter.removeListener),this.mediaInfo=new s,this._instanceMap={},this._clsMap={},this._inited=!1,this.allowedEvents=r,this._configs=i,this._player=t,this._hooks={}}return v(e,[{key:"getInstance",value:function(e){return this._instanceMap[e]||null}},{key:"initInstance",value:function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r1?i-1:0),o=1;o2?i-2:0),s=2;s{function r(e,t){for(var i=0;ia});var n=i(6753).A.CRYPTO_EVENTS;const a=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.inputBuffer=t.inputbuffer,this.outputBuffer=t.outputbuffer,this.key=t.key,this.iv=t.iv,this.method=t.method,this.crypto=window.crypto||window.msCrypto}var t,i;return t=e,(i=[{key:"init",value:function(){this.on(n.START_DECRYPTO,this.decrypto.bind(this))}},{key:"decrypto",value:function(){var e=this;this.aeskey?this.decryptoData():this.crypto.subtle.importKey("raw",this.key.buffer,{name:"AES-CBC"},!1,["encrypt","decrypt"]).then((function(t){e.aeskey=t,e.decryptoData()}))}},{key:"decryptoData",value:function(){var e=this,t=this._context.getInstance(this.inputBuffer),i=this._context.getInstance(this.outputBuffer),r=t.shift();r&&this.crypto.subtle.decrypt({name:"AES-CBC",iv:this.iv.buffer},this.aeskey,r).then((function(t){i.push(new Uint8Array(t)),e.emit(n.DECRYPTED),e.decryptoData(r)}))}}])&&r(t.prototype,i),e}()},6753:(e,t,i)=>{i.d(t,{A:()=>v});var r={VISIBILITY_CHANGE:"VISIBILITY_CHANGE"},n={SEEK:"SEEK"},a={LADER_START:"LOADER_START",LOADER_DATALOADED:"LOADER_DATALOADED",LOADER_COMPLETE:"LOADER_COMPLETE",LOADER_RESPONSE_HEADERS:"LOADER_RESPONSE_HEADERS",LOADER_ERROR:"LOADER_ERROR",LOADER_RETRY:"LOADER_RETRY",LOADER_TTFB:"LOADER_TTFB"},s={DEMUX_START:"DEMUX_START",DEMUX_COMPLETE:"DEMUX_COMPLETE",DEMUX_ERROR:"DEMUX_ERROR",METADATA_PARSED:"METADATA_PARSED",SEI_PARSED:"SEI_PARSED",VIDEO_METADATA_CHANGE:"VIDEO_METADATA_CHANGE",AUDIO_METADATA_CHANGE:"AUDIO_METADATA_CHANGE",MEDIA_INFO:"MEDIA_INFO",ISKEYFRAME:"ISKEYFRAME"},o={REMUX_METADATA:"REMUX_METADATA",REMUX_MEDIA:"REMUX_MEDIA",MEDIA_SEGMENT:"MEDIA_SEGMENT",REMUX_ERROR:"REMUX_ERROR",INIT_SEGMENT:"INIT_SEGMENT",DETECT_CHANGE_STREAM:"DETECT_CHANGE_STREAM",DETECT_CHANGE_STREAM_DISCONTINUE:"DETECT_CHANGE_STREAM_DISCONTINUE",DETECT_AUDIO_GAP:"DETECT_AUDIO_GAP",DETECT_LARGE_GAP:"DETECT_LARGE_GAP",DETECT_AUDIO_OVERLAP:"DETECT_AUDIO_OVERLAP",RANDOM_ACCESS_POINT:"RANDOM_ACCESS_POINT",DETECT_FRAG_ID_DISCONTINUE:"DETECT_FRAG_ID_DISCONTINUE"},u={SOURCE_UPDATE_END:"SOURCE_UPDATE_END",MSE_ERROR:"MSE_ERROR",MSE_WRONG_TRACK_ADD:"MSE_WRONG_TRACK_ADD",MSE_CHANGE_CODEC_ERROR:"MSE_CHANGE_CODEC_ERROR"},c={RETRY_TIME_EXCEEDED:"RETRY_TIME_EXCEEDED"},l=Object.assign({},a,s,o,u,c,n,r),d=[],f=[];for(var h in l)l.hasOwnProperty(h)&&d.push(l[h]);for(var p in l)l.hasOwnProperty(p)&&f.push(l[p]);const v={ALLEVENTS:l,HLS_EVENTS:c,REMUX_EVENTS:o,DEMUX_EVENTS:s,MSE_EVENTS:u,LOADER_EVENTS:a,FlvAllowedEvents:d,HlsAllowedEvents:f,CRYPTO_EVENTS:{START_DECRYPTOO:"START_DECRYPTO",DECRYPTED:"DECRYPTED"},PLAYER_EVENTS:n,BROWSER_EVENTS:r}},43043:(e,t,i)=>{i.d(t,{A:()=>l});var r=i(6753);function n(e,t){for(var i=0;i3&&(this._sampleQueue=[]),this._sampleQueue.push(e),this._calcAvgSpeed(this._sampleQueue)}},{key:"_calcAvgSpeed",value:function(e){var t=e.length,i=e.reduce((function(e,t){return e+t}),0)/t;this._speed=1e3*Math.floor(i)}},{key:"_cleanTimer",value:function(){clearTimeout(this._timer),this._timer=0}},{key:"clean",value:function(){this._cleanTimer()}},{key:"destroy",value:function(){clearTimeout(this._timer)}},{key:"totalByteSize",get:function(){return this._totalByteSize}},{key:"avgSpeed",get:function(){return this._speed||this._addSample(this._calcSampleSpeed()),8*this._speed}},{key:"recentSpeed",get:function(){return this._recentSpeed||this._addSample(this._calcSampleSpeed()),8*this._recentSpeed}}])&&n(t.prototype,i),e}();function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}function u(e,t){for(var i=0;i4&&void 0!==arguments[4]?arguments[4]:0,s=arguments.length>5?arguments[5]:void 0,o=arguments.length>6?arguments[6]:void 0;if(!this._destroyed)return this.loading=!0,this.fetch(this.url,t,s).then((function(u){if(!n._destroyed&&n.emit(c.LOADER_RESPONSE_HEADERS,n.TAG,u.headers),n._responseHeader=u.headers,u.ok)return n.status=u.status,Promise.resolve().then((function(){n._onFetchResponse(u,o)})),Promise.resolve(u);i-- >0?n._retryTimer=setTimeout((function(){return n.emit(c.LOADER_RETRY,n.TAG,{response:u,reason:"response not ok",retryTime:r-i}),n.internalLoad(e,t,i,r,a,s,o)}),a):(n.loading=!1,n.emit(c.LOADER_ERROR,n.TAG,{code:u.status||21,message:"".concat(u.status," (").concat(u.statusText,")")}))})).catch((function(u){if(n._destroyed||u&&"AbortError"===u.name)n.loading=!1;else if(i-- >0)n._retryTimer=setTimeout((function(){return n.emit(c.LOADER_RETRY,n.TAG,{error:u,reason:"fetch error",retryTime:r-i}),n.internalLoad(e,t,i,r,a,s,o)}),a);else{if(n.loading=!1,u&&"AbortError"===u.name)return;n.emit(c.LOADER_ERROR,n.TAG,Object.assign({code:21},u))}}))}},{key:"load",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=i.retryCount,n=i.retryDelay,a=i.loadTimeout,s=i.maxReaderInterval;if(e){r=void 0===r?3:r,this.url=e,this._canceled=!1;var o=this.getParams(t);return this.internalLoad(e,o,r,r,n,a,s)}this.emit(c.LOADER_ERROR,this.TAG,{code:0,message:"empty url"})}},{key:"_onFetchResponse",value:function(e,t){var i=this,r=this,n=this._context.getInstance(this.buffer);this._loaderTaskNo++;var a=this._loaderTaskNo;if(!0===e.ok){var s;switch(this.readtype){case 2:s=e.json();break;case 1:s=e.text();break;case 3:s=e.arrayBuffer();break;default:return this._onReader(e.body.getReader(),a,t)}if(!s)return;s.then((function(e){var t;null===(t=i._speed)||void 0===t||t.recordLoaded(),r.loading=!1,r._canceled||r._destroyed||(n?(n.push(e instanceof ArrayBuffer?new Uint8Array(e):e),r.emit(c.LOADER_COMPLETE,n)):r.emit(c.LOADER_COMPLETE,e))})).catch((function(){}))}}},{key:"_onReader",value:function(e,t,i){var r=this,n=this._context.getInstance(this.buffer);if(!n&&this._reader||this._destroyed)try{this._reader.cancel()}catch(e){}this._reader=e,!1!==this.loading&&(this._noDataTimer=setTimeout((function(){!1!==r.loading&&r.emit(c.LOADER_COMPLETE,"nobuffer")}),i||3e3),this._reader&&this._reader.read().then((function(a){var s,o;if(clearTimeout(r._noDataTimer),!r._canceled&&!r._destroyed)return a.done?(r.loading=!1,r.status=0,null===(o=r._speed)||void 0===o||o.destroy(),void Promise.resolve().then((function(){r.emit(c.LOADER_COMPLETE,"done")}))):(n.push(a.value),null===(s=r._speed)||void 0===s||s.recordChunk(a.value.byteLength),Promise.resolve().then((function(){r.emit(c.LOADER_DATALOADED,n)})),r._onReader(e,t,i));if(r._reader)try{r._reader.cancel()}catch(e){}})).catch((function(e){clearTimeout(r._noDataTimer),r.loading=!1,(!e||"AbortError"!==e.name&&"network error"!==e.message)&&r.emit(c.LOADER_ERROR,r.TAG,e)})))}},{key:"getParams",value:function(e){var t=Object.assign({},e),i=new Headers,r={method:"GET",headers:i,mode:"cors",cache:"default"};if("object"===o(this.configs.headers)){var n=this.configs.headers;for(var a in n)n.hasOwnProperty(a)&&i.append(a,n[a])}if("object"===o(t.headers)){var s=t.headers;for(var u in s)s.hasOwnProperty(u)&&i.append(u,s[u])}return!1===t.cors&&(r.mode="same-origin"),t.withCredentials&&(r.credentials="include"),r}},{key:"ttfbInfo",get:function(){return this._ttfbInfo}},{key:"avgSpeed",get:function(){var e;return(null===(e=this._speed)||void 0===e?void 0:e.avgSpeed)||0}},{key:"recentSpeed",get:function(){var e;return(null===(e=this._speed)||void 0===e?void 0:e.recentSpeed)||0}},{key:"currentSpeed",get:function(){var e;return(null===(e=this._speed)||void 0===e?void 0:e.avgSpeed)/8e3}},{key:"totalByteSize",get:function(){var e;return null===(e=this._speed)||void 0===e?void 0:e.totalByteSize}},{key:"responseHeader",get:function(){return this._responseHeader}},{key:"cancel",value:function(){var e;if(this._reader){try{var t=this._reader.cancel();t.catch&&t.catch((function(e){}))}catch(e){}this._reader=null,this.loading=!1}clearTimeout(this._noDataTimer),this._canceled=!0,this.abortController&&this.abortController.abort(),null===(e=this._speed)||void 0===e||e.clean()}},{key:"destroy",value:function(){var e;this._destroyed=!0,this._responseHeader=null,clearTimeout(this._retryTimer),clearTimeout(this._noDataTimer),this.cancel(),null===(e=this._speed)||void 0===e||e.destroy(),this._speed=null}}],r=[{key:"isSupported",value:function(){return!!window.fetch}},{key:"type",get:function(){return"loader"}}],i&&u(t.prototype,i),r&&u(t,r),e}()},2462:(e,t,i)=>{function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function n(e,t){for(var i=0;is});var a=i(6753).A.LOADER_EVENTS;const s=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._xhr=null,this.configs=Object.assign({},t),this.loading=!1,this._readtype=this.configs.readtype,this._bufferType=this.configs.buffer||"LOADER_BUFFER",this._requestInfo=null,this._onReadyStateChange=this._onReadyStateChange.bind(this),this._onError=this._onError.bind(this),this._onAbort=this._onAbort.bind(this),this._onTimeout=this._onTimeout.bind(this)}var t,i,s;return t=e,i=[{key:"bufferIns",get:function(){return this._context.getInstance(this._bufferType)}},{key:"init",value:function(){this.on(a.LADER_START,this.load.bind(this))}},{key:"_createXhr",value:function(){return window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP")}},{key:"load",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,n=Object.assign({},t);this._requestInfo={url:e,options:n,retryTimes:i,totalRetry:i,delayTime:r},this._xhr=this._createXhr(),this.loading=!0;try{this._bindEvents(),this._loadInternal(e,n)}catch(e){this._whenError({code:this._xhr.status,message:e&&e.message})}}},{key:"_loadInternal",value:function(e,t){var i=this._xhr;i.open("GET",e,!0),this._setTimeout(i,t),this._setCredentails(i,t),this._setHeaders(i,t),this._setResponseType(i),i.send()}},{key:"_bindEvents",value:function(){var e=this._xhr;e.addEventListener("readystatechange",this._onReadyStateChange),e.addEventListener("timeout",this._onTimeout),e.addEventListener("error",this._onError),e.addEventListener("abort",this._onAbort)}},{key:"_setTimeout",value:function(e,t){e.timeout=t.timeout||2e3}},{key:"_setCredentails",value:function(e,t){t.withCredentials&&(e.withCredentials=!0)}},{key:"_setHeaders",value:function(e,t){if("object"===r(t.headers)){var i=t.headers;for(var n in i)i.hasOwnProperty(n)&&e.setRequestHeader(n,i[n])}}},{key:"_setResponseType",value:function(e){switch(this._readtype){case 3:e.responseType="arraybuffer";break;case 2:e.responseType="json";break;default:e.responseType=""}}},{key:"_onReadyStateChange",value:function(){var e=this._xhr,t=e.readyState,i=e.status;if(4===t){if(i>=200&&i<300)return void this._onComplete(this._xhr);if(0===i)return;this._onError()}}},{key:"_onComplete",value:function(e){var t;switch(this._readtype){case 2:try{t=JSON.parse(e.responseText)}catch(e){}break;case 3:var i=e.response;t=new Uint8Array(i);break;default:t=e.responseText}this.bufferIns?(this.bufferIns.push(t),this.emit(a.LOADER_COMPLETE,this.bufferIns)):this.emit(a.LOADER_COMPLETE,t),this.loading=!1}},{key:"_onError",value:function(){var e=this._xhr,t={code:e.status||21,message:e.statusText};this._whenError(t)}},{key:"_onTimeout",value:function(){console.warn("timeout"),this._whenError({code:999,message:"fetch timeout"})}},{key:"_onAbort",value:function(){console.warn("abort")}},{key:"_whenError",value:function(e){var t=this,i=this._requestInfo,r=i.url,n=i.options,s=i.totalRetry,o=i.retryTimes,u=i.delayTime;if(!o)return this.loading=!1,void this.emit(a.LOADER_ERROR,this.TAG,e);o--,setTimeout((function(){t.emit(a.LOADER_RETRY,t.TAG,{response:e,reason:"response not ok",retryTime:s-o}),t.load(r,n,o,u)}),u)}},{key:"cancel",value:function(){4!==this._xhr.readyState&&this._xhr.abort()}},{key:"destroy",value:function(){this.cancel(),this._xhr&&(this._xhr.removeEventListener("readystatechange",this._onReadyStateChange),this._xhr.removeEventListener("timeout",this._onTimeout),this._xhr.removeEventListener("error",this._onError),this._xhr.removeEventListener("abort",this._onAbort),this._xhr=null)}}],s=[{key:"type",get:function(){return"loader"}}],i&&n(t.prototype,i),s&&n(t,s),e}()},8396:(e,t,i)=>{i.d(t,{A:()=>o});var r=i(6753),n=i(51223);function a(e,t){for(var i=0;i1)return;for(var c=0,l=Object.keys(t).length;c0)return this.emit(s.MSE_WRONG_TRACK_ADD,d);this.emit(s.MSE_ERROR,this.TAG,new Error(e.message))}}}Object.keys(this.sourceBuffers).length===this.sourceBufferLen&&this.doAppend()}}}}},{key:"doAppend",value:function(){if(this.mediaSource&&"closed"!==this.mediaSource.readyState){try{this._doCleanupSourceBuffer()}catch(e){}var e=this._context.getInstance("PRE_SOURCE_BUFFER");if(e&&!(Object.keys(this.sourceBuffers).length1&&void 0!==arguments[1]?arguments[1]:0;try{for(var i=0;it&&r.remove(t,e)}}catch(e){}}},{key:"_doCleanupSourceBuffer",value:function(){for(var e=this.container.currentTime,t={video:[],audio:[]},i=0;i=180){s=!0;var l=e-180;t[r].push({start:u,end:l})}}else c=180&&(s=!0,t[r].push({start:u,end:c}))}s&&!n.updating&&this._doRemoveRanges(t)}}},{key:"_doRemoveRanges",value:function(e){for(var t in e)if(this.sourceBuffers[t]&&!this.sourceBuffers[t].updating)for(var i=this.sourceBuffers[t],r=e[t];r.length&&!i.updating;){var n=r.shift();try{n&&n.end>n.start&&i.remove(n.start,n.end)}catch(e){}}}},{key:"cleanBuffers",value:function(){for(var t=this,i=[],r=function(r){var n,a=t.sourceBuffers[Object.keys(t.sourceBuffers)[r]];n=a.updating?new Promise((function(t){a.addEventListener("updateend",(function i(){var r=3;setTimeout((function i(){a.updating?r>0?(setTimeout(i,200),r--):t():(e.clearBuffer(a),a.addEventListener("updateend",(function(){t()})))}),200),a.removeEventListener("updateend",i)}))})):new Promise((function(t){a.buffered.length?(e.clearBuffer(a),a.addEventListener("updateend",(function(){t()}))):t()})).catch((function(){})),i.push(n)},n=0;n0?(setTimeout(i,200),r--):t():(e.clearBuffer(n),n.addEventListener("updateend",(function(){t()})))}),200),n.removeEventListener("updateend",i)}))})):new Promise((function(t){n.buffered.length?(e.clearBuffer(n),n.addEventListener("updateend",(function(){t()}))):t()})).catch((function(){})),i.push(a)},n=0;n{function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,r=new Array(t);ia});const a=new(function(){function e(){var t=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e);try{var i=/xgd=(\d)/.exec(document.cookie);this._status=!!i,this._level=i&&i[1]}catch(e){this._status=!1}["group","groupEnd","log","warn","error","trace"].forEach((function(e){t[e]=function(i,n,a,s,o,u,c,l,d,f){var h,p;if(t._status){var v=i,y=[n,a,s,o,u,c,l,d,f].filter((function(e){return void 0!==e}));(h=console)[e].apply(h,["["+v+"]:"].concat(function(e){if(Array.isArray(e))return r(e)}(p=y)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(p)||function(e,t){if(e){if("string"==typeof e)return r(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?r(e,t):void 0}}(p)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()))}}}))}var t,i;return t=e,(i=[{key:"enable",get:function(){return this._status}},{key:"long",get:function(){return"2"===this._level}}])&&n(t.prototype,i),e}())},60877:(e,t,i)=>{i.d(t,{A:()=>g});var r=i(65907);function n(e,t){for(var i=0;i2&&void 0!==arguments[2]?arguments[2]:[];h(this,e),this._emitter=new(u()),this._emitter.off||(this._emitter.off=this._emitter.removeListener),this.mediaInfo=new s,this._instanceMap={},this._clsMap={},this._inited=!1,this.allowedEvents=r,this._configs=i,this._player=t,this._hooks={}}return v(e,[{key:"getInstance",value:function(e){return this._instanceMap[e]||null}},{key:"initInstance",value:function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r1?i-1:0),o=1;o2?i-2:0),s=2;s{i.d(t,{A:()=>v});var r={VISIBILITY_CHANGE:"VISIBILITY_CHANGE"},n={SEEK:"SEEK"},a={LADER_START:"LOADER_START",LOADER_DATALOADED:"LOADER_DATALOADED",LOADER_COMPLETE:"LOADER_COMPLETE",LOADER_RESPONSE_HEADERS:"LOADER_RESPONSE_HEADERS",LOADER_ERROR:"LOADER_ERROR",LOADER_RETRY:"LOADER_RETRY",LOADER_TTFB:"LOADER_TTFB"},s={DEMUX_START:"DEMUX_START",DEMUX_COMPLETE:"DEMUX_COMPLETE",DEMUX_ERROR:"DEMUX_ERROR",METADATA_PARSED:"METADATA_PARSED",SEI_PARSED:"SEI_PARSED",VIDEO_METADATA_CHANGE:"VIDEO_METADATA_CHANGE",AUDIO_METADATA_CHANGE:"AUDIO_METADATA_CHANGE",MEDIA_INFO:"MEDIA_INFO",ISKEYFRAME:"ISKEYFRAME"},o={REMUX_METADATA:"REMUX_METADATA",REMUX_MEDIA:"REMUX_MEDIA",MEDIA_SEGMENT:"MEDIA_SEGMENT",REMUX_ERROR:"REMUX_ERROR",INIT_SEGMENT:"INIT_SEGMENT",DETECT_CHANGE_STREAM:"DETECT_CHANGE_STREAM",DETECT_CHANGE_STREAM_DISCONTINUE:"DETECT_CHANGE_STREAM_DISCONTINUE",DETECT_AUDIO_GAP:"DETECT_AUDIO_GAP",DETECT_LARGE_GAP:"DETECT_LARGE_GAP",DETECT_AUDIO_OVERLAP:"DETECT_AUDIO_OVERLAP",RANDOM_ACCESS_POINT:"RANDOM_ACCESS_POINT",DETECT_FRAG_ID_DISCONTINUE:"DETECT_FRAG_ID_DISCONTINUE"},u={SOURCE_UPDATE_END:"SOURCE_UPDATE_END",MSE_ERROR:"MSE_ERROR",MSE_WRONG_TRACK_ADD:"MSE_WRONG_TRACK_ADD",MSE_CHANGE_CODEC_ERROR:"MSE_CHANGE_CODEC_ERROR"},c={RETRY_TIME_EXCEEDED:"RETRY_TIME_EXCEEDED"},l=Object.assign({},a,s,o,u,c,n,r),d=[],f=[];for(var h in l)l.hasOwnProperty(h)&&d.push(l[h]);for(var p in l)l.hasOwnProperty(p)&&f.push(l[p]);const v={ALLEVENTS:l,HLS_EVENTS:c,REMUX_EVENTS:o,DEMUX_EVENTS:s,MSE_EVENTS:u,LOADER_EVENTS:a,FlvAllowedEvents:d,HlsAllowedEvents:f,CRYPTO_EVENTS:{START_DECRYPTOO:"START_DECRYPTO",DECRYPTED:"DECRYPTED"},PLAYER_EVENTS:n,BROWSER_EVENTS:r}},93425:(e,t,i)=>{i.d(t,{A:()=>l});var r=i(65907);function n(e,t){for(var i=0;i3&&(this._sampleQueue=[]),this._sampleQueue.push(e),this._calcAvgSpeed(this._sampleQueue)}},{key:"_calcAvgSpeed",value:function(e){var t=e.length,i=e.reduce((function(e,t){return e+t}),0)/t;this._speed=1e3*Math.floor(i)}},{key:"_cleanTimer",value:function(){clearTimeout(this._timer),this._timer=0}},{key:"clean",value:function(){this._cleanTimer()}},{key:"destroy",value:function(){clearTimeout(this._timer)}},{key:"totalByteSize",get:function(){return this._totalByteSize}},{key:"avgSpeed",get:function(){return this._speed||this._addSample(this._calcSampleSpeed()),8*this._speed}},{key:"recentSpeed",get:function(){return this._recentSpeed||this._addSample(this._calcSampleSpeed()),8*this._recentSpeed}}])&&n(t.prototype,i),e}();function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}function u(e,t){for(var i=0;i4&&void 0!==arguments[4]?arguments[4]:0,s=arguments.length>5?arguments[5]:void 0,o=arguments.length>6?arguments[6]:void 0;if(!this._destroyed)return this.loading=!0,this.fetch(this.url,t,s).then((function(u){if(!n._destroyed&&n.emit(c.LOADER_RESPONSE_HEADERS,n.TAG,u.headers),n._responseHeader=u.headers,u.ok)return n.status=u.status,Promise.resolve().then((function(){n._onFetchResponse(u,o)})),Promise.resolve(u);i-- >0?n._retryTimer=setTimeout((function(){return n.emit(c.LOADER_RETRY,n.TAG,{response:u,reason:"response not ok",retryTime:r-i}),n.internalLoad(e,t,i,r,a,s,o)}),a):(n.loading=!1,n.emit(c.LOADER_ERROR,n.TAG,{code:u.status||21,message:"".concat(u.status," (").concat(u.statusText,")")}))})).catch((function(u){if(n._destroyed||u&&"AbortError"===u.name)n.loading=!1;else if(i-- >0)n._retryTimer=setTimeout((function(){return n.emit(c.LOADER_RETRY,n.TAG,{error:u,reason:"fetch error",retryTime:r-i}),n.internalLoad(e,t,i,r,a,s,o)}),a);else{if(n.loading=!1,u&&"AbortError"===u.name)return;n.emit(c.LOADER_ERROR,n.TAG,Object.assign({code:21},u))}}))}},{key:"load",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=i.retryCount,n=i.retryDelay,a=i.loadTimeout,s=i.maxReaderInterval;if(e){r=void 0===r?3:r,this.url=e,this._canceled=!1;var o=this.getParams(t);return this.internalLoad(e,o,r,r,n,a,s)}this.emit(c.LOADER_ERROR,this.TAG,{code:0,message:"empty url"})}},{key:"_onFetchResponse",value:function(e,t){var i=this,r=this,n=this._context.getInstance(this.buffer);this._loaderTaskNo++;var a=this._loaderTaskNo;if(!0===e.ok){var s;switch(this.readtype){case 2:s=e.json();break;case 1:s=e.text();break;case 3:s=e.arrayBuffer();break;default:return this._onReader(e.body.getReader(),a,t)}if(!s)return;s.then((function(e){var t;null===(t=i._speed)||void 0===t||t.recordLoaded(),r.loading=!1,r._canceled||r._destroyed||(n?(n.push(e instanceof ArrayBuffer?new Uint8Array(e):e),r.emit(c.LOADER_COMPLETE,n)):r.emit(c.LOADER_COMPLETE,e))})).catch((function(){}))}}},{key:"_onReader",value:function(e,t,i){var r=this,n=this._context.getInstance(this.buffer);if(!n&&this._reader||this._destroyed)try{this._reader.cancel()}catch(e){}this._reader=e,!1!==this.loading&&(this._noDataTimer=setTimeout((function(){!1!==r.loading&&r.emit(c.LOADER_COMPLETE,"nobuffer")}),i||3e3),this._reader&&this._reader.read().then((function(a){var s,o;if(clearTimeout(r._noDataTimer),!r._canceled&&!r._destroyed)return a.done?(r.loading=!1,r.status=0,null===(o=r._speed)||void 0===o||o.destroy(),void Promise.resolve().then((function(){r.emit(c.LOADER_COMPLETE,"done")}))):(n.push(a.value),null===(s=r._speed)||void 0===s||s.recordChunk(a.value.byteLength),Promise.resolve().then((function(){r.emit(c.LOADER_DATALOADED,n)})),r._onReader(e,t,i));if(r._reader)try{r._reader.cancel()}catch(e){}})).catch((function(e){clearTimeout(r._noDataTimer),r.loading=!1,(!e||"AbortError"!==e.name&&"network error"!==e.message)&&r.emit(c.LOADER_ERROR,r.TAG,e)})))}},{key:"getParams",value:function(e){var t=Object.assign({},e),i=new Headers,r={method:"GET",headers:i,mode:"cors",cache:"default"};if("object"===o(this.configs.headers)){var n=this.configs.headers;for(var a in n)n.hasOwnProperty(a)&&i.append(a,n[a])}if("object"===o(t.headers)){var s=t.headers;for(var u in s)s.hasOwnProperty(u)&&i.append(u,s[u])}return!1===t.cors&&(r.mode="same-origin"),t.withCredentials&&(r.credentials="include"),r}},{key:"ttfbInfo",get:function(){return this._ttfbInfo}},{key:"avgSpeed",get:function(){var e;return(null===(e=this._speed)||void 0===e?void 0:e.avgSpeed)||0}},{key:"recentSpeed",get:function(){var e;return(null===(e=this._speed)||void 0===e?void 0:e.recentSpeed)||0}},{key:"currentSpeed",get:function(){var e;return(null===(e=this._speed)||void 0===e?void 0:e.avgSpeed)/8e3}},{key:"totalByteSize",get:function(){var e;return null===(e=this._speed)||void 0===e?void 0:e.totalByteSize}},{key:"responseHeader",get:function(){return this._responseHeader}},{key:"cancel",value:function(){var e;if(this._reader){try{var t=this._reader.cancel();t.catch&&t.catch((function(e){}))}catch(e){}this._reader=null,this.loading=!1}clearTimeout(this._noDataTimer),this._canceled=!0,this.abortController&&this.abortController.abort(),null===(e=this._speed)||void 0===e||e.clean()}},{key:"destroy",value:function(){var e;this._destroyed=!0,this._responseHeader=null,clearTimeout(this._retryTimer),clearTimeout(this._noDataTimer),this.cancel(),null===(e=this._speed)||void 0===e||e.destroy(),this._speed=null}}],r=[{key:"isSupported",value:function(){return!!window.fetch}},{key:"type",get:function(){return"loader"}}],i&&u(t.prototype,i),r&&u(t,r),e}()},87429:(e,t,i)=>{i.d(t,{A:()=>o});var r=i(65907),n=i(96865);function a(e,t){for(var i=0;i1)return;for(var c=0,l=Object.keys(t).length;c0)return this.emit(s.MSE_WRONG_TRACK_ADD,d);this.emit(s.MSE_ERROR,this.TAG,new Error(e.message))}}}Object.keys(this.sourceBuffers).length===this.sourceBufferLen&&this.doAppend()}}}}},{key:"doAppend",value:function(){if(this.mediaSource&&"closed"!==this.mediaSource.readyState){try{this._doCleanupSourceBuffer()}catch(e){}var e=this._context.getInstance("PRE_SOURCE_BUFFER");if(e&&!(Object.keys(this.sourceBuffers).length1&&void 0!==arguments[1]?arguments[1]:0;try{for(var i=0;it&&r.remove(t,e)}}catch(e){}}},{key:"_doCleanupSourceBuffer",value:function(){for(var e=this.container.currentTime,t={video:[],audio:[]},i=0;i=180){s=!0;var l=e-180;t[r].push({start:u,end:l})}}else c=180&&(s=!0,t[r].push({start:u,end:c}))}s&&!n.updating&&this._doRemoveRanges(t)}}},{key:"_doRemoveRanges",value:function(e){for(var t in e)if(this.sourceBuffers[t]&&!this.sourceBuffers[t].updating)for(var i=this.sourceBuffers[t],r=e[t];r.length&&!i.updating;){var n=r.shift();try{n&&n.end>n.start&&i.remove(n.start,n.end)}catch(e){}}}},{key:"cleanBuffers",value:function(){for(var t=this,i=[],r=function(r){var n,a=t.sourceBuffers[Object.keys(t.sourceBuffers)[r]];n=a.updating?new Promise((function(t){a.addEventListener("updateend",(function i(){var r=3;setTimeout((function i(){a.updating?r>0?(setTimeout(i,200),r--):t():(e.clearBuffer(a),a.addEventListener("updateend",(function(){t()})))}),200),a.removeEventListener("updateend",i)}))})):new Promise((function(t){a.buffered.length?(e.clearBuffer(a),a.addEventListener("updateend",(function(){t()}))):t()})).catch((function(){})),i.push(n)},n=0;n0?(setTimeout(i,200),r--):t():(e.clearBuffer(n),n.addEventListener("updateend",(function(){t()})))}),200),n.removeEventListener("updateend",i)}))})):new Promise((function(t){n.buffered.length?(e.clearBuffer(n),n.addEventListener("updateend",(function(){t()}))):t()})).catch((function(){})),i.push(a)},n=0;n