!function(e){"function"==typeof define&&define.amd?define(e):e()}(function(){"use strict";class e{on(e,t,i){var r=this.e||(this.e={});return(r[e]||(r[e]=[])).push({fn:t,ctx:i}),this}once(r,s,a){const n=this;function o(){n.off(r,o);for(var e=arguments.length,t=new Array(e),i=0;i{delete t[e]}),delete this.e}}const i="fetch",F="websocket",j="worker",n="player",U="playerAudio",v="playbackTF",p="mp4",N="webm",G="flv",z="webTransport",H="nakedFlow",W={flv:"FLV",m7s:"m7s",hls:"HLS",fmp4:"FMP4",webrtc:"Webrtc",webTransport:"WebTransport",nakedFlow:"裸流"},V="canvas",$="video",K="debug",J="warn",q="click",Q="jbprov",Y={url:"",playbackConfig:{},fullscreenWatermarkConfig:{},playType:n,playbackForwardMaxRateDecodeIFrame:4,playOptions:{},isLive:!0,isMulti:!1,isCrypto:!1},X={playType:n,container:"",videoBuffer:1e3,videoBufferDelay:1e3,networkDelay:1e4,isResize:!0,isFullResize:!1,isFlv:!1,isHls:!1,isFmp4:!1,isWebrtc:!1,isWebrtcForZLM:!1,isNakedFlow:!1,isMpeg4:!1,debug:!1,debugLevel:J,debugUuid:"",isMulti:!1,hotKey:!1,loadingTimeout:10,heartTimeout:10,timeout:10,pageVisibilityHiddenTimeout:300,loadingTimeoutReplay:!0,heartTimeoutReplay:!0,loadingTimeoutReplayTimes:3,heartTimeoutReplayTimes:3,heartTimeoutReplayUseLastFrameShow:!1,replayUseLastFrameShow:!1,supportDblclickFullscreen:!1,showBandwidth:!1,showPerformance:!1,mseCorrectTimeDuration:20,keepScreenOn:!0,isNotMute:!1,hasAudio:!0,hasVideo:!0,operateBtns:{fullscreen:!1,screenshot:!1,play:!1,audio:!1,record:!1,ptz:!1,quality:!1,zoom:!1,close:!1,scale:!1,performance:!1,aiFace:!1,aiObject:!1,fullscreenFn:null,fullscreenExitFn:null,screenshotFn:null,playFn:null,pauseFn:null,recordFn:null,recordStopFn:null},extendOperateBtns:[],contextmenuBtns:[],watermarkConfig:{},controlAutoHide:!1,hasControl:!1,loadingIcon:!0,loadingText:"",background:"",backgroundLoadingShow:!1,loadingBackground:"",decoder:"decoder-pro.js",decoderAudio:"decoder-pro-audio.js",decoderWASM:"",isDecoderUseCDN:!1,url:"",rotate:0,mirrorRotate:"none",playbackConfig:{playList:[],fps:"",showControl:!0,showRateBtn:!1,rateConfig:[],isCacheBeforeDecodeForFpsRender:!1,uiUsePlaybackPause:!1,isPlaybackPauseClearCache:!0,isUseFpsRender:!1,isUseLocalCalculateTime:!1,localOneFrameTimestamp:40,supportWheel:!1},qualityConfig:[],defaultStreamQuality:"",scaleConfig:["拉伸","缩放","正常"],forceNoOffscreen:!0,hiddenAutoPause:!1,protocol:2,demuxType:G,useWasm:!1,useWCS:!1,useSIMD:!0,wcsUseVideoRender:!0,wasmUseVideoRender:!0,mseUseCanvasRender:!1,hlsUseCanvasRender:!1,useMSE:!1,useOffscreen:!1,useWebGPU:!1,mseDecodeErrorReplay:!0,wcsDecodeErrorReplay:!0,wasmDecodeErrorReplay:!0,autoWasm:!0,webglAlignmentErrorReplay:!0,webglContextLostErrorReplay:!0,openWebglAlignment:!1,syncAudioAndVideo:!1,playbackDelayTime:1e3,playbackFps:25,playbackForwardMaxRateDecodeIFrame:4,playbackCurrentTimeMove:!0,useVideoRender:!0,useCanvasRender:!1,networkDelayTimeoutReplay:!1,recordType:p,checkFirstIFrame:!0,nakedFlowFps:25,audioEngine:null,isShowRecordingUI:!0,isShowZoomingUI:!0,useFaceDetector:!1,useObjectDetector:!1,ptzClickType:q,ptzStopEmitDelay:.3,ptzZoomShow:!1,ptzApertureShow:!1,ptzFocusShow:!1,ptzMoreArrowShow:!1,weiXinInAndroidAudioBufferSize:4800,isCrypto:!1,cryptoKey:"",cryptoIV:"",cryptoKeyUrl:"",autoResize:!1,useWebFullScreen:!1,ptsMaxDiff:3600,aiFaceDetectWidth:192,aiObjectDetectWidth:192,videoRenderSupportScale:!0,mediaSourceTsIsMaxDiffReplay:!0,controlHtml:"",isH265:!1,supportLockScreenPlayAudio:!0,supportHls265:!0},Z="init",ee="initVideo",te="initAudio",ie="audioCode",re="videoCode",se="videoCodec",ae="closeEnd",w={fullscreen:"fullscreen$2",webFullscreen:"webFullscreen",decoderWorkerInit:"decoderWorkerInit",play:"play",playing:"playing",pause:"pause",mute:"mute",load:"load",loading:"loading",zooming:"zooming",videoInfo:"videoInfo",timeUpdate:"timeUpdate",audioInfo:"audioInfo",log:"log",error:"error",kBps:"kBps",timeout:"timeout",delayTimeout:"delayTimeout",delayTimeoutRetryEnd:"delayTimeoutRetryEnd",loadingTimeout:"loadingTimeout",loadingTimeoutRetryEnd:"loadingTimeoutRetryEnd",stats:"stats",performance:"performance",faceDetectActive:"faceDetectActive",objectDetectActive:"objectDetectActive",record:"record",recording:"recording",recordingTimestamp:"recordingTimestamp",recordStart:"recordStart",recordEnd:"recordEnd",recordCreateError:"recordCreateError",recordBlob:"recordBlob",buffer:"buffer",videoFrame:"videoFrame",start:"start",metadata:"metadata",resize:"resize",volumechange:"volumechange",destroy:"destroy",beforeDestroy:"beforeDestroy",streamEnd:"streamEnd",streamRate:"streamRate",streamAbps:"streamAbps",streamVbps:"streamVbps",streamDts:"streamDts",streamSuccess:"streamSuccess",streamMessage:"streamMessage",streamError:"streamError",streamStats:"streamStats",mseSourceOpen:"mseSourceOpen",mseSourceClose:"mseSourceClose",mseSourceended:"mseSourceended",mseSourceBufferError:"mseSourceBufferError",mseAddSourceBufferError:"mseAddSourceBufferError",mseSourceBufferBusy:"mseSourceBufferBusy",mseSourceBufferFull:"mseSourceBufferFull",videoWaiting:"videoWaiting",videoTimeUpdate:"videoTimeUpdate",videoSyncAudio:"videoSyncAudio",playToRenderTimes:"playToRenderTimes",playbackTime:"playbackTime",playbackTimestamp:"playbackTimestamp",playbackPrecision:"playbackPrecision",playbackJustTime:"playbackJustTime",playbackStats:"playbackStats",playbackSeek:"playbackSeek",playbackPause:"playbackPause",playbackPauseOrResume:"playbackPauseOrResume",playbackRateChange:"playbackRateChange",playbackPreRateChange:"playbackPreRateChange",ptz:"ptz",streamQualityChange:"streamQualityChange",visibilityChange:"visibilityChange",netBuf:"netBuf",close:"close",networkDelayTimeout:"networkDelayTimeout",togglePerformancePanel:"togglePerformancePanel",viewResizeChange:"viewResizeChange",flvDemuxBufferSizeTooLarge:"flvDemuxBufferSizeTooLarge",talkGetUserMediaSuccess:"talkGetUserMediaSuccess",talkGetUserMediaFail:"talkGetUserMediaFail",talkGetUserMediaTimeout:"talkGetUserMediaTimeout",talkStreamStart:"talkStreamStart",talkStreamOpen:"talkStreamOpen",talkStreamClose:"talkStreamClose",talkStreamError:"talkStreamError",talkStreamInactive:"talkStreamInactive",webrtcDisconnect:"webrtcDisconnect",webrtcFailed:"webrtcFailed",webrtcClosed:"webrtcClosed",crashLog:"crashLog",focus:"focus",blur:"blur",visibilityHiddenTimeout:"visibilityHiddenTimeout",websocketOpen:"websocketOpen",websocketClose:"websocketClose",websocketError:"websocketError",websocketMessage:"websocketMessage",aiObjectDetectorInfo:"aiObjectDetectorInfo",aiFaceDetector:"aiFaceDetector",playFailedAndPaused:"playFailedAndPaused",audioResumeState:"audioResumeState"},d={load:w.load,timeUpdate:w.timeUpdate,videoInfo:w.videoInfo,audioInfo:w.audioInfo,error:w.error,kBps:w.kBps,start:w.start,timeout:w.timeout,loadingTimeout:w.loadingTimeout,loadingTimeoutRetryEnd:w.loadingTimeoutRetryEnd,delayTimeout:w.delayTimeout,delayTimeoutRetryEnd:w.delayTimeoutRetryEnd,fullscreen:"fullscreen",webFullscreen:w.webFullscreen,play:w.play,pause:w.pause,mute:w.mute,stats:w.stats,performance:w.performance,recordingTimestamp:w.recordingTimestamp,recordStart:w.recordStart,recordEnd:w.recordEnd,recordBlob:w.recordBlob,playToRenderTimes:w.playToRenderTimes,playbackSeek:w.playbackSeek,playbackStats:w.playbackStats,playbackTimestamp:w.playbackTimestamp,playbackPauseOrResume:w.playbackPauseOrResume,playbackPreRateChange:w.playbackPreRateChange,playbackRateChange:w.playbackRateChange,ptz:w.ptz,streamQualityChange:w.streamQualityChange,zooming:w.zooming,crashLog:w.crashLog,focus:w.focus,blur:w.blur,visibilityHiddenTimeout:w.visibilityHiddenTimeout,visibilityChange:w.visibilityChange,websocketOpen:w.websocketOpen,websocketClose:w.websocketClose,networkDelayTimeout:w.networkDelayTimeout,aiObjectDetectorInfo:w.aiObjectDetectorInfo,playFailedAndPaused:w.playFailedAndPaused,audioResumeState:w.audioResumeState},ne={talkStreamClose:w.talkStreamClose,talkStreamError:w.talkStreamError,talkStreamInactive:w.talkStreamInactive,talkGetUserMediaTimeout:w.talkGetUserMediaTimeout},m={playError:"playIsNotPauseOrUrlIsNull",fetchError:"fetchError",websocketError:"websocketError",webcodecsH265NotSupport:"webcodecsH265NotSupport",webcodecsDecodeError:"webcodecsDecodeError",webcodecsUnsupportedConfigurationError:"webcodecsUnsupportedConfigurationError",mediaSourceH265NotSupport:"mediaSourceH265NotSupport",mediaSourceDecoderConfigurationError:"mediaSourceDecoderConfigurationError",mediaSourceFull:w.mseSourceBufferFull,mseSourceBufferError:w.mseSourceBufferError,mseAddSourceBufferError:w.mseAddSourceBufferError,mediaSourceAppendBufferError:"mediaSourceAppendBufferError",mediaSourceBufferListLarge:"mediaSourceBufferListLarge",mediaSourceAppendBufferEndTimeout:"mediaSourceAppendBufferEndTimeout",mediaSourceTsIsMaxDiff:"mediaSourceTsIsMaxDiff",mediaSourceUseCanvasRenderPlayFailed:"mediaSourceUseCanvasRenderPlayFailed",wasmDecodeError:"wasmDecodeError",wasmUseVideoRenderError:"wasmUseVideoRenderError",hlsError:"hlsError",webrtcError:"webrtcError",webglAlignmentError:"webglAlignmentError",wasmWidthOrHeightChange:"wasmWidthOrHeightChange",mseWidthOrHeightChange:"mseWidthOrHeightChange",wcsWidthOrHeightChange:"wcsWidthOrHeightChange",tallWebsocketClosedByError:"tallWebsocketClosedByError",flvDemuxBufferSizeTooLarge:w.flvDemuxBufferSizeTooLarge,wasmDecodeVideoNoResponseError:"wasmDecodeVideoNoResponseError",audioChannelError:"audioChannelError",simdH264DecodeVideoWidthIsTooLarge:"simdH264DecodeVideoWidthIsTooLarge",webglContextLostError:"webglContextLostError"},oe="notConnect",le="open",o={download:"download",base64:"base64",blob:"blob"},ce="download",de={7:"H264(AVC)",12:"H265(HEVC)",99:"MPEG4"},ue="H264(AVC)",he="H265(HEVC)",pe={AAC:"AAC",ALAW:"ALAW(g711a)",MULAW:"MULAW(g711u)"},fe={10:"AAC",7:"ALAW",8:"MULAW"},ge=6,me="webcodecs",Ae="webgl",ye="webgpu",be="offscreen",ve="mse",we='video/mp4; codecs="avc1.64002A"',Ee='video/mp4; codecs="hev1.1.6.L123.b0"',Te="oneHour",Se="halfHour",ke="fiveMin",_e={oneHour:"one-hour",halfHour:"half-hour",tenMin:"ten-min",fiveMin:"five-min"},Ce=["oneHour","halfHour","tenMin","fiveMin"],Re=["up","right","down","left","left-up","right-up","left-down","right-down"],Le="stop",xe="fiStop",De="g711a",Ie="g711u",l={png:"image/png",jpeg:"image/jpeg",webp:"image/webp"},Pe="canplay",Be="waiting",Me="timeupdate",Oe="ratechange",Fe="The user aborted a request",je="AbortError",Ue="AbortError",Ne="worklet",Ge={encType:De,packetType:"rtp",rtpSsrc:"0000000000",numberChannels:1,sampleRate:8e3,sampleBitsWidth:16,debug:!1,debugLevel:J,testMicrophone:!1,audioBufferLength:160,engine:Ne,checkGetUserMediaTimeout:!1,getUserMediaTimeout:1e4},ze="worklet",He="script",We="active",Ve={name:"",index:0,icon:"",iconHover:"",iconTitle:"",activeIcon:"",activeIconHover:"",activeIconTitle:"",click:null,activeClick:null},$e={content:"",click:null,index:0},Ke={container:"",maxSplit:4,split:1,supportDblclickContainerFullscreen:!0,style:{border:"#343434",borderSelect:"#FFCC00",background:"#000"}},Je={dblSelected:"multiDblSelected",selected:"multiSelected",mouseOver:"multiMouseover",mouseOut:"multiMouseout",mouseUp:"multiMouseup"},qe="3-1",Qe="4-1";class Ye{constructor(a){this.log=function(e){if(a._opt.debug&&a._opt.debugLevel==K){for(var t=a._opt.debugUuid?`[${a._opt.debugUuid}]`:"",i=arguments.length,r=new Array(1>4==10&&0===e[1]}function et(){}function tt(e){let t=null;var i=["webgl","experimental-webgl","moz-webgl","webkit-3d"];let r=0;for(;!t&&r{E(t,e,i[e])}),t.style[i]=e)}function rt(e,t,i){i=!(2{var t;u(e)&&(r+=e,1e3<=(t=(e=st())-s))&&(i(r/t*1e3),s=e,r=0)}}f.isEnabled;try{if("object"==typeof WebAssembly&&"function"==typeof WebAssembly.instantiate){var nt=new WebAssembly.Module(Uint8Array.of(0,97,115,109,1,0,0,0));if(nt instanceof WebAssembly.Module)new WebAssembly.Instance(nt)instanceof WebAssembly.Instance}}catch(e){}function g(){return/iphone|ipod|android.*mobile|windows.*phone|blackberry.*mobile/i.test(window.navigator.userAgent.toLowerCase())}function ot(){const t=window.navigator.userAgent.toLowerCase()||"",i={type:"",version:""},e={IE:window.ActiveXObject||"ActiveXObject"in window,Chrome:-1{var i=r[t];return"a"===t?["一","二","三","四","五","六","日"][i-1]:(i=0{l=!1,n&&(e.apply(o,n),n=null,o=null)},a))}}function u(e){return"[object Number]"===Object.prototype.toString.call(e)}function ft(){let e=!1;return e="MediaSource"in window&&window.MediaSource.isTypeSupported(Ee)?!0:e}function gt(){var e=ot();return"chrome"===e.type.toLowerCase()&&107<=e.version}function mt(){let e=!1;return e="MediaStreamTrackGenerator"in window?!0:e}function At(){let e=!1;return e="MediaStream"in window?!0:e}function yt(e){return null==e}function bt(e){return!0===e||!1===e}function c(e){return!yt(e)}function vt(e){var t={left:"",right:"",top:"",bottom:"",opacity:1,backgroundColor:"",image:{src:"",width:"100",height:"60"},text:{content:"",fontSize:"14",color:"#000"},rect:{color:"",lineWidth:2,width:"",height:""},html:""},i=Object.assign(t.image,e.image||{}),r=Object.assign(t.text,e.text||{});return Object.assign(t,e,{image:i,text:r})}function wt(e,t){e={container:e||"",text:"",opacity:"",angle:"",color:"",fontSize:"",fontFamily:""};return{watermark_parent_node:(e=Object.assign(e,t)).container,watermark_alpha:e.opacity,watermark_angle:e.angle,watermark_fontsize:e.fontSize,watermark_color:e.color,watermark_font:e.fontFamily,watermark_txt:e.text}}function Et(e,c){return new Promise((t,i)=>{let r=vt(c);if(!r.image.src&&!r.text.content)return t(e);let s=document.createElement("canvas"),a=(s.width=c.width,s.height=c.height,s.getContext("2d")),n=0,o=0;u(r.left)?n=r.left:u(r.right)&&(n=s.width-r.right),u(r.top)?o=r.top:u(r.bottom)&&(o=s.height-r.bottom);const l=new Image;l.src=e,l.onload=()=>{if(a.drawImage(l,0,0),r.image&&r.image.src){const e=new Image;e.src=r.image.src,e.setAttribute("crossOrigin","Anonymous"),e.onload=()=>{n-=r.image.width,a.drawImage(e,n,o,r.image.width,r.image.height),t(s.toDataURL(c.format,c.quality))},e.onerror=e=>{i()}}else r.text&&r.text.content&&(a.font=r.text.fontSize+"px 宋体",a.fillStyle=r.text.color,a.textAlign="right",a.fillText(r.text.content,n,o),t(s.toDataURL(c.format,c.quality)))},l.onerror=e=>{i(e)}})}function Tt(e){var t,i;return-1{var e=window.navigator.userAgent;return/MicroMessenger/i.test(e)};function S(e){e=e||window.event;return e.target||e.srcElement}function b(e){return"function"==typeof e}function xt(e){let t=0,i=0;var r=e||window.event;return r.pageX||r.pageY?(t=r.pageX,i=r.pageY):(r.clientX||r.clientY)&&(t=e.clientX+document.documentElement.scrollLeft+document.body.scrollLeft,i=e.clientY+document.documentElement.scrollTop+document.body.scrollTop),{posX:t,posY:i}}function Dt(e){return _(e.hasAudio)&&(e.useMSE||e.useWCS&&!e.useOffscreen)}function It(e){e=e.toString().trim().match(/^function\s*\w*\s*\([\w\s,]*\)\s*{([\w\W]*?)}$/)[1],e=new Blob([e],{type:"application/javascript"});return URL.createObjectURL(e)}function Pt(e){e.close?e.close():e.destroy&&e.destroy()}function Bt(){return"https:"===window.location.protocol||"localhost"===window.location.hostname}function Mt(e){for(var e=(e+"=".repeat((4-e.length%4)%4)).replace(/\-/g,"+").replace(/_/g,"/"),t=window.atob(e),i=new Uint8Array(t.length),r=0;r>4==1&&0===e[1]}function k(e){return!0===e||"true"===e}function _(e){return!0!==e&&"true"!==e}function Nt(e){return e.replace(/-([a-z])/g,function(e,t){return t.toUpperCase()})}class Gt{constructor(e){this.destroys=[],this.proxy=this.proxy.bind(this),this.master=e}proxy(t,e,i){let r=3this.proxy(t,e,i,r));t.addEventListener(e,i,r);var s=()=>{b(t.removeEventListener)&&t.removeEventListener(e,i,r)};return this.destroys.push(s),s}}destroy(){this.master.debug&&this.master.debug.log("Events","destroy"),this.destroys.forEach(e=>e())}}var zt="undefined"!=typeof Float32Array?Float32Array:Array;function Ht(){var e=new zt(16);return zt!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function Wt(e){e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});function Vt(e,t,i){var r=new zt(3);return r[0]=e,r[1]=t,r[2]=i,r}nt=new zt(3),zt!=Float32Array&&(nt[0]=0,nt[1]=0,nt[2]=0),Tr=new zt(4),zt!=Float32Array&&(Tr[0]=0,Tr[1]=0,Tr[2]=0,Tr[3]=0);class $t{constructor(e,t){this.gl=e,t&&this.gl.pixelStorei(this.gl.UNPACK_ALIGNMENT,1);t=this._initShaderProgram();this._programInfo={program:t,attribLocations:{vertexPosition:e.getAttribLocation(t,"aVertexPosition"),texturePosition:e.getAttribLocation(t,"aTexturePosition")},uniformLocations:{projectionMatrix:e.getUniformLocation(t,"uProjectionMatrix"),modelMatrix:e.getUniformLocation(t,"uModelMatrix"),viewMatrix:e.getUniformLocation(t,"uViewMatrix"),rgbatexture:e.getUniformLocation(t,"rgbaTexture"),ytexture:e.getUniformLocation(t,"yTexture"),utexture:e.getUniformLocation(t,"uTexture"),vtexture:e.getUniformLocation(t,"vTexture"),isyuv:e.getUniformLocation(t,"isyuv")}},this._buffers=this._initBuffers(),this._rgbatexture=this._createTexture(),this._ytexture=this._createTexture(),this._utexture=this._createTexture(),this._vtexture=this._createTexture()}destroy(){this.gl.deleteProgram(this._programInfo.program),this.gl.deleteBuffer(this._buffers.position),this.gl.deleteBuffer(this._buffers.texPosition),this.gl.deleteBuffer(this._buffers.indices),this.gl.deleteTexture(this._rgbatexture),this.gl.deleteTexture(this._ytexture),this.gl.deleteTexture(this._utexture),this.gl.deleteTexture(this._vtexture),this._programInfo=null,this._buffers=null,this._rgbatexture=null,this._ytexture=null,this._utexture=null,this._vtexture=null}_initShaderProgram(){var e=this._loadShader(this.gl.VERTEX_SHADER,"\n attribute vec4 aVertexPosition;\n attribute vec2 aTexturePosition;\n varying lowp vec2 vTexturePosition;\n void main(void) {\n gl_Position = aVertexPosition;\n vTexturePosition = aTexturePosition;\n }\n "),t=this._loadShader(this.gl.FRAGMENT_SHADER,"\n precision highp float;\n varying highp vec2 vTexturePosition;\n uniform int isyuv;\n uniform sampler2D rgbaTexture;\n uniform sampler2D yTexture;\n uniform sampler2D uTexture;\n uniform sampler2D vTexture;\n\n const mat4 YUV2RGB = mat4( 1.1643828125, 0, 1.59602734375, -.87078515625,\n 1.1643828125, -.39176171875, -.81296875, .52959375,\n 1.1643828125, 2.017234375, 0, -1.081390625,\n 0, 0, 0, 1);\n\n\n void main(void) {\n\n if (isyuv>0) {\n\n highp float y = texture2D(yTexture, vTexturePosition).r;\n highp float u = texture2D(uTexture, vTexturePosition).r;\n highp float v = texture2D(vTexture, vTexturePosition).r;\n gl_FragColor = vec4(y, u, v, 1) * YUV2RGB;\n\n } else {\n gl_FragColor = texture2D(rgbaTexture, vTexturePosition);\n }\n }\n "),i=this.gl.createProgram();return this.gl.attachShader(i,e),this.gl.attachShader(i,t),this.gl.linkProgram(i),this.gl.getProgramParameter(i,this.gl.LINK_STATUS)?i:(console.log("Unable to initialize the shader program: "+this.gl.getProgramInfoLog(i)),null)}_loadShader(e,t){var i=this.gl,e=i.createShader(e);return i.shaderSource(e,t),i.compileShader(e),i.getShaderParameter(e,i.COMPILE_STATUS)?e:(console.log("An error occurred compiling the shaders: "+i.getShaderInfoLog(e)),i.deleteShader(e),null)}_initBuffers(){var e=this.gl,t=e.createBuffer(),i=(e.bindBuffer(e.ARRAY_BUFFER,t),[-1,-1,1,-1,1,1,-1,1]);e.bufferData(e.ARRAY_BUFFER,new Float32Array(i),e.STATIC_DRAW);var r=(r=[]).concat([0,1],[1,1],[1,0],[0,0]),s=e.createBuffer(),r=(e.bindBuffer(e.ARRAY_BUFFER,s),e.bufferData(e.ARRAY_BUFFER,new Float32Array(r),e.STATIC_DRAW),e.createBuffer());return e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,r),e.bufferData(e.ELEMENT_ARRAY_BUFFER,new Uint16Array([0,1,2,0,2,3]),e.STATIC_DRAW),{positions:i,position:t,texPosition:s,indices:r}}_createTexture(){var e=this.gl.createTexture();return this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),e}_drawScene(e,t,i){this.gl.viewport(0,0,e,t),this.gl.enable(this.gl.BLEND),this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this._buffers.position),this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array(this._buffers.positions),this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this._programInfo.attribLocations.vertexPosition,2,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this._programInfo.attribLocations.vertexPosition),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this._buffers.texPosition),this.gl.vertexAttribPointer(this._programInfo.attribLocations.texturePosition,2,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this._programInfo.attribLocations.texturePosition),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this._buffers.indices),i?(this.gl.activeTexture(this.gl.TEXTURE0+3),this.gl.bindTexture(this.gl.TEXTURE_2D,this._ytexture),this.gl.activeTexture(this.gl.TEXTURE0+4),this.gl.bindTexture(this.gl.TEXTURE_2D,this._utexture),this.gl.activeTexture(this.gl.TEXTURE0+5),this.gl.bindTexture(this.gl.TEXTURE_2D,this._vtexture)):(this.gl.activeTexture(this.gl.TEXTURE0+2),this.gl.bindTexture(this.gl.TEXTURE_2D,this._rgbatexture)),this.gl.useProgram(this._programInfo.program),this.gl.uniform1i(this._programInfo.uniformLocations.rgbatexture,2),this.gl.uniform1i(this._programInfo.uniformLocations.ytexture,3),this.gl.uniform1i(this._programInfo.uniformLocations.utexture,4),this.gl.uniform1i(this._programInfo.uniformLocations.vtexture,5),this.gl.uniform1i(this._programInfo.uniformLocations.isyuv,i?1:0),this.gl.drawElements(this.gl.TRIANGLES,6,this.gl.UNSIGNED_SHORT,0)}_calRect(e,t,i,r,s,a){var n=2*e/s-1,r=2*(a-t-r)/a-1,e=2*(e+i)/s-1,i=2*(a-t)/a-1;return[n,r,e,r,e,i,n,i]}_clear(){this.gl.clearColor(0,0,0,1),this.gl.clearDepth(1),this.gl.clear(this.gl.COLOR_BUFFER_BIT|this.gl.DEPTH_BUFFER_BIT)}render(e,t,i,r,s){var a=this.gl;this._clear(),a.activeTexture(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,this._ytexture),a.texImage2D(a.TEXTURE_2D,0,a.LUMINANCE,e,t,0,a.LUMINANCE,a.UNSIGNED_BYTE,i),a.activeTexture(a.TEXTURE1),a.bindTexture(a.TEXTURE_2D,this._utexture),a.texImage2D(a.TEXTURE_2D,0,a.LUMINANCE,e/2,t/2,0,a.LUMINANCE,a.UNSIGNED_BYTE,r),a.activeTexture(a.TEXTURE2),a.bindTexture(a.TEXTURE_2D,this._vtexture),a.texImage2D(a.TEXTURE_2D,0,a.LUMINANCE,e/2,t/2,0,a.LUMINANCE,a.UNSIGNED_BYTE,s),this._buffers.positions=[-1,-1,1,-1,1,1,-1,1],this._drawScene(e,t,!0)}renderYUV(e,t,i){var r=i.slice(0,e*t),s=i.slice(e*t,e*t*5/4),i=i.slice(e*t*5/4,e*t*3/2),a=this.gl;this._clear(),a.activeTexture(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,this._ytexture),a.texImage2D(a.TEXTURE_2D,0,a.LUMINANCE,e,t,0,a.LUMINANCE,a.UNSIGNED_BYTE,r),a.activeTexture(a.TEXTURE1),a.bindTexture(a.TEXTURE_2D,this._utexture),a.texImage2D(a.TEXTURE_2D,0,a.LUMINANCE,e/2,t/2,0,a.LUMINANCE,a.UNSIGNED_BYTE,s),a.activeTexture(a.TEXTURE2),a.bindTexture(a.TEXTURE_2D,this._vtexture),a.texImage2D(a.TEXTURE_2D,0,a.LUMINANCE,e/2,t/2,0,a.LUMINANCE,a.UNSIGNED_BYTE,i),this._buffers.positions=[-1,-1,1,-1,1,1,-1,1],this._drawScene(e,t,!0)}drawDom(e,t,i,r,s){var a=this.gl;a.activeTexture(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,this._rgbatexture),a.texImage2D(a.TEXTURE_2D,0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,s),this._buffers.positions=this._calRect(i,r,s.width,s.height,e,t),this._drawScene(e,t,!1)}}class Kt{constructor(e){this.gpu=e,this.pipeline=null,this.matrixGroupInfo=null,this.depthTexture=null,this.textureGroupInfo=null,this.hasInited=!1,this.buffers=this._initBuffer(),this._initPipeline().then(e=>{this.pipeline=e,this.matrixGroupInfo=this._initMatrixGroupInfo(),this.hasInited=!0})}destroy(){this.gpu&&(this.gpu.device.destroy(),this.gpu=null),this.hasInited=!1,this.pipeline=null,this.matrixGroupInfo=null,this.depthTexture=null,this.textureGroupInfo=null}_initBuffer(){var e=this.gpu.device,t=new Float32Array([-1,-1,-1,1,-1,-1,1,1,-1,-1,1,-1]),i=e.createBuffer({size:t.byteLength,usage:window.GPUBufferUsage.VERTEX|window.GPUBufferUsage.COPY_DST}),t=(e.queue.writeBuffer(i,0,t),new Float32Array([0,1,1,1,1,0,0,0])),r=e.createBuffer({size:t.byteLength,usage:window.GPUBufferUsage.VERTEX|window.GPUBufferUsage.COPY_DST}),t=(e.queue.writeBuffer(r,0,t),new Uint16Array([0,1,2,0,2,3])),s=e.createBuffer({size:t.byteLength,usage:window.GPUBufferUsage.INDEX|window.GPUBufferUsage.COPY_DST});return e.queue.writeBuffer(s,0,t),{positionBuffer:i,texpositionBuffer:r,indexBuffer:s}}_initPipeline(){return new Promise((t,i)=>{var e=this.gpu.device,r=this.gpu.format,r={layout:"auto",vertex:{module:e.createShaderModule({code:"\n\n @binding(0) @group(0) var uModelMatrix : mat4x4;\n @binding(1) @group(0) var uViewMatrix : mat4x4;\n @binding(2) @group(0) var uProjectionMatrix : mat4x4;\n\n struct VertexOutput {\n @builtin(position) Position : vec4,\n @location(0) vTexturePosition : vec2,\n }\n\n @vertex\n fn main(\n @location(0) aVertexPosition : vec4,\n @location(1) aTexturePosition : vec2\n ) -> VertexOutput {\n var output : VertexOutput;\n var tmppos : vec4 = uProjectionMatrix * uViewMatrix * uModelMatrix * aVertexPosition;\n output.Position = vec4(tmppos.x, tmppos.y, (tmppos.z+1.)/2., tmppos.w); // webgl z [-1, 1], webgpu z [0, 1], 这里z做下调整 z-webgpu = (z-webgl+1)/2\n output.vTexturePosition = aTexturePosition;\n return output;\n }\n\n "}),entryPoint:"main",buffers:[{arrayStride:12,attributes:[{shaderLocation:0,offset:0,format:"float32x3"}]},{arrayStride:8,attributes:[{shaderLocation:1,offset:0,format:"float32x2"}]}]},primitive:{topology:"triangle-list"},fragment:{module:e.createShaderModule({code:"\n @group(1) @binding(0) var mySampler: sampler;\n @group(1) @binding(1) var yTexture: texture_2d;\n @group(1) @binding(2) var uTexture: texture_2d;\n @group(1) @binding(3) var vTexture: texture_2d;\n\n const YUV2RGB : mat4x4 = mat4x4( 1.1643828125, 0, 1.59602734375, -.87078515625,\n 1.1643828125, -.39176171875, -.81296875, .52959375,\n 1.1643828125, 2.017234375, 0, -1.081390625,\n 0, 0, 0, 1);\n\n @fragment\n fn main(\n @location(0) vTexturePosition: vec2\n ) -> @location(0) vec4 {\n\n var y : f32= textureSample(yTexture, mySampler, vTexturePosition).r;\n var u : f32 = textureSample(uTexture, mySampler, vTexturePosition).r;\n var v : f32 = textureSample(vTexture, mySampler, vTexturePosition).r;\n\n return vec4(y, u, v, 1.0)*YUV2RGB;\n }\n\n "}),entryPoint:"main",targets:[{format:r}]},depthStencil:{depthWriteEnabled:!0,depthCompare:"less",format:"depth24plus"}};e.createRenderPipelineAsync(r).then(e=>{t(e)}).catch(e=>{i(e)})})}_initMatrixGroupInfo(){var e,t,i,r,s,a,n,o,l,c,d,u=this.gpu.device,h=this.pipeline,p=Ht(),f=(e=(t=g=1)/((f=-1)-g),y=1/((i=-1)-t),o=1/((n=.1)-(a=100)),(l=p)[0]=-2*e,l[1]=0,l[2]=0,l[3]=0,l[4]=0,l[5]=-2*y,l[6]=0,l[7]=0,l[8]=0,l[9]=0,l[10]=2*o,l[11]=0,l[12]=(f+g)*e,l[13]=(t+i)*y,l[14]=(a+n)*o,l[15]=1,Ht()),g=(Wt(f),Ht()),m=(e=g,t=Vt(0,0,0),i=Vt(0,0,-1),y=Vt(0,1,0),a=t[0],n=t[1],t=t[2],o=y[0],l=y[1],y=y[2],c=i[0],d=i[1],i=i[2],Math.abs(a-c)<1e-6&&Math.abs(n-d)<1e-6&&Math.abs(t-i)<1e-6?Wt(e):(c=a-c,d=n-d,i=t-i,A=l*(i*=m=1/Math.hypot(c,d,i))-y*(d*=m),y=y*(c*=m)-o*i,o=o*d-l*c,(m=Math.hypot(A,y,o))?(A*=m=1/m,y*=m,o*=m):o=y=A=0,l=d*o-i*y,r=i*A-c*o,s=c*y-d*A,(m=Math.hypot(l,r,s))?(l*=m=1/m,r*=m,s*=m):s=r=l=0,e[0]=A,e[1]=l,e[2]=c,e[3]=0,e[4]=y,e[5]=r,e[6]=d,e[7]=0,e[8]=o,e[9]=s,e[10]=i,e[11]=0,e[12]=-(A*a+y*n+o*t),e[13]=-(l*a+r*n+s*t),e[14]=-(c*a+d*n+i*t),e[15]=1),u.createBuffer({size:64,usage:window.GPUBufferUsage.UNIFORM|window.GPUBufferUsage.COPY_DST})),A=(u.queue.writeBuffer(m,0,f),u.createBuffer({size:64,usage:window.GPUBufferUsage.UNIFORM|window.GPUBufferUsage.COPY_DST})),y=(u.queue.writeBuffer(A,0,g),u.createBuffer({size:64,usage:window.GPUBufferUsage.UNIFORM|window.GPUBufferUsage.COPY_DST}));return u.queue.writeBuffer(y,0,p),{modelMatrixBuffer:m,viewMatrixBuffer:A,projectMatrixBuffer:y,group:u.createBindGroup({label:"group0",layout:h.getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:m}},{binding:1,resource:{buffer:A}},{binding:2,resource:{buffer:y}}]})}}_initTextureGroupInfo(e,t){var i=this.gpu.device,r=this.pipeline,s=i.createTexture({size:[e,t],format:"r8unorm",usage:window.GPUTextureUsage.TEXTURE_BINDING|window.GPUTextureUsage.COPY_DST|window.GPUTextureUsage.RENDER_ATTACHMENT}),a=i.createTexture({size:[e/2,t/2],format:"r8unorm",usage:window.GPUTextureUsage.TEXTURE_BINDING|window.GPUTextureUsage.COPY_DST|window.GPUTextureUsage.RENDER_ATTACHMENT}),e=i.createTexture({size:[e/2,t/2],format:"r8unorm",usage:window.GPUTextureUsage.TEXTURE_BINDING|window.GPUTextureUsage.COPY_DST|window.GPUTextureUsage.RENDER_ATTACHMENT}),t=i.createSampler({magFilter:"linear",minFilter:"linear"}),i=i.createBindGroup({label:"group1",layout:r.getBindGroupLayout(1),entries:[{binding:0,resource:t},{binding:1,resource:s.createView()},{binding:2,resource:a.createView()},{binding:3,resource:e.createView()}]});return{yTexture:s,uTexture:a,vTexture:e,group:i}}_drawScene(){var e=this.gpu.device,t=this.gpu.context,i=e.createCommandEncoder(),t={colorAttachments:[{view:t.getCurrentTexture().createView(),clearValue:{r:0,g:0,b:0,a:0},loadOp:"clear",storeOp:"store"}],depthStencilAttachment:{view:this.depthTexture.createView(),depthClearValue:1,depthLoadOp:"clear",depthStoreOp:"store"}},t=i.beginRenderPass(t);t.setPipeline(this.pipeline),t.setBindGroup(0,this.matrixGroupInfo.group),t.setBindGroup(1,this.textureGroupInfo.group),t.setVertexBuffer(0,this.buffers.positionBuffer),t.setVertexBuffer(1,this.buffers.texpositionBuffer),t.setIndexBuffer(this.buffers.indexBuffer,"uint16"),t.drawIndexed(6),t.end(),e.queue.submit([i.finish()])}renderYUV(e,t,i){var r,s,a;this.hasInited&&(r=i.slice(0,e*t),s=i.slice(e*t,e*t*5/4),i=i.slice(e*t*5/4,e*t*3/2),a=this.gpu.device,this.depthTexture||(this.depthTexture=this.gpu.device.createTexture({size:[e,t],format:"depth24plus",usage:window.GPUTextureUsage.RENDER_ATTACHMENT})),this.textureGroupInfo||(this.textureGroupInfo=this._initTextureGroupInfo(e,t)),a.queue.writeTexture({texture:this.textureGroupInfo.yTexture},r,{bytesPerRow:e,rowsPerImage:t},[e,t]),a.queue.writeTexture({texture:this.textureGroupInfo.uTexture},s,{bytesPerRow:e/2,rowsPerImage:t/2},[e/2,t/2]),a.queue.writeTexture({texture:this.textureGroupInfo.vTexture},i,{bytesPerRow:e/2,rowsPerImage:t/2},[e/2,t/2]),this._drawScene())}clear(){}}class Jt extends e{constructor(){super(),this.videoInfo={width:null,height:null,encType:null},this.init=!1}destroy(){this.resetInit(),this.off()}resetInit(){this.videoInfo={width:null,height:null,encType:null},this.init=!1}getHasInit(){return this.init}updateVideoInfo(e){c(e.encTypeCode)&&(this.videoInfo.encType=de[e.encTypeCode]),c(e.encType)&&(this.videoInfo.encType=e.encType),c(e.width)&&(this.videoInfo.width=e.width),c(e.height)&&(this.videoInfo.height=e.height),c(this.videoInfo.encType)&&c(this.videoInfo.height)&&c(this.videoInfo.width)&&!this.init&&(this.player.emit(w.videoInfo,this.videoInfo),this.init=!0)}getVideoInfo(){return this.videoInfo}clearView(){}play(){}pause(){}getType(){return""}getCanvasType(){return""}isPlaying(){return!0}addContentToCanvas(){}getPlaybackQuality(){return null}}var qt="object"==typeof window&&window.window===window?window:"object"==typeof self&&self.self===self?self:"object"==typeof global&&global.global===global?global:void 0;function Qt(e,t,i){var r=new XMLHttpRequest;r.open("GET",e),r.responseType="blob",r.onload=function(){ei(r.response,t,i)},r.onerror=function(){console.error("could not download file")},r.send()}function Yt(e){var t=new XMLHttpRequest;t.open("HEAD",e,!1);try{t.send()}catch(e){}return 200<=t.status&&t.status<=299}function Xt(t){try{t.dispatchEvent(new MouseEvent("click"))}catch(e){var i=document.createEvent("MouseEvents");i.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),t.dispatchEvent(i)}}var Zt=qt.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),ei="object"!=typeof window||window!==qt?function(){}:"download"in HTMLAnchorElement.prototype&&!Zt?function(e,t,i){var r=qt.URL||qt.webkitURL,s=document.createElementNS("http://www.w3.org/1999/xhtml","a");t=t||e.name||"download",s.download=t,s.rel="noopener","string"==typeof e?(s.href=e,s.origin!==location.origin?Yt(s.href)?Qt(e,t,i):Xt(s,s.target="_blank"):Xt(s)):(s.href=r.createObjectURL(e),setTimeout(function(){r.revokeObjectURL(s.href)},4e4),setTimeout(function(){Xt(s)},0))}:"msSaveOrOpenBlob"in navigator?function(e,t,i){var r;t=t||e.name||"download","string"==typeof e?Yt(e)?Qt(e,t,i):((r=document.createElement("a")).href=e,r.target="_blank",setTimeout(function(){Xt(r)})):navigator.msSaveOrOpenBlob((e=e,void 0===(i=i)?i={autoBom:!1}:"object"!=typeof i&&(console.warn("Deprecated: Expected third argument to be a object"),i={autoBom:!i}),i.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob([String.fromCharCode(65279),e],{type:e.type}):e),t)}:function(e,t,i,r){if((r=r||open("","_blank"))&&(r.document.title=r.document.body.innerText="downloading..."),"string"==typeof e)return Qt(e,t,i);var s,a,n,t="application/octet-stream"===e.type,i=/constructor/i.test(qt.HTMLElement)||qt.safari,o=/CriOS\/[\d]+/.test(navigator.userAgent);(o||t&&i||Zt)&&"undefined"!=typeof FileReader?((s=new FileReader).onloadend=function(){var e=s.result,e=o?e:e.replace(/^data:[^;]*;/,"data:attachment/file;");r?r.location.href=e:location=e,r=null},s.readAsDataURL(e)):(a=qt.URL||qt.webkitURL,n=a.createObjectURL(e),r?r.location=n:location.href=n,r=null,setTimeout(function(){a.revokeObjectURL(n)},4e4))};class ti{constructor(e,t){this.gl=e,t&&this.gl.pixelStorei(this.gl.UNPACK_ALIGNMENT,1);e=this._initShaderProgram();this.shaderProgram=e,this.programInfo={program:e,attribLocations:{vertexPosition:this.gl.getAttribLocation(e,"aVertexPosition")},uniformLocations:{linewidth:this.gl.getUniformLocation(e,"uLineWidth"),rect:this.gl.getUniformLocation(e,"uRect"),linecolor:this.gl.getUniformLocation(e,"uLineColor"),resolution:this.gl.getUniformLocation(e,"uResolution")}},this.buffers=this._initBuffers()}destroy(){this.gl.deleteProgram(this.shaderProgram),this.gl.deleteBuffer(this.buffers.position),this.gl.deleteBuffer(this.buffers.indices),this.shaderProgram=null,this.buffers=null}_initShaderProgram(){var e=this.gl,t=this._loadShader(e.VERTEX_SHADER,"\n attribute vec4 aVertexPosition;\n void main(void) {\n gl_Position = aVertexPosition;\n }\n "),i=this._loadShader(e.FRAGMENT_SHADER,"\n precision highp float;\n uniform float uLineWidth;\n uniform vec4 uRect;\n uniform vec3 uLineColor;\n uniform vec2 uResolution;\n\n\n float inBox(vec2 st, vec4 rect){\n\n vec2 bl = step(rect.xy,st);\n float pct = bl.x * bl.y;\n\n vec2 tr = step(st, rect.zw);\n pct *= tr.x * tr.y;\n\n return pct;\n }\n\n void main(void) {\n\n vec2 cur = gl_FragCoord.xy/uResolution;\n\n float xlinewidth = uLineWidth/uResolution.x;\n float ylinewidth = uLineWidth/uResolution.y;\n\n // vec4 outRect = uRect + vec4(-1.*xlinewidth/2., -1.*ylinewidth/2., xlinewidth/2., ylinewidth/2.);\n // vec4 inRect = uRect + vec4(xlinewidth/2., ylinewidth/2., -1.*xlinewidth/2., -1.*ylinewidth/2.);\n\n vec4 outRect = uRect + vec4(-1.*xlinewidth/2., -1.*ylinewidth/2., xlinewidth/2., ylinewidth/2.);\n vec4 inRect = uRect;\n\n float a = inBox(cur, outRect);\n float b = inBox(cur, inRect);\n\n gl_FragColor = mix(vec4(0., 0., 0., 0.), vec4(uLineColor.rgb, 1.0), a-b);\n\n }\n "),r=e.createProgram();return e.attachShader(r,t),e.attachShader(r,i),e.linkProgram(r),e.getProgramParameter(r,e.LINK_STATUS)?r:(console.log("Unable to initialize the shader program: "+e.getProgramInfoLog(r)),null)}_loadShader(e,t){var i=this.gl,e=i.createShader(e);return i.shaderSource(e,t),i.compileShader(e),i.getShaderParameter(e,i.COMPILE_STATUS)?e:(console.log("An error occurred compiling the shaders: "+i.getShaderInfoLog(e)),i.deleteShader(e),null)}_createTexture(){var e=this.gl,t=e.createTexture();return e.bindTexture(e.TEXTURE_2D,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),t}_initBuffers(){var e=this.gl,t=e.createBuffer(),i=(e.bindBuffer(e.ARRAY_BUFFER,t),e.bufferData(e.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,1,1,-1,1]),e.STATIC_DRAW),e.createBuffer());return e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,i),e.bufferData(e.ELEMENT_ARRAY_BUFFER,new Uint16Array([0,1,2,0,2,3]),e.STATIC_DRAW),{position:t,indices:i}}_drawScene(e){var{canvasWidth:e,canvasHeight:t,rect:i,lineWidth:r,lineColor:s}=e,a=this.gl,n=this.buffers,o=this.programInfo;a.viewport(0,0,e,t),a.enable(a.BLEND),a.blendFunc(a.SRC_ALPHA,a.ONE_MINUS_SRC_ALPHA),a.bindBuffer(a.ARRAY_BUFFER,n.position),a.vertexAttribPointer(o.attribLocations.vertexPosition,2,a.FLOAT,!1,0,0),a.enableVertexAttribArray(o.attribLocations.vertexPosition),a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,n.indices),a.useProgram(o.program),a.uniform2f(o.uniformLocations.resolution,e,t),a.uniform4f(o.uniformLocations.rect,i[0],i[1],i[2],i[3]),a.uniform1f(o.uniformLocations.linewidth,r),a.uniform3f(o.uniformLocations.linecolor,s[0],s[1],s[2]),a.drawElements(a.TRIANGLES,6,a.UNSIGNED_SHORT,0)}drawBox(e){var{x:e,y:t,width:i,height:r,lineWidth:s,lineColor:a,canvasWidth:n,canvasHeight:o}=e,l=(l=e/n,r=(o-t-r)/o,e=(e+i)/n,i=(o-t)/o,(t=new zt(4))[0]=l,t[1]=r,t[2]=e,t[3]=i,t),a=Vt(1,0,0);this._drawScene({canvasWidth:n,canvasHeight:o,rect:l,lineWidth:s,lineColor:a})}}class ii extends Jt{constructor(e){super(),this.player=e;var t=document.createElement("canvas");t.style.position="absolute",t.style.top=0,t.style.left=0,this.$videoElement=t,e.$container.appendChild(this.$videoElement),this.context2D=null,this.contextGl=null,this.webglRender=null,this.webglRectRender=null,this.webGPURender=null,this.isWebglContextLost=!1,this.bitmaprenderer=null,this.renderType=null,this.controlHeight=0,this.proxyDestroyList=[],this.tempCanvasContentList=[],this._initCanvasRender()}destroy(){super.destroy(),0{e&&e()}),this.proxyDestroyList=[]),this.contextGl&&(this.contextGl=null),this.context2D&&(this.context2D=null),this.webglRender&&(this.webglRender.destroy(),this.webglRender=null),this.webglRectRender&&(this.webglRectRender.destroy(),this.webglRectRender=null),this.webGPURender&&(this.webGPURender.destroy(),this.webGPURender=null),this.bitmaprenderer&&(this.bitmaprenderer=null),this.renderType=null,this.isWebglContextLost=!1,this.videoInfo={width:"",height:"",encType:""},this.tempCanvasContentList=[],this.player.$container.removeChild(this.$videoElement),this.init=!1,this.off()}_initContextGl(){var e,t=this.player.events["proxy"];this.contextGl=tt(this.$videoElement),this.contextGl?(e=t(this.$videoElement,"webglcontextlost",e=>{e.preventDefault(),this.player.debug.error("canvasVideo","webglcontextlost error",e),this.isWebglContextLost=!0,this.webglRender&&(this.player.debug.log("CommonCanvasLoader","webglcontextlost error and destroy webglRender"),this.webglRender.destroy(),this.webglRender=null),this.webglRectRender&&(this.player.debug.log("CommonCanvasLoader","webglcontextlost error and destroy webglRectRender"),this.webglRectRender.destroy(),this.webglRectRender=null),this.contextGl=null,setTimeout(()=>{this.player.debug.log("CommonCanvasLoader","createContextGL()"),this.contextGl=tt(this.$videoElement),this.player.debug.log("CommonCanvasLoader","createContextGL success"),this.contextGl&&this.contextGl.getContextAttributes&&this.contextGl.getContextAttributes().stencil?(this.webglRender=new $t(this.contextGl,this.player._opt.openWebglAlignment),this.webglRectRender=new ti(this.contextGl,this.player._opt.openWebglAlignment),this.isWebglContextLost=!1,this.player.debug.log("CommonCanvasLoader","webglcontextlost error reset and getContextAttributes().stencil is true")):(this.player.debug.error("CommonCanvasLoader","webglcontextlost error, getContextAttributes().stencil is false"),this.player.emitError(m.webglContextLostError))},500)}),t=t(this.$videoElement,"webglcontextrestored",e=>{e.preventDefault(),this.player.debug.log("CommonCanvasLoader","webglcontextrestored ",e)}),this.webglRender=new $t(this.contextGl,this.player._opt.openWebglAlignment),this.webglRectRender=new ti(this.contextGl,this.player._opt.openWebglAlignment),this.proxyDestroyList.push(e,t)):this.player.debug.error("CommonCanvasLoader","_initContextGl() createContextGL error")}_initContextGPU(){var a=this.$videoElement;new Promise((r,s)=>{navigator.gpu?navigator.gpu.requestAdapter().then(i=>{i?i.requestDevice().then(e=>{if(e){var t=a.getContext("webgpu");if(t){const a=navigator.gpu.getPreferredCanvasFormat();t.configure({device:e,format:a,alphaMode:"opaque"}),r({adapter:i,device:e,context:t,format:a})}else s('WebGPU "context" create fail')}else s('WebGPU "device" request fail')}).catch(e=>{s('WebGPU "adapter.requestDevice()" fail')}):s('WebGPU "adapter" request fail is empty')}).catch(e=>{s('WebGPU "navigator.gpu.requestAdapter()" fail')}):s("WebGPU not support!!")}).then(e=>{this.webGPURender=new Kt(e),this.player.debug.log("CommonCanvasLoader","webGPURender init success")}).catch(e=>{this.player.debug.error("CommonCanvasLoader",`createWebGPUContext error is ${e} and next use webgl render`),this.renderType=Ae,this._initContextGl()})}initCanvasViewSize(){this.$videoElement.width=this.videoInfo.width,this.$videoElement.height=this.videoInfo.height,this.resize()}screenshot(e,t,i,r){e=e||A(),r=r||o.download;let s=.92;!l[t]&&o[t]&&(r=t,t="png",i=void 0),"string"==typeof i&&(r=i,i=void 0),void 0!==i&&(s=Number(i));var a=l[t]||l.png,i=this.$videoElement.toDataURL(a,s);if(r===o.base64)return i;{const t=it(i);if(r===o.blob)return t;if(r===o.download){const i=a.split("/")[1];ei(t,e+"."+i)}}}screenshotWatermark(s){return new Promise((t,i)=>{(s=(s=Rt(s)?{filename:s}:s)||{}).width=this.videoInfo.width,s.height=this.videoInfo.height,s.filename=s.filename||A(),s.format=s.format?l[s.format]:l.png,s.quality=Number(s.quality)||.92,s.type=s.type||o.download;const r=this.$videoElement.toDataURL(s.format,s.quality);Et(r,s).then(e=>{if(s.type===o.base64)t(r);else{const r=it(e);if(s.type===o.blob)t(r);else if(s.type===o.download){t();const e=s.format.split("/")[1];ei(r,s.filename+"."+e)}}}).catch(e=>{i(e)})})}render(){}clearView(){}play(){}pause(){}resize(){this.player.debug.log("canvasVideo","resize");var e=this.player._opt;let t=this.player.width,i=this.player.height;if(e.hasControl&&!e.controlAutoHide){const r=this.controlHeight;g()&&this.player.fullscreen&&e.useWebFullScreen?t-=r:i-=r}let r=this.$videoElement.width,s=this.$videoElement.height;var a=e.rotate,n=(t-r)/2,o=(i-s)/2,l=(270!==a&&90!==a||(r=this.$videoElement.height,s=this.$videoElement.width),t/r),c=i/s;let d=c{this.context2D.drawImage(e,0,0,this.$videoElement.width,this.$videoElement.height),Pt(t.videoFrame),this.doAddContentToCanvas()})}catch(t){}else this.context2D.drawImage(t.videoFrame,0,0,this.$videoElement.width,this.$videoElement.height),Pt(t.videoFrame),this.doAddContentToCanvas();break;case ve:case"hls":this.context2D.drawImage(t.$video,0,0,this.$videoElement.width,this.$videoElement.height),this.doAddContentToCanvas()}}clearView(){switch(this.renderType){case be:e=this.$videoElement.width,t=this.$videoElement.height,(i=document.createElement("canvas")).width=e,i.height=t,e=window.createImageBitmap(i,0,0,e,t),i.width=0,i.height=0,e.then(e=>{this.bitmaprenderer.transferFromImageBitmap(e)});break;case Ae:this.contextGl.clear(this.contextGl.COLOR_BUFFER_BIT);break;case ye:this.webGPURender.clear();break;case me:case ve:case"hls":this.context2D.clearRect(0,0,this.$videoElement.width,this.$videoElement.height)}var e,t,i}_initTempTextCanvas(){this.tempTextCanvas=document.createElement("canvas"),this.tempTextCanvasCtx=this.tempTextCanvas.getContext("2d"),this.tempTextCanvas.width=600,this.tempTextCanvas.height=20}doAddContentToCanvas(){if(0{"text"===e.type?(t.font=`${e.fontSize||12}px Arial`,t.fillStyle=e.color||"green",t.fillText(e.text,e.x,e.y)):"rect"===e.type&&(t.strokeStyle=e.color||"green",t.lineWidth=e.lineWidth||2,t.strokeRect(e.x,e.y,e.width,e.height))}),t.restore()}}doAddContentToWebGlCanvas(){0{var t=e.x,i=e.y;if("rect"===e.type){var r=e.width,s=e.height,a=(a=e.color||"#008000",[parseInt(a.substring(1,3),16)/255,parseInt(a.substring(3,5),16)/255,parseInt(a.substring(5,7),16)/255,1]),n=e.lineWidth||4;r&&s&&this.webglRectRender.drawBox({x:t,y:i,width:r,height:s,lineColor:a,lineWidth:n,canvasWidth:this.$videoElement.width,canvasHeight:this.$videoElement.height})}else if("text"===e.type){const a=e.text||"";a&&(r=e.fontSize||20,s=e.color||"#008000",this.tempTextCanvas||this._initTempTextCanvas(),this.tempTextCanvasCtx.clearRect(0,0,this.tempTextCanvas.width,this.tempTextCanvas.height),this.tempTextCanvasCtx.font=r+"px Arial",this.tempTextCanvasCtx.fillStyle=s,this.tempTextCanvasCtx.textBaseline="top",this.tempTextCanvasCtx.fillText(a,0,0),this.webglRender.drawDom(this.$videoElement.width,this.$videoElement.height,t,i,this.tempTextCanvas))}})}}class si{constructor(e){this.player=e,this.configList=[],this.shadowRoot=null,this.shadowRootRealDom=null,this.shadowRootInnerDom=null,this.scale=1,this._initDom(),this.player.debug.log("SingleWatermark","int")}destroy(){this.configList=[],this.shadowRootInnerDom=null,this.scale=1,this.shadowRoot&&(this.player.$container.removeChild(this.shadowRootRealDom),this.shadowRoot=null,this.shadowRootInnerDom=null),this.player.debug.log("SingleWatermark","destroy")}resize(){this._resizeDom()}_initDom(){var e=this.player.$container,t=null,i=document.createElement("div"),r=(i.setAttribute("style","pointer-events: none !important;display: block !important;"),t="function"==typeof i.attachShadow?i.attachShadow({mode:"open"}):i.shadowRoot||i,document.createElement("div")),s=(r.setAttribute("style","position: absolute; top: 0; left: 0; width: 0; height: 0;display: none;"),t.appendChild(r),e.children),a=Math.floor(Math.random()*(s.length-1));s[a]?e.insertBefore(i,s[a]):e.appendChild(i),this.shadowRootInnerDom=r,this.shadowRootRealDom=i,this.shadowRoot=t}update(e){this._removeDom();let t=[];Array.isArray(e)?t=e:Ct(e)&&t.push(e);e=t.map(e=>vt(e));this.configList=e,this._updateDom()}_resizeDom(){this.player.$container;const n=this.player.width,o=this.player.height,l=this.player.getVideoInfo();if(l&&0{var t=document.createElement("div");let i=null;e.image&&e.image.src?((i=document.createElement("img")).style.height="100%",i.style.width="100%",i.style.objectFit="contain",i.src=e.image.src):e.text&&e.text.content?i=document.createTextNode(e.text.content):(e.rect&&e.rect.color&&e.rect.width||e.html)&&(i=document.createElement("div")),i&&(t.appendChild(i),t.style.visibility="",t.style.position="absolute",t.style.display="block",t.style["-ms-user-select"]="none",t.style["-moz-user-select"]="none",t.style["-webkit-user-select"]="none",t.style["-o-user-select"]="none",t.style["user-select"]="none",t.style["-webkit-touch-callout"]="none",t.style["-webkit-tap-highlight-color"]="rgba(0,0,0,0)",t.style["-webkit-text-size-adjust"]="none",t.style["-webkit-touch-callout"]="none",t.style.opacity=e.opacity,u(e.left)&&(t.style.left=e.left+"px"),u(e.right)&&(t.style.right=e.right+"px"),u(e.top)&&(t.style.top=e.top+"px"),u(e.bottom)&&(t.style.bottom=e.bottom+"px"),e.backgroundColor&&(t.style.backgroundColor=e.backgroundColor),t.style.overflow="hidden",t.style.zIndex="9999999",e.image&&e.image.src?(t.style.width=e.image.width+"px",t.style.height=e.image.height+"px"):e.text&&e.text.content?(t.style.fontSize=e.text.fontSize+"px",t.style.color=e.text.color):e.rect&&e.rect.color&&e.rect.width?(t.style.width=e.rect.width+"px",t.style.height=e.rect.height+"px",t.style.borderWidth=e.rect.lineWidth+"px",t.style.borderStyle="solid",t.style.borderColor=e.rect.color):e.html&&(t.innerHTML=e.html,t.style.width=e.width+"px",t.style.height=e.height+"px"),this.shadowRootInnerDom.appendChild(t))})}remove(){this._removeDom()}_removeDom(){this.shadowRootInnerDom&&(this.shadowRootInnerDom.innerHTML="")}}class ai extends Jt{constructor(t){super(),this.player=t;var e=document.createElement("video"),i=document.createElement("canvas"),i=(e.muted=!0,e.style.position="absolute",e.style.top=0,e.style.left=0,this._delayPlay=!1,t.$container.appendChild(e),this.$videoElement=e,this.$canvasElement=i,this.canvasContext=i.getContext("2d"),this.mediaStream=null,this.vwriter=null,t.canVideoTrackWritter()&&mt()&&At()&&(this.trackGenerator=new MediaStreamTrackGenerator({kind:"video"}),this.mediaStream=new MediaStream([this.trackGenerator]),e.srcObject=this.mediaStream,this.vwriter=this.trackGenerator.writable.getWriter()),this.fixChromeVideoFlashBug(),this.resize(),this.eventListenList=[],this.tempContentList=[],this.contentWatermark=null,this.player.events)["proxy"],e=i(this.$videoElement,"canplay",()=>{this.player.debug.log("Video","canplay"),this._delayPlay&&this._play()}),r=i(this.$videoElement,"waiting",()=>{this.player.debug.log("Video","waiting")}),s=i(this.$videoElement,"loadedmetadata",()=>{this.player.debug.log("Video","loadedmetadata")}),a=i(this.$videoElement,"timeupdate",e=>{e=parseInt(e.timeStamp,10);(this.player._opt.isWebrtc||this.player._opt.isHls)&&this.player.emit(w.timeUpdate,e),t._opt.isWebrtc&&(t.handleRender(),t.updateStats({fps:!0}))}),i=i(this.$videoElement,"error",()=>{this.player.debug.error("Video","Error "+this.$videoElement.error.code+"; details: "+this.$videoElement.error.message)});this.eventListenList.push(e,r,a,i,s),this.player.debug.log("Video","init")}destroy(){var e;if(super.destroy(),this.eventListenList&&(this.eventListenList.forEach(e=>{e()}),this.eventListenList=[]),this.contentWatermark&&(this.contentWatermark.destroy(),this.contentWatermark=null),this.tempContentList=[],this.player._opt.videoRenderSupportScale&&this._isNeedAddBackDropFilter()&&((e=this.player.$container).style.backdropFilter="none",e.style.transform="none"),this.$canvasElement.height=0,this.$canvasElement.width=0,this.$canvasElement=null,this.canvasContext=null,this.$videoElement){this.$videoElement.pause(),this.$videoElement.currentTime=0,this.$videoElement.srcObject&&(this.$videoElement.srcObject=null,this.$videoElement.removeAttribute("srcObject")),this.$videoElement.src&&(this.$videoElement.src="",this.$videoElement.removeAttribute("src"));try{this.$videoElement.load()}catch(e){}this.player.$container.removeChild(this.$videoElement),this.$videoElement=null}this.trackGenerator&&(this.trackGenerator.stop(),this.trackGenerator=null),this.vwriter&&(this.vwriter.close(),this.vwriter=null),this._delayPlay=!1,this.mediaStream&&(this.mediaStream.getTracks().forEach(e=>e.stop()),this.mediaStream=null),this.off(),this.player.debug.log("Video","destroy")}fixChromeVideoFlashBug(){var e;this.player._opt.videoRenderSupportScale&&this._isNeedAddBackDropFilter()&&((e=this.player.$container).style.backdropFilter="blur(0px)",e.style.transform="translateZ(0)")}_isNeedAddBackDropFilter(){var e=ot().type.toLowerCase();return"chrome"===e||"edge"===e}isPause(){let e=!0;return e=this.$videoElement?this.$videoElement.paused:e}_getVideoReadyState(){let e=0;return e=this.$videoElement?this.$videoElement.readyState:e}_getVideoCurrentTime(){let e=0;return e=this.$videoElement?this.$videoElement.currentTime:e}play(){var e;this.$videoElement&&(e=this._getVideoReadyState(),this.player.debug.log("Video","play and readyState: "+e),0===e?(this.player.debug.warn("Video","readyState is 0 and set _delayPlay to true"),this._delayPlay=!0):this._play())}_play(){this.$videoElement&&this.$videoElement.play().then(()=>{this._delayPlay=!1,this.player.debug.log("Video","_play success"),setTimeout(()=>{this.isPlaying()||(this.player.debug.warn("Video","play failed and retry play"),this._play())},100)}).catch(e=>{this.player.debug.error("Video","_play error",e)})}pause(e){this.isPlaying()&&(e?this.$videoElement&&this.$videoElement.pause():setTimeout(()=>{this.$videoElement&&this.$videoElement.pause()},100))}clearView(){this.$videoElement&&(this.$videoElement.pause(),this.$videoElement.currentTime=0,this.$videoElement.src&&(this.$videoElement.src="",this.$videoElement.removeAttribute("src")),this.$videoElement.srcObject)&&(this.$videoElement.srcObject=null,this.$videoElement.removeAttribute("srcObject"))}screenshot(e,t,i,r){if(!this._canScreenshot())return this.player.debug.warn("Video","screenshot failed, video is not ready"),null;e=e||A(),r=r||o.download;let s=.92;!l[t]&&o[t]&&(r=t,t="png",i=void 0),"string"==typeof i&&(r=i,i=void 0),void 0!==i&&(s=Number(i));var i=this.$videoElement,a=this.$canvasElement,n=(a.width=i.videoWidth,a.height=i.videoHeight,this.canvasContext.drawImage(i,0,0,a.width,a.height),l[t]||l.png),i=a.toDataURL(n,s);if(this.canvasContext.clearRect(0,0,a.width,a.height),a.width=0,a.height=0,r===o.base64)return i;{const t=it(i);if(r===o.blob)return t;if(r===o.download){const i=n.split("/")[1];ei(t,e+"."+i)}}}screenshotWatermark(a){return new Promise((i,t)=>{if(Rt(a)&&(a={filename:a}),!this._canScreenshot())return this.player.debug.warn("Video","screenshot failed, video is not ready"),t("screenshot failed, video is not ready");var e=this.$videoElement,r=((a=a||{}).width=e.videoWidth,a.height=e.videoHeight,a.filename=a.filename||A(),a.format=a.format?l[a.format]:l.png,a.quality=Number(a.quality)||.92,a.type=a.type||o.download,this.$canvasElement);r.width=e.videoWidth,r.height=e.videoHeight,this.canvasContext.drawImage(e,0,0,r.width,r.height);const s=r.toDataURL(a.format,a.quality);this.canvasContext.clearRect(0,0,r.width,r.height),r.width=0,r.height=0,Et(s,a).then(e=>{if(a.type===o.base64)i(s);else{var t=it(e);if(a.type===o.blob)i(t);else if(a.type===o.download){i();const e=a.format.split("/")[1];ei(t,a.filename+"."+e)}}}).catch(e=>{t(e)})})}initCanvasViewSize(){this.resize()}clear(){var e=this.$videoElement,t=e.buffered,t=t.length?t.end(t.length-1):0;e.currentTime=t}render(t){if(this.vwriter){if(this.$videoElement.srcObject||(this.$videoElement.srcObject=this.mediaStream),this.$videoElement.paused&&this.player.debug.warn("Video","render error, video is paused"),this.player.videoTimestamp=t.ts||0,this.player.updateStats({fps:!0,ts:t.ts||0}),t.videoFrame)this.vwriter.write(t.videoFrame),Pt(t.videoFrame);else if(t.output){let e=t.output;this.player.faceDetectActive&&this.player.ai&&this.player.ai.faceDetector&&(e=this.player.ai.faceDetector.detect({width:this.videoInfo.width,height:this.videoInfo.height,data:t.output})),this.player.objectDetectActive&&this.player.ai&&this.player.ai.objectDetector&&(e=this.player.ai.objectDetector.detect({width:this.videoInfo.width,height:this.videoInfo.height,data:t.output}));try{r=e,s={format:"I420",codedWidth:this.videoInfo.width,codedHeight:this.videoInfo.height,timestamp:t.ts};var i=new VideoFrame(r,s);this.vwriter.write(i),Pt(i)}catch(t){this.player.debug.error("Video","render error",t),this.player.emitError(m.wasmUseVideoRenderError,t)}}this.doAddContentToWatermark()}else this.player.debug.warn("Video","render and this.vwriter is null");var r,s}resize(){let e=this.player.width,t=this.player.height;const i=this.player._opt,r=i.rotate;if(i.hasControl&&!i.controlAutoHide){const r=i.playType===v?48:38;g()&&this.player.fullscreen&&i.useWebFullScreen?e-=r:t-=r}this.$videoElement.width=e,this.$videoElement.height=t,270!==r&&90!==r||(this.$videoElement.width=t,this.$videoElement.height=e);let s=(e-this.$videoElement.width)/2,a=(t-this.$videoElement.height)/2,n="contain",o=(i.isResize||(n="fill"),i.isFullResize&&(n="none"),"");"none"===i.mirrorRotate&&r&&(o+=" rotate("+r+"deg)"),"level"===i.mirrorRotate?o+=" rotateY(180deg)":"vertical"===i.mirrorRotate&&(o+=" rotateX(180deg)"),this.player._opt.videoRenderSupportScale&&(this.$videoElement.style.objectFit=n),this.$videoElement.style.transform=o,this.$videoElement.style.left=s+"px",this.$videoElement.style.top=a+"px"}getType(){return $}isPlaying(){return this.$videoElement&&_(this.$videoElement.paused)&&_(this.$videoElement.ended)&&0!==this.$videoElement.playbackRate&&0!==this.$videoElement.readyState}_canScreenshot(){return this.$videoElement&&2<=this.$videoElement.readyState}addContentToCanvas(){this.tempContentList=0{var t={left:e.x,top:e.y};return"text"===e.type?t.text={content:e.text,fontSize:e.fontSize,color:e.color}:"rect"===e.type&&(t.rect={width:e.width,height:e.height,color:e.color,lineWidth:e.lineWidth}),t}),this.contentWatermark.update(e)):this.contentWatermark&&this.contentWatermark.remove()}getPlaybackQuality(){let e=null;var t;return this.$videoElement&&(e=b(this.$videoElement.getVideoPlaybackQuality)?{droppedVideoFrames:(t=this.$videoElement.getVideoPlaybackQuality()).droppedVideoFrames||t.corruptedVideoFrames,totalVideoFrames:t.totalVideoFrames,creationTime:t.creationTime}:{droppedVideoFrames:this.$videoElement.webkitDroppedFrameCount,totalVideoFrames:this.$videoElement.webkitDecodedFrameCount,creationTime:A()})&&(e.renderedVideoFrames=e.totalVideoFrames-e.droppedVideoFrames),e}}class ni extends ii{constructor(e){super(e),this.controlHeight=48,this.bufferList=[],this.playing=!1,this.playInterval=null,this.fps=1,this.preFps=1,this.streamFps=0,this.playbackRate=1,this._firstTimestamp=null,this._renderFps=0,this._startfpsTime=null,this._startFpsTimestamp=null,this._hasCalcFps=!1,this.player.on(w.playbackPause,e=>{e?(this.pause(),this.player.playback.isPlaybackPauseClearCache&&this.clear()):this.resume()}),this.player.debug.log("CanvasPlaybackLoader","init")}destroy(){this._stopSync(),this._firstTimestamp=null,this.playing=!1,this.playbackRate=1,this.fps=1,this.preFps=1,this.bufferList=[],this._renderFps=0,this._startfpsTime=null,this._startFpsTimestamp=null,this._hasCalcFps=!1,super.destroy(),this.player.debug.log("CanvasPlaybackLoader","destroy")}_initCanvasRender(){this.player._opt.useWebGPU?(this.renderType=ye,this._initContextGPU()):(this.renderType=Ae,this._initContextGl())}_sync(){this._stopSync(),this._doPlay(),this.playInterval=setInterval(()=>{this._doPlay()},this.fragDuration)}_doPlay(){var e;0 `+this.fps),this.player.playback.isUseFpsRender&&this._sync()):this.player.debug.log("CanvasPlaybackLoader","setFps, same fps "+e)}setStreamFps(e){this.player.debug.log("CanvasPlaybackLoader","setStreamFps",e),this._hasCalcFps=!0,this.streamFps=e,this.preFps=e,this.setFps(e)}setRate(e){e!==this.playbackRate&&(this.playbackRate=e,this.player.playback.isUseFpsRender)&&this._sync()}render$2(e){null===this._firstTimestamp&&(this._firstTimestamp=e.ts);var t={tfTs:e.ts-this._firstTimestamp,ts:e.ts,buffer:e.output};this.bufferList.push(t),this.startRender(),this.player.handleRender(),this.player.playback.updateStats({ts:e.ts,tfTs:t.tfTs})}startRender(){for(;!(this.bufferList.length<=0);){var e=this.bufferList.shift();this._doRender(e.buffer)}}pushData(e){null===this._firstTimestamp&&(this._firstTimestamp=e.ts);const t={tfTs:e.ts-this._firstTimestamp,ts:e.ts,buffer:e.output},i=this.player._opt.playbackConfig.isCacheBeforeDecodeForFpsRender;if(i||this.bufferSize>this.fps*this.playbackRate*2&&(this.player.debug.warn("CanvasPlaybackLoader","buffer size is "+this.bufferSize),this._doPlay()),this.bufferList.push(t),!this._hasCalcFps){const e=function(i){let r=i[0],s=null,e=1;var t;if(0{this.initVideo()},e):this.initVideo()}clearView(){this.contextGl.clear(this.contextGl.COLOR_BUFFER_BIT)}clear(){this.bufferList=[]}resume(){this.player.playback.isUseFpsRender&&this._sync(),this.playing=!0}pause(){this.player.playback.isUseFpsRender&&this._stopSync(),this.playing=!1}}class oi{constructor(e){return new(oi.getLoaderFactory(e._opt))(e)}static getLoaderFactory(e){return e.useMSE?e.mseUseCanvasRender?ri:ai:e.isHls?e.useCanvasRender?ri:ai:e.isWebrtc?ai:e.useWCS?!e.useOffscreen&&e.wcsUseVideoRender?ai:ri:e.playType===v?ni:e.wasmUseVideoRender&&!e.useOffscreen?ai:ri}}class li extends e{constructor(e){super(),this.bufferList=[],this.player=e,this.$audio=null,this.scriptNode=null,this.workletProcessorNode=null,this.hasInitScriptNode=!1,this.audioContext=new(window.AudioContext||window.webkitAudioContext)({sampleRate:48e3}),this.gainNode=this.audioContext.createGain();e=this.audioContext.createBufferSource();e.buffer=this.audioContext.createBuffer(1,1,22050),e.connect(this.audioContext.destination),e.noteOn?e.noteOn(0):e.start(0),this.audioBufferSourceNode=e,this.mediaStreamAudioDestinationNode=this.audioContext.createMediaStreamDestination(),this.gainNode.gain.value=0,this.playing=!1,this.audioSyncVideoOption={diff:null},this.audioInfo={encType:"",channels:"",sampleRate:""},this.init=!1,this.hasAudio=!1,this.audioResumeStateTimeout=null,this.on(w.videoSyncAudio,e=>{this.audioSyncVideoOption=e})}destroy(){this.closeAudio(),this.resetInit(),this.audioContext.close(),this.audioContext=null,this.gainNode=null,this.hasAudio=!1,this.playing=!1,this.scriptNode&&(this.scriptNode.onaudioprocess=et,this.scriptNode=null),this.workletProcessorNode&&(this.workletProcessorNode.port.onmessage=et,this.workletProcessorNode=null),this.audioResumeStateTimeout&&(clearTimeout(this.audioResumeStateTimeout),this.audioResumeStateTimeout=null),this.audioBufferSourceNode=null,this.mediaStreamAudioDestinationNode=null,this.hasInitScriptNode=!1,this.audioSyncVideoOption={diff:null},this.off()}resetInit(){this.audioInfo={encType:"",channels:"",sampleRate:""},this.init=!1}getAudioInfo(){return this.audioInfo}updateAudioInfo(e){e.encTypeCode&&(this.audioInfo.encType=fe[e.encTypeCode]),e.channels&&(this.audioInfo.channels=e.channels),e.sampleRate&&(this.audioInfo.sampleRate=e.sampleRate),this.audioInfo.sampleRate&&this.audioInfo.channels&&this.audioInfo.encType&&!this.init&&(this.player.emit(w.audioInfo,this.audioInfo),this.init=!0)}get isPlaying(){return this.playing}get isMute(){return 0===this.gainNode.gain.value}get volume(){return this.gainNode.gain.value}get bufferSize(){return this.bufferList.length}initScriptNode(){}initMobileScriptNode(){}initWorkletScriptNode(){}getEngineType(){return""}mute(e){e?(this.isMute||this.player.emit(w.mute,e),this.setVolume(0),this.clear()):(this.isMute&&this.player.emit(w.mute,e),this.setVolume(.5))}setVolume(e){e=parseFloat(e).toFixed(2),isNaN(e)||(this.audioEnabled(!0),e=y(e,0,1),this.gainNode.gain.value=e,this.player.emit(w.volumechange,this.player.volume))}closeAudio(){this.hasInitScriptNode&&(this.scriptNode&&this.scriptNode.disconnect(this.gainNode),this.workletProcessorNode&&this.workletProcessorNode.disconnect(this.gainNode),this.gainNode)&&(this.gainNode.disconnect(this.mediaStreamAudioDestinationNode),this.$audio||this.gainNode.disconnect(this.audioContext.destination)),this.clear()}audioEnabled(e){e?this.isStateSuspended()&&(this.audioContext.resume().then(()=>{this.player.emit(w.audioResumeState,{state:this.audioContext.state,isRunning:this.isStateRunning()})}),this.audioResumeStateTimeout=setTimeout(()=>{clearTimeout(this.audioResumeStateTimeout),this.audioResumeStateTimeout=null,this.isStateSuspended()&&this.player.emit(w.audioResumeState,{state:this.audioContext.state,isRunning:this.isStateRunning()})},1e3)):this.isStateRunning()&&this.audioContext.suspend()}isStateRunning(){return"running"===this.audioContext.state}isStateSuspended(){return"suspended"===this.audioContext.state}clear(){this.bufferList=[]}play(e,t){}pause(){this.audioSyncVideoOption={diff:null},this.playing=!1}resume(){this.playing=!0}setRate(e){}getAudioBufferSize(){return 0}}class ci{constructor(e,t,i,r){this.player=e,this.audio=t,this.channel=i,this.bufferSize=r}extract(t,e){var i=this.provide(e);for(let e=0;en){try{for(let e=0;ethis._frameCount)||(e=this.frameCount),this._frameCount-=e,this._position+=e}receiveSamples(e){var t=1=e-1)break e;var o=i+2*a;r[s+2*n]=(1-this.slopeCount)*t[o]+this.slopeCount*t[o+2],r[s+2*n+1]=(1-this.slopeCount)*t[o+1]+this.slopeCount*t[o+3],n+=1,this.slopeCount+=this._rate}return this.prevSampleL=t[i+2*e-2],this.prevSampleR=t[i+2*e-1],n}}function pi(){}class fi extends class{constructor(e){this._pipe=e}get pipe(){return this._pipe}get inputBuffer(){return this._pipe.inputBuffer}get outputBuffer(){return this._pipe.outputBuffer}fillInputBuffer(){throw new Error("fillInputBuffer() not overridden")}fillOutputBuffer(){let e=0this._position)throw new RangeError("New position may not be greater than current position");var t=this.outputBufferPosition-(this._position-e);if(t<0)throw new RangeError("New position falls outside of history buffer");this.outputBufferPosition=t,this._position=e}get sourcePosition(){return this._sourcePosition}set sourcePosition(e){this.clear(),this._sourcePosition=e}onEnd(){this.callback()}fillInputBuffer(){var e=0t&&(t=i,e=r);return e}seekBestOverlapPositionStereoQuick(){let t,i,r,s,a,n=0;for(this.preCalculateCorrelationReferenceStereo(),i=Number.MIN_VALUE,t=0,s=0,a=0;n<4;n+=1){let e=0;for(;gi[n][e]&&!((a=s+gi[n][e])>=this.seekLength);)(r=this.calculateCrossCorrelationStereo(2*a,this.refMidBuffer))>i&&(i=r,t=a),e+=1;s=t}return t}preCalculateCorrelationReferenceStereo(){let e,t,i=0;for(;i=this.sampleReq;){e=this.seekBestOverlapPosition(),this._outputBuffer.ensureAdditionalCapacity(this.overlapLength),this.overlap(Math.floor(e)),this._outputBuffer.put(this.overlapLength),0<(t=this.seekWindowLength-2*this.overlapLength)&&this._outputBuffer.putBuffer(this._inputBuffer,e+this.overlapLength,t);var t=this._inputBuffer.startIndex+2*(e+this.seekWindowLength-this.overlapLength);this.midBuffer.set(this._inputBuffer.vector.subarray(t,t+2*this.overlapLength)),this.skipFract+=this.nominalSkip,e=Math.floor(this.skipFract),this.skipFract-=e,this._inputBuffer.receive(e)}}}function Ai(e,t){return 1e-10<(t{e()}),this.eventListenList=[]),this.$audio&&(this.$audio.pause(),this.$audio.srcObject=null,this.$audio.parentNode&&this.$audio.parentNode.removeChild(this.$audio),this.$audio=null),this.processor&&(this.processor.destroy(),this.processor=null),this.rateProcessor&&(this.rateProcessor.destroy(),this.rateProcessor=null),this.scriptNodeInterval&&(clearInterval(this.scriptNodeInterval),this.scriptNodeInterval=null),this.defaultPlaybackRate=1,this.playbackRate=1,this.scriptStartTime=0,this.audioBufferSize=0,this.engineType=He,this.player.debug.log("AudioContext","destroy")}isAudioPlaying(){return this.$audio&&_(this.$audio.paused)&&_(this.$audio.ended)&&0!==this.$audio.playbackRate&&0!==this.$audio.readyState}_bindAudioProxy(){var e=this.player.events["proxy"],e=e(this.$audio,"canplay",()=>{this.player.debug.log("AudioContext","canplay"),this._delayPlay&&this._audioElementPlay()});this.eventListenList.push(e)}_getAudioElementReadyState(){let e=0;return e=this.$audio?this.$audio.readyState:e}audioElementPlay(){var e;this.$audio&&(e=this._getAudioElementReadyState(),this.player.debug.log("AudioContext","play and readyState: "+e),0!==e||Lt()&<()?this._audioElementPlay():(this.player.debug.warn("AudioContext","readyState is 0 and set _delayPlay to true"),this._delayPlay=!0))}_audioElementPlay(){this.$audio&&this.$audio.play().then(()=>{this._delayPlay=!1,this.player.debug.log("AudioContext","_audioElementPlay success"),setTimeout(()=>{this.isAudioPlaying()||(this.player.debug.warn("AudioContext","play failed and retry play"),this._audioElementPlay())},100),this.isAudioPlaying()&&(this.player.debug.log("AudioContext","play success and remove document click event listener"),document.removeEventListener("click",this._audioElementPlay.bind(this)))}).catch(e=>{this.player.debug.error("AudioContext","_audioElementPlay error",e),document.addEventListener("click",this._audioElementPlay.bind(this))})}getAudioBufferSize(){return this.audioBufferSize}get oneBufferDuration(){return this.audioBufferSize/this.audioContext.sampleRate*1e3}get isActiveEngineType(){return this.engineType===We}initProcessor(){this.processor=new ci(this.player,this,this.audioInfo.channels,this.audioBufferSize),this.rateProcessor=new bi(this.player,this,this.processor)}getAutoAudioEngineType(){let t=this.player._opt.audioEngine||He;var e=()=>{var e;t=Lt()&&(e=window.navigator.userAgent.toLowerCase(),/android/i.test(e))?We:(!lt()||!this.player._opt.supportLockScreenPlayAudio)&&Bt()?ze:He};return this.player._opt.audioEngine?this.player._opt.audioEngine===ze&&Bt()?t=ze:this.player._opt.audioEngine===We?t=We:this.player._opt.audioEngine===He?t=He:e():e(),t}getAudioBufferSizeByType(){var e=this.engineType,t=(this.player._opt.hasVideo,this.player._opt.weiXinInAndroidAudioBufferSize);return e!==ze&&e===We?t||4800:1024}initScriptNode(){this.playing=!0,this.hasInitScriptNode||(this.initProcessor(),this.engineType===ze?this.initWorkletScriptNode():this.engineType===We?this.initIntervalScriptNode():this.engineType===He&&this.initProcessScriptNode(),this.audioElementPlay())}getEngineType(){return this.engineType}isPlaybackRateSpeed(){return this.playbackRate>this.defaultPlaybackRate}initProcessScriptNode(){var e=this.audioContext.createScriptProcessor(this.audioBufferSize,0,this.audioInfo.channels);e.onaudioprocess=e=>{e=e.outputBuffer;this.handleScriptNodeCallback(e)},e.connect(this.gainNode),this.scriptNode=e,this.gainNode.connect(this.mediaStreamAudioDestinationNode),this.$audio?this.$audio.srcObject=this.mediaStreamAudioDestinationNode.stream:this.gainNode.connect(this.audioContext.destination),this.hasInitScriptNode=!0}initIntervalScriptNode(){this.scriptStartTime=0;var e=1e3*this.audioBufferSize/this.audioContext.sampleRate;this.scriptNodeInterval=setInterval(()=>{const e=this.audioContext.createBufferSource(),t=this.audioContext.createBuffer(this.audioInfo.channels,this.audioBufferSize,this.audioContext.sampleRate);this.handleScriptNodeCallback(t,()=>{this.scriptStartTime{"init"===e.data.message?(this.audioBufferSize=e.data.audioBufferSize,this.start=e.data.start,this.channels=e.data.channels,this.state=0,this.offset=0,this.samplesArray=[]):"stop"===e.data.message?(this.state=0,this.start=!1,this.offset=0,this.samplesArray=[]):"data"===e.data.message?this.samplesArray.push(e.data.buffer):"zero"===e.data.message&&this.samplesArray.push({left:new Float32Array(this.audioBufferSize).fill(0),right:new Float32Array(this.audioBufferSize).fill(0)})}}process(t,e,i){var r=e[0][0],s=e[0][1];if(0===this.offset&&this.port.postMessage({message:"beep"}),0===this.state)this.state=1;else if(1===this.state&&4<=this.samplesArray.length)this.state=2;else if(2===this.state){const t=this.samplesArray[0];for(let e=0;e{if(this.audioContext){let e=[1];2===this.audioInfo.channels&&(e=[1,1]),this.workletProcessorNode=new AudioWorkletNode(this.audioContext,"worklet-processor",{numberOfOutputs:this.audioInfo.channels,outputChannelCount:e}),this.workletProcessorNode.connect(this.gainNode),this.gainNode.connect(this.mediaStreamAudioDestinationNode),this.$audio?this.$audio.srcObject=this.mediaStreamAudioDestinationNode.stream:this.gainNode.connect(this.audioContext.destination),this.hasInitScriptNode=!0,this.workletProcessorNode.port.postMessage({message:"init",audioBufferSize:this.audioBufferSize,start:!0,channels:this.audioInfo.channels}),this.workletProcessorNode.port.onmessage=e=>{this.workletProcessorNode?this.audioContext?this.handleScriptNodeCallback(this.workletProcessorNode,null,!0):this.workletProcessorNode.port.postMessage({message:"zero"}):this.player.debug.error("AudioContext","workletProcessorNode is null")}}else this.player.debug.error("AudioContext","initWorkletScriptNode audioContext is null")})}handleScriptNodeCallback(e,t){let i,r=2i?(this.player.debug.warn("AudioContext",`bufferList length ${this.bufferList.length} more than ${i}, and drop`),this.clear()):(this.bufferList.length>t?(e=this.defaultPlaybackRate+.1,this.player.debug.warn("AudioContext",`bufferList length ${this.bufferList.length} more than ${t}, speed up, playbackRate is `+e)):this.bufferList.length{this.listenPlaybackPause(e)}),this.player.debug.log("AudioPlaybackContext","init")}destroy(){this.delayTimeout&&(clearTimeout(this.delayTimeout),this.delayTimeout=null),super.destroy(),this.player.debug.log("AudioPlaybackLoader","destroy")}listenPlaybackPause(e){e?(this.pause(),this.player.playback.isPlaybackPauseClearCache&&this.clear()):this.resume()}initScriptNodeDelay(){var e=this.player._opt.playbackDelayTime;0{this.initScriptNode()},e):this.initScriptNode()}setRate(e){e!==this.defaultPlaybackRate&&this.rateProcessor&&(this.player.debug.log("AudioPlaybackContext","setRate",e),this.defaultPlaybackRate=e,this.updatePlaybackRate(e))}}class Ti extends vi{constructor(e){super(e),this.TAG_NAME="AudioPlayerLoader",this.player.debug.log(this.TAG_NAME,"init")}destroy(){super.destroy(),this.player.debug.log(this.TAG_NAME,"destroy")}play(e,t){_(this.playing)||super.play(e,t)}pause(){this.player.debug.log(this.TAG_NAME,"pause"),this.playing=!1,this.clear()}resume(){this.player.debug.log(this.TAG_NAME,"resume"),this.playing=!0}}class Si{constructor(e){return new(Si.getLoaderFactory(e._opt))(e)}static getLoaderFactory(e){return e.playType===v?Ei:e.playType===U?Ti:e.isHls||e.isWebrtc?wi:vi}}class ki extends e{constructor(t){super(),this.player=t,this.playing=!1,this.abortController=new AbortController,this.streamRate=at(e=>{t.emit(w.kBps,(e/1024).toFixed(2))}),this.streamRateInterval=null,t.debug.log("FetchStream","init")}destroy(){this.abort(),this.off(),this.streamRate=null,this.stopStreamRateInterval(),this.player.debug.log("FetchStream","destroy")}startStreamRateInterval(){this.stopStreamRateInterval(),this.streamRateInterval=setInterval(()=>{this.streamRate&&this.streamRate(0)},1e3)}stopStreamRateInterval(){this.streamRateInterval&&(clearInterval(this.streamRateInterval),this.streamRateInterval=null)}fetchStream(e){var t=1{if(e.ok&&200<=e.status&&e.status<=299)if(this.emit(w.streamSuccess),this.startStreamRateInterval(),"undefined"!=typeof WritableStream)e.body.pipeTo(new WritableStream({write:e=>(this.streamRate&&this.streamRate(e.byteLength),r.dispatch(e)),close:()=>{r.close()},abort:e=>{r.close();var t=e.toString();-1===t.indexOf(Fe)&&-1===t.indexOf(je)&&e.name!==Ue&&(this.abort(),this.emit(m.fetchError,e))}}));else{this.player.debug.log("FetchStream","not support WritableStream and use getReader() to read stream");const t=e.body.getReader(),i=()=>{t.read().then(e=>{var{done:e,value:t}=e;e?r.close():(this.streamRate&&this.streamRate(t.byteLength),r.dispatch(t),i())}).catch(e=>{r.close();var t=e.toString();-1===t.indexOf(Fe)&&-1===t.indexOf(je)&&e.name!==Ue&&(this.abort(),this.emit(m.fetchError,e))})};i()}else this.player.debug.error("FetchStream",`fetch response status is ${e.status} and ok is ${e.ok} and emit error and next abort()`),this.abort(),this.emit(m.fetchError,`fetch response status is ${e.status} and ok is `+e.ok)}).catch(e=>{"AbortError"!==e.name&&(r.close(),this.abort(),this.emit(m.fetchError,e))})}abort(){this.abortController&&(this.abortController.abort(),this.abortController=null)}getStreamType(){return i}}class _i extends e{constructor(t){super(),this.player=t,this.socket=null,this.socketStatus=oe,this.wsUrl=null,this.socketDestroyFnList=[],this.streamRate=at(e=>{t.emit(w.kBps,(e/1024).toFixed(2))}),this.streamRateInterval=null,t.debug.log("WebsocketStream","init")}destroy(){this._closeWebSocket(),this.stopStreamRateInterval(),this.wsUrl=null,this.off(),this.player.debug.log("WebsocketStream","destroy")}startStreamRateInterval(){this.stopStreamRateInterval(),this.streamRateInterval=setInterval(()=>{this.streamRate&&this.streamRate(0)},1e3)}stopStreamRateInterval(){this.streamRateInterval&&(clearInterval(this.streamRateInterval),this.streamRateInterval=null)}_createWebSocket(){const e=this.player,{debug:t,events:{proxy:i},demux:r}=e;this.socket=new WebSocket(this.wsUrl),this.socket.binaryType="arraybuffer";var s=i(this.socket,"open",()=>{t.log("WebsocketStream","socket open"),this.socketStatus=le,this.emit(w.streamSuccess),this.player.emit(w.websocketOpen),this.startStreamRateInterval()}),a=i(this.socket,"message",e=>{this.streamRate&&this.streamRate(e.data.byteLength),this._handleMessage(e.data)}),n=i(this.socket,"close",e=>{t.log("WebsocketStream","socket close and code is "+e.code),1006===e.code&&t.error("WebsocketStream","socket close abnormally and code is "+e.code),r.close(),this.socketStatus="close",this.player.emit(w.websocketClose),this.emit(w.streamEnd)}),o=i(this.socket,"error",e=>{t.error("WebsocketStream","socket error",e),this.socketStatus="error",this.emit(m.websocketError,e),r.close(),t.log("WebsocketStream","socket error:",e.isTrusted?"websocket user aborted":"websocket error")});this.socketDestroyFnList.push(s,a,n,o)}_closeWebSocket(){this.socketDestroyFnList.forEach(e=>e()),this.socket&&(this.socket.close(1e3,"Client disconnecting"),this.socket=null),this.socketStatus=oe,this.streamRate=null}_handleMessage(e){var t=this.player["demux"];t?t.dispatch(e):this.player.debug.warn("WebsocketStream","websocket handle message demux is null")}fetchStream(e,t){this.player._times.streamStart=A(),this.wsUrl=e,this._createWebSocket()}sendMessage(e){this.socket?this.socketStatus===le?this.socket.send(e):this.player.debug.error("WebsocketStream","websocket send message error and socket status is "+this.socketStatus):this.player.debug.error("WebsocketStream","websocket send message socket is null")}resetFetchStream(){this._closeWebSocket(),this._createWebSocket()}getStreamType(){return F}}class Ci extends e{constructor(e){super(),(this.player=e).debug.log("HlsStream","init")}destroy(){this.off(),this.player.debug.log("HlsStream","destroy")}fetchStream(e){var t=this.player["hlsDecoder"];this.player._times.streamStart=A(),t.loadSource(e).then(()=>{this.player.debug.log("HlsStream","loadSource success"),this.emit(w.streamSuccess)}).catch(e=>{this.emit(m.hlsError,e)})}getStreamType(){return"hls"}}class Ri extends e{constructor(e){super(),this.player=e,this.webrctUrl=null,e.debug.log("WebrtcStream","init")}destroy(){this.webrctUrl=null,this.off(),this.player.debug.log("WebrtcStream","destroy")}fetchStream(e){var t=this.player["webrtc"];this.player._times.streamStart=A(),this.webrctUrl=e.replace("webrtc:",window.location.protocol),t.loadSource(this.webrctUrl).then(()=>{this.player.debug.log("WebrtcStream","loadSource success"),this.emit(w.streamSuccess)}).catch(e=>{this.emit(m.webrtcError,e)})}getStreamType(){return"webrtc"}}class Li extends e{constructor(t){super(),this.player=t,this.transport=null,this.wtUrl=null,this.streamRate=at(e=>{t.emit(w.kBps,(e/1024).toFixed(2))}),this.streamRateInterval=null,t.debug.log("WebTransportLoader","init")}destroy(){this.abort(),this.off(),this.player.debug.log("WebTransportLoader","destroy")}startStreamRateInterval(){this.stopStreamRateInterval(),this.streamRateInterval=setInterval(()=>{this.streamRate&&this.streamRate(0)},1e3)}stopStreamRateInterval(){this.streamRateInterval&&(clearInterval(this.streamRateInterval),this.streamRateInterval=null)}_createWebTransport(){const e=this.player,{events:{},demux:t}=e;try{this.transport=new WebTransport(this.wtUrl),this.transport.ready.then(()=>{this.emit(w.streamSuccess),this.startStreamRateInterval(),this.transport.createBidirectionalStream().then(e=>{e.readable.pipeTo(new WritableStream(t.input))})}).catch(e=>{this.player.debug.warn("WebTransportLoader","_createWebTransport-ready",e)})}catch(e){this.player.debug.warn("WebTransportLoader","_createWebTransport",e)}}fetchStream(e){this.player._times.streamStart=A(),this.wtUrl=e.replace(/^wt/,"https"),this._createWebTransport()}abort(){if(this.transport)try{this.transport.close(),this.transport=null}catch(e){this.transport=null}}getStreamType(){return"webTransport"}}class xi extends e{constructor(e){super(),this.player=e,this.workUrl=null,e.debug.log("WorkerStream","init")}destroy(){this.workUrl=null,this.off(),this.player.debug.log("WorkerStream","destroy")}sendMessage(e){this.player.decoderWorker.workerSendMessage(e)}fetchStream(e){this.workUrl=e,this.player._times.streamStart=A(),this.player.decoderWorker.workerFetchStream(e)}getStreamType(){var e=this.player._opt.protocol;return j+" "+(2===e?i:F)}}class Di{constructor(e){return new(Di.getLoaderFactory(e._opt))(e)}static getLoaderFactory(e){var{protocol:t,useWasm:i,playType:r}=e;return 2===t?r===U||r!==n||i&&!Dt(e)?xi:ki:1===t?r===U||r!==n||i&&!Dt(e)?xi:_i:3===t?Ci:4===t?Ri:5===t?Li:void 0}}var Ii=Xe(function(e){function T(i,s){if(!i)throw"First parameter is required.";s=new f(i,s=s||{type:"video"});var a=this;function t(e){e&&(s.initCallback=function(){e(),e=s.initCallback=null});var t=new g(i,s);(d=new t(i,s)).record(),c("recording"),s.disableLogs||console.log("Initialized recorderType:",d.constructor.name,"for output-type:",s.type)}function n(r){function e(e){if(d){Object.keys(d).forEach(function(e){"function"!=typeof d[e]&&(a[e]=d[e])});var t,i=d.blob;if(!i){if(!e)throw"Recording failed.";d.blob=i=e}if(i&&!s.disableLogs&&console.log(i.type,"->",y(i.size)),r){try{t=S.createObjectURL(i)}catch(e){}"function"==typeof r.call?r.call(a,t):r(t)}s.autoWriteToDisk&&l(function(e){var t={};t[s.type+"Blob"]=e,L.Store(t)})}else"function"==typeof r.call?r.call(a,""):r("")}r=r||function(){},d?"paused"===a.state?(a.resumeRecording(),setTimeout(function(){n(r)},1)):("recording"===a.state||s.disableLogs||console.warn('Recording state should be: "recording", however current state is: ',a.state),s.disableLogs||console.log("Stopped recording "+s.type+" stream."),"gif"!==s.type?d.stop(e):(d.stop(),e()),c("stopped")):u()}function o(e){postMessage((new FileReaderSync).readAsDataURL(e))}function l(t,e){if(!t)throw"Pass a callback function over getDataURL.";var i,r=(e||d||{}).blob;r?"undefined"==typeof Worker||navigator.mozGetUserMedia?((i=new FileReader).readAsDataURL(r),i.onload=function(e){t(e.target.result)}):((i=function(e){try{var t=S.createObjectURL(new Blob([e.toString(),"this.onmessage = function (eee) {"+e.name+"(eee.data);}"],{type:"application/javascript"})),i=new Worker(t);return S.revokeObjectURL(t),i}catch(e){}}(o)).onmessage=function(e){t(e.data)},i.postMessage(r)):(s.disableLogs||console.warn("Blob encoder did not finish its job yet."),setTimeout(function(){l(t,e)},1e3))}function r(e){e=e||0,"paused"!==a.state?"stopped"!==a.state&&(e>=a.recordingDuration?n(a.onRecordingStopped):(e+=1e3,setTimeout(function(){r(e)},1e3))):setTimeout(function(){r(e)},1e3)}function c(e){a&&(a.state=e,"function"==typeof a.onStateChanged.call?a.onStateChanged.call(a,e):a.onStateChanged(e))}var d,e='It seems that recorder is destroyed or "startRecording" is not invoked for '+s.type+" recorder.";function u(){!0!==s.disableLogs&&console.warn(e)}var h={startRecording:function(e){return s.disableLogs||console.log("RecordRTC version: ",a.version),(s=e?new f(i,e):s).disableLogs||console.log("started recording "+s.type+" stream."),d?(d.clearRecordedData(),d.record(),c("recording"),a.recordingDuration&&r()):t(function(){a.recordingDuration&&r()}),a},stopRecording:n,pauseRecording:function(){d?"recording"===a.state?(c("paused"),d.pause(),s.disableLogs||console.log("Paused recording.")):s.disableLogs||console.warn("Unable to pause the recording. Recording state: ",a.state):u()},resumeRecording:function(){d?"paused"===a.state?(c("recording"),d.resume(),s.disableLogs||console.log("Resumed recording.")):s.disableLogs||console.warn("Unable to resume the recording. Recording state: ",a.state):u()},initRecorder:t,setRecordingDuration:function(e,t){if(void 0===e)throw"recordingDuration is required.";if("number"!=typeof e)throw"recordingDuration must be a number.";return a.recordingDuration=e,a.onRecordingStopped=t||function(){},{onRecordingStopped:function(e){a.onRecordingStopped=e}}},clearRecordedData:function(){d?(d.clearRecordedData(),s.disableLogs||console.log("Cleared old recorded data.")):u()},getBlob:function(){if(d)return d.blob;u()},getDataURL:l,toURL:function(){if(d)return S.createObjectURL(d.blob);u()},getInternalRecorder:function(){return d},save:function(e){d?b(d.blob,e):u()},getFromDisk:function(e){d?T.getFromDisk(s.type,e):u()},setAdvertisementArray:function(e){s.advertisement=[];for(var t=e.length,i=0;i>=8;return new Uint8Array(t.reverse())}(e[i].id)),t.push(n(a)),t.push(r)}return new Blob(t,{type:"video/webm"})}function o(e){for(var t=0,i={};t 127 not supported";return[128|e.trackNum,e.timecode>>8,255&e.timecode,t].map(function(e){return String.fromCharCode(e)}).join("")+e.frame}({discardable:0,frame:e.data.slice(4),invisible:0,keyframe:1,lacing:0,trackNum:1,timecode:Math.round(i)});return i+=e.duration,{data:t,id:163}}))}(a,0,n)};r[1].data.push(l),a+=o}return c(r)}(e.map(function(e){var t=function(e){for(var t=e.RIFF[0].WEBP[0],i=t.indexOf("*"),r=0,s=[];r<4;r++)s[r]=t.charCodeAt(i+3+r);return{width:16383&(s[1]<<8|s[0]),height:16383&(s[3]<<8|s[2]),data:t,riff:e}}(o(atob(e.image.slice(23))));return t.duration=e.duration,t}));postMessage(e)}T.Whammy=_;var L={init:function(){var i,e,t,r=this;function s(e){e.createObjectStore(r.dataStoreName)}function a(){var e=i.transaction([r.dataStoreName],"readwrite");function t(t){e.objectStore(r.dataStoreName).get(t).onsuccess=function(e){r.callback&&r.callback(e.target.result,t)}}r.videoBlob&&e.objectStore(r.dataStoreName).put(r.videoBlob,"videoBlob"),r.gifBlob&&e.objectStore(r.dataStoreName).put(r.gifBlob,"gifBlob"),r.audioBlob&&e.objectStore(r.dataStoreName).put(r.audioBlob,"audioBlob"),t("audioBlob"),t("videoBlob"),t("gifBlob")}"undefined"!=typeof indexedDB&&void 0!==indexedDB.open?(e=this.dbName||location.href.replace(/\/|:|#|%|\.|\[|\]/g,""),(t=indexedDB.open(e,1)).onerror=r.onError,t.onsuccess=function(){(i=t.result).onerror=r.onError,i.setVersion&&1!==i.version?i.setVersion(1).onsuccess=function(){s(i),a()}:a()},t.onupgradeneeded=function(e){s(e.target.result)}):console.error("IndexedDB API are not available in this browser.")},Fetch:function(e){return this.callback=e,this.init(),this},Store:function(e){return this.audioBlob=e.audioBlob,this.videoBlob=e.videoBlob,this.gifBlob=e.gifBlob,this.init(),this},onError:function(e){console.error(JSON.stringify(e,null,"\t"))},dataStoreName:"recordRTC",dbName:null};function x(e,i){"undefined"==typeof GIFEncoder&&((t=document.createElement("script")).src="https://www.webrtc-experiment.com/gif-recorder.js",(document.body||document.documentElement).appendChild(t)),i=i||{};var t,r,s=e instanceof CanvasRenderingContext2D||e instanceof HTMLCanvasElement,a=(this.record=function(){"undefined"!=typeof GIFEncoder&&l?(s||(i.width||(i.width=r.offsetWidth||320),i.height||(i.height=r.offsetHeight||240),i.video||(i.video={width:i.width,height:i.height}),i.canvas||(i.canvas={width:i.width,height:i.height}),n.width=i.canvas.width||320,n.height=i.canvas.height||240,r.width=i.video.width||320,r.height=i.video.height||240),(d=new GIFEncoder).setRepeat(0),d.setDelay(i.frameRate||200),d.setQuality(i.quality||10),d.start(),"function"==typeof i.onGifRecordingStarted&&i.onGifRecordingStarted(),u=p(function e(t){if(!0!==h.clearedRecordedData){if(a)return setTimeout(function(){e(t)},100);u=p(e),t-c<90||(!s&&r.paused&&r.play(),s||o.drawImage(r,0,0,n.width,n.height),i.onGifPreview&&i.onGifPreview(n.toDataURL("image/png")),d.addFrame(o),c=t)}}),i.initCallback&&i.initCallback()):setTimeout(h.record,1e3)},!(this.stop=function(e){e=e||function(){},u&&m(u),this.blob=new Blob([new Uint8Array(d.stream().bin)],{type:"image/gif"}),e(this.blob),d.stream().bin=[]})),n=(this.pause=function(){a=!0},this.resume=function(){a=!1},this.clearRecordedData=function(){h.clearedRecordedData=!0,d&&(d.stream().bin=[])},this.name="GifRecorder",this.toString=function(){return this.name},document.createElement("canvas")),o=n.getContext("2d"),l=(s&&(e instanceof CanvasRenderingContext2D?n=(o=e).canvas:e instanceof HTMLCanvasElement&&(o=e.getContext("2d"),n=e)),!0);s||((r=document.createElement("video")).muted=!0,r.autoplay=!0,r.playsInline=!0,l=!1,r.onloadedmetadata=function(){l=!0},E(e,r),r.play());var c,d,u=null,h=this}function D(r,s){s=s||"multi-streams-mixer";var a=[],n=!1,o=document.createElement("canvas"),l=o.getContext("2d"),c=(o.style.opacity=0,o.style.position="absolute",o.style.zIndex=-1,o.style.top="-1000em",o.style.left="-1000em",o.className=s,(document.body||document.documentElement).appendChild(o),this.disableLogs=!1,this.frameInterval=10,this.width=360,this.height=240,this.useGainNode=!0,this),e=window.AudioContext;void 0===e&&("undefined"!=typeof webkitAudioContext&&(e=webkitAudioContext),"undefined"!=typeof mozAudioContext)&&(e=mozAudioContext);window.URL,"undefined"!=typeof navigator&&void 0===navigator.getUserMedia&&(void 0!==navigator.webkitGetUserMedia&&(navigator.getUserMedia=navigator.webkitGetUserMedia),void 0!==navigator.mozGetUserMedia)&&(navigator.getUserMedia=navigator.mozGetUserMedia);var d=window.MediaStream,u=(void 0!==(d=void 0===d&&"undefined"!=typeof webkitMediaStream?webkitMediaStream:d)&&void 0===d.prototype.stop&&(d.prototype.stop=function(){this.getTracks().forEach(function(e){e.stop()})}),{});function h(){var e,t,i;n||(e=a.length,t=!1,i=[],a.forEach(function(e){e.stream||(e.stream={}),e.stream.fullcanvas?t=e:i.push(e)}),t?(o.width=t.stream.width,o.height=t.stream.height):i.length?(o.width=1>>32-e,this._current_word<<=e,this._current_word_bits_left-=e,t):(t=this._current_word_bits_left?this._current_word:0,t>>>=32-this._current_word_bits_left,e=e-this._current_word_bits_left,this._fillCurrentWord(),e=Math.min(e,this._current_word_bits_left),i=this._current_word>>>32-e,this._current_word<<=e,this._current_word_bits_left-=e,t<>>e))return this._current_word<<=e,this._current_word_bits_left-=e,e;return this._fillCurrentWord(),e+this._skipLeadingZero()}readUEG(){var e=this._skipLeadingZero();return this.readBits(e+1)-1}readSEG(){var e=this.readUEG();return 1&e?e+1>>>1:-1*(e>>>1)}}class P{static _ebsp2rbsp(e){let t=e,i=t.byteLength,r=new Uint8Array(i),s=0;for(let e=0;e=this.buflen)return this.iserro=!0,0;this.iserro=!1,i=8>8-this.bufoff-i&255>>8-i),this.bufoff+=i,e-=i,8==this.bufoff&&(this.bufpos++,this.bufoff=0)}return t}look(e){var t=this.bufpos,i=this.bufoff,e=this.read(e);return this.bufpos=t,this.bufoff=i,e}read_golomb(){let e;for(e=0;0===this.read(1)&&!this.iserro;e++);return(1<>>24&255,t>>>16&255,t>>>8&255,255&t]),e=new Uint8Array(t+4);e.set(i,0),e.set(s.sps,4),s.sps=e}if(s.pps){const t=s.pps.byteLength,i=new Uint8Array([t>>>24&255,t>>>16&255,t>>>8&255,255&t]),e=new Uint8Array(t+4);e.set(i,0),e.set(s.pps,4),s.pps=e}return s}function Oi(e){var t=e.byteLength,i=new Uint8Array(4),t=(i[0]=t>>>24&255,i[1]=t>>>16&255,i[2]=t>>>8&255,i[3]=255&t,new Uint8Array(t+4));return t.set(i,0),t.set(e,4),t}function Fi(e){return 31&e[0]}function ji(e){return e===ge}function Ui(e){return 7!==e&&8!==e&&!ji(e)}const Ni=e=>{let t=e,i=t.byteLength,r=new Uint8Array(i),s=0;for(let e=0;e>6&3,s.general_tier_flag=e[1]>>5&1,s.general_profile_idc=31&e[1],s.general_profile_compatibility_flags=e[2]<<24|e[3]<<16|e[4]<<8|e[5],s.general_constraint_indicator_flags=e[6]<<24|e[7]<<16|e[8]<<8|e[9],s.general_constraint_indicator_flags=s.general_constraint_indicator_flags<<16|e[10]<<8|e[11],s.general_level_idc=e[12],s.min_spatial_segmentation_idc=(15&e[13])<<8|e[14],s.parallelismType=3&e[15],s.chromaFormat=3&e[16],s.bitDepthLumaMinus8=7&e[17],s.bitDepthChromaMinus8=7&e[18],s.avgFrameRate=e[19]<<8|e[20],s.constantFrameRate=e[21]>>6&3,s.numTemporalLayers=e[21]>>3&7,s.temporalIdNested=e[21]>>2&1,s.lengthSizeMinusOne=3&e[21];let t=e[22],i=e.slice(23);for(let e=0;e>1}class Hi extends e{constructor(e){super(),this.player=e,this.fileName="",this._isRecording=!1,this._recordingTimestamp=0,this.recordingInterval=null,this.sps=null,this.pps=null,this.vps=null,this.codecId=null,this.mdatBytesLength=0,this.metaInfo={codecWidth:0,codecHeight:0,presentWidth:0,presentHeight:0,refSampleDuration:0,timescale:1e3,avcc:null,videoType:""}}destroy(){this._reset()}get isH264(){return 7===this.codecId}get isH265(){return 12===this.codecId}setFileName(e){this.fileName=e}get isRecording(){return this._isRecording}get recording(){return this._isRecording}get recordTime(){return this._recordingTimestamp}startRecord(){}handleAddNaluTrack(e,t,i,r){}handleAddTrack(e){}stopRecordAndSave(){}startRecordingInterval(){}stopRecordingInterval(){this.recordingInterval&&clearInterval(this.recordingInterval),this.recordingInterval=null}getToTalByteLength(){}_reset(){this.fileName="",this._isRecording=!1,this._recordingTimestamp=0,this.stopRecordingInterval(),this.sps=null,this.pps=null,this.vps=null,this.codecId=null,this.mdatBytesLength=0}initMetaData(e,t){let i;var r=e.slice(5);if(this.codecId=t,this.metaInfo.avcc=r,7===t)i=Mi(r);else if(12===t){i=function(e){var t=23,i=e[23];if(32!=(63&i))return console.warn("parseHEVCDecoderVPSAndSPSAndPPS and vpsTag is "+i),{};t+=2,++t;var i=e[27]|e[26]<<8,r=(t+=2,e.slice(28,28+i)),s=e[t+=i];if(33!=(63&s))return console.warn("parseHEVCDecoderVPSAndSPSAndPPS and sps tag is "+s),{};t+=2;var s=e[1+ ++t]|e[t]<<8,a=e.slice(t+=2,t+s),n=e[t+=s];if(34!=(63&n))return console.warn("parseHEVCDecoderVPSAndSPSAndPPS and pps tag is "+n),{};t+=2;var n=e[1+ ++t]|e[t]<<8,e=e.slice(t+=2,t+n),t=new Uint8Array([s>>>24&255,s>>>16&255,s>>>8&255,255&s]),o=new Uint8Array([n>>>24&255,n>>>16&255,n>>>8&255,255&n]),l=new Uint8Array([i>>>24&255,i>>>16&255,i>>>8&255,255&i]),s=new Uint8Array(4+s),t=(s.set(t,0),s.set(a,4),new Uint8Array(4+n)),a=(t.set(o,0),t.set(e,4),new Uint8Array(4+i));return a.set(l,0),a.set(r,4),{sps:s,pps:t,vps:a}}(r);const t=Gi(e);i=Object.assign(i,t)}i&&(i.vps&&(this.vps=i.vps),i.pps&&(this.pps=i.pps),i.sps&&(this.sps=i.sps),i.presentWidth&&(this.metaInfo.presentWidth=i.presentWidth),i.presentHeight&&(this.metaInfo.presentHeight=i.presentHeight),i.codecWidth&&(this.metaInfo.codecWidth=i.codecWidth),i.codecHeight&&(this.metaInfo.codecHeight=i.codecHeight),i.timescale&&(this.metaInfo.timescale=i.timescale),i.refSampleDuration&&(this.metaInfo.refSampleDuration=i.refSampleDuration),i.videoType)&&(this.metaInfo.videoType=i.videoType)}}class Wi extends Hi{constructor(e){super(e),this.totalByteLength=0,this._startRecordingTimestamp=null,e.debug.log("RecorderRTC","init")}_reset(){super._reset(),this.totalByteLength=0,this._startRecordingTimestamp=null,this.recorder&&(this.recorder.destroy(),this.recorder=null)}destroy(){super.destroy(),this._reset(),this.player.debug.log("RecorderRTC","destroy")}getSeekableBlob(t){const s=new EBML.Reader,a=new EBML.Decoder,n=EBML.tools,i=new FileReader;return new Promise((r,e)=>{i.onload=function(e){a.decode(this.result).forEach(function(e){s.read(e)}),s.stop();var t=n.makeMetadataSeekable(s.metadatas,s.duration,s.cues),i=this.result.slice(s.metadataSize),t=new Blob([t,i],{type:"video/webm"});r(t)},i.readAsArrayBuffer(t)})}startRecord(){const t=this.player.debug,i={type:"video",mimeType:"video/webm;codecs=h264",timeSlice:1e3,onTimeStamp:e=>{t.log("RecorderRTC","record timestamp :"+e),null===this._startRecordingTimestamp&&(this._startRecordingTimestamp=e),this._recordingTimestamp=(e-this._startRecordingTimestamp)/1e3},ondataavailable:e=>{this.totalByteLength+=e.size,t.log("RecorderRTC","ondataavailable",e.size)},disableLogs:!this.player._opt.debug};try{let e=null;if(this.player.getRenderType()===V?e=this.player.video.$videoElement.captureStream(25):this.player.video.mediaStream?e=this.player.video.mediaStream:this.player._opt.isHls||this.player._opt.useMSE||this.player._opt.useWCS?e=this.player.video.$videoElement.captureStream(25):this.player._opt.isWebrtc&&(e=this.player.webrtc.videoStream),e){if(this.player.audio&&this.player.audio.mediaStreamAudioDestinationNode&&this.player.audio.mediaStreamAudioDestinationNode.stream&&!this.player.audio.isStateSuspended()&&this.player.audio.hasAudio&&this.player._opt.hasAudio){const t=this.player.audio.mediaStreamAudioDestinationNode.stream;if(0{this.player.emit(w.recordingTimestamp,this._recordingTimestamp)},1e3)}stopRecordAndSave(){let i=0{this.recorder&&this._isRecording||e("recorder is not ready"),r&&this.setFileName(r),this.recorder.stopRecording(()=>{this.player.debug.log("RecorderRTC","stop recording");var e=(this.fileName||A())+"."+N;if(this.recorder.getBlob(),"blob"===i){const i=this.recorder.getBlob();t(i),this.player.emit(w.recordBlob,i)}else t(),this.recorder.save(e);this.player.emit(w.recordEnd),this._reset(),this.player.emit(w.recording,!1)})})}getToTalByteLength(){return this.totalByteLength}getTotalDuration(){return this.recordTime}getType(){return N}initMetaData(){}}class h{static init(){for(var e in h.types={avc1:[],avcC:[],hvc1:[],hvcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[],".mp3":[],free:[],edts:[],elst:[],stss:[]},h.types)h.types.hasOwnProperty(e)&&(h.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);var t=h.constants={};t.FTYP=new Uint8Array([105,115,111,109,0,0,2,0,105,115,111,109,105,115,111,50,97,118,99,49,109,112,52,49,0,0,0,0]),t.STSD_PREFIX=new Uint8Array([0,0,0,0,0,0,0,1]),t.STTS=new Uint8Array([0,0,0,0,0,0,0,0]),t.STSC=t.STCO=t.STTS,t.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),t.HDLR_VIDEO=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),t.HDLR_AUDIO=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]),t.DREF=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),t.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),t.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])}static box(e){let t=8,i=null,r=Array.prototype.slice.call(arguments,1),s=r.length;for(let e=0;e>>24&255,i[1]=t>>>16&255,i[2]=t>>>8&255,i[3]=255&t,i.set(e,4);let a=8;for(let e=0;e=Math.pow(2,32)-1?(a=16,(n=new Uint8Array(i+a)).set(new Uint8Array([0,0,0,1]),0),n.set(h.types.mdat,4),n.set(new Uint8Array([i+8>>>56&255,i+8>>>48&255,i+8>>>40&255,i+8>>>32&255,i+8>>>24&255,i+8>>>16&255,i+8>>>8&255,i+8&255]),8)):((n=new Uint8Array(i+a))[0]=i+8>>>24&255,n[1]=i+8>>>16&255,n[2]=i+8>>>8&255,n[3]=i+8&255,n.set(h.types.mdat,4));for(let e=0;e>>24&255,e>>>16&255,e>>>8&255,255&e,t>>>24&255,t>>>16&255,t>>>8&255,255&t,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3]))}static trak(e){return h.box(h.types.trak,h.tkhd(e),h.mdia(e))}static tkhd(e){var t=e.id,i=e.duration,r=e.presentWidth,e=e.presentHeight;return h.box(h.types.tkhd,new Uint8Array([0,0,0,15,206,186,253,168,206,186,253,168,t>>>24&255,t>>>16&255,t>>>8&255,255&t,0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,r>>>8&255,255&r,0,0,e>>>8&255,255&e,0,0]))}static edts(e,t){return h.box(h.types.edts,h.elst(e,t))}static elst(t,i){let r=0;for(let e=0;e>>24&255,r>>>16&255,r>>>8&255,255&r,255,255,255,255,0,1,0,0,e>>>24&255,e>>>16&255,e>>>8&255,255&e,0,0,0,0,0,1,0,0]))}static mdia(e){return h.box(h.types.mdia,h.mdhd(e),h.hdlr(e),h.minf(e))}static mdhd(e){var t=e.timescale/e.refSampleDuration,e=t*e.duration/e.timescale;return h.box(h.types.mdhd,new Uint8Array([0,0,0,0,206,186,253,168,206,186,253,168,t>>>24&255,t>>>16&255,t>>>8&255,255&t,e>>>24&255,e>>>16&255,e>>>8&255,255&e,85,196,0,0]))}static hdlr(e){var t=h.constants.HDLR_VIDEO;return h.box(h.types.hdlr,t)}static minf(e){var t=h.box(h.types.vmhd,h.constants.VMHD);return h.box(h.types.minf,t,h.dinf(),h.stbl(e))}static dinf(){return h.box(h.types.dinf,h.box(h.types.dref,h.constants.DREF))}static stbl(e){var i=e.samples,r=[{No:1,num:0,sampleDelte:1,chunkNo:1,duration:i[0].duration}],s=[i[0].duration],a=i.length;for(let t=0;t>>24&255,i>>>16&255,i>>>8&255,255&i]),r=e.byteLength,s=new Uint8Array(r+8*i);s.set(e,0);for(let e=0;e>>24&255,t[e].num>>>16&255,t[e].num>>>8&255,255&t[e].num,t[e].sampleDelte>>>24&255,t[e].sampleDelte>>>16&255,t[e].sampleDelte>>>8&255,255&t[e].sampleDelte]),r),r+=8;return h.box(h.types.stts,s)}static stss(t){var i=[],r=t.length;for(let e=0;e>>24&255,s>>>16&255,s>>>8&255,255&s]),a=e.byteLength,n=new Uint8Array(a+4*s);n.set(e,0);for(let e=0;e>>24&255,i[e]>>>16&255,i[e]>>>8&255,255&i[e]]),a),a+=4;return h.box(h.types.stss,n)}static stsc(t){let i=t.length,e=new Uint8Array([0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i]),r=e.byteLength,s=new Uint8Array(r+12*i);s.set(e,0);for(let e=0;e>>24&255,a>>>16&255,a>>>8&255,255&a,n>>>24&255,n>>>16&255,n>>>8&255,255&n,o>>>24&255,o>>>16&255,o>>>8&255,255&o]),r),r+=12}return h.box(h.types.stsc,s)}static stsz(t){let i=t.length,e=new Uint8Array([0,0,0,0,0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i]),r=e.byteLength,s=new Uint8Array(r+4*i);s.set(e,0);for(let e=0;e>>24&255,a>>>16&255,a>>>8&255,255&a]),r),r+=4}return h.box(h.types.stsz,s)}static stco(e,t){t=t[0].chunkOffset;return h.box(h.types.stco,new Uint8Array([0,0,0,0,0,0,0,1,t>>>24&255,t>>>16&255,t>>>8&255,255&t]))}static stsd(e){return"audio"===e.type?"mp3"===e.codec?h.box(h.types.stsd,h.constants.STSD_PREFIX,h.mp3(e)):h.box(h.types.stsd,h.constants.STSD_PREFIX,h.mp4a(e)):"avc"===e.videoType?h.box(h.types.stsd,h.constants.STSD_PREFIX,h.avc1(e)):h.box(h.types.stsd,h.constants.STSD_PREFIX,h.hvc1(e))}static mp3(e){var t=e.channelCount,e=e.audioSampleRate,t=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t,0,16,0,0,0,0,e>>>8&255,255&e,0,0]);return h.box(h.types[".mp3"],t)}static mp4a(e){var t=e.channelCount,i=e.audioSampleRate,t=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t,0,16,0,0,0,0,i>>>8&255,255&i,0,0]);return h.box(h.types.mp4a,t,h.esds(e))}static esds(e){var e=e.config||[],t=e.length,t=new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e).concat([6,1,2]));return h.box(h.types.esds,t)}static avc1(e){var t=e.avcc,i=e.codecWidth,e=e.codecHeight,i=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,i>>>8&255,255&i,e>>>8&255,255&e,0,72,0,0,0,72,0,0,0,0,0,0,0,1,13,106,101,115,115,105,98,117,99,97,45,112,114,111,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,255,255]);return h.box(h.types.avc1,i,h.box(h.types.avcC,t))}static hvc1(e){var t=e.avcc,i=e.codecWidth,e=e.codecHeight,i=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,i>>>8&255,255&i,e>>>8&255,255&e,0,72,0,0,0,72,0,0,0,0,0,0,0,1,13,106,101,115,115,105,98,117,99,97,45,112,114,111,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,255,255]);return h.box(h.types.hvc1,i,h.box(h.types.hvcC,t))}static mvex(e){return h.box(h.types.mvex,h.trex(e))}static trex(e){e=e.id,e=new Uint8Array([0,0,0,0,e>>>24&255,e>>>16&255,e>>>8&255,255&e,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return h.box(h.types.trex,e)}static moof(e,t){return h.box(h.types.moof,h.mfhd(e.sequenceNumber),h.traf(e,t))}static mfhd(e){e=new Uint8Array([0,0,0,0,e>>>24&255,e>>>16&255,e>>>8&255,255&e]);return h.box(h.types.mfhd,e)}static traf(e,t){var i=e.id,i=h.box(h.types.tfhd,new Uint8Array([0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i])),t=h.box(h.types.tfdt,new Uint8Array([0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t])),r=h.sdtp(e),e=h.trun(e,r.byteLength+16+16+8+16+8+8);return h.box(h.types.traf,i,t,e,r)}static sdtp(e){var t=e.samples||[],i=t.length,r=new Uint8Array(4+i);for(let e=0;e>>24&255,r>>>16&255,r>>>8&255,255&r,(t+=8+e)>>>24&255,t>>>16&255,t>>>8&255,255&t],0);for(let e=0;e>>24&255,a>>>16&255,a>>>8&255,255&a,n>>>24&255,n>>>16&255,n>>>8&255,255&n,o.isLeading<<2|o.dependsOn,o.isDependedOn<<6|o.hasRedundancy<<4|o.isNonSync,0,0,l>>>24&255,l>>>16&255,l>>>8&255,255&l],12+16*e)}return h.box(h.types.trun,s)}static mdat(e){return h.box(h.types.mdat,e)}}h.init();class Vi extends Hi{constructor(e){super(e),this.tagName="recorderMP4",this.totalDuration=0,this.totalByteLength=0,this.bufferList=[],this.cacheTrack={},this.sequenceNumber=0,e.debug.log(this.tagName,"init")}destroy(){super.destroy(),this._reset(),this.player.debug.log(this.tagName,"destroy")}_reset(){super._reset(),this.totalDuration=0,this.totalByteLength=0,this.sequenceNumber=0,this.cacheTrack={},this.bufferList=[]}startRecord(){var e=this.player.debug;this._isRecording=!0,this.player.emit(w.recording,!0),e.log(this.tagName,"start recording"),this.player.emit(w.recordStart),this.startRecordingInterval()}startRecordingInterval(){this.stopRecordingInterval(),this.recordingInterval=window.setInterval(()=>{this.player.emit(w.recordingTimestamp,this.getTotalDuration())},1e3)}formatFmp4Track(e,t,i,r){return{id:1,sequenceNumber:++this.sequenceNumber,size:e.byteLength,dts:i,cts:r,isKeyframe:t,data:e,duration:0,flags:{isLeading:0,dependsOn:t?2:1,isDependedOn:t?1:0,hasRedundancy:0,isNonSync:t?0:1}}}handleAddNaluTrack(e,t,i,r){this.cacheTrack.id&&i>=this.cacheTrack.dts?(this.cacheTrack.duration=i-this.cacheTrack.dts,this.handleAddFmp4Track(this.cacheTrack)):this.cacheTrack={},this.cacheTrack=this.formatFmp4Track(e,t,i,r)}handleAddFmp4Track(e){if(this.isRecording)if(null!==this.sps&&null!==this.pps||!this.isH264)if(null!==this.sps&&null!==this.pps&&null!==this.vps||!this.isH265){var t=Object.assign({},e),i=(t.pts=t.dts+t.cts,t.data);if(t.isKeyframe)if(this.isH264){const e=new Uint8Array(this.sps.byteLength+this.pps.byteLength);e.set(this.sps,0),e.set(this.pps,this.sps.byteLength);var r=new Uint8Array(e.byteLength+i.byteLength);r.set(e,0),r.set(i,e.byteLength),t.data=r}else if(this.isH265){const e=new Uint8Array(this.sps.byteLength+this.pps.byteLength+this.vps.byteLength);e.set(this.vps,0),e.set(this.sps,this.vps.byteLength),e.set(this.pps,this.vps.byteLength+this.sps.byteLength);r=new Uint8Array(e.byteLength+i.byteLength);r.set(e,0),r.set(i,e.byteLength),t.data=r}t.size=t.data.byteLength,this.totalDuration+=t.duration,this.totalByteLength+=t.data.byteLength,t.duration=0,t.originalDts=t.dts,delete t.id,delete t.sequenceNumber,this.bufferList.push(t)}else this.player.debug.error(this.tagName,"handleAddFmp4Track, is h265 and this.sps or this.pps or this.vps is null ");else this.player.debug.error(this.tagName,"handleAddFmp4Track, is h264 and this.sps or this.pps is null ");else this.player.debug.error(this.tagName,"handleAddFmp4Track, isRecording is false ")}getTotalDuration(){return this.totalDuration/1e3}getType(){return p}getToTalByteLength(){return this.totalByteLength}stopRecordAndSave(){let e=0{if(!this.isRecording)return this.player.debug.error(this.tagName,"stop recording fail, isRecording is false "),r("stop recording fail, isRecording is false ");if(0===this.bufferList.length)return this.player.debug.error(this.tagName,"stop recording fail, this.bufferList.length is 0 "),r("stop recording fail, this.bufferList.length is 0 ");t&&this.setFileName(t);r={id:1,type:"video",sps:this.sps,pps:this.pps,samples:this.bufferList,sequenceNumber:this.bufferList.length,length:0,addSampleNum:1,duration:0,...this.metaInfo},r=h.generateInitSegment({timescale:1e3,duration:this.totalDuration},[r],this.totalByteLength),this.player.debug.log(this.tagName,"stop recording"),r=new Blob([r],{type:"application/octet-stream"});if("blob"===e)i(r),this.player.emit(w.recordBlob,r);else{i();{i=(this.fileName||A())+"."+p;let e=window.URL.createObjectURL(r),t=window.document.createElement("a");t.download=i,t.href=e;i=window.document.createEvent("MouseEvents");i.initEvent("click",!0,!0),t.dispatchEvent(i),setTimeout(()=>{window.URL.revokeObjectURL(e)},lt()?1e3:0)}}this._reset(),this.player.emit(w.recording,!1)})}}class $i{constructor(e){return new($i.getLoaderFactory(e._opt))(e)}static getLoaderFactory(e){return e.recordType===p&&(e.useWasm||e.useMSE||e.useWCS)?Vi:Wi}}class Ki{constructor(e){this.player=e,this.destroyResolve=null;let t=e._opt.decoder;if(0===(t=_(this.player._opt.useWasm)?e._opt.decoderAudio:t).indexOf("http")&&this.player._opt.isDecoderUseCDN){const e=new Blob([`importScripts("${t}")`],{type:"application/javascript"});t=window.URL.createObjectURL(e)}this.decoderWorker=new Worker(t),this._initDecoderWorker(),e.debug.log("decoderWorker","init"),e.on(w.visibilityChange,()=>{this.updateWorkConfig({key:"visibility",value:e.visibility})})}destroy(){return new Promise((e,t)=>{this.player.loaded?(this.player.debug.log("decoderWorker","has loaded and post message to destroy"),this.decoderWorker?(this.decoderWorker.postMessage({cmd:"close"}),this.destroyResolve=e):(this.player.debug.warn("decoderWorker","has loaded but decoderWorker is null and destroy directly"),this._destroy(),setTimeout(()=>{e()},0))):(this.player.debug.log("decoderWorker","has not loaded and destroy directly"),this._destroy(),setTimeout(()=>{e()},0))})}_destroy(){this.decoderWorker&&(this.decoderWorker.terminate(),this.decoderWorker=null),this.player.debug.log("decoderWorker","destroy"),this.destroyResolve&&(this.destroyResolve(),this.destroyResolve=null)}_initDecoderWorker(){const{debug:i,events:{}}=this.player;this.decoderWorker.onmessage=e=>{var t=e.data;switch(t.cmd){case Z:i.log("decoderWorker","onmessage:",Z),this.decoderWorker&&this._initWork(),this.player.loaded||this.player.emit(w.load),this.player.emit(w.decoderWorkerInit);break;case re:i.log("decoderWorker","onmessage:",re,t.code),this.player._times.decodeStart||(this.player._times.decodeStart=A()),this.player.video.updateVideoInfo({encTypeCode:t.code});break;case se:i.log("decoderWorker","onmessage:",se,t.codecId),this.player.recorder&&this.player.recorder.initMetaData(t.buffer,t.codecId);break;case ie:i.log("decoderWorker","onmessage:",ie,t.code),this.player.audio&&this.player.audio.updateAudioInfo({encTypeCode:t.code});break;case ee:(i.log("decoderWorker","onmessage:",ee,`width:${t.w},height:`+t.h),this.player.video.updateVideoInfo({width:t.w,height:t.h}),this.player._opt.openWebglAlignment||t.w/2%4==0||this.player.getRenderType()!==V)?(this.player.video.initCanvasViewSize(),this.player._opt.playType===v&&(this.player.video.initFps(),this.player.video.initVideoDelay())):this.player.emit(m.webglAlignmentError);break;case te:(i.log("decoderWorker","onmessage:",te,`channels:${t.channels},sampleRate:`+t.sampleRate),2=this.player._opt.playbackForwardMaxRateDecodeIFrame?i&&(this.player.debug.log("decoderWorker",`current rate is ${this.player.video.rate},only decode i frame`),this._decodeVideoNoDelay(e,t,i)):1===this.player.video.rate?this._decodeVideo(e,t,i):this._decodeVideoNoDelay(e,t,i))}_decodeVideo(e,t,i){t={type:2,ts:Math.max(t,0),isIFrame:i};this.decoderWorker.postMessage({cmd:"decode",buffer:e,options:t},[e.buffer])}_decodeVideoNoDelay(e,t,i){this.decoderWorker.postMessage({cmd:"videoDecode",buffer:e,ts:Math.max(t,0),isIFrame:i},[e.buffer])}decodeAudio(e,t){this.player._opt.playType===n?this.player._opt.useWCS||this.player._opt.useMSE?this._decodeAudioNoDelay(e,t):this._decodeAudio(e,t):this.player._opt.playType===v&&(1===this.player.video.rate?this._decodeAudio(e,t):this._decodeAudioNoDelay(e,t))}_decodeAudio(e,t){t={type:1,ts:Math.max(t,0)};this.decoderWorker.postMessage({cmd:"decode",buffer:e,options:t},[e.buffer])}_decodeAudioNoDelay(e,t){this.decoderWorker.postMessage({cmd:"audioDecode",buffer:e,ts:Math.max(t,0)},[e.buffer])}updateWorkConfig(e){this.decoderWorker&&this.decoderWorker.postMessage({cmd:"updateConfig",key:e.key,value:e.value})}workerFetchStream(e){var t=this.player["_opt"],t={protocol:t.protocol,isFlv:t.isFlv};this.decoderWorker.postMessage({cmd:"fetchStream",url:e,opt:JSON.stringify(t)})}clearWorkBuffer(){this.decoderWorker.postMessage({cmd:"clearBuffer",needClear:0e?1e3 timestamp is ${e} more than ${this.preDelayTimestamp-e}ms`):this.firstTimestamp?e&&(t=Date.now()-this.startTimestamp,(i=e-this.firstTimestamp)<=t?(this.isStreamTsMoreThanLocal=!1,this.delay=t-i):(this.isStreamTsMoreThanLocal=!0,this.delay=i-t)):(this.firstTimestamp=e,this.startTimestamp=Date.now(),this.delay=-1),this.preDelayTimestamp=e,this.delay):-1}getDelayNotUpdateDelay(t){if(t&&this.player.isDemuxDecodeFirstIIframeInit())if(this.preDelayTimestamp&&1e3 timestamp is ${t} more than ${this.preDelayTimestamp-t}ms`);else if(this.firstTimestamp){let e=-1;var i;return t&&(i=Date.now()-this.startTimestamp,t=t-this.firstTimestamp,e=t<=i?i-t:t-i),e}return-1}resetDelay(){this.firstTimestamp=null,this.startTimestamp=null,this.delay=-1,this.dropping=!1}resetAllDelay(){this.resetDelay(),this.preDelayTimestamp=null}initInterval(){this.player.debug.log("CommonDemux","init Interval"),this._loop(),this.stopId=setInterval(()=>{var e=(new Date).getTime(),e=(this.preLoopTimestamp||(this.preLoopTimestamp=e),e-this.preLoopTimestamp);100i+t&&r?this.hasIframeInBufferList()?(this.player.debug.warn("CommonDemux",`_loop delay is ${this.delay}, set dropping is true`),this.resetAllDelay(),this.dropping=!0):(this.bufferList.shift(),this._doDecoderDecode(e)):this.delay>t?(this.bufferList.shift(),this._doDecoderDecode(e)):this.delay<0&&this.player.debug.warn("CommonDemux",`_loop delay is ${this.delay} bufferList is `+this.bufferList);else-1!==this.delay&&this.player.debug.log("CommonDemux","loop() bufferList is empty and reset delay"),this.resetAllDelay()}_doDecode(e,t,i,r){var s=this.player,a={ts:i,cts:4=2*this.preTimestampDuration-5&&this.player.debug.warn("CommonDemux",`pushBuffer video ts is ${t.ts}, preTimestamp is ${this.preTimestamp}, diff is ${e} and preTimestampDuration is ${this.preTimestampDuration} maybe trigger black screen or flower screen`)}if(0s&&this.delay ${r+i}, bufferList is ${this.bufferList.length}, delay is ${this.delay} and dropBuffer$2()`),this.dropBuffer$2()):a>s&&this.delay ${r+i},bufferList is ${this.bufferList.length}, delay is ${this.delay} and dropBuffer$2()`),this.dropBuffer$2())}2===t.type&&(0k(e.isIFrame)&&2===e.type))?(this.bufferList=this.bufferList.slice(e),t=this.bufferList.shift(),i=this.getDelayNotUpdateDelay(t.ts),this._doDecoderDecode(t),this.isPushDropping=!1,this.player.debug.log("CommonDemux",`dropBuffer$2() iFrameIndex is ${e},and bufferList length is ${this.bufferList.length} and tempDelay is ${i} ,delay is ${this.delay} `)):this.isPushDropping=!1),0===this.bufferList.length&&(this.isPushDropping=!1)}clearBuffer(){var e=0this.player._opt.networkDelay&&this.player._opt.playType===n&&(this.player.debug.warn("CommonDemux",`delay is more than networkDelay and now dts:${e},start dts is ${this.bufferStartDts}, vs start is ${t},local diff is ${i} ,delay is ${r}, _opt.networkDelay is `+this.player._opt.networkDelay),this.player.emit(w.networkDelayTimeout,r)),this.player.updateStats({netBuf:r}))}calcIframeIntervalTimestamp(e){var t;null===this.preIframeTs?this.preIframeTs=e:this.preIframeTs2===e.type&&e.isIFrame)}getInputByteLength(){return 0}getIsStreamTsMoreThanLocal(){return this.isStreamTsMoreThanLocal}close(){}reset(){}}const qi=Symbol(32),Qi=Symbol(16),Yi=Symbol(8);class Xi{constructor(e){this.g=e,this.consumed=0,e&&(this.need=e.next().value)}setG(e){this.g=e,this.demand(e.next().value,!0)}consume(){this.buffer&&this.consumed&&(this.buffer.copyWithin(0,this.consumed),this.buffer=this.buffer.subarray(0,this.buffer.length-this.consumed),this.consumed=0)}demand(e,t){return t&&this.consume(),this.need=e,this.flush()}read(i){return e=this,l=function*(){return this.lastReadPromise&&(yield this.lastReadPromise),this.lastReadPromise=new Promise((t,e)=>{this.reject=e,this.resolve=e=>{delete this.lastReadPromise,delete this.resolve,delete this.need,t(e)},this.demand(i,!0)||null==(e=this.pull)||e.call(this,i)})},new(o=(o=n=void 0)||Promise)(function(i,t){function r(e){try{a(l.next(e))}catch(e){t(e)}}function s(e){try{a(l.throw(e))}catch(e){t(e)}}function a(e){var t;e.done?i(e.value):((t=e.value)instanceof o?t:new o(function(e){e(t)})).then(r,s)}a((l=l.apply(e,n||[])).next())});var e,n,o,l}readU32(){return this.read(qi)}readU16(){return this.read(Qi)}readU8(){return this.read(Yi)}close(){var e;this.g&&this.g.return(),this.buffer&&this.buffer.subarray(0,0),null!=(e=this.reject)&&e.call(this,new Error("EOF")),delete this.lastReadPromise}flush(){if(this.buffer&&this.need){let e=null;const r=this.buffer.subarray(this.consumed);let t=0;var i=e=>r.length<(t=e);if("number"==typeof this.need){if(i(this.need))return;e=r.subarray(0,t)}else if(this.need===qi){if(i(4))return;e=r[0]<<24|r[1]<<16|r[2]<<8|r[3]}else if(this.need===Qi){if(i(2))return;e=r[0]<<8|r[1]}else if(this.need===Yi){if(i(1))return;e=r[0]}else if("buffer"in this.need){if("byteOffset"in this.need){if(i(this.need.byteLength-this.need.byteOffset))return;new Uint8Array(this.need.buffer,this.need.byteOffset).set(r.subarray(0,t)),e=this.need}else if(this.g)return void this.g.throw(new Error("Unsupported type"))}else{if(i(this.need.byteLength))return;new Uint8Array(this.need).set(r.subarray(0,t)),e=this.need}return this.consumed+=t,this.g?this.demand(this.g.next(e).value,!0):this.resolve&&this.resolve(e),e}}write(e){if(e instanceof Uint8Array?this.malloc(e.length).set(e):"buffer"in e?this.malloc(e.byteLength).set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)):this.malloc(e.byteLength).set(new Uint8Array(e)),!this.g&&!this.resolve)return new Promise(e=>this.pull=e);this.flush()}writeU32(e){this.malloc(4).set([e>>24&255,e>>16&255,e>>8&255,255&e]),this.flush()}writeU16(e){this.malloc(2).set([e>>8&255,255&e]),this.flush()}writeU8(e){this.malloc(1)[0]=e,this.flush()}malloc(e){if(this.buffer){var t=this.buffer.length,i=t+e;if(i<=this.buffer.buffer.byteLength-this.buffer.byteOffset)this.buffer=new Uint8Array(this.buffer.buffer,this.buffer.byteOffset,i);else{const e=new Uint8Array(i);e.set(this.buffer),this.buffer=e}return this.buffer.subarray(t,i)}return this.buffer=new Uint8Array(e),this.buffer}}Xi.U32=qi,Xi.U16=Qi,Xi.U8=Yi;var Zi,er="application/json, text/javascript",tr="text/html",ir=/^(?:text|application)\/xml/i,rr=/^(.*?):[ \t]*([^\r\n]*)\r?$/gm,sr=/^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,ar=/^\s*$/,nr={},or={},lr="",cr={type:"GET",beforeSend:C,success:C,error:C,complete:C,context:null,xhr:function(){return new window.XMLHttpRequest},accepts:{json:er,xml:"application/xml, text/xml",html:tr,text:"text/plain","*":"*/".concat("*")},crossDomain:!1,timeout:0,username:null,password:null,processData:!0,promise:C,contentType:"application/x-www-form-urlencoded; charset=UTF-8"};function C(){}function R(e,t){"object"==typeof e&&(t=e,e=void 0);var i,r=mr({},t=t||{});for(i in cr)void 0===r[i]&&(r[i]=cr[i]);try{var s={},a=new Promise(function(e,t){s.resolve=e,s.reject=t});a.resolve=s.resolve,a.reject=s.reject,r.promise=a}catch(e){r.promise={resolve:C,reject:C}}var n,o,l,c,d,a=sr.exec(window.location.href.toLowerCase())||[],u=(r.url=((e||r.url||window.location.href)+"").replace(/#.*$/,"").replace(/^\/\//,a[1]+"//"),r.url),h=(r.crossDomain||(r.crossDomain=/^([\w-]+:)?\/\/([^\/]+)/.test(r.url)&&RegExp.$2!==window.location.href),r.dataType);if("jsonp"===h)return/=\?/.test(r.url)||(a=(r.jsonp||"callback")+"=?",r.url=fr(r.url,a)),l=(n=r).jsonpCallback||"jsonp"+br(),c=window.document.createElement("script"),d={abort:function(){l in window&&(window[l]=C)}},a=window.document.getElementsByTagName("head")[0]||window.document.documentElement,c.onerror=function(e){e=e,window.clearTimeout(o),d.abort(),hr(e.type,d,e.type,n),p()},window[l]=function(e){window.clearTimeout(o),dr(e,d,n),p()},gr(n),c.src=n.url.replace(/=\?/,"="+l),c.src=fr(c.src,"_="+(new Date).getTime()),c.async=!0,n.scriptCharset&&(c.charset=n.scriptCharset),a.insertBefore(c,a.firstChild),0>4]+Er[15&r])}return t.join("")}}),kr={16:10,24:12,32:14},_r=[1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145],D=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],Cr=[82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125],Rr=[3328402341,4168907908,4000806809,4135287693,4294111757,3597364157,3731845041,2445657428,1613770832,33620227,3462883241,1445669757,3892248089,3050821474,1303096294,3967186586,2412431941,528646813,2311702848,4202528135,4026202645,2992200171,2387036105,4226871307,1101901292,3017069671,1604494077,1169141738,597466303,1403299063,3832705686,2613100635,1974974402,3791519004,1033081774,1277568618,1815492186,2118074177,4126668546,2211236943,1748251740,1369810420,3521504564,4193382664,3799085459,2883115123,1647391059,706024767,134480908,2512897874,1176707941,2646852446,806885416,932615841,168101135,798661301,235341577,605164086,461406363,3756188221,3454790438,1311188841,2142417613,3933566367,302582043,495158174,1479289972,874125870,907746093,3698224818,3025820398,1537253627,2756858614,1983593293,3084310113,2108928974,1378429307,3722699582,1580150641,327451799,2790478837,3117535592,0,3253595436,1075847264,3825007647,2041688520,3059440621,3563743934,2378943302,1740553945,1916352843,2487896798,2555137236,2958579944,2244988746,3151024235,3320835882,1336584933,3992714006,2252555205,2588757463,1714631509,293963156,2319795663,3925473552,67240454,4269768577,2689618160,2017213508,631218106,1269344483,2723238387,1571005438,2151694528,93294474,1066570413,563977660,1882732616,4059428100,1673313503,2008463041,2950355573,1109467491,537923632,3858759450,4260623118,3218264685,2177748300,403442708,638784309,3287084079,3193921505,899127202,2286175436,773265209,2479146071,1437050866,4236148354,2050833735,3362022572,3126681063,840505643,3866325909,3227541664,427917720,2655997905,2749160575,1143087718,1412049534,999329963,193497219,2353415882,3354324521,1807268051,672404540,2816401017,3160301282,369822493,2916866934,3688947771,1681011286,1949973070,336202270,2454276571,201721354,1210328172,3093060836,2680341085,3184776046,1135389935,3294782118,965841320,831886756,3554993207,4068047243,3588745010,2345191491,1849112409,3664604599,26054028,2983581028,2622377682,1235855840,3630984372,2891339514,4092916743,3488279077,3395642799,4101667470,1202630377,268961816,1874508501,4034427016,1243948399,1546530418,941366308,1470539505,1941222599,2546386513,3421038627,2715671932,3899946140,1042226977,2521517021,1639824860,227249030,260737669,3765465232,2084453954,1907733956,3429263018,2420656344,100860677,4160157185,470683154,3261161891,1781871967,2924959737,1773779408,394692241,2579611992,974986535,664706745,3655459128,3958962195,731420851,571543859,3530123707,2849626480,126783113,865375399,765172662,1008606754,361203602,3387549984,2278477385,2857719295,1344809080,2782912378,59542671,1503764984,160008576,437062935,1707065306,3622233649,2218934982,3496503480,2185314755,697932208,1512910199,504303377,2075177163,2824099068,1841019862,739644986],Lr=[2781242211,2230877308,2582542199,2381740923,234877682,3184946027,2984144751,1418839493,1348481072,50462977,2848876391,2102799147,434634494,1656084439,3863849899,2599188086,1167051466,2636087938,1082771913,2281340285,368048890,3954334041,3381544775,201060592,3963727277,1739838676,4250903202,3930435503,3206782108,4149453988,2531553906,1536934080,3262494647,484572669,2923271059,1783375398,1517041206,1098792767,49674231,1334037708,1550332980,4098991525,886171109,150598129,2481090929,1940642008,1398944049,1059722517,201851908,1385547719,1699095331,1587397571,674240536,2704774806,252314885,3039795866,151914247,908333586,2602270848,1038082786,651029483,1766729511,3447698098,2682942837,454166793,2652734339,1951935532,775166490,758520603,3000790638,4004797018,4217086112,4137964114,1299594043,1639438038,3464344499,2068982057,1054729187,1901997871,2534638724,4121318227,1757008337,0,750906861,1614815264,535035132,3363418545,3988151131,3201591914,1183697867,3647454910,1265776953,3734260298,3566750796,3903871064,1250283471,1807470800,717615087,3847203498,384695291,3313910595,3617213773,1432761139,2484176261,3481945413,283769337,100925954,2180939647,4037038160,1148730428,3123027871,3813386408,4087501137,4267549603,3229630528,2315620239,2906624658,3156319645,1215313976,82966005,3747855548,3245848246,1974459098,1665278241,807407632,451280895,251524083,1841287890,1283575245,337120268,891687699,801369324,3787349855,2721421207,3431482436,959321879,1469301956,4065699751,2197585534,1199193405,2898814052,3887750493,724703513,2514908019,2696962144,2551808385,3516813135,2141445340,1715741218,2119445034,2872807568,2198571144,3398190662,700968686,3547052216,1009259540,2041044702,3803995742,487983883,1991105499,1004265696,1449407026,1316239930,504629770,3683797321,168560134,1816667172,3837287516,1570751170,1857934291,4014189740,2797888098,2822345105,2754712981,936633572,2347923833,852879335,1133234376,1500395319,3084545389,2348912013,1689376213,3533459022,3762923945,3034082412,4205598294,133428468,634383082,2949277029,2398386810,3913789102,403703816,3580869306,2297460856,1867130149,1918643758,607656988,4049053350,3346248884,1368901318,600565992,2090982877,2632479860,557719327,3717614411,3697393085,2249034635,2232388234,2430627952,1115438654,3295786421,2865522278,3633334344,84280067,33027830,303828494,2747425121,1600795957,4188952407,3496589753,2434238086,1486471617,658119965,3106381470,953803233,334231800,3005978776,857870609,3151128937,1890179545,2298973838,2805175444,3056442267,574365214,2450884487,550103529,1233637070,4289353045,2018519080,2057691103,2399374476,4166623649,2148108681,387583245,3664101311,836232934,3330556482,3100665960,3280093505,2955516313,2002398509,287182607,3413881008,4238890068,3597515707,975967766],xr=[1671808611,2089089148,2006576759,2072901243,4061003762,1807603307,1873927791,3310653893,810573872,16974337,1739181671,729634347,4263110654,3613570519,2883997099,1989864566,3393556426,2191335298,3376449993,2106063485,4195741690,1508618841,1204391495,4027317232,2917941677,3563566036,2734514082,2951366063,2629772188,2767672228,1922491506,3227229120,3082974647,4246528509,2477669779,644500518,911895606,1061256767,4144166391,3427763148,878471220,2784252325,3845444069,4043897329,1905517169,3631459288,827548209,356461077,67897348,3344078279,593839651,3277757891,405286936,2527147926,84871685,2595565466,118033927,305538066,2157648768,3795705826,3945188843,661212711,2999812018,1973414517,152769033,2208177539,745822252,439235610,455947803,1857215598,1525593178,2700827552,1391895634,994932283,3596728278,3016654259,695947817,3812548067,795958831,2224493444,1408607827,3513301457,0,3979133421,543178784,4229948412,2982705585,1542305371,1790891114,3410398667,3201918910,961245753,1256100938,1289001036,1491644504,3477767631,3496721360,4012557807,2867154858,4212583931,1137018435,1305975373,861234739,2241073541,1171229253,4178635257,33948674,2139225727,1357946960,1011120188,2679776671,2833468328,1374921297,2751356323,1086357568,2408187279,2460827538,2646352285,944271416,4110742005,3168756668,3066132406,3665145818,560153121,271589392,4279952895,4077846003,3530407890,3444343245,202643468,322250259,3962553324,1608629855,2543990167,1154254916,389623319,3294073796,2817676711,2122513534,1028094525,1689045092,1575467613,422261273,1939203699,1621147744,2174228865,1339137615,3699352540,577127458,712922154,2427141008,2290289544,1187679302,3995715566,3100863416,339486740,3732514782,1591917662,186455563,3681988059,3762019296,844522546,978220090,169743370,1239126601,101321734,611076132,1558493276,3260915650,3547250131,2901361580,1655096418,2443721105,2510565781,3828863972,2039214713,3878868455,3359869896,928607799,1840765549,2374762893,3580146133,1322425422,2850048425,1823791212,1459268694,4094161908,3928346602,1706019429,2056189050,2934523822,135794696,3134549946,2022240376,628050469,779246638,472135708,2800834470,3032970164,3327236038,3894660072,3715932637,1956440180,522272287,1272813131,3185336765,2340818315,2323976074,1888542832,1044544574,3049550261,1722469478,1222152264,50660867,4127324150,236067854,1638122081,895445557,1475980887,3117443513,2257655686,3243809217,489110045,2662934430,3778599393,4162055160,2561878936,288563729,1773916777,3648039385,2391345038,2493985684,2612407707,505560094,2274497927,3911240169,3460925390,1442818645,678973480,3749357023,2358182796,2717407649,2306869641,219617805,3218761151,3862026214,1120306242,1756942440,1103331905,2578459033,762796589,252780047,2966125488,1425844308,3151392187,372911126],Dr=[1667474886,2088535288,2004326894,2071694838,4075949567,1802223062,1869591006,3318043793,808472672,16843522,1734846926,724270422,4278065639,3621216949,2880169549,1987484396,3402253711,2189597983,3385409673,2105378810,4210693615,1499065266,1195886990,4042263547,2913856577,3570689971,2728590687,2947541573,2627518243,2762274643,1920112356,3233831835,3082273397,4261223649,2475929149,640051788,909531756,1061110142,4160160501,3435941763,875846760,2779116625,3857003729,4059105529,1903268834,3638064043,825316194,353713962,67374088,3351728789,589522246,3284360861,404236336,2526454071,84217610,2593830191,117901582,303183396,2155911963,3806477791,3958056653,656894286,2998062463,1970642922,151591698,2206440989,741110872,437923380,454765878,1852748508,1515908788,2694904667,1381168804,993742198,3604373943,3014905469,690584402,3823320797,791638366,2223281939,1398011302,3520161977,0,3991743681,538992704,4244381667,2981218425,1532751286,1785380564,3419096717,3200178535,960056178,1246420628,1280103576,1482221744,3486468741,3503319995,4025428677,2863326543,4227536621,1128514950,1296947098,859002214,2240123921,1162203018,4193849577,33687044,2139062782,1347481760,1010582648,2678045221,2829640523,1364325282,2745433693,1077985408,2408548869,2459086143,2644360225,943212656,4126475505,3166494563,3065430391,3671750063,555836226,269496352,4294908645,4092792573,3537006015,3452783745,202118168,320025894,3974901699,1600119230,2543297077,1145359496,387397934,3301201811,2812801621,2122220284,1027426170,1684319432,1566435258,421079858,1936954854,1616945344,2172753945,1330631070,3705438115,572679748,707427924,2425400123,2290647819,1179044492,4008585671,3099120491,336870440,3739122087,1583276732,185277718,3688593069,3772791771,842159716,976899700,168435220,1229577106,101059084,606366792,1549591736,3267517855,3553849021,2897014595,1650632388,2442242105,2509612081,3840161747,2038008818,3890688725,3368567691,926374254,1835907034,2374863873,3587531953,1313788572,2846482505,1819063512,1448540844,4109633523,3941213647,1701162954,2054852340,2930698567,134748176,3132806511,2021165296,623210314,774795868,471606328,2795958615,3031746419,3334885783,3907527627,3722280097,1953799400,522133822,1263263126,3183336545,2341176845,2324333839,1886425312,1044267644,3048588401,1718004428,1212733584,50529542,4143317495,235803164,1633788866,892690282,1465383342,3115962473,2256965911,3250673817,488449850,2661202215,3789633753,4177007595,2560144171,286339874,1768537042,3654906025,2391705863,2492770099,2610673197,505291324,2273808917,3924369609,3469625735,1431699370,673740880,3755965093,2358021891,2711746649,2307489801,218961690,3217021541,3873845719,1111672452,1751693520,1094828930,2576986153,757954394,252645662,2964376443,1414855848,3149649517,370555436],Ir=[1374988112,2118214995,437757123,975658646,1001089995,530400753,2902087851,1273168787,540080725,2910219766,2295101073,4110568485,1340463100,3307916247,641025152,3043140495,3736164937,632953703,1172967064,1576976609,3274667266,2169303058,2370213795,1809054150,59727847,361929877,3211623147,2505202138,3569255213,1484005843,1239443753,2395588676,1975683434,4102977912,2572697195,666464733,3202437046,4035489047,3374361702,2110667444,1675577880,3843699074,2538681184,1649639237,2976151520,3144396420,4269907996,4178062228,1883793496,2403728665,2497604743,1383856311,2876494627,1917518562,3810496343,1716890410,3001755655,800440835,2261089178,3543599269,807962610,599762354,33778362,3977675356,2328828971,2809771154,4077384432,1315562145,1708848333,101039829,3509871135,3299278474,875451293,2733856160,92987698,2767645557,193195065,1080094634,1584504582,3178106961,1042385657,2531067453,3711829422,1306967366,2438237621,1908694277,67556463,1615861247,429456164,3602770327,2302690252,1742315127,2968011453,126454664,3877198648,2043211483,2709260871,2084704233,4169408201,0,159417987,841739592,504459436,1817866830,4245618683,260388950,1034867998,908933415,168810852,1750902305,2606453969,607530554,202008497,2472011535,3035535058,463180190,2160117071,1641816226,1517767529,470948374,3801332234,3231722213,1008918595,303765277,235474187,4069246893,766945465,337553864,1475418501,2943682380,4003061179,2743034109,4144047775,1551037884,1147550661,1543208500,2336434550,3408119516,3069049960,3102011747,3610369226,1113818384,328671808,2227573024,2236228733,3535486456,2935566865,3341394285,496906059,3702665459,226906860,2009195472,733156972,2842737049,294930682,1206477858,2835123396,2700099354,1451044056,573804783,2269728455,3644379585,2362090238,2564033334,2801107407,2776292904,3669462566,1068351396,742039012,1350078989,1784663195,1417561698,4136440770,2430122216,775550814,2193862645,2673705150,1775276924,1876241833,3475313331,3366754619,270040487,3902563182,3678124923,3441850377,1851332852,3969562369,2203032232,3868552805,2868897406,566021896,4011190502,3135740889,1248802510,3936291284,699432150,832877231,708780849,3332740144,899835584,1951317047,4236429990,3767586992,866637845,4043610186,1106041591,2144161806,395441711,1984812685,1139781709,3433712980,3835036895,2664543715,1282050075,3240894392,1181045119,2640243204,25965917,4203181171,4211818798,3009879386,2463879762,3910161971,1842759443,2597806476,933301370,1509430414,3943906441,3467192302,3076639029,3776767469,2051518780,2631065433,1441952575,404016761,1942435775,1408749034,1610459739,3745345300,2017778566,3400528769,3110650942,941896748,3265478751,371049330,3168937228,675039627,4279080257,967311729,135050206,3635733660,1683407248,2076935265,3576870512,1215061108,3501741890],Pr=[1347548327,1400783205,3273267108,2520393566,3409685355,4045380933,2880240216,2471224067,1428173050,4138563181,2441661558,636813900,4233094615,3620022987,2149987652,2411029155,1239331162,1730525723,2554718734,3781033664,46346101,310463728,2743944855,3328955385,3875770207,2501218972,3955191162,3667219033,768917123,3545789473,692707433,1150208456,1786102409,2029293177,1805211710,3710368113,3065962831,401639597,1724457132,3028143674,409198410,2196052529,1620529459,1164071807,3769721975,2226875310,486441376,2499348523,1483753576,428819965,2274680428,3075636216,598438867,3799141122,1474502543,711349675,129166120,53458370,2592523643,2782082824,4063242375,2988687269,3120694122,1559041666,730517276,2460449204,4042459122,2706270690,3446004468,3573941694,533804130,2328143614,2637442643,2695033685,839224033,1973745387,957055980,2856345839,106852767,1371368976,4181598602,1033297158,2933734917,1179510461,3046200461,91341917,1862534868,4284502037,605657339,2547432937,3431546947,2003294622,3182487618,2282195339,954669403,3682191598,1201765386,3917234703,3388507166,0,2198438022,1211247597,2887651696,1315723890,4227665663,1443857720,507358933,657861945,1678381017,560487590,3516619604,975451694,2970356327,261314535,3535072918,2652609425,1333838021,2724322336,1767536459,370938394,182621114,3854606378,1128014560,487725847,185469197,2918353863,3106780840,3356761769,2237133081,1286567175,3152976349,4255350624,2683765030,3160175349,3309594171,878443390,1988838185,3704300486,1756818940,1673061617,3403100636,272786309,1075025698,545572369,2105887268,4174560061,296679730,1841768865,1260232239,4091327024,3960309330,3497509347,1814803222,2578018489,4195456072,575138148,3299409036,446754879,3629546796,4011996048,3347532110,3252238545,4270639778,915985419,3483825537,681933534,651868046,2755636671,3828103837,223377554,2607439820,1649704518,3270937875,3901806776,1580087799,4118987695,3198115200,2087309459,2842678573,3016697106,1003007129,2802849917,1860738147,2077965243,164439672,4100872472,32283319,2827177882,1709610350,2125135846,136428751,3874428392,3652904859,3460984630,3572145929,3593056380,2939266226,824852259,818324884,3224740454,930369212,2801566410,2967507152,355706840,1257309336,4148292826,243256656,790073846,2373340630,1296297904,1422699085,3756299780,3818836405,457992840,3099667487,2135319889,77422314,1560382517,1945798516,788204353,1521706781,1385356242,870912086,325965383,2358957921,2050466060,2388260884,2313884476,4006521127,901210569,3990953189,1014646705,1503449823,1062597235,2031621326,3212035895,3931371469,1533017514,350174575,2256028891,2177544179,1052338372,741876788,1606591296,1914052035,213705253,2334669897,1107234197,1899603969,3725069491,2631447780,2422494913,1635502980,1893020342,1950903388,1120974935],Br=[2807058932,1699970625,2764249623,1586903591,1808481195,1173430173,1487645946,59984867,4199882800,1844882806,1989249228,1277555970,3623636965,3419915562,1149249077,2744104290,1514790577,459744698,244860394,3235995134,1963115311,4027744588,2544078150,4190530515,1608975247,2627016082,2062270317,1507497298,2200818878,567498868,1764313568,3359936201,2305455554,2037970062,1047239e3,1910319033,1337376481,2904027272,2892417312,984907214,1243112415,830661914,861968209,2135253587,2011214180,2927934315,2686254721,731183368,1750626376,4246310725,1820824798,4172763771,3542330227,48394827,2404901663,2871682645,671593195,3254988725,2073724613,145085239,2280796200,2779915199,1790575107,2187128086,472615631,3029510009,4075877127,3802222185,4107101658,3201631749,1646252340,4270507174,1402811438,1436590835,3778151818,3950355702,3963161475,4020912224,2667994737,273792366,2331590177,104699613,95345982,3175501286,2377486676,1560637892,3564045318,369057872,4213447064,3919042237,1137477952,2658625497,1119727848,2340947849,1530455833,4007360968,172466556,266959938,516552836,0,2256734592,3980931627,1890328081,1917742170,4294704398,945164165,3575528878,958871085,3647212047,2787207260,1423022939,775562294,1739656202,3876557655,2530391278,2443058075,3310321856,547512796,1265195639,437656594,3121275539,719700128,3762502690,387781147,218828297,3350065803,2830708150,2848461854,428169201,122466165,3720081049,1627235199,648017665,4122762354,1002783846,2117360635,695634755,3336358691,4234721005,4049844452,3704280881,2232435299,574624663,287343814,612205898,1039717051,840019705,2708326185,793451934,821288114,1391201670,3822090177,376187827,3113855344,1224348052,1679968233,2361698556,1058709744,752375421,2431590963,1321699145,3519142200,2734591178,188127444,2177869557,3727205754,2384911031,3215212461,2648976442,2450346104,3432737375,1180849278,331544205,3102249176,4150144569,2952102595,2159976285,2474404304,766078933,313773861,2570832044,2108100632,1668212892,3145456443,2013908262,418672217,3070356634,2594734927,1852171925,3867060991,3473416636,3907448597,2614737639,919489135,164948639,2094410160,2997825956,590424639,2486224549,1723872674,3157750862,3399941250,3501252752,3625268135,2555048196,3673637356,1343127501,4130281361,3599595085,2957853679,1297403050,81781910,3051593425,2283490410,532201772,1367295589,3926170974,895287692,1953757831,1093597963,492483431,3528626907,1446242576,1192455638,1636604631,209336225,344873464,1015671571,669961897,3375740769,3857572124,2973530695,3747192018,1933530610,3464042516,935293895,3454686199,2858115069,1863638845,3683022916,4085369519,3292445032,875313188,1080017571,3279033885,621591778,1233856572,2504130317,24197544,3017672716,3835484340,3247465558,2220981195,3060847922,1551124588,1463996600],Mr=[4104605777,1097159550,396673818,660510266,2875968315,2638606623,4200115116,3808662347,821712160,1986918061,3430322568,38544885,3856137295,718002117,893681702,1654886325,2975484382,3122358053,3926825029,4274053469,796197571,1290801793,1184342925,3556361835,2405426947,2459735317,1836772287,1381620373,3196267988,1948373848,3764988233,3385345166,3263785589,2390325492,1480485785,3111247143,3780097726,2293045232,548169417,3459953789,3746175075,439452389,1362321559,1400849762,1685577905,1806599355,2174754046,137073913,1214797936,1174215055,3731654548,2079897426,1943217067,1258480242,529487843,1437280870,3945269170,3049390895,3313212038,923313619,679998e3,3215307299,57326082,377642221,3474729866,2041877159,133361907,1776460110,3673476453,96392454,878845905,2801699524,777231668,4082475170,2330014213,4142626212,2213296395,1626319424,1906247262,1846563261,562755902,3708173718,1040559837,3871163981,1418573201,3294430577,114585348,1343618912,2566595609,3186202582,1078185097,3651041127,3896688048,2307622919,425408743,3371096953,2081048481,1108339068,2216610296,0,2156299017,736970802,292596766,1517440620,251657213,2235061775,2933202493,758720310,265905162,1554391400,1532285339,908999204,174567692,1474760595,4002861748,2610011675,3234156416,3693126241,2001430874,303699484,2478443234,2687165888,585122620,454499602,151849742,2345119218,3064510765,514443284,4044981591,1963412655,2581445614,2137062819,19308535,1928707164,1715193156,4219352155,1126790795,600235211,3992742070,3841024952,836553431,1669664834,2535604243,3323011204,1243905413,3141400786,4180808110,698445255,2653899549,2989552604,2253581325,3252932727,3004591147,1891211689,2487810577,3915653703,4237083816,4030667424,2100090966,865136418,1229899655,953270745,3399679628,3557504664,4118925222,2061379749,3079546586,2915017791,983426092,2022837584,1607244650,2118541908,2366882550,3635996816,972512814,3283088770,1568718495,3499326569,3576539503,621982671,2895723464,410887952,2623762152,1002142683,645401037,1494807662,2595684844,1335535747,2507040230,4293295786,3167684641,367585007,3885750714,1865862730,2668221674,2960971305,2763173681,1059270954,2777952454,2724642869,1320957812,2194319100,2429595872,2815956275,77089521,3973773121,3444575871,2448830231,1305906550,4021308739,2857194700,2516901860,3518358430,1787304780,740276417,1699839814,1592394909,2352307457,2272556026,188821243,1729977011,3687994002,274084841,3594982253,3613494426,2701949495,4162096729,322734571,2837966542,1640576439,484830689,1202797690,3537852828,4067639125,349075736,3342319475,4157467219,4255800159,1030690015,1155237496,2951971274,1757691577,607398968,2738905026,499347990,3794078908,1011452712,227885567,2818666809,213114376,3034881240,1455525988,3414450555,850817237,1817998408,3092726480],Or=[0,235474187,470948374,303765277,941896748,908933415,607530554,708780849,1883793496,2118214995,1817866830,1649639237,1215061108,1181045119,1417561698,1517767529,3767586992,4003061179,4236429990,4069246893,3635733660,3602770327,3299278474,3400528769,2430122216,2664543715,2362090238,2193862645,2835123396,2801107407,3035535058,3135740889,3678124923,3576870512,3341394285,3374361702,3810496343,3977675356,4279080257,4043610186,2876494627,2776292904,3076639029,3110650942,2472011535,2640243204,2403728665,2169303058,1001089995,899835584,666464733,699432150,59727847,226906860,530400753,294930682,1273168787,1172967064,1475418501,1509430414,1942435775,2110667444,1876241833,1641816226,2910219766,2743034109,2976151520,3211623147,2505202138,2606453969,2302690252,2269728455,3711829422,3543599269,3240894392,3475313331,3843699074,3943906441,4178062228,4144047775,1306967366,1139781709,1374988112,1610459739,1975683434,2076935265,1775276924,1742315127,1034867998,866637845,566021896,800440835,92987698,193195065,429456164,395441711,1984812685,2017778566,1784663195,1683407248,1315562145,1080094634,1383856311,1551037884,101039829,135050206,437757123,337553864,1042385657,807962610,573804783,742039012,2531067453,2564033334,2328828971,2227573024,2935566865,2700099354,3001755655,3168937228,3868552805,3902563182,4203181171,4102977912,3736164937,3501741890,3265478751,3433712980,1106041591,1340463100,1576976609,1408749034,2043211483,2009195472,1708848333,1809054150,832877231,1068351396,766945465,599762354,159417987,126454664,361929877,463180190,2709260871,2943682380,3178106961,3009879386,2572697195,2538681184,2236228733,2336434550,3509871135,3745345300,3441850377,3274667266,3910161971,3877198648,4110568485,4211818798,2597806476,2497604743,2261089178,2295101073,2733856160,2902087851,3202437046,2968011453,3936291284,3835036895,4136440770,4169408201,3535486456,3702665459,3467192302,3231722213,2051518780,1951317047,1716890410,1750902305,1113818384,1282050075,1584504582,1350078989,168810852,67556463,371049330,404016761,841739592,1008918595,775550814,540080725,3969562369,3801332234,4035489047,4269907996,3569255213,3669462566,3366754619,3332740144,2631065433,2463879762,2160117071,2395588676,2767645557,2868897406,3102011747,3069049960,202008497,33778362,270040487,504459436,875451293,975658646,675039627,641025152,2084704233,1917518562,1615861247,1851332852,1147550661,1248802510,1484005843,1451044056,933301370,967311729,733156972,632953703,260388950,25965917,328671808,496906059,1206477858,1239443753,1543208500,1441952575,2144161806,1908694277,1675577880,1842759443,3610369226,3644379585,3408119516,3307916247,4011190502,3776767469,4077384432,4245618683,2809771154,2842737049,3144396420,3043140495,2673705150,2438237621,2203032232,2370213795],Fr=[0,185469197,370938394,487725847,741876788,657861945,975451694,824852259,1483753576,1400783205,1315723890,1164071807,1950903388,2135319889,1649704518,1767536459,2967507152,3152976349,2801566410,2918353863,2631447780,2547432937,2328143614,2177544179,3901806776,3818836405,4270639778,4118987695,3299409036,3483825537,3535072918,3652904859,2077965243,1893020342,1841768865,1724457132,1474502543,1559041666,1107234197,1257309336,598438867,681933534,901210569,1052338372,261314535,77422314,428819965,310463728,3409685355,3224740454,3710368113,3593056380,3875770207,3960309330,4045380933,4195456072,2471224067,2554718734,2237133081,2388260884,3212035895,3028143674,2842678573,2724322336,4138563181,4255350624,3769721975,3955191162,3667219033,3516619604,3431546947,3347532110,2933734917,2782082824,3099667487,3016697106,2196052529,2313884476,2499348523,2683765030,1179510461,1296297904,1347548327,1533017514,1786102409,1635502980,2087309459,2003294622,507358933,355706840,136428751,53458370,839224033,957055980,605657339,790073846,2373340630,2256028891,2607439820,2422494913,2706270690,2856345839,3075636216,3160175349,3573941694,3725069491,3273267108,3356761769,4181598602,4063242375,4011996048,3828103837,1033297158,915985419,730517276,545572369,296679730,446754879,129166120,213705253,1709610350,1860738147,1945798516,2029293177,1239331162,1120974935,1606591296,1422699085,4148292826,4233094615,3781033664,3931371469,3682191598,3497509347,3446004468,3328955385,2939266226,2755636671,3106780840,2988687269,2198438022,2282195339,2501218972,2652609425,1201765386,1286567175,1371368976,1521706781,1805211710,1620529459,2105887268,1988838185,533804130,350174575,164439672,46346101,870912086,954669403,636813900,788204353,2358957921,2274680428,2592523643,2441661558,2695033685,2880240216,3065962831,3182487618,3572145929,3756299780,3270937875,3388507166,4174560061,4091327024,4006521127,3854606378,1014646705,930369212,711349675,560487590,272786309,457992840,106852767,223377554,1678381017,1862534868,1914052035,2031621326,1211247597,1128014560,1580087799,1428173050,32283319,182621114,401639597,486441376,768917123,651868046,1003007129,818324884,1503449823,1385356242,1333838021,1150208456,1973745387,2125135846,1673061617,1756818940,2970356327,3120694122,2802849917,2887651696,2637442643,2520393566,2334669897,2149987652,3917234703,3799141122,4284502037,4100872472,3309594171,3460984630,3545789473,3629546796,2050466060,1899603969,1814803222,1730525723,1443857720,1560382517,1075025698,1260232239,575138148,692707433,878443390,1062597235,243256656,91341917,409198410,325965383,3403100636,3252238545,3704300486,3620022987,3874428392,3990953189,4042459122,4227665663,2460449204,2578018489,2226875310,2411029155,3198115200,3046200461,2827177882,2743944855],jr=[0,218828297,437656594,387781147,875313188,958871085,775562294,590424639,1750626376,1699970625,1917742170,2135253587,1551124588,1367295589,1180849278,1265195639,3501252752,3720081049,3399941250,3350065803,3835484340,3919042237,4270507174,4085369519,3102249176,3051593425,2734591178,2952102595,2361698556,2177869557,2530391278,2614737639,3145456443,3060847922,2708326185,2892417312,2404901663,2187128086,2504130317,2555048196,3542330227,3727205754,3375740769,3292445032,3876557655,3926170974,4246310725,4027744588,1808481195,1723872674,1910319033,2094410160,1608975247,1391201670,1173430173,1224348052,59984867,244860394,428169201,344873464,935293895,984907214,766078933,547512796,1844882806,1627235199,2011214180,2062270317,1507497298,1423022939,1137477952,1321699145,95345982,145085239,532201772,313773861,830661914,1015671571,731183368,648017665,3175501286,2957853679,2807058932,2858115069,2305455554,2220981195,2474404304,2658625497,3575528878,3625268135,3473416636,3254988725,3778151818,3963161475,4213447064,4130281361,3599595085,3683022916,3432737375,3247465558,3802222185,4020912224,4172763771,4122762354,3201631749,3017672716,2764249623,2848461854,2331590177,2280796200,2431590963,2648976442,104699613,188127444,472615631,287343814,840019705,1058709744,671593195,621591778,1852171925,1668212892,1953757831,2037970062,1514790577,1463996600,1080017571,1297403050,3673637356,3623636965,3235995134,3454686199,4007360968,3822090177,4107101658,4190530515,2997825956,3215212461,2830708150,2779915199,2256734592,2340947849,2627016082,2443058075,172466556,122466165,273792366,492483431,1047239e3,861968209,612205898,695634755,1646252340,1863638845,2013908262,1963115311,1446242576,1530455833,1277555970,1093597963,1636604631,1820824798,2073724613,1989249228,1436590835,1487645946,1337376481,1119727848,164948639,81781910,331544205,516552836,1039717051,821288114,669961897,719700128,2973530695,3157750862,2871682645,2787207260,2232435299,2283490410,2667994737,2450346104,3647212047,3564045318,3279033885,3464042516,3980931627,3762502690,4150144569,4199882800,3070356634,3121275539,2904027272,2686254721,2200818878,2384911031,2570832044,2486224549,3747192018,3528626907,3310321856,3359936201,3950355702,3867060991,4049844452,4234721005,1739656202,1790575107,2108100632,1890328081,1402811438,1586903591,1233856572,1149249077,266959938,48394827,369057872,418672217,1002783846,919489135,567498868,752375421,209336225,24197544,376187827,459744698,945164165,895287692,574624663,793451934,1679968233,1764313568,2117360635,1933530610,1343127501,1560637892,1243112415,1192455638,3704280881,3519142200,3336358691,3419915562,3907448597,3857572124,4075877127,4294704398,3029510009,3113855344,2927934315,2744104290,2159976285,2377486676,2594734927,2544078150],Ur=[0,151849742,303699484,454499602,607398968,758720310,908999204,1059270954,1214797936,1097159550,1517440620,1400849762,1817998408,1699839814,2118541908,2001430874,2429595872,2581445614,2194319100,2345119218,3034881240,3186202582,2801699524,2951971274,3635996816,3518358430,3399679628,3283088770,4237083816,4118925222,4002861748,3885750714,1002142683,850817237,698445255,548169417,529487843,377642221,227885567,77089521,1943217067,2061379749,1640576439,1757691577,1474760595,1592394909,1174215055,1290801793,2875968315,2724642869,3111247143,2960971305,2405426947,2253581325,2638606623,2487810577,3808662347,3926825029,4044981591,4162096729,3342319475,3459953789,3576539503,3693126241,1986918061,2137062819,1685577905,1836772287,1381620373,1532285339,1078185097,1229899655,1040559837,923313619,740276417,621982671,439452389,322734571,137073913,19308535,3871163981,4021308739,4104605777,4255800159,3263785589,3414450555,3499326569,3651041127,2933202493,2815956275,3167684641,3049390895,2330014213,2213296395,2566595609,2448830231,1305906550,1155237496,1607244650,1455525988,1776460110,1626319424,2079897426,1928707164,96392454,213114376,396673818,514443284,562755902,679998e3,865136418,983426092,3708173718,3557504664,3474729866,3323011204,4180808110,4030667424,3945269170,3794078908,2507040230,2623762152,2272556026,2390325492,2975484382,3092726480,2738905026,2857194700,3973773121,3856137295,4274053469,4157467219,3371096953,3252932727,3673476453,3556361835,2763173681,2915017791,3064510765,3215307299,2156299017,2307622919,2459735317,2610011675,2081048481,1963412655,1846563261,1729977011,1480485785,1362321559,1243905413,1126790795,878845905,1030690015,645401037,796197571,274084841,425408743,38544885,188821243,3613494426,3731654548,3313212038,3430322568,4082475170,4200115116,3780097726,3896688048,2668221674,2516901860,2366882550,2216610296,3141400786,2989552604,2837966542,2687165888,1202797690,1320957812,1437280870,1554391400,1669664834,1787304780,1906247262,2022837584,265905162,114585348,499347990,349075736,736970802,585122620,972512814,821712160,2595684844,2478443234,2293045232,2174754046,3196267988,3079546586,2895723464,2777952454,3537852828,3687994002,3234156416,3385345166,4142626212,4293295786,3841024952,3992742070,174567692,57326082,410887952,292596766,777231668,660510266,1011452712,893681702,1108339068,1258480242,1343618912,1494807662,1715193156,1865862730,1948373848,2100090966,2701949495,2818666809,3004591147,3122358053,2235061775,2352307457,2535604243,2653899549,3915653703,3764988233,4219352155,4067639125,3444575871,3294430577,3746175075,3594982253,836553431,953270745,600235211,718002117,367585007,484830689,133361907,251657213,2041877159,1891211689,1806599355,1654886325,1568718495,1418573201,1335535747,1184342925];function Nr(e){for(var t=[],i=0;i>2][t%4]=a[t],this._Kd[e-i][t%4]=a[t];for(var n,o=0,l=s;l>16&255]<<24^D[n>>8&255]<<16^D[255&n]<<8^D[n>>24&255]^_r[o]<<24,o+=1,8!=s)for(t=1;t>8&255]<<8^D[n>>16&255]<<16^D[n>>24&255]<<24,t=s/2+1;t>2][d=l%4]=a[t],this._Kd[e-c][d]=a[t++],l++}for(var c=1;c>24&255]^Fr[n>>16&255]^jr[n>>8&255]^Ur[255&n]},r.prototype.encrypt=function(e){if(16!=e.length)throw new Error("invalid plaintext size (must be 16 bytes)");for(var t=this._Ke.length-1,i=[0,0,0,0],r=Nr(e),s=0;s<4;s++)r[s]^=this._Ke[0][s];for(var a=1;a>24&255]^Lr[r[(s+1)%4]>>16&255]^xr[r[(s+2)%4]>>8&255]^Dr[255&r[(s+3)%4]]^this._Ke[a][s];r=i.slice()}for(var n,o=L(16),s=0;s<4;s++)n=this._Ke[t][s],o[4*s]=255&(D[r[s]>>24&255]^n>>24),o[4*s+1]=255&(D[r[(s+1)%4]>>16&255]^n>>16),o[4*s+2]=255&(D[r[(s+2)%4]>>8&255]^n>>8),o[4*s+3]=255&(D[255&r[(s+3)%4]]^n);return o},r.prototype.decrypt=function(e){if(16!=e.length)throw new Error("invalid ciphertext size (must be 16 bytes)");for(var t=this._Kd.length-1,i=[0,0,0,0],r=Nr(e),s=0;s<4;s++)r[s]^=this._Kd[0][s];for(var a=1;a>24&255]^Pr[r[(s+3)%4]>>16&255]^Br[r[(s+2)%4]>>8&255]^Mr[255&r[(s+1)%4]]^this._Kd[a][s];r=i.slice()}for(var n,o=L(16),s=0;s<4;s++)n=this._Kd[t][s],o[4*s]=255&(Cr[r[s]>>24&255]^n>>24),o[4*s+1]=255&(Cr[r[(s+3)%4]>>16&255]^n>>16),o[4*s+2]=255&(Cr[r[(s+2)%4]>>8&255]^n>>8),o[4*s+3]=255&(Cr[255&r[(s+1)%4]]^n);return o},Gr.prototype.encrypt=function(e){if((e=a(e)).length%16!=0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var t=L(e.length),i=L(16),r=0;rNumber.MAX_SAFE_INTEGER)throw new Error("integer value out of safe range");for(var t=15;0<=t;--t)this._counter[t]=e%256,e=parseInt(e/256)},Vr.prototype.setBytes=function(e){if(16!=(e=a(e,!0)).length)throw new Error("invalid counter bytes size (must be 16 bytes)");this._counter=e},Vr.prototype.increment=function(){for(var e=15;0<=e;e--){if(255!==this._counter[e]){this._counter[e]++;break}this._counter[e]=0}};$r.prototype.decrypt=$r.prototype.encrypt=function(e){for(var t=a(e,!0),i=0;i>4&15,c=1==t;if(1!=t&&2!=t&&r.debug.warn("FlvDemux",`frameType is ${t} is not keyFrame or interFrame`),c&&this.calcIframeIntervalTimestamp(a),0s)break;var n=t[a+4];if(1==(n&=31)||5==n){const s=t.slice(a+4+2,a+4+o);let e=new Kr.ModeOfOperation.ctr(i,new Kr.Counter(r));n=e.decrypt(s);e=null,t.set(n,a+4+2)}a=a+4+o}var o;return t}(n,r._opt.cryptoKey,r._opt.cryptoIV):r.debug.error("FlvDemux",`cryptoKey.length is ${r._opt.cryptoKey&&r._opt.cryptoKey.byteLength} or cryptoIV.length is ${r._opt.cryptoIV&&r._opt.cryptoIV.byteLength} null`)),this._doDecode(e,2,a,c,o)}}break;default:r.debug.log("FlvDemux","demux() type is "+l)}}}close(){this.input=null}getInputByteLength(){let e=0;return e=this.input&&this.input.buffer?this.input.buffer.byteLength:e}}class qr extends Ji{constructor(e){super(e),e.debug.log("M7sDemux","init")}destroy(){super.destroy(),this.player.debug.log("M7sDemux","destroy")}dispatch(t){const i=this.player,r=new DataView(t),s=r.getUint8(0),a=r.getUint32(1,!1);switch(s){case 1:if(i._opt.hasAudio){const r=new Uint8Array(t,5);i.updateStats({abps:r.byteLength}),0>4==1;let e=a;this.player._opt.useMSE&&c(this.player.mseDecoder.firstRenderTime)&&(e=a-this.player.mseDecoder.firstRenderTime),i.updateStats({vbps:n.byteLength,dts:e}),0>1)&&33!=i&&34!=i?t:he}(t)),this.streamVideoType===ue){const e=this.handleAddNaluStartCode(t),i=this.extractNALu(e);if(0===i.length)this.player.debug.warn(this.TAG_NAME,"handleVideoNalu","naluList.length === 0");else{const r=[];if(i.forEach(e=>{var t=Fi(e);8===t||7===t?this.handleVideoH264Nalu(e):Ui(t)&&r.push(e)}),1===r.length)this.handleVideoH264Nalu(r[0]);else{const e=function(t){if(0===t.length)return!1;var i=Fi(t[0]);for(let e=1;e{this.handleVideoH264Nalu(e)})}}}else this.streamVideoType===he?34===zi(t)?this.extractH265PPS(t):this.handleVideoH265Nalu(t):this.player.debug.error(this.TAG_NAME," this.streamVideoType is null")}extractH264PPS(e){e=this.handleAddNaluStartCode(e);this.extractNALu(e).forEach(e=>{ji(Fi(e))?this.extractH264SEI(e):this.handleVideoH264Nalu(e)})}extractH265PPS(e){e=this.handleAddNaluStartCode(e);this.extractNALu(e).forEach(e=>{39===zi(e)?this.extractH265SEI(e):this.handleVideoH265Nalu(e)})}extractH264SEI(e){e=this.handleAddNaluStartCode(e);this.extractNALu(e).forEach(e=>{this.handleVideoH264Nalu(e)})}extractH265SEI(e){e=this.handleAddNaluStartCode(e);this.extractNALu(e).forEach(e=>{this.handleVideoH265Nalu(e)})}handleAddNaluStartCode(e){var t=[0,0,0,1],i=new Uint8Array(e.length+t.length);return i.set(t),i.set(e,t.length),i}handleAudioAACNalu(t){if(t&&!(t.byteLength<1)){this.streamAudioType||(this.streamAudioType=pe.AAC);let e=new Uint8Array(t);var i=e.slice(0,7);if(e=e.slice(7),!this.isSendAACSeqHeader){const t=(192&i[2])>>6,e=(60&i[2])>>2,r=(1&i[2])<<2|(192&i[3])>>6,s=new Uint8Array([175,0,t<<3|(14&e)>>1,(1&e)<<7|r<<3]);this.isSendAACSeqHeader=!0,this._doDecode(s,1,0,!1,0)}const r=this.getNaluAudioDts(),s=new Uint8Array(e.length+2);s.set([175,1],0),s.set(e,2),this._doDecode(s,1,r,!1,0)}}handleAudioG711ANalu(e){var t,i;!e||e.byteLength<1||(this.streamAudioType||(this.streamAudioType=pe.ALAW),e=new Uint8Array(e),t=this.getNaluAudioDts(),(i=new Uint8Array(e.length+1)).set([114],0),i.set(e,1),this._doDecode(i,1,t,!1,0))}handleAudioG711UNalu(e){var t,i;!e||e.byteLength<1||(this.streamAudioType||(this.streamAudioType=pe.MULAW),e=new Uint8Array(e),t=this.getNaluAudioDts(),(i=new Uint8Array(e.length+1)).set([130],0),i.set(e,1),this._doDecode(i,1,t,!1,0))}handleVideoH264Nalu(e){var t,i,r,s=Fi(e);switch(s){case 7:this.sps=e;break;case 8:this.pps=e}if(this.isSendSeqHeader)if(Ui(s)){this.player._times.demuxStart||(this.player._times.demuxStart=A());const a=5===s,n=this.getNaluDts(),o=(t=e,(i=[])[0]=a?23:39,i[1]=1,i[2]=0,i[3]=0,i[4]=0,i[5]=t.byteLength>>24&255,i[6]=t.byteLength>>16&255,i[7]=t.byteLength>>8&255,i[8]=255&t.byteLength,(r=new Uint8Array(i.length+t.byteLength)).set(i,0),r.set(t,i.length),r);this.player.updateStats({vbps:o.byteLength,dts:n}),a&&this.calcIframeIntervalTimestamp(n),this._doDecode(o,2,n,a,0)}else this.player.debug.warn(this.TAG_NAME,"handleVideoH264Nalu is avc seq head nalType is "+s);else if(this.sps&&this.pps){this.isSendSeqHeader=!0;const e=function(e){let{sps:t,pps:i}=e,r=8+t.byteLength+1+2+i.byteLength,s=!1;var e=P.parseSPS$2(t),a=(66!==t[3]&&77!==t[3]&&88!==t[3]&&(s=!0,r+=4),new Uint8Array(r)),n=(a[0]=1,a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=255,a[5]=225,t.byteLength),o=(a[6]=n>>>8,a[7]=255&n,8),n=(a.set(t,8),a[o+=n]=1,i.byteLength),n=(a[o+1]=n>>>8,a[o+2]=255&n,a.set(i,o+3),o+=3+n,s&&(a[o]=252|e.chroma_format_idc,a[o+1]=248|e.bit_depth_luma-8,a[o+2]=248|e.bit_depth_chroma-8,a[o+3]=0,o+=4),[23,0,0,0,0]),e=new Uint8Array(n.length+a.byteLength);return e.set(n,0),e.set(a,n.length),e}({sps:this.sps,pps:this.pps});this._doDecode(e,2,0,!0,0)}}handleVideoH264NaluList(e,t,i){if(this.isSendSeqHeader){this.player._times.demuxStart||(this.player._times.demuxStart=A());const i=this.getNaluDts(),a=(e=e.reduce((e,t)=>{var e=Oi(e),t=Oi(t),i=new Uint8Array(e.byteLength+t.byteLength);return i.set(e,0),i.set(t,e.byteLength),i}),(r=[])[0]=t?23:39,r[1]=1,r[2]=0,r[3]=0,r[4]=0,(s=new Uint8Array(r.length+e.byteLength)).set(r,0),s.set(e,r.length),s);this.player.updateStats({vbps:a.byteLength,dts:i}),t&&this.calcIframeIntervalTimestamp(i),this._doDecode(a,2,i,t,0)}else this.player.debug.warn(this.TAG_NAME,"handleVideoH264NaluList isSendSeqHeader is false");var r,s}handleVideoH265Nalu(e){var t,i,r=zi(e);switch(r){case 32:this.vps=e;break;case 33:this.sps=e;break;case 34:this.pps=e}if(this.isSendSeqHeader){if(!(32<=r&&r<=40)){this.player._times.demuxStart||(this.player._times.demuxStart=A());const s=16<=r&&r<=21,a=this.getNaluDts(),n=(r=e,(t=[])[0]=s?28:44,t[1]=1,t[2]=0,t[3]=0,t[4]=0,t[5]=r.byteLength>>24&255,t[6]=r.byteLength>>16&255,t[7]=r.byteLength>>8&255,t[8]=255&r.byteLength,(i=new Uint8Array(t.length+r.byteLength)).set(t,0),i.set(r,t.length),i);this.player.updateStats({vbps:n.byteLength,dts:a}),s&&this.calcIframeIntervalTimestamp(a),this._doDecode(n,2,a,s,0)}}else if(this.vps&&this.sps&&this.pps){this.isSendSeqHeader=!0;const e=function(e){var{vps:e,pps:t,sps:i}=e,r={configurationVersion:1},s=(e=>{e=Ni(e),e=new Pi(e);return e.readByte(),e.readByte(),e.readBits(4),e.readBits(2),e.readBits(6),{num_temporal_layers:e.readBits(3)+1,temporal_id_nested:e.readBool()}})(e),a=(e=>{let t=Ni(e),a=new Pi(t),i=(a.readByte(),a.readByte(),0),r=0,s=0,n=0;a.readBits(4);var o=a.readBits(3),e=(a.readBool(),a.readBits(2)),l=a.readBool(),c=a.readBits(5),d=a.readByte(),u=a.readByte(),h=a.readByte(),p=a.readByte(),f=a.readByte(),g=a.readByte(),m=a.readByte(),O=a.readByte(),F=a.readByte(),j=a.readByte(),A=a.readByte(),y=[],U=[];for(let e=0;e{switch(e){case 0:return"4:0:0";case 1:return"4:2:0";case 2:return"4:2:2";case 3:return"4:4:4";default:return"Unknown"}})(v),general_level_idc:A,general_profile_space:e,general_tier_flag:l,general_profile_idc:c,general_profile_compatibility_flags_1:d,general_profile_compatibility_flags_2:u,general_profile_compatibility_flags_3:h,general_profile_compatibility_flags_4:p,general_constraint_indicator_flags_1:f,general_constraint_indicator_flags_2:g,general_constraint_indicator_flags_3:m,general_constraint_indicator_flags_4:O,general_constraint_indicator_flags_5:F,general_constraint_indicator_flags_6:j,min_spatial_segmentation_idc:_,constant_frame_rate:0,chroma_format_idc:v,bit_depth_luma_minus8:w,bit_depth_chroma_minus8:z,frame_rate:{fixed:L,fps:D/x,fps_den:x,fps_num:D},sar_ratio:{width:C,height:R},codec_size:{width:P,height:B},present_size:{width:P*M,height:B}}})(i),n=(e=>{e=Ni(e),e=new Pi(e);e.readByte(),e.readByte(),e.readUEG(),e.readUEG(),e.readBool(),e.readBool(),e.readBits(3),e.readBool(),e.readBool(),e.readUEG(),e.readUEG(),e.readSEG(),e.readBool(),e.readBool(),e.readBool()&&e.readUEG(),e.readSEG(),e.readSEG(),e.readBool(),e.readBool(),e.readBool(),e.readBool();let t=e.readBool(),i=e.readBool(),r=1;return i&&t?r=0:i?r=3:t&&(r=2),{parallelismType:r}})(t),r=Object.assign(r,s,a,n),s=23+(5+e.byteLength)+(5+i.byteLength)+(5+t.byteLength),n=((a=new Uint8Array(s))[0]=1,a[1]=(3&r.general_profile_space)<<6|(r.general_tier_flag?1:0)<<5|31&r.general_profile_idc,a[2]=r.general_profile_compatibility_flags_1||0,a[3]=r.general_profile_compatibility_flags_2||0,a[4]=r.general_profile_compatibility_flags_3||0,a[5]=r.general_profile_compatibility_flags_4||0,a[6]=r.general_constraint_indicator_flags_1||0,a[7]=r.general_constraint_indicator_flags_2||0,a[8]=r.general_constraint_indicator_flags_3||0,a[9]=r.general_constraint_indicator_flags_4||0,a[10]=r.general_constraint_indicator_flags_5||0,a[11]=r.general_constraint_indicator_flags_6||0,a[12]=60,a[13]=240|(3840&r.min_spatial_segmentation_idc)>>8,a[14]=255&r.min_spatial_segmentation_idc,a[15]=252|3&r.parallelismType,a[16]=252|3&r.chroma_format_idc,a[17]=248|7&r.bit_depth_luma_minus8,a[18]=248|7&r.bit_depth_chroma_minus8,a[19]=0,a[20]=0,a[21]=(3&r.constant_frame_rate)<<6|(7&r.num_temporal_layers)<<3|(r.temporal_id_nested?1:0)<<2|3,a[22]=3,a[23]=160,a[24]=0,a[25]=1,a[26]=(65280&e.byteLength)>>8,a[27]=(255&e.byteLength)>>0,a.set(e,28),a[23+(5+e.byteLength)+0]=161,a[23+(5+e.byteLength)+1]=0,a[23+(5+e.byteLength)+2]=1,a[23+(5+e.byteLength)+3]=(65280&i.byteLength)>>8,a[23+(5+e.byteLength)+4]=(255&i.byteLength)>>0,a.set(i,23+(5+e.byteLength)+5),a[23+(5+e.byteLength+5+i.byteLength)+0]=162,a[23+(5+e.byteLength+5+i.byteLength)+1]=0,a[23+(5+e.byteLength+5+i.byteLength)+2]=1,a[23+(5+e.byteLength+5+i.byteLength)+3]=(65280&t.byteLength)>>8,a[23+(5+e.byteLength+5+i.byteLength)+4]=(255&t.byteLength)>>0,a.set(t,23+(5+e.byteLength+5+i.byteLength)+5),[28,0,0,0,0]);return(s=new Uint8Array(n.length+a.byteLength)).set(n,0),s.set(a,n.length),s}({vps:this.vps,sps:this.sps,pps:this.pps});this._doDecode(e,2,0,!0,0)}}getInputByteLength(){let e=0;return e=this.lastBuf?this.lastBuf.byteLength:e}}class Xr extends Ji{constructor(e){super(e),(this.player=e).debug.log("EmptyDemux","init")}destroy(){super.destroy(),this.player.debug.log("EmptyDemux","destroy")}}class Zr{constructor(e){return new(Zr.getLoaderFactory(e._opt.demuxType))(e)}static getLoaderFactory(e){return"m7s"===e?qr:e===G?Jr:e===z?Qr:e===H?Yr:Xr}}class es extends e{constructor(e){super(),this.player=e,this.hasInit=!1,this.isDecodeFirstIIframe=!1,this.isInitInfo=!1,this.prevTimestamp=null,this.decodeDiffTimestamp=null,this.prevDts=null,this.decoder=null,this.isWidthOrHeightChanged=!1,this.initDecoder(),e.debug.log("Webcodecs","init")}destroy(){this.decoder&&("closed"!==this.decoder.state&&this.decoder.close(),this.decoder=null),this.prevTimestamp=null,this.decodeDiffTimestamp=null,this.prevDts=null,this.hasInit=!1,this.isInitInfo=!1,this.isDecodeFirstIIframe=!1,this.isWidthOrHeightChanged=!1,this.off(),this.player.debug.log("Webcodecs","destroy")}initDecoder(){const t=this;this.decoder=new VideoDecoder({output(e){t.handleDecode(e)},error(e){t.handleError(e)}})}handleDecode(e){this.isInitInfo||(this.player.video.updateVideoInfo({width:e.codedWidth,height:e.codedHeight}),this.player.video.initCanvasViewSize(),this.isInitInfo=!0),this.player._times.videoStart||(this.player._times.videoStart=A(),this.player.handlePlayToRenderTimes()),this.player.video.render({videoFrame:e,ts:e.timestamp}),this.player.handleRender(),this.player.updateStats({dfps:!0,buf:this.player.demux&&this.player.demux.delay||0})}handleError(e){this.player.debug.error("Webcodecs","VideoDecoder handleError:",e.code,e);e=e.toString();-1!==e.indexOf("Unsupported configuration")&&this.player.emitError(m.webcodecsUnsupportedConfigurationError,e)}decodeVideo(i,r,s,a){if(this.hasInit)if(this.isDecodeFirstIIframe||s||this.player.debug.warn("Webcodecs","VideoDecoder isDecodeFirstIIframe false and isIframe is false"),!this.isDecodeFirstIIframe&&s&&(this.isDecodeFirstIIframe=!0),this.isDecodeFirstIIframe){if(s&&0===i[1]){const r=15&i[0];let e={};7==r?e=Mi(i.slice(5)):12==r&&(e=Gi(i));const a=this.player.video.videoInfo;a&&a.width&&a.height&&e&&e.codecWidth&&e.codecHeight&&(e.codecWidth!==a.width||e.codecHeight!==a.height)&&(this.player.debug.warn("Webcodecs",`decodeVideo: video width or height is changed, old width is ${videoWidth}, old height is ${videoHeight}, new width is ${e.codecWidth}, new height is ${e.codecHeight}, and emit change event`),this.isWidthOrHeightChanged=!0,this.player.emitError(m.wcsWidthOrHeightChange))}if(this.isWidthOrHeightChanged)this.player.debug.warn("Webcodecs","decodeVideo: video width or height is changed, and return");else if(Ut(i))this.player.debug.warn("Webcodecs","decodeVideo and payload is video sequence header so drop this frame");else if(i.byteLength<12)this.player.debug.warn("Webcodecs","decodeVideo and payload is too small , payload length is "+i.byteLength);else{let e=!1,t=(new Date).getTime();this.prevTimestamp||(this.prevTimestamp=t,e=!0);var n=t-this.prevTimestamp,n=(((this.decodeDiffTimestamp=n)<5||500(e[t]=` ${ts[t]?`${ts[t]}`:""} `,e),{});function is(e,t){let i=!1;return e.forEach(e=>{i||e.startTimestamp<=t&&e.endTimestamp>t&&(i=!0)}),i}function rs(e,t,i){let r=0 ${a.title} `),s[h]);c&&(i+=`
${c.title}
`),h+=1}t&&a.$playbackTimeListOne.insertAdjacentHTML("beforeend",t),i&&a.$playbackTimeListSecond.insertAdjacentHTML("beforeend",i),(u+=1){const s=y["events"]["proxy"],a=document.createElement("object");a.setAttribute("aria-hidden","true"),a.setAttribute("tabindex",-1),a.type="text/html",a.data="about:blank",E(a,{display:"block",position:"absolute",top:"0",left:"0",height:"100%",width:"100%",overflow:"hidden",pointerEvents:"none",zIndex:"-1"});let n=y.width,e=y.height;const t=pt(()=>{y.width===n&&y.height===e||(n=y.width,e=y.height,y.emit(w.resize),l())},500),i=(s(a,"load",()=>{s(a.contentDocument.defaultView,"resize",()=>{t()})}),y.$container.appendChild(a),y.on(w.destroy,()=>{y.$container.removeChild(a)}),y.on(w.volumechange,()=>{var e,t,i;0===(e=y.volume)?(E(b.$volumeOn,"display","none"),E(b.$volumeOff,"display","flex"),E(b.$volumeHandle,"top","48px")):b.$volumeHandle&&b.$volumePanel&&(t=rt(b.$volumePanel,"height")||60,i=rt(b.$volumeHandle,"height"),E(b.$volumeHandle,"top",t-(t-i)*e-i+"px"),E(b.$volumeOn,"display","flex"),E(b.$volumeOff,"display","none")),b.$volumePanelText&&(b.$volumePanelText.innerHTML=parseInt(100*e))}),y.on(w.loading,e=>{E(b.$loading,"display",e?"flex":"none"),(_(y._opt.backgroundLoadingShow)&&k(e)||_(e))&&E(b.$poster,"display","none"),e&&E(b.$playBig,"display","none"),g()||e||(b.$loadingBgImage.width=0,b.$loadingBgImage.height=0,b.$loadingBgImage.src="",E(b.$loadingBg,"display","none"))}),e=>{y.fullscreen&&S(e)!==y.$container||r()}),r=e=>{e=bt(e)?e:y.fullscreen;E(b.$fullscreenExit,"display",e?"flex":"none"),E(b.$fullscreen,"display",e?"none":"flex")},o=()=>y._opt.playType===v&&y._opt.playbackConfig.showControl,l=i=>{g()&&b.$controls&&y._opt.useWebFullScreen&&setTimeout(()=>{if(y.fullscreen){const i=o()?48:38;var e=y.height/2-y.width+i/2,t=y.height/2-i/2;b.$controls.style.transform=`translateX(${-e}px) translateY(-${t}px) rotate(-90deg)`}else b.$controls.style.transform="translateX(0) translateY(0) rotate(0)";i&&i()},10)};try{f.on("change",i),y.events.destroys.push(()=>{f.off("change",i)})}catch(y){}y.on(w.webFullscreen,e=>{g()&&(r(e),l(()=>{d()}))}),y.on(w.recording,()=>{y.playing&&(E(b.$record,"display",y.recording?"none":"flex"),E(b.$recordStop,"display",y.recording?"flex":"none"),y._opt.hasControl||y._opt.isShowRecordingUI)&&E(b.$recording,"display",y.recording?"flex":"none")}),y.on(w.recordingTimestamp,e=>{b.$recordingTime&&(b.$recordingTime.innerHTML=Tt(e))}),y.on(w.zooming,()=>{y.playing&&(E(b.$zoom,"display",y.zooming?"none":"flex"),E(b.$zoomStop,"display",y.zooming?"flex":"none"),y._opt.hasControl||y._opt.isShowZoomingUI)&&E(b.$zoomControls,"display",y.zooming?"flex":"none")}),y.on(w.playing,e=>{c(e)});const c=t=>{E(b.$play,"display",t?"none":"flex"),E(b.$playBig,"display",t?"none":"block"),E(b.$pause,"display",t?"flex":"none"),E(b.$screenshot,"display",t?"flex":"none"),E(b.$record,"display",t?"flex":"none"),E(b.$qualityMenu,"display",t?"flex":"none"),E(b.$volume,"display",t?"flex":"none"),E(b.$ptz,"display",t?"flex":"none"),E(b.$zoom,"display",t?"flex":"none"),E(b.$scaleMenu,"display",t?"flex":"none"),E(b.$faceDetect,"display",t?"flex":"none"),E(b.$controlHtml,"display",t?"flex":"none"),y.isPlayback()&&E(b.$speedMenu,"display",t?"flex":"none"),r(),b.extendBtnList.forEach(e=>{e.$iconWrap&&E(e.$iconWrap,"display",t?"flex":"none"),e.$activeIconWrap&&E(e.$activeIconWrap,"display","none")}),y._opt.showPerformance?E(b.$performanceActive,"display",t?"flex":"none"):E(b.$performance,"display",t?"flex":"none"),E(b.$poster,"display","none"),E(b.$ptzActive,"display","none"),E(b.$recordStop,"display","none"),E(b.$zoomStop,"display","none"),E(b.$faceDetectActive,"display","none"),t||(b.$speed&&(b.$speed.innerHTML="0 KB/s"),E(b.$zoomControls,"display","none"),E(b.$recording,"display","none"),b.$ptzControl&&b.$ptzControl.classList.remove("jessibuca-ptz-controls-show")),d()},d=(y.on(w.playbackPause,e=>{c(!e)}),y.on(w.kBps,e=>{e=function(e){if(null==e||""===e||0===parseFloat(e)||"NaN"===e)return"0 KB/s";var t=["KB/s","MB/s","GB/s","TB/s","PB/s","EB/s","ZB/s","YB/s"],e=parseFloat(e),i=Math.floor(Math.log(e)/Math.log(1024));let r=e/Math.pow(1024,i);return(r=r.toFixed(2))+(t[i]||t[0])}(e);b.kbpsShow=e,y._opt.showBandwidth&&(b.$speed&&(b.$speed.innerHTML=e),d())}),()=>{if(o()){let e=b.controlsInnerRect.width-b.controlsLeftRect.width-b.controlsRightRect.width-b.controlsPlaybackBtnsRect.width;g()&&y.webFullscreen&&(e=b.controlsInnerRect.height-b.controlsLeftRect.height-b.controlsRightRect.height-b.controlsPlaybackBtnsRect.height),b.$playbackTimeInner.style.width=e+"px"}});if(o()){const s=()=>{if(o()){let e=0;var t,i,r=y.playback&&y.playback.playingTimestamp;r&&(t=(r=new Date(r)).getHours(),i=r.getMinutes(),r=r.getSeconds(),y.playback.is60Min?e=60*t+i:y.playback.is30Min?e=2*(60*t+i)+parseInt(r/30,10):y.playback.is10Min?e=6*(60*t+i)+parseInt(r/10,10):y.playback.is5Min?e=12*(60*t+i)+parseInt(r/5,10):y.playback.is1Min&&(e=60*(60*t+i)+parseInt(r,10)),b.$playbackCurrentTime.style.left=e+"px")}},a=e=>{b.$playbackNarrow.classList.remove("disabled"),b.$playbackExpand.classList.remove("disabled"),e===Te&&b.$playbackNarrow.classList.add("disabled"),e===ke&&b.$playbackExpand.classList.add("disabled")},n=()=>{var e=b.$playbackCurrentTime.style.left,e=parseInt(e,10),t=b.controlsPlaybackTimeInner.width,e=0{b.$playbackCurrentTimeText&&(b.$playbackCurrentTimeText.innerText=dt(e,"{h}:{i}:{s}")),s()}),y.on(w.playbackPrecision,(i,r)=>{b.$playbackTimeScroll.classList.remove(_e.oneHour,_e.halfHour,_e.fiveMin,_e.tenMin),b.$playbackTimeScroll.classList.add(_e[i]),b.rafId&&(window.cancelAnimationFrame(b.rafId),b.rafId=null),b.changePercisitionInterval&&(clearTimeout(b.changePercisitionInterval),b.changePercisitionInterval=null),b.$playbackTimeListOne.innerHTML="",b.$playbackTimeListSecond.innerHTML="",b.changePercisitionInterval=setTimeout(()=>{switch(b.$playbackTimeListOne.innerHTML="",b.$playbackTimeListSecond.innerHTML="",i){case Te:ss(r,b);break;case Se:t=b,rs(function(e){var s=0{d()}),d()}if(y._opt.operateBtns.quality&&0{s(e)});const s=i=>{b.$qualityText.innerText=i,b.$qualityMenuItems.forEach(e=>{var t=e.dataset.quality;e.classList.remove("jessibuca-quality-menu-item-active"),t===i&&e.classList.add("jessibuca-quality-menu-item-active")})};{const h=y._opt.qualityConfig||[];let t="";h.forEach(e=>{t+=`
${e}
`}),t&&(b.$qualityMenuList.insertAdjacentHTML("beforeend",t),Object.defineProperty(b,"$qualityMenuItems",{value:y.$container.querySelectorAll(".jessibuca-quality-menu-item")}),setTimeout(()=>{var e=h[0];y.streamQuality=e},0))}y.streamQuality&&s(y.streamQuality)}if(y._opt.operateBtns.scale&&0{s(e)});const s=i=>{var e=y._opt.scaleConfig[i];b.$scaleText.innerText=e,b.$scaleMenuItems.forEach(e=>{var t=e.dataset.scale;e.classList.remove("jessibuca-scale-menu-item-active"),T(t)===T(i)&&e.classList.add("jessibuca-scale-menu-item-active")})};{var u=y._opt.scaleConfig||[];let i="";u.forEach((e,t)=>{i+=`
${e}
`}),i&&(b.$scaleMenuList.insertAdjacentHTML("beforeend",i),Object.defineProperty(b,"$scaleMenuItems",{value:y.$container.querySelectorAll(".jessibuca-scale-menu-item")}))}s(y.scaleType)}if(y.isPlayback()&&y._opt.playbackConfig.showRateBtn&&0{s(e)});const s=i=>{var e=y._opt.playbackConfig.rateConfig.find(e=>T(e.value)===T(i));e&&(b.$speedText.innerText=e.label,b.$speedMenuItems.forEach(e=>{var t=e.dataset.speed;e.classList.remove("jessibuca-speed-menu-item-active"),T(t)===T(i)&&e.classList.add("jessibuca-speed-menu-item-active")}))};{u=y._opt.playbackConfig.rateConfig;let i="";u.forEach((e,t)=>{i+=`
${e.label}
`}),i&&(b.$speedMenuList.insertAdjacentHTML("beforeend",i),Object.defineProperty(b,"$speedMenuItems",{value:y.$container.querySelectorAll(".jessibuca-speed-menu-item")}))}const a=y.playback?y.playback.playbackRate:1;s(a)}y.on(w.stats,function(){var e,t,i,r,s,a,n,o,l,c,d,u,h,p,f,g,m,A=0 版本 "6-3-2023"
播放模式 ${f}
${y.isPlayback()?`
播放倍率 ${y.playback.rate}倍
播放模式 ${y.playback.isUseFpsRender?"固定FPS":"动态FPS"}
${y.playback.isUseFpsRender?`
固定FPS ${y.video.getStreamFps()}
`:""} `:""}
解封装模式 ${W[n]}
解码模式 ${a}
渲染组件 ${r}
${r===V?`
渲染引擎 ${s}
`:""}
网络请求组件 ${o}
视频格式 ${e.encType||"-"}
视频(宽x高) ${e.width||"-"}x${e.height||"-"}
${y.isPlayer()?`
视频GOP(ms) ${d||"-"}
`:""}
音频格式 ${pe[t.encType]||"-"}
音频引擎 ${l||"-"}
音频通道 ${t.channels||"-"}
音频采样率 ${t.sampleRate||"-"}
${y.isPlayer()?`
播放器初始化(ms) ${i.playTimestamp}
开始请求地址(ms) ${i.streamTimestamp}
请求响应(ms) ${i.streamResponseTimestamp}
解封装(ms) ${i.demuxTimestamp}
解码(ms) ${i.decodeTimestamp}
页面开始渲染(ms) ${i.videoTimestamp}
初始化到页面渲染(ms) ${i.allTimestamp}
${y.recording?`
视频录制时间 ${u}
视频录制大小 ${h}
`:""} `:""}
音频码率(bit) ${A.abps}
视频码率(bit) ${A.vbps}
视频帧率(fps) ${A.fps}
视频峰值帧率(fps) ${A.maxFps}
解码帧率(fps) ${A.dfps}
音频缓冲帧 ${A.audioBuffer}
音频缓冲时长(ms) ${A.audioBufferDelayTs}
${y.isPlayer()?`
视频待解码帧 ${A.demuxBuffer}
`:`
缓存时长(ms) ${A.playbackCacheDataDuration}
视频待渲染帧 ${A.playbackVideoBuffer}
视频待解码帧 ${A.demuxBuffer}
音频待解码帧 ${A.audioDemuxBuffer}
`}
待解封装数据(byte) ${A.flvBuffer}
${y._opt.useMSE?`
MSE缓冲时长(ms) ${A.mseDelay}
MSE解码间隔(ms) ${A.mseDecodeDiffTimes}
MSE解码时间(ms) ${A.mseTs}
MSE播放模式 ${1
`:""} ${y._opt.useWCS?`
WCS解码间隔(ms) ${A.wcsDecodeDiffTimes}
`:""} ${y._opt.isHls?`
HLS缓冲时长(ms) ${A.hlsDelay}
HLS播放模式 ${1
`:""} ${y.isPlayer()&&p?`
已渲染帧 ${p.renderedVideoFrames}
已丢弃帧 ${p.droppedVideoFrames}
`:""} ${y.isPlayer()?`
网络延迟(ms) ${A.netBuf}
缓冲时长(ms) ${A.buf}
最新缓冲时长(ms) ${A.pushLatestDelay}
`:""}
视频显示时间(ms) ${A.ts}
${y._opt.hasAudio&&y.isAudioNotMute()?`
音频显示时间(ms) ${A.audioTs}
${y._opt.hasVideo?`
音视频同步时间戳(ms) ${A.ts-A.audioTs}
`:""}
音频播放模式 ${c?"加速":"正常"}
`:""}
视频解码时间(ms) ${A.dts}
${y.isPlayer()?`
解码前-解码后延迟(ms) ${A.delayTs}
总延迟(网络+解码)(ms) ${A.totalDelayTs}
`:""} ${y.isPlayer()&&A.isStreamTsMoreThanLocal?'
\n 是否超过一倍率推流 是\n
\n ':""} ${y.isPlayer()?`
是否在丢帧 ${g}
`:""}
网速 ${m}
播放时长(s) ${Tt(A.pTs)}
`,b.$performancePanel.insertAdjacentHTML("beforeend",f)):(b.$performancePanel.innerHTML="",E(b.$performancePanel,"display","none"))}),y.on(w.togglePerformancePanel,e=>{E(b.$performance,"display",e?"none":"flex"),E(b.$performanceActive,"display",e?"flex":"none")}),y.on(w.faceDetectActive,e=>{E(b.$faceDetect,"display",e?"none":"flex"),E(b.$faceDetectActive,"display",e?"flex":"none")})};function ns(e,t){var i,r,t=(t=void 0===t?{}:t).insertAt;e&&"undefined"!=typeof document&&(i=document.head||document.getElementsByTagName("head")[0],(r=document.createElement("style")).type="text/css","top"===t&&i.firstChild?i.insertBefore(r,i.firstChild):i.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e)))}function os(e,t){t instanceof Element?e.appendChild(t):e.insertAdjacentHTML("beforeend",String(t)),e.lastElementChild||e.lastChild}function M(e,t,i){e.style[t]=i}function ls(e,t){return e.composedPath&&-1
00:00:00
${I.narrow}
${I.expand}
`,l.$container.insertAdjacentHTML("beforeend",` ${d.background?`
`:""}
${d.loadingIcon?`
${I.loading} ${d.loadingText?`
${d.loadingText}
`:""}
`:""} ${d.hasControl&&u.play?'
':""} ${d.hasControl&&u.ptz?`
${d.ptzMoreArrow?'\n
\n
\n
\n
\n ':""}
${d.ptzZoomShow?'\n
\n
\n \n \n 缩放+\n \n
\n
\n \n \n 缩放-\n \n
\n
\n ':""} ${d.ptzApertureShow?'\n
\n
\n \n \n 光圈+\n \n
\n
\n \n \n 光圈-\n \n
\n
\n ':""} ${d.ptzFocusShow?'\n
\n
\n \n \n 聚焦+\n \n
\n
\n \n \n 聚焦-\n \n
\n
\n ':""}
`:""} ${d.hasVideo?`
${I.narrow}
电子放大
${I.expand}
${I.zoomStop}
00:00:00
${I.recordStop}
`:""} ${d.hasControl?`
${d.showBandwidth?'
':""}
${d.controlHtml}
${d.playType===v&&d.playbackConfig.showControl?h:""}
${d.playType===v&&d.playbackConfig.showRateBtn?'\n
\n
\n
\n
\n
\n
\n ':""} ${u.close?`
${I.close}
`:""} ${u.performance?`
${I.performance}
${I.performanceActive}
`:""} ${u.aiFace?`
${I.face}
${I.faceActive}
`:""} ${u.quality?'\n
\n
\n
\n
\n
\n
\n ':""} ${u.scale?'\n
\n
\n
\n
\n
\n
\n ':""} ${u.audio?`
${I.audio} ${I.mute}
`:""} ${u.play?`
${I.play}
${I.pause}
`:""} ${u.screenshot?`
${I.screenshot}
`:""} ${u.record?`
${I.record}
${I.recordStop}
`:""} ${u.ptz?`
${I.ptz}
${I.ptzActive}
`:""} ${u.zoom?`
${I.zoom}
${I.zoomStop}
`:""} ${u.fullscreen?`
${I.fullscreen}
${I.fullscreenExit}
`:""}
`:""}
`),Object.defineProperty(c,"$poster",{value:l.$container.querySelector(".jessibuca-poster")}),Object.defineProperty(c,"$loadingBg",{value:l.$container.querySelector(".jessibuca-loading-bg")}),Object.defineProperty(c,"$loadingBgImage",{value:l.$container.querySelector(".jessibuca-loading-bg-image")}),Object.defineProperty(c,"$loading",{value:l.$container.querySelector(".jessibuca-loading")}),Object.defineProperty(c,"$play",{value:l.$container.querySelector(".jessibuca-play")}),Object.defineProperty(c,"$playBig",{value:l.$container.querySelector(".jessibuca-play-big")}),Object.defineProperty(c,"$recording",{value:l.$container.querySelector(".jessibuca-recording")}),Object.defineProperty(c,"$recordingTime",{value:l.$container.querySelector(".jessibuca-recording-time")}),Object.defineProperty(c,"$recordingStop",{value:l.$container.querySelector(".jessibuca-recording-stop")}),Object.defineProperty(c,"$pause",{value:l.$container.querySelector(".jessibuca-pause")}),Object.defineProperty(c,"$controls",{value:l.$container.querySelector(".jessibuca-controls")}),Object.defineProperty(c,"$controlsInner",{value:l.$container.querySelector(".jessibuca-controls-bottom")}),Object.defineProperty(c,"$controlsLeft",{value:l.$container.querySelector(".jessibuca-controls-left")}),Object.defineProperty(c,"$controlsRight",{value:l.$container.querySelector(".jessibuca-controls-right")}),Object.defineProperty(c,"$volume",{value:l.$container.querySelector(".jessibuca-volume")}),Object.defineProperty(c,"$volumePanelWrap",{value:l.$container.querySelector(".jessibuca-volume-panel-wrap")}),Object.defineProperty(c,"$volumePanelText",{value:l.$container.querySelector(".jessibuca-volume-panel-text")}),Object.defineProperty(c,"$volumePanel",{value:l.$container.querySelector(".jessibuca-volume-panel")}),Object.defineProperty(c,"$volumeHandle",{value:l.$container.querySelector(".jessibuca-volume-panel-handle")}),Object.defineProperty(c,"$volumeOn",{value:l.$container.querySelector(".jessibuca-icon-audio")}),Object.defineProperty(c,"$volumeOff",{value:l.$container.querySelector(".jessibuca-icon-mute")}),Object.defineProperty(c,"$fullscreen",{value:l.$container.querySelector(".jessibuca-fullscreen")}),Object.defineProperty(c,"$fullscreenExit",{value:l.$container.querySelector(".jessibuca-fullscreen-exit")}),Object.defineProperty(c,"$record",{value:l.$container.querySelector(".jessibuca-record")}),Object.defineProperty(c,"$recordStop",{value:l.$container.querySelector(".jessibuca-record-stop")}),Object.defineProperty(c,"$screenshot",{value:l.$container.querySelector(".jessibuca-screenshot")}),Object.defineProperty(c,"$speed",{value:l.$container.querySelector(".jessibuca-speed")}),Object.defineProperty(c,"$controlHtml",{value:l.$container.querySelector(".jessibuca-controls-item-html")}),Object.defineProperty(c,"$playbackTime",{value:l.$container.querySelector(".jessibuca-controls-playback-time")}),Object.defineProperty(c,"$playbackTimeInner",{value:l.$container.querySelector(".jessibuca-controls-playback-time-inner")}),Object.defineProperty(c,"$playbackTimeScroll",{value:l.$container.querySelector(".jessibuca-controls-playback-time-scroll")}),Object.defineProperty(c,"$playbackTimeList",{value:l.$container.querySelector(".jessibuca-controls-playback-time-list")}),Object.defineProperty(c,"$playbackTimeListOne",{value:l.$container.querySelector(".jessibuca-playback-time-one-wrap")}),Object.defineProperty(c,"$playbackTimeListSecond",{value:l.$container.querySelector(".jessibuca-playback-time-second-wrap")}),Object.defineProperty(c,"$playbackCurrentTime",{value:l.$container.querySelector(".jessibuca-controls-playback-current-time")}),Object.defineProperty(c,"$playbackCurrentTimeText",{value:l.$container.querySelector(".jessibuca-controls-playback-current-time-text")}),Object.defineProperty(c,"$controlsPlaybackBtns",{value:l.$container.querySelector(".jessibuca-controls-playback-btns")}),Object.defineProperty(c,"$playbackNarrow",{value:l.$container.querySelector(".jessibuca-playback-narrow")}),Object.defineProperty(c,"$playbackExpand",{value:l.$container.querySelector(".jessibuca-playback-expand")}),Object.defineProperty(c,"$ptz",{value:l.$container.querySelector(".jessibuca-ptz")}),Object.defineProperty(c,"$ptzActive",{value:l.$container.querySelector(".jessibuca-ptz-active")}),Object.defineProperty(c,"$ptzControl",{value:l.$container.querySelector(".jessibuca-ptz-controls")}),Object.defineProperty(c,"$ptzBgActive",{value:l.$container.querySelector(".jessibuca-ptz-bg-active")}),Object.defineProperty(c,"$ptzControlCircular",{value:l.$container.querySelector(".jessibuca-ptz-control")}),Object.defineProperty(c,"$ptzArrows",{value:l.$container.querySelectorAll(".jessibuca-ptz-arrow")}),Object.defineProperty(c,"$ptzExpand",{value:l.$container.querySelector(".jessibuca-ptz-expand")}),Object.defineProperty(c,"$ptzNarrow",{value:l.$container.querySelector(".jessibuca-ptz-narrow")}),Object.defineProperty(c,"$ptzApertureFar",{value:l.$container.querySelector(".jessibuca-ptz-aperture-far")}),Object.defineProperty(c,"$ptzApertureNear",{value:l.$container.querySelector(".jessibuca-ptz-aperture-near")}),Object.defineProperty(c,"$ptzFocusFar",{value:l.$container.querySelector(".jessibuca-ptz-focus-far")}),Object.defineProperty(c,"$ptzFocusNear",{value:l.$container.querySelector(".jessibuca-ptz-focus-near")}),Object.defineProperty(c,"$qualityText",{value:l.$container.querySelector(".jessibuca-quality-icon-text")}),Object.defineProperty(c,"$qualityMenu",{value:l.$container.querySelector(".jessibuca-quality-menu")}),Object.defineProperty(c,"$qualityMenuList",{value:l.$container.querySelector(".jessibuca-quality-menu-list")}),Object.defineProperty(c,"$scaleText",{value:l.$container.querySelector(".jessibuca-scale-icon-text")}),Object.defineProperty(c,"$scaleMenu",{value:l.$container.querySelector(".jessibuca-scale-menu")}),Object.defineProperty(c,"$scaleMenuList",{value:l.$container.querySelector(".jessibuca-scale-menu-list")}),Object.defineProperty(c,"$zoom",{value:l.$container.querySelector(".jessibuca-zoom")}),Object.defineProperty(c,"$zoomStop",{value:l.$container.querySelector(".jessibuca-zoom-stop")}),Object.defineProperty(c,"$zoomNarrow",{value:l.$container.querySelector(".jessibuca-zoom-narrow")}),Object.defineProperty(c,"$zoomExpand",{value:l.$container.querySelector(".jessibuca-zoom-expand")}),Object.defineProperty(c,"$zoomStop2",{value:l.$container.querySelector(".jessibuca-zoom-stop2")}),Object.defineProperty(c,"$close",{value:l.$container.querySelector(".jessibuca-close")}),Object.defineProperty(c,"$zoomControls",{value:l.$container.querySelector(".jessibuca-zoom-controls")}),Object.defineProperty(c,"$performancePanel",{value:l.$container.querySelector(".jessibuca-performance-panel")}),Object.defineProperty(c,"$performance",{value:l.$container.querySelector(".jessibuca-performance")}),Object.defineProperty(c,"$performanceActive",{value:l.$container.querySelector(".jessibuca-performance-active")}),Object.defineProperty(c,"$faceDetect",{value:l.$container.querySelector(".jessibuca-face")}),Object.defineProperty(c,"$faceDetectActive",{value:l.$container.querySelector(".jessibuca-face-active")}),Object.defineProperty(c,"$contextmenus",{value:l.$container.querySelector(".jessibuca-contextmenus")}),Object.defineProperty(c,"$speedText",{value:l.$container.querySelector(".jessibuca-speed-icon-text")}),Object.defineProperty(c,"$speedMenu",{value:l.$container.querySelector(".jessibuca-speed-menu")}),Object.defineProperty(c,"$speedMenuList",{value:l.$container.querySelector(".jessibuca-speed-menu-list")}),0{this.addExtendBtn(e)}),o=this,Object.defineProperty(o,"controlsRect",{get:()=>o.$controls.getBoundingClientRect()}),Object.defineProperty(o,"controlsInnerRect",{get:()=>o.$controlsInner.getBoundingClientRect()}),Object.defineProperty(o,"controlsLeftRect",{get:()=>o.$controlsLeft.getBoundingClientRect()}),Object.defineProperty(o,"controlsRightRect",{get:()=>o.$controlsRight.getBoundingClientRect()}),Object.defineProperty(o,"controlsPlaybackTimeInner",{get:()=>o.$playbackTimeInner&&o.$playbackTimeInner.getBoundingClientRect()||{}}),Object.defineProperty(o,"controlsPlaybackBtnsRect",{get:()=>o.$controlsPlaybackBtns&&o.$controlsPlaybackBtns.getBoundingClientRect()||{width:0}}),as(e,this);{var r=e,s=this;const p=r["events"]["proxy"],f=r._opt,g=f.operateBtns;function t(e){var{bottom:t,height:i}=s.$volumePanel.getBoundingClientRect(),r=s.$volumeHandle.getBoundingClientRect()["height"];return y(t-e.y-r/2,0,i-r/2)/(i-r)}if(p(window,["click","contextmenu"],e=>{-1{setTimeout(()=>{r.resize()},300)}),p(s.$controls,"click",e=>{e.stopPropagation()}),g.play&&(p(s.$pause,"click",e=>{f.playType===v&&f.playbackConfig.uiUsePlaybackPause?r.playbackPause=!0:b(g.pauseFn)?g.pauseFn():r.pause()}),p(s.$play,"click",e=>{f.playType===v&&r.playbackPause?r.playbackPause=!1:b(g.playFn)?g.playFn():(r.play(),r.resumeAudioAfterPause())})),p(s.$playBig,"click",e=>{f.playType===v&&r.playbackPause?r.playbackPause=!1:b(g.playFn)?g.playFn():(r.play(),r.resumeAudioAfterPause())}),g.screenshot&&p(s.$screenshot,"click",e=>{e.stopPropagation(),b(g.screenshotFn)?g.screenshotFn():r.video.screenshot()}),g.audio&&(p(s.$volume,"mouseover",()=>{s.$volumePanelWrap.classList.add("jessibuca-volume-panel-wrap-show")}),p(s.$volume,"mouseout",()=>{s.$volumePanelWrap.classList.remove("jessibuca-volume-panel-wrap-show")}),p(s.$volumeOn,"click",e=>{e.stopPropagation(),E(s.$volumeOn,"display","none"),E(s.$volumeOff,"display","block");e=r.volume;r.volume=0,r._lastVolume=e}),p(s.$volumeOff,"click",e=>{e.stopPropagation(),E(s.$volumeOn,"display","block"),E(s.$volumeOff,"display","none"),r.volume=r.lastVolume||.5}),p(s.$volumePanel,"click",e=>{e.stopPropagation(),r.volume=t(e)}),p(s.$volumeHandle,"mousedown",()=>{s.isVolumeDroging=!0}),p(s.$volumeHandle,"mousemove",e=>{s.isVolumeDroging&&(r.volume=t(e))}),p(document,"mouseup",()=>{s.isVolumeDroging&&(s.isVolumeDroging=!1)})),g.record&&(p(s.$record,"click",e=>{e.stopPropagation(),b(g.recordFn)?g.recordFn():r.recording=!0}),p(s.$recordStop,"click",e=>{e.stopPropagation(),b(g.recordStopFn)?g.recordStopFn():r.recording=!1})),p(s.$recordingStop,"click",e=>{e.stopPropagation(),b(g.recordStopFn)?g.recordStopFn():r.recording=!1}),g.fullscreen&&(p(s.$fullscreen,"click",e=>{e.stopPropagation(),b(g.fullscreenFn)?g.fullscreenFn():r.fullscreen=!0}),p(s.$fullscreenExit,"click",e=>{e.stopPropagation(),b(g.fullscreenExitFn)?g.fullscreenExitFn():r.fullscreen=!1})),g.ptz&&(p(s.$ptz,"click",e=>{e.stopPropagation(),E(s.$ptzActive,"display","flex"),E(s.$ptz,"display","none"),s.$ptzControl.classList.add("jessibuca-ptz-controls-show")}),p(s.$ptzActive,"click",e=>{e.stopPropagation(),E(s.$ptz,"display","flex"),E(s.$ptzActive,"display","none"),s.$ptzControl.classList.remove("jessibuca-ptz-controls-show")}),s.$ptzArrows.forEach(e=>{if(f.ptzClickType===q)p(e,"click",e=>{e.stopPropagation();e=e.currentTarget.dataset.arrow;s.$ptzBgActive.classList.add("jessibuca-ptz-bg-active-show"),s.$ptzBgActive.classList.add("jessibuca-ptz-bg-active-"+e),s.$ptzControlCircular.classList.add("jessibuca-ptz-control-"+e),r.emit(w.ptz,Nt(e)),setTimeout(()=>{s.$ptzBgActive.classList.remove("jessibuca-ptz-bg-active-show"),Re.forEach(e=>{s.$ptzBgActive.classList.remove("jessibuca-ptz-bg-active-"+e),s.$ptzControlCircular.classList.remove("jessibuca-ptz-control-"+e)}),r.emit(w.ptz,Le)},1e3*f.ptzStopEmitDelay)});else if("mouseDownAndUp"===f.ptzClickType){let t=!1;p(e,"mousedown",e=>{e.stopPropagation(),t=!0;e=e.currentTarget.dataset.arrow;s.$ptzBgActive.classList.add("jessibuca-ptz-bg-active-show"),s.$ptzBgActive.classList.add("jessibuca-ptz-bg-active-"+e),s.$ptzControlCircular.classList.add("jessibuca-ptz-control-"+e),r.emit(w.ptz,Nt(e))});const i=()=>{t=!1,s.$ptzBgActive.classList.remove("jessibuca-ptz-bg-active-show"),Re.forEach(e=>{s.$ptzBgActive.classList.remove("jessibuca-ptz-bg-active-"+e),s.$ptzControlCircular.classList.remove("jessibuca-ptz-control-"+e)}),r.emit(w.ptz,Le)};p(e,"mouseup",e=>{e.stopPropagation(),t&&i()}),p(window,"mouseup",e=>{e.stopPropagation(),t&&i()})}}),f.ptzZoomShow&&(p(s.$ptzExpand,"click",e=>{e.stopPropagation(),r.emit(w.ptz,"zoomExpand"),setTimeout(()=>{r.emit(w.ptz,Le)},1e3*f.ptzStopEmitDelay)}),p(s.$ptzNarrow,"click",e=>{e.stopPropagation(),r.emit(w.ptz,"zoomNarrow"),setTimeout(()=>{r.emit(w.ptz,Le)},1e3*f.ptzStopEmitDelay)})),f.ptzApertureShow&&(p(s.$ptzApertureFar,"click",e=>{e.stopPropagation(),r.emit(w.ptz,"apertureFar"),setTimeout(()=>{r.emit(w.ptz,xe)},1e3*f.ptzStopEmitDelay)}),p(s.$ptzApertureNear,"click",e=>{e.stopPropagation(),r.emit(w.ptz,"apertureNear"),setTimeout(()=>{r.emit(w.ptz,xe)},1e3*f.ptzStopEmitDelay)})),f.ptzFocusShow)&&(p(s.$ptzFocusFar,"click",e=>{e.stopPropagation(),r.emit(w.ptz,"focusFar"),setTimeout(()=>{r.emit(w.ptz,xe)},1e3*f.ptzStopEmitDelay)}),p(s.$ptzFocusNear,"click",e=>{e.stopPropagation(),r.emit(w.ptz,"focusNear"),setTimeout(()=>{r.emit(w.ptz,xe)},1e3*f.ptzStopEmitDelay)})),g.performance&&(p(s.$performance,"click",e=>{e.stopPropagation(),r.togglePerformancePanel(!0)}),p(s.$performanceActive,"click",e=>{e.stopPropagation(),r.togglePerformancePanel(!1)})),g.aiFace&&(p(s.$faceDetect,"click",e=>{e.stopPropagation(),r.faceDetect(!0)}),p(s.$faceDetectActive,"click",e=>{e.stopPropagation(),r.faceDetect(!1)})),r._opt.hasControl&&r._opt.controlAutoHide){p(r.$container,"mouseover",()=>{r.fullscreen||(E(s.$controls,"display","block"),f())}),p(r.$container,"mousemove",()=>{r.$container&&s.$controls&&(r.fullscreen,"none"===s.$controls.style.display)&&(E(s.$controls,"display","block"),f())}),p(r.$container,"mouseout",()=>{g(),E(s.$controls,"display","none")});let e=null;const f=()=>{g(),e=setTimeout(()=>{E(s.$controls,"display","none")},5e3)},g=()=>{e&&(clearTimeout(e),e=null)}}r._opt.playType===v&&(p(s.$playbackNarrow,"click",e=>{e.stopPropagation(),r.playback&&r.playback.narrowPrecision()}),p(s.$playbackExpand,"click",e=>{e.stopPropagation(),r.playback&&r.playback.expandPrecision()}),p(s.$playbackTimeList,"click",e=>{e=S(e);e.matches("div.jessibuca-playback-time-minute-one")&&r.playback&&r.playback.seek(e.dataset)}),r._opt.playbackConfig.showRateBtn&&(p(s.$speedMenu,"mouseover",()=>{s.$speedMenuList.classList.add("jessibuca-speed-menu-shown")}),p(s.$speedMenu,"mouseout",()=>{s.$speedMenuList.classList.remove("jessibuca-speed-menu-shown")}),p(s.$speedMenuList,"click",e=>{var t=S(e);if(t.matches("div.jessibuca-speed-menu-item")){const e=t.dataset;r.emit(w.playbackPreRateChange,e.speed)}})),r._opt.playbackConfig.supportWheel)&&p(s.$playbackTimeInner,"wheel",e=>{e.preventDefault(),0<(e.wheelDelta?e.wheelDelta/120:-(e.detail||0)/3)?r.playback&&r.playback.expandPrecision():r.playback&&r.playback.narrowPrecision()}),g.quality&&(p(s.$qualityMenu,"mouseover",()=>{s.$qualityMenuList.classList.add("jessibuca-quality-menu-shown")}),p(s.$qualityMenu,"mouseout",()=>{s.$qualityMenuList.classList.remove("jessibuca-quality-menu-shown")}),p(s.$qualityMenuList,"click",e=>{var t=S(e);if(t.matches("div.jessibuca-quality-menu-item")){const e=t.dataset;r.streamQuality=e.quality}})),g.scale&&(p(s.$scaleMenu,"mouseover",()=>{s.$scaleMenuList.classList.add("jessibuca-scale-menu-shown")}),p(s.$scaleMenu,"mouseout",()=>{s.$scaleMenuList.classList.remove("jessibuca-scale-menu-shown")}),p(s.$scaleMenuList,"click",e=>{var t=S(e);if(t.matches("div.jessibuca-scale-menu-item")){const e=t.dataset;r.setScaleMode(e.scale)}})),g.zoom&&(p(s.$zoom,"click",e=>{e.stopPropagation(),r.zooming=!0}),p(s.$zoomStop,"click",e=>{e.stopPropagation(),r.zooming=!1})),p(s.$zoomExpand,"click",e=>{e.stopPropagation(),r.zoom&&r.zoom.expandPrecision()}),p(s.$zoomNarrow,"click",e=>{e.stopPropagation(),r.zoom&&r.zoom.narrowPrecision()}),p(s.$zoomStop2,"click",e=>{e.stopPropagation(),r.zooming=!1}),g.close&&p(s.$close,"click",e=>{e.stopPropagation(),r.doDestroy()})}if(e._opt.hotKey){var i=e,a=this;const m=i["events"]["proxy"],A={};function n(e,t){A[e]?A[e].push(t):A[e]=[t]}n(27,()=>{i.fullscreen&&(i.fullscreen=!1)}),n(38,()=>{i.volume+=.05}),n(40,()=>{i.volume-=.05}),m(window,"keydown",e=>{if(a.isFocus){const a=document.activeElement.tagName.toUpperCase(),t=document.activeElement.getAttribute("contenteditable");if("INPUT"!==a&&"TEXTAREA"!==a&&""!==t&&"true"!==t){const a=A[e.keyCode];a&&(e.preventDefault(),a.forEach(e=>e()))}}})}var o,l,c,d,u,h;this.btnIndex=0,this.kbpsShow="0 KB/s",this.initLoadingBackground(),this.player.debug.log("Control","init")}destroy(){var e;this.$performancePanel&&(this.$performancePanel.innerHTML="",t(this.$performancePanel)||(e=this.player.$container.querySelector(".jessibuca-performance-panel"))&&this.player.$container&&this.player.$container.removeChild(e)),this.$poster&&!t(this.$poster)&&(e=this.player.$container.querySelector(".jessibuca-poster"))&&this.player.$container&&this.player.$container.removeChild(e),this.$loading&&!t(this.$loading)&&(e=this.player.$container.querySelector(".jessibuca-loading"))&&this.player.$container&&this.player.$container.removeChild(e),this.$loadingBg&&!t(this.$loadingBg)&&(e=this.player.$container.querySelector(".jessibuca-loading-bg"))&&this.player.$container&&this.player.$container.removeChild(e),this.$controls&&!t(this.$controls)&&(e=this.player.$container.querySelector(".jessibuca-controls"))&&this.player.$container&&this.player.$container.removeChild(e),this.$playBig&&!t(this.$playBig)&&(e=this.player.$container.querySelector(".jessibuca-play-big"))&&this.player.$container&&this.player.$container.removeChild(e),this.$recording&&!t(this.$recording)&&(e=this.player.$container.querySelector(".jessibuca-recording"))&&this.player.$container&&this.player.$container.removeChild(e),this.$ptzControl&&!t(this.$ptzControl)&&(e=this.player.$container.querySelector(".jessibuca-ptz-controls"))&&this.player.$container&&this.player.$container.removeChild(e),this.$zoomControls&&!t(this.$zoomControls)&&(e=this.player.$container.querySelector(".jessibuca-zoom-controls"))&&this.player.$container&&this.player.$container.removeChild(e),this.$contextmenus&&(this.$contextmenus.innerHTML="",t(this.$contextmenus)||(e=this.player.$container.querySelector(".jessibuca-contextmenus"))&&this.player.$container&&this.player.$container.removeChild(e)),this.btnIndex=0,this.extendBtnList=[],this.kbpsShow="0 KB/s",this.player.$container&&(this.player.$container.classList.remove("jessibuca-controls-show-auto-hide"),this.player.$container.classList.remove("jessibuca-controls-show")),this.player.debug.log("control","destroy")}getBtnIndex(){return this.btnIndex++}autoSize(){var e=this.player;e.$container.style.padding="0 0";const t=e.width,i=e.height,r=t/i,s=e.video.$videoElement.width/e.video.$videoElement.height;if(r>s){const r=(t-i*s)/2;e.$container.style.padding=`0 ${r}px`}else{const r=(i-t/s)/2;e.$container.style.padding=r+"px 0"}}initLoadingBackground(){var r=this.player;if(r._opt.loadingBackground&&r._opt.heartTimeoutReplayUseLastFrameShow){let e=r.height;var s=r._opt,a=(s.hasControl&&!s.controlAutoHide&&(e-=s.playType===v?48:38),this.$loadingBgImage.width=r.width,this.$loadingBgImage.height=e,s.rotate);270!==a&&90!==a||(control.$loadingBgImage.width=e,control.$loadingBgImage.height=r.width),this.$loadingBgImage.src=r._opt.loadingBackground;let t="contain",i=(s.isResize||(t="fill"),s.isFullResize&&(t="none"),"");"none"===s.mirrorRotate&&a&&(i+=" rotate("+a+"deg)"),"level"===s.mirrorRotate?i+=" rotateY(180deg)":"vertical"===s.mirrorRotate&&(i+=" rotateX(180deg)"),this.$loadingBgImage.style.transform=i,this.$loadingBgImage.style.objectFit=t,M(this.$loadingBg,"display","block")}}_validateExtendBtn(t){let e=!0;return t.name||(this.player.debug.warn("Control","extend button name is required"),e=!1),e&&-1!==this.extendBtnList.findIndex(e=>e.name===t.name)&&(this.player.debug.warn("Control",`extend button name: ${t.name} is already exist`),e=!1),e&&!t.icon&&(this.player.debug.warn("Control","extend button icon is required"),e=!1),e}addExtendBtn(){let t=0 ${t.icon?`
${t.iconTitle?` ${t.iconTitle} `:""}
`:""} ${t.activeIcon?`
${t.activeIconTitle?` ${t.activeIconTitle} `:""}
`:""} `,n=Array.from(r.children)[t.index],o=(n?n.insertAdjacentHTML("beforebegin",a):os(r,a),t.icon?r.querySelector(".jessibuca-icon-extend-"+i):null),l=t.icon?r.querySelector(".jessibuca-control-extend-"+i):null,c=t.activeIcon?r.querySelector(`.jessibuca-icon-extend-${i}-active`):null,d=t.activeIcon?r.querySelector(`.jessibuca-control-extend-${i}-active`):null,{proxy:u}=this.player["events"];t.icon&&(M(o,"background",`url(${t.icon}) no-repeat center`),M(o,"background-size","100% 100%"),M(l,"display","none"),t.iconHover)&&(u(o,"mouseover",()=>{M(o,"background",`url(${t.iconHover}) no-repeat center`),M(o,"background-size","100% 100%")}),u(o,"mouseout",()=>{M(o,"background",`url(${t.icon}) no-repeat center`),M(o,"background-size","100% 100%")})),t.activeIcon&&(M(c,"background",`url(${t.activeIcon}) no-repeat center`),M(c,"background-size","100% 100%"),M(d,"display","none"),t.activeIconHover)&&(u(c,"mouseover",()=>{M(c,"background",`url(${t.activeIconHover}) no-repeat center`),M(c,"background-size","100% 100%")}),u(c,"mouseout",()=>{M(c,"background",`url(${t.activeIcon}) no-repeat center`),M(c,"background-size","100% 100%")})),t.click&&o&&u(o,"click",e=>{e.preventDefault(),s&&(M(l,"display","none"),M(d,"display","flex")),t.click.call(this.player,this,e)}),t.activeClick&&c&&u(c,"click",e=>{e.preventDefault(),M(l,"display","flex"),M(d,"display","none"),t.activeClick.call(this.player,this,e)}),this.extendBtnList.push({name:i,$iconWrap:l,$activeIconWrap:d})}}}ns(".jessibuca-container{position:relative;width:100%;height:100%;overflow:hidden}.jessibuca-container.jessibuca-fullscreen-web{position:fixed;z-index:9999;left:0;top:0;right:0;bottom:0;width:100vw!important;height:100vh!important;background:#000}");class O{static init(){for(var e in O.types={avc1:[],avcC:[],hvc1:[],hvcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},O.types)O.types.hasOwnProperty(e)&&(O.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);var t=O.constants={};t.FTYP=new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]),t.STSD_PREFIX=new Uint8Array([0,0,0,0,0,0,0,1]),t.STTS=new Uint8Array([0,0,0,0,0,0,0,0]),t.STSC=t.STCO=t.STTS,t.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),t.HDLR_VIDEO=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),t.HDLR_AUDIO=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]),t.DREF=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),t.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),t.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])}static box(e){let t=8,i=null,r=Array.prototype.slice.call(arguments,1),s=r.length;for(let e=0;e>>24&255,i[1]=t>>>16&255,i[2]=t>>>8&255,i[3]=255&t,i.set(e,4);let a=8;for(let e=0;e>>24&255,e>>>16&255,e>>>8&255,255&e,t>>>24&255,t>>>16&255,t>>>8&255,255&t,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]))}static trak(e){return O.box(O.types.trak,O.tkhd(e),O.mdia(e))}static tkhd(e){var t=e.id,i=e.duration,r=e.presentWidth,e=e.presentHeight;return O.box(O.types.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t,0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,r>>>8&255,255&r,0,0,e>>>8&255,255&e,0,0]))}static mdia(e){return O.box(O.types.mdia,O.mdhd(e),O.hdlr(e),O.minf(e))}static mdhd(e){var t=e.timescale,e=e.duration;return O.box(O.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t,e>>>24&255,e>>>16&255,e>>>8&255,255&e,85,196,0,0]))}static hdlr(e){e="audio"===e.type?O.constants.HDLR_AUDIO:O.constants.HDLR_VIDEO;return O.box(O.types.hdlr,e)}static minf(e){var t="audio"===e.type?O.box(O.types.smhd,O.constants.SMHD):O.box(O.types.vmhd,O.constants.VMHD);return O.box(O.types.minf,t,O.dinf(),O.stbl(e))}static dinf(){return O.box(O.types.dinf,O.box(O.types.dref,O.constants.DREF))}static stbl(e){return O.box(O.types.stbl,O.stsd(e),O.box(O.types.stts,O.constants.STTS),O.box(O.types.stsc,O.constants.STSC),O.box(O.types.stsz,O.constants.STSZ),O.box(O.types.stco,O.constants.STCO))}static stsd(e){return"audio"===e.type?O.box(O.types.stsd,O.constants.STSD_PREFIX,O.mp4a(e)):"avc"===e.videoType?O.box(O.types.stsd,O.constants.STSD_PREFIX,O.avc1(e)):O.box(O.types.stsd,O.constants.STSD_PREFIX,O.hvc1(e))}static mp4a(e){var t=e.channelCount,i=e.audioSampleRate,t=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t,0,16,0,0,0,0,i>>>8&255,255&i,0,0]);return O.box(O.types.mp4a,t,O.esds(e))}static esds(e){var e=e.config||[],t=e.length,t=new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e).concat([6,1,2]));return O.box(O.types.esds,t)}static avc1(e){var t=e.avcc,i=e.codecWidth,e=e.codecHeight,i=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,i>>>8&255,255&i,e>>>8&255,255&e,0,72,0,0,0,72,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,255,255]);return O.box(O.types.avc1,i,O.box(O.types.avcC,t))}static hvc1(e){var t=e.avcc,i=e.codecWidth,e=e.codecHeight,i=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,i>>>8&255,255&i,e>>>8&255,255&e,0,72,0,0,0,72,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,255,255]);return O.box(O.types.hvc1,i,O.box(O.types.hvcC,t))}static mvex(e){return O.box(O.types.mvex,O.trex(e))}static trex(e){e=e.id,e=new Uint8Array([0,0,0,0,e>>>24&255,e>>>16&255,e>>>8&255,255&e,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return O.box(O.types.trex,e)}static moof(e,t){return O.box(O.types.moof,O.mfhd(e.sequenceNumber),O.traf(e,t))}static mfhd(e){e=new Uint8Array([0,0,0,0,e>>>24&255,e>>>16&255,e>>>8&255,255&e]);return O.box(O.types.mfhd,e)}static traf(e,t){var i=e.id,i=O.box(O.types.tfhd,new Uint8Array([0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i])),t=O.box(O.types.tfdt,new Uint8Array([0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t])),r=O.sdtp(e),e=O.trun(e,r.byteLength+16+16+8+16+8+8);return O.box(O.types.traf,i,t,e,r)}static sdtp(e){var t=new Uint8Array(5),e=e.flags;return t[4]=e.isLeading<<6|e.dependsOn<<4|e.isDependedOn<<2|e.hasRedundancy,O.box(O.types.sdtp,t)}static trun(e,t){var i=new Uint8Array(28),t=(i.set([0,0,15,1,0,0,0,1,(t+=36)>>>24&255,t>>>16&255,t>>>8&255,255&t],0),e.duration),r=e.size,s=e.flags,e=e.cts;return i.set([t>>>24&255,t>>>16&255,t>>>8&255,255&t,r>>>24&255,r>>>16&255,r>>>8&255,255&r,s.isLeading<<2|s.dependsOn,s.isDependedOn<<6|s.hasRedundancy<<4|s.isNonSync,0,0,e>>>24&255,e>>>16&255,e>>>8&255,255&e],12),O.box(O.types.trun,i)}static mdat(e){return O.box(O.types.mdat,e)}}O.init();class ds extends e{constructor(t){super(),this.player=t,this.isAvc=!0,this.mediaSource=new window.MediaSource,this.sourceBuffer=null,this.hasInit=!1,this.isInitInfo=!1,this.cacheTrack={},this.timeInit=!1,this.sequenceNumber=0,this.dropping=!1,this.firstRenderTime=null,this.$videoElement=null,this.mediaSourceAppendBufferFull=!1,this.mediaSourceAppendBufferError=!1,this.isDecodeFirstIIframe=!1,this.prevTimestamp=null,this.decodeDiffTimestamp=null,this.prevDts=null,this.prevPayloadBufferSize=0,this.isWidthOrHeightChanged=!1,this.prevTs=null,this.mediaSourceObjectURL=window.URL.createObjectURL(this.mediaSource),this.eventListenList=[],t._opt.mseUseCanvasRender?(this.$videoElement=document.createElement("video"),this.$videoElement.src=this.mediaSourceObjectURL,this.initVideoEvents()):(this.player.video.$videoElement.src=this.mediaSourceObjectURL,this.$videoElement=this.player.video.$videoElement);const{proxy:e}=t["events"],i=e(this.mediaSource,"sourceopen",()=>{this.player&&this.player.emit(w.mseSourceOpen)}),r=e(this.mediaSource,"sourceclose",()=>{this.player&&this.player.emit(w.mseSourceClose)}),s=e(this.mediaSource,"sourceended",()=>{this.player&&this.player.emit(w.mseSourceended)});if(this.eventListenList.push(i,r,s),this.player.isPlayer){const a=e(this.$videoElement,Me,e=>{if(this._handleUpdatePlaybackRate(),t._opt.mseUseCanvasRender)if(this.player.checkIsInRender())this.player.handleRender();else{const t=parseInt(e.timeStamp,10);this.player.debug.warn("MediaSource",`mseUseCanvasRender is true and $videoElement ts is ${t}, but not in render`)}else this.player.handleRender()}),i=e(this.$videoElement,Oe,()=>{t.debug.log("MediaSource","video playback Rate change",this.$videoElement&&this.$videoElement.playbackRate)});this.eventListenList.push(a,i)}t.debug.log("MediaSource","init")}destroy(){this.stop(),this.eventListenList.length&&(this.eventListenList.forEach(e=>e()),this.eventListenList=[]),this.mediaSource=null,this.sourceBuffer=null,this.hasInit=!1,this.isInitInfo=!1,this.sequenceNumber=0,this.cacheTrack={},this.timeInit=!1,this.mediaSourceAppendBufferFull=!1,this.mediaSourceAppendBufferError=!1,this.isDecodeFirstIIframe=!1,this.prevTimestamp=null,this.prevDts=null,this.prevPayloadBufferSize=0,this.prevTs=null,this.firstRenderTime=null,this.isWidthOrHeightChanged=!1,this.dropping=!1,this.$videoElement&&(this.player._opt.mseUseCanvasRender&&this.$videoElement.src&&(this.$videoElement.src="",this.$videoElement.removeAttribute("src")),this.$videoElement=null),this.mediaSourceObjectURL&&(window.URL.revokeObjectURL(this.mediaSourceObjectURL),this.mediaSourceObjectURL=null),this.off(),this.player.debug.log("MediaSource","destroy")}get state(){return this.mediaSource&&this.mediaSource.readyState}get isStateOpen(){return"open"===this.state}get isStateClosed(){return"closed"===this.state}get isStateEnded(){return"ended"===this.state}get duration(){return this.mediaSource&&this.mediaSource.duration||-1}set duration(e){this.mediaSource.duration=e}initVideoEvents(){var e=this.player.events["proxy"],t=e(this.$videoElement,Pe,()=>{this.player.debug.log("MediaSource","video canplay"),this.$videoElement.play().then(()=>{this.player.debug.log("MediaSource","video play")}).catch(e=>{this.player.debug.error("MediaSource","video play error ",e),this.player.emitError(m.mediaSourceUseCanvasRenderPlayFailed,e)})}),i=e(this.$videoElement,Be,()=>{this.player.debug.log("MediaSource","video waiting")}),e=e(this.$videoElement,Me,e=>{e=parseInt(e.timeStamp,10);this.player.emit(w.videoTimeUpdate,e),this.$videoElement.paused&&(this.player.debug.warn("MediaSource","video is paused and next try to replay"),this.$videoElement.play().then(()=>{this.player.debug.log("MediaSource","video is paused and replay success")}).catch(e=>{this.player.debug.warn("MediaSource","video is paused and replay error ",e)}))});this.eventListenList.push(t,i,e)}decodeVideo(t,i,r,s){var e=this.player;if(e)if(this.player.isDestroyed())this.player.debug.warn("MediaSource","decodeVideo() player is destroyed");else if(this.hasInit)if(!this.isDecodeFirstIIframe&&r&&(this.isDecodeFirstIIframe=!0),this.isDecodeFirstIIframe){if(r&&0===t[1]){const i=15&t[0];let e={};7==i?e=Mi(t.slice(5)):12==i&&(e=Gi(t));const s=this.player.video.videoInfo;s&&s.width&&s.height&&e&&e.codecWidth&&e.codecHeight&&(e.codecWidth!==s.width||e.codecHeight!==s.height)&&(this.player.debug.warn("MediaSource",` decodeVideo: video width or height is changed, old width is ${s.width}, old height is ${s.height}, new width is ${e.codecWidth}, new height is ${e.codecHeight}, and emit change event`),this.isWidthOrHeightChanged=!0,this.player.emitError(m.mseWidthOrHeightChange))}if(this.isWidthOrHeightChanged)this.player.debug.warn("MediaSource","decodeVideo: video width or height is changed, and return");else if(Ut(t))this.player.debug.warn("MediaSource","decodeVideo and payload is video sequence header so drop this frame");else if(t.byteLength<12)this.player.debug.warn("MediaSource","decodeVideo and payload is too small , payload length is "+t.byteLength);else{null===this.firstRenderTime&&(this.firstRenderTime=i);let e=i-this.firstRenderTime;if(e<0&&(this.player.debug.warn("MediaSource",`decodeVideo local dts is < 0 , ts is ${i} and prevTs is ${this.prevTs}, firstRenderTime is ${this.firstRenderTime} and mseCorrectTimeDuration is `+this.player._opt.mseCorrectTimeDuration),e=null===this.prevDts?0:this.prevDts+this.player._opt.mseCorrectTimeDuration,this._checkTsIsMaxDiff(i)))this.player.debug.warn("MediaSource",`decodeVideo is max diff , ts is ${i} and prevTs is ${this.prevTs}, diff is `+(this.prevTs-i)),this.emit(m.mediaSourceTsIsMaxDiff);else{if(null!==this.prevDts&&e<=this.prevDts){if(this.player.debug.warn("MediaSource",` decodeVideo dts is less than(or equal) prev dts , dts is ${e} and prev dts is ${this.prevDts} , and now ts is ${i} and prev ts is ${this.prevTs} , and diff is ${i-this.prevTs} and firstRenderTime is ${this.firstRenderTime}, and mseCorrectTimeDuration is ${this.player._opt.mseCorrectTimeDuration}, and prevPayloadBufferSize is ${this.prevPayloadBufferSize} and payload size is `+t.byteLength),e===this.prevDts&&this.prevPayloadBufferSize===t.byteLength)return void this.player.debug.warn("MediaSource","decodeVideo dts is equal to prev dts and payload size is equal to prev payload size so drop this frame");if(e=this.prevDts+this.player._opt.mseCorrectTimeDuration,this._checkTsIsMaxDiff(i))return this.player.debug.warn("MediaSource",`decodeVideo is max diff , ts is ${i} and prevTs is ${this.prevTs}, diff is ${this.prevTs-i} and emit replay`),void this.emit(m.mediaSourceTsIsMaxDiff)}this._decodeVideo(t,e,r,s,i),this.prevDts=e,this.prevPayloadBufferSize=t.byteLength,this.prevTs=i,this.player.getRenderType()===$&&this.player.video&&this.player.video.doAddContentToWatermark()}}}else this.player.debug.warn("MediaSource","decodeVideo isDecodeFirstIIframe false");else if(r&&0===t[1]){const s=15&t[0];(e.video.updateVideoInfo({encTypeCode:s}),12!=s||ft())?(e._times.decodeStart||(e._times.decodeStart=A()),this.hasInit=this._decodeConfigurationRecord(t,i,r,s)):this.emit(m.mediaSourceH265NotSupport)}else this.player.debug.warn("MediaSource",`decodeVideo has not init , isIframe is ${r} , payload is `+t[1])}_checkTsIsMaxDiff(e){return 0h?(a.debug.warn("MediaSource","dropping time is ",t-this.cacheTrack.dts),this.dropping=!1,this.cacheTrack={}):this.cacheTrack.id&&t>=this.cacheTrack.dts?(h=8+this.cacheTrack.size,(d=new Uint8Array(h))[0]=h>>>24&255,d[1]=h>>>16&255,d[2]=h>>>8&255,d[3]=255&h,d.set(O.types.mdat,4),d.set(this.cacheTrack.data,8),this.cacheTrack.duration=t-this.cacheTrack.dts,this.player.recorder&&this.player.recorder.isRecording&&this.player._opt.recordType===p&&this.player.recorder.handleAddFmp4Track(this.cacheTrack),h=O.moof(this.cacheTrack,this.cacheTrack.dts),(u=new Uint8Array(h.byteLength+d.byteLength)).set(h,0),u.set(d,h.byteLength),this.appendBuffer(u.buffer),a.emit(w.timeUpdate,s),a.videoTimestamp=s,a.updateStats({fps:!0,ts:s,mseTs:t,buf:a.demux&&a.demux.delay||0}),a._times.videoStart||(a._times.videoStart=A(),a.handlePlayToRenderTimes())):(a.debug.log("MediaSource",`timeInit set false , cacheTrack = {} now dts is ${t}, and ts is ${s} cacheTrack dts is `+(this.cacheTrack&&this.cacheTrack.dts)),this.timeInit=!1,this.cacheTrack={}),this.cacheTrack||(this.cacheTrack={}),this.cacheTrack.id=1,this.cacheTrack.sequenceNumber=++this.sequenceNumber,this.cacheTrack.size=o,this.cacheTrack.dts=t,this.cacheTrack.cts=r,this.cacheTrack.isKeyframe=i,this.cacheTrack.data=n,this.cacheTrack.flags={isLeading:0,dependsOn:i?2:1,isDependedOn:i?1:0,hasRedundancy:0,isNonSync:i?0:1},this.timeInit||1!==e.buffered.length||(a.debug.log("MediaSource","timeInit set true"),this.timeInit=!0,e.currentTime=e.buffered.end(0)),!this.isInitInfo&&0{this.player.emitError(m.mseSourceBufferError,e)}),i=i(this.sourceBuffer,"updateend",()=>{});this.eventListenList.push(r,i)}if(this.mediaSourceAppendBufferFull)t.warn("MediaSource","this.mediaSourceAppendBufferFull is true");else if(this.mediaSourceAppendBufferError)t.warn("MediaSource","this.mediaSourceAppendBufferError is true");else if(!1===this.sourceBuffer.updating&&this.isStateOpen)try{this.sourceBuffer.appendBuffer(e)}catch(e){t.warn("MediaSource","this.sourceBuffer.appendBuffer()",e.code,e),22===e.code?(this.stop(),this.mediaSourceAppendBufferFull=!0,this.emit(m.mediaSourceFull)):11===e.code?(this.stop(),this.mediaSourceAppendBufferError=!0,this.emit(m.mediaSourceAppendBufferError)):(t.error("MediaSource","appendBuffer error",e),this.player.emitError(w.mseSourceBufferError,e))}else this.isStateClosed?this.player.emitError(m.mseSourceBufferError,"mediaSource is not attached to video or mediaSource is closed"):this.isStateEnded?this.player.emitError(m.mseSourceBufferError,"mediaSource is end"):k(this.sourceBuffer.updating)&&(t.warn("MediaSource","mseSourceBufferBusy"),this.player.emit(w.mseSourceBufferBusy))}getSourceBufferUpdating(){return this.sourceBuffer&&this.sourceBuffer.updating}stop(){this.abortSourceBuffer(),this.endOfStream(),this.removeSourceBuffer()}dropSourceBuffer(e){var t=this.$videoElement;this.dropping=e,0"wakeLock"in navigator&&-1===window.navigator.userAgent.indexOf("Samsung")&&_(lt());class hs{constructor(e){this.player=e,this.enabled=!1,us()?(this.player.debug.log("NoSleep","Native Wake Lock API supported."),this._wakeLock=null,this.handleVisibilityChange=()=>{null!==this._wakeLock&&"visible"===document.visibilityState&&this.enable()},document.addEventListener("visibilitychange",this.handleVisibilityChange),document.addEventListener("fullscreenchange",this.handleVisibilityChange)):(this.player.debug.log("NoSleep","Native Wake Lock API not supported. so use video element."),this.noSleepVideo=document.createElement("video"),this.noSleepVideo.setAttribute("title","No Sleep"),this.noSleepVideo.setAttribute("playsinline",""),this._addSourceToVideo(this.noSleepVideo,"webm","data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQRChYECGFOAZwEAAAAAABLfEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHYTbuMU6uEElTDZ1OsggGXTbuMU6uEHFO7a1OsghLJ7AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmsirXsYMPQkBNgI1MYXZmNTguNDUuMTAwV0GNTGF2ZjU4LjQ1LjEwMESJiECzmgAAAAAAFlSua0C5rgEAAAAAAABO14EBc8WI9UhIq9EDJPCcgQAitZyDdW5khoVWX1ZQOIOBASPjg4QF9eEA4AEAAAAAAAAbsIIBQLqB8FSwggElVLqB8FWwiFW3gQFVuIECrgEAAAAAAABZ14ECc8WIUEWPA9J/iJ6cgQAitZyDdW5khoZBX09QVVNWqoNjLqBWu4QExLQAg4EC4ZGfgQG1iEDncAAAAAAAYmSBIGOik09wdXNIZWFkAQE4AYC7AAAAAAASVMNnQcJzcwEAAAAAAACXY8CAZ8gBAAAAAAAAFUWji01BSk9SX0JSQU5ERIeEaXNvbWfIAQAAAAAAABZFo41NSU5PUl9WRVJTSU9ORIeDNTEyZ8gBAAAAAAAAJ0WjkUNPTVBBVElCTEVfQlJBTkRTRIeQaXNvbWlzbzJhdmMxbXA0MWfIAQAAAAAAABpFo4dFTkNPREVSRIeNTGF2ZjU4LjQ1LjEwMHNzAQAAAAAAAIZjwItjxYj1SEir0QMk8GfIAQAAAAAAAB5Fo4xIQU5ETEVSX05BTUVEh4xWaWRlb0hhbmRsZXJnyAEAAAAAAAAhRaOHRU5DT0RFUkSHlExhdmM1OC45MS4xMDAgbGlidnB4Z8iiRaOIRFVSQVRJT05Eh5QwMDowMDowNS4wMDcwMDAwMDAAAHNzAQAAAAAAAIdjwItjxYhQRY8D0n+InmfIAQAAAAAAAB5Fo4xIQU5ETEVSX05BTUVEh4xTb3VuZEhhbmRsZXJnyAEAAAAAAAAiRaOHRU5DT0RFUkSHlUxhdmM1OC45MS4xMDAgbGlib3B1c2fIokWjiERVUkFUSU9ORIeUMDA6MDA6MDUuMDE4MDAwMDAwAAAfQ7Z1T2TngQCjh4IAAID4//6jQKSBAAeAMBIAnQEqQAHwAABHCIWFiIWEiAICAAYWBPcGgWSfa9ubJzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh7Jzh69AD+/6tQgKOHggAVgPj//qOHggApgPj//qOHggA9gPj//qOHggBRgPj//qOHggBlgPj//qOegQBrANECAAUQrAAYABhYL/QACIAEM1+tck+ccwAAo4eCAHmA+P/+o4eCAI2A+P/+o4eCAKGA+P/+o4eCALWA+P/+o4eCAMmA+P/+o56BAM8A0QIABRCsABgAGFgv9AAIgAQzX61yT5xzAACjh4IA3YD4//6jh4IA8YD4//6jh4IBBYD4//6jh4IBGYD4//6jh4IBLYD4//6jnoEBMwDRAgAFEKwAGAAYWC/0AAiABDNfrXJPnHMAAKOHggFBgPj//qOHggFVgPj//qOHggFpgPj//qOHggF9gPj//qOHggGRgPj//qOegQGXANECAAUQrAAYABhYL/QACIAEM1+tck+ccwAAo4eCAaWA+P/+o4eCAbmA+P/+o4eCAc2A+P/+o4eCAeGA+P/+o4eCAfWA+P/+o56BAfsA0QIABRCsABgAGFgv9AAIgAQzX61yT5xzAACjh4ICCYD4//6jh4ICHYD4//6jh4ICMYD4//6jh4ICRYD4//6jh4ICWYD4//6jnoECXwDRAgAFEKwAGAAYWC/0AAiABDNfrXJPnHMAAKOHggJtgPj//qOHggKBgPj//qOHggKVgPj//qOHggKpgPj//qOHggK9gPj//qOegQLDANECAAUQEBRgAGFgv9AAIgAQzX61yT5xzAAAo4eCAtGA+P/+o4eCAuWA+P/+o4eCAvmA+P/+o4eCAw2A+P/+o4eCAyGA+P/+o56BAycA0QIABRCsABgAGFgv9AAIgAQzX61yT5xzAACjh4IDNYD4//6jh4IDSYD4//6jh4IDXYD4//6jh4IDcYD4//6jh4IDhYD4//6jnoEDiwDRAgAFEKwAGAAYWC/0AAiABDNfrXJPnHMAAKOHggOZgPj//qOHggOtgPj//qOHggPBgPj//qOHggPVgPj//qOHggPpgPj//qOegQPvANECAAUQrAAYABhYL/QACIAEM1+tck+ccwAAo4eCA/2A+P/+o4eCBBGA+P/+o4eCBCWA+P/+o4eCBDmA+P/+o4eCBE2A+P/+o56BBFMA0QIABRCsABgAGFgv9AAIgAQzX61yT5xzAACjh4IEiID4//6jh4IEnID4//6jh4IEsID4//6jnoEEtwDRAgAFEKwAGAAYWC/0AAiABDNfrXJPnHMAAKOHggTEgPj//qOHggTYgPj//qOHggTsgPj//qOHggUAgPj//qOHggUUgPj//qOegQUbANECAAUQrAAYABhYL/QACIAEM1+tck+ccwAAo4eCBSiA+P/+o4eCBTyA+P/+o4eCBVCA+P/+o4eCBWSA+P/+o4eCBXiA+P/+o56BBX8A0QIABRCsABgAGFgv9AAIgAQzX61yT5xzAACjh4IFjID4//6jh4IFoID4//6jh4IFtID4//6jh4IFyID4//6jh4IF3ID4//6jnoEF4wDRAgAFEKwAGAAYWC/0AAiABDNfrXJPnHMAAKOHggXwgPj//qOHggYEgPj//qOHggYYgPj//qOHggYsgPj//qOHggZAgPj//qOegQZHANECAAUQrAAYABhYL/QACIAEM1+tck+ccwAAo4eCBlSA+P/+o4eCBmiA+P/+o4eCBnyA+P/+o4eCBpCA+P/+o4eCBqSA+P/+o56BBqsA0QIABRCsABgAGFgv9AAIgAQzX61yT5xzAACjh4IGuID4//6jh4IGzID4//6jh4IG4ID4//6jh4IG9ID4//6jh4IHCID4//6jnoEHDwDRAgAFEBAUYABhYL/QACIAEM1+tck+ccwAAKOHggccgPj//qOHggcwgPj//qOHggdEgPj//qOHggdYgPj//qOHggdsgPj//qOegQdzANECAAUQrAAYABhYL/QACIAEM1+tck+ccwAAo4eCB4CA+P/+o4eCB5SA+P/+o4eCB6iA+P/+o4eCB7yA+P/+o4eCB9CA+P/+o56BB9cA0QIABRCsABgAGFgv9AAIgAQzX61yT5xzAACjh4IH5ID4//6jh4IH+ID4//6jh4IIDID4//6jh4IIIID4//6jh4IINID4//6jnoEIOwDRAgAFEKwAGAAYWC/0AAiABDNfrXJPnHMAAKOHgghIgPj//qOHgghcgPj//qOHgghwgPj//qOHggiEgPj//qOegQifANECAAUQrAAYABhYL/QACIAEM1+tck+ccwAAo4eCCMCA+P/+o4eCCNSA+P/+o4eCCOiA+P/+o4eCCPyA+P/+o56BCQMA0QIABRCsABgAGFgv9AAIgAQzX61yT5xzAACjh4IJEID4//6jh4IJJID4//6jh4IJOID4//6jh4IJTID4//6jh4IJYID4//6jnoEJZwDRAgAFEKwAGAAYWC/0AAiABDNfrXJPnHMAAKOHggl0gPj//qOHggmIgPj//qOHggmcgPj//qOHggmwgPj//qOHggnEgPj//qOegQnLANECAAUQrAAYABhYL/QACIAEM1+tck+ccwAAo4eCCdiA+P/+o4eCCeyA+P/+o4eCCgCA+P/+o4eCChSA+P/+o4eCCiiA+P/+o56BCi8A0QIABRCsABgAGFgv9AAIgAQzX61yT5xzAACjh4IKPID4//6jh4IKUID4//6jh4IKZID4//6jh4IKeID4//6jh4IKjID4//6jnoEKkwDRAgAFEKwAGAAYWC/0AAiABDNfrXJPnHMAAKOHggqggPj//qOHggq0gPj//qOHggrIgPj//qOHggrcgPj//qOHggrwgPj//qOegQr3ANECAAUQrAAYABhYL/QACIAEM1+tck+ccwAAo4eCCwSA+P/+o4eCCxiA+P/+o4eCCyyA+P/+o4eCC0CA+P/+o4eCC1SA+P/+o56BC1sA0QIABRAQFGAAYWC/0AAiABDNfrXJPnHMAACjh4ILaID4//6jh4ILfID4//6jh4ILkID4//6jh4ILpID4//6jh4ILuID4//6jnoELvwDRAgAFEKwAGAAYWC/0AAiABDNfrXJPnHMAAKOHggvMgPj//qOHggvggPj//qOHggv0gPj//qOHggwIgPj//qOHggwcgPj//qOegQwjANECAAUQrAAYABhYL/QACIAEM1+tck+ccwAAo4eCDDCA+P/+o4eCDESA+P/+o4eCDFiA+P/+o4eCDGyA+P/+o4eCDICA+P/+o56BDIcA0QIABRCsABgAGFgv9AAIgAQzX61yT5xzAACjh4IMlID4//6jh4IMqID4//6jh4IMvID4//6jh4IM0ID4//6jnoEM6wDRAgAFEKwAGAAYWC/0AAiABDNfrXJPnHMAAKOHgg0MgPj//qOHgg0ggPj//qOHgg00gPj//qOHgg1IgPj//qOegQ1PANECAAUQrAAYABhYL/QACIAEM1+tck+ccwAAo4eCDVyA+P/+o4eCDXCA+P/+o4eCDYSA+P/+o4eCDZiA+P/+o4eCDayA+P/+o56BDbMA0QIABRCsABgAGFgv9AAIgAQzX61yT5xzAACjh4INwID4//6jh4IN1ID4//6jh4IN6ID4//6jh4IN/ID4//6jh4IOEID4//6jnoEOFwDRAgAFEKwAGAAYWC/0AAiABDNfrXJPnHMAAKOHgg4kgPj//qOHgg44gPj//qOHgg5MgPj//qOHgg5ggPj//qOHgg50gPj//qOegQ57ANECAAUQrAAYABhYL/QACIAEM1+tck+ccwAAo4eCDoiA+P/+o4eCDpyA+P/+o4eCDrCA+P/+o4eCDsSA+P/+o4eCDtiA+P/+o56BDt8A0QIABRCsABgAGFgv9AAIgAQzX61yT5xzAACjh4IO7ID4//6jh4IPAID4//6jh4IPFID4//6jh4IPKID4//6jh4IPPID4//6jnoEPQwDRAgAFEKwAGAAYWC/0AAiABDNfrXJPnHMAAKOHgg9QgPj//qOHgg9kgPj//qOHgg94gPj//qOHgg+MgPj//qOHgg+ggPj//qOegQ+nANECAAUQEBRgAGFgv9AAIgAQzX61yT5xzAAAo4eCD7SA+P/+o4eCD8iA+P/+o4eCD9yA+P/+o4eCD/CA+P/+o4eCEASA+P/+o56BEAsA0QIABRCsABgAGFgv9AAIgAQzX61yT5xzAACjh4IQGID4//6jh4IQLID4//6jh4IQQID4//6jh4IQVID4//6jh4IQaID4//6jnoEQbwDRAgAFEKwAGAAYWC/0AAiABDNfrXJPnHMAAKOHghB8gPj//qOHghCQgPj//qOHghCkgPj//qOHghC4gPj//qOHghDMgPj//qOegRDTANECAAUQrAAYABhYL/QACIAEM1+tck+ccwAAo4eCEOCA+P/+o4eCEPSA+P/+o4eCEQiA+P/+o56BETcA0QIABRCsABgAGFgv9AAIgAQzX61yT5xzAACjh4IRQ4D4//6jh4IRV4D4//6jh4IRa4D4//6jh4IRf4D4//6jh4IRk4D4//6jnoERmwDRAgAFEKwAGAAYWC/0AAiABDNfrXJPnHMAAKOHghGngPj//qOHghG7gPj//qOHghHPgPj//qOHghHjgPj//qOHghH3gPj//qOegRH/ANECAAUQrAAYABhYL/QACIAEM1+tck+ccwAAo4eCEguA+P/+o4eCEh+A+P/+o4eCEjOA+P/+o4eCEkeA+P/+o4eCEluA+P/+o56BEmMA0QIABRCsABgAGFgv9AAIgAQzX61yT5xzAACjh4ISb4D4//6jh4ISg4D4//6jh4ISl4D4//6jh4ISq4D4//6jh4ISv4D4//6jnoESxwDRAgAFEKwAGAAYWC/0AAiABDNfrXJPnHMAAKOHghLTgPj//qOHghLngPj//qOHghL7gPj//qOHghMPgPj//qOHghMjgPj//qOegRMrANECAAUQrAAYABhYL/QACIAEM1+tck+ccwAAo4eCEzeA+P/+o4eCE0uA+P/+o4eCE1+A+P/+o4eCE3OA+P/+oAEAAAAAAAAPoYeCE4cA+P/+daKDB/KBHFO7a5G7j7OBB7eK94EB8YIDX/CBDA=="),this._addSourceToVideo(this.noSleepVideo,"mp4","data:video/mp4;base64,AAAAIGZ0eXBpc29tAAACAGlzb21pc28yYXZjMW1wNDEAAAAIZnJlZQAACORtZGF03gIATGF2YzU4LjM1LjEwMAACMEAOAAACcQYF//9t3EXpvebZSLeWLNgg2SPu73gyNjQgLSBjb3JlIDE2MSByMzAyNyA0MTIxMjc3IC0gSC4yNjQvTVBFRy00IEFWQyBjb2RlYyAtIENvcHlsZWZ0IDIwMDMtMjAyMCAtIGh0dHA6Ly93d3cudmlkZW9sYW4ub3JnL3gyNjQuaHRtbCAtIG9wdGlvbnM6IGNhYmFjPTAgcmVmPTMgZGVibG9jaz0xOjA6MCBhbmFseXNlPTB4MToweDExMSBtZT1oZXggc3VibWU9NyBwc3k9MSBwc3lfcmQ9MS4wMDowLjAwIG1peGVkX3JlZj0xIG1lX3JhbmdlPTE2IGNocm9tYV9tZT0xIHRyZWxsaXM9MSA4eDhkY3Q9MCBjcW09MCBkZWFkem9uZT0yMSwxMSBmYXN0X3Bza2lwPTEgY2hyb21hX3FwX29mZnNldD0tMiB0aHJlYWRzPTcgbG9va2FoZWFkX3RocmVhZHM9MSBzbGljZWRfdGhyZWFkcz0wIG5yPTAgZGVjaW1hdGU9MSBpbnRlcmxhY2VkPTAgYmx1cmF5X2NvbXBhdD0wIGNvbnN0cmFpbmVkX2ludHJhPTAgYmZyYW1lcz0wIHdlaWdodHA9MCBrZXlpbnQ9MjUwIGtleWludF9taW49MTAgc2NlbmVjdXQ9NDAgaW50cmFfcmVmcmVzaD0wIHJjX2xvb2thaGVhZD00MCByYz1jcmYgbWJ0cmVlPTEgY3JmPTIzLjAgcWNvbXA9MC42MCBxcG1pbj0wIHFwbWF4PTY5IHFwc3RlcD00IGlwX3JhdGlvPTEuNDAgYXE9MToxLjAwAIAAAADvZYiED/JigADD7JycnJycnJycnJycnJycnJycnJ11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111114BGCAHARggBwEYIAcBGCAHARggBwAAAAdBmjgf4BLYARggBwEYIAcBGCAHARggBwAAAAdBmlQH+AS2ARggBwEYIAcBGCAHARggBwAAAAdBmmA/wCWwARggBwEYIAcBGCAHARggBwEYIAcAAAAHQZqAP8AlsAEYIAcBGCAHARggBwEYIAcAAAAHQZqgP8AlsAEYIAcBGCAHARggBwEYIAcAAAAHQZrAP8AlsAEYIAcBGCAHARggBwEYIAcBGCAHAAAAB0Ga4D/AJbABGCAHARggBwEYIAcBGCAHAAAAB0GbAD/AJbABGCAHARggBwEYIAcBGCAHAAAAB0GbID/AJbABGCAHARggBwEYIAcBGCAHARggBwAAAAdBm0A/wCWwARggBwEYIAcBGCAHAAAAB0GbYD/AJbABGCAHARggBwEYIAcAAAAHQZuAP8AlsAEYIAcBGCAHARggBwEYIAcBGCAHAAAAB0GboD/AJbABGCAHARggBwEYIAcBGCAHAAAAB0GbwD/AJbABGCAHARggBwEYIAcBGCAHAAAAB0Gb4D/AJbABGCAHARggBwEYIAcBGCAHARggBwAAAAdBmgA/wCWwARggBwEYIAcBGCAHARggBwAAAAdBmiA/wCWwARggBwEYIAcBGCAHARggBwAAAAdBmkA/wCWwARggBwEYIAcBGCAHARggBwEYIAcAAAAHQZpgP8AlsAEYIAcBGCAHARggBwEYIAcAAAAHQZqAP8AlsAEYIAcBGCAHARggBwEYIAcAAAAHQZqgP8AlsAEYIAcBGCAHARggBwAAAAdBmsA/wCWwARggBwEYIAcBGCAHARggBwAAAAdBmuA/wCWwARggBwEYIAcBGCAHARggBwAAAAdBmwA/wCWwARggBwEYIAcBGCAHARggBwEYIAcAAAAHQZsgP8AlsAEYIAcBGCAHARggBwEYIAcAAAAHQZtAP8AlsAEYIAcBGCAHARggBwEYIAcAAAAHQZtgP8AlsAEYIAcBGCAHARggBwEYIAcBGCAHAAAAB0GbgD/AJbABGCAHARggBwEYIAcBGCAHAAAAB0GboD/AJbABGCAHARggBwEYIAcBGCAHAAAAB0GbwD/AJbABGCAHARggBwEYIAcBGCAHARggBwAAAAdBm+A/wCWwARggBwEYIAcBGCAHARggBwAAAAdBmgA/wCWwARggBwEYIAcAAAAHQZogP8AlsAEYIAcBGCAHARggBwEYIAcBGCAHAAAAB0GaQD/AJbABGCAHARggBwEYIAcBGCAHAAAAB0GaYD/AJbABGCAHARggBwEYIAcBGCAHAAAAB0GagD/AJbABGCAHARggBwEYIAcBGCAHARggBwAAAAdBmqA/wCWwARggBwEYIAcBGCAHARggBwAAAAdBmsA/wCWwARggBwEYIAcBGCAHARggBwAAAAdBmuA/wCWwARggBwEYIAcBGCAHARggBwEYIAcAAAAHQZsAP8AlsAEYIAcBGCAHARggBwEYIAcAAAAHQZsgP8AlsAEYIAcBGCAHARggBwEYIAcAAAAHQZtAP8AlsAEYIAcBGCAHARggBwEYIAcBGCAHAAAAB0GbYD/AJbABGCAHARggBwAAAAdBm4A/wCWwARggBwEYIAcBGCAHARggBwAAAAdBm6A/wCWwARggBwEYIAcBGCAHARggBwEYIAcAAAAHQZvAP8AlsAEYIAcBGCAHARggBwEYIAcAAAAHQZvgP8AlsAEYIAcBGCAHARggBwEYIAcAAAAHQZoAO8AlsAEYIAcBGCAHARggBwEYIAcBGCAHAAAAB0GaIDfAJbABGCAHARggBwEYIAcBGCAHAAAMxm1vb3YAAABsbXZoZAAAAAAAAAAAAAAAAAAAA+gAABOgAAEAAAEAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAPLdHJhawAAAFx0a2hkAAAAAwAAAAAAAAAAAAAAAQAAAAAAABOIAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAQAAAAAElVVUA8AAAAAAAJGVkdHMAAAAcZWxzdAAAAAAAAAABAAATiAAAAAAAAQAAAAADQ21kaWEAAAAgbWRoZAAAAAAAAAAAAAAAAAAAKAAAAMgAVcQAAAAAAC1oZGxyAAAAAAAAAAB2aWRlAAAAAAAAAAAAAAAAVmlkZW9IYW5kbGVyAAAAAu5taW5mAAAAFHZtaGQAAAABAAAAAAAAAAAAAAAkZGluZgAAABxkcmVmAAAAAAAAAAEAAAAMdXJsIAAAAAEAAAKuc3RibAAAAKpzdHNkAAAAAAAAAAEAAACaYXZjMQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAFAAPAASAAAAEgAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABj//wAAADRhdmNDAULAC//hABxnQsAL2QFB+/8ACwAMEAAAAwAQAAADAUDxQqSAAQAFaMuDyyAAAAAQcGFzcAAAAAsAAAAMAAAAGHN0dHMAAAAAAAAAAQAAADIAAAQAAAAAFHN0c3MAAAAAAAAAAQAAAAEAAAAcc3RzYwAAAAAAAAABAAAAAQAAAAEAAAABAAAA3HN0c3oAAAAAAAAAAAAAADIAAANoAAAACwAAAAsAAAALAAAACwAAAAsAAAALAAAACwAAAAsAAAALAAAACwAAAAsAAAALAAAACwAAAAsAAAALAAAACwAAAAsAAAALAAAACwAAAAsAAAALAAAACwAAAAsAAAALAAAACwAAAAsAAAALAAAACwAAAAsAAAALAAAACwAAAAsAAAALAAAACwAAAAsAAAALAAAACwAAAAsAAAALAAAACwAAAAsAAAALAAAACwAAAAsAAAALAAAACwAAAAsAAAALAAAACwAAANhzdGNvAAAAAAAAADIAAABFAAADwQAAA9wAAAP3AAAEFgAABDEAAARMAAAEawAABIYAAAShAAAEwAAABNcAAATuAAAFDQAABSgAAAVDAAAFYgAABX0AAAWYAAAFtwAABdIAAAXtAAAGBAAABh8AAAY6AAAGWQAABnQAAAaPAAAGrgAABskAAAbkAAAHAwAABx4AAAcxAAAHUAAAB2sAAAeGAAAHpQAAB8AAAAfbAAAH+gAACBUAAAgwAAAITwAACGIAAAh9AAAInAAACLcAAAjSAAAI8QAACCV0cmFrAAAAXHRraGQAAAADAAAAAAAAAAAAAAACAAAAAAAAE6AAAAAAAAAAAAAAAAEBAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAkZWR0cwAAABxlbHN0AAAAAAAAAAEAABOIAAAEAAABAAAAAAedbWRpYQAAACBtZGhkAAAAAAAAAAAAAAAAAACsRAADYVRVxAAAAAAALWhkbHIAAAAAAAAAAHNvdW4AAAAAAAAAAAAAAABTb3VuZEhhbmRsZXIAAAAHSG1pbmYAAAAQc21oZAAAAAAAAAAAAAAAJGRpbmYAAAAcZHJlZgAAAAAAAAABAAAADHVybCAAAAABAAAHDHN0YmwAAABqc3RzZAAAAAAAAAABAAAAWm1wNGEAAAAAAAAAAQAAAAAAAAAAAAIAEAAAAACsRAAAAAAANmVzZHMAAAAAA4CAgCUAAgAEgICAF0AVAAAAAAENiAAABVQFgICABRIIVuUABoCAgAECAAAAYHN0dHMAAAAAAAAACgAAAC8AAAQAAAAAAQAACtUAAAAsAAAEAAAAAAEAAArWAAAALAAABAAAAAABAAAK1QAAACwAAAQAAAAAAQAACtUAAAAaAAAEAAAAAAEAAAH/AAABzHN0c2MAAAAAAAAAJQAAAAEAAAABAAAAAQAAAAIAAAAFAAAAAQAAAAMAAAAEAAAAAQAAAAUAAAAFAAAAAQAAAAYAAAAEAAAAAQAAAAgAAAAFAAAAAQAAAAkAAAAEAAAAAQAAAAsAAAAFAAAAAQAAAAwAAAADAAAAAQAAAA4AAAAFAAAAAQAAAA8AAAAEAAAAAQAAABEAAAAFAAAAAQAAABIAAAAEAAAAAQAAABQAAAAFAAAAAQAAABUAAAAEAAAAAQAAABcAAAADAAAAAQAAABgAAAAEAAAAAQAAABoAAAAFAAAAAQAAABsAAAAEAAAAAQAAAB0AAAAFAAAAAQAAAB4AAAAEAAAAAQAAACAAAAAFAAAAAQAAACEAAAAEAAAAAQAAACIAAAACAAAAAQAAACMAAAAFAAAAAQAAACQAAAAEAAAAAQAAACYAAAAFAAAAAQAAACcAAAAEAAAAAQAAACkAAAAFAAAAAQAAACoAAAAEAAAAAQAAACwAAAAFAAAAAQAAAC0AAAACAAAAAQAAAC4AAAAEAAAAAQAAAC8AAAAFAAAAAQAAADAAAAAEAAAAAQAAADIAAAAFAAAAAQAAADMAAAAEAAAAAQAAA1xzdHN6AAAAAAAAAAAAAADSAAAAFQAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAA3HN0Y28AAAAAAAAAMwAAADAAAAOtAAADzAAAA+cAAAQCAAAEIQAABDwAAARXAAAEdgAABJEAAASsAAAEywAABOIAAAT5AAAFGAAABTMAAAVOAAAFbQAABYgAAAWjAAAFwgAABd0AAAX4AAAGDwAABioAAAZFAAAGZAAABn8AAAaaAAAGuQAABtQAAAbvAAAHDgAABykAAAc8AAAHWwAAB3YAAAeRAAAHsAAAB8sAAAfmAAAIBQAACCAAAAg7AAAIWgAACG0AAAiIAAAIpwAACMIAAAjdAAAI/AAAABpzZ3BkAQAAAHJvbGwAAAACAAAAAf//AAAAHHNiZ3AAAAAAcm9sbAAAAAEAAADSAAAAAQAAAGJ1ZHRhAAAAWm1ldGEAAAAAAAAAIWhkbHIAAAAAAAAAAG1kaXJhcHBsAAAAAAAAAAAAAAAALWlsc3QAAAAlqXRvbwAAAB1kYXRhAAAAAQAAAABMYXZmNTguMjAuMTAw"),Object.assign(this.noSleepVideo.style,{position:"absolute",left:"-100%",top:"-100%"}),document.querySelector("body").append(this.noSleepVideo),this.noSleepVideo.addEventListener("timeupdate",()=>{this.noSleepVideo&&4{this._wakeLock=e,this.enabled=!0,t.log("wakeLock","Wake Lock active."),this._wakeLock.addEventListener("release",()=>{t.log("wakeLock","Wake Lock released.")})}).catch(e=>{throw this.enabled=!1,t.warn("wakeLock",e.name+", "+e.message),e}):this.noSleepVideo.play().then(e=>(t.log("wakeLock","noSleepVideo Wake Lock active."),this.enabled=!0,e)).catch(e=>{throw t.warn("wakeLock",`noSleepVideo ${e.name}, `+e.message),this.enabled=!1,e})}disable(){us()?(this._wakeLock&&this._wakeLock.release(),this._wakeLock=null):this.noSleepVideo.pause(),this.enabled=!1,this.player.debug.log("wakeLock","Disabling wake lock.")}}var s=(Sr=Xe(function(e,t){"undefined"!=typeof window&&(e.exports=function(){return i={"./node_modules/eventemitter3/index.js":function(e,t,i){var r=Object.prototype.hasOwnProperty,p="~";function s(){}function a(e,t,i){this.fn=e,this.context=t,this.once=i||!1}function n(e,t,i,r,s){if("function"!=typeof i)throw new TypeError("The listener must be a function");i=new a(i,r||e,s),r=p?p+t:t;return e._events[r]?e._events[r].fn?e._events[r]=[e._events[r],i]:e._events[r].push(i):(e._events[r]=i,e._eventsCount++),e}function l(e,t){0==--e._eventsCount?e._events=new s:delete e._events[t]}function o(){this._events=new s,this._eventsCount=0}Object.create&&(s.prototype=Object.create(null),(new s).__proto__||(p=!1)),o.prototype.eventNames=function(){var e,t,i=[];if(0===this._eventsCount)return i;for(t in e=this._events)r.call(e,t)&&i.push(p?t.slice(1):t);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},o.prototype.listeners=function(e){var e=p?p+e:e,t=this._events[e];if(!t)return[];if(t.fn)return[t.fn];for(var i=0,r=t.length,s=new Array(r);ie||r.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),s.currentTime=e+.05),(t=this.getNextFragment(a,n))?"identity"!==(null==(i=t.decryptdata)?void 0:i.keyFormat)||null!=(r=t.decryptdata)&&r.key?this.loadFragment(t,n,a):this.loadKey(t,n):this.bufferFlushed=!0)))))},w.getMaxBufferLength=function(){var e=v.prototype.getMaxBufferLength.call(this),t=this.getFwdBufferInfo(this.videoBuffer||this.media,d.PlaylistLevelType.MAIN);return null===t?e:Math.max(e,t.len)},w.onMediaDetaching=function(){this.videoBuffer=null,v.prototype.onMediaDetaching.call(this)},w.onAudioTracksUpdated=function(e,t){t=t.audioTracks;this.resetTransmuxer(),this.levels=t.map(function(e){return new r.Level(e)})},w.onAudioTrackSwitching=function(e,t){var i=!!t.url,t=(this.trackId=t.id,this.fragCurrent);null!=t&&t.loader&&t.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),i?this.setInterval(100):this.resetTransmuxer(),i?(this.audioSwitch=!0,this.state=u.State.IDLE):this.state=u.State.STOPPED,this.tick()},w.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},w.onLevelLoaded=function(e,t){this.mainDetails=t.details},w.onAudioTrackLoaded=function(e,t){var i=this.levels,r=t.details,t=t.id;if(i){this.log("Track "+t+" loaded ["+r.startSN+","+r.endSN+"],duration:"+r.totalduration);var i=i[t],s=0;if(r.live||null!=(a=i.details)&&a.live){var a=this.mainDetails;if(r.fragments[0]||(r.deltaUpdateFailed=!0),r.deltaUpdateFailed||!a)return;s=!i.details&&r.hasProgramDateTime&&a.hasProgramDateTime?(Object(l.alignMediaPlaylistByPDT)(r,a),r.fragments[0].start):this.alignPlaylists(r,i.details)}i.details=r,this.levelLastLoaded=t,this.startFragRequested||!this.mainDetails&&r.live||this.setStartPosition(i.details,s),this.state!==u.State.WAITING_TRACK||this.waitForCdnTuneIn(r)||(this.state=u.State.IDLE),this.tick()}else this.warn("Audio tracks were reset while loading level "+t)},w._handleFragmentLoadProgress=function(e){var t,i,r,s,a=e.frag,n=e.part,e=e.payload,o=this.config,l=this.trackId,c=this.levels;c?(c=c[l],console.assert(c,"Audio track is defined on fragment load progress"),t=c.details,console.assert(t,"Audio track details are defined on fragment load progress"),o=o.defaultAudioCodec||c.audioCodec||"mp4a.40.2",c=(c=this.transmuxer)||(this.transmuxer=new g.default(this.hls,d.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this))),i=this.initPTS[a.cc],r=null==(r=a.initSegment)?void 0:r.data,void 0!==i?(s=n?n.index:-1,s=new m.ChunkMetadata(a.level,a.sn,a.stats.chunkCount,e.byteLength,s,-1!==s),c.push(e,r,o,"",a,n,t.totalduration,!1,s,i)):(A.logger.log("Unknown video PTS for cc "+a.cc+", waiting for video PTS before demuxing audio frag "+a.sn+" of ["+t.startSN+" ,"+t.endSN+"],track "+l),(this.waitingData=this.waitingData||{frag:a,part:n,cache:new f.default,complete:!1}).cache.push(new Uint8Array(e)),this.waitingVideoCC=this.videoTrackCC,this.state=u.State.WAITING_INIT_PTS)):this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+a.sn+" of level "+a.level+" will not be buffered")},w._handleFragmentLoadComplete=function(e){this.waitingData?this.waitingData.complete=!0:v.prototype._handleFragmentLoadComplete.call(this,e)},w.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},w.onBufferCreated=function(e,t){var i=t.tracks.audio;i&&(this.mediaBuffer=i.buffer),t.tracks.video&&(this.videoBuffer=t.tracks.video.buffer)},w.onFragBuffered=function(e,t){var i=t.frag,t=t.part;i.type===d.PlaylistLevelType.AUDIO&&(this.fragContextChanged(i)?this.warn("Fragment "+i.sn+(t?" p: "+t.index:"")+" of level "+i.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch):("initSegment"!==i.sn&&(this.fragPrevious=i,this.audioSwitch)&&(this.audioSwitch=!1,this.hls.trigger(h.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId})),this.fragBufferedComplete(i,t)))},w.onError=function(e,t){switch(t.details){case c.ErrorDetails.FRAG_LOAD_ERROR:case c.ErrorDetails.FRAG_LOAD_TIMEOUT:case c.ErrorDetails.KEY_LOAD_ERROR:case c.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(d.PlaylistLevelType.AUDIO,t);break;case c.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case c.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==u.State.ERROR&&this.state!==u.State.STOPPED&&(this.state=t.fatal?u.State.ERROR:u.State.IDLE,this.warn(t.details+" while loading frag, switching to "+this.state+" state"));break;case c.ErrorDetails.BUFFER_FULL_ERROR:var i,r;"audio"!==t.parent||this.state!==u.State.PARSING&&this.state!==u.State.PARSED||(i=!0,(i=(r=this.getFwdBufferInfo(this.mediaBuffer,d.PlaylistLevelType.AUDIO))&&.5=o.length?this.warn("Invalid id passed to audio-track controller"):(this.clearTimer(),t=o[this.trackId],this.log("Now switching to audio-track index "+e),i=(o=o[e]).id,r=void 0===(r=o.groupId)?"":r,s=o.name,a=o.type,n=o.url,this.trackId=e,this.trackName=s,this.selectDefaultTrack=!1,this.hls.trigger(l.Events.AUDIO_TRACK_SWITCHING,{id:i,groupId:r,name:s,type:a,url:n}),o.details&&!o.details.live||(e=this.switchParams(o.url,null==t?void 0:t.details),this.loadPlaylist(e)))},s.selectInitialTrack=function(){var e=this.tracksInGroup,e=(console.assert(e.length,"Initial audio track should be selected when tracks are known"),this.trackName),e=this.findTrackId(e)||this.findTrackId();-1!==e?this.setAudioTrack(e):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(l.Events.ERROR,{type:r.ErrorTypes.MEDIA_ERROR,details:r.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},s.findTrackId=function(e){for(var t=this.tracksInGroup,i=0;it.partTarget&&(s+=1),Object(o.isFiniteNumber)(a))return new l.HlsUrlParameters(a,Object(o.isFiniteNumber)(s)?s:void 0,l.HlsSkip.No)}}},t.loadPlaylist=function(e){},t.shouldLoadTrack=function(e){return this.canLoad&&e&&!!e.url&&(!e.details||e.details.live)},t.playlistLoaded=function(e,t,i){var r=this,s=t.details,a=t.stats,n=a.loading.end?Math.max(0,self.performance.now()-a.loading.end):0;if(s.advancedDateTime=Date.now()-n,s.live||null!=i&&i.live){if(s.reloaded(i),i&&this.log("live playlist "+e+" "+(s.advanced?"REFRESHED "+s.lastPartSn+"-"+s.lastPartIndex:"MISSED")),i&&0i.tuneInGoal?(this.warn("CDN Tune-in goal increased from: "+i.tuneInGoal+" to: "+u+" with playlist age: "+s.age),u=0):(n+=h=Math.floor(u/s.targetduration),void 0!==l&&(l+=Math.round(u%s.targetduration/s.partTarget)),this.log("CDN Tune-in age: "+s.ageHeader+"s last advanced "+d.toFixed(2)+"s goal: "+u+" skip sn "+h+" to part "+l)),s.tuneInGoal=u),o=this.getDeliveryDirectives(s,t.deliveryDirectives,n,l),c||!p)return void this.loadPlaylist(o)}else o=this.getDeliveryDirectives(s,t.deliveryDirectives,n,l);i=Object(f.computeReloadInterval)(s,a);void 0!==n&&s.canBlockReload&&(i-=s.partTarget||1),this.log("reload live playlist "+e+" in "+Math.round(i)+" ms"),this.timer=self.setTimeout(function(){return r.loadPlaylist(o)},i)}}else this.clearTimer()},t.getDeliveryDirectives=function(e,t,i,r){var s=Object(l.getSkipValue)(e,i);return null!=t&&t.skip&&e.deltaUpdateFailed&&(i=t.msn,r=t.part,s=l.HlsSkip.No),new l.HlsUrlParameters(i,r,s)},t.retryLoadingOrFail=function(e){var t,i=this,r=this.hls.config,s=this.retryCount=t.endSN)||e.nextStart)&&(null!=(e=t.partList)&&e.length?(t=e[e.length-1],n.BufferHelper.isBuffered(this.media,t.start+t.duration/2)):(e=r.getState(i))===u.FragmentState.PARTIAL||e===u.FragmentState.OK)},t.onMediaAttached=function(e,t){t=this.media=this.mediaBuffer=t.media,this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),t.addEventListener("seeking",this.onvseeking),t.addEventListener("ended",this.onvended),t=this.config;this.levels&&t.autoStartLoad&&this.state===w.STOPPED&&this.startLoad(t.startPosition)},t.onMediaDetaching=function(){var e=this.media;null!=e&&e.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),e&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},t.onMediaSeeking=function(){var e=this.config,t=this.fragCurrent,i=this.media,r=this.mediaBuffer,s=this.state,a=i?i.currentTime:0,r=n.BufferHelper.bufferInfo(r||i,a,e.maxBufferHole);this.log("media seeking to "+(Object(l.isFiniteNumber)(a)?a.toFixed(3):a)+", state: "+s),s===w.ENDED?this.resetLoadingState():t&&!r.len&&(s=e.maxFragLookUpTolerance,e=t.start-s,s=a>t.start+t.duration+s,ae.end&&t.fragmentHint&&(e=t.fragmentHint);var n,o=this.getNextPart(a,e,i);if(-1i&&this.flushMainBuffer(r,e.start)):this.flushMainBuffer(0,e.start))},t.getFwdBufferInfo=function(e,t){var i=this.config,r=this.getLoadPosition();if(!Object(l.isFiniteNumber)(r))return null;var s=n.BufferHelper.bufferInfo(e,r,i.maxBufferHole);if(0===s.len&&void 0!==s.nextStart){t=this.fragmentTracker.getBufferedFrag(r,t);if(t&&s.nextStart=e&&(t.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+t.maxMaxBufferLength+"s"),!0)},t.getNextFragment=function(e,t){var i=t.fragments,r=i.length;if(!r)return null;var s,a=this.config,n=i[0].start;if(t.live){var o=a.initialLiveManifestSize;if(re.start&&e.loaded},t.getInitialLiveFragment=function(e,t){var i,r=this.fragPrevious,s=null;return r?(e.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+r.programDateTime),s=Object(p.findFragmentByPDT)(t,r.endProgramDateTime,this.config.maxFragLookUpTolerance)),s||((i=r.sn+1)>=e.startSN&&i<=e.endSN&&(i=t[i-e.startSN],r.cc===i.cc)&&this.log("Live playlist, switching playlist, load frag with next SN: "+(s=i).sn),s)||(s=Object(p.findFragWithCC)(t,r.cc))&&this.log("Live playlist, switching playlist, load frag with same CC: "+s.sn)):null!==(i=this.hls.liveSyncPosition)&&(s=this.getFragmentAtPosition(i,this.bitrateTest?e.fragmentEnd:e.edge,e)),s},t.getFragmentAtPosition=function(e,t,i){var r,s=this.config,a=this.fragPrevious,n=i.fragments,o=i.endSN,l=i.fragmentHint,c=s.maxFragLookUpTolerance,s=!!(s.lowLatencyMode&&i.partList&&l);if(s&&l&&!this.bitrateTest&&(n=n.concat(l),o=l.sn),r=e=s-a.maxFragLookUpTolerance&&i<=r,null!==t)&&n.duration>t&&(i"+e.startSN+" prev-sn: "+(o?o.sn:"na")+" fragments: "+n),s):i):(this.warn("No fragments in live playlist"),0)},t.waitForCdnTuneIn=function(e){return e.live&&e.canBlockReload&&e.tuneInGoal>Math.max(e.partHoldBack,3*e.partTarget)},t.setStartPosition=function(e,t){var i,r=this.startPosition;-1!==(r=r"+e))}}]),T);function T(e,t,i){var r;return(r=v.call(this)||this).hls=void 0,r.fragPrevious=null,r.fragCurrent=null,r.fragmentTracker=void 0,r.transmuxer=null,r._state=w.STOPPED,r.media=void 0,r.mediaBuffer=void 0,r.config=void 0,r.bitrateTest=!1,r.lastCurrentTime=0,r.nextLoadPosition=0,r.startPosition=0,r.loadedmetadata=!1,r.fragLoadError=0,r.retryDate=0,r.levels=null,r.fragmentLoader=void 0,r.levelLastLoaded=null,r.startFragRequested=!1,r.decrypter=void 0,r.initPTS=[],r.onvseeking=null,r.onvended=null,r.logPrefix="",r.log=void 0,r.warn=void 0,r.logPrefix=i,r.log=s.logger.log.bind(s.logger,i+":"),r.warn=s.logger.warn.bind(s.logger,i+":"),r.hls=e,r.fragmentLoader=new f.default(e.config),r.fragmentTracker=t,r.config=e.config,r.decrypter=new g.default(e,e.config),e.on(h.Events.KEY_LOADED,r.onKeyLoaded,function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(r)),r}},"./src/controller/buffer-controller.ts":function(e,t,i){i.r(t),i.d(t,"default",function(){return a});var l=i("./src/polyfills/number.ts"),g=i("./src/events.ts"),m=i("./src/utils/logger.ts"),A=i("./src/errors.ts"),y=i("./src/utils/buffer-helper.ts"),t=i("./src/utils/mediasource-helper.ts"),n=i("./src/loader/fragment.ts"),r=i("./src/controller/buffer-operation-queue.ts"),s=Object(t.getMediaSource)(),c=/([ha]vc.)(?:\.[^.,]+)+/,a=((i=o.prototype).hasSourceTypes=function(){return 0i.config.appendErrorMaxRetry&&(m.logger.error("[buffer-controller]: Failed "+i.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),t.fatal=!0)),i.trigger(g.Events.ERROR,t)}},o)},i.onBufferFlushing=function(e,i){function t(t){return{execute:r.removeExecutor.bind(r,t,i.startOffset,i.endOffset),onStart:function(){},onComplete:function(){r.hls.trigger(g.Events.BUFFER_FLUSHED,{type:t})},onError:function(e){m.logger.warn("[buffer-controller]: Failed to remove from "+t+" SourceBuffer",e)}}}var r=this,s=this.operationQueue;i.type?s.append(t(i.type),i.type):this.getSourceBufferTypes().forEach(function(e){s.append(t(e),e)})},i.onFragParsed=function(e,t){var i=this,r=t.frag,s=t.part,t=[],a=(s||r).elementaryStreams;a[n.ElementaryStreamTypes.AUDIOVIDEO]?t.push("audiovideo"):(a[n.ElementaryStreamTypes.AUDIO]&&t.push("audio"),a[n.ElementaryStreamTypes.VIDEO]&&t.push("video")),0===t.length&&m.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+r.type+" level: "+r.level+" sn: "+r.sn),this.blockBuffers(function(){var e=self.performance.now(),e=(r.stats.buffering.end=e,s&&(s.stats.buffering.end=e),(s||r).stats);i.hls.trigger(g.Events.FRAG_BUFFERED,{frag:r,part:s,stats:e,id:r.type})},t)},i.onFragChanged=function(e,t){this.flushBackBuffer()},i.onBufferEos=function(e,r){var s=this;this.getSourceBufferTypes().reduce(function(e,t){var i=s.sourceBuffer[t];return r.type&&r.type!==t||i&&!i.ended&&(i.ended=!0,m.logger.log("[buffer-controller]: "+t+" sourceBuffer now EOS")),e&&!(i&&!i.ended)},!0)&&this.blockBuffers(function(){var e=s.mediaSource;e&&"open"===e.readyState&&e.endOfStream()})},i.onLevelUpdated=function(e,t){t=t.details;t.fragments.length&&(this.details=t,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},i.flushBackBuffer=function(){var e,t,i,r,s=this.hls,a=this.details,n=this.media,o=this.sourceBuffer;n&&null!==a&&(e=this.getSourceBufferTypes()).length&&(i=a.live&&null!==s.config.liveBackBufferLength?s.config.liveBackBufferLength:s.config.backBufferLength,!Object(l.isFiniteNumber)(i)||i<0||(n=n.currentTime,t=a.levelTargetDuration,i=Math.max(i,t),r=Math.floor(n/t)*t-i,e.forEach(function(e){var t=o[e];t&&0<(t=y.BufferHelper.getBuffered(t)).length&&r>t.start(0)&&(s.trigger(g.Events.BACK_BUFFER_REACHED,{bufferEnd:r}),a.live&&s.trigger(g.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:r}),s.trigger(g.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:r,type:e}))})))},i.updateMediaElementDuration=function(){var e,t,i,r,s,a;this.details&&this.media&&this.mediaSource&&"open"===this.mediaSource.readyState&&(e=this.details,t=this.hls,s=this.media,i=this.mediaSource,r=e.fragments[0].start+e.totalduration,s=s.duration,a=Object(l.isFiniteNumber)(i.duration)?i.duration:0,e.live&&t.config.liveDurationInfinity?(m.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),i.duration=1/0,this.updateSeekableRange(e)):(athis.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping)},i.getMaxLevel=function(i){var r=this,e=this.hls.levels;return e.length?(e=e.filter(function(e,t){return n.isLevelAllowed(t,r.restrictedLevels)&&t<=i}),this.clientRect=null,n.getMaxLevelByMediaSize(e,this.mediaWidth,this.mediaHeight)):-1},i.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},i.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},i.getDimensions=function(){var e,t,i;return this.clientRect||(t={width:0,height:0},(e=this.media)&&(i=e.getBoundingClientRect(),t.width=i.width,t.height=i.height,t.width||t.height||(t.width=i.right-i.left||e.width||0,t.height=i.bottom-i.top||e.height||0)),this.clientRect=t)},n.isLevelAllowed=function(e,t){return-1===(t=void 0===t?[]:t).indexOf(e)},n.getMaxLevelByMediaSize=function(e,t,i){if(!e||!e.length)return-1;for(var r,s=e.length-1,a=0;a=t||n.height>=i)&&(!(r=e[a+1])||n.width!==r.width||n.height!==r.height)){s=a;break}}return s},i=[{key:"contentScaleFactor",get:function(){var e=1;try{e=self.devicePixelRatio}catch(e){}return e}}],s((a=n).prototype,[{key:"mediaWidth",get:function(){return this.getDimensions().width*n.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*n.contentScaleFactor}}]),s(a,i);var a=n;function n(e){this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.hls=void 0,this.streamController=void 0,this.clientRect=void 0,this.hls=e,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}t.default=a},"./src/controller/cmcd-controller.ts":function(e,t,i){i.r(t),i.d(t,"default",function(){return h});var r=i("./src/events.ts"),n=i("./src/types/cmcd.ts"),s=i("./src/utils/buffer-helper.ts"),o=i("./src/utils/logger.ts");function a(e,t){for(var i=0;i=e.length?{done:!0}:{done:!1,value:e[i++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,r=new Array(t);it&&(t=s.bitrate)}return 0a.config.fpsDroppedMonitoringThreshold*s&&(n=a.currentLevel,c.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+n),0=n)&&(a.trigger(l.Events.FPS_DROP_LEVEL_CAPPING,{level:--n,droppedLevel:a.currentLevel}),a.autoLevelCapping=n,this.streamController.nextLevelSwitch()),this.lastTime=o,this.lastDroppedFrames=i,this.lastDecodedFrames=t)},i.checkFPSInterval=function(){var e,t=this.media;t&&(this.isVideoPlaybackQualityAvailable?(e=t.getVideoPlaybackQuality(),this.checkFPS(t,e.totalVideoFrames,e.droppedVideoFrames)):this.checkFPS(t,t.webkitDecodedFrameCount,t.webkitDroppedFrameCount))},t.default=r},"./src/controller/fragment-finders.ts":function(e,t,i){i.r(t),i.d(t,"findFragmentByPDT",function(){return r}),i.d(t,"findFragmentByPTS",function(){return s}),i.d(t,"fragmentWithinToleranceTest",function(){return o}),i.d(t,"pdtWithinToleranceTest",function(){return l}),i.d(t,"findFragWithCC",function(){return c});var a=i("./src/polyfills/number.ts"),n=i("./src/utils/binary-search.ts");function r(e,t,i){if(null!==t&&Array.isArray(e)&&e.length&&Object(a.isFiniteNumber)(t)&&!(t<(e[0].programDateTime||0)||t>=(e[e.length-1].endProgramDateTime||0))){i=i||0;for(var r=0;re&&i.start?-1:0}function l(e,t,i){t=1e3*Math.min(t,i.duration+(i.deltaPTS||0));return(i.endProgramDateTime||0)-t>e}function c(e,t){return n.default.search(e,function(e){return e.cct?-1:0})}},"./src/controller/fragment-tracker.ts":function(e,t,i){i.r(t),i.d(t,"FragmentState",function(){return r}),i.d(t,"FragmentTracker",function(){return a});var r,s=i("./src/events.ts"),o=i("./src/types/loader.ts"),a=((t=r=r||{}).NOT_LOADED="NOT_LOADED",t.BACKTRACKED="BACKTRACKED",t.APPENDING="APPENDING",t.PARTIAL="PARTIAL",t.OK="OK",(i=n.prototype)._registerListeners=function(){var e=this.hls;e.on(s.Events.BUFFER_APPENDED,this.onBufferAppended,this),e.on(s.Events.FRAG_BUFFERED,this.onFragBuffered,this),e.on(s.Events.FRAG_LOADED,this.onFragLoaded,this)},i._unregisterListeners=function(){var e=this.hls;e.off(s.Events.BUFFER_APPENDED,this.onBufferAppended,this),e.off(s.Events.FRAG_BUFFERED,this.onFragBuffered,this),e.off(s.Events.FRAG_LOADED,this.onFragLoaded,this)},i.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},i.getAppendedFrag=function(e,t){if(t===o.PlaylistLevelType.MAIN){var i=this.activeFragment,r=this.activeParts;if(!i)return null;if(r)for(var s=r.length;s--;){var a=r[s],n=a?a.end:i.appendedPTS;if(a.start<=e&&void 0!==n&&e<=n)return 9t&&s.removeFragment(e)})},i.removeFragment=function(e){var t=c(e);e.stats.loaded=0,e.clearElementaryStreamInfo(),delete this.fragments[t]},i.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},n);function n(e){this.activeFragment=null,this.activeParts=null,this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hls=e,this._registerListeners()}function l(e){var t;return e.buffered&&(null!=(t=e.range.video)&&t.partial||null!=(t=e.range.audio)&&t.partial)}function c(e){return e.type+"_"+e.level+"_"+e.urlId+"_"+e.sn}},"./src/controller/gap-controller.ts":function(e,t,i){i.r(t),i.d(t,"STALL_MINIMUM_DURATION_MS",function(){return p}),i.d(t,"MAX_START_GAP_JUMP",function(){return f}),i.d(t,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return g}),i.d(t,"SKIP_BUFFER_RANGE_START",function(){return m}),i.d(t,"default",function(){return r});var c=i("./src/utils/buffer-helper.ts"),d=i("./src/errors.ts"),u=i("./src/events.ts"),h=i("./src/utils/logger.ts"),p=250,f=2,g=.1,m=.05,r=((t=s.prototype).destroy=function(){this.hls=this.fragmentTracker=this.media=null},t.poll=function(e){var t=this.config,i=this.media,r=this.stalled,s=i.currentTime,a=i.seeking,n=this.seeking&&!a,o=!this.seeking&&a;if(this.seeking=a,s===e){if((o||n)&&(this.stalled=null),!i.paused&&!i.ended&&0!==i.playbackRate&&c.BufferHelper.getBuffered(i).length){e=c.BufferHelper.bufferInfo(i,s,0),o=0f,l=!n||fi.maxBufferHole&&t>1e3*i.highBufferWatchdogPeriod&&(h.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},t._reportStall=function(e){var t=this.hls,i=this.media;this.stallReported||(this.stallReported=!0,h.logger.warn("Playback stalling at @"+i.currentTime+" due to low buffer (buffer="+e+")"),t.trigger(u.Events.ERROR,{type:d.ErrorTypes.MEDIA_ERROR,details:d.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:e}))},t._trySkipBufferHole=function(e){for(var t=this.config,i=this.hls,r=this.media,s=r.currentTime,a=0,n=c.BufferHelper.getBuffered(r),o=0;o=a&&sthis.hls.config.fragLoadingMaxRetry))&&(r=t.frag.level);break;case g.ErrorDetails.LEVEL_LOAD_ERROR:case g.ErrorDetails.LEVEL_LOAD_TIMEOUT:i&&(i.deliveryDirectives&&(n=!1),r=i.level),a=!0;break;case g.ErrorDetails.REMUX_ALLOC_ERROR:r=t.level,a=!0}void 0!==r&&this.recoverLevel(t,r,a,n)}}},t.recoverLevel=function(e,t,i,r){var s=e.details,a=this._levels[t];if(a.loadError++,i){if(!this.retryLoadingOrFail(e))return void(this.currentLevelIndex=-1);e.levelRetry=!0}r&&(1<(i=a.url.length)&&a.loadError=t.length){var i=e<0;if(this.hls.trigger(f.Events.ERROR,{type:g.ErrorTypes.OTHER_ERROR,details:g.ErrorDetails.LEVEL_SWITCH_ERROR,level:e,fatal:i,reason:"invalid level idx"}),i)return;e=Math.min(e,t.length-1)}this.clearTimer();var i=this.currentLevelIndex,r=t[i],t=t[e],i=(this.log("switching to level "+e+" from "+i),s({},t,{level:this.currentLevelIndex=e,maxBitrate:t.maxBitrate,uri:t.uri,urlId:t.urlId})),e=(delete i._urlId,this.hls.trigger(f.Events.LEVEL_SWITCHING,i),t.details);e&&!e.live||(i=this.switchParams(t.uri,null==r?void 0:r.details),this.loadPlaylist(i))}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(e){this.manualLevelIndex=e,void 0===this._startLevel&&(this._startLevel=e),-1!==e&&(this.level=e)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(e){this._firstLevel=e}},{key:"startLevel",get:function(){var e;return void 0===this._startLevel?void 0!==(e=this.hls.config.startLevel)?e:this._firstLevel:this._startLevel},set:function(e){this._startLevel=e}},{key:"nextLoadLevel",get:function(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(e){this.level=e,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=e)}}]),c);function c(e){return(e=l.call(this,e,"[level-controller]")||this)._levels=[],e._firstLevel=-1,e._startLevel=void 0,e.currentLevelIndex=-1,e.manualLevelIndex=-1,e.onParsedComplete=void 0,e._registerListeners(),e}},"./src/controller/level-helper.ts":function(e,t,i){i.r(t),i.d(t,"addGroupId",function(){return r}),i.d(t,"assignTrackIdsByGroup",function(){return s}),i.d(t,"updatePTS",function(){return a}),i.d(t,"updateFragPTSDTS",function(){return m}),i.d(t,"mergeDetails",function(){return n}),i.d(t,"mapPartIntersection",function(){return A}),i.d(t,"mapFragmentIntersection",function(){return y}),i.d(t,"adjustSliding",function(){return b}),i.d(t,"addSliding",function(){return o}),i.d(t,"computeReloadInterval",function(){return l}),i.d(t,"getFragmentWithSN",function(){return c}),i.d(t,"getPartWith",function(){return d});var p=i("./src/polyfills/number.ts"),f=i("./src/utils/logger.ts");function r(e,t,i){switch(t){case"audio":e.audioGroupIds||(e.audioGroupIds=[]),e.audioGroupIds.push(i);break;case"text":e.textGroupIds||(e.textGroupIds=[]),e.textGroupIds.push(i)}}function s(e){var i={};e.forEach(function(e){var t=e.groupId||"";e.id=i[t]=i[t]||0,i[t]++})}function a(e,t,i){g(e[t],e[i])}function g(e,t){var i,r=t.startPTS;Object(p.isFiniteNumber)(r)?(i=0,(r=t.sn>e.sn?(i=r-e.start,e):(i=e.start-r,t)).duration!==i&&(r.duration=i)):t.sn>e.sn?e.cc===t.cc&&e.minEndPTS?t.start=e.start+(e.minEndPTS-e.start):t.start=e.start+e.duration:t.start=Math.max(e.start-t.duration,0)}function m(e,t,i,r,s,a){r-i<=0&&(f.logger.warn("Fragment should have a positive duration",t),r=i+t.duration,a=s+t.duration);var n=i,o=r,l=t.startPTS,c=t.endPTS,d=(Object(p.isFiniteNumber)(l)&&(d=Math.abs(l-i),Object(p.isFiniteNumber)(t.deltaPTS)?t.deltaPTS=Math.max(d,t.deltaPTS):t.deltaPTS=d,n=Math.max(i,l),i=Math.min(i,l),s=Math.min(s,t.startDTS),o=Math.min(r,c),r=Math.max(r,c),a=Math.max(a,t.endDTS)),t.duration=r-i,i-t.start);t.appendedPTS=r,t.start=t.startPTS=i,t.maxStartPTS=n,t.startDTS=s,t.endPTS=r,t.minEndPTS=o,t.endDTS=a;var u,l=t.sn;if(!e||le.endSN)return 0;var c=l-e.startSN,h=e.fragments;for(h[c]=t,u=c;0=e.length||o(t,e[i].start)}function o(e,t){if(t){for(var i=e.fragments,r=e.skippedSegments;r=this.getMaxBufferLength(t.maxBitrate)||(this._streamEnded(i,s)?(e={},this.altAudio&&(e.type="video"),this.hls.trigger(m.Events.BUFFER_EOS,e),this.state=g.State.ENDED):(a=i.end,t=this.getNextFragment(a,s),this.couldBacktrack&&!this.fragPrevious&&t&&"initSegment"!==t.sn&&1<(e=t.sn-s.startSN)&&(t=s.fragments[e-1],this.fragmentTracker.removeFragment(t)),t&&this.fragmentTracker.getState(t)===n.FragmentState.OK&&this.nextLoadPosition>a&&(i=this.audioOnly&&!this.altAudio?A.ElementaryStreamTypes.AUDIO:A.ElementaryStreamTypes.VIDEO,this.afterBufferFlushed(r,i,u.PlaylistLevelType.MAIN),t=this.getNextFragment(this.nextLoadPosition,s)),t&&("identity"!==(null==(e=(t=!t.initSegment||t.initSegment.data||this.bitrateTest?t:t.initSegment).decryptdata)?void 0:e.keyFormat)||null!=(r=t.decryptdata)&&r.key?this.loadFragment(t,s,a):this.loadKey(t,s)))))},i.loadFragment=function(e,t,i){var r=this.fragmentTracker.getState(e);if(this.fragCurrent=e,r===n.FragmentState.BACKTRACKED){var s=this.fragmentTracker.getBacktrackData(e);if(s)return this._handleFragmentLoadProgress(s),void this._handleFragmentLoadComplete(s);r=n.FragmentState.NOT_LOADED}r===n.FragmentState.NOT_LOADED||r===n.FragmentState.PARTIAL?"initSegment"===e.sn?this._loadInitSegment(e):this.bitrateTest?(e.bitrateTest=!0,this.log("Fragment "+e.sn+" of level "+e.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(e)):(this.startFragRequested=!0,y.prototype.loadFragment.call(this,e,t,i)):r===n.FragmentState.APPENDING?this.reduceMaxBufferLength(e.duration)&&this.fragmentTracker.removeFragment(e):0===(null==(s=this.media)?void 0:s.buffered.length)&&this.fragmentTracker.removeAllFragments()},i.getAppendedFrag=function(e){e=this.fragmentTracker.getAppendedFrag(e,u.PlaylistLevelType.MAIN);return e&&"fragment"in e?e.fragment:e},i.getBufferedFrag=function(e){return this.fragmentTracker.getBufferedFrag(e,u.PlaylistLevelType.MAIN)},i.followingBufferedFrag=function(e){return e?this.getBufferedFrag(e.end+.5):null},i.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},i.nextLevelSwitch=function(){var e,t=this.levels,i=this.media;null!=i&&i.readyState&&((e=this.getAppendedFrag(i.currentTime))&&1=r[n].start&&a<=r[n].end){s=r[n];break}t=i.start+i.duration;s?s.end=t:r.push(s={start:a,end:t}),this.fragmentTracker.fragBuffered(i)}}},i.onBufferFlushing=function(e,t){var i,r,s,a=t.startOffset,n=t.endOffset;0===a&&n!==Number.POSITIVE_INFINITY&&(i=this.currentTrackId,(r=this.levels).length)&&r[i]&&r[i].details&&((s=n-r[i].details.targetduration)<=0||(t.endOffsetSubtitles=Math.max(0,s),this.tracksBuffered.forEach(function(e){for(var t=0;t=s.length||t!==r)&&a){if(this.mediaBuffer=this.mediaBufferTimeRanges,i.live||null!=(s=a.details)&&s.live){r=this.mainDetails;if(i.deltaUpdateFailed||!r)return;s=r.fragments[0];a.details?0===this.alignPlaylists(i,a.details)&&s&&Object(o.addSliding)(i,s.start):i.hasProgramDateTime&&r.hasProgramDateTime?Object(n.alignMediaPlaylistByPDT)(i,r):s&&Object(o.addSliding)(i,s.start)}a.details=i,this.levelLastLoaded=t,this.tick(),!i.live||this.fragCurrent||!this.media||this.state!==u.State.IDLE||Object(c.findFragmentByPTS)(null,i.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),a.details=void 0)}}},i._handleFragmentLoadComplete=function(e){var i,r=e.frag,e=e.payload,t=r.decryptdata,s=this.hls;!this.fragContextChanged(r)&&e&&0this.getMaxBufferLength()+a||(console.assert(e,"Subtitle track details are defined on idle subtitle stream controller tick"),a=(s=e.fragments).length,o=e.edge,n=this.fragPrevious,i=o.length||(this.clearTimer(),i=o[e],this.log("Switching to subtitle track "+e),this.trackId=e,i?(o=i.id,r=i.groupId,s=i.name,a=i.type,n=i.url,this.hls.trigger(l.Events.SUBTITLE_TRACK_SWITCH,{id:o,groupId:void 0===r?"":r,name:s,type:a,url:n}),o=this.switchParams(i.url,null==t?void 0:t.details),this.loadPlaylist(o)):this.hls.trigger(l.Events.SUBTITLE_TRACK_SWITCH,{id:e}))):this.queuedDefaultTrack=e},s.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),this.media&&this.hls.config.renderTextTracksNatively){for(var e=-1,t=u(this.media.textTracks),i=0;i>>8^255&g^99,u[t[g]=h]),A=u[m],y=u[A],b=257*u[g]^16843008*g;r[h]=b<<24|b>>>8,s[h]=b<<16|b>>>16,a[h]=b<<8|b>>>24,n[h]=b,o[g]=(b=16843009*y^65537*A^257*m^16843008*h)<<24|b>>>8,l[g]=b<<16|b>>>16,c[g]=b<<8|b>>>24,d[g]=b,h?(h=m^u[u[u[y^m]]],p^=u[u[p]]):h=p=1}},t.expandKey=function(e){for(var t=this.uint8ArrayToUint32Array_(e),i=!0,r=0;r>>6),d=(60&t[i+2])>>>2;if(!(l.length-1>>6,u.logger.log("manifest codec:"+r+", ADTS type:"+c+", samplingIndex:"+d),t=/firefox/i.test(n)?6<=d?(c=5,a=new Array(4),d-3):(c=2,a=new Array(2),d):-1!==n.indexOf("android")?(c=2,a=new Array(2),d):(c=5,a=new Array(4),r&&(-1!==r.indexOf("mp4a.40.29")||-1!==r.indexOf("mp4a.40.5"))||!r&&6<=d?d-3:((r&&-1!==r.indexOf("mp4a.40.2")&&(6<=d&&1==s||/vivaldi/i.test(n))||!r&&1==s)&&(c=2,a=new Array(2)),d)),a[0]=c<<3,a[0]|=(14&d)>>1,a[1]|=(1&d)<<7,a[1]|=s<<3,5===c&&(a[1]|=(14&t)>>1,a[2]=(1&t)<<7,a[2]|=8,a[3]=0),{config:a,samplerate:l[d],channelCount:s,codec:"mp4a.40."+c,manifestCodec:o};e.trigger(p.Events.ERROR,{type:h.ErrorTypes.MEDIA_ERROR,details:h.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+d})}function r(e,t){return 255===e[t]&&240==(246&e[t+1])}function n(e,t){return 1&e[t+1]?7:9}function o(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function s(e,t){return t+5=e.length||(i=o(e,t))<=r)&&((r=t+i)===e.length||l(e,r))}function f(e,t,i,r,s){e.samplerate||(t=a(t,i,r,s))&&(e.config=t.config,e.samplerate=t.samplerate,e.channelCount=t.channelCount,e.codec=t.codec,e.manifestCodec=t.manifestCodec,u.logger.log("parsed codec:"+e.codec+", rate:"+t.samplerate+", channels:"+t.channelCount))}function g(e){return 9216e4/e}function m(e,t,i,r,s){var a=n(e,t),e=o(e,t);if(0<(e-=a))return{headerLength:a,frameLength:e,stamp:i+r*s}}function A(e,t,i,r,s){var a,n,o,r=m(t,i,r,s,g(e.samplerate));if(r)return s=r.frameLength,n=r.headerLength,r=r.stamp,s=n+s,(o=Math.max(0,i+s-t.length))?(a=new Uint8Array(s-n)).set(t.subarray(i+n,t.length),0):a=t.subarray(i+n,i+s),t={unit:a,pts:r},o||e.samples.push(t),{sample:t,length:s,missing:o}}},"./src/demux/base-audio-demuxer.ts":function(e,t,i){i.r(t),i.d(t,"initPTSFn",function(){return g});var r=i("./src/polyfills/number.ts"),u=i("./src/demux/id3.ts"),h=i("./src/demux/dummy-demuxed-track.ts"),p=i("./src/utils/mp4-tools.ts"),f=i("./src/utils/typed-array.ts");(i=s.prototype).resetInitSegment=function(e,t,i){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},i.resetTimeStamp=function(){},i.resetContiguity=function(){},i.canParse=function(e,t){return!1},i.appendFrame=function(e,t,i){},i.demux=function(e,t){this.cachedData&&(e=Object(p.appendUint8Array)(this.cachedData,e),this.cachedData=null);var i,r,s,a=u.getID3Data(e,0),n=a?a.length:0,o=this._audioTrack,l=this._id3Track,c=a?u.getTimeStamp(a):void 0,d=e.length;for(0!==this.frameIndex&&null!==this.initPTS||(this.initPTS=g(c,t)),a&&0e||(e=(e-=this.bitsAvailable)-((t=e>>3)>>3),this.bytesAvailable-=t,this.loadWord()),this.word<<=e,this.bitsAvailable-=e},i.readBits=function(e){var t=Math.min(this.bitsAvailable,e),i=this.word>>>32-t;return 32>>e))return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()},i.skipUEG=function(){this.skipBits(1+this.skipLZ())},i.skipEG=function(){this.skipBits(1+this.skipLZ())},i.readUEG=function(){var e=this.skipLZ();return this.readBits(e+1)-1},i.readEG=function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)},i.readBoolean=function(){return 1===this.readBits(1)},i.readUByte=function(){return this.readBits(8)},i.readUShort=function(){return this.readBits(16)},i.readUInt=function(){return this.readBits(32)},i.skipScalingList=function(e){for(var t=8,i=8,r=0;r>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:l+=String.fromCharCode(s);break;case 12:case 13:a=e[c++],l+=String.fromCharCode((31&s)<<6|63&a);break;case 14:a=e[c++],n=e[c++],l+=String.fromCharCode((15&s)<<12|(63&a)<<6|(63&n)<<0)}}return l},b={decodeTextFrame:g}},"./src/demux/mp3demuxer.ts":function(e,t,i){i.r(t);var r=i("./src/demux/base-audio-demuxer.ts"),s=i("./src/demux/id3.ts"),a=i("./src/utils/logger.ts"),n=i("./src/demux/mpegaudio.ts");function o(e,t){return(o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}l=r.default,i=l,(r=c).prototype=Object.create(i.prototype),o(r.prototype.constructor=r,i),(r=c.prototype).resetInitSegment=function(e,t,i){l.prototype.resetInitSegment.call(this,e,t,i),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!1,samples:[],manifestCodec:e,duration:i,inputTimeScale:9e4,dropped:0}},c.probe=function(e){if(e)for(var t=(s.getID3Data(e,0)||[]).length,i=e.length;tt.length)){var a=n(t,i);if(a&&i+a.frameLength<=t.length)return r=r+s*(9e4*a.samplesPerFrame/a.sampleRate),s={unit:t.subarray(i,i+a.frameLength),pts:r,dts:r},e.config=[],e.channelCount=a.channelCount,e.samplerate=a.sampleRate,e.samples.push(s),{sample:s,length:a.frameLength,missing:0}}}function n(e,t){var i,r,s,a,n,o=e[t+1]>>3&3,l=e[t+1]>>1&3,c=e[t+2]>>4&15,d=e[t+2]>>2&3;if(1!=o&&0!=c&&15!=c&&3!=d)return n=e[t+2]>>1&1,i=e[t+3]>>6,c=1e3*h[14*(3==o?3-l:3==l?3:4)+c-1],d=p[3*(3==o?0:2==o?1:2)+d],r=3==i?1:2,a=8*(o=f[o][l])*(s=g[l]),o=Math.floor(o*c/d+n)*s,null===u&&(n=(navigator.userAgent||"").match(/Chrome\/(\d+)/i),u=n?parseInt(n[1]):0),u&&u<=87&&2==l&&224e3<=c&&0==i&&(e[t+3]=128|e[t+3]),{sampleRate:d,channelCount:r,frameLength:o,samplesPerFrame:a}}function s(e,t){return 255===e[t]&&224==(224&e[t+1])&&0!=(6&e[t+1])}function a(e,t){return t+1=e.length)return void i();if(!(e[t].unit.length<32)){var r=this.decrypter.isSync();if(this.decryptAacSample(e,t,i,r),!r)return}}},i.getAvcEncryptedData=function(e){for(var t=16*Math.floor((e.length-48)/160)+16,i=new Int8Array(t),r=0,s=32;s=e.length)return void r();for(var s=e[t].units;!(i>=s.length);i++){var a=s[i];if(!(a.data.length<=48||1!==a.type&&5!==a.type)){var n=this.decrypter.isSync();if(this.decryptAvcSample(e,t,i,r,a,n),!n)return}}}},t.default=s},"./src/demux/transmuxer-interface.ts":function(e,t,i){i.r(t),i.d(t,"default",function(){return r});var l=i("./node_modules/webworkify-webpack/index.js"),c=i("./src/events.ts"),E=i("./src/demux/transmuxer.ts"),T=i("./src/utils/logger.ts"),d=i("./src/errors.ts"),t=i("./src/utils/mediasource-helper.ts"),u=i("./node_modules/eventemitter3/index.js"),h=Object(t.getMediaSource)()||{isTypeSupported:function(){return!1}},r=((i=s.prototype).destroy=function(){var e=this.worker,e=(e?(e.removeEventListener("message",this.onwmsg),e.terminate(),this.worker=null):(e=this.transmuxer)&&(e.destroy(),this.transmuxer=null),this.observer);e&&e.removeAllListeners(),this.observer=null},i.push=function(e,t,i,r,s,a,n,o,l,c){var d=this,u=(l.transmuxing.start=self.performance.now(),this.transmuxer),h=this.worker,p=(a||s).start,f=s.decryptdata,g=this.frag,m=!(g&&s.cc===g.cc),A=!(g&&l.level===g.level),y=g?l.sn-g.sn:-1,b=this.part?l.part-this.part.index:1,v=!A&&(1==y||0==y&&1==b),w=self.performance.now(),w=((A||y||0===s.stats.parsing.start)&&(s.stats.parsing.start=w),!a||!b&&v||(a.stats.parsing.start=w),!(g&&(null==(y=s.initSegment)?void 0:y.url)===(null==(b=g.initSegment)?void 0:b.url))),y=new E.TransmuxState(m,v,o,A,p,w);v&&!m&&!w||(T.logger.log("[transmuxer-interface, "+s.type+"]: Starting new transmux session for sn: "+l.sn+" p: "+l.part+" level: "+l.level+" id: "+l.id+"\n discontinuity: "+m+"\n trackSwitch: "+A+"\n contiguous: "+v+"\n accurateTimeOffset: "+o+"\n timeOffset: "+p+"\n initSegmentChange: "+w),g=new E.TransmuxConfig(i,r,t,n,c),this.configureTransmuxer(g)),this.frag=s,this.part=a,h?h.postMessage({cmd:"demux",data:e,decryptdata:f,chunkMeta:l,state:y},e instanceof ArrayBuffer?[e]:[]):u&&(b=u.push(e,f,l,y),Object(E.isPromise)(b)?b.then(function(e){d.handleTransmuxComplete(e)}):this.handleTransmuxComplete(b))},i.flush=function(t){var i=this,e=(t.transmuxing.start=self.performance.now(),this.transmuxer),r=this.worker;r?r.postMessage({cmd:"flush",chunkMeta:t}):e&&(r=e.flush(t),Object(E.isPromise)(r)?r.then(function(e){i.handleFlushResult(e,t)}):this.handleFlushResult(r,t))},i.handleFlushResult=function(e,t){var i=this;e.forEach(function(e){i.handleTransmuxComplete(e)}),this.onFlush(t)},i.onWorkerMessage=function(e){var t=e.data,i=this.hls;switch(t.event){case"init":self.URL.revokeObjectURL(this.worker.objectURL);break;case"transmuxComplete":this.handleTransmuxComplete(t.data);break;case"flush":this.onFlush(t.data);break;default:t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,i.trigger(t.event,t.data)}},i.configureTransmuxer=function(e){var t=this.worker,i=this.transmuxer;t?t.postMessage({cmd:"configure",config:e}):i&&i.configure(e)},i.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},s);function s(i,e,t,r){function s(e,t){(t=t||{}).frag=n.frag,t.id=n.id,i.trigger(e,t)}var a,n=this,t=(this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.worker=void 0,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.hls=i,this.id=e,this.onTransmuxComplete=t,this.onFlush=r,i.config),r=(this.observer=new u.EventEmitter,this.observer.on(c.Events.FRAG_DECRYPTED,s),this.observer.on(c.Events.ERROR,s),{mp4:h.isTypeSupported("video/mp4"),mpeg:h.isTypeSupported("audio/mpeg"),mp3:h.isTypeSupported('audio/mp4; codecs="mp3"')}),o=navigator.vendor;if(t.enableWorker&&"undefined"!=typeof Worker){T.logger.log("demuxing in webworker");try{a=this.worker=l("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),a.addEventListener("message",this.onwmsg),a.onerror=function(e){i.trigger(c.Events.ERROR,{type:d.ErrorTypes.OTHER_ERROR,details:d.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(e.message+" ("+e.filename+":"+e.lineno+")")})},a.postMessage({cmd:"init",typeSupported:r,vendor:o,id:e,config:JSON.stringify(t)})}catch(i){T.logger.warn("Error in worker:",i),T.logger.error("Error while initializing DemuxerWorker, fallback to inline"),a&&self.URL.revokeObjectURL(a.objectURL),this.transmuxer=new E.default(this.observer,r,t,o,e),this.worker=null}}else this.transmuxer=new E.default(this.observer,r,t,o,e)}},"./src/demux/transmuxer-worker.ts":function(e,t,i){i.r(t),i.d(t,"default",function(){return s});var o=i("./src/demux/transmuxer.ts"),r=i("./src/events.ts"),l=i("./src/utils/logger.ts"),c=i("./node_modules/eventemitter3/index.js");function s(s){function a(e,t){s.postMessage({event:e,data:t})}var n=new c.EventEmitter;n.on(r.Events.FRAG_DECRYPTED,a),n.on(r.Events.ERROR,a),s.addEventListener("message",function(e){var t=e.data;switch(t.cmd){case"init":var i=JSON.parse(t.config);s.transmuxer=new o.default(n,t.typeSupported,i,t.vendor,t.id),Object(l.enableLogs)(i.debug),a("init",null);break;case"configure":s.transmuxer.configure(t.config);break;case"demux":i=s.transmuxer.push(t.data,t.decryptdata,t.chunkMeta,t.state);Object(o.isPromise)(i)?i.then(function(e){d(s,e)}):d(s,i);break;case"flush":var r=t.chunkMeta,i=s.transmuxer.flush(r);Object(o.isPromise)(i)?i.then(function(e){u(s,e,r)}):u(s,i,r)}})}function d(e,t){var i,r,s;((i=t.remuxResult).audio||i.video||i.text||i.id3||i.initSegment)&&(i=[],r=(s=t.remuxResult).audio,s=s.video,r&&a(i,r),s&&a(i,s),e.postMessage({event:"transmuxComplete",data:t},i))}function a(e,t){t.data1&&e.push(t.data1.buffer),t.data2&&e.push(t.data2.buffer)}function u(t,e,i){e.forEach(function(e){d(t,e)}),t.postMessage({event:"flush",data:i})}},"./src/demux/transmuxer.ts":function(e,t,i){i.r(t),i.d(t,"default",function(){return u}),i.d(t,"isPromise",function(){return p}),i.d(t,"TransmuxConfig",function(){return f}),i.d(t,"TransmuxState",function(){return g});var y,l=i("./src/events.ts"),c=i("./src/errors.ts"),r=i("./src/crypt/decrypter.ts"),t=i("./src/demux/aacdemuxer.ts"),A=i("./src/demux/mp4demuxer.ts"),s=i("./src/demux/tsdemuxer.ts"),a=i("./src/demux/mp3demuxer.ts"),n=i("./src/remux/mp4-remuxer.ts"),b=i("./src/remux/passthrough-remuxer.ts"),o=i("./src/demux/chunk-cache.ts"),v=i("./src/utils/mp4-tools.ts"),w=i("./src/utils/logger.ts");try{y=self.performance.now.bind(self.performance)}catch(e){w.logger.debug("Unable to use Performance API on this environment"),y=self.Date.now}var E=[{demux:s.default,remux:n.default},{demux:A.default,remux:b.default},{demux:t.default,remux:n.default},{demux:a.default,remux:n.default}],d=1024,u=(E.forEach(function(e){e=e.demux;d=Math.max(d,e.minProbeByteLength)}),(i=h.prototype).configure=function(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()},i.push=function(e,t,i,r){var s=this,a=i.transmuxing,e=(a.executeStart=y(),new Uint8Array(e)),n=this.cache,o=this.config,l=this.currentTransmuxState,c=this.transmuxConfig,t=(r&&(this.currentTransmuxState=r),d=null,d=0>4){if((S=w+5+e[w+4])===w+188)continue}else S=w+4;switch(T){case l:E&&(c&&(s=M(c))&&this.parseAVCPES(s,!1),c={data:[],size:0}),c&&(c.data.push(e.subarray(S,w+188)),c.size+=w+188-S);break;case d:E&&(h&&(s=M(h))&&(n.isAAC?this.parseAACPES(s):this.parseMPEGPES(s)),h={data:[],size:0}),h&&(h.data.push(e.subarray(S,w+188)),h.size+=w+188-S);break;case u:E&&(p&&(s=M(p))&&this.parseID3PES(s),p={data:[],size:0}),p&&(p.data.push(e.subarray(S,w+188)),p.size+=w+188-S);break;case 0:E&&(S+=e[S]+1),m=this._pmtId=(31&(k=e)[(b=S)+10])<<8|k[b+11];break;case m:E&&(S+=e[S]+1);var k=function(e,t,i,r){var s={audio:-1,avc:-1,id3:-1,isAAC:!0},a=t+3+((15&e[t+1])<<8|e[t+2])-4;for(t+=12+((15&e[t+10])<<8|e[t+11]);te.size-6)return null;var l=t[7],c=(192&l&&(r=536870912*(14&t[9])+4194304*(255&t[10])+16384*(254&t[11])+128*(255&t[12])+(254&t[13])/2,64&l?54e5=e[i-1].pts)e.push(t);else for(var r=i-1;0<=r;r--)if(t.ptst)return r;return 0}},{key:"maxAutoLevel",get:function(){var e=this.levels,t=this.autoLevelCapping;return-1===t&&e&&e.length?e.length-1:t}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(e){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,e)}},{key:"audioTracks",get:function(){var e=this.audioTrackController;return e?e.audioTracks:[]}},{key:"audioTrack",get:function(){var e=this.audioTrackController;return e?e.audioTrack:-1},set:function(e){var t=this.audioTrackController;t&&(t.audioTrack=e)}},{key:"subtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTrack:-1},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var e=this.subtitleTrackController;return!!e&&e.subtitleDisplay},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(e){this.config.lowLatencyMode=e}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}]),o(i,t);var l=w;function w(e){void 0===e&&(e={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new v.EventEmitter,this._autoLevelCapping=void 0,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null;var t=this.config=Object(b.mergeConfig)(w.DefaultConfig,e),e=(this.userConfig=e,Object(y.enableLogs)(t.debug),this._autoLevelCapping=-1,t.progressive&&Object(b.enableStreamingMode)(t),t.abrController),i=t.bufferController,r=t.capLevelController,s=t.fpsController,e=this.abrController=new e(this),i=this.bufferController=new i(this),r=this.capLevelController=new r(this),s=new s(this),a=new u.default(this),n=new h.default(this),o=new p.default(this),l=this.levelController=new g.default(this),c=new m.FragmentTracker(this),d=this.streamController=new A.default(this,c),l=(r.setStreamController(d),s.setStreamController(d),[l,d]),d=(this.networkControllers=l,[a,n,e,i,r,s,o,c]);this.audioTrackController=this.createController(t.audioTrackController,null,l),this.createController(t.audioStreamController,c,l),this.subtitleTrackController=this.createController(t.subtitleTrackController,null,l),this.createController(t.subtitleStreamController,c,l),this.createController(t.timelineController,null,d),this.emeController=this.createController(t.emeController,null,d),this.cmcdController=this.createController(t.cmcdController,null,d),this.latencyController=this.createController(f.default,null,d),this.coreComponents=d}l.defaultConfig=void 0},"./src/is-supported.ts":function(e,t,i){i.r(t),i.d(t,"isSupported",function(){return a}),i.d(t,"changeTypeSupported",function(){return n});var r=i("./src/utils/mediasource-helper.ts");function s(){return self.SourceBuffer||self.WebKitSourceBuffer}function a(){var e,t=Object(r.getMediaSource)();return!!t&&(e=s(),t=t&&"function"==typeof t.isTypeSupported&&t.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),e=!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove,!!t)&&!!e}function n(){var e=s();return"function"==typeof(null==e||null==(e=e.prototype)?void 0:e.changeType)}},"./src/loader/fragment-loader.ts":function(e,t,i){i.r(t),i.d(t,"default",function(){return l}),i.d(t,"LoadError",function(){return g});var r=i("./src/polyfills/number.ts"),h=i("./src/errors.ts");function s(e){var i="function"==typeof Map?new Map:void 0;return(s=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==i){if(i.has(e))return i.get(e);i.set(e,t)}function t(){return a(e,arguments,o(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),n(t,e)})(e)}function a(e,t,i){return(a=function(){if("undefined"==typeof Reflect||!Reflect.construct)return;if(Reflect.construct.sham)return;if("function"==typeof Proxy)return 1;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),1}catch(e){}}()?Reflect.construct:function(e,t,i){var r=[null],t=(r.push.apply(r,t),new(Function.bind.apply(e,r)));return i&&n(t,i.prototype),t}).apply(null,arguments)}function n(e,t){return(n=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function o(e){return(o=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var p=Math.pow(2,17),l=((t=c.prototype).destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},t.abort=function(){this.loader&&this.loader.abort()},t.load=function(n,o){var l=this,e=n.url;if(!e)return Promise.reject(new g({type:h.ErrorTypes.NETWORK_ERROR,details:h.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:n,networkDetails:null},"Fragment does not have a "+(e?"part list":"url")));this.abort();var i=this.config,c=i.fLoader,d=i.loader;return new Promise(function(s,r){l.loader&&l.loader.destroy();var a=l.loader=n.loader=new(c||d)(i),e=f(n),t={timeout:i.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:i.fragLoadingMaxRetryTimeout,highWaterMark:p};n.stats=a.stats,a.load(e,t,{onSuccess:function(e,t,i,r){l.resetLoader(n,a),s({frag:n,part:null,payload:e.data,networkDetails:r})},onError:function(e,t,i){l.resetLoader(n,a),r(new g({type:h.ErrorTypes.NETWORK_ERROR,details:h.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:n,response:e,networkDetails:i}))},onAbort:function(e,t,i){l.resetLoader(n,a),r(new g({type:h.ErrorTypes.NETWORK_ERROR,details:h.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:n,networkDetails:i}))},onTimeout:function(e,t,i){l.resetLoader(n,a),r(new g({type:h.ErrorTypes.NETWORK_ERROR,details:h.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:n,networkDetails:i}))},onProgress:function(e,t,i,r){o&&o({frag:n,part:null,payload:i,networkDetails:r})}})})},t.loadPart=function(n,o,l){var c=this,i=(this.abort(),this.config),d=i.fLoader,u=i.loader;return new Promise(function(s,r){c.loader&&c.loader.destroy();var a=c.loader=n.loader=new(d||u)(i),e=f(n,o),t={timeout:i.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:i.fragLoadingMaxRetryTimeout,highWaterMark:p};o.stats=a.stats,a.load(e,t,{onSuccess:function(e,t,i,r){c.resetLoader(n,a),c.updateStatsFromPart(n,o);e={frag:n,part:o,payload:e.data,networkDetails:r};l(e),s(e)},onError:function(e,t,i){c.resetLoader(n,a),r(new g({type:h.ErrorTypes.NETWORK_ERROR,details:h.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:n,part:o,response:e,networkDetails:i}))},onAbort:function(e,t,i){n.stats.aborted=o.stats.aborted,c.resetLoader(n,a),r(new g({type:h.ErrorTypes.NETWORK_ERROR,details:h.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:n,part:o,networkDetails:i}))},onTimeout:function(e,t,i){c.resetLoader(n,a),r(new g({type:h.ErrorTypes.NETWORK_ERROR,details:h.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:n,part:o,networkDetails:i}))}})})},t.updateStatsFromPart=function(e,t){var i=e.stats,r=t.stats,s=r.total,e=(i.loaded+=r.loaded,s?(s=((e=Math.round(e.duration/t.duration))-(t=Math.min(Math.round(i.loaded/s),e)))*Math.round(i.loaded/t),i.total=i.loaded+s):i.total=Math.max(i.loaded,i.total),i.loading),t=r.loading;e.start?e.first+=t.first-t.start:(e.start=t.start,e.first=t.first),e.end=t.end},t.resetLoader=function(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()},c);function c(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}function f(e,t){var i=(t=void 0===t?null:t)||e,e={frag:e,part:t,responseType:"arraybuffer",url:i.url,headers:{},rangeStart:0,rangeEnd:0},t=i.byteRangeStartOffset,i=i.byteRangeEndOffset;return Object(r.isFiniteNumber)(t)&&Object(r.isFiniteNumber)(i)&&(e.rangeStart=t,e.rangeEnd=i),e}d=s(Error),i=d,(t=u).prototype=Object.create(i.prototype),n(t.prototype.constructor=t,i);var d,g=u;function u(e){for(var t,i=arguments.length,r=new Array(1>8*(15-i)&255;return t},i.setDecryptDataFromLevelKey=function(e,t){var i=e;return"AES-128"===(null==e?void 0:e.method)&&e.uri&&!e.iv&&((i=o.LevelKey.fromURI(e.uri)).method=e.method,i.iv=this.createInitializationVector(t),i.keyFormat="identity"),i},i.setElementaryStreamInfo=function(e,t,i,r,s,a){void 0===a&&(a=!1);var n=this.elementaryStreams,o=n[e];o?(o.startPTS=Math.min(o.startPTS,t),o.endPTS=Math.max(o.endPTS,i),o.startDTS=Math.min(o.startDTS,r),o.endDTS=Math.max(o.endDTS,s)):n[e]={startPTS:t,endPTS:i,startDTS:r,endDTS:s,partial:a}},i.clearElementaryStreamInfo=function(){var e=this.elementaryStreams;e[r.AUDIO]=null,e[r.VIDEO]=null,e[r.AUDIOVIDEO]=null},h(b,[{key:"decryptdata",get:function(){var e;return this.levelkey||this._decryptdata?(!this._decryptdata&&this.levelkey&&("number"!=typeof(e=this.sn)&&(this.levelkey&&"AES-128"===this.levelkey.method&&!this.levelkey.iv&&n.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),e=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,e)),this._decryptdata):null}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){var e;return null!==this.programDateTime&&Object(s.isFiniteNumber)(this.programDateTime)?(e=Object(s.isFiniteNumber)(this.duration)?this.duration:0,this.programDateTime+1e3*e):null}},{key:"encrypted",get:function(){var e;return!(null==(e=this.decryptdata)||!e.keyFormat||!this.decryptdata.uri)}}]),b),A=(c(y,p=g),h(y,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var e=this.elementaryStreams;return!!(e.audio||e.video||e.audiovideo)}}]),y);function y(e,t,i,r,s){(i=p.call(this,i)||this).fragOffset=0,i.duration=0,i.gap=!1,i.independent=!1,i.relurl=void 0,i.fragment=void 0,i.index=void 0,i.stats=new l.LoadStats,i.duration=e.decimalFloatingPoint("DURATION"),i.gap=e.bool("GAP"),i.independent=e.bool("INDEPENDENT"),i.relurl=e.enumeratedString("URI"),i.fragment=t,i.index=r;t=e.enumeratedString("BYTERANGE");return t&&i.setByteRange(t,s),s&&(i.fragOffset=s.fragOffset+s.duration),i}function b(e,t){return(t=f.call(this,t)||this)._decryptdata=null,t.rawProgramDateTime=null,t.programDateTime=null,t.tagList=[],t.duration=0,t.sn=0,t.levelkey=void 0,t.type=void 0,t.loader=null,t.level=-1,t.cc=0,t.startPTS=void 0,t.endPTS=void 0,t.appendedPTS=void 0,t.startDTS=void 0,t.endDTS=void 0,t.start=0,t.deltaPTS=void 0,t.maxStartPTS=void 0,t.minEndPTS=void 0,t.stats=new l.LoadStats,t.urlId=0,t.data=void 0,t.bitrateTest=!1,t.title=null,t.initSegment=null,t.type=e,t}function v(e){var t;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=((t={})[r.AUDIO]=null,t[r.VIDEO]=null,t[r.AUDIOVIDEO]=null,t),this.baseurl=e}},"./src/loader/key-loader.ts":function(e,t,i){i.r(t),i.d(t,"default",function(){return s});var n=i("./src/events.ts"),r=i("./src/errors.ts"),o=i("./src/utils/logger.ts"),s=((t=a.prototype)._registerListeners=function(){this.hls.on(n.Events.KEY_LOADING,this.onKeyLoading,this)},t._unregisterListeners=function(){this.hls.off(n.Events.KEY_LOADING,this.onKeyLoading)},t.destroy=function(){for(var e in this._unregisterListeners(),this.loaders){e=this.loaders[e];e&&e.destroy()}this.loaders={}},t.onKeyLoading=function(e,t){var i,r,t=t.frag,s=t.type,a=this.loaders[s];t.decryptdata?(i=t.decryptdata.uri)!==this.decrypturl||null===this.decryptkey?(r=this.hls.config,a&&(o.logger.warn("abort previous key loader for type:"+s),a.abort()),i?(a=r.loader,s=t.loader=this.loaders[s]=new a(r),this.decrypturl=i,this.decryptkey=null,a={url:i,frag:t,responseType:"arraybuffer"},i={timeout:r.fragLoadingTimeOut,maxRetry:0,retryDelay:r.fragLoadingRetryDelay,maxRetryDelay:r.fragLoadingMaxRetryTimeout,highWaterMark:0},r={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)},s.load(a,i,r)):o.logger.warn("key uri is falsy")):this.decryptkey&&(t.decryptdata.key=this.decryptkey,this.hls.trigger(n.Events.KEY_LOADED,{frag:t})):o.logger.warn("Missing decryption data on fragment in onKeyLoading")},t.loadsuccess=function(e,t,i){i=i.frag;i.decryptdata?(this.decryptkey=i.decryptdata.key=new Uint8Array(e.data),i.loader=null,delete this.loaders[i.type],this.hls.trigger(n.Events.KEY_LOADED,{frag:i})):o.logger.error("after key load, decryptdata unset")},t.loaderror=function(e,t){var t=t.frag,i=t.loader;i&&i.abort(),delete this.loaders[t.type],this.hls.trigger(n.Events.ERROR,{type:r.ErrorTypes.NETWORK_ERROR,details:r.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:t,response:e})},t.loadtimeout=function(e,t){var t=t.frag,i=t.loader;i&&i.abort(),delete this.loaders[t.type],this.hls.trigger(n.Events.ERROR,{type:r.ErrorTypes.NETWORK_ERROR,details:r.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:t})},a);function a(e){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=e,this._registerListeners()}},"./src/loader/level-details.ts":function(e,t,i){i.r(t),i.d(t,"LevelDetails",function(){return a});var r=i("./src/polyfills/number.ts");function s(e,t){for(var i=0;ie.endSN||0>24&255,o[1]=t>>16&255,o[2]=t>>8&255,o[3]=255&t,o.set(e,4),a=0,t=8;a>24&255,e>>16&255,e>>8&255,255&e,i>>24,i>>16&255,i>>8&255,255&i,t>>24,t>>16&255,t>>8&255,255&t,85,196,0,0]))},u.mdia=function(e){return u.box(u.types.mdia,u.mdhd(e.timescale,e.duration),u.hdlr(e.type),u.minf(e))},u.mfhd=function(e){return u.box(u.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e]))},u.minf=function(e){return"audio"===e.type?u.box(u.types.minf,u.box(u.types.smhd,u.SMHD),u.DINF,u.stbl(e)):u.box(u.types.minf,u.box(u.types.vmhd,u.VMHD),u.DINF,u.stbl(e))},u.moof=function(e,t,i){return u.box(u.types.moof,u.mfhd(e),u.traf(i,t))},u.moov=function(e){for(var t=e.length,i=[];t--;)i[t]=u.trak(e[t]);return u.box.apply(null,[u.types.moov,u.mvhd(e[0].timescale,e[0].duration)].concat(i).concat(u.mvex(e)))},u.mvex=function(e){for(var t=e.length,i=[];t--;)i[t]=u.trex(e[t]);return u.box.apply(null,[u.types.mvex].concat(i))},u.mvhd=function(e,t){t*=e;var i=Math.floor(t/(1+a)),t=Math.floor(t%(1+a)),e=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,i>>24,i>>16&255,i>>8&255,255&i,t>>24,t>>16&255,t>>8&255,255&t,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return u.box(u.types.mvhd,e)},u.sdtp=function(e){for(var t,i=e.samples||[],r=new Uint8Array(4+i.length),s=0;s>>8&255),r.push(255&i),r=r.concat(Array.prototype.slice.call(t));for(a=0;a>>8&255),s.push(255&i),s=s.concat(Array.prototype.slice.call(t));var n=u.box(u.types.avcC,new Uint8Array([1,r[3],r[4],r[5],255,224|e.sps.length].concat(r).concat([e.pps.length]).concat(s))),o=e.width,l=e.height,c=e.pixelRatio[0],d=e.pixelRatio[1];return u.box(u.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,o>>8&255,255&o,l>>8&255,255&l,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),n,u.box(u.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),u.box(u.types.pasp,new Uint8Array([c>>24,c>>16&255,c>>8&255,255&c,d>>24,d>>16&255,d>>8&255,255&d])))},u.esds=function(e){var t=e.config.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e.config).concat([6,1,2]))},u.mp4a=function(e){var t=e.samplerate;return u.box(u.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,255&t,0,0]),u.box(u.types.esds,u.esds(e)))},u.mp3=function(e){var t=e.samplerate;return u.box(u.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,255&t,0,0]))},u.stsd=function(e){return"audio"===e.type?e.isAAC||"mp3"!==e.codec?u.box(u.types.stsd,u.STSD,u.mp4a(e)):u.box(u.types.stsd,u.STSD,u.mp3(e)):u.box(u.types.stsd,u.STSD,u.avc1(e))},u.tkhd=function(e){var t=e.id,i=e.duration*e.timescale,r=e.width,e=e.height,s=Math.floor(i/(1+a)),i=Math.floor(i%(1+a));return u.box(u.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,0,0,0,0,s>>24,s>>16&255,s>>8&255,255&s,i>>24,i>>16&255,i>>8&255,255&i,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,r>>8&255,255&r,0,0,e>>8&255,255&e,0,0]))},u.traf=function(e,t){var i=u.sdtp(e),r=e.id,s=Math.floor(t/(1+a)),t=Math.floor(t%(1+a));return u.box(u.types.traf,u.box(u.types.tfhd,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r])),u.box(u.types.tfdt,new Uint8Array([1,0,0,0,s>>24,s>>16&255,s>>8&255,255&s,t>>24,t>>16&255,t>>8&255,255&t])),u.trun(e,i.length+16+20+8+16+8+8),i)},u.trak=function(e){return e.duration=e.duration||4294967295,u.box(u.types.trak,u.tkhd(e),u.mdia(e))},u.trex=function(e){e=e.id;return u.box(u.types.trex,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},u.trun=function(e,t){var i,r,s,a,n,o=e.samples||[],l=o.length,e=12+16*l,c=new Uint8Array(e);for(c.set([0,0,15,1,l>>>24&255,l>>>16&255,l>>>8&255,255&l,(t+=8+e)>>>24&255,t>>>16&255,t>>>8&255,255&t],0),i=0;i>>24&255,r>>>16&255,r>>>8&255,255&r,s>>>24&255,s>>>16&255,s>>>8&255,255&s,a.isLeading<<2|a.dependsOn,a.isDependedOn<<6|a.hasRedundancy<<4|a.paddingValue<<1|a.isNonSync,61440&a.degradPrio,15&a.degradPrio,n>>>24&255,n>>>16&255,n>>>8&255,255&n],12+16*i);return u.box(u.types.trun,c)},u.initSegment=function(e){u.types||u.init();var e=u.moov(e),t=new Uint8Array(u.FTYP.byteLength+e.byteLength);return t.set(u.FTYP),t.set(e,u.FTYP.byteLength),t},u);function u(){}i.types=void 0,i.HDLR_TYPES=void 0,i.STTS=void 0,i.STSC=void 0,i.STCO=void 0,i.STSZ=void 0,i.VMHD=void 0,i.SMHD=void 0,i.STSD=void 0,i.FTYP=void 0,i.DINF=void 0,t.default=i},"./src/remux/mp4-remuxer.ts":function(e,t,i){i.r(t),i.d(t,"default",function(){return r}),i.d(t,"normalizePts",function(){return X});var h=i("./src/polyfills/number.ts"),F=i("./src/remux/aac-helper.ts"),W=i("./src/remux/mp4-generator.ts"),V=i("./src/events.ts"),$=i("./src/errors.ts"),K=i("./src/utils/logger.ts"),E=i("./src/types/loader.ts"),J=i("./src/utils/timescale-conversion.ts");function q(){return(q=Object.assign||function(e){for(var t=1;tA.pts&&(f=Math.max(Math.min(f,A.pts-A.dts),-18e3)),A.dtsNumber.MAX_SAFE_INTEGER?1/0:e},i.hexadecimalInteger=function(e){if(this[e]){for(var t=(1&(t=(this[e]||"0x").slice(2)).length?"0":"")+t,i=new Uint8Array(t.length/2),r=0;rNumber.MAX_SAFE_INTEGER?1/0:e},i.decimalFloatingPoint=function(e){return parseFloat(this[e])},i.optionalFloat=function(e,t){e=this[e];return e?parseFloat(e):t},i.enumeratedString=function(e){return this[e]},i.bool=function(e){return"YES"===this[e]},i.decimalResolution=function(e){e=r.exec(this[e]);if(null!==e)return{width:parseInt(e[1],10),height:parseInt(e[2],10)}},n.parseAttrList=function(e){var t,i={};for(s.lastIndex=0;null!==(t=s.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},n);function n(e){for(var t in e="string"==typeof e?n.parseAttrList(e):e)e.hasOwnProperty(t)&&(this[t]=e[t])}},"./src/utils/binary-search.ts":function(e,t,i){i.r(t),t.default={search:function(e,t){for(var i,r,s=0,a=e.length-1;s<=a;){var n=t(r=e[i=(s+a)/2|0]);if(0=i.start(r)&&t<=i.end(r))return!0}catch(e){}return!1},n.bufferInfo=function(e,t,i){try{if(e){for(var r=n.getBuffered(e),s=[],a=0;aa&&(r[n-1].end=e[s].end):r.push(e[s])}else r=e;for(var o,l=0,c=t,d=t,u=0;u=e&&r.logger.log(this.time+" ["+e+"] "+t)},C),m=((i=_.prototype).reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},i.setStyles=function(e){for(var t=["foreground","underline","italics","background","flash"],i=0;in&&(this.logger.log(c.DEBUG,"Too large cursor position "+this.pos),this.pos=n)},i.moveCursor=function(e){var t=this.pos+e;if(1=n?this.logger.log(c.ERROR,"Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!"):(this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1))},i.clearFromPos=function(e){for(var t=e;t ("+l([n,o])+")"),!(i=(i=(i=(i=this.parseCmd(n,o))||this.parseMidrow(n,o))||this.parsePAC(n,o))||this.parseBackgroundAttributes(n,o))&&(r=this.parseChars(n,o))&&((a=this.currentChannel)&&0i.startCC||e&&e.cc=this.minWeight_},i.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},i.destroy=function(){},t.default=r},"./src/utils/ewma.ts":function(e,t,i){function r(e,t,i){void 0===t&&(t=0),void 0===i&&(i=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=i}i.r(t),(i=r.prototype).sample=function(e,t){var i=Math.pow(this.alpha_,e);this.estimate_=t*(1-i)+i*this.estimate_,this.totalWeight_+=e},i.getTotalWeight=function(){return this.totalWeight_},i.getEstimate=function(){if(this.alpha_){var e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_},t.default=r},"./src/utils/fetch-loader.ts":function(e,t,i){i.r(t),i.d(t,"fetchSupported",function(){return l});var u=i("./src/polyfills/number.ts"),r=i("./src/loader/load-stats.ts"),c=i("./src/demux/chunk-cache.ts");function s(e){var i="function"==typeof Map?new Map:void 0;return(s=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==i){if(i.has(e))return i.get(e);i.set(e,t)}function t(){return a(e,arguments,o(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),n(t,e)})(e)}function a(e,t,i){return(a=function(){if("undefined"==typeof Reflect||!Reflect.construct)return;if(Reflect.construct.sham)return;if("function"==typeof Proxy)return 1;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),1}catch(e){}}()?Reflect.construct:function(e,t,i){var r=[null],t=(r.push.apply(r,t),new(Function.bind.apply(e,r)));return i&&n(t,i.prototype),t}).apply(null,arguments)}function n(e,t){return(n=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function o(e){return(o=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function h(){return(h=Object.assign||function(e){for(var t=1;t=n&&o(s,a,l.flush(),r)):o(s,a,e,r),i())}).catch(function(){return Promise.reject()})}()};i=d;function d(e){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=e.fetchSetup||p,this.controller=new self.AbortController,this.stats=new r.LoadStats}function p(e,t){return new self.Request(e.url,t)}f=s(Error),m=f,(g=y).prototype=Object.create(m.prototype),n(g.prototype.constructor=g,m);var f,g,m,A=y;function y(e,t,i){return(e=f.call(this,e)||this).code=void 0,e.details=void 0,e.code=t,e.details=i,e}t.default=i},"./src/utils/imsc1-ttml-parser.ts":function(e,t,i){i.r(t),i.d(t,"IMSC1_CODEC",function(){return r}),i.d(t,"parseIMSC1",function(){return s});var n=i("./src/utils/mp4-tools.ts"),o=i("./src/utils/vttparser.ts"),p=i("./src/utils/vttcue.ts"),l=i("./src/demux/id3.ts"),c=i("./src/utils/timescale-conversion.ts"),f=i("./src/utils/webvtt-parser.ts");function g(){return(g=Object.assign||function(e){for(var t=1;t"):s)})}(e,"debug","log","info","warn","error");try{a.log()}catch(e){a=r}}else a=r}var o=r},"./src/utils/mediakeys-helper.ts":function(e,t,i){i.r(t),i.d(t,"KeySystems",function(){return r}),i.d(t,"requestMediaKeySystemAccess",function(){return s}),(i=r=r||{}).WIDEVINE="com.widevine.alpha",i.PLAYREADY="com.microsoft.playready";var r,s="undefined"!=typeof self&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null},"./src/utils/mediasource-helper.ts":function(e,t,i){function r(){return self.MediaSource||self.WebKitMediaSource}i.r(t),i.d(t,"getMediaSource",function(){return r})},"./src/utils/mp4-tools.ts":function(e,t,i){i.r(t),i.d(t,"bin2str",function(){return d}),i.d(t,"readUint16",function(){return h}),i.d(t,"readUint32",function(){return A}),i.d(t,"writeUint32",function(){return n}),i.d(t,"findBox",function(){return y}),i.d(t,"parseSegmentIndex",function(){return b}),i.d(t,"parseInitSegment",function(){return s}),i.d(t,"getStartDTS",function(){return o}),i.d(t,"getDuration",function(){return l}),i.d(t,"computeRawDurationFromSamples",function(){return v}),i.d(t,"offsetStartDTS",function(){return u}),i.d(t,"segmentValidRange",function(){return p}),i.d(t,"appendUint8Array",function(){return f});var r=i("./src/utils/typed-array.ts"),m=i("./src/loader/fragment.ts"),a=Math.pow(2,32)-1,c=[].push;function d(e){return String.fromCharCode.apply(null,e)}function h(e,t){"data"in e&&(t+=e.start,e=e.data);e=e[t]<<8|e[t+1];return e<0?65536+e:e}function A(e,t){"data"in e&&(t+=e.start,e=e.data);e=e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3];return e<0?4294967296+e:e}function n(e,t,i){"data"in e&&(t+=e.start,e=e.data),e[t]=i>>24,e[t+1]=i>>16&255,e[t+2]=i>>8&255,e[t+3]=255&i}function y(e,t){var i,r,s=[];if(t.length)for(var a=("data"in e?(i=e.data,r=e.start,e.end):(r=0,(i=e).byteLength)),n=r;n>>31)return console.warn("SIDX has hierarchical references (not supported)"),null;d=A(r,c);c+=4,i.push({referenceSize:u,subsegmentDuration:d,info:{duration:d/a,start:n,end:n+u-1}}),n+=u,s=c+=4}return{earliestPresentationTime:0,timescale:a,version:e,referencesCount:o,references:i,moovEndOffset:t}}function s(e){for(var i=[],t=y(e,["moov","trak"]),r=0;re)&&(this.startTime=e),this.endTime=t,this.screen=i,this.timelineController.createCaptionsTrack(this.trackName)},i.reset=function(){this.cueRanges=[],this.startTime=null};var r=s;function s(e,t){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=e,this.trackName=t}},"./src/utils/texttrack-utils.ts":function(e,t,i){i.r(t),i.d(t,"sendAddTrackEvent",function(){return r}),i.d(t,"addCueToTrack",function(){return a}),i.d(t,"clearCurrentCues",function(){return n}),i.d(t,"removeCuesInRange",function(){return o}),i.d(t,"getCuesInRange",function(){return l});var s=i("./src/utils/logger.ts");function r(e,t){var i;try{i=new Event("addtrack")}catch(e){(i=document.createEvent("Event")).initEvent("addtrack",!1,!1)}i.track=e,t.dispatchEvent(i)}function a(e,t){var i=e.mode;if("disabled"===i&&(e.mode="hidden"),e.cues&&!e.cues.getCueById(t.id))try{if(e.addCue(t),!e.cues.getCueById(t.id))throw new Error("addCue is failed for: "+t)}catch(i){s.logger.debug("[texttrack-utils]: "+i);var r=new self.TextTrackCue(t.startTime,t.endTime,t.text);r.id=t.id,e.addCue(r)}"disabled"===i&&(e.mode=i)}function n(e){var t=e.mode;if("disabled"===t&&(e.mode="hidden"),e.cues)for(var i=e.cues.length;i--;)e.removeCue(e.cues[i]);"disabled"===t&&(e.mode=t)}function o(e,t,i){var r=e.mode;if("disabled"===r&&(e.mode="hidden"),e.cues&&0e[i].endTime)return-1;for(var r=0,s=i;r<=s;){var a=Math.floor((s+r)/2);if(te[a].startTime&&r=t&&o.endTime<=i)r.push(o);else if(o.startTime>i)return r}return r}},"./src/utils/time-ranges.ts":function(e,t,i){i.r(t),t.default={toString:function(e){for(var t="",i=e.length,r=0;r/gi,"\n")}(i=f.prototype).parse=function(e){var r=this;function t(){for(var e=0,t=p(t=r.buffer);e>>0).toString()};function S(e,t,i){return r(e.toString())+r(t.toString())+r(i)}function s(e,t,i,s,a,n,r,o){var l,c=new y.VTTParser,e=Object(b.utf8ArrayToStr)(new Uint8Array(e)).trim().replace(E,"\n").split("\n"),d=[],u=Object(v.toMpegTsClockFromTimescale)(t,i),h="00:00.000",p=0,f=0,g=!0,m=!1;c.oncue=function(e){var t=s[a],i=s.ccOffset,r=(p-u)/9e4,i=(null!=t&&t.new&&(void 0!==f?i=s.ccOffset=t.start:function(e,t){var i,r=e[a],s=e[r.prevCC];if(!s||!s.new&&r.new)return e.ccOffset=e.presentationOffset=r.start,r.new=!1;for(;null!=(i=s)&&i.new;)e.ccOffset+=r.start-s.start,r.new=!1,s=e[(r=s).prevCC];e.presentationOffset=t}(s,r)),r&&(i=r-s.presentationOffset),m&&(t=e.endTime-e.startTime,r=Object(w.normalizePts)(9e4*(e.startTime+i-f),9e4*n)/9e4,e.startTime=r,e.endTime=r+t),e.text.trim());e.text=decodeURIComponent(encodeURIComponent(i)),e.id||(e.id=S(e.startTime,e.endTime,i)),0=e.maxRetry||400<=t&&t<499?(o.logger.error(t+" while loading "+s.url),this.callbacks.onError({code:t,text:a.statusText},s,a)):(o.logger.warn(t+" while loading "+s.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,e.maxRetryDelay),n.retry++)):(self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),e.timeout)))},i.loadtimeout=function(){o.logger.warn("timeout while loading "+this.context.url);var e=this.callbacks;e&&(this.abortInternal(),e.onTimeout(this.stats,this.context,this.loader))},i.loadprogress=function(e){var t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)},i.getCacheAge=function(){var e,t=null;return t=this.loader&&s.test(this.loader.getAllResponseHeaders())?(e=this.loader.getResponseHeader("age"))?parseFloat(e):null:t},t.default=a}},r={},s.m=i,s.c=r,s.d=function(e,t,i){s.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},s.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s.t=function(t,e){if(1&e&&(t=s(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(s.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)s.d(i,r,function(e){return t[e]}.bind(null,r));return i},s.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return s.d(t,"a",t),t},s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},s.p="/dist/",s(s.s="./src/hls.ts").default;function s(e){var t;return(r[e]||(t=r[e]={i:e,l:!1,exports:{}},i[e].call(t.exports,t,t.exports,s),t.l=!0,t)).exports}var i,r}())}))&&Sr.__esModule&&Object.prototype.hasOwnProperty.call(Sr,"default")?Sr.default:Sr;class ps extends e{constructor(e){super(),(this.player=e)._opt,this.canVideoPlay=!1,this.$videoElement=null,this.canvasRenderInterval=null,this.bandwidthEstimateInterval=null,this.fpsInterval=null,this.hlsFps=0,this.hlsPrevFrams=0,this.isInitInfo=!1,this.eventsDestroy=[],function(){let e=document.createElement("video"),t=e.canPlayType("application/vnd.apple.mpegurl");return e=null,t}()?(this.$videoElement=this.player.video.$videoElement,this.canVideoPlay=!0):s.isSupported()?(this.$videoElement=this.player.video.$videoElement,this.hls=new s({}),this._initHls(),this._bindEvents()):this.player.debug.error("HlsDecoder","init hls error ,not support "),this.player.debug.log("HlsDecoder","init")}destroy(){this.hls&&(this.hls.destroy(),this.hls=null),this.eventsDestroy.length&&(this.eventsDestroy.forEach(e=>e()),this.eventsDestroy=[]),this.isInitInfo=!1,this._stopCanvasRender(),this._stopBandwidthEstimateInterval(),this._stopFpsInterval(),this.$videoElement=null,this.hlsFps=0,this.player.debug.log("HlsDecoder","destroy")}checkHlsBufferedDelay(){var e=this.$videoElement;let t=0;var i=e.buffered,i=i.length?i.end(i.length-1):0;return(t=i-e.currentTime)<0&&(this.player.debug.warn("HlsDecoder","checkHlsBufferedDelay result < 0",t,i,e.currentTime),t=0),t}getFps(){return this.hlsFps}_startCanvasRender(){this._stopCanvasRender(),this.canvasRenderInterval=setInterval(()=>{this.player.video.render({$video:this.$videoElement,ts:0})},40)}_stopCanvasRender(){this.canvasRenderInterval&&(clearInterval(this.canvasRenderInterval),this.canvasRenderInterval=null)}_startBandwidthEstimateInterval(){this._stopBandwidthEstimateInterval(),this.bandwidthEstimateInterval=setInterval(()=>{let e=0;this.hls.bandwidthEstimate&&(e=this.hls.bandwidthEstimate),this.player.emit(w.kBps,(e/1024/8/10).toFixed(2))},1e3)}_stopBandwidthEstimateInterval(){this.bandwidthEstimateInterval&&(clearInterval(this.bandwidthEstimateInterval),this.bandwidthEstimateInterval=null)}_startFpsInterval(){this._stopCanvasRender(),this.fpsInterval=setInterval(()=>{var e=this.$videoElement.getVideoPlaybackQuality();this.hlsFps=e.totalVideoFrames-this.hlsPrevFrams,this.hlsPrevFrams=e.totalVideoFrames},1e3)}_stopFpsInterval(){this.fpsInterval&&(clearInterval(this.fpsInterval),this.fpsInterval=null)}_initHls(){this.player._opt.useCanvasRender&&(this.$videoElement=document.createElement("video"),this.$videoElement.muted=!0,ct()&&(this.$videoElement.style.position="absolute"),this.initVideoEvents()),this.hls.attachMedia(this.$videoElement)}_bindEvents(){const i=this.player,e=this.player.events["proxy"];this.hls;var t=e(this.$videoElement,Me,e=>{this.hls&&(e=parseInt(e.timeStamp,10),i.handleRender(),i.updateStats({ts:e,dts:e,fps:!0}),i.emit(w.videoTimeUpdate,e))});this.eventsDestroy.push(t),this._startBandwidthEstimateInterval(),this._startFpsInterval(),this.hls.on(s.Events.ERROR,(e,t)=>{if(t.fatal)switch(t.type){case s.ErrorTypes.NETWORK_ERROR:this.player.debug.error("HlsDecoder","fatal network error encountered, try to recover"),this.hls.startLoad();break;case s.ErrorTypes.MEDIA_ERROR:this.player.debug.error("HlsDecoder","fatal media error encountered, try to recover"),this.hls.recoverMediaError()}}),this.hls.on(s.Events.MEDIA_ATTACHING,()=>{}),this.hls.on(s.Events.MEDIA_ATTACHED,()=>{}),this.hls.on(s.Events.MEDIA_DETACHING,()=>{}),this.hls.on(s.Events.MEDIA_DETACHED,()=>{}),this.hls.on(s.Events.BUFFER_RESET,()=>{}),this.hls.on(s.Events.BUFFER_CODECS,()=>{}),this.hls.on(s.Events.BUFFER_CREATED,()=>{}),this.hls.on(s.Events.BUFFER_APPENDING,(e,t)=>{this.player.debug.log("HlsDecoder","BUFFER_APPENDING",t)}),this.hls.on(s.Events.BUFFER_APPENDED,()=>{}),this.hls.on(s.Events.BUFFER_EOS,()=>{}),this.hls.on(s.Events.BUFFER_FLUSHING,()=>{}),this.hls.on(s.Events.BUFFER_FLUSHED,()=>{}),this.hls.on(s.Events.MANIFEST_LOADING,()=>{this.player.debug.log("HlsDecoder","MANIFEST_LOADING 开始加载playlist m3u8资源")}),this.hls.on(s.Events.MANIFEST_LOADED,(e,t)=>{this.player.debug.log("HlsDecoder","MANIFEST_LOADED playlist m3u8文件加载完成",t)}),this.hls.on(s.Events.MANIFEST_PARSED,()=>{this.player.debug.log("HlsDecoder","MANIFEST_PARSED playlist m3u8解析完成"),i._times.demuxStart||(i._times.demuxStart=A())}),this.hls.on(s.Events.LEVEL_LOADING,()=>{}),this.hls.on(s.Events.LEVEL_LOADED,(e,t)=>{}),this.hls.on(s.Events.FRAG_LOADING,()=>{}),this.hls.on(s.Events.FRAG_LOADED,(e,t)=>{i._times.decodeStart||(i._times.decodeStart=A())}),this.hls.on(s.Events.BUFFER_APPENDING,()=>{i._times.videoStart||(i._times.videoStart=A(),i.handlePlayToRenderTimes())}),this.hls.on(s.Events.FRAG_DECRYPTED,()=>{}),this.hls.on(s.Events.KEY_LOADING,()=>{}),this.hls.on(s.Events.KEY_LOADING,()=>{}),this.hls.on(s.Events.FPS_DROP,e=>{}),this.hls.on(s.Events.FPS_DROP_LEVEL_CAPPING,e=>{}),this.hls.on(s.Events.FRAG_PARSING_INIT_SEGMENT,(e,t)=>{this.player.debug.log("HlsDecoder","FRAG_PARSING_INIT_SEGMENT",t);const i=!!(t&&t.tracks&&t.tracks.audio),r=!!(t&&t.tracks&&t.tracks.video);if(i&&t.tracks.audio){var s=t.tracks.audio;const i=s.metadata&&s.metadata.channelCount?s.metadata.channelCount:0,r=s.codec;this.player.audio&&this.player.audio.updateAudioInfo({encType:r,channels:i,sampleRate:44100})}var a;r&&t.tracks.video&&(t=(s=t.tracks.video).codec,a=s.metadata&&s.metadata.width?s.metadata.width:0,s=s.metadata&&s.metadata.height?s.metadata.height:0,this.player.video)&&this.player.video.updateVideoInfo({encTypeCode:-1!==t.indexOf("avc")?7:12,width:a,height:s})})}initVideoPlay(e){this.player._opt.useCanvasRender&&(this.$videoElement=document.createElement("video"),this.initVideoEvents()),this.$videoElement.muted=!0,this.$videoElement.src=e}initRenderSize(){this.isInitInfo||(this.player.video.updateVideoInfo({width:this.$videoElement.videoWidth,height:this.$videoElement.videoHeight}),this.player.video.initCanvasViewSize(),this.isInitInfo=!0)}initVideoEvents(){var e=this.player.events["proxy"],t=e(this.$videoElement,Pe,()=>{this.player.debug.log("HlsDecoder","video canplay"),this.$videoElement.play().then(()=>{this.player.debug.log("HlsDecoder","video play"),this._startCanvasRender(),this.initRenderSize()}).catch(e=>{this.player.debug.warn("HlsDecoder","video play error ",e)})}),i=e(this.$videoElement,Be,()=>{this.player.debug.log("HlsDecoder","video waiting")}),r=e(this.$videoElement,Me,e=>{e=parseInt(e.timeStamp,10);this.player.handleRender(),this.player.updateStats({ts:e}),this.player.emit(w.videoTimeUpdate,e),this.$videoElement.paused&&(this.player.debug.warn("HlsDecoder","video is paused and next try to replay"),this.$videoElement.play().then(()=>{this.player.debug.log("HlsDecoder","video is paused and replay success")}).catch(e=>{this.player.debug.warn("HlsDecoder","video is paused and replay error ",e)}))}),e=e(this.$videoElement,Oe,()=>{this.player.debug.log("HlsDecoder","video playback Rate change",this.$videoElement&&this.$videoElement.playbackRate)});this.eventsDestroy.push(t,i,r,e)}loadSource(i){return new Promise((e,t)=>{this.canVideoPlay?(this.initVideoPlay(i),e()):this.hls.on(s.Events.MEDIA_ATTACHED,()=>{this.hls.loadSource(i),e()})})}_handleUpdatePlaybackRate(){if(this.$videoElement){var t=this.$videoElement,i=(this.player._opt.videoBuffer+this.player._opt.videoBufferDelay)/1e3,r=t.buffered,r=(r.length&&r.start(0),r.length?r.end(r.length-1):0);let e=t.currentTime;var s=r-e,i=Math.max(5,3+i),i=(i{this.player.debug.log("WebrtcDecoder","onsignalingstatechange",e)},t.oniceconnectionstatechange=e=>{this.player.debug.log("WebrtcDecoder","oniceconnectionstatechange",t.iceConnectionState)},t.onicecandidate=e=>{this.player.debug.log("WebrtcDecoder","onicecandidate",e)},t.ontrack=e=>{var t=i.video.$videoElement;"video"===e.track.kind&&(e=e.streams[0],t.srcObject=e,this.videoStream=e)},t.onconnectionstatechange=e=>{switch(i.debug.log("WebrtcDecoder","sdp connect status "+t.connectionState),t.connectionState){case"connected":break;case"disconnected":i.emit(w.webrtcDisconnect);break;case"failed":i.emit(w.webrtcFailed);break;case"closed":i.emit(w.webrtcClosed)}},this.rtcPeerConnection=t}loadSource(s){return new Promise((t,i)=>{const r=this.rtcPeerConnection;r.createOffer().then(e=>{r.setLocalDescription(e),this.player.debug.log("WebrtcDecoder","getWebRtcRemoteSdp loadSource"),e=e.sdp,fetch(s,{method:"POST",mode:"cors",cache:"no-cache",credentials:"include",redirect:"follow",referrerPolicy:"no-referrer",headers:{"Content-Type":"application/sdp"},body:e}).then(e=>{e.text().then(e=>{this.player.debug.log("WebrtcDecoder","getWebRtcRemoteSdp response"),r.setRemoteDescription(new RTCSessionDescription({type:"answer",sdp:e})),t()}).catch(e=>{this.player.debug.error("WebrtcDecoder","loadSource response.text() error",e),i(e)})}).catch(e=>{this.player.debug.error("WebrtcDecoder","loadSource getWebRtcRemoteSdp response error",e),i(e)})}).catch(e=>{this.player.debug.error("WebrtcDecoder","loadSource rtcPeerConnection.createOffer() error",e),i(e)})})}}class gs extends e{constructor(e){super(),this.tagName="WebrtcForZLMDecoder",this.player=e,this.rtcPeerConnection=null,this.videoStream=null,this._initRtcPeerConnection(),this.player.debug.log(this.tagName,"init")}destroy(){this.rtcPeerConnection&&(this.rtcPeerConnection.close(),this.rtcPeerConnection=null),this.videoStream&&(this.videoStream.getTracks().forEach(e=>e.stop()),this.videoStream=null),this.videoStream=null,this.player.video.$videoElement.srcObject=null,this.player.debug.log(this.tagName,"destroy")}_initRtcPeerConnection(){const t=new RTCPeerConnection,i=this.player;t.addTransceiver("video",{direction:"recvonly"}),t.addTransceiver("audio",{direction:"recvonly"}),t.onsignalingstatechange=e=>{console.log("onsignalingstatechange",e)},t.oniceconnectionstatechange=e=>{console.log("oniceconnectionstatechange",t.iceConnectionState)},t.onicecandidate=e=>{console.log("onicecandidate",e)},t.ontrack=e=>{var t=i.video.$videoElement;console.log("ontrack",e),"video"===e.track.kind&&(e=e.streams[0],t.srcObject=e,this.videoStream=e)},this.rtcPeerConnection=t}loadSource(s){return new Promise((t,i)=>{const r=this.rtcPeerConnection;r.createOffer().then(e=>{r.setLocalDescription(e),this.player.debug.log(this.tagName,"getWebRtcRemoteSdp loadSource"),e=e.sdp,R({url:s,type:"POST",data:e,contentType:"text/plain;charset=utf-8",processData:!1,dataType:"json"}).then(e=>{this.player.debug.log(this.tagName,"getWebRtcRemoteSdp response");e=e.data;if(0!==e.code)return i(e.msg);r.setRemoteDescription(new RTCSessionDescription({type:"answer",sdp:e.sdp})),t()}).catch(e=>{this.player.debug.error(this.tagName,"loadSource getWebRtcRemoteSdp response error",e),i(e)})}).catch(e=>{this.player.debug.error(this.tagName,"loadSource rtcPeerConnection.createOffer() error",e),i(e)})})}}class ms extends e{constructor(e,t){super(),this.player=e,this.player.$container.classList.add("jessibuca-container-playback"),this._showPrecision=null,this._startTime=null,this._playStartTime=null,this._playingTimestamp=null,this._fps=parseInt(t.fps,10)||e._opt.playbackFps,this._isUseFpsRender=!!k(t.isUseFpsRender),this._rate=1,this._audioTimestamp=0,this._videoTimestamp=0,this._currentLocalTimestamp=0,this._localOneFrameTimestamp=t.localOneFrameTimestamp||40,this._localCalculateTimeInterval=null,this._isUseLocalCalculateTime=!!k(t.isUseLocalCalculateTime),this._isPlaybackPauseClearCache=!_(t.isPlaybackPauseClearCache),this._isCacheBeforeDecodeForFpsRender=!!k(t.isCacheBeforeDecodeForFpsRender),this._startfpsTime=null,this._startFpsTimestamp=null,this._checkStatsInterval=null,this._playbackTs=0,this._renderFps=0,this._isUseLocalCalculateTime?this._startLocalCalculateTime():this._listen(),this.playbackList=[],this._totalDuration=0,this.initPlaybackList(t.playList),this.player.on(w.playbackPause,e=>{e?this.pause():this.resume()}),e.debug.log("Playback","init",{fps:this._fps,isUseFpsRender:this._isUseFpsRender,localOneFrameTimestamp:this._localOneFrameTimestamp,isUseLocalCalculateTime:this._isUseLocalCalculateTime,uiUsePlaybackPause:t.uiUsePlaybackPause,showControl:t.showControl})}destroy(){this._startTime=null,this._showPrecision=null,this._playStartTime=null,this._playingTimestamp=null,this._totalDuration=0,this._audioTimestamp=0,this._videoTimestamp=0,this._fps=null,this._isUseFpsRender=!1,this._rate=1,this.playbackList=[],this._localCalculateTimeInterval=null,this._currentLocalTimestamp=0,this._startfpsTime=null,this._startFpsTimestamp=null,this._renderFps=0,this._playbackTs=0,this._stopLocalCalculateTime(),this.clearStatsInterval(),this.player.$container&&this.player.$container.classList.remove("jessibuca-container-playback"),this.off(),this.player.debug.log("Playback","destroy")}_listen(){this.player.on(w.stats,e=>{e=e.ts,this._playStartTime||(this._playStartTime=e),e-=this._playStartTime;this.setPlayingTimestamp(e)})}pause(){this.clearStatsInterval()}resume(){this.startCheckStatsInterval()}updateStats(){var t=0{var e=this._currentLocalTimestamp,e=(this._playStartTime||(this._playStartTime=e),e-this._playStartTime);this.setPlayingTimestamp(e)},1e3)}startCheckStatsInterval(){this.clearStatsInterval(),this._checkStatsInterval=setInterval(()=>{this.updateStats()},1e3)}_stopLocalCalculateTime(){this._localCalculateTimeInterval&&(clearInterval(this._localCalculateTimeInterval),this._localCalculateTimeInterval=null)}clearStatsInterval(){this._checkStatsInterval&&(clearInterval(this._checkStatsInterval),this._checkStatsInterval=null)}increaseLocalTimestamp(){this._isUseLocalCalculateTime&&(this._currentLocalTimestamp+=this._localOneFrameTimestamp)}initPlaybackList(e){this.playbackList=e||[];let i=0;this.playbackList.forEach((e,t)=>{10===_t(e.start)&&(e.startTimestamp=1e3*e.start,e.startTime=dt(e.startTimestamp)),10===_t(e.end)&&(e.endTimestamp=1e3*e.end,e.endTime=dt(e.endTimestamp)),e.duration=e.end-e.start,i+=e.duration}),this._totalDuration=i,this.player.debug.log("Playback",this.playbackList),0{if(e){this.player.$container.classList.add("jessibuca-zoom-control"),this._bindEvents();const e=this.player.video.$videoElement.style.transform;var t=this.player.video.$videoElement.style.left,i=this.player.video.$videoElement.style.top,t=parseFloat(t),i=parseFloat(i),t=(t&&(this.videoPosition.left=t),i&&(this.videoPosition.top=i),(this.prevVideoElementStyleTransform=e).match(/scale\([0-9., ]*\)/g));t&&t[0]&&(i=t[0].replace("scale(","").replace(")",""),this.prevVideoElementStyleScale=i.split(","))}else this.player.$container.classList.remove("jessibuca-zoom-control"),this._unbindEvents(),this._resetVideoPosition(),this.player.$container.style.cursor="auto",this.player.video.$videoElement.style.transform=this.prevVideoElementStyleTransform,this.prevVideoElementStyleTransform=null,this.prevVideoElementStyleScale=null}),t(window,"mouseup",e=>{this.handleMouseUp(e)}),e.debug.log("zoom","init")}destroy(){this.bindEvents=[],this.isDragging=!1,this.currentZoom=1,this.prevVideoElementStyleTransform=null,this.prevVideoElementStyleScale=null,this.tempPosition={x:0,y:0},this.videoPosition={left:0,top:0},this.off(),this.player.debug.log("zoom","destroy")}_bindEvents(){var e=this.player["events"]["proxy"],t=e(this.player.$container,"mousemove",e=>{this.handleMouseMove(e)}),t=(this.bindEvents.push(t),e(this.player.$container,"mousedown",e=>{this.handleMouseDown(e)}));this.bindEvents.push(t)}_unbindEvents(){this.bindEvents.forEach(e=>{e&&e()})}handleMouseMove(e){var t,i,r;e.stopPropagation(),this.isDragging&&this.player.zooming&&({posX:e,posY:t}=xt(e),i=this.tempPosition.x-e,r=this.tempPosition.y-t,this.videoPosition.left=this.videoPosition.left-i,this.videoPosition.top=this.videoPosition.top-r,this.tempPosition.x=e,this.tempPosition.y=t,this.updateVideoPosition())}handleMouseDown(e){e.stopPropagation();const t=S(e);if(this.player.zooming&&(t.matches("video")||t.matches("canvas"))){const{posX:t,posY:i}=xt(e);this.player.$container.style.cursor="grabbing",this.tempPosition.x=t,this.tempPosition.y=i,this.isDragging=!0,this.player.debug.log("zoom","handleMouseDown is dragging true")}}handleMouseUp(e){e.stopPropagation(),this.isDragging&&this.player.zooming&&(this.tempPosition={x:0,y:0},this.isDragging=!1,this.player.$container.style.cursor="grab",this.player.debug.log("zoom","handleMouseUp is dragging false"))}updateVideoPosition(){var e=this.player.video.$videoElement;e.style.left=this.videoPosition.left+"px",e.style.top=this.videoPosition.top+"px"}_resetVideoPosition(){this.player.resize(),this.tempPosition={x:0,y:0},this.videoPosition={left:0,top:0},this.currentZoom=1}narrowPrecision(){this.currentZoom<=1||(--this.currentZoom,this.updateVideoElementScale())}expandPrecision(){5<=this.currentZoom||(this.currentZoom+=1,this.updateVideoElementScale())}updateVideoElementScale(){const e=this.player.video.$videoElement;let t=e.style.transform,i=1,r=1;if(this.prevVideoElementStyleScale){const e=this.prevVideoElementStyleScale[0],t=(void 0!==e&&(i=e,r=e),this.prevVideoElementStyleScale[1]);void 0!==t&&(r=t)}r=T(r);var s=.5*(i=T(i))*(this.currentZoom-1)+i,a=.5*r*(this.currentZoom-1)+r,n=-1===t.indexOf("scale(")?t+` scale(${s},${a})`:t.replace(/scale\([0-9., ]*\)/,`scale(${s},${a})`);this.player.debug.log("zoom",`updateVideoElementScale end is ${s}, ${a} style is `+n),e.style.transform=n}}class ys extends e{constructor(e){super(),this.player=e,this.faceDetector=null,this.objectDetector=null,this.initFaceDetector(),this.initObjectDetector(),this.player.debug.log("AiLoader","init")}initFaceDetector(){if(this.player._opt.useFaceDetector&&window.JessibucaProFaceDetector){const e=new JessibucaProFaceDetector({detectWidth:this.player._opt.aiFaceDetectWidth});e.load().then(()=>{this.player.debug.log("AiLoader","init face detector success"),this.faceDetector=e})}}initObjectDetector(){if(this.player._opt.useObjectDetector&&window.JessibucaProObjectDetector){const e=new JessibucaProObjectDetector({detectWidth:this.player._opt.aiObjectDetectWidth});e.load().then(()=>{this.player.debug.log("AiLoader","init object detector success"),this.objectDetector=e,this.objectDetector.on("jessibuca-pro-object-detector-info",e=>{e&&0{this.addMenuItem(e)}),e(this.player.$container,"contextmenu",e=>{e.preventDefault(),this.show();var t=e.clientX,e=e.clientY,{height:i,width:r,left:s,top:a}=this.player.$container.getBoundingClientRect(),{height:n,width:o}=this.$contextmenus.getBoundingClientRect();let l=t-s,c=e-a;s+r{ls(e,this.$contextmenus)||this.hide()}),this.player.on(w.blur,()=>{this.hide()})}_validateMenuItem(e){let t=!0;return e.content||(this.player.debug.warn(this.LOG_NAME,"content is required"),t=!1),t}addMenuItem(){let t=0 ${t.content} `,(s=Array.from(this.$contextmenus.children)[t.index])?s.insertAdjacentHTML("beforebegin",r):os(this.$contextmenus,r),s=this.$contextmenus.querySelector(".jessibuca-contextmenu-"+i),t.click&&a(s,"click",e=>{e.preventDefault(),t.click.call(this.player,this,e),this.hide()}),this.menuList.push({uuid:i,$menuItem:s}))}}class vs extends e{_opt={};constructor(e){let t=1false"),this._opt.forceNoOffscreen||this.debug.warn("Player","useMSE is true and forceNoOffscreen is false then forceNoOffscreen set false->true"),this._opt.useWCS=!1,this._opt.forceNoOffscreen=!0):this._opt.useWCS,!this._opt.useSIMD&&-1===this._opt.decoder.indexOf("-simd")||(this._opt.useSIMD=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]))&&_(/iphone/i.test(navigator.userAgent)),this._opt.useSIMD)||this.debug.warn("Player","useSIMD is true, but not support so set useSIMD false"),this._opt.useSIMD?-1===this._opt.decoder.indexOf("-simd")&&(this._opt.decoder=this._opt.decoder.replace("decoder-pro","decoder-pro-simd")):-1!==this._opt.decoder.indexOf("-simd")&&(this._opt.decoder=this._opt.decoder.replace("decoder-pro-simd","decoder-pro")),-1!==this._opt.decoder.indexOf("-simd")?this._opt.decoderAudio=this._opt.decoder.replace("decoder-pro-simd","decoder-pro-audio"):this._opt.decoderAudio=this._opt.decoder.replace("decoder-pro","decoder-pro-audio"),_(this._opt.hasAudio)&&(this._opt.operateBtns.audio=!1),_(this._opt.hasVideo)&&(this._opt.operateBtns.fullscreen=!1,this._opt.operateBtns.screenshot=!1,this._opt.operateBtns.record=!1,this._opt.operateBtns.ptz=!1,this._opt.operateBtns.quality=!1,this._opt.operateBtns.zoom=!1),this._opt.qualityConfig&&0===this._opt.qualityConfig.length&&this._opt.operateBtns.quality&&(this._opt.operateBtns.quality=!1,this.debug.warn("Player","_opt.qualityConfig is empty, so set operateBtns.quality false")),k(this._opt.useWebGPU)&&(this._opt.useWebGPU=function(){let e=!1;return e="gpu"in navigator?!0:e}(),_(this._opt.useWebGPU))&&this.debug.warn("Player","useWebGPU is true, but not support so set useWebGPU false"),this._opt.hasControl=this._hasControl(),this._loading=!1,this._playing=!1,this._playbackPause=!1,this._hasLoaded=!1,this._zooming=!1,this._destroyed=!1,this._checkHeartTimeout=null,this._checkLoadingTimeout=null,this._checkStatsInterval=null,this._checkVisibleHiddenTimeout=null,this._startBpsTime=null,this._isPlayingBeforePageHidden=!1,this._stats={buf:0,netBuf:0,fps:0,maxFps:0,dfps:0,abps:0,vbps:0,ts:0,mseTs:0,pTs:0,dts:0},this._allStatsData={},this._faceDetectActive=!1,this._objectDetectActive=!1,this._times={playInitStart:"",playStart:"",streamStart:"",streamResponse:"",demuxStart:"",decodeStart:"",videoStart:"",playTimestamp:"",streamTimestamp:"",streamResponseTimestamp:"",demuxTimestamp:"",decodeTimestamp:"",videoTimestamp:"",allTimestamp:""},this._videoTimestamp=0,this._audioTimestamp=0,this._videoIframeIntervalTs=0,this._streamQuality=this._opt.defaultStreamQuality||"",this._visibility=!0,this._lastestVisibilityChangeTimestamp=null,this._tempWorkerStats=null,this._historyFpsList=[],this._isPlayback()&&(this._opt.useMSE=!1,this._opt.useWCS=!1),_(this._opt.useMSE)&&_(this._opt.useWCS)&&_(this._opt.isWebrtc)&&_(this._opt.isHls)&&(this._opt.useWasm=!0),(this._opt.isHls||this._opt.isWebrtc)&&(this._opt.hasVideo=!0,this._opt.hasAudio=!0),this._opt.hasVideo||(this._opt.useMSE=!1,this._opt.useWCS=!1),this._opt.useWasm&&(this._opt.useOffscreen?this._opt.wasmUseVideoRender=!1:this._opt.wasmUseVideoRender&&(this._opt.wasmUseVideoRender=ut()&&mt()&&At(),this._opt.wasmUseVideoRender||this.debug.warn("Player","use wasm video render, but not support so set wasmUseVideoRender false")),this._opt.useSIMD?this.debug.log("Player","use simd wasm"):this.debug.log("Player","use wasm")),this._opt.useWasm&&(this._opt.useFaceDetector&&window.JessibucaProFaceDetector||this._opt.useObjectDetector&&window.JessibucaProObjectDetector)?(this.ai=new ys(this),this._opt.useFaceDetector&&window.JessibucaProFaceDetector||(this._opt.operateBtns.aiFace=!1),this._opt.useObjectDetector&&window.JessibucaProObjectDetector||(this._opt.operateBtns.aiObject=!1)):(this._opt.operateBtns.aiObject=!1,this._opt.operateBtns.aiFace=!1),!this._opt.useFaceDetector||this._opt.useWasm&&window.JessibucaProFaceDetector||this.debug.warn("Player",`use face detector, useWasm is ${this._opt.useWasm} and window.JessibucaProFaceDetector is `+!!window.JessibucaProFaceDetector),!this._opt.useObjectDetector||this._opt.useWasm&&window.JessibucaProObjectDetector||this.debug.warn("Player",`use object detector, useWasm is ${this._opt.useWasm} and window.JessibucaProObjectDetector is `+!!window.JessibucaProObjectDetector),this._opt.useVideoRender&&(this._opt.useWasm&&!this._opt.useOffscreen?(this._opt.wasmUseVideoRender=ut()&&mt()&&At(),this._opt.wasmUseVideoRender||this.debug.warn("Player","use wasm video render, but not support so set wasmUseVideoRender false")):this._opt.useWCS&&!this._opt.useOffscreen&&(this._opt.wcsUseVideoRender=mt()&&At(),this._opt.wcsUseVideoRender||this.debug.warn("Player","use wcs video render, but not support so set wcsUseVideoRender false"))),this._opt.useCanvasRender&&(this._opt.useMSE&&(this._opt.mseUseCanvasRender=!0),this._opt.useWasm&&(this._opt.wasmUseVideoRender=!1),this._opt.useWCS&&(this._opt.wcsUseVideoRender=!1),this._opt.isHls)&&!ct()&&(this._opt.hlsUseCanvasRender=!0),this._opt.useVideoRender=!1,this._opt.useCanvasRender=!1,this._opt.useWasm?this._opt.wasmUseVideoRender?this._opt.useVideoRender=!0:this._opt.useCanvasRender=!0:this._opt.useWCS?this._opt.wcsUseVideoRender?this._opt.useVideoRender=!0:this._opt.useCanvasRender=!0:this._opt.useMSE?this._opt.mseUseCanvasRender?this._opt.useCanvasRender=!0:this._opt.useVideoRender=!0:this._opt.isHls?this._opt.hlsUseCanvasRender?this._opt.useCanvasRender=!0:this._opt.useVideoRender=!0:this._opt.isWebrtc&&(this._opt.useVideoRender=!0),i=this,Object.defineProperty(i,"rect",{get:()=>{var e=i.$container.getBoundingClientRect();return e.width=Math.max(e.width,i.$container.clientWidth),e.height=Math.max(e.height,i.$container.clientHeight),e}}),["bottom","height","left","right","top","width"].forEach(e=>{Object.defineProperty(i,e,{get:()=>i.rect[e]})}),this.events=new Gt(this),this._opt.hasVideo&&(this.video=new oi(this),this.recorder=new $i(this)),this._opt.isHls?(this.hlsDecoder=new ps(this),this.loaded=!0):this._opt.isWebrtc?(this._opt.isWebrtcForZLM?this.webrtc=new gs(this):this.webrtc=new fs(this),this.loaded=!0):Dt(this._opt)?this.loaded=!0:this.decoderWorker=new Ki(this),this._opt.hasAudio&&(this.audio=new Si(this)),this.stream=null,this.demux=null,this._lastVolume=null,this._isInZoom=!1,this._playingStartTimestamp=null,this._opt.useWCS&&(this.webcodecsDecoder=new es(this),this._opt.hasAudio||(this.loaded=!0)),this._opt.useMSE&&(this.mseDecoder=new ds(this),this._opt.hasAudio||(this.loaded=!0)),this.control=new cs(this),0{S(e)===r.$container&&(r.emit(d.fullscreen,r.fullscreen),!r.fullscreen||r._opt.useMSE)&&r.resize()};f.on("change",a),r.events.destroys.push(()=>{f.off("change",a)})}catch(r){}if(r.on(w.decoderWorkerInit,()=>{r.debug.log("player","listen decoderWorkerInit and set loaded true"),r.loaded=!0}),r.on(w.play,()=>{r.loading=!1}),r.on(w.fullscreen,e=>{if(e)try{f.request(r.$container).then(()=>{}).catch(e=>{r.debug.error("player","fullscreen request error",e),g()&&r._opt.useWebFullScreen&&(r.webFullscreen=!0)})}catch(e){g()&&r._opt.useWebFullScreen&&(r.webFullscreen=!0)}else try{f.exit().then(()=>{r.webFullscreen&&(r.webFullscreen=!1)}).catch(e=>{r.debug.error("player","fullscreen exit error",e),r.webFullscreen&&(r.webFullscreen=!1)})}catch(e){r.webFullscreen&&(r.webFullscreen=!1)}}),g()&&r.on(w.webFullscreen,e=>{e?r.$container.classList.add("jessibuca-fullscreen-web"):r.$container.classList.remove("jessibuca-fullscreen-web"),r.emit(d.fullscreen,r.fullscreen)}),r.on(w.resize,()=>{r.video&&r.video.resize()}),r._opt.debug){const n=[w.timeUpdate];Object.keys(w).forEach(t=>{r.on(w[t],e=>{n.includes(t)||r.debug.log("player events",w[t],e)})}),Object.keys(m).forEach(t=>{r.on(m[t],e=>{r.debug.warn("player event error",m[t],e)})})}{var s=this;const{_opt:o,debug:l,events:{proxy:c}}=s;if(o.supportDblclickFullscreen&&c(s.$container,"dblclick",e=>{e=S(e).nodeName.toLowerCase();"canvas"!==e&&"video"!==e||(s.fullscreen=!s.fullscreen)}),c(document,"visibilitychange",()=>{s.visibility="visible"===document.visibilityState,l.log("visibilitychange",document.visibilityState),o.hiddenAutoPause&&(l.log("visibilitychange","hiddenAutoPause is true ",document.visibilityState,s._isPlayingBeforePageHidden),"visible"===document.visibilityState?s._isPlayingBeforePageHidden&&s.play():(s._isPlayingBeforePageHidden=s.playing,s.playing&&s.pause()))}),c(document,["click","contextmenu"],e=>{ls(e,s.$container)?(s.isInput="INPUT"===e.target.tagName,s.isFocus=!0,s.emit(w.focus)):(s.isInput=!1,s.isFocus=!1,s.emit(w.blur))}),o.autoResize){const o=pt(()=>{s.resize()},500);c(window,["resize","orientationchange"],()=>{o()}),screen&&screen.orientation&&screen.orientation.onchange&&c(screen.orientation,"change",()=>{o()})}}this.singleWatermark=new si(this),this._opt.watermarkConfig&&this.updateWatermark(this._opt.watermarkConfig),this._opt.useWCS&&this.debug.log("Player","use WCS"),this._opt.useMSE&&this.debug.log("Player","use MSE"),this._opt.useOffscreen&&this.debug.log("Player","use offscreen"),this._opt.isHls&&this.debug.log("Player","use hls"),this._opt.isWebrtc&&this.debug.log("Player","use webrtc"),this._isPlayback()&&this.debug.log("Player","use playback"),this._opt.hasVideo&&(0===this.width&&this.debug.warn("Player","container width is 0, please check the container width"),0===this.height)&&this.debug.warn("Player","container height is 0, please check the container height"),this.debug.log("Player options",JSON.stringify(this._opt))}destroy(){return new Promise((e,t)=>{this._destroyed=!0,this.emit("destroy"),this.off(),this.events&&(this.events.destroy(),this.events=null),this.clearCheckHeartTimeout(),this.clearCheckLoadingTimeout(),this.clearStatsInterval(),this.clearVisibilityHiddenTimeout(),this.decoderWorker?this.decoderWorker.destroy().then(()=>{this.decoderWorker=null,this._destroy(),e()}):(this._destroy(),e())})}_destroy(){this._loading=!1,this._playing=!1,this._playbackPause=!1,this._hasLoaded=!1,this._lastVolume=null,this._zooming=!1,this._faceDetectActive=!1,this._objectDetectActive=!1,this._times={playInitStart:"",playStart:"",streamStart:"",streamResponse:"",demuxStart:"",decodeStart:"",videoStart:"",playTimestamp:"",streamTimestamp:"",streamResponseTimestamp:"",demuxTimestamp:"",decodeTimestamp:"",videoTimestamp:"",allTimestamp:""},this.singleWatermark&&(this.singleWatermark.destroy(),this.singleWatermark=null),this.mseDecoder&&(this.mseDecoder.destroy(),this.mseDecoder=null),this.video&&(this.video.destroy(),this.video=null),this.audio&&(this.audio.destroy(),this.audio=null),this.stream&&(this.stream.destroy(),this.stream=null),this.recorder&&(this.recorder.destroy(),this.recorder=null),this.control&&(this.control.destroy(),this.control=null),this.webcodecsDecoder&&(this.webcodecsDecoder.destroy(),this.webcodecsDecoder=null),this.demux&&(this.demux.destroy(),this.demux=null),this.hlsDecoder&&(this.hlsDecoder.destroy(),this.hlsDecoder=null),this.playback&&(this.playback.destroy(),this.playback=null),this.zoom&&(this.zoom.destroy(),this.zoom=null),this.ai&&(this.ai.destroy(),this.ai=null),this.keepScreenOn&&(this.releaseWakeLock(),this.keepScreenOn.destroy(),this.keepScreenOn=null),this.resetStats(),this._audioTimestamp=0,this._videoTimestamp=0,this._streamQuality="",this._visibility=!0,this._isInZoom=!1,this._playingStartTimestamp=null,this._lastestVisibilityChangeTimestamp=null,this._videoIframeIntervalTs=null,this._tempWorkerStats=null,this.debug.log("play","destroy end"),this._opt=jt(),this.$container=null}set fullscreen(e){g()&&this._opt.useWebFullScreen?(this.emit(w.webFullscreen,e),setTimeout(()=>{this.updateOption({rotate:e?270:0}),this.resize()},10)):this.emit(w.fullscreen,e)}get fullscreen(){return f.isFullscreen||this.webFullscreen}set webFullscreen(e){this.emit(w.webFullscreen,e)}get webFullscreen(){return this.$container.classList.contains("jessibuca-fullscreen-web")}set loaded(e){this._hasLoaded=e}get loaded(){return this._hasLoaded||this._opt.isHls||this._opt.isWebrtc||this._opt.useMSE&&!this._opt.hasAudio||this._opt.useWCS&&!this._opt.hasAudio}set playing(e){e&&(this.loading=!1),this.playing!==e&&(this._playing=e,this.emit(w.playing,e),this.emit(w.volumechange,this.volume),e?this.emit(w.play):this.emit(w.pause))}get playing(){return this._playing}get volume(){return this.audio&&this.audio.volume||0}set volume(e){e!==this.volume&&(this.audio?(this.audio.setVolume(e),this._lastVolume=this.volume):this.debug.error("Player","set volume error, audio is null"))}get lastVolume(){return this._lastVolume}set loading(e){this.loading!==e&&(this._loading=e,this.emit(w.loading,this._loading))}get loading(){return this._loading}set zooming(e){this.zooming!==e&&(this.zoom||(this.zoom=new As(this)),this._zooming=e,this.emit(w.zooming,this.zooming))}get zooming(){return this._zooming}set recording(e){e?this.playing&&!this.recording&&(this.recorder&&this.recorder.startRecord(),this._opt.useWasm)&&this.decoderWorker.updateWorkConfig({key:"isRecording",value:!0}):this.recording&&(this._opt.useWasm&&this.decoderWorker.updateWorkConfig({key:"isRecording",value:!1}),this.recorder)&&this.recorder.stopRecordAndSave().then(()=>{}).catch(e=>{})}get recording(){return!!this.recorder&&this.recorder.isRecording}set audioTimestamp(e){null!==e&&(this._audioTimestamp=e)}get audioTimestamp(){return this._audioTimestamp}set videoTimestamp(e){null!==e&&(this._videoTimestamp=e,this._opt.useWCS||this._opt.useMSE||this.audioTimestamp&&this.videoTimestamp&&this.audio&&this.audio.emit(w.videoSyncAudio,{audioTimestamp:this.audioTimestamp,videoTimestamp:this.videoTimestamp,diff:this.audioTimestamp-this.videoTimestamp}))}set streamQuality(e){this.streamQuality!==e&&(this._streamQuality=e,this.emit(w.streamQualityChange,e))}get streamQuality(){return this._streamQuality}get videoTimestamp(){return this._videoTimestamp}get isDebug(){return k(this._opt.debug)}get scaleType(){var e=this._opt,t=e.isResize,e=e.isFullResize;let i=0;return _(e)&&_(t)?i=0:_(e)&&k(t)?i=1:k(e)&&k(t)&&(i=2),i}set visibility(e){this._visibility!==e&&(this._visibility=e,this.emit(w.visibilityChange,e),this._lastestVisibilityChangeTimestamp=A(),e?this.clearVisibilityHiddenTimeout():this.startVisibilityHiddenTimeout())}get visibility(){return this._visibility}set playbackPause(e){this._playbackPause!==e&&(this._playbackPause=e,this.emit(w.playbackPause,e),this.emit(w.playbackPauseOrResume,e))}get playbackPause(){return this._playbackPause}set videoIframeIntervalTs(e){this._videoIframeIntervalTs=e}get videoIframeIntervalTs(){return this._videoIframeIntervalTs}set faceDetectActive(e){this._faceDetectActive!==e&&(this._faceDetectActive=e,this.emit(w.faceDetectActive,e))}get faceDetectActive(){return this._faceDetectActive}set objectDetectActive(e){this._objectDetectActive!==e&&(this._objectDetectActive=e,this.emit(w.objectDetectActive,e))}get objectDetectActive(){return this._objectDetectActive}get isUseWorkerDemuxAndDecode(){return this.stream&&this.stream.getStreamType()===j}isDestroyed(){return this._destroyed}updateOption(e){this._opt=Object.assign({},this._opt,e)}init(){return new Promise((e,t)=>{this.video||this._opt.hasVideo&&(this.video=new oi(this)),this.audio||this._opt.hasAudio&&(this.audio=new Si(this)),this.stream||(this.stream=new Di(this)),this._opt.isHls?(this.hlsDecoder||(this.hlsDecoder=new ps(this),this.loaded=!0),e()):this._opt.isWebrtc?(this.webrtc||(this._opt.isWebrtcForZLM?this.webrtc=new gs(this):this.webrtc=new fs(this),this.loaded=!0),e()):(this.demux||this._opt.hasVideo&&!this.isUseWorkerDemuxAndDecode&&(this.demux=new Zr(this)),this._opt.useWCS&&!this.webcodecsDecoder&&(this.webcodecsDecoder=new es(this)),this._opt.useMSE&&!this.mseDecoder&&(this.mseDecoder=new ds(this)),this.decoderWorker?this.loaded?e():this.once(w.decoderWorkerInit,()=>{this.loaded=!0,e()}):Dt(this._opt)?e():(this.decoderWorker=new Ki(this),this.once(w.decoderWorkerInit,()=>{this.loaded=!0,e()})))})}play(i,r){return new Promise((e,t)=>{if(!i&&!this._opt.url)return t("url is empty");this.loading=!0,this.playing=!1,this._times.playInitStart=A(),i=i||this._opt.url,this._opt.url=i,this.clearCheckHeartTimeout(),this.init().then(()=>{this._times.playStart=A(),this._opt.isNotMute&&this.mute(!1),this.webcodecsDecoder&&this.webcodecsDecoder.once(m.webcodecsH265NotSupport,()=>{this.emitError(m.webcodecsH265NotSupport)}),this.mseDecoder&&(this.mseDecoder.once(m.mediaSourceH265NotSupport,()=>{this.emitError(m.mediaSourceH265NotSupport)}),this.mseDecoder.once(m.mediaSourceFull,()=>{this.emitError(m.mediaSourceFull)}),this.mseDecoder.once(m.mediaSourceAppendBufferError,()=>{this.emitError(m.mediaSourceAppendBufferError)}),this.mseDecoder.once(m.mediaSourceBufferListLarge,()=>{this.emitError(m.mediaSourceBufferListLarge)}),this.mseDecoder.once(m.mediaSourceAppendBufferEndTimeout,()=>{this.emitError(m.mediaSourceAppendBufferEndTimeout)}),this.mseDecoder.once(m.mediaSourceDecoderConfigurationError,()=>{this.emitError(m.mediaSourceDecoderConfigurationError)}),this.mseDecoder.once(m.mediaSourceTsIsMaxDiff,()=>{this.emitError(m.mediaSourceTsIsMaxDiff)})),this.enableWakeLock(),this.checkLoadingTimeout(),this.stream?(this.stream.once(m.fetchError,e=>{this.emitError(m.fetchError,e)}),this.stream.once(m.websocketError,e=>{this.emitError(m.websocketError,e)}),this.stream.once(w.streamEnd,()=>{this.emit(w.streamEnd)}),this.stream.once(m.hlsError,e=>{this.emitError(m.hlsError,e)}),this.stream.once(m.webrtcError,e=>{this.emitError(m.webrtcError,e)}),this.stream.once(w.streamSuccess,()=>{e(),this._times.streamResponse=A(),this.video&&this.video.play(),this.checkStatsInterval(),this.isPlayback()&&this.playback&&this.playback.startCheckStatsInterval()}),this.stream.fetchStream(i,r)):this.debug.warn("player","play() this.stream is null")}).catch(e=>{t(e)})})}close(){return new Promise((e,t)=>{this._close().then(()=>{this.video&&this.video.clearView(),e()}).catch(e=>{t(e)})})}resumeAudioAfterPause(){this.lastVolume&&(this.volume=this.lastVolume)}_close(){return new Promise((e,t)=>{const i=()=>{this.stream&&(this.stream.destroy(),this.stream=null),this.demux&&(this.demux.destroy(),this.demux=null),this.webcodecsDecoder&&(this.webcodecsDecoder.destroy(),this.webcodecsDecoder=null),this.mseDecoder&&(this.mseDecoder.destroy(),this.mseDecoder=null),this.hlsDecoder&&(this.hlsDecoder.destroy(),this.hlsDecoder=null),this.webrtc&&(this.webrtc.destroy(),this.webrtc=null),this.audio&&(this.audio.destroy(),this.audio=null),this.clearCheckHeartTimeout(),this.clearCheckLoadingTimeout(),this.clearStatsInterval(),this.isPlayback()&&this.playback&&this.playback.clearStatsInterval(),this.loading=!1,this.recording=!1,this.zooming=!1,this.playing=!1,this.video&&(this.video.resetInit(),this.video.pause(!0)),this.releaseWakeLock(),this.resetStats(),this._audioTimestamp=0,this._videoTimestamp=0,this._times={playInitStart:"",playStart:"",streamStart:"",streamResponse:"",demuxStart:"",decodeStart:"",videoStart:"",playTimestamp:"",streamTimestamp:"",streamResponseTimestamp:"",demuxTimestamp:"",decodeTimestamp:"",videoTimestamp:"",allTimestamp:""}};this.decoderWorker?this.decoderWorker.destroy().then(()=>{this.decoderWorker=null,i(),setTimeout(()=>{e()},0)}).catch(e=>{this.debug&&this.debug.error("player","close() decoderWorker.destroy() error",e),t()}):(i(),setTimeout(()=>{e()},0))})}pause(){let i=0{i?this.close().then(()=>{e()}).catch(e=>{t(e)}):this._close().then(()=>{e()}).catch(e=>{t(e)})})}isAudioMute(){let e=!0;return e=this.audio?this.audio.isMute:e}isAudioNotMute(){return!this.isAudioMute()}mute(e){this.audio&&this.audio.mute(e)}resize(){this.video&&this.video.resize()}startRecord(e,t){this.recording||(this.recorder.setFileName(e,t),this.recording=!0)}stopRecordAndSave(e,r){return new Promise((t,i)=>{this.recorder||i("recorder is null"),this.recording?(this._opt.useWasm&&this.decoderWorker.updateWorkConfig({key:"isRecording",value:!0}),this.recorder.stopRecordAndSave(e,r).then(e=>{t(e)}).catch(e=>{i(e)})):i("recorder is not recording")})}_hasControl(){let e=!1,t=!1;return Object.keys(this._opt.operateBtns).forEach(e=>{this._opt.operateBtns[e]&&-1===(""+e).indexOf("Fn")&&(t=!0)}),(this._opt.showBandwidth||t)&&(e=!0),e=this._isPlayback()&&this._opt.playbackConfig.showControl?!0:e}_isPlayback(){return this._opt.playType===v}useWasmDecode(){return _(this._opt.useMSE)&&_(this._opt.useWCS)}canVideoTrackWritter(){var e=this._opt;return _(e.isHls)&&_(e.isWebrtc)&&_(e.useMSE)&&(e.useWCS&&_(e.useOffscreen)&&e.wcsUseVideoRender||this.useWasmDecode())}checkHeart(){this.clearCheckHeartTimeout(),this.checkHeartTimeout()}checkHeartTimeout(){this._checkHeartTimeout=setTimeout(()=>{_(this.playbackPause)&&this.playing?this.isDestroyed()?this.debug&&this.debug.warn("player","checkHeartTimeout but player is destroyed"):0!==this._stats.fps?this.debug&&this.debug.warn("player","checkHeartTimeout but fps is "+this._stats.fps):_(this.visibility)&&0!==this._stats.vbps?this.debug&&this.debug.warn("player","checkHeartTimeout but page is not visibility and vbps is "+this._stats.vbps):(this.debug.warn("player",`checkHeartTimeout and pause and emit delayTimeout event and current vbps is ${this._stats.vbps} and current fps is ${this._stats.fps} and current visibility is ${this.visibility} and`),this.emit(w.timeout,w.delayTimeout),this.emit(w.delayTimeout)):this.debug.warn("player",`playbackPause is ${this.playbackPause}, playing is `+this.playing)},1e3*this._opt.heartTimeout)}checkHeartTimeout$2(){var e;_(this.playbackPause)&&this.playing?this.isDestroyed()?this.debug&&this.debug.warn("player","checkHeartTimeout$2 but player is destroyed"):_(this.isHistoryFpsListAllZero())?this.debug&&this.debug.warn("player","checkHeartTimeout$2 but fps is not all zero"):0!==this._stats.fps?this.debug&&this.debug.warn("player","checkHeartTimeout$2 but fps is "+this._stats.fps):_(this.visibility)&&0!==this._stats.vbps?this.debug&&this.debug.warn("player","checkHeartTimeout$2 but page is not visibility and vbps is "+this._stats.vbps):(e=this._historyFpsList.join(","),this.debug.warn("player",`checkHeartTimeout$2 and pause and emit delayTimeout event and current vbps is ${this._stats.vbps} and current fps is ${this._stats.fps} and history FpsList is ${e} and current visibility is ${this.visibility} and`),this.emit(w.timeout,w.delayTimeout),this.emit(w.delayTimeout)):this.debug.log("player",`checkHeartTimeout$2 playbackPause is ${this.playbackPause}, playing is `+this.playing)}checkStatsInterval(){this._checkStatsInterval=setInterval(()=>{this.updateStats()},1e3)}clearCheckHeartTimeout(){this._checkHeartTimeout&&(clearTimeout(this._checkHeartTimeout),this._checkHeartTimeout=null)}checkLoadingTimeout(){this._checkLoadingTimeout=setTimeout(()=>{this.playing?this.debug.warn("player",`checkLoadingTimeout but loading is ${this.loading} and playing is `+this.playing):this.isDestroyed()?this.debug&&this.debug.warn("player","checkLoadingTimeout but player is destroyed"):(this.debug.warn("player","checkLoadingTimeout and pause and emit loadingTimeout event"),this.emit(w.timeout,w.loadingTimeout),this.emit(w.loadingTimeout))},1e3*this._opt.loadingTimeout)}clearCheckLoadingTimeout(){this._checkLoadingTimeout&&(this.debug.log("player","clearCheckLoadingTimeout"),clearTimeout(this._checkLoadingTimeout),this._checkLoadingTimeout=null)}clearStatsInterval(){this._checkStatsInterval&&(clearInterval(this._checkStatsInterval),this._checkStatsInterval=null)}handleRender(){this.isDestroyed()?this.debug&&this.debug.warn("player","handleRender but player is destroyed"):(this.loading&&(this.clearCheckLoadingTimeout(),this.emit(w.start),this.loading=!1),this.playing||(this.playing=!0))}updateStats(){var p=0this._stats.maxFps&&(this._stats.maxFps=this._stats.fps),this._allStatsData=Object.assign(this._stats,{audioBuffer:c,audioBufferDelayTs:d,audioTs:this.audioTimestamp,playbackVideoBuffer:u,playbackVideoWaitingBuffer:0,playbackAudioWaitingBuffer:0,playbackCacheDataDuration:h,demuxBuffer:s,pushLatestDelay:l,audioDemuxBuffer:a,flvBuffer:r,mseDelay:e,mseDecodeDiffTimes:t,mseDecodePlaybackRate:i,wcsDecodeDiffTimes:t,hlsDelay:e,hlsDecodePlaybackRate:i,delayTs:p,totalDelayTs:g,isDropping:n,isStreamTsMoreThanLocal:o}),this.emit(w.stats,this._allStatsData),1048576{this.emit(w.visibilityHiddenTimeout)},1e3*this._opt.pageVisibilityHiddenTimeout))}clearVisibilityHiddenTimeout(){this._checkVisibleHiddenTimeout&&(clearTimeout(this._checkVisibleHiddenTimeout),this._checkVisibleHiddenTimeout=null)}faceDetect(e){this.faceDetectActive=e}objectDetect(e){this.objectDetectActive=e}downloadNakedFlowFile(){this.demux&&this.demux.downloadNakedFlowFile&&this.demux.downloadNakedFlowFile()}hasCacheOnGopBuffer(){var e=this.videoIframeIntervalTs,t=this._allStatsData.demuxBuffer,i=this._allStatsData.maxFps;let r=e&&t&&i?e<1e3/i*t:!1;return r}addContentToCanvas(){this.video&&this.video.addContentToCanvas(0this._opt.heartTimeout&&this._historyFpsList.shift(),this._historyFpsList.push(e),this.isHistoryFpsListAllZero()&&this.checkHeartTimeout$2()}isHistoryFpsListAllZero(){let t=!0;if(t=this._historyFpsList.lengthe,this.ratioWeight=1):(this.fromSampleRate{let t,i,r,s,a,n,o,l,c,d=e.length,u=this.channels;if(d%u!=0)throw new Error("Buffer was of incorrect sample length.");if(d<=0)return[];for(t=this.outputBufferSize,i=this.ratioWeight,r=this.lastWeight,s=0,a=0,n=0,o=0,l=this.outputBuffer;r<1;r+=i)for(a=r%1,s=1-a,this.lastWeight=r%1,c=0;c{let t,i,r,s,a,n,o,l,c,d,u,h=e.length,p=this.channels;if(h%p!=0)throw new Error("Buffer was of incorrect sample length.");if(h<=0)return[];for(t=this.outputBufferSize,i=[],r=this.ratioWeight,s=0,n=0,l=!this.tailExists,this.tailExists=!1,c=this.outputBuffer,d=0,u=0,a=0;a=o)){for(a=0;a{e.stop()}),this.userMediaStream=null),this.mediaStreamSource&&(this.mediaStreamSource.disconnect(),this.mediaStreamSource=null),this.recorder&&(this.recorder.disconnect(),this.recorder.onaudioprocess=null),this.biquadFilter&&(this.biquadFilter.disconnect(),this.biquadFilter=null),this.gainNode&&(this.gainNode.disconnect(),this.gainNode=null),this.workletRecorder&&(this.workletRecorder.disconnect(),this.workletRecorder=null),this.socket&&(this.socketStatus===le&&this._sendClose(),this.socket.close(),this.socket=null),this._stopHeartInterval(),this._stopCheckGetUserMediaTimeout(),this.audioContext=null,this.gainNode=null,this.recorder=null,this.audioBufferList=[],this.sequenceId=0,this.wsUrl=null,this.tempTimestamp=null,this.tempRtpBufferList=[],this.startTimestamp=0,this.log("talk","destroy")}addRtpToBuffer(e){var t=e.length+this.tempRtpBufferList.length,t=new Uint8Array(t);t.set(this.tempRtpBufferList,0),t.set(e,this.tempRtpBufferList.length),this.tempRtpBufferList=t}downloadRtpFile(){var e=new Blob([this.tempRtpBufferList]);try{var t=document.createElement("a");t.href=window.URL.createObjectURL(e),t.download=Date.now()+".rtp",t.click()}catch(e){console.error("downloadRtpFile",e)}}calcAudioBufferLength(){var e=this._opt["sampleRate"];return 8*e*.02/8}get socketStatusOpen(){return this.socketStatus===le}log(){for(var e=arguments.length,t=new Array(e),i=0;i{var i=this.events.proxy;this.socket=new WebSocket(this.wsUrl),this.socket.binaryType="arraybuffer",this.emit(w.talkStreamStart),i(this.socket,"open",()=>{this.socketStatus=le,this.log(this.tag,"websocket open -> do talk"),this.emit(w.talkStreamOpen),e(),this._doTalk()}),i(this.socket,"message",e=>{this.log(this.tag,"websocket message",e.data)}),i(this.socket,"close",e=>{this.socketStatus="close",this.log(this.tag,"websocket close"),this.emit(w.talkStreamClose),t(e)}),i(this.socket,"error",e=>{this.socketStatus="error",this.error(this.tag,"websocket error",e),this.emit(w.talkStreamError,e),t(e)})})}_sendClose(){}_initTalk(){this._initMethods(),this._opt.engine===Ne?this._initWorklet():"script"===this._opt.engine&&this._initScriptProcessor(),this.log(this.tag,"audioContext samplerate",this.audioContext.sampleRate)}_initMethods(){this.audioContext=new(window.AudioContext||window.webkitAudioContext)({sampleRate:48e3}),this.gainNode=this.audioContext.createGain(),this.gainNode.gain.value=1,this.biquadFilter=this.audioContext.createBiquadFilter(),this.biquadFilter.type="lowpass",this.biquadFilter.frequency.value=3e3,this.resampler=new ws({fromSampleRate:this.audioContext.sampleRate,toSampleRate:this._opt.sampleRate,channels:this._opt.numberChannels,inputBufferSize:this.bufferSize})}_initScriptProcessor(){var e=this.audioContext.createScriptProcessor||this.audioContext.createJavaScriptNode;this.recorder=e.apply(this.audioContext,[this.bufferSize,this._opt.numberChannels,this._opt.numberChannels]),this.recorder.onaudioprocess=e=>this._onaudioprocess(e)}_initWorklet(){this.audioContext.audioWorklet.addModule(It(function(){class e extends AudioWorkletProcessor{constructor(e){super(),this._cursor=0,this._bufferSize=e.processorOptions.bufferSize,this._buffer=new Float32Array(this._bufferSize)}process(t,e,i){if(t.length&&t[0].length)for(let e=0;e{var e=new AudioWorkletNode(this.audioContext,"talk-processor",{processorOptions:{bufferSize:this.bufferSize}});e.connect(this.gainNode),e.port.onmessage=e=>{"data"===e.data.eventType&&this._encodeAudioData(e.data.buffer)},this.workletRecorder=e})}_onaudioprocess(e){e=e.inputBuffer.getChannelData(0);this._encodeAudioData(new Float32Array(e))}_encodeAudioData(e){if(0===e[0]&&0===e[1])this.log(this.tag,"empty audio data");else{const r=this.resampler.resample(e);let t=r;if(16===this._opt.sampleBitsWidth?t=function(e){let t=e.length,i=new Int16Array(t);for(;t--;){var r=Math.max(-1,Math.min(1,e[t]));i[t]=r<0?32768*r:32767*r}return i}(r):8===this._opt.sampleBitsWidth&&(t=function(e){let t=e.length,i=new Int8Array(t);for(;t--;){var r=Math.max(-1,Math.min(1,e[t]));i[t]=parseInt(255/(65535/(32768+(r<0?32768*r:32767*r))),10)}return i}(r)),null!==t.buffer){let e=null;this._opt.encType===De?e=function(e){const i=[];return Array.prototype.slice.call(e).forEach((e,t)=>{i[t]=function(e){let t,i,r;return 0<=e?t=213:(t=85,(e=-e-1)<0&&(e=32767)),8<=(i=Ts(e,Es,8))?127^t:(r=i<<4,(r|=i<2?e>>4&15:e>>i+3&15)^t)}(e)}),i}(t):this._opt.encType===Ie&&(e=function(e){const i=[];return Array.prototype.slice.call(e).forEach((e,t)=>{i[t]=function(e){let t=0;t=e<0?(e=132-e,127):(e+=132,255);var i=Ts(e,Es,8);return 8<=i?127^t:(i<<4|e>>i+3&15)^t}(e)}),i}(t));const r=Uint8Array.from(e);for(let e=0;e>8,t[1]=255&n>>0,t[2]=128,t[3]=128+i,t[4]=r/256,t[5]=r%256,t[6]=s/65536/256,t[7]=s/65536%256,t[8]=s%65536/256,t[9]=s%65536%256,t[10]=a/65536/256,t[11]=a/65536%256,t[12]=a%65536/256,t[13]=a%65536%256,t.concat([...e])),l=new Uint8Array(o.length);for(let e=0;e{this.log(this.tag,"getUserMedia success"),this.userMediaStream=e,this.mediaStreamSource=this.audioContext.createMediaStreamSource(e),this.mediaStreamSource.connect(this.biquadFilter),this.recorder?(this.biquadFilter.connect(this.recorder),this.recorder.connect(this.gainNode)):this.workletRecorder&&(this.biquadFilter.connect(this.workletRecorder),this.workletRecorder.connect(this.gainNode)),this.gainNode.connect(this.audioContext.destination),this.emit(w.talkGetUserMediaSuccess),null===e.oninactive&&(e.oninactive=e=>{this._handleStreamInactive(e)})}).catch(e=>{this.error(this.tag,"getUserMedia error",e.toString()),this.emit(w.talkGetUserMediaFail,e.toString())}).finally(()=>{this.log(this.tag,"getUserMedia finally"),this._stopCheckGetUserMediaTimeout()})}_getUserMedia2(){this.log(this.tag,"getUserMedia"),navigator.mediaDevices?navigator.mediaDevices.getUserMedia({audio:!0}).then(e=>{this.log(this.tag,"getUserMedia2 success")}):navigator.getUserMedia({audio:!0},this.log(this.tag,"getUserMedia2 success"),this.log(this.tag,"getUserMedia2 fail"))}async _getUserMedia3(){this.log(this.tag,"getUserMedia3");try{var e=await navigator.mediaDevices.getUserMedia({audio:{latency:!0,noiseSuppression:!0,autoGainControl:!0,echoCancellation:!0,sampleRate:48e3,channelCount:1},video:!1});console.log("getUserMedia() got stream:",e),this.log(this.tag,"getUserMedia3 success")}catch(e){this.log(this.tag,"getUserMedia3 fail")}}_handleStreamInactive(e){this.userMediaStream&&(this.error(this.tag,"stream oninactive"),this.emit(w.talkStreamInactive))}_startCheckGetUserMediaTimeout(){this._stopCheckGetUserMediaTimeout(),this.checkGetUserMediaTimeout=setTimeout(()=>{this.log(this.tag,"check getUserMedia timeout"),this.emit(w.talkGetUserMediaTimeout)},this._opt.getUserMediaTimeout)}_stopCheckGetUserMediaTimeout(){this.checkGetUserMediaTimeout&&(this.log(this.tag,"stop checkGetUserMediaTimeout"),clearTimeout(this.checkGetUserMediaTimeout),this.checkGetUserMediaTimeout=null)}_startHeartInterval(){this.heartInterval=setInterval(()=>{this.log(this.tag,"heart interval");var e=[35,36,0,0,0,0,0,0],e=new Uint8Array(e);this.socket.send(e.buffer)},15e3)}_stopHeartInterval(){this.heartInterval&&(this.log(this.tag,"stop heart interval"),clearInterval(this.heartInterval),this.heartInterval=null)}startTalk(i){return new Promise((e,t)=>function(){let e=!1;var t=window.navigator;return e=t?(e=!(!t.mediaDevices||!t.mediaDevices.getUserMedia))||!!(t.getUserMedia||t.webkitGetUserMedia||t.mozGetUserMedia||t.msGetUserMedia):e}()?(this.wsUrl=i,this._opt.testMicrophone?(this._doTalk(),e()):(this._createWebSocket().catch(e=>{t(e)}),this.once(w.talkGetUserMediaFail,()=>{t("getUserMedia fail")}),void this.once(w.talkGetUserMediaSuccess,()=>{e()}))):t("not support getUserMedia"))}setVolume(e){e=parseFloat(e).toFixed(2),isNaN(e)||(e=y(e,0,1),this.gainNode.gain.value=e)}getOption(){return this._opt}get volume(){return this.gainNode?parseFloat(100*this.gainNode.gain.value).toFixed(0):null}}class ks{constructor(e){this.player=e,this.globalSetting=null;e=ht();this.defaultSettings={watermark_id:"JessibucaPro_"+e,watermark_prefix:"JessibucaPro_mask_"+e,watermark_txt:"JessibucaPro 测试水印",watermark_x:0,watermark_y:0,watermark_rows:0,watermark_cols:0,watermark_x_space:0,watermark_y_space:0,watermark_font:"微软雅黑",watermark_color:"black",watermark_fontsize:"18px",watermark_alpha:.15,watermark_width:150,watermark_height:100,watermark_angle:15,watermark_parent_width:0,watermark_parent_height:0,watermark_parent_node:null},this.player.debug.log("Watermark","int")}destroy(){this._removeMark(),this.globalSetting=null,this.defaultSettings={watermark_id:"",watermark_prefix:"",watermark_txt:"JessibucaPro 测试水印",watermark_x:0,watermark_y:0,watermark_rows:0,watermark_cols:0,watermark_x_space:0,watermark_y_space:0,watermark_font:"微软雅黑",watermark_color:"black",watermark_fontsize:"18px",watermark_alpha:.15,watermark_width:150,watermark_height:100,watermark_angle:15,watermark_parent_width:0,watermark_parent_height:0,watermark_parent_node:null},this.player.debug.log("Watermark","destroy")}remove(){this._removeMark()}load(e){this.globalSetting=e,this._loadMark(e)}resize(){this.globalSetting&&this._loadMark(this.globalSetting)}_loadMark(){var e=this.defaultSettings;if(1===arguments.length&&"object"==typeof arguments[0]){var t,i=arguments[0]||{};for(t in i)i[t]&&e[t]&&i[t]===e[t]||!i[t]&&0!==i[t]||(e[t]=i[t])}var r=document.getElementById(e.watermark_id),s=(r&&r.parentNode&&r.parentNode.removeChild(r),"string"==typeof e.watermark_parent_node?document.getElementById(e.watermark_parent_node):e.watermark_parent_node),r=s||document.body,a=r.getBoundingClientRect(),n=Math.max(r.scrollWidth,r.clientWidth,a.width),o=Math.max(r.scrollHeight,r.clientHeight,a.height),a=arguments[0]||{},a=((a.watermark_parent_width||a.watermark_parent_height)&&r&&(e.watermark_x=e.watermark_x+0,e.watermark_y=e.watermark_y+0),document.getElementById(e.watermark_id)),l=null;a?a.shadowRoot&&(l=a.shadowRoot):((a=document.createElement("div")).id=e.watermark_id,a.setAttribute("style","pointer-events: none !important; display: block !important"),l="function"==typeof a.attachShadow?a.attachShadow({mode:"open"}):a,(d=r.children)[u=Math.floor(Math.random()*(d.length-1))]?r.insertBefore(a,d[u]):r.appendChild(a)),e.watermark_cols=parseInt((n-e.watermark_x)/(e.watermark_width+e.watermark_x_space));var c,d=parseInt((n-e.watermark_x-e.watermark_width*e.watermark_cols)/e.watermark_cols);e.watermark_x_space=d&&e.watermark_x_space,e.watermark_rows=parseInt((o-e.watermark_y)/(e.watermark_height+e.watermark_y_space));var u=parseInt((o-e.watermark_y-e.watermark_height*e.watermark_rows)/e.watermark_rows);e.watermark_y_space=u&&e.watermark_y_space;for(var h=s?(c=e.watermark_x+e.watermark_width*e.watermark_cols+e.watermark_x_space*(e.watermark_cols-1),e.watermark_y+e.watermark_height*e.watermark_rows+e.watermark_y_space*(e.watermark_rows-1)):(c=0+e.watermark_x+e.watermark_width*e.watermark_cols+e.watermark_x_space*(e.watermark_cols-1),0+e.watermark_y+e.watermark_height*e.watermark_rows+e.watermark_y_space*(e.watermark_rows-1)),p=0;p{if(void 0===t[e])throw new Error(`JbPro option "${e}" can not be undefined`)});var e,i,r=Ft(),r=Object.assign({},r,t);r.url="",r.isMulti&&(r.debugUuid="xxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)})),this.debug=new Ye(this);let s=t.container;if(!(s="string"==typeof t.container?document.querySelector(t.container):s))throw this.debug.error("JbPro","JbPro need container option and now container is",t.container),new Error("JbPro need container option");if("CANVAS"===s.nodeName||"VIDEO"===s.nodeName)throw this.debug.error("JbPro",`JbPro container type can not be ${s.nodeName} type`),new Error(`JbPro container type can not be ${s.nodeName} type`);if(r.videoBuffer>=r.heartTimeout)throw this.debug.error("JbPro",`JbPro videoBuffer ${r.videoBuffer}s must be less than heartTimeout ${r.heartTimeout}s`),new Error(`JbPro videoBuffer ${r.videoBuffer}s must be less than heartTimeout ${r.heartTimeout}s`);if(this._checkHasCreated(s))throw this.debug.error("JbPro","JbPro container has been created and can not be created again",s),new Error("JbPro container has been created and can not be created again",s);if(s.classList.add("jessibuca-container"),e=s,Q,i=ht(),e&&(e.dataset?e.dataset.jbprov=i:e.setAttribute("data-jbprov",i)),_(r.isLive)){const t=document.createElement("video");t.muted=!0,t.setAttribute("controlsList","nodownload"),t.disablePictureInPicture="disablePictureInPicture",t.style.position="absolute",t.style.top=0,t.style.left=0,t.style.height="100%",t.style.width="100%",s.appendChild(t),this.$videoElement=t,this.$container=s,void(this._opt=r)}else delete r.container,c(r.videoBuffer)&&(r.videoBuffer=1e3*Number(r.videoBuffer)),c(r.videoBufferDelay)&&(r.videoBufferDelay=1e3*Number(r.videoBufferDelay)),c(r.networkDelay)&&(r.networkDelay=1e3*Number(r.networkDelay)),c(r.timeout)&&(yt(r.loadingTimeout)&&(r.loadingTimeout=r.timeout),yt(r.heartTimeout))&&(r.heartTimeout=r.timeout),this._opt=r,this._destroyed=!1,this.$container=s,this._loadingTimeoutReplayTimes=0,this._heartTimeoutReplayTimes=0,this.events=new Gt(this),this.watermark=new ks(this),this._initPlayer(s,r),this._initWatermark(),this.debug.log("JbPro",'init success and version is "6-3-2023"'),console.log('JbPro version is "6-3-2023"')}destroy(){return new Promise((e,t)=>{this.debug.log("JbPro","destroy()"),this._destroyed=!0,this.off(),this.$videoElement&&(this.$videoElement.pause(),this.$videoElement.currentTime=0,this.$videoElement.srcObject&&(this.$videoElement.srcObject=null,this.$videoElement.removeAttribute("srcObject")),this.$videoElement.src&&(this.$videoElement.src="",this.$videoElement.removeAttribute("src")),this.$container.removeChild(this.$videoElement),this.$videoElement=null),this.player?this.player.destroy().then(()=>{this.player=null,this._destroy(),setTimeout(()=>{e()},0)}).catch(()=>{t()}):(this._destroy(),setTimeout(()=>{e()},0))})}_destroy(){var e;this.events&&(this.events.destroy(),this.events=null),this.talk&&(this.talk.destroy(),this.talk=null),this.watermark&&(this.watermark.destroy(),this.watermark=null),this.$container&&(this.$container.classList.remove("jessibuca-container"),e=this.$container,Q,e&&(e.dataset?delete e.dataset.jbprov:e.removeAttribute("data-jbprov")),this.$container=null),this.debug&&this.debug.log("JbPro","destroy end"),this._resetOpt(),this._loadingTimeoutReplayTimes=0,this._heartTimeoutReplayTimes=0}_resetOpt(){this._opt=Ft()}_initPlayer(e,t){this.player=new vs(e,t),this.debug.log("JbPro","_initPlayer",this.player.getOption()),this._bindEvents()}_initTalk(){var e=0{const i=()=>{this._opt.url="",this._opt.playOptions={},this._opt=Object.assign(this._opt,r),this._initPlayer(this.$container,this._opt)};this.player?this.player.destroy().then(()=>{this.player=null,i(),e()}):(i(),e())})}_bindEvents(){Object.keys(d).forEach(t=>{this.player.on(d[t],e=>{this.emit(t,e)})}),this.player.once(w.beforeDestroy,()=>{this.emit(w.close),this.destroy().then(()=>{}).catch(e=>{})}),this.player.on(w.resize,()=>{this.watermark&&this.watermark.resize(),this.player.singleWatermark&&this.player.singleWatermark.resize()}),this.player.on(w.fullscreen,()=>{this.watermark&&this.watermark.resize(),this.player.singleWatermark&&this.player.singleWatermark.resize()}),this.player.on(w.videoInfo,()=>{this.player.singleWatermark&&this.player.singleWatermark.resize()})}_bindTalkEvents(){Object.keys(ne).forEach(t=>{this.player.on(ne[t],e=>{this.emit(t,e)})})}_initWatermark(){var e;Ct(this._opt.fullscreenWatermarkConfig)&&((e=wt(this.$container,this._opt.fullscreenWatermarkConfig)).watermark_txt?this.watermark.load(e):this.debug.warn("JbPro","fullscreenWatermarkConfig text is empty"))}_checkHasCreated(e){return!!e&&(e=e,Q,!!(e?e.dataset?e.dataset.jbprov:e.getAttribute("data-jbprov"):""))}isDestroyed(){return this._destroyed}getOption(){return this.player?this.player.getOption():{}}setDebug(e){this.debug.log("JbPro","setDebug() "+e),this.player?this.player.updateOption({debug:!!e}):this.debug.warn("JbPro","player is not init")}getIsDebug(){let e=!1;return e=this.player?this.player._opt.debug:e}mute(){this.debug.log("JbPro","mute()"),this.player&&this.player.mute(!0)}cancelMute(){this.debug.log("JbPro","cancelMute()"),this.player&&this.player.mute(!1)}setVolume(e){this.debug.log("JbPro","setVolume() "+e),this.player&&(this.player.volume=e)}getVolume(){let e=null;return this.player&&(e=this.player.volume,e=parseFloat(e).toFixed(2)),e}audioResume(){this.debug.log("JbPro","audioResume()"),this.player&&this.player.audio?this.player.audio.audioEnabled(!0):this.debug.warn("JbPro","audioResume error")}setTimeout(e){this.debug.log("JbPro","setTimeout() "+e),e=Number(e),isNaN(e)?this.debug.warn("JbPro",`setTimeout error: ${e} is not a number`):this.player&&this.player.updateOption({timeout:e,loadingTimeout:e,heartTimeout:e})}setScaleMode(e){this.debug.log("JbPro","setScaleMode() "+e),this.player?this.player.setScaleMode(e):this.debug.warn("JbPro","setScaleMode() player is null")}pause(){let e=0{if(this.debug.log("JbPro","pause() "+e),this.isDestroyed())return i("JbPro is destroyed");this.player?this.player.pause(e).then(e=>{t(e)}).catch(e=>{i(e)}):i("player is null")})}close(){return new Promise((e,t)=>{this.debug.log("JbPro","close()"),this._opt.url="",this._loadingTimeoutReplayTimes=0,this._heartTimeoutReplayTimes=0,this.player?this.player.close().then(()=>{e()}).catch(e=>{t(e)}):t("player is null")})}clearView(){this.debug.log("JbPro","clearView()"),this.player&&this.player.video?this.getRenderType()===V?this.player.video.clearView():this.debug.warn("JbPro","clearView","render type is video, not support clearView, please use canvas render type"):this.debug.warn("JbPro","clearView","player is null")}play(){let a=0{if(this.debug.log("JbPro","play() "+a),a||this._opt.url)if(a=a&&(""+a).trim(),_(this._opt.isLive))this.$videoElement.controls="controls",this.$videoElement.muted=!1,this.$videoElement.src=a,this.$videoElement.play(),i(this.$videoElement);else{if(this._opt.isCrypto){var e,t=n.cryptoKey||this._opt.playOptions.cryptoKey,s=n.cryptoIV||this._opt.playOptions.cryptoIV;if(!t||!s)return e=a||this._opt.url,void this._cryptoPlay(e).then(e=>{var{cryptoIV:e,cryptoKey:t}=e;this._opt.playOptions.cryptoKey=t,this._opt.playOptions.cryptoIV=e,n.cryptoIV=e,n.cryptoKey=t,this._playBefore(a,n).then(()=>{i()}).catch(e=>{r(e)})}).catch(e=>{r(e)});this._opt.playOptions.cryptoKey=t,this._opt.playOptions.cryptoIV=s,n.cryptoIV=s,n.cryptoKey=t}this._playBefore(a,n).then(()=>{i()}).catch(e=>{r(e)})}else this.emit(w.error,m.playError),r("url is null and this._opt.url is null")})}_playBefore(i,r){return new Promise((e,t)=>{this.player?i?this._opt.url?i===this._opt.url?this.player.playing?(this.debug.log("JbPro","_playBefore","playing and resolve()"),e()):(this.debug.log("JbPro","_playBefore","pause -> play"),this.player.play(this._opt.url,this._opt.playOptions).then(()=>{e(),this.player.resumeAudioAfterPause()}).catch(e=>{this.debug.error("JbPro","_playBefore this.player.play error",e),this.emit(w.crashLog,this.getCrashLog("this.player.play 1",e)),this.player.pause().then(()=>{t(e)})})):this.player.pause().then(()=>{this._play(i,r).then(()=>{e()}).catch(e=>{this.debug.error("JbPro","_play error",e),this.emit(w.crashLog,this.getCrashLog("this.player.play 2",e)),t(e)})}).catch(e=>{this.debug.error("JbPro","this.player.pause error",e),t(e)}):this._play(i,r).then(()=>{e()}).catch(e=>{this.debug.error("JbPro","_play error",e),this.emit(w.crashLog,this.getCrashLog("this.player.play 3",e)),t(e)}):this.player.play(this._opt.url,this._opt.playOptions).then(()=>{e(),this.player.resumeAudioAfterPause()}).catch(e=>{this.debug.error("JbPro","this.player.play error",e),this.emit(w.crashLog,this.getCrashLog("this.player.play 4",e)),this.player.pause().then(()=>{t(e)})}):i?this._play(i,r).then(()=>{e()}).catch(e=>{this.debug.error("JbPro","_play error",e),this.emit(w.crashLog,this.getCrashLog("this.player.play 5",e)),t(e)}):this._play(this._opt.url,this._opt.playOptions).then(()=>{e()}).catch(e=>{this.debug.error("JbPro","_play error",e),this.emit(w.crashLog,this.getCrashLog("this.player.play 6",e)),t(e)})})}_cryptoPlay(n){return new Promise((r,s)=>{var e,t=function(){var e=(n||document.location.toString()).split("//"),t=e[1].indexOf("/");let i=e[1].substring(t);return i=-1!=i.indexOf("?")?i.split("?")[0]:i}();let i=this._opt.cryptoKeyUrl,a="";if(i)a=i;else{const r=function(e){var t=/(msie|trident)/i.test(navigator.userAgent),i=document.createElement("a");let r=e;return t&&(i.setAttribute("href",r),r=i.href),i.setAttribute("href",r),{origin:i.origin,href:i.href,protocol:i.protocol?i.protocol.replace(/:$/,""):"",host:i.host,search:i.search?i.search.replace(/^\?/,""):"",hash:i.hash?i.hash.replace(/^#/,""):"",hostname:i.hostname,port:i.port,pathname:"/"===i.pathname.charAt(0)?i.pathname:"/"+i.pathname}}(n);i=r.origin+"/crypto/",a=i+"?stream="+t}e=a,new Promise((t,i)=>{R.get(e).then(e=>{t(e)}).catch(e=>{i(e)})}).then(e=>{if(e){const t=e.split("."),i=Mt(t[0]),a=Mt(t[1]);a&&i?r({cryptoIV:a,cryptoKey:i}):s("get cryptoIV or cryptoKey error")}else s(`cryptoKeyUrl: getM7SCryptoStreamKey ${a} res is null`)}).catch(e=>{s(e)})})}playback(r){let s=1{if(this.debug.log("JbPro","playback() "+r),_(this._opt.isLive))return t("this._opt.isLive is false, can not playback");var i=jt(),i=Object.assign({},i.playbackConfig,this._opt.playbackConfig,s);i.isUseFpsRender||i.isCacheBeforeDecodeForFpsRender&&(i.isCacheBeforeDecodeForFpsRender=!1,this.debug.warn("JbPro","playbackConfig.isUseFpsRender is false, isCacheBeforeDecodeForFpsRender can not be ture, isCacheBeforeDecodeForFpsRender is set to false")),0===i.rateConfig.length&&i.showRateBtn&&(i.showRateBtn=!1,this.debug.warn("JbPro","playbackConfig.rateConfig.length is 0, showRateBtn can not be ture, showRateBtn is set to false")),this._resetPlayer({videoBuffer:0,playbackConfig:i,playType:v,openWebglAlignment:!0,useMSE:!1,useWCS:!1,useSIMD:!0}).then(()=>{this.play(r).then(()=>{e()}).catch(e=>{t(e)})}).catch(e=>{t(e)})})}playbackPause(){let i=0{if(!this.player)return t("player is null");k(i)?this.pause().then(()=>{e()}).catch(e=>{t(e)}):(this.player.playbackPause=!0,e())})}playbackResume(){return this.debug.log("JbPro","playbackResume()"),this._opt.playType===n?Promise.reject("playType is player, can not call playbackResume method"):new Promise((e,t)=>{if(!this.player)return t();this.player.playbackPause=!1,e()})}forward(i){return this.debug.log("JbPro","forward() "+i),_(this._opt.isLive)||this._opt.playType===n?Promise.reject("forward() method only just for playback type"):u(Number(i))?new Promise((e,t)=>{(this.player&&this.player.playing?(i=y(Number(i),.1,32),this.player.decoderWorker&&this.player.decoderWorker.updateWorkConfig({key:"playbackRate",value:i}),this.player.playback.setRate(i),this.player.video&&this.player.video.setRate(i),this.player.audio&&this.player.audio.setRate(i),e):t)()}):Promise.reject(`forward() params "rate": ${i} must be number type`)}playbackForward(e){return this.forward(e)}normal(){return this.forward(1)}playbackNormal(){return this.normal()}updatePlaybackForwardMaxRateDecodeIFrame(e){this.debug.log("JbPro","updatePlaybackForwardMaxRateDecodeIFrame() "+e),e=Number(e),e=y(e=parseInt(e,10),1,8),this._opt.playbackForwardMaxRateDecodeIFrame=e,this.player?(this.player.updateOption({playbackForwardMaxRateDecodeIFrame:e}),this.player.decoderWorker&&this.player.decoderWorker.updateWorkConfig({key:"playbackForwardMaxRateDecodeIFrame",value:e})):this.debug.warn("JbPro","updatePlaybackForwardMaxRateDecodeIFrame() player is null")}setPlaybackStartTime(e){this.debug.log("JbPro","setPlaybackStartTime() "+e);var t=_t(e);this.player?this.player.isPlayback()?t<10&&0!==e?this.debug.warn("JbPro",`timestamp: ${e} is not valid`):this.player.playing&&(10===t&&(e*=1e3),this.player.playback.setStartTime(e),this.playbackClearCacheBuffer()):this.debug.warn("JbPro","playType is not playback"):this.debug.warn("JbPro","player is null")}playbackClearCacheBuffer(){this.debug.log("JbPro","playbackClearCacheBuffer()"),this.player?this.player.isPlayback()?(this.player.video&&this.player.video.clear(),this.player.audio&&this.player.audio.clear(),this.player.decoderWorker.clearWorkBuffer(!0)):this.debug.warn("JbPro","playType is not playback"):this.debug.warn("JbPro","player is null")}getPlaybackCurrentRate(){return this.player&&this.player.isPlayback()?this.player.playback.rate:1}updatePlaybackLocalOneFrameTimestamp(e){this.debug.log("JbPro","updatePlaybackLocalOneFrameTimestamp() "+e),this.player?this.player.isPlayback()?this.player.playback.updateLocalOneFrameTimestamp(e):this.debug.warn("JbPro","playType is not playback"):this.debug.warn("JbPro","player is null")}setStreamQuality(e){this.debug.log("JbPro","setStreamQuality() "+e),this.player?this.player._opt.operateBtns.quality?(this.player._opt.qualityConfig||[]).includes(e)?this.player.streamQuality=e:this.debug.warn("JbPro",`quality: ${e} is not in qualityList`):this.debug.warn("JbPro","player._opt.operateBtns.quality is false"):this.debug.warn("JbPro","player is null")}_play(){let d=0{if(!this.player)return t("player is null");let i=!1;this._opt.url&&this._opt.url!==d&&(i=!0),this._opt.url=d,this._opt.playOptions=u;var r=0===d.indexOf("http"),s=0===d.indexOf("webrtc"),a=0===d.indexOf("wt"),n=!s&&-1!==d.indexOf(".m3u8"),o=!s&&-1!==d.indexOf(".flv"),l=r?n?3:2:a?5:s?4:1,r=this._opt.isNakedFlow?H:r&&!n||o||this._opt.isFlv?G:n?"hls":s?"webrtc":a?z:"m7s";if(o&&!this._opt.isFlv&&(this._opt.isFlv=!0),!l||!r)return t(`play protocol is ${l}, demuxType is `+r);const c=()=>{this.player.once(m.webglAlignmentError,e=>{this.emit(w.crashLog,this.getCrashLog(m.webglAlignmentError,e)),this.pause().then(()=>{if(this.player&&this.player._opt.webglAlignmentErrorReplay){this.debug.log("JbPro","webglAlignmentError");const e=this._opt.url;this._resetPlayer({openWebglAlignment:!0}).then(()=>{this.play(e).then(()=>{this.debug.log("JbPro","webglAlignmentError and play success")}).catch(e=>{this.debug.error("JbPro","webglAlignmentError and play error",e)})}).catch(e=>{this.debug.error("JbPro","webglAlignmentError and _resetPlayer error",e)})}else this.emit(w.playFailedAndPaused,m.webglAlignmentError),this.debug.log("JbPro","webglAlignmentError and webglAlignmentErrorReplay is false")}).catch(e=>{this.debug.error("JbPro","webglAlignmentError and pause error",e)})}),this.player.once(m.webglContextLostError,e=>{this.emit(w.crashLog,this.getCrashLog(m.webglContextLostError,e)),this.pause().then(()=>{if(this.player&&this.player._opt.webglContextLostErrorReplay){this.debug.log("JbPro","webglContextLostError");const t=this._opt.url,i={};var e;this.player._opt.replayUseLastFrameShow&&(e=this.screenshot("","png",.92,"base64"),i.loadingBackground=e),this._resetPlayer(i).then(()=>{this.play(t).then(()=>{this.debug.log("JbPro","webglContextLostError and play success")}).catch(e=>{this.debug.error("JbPro","webglContextLostError and play error",e)})}).catch(e=>{this.debug.error("JbPro","webglContextLostError and _resetPlayer error",e)})}else this.emit(w.playFailedAndPaused,m.webglContextLostError),this.debug.log("JbPro","webglContextLostError and webglContextLostErrorReplay is false")}).catch(e=>{this.debug.error("JbPro","webglAlignmentError and pause error",e)})}),this.player.once(m.mediaSourceH265NotSupport,e=>{this.emit(w.crashLog,this.getCrashLog(m.mediaSourceH265NotSupport,e)),this.pause().then(()=>{if(this.player&&this.player._opt.autoWasm){this.debug.log("JbPro","mediaSourceH265NotSupport auto wasm [mse-> wasm] reset player and play");const e=this._opt.url;this._resetPlayer({useMSE:!1,useWCS:!1}).then(()=>{this.play(e).then(()=>{this.debug.log("JbPro","mediaSourceH265NotSupport auto wasm [mse-> wasm] reset player and play success")}).catch(e=>{this.debug.error("JbPro","mediaSourceH265NotSupport auto wasm [mse-> wasm] reset player and play error",e)})}).catch(e=>{this.debug.error("JbPro","mediaSourceH265NotSupport auto wasm [mse-> wasm] _resetPlayer error",e)})}else this.emit(w.playFailedAndPaused,m.mediaSourceH265NotSupport),this.debug.log("JbPro","mediaSourceH265NotSupport and autoWasm is false")}).catch(e=>{this.debug.error("JbPro","mediaSourceH265NotSupport and pause error",e)})}),this.player.once(m.mediaSourceFull,e=>{this.emit(w.crashLog,this.getCrashLog(m.mediaSourceFull,e)),this.pause().then(()=>{if(this.player&&this.player._opt.mseDecodeErrorReplay){this.debug.log("JbPro","mediaSourceFull and auto wasm [mse-> wasm] reset player and play");const i=this._opt.url;let e={};var t;this.player._opt.autoWasm&&(e={useMSE:!1,useWCS:!1}),this.player._opt.replayUseLastFrameShow&&(t=this.screenshot("","png",.92,"base64"),e.loadingBackground=t),this._resetPlayer(e).then(()=>{this.play(i).then(()=>{this.debug.log("JbPro","mediaSourceFull and reset player and play success")}).catch(e=>{this.debug.error("JbPro","mediaSourceFull and reset player and play error",e)})}).catch(e=>{this.debug.error("JbPro","mediaSourceFull and _resetPlayer error",e)})}else this.emit(w.playFailedAndPaused,m.mediaSourceFull),this.debug.log("JbPro","mediaSourceFull and autoWasm is false")}).catch(e=>{this.debug.error("JbPro","mediaSourceFull and pause error",e)})}),this.player.once(m.mediaSourceAppendBufferError,e=>{this.emit(w.crashLog,this.getCrashLog(m.mediaSourceAppendBufferError,e)),this.pause().then(()=>{if(this.player&&this.player._opt.mseDecodeErrorReplay){this.debug.log("JbPro","mediaSourceAppendBufferError and auto wasm [mse-> wasm] reset player and play");const i=this._opt.url;let e={};var t;this.player._opt.autoWasm&&(e={useMSE:!1,useWCS:!1}),this.player._opt.replayUseLastFrameShow&&(t=this.screenshot("","png",.92,"base64"),e.loadingBackground=t),this._resetPlayer(e).then(()=>{this.play(i).then(()=>{this.debug.log("JbPro","mediaSourceAppendBufferError and reset player and play success")}).catch(e=>{this.debug.error("JbPro","mediaSourceAppendBufferError and reset player and play error",e)})}).catch(e=>{this.debug.error("JbPro","mediaSourceAppendBufferError and _resetPlayer error",e)})}else this.emit(w.playFailedAndPaused,m.mediaSourceAppendBufferError),this.debug.log("JbPro","mediaSourceAppendBufferError and autoWasm is false")}).catch(e=>{this.debug.error("JbPro","mediaSourceAppendBufferError and pause error",e)})}),this.player.once(m.mediaSourceBufferListLarge,e=>{this.emit(w.crashLog,this.getCrashLog(m.mediaSourceBufferListLarge,e)),this.pause().then(()=>{if(this.player&&this.player._opt.mseDecodeErrorReplay){this.debug.log("JbPro","media source buffer list large and auto wasm [mse-> wasm] reset player and play");const i=this._opt.url;let e={};var t;this.player._opt.autoWasm&&(e={useMSE:!1,useWCS:!1}),this.player._opt.replayUseLastFrameShow&&(t=this.screenshot("","png",.92,"base64"),e.loadingBackground=t),this._resetPlayer(e).then(()=>{this.play(i).then(()=>{this.debug.log("JbPro","media source buffer list large and reset player and play success")}).catch(e=>{this.debug.error("JbPro","media source buffer list large and reset player and play error",e)})}).catch(e=>{this.debug.error("JbPro","media source buffer list large and _resetPlayer error",e)})}else this.emit(w.playFailedAndPaused,m.mediaSourceBufferListLarge),this.debug.log("JbPro","media source buffer list large and autoWasm is false")}).catch(e=>{this.debug.error("JbPro","media source buffer list large and pause error",e)})}),this.player.once(m.mediaSourceAppendBufferEndTimeout,e=>{this.emit(w.crashLog,this.getCrashLog(m.mediaSourceAppendBufferEndTimeout,e)),this.pause().then(()=>{if(this.player&&this.player._opt.mseDecodeErrorReplay){this.debug.log("JbPro","media source append buffer end timeout and auto wasm [mse-> wasm] reset player and play");const i=this._opt.url;let e={};var t;this.player._opt.autoWasm&&(e={useMSE:!1,useWCS:!1}),this.player._opt.replayUseLastFrameShow&&(t=this.screenshot("","png",.92,"base64"),e.loadingBackground=t),this._resetPlayer(e).then(()=>{this.play(i).then(()=>{this.debug.log("JbPro","media source append buffer end timeout and reset player and play success")}).catch(e=>{this.debug.error("JbPro","media source append buffer end timeout and reset player and play error",e)})}).catch(e=>{this.debug.error("JbPro","media source append buffer end timeout and _resetPlayer error",e)})}else this.emit(w.playFailedAndPaused,m.mediaSourceAppendBufferEndTimeout),this.debug.log("JbPro","media source append buffer end timeout and autoWasm is false")}).catch(e=>{this.debug.error("JbPro","media source append buffer end timeout and pause error",e)})}),this.player.once(m.mseSourceBufferError,e=>{this.emit(w.crashLog,this.getCrashLog(m.mseSourceBufferError,e)),this.pause().then(()=>{if(this.player&&this.player._opt.mseDecodeErrorReplay){this.debug.log("JbPro","mseSourceBufferError auto wasm [mse-> wasm] reset player and play");const i=this._opt.url;let e={};var t;this.player._opt.autoWasm&&(e={useMSE:!1,useWCS:!1}),this.player._opt.replayUseLastFrameShow&&(t=this.screenshot("","png",.92,"base64"),e.loadingBackground=t),this._resetPlayer(e).then(()=>{this.play(i).then(()=>{this.debug.log("JbPro","mseSourceBufferError auto wasm [mse-> wasm] reset player and play success")}).catch(e=>{this.debug.error("JbPro","mseSourceBufferError auto wasm [mse-> wasm] reset player and play error",e)})}).catch(e=>{this.debug.error("JbPro","mseSourceBufferError auto wasm [mse-> wasm] _resetPlayer and play error",e)})}else this.emit(w.playFailedAndPaused,m.mseSourceBufferError),this.debug.log("JbPro","mseSourceBufferError and autoWasm is false")}).catch(e=>{this.debug.error("JbPro","mseSourceBufferError and pause error:",e)})}),this.player.once(m.mseAddSourceBufferError,e=>{this.emit(w.crashLog,this.getCrashLog(m.mseAddSourceBufferError,e)),this.pause().then(()=>{if(this.player&&this.player._opt.autoWasm){this.debug.log("JbPro","mseAddSourceBufferError auto wasm [mse-> wasm] reset player and play");const e=this._opt.url;this._resetPlayer({useMSE:!1,useWCS:!1}).then(()=>{this.play(e).then(()=>{this.debug.log("JbPro","mseAddSourceBufferError auto wasm [mse-> wasm] reset player and play success")}).catch(e=>{this.debug.error("JbPro","mseAddSourceBufferError auto wasm [mse-> wasm] reset player and play error",e)})}).catch(e=>{this.debug.error("JbPro","mseAddSourceBufferError auto wasm [mse-> wasm] _resetPlayer and play error",e)})}else this.emit(w.playFailedAndPaused,m.mseAddSourceBufferError),this.debug.log("JbPro","mseAddSourceBufferError and autoWasm is false")}).catch(e=>{this.debug.error("JbPro","mseAddSourceBufferError and pause error",e)})}),this.player.once(m.mediaSourceDecoderConfigurationError,e=>{this.emit(w.crashLog,this.getCrashLog(m.mediaSourceDecoderConfigurationError,e)),this.pause().then(()=>{if(this.player&&this.player._opt.autoWasm){this.debug.log("JbPro","mediaSourceDecoderConfigurationError auto wasm [mse-> wasm] reset player and play");const e=this._opt.url;this._resetPlayer({useMSE:!1,useWCS:!1}).then(()=>{this.play(e).then(()=>{this.debug.log("JbPro","mediaSourceDecoderConfigurationError auto wasm [mse-> wasm] reset player and play success")}).catch(e=>{this.debug.error("JbPro","mediaSourceDecoderConfigurationError auto wasm [mse-> wasm] reset player and play error",e)})}).catch(e=>{this.debug.error("JbPro","mediaSourceDecoderConfigurationError auto wasm [mse-> wasm] _resetPlayer and play error",e)})}else this.debug.log("JbPro","mediaSourceDecoderConfigurationError and autoWasm is false")}).catch(e=>{this.debug.error("JbPro","mediaSourceDecoderConfigurationError and pause error",e)})}),this.player.once(m.mediaSourceTsIsMaxDiff,e=>{this.emit(w.crashLog,this.getCrashLog(m.mediaSourceTsIsMaxDiff,e)),this.pause().then(()=>{if(this.player&&this.player._opt.mediaSourceTsIsMaxDiffReplay){this.debug.log("JbPro","mediaSourceTsIsMaxDiff reset player and play");const e=this._opt.url,t={};t.loadingBackground=this.screenshot("","png",.92,"base64"),this._resetPlayer(t).then(()=>{this.play(e).then(()=>{}).catch(e=>{this.debug.error("JbPro","mediaSourceTsIsMaxDiff replay error",e)})}).catch(e=>{this.debug.error("JbPro","mediaSourceTsIsMaxDiff _resetPlayer error",e)})}else this.emit(w.playFailedAndPaused,m.mediaSourceTsIsMaxDiff),this.debug.log("JbPro","mediaSourceTsIsMaxDiff and replay is false")}).catch(e=>{this.debug.error("JbPro","mediaSourceTsIsMaxDiff and pause error",e)})}),this.player.once(m.mseWidthOrHeightChange,e=>{this.emit(w.crashLog,this.getCrashLog(m.mseWidthOrHeightChange,e)),this.debug.log("JbPro","mseWidthOrHeightChange and reset player and play");const t=this._opt.url,i=this.screenshot("","png",.92,"base64");this._resetPlayer({loadingBackground:i}).then(()=>{this.play(t).then(()=>{this.debug.log("JbPro","mseWidthOrHeightChange and reset player and play success")}).catch(e=>{this.debug.error("JbPro","mseWidthOrHeightChange and reset player and play error",e)})}).catch(e=>{this.debug.error("JbPro","mseWidthOrHeightChange and _resetPlayer error",e)})}),this.player.once(m.mediaSourceUseCanvasRenderPlayFailed,e=>{this.emit(w.crashLog,this.getCrashLog(m.mediaSourceUseCanvasRenderPlayFailed,e)),this.debug.log("JbPro","mediaSourceUseCanvasRenderPlayFailed and reset player"),this.pause().then(()=>{this._resetPlayer().then(()=>{this.debug.log("JbPro","mediaSourceUseCanvasRenderPlayFailed and reset player success")}).catch(e=>{this.debug.error("JbPro","mediaSourceUseCanvasRenderPlayFailed and reset player error",e)})}).catch(e=>{this.debug.error("JbPro","mediaSourceUseCanvasRenderPlayFailed and pause",e)})}),this.player.once(m.webcodecsH265NotSupport,e=>{this.emit(w.crashLog,this.getCrashLog(m.webcodecsH265NotSupport,e)),this.pause().then(()=>{if(this.player&&this.player._opt.autoWasm){this.debug.log("JbPro","webcodecsH265NotSupport auto wasm [wcs-> wasm] reset player and play");const e=this._opt.url;this._resetPlayer({useMSE:!1,useWCS:!1}).then(()=>{this.play(e).then(()=>{this.debug.log("JbPro","webcodecsH265NotSupport auto wasm [wcs-> wasm] reset player and play success")}).catch(e=>{this.debug.error("JbPro","webcodecsH265NotSupport auto wasm [wcs-> wasm] reset player and play error",e)})}).catch(e=>{this.debug.error("JbPro","webcodecsH265NotSupport auto wasm [wcs-> wasm] _resetPlayer and play error",e)})}else this.emit(w.playFailedAndPaused,m.webcodecsH265NotSupport),this.debug.log("JbPro","webcodecsH265NotSupport and autoWasm is false")}).catch(e=>{this.debug.error("JbPro","webcodecsH265NotSupport and pause error",e)})}),this.player.once(m.webcodecsUnsupportedConfigurationError,e=>{this.emit(w.crashLog,this.getCrashLog(m.webcodecsUnsupportedConfigurationError,e)),this.pause().then(()=>{if(this.player&&this.player._opt.autoWasm){this.debug.log("Jessibuca","webcodecsUnsupportedConfigurationError auto wasm [wcs-> wasm] reset player and play");const e=this._opt.url;this._resetPlayer({useMSE:!1,useWCS:!1}).then(()=>{this.play(e).then(()=>{this.debug.log("Jessibuca","webcodecsUnsupportedConfigurationError auto wasm [wcs-> wasm] reset player and play success")}).catch(e=>{this.debug.error("Jessibuca","webcodecsUnsupportedConfigurationError auto wasm [wcs-> wasm] reset player and play error",e)})}).catch(e=>{this.debug.error("Jessibuca","webcodecsUnsupportedConfigurationError auto wasm [wcs-> wasm] _resetPlayer and play error",e)})}else this.emit(w.playFailedAndPaused,m.webcodecsUnsupportedConfigurationError),this.debug.log("Jessibuca","webcodecsUnsupportedConfigurationError and autoWasm is false")}).catch(e=>{this.debug.error("Jessibuca","webcodecsUnsupportedConfigurationError and pause error",e)})}),this.player.once(m.webcodecsDecodeError,e=>{this.emit(w.crashLog,this.getCrashLog(m.webcodecsDecodeError,e)),this.pause().then(()=>{if(this.player&&this.player._opt.wcsDecodeErrorReplay){this.debug.log("JbPro","webcodecs decode error reset player and play");const i=this._opt.url;let e={};var t;this.player._opt.autoWasm&&(e={useMSE:!1,useWCS:!1}),this.player._opt.replayUseLastFrameShow&&(t=this.screenshot("","png",.92,"base64"),e.loadingBackground=t),this._resetPlayer(e).then(()=>{this.play(i).then(()=>{this.debug.log("JbPro","webcodecs decode error reset player and play success")}).catch(e=>{this.debug.error("JbPro","webcodecs decode error reset player and play error",e)})}).catch(()=>{this.debug.error("JbPro","webcodecs decode error _resetPlayer error")})}else this.emit(w.playFailedAndPaused,m.webcodecsDecodeError),this.debug.log("JbPro","webcodecs decode error and autoWasm is false")}).catch(e=>{this.debug.error("JbPro","webcodecs decode error and pause error",e)})}),this.player.once(m.wcsWidthOrHeightChange,e=>{this.emit(w.crashLog,this.getCrashLog(m.wcsWidthOrHeightChange,e)),this.debug.log("JbPro","wcsWidthOrHeightChange and reset player and play");const t=this._opt.url,i=this.screenshot("","png",.92,"base64");this._resetPlayer({loadingBackground:i}).then(()=>{this.play(t).then(()=>{this.debug.log("JbPro","wcsWidthOrHeightChange and reset player and play success")}).catch(e=>{this.debug.error("JbPro","wcsWidthOrHeightChange and reset player and play error",e)})}).catch(e=>{this.debug.error("JbPro","wcsWidthOrHeightChange and _resetPlayer error",e)})}),this.player.once(m.wasmDecodeError,e=>{this.emit(w.crashLog,this.getCrashLog(m.wasmDecodeError,e)),this.pause().then(()=>{if(this.player&&this.player._opt.wasmDecodeErrorReplay){this.debug.log("JbPro","wasm decode error and reset player and play");const t=this._opt.url,i={};var e;this.player._opt.replayUseLastFrameShow&&(e=this.screenshot("","png",.92,"base64"),i.loadingBackground=e),this._resetPlayer(i).then(()=>{this.play(t).then(()=>{this.debug.log("JbPro","wasm decode error and reset player and play success")}).catch(e=>{this.debug.error("JbPro","wasm decode error and reset player and play error",e)})}).catch(()=>{this.debug.error("JbPro","wasm decode error and _resetPlayer error")})}else this.emit(w.playFailedAndPaused,m.wasmDecodeError),this.debug.log("JbPro","wasm decode error and wasmDecodeErrorReplay is false")}).catch(e=>{this.debug.error("JbPro","wasm decode error and pause error",e)})}),this.player.once(m.wasmDecodeVideoNoResponseError,e=>{this.emit(w.crashLog,this.getCrashLog(m.wasmDecodeVideoNoResponseError,e)),this.pause().then(()=>{this.debug.log("JbPro","wasm decode video no response error and reset player and play");const e=this._opt.url,t={};if(this.player&&this.player._opt.replayUseLastFrameShow){const e=this.screenshot("","png",.92,"base64");t.loadingBackground=e}this._resetPlayer(t).then(()=>{this.play(e).then(()=>{this.debug.log("JbPro","wasm decode video no response error and reset player and play success")}).catch(e=>{this.debug.error("JbPro","wasm decode video no response error and reset player and play error",e)})}).catch(e=>{this.debug.error("JbPro","wasm decode video no response error and _resetPlayer error",e)})}).catch(e=>{this.debug.error("JbPro","wasm decode video no response error and pause error",e)})}),this.player.once(m.wasmWidthOrHeightChange,e=>{this.emit(w.crashLog,this.getCrashLog(m.wasmWidthOrHeightChange,e)),this.debug.log("JbPro","wasmWidthOrHeightChange and reset player and play");const t=this._opt.url,i=this.screenshot("","png",.92,"base64");this._resetPlayer({loadingBackground:i}).then(()=>{this.play(t).then(()=>{this.debug.log("JbPro","wasmWidthOrHeightChange and reset player and play success")}).catch(e=>{this.debug.error("JbPro","wasmWidthOrHeightChange and reset player and play error",e)})}).catch(e=>{this.debug.error("JbPro","wasmWidthOrHeightChange and _resetPlayer error",e)})}),this.player.once(m.wasmUseVideoRenderError,e=>{this.emit(w.crashLog,this.getCrashLog(m.wasmUseVideoRenderError,e)),this.debug.log("JbPro","wasmUseVideoRenderError and reset player and play");const t=this._opt.url;this._resetPlayer({useVideoRender:!1}).then(()=>{this.play(t).then(()=>{this.debug.log("JbPro","wasmUseVideoRenderError and reset player and play success")}).catch(e=>{this.debug.error("JbPro","wasmUseVideoRenderError and reset player and play error",e)})}).catch(e=>{this.debug.error("JbPro","wasmUseVideoRenderError and _resetPlayer error",e)})}),this.player.once(m.simdH264DecodeVideoWidthIsTooLarge,e=>{this.emit(w.crashLog,this.getCrashLog(m.simdH264DecodeVideoWidthIsTooLarge,e)),this.pause().then(()=>{this.debug.log("JbPro","simdH264DecodeVideoWidthIsTooLarge and reset player and play");const e=this._opt.url;this._resetPlayer({useSIMD:!1}).then(()=>{this.play(e).then(()=>{this.debug.log("JbPro","simdH264DecodeVideoWidthIsTooLarge and reset player and play success")}).catch(e=>{this.debug.error("JbPro","simdH264DecodeVideoWidthIsTooLarge and reset player and play error",e)})}).catch(e=>{this.debug.error("JbPro","simdH264DecodeVideoWidthIsTooLarge and _resetPlayer error",e)})}).catch(e=>{this.debug.error("JbPro","simdH264DecodeVideoWidthIsTooLarge and pause error",e)})}),this.player.once(w.networkDelayTimeout,e=>{if(this.player._opt.networkDelayTimeoutReplay){this.emit(w.crashLog,this.getCrashLog(w.networkDelayTimeout,e)),this.debug.log("JbPro","network delay time out and reset player and play");const t=this._opt.url,i={};if(this.player&&this.player._opt.replayUseLastFrameShow){const e=this.screenshot("","png",.92,"base64");i.loadingBackground=e}this._resetPlayer(i).then(()=>{this.play(t).then(()=>{this.debug.log("JbPro","wasm decode error and reset player and play success")}).catch(e=>{this.debug.error("JbPro","wasm decode error and reset player and play error",e)})}).catch(()=>{this.debug.error("JbPro","wasm decode error and _resetPlayer error")})}}),this.player.once(m.fetchError,e=>{this.emit(w.crashLog,this.getCrashLog(m.fetchError,e)),this.debug.log("JbPro","fetch error and reset player"),this.pause().then(()=>{this._resetPlayer().then(()=>{this.emit(w.playFailedAndPaused,m.fetchError)}).catch(()=>{this.emit(w.playFailedAndPaused,m.fetchError)})}).catch(e=>{this.debug.error("JbPro","fetch error and pause",e)})}),this.player.once(w.streamEnd,e=>{this.emit(w.crashLog,this.getCrashLog(w.streamEnd,e)),this.debug.log("JbPro","streamEnd reset player"),this.pause().then(()=>{this._resetPlayer().then(()=>{this.emit(w.playFailedAndPaused,w.streamEnd)}).catch(()=>{this.emit(w.playFailedAndPaused,w.streamEnd)})}).catch(e=>{this.debug.error("JbPro","streamEnd pause",e)})}),this.player.once(m.websocketError,e=>{this.emit(w.crashLog,this.getCrashLog(m.websocketError,e)),this.debug.log("JbPro","websocketError and reset player"),this.pause().then(()=>{this._resetPlayer().then(()=>{this.emit(w.playFailedAndPaused,m.websocketError)}).catch(()=>{this.emit(w.playFailedAndPaused,m.websocketError)})}).catch(e=>{this.debug.error("JbPro","websocketError and pause",e)})}),this.player.once(m.webrtcError,e=>{this.emit(w.crashLog,this.getCrashLog(m.webrtcError,e)),this.debug.log("JbPro","webrtcError and reset player"),this.pause().then(()=>{this._resetPlayer().then(()=>{this.emit(w.playFailedAndPaused,m.webrtcError)}).catch(()=>{this.emit(w.playFailedAndPaused,m.webrtcError)})}).catch(e=>{this.debug.error("JbPro","webrtcError and pause",e)})}),this.player.once(m.hlsError,e=>{this.emit(w.crashLog,this.getCrashLog(m.hlsError,e)),this.debug.log("JbPro","hlsError and reset player"),this.pause().then(()=>{this._resetPlayer().then(()=>{this.emit(w.playFailedAndPaused,m.hlsError)}).catch(()=>{this.emit(w.playFailedAndPaused,m.hlsError)})}).catch(e=>{this.debug.error("JbPro","hlsError and pause",e)})}),this.player.on(w.delayTimeout,e=>{this.emit(w.crashLog,this.getCrashLog(w.delayTimeout,e)),this.isDestroyed()?this.debug.log("JbPro","delay timeout but player is destroyed"):this.pause().then(()=>{if(this.player&&this.player._opt.heartTimeoutReplay&&(this._heartTimeoutReplayTimes{this.play(e).then(()=>{}).catch(e=>{this.debug.error("JbPro","delay timeout replay error",e)})}).catch(e=>{this.debug.error("JbPro","delay timeout _resetPlayer error",e)})}else this.emit(w.playFailedAndPaused,w.delayTimeout),this.player&&this.player.emit(w.delayTimeoutRetryEnd),this.debug.warn("JbPro",`delayTimeoutRetryEnd and opt.heartTimeout is ${this.player&&this.player._opt.heartTimeout} and opt.heartTimeoutReplay is ${this.player&&this.player._opt.heartTimeoutReplay} and opt.heartTimeoutReplayTimes is ${this.player&&this.player._opt.heartTimeoutReplayTimes},and local._heartTimeoutReplayTimes is `+this._heartTimeoutReplayTimes)}).catch(e=>{this.debug.error("JbPro","delay timeout and pause error",e)})}),this.player.on(w.loadingTimeout,e=>{this.emit(w.crashLog,this.getCrashLog(w.loadingTimeout,e)),this.isDestroyed()?this.debug.log("JbPro","loading timeout but player is destroyed"):this.pause().then(()=>{if(this.player&&this.player._opt.loadingTimeoutReplay&&(this._loadingTimeoutReplayTimes{this.play(e).then(()=>{}).catch(e=>{this.debug.error("JbPro","loading timeout replay error",e)})}).catch(e=>{this.debug.error("JbPro","loading timeout _resetPlayer error",e)})}else this.emit(w.playFailedAndPaused,w.loadingTimeout),this.player&&this.player.emit(w.loadingTimeoutRetryEnd),this.debug.log("JbPro",`loadingTimeoutRetryEnd and opt.loadingTimeout is ${this.player&&this.player._opt.loadingTimeout} and opt.loadingTimeoutReplay is ${this.player&&this.player._opt.loadingTimeoutReplay} and local._loadingTimeoutReplayTimes time is ${this._loadingTimeoutReplayTimes} and opt.loadingTimeoutReplayTimes is `+(this.player&&this.player._opt.loadingTimeoutReplayTimes))}).catch(e=>{this.debug.error("JbPro","loading timeout and pause error",e)})}),this.hasLoaded()?this.player.play(d,u).then(()=>{e()}).catch(e=>{this.debug.error("JbPro","hasLoaded and play error",e),this.emit(w.crashLog,this.getCrashLog("hasLoaded and play error",e)),this.player.pause().then(()=>{t(e)}).catch(e=>{this.debug.error("JbPro","hasLoaded and play error and next pause error",e)})}):this.player.once(w.decoderWorkerInit,()=>{this.player.play(d,u).then(()=>{e()}).catch(e=>{this.debug.error("JbPro","decoderWorkerInit and play error",e),this.emit(w.crashLog,this.getCrashLog("decoderWorkerInit and play error",e)),this.player&&this.player.pause().then(()=>{t(e)}).catch(e=>{this.debug.error("JbPro","decoderWorkerInit and play error and next pause error",e)})})})};n||s||i?this._resetPlayer({protocol:l,demuxType:r,isHls:n,isWebrtc:s,url:d}).then(()=>{c()}).catch(e=>{t("reset player error")}):(this.player.updateOption({protocol:l,demuxType:r,isFlv:this._opt.isFlv,cryptoKey:u.cryptoKey||"",cryptoIV:u.cryptoIV||""}),u.cryptoKey&&u.cryptoIV&&(this.player.decoderWorker&&this.player.decoderWorker.updateWorkConfig({key:"cryptoKey",value:u.cryptoKey}),this.player.decoderWorker)&&this.player.decoderWorker.updateWorkConfig({key:"cryptoIV",value:u.cryptoIV}),c())})}resize(){this.debug.log("JbPro","resize()"),this.player&&this.player.resize()}setBufferTime(e){this.debug.log("JbPro","setBufferTime() "+e),e=Number(e),this.player?(10{this.debug.log("JbPro","screenshotWatermark()",e),this.player&&this.player.video?this.player.video.screenshotWatermark(e).then(e=>{t(e)}).catch(e=>{i(e)}):(this.debug.warn("JbPro","screenshotWatermark() player is not ready"),i("player is not ready"))})}startRecord(i,r){return new Promise((e,t)=>{if(this.debug.log("JbPro",`startRecord() ${i} `+r),!this.player)return this.debug.warn("JbPro","startRecord() player is not ready"),t("player is not ready");this.player.playing?(this.player.startRecord(i,r),e()):(this.debug.warn("JbPro","startRecord() player is not playing"),t("not playing"))})}stopRecordAndSave(e,r){return new Promise((t,i)=>{this.debug.log("JbPro",`stopRecordAndSave() ${e} `+r),this.player&&this.player.recording?this.player.stopRecordAndSave(e,r).then(e=>{t(e)}).catch(e=>{i(e)}):i("not recording")})}isPlaying(){let e=!1;return this.player&&(this._opt.playType===n?e=this.player.playing:this._opt.playType===v&&(e=_(this.player.playbackPause)&&this.player.playing)),e}isLoading(){return!!this.player&&this.player.loading}isPause(){let e=!1;return this._opt.playType===n?e=!this.isPlaying()&&!this.isLoading():this._opt.playType===v&&this.player&&(e=this.player.playbackPause),e}isPaused(){return this.isPause()}isPlaybackPause(){let e=!1;return e=this._opt.playType===v&&this.player?this.player.playbackPause:e}isMute(){let e=!0;return e=this.player?this.player.isAudioMute():e}isRecording(){return this.player&&this.player.recorder&&this.player.recorder.recording||!1}clearBufferDelay(){this.debug.log("JbPro","clearBufferDelay()"),this.player?this.player.clearBufferDelay():this.debug.warn("JbPro","clearBufferDelay() player is not init")}setNetworkDelayTime(e){this.debug.log("JbPro","setNetworkDelayTime() "+e),e=Number(e),this.player?(e<1&&this.debug.warn("JbPro",`setNetworkDelayTime() network delay is ${e} second, is too small`),e=y(e,1,100),this.player.updateOption({networkDelay:1e3*e}),this.player.decoderWorker&&this.player.decoderWorker.updateWorkConfig({key:"networkDelay",value:1e3*e})):this.debug.warn("JbPro","setNetworkDelayTime() player is not init")}getDecodeType(){let e="";return e=this.player?this.player.getDecodeType():e}getRenderType(){let e="";return e=this.player?this.player.getRenderType():e}getAudioEngineType(){let e="";return e=this.player?this.player.getAudioEngineType():e}getPlayingTimestamp(){let e=0;return e=this.player?this.player.getPlayingTimestamp():e}getStatus(){let e="destroy";return e=this.player?this.player.loading?"loading":this.player.playing?"playing":"paused":e}getPlayType(){return this.player?this.player._opt.playType:n}togglePerformancePanel(e){this.debug.log("JbPro","togglePerformancePanel() "+e);var t=this.player._opt.showPerformance;let i=!t;(i=bt(e)?e:i)!==t?this.player?this.player.togglePerformancePanel(i):this.debug.warn("JbPro","togglePerformancePanel() failed, this.player is not init"):this.debug.warn("JbPro",`togglePerformancePanel() failed, showPerformance is prev: ${t} === now: `+i)}openZoom(){this.debug.log("JbPro","openZoom()"),this.player?this.player.zooming=!0:this.debug.warn("JbPro","openZoom() failed, this.player is not init")}closeZoom(){this.debug.log("JbPro","closeZoom()"),this.player?this.player.zooming=!1:this.debug.warn("JbPro","closeZoom() failed, this.player is not init")}isZoomOpen(){let e=!1;return e=this.player?this.player.zooming:e}expandZoom(){this.debug.log("JbPro","expandZoom()"),this.player&&this.player.zoom&&this.player.zooming?this.player.zoom.expandPrecision():this.debug.warn("JbPro","expandZoom() failed, zoom is not open or not init")}narrowZoom(){this.debug.log("JbPro","narrowZoom()"),this.player&&this.player.zoom&&this.player.zooming?this.player.zoom.narrowPrecision():this.debug.warn("JbPro","narrowZoom failed, zoom is not open or not init")}getCurrentZoomIndex(){let e=1;return e=this.player&&this.player.zoom?this.player.zoom.currentZoom:e}startTalk(i){let r=1{this.debug.log("JbPro","startTalk()",i,r),this._initTalk(r),this.talk.startTalk(i).then(()=>{e(),this.talk.once(w.talkStreamClose,()=>{this.debug.warn("JbPro","talk stream close"),this.stopTalk().catch(e=>{})}),this.talk.once(w.talkStreamError,e=>{this.debug.warn("JbPro","talk stream error",e),this.stopTalk().catch(e=>{})}),this.talk.once(w.talkStreamInactive,()=>{this.debug.warn("JbPro","talk stream inactive"),this.stopTalk().catch(e=>{})})}).catch(e=>{t(e)})})}stopTalk(){return new Promise((e,t)=>{if(this.debug.log("JbPro","stopTalk()"),!this.talk)return t("stopTalk() talk is not init");this.talk.destroy(),e()})}getTalkVolume(){return new Promise((e,t)=>{if(!this.talk)return t("getTalkVolume() talk is not init");e(this.talk.volume)})}setTalkVolume(i){return new Promise((e,t)=>{if(this.debug.log("JbPro","setTalkVolume()",i),!this.talk)return t("setTalkVolume() talk is not init");this.talk.setVolume(i/100),e()})}setNakedFlowFps(r){return new Promise((e,t)=>{var i;return this.debug.log("JbPro","setNakedFlowFps()",r),this.player?yt(r)?t("setNakedFlowFps() fps is empty"):(i=y(i=Number(r),1,100),void this.player.updateOption({nakedFlowFps:i})):t("setNakedFlowFps() player is not init")})}getCrashLog(e){var t=1{this.player?(this.player.downloadNakedFlowFile(),e()):t("player is not init")})}downloadTempRtpFile(){return new Promise((e,t)=>{this.talk?(this.talk.downloadRtpFile(),e()):t("talk is not init")})}}_s.ERROR=m,_s.EVENTS=d,window.JessibucaPro=_s,window.WebPlayerPro=_s;class Cs extends e{_opt={};constructor(){let t=0{if(void 0===t[e])throw new Error(`Jessibuca-pro-multi option "${e}" can not be undefined`)});var e=Ot(Ke);this._opt=Object.assign({},e,t),this.LOG_TAG="jessibucaProMulti";let i=t.container;if(!(i="string"==typeof t.container?document.querySelector(t.container):i))throw new Error("Jessibuca-pro-multi need container option");if("CANVAS"===i.nodeName||"VIDEO"===i.nodeName)throw new Error(`Jessibuca-pro-multi container type can not be ${i.nodeName} type`);i.classList.add("jessibuca-multi-container"),this.maxWindowSize=this._opt.maxSplit*this._opt.maxSplit,this.currentWindowIndex=-1,this.specialLayoutType=null,this.windowList=[],this.$container=i,this.debug=new Ye(this),this.events=new Gt(this),this._initWindows(),this._initEvents(),this._handleWindowSelect(0),this._listenFullscreenChange()}destroy(){return new Promise((e,t)=>{if(this.debug.log(this.LOG_TAG,"destroy()"),this.off(),this.events&&(this.events.destroy(),this.events=null),this.specialLayoutType=null,this.windowList){const i=[];this.windowList.forEach(e=>{e.$playerContainerEvents.forEach(e=>{e()}),e.player&&i.push(e.player.destroy())}),Promise.all(i).then(()=>{this.windowList.forEach(e=>{e.player=null}),this.windowList=[],e()}).catch(e=>{t(e)})}else e();this.debug&&this.debug.log(this.LOG_TAG,"destroy")})}_createPlayer(e){const i=this._findWindowItemIndex(e),t=this._opt,r=(t.supportDblclickContainerFullscreen&&(t.supportDblclickFullscreen=!1),new _s({...t,isMulti:!0,container:e.$player}));return Object.keys(d).forEach(t=>{r.on(d[t],e=>{this.emit(t,i,e)})}),r.on(w.close,()=>{this.emit(w.close,i),e.player=null}),r}_initWindows(){const e=this._getContainerRect(),t=e.width,i=e.height;let r="";var s,a,n,o,l=this._opt.split,c=t%l,d=i%l,u=(t-c-2*l)/l,h=(i-d-2*l)/l,p=(t-c)/l,f=(i-d)/l;for(let e=0;e=Math.pow(l,2)?d:0),n=p+(e%l==l-1?c:0),o=f+(e+l>=Math.pow(l,2)?d:0),r+=`
`;var g=`
${r}
`,m=(this.$container.innerHTML=g,this.$container.querySelectorAll(".jessibuca-multi-player"));for(let e=0;e{var i=e.$playerContainer,r=o(i,"click",()=>{this.emit(Je.selected,t),this.getSelectedWindowIndex()===t&&this.windowList[t].isContainerFullscreen||1!==this._opt.split&&this._handleWindowSelect(t)}),s=o(i,"dblclick",()=>{this.emit(Je.dblSelected,t),this._opt.supportDblclickContainerFullscreen&&1!==this._opt.split&&this._handleWindowContainerFullscreen(t)}),a=o(i,"mouseup",()=>{this.emit(Je.mouseUp,t)}),n=o(i,"mouseover",()=>{this.emit(Je.mouseOver,t)}),i=o(i,"mouseout",()=>{this.emit(Je.mouseOut,t)});e.$playerContainerEvents=[r,a,n,i,s]})}_getContainerRect(){var e=this.$container.getBoundingClientRect();return{width:Math.max(e.width,this.$container.clientWidth),height:Math.max(e.height,this.$container.clientHeight)}}_updateWindows(){const s=this._getContainerRect(),a=s.width,n=s.height,o=this._opt.split,l=a%o,c=n%o,d=(a-l-2*o)/o,u=(n-c-2*o)/o,t=(a-l)/o,i=(n-c)/o;let h=this._getCurrentMaxSplit();for(let e=0;e=Math.pow(o,2)?c:0),g=t+(e%o==o-1?l:0),m=i+(e+o>=Math.pow(o,2)?c:0);n.style.width=g+"px",n.style.height=m+"px",n.style.display="block",r.style.width=p+"px",r.style.height=f+"px",r.style.display="block",h.style.width=p+"px",h.style.height=f+"px",h.style.display="block",a.player&&a.player.resize()}if(this.specialLayoutType){const s=this.windowList[0],a=s.$playerContainer,n=s.$player,o=s.$playerBorder,l=a.style.width.replace("px",""),c=a.style.height.replace("px",""),d=n.style.width.replace("px",""),u=n.style.height.replace("px","");let e,t,i,r;this.specialLayoutType===qe?(e=2*l,t=2*c,i=2*d+2,r=2*u+2):this.specialLayoutType===Qe&&(e=3*l,t=3*c,i=3*d+4,r=3*u+4),a.style.width=e+"px",a.style.height=t+"px",n.style.width=i+"px",n.style.height=r+"px",o.style.width=i+"px",o.style.height=r+"px",s.player&&s.player.resize(),h=this._getSpecialMaxSplit()}for(let e=h;e{t.$playerBorder.style.display="block",e.$playerBorder.style.border="1px solid "+this._opt.style.border}),t.$playerBorder.style.border="1px solid "+this._opt.style.borderSelect)):this.debug.warn(this.LOG_TAG,`_handleWindowSelect() ${e} is not exist`),1===this._opt.split&&(t.$playerBorder.style.display="none")}_handleWindowContainerFullscreen(e){var t=this.windowList[e];if(t){if(t.isContainerFullscreen)t.$playerContainer.style.position="relative",t.$playerContainer.style.left="auto",t.$playerContainer.style.top="auto",t.$playerContainer.style.zIndex="auto",t.$playerContainer.style.width=t.prevInfo.playerContainerWidth,t.$playerContainer.style.height=t.prevInfo.playerContainerHeight,t.$player.style.width=t.prevInfo.playerWidth,t.$player.style.height=t.prevInfo.playerHeight,this.getSelectedWindowIndex()===e&&(t.$playerBorder.style.display="block");else{const e=this._getContainerRect(),i=e.width,r=e.height;t.prevInfo={playerContainerWidth:t.$playerContainer.style.width,playerContainerHeight:t.$playerContainer.style.height,playerWidth:t.$player.style.width,playerHeight:t.$player.style.height},t.$playerContainer.style.position="absolute",t.$playerContainer.style.top="0",t.$playerContainer.style.left="0",t.$playerContainer.style.zIndex="10",t.$playerContainer.style.width=i+"px",t.$playerContainer.style.height=r+"px",t.$player.style.width=i+"px",t.$player.style.height=r+"px",t.$playerBorder.style.display="none"}t.isContainerFullscreen=!t.isContainerFullscreen,t.player&&t.player.resize()}else this.debug.warn(this.LOG_TAG,`handleWindowContainerFullscreen() ${e} is not exist`)}_handleFullscreenResize(){let t=this._getContainerRect(),i=0;const r=setInterval(()=>{var e=this._getContainerRect();e.width===t.width&&e.height===t.height&&4{S(e)===this.$container&&(this.emit(d.fullscreen,f.isFullscreen),f.isFullscreen?this._handleFullscreenResize():this.resize())};f.on("change",e),this.events.destroys.push(()=>{f.off("change",e)})}catch(e){}}play(a,n,o){return new Promise((t,i)=>{u(n)&&(o=n,n={});const e=()=>{var e=this._createPlayer(s);(s.player=e).play(a,n).then(()=>{t()}).catch(e=>{i(e)})};var r=u(o)?o:this.currentWindowIndex;const s=this.windowList[r];s?s.player?s.player.destroy().then(()=>{s.player=null,e()}).catch(()=>{}):e():i(`play() windowIndex ${r} is not exist`)})}getOption(e){e=u(e)?e:this.currentWindowIndex;var t=this.windowList[e];return t&&t.player?t.player.getOption():(this.debug.warn(this.LOG_TAG,`getOption() windowIndex ${e} is not exist`),{})}setDebug(e,t){t=u(t)?t:this.currentWindowIndex;var i=this.windowList[t];i&&i.player?i.player.setDebug(e):this.debug.warn(this.LOG_TAG,`setDebug() windowIndex ${t} is not exist`)}mute(e){e=u(e)?e:this.currentWindowIndex;var t=this.windowList[e];t&&t.player?t.player.mute():this.debug.warn(this.LOG_TAG,`mute() windowIndex ${e} is not exist`)}cancelMute(e){e=u(e)?e:this.currentWindowIndex;var t=this.windowList[e];t&&t.player?t.player.cancelMute():this.debug.warn(this.LOG_TAG,`cancelMute() windowIndex ${e} is not exist`)}setVolume(e,t){t=u(t)?t:this.currentWindowIndex;var i=this.windowList[t];i&&i.player?i.player.setVolume(e):this.debug.warn(this.LOG_TAG,`setVolume() windowIndex ${t} is not exist`)}audioResume(e){e=u(e)?e:this.currentWindowIndex;var t=this.windowList[e];t&&t.player?t.player.audioResume():this.debug.warn(this.LOG_TAG,`audioResume() windowIndex ${e} is not exist`)}setTimeout(e,t){t=u(t)?t:this.currentWindowIndex;var i=this.windowList[t];i&&i.player?i.player.setTimeout(e):this.debug.warn(this.LOG_TAG,`setTimeout() windowIndex ${t} is not exist`)}setScaleMode(e,t){t=u(t)?t:this.currentWindowIndex;var i=this.windowList[t];i&&i.player?i.player.setScaleMode(e):this.debug.warn(this.LOG_TAG,`setScaleMode() windowIndex ${t} is not exist`)}pause(){let r=0{s=u(s)?s:this.currentWindowIndex;var i=this.windowList[s];i&&i.player?i.player.pause(r).then(()=>{e()}).catch(e=>{t(e)}):t(`pause() windowIndex ${s} is not exist`)})}close(r){return new Promise((e,t)=>{r=u(r)?r:this.currentWindowIndex;var i=this.windowList[r];i&&i.player?i.player.close().then(()=>{e()}).catch(e=>{t(e)}):t(`close() windowIndex ${r} is not exist`)})}clearView(e){e=u(e)?e:this.currentWindowIndex;var t=this.windowList[e];t&&t.player?t.player.clearView():this.debug.warn(this.LOG_TAG,`clearView() windowIndex ${e} is not exist`)}setStreamQuality(e,t){t=u(t)?t:this.currentWindowIndex;var i=this.windowList[t];i&&i.player?i.player.setStreamQuality(e):this.debug.warn(this.LOG_TAG,`setStreamQuality() windowIndex ${t} is not exist`)}resize(){this._updateWindows()}setBufferTime(e,t){t=u(t)?t:this.currentWindowIndex;var i=this.windowList[t];i&&i.player?i.player.setBufferTime(e):this.debug.warn(this.LOG_TAG,`setBufferTime() windowIndex ${t} is not exist`)}setBufferDelayTime(e,t){t=u(t)?t:this.currentWindowIndex;var i=this.windowList[t];i&&i.player?i.player.setBufferDelayTime(e):this.debug.warn(this.LOG_TAG,`setBufferDelayTime() windowIndex ${t} is not exist`)}setRotate(e,t){t=u(t)?t:this.currentWindowIndex;var i=this.windowList[t];i&&i.player?i.player.setRotate(e):this.debug.warn(this.LOG_TAG,`setRotate() windowIndex ${t} is not exist`)}setMirrorRotate(e,t){t=u(t)?t:this.currentWindowIndex;var i=this.windowList[t];i&&i.player?i.player.setMirrorRotate(e):this.debug.warn(this.LOG_TAG,`setMirrorRotate() windowIndex ${t} is not exist`)}hasLoaded(e){e=u(e)?e:this.currentWindowIndex;e=this.windowList[e];return!(!e||!e.player)&&e.player.hasLoaded()}setKeepScreenOn(e){e=u(e)?e:this.currentWindowIndex;var t=this.windowList[e];t&&t.player?t.player.setKeepScreenOn():this.debug.warn(this.LOG_TAG,`setKeepScreenOn() windowIndex ${e} is not exist`)}setFullscreen(e,t){t=u(t)?t:this.currentWindowIndex;var i=this.windowList[t];i&&i.player?i.player.setFullscreen(e):this.debug.warn(this.LOG_TAG,`setFullscreen() windowIndex ${t} is not exist`)}screenshot(e,t){t=u(t)?t:this.currentWindowIndex;t=this.windowList[t];return t&&t.player?t.player.screenshot(e.filename,e.format,e.quality,e.type):null}screenshotWatermark(e,t){t=u(t)?t:this.currentWindowIndex;t=this.windowList[t];return t&&t.player?t.player.screenshotWatermark(e):null}startRecord(r,s,a){return new Promise((e,t)=>{a=u(a)?a:this.currentWindowIndex;var i=this.windowList[a];i&&i.player?i.player.startRecord(r,s).then(()=>{e()}).catch(e=>{t(e)}):(this.debug.warn(this.LOG_TAG,`startRecord() windowIndex ${a} is not exist`),t(`windowIndex ${a} is not exist`))})}stopRecordAndSave(r,s,a){return new Promise((t,i)=>{a=u(a)?a:this.currentWindowIndex;var e=this.windowList[a];e&&e.player?e.player.stopRecordAndSave(r,s).then(e=>{t(e)}).catch(e=>{i(e)}):(this.debug.warn(this.LOG_TAG,`stopRecordAndSave() windowIndex ${a} is not exist`),i(`windowIndex ${a} is not exist`))})}isPlaying(e){e=u(e)?e:this.currentWindowIndex;var t=this.windowList[e];return t&&t.player?t.player.isPlaying():(this.debug.warn(this.LOG_TAG,`isPlaying() windowIndex ${e} is not exist`),!1)}isLoading(e){e=u(e)?e:this.currentWindowIndex;var t=this.windowList[e];return t&&t.player?t.player.isLoading():(this.debug.warn(this.LOG_TAG,`isLoading() windowIndex ${e} is not exist`),!1)}isPaused(e){e=u(e)?e:this.currentWindowIndex;var t=this.windowList[e];return t&&t.player?t.player.isPaused():(this.debug.warn(this.LOG_TAG,`windowIndex ${e} is not exist`),!1)}isMute(e){e=u(e)?e:this.currentWindowIndex;var t=this.windowList[e];return t&&t.player?t.player.isMute():(this.debug.warn(this.LOG_TAG,`isMute() windowIndex ${e} is not exist`),!1)}isRecording(e){e=u(e)?e:this.currentWindowIndex;var t=this.windowList[e];return t&&t.player?t.player.isRecording():(this.debug.warn(this.LOG_TAG,`isRecording() windowIndex ${e} is not exist`),!1)}clearBufferDelay(e){e=u(e)?e:this.currentWindowIndex;var t=this.windowList[e];t&&t.player?t.player.clearBufferDelay():this.debug.warn(this.LOG_TAG,`clearBufferDelay() windowIndex ${e} is not exist`)}setNetworkDelayTime(e,t){t=u(t)?t:this.currentWindowIndex;var i=this.windowList[t];i&&i.player?i.player.setNetworkDelayTime(e):this.debug.warn(this.LOG_TAG,`setNetworkDelayTime() windowIndex ${t} is not exist`)}getDecodeType(e){e=u(e)?e:this.currentWindowIndex;var t=this.windowList[e];return t&&t.player?t.player.getDecodeType():(this.debug.warn(this.LOG_TAG,`getDecodeType() windowIndex ${e} is not exist`),null)}getRenderType(e){e=u(e)?e:this.currentWindowIndex;var t=this.windowList[e];return t&&t.player?t.player.getRenderType():(this.debug.warn(this.LOG_TAG,`windowIndex ${e} is not exist`),null)}getAudioEngineType(e){e=u(e)?e:this.currentWindowIndex;var t=this.windowList[e];return t&&t.player?t.player.getAudioEngineType():(this.debug.warn(this.LOG_TAG,`windowIndex ${e} is not exist`),null)}getPlayingTimestamp(e){e=u(e)?e:this.currentWindowIndex;var t=this.windowList[e];return t&&t.player?t.player.getPlayingTimestamp():(this.debug.warn(this.LOG_TAG,`windowIndex ${e} is not exist`),null)}getStatus(e){e=u(e)?e:this.currentWindowIndex;var t=this.windowList[e];return t&&t.player?t.player.getStatus():(this.debug.warn(this.LOG_TAG,`getStatus() windowIndex ${e} is not exist`),null)}getPlayType(e){e=u(e)?e:this.currentWindowIndex;var t=this.windowList[e];return t&&t.player?t.player.getPlayType():(this.debug.warn(this.LOG_TAG,`getPlayType() windowIndex ${e} is not exist`),null)}togglePerformancePanel(e,t){t=u(t)?t:this.currentWindowIndex;var i=this.windowList[t];i&&i.player?i.player.togglePerformancePanel(e):this.debug.warn(this.LOG_TAG,`togglePerformancePanel() windowIndex ${t} is not exist`)}openZoom(e){e=u(e)?e:this.currentWindowIndex;var t=this.windowList[e];t&&t.player?t.player.openZoom():this.debug.warn(this.LOG_TAG,`openZoom() windowIndex ${e} is not exist`)}closeZoom(e){e=u(e)?e:this.currentWindowIndex;var t=this.windowList[e];t&&t.player?t.player.closeZoom():this.debug.warn(this.LOG_TAG,`closeZoom() windowIndex ${e} is not exist`)}isZoomOpen(e){e=u(e)?e:this.currentWindowIndex;var t=this.windowList[e];return t&&t.player?t.player.isZoomOpen():(this.debug.warn(this.LOG_TAG,`isZoomOpen() windowIndex ${e} is not exist`),!1)}expandZoom(e){e=u(e)?e:this.currentWindowIndex;var t=this.windowList[e];t&&t.player?t.player.expandZoom():this.debug.warn(this.LOG_TAG,`expandZoom() windowIndex ${e} is not exist`)}narrowZoom(e){e=u(e)?e:this.currentWindowIndex;var t=this.windowList[e];t&&t.player?t.player.narrowZoom():this.debug.warn(this.LOG_TAG,`narrowZoom() windowIndex ${e} is not exist`)}getCurrentZoomIndex(e){e=u(e)?e:this.currentWindowIndex;var t=this.windowList[e];return t&&t.player?t.player.getCurrentZoomIndex():(this.debug.warn(this.LOG_TAG,`getCurrentZoomIndex() windowIndex ${e} is not exist`),0)}setNakedFlowFps(e,t){t=u(t)?t:this.currentWindowIndex;var i=this.windowList[t];i&&i.player?i.player.setNakedFlowFps(e):this.debug.warn(this.LOG_TAG,`setNakedFlowFps() windowIndex ${t} is not exist`)}updateDebugLevel(e,t){t=u(t)?t:this.currentWindowIndex;var i=this.windowList[t];i&&i.player?i.player.updateDebugLevel(e):this.debug.warn(this.LOG_TAG,`updateDebugLevel() windowIndex ${t} is not exist`)}updateWatermark(e,t){t=u(t)?t:this.currentWindowIndex;var i=this.windowList[t];i&&i.player?i.player.updateWatermark(e):this.debug.warn(this.LOG_TAG,`updateWatermark() windowIndex ${t} is not exist`)}removeWatermark(e){e=u(e)?e:this.currentWindowIndex;var t=this.windowList[e];t&&t.player?t.player.removeWatermark():this.debug.warn(this.LOG_TAG,`removeWatermark() windowIndex ${e} is not exist`)}updateFullscreenWatermark(e,t){t=u(t)?t:this.currentWindowIndex;var i=this.windowList[t];i&&i.player?i.player.updateFullscreenWatermark(e):this.debug.warn(this.LOG_TAG,`updateFullscreenWatermark() windowIndex ${t} is not exist`)}removeFullscreenWatermark(e){e=u(e)?e:this.currentWindowIndex;var t=this.windowList[e];t&&t.player?t.player.removeFullscreenWatermark():this.debug.warn(this.LOG_TAG,`removeFullscreenWatermark() windowIndex ${e} is not exist`)}faceDetectOpen(e){e=u(e)?e:this.currentWindowIndex;var t=this.windowList[e];t&&t.player?t.player.faceDetectOpen():this.debug.warn(this.LOG_TAG,`faceDetectOpen() windowIndex ${e} is not exist`)}faceDetectClose(e){e=u(e)?e:this.currentWindowIndex;var t=this.windowList[e];t&&t.player?t.player.faceDetectClose():this.debug.warn(this.LOG_TAG,`faceDetectClose() windowIndex ${e} is not exist`)}objectDetectOpen(e){e=u(e)?e:this.currentWindowIndex;var t=this.windowList[e];t&&t.player?t.player.objectDetectOpen():this.debug.warn(this.LOG_TAG,`objectDetectOpen() windowIndex ${e} is not exist`)}objectDetectClose(e){e=u(e)?e:this.currentWindowIndex;var t=this.windowList[e];t&&t.player?t.player.objectDetectClose():this.debug.warn(this.LOG_TAG,`objectDetectClose() windowIndex ${e} is not exist`)}sendWebsocketMessage(e,t){t=u(t)?t:this.currentWindowIndex;var i=this.windowList[t];i&&i.player?i.player.sendWebsocketMessage(e):this.debug.warn(this.LOG_TAG,`sendWebsocketMessage() windowIndex ${t} is not exist`)}addContentToCanvas(e,t){t=u(t)?t:this.currentWindowIndex;var i=this.windowList[t];i&&i.player?i.player.addContentToCanvas(e):this.debug.warn(this.LOG_TAG,`addContentToCanvas() windowIndex ${t} is not exist`)}clearContentToCanvas(e){e=u(e)?e:this.currentWindowIndex;var t=this.windowList[e];t&&t.player?t.player.clearContentToCanvas():this.debug.warn(this.LOG_TAG,`clearContentToCanvas() windowIndex ${e} is not exist`)}setControlHtml(e,t){t=u(t)?t:this.currentWindowIndex;var i=this.windowList[t];i&&i.player?i.player.setControlHtml(e):this.debug.warn(this.LOG_TAG,`setControlHtml() windowIndex ${t} is not exist`)}clearControlHtml(e){e=u(e)?e:this.currentWindowIndex;var t=this.windowList[e];t&&t.player?t.player.clearControlHtml():this.debug.warn(this.LOG_TAG,`clearControlHtml() windowIndex ${e} is not exist`)}destroySingle(r){return new Promise((e,t)=>{r=u(r)?r:this.currentWindowIndex;const i=this.windowList[r];i?i.player&&i.player.destroy().then(()=>{i.player=null,e()}).catch(e=>{t(e)}):(t("windowIndex is not exist"),this.debug.warn(this.LOG_TAG,`destroySingle() windowIndex ${r} is not exist`))})}setFullscreenMulti(i){return new Promise((e,t)=>{if(this.debug.log(this.LOG_TAG,"setFullscreenMulti",i),i)try{f.request(this.$container).then(()=>{e()}).catch(e=>{this.debug.error(this.LOG_TAG,"fullscreen request inner error",e),t(e)})}catch(e){this.debug.error(this.LOG_TAG,"fullscreen request error",e),t(e)}else try{f.exit().then(()=>{e()}).catch(e=>{this.debug.error(this.LOG_TAG,"fullscreen exit inner error",e),t(e)})}catch(e){this.debug.error(this.LOG_TAG,"fullscreen exit error",e),t(e)}})}selectWindow(e){this.debug.log(this.LOG_TAG,"selectWindow",e),this._handleWindowSelect(e)}arrangeWindow(e){this.debug.log(this.LOG_TAG,"arrangeWindow",e),e?[qe,Qe].includes(e)?this._arrangeSpecialWindow(e):this._opt.split===e&&null===this.specialLayoutType?this.debug.warn(this.LOG_TAG,`arrangeWindow() split ${e} is not changed`):(this.specialLayoutType=null,this._arrangeWindow(e)):this.debug.warn(this.LOG_TAG,`arrangeWindow() split ${e} is not valid`)}_arrangeWindow(e){(e=T(e))<1||!u(e)?this.debug.warn(this.LOG_TAG,`arrangeWindow() split ${e} is not valid`):(e>this._opt.maxSplit&&(e=this._opt.maxSplit),this._opt.split=e,this.currentWindowIndex=0,this._updateWindows(),this._handleWindowSelect(this.currentWindowIndex))}_arrangeSpecialWindow(e){this._opt.maxSplit<=3&&e===Qe||this._opt.maxSplit<=2&&e===qe?this.debug.warn(this.LOG_TAG,`_arrangeSpecialWindow() type ${e} is not valid because maxSplit is `+this._opt.maxSplit):this.specialLayoutType&&this.specialLayoutType===e?this.debug.warn(this.LOG_TAG,`_arrangeSpecialWindow() type ${e} is not changed`):(this.specialLayoutType=e)===qe?this._arrangeWindow(3):e===Qe?this._arrangeWindow(4):this.debug.warn(this.LOG_TAG,`_arrangeSpecialWindow() type ${e} is not valid`)}getCurrentSplit(){return this.specialLayoutType||this._opt.split}_getCurrentMaxSplit(){if(this.specialLayoutType){let e=0;return this.specialLayoutType===qe?e=9:this.specialLayoutType===Qe&&(e=16),e}return this._opt.split*this._opt.split}_getSpecialMaxSplit(){let e=0;return this.specialLayoutType===qe?e=6:this.specialLayoutType===Qe&&(e=8),e}getSelectedWindowIndex(){return this.currentWindowIndex}_findWindowItemIndex(t){return this.windowList.findIndex(e=>e.uuid===t.uuid)}}Cs.MULTI_EVENTS=Je,Cs.EVENTS=w,Cs.ERROR=m,window.JessibucaProMulti=Cs,window.WebPlayerProMulti=Cs});