>4>1){if((c=o+5+e[o+4])===o+188)continue}else c=o+4;switch(d){case S:_&&(L&&(u=v(L,!0))&&void 0!==u.pts&&E(u,!1),L={data:[],size:0}),L&&(L.data.push(e.subarray(c,o+188)),L.size+=o+188-c);break;case T:_&&(x&&(u=v(x))&&void 0!==u.pts&&(f.codecType===l.b.aac?g(u):y(u)),x={data:[],size:0}),x&&(x.data.push(e.subarray(c,o+188)),x.size+=o+188-c);break;case 0:_&&(c+=e[c]+1),R=this._pmtId=p(e,c);break;case R:_&&(c+=e[c]+1);var A=m(e,c,this._typeSupported,null!==this._sampleAes);if(A.video<0&&A.audio<0)return void this._onError({type:r.b.MUX_ERROR,details:r.a.PARSING_ERROR,fatal:!0,reason:\"no track found\"});if(!this._pmtParsed){var D={};this._duration&&(D.duration=this._duration),this._eventEmitter.emit(a.a.METADATA,D)}if(A.video>0){var C=\"boolean\"!=typeof h.active||h.active;if(!this._isHevcSimilar(h.codecType)&&this._isHevcSimilar(A.codecType))C=A.codecType===l.b.hevc?ue.onHEVCDetected(h,this._config,this._typeSupported):ue.onKVCDetected(h,this._config,this._typeSupported);else if(h.codecType!==l.b.h264&&A.codecType===l.b.h264||h.codecType!==l.b.av1&&A.codecType===l.b.av1){var I;this._videoTrack.outputRaw&&(this._remux(!0),this._remuxer.ISGenerated&&this._transmuxData&&this._remuxer.resetInitSegment(this._transmuxData),this._videoTrack.outputRaw=!1),this._eventEmitter.emit(a.a.VIDEO_CODEC_DETECTED,{enabled:!0,decoder:l.c.buildIn,codecType:l.b.h264,timeOffset:(null==(I=this._remuxStat)?void 0:I.timeOffset)||0})}h.pid=S=C?A.video:-1,h.active=C,h.codecType=A.codecType}(T=A.audio)>0&&(f.pid=T,f.active=!0,f.codecType=A.aCodecType),this._pmtParsed=!0;break;case 17:case 8191:break;default:this._qos.unknownTSPacketCount++}}else this._onError({type:r.b.MUX_ERROR,details:r.a.PARSING_ERROR,fatal:!1,reason:\"TS packet did not start with 0x47\"});L&&(u=v(L,s))&&void 0!==u.pts?(E(u,s),h.pesData=void 0):(this._videoSample&&s&&(this._pushAccesUnit(this._videoSample,h),this._videoSample=null),h.pesData=L),x&&(u=v(x))&&void 0!==u.pts?(f.codecType===l.b.aac?g(u):y(u),f.pesData=void 0):(x&&x.size,f.pesData=x),(T>0&&0===f.samples.length||S>0&&0===h.samples.length||S<=0&&T<=0)&&!s||(!s&&this._config.gopRemux||this._remux(s),s&&this._onParsed())},t._onParsed=function(){var e=me()({extra:this._transmuxData,audioNonMonotonous:this._audioNonMonotonous},this._qos);this._eventEmitter.emit(a.a.PARSED_DATA,e)},t.flush=function(){var e,t=this._videoTrack,i=this._audioTrack,r=t.pesData,a=i.pesData,n=this._parsePES,s=this._parseVideoPES,o=this._parseAACPES,_=this._parseMPEGPES;if(r&&(e=n(r,!0))&&void 0!==e.pts&&s(e,!0),t.pesData=void 0,a&&(e=n(a))&&void 0!==e.pts&&(i.codecType===l.b.aac?o(e):_(e)),i.pesData=void 0,i.pid&&0===i.samples.length&&t.pid&&0===t.samples.length)this._remuxer.flush();else{var d=this._remuxStat;d&&(d={timeOffset:this._timeOffset,contiguous:!0,accurateTimeOffset:this._accurateTimeOffset}),this._remux(!0),this._videoSample=null,this._remuxStat=null}},t._remuxByStat=function(e){void 0===e&&(e=!1),this._remuxStat&&this._remux(e)},t._remux=function(e){void 0===e&&(e=!1);var t=this._audioTrack,i=this._videoTrack;if(e){if(0==i.samples.length&&0===t.samples.length)return}else if(i.active&&i.samples.length<2||t.active&&0===t.samples.length)return;if(!this._remuxOnFlush||e){var r=!0,n=0,s=!1;this._remuxStat&&(r=this._remuxStat.contiguous,n=this._remuxStat.timeOffset,s=this._remuxStat.accurateTimeOffset),this._firstRemux&&(this._firstRemux=!1,this._eventEmitter.emit(a.a.MEDIA_DEMUX,{type:f.b.TS})),this._sampleAes?this._decryptAndRemux(t,i,n,r,s,e):this._remuxer.remux(t,i,n,r,s,e),this._remuxStat=null}},t._decryptAndRemux=function(e,t,i,r,a,n){if(void 0===n&&(n=!1),e.samples&&this._sampleAes){var s=this;this._sampleAes.decryptAacSamples(e.samples,0,(function(){s._decryptAndRemuxAvc(e,t,i,r,a,n)}))}else this._decryptAndRemuxAvc(e,t,i,r,a,n)},t._decryptAndRemuxAvc=function(e,t,i,r,a,n){if(void 0===n&&(n=!1),t.samples&&this._sampleAes){var s=this;this._sampleAes.decryptAvcSamples(t.samples,0,0,(function(){s._remuxer.remux(e,t,i,r,a,n)}))}else this._remuxer.remux(e,t,i,r,a,n)},t.destroy=function(){this._duration=0},t._parsePAT=function(e,t){return(31&e[t+10])<<8|e[t+11]},t._readDescriptors=function(e,t,i){for(var r=i?t+i:e.byteLength,a=[];r-t>2;){var n=we(e,t);a.push(n),t+=2+n.descriptor_length}return a},t._checkRegistrationDescriptors=function(e,t,i){var r=e[t];return t+=2,5===r&&e.length>=t+4?Object(m.a)(e,t,4):\"\"},t._parsePES=function(e,t){void 0===t&&(t=!1);var i,r,a,s,o,_,d=e.data,c=0,u=0,h=0;if(!e||0===e.size)return null;for(;d[0].length<19&&d.length>1;){var l=new Uint8Array(d[0].length+d[1].length);l.set(d[0]),l.set(d[1],d[0].length),d[0]=l,d.splice(1,1)}if(1===((i=d[0])[0]<<16)+(i[1]<<8)+i[2]){if((a=(i[4]<<8)+i[5])&&a>e.size-6)return null;if(0===a&&!t)return null;192&(r=i[7])&&((u=536870912*(14&i[9])+4194304*(255&i[10])+16384*(254&i[11])+128*(255&i[12])+(254&i[13])/2)>4294967295&&(u-=8589934592),64&r?((h=536870912*(14&i[14])+4194304*(255&i[15])+16384*(254&i[16])+128*(255&i[17])+(254&i[18])/2)>4294967295&&(h-=8589934592),u-h>54e5&&(n.b.w(Math.round((u-h)/9e4)+\"s delta between PTS and DTS, align them\"),u=h)):h=u),_=(s=i[8])+9,e.size-=_,o=new Uint8Array(e.size);for(var f=0,p=d.length;fm){_-=m;continue}i=i.subarray(_),m-=_,_=0}o.set(i,c),c+=m}return a&&(a-=s+3),{data:o,pts:u,dts:h,len:a}}return null},t._parseHEVCNalu=function(e,t,i){var r,a=this,n=this._videoTrack,s=this._hevcParamSets,o=this._videoSample;return e.forEach((function(e){var _;switch(e.type){case M.a.HEVC_NAL_IDR_W_RADL:case M.a.HEVC_NAL_IDR_N_LP:case M.a.HEVC_NAL_CRA_NUT:a._checkParamSets(),r=!0,o||(o=a._videoSample=a._createVSample(!1,t,i)),o.key=!0,o.frame=!0;break;case M.a.HEVC_NAL_AUD:r=!1,n.audFound=!0,o&&a._pushAccesUnit(o,n),o=a._videoSample=a._createVSample(!1,t,i);break;case M.a.HEVC_NAL_SPS:r=!0;var d=_e.parse(e.data,n.codecType);s.sps&&!Object(m.b)(s.sps.data,d.data)&&(a._psUpdated=!0),s.spsList[d.sps_id]=d,s.sps=d;break;case M.a.HEVC_NAL_PPS:r=!0;var c=ie.parse(e.data);s.pps&&!Object(m.b)(s.pps.data,c.data)&&(a._psUpdated=!0),s.ppsList[c.pps_id]=c,s.pps=c;break;case M.a.HEVC_NAL_VPS:r=!0;var u=de.parse(e.data);s.vps&&!Object(m.b)(s.vps.data,u.data)&&(a._psUpdated=!0),s.vpsList[u.vps_id]=u,s.vps=u;break;default:if(a._checkParamSets(),r=!0,void 0===e.type){r=!1;break}o||(o=a._videoSample=a._createVSample(!0,t,i)),o.frame=!0}o&&r&&(null==(_=o.units)||_.push(e))})),o},t._parseAVCNalu=function(e,t,i){var r,a=this,n=this._videoTrack,s=this._avcParamSets,o=this._videoSample,_=!1;e.forEach((function(e){var d;switch(e.type){case x.H264_NAL_SLICE:a._checkParamSets(),r=!0,o||(o=a._videoSample=a._createVSample(!0,t,i)),o.frame=!0;var c=e.data;if(_&&c.length>4){var u=U(c);B(u,8),W(u);var h=W(u);2!==h&&4!==h&&7!==h&&9!==h||(o.key=!0)}break;case x.H264_NAL_IDR_SLICE:a._checkParamSets(),r=!0,o||(o=a._videoSample=a._createVSample(!0,t,i)),o.key=!0,o.frame=!0;break;case x.H264_NAL_SEI:r=!0;break;case x.H264_NAL_SPS:r=!0,_=!0;var l=te.parse(e.data);s.sps&&!Object(m.b)(s.sps.data,l.data)&&(a._psUpdated=!0),s.spsList[l.sps_id]=l,s.sps=l;break;case x.H264_NAL_PPS:r=!0;var f=ee.parse(e.data);s.pps&&!Object(m.b)(s.pps.data,f.data)&&(a._psUpdated=!0),s.ppsList[f.pps_id]=f,s.pps=f;break;case x.H264_NAL_AUD:r=!1,n.audFound=!0,o&&a._pushAccesUnit(o,n),o=a._videoSample=a._createVSample(!1,t,i);break;case x.H264_NAL_FILLER_DATA:default:r=!1}o&&r&&(null==(d=o.units)||d.push(e))}))},t._checkParamSets=function(){var e,t=this._videoTrack;t.decConf&&this._psUpdated&&(this._remuxByStat(!0),this._remuxer.ISGenerated&&this._transmuxData&&this._remuxer.resetInitSegment(this._transmuxData));var i=!1;t.decConf&&!this._psUpdated||(t.codecType===l.b.h264?this._avcParamSets.spsList.length&&this._avcParamSets.ppsList.length&&(ue.updateAVCTrack(t,this._avcParamSets),i=!0):this._hevcParamSets.spsList.length&&this._hevcParamSets.ppsList.length&&this._hevcParamSets.vpsList.length&&(ue.updateHEVCTrack(t,this._hevcParamSets),i=!0)),i&&this._eventEmitter.emit(a.a.VIDEO_CODEC_DETECTED,{enabled:t.active,decoder:t.outputRaw?l.c.wasm:l.c.buildIn,codecType:t.codecType,bitDepth:t.bitDepth,timeOffset:(null==(e=this._remuxStat)?void 0:e.timeOffset)||0}),this._psUpdated=!1},t._getLastNalUnit=function(){var e,t=this._videoSample;if(!t||0===t.units.length){var i=this._videoTrack.samples;t=i[i.length-1]}if(t){var r=t.units;e=r[r.length-1]}return e},t._readVideoNALu=function(e){var t,i,r,a,n=this._videoTrack,s=e.byteLength,o=s,_=[],d=0,c=0,u=n.naluState||0,h=-1,l=u;if(-1===u)h=0,a=this._isHevcSimilar(n.codecType)?(126&e[0])>>1:31&e[0],u=0,d=1;else if(u>0)for(;c<4;c++){var f=e[c];if(0!==f){if(1===f&&u>=2){h=c+1,a=this._isHevcSimilar(n.codecType)?(126&e[h])>>1:31&e[h],u=0;var p=this._getLastNalUnit();p&&l&&c<=4-l&&p.state&&(p.data=p.data.subarray(0,p.data.byteLength-l));break}c0&&0===e[d-1]?3:2,d+=3,h>=0)r={data:e.subarray(h,d-u-1),type:a},_.push(r);else{var m=this._getLastNalUnit();if(m&&(i=d-u-1)>0){var v=new Uint8Array(m.data.byteLength+i);v.set(m.data,0),v.set(e.subarray(0,i),m.data.byteLength),m.data=v}}d>1:31&e[d],u=0):u=-1}else d+=3;else 0===t?d++:d+=3;for(var E=s-1;E>s-4&&E>=c&&0===e[E];E--)u++;if(h>=0&&u>=0&&h=this._minChunkSize))return void(this._stat||(this._stat={contiguous:a,trackSwitch:n,discontinuity:s,accurateTimeOffset:o}));h=this._cache.get(l)}else this._cache.unreadLen&&(this._cache.put(e),h=this._cache.get(this._cache.unreadLen));if(h)if(e=h,this._stat&&(a=this._stat.contiguous,n=this._stat.trackSwitch,s=this._stat.discontinuity,o=this._stat.accurateTimeOffset,this._stat=void 0),e.byteLength>0&&t&&t.key&&\"AES-128\"===t.method){var f=this._decrypter;f||(f=this._decrypter=new c(this._config,{removePKCS7Padding:_})),s&&(this._nextIV=null);var p=this._nextIV?this._nextIV:t.iv;f.decrypt(e,t.key.buffer,p.buffer,(function(c){_?u._nextIV=null:(u._nextIV=new Uint8Array(16),u._nextIV.set(e.subarray(e.byteLength-16),0)),u._pushDecrypted(new Uint8Array(c),t,i,r,a,n,s,o,_,d)}))}else t&&_&&(this._nextIV=null),this._pushDecrypted(e,t,i,r,a,n,s,o,_,d)},t.flush=function(){this._demuxer&&this._demuxer.flush(),this._cache.clear()},t.end=function(){this._eventEmitter.emit(a.a.LOAD_END)},t._probeData=function(e,t,i,n){if(!this._demuxer||t&&this._probe&&!this._probe(e)){for(var s=this._eventEmitter,o=this._typeSupported,_=this._config,d=0,c=this._muxConfig.length;d8?s.LUMINANCE_ALPHA:s.LUMINANCE,i,r,0,a>8?s.LUMINANCE_ALPHA:s.LUMINANCE,s.UNSIGNED_BYTE,n)}},t._init=function(){var e=this._gl;e&&(this._program=this._initProgram(\"\\n precision lowp float;\\n\\n attribute vec2 aPosition;\\n attribute vec2 aLumaPosition;\\n attribute vec2 aChromaPosition;\\n varying vec2 vLumaPosition;\\n varying vec2 vChromaPosition;\\n uniform mat3 uMatrix;\\n void main() {\\n gl_Position = vec4((uMatrix * vec3(aPosition, 1)).xy, 0, 1);\\n vLumaPosition = aLumaPosition;\\n vChromaPosition = aChromaPosition;\\n }\\n \",\"\\n #define EOTF_C1 .8359375\\n #define EOTF_C2 18.8515625\\n #define EOTF_C3 18.6875\\n #define EOTF_HLG_GAMMA 0.2\\n #define _EOTF_HLG_A 0.17883277\\n #define _EOTF_HLG_B 0.28466892\\n #define _EOTF_HLG_C 0.55991073\\n #define MAIN_A 2.51\\n #define MAIN_B 0.03\\n #define MAIN_C 1.23\\n #define MAIN_D 0.59\\n #define MAIN_E 0.14\\n #define MAIN_ADAPTED_LUM 0.001\\n\\n precision lowp float;\\n\\n const vec3 eotf_m1 = vec3(1.0 / .1593017578125);\\n const vec3 eotf_m2 = vec3(1.0 / 78.84375);\\n const vec3 tonemapping_hlg_m1 = vec3(1.0 / 1.3);\\n const vec3 main_m1 = vec3(0.555555555556);\\n const vec3 main_m2 = vec3(2.0);\\n \\n // bt2020 to bt709\\n const mat3 mat_xyz_to_rgbp3 = mat3(\\n 1.66049100210843, -0.124550474521591, -0.0181507633549054, \\n -0.587641138788548, 1.13289989712596, -0.100578898008008, \\n -0.0728498633198855, -0.00834942260436943, 1.11872966136291\\n );\\n\\n float _eotf_hlg(float x) {\\n if (x < 0.5) {\\n return pow(x / 0.5, 2.0) / 12.0;\\n } else {\\n return (exp((x - _EOTF_HLG_C) / _EOTF_HLG_A) + _EOTF_HLG_B) / 12.0;\\n }\\n }\\n\\n vec3 eotf_hlg(vec3 i) {\\n vec3 res;\\n float Y = 0.2627 * res.x + 0.6780 * res.y + 0.0593 * res.z;\\n res = pow(Y, EOTF_HLG_GAMMA) * res;\\n res.x = _eotf_hlg(i.x);\\n res.y = _eotf_hlg(i.y);\\n res.z = _eotf_hlg(i.z);\\n return res;\\n }\\n\\n vec3 eotf(vec3 i) {\\n i = max(i, 1e-10);\\n vec3 input_m2 = pow(i, eotf_m2);\\n return pow((input_m2 - EOTF_C1) / (EOTF_C2 - EOTF_C3 * input_m2), eotf_m1) * 10000.0;\\n }\\n\\n vec3 tonemapping_hlg(vec3 i) {\\n vec3 res = pow(i, tonemapping_hlg_m1);\\n return res;\\n }\\n\\n float _trc_gamma(float i) {\\n if (i < 0.018) {\\n return 4.5 * i;\\n } else {\\n return 1.099 * pow(i, 0.45);\\n }\\n }\\n\\n vec3 trc_gamma(vec3 i) {\\n vec3 res;\\n res.x = _trc_gamma(i.x);\\n res.y = _trc_gamma(i.y);\\n res.z = _trc_gamma(i.z);\\n return res;\\n }\\n\\n // vec3 rgb_gamma(vec3 i) {\\n // vec3 l = 4.5 * i;\\n // vec3 g = 1.099 * pow(i, vec3(0.45)) - 0.099;\\n // if(i.x > 0.018 && i.y > 0.018 && i.z > 0.018) {\\n // return l;\\n // } else {\\n // return g;\\n // }\\n // }\\n\\n // vec3 rgb_inverse_gamma(vec3 i) {\\n // vec3 l = i / 4.5;\\n // vec3 g = pow((i + 0.099) / 1.099, vec3(1.0 / 0.45, 1.0 / 0.45, 1.0 / 0.45));\\n // if(i.x > 0.018 * 4.5 && i.y > 0.018 * 4.5 && i.z > 0.018 * 4.5) {\\n // return l;\\n // } else {\\n // return g;\\n // }\\n // }\\n\\n // vec3 inverse_eotf(vec3 i) {\\n // float c1 = .8359375;\\n // float c2 = 18.8515625;\\n // float c3 = 18.6875;\\n // vec3 m1 = vec3(.1593017578125);\\n // vec3 m2 = vec3(78.84375);\\n\\n // i = max(i / 10000.0, 1e-10);\\n // return pow(max(pow(i, m1) * c2 + c1, vec3(0.0)) / (1.0 + c3 * pow(i, m1)), m2);\\n // }\\n\\n // float _inverse_trc(float x) {\\n // return pow(x, 1.5);\\n // }\\n\\n // vec3 inverse_trc(vec3 i) {\\n // vec3 res;\\n // res.x = _inverse_trc(i.x);\\n // res.y = _inverse_trc(i.y);\\n // res.z = _inverse_trc(i.z);\\n // return res;\\n // }\\n\\n uniform sampler2D uTextureY;\\n uniform sampler2D uTextureCb;\\n uniform sampler2D uTextureCr;\\n uniform float uColorCovYOffset;\\n uniform mat3 uColorConversion;\\n uniform int uColorTrc;\\n uniform int uBitsPerPixel;\\n varying vec2 vLumaPosition;\\n varying vec2 vChromaPosition;\\n\\n void main() {\\n vec3 yuv;\\n if (uBitsPerPixel > 8) {\\n float normalized = pow(2.0, float(uBitsPerPixel - 8));\\n yuv.x = (texture2D(uTextureY, vLumaPosition).r + texture2D(uTextureY, vLumaPosition).a * 256.0) / normalized + uColorCovYOffset;\\n yuv.y = (texture2D(uTextureCb, vChromaPosition).r + texture2D(uTextureCb, vChromaPosition).a * 256.0) / normalized - 0.5;\\n yuv.z = (texture2D(uTextureCr, vChromaPosition).r + texture2D(uTextureCr, vChromaPosition).a * 256.0) / normalized - 0.5;\\n vec3 rgb = uColorConversion * yuv;\\n\\n vec3 rgb_lum;\\n if (uColorTrc == 16) { // HDR10 or HDR10+\\n // 电光转换(EOTF)\\n rgb_lum = eotf(rgb);\\n\\n //tone mapping\\n vec3 tmp = rgb_lum * MAIN_ADAPTED_LUM;\\n rgb_lum = tmp * (tmp * MAIN_A + MAIN_B) / (tmp * (tmp * MAIN_C + MAIN_D) + MAIN_E) / 1.3;\\n rgb_lum = pow(rgb_lum, main_m1) * pow(main_m2, rgb_lum) / 2.0; //g=1.8\\n\\n //调节饱和度\\n float gray = (rgb_lum.x + rgb_lum.y + rgb_lum.z) / 2.0;\\n rgb_lum = rgb_lum + (rgb_lum * 1.5 - gray) * 0.12;\\n } else { // HLG\\n rgb_lum = eotf_hlg(rgb);\\n rgb_lum = tonemapping_hlg(rgb_lum);\\n }\\n vec3 rgbp3 = trc_gamma(mat_xyz_to_rgbp3 * rgb_lum);\\n gl_FragColor = vec4(rgbp3, 1.0);\\n } else {\\n yuv.x = texture2D(uTextureY, vLumaPosition).x + uColorCovYOffset;\\n yuv.y = texture2D(uTextureCb, vChromaPosition).x - 0.5;\\n yuv.z = texture2D(uTextureCr, vChromaPosition).x - 0.5;\\n gl_FragColor = vec4(clamp(uColorConversion * yuv, 0.0, 1.0), 1.0);\\n }\\n }\"),this._program&&(this._buf=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,this._buf),e.bufferData(e.ARRAY_BUFFER,u,e.STATIC_DRAW),this._positionLocation=e.getAttribLocation(this._program,\"aPosition\"),this._lumaPositionBuffer=e.createBuffer(),this._lumaPositionLocation=e.getAttribLocation(this._program,\"aLumaPosition\"),this._chromaPositionBuffer=e.createBuffer(),this._chromaPositionLocation=e.getAttribLocation(this._program,\"aChromaPosition\"),this._colorCovYoffset=e.getUniformLocation(this._program,\"uColorCovYOffset\"),this._colorCovLocation=e.getUniformLocation(this._program,\"uColorConversion\"),this._colorTrcLocation=e.getUniformLocation(this._program,\"uColorTrc\"),this._bitsPerPixelLocation=e.getUniformLocation(this._program,\"uBitsPerPixel\"),this._texsizeLocation=e.getUniformLocation(this._program,\"textureSize\"),this._matrixLocation=e.getUniformLocation(this._program,\"uMatrix\"),e.pixelStorei(e.UNPACK_ALIGNMENT,1)))},t._attachTexture=function(e,t,i){var r=this._gl;r&&this._program&&(r.activeTexture(t),r.bindTexture(r.TEXTURE_2D,this._textures[e]),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR),r.uniform1i(r.getUniformLocation(this._program,e),i))},t._initProgram=function(e,t){var i=this._gl;if(i){var r=this._compileShader(i.VERTEX_SHADER,e),a=this._compileShader(i.FRAGMENT_SHADER,t);this._vertexShader=r,this._fragmentShader=a;var n=i.createProgram();if(n&&r&&a){if(i.attachShader(n,r),i.attachShader(n,a),i.linkProgram(n),!i.getProgramParameter(n,i.LINK_STATUS)){var s=i.getProgramInfoLog(n);throw i.deleteProgram(n),new Error(\"GL program linking failed: \"+s)}return n}}return null},t._compileShader=function(e,t){var i=this._gl;if(i){var r=i.createShader(e);if(r){if(i.shaderSource(r,t),i.compileShader(r),!i.getShaderParameter(r,i.COMPILE_STATUS)){var a=i.getShaderInfoLog(r);throw i.deleteShader(r),new Error(\"GL shader compilation for \"+e+\" failed: \"+a)}return r}}return null},t.drawFrame=function(t,i,r){void 0===r&&(r=0);var a=this._gl;if(a){this._initVPP();var n=t.format,s=t.y.bits>8?2:1,o=!this._program||this._checkFormatUpdated(n);o&&this.clear(),this._program||this._init(),o&&(this._setupTexturePosition(this._lumaPositionBuffer,this._lumaPositionLocation,t.y.stride/s,t.format),this._setupTexturePosition(this._chromaPositionBuffer,this._chromaPositionLocation,t.u.stride*n.width/n.chromaWidth/s,t.format)),this._uploadTexture(\"uTextureY\",t.y.stride/s,t.format.height,t.y.bits,t.y.bytes),this._uploadTexture(\"uTextureCb\",t.u.stride/s,t.format.chromaHeight,t.u.bits,t.u.bytes),this._uploadTexture(\"uTextureCr\",t.v.stride/s,t.format.chromaHeight,t.v.bits,t.v.bytes),a.useProgram(this._program),a.viewport((a.canvas.width-n.displayWidth)/2,(a.canvas.height-n.displayHeight)/2,n.displayWidth,n.displayHeight),this._attachTexture(\"uTextureY\",a.TEXTURE0,0),this._attachTexture(\"uTextureCb\",a.TEXTURE1,1),this._attachTexture(\"uTextureCr\",a.TEXTURE2,2),this._output&&this._vpp&&(a.activeTexture(a.TEXTURE3),a.bindTexture(a.TEXTURE_2D,this._output),a.bindFramebuffer(a.FRAMEBUFFER,this._outputFBO),a.texImage2D(a.TEXTURE_2D,0,a.RGBA,a.canvas.width,a.canvas.height,0,a.RGBA,a.UNSIGNED_BYTE,null));var _,d=-16/255;i?(_=i.matrixCoefficients===c.c.AVCOL_SPC_BT2020_CL||i.matrixCoefficients===c.c.AVCOL_SPC_BT2020_NCL?E:i.matrixCoefficients===c.c.AVCOL_SPC_BT709?i.colorRange===c.b.AVCOL_RANGE_MPEG?m:v:i.colourPrimaries===c.a.AVCOL_PRI_BT470BG?i.colorRange===c.b.AVCOL_RANGE_MPEG?p:f:i.colorRange===c.b.AVCOL_RANGE_MPEG?h:l,i.colorRange===c.b.AVCOL_RANGE_JPEG&&(d=0),a.uniform1i(this._colorTrcLocation,i.transferCharacteristics)):_=h,a.uniform1i(this._bitsPerPixelLocation,t.y.bits),a.uniformMatrix3fv(this._matrixLocation,!1,e.getRotMatrix(r)),a.uniform1f(this._colorCovYoffset,d),a.uniformMatrix3fv(this._colorCovLocation,!1,_);var g=new Float32Array([n.width,n.height]);a.uniform2fv(this._texsizeLocation,g),a.bindBuffer(a.ARRAY_BUFFER,this._buf),a.enableVertexAttribArray(this._positionLocation),a.vertexAttribPointer(this._positionLocation,2,a.FLOAT,!1,0,0),a.bindBuffer(a.ARRAY_BUFFER,this._lumaPositionBuffer),a.enableVertexAttribArray(this._lumaPositionLocation),a.vertexAttribPointer(this._lumaPositionLocation,2,a.FLOAT,!1,0,0),a.bindBuffer(a.ARRAY_BUFFER,this._chromaPositionBuffer),a.enableVertexAttribArray(this._chromaPositionLocation),a.vertexAttribPointer(this._chromaPositionLocation,2,a.FLOAT,!1,0,0),a.drawArrays(a.TRIANGLES,0,u.length/2),this._output&&this._vpp&&(a.bindTexture(a.TEXTURE_2D,null),a.bindFramebuffer(a.FRAMEBUFFER,null),a.activeTexture(a.TEXTURE0),this._vpp.draw())}},t.reDraw=function(){},t._setupTexturePosition=function(e,t,i,r){var a=this._gl;if(a){var n=r.cropLeft/i,s=(r.cropLeft+r.cropWidth)/i,o=(r.cropTop+r.cropHeight)/r.height,_=r.cropTop/r.height,d=new Float32Array([n,o,s,o,n,_,n,_,s,o,s,_]);a.bindBuffer(a.ARRAY_BUFFER,e),a.bufferData(a.ARRAY_BUFFER,d,a.STATIC_DRAW)}},t.clear=function(){var e=this._gl;e&&(e.viewport(0,0,e.canvas.width,e.canvas.height),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT))},t._checkFormatUpdated=function(e){var t=!(this._format&&e.width===this._format.width&&e.height===this._format.height&&e.chromaWidth===this._format.chromaWidth&&e.chromaHeight===this._format.chromaHeight);return t&&(this._format?d()(this._format,e):this._format=d()({},this._format)),t},e}(),x=i(5),A=i.n(x),D=i(26);!function(e){e[e.OK=0]=\"OK\",e[e.REORDER=1]=\"REORDER\"}(r||(r={}));var C=\"yuv-cache\",I=function(){function e(){this._cache=[],this._totalSize=0,this._index=-1,this._lastDuration=1e3/24,this._maxCacheSize=52428800}var t=e.prototype;return t.init=function(e){e&&e>52428800&&(this._maxCacheSize=e)},t.reset=function(){o.b.i(C,\"reset\"),this._cache=[],this._totalSize=0,this._index=-1},t.next=function(){return this.getFrameByIndex(this._index+1)},t.prev=function(){return this.getFrameByIndex(this._index-1)},t.push=function(e,t){void 0===t&&(t=!1);var i=r.OK,a=e.y.bytes.byteLength+e.u.bytes.byteLength+e.v.bytes.byteLength,n=this._cache[this._cache.length-1],s=n?e.format.pts-n.pts:this._lastDuration;if(this._cache.push({pts:e.format.pts,endPTS:e.format.pts+s,size:a,yuv:e}),t&&(e.y.bytes=new Uint8Array(e.y.bytes),e.u.bytes=new Uint8Array(e.u.bytes),e.v.bytes=new Uint8Array(e.v.bytes)),n)if((s<=0||s>=1e3)&&o.b.i(C,\"yuv cache pts diff: \"+s+\", \"+n.pts+\"/\"+e.format.pts),s<0){this._cache.sort((function(e,t){return e.pts-t.pts}));for(var _=0;_=1e3)&&o.b.i(C,\"yuv drop frame pts diff: \"+this._lastDuration)),this._cache.push({pts:e.pts,endPTS:e.endPTS,size:0})},t.ptsToIndex=function(e){return this._cache.length&&e<=this._cache[this._cache.length-1].endPTS?D.a.searchIndex(this._cache,(function(t){return et.endPTS?1:0})):-1},t.getFrameByIndex=function(e){if(e>=0&&e0&&e=0;i--)if(this._cache[i].pts=0&&this.reset(),this._cache.length&&e<=this._cache[this._cache.length-1].endPTS){var t=Math.max(0,D.a.searchIndex(this._cache,(function(t){return et.pts?1:0})));this._cache=this._cache.slice(0,t),t=this._cache.length)return!1;for(var t=Math.max(0,e);t=this._maxCacheSize&&this._index>0;){var e=this._cache.shift();e&&e.yuv&&(this._totalSize-=e.size),this._index--}},A()(e,[{key:\"current\",get:function(){return this.getFrameByIndex(this._index)}},{key:\"index\",get:function(){return this._index},set:function(e){e>=0&&e=this._yuvBufferLenOnWaiting||this._dataEnded())&&this._onWaitingReady()},t.updateState=function(e,t,i,r,a,n){if(this._clock=1e3*e,this._output!==a&&this._yuv&&this._yuv.clear(),this._output=a,this._maxFrameBufLen=n,a!==s.p.video&&(this._size.cw!==t||this._size.ch!==i)){this._size.cw=t,this._size.ch=i,this._size.update=!0;var o=this._yuvCache.current;o&&o.yuv&&this._draw(o.yuv)}},t.updateMediaInfo=function(e){this._mediaInfo=e},t.step=function(e){if(!this._waitingVideoSync)if(e===s.j.NEXT){var t,i=this._nextDraw?this._nextDraw.pts:-1;i>=0&&null!=(t=this._nextDraw)&&t.yuv&&(this._clock=i,this._eventEmitter.emit(n.a.STEP,{type:e,time:i}))}else if(e===s.j.PREV){if(this._yuvCache.index>0){var r=this._nextDraw?this._yuvCache.index-1:this._yuvCache.index,a=this._yuvCache.getLessPtsIdxThen(r);if(a>=0){if(r-a>1&&o.b.i(\"canvas-renderer\",\"step prev skip \"+(r-a-1)),this._nextDraw=this._yuvCache.getFrameByIndex(a),this._nextDraw&&this._nextDraw.yuv)return this._clock=this._nextDraw.yuv.format.pts,void this._eventEmitter.emit(n.a.STEP,{type:e,time:this._nextDraw.yuv.format.pts})}else this._yuvCache.reset()}this._eventEmitter.emit(n.a.STEP,{type:e,time:-1})}},t.seek=function(e){o.b.i(\"canvas-renderer\",\"seek: \"+e);var t=this._yuvCache.ptsToIndex(1e3*e);if(-1!==t){if(!this._yuvCache.hasDropedAfterIdx(t))return this._yuvCache.index=t,this._nextDraw=this._yuvCache.current,o.b.i(\"canvas-renderer\",\"seek hit yuv cache\"),this._clock=1e3*e,this._updateRenderer(),void this._eventEmitter.emit(n.a.RENDERER_SEEK,{hitCache:!0,time:e,type:\"renderer\"});o.b.i(\"canvas-renderer\",\"yuv cache has dropped.\"),this._yuvCache.reset()}o.b.i(\"canvas-renderer\",\"seek miss yuv cache\"),this._eventEmitter.emit(n.a.RENDERER_SEEK,{hitCache:!1,time:e,type:\"renderer\"})},t.endOfData=function(){o.b.i(\"canvas-renderer\",\"end of data\"),this._endOfData=!0,this._checkWaitingReady()},t.decDropFrameInfo=function(e){o.b.i(\"canvas-renderer\",\"dec drop frame info\"),this._yuvCache.decDropFrameInfo(e)},t.reset=function(e,t){void 0===t&&(t=!1),o.b.i(\"canvas-renderer\",\"reset\",e),this._yuvCache.reset(),t||(this._clock=-1),this._waitingVideoSync=!0,this._nextDraw=void 0,this._endOfData=!1,this._eventEmitter.emit(n.a.RENDERER_BUF_UPDATE,{needMore:!0,yuvBufLen:0})},t.flush=function(e){void 0===e&&(e=0),this._yuvCache.flush(e),this._nextDraw=void 0,this._eventEmitter.emit(n.a.RENDERER_BUF_UPDATE,{needMore:!0,yuvBufLen:0})},t.destroy=function(){this._yuv&&this._yuv.destroy(),this._yuvCache.reset(),this._stopLoop(),this._vpp=void 0},t.bindVPP=function(e){this._vpp=e,this._yuv&&this._yuv.bindVPP(e)},t.unbindVPP=function(){this._vpp=void 0,this._yuv&&this._yuv.unbindVPP()},t._dataEnded=function(){return this._endOfData},t._updateRenderer=function(){var e,t;if(this._canvas&&-1!==this._clock){var i=this._yuvCache.remaining;for(!this._nextDraw||null!=(e=this._nextDraw)&&e.yuv||o.b.i(\"canvas-renderer\",\"skip empty frame\"),this._nextDraw&&null!=(t=this._nextDraw)&&t.yuv||(this._nextDraw=this._yuvCache.next());this._nextDraw&&this._clock>=0;){var r=this._clock-this._nextDraw.pts,a=this._clock-this._nextDraw.endPTS;if(this._waitingVideoSync&&a>200)o.b.v(\"canvas-renderer\",\"skip draw\",this._clock,this._nextDraw.endPTS,a),this._nextDraw=this._yuvCache.next();else{if(this._checkWaitingReady(),this._waitingVideoSync||!(r>=-1))break;if(a<=200){o.b.v(\"canvas-renderer\",\"draw\",this._nextDraw.pts,r,a),this._nextDraw.yuv&&this._draw(this._nextDraw.yuv),this._nextDraw=this._yuvCache.next();break}this._decBlockPolicy===s.m.NONE?(this._nextDraw.yuv&&this._draw(this._nextDraw.yuv),this._nextDraw=this._yuvCache.next()):(o.b.v(\"canvas-renderer\",\"skip b\",this._nextDraw.pts,r,a),this._nextDraw=this._yuvCache.next(),this._nextDraw||this._onWaiting())}}i!=this._yuvCache.remaining&&this._eventEmitter.emit(n.a.RENDERER_BUF_UPDATE,{needMore:this._yuvCache.remainingr?e.ch>e.fh&&(t=(i=e.fh)*a):e.cw>e.fw&&(i=(t=e.fw)/a)}this._canvas.width=t,this._canvas.height=i,o.b.i(\"canvas-renderer\",\"update canvas size\",t,i)}},t._draw=function(e){var t;if(this._canvas){var i=e.format,r=(null==(t=this._mediaInfo)?void 0:t.rotation)||0,a=r%180==90||r%180==-90,s=a?i.height:i.width,o=a?i.width:i.height,_=s/o;(this._size.update||s!==this._size.fw||o!==this._size.fh)&&(this._size.fw=s,this._size.fh=o,this._calculateCanvasSize());var d,c=this._canvas.width,u=this._canvas.height;_>c/u?(i.displayWidth=c,i.displayHeight=Math.round(c/_)):(i.displayWidth=Math.round(u*_),i.displayHeight=u),this._yuv&&this._yuv.drawFrame(e,null==(d=this._mediaInfo)?void 0:d.colorInfo,r),this._eventEmitter.emit(n.a.RENDERER_DRAW,{yuvBufLen:this._yuvCache.remaining})}},t._startLoop=function(){var e=this;this._loop||(this._loop=setInterval((function(){e._updateRenderer()}),0))},t._stopLoop=function(){this._loop&&(clearInterval(this._loop),this._loop=void 0)},t._onWaiting=function(){var e=this._maxFrameBufLen||10;o.b.i(\"canvas-renderer\",\"waiting. frame buf: \"+e),this._yuvBufferLenOnWaiting!==e&&(this._yuvBufferLenOnWaiting=e),this._waitingVideoSync=!0,this._eventEmitter.emit(n.a.DECODER_WAITING)},t._onWaitingReady=function(){o.b.i(\"canvas-renderer\",\"waiting ready. frame buf: \"+this._yuvCache.remaining+\", data ended: \"+this._dataEnded()),this._waitingVideoSync=!1,this._eventEmitter.emit(n.a.DEC_VIDEO_READY)},e}();t.a=O},function(e,t,i){var r,a=i(3),n=i(0),s=i(6),o=i(1),_=i(10),d=i(2);!function(e){e[e.KS265_PIXFMT_YUV_420P=0]=\"KS265_PIXFMT_YUV_420P\",e[e.KS265_PIXFMT_YUV_420SP=1]=\"KS265_PIXFMT_YUV_420SP\",e[e.KS265_PIXFMT_YUV_420SP_VU=2]=\"KS265_PIXFMT_YUV_420SP_VU\"}(r||(r={}));var c,u={nWidth:720,nHeight:1280,nCodedWidth:720,nCodedHeight:1280,nLumaBitDepth:10,nChromaBitDepth:10,nChromaFormatIdc:0,profile:1,level:150,has_b_frames:1,pts:0,bIllegalStream:0,poc:0},h=[0,0,0,1],l=function(){function e(e){this._eventEmitter=void 0,this._module=void 0,this._libks265=void 0,this._ctx=0,this._needNextFrame=!1,this._pendingNum=0,this._isDataEnded=!1,this._config={pAuth:0,threads:1,nal_mode:0,pic_out_pos:0,bEnableOutputRecToFile:0,strRecYuvFileName:0,logLevel:0,outputPixfmt:r.KS265_PIXFMT_YUV_420P,b_use_pthread:0},this._configPtr=0,this._framePtr=0,this._eventEmitter=e}var t=e.prototype;return t.init=function(e,t,i){var r=this,a=e.js.data,n=e.jsw?e.jsw.data:\"\",s=new Function(a+\" return KW265;\")(),o=n?new Blob([a],{type:\"text/javascript\"}):\"\",_=new Blob([n],{type:\"text/javascript\"});return s({wasmBinary:e.wasm.data,mainScriptUrlOrBlob:o,locateFile:function(e){return-1!==e.indexOf(\".worker.js\")?URL.createObjectURL(_):\"\"}}).then((function(e){r._module=e,r._cwrapLibKS265Fun(),i>1?(r._config.b_use_pthread=1,r._config.threads=i,r._config.nal_mode=0):r._config.nal_mode=0,r._newDecoder()}))},t.pushNalus=function(e,t,i){void 0===i&&(i=!1),this._updateKS265FrameInfo(this._module,this._framePtr+24,u),this._module.setValue(this._framePtr,0,\"i32\"),this._pendingNum++;var r=e.reduce((function(e,t){return e+t.data.byteLength}),0)+h.length*e.length,a=new Uint8Array(r),n=0;e.forEach((function(e){a.set(h,n),a.set(e.data,n+h.length),n+=h.length+e.data.byteLength}));var s=performance.now();this._libks265.KS265DecodeFrame(this._ctx,a,r,Math.round(t)||0),this._tryGetFrame(s),this._isDataEnded=i},t.getPendingNALNumber=function(){return this._pendingNum},t.endOfFrame=function(){},t.nextFrame=function(){this._pendingNum&&this._tryGetFrame(),this._needNextFrame=!0},t.free=function(){this._libks265.KS265DecoderDestroy(this._ctx),this._configPtr&&this._module._free(this._configPtr),this._framePtr&&this._module._free(this._framePtr),this._configPtr=this._framePtr=0},t.rebuild=function(){d.b.i(\"ks265-wrapper\",\"rebuild\"),this.free(),this._pendingNum=0,this._needNextFrame=!1,this._isDataEnded=!1,this._newDecoder()},t.flush=function(){},t.reset=function(){},t.isWaitingData=function(){return this._needNextFrame},t._tryGetFrame=function(e){if(e=e||performance.now(),this._isDataEnded&&this._libks265.KS265DecodeFlush(this._ctx,0),!(this._libks265.KS265DecoderGetDecodedFrame(this._ctx,this._framePtr)<0)){var t=this._readKS265Frame(this._module,this._framePtr);t.bValid&&(this._eventEmitter.emit(n.a.DECODER_FRAME,{frame:this._getImage(t),startTime:e}),this._isDataEnded||this._libks265.KS265DecoderReturnDecodedFrame(this._ctx,this._framePtr),this._needNextFrame=!1,this._pendingNum--)}},t._newDecoder=function(){this._configPtr=this._mallocKS265DecConfig(this._module,this._config),this._framePtr=this._mallocKS265Frame(this._module,u),this._ctx=this._libks265.KS265DecoderCreate(this._configPtr),this._libks265.KS265DecodeFlush(this._ctx,1)},t._getImage=function(e){return{format:{width:e.frameinfo.nWidth,height:e.frameinfo.nHeight,chroma:1,chromaWidth:e.frameinfo.nWidth/2,chromaHeight:e.frameinfo.nHeight/2,cropLeft:0,cropTop:0,cropWidth:e.frameinfo.nWidth,cropHeight:e.frameinfo.nHeight,displayWidth:0,displayHeight:0,pts:e.frameinfo.pts},y:{bytes:this._module.HEAPU8.subarray(e.pData[0],e.pData[0]+e.iStride[0]*e.frameinfo.nHeight),stride:e.iStride[0],bits:8},u:{bytes:this._module.HEAPU8.subarray(e.pData[1],e.pData[1]+e.iStride[1]*e.frameinfo.nHeight/2),stride:e.iStride[1],bits:8},v:{bytes:this._module.HEAPU8.subarray(e.pData[2],e.pData[2]+e.iStride[2]*e.frameinfo.nHeight/2),stride:e.iStride[2],bits:8}}},t._mallocKS265DecConfig=function(e,t){var i=e._malloc(36);return e.setValue(i,t.pAuth,\"i32\"),e.setValue(i+4,t.threads,\"i32\"),e.setValue(i+8,t.nal_mode,\"i32\"),e.setValue(i+12,t.pic_out_pos,\"i32\"),e.setValue(i+16,t.bEnableOutputRecToFile,\"i32\"),e.setValue(i+20,t.strRecYuvFileName,\"i32\"),e.setValue(i+24,t.logLevel,\"i32\"),e.setValue(i+28,t.outputPixfmt,\"i32\"),e.setValue(i+32,t.b_use_pthread,\"i32\"),i},t._readKS265FrameInfo=function(e,t){return{nWidth:e.getValue(t,\"i32\"),nHeight:e.getValue(t+4,\"i32\"),nCodedWidth:e.getValue(t+8,\"i32\"),nCodedHeight:e.getValue(t+12,\"i32\"),nLumaBitDepth:e.getValue(t+16,\"i32\"),nChromaBitDepth:e.getValue(t+20,\"i32\"),nChromaFormatIdc:e.getValue(t+24,\"i32\"),profile:e.getValue(t+28,\"i32\"),level:e.getValue(t+32,\"i32\"),has_b_frames:e.getValue(t+36,\"i32\"),pts:e.getValue(t+40,\"i32\"),bIllegalStream:e.getValue(t+48,\"i32\"),poc:e.getValue(t+52,\"i32\")}},t._updateKS265FrameInfo=function(e,t,i){e.setValue(t,i.nWidth,\"i32\"),e.setValue(t+4,i.nHeight,\"i32\"),e.setValue(t+8,i.nCodedWidth,\"i32\"),e.setValue(t+12,i.nCodedHeight,\"i32\"),e.setValue(t+16,i.nChromaFormatIdc,\"i32\"),e.setValue(t+20,i.profile,\"i32\"),e.setValue(t+24,i.level,\"i32\"),e.setValue(t+28,i.has_b_frames,\"i32\"),e.setValue(t+32,i.pts,\"i64\")},t._mallocKS265Frame=function(e,t){return e._malloc(80)},t._readKS265Frame=function(e,t){return{bValid:e.getValue(t,\"i32\"),pData:[e.getValue(t+4,\"i32\"),e.getValue(t+8,\"i32\"),e.getValue(t+12,\"i32\")],iStride:[e.getValue(t+16,\"i16\"),e.getValue(t+18,\"i16\"),e.getValue(t+20,\"i16\")],frameinfo:this._readKS265FrameInfo(e,t+24)}},t._cwrapLibKS265Fun=function(){this._libks265={KS265DecoderCreate:this._module.cwrap(\"KS265DecoderCreate\",\"number\",[\"number\"]),KS265DecoderDestroy:this._module.cwrap(\"KS265DecoderDestroy\",\"number\",[\"number\"]),KS265DecoderSetDecConfig:this._module.cwrap(\"KS265DecoderSetDecConfig\",\"number\",[\"number\",\"number\"]),KS265DecodeFrameHeader:this._module.cwrap(\"KS265DecodeFrameHeader\",\"number\",[\"number\",\"array\",\"number\"]),KS265DecodeFrame:this._module.cwrap(\"KS265DecodeFrame\",\"number\",[\"number\",\"array\",\"number\",\"number\"]),KS265DecodeFlush:this._module.cwrap(\"KS265DecodeFlush\",\"number\",[\"number\",\"number\"]),KS265DecoderGetDecodedFrame:this._module.cwrap(\"KS265DecoderGetDecodedFrame\",\"number\",[\"number\",\"number\"]),KS265DecoderReturnDecodedFrame:this._module.cwrap(\"KS265DecoderReturnDecodedFrame\",\"number\",[\"number\",\"number\"]),KS265DumpVUIParameters:this._module.cwrap(\"KS265DumpVUIParameters\",\"number\",[\"number\",\"number\",\"number\"]),module:this._module}},e}();!function(e){e[e.KVC_PIXFMT_YUV_420P=0]=\"KVC_PIXFMT_YUV_420P\",e[e.KVC_PIXFMT_YUV_420SP=1]=\"KVC_PIXFMT_YUV_420SP\",e[e.KVC_PIXFMT_YUV_420SP_VU=2]=\"KVC_PIXFMT_YUV_420SP_VU\"}(c||(c={}));var f={width:720,height:1280,codedWidth:720,codedHeight:1280,chromaFormat:0,profile:1,level:150,hasBFrames:1,pts:0},p=[0,0,0,1],m=function(){function e(e){this._eventEmitter=void 0,this._module=void 0,this._libkvc=void 0,this._ctx=0,this._needNextFrame=!1,this._pendingNum=0,this._isDataEnded=!1,this._config={threads:1,queueDecode:0,picOutPos:0,outputPixfmt:c.KVC_PIXFMT_YUV_420P,b_use_pthread:0},this._configPtr=0,this._framePtr=0,this._eventEmitter=e}var t=e.prototype;return t.init=function(e,t,i){var r=this,a=e.js.data,n=e.jsw?e.jsw.data:\"\",s=new Function(a+\" return KVCDecoder;\")(),o=n?new Blob([a],{type:\"text/javascript\"}):\"\",_=new Blob([n],{type:\"text/javascript\"});return s({wasmBinary:e.wasm.data,mainScriptUrlOrBlob:o,locateFile:function(e){return-1!==e.indexOf(\".worker.js\")?URL.createObjectURL(_):\"\"}}).then((function(e){r._module=e,r._cwrapLibKVCFun(),i>1?(r._config.b_use_pthread=1,r._config.threads=i,r._config.queueDecode=0):r._config.queueDecode=0,r._newDecoder()}))},t.pushNalus=function(e,t,i){void 0===i&&(i=!1),this._updateKVCFrameInfo(this._module,this._framePtr+24,f),this._module.setValue(this._framePtr,0,\"i32\"),this._pendingNum++;var r=e.reduce((function(e,t){return e+t.data.byteLength}),0)+p.length*e.length,a=new Uint8Array(r),n=0;e.forEach((function(e){a.set(p,n),a.set(e.data,n+p.length),n+=p.length+e.data.byteLength}));var s=performance.now();this._libkvc.KVCDecodeFrame(this._ctx,a,r,Math.round(t)||0),this._tryGetFrame(s),this._isDataEnded=i},t.getPendingNALNumber=function(){return this._pendingNum},t.endOfFrame=function(){},t.nextFrame=function(){this._pendingNum&&this._tryGetFrame(),this._needNextFrame=!0},t.free=function(){this._libkvc.KVCDecoderDestroy(this._ctx),this._ctx=0,this._configPtr&&this._module._free(this._configPtr),this._framePtr&&this._module._free(this._framePtr),this._configPtr=this._framePtr=0},t.rebuild=function(){this._pendingNum=0,this._needNextFrame=!1,this._isDataEnded=!1,d.b.i(\"kvc-wrapper\",\"rebuild\"),this.free(),this._newDecoder()},t.flush=function(){},t.reset=function(){},t.isWaitingData=function(){return this._needNextFrame},t._tryGetFrame=function(e){if(e=e||performance.now(),this._isDataEnded&&this._libkvc.KVCDecodeFlush(this._ctx,0),!(this._libkvc.KVCDecoderGetDecodedFrame(this._ctx,this._framePtr)<0)){var t=this._readKVCFrame(this._module,this._framePtr);t.valid&&(this._eventEmitter.emit(n.a.DECODER_FRAME,{frame:this._getImage(t),startTime:e}),this._isDataEnded||this._libkvc.KVCDecoderReturnDecodedFrame(this._ctx,this._framePtr),this._needNextFrame=!1,this._pendingNum--)}},t._newDecoder=function(){this._configPtr=this._mallocKVCDecConfig(this._module,this._config),this._framePtr=this._mallocKVCFrame(this._module,f),this._ctx=this._libkvc.KVCDecoderCreate(this._configPtr),this._libkvc.KVCDecodeFlush(this._ctx,1)},t._getImage=function(e){return{format:{width:e.info.width,height:e.info.height,chroma:1,chromaWidth:e.info.width/2,chromaHeight:e.info.height/2,cropLeft:0,cropTop:0,cropWidth:e.info.width,cropHeight:e.info.height,displayWidth:0,displayHeight:0,pts:e.info.pts},y:{bytes:this._module.HEAPU8.subarray(e.data[0],e.data[0]+e.stride[0]*e.info.height),stride:e.stride[0],bits:8},u:{bytes:this._module.HEAPU8.subarray(e.data[1],e.data[1]+e.stride[1]*e.info.height/2),stride:e.stride[1],bits:8},v:{bytes:this._module.HEAPU8.subarray(e.data[2],e.data[2]+e.stride[2]*e.info.height/2),stride:e.stride[2],bits:8}}},t._mallocKVCDecConfig=function(e,t){var i=e._malloc(20);return e.setValue(i,t.threads,\"i32\"),e.setValue(i+4,t.queueDecode,\"i32\"),e.setValue(i+8,t.picOutPos,\"i32\"),e.setValue(i+12,t.outputPixfmt,\"i32\"),e.setValue(i+16,t.b_use_pthread,\"i32\"),i},t._mallocKVCFrameInfo=function(e){return e._malloc(40)},t._readKVCFrameInfo=function(e,t){return{width:e.getValue(t,\"i32\"),height:e.getValue(t+4,\"i32\"),codedWidth:e.getValue(t+8,\"i32\"),codedHeight:e.getValue(t+12,\"i32\"),chromaFormat:e.getValue(t+16,\"i32\"),profile:e.getValue(t+20,\"i32\"),level:e.getValue(t+24,\"i32\"),hasBFrames:e.getValue(t+28,\"i32\"),pts:e.getValue(t+32,\"i64\")}},t._updateKVCFrameInfo=function(e,t,i){e.setValue(t,i.width,\"i32\"),e.setValue(t+4,i.height,\"i32\"),e.setValue(t+8,i.codedWidth,\"i32\"),e.setValue(t+12,i.codedHeight,\"i32\"),e.setValue(t+16,i.chromaFormat,\"i32\"),e.setValue(t+20,i.profile,\"i32\"),e.setValue(t+24,i.level,\"i32\"),e.setValue(t+28,i.hasBFrames,\"i32\"),e.setValue(t+32,i.pts,\"i64\")},t._mallocKVCFrame=function(e,t){return e._malloc(64)},t._readKVCFrame=function(e,t){return{valid:e.getValue(t,\"i32\"),data:[e.getValue(t+4,\"i32\"),e.getValue(t+8,\"i32\"),e.getValue(t+12,\"i32\")],stride:[e.getValue(t+16,\"i16\"),e.getValue(t+18,\"i16\"),e.getValue(t+20,\"i16\")],info:this._readKVCFrameInfo(e,t+24)}},t._cwrapLibKVCFun=function(){this._libkvc={KVCDecoderCreate:this._module.cwrap(\"KVCDecoderCreate\",\"number\",[\"number\"]),KVCDecoderDestroy:this._module.cwrap(\"KVCDecoderDestroy\",\"number\",[\"number\"]),KVCDecoderSetDecConfig:this._module.cwrap(\"KVCDecoderSetDecConfig\",\"number\",[\"number\",\"number\"]),KVCDecodeFrameHeader:this._module.cwrap(\"KVCDecodeFrameHeader\",\"number\",[\"number\",\"array\",\"number\"]),KVCDecodeFrame:this._module.cwrap(\"KVCDecodeFrame\",\"number\",[\"number\",\"array\",\"number\",\"number\"]),KVCDecodeFlush:this._module.cwrap(\"KVCDecodeFlush\",\"number\",[\"number\",\"number\"]),KVCDecoderGetDecodedFrame:this._module.cwrap(\"KVCDecoderGetDecodedFrame\",\"number\",[\"number\",\"number\"]),KVCDecoderReturnDecodedFrame:this._module.cwrap(\"KVCDecoderReturnDecodedFrame\",\"number\",[\"number\",\"number\"]),KVCDecoderGetVersion:this._module.cwrap(\"KVCDecoderGetVersion\",\"number\"),KVC19DumpVUIParameters:this._module.cwrap(\"KVCDumpVUIParameters\",\"number\",[\"number\",\"number\",\"number\"]),module:this._module}},e}(),v=i(30),E=1e3/o.f,g=[s.a.HEVC_NAL_TRAIL_N,s.a.HEVC_NAL_TSA_N,s.a.HEVC_NAL_STSA_N,s.a.HEVC_NAL_RADL_N,s.a.HEVC_NAL_RASL_N],y=[s.a.HEVC_NAL_IDR_W_RADL,s.a.HEVC_NAL_IDR_N_LP,s.a.HEVC_NAL_CRA_NUT],b=function(){function e(e){var t=this;this._decoder=void 0,this._eventEmitter=void 0,this._clock=-1,this._frameBufLen=0,this._maxFrameBufLen=16,this._vLastPTS=0,this._vLastDTS=0,this._dataCache=[],this._gopId=0,this._frameDuration=33,this._droppedFrames=0,this._decodedFrames=0,this._loop=void 0,this._decodeTimes=[],this._avgDecodeDuration=0,this._mediaInfo=void 0,this._hasOverriddenFPS=!1,this._output=o.p.canvas,this._decConfigData=void 0,this._seeking=!1,this._seekingTime=0,this._decId=1,this._defaultDropPolicy=o.n.AUTO,this._dropPolicy=o.n.AUTO,this._lastDataCachePTS=-1,this._endOfData=!1,this._expiredDataSync=!1,this._lastPushPTS=0,this._appendDecActive=!1,this._decBufInfo=[],this._onSeeked=function(e){t._eventEmitter.emit(n.a.DECODER_SEEK,{hitCache:e}),e?t._seeking=!1:t._expiredDataSync=!0},this._onSeekAbort=function(){t._seeking=!1,t._eventEmitter.emit(n.a.DECODER_SEEK_ABORT)},this._onFrame=function(e){for(t._vLastPTS=e.frame.format.pts;t._decBufInfo.length&&e.frame.format.pts+1>=t._decBufInfo[0].pts;)t._decBufInfo.shift();if(t._decodeTimes.length>10&&t._decodeTimes.shift(),e.startTime){var i=performance.now()-e.startTime;t._decodeTimes.push(i),t._avgDecodeDuration=t._decodeTimes.reduce((function(e,t){return e+t}),0)/t._decodeTimes.length,t._vLastPTS+=i,t._decodedFrames++;var r=e.frame;t._preprocessYUV(r),t._eventEmitter.emit(n.a.DECODER_IMG,{droped:t._droppedFrames,decoded:t._decodedFrames,decId:t._decId,frame:r});var a=t._seekingTime;t._endOfData&&(a=t._lastDataCachePTS>=0?Math.min(t._lastDataCachePTS,a):a),t._seeking&&e.frame.format.pts+1>=a&&t._onSeeked(!0)}},this._eventEmitter=e,this._eventEmitter.on(n.a.DECODER_FRAME,this._onFrame)}var t=e.prototype;return t.init=function(e,t,i,r,s,_,d){var c=this;this._decId=e,this._dropPolicy=i.videoDropFramePolicy,this._defaultDropPolicy=i.videoDropFramePolicy,this._decoder=_===o.b.kvc3||_===o.b.kvc4?new m(this._eventEmitter):d===o.q.kw265?new l(this._eventEmitter):new v.a(this._eventEmitter);try{this._decoder.init(t,r,s).then((function(){c._decoder&&(c._appendDecActive=!0,c._decoder.nextFrame(),c._startLoop(),c._eventEmitter.emit(n.a.DEC_INIT_COMPLETE,{simd:r,threads:s,decoderType:d}))})).catch((function(e){c._eventEmitter.emit(n.a.ERROR,{type:a.b.DECODER_ERROR,details:a.a.DECODER_INIT_ERROR,fatal:!0,reason:e})}))}catch(e){this._eventEmitter.emit(n.a.ERROR,{type:a.b.DECODER_ERROR,details:a.a.DECODER_INIT_ERROR,fatal:!0,reason:e.message})}},t.expiredDataSync=function(){this._expiredDataSync=!1},t.appendData=function(e){var t=this;this._expiredDataSync||(this._endOfData&&d.b.i(\"v-decoder-inline\",\"end of data false on append\"),this._endOfData=!1,e.type!==_.d.decoderConfig?(e.samples.forEach((function(i){var r=t._isIDR(i);if(r||-1!==t._lastDataCachePTS){var a;if(r)t._decConfigData&&(a=i.units).unshift.apply(a,t._decConfigData.units),t._gopId++;var n={key:r,gopId:t._gopId,type:e.type||_.d.videoFrame,data:i,dts:i.dts/90,pts:i.pts/90};n.pts>t._lastDataCachePTS&&(t._lastDataCachePTS=n.pts);var s=t._dataCache.length?t._dataCache[t._dataCache.length-1].dts:t._vLastDTS;n.discontinuity=!!(n.type===_.d.videoFrame&&s&&Math.abs(n.dts-s)>_.c),t._dataCache.push(n)}})),!this._hasOverriddenFPS&&this._dataCache.length>10&&(this._frameDuration=Math.max(E,(this._dataCache[this._dataCache.length-1].dts-this._dataCache[0].dts)/(this._dataCache.length-1)))):this._decConfigData=e.samples[0])},t.endOfData=function(){d.b.i(\"v-decoder-inline\",\"end of data\"),this._endOfData=!0},t.updateState=function(e,t,i,r,a,n){this._output=t,this._appendDecActive=i,this._frameBufLen=r,this._maxFrameBufLen=n,this._dropPolicy=a>=1.5?o.n.ALL_NON_REF:this._defaultDropPolicy,this._seeking&&Math.abs(e-this._seekingTime/1e3)>.1&&this._onSeekAbort(),t!==o.p.video&&(this._clock=1e3*e)},t.updateMediaInfo=function(e){var t;this._mediaInfo=e,this._mediaInfo.rotation=((null==(t=this._mediaInfo)?void 0:t.rotation)||0)%360,this._mediaInfo.rotation<0&&(this._mediaInfo.rotation+=360),this._updateFPS()},t.destroy=function(){this._eventEmitter.off(n.a.DECODER_FRAME,this._onFrame),this._appendDecActive=!1,this._stopLoop()},t.flush=function(e){if(d.b.i(\"v-decoder-inline\",\"flush\",e),this._dataCache.length&&e>this._dataCache[0].pts){for(var t=0;te);t++);this._dataCache=this._dataCache.slice(0,t)}else e>this._lastPushPTS&&this._decoder&&this._decoder.rebuild()},t.reset=function(e,t){void 0===t&&(t=!1),d.b.i(\"v-decoder-inline\",\"reset\",e),this._decoder&&this._decoder.rebuild(),this._decId=e,this._dataCache=[],this._lastDataCachePTS=-1,this._vLastPTS=0,this._vLastDTS=0,this._clock=-1,this._frameBufLen=0,this._endOfData=!1,this._expiredDataSync=!1,this._lastPushPTS=0,this._appendDecActive=!0,this._decBufInfo=[],this._updateFPS(),t||(this._seeking=!1,this._seekingTime=0)},t.seek=function(e){var t,i;d.b.i(\"v-decoder-inline\",\"decoder seek: \"+e),e*=1e3,this._clock=this._seekingTime=e,this._seeking=!0;var r=this._vLastPTS||(null==(t=this._decBufInfo[0])?void 0:t.pts)||0,a=this._decBufInfo.length?this._decBufInfo[this._decBufInfo.length-1].pts+this._frameDuration:this._vLastPTS||(null==(i=this._dataCache[0])?void 0:i.pts)||0;if(this._decBufInfo.length&&e>=r&&e<=a)d.b.i(\"v-decoder-inline\",\"decoder seek hit dec cache\");else if(this._dataCache.length&&a<=e&&this._lastDataCachePTS>=e){for(var s=this._dataCache[0].gopId,o=s,_=0,c=0,u=0;u=e));u++);o===s||c<=3&&o-s==1?d.b.i(\"v-decoder-inline\",\"decoder seek hit data cache. continue decode\"):(d.b.i(\"v-decoder-inline\",\"decoder seek hit data cache. switch gop\"),this._eventEmitter.emit(n.a.RENDERER_BUF_EXPIRED),this._dataCache.splice(0,_),this._decoder&&this._decoder.rebuild(),this._vLastPTS=0,this._vLastDTS=0,this._lastPushPTS=0)}else d.b.i(\"v-decoder-inline\",\"decoder seek miss cache.\"),this._dataCache=[],this._onSeeked(!1)},t._dataEnded=function(){return!(!this._endOfData||this._dataCache.length||!this._decoder||this._decoder.isWaitingData()||this._decoder.getPendingNALNumber())},t._preprocessYUV=function(e){this._preprocessYUVPlane(e.y,e.format.width,e.format.height),this._preprocessYUVPlane(e.u,e.format.chromaWidth,e.format.chromaHeight),this._preprocessYUVPlane(e.v,e.format.chromaWidth,e.format.chromaHeight)},t._preprocessYUVPlane=function(e,t,i){var r=e.bits>8?2:1;if(e.stride/r>t){for(var a=new Uint8Array(t*i*r),n=0;nthis._lastPushPTS&&(this._lastPushPTS=e.pts),e.type===_.d.videoFrame&&(this._vLastDTS=e.dts,this._dataCache.length||this._decoder.endOfFrame()))},t._resetTime=function(){d.b.i(\"v-decoder-inline\",\"reset time\"),this._decoder&&this._vLastDTS&&this._decoder.reset(),this._vLastPTS=0,this._vLastDTS=0,this._lastPushPTS=0},t._update=function(){if(this._decoder&&-1!==this._clock&&this._output!==o.p.video){var e=this._clock;if(this._vLastPTS&&this._dataCache.length&&this._appendDecActive&&!this._seeking){var t=this._syncIndex(e);t>5&&this._dropFrame(e,this._dataCache[t].gopId)}e+=(this._maxFrameBufLen+16)*this._frameDuration;var i=this._frameBufLen3);)if(this._dropPolicy===o.n.ALL_NON_REF&&this._isRefFrame(r.data))this._dataCache.shift(),r=this._dataCache[0],this._droppedFrames++;else{var s=this._dataCache.shift();this._pushDataToDecoder(s),r=this._dataCache[0],i=!1}this._endOfData&&!this._dataCache.length&&(this._decoder.flush(),this._eventEmitter.emit(n.a.DECODER_DATA_END))}this._decoder.isWaitingData()&&!this._decoder.getPendingNALNumber()||this._decoder.nextFrame()}},t._syncIndex=function(e){for(var t=0;t=e)return t;return this._dataCache.length?this._dataCache.length-1:-1},t._dropFrame=function(e,t){for(var i,r=0,a=!1,s=0,c=!1,u=0;st)break;if(!(e>h.dts&&this._dropPolicy!==o.n.MIN))break;this._isRefFrame(h.data)&&(l=this._dataCache.splice(s,1)[0]),s++}else h.gopId0&&e.fps255||(r=e.charCodeAt(_++))>255||(a=e.charCodeAt(_++))>255)throw new TypeError(\"invalid character found\");n+=s[(t=i<<16|r<<8|a)>>18&63]+s[t>>12&63]+s[t>>6&63]+s[63&t]}return o?n.slice(0,o-3)+\"===\".substring(o):n},f=i?function(e){return btoa(e)}:r?function(e){return Buffer.from(e,\"binary\").toString(\"base64\")}:l,p=r?function(e){return Buffer.from(e).toString(\"base64\")}:function(e){for(var t=[],i=0,r=e.length;i>>6)+d(128|63&t):d(224|t>>>12&15)+d(128|t>>>6&63)+d(128|63&t);var t=65536+1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320);return d(240|t>>>18&7)+d(128|t>>>12&63)+d(128|t>>>6&63)+d(128|63&t)},E=/[\\uD800-\\uDBFF][\\uDC00-\\uDFFFF]|[^\\x00-\\x7F]/g,g=function(e){return e.replace(E,v)},y=r?function(e){return Buffer.from(e,\"utf8\").toString(\"base64\")}:n?function(e){return p(n.encode(e))}:function(e){return f(g(e))},b=function(e,t){return void 0===t&&(t=!1),t?u(y(e)):y(e)},S=function(e){return b(e,!0)},T=/[\\xC0-\\xDF][\\x80-\\xBF]|[\\xE0-\\xEF][\\x80-\\xBF]{2}|[\\xF0-\\xF7][\\x80-\\xBF]{3}/g,R=function(e){switch(e.length){case 4:var t=((7&e.charCodeAt(0))<<18|(63&e.charCodeAt(1))<<12|(63&e.charCodeAt(2))<<6|63&e.charCodeAt(3))-65536;return d(55296+(t>>>10))+d(56320+(1023&t));case 3:return d((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return d((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},L=function(e){return e.replace(T,R)},x=function(e){if(e=e.replace(/\\s+/g,\"\"),!_.test(e))throw new TypeError(\"malformed base64.\");e+=\"==\".slice(2-(3&e.length));for(var t,i,r,a=\"\",n=0;n>16&255):64===r?d(t>>16&255,t>>8&255):d(t>>16&255,t>>8&255,255&t);return a},A=t?function(e){return atob(h(e))}:r?function(e){return Buffer.from(e,\"base64\").toString(\"binary\")}:x,D=r?function(e){return c(Buffer.from(e,\"base64\"))}:function(e){return c(A(e),(function(e){return e.charCodeAt(0)}))},C=function(e){return D(O(e))},I=r?function(e){return Buffer.from(e,\"base64\").toString(\"utf8\")}:a?function(e){return a.decode(D(e))}:function(e){return L(A(e))},O=function(e){return h(e.replace(/[-_]/g,(function(e){return\"-\"==e?\"+\":\"/\"})))},k=function(e){return I(O(e))},P=function(e){return{value:e,enumerable:!1,writable:!0,configurable:!0}},w=function(){var e=function(e,t){return Object.defineProperty(String.prototype,e,P(t))};e(\"fromBase64\",(function(){return k(this)})),e(\"toBase64\",(function(e){return b(this,e)})),e(\"toBase64URI\",(function(){return b(this,!0)})),e(\"toBase64URL\",(function(){return b(this,!0)})),e(\"toUint8Array\",(function(){return C(this)}))},N=function(){var e=function(e,t){return Object.defineProperty(Uint8Array.prototype,e,P(t))};e(\"toBase64\",(function(e){return m(this,e)})),e(\"toBase64URI\",(function(){return m(this,!0)})),e(\"toBase64URL\",(function(){return m(this,!0)}))},M={version:\"3.7.2\",VERSION:\"3.7.2\",atob:A,atobPolyfill:x,btoa:f,btoaPolyfill:l,fromBase64:k,toBase64:b,encode:b,encodeURI:S,encodeURL:S,utob:g,btou:L,decode:k,isValid:function(e){if(\"string\"!=typeof e)return!1;var t=e.replace(/\\s+/g,\"\").replace(/={0,2}$/,\"\");return!/[^\\s0-9a-zA-Z\\+/]/.test(t)||!/[^\\s0-9a-zA-Z\\-_]/.test(t)},fromUint8Array:m,toUint8Array:C,extendString:w,extendUint8Array:N,extendBuiltins:function(){w(),N()},Base64:{}};return Object.keys(M).forEach((function(e){return M.Base64[e]=M[e]})),M}()},function(e,t){function i(t,r){return e.exports=i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},e.exports.__esModule=!0,e.exports.default=e.exports,i(t,r)}e.exports=i,e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,i){e.exports=function(e,t){if(t=t.split(\":\")[0],!(e=+e))return!1;switch(t){case\"http\":case\"ws\":return 80!==e;case\"https\":case\"wss\":return 443!==e;case\"ftp\":return 21!==e;case\"gopher\":return 70!==e;case\"file\":return!1}return 0!==e}},function(e,t,i){var r=Object.prototype.hasOwnProperty;function a(e){try{return decodeURIComponent(e.replace(/\\+/g,\" \"))}catch(e){return null}}function n(e){try{return encodeURIComponent(e)}catch(e){return null}}t.stringify=function(e,t){t=t||\"\";var i,a,s=[];for(a in\"string\"!=typeof t&&(t=\"?\"),e)if(r.call(e,a)){if((i=e[a])||null!=i&&!isNaN(i)||(i=\"\"),a=n(a),i=n(i),null===a||null===i)continue;s.push(a+\"=\"+i)}return s.length?t+s.join(\"&\"):\"\"},t.parse=function(e){for(var t,i=/([^=?#&]+)=?([^&]*)/g,r={};t=i.exec(e);){var n=a(t[1]),s=a(t[2]);null===n||null===s||n in r||(r[n]=s)}return r}},function(e,t,i){i.r(t);var r=i(12),a=i(0),n=i(2),s=i(34),o=i(11);t.default=function(e){var t=new r.EventEmitter,i=new s.a(t);t.on(a.a.DEC_INIT_COMPLETE,(function(t){e.postMessage({event:a.a.DEC_INIT_COMPLETE,data:t})})),t.on(a.a.DECODER_IMG,(function(t){e.postMessage({event:a.a.DECODER_IMG,data:t},[t.frame.y.bytes.buffer,t.frame.u.bytes.buffer,t.frame.v.bytes.buffer])})),t.on(a.a.STEP,(function(t){e.postMessage({event:a.a.STEP,data:t})})),t.on(a.a.DECODER_SEEK,(function(t){e.postMessage({event:a.a.DECODER_SEEK,data:t})})),t.on(a.a.DECODER_SEEK_ABORT,(function(t){e.postMessage({event:a.a.DECODER_SEEK_ABORT,data:t})})),t.on(a.a.RENDERER_BUF_EXPIRED,(function(t){e.postMessage({event:a.a.RENDERER_BUF_EXPIRED,data:t})})),t.on(a.a.DECODER_DATA_END,(function(t){e.postMessage({event:a.a.DECODER_DATA_END,data:t})})),t.on(a.a.DECODER_DROP_FRAME,(function(t){e.postMessage({event:a.a.DECODER_DROP_FRAME,data:t})})),t.on(a.a.ERROR,(function(t){e.postMessage({event:a.a.ERROR,data:t})})),e.addEventListener(\"message\",(function(e){var r=e.data;switch(r.cmd){case o.a.APPEND_DATA:i.appendData(r.data);break;case o.a.UPDATE_STATE:i.updateState(r.streamTime,r.output,r.active,r.frameBufLen,r.playbackRate,r.maxFrameBufLen);break;case o.a.INIT_265:n.b.level(r.config.kwaiKernelLog),i.init(r.id,r.lib,r.config,r.simd,r.threads,r.codecType,r.decoderType);break;case o.a.MEDIA_INFO:i.updateMediaInfo(r.mediaInfo);break;case o.a.DESTROY:i&&i.destroy(),t&&t.removeAllListeners();break;case o.a.RESET:i.reset(r.decId,r.seeking);break;case o.a.FLUSH:i.flush(r.startTime);break;case o.a.SEEK:i.seek(r.time);break;case o.a.END_OF_DATA:i.endOfData();break;case o.a.EXPIRED_DATA_SYNC:i.expiredDataSync()}}))}},function(e,t,i){i.r(t);var r=i(12),a=i(0),n=i(2),s=i(11),o=i(33);t.default=function(e){var t=new r.EventEmitter,i=new o.a(t);t.on(a.a.STEP,(function(t){e.postMessage({event:a.a.STEP,data:t})})),t.on(a.a.RENDERER_INIT_COMPLETE,(function(t){e.postMessage({event:a.a.RENDERER_INIT_COMPLETE,data:t})})),t.on(a.a.RENDERER_BUF_UPDATE,(function(t){e.postMessage({event:a.a.RENDERER_BUF_UPDATE,data:t})})),t.on(a.a.DEC_VIDEO_READY,(function(t){e.postMessage({event:a.a.DEC_VIDEO_READY})})),t.on(a.a.DECODER_IMG,(function(t){e.postMessage({event:a.a.DECODER_IMG,data:t},[t.frame.y.bytes.buffer,t.frame.u.bytes.buffer,t.frame.v.bytes.buffer])})),t.on(a.a.DECODER_WAITING,(function(t){e.postMessage({event:a.a.DECODER_WAITING,data:t})})),t.on(a.a.RENDERER_SEEK,(function(t){e.postMessage({event:a.a.RENDERER_SEEK,data:t})})),t.on(a.a.RENDERER_DRAW,(function(t){e.postMessage({event:a.a.RENDERER_DRAW,data:t})})),t.on(a.a.ERROR,(function(t){e.postMessage({event:a.a.ERROR,data:t})})),e.addEventListener(\"message\",(function(e){var r=e.data;switch(r.cmd){case s.a.UPDATE_STATE:i.updateState(r.streamTime,r.width,r.height,r.stoped,r.output,r.maxFrameBufLen);break;case s.a.APPEND_DATA:i.append(r.frame);break;case s.a.SEEK:i.seek(r.time);break;case s.a.STEP:i.step(r.type);break;case s.a.INIT_RENDERER:n.b.level(r.config.kwaiKernelLog),i.init(r.id,r.config,r.canvas);break;case s.a.RESET:i.reset(r.decId,r.seeking);break;case s.a.FLUSH:i.flush(r.startTime);break;case s.a.MEDIA_INFO:i.updateMediaInfo(r.mediaInfo);break;case s.a.END_OF_DATA:i.endOfData();break;case s.a.DEC_DROP_FRAME:i.decDropFrameInfo(r.data);break;case s.a.DESTROY:i&&i.destroy(),t&&t.removeAllListeners()}}))}},function(e,t,i){i.r(t);var r=i(12),a=i(0),n=i(22),s=i(10),o=i(2),_=i(32);t.default=function(e){var t,i=new r.EventEmitter;i.on(a.a.PRIV_NAL,(function(t){return e.postMessage({event:a.a.PRIV_NAL,data:t})})),i.on(a.a.VIDEO_CODEC_DETECTED,(function(t){return e.postMessage({event:a.a.VIDEO_CODEC_DETECTED,data:t})})),i.on(a.a.INIT_PTS_FOUND,(function(t){return e.postMessage({event:a.a.INIT_PTS_FOUND,data:t})})),i.on(a.a.PARSING_INIT_SEGMENT,(function(t){return e.postMessage({event:a.a.PARSING_INIT_SEGMENT,data:t})})),i.on(a.a.PARSED_DATA,(function(t){return e.postMessage({event:a.a.PARSED_DATA,data:t})})),i.on(a.a.LOAD_END,(function(t){return e.postMessage({event:a.a.LOAD_END,data:t})})),i.on(a.a.ERROR,(function(t){return e.postMessage({event:a.a.ERROR,data:t})})),i.on(a.a.DEMUXER_DETECTED,(function(t){return e.postMessage({event:a.a.DEMUXER_DETECTED,data:t})})),i.on(a.a.MEDIA_DEMUX,(function(t){return e.postMessage({event:a.a.MEDIA_DEMUX,data:t})})),i.on(a.a.METADATA,(function(t){return e.postMessage({event:a.a.METADATA,data:t})})),i.on(a.a.KEY_FRAME_INDEXS,(function(t){return e.postMessage({event:a.a.KEY_FRAME_INDEXS,data:t})})),i.on(a.a.KEY_FRAME,(function(){return e.postMessage({event:a.a.KEY_FRAME})})),i.on(a.a.VIDEO_FRAME_INFO,(function(t){return e.postMessage({event:a.a.VIDEO_FRAME_INFO,data:t})})),i.on(a.a.MP4_NOT_FASTSTART,(function(t){return e.postMessage({event:a.a.MP4_NOT_FASTSTART,data:t})})),i.on(a.a.PARSING_DATA,(function(t){var i={event:a.a.PARSING_DATA,data:t},r=[];t.segments.forEach((function(e){r.push(e.payload.buffer)})),e.postMessage(i,r)})),i.on(a.a.RAW_DATA,(function(t){var i={event:a.a.RAW_DATA,data:t};if(t.type===s.d.videoFrame){var r=[];t.samples&&t.samples.forEach((function(e){e.units.forEach((function(t){e.units.length&&-1===r.indexOf(t.data.buffer)&&r.push(t.data.buffer)}))}));try{e.postMessage(i,r)}catch(t){e.postMessage(i)}}else e.postMessage(i)})),e.addEventListener(\"message\",(function(e){var r=e.data;switch(r.cmd){case n.a.INIT:o.b.level(r.config.kwaiKernelLog),function(e,i,r,a){t=new _.a(e,i,r,a)}(i,r.typeSupported,r.config,r.vendor);break;case n.a.PUSH:t.push(r.data,r.decryptdata,r.initSegment,r.timeOffset,r.contiguous,r.trackSwitch,r.discontinuity,r.accurateTimeOffset,r.fragEnd,r.transmuxData);break;case n.a.FLUSH:t.flush();break;case n.a.LOAD_END:t.end()}}))}},function(e,t,i){i.r(t),i.d(t,\"default\",(function(){return Zi})),i.d(t,\"createKernel\",(function(){return er})),i.d(t,\"LOG_LEVEL\",(function(){return g.a})),i.d(t,\"KEvents\",(function(){return l.a})),i.d(t,\"REPORT_TYPES\",(function(){return Ve})),i.d(t,\"CodecType\",(function(){return v.b})),i.d(t,\"Decoder\",(function(){return v.c})),i.d(t,\"DemuxerType\",(function(){return se.b})),i.d(t,\"HttpRangeType\",(function(){return v.d})),i.d(t,\"MediaBox\",(function(){return v.g})),i.d(t,\"VideoDecBlockPolicy\",(function(){return v.m})),i.d(t,\"VideoDropFramePolicy\",(function(){return v.n})),i.d(t,\"VideoRenderer\",(function(){return v.o})),i.d(t,\"VideoRendererType\",(function(){return v.p})),i.d(t,\"WasmDecoder\",(function(){return v.q}));var r=i(7),a=i.n(r),n=i(5),s=i.n(n),o=i(12),_=i(13),d=i.n(_),c=i(28),u=i.n(c),h=i(3),l=i(0),f=i(35),p=i(18),m=i.n(p),v=i(1),E=i(9),g=i(2),y=function(){function e(){this.tag=\"blob\",this._context=void 0,this._callbacks=void 0,this._reader=void 0,this._buffer=void 0}var t=e.prototype;return t.load=function(e,t){var i=this;this._context=e,this._callbacks=t;var r=this._buffer;if(e.url instanceof Blob)if(r)setTimeout((function(){i._loadDataByRange(r,e.rangeStart,e.rangeEnd)}),0);else{var a=e.url,n=this._reader=new FileReader;n.onerror=function(){i._callbacks&&i._callbacks.onError&&i._callbacks.onError(n.error||new Error(\"blob read error\"))},this._reader.onloadend=function(t){i._buffer=new Uint8Array(n.result),i._loadDataByRange(i._buffer,e.rangeStart,e.rangeEnd)},this._reader.readAsArrayBuffer(a)}},t.abort=function(){this._reader&&(this._reader.abort(),this._reader.onerror=null,this._reader.onloadend=null,this._reader=void 0)},t.destroy=function(){this.abort(),this._buffer=void 0},t._loadDataByRange=function(e,t,i){if(this._context&&this._callbacks){t||(t=0),i||(i=e.length),i=Math.min(i,e.length);var r=new Uint8Array(e.subarray(t,i)),a=this._context,n=this._callbacks;n.onProgress&&n.onProgress(a,r.buffer),setTimeout((function(){n.onEnd&&n.onEnd(a,null)}),0)}},e}();function b(e,t,i){if(void 0===e[t=t.toLocaleLowerCase()])e[t]=i;else{var r=e[t];Array.isArray(r)?r.push(i):\"string\"==typeof r&&(e[t]=[r,i])}}function S(e){var t={};return\"string\"==typeof e?e.trim().split(/[\\r\\n]+/).forEach((function(e){var i=e.split(\": \"),r=i.shift(),a=i.join(\":\");r&&b(t,r,a)})):e&&e.forEach((function(e,i){e.split(\",\").forEach((function(e){b(t,i,e)}))})),t}function T(e){var t=[];if(e)for(var i in t=[],e)if(\"kwaisign\"===i||0===i.indexOf(\"x-ks-\")){var r=e[i];r&&t.push(i+\": \"+(Array.isArray(r)?r.join(\",\"):r).slice(0,255))}if(t.length)return t.slice(0,10),t}var R,L=function(){function e(){this.tag=\"fetch\",this._context=void 0,this._callbacks=null,this._controller=null,this._reader=null,this._abort=!1}e.isSupported=function(){return\"undefined\"!=typeof fetch&&void 0!==typeof ReadableStream};var t=e.prototype;return t.load=function(e,t){var i=this;this._context=e,this._callbacks=t;var r=new Headers;e.headers&&e.headers.forEach((function(e){r.append(e.header,e.value)})),e.range&&r.append(\"Range\",e.range);var a={method:e.requestMethod?e.requestMethod:\"GET\",headers:r,mode:\"cors\",cache:\"default\",referrerPolicy:\"no-referrer-when-downgrade\",signal:this._getAbortSignal()};e.requestBody&&(a.body=e.requestBody),e.credentials&&(a.credentials=\"include\"),fetch(e.url,a).then((function(t){if(e.responseUrl=t.url,e.responseHeader=S(t.headers),i._callbacks&&i._callbacks.onConnect&&i._callbacks.onConnect(e,t.status),t.ok)return i._abort?void(t.body&&t.body.getReader().cancel()):\"arraybuffer\"===e.responseType?e.progress?void(t.body&&(i._reader=t.body.getReader(),i._pump(i._reader))):void t.arrayBuffer().then((function(t){i._onEnd(e,t)})):void t.text().then((function(t){i._onEnd(e,t)}));var r=new Error(t.status+\" \"+t.statusText);i._onError(r)})).catch((function(e){\"AbortError\"!==e.name&&i._onError(e)}))},t.abort=function(){this._controller?this._controller.abort():this._reader&&(this._reader.cancel(),this._reader=null),this._abort=!0},t.destroy=function(){this._callbacks=null,this.abort()},t._onProgress=function(e,t){this._callbacks&&this._callbacks.onProgress&&this._callbacks.onProgress(e,t)},t._onEnd=function(e,t){this._callbacks&&this._callbacks.onEnd&&(this._reader=null,this._controller=null,this._callbacks.onEnd(e,t))},t._onError=function(e){this._callbacks&&this._callbacks.onError&&this._callbacks.onError(e)},t._pump=function(e){var t=this;e.read().then((function(i){if(t._abort)return e.cancel(),null;if(i.done)return t._onEnd(t._context,null),null;var r=i.value.buffer;return t._onProgress(t._context,r),t._pump(e)})).catch((function(e){\"AbortError\"!==e.name&&t._onError(e)}))},t._getAbortSignal=function(){try{if(AbortController)return this._controller=new AbortController,this._controller.signal}catch(e){return null}return null},e}();!function(e){e.MOZ_CHUNK=\"moz-chunked-arraybuffer\",e.UNKNOW=\"unknow\",e.UNSUPPORT=\"\"}(R||(R={}));var x,A=function(){function e(){var e=this;this.tag=\"xhr\",this._xhr=null,this._context=void 0,this._callbacks=null,this._progress=R.UNKNOW,this._onReadyStateChange=function(t){if(e._xhr){var i=e._xhr;2===i.readyState&&(e._context.responseUrl=i.responseURL,e._context.responseHeader=S(i.getAllResponseHeaders()),e._callbacks&&e._callbacks.onConnect&&e._callbacks.onConnect(e._context,i.status),(i.status<200||i.status>299)&&e._onError(new Error(\"xhr error\")))}},this._onProgress=function(t){if(e._xhr){var i=e._xhr.response;e._callbacks&&e._callbacks.onProgress&&i&&e._callbacks.onProgress(e._context,i)}},this._onLoadEnd=function(t){var i=null,r=e._xhr;!e._progress&&r&&(i=r.response),e._callbacks&&e._callbacks.onEnd(e._context,i)},this._onError=function(t){var i;e._callbacks&&e._callbacks.onError&&e._callbacks.onError(t),null==(i=e._xhr)||i.abort()},this._xhr=null}e.isSupportChunk=function(){if(e.supportChunk!==R.UNKNOW)return e.supportChunk;try{var t=new XMLHttpRequest;if(t.open(\"GET\",\"https://example.com\",!0),t.responseType=R.MOZ_CHUNK,t.responseType===R.MOZ_CHUNK)return e.supportChunk=R.MOZ_CHUNK,e.supportChunk}catch(t){e.supportChunk=R.UNSUPPORT}return R.UNSUPPORT};var t=e.prototype;return t.load=function(t,i){this._callbacks=i,this._context=t,this._progress=R.UNSUPPORT,t.progress&&\"arraybuffer\"===t.responseType&&(this._progress=e.isSupportChunk());var r=this._xhr=new XMLHttpRequest;r.open(t.requestMethod?t.requestMethod:\"GET\",this._context.url,!0),this._progress===R.MOZ_CHUNK?(r.responseType=R.MOZ_CHUNK,r.onprogress=this._onProgress,r.onload=this._onLoadEnd):(r.responseType=t.responseType||\"arraybuffer\",r.onload=this._onLoadEnd),r.onreadystatechange=this._onReadyStateChange,r.onerror=this._onError,r.withCredentials=!!t.credentials,t.range&&r.setRequestHeader(\"Range\",t.range),t.headers&&t.headers.forEach((function(e){r.setRequestHeader(e.header,e.value)})),r.send(t.requestBody)},t.abort=function(){this._xhr&&(this._xhr.onreadystatechange=null,this._xhr.onprogress=null,this._xhr.onload=null,this._xhr.onerror=null,this._xhr.abort(),this._xhr=null)},t.destroy=function(){this._callbacks=null,this.abort()},e}();A.supportChunk=R.UNKNOW;var D=0,C=function(){var e=t.prototype;function t(){var e=this;this._context=void 0,this._loader=void 0,this._callbacks=null,this._config=void 0,this._loaderCallback=void 0,this._stats=void 0,this._retryDelay=0,this._loading=!1,this._aborted=!1,this._requestTimeout=void 0,this._transTimer=void 0,this._retryTimeout=void 0,this._rangeStart=void 0,this._progressTime=0,this._loadInternal=function(){e._loading=!0,e._aborted=!1;var t=e._stats;t.code=0,t.tfirst=0,t.loaded=0,e._retryTimeout&&(clearTimeout(e._retryTimeout),e._retryTimeout=null),e._loader=new(e._getInternalLoader(e._context,e._config)),e._loader&&(t.id=e._loader.tag+\"-\"+D,e._config.connectionTimeout&&(e._requestTimeout=setTimeout(e._onTimeout,e._config.connectionTimeout)),e._httpRange(e._context),t.tsload=Date.now(),t.tstart=performance.now(),e._loader.load(e._context,e._loaderCallback))},this._onConnect=function(t,i){var r=e._stats;e._getContentLen(t,r),e._requestTimeout&&(clearTimeout(e._requestTimeout),e._requestTimeout=null),e._startTransmissionTimer(),r.code=i,r.tfirst=Math.max(r.trequest,performance.now()),e._callbacks&&e._callbacks.onConnect&&e._callbacks.onConnect(t,r)},this._onProgress=function(t,i){var r=e._stats;if(e._progressTime=performance.now(),!t.breakpointContinuation&&r.output>r.loaded){if(r.loaded+i.byteLength-r.output>0){var a=i.slice(r.output-r.loaded);e._callProgress(e._context,a,r)}r.loaded+=i.byteLength}else r.loaded+=i.byteLength,e._callProgress(e._context,i,r)},this._onError=function(t){g.b.i(\"loader\",t),e._stopTimer(),e._destroyLoader();var i,r=e._stats,a=e._config;e._loading=!1,e._context.breakpointContinuation&&416===r.code?null!=(i=e._callbacks)&&i.onEnd&&e._callbacks.onEnd(e._context,null,r):(r.fatal=!a.maxRetry||r.retry>=a.maxRetry||!a.maxRetry,r.text=t.message||\"load error\",e._callbacks&&e._callbacks.onError&&e._callbacks.onError(e._context,r),r.fatal||(a.breakpointContinuation&&(g.b.i(\"loader\",\"breakpointContinuation\"),e._stats.output&&e._stats.loaded>0?(e._rangeStart?e._context.rangeStart=e._rangeStart+e._stats.output:e._context.rangeStart=e._stats.output,e._context.breakpointContinuation=!0):(e._context.rangeStart=e._rangeStart,e._context.breakpointContinuation=!1)),r.retry++,e._callbacks&&(e._retryDelay?(e._retryTimeout=setTimeout(e._loadInternal,e._retryDelay),e._retryDelay=2*e._retryDelay):e._loadInternal())))},this._onTimeout=function(){e._loading=!1,e._abortInternal();var t=new Error(\"timeout\");e._onError(t)},D++,this._loader=null,this._config={useFetch:!1,connectionTimeout:0,transmissionTimeout:0,maxRetry:0,retryDelay:0},this._loaderCallback={onConnect:this._onConnect,onProgress:this._onProgress,onEnd:this._onEnd.bind(this),onError:this._onError}}return e._getInternalLoader=function(e,t){if(\"string\"!=typeof e.url)return y;if(!e.progress)return A;if(void 0!==x)return x;if(x=null,E.a.msie||E.a.msedge){if(t.useFetch)return L.isSupported()&&(x=L),x;A.isSupportChunk()?x=A:L.isSupported()&&(x=L)}else L.isSupported()?x=L:A.isSupportChunk()&&(x=A);return x},e.load=function(e,t,i){this._init(e,t,i),this._loadInternal()},e.destroy=function(){this._stopTimer(),this._abortInternal(),this._destroyLoader(),this._callbacks=null},e.abort=function(){this._stopTimer(),this._abortInternal()},e._init=function(e,t,i){this._context=e,this._rangeStart=e.rangeStart,this._callbacks=t,this._config=i||this._config,this._stats={id:\"\",trequest:performance.now(),retry:0,loaded:0,code:0,output:0,tfirst:0,tload:0,total:0,tsload:0,tstart:0,fatal:!1,text:\"\"},this._config.retryDelay&&(this._retryDelay=this._config.retryDelay)},e._destroyLoader=function(){this._loader&&(this._loader.destroy(),this._loader=null)},e._abortInternal=function(){this._callbacks&&this._callbacks.onAbort&&!this._aborted&&this._loading&&this._callbacks.onAbort(this._context,this._stats),this._aborted=!0,this._loader&&this._loader.abort()},e._stopTimer=function(){this._requestTimeout&&(clearTimeout(this._requestTimeout),this._requestTimeout=null),this._retryTimeout&&(clearTimeout(this._retryTimeout),this._retryTimeout=null),this._stopTransmissionTimer()},e._callProgress=function(e,t,i){this._stats.output+=t.byteLength,this._callbacks&&this._callbacks.onProgress&&this._callbacks.onProgress(e,t,i)},e._onEnd=function(e,t){this._stopTimer();var i=this._stats;this._getContentLen(e,i),i.total=t?i.loaded=\"string\"==typeof t?t.length||0:t.byteLength||0:i.loaded,i.tload=Math.max(i.tfirst,performance.now()),this._loading=!1,i.output=0,this._callbacks&&this._callbacks.onEnd(e,t,i)},e._startTransmissionTimer=function(){var e=this;this._stopTransmissionTimer(),this._progressTime=performance.now();var t=this._config.transmissionTimeout||0;t&&(this._transTimer=setInterval((function(){performance.now()-e._progressTime>t&&e._onTimeout()}),1e3))},e._stopTransmissionTimer=function(){this._transTimer&&(clearInterval(this._transTimer),this._transTimer=null)},e._httpRange=function(e){if(e.rangeEnd||e.rangeStart)if(e.rangeType&&e.rangeType!==v.d.STANDARD&&\"string\"==typeof e.url){var t=new m.a(e.url,!0);e.rangeEnd?(t.query.start=(e.rangeStart||0).toString(),t.query.end=(e.rangeEnd-1).toString()):e.rangeStart&&(t.query.start=e.rangeStart.toString()),e.url=t.toString()}else e.rangeEnd?e.range=\"bytes=\"+(e.rangeStart||0)+\"-\"+(e.rangeEnd-1):e.rangeStart&&(e.range=\"bytes=\"+e.rangeStart+\"-\")},e._getContentLen=function(e,t){t.contentLength||(t.contentLength=this._getContentLenFromHeader(e))},e._getContentLenFromHeader=function(e){var t=0,i=e.responseHeader;if(i)if(e.range||\"number\"==typeof e.rangeStart){var r=i[\"content-range\"];r&&(t=parseInt((Array.isArray(r)?r[0]:r).split(\"/\")[1])||0)}else{var a=i[\"content-length\"];a&&(t=parseInt(Array.isArray(a)?a[0]:a)||0)}return t},s()(t,[{key:\"context\",get:function(){return this._context}},{key:\"config\",get:function(){return this._config}}]),t}(),I=function(){function e(){this.timeout=6048e5}var t=e.prototype;return t.write=function(t,i){if(e.available)try{localStorage.setItem(t,JSON.stringify({value:i,time:Date.now()}))}catch(e){}},t.read=function(t,i){if(void 0===i&&(i=!0),e.available)try{var r=localStorage.getItem(t);if(r){var a=JSON.parse(r),n=a.value,s=a.time,o=void 0===s?0:s;if(!i)return n;if(Date.now()-o=2):t!==v.b.hevc&&t!==v.b.kvc3&&t!==v.b.kvc4||((i=t===v.b.hevc&&e.isMSECodecSupported(v.b.hevc)?v.c.buildIn:v.c.unsupported)===v.c.unsupported&&\"undefined\"!=typeof WebAssembly?(i=WebAssembly?v.c.wasm:v.c.unsupported,r=e.wasmSmooth):(E.a.msedge&&(i=v.c.unsupported),r=navigator.hardwareConcurrency>=2||E.a.safari));var a=!1;return i===v.c.buildIn&&(a=e.isChangeTypeSupported()),{decoder:i,smooth:i!==v.c.unsupported&&r,mix:a}},e._threads=function(){try{return\"undefined\"!=typeof WebAssembly&&\"undefined\"!=typeof MessageChannel&&(new MessageChannel).port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11]))}catch(e){return!1}},e._simd=function(){return\"undefined\"!=typeof WebAssembly&&WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]))},s()(e,null,[{key:\"isSupportSimd\",get:function(){return void 0===e._isSupportSimd&&(e._isSupportSimd=e._simd()),e._isSupportSimd}},{key:\"isSupportThreads\",get:function(){return void 0===e._isSupportThreads&&(e._isSupportThreads=e._threads()),e._isSupportThreads}},{key:\"wasmSmooth\",get:function(){return void 0===e._wasmSmooth&&(e._wasmSmooth=!!(e.isSupportHW&&e.isSupportThreads&&navigator.hardwareConcurrency&&navigator.hardwareConcurrency>=6)),e._wasmSmooth}},{key:\"isSupportHW\",get:function(){if(void 0===e._isSupportHW){e._isSupportHW=!1;try{var t=document.createElement(\"canvas\"),i={preferLowPowerToHighPerformance:!0,failIfMajorPerformanceCaveat:!0,preserveDrawingBuffer:!0};e._isSupportHW=!(\"undefined\"==typeof WebGLRenderingContext||!t.getContext(\"webgl\",i)&&!t.getContext(\"experimental-webgl\",i))}catch(e){}}return e._isSupportHW}}]),e}();j._changeTypeSupported=void 0,j.MSE_AVAILABLE=void 0,j.MSE_API_AVAILABLE=void 0,j._isSupportSimd=void 0,j._isSupportThreads=void 0,j._wasmSmooth=void 0,j._isSupportHW=void 0,j.TYPE_SUPPORTED={mpeg:j.isMSECodecStrSupported(\"audio/mpeg\"),mp3:j.isMSECodecSupported(v.b.mp3),opus:j.isMSECodecSupported(v.b.opus),hevc:j.isMSECodecSupported(v.b.hevc),av1:j.isMSECodecSupported(v.b.av1)};var K,G=j,z=[16,24,32],Y=function(){function e(){this._waitingRec=[],this._frameBufLenIdx=0}return e.prototype.onWaiting=function(){this._waitingRec.push(performance.now()),this._waitingRec.length>3&&this._waitingRec.shift(),this._frameBufLenIdx>=z.length-1||this._waitingRec.length>=3&&this._waitingRec[this._waitingRec.length-1]-this._waitingRec[0]<15e3&&this._frameBufLenIdx++},s()(e,[{key:\"maxFrameBufLen\",get:function(){return z[this._frameBufLenIdx]||z[z.length-1]}}]),e}(),q=i(33),X=[4,2],Q=[8,6,4,2];!function(e){e[e.data=0]=\"data\",e[e.end=1]=\"end\"}(K||(K={}));var $=function(e){function t(t){var i;(i=e.call(this)||this)._ctx=void 0,i._active=!1,i._initCache=[],i._decInline=void 0,i._decW=void 0,i._renderer=void 0,i._rendererW=void 0,i._ready=!1,i._canvas=void 0,i._audioSegmentCnt=0,i._mediaInfo=[],i._eventEmitter=void 0,i._decAppendActive=!0,i._frameBufLen=0,i._libCacheHit=!1,i._activeTimes=[],i._state={streamTime:0,width:0,height:0,stoped:!1,output:v.p.canvas,decAppendActive:!0,frameBufLen:0,maxFrameBufLen:0},i._waiting=!0,i._pausedOnWaiting=void 0,i._simdEnabled=void 0,i._threadsEnabled=void 0,i._codecType=v.b.hevc,i._decoderType=v.q.kw265,i._decId=1,i._lastDecoder=void 0,i._bufRules=new Y,i._seeking=!1,i._nextSeek=-1,i._libLoader=void 0,i._vpp=void 0,i._onDecLibLoaded=function(e){g.b.i(\"v-dec-proxy\",\"dec lib loaded\"),i.emit(l.a.DEC_LIB_LOADED,e),i._libCacheHit=e.hitCache,i._initDecoder(e.lib)},i._loop=function(){i._active&&i._canvas&&(i._updateState(),requestAnimationFrame(i._loop))},i._onWorkMessage=function(e){var t=e.data;i._onMessage(e.data.event,t.data)},i._onMessage=function(e,t){var r,a;switch(e){case l.a.DECODER_IMG:i._ctx.updateVideoPlaybackQuality(t.decoded,t.droped),t.decId===i._decId&&i._appendFrame(t.frame);break;case l.a.RENDERER_DRAW:i._frameBufLen=t.yuvBufLen;break;case l.a.STEP:g.b.i(\"v-dec-proxy\",\"decoder step event\",t),i.emit(l.a.STEP,t);break;case l.a.DECODER_SEEK:g.b.i(\"v-dec-proxy\",\"decoder seek event\",t),t.hitCache&&(i._waiting=!1),t.hitCache||(i._reset(!0),i._updateState()),i._onSeeked(t);break;case l.a.DECODER_SEEK_ABORT:g.b.i(\"v-dec-proxy\",\"decoder seek abort event\",t),i._onSeekAbort();break;case l.a.RENDERER_SEEK:g.b.i(\"v-dec-proxy\",\"renderer seek event\",t),t.hitCache?(i._waiting=!1,i._onSeeked(t)):(i._onMessage(l.a.DECODER_WAITING,void 0),i._seekInDecoder(t.time));break;case l.a.DEC_VIDEO_READY:i._waiting=!1,i.emit(l.a.DEC_VIDEO_READY),i._pausedOnWaiting=void 0;break;case l.a.RENDERER_BUF_EXPIRED:g.b.i(\"v-dec-proxy\",\"renderer buf expired\",t),i._flushRenderer(0);break;case l.a.DECODER_WAITING:if(null!=(r=i._ctx.video)&&r.ended)return;i._bufRules.onWaiting(),i._waiting=!0,void 0===i._pausedOnWaiting&&(i._pausedOnWaiting=!(null==(a=i._ctx.video)||!a.paused)),i.emit(l.a.DECODER_WAITING,t);break;case l.a.RENDERER_BUF_UPDATE:i._decAppendActive=!!t.needMore,i._frameBufLen=t.yuvBufLen;break;case l.a.DEC_INIT_COMPLETE:for(i._ready=!0;i._initCache.length;){var n=i._initCache.shift();n&&(n.type===K.data?i._appendData(n.data):n.type===K.end&&i._endOfData())}i.emit(l.a.DEC_INIT_COMPLETE,t);break;case l.a.RENDERER_INIT_COMPLETE:i.emit(l.a.RENDERER_INIT_COMPLETE,t);break;case l.a.DECODER_DATA_END:i._decEndOfData();break;case l.a.DECODER_DROP_FRAME:i._decDropFrame(t);break;case l.a.ERROR:if(t.details===h.a.DECODER_INIT_ERROR&&(i._libCacheHit||i._threadsEnabled))return i._threadsEnabled&&(i._threadsEnabled=!1),void i._loadLib(!0);i.emit(l.a.ERROR,t)}},i._ctx=t,i._canvas=document.createElement(\"canvas\");var r=i._ctx.video;return r&&(i._canvas.width=r.clientWidth||80,i._canvas.height=r.clientHeight||60),i._libLoader=new M(i._ctx.config),i._libLoader.on(l.a.DEC_LIB_LOADED,i._onDecLibLoaded),i._libLoader.on(l.a.ERROR,(function(e){return i.emit(l.a.ERROR,e)})),i._state.maxFrameBufLen=i._bufRules.maxFrameBufLen,i._simdEnabled=G.isSupportSimd,i._threadsEnabled=!!(G.isSupportThreads&&i._ctx.config.maxVideoDecThreads>1),i}d()(t,e);var i=t.prototype;return i.init=function(e,t){var i=this;if(g.b.i(\"v-dec-proxy\",\"init codecType: \"+e+\" bitDepth: \"+t),this._decW=u()(39),E.a.chrome&&!this._ctx.config.mainThreadRendering&&(this._rendererW=u()(40)),g.b.i(\"v-dec-proxy\",\"init\",e,t),e&&(this._codecType=e),e===v.b.kvc3?this._decoderType=v.q.kvc3:e===v.b.kvc4?this._decoderType=v.q.kvc4:e===v.b.hevc&&(this._decoderType=v.q.kw265,t&&t>8&&(this._decoderType=v.q.h265)),this._canvas&&(this._rendererW&&this._rendererW.addEventListener(\"message\",this._onWorkMessage),this._decW&&this._decW.addEventListener(\"message\",this._onWorkMessage),!this._decW||!this._rendererW)){var r=this._eventEmitter=new o.EventEmitter;r.on(l.a.DEC_INIT_COMPLETE,(function(e){i._onMessage(l.a.DEC_INIT_COMPLETE,e)})),r.on(l.a.DECODER_IMG,(function(e){i._onMessage(l.a.DECODER_IMG,e)})),r.on(l.a.DEC_VIDEO_READY,(function(e){i._onMessage(l.a.DEC_VIDEO_READY,e)})),r.on(l.a.STEP,(function(e){i._onMessage(l.a.STEP,e)})),r.on(l.a.DECODER_SEEK,(function(e){i._onMessage(l.a.DECODER_SEEK,e)})),r.on(l.a.DECODER_SEEK_ABORT,(function(e){i._onMessage(l.a.DECODER_SEEK_ABORT,e)})),r.on(l.a.DECODER_WAITING,(function(e){i._onMessage(l.a.DECODER_WAITING,e)})),r.on(l.a.DECODER_DATA_END,(function(e){i._onMessage(l.a.DECODER_DATA_END,e)})),r.on(l.a.DECODER_DROP_FRAME,(function(e){i._onMessage(l.a.DECODER_DROP_FRAME,e)})),r.on(l.a.RENDERER_INIT_COMPLETE,(function(e){i._onMessage(l.a.RENDERER_INIT_COMPLETE,e)})),r.on(l.a.RENDERER_BUF_UPDATE,(function(e){i._onMessage(l.a.RENDERER_BUF_UPDATE,e)})),r.on(l.a.RENDERER_BUF_EXPIRED,(function(e){i._onMessage(l.a.RENDERER_BUF_EXPIRED,e)})),r.on(l.a.RENDERER_SEEK,(function(e){i._onMessage(l.a.RENDERER_SEEK,e)})),r.on(l.a.RENDERER_DRAW,(function(e){i._onMessage(l.a.RENDERER_DRAW,e)})),r.on(l.a.ERROR,(function(e){i._onMessage(l.a.ERROR,e)})),this._decW||(this._decInline=new V.a(this._eventEmitter)),this._rendererW||(this._renderer=new q.a(this._eventEmitter))}this._loadLib(),this._initRenderer()},i.setMediaInfo=function(e){g.b.i(\"v-dec-proxy\",\"setMediaInfo\"),this._mediaInfo.push(e),this._updateMediaInfo()},i.destroy=function(){this._initCache=[],this._canvas&&(this._canvas.remove(),this._canvas=void 0),this.stop(),this._decW?(this._decW.postMessage({cmd:F.a.DESTROY}),this._decW.removeEventListener(\"message\",this._onWorkMessage),this._decW.terminate()):this._decInline&&(this._decInline.destroy(),this._decInline=void 0),this._rendererW?(this._rendererW.postMessage({cmd:F.a.DESTROY}),this._rendererW.removeEventListener(\"message\",this._onWorkMessage),this._rendererW.terminate()):this._renderer&&(this._renderer.destroy(),this._renderer=void 0),this._eventEmitter&&(this._eventEmitter.removeAllListeners(),this._eventEmitter=void 0),this._libLoader.destroy(),this.removeAllListeners()},i.appendData=function(e){this._ready?this._appendData(e):this._initCache.push({type:K.data,data:e})},i.endOfData=function(){g.b.i(\"v-dec-proxy\",\"endOfData\"),this._ready?this._endOfData():this._initCache.push({type:K.end})},i.decoderChange=function(e,t){g.b.i(\"v-dec-proxy\",\"decoderChange type: \"+e+\" time: \"+t),this._lastDecoder=e;var i=this._activeTimes;e===v.c.wasm?(!i.length||i.length&&-1!==i[i.length-1].end)&&i.push({start:t,end:-1}):e===v.c.buildIn&&i.length&&-1===i[i.length-1].end&&(i[i.length-1].end=t)},i.onParsingData=function(e){var t=this;e.segments.forEach((function(e){e.type===v.k.AUDIO&&t._audioSegmentCnt++}))},i.start=function(){this._active||(g.b.i(\"v-dec-proxy\",\"start loop\"),this._active=!0,requestAnimationFrame(this._loop))},i.stop=function(){g.b.i(\"v-dec-proxy\",\"stop loop\"),this._active=!1},i.seek=function(e){g.b.i(\"v-dec-proxy\",\"seek: \"+e+\" \"+this._seeking),this._seeking?this._nextSeek=e:(this._seeking=!0,this._seekInRenderer(e),this.start())},i.seekWithLoad=function(e){g.b.i(\"v-dec-proxy\",\"seekWithLoad: \"+e),this._ready?(this._reset(!0),this._updateState()):this._initCache=[]},i.step=function(e){g.b.i(\"v-dec-proxy\",\"step: \"+e),this._rendererW?this._rendererW.postMessage({cmd:F.a.STEP,type:e}):this._renderer&&this._renderer.step(e)},i.bindVPP=function(e){g.b.i(\"v-dec-proxy\",\"bind vpp\"),this._vpp=e,this._renderer&&this._renderer.bindVPP(e)},i.unbindVPP=function(){this._vpp=void 0,this._renderer&&this._renderer.unbindVPP()},i.flush=function(e){void 0===e&&(e=0),g.b.i(\"v-dec-proxy\",\"flush\"),e?(this._flushDec(e),this._flushRenderer(e)):this._reset(!1)},i._seekInRenderer=function(e){this._rendererW?this._rendererW.postMessage({cmd:F.a.SEEK,time:e}):this._renderer&&this._renderer.seek(e)},i._seekInDecoder=function(e){this._decW?this._decW.postMessage({cmd:F.a.SEEK,time:e}):this._decInline&&this._decInline.seek(e)},i._updateState=function(){if(this._canvas){var e,t,i=this._ctx.currentTime,r=this._canvas.clientWidth*window.devicePixelRatio,a=this._canvas.clientHeight*window.devicePixelRatio,n=!(null==(e=this._ctx.video)||!e.ended),s=(null==(t=this._ctx.video)?void 0:t.playbackRate)||1,o=this.isCanvasRenderer?v.p.canvas:v.p.video,_=!1,d=!1,c=this._decAppendActive,u=this._state;if(u.output!==o&&(u.output=o,_=!0,this.emit(l.a.VIDEO_RENDERER_CHANGE,{type:u.output,canvas:this.canvas,enabled:!0})),0!==i||this._audioSegmentCnt||(i=-1),u.streamTime===i&&u.stoped===n&&u.decAppendActive===c&&u.frameBufLen===this._frameBufLen&&u.maxFrameBufLen===this._bufRules.maxFrameBufLen||(u.streamTime=i,u.stoped=n,u.decAppendActive=c,u.frameBufLen=this._frameBufLen,u.maxFrameBufLen=this._bufRules.maxFrameBufLen,_=!0),u.width===r&&u.height===a||(u.width=r,u.height=a,d=!0),!_&&!this._waiting&&!d)return;(_||this._waiting)&&(this._decW?this._decW.postMessage({cmd:F.a.UPDATE_STATE,streamTime:i,output:o,active:c,waiting:this._waiting,frameBufLen:this._frameBufLen,playbackRate:s,maxFrameBufLen:u.maxFrameBufLen}):this._decInline&&this._decInline.updateState(i,o,c,this._frameBufLen,s,u.maxFrameBufLen)),(_||d)&&(this._rendererW?this._rendererW.postMessage({cmd:F.a.UPDATE_STATE,streamTime:i,width:r,height:a,stoped:n,output:o,maxFrameBufLen:u.maxFrameBufLen}):this._renderer&&this._renderer.updateState(i,r,a,n,o,u.maxFrameBufLen))}},i._endOfData=function(){this._decW?this._decW.postMessage({cmd:F.a.END_OF_DATA}):this._decInline&&this._decInline.endOfData()},i._decEndOfData=function(){this._rendererW?this._rendererW.postMessage({cmd:F.a.END_OF_DATA}):this._renderer&&this._renderer.endOfData()},i._decDropFrame=function(e){this._rendererW?this._rendererW.postMessage({cmd:F.a.DEC_DROP_FRAME,data:e}):this._renderer&&this._renderer.decDropFrameInfo(e)},i._appendData=function(e){this._decW?this._decW.postMessage({cmd:F.a.APPEND_DATA,data:e}):this._decInline&&this._decInline.appendData(e)},i._updateMediaInfo=function(){if(this._mediaInfo.length&&(this._decW||this._decInline)&&(this._rendererW||this._renderer)){var e=this._mediaInfo.shift();this._decW?this._decW.postMessage({cmd:F.a.MEDIA_INFO,mediaInfo:e}):this._decInline&&this._decInline.updateMediaInfo(e),this._rendererW?this._rendererW.postMessage({cmd:F.a.MEDIA_INFO,mediaInfo:e}):this._renderer&&this._renderer.updateMediaInfo(e)}},i._reset=function(e){void 0===e&&(e=!1),this._decId++,this._decAppendActive=!0,this._audioSegmentCnt=0,this._activeTimes=[],e||(this._seeking=!1,this._nextSeek=-1),this._lastDecoder===v.c.wasm&&this._activeTimes.push({start:0,end:-1}),this._decW?this._decW.postMessage({cmd:F.a.RESET,decId:this._decId,seeking:e}):this._decInline&&this._decInline.reset(this._decId,e),this._resetRenderer(e),this._waiting=!0},i._resetRenderer=function(e){void 0===e&&(e=!1),this._frameBufLen=0,this._rendererW?this._rendererW.postMessage({cmd:F.a.RESET,decId:this._decId,seeking:e}):this._renderer&&this._renderer.reset(this._decId,e)},i._flushDec=function(e){this._decW?this._decW.postMessage({cmd:F.a.FLUSH,startTime:e}):this._decInline&&this._decInline.flush(e)},i._flushRenderer=function(e){this._rendererW?this._rendererW.postMessage({cmd:F.a.FLUSH,startTime:e}):this._renderer&&this._renderer.flush(e)},i._appendFrame=function(e){this._rendererW?this._rendererW.postMessage({cmd:F.a.APPEND_DATA,frame:e},[e.y.bytes.buffer,e.u.bytes.buffer,e.v.bytes.buffer]):this._renderer&&this._renderer.append(e)},i._loadLib=function(e){void 0===e&&(e=!1),void 0===this._simdEnabled||void 0===this._threadsEnabled?(this._simdEnabled=!!G.isSupportSimd,this._threadsEnabled=!!(G.isSupportThreads&&this._ctx.config.maxVideoDecThreads>1),this._libLoader.load(e,this._decoderType,this._simdEnabled,this._threadsEnabled)):this._libLoader.load(e,this._decoderType,this._simdEnabled,this._threadsEnabled)},i._initDecoder=function(e){g.b.i(\"v-dec-proxy\",\"init dec\"),this.start();var t=this._threadsEnabled?this._getThreadNum():1;this._decW?this._decW.postMessage({cmd:F.a.INIT_265,id:this._decId,lib:e,config:this._ctx.config,simd:this._simdEnabled,threads:t,codecType:this._codecType,decoderType:this._decoderType}):this._decInline&&this._decInline.init(this._decId,e,this._ctx.config,!!this._simdEnabled,t,this._codecType,this._decoderType),this._updateMediaInfo()},i._initRenderer=function(){if(g.b.i(\"v-dec-proxy\",\"init renderer\"),this._canvas){if(this._rendererW){var e=this._canvas.transferControlToOffscreen();this._rendererW.postMessage({cmd:F.a.INIT_RENDERER,id:this._decId,config:this._ctx.config,canvas:e},[e])}else this._renderer&&(this._renderer.init(this._decId,this._ctx.config,this._canvas),this._vpp&&this.bindVPP(this._vpp));this._updateMediaInfo()}else this.emit(l.a.ERROR,{type:h.b.DECODER_ERROR,details:h.a.DECODER_UNSUPPORTED,fatal:!0,reason:\"init error worker:\"+!!this._decW+\" canvas:\"+!!this._canvas+\" decoder:\"+!!this._decInline})},i._getThreadNum=function(){var e=Math.min(navigator.hardwareConcurrency,this._ctx.config.maxVideoDecThreads),t=Q;this._decoderType===v.q.kw265&&(t=X);for(var i=0;i=t[i])return t[i];return t[t.length-1]},i._onSeeked=function(e){if(g.b.i(\"v-dec-proxy\",\"seeked\"),this._seeking=!1,-1===this._nextSeek)this.emit(l.a.DECODER_SEEK,e);else{var t=this._nextSeek;this._nextSeek=-1,this.seek(t)}},i._onSeekAbort=function(){if(g.b.i(\"v-dec-proxy\",\"seek abort\"),this._seeking=!1,-1!==this._nextSeek){var e=this._nextSeek;this._nextSeek=-1,this.seek(e)}},s()(t,[{key:\"canvas\",get:function(){return this._canvas}},{key:\"waiting\",get:function(){return this._waiting}},{key:\"pausedOnWaiting\",get:function(){return this._pausedOnWaiting},set:function(e){this._pausedOnWaiting=e}},{key:\"isCanvasRenderer\",get:function(){var e=this._activeTimes.length;if(e)for(var t=this._ctx.currentTime,i=e-1;i>=0;i--)if(t>=this._activeTimes[i].start&&(te.lower&&e.rate>0}))).sort((function(e,t){return t.rate-e.rate})),i.length>1))return t.rule=i,void(e.autoPlaybackRateConf=t)}else{var r=-e.defaultSpts/1e3,a={startDelay:r,interval:.6,rule:[{rate:1.5,lower:r+7,upper:Number.MAX_SAFE_INTEGER},{rate:1.25,lower:r+4,upper:r+6},{rate:1.1,lower:r+1,upper:r+3},{rate:1,lower:0,upper:r}]};e.autoPlaybackRateConf=e.adaptive&&e.box===v.g.flv?a:ie}},e}();re._streamingSupported=void 0;var ae,ne=function(){function e(){this._traffic=0,this._streams=[],this._download=[],this._speed=0,this._trafficGroupedByVCodecType={},this._trafficGroupedByLevel={},this._currentLoad=void 0}var t=e.prototype;return t.onStreamOpen=function(e,t,i,r){if(this._streams.length>10){var a=this._streams.shift();if(a){this._trafficGroupedByVCodecType[a.vCodecType]=(this._trafficGroupedByVCodecType[a.vCodecType]||0)+a.traffic;var n=a.qualityType||a.bitrate;this._trafficGroupedByLevel[n]=(this._trafficGroupedByLevel[n]||0)+a.traffic}}var s=this._currentLoad?this._currentLoad.index+1:0;this._currentLoad={index:s,startPos:e,url:t,bitrate:i,qualityType:r,traffic:0,loadTimeCost:0,keyFrame:0,videoDataRate:0,audioDataRate:0,speed:0,vCodecType:v.b.unknown,segments:[]},this._streams.push(this._currentLoad)},t.onMediaInfo=function(e){var t=this._streams[this._streams.length-1];t&&(e.videoCodecType&&(t.vCodecType=e.videoCodecType),t.mediaInfo=a()({},e))},t.setRTCStats=function(e){var t=this._currentLoad;t&&(t.traffic=e.totalReceive,t.audioDataRate=e.audioDataRate,t.videoDataRate=e.videoDataRate,t.speed=e.speed,t.keyFrame=e.key,this._traffic=t.traffic,this._speed=e.speed)},t.onDataReceive=function(e){this._traffic+=e.byteLength;var t=this._download;t.length>200&&t.pop(),t.unshift(e);var i=this._currentLoad;i&&(i.traffic+=e.byteLength,i.loadTimeCost+=e.timeCost,i.speed=Math.round(i.traffic/i.loadTimeCost*1e3)||0)},t.onMediaSegment=function(e){this._calculateDataRate(e.type,1e3*(e.endDTS-e.startDTS),e.payload.byteLength)},t.onRaw=function(e){if(e.samples.length){var t=e.samples.reduce((function(e,t){return e+t.units.reduce((function(e,t){return e+t.data.byteLength}),0)}),0),i=e.samples[e.samples.length-1].dts-e.samples[0].dts+(e.samples[e.samples.length-1].duration||0);this._calculateDataRate(v.k.VIDEO,i/90,t)}},t.downloadSpeedByRange=function(e){if(void 0===e&&(e=1e3),this._download.length){for(var t=performance.now(),i=0,r=0,a=0;at-e;a++)i+=this._download[a].byteLength,r+=this._download[a].timeCost;this._speed=Math.round(i/r*1e3)||0}return this._speed},t._calculateDataRate=function(e,t,i){var r=this._streams[this._streams.length-1],a=r.segments;a.push({type:e,duration:t,byteLength:i}),a.length>200&&a.shift();for(var n=0,s=0,o=0;o0&&(e===v.k.VIDEO?r.videoDataRate=Math.round(8*s/n):e===v.k.AUDIO&&(r.audioDataRate=Math.round(8*s/n)))},s()(e,[{key:\"smoothedDownloadSpeed\",get:function(){if(this._download.length<1)return 0;var e=this._download[0].byteLength/this._download[0].timeCost*1e3,t=this._download.slice(1).reduce((function(e,t){return e+t.byteLength/t.timeCost*1e3}),0)/(this._download.length-1)||0;return t>0?e*(1-.9)+.9*t:e}},{key:\"trafficGroupedByVCodecType\",get:function(){var e=a()({},this._trafficGroupedByVCodecType);return e.total=this._traffic,this._streams.forEach((function(t){e[t.vCodecType]=(e[t.vCodecType]||0)+t.traffic})),e}},{key:\"trafficGroupedByLevel\",get:function(){var e=a()({},this._trafficGroupedByLevel);return e.total=this._traffic,this._streams.forEach((function(t){var i=t.qualityType||t.bitrate;e[i]=(e[i]||0)+t.traffic})),e}},{key:\"traffic\",get:function(){return this._traffic}},{key:\"speed\",get:function(){return this._speed}},{key:\"currentLoad\",get:function(){return this._currentLoad}},{key:\"streams\",get:function(){return this._streams}}]),e}(),se=i(10),oe=function(){function e(e){this._ctx=void 0,this._lazyLoadDuration=30,this._playbackRate=1,this._ctx=e,g.b.i(\"auto-lazyload\",e.stat.autoLazyLoad,e.stat.lazyLoadMaxDuration,e.stat.lazyLoadRecoverDuration)}var t=e.prototype;return t.onLevel=function(){this._updateLazyloadConf(30)},t.update=function(){var e=this._ctx.lctx.current;!this._ctx.stat.isLive&&this._ctx.stat.autoLazyLoad&&e&&(e.maxBitrate||e.bitrate)&&this._checkLazyLoadConf(e,8*this._ctx.loadRec.smoothedDownloadSpeed/1e3)},t.onRateChange=function(){this._updateLazyloadConf(this._lazyLoadDuration)},t._checkLazyLoadConf=function(e,t){var i=0;if(e.maxBitrate)i=t/e.maxBitrate;else{if(!e.bitrate)return;i=t/(1.5*e.bitrate)}i>10?this._updateLazyloadConf(this._ctx.stat.lazyLoadMaxDuration-2):i<5&&this._updateLazyloadConf(30)},t._updateLazyloadConf=function(e){e>30&&(e=30),e<14&&(e=14);var t=Math.max(1,this._ctx.playbackRate);this._lazyLoadDuration===e&&this._playbackRate===t||(this._lazyLoadDuration=e,this._playbackRate=t,this._ctx.stat.lazyLoadMaxDuration=Math.min(45,e*t),this._ctx.stat.lazyLoadRecoverDuration=.8*this._ctx.stat.lazyLoadMaxDuration,g.b.i(\"auto-lazyload\",\"lazyload conf update\",this._ctx.stat.lazyLoadMaxDuration,this._ctx.stat.lazyLoadRecoverDuration))},e}(),_e=function(){function e(e){this._abr=!1,this._startIdx=0,this._currentIdx=0,this._nextIdx=0,this._levels=[],this._audioIdx=0,this._audioTracks=[],this._subtitleIdx=0,this._subtitleTracks=[],this._abrLevels=[],this._default=void 0,this._availableList=void 0,this._startIdx=e?-1:0,this._abr=e}var t=e.prototype;return t.getLevel=function(e){return void 0===e&&(e=v.e.MAIN),e===v.e.MAIN?this._levels[this._currentIdx]:e===v.e.AUDIO?this._audioTracks[this._audioIdx]:e===v.e.SUBTITLE?this._subtitleTracks[this._subtitleIdx]:void 0},t.setLevelIdx=function(e,t){void 0===t&&(t=v.e.MAIN),t===v.e.MAIN?this.currentIdx=e:t===v.e.AUDIO?this.audioIdx=e:t===v.e.SUBTITLE&&(this.subtitleIdx=e)},t.getLevelIdx=function(e){return void 0===e&&(e=v.e.MAIN),e===v.e.MAIN?this._currentIdx:e===v.e.AUDIO?this._audioIdx:e===v.e.SUBTITLE?this._subtitleIdx:-1},t.setNextIdx=function(e,t){void 0===t&&(t=v.e.MAIN),t===v.e.MAIN&&(this.nextIdx=e)},t.getNextIdx=function(e){return void 0===e&&(e=v.e.MAIN),e===v.e.MAIN?this._nextIdx:-1},t.abrIndexToOrign=function(e){var t=this._abrLevels[e];return t?t.index:0},t.orignIndexToAbr=function(e){var t=0;return this._abrLevels.forEach((function(i,r){i.index!==e||(t=r)})),t},t._generateAbrList=function(){var e=this,t=this._availableList;this._default=0,this._abrLevels=[],this._levels.forEach((function(i,r){i.default&&!t&&(e._default=r),i.enableAdaptive&&(!t||t&&-1!==t.indexOf(r))&&e._abrLevels.push(i)})),this._abrLevels.sort((function(e,t){return e.bitrate-t.bitrate}))},s()(e,[{key:\"abr\",get:function(){return this._abr},set:function(e){this._abr=e}},{key:\"startIdx\",get:function(){return this._startIdx},set:function(e){this._startIdx=e}},{key:\"currentIdx\",get:function(){return this._currentIdx},set:function(e){e>=0&&(this._currentIdx=e)}},{key:\"nextIdx\",get:function(){return this._nextIdx},set:function(e){e>=0&&(this._nextIdx=e)}},{key:\"levels\",get:function(){return this._levels},set:function(e){this._levels=e,this._generateAbrList()}},{key:\"current\",get:function(){return this._levels[this._currentIdx]}},{key:\"audioIdx\",get:function(){return this._audioIdx},set:function(e){e>=0&&(this._audioIdx=e)}},{key:\"audioTracks\",get:function(){return this._audioTracks},set:function(e){this._audioTracks=e}},{key:\"audio\",get:function(){return this._audioTracks[this._audioIdx]}},{key:\"subtitleIdx\",get:function(){return this._subtitleIdx},set:function(e){e>=0&&(this._subtitleIdx=e)}},{key:\"subtitleTracks\",get:function(){return this._subtitleTracks},set:function(e){this._subtitleTracks=e}},{key:\"subtitle\",get:function(){return this._subtitleTracks[this._subtitleIdx]}},{key:\"abrLevels\",get:function(){return this._abrLevels}},{key:\"availableList\",set:function(e){this._availableList=e,this._generateAbrList()}},{key:\"default\",get:function(){return this._default||0},set:function(e){this._default=e}},{key:\"abrDefault\",get:function(){var e=0;return this._abrLevels.forEach((function(t,i){t.default&&(e=i)})),e}}]),e}(),de=function(){function e(e){this.url=[],this.urlId=0,this.bitrate=0,this.maxBitrate=0,this.qualityType=\"\",this.qualityLabel=\"\",this.id=0,this.codec=\"\",this.audioCodec=\"\",this.videoCodec=\"\",this.hidden=!1,this.enableAdaptive=!0,this.default=!1,this.width=void 0,this.height=void 0,this.index=0,this.drmSchemaId=\"\",this.drmToken=\"\",this.comment=\"\",this.url=[e],this.urlId=0}return e.prototype.getKLevel=function(){return{width:this.width,height:this.height,qualityLabel:this.qualityLabel,qualityType:this.qualityType,bitrate:this.bitrate,maxBitrate:this.maxBitrate}},s()(e,[{key:\"currentUrl\",get:function(){return this.url[this.urlId]||\"\"}}]),e}(),ce=function(){function e(){}return e.verify=function(e){return!!(e&&e.hasOwnProperty(\"version\")&&e.hasOwnProperty(\"adaptationSet\")&&e.adaptationSet.hasOwnProperty(\"representation\")&&Array.isArray(e.adaptationSet.representation)&&e.adaptationSet.representation.length>0)&&e.adaptationSet.representation.reduce((function(e,t){return!!(e&&t.url&&t.bitrate&&t.qualityType)}),!0)},e.parse=function(t){var i,r=[];return e.verify(t)&&t.adaptationSet.representation.forEach((function(e,t){var a=new de(e.url);a.id=e.id||t,a.maxBitrate=e.bitrate||0,a.bitrate=e.averageBitrate||a.maxBitrate,a.qualityType=e.qualityType||\"\",a.qualityLabel=e.name||\"\",a.codec=e.codec||\"\",a.hidden=e.hidden||!1,a.enableAdaptive=void 0===e.enableAdaptive||!!e.enableAdaptive,a.default=e.defaultSelect||!1,a.index=t,r.push(a),a.default&&void 0===i&&(i=t)})),{levels:r,def:i||0,srcType:v.i.KWAI_FLV_ABR}},e}(),ue=i(8),he=i(24),le=function(){function e(e,t){this._uri=null,this.baseuri=void 0,this.reluri=void 0,this.method=null,this.key=null,this.iv=void 0,this.baseuri=e,this.reluri=t}return s()(e,[{key:\"uri\",get:function(){return!this._uri&&this.reluri&&(this._uri=Object(he.buildAbsoluteURL)(this.baseuri,this.reluri,{alwaysNormalize:!0})),this._uri}}]),e}();!function(e){e.AUDIO=\"audio\",e.VIDEO=\"video\"}(ae||(ae={}));var fe=function(){function e(){var e;this._url=\"\",this._byteRange=null,this._decryptdata=null,this._elementaryStreams=((e={})[ae.AUDIO]=!1,e[ae.VIDEO]=!1,e),this.rawProgramDateTime=null,this.programDateTime=null,this.tagList=[],this.relurl=void 0,this.baseurl=void 0,this.duration=void 0,this.sn=0,this.levelkey=void 0,this.level=0,this.start=0,this.cc=0,this.maxStartPTS=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.deltaPTS=void 0,this.dropped=void 0,this.backtracked=void 0,this.type=void 0,this.loader=void 0,this.title=null,this.urlId=void 0,this.data=void 0}var t=e.prototype;return t.setByteRange=function(e,t){var i=e.split(\"@\",2),r=[];1===i.length?r[0]=t?t.byteRangeEndOffset:0:r[0]=parseInt(i[1],10),r[1]=parseInt(i[0],10)+r[0],this._byteRange=r},t.addElementaryStream=function(e){this._elementaryStreams[e]=!0},t.hasElementaryStream=function(e){return!0===this._elementaryStreams[e]},t.createInitializationVector=function(e){for(var t=new Uint8Array(16),i=12;i<16;i++)t[i]=e>>8*(15-i)&255;return t},t.setDecryptDataFromLevelKey=function(e,t){var i=e;return e&&e.method&&e.uri&&!e.iv&&((i=new le(e.baseuri,e.reluri)).method=e.method,i.iv=this.createInitializationVector(t)),i},s()(e,[{key:\"url\",get:function(){return!this._url&&this.relurl&&(this._url=Object(he.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url},set:function(e){this._url=e}},{key:\"byteRange\",get:function(){return this._byteRange?this._byteRange:[]}},{key:\"byteRangeStartOffset\",get:function(){return this.byteRange[0]}},{key:\"byteRangeEndOffset\",get:function(){return this.byteRange[1]}},{key:\"decryptdata\",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var e=this.sn;\"number\"!=typeof e&&(e=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,e)}return this._decryptdata}},{key:\"endProgramDateTime\",get:function(){if(null===this.programDateTime)return null;if(!Object(ue.a)(this.programDateTime))return null;var e=Object(ue.a)(this.duration)?this.duration:0;return this.programDateTime+1e3*e}},{key:\"encrypted\",get:function(){return!(!this.decryptdata||null===this.decryptdata.uri||null!==this.decryptdata.key)}}]),e}(),pe=function(e){function t(t){var i;return(i=e.call(this,t)||this).startSN=0,i.endSN=0,i.fragments=[],i.initSegment=null,i.live=!0,i.needSidxRanges=!1,i.startTimeOffset=null,i.targetduration=0,i.totalduration=0,i.type=null,i.version=null,i.details=null,i.PTSKnown=!1,i.m3u8Slice=void 0,i.audioGroupIds=void 0,i.attrs=void 0,i.averagetargetduration=void 0,i.name=void 0,i.lang=void 0,i.groupId=\"\",i.instreamId=\"\",i.autoselect=void 0,i.forced=void 0,i}return d()(t,e),s()(t,[{key:\"hasProgramDateTime\",get:function(){return!(!this.fragments[0]||\"number\"!=typeof this.fragments[0].programDateTime||!Object(ue.a)(this.fragments[0].programDateTime))}}]),t}(de),me=function(){function e(){}return e.verify=function(e){return!!(e&&e.hasOwnProperty(\"segments\")&&Array.isArray(e.segments)&&e.segments.length>0)&&(e.segments.forEach((function(e){if(!e.url||!e.duration||!e.time)return!1})),!0)},e.parse=function(t,i){void 0===i&&(i=\"\");var r=[],a={levels:r,withCredentials:!1,hasVideo:!0,hasAudio:!0};if(e.verify(t)){var n=new pe(\"\");r.push(n);var s=new pe(\"\"),o=t;a.withCredentials=!!o.withCredentials,void 0!==o.hasAudio&&(a.hasAudio=!!o.hasAudio),void 0!==o.hasVideo&&(a.hasVideo=!!o.hasVideo);var _=0,d=0,c=0;o.segments.forEach((function(e,t){var r=new fe;r.sn=t,\"string\"==typeof e.startUtcTime?r.programDateTime=parseInt(e.startUtcTime):\"number\"==typeof e.startUtcTime&&(r.programDateTime=e.startUtcTime),\"string\"==typeof e.duration?r.duration=(parseFloat(e.duration)||0)/1e3:r.duration=(e.duration||0)/1e3,r.start=_,r.baseurl=i,r.relurl=e.url,_+=r.duration,t>0&&c!==e.periodId&&(r.tagList.push([\"DIS\"]),d++),r.cc=d,c=e.periodId,s.fragments.push(r)})),s.live=!1,s.type=v.e.MAIN,s.startSN=0,s.endSN=s.fragments.length-1,s.totalduration=_,n.details=s}return a},e}(),ve=/^(\\d+)x(\\d+)$/,Ee=/\\s*(.+?)\\s*=((?:\\\".*?\\\")|.*?)(?:,|$)/g,ge=function(){function e(t){for(var i in\"string\"==typeof t&&(t=e.parseAttrList(t)),t)t.hasOwnProperty(i)&&(this[i]=t[i])}var t=e.prototype;return t.decimalInteger=function(e){var t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t},t.hexadecimalInteger=function(e){if(this[e]){var t=(this[e]||\"0x\").slice(2);t=(1&t.length?\"0\":\"\")+t;for(var i=new Uint8Array(t.length/2),r=0;rNumber.MAX_SAFE_INTEGER?1/0:t},t.decimalFloatingPoint=function(e){return parseFloat(this[e])},t.optionalFloat=function(e,t){var i=this[e];return i?parseFloat(i):t},t.enumeratedString=function(e){return this[e]},t.bool=function(e){return\"YES\"===this[e]},t.decimalResolution=function(e){var t=ve.exec(this[e]);if(null!==t)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}},e.parseAttrList=function(e){var t,i={};for(Ee.lastIndex=0;null!==(t=Ee.exec(e));){var r=t[2];0===r.indexOf('\"')&&r.lastIndexOf('\"')===r.length-1&&(r=r.slice(1,-1)),i[t[1]]=r}return i},e}(),ye={audio:{a3ds:!0,\"ac-3\":!0,\"ac-4\":!0,alac:!0,alaw:!0,dra1:!0,\"dts+\":!0,\"dts-\":!0,dtsc:!0,dtse:!0,dtsh:!0,\"ec-3\":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,\"raw \":!0,Opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,drac:!0,dvav:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,\"vc-1\":!0,vp08:!0,vp09:!0}},be=/#EXT-X-STREAM-INF:([^\\n\\r]*)[\\r\\n]+([^\\r\\n]+)/g,Se=/#EXT-X-MEDIA:(.*)/g,Te=new RegExp([/#EXTINF:\\s*(\\d*(?:\\.\\d+)?)(?:,(.*)\\s+)?/.source,/|(?!#)([\\S+ ?]+)/.source,/|#EXT-X-BYTERANGE:*(.+)/.source,/|#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/|#.*/.source].join(\"\"),\"g\"),Re=/(?:(?:#(EXTM3U))|(?:#EXT-X-(PLAYLIST-TYPE):(.+))|(?:#EXT-X-(MEDIA-SEQUENCE): *(\\d+))|(?:#EXT-X-(TARGETDURATION): *(\\d+))|(?:#EXT-X-(KEY):(.+))|(?:#EXT-X-(START):(.+))|(?:#EXT-X-(ENDLIST))|(?:#EXT-X-(DISCONTINUITY-SEQ)UENCE:(\\d+))|(?:#EXT-X-(DIS)CONTINUITY))|(?:#EXT-X-(VERSION):(\\d+))|(?:#EXT-X-(MAP):(.+))|(?:(#)([^:]*):(.*))|(?:(#)(.*))(?:.*)\\r?\\n?/,Le=/\\.(mp4|m4s|m4v|m4a)$/i;function xe(e,t){e.rawProgramDateTime?e.programDateTime=Date.parse(e.rawProgramDateTime):t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime),\"number\"==typeof e.programDateTime&&Object(ue.a)(e.programDateTime)||(e.programDateTime=null,e.rawProgramDateTime=null)}var Ae,De,Ce=function(){function e(){}return e.findGroup=function(e,t){for(var i=0;i2?(t=i.shift()+\".\",t+=parseInt(i.shift(),10).toString(16),t+=(\"000\"+parseInt(i.shift(),10).toString(16)).substr(-4)):t=e,t},e.resolve=function(e,t){return Object(he.buildAbsoluteURL)(t,e,{alwaysNormalize:!0})},e.setCodecs=function(e,t){[\"video\",\"audio\"].forEach((function(i){var r=e.filter((function(e){return function(e,t){var i=ye[t];return!!i&&!0===i[e.slice(0,4)]}(e,i)}));if(r.length){var a=r.filter((function(e){return 0===e.lastIndexOf(\"avc1\",0)||0===e.lastIndexOf(\"mp4a\",0)}));t[i+\"Codec\"]=a.length>0?a[0]:r[0],e=e.filter((function(e){return-1===r.indexOf(e)}))}})),t.codec=e.join(\",\")},e.parseMasterPlaylist=function(t,i){var r,a=[];for(be.lastIndex=0;null!==(r=be.exec(t));){var n=new pe(e.resolve(r[2],i)),s=n.attrs=new ge(r[1]),o=s.decimalResolution(\"RESOLUTION\");o&&(n.width=o.width,n.height=o.height),n.maxBitrate=s.decimalInteger(\"BANDWIDTH\")/1e3;var _=s.decimalInteger(\"AVERAGE-BANDWIDTH\")/1e3;n.bitrate=_||n.maxBitrate,n.name=s.NAME,e.setCodecs([].concat((s.CODECS||\"\").split(/[ ,]+/)),n),n.videoCodec&&-1!==n.videoCodec.indexOf(\"avc1\")&&(n.videoCodec=e.convertAVC1ToAVCOTI(n.videoCodec)),a.push(n)}return a},e.parseMasterPlaylistMedia=function(t,i,r,a){var n;void 0===a&&(a=[]);var s=[],o=0;for(Se.lastIndex=0;null!==(n=Se.exec(t));){var _=new ge(n[1]);if(_.TYPE===r){var d=new pe(_.URI?e.resolve(_.URI,i):\"\");if(d.attrs=_,d.index=d.id=o++,d.groupId=_[\"GROUP-ID\"]||\"\",d.instreamId=_[\"INSTREAM-ID\"]||\"\",d.name=_.NAME||_.LANGUAGE,d.type=r,d.default=\"YES\"===_.DEFAULT,d.autoselect=\"YES\"===_.AUTOSELECT,d.forced=\"YES\"===_.FORCED,d.lang=_.LANGUAGE||\"\",a.length){var c=e.findGroup(a,d.groupId);d.audioCodec=c?c.codec:a[0].codec}s.push(d)}}return s},e.parseLevelPlaylist=function(e,t,i,r,a){void 0===r&&(r=v.e.MAIN),void 0===a&&(a=0);var n,s,o,_=0,d=0,c=0,u=null,h=new fe,l=null,f=new pe(t);for(Te.lastIndex=0;null!==(s=Te.exec(e));){var p=s[1];if(p){h.duration=parseFloat(p);var m=(\" \"+s[2]).slice(1);h.title=m||null,h.tagList.push(m?[\"INF\",p,m]:[\"INF\",p])}else if(s[3]){if(Object(ue.a)(h.duration)){var E=_++;h.type=r,h.start=d,h.levelkey=n,h.sn=E,h.level=i,h.cc=c,h.urlId=a,h.baseurl=t,h.relurl=(\" \"+s[3]).slice(1),xe(h,u),f.fragments.push(h),u=h,d+=h.duration,h=new fe}}else if(s[4]){var y=(\" \"+s[4]).slice(1);u?h.setByteRange(y,u):h.setByteRange(y)}else if(s[5])h.rawProgramDateTime=(\" \"+s[5]).slice(1),h.tagList.push([\"PROGRAM-DATE-TIME\",h.rawProgramDateTime]),null===l&&(l=f.fragments.length);else{if(!(s=s[0].match(Re))||s.length<=0)break;for(o=1;o=0&&(n.method=R,n.key=null,x&&(n.iv=x)));break;case\"START\":var A=new ge(b).decimalFloatingPoint(\"TIME-OFFSET\");Object(ue.a)(A)&&(f.startTimeOffset=A);break;case\"MAP\":var D=new ge(b);h.relurl=D.URI,D.BYTERANGE&&h.setByteRange(D.BYTERANGE),h.baseurl=t,h.level=i,h.type=r,h.sn=\"initSegment\",f.initSegment=h,(h=new fe).rawProgramDateTime=f.initSegment.rawProgramDateTime;break;default:g.b.w(\"line parsed but not handled: \"+s)}}}return(h=u)&&!h.relurl&&(f.fragments.pop(),d-=h.duration),f.totalduration=d,f.averagetargetduration=d/f.fragments.length,f.endSN=_-1,!f.initSegment&&f.fragments.length&&f.fragments.every((function(e){return Le.test(e.relurl)}))&&(g.b.w(\"MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX\"),(h=new fe).relurl=f.fragments[0].relurl,h.baseurl=t,h.level=i,h.type=r,h.sn=\"initSegment\",f.initSegment=h,f.needSidxRanges=!0),l&&function(e,t){for(var i=e[t],r=t-1;r>=0;r--){var a=e[r];i.programDateTime&&(a.programDateTime=i.programDateTime-1e3*a.duration),i=a}}(f.fragments,l),f},e}(),Ie=function(){function e(){}return e.verify=function(e){return!!(e&&e.adaptationSet&&e.adaptationSet.representation&&e.adaptationSet.representation.length)&&e.adaptationSet.representation.reduce((function(e,t){return!!(t.url&&t.bandwidth&&e)}),!0)},e.parse=function(t){var i=[];return e.verify(t)&&t.adaptationSet.representation.forEach((function(e){if(e&&(e.url||e.m3u8)){var t=new pe(e.baseUrl?Ce.resolve(e.url,e.baseUrl):e.url);t.bitrate=Math.floor(e.bandwidth/1e3),t.maxBitrate=Math.floor(e.bandwidth/1e3),t.qualityType=e.qualityType||\"\",t.qualityLabel=e.qualityLabel||\"\",e.width&&e.height&&(t.width=e.width,t.height=e.height),Ce.setCodecs([].concat((e.codecs||\"\").split(/[ ,]+/)),t),t.audioCodec=\"\",t.m3u8Slice=e.m3u8||e.m3u8Slice,t.totalduration=e.duration,e.backupUrl&&e.backupUrl.length&&(t.url=t.url.concat(e.backupUrl)),t.default=e.defaultSelect||!1,t.urlId=0,i.push(t)}})),{levels:i,def:0}},e}();function Oe(e){var t={};return(e||\"\").split(/[ ,]+/).forEach((function(e){0!==e.indexOf(\"avc1\")&&0!==e.indexOf(\"hev1\")&&0!==e.indexOf(\"av01\")&&0!==e.indexOf(\"kvc\")||(t.video=e),0===e.indexOf(\"mp4a\")&&(t.audio=e)})),t}!function(e){e[e.HLSTS=1]=\"HLSTS\",e[e.MP4=2]=\"MP4\",e[e.FLV=3]=\"FLV\",e[e.HLSFMP4=4]=\"HLSFMP4\"}(Ae||(Ae={})),function(e){e[e.LongVideo=1]=\"LongVideo\",e[e.ShortVideo=2]=\"ShortVideo\",e[e.LiveGame=3]=\"LiveGame\",e[e.LiveShow=4]=\"LiveShow\",e[e.LivePlayBack=5]=\"LivePlayBack\"}(De||(De={}));var ke={1:v.g.hls_ts,2:v.g.mp4,3:v.g.flv,4:v.g.hls_fmp4},Pe=function(){function e(){}return e.verify=function(e){return!!(e&&e.adaptationSet&&e.adaptationSet.length)&&e.adaptationSet.reduce((function(e,t){return!!(e&&t.representation&&t.representation.length)}),!0)},e.parse=function(t){var i,r,a,n,s,o,_=[],d=!1,c=0;if(e.verify(t)){var u=t;o=ke[u.mediaType],u.adaptationSet.forEach((function(e){var t=e.duration/1e3;!c&&t&&(c=t);var o=e.drmSchemaId,h=e.drmToken;e.drmSchemaId&&(d=!0);var l=v.e.MAIN;if(e.mimeType&&(-1!==e.mimeType.indexOf(\"video\")||(l=-1!==e.mimeType.indexOf(\"audio\")?v.e.AUDIO:\"text/vtt\"===e.mimeType?v.e.SUBTITLE:void 0)),l){var f=e.representation.map((function(i,r){var _;if(u.mediaType===Ae.HLSTS||u.mediaType===Ae.HLSFMP4?((_=new pe(i.url)).lang=e.language||\"\",_.default=!!i.defaultSelect,_.id=i.id||r,_.m3u8Slice=i.m3u8Slice,_.totalduration=t||c,_.maxBitrate=i.maxBitrate||0):(_=new de(i.url)).maxBitrate=i.maxBitrate||0,_.bitrate=i.avgBitrate||_.maxBitrate,_.qualityType=i.qualityType||\"\",_.qualityLabel=i.qualityLabel||\"\",_.codec=i.codecs||\"\",_.codec){var f=Oe(_.codec);_.audioCodec=f.audio||\"\",_.videoCodec=f.video||\"\"}return 1===u.adaptationSet.length&&(_.audioCodec=\"\"),i.width&&i.height&&(_.width=i.width,_.height=i.height),_.hidden=i.hidden||!1,_.enableAdaptive=void 0===i.disableAdaptive||!i.disableAdaptive,_.default=i.defaultSelect||!1,_.index=r,_.drmSchemaId=i.drmSchemaId||o,_.drmToken=i.drmToken||h,_.drmSchemaId&&(d=!0),i.backupUrl&&i.backupUrl.length&&(_.url=_.url.concat(i.backupUrl)),_.urlId=0,_.default&&void 0===a&&(l===v.e.MAIN?a=r:l===v.e.AUDIO?n=r:l===v.e.SUBTITLE&&(s=r)),_.comment=i.comment,_}));l===v.e.MAIN?_=_.concat(f):l===v.e.AUDIO?(i||(i=[]),i=i.concat(f)):l===v.e.SUBTITLE&&(r||(r=[]),r=r.concat(f))}}))}return r&&e.processingSubtitleType(r,c),{levels:_,def:a||0,audioTracks:i,defAudio:n||0,subtitleTracks:r,defSubtitle:s||0,drm:d,box:o}},e.processingSubtitleType=function(e,t){e.forEach((function(e,i){if(-1===e.currentUrl.indexOf(\".m3u8\")){e.live=!1,e.index=i,e.details=new pe(\"\"),e.totalduration=t;var r=new fe;r.type=v.e.SUBTITLE,r.start=0,r.sn=1,r.level=i,r.cc=0,r.url=e.currentUrl,r.duration=t,e.details.live=!1,e.details.targetduration=t,e.details.totalduration=t,e.details.endSN=1,e.details.fragments=[r]}}))},e.getAdaptationIdxByType=function(e,t){for(var i=0;i2&&r[1].split(\",\").forEach((function(e){0===e.indexOf(\"avc1\")?t.vCodec=v.b.h264:0===e.indexOf(\"av01\")?t.vCodec=v.b.av1:0!==e.indexOf(\"hev1\")&&0!==e.indexOf(\"hvc1\")||(t.vCodec=v.b.hevc)}));break}return t}var Ve,Fe=new RegExp(\"^((http|https)://)|blob:\"),Ue=[v.g.matroska,v.g.mp3,v.g.aac],Be=[v.g.flv,v.g.raw,v.g.webrtc],He=[v.g.mp4,v.g.flv,v.g.hls,v.g.raw,v.g.hls_fmp4,v.g.hls_ts],We=Object.keys(v.b).map((function(e){return v.b[e]})),je=function(){function e(){}return e.verifyMix=function(e){var t=0;for(var i in e)-1!==We.indexOf(i)&&t++;return t>0},e.isSrcEmpty=function(e){try{if(\"string\"==typeof e){if(!(e=e.trim()))return!0;if(!Fe.test(e))return 0===Object.keys(JSON.parse(e)).length}else if(!(e instanceof Blob))return 0===Object.keys(e).length}catch(e){}return!1},e.filterLevels=function(e){var t=E.a.chrome||E.a.firefox;e.levels.forEach((function(e){t&&e.audioCodec&&-1!==e.audioCodec.indexOf(\"mp4a.40.34\")&&(e.audioCodec=\"\")}));var i=G.isMSEAvailable()?G.isMSECodecStrSupportedInMp4:G.isVideoCodecStrSupportedInMp4;e.levels=e.levels.filter((function(e){var t=e.audioCodec,r=e.videoCodec;return(!t||i(t,\"audio\"))&&(!r||i(r))}));var r=!1;return e.levels.forEach((function(t,i){t.index=i,t.default&&(e.def=i,r=!0)})),r||(g.b.i(\"media-src\",\"no default main level, select the one with the lowest bit rate.\"),e.def=e.levels.reduce((function(t,i,r){return i.bitrate=0?2:-2,_.priority+=_.info.codecType===v.b.unknown?1:G.isMSECodecSupported(_.info.codecType)?2:-2}}return s.sort((function(e,t){return t.priority-e.priority})),(null==(n=s[0])?void 0:n.info)||{src:t,box:v.g.unknown,srcType:v.i.OTHERS}}return e._preParseMd(t,i,r,a)},e._preParseMd=function(t,i,r,a){if(void 0===r&&(r=!1),\"string\"==typeof t&&(t=t.trim(),!Fe.test(t)))try{t=JSON.parse(t)}catch(e){return g.b.i(\"media-src\",\"pre prese src error\",t),{src:t,box:v.g.unknown,srcType:v.i.OTHERS}}var n,s,o=[],_=G.isMSEAvailable();if(e.verifyMix(t)){var d={},c=t;for(var u in s={},c){var h=u;if(-1!==We.indexOf(h)){var l=c[h];if(\"string\"==typeof l&&(l=l.trim()),!l)continue;var f=this._getBoxBySrc(l);if(f.nativeFirst=this._getNativeFirstByBox(f.box,_,a),o.push(h),_&&!f.nativeFirst){var p=G.getVideoCodecCompatibilityByCodec(h);s[h]=p.decoder,h===v.b.h264&&(p={decoder:v.c.buildIn,smooth:!0,mix:p.mix}),p.smooth&&p.decoder===v.c.buildIn&&l&&(f.compatibility=p,f.codecType=h,d[h]=f)}else{var m=G.isVideoCodecSupported(h);s[h]=m?v.c.buildIn:v.c.unsupported,(m&&(!E.a.iphone&&!E.a.ipad||h!==v.b.hevc||f.box!==v.g.hls_ts)||h===v.b.h264)&&(f.compatibility={decoder:v.c.buildIn,smooth:!0,mix:!1},f.codecType=h,d[h]=f)}}}var y,b=d[v.b.hevc],S=d[v.b.av1],T=d[v.b.h264],R=S||b;if(r&&R&&R.compatibility&&R.compatibility.mix&&T)if(Pe.verify(R.src)&&Pe.verify(T.src)&&R.src.adaptationSet.length===T.src.adaptationSet.length){var L=[],x=Pe.getAdaptationIdxByType(T.src,\"video\"),A=Pe.getAdaptationIdxByType(R.src,\"video\");x>=0&&A>=0&&(T.src.adaptationSet[x].representation.forEach((function(e){var t=Math.min(e.height,e.width);(t>1080||1080===t&&e.frameRate>35)&&(e.defaultSelect=!1,L.push(e))})),R.src.adaptationSet[A].representation.forEach((function(e){var t=Math.min(e.height,e.width);(t<1080||1080===t&&e.frameRate<=35)&&L.push(e)}))),L.length&&(R.src.adaptationSet[A].representation=L,R.codecType=v.b.unknown,n=R)}else if(ce.verify(R.src)&&ce.verify(T.src)){var D=[];T.src.adaptationSet.representation.forEach((function(e){e.bitrate>=3e3&&D.push(e)})),R.src.adaptationSet.representation.forEach((function(e){e.bitrate<3e3&&-1===function(e,t){for(var i=0;i0||e.indexOf(\".m4s\")>0||e.indexOf(\".mov\")>0||e.indexOf(\".m4a\")>0?v.g.mp4:e.indexOf(\".flv\")>0?v.g.flv:e.indexOf(\".m3u8\")>0?v.g.hls:e.indexOf(\".sdp\")>0?v.g.webrtc:e.indexOf(\".webm\")>0||e.indexOf(\".mkv\")>0||e.indexOf(\".mka\")>0?v.g.matroska:e.indexOf(\".mp3\")>0?v.g.mp3:e.indexOf(\".aac\")>0?v.g.aac:v.g.unknown},e}(),Ke=function(){function e(e,t){this.video=void 0,this.mse=void 0,this.stat=void 0,this.loadRec=void 0,this.lctx=void 0,this._src=void 0,this._config=void 0,this._streamTime=0,this._localTime=0,this.video=t,this.lctx=new _e(!0),this._setConfig(re.processConfig(e))}var t=e.prototype;return t.destroy=function(){this._destroyLevels()},t.getNewCtx=function(){return new e(this._config)},t.updateVideoPlaybackQuality=function(e,t){this.stat.videoPlaybackQuality?(this.stat.videoPlaybackQuality.droppedVideoFrames=t,this.stat.videoPlaybackQuality.totalVideoFrames=e):this.stat.videoPlaybackQuality={corruptedVideoFrames:0,creationTime:0,droppedVideoFrames:t,totalVideoFrames:e}},t.isTimeinBuffered=function(e){if(this.video)for(var t=this.video.buffered,i=0;i