jessibuca-pro.js 1.6 MB

1
  1. !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("crypto")):"function"==typeof define&&define.amd?define(["crypto"],t):(e="undefined"!=typeof globalThis?globalThis:e||self)["jessibuca-pro"]=t(e.crypto$1)}(this,(function(t){"use strict";function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=s(t);const a=1,o=2,n=3,l=4,d=5,h=6,c=["","websocket","fetch","hls","webrtc","webTransport","aliyunRtc","ts"],u="fetch",p="hls",f="websocket",m="webrtc",g="webTransport",y="worker",A="aliyunRtc",b="player",_="playerAudio",v="playbackTF",S="mp4",w="webm",E="flv",T="flv",k="m7s",C="hls",R="webrtc",x="webTransport",D="nakedFlow",L="fmp4",P="mpeg4",B="aliyunRtc",I="ts",M={flv:"FLV",m7s:"M7S",hls:"HLS",fmp4:"FMP4",mpeg4:"MPEG4",webrtc:"Webrtc",webTransport:"WebTransport",nakedFlow:"裸流",aliyunRtc:"AliyunRtc",ts:"TS"},U="mse",F="wcs",O="offscreen",N="wasm",j="simd",z="mt",G="webrtc",H="hls",$="aliyunRtc",V="canvas",W="video",J="debug",q="warn",K="click",Y="mouseDownAndUp",Q={normal:"normal",simple:"simple"},X=36e5,Z="/crypto/",ee="jbprov",te=1e4,ie={url:"",playbackConfig:{},fullscreenWatermarkConfig:{},playType:b,playbackForwardMaxRateDecodeIFrame:4,playOptions:{},isLive:!0,isMulti:!0,isM7sCrypto:!1,supportHls265:!1,playFailedUseLastFrameShow:!0,playFailedAndPausedShowMessage:!1,pauseAndNextPlayUseLastFrameShow:!1,widthOrHeightChangeReplayDelayTime:0,isUseNewFullscreenWatermark:!1,websocket1006ErrorReplay:!1,websocket1006ErrorReplayDelayTime:1,streamErrorReplay:!1,streamErrorReplayDelayTime:1,streamEndReplay:!1,streamEndReplayDelayTime:1,networkDisconnectReplay:!1},se={playType:b,container:"",videoBuffer:1e3,videoBufferDelay:1e3,networkDelay:1e4,isResize:!0,isFullResize:!1,isFlv:!1,isHls:!1,isFmp4:!1,isFmp4Private:!1,isWebrtc:!1,isWebrtcForZLM:!1,isWebrtcForSRS:!1,isWebrtcForOthers:!1,isNakedFlow:!1,isMpeg4:!1,isAliyunRtc:!1,isTs:!1,debug:!1,debugLevel:q,debugUuid:"",isMulti:!0,multiIndex:-1,hotKey:!1,loadingTimeout:10,heartTimeout:10,timeout:10,pageVisibilityHiddenTimeout:300,loadingTimeoutReplay:!0,heartTimeoutReplay:!0,loadingTimeoutReplayTimes:3,heartTimeoutReplayTimes:3,heartTimeoutReplayUseLastFrameShow:!0,replayUseLastFrameShow:!0,replayShowLoadingIcon:!1,supportDblclickFullscreen:!1,showBandwidth:!1,showPerformance:!1,mseCorrectTimeDuration:20,mseCorrectAudioTimeDuration:20,keepScreenOn:!0,isNotMute:!1,muted:!0,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,logSave:!1,aiFace:!1,aiObject:!1,aiOcclusion:!1,fullscreenFn:null,fullscreenExitFn:null,screenshotFn:null,playFn:null,pauseFn:null,recordFn:null,recordStopFn:null},extendOperateBtns:[],contextmenuBtns:[],watermarkConfig:{},controlAutoHide:!1,hasControl:!1,loadingIcon:!0,loadingIconStyle:{},loadingText:"",background:"",poster:"",backgroundLoadingShow:!0,loadingBackground:"",loadingBackgroundWidth:0,loadingBackgroundHeight:0,decoder:"decoder-pro.js",decoderAudio:"decoder-pro-audio.js",decoderHard:"decoder-pro-hard.js",decoderHardNotWasm:"decoder-pro-hard-not-wasm.js",wasmMp4RecorderDecoder:"jessibuca-pro-mp4-recorder-decoder.js",decoderWASM:"",isDecoderUseCDN:!1,url:"",rotate:0,mirrorRotate:"none",aspectRatio:"default",playbackConfig:{playList:[],fps:"",showControl:!0,controlType:Q.normal,duration:0,startTime:"",showRateBtn:!1,rateConfig:[],showPrecision:"",showPrecisionBtn:!0,isCacheBeforeDecodeForFpsRender:!1,uiUsePlaybackPause:!1,isPlaybackPauseClearCache:!0,isUseFpsRender:!1,isUseLocalCalculateTime:!1,localOneFrameTimestamp:40,supportWheel:!1,useWCS:!1,useMSE:!1},qualityConfig:[],defaultStreamQuality:"",scaleConfig:["拉伸","缩放","正常"],forceNoOffscreen:!0,hiddenAutoPause:!1,protocol:o,demuxType:T,useWasm:!1,useMSE:!1,useWCS:!1,useSIMD:!0,useMThreading:!1,wcsUseVideoRender:!0,wcsUseWebgl2Render:!0,wasmUseVideoRender:!0,mseUseCanvasRender:!1,hlsUseCanvasRender:!1,webrtcUseCanvasRender:!1,useOffscreen:!1,useWebGPU:!1,mseDecodeErrorReplay:!0,wcsDecodeErrorReplay:!0,wasmDecodeErrorReplay:!0,simdDecodeErrorReplay:!0,simdDecodeErrorReplayType:N,autoWasm:!0,decoderErrorAutoWasm:!0,hardDecodingNotSupportAutoWasm:!0,webglAlignmentErrorReplay:!0,webglContextLostErrorReplay:!0,openWebglAlignment:!1,syncAudioAndVideo:!1,syncAudioAndVideoDiff:500,playbackDelayTime:1e3,playbackFps:25,playbackForwardMaxRateDecodeIFrame:4,playbackCurrentTimeMove:!0,useVideoRender:!0,useCanvasRender:!1,networkDelayTimeoutReplay:!1,recordType:S,checkFirstIFrame:!0,nakedFlowFps:25,audioEngine:null,isShowRecordingUI:!0,isShowZoomingUI:!0,useFaceDetector:!1,useObjectDetector:!1,useImageDetector:!1,useOcclusionDetector:!1,ptzPositionConfig:{},ptzShowType:"vertical",ptzClickType:K,ptzStopEmitDelay:.3,ptzZoomShow:!1,ptzApertureShow:!1,ptzFocusShow:!1,ptzMoreArrowShow:!1,ptzCruiseShow:!1,ptzFogShow:!1,ptzWiperShow:!1,ptzSupportDraggable:!1,weiXinInAndroidAudioBufferSize:4800,isM7sCrypto:!1,m7sCryptoAudio:!1,isSm4Crypto:!1,isXorCrypto:!1,sm4CryptoKey:"",m7sCryptoKey:"",xorCryptoKey:"",cryptoKey:"",cryptoIV:"",cryptoKeyUrl:"",autoResize:!1,useWebFullScreen:!1,ptsMaxDiff:3600,aiFaceDetectLevel:2,aiFaceDetectWidth:240,aiFaceDetectShowRect:!0,aiFaceDetectInterval:1e3,aiFaceDetectRectConfig:{},aiObjectDetectLevel:2,aiObjectDetectWidth:240,aiObjectDetectShowRect:!0,aiObjectDetectInterval:1e3,aiObjectDetectRectConfig:{},aiOcclusionDetectInterval:1e3,aiImageDetectDrop:!1,aiImageDetectActive:!1,videoRenderSupportScale:!0,mediaSourceTsIsMaxDiffReplay:!0,controlHtml:"",isH265:!1,isWebrtcH265:!1,supportLockScreenPlayAudio:!0,supportHls265:!1,isEmitSEI:!1,pauseAndNextPlayUseLastFrameShow:!1,demuxUseWorker:!0,playFailedAndReplay:!0,showMessageConfig:{webglAlignmentError:"Webgl 渲染失败",webglContextLostError:"webgl 上下文丢失",mediaSourceH265NotSupport:"不支持硬解码H265",mediaSourceFull:"缓冲区已满",mediaSourceAppendBufferError:"初始化解码器失败",mseSourceBufferError:"解码失败",mseAddSourceBufferError:"初始化解码器失败",mediaSourceDecoderConfigurationError:"初始化解码器失败",mediaSourceTsIsMaxDiff:"流异常",mseWidthOrHeightChange:"流异常",mediaSourceAudioG711NotSupport:"硬解码不支持G711a/u音频格式",mediaSourceUseCanvasRenderPlayFailed:"MediaSource解码使用canvas渲染失败",webcodecsH265NotSupport:"不支持硬解码H265",webcodecsUnsupportedConfigurationError:"初始化解码器失败",webcodecsDecodeConfigureError:"初始化解码器失败",webcodecsDecodeError:"解码失败",wcsWidthOrHeightChange:"解码失败",wasmDecodeError:"解码失败",simdDecodeError:"解码失败",wasmWidthOrHeightChange:"流异常",wasmUseVideoRenderError:"video自动渲染失败",videoElementPlayingFailed:"video自动渲染失败",simdH264DecodeVideoWidthIsTooLarge:"不支持该分辨率的视频",networkDelayTimeout:"网络超时重播失败",fetchError:"请求失败",streamEnd:"请求结束",websocketError:"请求失败",webrtcError:"请求失败",hlsError:"请求失败",decoderWorkerInitError:"初始化worker失败",videoElementPlayingFailedForWebrtc:"video自动渲染失败",videoInfoError:"解析视频分辨率失败",webrtcStreamH265:"webrtc不支持H265",delayTimeout:"播放超时重播失败",loadingTimeout:"加载超时重播失败",loadingTimeoutRetryEnd:"加载超时重播失败",delayTimeoutRetryEnd:"播放超时重播失败"},videoElementPlayingFailedReplay:!0,mp4RecordUseWasm:!0,mseAutoCleanupSourceBuffer:!0,mseAutoCleanupMaxBackwardDuration:30,mseAutoCleanupMinBackwardDuration:10,widthOrHeightChangeReplay:!0,simdH264DecodeVideoWidthIsTooLargeReplay:!0,mediaSourceAudioG711NotSupportReplay:!0,mediaSourceAudioInitTimeoutReplay:!0,mediaSourceUseCanvasRenderPlayFailedReplay:!0,mediaSourceUseCanvasRenderPlayFailedReplayType:W,widthOrHeightChangeReplayDelayTime:0,ghostWatermarkConfig:{on:5,off:5,content:"",fontSize:12,color:"white",opacity:.15,speed:.2},dynamicWatermarkConfig:{content:"",speed:.2,fontSize:12,color:"white",opacity:.15},isDropSameTimestampGop:!1,mseDecodeAudio:!1,nakedFlowH265DemuxUseNew:!0,extendDomConfig:{html:"",showBeforePlay:!1,showAfterLoading:!0},disableContextmenu:!1,mseDecoderUseWorker:!1,openMemoryLog:!1,mainThreadFetchUseWorker:!0,playFailedAndPausedShowPlayBtn:!0,mseCorrectionTimestamp:!0,flvDemuxBufferSizeTooLargeReplay:!1,flvDemuxBufferSizeTooLargeEmitFailed:!1,flvDemuxBufferSizeMaxLarge:1048576,isCheckInView:!1,hiddenControl:!1},re="init",ae="initVideo",oe="render",ne="playAudio",le="initAudio",de="audioCode",he="audioNalu",ce="audioAACSequenceHeader",ue="videoCode",pe="videoCodec",fe="videoNalu",me="videoPayload",ge="audioPayload",ye="wasmError",Ae="workerFetch",be="iframeIntervalTs",_e="isDropping",ve="workerEnd",Se="playbackStreamVideoFps",we="wasmDecodeVideoNoResponseError",Ee="wasmWidthOrHeightChange",Te="simdDecodeError",ke="simdH264DecodeVideoWidthIsTooLarge",Ce="closeEnd",Re="tempStream",xe="videoSEI",De="flvScriptData",Le="aacSequenceHeader",Pe="videoSequenceHeader",Be="flvBufferData",Ie="checkFirstIFrame",Me="mseHandle",Ue="mseFirstRenderTime",Fe="mseError",Oe="Invalid NAL unit size",Ne=1,je=2,ze=8,Ge=9,He=18,$e="init",Ve="decode",We="audioDecode",Je="videoDecode",qe="close",Ke="updateConfig",Ye="clearBuffer",Qe="fetchStream",Xe="sendWsMessage",Ze="mseUpdateVideoTimestamp",et="fetch",tt="destroy",it="destroyEnd",st="buffer",rt="fetchError",at="fetchClose",ot="fetchSuccess",nt={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",videoSmooth:"videoSmooth",faceDetectActive:"faceDetectActive",objectDetectActive:"objectDetectActive",occlusionDetectActive:"occlusionDetectActive",imageDetectActive:"imageDetectActive",record:"record",recording:"recording",recordingTimestamp:"recordingTimestamp",recordStart:"recordStart",recordEnd:"recordEnd",recordCreateError:"recordCreateError",recordBlob:"recordBlob",buffer:"buffer",videoFrame:"videoFrame",videoSEI:"videoSEI",start:"start",metadata:"metadata",resize:"resize",volumechange:"volumechange",volume:"volume",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",mseSourceStartStreaming:"mseSourceStartStreaming",mseSourceEndStreaming:"mseSourceEndStreaming",mseSourceBufferError:"mseSourceBufferError",mseAddSourceBufferError:"mseAddSourceBufferError",mseSourceBufferBusy:"mseSourceBufferBusy",mseSourceBufferFull:"mseSourceBufferFull",videoWaiting:"videoWaiting",videoTimeUpdate:"videoTimeUpdate",videoSyncAudio:"videoSyncAudio",playToRenderTimes:"playToRenderTimes",playbackTime:"playbackTime",playbackTimestamp:"playbackTimestamp",playbackTimeScroll:"playbackTimeScroll",playbackPrecision:"playbackPrecision",playbackShowPrecisionChange:"playbackShowPrecisionChange",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",webrtcOnConnectionStateChange:"webrtcOnConnectionStateChange",webrtcOnIceConnectionStateChange:"webrtcOnIceConnectionStateChange",crashLog:"crashLog",focus:"focus",blur:"blur",inView:"inView",visibilityHiddenTimeout:"visibilityHiddenTimeout",websocketOpen:"websocketOpen",websocketClose:"websocketClose",websocketError:"websocketError",websocketMessage:"websocketMessage",aiObjectDetectorInfo:"aiObjectDetectorInfo",aiFaceDetectorInfo:"aiFaceDetectorInfo",aiOcclusionDetectResult:"aiOcclusionDetectResult",aiImageDetectResult:"aiImageDetectResult",playFailedAndPaused:"playFailedAndPaused",audioResumeState:"audioResumeState",webrtcStreamH265:"webrtcStreamH265",flvMetaData:"flvMetaData",talkFailedAndStop:"talkFailedAndStop",removeLoadingBgImage:"removeLoadingBgImage",memoryLog:"memoryLog",downloadMemoryLog:"downloadMemoryLog",pressureObserverCpu:"pressureObserverCpu",currentPts:"currentPts",online:"online",offline:"offline",networkState:"networkState"},lt={load:nt.load,timeUpdate:nt.timeUpdate,videoInfo:nt.videoInfo,audioInfo:nt.audioInfo,error:nt.error,kBps:nt.kBps,start:nt.start,timeout:nt.timeout,loadingTimeout:nt.loadingTimeout,loadingTimeoutRetryEnd:nt.loadingTimeoutRetryEnd,delayTimeout:nt.delayTimeout,delayTimeoutRetryEnd:nt.delayTimeoutRetryEnd,fullscreen:"fullscreen",webFullscreen:nt.webFullscreen,play:nt.play,pause:nt.pause,mute:nt.mute,stats:nt.stats,performance:nt.performance,recordingTimestamp:nt.recordingTimestamp,recordStart:nt.recordStart,recordCreateError:nt.recordCreateError,recordEnd:nt.recordEnd,recordBlob:nt.recordBlob,playToRenderTimes:nt.playToRenderTimes,playbackSeek:nt.playbackSeek,playbackStats:nt.playbackStats,playbackTimestamp:nt.playbackTimestamp,playbackPauseOrResume:nt.playbackPauseOrResume,playbackPreRateChange:nt.playbackPreRateChange,playbackRateChange:nt.playbackRateChange,playbackShowPrecisionChange:nt.playbackShowPrecisionChange,ptz:nt.ptz,streamQualityChange:nt.streamQualityChange,zooming:nt.zooming,crashLog:nt.crashLog,focus:nt.focus,blur:nt.blur,visibilityHiddenTimeout:nt.visibilityHiddenTimeout,visibilityChange:nt.visibilityChange,websocketOpen:nt.websocketOpen,websocketClose:nt.websocketClose,networkDelayTimeout:nt.networkDelayTimeout,aiObjectDetectorInfo:nt.aiObjectDetectorInfo,aiFaceDetectorInfo:nt.aiFaceDetectorInfo,aiOcclusionDetectResult:nt.aiOcclusionDetectResult,aiImageDetectResult:nt.aiImageDetectResult,playFailedAndPaused:nt.playFailedAndPaused,streamEnd:nt.streamEnd,audioResumeState:nt.audioResumeState,videoSEI:nt.videoSEI,flvMetaData:nt.flvMetaData,webrtcOnConnectionStateChange:nt.webrtcOnConnectionStateChange,webrtcOnIceConnectionStateChange:nt.webrtcOnIceConnectionStateChange,currentPts:nt.currentPts,videoSmooth:nt.videoSmooth,networkState:nt.networkState,volume:nt.volume},dt={talkStreamClose:nt.talkStreamClose,talkStreamError:nt.talkStreamError,talkStreamInactive:nt.talkStreamInactive,talkGetUserMediaTimeout:nt.talkGetUserMediaTimeout,talkFailedAndStop:nt.talkFailedAndStop},ht={talkStreamError:nt.talkStreamError,talkStreamClose:nt.talkStreamClose},ct={playError:"playIsNotPauseOrUrlIsNull",fetchError:"fetchError",websocketError:"websocketError",webcodecsH265NotSupport:"webcodecsH265NotSupport",webcodecsDecodeError:"webcodecsDecodeError",webcodecsUnsupportedConfigurationError:"webcodecsUnsupportedConfigurationError",webcodecsDecodeConfigureError:"webcodecsDecodeConfigureError",mediaSourceH265NotSupport:"mediaSourceH265NotSupport",mediaSourceAudioG711NotSupport:"mediaSourceAudioG711NotSupport",mediaSourceAudioInitTimeout:"mediaSourceAudioInitTimeout",mediaSourceAudioNoDataTimeout:"mediaSourceAudioNoDataTimeout",mediaSourceDecoderConfigurationError:"mediaSourceDecoderConfigurationError",mediaSourceFull:nt.mseSourceBufferFull,mseSourceBufferError:nt.mseSourceBufferError,mseAddSourceBufferError:nt.mseAddSourceBufferError,mediaSourceAppendBufferError:"mediaSourceAppendBufferError",mediaSourceTsIsMaxDiff:"mediaSourceTsIsMaxDiff",mediaSourceUseCanvasRenderPlayFailed:"mediaSourceUseCanvasRenderPlayFailed",mediaSourceBufferedIsZeroError:"mediaSourceBufferedIsZeroError",wasmDecodeError:"wasmDecodeError",wasmUseVideoRenderError:"wasmUseVideoRenderError",hlsError:"hlsError",webrtcError:"webrtcError",webrtcClosed:nt.webrtcClosed,webrtcIceCandidateError:"webrtcIceCandidateError",webglAlignmentError:"webglAlignmentError",wasmWidthOrHeightChange:"wasmWidthOrHeightChange",mseWidthOrHeightChange:"mseWidthOrHeightChange",wcsWidthOrHeightChange:"wcsWidthOrHeightChange",widthOrHeightChange:"widthOrHeightChange",tallWebsocketClosedByError:"tallWebsocketClosedByError",flvDemuxBufferSizeTooLarge:nt.flvDemuxBufferSizeTooLarge,wasmDecodeVideoNoResponseError:"wasmDecodeVideoNoResponseError",audioChannelError:"audioChannelError",simdH264DecodeVideoWidthIsTooLarge:"simdH264DecodeVideoWidthIsTooLarge",simdDecodeError:"simdDecodeError",webglContextLostError:"webglContextLostError",videoElementPlayingFailed:"videoElementPlayingFailed",videoElementPlayingFailedForWebrtc:"videoElementPlayingFailedForWebrtc",decoderWorkerInitError:"decoderWorkerInitError",videoInfoError:"videoInfoError",videoCodecIdError:"videoCodecIdError",streamEnd:nt.streamEnd,websocket1006Error:"websocket1006Error",delayTimeout:nt.delayTimeout,loadingTimeout:nt.loadingTimeout,networkDelayTimeout:nt.networkDelayTimeout,aliyunRtcError:"aliyunRtcError",...ht},ut="notConnect",pt="open",ft="close",mt="error",gt={download:"download",base64:"base64",blob:"blob"},yt="download",At="blob",bt={7:"H264(AVC)",12:"H265(HEVC)",99:"MPEG4"},_t=7,vt=12,St="H264(AVC)",wt="H265(HEVC)",Et={AAC:10,ALAW:7,MULAW:8,MP3:2},Tt={AAC:"AAC",ALAW:"ALAW(g711a)",MULAW:"MULAW(g711u)",MP3:"MP3"},kt={10:"AAC",7:"ALAW",8:"MULAW",2:"MP3"},Ct={sps:7,pps:8,iFrame:5,kUnspecified:0,kSliceNonIDR:1,kSliceDPA:2,kSliceDPB:3,kSliceDPC:4,kSliceIDR:5,kSliceSEI:6,kSliceSPS:7,kSlicePPS:8,kSliceAUD:9,kEndOfSequence:10,kEndOfStream:11,kFiller:12,kSPSExt:13,kReserved0:14},Rt=19,xt=20,Dt=21,Lt=32,Pt=32,Bt=33,It=33,Mt=34,Ut=34,Ft=39,Ot=39,Nt=40,jt=38,zt=48,Gt=0,Ht=1,$t=2,Vt="webcodecs",Wt="webgl",Jt="webgl2",qt="webgpu",Kt="offscreen",Yt="mse",Qt="hls",Xt="webrtc",Zt="key",ei="delta",ti='video/mp4; codecs="avc1.64002A"',ii='video/mp4; codecs="hev1.1.6.L123.b0"',si='video/mp4;codecs="hev1.1.6.L120.90"',ri='video/mp4;codecs="hev1.2.4.L120.90"',ai='video/mp4;codecs="hev1.3.E.L120.90"',oi='video/mp4;codecs="hev1.4.10.L120.90"',ni="ended",li="open",di="closed",hi=2e3,ci=27,ui=38,pi=40,fi="oneHour",mi="halfHour",gi="tenMin",yi="fiveMin",Ai={oneHour:"one-hour",halfHour:"half-hour",tenMin:"ten-min",fiveMin:"five-min"},bi=["oneHour","halfHour","tenMin","fiveMin"],_i=["up","right","down","left","left-up","right-up","left-down","right-down"],vi="stop",Si="fiStop",wi="zoomExpand",Ei="zoomNarrow",Ti="apertureFar",ki="apertureNear",Ci="focusFar",Ri="focusNear",xi="cruiseStart",Di="cruiseStop",Li="fogOpen",Pi="fogClose",Bi="wiperOpen",Ii="wiperClose",Mi="g711a",Ui="g711u",Fi="pcm",Oi="opus",Ni={png:"image/png",jpeg:"image/jpeg",webp:"image/webp"},ji="sourceclose",zi="sourceopen",Gi="sourceended",Hi="startstreaming",$i="endstreaming",Vi="qualitychange",Wi="canplay",Ji="waiting",qi="timeupdate",Ki="ratechange",Yi="avc",Qi="hevc",Xi="A key frame is required after configure() or flush()",Zi="Cannot call 'decode' on a closed codec",es="Unsupported configuration",ts="Decoder failure",is="Decoding error",ss="Decoder error",rs="HEVC decoding is not supported",as="The user aborted a request",os="AbortError",ns="AbortError",ls="loading",ds="playing",hs="paused",cs="destroy",us=0,ps=1,fs=8,ms=0,gs=98,ys="empty",As="rtp",bs="tcp",_s="open",vs="close",Ss="error",ws="message",Es="worklet",Ts="script",ks={encType:Mi,packetType:As,packetTcpSendType:bs,rtpSsrc:"0000000000",numberChannels:1,sampleRate:8e3,sampleBitsWidth:16,sendInterval:20,debug:!1,debugLevel:q,testMicrophone:!1,saveToTempFile:!1,audioBufferLength:160,engine:Es,checkGetUserMediaTimeout:!1,getUserMediaTimeout:1e4,audioConstraints:{latency:!0,noiseSuppression:!0,autoGainControl:!0,echoCancellation:!0,sampleRate:48e3,channelCount:1}},Cs="worklet",Rs="script",xs="active",Ds={name:"",index:0,icon:"",iconHover:"",iconTitle:"",activeIcon:"",activeIconHover:"",activeIconTitle:"",click:null,activeClick:null},Ls={content:"",click:null,index:0},Ps=1,Bs="subtitle-segments",Is="hls-manifest-loaded",Ms="hls-level-loaded",Us="demuxed-track",Fs="flv-script-data",Os="metadata-parsed",Ns="ttfb",js="load-retry",zs="load-start",Gs="speed",Hs="load-complete",$s="load-response-headers",Vs="sei",Ws="sei-in-time",Js="switch-url-failed",qs="switch-url-success",Ks="subtitle-playlist",Ys="stream-parsed",Qs="error",Xs=[0,160,240,320,480,640],Zs=[0,160,240,320,480,640],er=["轻松","正常","较高","高"],tr="idle",ir="buffering",sr="complete",rr={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"},ar="video decoder initialization failed",or="audio packet",nr=1,lr=2,dr=0,hr=1,cr=3,ur=16,pr="candidate-pair",fr="inbound-rtp",mr="local-candidate",gr="remote-candidate",yr="track",Ar=9e4,br=45e4,_r=9e4,vr="ws1006",Sr="mseDecodeError",wr="wcsDecodeError";class Er{constructor(e){this.log=function(t){if(e._opt.debug&&e._opt.debugLevel==J){const a=e._opt.debugUuid?`[${e._opt.debugUuid}]`:"";for(var i=arguments.length,s=new Array(i>1?i-1:0),r=1;r<i;r++)s[r-1]=arguments[r];console.log(`JbPro${a}[✅✅✅][${t}]`,...s)}},this.warn=function(t){if(e._opt.debug&&(e._opt.debugLevel==J||e._opt.debugLevel==q)){const a=e._opt.debugUuid?`[${e._opt.debugUuid}]`:"";for(var i=arguments.length,s=new Array(i>1?i-1:0),r=1;r<i;r++)s[r-1]=arguments[r];console.log(`JbPro${a}[❗❗❗][${t}]`,...s)}},this.error=function(t){const i=e._opt.debugUuid?`[${e._opt.debugUuid}]`:"";for(var s=arguments.length,r=new Array(s>1?s-1:0),a=1;a<s;a++)r[a-1]=arguments[a];console.error(`JbPro${i}[❌❌❌][${t}]`,...r)}}}var Tr="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function kr(e,t){return e(t={exports:{}},t.exports),t.exports}var Cr=kr((function(e){!function(){var t="undefined"!=typeof window&&void 0!==window.document?window.document:{},i=e.exports,s=function(){for(var e,i=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror"],["webkitRequestFullScreen","webkitCancelFullScreen","webkitCurrentFullScreenElement","webkitCancelFullScreen","webkitfullscreenchange","webkitfullscreenerror"],["mozRequestFullScreen","mozCancelFullScreen","mozFullScreenElement","mozFullScreenEnabled","mozfullscreenchange","mozfullscreenerror"],["msRequestFullscreen","msExitFullscreen","msFullscreenElement","msFullscreenEnabled","MSFullscreenChange","MSFullscreenError"]],s=0,r=i.length,a={};s<r;s++)if((e=i[s])&&e[1]in t){for(s=0;s<e.length;s++)a[i[0][s]]=e[s];return a}return!1}(),r={change:s.fullscreenchange,error:s.fullscreenerror},a={request:function(e,i){return new Promise(function(r,a){var o=function(){this.off("change",o),r()}.bind(this);this.on("change",o);var n=(e=e||t.documentElement)[s.requestFullscreen](i);n instanceof Promise&&n.then(o).catch(a)}.bind(this))},exit:function(){return new Promise(function(e,i){if(this.isFullscreen){var r=function(){this.off("change",r),e()}.bind(this);this.on("change",r);var a=t[s.exitFullscreen]();a instanceof Promise&&a.then(r).catch(i)}else e()}.bind(this))},toggle:function(e,t){return this.isFullscreen?this.exit():this.request(e,t)},onchange:function(e){this.on("change",e)},onerror:function(e){this.on("error",e)},on:function(e,i){var s=r[e];s&&t.addEventListener(s,i,!1)},off:function(e,i){var s=r[e];s&&t.removeEventListener(s,i,!1)},raw:s};s?(Object.defineProperties(a,{isFullscreen:{get:function(){return Boolean(t[s.fullscreenElement])}},element:{enumerable:!0,get:function(){return t[s.fullscreenElement]}},isEnabled:{enumerable:!0,get:function(){return Boolean(t[s.fullscreenEnabled])}}}),i?e.exports=a:window.screenfull=a):i?e.exports={isEnabled:!1}:window.screenfull={isEnabled:!1}}()}));Cr.isEnabled;class Rr{constructor(e){this._buffer=e,this._buffer_index=0,this._total_bytes=e.byteLength,this._total_bits=8*e.byteLength,this._current_word=0,this._current_word_bits_left=0}destroy(){this._buffer=null}_fillCurrentWord(){let e=this._total_bytes-this._buffer_index;if(e<=0)return void console.error("ExpGolomb: _fillCurrentWord() but no bytes available",this._total_bytes,this._buffer_index);let t=Math.min(4,e),i=new Uint8Array(4);i.set(this._buffer.subarray(this._buffer_index,this._buffer_index+t)),this._current_word=new DataView(i.buffer).getUint32(0,!1),this._buffer_index+=t,this._current_word_bits_left=8*t}readBits(e){if(e>32&&console.error("ExpGolomb: readBits() bits exceeded max 32bits!"),e<=this._current_word_bits_left){let t=this._current_word>>>32-e;return this._current_word<<=e,this._current_word_bits_left-=e,t}let t=this._current_word_bits_left?this._current_word:0;t>>>=32-this._current_word_bits_left;let i=e-this._current_word_bits_left;this._fillCurrentWord();let s=Math.min(i,this._current_word_bits_left),r=this._current_word>>>32-s;return this._current_word<<=s,this._current_word_bits_left-=s,t=t<<s|r,t}readBool(){return 1===this.readBits(1)}readByte(){return this.readBits(8)}_skipLeadingZero(){let e;for(e=0;e<this._current_word_bits_left;e++)if(this._current_word&2147483648>>>e)return this._current_word<<=e,this._current_word_bits_left-=e,e;return this._fillCurrentWord(),e+this._skipLeadingZero()}readUEG(){let e=this._skipLeadingZero();return this.readBits(e+1)-1}readSEG(){let e=this.readUEG();return 1&e?e+1>>>1:-1*(e>>>1)}}const xr=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350,-1,-1,-1],Dr=xr,Lr=xr;function Pr(e){let{profile:t,sampleRate:i,channel:s}=e;return new Uint8Array([175,0,t<<3|(14&i)>>1,(1&i)<<7|s<<3])}function Br(e){return Ir(e)&&e[1]===us}function Ir(e){return e[0]>>4===Et.AAC}function Mr(e,t){if("mp4a.40.2"===e){if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(6===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(1===t)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(3===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}}function Ur(e){return 1024*(arguments.length>1&&void 0!==arguments[1]?arguments[1]:9e4)/e}const Fr=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];class Or{constructor(e){this.buffer=e,this.buflen=e.length,this.bufpos=0,this.bufoff=0,this.iserro=!1}read(e){let t=0,i=0;for(;e;){if(e<0||this.bufpos>=this.buflen)return this.iserro=!0,0;this.iserro=!1,i=this.bufoff+e>8?8-this.bufoff:e,t<<=i,t+=this.buffer[this.bufpos]>>8-this.bufoff-i&255>>8-i,this.bufoff+=i,e-=i,8==this.bufoff&&(this.bufpos++,this.bufoff=0)}return t}look(e){let t=this.bufpos,i=this.bufoff,s=this.read(e);return this.bufpos=t,this.bufoff=i,s}read_golomb(){let e;for(e=0;0==this.read(1)&&!this.iserro;e++);return(1<<e)+this.read(e)-1}}function Nr(e){let t=e.read(5);return 31===t&&(t=e.read(6)+32),t}function jr(e,t){return t.sampling_index=e.read(4),15==t.sampling_index?e.read(24):zr[t.sampling_index]}const zr=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350,0,0,0],Gr=[0,1,2,3,4,5,6,8];class Hr{constructor(e){this.data_=e,this.eof_flag_=!1,this.current_syncword_offset_=this.findNextSyncwordOffset(0),this.eof_flag_&&console.error("Could not found ADTS syncword until payload end")}findNextSyncwordOffset(e){let t=e,i=this.data_;for(;;){if(t+7>=i.byteLength)return this.eof_flag_=!0,i.byteLength;if(4095===(i[t+0]<<8|i[t+1])>>>4)return t;t++}}readNextAACFrame(){let e=this.data_,t=null;for(;null==t&&!this.eof_flag_;){let i=this.current_syncword_offset_,s=(8&e[i+1])>>>3,r=(6&e[i+1])>>>1,a=1&e[i+1],o=(192&e[i+2])>>>6,n=(60&e[i+2])>>>2,l=(1&e[i+2])<<2|(192&e[i+3])>>>6,d=(3&e[i+3])<<11|e[i+4]<<3|(224&e[i+5])>>>5;if(e[i+6],i+d>this.data_.byteLength){this.eof_flag_=!0,this.has_last_incomplete_data=!0;break}let h=1===a?7:9,c=d-h;i+=h;let u=this.findNextSyncwordOffset(i+c);if(this.current_syncword_offset_=u,0!==s&&1!==s||0!==r)continue;let p=e.subarray(i,i+c);t={},t.audio_object_type=o+1,t.sampling_freq_index=n,t.sampling_frequency=Dr[n],t.channel_config=l,t.data=p}return t}hasIncompleteData(){return this.has_last_incomplete_data}getIncompleteData(){return this.has_last_incomplete_data?this.data_.subarray(this.current_syncword_offset_):null}}class $r{constructor(e){this.data_=e,this.eof_flag_=!1,this.current_syncword_offset_=this.findNextSyncwordOffset(0),this.eof_flag_&&console.error("Could not found ADTS syncword until payload end")}findNextSyncwordOffset(e){let t=e,i=this.data_;for(;;){if(t+1>=i.byteLength)return this.eof_flag_=!0,i.byteLength;if(695===(i[t+0]<<3|i[t+1]>>>5))return t;t++}}getLATMValue(e){let t=e.readBits(2),i=0;for(let s=0;s<=t;s++)i<<=8,i|=e.readByte();return i}readNextAACFrame(e){let t=this.data_,i=null;for(;null==i&&!this.eof_flag_;){let s=this.current_syncword_offset_,r=(31&t[s+1])<<8|t[s+2];if(s+3+r>=this.data_.byteLength){this.eof_flag_=!0,this.has_last_incomplete_data=!0;break}let a=new Rr(t.subarray(s+3,s+3+r)),o=null;if(a.readBool()){if(null==e){console.warn("StreamMuxConfig Missing"),this.current_syncword_offset_=this.findNextSyncwordOffset(s+3+r),a.destroy();continue}o=e}else{let e=a.readBool();if(e&&a.readBool()){console.error("audioMuxVersionA is Not Supported"),a.destroy();break}if(e&&this.getLATMValue(a),!a.readBool()){console.error("allStreamsSameTimeFraming zero is Not Supported"),a.destroy();break}if(0!==a.readBits(6)){console.error("more than 2 numSubFrames Not Supported"),a.destroy();break}if(0!==a.readBits(4)){console.error("more than 2 numProgram Not Supported"),a.destroy();break}if(0!==a.readBits(3)){console.error("more than 2 numLayer Not Supported"),a.destroy();break}let t=e?this.getLATMValue(a):0,i=a.readBits(5);t-=5;let s=a.readBits(4);t-=4;let r=a.readBits(4);t-=4,a.readBits(3),t-=3,t>0&&a.readBits(t);let n=a.readBits(3);if(0!==n){console.error(`frameLengthType = ${n}. Only frameLengthType = 0 Supported`),a.destroy();break}a.readByte();let l=a.readBool();if(l)if(e)this.getLATMValue(a);else{let e=0;for(;;){e<<=8;let t=a.readBool();if(e+=a.readByte(),!t)break}console.log(e)}a.readBool()&&a.readByte(),o={},o.audio_object_type=i,o.sampling_freq_index=s,o.sampling_frequency=Dr[o.sampling_freq_index],o.channel_config=r,o.other_data_present=l}let n=0;for(;;){let e=a.readByte();if(n+=e,255!==e)break}let l=new Uint8Array(n);for(let e=0;e<n;e++)l[e]=a.readByte();i={},i.audio_object_type=o.audio_object_type,i.sampling_freq_index=o.sampling_freq_index,i.sampling_frequency=Dr[o.sampling_freq_index],i.channel_config=o.channel_config,i.other_data_present=o.other_data_present,i.data=l,this.current_syncword_offset_=this.findNextSyncwordOffset(s+3+r)}return i}hasIncompleteData(){return this.has_last_incomplete_data}getIncompleteData(){return this.has_last_incomplete_data?this.data_.subarray(this.current_syncword_offset_):null}}function Vr(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return(e[t]<<24>>>0)+(e[t+1]<<16)+(e[t+2]<<8)+(e[t+3]||0)}function Wr(e){const t=e.byteLength,i=new Uint8Array(4);i[0]=t>>>24&255,i[1]=t>>>16&255,i[2]=t>>>8&255,i[3]=255&t;const s=new Uint8Array(t+4);return s.set(i,0),s.set(e,4),s}function Jr(){}function qr(e){let t=null;const i=["webgl","experimental-webgl","moz-webgl","webkit-3d"];let s=0;for(;!t&&s<i.length;){const r=i[s];try{let i={preserveDrawingBuffer:!0};t=e.getContext(r,i)}catch(e){console.error(e),t=null}t&&"function"==typeof t.getParameter||(t=null),++s}return t}function Kr(e){let t=null;return t=e.getContext("webgl2"),t}function Yr(){const e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").split(","),t=atob(e[1]),i=e[0].replace("data:","").replace(";base64","");let s=t.length,r=new Uint8Array(s);for(;s--;)r[s]=t.charCodeAt(s);return new File([r],"file",{type:i})}function Qr(){return(new Date).getTime()}function Xr(e,t,i){return Math.max(Math.min(e,Math.max(t,i)),Math.min(t,i))}function Zr(e,t,i){if(e)return"object"==typeof t&&Object.keys(t).forEach((i=>{Zr(e,i,t[i])})),e.style[t]=i,e}function ea(e,t){let i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(!e)return 0;const s=getComputedStyle(e,null).getPropertyValue(t);return i?parseFloat(s):s}function ta(){return performance&&"function"==typeof performance.now?performance.now():Date.now()}function ia(e){let t=0,i=ta();return s=>{if(!ya(s))return;t+=s;const r=ta(),a=r-i;a>=1e3&&(e(t/a*1e3),i=r,t=0)}}(()=>{try{if("object"==typeof WebAssembly&&"function"==typeof WebAssembly.instantiate){const e=new WebAssembly.Module(Uint8Array.of(0,97,115,109,1,0,0,0));if(e instanceof WebAssembly.Module)return new WebAssembly.Instance(e)instanceof WebAssembly.Instance}}catch(e){}})();const sa='"2025-3-11"';function ra(){return/iphone|ipod|android.*mobile|windows.*phone|blackberry.*mobile/i.test(window.navigator.userAgent.toLowerCase())}function aa(){return!(ra()||/ipad|android(?!.*mobile)|tablet|kindle|silk/i.test(window.navigator.userAgent.toLowerCase()))}function oa(){const e=window.navigator.userAgent.toLowerCase();return/android/i.test(e)}function na(){const e=window.navigator.userAgent.toLowerCase();return/firefox/i.test(e)}function la(){const e=window.navigator.userAgent.toLowerCase()||"",t={type:"",version:""},i={IE:window.ActiveXObject||"ActiveXObject"in window,Chrome:e.indexOf("chrome")>-1&&e.indexOf("safari")>-1,Firefox:e.indexOf("firefox")>-1,Opera:e.indexOf("opera")>-1,Safari:e.indexOf("safari")>-1&&-1==e.indexOf("chrome"),Edge:e.indexOf("edge")>-1,QQBrowser:/qqbrowser/.test(e),WeixinBrowser:/MicroMessenger/i.test(e)};for(let s in i)if(i[s]){let i="";if("IE"===s){const t=e.match(/(msie\s|trident.*rv:)([\w.]+)/);t&&t.length>2&&(i=e.match(/(msie\s|trident.*rv:)([\w.]+)/)[2])}else if("Chrome"===s){for(let e in navigator.mimeTypes)"application/360softmgrplugin"===navigator.mimeTypes[e].type&&(s="360");const t=e.match(/chrome\/([\d.]+)/);t&&t.length>1&&(i=t[1])}else if("Firefox"===s){const t=e.match(/firefox\/([\d.]+)/);t&&t.length>1&&(i=t[1])}else if("Opera"===s){const t=e.match(/opera\/([\d.]+)/);t&&t.length>1&&(i=t[1])}else if("Safari"===s){const t=e.match(/version\/([\d.]+)/);t&&t.length>1&&(i=t[1])}else if("Edge"===s){const t=e.match(/edge\/([\d.]+)/);t&&t.length>1&&(i=t[1])}else if("QQBrowser"===s){const t=e.match(/qqbrowser\/([\d.]+)/);t&&t.length>1&&(i=t[1])}t.type=s,t.version=parseInt(i)}return t}function da(){const e=window.navigator.userAgent.toLowerCase();return e&&/iphone|ipad|ipod|ios/.test(e)}function ha(){const e=window.navigator.userAgent;return!e.match(/Chrome/gi)&&!!e.match(/Safari/gi)}function ca(e,t){if(0===arguments.length)return null;var i,s=t||"{y}-{m}-{d} {h}:{i}:{s}";"object"==typeof e?i=e:(10===(""+e).length&&(e=1e3*parseInt(e)),e=+e,i=new Date(e));var r={y:i.getFullYear(),m:i.getMonth()+1,d:i.getDate(),h:i.getHours(),i:i.getMinutes(),s:i.getSeconds(),a:i.getDay()};return s.replace(/{(y|m|d|h|i|s|a)+}/g,((e,t)=>{var i=r[t];return"a"===t?["一","二","三","四","五","六","日"][i-1]:(e.length>0&&i<10&&(i="0"+i),i||0)}))}function ua(){return"VideoFrame"in window}function pa(e){if("string"!=typeof e)return e;var t=Number(e);return isNaN(t)?e:t}function fa(){return"xxxxxxxxxxxx4xxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}))}function ma(e,t){let i,s,r=!1;return function a(){for(var o=arguments.length,n=new Array(o),l=0;l<o;l++)n[l]=arguments[l];if(r)return i=n,void(s=this);r=!0,e.apply(this,n),setTimeout((()=>{r=!1,i&&(a.apply(s,i),i=null,s=null)}),t)}}function ga(e){if(null==e||""==e)return"0 Bytes";const t=new Array("Bytes","KB","MB","GB","TB","PB","EB","ZB","YB");let i=0;const s=parseFloat(e);i=Math.floor(Math.log(s)/Math.log(1024));var r=s/Math.pow(1024,i);return(r=r.toFixed(2))+t[i]}function ya(e){return"[object Number]"===Object.prototype.toString.call(e)}function Aa(){let e=!1;return"MediaSource"in self&&(self.MediaSource.isTypeSupported(ii)||self.MediaSource.isTypeSupported(si)||self.MediaSource.isTypeSupported(ri)||self.MediaSource.isTypeSupported(ai)||self.MediaSource.isTypeSupported(oi))&&(e=!0),e}function ba(){const e=la();return"chrome"===e.type.toLowerCase()&&e.version>=107}function _a(){let e=!1;return"MediaStreamTrackGenerator"in window&&(e=!0),e}function va(){let e=!1;return"MediaStream"in window&&(e=!0),e}function Sa(e,t){let i=window.URL.createObjectURL(t),s=window.document.createElement("a");s.download=e,s.href=i;let r=window.document.createEvent("MouseEvents");r.initEvent("click",!0,!0),s.dispatchEvent(r),setTimeout((()=>{window.URL.revokeObjectURL(i)}),da()?1e3:0)}function wa(e){return null==e}function Ea(e){return!0===e||!1===e}function Ta(e){return!wa(e)}function ka(e){let t={left:"",right:"",top:"",bottom:"",opacity:1,backgroundColor:"",image:{src:"",width:"100",height:"60"},text:{content:"",fontSize:"14",color:"#000",width:"",height:""},rect:{color:"green",lineWidth:2,width:"",height:"",fill:"",fillOpacity:.2},line:{x1:"",y1:"",x2:"",y2:"",color:"green",lineWidth:2},polygon:{color:"green",lineWidth:2,list:[],fill:"",fillOpacity:.2},html:""};const i=Object.assign(t.image,e.image||{}),s=Object.assign(t.text,e.text||{}),r=Object.assign(t.rect,e.rect||{}),a=Object.assign(t.line,e.line||{});return t=Object.assign(t,e,{image:i,text:s,rect:r,line:a}),t}function Ca(e,t){let i={container:e||"",text:"",opacity:"",angle:"",color:"",fontSize:"",fontFamily:""};return i=Object.assign(i,t),{watermark_parent_node:i.container,watermark_alpha:i.opacity,watermark_angle:i.angle,watermark_fontsize:i.fontSize,watermark_color:i.color,watermark_font:i.fontFamily,watermark_txt:i.text}}function Ra(e,t){return new Promise(((i,s)=>{let r=ka(t);if(!r.image.src&&!r.text.content)return i(e);let a=document.createElement("canvas");a.width=t.width,a.height=t.height;let o=a.getContext("2d"),n=0,l=0;ya(r.left)?n=r.left:ya(r.right)&&(n=a.width-r.right),ya(r.top)?l=r.top:ya(r.bottom)&&(l=a.height-r.bottom);const d=new Image;d.src=e,d.onload=()=>{if(o.drawImage(d,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,o.drawImage(e,n,l,r.image.width,r.image.height),i(a.toDataURL(t.format,t.quality))},e.onerror=e=>{s()}}else r.text&&r.text.content&&(o.font=r.text.fontSize+"px 宋体",o.fillStyle=r.text.color,o.textAlign="right",o.fillText(r.text.content,n,l),i(a.toDataURL(t.format,t.quality)))},d.onerror=e=>{s(e)}}))}function xa(e){var t;if(e>-1){var i=Math.floor(e/3600),s=Math.floor(e/60)%60,r=e%60;t=i<10?"0"+i+":":i+":",s<10&&(t+="0"),t+=s+":",(r=Math.round(r))<10&&(t+="0"),t+=r.toFixed(0)}return t}function Da(e,t){let i="";if(e>-1){const s=Math.floor(e/60)%60;let r=e%60;r=Math.round(r),i=s<10?"0"+s+":":s+":",r<10&&(i+="0"),i+=r,wa(t)||(t<10&&(t="0"+t),i+=":"+t)}return i}function La(e){let t="";if(e>-1){const i=Math.floor(e/60/60)%60;let s=Math.floor(e/60)%60,r=e%60;s=Math.round(s),t=i<10?"0"+i+":":i+":",s<10&&(t+="0"),t+=s+":",r<10&&(t+="0"),t+=r}return t}function Pa(e,t){const i=Math.floor(t/60)%60,s=Math.floor(t%60);return new Date(e).setHours(i,s,0,0)}function Ba(e,t){const i=Math.floor(t/60/60)%60,s=Math.floor(t/60)%60,r=t%60;return new Date(e).setHours(i,s,r,0)}function Ia(e){return(""+e).length}function Ma(e){return e&&0===Object.keys(e).length}function Ua(e){return!Ma(e)}function Fa(e){return"string"==typeof e}const Oa=()=>{const e=window.navigator.userAgent;return/MicroMessenger/i.test(e)},Na=()=>{const e=window.navigator.userAgent;return/Chrome/i.test(e)};function ja(e){const t=e||window.event;return t.target||t.srcElement}function za(){return na()&&function(){const e=navigator.userAgent.toLowerCase();return/macintosh|mac os x/i.test(e)}()}function Ga(e){return"function"==typeof e}function Ha(e){if(ra()){let t=0,i=0;if(1===e.touches.length){let s=e.touches[0];t=s.clientX,i=s.clientY}return{posX:t,posY:i}}let t=0,i=0;const s=e||window.event;return s.pageX||s.pageY?(t=s.pageX,i=s.pageY):(s.clientX||s.clientY)&&(t=e.clientX+document.documentElement.scrollLeft+document.body.scrollLeft,i=e.clientY+document.documentElement.scrollTop+document.body.scrollTop),{posX:t,posY:i}}function $a(){let e=document.createElement("video"),t=e.canPlayType("application/vnd.apple.mpegurl");return e=null,t}function Va(e){let t=ro(e.hasAudio)&&(e.useMSE||e.useWCS&&!e.useOffscreen)&&ro(e.demuxUseWorker);return!!(ro(t)&&e.useMSE&&e.mseDecodeAudio&&ro(e.demuxUseWorker))||t}function Wa(e){const t=e.toString().trim().match(/^function\s*\w*\s*\([\w\s,]*\)\s*{([\w\W]*?)}$/)[1];const i=new Blob([t],{type:"application/javascript"});return URL.createObjectURL(i)}function Ja(e){e.close()}function qa(){return"https:"===window.location.protocol||"localhost"===window.location.hostname}function Ka(e){const t=Object.prototype.toString;return function(e){switch(t.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":return!0;default:try{return e instanceof Error}catch(e){return!1}}}(e)?e.message:null==e?"":"object"==typeof e?JSON.stringify(e,null,2):String(e)}function Ya(e,t){t&&(e=e.filter((e=>e.type&&e.type===t)));let i=e[0],s=null,r=1;if(e.length>0){let t=e[1];t&&t.ts-i.ts>1e5&&(i=t,r=2)}if(i)for(let a=r;a<e.length;a++){let r=e[a];if(t&&r.type&&r.type!==t&&(r=null),r){if(r.ts-i.ts>=1e3){e[a-1].ts-i.ts<1e3&&(s=a+1)}}}return s}function Qa(e){for(var t=(e+"=".repeat((4-e.length%4)%4)).replace(/\-/g,"+").replace(/_/g,"/"),i=window.atob(t),s=new Uint8Array(i.length),r=0;r<i.length;++r)s[r]=i.charCodeAt(r);return s}function Xa(e){const t=/(msie|trident)/i.test(navigator.userAgent),i=document.createElement("a");let s=e;return t&&(i.setAttribute("href",s),s=i.href),i.setAttribute("href",s),{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}}function Za(e){let t="";if("object"==typeof e)try{t=JSON.stringify(e),t=JSON.parse(t)}catch(i){t=e}else t=e;return t}function eo(){return Za(ie)}function to(){return Za(se)}function io(e){return e[0]>>4===ps&&e[1]===us}function so(e){return!0===e||"true"===e}function ro(e){return!0!==e&&"true"!==e}function ao(e){return e.replace(/-([a-z])/g,(function(e,t){return t.toUpperCase()}))}function oo(){return/iphone/i.test(navigator.userAgent)}function no(){try{var e=document.createElement("canvas");return!(!window.WebGL2RenderingContext||!e.getContext("webgl2"))}catch(e){return!1}}function lo(e){return e.trim().match(/^function\s*\w*\s*\([\w\s,]*\)\s*{([\w\W]*?)}$/)[1]}function ho(){let e=!1;return"requestVideoFrameCallback"in HTMLVideoElement.prototype&&(e=!0),e}function co(){let e=!1;return"PressureObserver"in window&&(e=!0),e}class uo{constructor(e){this.destroys=[],this.proxy=this.proxy.bind(this),this.master=e}proxy(e,t,i){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if(!e)return;if(Array.isArray(t))return t.map((t=>this.proxy(e,t,i,s)));e.addEventListener(t,i,s);const r=()=>{Ga(e.removeEventListener)&&e.removeEventListener(t,i,s)};return this.destroys.push(r),r}destroy(){this.master.debug&&this.master.debug.log("Events","destroy"),this.destroys.forEach((e=>e())),this.destroys=[]}}class po{on(e,t,i){const s=this.e||(this.e={});return(s[e]||(s[e]=[])).push({fn:t,ctx:i}),this}once(e,t,i){const s=this;function r(){s.off(e,r);for(var a=arguments.length,o=new Array(a),n=0;n<a;n++)o[n]=arguments[n];t.apply(i,o)}return r._=t,this.on(e,r,i)}emit(e){const t=((this.e||(this.e={}))[e]||[]).slice();for(var i=arguments.length,s=new Array(i>1?i-1:0),r=1;r<i;r++)s[r-1]=arguments[r];for(let e=0;e<t.length;e+=1)t[e].fn.apply(t[e].ctx,s);return this}off(e,t){const i=this.e||(this.e={});if(!e)return Object.keys(i).forEach((e=>{delete i[e]})),void delete this.e;const s=i[e],r=[];if(s&&t)for(let e=0,i=s.length;e<i;e+=1)s[e].fn!==t&&s[e].fn._!==t&&r.push(s[e]);return r.length?i[e]=r:delete i[e],this}}var fo=1e-6,mo="undefined"!=typeof Float32Array?Float32Array:Array;function go(){var e=new mo(16);return mo!=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 yo(e){return 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,e}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});var Ao,bo=function(e,t,i,s,r,a,o){var n=1/(t-i),l=1/(s-r),d=1/(a-o);return e[0]=-2*n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*d,e[11]=0,e[12]=(t+i)*n,e[13]=(r+s)*l,e[14]=(o+a)*d,e[15]=1,e};function _o(e,t,i){var s=new mo(3);return s[0]=e,s[1]=t,s[2]=i,s}Ao=new mo(3),mo!=Float32Array&&(Ao[0]=0,Ao[1]=0,Ao[2]=0);class vo{constructor(e,t){this.gl=e,t&&this.gl.pixelStorei(this.gl.UNPACK_ALIGNMENT,1);const i=this._initShaderProgram();this._programInfo={program:i,attribLocations:{vertexPosition:e.getAttribLocation(i,"aVertexPosition"),texturePosition:e.getAttribLocation(i,"aTexturePosition")},uniformLocations:{projectionMatrix:e.getUniformLocation(i,"uProjectionMatrix"),modelMatrix:e.getUniformLocation(i,"uModelMatrix"),viewMatrix:e.getUniformLocation(i,"uViewMatrix"),rgbatexture:e.getUniformLocation(i,"rgbaTexture"),ytexture:e.getUniformLocation(i,"yTexture"),utexture:e.getUniformLocation(i,"uTexture"),vtexture:e.getUniformLocation(i,"vTexture"),isyuv:e.getUniformLocation(i,"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(){const 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){const i=this.gl,s=i.createShader(e);return i.shaderSource(s,t),i.compileShader(s),i.getShaderParameter(s,i.COMPILE_STATUS)?s:(console.log("An error occurred compiling the shaders: "+i.getShaderInfoLog(s)),i.deleteShader(s),null)}_initBuffers(){const e=this.gl,t=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,t);const i=[-1,-1,1,-1,1,1,-1,1];e.bufferData(e.ARRAY_BUFFER,new Float32Array(i),e.STATIC_DRAW);var s=[];s=s.concat([0,1],[1,1],[1,0],[0,0]);const r=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,r),e.bufferData(e.ARRAY_BUFFER,new Float32Array(s),e.STATIC_DRAW);const a=e.createBuffer();e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,a);return e.bufferData(e.ELEMENT_ARRAY_BUFFER,new Uint16Array([0,1,2,0,2,3]),e.STATIC_DRAW),{positions:i,position:t,texPosition:r,indices:a}}_createTexture(){let 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,s,r,a){let o=2*e/r-1,n=2*(a-t-s)/a-1,l=2*(e+i)/r-1,d=2*(a-t)/a-1;return[o,n,l,n,l,d,o,d]}_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,s,r){const 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,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,r),this._buffers.positions=[-1,-1,1,-1,1,1,-1,1],this._drawScene(e,t,!0)}renderYUV(e,t,i){let s=i.slice(0,e*t),r=i.slice(e*t,e*t*5/4),a=i.slice(e*t*5/4,e*t*3/2);const o=this.gl;this._clear(),o.activeTexture(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,this._ytexture),o.texImage2D(o.TEXTURE_2D,0,o.LUMINANCE,e,t,0,o.LUMINANCE,o.UNSIGNED_BYTE,s),o.activeTexture(o.TEXTURE1),o.bindTexture(o.TEXTURE_2D,this._utexture),o.texImage2D(o.TEXTURE_2D,0,o.LUMINANCE,e/2,t/2,0,o.LUMINANCE,o.UNSIGNED_BYTE,r),o.activeTexture(o.TEXTURE2),o.bindTexture(o.TEXTURE_2D,this._vtexture),o.texImage2D(o.TEXTURE_2D,0,o.LUMINANCE,e/2,t/2,0,o.LUMINANCE,o.UNSIGNED_BYTE,a),this._buffers.positions=[-1,-1,1,-1,1,1,-1,1],this._drawScene(e,t,!0)}drawDom(e,t,i,s,r){const 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,r),this._buffers.positions=this._calRect(i,s,r.width,r.height,e,t),this._drawScene(e,t,!1)}}class So{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(){const 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});e.queue.writeBuffer(i,0,t);const s=new Float32Array([0,1,1,1,1,0,0,0]),r=e.createBuffer({size:s.byteLength,usage:window.GPUBufferUsage.VERTEX|window.GPUBufferUsage.COPY_DST});e.queue.writeBuffer(r,0,s);const a=new Uint16Array([0,1,2,0,2,3]),o=e.createBuffer({size:a.byteLength,usage:window.GPUBufferUsage.INDEX|window.GPUBufferUsage.COPY_DST});return e.queue.writeBuffer(o,0,a),{positionBuffer:i,texpositionBuffer:r,indexBuffer:o}}_initPipeline(){return new Promise(((e,t)=>{const i=this.gpu.device,s=this.gpu.format,r={layout:"auto",vertex:{module:i.createShaderModule({code:"\n\n @binding(0) @group(0) var<uniform> uModelMatrix : mat4x4<f32>;\n @binding(1) @group(0) var<uniform> uViewMatrix : mat4x4<f32>;\n @binding(2) @group(0) var<uniform> uProjectionMatrix : mat4x4<f32>;\n\n struct VertexOutput {\n @builtin(position) Position : vec4<f32>,\n @location(0) vTexturePosition : vec2<f32>,\n }\n\n @vertex\n fn main(\n @location(0) aVertexPosition : vec4<f32>,\n @location(1) aTexturePosition : vec2<f32>\n ) -> VertexOutput {\n var output : VertexOutput;\n var tmppos : vec4<f32> = uProjectionMatrix * uViewMatrix * uModelMatrix * aVertexPosition;\n output.Position = vec4<f32>(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:i.createShaderModule({code:"\n @group(1) @binding(0) var mySampler: sampler;\n @group(1) @binding(1) var yTexture: texture_2d<f32>;\n @group(1) @binding(2) var uTexture: texture_2d<f32>;\n @group(1) @binding(3) var vTexture: texture_2d<f32>;\n\n const YUV2RGB : mat4x4<f32> = mat4x4<f32>( 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<f32>\n ) -> @location(0) vec4<f32> {\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<f32>(y, u, v, 1.0)*YUV2RGB;\n }\n\n "}),entryPoint:"main",targets:[{format:s}]},depthStencil:{depthWriteEnabled:!0,depthCompare:"less",format:"depth24plus"}};i.createRenderPipelineAsync(r).then((t=>{e(t)})).catch((e=>{t(e)}))}))}_initMatrixGroupInfo(){const e=this.gpu.device,t=this.pipeline,i=go();bo(i,-1,1,-1,1,.1,100);const s=go();yo(s);const r=go();!function(e,t,i,s){var r,a,o,n,l,d,h,c,u,p,f=t[0],m=t[1],g=t[2],y=s[0],A=s[1],b=s[2],_=i[0],v=i[1],S=i[2];Math.abs(f-_)<fo&&Math.abs(m-v)<fo&&Math.abs(g-S)<fo?yo(e):(h=f-_,c=m-v,u=g-S,r=A*(u*=p=1/Math.hypot(h,c,u))-b*(c*=p),a=b*(h*=p)-y*u,o=y*c-A*h,(p=Math.hypot(r,a,o))?(r*=p=1/p,a*=p,o*=p):(r=0,a=0,o=0),n=c*o-u*a,l=u*r-h*o,d=h*a-c*r,(p=Math.hypot(n,l,d))?(n*=p=1/p,l*=p,d*=p):(n=0,l=0,d=0),e[0]=r,e[1]=n,e[2]=h,e[3]=0,e[4]=a,e[5]=l,e[6]=c,e[7]=0,e[8]=o,e[9]=d,e[10]=u,e[11]=0,e[12]=-(r*f+a*m+o*g),e[13]=-(n*f+l*m+d*g),e[14]=-(h*f+c*m+u*g),e[15]=1)}(r,_o(0,0,0),_o(0,0,-1),_o(0,1,0));const a=e.createBuffer({size:64,usage:window.GPUBufferUsage.UNIFORM|window.GPUBufferUsage.COPY_DST});e.queue.writeBuffer(a,0,s);const o=e.createBuffer({size:64,usage:window.GPUBufferUsage.UNIFORM|window.GPUBufferUsage.COPY_DST});e.queue.writeBuffer(o,0,r);const n=e.createBuffer({size:64,usage:window.GPUBufferUsage.UNIFORM|window.GPUBufferUsage.COPY_DST});e.queue.writeBuffer(n,0,i);return{modelMatrixBuffer:a,viewMatrixBuffer:o,projectMatrixBuffer:n,group:e.createBindGroup({label:"group0",layout:t.getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:a}},{binding:1,resource:{buffer:o}},{binding:2,resource:{buffer:n}}]})}}_initTextureGroupInfo(e,t){const i=this.gpu.device,s=this.pipeline,r=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}),o=i.createTexture({size:[e/2,t/2],format:"r8unorm",usage:window.GPUTextureUsage.TEXTURE_BINDING|window.GPUTextureUsage.COPY_DST|window.GPUTextureUsage.RENDER_ATTACHMENT}),n=i.createSampler({magFilter:"linear",minFilter:"linear"}),l=i.createBindGroup({label:"group1",layout:s.getBindGroupLayout(1),entries:[{binding:0,resource:n},{binding:1,resource:r.createView()},{binding:2,resource:a.createView()},{binding:3,resource:o.createView()}]});return{yTexture:r,uTexture:a,vTexture:o,group:l}}_drawScene(){const e=this.gpu.device,t=this.gpu.context,i=e.createCommandEncoder(),s={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"}},r=i.beginRenderPass(s);r.setPipeline(this.pipeline),r.setBindGroup(0,this.matrixGroupInfo.group),r.setBindGroup(1,this.textureGroupInfo.group),r.setVertexBuffer(0,this.buffers.positionBuffer),r.setVertexBuffer(1,this.buffers.texpositionBuffer),r.setIndexBuffer(this.buffers.indexBuffer,"uint16"),r.drawIndexed(6),r.end(),e.queue.submit([i.finish()])}renderYUV(e,t,i){if(!this.hasInited)return;let s=i.slice(0,e*t),r=i.slice(e*t,e*t*5/4),a=i.slice(e*t*5/4,e*t*3/2);const o=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)),o.queue.writeTexture({texture:this.textureGroupInfo.yTexture},s,{bytesPerRow:e,rowsPerImage:t},[e,t]),o.queue.writeTexture({texture:this.textureGroupInfo.uTexture},r,{bytesPerRow:e/2,rowsPerImage:t/2},[e/2,t/2]),o.queue.writeTexture({texture:this.textureGroupInfo.vTexture},a,{bytesPerRow:e/2,rowsPerImage:t/2},[e/2,t/2]),this._drawScene()}clear(){}}class wo{constructor(e){this.player=e,this.TAG_NAME="SingleWatermark",this.configList=[],this.shadowRoot=null,this.shadowRootRealDom=null,this.shadowRootInnerDom=null,this.scale=1,this.isDynamic=!1,this._initDom(),this.player.debug.log(this.TAG_NAME,"int")}destroy(){this.configList=[],this.shadowRootInnerDom=null,this.isDynamic=!1,this.scale=1,this.shadowRoot&&(this.player.$container.removeChild(this.shadowRootRealDom),this.shadowRoot=null,this.shadowRootRealDom=null),this.player.debug.log(this.TAG_NAME,"destroy")}resize(){this.player.debug.log(this.TAG_NAME,"resize()"),"default"===this.player._opt.aspectRatio||ra()?this.player.getRenderType()===V?this._resizeDomForCanvas():this.player.getRenderType()===W&&this._resizeDomForVideo():this._resizeDomRatio()}_initDom(){const e=this.player.$container;let t=null;const i=document.createElement("div");i.setAttribute("style","pointer-events: none !important;display: block !important;"),t="function"==typeof i.attachShadow?i.attachShadow({mode:"open"}):i.shadowRoot?i.shadowRoot:i;const s=document.createElement("div");s.setAttribute("style","position: absolute; top: 0; left: 0; width: 0; height: 0;display: none;"),t.appendChild(s);const r=e.children,a=Math.floor(Math.random()*(r.length-1))+1;r[a]?e.insertBefore(i,r[a]):e.appendChild(i),this.shadowRootInnerDom=s,this.shadowRootRealDom=i,this.shadowRoot=t}update(e){this._removeDom();let t=[];Array.isArray(e)?t=e:Ua(e)&&t.push(e);let i=t.map((e=>ka(e)));this.configList=i,this._updateDom()}_resizeDomForVideo(){const e=this.player.width,t=this.player.height,i=this.player.getVideoInfo();if(!(i&&i.height>0&&i.width>0))return;let s=i.width,r=i.height;const a=this.player._opt;let o=t,n=e;if(a.hasControl&&!a.controlAutoHide){const e=a.playType===v?zt:jt;ra()&&this.player.fullscreen&&a.useWebFullScreen?n-=e:o-=e}const l=a.rotate;let d=(n-s)/2,h=(o-r)/2;270!==l&&90!==l||(s=i.height,r=i.width);const c=n/s,u=o/r;let p=c>u?u:c;a.isResize||c!==u&&(p=c+","+u),a.isFullResize&&(p=c>u?c:u);let f="scale("+p+")";"none"===a.mirrorRotate&&l&&(f+=" rotate("+l+"deg)"),"level"===a.mirrorRotate?f+=" rotateY(180deg)":"vertical"===a.mirrorRotate&&(f+=" rotateX(180deg)"),this.scale=-1!==(""+p).indexOf(",")?c:p,this.shadowRootInnerDom.style.transform=f,this.shadowRootInnerDom.style.left=d+"px",this.shadowRootInnerDom.style.top=h+"px",this.shadowRootInnerDom.style.width=i.width+"px",this.shadowRootInnerDom.style.height=i.height+"px",this.shadowRootInnerDom.style.display="block"}_resizeDomForCanvas(){const e=this.player.getVideoInfo();if(!(e&&e.height>0&&e.width>0))return;const t=this.player._opt;let i=this.player.width,s=this.player.height;if(t.hasControl&&!t.controlAutoHide){const e=t.playType===v?zt:jt;ra()&&this.player.fullscreen&&t.useWebFullScreen?i-=e:s-=e}let r=e.width,a=e.height;const o=t.rotate;let n=(i-r)/2,l=(s-a)/2;270!==o&&90!==o||(r=e.height,a=e.width);const d=i/r,h=s/a;let c=d>h?h:d;t.isResize||d!==h&&(c=d+","+h),t.isFullResize&&(c=d>h?d:h);let u="scale("+c+")";"none"===t.mirrorRotate&&o&&(u+=" rotate("+o+"deg)"),"level"===t.mirrorRotate?u+=" rotateY(180deg)":"vertical"===t.mirrorRotate&&(u+=" rotateX(180deg)"),this.shadowRootInnerDom.style.height=e.height+"px",this.shadowRootInnerDom.style.width=e.width+"px",this.shadowRootInnerDom.style.padding="0",this.shadowRootInnerDom.style.transform=u,this.shadowRootInnerDom.style.left=n+"px",this.shadowRootInnerDom.style.top=l+"px",this.shadowRootInnerDom.style.display="block"}_resizeDomRatio(){const e=this.player.getVideoInfo();if(!(e&&e.height>0&&e.width>0))return;const t=this.player._opt.aspectRatio.split(":").map(Number);let i=this.player.width,s=this.player.height;const r=this.player._opt;let a=0;r.hasControl&&!r.controlAutoHide&&(a=r.playType===v?zt:jt,s-=a);const o=e.width/e.height,n=t[0]/t[1];if(o>n){const t=n*e.height/e.width;this.shadowRootInnerDom.style.width=100*t+"%",this.shadowRootInnerDom.style.height=`calc(100% - ${a}px)`,this.shadowRootInnerDom.style.padding=`0 ${(i-i*t)/2}px`}else{const t=e.width/n/e.height;this.shadowRootInnerDom.style.width="100%",this.shadowRootInnerDom.style.height=`calc(${100*t}% - ${a}px)`,this.shadowRootInnerDom.style.padding=(s-s*t)/2+"px 0"}this.shadowRootInnerDom.style.display="block"}_updateDom(){this.shadowRoot&&this.configList.forEach((e=>{const t=document.createElement("div");let i=null;if(e.image&&e.image.src?(i=document.createElement("img"),i.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||e.line&&e.line.x1&&e.line.y1&&e.line.x2&&e.line.y2||e.polygon&&e.polygon.list&&e.polygon.list.length>=3)&&(i=document.createElement("div")),i){if(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,Ta(e.left)&&(ya(e.left)?t.style.left=e.left+"px":t.style.left=e.left),Ta(e.right)&&(ya(e.right)?t.style.right=e.right+"px":t.style.right=e.right),Ta(e.top)&&(ya(e.top)?t.style.top=e.top+"px":t.style.top=e.top),Ta(e.bottom)&&(ya(e.bottom)?t.style.bottom=e.bottom+"px":t.style.bottom=e.bottom),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";else if(e.text&&e.text.content)t.style.fontSize=e.text.fontSize+"px",t.style.color=e.text.color,e.text.width&&(t.style.width=e.text.width+"px"),e.text.height&&(t.style.height=e.text.height+"px");else if(e.rect&&e.rect.color&&e.rect.width){if(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.rect.fill){const i=document.createElement("div");i.style.position="absolute",i.style.width="100%",i.style.height="100%",i.style.backgroundColor=e.rect.fill,e.rect.fillOpacity&&(i.style.opacity=e.rect.fillOpacity),t.appendChild(i)}}else if(e.html)t.style.width="100%",t.style.height="100%",t.innerHTML=e.html;else if(e.line&&e.line.x1&&e.line.y1&&e.line.x2&&e.line.y2)this.settingLine(t,e.line);else if(e.polygon&&e.polygon.list&&e.polygon.list.length>=3){t.style.width="100%",t.style.height="100%";let i=e.polygon.list;const s=e.polygon.color,r=e.polygon.lineWidth;if(i=i.sort(((e,t)=>(e.index||0)-(t.index||0))),e.polygon.fill){const s=document.createElement("div");s.style.position="absolute",s.style.width="100%",s.style.height="100%";const r="polygon("+i.map((e=>`${e.x}px ${e.y}px`)).join(", ")+")";s.style.clipPath=r,s.style.backgroundColor=e.polygon.fill,e.polygon.fillOpacity&&(s.style.opacity=e.polygon.fillOpacity),t.appendChild(s)}i.forEach(((e,a)=>{const o=document.createElement("div");if(a===i.length-1){const a=i[0],n={x1:e.x,y1:e.y,x2:a.x,y2:a.y,color:s,lineWidth:r};return this.settingLine(o,n),void t.appendChild(o)}const n=i[a+1],l={x1:e.x,y1:e.y,x2:n.x,y2:n.y,color:s,lineWidth:r};this.settingLine(o,l),t.appendChild(o)}))}this.isDynamic&&(this.shadowRootDynamicDom=t),this.shadowRootInnerDom.appendChild(t)}}))}settingLine(e,t){const i=t.x1,s=t.y1,r=t.x2,a=t.y2;var o=Math.sqrt((i-r)**2+(s-a)**2),n=180*Math.atan2(a-s,r-i)/Math.PI;e.style.backgroundColor=t.color,e.style.width=o+"px",e.style.height=t.lineWidth+"px",e.style.position="absolute",e.style.top=s+"px",e.style.left=i+"px",e.style.transform="rotate("+n+"deg)",e.style.transformOrigin="0 0"}remove(){this._removeDom()}_removeDom(){this.shadowRootInnerDom&&(this.shadowRootInnerDom.innerHTML="")}}class Eo extends po{constructor(){super(),this.videoInfo={width:null,height:null,encType:null,encTypeCode:null},this.init=!1,this.prevAiFaceDetectTime=null,this.prevAiObjectDetectTime=null,this.prevOcclusionDetectTime=null,this.contentWatermark=null,this.aiContentWatermark=null,this.tempContentList=[],this.tempAiContentList=[],this.streamFps=0}destroy(){this.resetInit(),this.contentWatermark&&(this.contentWatermark.destroy(),this.contentWatermark=null),this.tempContentList=[],this.aiContentWatermark&&(this.aiContentWatermark.destroy(),this.aiContentWatermark=null),this.tempAiContentList=[],this.prevAiFaceDetectTime=null,this.prevAiObjectDetectTime=null,this.streamFps=0,this.off()}resetInit(){this.videoInfo={width:null,height:null,encType:null,encTypeCode:null},this.init=!1}getHasInit(){return this.init}updateVideoInfo(e){Ta(e.encTypeCode)&&(this.videoInfo.encType=bt[e.encTypeCode],this.videoInfo.encTypeCode=e.encTypeCode),Ta(e.encType)&&(this.videoInfo.encType=e.encType),Ta(e.width)&&(this.videoInfo.width=e.width),Ta(e.height)&&(this.videoInfo.height=e.height),Ta(this.videoInfo.encType)&&Ta(this.videoInfo.height)&&Ta(this.videoInfo.width)&&!this.init&&(this.player.emit(nt.videoInfo,this.videoInfo),this.init=!0)}getVideoInfo(){return this.videoInfo}clearView(){this.tempContentList=[],this.tempAiContentList=[]}resize(){if(this.player.debug.log("CommonVideo","resize()"),"default"===this.player._opt.aspectRatio||ra()?this._resize():this._resizeRatio(),this.contentWatermark&&this.contentWatermark.resize(),this.aiContentWatermark&&this.aiContentWatermark.resize(),this.player.singleWatermark&&this.player.singleWatermark.resize(),this.player.ghostWatermark&&this.player.ghostWatermark.resize(),this.player.dynamicWatermark&&this.player.dynamicWatermark.resize(),this.player.zoom&&this.player.zooming){const e=this._getStyleScale();this.player.zoom.updatePrevVideoElementStyleScale(e),this.player.zoom.updateVideoElementScale()}}_resizeRatio(){this.player.debug.log("CommonVideo","_resizeRatio()");const e=this.player._opt.aspectRatio.split(":").map(Number);let t=this.player.width,i=this.player.height;const s=this.player._opt;let r=0;s.hasControl&&!s.controlAutoHide&&(r=s.playType===v?zt:jt,i-=r);const a=this.videoInfo,o=a.width/a.height,n=e[0]/e[1];if(this.getType()===V&&(this.$videoElement.style.left="0",this.$videoElement.style.top="0",this.$videoElement.style.transform="none"),this.getType()===W&&this.player._opt.videoRenderSupportScale&&(this.$videoElement.style.objectFit="fill"),o>n){const e=n*a.height/a.width;this.$videoElement.style.width=100*e+"%",this.$videoElement.style.height=`calc(100% - ${r}px)`,this.$videoElement.style.padding=`0 ${(t-t*e)/2}px`}else{const e=a.width/n/a.height;this.$videoElement.style.width="100%",this.$videoElement.style.height=`calc(${100*e}% - ${r}px)`,this.$videoElement.style.padding=(i-i*e)/2+"px 0"}}play(){}pause(){}setRate(e){}getType(){return""}getCanvasType(){return""}getCurrentTime(){return 0}getStreamFps(){return this.streamFps}isPlaying(){return!0}getPlaybackQuality(){return null}setStreamFps(e){this.player.debug.log("CommonVideo","setStreamFps",e),this.streamFps=e}addContentToCanvas(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.tempContentList=e}addAiContentToCanvas(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.tempAiContentList=e}doAddContentToWatermark(){if(this.tempContentList.length>0){this.contentWatermark||(this.contentWatermark=new wo(this.player),this.contentWatermark.resize());const e=[];this.tempContentList.forEach((t=>{let i={left:t.x||0,top:t.y||0};"text"===t.type?i.text={content:t.text,fontSize:t.fontSize||"14",color:t.color||"#000"}:"rect"===t.type?i.rect={width:t.width,height:t.height,color:t.color||"green",lineWidth:t.lineWidth||2,fill:t.fill||"",fillOpacity:t.fillOpacity||.2}:"polygon"===t.type?i.polygon={list:t.list,color:t.color||"green",lineWidth:t.lineWidth||2,fill:t.fill,fillOpacity:t.fillOpacity||.2}:"line"===t.type&&(i.line={color:t.color||"green",lineWidth:t.lineWidth||2,x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2}),e.push(i)})),this.contentWatermark.update(e)}else this.contentWatermark&&this.contentWatermark.remove()}doAddAiContentToWatermark(){if(this.tempAiContentList.length>0){this.aiContentWatermark||(this.aiContentWatermark=new wo(this.player),this.aiContentWatermark.resize());const e=this.tempAiContentList.map((e=>{let 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.aiContentWatermark.update(e)}else this.aiContentWatermark&&this.aiContentWatermark.remove()}_getStyleScale(){let e=this.$videoElement.style.transform.match(/scale\([0-9., ]*\)/g),t="";if(e&&e[0]){t=e[0].replace("scale(","").replace(")","").split(",")}return t}getReadyStateInited(){return!0}}var To="object"==typeof window&&window.window===window?window:"object"==typeof self&&self.self===self?self:"object"==typeof global&&global.global===global?global:void 0;function ko(e,t,i){var s=new XMLHttpRequest;s.open("GET",e),s.responseType="blob",s.onload=function(){Do(s.response,t,i)},s.onerror=function(){console.error("could not download file")},s.send()}function Co(e){var t=new XMLHttpRequest;t.open("HEAD",e,!1);try{t.send()}catch(e){}return t.status>=200&&t.status<=299}function Ro(e){try{e.dispatchEvent(new MouseEvent("click"))}catch(i){var t=document.createEvent("MouseEvents");t.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),e.dispatchEvent(t)}}var xo=To.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),Do="object"!=typeof window||window!==To?function(){}:"download"in HTMLAnchorElement.prototype&&!xo?function(e,t,i){var s=To.URL||To.webkitURL,r=document.createElementNS("http://www.w3.org/1999/xhtml","a");t=t||e.name||"download",r.download=t,r.rel="noopener","string"==typeof e?(r.href=e,r.origin!==location.origin?Co(r.href)?ko(e,t,i):Ro(r,r.target="_blank"):Ro(r)):(r.href=s.createObjectURL(e),setTimeout((function(){s.revokeObjectURL(r.href)}),4e4),setTimeout((function(){Ro(r)}),0))}:"msSaveOrOpenBlob"in navigator?function(e,t,i){if(t=t||e.name||"download","string"==typeof e)if(Co(e))ko(e,t,i);else{var s=document.createElement("a");s.href=e,s.target="_blank",setTimeout((function(){Ro(s)}))}else navigator.msSaveOrOpenBlob(function(e,t){return void 0===t?t={autoBom:!1}:"object"!=typeof t&&(console.warn("Deprecated: Expected third argument to be a object"),t={autoBom:!t}),t.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}(e,i),t)}:function(e,t,i,s){if((s=s||open("","_blank"))&&(s.document.title=s.document.body.innerText="downloading..."),"string"==typeof e)return ko(e,t,i);var r="application/octet-stream"===e.type,a=/constructor/i.test(To.HTMLElement)||To.safari,o=/CriOS\/[\d]+/.test(navigator.userAgent);if((o||r&&a||xo)&&"undefined"!=typeof FileReader){var n=new FileReader;n.onloadend=function(){var e=n.result;e=o?e:e.replace(/^data:[^;]*;/,"data:attachment/file;"),s?s.location.href=e:location=e,s=null},n.readAsDataURL(e)}else{var l=To.URL||To.webkitURL,d=l.createObjectURL(e);s?s.location=d:location.href=d,s=null,setTimeout((function(){l.revokeObjectURL(d)}),4e4)}};class Lo{constructor(e,t){this.canvas=e,this.gl=t;const i=t.createShader(t.VERTEX_SHADER);if(t.shaderSource(i,"\n attribute vec2 xy;\n varying highp vec2 uv;\n void main(void) {\n gl_Position = vec4(xy, 0.0, 1.0);\n // Map vertex coordinates (-1 to +1) to UV coordinates (0 to 1).\n // UV coordinates are Y-flipped relative to vertex coordinates.\n uv = vec2((1.0 + xy.x) / 2.0, (1.0 - xy.y) / 2.0);\n }\n "),t.compileShader(i),!t.getShaderParameter(i,t.COMPILE_STATUS))throw t.getShaderInfoLog(i);const s=t.createShader(t.FRAGMENT_SHADER);if(t.shaderSource(s,"\n varying highp vec2 uv;\n uniform sampler2D texture;\n void main(void) {\n gl_FragColor = texture2D(texture, uv);\n }\n "),t.compileShader(s),!t.getShaderParameter(s,t.COMPILE_STATUS))throw t.getShaderInfoLog(s);const r=t.createProgram();if(t.attachShader(r,i),t.attachShader(r,s),t.linkProgram(r),!t.getProgramParameter(r,t.LINK_STATUS))throw t.getProgramInfoLog(r);t.useProgram(r);const a=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,a),t.bufferData(t.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),t.STATIC_DRAW);const o=t.getAttribLocation(r,"xy");t.vertexAttribPointer(o,2,t.FLOAT,!1,0,0),t.enableVertexAttribArray(o);const n=t.createTexture();t.bindTexture(t.TEXTURE_2D,n),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),this.program=r,this.buffer=a,this.vertexShader=i,this.fragmentShader=s,this.texture=n}destroy(){this.gl.deleteProgram(this.program),this.gl.deleteBuffer(this.buffer),this.gl.deleteTexture(this.texture),this.gl.deleteShader(this.vertexShader),this.gl.deleteShader(this.fragmentShader),this.program=null,this.buffer=null,this.vertexShader=null,this.fragmentShader=null,this.texture=null}render(e){this.canvas.width=e.displayWidth,this.canvas.height=e.displayHeight;const t=this.gl;t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e),t.viewport(0,0,t.drawingBufferWidth,t.drawingBufferHeight),t.clearColor(1,0,0,1),t.clear(t.COLOR_BUFFER_BIT),t.drawArrays(t.TRIANGLE_FAN,0,4)}}class Po extends Eo{constructor(e){super(),this.player=e;const 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.isWcsWebgl2=!1,this.bitmaprenderer=null,this.renderType=null,this.controlHeight=0,this.proxyDestroyList=[],this._initCanvasRender()}destroy(){super.destroy(),this.proxyDestroyList.length>0&&(this.proxyDestroyList.forEach((e=>{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.player.$container.removeChild(this.$videoElement),this.init=!1,this.off()}_initContext2D(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.context2D=this.$videoElement.getContext("2d",e)}_initContextGl(){if(this.player.events,this.contextGl=qr(this.$videoElement),!this.contextGl)throw this.player.debug.error("CommonCanvasLoader","_initContextGl() createContextGL error"),new Error("CommonCanvasLoader and _initContextGl createContextGL error");this._bindContextGlEvents(),this.webglRender=new vo(this.contextGl,this.player._opt.openWebglAlignment)}_initContextGl2(){if(this.contextGl=Kr(this.$videoElement),this.contextGl){this._bindContextGlEvents(2);try{this.webglRender=new Lo(this.$videoElement,this.contextGl)}catch(e){this.player.debug.error("CommonCanvasLoader",`create webgl2Render error is ${e} and next use context2d.draw render`),this.contextGl=null,this.webglRender=null,this._initContext2D()}}else this.player.debug.error("CommonCanvasLoader","_initContextGl2() createContextGL2 error")}_bindContextGlEvents(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;const{proxy:t}=this.player.events,i=t(this.$videoElement,"webglcontextlost",(t=>{t.preventDefault(),this.player.debug.error("canvasVideo","webglcontextlost error",t),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((()=>{if(this.player.debug.log("CommonCanvasLoader",`createContextGL() version ${e}`),1===e?this.contextGl=qr(this.$videoElement):2===e&&(this.contextGl=Kr(this.$videoElement)),this.player.debug.log("CommonCanvasLoader","createContextGL success"),this.contextGl&&this.contextGl.getContextAttributes){const t=this.contextGl.getContextAttributes();t&&t.stencil?(1===e?this.webglRender=new vo(this.contextGl,this.player._opt.openWebglAlignment):2===e&&(this.webglRender=new Lo(this.$videoElement,this.contextGl)),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(ct.webglContextLostError))}else this.player.debug.error("CommonCanvasLoader","webglcontextlost error, getContextAttributes().stencil is false"),this.player.emitError(ct.webglContextLostError)}),500)})),s=t(this.$videoElement,"webglcontextrestored",(e=>{e.preventDefault(),this.player.debug.log("CommonCanvasLoader","webglcontextrestored ",e)}));this.proxyDestroyList.push(i,s)}_initContextGPU(){var t;(t=this.$videoElement,new Promise(((e,i)=>{navigator.gpu?navigator.gpu.requestAdapter().then((s=>{s?s.requestDevice().then((r=>{if(r){const a=t.getContext("webgpu");if(a){const t=navigator.gpu.getPreferredCanvasFormat();a.configure({device:r,format:t,alphaMode:"opaque"}),e({adapter:s,device:r,context:a,format:t})}else i('WebGPU "context" create fail')}else i('WebGPU "device" request fail')})).catch((e=>{i('WebGPU "adapter.requestDevice()" fail')})):i('WebGPU "adapter" request fail is empty')})).catch((e=>{i('WebGPU "navigator.gpu.requestAdapter()" fail')})):i("WebGPU not support!!")}))).then((t=>{t?(this.webGPURender=new So(t),this.player.debug.log("CommonCanvasLoader","webGPURender init success")):(this.player.debug.warn("CommonCanvasLoader",`createWebGPUContext error is ${e} and next use webgl render`),this.renderType=Wt,this._initContextGl())})).catch((e=>{this.player.debug.warn("CommonCanvasLoader",`createWebGPUContext error is ${e} and next use webgl render`),this.renderType=Wt,this._initContextGl()}))}initCanvasViewSize(){this.$videoElement.width=this.videoInfo.width,this.$videoElement.height=this.videoInfo.height,this.resize()}screenshot(e,t,i,s){e=e||Qr(),s=s||gt.download;let r=.92;!Ni[t]&&gt[t]&&(s=t,t="png",i=void 0),"string"==typeof i&&(s=i,i=void 0),void 0!==i&&(r=Number(i));const a=Ni[t]||Ni.png,o=this.$videoElement.toDataURL(a,r);if(s===gt.base64)return o;{const t=Yr(o);if(s===gt.blob)return t;if(s===gt.download){const i=a.split("/")[1];Do(t,e+"."+i)}}}screenshotWatermark(e){return new Promise(((t,i)=>{Fa(e)&&(e={filename:e}),(e=e||{}).width=this.videoInfo.width,e.height=this.videoInfo.height,e.filename=e.filename||Qr(),e.format=e.format?Ni[e.format]:Ni.png,e.quality=Number(e.quality)||.92,e.type=e.type||gt.download;const s=this.$videoElement.toDataURL(e.format,e.quality);Ra(s,e).then((i=>{if(e.type===gt.base64)t(s);else{const s=Yr(i);if(e.type===gt.blob)t(s);else if(e.type===gt.download){t();const i=e.format.split("/")[1];Do(s,e.filename+"."+i)}}})).catch((e=>{i(e)}))}))}render(){}clearView(){super.clearView()}play(){}pause(){}_resize(){this.player.debug.log("canvasVideo","_resize()");const e=this.player._opt;let t=this.player.width,i=this.player.height;if(e.hasControl&&!e.controlAutoHide){const s=this.controlHeight;ra()&&this.player.fullscreen&&e.useWebFullScreen?t-=s:i-=s}let s=this.$videoElement.width,r=this.$videoElement.height;const a=e.rotate;let o=(t-s)/2,n=(i-r)/2;270!==a&&90!==a||(s=this.$videoElement.height,r=this.$videoElement.width);const l=t/s,d=i/r;let h=l>d?d:l;ro(e.isResize)&&l!==d&&(h=l+","+d),e.isFullResize&&(h=l>d?l:d);let c="scale("+h+")";"none"===e.mirrorRotate&&a&&(c+=" rotate("+a+"deg)"),"level"===e.mirrorRotate?c+=" rotateY(180deg)":"vertical"===e.mirrorRotate&&(c+=" rotateX(180deg)"),this.$videoElement.style.height=this.videoInfo.height+"px",this.$videoElement.style.width=this.videoInfo.width+"px",this.$videoElement.style.padding="0",this.$videoElement.style.transform=c,this.$videoElement.style.left=o+"px",this.$videoElement.style.top=n+"px"}initFps(){}setStreamFps(e){}getStreamFps(){return 25}getType(){return V}getCanvasType(){let e=this.renderType===qt?qt:Wt;return this.isWcsWebgl2&&(e=Jt),e}}class Bo extends Po{constructor(e){super(e),this.yuvList=[],this.controlHeight=jt,this.tempTextCanvas=null,this.tempTextCanvasCtx=null,this.player.debug.log("CanvasVideo","init")}async destroy(){super.destroy(),this.yuvList=[],this.tempTextCanvas&&(this.tempTextCanvasCtx.clearRect(0,0,this.tempTextCanvas.width,this.tempTextCanvas.height),this.tempTextCanvas.width=0,this.tempTextCanvas.height=0,this.tempTextCanvas=null),this.player.debug.log("CanvasVideoLoader","destroy")}_initCanvasRender(){this.player._opt.useWCS&&!this._supportOffscreen()?(this.renderType=Vt,no()&&this.player._opt.wcsUseWebgl2Render?(this._initContextGl2(),this.webglRender&&(this.isWcsWebgl2=!0)):this._initContext2D()):this.player._opt.useMSE&&this.player._opt.mseUseCanvasRender?(this.renderType=Yt,this._initContext2D()):this.player.isOldHls()&&this.player._opt.useCanvasRender?(this.renderType=Qt,this._initContext2D()):this.player.isWebrtcH264()&&this.player._opt.webrtcUseCanvasRender?(this.renderType=Xt,this._initContext2D()):this._supportOffscreen()?(this.renderType=Kt,this._bindOffscreen()):this.player._opt.useWebGPU?(this.renderType=qt,this._initContextGPU()):(this.renderType=Wt,this._initContextGl())}_supportOffscreen(){return"function"==typeof this.$videoElement.transferControlToOffscreen&&this.player._opt.useOffscreen}_bindOffscreen(){this.bitmaprenderer=this.$videoElement.getContext("bitmaprenderer")}render(e){this.yuvList.push(e),this.startRender()}startRender(){for(;!(this.yuvList.length<=0);){const e=this.yuvList.shift();this.doRender(e)}}doRender(e){if(this.renderType!==Yt){const t={ts:e.ts||0,fps:!0};this.player.updateStats(t)}switch(this.renderType){case Kt:this.bitmaprenderer.transferFromImageBitmap(e.buffer);break;case Wt:case qt:if(this.isWebglContextLost)return void this.player.debug.warn("CanvasVideoLoader","doRender() and webgl context is lost");let t=e.output;if(this.player.faceDetectActive&&this.player.ai&&this.player.ai.faceDetector){null===this.prevAiFaceDetectTime&&(this.prevAiFaceDetectTime=Qr());const i=Qr();i-this.prevAiFaceDetectTime>=this.player._opt.aiFaceDetectInterval&&(t=this.player.ai.faceDetector.detect({width:this.$videoElement.width,height:this.$videoElement.height,data:e.output,ts:e.ts||0}),this.prevAiFaceDetectTime=i)}if(this.player.objectDetectActive&&this.player.ai&&this.player.ai.objectDetector){null===this.prevAiObjectDetectTime&&(this.prevAiObjectDetectTime=Qr());const i=Qr();i-this.prevAiObjectDetectTime>=this.player._opt.aiObjectDetectInterval&&(t=this.player.ai.objectDetector.detect({width:this.$videoElement.width,height:this.$videoElement.height,data:e.output,ts:e.ts||0}),this.prevAiObjectDetectTime=i)}if(this.player.occlusionDetectActive&&this.player.ai&&this.player.ai.occlusionDetector){null===this.prevAiOcclusionDetectTime&&(this.prevAiOcclusionDetectTime=Qr());const t=Qr();if(t-this.prevAiOcclusionDetectTime>=this.player._opt.aiOcclusionDetectInterval){const i=this.player.ai.occlusionDetector.check({width:this.$videoElement.width,height:this.$videoElement.height,data:e.output});this.prevAiOcclusionDetectTime=t,i&&this.player.emit(nt.aiOcclusionDetectResult,{ts:e.ts||0})}}if(this.player.imageDetectActive&&this.player.ai&&this.player.ai.imageDetector){const t=this.player.ai.imageDetector.check({width:this.$videoElement.width,height:this.$videoElement.height,data:e.output});if(t&&t.data&&(this.player.emit(nt.aiOcclusionDetectResult,{type:t.type,ts:e.ts||0}),this.player._opt.aiImageDetectDrop))return void this.player.debug.log("CanvasVideoLoader",`doRender() and ai image detect result type is ${t.type} and drop`)}if(this.renderType===qt)try{if(!this.webGPURender)return void this.player.debug.warn("CanvasVideoLoader","doRender webgpu render is not init");this.webGPURender.renderYUV(this.$videoElement.width,this.$videoElement.height,t)}catch(e){this.player.debug.error("CanvasVideoLoader",`doRender webgpu render and error: ${e.toString()}`)}else if(this.renderType===Wt)try{this.webglRender.renderYUV(this.$videoElement.width,this.$videoElement.height,t)}catch(e){this.player.debug.error("CanvasVideoLoader",`doRender webgl render context is lost ${this.contextGl&&this.contextGl.isContextLost()} and error: ${e.toString()}`)}break;case Vt:if(this.webglRender)this.webglRender.render(e.videoFrame),Ja(e.videoFrame);else if(this.context2D)if(Ga(e.videoFrame.createImageBitmap))try{e.videoFrame.createImageBitmap().then((t=>{this.context2D.drawImage(t,0,0,this.$videoElement.width,this.$videoElement.height),Ja(e.videoFrame)}))}catch(e){}else this.context2D.drawImage(e.videoFrame,0,0,this.$videoElement.width,this.$videoElement.height),Ja(e.videoFrame);else this.player.debug.warn("CanvasVideoLoader","doRender() and webcodecs context is lost");break;case Yt:case Qt:case Xt:this.context2D.drawImage(e.$video,0,0,this.$videoElement.width,this.$videoElement.height)}let t=e.ts||0;this.renderType===Yt&&(t=parseInt(1e3*e.$video.currentTime,10)+(this.player.mseDecoder.firstRenderTime||0)),this.player.updateCurrentPts(t),this.doAddContentToWatermark(),this.doAddAiContentToWatermark()}clearView(){switch(super.clearView(),this.renderType){case Kt:(function(e,t){const i=document.createElement("canvas");i.width=e,i.height=t;const s=window.createImageBitmap(i,0,0,e,t);return i.width=0,i.height=0,s})(this.$videoElement.width,this.$videoElement.height).then((e=>{this.bitmaprenderer.transferFromImageBitmap(e)}));break;case Wt:this.contextGl.clear(this.contextGl.COLOR_BUFFER_BIT);break;case qt:this.webGPURender.clear();break;case Vt:this.contextGl?this.contextGl.clear(this.contextGl.COLOR_BUFFER_BIT):this.context2D&&this.context2D.clearRect(0,0,this.$videoElement.width,this.$videoElement.height);break;case Yt:case Qt:case Xt:this.context2D.clearRect(0,0,this.$videoElement.width,this.$videoElement.height)}}_initTempTextCanvas(){this.tempTextCanvas=document.createElement("canvas"),this.tempTextCanvasCtx=this.tempTextCanvas.getContext("2d"),this.tempTextCanvas.width=600,this.tempTextCanvas.height=20}doAddContentToCanvas(){this.tempContentList.length>0&&this.context2D&&function(e){let{ctx:t,list:i}=e;t.save(),(i||[]).forEach((e=>{"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()}({ctx:this.context2D,list:this.tempContentList})}doAddContentToWebGlCanvas(){this.tempContentList.length>0&&this.contextGl&&this.webglRectRender&&this.tempContentList.forEach((e=>{const t=e.x,i=e.y;if("rect"===e.type){const r=e.width,a=e.height,o=(s=e.color||"#008000",[parseInt(s.substring(1,3),16)/255,parseInt(s.substring(3,5),16)/255,parseInt(s.substring(5,7),16)/255,1]),n=e.lineWidth||4;if(!r||!a)return;this.webglRectRender.drawBox({x:t,y:i,width:r,height:a,lineColor:o,lineWidth:n,canvasWidth:this.$videoElement.width,canvasHeight:this.$videoElement.height})}else if("text"===e.type){const s=e.text||"";if(!s)return;const r=e.fontSize||20,a=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=a,this.tempTextCanvasCtx.textBaseline="top",this.tempTextCanvasCtx.fillText(s,0,0),this.webglRender.drawDom(this.$videoElement.width,this.$videoElement.height,t,i,this.tempTextCanvas)}var s}))}}class Io extends Eo{constructor(e){super(),this.player=e,this.TAG_NAME="Video";const t=document.createElement("video"),i=document.createElement("canvas");t.muted=!0,t.style.position="absolute",t.style.top=0,t.style.left=0,this._delayPlay=!1,e.$container.appendChild(t),this.$videoElement=t,this.$canvasElement=i,this.canvasContext=i.getContext("2d"),this.mediaStream=null,this.vwriter=null,e.canVideoTrackWritter()&&_a()&&va()&&(this.trackGenerator=new MediaStreamTrackGenerator({kind:"video"}),this.mediaStream=new MediaStream([this.trackGenerator]),t.srcObject=this.mediaStream,this.vwriter=this.trackGenerator.writable.getWriter()),this.fixChromeVideoFlashBug(),this.player.debug.log(this.TAG_NAME,"fixChromeVideoFlashBug"),this.fixMobileAutoFullscreen(),this.player.debug.log(this.TAG_NAME,"fixMobileAutoFullscreen"),this.resize(),this.player.debug.log(this.TAG_NAME,"resize"),this.eventListenList=[],this.isRenderRetryPlaying=!1,this.isRenderRetryPlayingTimes=0,this.isRetryPlaying=!1,this.isRetryPlayingTimes=0,this.canplayReceived=!1,this.progressProxyDestroy=null,this.checkVideoCanplayTimeout=null;const s=ho();this.player.debug.log(this.TAG_NAME,"isSupportVideoFrameCallback"),this.supportVideoFrameCallbackHandle=null;const{proxy:r}=this.player.events;this.player.debug.log(this.TAG_NAME,"proxy");const a=r(this.$videoElement,"canplay",(()=>{this.player.debug.log("Video","canplay"),this.player.isDestroyedOrClosed()||(this.canplayReceived=!0,this._delayPlay?(this.clearCheckVideoCanplayTimeout(),this._play(),ho()?this.supportVideoFrameCallbackHandle||(this.supportVideoFrameCallbackHandle=this.$videoElement.requestVideoFrameCallback(this.videoFrameCallback.bind(this))):this.player.debug.warn("Video","not support requestVideoFrameCallback and use timeupdate event to update stats")):this.$videoElement.paused&&this.player.isMSEPlaybackRateChangePause&&(this.player.debug.log("Video",`canplay and video is paused and isMSEPlaybackRateChangePause is ${this.player.isMSEPlaybackRateChangePause} so next try to play`),this.player.isMSEPlaybackRateChangePause=!1,this.$videoElement.play()))})),o=r(this.$videoElement,"waiting",(()=>{this.player.debug.log("Video","waiting")})),n=r(this.$videoElement,"loadedmetadata",(()=>{this.player.debug.log("Video","loadedmetadata")})),l=r(this.$videoElement,"timeupdate",(t=>{if(!this.player.isDestroyedOrClosed()){if(ro(s)){const t=parseInt(1e3*this.getCurrentTime(),10);(e.isWebrtcH264()||this.player.isOldHls()||this.player.isAliyunRtc())&&(this.player.emit(nt.timeUpdate,t),e.handleRender(),e.updateStats({fps:!0,ts:t,dts:t}))}this.player.isMseDecoderUseWorker()&&(this.player.decoderWorker.updateVideoTimestamp(this.getCurrentTime()),this._handleUpdatePlaybackRate())}})),d=r(this.$videoElement,"error",(()=>{let e={};if(this.player.isUseMSE()&&(e=this.player.getMseMineType()),this.player.debug.error("Video","Error Code "+this.$videoElement.error.code+" "+rr[this.$videoElement.error.code]+"; Details: "+this.$videoElement.error.message+"; Video Info: "+JSON.stringify(this.videoInfo)+"; Mse Mine Type: "+e.video+"; "),this.player.isUseMSE()){this.$videoElement.error.code;const e=this.$videoElement.error.message;-1!==e.indexOf(ar)&&(this.player.isMSEVideoDecoderInitializationFailedNotSupportHevc=!0),-1!==e.indexOf(or)&&(this.player.isMSEAudioDecoderError=!0)}this.player.isHlsCanVideoPlay()})),h=r(this.$videoElement,"stalled",(()=>{this._detectAndFixStuckPlayback(!0)}));if(this.progressProxyDestroy=r(this.$videoElement,"progress",(()=>{this._detectAndFixStuckPlayback()})),this.player.debug.log(this.TAG_NAME,"eventListenList"),this.eventListenList.push(a,o,l,d,n,h),this.player.isUseMSE()){const e=r(this.$videoElement,Ki,(()=>{this.player.debug.log(this.TAG_NAME,"video playback Rate change",this.$videoElement&&this.$videoElement.playbackRate),this.$videoElement&&this.$videoElement.paused&&(this.player.debug.warn(this.TAG_NAME,"ratechange and video is paused and sent isMSEPlaybackRateChangePause true"),this.player.isMSEPlaybackRateChangePause=!0)}));this.eventListenList.push(e),this.player.on(nt.visibilityChange,(e=>{e&&setTimeout((()=>{if(this.player.isPlaying()&&this.$videoElement){const e=this.getVideoBufferLastTime();e-this.$videoElement.currentTime>this.getBufferMaxDelayTime()&&(this.player.debug.log(this.TAG_NAME,`visibilityChange is true and lastTime is ${e} and currentTime is ${this.$videoElement.currentTime} so set currentTime to lastTime`),this.$videoElement.currentTime=e)}}),300)}))}this.player.debug.log("Video","init")}async destroy(){if(super.destroy(),this.clearCheckVideoCanplayTimeout(),this._cancelVideoFrameCallback(),this._removeProgressProxyDestroy(),this.eventListenList.length&&(this.eventListenList.forEach((e=>{e()})),this.eventListenList=[]),this.isRenderRetryPlaying=!1,this.isRenderRetryPlayingTimes=0,this.isRetryPlaying=!1,this.isRetryPlayingTimes=0,this.canplayReceived=!1,this.player._opt.videoRenderSupportScale&&this._isNeedAddBackDropFilter()){const e=this.player.$container;e.style.backdropFilter="none",e.style.transform="none"}if(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&&(await 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")}videoFrameCallback(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.player.isDestroyedOrClosed())return void this.player.debug.log("Video","videoFrameCallback() and isDestroyedOrClosed and return");this.player.handleRender();const i=parseInt(1e3*Math.max(t.mediaTime,this.getCurrentTime()),10)||0;if(this.player.isUseHls265UseMse())this.player.updateStats({fps:!0,ts:i});else if(this.player.isMseDecoderUseWorker()){this.player._times.videoStart||(this.player._times.videoStart=Qr(),this.player.handlePlayToRenderTimes());const e=i+(this.player._mseWorkerData.firstRenderTime||0);if(this.player.updateStats({fps:!0,dfps:!0,ts:e,mseTs:i}),this.player.emit(nt.timeUpdate,e),ro(this.getHasInit())&&t.width&&t.height){const e={width:t.width,height:t.height};this.updateVideoInfo(e),this.initCanvasViewSize()}}if(this.player.isWebrtcH264()||this.player.isOldHls()||this.player.isAliyunRtc()){if(this.player.emit(nt.timeUpdate,i),ro(this.getHasInit())&&t.width&&t.height){const e={width:t.width,height:t.height};this.videoInfo.encTypeCode||this.player.isOldHls()||(e.encTypeCode=_t),this.updateVideoInfo(e)}this.player.updateStats({fps:!0,ts:i,dts:i}),this.player.updateCurrentPts(i),this.doAddContentToWatermark()}else if(so(this.player._opt.useMSE)&&ro(this.player._opt.mseUseCanvasRender)){if(this.player.mseDecoder){let e=parseInt(1e3*Math.max(t.mediaTime,this.getCurrentTime()),10)+(this.player.mseDecoder.firstRenderTime||0);this.player.updateCurrentPts(e)}else if(this.player._opt.mseDecoderUseWorker){let e=parseInt(1e3*Math.max(t.mediaTime,this.getCurrentTime()),10)+(this.player._mseWorkerData.firstRenderTime||0);this.player.updateCurrentPts(e)}this.doAddContentToWatermark()}this.supportVideoFrameCallbackHandle=this.$videoElement.requestVideoFrameCallback(this.videoFrameCallback.bind(this))}fixChromeVideoFlashBug(){if(this.player._opt.videoRenderSupportScale&&this._isNeedAddBackDropFilter()){const e=this.player.$container;e.style.backdropFilter="blur(0px)",e.style.transform="translateZ(0)"}}fixMobileAutoFullscreen(){const e=da(),t=oa();(e||t)&&(this.player.debug.log("Video",`fixMobileAutoFullscreen and isIOS ${e} and isAndroid ${t}`),this.$videoElement.setAttribute("webkit-playsinline","true"),this.$videoElement.setAttribute("playsinline","true"),this.$videoElement.setAttribute("x5-video-player-type","h5-page"))}_detectAndFixStuckPlayback(e){const t=this.$videoElement,i=t.buffered,s=t.readyState;this.player.debug.log(this.TAG_NAME,`_detectAndFixStuckPlayback() and isStalled is ${e} ,canplayReceived is ${this.canplayReceived} ,videoReadyState is ${s}`),e||ro(this.canplayReceived)||s<2?i.length>0&&t.currentTime<i.start(0)&&(this.player.debug.warn(this.TAG_NAME,`_detectAndFixStuckPlayback() and video is stuck and currentTime is ${t.currentTime} ,seek to ${i.start(0)}`),t.currentTime=i.start(0),this._removeProgressProxyDestroy()):this._removeProgressProxyDestroy()}_removeProgressProxyDestroy(){this.progressProxyDestroy&&(this.player.debug.log(this.TAG_NAME,"_removeProgressProxyDestroy()"),this.progressProxyDestroy(),this.progressProxyDestroy=null)}_isNeedAddBackDropFilter(){const e=la().type.toLowerCase();return"chrome"===e||"edge"===e}isPaused(){let e=!0;return this.$videoElement&&(e=this.$videoElement.paused),e}isPause(){return this.isPaused()}_getVideoReadyState(){let e=0;return this.$videoElement&&(e=this.$videoElement.readyState),e}_getVideoCurrentTime(){let e=0;return this.$videoElement&&(e=this.$videoElement.currentTime),e}play(){if(this.$videoElement){const e=this._getVideoReadyState();if(this.player.debug.log("Video",`play and readyState: ${e}`),0===e)return this.player.debug.log("Video","readyState is 0 and set _delayPlay to true and listen canplay event to play"),this._delayPlay=!0,void(null===this.checkVideoCanplayTimeout&&(this.checkVideoCanplayTimeout=setTimeout((()=>{if(this.clearCheckVideoCanplayTimeout(),!this.player.isDestroyedOrClosed()&&ro(this.isPlaying())){const e=this._getBufferStore();this.player.debug.warn("Video",`checkVideoCanplayTimeout and video is not playing and buffer store is ${e} and retry play`),this.$videoElement.currentTime=e,this._replay()}}),1e3)));this._play()}}_play(){this.$videoElement&&this.$videoElement.play().then((()=>{this._delayPlay=!1,this.player.debug.log("Video","_play success"),this.isPlaying()?(this.player.emit(nt.removeLoadingBgImage),this.isRetryPlayingTimes=0,this.isRetryPlaying=!1):setTimeout((()=>{this._replay()}),100)})).catch((e=>{this.player.isDestroyedOrClosed()?this.player.debug.log("Video","_play error and player is isDestroyedOrClosed and return"):(this.player.debug.error("Video","_play error",e),this.isRetryPlaying=!1,setTimeout((()=>{this._replay()}),100))}))}_replay(){if(!this.isPlaying()&&ro(this.player.isDestroyedOrClosed())&&ro(this.isRetryPlaying)){if(this.isRetryPlaying=!0,this.isRetryPlayingTimes>=3)return void(this.player.isWebrtcH264()?(this.player.debug.error("Video",`_replay(webrtc H264) then but not playing and retry play times is ${this.isRetryPlayingTimes} and emit error`),this.player.emitError(ct.videoElementPlayingFailedForWebrtc)):(this.player.debug.error("Video",`_replay then but not playing and retry play times is ${this.isRetryPlayingTimes} and emit error to use canvas render`),this.player.emitError(ct.videoElementPlayingFailed)));this.player.debug.warn("Video",`_play then but not playing and retry play and isRetryPlayingTimes is ${this.isRetryPlayingTimes}`),this._play(),this.isRetryPlayingTimes++}else this.player.debug.log("Video",`_replay() and isPlaying is ${this.isPlaying()} and isRetryPlaying is ${this.isRetryPlaying} and isDestroyedOrClosed is ${this.player.isDestroyedOrClosed()} and return;`)}pause(e){this.player.debug.log(this.TAG_NAME,"pause and isNow is "+e),this.isPlaying()&&(e?(this.$videoElement&&this.$videoElement.pause(),this._cancelVideoFrameCallback()):setTimeout((()=>{this.$videoElement&&this.$videoElement.pause(),this._cancelVideoFrameCallback()}),100))}clearView(){super.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,s){if(!this._canScreenshot())return this.player.debug.warn("Video",`screenshot failed, video is not ready and stats is ${this._getVideoReadyState()}`),null;e=e||Qr(),s=s||gt.download;let r=.92;!Ni[t]&&gt[t]&&(s=t,t="png",i=void 0),"string"==typeof i&&(s=i,i=void 0),void 0!==i&&(r=Number(i));const a=this.$videoElement;let o=this.$canvasElement;o.width=a.videoWidth,o.height=a.videoHeight,this.canvasContext.drawImage(a,0,0,o.width,o.height);const n=Ni[t]||Ni.png,l=o.toDataURL(n,r);if(this.canvasContext.clearRect(0,0,o.width,o.height),o.width=0,o.height=0,s===gt.base64)return l;{const t=Yr(l);if(s===gt.blob)return t;if(s===gt.download){const i=n.split("/")[1];Do(t,e+"."+i)}}}screenshotWatermark(e){return new Promise(((t,i)=>{if(Fa(e)&&(e={filename:e}),!this._canScreenshot())return this.player.debug.warn("Video","screenshot failed, video is not ready"),i("screenshot failed, video is not ready");const s=this.$videoElement;(e=e||{}).width=s.videoWidth,e.height=s.videoHeight,e.filename=e.filename||Qr(),e.format=e.format?Ni[e.format]:Ni.png,e.quality=Number(e.quality)||.92,e.type=e.type||gt.download;let r=this.$canvasElement;r.width=s.videoWidth,r.height=s.videoHeight,this.canvasContext.drawImage(s,0,0,r.width,r.height);const a=r.toDataURL(e.format,e.quality);this.canvasContext.clearRect(0,0,r.width,r.height),r.width=0,r.height=0,Ra(a,e).then((i=>{if(e.type===gt.base64)t(a);else{const s=Yr(i);if(e.type===gt.blob)t(s);else if(e.type===gt.download){t();const i=e.format.split("/")[1];Do(s,e.filename+"."+i)}}})).catch((e=>{i(e)}))}))}initCanvasViewSize(){this.resize()}clear(){const e=this.$videoElement,t=e.buffered,i=t.length?t.end(t.length-1):0;e.currentTime=i}render(e){if(this.vwriter){if(this.$videoElement.srcObject||(this.$videoElement.srcObject=this.mediaStream),this.isPaused()){const e=this._getVideoReadyState();if(this.player.debug.warn("Video","render() error, video is paused and readyState is "+e),4===e&&ro(this.isRenderRetryPlaying)){if(this.isRenderRetryPlaying=!0,this.isRenderRetryPlayingTimes>3)return this.player.debug.error("Video","render() error, video is paused and readyState is "+e+", retry times is "+this.isRenderRetryPlayingTimes+", emit error and use canvas render"),void this.player.emitError(ct.videoElementPlayingFailed);this.$videoElement.play().then((()=>{this.isRenderRetryPlayingTimes=0,this.isRenderRetryPlaying=!1,this.player.debug.log("Video","render() video is paused and replay success")})).catch((e=>{this.isRenderRetryPlaying=!1,this.isRenderRetryPlayingTimes++,this.player.debug.warn("Video","render() error, video is paused and replay error ",e)}))}}if(this.player.updateStats({fps:!0,ts:e.ts||0}),e.videoFrame)this.vwriter.write(e.videoFrame),Ja(e.videoFrame);else if(e.output){let s=e.output;if(this.player.faceDetectActive&&this.player.ai&&this.player.ai.faceDetector){null===this.prevAiFaceDetectTime&&(this.prevAiFaceDetectTime=Qr());const t=Qr();t-this.prevAiFaceDetectTime>this.player._opt.aiFaceDetectInterval&&(s=this.player.ai.faceDetector.detect({width:this.videoInfo.width,height:this.videoInfo.height,data:e.output,ts:e.ts||0}),this.prevAiFaceDetectTime=t)}if(this.player.objectDetectActive&&this.player.ai&&this.player.ai.objectDetector){null===this.prevAiObjectDetectTime&&(this.prevAiObjectDetectTime=Qr());const t=Qr();t-this.prevAiObjectDetectTime>this.player._opt.aiObjectDetectInterval&&(s=this.player.ai.objectDetector.detect({width:this.videoInfo.width,height:this.videoInfo.height,data:e.output,ts:e.ts||0}),this.prevAiObjectDetectTime=t)}if(this.player.occlusionDetectActive&&this.player.ai&&this.player.ai.occlusionDetector){null===this.prevAiOcclusionDetectTime&&(this.prevAiOcclusionDetectTime=Qr());const t=Qr();if(t-this.prevAiOcclusionDetectTime>=this.player._opt.aiOcclusionDetectInterval){const i=this.player.ai.occlusionDetector.check({width:this.videoInfo.width,height:this.videoInfo.height,data:e.output,ts:e.ts||0});this.prevAiOcclusionDetectTime=t,i&&(this.player.debug.log("Video","render() and ai occlusion detect result is true"),this.player.emit(nt.aiOcclusionDetectResult,{ts:e.ts||0}))}}if(this.player.imageDetectActive&&this.player.ai&&this.player.ai.imageDetector){const t=this.player.ai.imageDetector.check({width:this.videoInfo.width,height:this.videoInfo.height,data:e.output,ts:e.ts||0});if(t&&t.data&&(this.player.emit(nt.aiOcclusionDetectResult,{type:t.type,ts:e.ts||0}),this.player._opt.aiImageDetectDrop))return void this.player.debug.log("Video",`render() and ai image detect result type is ${t.type} and drop`)}try{const r=(t=s,i={format:"I420",codedWidth:this.videoInfo.width,codedHeight:this.videoInfo.height,timestamp:e.ts},new VideoFrame(t,i));this.vwriter.write(r),Ja(r)}catch(e){this.player.debug.error("Video","render error",e),this.player.emitError(ct.wasmUseVideoRenderError,e)}}this.player.updateCurrentPts(e.ts||0),this.doAddContentToWatermark(),this.doAddAiContentToWatermark()}else this.player.debug.warn("Video","render and this.vwriter is null");var t,i}_resize(){this.player.debug.log("Video","_resize()");let e=this.player.width,t=this.player.height;const i=this.player._opt,s=i.rotate;if(i.hasControl&&!i.controlAutoHide){const s=i.playType===v?zt:jt;ra()&&this.player.fullscreen&&i.useWebFullScreen?e-=s:t-=s}this.$videoElement.width=e,this.$videoElement.height=t,this.$videoElement.style.width=e+"px",this.$videoElement.style.height=t+"px",270!==s&&90!==s||(this.$videoElement.width=t,this.$videoElement.height=e,this.$videoElement.style.width=t+"px",this.$videoElement.style.height=e+"px");let r=(e-this.$videoElement.width)/2,a=(t-this.$videoElement.height)/2,o="contain";ro(i.isResize)&&(o="fill"),i.isFullResize&&(o="none");let n="";"none"===i.mirrorRotate&&s&&(n+=" rotate("+s+"deg)"),"level"===i.mirrorRotate?n+=" rotateY(180deg)":"vertical"===i.mirrorRotate&&(n+=" rotateX(180deg)"),this.player._opt.videoRenderSupportScale&&(this.$videoElement.style.objectFit=o),this.$videoElement.style.transform=n,this.$videoElement.style.padding="0",this.$videoElement.style.left=r+"px",this.$videoElement.style.top=a+"px"}getType(){return W}getCurrentTime(){return this.$videoElement.currentTime}isPlaying(){return this.$videoElement&&ro(this.$videoElement.paused)&&ro(this.$videoElement.ended)&&0!==this.$videoElement.playbackRate&&0!==this.$videoElement.readyState}_canScreenshot(){return this.$videoElement&&this.$videoElement.readyState>=1}getPlaybackQuality(){let e=null;if(this.$videoElement){if(Ga(this.$videoElement.getVideoPlaybackQuality)){const t=this.$videoElement.getVideoPlaybackQuality();e={droppedVideoFrames:t.droppedVideoFrames||t.corruptedVideoFrames,totalVideoFrames:t.totalVideoFrames,creationTime:t.creationTime}}else e={droppedVideoFrames:this.$videoElement.webkitDroppedFrameCount,totalVideoFrames:this.$videoElement.webkitDecodedFrameCount,creationTime:Qr()};e&&(e.renderedVideoFrames=e.totalVideoFrames-e.droppedVideoFrames)}return e}setRate(e){this.$videoElement&&(this.$videoElement.playbackRate=e)}get rate(){let e=1;return this.$videoElement&&(e=this.$videoElement.playbackRate),e}clearCheckVideoCanplayTimeout(){this.checkVideoCanplayTimeout&&(clearTimeout(this.checkVideoCanplayTimeout),this.checkVideoCanplayTimeout=null)}_cancelVideoFrameCallback(){this.supportVideoFrameCallbackHandle&&this.$videoElement&&(this.$videoElement.cancelVideoFrameCallback(this.supportVideoFrameCallbackHandle),this.supportVideoFrameCallbackHandle=null)}_getBufferStore(){const e=this.$videoElement;let t=0;return e.buffered.length>0&&(t=e.buffered.start(0)),t}_handleUpdatePlaybackRate(){const e=this.$videoElement,t=e.buffered;t.length&&t.start(0);const i=t.length?t.end(t.length-1):0;let s=e.currentTime;const r=i-s,a=this.getBufferMaxDelayTime();if(this.player.updateStats({mseVideoBufferDelayTime:r}),r>a)this.player.debug.log(this.TAG_NAME,`handleUpdatePlaybackRate and buffered is ${i} and current is ${s} , delay buffer is more than ${a} is ${r} and new time is ${i}`),e.currentTime=i,s=e.currentTime;else if(r<0){if(this.player.debug.warn(this.TAG_NAME,`handleUpdatePlaybackRate and delay buffer is ${i} - current is ${s} = ${r} < 0 and check video is paused : ${e.paused} `),0===i)return void this.player.emit(ct.mediaSourceBufferedIsZeroError,"video.buffered is empty");e.paused&&e.play()}const o=this._getPlaybackRate(i-s);e.playbackRate!==o&&(this.player.debug.log(this.TAG_NAME,`handleUpdatePlaybackRate and buffered is ${i} and current time is ${s} and delay is ${i-s} set playbackRate is ${o} `),e.playbackRate=o)}_getPlaybackRate(e){const t=this.$videoElement;let i=this.player._opt.videoBufferDelay+this.player._opt.videoBuffer;const s=Math.max(i,1e3),r=s/2;return e*=1e3,1===t.playbackRate?e>s?1.2:1:e<=r?1:t.playbackRate}getVideoCurrentTime(){let e=0;return this.$videoElement&&(e=this.$videoElement.currentTime),e}getVideoBufferLastTime(){const e=this.$videoElement;let t=0;if(e){const i=e.buffered;i.length&&i.start(0);t=i.length?i.end(i.length-1):0}return t}getVideoBufferDelayTime(){const e=this.$videoElement;const t=this.getVideoBufferLastTime()-e.currentTime;return t>0?t:0}checkSourceBufferDelay(){const e=this.$videoElement;let t=0,i=0;return e.buffered.length>0&&(i=e.buffered.end(e.buffered.length-1),t=i-e.currentTime),t<0&&(this.player.debug.warn(this.TAG_NAME,`checkVideoSourceBufferDelay ${t} < 0, and buffered is ${i} ,currentTime is ${e.currentTime} , try to seek ${e.currentTime} to ${i}`),e.currentTime=i,t=0),t}checkSourceBufferStore(){const e=this.$videoElement;let t=0;return e.buffered.length>0&&(t=e.currentTime-e.buffered.start(0)),t}getDecodePlaybackRate(){let e=0;const t=this.$videoElement;return t&&(e=t.playbackRate),e}getBufferMaxDelayTime(){let e=(this.player._opt.videoBuffer+this.player._opt.videoBufferDelay)/1e3;return Math.max(5,e+3)}getReadyStateInited(){return this._getVideoReadyState()>=1}}class Mo extends Po{constructor(e){super(e),this.controlHeight=zt,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(nt.playbackPause,(e=>{e?(this.pause(),this.player.playback.isPlaybackPauseClearCache&&this.clear()):this.resume()})),this.player.debug.log("CanvasPlaybackLoader","init")}async 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.useWCS?(this.renderType=Vt,no()&&this.player._opt.wcsUseWebgl2Render?(this._initContextGl2(),this.webglRender&&(this.isWcsWebgl2=!0)):this._initContext2D()):this.player._opt.useWebGPU?(this.renderType=qt,this._initContextGPU()):(this.renderType=Wt,this._initContextGl())}_sync(){this._stopSync(),this._doPlay(),this.playInterval=setInterval((()=>{this._doPlay()}),this.fragDuration)}_doPlay(){if(this.bufferList.length>0&&!this.player.seeking){const e=this.bufferList.shift();e&&e.buffer&&(this._doRender(e.buffer),this.player.handleRender(),this.player.playback.updateStats({ts:e.ts,tfTs:e.tfTs}))}}_stopSync(){this.playInterval&&(clearInterval(this.playInterval),this.playInterval=null)}_doRender(e){if(this.player._opt.useWCS)if(this.webglRender)this.webglRender.render(e),Ja(e);else if(Ga(e.createImageBitmap))try{e.createImageBitmap().then((t=>{this.context2D.drawImage(t,0,0,this.$videoElement.width,this.$videoElement.height),Ja(e)}))}catch(e){}else this.context2D.drawImage(e,0,0,this.$videoElement.width,this.$videoElement.height),Ja(e);else if(this.getCanvasType()===Wt)try{this.webglRender.renderYUV(this.$videoElement.width,this.$videoElement.height,e)}catch(e){this.player.debug.error("CanvasPlaybackLoader",`doRender webgl render context is lost ${this.contextGl&&this.contextGl.isContextLost()} and error: ${e.toString()}`)}else if(this.getCanvasType()===qt)try{if(!this.webGPURender)return void this.player.debug.warn("CanvasVideoLoader","doRender webgpu render is not init");this.webGPURender.renderYUV(this.$videoElement.width,this.$videoElement.height,e)}catch(e){this.player.debug.error("CanvasPlaybackLoader",`doRender webgpu render and error: ${e.toString()}`)}}get rate(){return this.playbackRate}get fragDuration(){return Math.ceil(1e3/(this.fps*this.playbackRate))}get bufferSize(){return this.bufferList.length}getStreamFps(){return this.streamFps}initFps(){this._hasCalcFps?this.player.debug.log("CanvasPlaybackLoader","initFps, has calc fps"):(this.preFps=Xr(this.player.playback.fps,1,100),this.fps=this.preFps)}setFps(e){e!==this.fps?(e>100&&this.player.debug.warn("CanvasPlaybackLoader","setFps max",e),e<0&&this.player.debug.warn("CanvasPlaybackLoader","setFps min",e),this.fps=Xr(e,1,100),this.player.debug.log("CanvasPlaybackLoader",`setFps ${this.preFps} -> ${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);const t={tfTs:e.ts-this._firstTimestamp,ts:e.ts};e.videoFrame?t.buffer=e.videoFrame:t.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);){const 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};e.videoFrame?t.buffer=e.videoFrame:t.buffer=e.output;const 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=Ya(this.bufferList);null!==e&&e!==this.preFps&&(this.player.debug.log("CanvasPlaybackLoader",`calc fps is ${e} pre fps is ${this.preFps} and updatePreFps`),this.setStreamFps(e))}if(!i){const e=this.bufferList.length,t=e/(this.fps*this.playbackRate);this.player.debug.log("CanvasPlaybackLoader","rate is",t),t<=1?this.setFps(this.preFps):(this.setFps(this.fps+Math.floor(t*this.playbackRate)),this.player.debug.warn("CanvasPlaybackLoader","rate is",t,"fps is",this.fps,"bufferListLength is",e))}}initVideo(){this.player.playback&&this.player.playback.isUseFpsRender&&this._sync(),this.playing=!0}initVideoDelay(){const e=this.player._opt.playbackDelayTime;e>0?this.delayTimeout=setTimeout((()=>{this.initVideo()}),e):this.initVideo()}clearView(){super.clearView(),this.contextGl.clear(this.contextGl.COLOR_BUFFER_BIT)}clear(){this.player._opt.useWCS&&this.bufferList.forEach((e=>{e.buffer&&Ja(e.buffer)})),this.bufferList=[]}resume(){this.player.playback.isUseFpsRender&&this._sync(),this.playing=!0}pause(){this.player.playback.isUseFpsRender&&this._stopSync(),this.playing=!1}}class Uo{constructor(e){return new(Uo.getLoaderFactory(e._opt))(e)}static getLoaderFactory(e){return e.useMSE?e.mseUseCanvasRender?Bo:Io:e.isHls&&ro(e.supportHls265)||e.isWebrtc&&ro(e.isWebrtcH265)?e.useCanvasRender?Bo:Io:e.isAliyunRtc?Io:e.useWCS?e.playType===v?Mo:!e.useOffscreen&&e.wcsUseVideoRender?Io:Bo:e.playType===v?Mo:e.wasmUseVideoRender&&!e.useOffscreen?Io:Bo}}class Fo extends po{constructor(e){super(),this.bufferList=[],this.player=e,this.$audio=null,this.scriptNode=null,this.workletProcessorNode=null,this.workletWorkerCloseTimeout=null,this.hasInitScriptNode=!1,this.audioContext=new(window.AudioContext||window.webkitAudioContext)({sampleRate:48e3}),this.gainNode=this.audioContext.createGain();const t=this.audioContext.createBufferSource();t.buffer=this.audioContext.createBuffer(1,1,22050),t.connect(this.audioContext.destination),t.noteOn?t.noteOn(0):t.start(0),this.audioBufferSourceNode=t,this.mediaStreamAudioDestinationNode=this.audioContext.createMediaStreamDestination(),this.gainNode.gain.value=0,this._prevVolume=null,this.playing=!1,this.audioInfo={encTypeCode:"",encType:"",channels:"",sampleRate:"",depth:""},this.init=!1,this.hasAudio=!1,this.audioResumeStateTimeout=null}async destroy(){return this.closeAudio(),this.resetInit(),this.clearAudioResumeStateTimeout(),this.audioContext&&(await this.audioContext.close(),this.audioContext=null),this.gainNode&&(this.gainNode.disconnect(),this.gainNode=null),this.hasAudio=!1,this.playing=!1,this.scriptNode&&(this.scriptNode.disconnect(),this.scriptNode.onaudioprocess=Jr,this.scriptNode=null),await this._destroyWorklet(),this.workletProcessorNode&&(this.workletProcessorNode.disconnect(),this.workletProcessorNode.port.onmessage=Jr,this.workletProcessorNode=null),this.audioBufferSourceNode&&(this.audioBufferSourceNode.stop(),this.audioBufferSourceNode=null),this.mediaStreamAudioDestinationNode&&(this.mediaStreamAudioDestinationNode.disconnect(),this.mediaStreamAudioDestinationNode=null),this.hasInitScriptNode=!1,this._prevVolume=null,this.off(),!0}_destroyWorklet(){return new Promise(((e,t)=>{this.workletProcessorNode?(this.workletProcessorNode.port.postMessage({type:"destroy"}),this.workletWorkerCloseTimeout=setTimeout((()=>{this.player.debug.log(this.TAG_NAME,"send close and wait 10ms destroy directly"),this.workletWorkerCloseTimeout&&(clearTimeout(this.workletWorkerCloseTimeout),this.workletWorkerCloseTimeout=null),e()}),10)):e()}))}resetInit(){this.audioInfo={encTypeCode:"",encType:"",channels:"",sampleRate:"",depth:""},this.init=!1}getAudioInfo(){return this.audioInfo}updateAudioInfo(e){e.encTypeCode&&(this.audioInfo.encTypeCode=e.encTypeCode,this.audioInfo.encType=kt[e.encTypeCode]),e.channels&&(this.audioInfo.channels=e.channels),e.sampleRate&&(this.audioInfo.sampleRate=e.sampleRate),e.depth&&(this.audioInfo.depth=e.depth),this.audioInfo.sampleRate&&this.audioInfo.channels&&this.audioInfo.encType&&!this.init&&(this.player.emit(nt.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}get audioContextState(){let e=null;return this.audioContext&&(e=this.audioContext.state),e}initScriptNode(){}initMobileScriptNode(){}initWorkletScriptNode(){}getEngineType(){return""}mute(e){e?(this.setVolume(0),this.clear()):this.setVolume(this.player.lastVolume||.5)}setVolume(e){e=parseFloat(e).toFixed(2),isNaN(e)||(this.audioEnabled(!0),e=Xr(e,0,1),null===this._prevVolume?this.player.emit(nt.mute,0===e):0===this._prevVolume&&e>0?this.player.emit(nt.mute,!1):this._prevVolume>0&&0===e&&this.player.emit(nt.mute,!0),this.gainNode.gain.value=e,this.player.emit(nt.volumechange,this.player.volume),this.player.emit(nt.volume,this.player.volume),this._prevVolume=e)}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(nt.audioResumeState,{state:this.audioContextState,isRunning:this.isStateRunning()})})),this.audioResumeStateTimeout=setTimeout((()=>{this.clearAudioResumeStateTimeout(),this.isStateSuspended()&&this.player.emit(nt.audioResumeState,{state:this.audioContextState,isRunning:this.isStateRunning()})}),1e3)):this.isStateRunning()&&this.audioContext.suspend()}isStateRunning(){return"running"===this.audioContextState}isStateSuspended(){return"suspended"===this.audioContextState}clearAudioResumeStateTimeout(){this.audioResumeStateTimeout&&(clearTimeout(this.audioResumeStateTimeout),this.audioResumeStateTimeout=null)}clear(){this.bufferList=[]}play(e,t){}pause(){this.playing=!1}resume(){this.playing=!0}setRate(e){}getAudioBufferSize(){return 0}}class Oo{constructor(e,t,i,s){this.player=e,this.audio=t,this.channel=i,this.bufferSize=s}destroy(){this.buffer=null,this.channel=null}extract(e,t){let i=this.provide(t);for(let t=0;t<i.size;t++)e[2*t]=i.left[t],e[2*t+1]=i.right[t];return this.audio.tempAudioTimestamp=i.ts,i.size}provide(e){let t=new Float32Array(e),i=new Float32Array(e),s=0,r=0,a=0,o=e/this.bufferSize;const n=this.audio.bufferList;if(o&&n.length>=o){try{for(let e=0;e<o;e++){const e=n.shift();2===this.channel?(t.set(e.buffer[0],a),i.set(e.buffer[1],a)):(t.set(e.buffer[0],a),i.set(e.buffer[0],a)),a+=this.bufferSize,r=e.ts}}catch(e){this.player.debug.warn("Processor","provide()",e),t=new Float32Array(0),i=new Float32Array(0)}s=t.length}return{size:s,ts:r,left:t,right:i}}}class No{constructor(){this._vector=new Float32Array,this._position=0,this._frameCount=0}destroy(){this.clear(),this._vector=null}get vector(){return this._vector}get position(){return this._position}get startIndex(){return 2*this._position}get frameCount(){return this._frameCount}get endIndex(){return 2*(this._position+this._frameCount)}clear(){this.receive(this._frameCount),this.rewind()}put(e){this._frameCount+=e}putSamples(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;const s=2*(t=t||0);i>=0||(i=(e.length-s)/2);const r=2*i;this.ensureCapacity(i+this._frameCount);const a=this.endIndex;this.vector.set(e.subarray(s,s+r),a),this._frameCount+=i}putBuffer(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;t=t||0,i>=0||(i=e.frameCount-t),this.putSamples(e.vector,e.position+t,i)}receive(e){e>=0&&!(e>this._frameCount)||(e=this.frameCount),this._frameCount-=e,this._position+=e}receiveSamples(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const i=2*t,s=this.startIndex;e.set(this._vector.subarray(s,s+i)),this.receive(t)}extract(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;const s=this.startIndex+2*t,r=2*i;e.set(this._vector.subarray(s,s+r))}ensureCapacity(){const e=parseInt(2*(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0));if(this._vector.length<e){const t=new Float32Array(e);t.set(this._vector.subarray(this.startIndex,this.endIndex)),this._vector=t,this._position=0}else this.rewind()}ensureAdditionalCapacity(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.ensureCapacity(this._frameCount+e)}rewind(){this._position>0&&(this._vector.set(this._vector.subarray(this.startIndex,this.endIndex)),this._position=0)}}class jo{constructor(e){e?(this._inputBuffer=new No,this._outputBuffer=new No):this._inputBuffer=this._outputBuffer=null}destroy(){this.clear(),this._outputBuffer&&(this._outputBuffer.destroy(),this._outputBuffer=null),this._inputBuffer&&(this._inputBuffer.destroy(),this._inputBuffer=null)}get inputBuffer(){return this._inputBuffer}set inputBuffer(e){this._inputBuffer=e}get outputBuffer(){return this._outputBuffer}set outputBuffer(e){this._outputBuffer=e}clear(){this._inputBuffer.clear(),this._outputBuffer.clear()}}class zo extends jo{constructor(e){super(e),this.reset(),this._rate=1}destroy(){super.destroy()}set rate(e){this._rate=e}reset(){this.slopeCount=0,this.prevSampleL=0,this.prevSampleR=0}clone(){const e=new zo;return e.rate=this._rate,e}process(){const e=this._inputBuffer.frameCount;this._outputBuffer.ensureAdditionalCapacity(e/this._rate+1);const t=this.transpose(e);this._inputBuffer.receive(),this._outputBuffer.put(t)}transpose(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;if(0===e)return 0;const t=this._inputBuffer.vector,i=this._inputBuffer.startIndex,s=this._outputBuffer.vector,r=this._outputBuffer.endIndex;let a=0,o=0;for(;this.slopeCount<1;)s[r+2*o]=(1-this.slopeCount)*this.prevSampleL+this.slopeCount*t[i],s[r+2*o+1]=(1-this.slopeCount)*this.prevSampleR+this.slopeCount*t[i+1],o+=1,this.slopeCount+=this._rate;if(this.slopeCount-=1,1!==e)e:for(;;){for(;this.slopeCount>1;)if(this.slopeCount-=1,a+=1,a>=e-1)break e;const n=i+2*a;s[r+2*o]=(1-this.slopeCount)*t[n]+this.slopeCount*t[n+2],s[r+2*o+1]=(1-this.slopeCount)*t[n+1]+this.slopeCount*t[n+3],o+=1,this.slopeCount+=this._rate}return this.prevSampleL=t[i+2*e-2],this.prevSampleR=t[i+2*e-1],o}}class Go{constructor(e){this._pipe=e}destroy(){}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=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;for(;this.outputBuffer.frameCount<e;){const e=16384-this.inputBuffer.frameCount;if(this.fillInputBuffer(e),this.inputBuffer.frameCount<16384)break;this._pipe.process()}}clear(){this._pipe.clear()}}const Ho=function(){};class $o extends Go{constructor(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Ho;super(t),this.callback=i,this.sourceSound=e,this.historyBufferSize=22050,this._sourcePosition=0,this.outputBufferPosition=0,this._position=0}destroy(){this.clear(),this.sourceSound.destroy(),this.sourceSound=null,this._sourcePosition=0,this.outputBufferPosition=0,this._position=0}get position(){return this._position}set position(e){if(e>this._position)throw new RangeError("New position may not be greater than current position");const 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(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;const t=new Float32Array(2*e),i=this.sourceSound.extract(t,e,this._sourcePosition);this._sourcePosition+=i,this.inputBuffer.putSamples(t,0,i)}extract(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.fillOutputBuffer(this.outputBufferPosition+t);const i=Math.min(t,this.outputBuffer.frameCount-this.outputBufferPosition);this.outputBuffer.extract(e,this.outputBufferPosition,i);const s=this.outputBufferPosition+i;return this.outputBufferPosition=Math.min(this.historyBufferSize,s),this.outputBuffer.receive(Math.max(s-this.historyBufferSize,0)),this._position+=i,i}handleSampleData(e){this.extract(e.data,4096)}clear(){super.clear(),this.outputBufferPosition=0}}const Vo=[[124,186,248,310,372,434,496,558,620,682,744,806,868,930,992,1054,1116,1178,1240,1302,1364,1426,1488,0],[-100,-75,-50,-25,25,50,75,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[-20,-15,-10,-5,5,10,15,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[-4,-3,-2,-1,1,2,3,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]],Wo=-10/1.5;class Jo extends jo{constructor(e){super(e),this._quickSeek=!0,this.midBufferDirty=!1,this.midBuffer=null,this.refMidBuffer=null,this.overlapLength=0,this.autoSeqSetting=!0,this.autoSeekSetting=!0,this._tempo=1,this.setParameters(44100,0,0,8)}destroy(){this.clear(),super.destroy()}clear(){super.clear(),this.clearMidBuffer(),this.refMidBuffer=null}clearMidBuffer(){this.midBufferDirty&&(this.midBufferDirty=!1),this.midBuffer=null}setParameters(e,t,i,s){e>0&&(this.sampleRate=e),s>0&&(this.overlapMs=s),t>0?(this.sequenceMs=t,this.autoSeqSetting=!1):this.autoSeqSetting=!0,i>0?(this.seekWindowMs=i,this.autoSeekSetting=!1):this.autoSeekSetting=!0,this.calculateSequenceParameters(),this.calculateOverlapLength(this.overlapMs),this.tempo=this._tempo}set tempo(e){let t;this._tempo=e,this.calculateSequenceParameters(),this.nominalSkip=this._tempo*(this.seekWindowLength-this.overlapLength),this.skipFract=0,t=Math.floor(this.nominalSkip+.5),this.sampleReq=Math.max(t+this.overlapLength,this.seekWindowLength)+this.seekLength}get tempo(){return this._tempo}get inputChunkSize(){return this.sampleReq}get outputChunkSize(){return this.overlapLength+Math.max(0,this.seekWindowLength-2*this.overlapLength)}calculateOverlapLength(){let e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;e=this.sampleRate*t/1e3,e=e<16?16:e,e-=e%8,this.overlapLength=e,this.refMidBuffer=new Float32Array(2*this.overlapLength),this.midBuffer=new Float32Array(2*this.overlapLength)}checkLimits(e,t,i){return e<t?t:e>i?i:e}calculateSequenceParameters(){let e,t;this.autoSeqSetting&&(e=150+-50*this._tempo,e=this.checkLimits(e,50,125),this.sequenceMs=Math.floor(e+.5)),this.autoSeekSetting&&(t=28.333333333333332+Wo*this._tempo,t=this.checkLimits(t,15,25),this.seekWindowMs=Math.floor(t+.5)),this.seekWindowLength=Math.floor(this.sampleRate*this.sequenceMs/1e3),this.seekLength=Math.floor(this.sampleRate*this.seekWindowMs/1e3)}set quickSeek(e){this._quickSeek=e}clone(){const e=new Jo;return e.tempo=this._tempo,e.setParameters(this.sampleRate,this.sequenceMs,this.seekWindowMs,this.overlapMs),e}seekBestOverlapPosition(){return this._quickSeek?this.seekBestOverlapPositionStereoQuick():this.seekBestOverlapPositionStereo()}seekBestOverlapPositionStereo(){let e,t,i,s=0;for(this.preCalculateCorrelationReferenceStereo(),e=0,t=Number.MIN_VALUE;s<this.seekLength;s+=1)i=this.calculateCrossCorrelationStereo(2*s,this.refMidBuffer),i>t&&(t=i,e=s);return e}seekBestOverlapPositionStereoQuick(){let e,t,i,s,r,a=0;for(this.preCalculateCorrelationReferenceStereo(),t=Number.MIN_VALUE,e=0,s=0,r=0;a<4;a+=1){let o=0;for(;Vo[a][o]&&(r=s+Vo[a][o],!(r>=this.seekLength));)i=this.calculateCrossCorrelationStereo(2*r,this.refMidBuffer),i>t&&(t=i,e=r),o+=1;s=e}return e}preCalculateCorrelationReferenceStereo(){let e,t,i=0;for(;i<this.overlapLength;i+=1)t=i*(this.overlapLength-i),e=2*i,this.refMidBuffer[e]=this.midBuffer[e]*t,this.refMidBuffer[e+1]=this.midBuffer[e+1]*t}calculateCrossCorrelationStereo(e,t){const i=this._inputBuffer.vector;e+=this._inputBuffer.startIndex;let s=0,r=2;const a=2*this.overlapLength;let o;for(;r<a;r+=2)o=r+e,s+=i[o]*t[r]+i[o+1]*t[r+1];return s}overlap(e){this.overlapStereo(2*e)}overlapStereo(e){const t=this._inputBuffer.vector;e+=this._inputBuffer.startIndex;const i=this._outputBuffer.vector,s=this._outputBuffer.endIndex;let r,a,o=0;const n=1/this.overlapLength;let l,d,h;for(;o<this.overlapLength;o+=1)a=(this.overlapLength-o)*n,l=o*n,r=2*o,d=r+e,h=r+s,i[h+0]=t[d+0]*l+this.midBuffer[r+0]*a,i[h+1]=t[d+1]*l+this.midBuffer[r+1]*a}process(){let e,t,i;if(null===this.midBuffer){if(this._inputBuffer.frameCount<this.overlapLength)return;this.midBuffer=new Float32Array(2*this.overlapLength),this._inputBuffer.receiveSamples(this.midBuffer,this.overlapLength)}for(;this._inputBuffer.frameCount>=this.sampleReq;){e=this.seekBestOverlapPosition(),this._outputBuffer.ensureAdditionalCapacity(this.overlapLength),this.overlap(Math.floor(e)),this._outputBuffer.put(this.overlapLength),t=this.seekWindowLength-2*this.overlapLength,t>0&&this._outputBuffer.putBuffer(this._inputBuffer,e+this.overlapLength,t);const s=this._inputBuffer.startIndex+2*(e+this.seekWindowLength-this.overlapLength);this.midBuffer.set(this._inputBuffer.vector.subarray(s,s+2*this.overlapLength)),this.skipFract+=this.nominalSkip,i=Math.floor(this.skipFract),this.skipFract-=i,this._inputBuffer.receive(i)}}}const qo=function(e,t){return(e>t?e-t:t-e)>1e-10};class Ko{constructor(){this.transposer=new zo(!1),this.stretch=new Jo(!1),this._inputBuffer=new No,this._intermediateBuffer=new No,this._outputBuffer=new No,this._rate=0,this._tempo=0,this.virtualPitch=1,this.virtualRate=1,this.virtualTempo=1,this.calculateEffectiveRateAndTempo()}destroy(){this.clear(),this._inputBuffer.destroy(),this._intermediateBuffer.destroy(),this._outputBuffer.destroy(),this._inputBuffer=null,this._intermediateBuffer=null,this._outputBuffer=null}clear(){this.transposer.clear(),this.stretch.clear()}clone(){const e=new Ko;return e.rate=this.rate,e.tempo=this.tempo,e}get rate(){return this._rate}set rate(e){this.virtualRate=e,this.calculateEffectiveRateAndTempo()}set rateChange(e){this._rate=1+.01*e}get tempo(){return this._tempo}set tempo(e){this.virtualTempo=e,this.calculateEffectiveRateAndTempo()}set tempoChange(e){this.tempo=1+.01*e}set pitch(e){this.virtualPitch=e,this.calculateEffectiveRateAndTempo()}set pitchOctaves(e){this.pitch=Math.exp(.69314718056*e),this.calculateEffectiveRateAndTempo()}set pitchSemitones(e){this.pitchOctaves=e/12}get inputBuffer(){return this._inputBuffer}get outputBuffer(){return this._outputBuffer}calculateEffectiveRateAndTempo(){const e=this._tempo,t=this._rate;this._tempo=this.virtualTempo/this.virtualPitch,this._rate=this.virtualRate*this.virtualPitch,qo(this._tempo,e)&&(this.stretch.tempo=this._tempo),qo(this._rate,t)&&(this.transposer.rate=this._rate),this._rate>1?this._outputBuffer!=this.transposer.outputBuffer&&(this.stretch.inputBuffer=this._inputBuffer,this.stretch.outputBuffer=this._intermediateBuffer,this.transposer.inputBuffer=this._intermediateBuffer,this.transposer.outputBuffer=this._outputBuffer):this._outputBuffer!=this.stretch.outputBuffer&&(this.transposer.inputBuffer=this._inputBuffer,this.transposer.outputBuffer=this._intermediateBuffer,this.stretch.inputBuffer=this._intermediateBuffer,this.stretch.outputBuffer=this._outputBuffer)}process(){this._rate>1?(this.stretch.process(),this.transposer.process()):(this.transposer.process(),this.stretch.process())}}class Yo{constructor(e,t,i){this.player=e,this.audio=t,this.soundTouch=new Ko,this.soundTouch.tempo=1,this.soundTouch.rate=1,this.filter=new $o(i,this.soundTouch)}destroy(){this.filter&&(this.filter.destroy(),this.filter=null),this.soundTouch&&(this.soundTouch.destroy(),this.soundTouch=null)}setRate(e){e!==this.soundTouch.rate&&(this.soundTouch.tempo=e)}provide(e){let t=new Float32Array(2*e),i=this.filter.extract(t,e),s=new Float32Array(i),r=new Float32Array(i);for(let e=0;e<i;e++)s[e]=t[2*e],r[e]=t[2*e+1];return{size:i,left:s,right:r,ts:this.audio.tempAudioTimestamp||0}}}class Qo extends Fo{constructor(e){super(e),this.defaultPlaybackRate=1,this.playbackRate=1,this.rateProcessor=null,this.processor=null,this.scriptNodeInterval=null,this.engineType=this.getAutoAudioEngineType(),this.audioBufferSize=this.getAudioBufferSizeByType(),this.$audio=null,this._delayPlay=!1,this.eventListenList=[],this.workletUrl=null,this.clearWorkletUrlTimeout=null,this.player._opt.supportLockScreenPlayAudio&&da()&&(this.$audio=document.createElement("audio"),Object.assign(this.$audio.style,{position:"absolute",left:"-100%",top:"-100%"}),e.$container?e.$container.appendChild(this.$audio):document.body.appendChild(this.$audio),this._bindAudioProxy(),this.player.debug.log("AudioContext","create audio element")),this.scriptStartTime=0,this.player.debug.log("AudioContext","init",`engineType: ${this.engineType}, audioBufferSize: ${this.audioBufferSize}`)}async destroy(){return await super.destroy(),this.workletUrl&&(URL.revokeObjectURL(this.workletUrl),this.workletUrl=null),this.clearWorkletUrlTimeout&&(clearTimeout(this.clearWorkletUrlTimeout),this.clearWorkletUrlTimeout=null),this.eventListenList.length&&(this.eventListenList.forEach((e=>{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=Rs,this.player.debug.log("AudioContext","destroy"),!0}isAudioPlaying(){return this.$audio&&ro(this.$audio.paused)&&ro(this.$audio.ended)&&0!==this.$audio.playbackRate&&0!==this.$audio.readyState}_bindAudioProxy(){const{proxy:e}=this.player.events,t=e(this.$audio,"canplay",(()=>{this.player.debug.log("AudioContext","canplay"),this._delayPlay&&this._audioElementPlay()}));this.eventListenList.push(t)}_getAudioElementReadyState(){let e=0;return this.$audio&&(e=this.$audio.readyState),e}audioElementPlay(){if(this.$audio){const e=this._getAudioElementReadyState();if(this.player.debug.log("AudioContext",`play and readyState: ${e}`),!(0!==e||Oa()&&da()))return this.player.debug.warn("AudioContext","readyState is 0 and set _delayPlay to true"),void(this._delayPlay=!0);this._audioElementPlay()}}_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===xs}getBufferListDuration(){return this.bufferList.length*this.oneBufferDuration}isMoreThanMinBufferDuration(){return this.getBufferListDuration()>=100*this.playbackRate}initProcessor(){this.processor=new Oo(this.player,this,this.audioInfo.channels,this.audioBufferSize),this.rateProcessor=new Yo(this.player,this,this.processor)}getAutoAudioEngineType(){let e=this.player._opt.audioEngine||Rs;const t=()=>{e=Oa()&&oa()?xs:(da()&&this.player._opt.supportLockScreenPlayAudio||qa()&&this.supportAudioWorklet(),Rs)};return this.player._opt.audioEngine?this.player._opt.audioEngine===Cs&&qa()&&this.supportAudioWorklet()?e=Cs:this.player._opt.audioEngine===xs?e=xs:this.player._opt.audioEngine===Rs?e=Rs:t():t(),e}getAudioBufferSizeByType(){const e=this.engineType;this.player._opt.hasVideo;const t=this.player._opt.weiXinInAndroidAudioBufferSize;return e===Cs?1024:e===xs?t||4800:1024}supportAudioWorklet(){return this.audioContext&&this.audioContext.audioWorklet}initScriptNode(){this.playing=!0,this.hasInitScriptNode||(this.initProcessor(),this.engineType===Cs?this.initWorkletScriptNode():this.engineType===xs?this.initIntervalScriptNode():this.engineType===Rs&&this.initProcessScriptNode(),this.audioElementPlay())}getEngineType(){return this.engineType}isPlaybackRateSpeed(){return this.playbackRate>this.defaultPlaybackRate}initProcessScriptNode(){const e=this.audioContext.createScriptProcessor(this.audioBufferSize,0,this.audioInfo.channels);e.onaudioprocess=e=>{const t=e.outputBuffer;this.handleScriptNodeCallback(t)},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;const e=1e3*this.audioBufferSize/this.audioContext.sampleRate;this.scriptNodeInterval=setInterval((()=>{if(0===this.bufferList.length||ro(this.playing)||this.isMute)return void(this.playing&&ro(this.isMute)&&this.player.debug.log("AudioContext",`interval script node and bufferList is ${this.bufferList.length} or playing is ${this.playing}`));const e=this.audioContext.createBufferSource(),t=this.audioContext.createBuffer(this.audioInfo.channels,this.audioBufferSize,this.audioContext.sampleRate);this.handleScriptNodeCallback(t,(()=>{this.scriptStartTime<this.audioContext.currentTime&&(this.player.debug.log("AudioContext",`script start time ${this.scriptStartTime} is less than current time ${this.audioContext.currentTime}`),this.scriptStartTime=this.audioContext.currentTime),e.buffer=t,e.connect(this.gainNode),e.start(this.scriptStartTime),this.scriptStartTime+=t.duration}))}),e),this.gainNode.connect(this.mediaStreamAudioDestinationNode),this.$audio?this.$audio.srcObject=this.mediaStreamAudioDestinationNode.stream:this.gainNode.connect(this.audioContext.destination),this.hasInitScriptNode=!0}initWorkletScriptNode(){let e=Wa((function(){class e extends AudioWorkletProcessor{constructor(){super(),this.audioBufferSize=1024,this.start=!1,this.channels=1,this.samplesArray=[],this.offset=0,this.state=0,this.port.onmessage=e=>{"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(e,t,i){const s=t[0][0],r=t[0][1];if(0===this.offset&&this.port.postMessage({message:"beep"}),0===this.state)this.state=1;else if(1===this.state&&this.samplesArray.length>=4)this.state=2;else if(2===this.state){const e=this.samplesArray[0];for(let t=0;t<s.length;t++)1===this.channels?s[t]=e.left[t+this.offset]:2===this.channels&&(s[t]=e.left[t+this.offset],r&&(r[t]=e.right[t+this.offset]))}else 1===this.channels?s.fill(0):2===this.channels&&(s.fill(0),r&&r.fill(0));return this.offset+=128,this.offset===this.audioBufferSize&&(this.offset=0,2===this.state&&this.samplesArray.shift(),0===this.samplesArray.length&&(this.state=0)),this.start}}registerProcessor("worklet-processor",e)}));this.workletUrl=e,this.audioContext.audioWorklet.addModule(e).then((()=>{if(this.player.isDestroyedOrClosed())return void this.player.debug.log("AudioContext","initWorkletScriptNode() player is destroyed");if(!this.audioContext)return void this.player.debug.warn("AudioContext","initWorkletScriptNode audioContext is null");let e=[1];2===this.audioInfo.channels&&(e=[1,1]);try{this.workletProcessorNode=new AudioWorkletNode(this.audioContext,"worklet-processor",{numberOfOutputs:this.audioInfo.channels,outputChannelCount:e})}catch(e){this.player.debug.error("AudioContext","initWorkletScriptNode error",e),this.workletProcessorNode=null,this.tierDownToProcessScript()}this.workletProcessorNode&&(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")})})),this.clearWorkletUrlTimeout=setTimeout((()=>{URL.revokeObjectURL(this.workletUrl),this.workletUrl=null,this.clearWorkletUrlTimeout=null}),te)}tierDownToProcessScript(){this.player.debug.log("AudioContext","tierDownToProcessScript"),this.engineType=Rs,this.audioBufferSize=this.getAudioBufferSizeByType(),this.initProcessScriptNode(),this.audioElementPlay()}handleScriptNodeCallback(e,t){let i,s=arguments.length>2&&void 0!==arguments[2]&&arguments[2];t=t||Jr;let r=e.length;s&&(i=e,r=this.audioBufferSize);const a=this.audioInfo.channels;if(this.playing&&this.isMoreThanMinBufferDuration()){if(this.player._opt,this.player.openSyncAudioAndVideo()&&so(this.player.visibility)){this.calcPlaybackRateBySync();const r=this.player.getAudioSyncVideoDiff();if(r>this.player._opt.syncAudioAndVideoDiff)return this.player.debug.warn("AudioContext",`audioSyncVideoOption more than diff :${r}, waiting and bufferList is ${this.bufferList.length}`),s?i.port.postMessage({message:"zero"}):this.fillScriptNodeOutputBuffer(e,a),void t()}let o=this._provide(r);if(0===o.size)return ro(this.player.isPlaybackOnlyDecodeIFrame())&&this.player.debug.warn("AudioContext",`bufferList size is ${this.bufferList.length} outputBufferLength is ${r},and bufferItem.size is 0`),s?i.port.postMessage({message:"zero"}):this.fillScriptNodeOutputBuffer(e,a),void t();o&&o.ts&&(this.player.audioTimestamp=o.ts),s?i.port.postMessage({message:"data",buffer:o}):this.fillScriptNodeOutputBuffer(e,a,o),t()}else 0===this.bufferList.length&&this.playing&&ro(this.isMute)&&ro(this.player.isPlaybackOnlyDecodeIFrame())&&this.player.debug.warn("AudioContext",`bufferList size is 0 and outputBufferLength is ${r}`),s?i.port.postMessage({message:"zero"}):this.fillScriptNodeOutputBuffer(e,a),t()}fillScriptNodeOutputBuffer(e,t,i){if(1===t){const t=e.getChannelData(0);i?0===i.size?t.fill(0):t.set(i.left):t.fill(0)}else if(2===t){const t=e.getChannelData(0),s=e.getChannelData(1);i?0===i.size?(t.fill(0),s.fill(0)):(t.set(i.left),s.set(i.right)):(t.fill(0),s.fill(0))}}play(e,t){this.isMute||(this.hasInitScriptNode?(this.hasAudio=!0,this.player.latestAudioTimestamp=t,this.bufferList.push({buffer:e,ts:t}),ro(this.player.openSyncAudioAndVideo())&&this.calcPlaybackRateByBuffer()):this.player.debug.warn("AudioContext","play has not init script node"))}calcPlaybackRateBySync(){if(this.isMute)return;if(!this.playing)return;const e=Math.floor(2e3/this.oneBufferDuration);if(this.bufferList.length>e)return this.player.debug.warn("AudioContext",`bufferList length ${this.bufferList.length} more than ${e}, and drop`),void this.clear();const t=this.player.getAudioSyncVideoDiff();if(this.getEngineType()===xs){if(t<-this.player._opt.syncAudioAndVideoDiff){this.player.debug.warn("AudioContext",`engine active , audioSyncVideoOption ${-this.player._opt.syncAudioAndVideoDiff} less than diff :${t},\n and bufferlist is ${this.bufferList.length}`);const e=this.player.getRenderCurrentPts();for(;this.bufferList.length>0;){const t=this.bufferList[0],i=t.ts-e;if(i>-this.player._opt.syncAudioAndVideoDiff/2){this.player.audioTimestamp=t.ts,this.player.debug.log("AudioContext",`engine active , audioSyncVideoOption\n item.ts is ${t.ts} and currentVideoTimestamp is ${e}, diff is ${i} > -${this.player._opt.syncAudioAndVideoDiff/2} and end`);break}this.bufferList.shift(),this.player.audioTimestamp=t.ts}}}else{let e=this.playbackRate;t<-this.player._opt.syncAudioAndVideoDiff?e===this.defaultPlaybackRate&&(this.player.debug.log("AudioContext",`audioSyncVideoOption ${-this.player._opt.syncAudioAndVideoDiff} less than diff :${t},\n speed up, playbackRate is ${e},\n and bufferList is ${this.bufferList.length}`),e=this.defaultPlaybackRate+.2):t>-this.player._opt.syncAudioAndVideoDiff/2&&e!==this.defaultPlaybackRate&&(this.player.debug.log("AudioContext",`diff is ${t} > -${this.player._opt.syncAudioAndVideoDiff/2} and speed to 1`),e=this.defaultPlaybackRate),this.updatePlaybackRate(e)}}calcPlaybackRateByBuffer(){if(this.isMute)return;if(!this.playing)return;let e=this.playbackRate,t=1e3,i=5e3;this.isAudioPlayer&&(t=this.player._opt.videoBufferDelay,i=this.player._opt.videoBufferMax);const s=Math.floor(t/this.oneBufferDuration),r=Math.floor(i/this.oneBufferDuration);if(this.bufferList.length>r)return this.player.debug.warn("AudioContext",`bufferList length ${this.bufferList.length} more than ${r}, and drop`),void this.clear();this.getEngineType()!==xs&&(this.bufferList.length>s?(e=this.defaultPlaybackRate+.2,this.player.debug.log("AudioContext",`bufferList length ${this.bufferList.length} more than ${s}, speed up, playbackRate is ${e}`)):this.bufferList.length<s/2&&(e=this.defaultPlaybackRate),this.updatePlaybackRate(e))}updatePlaybackRate(e){this.rateProcessor&&(this.playbackRate=e,this.rateProcessor.setRate(this.playbackRate))}_provide(e){return(1===this.playbackRate?this.processor:this.rateProcessor).provide(e)}}class Xo extends po{constructor(e){super(),this.player=e,this.$video=e.video.$videoElement,this.init=!1,this.player._opt.hlsUseCanvasRender&&(this.$video=this.player.hlsDecoder.$videoElement),this.player._opt.webrtcUseCanvasRender&&(this.$video=this.player.webrtc.$videoElement),this.audioInfo={encTypeCode:"",encType:"",channels:"",sampleRate:"",depth:""},this._prevVolume=null,this.player.debug.log("Audio","init")}async destroy(){return this.resetInit(),this.off(),this._prevVolume=null,this.player.debug.log("Audio","destroy"),!0}resetInit(){this.init=!1,this.audioInfo={encTypeCode:"",encType:"",channels:"",sampleRate:"",depth:""}}getAudioInfo(){return this.audioInfo}updateAudioInfo(e){e.encTypeCode&&(this.audioInfo.encTypeCode=e.encTypeCode,this.audioInfo.encType=kt[e.encTypeCode]),e.encType&&(this.audioInfo.encType=e.encType),e.channels&&(this.audioInfo.channels=e.channels),e.sampleRate&&(this.audioInfo.sampleRate=e.sampleRate),e.depth&&(this.audioInfo.depth=e.depth),this.audioInfo.sampleRate&&this.audioInfo.channels&&this.audioInfo.encType&&!this.init&&(this.player.debug.log("Audio","audioInfo",JSON.stringify(this.audioInfo)),this.player.emit(nt.audioInfo,this.audioInfo),this.init=!0)}get isPlaying(){return!0}get volume(){return so(this.$video.muted)?0:this.$video.volume}get isMute(){return 0===this.$video.volume||so(this.$video.muted)}mute(e){this.setVolume(e?0:this.player.lastVolume||.5)}setVolume(e){e=parseFloat(e),isNaN(e)||(e=Xr(e,0,1),this.$video.muted&&(this.$video.muted=!1),da()&&(this.$video.muted=0===e),this.player.isAliyunRtc()&&this.player.aliyunRtcDecoder&&this.player.aliyunRtcDecoder.aliyunRtcRemoteStream&&(this.player.aliyunRtcDecoder.aliyunRtcRemoteStream.muted=0===e),null===this._prevVolume?this.player.emit(nt.mute,0===e):0===this._prevVolume&&e>0?this.player.emit(nt.mute,!1):this._prevVolume>0&&0===e&&this.player.emit(nt.mute,!0),this.$video.volume=e,this.player.emit(nt.volumechange,this.player.volume),this.player.emit(nt.volume,this.player.volume),this._prevVolume=e)}clear(){}play(){}pause(){}resume(){}getEngineType(){return"audio"}isPlaybackRateSpeed(){return!1}getAudioBufferSize(){return 0}setRate(){}initScriptNode(){}initScriptNodeDelay(){}audioEnabled(){this.mute(!1)}}class Zo extends Qo{constructor(e){super(e),this.delayTimeout=null,this.player.on(nt.playbackPause,(e=>{this.listenPlaybackPause(e)})),this.player.debug.log("AudioPlaybackContext","init")}async destroy(){return this.delayTimeout&&(clearTimeout(this.delayTimeout),this.delayTimeout=null),await super.destroy(),this.player.debug.log("AudioPlaybackLoader","destroy"),!0}listenPlaybackPause(e){e?(this.pause(),this.player.playback.isPlaybackPauseClearCache&&this.clear()):this.resume()}initScriptNodeDelay(){const e=this.player._opt.playbackDelayTime;e>0?this.delayTimeout=setTimeout((()=>{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 en extends Qo{constructor(e){super(e),this.TAG_NAME="AudioPlayerLoader",this.isAudioPlayer=!0,this.player.debug.log(this.TAG_NAME,"init")}async destroy(){return await super.destroy(),this.player.debug.log(this.TAG_NAME,"destroy"),!0}play(e,t){ro(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 tn{constructor(e){return new(tn.getLoaderFactory(e._opt))(e)}static getLoaderFactory(e){return e.playType===v?e.useMSE&&e.mseDecodeAudio?Xo:Zo:e.playType===_?en:e.isHls&&ro(e.supportHls265)||e.isWebrtc&&ro(e.isWebrtcH265)||e.useMSE&&e.mseDecodeAudio||e.isAliyunRtc?Xo:Qo}}class sn extends po{constructor(e){super(),this.player=e,this.playing=!1,this._requestAbort=!1,this._status=tr,this.writableStream=null,this.abortController=new AbortController,this.streamRate=ia((t=>{e.emit(nt.kBps,(t/1024).toFixed(2))})),this.streamRateInterval=null,e.debug.log("FetchStream","init")}async destroy(){return this.abort(),this.writableStream&&ro(this.writableStream.locked)&&this.writableStream.close().catch((e=>{this.player.debug.log("FetchStream","destroy and writableStream.close()",e)})),this.writableStream=null,this.off(),this._status=tr,this.streamRate=null,this.stopStreamRateInterval(),this.player.debug.log("FetchStream","destroy"),!0}startStreamRateInterval(){this.stopStreamRateInterval(),this.streamRateInterval=setInterval((()=>{this.streamRate&&this.streamRate(0)}),1e3)}stopStreamRateInterval(){this.streamRateInterval&&(clearInterval(this.streamRateInterval),this.streamRateInterval=null)}fetchStream(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{demux:i}=this.player;this.player._times.streamStart=Qr();const s=Object.assign({signal:this.abortController.signal},{headers:t.headers||{}});fetch(e,s).then((e=>{if(this._requestAbort)return this._status=tr,void e.body.cancel();if(!function(e){return e.ok&&e.status>=200&&e.status<=299}(e))return this.player.debug.error("FetchStream",`fetch response status is ${e.status} and ok is ${e.ok} and emit error and next abort()`),this.abort(),void this.emit(ct.fetchError,`fetch response status is ${e.status} and ok is ${e.ok}`);if(this.emit(nt.streamSuccess),this.startStreamRateInterval(),"undefined"!=typeof WritableStream)this.player.debug.log("FetchStream","use WritableStream() to read stream"),this.writableStream=new WritableStream({write:e=>this.abortController&&this.abortController.signal&&this.abortController.signal.aborted?(this.player.debug.log("FetchStream","writableStream.write() and this.abortController.signal.aborted so return"),void(this._status=sr)):so(this._requestAbort)?(this.player.debug.log("FetchStream","writableStream.write() and this._requestAbort is true so return"),void(this._status=sr)):"string"!=typeof e?(this._status=ir,this.streamRate&&this.streamRate(e.byteLength),i.dispatch(e)):void this.player.debug.warn("FetchStream",`writableStream.write() and value is "${e}" string so return`),close:()=>{this._status=sr,i.close(),this.emit(nt.streamEnd,"fetch done")},abort:e=>{if(this.abortController&&this.abortController.signal&&this.abortController.signal.aborted)return this.player.debug.log("FetchStream","writableStream.abort() and this.abortController.signal.aborted so return"),void(this._status=sr);i.close();const t=e.toString();-1===t.indexOf(as)&&-1===t.indexOf(os)&&e.name!==ns&&(this.abort(),this.emit(ct.fetchError,e))}}),e.body.pipeTo(this.writableStream);else{this.player.debug.log("FetchStream","not support WritableStream and use getReader() to read stream");const t=e.body.getReader(),s=()=>{t.read().then((e=>{let{done:t,value:r}=e;return t?(this._status=sr,i.close(),void this.emit(nt.streamEnd,"fetch done")):this.abortController&&this.abortController.signal&&this.abortController.signal.aborted?(this.player.debug.log("FetchStream","reader.read() and this.abortController.signal.aborted so return"),void(this._status=sr)):so(this._requestAbort)?(this.player.debug.log("FetchStream","reader.read() and this._requestAbort is true so return"),void(this._status=sr)):void("string"!=typeof r?(this._status=ir,this.streamRate&&this.streamRate(r.byteLength),i.dispatch(r),s()):this.player.debug.warn("FetchStream",`reader.read() and value is "${r}" string so return`))})).catch((e=>{if(this.abortController&&this.abortController.signal&&this.abortController.signal.aborted)return this.player.debug.log("FetchStream","reader.read().catch() and this.abortController.signal.aborted so return"),void(this._status=sr);i.close();const t=e.toString();-1===t.indexOf(as)&&-1===t.indexOf(os)&&e.name!==ns&&(this.abort(),this.emit(ct.fetchError,e))}))};s()}})).catch((e=>{this.abortController&&this.abortController.signal&&this.abortController.signal.aborted||"AbortError"!==e.name&&(i.close(),this.abort(),this.emit(ct.fetchError,e))}))}abort(){this._requestAbort=!0;const e=Na();if(this._status!==ir||ro(e)){if(this.abortController){try{this.abortController.abort()}catch(e){}this.abortController=null}}else this.abortController=null,this.player.debug.log("FetchStream",`abort() and not abortController.abort() _status is ${this._status} and _isChrome is ${e}`)}getStreamType(){return u}}class rn extends po{constructor(e){super(),this.TAG_NAME="FetchWorkerLoader",this.player=e,this.playing=!1,this.fetchWorker=null,this.workerClearTimeout=null,this.workerUrl=null,this.destroyResolve=null,this.decoderWorkerCloseTimeout=null,this.abortController=new AbortController,this.streamRate=ia((t=>{e.emit(nt.kBps,(t/1024).toFixed(2))})),this.streamRateInterval=null,this._initFetchWorker(),e.debug.log(this.TAG_NAME,"init")}destroy(){return new Promise(((e,t)=>{this.fetchWorker?(this.player.debug.log(this.TAG_NAME,"send destroy"),this.fetchWorker.postMessage({cmd:tt}),this.destroyResolve=e,this.decoderWorkerCloseTimeout=setTimeout((()=>{this.player.debug.warn(this.TAG_NAME,"send close but not response and destroy directly"),this.decoderWorkerCloseTimeout&&(clearTimeout(this.decoderWorkerCloseTimeout),this.decoderWorkerCloseTimeout=null),this._destroy(),setTimeout((()=>{e()}),0)}),2e3)):(this._destroy(),setTimeout((()=>{e()}),0))}))}_destroy(){this.off(),this.decoderWorkerCloseTimeout&&(clearTimeout(this.decoderWorkerCloseTimeout),this.decoderWorkerCloseTimeout=null),this.workerUrl&&(window.URL.revokeObjectURL(this.workerUrl),this.workerUrl=null),this.workerClearTimeout&&(clearTimeout(this.workerClearTimeout),this.workerClearTimeout=null),this._stopStreamRateInterval(),this.streamRate=null,this.fetchWorker&&(this.fetchWorker.terminate(),this.fetchWorker.onmessage=null,this.fetchWorker=null),this.destroyResolve&&(this.destroyResolve(),this.destroyResolve=null),this.player.debug.log(this.TAG_NAME,"destroy")}_initFetchWorker(){const e=lo(function(){function e(e){return!0===e||"true"===e}function t(e){return!1===e||"false"===e}const i="The user aborted a request",s="AbortError",r="AbortError",a="fetch",o="destroy",n="destroyEnd",l="buffer",d="fetchError",h="fetchClose",c="fetchSuccess",u="idle",p="buffering",f="complete";let m=new class{constructor(){this._requestAbort=!1,this._status=u,this.writableStream=null,this.isChrome=!1,this.abortController=new AbortController}destroy(){this.abort(),this.writableStream&&t(this.writableStream.locked)&&this.writableStream.close().catch((e=>{})),this.writableStream=null,this._status=u}fetchStream(t){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const o=Object.assign({signal:this.abortController.signal},{headers:a.headers||{}});fetch(t,o).then((t=>{if(this._requestAbort)return this._status=u,void t.body.cancel();if(!function(e){return e.ok&&e.status>=200&&e.status<=299}(t))return this.abort(),void postMessage({cmd:d,message:`fetch response status is ${t.status} and ok is ${t.ok}`});if(postMessage({cmd:c}),"undefined"!=typeof WritableStream)this.writableStream=new WritableStream({write:t=>{this.abortController&&this.abortController.signal&&this.abortController.signal.aborted||e(this._requestAbort)?this._status=f:"string"!=typeof t&&(this._status=p,postMessage({cmd:l,buffer:t},[t.buffer]))},close:()=>{this._status=f,postMessage({cmd:h})},abort:e=>{if(this.abortController&&this.abortController.signal&&this.abortController.signal.aborted)return void(this._status=f);const t=e.toString();-1===t.indexOf(i)&&-1===t.indexOf(s)&&e.name!==r&&(this.abort(),postMessage({cmd:d,message:e.toString()}))}}),t.body.pipeTo(this.writableStream);else{const a=t.body.getReader(),o=()=>{a.read().then((t=>{let{done:i,value:s}=t;if(i)return this._status=f,void postMessage({cmd:h});this.abortController&&this.abortController.signal&&this.abortController.signal.aborted||e(this._requestAbort)?this._status=f:"string"!=typeof s&&(this._status=p,postMessage({cmd:l,buffer:s},[s.buffer]),o())})).catch((e=>{if(this.abortController&&this.abortController.signal&&this.abortController.signal.aborted)return void(this._status=f);const t=e.toString();-1===t.indexOf(i)&&-1===t.indexOf(s)&&e.name!==r&&(this.abort(),postMessage({cmd:d,message:e.toString()}))}))};o()}})).catch((e=>{this.abortController&&this.abortController.signal&&this.abortController.signal.aborted||"AbortError"!==e.name&&(this.abort(),postMessage({cmd:d,message:e.toString()}))}))}abort(){if(this._requestAbort=!0,this._status!==p||t(m.isChrome)){if(this.abortController){try{this.abortController.abort()}catch(e){}this.abortController=null}}else this.abortController=null}};self.onmessage=t=>{const i=t.data;switch(i.cmd){case a:m.isChrome=e(i.isChrome),m.fetchStream(i.url,JSON.parse(i.options));break;case o:m.destroy(),m=null,postMessage({cmd:n})}}}.toString()),t=new Blob([e],{type:"text/javascript"});let i=URL.createObjectURL(t);const s=new Worker(i);this.workerUrl=i,this.workerClearTimeout=setTimeout((()=>{window.URL.revokeObjectURL(this.workerUrl),this.workerUrl=null,this.workerClearTimeout=null}),te),s.onmessage=e=>{const{demux:t}=this.player,i=e.data;switch(i.cmd){case st:this.streamRate&&this.streamRate(i.buffer.byteLength),t.dispatch(i.buffer);break;case ot:this.emit(nt.streamSuccess),this._startStreamRateInterval();break;case at:t.close(),this.emit(nt.streamEnd,"fetch done");break;case rt:t.close(),this.emit(ct.fetchError,i.message);break;case it:this._destroy()}},this.fetchWorker=s}_startStreamRateInterval(){this._stopStreamRateInterval(),this.streamRateInterval=setInterval((()=>{this.streamRate&&this.streamRate(0)}),1e3)}_stopStreamRateInterval(){this.streamRateInterval&&(clearInterval(this.streamRateInterval),this.streamRateInterval=null)}fetchStream(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.player._times.streamStart=Qr(),this.fetchWorker.postMessage({cmd:et,url:e,isChrome:Na(),options:JSON.stringify(t)})}getStreamType(){return u}}class an extends po{constructor(e){super(),this.player=e,this.socket=null,this.socketStatus=ut,this.wsUrl=null,this.requestAbort=!1,this.socketDestroyFnList=[],this.streamRate=ia((t=>{e.emit(nt.kBps,(t/1024).toFixed(2))})),this.streamRateInterval=null,e.debug.log("WebsocketStream","init")}async 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:s}=e;this.socket=new WebSocket(this.wsUrl),this.socket.binaryType="arraybuffer";const r=i(this.socket,"open",(()=>{t.log("WebsocketStream","socket open"),this.socketStatus=pt,this.emit(nt.streamSuccess),this.player.emit(nt.websocketOpen),this.startStreamRateInterval()})),a=i(this.socket,"message",(e=>{"string"!=typeof e.data?(this.streamRate&&this.streamRate(e.data.byteLength),this._handleMessage(e.data)):this.player.debug.warn("WebsocketStream",`websocket handle message message is "${e.data}" string so return`)})),o=i(this.socket,"close",(e=>{if(this.socketStatus!==mt){if(t.log("WebsocketStream",`socket close and code is ${e.code}`),1006===e.code&&t.error("WebsocketStream",`socket close abnormally and code is ${e.code}`),so(this.requestAbort))return this.requestAbort=!1,void t.log("WebsocketStream","socket close and requestAbort is true");s.close(),this.socketStatus=ft,this.player.emit(nt.websocketClose,e.code),this.emit(nt.streamEnd,e.code)}else t.log("WebsocketStream","socket close and status is error, so return")})),n=i(this.socket,"error",(e=>{t.error("WebsocketStream","socket error",e),this.socketStatus=mt,this.emit(ct.websocketError,e),s.close(),t.log("WebsocketStream","socket error:",e.isTrusted?"websocket user aborted":"websocket error")}));this.socketDestroyFnList.push(r,a,o,n)}_closeWebSocket(){this.socketDestroyFnList.forEach((e=>e())),!this.socket||0!==this.socket.readyState&&1!==this.socket.readyState?this.socket&&this.player.debug.log("WebsocketStream",`_closeWebSocket() socket is null or socket status is ${this.socket&&this.socket.readyState}`):(this.requestAbort=!0,this.socket.close(1e3,"Client disconnecting")),this.socket=null,this.socketStatus=ut,this.streamRate=null}_handleMessage(e){const{demux:t}=this.player;t?t.dispatch(e):this.player.debug.warn("WebsocketStream","websocket handle message demux is null so return")}fetchStream(e,t){this.player._times.streamStart=Qr(),this.wsUrl=e,this._createWebSocket()}sendMessage(e){this.socket?this.socketStatus===pt?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 on extends po{constructor(e){super(),this.player=e,e.debug.log("HlsStream","init")}async destroy(){return this.off(),this.player.debug.log("HlsStream","destroy"),!0}fetchStream(e){const{hlsDecoder:t,debug:i}=this.player;this.player._times.streamStart=Qr(),t.loadSource(e).then((()=>{this.player.debug.log("HlsStream","loadSource success"),this.emit(nt.streamSuccess)})).catch((e=>{this.emit(ct.hlsError,e)}))}getStreamType(){return p}}class nn extends po{constructor(e){super(),this.player=e,this.webrctUrl=null,e.debug.log("WebrtcStream","init")}async destroy(){return this.webrctUrl=null,this.off(),this.player.debug.log("WebrtcStream","destroy"),!0}fetchStream(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{webrtc:i,debug:s}=this.player;if(this.player._times.streamStart=Qr(),this.webrctUrl=e.replace("webrtc:",window.location.protocol),-1===this.webrctUrl.indexOf("/webrtc/play")&&this.player.isWebrtcForM7S()){const t=new URL(this.webrctUrl),i="/webrtc/play"+t.pathname;this.webrctUrl=t.origin+i+t.search,this.player.debug.log("WebrtcStream",`original url is ${e}, and new url is: ${this.webrctUrl}`)}i.loadSource(this.webrctUrl,t).then((()=>{this.player.debug.log("WebrtcStream","loadSource success"),this.emit(nt.streamSuccess)})).catch((e=>{this.player.debug.error("WebrtcStream","loadSource error",e),this.emit(ct.webrtcError,e)}))}getStreamType(){return m}}class ln extends po{constructor(e){super(),this.player=e,this.transport=null,this.wtUrl=null,this.streamRate=ia((t=>{e.emit(nt.kBps,(t/1024).toFixed(2))})),this.streamRateInterval=null,e.debug.log("WebTransportLoader","init")}async destroy(){return this.abort(),this.off(),this.player.debug.log("WebTransportLoader","destroy"),!0}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,{debug:t,events:{proxy:i},demux:s}=e;try{this.transport=new WebTransport(this.wtUrl),this.transport.ready.then((()=>{this.emit(nt.streamSuccess),this.startStreamRateInterval(),this.transport.createBidirectionalStream().then((e=>{e.readable.pipeTo(new WritableStream(s.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=Qr(),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 g}}class dn extends po{constructor(e){super(),this.player=e,this.workUrl=null,e.debug.log("WorkerStream","init")}async destroy(){return this.workUrl=null,this.off(),this.player.debug.log("WorkerStream","destroy"),!0}sendMessage(e){this.player.decoderWorker.workerSendMessage(e)}fetchStream(e){this.workUrl=e,this.player._times.streamStart=Qr(),this.player.decoderWorker.workerFetchStream(e)}getStreamType(){const e=this.player._opt.protocol;return y+" "+(e===o?u:f)}}class hn extends po{constructor(e){super(),this.TAG_NAME="AliyunRtcLoader",this.player=e,e.debug.log(this.TAG_NAME,"init")}async destroy(){return this.off(),this.player.debug.log(this.TAG_NAME,"destroy"),!0}fetchStream(e){const{aliyunRtcDecoder:t}=this.player;this.player._times.streamStart=Qr(),t.loadSource(e).then((()=>{this.player.debug.log(this.TAG_NAME,"loadSource success"),this.emit(nt.streamSuccess)})).catch((e=>{this.player.debug.error(this.TAG_NAME,"loadSource error",e),this.emit(ct.aliyunRtcError,e)}))}getStreamType(){return A}}class cn{constructor(e){return new(cn.getLoaderFactory(e._opt))(e)}static getLoaderFactory(e){const{protocol:t,useWasm:i,playType:s,useWCS:r,useMSE:c,demuxUseWorker:u,mainThreadFetchUseWorker:p}=e;return t===o?s===_?dn:s===b?i&&!Va(e)||u?dn:p?rn:sn:r||c?u?dn:p?rn:sn:dn:t===a?s===_?dn:s===b?i&&!Va(e)||u?dn:an:r||c?u?dn:an:dn:t===n?on:t===l?nn:t===d?ln:t===h?hn:void 0}}var un=kr((function(e){function t(e,r){if(!e)throw"First parameter is required.";r=new i(e,r=r||{type:"video"});var a=this;function o(t){t&&(r.initCallback=function(){t(),t=r.initCallback=null});var i=new s(e,r);(p=new i(e,r)).record(),u("recording"),r.disableLogs||console.log("Initialized recorderType:",p.constructor.name,"for output-type:",r.type)}function n(e){if(e=e||function(){},p){if("paused"===a.state)return a.resumeRecording(),void setTimeout((function(){n(e)}),1);"recording"===a.state||r.disableLogs||console.warn('Recording state should be: "recording", however current state is: ',a.state),r.disableLogs||console.log("Stopped recording "+r.type+" stream."),"gif"!==r.type?p.stop(t):(p.stop(),t()),u("stopped")}else m();function t(t){if(p){Object.keys(p).forEach((function(e){"function"!=typeof p[e]&&(a[e]=p[e])}));var i=p.blob;if(!i){if(!t)throw"Recording failed.";p.blob=i=t}if(i&&!r.disableLogs&&console.log(i.type,"->",y(i.size)),e){var s;try{s=h.createObjectURL(i)}catch(e){}"function"==typeof e.call?e.call(a,s):e(s)}r.autoWriteToDisk&&d((function(e){var t={};t[r.type+"Blob"]=e,x.Store(t)}))}else"function"==typeof e.call?e.call(a,""):e("")}}function l(e){postMessage((new FileReaderSync).readAsDataURL(e))}function d(e,t){if(!e)throw"Pass a callback function over getDataURL.";var i=t?t.blob:(p||{}).blob;if(!i)return r.disableLogs||console.warn("Blob encoder did not finish its job yet."),void setTimeout((function(){d(e,t)}),1e3);if("undefined"==typeof Worker||navigator.mozGetUserMedia){var s=new FileReader;s.readAsDataURL(i),s.onload=function(t){e(t.target.result)}}else{var a=function(e){try{var t=h.createObjectURL(new Blob([e.toString(),"this.onmessage = function (eee) {"+e.name+"(eee.data);}"],{type:"application/javascript"})),i=new Worker(t);return h.revokeObjectURL(t),i}catch(e){}}(l);a.onmessage=function(t){e(t.data)},a.postMessage(i)}}function c(e){e=e||0,"paused"!==a.state?"stopped"!==a.state&&(e>=a.recordingDuration?n(a.onRecordingStopped):(e+=1e3,setTimeout((function(){c(e)}),1e3))):setTimeout((function(){c(e)}),1e3)}function u(e){a&&(a.state=e,"function"==typeof a.onStateChanged.call?a.onStateChanged.call(a,e):a.onStateChanged(e))}var p,f='It seems that recorder is destroyed or "startRecording" is not invoked for '+r.type+" recorder.";function m(){!0!==r.disableLogs&&console.warn(f)}var g={startRecording:function(t){return r.disableLogs||console.log("RecordRTC version: ",a.version),t&&(r=new i(e,t)),r.disableLogs||console.log("started recording "+r.type+" stream."),p?(p.clearRecordedData(),p.record(),u("recording"),a.recordingDuration&&c(),a):(o((function(){a.recordingDuration&&c()})),a)},stopRecording:n,pauseRecording:function(){p?"recording"===a.state?(u("paused"),p.pause(),r.disableLogs||console.log("Paused recording.")):r.disableLogs||console.warn("Unable to pause the recording. Recording state: ",a.state):m()},resumeRecording:function(){p?"paused"===a.state?(u("recording"),p.resume(),r.disableLogs||console.log("Resumed recording.")):r.disableLogs||console.warn("Unable to resume the recording. Recording state: ",a.state):m()},initRecorder:o,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(){p?(p.clearRecordedData(),r.disableLogs||console.log("Cleared old recorded data.")):m()},getBlob:function(){if(p)return p.blob;m()},getDataURL:d,toURL:function(){if(p)return h.createObjectURL(p.blob);m()},getInternalRecorder:function(){return p},save:function(e){p?A(p.blob,e):m()},getFromDisk:function(e){p?t.getFromDisk(r.type,e):m()},setAdvertisementArray:function(e){r.advertisement=[];for(var t=e.length,i=0;i<t;i++)r.advertisement.push({duration:i,image:e[i]})},blob:null,bufferSize:0,sampleRate:0,buffer:null,reset:function(){"recording"!==a.state||r.disableLogs||console.warn("Stop an active recorder."),p&&"function"==typeof p.clearRecordedData&&p.clearRecordedData(),p=null,u("inactive"),a.blob=null},onStateChanged:function(e){r.disableLogs||console.log("Recorder state changed:",e)},state:"inactive",getState:function(){return a.state},destroy:function(){var e=r.disableLogs;r={disableLogs:!0},a.reset(),u("destroyed"),g=a=null,S.AudioContextConstructor&&(S.AudioContextConstructor.close(),S.AudioContextConstructor=null),r.disableLogs=e,r.disableLogs||console.log("RecordRTC is destroyed.")},version:"5.6.2"};if(!this)return a=g,g;for(var b in g)this[b]=g[b];return a=this,g}function i(e,t){return t.recorderType||t.type||(t.audio&&t.video?t.type="video":t.audio&&!t.video&&(t.type="audio")),t.recorderType&&!t.type&&(t.recorderType===C||t.recorderType===k||void 0!==B&&t.recorderType===B?t.type="video":t.recorderType===D?t.type="gif":t.recorderType===T?t.type="audio":t.recorderType===E&&(_(e,"audio").length&&_(e,"video").length||!_(e,"audio").length&&_(e,"video").length?t.type="video":_(e,"audio").length&&!_(e,"video").length&&(t.type="audio"))),void 0!==E&&"undefined"!=typeof MediaRecorder&&"requestData"in MediaRecorder.prototype&&(t.mimeType||(t.mimeType="video/webm"),t.type||(t.type=t.mimeType.split("/")[0]),t.bitsPerSecond),t.type||(t.mimeType&&(t.type=t.mimeType.split("/")[0]),t.type||(t.type="audio")),t}function s(e,t){var i;return(f||c||u)&&(i=T),"undefined"!=typeof MediaRecorder&&"requestData"in MediaRecorder.prototype&&!f&&(i=E),"video"===t.type&&(f||u)&&(i=C,void 0!==B&&"undefined"!=typeof ReadableStream&&(i=B)),"gif"===t.type&&(i=D),"canvas"===t.type&&(i=k),w()&&i!==k&&i!==D&&"undefined"!=typeof MediaRecorder&&"requestData"in MediaRecorder.prototype&&(_(e,"video").length||_(e,"audio").length)&&("audio"===t.type?"function"==typeof MediaRecorder.isTypeSupported&&MediaRecorder.isTypeSupported("audio/webm")&&(i=E):"function"==typeof MediaRecorder.isTypeSupported&&MediaRecorder.isTypeSupported("video/webm")&&(i=E)),e instanceof Array&&e.length&&(i=P),t.recorderType&&(i=t.recorderType),!t.disableLogs&&i&&i.name&&console.log("Using recorderType:",i.name||i.constructor.name),!i&&m&&(i=E),i}function r(e){this.addStream=function(t){t&&(e=t)},this.mediaType={audio:!0,video:!0},this.startRecording=function(){var i,s=this.mediaType,r=this.mimeType||{audio:null,video:null,gif:null};if("function"!=typeof s.audio&&w()&&!_(e,"audio").length&&(s.audio=!1),"function"!=typeof s.video&&w()&&!_(e,"video").length&&(s.video=!1),"function"!=typeof s.gif&&w()&&!_(e,"video").length&&(s.gif=!1),!s.audio&&!s.video&&!s.gif)throw"MediaStream must have either audio or video tracks.";if(s.audio&&(i=null,"function"==typeof s.audio&&(i=s.audio),this.audioRecorder=new t(e,{type:"audio",bufferSize:this.bufferSize,sampleRate:this.sampleRate,numberOfAudioChannels:this.numberOfAudioChannels||2,disableLogs:this.disableLogs,recorderType:i,mimeType:r.audio,timeSlice:this.timeSlice,onTimeStamp:this.onTimeStamp}),s.video||this.audioRecorder.startRecording()),s.video){i=null,"function"==typeof s.video&&(i=s.video);var a=e;if(w()&&s.audio&&"function"==typeof s.audio){var o=_(e,"video")[0];p?((a=new g).addTrack(o),i&&i===C&&(i=E)):(a=new g).addTrack(o)}this.videoRecorder=new t(a,{type:"video",video:this.video,canvas:this.canvas,frameInterval:this.frameInterval||10,disableLogs:this.disableLogs,recorderType:i,mimeType:r.video,timeSlice:this.timeSlice,onTimeStamp:this.onTimeStamp,workerPath:this.workerPath,webAssemblyPath:this.webAssemblyPath,frameRate:this.frameRate,bitrate:this.bitrate}),s.audio||this.videoRecorder.startRecording()}if(s.audio&&s.video){var n=this,l=!0===w();(s.audio instanceof T&&s.video||!0!==s.audio&&!0!==s.video&&s.audio!==s.video)&&(l=!1),!0===l?(n.audioRecorder=null,n.videoRecorder.startRecording()):n.videoRecorder.initRecorder((function(){n.audioRecorder.initRecorder((function(){n.videoRecorder.startRecording(),n.audioRecorder.startRecording()}))}))}s.gif&&(i=null,"function"==typeof s.gif&&(i=s.gif),this.gifRecorder=new t(e,{type:"gif",frameRate:this.frameRate||200,quality:this.quality||10,disableLogs:this.disableLogs,recorderType:i,mimeType:r.gif}),this.gifRecorder.startRecording())},this.stopRecording=function(e){e=e||function(){},this.audioRecorder&&this.audioRecorder.stopRecording((function(t){e(t,"audio")})),this.videoRecorder&&this.videoRecorder.stopRecording((function(t){e(t,"video")})),this.gifRecorder&&this.gifRecorder.stopRecording((function(t){e(t,"gif")}))},this.pauseRecording=function(){this.audioRecorder&&this.audioRecorder.pauseRecording(),this.videoRecorder&&this.videoRecorder.pauseRecording(),this.gifRecorder&&this.gifRecorder.pauseRecording()},this.resumeRecording=function(){this.audioRecorder&&this.audioRecorder.resumeRecording(),this.videoRecorder&&this.videoRecorder.resumeRecording(),this.gifRecorder&&this.gifRecorder.resumeRecording()},this.getBlob=function(e){var t={};return this.audioRecorder&&(t.audio=this.audioRecorder.getBlob()),this.videoRecorder&&(t.video=this.videoRecorder.getBlob()),this.gifRecorder&&(t.gif=this.gifRecorder.getBlob()),e&&e(t),t},this.destroy=function(){this.audioRecorder&&(this.audioRecorder.destroy(),this.audioRecorder=null),this.videoRecorder&&(this.videoRecorder.destroy(),this.videoRecorder=null),this.gifRecorder&&(this.gifRecorder.destroy(),this.gifRecorder=null)},this.getDataURL=function(e){function t(e,t){if("undefined"!=typeof Worker){var i=function(e){var t,i=h.createObjectURL(new Blob([e.toString(),"this.onmessage = function (eee) {"+e.name+"(eee.data);}"],{type:"application/javascript"})),s=new Worker(i);if(void 0!==h)t=h;else{if("undefined"==typeof webkitURL)throw"Neither URL nor webkitURL detected.";t=webkitURL}return t.revokeObjectURL(i),s}((function(e){postMessage((new FileReaderSync).readAsDataURL(e))}));i.onmessage=function(e){t(e.data)},i.postMessage(e)}else{var s=new FileReader;s.readAsDataURL(e),s.onload=function(e){t(e.target.result)}}}this.getBlob((function(i){i.audio&&i.video?t(i.audio,(function(s){t(i.video,(function(t){e({audio:s,video:t})}))})):i.audio?t(i.audio,(function(t){e({audio:t})})):i.video&&t(i.video,(function(t){e({video:t})}))}))},this.writeToDisk=function(){t.writeToDisk({audio:this.audioRecorder,video:this.videoRecorder,gif:this.gifRecorder})},this.save=function(e){(e=e||{audio:!0,video:!0,gif:!0}).audio&&this.audioRecorder&&this.audioRecorder.save("string"==typeof e.audio?e.audio:""),e.video&&this.videoRecorder&&this.videoRecorder.save("string"==typeof e.video?e.video:""),e.gif&&this.gifRecorder&&this.gifRecorder.save("string"==typeof e.gif?e.gif:"")}}t.version="5.6.2",e.exports=t,t.getFromDisk=function(e,t){if(!t)throw"callback is mandatory.";console.log("Getting recorded "+("all"===e?"blobs":e+" blob ")+" from disk!"),x.Fetch((function(i,s){"all"!==e&&s===e+"Blob"&&t&&t(i),"all"===e&&t&&t(i,s.replace("Blob",""))}))},t.writeToDisk=function(e){console.log("Writing recorded blob(s) to disk!"),(e=e||{}).audio&&e.video&&e.gif?e.audio.getDataURL((function(t){e.video.getDataURL((function(i){e.gif.getDataURL((function(e){x.Store({audioBlob:t,videoBlob:i,gifBlob:e})}))}))})):e.audio&&e.video?e.audio.getDataURL((function(t){e.video.getDataURL((function(e){x.Store({audioBlob:t,videoBlob:e})}))})):e.audio&&e.gif?e.audio.getDataURL((function(t){e.gif.getDataURL((function(e){x.Store({audioBlob:t,gifBlob:e})}))})):e.video&&e.gif?e.video.getDataURL((function(t){e.gif.getDataURL((function(e){x.Store({videoBlob:t,gifBlob:e})}))})):e.audio?e.audio.getDataURL((function(e){x.Store({audioBlob:e})})):e.video?e.video.getDataURL((function(e){x.Store({videoBlob:e})})):e.gif&&e.gif.getDataURL((function(e){x.Store({gifBlob:e})}))},r.getFromDisk=t.getFromDisk,r.writeToDisk=t.writeToDisk,void 0!==t&&(t.MRecordRTC=r);var a;(a=void 0!==Tr?Tr:null)&&"undefined"==typeof window&&void 0!==Tr&&(Tr.navigator={userAgent:"Fake/5.0 (FakeOS) AppleWebKit/123 (KHTML, like Gecko) Fake/12.3.4567.89 Fake/123.45",getUserMedia:function(){}},Tr.console||(Tr.console={}),void 0!==Tr.console.log&&void 0!==Tr.console.error||(Tr.console.error=Tr.console.log=Tr.console.log||function(){console.log(arguments)}),"undefined"==typeof document&&(a.document={documentElement:{appendChild:function(){return""}}},document.createElement=document.captureStream=document.mozCaptureStream=function(){var e={getContext:function(){return e},play:function(){},pause:function(){},drawImage:function(){},toDataURL:function(){return""},style:{}};return e},a.HTMLVideoElement=function(){}),"undefined"==typeof location&&(a.location={protocol:"file:",href:"",hash:""}),"undefined"==typeof screen&&(a.screen={width:0,height:0}),void 0===h&&(a.URL={createObjectURL:function(){return""},revokeObjectURL:function(){return""}}),a.window=Tr);var o=window.requestAnimationFrame;if(void 0===o)if("undefined"!=typeof webkitRequestAnimationFrame)o=webkitRequestAnimationFrame;else if("undefined"!=typeof mozRequestAnimationFrame)o=mozRequestAnimationFrame;else if("undefined"!=typeof msRequestAnimationFrame)o=msRequestAnimationFrame;else if(void 0===o){var n=0;o=function(e,t){var i=(new Date).getTime(),s=Math.max(0,16-(i-n)),r=setTimeout((function(){e(i+s)}),s);return n=i+s,r}}var l=window.cancelAnimationFrame;void 0===l&&("undefined"!=typeof webkitCancelAnimationFrame?l=webkitCancelAnimationFrame:"undefined"!=typeof mozCancelAnimationFrame?l=mozCancelAnimationFrame:"undefined"!=typeof msCancelAnimationFrame?l=msCancelAnimationFrame:void 0===l&&(l=function(e){clearTimeout(e)}));var d=window.AudioContext;void 0===d&&("undefined"!=typeof webkitAudioContext&&(d=webkitAudioContext),"undefined"!=typeof mozAudioContext&&(d=mozAudioContext));var h=window.URL;void 0===h&&"undefined"!=typeof webkitURL&&(h=webkitURL),"undefined"!=typeof navigator&&void 0===navigator.getUserMedia&&(void 0!==navigator.webkitGetUserMedia&&(navigator.getUserMedia=navigator.webkitGetUserMedia),void 0!==navigator.mozGetUserMedia&&(navigator.getUserMedia=navigator.mozGetUserMedia));var c=!(-1===navigator.userAgent.indexOf("Edge")||!navigator.msSaveBlob&&!navigator.msSaveOrOpenBlob),u=!!window.opera||-1!==navigator.userAgent.indexOf("OPR/"),p=navigator.userAgent.toLowerCase().indexOf("firefox")>-1&&"netscape"in window&&/ rv:/.test(navigator.userAgent),f=!u&&!c&&!!navigator.webkitGetUserMedia||b()||-1!==navigator.userAgent.toLowerCase().indexOf("chrome/"),m=/^((?!chrome|android).)*safari/i.test(navigator.userAgent);m&&!f&&-1!==navigator.userAgent.indexOf("CriOS")&&(m=!1,f=!0);var g=window.MediaStream;function y(e){if(0===e)return"0 Bytes";var t=parseInt(Math.floor(Math.log(e)/Math.log(1e3)),10);return(e/Math.pow(1e3,t)).toPrecision(3)+" "+["Bytes","KB","MB","GB","TB"][t]}function A(e,t){if(!e)throw"Blob object is required.";if(!e.type)try{e.type="video/webm"}catch(e){}var i=(e.type||"video/webm").split("/")[1];if(-1!==i.indexOf(";")&&(i=i.split(";")[0]),t&&-1!==t.indexOf(".")){var s=t.split(".");t=s[0],i=s[1]}var r=(t||Math.round(9999999999*Math.random())+888888888)+"."+i;if(void 0!==navigator.msSaveOrOpenBlob)return navigator.msSaveOrOpenBlob(e,r);if(void 0!==navigator.msSaveBlob)return navigator.msSaveBlob(e,r);var a=document.createElement("a");a.href=h.createObjectURL(e),a.download=r,a.style="display:none;opacity:0;color:transparent;",(document.body||document.documentElement).appendChild(a),"function"==typeof a.click?a.click():(a.target="_blank",a.dispatchEvent(new MouseEvent("click",{view:window,bubbles:!0,cancelable:!0}))),h.revokeObjectURL(a.href)}function b(){return"undefined"!=typeof window&&"object"==typeof window.process&&"renderer"===window.process.type||(!("undefined"==typeof process||"object"!=typeof process.versions||!process.versions.electron)||"object"==typeof navigator&&"string"==typeof navigator.userAgent&&navigator.userAgent.indexOf("Electron")>=0)}function _(e,t){return e&&e.getTracks?e.getTracks().filter((function(e){return e.kind===(t||"audio")})):[]}function v(e,t){"srcObject"in t?t.srcObject=e:"mozSrcObject"in t?t.mozSrcObject=e:t.srcObject=e}void 0===g&&"undefined"!=typeof webkitMediaStream&&(g=webkitMediaStream),void 0!==g&&void 0===g.prototype.stop&&(g.prototype.stop=function(){this.getTracks().forEach((function(e){e.stop()}))}),void 0!==t&&(t.invokeSaveAsDialog=A,t.getTracks=_,t.getSeekableBlob=function(e,t){if("undefined"==typeof EBML)throw new Error("Please link: https://www.webrtc-experiment.com/EBML.js");var i=new EBML.Reader,s=new EBML.Decoder,r=EBML.tools,a=new FileReader;a.onload=function(e){s.decode(this.result).forEach((function(e){i.read(e)})),i.stop();var a=r.makeMetadataSeekable(i.metadatas,i.duration,i.cues),o=this.result.slice(i.metadataSize),n=new Blob([a,o],{type:"video/webm"});t(n)},a.readAsArrayBuffer(e)},t.bytesToSize=y,t.isElectron=b);var S={};function w(){if(p||m||c)return!0;var e,t,i=navigator.userAgent,s=""+parseFloat(navigator.appVersion),r=parseInt(navigator.appVersion,10);return(f||u)&&(e=i.indexOf("Chrome"),s=i.substring(e+7)),-1!==(t=s.indexOf(";"))&&(s=s.substring(0,t)),-1!==(t=s.indexOf(" "))&&(s=s.substring(0,t)),r=parseInt(""+s,10),isNaN(r)&&(s=""+parseFloat(navigator.appVersion),r=parseInt(navigator.appVersion,10)),r>=49}function E(e,t){var i=this;if(void 0===e)throw'First argument "MediaStream" is required.';if("undefined"==typeof MediaRecorder)throw"Your browser does not support the Media Recorder API. Please try other modules e.g. WhammyRecorder or StereoAudioRecorder.";if("audio"===(t=t||{mimeType:"video/webm"}).type){var s;if(_(e,"video").length&&_(e,"audio").length)navigator.mozGetUserMedia?(s=new g).addTrack(_(e,"audio")[0]):s=new g(_(e,"audio")),e=s;t.mimeType&&-1!==t.mimeType.toString().toLowerCase().indexOf("audio")||(t.mimeType=f?"audio/webm":"audio/ogg"),t.mimeType&&"audio/ogg"!==t.mimeType.toString().toLowerCase()&&navigator.mozGetUserMedia&&(t.mimeType="audio/ogg")}var r,a=[];function o(){i.timestamps.push((new Date).getTime()),"function"==typeof t.onTimeStamp&&t.onTimeStamp(i.timestamps[i.timestamps.length-1],i.timestamps)}function n(e){return r&&r.mimeType?r.mimeType:e.mimeType||"video/webm"}function l(){a=[],r=null,i.timestamps=[]}this.getArrayOfBlobs=function(){return a},this.record=function(){i.blob=null,i.clearRecordedData(),i.timestamps=[],d=[],a=[];var s=t;t.disableLogs||console.log("Passing following config over MediaRecorder API.",s),r&&(r=null),f&&!w()&&(s="video/vp8"),"function"==typeof MediaRecorder.isTypeSupported&&s.mimeType&&(MediaRecorder.isTypeSupported(s.mimeType)||(t.disableLogs||console.warn("MediaRecorder API seems unable to record mimeType:",s.mimeType),s.mimeType="audio"===t.type?"audio/webm":"video/webm"));try{r=new MediaRecorder(e,s),t.mimeType=s.mimeType}catch(t){r=new MediaRecorder(e)}s.mimeType&&!MediaRecorder.isTypeSupported&&"canRecordMimeType"in r&&!1===r.canRecordMimeType(s.mimeType)&&(t.disableLogs||console.warn("MediaRecorder API seems unable to record mimeType:",s.mimeType)),r.ondataavailable=function(e){if(e.data&&d.push("ondataavailable: "+y(e.data.size)),"number"!=typeof t.timeSlice)!e.data||!e.data.size||e.data.size<100||i.blob?i.recordingCallback&&(i.recordingCallback(new Blob([],{type:n(s)})),i.recordingCallback=null):(i.blob=t.getNativeBlob?e.data:new Blob([e.data],{type:n(s)}),i.recordingCallback&&(i.recordingCallback(i.blob),i.recordingCallback=null));else if(e.data&&e.data.size&&(a.push(e.data),o(),"function"==typeof t.ondataavailable)){var r=t.getNativeBlob?e.data:new Blob([e.data],{type:n(s)});t.ondataavailable(r)}},r.onstart=function(){d.push("started")},r.onpause=function(){d.push("paused")},r.onresume=function(){d.push("resumed")},r.onstop=function(){d.push("stopped")},r.onerror=function(e){e&&(e.name||(e.name="UnknownError"),d.push("error: "+e),t.disableLogs||(-1!==e.name.toString().toLowerCase().indexOf("invalidstate")?console.error("The MediaRecorder is not in a state in which the proposed operation is allowed to be executed.",e):-1!==e.name.toString().toLowerCase().indexOf("notsupported")?console.error("MIME type (",s.mimeType,") is not supported.",e):-1!==e.name.toString().toLowerCase().indexOf("security")?console.error("MediaRecorder security error",e):"OutOfMemory"===e.name?console.error("The UA has exhaused the available memory. User agents SHOULD provide as much additional information as possible in the message attribute.",e):"IllegalStreamModification"===e.name?console.error("A modification to the stream has occurred that makes it impossible to continue recording. An example would be the addition of a Track while recording is occurring. User agents SHOULD provide as much additional information as possible in the message attribute.",e):"OtherRecordingError"===e.name?console.error("Used for an fatal error other than those listed above. User agents SHOULD provide as much additional information as possible in the message attribute.",e):"GenericError"===e.name?console.error("The UA cannot provide the codec or recording option that has been requested.",e):console.error("MediaRecorder Error",e)),function(e){if(!i.manuallyStopped&&r&&"inactive"===r.state)return delete t.timeslice,void r.start(6e5);setTimeout(void 0,1e3)}(),"inactive"!==r.state&&"stopped"!==r.state&&r.stop())},"number"==typeof t.timeSlice?(o(),r.start(t.timeSlice)):r.start(36e5),t.initCallback&&t.initCallback()},this.timestamps=[],this.stop=function(e){e=e||function(){},i.manuallyStopped=!0,r&&(this.recordingCallback=e,"recording"===r.state&&r.stop(),"number"==typeof t.timeSlice&&setTimeout((function(){i.blob=new Blob(a,{type:n(t)}),i.recordingCallback(i.blob)}),100))},this.pause=function(){r&&"recording"===r.state&&r.pause()},this.resume=function(){r&&"paused"===r.state&&r.resume()},this.clearRecordedData=function(){r&&"recording"===r.state&&i.stop(l),l()},this.getInternalRecorder=function(){return r},this.blob=null,this.getState=function(){return r&&r.state||"inactive"};var d=[];this.getAllStates=function(){return d},void 0===t.checkForInactiveTracks&&(t.checkForInactiveTracks=!1);i=this;!function s(){if(r&&!1!==t.checkForInactiveTracks)return!1===function(){if("active"in e){if(!e.active)return!1}else if("ended"in e&&e.ended)return!1;return!0}()?(t.disableLogs||console.log("MediaStream seems stopped."),void i.stop()):void setTimeout(s,1e3)}(),this.name="MediaStreamRecorder",this.toString=function(){return this.name}}function T(e,i){if(!_(e,"audio").length)throw"Your stream has no audio tracks.";var s,r=this,a=[],o=[],n=!1,l=0,d=2,c=(i=i||{}).desiredSampRate;function u(){if(!1===i.checkForInactiveTracks)return!0;if("active"in e){if(!e.active)return!1}else if("ended"in e&&e.ended)return!1;return!0}function p(e,t){function i(e,t){var i,s=e.numberOfAudioChannels,r=e.leftBuffers.slice(0),a=e.rightBuffers.slice(0),o=e.sampleRate,n=e.internalInterleavedLength,l=e.desiredSampRate;function d(e,t,i){var s=Math.round(e.length*(t/i)),r=[],a=Number((e.length-1)/(s-1));r[0]=e[0];for(var o=1;o<s-1;o++){var n=o*a,l=Number(Math.floor(n)).toFixed(),d=Number(Math.ceil(n)).toFixed(),c=n-l;r[o]=h(e[l],e[d],c)}return r[s-1]=e[e.length-1],r}function h(e,t,i){return e+(t-e)*i}function c(e,t){for(var i=new Float64Array(t),s=0,r=e.length,a=0;a<r;a++){var o=e[a];i.set(o,s),s+=o.length}return i}function u(e,t,i){for(var s=i.length,r=0;r<s;r++)e.setUint8(t+r,i.charCodeAt(r))}2===s&&(r=c(r,n),a=c(a,n),l&&(r=d(r,l,o),a=d(a,l,o))),1===s&&(r=c(r,n),l&&(r=d(r,l,o))),l&&(o=l),2===s&&(i=function(e,t){for(var i=e.length+t.length,s=new Float64Array(i),r=0,a=0;a<i;)s[a++]=e[r],s[a++]=t[r],r++;return s}(r,a)),1===s&&(i=r);var p=i.length,f=new ArrayBuffer(44+2*p),m=new DataView(f);u(m,0,"RIFF"),m.setUint32(4,36+2*p,!0),u(m,8,"WAVE"),u(m,12,"fmt "),m.setUint32(16,16,!0),m.setUint16(20,1,!0),m.setUint16(22,s,!0),m.setUint32(24,o,!0),m.setUint32(28,o*s*2,!0),m.setUint16(32,2*s,!0),m.setUint16(34,16,!0),u(m,36,"data"),m.setUint32(40,2*p,!0);for(var g=p,y=44,A=0;A<g;A++)m.setInt16(y,32767*i[A],!0),y+=2;if(t)return t({buffer:f,view:m});postMessage({buffer:f,view:m})}if(e.noWorker)i(e,(function(e){t(e.buffer,e.view)}));else{var s,r,a,o=(s=i,r=h.createObjectURL(new Blob([s.toString(),";this.onmessage = function (eee) {"+s.name+"(eee.data);}"],{type:"application/javascript"})),(a=new Worker(r)).workerURL=r,a);o.onmessage=function(e){t(e.data.buffer,e.data.view),h.revokeObjectURL(o.workerURL),o.terminate()},o.postMessage(e)}}!0===i.leftChannel&&(d=1),1===i.numberOfAudioChannels&&(d=1),(!d||d<1)&&(d=2),i.disableLogs||console.log("StereoAudioRecorder is set to record number of channels: "+d),void 0===i.checkForInactiveTracks&&(i.checkForInactiveTracks=!0),this.record=function(){if(!1===u())throw"Please make sure MediaStream is active.";v(),w=b=!1,n=!0,void 0!==i.timeSlice&&T()},this.stop=function(e){e=e||function(){},n=!1,p({desiredSampRate:c,sampleRate:A,numberOfAudioChannels:d,internalInterleavedLength:l,leftBuffers:a,rightBuffers:1===d?[]:o,noWorker:i.noWorker},(function(t,i){r.blob=new Blob([i],{type:"audio/wav"}),r.buffer=new ArrayBuffer(i.buffer.byteLength),r.view=i,r.sampleRate=c||A,r.bufferSize=y,r.length=l,w=!1,e&&e(r.blob)}))},void 0===t.Storage&&(t.Storage={AudioContextConstructor:null,AudioContext:window.AudioContext||window.webkitAudioContext}),t.Storage.AudioContextConstructor&&"closed"!==t.Storage.AudioContextConstructor.state||(t.Storage.AudioContextConstructor=new t.Storage.AudioContext);var f=t.Storage.AudioContextConstructor,m=f.createMediaStreamSource(e),g=[0,256,512,1024,2048,4096,8192,16384],y=void 0===i.bufferSize?4096:i.bufferSize;if(-1===g.indexOf(y)&&(i.disableLogs||console.log("Legal values for buffer-size are "+JSON.stringify(g,null,"\t"))),f.createJavaScriptNode)s=f.createJavaScriptNode(y,d,d);else{if(!f.createScriptProcessor)throw"WebAudio API has no support on this browser.";s=f.createScriptProcessor(y,d,d)}m.connect(s),i.bufferSize||(y=s.bufferSize);var A=void 0!==i.sampleRate?i.sampleRate:f.sampleRate||44100;(A<22050||A>96e3)&&(i.disableLogs||console.log("sample-rate must be under range 22050 and 96000.")),i.disableLogs||i.desiredSampRate&&console.log("Desired sample-rate: "+i.desiredSampRate);var b=!1;function v(){a=[],o=[],l=0,w=!1,n=!1,b=!1,f=null,r.leftchannel=a,r.rightchannel=o,r.numberOfAudioChannels=d,r.desiredSampRate=c,r.sampleRate=A,r.recordingLength=l,E={left:[],right:[],recordingLength:0}}function S(){s&&(s.onaudioprocess=null,s.disconnect(),s=null),m&&(m.disconnect(),m=null),v()}this.pause=function(){b=!0},this.resume=function(){if(!1===u())throw"Please make sure MediaStream is active.";if(!n)return i.disableLogs||console.log("Seems recording has been restarted."),void this.record();b=!1},this.clearRecordedData=function(){i.checkForInactiveTracks=!1,n&&this.stop(S),S()},this.name="StereoAudioRecorder",this.toString=function(){return this.name};var w=!1;s.onaudioprocess=function(e){if(!b)if(!1===u()&&(i.disableLogs||console.log("MediaStream seems stopped."),s.disconnect(),n=!1),n){w||(w=!0,i.onAudioProcessStarted&&i.onAudioProcessStarted(),i.initCallback&&i.initCallback());var t=e.inputBuffer.getChannelData(0),h=new Float32Array(t);if(a.push(h),2===d){var c=e.inputBuffer.getChannelData(1),p=new Float32Array(c);o.push(p)}l+=y,r.recordingLength=l,void 0!==i.timeSlice&&(E.recordingLength+=y,E.left.push(h),2===d&&E.right.push(p))}else m&&(m.disconnect(),m=null)},f.createMediaStreamDestination?s.connect(f.createMediaStreamDestination()):s.connect(f.destination),this.leftchannel=a,this.rightchannel=o,this.numberOfAudioChannels=d,this.desiredSampRate=c,this.sampleRate=A,r.recordingLength=l;var E={left:[],right:[],recordingLength:0};function T(){n&&"function"==typeof i.ondataavailable&&void 0!==i.timeSlice&&(E.left.length?(p({desiredSampRate:c,sampleRate:A,numberOfAudioChannels:d,internalInterleavedLength:E.recordingLength,leftBuffers:E.left,rightBuffers:1===d?[]:E.right},(function(e,t){var s=new Blob([t],{type:"audio/wav"});i.ondataavailable(s),setTimeout(T,i.timeSlice)})),E={left:[],right:[],recordingLength:0}):setTimeout(T,i.timeSlice))}}function k(e,t){if("undefined"==typeof html2canvas)throw"Please link: https://www.webrtc-experiment.com/screenshot.js";(t=t||{}).frameInterval||(t.frameInterval=10);var i=!1;["captureStream","mozCaptureStream","webkitCaptureStream"].forEach((function(e){e in document.createElement("canvas")&&(i=!0)}));var s,r,a,o=!(!window.webkitRTCPeerConnection&&!window.webkitGetUserMedia||!window.chrome),n=50,l=navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);if(o&&l&&l[2]&&(n=parseInt(l[2],10)),o&&n<52&&(i=!1),t.useWhammyRecorder&&(i=!1),i)if(t.disableLogs||console.log("Your browser supports both MediRecorder API and canvas.captureStream!"),e instanceof HTMLCanvasElement)s=e;else{if(!(e instanceof CanvasRenderingContext2D))throw"Please pass either HTMLCanvasElement or CanvasRenderingContext2D.";s=e.canvas}else navigator.mozGetUserMedia&&(t.disableLogs||console.error("Canvas recording is NOT supported in Firefox."));this.record=function(){if(a=!0,i&&!t.useWhammyRecorder){var e;"captureStream"in s?e=s.captureStream(25):"mozCaptureStream"in s?e=s.mozCaptureStream(25):"webkitCaptureStream"in s&&(e=s.webkitCaptureStream(25));try{var o=new g;o.addTrack(_(e,"video")[0]),e=o}catch(e){}if(!e)throw"captureStream API are NOT available.";(r=new E(e,{mimeType:t.mimeType||"video/webm"})).record()}else p.frames=[],u=(new Date).getTime(),c();t.initCallback&&t.initCallback()},this.getWebPImages=function(i){if("canvas"===e.nodeName.toLowerCase()){var s=p.frames.length;p.frames.forEach((function(e,i){var r=s-i;t.disableLogs||console.log(r+"/"+s+" frames remaining"),t.onEncodingCallback&&t.onEncodingCallback(r,s);var a=e.image.toDataURL("image/webp",1);p.frames[i].image=a})),t.disableLogs||console.log("Generating WebM"),i()}else i()},this.stop=function(e){a=!1;var s=this;i&&r?r.stop(e):this.getWebPImages((function(){p.compile((function(i){t.disableLogs||console.log("Recording finished!"),s.blob=i,s.blob.forEach&&(s.blob=new Blob([],{type:"video/webm"})),e&&e(s.blob),p.frames=[]}))}))};var d=!1;function h(){p.frames=[],a=!1,d=!1}function c(){if(d)return u=(new Date).getTime(),setTimeout(c,500);if("canvas"===e.nodeName.toLowerCase()){var i=(new Date).getTime()-u;return u=(new Date).getTime(),p.frames.push({image:(s=document.createElement("canvas"),r=s.getContext("2d"),s.width=e.width,s.height=e.height,r.drawImage(e,0,0),s),duration:i}),void(a&&setTimeout(c,t.frameInterval))}var s,r;html2canvas(e,{grabMouse:void 0===t.showMousePointer||t.showMousePointer,onrendered:function(e){var i=(new Date).getTime()-u;if(!i)return setTimeout(c,t.frameInterval);u=(new Date).getTime(),p.frames.push({image:e.toDataURL("image/webp",1),duration:i}),a&&setTimeout(c,t.frameInterval)}})}this.pause=function(){d=!0,r instanceof E&&r.pause()},this.resume=function(){d=!1,r instanceof E?r.resume():a||this.record()},this.clearRecordedData=function(){a&&this.stop(h),h()},this.name="CanvasRecorder",this.toString=function(){return this.name};var u=(new Date).getTime(),p=new R.Video(100)}function C(e,t){function i(e){e=void 0!==e?e:10;var t=(new Date).getTime()-l;return t?a?(l=(new Date).getTime(),setTimeout(i,100)):(l=(new Date).getTime(),n.paused&&n.play(),c.drawImage(n,0,0,h.width,h.height),d.frames.push({duration:t,image:h.toDataURL("image/webp")}),void(r||setTimeout(i,e,e))):setTimeout(i,e,e)}function s(e,t,i,s,r){var a=document.createElement("canvas");a.width=h.width,a.height=h.height;var o=a.getContext("2d"),n=[],l=-1===t,d=t&&t>0&&t<=e.length?t:e.length,c=0,u=0,p=0,f=Math.sqrt(Math.pow(255,2)+Math.pow(255,2)+Math.pow(255,2)),m=i&&i>=0&&i<=1?i:0,g=s&&s>=0&&s<=1?s:0,y=!1;!function(e){var t=-1,i=e.length;!function s(){++t!==i?setTimeout((function(){e.functionToLoop(s,t)}),1):e.callback()}()}({length:d,functionToLoop:function(t,i){var s,r,a,d=function(){!y&&a-s<=a*g||(l&&(y=!0),n.push(e[i])),t()};if(y)d();else{var A=new Image;A.onload=function(){o.drawImage(A,0,0,h.width,h.height);var e=o.getImageData(0,0,h.width,h.height);s=0,r=e.data.length,a=e.data.length/4;for(var t=0;t<r;t+=4){var i={r:e.data[t],g:e.data[t+1],b:e.data[t+2]};Math.sqrt(Math.pow(i.r-c,2)+Math.pow(i.g-u,2)+Math.pow(i.b-p,2))<=f*m&&s++}d()},A.src=e[i].image}},callback:function(){(n=n.concat(e.slice(d))).length<=0&&n.push(e[e.length-1]),r(n)}})}(t=t||{}).frameInterval||(t.frameInterval=10),t.disableLogs||console.log("Using frames-interval:",t.frameInterval),this.record=function(){t.width||(t.width=320),t.height||(t.height=240),t.video||(t.video={width:t.width,height:t.height}),t.canvas||(t.canvas={width:t.width,height:t.height}),h.width=t.canvas.width||320,h.height=t.canvas.height||240,c=h.getContext("2d"),t.video&&t.video instanceof HTMLVideoElement?(n=t.video.cloneNode(),t.initCallback&&t.initCallback()):(n=document.createElement("video"),v(e,n),n.onloadedmetadata=function(){t.initCallback&&t.initCallback()},n.width=t.video.width,n.height=t.video.height),n.muted=!0,n.play(),l=(new Date).getTime(),d=new R.Video,t.disableLogs||(console.log("canvas resolutions",h.width,"*",h.height),console.log("video width/height",n.width||h.width,"*",n.height||h.height)),i(t.frameInterval)};var r=!1;this.stop=function(e){e=e||function(){},r=!0;var i=this;setTimeout((function(){s(d.frames,-1,null,null,(function(s){d.frames=s,t.advertisement&&t.advertisement.length&&(d.frames=t.advertisement.concat(d.frames)),d.compile((function(t){i.blob=t,i.blob.forEach&&(i.blob=new Blob([],{type:"video/webm"})),e&&e(i.blob)}))}))}),10)};var a=!1;function o(){d.frames=[],r=!0,a=!1}this.pause=function(){a=!0},this.resume=function(){a=!1,r&&this.record()},this.clearRecordedData=function(){r||this.stop(o),o()},this.name="WhammyRecorder",this.toString=function(){return this.name};var n,l,d,h=document.createElement("canvas"),c=h.getContext("2d")}void 0!==d?S.AudioContext=d:"undefined"!=typeof webkitAudioContext&&(S.AudioContext=webkitAudioContext),void 0!==t&&(t.Storage=S),void 0!==t&&(t.MediaStreamRecorder=E),void 0!==t&&(t.StereoAudioRecorder=T),void 0!==t&&(t.CanvasRecorder=k),void 0!==t&&(t.WhammyRecorder=C);var R=function(){function e(e){this.frames=[],this.duration=e||1,this.quality=.8}function t(e){function t(e,t,i){return[{data:e,id:231}].concat(i.map((function(e){var i=function(e){var t=0;e.keyframe&&(t|=128);e.invisible&&(t|=8);e.lacing&&(t|=e.lacing<<1);e.discardable&&(t|=1);if(e.trackNum>127)throw"TrackNumber > 127 not supported";var i=[128|e.trackNum,e.timecode>>8,255&e.timecode,t].map((function(e){return String.fromCharCode(e)})).join("")+e.frame;return i}({discardable:0,frame:e.data.slice(4),invisible:0,keyframe:1,lacing:0,trackNum:1,timecode:Math.round(t)});return t+=e.duration,{data:i,id:163}})))}function i(e){for(var t=[];e>0;)t.push(255&e),e>>=8;return new Uint8Array(t.reverse())}function s(e){var t=[];e=(e.length%8?new Array(9-e.length%8).join("0"):"")+e;for(var i=0;i<e.length;i+=8)t.push(parseInt(e.substr(i,8),2));return new Uint8Array(t)}function r(e){for(var t=[],a=0;a<e.length;a++){var o=e[a].data;"object"==typeof o&&(o=r(o)),"number"==typeof o&&(o=s(o.toString(2))),"string"==typeof o&&(o=new Uint8Array(o.split("").map((function(e){return e.charCodeAt(0)}))));var n=o.size||o.byteLength||o.length,l=Math.ceil(Math.ceil(Math.log(n)/Math.log(2))/8),d=n.toString(2),h=new Array(7*l+7+1-d.length).join("0")+d,c=new Array(l).join("0")+"1"+h;t.push(i(e[a].id)),t.push(s(c)),t.push(o)}return new Blob(t,{type:"video/webm"})}function a(e,t){return parseInt(e.substr(t+4,4).split("").map((function(e){var t=e.charCodeAt(0).toString(2);return new Array(8-t.length+1).join("0")+t})).join(""),2)}function o(e){for(var t=0,i={};t<e.length;){var s=e.substr(t,4),r=a(e,t),n=e.substr(t+4+4,r);t+=8+r,i[s]=i[s]||[],"RIFF"===s||"LIST"===s?i[s].push(o(n)):i[s].push(n)}return i}var n=new function(e){var i=function(e){if(!e[0])return void postMessage({error:"Something went wrong. Maybe WebP format is not supported in the current browser."});for(var t=e[0].width,i=e[0].height,s=e[0].duration,r=1;r<e.length;r++)s+=e[r].duration;return{duration:s,width:t,height:i}}(e);if(!i)return[];for(var s,a=[{id:440786851,data:[{data:1,id:17030},{data:1,id:17143},{data:4,id:17138},{data:8,id:17139},{data:"webm",id:17026},{data:2,id:17031},{data:2,id:17029}]},{id:408125543,data:[{id:357149030,data:[{data:1e6,id:2807729},{data:"whammy",id:19840},{data:"whammy",id:22337},{data:(s=i.duration,[].slice.call(new Uint8Array(new Float64Array([s]).buffer),0).map((function(e){return String.fromCharCode(e)})).reverse().join("")),id:17545}]},{id:374648427,data:[{id:174,data:[{data:1,id:215},{data:1,id:29637},{data:0,id:156},{data:"und",id:2274716},{data:"V_VP8",id:134},{data:"VP8",id:2459272},{data:1,id:131},{id:224,data:[{data:i.width,id:176},{data:i.height,id:186}]}]}]}]}],o=0,n=0;o<e.length;){var l=[],d=0;do{l.push(e[o]),d+=e[o].duration,o++}while(o<e.length&&d<3e4);var h={id:524531317,data:t(n,0,l)};a[1].data.push(h),n+=d}return r(a)}(e.map((function(e){var t=function(e){for(var t=e.RIFF[0].WEBP[0],i=t.indexOf("*"),s=0,r=[];s<4;s++)r[s]=t.charCodeAt(i+3+s);return{width:16383&(r[1]<<8|r[0]),height:16383&(r[3]<<8|r[2]),data:t,riff:e}}(o(atob(e.image.slice(23))));return t.duration=e.duration,t})));postMessage(n)}return e.prototype.add=function(e,t){if("canvas"in e&&(e=e.canvas),"toDataURL"in e&&(e=e.toDataURL("image/webp",this.quality)),!/^data:image\/webp;base64,/gi.test(e))throw"Input must be formatted properly as a base64 encoded DataURI of type image/webp";this.frames.push({image:e,duration:t||this.duration})},e.prototype.compile=function(e){var i,s,r,a=(i=t,s=h.createObjectURL(new Blob([i.toString(),"this.onmessage = function (eee) {"+i.name+"(eee.data);}"],{type:"application/javascript"})),r=new Worker(s),h.revokeObjectURL(s),r);a.onmessage=function(t){t.data.error?console.error(t.data.error):e(t.data)},a.postMessage(this.frames)},{Video:e}}();void 0!==t&&(t.Whammy=R);var x={init:function(){var e=this;if("undefined"!=typeof indexedDB&&void 0!==indexedDB.open){var t,i=this.dbName||location.href.replace(/\/|:|#|%|\.|\[|\]/g,""),s=indexedDB.open(i,1);s.onerror=e.onError,s.onsuccess=function(){((t=s.result).onerror=e.onError,t.setVersion)?1!==t.version?t.setVersion(1).onsuccess=function(){r(t),a()}:a():a()},s.onupgradeneeded=function(e){r(e.target.result)}}else console.error("IndexedDB API are not available in this browser.");function r(t){t.createObjectStore(e.dataStoreName)}function a(){var i=t.transaction([e.dataStoreName],"readwrite");function s(t){i.objectStore(e.dataStoreName).get(t).onsuccess=function(i){e.callback&&e.callback(i.target.result,t)}}e.videoBlob&&i.objectStore(e.dataStoreName).put(e.videoBlob,"videoBlob"),e.gifBlob&&i.objectStore(e.dataStoreName).put(e.gifBlob,"gifBlob"),e.audioBlob&&i.objectStore(e.dataStoreName).put(e.audioBlob,"audioBlob"),s("audioBlob"),s("videoBlob"),s("gifBlob")}},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 D(e,t){if("undefined"==typeof GIFEncoder){var i=document.createElement("script");i.src="https://www.webrtc-experiment.com/gif-recorder.js",(document.body||document.documentElement).appendChild(i)}t=t||{};var s=e instanceof CanvasRenderingContext2D||e instanceof HTMLCanvasElement;this.record=function(){"undefined"!=typeof GIFEncoder&&d?(s||(t.width||(t.width=h.offsetWidth||320),t.height||(t.height=h.offsetHeight||240),t.video||(t.video={width:t.width,height:t.height}),t.canvas||(t.canvas={width:t.width,height:t.height}),a.width=t.canvas.width||320,a.height=t.canvas.height||240,h.width=t.video.width||320,h.height=t.video.height||240),(u=new GIFEncoder).setRepeat(0),u.setDelay(t.frameRate||200),u.setQuality(t.quality||10),u.start(),"function"==typeof t.onGifRecordingStarted&&t.onGifRecordingStarted(),p=o((function e(i){if(!0!==f.clearedRecordedData){if(r)return setTimeout((function(){e(i)}),100);p=o(e),void 0===typeof c&&(c=i),i-c<90||(!s&&h.paused&&h.play(),s||n.drawImage(h,0,0,a.width,a.height),t.onGifPreview&&t.onGifPreview(a.toDataURL("image/png")),u.addFrame(n),c=i)}})),t.initCallback&&t.initCallback()):setTimeout(f.record,1e3)},this.stop=function(e){e=e||function(){},p&&l(p),this.blob=new Blob([new Uint8Array(u.stream().bin)],{type:"image/gif"}),e(this.blob),u.stream().bin=[]};var r=!1;this.pause=function(){r=!0},this.resume=function(){r=!1},this.clearRecordedData=function(){f.clearedRecordedData=!0,u&&(u.stream().bin=[])},this.name="GifRecorder",this.toString=function(){return this.name};var a=document.createElement("canvas"),n=a.getContext("2d");s&&(e instanceof CanvasRenderingContext2D?a=(n=e).canvas:e instanceof HTMLCanvasElement&&(n=e.getContext("2d"),a=e));var d=!0;if(!s){var h=document.createElement("video");h.muted=!0,h.autoplay=!0,h.playsInline=!0,d=!1,h.onloadedmetadata=function(){d=!0},v(e,h),h.play()}var c,u,p=null,f=this}function L(e,i){!function(e){void 0===t&&e&&"undefined"==typeof window&&void 0!==Tr&&(Tr.navigator={userAgent:"Fake/5.0 (FakeOS) AppleWebKit/123 (KHTML, like Gecko) Fake/12.3.4567.89 Fake/123.45",getUserMedia:function(){}},Tr.console||(Tr.console={}),void 0!==Tr.console.log&&void 0!==Tr.console.error||(Tr.console.error=Tr.console.log=Tr.console.log||function(){console.log(arguments)}),"undefined"==typeof document&&(e.document={documentElement:{appendChild:function(){return""}}},document.createElement=document.captureStream=document.mozCaptureStream=function(){var e={getContext:function(){return e},play:function(){},pause:function(){},drawImage:function(){},toDataURL:function(){return""},style:{}};return e},e.HTMLVideoElement=function(){}),"undefined"==typeof location&&(e.location={protocol:"file:",href:"",hash:""}),"undefined"==typeof screen&&(e.screen={width:0,height:0}),void 0===d&&(e.URL={createObjectURL:function(){return""},revokeObjectURL:function(){return""}}),e.window=Tr)}(void 0!==Tr?Tr:null),i=i||"multi-streams-mixer";var s=[],r=!1,a=document.createElement("canvas"),o=a.getContext("2d");a.style.opacity=0,a.style.position="absolute",a.style.zIndex=-1,a.style.top="-1000em",a.style.left="-1000em",a.className=i,(document.body||document.documentElement).appendChild(a),this.disableLogs=!1,this.frameInterval=10,this.width=360,this.height=240,this.useGainNode=!0;var n=this,l=window.AudioContext;void 0===l&&("undefined"!=typeof webkitAudioContext&&(l=webkitAudioContext),"undefined"!=typeof mozAudioContext&&(l=mozAudioContext));var d=window.URL;void 0===d&&"undefined"!=typeof webkitURL&&(d=webkitURL),"undefined"!=typeof navigator&&void 0===navigator.getUserMedia&&(void 0!==navigator.webkitGetUserMedia&&(navigator.getUserMedia=navigator.webkitGetUserMedia),void 0!==navigator.mozGetUserMedia&&(navigator.getUserMedia=navigator.mozGetUserMedia));var h=window.MediaStream;void 0===h&&"undefined"!=typeof webkitMediaStream&&(h=webkitMediaStream),void 0!==h&&void 0===h.prototype.stop&&(h.prototype.stop=function(){this.getTracks().forEach((function(e){e.stop()}))});var c={};function u(){if(!r){var e=s.length,t=!1,i=[];if(s.forEach((function(e){e.stream||(e.stream={}),e.stream.fullcanvas?t=e:i.push(e)})),t)a.width=t.stream.width,a.height=t.stream.height;else if(i.length){a.width=e>1?2*i[0].width:i[0].width;var o=1;3!==e&&4!==e||(o=2),5!==e&&6!==e||(o=3),7!==e&&8!==e||(o=4),9!==e&&10!==e||(o=5),a.height=i[0].height*o}else a.width=n.width||360,a.height=n.height||240;t&&t instanceof HTMLVideoElement&&p(t),i.forEach((function(e,t){p(e,t)})),setTimeout(u,n.frameInterval)}}function p(e,t){if(!r){var i=0,s=0,a=e.width,n=e.height;1===t&&(i=e.width),2===t&&(s=e.height),3===t&&(i=e.width,s=e.height),4===t&&(s=2*e.height),5===t&&(i=e.width,s=2*e.height),6===t&&(s=3*e.height),7===t&&(i=e.width,s=3*e.height),void 0!==e.stream.left&&(i=e.stream.left),void 0!==e.stream.top&&(s=e.stream.top),void 0!==e.stream.width&&(a=e.stream.width),void 0!==e.stream.height&&(n=e.stream.height),o.drawImage(e,i,s,a,n),"function"==typeof e.stream.onRender&&e.stream.onRender(o,i,s,a,n,t)}}function f(e){var t=document.createElement("video");return function(e,t){"srcObject"in t?t.srcObject=e:"mozSrcObject"in t?t.mozSrcObject=e:t.srcObject=e}(e,t),t.className=i,t.muted=!0,t.volume=0,t.width=e.width||n.width||360,t.height=e.height||n.height||240,t.play(),t}function m(t){s=[],(t=t||e).forEach((function(e){if(e.getTracks().filter((function(e){return"video"===e.kind})).length){var t=f(e);t.stream=e,s.push(t)}}))}void 0!==l?c.AudioContext=l:"undefined"!=typeof webkitAudioContext&&(c.AudioContext=webkitAudioContext),this.startDrawingFrames=function(){u()},this.appendStreams=function(t){if(!t)throw"First parameter is required.";t instanceof Array||(t=[t]),t.forEach((function(t){var i=new h;if(t.getTracks().filter((function(e){return"video"===e.kind})).length){var r=f(t);r.stream=t,s.push(r),i.addTrack(t.getTracks().filter((function(e){return"video"===e.kind}))[0])}if(t.getTracks().filter((function(e){return"audio"===e.kind})).length){var a=n.audioContext.createMediaStreamSource(t);n.audioDestination=n.audioContext.createMediaStreamDestination(),a.connect(n.audioDestination),i.addTrack(n.audioDestination.stream.getTracks().filter((function(e){return"audio"===e.kind}))[0])}e.push(i)}))},this.releaseStreams=function(){s=[],r=!0,n.gainNode&&(n.gainNode.disconnect(),n.gainNode=null),n.audioSources.length&&(n.audioSources.forEach((function(e){e.disconnect()})),n.audioSources=[]),n.audioDestination&&(n.audioDestination.disconnect(),n.audioDestination=null),n.audioContext&&n.audioContext.close(),n.audioContext=null,o.clearRect(0,0,a.width,a.height),a.stream&&(a.stream.stop(),a.stream=null)},this.resetVideoStreams=function(e){!e||e instanceof Array||(e=[e]),m(e)},this.name="MultiStreamsMixer",this.toString=function(){return this.name},this.getMixedStream=function(){r=!1;var t=function(){var e;m(),"captureStream"in a?e=a.captureStream():"mozCaptureStream"in a?e=a.mozCaptureStream():n.disableLogs||console.error("Upgrade to latest Chrome or otherwise enable this flag: chrome://flags/#enable-experimental-web-platform-features");var t=new h;return e.getTracks().filter((function(e){return"video"===e.kind})).forEach((function(e){t.addTrack(e)})),a.stream=t,t}(),i=function(){c.AudioContextConstructor||(c.AudioContextConstructor=new c.AudioContext);n.audioContext=c.AudioContextConstructor,n.audioSources=[],!0===n.useGainNode&&(n.gainNode=n.audioContext.createGain(),n.gainNode.connect(n.audioContext.destination),n.gainNode.gain.value=0);var t=0;if(e.forEach((function(e){if(e.getTracks().filter((function(e){return"audio"===e.kind})).length){t++;var i=n.audioContext.createMediaStreamSource(e);!0===n.useGainNode&&i.connect(n.gainNode),n.audioSources.push(i)}})),!t)return;return n.audioDestination=n.audioContext.createMediaStreamDestination(),n.audioSources.forEach((function(e){e.connect(n.audioDestination)})),n.audioDestination.stream}();return i&&i.getTracks().filter((function(e){return"audio"===e.kind})).forEach((function(e){t.addTrack(e)})),e.forEach((function(e){e.fullcanvas})),t}}function P(e,t){e=e||[];var i,s,r=this;(t=t||{elementClass:"multi-streams-mixer",mimeType:"video/webm",video:{width:360,height:240}}).frameInterval||(t.frameInterval=10),t.video||(t.video={}),t.video.width||(t.video.width=360),t.video.height||(t.video.height=240),this.record=function(){var r;i=new L(e,t.elementClass||"multi-streams-mixer"),(r=[],e.forEach((function(e){_(e,"video").forEach((function(e){r.push(e)}))})),r).length&&(i.frameInterval=t.frameInterval||10,i.width=t.video.width||360,i.height=t.video.height||240,i.startDrawingFrames()),t.previewStream&&"function"==typeof t.previewStream&&t.previewStream(i.getMixedStream()),(s=new E(i.getMixedStream(),t)).record()},this.stop=function(e){s&&s.stop((function(t){r.blob=t,e(t),r.clearRecordedData()}))},this.pause=function(){s&&s.pause()},this.resume=function(){s&&s.resume()},this.clearRecordedData=function(){s&&(s.clearRecordedData(),s=null),i&&(i.releaseStreams(),i=null)},this.addStreams=function(r){if(!r)throw"First parameter is required.";r instanceof Array||(r=[r]),e.concat(r),s&&i&&(i.appendStreams(r),t.previewStream&&"function"==typeof t.previewStream&&t.previewStream(i.getMixedStream()))},this.resetVideoStreams=function(e){i&&(!e||e instanceof Array||(e=[e]),i.resetVideoStreams(e))},this.getMixer=function(){return i},this.name="MultiStreamRecorder",this.toString=function(){return this.name}}function B(e,t){var i,s,r;function a(){return new ReadableStream({start:function(s){var r=document.createElement("canvas"),a=document.createElement("video"),o=!0;a.srcObject=e,a.muted=!0,a.height=t.height,a.width=t.width,a.volume=0,a.onplaying=function(){r.width=t.width,r.height=t.height;var e=r.getContext("2d"),n=1e3/t.frameRate,l=setInterval((function(){if(i&&(clearInterval(l),s.close()),o&&(o=!1,t.onVideoProcessStarted&&t.onVideoProcessStarted()),e.drawImage(a,0,0),"closed"!==s._controlledReadableStream.state)try{s.enqueue(e.getImageData(0,0,t.width,t.height))}catch(e){}}),n)},a.play()}})}function o(e,l){if(!t.workerPath&&!l)return i=!1,void fetch("https://unpkg.com/webm-wasm@latest/dist/webm-worker.js").then((function(t){t.arrayBuffer().then((function(t){o(e,t)}))}));if(!t.workerPath&&l instanceof ArrayBuffer){var d=new Blob([l],{type:"text/javascript"});t.workerPath=h.createObjectURL(d)}t.workerPath||console.error("workerPath parameter is missing."),(s=new Worker(t.workerPath)).postMessage(t.webAssemblyPath||"https://unpkg.com/webm-wasm@latest/dist/webm-wasm.wasm"),s.addEventListener("message",(function(e){"READY"===e.data?(s.postMessage({width:t.width,height:t.height,bitrate:t.bitrate||1200,timebaseDen:t.frameRate||30,realtime:t.realtime}),a().pipeTo(new WritableStream({write:function(e){i?console.error("Got image, but recorder is finished!"):s.postMessage(e.data.buffer,[e.data.buffer])}}))):e.data&&(r||n.push(e.data))}))}"undefined"!=typeof ReadableStream&&"undefined"!=typeof WritableStream||console.error("Following polyfill is strongly recommended: https://unpkg.com/@mattiasbuelens/web-streams-polyfill/dist/polyfill.min.js"),(t=t||{}).width=t.width||640,t.height=t.height||480,t.frameRate=t.frameRate||30,t.bitrate=t.bitrate||1200,t.realtime=t.realtime||!0,this.record=function(){n=[],r=!1,this.blob=null,o(e),"function"==typeof t.initCallback&&t.initCallback()},this.pause=function(){r=!0},this.resume=function(){r=!1};var n=[];this.stop=function(e){i=!0;var t=this;!function(e){s?(s.addEventListener("message",(function(t){null===t.data&&(s.terminate(),s=null,e&&e())})),s.postMessage(null)):e&&e()}((function(){t.blob=new Blob(n,{type:"video/webm"}),e(t.blob)}))},this.name="WebAssemblyRecorder",this.toString=function(){return this.name},this.clearRecordedData=function(){n=[],r=!1,this.blob=null},this.blob=null}void 0!==t&&(t.DiskStorage=x),void 0!==t&&(t.GifRecorder=D),void 0===t&&(e.exports=L),void 0!==t&&(t.MultiStreamRecorder=P),void 0!==t&&(t.RecordRTCPromisesHandler=function(e,i){if(!this)throw'Use "new RecordRTCPromisesHandler()"';if(void 0===e)throw'First argument "MediaStream" is required.';var s=this;s.recordRTC=new t(e,i),this.startRecording=function(){return new Promise((function(e,t){try{s.recordRTC.startRecording(),e()}catch(e){t(e)}}))},this.stopRecording=function(){return new Promise((function(e,t){try{s.recordRTC.stopRecording((function(i){s.blob=s.recordRTC.getBlob(),s.blob&&s.blob.size?e(i):t("Empty blob.",s.blob)}))}catch(e){t(e)}}))},this.pauseRecording=function(){return new Promise((function(e,t){try{s.recordRTC.pauseRecording(),e()}catch(e){t(e)}}))},this.resumeRecording=function(){return new Promise((function(e,t){try{s.recordRTC.resumeRecording(),e()}catch(e){t(e)}}))},this.getDataURL=function(e){return new Promise((function(e,t){try{s.recordRTC.getDataURL((function(t){e(t)}))}catch(e){t(e)}}))},this.getBlob=function(){return new Promise((function(e,t){try{e(s.recordRTC.getBlob())}catch(e){t(e)}}))},this.getInternalRecorder=function(){return new Promise((function(e,t){try{e(s.recordRTC.getInternalRecorder())}catch(e){t(e)}}))},this.reset=function(){return new Promise((function(e,t){try{e(s.recordRTC.reset())}catch(e){t(e)}}))},this.destroy=function(){return new Promise((function(e,t){try{e(s.recordRTC.destroy())}catch(e){t(e)}}))},this.getState=function(){return new Promise((function(e,t){try{e(s.recordRTC.getState())}catch(e){t(e)}}))},this.blob=null,this.version="5.6.2"}),void 0!==t&&(t.WebAssemblyRecorder=B)}));class pn{static _ebsp2rbsp(e){let t=e,i=t.byteLength,s=new Uint8Array(i),r=0;for(let e=0;e<i;e++)e>=2&&3===t[e]&&0===t[e-1]&&0===t[e-2]||(s[r]=t[e],r++);return new Uint8Array(s.buffer,0,r)}static parseSPS(e){let t=pn._ebsp2rbsp(e),i=new Rr(t);i.readByte();let s=i.readByte();i.readByte();let r=i.readByte();i.readUEG();let a=pn.getProfileString(s),o=pn.getLevelString(r),n=1,l=420,d=[0,420,422,444],h=8;if((100===s||110===s||122===s||244===s||44===s||83===s||86===s||118===s||128===s||138===s||144===s)&&(n=i.readUEG(),3===n&&i.readBits(1),n<=3&&(l=d[n]),h=i.readUEG()+8,i.readUEG(),i.readBits(1),i.readBool())){let e=3!==n?8:12;for(let t=0;t<e;t++)i.readBool()&&(t<6?pn._skipScalingList(i,16):pn._skipScalingList(i,64))}i.readUEG();let c=i.readUEG();if(0===c)i.readUEG();else if(1===c){i.readBits(1),i.readSEG(),i.readSEG();let e=i.readUEG();for(let t=0;t<e;t++)i.readSEG()}let u=i.readUEG();i.readBits(1);let p=i.readUEG(),f=i.readUEG(),m=i.readBits(1);0===m&&i.readBits(1),i.readBits(1);let g=0,y=0,A=0,b=0;i.readBool()&&(g=i.readUEG(),y=i.readUEG(),A=i.readUEG(),b=i.readUEG());let _=1,v=1,S=0,w=!0,E=0,T=0;if(i.readBool()){if(i.readBool()){let e=i.readByte();e>0&&e<16?(_=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2][e-1],v=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1][e-1]):255===e&&(_=i.readByte()<<8|i.readByte(),v=i.readByte()<<8|i.readByte())}if(i.readBool()&&i.readBool(),i.readBool()&&(i.readBits(4),i.readBool()&&i.readBits(24)),i.readBool()&&(i.readUEG(),i.readUEG()),i.readBool()){let e=i.readBits(32),t=i.readBits(32);w=i.readBool(),E=t,T=2*e,S=E/T}}let k=1;1===_&&1===v||(k=_/v);let C=0,R=0;if(0===n)C=1,R=2-m;else{C=3===n?1:2,R=(1===n?2:1)*(2-m)}let x=16*(p+1),D=16*(f+1)*(2-m);x-=(g+y)*C,D-=(A+b)*R;let L=Math.ceil(x*k);return i.destroy(),i=null,{profile_string:a,level_string:o,bit_depth:h,ref_frames:u,chroma_format:l,chroma_format_string:pn.getChromaFormatString(l),frame_rate:{fixed:w,fps:S,fps_den:T,fps_num:E},sar_ratio:{width:_,height:v},codec_size:{width:x,height:D},present_size:{width:L,height:D}}}static parseSPS$2(e){let t=e.subarray(1,4),i="avc1.";for(let e=0;e<3;e++){let s=t[e].toString(16);s.length<2&&(s="0"+s),i+=s}let s=pn._ebsp2rbsp(e),r=new Rr(s);r.readByte();let a=r.readByte();r.readByte();let o=r.readByte();r.readUEG();let n=pn.getProfileString(a),l=pn.getLevelString(o),d=1,h=420,c=[0,420,422,444],u=8,p=8;if((100===a||110===a||122===a||244===a||44===a||83===a||86===a||118===a||128===a||138===a||144===a)&&(d=r.readUEG(),3===d&&r.readBits(1),d<=3&&(h=c[d]),u=r.readUEG()+8,p=r.readUEG()+8,r.readBits(1),r.readBool())){let e=3!==d?8:12;for(let t=0;t<e;t++)r.readBool()&&(t<6?pn._skipScalingList(r,16):pn._skipScalingList(r,64))}r.readUEG();let f=r.readUEG();if(0===f)r.readUEG();else if(1===f){r.readBits(1),r.readSEG(),r.readSEG();let e=r.readUEG();for(let t=0;t<e;t++)r.readSEG()}let m=r.readUEG();r.readBits(1);let g=r.readUEG(),y=r.readUEG(),A=r.readBits(1);0===A&&r.readBits(1),r.readBits(1);let b=0,_=0,v=0,S=0;r.readBool()&&(b=r.readUEG(),_=r.readUEG(),v=r.readUEG(),S=r.readUEG());let w=1,E=1,T=0,k=!0,C=0,R=0;if(r.readBool()){if(r.readBool()){let e=r.readByte();e>0&&e<16?(w=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2][e-1],E=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1][e-1]):255===e&&(w=r.readByte()<<8|r.readByte(),E=r.readByte()<<8|r.readByte())}if(r.readBool()&&r.readBool(),r.readBool()&&(r.readBits(4),r.readBool()&&r.readBits(24)),r.readBool()&&(r.readUEG(),r.readUEG()),r.readBool()){let e=r.readBits(32),t=r.readBits(32);k=r.readBool(),C=t,R=2*e,T=C/R}}let x=1;1===w&&1===E||(x=w/E);let D=0,L=0;if(0===d)D=1,L=2-A;else{D=3===d?1:2,L=(1===d?2:1)*(2-A)}let P=16*(g+1),B=16*(y+1)*(2-A);P-=(b+_)*D,B-=(v+S)*L;let I=Math.ceil(P*x);return r.destroy(),r=null,{codec_mimetype:i,profile_idc:a,level_idc:o,profile_string:n,level_string:l,chroma_format_idc:d,bit_depth:u,bit_depth_luma:u,bit_depth_chroma:p,ref_frames:m,chroma_format:h,chroma_format_string:pn.getChromaFormatString(h),frame_rate:{fixed:k,fps:T,fps_den:R,fps_num:C},sar_ratio:{width:w,height:E},codec_size:{width:P,height:B},present_size:{width:I,height:B}}}static _skipScalingList(e,t){let i=8,s=8,r=0;for(let a=0;a<t;a++)0!==s&&(r=e.readSEG(),s=(i+r+256)%256),i=0===s?i:s}static getProfileString(e){switch(e){case 66:return"Baseline";case 77:return"Main";case 88:return"Extended";case 100:return"High";case 110:return"High10";case 122:return"High422";case 244:return"High444";default:return"Unknown"}}static getLevelString(e){return(e/10).toFixed(1)}static getChromaFormatString(e){switch(e){case 420:return"4:2:0";case 422:return"4:2:2";case 444:return"4:4:4";default:return"Unknown"}}}class fn{constructor(e){this.buffer=e,this.buflen=e.length,this.bufpos=0,this.bufoff=0,this.iserro=!1}read(e){let t=0,i=0;for(;e;){if(e<0||this.bufpos>=this.buflen)return this.iserro=!0,0;this.iserro=!1,i=this.bufoff+e>8?8-this.bufoff:e,t<<=i,t+=this.buffer[this.bufpos]>>8-this.bufoff-i&255>>8-i,this.bufoff+=i,e-=i,8==this.bufoff&&(this.bufpos++,this.bufoff=0)}return t}look(e){let t=this.bufpos,i=this.bufoff,s=this.read(e);return this.bufpos=t,this.bufoff=i,s}read_golomb(){let e;for(e=0;0===this.read(1)&&!this.iserro;e++);return(1<<e)+this.read(e)-1}}function mn(e){const t={};let i=function(){let e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),256===new Int16Array(e)[0]}();const s=new DataView(e.buffer);let r=s.getUint8(0),a=s.getUint8(1);if(s.getUint8(2),s.getUint8(3),1!==r||0===a)return{};const o=1+(3&s.getUint8(4));if(3!==o&&4!==o)return{};let n=31&s.getUint8(5);if(0===n)return{};let l=6;for(let r=0;r<n;r++){let a=s.getUint16(l,!i);if(l+=2,0===a)continue;let o=new Uint8Array(e.buffer,l,a);l+=a;let n=pn.parseSPS(o);if(0!==r)continue;t.sps=o,t.timescale=1e3,t.codecWidth=n.codec_size.width,t.codecHeight=n.codec_size.height,t.presentWidth=n.present_size.width,t.presentHeight=n.present_size.height,t.profile=n.profile_string,t.level=n.level_string,t.bitDepth=n.bit_depth,t.chromaFormat=n.chroma_format,t.sarRatio=n.sar_ratio,t.frameRate=n.frame_rate,!1!==n.frame_rate.fixed&&0!==n.frame_rate.fps_num&&0!==n.frame_rate.fps_den||(t.frameRate={fixed:!0,fps:25,fps_num:25e3,fps_den:1e3});let d=t.frameRate.fps_den,h=t.frameRate.fps_num;t.refSampleDuration=t.timescale*(d/h);let c=o.subarray(1,4),u="avc1.";for(let e=0;e<3;e++){let t=c[e].toString(16);t.length<2&&(t="0"+t),u+=t}t.codec=u}let d=s.getUint8(l);if(0===d)return{};l++;for(let r=0;r<d;r++){let r=s.getUint16(l,!i);if(l+=2,0===r)continue;let a=new Uint8Array(e.buffer,l,r);l+=r,t.pps=a}if(t.videoType=Yi,t.sps){const e=t.sps.byteLength,i=new Uint8Array([e>>>24&255,e>>>16&255,e>>>8&255,255&e]),s=new Uint8Array(e+4);s.set(i,0),s.set(t.sps,4),t.sps=s}if(t.pps){const e=t.pps.byteLength,i=new Uint8Array([e>>>24&255,e>>>16&255,e>>>8&255,255&e]),s=new Uint8Array(e+4);s.set(i,0),s.set(t.pps,4),t.pps=s}return t}function gn(e){let{sps:t,pps:i}=e,s=8+t.byteLength+1+2+i.byteLength,r=!1;const a=pn.parseSPS$2(t);66!==t[3]&&77!==t[3]&&88!==t[3]&&(r=!0,s+=4);let o=new Uint8Array(s);o[0]=1,o[1]=t[1],o[2]=t[2],o[3]=t[3],o[4]=255,o[5]=225;let n=t.byteLength;o[6]=n>>>8,o[7]=255&n;let l=8;o.set(t,8),l+=n,o[l]=1;let d=i.byteLength;o[l+1]=d>>>8,o[l+2]=255&d,o.set(i,l+3),l+=3+d,r&&(o[l]=252|a.chroma_format_idc,o[l+1]=248|a.bit_depth_luma-8,o[l+2]=248|a.bit_depth_chroma-8,o[l+3]=0,l+=4);const h=[23,0,0,0,0],c=new Uint8Array(h.length+o.byteLength);return c.set(h,0),c.set(o,h.length),c}function yn(e,t){let i=[];i[0]=t?23:39,i[1]=1,i[2]=0,i[3]=0,i[4]=0;const s=new Uint8Array(i.length+e.byteLength);return s.set(i,0),s.set(e,i.length),s}function An(e){return 31&e[0]}function bn(e){return e===Ct.kSliceSEI}function _n(e){return!function(e){return e===Ct.sps||e===Ct.pps}(e)&&!bn(e)}function vn(e){return e===Ct.iFrame}class Sn{constructor(e){this.data=e,this.eofFlag=!1,this.currentStartcodeOffset=this.findNextStartCodeOffset(0),this.eofFlag&&console.error("Could not find H264 startcode until payload end!")}findNextStartCodeOffset(e){let t=e,i=this.data;for(;;){if(t+3>=i.byteLength)return this.eofFlag=!0,i.byteLength;let e=i[t+0]<<24|i[t+1]<<16|i[t+2]<<8|i[t+3],s=i[t+0]<<16|i[t+1]<<8|i[t+2];if(1===e||1===s)return t;t++}}readNextNaluPayload(){let e=this.data,t=null;for(;null==t&&!this.eofFlag;){let i=this.currentStartcodeOffset;i+=1===(e[i]<<24|e[i+1]<<16|e[i+2]<<8|e[i+3])?4:3;let s=31&e[i],r=(128&e[i])>>>7,a=this.findNextStartCodeOffset(i);this.currentStartcodeOffset=a,s>=Ct.kReserved0||0===r&&(t={type:s,data:e.subarray(i,a)})}return t}}class wn{constructor(e){let t=e.data.byteLength;this.type=e.type,this.data=new Uint8Array(4+t),new DataView(this.data.buffer).setUint32(0,t),this.data.set(e.data,4)}}const En=e=>{let t=e,i=t.byteLength,s=new Uint8Array(i),r=0;for(let e=0;e<i;e++)e>=2&&3===t[e]&&0===t[e-1]&&0===t[e-2]||(s[r]=t[e],r++);return new Uint8Array(s.buffer,0,r)},Tn=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"}};class kn{static _ebsp2rbsp(e){let t=e,i=t.byteLength,s=new Uint8Array(i),r=0;for(let e=0;e<i;e++)e>=2&&3===t[e]&&0===t[e-1]&&0===t[e-2]||(s[r]=t[e],r++);return new Uint8Array(s.buffer,0,r)}static parseVPS(e){let t=kn._ebsp2rbsp(e),i=new Rr(t);return i.readByte(),i.readByte(),i.readBits(4),i.readBits(2),i.readBits(6),{num_temporal_layers:i.readBits(3)+1,temporal_id_nested:i.readBool()}}static parseSPS(e){let t=kn._ebsp2rbsp(e),i=new Rr(t);i.readByte(),i.readByte();let s=0,r=0,a=0,o=0;i.readBits(4);let n=i.readBits(3);i.readBool();let l=i.readBits(2),d=i.readBool(),h=i.readBits(5),c=i.readByte(),u=i.readByte(),p=i.readByte(),f=i.readByte(),m=i.readByte(),g=i.readByte(),y=i.readByte(),A=i.readByte(),b=i.readByte(),_=i.readByte(),v=i.readByte(),S=[],w=[];for(let e=0;e<n;e++)S.push(i.readBool()),w.push(i.readBool());if(n>0)for(let e=n;e<8;e++)i.readBits(2);for(let e=0;e<n;e++)S[e]&&(i.readByte(),i.readByte(),i.readByte(),i.readByte(),i.readByte(),i.readByte(),i.readByte(),i.readByte(),i.readByte(),i.readByte(),i.readByte()),w[e]&&i.readByte();i.readUEG();let E=i.readUEG();3==E&&i.readBits(1);let T=i.readUEG(),k=i.readUEG();i.readBool()&&(s+=i.readUEG(),r+=i.readUEG(),a+=i.readUEG(),o+=i.readUEG());let C=i.readUEG(),R=i.readUEG(),x=i.readUEG();for(let e=i.readBool()?0:n;e<=n;e++)i.readUEG(),i.readUEG(),i.readUEG();if(i.readUEG(),i.readUEG(),i.readUEG(),i.readUEG(),i.readUEG(),i.readUEG(),i.readBool()){if(i.readBool())for(let e=0;e<4;e++)for(let t=0;t<(3===e?2:6);t++){if(i.readBool()){let t=Math.min(64,1<<4+(e<<1));e>1&&i.readSEG();for(let e=0;e<t;e++)i.readSEG()}else i.readUEG()}}i.readBool(),i.readBool(),i.readBool()&&(i.readByte(),i.readUEG(),i.readUEG(),i.readBool());let D=i.readUEG(),L=0;for(let e=0;e<D;e++){let t=!1;if(0!==e&&(t=i.readBool()),t){e===D&&i.readUEG(),i.readBool(),i.readUEG();let t=0;for(let e=0;e<=L;e++){let e=i.readBool(),s=!1;e||(s=i.readBool()),(e||s)&&t++}L=t}else{let e=i.readUEG(),t=i.readUEG();L=e+t;for(let t=0;t<e;t++)i.readUEG(),i.readBool();for(let e=0;e<t;e++)i.readUEG(),i.readBool()}}if(i.readBool()){let e=i.readUEG();for(let t=0;t<e;t++){for(let e=0;e<x+4;e++)i.readBits(1);i.readBits(1)}}let P=!1,B=0,I=1,M=1,U=!1,F=1,O=1;if(i.readBool(),i.readBool(),i.readBool()){if(i.readBool()){let e=i.readByte();e>0&&e<=16?(I=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2][e-1],M=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1][e-1]):255===e&&(I=i.readBits(16),M=i.readBits(16))}if(i.readBool()&&i.readBool(),i.readBool()){i.readBits(3),i.readBool(),i.readBool()&&(i.readByte(),i.readByte(),i.readByte())}if(i.readBool()&&(i.readUEG(),i.readUEG()),i.readBool(),i.readBool(),i.readBool(),P=i.readBool(),P&&(i.readUEG(),i.readUEG(),i.readUEG(),i.readUEG()),i.readBool()){if(F=i.readBits(32),O=i.readBits(32),i.readBool()&&i.readUEG(),i.readBool()){let e=!1,t=!1,s=!1;e=i.readBool(),t=i.readBool(),(e||t)&&(s=i.readBool(),s&&(i.readByte(),i.readBits(5),i.readBool(),i.readBits(5)),i.readBits(4),i.readBits(4),s&&i.readBits(4),i.readBits(5),i.readBits(5),i.readBits(5));for(let r=0;r<=n;r++){let r=i.readBool();U=r;let a=!0,o=1;r||(a=i.readBool());let n=!1;if(a?i.readUEG():n=i.readBool(),n||(o=i.readUEG()+1),e){for(let e=0;e<o;e++)i.readUEG(),i.readUEG(),s&&(i.readUEG(),i.readUEG());i.readBool()}if(t){for(let e=0;e<o;e++)i.readUEG(),i.readUEG(),s&&(i.readUEG(),i.readUEG());i.readBool()}}}}i.readBool()&&(i.readBool(),i.readBool(),i.readBool(),B=i.readUEG(),i.readUEG(),i.readUEG(),i.readUEG(),i.readUEG())}i.readBool();let N=`hvc1.${h}.1.L${v}.B0`,j=T-(s+r)*(1===E||2===E?2:1),z=k-(a+o)*(1===E?2:1),G=1;return 1!==I&&1!==M&&(G=I/M),i.destroy(),i=null,{codec_mimetype:N,profile_string:kn.getProfileString(h),level_string:kn.getLevelString(v),profile_idc:h,bit_depth:C+8,ref_frames:1,chroma_format:E,chroma_format_string:kn.getChromaFormatString(E),general_level_idc:v,general_profile_space:l,general_tier_flag:d,general_profile_idc:h,general_profile_compatibility_flags_1:c,general_profile_compatibility_flags_2:u,general_profile_compatibility_flags_3:p,general_profile_compatibility_flags_4:f,general_constraint_indicator_flags_1:m,general_constraint_indicator_flags_2:g,general_constraint_indicator_flags_3:y,general_constraint_indicator_flags_4:A,general_constraint_indicator_flags_5:b,general_constraint_indicator_flags_6:_,min_spatial_segmentation_idc:B,constant_frame_rate:0,chroma_format_idc:E,bit_depth_luma_minus8:C,bit_depth_chroma_minus8:R,frame_rate:{fixed:U,fps:O/F,fps_den:F,fps_num:O},sar_ratio:{width:I,height:M},codec_size:{width:j,height:z},present_size:{width:j*G,height:z}}}static parsePPS(e){let t=kn._ebsp2rbsp(e),i=new Rr(t);i.readByte(),i.readByte(),i.readUEG(),i.readUEG(),i.readBool(),i.readBool(),i.readBits(3),i.readBool(),i.readBool(),i.readUEG(),i.readUEG(),i.readSEG(),i.readBool(),i.readBool(),i.readBool()&&i.readUEG(),i.readSEG(),i.readSEG(),i.readBool(),i.readBool(),i.readBool(),i.readBool();let s=i.readBool(),r=i.readBool(),a=1;return r&&s?a=0:r?a=3:s&&(a=2),{parallelismType:a}}static getChromaFormatString(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"}}static getProfileString(e){switch(e){case 1:return"Main";case 2:return"Main10";case 3:return"MainSP";case 4:return"Rext";case 9:return"SCC";default:return"Unknown"}}static getLevelString(e){return(e/30).toFixed(1)}}function Cn(e){let t={codecWidth:0,codecHeight:0,videoType:Qi,width:0,height:0,profile:0,level:0};e=e.slice(5);do{let i={};if(e.length<23){console.warn("parseHEVCDecoderConfigurationRecord$2",`arrayBuffer.length ${e.length} < 23`);break}if(i.configurationVersion=e[0],1!=i.configurationVersion)break;i.general_profile_space=e[1]>>6&3,i.general_tier_flag=e[1]>>5&1,i.general_profile_idc=31&e[1],i.general_profile_compatibility_flags=e[2]<<24|e[3]<<16|e[4]<<8|e[5],i.general_constraint_indicator_flags=e[6]<<24|e[7]<<16|e[8]<<8|e[9],i.general_constraint_indicator_flags=i.general_constraint_indicator_flags<<16|e[10]<<8|e[11],i.general_level_idc=e[12],i.min_spatial_segmentation_idc=(15&e[13])<<8|e[14],i.parallelismType=3&e[15],i.chromaFormat=3&e[16],i.bitDepthLumaMinus8=7&e[17],i.bitDepthChromaMinus8=7&e[18],i.avgFrameRate=e[19]<<8|e[20],i.constantFrameRate=e[21]>>6&3,i.numTemporalLayers=e[21]>>3&7,i.temporalIdNested=e[21]>>2&1,i.lengthSizeMinusOne=3&e[21];let s=e[22],r=e.slice(23);for(let e=0;e<s&&!(r.length<3);e++){let e=63&r[0],s=r[1]<<8|r[2];r=r.slice(3);for(let a=0;a<s&&!(r.length<2);a++){let s=r[0]<<8|r[1];if(r.length<2+s)break;if(r=r.slice(2),33==e){let e=new Uint8Array(s);e.set(r.slice(0,s),0),i.psps=xn(e,i),t.profile=i.general_profile_idc,t.level=i.general_level_idc/30,t.width=i.psps.pic_width_in_luma_samples-(i.psps.conf_win_left_offset+i.psps.conf_win_right_offset),t.height=i.psps.pic_height_in_luma_samples-(i.psps.conf_win_top_offset+i.psps.conf_win_bottom_offset)}r=r.slice(s)}}}while(0);return t.codecWidth=t.width||1920,t.codecHeight=t.height||1080,t.presentHeight=t.codecHeight,t.presentWidth=t.codecWidth,t.timescale=1e3,t.refSampleDuration=1e3/23976*1e3,t}function Rn(e){const t=e;if(t.length<22)return console.error(`Invalid HEVCDecoderConfigurationRecord, lack of data! ${t.length} < 22`),{};let i={codecWidth:0,codecHeight:0,videoType:Qi},s=function(){let e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),256===new Int16Array(e)[0]}(),r=new DataView(t.buffer),a=r.getUint8(0),o=31&r.getUint8(1);if(1!==a||0===o)return console.error(`Invalid HEVCDecoderConfigurationRecord,version is ${a}, hevcProfile is ${o}`),{};let n=1+(3&r.getUint8(21));if(3!==n&&4!==n)return console.error("Invalid HEVCDecoderConfigurationRecord, Strange NaluLengthSizeMinusOne: "+(n-1)),{};let l=r.getUint8(22);for(let e=0,a=23;e<l;e++){let e=63&r.getUint8(a+0),o=r.getUint16(a+1,!s);a+=3;for(let n=0;n<o;n++){let o=r.getUint16(a+0,!s);if(0===n)if(33===e){a+=2;let e=new Uint8Array(t.buffer,a,o),s=kn.parseSPS(e);i.codecWidth=s.codec_size.width,i.codecHeight=s.codec_size.height,i.presentWidth=s.present_size.width,i.presentHeight=s.present_size.height,i.profile=s.profile_string,i.level=s.level_string,i.bitDepth=s.bit_depth,i.chromaFormat=s.chroma_format,i.sarRatio=s.sar_ratio,i.frameRate=s.frame_rate,!1!==s.frame_rate.fixed&&0!==s.frame_rate.fps_num&&0!==s.frame_rate.fps_den||(i.frameRate={fixed:!0,fps:23.976,fps_num:23976,fps_den:1e3}),i.frameRate.fps_den,i.frameRate.fps_num,i.codec=s.codec_mimetype,a+=o}else a+=2+o;else a+=2+o}}return i.hvcc=new Uint8Array(t),i}function xn(e,t){let i={},s=e.length,r=[],a=new fn(e);a.read(1),a.read(6),a.read(6),a.read(3);for(let e=2;e<s;e++)e+2<s&&3==a.look(24)?(r.push(a.read(8)),r.push(a.read(8)),e+=2,a.read(8)):r.push(a.read(8));let o=new Uint8Array(r),n=new fn(o);if(i.sps_video_parameter_set_id=n.read(4),i.sps_max_sub_layers_minus1=n.read(3),i.sps_temporal_id_nesting_flag=n.read(1),i.profile_tier_level=function(e,t,i){let s={};s.profile_space=e.read(2),s.tier_flag=e.read(1),s.profile_idc=e.read(5),s.profile_compatibility_flags=e.read(32),s.general_progressive_source_flag=e.read(1),s.general_interlaced_source_flag=e.read(1),s.general_non_packed_constraint_flag=e.read(1),s.general_frame_only_constraint_flag=e.read(1),e.read(32),e.read(12),s.level_idc=e.read(8),s.sub_layer_profile_present_flag=[],s.sub_layer_level_present_flag=[];for(let t=0;t<i;t++)s.sub_layer_profile_present_flag[t]=e.read(1),s.sub_layer_level_present_flag[t]=e.read(1);if(i>0)for(let t=i;t<8;t++)e.read(2);s.sub_layer_profile_space=[],s.sub_layer_tier_flag=[],s.sub_layer_profile_idc=[],s.sub_layer_profile_compatibility_flag=[],s.sub_layer_progressive_source_flag=[],s.sub_layer_interlaced_source_flag=[],s.sub_layer_non_packed_constraint_flag=[],s.sub_layer_frame_only_constraint_flag=[],s.sub_layer_level_idc=[];for(let t=0;t<i;t++)s.sub_layer_profile_present_flag[t]&&(s.sub_layer_profile_space[t]=e.read(2),s.sub_layer_tier_flag[t]=e.read(1),s.sub_layer_profile_idc[t]=e.read(5),s.sub_layer_profile_compatibility_flag[t]=e.read(32),s.sub_layer_progressive_source_flag[t]=e.read(1),s.sub_layer_interlaced_source_flag[t]=e.read(1),s.sub_layer_non_packed_constraint_flag[t]=e.read(1),s.sub_layer_frame_only_constraint_flag[t]=e.read(1),e.read(32),e.read(12)),s.sub_layer_level_present_flag[t]?s.sub_layer_level_idc[t]=e.read(8):s.sub_layer_level_idc[t]=1;return s}(n,0,i.sps_max_sub_layers_minus1),i.sps_seq_parameter_set_id=n.read_golomb(),i.chroma_format_idc=n.read_golomb(),3==i.chroma_format_idc?i.separate_colour_plane_flag=n.read(1):i.separate_colour_plane_flag=0,i.pic_width_in_luma_samples=n.read_golomb(),i.pic_height_in_luma_samples=n.read_golomb(),i.conformance_window_flag=n.read(1),i.conformance_window_flag){let e=1+(i.chroma_format_idc<2),t=1+(i.chroma_format_idc<3);i.conf_win_left_offset=n.read_golomb()*t,i.conf_win_right_offset=n.read_golomb()*t,i.conf_win_top_offset=n.read_golomb()*e,i.conf_win_bottom_offset=n.read_golomb()*e}else i.conf_win_left_offset=0,i.conf_win_right_offset=0,i.conf_win_top_offset=0,i.conf_win_bottom_offset=0;return i}function Dn(e){let{vps:t,pps:i,sps:s}=e,r={configurationVersion:1};const a=(e=>{let t=En(e),i=new Rr(t);return i.readByte(),i.readByte(),i.readBits(4),i.readBits(2),i.readBits(6),{num_temporal_layers:i.readBits(3)+1,temporal_id_nested:i.readBool()}})(t),o=(e=>{let t=En(e),i=new Rr(t);i.readByte(),i.readByte();let s=0,r=0,a=0,o=0;i.readBits(4);let n=i.readBits(3);i.readBool();let l=i.readBits(2),d=i.readBool(),h=i.readBits(5),c=i.readByte(),u=i.readByte(),p=i.readByte(),f=i.readByte(),m=i.readByte(),g=i.readByte(),y=i.readByte(),A=i.readByte(),b=i.readByte(),_=i.readByte(),v=i.readByte(),S=[],w=[];for(let e=0;e<n;e++)S.push(i.readBool()),w.push(i.readBool());if(n>0)for(let e=n;e<8;e++)i.readBits(2);for(let e=0;e<n;e++)S[e]&&(i.readByte(),i.readByte(),i.readByte(),i.readByte(),i.readByte(),i.readByte(),i.readByte(),i.readByte(),i.readByte(),i.readByte(),i.readByte()),S[e]&&i.readByte();i.readUEG();let E=i.readUEG();3==E&&i.readBits(1);let T=i.readUEG(),k=i.readUEG();i.readBool()&&(s+=i.readUEG(),r+=i.readUEG(),a+=i.readUEG(),o+=i.readUEG());let C=i.readUEG(),R=i.readUEG(),x=i.readUEG();for(let e=i.readBool()?0:n;e<=n;e++)i.readUEG(),i.readUEG(),i.readUEG();if(i.readUEG(),i.readUEG(),i.readUEG(),i.readUEG(),i.readUEG(),i.readUEG(),i.readBool()&&i.readBool())for(let e=0;e<4;e++)for(let t=0;t<(3===e?2:6);t++)if(i.readBool()){let t=Math.min(64,1<<4+(e<<1));e>1&&i.readSEG();for(let e=0;e<t;e++)i.readSEG()}else i.readUEG();i.readBool(),i.readBool(),i.readBool()&&(i.readByte(),i.readUEG(),i.readUEG(),i.readBool());let D=i.readUEG(),L=0;for(let e=0;e<D;e++){let t=!1;if(0!==e&&(t=i.readBool()),t){e===D&&i.readUEG(),i.readBool(),i.readUEG();let t=0;for(let e=0;e<=L;e++){let e=i.readBool(),s=!1;e||(s=i.readBool()),(e||s)&&t++}L=t}else{let e=i.readUEG(),t=i.readUEG();L=e+t;for(let t=0;t<e;t++)i.readUEG(),i.readBool();for(let e=0;e<t;e++)i.readUEG(),i.readBool()}}if(i.readBool()){let e=i.readUEG();for(let t=0;t<e;t++){for(let e=0;e<x+4;e++)i.readBits(1);i.readBits(1)}}let P=!1,B=0,I=1,M=1,U=!1,F=1,O=1;if(i.readBool(),i.readBool(),i.readBool()){if(i.readBool()){let e=i.readByte();e>0&&e<16?(I=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2][e-1],M=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1][e-1]):255===e&&(I=i.readBits(16),M=i.readBits(16))}if(i.readBool()&&i.readBool(),i.readBool()&&(i.readBits(3),i.readBool(),i.readBool()&&(i.readByte(),i.readByte(),i.readByte())),i.readBool()&&(i.readUEG(),i.readUEG()),i.readBool(),i.readBool(),i.readBool(),P=i.readBool(),P&&(s+=i.readUEG(),r+=i.readUEG(),a+=i.readUEG(),o+=i.readUEG()),i.readBool()&&(F=i.readBits(32),O=i.readBits(32),i.readBool()&&(i.readUEG(),i.readBool()))){let e=!1,t=!1,s=!1;e=i.readBool(),t=i.readBool(),(e||t)&&(s=i.readBool(),s&&(i.readByte(),i.readBits(5),i.readBool(),i.readBits(5)),i.readBits(4),i.readBits(4),s&&i.readBits(4),i.readBits(5),i.readBits(5),i.readBits(5));for(let r=0;r<=n;r++){let r=i.readBool();U=r;let a=!1,o=1;r||(a=i.readBool());let n=!1;if(a?i.readSEG():n=i.readBool(),n||(cpbcnt=i.readUEG()+1),e)for(let e=0;e<o;e++)i.readUEG(),i.readUEG(),s&&(i.readUEG(),i.readUEG());if(t)for(let e=0;e<o;e++)i.readUEG(),i.readUEG(),s&&(i.readUEG(),i.readUEG())}}i.readBool()&&(i.readBool(),i.readBool(),i.readBool(),B=i.readUEG(),i.readUEG(),i.readUEG(),i.readUEG(),i.readUEG())}i.readBool();let N=`hvc1.${h}.1.L${v}.B0`,j=T,z=k,G=1;return 1!==I&&1!==M&&(G=I/M),i.destroy(),i=null,{codec_mimetype:N,level_string:(H=v,(H/30).toFixed(1)),profile_idc:h,bit_depth:C+8,ref_frames:1,chroma_format:E,chroma_format_string:Tn(E),general_level_idc:v,general_profile_space:l,general_tier_flag:d,general_profile_idc:h,general_profile_compatibility_flags_1:c,general_profile_compatibility_flags_2:u,general_profile_compatibility_flags_3:p,general_profile_compatibility_flags_4:f,general_constraint_indicator_flags_1:m,general_constraint_indicator_flags_2:g,general_constraint_indicator_flags_3:y,general_constraint_indicator_flags_4:A,general_constraint_indicator_flags_5:b,general_constraint_indicator_flags_6:_,min_spatial_segmentation_idc:B,constant_frame_rate:0,chroma_format_idc:E,bit_depth_luma_minus8:C,bit_depth_chroma_minus8:R,frame_rate:{fixed:U,fps:O/F,fps_den:F,fps_num:O},sar_ratio:{width:I,height:M},codec_size:{width:j,height:z},present_size:{width:j*G,height:z}};var H})(s),n=(e=>{let t=En(e),i=new Rr(t);i.readByte(),i.readByte(),i.readUEG(),i.readUEG(),i.readBool(),i.readBool(),i.readBits(3),i.readBool(),i.readBool(),i.readUEG(),i.readUEG(),i.readSEG(),i.readBool(),i.readBool(),i.readBool()&&i.readUEG(),i.readSEG(),i.readSEG(),i.readBool(),i.readBool(),i.readBool(),i.readBool();let s=i.readBool(),r=i.readBool(),a=1;return r&&s?a=0:r?a=3:s&&(a=2),{parallelismType:a}})(i);r=Object.assign(r,a,o,n);let l=23+(5+t.byteLength)+(5+s.byteLength)+(5+i.byteLength),d=new Uint8Array(l);d[0]=1,d[1]=(3&r.general_profile_space)<<6|(r.general_tier_flag?1:0)<<5|31&r.general_profile_idc,d[2]=r.general_profile_compatibility_flags_1||0,d[3]=r.general_profile_compatibility_flags_2||0,d[4]=r.general_profile_compatibility_flags_3||0,d[5]=r.general_profile_compatibility_flags_4||0,d[6]=r.general_constraint_indicator_flags_1||0,d[7]=r.general_constraint_indicator_flags_2||0,d[8]=r.general_constraint_indicator_flags_3||0,d[9]=r.general_constraint_indicator_flags_4||0,d[10]=r.general_constraint_indicator_flags_5||0,d[11]=r.general_constraint_indicator_flags_6||0,d[12]=60,d[13]=240|(3840&r.min_spatial_segmentation_idc)>>8,d[14]=255&r.min_spatial_segmentation_idc,d[15]=252|3&r.parallelismType,d[16]=252|3&r.chroma_format_idc,d[17]=248|7&r.bit_depth_luma_minus8,d[18]=248|7&r.bit_depth_chroma_minus8,d[19]=0,d[20]=0,d[21]=(3&r.constant_frame_rate)<<6|(7&r.num_temporal_layers)<<3|(r.temporal_id_nested?1:0)<<2|3,d[22]=3,d[23]=128|Lt,d[24]=0,d[25]=1,d[26]=(65280&t.byteLength)>>8,d[27]=255&t.byteLength,d.set(t,28),d[23+(5+t.byteLength)+0]=128|Bt,d[23+(5+t.byteLength)+1]=0,d[23+(5+t.byteLength)+2]=1,d[23+(5+t.byteLength)+3]=(65280&s.byteLength)>>8,d[23+(5+t.byteLength)+4]=255&s.byteLength,d.set(s,23+(5+t.byteLength)+5),d[23+(5+t.byteLength+5+s.byteLength)+0]=128|Mt,d[23+(5+t.byteLength+5+s.byteLength)+1]=0,d[23+(5+t.byteLength+5+s.byteLength)+2]=1,d[23+(5+t.byteLength+5+s.byteLength)+3]=(65280&i.byteLength)>>8,d[23+(5+t.byteLength+5+s.byteLength)+4]=255&i.byteLength,d.set(i,23+(5+t.byteLength+5+s.byteLength)+5);const h=[28,0,0,0,0],c=new Uint8Array(h.length+d.byteLength);return c.set(h,0),c.set(d,h.length),c}function Ln(e,t){let i=[];i[0]=t?28:44,i[1]=1,i[2]=0,i[3]=0,i[4]=0;const s=new Uint8Array(i.length+e.byteLength);return s.set(i,0),s.set(e,i.length),s}function Pn(e){return(126&e[0])>>1}function Bn(e){return!function(e){return e>=32&&e<=40}(e)}function In(e){return e>=16&&e<=21}class Mn{constructor(e){this.data=e,this.eofFlag=!1,this.currentStartcodeOffset=this.findNextStartCodeOffset(0),this.eofFlag&&console.error("Could not find H265 startcode until payload end!")}findNextStartCodeOffset(e){let t=e,i=this.data;for(;;){if(t+3>=i.byteLength)return this.eofFlag=!0,i.byteLength;let e=i[t+0]<<24|i[t+1]<<16|i[t+2]<<8|i[t+3],s=i[t+0]<<16|i[t+1]<<8|i[t+2];if(1===e||1===s)return t;t++}}readNextNaluPayload(){let e=this.data,t=null;for(;null==t&&!this.eofFlag;){let i=this.currentStartcodeOffset;i+=1===(e[i]<<24|e[i+1]<<16|e[i+2]<<8|e[i+3])?4:3;let s=e[i]>>1&63,r=(128&e[i])>>>7,a=this.findNextStartCodeOffset(i);this.currentStartcodeOffset=a,0===r&&(t={type:s,data:e.subarray(i,a)})}return t}}class Un{constructor(e){let t=e.data.byteLength;this.type=e.type,this.data=new Uint8Array(4+t),new DataView(this.data.buffer).setUint32(0,t),this.data.set(e.data,4)}}class Fn extends po{constructor(e){super(),this.TAG_NAME="recorderCommon",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.audioCodeId=null,this.metaInfo={codecWidth:0,codecHeight:0,presentWidth:0,presentHeight:0,refSampleDuration:0,timescale:1e3,avcc:null,videoType:""},this.audioMetaInfo={timescale:1e3,sampleRate:0,refSampleDuration:0,channelCount:0,codec:"",originalCodec:"",audioType:"",extraData:new Uint8Array(0)}}destroy(){this._reset(),this.sps=null,this.pps=null,this.vps=null,this.codecId=null,this.audioCodeId=null,this.metaInfo=null,this.audioMetaInfo=null}get isH264(){return this.codecId===_t}get isH265(){return this.codecId===vt}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,s){}handleAddAudioTrack(e,t){}handleAddTrack(e){}stopRecordAndSave(){}startRecordingInterval(){}isWasmMp4(){return!1}stopRecordingInterval(){this.recordingInterval&&clearInterval(this.recordingInterval),this.recordingInterval=null}getToTalByteLength(){return 0}_reset(){this.fileName="",this._isRecording=!1,this._recordingTimestamp=0,this.stopRecordingInterval()}initMetaData(e,t){let i;const s=e.slice(5);if(this.codecId=t,this.metaInfo.avcc=s,t===_t)i=mn(s);else if(t===vt){i=function(e){let t=23;const i=e[t];if((63&i)!==Lt)return console.warn(`parseHEVCDecoderVPSAndSPSAndPPS and vpsTag is ${i}`),{};t+=2,t+=1;const s=e[t+1]|e[t]<<8;t+=2;const r=e.slice(t,t+s);t+=s;const a=e[t];if((63&a)!==Bt)return console.warn(`parseHEVCDecoderVPSAndSPSAndPPS and sps tag is ${a}`),{};t+=2,t+=1;const o=e[t+1]|e[t]<<8;t+=2;const n=e.slice(t,t+o);t+=o;const l=e[t];if((63&l)!==Mt)return console.warn(`parseHEVCDecoderVPSAndSPSAndPPS and pps tag is ${l}`),{};t+=2,t+=1;const d=e[t+1]|e[t]<<8;t+=2;const h=e.slice(t,t+d),c=new Uint8Array([o>>>24&255,o>>>16&255,o>>>8&255,255&o]),u=new Uint8Array([d>>>24&255,d>>>16&255,d>>>8&255,255&d]),p=new Uint8Array([s>>>24&255,s>>>16&255,s>>>8&255,255&s]),f=new Uint8Array(o+4);f.set(c,0),f.set(n,4);const m=new Uint8Array(d+4);m.set(u,0),m.set(h,4);const g=new Uint8Array(s+4);return g.set(p,0),g.set(r,4),{sps:f,pps:m,vps:g}}(s);const t=Cn(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))}initAudioMetaData(e,t){this.audioCodeId=t;const i=e[0]>>1&1;let s=null;t===Et.AAC?(s=function(e){let t={},i=new Or(e);return i.read(16),t.object_type=Nr(i),t.sample_rate=jr(i,t),t.chan_config=i.read(4),t.chan_config<Gr.length&&(t.channels=Gr[t.chan_config]),t.sbr=-1,t.ps=-1,5!=t.object_type&&29!=t.object_type||(29==t.object_type&&(t.ps=1),t.ext_object_type=5,t.sbr=1,t.sample_rate=jr(i,t),t.object_type=Nr(i)),{...t,channelCount:t.channels,sampleRate:t.sample_rate}}(e),s&&(s.channelCount&&(this.audioMetaInfo.channelCount=s.channelCount),s.codec&&(this.audioMetaInfo.codec=s.codec),s.originalCodec&&(this.audioMetaInfo.originalCodec=s.originalCodec),s.config&&(this.audioMetaInfo.config=s.config),s.sampleRate&&(this.audioMetaInfo.sampleRate=s.sampleRate),this.audioMetaInfo.sampleRate&&this.audioMetaInfo.timescale&&(this.audioMetaInfo.refSampleDuration=1024/this.audioMetaInfo.sampleRate*this.audioMetaInfo.timescale)),this.audioMetaInfo.depth=i?16:8,this.audioMetaInfo.extraData=e.slice(2)):this.audioMetaInfo.depth=0===i?8:16}initAudioAacExtraData(e){this.audioMetaInfo.extraData=new Uint8Array(e)}}class On extends Fn{constructor(e){super(e),this.totalByteLength=0,this._startRecordingTimestamp=null,e.debug.log("RecorderRTC","init")}destroy(){super.destroy(),this._reset(),this.player.debug.log("RecorderRTC","destroy")}_reset(){super._reset(),this.totalByteLength=0,this._startRecordingTimestamp=null,this.recorder&&(this.recorder.destroy(),this.recorder=null)}getSeekableBlob(e){const t=new EBML.Reader,i=new EBML.Decoder,s=EBML.tools,r=new FileReader;return new Promise(((a,o)=>{r.onload=function(e){i.decode(this.result).forEach((function(e){t.read(e)})),t.stop();const r=s.makeMetadataSeekable(t.metadatas,t.duration,t.cues),o=this.result.slice(t.metadataSize),n=new Blob([r,o],{type:"video/webm"});a(n)},r.readAsArrayBuffer(e)}))}startRecord(){const e=this.player.debug,t={type:"video",mimeType:"video/webm;codecs=h264",timeSlice:1e3,onTimeStamp:t=>{e.log("RecorderRTC","record timestamp :"+t),null===this._startRecordingTimestamp&&(this._startRecordingTimestamp=t),this._recordingTimestamp=(t-this._startRecordingTimestamp)/1e3},ondataavailable:t=>{this.totalByteLength+=t.size,e.log("RecorderRTC","ondataavailable",t.size)},disableLogs:!this.player._opt.debug};try{let i=null;if(this.player.getRenderType()===V?i=this.player.video.$videoElement.captureStream(25):this.player.video.mediaStream?i=this.player.video.mediaStream:this.player.isOldHls()||this.player._opt.useMSE||this.player._opt.useWCS?i=this.player.video.$videoElement.captureStream(25):this.player.isWebrtcH264()?i=this.player.webrtc.videoStream:this.player.isAliyunRtc()&&(i=this.player.video.$videoElement.captureStream(25)),!i)return e.error("RecorderRTC","startRecord error and can not create stream"),void this.player.emitError(nt.recordCreateError,"can not create stream");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 e=this.player.audio.mediaStreamAudioDestinationNode.stream;if(e.getAudioTracks().length>0){const t=e.getAudioTracks()[0];t&&t.enabled&&i.addTrack(t)}}this.recorder=un(i,t)}catch(t){return e.error("RecorderRTC","startRecord error",t),void this.player.emitError(nt.recordCreateError,t)}this.recorder&&(this._isRecording=!0,this.player.emit(nt.recording,!0),this.recorder.startRecording(),e.log("RecorderRTC","start recording"),this.player.emit(nt.recordStart),this.startRecordingInterval())}startRecordingInterval(){this.stopRecordingInterval(),this.recordingInterval=window.setInterval((()=>{this.player.emit(nt.recordingTimestamp,this._recordingTimestamp)}),1e3)}stopRecordAndSave(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:yt,t=arguments.length>1?arguments[1]:void 0;return new Promise(((i,s)=>{this.recorder&&this._isRecording||s("recorder is not ready"),t&&this.setFileName(t),this.recorder.stopRecording((()=>{this.player.debug.log("RecorderRTC","stop recording");const t=(this.fileName||Qr())+"."+w;if(this.recorder.getBlob(),e===At){const e=this.recorder.getBlob();i(e),this.player.emit(nt.recordBlob,e)}else i(),this.recorder.save(t);this.player.emit(nt.recordEnd),this._reset(),this.player.emit(nt.recording,!1)}))}))}getToTalByteLength(){return this.totalByteLength}getTotalDuration(){return this.recordTime}getType(){return w}initMetaData(){}}class Nn{static init(){Nn.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:[]};for(let e in Nn.types)Nn.types.hasOwnProperty(e)&&(Nn.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);let e=Nn.constants={};e.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]),e.STSD_PREFIX=new Uint8Array([0,0,0,0,0,0,0,1]),e.STTS=new Uint8Array([0,0,0,0,0,0,0,0]),e.STSC=e.STCO=e.STTS,e.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),e.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]),e.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]),e.DREF=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),e.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),e.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])}static box(e){let t=8,i=null,s=Array.prototype.slice.call(arguments,1),r=s.length;for(let e=0;e<r;e++)t+=s[e].byteLength;i=new Uint8Array(t),i[0]=t>>>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<r;e++)i.set(s[e],a),a+=s[e].byteLength;return i}static generateInitSegment(e,t,i){let s=Nn.box(Nn.types.ftyp,Nn.constants.FTYP),r=Nn.box(Nn.types.free),a=8,o=new Uint8Array;i+a>=Math.pow(2,32)-1?(a=16,o=new Uint8Array(i+a),o.set(new Uint8Array([0,0,0,1]),0),o.set(Nn.types.mdat,4),o.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)):(o=new Uint8Array(i+a),o[0]=i+8>>>24&255,o[1]=i+8>>>16&255,o[2]=i+8>>>8&255,o[3]=i+8&255,o.set(Nn.types.mdat,4));for(let e=0;e<t.length;e++){let i=t[e];i.duration=i.refSampleDuration*i.sequenceNumber;for(let e=0;e<i.sequenceNumber;e++){let t=i.samples[e];t.chunkOffset=s.byteLength+r.byteLength+a;let n=t.data;o.set(n,a),a+=n.byteLength}}let n=Nn.moov(e,t),l=new Uint8Array(s.byteLength+n.byteLength+o.byteLength+r.byteLength);return l.set(s,0),l.set(r,s.byteLength),l.set(o,s.byteLength+r.byteLength),l.set(n,s.byteLength+o.byteLength+r.byteLength),l}static moov(e,t){let i=e.timescale,s=e.duration,r=t.length,a=Nn.mvhd(i,s),o=new Uint8Array;for(let e=0;e<r;e++){let i=Nn.trak(t[e]),s=new Uint8Array(i.byteLength+o.byteLength);s.set(o,0),s.set(i,o.byteLength),o=new Uint8Array(s.byteLength),o.set(s,0)}return Nn.box(Nn.types.moov,a,o)}static mvhd(e,t){return Nn.box(Nn.types.mvhd,new Uint8Array([0,0,0,0,206,186,253,168,206,186,253,168,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 Nn.box(Nn.types.trak,Nn.tkhd(e),Nn.mdia(e))}static tkhd(e){let t=e.id,i=e.duration,s=e.presentWidth,r=e.presentHeight;return Nn.box(Nn.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,s>>>8&255,255&s,0,0,r>>>8&255,255&r,0,0]))}static edts(e,t){return Nn.box(Nn.types.edts,Nn.elst(e,t))}static elst(e,t){let i=0;for(let s=0;s<t;s++)"video"===e[s].type&&(i+=e[s].duration);let s=e[t].duration;return 0===i&&(i=e[t].refSampleDuration),Nn.box(Nn.types.elst,new Uint8Array([0,0,0,0,0,0,0,2,i>>>24&255,i>>>16&255,i>>>8&255,255&i,255,255,255,255,0,1,0,0,s>>>24&255,s>>>16&255,s>>>8&255,255&s,0,0,0,0,0,1,0,0]))}static mdia(e){return Nn.box(Nn.types.mdia,Nn.mdhd(e),Nn.hdlr(e),Nn.minf(e))}static mdhd(e){let t=e.timescale/e.refSampleDuration,i=t*e.duration/e.timescale;return Nn.box(Nn.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,i>>>24&255,i>>>16&255,i>>>8&255,255&i,85,196,0,0]))}static hdlr(e){let t=null;return t=Nn.constants.HDLR_VIDEO,Nn.box(Nn.types.hdlr,t)}static minf(e){let t=null;return t=Nn.box(Nn.types.vmhd,Nn.constants.VMHD),Nn.box(Nn.types.minf,t,Nn.dinf(),Nn.stbl(e))}static dinf(){return Nn.box(Nn.types.dinf,Nn.box(Nn.types.dref,Nn.constants.DREF))}static stbl(e){let t=e.samples,i=[{No:1,num:0,sampleDelte:1,chunkNo:1,duration:t[0].duration}],s=[t[0].duration],r=t.length;for(let e=0;e<r;e++)for(let r=0;r<i.length;r++)t[e].duration===i[r].duration?i[r].num++:s.indexOf(t[e].duration)<0&&(s.push(t[e].duration),i.push({No:2,num:0,sampleDelte:1,chunkNo:e+1,duration:t[e].duration}));return Nn.box(Nn.types.stbl,Nn.stsd(e),Nn.stts(i),Nn.stss(t),Nn.stsc(i),Nn.stsz(t),Nn.stco(i,t))}static stts(e){let t=e.length,i=new Uint8Array([0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t]),s=i.byteLength,r=new Uint8Array(s+8*t);r.set(i,0);for(let i=0;i<t;i++)r.set(new Uint8Array([e[i].num>>>24&255,e[i].num>>>16&255,e[i].num>>>8&255,255&e[i].num,e[i].sampleDelte>>>24&255,e[i].sampleDelte>>>16&255,e[i].sampleDelte>>>8&255,255&e[i].sampleDelte]),s),s+=8;return Nn.box(Nn.types.stts,r)}static stss(e){let t=[],i=e.length;for(let s=0;s<i;s++)!0===e[s].isKeyframe&&t.push(s+1);let s=t.length,r=new Uint8Array([0,0,0,0,s>>>24&255,s>>>16&255,s>>>8&255,255&s]),a=r.byteLength,o=new Uint8Array(a+4*s);o.set(r,0);for(let e=0;e<s;e++)o.set(new Uint8Array([t[e]>>>24&255,t[e]>>>16&255,t[e]>>>8&255,255&t[e]]),a),a+=4;return Nn.box(Nn.types.stss,o)}static stsc(e){let t=e.length,i=new Uint8Array([0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t]),s=i.byteLength,r=new Uint8Array(s+12*t);r.set(i,0);for(let i=0;i<t;i++){let t=e[i].chunkNo,a=e[i].num,o=e[i].sampleDelte;r.set(new Uint8Array([t>>>24&255,t>>>16&255,t>>>8&255,255&t,a>>>24&255,a>>>16&255,a>>>8&255,255&a,o>>>24&255,o>>>16&255,o>>>8&255,255&o]),s),s+=12}return Nn.box(Nn.types.stsc,r)}static stsz(e){let t=e.length,i=new Uint8Array([0,0,0,0,0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t]),s=i.byteLength,r=new Uint8Array(s+4*t);r.set(i,0);for(let i=0;i<t;i++){let t=e[i].data.byteLength;r.set(new Uint8Array([t>>>24&255,t>>>16&255,t>>>8&255,255&t]),s),s+=4}return Nn.box(Nn.types.stsz,r)}static stco(e,t){let i=t[0].chunkOffset;return Nn.box(Nn.types.stco,new Uint8Array([0,0,0,0,0,0,0,1,i>>>24&255,i>>>16&255,i>>>8&255,255&i]))}static stsd(e){return"audio"===e.type?"mp3"===e.codec?Nn.box(Nn.types.stsd,Nn.constants.STSD_PREFIX,Nn.mp3(e)):Nn.box(Nn.types.stsd,Nn.constants.STSD_PREFIX,Nn.mp4a(e)):"avc"===e.videoType?Nn.box(Nn.types.stsd,Nn.constants.STSD_PREFIX,Nn.avc1(e)):Nn.box(Nn.types.stsd,Nn.constants.STSD_PREFIX,Nn.hvc1(e))}static mp3(e){let t=e.channelCount,i=e.sampleRate,s=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 Nn.box(Nn.types[".mp3"],s)}static mp4a(e){let t=e.channelCount,i=e.sampleRate,s=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 Nn.box(Nn.types.mp4a,s,Nn.esds(e))}static esds(e){let t=e.config||[],i=t.length,s=new Uint8Array([0,0,0,0,3,23+i,0,1,0,4,15+i,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([i]).concat(t).concat([6,1,2]));return Nn.box(Nn.types.esds,s)}static avc1(e){let t=e.avcc,i=e.codecWidth,s=e.codecHeight,r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,i>>>8&255,255&i,s>>>8&255,255&s,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 Nn.box(Nn.types.avc1,r,Nn.box(Nn.types.avcC,t))}static hvc1(e){let t=e.avcc;const i=e.codecWidth,s=e.codecHeight;let r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,i>>>8&255,255&i,s>>>8&255,255&s,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 Nn.box(Nn.types.hvc1,r,Nn.box(Nn.types.hvcC,t))}static mvex(e){return Nn.box(Nn.types.mvex,Nn.trex(e))}static trex(e){let t=e.id,i=new Uint8Array([0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return Nn.box(Nn.types.trex,i)}static moof(e,t){return Nn.box(Nn.types.moof,Nn.mfhd(e.sequenceNumber),Nn.traf(e,t))}static mfhd(e){let t=new Uint8Array([0,0,0,0,e>>>24&255,e>>>16&255,e>>>8&255,255&e]);return Nn.box(Nn.types.mfhd,t)}static traf(e,t){let i=e.id,s=Nn.box(Nn.types.tfhd,new Uint8Array([0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i])),r=Nn.box(Nn.types.tfdt,new Uint8Array([0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t])),a=Nn.sdtp(e),o=Nn.trun(e,a.byteLength+16+16+8+16+8+8);return Nn.box(Nn.types.traf,s,r,o,a)}static sdtp(e){let t=e.samples||[],i=t.length,s=new Uint8Array(4+i);for(let e=0;e<i;e++){let i=t[e].flags;s[e+4]=i.isLeading<<6|i.dependsOn<<4|i.isDependedOn<<2|i.hasRedundancy}return Nn.box(Nn.types.sdtp,s)}static trun(e,t){let i=e.samples||[],s=i.length,r=12+16*s,a=new Uint8Array(r);t+=8+r,a.set([0,0,15,1,s>>>24&255,s>>>16&255,s>>>8&255,255&s,t>>>24&255,t>>>16&255,t>>>8&255,255&t],0);for(let e=0;e<s;e++){let t=i[e].duration,s=i[e].size,r=i[e].flags,o=i[e].cts;a.set([t>>>24&255,t>>>16&255,t>>>8&255,255&t,s>>>24&255,s>>>16&255,s>>>8&255,255&s,r.isLeading<<2|r.dependsOn,r.isDependedOn<<6|r.hasRedundancy<<4|r.isNonSync,0,0,o>>>24&255,o>>>16&255,o>>>8&255,255&o],12+16*e)}return Nn.box(Nn.types.trun,a)}static mdat(e){return Nn.box(Nn.types.mdat,e)}}Nn.init();class jn extends Fn{constructor(e){super(e),this.TAG_NAME="recorderMP4",this._reset(),e.debug.log(this.TAG_NAME,"init")}destroy(){super.destroy(),this._reset(),this.player.debug.log(this.TAG_NAME,"destroy")}_reset(){super._reset(),this.totalDuration=0,this.totalAudioDuration=0,this.totalByteLength=0,this.totalAudioByteLength=0,this.bufferList=[],this.audioBufferList=[],this.cacheTrack={},this.audioCacheTrack={},this.sequenceNumber=0,this.audioSequenceNumber=0}startRecord(){const e=this.player.debug;this._isRecording=!0,this.player.emit(nt.recording,!0),e.log(this.TAG_NAME,"start recording"),this.player.emit(nt.recordStart),this.startRecordingInterval()}startRecordingInterval(){this.stopRecordingInterval(),this.recordingInterval=window.setInterval((()=>{this.player.emit(nt.recordingTimestamp,this.getTotalDuration())}),1e3)}formatFmp4Track(e,t,i,s){return{id:1,sequenceNumber:++this.sequenceNumber,size:e.byteLength,dts:i,cts:s,isKeyframe:t,data:e,duration:0,flags:{isLeading:0,dependsOn:t?2:1,isDependedOn:t?1:0,hasRedundancy:0,isNonSync:t?0:1}}}formatAudioFmp4Track(e,t){return{id:2,sequenceNumber:++this.audioSequenceNumber,size:e.byteLength,dts:t,pts:t,cts:0,data:new Uint8Array(e),duration:0,originalDts:t,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}}}handleAddNaluTrack(e,t,i,s){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,s)}handleAddAudioTrack(e,t){}handleAddFmp4Track(e){if(!this.isRecording)return void this.player.debug.error(this.TAG_NAME,"handleAddFmp4Track, isRecording is false ");if((null===this.sps||null===this.pps)&&this.isH264)return void this.player.debug.error(this.TAG_NAME,"handleAddFmp4Track, is h264 and this.sps or this.pps is null ");if((null===this.sps||null===this.pps||null===this.vps)&&this.isH265)return void this.player.debug.error(this.TAG_NAME,"handleAddFmp4Track, is h265 and this.sps or this.pps or this.vps is null ");const t=Object.assign({},e);t.pts=t.dts+t.cts;const i=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);const s=new Uint8Array(e.byteLength+i.byteLength);s.set(e,0),s.set(i,e.byteLength),t.data=s}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);const s=new Uint8Array(e.byteLength+i.byteLength);s.set(e,0),s.set(i,e.byteLength),t.data=s}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)}handleAddFmp4AudioTrack(e){const t=Object.assign({},e);t.pts=t.dts+t.cts,t.size=t.data.byteLength,this.totalAudioDuration+=t.duration,this.totalAudioByteLength+=t.data.byteLength,t.duration=0,t.originalDts=t.dts,delete t.id,delete t.sequenceNumber,this.audioBufferList.push(t)}getTotalDuration(){return this.totalDuration/1e3}getType(){return S}getToTalByteLength(){return this.totalByteLength+this.totalAudioByteLength}stopRecordAndSave(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:yt,t=arguments.length>1?arguments[1]:void 0;return new Promise(((i,s)=>{if(!this.isRecording)return this.player.debug.error(this.TAG_NAME,"stop recording fail, isRecording is false "),s("stop recording fail, isRecording is false ");if(0===this.bufferList.length)return this.player.debug.error(this.TAG_NAME,"stop recording fail, this.bufferList.length is 0 "),s("stop recording fail, this.bufferList.length is 0 ");t&&this.setFileName(t);const 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},a={id:2,type:"audio",sequenceNumber:this.audioBufferList.length,samples:this.audioBufferList,...this.audioMetaInfo},o=[r];a.samples.length>0&&o.push(a),this.player.debug.log(this.TAG_NAME,`trackList length is ${o.length}`);const n=Nn.generateInitSegment({timescale:1e3,duration:this.totalDuration},o,this.totalByteLength+this.totalAudioByteLength);this.player.debug.log(this.TAG_NAME,"stop recording");const l=new Blob([n],{type:"application/octet-stream"});if(e===At)i(l),this.player.emit(nt.recordBlob,l);else{i();Sa((this.fileName||Qr())+"."+S,l)}this._reset(),this.player.emit(nt.recording,!1)}))}}class zn extends Fn{constructor(e){super(e),this.TAG_NAME="FlvRecorderLoader",this.player=e,this._init(),this.player.debug.log(this.TAG_NAME,"init")}destroy(){super.destroy(),this._init(),this.player.debug.log(this.TAG_NAME,"destroy")}_init(){this.hasAudio=!1,this.hasVideo=!1,this.startTime=null,this.currentTime=0,this.prevTimestamp=0,this.totalByteLength=0,this.totalDuration=0,this.flvMetaData=null,this.aacSequenceHeader=null,this.videoSequenceHeader=null,this.bufferList=[]}_reset(){super._reset(),this._init()}startRecord(){const e=this.player.debug;this._isRecording=!0,this.player.emit(nt.recording,!0),e.log(this.TAG_NAME,"start recording"),this.player.emit(nt.recordStart),this.startRecordingInterval()}startRecordingInterval(){this.stopRecordingInterval(),this.recordingInterval=window.setInterval((()=>{this.player.emit(nt.recordingTimestamp,this.getTotalDuration())}),1e3)}addMetaData(e){this.flvMetaData=e}addAACSequenceHeader(e){this.aacSequenceHeader=e}addVideoSequenceHeader(e){this.videoSequenceHeader=e}addVideo(e,t){this._setStartTime(t);const i=this._getBufferTs(t);this.hasVideo=!0,this._createBufferItem(e,Ge,i)}addAudio(e,t){this._setStartTime(t);const i=this._getBufferTs(t);this.hasAudio=!0,this._createBufferItem(e,ze,i)}_setStartTime(e){null===this.startTime&&this._isRecording&&(this.startTime=e,this.player.debug.log(this.TAG_NAME,`_setStartTime is ${e}`))}_getBufferTs(e){e>this.currentTime&&(this.currentTime=e);let t=0;return this.startTime&&e>=this.startTime&&(t=e-this.startTime),t>this.prevTimestamp?this.prevTimestamp=t:t=this.prevTimestamp,t}_createBufferItem(e,t,i){const s=this._createFlvPacket(e,t,i),r=this._createFlvTag(s);this.totalByteLength+=r.byteLength,this.bufferList.push(r)}_createFlvTag(e){let t=11+e.header.length,i=new Uint8Array(t+4);i[0]=e.header.type;let s=new DataView(i.buffer);return i[1]=e.header.length>>16&255,i[2]=e.header.length>>8&255,i[3]=255&e.header.length,i[4]=e.header.timestamp>>16&255,i[5]=e.header.timestamp>>8&255,i[6]=255&e.header.timestamp,i[7]=e.header.timestamp>>24&255,i[8]=0,i[9]=0,i[10]=0,s.setUint32(t,t),i.set(e.payload.subarray(0,e.header.length),11),i}_createFlvPacket(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return{header:{length:e?e.length:0,timestamp:i,type:t},payload:e}}stopRecordAndSave(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:yt,t=arguments.length>1?arguments[1]:void 0;return new Promise(((i,s)=>{if(!this.isRecording)return this.player.debug.error(this.TAG_NAME,"stop recording fail, isRecording is false "),s("stop recording fail, isRecording is false ");if(0===this.bufferList.length)return this.player.debug.error(this.TAG_NAME,"stop recording fail, this.bufferList.length is 0 "),s("stop recording fail, this.bufferList.length is 0 ");t&&this.setFileName(t);const r=new Uint8Array([70,76,86,1,0,0,0,0,9,0,0,0,0]);this.hasVideo&&(r[4]|=1),this.hasAudio&&(r[4]|=4);let a=[r];if(this.flvMetaData){const e=this._createFlvPacket(this.flvMetaData,He),t=this._createFlvTag(e);a.push(t)}if(this.videoSequenceHeader){const e=this._createFlvPacket(this.videoSequenceHeader,Ge),t=this._createFlvTag(e);a.push(t)}if(this.aacSequenceHeader){const e=this._createFlvPacket(this.aacSequenceHeader,ze),t=this._createFlvTag(e);a.push(t)}const o=function(e){const t=e[0].constructor;return e.reduce(((e,i)=>{const s=new t((0|e.byteLength)+(0|i.byteLength));return s.set(e,0),s.set(i,0|e.byteLength),s}),new t)}(a.concat(this.bufferList));this.player.debug.log(this.TAG_NAME,"stop recording");const n=new Blob([o],{type:"application/octet-stream"});if(e===At)i(n),this.player.emit(nt.recordBlob,n);else{i();Sa((this.fileName||Qr())+"."+E,n)}this._reset(),this.player.emit(nt.recording,!1)}))}getTotalDuration(){let e=0;return null!==this.startTime&&null!==this.currentTime&&(e=this.currentTime-this.startTime),Math.round(e/1e3)}getType(){return E}getToTalByteLength(){return this.totalByteLength}}const Gn={init:0,findFirstStartCode:1,findSecondStartCode:2};class Hn extends po{constructor(e){super(),this.player=e,this.isDestroyed=!1,this.reset()}destroy(){this.isDestroyed=!1,this.off(),this.reset()}reset(){this.stats=Gn.init,this.tempBuffer=new Uint8Array(0),this.parsedOffset=0,this.versionLayer=0}dispatch(e,t){let i=new Uint8Array(this.tempBuffer.length+e.length);for(i.set(this.tempBuffer,0),i.set(e,this.tempBuffer.length),this.tempBuffer=i;!this.isDestroyed;){if(this.state==Gn.Init){let e=!1;for(;this.tempBuffer.length-this.parsedOffset>=2&&!this.isDestroyed;)if(255==this.tempBuffer[this.parsedOffset]){if(!(!1&this.tempBuffer[this.parsedOffset+1])){this.versionLayer=this.tempBuffer[this.parsedOffset+1],this.state=Gn.findFirstStartCode,this.fisrtStartCodeOffset=this.parsedOffset,this.parsedOffset+=2,e=!0;break}this.parsedOffset++}else this.parsedOffset++;if(e)continue;break}if(this.state==Gn.findFirstStartCode){let e=!1;for(;this.tempBuffer.length-this.parsedOffset>=2&&!this.isDestroyed;)if(255==this.tempBuffer[this.parsedOffset]){if(this.tempBuffer[this.parsedOffset+1]==this.versionLayer){this.state=Gn.findSecondStartCode,this.secondStartCodeOffset=this.parsedOffset,this.parsedOffset+=2,e=!0;break}this.parsedOffset++}else this.parsedOffset++;if(e)continue;break}if(this.state==Gn.findSecondStartCode){let e=this.tempBuffer.slice(this.fisrtStartCodeOffset,this.secondStartCodeOffset);this.emit("data",e,t),this.tempBuffer=this.tempBuffer.slice(this.secondStartCodeOffset),this.fisrtStartCodeOffset=0,this.parsedOffset=2,this.state=Gn.findFirstStartCode}}}}class $n extends Fn{constructor(e){super(e),this.TAG_NAME="recorderWasmMP4",this._reset(),this.wasmMp4Recorder=new window.JessibucaProMp4Recorder({debug:e._opt.debug,debugLevel:e._opt.debugLevel,debugUuid:e._opt.debugUuid,decoder:e._opt.wasmMp4RecorderDecoder}),this.wasmMp4Recorder.on("recordingTimestamp",(e=>{this._recordingTimestamp=e/1e3})),this.mp3Demuxer=null,e.debug.log(this.TAG_NAME,"init")}destroy(){super.destroy(),this.mp3Demuxer&&(this.mp3Demuxer.destroy(),this.mp3Demuxer=null),this._reset(),this.player.debug.log(this.TAG_NAME,"destroy")}_reset(){super._reset(),this.cacheTrack={},this.audioCacheTrack={},this.totalDuration=0,this.totalAudioDuration=0,this.totalByteLength=0,this.totalAudioByteLength=0,this.hasAudio=!1,this.hasVideo=!1}getType(){return S}isWasmMp4(){return!0}getTotalDuration(){return this.totalDuration/1e3}getToTalByteLength(){return this.totalByteLength+this.totalAudioByteLength}startRecord(){const e=this.player.debug,t=this.player.getAudioInfo(),i=this.player.getVideoInfo(),s={};if(this.codecId){const e={type:this.codecId,width:i.width,height:i.height,extraData:this.metaInfo.avcc};s.video=e,this.hasVideo=!0}if(t.encTypeCode){const e={type:t.encTypeCode,sampleRate:t.sampleRate,channels:t.channels,extraData:this.audioMetaInfo.extraData,depth:t.depth};this.audioCodeId=t.encTypeCode,s.audio=e,this.hasAudio=!0}this.wasmMp4Recorder.startRecord(s).then((()=>{this._isRecording=!0,this.player.emit(nt.recording,!0),e.log(this.TAG_NAME,"start recording"),this.player.emit(nt.recordStart),this.startRecordingInterval()})).catch((t=>{e.error(this.TAG_NAME,"startRecord error",t),this.player.emitError(nt.recordCreateError,t)}))}startRecordingInterval(){this.stopRecordingInterval(),this.recordingInterval=window.setInterval((()=>{this.player.emit(nt.recordingTimestamp,this.recordTime)}),1e3)}stopRecordAndSave(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:yt,t=arguments.length>1?arguments[1]:void 0;return new Promise(((i,s)=>this.isRecording?0===this.totalDuration?(this.player.debug.error(this.TAG_NAME,"stop recording fail, totalDuration is 0 "),s("stop recording fail, totalDuration is 0 ")):(t&&this.setFileName(t),void this.wasmMp4Recorder.stopRecord().then((t=>{if(e===At)i(t),this.player.emit(nt.recordBlob,t);else{i();Sa((this.fileName||Qr())+"."+S,t)}})).catch((e=>{this.player.debug.error(this.TAG_NAME,"stopRecord error",e),s(e)})).finally((()=>{this._reset(),this.player.emit(nt.recording,!1)}))):(this.player.debug.error(this.TAG_NAME,"stop recording fail, isRecording is false "),s("stop recording fail, isRecording is false "))))}handleAddAudioTrack(e,t){this.audioCodeId===Et.MP3?(this.mp3Demuxer||(this.mp3Demuxer=new Hn(this.player),this.mp3Demuxer.on("data",((e,t)=>{this._handleAddAudioTrack(e,t)}))),this.mp3Demuxer.dispatch(e,t)):this._handleAddAudioTrack(e,t)}_handleAddAudioTrack(e,t){ro(this.hasAudio)||(this.audioCacheTrack.id&&t>=this.audioCacheTrack.dts?(this.audioCacheTrack.duration=t-this.audioCacheTrack.dts,this.totalAudioDuration+=this.audioCacheTrack.duration,this.totalAudioByteLength+=this.audioCacheTrack.payload.byteLength,this.wasmMp4Recorder.sendAudioFrame(this.audioCacheTrack.payload,this.audioCacheTrack.dts)):this.audioCacheTrack={},this.audioCacheTrack={id:2,payload:e,dts:t})}handleAddNaluTrack(e,t,i,s){ro(this.hasVideo)||(this.cacheTrack.id&&i>=this.cacheTrack.dts?(this.cacheTrack.duration=i-this.cacheTrack.dts,this.totalDuration+=this.cacheTrack.duration,this.totalByteLength+=this.cacheTrack.payload.byteLength,this.wasmMp4Recorder.sendVideoFrame(this.cacheTrack.payload,this.cacheTrack.isIFrame,this.cacheTrack.dts,this.cacheTrack.cts)):this.cacheTrack={},this.cacheTrack={id:1,payload:e,isIFrame:t,dts:i,cts:s})}}class Vn{constructor(e){return new(Vn.getLoaderFactory(e._opt))(e)}static getLoaderFactory(e){if(e.recordType===S){if(e.useWasm||e.useMSE||e.useWCS)return window.JessibucaProMp4Recorder&&e.mp4RecordUseWasm?$n:jn}else if(e.recordType===E)return zn;return On}}function Wn(e,t,i){let s=e;if(t+i<s.length){for(;i--;)if(128!=(192&s[++t]))return!1;return!0}return!1}function Jn(e){let t=[],i=e,s=0,r=e.length;for(;s<r;)if(i[s]<128)t.push(String.fromCharCode(i[s])),++s;else{if(i[s]<192);else if(i[s]<224){if(Wn(i,s,1)){let e=(31&i[s])<<6|63&i[s+1];if(e>=128){t.push(String.fromCharCode(65535&e)),s+=2;continue}}}else if(i[s]<240){if(Wn(i,s,2)){let e=(15&i[s])<<12|(63&i[s+1])<<6|63&i[s+2];if(e>=2048&&55296!=(63488&e)){t.push(String.fromCharCode(65535&e)),s+=3;continue}}}else if(i[s]<248&&Wn(i,s,3)){let e=(7&i[s])<<18|(63&i[s+1])<<12|(63&i[s+2])<<6|63&i[s+3];if(e>65536&&e<1114112){e-=65536,t.push(String.fromCharCode(e>>>10|55296)),t.push(String.fromCharCode(1023&e|56320)),s+=4;continue}}t.push(String.fromCharCode(65533)),++s}return t.join("")}let qn=function(){let e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),256===new Int16Array(e)[0]}();class Kn{static parseScriptData(e,t,i){let s={};try{let r=Kn.parseValue(e,t,i),a=Kn.parseValue(e,t+r.size,i-r.size);s[r.data]=a.data}catch(e){console.error("AMF",e.toString())}return s}static parseObject(e,t,i){let s=Kn.parseString(e,t,i),r=Kn.parseValue(e,t+s.size,i-s.size),a=r.objectEnd;return{data:{name:s.data,value:r.data},size:s.size+r.size,objectEnd:a}}static parseVariable(e,t,i){return Kn.parseObject(e,t,i)}static parseString(e,t,i){let s,r=new DataView(e,t,i).getUint16(0,!qn);return s=r>0?Jn(new Uint8Array(e,t+2,r)):"",{data:s,size:2+r}}static parseLongString(e,t,i){let s,r=new DataView(e,t,i).getUint32(0,!qn);return s=r>0?Jn(new Uint8Array(e,t+4,r)):"",{data:s,size:4+r}}static parseDate(e,t,i){let s=new DataView(e,t,i),r=s.getFloat64(0,!qn);return r+=60*s.getInt16(8,!qn)*1e3,{data:new Date(r),size:10}}static parseValue(e,t,i){let s,r=new DataView(e,t,i),a=1,o=r.getUint8(0),n=!1;try{switch(o){case 0:s=r.getFloat64(1,!qn),a+=8;break;case 1:s=!!r.getUint8(1),a+=1;break;case 2:{let r=Kn.parseString(e,t+1,i-1);s=r.data,a+=r.size;break}case 3:{s={};let o=0;for(9==(16777215&r.getUint32(i-4,!qn))&&(o=3);a<i-4;){let r=Kn.parseObject(e,t+a,i-a-o);if(r.objectEnd)break;s[r.data.name]=r.data.value,a+=r.size}if(a<=i-3){9===(16777215&r.getUint32(a-1,!qn))&&(a+=3)}break}case 8:{s={},a+=4;let o=0;for(9==(16777215&r.getUint32(i-4,!qn))&&(o=3);a<i-8;){let r=Kn.parseVariable(e,t+a,i-a-o);if(r.objectEnd)break;s[r.data.name]=r.data.value,a+=r.size}if(a<=i-3){9===(16777215&r.getUint32(a-1,!qn))&&(a+=3)}break}case 9:s=void 0,a=1,n=!0;break;case 10:{s=[];let o=r.getUint32(1,!qn);a+=4;for(let r=0;r<o;r++){let r=Kn.parseValue(e,t+a,i-a);s.push(r.data),a+=r.size}break}case 11:{let r=Kn.parseDate(e,t+1,i-1);s=r.data,a+=r.size;break}case 12:{let r=Kn.parseString(e,t+1,i-1);s=r.data,a+=r.size;break}default:a=i,console.warn("AMF","Unsupported AMF value type "+o)}}catch(e){console.error("AMF",e.toString())}return{data:s,size:a,objectEnd:n}}}function Yn(e){return Kn.parseScriptData(e.buffer,e.byteOffset,e.byteLength)}class Qn{constructor(e){this.player=e,this.destroyResolve=null,this.workerClearTimeout=null,this.workerUrl=null;let t=e._opt.decoder;if(this.decoderWorkerCloseTimeout=null,ro(this.player._opt.useWasm)&&(t=this.player._opt.demuxUseWorker?this.player._opt.mseDecodeAudio||ro(this.player._opt.hasAudio)?e._opt.decoderHardNotWasm:e._opt.decoderHard:e._opt.decoderAudio),0===t.indexOf("http")&&this.player._opt.isDecoderUseCDN){const e=new Blob([`importScripts("${t}")`],{type:"application/javascript"});t=window.URL.createObjectURL(e),this.workerUrl=t,this.workerClearTimeout=setTimeout((()=>{window.URL.revokeObjectURL(this.workerUrl),this.workerUrl=null,this.workerClearTimeout=null}),te)}this.decoderWorker=new Worker(t),this._initDecoderWorker(),e.debug.log("decoderWorker",`init and decoder url is ${t}`),e.on(nt.visibilityChange,(()=>{this.updateWorkConfig({key:"visibility",value:e.visibility})}))}destroy(){return new Promise(((e,t)=>{if(this.player.loaded)if(this.player.debug.log("decoderWorker","has loaded and post message to destroy"),this.decoderWorker){const t={};this.player.isMseDecoderUseWorker()&&(t.isVideoInited=this.player.isMseVideoStateInited()),this.decoderWorker.postMessage({cmd:qe,options:t}),this.destroyResolve=e,this.decoderWorkerCloseTimeout=setTimeout((()=>{this.player.debug.warn("decoderWorker","send close but not response and destroy directly"),this.decoderWorkerCloseTimeout&&(clearTimeout(this.decoderWorkerCloseTimeout),this.decoderWorkerCloseTimeout=null),this._destroy(),setTimeout((()=>{e()}),0)}),2e3)}else this.player.debug.warn("decoderWorker","has loaded but decoderWorker is null and destroy directly"),this._destroy(),setTimeout((()=>{e()}),0);else this.player.debug.log("decoderWorker","has not loaded and destroy directly"),this._destroy(),setTimeout((()=>{e()}),0)}))}_destroy(){this.decoderWorkerCloseTimeout&&(clearTimeout(this.decoderWorkerCloseTimeout),this.decoderWorkerCloseTimeout=null),this.workerUrl&&(window.URL.revokeObjectURL(this.workerUrl),this.workerUrl=null),this.workerClearTimeout&&(clearTimeout(this.workerClearTimeout),this.workerClearTimeout=null),this.decoderWorker&&(this.decoderWorker.terminate(),this.decoderWorker.onerror=null,this.decoderWorker.onmessageerror=null,this.decoderWorker.onmessage=null,this.decoderWorker=null),this.player.debug.log("decoderWorker","destroy"),this.destroyResolve&&(this.destroyResolve(),this.destroyResolve=null)}_initDecoderWorker(){const{debug:e,events:{proxy:t}}=this.player;this.decoderWorker.onerror=e=>{this.player.debug.error("decoderWorker","onerror",e),this.player.emitError(ct.decoderWorkerInitError,e)},this.decoderWorker.onmessageerror=e=>{this.player.debug.error("decoderWorker","onmessageerror",e)},this.decoderWorker.onmessage=t=>{const i=t.data;switch(i.cmd){case re:e.log("decoderWorker","onmessage:",re),this.decoderWorker&&this._initWork(),this.player.loaded||this.player.emit(nt.load),this.player.emit(nt.decoderWorkerInit);break;case ue:e.log("decoderWorker","onmessage:",ue,i.code),this.player._times.decodeStart||(this.player._times.decodeStart=Qr()),this.player.video.updateVideoInfo({encTypeCode:i.code});break;case pe:e.log("decoderWorker","onmessage:",pe,i.codecId),this.player.recorder&&this.player.recorder.initMetaData(i.buffer,i.codecId),this.player.video.updateVideoInfo({encTypeCode:i.codecId});break;case de:e.log("decoderWorker","onmessage:",de,i.code),this.player.audio&&this.player.audio.updateAudioInfo({encTypeCode:i.code});break;case ce:e.log("decoderWorker","onmessage:",ce),this.player.recorder&&this.player.recorder.initAudioAacExtraData(i.buffer);break;case ae:if(e.log("decoderWorker","onmessage:",ae,`width:${i.w},height:${i.h}`),wa(i.w)||wa(i.h))return void this.player.emitError(ct.videoInfoError,`video width ${i.w} or height ${i.h} is empty`);if(this.player.video.updateVideoInfo({width:i.w,height:i.h}),!this.player._opt.openWebglAlignment&&i.w/2%4!=0&&this.player.getRenderType()===V)return void this.player.emitError(ct.webglAlignmentError);this.player.video.initCanvasViewSize(),this.player._opt.playType===v&&(this.player.video.initFps(),this.player.video.initVideoDelay());break;case le:if(e.log("decoderWorker","onmessage:",le,`channels:${i.channels},sampleRate:${i.sampleRate}`),i.channels>2)return void this.player.emitError(ct.audioChannelError,`audio channel is ${i.channels}, max is 2`);this.player.audio&&(this.player.audio.updateAudioInfo(i),this.player._opt.playType===b?this.player.audio.initScriptNode():this.player._opt.playType===v&&this.player.audio.initScriptNodeDelay());break;case oe:if(!this.player.video)return void e.warn("decoderWorker","onmessage render but video is null");if(this.player.isPlayer()){if(ro(this.player.video.getHasInit()))return void e.warn("decoderWorker","onmessage render but video has not init");this.player.video.render(i),this.player.handleRender(),this.player.emit(nt.timeUpdate,i.ts),this.player.updateStats({dfps:!0,buf:i.delay}),this.player._times.videoStart||(this.player._times.videoStart=Qr(),this.player.handlePlayToRenderTimes())}else this.player.isPlayback()&&(this.player.updateStats({dfps:!0}),ro(this.player.playbackPause)?(this.player.playback.isUseLocalCalculateTime&&this.player.playback.increaseLocalTimestamp(),this.player.playback.isUseFpsRender?this.player.video.pushData(i):this.player.video.render$2(i)):!this.player.playback.isPlaybackPauseClearCache&&this.player.playback.isCacheBeforeDecodeForFpsRender&&this.player.playback.isUseFpsRender&&this.player.video.pushData(i));break;case fe:this.player.recorder&&this.player.recorder.isRecording&&this.player._opt.recordType===S&&this.player.recorder.handleAddNaluTrack(i.buffer,i.isIFrame,i.ts,i.cts);break;case he:this.player.recorder&&this.player.recorder.isRecording&&this.player._opt.recordType===S&&this.player.recorder.isWasmMp4()&&this.player.recorder.handleAddAudioTrack(i.buffer,i.ts);break;case me:const{webcodecsDecoder:t,mseDecoder:s}=this.player;this.player.updateStats({buf:i.delay});const r=new Uint8Array(i.payload);this.player._opt.useWCS&&!this.player._opt.useOffscreen?t.decodeVideo(r,i.ts,i.isIFrame,i.cts):this.player._opt.useMSE&&s.decodeVideo(r,i.ts,i.isIFrame,i.cts);break;case ge:if(this.player._opt.useMSE){const e=new Uint8Array(i.payload);this.player.mseDecoder.decodeAudio(e,i.ts,i.cts)}break;case ne:if(!this.player.audio)return void e.warn("decoderWorker","onmessage playAudio but audio is null");(this.player.playing&&this.player.audio||!this.player.video)&&(this.player._opt.hasVideo||this.player.handleRender(),(this.player._opt.playType===b||this.player._opt.playType===v&&(ro(this.player.playbackPause)||!this.player.playback.isPlaybackPauseClearCache&&this.player.playback.isCacheBeforeDecodeForFpsRender&&this.player.playback.isUseFpsRender))&&this.player.audio.play(i.buffer,i.ts));break;case Ae:if(i.type===nt.streamSuccess)this.player.stream?this.player.stream.emit(nt.streamSuccess):e.warn("decoderWorker","onmessage and workerFetch response stream success but stream is null");else if(i.type===nt.streamRate)this.player.emit(nt.kBps,(i.value/1024).toFixed(2));else if(i.type===nt.streamEnd)this.player?(i.value===f&&this.player.emit(nt.websocketClose,i.msg),this.player.stream?this.player.stream.emit(nt.streamEnd,i.msg):e&&e.warn("decoderWorker","onmessage and workerFetch response stream end but player.stream is null")):e&&e.warn("decoderWorker","onmessage and workerFetch response stream end but player is null");else if(i.type===ct.websocketError)this.player&&this.player.stream?this.player.stream.emit(ct.websocketError,i.value):e&&e.warn("decoderWorker","onmessage and workerFetch response websocket error but stream is null");else if(i.type===ct.fetchError)this.player&&this.player.stream?this.player.stream.emit(ct.fetchError,i.value):e&&e.warn("decoderWorker","onmessage and workerFetch response fetch error but stream is null");else if(i.type===nt.streamAbps)this.player.updateStats({abps:i.value});else if(i.type===nt.streamVbps)this.player._times.demuxStart||(this.player._times.demuxStart=Qr()),this.player.updateStats({vbps:i.value});else if(i.type===nt.streamDts)this.player.updateStats({dts:i.value});else if(i.type===nt.netBuf)this.player.updateStats({netBuf:i.value});else if(i.type===nt.networkDelayTimeout)this.player.emit(nt.networkDelayTimeout,i.value);else if(i.type===nt.streamStats){const e=JSON.parse(i.value);this.player.updateStats({workerStats:e})}else i.type===nt.websocketOpen&&this.player.emit(nt.websocketOpen);break;case be:this.player&&(this.player.videoIframeIntervalTs=i.value);break;case _e:this.player&&this.player.updateStats({isDropping:!0});break;case Ie:this.player.decoderCheckFirstIFrame();break;case Se:this.player&&this.player.video&&this.player.video.setStreamFps(i.value);break;case ye:i.message&&-1!==i.message.indexOf(Oe)&&this.player.emitError(ct.wasmDecodeError,"");break;case we:this.player.emitError(ct.wasmDecodeVideoNoResponseError);break;case ke:this.player.emitError(ct.simdH264DecodeVideoWidthIsTooLarge);break;case Ee:this.player.emitError(ct.wasmWidthOrHeightChange);break;case Te:this.player.emitError(ct.simdDecodeError);break;case ve:e.log("decoderWorker","onmessage:",ve);break;case Ce:e.log("decoderWorker","onmessage:",Ce),this._destroy();break;case Re:this.player&&this.player.pushTempStream(i.buffer);break;case xe:this.player&&this.player.emit(nt.videoSEI,{ts:i.ts,data:new Uint8Array(i.buffer)});break;case De:if(this.player){if(this.player.isRecordTypeFlv()){const e=new Uint8Array(i.buffer);this.player.recorder.addMetaData(e)}const e=Yn(new Uint8Array(i.buffer));e&&e.onMetaData&&this.player.updateMetaData(e.onMetaData)}break;case Le:if(this.player&&this.player.isRecordTypeFlv()){const e=new Uint8Array(i.buffer);this.player.recorder.addAACSequenceHeader(e,i.ts)}break;case Pe:if(this.player&&this.player.isRecordTypeFlv()){const e=new Uint8Array(i.buffer);this.player.recorder.addVideoSequenceHeader(e,i.ts)}break;case Be:if(this.player&&this.player.isRecordTypeFlv()&&this.player.recording){const e=new Uint8Array(i.buffer);i.type===je?this.player.recorder.addVideo(e,i.ts):i.type===Ne&&this.player.recorder.addAudio(e,i.ts)}break;case Me:this.player&&(this.player.debug.log("decoderWorker","onmessage:",Me),this.player.video.$videoElement.srcObject=i.mseHandle);break;case Ue:this.player&&(this.player.debug.log("decoderWorker","onmessage:",Ue,i.value),this.player._mseWorkerData.firstRenderTime=Number(i.value));break;case Fe:this.player&&(this.player.debug.log("decoderWorker","onmessage:",Fe,i.value,i.msg),this.player.emitError(i.value,i.msg));break;default:this.player[i.cmd]&&this.player[i.cmd](i)}}}_initWork(){const e={debug:this.player._opt.debug,debugLevel:this.player._opt.debugLevel,debugUuid:this.player._opt.debugUuid,useOffscreen:this.player._opt.useOffscreen,useWCS:this.player._opt.useWCS,useMSE:this.player._opt.useMSE,videoBuffer:this.player._opt.videoBuffer,videoBufferDelay:this.player._opt.videoBufferDelay,openWebglAlignment:this.player._opt.openWebglAlignment,playType:this.player._opt.playType,hasAudio:this.player._opt.hasAudio,hasVideo:this.player._opt.hasVideo,playbackRate:1,playbackForwardMaxRateDecodeIFrame:this.player._opt.playbackForwardMaxRateDecodeIFrame,playbackIsCacheBeforeDecodeForFpsRender:this.player._opt.playbackConfig.isCacheBeforeDecodeForFpsRender,sampleRate:this.player.audio&&this.player.audio.audioContext&&this.player.audio.audioContext.sampleRate||0,audioBufferSize:this.player.audio&&this.player.audio.getAudioBufferSize()||1024,networkDelay:this.player._opt.networkDelay,visibility:this.player.visibility,useSIMD:this.player._opt.useSIMD,recordType:this.player._opt.recordType,checkFirstIFrame:this.player._opt.checkFirstIFrame,isM7sCrypto:this.player._opt.isM7sCrypto,isXorCrypto:this.player._opt.isXorCrypto,isSm4Crypto:this.player._opt.isSm4Crypto,sm4CryptoKey:this.player._opt.sm4CryptoKey,m7sCryptoAudio:this.player._opt.m7sCryptoAudio,isFlv:this.player._opt.isFlv,isFmp4:this.player._opt.isFmp4,isMpeg4:this.player._opt.isMpeg4,isTs:this.player._opt.isTs,isNakedFlow:this.player._opt.isNakedFlow,isHls265:this.player.isUseHls265(),isFmp4Private:this.player._opt.isFmp4Private,isEmitSEI:this.player._opt.isEmitSEI,isRecordTypeFlv:this.player.isRecordTypeFlv(),isWasmMp4:this.player.recorder&&this.player.recorder.isWasmMp4()||!1,isChrome:Na(),isDropSameTimestampGop:this.player._opt.isDropSameTimestampGop,mseDecodeAudio:this.player._opt.mseDecodeAudio,nakedFlowH265DemuxUseNew:this.player._opt.nakedFlowH265DemuxUseNew,mseDecoderUseWorker:this.player._opt.mseDecoderUseWorker,mseAutoCleanupMinBackwardDuration:this.player._opt.mseAutoCleanupMinBackwardDuration,mseAutoCleanupMaxBackwardDuration:this.player._opt.mseAutoCleanupMaxBackwardDuration,mseCorrectTimeDuration:this.player._opt.mseCorrectTimeDuration,mseCorrectAudioTimeDuration:this.player._opt.mseCorrectAudioTimeDuration};this.decoderWorker.postMessage({cmd:$e,opt:JSON.stringify(e)}),this.player._opt.isM7sCrypto&&(this.updateWorkConfig({key:"cryptoKey",value:this.player._opt.cryptoKey}),this.updateWorkConfig({key:"cryptoIV",value:this.player._opt.cryptoIV}))}decodeVideo(e,t,i){this.player._opt.playType===b?this.player.isUseHls265()?this._decodeVideoNoDelay(e,t,i):this._decodeVideo(e,t,i):this.player._opt.playType===v&&(this.player.video.rate>=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){const s={type:je,ts:Math.max(t,0),isIFrame:i};this.decoderWorker.postMessage({cmd:Ve,buffer:e,options:s},[e.buffer])}_decodeVideoNoDelay(e,t,i){this.decoderWorker.postMessage({cmd:Je,buffer:e,ts:Math.max(t,0),isIFrame:i},[e.buffer])}decodeAudio(e,t){this.player._opt.playType===b?this.player._opt.useWCS||this.player._opt.useMSE||this.player.isUseHls265()?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){const i={type:Ne,ts:Math.max(t,0)};this.decoderWorker.postMessage({cmd:Ve,buffer:e,options:i},[e.buffer])}_decodeAudioNoDelay(e,t){this.decoderWorker.postMessage({cmd:We,buffer:e,ts:Math.max(t,0)},[e.buffer])}updateWorkConfig(e){this.decoderWorker&&this.decoderWorker.postMessage({cmd:Ke,key:e.key,value:e.value})}workerFetchStream(e){const{_opt:t}=this.player,i={protocol:t.protocol,isFlv:t.isFlv,isFmp4:t.isFmp4,isMpeg4:t.isMpeg4,isNakedFlow:t.isNakedFlow,isTs:t.isTs};this.decoderWorker.postMessage({cmd:Qe,url:e,opt:JSON.stringify(i)})}clearWorkBuffer(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.decoderWorker.postMessage({cmd:Ye,needClear:e})}workerSendMessage(e){this.decoderWorker.postMessage({cmd:Xe,message:e})}updateVideoTimestamp(e){this.decoderWorker.postMessage({cmd:Ze,message:e})}}var Xn,Zn="application/json, text/javascript",el="text/html",tl=/^(?:text|application)\/xml/i,il=/^(.*?):[ \t]*([^\r\n]*)\r?$/gm,sl=/^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,rl=/^\s*$/,al={},ol={},nl="",ll={type:"GET",beforeSend:dl,success:dl,error:dl,complete:dl,context:null,xhr:function(){return new window.XMLHttpRequest},accepts:{json:Zn,xml:"application/xml, text/xml",html:el,text:"text/plain","*":"*/".concat("*")},crossDomain:!1,timeout:0,username:null,password:null,processData:!0,promise:dl,contentType:"application/x-www-form-urlencoded; charset=UTF-8"};function dl(){}var hl=function(e,t){"object"==typeof e&&(t=e,e=void 0);var i=Al({},t=t||{});for(var s in ll)void 0===i[s]&&(i[s]=ll[s]);try{var r={},a=new Promise((function(e,t){r.resolve=e,r.reject=t}));a.resolve=r.resolve,a.reject=r.reject,i.promise=a}catch(e){i.promise={resolve:dl,reject:dl}}var o=sl.exec(window.location.href.toLowerCase())||[];i.url=((e||i.url||window.location.href)+"").replace(/#.*$/,"").replace(/^\/\//,o[1]+"//");var n=i.url;i.crossDomain||(i.crossDomain=/^([\w-]+:)?\/\/([^\/]+)/.test(i.url)&&RegExp.$2!==window.location.href);var l=i.dataType;if("jsonp"===l){if(!/=\?/.test(i.url)){var d=(i.jsonp||"callback")+"=?";i.url=ml(i.url,d)}return function(e){var t,i=e.jsonpCallback||"jsonp"+vl(),s=window.document.createElement("script"),r={abort:function(){i in window&&(window[i]=dl)}},a=window.document.getElementsByTagName("head")[0]||window.document.documentElement;function o(i){window.clearTimeout(t),r.abort(),pl(i.type,r,i.type,e),n()}s.onerror=function(e){o(e)},window[i]=function(i){window.clearTimeout(t),cl(i,r,e),n()},gl(e),s.src=e.url.replace(/=\?/,"="+i),s.src=ml(s.src,"_="+(new Date).getTime()),s.async=!0,e.scriptCharset&&(s.charset=e.scriptCharset);a.insertBefore(s,a.firstChild),e.timeout>0&&(t=window.setTimeout((function(){r.abort(),pl("timeout",r,"timeout",e),n()}),e.timeout));function n(){s.clearAttributes?s.clearAttributes():s.onload=s.onreadystatechange=s.onerror=null,s.parentNode&&s.parentNode.removeChild(s),s=null,delete window[i]}return e.promise.abort=function(){r.abort()},e.promise.xhr=r,e.promise}(i)}gl(i);var h=i.accepts[l]||i.accepts["*"],c={};/^([\w-]+:)\/\//.test(i.url)?RegExp.$1:window.location.protocol;var u,p=ll.xhr();i.crossDomain||c["X-Requested-With"]||(c["X-Requested-With"]="XMLHttpRequest"),i.ifModified&&(al[n]&&(c["If-Modified-Since"]=al[n]),ol[n]&&(c["If-None-Match"]=ol[n])),h&&(c.Accept=h,h.indexOf(",")>-1&&(h=h.split(",",2)[0]),p.overrideMimeType&&p.overrideMimeType(h));var f=!/^(?:GET|HEAD)$/.test(i.type.toUpperCase());if((i.data&&f&&!1!==i.contentType||t.contentType)&&(c["Content-Type"]=i.contentType),!1===i.cache&&!f){var m=/([?&])_=[^&]*/;i.url=m.test(n)?n.replace(m,"$1_="+vl()):n+(/\?/.test(n)?"&":"?")+"_="+vl()}i.headers=Al(c,i.headers||{}),p.onreadystatechange=function(){if(4===p.readyState){var e;clearTimeout(u);var t=!1;if(p.status>=200&&p.status<300||304===p.status){if(nl=p.getAllResponseHeaders(),i.ifModified){var s=fl("Last-Modified");s&&(al[n]=s),(s=fl("etag"))&&(ol[n]=s)}l=l||function(e){return e&&(e===el?"html":e===Zn?"json":tl.test(e)&&"xml")||"text"}(p.getResponseHeader("content-type")),e=p.responseText;try{"xml"===l?e=p.responseXML:"json"===l&&(e=rl.test(e)?null:JSON.parse(e))}catch(e){t=e}t?pl(t,"parseerror",p,i):cl(e,p,i)}else pl(null,"error",p,i)}};var g=!("async"in i)||i.async;if(p.open(i.type,i.url,g,i.username,i.password),i.xhrFields)for(var y in i.xhrFields)p[y]=i.xhrFields[y];for(var y in i.mimeType&&p.overrideMimeType&&p.overrideMimeType(i.mimeType),i.headers)void 0!==i.headers[y]&&p.setRequestHeader(y,i.headers[y]+"");return!1===function(e,t){var i=t.context;if(!1===t.beforeSend.call(i,e,t))return!1}(p,i)?(p.abort(),!1):(i.timeout>0&&(u=window.setTimeout((function(){p.onreadystatechange=dl,p.abort(),pl(null,"timeout",p,i)}),i.timeout)),p.send(i.data?i.data:null),i.promise.abort=function(){p.abort()},i.promise)};function cl(e,t,i){var s=i.context,r="success";i.success.call(s,e,r,t),i.promise.resolve(e,r,t),ul(r,t,i)}function ul(e,t,i){var s=i.context;i.complete.call(s,t,e)}function pl(e,t,i,s){var r=s.context;s.error.call(r,i,t,e),s.promise.reject(i,t,e),ul(t,i,s)}function fl(e){var t;if(!Xn){for(Xn={};t=il.exec(nl);)Xn[t[1].toLowerCase()]=t[2];t=Xn[e.toLowerCase()]}return null===t?null:t}function ml(e,t){return(e+"&"+t).replace(/[&?]{1,2}/,"?")}function gl(e){!bl(e)||e.data instanceof FormData||!e.processData||(e.data=function(e,t){var i=[];return i.add=function(e,t){this.push(encodeURIComponent(e)+"="+encodeURIComponent(t))},yl(i,e,t),i.join("&").replace("%20","+")}(e.data)),!e.data||e.type&&"GET"!==e.type.toUpperCase()||(e.url=ml(e.url,e.data))}function yl(e,t,i,s){var r=function(e){return"[object Array]"===Object.prototype.toString.call(e)}(t);for(var a in t){var o=t[a];s&&(a=i?s:s+"["+(r?"":a)+"]"),!s&&r?e.add(o.name,o.value):(i?r(o):bl(o))?yl(e,o,i,a):e.add(a,o)}}function Al(e){for(var t=Array.prototype.slice.call(arguments,1),i=0,s=t.length;i<s;i++){var r=t[i]||{};for(var a in r)r.hasOwnProperty(a)&&void 0!==r[a]&&(e[a]=r[a])}return e}function bl(e){var t=typeof e;return"function"===t||"object"===t&&!!e}function _l(e){return"function"==typeof e}function vl(){return(new Date).getTime()}function Sl(e){return parseInt(e)===e}function wl(e){if(!Sl(e.length))return!1;for(var t=0;t<e.length;t++)if(!Sl(e[t])||e[t]<0||e[t]>255)return!1;return!0}function El(e,t){if(e.buffer&&"Uint8Array"===e.name)return t&&(e=e.slice?e.slice():Array.prototype.slice.call(e)),e;if(Array.isArray(e)){if(!wl(e))throw new Error("Array contains invalid value: "+e);return new Uint8Array(e)}if(Sl(e.length)&&wl(e))return new Uint8Array(e);throw new Error("unsupported array-like object")}function Tl(e){return new Uint8Array(e)}function kl(e,t,i,s,r){null==s&&null==r||(e=e.slice?e.slice(s,r):Array.prototype.slice.call(e,s,r)),t.set(e,i)}hl.get=function(e,t,i,s){return _l(t)&&(s=s||i,i=t,t=void 0),hl({url:e,data:t,success:i,dataType:s})},hl.post=function(e,t,i,s){return _l(t)&&(s=s||i,i=t,t=void 0),hl({type:"POST",url:e,data:t,success:i,dataType:s})},hl.getJSON=function(e,t,i){return _l(t)&&(i=t,t=void 0),hl({url:e,data:t,success:i,dataType:"json"})},hl.ajaxSetup=function(e,t){return t?Al(Al(e,ll),t):Al(ll,e)};var Cl={toBytes:function(e){var t=[],i=0;for(e=encodeURI(e);i<e.length;){var s=e.charCodeAt(i++);37===s?(t.push(parseInt(e.substr(i,2),16)),i+=2):t.push(s)}return El(t)},fromBytes:function(e){for(var t=[],i=0;i<e.length;){var s=e[i];s<128?(t.push(String.fromCharCode(s)),i++):s>191&&s<224?(t.push(String.fromCharCode((31&s)<<6|63&e[i+1])),i+=2):(t.push(String.fromCharCode((15&s)<<12|(63&e[i+1])<<6|63&e[i+2])),i+=3)}return t.join("")}},Rl=function(){var e="0123456789abcdef";return{toBytes:function(e){for(var t=[],i=0;i<e.length;i+=2)t.push(parseInt(e.substr(i,2),16));return t},fromBytes:function(t){for(var i=[],s=0;s<t.length;s++){var r=t[s];i.push(e[(240&r)>>4]+e[15&r])}return i.join("")}}}(),xl={16:10,24:12,32:14},Dl=[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],Ll=[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],Pl=[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],Bl=[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],Il=[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],Ml=[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],Ul=[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],Fl=[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],Ol=[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],Nl=[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],jl=[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],zl=[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],Gl=[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],Hl=[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],$l=[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 Vl(e){for(var t=[],i=0;i<e.length;i+=4)t.push(e[i]<<24|e[i+1]<<16|e[i+2]<<8|e[i+3]);return t}var Wl=function(e){if(!(this instanceof Wl))throw Error("AES must be instanitated with `new`");Object.defineProperty(this,"key",{value:El(e,!0)}),this._prepare()};Wl.prototype._prepare=function(){var e=xl[this.key.length];if(null==e)throw new Error("invalid key size (must be 16, 24 or 32 bytes)");this._Ke=[],this._Kd=[];for(var t=0;t<=e;t++)this._Ke.push([0,0,0,0]),this._Kd.push([0,0,0,0]);var i,s=4*(e+1),r=this.key.length/4,a=Vl(this.key);for(t=0;t<r;t++)i=t>>2,this._Ke[i][t%4]=a[t],this._Kd[e-i][t%4]=a[t];for(var o,n=0,l=r;l<s;){if(o=a[r-1],a[0]^=Ll[o>>16&255]<<24^Ll[o>>8&255]<<16^Ll[255&o]<<8^Ll[o>>24&255]^Dl[n]<<24,n+=1,8!=r)for(t=1;t<r;t++)a[t]^=a[t-1];else{for(t=1;t<r/2;t++)a[t]^=a[t-1];o=a[r/2-1],a[r/2]^=Ll[255&o]^Ll[o>>8&255]<<8^Ll[o>>16&255]<<16^Ll[o>>24&255]<<24;for(t=r/2+1;t<r;t++)a[t]^=a[t-1]}for(t=0;t<r&&l<s;)d=l>>2,h=l%4,this._Ke[d][h]=a[t],this._Kd[e-d][h]=a[t++],l++}for(var d=1;d<e;d++)for(var h=0;h<4;h++)o=this._Kd[d][h],this._Kd[d][h]=zl[o>>24&255]^Gl[o>>16&255]^Hl[o>>8&255]^$l[255&o]},Wl.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],s=Vl(e),r=0;r<4;r++)s[r]^=this._Ke[0][r];for(var a=1;a<t;a++){for(r=0;r<4;r++)i[r]=Bl[s[r]>>24&255]^Il[s[(r+1)%4]>>16&255]^Ml[s[(r+2)%4]>>8&255]^Ul[255&s[(r+3)%4]]^this._Ke[a][r];s=i.slice()}var o,n=Tl(16);for(r=0;r<4;r++)o=this._Ke[t][r],n[4*r]=255&(Ll[s[r]>>24&255]^o>>24),n[4*r+1]=255&(Ll[s[(r+1)%4]>>16&255]^o>>16),n[4*r+2]=255&(Ll[s[(r+2)%4]>>8&255]^o>>8),n[4*r+3]=255&(Ll[255&s[(r+3)%4]]^o);return n},Wl.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],s=Vl(e),r=0;r<4;r++)s[r]^=this._Kd[0][r];for(var a=1;a<t;a++){for(r=0;r<4;r++)i[r]=Fl[s[r]>>24&255]^Ol[s[(r+3)%4]>>16&255]^Nl[s[(r+2)%4]>>8&255]^jl[255&s[(r+1)%4]]^this._Kd[a][r];s=i.slice()}var o,n=Tl(16);for(r=0;r<4;r++)o=this._Kd[t][r],n[4*r]=255&(Pl[s[r]>>24&255]^o>>24),n[4*r+1]=255&(Pl[s[(r+3)%4]>>16&255]^o>>16),n[4*r+2]=255&(Pl[s[(r+2)%4]>>8&255]^o>>8),n[4*r+3]=255&(Pl[255&s[(r+1)%4]]^o);return n};var Jl=function(e){if(!(this instanceof Jl))throw Error("AES must be instanitated with `new`");this.description="Electronic Code Block",this.name="ecb",this._aes=new Wl(e)};Jl.prototype.encrypt=function(e){if((e=El(e)).length%16!=0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var t=Tl(e.length),i=Tl(16),s=0;s<e.length;s+=16)kl(e,i,0,s,s+16),kl(i=this._aes.encrypt(i),t,s);return t},Jl.prototype.decrypt=function(e){if((e=El(e)).length%16!=0)throw new Error("invalid ciphertext size (must be multiple of 16 bytes)");for(var t=Tl(e.length),i=Tl(16),s=0;s<e.length;s+=16)kl(e,i,0,s,s+16),kl(i=this._aes.decrypt(i),t,s);return t};var ql=function(e,t){if(!(this instanceof ql))throw Error("AES must be instanitated with `new`");if(this.description="Cipher Block Chaining",this.name="cbc",t){if(16!=t.length)throw new Error("invalid initialation vector size (must be 16 bytes)")}else t=Tl(16);this._lastCipherblock=El(t,!0),this._aes=new Wl(e)};ql.prototype.encrypt=function(e){if((e=El(e)).length%16!=0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var t=Tl(e.length),i=Tl(16),s=0;s<e.length;s+=16){kl(e,i,0,s,s+16);for(var r=0;r<16;r++)i[r]^=this._lastCipherblock[r];this._lastCipherblock=this._aes.encrypt(i),kl(this._lastCipherblock,t,s)}return t},ql.prototype.decrypt=function(e){if((e=El(e)).length%16!=0)throw new Error("invalid ciphertext size (must be multiple of 16 bytes)");for(var t=Tl(e.length),i=Tl(16),s=0;s<e.length;s+=16){kl(e,i,0,s,s+16),i=this._aes.decrypt(i);for(var r=0;r<16;r++)t[s+r]=i[r]^this._lastCipherblock[r];kl(e,this._lastCipherblock,0,s,s+16)}return t};var Kl=function(e,t,i){if(!(this instanceof Kl))throw Error("AES must be instanitated with `new`");if(this.description="Cipher Feedback",this.name="cfb",t){if(16!=t.length)throw new Error("invalid initialation vector size (must be 16 size)")}else t=Tl(16);i||(i=1),this.segmentSize=i,this._shiftRegister=El(t,!0),this._aes=new Wl(e)};Kl.prototype.encrypt=function(e){if(e.length%this.segmentSize!=0)throw new Error("invalid plaintext size (must be segmentSize bytes)");for(var t,i=El(e,!0),s=0;s<i.length;s+=this.segmentSize){t=this._aes.encrypt(this._shiftRegister);for(var r=0;r<this.segmentSize;r++)i[s+r]^=t[r];kl(this._shiftRegister,this._shiftRegister,0,this.segmentSize),kl(i,this._shiftRegister,16-this.segmentSize,s,s+this.segmentSize)}return i},Kl.prototype.decrypt=function(e){if(e.length%this.segmentSize!=0)throw new Error("invalid ciphertext size (must be segmentSize bytes)");for(var t,i=El(e,!0),s=0;s<i.length;s+=this.segmentSize){t=this._aes.encrypt(this._shiftRegister);for(var r=0;r<this.segmentSize;r++)i[s+r]^=t[r];kl(this._shiftRegister,this._shiftRegister,0,this.segmentSize),kl(e,this._shiftRegister,16-this.segmentSize,s,s+this.segmentSize)}return i};var Yl=function(e,t){if(!(this instanceof Yl))throw Error("AES must be instanitated with `new`");if(this.description="Output Feedback",this.name="ofb",t){if(16!=t.length)throw new Error("invalid initialation vector size (must be 16 bytes)")}else t=Tl(16);this._lastPrecipher=El(t,!0),this._lastPrecipherIndex=16,this._aes=new Wl(e)};Yl.prototype.encrypt=function(e){for(var t=El(e,!0),i=0;i<t.length;i++)16===this._lastPrecipherIndex&&(this._lastPrecipher=this._aes.encrypt(this._lastPrecipher),this._lastPrecipherIndex=0),t[i]^=this._lastPrecipher[this._lastPrecipherIndex++];return t},Yl.prototype.decrypt=Yl.prototype.encrypt;var Ql=function(e){if(!(this instanceof Ql))throw Error("Counter must be instanitated with `new`");0===e||e||(e=1),"number"==typeof e?(this._counter=Tl(16),this.setValue(e)):this.setBytes(e)};Ql.prototype.setValue=function(e){if("number"!=typeof e||parseInt(e)!=e)throw new Error("invalid counter value (must be an integer)");if(e>Number.MAX_SAFE_INTEGER)throw new Error("integer value out of safe range");for(var t=15;t>=0;--t)this._counter[t]=e%256,e=parseInt(e/256)},Ql.prototype.setBytes=function(e){if(16!=(e=El(e,!0)).length)throw new Error("invalid counter bytes size (must be 16 bytes)");this._counter=e},Ql.prototype.increment=function(){for(var e=15;e>=0;e--){if(255!==this._counter[e]){this._counter[e]++;break}this._counter[e]=0}};var Xl=function(e,t){if(!(this instanceof Xl))throw Error("AES must be instanitated with `new`");this.description="Counter",this.name="ctr",t instanceof Ql||(t=new Ql(t)),this._counter=t,this._remainingCounter=null,this._remainingCounterIndex=16,this._aes=new Wl(e)};Xl.prototype.encrypt=function(e){for(var t=El(e,!0),i=0;i<t.length;i++)16===this._remainingCounterIndex&&(this._remainingCounter=this._aes.encrypt(this._counter._counter),this._remainingCounterIndex=0,this._counter.increment()),t[i]^=this._remainingCounter[this._remainingCounterIndex++];return t},Xl.prototype.decrypt=Xl.prototype.encrypt;const Zl={AES:Wl,Counter:Ql,ModeOfOperation:{ecb:Jl,cbc:ql,cfb:Kl,ofb:Yl,ctr:Xl},utils:{hex:Rl,utf8:Cl},padding:{pkcs7:{pad:function(e){var t=16-(e=El(e,!0)).length%16,i=Tl(e.length+t);kl(e,i);for(var s=e.length;s<i.length;s++)i[s]=t;return i},strip:function(e){if((e=El(e,!0)).length<16)throw new Error("PKCS#7 invalid length");var t=e[e.length-1];if(t>16)throw new Error("PKCS#7 padding byte out of range");for(var i=e.length-t,s=0;s<t;s++)if(e[i+s]!==t)throw new Error("PKCS#7 invalid padding byte");var r=Tl(i);return kl(e,r,0,0,i),r}}},_arrayTest:{coerceArray:El,createArray:Tl,copyArray:kl}};var ed=kr((function(e,t){var i;e.exports=(i=i||function(e,t){var i;if("undefined"!=typeof window&&window.crypto&&(i=window.crypto),"undefined"!=typeof self&&self.crypto&&(i=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(i=globalThis.crypto),!i&&"undefined"!=typeof window&&window.msCrypto&&(i=window.msCrypto),!i&&void 0!==Tr&&Tr.crypto&&(i=Tr.crypto),!i)try{i=r.default}catch(e){}var s=function(){if(i){if("function"==typeof i.getRandomValues)try{return i.getRandomValues(new Uint32Array(1))[0]}catch(e){}if("function"==typeof i.randomBytes)try{return i.randomBytes(4).readInt32LE()}catch(e){}}throw new Error("Native crypto module could not be used to get secure random number.")},a=Object.create||function(){function e(){}return function(t){var i;return e.prototype=t,i=new e,e.prototype=null,i}}(),o={},n=o.lib={},l=n.Base={extend:function(e){var t=a(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},d=n.WordArray=l.extend({init:function(e,i){e=this.words=e||[],this.sigBytes=i!=t?i:4*e.length},toString:function(e){return(e||c).stringify(this)},concat:function(e){var t=this.words,i=e.words,s=this.sigBytes,r=e.sigBytes;if(this.clamp(),s%4)for(var a=0;a<r;a++){var o=i[a>>>2]>>>24-a%4*8&255;t[s+a>>>2]|=o<<24-(s+a)%4*8}else for(var n=0;n<r;n+=4)t[s+n>>>2]=i[n>>>2];return this.sigBytes+=r,this},clamp:function(){var t=this.words,i=this.sigBytes;t[i>>>2]&=4294967295<<32-i%4*8,t.length=e.ceil(i/4)},clone:function(){var e=l.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],i=0;i<e;i+=4)t.push(s());return new d.init(t,e)}}),h=o.enc={},c=h.Hex={stringify:function(e){for(var t=e.words,i=e.sigBytes,s=[],r=0;r<i;r++){var a=t[r>>>2]>>>24-r%4*8&255;s.push((a>>>4).toString(16)),s.push((15&a).toString(16))}return s.join("")},parse:function(e){for(var t=e.length,i=[],s=0;s<t;s+=2)i[s>>>3]|=parseInt(e.substr(s,2),16)<<24-s%8*4;return new d.init(i,t/2)}},u=h.Latin1={stringify:function(e){for(var t=e.words,i=e.sigBytes,s=[],r=0;r<i;r++){var a=t[r>>>2]>>>24-r%4*8&255;s.push(String.fromCharCode(a))}return s.join("")},parse:function(e){for(var t=e.length,i=[],s=0;s<t;s++)i[s>>>2]|=(255&e.charCodeAt(s))<<24-s%4*8;return new d.init(i,t)}},p=h.Utf8={stringify:function(e){try{return decodeURIComponent(escape(u.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return u.parse(unescape(encodeURIComponent(e)))}},f=n.BufferedBlockAlgorithm=l.extend({reset:function(){this._data=new d.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=p.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var i,s=this._data,r=s.words,a=s.sigBytes,o=this.blockSize,n=a/(4*o),l=(n=t?e.ceil(n):e.max((0|n)-this._minBufferSize,0))*o,h=e.min(4*l,a);if(l){for(var c=0;c<l;c+=o)this._doProcessBlock(r,c);i=r.splice(0,l),s.sigBytes-=h}return new d.init(i,h)},clone:function(){var e=l.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});n.Hasher=f.extend({cfg:l.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){f.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,i){return new e.init(i).finalize(t)}},_createHmacHelper:function(e){return function(t,i){return new m.HMAC.init(e,i).finalize(t)}}});var m=o.algo={};return o}(Math),i)})),td=(kr((function(e,t){var i,s,r,a,o,n,l;e.exports=(r=(s=l=ed).lib,a=r.Base,o=r.WordArray,(n=s.x64={}).Word=a.extend({init:function(e,t){this.high=e,this.low=t}}),n.WordArray=a.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=t!=i?t:8*e.length},toX32:function(){for(var e=this.words,t=e.length,i=[],s=0;s<t;s++){var r=e[s];i.push(r.high),i.push(r.low)}return o.create(i,this.sigBytes)},clone:function(){for(var e=a.clone.call(this),t=e.words=this.words.slice(0),i=t.length,s=0;s<i;s++)t[s]=t[s].clone();return e}}),l)})),kr((function(e,t){var i;e.exports=(i=ed,function(){if("function"==typeof ArrayBuffer){var e=i.lib.WordArray,t=e.init,s=e.init=function(e){if(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),(e instanceof Int8Array||"undefined"!=typeof Uint8ClampedArray&&e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array)&&(e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),e instanceof Uint8Array){for(var i=e.byteLength,s=[],r=0;r<i;r++)s[r>>>2]|=e[r]<<24-r%4*8;t.call(this,s,i)}else t.apply(this,arguments)};s.prototype=e}}(),i.lib.WordArray)})),kr((function(e,t){var i;e.exports=(i=ed,function(){var e=i,t=e.lib.WordArray,s=e.enc;function r(e){return e<<8&4278255360|e>>>8&16711935}s.Utf16=s.Utf16BE={stringify:function(e){for(var t=e.words,i=e.sigBytes,s=[],r=0;r<i;r+=2){var a=t[r>>>2]>>>16-r%4*8&65535;s.push(String.fromCharCode(a))}return s.join("")},parse:function(e){for(var i=e.length,s=[],r=0;r<i;r++)s[r>>>1]|=e.charCodeAt(r)<<16-r%2*16;return t.create(s,2*i)}},s.Utf16LE={stringify:function(e){for(var t=e.words,i=e.sigBytes,s=[],a=0;a<i;a+=2){var o=r(t[a>>>2]>>>16-a%4*8&65535);s.push(String.fromCharCode(o))}return s.join("")},parse:function(e){for(var i=e.length,s=[],a=0;a<i;a++)s[a>>>1]|=r(e.charCodeAt(a)<<16-a%2*16);return t.create(s,2*i)}}}(),i.enc.Utf16)})),kr((function(e,t){var i;e.exports=(i=ed,function(){var e=i,t=e.lib.WordArray;function s(e,i,s){for(var r=[],a=0,o=0;o<i;o++)if(o%4){var n=s[e.charCodeAt(o-1)]<<o%4*2|s[e.charCodeAt(o)]>>>6-o%4*2;r[a>>>2]|=n<<24-a%4*8,a++}return t.create(r,a)}e.enc.Base64={stringify:function(e){var t=e.words,i=e.sigBytes,s=this._map;e.clamp();for(var r=[],a=0;a<i;a+=3)for(var o=(t[a>>>2]>>>24-a%4*8&255)<<16|(t[a+1>>>2]>>>24-(a+1)%4*8&255)<<8|t[a+2>>>2]>>>24-(a+2)%4*8&255,n=0;n<4&&a+.75*n<i;n++)r.push(s.charAt(o>>>6*(3-n)&63));var l=s.charAt(64);if(l)for(;r.length%4;)r.push(l);return r.join("")},parse:function(e){var t=e.length,i=this._map,r=this._reverseMap;if(!r){r=this._reverseMap=[];for(var a=0;a<i.length;a++)r[i.charCodeAt(a)]=a}var o=i.charAt(64);if(o){var n=e.indexOf(o);-1!==n&&(t=n)}return s(e,t,r)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),i.enc.Base64)})),kr((function(e,t){var i;e.exports=(i=ed,function(){var e=i,t=e.lib.WordArray;function s(e,i,s){for(var r=[],a=0,o=0;o<i;o++)if(o%4){var n=s[e.charCodeAt(o-1)]<<o%4*2|s[e.charCodeAt(o)]>>>6-o%4*2;r[a>>>2]|=n<<24-a%4*8,a++}return t.create(r,a)}e.enc.Base64url={stringify:function(e,t){void 0===t&&(t=!0);var i=e.words,s=e.sigBytes,r=t?this._safe_map:this._map;e.clamp();for(var a=[],o=0;o<s;o+=3)for(var n=(i[o>>>2]>>>24-o%4*8&255)<<16|(i[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|i[o+2>>>2]>>>24-(o+2)%4*8&255,l=0;l<4&&o+.75*l<s;l++)a.push(r.charAt(n>>>6*(3-l)&63));var d=r.charAt(64);if(d)for(;a.length%4;)a.push(d);return a.join("")},parse:function(e,t){void 0===t&&(t=!0);var i=e.length,r=t?this._safe_map:this._map,a=this._reverseMap;if(!a){a=this._reverseMap=[];for(var o=0;o<r.length;o++)a[r.charCodeAt(o)]=o}var n=r.charAt(64);if(n){var l=e.indexOf(n);-1!==l&&(i=l)}return s(e,i,a)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",_safe_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"}}(),i.enc.Base64url)})),kr((function(e,t){var i;e.exports=(i=ed,function(e){var t=i,s=t.lib,r=s.WordArray,a=s.Hasher,o=t.algo,n=[];!function(){for(var t=0;t<64;t++)n[t]=4294967296*e.abs(e.sin(t+1))|0}();var l=o.MD5=a.extend({_doReset:function(){this._hash=new r.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var i=0;i<16;i++){var s=t+i,r=e[s];e[s]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8)}var a=this._hash.words,o=e[t+0],l=e[t+1],p=e[t+2],f=e[t+3],m=e[t+4],g=e[t+5],y=e[t+6],A=e[t+7],b=e[t+8],_=e[t+9],v=e[t+10],S=e[t+11],w=e[t+12],E=e[t+13],T=e[t+14],k=e[t+15],C=a[0],R=a[1],x=a[2],D=a[3];C=d(C,R,x,D,o,7,n[0]),D=d(D,C,R,x,l,12,n[1]),x=d(x,D,C,R,p,17,n[2]),R=d(R,x,D,C,f,22,n[3]),C=d(C,R,x,D,m,7,n[4]),D=d(D,C,R,x,g,12,n[5]),x=d(x,D,C,R,y,17,n[6]),R=d(R,x,D,C,A,22,n[7]),C=d(C,R,x,D,b,7,n[8]),D=d(D,C,R,x,_,12,n[9]),x=d(x,D,C,R,v,17,n[10]),R=d(R,x,D,C,S,22,n[11]),C=d(C,R,x,D,w,7,n[12]),D=d(D,C,R,x,E,12,n[13]),x=d(x,D,C,R,T,17,n[14]),C=h(C,R=d(R,x,D,C,k,22,n[15]),x,D,l,5,n[16]),D=h(D,C,R,x,y,9,n[17]),x=h(x,D,C,R,S,14,n[18]),R=h(R,x,D,C,o,20,n[19]),C=h(C,R,x,D,g,5,n[20]),D=h(D,C,R,x,v,9,n[21]),x=h(x,D,C,R,k,14,n[22]),R=h(R,x,D,C,m,20,n[23]),C=h(C,R,x,D,_,5,n[24]),D=h(D,C,R,x,T,9,n[25]),x=h(x,D,C,R,f,14,n[26]),R=h(R,x,D,C,b,20,n[27]),C=h(C,R,x,D,E,5,n[28]),D=h(D,C,R,x,p,9,n[29]),x=h(x,D,C,R,A,14,n[30]),C=c(C,R=h(R,x,D,C,w,20,n[31]),x,D,g,4,n[32]),D=c(D,C,R,x,b,11,n[33]),x=c(x,D,C,R,S,16,n[34]),R=c(R,x,D,C,T,23,n[35]),C=c(C,R,x,D,l,4,n[36]),D=c(D,C,R,x,m,11,n[37]),x=c(x,D,C,R,A,16,n[38]),R=c(R,x,D,C,v,23,n[39]),C=c(C,R,x,D,E,4,n[40]),D=c(D,C,R,x,o,11,n[41]),x=c(x,D,C,R,f,16,n[42]),R=c(R,x,D,C,y,23,n[43]),C=c(C,R,x,D,_,4,n[44]),D=c(D,C,R,x,w,11,n[45]),x=c(x,D,C,R,k,16,n[46]),C=u(C,R=c(R,x,D,C,p,23,n[47]),x,D,o,6,n[48]),D=u(D,C,R,x,A,10,n[49]),x=u(x,D,C,R,T,15,n[50]),R=u(R,x,D,C,g,21,n[51]),C=u(C,R,x,D,w,6,n[52]),D=u(D,C,R,x,f,10,n[53]),x=u(x,D,C,R,v,15,n[54]),R=u(R,x,D,C,l,21,n[55]),C=u(C,R,x,D,b,6,n[56]),D=u(D,C,R,x,k,10,n[57]),x=u(x,D,C,R,y,15,n[58]),R=u(R,x,D,C,E,21,n[59]),C=u(C,R,x,D,m,6,n[60]),D=u(D,C,R,x,S,10,n[61]),x=u(x,D,C,R,p,15,n[62]),R=u(R,x,D,C,_,21,n[63]),a[0]=a[0]+C|0,a[1]=a[1]+R|0,a[2]=a[2]+x|0,a[3]=a[3]+D|0},_doFinalize:function(){var t=this._data,i=t.words,s=8*this._nDataBytes,r=8*t.sigBytes;i[r>>>5]|=128<<24-r%32;var a=e.floor(s/4294967296),o=s;i[15+(r+64>>>9<<4)]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),i[14+(r+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),t.sigBytes=4*(i.length+1),this._process();for(var n=this._hash,l=n.words,d=0;d<4;d++){var h=l[d];l[d]=16711935&(h<<8|h>>>24)|4278255360&(h<<24|h>>>8)}return n},clone:function(){var e=a.clone.call(this);return e._hash=this._hash.clone(),e}});function d(e,t,i,s,r,a,o){var n=e+(t&i|~t&s)+r+o;return(n<<a|n>>>32-a)+t}function h(e,t,i,s,r,a,o){var n=e+(t&s|i&~s)+r+o;return(n<<a|n>>>32-a)+t}function c(e,t,i,s,r,a,o){var n=e+(t^i^s)+r+o;return(n<<a|n>>>32-a)+t}function u(e,t,i,s,r,a,o){var n=e+(i^(t|~s))+r+o;return(n<<a|n>>>32-a)+t}t.MD5=a._createHelper(l),t.HmacMD5=a._createHmacHelper(l)}(Math),i.MD5)})),kr((function(e,t){var i,s,r,a,o,n,l,d;e.exports=(s=(i=d=ed).lib,r=s.WordArray,a=s.Hasher,o=i.algo,n=[],l=o.SHA1=a.extend({_doReset:function(){this._hash=new r.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var i=this._hash.words,s=i[0],r=i[1],a=i[2],o=i[3],l=i[4],d=0;d<80;d++){if(d<16)n[d]=0|e[t+d];else{var h=n[d-3]^n[d-8]^n[d-14]^n[d-16];n[d]=h<<1|h>>>31}var c=(s<<5|s>>>27)+l+n[d];c+=d<20?1518500249+(r&a|~r&o):d<40?1859775393+(r^a^o):d<60?(r&a|r&o|a&o)-1894007588:(r^a^o)-899497514,l=o,o=a,a=r<<30|r>>>2,r=s,s=c}i[0]=i[0]+s|0,i[1]=i[1]+r|0,i[2]=i[2]+a|0,i[3]=i[3]+o|0,i[4]=i[4]+l|0},_doFinalize:function(){var e=this._data,t=e.words,i=8*this._nDataBytes,s=8*e.sigBytes;return t[s>>>5]|=128<<24-s%32,t[14+(s+64>>>9<<4)]=Math.floor(i/4294967296),t[15+(s+64>>>9<<4)]=i,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=a.clone.call(this);return e._hash=this._hash.clone(),e}}),i.SHA1=a._createHelper(l),i.HmacSHA1=a._createHmacHelper(l),d.SHA1)})),kr((function(e,t){var i;e.exports=(i=ed,function(e){var t=i,s=t.lib,r=s.WordArray,a=s.Hasher,o=t.algo,n=[],l=[];!function(){function t(t){for(var i=e.sqrt(t),s=2;s<=i;s++)if(!(t%s))return!1;return!0}function i(e){return 4294967296*(e-(0|e))|0}for(var s=2,r=0;r<64;)t(s)&&(r<8&&(n[r]=i(e.pow(s,.5))),l[r]=i(e.pow(s,1/3)),r++),s++}();var d=[],h=o.SHA256=a.extend({_doReset:function(){this._hash=new r.init(n.slice(0))},_doProcessBlock:function(e,t){for(var i=this._hash.words,s=i[0],r=i[1],a=i[2],o=i[3],n=i[4],h=i[5],c=i[6],u=i[7],p=0;p<64;p++){if(p<16)d[p]=0|e[t+p];else{var f=d[p-15],m=(f<<25|f>>>7)^(f<<14|f>>>18)^f>>>3,g=d[p-2],y=(g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10;d[p]=m+d[p-7]+y+d[p-16]}var A=s&r^s&a^r&a,b=(s<<30|s>>>2)^(s<<19|s>>>13)^(s<<10|s>>>22),_=u+((n<<26|n>>>6)^(n<<21|n>>>11)^(n<<7|n>>>25))+(n&h^~n&c)+l[p]+d[p];u=c,c=h,h=n,n=o+_|0,o=a,a=r,r=s,s=_+(b+A)|0}i[0]=i[0]+s|0,i[1]=i[1]+r|0,i[2]=i[2]+a|0,i[3]=i[3]+o|0,i[4]=i[4]+n|0,i[5]=i[5]+h|0,i[6]=i[6]+c|0,i[7]=i[7]+u|0},_doFinalize:function(){var t=this._data,i=t.words,s=8*this._nDataBytes,r=8*t.sigBytes;return i[r>>>5]|=128<<24-r%32,i[14+(r+64>>>9<<4)]=e.floor(s/4294967296),i[15+(r+64>>>9<<4)]=s,t.sigBytes=4*i.length,this._process(),this._hash},clone:function(){var e=a.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=a._createHelper(h),t.HmacSHA256=a._createHmacHelper(h)}(Math),i.SHA256)})),kr((function(e,t){var i,s,r,a,o,n;e.exports=(s=(i=n=ed).lib.WordArray,r=i.algo,a=r.SHA256,o=r.SHA224=a.extend({_doReset:function(){this._hash=new s.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var e=a._doFinalize.call(this);return e.sigBytes-=4,e}}),i.SHA224=a._createHelper(o),i.HmacSHA224=a._createHmacHelper(o),n.SHA224)})),kr((function(e,t){var i;e.exports=(i=ed,function(){var e=i,t=e.lib.Hasher,s=e.x64,r=s.Word,a=s.WordArray,o=e.algo;function n(){return r.create.apply(r,arguments)}var l=[n(1116352408,3609767458),n(1899447441,602891725),n(3049323471,3964484399),n(3921009573,2173295548),n(961987163,4081628472),n(1508970993,3053834265),n(2453635748,2937671579),n(2870763221,3664609560),n(3624381080,2734883394),n(310598401,1164996542),n(607225278,1323610764),n(1426881987,3590304994),n(1925078388,4068182383),n(2162078206,991336113),n(2614888103,633803317),n(3248222580,3479774868),n(3835390401,2666613458),n(4022224774,944711139),n(264347078,2341262773),n(604807628,2007800933),n(770255983,1495990901),n(1249150122,1856431235),n(1555081692,3175218132),n(1996064986,2198950837),n(2554220882,3999719339),n(2821834349,766784016),n(2952996808,2566594879),n(3210313671,3203337956),n(3336571891,1034457026),n(3584528711,2466948901),n(113926993,3758326383),n(338241895,168717936),n(666307205,1188179964),n(773529912,1546045734),n(1294757372,1522805485),n(1396182291,2643833823),n(1695183700,2343527390),n(1986661051,1014477480),n(2177026350,1206759142),n(2456956037,344077627),n(2730485921,1290863460),n(2820302411,3158454273),n(3259730800,3505952657),n(3345764771,106217008),n(3516065817,3606008344),n(3600352804,1432725776),n(4094571909,1467031594),n(275423344,851169720),n(430227734,3100823752),n(506948616,1363258195),n(659060556,3750685593),n(883997877,3785050280),n(958139571,3318307427),n(1322822218,3812723403),n(1537002063,2003034995),n(1747873779,3602036899),n(1955562222,1575990012),n(2024104815,1125592928),n(2227730452,2716904306),n(2361852424,442776044),n(2428436474,593698344),n(2756734187,3733110249),n(3204031479,2999351573),n(3329325298,3815920427),n(3391569614,3928383900),n(3515267271,566280711),n(3940187606,3454069534),n(4118630271,4000239992),n(116418474,1914138554),n(174292421,2731055270),n(289380356,3203993006),n(460393269,320620315),n(685471733,587496836),n(852142971,1086792851),n(1017036298,365543100),n(1126000580,2618297676),n(1288033470,3409855158),n(1501505948,4234509866),n(1607167915,987167468),n(1816402316,1246189591)],d=[];!function(){for(var e=0;e<80;e++)d[e]=n()}();var h=o.SHA512=t.extend({_doReset:function(){this._hash=new a.init([new r.init(1779033703,4089235720),new r.init(3144134277,2227873595),new r.init(1013904242,4271175723),new r.init(2773480762,1595750129),new r.init(1359893119,2917565137),new r.init(2600822924,725511199),new r.init(528734635,4215389547),new r.init(1541459225,327033209)])},_doProcessBlock:function(e,t){for(var i=this._hash.words,s=i[0],r=i[1],a=i[2],o=i[3],n=i[4],h=i[5],c=i[6],u=i[7],p=s.high,f=s.low,m=r.high,g=r.low,y=a.high,A=a.low,b=o.high,_=o.low,v=n.high,S=n.low,w=h.high,E=h.low,T=c.high,k=c.low,C=u.high,R=u.low,x=p,D=f,L=m,P=g,B=y,I=A,M=b,U=_,F=v,O=S,N=w,j=E,z=T,G=k,H=C,$=R,V=0;V<80;V++){var W,J,q=d[V];if(V<16)J=q.high=0|e[t+2*V],W=q.low=0|e[t+2*V+1];else{var K=d[V-15],Y=K.high,Q=K.low,X=(Y>>>1|Q<<31)^(Y>>>8|Q<<24)^Y>>>7,Z=(Q>>>1|Y<<31)^(Q>>>8|Y<<24)^(Q>>>7|Y<<25),ee=d[V-2],te=ee.high,ie=ee.low,se=(te>>>19|ie<<13)^(te<<3|ie>>>29)^te>>>6,re=(ie>>>19|te<<13)^(ie<<3|te>>>29)^(ie>>>6|te<<26),ae=d[V-7],oe=ae.high,ne=ae.low,le=d[V-16],de=le.high,he=le.low;J=(J=(J=X+oe+((W=Z+ne)>>>0<Z>>>0?1:0))+se+((W+=re)>>>0<re>>>0?1:0))+de+((W+=he)>>>0<he>>>0?1:0),q.high=J,q.low=W}var ce,ue=F&N^~F&z,pe=O&j^~O&G,fe=x&L^x&B^L&B,me=D&P^D&I^P&I,ge=(x>>>28|D<<4)^(x<<30|D>>>2)^(x<<25|D>>>7),ye=(D>>>28|x<<4)^(D<<30|x>>>2)^(D<<25|x>>>7),Ae=(F>>>14|O<<18)^(F>>>18|O<<14)^(F<<23|O>>>9),be=(O>>>14|F<<18)^(O>>>18|F<<14)^(O<<23|F>>>9),_e=l[V],ve=_e.high,Se=_e.low,we=H+Ae+((ce=$+be)>>>0<$>>>0?1:0),Ee=ye+me;H=z,$=G,z=N,G=j,N=F,j=O,F=M+(we=(we=(we=we+ue+((ce+=pe)>>>0<pe>>>0?1:0))+ve+((ce+=Se)>>>0<Se>>>0?1:0))+J+((ce+=W)>>>0<W>>>0?1:0))+((O=U+ce|0)>>>0<U>>>0?1:0)|0,M=B,U=I,B=L,I=P,L=x,P=D,x=we+(ge+fe+(Ee>>>0<ye>>>0?1:0))+((D=ce+Ee|0)>>>0<ce>>>0?1:0)|0}f=s.low=f+D,s.high=p+x+(f>>>0<D>>>0?1:0),g=r.low=g+P,r.high=m+L+(g>>>0<P>>>0?1:0),A=a.low=A+I,a.high=y+B+(A>>>0<I>>>0?1:0),_=o.low=_+U,o.high=b+M+(_>>>0<U>>>0?1:0),S=n.low=S+O,n.high=v+F+(S>>>0<O>>>0?1:0),E=h.low=E+j,h.high=w+N+(E>>>0<j>>>0?1:0),k=c.low=k+G,c.high=T+z+(k>>>0<G>>>0?1:0),R=u.low=R+$,u.high=C+H+(R>>>0<$>>>0?1:0)},_doFinalize:function(){var e=this._data,t=e.words,i=8*this._nDataBytes,s=8*e.sigBytes;return t[s>>>5]|=128<<24-s%32,t[30+(s+128>>>10<<5)]=Math.floor(i/4294967296),t[31+(s+128>>>10<<5)]=i,e.sigBytes=4*t.length,this._process(),this._hash.toX32()},clone:function(){var e=t.clone.call(this);return e._hash=this._hash.clone(),e},blockSize:32});e.SHA512=t._createHelper(h),e.HmacSHA512=t._createHmacHelper(h)}(),i.SHA512)})),kr((function(e,t){var i,s,r,a,o,n,l,d;e.exports=(s=(i=d=ed).x64,r=s.Word,a=s.WordArray,o=i.algo,n=o.SHA512,l=o.SHA384=n.extend({_doReset:function(){this._hash=new a.init([new r.init(3418070365,3238371032),new r.init(1654270250,914150663),new r.init(2438529370,812702999),new r.init(355462360,4144912697),new r.init(1731405415,4290775857),new r.init(2394180231,1750603025),new r.init(3675008525,1694076839),new r.init(1203062813,3204075428)])},_doFinalize:function(){var e=n._doFinalize.call(this);return e.sigBytes-=16,e}}),i.SHA384=n._createHelper(l),i.HmacSHA384=n._createHmacHelper(l),d.SHA384)})),kr((function(e,t){var i;e.exports=(i=ed,function(e){var t=i,s=t.lib,r=s.WordArray,a=s.Hasher,o=t.x64.Word,n=t.algo,l=[],d=[],h=[];!function(){for(var e=1,t=0,i=0;i<24;i++){l[e+5*t]=(i+1)*(i+2)/2%64;var s=(2*e+3*t)%5;e=t%5,t=s}for(e=0;e<5;e++)for(t=0;t<5;t++)d[e+5*t]=t+(2*e+3*t)%5*5;for(var r=1,a=0;a<24;a++){for(var n=0,c=0,u=0;u<7;u++){if(1&r){var p=(1<<u)-1;p<32?c^=1<<p:n^=1<<p-32}128&r?r=r<<1^113:r<<=1}h[a]=o.create(n,c)}}();var c=[];!function(){for(var e=0;e<25;e++)c[e]=o.create()}();var u=n.SHA3=a.extend({cfg:a.cfg.extend({outputLength:512}),_doReset:function(){for(var e=this._state=[],t=0;t<25;t++)e[t]=new o.init;this.blockSize=(1600-2*this.cfg.outputLength)/32},_doProcessBlock:function(e,t){for(var i=this._state,s=this.blockSize/2,r=0;r<s;r++){var a=e[t+2*r],o=e[t+2*r+1];a=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),o=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),(R=i[r]).high^=o,R.low^=a}for(var n=0;n<24;n++){for(var u=0;u<5;u++){for(var p=0,f=0,m=0;m<5;m++)p^=(R=i[u+5*m]).high,f^=R.low;var g=c[u];g.high=p,g.low=f}for(u=0;u<5;u++){var y=c[(u+4)%5],A=c[(u+1)%5],b=A.high,_=A.low;for(p=y.high^(b<<1|_>>>31),f=y.low^(_<<1|b>>>31),m=0;m<5;m++)(R=i[u+5*m]).high^=p,R.low^=f}for(var v=1;v<25;v++){var S=(R=i[v]).high,w=R.low,E=l[v];E<32?(p=S<<E|w>>>32-E,f=w<<E|S>>>32-E):(p=w<<E-32|S>>>64-E,f=S<<E-32|w>>>64-E);var T=c[d[v]];T.high=p,T.low=f}var k=c[0],C=i[0];for(k.high=C.high,k.low=C.low,u=0;u<5;u++)for(m=0;m<5;m++){var R=i[v=u+5*m],x=c[v],D=c[(u+1)%5+5*m],L=c[(u+2)%5+5*m];R.high=x.high^~D.high&L.high,R.low=x.low^~D.low&L.low}R=i[0];var P=h[n];R.high^=P.high,R.low^=P.low}},_doFinalize:function(){var t=this._data,i=t.words;this._nDataBytes;var s=8*t.sigBytes,a=32*this.blockSize;i[s>>>5]|=1<<24-s%32,i[(e.ceil((s+1)/a)*a>>>5)-1]|=128,t.sigBytes=4*i.length,this._process();for(var o=this._state,n=this.cfg.outputLength/8,l=n/8,d=[],h=0;h<l;h++){var c=o[h],u=c.high,p=c.low;u=16711935&(u<<8|u>>>24)|4278255360&(u<<24|u>>>8),p=16711935&(p<<8|p>>>24)|4278255360&(p<<24|p>>>8),d.push(p),d.push(u)}return new r.init(d,n)},clone:function(){for(var e=a.clone.call(this),t=e._state=this._state.slice(0),i=0;i<25;i++)t[i]=t[i].clone();return e}});t.SHA3=a._createHelper(u),t.HmacSHA3=a._createHmacHelper(u)}(Math),i.SHA3)})),kr((function(e,t){var i;e.exports=(i=ed,function(e){var t=i,s=t.lib,r=s.WordArray,a=s.Hasher,o=t.algo,n=r.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),l=r.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),d=r.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),h=r.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),c=r.create([0,1518500249,1859775393,2400959708,2840853838]),u=r.create([1352829926,1548603684,1836072691,2053994217,0]),p=o.RIPEMD160=a.extend({_doReset:function(){this._hash=r.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var i=0;i<16;i++){var s=t+i,r=e[s];e[s]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8)}var a,o,p,_,v,S,w,E,T,k,C,R=this._hash.words,x=c.words,D=u.words,L=n.words,P=l.words,B=d.words,I=h.words;for(S=a=R[0],w=o=R[1],E=p=R[2],T=_=R[3],k=v=R[4],i=0;i<80;i+=1)C=a+e[t+L[i]]|0,C+=i<16?f(o,p,_)+x[0]:i<32?m(o,p,_)+x[1]:i<48?g(o,p,_)+x[2]:i<64?y(o,p,_)+x[3]:A(o,p,_)+x[4],C=(C=b(C|=0,B[i]))+v|0,a=v,v=_,_=b(p,10),p=o,o=C,C=S+e[t+P[i]]|0,C+=i<16?A(w,E,T)+D[0]:i<32?y(w,E,T)+D[1]:i<48?g(w,E,T)+D[2]:i<64?m(w,E,T)+D[3]:f(w,E,T)+D[4],C=(C=b(C|=0,I[i]))+k|0,S=k,k=T,T=b(E,10),E=w,w=C;C=R[1]+p+T|0,R[1]=R[2]+_+k|0,R[2]=R[3]+v+S|0,R[3]=R[4]+a+w|0,R[4]=R[0]+o+E|0,R[0]=C},_doFinalize:function(){var e=this._data,t=e.words,i=8*this._nDataBytes,s=8*e.sigBytes;t[s>>>5]|=128<<24-s%32,t[14+(s+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),e.sigBytes=4*(t.length+1),this._process();for(var r=this._hash,a=r.words,o=0;o<5;o++){var n=a[o];a[o]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8)}return r},clone:function(){var e=a.clone.call(this);return e._hash=this._hash.clone(),e}});function f(e,t,i){return e^t^i}function m(e,t,i){return e&t|~e&i}function g(e,t,i){return(e|~t)^i}function y(e,t,i){return e&i|t&~i}function A(e,t,i){return e^(t|~i)}function b(e,t){return e<<t|e>>>32-t}t.RIPEMD160=a._createHelper(p),t.HmacRIPEMD160=a._createHmacHelper(p)}(),i.RIPEMD160)})),kr((function(e,t){var i,s,r;e.exports=(s=(i=ed).lib.Base,r=i.enc.Utf8,void(i.algo.HMAC=s.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=r.parse(t));var i=e.blockSize,s=4*i;t.sigBytes>s&&(t=e.finalize(t)),t.clamp();for(var a=this._oKey=t.clone(),o=this._iKey=t.clone(),n=a.words,l=o.words,d=0;d<i;d++)n[d]^=1549556828,l[d]^=909522486;a.sigBytes=o.sigBytes=s,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t=this._hasher,i=t.finalize(e);return t.reset(),t.finalize(this._oKey.clone().concat(i))}})))})),kr((function(e,t){var i,s,r,a,o,n,l,d,h;e.exports=(s=(i=h=ed).lib,r=s.Base,a=s.WordArray,o=i.algo,n=o.SHA256,l=o.HMAC,d=o.PBKDF2=r.extend({cfg:r.extend({keySize:4,hasher:n,iterations:25e4}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var i=this.cfg,s=l.create(i.hasher,e),r=a.create(),o=a.create([1]),n=r.words,d=o.words,h=i.keySize,c=i.iterations;n.length<h;){var u=s.update(t).finalize(o);s.reset();for(var p=u.words,f=p.length,m=u,g=1;g<c;g++){m=s.finalize(m),s.reset();for(var y=m.words,A=0;A<f;A++)p[A]^=y[A]}r.concat(u),d[0]++}return r.sigBytes=4*h,r}}),i.PBKDF2=function(e,t,i){return d.create(i).compute(e,t)},h.PBKDF2)})),kr((function(e,t){var i,s,r,a,o,n,l,d;e.exports=(s=(i=d=ed).lib,r=s.Base,a=s.WordArray,o=i.algo,n=o.MD5,l=o.EvpKDF=r.extend({cfg:r.extend({keySize:4,hasher:n,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var i,s=this.cfg,r=s.hasher.create(),o=a.create(),n=o.words,l=s.keySize,d=s.iterations;n.length<l;){i&&r.update(i),i=r.update(e).finalize(t),r.reset();for(var h=1;h<d;h++)i=r.finalize(i),r.reset();o.concat(i)}return o.sigBytes=4*l,o}}),i.EvpKDF=function(e,t,i){return l.create(i).compute(e,t)},d.EvpKDF)})),kr((function(e,t){var i;e.exports=void((i=ed).lib.Cipher||function(e){var t=i,s=t.lib,r=s.Base,a=s.WordArray,o=s.BufferedBlockAlgorithm,n=t.enc;n.Utf8;var l=n.Base64,d=t.algo.EvpKDF,h=s.Cipher=o.extend({cfg:r.extend(),createEncryptor:function(e,t){return this.create(this._ENC_XFORM_MODE,e,t)},createDecryptor:function(e,t){return this.create(this._DEC_XFORM_MODE,e,t)},init:function(e,t,i){this.cfg=this.cfg.extend(i),this._xformMode=e,this._key=t,this.reset()},reset:function(){o.reset.call(this),this._doReset()},process:function(e){return this._append(e),this._process()},finalize:function(e){return e&&this._append(e),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function e(e){return"string"==typeof e?b:y}return function(t){return{encrypt:function(i,s,r){return e(s).encrypt(t,i,s,r)},decrypt:function(i,s,r){return e(s).decrypt(t,i,s,r)}}}}()});s.StreamCipher=h.extend({_doFinalize:function(){return this._process(!0)},blockSize:1});var c=t.mode={},u=s.BlockCipherMode=r.extend({createEncryptor:function(e,t){return this.Encryptor.create(e,t)},createDecryptor:function(e,t){return this.Decryptor.create(e,t)},init:function(e,t){this._cipher=e,this._iv=t}}),p=c.CBC=function(){var t=u.extend();function i(t,i,s){var r,a=this._iv;a?(r=a,this._iv=e):r=this._prevBlock;for(var o=0;o<s;o++)t[i+o]^=r[o]}return t.Encryptor=t.extend({processBlock:function(e,t){var s=this._cipher,r=s.blockSize;i.call(this,e,t,r),s.encryptBlock(e,t),this._prevBlock=e.slice(t,t+r)}}),t.Decryptor=t.extend({processBlock:function(e,t){var s=this._cipher,r=s.blockSize,a=e.slice(t,t+r);s.decryptBlock(e,t),i.call(this,e,t,r),this._prevBlock=a}}),t}(),f=(t.pad={}).Pkcs7={pad:function(e,t){for(var i=4*t,s=i-e.sigBytes%i,r=s<<24|s<<16|s<<8|s,o=[],n=0;n<s;n+=4)o.push(r);var l=a.create(o,s);e.concat(l)},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}};s.BlockCipher=h.extend({cfg:h.cfg.extend({mode:p,padding:f}),reset:function(){var e;h.reset.call(this);var t=this.cfg,i=t.iv,s=t.mode;this._xformMode==this._ENC_XFORM_MODE?e=s.createEncryptor:(e=s.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==e?this._mode.init(this,i&&i.words):(this._mode=e.call(s,this,i&&i.words),this._mode.__creator=e)},_doProcessBlock:function(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e,t=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(t.pad(this._data,this.blockSize),e=this._process(!0)):(e=this._process(!0),t.unpad(e)),e},blockSize:4});var m=s.CipherParams=r.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),g=(t.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext,i=e.salt;return(i?a.create([1398893684,1701076831]).concat(i).concat(t):t).toString(l)},parse:function(e){var t,i=l.parse(e),s=i.words;return 1398893684==s[0]&&1701076831==s[1]&&(t=a.create(s.slice(2,4)),s.splice(0,4),i.sigBytes-=16),m.create({ciphertext:i,salt:t})}},y=s.SerializableCipher=r.extend({cfg:r.extend({format:g}),encrypt:function(e,t,i,s){s=this.cfg.extend(s);var r=e.createEncryptor(i,s),a=r.finalize(t),o=r.cfg;return m.create({ciphertext:a,key:i,iv:o.iv,algorithm:e,mode:o.mode,padding:o.padding,blockSize:e.blockSize,formatter:s.format})},decrypt:function(e,t,i,s){return s=this.cfg.extend(s),t=this._parse(t,s.format),e.createDecryptor(i,s).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}}),A=(t.kdf={}).OpenSSL={execute:function(e,t,i,s,r){if(s||(s=a.random(8)),r)o=d.create({keySize:t+i,hasher:r}).compute(e,s);else var o=d.create({keySize:t+i}).compute(e,s);var n=a.create(o.words.slice(t),4*i);return o.sigBytes=4*t,m.create({key:o,iv:n,salt:s})}},b=s.PasswordBasedCipher=y.extend({cfg:y.cfg.extend({kdf:A}),encrypt:function(e,t,i,s){var r=(s=this.cfg.extend(s)).kdf.execute(i,e.keySize,e.ivSize,s.salt,s.hasher);s.iv=r.iv;var a=y.encrypt.call(this,e,t,r.key,s);return a.mixIn(r),a},decrypt:function(e,t,i,s){s=this.cfg.extend(s),t=this._parse(t,s.format);var r=s.kdf.execute(i,e.keySize,e.ivSize,t.salt,s.hasher);return s.iv=r.iv,y.decrypt.call(this,e,t,r.key,s)}})}())})),kr((function(e,t){var i;e.exports=((i=ed).mode.CFB=function(){var e=i.lib.BlockCipherMode.extend();function t(e,t,i,s){var r,a=this._iv;a?(r=a.slice(0),this._iv=void 0):r=this._prevBlock,s.encryptBlock(r,0);for(var o=0;o<i;o++)e[t+o]^=r[o]}return e.Encryptor=e.extend({processBlock:function(e,i){var s=this._cipher,r=s.blockSize;t.call(this,e,i,r,s),this._prevBlock=e.slice(i,i+r)}}),e.Decryptor=e.extend({processBlock:function(e,i){var s=this._cipher,r=s.blockSize,a=e.slice(i,i+r);t.call(this,e,i,r,s),this._prevBlock=a}}),e}(),i.mode.CFB)})),kr((function(e,t){var i,s,r;e.exports=((r=ed).mode.CTR=(i=r.lib.BlockCipherMode.extend(),s=i.Encryptor=i.extend({processBlock:function(e,t){var i=this._cipher,s=i.blockSize,r=this._iv,a=this._counter;r&&(a=this._counter=r.slice(0),this._iv=void 0);var o=a.slice(0);i.encryptBlock(o,0),a[s-1]=a[s-1]+1|0;for(var n=0;n<s;n++)e[t+n]^=o[n]}}),i.Decryptor=s,i),r.mode.CTR)})),kr((function(e,t){var i;e.exports=((i=ed).mode.CTRGladman=function(){var e=i.lib.BlockCipherMode.extend();function t(e){if(255&~(e>>24))e+=1<<24;else{var t=e>>16&255,i=e>>8&255,s=255&e;255===t?(t=0,255===i?(i=0,255===s?s=0:++s):++i):++t,e=0,e+=t<<16,e+=i<<8,e+=s}return e}function s(e){return 0===(e[0]=t(e[0]))&&(e[1]=t(e[1])),e}var r=e.Encryptor=e.extend({processBlock:function(e,t){var i=this._cipher,r=i.blockSize,a=this._iv,o=this._counter;a&&(o=this._counter=a.slice(0),this._iv=void 0),s(o);var n=o.slice(0);i.encryptBlock(n,0);for(var l=0;l<r;l++)e[t+l]^=n[l]}});return e.Decryptor=r,e}(),i.mode.CTRGladman)})),kr((function(e,t){var i,s,r;e.exports=((r=ed).mode.OFB=(i=r.lib.BlockCipherMode.extend(),s=i.Encryptor=i.extend({processBlock:function(e,t){var i=this._cipher,s=i.blockSize,r=this._iv,a=this._keystream;r&&(a=this._keystream=r.slice(0),this._iv=void 0),i.encryptBlock(a,0);for(var o=0;o<s;o++)e[t+o]^=a[o]}}),i.Decryptor=s,i),r.mode.OFB)})),kr((function(e,t){var i,s;e.exports=((s=ed).mode.ECB=((i=s.lib.BlockCipherMode.extend()).Encryptor=i.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),i.Decryptor=i.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),i),s.mode.ECB)})),kr((function(e,t){var i;e.exports=((i=ed).pad.AnsiX923={pad:function(e,t){var i=e.sigBytes,s=4*t,r=s-i%s,a=i+r-1;e.clamp(),e.words[a>>>2]|=r<<24-a%4*8,e.sigBytes+=r},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},i.pad.Ansix923)})),kr((function(e,t){var i;e.exports=((i=ed).pad.Iso10126={pad:function(e,t){var s=4*t,r=s-e.sigBytes%s;e.concat(i.lib.WordArray.random(r-1)).concat(i.lib.WordArray.create([r<<24],1))},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},i.pad.Iso10126)})),kr((function(e,t){var i;e.exports=((i=ed).pad.Iso97971={pad:function(e,t){e.concat(i.lib.WordArray.create([2147483648],1)),i.pad.ZeroPadding.pad(e,t)},unpad:function(e){i.pad.ZeroPadding.unpad(e),e.sigBytes--}},i.pad.Iso97971)})),kr((function(e,t){var i;e.exports=((i=ed).pad.ZeroPadding={pad:function(e,t){var i=4*t;e.clamp(),e.sigBytes+=i-(e.sigBytes%i||i)},unpad:function(e){var t=e.words,i=e.sigBytes-1;for(i=e.sigBytes-1;i>=0;i--)if(t[i>>>2]>>>24-i%4*8&255){e.sigBytes=i+1;break}}},i.pad.ZeroPadding)})),kr((function(e,t){var i;e.exports=((i=ed).pad.NoPadding={pad:function(){},unpad:function(){}},i.pad.NoPadding)})),kr((function(e,t){var i;e.exports=(i=ed,function(e){var t=i,s=t.lib.CipherParams,r=t.enc.Hex;t.format.Hex={stringify:function(e){return e.ciphertext.toString(r)},parse:function(e){var t=r.parse(e);return s.create({ciphertext:t})}}}(),i.format.Hex)})),kr((function(e,t){var i;e.exports=(i=ed,function(){var e=i,t=e.lib.BlockCipher,s=e.algo,r=[],a=[],o=[],n=[],l=[],d=[],h=[],c=[],u=[],p=[];!function(){for(var e=[],t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;var i=0,s=0;for(t=0;t<256;t++){var f=s^s<<1^s<<2^s<<3^s<<4;f=f>>>8^255&f^99,r[i]=f,a[f]=i;var m=e[i],g=e[m],y=e[g],A=257*e[f]^16843008*f;o[i]=A<<24|A>>>8,n[i]=A<<16|A>>>16,l[i]=A<<8|A>>>24,d[i]=A,A=16843009*y^65537*g^257*m^16843008*i,h[f]=A<<24|A>>>8,c[f]=A<<16|A>>>16,u[f]=A<<8|A>>>24,p[f]=A,i?(i=m^e[e[e[y^m]]],s^=e[e[s]]):i=s=1}}();var f=[0,1,2,4,8,16,32,64,128,27,54],m=s.AES=t.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var e=this._keyPriorReset=this._key,t=e.words,i=e.sigBytes/4,s=4*((this._nRounds=i+6)+1),a=this._keySchedule=[],o=0;o<s;o++)o<i?a[o]=t[o]:(d=a[o-1],o%i?i>6&&o%i==4&&(d=r[d>>>24]<<24|r[d>>>16&255]<<16|r[d>>>8&255]<<8|r[255&d]):(d=r[(d=d<<8|d>>>24)>>>24]<<24|r[d>>>16&255]<<16|r[d>>>8&255]<<8|r[255&d],d^=f[o/i|0]<<24),a[o]=a[o-i]^d);for(var n=this._invKeySchedule=[],l=0;l<s;l++){if(o=s-l,l%4)var d=a[o];else d=a[o-4];n[l]=l<4||o<=4?d:h[r[d>>>24]]^c[r[d>>>16&255]]^u[r[d>>>8&255]]^p[r[255&d]]}}},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,o,n,l,d,r)},decryptBlock:function(e,t){var i=e[t+1];e[t+1]=e[t+3],e[t+3]=i,this._doCryptBlock(e,t,this._invKeySchedule,h,c,u,p,a),i=e[t+1],e[t+1]=e[t+3],e[t+3]=i},_doCryptBlock:function(e,t,i,s,r,a,o,n){for(var l=this._nRounds,d=e[t]^i[0],h=e[t+1]^i[1],c=e[t+2]^i[2],u=e[t+3]^i[3],p=4,f=1;f<l;f++){var m=s[d>>>24]^r[h>>>16&255]^a[c>>>8&255]^o[255&u]^i[p++],g=s[h>>>24]^r[c>>>16&255]^a[u>>>8&255]^o[255&d]^i[p++],y=s[c>>>24]^r[u>>>16&255]^a[d>>>8&255]^o[255&h]^i[p++],A=s[u>>>24]^r[d>>>16&255]^a[h>>>8&255]^o[255&c]^i[p++];d=m,h=g,c=y,u=A}m=(n[d>>>24]<<24|n[h>>>16&255]<<16|n[c>>>8&255]<<8|n[255&u])^i[p++],g=(n[h>>>24]<<24|n[c>>>16&255]<<16|n[u>>>8&255]<<8|n[255&d])^i[p++],y=(n[c>>>24]<<24|n[u>>>16&255]<<16|n[d>>>8&255]<<8|n[255&h])^i[p++],A=(n[u>>>24]<<24|n[d>>>16&255]<<16|n[h>>>8&255]<<8|n[255&c])^i[p++],e[t]=m,e[t+1]=g,e[t+2]=y,e[t+3]=A},keySize:8});e.AES=t._createHelper(m)}(),i.AES)})),kr((function(e,t){var i;e.exports=(i=ed,function(){var e=i,t=e.lib,s=t.WordArray,r=t.BlockCipher,a=e.algo,o=[57,49,41,33,25,17,9,1,58,50,42,34,26,18,10,2,59,51,43,35,27,19,11,3,60,52,44,36,63,55,47,39,31,23,15,7,62,54,46,38,30,22,14,6,61,53,45,37,29,21,13,5,28,20,12,4],n=[14,17,11,24,1,5,3,28,15,6,21,10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,37,47,55,30,40,51,45,33,48,44,49,39,56,34,53,46,42,50,36,29,32],l=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],d=[{0:8421888,268435456:32768,536870912:8421378,805306368:2,1073741824:512,1342177280:8421890,1610612736:8389122,1879048192:8388608,2147483648:514,2415919104:8389120,2684354560:33280,2952790016:8421376,3221225472:32770,3489660928:8388610,3758096384:0,4026531840:33282,134217728:0,402653184:8421890,671088640:33282,939524096:32768,1207959552:8421888,1476395008:512,1744830464:8421378,2013265920:2,2281701376:8389120,2550136832:33280,2818572288:8421376,3087007744:8389122,3355443200:8388610,3623878656:32770,3892314112:514,4160749568:8388608,1:32768,268435457:2,536870913:8421888,805306369:8388608,1073741825:8421378,1342177281:33280,1610612737:512,1879048193:8389122,2147483649:8421890,2415919105:8421376,2684354561:8388610,2952790017:33282,3221225473:514,3489660929:8389120,3758096385:32770,4026531841:0,134217729:8421890,402653185:8421376,671088641:8388608,939524097:512,1207959553:32768,1476395009:8388610,1744830465:2,2013265921:33282,2281701377:32770,2550136833:8389122,2818572289:514,3087007745:8421888,3355443201:8389120,3623878657:0,3892314113:33280,4160749569:8421378},{0:1074282512,16777216:16384,33554432:524288,50331648:1074266128,67108864:1073741840,83886080:1074282496,100663296:1073758208,117440512:16,134217728:540672,150994944:1073758224,167772160:1073741824,184549376:540688,201326592:524304,218103808:0,234881024:16400,251658240:1074266112,8388608:1073758208,25165824:540688,41943040:16,58720256:1073758224,75497472:1074282512,92274688:1073741824,109051904:524288,125829120:1074266128,142606336:524304,159383552:0,176160768:16384,192937984:1074266112,209715200:1073741840,226492416:540672,243269632:1074282496,260046848:16400,268435456:0,285212672:1074266128,301989888:1073758224,318767104:1074282496,335544320:1074266112,352321536:16,369098752:540688,385875968:16384,402653184:16400,419430400:524288,436207616:524304,452984832:1073741840,469762048:540672,486539264:1073758208,503316480:1073741824,520093696:1074282512,276824064:540688,293601280:524288,310378496:1074266112,327155712:16384,343932928:1073758208,360710144:1074282512,377487360:16,394264576:1073741824,411041792:1074282496,427819008:1073741840,444596224:1073758224,461373440:524304,478150656:0,494927872:16400,511705088:1074266128,528482304:540672},{0:260,1048576:0,2097152:67109120,3145728:65796,4194304:65540,5242880:67108868,6291456:67174660,7340032:67174400,8388608:67108864,9437184:67174656,10485760:65792,11534336:67174404,12582912:67109124,13631488:65536,14680064:4,15728640:256,524288:67174656,1572864:67174404,2621440:0,3670016:67109120,4718592:67108868,5767168:65536,6815744:65540,7864320:260,8912896:4,9961472:256,11010048:67174400,12058624:65796,13107200:65792,14155776:67109124,15204352:67174660,16252928:67108864,16777216:67174656,17825792:65540,18874368:65536,19922944:67109120,20971520:256,22020096:67174660,23068672:67108868,24117248:0,25165824:67109124,26214400:67108864,27262976:4,28311552:65792,29360128:67174400,30408704:260,31457280:65796,32505856:67174404,17301504:67108864,18350080:260,19398656:67174656,20447232:0,21495808:65540,22544384:67109120,23592960:256,24641536:67174404,25690112:65536,26738688:67174660,27787264:65796,28835840:67108868,29884416:67109124,30932992:67174400,31981568:4,33030144:65792},{0:2151682048,65536:2147487808,131072:4198464,196608:2151677952,262144:0,327680:4198400,393216:2147483712,458752:4194368,524288:2147483648,589824:4194304,655360:64,720896:2147487744,786432:2151678016,851968:4160,917504:4096,983040:2151682112,32768:2147487808,98304:64,163840:2151678016,229376:2147487744,294912:4198400,360448:2151682112,425984:0,491520:2151677952,557056:4096,622592:2151682048,688128:4194304,753664:4160,819200:2147483648,884736:4194368,950272:4198464,1015808:2147483712,1048576:4194368,1114112:4198400,1179648:2147483712,1245184:0,1310720:4160,1376256:2151678016,1441792:2151682048,1507328:2147487808,1572864:2151682112,1638400:2147483648,1703936:2151677952,1769472:4198464,1835008:2147487744,1900544:4194304,1966080:64,2031616:4096,1081344:2151677952,1146880:2151682112,1212416:0,1277952:4198400,1343488:4194368,1409024:2147483648,1474560:2147487808,1540096:64,1605632:2147483712,1671168:4096,1736704:2147487744,1802240:2151678016,1867776:4160,1933312:2151682048,1998848:4194304,2064384:4198464},{0:128,4096:17039360,8192:262144,12288:536870912,16384:537133184,20480:16777344,24576:553648256,28672:262272,32768:16777216,36864:537133056,40960:536871040,45056:553910400,49152:553910272,53248:0,57344:17039488,61440:553648128,2048:17039488,6144:553648256,10240:128,14336:17039360,18432:262144,22528:537133184,26624:553910272,30720:536870912,34816:537133056,38912:0,43008:553910400,47104:16777344,51200:536871040,55296:553648128,59392:16777216,63488:262272,65536:262144,69632:128,73728:536870912,77824:553648256,81920:16777344,86016:553910272,90112:537133184,94208:16777216,98304:553910400,102400:553648128,106496:17039360,110592:537133056,114688:262272,118784:536871040,122880:0,126976:17039488,67584:553648256,71680:16777216,75776:17039360,79872:537133184,83968:536870912,88064:17039488,92160:128,96256:553910272,100352:262272,104448:553910400,108544:0,112640:553648128,116736:16777344,120832:262144,124928:537133056,129024:536871040},{0:268435464,256:8192,512:270532608,768:270540808,1024:268443648,1280:2097152,1536:2097160,1792:268435456,2048:0,2304:268443656,2560:2105344,2816:8,3072:270532616,3328:2105352,3584:8200,3840:270540800,128:270532608,384:270540808,640:8,896:2097152,1152:2105352,1408:268435464,1664:268443648,1920:8200,2176:2097160,2432:8192,2688:268443656,2944:270532616,3200:0,3456:270540800,3712:2105344,3968:268435456,4096:268443648,4352:270532616,4608:270540808,4864:8200,5120:2097152,5376:268435456,5632:268435464,5888:2105344,6144:2105352,6400:0,6656:8,6912:270532608,7168:8192,7424:268443656,7680:270540800,7936:2097160,4224:8,4480:2105344,4736:2097152,4992:268435464,5248:268443648,5504:8200,5760:270540808,6016:270532608,6272:270540800,6528:270532616,6784:8192,7040:2105352,7296:2097160,7552:0,7808:268435456,8064:268443656},{0:1048576,16:33555457,32:1024,48:1049601,64:34604033,80:0,96:1,112:34603009,128:33555456,144:1048577,160:33554433,176:34604032,192:34603008,208:1025,224:1049600,240:33554432,8:34603009,24:0,40:33555457,56:34604032,72:1048576,88:33554433,104:33554432,120:1025,136:1049601,152:33555456,168:34603008,184:1048577,200:1024,216:34604033,232:1,248:1049600,256:33554432,272:1048576,288:33555457,304:34603009,320:1048577,336:33555456,352:34604032,368:1049601,384:1025,400:34604033,416:1049600,432:1,448:0,464:34603008,480:33554433,496:1024,264:1049600,280:33555457,296:34603009,312:1,328:33554432,344:1048576,360:1025,376:34604032,392:33554433,408:34603008,424:0,440:34604033,456:1049601,472:1024,488:33555456,504:1048577},{0:134219808,1:131072,2:134217728,3:32,4:131104,5:134350880,6:134350848,7:2048,8:134348800,9:134219776,10:133120,11:134348832,12:2080,13:0,14:134217760,15:133152,2147483648:2048,2147483649:134350880,2147483650:134219808,2147483651:134217728,2147483652:134348800,2147483653:133120,2147483654:133152,2147483655:32,2147483656:134217760,2147483657:2080,2147483658:131104,2147483659:134350848,2147483660:0,2147483661:134348832,2147483662:134219776,2147483663:131072,16:133152,17:134350848,18:32,19:2048,20:134219776,21:134217760,22:134348832,23:131072,24:0,25:131104,26:134348800,27:134219808,28:134350880,29:133120,30:2080,31:134217728,2147483664:131072,2147483665:2048,2147483666:134348832,2147483667:133152,2147483668:32,2147483669:134348800,2147483670:134217728,2147483671:134219808,2147483672:134350880,2147483673:134217760,2147483674:134219776,2147483675:0,2147483676:133120,2147483677:2080,2147483678:131104,2147483679:134350848}],h=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],c=a.DES=r.extend({_doReset:function(){for(var e=this._key.words,t=[],i=0;i<56;i++){var s=o[i]-1;t[i]=e[s>>>5]>>>31-s%32&1}for(var r=this._subKeys=[],a=0;a<16;a++){var d=r[a]=[],h=l[a];for(i=0;i<24;i++)d[i/6|0]|=t[(n[i]-1+h)%28]<<31-i%6,d[4+(i/6|0)]|=t[28+(n[i+24]-1+h)%28]<<31-i%6;for(d[0]=d[0]<<1|d[0]>>>31,i=1;i<7;i++)d[i]=d[i]>>>4*(i-1)+3;d[7]=d[7]<<5|d[7]>>>27}var c=this._invSubKeys=[];for(i=0;i<16;i++)c[i]=r[15-i]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._subKeys)},decryptBlock:function(e,t){this._doCryptBlock(e,t,this._invSubKeys)},_doCryptBlock:function(e,t,i){this._lBlock=e[t],this._rBlock=e[t+1],u.call(this,4,252645135),u.call(this,16,65535),p.call(this,2,858993459),p.call(this,8,16711935),u.call(this,1,1431655765);for(var s=0;s<16;s++){for(var r=i[s],a=this._lBlock,o=this._rBlock,n=0,l=0;l<8;l++)n|=d[l][((o^r[l])&h[l])>>>0];this._lBlock=o,this._rBlock=a^n}var c=this._lBlock;this._lBlock=this._rBlock,this._rBlock=c,u.call(this,1,1431655765),p.call(this,8,16711935),p.call(this,2,858993459),u.call(this,16,65535),u.call(this,4,252645135),e[t]=this._lBlock,e[t+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});function u(e,t){var i=(this._lBlock>>>e^this._rBlock)&t;this._rBlock^=i,this._lBlock^=i<<e}function p(e,t){var i=(this._rBlock>>>e^this._lBlock)&t;this._lBlock^=i,this._rBlock^=i<<e}e.DES=r._createHelper(c);var f=a.TripleDES=r.extend({_doReset:function(){var e=this._key.words;if(2!==e.length&&4!==e.length&&e.length<6)throw new Error("Invalid key length - 3DES requires the key length to be 64, 128, 192 or >192.");var t=e.slice(0,2),i=e.length<4?e.slice(0,2):e.slice(2,4),r=e.length<6?e.slice(0,2):e.slice(4,6);this._des1=c.createEncryptor(s.create(t)),this._des2=c.createEncryptor(s.create(i)),this._des3=c.createEncryptor(s.create(r))},encryptBlock:function(e,t){this._des1.encryptBlock(e,t),this._des2.decryptBlock(e,t),this._des3.encryptBlock(e,t)},decryptBlock:function(e,t){this._des3.decryptBlock(e,t),this._des2.encryptBlock(e,t),this._des1.decryptBlock(e,t)},keySize:6,ivSize:2,blockSize:2});e.TripleDES=r._createHelper(f)}(),i.TripleDES)})),kr((function(e,t){var i;e.exports=(i=ed,function(){var e=i,t=e.lib.StreamCipher,s=e.algo,r=s.RC4=t.extend({_doReset:function(){for(var e=this._key,t=e.words,i=e.sigBytes,s=this._S=[],r=0;r<256;r++)s[r]=r;r=0;for(var a=0;r<256;r++){var o=r%i,n=t[o>>>2]>>>24-o%4*8&255;a=(a+s[r]+n)%256;var l=s[r];s[r]=s[a],s[a]=l}this._i=this._j=0},_doProcessBlock:function(e,t){e[t]^=a.call(this)},keySize:8,ivSize:0});function a(){for(var e=this._S,t=this._i,i=this._j,s=0,r=0;r<4;r++){i=(i+e[t=(t+1)%256])%256;var a=e[t];e[t]=e[i],e[i]=a,s|=e[(e[t]+e[i])%256]<<24-8*r}return this._i=t,this._j=i,s}e.RC4=t._createHelper(r);var o=s.RC4Drop=r.extend({cfg:r.cfg.extend({drop:192}),_doReset:function(){r._doReset.call(this);for(var e=this.cfg.drop;e>0;e--)a.call(this)}});e.RC4Drop=t._createHelper(o)}(),i.RC4)})),kr((function(e,t){var i;e.exports=(i=ed,function(){var e=i,t=e.lib.StreamCipher,s=e.algo,r=[],a=[],o=[],n=s.Rabbit=t.extend({_doReset:function(){for(var e=this._key.words,t=this.cfg.iv,i=0;i<4;i++)e[i]=16711935&(e[i]<<8|e[i]>>>24)|4278255360&(e[i]<<24|e[i]>>>8);var s=this._X=[e[0],e[3]<<16|e[2]>>>16,e[1],e[0]<<16|e[3]>>>16,e[2],e[1]<<16|e[0]>>>16,e[3],e[2]<<16|e[1]>>>16],r=this._C=[e[2]<<16|e[2]>>>16,4294901760&e[0]|65535&e[1],e[3]<<16|e[3]>>>16,4294901760&e[1]|65535&e[2],e[0]<<16|e[0]>>>16,4294901760&e[2]|65535&e[3],e[1]<<16|e[1]>>>16,4294901760&e[3]|65535&e[0]];for(this._b=0,i=0;i<4;i++)l.call(this);for(i=0;i<8;i++)r[i]^=s[i+4&7];if(t){var a=t.words,o=a[0],n=a[1],d=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),h=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8),c=d>>>16|4294901760&h,u=h<<16|65535&d;for(r[0]^=d,r[1]^=c,r[2]^=h,r[3]^=u,r[4]^=d,r[5]^=c,r[6]^=h,r[7]^=u,i=0;i<4;i++)l.call(this)}},_doProcessBlock:function(e,t){var i=this._X;l.call(this),r[0]=i[0]^i[5]>>>16^i[3]<<16,r[1]=i[2]^i[7]>>>16^i[5]<<16,r[2]=i[4]^i[1]>>>16^i[7]<<16,r[3]=i[6]^i[3]>>>16^i[1]<<16;for(var s=0;s<4;s++)r[s]=16711935&(r[s]<<8|r[s]>>>24)|4278255360&(r[s]<<24|r[s]>>>8),e[t+s]^=r[s]},blockSize:4,ivSize:2});function l(){for(var e=this._X,t=this._C,i=0;i<8;i++)a[i]=t[i];for(t[0]=t[0]+1295307597+this._b|0,t[1]=t[1]+3545052371+(t[0]>>>0<a[0]>>>0?1:0)|0,t[2]=t[2]+886263092+(t[1]>>>0<a[1]>>>0?1:0)|0,t[3]=t[3]+1295307597+(t[2]>>>0<a[2]>>>0?1:0)|0,t[4]=t[4]+3545052371+(t[3]>>>0<a[3]>>>0?1:0)|0,t[5]=t[5]+886263092+(t[4]>>>0<a[4]>>>0?1:0)|0,t[6]=t[6]+1295307597+(t[5]>>>0<a[5]>>>0?1:0)|0,t[7]=t[7]+3545052371+(t[6]>>>0<a[6]>>>0?1:0)|0,this._b=t[7]>>>0<a[7]>>>0?1:0,i=0;i<8;i++){var s=e[i]+t[i],r=65535&s,n=s>>>16,l=((r*r>>>17)+r*n>>>15)+n*n,d=((4294901760&s)*s|0)+((65535&s)*s|0);o[i]=l^d}e[0]=o[0]+(o[7]<<16|o[7]>>>16)+(o[6]<<16|o[6]>>>16)|0,e[1]=o[1]+(o[0]<<8|o[0]>>>24)+o[7]|0,e[2]=o[2]+(o[1]<<16|o[1]>>>16)+(o[0]<<16|o[0]>>>16)|0,e[3]=o[3]+(o[2]<<8|o[2]>>>24)+o[1]|0,e[4]=o[4]+(o[3]<<16|o[3]>>>16)+(o[2]<<16|o[2]>>>16)|0,e[5]=o[5]+(o[4]<<8|o[4]>>>24)+o[3]|0,e[6]=o[6]+(o[5]<<16|o[5]>>>16)+(o[4]<<16|o[4]>>>16)|0,e[7]=o[7]+(o[6]<<8|o[6]>>>24)+o[5]|0}e.Rabbit=t._createHelper(n)}(),i.Rabbit)})),kr((function(e,t){var i;e.exports=(i=ed,function(){var e=i,t=e.lib.StreamCipher,s=e.algo,r=[],a=[],o=[],n=s.RabbitLegacy=t.extend({_doReset:function(){var e=this._key.words,t=this.cfg.iv,i=this._X=[e[0],e[3]<<16|e[2]>>>16,e[1],e[0]<<16|e[3]>>>16,e[2],e[1]<<16|e[0]>>>16,e[3],e[2]<<16|e[1]>>>16],s=this._C=[e[2]<<16|e[2]>>>16,4294901760&e[0]|65535&e[1],e[3]<<16|e[3]>>>16,4294901760&e[1]|65535&e[2],e[0]<<16|e[0]>>>16,4294901760&e[2]|65535&e[3],e[1]<<16|e[1]>>>16,4294901760&e[3]|65535&e[0]];this._b=0;for(var r=0;r<4;r++)l.call(this);for(r=0;r<8;r++)s[r]^=i[r+4&7];if(t){var a=t.words,o=a[0],n=a[1],d=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),h=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8),c=d>>>16|4294901760&h,u=h<<16|65535&d;for(s[0]^=d,s[1]^=c,s[2]^=h,s[3]^=u,s[4]^=d,s[5]^=c,s[6]^=h,s[7]^=u,r=0;r<4;r++)l.call(this)}},_doProcessBlock:function(e,t){var i=this._X;l.call(this),r[0]=i[0]^i[5]>>>16^i[3]<<16,r[1]=i[2]^i[7]>>>16^i[5]<<16,r[2]=i[4]^i[1]>>>16^i[7]<<16,r[3]=i[6]^i[3]>>>16^i[1]<<16;for(var s=0;s<4;s++)r[s]=16711935&(r[s]<<8|r[s]>>>24)|4278255360&(r[s]<<24|r[s]>>>8),e[t+s]^=r[s]},blockSize:4,ivSize:2});function l(){for(var e=this._X,t=this._C,i=0;i<8;i++)a[i]=t[i];for(t[0]=t[0]+1295307597+this._b|0,t[1]=t[1]+3545052371+(t[0]>>>0<a[0]>>>0?1:0)|0,t[2]=t[2]+886263092+(t[1]>>>0<a[1]>>>0?1:0)|0,t[3]=t[3]+1295307597+(t[2]>>>0<a[2]>>>0?1:0)|0,t[4]=t[4]+3545052371+(t[3]>>>0<a[3]>>>0?1:0)|0,t[5]=t[5]+886263092+(t[4]>>>0<a[4]>>>0?1:0)|0,t[6]=t[6]+1295307597+(t[5]>>>0<a[5]>>>0?1:0)|0,t[7]=t[7]+3545052371+(t[6]>>>0<a[6]>>>0?1:0)|0,this._b=t[7]>>>0<a[7]>>>0?1:0,i=0;i<8;i++){var s=e[i]+t[i],r=65535&s,n=s>>>16,l=((r*r>>>17)+r*n>>>15)+n*n,d=((4294901760&s)*s|0)+((65535&s)*s|0);o[i]=l^d}e[0]=o[0]+(o[7]<<16|o[7]>>>16)+(o[6]<<16|o[6]>>>16)|0,e[1]=o[1]+(o[0]<<8|o[0]>>>24)+o[7]|0,e[2]=o[2]+(o[1]<<16|o[1]>>>16)+(o[0]<<16|o[0]>>>16)|0,e[3]=o[3]+(o[2]<<8|o[2]>>>24)+o[1]|0,e[4]=o[4]+(o[3]<<16|o[3]>>>16)+(o[2]<<16|o[2]>>>16)|0,e[5]=o[5]+(o[4]<<8|o[4]>>>24)+o[3]|0,e[6]=o[6]+(o[5]<<16|o[5]>>>16)+(o[4]<<16|o[4]>>>16)|0,e[7]=o[7]+(o[6]<<8|o[6]>>>24)+o[5]|0}e.RabbitLegacy=t._createHelper(n)}(),i.RabbitLegacy)})),kr((function(e,t){var i;e.exports=(i=ed,function(){var e=i,t=e.lib.BlockCipher,s=e.algo;const r=16,a=[608135816,2242054355,320440878,57701188,2752067618,698298832,137296536,3964562569,1160258022,953160567,3193202383,887688300,3232508343,3380367581,1065670069,3041331479,2450970073,2306472731],o=[[3509652390,2564797868,805139163,3491422135,3101798381,1780907670,3128725573,4046225305,614570311,3012652279,134345442,2240740374,1667834072,1901547113,2757295779,4103290238,227898511,1921955416,1904987480,2182433518,2069144605,3260701109,2620446009,720527379,3318853667,677414384,3393288472,3101374703,2390351024,1614419982,1822297739,2954791486,3608508353,3174124327,2024746970,1432378464,3864339955,2857741204,1464375394,1676153920,1439316330,715854006,3033291828,289532110,2706671279,2087905683,3018724369,1668267050,732546397,1947742710,3462151702,2609353502,2950085171,1814351708,2050118529,680887927,999245976,1800124847,3300911131,1713906067,1641548236,4213287313,1216130144,1575780402,4018429277,3917837745,3693486850,3949271944,596196993,3549867205,258830323,2213823033,772490370,2760122372,1774776394,2652871518,566650946,4142492826,1728879713,2882767088,1783734482,3629395816,2517608232,2874225571,1861159788,326777828,3124490320,2130389656,2716951837,967770486,1724537150,2185432712,2364442137,1164943284,2105845187,998989502,3765401048,2244026483,1075463327,1455516326,1322494562,910128902,469688178,1117454909,936433444,3490320968,3675253459,1240580251,122909385,2157517691,634681816,4142456567,3825094682,3061402683,2540495037,79693498,3249098678,1084186820,1583128258,426386531,1761308591,1047286709,322548459,995290223,1845252383,2603652396,3431023940,2942221577,3202600964,3727903485,1712269319,422464435,3234572375,1170764815,3523960633,3117677531,1434042557,442511882,3600875718,1076654713,1738483198,4213154764,2393238008,3677496056,1014306527,4251020053,793779912,2902807211,842905082,4246964064,1395751752,1040244610,2656851899,3396308128,445077038,3742853595,3577915638,679411651,2892444358,2354009459,1767581616,3150600392,3791627101,3102740896,284835224,4246832056,1258075500,768725851,2589189241,3069724005,3532540348,1274779536,3789419226,2764799539,1660621633,3471099624,4011903706,913787905,3497959166,737222580,2514213453,2928710040,3937242737,1804850592,3499020752,2949064160,2386320175,2390070455,2415321851,4061277028,2290661394,2416832540,1336762016,1754252060,3520065937,3014181293,791618072,3188594551,3933548030,2332172193,3852520463,3043980520,413987798,3465142937,3030929376,4245938359,2093235073,3534596313,375366246,2157278981,2479649556,555357303,3870105701,2008414854,3344188149,4221384143,3956125452,2067696032,3594591187,2921233993,2428461,544322398,577241275,1471733935,610547355,4027169054,1432588573,1507829418,2025931657,3646575487,545086370,48609733,2200306550,1653985193,298326376,1316178497,3007786442,2064951626,458293330,2589141269,3591329599,3164325604,727753846,2179363840,146436021,1461446943,4069977195,705550613,3059967265,3887724982,4281599278,3313849956,1404054877,2845806497,146425753,1854211946],[1266315497,3048417604,3681880366,3289982499,290971e4,1235738493,2632868024,2414719590,3970600049,1771706367,1449415276,3266420449,422970021,1963543593,2690192192,3826793022,1062508698,1531092325,1804592342,2583117782,2714934279,4024971509,1294809318,4028980673,1289560198,2221992742,1669523910,35572830,157838143,1052438473,1016535060,1802137761,1753167236,1386275462,3080475397,2857371447,1040679964,2145300060,2390574316,1461121720,2956646967,4031777805,4028374788,33600511,2920084762,1018524850,629373528,3691585981,3515945977,2091462646,2486323059,586499841,988145025,935516892,3367335476,2599673255,2839830854,265290510,3972581182,2759138881,3795373465,1005194799,847297441,406762289,1314163512,1332590856,1866599683,4127851711,750260880,613907577,1450815602,3165620655,3734664991,3650291728,3012275730,3704569646,1427272223,778793252,1343938022,2676280711,2052605720,1946737175,3164576444,3914038668,3967478842,3682934266,1661551462,3294938066,4011595847,840292616,3712170807,616741398,312560963,711312465,1351876610,322626781,1910503582,271666773,2175563734,1594956187,70604529,3617834859,1007753275,1495573769,4069517037,2549218298,2663038764,504708206,2263041392,3941167025,2249088522,1514023603,1998579484,1312622330,694541497,2582060303,2151582166,1382467621,776784248,2618340202,3323268794,2497899128,2784771155,503983604,4076293799,907881277,423175695,432175456,1378068232,4145222326,3954048622,3938656102,3820766613,2793130115,2977904593,26017576,3274890735,3194772133,1700274565,1756076034,4006520079,3677328699,720338349,1533947780,354530856,688349552,3973924725,1637815568,332179504,3949051286,53804574,2852348879,3044236432,1282449977,3583942155,3416972820,4006381244,1617046695,2628476075,3002303598,1686838959,431878346,2686675385,1700445008,1080580658,1009431731,832498133,3223435511,2605976345,2271191193,2516031870,1648197032,4164389018,2548247927,300782431,375919233,238389289,3353747414,2531188641,2019080857,1475708069,455242339,2609103871,448939670,3451063019,1395535956,2413381860,1841049896,1491858159,885456874,4264095073,4001119347,1565136089,3898914787,1108368660,540939232,1173283510,2745871338,3681308437,4207628240,3343053890,4016749493,1699691293,1103962373,3625875870,2256883143,3830138730,1031889488,3479347698,1535977030,4236805024,3251091107,2132092099,1774941330,1199868427,1452454533,157007616,2904115357,342012276,595725824,1480756522,206960106,497939518,591360097,863170706,2375253569,3596610801,1814182875,2094937945,3421402208,1082520231,3463918190,2785509508,435703966,3908032597,1641649973,2842273706,3305899714,1510255612,2148256476,2655287854,3276092548,4258621189,236887753,3681803219,274041037,1734335097,3815195456,3317970021,1899903192,1026095262,4050517792,356393447,2410691914,3873677099,3682840055],[3913112168,2491498743,4132185628,2489919796,1091903735,1979897079,3170134830,3567386728,3557303409,857797738,1136121015,1342202287,507115054,2535736646,337727348,3213592640,1301675037,2528481711,1895095763,1721773893,3216771564,62756741,2142006736,835421444,2531993523,1442658625,3659876326,2882144922,676362277,1392781812,170690266,3921047035,1759253602,3611846912,1745797284,664899054,1329594018,3901205900,3045908486,2062866102,2865634940,3543621612,3464012697,1080764994,553557557,3656615353,3996768171,991055499,499776247,1265440854,648242737,3940784050,980351604,3713745714,1749149687,3396870395,4211799374,3640570775,1161844396,3125318951,1431517754,545492359,4268468663,3499529547,1437099964,2702547544,3433638243,2581715763,2787789398,1060185593,1593081372,2418618748,4260947970,69676912,2159744348,86519011,2512459080,3838209314,1220612927,3339683548,133810670,1090789135,1078426020,1569222167,845107691,3583754449,4072456591,1091646820,628848692,1613405280,3757631651,526609435,236106946,48312990,2942717905,3402727701,1797494240,859738849,992217954,4005476642,2243076622,3870952857,3732016268,765654824,3490871365,2511836413,1685915746,3888969200,1414112111,2273134842,3281911079,4080962846,172450625,2569994100,980381355,4109958455,2819808352,2716589560,2568741196,3681446669,3329971472,1835478071,660984891,3704678404,4045999559,3422617507,3040415634,1762651403,1719377915,3470491036,2693910283,3642056355,3138596744,1364962596,2073328063,1983633131,926494387,3423689081,2150032023,4096667949,1749200295,3328846651,309677260,2016342300,1779581495,3079819751,111262694,1274766160,443224088,298511866,1025883608,3806446537,1145181785,168956806,3641502830,3584813610,1689216846,3666258015,3200248200,1692713982,2646376535,4042768518,1618508792,1610833997,3523052358,4130873264,2001055236,3610705100,2202168115,4028541809,2961195399,1006657119,2006996926,3186142756,1430667929,3210227297,1314452623,4074634658,4101304120,2273951170,1399257539,3367210612,3027628629,1190975929,2062231137,2333990788,2221543033,2438960610,1181637006,548689776,2362791313,3372408396,3104550113,3145860560,296247880,1970579870,3078560182,3769228297,1714227617,3291629107,3898220290,166772364,1251581989,493813264,448347421,195405023,2709975567,677966185,3703036547,1463355134,2715995803,1338867538,1343315457,2802222074,2684532164,233230375,2599980071,2000651841,3277868038,1638401717,4028070440,3237316320,6314154,819756386,300326615,590932579,1405279636,3267499572,3150704214,2428286686,3959192993,3461946742,1862657033,1266418056,963775037,2089974820,2263052895,1917689273,448879540,3550394620,3981727096,150775221,3627908307,1303187396,508620638,2975983352,2726630617,1817252668,1876281319,1457606340,908771278,3720792119,3617206836,2455994898,1729034894,1080033504],[976866871,3556439503,2881648439,1522871579,1555064734,1336096578,3548522304,2579274686,3574697629,3205460757,3593280638,3338716283,3079412587,564236357,2993598910,1781952180,1464380207,3163844217,3332601554,1699332808,1393555694,1183702653,3581086237,1288719814,691649499,2847557200,2895455976,3193889540,2717570544,1781354906,1676643554,2592534050,3230253752,1126444790,2770207658,2633158820,2210423226,2615765581,2414155088,3127139286,673620729,2805611233,1269405062,4015350505,3341807571,4149409754,1057255273,2012875353,2162469141,2276492801,2601117357,993977747,3918593370,2654263191,753973209,36408145,2530585658,25011837,3520020182,2088578344,530523599,2918365339,1524020338,1518925132,3760827505,3759777254,1202760957,3985898139,3906192525,674977740,4174734889,2031300136,2019492241,3983892565,4153806404,3822280332,352677332,2297720250,60907813,90501309,3286998549,1016092578,2535922412,2839152426,457141659,509813237,4120667899,652014361,1966332200,2975202805,55981186,2327461051,676427537,3255491064,2882294119,3433927263,1307055953,942726286,933058658,2468411793,3933900994,4215176142,1361170020,2001714738,2830558078,3274259782,1222529897,1679025792,2729314320,3714953764,1770335741,151462246,3013232138,1682292957,1483529935,471910574,1539241949,458788160,3436315007,1807016891,3718408830,978976581,1043663428,3165965781,1927990952,4200891579,2372276910,3208408903,3533431907,1412390302,2931980059,4132332400,1947078029,3881505623,4168226417,2941484381,1077988104,1320477388,886195818,18198404,3786409e3,2509781533,112762804,3463356488,1866414978,891333506,18488651,661792760,1628790961,3885187036,3141171499,876946877,2693282273,1372485963,791857591,2686433993,3759982718,3167212022,3472953795,2716379847,445679433,3561995674,3504004811,3574258232,54117162,3331405415,2381918588,3769707343,4154350007,1140177722,4074052095,668550556,3214352940,367459370,261225585,2610173221,4209349473,3468074219,3265815641,314222801,3066103646,3808782860,282218597,3406013506,3773591054,379116347,1285071038,846784868,2669647154,3771962079,3550491691,2305946142,453669953,1268987020,3317592352,3279303384,3744833421,2610507566,3859509063,266596637,3847019092,517658769,3462560207,3443424879,370717030,4247526661,2224018117,4143653529,4112773975,2788324899,2477274417,1456262402,2901442914,1517677493,1846949527,2295493580,3734397586,2176403920,1280348187,1908823572,3871786941,846861322,1172426758,3287448474,3383383037,1655181056,3139813346,901632758,1897031941,2986607138,3066810236,3447102507,1393639104,373351379,950779232,625454576,3124240540,4148612726,2007998917,544563296,2244738638,2330496472,2058025392,1291430526,424198748,50039436,29584100,3605783033,2429876329,2791104160,1057563949,3255363231,3075367218,3463963227,1469046755,985887462]];var n={pbox:[],sbox:[]};function l(e,t){let i=t>>24&255,s=t>>16&255,r=t>>8&255,a=255&t,o=e.sbox[0][i]+e.sbox[1][s];return o^=e.sbox[2][r],o+=e.sbox[3][a],o}function d(e,t,i){let s,a=t,o=i;for(let t=0;t<r;++t)a^=e.pbox[t],o=l(e,a)^o,s=a,a=o,o=s;return s=a,a=o,o=s,o^=e.pbox[r],a^=e.pbox[r+1],{left:a,right:o}}function h(e,t,i){let s,a=t,o=i;for(let t=r+1;t>1;--t)a^=e.pbox[t],o=l(e,a)^o,s=a,a=o,o=s;return s=a,a=o,o=s,o^=e.pbox[1],a^=e.pbox[0],{left:a,right:o}}function c(e,t,i){for(let t=0;t<4;t++){e.sbox[t]=[];for(let i=0;i<256;i++)e.sbox[t][i]=o[t][i]}let s=0;for(let o=0;o<r+2;o++)e.pbox[o]=a[o]^t[s],s++,s>=i&&(s=0);let n=0,l=0,h=0;for(let t=0;t<r+2;t+=2)h=d(e,n,l),n=h.left,l=h.right,e.pbox[t]=n,e.pbox[t+1]=l;for(let t=0;t<4;t++)for(let i=0;i<256;i+=2)h=d(e,n,l),n=h.left,l=h.right,e.sbox[t][i]=n,e.sbox[t][i+1]=l;return!0}var u=s.Blowfish=t.extend({_doReset:function(){if(this._keyPriorReset!==this._key){var e=this._keyPriorReset=this._key,t=e.words,i=e.sigBytes/4;c(n,t,i)}},encryptBlock:function(e,t){var i=d(n,e[t],e[t+1]);e[t]=i.left,e[t+1]=i.right},decryptBlock:function(e,t){var i=h(n,e[t],e[t+1]);e[t]=i.left,e[t+1]=i.right},blockSize:2,keySize:4,ivSize:2});e.Blowfish=t._createHelper(u)}(),i.Blowfish)})),kr((function(e,t){e.exports=ed})));function id(e){const t=[];for(let i=0;i<e.length;i+=1)t[i>>>2]|=e[i]<<24-i%4*8;return td.lib.WordArray.create(t,e.length)}const sd=0,rd=32,ad=16,od=[214,144,233,254,204,225,61,183,22,182,20,194,40,251,44,5,43,103,154,118,42,190,4,195,170,68,19,38,73,134,6,153,156,66,80,244,145,239,152,122,51,84,11,67,237,207,172,98,228,179,28,169,201,8,232,149,128,223,148,250,117,143,63,166,71,7,167,252,243,115,23,186,131,89,60,25,230,133,79,168,104,107,129,178,113,100,218,139,248,235,15,75,112,86,157,53,30,36,14,94,99,88,209,162,37,34,124,59,1,33,120,135,212,0,70,87,159,211,39,82,76,54,2,231,160,196,200,158,234,191,138,210,64,199,56,181,163,247,242,206,249,97,21,161,224,174,93,164,155,52,26,85,173,147,50,48,245,140,177,227,29,246,226,46,130,102,202,96,192,41,35,171,13,83,78,111,213,219,55,69,222,253,142,47,3,255,106,114,109,108,91,81,141,27,175,146,187,221,188,127,17,217,92,65,31,16,90,216,10,193,49,136,165,205,123,189,45,116,208,18,184,229,180,176,137,105,151,74,12,150,119,126,101,185,241,9,197,110,198,132,24,240,125,236,58,220,77,32,121,238,95,62,215,203,57,72],nd=[462357,472066609,943670861,1415275113,1886879365,2358483617,2830087869,3301692121,3773296373,4228057617,404694573,876298825,1347903077,1819507329,2291111581,2762715833,3234320085,3705924337,4177462797,337322537,808926789,1280531041,1752135293,2223739545,2695343797,3166948049,3638552301,4110090761,269950501,741554753,1213159005,1684763257];function ld(e){const t=[];for(let i=0,s=e.length;i<s;i+=2)t.push(parseInt(e.substr(i,2),16));return t}function dd(e,t){const i=31&t;return e<<i|e>>>32-i}function hd(e){return(255&od[e>>>24&255])<<24|(255&od[e>>>16&255])<<16|(255&od[e>>>8&255])<<8|255&od[255&e]}function cd(e){return e^dd(e,2)^dd(e,10)^dd(e,18)^dd(e,24)}function ud(e){return e^dd(e,13)^dd(e,23)}function pd(e,t,i){const s=new Array(4),r=new Array(4);for(let t=0;t<4;t++)r[0]=255&e[4*t],r[1]=255&e[4*t+1],r[2]=255&e[4*t+2],r[3]=255&e[4*t+3],s[t]=r[0]<<24|r[1]<<16|r[2]<<8|r[3];for(let e,t=0;t<32;t+=4)e=s[1]^s[2]^s[3]^i[t+0],s[0]^=cd(hd(e)),e=s[2]^s[3]^s[0]^i[t+1],s[1]^=cd(hd(e)),e=s[3]^s[0]^s[1]^i[t+2],s[2]^=cd(hd(e)),e=s[0]^s[1]^s[2]^i[t+3],s[3]^=cd(hd(e));for(let e=0;e<16;e+=4)t[e]=s[3-e/4]>>>24&255,t[e+1]=s[3-e/4]>>>16&255,t[e+2]=s[3-e/4]>>>8&255,t[e+3]=255&s[3-e/4]}function fd(e,t,i){let{padding:s="pkcs#7",mode:r,iv:a=[],output:o="string"}=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if("cbc"===r&&("string"==typeof a&&(a=ld(a)),16!==a.length))throw new Error("iv is invalid");if("string"==typeof t&&(t=ld(t)),16!==t.length)throw new Error("key is invalid");if(e="string"==typeof e?i!==sd?function(e){const t=[];for(let i=0,s=e.length;i<s;i++){const s=e.codePointAt(i);if(s<=127)t.push(s);else if(s<=2047)t.push(192|s>>>6),t.push(128|63&s);else if(s<=55295||s>=57344&&s<=65535)t.push(224|s>>>12),t.push(128|s>>>6&63),t.push(128|63&s);else{if(!(s>=65536&&s<=1114111))throw t.push(s),new Error("input is not supported");i++,t.push(240|s>>>18&28),t.push(128|s>>>12&63),t.push(128|s>>>6&63),t.push(128|63&s)}}return t}(e):ld(e):[...e],("pkcs#5"===s||"pkcs#7"===s)&&i!==sd){const t=ad-e.length%ad;for(let i=0;i<t;i++)e.push(t)}const n=new Array(rd);!function(e,t,i){const s=new Array(4),r=new Array(4);for(let t=0;t<4;t++)r[0]=255&e[0+4*t],r[1]=255&e[1+4*t],r[2]=255&e[2+4*t],r[3]=255&e[3+4*t],s[t]=r[0]<<24|r[1]<<16|r[2]<<8|r[3];s[0]^=2746333894,s[1]^=1453994832,s[2]^=1736282519,s[3]^=2993693404;for(let e,i=0;i<32;i+=4)e=s[1]^s[2]^s[3]^nd[i+0],t[i+0]=s[0]^=ud(hd(e)),e=s[2]^s[3]^s[0]^nd[i+1],t[i+1]=s[1]^=ud(hd(e)),e=s[3]^s[0]^s[1]^nd[i+2],t[i+2]=s[2]^=ud(hd(e)),e=s[0]^s[1]^s[2]^nd[i+3],t[i+3]=s[3]^=ud(hd(e));if(i===sd)for(let e,i=0;i<16;i++)e=t[i],t[i]=t[31-i],t[31-i]=e}(t,n,i);const l=[];let d=a,h=e.length,c=0;for(;h>=ad;){const t=e.slice(c,c+16),s=new Array(16);if("cbc"===r)for(let e=0;e<ad;e++)i!==sd&&(t[e]^=d[e]);pd(t,s,n);for(let e=0;e<ad;e++)"cbc"===r&&i===sd&&(s[e]^=d[e]),l[c+e]=s[e];"cbc"===r&&(d=i!==sd?s:t),h-=ad,c+=ad}if(("pkcs#5"===s||"pkcs#7"===s)&&i===sd){const e=l.length,t=l[e-1];for(let i=1;i<=t;i++)if(l[e-i]!==t)throw new Error("padding is invalid");l.splice(e-t,t)}return"array"!==o?i!==sd?l.map((e=>1===(e=e.toString(16)).length?"0"+e:e)).join(""):function(e){const t=[];for(let i=0,s=e.length;i<s;i++)e[i]>=240&&e[i]<=247?(t.push(String.fromCodePoint(((7&e[i])<<18)+((63&e[i+1])<<12)+((63&e[i+2])<<6)+(63&e[i+3]))),i+=3):e[i]>=224&&e[i]<=239?(t.push(String.fromCodePoint(((15&e[i])<<12)+((63&e[i+1])<<6)+(63&e[i+2]))),i+=2):e[i]>=192&&e[i]<=223?(t.push(String.fromCodePoint(((31&e[i])<<6)+(63&e[i+1]))),i++):t.push(String.fromCodePoint(e[i]));return t.join("")}(l):l}function md(e,t,i){for(let s=2;s<e.length;++s){const r=s-2,a=t[r%t.length],o=i[r%i.length];e[s]=e[s]^a^o}return e}class gd extends po{constructor(e){super(),this.TAG_NAME="CommonDemux",this.player=e,this.stopId=null,this.firstTimestamp=null,this.startTimestamp=null,this.preDelayTimestamp=null,this.preLoopTimestamp=null,this.bufferStartDts=null,this.bufferStartLocalTs=null,this.preIframeTs=null,this.preFrameTs=null,this.preTimestamp=null,this.preTimestampDuration=0,this.prevPayloadBufferSize=0,this.isStreamTsMoreThanLocal=!1,this.delay=-1,this.pushLatestDelay=-1,this.bufferList=[],this.historyIntervalDiffTimeList=[],this.playbackStreamFps=null,this.playbackStreamAudioFps=null,this.playbackStreamVideoFps=null,this.dropping=!1,this.isPushDropping=!1,this.nalUnitSize=null,this.initInterval(),this.player.debug.log("CommonDemux","init")}destroy(){this.bufferList=[],this.historyIntervalDiffTimeList=[],this.playbackStreamFps=null,this.playbackStreamAudioFps=null,this.playbackStreamVideoFps=null,this.clearStopInterval(),this.firstTimestamp=null,this.startTimestamp=null,this.bufferStartDts=null,this.bufferStartLocalTs=null,this.preDelayTimestamp=null,this.preLoopTimestamp=null,this.preIframeTs=null,this.preTimestamp=null,this.preTimestampDuration=0,this.prevPayloadBufferSize=0,this.isStreamTsMoreThanLocal=!1,this.delay=-1,this.pushLatestDelay=-1,this.dropping=!1,this.isPushDropping=!1,this.nalUnitSize=null,this.off(),this.player.debug.log("CommonDemux","destroy")}isDropping(){return this.dropping||this.isPushDropping}getDelay(e,t){if(!e||!this.player.isDemuxDecodeFirstIIframeInit())return-1;if(t===Ne)return this.delay;if(this.preDelayTimestamp&&this.preDelayTimestamp>e)return this.preDelayTimestamp-e>1e3&&this.player.debug.warn("CommonDemux",`getDelay() and preDelayTimestamp is ${this.preDelayTimestamp} > timestamp is ${e} more than ${this.preDelayTimestamp-e}ms and return ${this.delay}`),this.preDelayTimestamp=e,this.delay;if(this.firstTimestamp){if(e){const t=Date.now()-this.startTimestamp,i=e-this.firstTimestamp;t>=i?(this.isStreamTsMoreThanLocal=!1,this.delay=t-i):(this.isStreamTsMoreThanLocal=!0,this.delay=i-t)}}else this.firstTimestamp=e,this.startTimestamp=Date.now(),this.delay=-1;return this.preDelayTimestamp=e,this.delay}getDelayNotUpdateDelay(e,t){if(!e||!this.player.isDemuxDecodeFirstIIframeInit())return-1;if(t===Ne)return this.pushLatestDelay;if(this.preDelayTimestamp&&this.preDelayTimestamp-e>1e3)return this.player.debug.warn("CommonDemux",`getDelayNotUpdateDelay() and preDelayTimestamp is ${this.preDelayTimestamp} > timestamp is ${e} more than ${this.preDelayTimestamp-e}ms and return -1`),-1;if(this.firstTimestamp){let t=-1;if(e){const i=Date.now()-this.startTimestamp,s=e-this.firstTimestamp;t=i>=s?i-s:s-i}return t}return-1}resetDelay(){this.firstTimestamp=null,this.startTimestamp=null,this.delay=-1,this.dropping=!1}resetAllDelay(){this.resetDelay(),this.preDelayTimestamp=null}initInterval(){this.player.isUseHls265()?this.player.debug.log("CommonDemux","initInterval() and is hls and support hls265 so return"):-1===this.player.getStreamType().indexOf(y)?this.player.isPlaybackCacheBeforeDecodeForFpsRender()?this.player.debug.log("CommonDemux","initInterval() and playback and playbackIsCacheBeforeDecodeForFpsRender is true so return"):(this.player.debug.log("CommonDemux","setInterval()"),this._loop(),this.stopId=setInterval((()=>{let e=(new Date).getTime();this.preLoopTimestamp||(this.preLoopTimestamp=e);const t=e-this.preLoopTimestamp;this.updateHistoryIntervalDiffTimeList(t),t>100&&this.player.debug.warn("CommonDemux",`loop demux diff time is ${t}`),this._loop(),this.preLoopTimestamp=(new Date).getTime()}),20)):this.player.debug.log("CommonDemux","initInterval() and is worker stream so return")}clearStopInterval(){this.stopId&&(clearInterval(this.stopId),this.stopId=null)}updateHistoryIntervalDiffTimeList(e){this.historyIntervalDiffTimeList.length>5&&this.historyIntervalDiffTimeList.shift(),this.historyIntervalDiffTimeList.push(e)}isHistoryIntervalDiffTimeAllLarge(){if(this.historyIntervalDiffTimeList.length<5)return!1;for(let e=0;e<this.historyIntervalDiffTimeList.length;e++)if(this.historyIntervalDiffTimeList[e]<900)return!1;return!0}initPlaybackCacheLoop(){this.clearStopInterval();const e=()=>{let e=null;this.bufferList.length&&(e=this.bufferList.shift(),this._doDecoderDecode(e))};e();const t=Math.ceil(1e3/(this.playbackStreamFps*this.player.getPlaybackRate()));this.player.debug.log("CommonDemux",`initPlaybackCacheLoop() and fragDuration is ${t}, playbackStreamFps is ${this.playbackStreamFps}, playbackRate is ${this.player.getPlaybackRate()}`),this.stopId=setInterval(e,t)}_loop(){let e;const t=this.player._opt.videoBuffer,i=this.player._opt.videoBufferDelay,s=this.player._opt.playType===b;if(this.bufferList.length){if(this.isPushDropping)return void this.player.debug.warn("CommonDemux",`_loop isPushDropping is true and bufferList length is ${this.bufferList.length}`);if(this.dropping){for(e=this.bufferList.shift(),this.player.debug.warn("CommonDemux",`_loop is dropping and data.ts is ${e.ts}, data.type is ${e.type}, data.isIFrame is ${e.isIFrame}, delay is ${this.delay} ,buffer list is ${this.bufferList.length}`);!e.isIFrame&&this.bufferList.length;)e=this.bufferList.shift();const t=this.getDelayNotUpdateDelay(e.ts,e.type);e.isIFrame&&t<=this.getNotDroppingDelayTs()&&(this.player.debug.log("CommonDemux",`_loop data isIFrame is true and delay is ${this.delay}`),this.dropping=!1,this._doDecoderDecode(e),this._decodeNext(e))}else if(this.player.isPlayback()||this.player.isPlayUseMSE()||0===t)for(;this.bufferList.length;)e=this.bufferList.shift(),this._doDecoderDecode(e);else if(e=this.bufferList[0],-1===this.getDelay(e.ts,e.type))this.player.debug.log("CommonDemux",`delay is -1 and data.ts is ${e.ts} data.type is ${e.type}`),this.bufferList.shift(),this._doDecoderDecode(e),this._decodeNext(e);else if(this.delay>i+t&&s)this.hasIframeInBufferList()?(this.player.debug.warn("CommonDemux",`_loop delay is ${this.delay}, set dropping is true`),this.resetAllDelay(),this.dropping=!0,this.player.updateStats({isDropping:!0})):(this.bufferList.shift(),this._doDecoderDecode(e),this._decodeNext(e));else for(;this.bufferList.length;){if(e=this.bufferList[0],!(this.getDelay(e.ts,e.type)>t)){this.delay<0&&this.player.debug.warn("CommonDemux",`_loop delay is ${this.delay} bufferList is ${this.bufferList}`);break}this.bufferList.shift(),this._doDecoderDecode(e)}}else-1!==this.delay&&this.player.debug.log("CommonDemux","loop() bufferList is empty and reset delay"),this.resetAllDelay()}_doDecode(e,t,i,s){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0;const a=this.player;let o={ts:i,cts:r,type:t,isIFrame:!1};this.player.isPlayer()?(t===je&&a._opt.playType===b&&this.calcNetworkDelay(i),a._opt.useWCS&&!a._opt.useOffscreen||a._opt.useMSE?(t===je&&(o.isIFrame=s),this.pushBuffer(e,o)):t===je?a.decoderWorker&&a.decoderWorker.decodeVideo(e,i,s):t===Ne&&a._opt.hasAudio&&a.decoderWorker&&a.decoderWorker.decodeAudio(e,i)):this.player.isPlayback()&&(t===je&&(o.isIFrame=s),this.player.isPlaybackOnlyDecodeIFrame()?t===je&&s&&this.pushBuffer(e,o):this.player.isPlaybackCacheBeforeDecodeForFpsRender()||1===this.player.getPlaybackRate()?this.pushBuffer(e,o):this.pushBuffer(e,o,!1))}_doDecodeByHls(e,t,i,s){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,a=!1;if(t===Ne&&Br(e)&&(this.player.debug.log("CommonDemux",`hls pushBuffer audio ts is ${i}, isAacCodecPacket is true`),a=!0,this.player.isRecordTypeFlv())){const t=new Uint8Array(e);this.player.recorder.addAACSequenceHeader(t,i)}let o=!1;if(t===je&&s&&io(e)&&(this.player.debug.log("CommonDemux",`hls pushBuffer video ts is ${i}, isVideoSequenceHeader is true`),o=!0,this.player.isRecordTypeFlv())){const t=new Uint8Array(e);this.player.recorder.addVideoSequenceHeader(t,i)}this.player.recording&&ro(o)&&ro(a)&&this.handleRecording(e,t,i,s,r),t===je?this._doDecoderDecode({ts:i,cts:r,payload:e,type:je,isIFrame:s}):t===Ne&&this._doDecoderDecode({ts:i,payload:e,type:Ne})}_doDecodeByFmp4(e,t,i,s){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0;this._doDecode(e,t,i,s,r)}_doDecodeByTs(e,t,i,s){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0;this._doDecode(e,t,i,s,r)}_doDecodeByPs(e,t,i,s){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0;this._doDecode(e,t,i,s,r)}_decodeNext(e){const t=e.ts;if(0===this.bufferList.length)return;let i=this.bufferList[0];const s=i.ts-t,r=e.type===je&&i.type===Ne,a=e.type===je&&io(e.payload);(s<=20||r||a)&&(this.player.debug.log("CommonDemux",`decode data type is ${e.type} and\n ts is ${t} next data type is ${i.type} ts is ${i.ts}\n diff is ${s} and isVideoAndNextAudio is ${r} and isVideoSqeHeader is ${a}`),this.bufferList.shift(),this._doDecoderDecode(i))}_doDecoderDecode(e){const t=this.player,{webcodecsDecoder:i,mseDecoder:s}=t;this.player.isPlayer()&&this.player.updateStats({buf:this.delay}),e.type===Ne?t._opt.hasAudio&&(t._opt.useMSE&&t._opt.mseDecodeAudio?s.decodeAudio(e.payload,e.ts):t.decoderWorker&&t.decoderWorker.decodeAudio(e.payload,e.ts)):e.type===je&&(t._opt.isEmitSEI&&this.findSei(e.payload,e.ts),t._opt.useWCS&&!t._opt.useOffscreen?i.decodeVideo(e.payload,e.ts,e.isIFrame,e.cts):t._opt.useMSE?s.decodeVideo(e.payload,e.ts,e.isIFrame,e.cts):t.decoderWorker&&t.decoderWorker.decodeVideo(e.payload,e.ts,e.isIFrame))}pushBuffer(e,t){let i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];const s=this.player._opt.videoBuffer,r=this.player._opt.videoBufferDelay,a=this.player.isPlayer();if(t.type===Ne&&Br(e)){if(this.player.debug.log("CommonDemux",`pushBuffer() audio ts is ${t.ts}, isAacCodecPacket is true`),this.player.isRecordTypeFlv()){const i=new Uint8Array(e);this.player.recorder.addAACSequenceHeader(i,t.ts)}this._doDecoderDecode({ts:t.ts,payload:e,type:Ne})}else if(t.type===je&&t.isIFrame&&io(e)){if(this.player.debug.log("CommonDemux",`pushBuffer() video ts is ${t.ts}, isVideoSequenceHeader is true`),this.player.isRecordTypeFlv()){const i=new Uint8Array(e);this.player.recorder.addVideoSequenceHeader(i,t.ts)}this._doDecoderDecode({ts:t.ts,payload:e,type:je,isIFrame:t.isIFrame,cts:t.cts})}else{if(this.player.recording&&this.handleRecording(e,t.type,t.ts,t.isIFrame,t.cts),a){if(this.preTimestampDuration>0&&this.preTimestamp>0&&t.type===je){const e=t.ts-this.preTimestamp,i=this.preTimestampDuration+this.preTimestampDuration/2;e>=i&&this.player.debug.log("CommonDemux",`pushBuffer() video\n ts is ${t.ts}, preTimestamp is ${this.preTimestamp},\n diff is ${e} and preTimestampDuration is ${this.preTimestampDuration} and maxDiff is ${i}\n maybe trigger black screen or flower screen`)}if(this.preTimestamp>0&&t.ts<this.preTimestamp&&t.type===je&&this.preTimestamp-t.ts>X&&(this.player.debug.warn("CommonDemux",`pushBuffer() video\n ts is ${t.ts}, preTimestamp is ${this.preTimestamp},\n diff is ${this.preTimestamp-t.ts} more than 3600000\n and resetAllDelay()`),this.resetAllDelay()),t.ts<=this.preTimestamp&&this.preTimestamp>0&&t.type===je&&(this.player.debug.warn("CommonDemux",`pushBuffer() video and isIFrame is ${t.isIFrame} and\n ts is ${t.ts} less than (or equal) preTimestamp is ${this.preTimestamp} and\n payloadBufferSize is ${e.byteLength} and prevPayloadBufferSize is ${this.prevPayloadBufferSize}`),this.player._opt.isDropSameTimestampGop&&ro(t.isIFrame)&&this.player.isDemuxDecodeFirstIIframeInit())){const e=this.hasIframeInBufferList(),t=ro(this.isPushDropping);return this.player.debug.log("CommonDemux",`pushBuffer(), isDropSameTimestampGop is true and\n hasIframe is ${e} and isNotPushDropping is ${t} and next drop buffer`),void(e&&t?this.dropBuffer$2():this.clearBuffer(!0))}if(this.player.isDemuxDecodeFirstIIframeInit()){let e=this.getDelayNotUpdateDelay(t.ts,t.type);this.pushLatestDelay=e;const i=r+s;this.player._opt.useMSE?e>i&&this.delay<i&&this.delay>0&&this.hasIframeInBufferList()&&!1===this.isPushDropping&&(this.player.debug.warn("CommonDemux",`useMSE, pushLatestDelay is ${e} > ${r+s}, bufferList is ${this.bufferList.length}, delay is ${this.delay} and dropBuffer$2()`),this.dropBuffer$2()):e>i&&this.delay<i&&this.delay>0&&this.hasIframeInBufferList()&&!1===this.isPushDropping&&(this.player.debug.warn("CommonDemux",`useWCS, pushLatestDelay is ${e} > ${r+s},bufferList is ${this.bufferList.length}, delay is ${this.delay} and dropBuffer$2()`),this.dropBuffer$2()),this.isHistoryIntervalDiffTimeAllLarge()&&ro(this.player.visibility)&&(this.player._opt.useMSE?this.hasIframeInBufferList()&&!1===this.isPushDropping&&(this.player.debug.warn("CommonDemux",`useMSE, page visibility is false and\n history interval diff is ${this.historyIntervalDiffTimeList.join(",")} and\n bufferList is ${this.bufferList.length},\n delay is ${this.delay} and dropBuffer$2()`),this.dropBuffer$2()):this.hasIframeInBufferList()&&!1===this.isPushDropping&&(this.player.debug.warn("CommonDemux",`useWCS, page visibility is false and\n history interval diff is ${this.historyIntervalDiffTimeList.join(",")} and\n bufferList is ${this.bufferList.length},\n delay is ${this.delay} and dropBuffer$2()`),this.dropBuffer$2()))}t.type===je&&(this.preTimestamp>0&&(this.preTimestampDuration=t.ts-this.preTimestamp),this.prevPayloadBufferSize=e.byteLength,this.preTimestamp=t.ts)}if(i?t.type===Ne?this.bufferList.push({ts:t.ts,payload:e,type:Ne}):t.type===je&&this.bufferList.push({ts:t.ts,cts:t.cts,payload:e,type:je,isIFrame:t.isIFrame}):t.type===je?this._doDecoderDecode({ts:t.ts,cts:t.cts,payload:e,type:je,isIFrame:t.isIFrame}):t.type===Ne&&this._doDecoderDecode({ts:t.ts,payload:e,type:Ne}),this.player.isPlaybackCacheBeforeDecodeForFpsRender()&&(wa(this.playbackStreamVideoFps)||wa(this.playbackStreamAudioFps))){let e=this.playbackStreamVideoFps,t=this.playbackStreamAudioFps;if(wa(this.playbackStreamVideoFps)&&(e=Ya(this.bufferList,je),e>0&&(this.playbackStreamVideoFps=e,this.player.video&&this.player.video.setStreamFps(this.playbackStreamVideoFps),this.playbackStreamFps=t?e+t:e,ro(this.player._opt.hasAudio)&&(this.player.debug.log(this.TAG_NAME,"playbackCacheBeforeDecodeForFpsRender,_opt.hasAudio is false and set streamAudioFps is 0"),this.playbackStreamAudioFps=0),this.initPlaybackCacheLoop())),wa(this.playbackStreamAudioFps)&&(t=Ya(this.bufferList,Ne),t>0&&(this.playbackStreamAudioFps=t,this.playbackStreamFps=e?e+t:t,this.initPlaybackCacheLoop())),wa(this.playbackStreamVideoFps)&&wa(this.playbackStreamAudioFps)){const i=this.bufferList.map((e=>({type:e.type,ts:e.ts})));this.player.debug.log("CommonDemux",`playbackCacheBeforeDecodeForFpsRender, calc streamAudioFps is ${t}, streamVideoFps is ${e}, bufferListLength is ${this.bufferList.length} and ts list is ${JSON.stringify(i)}`)}const i=this.getAudioBufferLength()>0,s=i?60:40;this.bufferList.length>=s&&(this.debug.warn("CommonDemux",`playbackCacheBeforeDecodeForFpsRender, bufferListLength is ${this.bufferList.length} more than ${s}, and hasAudio is ${i} an set streamFps is 25`),this.playbackStreamVideoFps=e,this.player.video&&this.player.video.setStreamFps(this.playbackStreamVideoFps),i?(this.playbackStreamAudioFps=25,this.playbackStreamFps=this.playbackStreamVideoFps+this.playbackStreamAudioFps):this.playbackStreamFps=this.playbackStreamVideoFps,this.initPlaybackCacheLoop())}}}dropBuffer$2(){if(this.bufferList.length>0){let e=this.bufferList.findIndex((e=>so(e.isIFrame)&&e.type===je));if(this.isAllIframeInBufferList())for(let t=0;t<this.bufferList.length;t++){const i=this.bufferList[t],s=this.getDelayNotUpdateDelay(i.ts,i.type);if(s>=this.getNotDroppingDelayTs()){this.player.debug.log("CommonDemux",`dropBuffer$2() isAllIframeInBufferList() is true, and index is ${t} and tempDelay is ${s} and notDroppingDelayTs is ${this.getNotDroppingDelayTs()}`),e=t;break}}if(e>=0){this.isPushDropping=!0,this.player.updateStats({isDropping:!0});const t=this.bufferList.length;this.bufferList=this.bufferList.slice(e);const i=this.bufferList.shift();this.resetAllDelay(),this.getDelay(i.ts,i.type),this._doDecoderDecode(i),this.isPushDropping=!1,this.player.debug.log("CommonDemux",`dropBuffer$2() iFrameIndex is ${e},and old bufferList length is ${t} ,and new bufferList length is ${this.bufferList.length} and new delay is ${this.delay} `)}else this.isPushDropping=!1}0===this.bufferList.length&&(this.isPushDropping=!1)}clearBuffer(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.player.debug.log("CommonDemux",`clearBuffer,buffer length is ${this.bufferList.length}, need clear is ${e} and _opt.checkFirstIFrame is ${this.player._opt.checkFirstIFrame}`),e&&(this.bufferList=[]),this.player.isPlayer()&&(this.resetAllDelay(),so(this.player._opt.checkFirstIFrame)&&(this.dropping=!0,this.player.updateStats({isDropping:!0}))),this.player.decoderCheckFirstIFrame()}calcNetworkDelay(e){if(!(this.player.isDemuxDecodeFirstIIframeInit()&&e>0))return;null===this.bufferStartDts?(this.bufferStartDts=e,this.bufferStartLocalTs=Qr()):e<this.bufferStartDts&&(this.player.debug.warn("CommonDemux",`calcNetworkDelay dts is ${e} and bufferStartDts is ${this.bufferStartDts}`),this.bufferStartDts=e,this.bufferStartLocalTs=Qr());let t=e-this.bufferStartDts,i=Qr()-this.bufferStartLocalTs,s=i>t?i-t:0;s>this.player._opt.networkDelay&&this.player._opt.playType===b&&(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 ${s}, _opt.networkDelay is ${this.player._opt.networkDelay}`),this.player.emit(nt.networkDelayTimeout,s)),this.player.updateStats({netBuf:s})}calcIframeIntervalTimestamp(e){if(null===this.preIframeTs)this.preIframeTs=e;else if(this.preIframeTs<e){const t=e-this.preIframeTs;this.player&&(this.player.videoIframeIntervalTs=t),this.preIframeTs=e}}calcBufferFps(e){}getNotDroppingDelayTs(){return this.player._opt.videoBuffer+this.player._opt.videoBufferDelay/2}getMaxDelayTs(){return this.player._opt.videoBuffer+this.player._opt.videoBufferDelay}getPushLatestDelay(){return this.pushLatestDelay}getVideoBufferLength(){let e=0;return this.bufferList.forEach((t=>{t.type===je&&(e+=1)})),e}getAudioBufferLength(){let e=0;return this.bufferList.forEach((t=>{t.type===Ne&&(e+=1)})),e}hasIframeInBufferList(){return this.bufferList.some((e=>e.type===je&&e.isIFrame))}isAllIframeInBufferList(){const e=this.getVideoBufferLength();let t=0;return this.bufferList.forEach((e=>{e.type===je&&e.isIFrame&&(t+=1)})),e===t}getInputByteLength(){return 0}getIsStreamTsMoreThanLocal(){return this.isStreamTsMoreThanLocal}close(){}reset(){}findSei(e,t){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],s=4;Ta(this.nalUnitSize)&&(s=this.nalUnitSize);const r=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4;if(e.length<4)return;const i=e.length,s=[];let r,a=0;for(;a+t<i;)if(r=Vr(e,a),3===t&&(r>>>=8),a+=t,r){if(a+r>i)break;s.push(e.subarray(a,a+r)),a+=r}return s}(e.slice(5),s);if(ro(i)){const e=this.player.getVideoInfo();e&&e.encType&&(i=e.encType===wt)}r.forEach((e=>{const s=i?e[0]>>>1&63:31&e[0];(i&&(s===Nt||s===Ot)||ro(i)&&s===Ct.kSliceSEI)&&this.player.emit(nt.videoSEI,{ts:t,data:e})}))}handleRecording(e,t,i,s,r){if(this.player.isRecordTypeFlv()){const s=new Uint8Array(e);t===je?this.player.recorder.addVideo(s,i):t===Ne&&this.player.recorder.addAudio(s,i)}else if(this.player.isRecordTypeMp4()){const a=new Uint8Array(e);if(this.player.recorder.isWasmMp4()){if(t===je)this.player.recorder.handleAddNaluTrack(a.slice(5),s,i,r);else if(t===Ne){const t=new Uint8Array(e);this.player.recorder.handleAddAudioTrack(Ir(t)?t.slice(2):t.slice(1),i)}}else t===je&&this.player.recorder.handleAddNaluTrack(a.slice(5),s,i,r)}}updateNalUnitSize(e){const t=15&e[0];this.player.video.updateVideoInfo({encTypeCode:t});const i=t===vt;this.nalUnitSize=function(e,t){let i=null;return t?e.length>=28&&(i=1+(3&e[26])):e.length>=12&&(i=1+(3&e[9])),i}(e,i),this.player.debug.log(this.TAG_NAME,`demux() isVideoSequenceHeader is true and isHevc is ${i} and nalUnitSize is ${this.nalUnitSize}`)}cryptoPayload(e,t){let i=e,s=this.player;if(s._opt.isM7sCrypto)if(s._opt.cryptoKey&&s._opt.cryptoKey.byteLength>0&&s._opt.cryptoIV&&s._opt.cryptoIV.byteLength>0){const t=this.player.video.getVideoInfo();t.encTypeCode?i=function(e,t,i){let s=arguments.length>3&&void 0!==arguments[3]&&arguments[3];t=new Uint8Array(t),i=new Uint8Array(i);const r=e.byteLength;let a=5;for(;a<r;){let n=(o=e.slice(a,a+4))[3]|o[2]<<8|o[1]<<16|o[0]<<24;if(n>r)break;let l=e[a+4],d=!1;if(s?(l=l>>>1&63,d=[0,1,2,3,4,5,6,7,8,9,16,17,18,19,20,21].includes(l)):(l&=31,d=1===l||5===l),d){const s=e.slice(a+4+2,a+4+n);let r=new Zl.ModeOfOperation.ctr(t,new Zl.Counter(i));const o=r.decrypt(s);r=null,e.set(o,a+4+2)}a=a+4+n}var o;return e}(e,s._opt.cryptoKey,s._opt.cryptoIV,t.encTypeCode===vt):s.debug.warn(this.TAG_NAME,`videoInfo.encTypeCode is ${t.encTypeCode}`)}else s.debug.error(this.TAG_NAME,`isM7sCrypto cryptoKey.length is ${s._opt.cryptoKey&&s._opt.cryptoKey.byteLength} or cryptoIV.length is ${s._opt.cryptoIV&&s._opt.cryptoIV.byteLength} null`);else if(s._opt.isSm4Crypto)s._opt.sm4CryptoKey&&t?i=function(e,t){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const s=e.byteLength;let r=5;for(;r<s;){let o=(a=e.slice(r,r+4))[3]|a[2]<<8|a[1]<<16|a[0]<<24;if(o>s)break;let n=e[r+4],l=!1;if(i?(n=n>>>1&63,l=[0,1,2,3,4,5,6,7,8,9,16,17,18,19,20,21].includes(n)):(n&=31,l=1===n||5===n),l){const i=fd(e.slice(r+4+2,r+4+o),t,0,{padding:"none",output:"array"});e.set(i,r+4+2)}r=r+4+o}var a;return e}(e,s._opt.sm4CryptoKey):s._opt.sm4CryptoKey||s.debug.error(this.TAG_NAME,"isSm4Crypto opt.sm4CryptoKey is null");else if(s._opt.isXorCrypto)if(s._opt.cryptoKey&&s._opt.cryptoKey.byteLength>0&&s._opt.cryptoIV&&s._opt.cryptoIV.byteLength>0){const t=this.player.video.getVideoInfo();i=function(e,t,i){let s=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const r=e.byteLength;let a=5;for(;a<r;){let n=(o=e.slice(a,a+4))[3]|o[2]<<8|o[1]<<16|o[0]<<24;if(n>r)break;let l=e[a+4],d=!1;if(s?(l=l>>>1&63,d=[0,1,2,3,4,5,6,7,8,9,16,17,18,19,20,21].includes(l)):(l&=31,d=1===l||5===l),d){const s=md(e.slice(a+4,a+4+n),t,i);e.set(s,a+4)}a=a+4+n}var o;return e}(e,s._opt.cryptoKey,s._opt.cryptoIV,t.encTypeCode===vt)}else s.debug.error(this.TAG_NAME,"isXorCrypto opt.xorCryptoKey is null");return i}cryptoPayloadAudio(e){let t=e,i=this.player;if(i._opt.isM7sCrypto)if(i._opt.cryptoKey&&i._opt.cryptoKey.byteLength>0&&i._opt.cryptoIV&&i._opt.cryptoIV.byteLength>0){e[0]>>4===Et.AAC&&(t=function(e,t,i){if(e.byteLength<=30)return e;const s=e.slice(32);let r=new Zl.ModeOfOperation.ctr(t,new Zl.Counter(i));const a=r.decrypt(s);return r=null,e.set(a,32),e}(e,i._opt.cryptoKey,i._opt.cryptoIV))}else i.debug.error(this.TAG_NAME,`isM7sCrypto cryptoKey.length is ${i._opt.cryptoKey&&i._opt.cryptoKey.byteLength} or cryptoIV.length is ${i._opt.cryptoIV&&i._opt.cryptoIV.byteLength} null`);return t}_decodeEnhancedH265Video(e,t){const i=e[0],s=48&i,r=15&i,a=e.slice(1,5),o=new ArrayBuffer(4),n=new Uint32Array(o),l="a"==String.fromCharCode(a[0]);if(r===dr){if(s===ur){const t=e.slice(5);if(l);else{const e=new Uint8Array(5+t.length);e.set([28,0,0,0,0],0),e.set(t,5),this.updateNalUnitSize(e),this.player.debug.log(this.TAG_NAME,`demux() isVideoSequenceHeader(enhancedH265) is true and nalUnitSize is ${this.nalUnitSize}`),this._doDecode(e,je,0,!0,0)}}}else if(r===hr){let i=e,r=0;const a=s===ur;if(a&&this.calcIframeIntervalTimestamp(t),l);else{n[0]=e[4],n[1]=e[3],n[2]=e[2],n[3]=0,r=n[0];i=Ln(e.slice(8),a),i=this.cryptoPayload(i,a),this._doDecode(i,je,t,a,r)}}else if(r===cr){const i=s===ur,r=e.slice(5);i&&this.calcIframeIntervalTimestamp(t);let a=Ln(r,i);a=this.cryptoPayload(a,i),this._doDecode(a,je,t,i,0)}}_isEnhancedH265Header(e){return!(128&~e)}}var yd=function(e,t,i,s){return new(i||(i=Promise))((function(r,a){function o(e){try{l(s.next(e))}catch(e){a(e)}}function n(e){try{l(s.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,n)}l((s=s.apply(e,t||[])).next())}))};const Ad=Symbol(32),bd=Symbol(16),_d=Symbol(8);class vd{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(e){return yd(this,void 0,void 0,(function*(){return this.lastReadPromise&&(yield this.lastReadPromise),this.lastReadPromise=new Promise(((t,i)=>{var s;this.reject=i,this.resolve=e=>{delete this.lastReadPromise,delete this.resolve,delete this.need,t(e)};this.demand(e,!0)||null===(s=this.pull)||void 0===s||s.call(this,e)}))}))}readU32(){return this.read(Ad)}readU16(){return this.read(bd)}readU8(){return this.read(_d)}close(){var e;this.g&&this.g.return(),this.buffer&&this.buffer.subarray(0,0),null===(e=this.reject)||void 0===e||e.call(this,new Error("EOF")),delete this.lastReadPromise}flush(){if(!this.buffer||!this.need)return;let e=null;const t=this.buffer.subarray(this.consumed);let i=0;const s=e=>t.length<(i=e);if("number"==typeof this.need){if(s(this.need))return;e=t.subarray(0,i)}else if(this.need===Ad){if(s(4))return;e=t[0]<<24|t[1]<<16|t[2]<<8|t[3]}else if(this.need===bd){if(s(2))return;e=t[0]<<8|t[1]}else if(this.need===_d){if(s(1))return;e=t[0]}else if("buffer"in this.need){if("byteOffset"in this.need){if(s(this.need.byteLength-this.need.byteOffset))return;new Uint8Array(this.need.buffer,this.need.byteOffset).set(t.subarray(0,i)),e=this.need}else if(this.g)return void this.g.throw(new Error("Unsupported type"))}else{if(s(this.need.byteLength))return;new Uint8Array(this.need).set(t.subarray(0,i)),e=this.need}return this.consumed+=i,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){const 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}}vd.U32=Ad,vd.U16=bd,vd.U8=_d;class Sd extends gd{constructor(e){super(e),this.TAG_NAME="FlvDemux",this.input=new vd(this.demux()),e.debug.log(this.TAG_NAME,"init")}destroy(){super.destroy(),this.input=null,this.player.debug.log(this.TAG_NAME,"destroy")}dispatch(e){this.input?this.input.write(e):this.player&&this.player.debug.warn(this.TAG_NAME,"dispatch() this.input is null")}*demux(){yield 9;const e=new ArrayBuffer(4),t=new Uint8Array(e),i=new Uint32Array(e),s=this.player;for(;;){if(!this.input)return;t[3]=0;const e=yield 15,r=e[4];t[0]=e[7],t[1]=e[6],t[2]=e[5];const a=i[0];t[0]=e[10],t[1]=e[9],t[2]=e[8],t[3]=e[11];let o=i[0];const n=(yield a).slice();if(!s)return;switch(r){case ze:if(s._opt.hasAudio&&(s.updateStats({abps:n.byteLength}),n.byteLength>0)){let e=n;so(this.player._opt.m7sCryptoAudio)&&(e=this.cryptoPayloadAudio(n)),this._doDecode(e,Ne,o)}break;case Ge:if(s._opt.hasVideo&&n.length>=6){let e=o;s.updateStats({vbps:n.byteLength,dts:e}),s._times.demuxStart||(s._times.demuxStart=Qr());const t=n[0];if(this._isEnhancedH265Header(t))this._decodeEnhancedH265Video(n,e);else{const e=15&t;let s=(t>>4&15)===Ps;if(ro(e===vt||e===_t))return void this.player.debug.warn(this.TAG_NAME,`demux() codecId is ${e} and ignore`);s&&(this.calcIframeIntervalTimestamp(o),null===this.nalUnitSize&&io(n)&&this.updateNalUnitSize(n)),i[0]=n[4],i[1]=n[3],i[2]=n[2],i[3]=0;let r=i[0],a=this.cryptoPayload(n,s);this._doDecode(a,je,o,s,r)}}else n.length<6&&s.debug.warn(this.TAG_NAME,`payload.length is ${n.length} less than 6 and ignore`);break;case He:if(this.player.isRecordTypeFlv()){const e=new Uint8Array(n);this.player.recorder.addMetaData(e)}const e=Yn(n);e&&e.onMetaData&&s.updateMetaData(e.onMetaData);break;default:s.debug.log(this.TAG_NAME,`demux() type is ${r}`)}}}close(){this.input=null}getInputByteLength(){let e=0;return this.input&&this.input.buffer&&(e=this.input.buffer.byteLength),e}}class wd extends gd{constructor(e){super(e),this.TAG_NAME="M7sDemux",e.debug.log(this.TAG_NAME,"init")}destroy(){super.destroy(),this.player.debug.log(this.TAG_NAME,"destroy")}dispatch(e){const t=this.player,i=new DataView(e),s=i.getUint8(0),r=i.getUint32(1,!1),a=new ArrayBuffer(4),o=new Uint32Array(a);switch(s){case Ne:if(t._opt.hasAudio){const i=new Uint8Array(e,5);t.updateStats({abps:i.byteLength}),i.byteLength>0&&this._doDecode(i,s,r)}break;case je:if(t._opt.hasVideo)if(t._times.demuxStart||(t._times.demuxStart=Qr()),i.byteLength>=11){const a=new Uint8Array(e,5);let n=r;t.updateStats({vbps:a.byteLength,dts:n});const l=a[0];if(this._isEnhancedH265Header(l))this._decodeEnhancedH265Video(a,r);else{const e=i.getUint8(5)>>4==1;e&&this.calcIframeIntervalTimestamp(r),o[0]=a[4],o[1]=a[3],o[2]=a[2],o[3]=0;let t=o[0],n=this.cryptoPayload(a,e);this._doDecode(n,s,r,e,t)}}else this.player.debug.warn(this.TAG_NAME,"dispatch","dv byteLength is",i.byteLength,"and return")}}}class Ed extends Sd{constructor(e){super(e),e.debug.log("WebTransportDemux","init")}destroy(){this.player.debug.log("WebTransportDemux","destroy"),super.destroy()}}class Td extends gd{TAG_NAME="NakedFlowDemux";constructor(e){super(e),this.lastBuf=null,this.vps=null,this.sps=null,this.pps=null,this.streamVideoType=null,this.streamAudioType=null,this.tempNaluBufferList=new Uint8Array(0),this.localDts=0,this.isSendSeqHeader=!1,this.isSendAACSeqHeader=!1,e.debug.log(this.TAG_NAME,"init")}destroy(){super.destroy(),this.lastBuf=null,this.vps=null,this.sps=null,this.pps=null,this.streamVideoType=null,this.streamAudioType=null,this.tempNaluBufferList=new Uint8Array(0),this.localDts=0,this.localAudioDts=0,this.isSendSeqHeader=!1,this.isSendAACSeqHeader=!1,this.player.debug.log(this.TAG_NAME,"destroy")}dispatch(e){this.player;const t=new Uint8Array(e);this.extractNALu$2(t)}addNaluToBuffer(e){const t=e.byteLength+this.tempNaluBufferList.byteLength,i=new Uint8Array(t);i.set(this.tempNaluBufferList,0),i.set(e,this.tempNaluBufferList.byteLength),this.tempNaluBufferList=i}downloadNakedFlowFile(){const e=new Blob([this.tempNaluBufferList]);try{const t=document.createElement("a");t.href=window.URL.createObjectURL(e),t.download=Date.now()+".h264",t.click(),window.URL.revokeObjectURL(t.href)}catch(e){console.error("downloadTempNalu",e)}}getNaluDts(){const e=this.player._opt.nakedFlowFps;return this.localDts=this.localDts+parseInt(1e3/e),this.localDts}getNaluAudioDts(){const e=this.player.audio.audioContext.sampleRate,t=this.player.audio.audioBufferSize;return this.localDts+parseInt(t/e*1e3)}extractNALu(e){let t,i,s=0,r=e.byteLength,a=0,o=[];for(;s<r;)switch(t=e[s++],a){case 0:0===t&&(a=1);break;case 1:a=0===t?2:0;break;case 2:case 3:0===t?a=3:1===t&&s<r?(e[s],i&&o.push(e.subarray(i,s-a-1)),i=s,a=0):a=0}return i&&o.push(e.subarray(i,r)),o}extractNALu$2(e){let t=null;if(!e||e.byteLength<1)return;this.lastBuf?(t=new Uint8Array(e.byteLength+this.lastBuf.length),t.set(this.lastBuf),t.set(new Uint8Array(e),this.lastBuf.length)):t=new Uint8Array(e);let i=0,s=-1,r=-2;const a=new Array;for(let e=0;e<t.length;e+=2){const i=t[e],o=t[e+1];0==s&&0==i&&0==o?a.push(e-1):1==o&&0==i&&0==s&&0==r&&a.push(e-2),r=i,s=o}if(a.length>1)for(let e=0;e<a.length-1;++e){const s=t.subarray(a[e],a[e+1]+1);this.handleNALu(s),i=a[e+1]}else i=a[0];if(0!=i&&i<t.length)this.lastBuf=t.subarray(i);else{this.lastBuf||(this.lastBuf=t);const i=new Uint8Array(this.lastBuf.length+e.byteLength);i.set(this.lastBuf),i.set(new Uint8Array(e),this.lastBuf.length),this.lastBuf=i}}handleNALu(e){e.byteLength<4?this.player.debug.warn(this.TAG_NAME,`handleNALu nalu byteLength is ${e.byteLength} <= 4`):(e=e.slice(4),this.handleVideoNalu(e))}handleVideoNalu(e){const t=new Uint8Array(e);if(this.streamVideoType||(this.streamVideoType=function(e){let t=null,i=31&e[0];return i!==Ct.sps&&i!==Ct.pps||(t=St),t||(i=(126&e[0])>>1,i!==Lt&&i!==Bt&&i!==Mt||(t=wt)),t}(t)),this.streamVideoType===St){const e=this.handleAddNaluStartCode(t),i=this.extractNALu(e);if(0===i.length)return void this.player.debug.warn(this.TAG_NAME,"handleVideoNalu","naluList.length === 0");const s=[];if(i.forEach((e=>{const t=An(e);t===Ct.pps||t===Ct.sps?this.handleVideoH264Nalu(e):_n(t)&&s.push(e)})),1===s.length)this.handleVideoH264Nalu(s[0]);else{const e=function(e){if(0===e.length)return!1;const t=An(e[0]);for(let i=1;i<e.length;i++)if(t!==An(e[i]))return!1;return!0}(s);if(e){const e=An(s[0]),t=vn(e);this.handleVideoH264NaluList(s,t,e)}else s.forEach((e=>{this.handleVideoH264Nalu(e)}))}}else if(this.streamVideoType===wt)if(this.player._opt.nakedFlowH265DemuxUseNew){const e=this.handleAddNaluStartCode(t),i=this.extractNALu(e);if(0===i.length)return void this.player.debug.warn(this.TAG_NAME,"handleVideoNalu","h265 naluList.length === 0");const s=[];if(i.forEach((e=>{const t=Pn(e);t===Mt||t===Bt||t===Lt?this.handleVideoH265Nalu(e):Bn(t)&&s.push(e)})),1===s.length)this.handleVideoH265Nalu(s[0]);else{const e=function(e){if(0===e.length)return!1;const t=Pn(e[0]);for(let i=1;i<e.length;i++)if(t!==Pn(e[i]))return!1;return!0}(s);if(e){const e=Pn(s[0]),t=In(e);this.handleVideoH265NaluList(s,t,e)}else s.forEach((e=>{this.handleVideoH265Nalu(e)}))}}else{Pn(t)===Mt?this.extractH265PPS(t):this.handleVideoH265Nalu(t)}else this.player.debug.error(this.TAG_NAME," this.streamVideoType is null")}extractH264PPS(e){const t=this.handleAddNaluStartCode(e);this.extractNALu(t).forEach((e=>{bn(An(e))?this.extractH264SEI(e):this.handleVideoH264Nalu(e)}))}extractH265PPS(e){const t=this.handleAddNaluStartCode(e);this.extractNALu(t).forEach((e=>{const t=Pn(e);t===Ft?this.extractH265SEI(e):this.handleVideoH265Nalu(e)}))}extractH264SEI(e){const t=this.handleAddNaluStartCode(e);this.extractNALu(t).forEach((e=>{this.handleVideoH264Nalu(e)}))}extractH265SEI(e){const t=this.handleAddNaluStartCode(e);this.extractNALu(t).forEach((e=>{this.handleVideoH265Nalu(e)}))}handleAddNaluStartCode(e){const t=[0,0,0,1],i=new Uint8Array(e.length+t.length);return i.set(t),i.set(e,t.length),i}handleAudioAACNalu(e){if(!e||e.byteLength<1)return;this.streamAudioType||(this.streamAudioType=Tt.AAC);let t=new Uint8Array(e);const i=t.slice(0,7);if(t=t.slice(7),!this.isSendAACSeqHeader){const e=(192&i[2])>>6,t=(60&i[2])>>2,s=(1&i[2])<<2|(192&i[3])>>6,r=new Uint8Array([175,0,e<<3|(14&t)>>1,(1&t)<<7|s<<3]);this.isSendAACSeqHeader=!0,this._doDecode(r,Ne,0,!1,0)}const s=this.getNaluAudioDts(),r=new Uint8Array(t.length+2);r.set([175,1],0),r.set(t,2),this._doDecode(r,Ne,s,!1,0)}handleAudioG711ANalu(e){if(!e||e.byteLength<1)return;this.streamAudioType||(this.streamAudioType=Tt.ALAW);let t=new Uint8Array(e);const i=this.getNaluAudioDts(),s=new Uint8Array(t.length+1);s.set([114],0),s.set(t,1),this._doDecode(s,Ne,i,!1,0)}handleAudioG711UNalu(e){if(!e||e.byteLength<1)return;this.streamAudioType||(this.streamAudioType=Tt.MULAW);let t=new Uint8Array(e);const i=this.getNaluAudioDts(),s=new Uint8Array(t.length+1);s.set([130],0),s.set(t,1),this._doDecode(s,Ne,i,!1,0)}handleVideoH264Nalu(e){const t=An(e);switch(t){case Ct.sps:this.sps=e;break;case Ct.pps:this.pps=e}if(this.isSendSeqHeader){if(this.sps&&this.pps){const e=gn({sps:this.sps,pps:this.pps}),t=this.getNaluDts();this._doDecode(e,je,t,!0,0),this.sps=null,this.pps=null}if(_n(t)){this.player._times.demuxStart||(this.player._times.demuxStart=Qr());const i=vn(t),s=this.getNaluDts(),r=function(e,t){let i=[];i[0]=t?23:39,i[1]=1,i[2]=0,i[3]=0,i[4]=0,i[5]=e.byteLength>>24&255,i[6]=e.byteLength>>16&255,i[7]=e.byteLength>>8&255,i[8]=255&e.byteLength;const s=new Uint8Array(i.length+e.byteLength);return s.set(i,0),s.set(e,i.length),s}(e,i);this._preDoDecode(r,je,s,i,0)}else this.player.debug.warn(this.TAG_NAME,`handleVideoH264Nalu is avc seq head nalType is ${t}`)}else if(this.sps&&this.pps){this.isSendSeqHeader=!0;const e=gn({sps:this.sps,pps:this.pps});this._doDecode(e,je,0,!0,0),this.sps=null,this.pps=null}}handleVideoH264NaluList(e,t,i){if(this.isSendSeqHeader){this.player._times.demuxStart||(this.player._times.demuxStart=Qr());const i=this.getNaluDts(),s=yn(e.reduce(((e,t)=>{const i=Wr(e),s=Wr(t),r=new Uint8Array(i.byteLength+s.byteLength);return r.set(i,0),r.set(s,i.byteLength),r})),t);this._preDoDecode(s,je,i,t,0)}else this.player.debug.warn(this.TAG_NAME,"handleVideoH264NaluList isSendSeqHeader is false")}handleVideoH265Nalu(e){const t=Pn(e);switch(t){case Lt:this.vps=e;break;case Bt:this.sps=e;break;case Mt:this.pps=e}if(this.isSendSeqHeader){if(this.vps&&this.sps&&this.pps){const e=Dn({vps:this.vps,sps:this.sps,pps:this.pps}),t=this.getNaluDts();this._doDecode(e,je,t,!0,0),this.vps=null,this.sps=null,this.pps=null}if(Bn(t)){this.player._times.demuxStart||(this.player._times.demuxStart=Qr());const i=In(t),s=this.getNaluDts(),r=function(e,t){let i=[];i[0]=t?28:44,i[1]=1,i[2]=0,i[3]=0,i[4]=0,i[5]=e.byteLength>>24&255,i[6]=e.byteLength>>16&255,i[7]=e.byteLength>>8&255,i[8]=255&e.byteLength;const s=new Uint8Array(i.length+e.byteLength);return s.set(i,0),s.set(e,i.length),s}(e,i);this._preDoDecode(r,je,s,i,0)}}else if(this.vps&&this.sps&&this.pps){this.isSendSeqHeader=!0;const e=Dn({vps:this.vps,sps:this.sps,pps:this.pps});this._doDecode(e,je,0,!0,0),this.vps=null,this.sps=null,this.pps=null}}handleVideoH265NaluList(e,t,i){if(this.isSendSeqHeader){this.player._times.demuxStart||(this.player._times.demuxStart=Qr());const i=this.getNaluDts(),s=Ln(e.reduce(((e,t)=>{const i=Wr(e),s=Wr(t),r=new Uint8Array(i.byteLength+s.byteLength);return r.set(i,0),r.set(s,i.byteLength),r})),t);this._preDoDecode(s,je,i,t,0)}else this.player.debug.warn(this.TAG_NAME,"handleVideoH265NaluList isSendSeqHeader is false")}_preDoDecode(e,t,i,s,r){this.player.updateStats({vbps:e.byteLength,dts:i}),s&&this.calcIframeIntervalTimestamp(i),this._doDecode(e,je,i,s,r)}getInputByteLength(){let e=0;return this.lastBuf&&(e=this.lastBuf.byteLength),e}}class kd extends gd{constructor(e){super(e),this.player=e,e.debug.log("EmptyDemux","init")}destroy(){super.destroy(),this.player.debug.log("EmptyDemux","destroy")}}var Cd=kr((function(e,t){var s,r,a,o=(s=new Date,r=4,a={setLogLevel:function(e){r=e==this.debug?1:e==this.info?2:e==this.warn?3:(this.error,4)},debug:function(e,t){void 0===console.debug&&(console.debug=console.log),1>=r&&console.debug("["+o.getDurationString(new Date-s,1e3)+"]","["+e+"]",t)},log:function(e,t){this.debug(e.msg)},info:function(e,t){2>=r&&console.info("["+o.getDurationString(new Date-s,1e3)+"]","["+e+"]",t)},warn:function(e,t){3>=r&&console.warn("["+o.getDurationString(new Date-s,1e3)+"]","["+e+"]",t)},error:function(e,t){4>=r&&console.error("["+o.getDurationString(new Date-s,1e3)+"]","["+e+"]",t)}},a);o.getDurationString=function(e,t){var i;function s(e,t){for(var i=(""+e).split(".");i[0].length<t;)i[0]="0"+i[0];return i.join(".")}e<0?(i=!0,e=-e):i=!1;var r=e/(t||1),a=Math.floor(r/3600);r-=3600*a;var o=Math.floor(r/60),n=1e3*(r-=60*o);return n-=1e3*(r=Math.floor(r)),n=Math.floor(n),(i?"-":"")+a+":"+s(o,2)+":"+s(r,2)+"."+s(n,3)},o.printRanges=function(e){var t=e.length;if(t>0){for(var i="",s=0;s<t;s++)s>0&&(i+=","),i+="["+o.getDurationString(e.start(s))+","+o.getDurationString(e.end(s))+"]";return i}return"(empty)"},t.Log=o;var n=function(e){if(!(e instanceof ArrayBuffer))throw"Needs an array buffer";this.buffer=e,this.dataview=new DataView(e),this.position=0};n.prototype.getPosition=function(){return this.position},n.prototype.getEndPosition=function(){return this.buffer.byteLength},n.prototype.getLength=function(){return this.buffer.byteLength},n.prototype.seek=function(e){var t=Math.max(0,Math.min(this.buffer.byteLength,e));return this.position=isNaN(t)||!isFinite(t)?0:t,!0},n.prototype.isEos=function(){return this.getPosition()>=this.getEndPosition()},n.prototype.readAnyInt=function(e,t){var i=0;if(this.position+e<=this.buffer.byteLength){switch(e){case 1:i=t?this.dataview.getInt8(this.position):this.dataview.getUint8(this.position);break;case 2:i=t?this.dataview.getInt16(this.position):this.dataview.getUint16(this.position);break;case 3:if(t)throw"No method for reading signed 24 bits values";i=this.dataview.getUint8(this.position)<<16,i|=this.dataview.getUint8(this.position+1)<<8,i|=this.dataview.getUint8(this.position+2);break;case 4:i=t?this.dataview.getInt32(this.position):this.dataview.getUint32(this.position);break;case 8:if(t)throw"No method for reading signed 64 bits values";i=this.dataview.getUint32(this.position)<<32,i|=this.dataview.getUint32(this.position+4);break;default:throw"readInt method not implemented for size: "+e}return this.position+=e,i}throw"Not enough bytes in buffer"},n.prototype.readUint8=function(){return this.readAnyInt(1,!1)},n.prototype.readUint16=function(){return this.readAnyInt(2,!1)},n.prototype.readUint24=function(){return this.readAnyInt(3,!1)},n.prototype.readUint32=function(){return this.readAnyInt(4,!1)},n.prototype.readUint64=function(){return this.readAnyInt(8,!1)},n.prototype.readString=function(e){if(this.position+e<=this.buffer.byteLength){for(var t="",i=0;i<e;i++)t+=String.fromCharCode(this.readUint8());return t}throw"Not enough bytes in buffer"},n.prototype.readCString=function(){for(var e=[];;){var t=this.readUint8();if(0===t)break;e.push(t)}return String.fromCharCode.apply(null,e)},n.prototype.readInt8=function(){return this.readAnyInt(1,!0)},n.prototype.readInt16=function(){return this.readAnyInt(2,!0)},n.prototype.readInt32=function(){return this.readAnyInt(4,!0)},n.prototype.readInt64=function(){return this.readAnyInt(8,!1)},n.prototype.readUint8Array=function(e){for(var t=new Uint8Array(e),i=0;i<e;i++)t[i]=this.readUint8();return t},n.prototype.readInt16Array=function(e){for(var t=new Int16Array(e),i=0;i<e;i++)t[i]=this.readInt16();return t},n.prototype.readUint16Array=function(e){for(var t=new Int16Array(e),i=0;i<e;i++)t[i]=this.readUint16();return t},n.prototype.readUint32Array=function(e){for(var t=new Uint32Array(e),i=0;i<e;i++)t[i]=this.readUint32();return t},n.prototype.readInt32Array=function(e){for(var t=new Int32Array(e),i=0;i<e;i++)t[i]=this.readInt32();return t},t.MP4BoxStream=n;var l=function(e,t,i){this._byteOffset=t||0,e instanceof ArrayBuffer?this.buffer=e:"object"==typeof e?(this.dataView=e,t&&(this._byteOffset+=t)):this.buffer=new ArrayBuffer(e||0),this.position=0,this.endianness=null==i?l.LITTLE_ENDIAN:i};l.prototype={},l.prototype.getPosition=function(){return this.position},l.prototype._realloc=function(e){if(this._dynamicSize){var t=this._byteOffset+this.position+e,i=this._buffer.byteLength;if(t<=i)t>this._byteLength&&(this._byteLength=t);else{for(i<1&&(i=1);t>i;)i*=2;var s=new ArrayBuffer(i),r=new Uint8Array(this._buffer);new Uint8Array(s,0,r.length).set(r),this.buffer=s,this._byteLength=t}}},l.prototype._trimAlloc=function(){if(this._byteLength!=this._buffer.byteLength){var e=new ArrayBuffer(this._byteLength),t=new Uint8Array(e),i=new Uint8Array(this._buffer,0,t.length);t.set(i),this.buffer=e}},l.BIG_ENDIAN=!1,l.LITTLE_ENDIAN=!0,l.prototype._byteLength=0,Object.defineProperty(l.prototype,"byteLength",{get:function(){return this._byteLength-this._byteOffset}}),Object.defineProperty(l.prototype,"buffer",{get:function(){return this._trimAlloc(),this._buffer},set:function(e){this._buffer=e,this._dataView=new DataView(this._buffer,this._byteOffset),this._byteLength=this._buffer.byteLength}}),Object.defineProperty(l.prototype,"byteOffset",{get:function(){return this._byteOffset},set:function(e){this._byteOffset=e,this._dataView=new DataView(this._buffer,this._byteOffset),this._byteLength=this._buffer.byteLength}}),Object.defineProperty(l.prototype,"dataView",{get:function(){return this._dataView},set:function(e){this._byteOffset=e.byteOffset,this._buffer=e.buffer,this._dataView=new DataView(this._buffer,this._byteOffset),this._byteLength=this._byteOffset+e.byteLength}}),l.prototype.seek=function(e){var t=Math.max(0,Math.min(this.byteLength,e));this.position=isNaN(t)||!isFinite(t)?0:t},l.prototype.isEof=function(){return this.position>=this._byteLength},l.prototype.mapUint8Array=function(e){this._realloc(1*e);var t=new Uint8Array(this._buffer,this.byteOffset+this.position,e);return this.position+=1*e,t},l.prototype.readInt32Array=function(e,t){e=null==e?this.byteLength-this.position/4:e;var i=new Int32Array(e);return l.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,e*i.BYTES_PER_ELEMENT),l.arrayToNative(i,null==t?this.endianness:t),this.position+=i.byteLength,i},l.prototype.readInt16Array=function(e,t){e=null==e?this.byteLength-this.position/2:e;var i=new Int16Array(e);return l.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,e*i.BYTES_PER_ELEMENT),l.arrayToNative(i,null==t?this.endianness:t),this.position+=i.byteLength,i},l.prototype.readInt8Array=function(e){e=null==e?this.byteLength-this.position:e;var t=new Int8Array(e);return l.memcpy(t.buffer,0,this.buffer,this.byteOffset+this.position,e*t.BYTES_PER_ELEMENT),this.position+=t.byteLength,t},l.prototype.readUint32Array=function(e,t){e=null==e?this.byteLength-this.position/4:e;var i=new Uint32Array(e);return l.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,e*i.BYTES_PER_ELEMENT),l.arrayToNative(i,null==t?this.endianness:t),this.position+=i.byteLength,i},l.prototype.readUint16Array=function(e,t){e=null==e?this.byteLength-this.position/2:e;var i=new Uint16Array(e);return l.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,e*i.BYTES_PER_ELEMENT),l.arrayToNative(i,null==t?this.endianness:t),this.position+=i.byteLength,i},l.prototype.readUint8Array=function(e){e=null==e?this.byteLength-this.position:e;var t=new Uint8Array(e);return l.memcpy(t.buffer,0,this.buffer,this.byteOffset+this.position,e*t.BYTES_PER_ELEMENT),this.position+=t.byteLength,t},l.prototype.readFloat64Array=function(e,t){e=null==e?this.byteLength-this.position/8:e;var i=new Float64Array(e);return l.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,e*i.BYTES_PER_ELEMENT),l.arrayToNative(i,null==t?this.endianness:t),this.position+=i.byteLength,i},l.prototype.readFloat32Array=function(e,t){e=null==e?this.byteLength-this.position/4:e;var i=new Float32Array(e);return l.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,e*i.BYTES_PER_ELEMENT),l.arrayToNative(i,null==t?this.endianness:t),this.position+=i.byteLength,i},l.prototype.readInt32=function(e){var t=this._dataView.getInt32(this.position,null==e?this.endianness:e);return this.position+=4,t},l.prototype.readInt16=function(e){var t=this._dataView.getInt16(this.position,null==e?this.endianness:e);return this.position+=2,t},l.prototype.readInt8=function(){var e=this._dataView.getInt8(this.position);return this.position+=1,e},l.prototype.readUint32=function(e){var t=this._dataView.getUint32(this.position,null==e?this.endianness:e);return this.position+=4,t},l.prototype.readUint16=function(e){var t=this._dataView.getUint16(this.position,null==e?this.endianness:e);return this.position+=2,t},l.prototype.readUint8=function(){var e=this._dataView.getUint8(this.position);return this.position+=1,e},l.prototype.readFloat32=function(e){var t=this._dataView.getFloat32(this.position,null==e?this.endianness:e);return this.position+=4,t},l.prototype.readFloat64=function(e){var t=this._dataView.getFloat64(this.position,null==e?this.endianness:e);return this.position+=8,t},l.endianness=new Int8Array(new Int16Array([1]).buffer)[0]>0,l.memcpy=function(e,t,i,s,r){var a=new Uint8Array(e,t,r),o=new Uint8Array(i,s,r);a.set(o)},l.arrayToNative=function(e,t){return t==this.endianness?e:this.flipArrayEndianness(e)},l.nativeToEndian=function(e,t){return this.endianness==t?e:this.flipArrayEndianness(e)},l.flipArrayEndianness=function(e){for(var t=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),i=0;i<e.byteLength;i+=e.BYTES_PER_ELEMENT)for(var s=i+e.BYTES_PER_ELEMENT-1,r=i;s>r;s--,r++){var a=t[r];t[r]=t[s],t[s]=a}return e},l.prototype.failurePosition=0,String.fromCharCodeUint8=function(e){for(var t=[],i=0;i<e.length;i++)t[i]=e[i];return String.fromCharCode.apply(null,t)},l.prototype.readString=function(e,t){return null==t||"ASCII"==t?String.fromCharCodeUint8.apply(null,[this.mapUint8Array(null==e?this.byteLength-this.position:e)]):new TextDecoder(t).decode(this.mapUint8Array(e))},l.prototype.readCString=function(e){var t=this.byteLength-this.position,i=new Uint8Array(this._buffer,this._byteOffset+this.position),s=t;null!=e&&(s=Math.min(e,t));for(var r=0;r<s&&0!==i[r];r++);var a=String.fromCharCodeUint8.apply(null,[this.mapUint8Array(r)]);return null!=e?this.position+=s-r:r!=t&&(this.position+=1),a};var d=Math.pow(2,32);l.prototype.readInt64=function(){return this.readInt32()*d+this.readUint32()},l.prototype.readUint64=function(){return this.readUint32()*d+this.readUint32()},l.prototype.readInt64=function(){return this.readUint32()*d+this.readUint32()},l.prototype.readUint24=function(){return(this.readUint8()<<16)+(this.readUint8()<<8)+this.readUint8()},t.DataStream=l,l.prototype.save=function(e){var t=new Blob([this.buffer]);if(!window.URL||!URL.createObjectURL)throw"DataStream.save: Can't create object URL.";var i=window.URL.createObjectURL(t),s=document.createElement("a");document.body.appendChild(s),s.setAttribute("href",i),s.setAttribute("download",e),s.setAttribute("target","_self"),s.click(),window.URL.revokeObjectURL(i)},l.prototype._dynamicSize=!0,Object.defineProperty(l.prototype,"dynamicSize",{get:function(){return this._dynamicSize},set:function(e){e||this._trimAlloc(),this._dynamicSize=e}}),l.prototype.shift=function(e){var t=new ArrayBuffer(this._byteLength-e),i=new Uint8Array(t),s=new Uint8Array(this._buffer,e,i.length);i.set(s),this.buffer=t,this.position-=e},l.prototype.writeInt32Array=function(e,t){if(this._realloc(4*e.length),e instanceof Int32Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)l.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength),this.mapInt32Array(e.length,t);else for(var i=0;i<e.length;i++)this.writeInt32(e[i],t)},l.prototype.writeInt16Array=function(e,t){if(this._realloc(2*e.length),e instanceof Int16Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)l.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength),this.mapInt16Array(e.length,t);else for(var i=0;i<e.length;i++)this.writeInt16(e[i],t)},l.prototype.writeInt8Array=function(e){if(this._realloc(1*e.length),e instanceof Int8Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)l.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength),this.mapInt8Array(e.length);else for(var t=0;t<e.length;t++)this.writeInt8(e[t])},l.prototype.writeUint32Array=function(e,t){if(this._realloc(4*e.length),e instanceof Uint32Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)l.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength),this.mapUint32Array(e.length,t);else for(var i=0;i<e.length;i++)this.writeUint32(e[i],t)},l.prototype.writeUint16Array=function(e,t){if(this._realloc(2*e.length),e instanceof Uint16Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)l.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength),this.mapUint16Array(e.length,t);else for(var i=0;i<e.length;i++)this.writeUint16(e[i],t)},l.prototype.writeUint8Array=function(e){if(this._realloc(1*e.length),e instanceof Uint8Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)l.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength),this.mapUint8Array(e.length);else for(var t=0;t<e.length;t++)this.writeUint8(e[t])},l.prototype.writeFloat64Array=function(e,t){if(this._realloc(8*e.length),e instanceof Float64Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)l.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength),this.mapFloat64Array(e.length,t);else for(var i=0;i<e.length;i++)this.writeFloat64(e[i],t)},l.prototype.writeFloat32Array=function(e,t){if(this._realloc(4*e.length),e instanceof Float32Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)l.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength),this.mapFloat32Array(e.length,t);else for(var i=0;i<e.length;i++)this.writeFloat32(e[i],t)},l.prototype.writeInt32=function(e,t){this._realloc(4),this._dataView.setInt32(this.position,e,null==t?this.endianness:t),this.position+=4},l.prototype.writeInt16=function(e,t){this._realloc(2),this._dataView.setInt16(this.position,e,null==t?this.endianness:t),this.position+=2},l.prototype.writeInt8=function(e){this._realloc(1),this._dataView.setInt8(this.position,e),this.position+=1},l.prototype.writeUint32=function(e,t){this._realloc(4),this._dataView.setUint32(this.position,e,null==t?this.endianness:t),this.position+=4},l.prototype.writeUint16=function(e,t){this._realloc(2),this._dataView.setUint16(this.position,e,null==t?this.endianness:t),this.position+=2},l.prototype.writeUint8=function(e){this._realloc(1),this._dataView.setUint8(this.position,e),this.position+=1},l.prototype.writeFloat32=function(e,t){this._realloc(4),this._dataView.setFloat32(this.position,e,null==t?this.endianness:t),this.position+=4},l.prototype.writeFloat64=function(e,t){this._realloc(8),this._dataView.setFloat64(this.position,e,null==t?this.endianness:t),this.position+=8},l.prototype.writeUCS2String=function(e,t,i){null==i&&(i=e.length);for(var s=0;s<e.length&&s<i;s++)this.writeUint16(e.charCodeAt(s),t);for(;s<i;s++)this.writeUint16(0)},l.prototype.writeString=function(e,t,i){var s=0;if(null==t||"ASCII"==t)if(null!=i){var r=Math.min(e.length,i);for(s=0;s<r;s++)this.writeUint8(e.charCodeAt(s));for(;s<i;s++)this.writeUint8(0)}else for(s=0;s<e.length;s++)this.writeUint8(e.charCodeAt(s));else this.writeUint8Array(new TextEncoder(t).encode(e.substring(0,i)))},l.prototype.writeCString=function(e,t){var i=0;if(null!=t){var s=Math.min(e.length,t);for(i=0;i<s;i++)this.writeUint8(e.charCodeAt(i));for(;i<t;i++)this.writeUint8(0)}else{for(i=0;i<e.length;i++)this.writeUint8(e.charCodeAt(i));this.writeUint8(0)}},l.prototype.writeStruct=function(e,t){for(var i=0;i<e.length;i+=2){var s=e[i+1];this.writeType(s,t[e[i]],t)}},l.prototype.writeType=function(e,t,i){var s;if("function"==typeof e)return e(this,t);if("object"==typeof e&&!(e instanceof Array))return e.set(this,t,i);var r=null,a="ASCII",o=this.position;switch("string"==typeof e&&/:/.test(e)&&(s=e.split(":"),e=s[0],r=parseInt(s[1])),"string"==typeof e&&/,/.test(e)&&(s=e.split(","),e=s[0],a=parseInt(s[1])),e){case"uint8":this.writeUint8(t);break;case"int8":this.writeInt8(t);break;case"uint16":this.writeUint16(t,this.endianness);break;case"int16":this.writeInt16(t,this.endianness);break;case"uint32":this.writeUint32(t,this.endianness);break;case"int32":this.writeInt32(t,this.endianness);break;case"float32":this.writeFloat32(t,this.endianness);break;case"float64":this.writeFloat64(t,this.endianness);break;case"uint16be":this.writeUint16(t,l.BIG_ENDIAN);break;case"int16be":this.writeInt16(t,l.BIG_ENDIAN);break;case"uint32be":this.writeUint32(t,l.BIG_ENDIAN);break;case"int32be":this.writeInt32(t,l.BIG_ENDIAN);break;case"float32be":this.writeFloat32(t,l.BIG_ENDIAN);break;case"float64be":this.writeFloat64(t,l.BIG_ENDIAN);break;case"uint16le":this.writeUint16(t,l.LITTLE_ENDIAN);break;case"int16le":this.writeInt16(t,l.LITTLE_ENDIAN);break;case"uint32le":this.writeUint32(t,l.LITTLE_ENDIAN);break;case"int32le":this.writeInt32(t,l.LITTLE_ENDIAN);break;case"float32le":this.writeFloat32(t,l.LITTLE_ENDIAN);break;case"float64le":this.writeFloat64(t,l.LITTLE_ENDIAN);break;case"cstring":this.writeCString(t,r);break;case"string":this.writeString(t,a,r);break;case"u16string":this.writeUCS2String(t,this.endianness,r);break;case"u16stringle":this.writeUCS2String(t,l.LITTLE_ENDIAN,r);break;case"u16stringbe":this.writeUCS2String(t,l.BIG_ENDIAN,r);break;default:if(3==e.length){for(var n=e[1],d=0;d<t.length;d++)this.writeType(n,t[d]);break}this.writeStruct(e,t)}null!=r&&(this.position=o,this._realloc(r),this.position=o+r)},l.prototype.writeUint64=function(e){var t=Math.floor(e/d);this.writeUint32(t),this.writeUint32(4294967295&e)},l.prototype.writeUint24=function(e){this.writeUint8((16711680&e)>>16),this.writeUint8((65280&e)>>8),this.writeUint8(255&e)},l.prototype.adjustUint32=function(e,t){var i=this.position;this.seek(e),this.writeUint32(t),this.seek(i)},l.prototype.mapInt32Array=function(e,t){this._realloc(4*e);var i=new Int32Array(this._buffer,this.byteOffset+this.position,e);return l.arrayToNative(i,null==t?this.endianness:t),this.position+=4*e,i},l.prototype.mapInt16Array=function(e,t){this._realloc(2*e);var i=new Int16Array(this._buffer,this.byteOffset+this.position,e);return l.arrayToNative(i,null==t?this.endianness:t),this.position+=2*e,i},l.prototype.mapInt8Array=function(e){this._realloc(1*e);var t=new Int8Array(this._buffer,this.byteOffset+this.position,e);return this.position+=1*e,t},l.prototype.mapUint32Array=function(e,t){this._realloc(4*e);var i=new Uint32Array(this._buffer,this.byteOffset+this.position,e);return l.arrayToNative(i,null==t?this.endianness:t),this.position+=4*e,i},l.prototype.mapUint16Array=function(e,t){this._realloc(2*e);var i=new Uint16Array(this._buffer,this.byteOffset+this.position,e);return l.arrayToNative(i,null==t?this.endianness:t),this.position+=2*e,i},l.prototype.mapFloat64Array=function(e,t){this._realloc(8*e);var i=new Float64Array(this._buffer,this.byteOffset+this.position,e);return l.arrayToNative(i,null==t?this.endianness:t),this.position+=8*e,i},l.prototype.mapFloat32Array=function(e,t){this._realloc(4*e);var i=new Float32Array(this._buffer,this.byteOffset+this.position,e);return l.arrayToNative(i,null==t?this.endianness:t),this.position+=4*e,i};var h=function(e){this.buffers=[],this.bufferIndex=-1,e&&(this.insertBuffer(e),this.bufferIndex=0)};(h.prototype=new l(new ArrayBuffer,0,l.BIG_ENDIAN)).initialized=function(){var e;return this.bufferIndex>-1||(this.buffers.length>0?0===(e=this.buffers[0]).fileStart?(this.buffer=e,this.bufferIndex=0,o.debug("MultiBufferStream","Stream ready for parsing"),!0):(o.warn("MultiBufferStream","The first buffer should have a fileStart of 0"),this.logBufferLevel(),!1):(o.warn("MultiBufferStream","No buffer to start parsing from"),this.logBufferLevel(),!1))},ArrayBuffer.concat=function(e,t){o.debug("ArrayBuffer","Trying to create a new buffer of size: "+(e.byteLength+t.byteLength));var i=new Uint8Array(e.byteLength+t.byteLength);return i.set(new Uint8Array(e),0),i.set(new Uint8Array(t),e.byteLength),i.buffer},h.prototype.reduceBuffer=function(e,t,i){var s;return(s=new Uint8Array(i)).set(new Uint8Array(e,t,i)),s.buffer.fileStart=e.fileStart+t,s.buffer.usedBytes=0,s.buffer},h.prototype.insertBuffer=function(e){for(var t=!0,i=0;i<this.buffers.length;i++){var s=this.buffers[i];if(e.fileStart<=s.fileStart){if(e.fileStart===s.fileStart){if(e.byteLength>s.byteLength){this.buffers.splice(i,1),i--;continue}o.warn("MultiBufferStream","Buffer (fileStart: "+e.fileStart+" - Length: "+e.byteLength+") already appended, ignoring")}else e.fileStart+e.byteLength<=s.fileStart||(e=this.reduceBuffer(e,0,s.fileStart-e.fileStart)),o.debug("MultiBufferStream","Appending new buffer (fileStart: "+e.fileStart+" - Length: "+e.byteLength+")"),this.buffers.splice(i,0,e),0===i&&(this.buffer=e);t=!1;break}if(e.fileStart<s.fileStart+s.byteLength){var r=s.fileStart+s.byteLength-e.fileStart,a=e.byteLength-r;if(!(a>0)){t=!1;break}e=this.reduceBuffer(e,r,a)}}t&&(o.debug("MultiBufferStream","Appending new buffer (fileStart: "+e.fileStart+" - Length: "+e.byteLength+")"),this.buffers.push(e),0===i&&(this.buffer=e))},h.prototype.logBufferLevel=function(e){var t,i,s,r,a,n=[],l="";for(s=0,r=0,t=0;t<this.buffers.length;t++)i=this.buffers[t],0===t?(a={},n.push(a),a.start=i.fileStart,a.end=i.fileStart+i.byteLength,l+="["+a.start+"-"):a.end===i.fileStart?a.end=i.fileStart+i.byteLength:((a={}).start=i.fileStart,l+=n[n.length-1].end-1+"], ["+a.start+"-",a.end=i.fileStart+i.byteLength,n.push(a)),s+=i.usedBytes,r+=i.byteLength;n.length>0&&(l+=a.end-1+"]");var d=e?o.info:o.debug;0===this.buffers.length?d("MultiBufferStream","No more buffer in memory"):d("MultiBufferStream",this.buffers.length+" stored buffer(s) ("+s+"/"+r+" bytes), continuous ranges: "+l)},h.prototype.cleanBuffers=function(){var e,t;for(e=0;e<this.buffers.length;e++)(t=this.buffers[e]).usedBytes===t.byteLength&&(o.debug("MultiBufferStream","Removing buffer #"+e),this.buffers.splice(e,1),e--)},h.prototype.mergeNextBuffer=function(){var e;if(this.bufferIndex+1<this.buffers.length){if((e=this.buffers[this.bufferIndex+1]).fileStart===this.buffer.fileStart+this.buffer.byteLength){var t=this.buffer.byteLength,i=this.buffer.usedBytes,s=this.buffer.fileStart;return this.buffers[this.bufferIndex]=ArrayBuffer.concat(this.buffer,e),this.buffer=this.buffers[this.bufferIndex],this.buffers.splice(this.bufferIndex+1,1),this.buffer.usedBytes=i,this.buffer.fileStart=s,o.debug("ISOFile","Concatenating buffer for box parsing (length: "+t+"->"+this.buffer.byteLength+")"),!0}return!1}return!1},h.prototype.findPosition=function(e,t,i){var s,r=null,a=-1;for(s=!0===e?0:this.bufferIndex;s<this.buffers.length&&(r=this.buffers[s]).fileStart<=t;)a=s,i&&(r.fileStart+r.byteLength<=t?r.usedBytes=r.byteLength:r.usedBytes=t-r.fileStart,this.logBufferLevel()),s++;return-1!==a&&(r=this.buffers[a]).fileStart+r.byteLength>=t?(o.debug("MultiBufferStream","Found position in existing buffer #"+a),a):-1},h.prototype.findEndContiguousBuf=function(e){var t,i,s,r=void 0!==e?e:this.bufferIndex;if(i=this.buffers[r],this.buffers.length>r+1)for(t=r+1;t<this.buffers.length&&(s=this.buffers[t]).fileStart===i.fileStart+i.byteLength;t++)i=s;return i.fileStart+i.byteLength},h.prototype.getEndFilePositionAfter=function(e){var t=this.findPosition(!0,e,!1);return-1!==t?this.findEndContiguousBuf(t):e},h.prototype.addUsedBytes=function(e){this.buffer.usedBytes+=e,this.logBufferLevel()},h.prototype.setAllUsedBytes=function(){this.buffer.usedBytes=this.buffer.byteLength,this.logBufferLevel()},h.prototype.seek=function(e,t,i){var s;return-1!==(s=this.findPosition(t,e,i))?(this.buffer=this.buffers[s],this.bufferIndex=s,this.position=e-this.buffer.fileStart,o.debug("MultiBufferStream","Repositioning parser at buffer position: "+this.position),!0):(o.debug("MultiBufferStream","Position "+e+" not found in buffered data"),!1)},h.prototype.getPosition=function(){if(-1===this.bufferIndex||null===this.buffers[this.bufferIndex])throw"Error accessing position in the MultiBufferStream";return this.buffers[this.bufferIndex].fileStart+this.position},h.prototype.getLength=function(){return this.byteLength},h.prototype.getEndPosition=function(){if(-1===this.bufferIndex||null===this.buffers[this.bufferIndex])throw"Error accessing position in the MultiBufferStream";return this.buffers[this.bufferIndex].fileStart+this.byteLength},h.prototype.destroy=function(){this.buffers=[],this.bufferIndex},t.MultiBufferStream=h;var c=function(){var e=[];e[3]="ES_Descriptor",e[4]="DecoderConfigDescriptor",e[5]="DecoderSpecificInfo",e[6]="SLConfigDescriptor",this.getDescriptorName=function(t){return e[t]};var t=this,i={};return this.parseOneDescriptor=function(t){var s,r,a,n=0;for(s=t.readUint8(),a=t.readUint8();128&a;)n=(127&a)<<7,a=t.readUint8();return n+=127&a,o.debug("MPEG4DescriptorParser","Found "+(e[s]||"Descriptor "+s)+", size "+n+" at position "+t.getPosition()),(r=e[s]?new i[e[s]](n):new i.Descriptor(n)).parse(t),r},i.Descriptor=function(e,t){this.tag=e,this.size=t,this.descs=[]},i.Descriptor.prototype.parse=function(e){this.data=e.readUint8Array(this.size)},i.Descriptor.prototype.findDescriptor=function(e){for(var t=0;t<this.descs.length;t++)if(this.descs[t].tag==e)return this.descs[t];return null},i.Descriptor.prototype.parseRemainingDescriptors=function(e){for(var i=e.position;e.position<i+this.size;){var s=t.parseOneDescriptor(e);this.descs.push(s)}},i.ES_Descriptor=function(e){i.Descriptor.call(this,3,e)},i.ES_Descriptor.prototype=new i.Descriptor,i.ES_Descriptor.prototype.parse=function(e){if(this.ES_ID=e.readUint16(),this.flags=e.readUint8(),this.size-=3,128&this.flags?(this.dependsOn_ES_ID=e.readUint16(),this.size-=2):this.dependsOn_ES_ID=0,64&this.flags){var t=e.readUint8();this.URL=e.readString(t),this.size-=t+1}else this.URL="";32&this.flags?(this.OCR_ES_ID=e.readUint16(),this.size-=2):this.OCR_ES_ID=0,this.parseRemainingDescriptors(e)},i.ES_Descriptor.prototype.getOTI=function(e){var t=this.findDescriptor(4);return t?t.oti:0},i.ES_Descriptor.prototype.getAudioConfig=function(e){var t=this.findDescriptor(4);if(!t)return null;var i=t.findDescriptor(5);if(i&&i.data){var s=(248&i.data[0])>>3;return 31===s&&i.data.length>=2&&(s=32+((7&i.data[0])<<3)+((224&i.data[1])>>5)),s}return null},i.DecoderConfigDescriptor=function(e){i.Descriptor.call(this,4,e)},i.DecoderConfigDescriptor.prototype=new i.Descriptor,i.DecoderConfigDescriptor.prototype.parse=function(e){this.oti=e.readUint8(),this.streamType=e.readUint8(),this.upStream=!!(this.streamType>>1&1),this.streamType=this.streamType>>>2,this.bufferSize=e.readUint24(),this.maxBitrate=e.readUint32(),this.avgBitrate=e.readUint32(),this.size-=13,this.parseRemainingDescriptors(e)},i.DecoderSpecificInfo=function(e){i.Descriptor.call(this,5,e)},i.DecoderSpecificInfo.prototype=new i.Descriptor,i.SLConfigDescriptor=function(e){i.Descriptor.call(this,6,e)},i.SLConfigDescriptor.prototype=new i.Descriptor,this};t.MPEG4DescriptorParser=c;var u={ERR_INVALID_DATA:-1,ERR_NOT_ENOUGH_DATA:0,OK:1,BASIC_BOXES:["mdat","idat","free","skip","meco","strk"],FULL_BOXES:["hmhd","nmhd","iods","xml ","bxml","ipro","mere"],CONTAINER_BOXES:[["moov",["trak","pssh"]],["trak"],["edts"],["mdia"],["minf"],["dinf"],["stbl",["sgpd","sbgp"]],["mvex",["trex"]],["moof",["traf"]],["traf",["trun","sgpd","sbgp"]],["vttc"],["tref"],["iref"],["mfra",["tfra"]],["meco"],["hnti"],["hinf"],["strk"],["strd"],["sinf"],["rinf"],["schi"],["trgr"],["udta",["kind"]],["iprp",["ipma"]],["ipco"],["grpl"],["j2kH"],["etyp",["tyco"]]],boxCodes:[],fullBoxCodes:[],containerBoxCodes:[],sampleEntryCodes:{},sampleGroupEntryCodes:[],trackGroupTypes:[],UUIDBoxes:{},UUIDs:[],initialize:function(){u.FullBox.prototype=new u.Box,u.ContainerBox.prototype=new u.Box,u.SampleEntry.prototype=new u.Box,u.TrackGroupTypeBox.prototype=new u.FullBox,u.BASIC_BOXES.forEach((function(e){u.createBoxCtor(e)})),u.FULL_BOXES.forEach((function(e){u.createFullBoxCtor(e)})),u.CONTAINER_BOXES.forEach((function(e){u.createContainerBoxCtor(e[0],null,e[1])}))},Box:function(e,t,i){this.type=e,this.size=t,this.uuid=i},FullBox:function(e,t,i){u.Box.call(this,e,t,i),this.flags=0,this.version=0},ContainerBox:function(e,t,i){u.Box.call(this,e,t,i),this.boxes=[]},SampleEntry:function(e,t,i,s){u.ContainerBox.call(this,e,t),this.hdr_size=i,this.start=s},SampleGroupEntry:function(e){this.grouping_type=e},TrackGroupTypeBox:function(e,t){u.FullBox.call(this,e,t)},createBoxCtor:function(e,t){u.boxCodes.push(e),u[e+"Box"]=function(t){u.Box.call(this,e,t)},u[e+"Box"].prototype=new u.Box,t&&(u[e+"Box"].prototype.parse=t)},createFullBoxCtor:function(e,t){u[e+"Box"]=function(t){u.FullBox.call(this,e,t)},u[e+"Box"].prototype=new u.FullBox,u[e+"Box"].prototype.parse=function(e){this.parseFullHeader(e),t&&t.call(this,e)}},addSubBoxArrays:function(e){if(e){this.subBoxNames=e;for(var t=e.length,i=0;i<t;i++)this[e[i]+"s"]=[]}},createContainerBoxCtor:function(e,t,i){u[e+"Box"]=function(t){u.ContainerBox.call(this,e,t),u.addSubBoxArrays.call(this,i)},u[e+"Box"].prototype=new u.ContainerBox,t&&(u[e+"Box"].prototype.parse=t)},createMediaSampleEntryCtor:function(e,t,i){u.sampleEntryCodes[e]=[],u[e+"SampleEntry"]=function(e,t){u.SampleEntry.call(this,e,t),u.addSubBoxArrays.call(this,i)},u[e+"SampleEntry"].prototype=new u.SampleEntry,t&&(u[e+"SampleEntry"].prototype.parse=t)},createSampleEntryCtor:function(e,t,i,s){u.sampleEntryCodes[e].push(t),u[t+"SampleEntry"]=function(i){u[e+"SampleEntry"].call(this,t,i),u.addSubBoxArrays.call(this,s)},u[t+"SampleEntry"].prototype=new u[e+"SampleEntry"],i&&(u[t+"SampleEntry"].prototype.parse=i)},createEncryptedSampleEntryCtor:function(e,t,i){u.createSampleEntryCtor.call(this,e,t,i,["sinf"])},createSampleGroupCtor:function(e,t){u[e+"SampleGroupEntry"]=function(t){u.SampleGroupEntry.call(this,e,t)},u[e+"SampleGroupEntry"].prototype=new u.SampleGroupEntry,t&&(u[e+"SampleGroupEntry"].prototype.parse=t)},createTrackGroupCtor:function(e,t){u[e+"TrackGroupTypeBox"]=function(t){u.TrackGroupTypeBox.call(this,e,t)},u[e+"TrackGroupTypeBox"].prototype=new u.TrackGroupTypeBox,t&&(u[e+"TrackGroupTypeBox"].prototype.parse=t)},createUUIDBox:function(e,t,i,s){u.UUIDs.push(e),u.UUIDBoxes[e]=function(s){t?u.FullBox.call(this,"uuid",s,e):i?u.ContainerBox.call(this,"uuid",s,e):u.Box.call(this,"uuid",s,e)},u.UUIDBoxes[e].prototype=t?new u.FullBox:i?new u.ContainerBox:new u.Box,s&&(u.UUIDBoxes[e].prototype.parse=t?function(e){this.parseFullHeader(e),s&&s.call(this,e)}:s)}};function p(e,t){this.x=e,this.y=t}function f(e,t){this.bad_pixel_row=e,this.bad_pixel_column=t}u.initialize(),u.TKHD_FLAG_ENABLED=1,u.TKHD_FLAG_IN_MOVIE=2,u.TKHD_FLAG_IN_PREVIEW=4,u.TFHD_FLAG_BASE_DATA_OFFSET=1,u.TFHD_FLAG_SAMPLE_DESC=2,u.TFHD_FLAG_SAMPLE_DUR=8,u.TFHD_FLAG_SAMPLE_SIZE=16,u.TFHD_FLAG_SAMPLE_FLAGS=32,u.TFHD_FLAG_DUR_EMPTY=65536,u.TFHD_FLAG_DEFAULT_BASE_IS_MOOF=131072,u.TRUN_FLAGS_DATA_OFFSET=1,u.TRUN_FLAGS_FIRST_FLAG=4,u.TRUN_FLAGS_DURATION=256,u.TRUN_FLAGS_SIZE=512,u.TRUN_FLAGS_FLAGS=1024,u.TRUN_FLAGS_CTS_OFFSET=2048,u.Box.prototype.add=function(e){return this.addBox(new u[e+"Box"])},u.Box.prototype.addBox=function(e){return this.boxes.push(e),this[e.type+"s"]?this[e.type+"s"].push(e):this[e.type]=e,e},u.Box.prototype.set=function(e,t){return this[e]=t,this},u.Box.prototype.addEntry=function(e,t){var i=t||"entries";return this[i]||(this[i]=[]),this[i].push(e),this},t.BoxParser=u,u.parseUUID=function(e){return u.parseHex16(e)},u.parseHex16=function(e){for(var t="",i=0;i<16;i++){var s=e.readUint8().toString(16);t+=1===s.length?"0"+s:s}return t},u.parseOneBox=function(e,t,i){var s,r,a,n=e.getPosition(),l=0;if(e.getEndPosition()-n<8)return o.debug("BoxParser","Not enough data in stream to parse the type and size of the box"),{code:u.ERR_NOT_ENOUGH_DATA};if(i&&i<8)return o.debug("BoxParser","Not enough bytes left in the parent box to parse a new box"),{code:u.ERR_NOT_ENOUGH_DATA};var d=e.readUint32(),h=e.readString(4),c=h;if(o.debug("BoxParser","Found box of type '"+h+"' and size "+d+" at position "+n),l=8,"uuid"==h){if(e.getEndPosition()-e.getPosition()<16||i-l<16)return e.seek(n),o.debug("BoxParser","Not enough bytes left in the parent box to parse a UUID box"),{code:u.ERR_NOT_ENOUGH_DATA};l+=16,c=a=u.parseUUID(e)}if(1==d){if(e.getEndPosition()-e.getPosition()<8||i&&i-l<8)return e.seek(n),o.warn("BoxParser",'Not enough data in stream to parse the extended size of the "'+h+'" box'),{code:u.ERR_NOT_ENOUGH_DATA};d=e.readUint64(),l+=8}else if(0===d)if(i)d=i;else if("mdat"!==h)return o.error("BoxParser","Unlimited box size not supported for type: '"+h+"'"),s=new u.Box(h,d),{code:u.OK,box:s,size:s.size};return 0!==d&&d<l?(o.error("BoxParser","Box of type "+h+" has an invalid size "+d+" (too small to be a box)"),{code:u.ERR_NOT_ENOUGH_DATA,type:h,size:d,hdr_size:l,start:n}):0!==d&&i&&d>i?(o.error("BoxParser","Box of type '"+h+"' has a size "+d+" greater than its container size "+i),{code:u.ERR_NOT_ENOUGH_DATA,type:h,size:d,hdr_size:l,start:n}):0!==d&&n+d>e.getEndPosition()?(e.seek(n),o.info("BoxParser","Not enough data in stream to parse the entire '"+h+"' box"),{code:u.ERR_NOT_ENOUGH_DATA,type:h,size:d,hdr_size:l,start:n}):t?{code:u.OK,type:h,size:d,hdr_size:l,start:n}:(u[h+"Box"]?s=new u[h+"Box"](d):"uuid"!==h?(o.warn("BoxParser","Unknown box type: '"+h+"'"),(s=new u.Box(h,d)).has_unparsed_data=!0):u.UUIDBoxes[a]?s=new u.UUIDBoxes[a](d):(o.warn("BoxParser","Unknown uuid type: '"+a+"'"),(s=new u.Box(h,d)).uuid=a,s.has_unparsed_data=!0),s.hdr_size=l,s.start=n,s.write===u.Box.prototype.write&&"mdat"!==s.type&&(o.info("BoxParser","'"+c+"' box writing not yet implemented, keeping unparsed data in memory for later write"),s.parseDataAndRewind(e)),s.parse(e),(r=e.getPosition()-(s.start+s.size))<0?(o.warn("BoxParser","Parsing of box '"+c+"' did not read the entire indicated box data size (missing "+-r+" bytes), seeking forward"),e.seek(s.start+s.size)):r>0&&(o.error("BoxParser","Parsing of box '"+c+"' read "+r+" more bytes than the indicated box data size, seeking backwards"),0!==s.size&&e.seek(s.start+s.size)),{code:u.OK,box:s,size:s.size})},u.Box.prototype.parse=function(e){"mdat"!=this.type?this.data=e.readUint8Array(this.size-this.hdr_size):0===this.size?e.seek(e.getEndPosition()):e.seek(this.start+this.size)},u.Box.prototype.parseDataAndRewind=function(e){this.data=e.readUint8Array(this.size-this.hdr_size),e.position-=this.size-this.hdr_size},u.FullBox.prototype.parseDataAndRewind=function(e){this.parseFullHeader(e),this.data=e.readUint8Array(this.size-this.hdr_size),this.hdr_size-=4,e.position-=this.size-this.hdr_size},u.FullBox.prototype.parseFullHeader=function(e){this.version=e.readUint8(),this.flags=e.readUint24(),this.hdr_size+=4},u.FullBox.prototype.parse=function(e){this.parseFullHeader(e),this.data=e.readUint8Array(this.size-this.hdr_size)},u.ContainerBox.prototype.parse=function(e){for(var t,i;e.getPosition()<this.start+this.size;){if((t=u.parseOneBox(e,!1,this.size-(e.getPosition()-this.start))).code!==u.OK)return;if(i=t.box,this.boxes.push(i),this.subBoxNames&&-1!=this.subBoxNames.indexOf(i.type))this[this.subBoxNames[this.subBoxNames.indexOf(i.type)]+"s"].push(i);else{var s="uuid"!==i.type?i.type:i.uuid;this[s]?o.warn("Box of type "+s+" already stored in field of this type"):this[s]=i}}},u.Box.prototype.parseLanguage=function(e){this.language=e.readUint16();var t=[];t[0]=this.language>>10&31,t[1]=this.language>>5&31,t[2]=31&this.language,this.languageString=String.fromCharCode(t[0]+96,t[1]+96,t[2]+96)},u.SAMPLE_ENTRY_TYPE_VISUAL="Visual",u.SAMPLE_ENTRY_TYPE_AUDIO="Audio",u.SAMPLE_ENTRY_TYPE_HINT="Hint",u.SAMPLE_ENTRY_TYPE_METADATA="Metadata",u.SAMPLE_ENTRY_TYPE_SUBTITLE="Subtitle",u.SAMPLE_ENTRY_TYPE_SYSTEM="System",u.SAMPLE_ENTRY_TYPE_TEXT="Text",u.SampleEntry.prototype.parseHeader=function(e){e.readUint8Array(6),this.data_reference_index=e.readUint16(),this.hdr_size+=8},u.SampleEntry.prototype.parse=function(e){this.parseHeader(e),this.data=e.readUint8Array(this.size-this.hdr_size)},u.SampleEntry.prototype.parseDataAndRewind=function(e){this.parseHeader(e),this.data=e.readUint8Array(this.size-this.hdr_size),this.hdr_size-=8,e.position-=this.size-this.hdr_size},u.SampleEntry.prototype.parseFooter=function(e){u.ContainerBox.prototype.parse.call(this,e)},u.createMediaSampleEntryCtor(u.SAMPLE_ENTRY_TYPE_HINT),u.createMediaSampleEntryCtor(u.SAMPLE_ENTRY_TYPE_METADATA),u.createMediaSampleEntryCtor(u.SAMPLE_ENTRY_TYPE_SUBTITLE),u.createMediaSampleEntryCtor(u.SAMPLE_ENTRY_TYPE_SYSTEM),u.createMediaSampleEntryCtor(u.SAMPLE_ENTRY_TYPE_TEXT),u.createMediaSampleEntryCtor(u.SAMPLE_ENTRY_TYPE_VISUAL,(function(e){var t;this.parseHeader(e),e.readUint16(),e.readUint16(),e.readUint32Array(3),this.width=e.readUint16(),this.height=e.readUint16(),this.horizresolution=e.readUint32(),this.vertresolution=e.readUint32(),e.readUint32(),this.frame_count=e.readUint16(),t=Math.min(31,e.readUint8()),this.compressorname=e.readString(t),t<31&&e.readString(31-t),this.depth=e.readUint16(),e.readUint16(),this.parseFooter(e)})),u.createMediaSampleEntryCtor(u.SAMPLE_ENTRY_TYPE_AUDIO,(function(e){this.parseHeader(e),e.readUint32Array(2),this.channel_count=e.readUint16(),this.samplesize=e.readUint16(),e.readUint16(),e.readUint16(),this.samplerate=e.readUint32()/65536,this.parseFooter(e)})),u.createSampleEntryCtor(u.SAMPLE_ENTRY_TYPE_VISUAL,"avc1"),u.createSampleEntryCtor(u.SAMPLE_ENTRY_TYPE_VISUAL,"avc2"),u.createSampleEntryCtor(u.SAMPLE_ENTRY_TYPE_VISUAL,"avc3"),u.createSampleEntryCtor(u.SAMPLE_ENTRY_TYPE_VISUAL,"avc4"),u.createSampleEntryCtor(u.SAMPLE_ENTRY_TYPE_VISUAL,"av01"),u.createSampleEntryCtor(u.SAMPLE_ENTRY_TYPE_VISUAL,"dav1"),u.createSampleEntryCtor(u.SAMPLE_ENTRY_TYPE_VISUAL,"hvc1"),u.createSampleEntryCtor(u.SAMPLE_ENTRY_TYPE_VISUAL,"hev1"),u.createSampleEntryCtor(u.SAMPLE_ENTRY_TYPE_VISUAL,"hvt1"),u.createSampleEntryCtor(u.SAMPLE_ENTRY_TYPE_VISUAL,"lhe1"),u.createSampleEntryCtor(u.SAMPLE_ENTRY_TYPE_VISUAL,"dvh1"),u.createSampleEntryCtor(u.SAMPLE_ENTRY_TYPE_VISUAL,"dvhe"),u.createSampleEntryCtor(u.SAMPLE_ENTRY_TYPE_VISUAL,"vvc1"),u.createSampleEntryCtor(u.SAMPLE_ENTRY_TYPE_VISUAL,"vvi1"),u.createSampleEntryCtor(u.SAMPLE_ENTRY_TYPE_VISUAL,"vvs1"),u.createSampleEntryCtor(u.SAMPLE_ENTRY_TYPE_VISUAL,"vvcN"),u.createSampleEntryCtor(u.SAMPLE_ENTRY_TYPE_VISUAL,"vp08"),u.createSampleEntryCtor(u.SAMPLE_ENTRY_TYPE_VISUAL,"vp09"),u.createSampleEntryCtor(u.SAMPLE_ENTRY_TYPE_VISUAL,"avs3"),u.createSampleEntryCtor(u.SAMPLE_ENTRY_TYPE_VISUAL,"j2ki"),u.createSampleEntryCtor(u.SAMPLE_ENTRY_TYPE_VISUAL,"mjp2"),u.createSampleEntryCtor(u.SAMPLE_ENTRY_TYPE_VISUAL,"mjpg"),u.createSampleEntryCtor(u.SAMPLE_ENTRY_TYPE_VISUAL,"uncv"),u.createSampleEntryCtor(u.SAMPLE_ENTRY_TYPE_AUDIO,"mp4a"),u.createSampleEntryCtor(u.SAMPLE_ENTRY_TYPE_AUDIO,"ac-3"),u.createSampleEntryCtor(u.SAMPLE_ENTRY_TYPE_AUDIO,"ac-4"),u.createSampleEntryCtor(u.SAMPLE_ENTRY_TYPE_AUDIO,"ec-3"),u.createSampleEntryCtor(u.SAMPLE_ENTRY_TYPE_AUDIO,"Opus"),u.createSampleEntryCtor(u.SAMPLE_ENTRY_TYPE_AUDIO,"mha1"),u.createSampleEntryCtor(u.SAMPLE_ENTRY_TYPE_AUDIO,"mha2"),u.createSampleEntryCtor(u.SAMPLE_ENTRY_TYPE_AUDIO,"mhm1"),u.createSampleEntryCtor(u.SAMPLE_ENTRY_TYPE_AUDIO,"mhm2"),u.createEncryptedSampleEntryCtor(u.SAMPLE_ENTRY_TYPE_VISUAL,"encv"),u.createEncryptedSampleEntryCtor(u.SAMPLE_ENTRY_TYPE_AUDIO,"enca"),u.createEncryptedSampleEntryCtor(u.SAMPLE_ENTRY_TYPE_SUBTITLE,"encu"),u.createEncryptedSampleEntryCtor(u.SAMPLE_ENTRY_TYPE_SYSTEM,"encs"),u.createEncryptedSampleEntryCtor(u.SAMPLE_ENTRY_TYPE_TEXT,"enct"),u.createEncryptedSampleEntryCtor(u.SAMPLE_ENTRY_TYPE_METADATA,"encm"),u.createBoxCtor("a1lx",(function(e){var t=16*(1+(1&(1&e.readUint8())));this.layer_size=[];for(var i=0;i<3;i++)this.layer_size[i]=16==t?e.readUint16():e.readUint32()})),u.createBoxCtor("a1op",(function(e){this.op_index=e.readUint8()})),u.createFullBoxCtor("auxC",(function(e){this.aux_type=e.readCString();var t=this.size-this.hdr_size-(this.aux_type.length+1);this.aux_subtype=e.readUint8Array(t)})),u.createBoxCtor("av1C",(function(e){var t=e.readUint8();if(t>>7&!1)o.error("av1C marker problem");else if(this.version=127&t,1===this.version)if(t=e.readUint8(),this.seq_profile=t>>5&7,this.seq_level_idx_0=31&t,t=e.readUint8(),this.seq_tier_0=t>>7&1,this.high_bitdepth=t>>6&1,this.twelve_bit=t>>5&1,this.monochrome=t>>4&1,this.chroma_subsampling_x=t>>3&1,this.chroma_subsampling_y=t>>2&1,this.chroma_sample_position=3&t,t=e.readUint8(),this.reserved_1=t>>5&7,0===this.reserved_1){if(this.initial_presentation_delay_present=t>>4&1,1===this.initial_presentation_delay_present)this.initial_presentation_delay_minus_one=15&t;else if(this.reserved_2=15&t,0!==this.reserved_2)return void o.error("av1C reserved_2 parsing problem");var i=this.size-this.hdr_size-4;this.configOBUs=e.readUint8Array(i)}else o.error("av1C reserved_1 parsing problem");else o.error("av1C version "+this.version+" not supported")})),u.createBoxCtor("avcC",(function(e){var t,i;for(this.configurationVersion=e.readUint8(),this.AVCProfileIndication=e.readUint8(),this.profile_compatibility=e.readUint8(),this.AVCLevelIndication=e.readUint8(),this.lengthSizeMinusOne=3&e.readUint8(),this.nb_SPS_nalus=31&e.readUint8(),i=this.size-this.hdr_size-6,this.SPS=[],t=0;t<this.nb_SPS_nalus;t++)this.SPS[t]={},this.SPS[t].length=e.readUint16(),this.SPS[t].nalu=e.readUint8Array(this.SPS[t].length),i-=2+this.SPS[t].length;for(this.nb_PPS_nalus=e.readUint8(),i--,this.PPS=[],t=0;t<this.nb_PPS_nalus;t++)this.PPS[t]={},this.PPS[t].length=e.readUint16(),this.PPS[t].nalu=e.readUint8Array(this.PPS[t].length),i-=2+this.PPS[t].length;i>0&&(this.ext=e.readUint8Array(i))})),u.createBoxCtor("btrt",(function(e){this.bufferSizeDB=e.readUint32(),this.maxBitrate=e.readUint32(),this.avgBitrate=e.readUint32()})),u.createFullBoxCtor("ccst",(function(e){var t=e.readUint8();this.all_ref_pics_intra=!(128&~t),this.intra_pred_used=!(64&~t),this.max_ref_per_pic=(63&t)>>2,e.readUint24()})),u.createBoxCtor("cdef",(function(e){var t;for(this.channel_count=e.readUint16(),this.channel_indexes=[],this.channel_types=[],this.channel_associations=[],t=0;t<this.channel_count;t++)this.channel_indexes.push(e.readUint16()),this.channel_types.push(e.readUint16()),this.channel_associations.push(e.readUint16())})),u.createBoxCtor("clap",(function(e){this.cleanApertureWidthN=e.readUint32(),this.cleanApertureWidthD=e.readUint32(),this.cleanApertureHeightN=e.readUint32(),this.cleanApertureHeightD=e.readUint32(),this.horizOffN=e.readUint32(),this.horizOffD=e.readUint32(),this.vertOffN=e.readUint32(),this.vertOffD=e.readUint32()})),u.createBoxCtor("clli",(function(e){this.max_content_light_level=e.readUint16(),this.max_pic_average_light_level=e.readUint16()})),u.createFullBoxCtor("cmex",(function(e){1&this.flags&&(this.pos_x=e.readInt32()),2&this.flags&&(this.pos_y=e.readInt32()),4&this.flags&&(this.pos_z=e.readInt32()),8&this.flags&&(0==this.version?16&this.flags?(this.quat_x=e.readInt32(),this.quat_y=e.readInt32(),this.quat_z=e.readInt32()):(this.quat_x=e.readInt16(),this.quat_y=e.readInt16(),this.quat_z=e.readInt16()):this.version),32&this.flags&&(this.id=e.readUint32())})),u.createFullBoxCtor("cmin",(function(e){this.focal_length_x=e.readInt32(),this.principal_point_x=e.readInt32(),this.principal_point_y=e.readInt32(),1&this.flags&&(this.focal_length_y=e.readInt32(),this.skew_factor=e.readInt32())})),u.createBoxCtor("cmpd",(function(e){for(this.component_count=e.readUint32(),this.component_types=[],this.component_type_urls=[],i=0;i<this.component_count;i++){var t=e.readUint16();this.component_types.push(t),t>=32768&&this.component_type_urls.push(e.readCString())}})),u.createFullBoxCtor("co64",(function(e){var t,i;if(t=e.readUint32(),this.chunk_offsets=[],0===this.version)for(i=0;i<t;i++)this.chunk_offsets.push(e.readUint64())})),u.createFullBoxCtor("CoLL",(function(e){this.maxCLL=e.readUint16(),this.maxFALL=e.readUint16()})),u.createBoxCtor("colr",(function(e){if(this.colour_type=e.readString(4),"nclx"===this.colour_type){this.colour_primaries=e.readUint16(),this.transfer_characteristics=e.readUint16(),this.matrix_coefficients=e.readUint16();var t=e.readUint8();this.full_range_flag=t>>7}else("rICC"===this.colour_type||"prof"===this.colour_type)&&(this.ICC_profile=e.readUint8Array(this.size-4))})),u.createFullBoxCtor("cprt",(function(e){this.parseLanguage(e),this.notice=e.readCString()})),u.createFullBoxCtor("cslg",(function(e){0===this.version&&(this.compositionToDTSShift=e.readInt32(),this.leastDecodeToDisplayDelta=e.readInt32(),this.greatestDecodeToDisplayDelta=e.readInt32(),this.compositionStartTime=e.readInt32(),this.compositionEndTime=e.readInt32())})),u.createFullBoxCtor("ctts",(function(e){var t,i;if(t=e.readUint32(),this.sample_counts=[],this.sample_offsets=[],0===this.version)for(i=0;i<t;i++){this.sample_counts.push(e.readUint32());var s=e.readInt32();s<0&&o.warn("BoxParser","ctts box uses negative values without using version 1"),this.sample_offsets.push(s)}else if(1==this.version)for(i=0;i<t;i++)this.sample_counts.push(e.readUint32()),this.sample_offsets.push(e.readInt32())})),u.createBoxCtor("dac3",(function(e){var t=e.readUint8(),i=e.readUint8(),s=e.readUint8();this.fscod=t>>6,this.bsid=t>>1&31,this.bsmod=(1&t)<<2|i>>6&3,this.acmod=i>>3&7,this.lfeon=i>>2&1,this.bit_rate_code=3&i|s>>5&7})),u.createBoxCtor("dec3",(function(e){var t=e.readUint16();this.data_rate=t>>3,this.num_ind_sub=7&t,this.ind_subs=[];for(var i=0;i<this.num_ind_sub+1;i++){var s={};this.ind_subs.push(s);var r=e.readUint8(),a=e.readUint8(),o=e.readUint8();s.fscod=r>>6,s.bsid=r>>1&31,s.bsmod=(1&r)<<4|a>>4&15,s.acmod=a>>1&7,s.lfeon=1&a,s.num_dep_sub=o>>1&15,s.num_dep_sub>0&&(s.chan_loc=(1&o)<<8|e.readUint8())}})),u.createFullBoxCtor("dfLa",(function(e){var t=[],i=["STREAMINFO","PADDING","APPLICATION","SEEKTABLE","VORBIS_COMMENT","CUESHEET","PICTURE","RESERVED"];for(this.parseFullHeader(e);;){var s=e.readUint8(),r=Math.min(127&s,i.length-1);if(r?e.readUint8Array(e.readUint24()):(e.readUint8Array(13),this.samplerate=e.readUint32()>>12,e.readUint8Array(20)),t.push(i[r]),128&s)break}this.numMetadataBlocks=t.length+" ("+t.join(", ")+")"})),u.createBoxCtor("dimm",(function(e){this.bytessent=e.readUint64()})),u.createBoxCtor("dmax",(function(e){this.time=e.readUint32()})),u.createBoxCtor("dmed",(function(e){this.bytessent=e.readUint64()})),u.createBoxCtor("dOps",(function(e){if(this.Version=e.readUint8(),this.OutputChannelCount=e.readUint8(),this.PreSkip=e.readUint16(),this.InputSampleRate=e.readUint32(),this.OutputGain=e.readInt16(),this.ChannelMappingFamily=e.readUint8(),0!==this.ChannelMappingFamily){this.StreamCount=e.readUint8(),this.CoupledCount=e.readUint8(),this.ChannelMapping=[];for(var t=0;t<this.OutputChannelCount;t++)this.ChannelMapping[t]=e.readUint8()}})),u.createFullBoxCtor("dref",(function(e){var t,i;this.entries=[];for(var s=e.readUint32(),r=0;r<s;r++){if((t=u.parseOneBox(e,!1,this.size-(e.getPosition()-this.start))).code!==u.OK)return;i=t.box,this.entries.push(i)}})),u.createBoxCtor("drep",(function(e){this.bytessent=e.readUint64()})),u.createFullBoxCtor("elng",(function(e){this.extended_language=e.readString(this.size-this.hdr_size)})),u.createFullBoxCtor("elst",(function(e){this.entries=[];for(var t=e.readUint32(),i=0;i<t;i++){var s={};this.entries.push(s),1===this.version?(s.segment_duration=e.readUint64(),s.media_time=e.readInt64()):(s.segment_duration=e.readUint32(),s.media_time=e.readInt32()),s.media_rate_integer=e.readInt16(),s.media_rate_fraction=e.readInt16()}})),u.createFullBoxCtor("emsg",(function(e){1==this.version?(this.timescale=e.readUint32(),this.presentation_time=e.readUint64(),this.event_duration=e.readUint32(),this.id=e.readUint32(),this.scheme_id_uri=e.readCString(),this.value=e.readCString()):(this.scheme_id_uri=e.readCString(),this.value=e.readCString(),this.timescale=e.readUint32(),this.presentation_time_delta=e.readUint32(),this.event_duration=e.readUint32(),this.id=e.readUint32());var t=this.size-this.hdr_size-(16+(this.scheme_id_uri.length+1)+(this.value.length+1));1==this.version&&(t-=4),this.message_data=e.readUint8Array(t)})),u.createEntityToGroupCtor=function(e,t){u[e+"Box"]=function(t){u.FullBox.call(this,e,t)},u[e+"Box"].prototype=new u.FullBox,u[e+"Box"].prototype.parse=function(e){if(this.parseFullHeader(e),t)t.call(this,e);else for(this.group_id=e.readUint32(),this.num_entities_in_group=e.readUint32(),this.entity_ids=[],i=0;i<this.num_entities_in_group;i++){var s=e.readUint32();this.entity_ids.push(s)}}},u.createEntityToGroupCtor("aebr"),u.createEntityToGroupCtor("afbr"),u.createEntityToGroupCtor("albc"),u.createEntityToGroupCtor("altr"),u.createEntityToGroupCtor("brst"),u.createEntityToGroupCtor("dobr"),u.createEntityToGroupCtor("eqiv"),u.createEntityToGroupCtor("favc"),u.createEntityToGroupCtor("fobr"),u.createEntityToGroupCtor("iaug"),u.createEntityToGroupCtor("pano"),u.createEntityToGroupCtor("slid"),u.createEntityToGroupCtor("ster"),u.createEntityToGroupCtor("tsyn"),u.createEntityToGroupCtor("wbbr"),u.createEntityToGroupCtor("prgr"),u.createFullBoxCtor("esds",(function(e){var t=e.readUint8Array(this.size-this.hdr_size);if(void 0!==c){var i=new c;this.esd=i.parseOneDescriptor(new l(t.buffer,0,l.BIG_ENDIAN))}})),u.createBoxCtor("fiel",(function(e){this.fieldCount=e.readUint8(),this.fieldOrdering=e.readUint8()})),u.createBoxCtor("frma",(function(e){this.data_format=e.readString(4)})),u.createBoxCtor("ftyp",(function(e){var t=this.size-this.hdr_size;this.major_brand=e.readString(4),this.minor_version=e.readUint32(),t-=8,this.compatible_brands=[];for(var i=0;t>=4;)this.compatible_brands[i]=e.readString(4),t-=4,i++})),u.createFullBoxCtor("hdlr",(function(e){0===this.version&&(e.readUint32(),this.handler=e.readString(4),e.readUint32Array(3),this.name=e.readString(this.size-this.hdr_size-20),"\0"===this.name[this.name.length-1]&&(this.name=this.name.slice(0,-1)))})),u.createBoxCtor("hvcC",(function(e){var t,i,s,r;this.configurationVersion=e.readUint8(),r=e.readUint8(),this.general_profile_space=r>>6,this.general_tier_flag=(32&r)>>5,this.general_profile_idc=31&r,this.general_profile_compatibility=e.readUint32(),this.general_constraint_indicator=e.readUint8Array(6),this.general_level_idc=e.readUint8(),this.min_spatial_segmentation_idc=4095&e.readUint16(),this.parallelismType=3&e.readUint8(),this.chroma_format_idc=3&e.readUint8(),this.bit_depth_luma_minus8=7&e.readUint8(),this.bit_depth_chroma_minus8=7&e.readUint8(),this.avgFrameRate=e.readUint16(),r=e.readUint8(),this.constantFrameRate=r>>6,this.numTemporalLayers=(13&r)>>3,this.temporalIdNested=(4&r)>>2,this.lengthSizeMinusOne=3&r,this.nalu_arrays=[];var a=e.readUint8();for(t=0;t<a;t++){var o=[];this.nalu_arrays.push(o),r=e.readUint8(),o.completeness=(128&r)>>7,o.nalu_type=63&r;var n=e.readUint16();for(i=0;i<n;i++){var l={};o.push(l),s=e.readUint16(),l.data=e.readUint8Array(s)}}})),u.createFullBoxCtor("iinf",(function(e){var t;0===this.version?this.entry_count=e.readUint16():this.entry_count=e.readUint32(),this.item_infos=[];for(var i=0;i<this.entry_count;i++){if((t=u.parseOneBox(e,!1,this.size-(e.getPosition()-this.start))).code!==u.OK)return;"infe"!==t.box.type&&o.error("BoxParser","Expected 'infe' box, got "+t.box.type),this.item_infos[i]=t.box}})),u.createFullBoxCtor("iloc",(function(e){var t;t=e.readUint8(),this.offset_size=t>>4&15,this.length_size=15&t,t=e.readUint8(),this.base_offset_size=t>>4&15,1===this.version||2===this.version?this.index_size=15&t:this.index_size=0,this.items=[];var i=0;if(this.version<2)i=e.readUint16();else{if(2!==this.version)throw"version of iloc box not supported";i=e.readUint32()}for(var s=0;s<i;s++){var r={};if(this.items.push(r),this.version<2)r.item_ID=e.readUint16();else{if(2!==this.version)throw"version of iloc box not supported";r.item_ID=e.readUint32()}switch(1===this.version||2===this.version?r.construction_method=15&e.readUint16():r.construction_method=0,r.data_reference_index=e.readUint16(),this.base_offset_size){case 0:r.base_offset=0;break;case 4:r.base_offset=e.readUint32();break;case 8:r.base_offset=e.readUint64();break;default:throw"Error reading base offset size"}var a=e.readUint16();r.extents=[];for(var o=0;o<a;o++){var n={};if(r.extents.push(n),1===this.version||2===this.version)switch(this.index_size){case 0:n.extent_index=0;break;case 4:n.extent_index=e.readUint32();break;case 8:n.extent_index=e.readUint64();break;default:throw"Error reading extent index"}switch(this.offset_size){case 0:n.extent_offset=0;break;case 4:n.extent_offset=e.readUint32();break;case 8:n.extent_offset=e.readUint64();break;default:throw"Error reading extent index"}switch(this.length_size){case 0:n.extent_length=0;break;case 4:n.extent_length=e.readUint32();break;case 8:n.extent_length=e.readUint64();break;default:throw"Error reading extent index"}}}})),u.createBoxCtor("imir",(function(e){var t=e.readUint8();this.reserved=t>>7,this.axis=1&t})),u.createFullBoxCtor("infe",(function(e){if(0!==this.version&&1!==this.version||(this.item_ID=e.readUint16(),this.item_protection_index=e.readUint16(),this.item_name=e.readCString(),this.content_type=e.readCString(),this.content_encoding=e.readCString()),1===this.version)return this.extension_type=e.readString(4),o.warn("BoxParser","Cannot parse extension type"),void e.seek(this.start+this.size);this.version>=2&&(2===this.version?this.item_ID=e.readUint16():3===this.version&&(this.item_ID=e.readUint32()),this.item_protection_index=e.readUint16(),this.item_type=e.readString(4),this.item_name=e.readCString(),"mime"===this.item_type?(this.content_type=e.readCString(),this.content_encoding=e.readCString()):"uri "===this.item_type&&(this.item_uri_type=e.readCString()))})),u.createFullBoxCtor("ipma",(function(e){var t,i;for(entry_count=e.readUint32(),this.associations=[],t=0;t<entry_count;t++){var s={};this.associations.push(s),this.version<1?s.id=e.readUint16():s.id=e.readUint32();var r=e.readUint8();for(s.props=[],i=0;i<r;i++){var a=e.readUint8(),o={};s.props.push(o),o.essential=(128&a)>>7==1,1&this.flags?o.property_index=(127&a)<<8|e.readUint8():o.property_index=127&a}}})),u.createFullBoxCtor("iref",(function(e){var t,i;for(this.references=[];e.getPosition()<this.start+this.size;){if((t=u.parseOneBox(e,!0,this.size-(e.getPosition()-this.start))).code!==u.OK)return;(i=0===this.version?new u.SingleItemTypeReferenceBox(t.type,t.size,t.hdr_size,t.start):new u.SingleItemTypeReferenceBoxLarge(t.type,t.size,t.hdr_size,t.start)).write===u.Box.prototype.write&&"mdat"!==i.type&&(o.warn("BoxParser",i.type+" box writing not yet implemented, keeping unparsed data in memory for later write"),i.parseDataAndRewind(e)),i.parse(e),this.references.push(i)}})),u.createBoxCtor("irot",(function(e){this.angle=3&e.readUint8()})),u.createFullBoxCtor("ispe",(function(e){this.image_width=e.readUint32(),this.image_height=e.readUint32()})),u.createFullBoxCtor("kind",(function(e){this.schemeURI=e.readCString(),this.value=e.readCString()})),u.createFullBoxCtor("leva",(function(e){var t=e.readUint8();this.levels=[];for(var i=0;i<t;i++){var s={};this.levels[i]=s,s.track_ID=e.readUint32();var r=e.readUint8();switch(s.padding_flag=r>>7,s.assignment_type=127&r,s.assignment_type){case 0:s.grouping_type=e.readString(4);break;case 1:s.grouping_type=e.readString(4),s.grouping_type_parameter=e.readUint32();break;case 2:case 3:break;case 4:s.sub_track_id=e.readUint32();break;default:o.warn("BoxParser","Unknown leva assignement type")}}})),u.createBoxCtor("lsel",(function(e){this.layer_id=e.readUint16()})),u.createBoxCtor("maxr",(function(e){this.period=e.readUint32(),this.bytes=e.readUint32()})),p.prototype.toString=function(){return"("+this.x+","+this.y+")"},u.createBoxCtor("mdcv",(function(e){this.display_primaries=[],this.display_primaries[0]=new p(e.readUint16(),e.readUint16()),this.display_primaries[1]=new p(e.readUint16(),e.readUint16()),this.display_primaries[2]=new p(e.readUint16(),e.readUint16()),this.white_point=new p(e.readUint16(),e.readUint16()),this.max_display_mastering_luminance=e.readUint32(),this.min_display_mastering_luminance=e.readUint32()})),u.createFullBoxCtor("mdhd",(function(e){1==this.version?(this.creation_time=e.readUint64(),this.modification_time=e.readUint64(),this.timescale=e.readUint32(),this.duration=e.readUint64()):(this.creation_time=e.readUint32(),this.modification_time=e.readUint32(),this.timescale=e.readUint32(),this.duration=e.readUint32()),this.parseLanguage(e),e.readUint16()})),u.createFullBoxCtor("mehd",(function(e){1&this.flags&&(o.warn("BoxParser","mehd box incorrectly uses flags set to 1, converting version to 1"),this.version=1),1==this.version?this.fragment_duration=e.readUint64():this.fragment_duration=e.readUint32()})),u.createFullBoxCtor("meta",(function(e){this.boxes=[],u.ContainerBox.prototype.parse.call(this,e)})),u.createFullBoxCtor("mfhd",(function(e){this.sequence_number=e.readUint32()})),u.createFullBoxCtor("mfro",(function(e){this._size=e.readUint32()})),u.createFullBoxCtor("mskC",(function(e){this.bits_per_pixel=e.readUint8()})),u.createFullBoxCtor("mvhd",(function(e){1==this.version?(this.creation_time=e.readUint64(),this.modification_time=e.readUint64(),this.timescale=e.readUint32(),this.duration=e.readUint64()):(this.creation_time=e.readUint32(),this.modification_time=e.readUint32(),this.timescale=e.readUint32(),this.duration=e.readUint32()),this.rate=e.readUint32(),this.volume=e.readUint16()>>8,e.readUint16(),e.readUint32Array(2),this.matrix=e.readUint32Array(9),e.readUint32Array(6),this.next_track_id=e.readUint32()})),u.createBoxCtor("npck",(function(e){this.packetssent=e.readUint32()})),u.createBoxCtor("nump",(function(e){this.packetssent=e.readUint64()})),u.createFullBoxCtor("padb",(function(e){var t=e.readUint32();this.padbits=[];for(var i=0;i<Math.floor((t+1)/2);i++)this.padbits=e.readUint8()})),u.createBoxCtor("pasp",(function(e){this.hSpacing=e.readUint32(),this.vSpacing=e.readUint32()})),u.createBoxCtor("payl",(function(e){this.text=e.readString(this.size-this.hdr_size)})),u.createBoxCtor("payt",(function(e){this.payloadID=e.readUint32();var t=e.readUint8();this.rtpmap_string=e.readString(t)})),u.createFullBoxCtor("pdin",(function(e){var t=(this.size-this.hdr_size)/8;this.rate=[],this.initial_delay=[];for(var i=0;i<t;i++)this.rate[i]=e.readUint32(),this.initial_delay[i]=e.readUint32()})),u.createFullBoxCtor("pitm",(function(e){0===this.version?this.item_id=e.readUint16():this.item_id=e.readUint32()})),u.createFullBoxCtor("pixi",(function(e){var t;for(this.num_channels=e.readUint8(),this.bits_per_channels=[],t=0;t<this.num_channels;t++)this.bits_per_channels[t]=e.readUint8()})),u.createBoxCtor("pmax",(function(e){this.bytes=e.readUint32()})),u.createFullBoxCtor("prdi",(function(e){if(this.step_count=e.readUint16(),this.item_count=[],2&this.flags)for(var t=0;t<this.step_count;t++)this.item_count[t]=e.readUint16()})),u.createFullBoxCtor("prft",(function(e){this.ref_track_id=e.readUint32(),this.ntp_timestamp=e.readUint64(),0===this.version?this.media_time=e.readUint32():this.media_time=e.readUint64()})),u.createFullBoxCtor("pssh",(function(e){if(this.system_id=u.parseHex16(e),this.version>0){var t=e.readUint32();this.kid=[];for(var i=0;i<t;i++)this.kid[i]=u.parseHex16(e)}var s=e.readUint32();s>0&&(this.data=e.readUint8Array(s))})),u.createFullBoxCtor("clef",(function(e){this.width=e.readUint32(),this.height=e.readUint32()})),u.createFullBoxCtor("enof",(function(e){this.width=e.readUint32(),this.height=e.readUint32()})),u.createFullBoxCtor("prof",(function(e){this.width=e.readUint32(),this.height=e.readUint32()})),u.createContainerBoxCtor("tapt",null,["clef","prof","enof"]),u.createBoxCtor("rtp ",(function(e){this.descriptionformat=e.readString(4),this.sdptext=e.readString(this.size-this.hdr_size-4)})),u.createFullBoxCtor("saio",(function(e){1&this.flags&&(this.aux_info_type=e.readUint32(),this.aux_info_type_parameter=e.readUint32());var t=e.readUint32();this.offset=[];for(var i=0;i<t;i++)0===this.version?this.offset[i]=e.readUint32():this.offset[i]=e.readUint64()})),u.createFullBoxCtor("saiz",(function(e){1&this.flags&&(this.aux_info_type=e.readUint32(),this.aux_info_type_parameter=e.readUint32()),this.default_sample_info_size=e.readUint8();var t=e.readUint32();if(this.sample_info_size=[],0===this.default_sample_info_size)for(var i=0;i<t;i++)this.sample_info_size[i]=e.readUint8()})),u.createSampleEntryCtor(u.SAMPLE_ENTRY_TYPE_METADATA,"mett",(function(e){this.parseHeader(e),this.content_encoding=e.readCString(),this.mime_format=e.readCString(),this.parseFooter(e)})),u.createSampleEntryCtor(u.SAMPLE_ENTRY_TYPE_METADATA,"metx",(function(e){this.parseHeader(e),this.content_encoding=e.readCString(),this.namespace=e.readCString(),this.schema_location=e.readCString(),this.parseFooter(e)})),u.createSampleEntryCtor(u.SAMPLE_ENTRY_TYPE_SUBTITLE,"sbtt",(function(e){this.parseHeader(e),this.content_encoding=e.readCString(),this.mime_format=e.readCString(),this.parseFooter(e)})),u.createSampleEntryCtor(u.SAMPLE_ENTRY_TYPE_SUBTITLE,"stpp",(function(e){this.parseHeader(e),this.namespace=e.readCString(),this.schema_location=e.readCString(),this.auxiliary_mime_types=e.readCString(),this.parseFooter(e)})),u.createSampleEntryCtor(u.SAMPLE_ENTRY_TYPE_SUBTITLE,"stxt",(function(e){this.parseHeader(e),this.content_encoding=e.readCString(),this.mime_format=e.readCString(),this.parseFooter(e)})),u.createSampleEntryCtor(u.SAMPLE_ENTRY_TYPE_SUBTITLE,"tx3g",(function(e){this.parseHeader(e),this.displayFlags=e.readUint32(),this.horizontal_justification=e.readInt8(),this.vertical_justification=e.readInt8(),this.bg_color_rgba=e.readUint8Array(4),this.box_record=e.readInt16Array(4),this.style_record=e.readUint8Array(12),this.parseFooter(e)})),u.createSampleEntryCtor(u.SAMPLE_ENTRY_TYPE_METADATA,"wvtt",(function(e){this.parseHeader(e),this.parseFooter(e)})),u.createSampleGroupCtor("alst",(function(e){var t,i=e.readUint16();for(this.first_output_sample=e.readUint16(),this.sample_offset=[],t=0;t<i;t++)this.sample_offset[t]=e.readUint32();var s=this.description_length-4-4*i;for(this.num_output_samples=[],this.num_total_samples=[],t=0;t<s/4;t++)this.num_output_samples[t]=e.readUint16(),this.num_total_samples[t]=e.readUint16()})),u.createSampleGroupCtor("avll",(function(e){this.layerNumber=e.readUint8(),this.accurateStatisticsFlag=e.readUint8(),this.avgBitRate=e.readUint16(),this.avgFrameRate=e.readUint16()})),u.createSampleGroupCtor("avss",(function(e){this.subSequenceIdentifier=e.readUint16(),this.layerNumber=e.readUint8();var t=e.readUint8();this.durationFlag=t>>7,this.avgRateFlag=t>>6&1,this.durationFlag&&(this.duration=e.readUint32()),this.avgRateFlag&&(this.accurateStatisticsFlag=e.readUint8(),this.avgBitRate=e.readUint16(),this.avgFrameRate=e.readUint16()),this.dependency=[];for(var i=e.readUint8(),s=0;s<i;s++){var r={};this.dependency.push(r),r.subSeqDirectionFlag=e.readUint8(),r.layerNumber=e.readUint8(),r.subSequenceIdentifier=e.readUint16()}})),u.createSampleGroupCtor("dtrt",(function(e){o.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")})),u.createSampleGroupCtor("mvif",(function(e){o.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")})),u.createSampleGroupCtor("prol",(function(e){this.roll_distance=e.readInt16()})),u.createSampleGroupCtor("rap ",(function(e){var t=e.readUint8();this.num_leading_samples_known=t>>7,this.num_leading_samples=127&t})),u.createSampleGroupCtor("rash",(function(e){if(this.operation_point_count=e.readUint16(),this.description_length!==2+(1===this.operation_point_count?2:6*this.operation_point_count)+9)o.warn("BoxParser","Mismatch in "+this.grouping_type+" sample group length"),this.data=e.readUint8Array(this.description_length-2);else{if(1===this.operation_point_count)this.target_rate_share=e.readUint16();else{this.target_rate_share=[],this.available_bitrate=[];for(var t=0;t<this.operation_point_count;t++)this.available_bitrate[t]=e.readUint32(),this.target_rate_share[t]=e.readUint16()}this.maximum_bitrate=e.readUint32(),this.minimum_bitrate=e.readUint32(),this.discard_priority=e.readUint8()}})),u.createSampleGroupCtor("roll",(function(e){this.roll_distance=e.readInt16()})),u.SampleGroupEntry.prototype.parse=function(e){o.warn("BoxParser","Unknown Sample Group type: "+this.grouping_type),this.data=e.readUint8Array(this.description_length)},u.createSampleGroupCtor("scif",(function(e){o.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")})),u.createSampleGroupCtor("scnm",(function(e){o.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")})),u.createSampleGroupCtor("seig",(function(e){this.reserved=e.readUint8();var t=e.readUint8();this.crypt_byte_block=t>>4,this.skip_byte_block=15&t,this.isProtected=e.readUint8(),this.Per_Sample_IV_Size=e.readUint8(),this.KID=u.parseHex16(e),this.constant_IV_size=0,this.constant_IV=0,1===this.isProtected&&0===this.Per_Sample_IV_Size&&(this.constant_IV_size=e.readUint8(),this.constant_IV=e.readUint8Array(this.constant_IV_size))})),u.createSampleGroupCtor("stsa",(function(e){o.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")})),u.createSampleGroupCtor("sync",(function(e){var t=e.readUint8();this.NAL_unit_type=63&t})),u.createSampleGroupCtor("tele",(function(e){var t=e.readUint8();this.level_independently_decodable=t>>7})),u.createSampleGroupCtor("tsas",(function(e){o.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")})),u.createSampleGroupCtor("tscl",(function(e){o.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")})),u.createSampleGroupCtor("vipr",(function(e){o.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")})),u.createFullBoxCtor("sbgp",(function(e){this.grouping_type=e.readString(4),1===this.version?this.grouping_type_parameter=e.readUint32():this.grouping_type_parameter=0,this.entries=[];for(var t=e.readUint32(),i=0;i<t;i++){var s={};this.entries.push(s),s.sample_count=e.readInt32(),s.group_description_index=e.readInt32()}})),f.prototype.toString=function(){return"[row: "+this.bad_pixel_row+", column: "+this.bad_pixel_column+"]"},u.createFullBoxCtor("sbpm",(function(e){var t;for(this.component_count=e.readUint16(),this.component_index=[],t=0;t<this.component_count;t++)this.component_index.push(e.readUint16());var i=e.readUint8();for(this.correction_applied=!(128&~i),this.num_bad_rows=e.readUint32(),this.num_bad_cols=e.readUint32(),this.num_bad_pixels=e.readUint32(),this.bad_rows=[],this.bad_columns=[],this.bad_pixels=[],t=0;t<this.num_bad_rows;t++)this.bad_rows.push(e.readUint32());for(t=0;t<this.num_bad_cols;t++)this.bad_columns.push(e.readUint32());for(t=0;t<this.num_bad_pixels;t++){var s=e.readUint32(),r=e.readUint32();this.bad_pixels.push(new f(s,r))}})),u.createFullBoxCtor("schm",(function(e){this.scheme_type=e.readString(4),this.scheme_version=e.readUint32(),1&this.flags&&(this.scheme_uri=e.readString(this.size-this.hdr_size-8))})),u.createBoxCtor("sdp ",(function(e){this.sdptext=e.readString(this.size-this.hdr_size)})),u.createFullBoxCtor("sdtp",(function(e){var t,i=this.size-this.hdr_size;this.is_leading=[],this.sample_depends_on=[],this.sample_is_depended_on=[],this.sample_has_redundancy=[];for(var s=0;s<i;s++)t=e.readUint8(),this.is_leading[s]=t>>6,this.sample_depends_on[s]=t>>4&3,this.sample_is_depended_on[s]=t>>2&3,this.sample_has_redundancy[s]=3&t})),u.createFullBoxCtor("senc"),u.createFullBoxCtor("sgpd",(function(e){this.grouping_type=e.readString(4),o.debug("BoxParser","Found Sample Groups of type "+this.grouping_type),1===this.version?this.default_length=e.readUint32():this.default_length=0,this.version>=2&&(this.default_group_description_index=e.readUint32()),this.entries=[];for(var t=e.readUint32(),i=0;i<t;i++){var s;s=u[this.grouping_type+"SampleGroupEntry"]?new u[this.grouping_type+"SampleGroupEntry"](this.grouping_type):new u.SampleGroupEntry(this.grouping_type),this.entries.push(s),1===this.version&&0===this.default_length?s.description_length=e.readUint32():s.description_length=this.default_length,s.write===u.SampleGroupEntry.prototype.write&&(o.info("BoxParser","SampleGroup for type "+this.grouping_type+" writing not yet implemented, keeping unparsed data in memory for later write"),s.data=e.readUint8Array(s.description_length),e.position-=s.description_length),s.parse(e)}})),u.createFullBoxCtor("sidx",(function(e){this.reference_ID=e.readUint32(),this.timescale=e.readUint32(),0===this.version?(this.earliest_presentation_time=e.readUint32(),this.first_offset=e.readUint32()):(this.earliest_presentation_time=e.readUint64(),this.first_offset=e.readUint64()),e.readUint16(),this.references=[];for(var t=e.readUint16(),i=0;i<t;i++){var s={};this.references.push(s);var r=e.readUint32();s.reference_type=r>>31&1,s.referenced_size=2147483647&r,s.subsegment_duration=e.readUint32(),r=e.readUint32(),s.starts_with_SAP=r>>31&1,s.SAP_type=r>>28&7,s.SAP_delta_time=268435455&r}})),u.SingleItemTypeReferenceBox=function(e,t,i,s){u.Box.call(this,e,t),this.hdr_size=i,this.start=s},u.SingleItemTypeReferenceBox.prototype=new u.Box,u.SingleItemTypeReferenceBox.prototype.parse=function(e){this.from_item_ID=e.readUint16();var t=e.readUint16();this.references=[];for(var i=0;i<t;i++)this.references[i]={},this.references[i].to_item_ID=e.readUint16()},u.SingleItemTypeReferenceBoxLarge=function(e,t,i,s){u.Box.call(this,e,t),this.hdr_size=i,this.start=s},u.SingleItemTypeReferenceBoxLarge.prototype=new u.Box,u.SingleItemTypeReferenceBoxLarge.prototype.parse=function(e){this.from_item_ID=e.readUint32();var t=e.readUint16();this.references=[];for(var i=0;i<t;i++)this.references[i]={},this.references[i].to_item_ID=e.readUint32()},u.createFullBoxCtor("SmDm",(function(e){this.primaryRChromaticity_x=e.readUint16(),this.primaryRChromaticity_y=e.readUint16(),this.primaryGChromaticity_x=e.readUint16(),this.primaryGChromaticity_y=e.readUint16(),this.primaryBChromaticity_x=e.readUint16(),this.primaryBChromaticity_y=e.readUint16(),this.whitePointChromaticity_x=e.readUint16(),this.whitePointChromaticity_y=e.readUint16(),this.luminanceMax=e.readUint32(),this.luminanceMin=e.readUint32()})),u.createFullBoxCtor("smhd",(function(e){this.balance=e.readUint16(),e.readUint16()})),u.createFullBoxCtor("ssix",(function(e){this.subsegments=[];for(var t=e.readUint32(),i=0;i<t;i++){var s={};this.subsegments.push(s),s.ranges=[];for(var r=e.readUint32(),a=0;a<r;a++){var o={};s.ranges.push(o),o.level=e.readUint8(),o.range_size=e.readUint24()}}})),u.createFullBoxCtor("stco",(function(e){var t;if(t=e.readUint32(),this.chunk_offsets=[],0===this.version)for(var i=0;i<t;i++)this.chunk_offsets.push(e.readUint32())})),u.createFullBoxCtor("stdp",(function(e){var t=(this.size-this.hdr_size)/2;this.priority=[];for(var i=0;i<t;i++)this.priority[i]=e.readUint16()})),u.createFullBoxCtor("sthd"),u.createFullBoxCtor("stri",(function(e){this.switch_group=e.readUint16(),this.alternate_group=e.readUint16(),this.sub_track_id=e.readUint32();var t=(this.size-this.hdr_size-8)/4;this.attribute_list=[];for(var i=0;i<t;i++)this.attribute_list[i]=e.readUint32()})),u.createFullBoxCtor("stsc",(function(e){var t,i;if(t=e.readUint32(),this.first_chunk=[],this.samples_per_chunk=[],this.sample_description_index=[],0===this.version)for(i=0;i<t;i++)this.first_chunk.push(e.readUint32()),this.samples_per_chunk.push(e.readUint32()),this.sample_description_index.push(e.readUint32())})),u.createFullBoxCtor("stsd",(function(e){var t,i,s,r;for(this.entries=[],s=e.readUint32(),t=1;t<=s;t++){if((i=u.parseOneBox(e,!0,this.size-(e.getPosition()-this.start))).code!==u.OK)return;u[i.type+"SampleEntry"]?((r=new u[i.type+"SampleEntry"](i.size)).hdr_size=i.hdr_size,r.start=i.start):(o.warn("BoxParser","Unknown sample entry type: "+i.type),r=new u.SampleEntry(i.type,i.size,i.hdr_size,i.start)),r.write===u.SampleEntry.prototype.write&&(o.info("BoxParser","SampleEntry "+r.type+" box writing not yet implemented, keeping unparsed data in memory for later write"),r.parseDataAndRewind(e)),r.parse(e),this.entries.push(r)}})),u.createFullBoxCtor("stsg",(function(e){this.grouping_type=e.readUint32();var t=e.readUint16();this.group_description_index=[];for(var i=0;i<t;i++)this.group_description_index[i]=e.readUint32()})),u.createFullBoxCtor("stsh",(function(e){var t,i;if(t=e.readUint32(),this.shadowed_sample_numbers=[],this.sync_sample_numbers=[],0===this.version)for(i=0;i<t;i++)this.shadowed_sample_numbers.push(e.readUint32()),this.sync_sample_numbers.push(e.readUint32())})),u.createFullBoxCtor("stss",(function(e){var t,i;if(i=e.readUint32(),0===this.version)for(this.sample_numbers=[],t=0;t<i;t++)this.sample_numbers.push(e.readUint32())})),u.createFullBoxCtor("stsz",(function(e){var t;if(this.sample_sizes=[],0===this.version)for(this.sample_size=e.readUint32(),this.sample_count=e.readUint32(),t=0;t<this.sample_count;t++)0===this.sample_size?this.sample_sizes.push(e.readUint32()):this.sample_sizes[t]=this.sample_size})),u.createFullBoxCtor("stts",(function(e){var t,i,s;if(t=e.readUint32(),this.sample_counts=[],this.sample_deltas=[],0===this.version)for(i=0;i<t;i++)this.sample_counts.push(e.readUint32()),(s=e.readInt32())<0&&(o.warn("BoxParser","File uses negative stts sample delta, using value 1 instead, sync may be lost!"),s=1),this.sample_deltas.push(s)})),u.createFullBoxCtor("stvi",(function(e){var t=e.readUint32();this.single_view_allowed=3&t,this.stereo_scheme=e.readUint32();var i,s,r=e.readUint32();for(this.stereo_indication_type=e.readString(r),this.boxes=[];e.getPosition()<this.start+this.size;){if((i=u.parseOneBox(e,!1,this.size-(e.getPosition()-this.start))).code!==u.OK)return;s=i.box,this.boxes.push(s),this[s.type]=s}})),u.createBoxCtor("styp",(function(e){u.ftypBox.prototype.parse.call(this,e)})),u.createFullBoxCtor("stz2",(function(e){var t,i;if(this.sample_sizes=[],0===this.version)if(this.reserved=e.readUint24(),this.field_size=e.readUint8(),i=e.readUint32(),4===this.field_size)for(t=0;t<i;t+=2){var s=e.readUint8();this.sample_sizes[t]=s>>4&15,this.sample_sizes[t+1]=15&s}else if(8===this.field_size)for(t=0;t<i;t++)this.sample_sizes[t]=e.readUint8();else if(16===this.field_size)for(t=0;t<i;t++)this.sample_sizes[t]=e.readUint16();else o.error("BoxParser","Error in length field in stz2 box")})),u.createFullBoxCtor("subs",(function(e){var t,i,s,r;for(s=e.readUint32(),this.entries=[],t=0;t<s;t++){var a={};if(this.entries[t]=a,a.sample_delta=e.readUint32(),a.subsamples=[],(r=e.readUint16())>0)for(i=0;i<r;i++){var o={};a.subsamples.push(o),1==this.version?o.size=e.readUint32():o.size=e.readUint16(),o.priority=e.readUint8(),o.discardable=e.readUint8(),o.codec_specific_parameters=e.readUint32()}}})),u.createFullBoxCtor("tenc",(function(e){if(e.readUint8(),0===this.version)e.readUint8();else{var t=e.readUint8();this.default_crypt_byte_block=t>>4&15,this.default_skip_byte_block=15&t}this.default_isProtected=e.readUint8(),this.default_Per_Sample_IV_Size=e.readUint8(),this.default_KID=u.parseHex16(e),1===this.default_isProtected&&0===this.default_Per_Sample_IV_Size&&(this.default_constant_IV_size=e.readUint8(),this.default_constant_IV=e.readUint8Array(this.default_constant_IV_size))})),u.createFullBoxCtor("tfdt",(function(e){1==this.version?this.baseMediaDecodeTime=e.readUint64():this.baseMediaDecodeTime=e.readUint32()})),u.createFullBoxCtor("tfhd",(function(e){var t=0;this.track_id=e.readUint32(),this.size-this.hdr_size>t&&this.flags&u.TFHD_FLAG_BASE_DATA_OFFSET?(this.base_data_offset=e.readUint64(),t+=8):this.base_data_offset=0,this.size-this.hdr_size>t&&this.flags&u.TFHD_FLAG_SAMPLE_DESC?(this.default_sample_description_index=e.readUint32(),t+=4):this.default_sample_description_index=0,this.size-this.hdr_size>t&&this.flags&u.TFHD_FLAG_SAMPLE_DUR?(this.default_sample_duration=e.readUint32(),t+=4):this.default_sample_duration=0,this.size-this.hdr_size>t&&this.flags&u.TFHD_FLAG_SAMPLE_SIZE?(this.default_sample_size=e.readUint32(),t+=4):this.default_sample_size=0,this.size-this.hdr_size>t&&this.flags&u.TFHD_FLAG_SAMPLE_FLAGS?(this.default_sample_flags=e.readUint32(),t+=4):this.default_sample_flags=0})),u.createFullBoxCtor("tfra",(function(e){this.track_ID=e.readUint32(),e.readUint24();var t=e.readUint8();this.length_size_of_traf_num=t>>4&3,this.length_size_of_trun_num=t>>2&3,this.length_size_of_sample_num=3&t,this.entries=[];for(var i=e.readUint32(),s=0;s<i;s++)1===this.version?(this.time=e.readUint64(),this.moof_offset=e.readUint64()):(this.time=e.readUint32(),this.moof_offset=e.readUint32()),this.traf_number=e["readUint"+8*(this.length_size_of_traf_num+1)](),this.trun_number=e["readUint"+8*(this.length_size_of_trun_num+1)](),this.sample_number=e["readUint"+8*(this.length_size_of_sample_num+1)]()})),u.createFullBoxCtor("tkhd",(function(e){1==this.version?(this.creation_time=e.readUint64(),this.modification_time=e.readUint64(),this.track_id=e.readUint32(),e.readUint32(),this.duration=e.readUint64()):(this.creation_time=e.readUint32(),this.modification_time=e.readUint32(),this.track_id=e.readUint32(),e.readUint32(),this.duration=e.readUint32()),e.readUint32Array(2),this.layer=e.readInt16(),this.alternate_group=e.readInt16(),this.volume=e.readInt16()>>8,e.readUint16(),this.matrix=e.readInt32Array(9),this.width=e.readUint32(),this.height=e.readUint32()})),u.createBoxCtor("tmax",(function(e){this.time=e.readUint32()})),u.createBoxCtor("tmin",(function(e){this.time=e.readUint32()})),u.createBoxCtor("totl",(function(e){this.bytessent=e.readUint32()})),u.createBoxCtor("tpay",(function(e){this.bytessent=e.readUint32()})),u.createBoxCtor("tpyl",(function(e){this.bytessent=e.readUint64()})),u.TrackGroupTypeBox.prototype.parse=function(e){this.parseFullHeader(e),this.track_group_id=e.readUint32()},u.createTrackGroupCtor("msrc"),u.TrackReferenceTypeBox=function(e,t,i,s){u.Box.call(this,e,t),this.hdr_size=i,this.start=s},u.TrackReferenceTypeBox.prototype=new u.Box,u.TrackReferenceTypeBox.prototype.parse=function(e){this.track_ids=e.readUint32Array((this.size-this.hdr_size)/4)},u.trefBox.prototype.parse=function(e){for(var t,i;e.getPosition()<this.start+this.size;){if((t=u.parseOneBox(e,!0,this.size-(e.getPosition()-this.start))).code!==u.OK)return;(i=new u.TrackReferenceTypeBox(t.type,t.size,t.hdr_size,t.start)).write===u.Box.prototype.write&&"mdat"!==i.type&&(o.info("BoxParser","TrackReference "+i.type+" box writing not yet implemented, keeping unparsed data in memory for later write"),i.parseDataAndRewind(e)),i.parse(e),this.boxes.push(i)}},u.createFullBoxCtor("trep",(function(e){for(this.track_ID=e.readUint32(),this.boxes=[];e.getPosition()<this.start+this.size;){if(ret=u.parseOneBox(e,!1,this.size-(e.getPosition()-this.start)),ret.code!==u.OK)return;box=ret.box,this.boxes.push(box)}})),u.createFullBoxCtor("trex",(function(e){this.track_id=e.readUint32(),this.default_sample_description_index=e.readUint32(),this.default_sample_duration=e.readUint32(),this.default_sample_size=e.readUint32(),this.default_sample_flags=e.readUint32()})),u.createBoxCtor("trpy",(function(e){this.bytessent=e.readUint64()})),u.createFullBoxCtor("trun",(function(e){var t=0;if(this.sample_count=e.readUint32(),t+=4,this.size-this.hdr_size>t&&this.flags&u.TRUN_FLAGS_DATA_OFFSET?(this.data_offset=e.readInt32(),t+=4):this.data_offset=0,this.size-this.hdr_size>t&&this.flags&u.TRUN_FLAGS_FIRST_FLAG?(this.first_sample_flags=e.readUint32(),t+=4):this.first_sample_flags=0,this.sample_duration=[],this.sample_size=[],this.sample_flags=[],this.sample_composition_time_offset=[],this.size-this.hdr_size>t)for(var i=0;i<this.sample_count;i++)this.flags&u.TRUN_FLAGS_DURATION&&(this.sample_duration[i]=e.readUint32()),this.flags&u.TRUN_FLAGS_SIZE&&(this.sample_size[i]=e.readUint32()),this.flags&u.TRUN_FLAGS_FLAGS&&(this.sample_flags[i]=e.readUint32()),this.flags&u.TRUN_FLAGS_CTS_OFFSET&&(0===this.version?this.sample_composition_time_offset[i]=e.readUint32():this.sample_composition_time_offset[i]=e.readInt32())})),u.createFullBoxCtor("tsel",(function(e){this.switch_group=e.readUint32();var t=(this.size-this.hdr_size-4)/4;this.attribute_list=[];for(var i=0;i<t;i++)this.attribute_list[i]=e.readUint32()})),u.createFullBoxCtor("txtC",(function(e){this.config=e.readCString()})),u.createBoxCtor("tyco",(function(e){var t=(this.size-this.hdr_size)/4;this.compatible_brands=[];for(var i=0;i<t;i++)this.compatible_brands[i]=e.readString(4)})),u.createFullBoxCtor("udes",(function(e){this.lang=e.readCString(),this.name=e.readCString(),this.description=e.readCString(),this.tags=e.readCString()})),u.createFullBoxCtor("uncC",(function(e){var t;if(this.profile=e.readUint32(),1==this.version);else if(0==this.version){for(this.component_count=e.readUint32(),this.component_index=[],this.component_bit_depth_minus_one=[],this.component_format=[],this.component_align_size=[],t=0;t<this.component_count;t++)this.component_index.push(e.readUint16()),this.component_bit_depth_minus_one.push(e.readUint8()),this.component_format.push(e.readUint8()),this.component_align_size.push(e.readUint8());this.sampling_type=e.readUint8(),this.interleave_type=e.readUint8(),this.block_size=e.readUint8();var i=e.readUint8();this.component_little_endian=i>>7&1,this.block_pad_lsb=i>>6&1,this.block_little_endian=i>>5&1,this.block_reversed=i>>4&1,this.pad_unknown=i>>3&1,this.pixel_size=e.readUint32(),this.row_align_size=e.readUint32(),this.tile_align_size=e.readUint32(),this.num_tile_cols_minus_one=e.readUint32(),this.num_tile_rows_minus_one=e.readUint32()}})),u.createFullBoxCtor("url ",(function(e){1!==this.flags&&(this.location=e.readCString())})),u.createFullBoxCtor("urn ",(function(e){this.name=e.readCString(),this.size-this.hdr_size-this.name.length-1>0&&(this.location=e.readCString())})),u.createUUIDBox("a5d40b30e81411ddba2f0800200c9a66",!0,!1,(function(e){this.LiveServerManifest=e.readString(this.size-this.hdr_size).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")})),u.createUUIDBox("d08a4f1810f34a82b6c832d8aba183d3",!0,!1,(function(e){this.system_id=u.parseHex16(e);var t=e.readUint32();t>0&&(this.data=e.readUint8Array(t))})),u.createUUIDBox("a2394f525a9b4f14a2446c427c648df4",!0,!1),u.createUUIDBox("8974dbce7be74c5184f97148f9882554",!0,!1,(function(e){this.default_AlgorithmID=e.readUint24(),this.default_IV_size=e.readUint8(),this.default_KID=u.parseHex16(e)})),u.createUUIDBox("d4807ef2ca3946958e5426cb9e46a79f",!0,!1,(function(e){this.fragment_count=e.readUint8(),this.entries=[];for(var t=0;t<this.fragment_count;t++){var i={},s=0,r=0;1===this.version?(s=e.readUint64(),r=e.readUint64()):(s=e.readUint32(),r=e.readUint32()),i.absolute_time=s,i.absolute_duration=r,this.entries.push(i)}})),u.createUUIDBox("6d1d9b0542d544e680e2141daff757b2",!0,!1,(function(e){1===this.version?(this.absolute_time=e.readUint64(),this.duration=e.readUint64()):(this.absolute_time=e.readUint32(),this.duration=e.readUint32())})),u.createFullBoxCtor("vmhd",(function(e){this.graphicsmode=e.readUint16(),this.opcolor=e.readUint16Array(3)})),u.createFullBoxCtor("vpcC",(function(e){var t;1===this.version?(this.profile=e.readUint8(),this.level=e.readUint8(),t=e.readUint8(),this.bitDepth=t>>4,this.chromaSubsampling=t>>1&7,this.videoFullRangeFlag=1&t,this.colourPrimaries=e.readUint8(),this.transferCharacteristics=e.readUint8(),this.matrixCoefficients=e.readUint8(),this.codecIntializationDataSize=e.readUint16(),this.codecIntializationData=e.readUint8Array(this.codecIntializationDataSize)):(this.profile=e.readUint8(),this.level=e.readUint8(),t=e.readUint8(),this.bitDepth=t>>4&15,this.colorSpace=15&t,t=e.readUint8(),this.chromaSubsampling=t>>4&15,this.transferFunction=t>>1&7,this.videoFullRangeFlag=1&t,this.codecIntializationDataSize=e.readUint16(),this.codecIntializationData=e.readUint8Array(this.codecIntializationDataSize))})),u.createBoxCtor("vttC",(function(e){this.text=e.readString(this.size-this.hdr_size)})),u.createFullBoxCtor("vvcC",(function(e){var t,i,s={held_bits:void 0,num_held_bits:0,stream_read_1_bytes:function(e){this.held_bits=e.readUint8(),this.num_held_bits=8},stream_read_2_bytes:function(e){this.held_bits=e.readUint16(),this.num_held_bits=16},extract_bits:function(e){var t=this.held_bits>>this.num_held_bits-e&(1<<e)-1;return this.num_held_bits-=e,t}};if(s.stream_read_1_bytes(e),s.extract_bits(5),this.lengthSizeMinusOne=s.extract_bits(2),this.ptl_present_flag=s.extract_bits(1),this.ptl_present_flag){if(s.stream_read_2_bytes(e),this.ols_idx=s.extract_bits(9),this.num_sublayers=s.extract_bits(3),this.constant_frame_rate=s.extract_bits(2),this.chroma_format_idc=s.extract_bits(2),s.stream_read_1_bytes(e),this.bit_depth_minus8=s.extract_bits(3),s.extract_bits(5),s.stream_read_2_bytes(e),s.extract_bits(2),this.num_bytes_constraint_info=s.extract_bits(6),this.general_profile_idc=s.extract_bits(7),this.general_tier_flag=s.extract_bits(1),this.general_level_idc=e.readUint8(),s.stream_read_1_bytes(e),this.ptl_frame_only_constraint_flag=s.extract_bits(1),this.ptl_multilayer_enabled_flag=s.extract_bits(1),this.general_constraint_info=new Uint8Array(this.num_bytes_constraint_info),this.num_bytes_constraint_info){for(t=0;t<this.num_bytes_constraint_info-1;t++){var r=s.extract_bits(6);s.stream_read_1_bytes(e);var a=s.extract_bits(2);this.general_constraint_info[t]=r<<2|a}this.general_constraint_info[this.num_bytes_constraint_info-1]=s.extract_bits(6)}else s.extract_bits(6);if(this.num_sublayers>1){for(s.stream_read_1_bytes(e),this.ptl_sublayer_present_mask=0,i=this.num_sublayers-2;i>=0;--i){var o=s.extract_bits(1);this.ptl_sublayer_present_mask|=o<<i}for(i=this.num_sublayers;i<=8&&this.num_sublayers>1;++i)s.extract_bits(1);for(this.sublayer_level_idc=[],i=this.num_sublayers-2;i>=0;--i)this.ptl_sublayer_present_mask&1<<i&&(this.sublayer_level_idc[i]=e.readUint8())}if(this.ptl_num_sub_profiles=e.readUint8(),this.general_sub_profile_idc=[],this.ptl_num_sub_profiles)for(t=0;t<this.ptl_num_sub_profiles;t++)this.general_sub_profile_idc.push(e.readUint32());this.max_picture_width=e.readUint16(),this.max_picture_height=e.readUint16(),this.avg_frame_rate=e.readUint16()}this.nalu_arrays=[];var n=e.readUint8();for(t=0;t<n;t++){var l=[];this.nalu_arrays.push(l),s.stream_read_1_bytes(e),l.completeness=s.extract_bits(1),s.extract_bits(2),l.nalu_type=s.extract_bits(5);var d=1;for(13!=l.nalu_type&&12!=l.nalu_type&&(d=e.readUint16()),i=0;i<d;i++){var h=e.readUint16();l.push({data:e.readUint8Array(h),length:h})}}})),u.createFullBoxCtor("vvnC",(function(e){var t=strm.readUint8();this.lengthSizeMinusOne=3&t})),u.SampleEntry.prototype.isVideo=function(){return!1},u.SampleEntry.prototype.isAudio=function(){return!1},u.SampleEntry.prototype.isSubtitle=function(){return!1},u.SampleEntry.prototype.isMetadata=function(){return!1},u.SampleEntry.prototype.isHint=function(){return!1},u.SampleEntry.prototype.getCodec=function(){return this.type.replace(".","")},u.SampleEntry.prototype.getWidth=function(){return""},u.SampleEntry.prototype.getHeight=function(){return""},u.SampleEntry.prototype.getChannelCount=function(){return""},u.SampleEntry.prototype.getSampleRate=function(){return""},u.SampleEntry.prototype.getSampleSize=function(){return""},u.VisualSampleEntry.prototype.isVideo=function(){return!0},u.VisualSampleEntry.prototype.getWidth=function(){return this.width},u.VisualSampleEntry.prototype.getHeight=function(){return this.height},u.AudioSampleEntry.prototype.isAudio=function(){return!0},u.AudioSampleEntry.prototype.getChannelCount=function(){return this.channel_count},u.AudioSampleEntry.prototype.getSampleRate=function(){return this.samplerate},u.AudioSampleEntry.prototype.getSampleSize=function(){return this.samplesize},u.SubtitleSampleEntry.prototype.isSubtitle=function(){return!0},u.MetadataSampleEntry.prototype.isMetadata=function(){return!0},u.decimalToHex=function(e,t){var i=Number(e).toString(16);for(t=null==t?t=2:t;i.length<t;)i="0"+i;return i},u.avc1SampleEntry.prototype.getCodec=u.avc2SampleEntry.prototype.getCodec=u.avc3SampleEntry.prototype.getCodec=u.avc4SampleEntry.prototype.getCodec=function(){var e=u.SampleEntry.prototype.getCodec.call(this);return this.avcC?e+"."+u.decimalToHex(this.avcC.AVCProfileIndication)+u.decimalToHex(this.avcC.profile_compatibility)+u.decimalToHex(this.avcC.AVCLevelIndication):e},u.hev1SampleEntry.prototype.getCodec=u.hvc1SampleEntry.prototype.getCodec=function(){var e,t=u.SampleEntry.prototype.getCodec.call(this);if(this.hvcC){switch(t+=".",this.hvcC.general_profile_space){case 0:t+="";break;case 1:t+="A";break;case 2:t+="B";break;case 3:t+="C"}t+=this.hvcC.general_profile_idc,t+=".";var i=this.hvcC.general_profile_compatibility,s=0;for(e=0;e<32&&(s|=1&i,31!=e);e++)s<<=1,i>>=1;t+=u.decimalToHex(s,0),t+=".",0===this.hvcC.general_tier_flag?t+="L":t+="H",t+=this.hvcC.general_level_idc;var r=!1,a="";for(e=5;e>=0;e--)(this.hvcC.general_constraint_indicator[e]||r)&&(a="."+u.decimalToHex(this.hvcC.general_constraint_indicator[e],0)+a,r=!0);t+=a}return t},u.vvc1SampleEntry.prototype.getCodec=u.vvi1SampleEntry.prototype.getCodec=function(){var e,t=u.SampleEntry.prototype.getCodec.call(this);if(this.vvcC){t+="."+this.vvcC.general_profile_idc,this.vvcC.general_tier_flag?t+=".H":t+=".L",t+=this.vvcC.general_level_idc;var i="";if(this.vvcC.general_constraint_info){var s,r=[],a=0;for(a|=this.vvcC.ptl_frame_only_constraint<<7,a|=this.vvcC.ptl_multilayer_enabled<<6,e=0;e<this.vvcC.general_constraint_info.length;++e)a|=this.vvcC.general_constraint_info[e]>>2&63,r.push(a),a&&(s=e),a=this.vvcC.general_constraint_info[e]>>2&3;if(void 0===s)i=".CA";else{i=".C";var o="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",n=0,l=0;for(e=0;e<=s;++e)for(n=n<<8|r[e],l+=8;l>=5;){i+=o[n>>l-5&31],n&=(1<<(l-=5))-1}l&&(i+=o[31&(n<<=5-l)])}}t+=i}return t},u.mp4aSampleEntry.prototype.getCodec=function(){var e=u.SampleEntry.prototype.getCodec.call(this);if(this.esds&&this.esds.esd){var t=this.esds.esd.getOTI(),i=this.esds.esd.getAudioConfig();return e+"."+u.decimalToHex(t)+(i?"."+i:"")}return e},u.stxtSampleEntry.prototype.getCodec=function(){var e=u.SampleEntry.prototype.getCodec.call(this);return this.mime_format?e+"."+this.mime_format:e},u.vp08SampleEntry.prototype.getCodec=u.vp09SampleEntry.prototype.getCodec=function(){var e=u.SampleEntry.prototype.getCodec.call(this),t=this.vpcC.level;0==t&&(t="00");var i=this.vpcC.bitDepth;return 8==i&&(i="08"),e+".0"+this.vpcC.profile+"."+t+"."+i},u.av01SampleEntry.prototype.getCodec=function(){var e,t=u.SampleEntry.prototype.getCodec.call(this),i=this.av1C.seq_level_idx_0;return i<10&&(i="0"+i),2===this.av1C.seq_profile&&1===this.av1C.high_bitdepth?e=1===this.av1C.twelve_bit?"12":"10":this.av1C.seq_profile<=2&&(e=1===this.av1C.high_bitdepth?"10":"08"),t+"."+this.av1C.seq_profile+"."+i+(this.av1C.seq_tier_0?"H":"M")+"."+e},u.Box.prototype.writeHeader=function(e,t){this.size+=8,this.size>d&&(this.size+=8),"uuid"===this.type&&(this.size+=16),o.debug("BoxWriter","Writing box "+this.type+" of size: "+this.size+" at position "+e.getPosition()+(t||"")),this.size>d?e.writeUint32(1):(this.sizePosition=e.getPosition(),e.writeUint32(this.size)),e.writeString(this.type,null,4),"uuid"===this.type&&e.writeUint8Array(this.uuid),this.size>d&&e.writeUint64(this.size)},u.FullBox.prototype.writeHeader=function(e){this.size+=4,u.Box.prototype.writeHeader.call(this,e," v="+this.version+" f="+this.flags),e.writeUint8(this.version),e.writeUint24(this.flags)},u.Box.prototype.write=function(e){"mdat"===this.type?this.data&&(this.size=this.data.length,this.writeHeader(e),e.writeUint8Array(this.data)):(this.size=this.data?this.data.length:0,this.writeHeader(e),this.data&&e.writeUint8Array(this.data))},u.ContainerBox.prototype.write=function(e){this.size=0,this.writeHeader(e);for(var t=0;t<this.boxes.length;t++)this.boxes[t]&&(this.boxes[t].write(e),this.size+=this.boxes[t].size);o.debug("BoxWriter","Adjusting box "+this.type+" with new size "+this.size),e.adjustUint32(this.sizePosition,this.size)},u.TrackReferenceTypeBox.prototype.write=function(e){this.size=4*this.track_ids.length,this.writeHeader(e),e.writeUint32Array(this.track_ids)},u.avcCBox.prototype.write=function(e){var t;for(this.size=7,t=0;t<this.SPS.length;t++)this.size+=2+this.SPS[t].length;for(t=0;t<this.PPS.length;t++)this.size+=2+this.PPS[t].length;for(this.ext&&(this.size+=this.ext.length),this.writeHeader(e),e.writeUint8(this.configurationVersion),e.writeUint8(this.AVCProfileIndication),e.writeUint8(this.profile_compatibility),e.writeUint8(this.AVCLevelIndication),e.writeUint8(this.lengthSizeMinusOne+252),e.writeUint8(this.SPS.length+224),t=0;t<this.SPS.length;t++)e.writeUint16(this.SPS[t].length),e.writeUint8Array(this.SPS[t].nalu);for(e.writeUint8(this.PPS.length),t=0;t<this.PPS.length;t++)e.writeUint16(this.PPS[t].length),e.writeUint8Array(this.PPS[t].nalu);this.ext&&e.writeUint8Array(this.ext)},u.co64Box.prototype.write=function(e){var t;for(this.version=0,this.flags=0,this.size=4+8*this.chunk_offsets.length,this.writeHeader(e),e.writeUint32(this.chunk_offsets.length),t=0;t<this.chunk_offsets.length;t++)e.writeUint64(this.chunk_offsets[t])},u.cslgBox.prototype.write=function(e){this.version=0,this.flags=0,this.size=20,this.writeHeader(e),e.writeInt32(this.compositionToDTSShift),e.writeInt32(this.leastDecodeToDisplayDelta),e.writeInt32(this.greatestDecodeToDisplayDelta),e.writeInt32(this.compositionStartTime),e.writeInt32(this.compositionEndTime)},u.cttsBox.prototype.write=function(e){var t;for(this.version=0,this.flags=0,this.size=4+8*this.sample_counts.length,this.writeHeader(e),e.writeUint32(this.sample_counts.length),t=0;t<this.sample_counts.length;t++)e.writeUint32(this.sample_counts[t]),1===this.version?e.writeInt32(this.sample_offsets[t]):e.writeUint32(this.sample_offsets[t])},u.drefBox.prototype.write=function(e){this.version=0,this.flags=0,this.size=4,this.writeHeader(e),e.writeUint32(this.entries.length);for(var t=0;t<this.entries.length;t++)this.entries[t].write(e),this.size+=this.entries[t].size;o.debug("BoxWriter","Adjusting box "+this.type+" with new size "+this.size),e.adjustUint32(this.sizePosition,this.size)},u.elngBox.prototype.write=function(e){this.version=0,this.flags=0,this.size=this.extended_language.length,this.writeHeader(e),e.writeString(this.extended_language)},u.elstBox.prototype.write=function(e){this.version=0,this.flags=0,this.size=4+12*this.entries.length,this.writeHeader(e),e.writeUint32(this.entries.length);for(var t=0;t<this.entries.length;t++){var i=this.entries[t];e.writeUint32(i.segment_duration),e.writeInt32(i.media_time),e.writeInt16(i.media_rate_integer),e.writeInt16(i.media_rate_fraction)}},u.emsgBox.prototype.write=function(e){this.version=0,this.flags=0,this.size=16+this.message_data.length+(this.scheme_id_uri.length+1)+(this.value.length+1),this.writeHeader(e),e.writeCString(this.scheme_id_uri),e.writeCString(this.value),e.writeUint32(this.timescale),e.writeUint32(this.presentation_time_delta),e.writeUint32(this.event_duration),e.writeUint32(this.id),e.writeUint8Array(this.message_data)},u.ftypBox.prototype.write=function(e){this.size=8+4*this.compatible_brands.length,this.writeHeader(e),e.writeString(this.major_brand,null,4),e.writeUint32(this.minor_version);for(var t=0;t<this.compatible_brands.length;t++)e.writeString(this.compatible_brands[t],null,4)},u.hdlrBox.prototype.write=function(e){this.size=20+this.name.length+1,this.version=0,this.flags=0,this.writeHeader(e),e.writeUint32(0),e.writeString(this.handler,null,4),e.writeUint32(0),e.writeUint32(0),e.writeUint32(0),e.writeCString(this.name)},u.hvcCBox.prototype.write=function(e){var t,i;for(this.size=23,t=0;t<this.nalu_arrays.length;t++)for(this.size+=3,i=0;i<this.nalu_arrays[t].length;i++)this.size+=2+this.nalu_arrays[t][i].data.length;for(this.writeHeader(e),e.writeUint8(this.configurationVersion),e.writeUint8(this.general_profile_space<<6+this.general_tier_flag<<5+this.general_profile_idc),e.writeUint32(this.general_profile_compatibility),e.writeUint8Array(this.general_constraint_indicator),e.writeUint8(this.general_level_idc),e.writeUint16(this.min_spatial_segmentation_idc+(15<<24)),e.writeUint8(this.parallelismType+252),e.writeUint8(this.chroma_format_idc+252),e.writeUint8(this.bit_depth_luma_minus8+248),e.writeUint8(this.bit_depth_chroma_minus8+248),e.writeUint16(this.avgFrameRate),e.writeUint8((this.constantFrameRate<<6)+(this.numTemporalLayers<<3)+(this.temporalIdNested<<2)+this.lengthSizeMinusOne),e.writeUint8(this.nalu_arrays.length),t=0;t<this.nalu_arrays.length;t++)for(e.writeUint8((this.nalu_arrays[t].completeness<<7)+this.nalu_arrays[t].nalu_type),e.writeUint16(this.nalu_arrays[t].length),i=0;i<this.nalu_arrays[t].length;i++)e.writeUint16(this.nalu_arrays[t][i].data.length),e.writeUint8Array(this.nalu_arrays[t][i].data)},u.kindBox.prototype.write=function(e){this.version=0,this.flags=0,this.size=this.schemeURI.length+1+(this.value.length+1),this.writeHeader(e),e.writeCString(this.schemeURI),e.writeCString(this.value)},u.mdhdBox.prototype.write=function(e){this.size=20,this.flags=0,this.version=0,this.writeHeader(e),e.writeUint32(this.creation_time),e.writeUint32(this.modification_time),e.writeUint32(this.timescale),e.writeUint32(this.duration),e.writeUint16(this.language),e.writeUint16(0)},u.mehdBox.prototype.write=function(e){this.version=0,this.flags=0,this.size=4,this.writeHeader(e),e.writeUint32(this.fragment_duration)},u.mfhdBox.prototype.write=function(e){this.version=0,this.flags=0,this.size=4,this.writeHeader(e),e.writeUint32(this.sequence_number)},u.mvhdBox.prototype.write=function(e){this.version=0,this.flags=0,this.size=96,this.writeHeader(e),e.writeUint32(this.creation_time),e.writeUint32(this.modification_time),e.writeUint32(this.timescale),e.writeUint32(this.duration),e.writeUint32(this.rate),e.writeUint16(this.volume<<8),e.writeUint16(0),e.writeUint32(0),e.writeUint32(0),e.writeUint32Array(this.matrix),e.writeUint32(0),e.writeUint32(0),e.writeUint32(0),e.writeUint32(0),e.writeUint32(0),e.writeUint32(0),e.writeUint32(this.next_track_id)},u.SampleEntry.prototype.writeHeader=function(e){this.size=8,u.Box.prototype.writeHeader.call(this,e),e.writeUint8(0),e.writeUint8(0),e.writeUint8(0),e.writeUint8(0),e.writeUint8(0),e.writeUint8(0),e.writeUint16(this.data_reference_index)},u.SampleEntry.prototype.writeFooter=function(e){for(var t=0;t<this.boxes.length;t++)this.boxes[t].write(e),this.size+=this.boxes[t].size;o.debug("BoxWriter","Adjusting box "+this.type+" with new size "+this.size),e.adjustUint32(this.sizePosition,this.size)},u.SampleEntry.prototype.write=function(e){this.writeHeader(e),e.writeUint8Array(this.data),this.size+=this.data.length,o.debug("BoxWriter","Adjusting box "+this.type+" with new size "+this.size),e.adjustUint32(this.sizePosition,this.size)},u.VisualSampleEntry.prototype.write=function(e){this.writeHeader(e),this.size+=70,e.writeUint16(0),e.writeUint16(0),e.writeUint32(0),e.writeUint32(0),e.writeUint32(0),e.writeUint16(this.width),e.writeUint16(this.height),e.writeUint32(this.horizresolution),e.writeUint32(this.vertresolution),e.writeUint32(0),e.writeUint16(this.frame_count),e.writeUint8(Math.min(31,this.compressorname.length)),e.writeString(this.compressorname,null,31),e.writeUint16(this.depth),e.writeInt16(-1),this.writeFooter(e)},u.AudioSampleEntry.prototype.write=function(e){this.writeHeader(e),this.size+=20,e.writeUint32(0),e.writeUint32(0),e.writeUint16(this.channel_count),e.writeUint16(this.samplesize),e.writeUint16(0),e.writeUint16(0),e.writeUint32(this.samplerate<<16),this.writeFooter(e)},u.stppSampleEntry.prototype.write=function(e){this.writeHeader(e),this.size+=this.namespace.length+1+this.schema_location.length+1+this.auxiliary_mime_types.length+1,e.writeCString(this.namespace),e.writeCString(this.schema_location),e.writeCString(this.auxiliary_mime_types),this.writeFooter(e)},u.SampleGroupEntry.prototype.write=function(e){e.writeUint8Array(this.data)},u.sbgpBox.prototype.write=function(e){this.version=1,this.flags=0,this.size=12+8*this.entries.length,this.writeHeader(e),e.writeString(this.grouping_type,null,4),e.writeUint32(this.grouping_type_parameter),e.writeUint32(this.entries.length);for(var t=0;t<this.entries.length;t++){var i=this.entries[t];e.writeInt32(i.sample_count),e.writeInt32(i.group_description_index)}},u.sgpdBox.prototype.write=function(e){var t,i;for(this.flags=0,this.size=12,t=0;t<this.entries.length;t++)i=this.entries[t],1===this.version&&(0===this.default_length&&(this.size+=4),this.size+=i.data.length);for(this.writeHeader(e),e.writeString(this.grouping_type,null,4),1===this.version&&e.writeUint32(this.default_length),this.version>=2&&e.writeUint32(this.default_sample_description_index),e.writeUint32(this.entries.length),t=0;t<this.entries.length;t++)i=this.entries[t],1===this.version&&0===this.default_length&&e.writeUint32(i.description_length),i.write(e)},u.sidxBox.prototype.write=function(e){this.version=0,this.flags=0,this.size=20+12*this.references.length,this.writeHeader(e),e.writeUint32(this.reference_ID),e.writeUint32(this.timescale),e.writeUint32(this.earliest_presentation_time),e.writeUint32(this.first_offset),e.writeUint16(0),e.writeUint16(this.references.length);for(var t=0;t<this.references.length;t++){var i=this.references[t];e.writeUint32(i.reference_type<<31|i.referenced_size),e.writeUint32(i.subsegment_duration),e.writeUint32(i.starts_with_SAP<<31|i.SAP_type<<28|i.SAP_delta_time)}},u.smhdBox.prototype.write=function(e){this.version=0,this.flags=1,this.size=4,this.writeHeader(e),e.writeUint16(this.balance),e.writeUint16(0)},u.stcoBox.prototype.write=function(e){this.version=0,this.flags=0,this.size=4+4*this.chunk_offsets.length,this.writeHeader(e),e.writeUint32(this.chunk_offsets.length),e.writeUint32Array(this.chunk_offsets)},u.stscBox.prototype.write=function(e){var t;for(this.version=0,this.flags=0,this.size=4+12*this.first_chunk.length,this.writeHeader(e),e.writeUint32(this.first_chunk.length),t=0;t<this.first_chunk.length;t++)e.writeUint32(this.first_chunk[t]),e.writeUint32(this.samples_per_chunk[t]),e.writeUint32(this.sample_description_index[t])},u.stsdBox.prototype.write=function(e){var t;for(this.version=0,this.flags=0,this.size=0,this.writeHeader(e),e.writeUint32(this.entries.length),this.size+=4,t=0;t<this.entries.length;t++)this.entries[t].write(e),this.size+=this.entries[t].size;o.debug("BoxWriter","Adjusting box "+this.type+" with new size "+this.size),e.adjustUint32(this.sizePosition,this.size)},u.stshBox.prototype.write=function(e){var t;for(this.version=0,this.flags=0,this.size=4+8*this.shadowed_sample_numbers.length,this.writeHeader(e),e.writeUint32(this.shadowed_sample_numbers.length),t=0;t<this.shadowed_sample_numbers.length;t++)e.writeUint32(this.shadowed_sample_numbers[t]),e.writeUint32(this.sync_sample_numbers[t])},u.stssBox.prototype.write=function(e){this.version=0,this.flags=0,this.size=4+4*this.sample_numbers.length,this.writeHeader(e),e.writeUint32(this.sample_numbers.length),e.writeUint32Array(this.sample_numbers)},u.stszBox.prototype.write=function(e){var t,i=!0;if(this.version=0,this.flags=0,this.sample_sizes.length>0)for(t=0;t+1<this.sample_sizes.length;){if(this.sample_sizes[t+1]!==this.sample_sizes[0]){i=!1;break}t++}else i=!1;this.size=8,i||(this.size+=4*this.sample_sizes.length),this.writeHeader(e),i?e.writeUint32(this.sample_sizes[0]):e.writeUint32(0),e.writeUint32(this.sample_sizes.length),i||e.writeUint32Array(this.sample_sizes)},u.sttsBox.prototype.write=function(e){var t;for(this.version=0,this.flags=0,this.size=4+8*this.sample_counts.length,this.writeHeader(e),e.writeUint32(this.sample_counts.length),t=0;t<this.sample_counts.length;t++)e.writeUint32(this.sample_counts[t]),e.writeUint32(this.sample_deltas[t])},u.tfdtBox.prototype.write=function(e){var t=Math.pow(2,32)-1;this.version=this.baseMediaDecodeTime>t?1:0,this.flags=0,this.size=4,1===this.version&&(this.size+=4),this.writeHeader(e),1===this.version?e.writeUint64(this.baseMediaDecodeTime):e.writeUint32(this.baseMediaDecodeTime)},u.tfhdBox.prototype.write=function(e){this.version=0,this.size=4,this.flags&u.TFHD_FLAG_BASE_DATA_OFFSET&&(this.size+=8),this.flags&u.TFHD_FLAG_SAMPLE_DESC&&(this.size+=4),this.flags&u.TFHD_FLAG_SAMPLE_DUR&&(this.size+=4),this.flags&u.TFHD_FLAG_SAMPLE_SIZE&&(this.size+=4),this.flags&u.TFHD_FLAG_SAMPLE_FLAGS&&(this.size+=4),this.writeHeader(e),e.writeUint32(this.track_id),this.flags&u.TFHD_FLAG_BASE_DATA_OFFSET&&e.writeUint64(this.base_data_offset),this.flags&u.TFHD_FLAG_SAMPLE_DESC&&e.writeUint32(this.default_sample_description_index),this.flags&u.TFHD_FLAG_SAMPLE_DUR&&e.writeUint32(this.default_sample_duration),this.flags&u.TFHD_FLAG_SAMPLE_SIZE&&e.writeUint32(this.default_sample_size),this.flags&u.TFHD_FLAG_SAMPLE_FLAGS&&e.writeUint32(this.default_sample_flags)},u.tkhdBox.prototype.write=function(e){this.version=0,this.size=80,this.writeHeader(e),e.writeUint32(this.creation_time),e.writeUint32(this.modification_time),e.writeUint32(this.track_id),e.writeUint32(0),e.writeUint32(this.duration),e.writeUint32(0),e.writeUint32(0),e.writeInt16(this.layer),e.writeInt16(this.alternate_group),e.writeInt16(this.volume<<8),e.writeUint16(0),e.writeInt32Array(this.matrix),e.writeUint32(this.width),e.writeUint32(this.height)},u.trexBox.prototype.write=function(e){this.version=0,this.flags=0,this.size=20,this.writeHeader(e),e.writeUint32(this.track_id),e.writeUint32(this.default_sample_description_index),e.writeUint32(this.default_sample_duration),e.writeUint32(this.default_sample_size),e.writeUint32(this.default_sample_flags)},u.trunBox.prototype.write=function(e){this.version=0,this.size=4,this.flags&u.TRUN_FLAGS_DATA_OFFSET&&(this.size+=4),this.flags&u.TRUN_FLAGS_FIRST_FLAG&&(this.size+=4),this.flags&u.TRUN_FLAGS_DURATION&&(this.size+=4*this.sample_duration.length),this.flags&u.TRUN_FLAGS_SIZE&&(this.size+=4*this.sample_size.length),this.flags&u.TRUN_FLAGS_FLAGS&&(this.size+=4*this.sample_flags.length),this.flags&u.TRUN_FLAGS_CTS_OFFSET&&(this.size+=4*this.sample_composition_time_offset.length),this.writeHeader(e),e.writeUint32(this.sample_count),this.flags&u.TRUN_FLAGS_DATA_OFFSET&&(this.data_offset_position=e.getPosition(),e.writeInt32(this.data_offset)),this.flags&u.TRUN_FLAGS_FIRST_FLAG&&e.writeUint32(this.first_sample_flags);for(var t=0;t<this.sample_count;t++)this.flags&u.TRUN_FLAGS_DURATION&&e.writeUint32(this.sample_duration[t]),this.flags&u.TRUN_FLAGS_SIZE&&e.writeUint32(this.sample_size[t]),this.flags&u.TRUN_FLAGS_FLAGS&&e.writeUint32(this.sample_flags[t]),this.flags&u.TRUN_FLAGS_CTS_OFFSET&&(0===this.version?e.writeUint32(this.sample_composition_time_offset[t]):e.writeInt32(this.sample_composition_time_offset[t]))},u["url Box"].prototype.write=function(e){this.version=0,this.location?(this.flags=0,this.size=this.location.length+1):(this.flags=1,this.size=0),this.writeHeader(e),this.location&&e.writeCString(this.location)},u["urn Box"].prototype.write=function(e){this.version=0,this.flags=0,this.size=this.name.length+1+(this.location?this.location.length+1:0),this.writeHeader(e),e.writeCString(this.name),this.location&&e.writeCString(this.location)},u.vmhdBox.prototype.write=function(e){this.version=0,this.flags=1,this.size=8,this.writeHeader(e),e.writeUint16(this.graphicsmode),e.writeUint16Array(this.opcolor)},u.cttsBox.prototype.unpack=function(e){var t,i,s;for(s=0,t=0;t<this.sample_counts.length;t++)for(i=0;i<this.sample_counts[t];i++)e[s].pts=e[s].dts+this.sample_offsets[t],s++},u.sttsBox.prototype.unpack=function(e){var t,i,s;for(s=0,t=0;t<this.sample_counts.length;t++)for(i=0;i<this.sample_counts[t];i++)e[s].dts=0===s?0:e[s-1].dts+this.sample_deltas[t],s++},u.stcoBox.prototype.unpack=function(e){var t;for(t=0;t<this.chunk_offsets.length;t++)e[t].offset=this.chunk_offsets[t]},u.stscBox.prototype.unpack=function(e){var t,i,s,r,a;for(r=0,a=0,t=0;t<this.first_chunk.length;t++)for(i=0;i<(t+1<this.first_chunk.length?this.first_chunk[t+1]:1/0);i++)for(a++,s=0;s<this.samples_per_chunk[t];s++){if(!e[r])return;e[r].description_index=this.sample_description_index[t],e[r].chunk_index=a,r++}},u.stszBox.prototype.unpack=function(e){var t;for(t=0;t<this.sample_sizes.length;t++)e[t].size=this.sample_sizes[t]},u.DIFF_BOXES_PROP_NAMES=["boxes","entries","references","subsamples","items","item_infos","extents","associations","subsegments","ranges","seekLists","seekPoints","esd","levels"],u.DIFF_PRIMITIVE_ARRAY_PROP_NAMES=["compatible_brands","matrix","opcolor","sample_counts","sample_counts","sample_deltas","first_chunk","samples_per_chunk","sample_sizes","chunk_offsets","sample_offsets","sample_description_index","sample_duration"],u.boxEqualFields=function(e,t){if(e&&!t)return!1;var i;for(i in e)if(!(u.DIFF_BOXES_PROP_NAMES.indexOf(i)>-1||e[i]instanceof u.Box||t[i]instanceof u.Box||void 0===e[i]||void 0===t[i]||"function"==typeof e[i]||"function"==typeof t[i]||e.subBoxNames&&e.subBoxNames.indexOf(i.slice(0,4))>-1||t.subBoxNames&&t.subBoxNames.indexOf(i.slice(0,4))>-1||"data"===i||"start"===i||"size"===i||"creation_time"===i||"modification_time"===i||u.DIFF_PRIMITIVE_ARRAY_PROP_NAMES.indexOf(i)>-1||e[i]===t[i]))return!1;return!0},u.boxEqual=function(e,t){if(!u.boxEqualFields(e,t))return!1;for(var i=0;i<u.DIFF_BOXES_PROP_NAMES.length;i++){var s=u.DIFF_BOXES_PROP_NAMES[i];if(e[s]&&t[s]&&!u.boxEqual(e[s],t[s]))return!1}return!0};var m=function(){};m.prototype.parseSample=function(e){var t,i={};i.resources=[];var s=new n(e.data.buffer);if(e.subsamples&&0!==e.subsamples.length){if(i.documentString=s.readString(e.subsamples[0].size),e.subsamples.length>1)for(t=1;t<e.subsamples.length;t++)i.resources[t]=s.readUint8Array(e.subsamples[t].size)}else i.documentString=s.readString(e.data.length);return"undefined"!=typeof DOMParser&&(i.document=(new DOMParser).parseFromString(i.documentString,"application/xml")),i};var g=function(){};g.prototype.parseSample=function(e){return new n(e.data.buffer).readString(e.data.length)},g.prototype.parseConfig=function(e){var t=new n(e.buffer);return t.readUint32(),t.readCString()},t.XMLSubtitlein4Parser=m,t.Textin4Parser=g;var y=function(e){this.stream=e||new h,this.boxes=[],this.mdats=[],this.moofs=[],this.isProgressive=!1,this.moovStartFound=!1,this.onMoovStart=null,this.moovStartSent=!1,this.onReady=null,this.readySent=!1,this.onSegment=null,this.onSamples=null,this.onError=null,this.sampleListBuilt=!1,this.fragmentedTracks=[],this.extractedTracks=[],this.isFragmentationInitialized=!1,this.sampleProcessingStarted=!1,this.nextMoofNumber=0,this.itemListBuilt=!1,this.onSidx=null,this.sidxSent=!1};y.prototype.destroy=function(){this.stream&&(this.stream.destroy(),this.stream=null),this.boxes=[],this.mdats=[],this.moofs=[],this.isProgressive=!1,this.moovStartFound=!1,this.onMoovStart=null,this.moovStartSent=!1,this.onReady=null,this.readySent=!1,this.onSegment=null,this.onSamples=null,this.onError=null,this.sampleListBuilt=!1,this.fragmentedTracks=[],this.extractedTracks=[],this.isFragmentationInitialized=!1,this.sampleProcessingStarted=!1,this.nextMoofNumber=0,this.itemListBuilt=!1,this.onSidx=null,this.sidxSent=!1},y.prototype.setSegmentOptions=function(e,t,i){var s=this.getTrackById(e);if(s){var r={};this.fragmentedTracks.push(r),r.id=e,r.user=t,r.trak=s,s.nextSample=0,r.segmentStream=null,r.nb_samples=1e3,r.rapAlignement=!0,i&&(i.nbSamples&&(r.nb_samples=i.nbSamples),i.rapAlignement&&(r.rapAlignement=i.rapAlignement))}},y.prototype.unsetSegmentOptions=function(e){for(var t=-1,i=0;i<this.fragmentedTracks.length;i++){this.fragmentedTracks[i].id==e&&(t=i)}t>-1&&this.fragmentedTracks.splice(t,1)},y.prototype.setExtractionOptions=function(e,t,i){var s=this.getTrackById(e);if(s){var r={};this.extractedTracks.push(r),r.id=e,r.user=t,r.trak=s,s.nextSample=0,r.nb_samples=1e3,r.samples=[],i&&i.nbSamples&&(r.nb_samples=i.nbSamples)}},y.prototype.unsetExtractionOptions=function(e){for(var t=-1,i=0;i<this.extractedTracks.length;i++){this.extractedTracks[i].id==e&&(t=i)}t>-1&&this.extractedTracks.splice(t,1)},y.prototype.parse=function(){var e,t;if(!this.restoreParsePosition||this.restoreParsePosition())for(;;){if(this.hasIncompleteMdat&&this.hasIncompleteMdat()){if(this.processIncompleteMdat())continue;return}if(this.saveParsePosition&&this.saveParsePosition(),(e=u.parseOneBox(this.stream,false)).code===u.ERR_NOT_ENOUGH_DATA){if(this.processIncompleteBox){if(this.processIncompleteBox(e))continue;return}return}var i;switch(i="uuid"!==(t=e.box).type?t.type:t.uuid,this.boxes.push(t),i){case"mdat":this.mdats.push(t);break;case"moof":this.moofs.push(t);break;case"moov":this.moovStartFound=!0,0===this.mdats.length&&(this.isProgressive=!0);default:void 0!==this[i]&&o.warn("ISOFile","Duplicate Box of type: "+i+", overriding previous occurrence"),this[i]=t}this.updateUsedBytes&&this.updateUsedBytes(t,e)}},y.prototype.checkBuffer=function(e){if(null==e)throw"Buffer must be defined and non empty";if(void 0===e.fileStart)throw"Buffer must have a fileStart property";return 0===e.byteLength?(o.warn("ISOFile","Ignoring empty buffer (fileStart: "+e.fileStart+")"),this.stream.logBufferLevel(),!1):(o.info("ISOFile","Processing buffer (fileStart: "+e.fileStart+")"),e.usedBytes=0,this.stream.insertBuffer(e),this.stream.logBufferLevel(),!!this.stream.initialized()||(o.warn("ISOFile","Not ready to start parsing"),!1))},y.prototype.appendBuffer=function(e,t){var i;if(this.checkBuffer(e))return this.parse(),this.moovStartFound&&!this.moovStartSent&&(this.moovStartSent=!0,this.onMoovStart&&this.onMoovStart()),this.moov?(this.sampleListBuilt||(this.buildSampleLists(),this.sampleListBuilt=!0),this.updateSampleLists(),this.onReady&&!this.readySent&&(this.readySent=!0,this.onReady(this.getInfo())),this.processSamples(t),this.nextSeekPosition?(i=this.nextSeekPosition,this.nextSeekPosition=void 0):i=this.nextParsePosition,this.stream.getEndFilePositionAfter&&(i=this.stream.getEndFilePositionAfter(i))):i=this.nextParsePosition?this.nextParsePosition:0,this.sidx&&this.onSidx&&!this.sidxSent&&(this.onSidx(this.sidx),this.sidxSent=!0),this.meta&&(this.flattenItemInfo&&!this.itemListBuilt&&(this.flattenItemInfo(),this.itemListBuilt=!0),this.processItems&&this.processItems(this.onItem)),this.stream.cleanBuffers&&(o.info("ISOFile","Done processing buffer (fileStart: "+e.fileStart+") - next buffer to fetch should have a fileStart position of "+i),this.stream.logBufferLevel(),this.stream.cleanBuffers(),this.stream.logBufferLevel(!0),o.info("ISOFile","Sample data size in memory: "+this.getAllocatedSampleDataSize())),i},y.prototype.getInfo=function(){var e,t,i,s,r,a,o={},n=new Date("1904-01-01T00:00:00Z").getTime();if(this.moov)for(o.hasMoov=!0,o.duration=this.moov.mvhd.duration,o.timescale=this.moov.mvhd.timescale,o.isFragmented=null!=this.moov.mvex,o.isFragmented&&this.moov.mvex.mehd&&(o.fragment_duration=this.moov.mvex.mehd.fragment_duration),o.isProgressive=this.isProgressive,o.hasIOD=null!=this.moov.iods,o.brands=[],o.brands.push(this.ftyp.major_brand),o.brands=o.brands.concat(this.ftyp.compatible_brands),o.created=new Date(n+1e3*this.moov.mvhd.creation_time),o.modified=new Date(n+1e3*this.moov.mvhd.modification_time),o.tracks=[],o.audioTracks=[],o.videoTracks=[],o.subtitleTracks=[],o.metadataTracks=[],o.hintTracks=[],o.otherTracks=[],e=0;e<this.moov.traks.length;e++){if(a=(i=this.moov.traks[e]).mdia.minf.stbl.stsd.entries[0],s={},o.tracks.push(s),s.id=i.tkhd.track_id,s.name=i.mdia.hdlr.name,s.references=[],i.tref)for(t=0;t<i.tref.boxes.length;t++)r={},s.references.push(r),r.type=i.tref.boxes[t].type,r.track_ids=i.tref.boxes[t].track_ids;i.edts&&(s.edits=i.edts.elst.entries),s.created=new Date(n+1e3*i.tkhd.creation_time),s.modified=new Date(n+1e3*i.tkhd.modification_time),s.movie_duration=i.tkhd.duration,s.movie_timescale=o.timescale,s.layer=i.tkhd.layer,s.alternate_group=i.tkhd.alternate_group,s.volume=i.tkhd.volume,s.matrix=i.tkhd.matrix,s.track_width=i.tkhd.width/65536,s.track_height=i.tkhd.height/65536,s.timescale=i.mdia.mdhd.timescale,s.cts_shift=i.mdia.minf.stbl.cslg,s.duration=i.mdia.mdhd.duration,s.samples_duration=i.samples_duration,s.codec=a.getCodec(),s.kind=i.udta&&i.udta.kinds.length?i.udta.kinds[0]:{schemeURI:"",value:""},s.language=i.mdia.elng?i.mdia.elng.extended_language:i.mdia.mdhd.languageString,s.nb_samples=i.samples.length,s.size=i.samples_size,s.bitrate=8*s.size*s.timescale/s.samples_duration,a.isAudio()?(s.type="audio",o.audioTracks.push(s),s.audio={},s.audio.sample_rate=a.getSampleRate(),s.audio.channel_count=a.getChannelCount(),s.audio.sample_size=a.getSampleSize()):a.isVideo()?(s.type="video",o.videoTracks.push(s),s.video={},s.video.width=a.getWidth(),s.video.height=a.getHeight()):a.isSubtitle()?(s.type="subtitles",o.subtitleTracks.push(s)):a.isHint()?(s.type="metadata",o.hintTracks.push(s)):a.isMetadata()?(s.type="metadata",o.metadataTracks.push(s)):(s.type="metadata",o.otherTracks.push(s))}else o.hasMoov=!1;if(o.mime="",o.hasMoov&&o.tracks){for(o.videoTracks&&o.videoTracks.length>0?o.mime+='video/mp4; codecs="':o.audioTracks&&o.audioTracks.length>0?o.mime+='audio/mp4; codecs="':o.mime+='application/mp4; codecs="',e=0;e<o.tracks.length;e++)0!==e&&(o.mime+=","),o.mime+=o.tracks[e].codec;o.mime+='"; profiles="',o.mime+=this.ftyp.compatible_brands.join(),o.mime+='"'}return o},y.prototype.setNextSeekPositionFromSample=function(e){e&&(this.nextSeekPosition?this.nextSeekPosition=Math.min(e.offset+e.alreadyRead,this.nextSeekPosition):this.nextSeekPosition=e.offset+e.alreadyRead)},y.prototype.processSamples=function(e){var t,i;if(this.sampleProcessingStarted){if(this.isFragmentationInitialized&&null!==this.onSegment)for(t=0;t<this.fragmentedTracks.length;t++){var s=this.fragmentedTracks[t];for(i=s.trak;i.nextSample<i.samples.length&&this.sampleProcessingStarted;){o.debug("ISOFile","Creating media fragment on track #"+s.id+" for sample "+i.nextSample);var r=this.createFragment(s.id,i.nextSample,s.segmentStream);if(!r)break;if(s.segmentStream=r,i.nextSample++,(i.nextSample%s.nb_samples==0||e||i.nextSample>=i.samples.length)&&(o.info("ISOFile","Sending fragmented data on track #"+s.id+" for samples ["+Math.max(0,i.nextSample-s.nb_samples)+","+(i.nextSample-1)+"]"),o.info("ISOFile","Sample data size in memory: "+this.getAllocatedSampleDataSize()),this.onSegment&&this.onSegment(s.id,s.user,s.segmentStream.buffer,i.nextSample,e||i.nextSample>=i.samples.length),s.segmentStream=null,s!==this.fragmentedTracks[t]))break}}if(null!==this.onSamples)for(t=0;t<this.extractedTracks.length;t++){var a=this.extractedTracks[t];for(i=a.trak;i.nextSample<i.samples.length&&this.sampleProcessingStarted;){o.debug("ISOFile","Exporting on track #"+a.id+" sample #"+i.nextSample);var n=this.getSample(i,i.nextSample);if(!n){this.setNextSeekPositionFromSample(i.samples[i.nextSample]);break}if(i.nextSample++,a.samples.push(n),(i.nextSample%a.nb_samples==0||i.nextSample>=i.samples.length)&&(o.debug("ISOFile","Sending samples on track #"+a.id+" for sample "+i.nextSample),this.onSamples&&this.onSamples(a.id,a.user,a.samples),a.samples=[],a!==this.extractedTracks[t]))break}}}},y.prototype.getBox=function(e){var t=this.getBoxes(e,!0);return t.length?t[0]:null},y.prototype.getBoxes=function(e,t){var i=[];return y._sweep.call(this,e,i,t),i},y._sweep=function(e,t,i){for(var s in this.type&&this.type==e&&t.push(this),this.boxes){if(t.length&&i)return;y._sweep.call(this.boxes[s],e,t,i)}},y.prototype.getTrackSamplesInfo=function(e){var t=this.getTrackById(e);return t?t.samples:void 0},y.prototype.getTrackSample=function(e,t){var i=this.getTrackById(e);return this.getSample(i,t)},y.prototype.releaseUsedSamples=function(e,t){var i=0,s=this.getTrackById(e);s.lastValidSample||(s.lastValidSample=0);for(var r=s.lastValidSample;r<t;r++)i+=this.releaseSample(s,r);o.info("ISOFile","Track #"+e+" released samples up to "+t+" (released size: "+i+", remaining: "+this.samplesDataSize+")"),s.lastValidSample=t},y.prototype.start=function(){this.sampleProcessingStarted=!0,this.processSamples(!1)},y.prototype.stop=function(){this.sampleProcessingStarted=!1},y.prototype.flush=function(){o.info("ISOFile","Flushing remaining samples"),this.updateSampleLists(),this.processSamples(!0),this.stream.cleanBuffers(),this.stream.logBufferLevel(!0)},y.prototype.seekTrack=function(e,t,i){var s,r,a,n,l=0,d=0;if(0===i.samples.length)return o.info("ISOFile","No sample in track, cannot seek! Using time "+o.getDurationString(0,1)+" and offset: 0"),{offset:0,time:0};for(s=0;s<i.samples.length;s++){if(r=i.samples[s],0===s)d=0,n=r.timescale;else if(r.cts>e*r.timescale){d=s-1;break}t&&r.is_sync&&(l=s)}for(t&&(d=l),e=i.samples[d].cts,i.nextSample=d;i.samples[d].alreadyRead===i.samples[d].size&&i.samples[d+1];)d++;return a=i.samples[d].offset+i.samples[d].alreadyRead,o.info("ISOFile","Seeking to "+(t?"RAP":"")+" sample #"+i.nextSample+" on track "+i.tkhd.track_id+", time "+o.getDurationString(e,n)+" and offset: "+a),{offset:a,time:e/n}},y.prototype.getTrackDuration=function(e){var t;return e.samples?((t=e.samples[e.samples.length-1]).cts+t.duration)/t.timescale:1/0},y.prototype.seek=function(e,t){var i,s,r,a=this.moov,n={offset:1/0,time:1/0};if(this.moov){for(r=0;r<a.traks.length;r++)i=a.traks[r],e>this.getTrackDuration(i)||((s=this.seekTrack(e,t,i)).offset<n.offset&&(n.offset=s.offset),s.time<n.time&&(n.time=s.time));return o.info("ISOFile","Seeking at time "+o.getDurationString(n.time,1)+" needs a buffer with a fileStart position of "+n.offset),n.offset===1/0?n={offset:this.nextParsePosition,time:0}:n.offset=this.stream.getEndFilePositionAfter(n.offset),o.info("ISOFile","Adjusted seek position (after checking data already in buffer): "+n.offset),n}throw"Cannot seek: moov not received!"},y.prototype.equal=function(e){for(var t=0;t<this.boxes.length&&t<e.boxes.length;){var i=this.boxes[t],s=e.boxes[t];if(!u.boxEqual(i,s))return!1;t++}return!0},t.ISOFile=y,y.prototype.lastBoxStartPosition=0,y.prototype.parsingMdat=null,y.prototype.nextParsePosition=0,y.prototype.discardMdatData=!1,y.prototype.processIncompleteBox=function(e){var t;return"mdat"===e.type?(t=new u[e.type+"Box"](e.size),this.parsingMdat=t,this.boxes.push(t),this.mdats.push(t),t.start=e.start,t.hdr_size=e.hdr_size,this.stream.addUsedBytes(t.hdr_size),this.lastBoxStartPosition=t.start+t.size,this.stream.seek(t.start+t.size,!1,this.discardMdatData)?(this.parsingMdat=null,!0):(this.moovStartFound?this.nextParsePosition=this.stream.findEndContiguousBuf():this.nextParsePosition=t.start+t.size,!1)):("moov"===e.type&&(this.moovStartFound=!0,0===this.mdats.length&&(this.isProgressive=!0)),!!this.stream.mergeNextBuffer&&this.stream.mergeNextBuffer()?(this.nextParsePosition=this.stream.getEndPosition(),!0):(e.type?this.moovStartFound?this.nextParsePosition=this.stream.getEndPosition():this.nextParsePosition=this.stream.getPosition()+e.size:this.nextParsePosition=this.stream.getEndPosition(),!1))},y.prototype.hasIncompleteMdat=function(){return null!==this.parsingMdat},y.prototype.processIncompleteMdat=function(){var e;return e=this.parsingMdat,this.stream.seek(e.start+e.size,!1,this.discardMdatData)?(o.debug("ISOFile","Found 'mdat' end in buffered data"),this.parsingMdat=null,!0):(this.nextParsePosition=this.stream.findEndContiguousBuf(),!1)},y.prototype.restoreParsePosition=function(){return this.stream.seek(this.lastBoxStartPosition,!0,this.discardMdatData)},y.prototype.saveParsePosition=function(){this.lastBoxStartPosition=this.stream.getPosition()},y.prototype.updateUsedBytes=function(e,t){this.stream.addUsedBytes&&("mdat"===e.type?(this.stream.addUsedBytes(e.hdr_size),this.discardMdatData&&this.stream.addUsedBytes(e.size-e.hdr_size)):this.stream.addUsedBytes(e.size))},y.prototype.add=u.Box.prototype.add,y.prototype.addBox=u.Box.prototype.addBox,y.prototype.init=function(e){var t=e||{};this.add("ftyp").set("major_brand",t.brands&&t.brands[0]||"iso4").set("minor_version",0).set("compatible_brands",t.brands||["iso4"]);var i=this.add("moov");return i.add("mvhd").set("timescale",t.timescale||600).set("rate",t.rate||65536).set("creation_time",0).set("modification_time",0).set("duration",t.duration||0).set("volume",t.width?0:256).set("matrix",[65536,0,0,0,65536,0,0,0,1073741824]).set("next_track_id",1),i.add("mvex"),this},y.prototype.addTrack=function(e){this.moov||this.init(e);var t=e||{};t.width=t.width||320,t.height=t.height||320,t.id=t.id||this.moov.mvhd.next_track_id,t.type=t.type||"avc1";var i=this.moov.add("trak");this.moov.mvhd.next_track_id=t.id+1,i.add("tkhd").set("flags",u.TKHD_FLAG_ENABLED|u.TKHD_FLAG_IN_MOVIE|u.TKHD_FLAG_IN_PREVIEW).set("creation_time",0).set("modification_time",0).set("track_id",t.id).set("duration",t.duration||0).set("layer",t.layer||0).set("alternate_group",0).set("volume",1).set("matrix",[0,0,0,0,0,0,0,0,0]).set("width",t.width<<16).set("height",t.height<<16);var s=i.add("mdia");s.add("mdhd").set("creation_time",0).set("modification_time",0).set("timescale",t.timescale||1).set("duration",t.media_duration||0).set("language",t.language||"und"),s.add("hdlr").set("handler",t.hdlr||"vide").set("name",t.name||"Track created with MP4Box.js"),s.add("elng").set("extended_language",t.language||"fr-FR");var r=s.add("minf");if(void 0!==u[t.type+"SampleEntry"]){var a=new u[t.type+"SampleEntry"];a.data_reference_index=1;var o="";for(var l in u.sampleEntryCodes)for(var d=u.sampleEntryCodes[l],h=0;h<d.length;h++)if(d.indexOf(t.type)>-1){o=l;break}switch(o){case"Visual":if(r.add("vmhd").set("graphicsmode",0).set("opcolor",[0,0,0]),a.set("width",t.width).set("height",t.height).set("horizresolution",72<<16).set("vertresolution",72<<16).set("frame_count",1).set("compressorname",t.type+" Compressor").set("depth",24),t.avcDecoderConfigRecord){var c=new u.avcCBox;c.parse(new n(t.avcDecoderConfigRecord)),a.addBox(c)}else if(t.hevcDecoderConfigRecord){var p=new u.hvcCBox;p.parse(new n(t.hevcDecoderConfigRecord)),a.addBox(p)}break;case"Audio":r.add("smhd").set("balance",t.balance||0),a.set("channel_count",t.channel_count||2).set("samplesize",t.samplesize||16).set("samplerate",t.samplerate||65536);break;case"Hint":r.add("hmhd");break;case"Subtitle":if(r.add("sthd"),"stpp"===t.type)a.set("namespace",t.namespace||"nonamespace").set("schema_location",t.schema_location||"").set("auxiliary_mime_types",t.auxiliary_mime_types||"");break;default:r.add("nmhd")}t.description&&a.addBox(t.description),t.description_boxes&&t.description_boxes.forEach((function(e){a.addBox(e)})),r.add("dinf").add("dref").addEntry((new u["url Box"]).set("flags",1));var f=r.add("stbl");return f.add("stsd").addEntry(a),f.add("stts").set("sample_counts",[]).set("sample_deltas",[]),f.add("stsc").set("first_chunk",[]).set("samples_per_chunk",[]).set("sample_description_index",[]),f.add("stco").set("chunk_offsets",[]),f.add("stsz").set("sample_sizes",[]),this.moov.mvex.add("trex").set("track_id",t.id).set("default_sample_description_index",t.default_sample_description_index||1).set("default_sample_duration",t.default_sample_duration||0).set("default_sample_size",t.default_sample_size||0).set("default_sample_flags",t.default_sample_flags||0),this.buildTrakSampleLists(i),t.id}},u.Box.prototype.computeSize=function(e){var t=e||new l;t.endianness=l.BIG_ENDIAN,this.write(t)},y.prototype.addSample=function(e,t,i){var s=i||{},r={},a=this.getTrackById(e);if(null!==a){r.number=a.samples.length,r.track_id=a.tkhd.track_id,r.timescale=a.mdia.mdhd.timescale,r.description_index=s.sample_description_index?s.sample_description_index-1:0,r.description=a.mdia.minf.stbl.stsd.entries[r.description_index],r.data=t,r.size=t.byteLength,r.alreadyRead=r.size,r.duration=s.duration||1,r.cts=s.cts||0,r.dts=s.dts||0,r.is_sync=s.is_sync||!1,r.is_leading=s.is_leading||0,r.depends_on=s.depends_on||0,r.is_depended_on=s.is_depended_on||0,r.has_redundancy=s.has_redundancy||0,r.degradation_priority=s.degradation_priority||0,r.offset=0,r.subsamples=s.subsamples,a.samples.push(r),a.samples_size+=r.size,a.samples_duration+=r.duration,void 0===a.first_dts&&(a.first_dts=s.dts),this.processSamples();var o=this.createSingleSampleMoof(r);return this.addBox(o),o.computeSize(),o.trafs[0].truns[0].data_offset=o.size+8,this.add("mdat").data=new Uint8Array(t),r}},y.prototype.createSingleSampleMoof=function(e){var t=0;t=e.is_sync?1<<25:65536;var i=new u.moofBox;i.add("mfhd").set("sequence_number",this.nextMoofNumber),this.nextMoofNumber++;var s=i.add("traf"),r=this.getTrackById(e.track_id);return s.add("tfhd").set("track_id",e.track_id).set("flags",u.TFHD_FLAG_DEFAULT_BASE_IS_MOOF),s.add("tfdt").set("baseMediaDecodeTime",e.dts-(r.first_dts||0)),s.add("trun").set("flags",u.TRUN_FLAGS_DATA_OFFSET|u.TRUN_FLAGS_DURATION|u.TRUN_FLAGS_SIZE|u.TRUN_FLAGS_FLAGS|u.TRUN_FLAGS_CTS_OFFSET).set("data_offset",0).set("first_sample_flags",0).set("sample_count",1).set("sample_duration",[e.duration]).set("sample_size",[e.size]).set("sample_flags",[t]).set("sample_composition_time_offset",[e.cts-e.dts]),i},y.prototype.lastMoofIndex=0,y.prototype.samplesDataSize=0,y.prototype.resetTables=function(){var e,t,i,s,r,a;for(this.initial_duration=this.moov.mvhd.duration,this.moov.mvhd.duration=0,e=0;e<this.moov.traks.length;e++){(t=this.moov.traks[e]).tkhd.duration=0,t.mdia.mdhd.duration=0,(t.mdia.minf.stbl.stco||t.mdia.minf.stbl.co64).chunk_offsets=[],(i=t.mdia.minf.stbl.stsc).first_chunk=[],i.samples_per_chunk=[],i.sample_description_index=[],(t.mdia.minf.stbl.stsz||t.mdia.minf.stbl.stz2).sample_sizes=[],(s=t.mdia.minf.stbl.stts).sample_counts=[],s.sample_deltas=[],(r=t.mdia.minf.stbl.ctts)&&(r.sample_counts=[],r.sample_offsets=[]),a=t.mdia.minf.stbl.stss;var o=t.mdia.minf.stbl.boxes.indexOf(a);-1!=o&&(t.mdia.minf.stbl.boxes[o]=null)}},y.initSampleGroups=function(e,t,i,s,r){var a,o,n,l;function d(e,t,i){this.grouping_type=e,this.grouping_type_parameter=t,this.sbgp=i,this.last_sample_in_run=-1,this.entry_index=-1}for(t&&(t.sample_groups_info=[]),e.sample_groups_info||(e.sample_groups_info=[]),o=0;o<i.length;o++){for(l=i[o].grouping_type+"/"+i[o].grouping_type_parameter,n=new d(i[o].grouping_type,i[o].grouping_type_parameter,i[o]),t&&(t.sample_groups_info[l]=n),e.sample_groups_info[l]||(e.sample_groups_info[l]=n),a=0;a<s.length;a++)s[a].grouping_type===i[o].grouping_type&&(n.description=s[a],n.description.used=!0);if(r)for(a=0;a<r.length;a++)r[a].grouping_type===i[o].grouping_type&&(n.fragment_description=r[a],n.fragment_description.used=!0,n.is_fragment=!0)}if(t){if(r)for(o=0;o<r.length;o++)!r[o].used&&r[o].version>=2&&(l=r[o].grouping_type+"/0",(n=new d(r[o].grouping_type,0)).is_fragment=!0,t.sample_groups_info[l]||(t.sample_groups_info[l]=n))}else for(o=0;o<s.length;o++)!s[o].used&&s[o].version>=2&&(l=s[o].grouping_type+"/0",n=new d(s[o].grouping_type,0),e.sample_groups_info[l]||(e.sample_groups_info[l]=n))},y.setSampleGroupProperties=function(e,t,i,s){var r,a;for(r in t.sample_groups=[],s){var o;if(t.sample_groups[r]={},t.sample_groups[r].grouping_type=s[r].grouping_type,t.sample_groups[r].grouping_type_parameter=s[r].grouping_type_parameter,i>=s[r].last_sample_in_run&&(s[r].last_sample_in_run<0&&(s[r].last_sample_in_run=0),s[r].entry_index++,s[r].entry_index<=s[r].sbgp.entries.length-1&&(s[r].last_sample_in_run+=s[r].sbgp.entries[s[r].entry_index].sample_count)),s[r].entry_index<=s[r].sbgp.entries.length-1?t.sample_groups[r].group_description_index=s[r].sbgp.entries[s[r].entry_index].group_description_index:t.sample_groups[r].group_description_index=-1,0!==t.sample_groups[r].group_description_index)o=s[r].fragment_description?s[r].fragment_description:s[r].description,t.sample_groups[r].group_description_index>0?(a=t.sample_groups[r].group_description_index>65535?(t.sample_groups[r].group_description_index>>16)-1:t.sample_groups[r].group_description_index-1,o&&a>=0&&(t.sample_groups[r].description=o.entries[a])):o&&o.version>=2&&o.default_group_description_index>0&&(t.sample_groups[r].description=o.entries[o.default_group_description_index-1])}},y.process_sdtp=function(e,t,i){t&&(e?(t.is_leading=e.is_leading[i],t.depends_on=e.sample_depends_on[i],t.is_depended_on=e.sample_is_depended_on[i],t.has_redundancy=e.sample_has_redundancy[i]):(t.is_leading=0,t.depends_on=0,t.is_depended_on=0,t.has_redundancy=0))},y.prototype.buildSampleLists=function(){var e,t;for(e=0;e<this.moov.traks.length;e++)t=this.moov.traks[e],this.buildTrakSampleLists(t)},y.prototype.buildTrakSampleLists=function(e){var t,i,s,r,a,o,n,l,d,h,c,u,p,f,m,g,A,b,_,v,S,w,E,T;if(e.samples=[],e.samples_duration=0,e.samples_size=0,i=e.mdia.minf.stbl.stco||e.mdia.minf.stbl.co64,s=e.mdia.minf.stbl.stsc,r=e.mdia.minf.stbl.stsz||e.mdia.minf.stbl.stz2,a=e.mdia.minf.stbl.stts,o=e.mdia.minf.stbl.ctts,n=e.mdia.minf.stbl.stss,l=e.mdia.minf.stbl.stsd,d=e.mdia.minf.stbl.subs,u=e.mdia.minf.stbl.stdp,h=e.mdia.minf.stbl.sbgps,c=e.mdia.minf.stbl.sgpds,b=-1,_=-1,v=-1,S=-1,w=0,E=0,T=0,y.initSampleGroups(e,null,h,c),void 0!==r){for(t=0;t<r.sample_sizes.length;t++){var k={};k.number=t,k.track_id=e.tkhd.track_id,k.timescale=e.mdia.mdhd.timescale,k.alreadyRead=0,e.samples[t]=k,k.size=r.sample_sizes[t],e.samples_size+=k.size,0===t?(f=1,p=0,k.chunk_index=f,k.chunk_run_index=p,A=s.samples_per_chunk[p],g=0,m=p+1<s.first_chunk.length?s.first_chunk[p+1]-1:1/0):t<A?(k.chunk_index=f,k.chunk_run_index=p):(f++,k.chunk_index=f,g=0,f<=m||(m=++p+1<s.first_chunk.length?s.first_chunk[p+1]-1:1/0),k.chunk_run_index=p,A+=s.samples_per_chunk[p]),k.description_index=s.sample_description_index[k.chunk_run_index]-1,k.description=l.entries[k.description_index],k.offset=i.chunk_offsets[k.chunk_index-1]+g,g+=k.size,t>b&&(_++,b<0&&(b=0),b+=a.sample_counts[_]),t>0?(e.samples[t-1].duration=a.sample_deltas[_],e.samples_duration+=e.samples[t-1].duration,k.dts=e.samples[t-1].dts+e.samples[t-1].duration):k.dts=0,o?(t>=v&&(S++,v<0&&(v=0),v+=o.sample_counts[S]),k.cts=e.samples[t].dts+o.sample_offsets[S]):k.cts=k.dts,n?(t==n.sample_numbers[w]-1?(k.is_sync=!0,w++):(k.is_sync=!1,k.degradation_priority=0),d&&d.entries[E].sample_delta+T==t+1&&(k.subsamples=d.entries[E].subsamples,T+=d.entries[E].sample_delta,E++)):k.is_sync=!0,y.process_sdtp(e.mdia.minf.stbl.sdtp,k,k.number),k.degradation_priority=u?u.priority[t]:0,d&&d.entries[E].sample_delta+T==t&&(k.subsamples=d.entries[E].subsamples,T+=d.entries[E].sample_delta),(h.length>0||c.length>0)&&y.setSampleGroupProperties(e,k,t,e.sample_groups_info)}t>0&&(e.samples[t-1].duration=Math.max(e.mdia.mdhd.duration-e.samples[t-1].dts,0),e.samples_duration+=e.samples[t-1].duration)}},y.prototype.updateSampleLists=function(){var e,t,i,s,r,a,o,n,l,d,h,c,p,f,m;if(void 0!==this.moov)for(;this.lastMoofIndex<this.moofs.length;)if(l=this.moofs[this.lastMoofIndex],this.lastMoofIndex++,"moof"==l.type)for(d=l,e=0;e<d.trafs.length;e++){for(h=d.trafs[e],c=this.getTrackById(h.tfhd.track_id),p=this.getTrexById(h.tfhd.track_id),s=h.tfhd.flags&u.TFHD_FLAG_SAMPLE_DESC?h.tfhd.default_sample_description_index:p?p.default_sample_description_index:1,r=h.tfhd.flags&u.TFHD_FLAG_SAMPLE_DUR?h.tfhd.default_sample_duration:p?p.default_sample_duration:0,a=h.tfhd.flags&u.TFHD_FLAG_SAMPLE_SIZE?h.tfhd.default_sample_size:p?p.default_sample_size:0,o=h.tfhd.flags&u.TFHD_FLAG_SAMPLE_FLAGS?h.tfhd.default_sample_flags:p?p.default_sample_flags:0,h.sample_number=0,h.sbgps.length>0&&y.initSampleGroups(c,h,h.sbgps,c.mdia.minf.stbl.sgpds,h.sgpds),t=0;t<h.truns.length;t++){var g=h.truns[t];for(i=0;i<g.sample_count;i++){(f={}).moof_number=this.lastMoofIndex,f.number_in_traf=h.sample_number,h.sample_number++,f.number=c.samples.length,h.first_sample_index=c.samples.length,c.samples.push(f),f.track_id=c.tkhd.track_id,f.timescale=c.mdia.mdhd.timescale,f.description_index=s-1,f.description=c.mdia.minf.stbl.stsd.entries[f.description_index],f.size=a,g.flags&u.TRUN_FLAGS_SIZE&&(f.size=g.sample_size[i]),c.samples_size+=f.size,f.duration=r,g.flags&u.TRUN_FLAGS_DURATION&&(f.duration=g.sample_duration[i]),c.samples_duration+=f.duration,c.first_traf_merged||i>0?f.dts=c.samples[c.samples.length-2].dts+c.samples[c.samples.length-2].duration:(h.tfdt?f.dts=h.tfdt.baseMediaDecodeTime:f.dts=0,c.first_traf_merged=!0),f.cts=f.dts,g.flags&u.TRUN_FLAGS_CTS_OFFSET&&(f.cts=f.dts+g.sample_composition_time_offset[i]),m=o,g.flags&u.TRUN_FLAGS_FLAGS?m=g.sample_flags[i]:0===i&&g.flags&u.TRUN_FLAGS_FIRST_FLAG&&(m=g.first_sample_flags),f.is_sync=!(m>>16&1),f.is_leading=m>>26&3,f.depends_on=m>>24&3,f.is_depended_on=m>>22&3,f.has_redundancy=m>>20&3,f.degradation_priority=65535&m;var A=!!(h.tfhd.flags&u.TFHD_FLAG_BASE_DATA_OFFSET),b=!!(h.tfhd.flags&u.TFHD_FLAG_DEFAULT_BASE_IS_MOOF),_=!!(g.flags&u.TRUN_FLAGS_DATA_OFFSET),v=0;v=A?h.tfhd.base_data_offset:b||0===t?d.start:n,f.offset=0===t&&0===i?_?v+g.data_offset:v:n,n=f.offset+f.size,(h.sbgps.length>0||h.sgpds.length>0||c.mdia.minf.stbl.sbgps.length>0||c.mdia.minf.stbl.sgpds.length>0)&&y.setSampleGroupProperties(c,f,f.number_in_traf,h.sample_groups_info)}}if(h.subs){c.has_fragment_subsamples=!0;var S=h.first_sample_index;for(t=0;t<h.subs.entries.length;t++)S+=h.subs.entries[t].sample_delta,(f=c.samples[S-1]).subsamples=h.subs.entries[t].subsamples}}},y.prototype.getSample=function(e,t){var i,s=e.samples[t];if(!this.moov)return null;if(s.data){if(s.alreadyRead==s.size)return s}else s.data=new Uint8Array(s.size),s.alreadyRead=0,this.samplesDataSize+=s.size,o.debug("ISOFile","Allocating sample #"+t+" on track #"+e.tkhd.track_id+" of size "+s.size+" (total: "+this.samplesDataSize+")");for(;;){var r=this.stream.findPosition(!0,s.offset+s.alreadyRead,!1);if(!(r>-1))return null;var a=(i=this.stream.buffers[r]).byteLength-(s.offset+s.alreadyRead-i.fileStart);if(s.size-s.alreadyRead<=a)return o.debug("ISOFile","Getting sample #"+t+" data (alreadyRead: "+s.alreadyRead+" offset: "+(s.offset+s.alreadyRead-i.fileStart)+" read size: "+(s.size-s.alreadyRead)+" full size: "+s.size+")"),l.memcpy(s.data.buffer,s.alreadyRead,i,s.offset+s.alreadyRead-i.fileStart,s.size-s.alreadyRead),i.usedBytes+=s.size-s.alreadyRead,this.stream.logBufferLevel(),s.alreadyRead=s.size,s;if(0===a)return null;o.debug("ISOFile","Getting sample #"+t+" partial data (alreadyRead: "+s.alreadyRead+" offset: "+(s.offset+s.alreadyRead-i.fileStart)+" read size: "+a+" full size: "+s.size+")"),l.memcpy(s.data.buffer,s.alreadyRead,i,s.offset+s.alreadyRead-i.fileStart,a),s.alreadyRead+=a,i.usedBytes+=a,this.stream.logBufferLevel()}},y.prototype.releaseSample=function(e,t){var i=e.samples[t];return i.data?(this.samplesDataSize-=i.size,i.data=null,i.alreadyRead=0,i.size):0},y.prototype.getAllocatedSampleDataSize=function(){return this.samplesDataSize},y.prototype.getCodecs=function(){var e,t="";for(e=0;e<this.moov.traks.length;e++){e>0&&(t+=","),t+=this.moov.traks[e].mdia.minf.stbl.stsd.entries[0].getCodec()}return t},y.prototype.getTrexById=function(e){var t;if(!this.moov||!this.moov.mvex)return null;for(t=0;t<this.moov.mvex.trexs.length;t++){var i=this.moov.mvex.trexs[t];if(i.track_id==e)return i}return null},y.prototype.getTrackById=function(e){if(void 0===this.moov)return null;for(var t=0;t<this.moov.traks.length;t++){var i=this.moov.traks[t];if(i.tkhd.track_id==e)return i}return null},y.prototype.items=[],y.prototype.entity_groups=[],y.prototype.itemsDataSize=0,y.prototype.flattenItemInfo=function(){var e,t,i,s=this.items,r=this.entity_groups,a=this.meta;if(null!=a&&void 0!==a.hdlr&&void 0!==a.iinf){for(e=0;e<a.iinf.item_infos.length;e++)(i={}).id=a.iinf.item_infos[e].item_ID,s[i.id]=i,i.ref_to=[],i.name=a.iinf.item_infos[e].item_name,a.iinf.item_infos[e].protection_index>0&&(i.protection=a.ipro.protections[a.iinf.item_infos[e].protection_index-1]),a.iinf.item_infos[e].item_type?i.type=a.iinf.item_infos[e].item_type:i.type="mime",i.content_type=a.iinf.item_infos[e].content_type,i.content_encoding=a.iinf.item_infos[e].content_encoding;if(a.grpl)for(e=0;e<a.grpl.boxes.length;e++)entity_group={},entity_group.id=a.grpl.boxes[e].group_id,entity_group.entity_ids=a.grpl.boxes[e].entity_ids,entity_group.type=a.grpl.boxes[e].type,r[entity_group.id]=entity_group;if(a.iloc)for(e=0;e<a.iloc.items.length;e++){var n=a.iloc.items[e];switch(i=s[n.item_ID],0!==n.data_reference_index&&(o.warn("Item storage with reference to other files: not supported"),i.source=a.dinf.boxes[n.data_reference_index-1]),n.construction_method){case 0:break;case 1:case 2:o.warn("Item storage with construction_method : not supported")}for(i.extents=[],i.size=0,t=0;t<n.extents.length;t++)i.extents[t]={},i.extents[t].offset=n.extents[t].extent_offset+n.base_offset,i.extents[t].length=n.extents[t].extent_length,i.extents[t].alreadyRead=0,i.size+=i.extents[t].length}if(a.pitm&&(s[a.pitm.item_id].primary=!0),a.iref)for(e=0;e<a.iref.references.length;e++){var l=a.iref.references[e];for(t=0;t<l.references.length;t++)s[l.from_item_ID].ref_to.push({type:l.type,id:l.references[t]})}if(a.iprp)for(var d=0;d<a.iprp.ipmas.length;d++){var h=a.iprp.ipmas[d];for(e=0;e<h.associations.length;e++){var c=h.associations[e];if((i=s[c.id])||(i=r[c.id]),i)for(void 0===i.properties&&(i.properties={},i.properties.boxes=[]),t=0;t<c.props.length;t++){var u=c.props[t];if(u.property_index>0&&u.property_index-1<a.iprp.ipco.boxes.length){var p=a.iprp.ipco.boxes[u.property_index-1];i.properties[p.type]=p,i.properties.boxes.push(p)}}}}}},y.prototype.getItem=function(e){var t,i;if(!this.meta)return null;if(!(i=this.items[e]).data&&i.size)i.data=new Uint8Array(i.size),i.alreadyRead=0,this.itemsDataSize+=i.size,o.debug("ISOFile","Allocating item #"+e+" of size "+i.size+" (total: "+this.itemsDataSize+")");else if(i.alreadyRead===i.size)return i;for(var s=0;s<i.extents.length;s++){var r=i.extents[s];if(r.alreadyRead!==r.length){var a=this.stream.findPosition(!0,r.offset+r.alreadyRead,!1);if(!(a>-1))return null;var n=(t=this.stream.buffers[a]).byteLength-(r.offset+r.alreadyRead-t.fileStart);if(!(r.length-r.alreadyRead<=n))return o.debug("ISOFile","Getting item #"+e+" extent #"+s+" partial data (alreadyRead: "+r.alreadyRead+" offset: "+(r.offset+r.alreadyRead-t.fileStart)+" read size: "+n+" full extent size: "+r.length+" full item size: "+i.size+")"),l.memcpy(i.data.buffer,i.alreadyRead,t,r.offset+r.alreadyRead-t.fileStart,n),r.alreadyRead+=n,i.alreadyRead+=n,t.usedBytes+=n,this.stream.logBufferLevel(),null;o.debug("ISOFile","Getting item #"+e+" extent #"+s+" data (alreadyRead: "+r.alreadyRead+" offset: "+(r.offset+r.alreadyRead-t.fileStart)+" read size: "+(r.length-r.alreadyRead)+" full extent size: "+r.length+" full item size: "+i.size+")"),l.memcpy(i.data.buffer,i.alreadyRead,t,r.offset+r.alreadyRead-t.fileStart,r.length-r.alreadyRead),t.usedBytes+=r.length-r.alreadyRead,this.stream.logBufferLevel(),i.alreadyRead+=r.length-r.alreadyRead,r.alreadyRead=r.length}}return i.alreadyRead===i.size?i:null},y.prototype.releaseItem=function(e){var t=this.items[e];if(t.data){this.itemsDataSize-=t.size,t.data=null,t.alreadyRead=0;for(var i=0;i<t.extents.length;i++){t.extents[i].alreadyRead=0}return t.size}return 0},y.prototype.processItems=function(e){for(var t in this.items){var i=this.items[t];this.getItem(i.id),e&&!i.sent&&(e(i),i.sent=!0,i.data=null)}},y.prototype.hasItem=function(e){for(var t in this.items){var i=this.items[t];if(i.name===e)return i.id}return-1},y.prototype.getMetaHandler=function(){return this.meta?this.meta.hdlr.handler:null},y.prototype.getPrimaryItem=function(){return this.meta&&this.meta.pitm?this.getItem(this.meta.pitm.item_id):null},y.prototype.itemToFragmentedTrackFile=function(e){var t=e||{},i=null;if(null==(i=t.itemId?this.getItem(t.itemId):this.getPrimaryItem()))return null;var s=new y;s.discardMdatData=!1;var r={type:i.type,description_boxes:i.properties.boxes};i.properties.ispe&&(r.width=i.properties.ispe.image_width,r.height=i.properties.ispe.image_height);var a=s.addTrack(r);return a?(s.addSample(a,i.data),s):null},y.prototype.write=function(e){for(var t=0;t<this.boxes.length;t++)this.boxes[t].write(e)},y.prototype.createFragment=function(e,t,i){var s=this.getTrackById(e),r=this.getSample(s,t);if(null==r)return this.setNextSeekPositionFromSample(s.samples[t]),null;var a=i||new l;a.endianness=l.BIG_ENDIAN;var n=this.createSingleSampleMoof(r);n.write(a),n.trafs[0].truns[0].data_offset=n.size+8,o.debug("MP4Box","Adjusting data_offset with new value "+n.trafs[0].truns[0].data_offset),a.adjustUint32(n.trafs[0].truns[0].data_offset_position,n.trafs[0].truns[0].data_offset);var d=new u.mdatBox;return d.data=r.data,d.write(a),a},y.writeInitializationSegment=function(e,t,i,s){var r;o.debug("ISOFile","Generating initialization segment");var a=new l;a.endianness=l.BIG_ENDIAN,e.write(a);var n=t.add("mvex");for(i&&n.add("mehd").set("fragment_duration",i),r=0;r<t.traks.length;r++)n.add("trex").set("track_id",t.traks[r].tkhd.track_id).set("default_sample_description_index",1).set("default_sample_duration",s).set("default_sample_size",0).set("default_sample_flags",65536);return t.write(a),a.buffer},y.prototype.save=function(e){var t=new l;t.endianness=l.BIG_ENDIAN,this.write(t),t.save(e)},y.prototype.getBuffer=function(){var e=new l;return e.endianness=l.BIG_ENDIAN,this.write(e),e.buffer},y.prototype.initializeSegmentation=function(){var e,t,i,s;for(null===this.onSegment&&o.warn("MP4Box","No segmentation callback set!"),this.isFragmentationInitialized||(this.isFragmentationInitialized=!0,this.nextMoofNumber=0,this.resetTables()),t=[],e=0;e<this.fragmentedTracks.length;e++){var r=new u.moovBox;r.mvhd=this.moov.mvhd,r.boxes.push(r.mvhd),i=this.getTrackById(this.fragmentedTracks[e].id),r.boxes.push(i),r.traks.push(i),(s={}).id=i.tkhd.track_id,s.user=this.fragmentedTracks[e].user,s.buffer=y.writeInitializationSegment(this.ftyp,r,this.moov.mvex&&this.moov.mvex.mehd?this.moov.mvex.mehd.fragment_duration:void 0,this.moov.traks[e].samples.length>0?this.moov.traks[e].samples[0].duration:0),t.push(s)}return t},u.Box.prototype.printHeader=function(e){this.size+=8,this.size>d&&(this.size+=8),"uuid"===this.type&&(this.size+=16),e.log(e.indent+"size:"+this.size),e.log(e.indent+"type:"+this.type)},u.FullBox.prototype.printHeader=function(e){this.size+=4,u.Box.prototype.printHeader.call(this,e),e.log(e.indent+"version:"+this.version),e.log(e.indent+"flags:"+this.flags)},u.Box.prototype.print=function(e){this.printHeader(e)},u.ContainerBox.prototype.print=function(e){this.printHeader(e);for(var t=0;t<this.boxes.length;t++)if(this.boxes[t]){var i=e.indent;e.indent+=" ",this.boxes[t].print(e),e.indent=i}},y.prototype.print=function(e){e.indent="";for(var t=0;t<this.boxes.length;t++)this.boxes[t]&&this.boxes[t].print(e)},u.mvhdBox.prototype.print=function(e){u.FullBox.prototype.printHeader.call(this,e),e.log(e.indent+"creation_time: "+this.creation_time),e.log(e.indent+"modification_time: "+this.modification_time),e.log(e.indent+"timescale: "+this.timescale),e.log(e.indent+"duration: "+this.duration),e.log(e.indent+"rate: "+this.rate),e.log(e.indent+"volume: "+(this.volume>>8)),e.log(e.indent+"matrix: "+this.matrix.join(", ")),e.log(e.indent+"next_track_id: "+this.next_track_id)},u.tkhdBox.prototype.print=function(e){u.FullBox.prototype.printHeader.call(this,e),e.log(e.indent+"creation_time: "+this.creation_time),e.log(e.indent+"modification_time: "+this.modification_time),e.log(e.indent+"track_id: "+this.track_id),e.log(e.indent+"duration: "+this.duration),e.log(e.indent+"volume: "+(this.volume>>8)),e.log(e.indent+"matrix: "+this.matrix.join(", ")),e.log(e.indent+"layer: "+this.layer),e.log(e.indent+"alternate_group: "+this.alternate_group),e.log(e.indent+"width: "+this.width),e.log(e.indent+"height: "+this.height)};var A={createFile:function(e,t){var i=void 0===e||e,s=new y(t);return s.discardMdatData=!i,s}};t.createFile=A.createFile}));function Rd(e){return e.reduce(((e,t)=>256*e+t))}function xd(e){const t=[101,103,119,99],i=e.length-28,s=e.slice(i,i+t.length);return t.every(((e,t)=>e===s[t]))}Cd.Log,Cd.MP4BoxStream,Cd.DataStream,Cd.MultiBufferStream,Cd.MPEG4DescriptorParser,Cd.BoxParser,Cd.XMLSubtitlein4Parser,Cd.Textin4Parser,Cd.ISOFile,Cd.createFile;class Dd{constructor(){this.s=null,this.a=null,this.l=0,this.c=0,this.u=1/0,this.A=!1,this.d=!1,this.r=4194304,this.n=new Uint8Array([30,158,90,33,244,57,83,165,2,70,35,87,215,231,226,108]),this.t=this.n.slice().reverse()}destroy(){this.s=null,this.a=null,this.l=0,this.c=0,this.u=1/0,this.A=!1,this.d=!1,this.r=4194304,this.n=null,this.t=null}transport(e){if(!this.s&&this.l>50)return e;if(this.l++,this.d)return e;const t=new Uint8Array(e);if(this.A){if(!(this.c<this.u))return this.a&&this.s?(this.a.set(t,this.r),this.s.parse(null,this.r,t.byteLength),this.a.slice(this.r,this.r+t.byteLength)):(console.error("video_error_2"),this.d=!0,e);xd(t)&&this.c++}else{const i=function(e,t){const i=function(e,t){for(let i=0;i<e.byteLength-t.length;i++)for(let s=0;s<t.length&&e[i+s]===t[s];s++)if(s===t.length-1)return i;return null}(e,t);if(i){const t=Rd(e.slice(i+16,i+16+8));return[t,Rd(e.slice(i+24,i+24+8)),function(e){return e.map((e=>~e))}(e.slice(i+32,i+32+t))]}return null}(t,this.t);if(!i)return e;const s=function(e){try{if("object"!=typeof WebAssembly||"function"!=typeof WebAssembly.instantiate)throw null;{const e=new WebAssembly.Module(Uint8Array.of(0,97,115,109,1,0,0,0));if(!(e instanceof WebAssembly.Module&&new WebAssembly.Instance(e)instanceof WebAssembly.Instance))throw null}}catch(e){return new Error("video_error_4")}let t;try{t={env:{__handle_stack_overflow:()=>e(new Error("video_error_1")),memory:new WebAssembly.Memory({initial:256,maximum:256})}}}catch(e){return new Error("video_error_5")}return t}(e);if(s instanceof Error)return console.error(s.message),this.d=!0,e;this.A=!0,this.u=i[1],xd(t)&&this.c++,WebAssembly.instantiate(i[2],s).then((e=>{if(!function(e){return"function"==typeof e.parse&&"object"==typeof e.memory}(e.instance.exports))return this.d=!0,void console.error("video_error_3");this.s=e.instance.exports,this.a=new Uint8Array(this.s.memory.buffer)})).catch((e=>{this.d=!0,console.error("video_error_6")}))}return e}}class Ld extends gd{constructor(e){super(e),this.TAG_NAME="Fmp4Loader",this.player=e,this.mp4Box=Cd.createFile(),this.tempFmp4List=[],this.offset=0,this.videoTrackId=null,this.audioTrackId=null,this.isHevc=!1,this.transportDescarmber=null,this.player._opt.isFmp4Private&&(this.transportDescarmber=new Dd),this._listenMp4Box(),e.debug.log(this.TAG_NAME,"init")}destroy(){this.mp4Box&&(this.mp4Box.stop(),this.mp4Box.flush(),this.mp4Box.destroy(),this.mp4Box=null),this.transportDescarmber&&(this.transportDescarmber.destroy(),this.transportDescarmber=null),this.tempFmp4List=[],this.offset=0,this.videoTrackId=null,this.audioTrackId=null,this.isHevc=!1,this.player.debug.log(this.TAG_NAME,"destroy")}_listenMp4Box(){this.mp4Box.onReady=this.onReady.bind(this),this.mp4Box.onError=this.onError.bind(this),this.mp4Box.onSamples=this.onSamples.bind(this)}onReady(e){this.player.debug.log(this.TAG_NAME,"onReady",e);const t=e.videoTracks[0],i=e.audioTracks[0];if(t){this.videoTrackId=t.id;const e=this.getSeqHeader(t);e&&(this.player.debug.log(this.TAG_NAME,"seqHeader",e),this._doDecodeByFmp4(e,je,0,!0,0)),this.mp4Box.setExtractionOptions(t.id)}if(i&&this.player._opt.hasAudio){this.audioTrackId=i.id;const e=i.audio||{},t=Lr.indexOf(e.sample_rate),s=i.codec.replace("mp4a.40.","");this.mp4Box.setExtractionOptions(i.id);const r={profile:parseInt(s,10),sampleRate:t,channel:e.channel_count},a=Pr(r);this.player.debug.log(this.TAG_NAME,"aacADTSHeader",a,"config",r),this._doDecodeByFmp4(a,Ne,0,!1,0)}this.mp4Box.start()}onError(e){this.player.debug.error(this.TAG_NAME,"mp4Box onError",e)}onSamples(e,t,i){if(e===this.videoTrackId)for(const t of i){const i=t.data,s=t.is_sync,r=1e3*t.cts/t.timescale;t.duration,t.timescale,this.player.updateStats({vbps:i.byteLength,dts:r}),s&&this.calcIframeIntervalTimestamp(r);let a=null;a=this.isHevc?Ln(i,s):yn(i,s);let o=this.cryptoPayload(a,s);this._doDecodeByFmp4(o,je,r,s,0),this.mp4Box.releaseUsedSamples(e,t.number)}else if(e===this.audioTrackId){if(this.player._opt.hasAudio)for(const t of i){const i=t.data;this.player.updateStats({abps:i.byteLength});const s=1e3*t.cts/t.timescale;t.duration,t.timescale;const r=new Uint8Array(i.byteLength+2);r.set([175,1],0),r.set(i,2),this._doDecodeByFmp4(r,Ne,s,!1,0),this.mp4Box.releaseUsedSamples(e,t.number)}}else this.player.debug.warn(this.TAG_NAME,"onSamples() trackId error",e)}getSeqHeader(e){const t=this.mp4Box.getTrackById(e.id);for(const e of t.mdia.minf.stbl.stsd.entries)if(e.avcC||e.hvcC){const t=new Cd.DataStream(void 0,0,Cd.DataStream.BIG_ENDIAN);let i=[];e.avcC?(e.avcC.write(t),i=[23,0,0,0,0]):(this.isHevc=!0,e.hvcC.write(t),i=[28,0,0,0,0]);const s=new Uint8Array(t.buffer,8),r=new Uint8Array(i.length+s.length);return r.set(i,0),r.set(s,i.length),r}return null}dispatch(e){let t=new Uint8Array(e);this.transportDescarmber&&(t=this.transportDescarmber.transport(t)),t.buffer.fileStart=this.offset,this.offset+=t.byteLength,this.mp4Box.appendBuffer(t.buffer)}downloadFmp4File(){const e=new Blob(this.tempFmp4List,{type:'video/mp4; codecs="avc1.640028,mp4a.40.2"'}),t=URL.createObjectURL(e),i=document.createElement("a");i.href=t,i.download=Qr()+".fmp4",i.click(),URL.revokeObjectURL(t)}getInputByteLength(){let e=0;return this.mp4Box&&(e=this.mp4Box.getAllocatedSampleDataSize()),e}}class Pd extends gd{LOG_NAME="Mpeg4Loader";constructor(e){super(e),this.player=e,this.player.debug.log(this.LOG_NAME,"init")}destroy(){super.destroy(),this.player.debug.log(this.LOG_NAME,"destroy")}}function Bd(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];if((t=t.filter(Boolean)).length<2)return t[0];const s=new Uint8Array(t.reduce(((e,t)=>e+t.byteLength),0));let r=0;return t.forEach((e=>{s.set(e,r),r+=e.byteLength})),s}const Id=3,Md=4,Ud=6,Fd=15,Od=17,Nd=129,jd=135,zd=21,Gd=134,Hd=27,$d=36;class Vd{constructor(){this.slices=[],this.total_length=0,this.expected_length=0,this.random_access_indicator=0}}class Wd{constructor(){this.pid=null,this.data=null,this.stream_type=null,this.random_access_indicator=null}}class Jd{constructor(){this.pid=null,this.stream_id=null,this.len=null,this.data=null,this.pts=null,this.nearest_pts=null,this.dts=null}}const qd=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];class Kd{constructor(){this.mimeType=null,this.duration=null,this.hasAudio=null,this.hasVideo=null,this.audioCodec=null,this.videoCodec=null,this.audioDataRate=null,this.videoDataRate=null,this.audioSampleRate=null,this.audioChannelCount=null,this.width=null,this.height=null,this.fps=null,this.profile=null,this.level=null,this.refFrames=null,this.chromaFormat=null,this.sarNum=null,this.sarDen=null,this.metadata=null,this.segments=null,this.segmentCount=null,this.hasKeyframesIndex=null,this.keyframesIndex=null}isComplete(){let e=!1===this.hasAudio||!0===this.hasAudio&&null!=this.audioCodec&&null!=this.audioSampleRate&&null!=this.audioChannelCount,t=!1===this.hasVideo||!0===this.hasVideo&&null!=this.videoCodec&&null!=this.width&&null!=this.height&&null!=this.fps&&null!=this.profile&&null!=this.level&&null!=this.refFrames&&null!=this.chromaFormat&&null!=this.sarNum&&null!=this.sarDen;return null!=this.mimeType&&e&&t}isSeekable(){return!0===this.hasKeyframesIndex}getNearestKeyframe(e){if(null==this.keyframesIndex)return null;let t=this.keyframesIndex,i=this._search(t.times,e);return{index:i,milliseconds:t.times[i],fileposition:t.filepositions[i]}}_search(e,t){let i=0,s=e.length-1,r=0,a=0,o=s;for(t<e[0]&&(i=0,a=o+1);a<=o;){if(r=a+Math.floor((o-a)/2),r===s||t>=e[r]&&t<e[r+1]){i=r;break}e[r]<t?a=r+1:o=r-1}return i}}class Yd{constructor(e){let t=null,i=e.audio_object_type,s=e.audio_object_type,r=e.sampling_freq_index,a=e.channel_config,o=0,n=navigator.userAgent.toLowerCase();-1!==n.indexOf("firefox")?r>=6?(s=5,t=new Array(4),o=r-3):(s=2,t=new Array(2),o=r):-1!==n.indexOf("android")?(s=2,t=new Array(2),o=r):(s=5,o=r,t=new Array(4),r>=6?o=r-3:1===a&&(s=2,t=new Array(2),o=r)),t[0]=s<<3,t[0]|=(15&r)>>>1,t[1]=(15&r)<<7,t[1]|=(15&a)<<3,5===s&&(t[1]|=(15&o)>>>1,t[2]=(1&o)<<7,t[2]|=8,t[3]=0),this.config=t,this.sampling_rate=qd[r],this.sampling_index=r,this.channel_count=a,this.object_type=s,this.original_object_type=i,this.codec_mimetype="mp4a.40."+s,this.original_codec_mimetype="mp4a.40."+i}}class Qd extends gd{constructor(e){super(e),this.player=e,this.TAG_NAME="TsLoaderV2",this.first_parse_=!0,this.tsPacketSize=0,this.syncOffset=0,this.pmt_=null,this.config_=null,this.media_info_=new Kd,this.timescale_=90,this.duration_=0,this.pat_={version_number:0,network_pid:0,program_map_pid:{}},this.current_program_=null,this.current_pmt_pid_=-1,this.program_pmt_map_={},this.pes_slice_queues_={},this.section_slice_queues_={},this.video_metadata_={vps:null,sps:null,pps:null,details:null},this.audio_metadata_={codec:null,audio_object_type:null,sampling_freq_index:null,sampling_frequency:null,channel_config:null},this.last_pcr_=null,this.audio_last_sample_pts_=void 0,this.aac_last_incomplete_data_=null,this.has_video_=!1,this.has_audio_=!1,this.video_init_segment_dispatched_=!1,this.audio_init_segment_dispatched_=!1,this.video_metadata_changed_=!1,this.audio_metadata_changed_=!1,this.loas_previous_frame=null,this.video_track_={type:"video",id:1,sequenceNumber:0,samples:[],length:0},this.audio_track_={type:"audio",id:2,sequenceNumber:0,samples:[],length:0},this._remainingPacketData=null,this.player.debug.log(this.TAG_NAME,"init")}destroy(){this.media_info_=null,this.pes_slice_queues_=null,this.section_slice_queues_=null,this.video_metadata_=null,this.audio_metadata_=null,this.aac_last_incomplete_data_=null,this.video_track_=null,this.audio_track_=null,this._remainingPacketData=null,super.destroy()}probe(e){let t=new Uint8Array(e),i=-1,s=188;if(t.byteLength<=3*s)return{needMoreData:!0};for(;-1===i;){let e=Math.min(1e3,t.byteLength-3*s);for(let r=0;r<e;){if(71===t[r]&&71===t[r+s]&&71===t[r+2*s]){i=r;break}r++}if(-1===i)if(188===s)s=192;else{if(192!==s)break;s=204}}return-1===i?{match:!1}:(192===s&&i>=4&&(i-=4),{match:!0,consumed:0,ts_packet_size:s,sync_offset:i})}_initPmt(){return{program_number:0,version_number:0,pcr_pid:0,pid_stream_type:{},common_pids:{h264:void 0,h265:void 0,adts_aac:void 0,loas_aac:void 0,opus:void 0,ac3:void 0,eac3:void 0,mp3:void 0},pes_private_data_pids:{},timed_id3_pids:{},synchronous_klv_pids:{},asynchronous_klv_pids:{},scte_35_pids:{},smpte2038_pids:{}}}dispatch(e){let t=new Uint8Array(e);this._remainingPacketData&&(t=Bd(this._remainingPacketData,t),this._remainingPacketData=null);let i=t.buffer;const s=this.parseChunks(i);s?this._remainingPacketData=t.subarray(s):t.length<this.tsPacketSize&&(this._remainingPacketData=t)}parseChunks(e){let t=0;if(this.first_parse_){this.first_parse_=!1;const i=this.probe(e);i.match&&(this.tsPacketSize=i.ts_packet_size,this.syncOffset=i.sync_offset),t=this.syncOffset,this.player.debug.log(this.TAG_NAME,`isFirstDispatch and tsPacketSize = ${this.tsPacketSize}, syncOffset = ${this.syncOffset}`)}for(;t+this.tsPacketSize<=e.byteLength;){192===this.tsPacketSize&&(t+=4);const i=new Uint8Array(e,t,188);let s=i[0];if(71!==s){this.player.debug.warn(this.TAG_NAME,`parseChunks() sync_byte = ${s}, not start with 0x47, so break`);break}let r=(64&i[1])>>>6;i[1];let a=(31&i[1])<<8|i[2],o=(48&i[3])>>>4,n=15&i[3],l=!(!this.pmt_||this.pmt_.pcr_pid!==a),d={},h=4;if(2==o||3==o){let e=i[4];if(e>0&&(l||3==o)){if(d.discontinuity_indicator=(128&i[5])>>>7,d.random_access_indicator=(64&i[5])>>>6,d.elementary_stream_priority_indicator=(32&i[5])>>>5,(16&i[5])>>>4){let e=300*(i[6]<<25|i[7]<<17|i[8]<<9|i[9]<<1|i[10]>>>7)+((1&i[10])<<8|i[11]);this.last_pcr_=e}}if(2==o||5+e===188){t+=188,204===this.tsPacketSize&&(t+=16);continue}h=5+e}if(1==o||3==o)if(0===a||a===this.current_pmt_pid_||null!=this.pmt_&&this.pmt_.pid_stream_type[a]===Gd){let i=188-h;this.handleSectionSlice(e,t+h,i,{pid:a,payload_unit_start_indicator:r,continuity_conunter:n,random_access_indicator:d.random_access_indicator})}else if(null!=this.pmt_&&null!=this.pmt_.pid_stream_type[a]){let i=188-h,s=this.pmt_.pid_stream_type[a];a!==this.pmt_.common_pids.h264&&a!==this.pmt_.common_pids.h265&&a!==this.pmt_.common_pids.adts_aac&&a!==this.pmt_.common_pids.loas_aac&&a!==this.pmt_.common_pids.ac3&&a!==this.pmt_.common_pids.eac3&&a!==this.pmt_.common_pids.opus&&a!==this.pmt_.common_pids.mp3&&!0!==this.pmt_.pes_private_data_pids[a]&&!0!==this.pmt_.timed_id3_pids[a]&&!0!==this.pmt_.synchronous_klv_pids[a]&&!0!==this.pmt_.asynchronous_klv_pids[a]||this.handlePESSlice(e,t+h,i,{pid:a,stream_type:s,payload_unit_start_indicator:r,continuity_conunter:n,random_access_indicator:d.random_access_indicator})}t+=188,204===this.tsPacketSize&&(t+=16)}return this.dispatchAudioVideoMediaSegment(),t}handleSectionSlice(e,t,i,s){let r=new Uint8Array(e,t,i),a=this.section_slice_queues_[s.pid];if(s.payload_unit_start_indicator){let o=r[0];if(null!=a&&0!==a.total_length){let r=new Uint8Array(e,t+1,Math.min(i,o));a.slices.push(r),a.total_length+=r.byteLength,a.total_length===a.expected_length?this.emitSectionSlices(a,s):this.clearSlices(a,s)}for(let n=1+o;n<r.byteLength;){if(255===r[n+0])break;let o=(15&r[n+1])<<8|r[n+2];this.section_slice_queues_[s.pid]=new Vd,a=this.section_slice_queues_[s.pid],a.expected_length=o+3,a.random_access_indicator=s.random_access_indicator;let l=new Uint8Array(e,t+n,Math.min(i-n,a.expected_length-a.total_length));a.slices.push(l),a.total_length+=l.byteLength,a.total_length===a.expected_length?this.emitSectionSlices(a,s):a.total_length>=a.expected_length&&this.clearSlices(a,s),n+=l.byteLength}}else if(null!=a&&0!==a.total_length){let r=new Uint8Array(e,t,Math.min(i,a.expected_length-a.total_length));a.slices.push(r),a.total_length+=r.byteLength,a.total_length===a.expected_length?this.emitSectionSlices(a,s):a.total_length>=a.expected_length&&this.clearSlices(a,s)}}handlePESSlice(e,t,i,s){let r=new Uint8Array(e,t,i),a=r[0]<<16|r[1]<<8|r[2];r[3];let o=r[4]<<8|r[5];if(s.payload_unit_start_indicator){if(1!==a)return void this.player.debug.warn(this.TAG_NAME,`handlePESSlice: packet_start_code_prefix should be 1 but with value ${a}`);let e=this.pes_slice_queues_[s.pid];e&&(0===e.expected_length||e.expected_length===e.total_length?this.emitPESSlices(e,s):this.clearSlices(e,s)),this.pes_slice_queues_[s.pid]=new Vd,this.pes_slice_queues_[s.pid].random_access_indicator=s.random_access_indicator}if(null==this.pes_slice_queues_[s.pid])return;let n=this.pes_slice_queues_[s.pid];n.slices.push(r),s.payload_unit_start_indicator&&(n.expected_length=0===o?0:o+6),n.total_length+=r.byteLength,n.expected_length>0&&n.expected_length===n.total_length?this.emitPESSlices(n,s):n.expected_length>0&&n.expected_length<n.total_length&&this.clearSlices(n,s)}emitSectionSlices(e,t){let i=new Uint8Array(e.total_length);for(let t=0,s=0;t<e.slices.length;t++){let r=e.slices[t];i.set(r,s),s+=r.byteLength}e.slices=[],e.expected_length=-1,e.total_length=0;let s={};s.pid=t.pid,s.data=i,s.file_position=e.file_position,s.random_access_indicator=e.random_access_indicator,this.parseSection(s)}emitPESSlices(e,t){let i=new Uint8Array(e.total_length);for(let t=0,s=0;t<e.slices.length;t++){let r=e.slices[t];i.set(r,s),s+=r.byteLength}e.slices=[],e.expected_length=-1,e.total_length=0;let s=new Wd;s.pid=t.pid,s.data=i,s.stream_type=t.stream_type,s.random_access_indicator=e.random_access_indicator,this.parsePES(s)}clearSlices(e){e.slices=[],e.expected_length=-1,e.total_length=0}parseSection(e){let t=e.data,i=e.pid;0===i?this.parsePAT(t):i===this.current_pmt_pid_?this.parsePMT(t):null!=this.pmt_&&this.pmt_.scte_35_pids[i]&&this.parseSCTE35(t)}parsePES(e){let t=e.data,i=t[0]<<16|t[1]<<8|t[2],s=t[3],r=t[4]<<8|t[5];if(1===i){if(188!==s&&190!==s&&191!==s&&240!==s&&241!==s&&255!==s&&242!==s&&248!==s){t[6];let i,a,o=(192&t[7])>>>6,n=t[8];2!==o&&3!==o||(i=536870912*(14&t[9])+4194304*(255&t[10])+16384*(254&t[11])+128*(255&t[12])+(254&t[13])/2,a=3===o?536870912*(14&t[14])+4194304*(255&t[15])+16384*(254&t[16])+128*(255&t[17])+(254&t[18])/2:i);let l,d=9+n;if(0!==r){if(r<3+n)return void this.player.debug.warn(this.TAG_NAME,"Malformed PES: PES_packet_length < 3 + PES_header_data_length");l=r-3-n}else l=t.byteLength-d;let h=t.subarray(d,d+l);switch(e.stream_type){case Id:case Md:this.parseMP3Payload(h,i);break;case Ud:this.pmt_.common_pids.opus===e.pid?this.parseOpusPayload(h,i):this.pmt_.common_pids.ac3===e.pid?this.parseAC3Payload(h,i):this.pmt_.common_pids.eac3===e.pid?this.parseEAC3Payload(h,i):this.pmt_.asynchronous_klv_pids[e.pid]?this.parseAsynchronousKLVMetadataPayload(h,e.pid,s):this.pmt_.smpte2038_pids[e.pid]?this.parseSMPTE2038MetadataPayload(h,i,a,e.pid,s):this.parsePESPrivateDataPayload(h,i,a,e.pid,s);break;case Fd:this.parseADTSAACPayload(h,i);break;case Od:this.parseLOASAACPayload(h,i);break;case Nd:this.parseAC3Payload(h,i);break;case jd:this.parseEAC3Payload(h,i);break;case zd:this.pmt_.timed_id3_pids[e.pid]?this.parseTimedID3MetadataPayload(h,i,a,e.pid,s):this.pmt_.synchronous_klv_pids[e.pid]&&this.parseSynchronousKLVMetadataPayload(h,i,a,e.pid,s);break;case Hd:this.parseH264Payload(h,i,a,e.random_access_indicator);break;case $d:this.parseH265Payload(h,i,a,e.random_access_indicator)}}else if((188===s||191===s||240===s||241===s||255===s||242===s||248===s)&&e.stream_type===Ud){let i,a=6;i=0!==r?r:t.byteLength-a;let o=t.subarray(a,a+i);this.parsePESPrivateDataPayload(o,void 0,void 0,e.pid,s)}}else this.player.debug.error(this.TAG_NAME,`parsePES: packet_start_code_prefix should be 1 but with value ${i}`)}parsePAT(e){let t=e[0];if(0!==t)return void Log.e(this.TAG,`parsePAT: table_id ${t} is not corresponded to PAT!`);let i=(15&e[1])<<8|e[2];e[3],e[4];let s=(62&e[5])>>>1,r=1&e[5],a=e[6];e[7];let o=null;if(1===r&&0===a)o={version_number:0,network_pid:0,program_pmt_pid:{}},o.version_number=s;else if(o=this.pat_,null==o)return;let n=i-5-4,l=-1,d=-1;for(let t=8;t<8+n;t+=4){let i=e[t]<<8|e[t+1],s=(31&e[t+2])<<8|e[t+3];0===i?o.network_pid=s:(o.program_pmt_pid[i]=s,-1===l&&(l=i),-1===d&&(d=s))}1===r&&0===a&&(null==this.pat_&&this.player.debug.log(this.TAG_NAME,`Parsed first PAT: ${JSON.stringify(o)}`),this.pat_=o,this.current_program_=l,this.current_pmt_pid_=d)}parsePMT(e){let t=e[0];if(2!==t)return void this.player.debug.error(this.TAG_NAME,`parsePMT: table_id ${t} is not corresponded to PMT!`);let i,s=(15&e[1])<<8|e[2],r=e[3]<<8|e[4],a=(62&e[5])>>>1,o=1&e[5],n=e[6];if(e[7],1===o&&0===n)i=this._initPmt(),i.program_number=r,i.version_number=a,this.program_pmt_map_[r]=i;else if(i=this.program_pmt_map_[r],null==i)return;i.pcr_pid=(31&e[8])<<8|e[9];let l=(15&e[10])<<8|e[11],d=12+l,h=s-9-l-4;for(let t=d;t<d+h;){let s=e[t],r=(31&e[t+1])<<8|e[t+2],a=(15&e[t+3])<<8|e[t+4];i.pid_stream_type[r]=s;let o=i.common_pids.h264||i.common_pids.h265,n=i.common_pids.adts_aac||i.common_pids.loas_aac||i.common_pids.ac3||i.common_pids.eac3||i.common_pids.opus||i.common_pids.mp3;if(s!==Hd||o)if(s!==$d||o)if(s!==Fd||n)if(s!==Od||n)if(s!==Nd||n)if(s!==jd||n)if(s!==Id&&s!==Md||n)if(s===Ud){if(i.pes_private_data_pids[r]=!0,a>0){for(let s=t+5;s<t+5+a;){let t=e[s+0],a=e[s+1];if(5===t){let t=String.fromCharCode(...Array.from(e.subarray(s+2,s+2+a)));"VANC"===t?i.smpte2038_pids[r]=!0:"Opus"===t?i.common_pids.opus=r:"KLVA"===t&&(i.asynchronous_klv_pids[r]=!0)}else if(127===t&&r===i.common_pids.opus){let t=null;if(128===e[s+2]&&(t=e[s+3]),null==t){Log.e(this.TAG,"Not Supported Opus channel count.");continue}const i={codec:"opus",channel_count:15&t?15&t:2,channel_config_code:t,sample_rate:48e3},r={codec:"opus",meta:i};0==this.audio_init_segment_dispatched_?(this.audio_metadata_=i,this.dispatchAudioInitSegment(r)):this.detectAudioMetadataChange(r)&&(this.dispatchAudioMediaSegment(),this.dispatchAudioInitSegment(r))}s+=2+a}let o=e.subarray(t+5,t+5+a);this.dispatchPESPrivateDataDescriptor(r,s,o)}}else if(s===zd){if(a>0)for(let s=t+5;s<t+5+a;){let t=e[s+0],a=e[s+1];if(38===t){let t=e[s+2]<<8|e[s+3],a=null;65535===t&&(a=String.fromCharCode(...Array.from(e.subarray(s+4,s+4+4))));let o=null;if(255===e[s+4+(65535===t?4:0)]){let i=4+(65535===t?4:0)+1;o=String.fromCharCode(...Array.from(e.subarray(s+i,s+i+4)))}"ID3 "===a&&"ID3 "===o?i.timed_id3_pids[r]=!0:"KLVA"===o&&(i.synchronous_klv_pids[r]=!0)}s+=2+a}}else s===Gd&&(i.scte_35_pids[r]=!0);else i.common_pids.mp3=r;else i.common_pids.eac3=r;else i.common_pids.ac3=r;else i.common_pids.loas_aac=r;else i.common_pids.adts_aac=r;else i.common_pids.h265=r;else i.common_pids.h264=r;t+=5+a}r===this.current_program_&&(null==this.pmt_&&this.player.debug.log(this.TAG_NAME,`Parsed first PMT: ${JSON.stringify(i)}`),this.pmt_=i,(i.common_pids.h264||i.common_pids.h265)&&(this.has_video_=!0),(i.common_pids.adts_aac||i.common_pids.loas_aac||i.common_pids.ac3||i.common_pids.opus||i.common_pids.mp3)&&(this.has_audio_=!0))}parseSCTE35(e){}parseH264Payload(e,t,i,s){let r=new Sn(e),a=null,o=null,n=[],l=0,d=!1;for(;null!=(a=r.readNextNaluPayload());){let e=new wn(a);if(e.type===Ct.kSliceSPS){let t=pn.parseSPS$2(a.data);this.video_init_segment_dispatched_?!0===this.detectVideoMetadataChange(e,t)&&(this.player.debug.log(this.TAG_NAME,"H264: Critical h264 metadata has been changed, attempt to re-generate InitSegment"),this.video_metadata_changed_=!0,this.video_metadata_={vps:void 0,sps:e,pps:void 0,details:t}):(this.video_metadata_.sps=e,this.video_metadata_.details=t)}else e.type===Ct.kSlicePPS?this.video_init_segment_dispatched_&&!this.video_metadata_changed_||(this.video_metadata_.pps=e,this.video_metadata_.sps&&this.video_metadata_.pps&&(this.video_metadata_changed_&&this.dispatchVideoMediaSegment(),this.dispatchVideoInitSegment())):(e.type===Ct.kSliceIDR||e.type===Ct.kSliceNonIDR&&1===s)&&(d=!0);this.video_init_segment_dispatched_&&(n.push(e),l+=e.data.byteLength)}let h=Math.floor(t/this.timescale_),c=Math.floor(i/this.timescale_);if(n.length){let e=this.video_track_;for(let e=0;e<n.length;e++){let t=n[e];if(null==o)o=t.data;else{let e=new Uint8Array(o.byteLength+t.data.byteLength);e.set(o,0),e.set(t.data,o.byteLength),o=e}}let t={length:l,isIFrame:d,dts:c,pts:h,cts:h-c,payload:o,type:je,isHevc:!1};e.samples.push(t),e.length=o.byteLength}}parseH265Payload(e,t,i,s){let r=new Mn(e),a=null,o=null,n=[],l=0,d=!1;for(;null!=(a=r.readNextNaluPayload());){let e=new Un(a);if(e.type===Pt){if(!this.video_init_segment_dispatched_){let t=kn.parseVPS(a.data);this.video_metadata_.vps=e,this.video_metadata_.details={...this.video_metadata_.details,...t}}}else if(e.type===It){let t=kn.parseSPS(a.data);this.video_init_segment_dispatched_?!0===this.detectVideoMetadataChange(e,t)&&(this.player.debug.log(this.TAG_NAME,"H265: Critical h265 metadata has been changed, attempt to re-generate InitSegment"),this.video_metadata_changed_=!0,this.video_metadata_={vps:void 0,sps:e,pps:void 0,details:t}):(this.video_metadata_.sps=e,this.video_metadata_.details={...this.video_metadata_.details,...t})}else if(e.type===Ut){if(!this.video_init_segment_dispatched_||this.video_metadata_changed_){let t=kn.parsePPS(a.data);this.video_metadata_.pps=e,this.video_metadata_.details={...this.video_metadata_.details,...t},this.video_metadata_.vps&&this.video_metadata_.sps&&this.video_metadata_.pps&&(this.video_metadata_changed_&&this.dispatchVideoMediaSegment(),this.dispatchVideoInitSegment())}}else e.type!==Rt&&e.type!==xt&&e.type!==Dt||(d=!0);this.video_init_segment_dispatched_&&(n.push(e),l+=e.data.byteLength)}let h=Math.floor(t/this.timescale_),c=Math.floor(i/this.timescale_);if(n.length){let e=this.video_track_;for(let e=0;e<n.length;e++){let t=n[e];if(null==o)o=t.data;else{let e=new Uint8Array(o.byteLength+t.data.byteLength);e.set(o,0),e.set(t.data,o.byteLength),o=e}}let t={type:je,length:l,isIFrame:d,dts:c,pts:h,cts:h-c,payload:o,isHevc:!0};e.samples.push(t),e.length=o.byteLength}}detectVideoMetadataChange(e,t){if(t.codec_mimetype!==this.video_metadata_.details.codec_mimetype)return this.player.debug.log(this.TAG_NAME,`Video: Codec mimeType changed from ${this.video_metadata_.details.codec_mimetype} to ${t.codec_mimetype}`),!0;if(t.codec_size.width!==this.video_metadata_.details.codec_size.width||t.codec_size.height!==this.video_metadata_.details.codec_size.height){let e=this.video_metadata_.details.codec_size,i=t.codec_size;return this.player.debug.log(this.TAG_NAME,`Video: Coded Resolution changed from ${e.width}x${e.height} to ${i.width}x${i.height}`),!0}return t.present_size.width!==this.video_metadata_.details.present_size.width&&(this.player.debug.log(this.TAG_NAME,`Video: Present resolution width changed from ${this.video_metadata_.details.present_size.width} to ${t.present_size.width}`),!0)}isInitSegmentDispatched(){return this.has_video_&&this.has_audio_?this.video_init_segment_dispatched_&&this.audio_init_segment_dispatched_:this.has_video_&&!this.has_audio_?this.video_init_segment_dispatched_:!(this.has_video_||!this.has_audio_)&&this.audio_init_segment_dispatched_}dispatchVideoInitSegment(){let e=this.video_metadata_.details,t={type:"video"};t.id=this.video_track_.id,t.timescale=1e3,t.duration=this.duration_,t.codecWidth=e.codec_size.width,t.codecHeight=e.codec_size.height,t.presentWidth=e.present_size.width,t.presentHeight=e.present_size.height,t.profile=e.profile_string,t.level=e.level_string,t.bitDepth=e.bit_depth,t.chromaFormat=e.chroma_format,t.sarRatio=e.sar_ratio,t.frameRate=e.frame_rate;let i=t.frameRate.fps_den,s=t.frameRate.fps_num;t.refSampleDuration=i/s*1e3,t.codec=e.codec_mimetype;let r=!1;if(this.video_metadata_.vps){r=!0;let e=this.video_metadata_.vps.data.subarray(4),i=this.video_metadata_.sps.data.subarray(4),s=this.video_metadata_.pps.data.subarray(4);t.hvcc=Dn({vps:e,sps:i,pps:s}),0==this.video_init_segment_dispatched_&&this.player.debug.log(this.TAG_NAME,`Generated first HEVCDecoderConfigurationRecord for mimeType: ${t.codec}`),t.hvcc&&this._doDecodeByTs(t.hvcc,je,0,!0,0)}else{let e=this.video_metadata_.sps.data.subarray(4),i=this.video_metadata_.pps.data.subarray(4);t.avcc=gn({sps:e,pps:i}),0==this.video_init_segment_dispatched_&&this.player.debug.log(this.TAG_NAME,`Generated first AVCDecoderConfigurationRecord for mimeType: ${t.codec}`),t.avcc&&this._doDecodeByTs(t.avcc,je,0,!0,0)}this.video_init_segment_dispatched_=!0,this.video_metadata_changed_=!1;let a=this.media_info_;a.hasVideo=!0,a.width=t.codecWidth,a.height=t.codecHeight,a.fps=t.frameRate.fps,a.profile=t.profile,a.level=t.level,a.refFrames=e.ref_frames,a.chromaFormat=e.chroma_format_string,a.sarNum=t.sarRatio.width,a.sarDen=t.sarRatio.height,a.videoCodec=t.codec,a.hasAudio&&a.audioCodec?a.mimeType=`video/mp2t; codecs="${a.videoCodec},${a.audioCodec}"`:a.mimeType=`video/mp2t; codecs="${a.videoCodec}"`,this.player.video.updateVideoInfo({width:t.codecWidth,height:t.codecHeight,encTypeCode:r?vt:_t})}dispatchVideoMediaSegment(){this.isInitSegmentDispatched()&&this.video_track_.length&&this._preDoDecode()}dispatchAudioMediaSegment(){this.isInitSegmentDispatched()&&this.audio_track_.length&&this._preDoDecode()}dispatchAudioVideoMediaSegment(){this.isInitSegmentDispatched()&&(this.audio_track_.length||this.video_track_.length)&&this._preDoDecode()}parseADTSAACPayload(e,t){if(this.has_video_&&!this.video_init_segment_dispatched_)return;if(this.aac_last_incomplete_data_){let t=new Uint8Array(e.byteLength+this.aac_last_incomplete_data_.byteLength);t.set(this.aac_last_incomplete_data_,0),t.set(e,this.aac_last_incomplete_data_.byteLength),e=t}let i,s;if(null!=t&&(s=t/this.timescale_),"aac"===this.audio_metadata_.codec){if(null==t&&null!=this.audio_last_sample_pts_)i=1024/this.audio_metadata_.sampling_frequency*1e3,s=this.audio_last_sample_pts_+i;else if(null==t)return void this.player.debug.warn(this.TAG_NAME,"AAC: Unknown pts");if(this.aac_last_incomplete_data_&&this.audio_last_sample_pts_){i=1024/this.audio_metadata_.sampling_frequency*1e3;let e=this.audio_last_sample_pts_+i;Math.abs(e-s)>1&&(this.player.debug.warn(this.TAG_NAME,`AAC: Detected pts overlapped, expected: ${e}ms, PES pts: ${s}ms`),s=e)}}let r,a=new Hr(e),o=null,n=s;for(;null!=(o=a.readNextAACFrame());){i=1024/o.sampling_frequency*1e3;const e={codec:"aac",data:o};0==this.audio_init_segment_dispatched_?(this.audio_metadata_={codec:"aac",audio_object_type:o.audio_object_type,sampling_freq_index:o.sampling_freq_index,sampling_frequency:o.sampling_frequency,channel_config:o.channel_config},this.dispatchAudioInitSegment(e)):this.detectAudioMetadataChange(e)&&(this.dispatchAudioMediaSegment(),this.dispatchAudioInitSegment(e)),r=n;let t=Math.floor(n);const s=new Uint8Array(o.data.length+2);s.set([175,1],0),s.set(o.data,2);let a={payload:s,length:s.byteLength,pts:t,dts:t,type:Ne};this.audio_track_.samples.push(a),this.audio_track_.length+=s.byteLength,n+=i}a.hasIncompleteData()&&(this.aac_last_incomplete_data_=a.getIncompleteData()),r&&(this.audio_last_sample_pts_=r)}parseLOASAACPayload(e,t){if(this.has_video_&&!this.video_init_segment_dispatched_)return;if(this.aac_last_incomplete_data_){let t=new Uint8Array(e.byteLength+this.aac_last_incomplete_data_.byteLength);t.set(this.aac_last_incomplete_data_,0),t.set(e,this.aac_last_incomplete_data_.byteLength),e=t}let i,s;if(null!=t&&(s=t/this.timescale_),"aac"===this.audio_metadata_.codec){if(null==t&&null!=this.audio_last_sample_pts_)i=1024/this.audio_metadata_.sampling_frequency*1e3,s=this.audio_last_sample_pts_+i;else if(null==t)return void this.player.debug.warn(this.TAG_NAME,"AAC: Unknown pts");if(this.aac_last_incomplete_data_&&this.audio_last_sample_pts_){i=1024/this.audio_metadata_.sampling_frequency*1e3;let e=this.audio_last_sample_pts_+i;Math.abs(e-s)>1&&(this.player.debug.warn(this.TAG,`AAC: Detected pts overlapped, expected: ${e}ms, PES pts: ${s}ms`),s=e)}}let r,a=new $r(e),o=null,n=s;for(;null!=(o=a.readNextAACFrame(wa(this.loas_previous_frame)?void 0:this.loas_previous_frame));){this.loas_previous_frame=o,i=1024/o.sampling_frequency*1e3;const e={codec:"aac",data:o};0==this.audio_init_segment_dispatched_?(this.audio_metadata_={codec:"aac",audio_object_type:o.audio_object_type,sampling_freq_index:o.sampling_freq_index,sampling_frequency:o.sampling_frequency,channel_config:o.channel_config},this.dispatchAudioInitSegment(e)):this.detectAudioMetadataChange(e)&&(this.dispatchAudioMediaSegment(),this.dispatchAudioInitSegment(e)),r=n;let t=Math.floor(n);const s=new Uint8Array(o.data.length+2);s.set([175,1],0),s.set(o.data,2);let a={payload:s,length:s.byteLength,pts:t,dts:t,type:Ne};this.audio_track_.samples.push(a),this.audio_track_.length+=s.byteLength,n+=i}a.hasIncompleteData()&&(this.aac_last_incomplete_data_=a.getIncompleteData()),r&&(this.audio_last_sample_pts_=r)}parseAC3Payload(e,t){}parseEAC3Payload(e,t){}parseOpusPayload(e,t){}parseMP3Payload(e,t){if(this.has_video_&&!this.video_init_segment_dispatched_)return;let i=[44100,48e3,32e3,0],s=[22050,24e3,16e3,0],r=[11025,12e3,8e3,0],a=e[1]>>>3&3,o=(6&e[1])>>1;e[2];let n=(12&e[2])>>>2,l=3!==(e[3]>>>6&3)?2:1,d=0,h=34;switch(a){case 0:d=r[n];break;case 2:d=s[n];break;case 3:d=i[n]}switch(o){case 1:h=34;break;case 2:h=33;break;case 3:h=32}const c={};c.object_type=h,c.sample_rate=d,c.channel_count=l,c.data=e;const u={codec:"mp3",data:c};0==this.audio_init_segment_dispatched_?(this.audio_metadata_={codec:"mp3",object_type:h,sample_rate:d,channel_count:l},this.dispatchAudioInitSegment(u)):this.detectAudioMetadataChange(u)&&(this.dispatchAudioMediaSegment(),this.dispatchAudioInitSegment(u));let p={payload:e,length:e.byteLength,pts:t/this.timescale_,dts:t/this.timescale_,type:Ne};this.audio_track_.samples.push(p),this.audio_track_.length+=e.byteLength}detectAudioMetadataChange(e){if(e.codec!==this.audio_metadata_.codec)return this.player.debug.log(this.TAG_NAME,`Audio: Audio Codecs changed from ${this.audio_metadata_.codec} to ${e.codec}`),!0;if("aac"===e.codec&&"aac"===this.audio_metadata_.codec){const t=e.data;if(t.audio_object_type!==this.audio_metadata_.audio_object_type)return this.player.debug.log(this.TAG_NAME,`AAC: AudioObjectType changed from ${this.audio_metadata_.audio_object_type} to ${t.audio_object_type}`),!0;if(t.sampling_freq_index!==this.audio_metadata_.sampling_freq_index)return this.player.debug.log(this.TAG_NAME,`AAC: SamplingFrequencyIndex changed from ${this.audio_metadata_.sampling_freq_index} to ${t.sampling_freq_index}`),!0;if(t.channel_config!==this.audio_metadata_.channel_config)return this.player.debug.log(this.TAG_NAME,`AAC: Channel configuration changed from ${this.audio_metadata_.channel_config} to ${t.channel_config}`),!0}else if("ac-3"===e.codec&&"ac-3"===this.audio_metadata_.codec){const t=e.data;if(t.sampling_frequency!==this.audio_metadata_.sampling_frequency)return this.player.debug.log(this.TAG_NAME,`AC3: Sampling Frequency changed from ${this.audio_metadata_.sampling_frequency} to ${t.sampling_frequency}`),!0;if(t.bit_stream_identification!==this.audio_metadata_.bit_stream_identification)return this.player.debug.log(this.TAG_NAME,`AC3: Bit Stream Identification changed from ${this.audio_metadata_.bit_stream_identification} to ${t.bit_stream_identification}`),!0;if(t.bit_stream_mode!==this.audio_metadata_.bit_stream_mode)return this.player.debug.log(this.TAG_NAME,`AC3: BitStream Mode changed from ${this.audio_metadata_.bit_stream_mode} to ${t.bit_stream_mode}`),!0;if(t.channel_mode!==this.audio_metadata_.channel_mode)return this.player.debug.log(this.TAG_NAME,`AC3: Channel Mode changed from ${this.audio_metadata_.channel_mode} to ${t.channel_mode}`),!0;if(t.low_frequency_effects_channel_on!==this.audio_metadata_.low_frequency_effects_channel_on)return this.player.debug.log(this.TAG_NAME,`AC3: Low Frequency Effects Channel On changed from ${this.audio_metadata_.low_frequency_effects_channel_on} to ${t.low_frequency_effects_channel_on}`),!0}else if("opus"===e.codec&&"opus"===this.audio_metadata_.codec){const t=e.meta;if(t.sample_rate!==this.audio_metadata_.sample_rate)return this.player.debug.log(this.TAG_NAME,`Opus: SamplingFrequencyIndex changed from ${this.audio_metadata_.sample_rate} to ${t.sample_rate}`),!0;if(t.channel_count!==this.audio_metadata_.channel_count)return this.player.debug.log(this.TAG_NAME,`Opus: Channel count changed from ${this.audio_metadata_.channel_count} to ${t.channel_count}`),!0}else if("mp3"===e.codec&&"mp3"===this.audio_metadata_.codec){const t=e.data;if(t.object_type!==this.audio_metadata_.object_type)return this.player.debug.log(this.TAG_NAME,`MP3: AudioObjectType changed from ${this.audio_metadata_.object_type} to ${t.object_type}`),!0;if(t.sample_rate!==this.audio_metadata_.sample_rate)return this.player.debug.log(this.TAG_NAME,`MP3: SamplingFrequencyIndex changed from ${this.audio_metadata_.sample_rate} to ${t.sample_rate}`),!0;if(t.channel_count!==this.audio_metadata_.channel_count)return this.player.debug.log(this.TAG_NAME,`MP3: Channel count changed from ${this.audio_metadata_.channel_count} to ${t.channel_count}`),!0}return!1}dispatchAudioInitSegment(e){let t={type:"audio"};t.id=this.audio_track_.id,t.timescale=1e3,t.duration=this.duration_;let i="";if("aac"===this.audio_metadata_.codec){let s="aac"===e.codec?e.data:null,r=new Yd(s);t.audioSampleRate=r.sampling_rate,t.audioSampleRateIndex=r.sampling_index,t.channelCount=r.channel_count,t.codec=r.codec_mimetype,t.originalCodec=r.original_codec_mimetype,t.config=r.config,t.refSampleDuration=1024/t.audioSampleRate*t.timescale,i=Et.AAC;const a=Pr({profile:this.player._opt.mseDecodeAudio?r.object_type:r.original_object_type,sampleRate:t.audioSampleRateIndex,channel:t.channelCount});console.error("aacADTSHeader",`profile: ${r.object_type}, sampleRate: ${t.audioSampleRateIndex}, channel: ${t.channelCount}`),this._doDecodeByTs(a,Ne,0,!1,0)}else"ac-3"===this.audio_metadata_.codec||"ec-3"===this.audio_metadata_.codec||"opus"===this.audio_metadata_.codec||"mp3"===this.audio_metadata_.codec&&(t.audioSampleRate=this.audio_metadata_.sample_rate,t.channelCount=this.audio_metadata_.channel_count,t.codec="mp3",t.originalCodec="mp3",t.config=void 0,i=Et.MP3);0==this.audio_init_segment_dispatched_&&this.player.debug.log(this.TAG_NAME,`Generated first AudioSpecificConfig for mimeType: ${t.codec}`),this.audio_init_segment_dispatched_=!0,this.video_metadata_changed_=!1;let s=this.media_info_;s.hasAudio=!0,s.audioCodec=t.originalCodec,s.audioSampleRate=t.audioSampleRate,s.audioChannelCount=t.channelCount,s.hasVideo&&s.videoCodec?s.mimeType=`video/mp2t; codecs="${s.videoCodec},${s.audioCodec}"`:s.mimeType=`video/mp2t; codecs="${s.audioCodec}"`,i&&this.player.audio.updateAudioInfo({encTypeCode:i,channels:t.channelCount,sampleRate:t.audioSampleRate})}dispatchPESPrivateDataDescriptor(e,t,i){}parsePESPrivateDataPayload(e,t,i,s,r){let a=new Jd;if(a.pid=s,a.stream_id=r,a.len=e.byteLength,a.data=e,null!=t){let e=Math.floor(t/this.timescale_);a.pts=e}else a.nearest_pts=this.getNearestTimestampMilliseconds();if(null!=i){let e=Math.floor(i/this.timescale_);a.dts=e}}parseTimedID3MetadataPayload(e,t,i,s,r){this.player.debug.log(this.TAG_NAME,`Timed ID3 Metadata: pid=${s}, pts=${t}, dts=${i}, stream_id=${r}`)}parseSynchronousKLVMetadataPayload(e,t,i,s,r){this.player.debug.log(this.TAG_NAME,`Synchronous KLV Metadata: pid=${s}, pts=${t}, dts=${i}, stream_id=${r}`)}parseAsynchronousKLVMetadataPayload(e,t,i){this.player.debug.log(this.TAG_NAME,`Asynchronous KLV Metadata: pid=${t}, stream_id=${i}`)}parseSMPTE2038MetadataPayload(e,t,i,s,r){this.player.debug.log(this.TAG_NAME,`SMPTE 2038 Metadata: pid=${s}, pts=${t}, dts=${i}, stream_id=${r}`)}getNearestTimestampMilliseconds(){if(null!=this.audio_last_sample_pts_)return Math.floor(this.audio_last_sample_pts_);if(null!=this.last_pcr_){return Math.floor(this.last_pcr_/300/this.timescale_)}}_preDoDecode(){const e=this.video_track_,t=this.audio_track_;let i=e.samples;t.samples.length>0&&(i=e.samples.concat(t.samples),i=i.sort(((e,t)=>e.dts-t.dts))),i.forEach((e=>{const t=new Uint8Array(e.payload);delete e.payload,e.type===je?this._doDecodeVideo({...e,payload:t}):e.type===Ne&&this._doDecodeAudio({...e,payload:t})})),e.samples=[],e.length=0,t.samples=[],t.length=0}_doDecodeVideo(e){const t=new Uint8Array(e.payload);let i=null;i=e.isHevc?Ln(t,e.isIFrame):yn(t,e.isIFrame),this.player.updateStats({dts:e.dts,vbps:i.byteLength}),e.isIFrame&&this.calcIframeIntervalTimestamp(e.dts);let s=this.cryptoPayload(i,e.isIFrame);this._doDecodeByTs(s,je,e.dts,e.isIFrame,e.cts)}_doDecodeAudio(e){const t=new Uint8Array(e.payload);this.player.updateStats({abps:t.byteLength});let i=t;so(this.player._opt.m7sCryptoAudio)&&(i=this.cryptoPayloadAudio(t)),this._doDecodeByTs(i,Ne,e.dts,!1,0)}getInputByteLength(){return this._remainingPacketData&&this._remainingPacketData.byteLength||0}}class Xd{constructor(e){return new(Xd.getLoaderFactory(e))(e)}static getLoaderFactory(e){const t=e._opt.demuxType;return t===k?wd:t===T||e.isWebrtcH265()?Sd:t===x?Ed:t===D?Td:t===L?Ld:t===P?Pd:t===I?Qd:kd}}class Zd extends po{constructor(e){super(),this.player=e,this.TAG_NAME="Webcodecs",this.hasInit=!1,this.isDecodeFirstIIframe=!!ro(e._opt.checkFirstIFrame),this.isInitInfo=!1,this.prevTimestamp=null,this.decodeDiffTimestamp=null,this.prevDts=null,this.decoder=null,this.isWidthOrHeightChanged=!1,this.initDecoder(),e.debug.log(this.TAG_NAME,"init")}destroy(){this.decoder&&(ro(this.isDecodeStateClosed())&&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(this.TAG_NAME,"destroy")}initDecoder(){const e=this;this.decoder=new VideoDecoder({output(t){e.handleDecode(t)},error(t){e.handleError(t)}})}handleDecode(e){this.isInitInfo||(this.player.video.updateVideoInfo({width:e.codedWidth,height:e.codedHeight}),this.player.video.initCanvasViewSize(),this.isInitInfo=!0),this.player.isPlayer()?(this.player.updateStats({dfps:!0}),this.player._times.videoStart||(this.player._times.videoStart=Qr(),this.player.handlePlayToRenderTimes()),this.player.video.render({videoFrame:e,ts:e.timestamp}),this.player.handleRender()):this.player.isPlayback()&&(this.player.updateStats({dfps:!0}),ro(this.player.playbackPause)?(this.player.playback.isUseLocalCalculateTime&&this.player.playback.increaseLocalTimestamp(),this.player.playback.isUseFpsRender?this.player.video.pushData({videoFrame:e,ts:e.timestamp}):this.player.video.render$2({videoFrame:e,ts:e.timestamp})):ro(this.player.playback.isPlaybackPauseClearCache)&&this.player.playback.isCacheBeforeDecodeForFpsRender&&this.player.playback.isUseFpsRender&&this.player.video.pushData({videoFrame:e,ts:e.timestamp}))}handleError(e){this.player.debug.error(this.TAG_NAME,"VideoDecoder handleError:",e.code,e);const t=e.toString();-1!==t.indexOf(es)?this.player.emitError(ct.webcodecsUnsupportedConfigurationError,t):-1!==t.indexOf(ts)||-1!==t.indexOf(is)||-1!==t.indexOf(ss)?this.player.emitError(ct.webcodecsDecodeError,t):-1!==t.indexOf(rs)&&this.player.emitError(ct.webcodecsH265NotSupport)}decodeVideo(e,t,i,s){if(this.player)if(this.player.isDestroyedOrClosed())this.player.debug.warn(this.TAG_NAME,"decodeVideo() player is destroyed");else if(this.hasInit)if(!this.isDecodeFirstIIframe&&i&&(this.isDecodeFirstIIframe=!0),this.isDecodeFirstIIframe){if(this.isDecodeStateClosed())return void this.player.debug.warn(this.TAG_NAME,"VideoDecoder isDecodeStateClosed true");if(i&&0===e[1]){const t=15&e[0];let i={};if(t===_t){i=mn(e.slice(5))}else t===vt&&(i=Cn(e));const s=this.player.video.videoInfo;s&&s.width&&s.height&&i&&i.codecWidth&&i.codecHeight&&(i.codecWidth!==s.width||i.codecHeight!==s.height)&&(this.player.debug.warn(this.TAG_NAME,`decodeVideo: video width or height is changed,\n old width is ${s.width}, old height is ${s.height},\n new width is ${i.codecWidth}, new height is ${i.codecHeight},\n and emit change event`),this.isWidthOrHeightChanged=!0,this.player.emitError(ct.wcsWidthOrHeightChange))}if(this.isWidthOrHeightChanged)return void this.player.debug.warn(this.TAG_NAME,"decodeVideo: video width or height is changed, and return");if(io(e))return void this.player.debug.warn(this.TAG_NAME,"decodeVideo and payload is video sequence header so drop this frame");if(e.byteLength<12)return void this.player.debug.warn(this.TAG_NAME,`decodeVideo and payload is too small , payload length is ${e.byteLength}`);let s=!1,r=(new Date).getTime();this.prevTimestamp||(this.prevTimestamp=r,s=!0);const a=r-this.prevTimestamp;this.decodeDiffTimestamp=a,a>500&&!s&&this.player.isPlayer()&&this.player.debug.warn(this.TAG_NAME,"decodeVideo diff time is ",a);const o=e.slice(5),n=new EncodedVideoChunk({data:o,timestamp:t,type:i?Zt:ei});this.player.emit(nt.timeUpdate,t);try{this.decoder.decode(n)}catch(e){this.player.debug.error(this.TAG_NAME,"VideoDecoder",e);const t=e.toString();(-1!==t.indexOf(Xi)||-1!==t.indexOf(Zi))&&this.player.emitError(ct.webcodecsDecodeError)}this.prevTimestamp=(new Date).getTime()}else this.player.debug.log(this.TAG_NAME,"VideoDecoder first frame is not iFrame");else if(i&&e[1]===us){const t=15&e[0];if(this.player.video.updateVideoInfo({encTypeCode:t}),t===vt&&!ba()){const e=la();return this.player.debug.warn(this.TAG_NAME,"WebcodecsDecoder not support hevc decode",e.type,e.version),void this.player.emitError(ct.webcodecsH265NotSupport)}this.player._times.decodeStart||(this.player._times.decodeStart=Qr());let i=null,s=null;const r=e.slice(5);if(t===_t?(s=mn(r),i={codec:s.codec,description:r}):t===vt&&(s=Rn(r),i={codec:s.codec,description:r}),!i||i&&!i.codec)return this.player.debug.warn(this.TAG_NAME,"decodeVideo and webcodecs configure is",JSON.stringify(i)),void this.player.emitError(ct.webcodecsDecodeConfigureError);s&&s.codecWidth&&s.codecHeight&&(i.codedHeight=s.codecHeight,i.codedWidth=s.codecWidth),this.player.recorder&&this.player._opt.recordType===S&&this.player.recorder.initMetaData(e,t),this.player.debug.log(this.TAG_NAME,`decoder.configure() and codec is ${i.codec}`);try{this.decoder.configure(i),this.hasInit=!0}catch(e){this.player.debug.log(this.TAG_NAME,"configure error",e.code,e);-1!==e.toString().indexOf(rs)?this.player.emitError(ct.webcodecsH265NotSupport):this.player.emitError(ct.webcodecsDecodeConfigureError)}}}getDecodeDiffTimes(){return this.decodeDiffTimestamp}isDecodeStateClosed(){return"closed"===this.decoder.state}isDecodeStateConfigured(){return"configured"===this.decoder.state}isDecodeStateUnConfigured(){return"unconfigured"===this.decoder.state}}const eh={play:"播放",pause:"暂停",audio:"",mute:"",screenshot:"截图",loading:"",fullscreen:"全屏",fullscreenExit:"退出全屏",record:"录制",recordStop:"停止录制",narrow:"缩小",expand:"放大",ptz:"操作盘",ptzActive:"操作盘激活",zoom:"电子放大",zoomStop:"关闭电子放大",close:"关闭",performance:"性能面板",performanceActive:"性能面板激活",face:"人脸识别",faceActive:"人脸识别激活",object:"物品识别",objectActive:"物品识别激活",occlusion:"遮挡物检查",occlusionActive:"遮挡物检查激活",logSave:"保存日志"};var th=Object.keys(eh).reduce(((e,t)=>(e[t]=`\n <i class="jb-pro-icon jb-pro-icon-${t}"></i>\n ${eh[t]?`<span class="icon-title-tips"><span class="icon-title">${eh[t]}</span></span>`:""}\n`,e)),{});function ih(e,t){let i=!1;return e.forEach((e=>{i||e.startTimestamp<=t&&e.endTimestamp>t&&(i=!0)})),i}function sh(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],i=arguments.length>2?arguments[2]:void 0;const s=e.length,r=t.length,a=Math.max(s,r),o=hi,n=Math.ceil(a/o);let l=0,d=0;!function r(){let a="",h="";for(let i=0;i<o;i++){const i=e[d];i&&(a+=`\n <div class="jb-pro-playback-time-minute-one${i.hasRecord?" active":""}${i.isStart?" start":""}" data-has-record="${i.hasRecord}"\n data-time="${i.timestamp}" data-type="${i.dataType}">\n <span class="jb-pro-playback-time-title-tips ${d>s-60?"jb-pro-playback-time-title-tips-left":""}"><span class="jb-pro-playback-time-title">${i.title}</span></span>\n </div>\n `);const r=t[d];r&&(h+=`\n <div class="jb-pro-playback-time-hour" data-hour="${r.hour}" data-min="${r.min}" data-second="${r.second}"><span class="jb-pro-playback-time-hour-text">${r.title}</span></div>\n `),d+=1}a&&i.$playbackTimeListOne.insertAdjacentHTML("beforeend",a),h&&i.$playbackTimeListSecond.insertAdjacentHTML("beforeend",h),l+=1,l<n&&(i.rafId=window.requestAnimationFrame(r))}()}function rh(e,t){const i=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=[];const i=(e[0]||{}).startTimestamp;for(let s=0;s<1440;s++){const r=s%60==0;let a=!1;i&&(a=ih(e,Pa(i,s))),t.push({title:Da(s),timestamp:s,dataType:"min",hasRecord:a,isStart:r})}return t}(e);sh(i,function(){let e=[];for(let t=0;t<24;t++){let i=t+":00";t<10&&(i="0"+i),e.push({title:i,hour:t,min:0,second:0})}return e}(),t)}function ah(e,t){const i=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=[];const i=(e[0]||{}).startTimestamp;for(let s=0;s<1440;s++){let r=60*s,a=r%1800==0,o=!1;i&&(o=ih(e,Ba(i,r))),t.push({title:La(r),timestamp:r,dataType:"second",hasRecord:o,isStart:a});let n=60*s+30;a=n%1800==0,i&&(o=ih(e,Ba(i,n))),t.push({title:La(n),timestamp:n,dataType:"second",hasRecord:o,isStart:a})}return t}(e);sh(i,function(){let e=[];for(let t=0;t<24;t++){let i=t+":00",s=t+":30";t<10&&(i="0"+i,s="0"+s),e.push({title:i,hour:t,min:0,second:0}),e.push({title:s,hour:t,min:30,second:0})}return e}(),t)}function oh(e,t){const i=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=[];const i=(e[0]||{}).startTimestamp;for(let s=0;s<144;s++)for(let r=0;r<60;r++){let a=10*r+600*s,o=a%600==0,n=!1;i&&(n=ih(e,Ba(i,a))),t.push({title:La(a),timestamp:a,dataType:"second",isStart:o,hasRecord:n})}return t}(e);sh(i,function(){let e=[];for(let t=0;t<24;t++){let i=t+":00";t<10&&(i="0"+i),e.push({title:i,hour:t,min:0,second:0});for(let s=1;s<6;s++){let r=s+"0";e.push({title:i.replace(":00",":"+r),hour:t,min:10*s,second:0})}}return e}(),t)}function nh(e,t){const i=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=[];const i=(e[0]||{}).startTimestamp;for(let s=0;s<288;s++)for(let r=0;r<60;r++){let a=5*r+300*s,o=a%300==0,n=!1;i&&(n=ih(e,Ba(i,a))),t.push({title:La(a),timestamp:a,dataType:"second",isStart:o,hasRecord:n})}return t}(e);sh(i,function(){let e=[];for(let t=0;t<24;t++){let i=t+":00";t<10&&(i="0"+i),e.push({title:i,hour:t,min:0,second:0}),e.push({title:i.replace(":00",":05"),hour:t,min:5,second:0});for(let s=1;s<6;s++){let r=s+"0",a=s+"5";e.push({title:i.replace(":00",":"+r),hour:t,min:10*s,second:0}),e.push({title:i.replace(":00",":"+a),hour:t,min:10*s+5,second:0})}}return e}(),t)}function lh(e){const t=Math.floor(e/3600),i=Math.floor((e-3600*t)/60),s=Math.floor(e-3600*t-60*i);return(t>0?[t,i,s]:[i,s]).map((e=>e<10?`0${e}`:String(e))).join(":")}function dh(e,t,i){const s=e.$playbackProgress,{left:r}=s.getBoundingClientRect(),a=Xr((ra()?i.touches[0].clientX:i.pageX)-r,0,s.clientWidth),o=parseInt(a/s.clientWidth*t,10);return{second:o,time:lh(o),width:a,percentage:Xr(a/s.clientWidth,0,1)}}function hh(e,t){return e.classList.add(t)}function ch(e,t){return t instanceof Element?e.appendChild(t):e.insertAdjacentHTML("beforeend",String(t)),e.lastElementChild||e.lastChild}function uh(e,t,i){return e&&e.style&&Ta(t)&&(e.style[t]=i),e}function ph(e,t){return e.composedPath&&e.composedPath().indexOf(t)>-1}function fh(e){let t=!1;return e&&e.parentNode&&(e.parentNode.removeChild(e),t=!0),t}var mh=(e,t)=>{const{events:{proxy:i}}=e,s=document.createElement("object");s.setAttribute("aria-hidden","true"),s.setAttribute("tabindex",-1),s.type="text/html",s.data="about:blank",Zr(s,{display:"block",position:"absolute",top:"0",left:"0",height:"100%",width:"100%",overflow:"hidden",pointerEvents:"none",zIndex:"-1"});let r=e.width,a=e.height;const o=ma((()=>{e.width===r&&e.height===a||(r=e.width,a=e.height,e.emit(nt.resize),c())}),500);i(s,"load",(()=>{i(s.contentDocument.defaultView,"resize",(()=>{o()}))})),e.$container.appendChild(s),e.on(nt.destroy,(()=>{e.$container.removeChild(s)})),e.on(nt.volumechange,(()=>{!function(e){if(0===e)Zr(t.$volumeOn,"display","none"),Zr(t.$volumeOff,"display","flex"),Zr(t.$volumeHandle,"top","48px");else if(t.$volumeHandle&&t.$volumePanel){const i=ea(t.$volumePanel,"height")||60,s=ea(t.$volumeHandle,"height"),r=i-(i-s)*e-s;Zr(t.$volumeHandle,"top",`${r}px`),Zr(t.$volumeOn,"display","flex"),Zr(t.$volumeOff,"display","none")}t.$volumePanelText&&(t.$volumePanelText.innerHTML=parseInt(100*e))}(e.volume)})),e.on(nt.loading,(i=>{Zr(t.$loading,"display",i?"flex":"none"),(ro(e._opt.backgroundLoadingShow)&&so(i)||ro(i))&&Zr(t.$poster,"display","none"),i&&(Zr(t.$playBig,"display","none"),Zr(t.$tipsMessage,"display","none")),i||e._opt.extendDomConfig.showAfterLoading&&t.$extendDom&&Zr(t.$extendDom,"display","block"),i||e.getRenderType()===V&&ro(e._opt.useMSE)&&n()})),e.on(nt.removeLoadingBgImage,(()=>{n()}));const n=()=>{t.$loadingBgImage&&t.$loadingBg&&t.$loadingBgImage.src&&(e.debug&&e.debug.log("Control","remove loading bg image"),t.$loadingBgImage.width=0,t.$loadingBgImage.height=0,t.$loadingBgImage.src="",Zr(t.$loadingBg,"display","none"))},l=t=>{e.fullscreen?ja(t)===e.$container&&d():d()},d=i=>{let s=Ea(i)?i:e.fullscreen;Zr(t.$fullscreenExit,"display",s?"flex":"none"),Zr(t.$fullscreen,"display",s?"none":"flex")},h=()=>e._opt.playType===v&&e._opt.playbackConfig.showControl,c=i=>{ra()&&t.$controls&&e._opt.useWebFullScreen&&setTimeout((()=>{if(e.fullscreen){const i=h()?zt:jt;let s=e.height/2-e.width+i/2,r=e.height/2-i/2;if(t.$controls.style.transform=`translateX(${-s}px) translateY(-${r}px) rotate(-90deg)`,t.$zoomControls){const i=156,s=30,r=e.width/2+i/2-s/2;t.$zoomControls.style.transform=`translateX(${-r}px) translateY(${e.height/2}px) rotate(-90deg)`}if(t.$recording){const i=101,s=20,r=e.width/2+i/2-s/2;t.$recording.style.transform=`translateX(${-r}px) translateY(${e.height/2}px) rotate(-90deg)`}}else t.$controls.style.transform="translateX(0) translateY(0) rotate(0)",t.$zoomControls&&(t.$zoomControls.style.transform="translateX(-50%) translateY(0) rotate(0)"),t.$recording&&(t.$recording.style.transform="translateX(-50%) translateY(0) rotate(0)");i&&i()}),10)};try{Cr.on("change",l),e.events.destroys.push((()=>{Cr.off("change",l)}))}catch(e){}e.on(nt.webFullscreen,(e=>{ra()&&(d(e),c((()=>{p()})))})),e.on(nt.recording,(()=>{e.playing&&(Zr(t.$record,"display",e.recording?"none":"flex"),Zr(t.$recordStop,"display",e.recording?"flex":"none"),(e._opt.hasControl||e._opt.isShowRecordingUI)&&(Zr(t.$recording,"display",e.recording?"flex":"none"),ro(e.recording)&&t.$recordingTime&&(t.$recordingTime.innerHTML=xa(0))))})),e.on(nt.recordingTimestamp,(e=>{t.$recordingTime&&(t.$recordingTime.innerHTML=xa(e))})),e.on(nt.zooming,(()=>{e.playing&&(Zr(t.$zoom,"display",e.zooming?"none":"flex"),Zr(t.$zoomStop,"display",e.zooming?"flex":"none"),(e._opt.hasControl||e._opt.isShowZoomingUI)&&Zr(t.$zoomControls,"display",e.zooming?"flex":"none"))})),e.on(nt.playing,(e=>{u(e)}));const u=i=>{i||e.isPlayFailedAndPaused&&ro(e._opt.playFailedAndPausedShowPlayBtn)?(Zr(t.$play,"display","none"),Zr(t.$playBig,"display","none")):(Zr(t.$play,"display","flex"),Zr(t.$playBig,"display","block")),Zr(t.$pause,"display",i?"flex":"none"),Zr(t.$screenshot,"display",i?"flex":"none"),Zr(t.$record,"display",i?"flex":"none"),Zr(t.$qualityMenu,"display",i?"flex":"none"),Zr(t.$volume,"display",i?"flex":"none"),Zr(t.$ptz,"display",i?"flex":"none"),Zr(t.$zoom,"display",i?"flex":"none"),Zr(t.$scaleMenu,"display",i?"flex":"none"),Zr(t.$faceDetect,"display",i?"flex":"none"),Zr(t.$objectDetect,"display",i?"flex":"none"),Zr(t.$occlusionDetect,"display",i?"flex":"none"),Zr(t.$controlHtml,"display",i?"flex":"none"),e.isPlayback()&&Zr(t.$speedMenu,"display",i?"flex":"none"),d(),t.extendBtnList.forEach((e=>{e.$iconWrap&&Zr(e.$iconWrap,"display",i?"flex":"none"),e.$activeIconWrap&&Zr(e.$activeIconWrap,"display","none")})),e._opt.showPerformance?Zr(t.$performanceActive,"display",i?"flex":"none"):(Zr(t.$performance,"display",i?"flex":"none"),Zr(t.$performanceActive,"display","none")),Zr(t.$poster,"display","none"),Zr(t.$ptzActive,"display","none"),Zr(t.$recordStop,"display","none"),Zr(t.$zoomStop,"display","none"),Zr(t.$faceDetectActive,"display","none"),Zr(t.$objectDetectActive,"display","none"),i||(t.$speed&&(t.$speed.innerHTML=function(e){if(null==e||""===e)return"0 KB/s";let t=parseFloat(e);return t=t.toFixed(2),t+"KB/s"}("")),Zr(t.$zoomControls,"display","none"),Zr(t.$recording,"display","none"),t.$ptzControl&&t.$ptzControl.classList.remove("jb-pro-ptz-controls-show")),p(),i&&f()};e.on(nt.playbackPause,(e=>{u(!e)})),e.on(nt.kBps,(i=>{const s=function(e){if(null==e||""===e||0===parseFloat(e)||"NaN"===e)return"0 KB/s";const t=["KB/s","MB/s","GB/s","TB/s","PB/s","EB/s","ZB/s","YB/s"];let i=0;const s=parseFloat(e);i=Math.floor(Math.log(s)/Math.log(1024));let r=s/Math.pow(1024,i);return r=r.toFixed(2),r+(t[i]||t[0])}(i);t.kbpsShow=s,e._opt.showBandwidth&&(t.$speed&&(t.$speed.innerHTML=s),p())}));const p=()=>{if(h()&&e._opt.playbackConfig.controlType===Q.normal){let i=t.controlsInnerRect.width-t.controlsLeftRect.width-t.controlsRightRect.width-t.controlsPlaybackBtnsRect.width;ra()&&e.webFullscreen&&(i=t.controlsInnerRect.height-t.controlsLeftRect.height-t.controlsRightRect.height-t.controlsPlaybackBtnsRect.height),t.$playbackTimeInner.style.width=i+"px"}},f=()=>{if(!h()||e._opt.playbackConfig.controlType!==Q.normal)return;const i=t.$playbackCurrentTime.style.left;let s=parseInt(i,10);const r=t.controlsPlaybackTimeInner.width;s=s-r/2>0?parseInt(s-r/2,10):0,t.$playbackTimeInner.scrollLeft=s};if(h()){const i=()=>{if(h()){let i=0;const s=e.playback&&e.playback.playingTimestamp;if(s){const r=new Date(s),a=r.getHours(),o=r.getMinutes(),n=r.getSeconds();e.playback.is60Min?i=60*a+o:e.playback.is30Min?i=2*(60*a+o)+parseInt(n/30,10):e.playback.is10Min?i=6*(60*a+o)+parseInt(n/10,10):e.playback.is5Min?i=12*(60*a+o)+parseInt(n/5,10):e.playback.is1Min&&(i=60*(60*a+o)+parseInt(n,10)),t.$playbackCurrentTime.style.left=i+"px"}}},s=e=>{t.$playbackNarrow.classList.remove("disabled"),t.$playbackExpand.classList.remove("disabled"),e===fi&&t.$playbackNarrow.classList.add("disabled"),e===yi&&t.$playbackExpand.classList.add("disabled")};e.on(nt.playbackTime,(s=>{if(e._opt.playbackConfig.controlType===Q.normal)t.$playbackCurrentTimeText&&(t.$playbackCurrentTimeText.innerText=ca(s,"{h}:{i}:{s}")),i();else if(e._opt.playbackConfig.controlType===Q.simple){const i=(r=s,a=e.playback.totalDuration,Xr(r/a,0,1));t.$playbackProgressPlayed.style.width=100*i+"%",t.$playbackProgressIndicator.style.left=`calc(${100*i}% - 7px)`,t.$playbackProgressTime.innerText=`${lh(s)} / ${lh(e.playback.totalDuration)}`}var r,a})),e.on(nt.playbackPrecision,((r,a)=>{h()&&e._opt.playbackConfig.controlType===Q.normal&&(t.$playbackTimeScroll.classList.remove(Ai.oneHour,Ai.halfHour,Ai.fiveMin,Ai.tenMin),t.$playbackTimeScroll.classList.add(Ai[r]),t.rafId&&(window.cancelAnimationFrame(t.rafId),t.rafId=null),t.changePercisitionInterval&&(clearTimeout(t.changePercisitionInterval),t.changePercisitionInterval=null),t.$playbackTimeListOne.innerHTML="",t.$playbackTimeListSecond.innerHTML="",t.changePercisitionInterval=setTimeout((()=>{switch(t.$playbackTimeListOne.innerHTML="",t.$playbackTimeListSecond.innerHTML="",r){case fi:rh(a,t);break;case mi:ah(a,t);break;case gi:oh(a,t);break;case yi:nh(a,t)}i(),e._opt.playbackConfig.showPrecisionBtn&&s(r),f()}),16))})),e.on(nt.resize,(()=>{p()})),e.on(nt.playbackTimeScroll,(()=>{f()})),p()}if(e._opt.operateBtns.quality&&e._opt.qualityConfig.length>0){e.on(nt.streamQualityChange,(e=>{i(e)}));const i=e=>{t.$qualityText.innerText=e,t.$qualityMenuItems.forEach((t=>{const i=t.dataset.quality;t.classList.remove("jb-pro-quality-menu-item-active"),i===e&&t.classList.add("jb-pro-quality-menu-item-active")}))};(()=>{const i=e._opt.qualityConfig||[];let s="";i.forEach((e=>{s+=`\n <div class="jb-pro-quality-menu-item" data-quality="${e}">${e}</div>\n `})),s&&(t.$qualityMenuList.insertAdjacentHTML("beforeend",s),Object.defineProperty(t,"$qualityMenuItems",{value:e.$container.querySelectorAll(".jb-pro-quality-menu-item")}))})(),e.streamQuality&&i(e.streamQuality)}if(e._opt.operateBtns.scale&&e._opt.scaleConfig.length>0){e.on(nt.viewResizeChange,(e=>{i(e)}));const i=i=>{const s=e._opt.scaleConfig[i];t.$scaleText.innerText=s,t.$scaleMenuItems.forEach((e=>{const t=e.dataset.scale;e.classList.remove("jb-pro-scale-menu-item-active"),pa(t)===pa(i)&&e.classList.add("jb-pro-scale-menu-item-active")}))};(()=>{const i=e._opt.scaleConfig||[];let s="";i.forEach(((e,t)=>{s+=`\n <div class="jb-pro-scale-menu-item" data-scale="${t}">${e}</div>\n `})),s&&(t.$scaleMenuList.insertAdjacentHTML("beforeend",s),Object.defineProperty(t,"$scaleMenuItems",{value:e.$container.querySelectorAll(".jb-pro-scale-menu-item")}))})(),i(e.scaleType)}if(e.isPlayback()&&e._opt.playbackConfig.showRateBtn&&e._opt.playbackConfig.rateConfig.length>0){e.on(nt.playbackRateChange,(e=>{i(e)}));const i=i=>{const s=e._opt.playbackConfig.rateConfig.find((e=>pa(e.value)===pa(i)));s&&(t.$speedText.innerText=s.label,t.$speedMenuItems.forEach((e=>{const t=e.dataset.speed;e.classList.remove("jb-pro-speed-menu-item-active"),pa(t)===pa(i)&&e.classList.add("jb-pro-speed-menu-item-active")})))};(()=>{const i=e._opt.playbackConfig.rateConfig;let s="";i.forEach(((e,t)=>{s+=`\n <div class="jb-pro-speed-menu-item" data-speed="${e.value}">${e.label}</div>\n `})),s&&(t.$speedMenuList.insertAdjacentHTML("beforeend",s),Object.defineProperty(t,"$speedMenuItems",{value:e.$container.querySelectorAll(".jb-pro-speed-menu-item")}))})();const s=e.playback?e.playback.playbackRate:1;i(s)}e.on(nt.stats,(function(){let i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(e._opt.showPerformance){Zr(t.$performancePanel,"display","block"),t.$performancePanel.innerHTML="";const s=sa,r=window.performance&&window.performance.memory?window.performance.memory:null,a=e.getCpuLevel(),o=Ta(a)&&-1!==a?`${er[a]}`:"",n=e.video&&e.video.videoInfo||{},l=e.audio&&e.audio.audioInfo||{},d=e._times||{},h=e.getRenderType(),c=e.getCanvasRenderType(),u=e.getDecodeType(),p=e.getDemuxType(),f=e.getStreamType(),m=e.getAudioEngineType();let g=e.getRecordingDuration(),y=e.getRecordingByteLength();const A=e.isAudioPlaybackRateSpeed(),b=e.videoIframeIntervalTs;g=xa(g),y=ga(y);const _=e.isPlayback()?"录播":"直播";let v=i.isDropping;const S=e._opt.useMSE&&e._opt.mseDecodeAudio,w=e.control?e.control.kbpsShow:"0 KB/s",E=e.getVideoPlaybackQuality(),T=`\n <div class="jb-pro-performance-item">\n <span>版本 ${s}</span>\n </div>\n ${e._opt.isMulti?`\n <div class="jb-pro-performance-item">\n <span>UUid ${e._opt.debugUuid}</span>\n </div>\n `:""}\n ${e.isInMulti()?`\n <div class="jb-pro-performance-item">\n <span>窗口下标 ${e._opt.multiIndex}</span>\n </div>\n `:""}\n ${r?`\n <div class="jb-pro-performance-item">\n <span>内存大小限制 ${ga(r.jsHeapSizeLimit)}</span>\n </div>\n <div class="jb-pro-performance-item">\n <span>可使用的内存 ${ga(r.totalJSHeapSize)}</span>\n </div>\n <div class="jb-pro-performance-item">\n <span>已使用的内存 ${ga(r.usedJSHeapSize)}</span>\n </div>\n `:""}\n ${o?`\n <div class="jb-pro-performance-item">\n <span>CPU压力情况 ${o}</span>\n </div>\n `:""}\n\n ${r&&r.usedJSHeapSize>r.totalJSHeapSize?'\n <div class="jb-pro-performance-item">\n <span>可能内存泄漏 是}</span>\n </div>\n ':""}\n <div class="jb-pro-performance-item">\n <span>播放模式 ${_}</span>\n </div>\n ${e.isPlayback()?`\n <div class="jb-pro-performance-item">\n <span>播放倍率 ${e.playback.rate}倍</span>\n </div>\n <div class="jb-pro-performance-item">\n <span>播放模式 ${e.playback.isUseFpsRender?"固定FPS":"动态FPS"}</span>\n </div>\n ${e.playback.isUseFpsRender?`\n <div class="jb-pro-performance-item">\n <span>固定FPS ${e.video.getStreamFps()}</span>\n </div>\n `:""}\n `:""}\n <div class="jb-pro-performance-item">\n <span>解封装模式 ${M[p]}</span>\n </div>\n <div class="jb-pro-performance-item">\n <span>解码模式 ${u}</span>\n </div>\n <div class="jb-pro-performance-item">\n <span>渲染组件 ${h}</span>\n </div>\n ${h===V?`\n <div class="jb-pro-performance-item">\n <span>渲染引擎 ${c}</span>\n </div>\n `:""}\n <div class="jb-pro-performance-item">\n <span>网络请求组件 ${f}</span>\n </div>\n <div class="jb-pro-performance-item">\n <span>视频格式 ${n.encType||"-"}</span>\n </div>\n <div class="jb-pro-performance-item">\n <span>视频(宽x高) ${n.width||"-"}x${n.height||"-"}</span>\n </div>\n ${e.isPlayer()?`\n <div class="jb-pro-performance-item">\n <span>视频GOP(ms) ${b||"-"}</span>\n </div>\n `:""}\n <div class="jb-pro-performance-item">\n <span>音频格式 ${Tt[l.encType]||"-"}</span>\n </div>\n <div class="jb-pro-performance-item">\n <span>音频引擎 ${m||"-"}</span>\n </div>\n <div class="jb-pro-performance-item">\n <span>音频通道 ${l.channels||"-"}</span>\n </div>\n <div class="jb-pro-performance-item">\n <span>音频采样率 ${l.sampleRate||"-"}</span>\n </div>\n ${e.isPlayer()?`\n <div class="jb-pro-performance-item">\n <span>播放器初始化(ms) ${d.playTimestamp}</span>\n </div>\n <div class="jb-pro-performance-item">\n <span>开始请求地址(ms) ${d.streamTimestamp}</span>\n </div>\n <div class="jb-pro-performance-item">\n <span>请求响应(ms) ${d.streamResponseTimestamp}</span>\n </div>\n <div class="jb-pro-performance-item">\n <span>解封装(ms) ${d.demuxTimestamp}</span>\n </div>\n <div class="jb-pro-performance-item">\n <span>解码(ms) ${d.decodeTimestamp}</span>\n </div>\n <div class="jb-pro-performance-item">\n <span>页面开始渲染(ms) ${d.videoTimestamp}</span>\n </div>\n <div class="jb-pro-performance-item">\n <span>初始化到页面渲染(ms) ${d.allTimestamp}</span>\n </div>\n ${e.recording?`\n <div class="jb-pro-performance-item">\n <span>视频录制时间 ${g}</span>\n </div>\n <div class="jb-pro-performance-item">\n <span>视频录制大小 ${y}</span>\n </div>\n `:""}\n `:""}\n <div class="jb-pro-performance-item">\n <span>音频码率(bit) ${i.abps}</span>\n </div>\n <div class="jb-pro-performance-item">\n <span>视频码率(bit) ${i.vbps}</span>\n </div>\n <div class="jb-pro-performance-item">\n <span>视频帧率(fps) ${i.fps}</span>\n </div>\n <div class="jb-pro-performance-item">\n <span>视频峰值帧率(fps) ${i.maxFps}</span>\n </div>\n <div class="jb-pro-performance-item">\n <span>解码帧率(fps) ${i.dfps}</span>\n </div>\n <div class="jb-pro-performance-item">\n <span>音频缓冲帧 ${i.audioBuffer}</span>\n </div>\n <div class="jb-pro-performance-item">\n <span>音频缓冲时长(ms) ${i.audioBufferDelayTs}</span>\n </div>\n ${e.isPlayer()?`\n <div class="jb-pro-performance-item">\n <span>视频待解码帧 ${i.demuxBuffer}</span>\n </div>\n `:`\n <div class="jb-pro-performance-item">\n <span>缓存时长(ms) ${i.playbackCacheDataDuration}</span>\n </div>\n <div class="jb-pro-performance-item">\n <span>视频待渲染帧 ${i.playbackVideoBuffer}</span>\n </div>\n <div class="jb-pro-performance-item">\n <span>视频待解码帧 ${i.demuxBuffer}</span>\n </div>\n <div class="jb-pro-performance-item">\n <span>音频待解码帧 ${i.audioDemuxBuffer}</span>\n </div>\n `}\n <div class="jb-pro-performance-item">\n <span>待解封装数据(byte) ${i.streamBuffer}</span>\n </div>\n ${e._opt.useMSE?`\n <div class="jb-pro-performance-item">\n <span>MSE缓冲时长(ms) ${i.mseDelay}</span>\n </div>\n <div class="jb-pro-performance-item">\n <span>MSE待解码帧 ${i.msePendingBuffer}</span>\n </div>\n <div class="jb-pro-performance-item">\n <span>MSE缓存时长(s) ${i.mseStore}</span>\n </div>\n <div class="jb-pro-performance-item">\n <span>MSE解码间隔(ms) ${i.mseDecodeDiffTimes}</span>\n </div>\n <div class="jb-pro-performance-item">\n <span>MSE解码时间(ms) ${i.mseTs}</span>\n </div>\n <div class="jb-pro-performance-item">\n <span>MSE播放模式 ${i.mseDecodePlaybackRate>1?"加速":"正常"}</span>\n </div>\n `:""}\n ${e._opt.useWCS?`\n <div class="jb-pro-performance-item">\n <span>WCS解码间隔(ms) ${i.wcsDecodeDiffTimes}</span>\n </div>\n `:""}\n ${e.isOldHls()?`<div class="jb-pro-performance-item">\n <span>HLS缓冲时长(ms) ${i.hlsDelay}</span>\n </div>\n `:""}\n ${e.isUseHls265()?`<div class="jb-pro-performance-item">\n <span>HLS缓冲时长(ms) ${i.hlsDelay}</span>\n </div>\n <div class="jb-pro-performance-item">\n <span>HLS待解码帧 ${i.hlsDemuxLength}</span>\n </div>\n <div class="jb-pro-performance-item">\n <span>HLS待解码视频帧 ${i.hlsDemuxVideoLength}</span>\n </div>\n <div class="jb-pro-performance-item">\n <span>HLS待解码音频帧 ${i.hlsDemuxAudioLength}</span>\n </div>\n `:""}\n ${e.isPlayer()&&E?`\n <div class="jb-pro-performance-item">\n <span>Video已渲染帧 ${E.renderedVideoFrames}</span>\n </div>\n <div class="jb-pro-performance-item">\n <span>Video已丢弃帧 ${E.droppedVideoFrames}</span>\n </div>\n `:""}\n ${e.isPlayer()?`\n <div class="jb-pro-performance-item">\n <span>网络延迟(ms) ${i.netBuf}</span>\n </div>\n <div class="jb-pro-performance-item">\n <span>缓冲时长(ms) ${i.buf}</span>\n </div>\n <div class="jb-pro-performance-item">\n <span>最新缓冲时长(ms) ${i.pushLatestDelay}</span>\n </div>\n `:""}\n ${e._opt.useMSE||e.isWebrtcH264()||e.isAliyunRtc()?`\n <div class="jb-pro-performance-item">\n <span>video显示时间(s) ${i.videoCurrentTime}</span>\n </div>\n <div class="jb-pro-performance-item">\n <span>video间隔时间(s) ${i.videoCurrentTimeDiff}</span>\n </div>\n <div class="jb-pro-performance-item">\n <span>videoBuffer缓存时间(ms) ${i.mseVideoBufferDelayTime}</span>\n </div>\n `:""}\n <div class="jb-pro-performance-item">\n <span>视频显示时间(ms) ${i.currentPts||i.ts}</span>\n </div>\n ${e._opt.hasAudio&&e.isAudioNotMute()&&ro(S)?`\n <div class="jb-pro-performance-item">\n <span>音频显示时间(ms) ${i.audioTs}</span>\n </div>\n ${e._opt.hasVideo?`\n <div class="jb-pro-performance-item">\n <span>音视频同步时间戳(ms) ${i.audioSyncVideo}</span>\n </div>\n `:""}\n <div class="jb-pro-performance-item">\n <span>音频播放模式 ${A?"加速":"正常"}</span>\n </div>\n `:""}\n <div class="jb-pro-performance-item">\n <span>视频解码时间(ms) ${i.dts}</span>\n </div>\n ${e.isPlayer()?`\n <div class="jb-pro-performance-item">\n <span>解码前-解码后延迟(ms) ${i.delayTs}</span>\n </div>\n <div class="jb-pro-performance-item">\n <span>总延迟(网络+解码)(ms) ${i.totalDelayTs}</span>\n </div>\n `:""}\n ${e.isPlayer()&&i.isStreamTsMoreThanLocal?'<div class="jb-pro-performance-item">\n <span>是否超过一倍率推流 是</span>\n </div>\n ':""}\n ${e.isPlayer()?`\n <div class="jb-pro-performance-item">\n <span>是否播放流畅 ${i.videoSmooth}</span>\n </div>\n `:""}\n ${e.isPlayer()?`\n <div class="jb-pro-performance-item">\n <span>是否在丢帧 ${v}</span>\n </div>\n `:""}\n <div class="jb-pro-performance-item">\n <span>网速 ${w}</span>\n </div>\n <div class="jb-pro-performance-item">\n <span>播放时长(s) ${xa(i.pTs)}</span>\n </div>\n <div class="jb-pro-performance-item-block"></div>\n `;t.$performancePanel.insertAdjacentHTML("beforeend",T)}else t.$performancePanel.innerHTML="",Zr(t.$performancePanel,"display","none")})),e.on(nt.togglePerformancePanel,(e=>{Zr(t.$performance,"display",e?"none":"flex"),Zr(t.$performanceActive,"display",e?"flex":"none")})),e.on(nt.faceDetectActive,(e=>{Zr(t.$faceDetect,"display",e?"none":"flex"),Zr(t.$faceDetectActive,"display",e?"flex":"none")})),e.on(nt.objectDetectActive,(e=>{Zr(t.$objectDetect,"display",e?"none":"flex"),Zr(t.$objectDetectActive,"display",e?"flex":"none")})),e.on(nt.occlusionDetectActive,(e=>{Zr(t.$occlusionDetect,"display",e?"none":"flex"),Zr(t.$occlusionDetectActive,"display",e?"flex":"none")}))};function gh(e,t){void 0===t&&(t={});var i=t.insertAt;if(e&&"undefined"!=typeof document){var s=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css","top"===i&&s.firstChild?s.insertBefore(r,s.firstChild):s.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}}gh('@keyframes rotation{0%{-webkit-transform:rotate(0deg)}to{-webkit-transform:rotate(1turn)}}@keyframes magentaPulse{0%{background-color:#630030;-webkit-box-shadow:0 0 9px #333}50%{background-color:#a9014b;-webkit-box-shadow:0 0 18px #a9014b}to{background-color:#630030;-webkit-box-shadow:0 0 9px #333}}.jb-pro-container video::-webkit-media-controls{display:none!important}.jb-pro-container .jb-pro-icon{cursor:pointer;width:16px;height:16px;display:inline-block}.jb-pro-container .jb-pro-ptz-controls{position:absolute;width:156px;height:156px;visibility:hidden;opacity:0;border-radius:78px;background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAATgAAAE4BAMAAAA9UfJZAAAAMFBMVEUAAABHcEy0tLRZWVmysrKoqKi1tbWvr6+2traBgYG1tbWWlpa1tbW1tbVUVFS1tbVGCHqkAAAAD3RSTlMzAO9U3LSWySp3aZcVRDUDw823AAAJYUlEQVR42u3d32sbVxYH8EPHxgg/lBsa7SBkukmpSbwLI2KbEPpgZ5MQtwmM0wRMmgdhP6RgEuwlSVnYlmGMYaEvMU1KKX4QNq0pocVmm7CYfRBaQguFpbgPKRSC/4V2LGliO+bulWKrkvVrftyZ+WbxeTRG+nDnnnNmRjP3EpMR6tMH18du/0Xj1tGz5+9cf/DUlPKx5PsTkr8s3eZ1cX7ym1zkuI/f1wTFunNt9fP+FIno7/98/tFY+Y8ffBUlLrmkl2Cr96guTv27BMxP5iLCqUvi68+tpqhJKPNXBH3SjACnfimm/7Wmsl3fI/FP75lh457oPH+1Da3M+1T8481QcT0T7UetevR618LDPdH4hTlyHLGH3LoZEk6d4PlvyVW8pfNeMwzcDwa/kCKXoTzk9tfB455o1mXyEIOa+0PrFvcFt+fIU8QM/k6guOQifzNFHkN5l/flgsOJVHibfMR9l2nhBqem+VXyFZ/xghkMTp3il8lnDPKiGQROhs2lzjEuKcVW1uWk4ybk2Eq63pxk3CK/RZLiJO+Ti/vZXw3ZX1E+kon7jv+JJMY/+Q15uIRWIKmRthZk4VTDTsnFKYZtSsItWiskObq1Pjm4f8gqIrUF5W8ycAl+nAKIT/iCf1zSKFAgkW4/7drifrLmgsHF2k87alvhblFAcbJttWuDU/VtCiyyedMXbjGfCg6n6H1+cHE+TQFGFx/3jksa2xRoZO2cZ9xsUJn6e8aOeMX1aGco4Biw1jzilm0KPNJb3nBxvhI8rrtVTlCLK5ptCiEyBS+474POhr2c+NA9Lqm/QaHEiXzONW42yN5Q2ydG3OLU4MvI7+XEdImbCWvgSkN3zB1O1YYptOhoNnRNcDM2hRjGMTc4VZsOE9fVZOioyYyjUKPJrKPGNW44XFxX41rXEPc4vFTdS9iLTnFJ4wyFHAO2U1zcSoWNU7RLDnFTb1DocaLoDJfgc+HjYo3uTjTArW9TBJHdcYJTtdEocJ0NCnE97nGBIon0RQc4YzgaXIfdHhdBHdmrJuNtceubFFFkdtrhVG0lKlx3XUrsxz22KbIwLrbBTQ1Hhxsotsb18FR0OIWvtcT9Z5sijOyfW+KM6ShxXXYrXMJKRYlTtIUWuLubFGlknrXAGaPR4jrt5riERRFH7XGtwc1sRo3LHGuKi/qo7j+uhJOr9flKMBW4QR2uxk1NR4/rKjbGRdpXG/bXKtxrAEdVHNfTDXHLf0TAvbLVCJfU5hBwMSvXABfPE0To4w1wP25i4DLPG+CmRjFwncV6nIpQSF4UE7MOd7hAIJG+VIe7u4GCG3pWh0uPouA6C/txMFOuetIR3JSrmnQEN+WqJh2BVbmaSreLS+JMudKky9Xg4jYBRXq8BndoEwmXOVKDWx5GwnVs1eD0OSRcLF+N67EIKrS1Klx8GwuXHa/C/biBhRt6XoVbnsbCdW1V4bDyoZIRZZwKlg8iI8wKLl5Aw73oEWXcoQ003NCRCm59GA3XsVPBTa2g4bqLFZyWQsMp1h6uJ09woa/t4tCaV6WBEWSy7qYrQSbrbroS2MVNzUUOAXbWSnel0sU+AUbpsl/gEjYizlgo4w5vI+Kyl8o4xEryopYI3N1hRFzHszJueRQR17lVxqXnEHGxQhmHd06yd15CgBcQlcsIYokCJi69IHDxbUycOGki9toGJm7otMC9/ism7tXfBA6zBperMIHW4HIVJsDrwsrVIYE2CNEibIHDbBDlFkFJ0AYhWkSOemxUnLFGqN2r1L8ItXuV+hfFN1FxmXH6wwYqbuivdAgXd4RQ+36p8xNq3y91flqfRsV17dD6KCquc4eWcXFbtLyCiusu0hQ0bg4VFytSGhdXICOFilNs0nFx+QOcZ5xGsGEd4DzjOC6OH+A847QD3P9jtuJ2CGjcQeP3gYM+2YQ+TYe+wMG+NETGQd+OgL6RA30LDPrm4eu/ouJe/Q37hjX0rX7oH0mgf16C/mEO+idN6B+DoX9Gx34AAfrRDeiHXqAfF0Lt/OUHrVAfUcucRn+4D/qxSOgHSqEfxcV+iBn68W/EV3AqD85Dv3IA/bIG9GsumC8IaSb+q1XYL6VBv84H/SIk9Cuk0C/fQr+2jP3CN/Sr8tCLDEAvzwC9sAX0kiDYi6lAL0MDvYAP9NJH0ItGYS+3Bb1QGVaP2LfEG/TieNDLCmIvyAi9lCX0IqDQy6diLzwLvWQv9GLH0MtER76rRqWxPgdemtwYf9kWdYdeDh97IwHoLRigN6/A3vYDesMU6K1msDfpgd7eiOmjSEf1ZdpSC3ozMuht3LA3wIPeOjDSTRdfKb7M21VCb/QJvUUq9uay0NvyYm9oHFFKdDvaChp6E23s7cehN25nh5G3vE8aZ8LGDdjMIY49zoc9dPpFx7ikHnIh7sjnHOPYTMj36oxjzDlO1UI9Xe9oUICb49iMDTBwzXCqFuKsG2gycM1wYtaFlrCK3mTgmuJU7UzkA9cUx2bDGjpFH2FucUk9pA57onGNa4lj31uhnJzEtA+ZexxLh3KpkykwL7g4D+GUuJuPe8Kx5RCuJtJbzBuuJ/hyMmCtecSx2aBzIqaNMK+4pBHwtU7WznnGiZwI9Oykq1U2tMWxxSD7hKL3MT84VQ/wwGbzpi8c+47fCsp2kt9g/nDsp6AyNqb1Mb+4pBFQKU7bpm8cS/DjQdg+aXT/wTWOzfLL8m2DfITJwLFFS/oZQHf7CecQpxq25GqnGO0nnEMcS2iSq13WWmCycKLaHZebDDeYPBz7mb8tz3aff8Rk4tiivJQd5H1MLo5NyNIN8t6cbJw6ZV2WYys6tTnHCZ2MsRM2k8nHSdG5srnBMTXNr/qzfcYLLmyucEyd8FdR7vNeNzZ3OJZc5G967mTKu7wvx4LDMfYFtz2efMYM/o7LL3OLY080byVlULNusqBx7AeDX3B9aJWH3P6aBY8rpUX+W3e2t3SXqeAZVzq0/JyLmRe7wt0fUs849t8Jzv/u8Ngq/+K8d42FhxODp/P8VQc85VPxjzc9folXHFO/1Lh1rc3BjT0S//SeycLGCd6Sxvm51abDp8xf4dyaNL1/gw+caBhLuvj6O6v36mWn5scEPe+H5hMn4uP3hUEAr63e6y+PYX//qflHY+U/fvCVzw/3ixPD98vSbV4X5ye/yfn+aP+4MvDpg+tjZ4+K8bKOnr1z/cFTU8rH/g92biFxn2S73AAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%;transition:visibility .3s,opacity .3s;right:43px;bottom:135px}.jb-pro-container .jb-pro-ptz-controls.show-vertical{right:43px}.jb-pro-container .jb-pro-ptz-controls.show-vertical .jb-pro-ptz-btns{left:0;top:156px}.jb-pro-container .jb-pro-ptz-controls.show-level{right:163px}.jb-pro-container .jb-pro-ptz-controls.show-level .jb-pro-ptz-btns{min-height:156px;left:144px;top:0;display:flex;flex-direction:column;justify-content:center}.jb-pro-container .jb-pro-ptz-controls.jb-pro-ptz-controls-show{visibility:visible;opacity:1}.jb-pro-container .jb-pro-ptz-bg-active{visibility:hidden;opacity:0;width:156px;height:156px;background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAATgAAAE4CAMAAAD4oR9YAAAAM1BMVEX///////////////////////////9HcEz///////////////////////////////////85yRS0AAAAEXRSTlO5DCgVgZBxAK2fQDRkBR5XTPLKM/gAABnnSURBVHja7F0Jkqs6DGQPO9z/tD8Jq6WWbCCvIjKfzAGmulrW3ooedr6ui+M4TdP++SXPr1l/SdL3aRrHhv7ZyA5qb9xe0L3Am+DrkzeCL/BeX908MezTuPsfOArdgl3KsZuhq99fk/Tx3waum+ByAHua5QbYilkzY1aP728YhrH5InrfBa57OLAtVjpRbYaumex04dq4APeC7vnVSfo/45bXLe33jGscMx3f0A1vyg3t69e2dRL/NeA6wrgdcCvjyPM2U25mXDt9xVD3f/qN0yi3Mm6P20S54vlXtGPS/R3GPSbYOsC4ZAvmJtiaGiL3Zlzx/Ht+Y/KXTJXbqmaqe9za1VYn3N7YpX/OVGev2qduOLIiB7xqOzGuWCiXFVmWtU3368A5lkqeOJI21I5XXaORxVRnxmUTdNnY/4U3riNvHMJts9XRtdXVUttipdzrK/4x7UyY6sK4Gbo+nU21T1zKcd9AGJetlMvyLKvj3zXVfeqQElMljINx3MK4xVQ3xj2Ry7N/6CiMOIfYyVUXWxUyBx7HuZRbcHt9bf/Lb9zsHlzKzabauJaK47iVcC7jJujS33/joKkmxDnM4QiJ4xDjZuT+DXQW3jgxV012qcPuiePhCGfchlv1/P0D6Czmqmuq2gPGkbIS8Q4ZsNU3dGP3Y2+cW1RyKpkrbAnwqhi3iXHFHrU3bFVV5c3vBsCsOALjkXErAW85F3rjFvBm5Kos+TngCOXYG7fA1ojFER7GPUHbmer0tfGPANeROM6pjvDMQSkrsWQ1d564Fbr61964TvSqDa6O0ELmAtvGuc2rrpQrn/aa/qCpYq+6mSpOVhnjWBy38u2JXFl9yL8acg6CV3Ur5yxVZfW4AsRxG+XKssz6n3njVMYR4Eg8sj1yi3tgtroxrpyhG38gc+h8PYddPQ551dVQW5jju2/cG7kXdB946Uy9cbDnQOpxuCCHcq5dHDcht8D2/K67VxPNGtLJd7qDTcgb1zLGbXEcY9z0Fd39GReTzIH1B/2lcxrGTYxjXnXyqxNyef8zpipVlfDsyCCmDkuumhGvWq6W+vyisqxvDJwwOxJQO6fNmjaQcRt0ZdR2dwWOFZViuculNWtgBZjk+DNq1cq45y+Lf5NxE25B3oEyLueFJWqtT+Ciqr8r48jsCAyAG+2Na53MAdQxX16VhHEL4Z7Ilc2dGad28pskaULiEdDlyijjdqa6gBeNtwSu63AnP3V6NUnAG9cu1RHOuL2hVi5qr6+9Za4qV0dCGcfCEfDIufWRFbsZvKy7KeNgW7XHvRqxWfOGLhO6XCrjoiiPb/rGdZ75uGRfj9u3B1sWAEtdLuxVF/Cq9HaMe4A4TptkZYwLqI44rmGDbUe5E8hZcg54zquRbHXu5NN6HKuO7N84YqwbdGV/Q8YF5arUN7CJTNLkgplD5T5xG+OOI2ehAhxv00ocOlpWwhHwljns5uNg6bxCb9wbueSupip6VTnj2jGudSvnOeqrVo6h7vl2nHM2K8AkV1WyfDYDvHUcWF+1VBl3EDlLKdc2dQ6aNbhXw2eAt14Nf+MqFse5rDuS8tucHUmhqaJppYF6B8440h7E8cjhqMTiLtcaAL+ga9jWZb35hpbHceyNI9WRSmHcE7n4jqbqTp2D2nnzgm154mB1hJQy1cwBIpd3twCOrjnEoDsoTZ2jepybb2VKrhpx3zB92Z29Khpl1ZN8MHWzJV1CdYQHJEeqTMbqcfEMW+obLBwES83w7AgvY0YlMNT3N96GcXEHGQdxG2t3CQ5kDkoFeO8esHd4fc193jinAtxvXhUN3Ywz5VAFGM3cENfgVM4x5YICYRumqu5yIVMdJuhaLXMAFWBKOIhbWFBiO44Dg4Usxx/cCrDyxqESMIYuu4lX1fYcGnVaaVmtKXZxHOzW5Bvfqtk3iLAFuVaLew4HluDUzIH1VYMZF+AgLMZxcAYY1uNYBTgrwPDIaqxOQ1p540IchBFTJW9c2ofNAO99Q+sYaugbJ35Vd4sKsPbGqVM33KsWmdpXLeXqufsVNwhH8FyhOh8n74foKb5WVDr0zFky1Rgt+iaJZyJTWErKMynpqsqgVy4q0xv0VTvZq0pJPq5jzn41zzzVET0aCYjmTO05OLaaBEwWqhvSenUkKtVw5P0N96mOpNr2YCPuh4AJCGEAoioDver7628Sx8WAcU2i1eM259AWhZBzuQEJieN07JR6sCHgXoSLnepI7yo9NqgCLE5A6K4hjHGKsVqK49JYEGyBg4XIq2b7FREUx5Xu2LkXOtmz2pJBW5sOqdjJF3sOjHG5fz7OT7n8DtURwjjPtBKtx7VLOa6Q4zh5Wkn8xhvU4xbG9al/s2bAbxwYkJO7XCGME43VIuMc56Dnqi7hpPE4cVopBLnibozTp5X4DHAQ49iwfsCX3IhxYFoJB8C0y7Xr1iwBSZXDulIUjF11G6+qr5aPALlCmTrfyWfQzCEK49xoPMnnjFMaq3QlX9tzQPuq0QFbLeNbMU6cHRn3Sb60HwJ6NXAhKQi61nzpPAbtQaY8jUUgQnRHSodxZSjjoig161W7HePIRGZDJzJHQXiEzE4DpRtSjotCHzkUkhj2qqJi4V54T1S6cWwVp/nhjAP1JQuDhbs4TtFW0spKTgW4UHJVFv4GQpcZA64jkt1xDNS8lDEv9Y3z5KpRGY4biIINMC7e2lxKNFJDqUfQquGZA2yrHoINUM7G6ZX1iVM2RKDUI08dssVUfduDRyI5QDkbFWCnscrWVWV1/RZ2uaRc9UyKL1LO0r7q1qwBm761WsmEUjdge9ApAB9iHHWslq4kMalHTbHQieO0zXKljHmIc4XdOE695yCpsg7eOE7t5B/4Uqv1uDSGKhDYq0r6yQWYj5NnRw5BNxjOHJAKRJB+nJqr4jcuOki4qOzs5qrgulSDJzJHUcyrCNMdOc44ty5nel815KDZ4HTypeoILAEfZJxbCjYkSpVKgZx/IpOfXgnarDkKXWIrHAm7kiTqxw1er+oQzg2Bj32FTcYJ2kpCIx9PK2XMq1ZCz+EM46LYZK4qaCsdmo+TqiOV5FWPITdYLZ2jOqYa/6LN8kJSZT1dxkSTJEYKmZ2/OuI5aIYYh+UzKn3TN9A9mLjL1cl6LexKkqof575xVJWVx3HRefdgUbGQNGs2U2Ul4HYQ60o+HeBzjCtt9VXVqXMpc3DEzh2NzEJSnr7OuG35wUTpPGjqXN3lQgdE0AWRA2sOHls1eO2yh/uqWM1LbUgvQzeatOhR5NZM39QIBNyQbviBVajYItbOYa56knCbrRrUj0vxTn5QVQlOnUtdrjKKztuqpbMEJ27WtCG3BzX9uMPfYqsmlW7SPnRfFeSqwTrAp9641VZtXi1PlX1VN44THzlvPe4k45aZLys9h+7cvuqsAqEpBAm6I9HJN24pZ9oIRzp5XzVUsVCZOnd0Ry4zbu52GdMBDn7j+NVyYXaEneW6+sbNrQcjtwdJCTh4WmlrSLcF3axRZ4AvMC6zxjj9annty1X9M8BoefBMQGKudB5UjnMnMltQV1JuD5JK5jnGTUU52zeke+4cfMJ7ygxwSZuDJ6EbzDEuZF+VNLnczCETlPdkdf3Tj5yhAHhNVdV9VXgJGV9JyqWjjRdS1fWRs6vmRctK1KuiLD/b22q2KyvlWJT1HOPeo3IWqyNwlwtrxJNrlwW69ZNr0qKnoBsfNrWVcH+w9gzIFXxDeisr5cxSrzCusFVWkpVukH7coF/0zQRt0a2QGZ1HLrfAuIfDOL/uiLOTz9UMMiTmtXMOVXmxW/P+OqM6wPBKEmLcbuiGMw4lq9cmIPbewa5iIb3LdYxxKHMouYDcSeRqcxd9+dS5VFWCGZd3e9DtR5+21dbYRd/1EAaagUC6IzDLV7YHj4pSKbmDkZRLnmRNcHeQ3azZdvLJ9qCUOVyhXGVmQUSpx9GWAzNW6Y0DmYMzrbTeHjzxxTeI41zktugXtQezAsRxon7caUt9VZZMMQ7pAPMnjnTyB5lxJHPgU+enGTeajONUHWB46wfW41jmAE79nHerNiYyFeXpBu/keycyM8983CWv+sxWLe2rsgpwH7qRxPuqb7pl6IKe61RPYpcbvefQy3e58LSSbwY4B071CuNKk31VtswlTyuJ+6oZuss1h3HVCTEDluZb7Ks6prqrjijlOLTLxRlXUhng85RLo+77por7qp5c1fUN8I1Tbw9eqce9ArkvA6eqxOOr5UQGgrdVC1l5GszHnYSuNsC4OKgeF6au73S5Mt983IU3bvwqcN3jAe9y9VgkvvHPskp7DuI9h7PfYOGNw3EcH7rx91XRPbNPT2TOEbCNNw7uJOGhG+naD8+5PG/cJcI9gYu/CxuYVuqd+6reHbgBWqrvavlV5LLvAqfdc6AFYElcyW1IS0eScqg7ch65/MvABXW5ElWvZXDiOL2Tz3VHzn7Vt4F7iNuDobMjwp7DUh3hfKs+EQCbAs43O9KgG9KDrK6vMe5qIPdd4NS7XFLi4NxzADf0eEPa8aqX1lV35REjb5zac1geuYVwtfjGbTmXsJH0qf7g14Hz9xzE9iD0qigewTv5F71qaeKNwz0HXI+jb5zLODABQWaAP+MbXA2SbxdH9KlzMjw9jvAUMr72o6363hQ4VyQ+lU+vkH70ALVFM2cnP8f1uOojhLPgVZnWI7y9Enjtcr+TT/qDJdj0LW9tqlgFQtUdYQfNQupxnHE3dw5aripmDgOcOt90gHOpOvKRF85EOCJKPSrVEa/y9D9QLDQEXKco3UiqVPtdrjZIIxNuSEeX+qomc9U+3S/WUIUgvD2o7nJ9UnfECnAPWQUiSOu8HYKERz6oO2IDuE7THcHOATIO9xzQhnT1IcblVhjnagRp8QjZVw1gHOFb9ZnSuY1OvutVe3/86w4Be7XOc6GvetsuF47jAq5dElFWn9a5oJF5YUDOBHCdds9BzRw2xrWy1jl946qrC6tfb0i7uWoKZ0eaoJs1e8LR+6pQPy66GMiNhqaV4ljbc/DqjrTC1fL8n/RVa0ummiI1r0a/yyUPT2dcXBR08s9Cl9gVpdKvEvgO00LB7qta585g4eP7jIuDxEXdaSV87TID91WdiUx67uf011lkHBTea/R6HN1XhTdr0AmROw9Pd1h5euurJvxKEh2e9uyrfnYn38q4vnp7cLchXXuVbtxdLoFx1UVtpWnv0uLNGudquTCROXj2HHI6riRK791zJakjIxDKRGatMI5fu8z81y4vzU5bE2yJmYLyFsc1jaythPcc+CW4j2grGVi71GTQgnLV1tFrQduDUj3uWvwb27p2Sefjel/PAXXy+QywoFh4IZKrTF67lC6I1H6NTHEGOBeWB88LoVm6dimoGaxO1a+RiafOpX3V8r7yGayOuZfPgGsOQhy3V4Fgew7wSlJ5hXG1aY1Msj2IK8B0BAK8cYIIxBXG9bZuD6ZUlCqk5zC0x/Yczh9YtSVK9ZA3pAN6Dqq6vnAo9ANx3Ndl0LazXPK0kq/n4J06F+45XMkc7Ajv0Sy/VzZrpAsiLUnyhZ38fQX4vOqIOXX9o9cutRlgfZfrSuZgTVxU9KrKPQdQOgd3CZB7OO9VzcnZ4pYDHddnkoVSrprlAXe5ynN5gxF1/Vi7ocenp7XdcueJyxSt8wtjhRYku2EcB3Hb1LxqHMb9192VJTmuw7DxSsfxdv/Tvn7TSceiAEpylqYnH/lWsWBRXABMVLHQ8B4cjvWUfN1xTYU6wJEqqy7y1ynBEIGt8ycqBxe2BGh3JEt3hO3HtXjm0KFJ/kHIOTDCmEUM2RFMH9ygn8N+WoNmDpcLZEgfFuz2pQPMKof7eHBME0RsxAVX3OFS1Y/Zj77jtGQ34nLRWjVeHtFF/pOIc2EvRdf1m/2UKy11s+8qtXzmAKQMhiNNTDefqiWtFIlkQqEbNJFuO7g6oqr84p8PC710IxN0R0bK5VIFV2svTx9CnCPTxspm1iiGiBKeptmh26tAYOXpp+y3HSGuqUwnONzIZN7bRAdYp4bDZpee5qq5OsAKcdTQISjykUjmM/aq3lRZK3rH6a5SOMmPZw5BQ47yQ05rvm3NVVXhkLCs0YqF2EN60A4iw8Ev1dtcNXvmsGK+qukh/QIRtEHE06cK1fXtKRfLqoTLRadcw8Ev1ZkTXBXzVdkdt5k1PvtQo/24I604520lvq0EFAvxXLXlytPHpjUXcRU4tTuiJvkx4EbugxHojrRJTn4p5jY3gcspucLQKW0lVnNhFQhF5ir+VhsvgZsN/Tji9cOcVybD6wcOuQ5MuXpxirhyt0tTea9NTPKLEVf7CdzMaZdZbpd0Pw6LZ1wiN7PhWGpwk1Uz/BzQDsSEnOB6vXT+cLscntoB3sQZ4qiaV/qOixjSJYgrBNwwu0OcSYKzzbe1ExwYrF6InFdpVp3EG+IIJSlsnWv9uEQ/DrMH497IcOgt4hNxC9vXv2b5ElhU32fuuF78IQ4r3XyreV3NST5V86K16uG6YRF3iIt1gJscxRbgE9oG88E2oa5fdMu14h9x5pZX2I9DuaGn+nGXmOdw6PHrvh+X9OWagGdNbzCkI5uk7NhpwHliSDf2sIY4wQHl6ZysWvoaqcUz4hLyGUrsfF85QIZIvASsh1zZsYsA54qTDyuHSAViM7wH+x6NarDWeRHiFpHT3HE1g5zldsk6wEDOdiiwJejFJeKYvaqtWEhFqShfFSkWHikaPHZH0qJUxEOvnK9a4CE9ibvACVQsbMLKwWTWGP6qMeKOAW6o3AWOXHHZ/TiD55BGXHZW3UScfqqPVdbGMjSLa1VVcRG+KmRI53fOOxGnn2piedpgSK9GB5h0MssBVzsM3AwdfXPuuFh3ZGLaonBUk3/J9eIfcXDmcC1RLEwotgTvuDzIDY3LwM1z0kMam/1gjcyWjQePq7VscjrE2YuFxNHMLFWB1vlwKDO4rlX1tj7ROidZNc1XzZJPZh/q73O5BPBVo90R5PaTyKqYPVhcdK3iGXHxJB8RRLT14KZYl1FW7RJa5zkf6uw2cJJ8x5kbmcDsx+yO6NglQreInO+Oy9oBNry348qh2M5hFTkH4sysihA3WXNVvAIciQSVtH2d745kdZUYQ9pa1o8QNxzLqO4m+eFcNRk6BLmWiHZ3gK+a+FZH8Y444q9qbuuTmcMLlad7Ee+Iq9gOcNJ7cFqZDjCXOs98AV9m8Y84OFitI7fLK0VcwHPoqZ+Dks+wPtRhEf+IS4kZ1ElqOZrW3CBH+ar2O24U34GT8rmqntWsif24jjFrrCtuEjkD4qC2kpqrjrQ9cpDLZXlIt+I+cEl/VernsB7Zj9PTQZIYKjkX4iCz5go7mYpZY2qdI77qH+M9MtRyGsQZXC5rrzBWnt77OQCNzKB2YIi7ipwDcZXJ5YJS54p32UM/h84WAmZZdZMTBE435LLt3sm2foajbyqtTnKCwCkVCFMlHnKSpkhev4UdYHDHke5IK2cIXKACYbuWm7UqVp7uzDsOI66bzxE4ogKBZg5ZtWqCIR2+4wDiLtl2s84m+VW8ra+YNXZ3BHaA4VwVvn8vjcipEJezr8/UDOgOMDeYYv24ZGXvtzuS0Y9jO8AT3QHmnPzhz9G4OZs5QKIvFgJW40FYqraAWRP4OQSRK4qbM55Dxpeqd4B/uiNTmj1oVg5ZhZbvKZdi1mBHMyIuanPydXdk97GW4U28GZqFSjdL8h2nkgN+x7E7bo+40rj50AHOkTq3NYIQ4tpolRXKi36/Q0rj5m2uWkV81ZS6/hRvK/XRyIHRHIby95v/d1y9WEk1lmW1uVx4XekWua4SOSHiKuZnZu3HYXV9yh6EPIc74NojBuQe9uMqUz+ujp4jI+2dt6w7Qp3ghuw+krNaNctBrwYqaNB7MHgAdyk/h5K+pdfx4GzusoafKujHRR3gDu/HhfpxfxF3lTMGbrZtCdB+XIi4KDegmQPagbh1zsufIY4QV2ltJcVXDTn5EeKKuFyqcmgrOWng9g05pZG5RFvnd8SNtDuiPKRbw9H3/ztumkVOjrg5ra2kEIe7IxBx4e7IA3DjMwf3eMfhh9xovH/73dZ5n9cBHrpFzhs4hbhgB5iqeaH5IGDWtCazZuhnOXHg5jmdVX9mDte0u9TjAQz9HB6Iu4zPHt2v7kgNe+cb3FbqeVa9qBfw39C1jZw9cMBDmr7jwqHDylzL+5Sfw2V9wcn9Iy5qZFoTaZRV9b7+k1nB55Sr2gEOaysFiFO+tCSrhqsj2yzyjyAu3lYCHnojyap85gAdfV9wu3l+x2V0R36INSvWAUbvuMvzydRprWogTmfVO+AI4uB+XF/JvxK4UHekMZRucHdkQhsQvdqPuwGurV95cl+LhUR3hPfjTN5lkFa78bUH97StdEdcOJC277h0bvgO24ty6RkQV5OtG5Pn0GIy19S8/OCeKofojlu47gjVT+4/EjZvdu9grnq1uVxAB1il1beEzRtBJJQICv1VMeKU93a0OzItbzq5k90RgLhl+XGCqy3ERdYrO0fftXnb2T3VqjfE5aigMbf3YANirN54co93XMjJT20rhWteP5Hrr/NbT+7xjoPMctOzJkqq6/Luk3u84+7vuGUBSzeBweoE3yPTm8Hm444LiA5gyMXuuJU56G3NR07uAXHVwwo5fgBTf1Xo2rjVnzq7r6yK1LwSr5HHHTdt9fy5k5/R7XLcJdX7FbeOy2dP7trPweQ57FRZx7r6+Mndq3ldEzrAY938ysl9uiQ1cJNVa2SO16X6tZP/dj8uDqJW2VfM/O/ftf7FmPkK3OMZ3MAu8G3T6ytiTTU7OK8jxMlfuN1idg/X91/9VUZ81WOVo8P+Bw+0DogP6NDPAAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-ptz-bg-active.jb-pro-ptz-bg-active-up{transform:rotate(-90deg)}.jb-pro-container .jb-pro-ptz-bg-active.jb-pro-ptz-bg-active-left{transform:rotate(180deg)}.jb-pro-container .jb-pro-ptz-bg-active.jb-pro-ptz-bg-active-down{transform:rotate(90deg)}.jb-pro-container .jb-pro-ptz-bg-active.jb-pro-ptz-bg-active-left-up{transform:rotate(-135deg)}.jb-pro-container .jb-pro-ptz-bg-active.jb-pro-ptz-bg-active-right-up{transform:rotate(-45deg)}.jb-pro-container .jb-pro-ptz-bg-active.jb-pro-ptz-bg-active-left-down{transform:rotate(135deg)}.jb-pro-container .jb-pro-ptz-bg-active.jb-pro-ptz-bg-active-right-down{transform:rotate(45deg)}.jb-pro-container .jb-pro-ptz-bg-active.jb-pro-ptz-bg-active-show{visibility:visible;opacity:1}.jb-pro-container .jb-pro-ptz-control{position:absolute;left:53px;top:53px;width:50px;height:50px;background:#fff;border-radius:50%;transition:left .3s,top .3s}.jb-pro-container .jb-pro-ptz-control.jb-pro-ptz-control-left{left:33px}.jb-pro-container .jb-pro-ptz-control.jb-pro-ptz-control-up{top:33px}.jb-pro-container .jb-pro-ptz-control.jb-pro-ptz-control-right{left:73px}.jb-pro-container .jb-pro-ptz-control.jb-pro-ptz-control-down{top:73px}.jb-pro-container .jb-pro-ptz-control.jb-pro-ptz-control-left-up{top:39px;left:39px}.jb-pro-container .jb-pro-ptz-control.jb-pro-ptz-control-left-down{left:39px;top:67px}.jb-pro-container .jb-pro-ptz-control.jb-pro-ptz-control-right-up{top:39px;left:67px}.jb-pro-container .jb-pro-ptz-control.jb-pro-ptz-control-right-down{top:67px;left:67px}.jb-pro-container .jb-pro-ptz-icon{position:relative}.jb-pro-container .jb-pro-ptz-icon:hover .icon-title-tips{visibility:visible;opacity:1}.jb-pro-container .jb-pro-ptz-btns{display:block;position:absolute;left:0;top:156px;width:156px;box-sizing:border-box;padding:0 30px}.jb-pro-container .jb-pro-ptz-btns .jb-pro-ptz-btn{display:flex;justify-content:space-between}.jb-pro-container .jb-pro-ptz-expand .jb-pro-ptz-expand-icon{display:inline-block;width:28px;height:28px;cursor:pointer;background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAMAAABF0y+mAAAANlBMVEVfX19fX19fX19fX19fX19fX19fX19HcExfX19fX19fX1/////Pz8+oqKjCwsKhoaHn5+eWlpaOqTaDAAAAC3RSTlP/3CaKxwJiAELtp4ri/s4AAACuSURBVCjPfZPREoUgCERXBdPRyv7/Z6/Z1aQp9oWJMyYLiKUrOIpAJBdGCldgbzBkPM/QEoTI3jBEPBRDhwEvChe08Q1Ge0ImvIq4Qj8ljrLdH77CyQPWlCdHC0Q1e9rmmuC+oQN9Q4LwcQg40L6eyqm0uEpXSUqe3fKpkkqL+Y/o+07SrahNEO0T0LBsvOitf4xsLqiNTB32wtqaVKosGLO2mhUrS93+PZ4D99wPqzMJVcbEyA8AAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-ptz-expand:hover .jb-pro-ptz-expand-icon{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAMAAABF0y+mAAAAM1BMVEVHcEyZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZn////i4uLZ2dnIyMjExMS8vLy+iXNeAAAACnRSTlMAYomLxwEm9+NCLo6DKwAAALNJREFUKM99k9kWgyAMRIMmEMLm/39tKaVKFJkXl3sYJ4sAXeQ3ZOcYd0+gRYblFBuFLYoS2ot5lpvYn8zJQ65TO2GVNmdCmQq/qczw4gjpejD14BgmhziEIvCjVRlPioftHW6A7xBB1a8CCUMvsuSqEkPM7eZX6h8GrQ67bYpNIbRL6rb4/k2EfVXKsgmqfQrW9qnGq96a28jGQG1ky2HXpVysyYyeDIhWq7le6ua9P36HD6+2GRi8iBZBAAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-ptz-narrow .jb-pro-ptz-narrow-icon{display:inline-block;width:28px;height:28px;background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAMAAABF0y+mAAAAM1BMVEVHcExfX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX1/9/f2/v7/y8vLUObqxAAAADXRSTlMA3IrE6SZi9wI+y0gNXAn3CgAAAI5JREFUKM+Fk1kOwyAMBQ04bJHT3P+0JVUMNMWv8zvSk1cipfjAKXHwhR7k6KTjYp7dVuWLug1XWB5wz96T/JD2O3Phmv0k5ypL6lVVFIPYpLOka5WKSSFvS0/BloHYlkza5HkMzrvVLo8ZlRr7mtFYWBBsBQ4BjC//GTxcGVw2PpOVHQ6fJj7qS4936OoN2K4e5yE6N1UAAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%;cursor:pointer}.jb-pro-container .jb-pro-ptz-narrow:hover .jb-pro-ptz-narrow-icon{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAcBAMAAACAI8KnAAAAJ1BMVEVHcEyZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZn+/v7X19ckk9ihAAAACnRSTlMA9+NCAsuKJsRiPv/2GwAAAJlJREFUGNNjYAAC5gxFoTYDBijw1FoFBIumQHjsUavAYGkBmGu0CgqUwRqlYNyFIO2Fq+BAnIGBJQrBXerAwLkKCUxgYELmKjBYIXMXM2Qhc5cxdCFzVzBoIXMXMYAcsRsMdgEdgs4FKT4DBqdAitGMQrMIzRkojlRB9wKaB9G8z+CMGjgshjCuMCjoWNxRAxYt2KGRYgJiAQAnZcjElaB/xwAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-ptz-aperture-far .jb-pro-ptz-aperture-icon{display:inline-block;width:28px;height:28px;background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAMAAABF0y+mAAAASFBMVEVHcExfX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX1////9fX1+kpKRzc3ODg4PFxcW1tbXW1tbk5OT29vaVlZVmZmZ8vCMFAAAADHRSTlMAxGJ5Mssm9+NCiYtiH91SAAABAklEQVQoz41T7Q6DIAyEJQooUL55/zddhVazzZjdHyqXXo8DhWCYTWqltNyN+MZLuxP69UGti/vAsl6c0e4L+tQ2yv1AEbvecMhO5cXdYhk+6aO3WGrNAMwentlMz/ZAKIlNoRsqY2wtFWu9t8wasc0iYVN0LkQfrG1zbxNyrIBcntOQrH1Ukkb60QcxYF1xMA2dh8zWj6ZDsLCsIrL4Ds5Hm9FMbCEROWUB0COaLXEIZJKV7CKybGO7UuxjxY2C/TkMbxboKBQCxgMN6MCJQ6Ch/QjOZg/B13LGx8FDTe3IFvl+Bc9XBi3UWoex68qeL/vxmdyxyvz3NJ8f9dDef36HN7koIK2LjxB0AAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%;cursor:pointer}.jb-pro-container .jb-pro-ptz-aperture-far:hover .jb-pro-ptz-aperture-icon{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAMAAABF0y+mAAAAOVBMVEVHcEyZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZn+/v6cnJzr6+u/v7+xsbGlpaXNzc3b29vqh7uRAAAAC3RSTlMAyRjKA59J/3PzPhe1wxwAAAD2SURBVCjPjZPrssMgCIR1mkYtisD7P+zBCyZpM5mzv5hs0M8VnZvaok9BlXzc3FXbO5z0vtifFC5Kn8OL4UfxwVvuHm61d5Z0b6ZGZZwZpQAUosWsjVZntVS1sH3ZFo1IRVYfGXgx+VGwNkkIVbhq9/jm3cAhaNv1Uk3IA8mNn7D3kbQeWK3TLH2jCthrDFcTMwUWaKiClc9mJtJWhS3SF5BpJqMQW1b3xwnkDahMoHYomkeJRgSENA/MFsKML7fgoCBVbGvM+Cx4JcKWbWHKK/h1ZYS1Jy/nK3u8bB3KhzG5deMxtfv3aO7/Heq+9ms8h9fxHP4AHzAWU9zlWNgAAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-ptz-aperture-near .jb-pro-ptz-aperture-icon{display:inline-block;width:28px;height:28px;background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAMAAABF0y+mAAAAQlBMVEVHcExfX19fX19fX19fX19fX19fX19fX19fX19fX19fX1////9fX1+FhYWbm5vz8/Nzc3OwsLDi4uLDw8PW1tZmZmYgm6a+AAAAC3RSTlMAYmOLx4kn9+NCIVJiPGAAAAD+SURBVCjPjVPttoMgDMOJAqOU8uH7v+qKFN2c597lF5LTJg1VqQG3aGuM1bNTV0wWDtjpg3pq+IB+npyzcIE9ejsDXzDCrjccs+tOariF3n2OLyw5xko0vh9MDjNb9Q0hp2GK3cixlIApe4/JD9appR8SFxWAUFLg6n63iB1irnY1Jv0mlrok7nUdcZRa1YeshxBA9iijChlxI6iZEaBgSEL2tkRcymPGGJpqlbZ6uDg0WR/F0DwuMpxDkYwiIXA8hO2uMJdGCCK6teB8RQoY8xGfevQjxYQt25qoRwDT25MRBjZ7GtP/P/afa3LHmrflXa+ruf661Hvv+et3eAF6Fh3v+sSUGgAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%;cursor:pointer}.jb-pro-container .jb-pro-ptz-aperture-near:hover .jb-pro-ptz-aperture-icon{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAMAAABF0y+mAAAAM1BMVEWZmZmZmZmZmZmZmZmZmZmZmZmZmZlHcEyZmZmZmZn///+qqqq9vb3z8/PMzMzo6Oja2tpXGg+mAAAACnRSTlP/JomLxwJiAONCr+rW2wAAAOtJREFUKM99U9sWhCAInEpLBS///7WLEWy7p9O8qEzCMBIOQ15DAlLYsoegS9yFMKQ93skl4Adh+ZI54Q8pG5nxgKzkgkcsk4zhmQxRyN1OPHqtncjOu5AuppcJ6s1EHTA1YzC3Wgq3YmzGqpsmlwZAo7F8oLEVKoeE6+TbSxK0JJ/3FLOwFnUxzXuoltYDDMLoAlmYXLAWIrkqbdZKs+q4KBfkNV1uwGaBim9TdLWS3R7iGRvCNTPB7JvGlc5EXK8cKbrxooint73RzXh7Msl6Oj/uT/b62O9j8sj6gMXX0Xwf6jP3Zr9DtNAHTYMMXrXSK0YAAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-ptz-focus-far .jb-pro-ptz-focus-icon{display:inline-block;width:28px;height:28px;background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAMAAABF0y+mAAAAPFBMVEVHcExfX19fX19fX19fX19fX19fX19fX19fX19fX19fX1////92dnbs7OyFhYWjo6Pe3t7Ly8uxsbG8vLyG+Q0EAAAAC3RSTlMAiWJjx9wm/0Lti7mfpe0AAADaSURBVCjPfVMJDoQgDERFC/bg8P9/XUSO6CqTqA0TptNDpSrMpC2A1btRT8wrNKzzjdo03KC3zhkLD9imbeAFhd3sG2kvZQ2v0NknfGBJZKkhBM9MxOxDKBV1N4iHi0TRHYjN01Qi7/kK2PtyNDU7DAEJgDAAN0u1jsQEFEkcVVmrqjeXrkWRmC67eqbgG7bJyvkQSQkvUvec7szpek6t9ubWJSK/uJVSm+APzHKCh++DWWuH4plQKNYOpfappcjy2VvJn9744cjGwx6uyXjBxqs5Xuqsvf/9Dj8rLhRg+bQ5VAAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%;cursor:pointer}.jb-pro-container .jb-pro-ptz-focus-far:hover .jb-pro-ptz-focus-icon{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAMAAABF0y+mAAAAOVBMVEWZmZmZmZmZmZmZmZmZmZmZmZmZmZlHcEyZmZmZmZmZmZn///+xsbGoqKjt7e309PTExMTQ0NDe3t774OlGAAAAC3RSTlP/itxixwImAELtp8B2gZgAAADmSURBVCjPjZMLjsUgCEVpq60G8Lf/xQ62gvNeOmZuUiWeKHC1cKnC5iJAdFuwJXgmf+xg2g//G54OPuTOCUOEL8WgMMCLwgPP+Abj2aF38CrnBR7whw6Bo4fWUk7MMrQ2OrpAq0GspTLLgKg1wTailNITZA0EaTkZGjIAY5NwlATah5CGRMJYj50tFtlWiapsLvAPRdtL/WOmET7QzZyl5ywzp7NWsjBJ1odsragJqeJ9HGFNZoLaJw71hMTm0O7NeDE1Z6YsU5rGL69sedmXXz0ToW8PzA/oV09T8OJR32fb7+B17Qe3WwtC9PVbHAAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-ptz-focus-near .jb-pro-ptz-focus-icon{display:inline-block;width:28px;height:28px;background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAMAAABF0y+mAAAARVBMVEVHcExfX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX1/////t7e2dnZ3W1tbGxsa3t7eDg4Oqqqri4uKTk5NImu/5AAAADXRSTlMAYieJ3MvE/0Lti4oh87zNagAAAOtJREFUKM+NU1sOwyAMY30FtoWS8Lj/UZe2gWpVh2aJH1wcO0mNqbDj4gDc8rLmiscEDdPji3rP8IX5fXLWwQWuaVu4gbKDuyPdsJMz3GLefcIPbJ6PDCEAFDlUAJiORM3NigQFAXAFlqOeRhWJyFFIHxNGvRrN0mp470U++3axGM2RAmXcXqKnkDSN0a9WIk5Sa01MpDXBQAdVtrA8lBhFnnKpsmoo5VBrhszV0KuJ5N2tP92O50iQjpzcctravoihdoi0Q1NrfN56m0VWzFBoje+OrD/s7pr0F0yUr6s5/LvUu/bz+B2ep+IHdMIV2SUZfCsAAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%;cursor:pointer}.jb-pro-container .jb-pro-ptz-focus-near:hover .jb-pro-ptz-focus-icon{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAMAAABF0y+mAAAAQlBMVEVHcEyZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZn////c3Nz09PTp6enR0dHFxcW7u7uwsLAUKT0cAAAADXRSTlMA3IrE6WIm9wI+y0gNQZpqdwAAAOdJREFUKM99U9GShCAMQ8BF3Cmlpfz/r15dAe88l8zwQiQkoRrTEa3zIXhno7lhWxcYWNbtN/fa4Q/218VFDzf4of0O8A/h3TQfOGU/ytsOj9gPVyt8warkmYEQQAgABYDxTKROz88koS6AVIB1fRCNbSI1cVUy15Jq27LGjTtyzipPeWw40/IXQkrHyZSRmqw3LaQgctFNKYzYyGACfEXossLMojFEj7J0WfdwJ3dD9uY2X25tL0Hj45mTR87Y66u9IQFsDS1bL57o7JbUDNIofvpk08eej8kTe3Hz0ZwP9UFfv8OgfgBUByCEUZhYtAAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-ptz-cruise-play .jb-pro-ptz-focus-icon{display:inline-block;width:28px;height:28px;background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB0AAAAcCAYAAACdz7SqAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAJWSURBVHgBtZe/b9pAFMefbSYWMjCjdOtmYEYqXVC3umMlBFRiT7qxkexITcdKSDUSYna2iqX+E/DG6LCQgcETUiR+5Pv8I3Kc+McF5ysZ3x2++9x79/zuLFEG9Xq9s/1+r8my/AnVJq4z/2LZfB0Oh1tFUQxd1+208aQ0GAa7kCTpMgRJk4kJXk+nU5NEoe12W8PM/wrAotIx2Z+w3MkE7XQ6Q3S4otNlY5zPUZdL7wiMBUsRIK/fDeWvhQ92XS0HrQia83cCsqoIyMug8gQ9Ho/DpF7FYpEajQa9VTBoyIZxWeEfv6IndSqVSjQYDKhcLtNqtaLtdkuigmGSZVn/XKiqqr9wqyZ1YEtbrRZVKhX3zvX1ei0Eh7Ufa7Xan8C9VRIUg9lyQZfzO19VOOugkBpAgaXRtnq97oLZ5ZvNJm0YQkBZ8m63E7YyKl5ntrrf77vlJCF/qzLlKLZ4NBqRpmmuF2LBlLOyBFYBchDKlIeWyyWNx+PUtS2Qtx+eJA6i2WzmQtMEA+8KnA+73a6N+jkJil1pGAbN5/PMfRBIZsGn3+LFvSABMYiBgpnJgZEeFHQD4EzQrOsWI4N/nrY2uPg/eeefV8WvAKfALOsWJ3jzA++rcqjhB25OXAd244nA62AjV4LGxWLhIBk/oPiF8pc9mUy+BZVnyQEzueEZUb5yjyvhBiX6BCw2YTGvdZNyAkYPZsprT/rgO/K2vDcdQQH7jes7gPcv/kvqyCcKbEVX6PxVAG76QWPGPZAIDcEZqGECTQyokpe9wp8VfNqzyA2L9M+KRzm19l1i6ZQBAAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%;cursor:pointer}.jb-pro-container .jb-pro-ptz-cruise-play:hover .jb-pro-ptz-focus-icon{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB0AAAAdCAYAAABWk2cPAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAJ5SURBVHgBtZe7buJAFIYPjsVFAok3wBUlYcUDLNvQISUSDVVCA0IUYZ8gmzcgBeIiJLwdFau8QToaQKygovI20CJBARKX/Y/jICPAF3B+yRpjZvzNOWfOzLGLLKrZbAaXy+WdKIq32+1WcrlcQe0vZb1e/8XvQT6ff7fyLpdZh0qlEr+5uXne7XZxMpciCIKMSfzGBBSyCwVMAqxpEXYEhzdeAJYtQ2u12h2aJq4gXadSLpf7aQptNBoPm81GJofEsc5ms9/0zwT9j3K5HHUSyEJ4ovV6vXkSyjHEyvxDXyCAHxGy4hEUq+4JjWQ02O/30xV65rTbQ9lKNEWjEYFAgFKpFMViMbpQnOfFPRSKWxnldrtVaDqdpnA4THalefMDinx8sDOYrY7H45RIJOy6PMibjch3F24AJEmSeo3HY+p2u7RYLEzHwNqogOUcpSvFrk4mk5Zcjry9FZCX1+46qj5dzvEOhUKGfQVyWAyPRCLqojsnEYtohpiSE5rP59TpdEhRFMN+Itw7Q3DpGq1WKxqNRurF90YC75+gnXszulBsVbvdpl6vZwpkwasDNWVw9r3BWlu5Op1OVdBkMrEzTD11RO1exmUJytb0+30aDodkV7DyjT2rBpNrG8zg3WwQW9ZqtS4CatASt/sVhAC/GA3glWk1bqcEo+TPwm0P5QeYySt9jRS9UQe54vF4fqEZkMNCdXivrw4PoJlMZoad5IeDYE7F+0KhcPC+syVotVotIQ5PdLm4CD8CGkJZfAIhzlw3SWRdM+T9q9frLbHnTnUwrfBZfPCiecQG8v3MBHj/HvAm4/P55HMwW1C9tG8a/RmsGH1CnNJ/17UakVMOx7kAAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-ptz-cruise-pause .jb-pro-ptz-focus-icon{display:inline-block;width:28px;height:28px;background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB0AAAAcCAYAAACdz7SqAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAHySURBVHgBxZc7bsJAEIbHdprQJAU1ckln3FM4J4jTIkSMRB9uQDhBlBPECIk2yQ1MSeeIxg0KZQoKKpSCR/4xtsXTNmA7v2ThHe/ut7M7O7sIFEOGYdzO5/OSJEn3KGp4ZDy33ucxP6vVqo86H71ez47qT4iCLZfLJ0EQmhuQKNlo89rtdk06FVqtVjV49kZrr86RicG2TdMcx4LWarUWGjzT5Rqjn7tdsJAi8Ch4C4op1TGl75S8GKwCPOWC6FsRNDKAL5SOZER30HcAhbFFEUFTLBapXC5v2fL5/J7tiOCXofHLlVfikRhRrSqVChUKBXIchyaTiWtrNBruYLjM9jB5jlmup4vFQqMYyuVydKE03vsuVBTFR8pIcFD317REGQlRXBJ5PSl+iktCskgZC57eZA5l/Q/Uy4lTykjYq1++p5EHb1LC9rRdKA7dT8pO64yERG/SmVM8m81OqW7yckr8Ztv2r6Io1whnLawF59fhcLiVY0ejkWsfDAYUJfRfB+snOE85J2KRvym9RGF2Op06vwRbhg9YHgmlIz7E235B2vwC1x1VVdl7jZLT3nVF2q0BsJUg+ODFTDpU0wP3PfC5a2wB+BD7CuqLgws/TQQYn7cyxYfxfdc6ViEUujMAHUlER4cKHfhbATvPjBUG8/UH1xXJDxHoYGQAAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%;cursor:pointer}.jb-pro-container .jb-pro-ptz-cruise-pause:hover .jb-pro-ptz-focus-icon{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB0AAAAcCAYAAACdz7SqAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAH/SURBVHgBxVY7bsJAEJ01CAkJKUhUULmiDSnpoKYINyBuQIgi3AA4QZQKIQq4QaChhhuQCxAXSERUSDSIb944axSS+CPA5kn27o7X+2Z2dz6CXKDT6URXq1UqGAw+Hg6HDB4V4qj8rAsh9N1uN9rv971KpTJ2Wk84kW2322csVv1BYr+gEGMo8Foul7uWc6w+NJvNjKIoHXRVOgMg74K8AXLdFWm73a7BujpdDh3rZH8TCw8JLYlPSFutVh7NG10feigUetA0bcEDxZTiDFU0L+QN1M1mc1z7SBoIBGrkcGkSiQQlk8kTWSQS+SP7D3CzJ76c3A/yi61kodOP6XSaYrEYzWYzWi6XhiybzVI8HjfGLLeDNGxoWpohF8C50CXgwMK+r0gNCuQTENnyitQgRT4BQSOlyFvrKsRdCapC/uPuFqR0G1IZExfkH94NSzkHkk+Ap4wNUiTqPvmH74gUDoe7dOYWr9dr13M5sfNxBnjQ7/dXuVwuDGHG7ieOr9Pp9CTGzudzQz6ZTMgJ2FFtMBh8HvMpx0Ro/UEeBQq2slgsatw/uoxMsBp5A64WG+bgxE9LpVIPpUWDrgv7csUE4nEdlWCNPCC0JJXEF5Wg8MchHs11CWpCVvZVkBfckksyrneHVnMEuQRXitiqPBS4lwpEJYmORkc7Qju0IzPxBZ2t+3mW/JtqAAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-ptz-fog-open .jb-pro-ptz-focus-icon{display:inline-block;width:28px;height:28px;background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB0AAAAdCAYAAABWk2cPAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAKgSURBVHgBtZe/jtpAEMYH28WJioIa+URDF8MTkAalO6cH4YIiFbk8QXS8QO6oUlCAkGjDtTRHJBoa4nQ0KBZdJApoEAV/Mp9jkAF7bXPcJ5ndtdf725nZWdYxiijDMBKr1SqhKIqKNpdms9mcRxkjFqZTsVjMy7J8x1WdL9WjC6D97Xb73G63m0HjxULAvnI1T+FlMfxBBPeEwoW73Q6we7pcViwWe8+utwKhDFQZ+IOrGr1eAH9ksOkLdSz8Rd5xu1RzBmfdFkvupwz8dmUgBENeYNAZtFQqGVwY9DZSnTVi6+Decrn8h0JYWSgUKJfLHdrL5ZKm0ykNBgOazWbCd9nNt3CzgoZjpUohlEqlKJPJHN3DJHRdp16vR51Ox/ddTiVkw70NlSTp7rRDMpmkWq1G4/HYvmANSpHghXg8To1Gw/M5W1oGVEZD07TvXNy4O8Btw+GQFouFbV06nabRaGRbhbaf8AzvTiYTr8c32Wz2p8KrSuMgJ7x6IEa4AIuivau9tNlsNGm9XqsBY9gxhOvCCi728wa7OCHhRzQAZl2pVGyXRZEoBAoFCDGs1+v2QooiUfpIHE+LBEL+VatVezVfDcp/whYJhAWBVHFvCEFCfz8op6cpORuxJRokajz98tSRae+97OJnUS/RanQLkwNQ4FrzsA2yyU0Gf/br2e12A90LlwYAkS5Pdrm/wRs+/rh1ChAshuV7wTqAQoTAarVat6gorll8YWvzXBXmbdTUcY3/sK/L+4ppmnPeF/9SCGsvAXIsH8+gDthkMFyepyuJgS0GHh3w5NNOzO0zeMHVD/R64BMDP53d93vBORW+0GVnpvmpS0NBXXDDSacwR9K5kxaPok+NUJ8VDlzlQucJvKNj63G2/U3/E78fZqx/rk0w4ggu8jUAAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%;cursor:pointer}.jb-pro-container .jb-pro-ptz-fog-open:hover .jb-pro-ptz-focus-icon{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB0AAAAdCAYAAABWk2cPAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAK2SURBVHgBtVa9jtpAEB58/EqArqCBBqehorgTVDQxPVJOiD5QAEJUeYLjniBcgRACKeQJQsQDBBoqkIigookraC1BwT+ZcQBBsNd7Ovgk2LV3vd/M7PyZgBPlclnc7XZPFovFv91uRZPJdL9fktfr9W987udyuRbPWSajDUgm3d3dPSOhBMaQUaAXu93eSKVSCryVtFQqPaBWXznJNMlR8zo3aa1W+7zZbIo4vYd3QBCEQjqdfjEkrVarzyhlAa4EvOt6JpNJ6ZJWKpUnHH7A9VHMZrNfLkjJO9Ecv3Aqwg2A1osevFs4vCQP5SF0Op3g9XrPflar1egzut9vCNVHzPS3j8EkcCAcDkMgELh4PxqNoNvtwmw20/tUXC6XSRyLqqZ7LS80CgaDqiY8IEESiQSIoqi7B53qE40qqVYsolTgdrshEokAeh9IkgRGIDPTPhJYC8SD4eg3k52RQNQi7XQ66txms+kepEUcjUah2Wxqrq9Wq6h5Pp8/4CUzD1osFuqPFwfnIsE1IBKbyDqANIzFYhCPx+EtYPmCGQxAppJlGQaDAVwLaFlBgRtAx7T/SNGNZWCg1WqpoeP3+4EX0+kUJpOJNiEqKWA49HGusA6gwPd4PMCLXq+nu4bpsK+6LVV9YMDlcqnkPKD7JyF1oFD+PSSHV9ZB4/EYQqEQGGE4HEK73dZdR+Ua6nh4gWXtD3AkfCL3+XzHZ4pfyrekIQnHApr2A2oqn4YM1TvDWkr3xbozPVAxJ0KaH1MRFllSvQG3gYztz7FtOct/mLqorZDhulD2BVzWJKW2kTZckVjBnviM8IKUQBtQ40ck/w7vAIUhnvGYz+cvwpHZbGNHkcQMwtXGnICs9YrCF/Q2GHb4e3IJBxLgo44ACsY6afbT4XDUWd09N+kpqOhTDT55Jf9/Z0b4C/UJLQCcLGi1AAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-ptz-fog-close .jb-pro-ptz-focus-icon{display:inline-block;width:28px;height:28px;background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB0AAAAcCAYAAACdz7SqAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAIjSURBVHgBtZe9UsJAEMc3l1Q0WvAA2NEp1MyInVbGnoE8AVrSqW+gT2CY4QGwpTEFNcaOEqksKKiYcYYP/xsSJoRwx8f5n7nRu9u73+7lbu8waAc5jnM6m81sIcQlqhcoOZTTsHvAZT6fv5um2XZdd6Caz1DBMNm9YRgPMYhKHhx8brVaHu0LrVQqNjx/2wOWlAtnn9MiT4VWq9VHDHii4zXAPFdJsPGPwK1gIwHk7/dC+sXgAsBjroioFZsmpznCuHKLxeIxqqwirdVqvGmcbaOy2SyVSqW1tuFwGJTRaES7CEGd8TJbXOEo4YkjG8BQ27ZT+7rdLrXbbSUcx4+P3oOIVQ4Wr0Cj0aBMJiO1Q6Q1PvsirFzSkeKVqNfrKjM+8xeCybRMbUcrn88HRSasqs2R5kijisWitB+reiKm0+mhaS5VvMwqCdIs1WYKoJZljUmj+NwqobS8D7Wp1+tJ+5EPvkWYD33SIE4S/X5faoOHgCdC+jsdKc5GnJUUGiNIzwrpbjwh76tOpxMAJ5OJyjTwKp7wP/CnvM06LeFzdPwNd4AFihL+Chom/U86/HmiAr4CGOR4M2r0fX9cKBR+8e816deg2WzeRJW15ABPXvgxRXoVPFfiDWbSAhF7iJiXvUyagMmHmZlmGYK/aXn7HPSNAWui3AH4s9EnG8ibiy94DL6l3W8jL3zvetsMpNCEAw4cKGPCc9r8WeGj/YuBMlikP+yn3EGZYjlWAAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%;cursor:pointer}.jb-pro-container .jb-pro-ptz-fog-close:hover .jb-pro-ptz-focus-icon{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB0AAAAcCAYAAACdz7SqAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAI5SURBVHgBxZZLjtpAEIbLjUFih8QFnBUrJCIOEHOCROIACStALBhOMMwJMlkgBCyYnCDMCUJWrJCQYB+zBwkJFiBe+QvZyEz86IEezSc1dj/w76pyV5dGEnS73cR6vf4SiUQ+HY9HE0MJu5GmaSNcFrvd7hn3vXK5bIU9TwsTw8Oqh8PhzhGRoIf1tSBxX9F2u12FVfVXiL3ksVgs1khWtNVqfcfljm7HgtW5l1Zrbyh4Fo7FYh8LhcLCGRDu2U6nc69YkDG22+0v98DZ0mazaQgh/tLbUUOMHy9E8eH8treDJ8lkkgzDuBibz+c0m81otVqRBAu4+QO7WecerDSDBB3RbDbrOTcej2kwGFAIvNc5dPVTTLHpv9INpNNpyufzBEsC1yF81dOVf8KslCHIEy4SjUYjIxDLDDoGKYAtDrNW13VT7Pf7azOOJ6lUKnAeySLB7jVIIezmMAS9A/igxIIUwns3VBQ+HpFCLMsKnGcjhX0CKLF2MpnQcrkMXIPzuX+KKax9phthtw6Hw7BlVqVSGel25wntqqy02WxOFnLj+xB6/HNTwmdXTqdTGTHmfKA7lhKSxAOCbPr9g90n82X6AcGfTgVxUTngtKlD+J4UAw/2S6VSzulfJAe8SZ3fiNRiQbTgHvgvI0H4Gxb9IAVwTexVmHmmQbiCD1suHy26En7xaDSa86p/A4ttrpuIT3ohpLcTxw/tAWJ9vzUaSWCLm3DXZzS+z7hELFzYjX/i8fiTu9T04x9LgQk+PbvDKQAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-ptz-wiper-open .jb-pro-ptz-focus-icon{display:inline-block;width:28px;height:28px;background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAYAAAByDd+UAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAALxSURBVHgBtVYrrBpBFJ0FFAqBqCIrUXRBk5QaUleewBBIlwSDoW1CUlzz0CSlaJJHA8FgqMBg4CWIKkpRuEfQCDAYAvSeYYfsLgss6fYkk5ndmXvP/c1HYjaQTqdjbrf7PQ0VarLWgBW1Cdput3tutVrdW7qka5OZTEZ1uVwfaBhj9jDf7/ePzWazwe4hVFVVPhwOT3cQnRFLkvS20WjMzRMuCzKFyH7/AxkAg18oQp/ME24LsgENfcwBkJfvQqHQejqd/jr905HJGpnMHIYW3iHGp5AS2df/QabpfiKHfCdCVCN1qh1hv9/PIpEIi0ajLBgMskAgcDZfKBTMYjJVL8+nh7MeS/8ioFiQbDYbtlgseA/lXq+Xt9lsxrrdLkulUmw8Hp/poLB+JC+rkpa7FysiKEokEpyo3+/zBiIrr2EU1kKmWCxariMvsy46IRJWZFBSLpf5GApgvZUSYLlcstFoxMfwHnKQN4Mi+cYdDoe/IGpmslKpxJV0Oh223W7ZLcTjcb6uVqtxLxFayJtkfSga2Sycy+X4YnhlBzAQhGI9euTRqnhAaNjkKA5Unl0yALlD0SC0Au12m/fIvx5nRxsEYV2lUrHMgxmiYMwGwmiE1qzDrSiKSv0r8QMxF2Wdz+fZer3mhXAJCP9gMOCGAiBJJpM8h6jqXq9nWO+hLfGH9ohiVoTFIEbxwFqECMoQInwLy4V3mEMe0SB7YWtMJJzoVK7fLnkgKg65BVBM8Bj5gjHwDORoGNfrdUMu9SDnfl7d+HqAEArFCYNQYoxtAODfJSIBimTWpV2Swxt8PLwiRAgjGrwXuEVGmBNXw6MxP5KXMWYTCKs4U+2COH6g59tCu6uG7A7AYxteCcypVU+EmgVZbcJxkO4HcmplIEQuMcGOTz8nyT6T7on4Npw0mMBzgDnkqUZWNfyzWujQM/FB79lVQh2xeudbZ0VE36mvipzdRagjjtFtnSBlr9nxuS9uGCidk1HPdFp1xcvsGv4CcbeEIeSIw9MAAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%;cursor:pointer}.jb-pro-container .jb-pro-ptz-wiper-open:hover .jb-pro-ptz-focus-icon{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAYAAAByDd+UAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAM0SURBVHgBtVa/SyNREJ7dBLVQELU4bdwrtFJOUCxsXEG0Ue4OK6tLKhEb/QsO/4LzChVtvGvE0sPOxtiYJuFyJBBICtOlSSAQCEnIj5tvyC676ybZYPLB4y373ptv5puZt6uQB1xeXup+v/9zs9lc4qHxK621VFAUJYbRaDSeDw4O7rvZUroQBXw+3zcm0ckbMkx8enh4+It6IWQijYlueiByI95g4oxzQXW+OD8/X1JV9e87yACNbbxeXV0dOxcUJxnn6okfx6l/OOHcnr0hhIzsFcg06jNa8obwbErKOfs+CDIhUdUbxrhJiGrknAW8HB4bGyNN02h+fp6mp6dpcnLStj46OkpbW1vOY1q5XJZ8iqTX19dPnYpkZmZGSObm5qharVI+n5cZ5ENDQzKy2SxFIhFaW1ujTCZDqVTKaabA+z4qrdy9uhHB0PLyskSTSCRkVCoV16gRLfYODw/T7e2tOOQE5zKocmRf3Mggzd7eHvEtQnd3dxSNRl3JgGKxaEaE6HEO553gOllXuQ3W3ch2d3fFyMvLS1siKxYXF0XWh4cHOYfzUMgKpE1t3Y026LouhxCVF8DBhYUFcz9m5HF7e9u5VUOV2pp8dnaWpqamPJMBKysrEh2kNRAOh2VG/q14c7XhILzb3993zYMT2IOCcTo4MTEhkqKgrPCx1gGePxgv6vW6EKJYNjc3qVQqSSG0A+RPJpPiKACS1dVVaQ9UdSwWs+33c6n+47ZYchqKx+NCvLOzI80NiWAMEkFyeM75lx5FdFhD4SCXIEJluxRbTLm4uDjmcv3RLgIYgrfILZBOpymXy0m+UImIDLLCATyHQiFbLq1gB/90bHwrcNPAILwGAaREcz8+Pso6CNsRGZDGx0eS8xXqRgh5DYkgIwZuFQPdyGACfwJ+PHGhnHKUOnkEetS4U72Co/uNWdoC3yovUVqBiD1EZW4fGRk5MwkBjjKIBRoAarXa12AwWLARIpdY4McC9RcnR0dHZjPabhosMOkG9S9S2/8MMLDfRKhljawjoYU4wNXby79OgavxJwrEyFlPhBZinasYH+pPPOMaNL4wMJphJZ553Bt/Zp3wHwTYnvHjbDCuAAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-ptz-wiper-close .jb-pro-ptz-focus-icon{display:inline-block;width:28px;height:28px;background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB0AAAAcCAYAAACdz7SqAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAANOSURBVHgBtVc9TCJBFB52r7jYyCXWnhcbO1aru8RErjGXWBxX2BijGG1svNhJo56VhQU2ViQsgdDQYEFDc5rQ0BDoaMgRGhoKaMhdCHDve+6QZVhgMfglm9mdn/e9v3kz6xEusL+/79c0bcvj8fjpc8V6gCY9VXqK3W73MZFIpN3I80wj03X9il79wh2q/X7fJAXvTdNszkQaDAZXaHF0BrIRcvLKERE/OQ3qYwh/06shXg8vRPl8PlEqlZ4nktoIV8QcgBxwItbfitBOvL6+XioWi2XZp8kXIryaN6FNdpSM8spvthRWUmPaJ25vb4vV1VVRqVSGBCwtLYm1tTUeW1hY4KfVak2hFe+J+B+5+QkfnL2Hh4fI1KAq/OLiQlxeXorl5WWxsbEhNjc3RbvdFrVajVvMkcTlclmk02nRaDTGETfJ1Z+wlTxWLP84zQoEAkwEodlslh+QqZDWY36hUGByp3m9Xu88Ho+HNaokfidCCAIh2kgkMlYQAOtyuZy4vb1lBW9ubnidCioa37klkw0nQrgWgpLJJMfXDUAOBbEO66GAAkOS+tSRk5MTXgjr4FIAMXULrIObz87O1CHv8fHxR03thXAkDhbahezt7TlpzkA8sc7uUngIQIhUgNRr70AWQsu7u7uBEPTBdaqboQTcCIUgXL4DUBzjTrHVDcP4BmVlR6fTYVLg9PSU9yC2CIghEG7HHIC2GluJOGYyGR6DYiDCGEKD/iErNS2sU238QnH9rGqDopDP5zm+EIJ3aL6zs8NEUAKCQSiVwxp4BFaHQqGRwkJoRqPRkEZ7tCjGAAJQHED28PDAVkirsX1kUcAc7FEXWc5c7+iQTltnpyMgHNYgUSSZBL5BhqTBHkVMAZnxKsijMbQ6Vf+/FFe/mFLs6/X6IJZ20t3dXXb34uIihwFuTqVSI3Mt0nPia3LtpVLot461V0FWLiiBZwzMWCx2xOSy5+DgIEya/BRvA1xfvlKxr+JjUBwola/Fy81u7iDCX5JwiJSPHNJm3sQWoTnUp06a57XFIrxW+0dug8guutM8EvEHpxPIJRDDH6qFA2UmrSSrg0SO5HJLjhDdUxue+bLtQG7QqR8ggVvC4beCFHumRMSxVJxEJvEfnFm91YrgD/sAAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%;cursor:pointer}.jb-pro-container .jb-pro-ptz-wiper-close:hover .jb-pro-ptz-focus-icon{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB0AAAAcCAYAAACdz7SqAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAANwSURBVHgBtZa/SyNBFMffboJaKAS10SZ7hXqFegGbCyjmUPTAH3eHlZWmULG6u/Kqi/9BLEQRIdoKigf2l1Q2ChGtBLmtFAQloPgL1HvfRyZuJhuzBvOFzezOj/eZee/NZAzyoMXFxYjf7+99enqK8GNxlZVtyhiGYXOZ5vo/MzMzW17sGaVgPp/vN2DkTbZpmqs8wfloNJqh10AZZjEs8QpYAfzx8TE6Ozub9AQFkGf7l55dWLbYTmxqamruRehbAl8CG5UEOvTNmWSmekHCVAgIJVgB9eHHD1bJSTPp7NXe3k68Hejg4CBvdF1dHTU0NFBVVRVdXl7S/f09nZ+fl2BS4Pb29geXMXyIe5eXlxM6FMaHh4dpY2ODGhsbybIsamlpyUFQog/geE5PT2l3d5eurq6KgTPc7x22kpGN5T+3Xl1dXdTa2ipGDw8P5bm7uyvoB3hTU5P0t22b9vb2ZFIu+smxjSOmEbfW2tpaAcJgMpkUQ25ACG4+Ojqi7e1tqq6uprGxMRmvi8P1BaXJLyE34MjIiBja2dmhzs5O8iLAMUGMw3h4yCkOobDYs+YHfXAkEpGBWJ1KJMTUqzAObh4cHNSbAisrK0FTrw0Gg5I4GKiEBAmHwwUzV2pubpZJOV0KD0EIkS6TlxxwViALMcvx8fGcEdQhKzs6OvIGYxLIcEwIxuFSvEP19fXSjpzQ5RsdHf3M5XtV8fDwIFDs0f7+frq+vpYtAjAMwu3oA/X09MgqEcf9/X1pQ/wBQhuyPZ1O56/SNOO+oaGhMAM+6rM5Ozuj4+NjiS+M4B2ZGQqFBHRyckLd3d2USqWor6+Pbm5uZAySqa2tjdbX1+VbU2Z6evoX3JumIoIBHA6ATUxMyCl1cXEhQOxD1ON9c3NT9qjufl2K5a+pqdliA4liHWEc7kOiwMXOvYpvwJA02KOILwS3FoGuoTTlWDKMJJUQ4qwfDmoyAwMDkkiYIBIOsS2iJH7k7MW1JPu3VpbUyYWVw91u4oWtcjyjOSi0tLQU54bvVBnh+vKJry82PnKHAydFDI1UATFwTgHzoIgtZvPW4Cxw1VlX0YtZFhjT6wvOXrgBK+ZnjcqXimHMrbHUZXuSV43kCpE3IUTzvPfjr75s61pYWAgx/Ctndy9/WlxaCsKPzZs+xc8Ww9IvwZT+A8hTw5fcMmXrAAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-ptz-arrow{cursor:pointer;position:absolute;width:0;height:0}.jb-pro-container .jb-pro-ptz-arrow-up{left:71px;top:15px;border:7px solid transparent;border-bottom:10px solid #fff}.jb-pro-container .jb-pro-ptz-arrow-right{top:71px;right:15px;border:7px solid transparent;border-left:10px solid #fff}.jb-pro-container .jb-pro-ptz-arrow-left{left:15px;top:71px;border:7px solid transparent;border-right:10px solid #fff}.jb-pro-container .jb-pro-ptz-arrow-down{left:71px;bottom:15px;border:7px solid transparent;border-top:10px solid #fff}.jb-pro-container .jb-pro-ptz-arrow-left-up{transform:rotate(45deg);left:32px;top:33px;border:7px solid transparent;border-right:10px solid #fff}.jb-pro-container .jb-pro-ptz-arrow-right-up{transform:rotate(-45deg);right:32px;top:33px;border:7px solid transparent;border-left:10px solid #fff}.jb-pro-container .jb-pro-ptz-arrow-left-down{transform:rotate(45deg);left:32px;bottom:33px;border:7px solid transparent;border-top:10px solid #fff}.jb-pro-container .jb-pro-ptz-arrow-right-down{transform:rotate(-45deg);right:32px;bottom:33px;border:7px solid transparent;border-top:10px solid #fff}.jb-pro-container .jb-pro-loading-bg{display:none}.jb-pro-container .jb-pro-loading-bg,.jb-pro-container .jb-pro-poster{position:absolute;z-index:10;left:0;top:0;right:0;bottom:0;height:100%;width:100%;background-position:50%;background-repeat:no-repeat;background-size:contain;pointer-events:none}.jb-pro-container .jb-pro-play-big{position:absolute;display:none;height:100%;width:100%;z-index:1;background:rgba(0,0,0,.4)}.jb-pro-container .jb-pro-play-big:after{cursor:pointer;content:"";position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);display:block;width:48px;height:48px;background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAIVBMVEVHcEzMzMzMzMzNzc3MzMzPz8/Nzc3MzMzMzMzMzMzMzMzLVn6fAAAACnRSTlMA+duduRUwSGSD8toSsAAAAI9JREFUOMvV07ENgzAQhWG3lLSp6MwCViYIRSpG8AiM4FWMaPymDBKESMF/cQ0S136F353vnLuo3gp1kOYEoCXW4LFKIZAnqAXYICeASoAdzgG+cApwgF4EfwF+oDkCqIwA6gnyAKA8AaizQhsBAjzuqUHofInGIQbjRxXjMrTJuHDestR4Bng4eGrN0929PqNfzC6h06weAAAAAElFTkSuQmCC");background-repeat:no-repeat;background-position:50%}.jb-pro-container .jb-pro-play-big:hover:after{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAJFBMVEVHcEz///////////////////////////////////////////8Uel1nAAAAC3RSTlMA+rbVFUecgC7rYhEEz+4AAACbSURBVDjL1dMhDsJAEIXhdeiGpKYWQVKDWc8ReojFc4ReAlPFFQazad7lIGkb0jK/WEPSsZ+YN5mZEP5UrZIP0vgE0Kv3oPlIJlAk8AJM4ASYwAkww2+ABfQg0ImgugPYsfNBVl99kA0AsjOArAPQpRTGHiBB8whxM0y+3skXNltsvMYriIWrpWPA80mFJ5qL3gAfB1/tcAt7rzdiV+HEgs1oBgAAAABJRU5ErkJggg==")}.jb-pro-container .jb-pro-recording{display:none;position:absolute;box-sizing:border-box;left:50%;top:0;padding:0 3px;transform:translateX(-50%);justify-content:space-around;align-items:center;width:101px;height:20px;background:#000;opacity:1;border-radius:0 0 8px 8px;z-index:1}.jb-pro-container .jb-pro-recording .jb-pro-recording-red-point{width:8px;height:8px;background:#ff1f1f;border-radius:50%;animation:magentaPulse 1s linear infinite}.jb-pro-container .jb-pro-recording .jb-pro-recording-time{font-size:14px;font-weight:500;color:#ddd}.jb-pro-container .jb-pro-recording .jb-pro-recording-stop{height:100%}.jb-pro-container .jb-pro-recording .jb-pro-icon-recordStop{width:16px;height:16px;cursor:pointer}.jb-pro-container .jb-pro-zoom-controls{display:none;position:absolute;box-sizing:border-box;left:50%;top:0;padding:0 3px;transform:translateX(-50%);justify-content:space-around;align-items:center;width:156px;height:30px;background:#000;opacity:1;border-radius:0 0 8px 8px;z-index:1}.jb-pro-container .jb-pro-zoom-controls .jb-pro-icon{vertical-align:top}.jb-pro-container .jb-pro-zoom-controls .jb-pro-zoom-narrow{width:16px;height:16px;cursor:pointer}.jb-pro-container .jb-pro-zoom-controls .jb-pro-zoom-tips{font-size:14px;font-weight:500;color:#ddd}.jb-pro-container .jb-pro-zoom-controls .jb-pro-zoom-expand,.jb-pro-container .jb-pro-zoom-controls .jb-pro-zoom-stop2{width:16px;height:16px;cursor:pointer}.jb-pro-container .jb-pro-loading{display:none;flex-direction:column;justify-content:center;align-items:center;position:absolute;z-index:20;left:0;top:0;right:0;bottom:0;width:100%;height:100%;pointer-events:none}.jb-pro-container .jb-pro-loading-text{line-height:20px;font-size:13px;color:#fff;margin-top:10px}.jb-pro-container .jb-pro-controls{background-color:#161616;box-sizing:border-box;display:flex;flex-direction:column;justify-content:flex-end;position:absolute;z-index:40;left:0;right:0;bottom:0;height:38px;width:100%;padding-left:13px;padding-right:13px;font-size:14px;color:#fff;opacity:0;visibility:hidden;transition:all .2s ease-in-out;-webkit-user-select:none;-moz-user-select:none;user-select:none;transition:width .5s ease-in}.jb-pro-container .jb-pro-controls .jb-pro-controls-item{position:relative;display:flex;justify-content:center;padding:0 8px}.jb-pro-container .jb-pro-controls .jb-pro-controls-item:hover .icon-title-tips{visibility:visible;opacity:1}.jb-pro-container .jb-pro-controls .jb-pro-controls-item.jb-pro-face,.jb-pro-container .jb-pro-controls .jb-pro-controls-item.jb-pro-face-active,.jb-pro-container .jb-pro-controls .jb-pro-controls-item.jb-pro-fullscreen,.jb-pro-container .jb-pro-controls .jb-pro-controls-item.jb-pro-fullscreen-exit,.jb-pro-container .jb-pro-controls .jb-pro-controls-item.jb-pro-icon-audio,.jb-pro-container .jb-pro-controls .jb-pro-controls-item.jb-pro-microphone-close,.jb-pro-container .jb-pro-controls .jb-pro-controls-item.jb-pro-object,.jb-pro-container .jb-pro-controls .jb-pro-controls-item.jb-pro-object-active,.jb-pro-container .jb-pro-controls .jb-pro-controls-item.jb-pro-occlusion,.jb-pro-container .jb-pro-controls .jb-pro-controls-item.jb-pro-occlusion-active,.jb-pro-container .jb-pro-controls .jb-pro-controls-item.jb-pro-pause,.jb-pro-container .jb-pro-controls .jb-pro-controls-item.jb-pro-performance,.jb-pro-container .jb-pro-controls .jb-pro-controls-item.jb-pro-performance-active,.jb-pro-container .jb-pro-controls .jb-pro-controls-item.jb-pro-play,.jb-pro-container .jb-pro-controls .jb-pro-controls-item.jb-pro-ptz,.jb-pro-container .jb-pro-controls .jb-pro-controls-item.jb-pro-ptz-active,.jb-pro-container .jb-pro-controls .jb-pro-controls-item.jb-pro-quality-menu,.jb-pro-container .jb-pro-controls .jb-pro-controls-item.jb-pro-record,.jb-pro-container .jb-pro-controls .jb-pro-controls-item.jb-pro-record-stop,.jb-pro-container .jb-pro-controls .jb-pro-controls-item.jb-pro-scale-menu,.jb-pro-container .jb-pro-controls .jb-pro-controls-item.jb-pro-screenshot,.jb-pro-container .jb-pro-controls .jb-pro-controls-item.jb-pro-speed-menu,.jb-pro-container .jb-pro-controls .jb-pro-controls-item.jb-pro-template-menu,.jb-pro-container .jb-pro-controls .jb-pro-controls-item.jb-pro-volume,.jb-pro-container .jb-pro-controls .jb-pro-controls-item.jb-pro-zoom,.jb-pro-container .jb-pro-controls .jb-pro-controls-item.jb-pro-zoom-stop{display:none}.jb-pro-container .jb-pro-controls .jb-pro-controls-item.jb-pro-speed{padding:0}.jb-pro-container .jb-pro-controls .jb-pro-controls-item-html{position:relative;display:none;justify-content:center}.jb-pro-container .jb-pro-controls .jb-pro-playback-control-time{position:relative;justify-content:center;padding:0 8px}.jb-pro-container .jb-pro-controls .jb-pro-icon-audio,.jb-pro-container .jb-pro-controls .jb-pro-icon-mute{z-index:1}.jb-pro-container .jb-pro-controls .jb-pro-controls-bottom{display:flex;justify-content:space-between;height:100%}.jb-pro-container .jb-pro-controls .jb-pro-controls-bottom .jb-pro-controls-left,.jb-pro-container .jb-pro-controls .jb-pro-controls-bottom .jb-pro-controls-right{display:flex;align-items:center}.jb-pro-container.jb-pro-controls-show .jb-pro-controls{opacity:1;visibility:visible}.jb-pro-container.jb-pro-controls-show-auto-hide .jb-pro-controls{opacity:.8;visibility:visible;display:none}.jb-pro-container.jb-pro-hide-cursor *{cursor:none!important}.jb-pro-container .jb-pro-icon-loading{width:50px;height:50px;background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8BAMAAADI0sRBAAAAIVBMVEVHcEx4eHh4eHh4eHh4eHh3d3d4eHh4eHh4eHh4eHh4eHiqaCaRAAAACnRSTlMAikwX3CxpwZ7zIGi5xgAAAZ9JREFUOMt9lb9Lw0AUx2Njqm4iGEqmEnBxslKUdhJctFMVcW5wKZ0CLpJJQRw6iVqQbg3FtPdX+l5+XHJ3796bQj557773fe8ujtOI+6jz5p84dHjTkYD4+RhT9CIRZWRPJr1bChnbY532GhT4oUpbI6HEuqvgIH9544dh9J4/rpr0Ms8oV3zMNT7X1MXSmaznzfHjM4n72moe5n8ryYrW9rKRvgf0S93JA7yKa9lbzUg3keJb8OVCtwkrFmoO4MnsAuj5rGqnZg+GZXUXkl9NjEui9n3YA9XgpMgakLXz6ujMTIgrCkPVv0Jil8KgKQN/wRN69hLcb1vrbR2nQkxwiZTGQ5Teb7TO8PUaS8Q03sE+zkjP8qbjzgJtEhRbV4gnlkOFeM7hDYNdxPbiYFvKSHN6L2NmY5WzMYPtplZdTxncRvn2sI+DHIoug22jWMaA12Y7BrXzrG8BX32XPMDKWVzw1bdMOnH1KNqNi8toqn7JGumZnStXLi0e4tcP6R3I635Nc/mzsMxl9aux9b78UVmn2pve8u6eR50j9c0/ywzyVl5+z84AAAAASUVORK5CYII=");background-position:50%;background-repeat:no-repeat;background-size:100% 100%;animation-name:rotation;animation-duration:1s;animation-timing-function:linear;animation-iteration-count:infinite}.jb-pro-container .jb-pro-icon-screenshot{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAJFBMVEVHcEzMzMzMzMzMzMzMzMzNzc3MzMzMzMzNzc3Nzc3MzMzMzMwv5ahDAAAAC3RSTlMAW+8S2UGVwyyZnOTRhEMAAAEfSURBVDjLzZKxbsJADIYdBQpsSCyVMlXAdEuQYGKpWFk6dWHJgsQ7sMDSpUv3PgITAQT0f7ly57ucQ45KXRAZot+/89k+X4ju9KzL4XOhlm3pR0enYrWViSRPXQIQSASkRSkIJEFRimYCuQAHSW89IOv6SH5TCsuAj68Ab1wDzqkAzqoC7AUAPtgsABgkBBgkCJiNHehGok//KRVsHqd+3Dj1/vukt3AH/Jj05s5/AmyZhFVWXDls44iVvfQWkCvgxU6g9ZdJfCLvjJbYaT3GvjOY4mQSG3SJGjhr/Y1Xohp+TGKqqzexZ/1GVGdNCitt6R8zVvb9d+JmKdl8o5sPWbtxT6zFuJcDQtk92MNmYiXHquYlZlVt1j4P6cd7fgHFW7Nhqu29TwAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-icon-screenshot:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAALVBMVEVHcEz////////////////////////////////////////////////////////NXt0CAAAADnRSTlMAWe+X2TINXUYZvctoYyuS2NgAAAEVSURBVDjLzZKhDsJADIZLCAsEg8WgEGCWGSwCgZxB4MgEAonB8wQEXoBH4BEWXgPJgEBG0mdgR3u77raRYAgnlq+9+/t3TQF+dKbZcJXSYSnzlViT457lRScKmBqILSFA3GoO8S4E+Ex5JiSJ4CbVdyOQdZNomX9D4dl+ko3NC8vFFmhPy8FIsi0ZlwLBW/LY5BxYYreUSgoFAEmhB5Rc9OCbUoXmTmDadQKTn4y6A/XTaoSKdb6KyGU6RJ7eHgpb3ABinAoil303xB6vQnRahNhXvMdre+fzOgxVrokX4jHAnBh8PALU8Eq8BqgTg/vePF8tpuPy9/NFaalSc273RizarYqfkswjifNMQ/TyTGMv4v87L+ks5gqDbc9OAAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-icon-play{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAIVBMVEVHcEzMzMzMzMzNzc3MzMzPz8/Nzc3MzMzMzMzMzMzMzMzLVn6fAAAACnRSTlMA+duduRUwSGSD8toSsAAAAI9JREFUOMvV07ENgzAQhWG3lLSp6MwCViYIRSpG8AiM4FWMaPymDBKESMF/cQ0S136F353vnLuo3gp1kOYEoCXW4LFKIZAnqAXYICeASoAdzgG+cApwgF4EfwF+oDkCqIwA6gnyAKA8AaizQhsBAjzuqUHofInGIQbjRxXjMrTJuHDestR4Bng4eGrN0929PqNfzC6h06weAAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-icon-play:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAJFBMVEVHcEz///////////////////////////////////////////8Uel1nAAAAC3RSTlMA+rbVFUecgC7rYhEEz+4AAACbSURBVDjL1dMhDsJAEIXhdeiGpKYWQVKDWc8ReojFc4ReAlPFFQazad7lIGkb0jK/WEPSsZ+YN5mZEP5UrZIP0vgE0Kv3oPlIJlAk8AJM4ASYwAkww2+ABfQg0ImgugPYsfNBVl99kA0AsjOArAPQpRTGHiBB8whxM0y+3skXNltsvMYriIWrpWPA80mFJ5qL3gAfB1/tcAt7rzdiV+HEgs1oBgAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-icon-pause{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAFVBMVEVHcEzMzMzHx8fMzMzMzMzOzs7MzMz4IlKVAAAABnRSTlMA6xIU1hVqIuOVAAAAMUlEQVQ4y2NgGFYgLS3RAEQziQFZoxKjEqMSaBJpEAkgIw1ZQlBQRAEs4QhkDeIMDgAWx1gMHyIL4wAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-icon-pause:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAFVBMVEVHcEz///////////////////////+3ygHaAAAABnRSTlMA7OgSFBXMmAA4AAAAM0lEQVQ4y2NgGFYgLS3JAUQzi6WlJY5KjEqMSqBJpEEkgIw0ZAklJSUDsISikpLQIM7gAJjhWp6XcaOxAAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-icon-record{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAHlBMVEVHcEzGxsbMzMzMzMzLy8vMzMzMzMzNzc3MzMzMzMxEZ/aQAAAACXRSTlMADPKKKeBxlV6neZ4mAAAArUlEQVQ4y2NgGDZgJhpowCURAJeYpIQENJEkCgWRgCeShAGyjfgl2EqwS7BFToZJiLg4ICTEImdOh0pwRM6cDJcIjpw5E6aDFeh8B5gECBCUYAkKCoMbNXNSOlyCgUEQ4apJJmxIEkjOVWFgxi4RgEsikGQJnEYp4pLA6VxUDyJLIAUJcRLIwY7qXKSIQvOHWCQODzKIleBPPjgTHM4kijNR48oGkajiYUMykwMAAfmZhUjBISQAAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-icon-record:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAJ1BMVEVHcEz///////////////////////////////////////////////8NopmKAAAADHRSTlMA8gyMLeRw1x2DBpWGN2QDAAAAt0lEQVQ4y2NgGDbgDBpIwCVRAJc4KIgEZM4EwCU2KSEBHySJCcg29iBJGCBLgHUs24FdYlnNYZiESksDXKJALebMaagES8yZw3CJypgzZ2A6WIHOd4BJgABMgh2XBEtpaBjcqDMHs+ESDFyLEK46aMGGkEB2rgQDJ3aJAFwSUSRL4DQKp+VHcTkXxYMoEkhBQpwEcrCjSCBHFJo/1GIO408MOJMPzgSHM4niTNS4skENqnjYkMzkAEgzyFpeX6L3AAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-icon-recordStop{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAAOVBMVEVHcEz///////////////////////////////////////////////////////////////////////99PJZNAAAAEnRSTlMAMPndsnZj1CSYPcmL6wsdoU80pOJLAAABu0lEQVRIx5VV26KEIAhMA++p9f8fezatFDPr8LSrjMxwiWlqzRuMYKW0ENH46c3WuGyVLXEduuO83UyK59fl1jX5EEUXD9DOaSh43XEP5zUIdZ4pAecTofVnWSt3ip4rx7N61vjnY1D30CpH4QQR8vsP+RA5Rs3KpjfMU/pMim/LgbvH7DF2F8sU0owqapKLqgnhuGWwImUagn2zhUX6WQQoYkXG9WxSAJd700/ygsCpAoliaDsPiG48GM1X5Ft/06sfp8DrDE+3DpekWjxM6366fgEcnklC+AIIWYQmPEeAaUmjFOnhCLDfxZRH+w1gU5b/DYjfNcyJ0p7dxX8B+FwxQVtvAGB5ig0d5gFA5KbzS91hI8CenvlHflfN/XvzJQnxbBEko1gbvVnPii+FadSVRUEaYylQfJtpLB+aRG4LY/80yKdUbCraM0lozGR4ewZ0Wtnj1iC7hjWKNnjYmR62W15cLlL3+2pyMR09jccyuyUrHKsvthc5xsY1iWJ0Xk3t+2XP7AnWwrAQmBH6asXubmL1Z5Lz6o992jWiu9lnMSiQsK27FS9NxhCumZgB2fTBPFsFolhZr5B/D3o9sJAI6skAAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-icon-recordStop:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAMFBMVEVHcEwimP0imPwimP8imPwimP0imPsimP0imfsimPwimP0imPwimf8imPwimPwimPxLmg1rAAAAD3RSTlMA15sisGUvdz3szYwMT8H+hDJEAAABx0lEQVQ4y3WUO08CQRCADxBQchBiMDE24KswFlw0Wtig/oHzUWglJBZWio3GDjUxlhhrEzT+ABMrO2iptLLVRluDggI+xtmdXW73LkxxNzvfzuzszNwZhhDzdOxqaPGgYrgkOgFczh90ezAJQmpL2v6OHYnqk2aWxOTtAnu/O/Y5XNZXmTZjo3ot7aESwLdFeqAM0MoJkMf9ltwVQJ9PcQN0UFIJogvdJgLQVFMsAlxyBaPmVBDCE8W7qd+2SDsx0q4OwhSrCG134W54jDfKLjDNxaL8/9AAMM/solptRnoALBbwEPWYrOEzLnrZsTGoMW+fBHG2SiLPUNI6KMOH8QS/XsCMBYQekIEv7NGZF/Rht2yqmA4i3UG9O0iTqgMfhirDhRdU8XJZqqEO8tDAqje8IIt1r+I5HmBjfD9AxQ1MgJQRpc6GJRALHOAS1WRlhMs4VaSFzwIWzCUF3op71kdNsNs/FDCuA58YqCQl7IhN3WbDnlLtfjnuON515WM17c7w41QPOuBIzDT5wqi0T4ESGV3gjtTjkuPATwHoX9+cPRlmmvJ57YAir2qKy459QL/UhrS/uAu3xf8KiX3DI+b22t6jc9F/qfaum9E1pJ4AAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-icon-fullscreen{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAALVBMVEVHcEzMzMzOzs7Pz8/MzMzMzMzNzc3MzMzMzMzMzMzMzMzMzMzNzc3MzMzMzMxdHBitAAAADnRSTlMA8AwGYt0aUcg+til5kgmZywUAAAGWSURBVDjL1VM9SwNBEB12IcGkMagxNktQSZFCYimIJAqKpZ3Vco3YBYs0NkKQgBg4ECtLFSFVCGgQrERBsLayPE0Ip7n5De73BdKLTrE3ezPvze6+GYDfsAQKy/Rz0i/OZJjY9XREuohTKulS+ZFGiADfyZXU5uHktI44VH5apDx554aXwJqloiIwiEsStAjCAsRNF1jCmGqa4Vc+BvS4JkjwzyPE6xiwzsxxeTbZxqjkANSWZFkoIj5bQBl4aBDfkPDNpeRRialB+SRAFz8UU1sAaEUjSCDoJ7iukZJ1V+c01bFczM1pWaa+a0Rp7MHn4V8Z1R9vLLCv9WjKdVFfk77JP+bZdz35YAfKXx6KhKp93abUYVbrj49g9aAYSuFCLbPUwzdCsYEWTloXgw1oGwQbENeuKwxzXhxwAADRMFd+zzRc6AAASY6RH8VjUHaXTrlOpDgCUP3gelc01e2d+f16cWbnQ46BGCRNVsWAWQJVw2xGfUXVv2k1OsLfazXqblzS99u1FwKFvBJioXBY2+r82U75Ab7O0ypVV0wKAAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-icon-fullscreen:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAANlBMVEVHcEz///////////////////////////////////////////////////////////////////+GUsxbAAAAEXRSTlMA3clDHfdfDQbsVG00u4Cqkr04dRsAAAGaSURBVEjH7VXLdsQgCPUBAROdjP//s1UTDUxsz3TRTc+wC94bHsLVmP9hkE8LIdvgupt2tFhcpy2CMZyVxNePEoqDp4hwEGz5PTqWoZNzLrmD9riltBEYzzpZQ8bweXy56Qy6Tivsp5JQYtawuMH3eJlSxIJtdSSa4xer4lMB89pK23mKrwjZVpsRzLq35vEE3+r26h6w5EKppcp3fP2lIpTPWJvoXoobeNI1sM3haHvx56tu2sdElJ54GbnPQ7RZ1sCpl8qPEMXBNQ8vN82jNbzLCPzGSDOZj/2Bqd19R1rELIEbDFrUJfKYdlALbDuDMko/hz7t8DqtCfr8h1Vt4rn7eh/6Ph37ch20aW8McsfGCOXzcr+GOlQG1rJ2HSHUDO/4Mu01qVAqTCpCJfgZ3phTS2pKm5aZOMUbs7Q6nk6L8UzRh6W78jH+gD/VRxHokPuNgUGTaPPR+zDR1mrlvcGgwkAVacSbeoN4Z0rb5/6XLrW/2GTLk2NhXHRKzrqAt9cD4rr4ddvae0NAYgOICdZyvPj4UYRf2BdfbB8iWvnTUwAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-icon-fullscreenExit{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAG1BMVEVHcEzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMxi4XDRAAAACHRSTlMAf3WqJmy+7azWNnMAAADNSURBVDjLxZQ9E4IwDIaLfMzCOTDSOz07OjLir5CR0dmJFVHIzzZtnMzbOzcyZHnuaXpJWmO2ji4GhpAzzZeQzw8FKCj1pMHss9OgpwsGOS0YGOcVUMPsfBVkmJoVCBJW0FFB6SFIaMKAlRGDnEiDkuM00lP3SmL6H5QSh+iIr9ZWVWntUV9Z4qWbHAWrhcUYNLC4Wwm3xb1r2mOQYoVn2EKFAVb81KHiQQq6L3vSUoMBUmSzgCKbVeiL3eTp3Odf8H1sxRAZZNZt/Vt8AHcPQbiQQVF+AAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-icon-fullscreenExit:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAJ1BMVEVHcEz///////////////////////////////////////////////8NopmKAAAADHRSTlMAe4Fzh7MZbKPtN8gpX19xAAAA3klEQVQ4y8XUIQ7CQBAF0CWhKQHDGtQKQFcURUgqEARBED0Aoqp3IKnoATAEW8MNOACmhQYKcyi6uyjmr+aLqXj56bSbVoh/J3HBxcw0ZfA2c3FiQLGeQcWh1lOVDDJTAeCbCgAR6QqCDj0xCEU5Bl2BIALKMwhdKjGILRUYfCIOEynlvABANk64M5jabJxHfJY2I76yzYu/ZCc0s1WbNYAQ3jxqwMoGHoqWGHpUQajEgcYYcKWFtjLE4FGJQewoxODRDQOqKPPcHl9sfzSXa/0L349tEDsOsp/8+2/xAY+BZBY9KhM5AAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-icon-audio{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAIVBMVEVHcEzKysrMzMzMzMzMzMzMzMzMzMzMzMzMzMzNzc3MzMz8gU00AAAACnRSTlMAL0jMZKt96hGJsSKv1QAAAJ9JREFUOMvN078KQFAYBfCbJEw2q6SUyWxTnsJT2JTJ6D38Gb6n5PpT6BwbuaNfTnz3fEp9fZwAP7czD0MsGCzBYJcEYsGwBEHQQRB0EII1CMAWdAOzyJUvJ4jyDVyZVHKGpj9guEI2IuhaDFadYnCkIm9I+kPgn8t+kI7kOsT72HcwQnJR9Gofy8DrwwtHK8pLzdeALg5fNb6cdJ1fOjOGYrl5CLFcggAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-icon-audio:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAJ1BMVEVHcEz///////////////////////////////////////////////8NopmKAAAADHRSTlMAL0TQf2frEaZYt8E+idL4AAAAnUlEQVQ4y2NgoDdgUcAuzr4Hh4TaGQHsBp3BLsG+BoeE2hnsEkCDsEqADMIqATIImwTYICwSEIPQJFhnBjKInUGSUA2CSPCcOcIwB1ki5xRM4iiDDrKEzQlsEuUF2CVY0jbgkDhjMLQkEkj0IM4gQQ1EHMHOOXMiakRpTiQQtXgTA+7kgzvB4UyiuBM17myAM+Pgzmq4MyfO7EwjAAAEf+BAxqI/agAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-icon-mute{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAMFBMVEVHcEzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMztXryaAAAAD3RSTlMAHd4P7ztyiy1OnKhdx7uY2gyAAAAB8ElEQVQ4y72Uu0vDQBzHE45C3SJFaSGjUEiRpJRCBifXokkpSv0DfOBrEKxUUSoFH9ClFAUfU7c4OARRCs5WjThIsJuDlLo4ldvPe8SYxGyCt1zgw+dev+8vHPcvYybvfCR2OgUv2CoLdI62bUn3gq5UJxOomZofXPUNrIChJRklfcDSiKK2bYQ6PiCaREk0EQoYPFYa3F73F+DGsBJLmAjBAMBKakG15KAxqIhd2KuK5reRccBDNbqGJhfSlnNc/kBh4OY+vaoR5QrRC0afKgxMrKdXNKI8yxRENpyd+i0VA6wMm5IOBmORCwfAFjGwolofevbuPrvpGhRgpVaqiJflrLuUQQFRToS9l894EMDe7q6yL7/G5wMATc5mQCiAvQo3HAbwLtyYHQZgTxhohgGUa/CP12EA16W2/Ou4ZEj1dNG9oPMkZGiwJWQ8j+huPoJy9Z/XHTfUFSbAURveCtE5px5vs7hQDKS25FSDn2KR5Up1/lRmIHne7BvKd82LMRJbSjr5M40lmaYZ5/PRpiCpizjJyk+CwOGOzACLpSdz02QxkiuRhd8dNOwkV7zl2YX1mcySKJrQiPkXY9klSt6rkJPRwIlmzrcWSGyzHuTb11V/N0y/S6SdwdCR4m/47OIN7XOQCfwJwHGp8IcfyRdBLEZK4Uxp6wAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-icon-mute:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAAP1BMVEVHcEz///////////////////////////////////////////////////////////////////////////////9KjZoYAAAAFHRSTlMAbk2o8o0P5TsGnVojFi/XHcV9urLaq0oAAAIQSURBVEjH3ZZZkqswDEXxLM8T+1/rkw0BuwM0f131+IvDyZVk6SrL8p88QCHp8UAnWmoWoG8AwQRN4/vOiqwUuwWqiob646MMhEW+KnMLMIXffgiZoODBusb7kCzjByF7OOszkOyp4amJ7fWVPwCN6BpyWRypvANPCvi7u4aTXe13YI+KkYA5bMRTSMlLnSyGwisSH40B0FJOrKVB6iAw2U7sGgPgQ/DTPQjitCOZT4Q6gWCtGwGFbSM34ENUNSpAKTACmC31rnRgJwjDdkFAJpfkAsZcAJvCSVQB2FaWWKdB/ATMAHwIUYL21lRBZRDiC5AnsBHBUqxEyaraFMoz0AnvHNa6xDWS34FGgNf6PYAEZoCt+BroUWFVbeb5HbCqSvB2cToyca+Adjlycdawt0C/HeyScl1W/w3gsU3aAd7JF8AuAN6isr7NAogXAFeq59Ec7ifAm49hF8wCMWfVNXAeCAkjEGuBr6R5ZGJzBrl4gGniBME+w8aMMyCsNZtfaemnmYaAQ6I3Rz0fnDhHJxc93Vrr7sHWjP3XRtTba2L3EkdFVaPC6YmXxKI9DGF1YPLdiwfD2r37cL5nDVw+uKzU5K27hsXCXPtyC2uyyl0D0p2TY7VaIvFYWU0Dm8TdOXmrVp52HG4lU4K/N38PpS/Kw70dbmb/sC0WCcQwNNzzjrzUj7veUyIIyL/4m/EP8V829O8zh5EAAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-icon-ptz{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAAM1BMVEVHcEzMzMzMzMzMzMzMzMzMzMzNzc3MzMzNzc3MzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMxDm1AzAAAAEXRSTlMAHqw+E8It/gjxc03jhGDTlgAjE2kAAAI6SURBVEjHpVbZkoQgDBwg3Of/f+12gtfMbK1Yy4NampCju4Ov1y8ruNyyo9fyCibVlNW6vUu29GpWQwTVdPTernqwffHex0WP4Nro3k+PrMKCvew/PcZ95aoNsY9yua+cGxTZsnf2K7ch4CAdGnWwYx/5LgKZCgxGdrhH3BeqNmnwviFXPZbQJmcM25HJ5n7/Pczr2QqksMJfO7BJOHLKLWFdMiL1QXYRwFagMklb4GB1zS7s8Le3fqH7Q28tVLkKdIzeaOJB2OKtY8KfTQCUa4++dNsLbrqpTR7xguHGt8hfg8P+seuaEkNdBjahzOD7g1cHP21SL2LtMNBKMdTRJjffTX1wVgrsEb1ITJU6QknwYJAcQky2cE02NbzPp70KyKggtpu9xM7Ik+CBIqY+8FrYyRUkrs+MEm1TG6tG9LZxNDNFGDue63TYGgIHqUUcuNhvhyZtn5LnlDq3Juxa4noCuX0scErOpNMDCrVcHPCS5rFGuQR9KZpxnB6CQ0ZO+AIBcTPk3UdbTx1L7jLEEHsMW7ZYm8NlIFyxn8+xdL7MURYEhzd5k2N2TabxIAORwC2r00QQfNSgrnqTJfh7cDmDu9ggtV0EZFr7kGu4KAxtNDln406TLwF9iZCIwn9EfjPuncRHYm5x3NfK3cFAS5kWxljSnTFlPHBAUFg5HsCCVOd9cdwXq+027un2QJlMjqISJutCDceRtTTuT4+1Q3HWHR8cu0fh9sGvADTYH9iLah/9nPz5+/MDJnQfoIVoAnQAAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-icon-ptz:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAAQlBMVEVHcEz////////////////////////////////////////////////////////////////////////////////////1bZCPAAAAFXRSTlMAeVoYDS1pBiPv4/g6lkzO2qSxvoixscijAAACi0lEQVRIx51W2ZLcIAwcLnPf+P9/NS2wp5xkq0ziF3ZRC3R0i/l8fvi04oxx89n+RBi1sqB38TKw7lw7lNzDa3U0e57bHhJ4d567HlqGC08eLAj9Gv8XD4/OwtsdhlfCW2s9LfWtuNrMhG1uLWP17Xh14LF4m8dx1OJ9jkm85YCYch5JzDVy81on3MFYkpTNYGmHHloYI+aqlNhlh5ZSvmH1AyBUwPcMX+u/clW3XYvA2YgRGXyZIZX6PXv0l3GlV9Jp9FKcK7mytJIg8xEeBdaBtV4P8tAixexnp73tY7ZBkrk9WEL8t7ZUDqtIA3jXa8sODSeUVqw5aztT+g4QeNAgM0PGTA0+EmfVeUvU0CEW4hX+lt/zseE7jJKDSmi0EUKBhr7EAMKPvNjOA9Fz4Yk/CFgcGRSdkYOHCLRxQfzKRN5SB/b5Ot8SzzQiKqcb6ipFdCfi1JI84OBdxzarhJ8RkpxHOQszl7bpn0GpmnXq6R4OfTkwwlyUWzeQg7rSLNhNUzEUEqJF3DMHeeXgqRIaYwHimLKipK8hMZOYVfJ5oKtIFSgXk5z4KcNx3GOIPGYfPigh9YGHBNQKVKbZhxMnqq+OHfWBHARZfWm1dnfSXfJuXInplse8wy39zkisdQ5kuLY+Bpc5hwGiH8Mx1rE24DFaLqXkfrNVkjk+8JPTPF0bUw+R9MCVuA8ks/xDyF/9orMqpBQeiob5RbIbmv7/TxvoX1Oqa914TsYg7QUWx8Y7R89JQY8mY6Dat1G5GARuMOgYHY9cbL1vNvc++fk67olLk4nrQSl7457OPqdeKn+vEwm4LPzW87DyXvqIyei9znHS+cZz9SxV+Qf8nNbjn37NkDx4+PmCXzHOLUMtjgmUAAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-icon-ptzActive{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAANlBMVEVHcEwgmv8imPwimPwhmP8imP8imPwimPwmmf8imPwimPwhmP0imPwimPwimPwimPsimP0imPoLqfILAAAAEnRSTlMADprCJBnU/gXwh3LiUKxAXjJ/ELXKAAACbklEQVRIx5VW2bbjIAwLa1jM9v8/O7Iht+09MwPlpS2VwLZkJ9f1lxVG1joPdZ0u1ZIxurhv8DH6dMpQI5t439GAEc7xYPgTRnAtV7plReRhd5kDP8+fd+wzt70yPhIJzWT7/6DCJCAYLReZPMIuJC4pClSktHqbNpJO1aTmmAme3cvtWs9NSfq52CPhnJNjlbVHwgmWSWGHeQHcKFjj7fygwidf2fa4mbVOuladcnsoDn9/CKKAWf6HEtpANiJvUp9Fgr0SvocPP/sqjOCK9ktpyCAo4Kt/d4n4/6baseNKAt5XrauPN1A4ZLAd30RUI4kNfELVx+yd3lrXYIg1Bp/B/dGs5N8mPsJoVyiwkofQSlm+K9aiwmoQMDoI4wefoK/rhkESrSuV+BR2i6HZH9juLzxCtBmn6rFmB66gNJQwBOSxncT/N3FAlxAoLQfJDy2+6rMLI3aznl9fhOcGSdZzoNhex2K3TXJEVe3M4Zb6QhHuJc5BWakYIqqietcPw6FK+EHofUHRqtLEQ5X8dKVENXXgEpLOpcjwkFI30YFVHE8fyx2ShZJ/ydTKlZwZ4BCOv/af9uMi0DILe4kieynScgPbhai+DRDckTT6N6zJpI3HMghM3BMg+q9pHmwrbR0Q0D5wc0JHPy0E5Ur7Nf3Rk68LnR0NHfO28/T5P4cNr+uLFR7eEdiNxvMRbd5Onlqsis4iIVdme4di3akWOz+3T0aUnFWHa8QZrO51NO69MeLPafrNuBenxel/3d21j8k/jyxf+75OQabFxOtuT94G3Lpjzb0zBn2Dl0ep/waPidQ/p/XB60Dp7e8F/QO7WSJg4zEzdwAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-icon-ptzActive:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAANlBMVEVHcExru/9ru/9qu/9ru/9ru/9ru/9ru/9svP9ruv9ru/9ru/9ru/9ru/9ru/9ru/9ru/9ru/+3uxEqAAAAEnRSTlMA5q0cR/PC/ggSKtN5OIhaa5izIOiAAAACV0lEQVRIx5VW2ZLjMAiMToNu/f/PboNsJ5PaKWv8kKRkWkDTQF6v/zyUfO+JX9sP1dKKd/v2acQcm992kbo1R4il7iHIif0BRNtCUOozH4cikAdt2YfjRLTnzN15/8I85wFCI2xDzlnyMLO7R0aFoTzbFGB+jIkYLkyePvmW8d2fs2ZfZuv8It9s6zvV5uSr2LmKb9oVh37QvpjYOcf8fcO3Cb1jGqOU0SvTTd6X2KUBLgKdLzaiDtE2n+isTh8/+AX7E6/Vh/NNSyfVm10RXIe1nxXRapmsDQB7SMnkmE0IxgqvUn0jteEf1T2CHXgr0gjZllGk1HoJL7lD7fRpD20CgJcwQ6EdSh3lLK0zVfuqz2WvPlPJh7HqnCQ4MysxoAYQE0vHub/toRuqzRy5pEUvbg62MzlJQn1MHBe1x7WSAddpNDSN1c9wRMhKfi2jrICwAIsQvHkD7Al41bOrBNC1Y7QdmSg15LDokGETJB/imxYJKfmFMDqI3FjUkDS3NSEDjBaxknRYSb+4nj4kC43W2OKrkqGB8jV2Fq03YiWbhHQTpUV1mMHXWYf8HlNX7ZUQRC6iwBAIK0r0ILr1UxqKsPattAkhwSIiMl76bT/Ft/TbTy2jHQoM7Cz9isHVMb6GILl0H4DGivbw7xNc8rAtiJn3O/qvD6JT/wgs7Y370ZSdWmbZWEKiG1lXImldW7Q1jGMbZW9tUVKZmGjjGvf+EXAqzWiX5OfFSHVp/zjbfGPc3whdcbTF67V2N1e79qYMru2/AnzVYFsdWFt/+nOypv8vQvoHou4gOtSrG5EAAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-icon-performance{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAnUExURUdwTM7OzszMzM3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3NzW8hQDoAAAAMdFJOUwC/gO8ra6tUQNmVEKtAA1gAAAE4SURBVDjLzZMhT8RAEIWnpS3tXcWdQ6wgOJIKfFdUICv6AyruB5w4EuSJCwRXgUBWkGArLsEi6JVuaZkfxawguSWz/p7azLdtdt97C3ASagp+PpeXPDjHVx7McMWDCBc8qPCZB4m44YFIeOBh+ckCf9z+sCCYqi8WvA/5Nwu26cfA+JRBs4h7WmX/tr9AXcQHAPdgzEPZh5idTQBOZ3zyiModISKQGxZ7dd85E0SKfMGjM7vXeI/5AE5LvrwpcK9IOrQYB5BlCsFIvjzgrkaSjsBZbmC9XsGsAxfn8gKXpL9sSlnQFBwFTTuaKWXgI5Ar+sfHTrW6DUDO+2jEEtCNQ9wL6gNujMvvdFS3eugxGT51fBXxTvF1wLLngbT0BGphKalAy0MQ3Z4Ha2V7UoMFJKkFVAWcvH4B0OJfd9YsTl0AAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-icon-performance:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAzUExURUdwTP///////////////////////////////////////////////////////////////8/RimEAAAAQdFJOUwD2qdfrViyAwW2XORBGtSCsD6SyAAABN0lEQVRIx+2VzQ7DIAyDYfxToH7/p10CbQ+T2s33Rb1MijM3/qDG/EurolD9zSNRggBU0hFelMABmenfADhGkJDhGUFGgiX6I1AAQlDgZK/td8ELtQORiTmIq42I2bYdCD8NjzPmYQxO+rbn2S5qzEUF6YjkgcJude56X3s0SoL7LRAeylyaVPiFq0Jyx230mpeXmXVOHssRbhackhCq25Sny++xcBW1n6Snqw6BTgrqRP6kzfDcgmRLGonDWSf2OecwB491dOrEVZpNsxiyiHzWJ0Z+BbBwzaoWVb49HrqVfSkxHen7WNznLhzl8xpQlT3E9oHUtYaufB+7NY9g9ctbjFfj/h1DwXUrzDltMn1Ql9M814EQWPLmEBg4R7JSzpFQxTmSBMkLvJKOhFHfKEEnv3L/+qw3DuMPzAFH9pIAAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-icon-performanceActive{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAtUExURUdwTBGW2xKV2hKW3BKW2xGW3BKW2xGW3BGW2xKW2xKV3RGW2xGW2xGW3BKW2+P2IvgAAAAOdFJOUwC/gCvzq1RAleURc9VmrA9rXAAAAT9JREFUOMvNkzFLw1AUhU+SxtTahnZyC+IsIeAenDuE/oJQcS/FTYTi6hKcHYpDZ/EXBME95BeURpM0Me39Db4Mgk/u23umcL8kvHfOucBBKEr5eW95xoMjeuBBlyY86NOQBwt654HrPPHAca/YuUHrDQsG9eybBWa1+GLBqvS3LJiNX0vGJw/R0N6LJ+/f6x9I3uwG0D+luRU0FnmdCtBy6ZM7KvQdjgXwJYuNZVNrFfqF8IX+nFm/oBvyS2iZ8OWxgH4u1IZmU4kgfoa5E77c0jwhoTYCbTRFGE7QrXFCveCURkK/2cRBCp2gFYiyWk7Jw4AgXOmQZMAqa9uAeCP+JsViihtb9OKIPtBUuvy8jeqyHRpMhvc5X0W6Lvg60HrPg0DREySOoqQJKRbByRWbExaqlSoVwB0rwCLFwesHquttxhcsa64AAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-icon-performanceActive:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAnUExURUdwTH3G63zE6n3G7H3F633G7H3F633G633F7H3F7HvG7H3G7H3F6xOzy+EAAAAMdFJOUwC/hKbvK0BT2XURZct0z00AAAE3SURBVDjLzZMhU8NAEIX3LiSUNqI1qBMMChFRgYxAd07E4CI6HQwzEUXgKjC4CH5ABAKJyA+oaHqBJO3+KPaYYSZh9nyfyuyXu7l77x3ASSgu+flYX/HgHOc8kC4wwikPMnzhQaTueKAiHvi43bFg0m4OLPBM9sWCjyb9ZsHm8NkwPiUQT8MjfSX/fn+F/C3syJf9YB7oLsDkjIaiHix5QCNbGBmAFPve+3lXi/0viLB3ZnmDz5g2ICry5daAvCbZhSE2oIsFeC35ssJljiQbgZitIY7nIGu4wLG+xBnpL5tClxQhCANR1Q5TSmCCQK7YjftOVbYNUOxot0EsHl0uwHdFfcD14PJLG9W9HfpMho81X0V8MnwdcHvkgS4cBcqVo6QKHQ9B1a6XY1zAcSiIFg6QlXDy+gEd714RcAqEowAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-icon-face{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAeUExURUdwTL+/v76+vsDAwL+/v7+/v7+/v8DAwL+/v7+/v96T4QgAAAAJdFJOUwBAgSCbs9hZap+hQJoAAADvSURBVDjLY2AYRkAJCAygbEZBQUEBKJtpJhDAOJpA9kSYxESgKphuIaBuhASqyYzESjC2hDRilQBZ64BFgm2qMLPYNCwSkQpAwlMBWYIRzJsKYrKCxZSRncKSDFYzBSNY2MD2MqRhSFgqgClPAwwJBxwSbAk4jGKZDCKZp2JIsEOcOx0ztjQDYL5ENwsYJKrTsMSvGSgepzVg2pE5qSikPRPT8sopBuDod0ATZ54JsbZyBrJgAVAp1Ax2oPXMykjxYQaLA2CMoERUZQDMrgBUCc8CKIdzAvHJhyQJpLQLSu0TCaV2lPwBSu0KQy+LAwBuJj5UbruNggAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-icon-face:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAnUExURUdwTP///////////////////////////////////////////////w2imYoAAAAMdFJOUwBAgBvfrFmcw4wrbtGliFoAAAD2SURBVDjLY2AYRkAJCAygbEZBQUEBKJvpDBDAODpA9kGYxEGgKphuIaBuhASqyYzESjBu79yIVWIP0NoCLBIsR4WZJY5gkYiZACRqFJAlGMG8EyAmK1hMGdkp7M4gkus4RrCwBIApFwwJmwlgqsYAQ6IAIrEAwygHHEaxngJbfhRDgg0sxHoMM7Z0AmC+RAPsJ4S5NE5gid8VoHg8sgHTDh/PzM60HkzLc44bgKMf3RKuMwoQ+dNIgswJDAycUDPYjhgwMCsjxYcJLA6AMYISUTkBMLsaUCVqEqAcngPEJx+SJJDSLii1HySU2lHyByi1Kwy9LA4AqflRBKNSA88AAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-icon-faceActive{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAhUExURUdwTBCT2xKV2hGY2hKW2xGW2xGW2xGW2xKX3BGX3BKW23povfoAAAAKdFJOUwBAgRybs9hZLG6hrV9tAAAA80lEQVQ4y2NgGEZACQgMoGxGQUFBASibaRUQwDhaQPZCmMRCoCqYbiGgboQEqsmMxEowTgmZiFViFtBaBywSbEuFmcWWYZGIUgASXgrIEoxg3lIQkxUspozsFJZkEMmxBCNY2MD2MqRhSFgpgCkvAwwJBxwSbAk4jGJZAbZ8KYYEO8S5yzFjSysA5kt0s5YKc6guwxK/baB4XDYB045Vi4pCyrMwLa9aYgCOfgc0cY5VEGurViIJMhcAlULNYF9mwMCsjBQfZrA4AMYISkRVBcDsCkCV8CqAcrgWEJ98SJJASrug1L6QUGpHyR+g1K4w9LI4ALk0RHtSETFcAAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-icon-faceActive:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAhUExURUdwTHzD63zE6n7H7H3F7H3F633G63zF7H3G7H3F7H3F68TinBIAAAAKdFJOUwBAgR+Z31ipwW4yAjb9AAAA+UlEQVQ4y2NgGEZACQgMoGxGQUFBASibaRUQwDhaQPZCmMRCoCqYbiGgboQEqsmMxEowTmmZiFViFtBaBywSrMuFmSWWYpGoUgASXgrIEowgHtsKEJMDLKaM7BSWYLCaJRjBwloAploxJKwUwJSXAYYE2KUMVRgSrAFgKhTDKPbFIJJ5OYYEG1iIfRlmbGkVwHyJBlhWCDNrrMASvxageFw6AdOOqKCklrQuTMuzlhiAo98BTZx5FcTarJXIgglApVBr2ZYaMDArI8WHKSwOgDGCElFZBTC7GlAlvBKgHK4FxCcfkiSQ0i4otS8klNpR8gcotSsMvSwOAIs+RIlIrewIAAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-icon-object{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAA51JREFUaEPtmT1oFEEUx9/bnRALGxE70btkZjcR7QMiRisRbCzEQvxCLGyEhCDRBC/RoNaWFgYLFUSwUBAUDKKFFqIQ3OzNJpfCyspS8HaejNyG87J7t7N3l03gttydefP/vbcz8+YNwhZ/cIvrhx5A3hFMjEAQBDwMwzOmAi3LWhBCLDTr5/t+ycSubdtLnPOncX1iAfQAlmXdNBmkru2RVgBSSspg+5kQ4lRjv1iAIAgqRFTIMIju0i2AWNvrAKSUowDwLqP4tACm9rWmbABCiFxXKimlhu0BtPFHtdc19wj4vn/Wtu3XnPOfWVByA5BSngCAuwCwryb8Hud8EhGNltANB/B9/5BlWXcA4GCMx/8g4jjn/H7aaGwYgOd5BxhjcwCgPd/0QcRVAJhM2l3rO3cdQEq5GxFvEdH5VsLX7aKIH8MwLLmu+zapb9cAFhcXt/f3988AwJip8Jj2L2zbLg0MDHxr/NY1gCAIpohIJ2V2BwC0iUd9fX2lQqFQ6cQvtJbICSGOxHhlVOdKjuPMl8vlqzrxI6IdWUAQ8Um1Wp0ZGhryiYghYrUtgDQionxJT0al1IwGkVJeBAANvieNDQB4joglzvmilHIXAIwrpX67rmuUamfKcxoTvnoQ3/dP27Z9g4j2J4C81KBCiC9LS0suY2yMiC7rttoZuQBEQhsiopfT6wAwUvv+hjE2XSwWP0kpRxBxgohO1kPmDhAHEgTBUaVU1XGc98vLy8eVUhoqbpPLPwIx6/wqEV2ovX8AALzZ/Ng0EWgQGa1iLQ8xPYCUyx8YHjt7EWjm2I7sAy0it7ERqNWEDkeiklIJg8pFWwC1ZC6SM9NYc1oXgcaiVlxVYmVlZW8YhlMAcCnFvOkEQPqqRBqASLTneTsZY3pjapZSpwF4Y1nW7ODg4Ie202kTgGiwSqWyrVqtXgOA6Zj0OhGAiF4R0azrup87dqDJAlA/eLlcnkDESQCI0us4gOdEdNtxnK+tfkHjA027AJEgKeUVANBROVd7p3fixwAwJ4T43kp4nR2zylynAOoE/JuAiPiDcx6kFb5pAEwF5zKJ2xXZrH9uc6BTUD0AAGh639Xo6bjUI+G/NglS+p3Y87wCY+y/2ozJSGkuRDLekQFjbEexWPxVryfpjuxhllKhNtwtAESc55xHx9M1hsR0WlcOlFLHTLyv26Ypi5hesyql5oeHh3VBeN2T6TxgCtXN9j2Abno3je0tH4G/KbtRT7VUKs8AAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-icon-object:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAwdJREFUaEPtmTuIFTEUhv8fLSxsFrET3UIQRHtBRNdKBBsLsRBfiIWNoIisD1xfqLWlhYuFCiJYKAgKLqKFFqIgoiBoYWVlKbjwy4HMJXs3M5Nk7tzZCzfdvZPk/F9OHicnxIgXjrh+jAG69mCpByStB3AgQ+AcybmqdpJmEvv9SvJhqE0QwBm4lGikqD4VAaCMvh+R3NffrgzgB4DJDCPWpC2AYN+LACTtAPAqU3wsQGr/pikPgGSnO5Ukgx0DNJhRzZp27gFJBwE8J/k7B6UzAEl7ANwEsNEJvwVgmmTSFjp0AEnbANwAsDUw4v8AnCZ5O9YbQwOQtBnAdQA28nXlp/NG8HT1G7cOIGkNgKsADtepDnx/C2CG5Muytq0BSFoJ4DKAUxnC+5s8cSCf+j+0CXDBjAJYNgAA6+Keg7AwpldyAXqBHMmpwKjYyThJclbSSQBWfyIT5IF5kuQ3SctJzjcCiBHhxUu2GM24gRx1IGtj+gDw2I34Z0mrbXcC8JdkUqidFecEAj4fZD+A8wA2lYA8NVCSHyRtcGvouKtrg9EJQKHVB7Ht9ByALe7jCwAXSb6TZP+dAbC3D7JzgBDITgDzJF9L2u2gQoectV0yAD7IEffjDgC7plaVJQdgYotdLOYSMwaI2gETr51jD1SN6qDOgSobw/WAywltLxRVhBIxi7LxInaxUCHHFvmCpFkorWInoR8LheqsA2DB3LGIRdPIAznBXC1AIVrSKncwVYXUMQB2Sl8h+SYQOCanVaIBPJAVAM5aqBAIr6sAnjnh78s82aoHQkYlWYwz7YXXIQCLRK+R/Fg3BYcO4HnlhPPKIfefTYX7dm8m+aVOuNdP+1OoSow79KzKL5LfY4UvGYBUwZ0s4qYiazzY7RRqCtfZIm4qfGBrAEDle1e/0FDoUTKvUxiT3gfsaWlBbibFUsyDiKSkBK9nf4LkH19P2RvZ3cxUIVoEmCVZXE97DFXPrJY52JUy+lY3Ji2S8cxq4i3jsahk3QdSodqsPwZoc3Rj+h55D/wH5CHfQHNA9EUAAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-icon-objectActive{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAA9JJREFUaEPtmU+IE1ccx7+/N7O0BwUn24UeRKOd7LalvS+I6HoSwYsH8SCtLf1jEqWoyLJVMfEP6nlNIgi6eFChCB4UChaU0h7aQ1GQrnFSdw9e/JNs9LTFzPvJZI27m8xk5k02m13I3sK+33vfz/u9N+/7fo+wzP9ometHF6DTGfTMQF+mYNqwd6sKlFLcK++P3WsWF8nkUyr9stAeTcXN624xrgDVAUgcVxmk1lbaGPIFyFocou9fSonYzvo4d4BsYQLgaIhB0EYA174bAFaNWpuFhrthxDsxQQCMrKXUPwGbvfr2BSglYh39UjmwXYCwy2kh4jqegd5M/itdaL8+i5vPwwB1DMDIWNuJcBbA545wAs4V4+YIiJQ+oYsOYGTzGwniDIANLjP+hkCHiglzNGg2Fg3AGB3/Ugj9NBO2+4ujSSaMeJ2uc+PbDhC5aK1GhU6CeY+/8IZz9E+CnSomBn7zim0bQF/m4QqbPkgDOKgufH4EAzdZaKny3vUP6vtqG0BvtnCUwY4p01oFcOIZuCJ7elKvvo9OtLyESMN7IzeViA3VC3TshiY4Wkz2j0Uyj3+aMX5shAIhuia4kn6Z+DSPu6xjiCotAQQRMeuXaJJYpqsgOetbcBV8TZA+ANxgotRU3Hz48SWr7800DjHL6VJyQMlqh/I5jYZvFsTI5XcRa0cA/sLDv98iieMv98X++Sj7aEBCPwjwD9W2LNMdAqhJnQMyc5D9DGBwRhzukK4fK/647q9I1hoE6DDAO+ZBdh6gEaQ3V9hi27JS3tf/u3Hhv20kpQPldsgthQw0fOcnpc3fVK2EhosEmE33x9LJwKxM54Lj/Ap0SeoCBPz+qVw7uxnwmdQFOge8R1n0DDg1ISaxqSbJy0oE2pTvqhStbOK5FQy2ka6vOTVkoL6o5VaVWHX+yVoh7KMAvvPbNq1mQNmNBgGoiV55fry3R+jOweRpqQMBMO4wxImp5Cd/tGynVQBqg0UvT3z4eroyDMaxenvdHIBvE/GJYnzgb69MtjUDboMa2ceHCTQCoGqvPQBuSOZT5WT/fb8luOgANUFGxkoQYVja+Lq2iQm4ygKnS3tj//oJf9+PamUuzBJqJsY59Jz/9wh6+iJpFoIKXzIAqoI7solbFdksvmN7YKGgugAMNH3vqp9pN+vhtq5VMqT2PpAbjwrW59VmVAYL8iASCfdGBvm/bpQPrCvP1eP+RpYrXA5XKgTaBkA0Voqb1eupL4DToFo5YLlVZfadtkHKIqrPrFLIsXL8s0k3LaHuA6pQ7WzfBWjn7Abpe9ln4C11Qo9Pmb2aMgAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-icon-objectActive:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAA8hJREFUaEPtmU1oU1kUx//nvthx4cJqX3RgGLsQBNG1tq8Z7axkwM0sxIX4hbhwIygibfPMeyapunY5iymzGAURZjEDAwoVm8SPhSiIKAjtQtAmiooLiyb3yEtNm76+5L37kjQp5C2Te879/+65H+eeS1jlH61y/egCtDuCNSOQyH3cWirNHVIXKO6kYvqdenbxqVlLxS8J8Txp6Ne9bDwBnA5IiIRKJ5W2LDHsB2BmC6zqmxk3UkP6AbedJ4CZfTsNcL9qJ077VgHU8r0MID5V2EsCk2HEBwbIFdT8M/aGBkgaelt3KtOB7QKEnU9NsGt7BMyp2cOa4P8tY3M+DE/bAC7cK+xnxmUwtjvCCXzFHtRHiEhpC11xADOTjwG4BCLDY8S/MvhsyoheDRqNFQMwc292QmppEPb7i6MZgEdqna7V9i0HSNx/95MscRLgo/7CXS0IWS6VrFRs8+1ati0DSEzm18kesgGcURa+3OAfSGklY5ueuP9qGYCZzceZySKC1gQAgPkvXtNjpXatn258CmlYSOSSg/qwW+B8usH9SSM6Ec/lTxM7iR/3hgEh4Jpk2Kkh/UVikiP2MBUbAggiYjFfchajtB0QM/fuOFg64D8H8QHQTQ3CsowNT8cffdLnPn8+KyXPpWKb1FLtYJ0tbbU84asCyRYOEmiMwTtq+P63JJAYH9AfxTOFbUTlNXRyPlmTdpsAKlIXQZyDDJJGGbx7/l++BSHM5EDfg7HMm91CRM6B+fdqyA4AWA5iZd/++hWymDaid+OZ/G8EGgXB65DrhAi4Jw3NsORj5VRC4A8AW+tN2Q6KwKJM54b2HcD3EtMFCLojqVw7uxHwGdVQ992OjkC5JqSJPRXw2qlEsMpFo1OonMx9/7gE211z8iirLC1qeVUlxrLvtwgU4wBO+K2bpgCoVSX8ASqiRx682hgp/jBaL6UOBsC3pMTFdCyaaUI6HRyg0llicnptqWfdeTBMd3pdH4D/kyQupgf7HtaKZIj7gDpAdefxzOw5IjECoJxeewEQ6CZBpmwj+thvCq44QEWQmZ09BYjzLHFk4SQm/C2KIm3/svGZn/AFP+qVucYi4BbmbLnOb5rGr+zB6MugwjsGQFVwWxZxoyLr2bdtDTQLqgsAQt33LvdIe6UenvNaJUQqJ3Hi3ut+KSNLajMqfQV5EAnzRuZoEF8ivfZw74dqPbXeyP4MVSoE0DoAmkgafeXrqS+A08CpHBDTPpXRd9oGKYuoPrNqETlhD/w446Ul1H1AFaqV7bsArRzdIL5XfQS+AaeCtE+rbksUAAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-icon-occlusion{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAACCVJREFUaEO9Wn2MXFUVP+e96X5oa9UoYpUszrzzZlqLKDYhgAFaaKU2+M2W9Q8TNUQSQEsiRUjFVaHGNmoBMTUmaPwD2iIhqKR8WEBFGkLFUjbtzDtvpjYrVhpCXAtm1867x5zxvnXm9c28mR13b7LpdO65557fveeez0GYp1Gr1d4VRdF7lL3rui/n8/lX5mMr/H8wDcPwIgC4QkQuAwAVWv9eA4BJy/8sAHg7ALysf4i4DwAe9Tzvj/3uP2cA5XL5CsdxNiLi5QBwUkQeQcRHrNB/JaKZZuGYeRAA3gsAZ4nIBkTcAABLROS3xpjdpVLp0bmA6RlApVI5FxE3OY4zGkXRdkTc6/v+c3PZPAiC80Vkveu6Nxlj9ojIjmKx+GIvvLoGcODAgTctXbp0CwBsEpGHEXEbEf25l83a0TLzh0RkMyJ+AgB2TE1N3b5q1ap/dcO7KwC6AQDsRMQhAPiu53m7umHeK00YhlcDwC0iMg0A13ZzQJkAlKmI3A8ADyDi9Z7nnehVsF7owzA8Q0R+BABXIeJY1mF1BMDM3wSAcRHZ5Pv+nb0I0i9tEARfRcQdxphvFYvF8Xb82gJg5gsA4FkiyrylfoQVEScIgttyudxLhULhwSQvZhYAuJCI9qftkyrckSNHzs7lckdFZJ3v+0/0I2CntRMTEwNDQ0P3i8inAeCUPmLP8/Y2rwmCYC0iPl6v19+3fPnyvyT5nQZAmQ4ODv5aRF70fX/zfAk/OTk5PD09rcbg4/EeiPgPEfkUET2dALENEc+dmZm5cuXKlf9unjsNADNvBYD1AHAJEf1zPgCUy+UljuPsQsSPpfD/m95Is29h5rcAwO8AYC8R3doWgDopx3H2I+IXs17/XIEdOnTobcPDw3ry6zrwCKMo+kypVDoU01hreK8x5oJmZ9dyA0EQ/AwAhnzfH5urgJ3WVSqVd7iuu8vGTB23SLM+QRCoOZ/2ff8Ls2oXf9DYJpfLPSgiH+nGgfQKcGJi4szBwUE9+Uuy1orIQREZKxaL5WZadaiI+Ey9XtfbacROszfAzL8wxtQ62dysjdvNM7MGcSq8Rq1ZY/+pU6fGVqxYcSyNsFKpjDuOkyeizycBHBeRjb7v/z5rh17ma7XaSBRFuwHg/C7WPYWIV3fy9kEQXIyIu4no3bMAqtXqZcaYnUREXWzSNQkzFwBAhf9wF4v2RlG0sVQqncyiZWZ2HOfaQqGwr6FCYRhuE5E3E9F1WYuT83qluVzu74VCYWfzXLlcLuqDBYAPZvEUkYeIaBQR61m0Os/M9yDiG57nbW4AYOZnAeDWpAPJYsbMNwLAD5TOdd2L8/n8Hyy/FfbkV2bxaKgB4s89z5u1LFlrmPlSANhKRBfGAPTBrCGiatbieN7GSpoaDut3IvLa4sWLi8uWLXvVbvBUFi+NchFR00/V6+16ollr7AGpaj5JRCMxAL06VaGWNLATM2ZW4dc00yDinZ7nbdLvrLXQaDZ1iMi9vu9/ySb/BwHgTAC4kYh2ZIGw6ekbRJRDy+AlIjoja2E8X6vVilEUtdhoOzdBROdY4fcYY0Ydx0kDcQ8RXd90m+qVH9P/qwPTf9WcK5+YJmnemfmE67rnIDOfBwA/JaJuLEWDHzNrAPZwGmCNGnO53HYAWA4Aoykgvk9EX0uuDcPwBhG5KwahAjOzqqHqewNYMwhm/hMAXDMnAEEQaP76vTY39v4oiiZd1/0VALyzGYSI3OH7vubVqYOZ9fE3NEENin1LDdqkgZkFMBcVqlarG4wxv0mR4nUiWqLfHz58eGTRokXfdl33tnw+n+pVu1XZNLpZFbIq0fKIm6yIOhX10K8g4t1E9IDSa84wMDBwHBG1WNU8NIObDReY+RYA0EqDhhJqbQ4SkRYI+hotj9gCaDGj1Wp1lTHm+ZRdvk5EDdVh5h9qiaWZBhHXe57XCLKYWVXoygSPk0SksX1fw3r4FjPa4shsVqanP5DcyRhzebFY3Hf06NG31ut1fWQNT4uIWzzPu0M/d3gjTxPR6r6k/+/htDqyMAy/Y4zRPOCmmLn1zprYJ8eriLja87yJSqXyScdxHtKSi4YCVvgxRLyvjZCpFqhXQEEQbHccZ9rzvG/EsdBFIqKmVK1AYzQJl8Z/NH4PzHxV/NkCuAsRb0hb1C4x7xUAMx9GxGu0ONycD0yKyGcTuegLAJD26K4joh+nbczMe7QolZwTkZt939/Wq7BJeq2nIuIviUgr3v9LaDSdFJFjKR7vtMcYOxXVRWPMpY7jCBE1PGiz84k3F5G7fd//Sr/CW80YR8SROK2cvYFOKSUzr0PED2hGZYw5ISLHrafUx9QI2uICmFY1RORsx3FmEPE5EXne8zz1mn2Pjiml1d+ekvrmqHO+K3hWvvZJvb2ensoqCwmgq7KK1eGttnuyNqsSvVAAtGINAE9oF6hjYUsB2EaG6vWx2La3U96FAmAt28jU1NTqZOMjtbhrGxovZJXVFwJAXGYHgPPS6lVtS+dxY6PT41wIAFpe79To6Fj7j9PCdmX2TvF6vzYzLqtrgyX2MWk8M5sXcaNDRLQjeft8Vaxj4bQSLSJbEFHjsraNjZg+E4AS2obHTzRb0kxsvirXVm1vBoAT9Xr9y2kNjeQtdAVAF9kQW5PseW+zzszMjCcbGe1UsmsAMYOURveTc62nap1TRNYsSKM7eQIaO7mu+zkAWAsArwPA45oXdPNTAxutaillsTqoKIruW7CfGqRdpRaHReSj2lvo8scezyDiY1qc7dda9axC3W64UD+3+Q/fZENVhTDr2gAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-icon-occlusion:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAABphJREFUaEO9WmnIVVUUXSuiuahopOLLIqTBBgtCC01Ty8JmS/sRVESBNgiVJVZaaag0WBlGYNEPrSyiQdTKskEjpNKSCBqlzAqJSAsbYMV67vt13/3uffe+93pvw+Mb7rn77HXOPntY5xEdEkkHAjgk1G8k+VMnpuL/oVTSaQDOBnBmGG3DfwHwXeg/DMC+ADbGZwWAZSRXtTt/ywAk2eDLAIwAsAXAkvjY6O9J/pk2TtLOAA4FYDDnxmdPAG8AeJbkslbANA1A0gkAbgJwKYA5AJaS/KCVySWdCmA0gFsAPAfgIZLrmtFVGYCk3QBMDeNfAjCb5MfNTFY0VtJJAG4FcL5BALiX5B9VdFcCEBPMB7ALgPtIPlNFebNjJI0DcDuAbQCuq7JApQBC6SIAiwFMJPlzs4Y1M17SAQAeBTAWwPiyxWoIQNJdAKbZbUjObcaQdsdKujHcaTpJ25ArhQAkDQKwmmTpLrVjrKQdANwJ4FOSL2R1SRKAwSTfz5sn1zhJhwP4BsAokq+3Y2CjdyXtBMDueRGAv32ISS7NhN+RAF4D0I/kt1l9fQCE0lcArCPpyNARkbQrAAeD81IT/ArgQpIrMyBmA3D4HkPyr/SzPAAzIzYPJflbJ6yX5ARm48/J0f+DdySdWyTtBeDtyDlTCgFEkrKvXVV2+lsFJmmfMH5UAx1fAriY5CfJmIiGCwAMSie7uh2Q9KRjPcnxrRpY4vP7hfGumcqkT/SR5POyjeSVycu9AKK2cRQ4vUoCKZs9J5ocFMYPrfDu2sgBn2fOgjP2e7E7tdopDeBpAF83irkVJs4dIslFnH3eVWuZ2IWdwDbkDZTknHAEySuyADa5uiT5TtkMzTyX1ONqE4ALtzJ5C8C4Rtle0pCoXg/uBSDJPjmf5FFlMzTzXNKRYfzJFd5z/PcCujRvKJK+iFppRc2FJDnO7k5yQtnLOb7tLf2RpIu9XpHUP9zmxAo6X3R5TvKfCmNt7zwAvztPJQBWA5iSTSBlyiRNAvBAjBtC8t1YkGNi5Y8r0xHPn0pHlrJ3JJ0BYCbJwQkAH5jhJL8qezl5HrWSW0NnVItbyP4kN8cE9ucycVh0+2m/nlM184drvkmyJwHgrbML1bWBjWaXZOOHZ8bMJeluzdts13I1WyQLSF4dzb/DpsPsJJJuaBpKtKd2oR0ZClwJug6vJOHfdTE6XlxPckAY7xbRbWceiHkkJ6Z201l5efw93T8dzkNP7d/Z8C7JfckAAxgI4AmSVSJFTZkkF2BuK/OkX/TKRweALIj7Sd6cfVHS9QAeTkAEALuh/d1Sl5klfQjgmlYBuEqdVQDg2KBTXgawfwbEDJLuq3NFkg9/zRMcUOIsJTuQrVB7AZiAataFTIu8mmPFVpKuNL1LTmB3u1kpyqqV/LUY7HYXisnqDnEqijipOEObVXuEpPtiG+dGxP83WZUWd3C95YIkN+hmGlxKONqsJel6pi2pO8RhUF0YlXQKgDU5s9xGsuY6kh4MiiU9bHRCUEmyC43J6NhC0rV9W5IXRusSWaywV98rnZURJFdI2huAD1mSaaeSnBHgis7ISpLD2rJ+++L1SWT3RB9ghqwmkgzKjX1WNgMYRnK9pAsAuAxYTNLRxu+5l1hYYGRuBGoWkCQzgu4L7kjOgP3WodRRIAGQGJen33VLch7GJr8HAIdCh8Q8yW3MWwDwWS2EkqvS/YBJ2UsyvehHAPIO3QSSj+VNLMkJzKRUViaTdNHYlgSf+jxJk8R1DY3byQ05GS/vMNaSSvii/VEkaxlUUjr5JMY6gt3QluX/eYZLlJ6k+KvUUkpyqj8+OirH300pALWiLSHAJJnVMK/kusqs9RqSTjptS3C0+S1lrF5TTX266uw0gxf2FTf1McDkUWVapZsAKtEqAcIu4FJhZBkT3S0AwVib4lxCspjYCgC+yLBf+0DXYnuRdBGAI5trK+efuouPInLXodMhtCGt3g0AKZp9YB5f1Yhe923JokaHs0sATK8XXnSUXXAkbWEuzd6oXm83ZkpKaPVpSY7J01l6eZFcdESX5cu3jjDWiXHBRLvpcV1WeLGRjC8FEAfbienx6JZmdZC5tttOBuBkeW3ehUZ2FyoBCBAurWv3ZdEPd/Ka1W5Td5FR5JKVAaS2OHvRbX6mJT41eE5TM52/6M6uQNDxlzvhAdga91gusat81cDVquurPQA4QS3s2lcN8rYyyOGzfLdQ8cseLsiWu7NrN1o17UJVJ+zW123+BfogD+TkdLQFAAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-icon-occlusionActive{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAACItJREFUaEO9Wn+MVNUV/s59+wOqyM7bFaxAsDBvFqnWak0MYhBQUEqUVssi/aNJawg7bxaKScFqqKyt0gip4sK8XUKqjX/IL43RlqBSxLZWYqwWdWNh3oIlFClkebMUaXfZefc0983MMjv7Zt7MLrvvn93MPec753v33HPuPfcRhukZt+3YeCndCQpeCO3kmWVTTg+HKbocoKHWjpnEuBfMd4GgnJ7ADAcCJzx8iUlE0AGcBOMkiPYz4c1kNPzXodofNAE9fvheQCyBoLvBOA/wHunSHq7CiXM9+BdWGj39nGuxq8dWYyJdxCSh8UKAFoIwBpL/CMidTmzam4MhUzaBmpYjNwmNVoFEA9jdSEx7zzZFPhiM8dotiduYeAFIWw2Wu6TLm7pW1n9SDlbJBK7d+rev/c8du5aAVQC/Lok2dEWNv5djrJBsTat9s2BeA9AiBjaN1s499eXyW/9bCnZJBNIG0AbQKCb8OhkN7ygFvFyZUGvHQ8R4DOBuSWgs5QUFEkiD8nYAuyuJmk5Hw2fKdawc+fGtHeN6mbcAWMxES4NeVlECequ9DoxmMK9yYpHny3FkqLJ6PPFTEG0CyyedWH1zIbyCBPQ2ewYk3ndMI3CWhuTsOhb6uMQTEBWfOdGpr+Zj6ZbNELjdaTQO+tnxda6m9R/XCa74AoLnO42RfUNysJjyuvYqffyo7QA/AKCXQYuSZnhvrorelpgHSW9LSn2jK3r9P/PhBhLY1V6ld1b/HuBPHDOyZricn/jsidEXRnXvIOD+SzaoS7r8/a4Vxrv9SFiJDQDd5NT13IeGGy7mjg0gELLs9QQsQAp3OiuN/wwHgbrfHh4ju8UOEH3XB/9LkvxAbm3RW+yrUIE/MbA3aRqPFyTgFakKcZCJfhK0+gdLbKz1aUjDaJWG5xfCYKADcB9MmtM+zcpksuELMiVn5Ba7fjOgxxMvgjDKMSNLB+tgMb0xW4/UVUpth7dnCnp8so9uJbaD0e3EIj/OqvcR8PY2VPGqJL6jlAISZD9//Op4+zWSqncwcGewLh8il5eeXVF/OFc2XVDpPXDqwezeqY9AyLJfIpbHiuXcYMP+EnqLPREVUGEzMxCDcFC6vUu7mqYf95PV40eamcSUpGn8SI1fmgHLPiUFL+lqjPw50EgZAjVbjk0Wwt0J4LYgNQYOVBE9VKza17QlZglJOx3T+Hofgdq2o3dJKduSpmEEGSlnfOxWe6pwsZOA75Sgt1dUu0s6H552Pkg2ZNm2EKLxbOPU/d4M6FbHBma+IhkzYkHK+ePpKa34d9Kc2pY7VmcdrpfQVNh8OxCT+TVnutGAOZQKlAUQittxIrrgmOE1aQJx+30p8Xh+AQkC01vtR8B4VskxtFlJc8pfPLw2ezokVNjcEIThjRP9zomG+zJLkE7NZnu2EFjvxIzbMzNgH3c1zD233DgapJwd17fYM0DYD8Lo9G/s9GpX1p9ffm2nZ0DDgUAstcsVNAGMWQBtVG80UAeACk3NxTuOaUzOEkg5KVwx4BhYBE237P0A5vYTIXreiYZXpWf1SDNIrCsIwfyCE4s8rA7/qV73EIBrADzimMamQBItdrVegQuOaVSQAui96H6WjBnjAhUzAnXWsXoJt1+Ozgy1O6Zxo+e8JnbBlQ1+JBiIJ02jqW824/Z8EN5KT6R8Uv1R6dzDyTz56T0Ut89UVmk3Ut1W+xZXYlsyapSSKTy4Osu+XwKv+xFWu0aBio1gXA+BhgEkGL9xYsbP8nVrrY4VDG7JklAOhyz7AAGzc3/L6oVa7Y80gWWDIhCKJ9YQ0TO+MybwTVHpnnB7tDcIuDqXBDM/nYxF1haaabX4ZS+8SFAJRa2lrGx+gukjMJgQCllHFxLkH3wc+coxjTHq95otn08mUflLltoTXU1TfKtqqSHrJ9cXQt6Cs+x+izgni6iicgrg0wBtdkxjtwfmHUSqTgGkmlW5jzrB9W0Xai37MQYWAZioml0ADjmmcfNQHPd0cxdxhkC/NFrXdvRWKeWH+YYY+HnSNLzQ0S37OXgtlpyHaYETC3sNqlrLfoOB+/IwzjumcdVQCQxMo/mFzHvD1ertV+UbIynvPttUv7/muS9qRHVK5Xqv0hLT2rOx8NPq/0JrhIF3k6YxZ6gEfApZx68Aqc4Bq7PgqjqDMMPHWCcTzUlGw+211pHvMcRrquXimEZDxvmlRPSyr5MFMlC5hHQrsREQ3Y4Z/oVXyNLNWd7mmMb0LFiOc374Ddn1oFv24r61obCsRAuBVvgpFTqYl0/A/pyJlqnm8KXtdKt9glz+Qe5ZtNayP2ZgwKJjRiwZMyw/w7pl71JNqQHrh/nRZCyyoVxn8+W9fqpGrzhRY5IXupdCJvEiwMfzK57vYswc99KxKGdDCHaihldB+xWfDDiDNyfNyMqhOu8lD6860+TssbKkI6WuSj3oW0yYSZBnwHxKEc3dtGUbYF5Xg/k6CNHDTB9o4A87zfBHl8P5okfKNLvyDvV+BC6Ho4Uwih7qlVK5bZWRJFBSWyUTw+sJtLCSMC+oEz1SBNIda+xj8J6ijS1FQF1kdLtjVYE6ns3thaZ0pAhkMtvkUdq5OfkXHwWau96FxsdBbfWRIJBts0vCLX79qoKt8+zFRrH2+ogQsGwudtFR/IIjeyws0GYvtl8fajbKttVBaM7WGD/MwMuL7EUHwBuRoqeGq2PdV1C9TjSvBWh1sYuNrHwgAS+9pi88tgIYx0TPDFfnOhO2jwI4Iym13O9CI38WSiLgKe1qrwp1VjePxDVrsq6nOf8io1BIlk4gg5B/0S01emew/VSvz+ny3BG56M5/A6odz6T9kIB5DHwFxtsssbuUTw1IYDEI8wm4koF9xO7LI/apgd9UquYwS74HzHeU+LHHeyToLdWcHWq2KjuESjU4Up/b/B9u0kgtWdqPkwAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-icon-occlusionActive:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAACJpJREFUaEO9WntsW9UZ/33HaZJCX7S5TmhalQ1NaAzGYJUgvk7pe5QKusGa0v0xaZvQkKBbK60BWl/b8XWKaLWtUJg6IcG0P+hrCMHWlcdK2OLrFPFYGdU0ac+q9BHfFPoC2sQ+33SufVPXvfa1kyaWolg+3+t3zznfd87vu4Qx+nQfONc8yF+0KvP1NPHoxjsm9Y+FK7oSRo2+fh0I3AUpFwHUyoxWIv6EiI4o+8w8m5mmE+EowEchxH4g95rZ1myN1v+IAUR6M3eRwCqAFgM4C8ZeZuyFmHDk9OmpH2+7my4UB7fmj9wwderpWZBDs4mwHOoPmAzwn1hiV7I9+NpIwNQMwOjtvwWC1gLUwVJuIfA+s73lnZE4N3pP3M6gZSTEeoB3Q/JWs735w1psVQ0g/t6xq+T5uogkrCXQKyDebIaCf63FWTlZI525FUydDF4hGFtFYzYZnzvz82psVwVAOSCI7QA3MuMJU9d2VmO8VhnDsh8gwuMAnWfIh6p5QL4AlFEAO5ixp45yj8T1lkytgdUiH7dOBLMceIYIKwGs9ntYFQFELDtGQJyJ1yZDwadqCWS0spF05qfEtJWl7Eq2N8fL2SsLwLBOtgEybeqa7yyNJthYjEVucSYqRN1HCX3GS6W2DMtmQIRMfUaflx/P4GJ9x6+Tsu6/xGJpIjzjzdEEWEk3tvtQvZzVsgPM9zEwJJhXJMLBfcU60dTJJUzyDSGyX+pqu/Z/pfYuAxA7xPXytP17YvowEdY6xyr4dekjEydxo0oG9170QadY8neS7drbl4KwNzPxLWKqdk/XTTRYPHYZgGgqs0kSLQsExJ1dd8w4MxYAOlP25AaCCv5uD/vHIHP3FdeW2IGTU3I5+WfBvC8RDm4oC0AVKRbUR6Af+u3+kQJ7rPfwNXVi4k4CLS1vg/+Vy/H9m+Y1/82VUdmQwc+T5LbiYnfJDBhW5gWAGk1dWz3SACvpxd8705QbHNwJ5kV+9r2yj2HZOwA+b+rBH7j6wwDyZxt6CcThagqIXwCl47GeTIusJ7Vs7vTTZfDBHGVXPxGa+Y9i2ULFTrHk+92z00UAlv1bSPmfSjnXz3G58c6ej2c1TGjYCYLub4P6JAZXd+szD3vJRnr74xDiy0ld+74aHwZgpOzjknhVtx78i7+T6iU2Wp/OEZzdBcLtVWj1BJB7oFK132hl5gmmXWZYu3YYQDQ9sIiZt5u69pUqnFQtErH6rycWKvhv+ioR9l2QWLU5rJ31kzUs+59E9FAi1LTfmYFo2t7MzFebevBhP+XScTWlVCdOmG3a9uKxSMq+QRB2MvANX5vML4shraNrAWV9ZQEYVuZZIvosEdI6HQCGlUmzpA2lBcTPWLTPXscSv3DkmOeZ4WCv+ho7cPLGXC63i0A3+dnIj9NvTL1pOLP46UR67fkkeJOpB0MFAPZhxoSFSX3av/2U3XHD6m9j0H4CTSz89kmgoeGG+NwpA3kH6PGzxcAOAbQyMI8IW9QT9dNR4xHr1PWEobdMXZvjAIik7OzpM01Xl14DKxkzLHs/gIXFMgR6KqE3rXVsqqUlRKy8DX7e1IM/2nCgvzmQFQdBaAFjnRnWtvqBcK6nUwY+S4a1OlLswfnc5x+ZejDop+iOq/VNhEtytLOKwIeSevBmFXxgQt3u3FC2wwsEMT+bCAcfGbZn9S8liNcdG1J2qf8qnTsps/ApTe+Glck0Bq66mWJ99m3MeC4R0vwzRcFYpM++lyRe8QKsTo1STtgC4KsiQB2lIAj4eULXflaqG7UG1jD4aReECthI2z1gzC/+zdWLpu33ifDgiAAYVn8nIJ70BBAQX/siK480CLwKJq0YBIG7E3owUm6mnc0/JJ2VoBKK2ksXZ6DkhOoCGMkSilr2cgb+4BHIOVPXJqvfN1rH5giqT0gORLv1azyrarVL1ktueAl5beKiLKL4nuMg9BPxtkQouEfJOxeR1ubjAKaXbOJ0Qm8aPi5E0gOPE7ACzLMAtBJwMKFrt44mcKV7ySZWPxjWpWk0lrLnSsK7pY4Y9FhSb3KWjpG2fwmGk3HcD5NYlgzNcAgqI22/CsY9JTbOmro2ZbQALkujpYWs8IRVSa8vdUa53OLEvJb9sZ5Pp3F9tsettAyKJPWm7vwDKbNHCG+bIW3BqAFcVsj6BkzkuNEMa+td4woUQG0ezgYCCCyI69MPRdL93yYWLyvKJRnWOpy1n7ZXC8aLXkGWy0C1AjJS9hYE6LzZ1mTkK7EiZ6V4ztS1G11jbnCegRB3uPshms6sdL87+8nKPE2gNV565S7mNQOw7L9DyAcVOXzxOG3ZRyBz3y2+ixqW/QEAj01HD5t606+8HEdS9u4CKVUyLB819ebNtQZbKq/4VIjA70xdm63GigBkXmDJhy+reB6b0b3u5fO0nA8hOKlrTgUtLj7Dmxu8LakHfzLa4J0Zdo4oNMe9VlZ1pYyoUk/i62DSAc6wlMfzpf7ioc0lwAqsxnUEugDB7yCLd8127f0rEXzFK2U+e9R2qfcCcCUCLWej4qXeAVAjrTKeAKqiVRQItQQgaLng3BI/Jnq8ACjGWlLgTUjeW5HYUgCcRsZgfY9UG7qQ28tN6XgBUJlNCJoj6gcXlDY+PMndwmb5wI9WHw8ALs0O4tu8+KoK9Hq+sVGJXh8PAHl6vXyjo3KDo3AtLEezVzqvjzYbubQ6A3G3xpQ5nlR25TY6iLGF6kRyrBhrNwrFRHNWRpiwvlJjw5WvqvuSb3gEfs2gIAFPjhVznU+VeJTAGSFyP/ZqaJQ+7qoAKCXV+OBTdnw82qw0TYuXNjLKrZOqAbgGShvdLOitkfKpiuckyQvHpdFd+gQUHQ9B3yPGEhDOAfwGS9pT1asGgldCNTgYk5igCtSL4/aqgddUKnIY4G8xc7ialz2IKAXQ64qcHW22qnkJVetwvF63+T9nAHfjRfzL0gAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-icon-logSave{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAA1RJREFUaEPtmT1oFEEUx9/bFLFKJzG2WiknZObFxlO8RtFC8SuFWlrYGBtRRNCghV9YmFQWgoVaaAS1ULRRRKvbmYBBQezVYBOIGFMkT0ZuYXPufOxdspuDO7jibmfe/H/z3sy8eYvQ4R/scP3QBSjbg8EemJyc3La4uHgUETcx82YAWNum+N8A8IWZrxLR41ZtBQForUeY+Xarg/j6MfMVIrroa5f13AuglOJWDLfQ56aU8mzefk4ApdR9ADiW12ir7RFxXAgxkqe/FUBrvYeZXzQbY+bh3t7ed5VKZTrPQM2eNHYQ8VGGjTtSypOhtq0AcRyPIeKptCEppTfkbAM3AxhbcRwfyYJg5nEiCvKEVZBS6hUA7EoEIeJ+IcTz0JlpbpcFYNrYIBDxlhDijG88lwd+IGJ/YoCZ1xPRd5/BUA/Mzc31VavVWRcEM18jovOuMV0eWLL7tBM+RoBS6isAbEzERFFUHRwc/JD8dnjishDikg2iSIAJADiU8uhdIjqRFuZYEweI6Gmuc8AWs6EhVK/XR3t6eg4zMyKiEQ/MvOSwQsS3iHhhZmbmY61W++UIp/dSyu2FAmit3zDzTjMoItaFEFuVUt8AYCB0ElLtZqWUfYUCZHlQKXUQAJ60AAC2Nbhia8AWglprAoB7jYQwmGXVACSKzRqJomgLAJjvBh/JqgPwCQ7dRAoPIZ/w5HkXIHQGQlOHvCd56PjdEOpoD6TShT/MfD19OXeFQCPnOYeIaxYWFiaGhoZGQ9Pv5nZthVA6XWjkOsMJRGj+b/IhIURtVQCkIUJvYKUCONLf/+67tjuw+T+rLlTYLmSDCDmwbOIbF6CgC1Vba8B3m3JBuMQXDuC4iGQy+MSXAhAKESK+NAAfRKj4UgFsEHnElw5gBGit9wFAUqy9kbco1vY2Gsfxsha2QrbV1K42gIimAPDvw8zTRLQuy0ZhpcU8AMZ7zPws1ee1lHJ3LoDlLu7mAcioZFuLvYWV130AU1NT/fPz8zuyqtWIuFcI8TKXBxo7QaEvOCyQD6SUx20T4K33F/iKKVOj7yrqBWhsiSv6ki8zNBBPCyHGfKEXBGCMrMBr1mZtPxHxEzN/jqLoYbr07oIIBvDNRFnPuwBlzXwybsd74C95KWhPrxIhsgAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-icon-logSave:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAthJREFUaEPtmTuMTUEYx3//TrWdeLRUJCrReISGUBCvLVAqNGiEiASh8IoClUKyBQqPBAWhsREqnYRE9NgoV0T3yci5m9mzc2bmnHvvOXuTO8ktbs7MN//ffPP45hsx4kUjrp8xQNcezPaAmW0EDgFrgLXA0j7F/wG+AlckPW5qKwvAzE4At5p2ktHusqTzGfUWVEkCmJk1MdygzQ1Jp+u2iwKY2X3gcF2jfdS/I8l5O7tUApjZTuBlwNIk8E7STHYvQMCTzs6jgI27ko7l2o4B3AaO+4YkJadcVcdlAGfLzA5WQGR7IgbwGtjuCdoj6UXuyJTrhQBcnQjETUmnUv3FAH4CyzwDKyX9SBnM9QAwIWk2AXFV0tlYnzGAebtPP9OnEPkNWO2J2STpQ+9/xBOXJF2ogmgT4Amw3xNyT9JRX1gEYq+kZyGIoQGY2UXgAPyPt5x4V8qH1TRwDvgk6XdkOr2XtLltgLfA1qLTj5I2mNl3YEWDdTQraaJtgAVryMz2AU8bAFC1Boc5hYKbgJmtB6aKgDCbZdEAeLuOWyPrit+qFMmiA0gJrjr4yu1an0Ip4Z6Hss6hMUBu6FD3JB9PodwRGGkPeOHCX+CafzmPDUAR85wBlrgwQ5LbUueV3AHsaxGbmR8uOAGTPYga8f+0pG2LBWAOosYNrFOAqith6L5bdQee81optG7nHIjE8DlnVlB8EVa3AxCJ4VMAleJbB2gAERXfCUANiKT4zgAyILLEdwoQgcgW3zlAIWA30EvWXq+bFBvESTzQxFZqSyqdAe7i7xIAvTIjaXnIRmupxZoAznvPvTZvJO2oCzDQ5G5NgPKbRGWyt7X0egrAzFwedktFtnqXpFe1PFAsxLYfOEIaH0g6UjUAyXx/i09MQY2pq2gSoPDEsB/5QuJPSnLrMFqyAAqIQT+zloX9Aj4DX4CHfuo9RpANkBqJrr6PAboa+V6/I++Bf0in3kCazcMZAAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-icon-zoom{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAkUExURUdwTMDAwL+/v7+/v7+/v76+vr+/v7+/v7+/v7+/v7+/v7+/vxtcv/AAAAALdFJOUwBVdZCpGdZE7C3B0wnY6AAAAV9JREFUOMt1lDtPwzAQx20ghGwVsHVJhQRDlsywWKqEULsw8FhRJ2iWiglGGJvFCw8xIVVCSEwkKU25L4ftpOHs2Cclsu7v370smxCLecRh+xOH8Ja5kGEs/6dtYf1XONcWZurbwwRCQjYZ9l7uHAPAOBHpI1QC/QSY9g84ldmnAn7Z3htwsfZnvSe54eJd5hlcC7gccxTwSETZEr5+714vLRdfkFraVNtetXLpR7ha+mkHCV1Y/q8ZOW8AgDkecsIaAEIcGbIGyLUq4KcBYl0o7QAB4FZACBMrQKpaJOCZQqyAIhgayYEpgD1DZghXCvBTNJFKmCvgzmhcCEsBwMjSRx6BslYftRX0JLYKrAsLqzDC54EFMwvy58QhMM8hFNq0UpwET+sLC9/4BmEBTytyRCIbDoAEiR1Qp1dbRxfoyv9g3ogaKVuXhVZZbtqX6Ez6H23PxG4CM259QDwt/h8ABfK8nDqSAAAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-icon-zoom:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAzUExURUdwTP///////////////////////////////////////////////////////////////8/RimEAAAAQdFJOUwCCyreU7KZVRCDaZnETLwj6WaYVAAABUUlEQVRIx5WV2Q6EIAxFoVBWxf7/184AOnGUsvTBqDmXrqRCzNou1kwGtyZIQNuiD0P6evWTURFUMtIoPO+iVoGIZPkMqkdKA0jZgoJ6suQc2EoiGBldOoQ9HSDk5+GTs1Fqo9IlcEpvNv3qv0MBhSalIFSv3+MCJCY8fUaCxasycrMu9dp5VTUhubXZ6CqsAvn66ZAsx+e8fON37oT3bZ4aiRU0kDlavGSrQI95HPBZACt8FuCL16IruBVkzBeBW+CLYHvyfiDQd96IpHpOMqP++fAq9VMQ7rwrM5+6gjwG/3y/D/m8ylPYpvpAeqO7DfvwMPO9D6jnBabG56YFZx77fEjD+9AyLdYEhp8nxoNh5wmJtfY8AS+wzIZZrJNcC4h3wV8IH1p87Iyfnc6XVaAd7ICHAsebw97zgDSxZ/yvViiPuYUfTe650knM2+7Ywz9yOCklzohLOwAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-icon-zoomStop{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAzUExURUdwTP///////////////////////////////////////////////////////////////8/RimEAAAAQdFJOUwDjmTC6Y0KBVakX8s8iC3JYR1wyAAABVUlEQVRIx62V2baFIAiGcwJRS97/aU/Zbtht0VzrcJOuvl/AAabpXy1RF0F/m2h2PX5mzucEuO9gMon1MY7KlG8w4LImC1XFQmxDGVkm1DYpXi0qS1gXTEGzKoqNS1ajAxPqJDikFLcFS+aukYJffRfXnAj9kYUXFVi86wzzPjuCFRXBwS3KaC/Pt02Ww7uf1jz3BVYtX/OsyDQFDn7yswPXb+Ovs39eJJWwxrOXV4thgC+//QBf/uMAXwAa4AuRBvgdWR58CB2B+eaRG5e8QO7Jn2sIAvzhbdsDnXzev8q0BengGXv8EciH3y1CY5++yI/BRNx82g/La7lc7b0Am/tUC6n3HoZ4SbDyy5BgzSNivV6wbPXeIPOpHlOU+CjkTQKvQOpXdRdJvn+5xttWQa4EZUOzluonT6+q72X6Zb0+T/lNhQd7hg9vm8LWUhW5gT4iN7c/0ZUo8Q3AttYAAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-icon-zoomStop:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAqUExURUdwTBKV2hGW2xKW2xKW2xKW2xGV3BGW2xGW3BGX2xKW3BKW2xCX2xKW2yDN61kAAAANdFJOUwCAVKxm3T/DmhrxKw97YQBGAAABaklEQVQ4y2NgIA6wGqCLMCqAqV4HdIm9F0Ek22UMM9hiG4AkVzQDA+cmx+YyJJnDlw8wMNQaNpfevbu0QgxJgrN3JQPD3VvhjU57kESnOZqvvXuJgcEXxVFMEkDt1w11gZYwoVgue3d5SzaQSgCydZG1TMkBU8vBuq9guBcqNBNDgj0GQrMEb0CVYEmA2ViANRQZ795tQPZduADciXcVUNSthGu4hGrAJawagBIXsWoAClzGqgEocRWrBqDIrQNQDTPRXZ8A0cB41wBNQgGiQfbubTQJAagGDB0GIA0OsnevbkCTCADiu4J374ahW34JqAEIbiXMRJOAgkvMKJYgJBx6717AKiF4F4eOu+jxgQCXGHBIKPDgkBC8JYCURJDtQHYWN4oEcvpZiyR+C9lZtkgSKKG1CyGOGrxItleixjrcLFBWRAYcMIkG9NQMiY67N7AlcxAQwMwA6SBxM2xZQ3jtVRPsRQ83sg8ACMIUxzzE8wsAAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-icon-close{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAeUExURUdwTM3Nzc7Ozs7Ozs3Nzc3NzcrKys3Nzc3Nzc3NzePZJxkAAAAJdFJOUwCtKdPBGAmNTt3jdDcAAADfSURBVDjL1dOxDoIwEADQgwR07GTCZtI/IGHgAzBhM9EPkMTB0Y3V0ZXIcn/rtRR6pefgSKeSu3ellyvA9lZ/5F9p/3K7PZY8oPG5BD6MpPUSgIITzdIStifAshjRQV1PCFT8TxaicTzzwEwINOEdHVmDmcTAkRhMhMAp7iQRjcMtDhCp8SA1v0ARGIIK/gnkv0p1OBTS4QRUIpE7DiYYXTBrzcld3JIrAarXrps4AVNwRSZgExoJmIyAaAdsShUMn/JF2fh4YEkpAcgvnuwYCIb6EbbbP4PsDfLD2dD6Av1qTvAQlzUTAAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-icon-close:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAeUExURUdwTP///////////////////////////////////8kBMKEAAAAJdFJOUwCt0igUwJdJePGbgLgAAADcSURBVDjL1ZMxEoIwFESTCaOWFDapqeicnAALTiANnaWlnVewDTMW/7b+aCAb8jkAVIHN2/lsNkrt73lf8M08nnF1pAYFR/dFmAAx7SIoi4iDbRrWDMAuQFzmmxAGbjjJgjj6dCjMCAND/o8RWQMzUgIRKYE/wsC5TJIRR74rBUZaqqXwLZEXT0WTDGwLW1aavJWQir9qadw++NgykWoMNtcykh8Q5EECgr5C+jjpGjHjPGhPU5eVzyfPJitfnUyhPg6ywMKZ7BygcYcsPCj1Kc8uXYPqpeSLs6PnC4w8S+8OJ9MLAAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-icon-narrow{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAABm1JREFUaEPVWWuIVVUUXmvfYRosHzUZUUqKjkSXSe5Z+5qJhfawLELCR5ohPhKjjB4EWgkpkopRSWEPS1Mqy7Gkd0iPGaKy6ey9Z3z0opwEQytSMiS5NZ4Ve7j3dubMOfecO96buf/cx17rW+vba52919oH4RQfeIr7DxUjoLW+BhHHAsAAZh5gPwGghpl/TKVSHZ7n7T9+/Ph+ANg/atQo+1mRcUIEtNYzAWAiM09ExLPK8KgNADYw8wYp5Z9l6PUQ7RWBvON3AMClJ2Kcmb9DxAKR33qDVRYBrfUNzLwQESf0xliUDjPvR8T1RLSsXNzEBIwxc5l5fYSBnxGxxfO8bQCwN5VKHc7lcofr6+tzR44cGcTMg4UQgxDRfp8IAJdH4KwlooXlkEhEQGv9EAAsDQF+GwDWEdE75Rg1xlwFADcx83QAOCOg29SvX79ZDQ0NuSSYsQS01h8BwBUBsF45HnTIGHMBM9uFmR2Ya0bEWxzHORBHoiQBY8xmZp4RAFlNRIvigMuZN8asYOb7Azq7hBCTMpnMvlJYkQSMMUuYeblf2fO8ZdlsNiyVyvE3VNZ13XFCiGb/JCK+6DjOrLIJ2N0GAN4KKG4hIpuzVRtKqf6I+HvAwAIiWhdlNDQCSqntga3yUyK6rGqe+4Db2tqu8zzv3cJfiPiLfQYdx/k6zH4PAvlD6iWf8B7P8yZls9mO/4KAtaG1fhgAHvCReN1xnClJCXweOGFLhrAapJqamlLDhg372H9eMPNMKeXmoL1uEVBKTUXEJp+QJiJZDSfjMIOZgIibHMcJbrfdq1Gt9WMAcI8P/D9f/YJtpVQfW7n6isSDRHReyQhorXcCwMV5oWN1dXWD0un04bjVqta81to+i7bi7RpCiAmZTOYDv71iCu3cuXNQZ2env07fRkSTq+VcEtyQ7XwNEfkz5N8Ucl13khDiDR/b+ZlM5vkkhqopo5Q65Euj74loRGgElFJ3IuIThUnP8xqz2eyeajqXBFtrvR0AiuU7EXXbeIo/tNaPAMB9BVBmrpVS/l3KiDFmBjNPKbMbK0A+6zjOq3EktNavAUAxlUsR2AIA0ywgM3dIKYfFgRtjmph5apxc2Dwz/ySlHBynq7V+wV+tliLwPgBcmwdsJaLRceDGmD3MnI6Ti5j/g4j6x+lqrZ8EgGKTE0nAGPM0M9+Wj8BhKWV9HLjrukuFEPMBoMf+HKdrm3oimhcnFyy1IwkopRYj4soCYF1dXf3JPAMKfiilNiFisaSOJOC67nQhxCu+h3i0lLI1boWqPW+M6WDmoXk7+4io8L3rr+IuZIwZycztPocWEdHqajtYCl8pdSEifuOT2UhEc/w63fZUrfWvADCwixlii+M4408mAa31AgB4xufDHCLaGElAKbUZEf09cAMR/XCySGit7TXO3IJ9IcTQYI8cLKfvQsQ1BYVq9sBxi9La2jqipqbmMwA4Oy8bWtoHCTiIaBua0/JKB5hZSikPxhms9LxSah0i2i26MHoUct0eYt+2tRIRF5/MKGit7YFqD9auYU9tRBwfls49emJjzEBm3gEAxVKCmadJKbdWepWj8LTWHwLAlb75hUS0Nkw+6lbidkTspoCI6aibgUoSU0otR8QlBUxE3Oo4TleNlpiAFQwWUfa/XC7XZ8yYMccq6bAfS2v9OADcHUidqUT0RdkE8iS+BIBsQHkkEe2qNAml1HOIeGsA914isqQiR5LL3aMAcHoAYTIR2av0Ex7t7e3ne563mplvDoIh4le2xC+VurEE8pGwh1m3/sBec3ie96iUcndvWLS3t4/o7OycK4SYw8znRKZIDIlEBPIk7IrfGDB01JIAgJZsNtuShIjruplUKmWdtidsMLK2lFmFiPP8fUapSCQmYJ2L6cDsNfh7iLiXme1VjG3GOwFguOd5DYg4HAAa7O/Q3QTRXiavchxnhzHmIgCw3V6xWYoiURYBa9h13atTqdTssJxNEoEImQeJaIV/LimJsgkUjCilLrGXToho33mFrmoMod2I+LLneW9KKb8Nk01CotcE/AaVUmOFENcz8zgAGAIA54Y4dAgADiCifejtjcQnSSIWRgIAniIi+5q3cm/q/c40NzfX9e3bd4gQ4kxEPFhbW3sgnU7/lcThJJHwV8kViUBvHStHz0aCme2qe7W1tasbGxu7rkFPGQKR50Q5q/B/lP0HjgOoT/ydvaYAAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-icon-narrow:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAABS1JREFUaEPVmgmoVVUUhr+fosKC5ogGSsqIpKQwMqjIBpsICdMGQ7ISo4wGApugJCoxLClssElpNEuaI5okKjOI5onKhEQrSiKiaKA/Vu3zOu+8c88593qvj7fgcO99e6/h33udtdda+4khThri9tM1ALaPAQ4Btso9GwNfAyuBb7JHUnzvCq0XANuTgePSs00bFr0L3BuPpF/b4BswtSMAyfDzgYPXRznweQ7ID53IaguA7ROBGcC4TpRV8IRL3SNpVrtyGwOwfVYoaaHgW2AZsBT4CliXnt+BXYBd02d8D5c7rIWc+ZJigRpTIwC2rwauKZH6NLBA0jONNQK2jwJOAU4FtijwPgpMkRTga6kWgO2XgSMKkjoyvGiN7d3SwpxZGHsVOEPSmjoElQBsPwScVhAyR9LMOsHtjNu+Hri8wPMBMF7SqipZLQHYvgq4tsA8S1KZK7Vjb+lc24cDsfJ5ul/SlLYBpGjzVIFxsaTw2Z6R7S2BnwoKpkta0Epp6Q7YfqEQKl+XdGjPLM8Jtn088GzuT9/FOyjpkzL9AwCkQ+qB3OSPki9GOrBByPZ1wBU5ZY9LOrkpgDcLJ2zlFvYCke2NgFcK58VkSRFU+lG/HbA9EYg4nNE7kkb3wsg6mSWesEhSMdz2z0Zt3wRcnBO+wVc/0217WMpesyRxraSd6nbgfWC/NOm3OP4lRVowKGQ73sXIeDMaJ+nFvDF9LmQ78pR8nr5U0oRBsTwpLQnn8yTlPeR/F7I9HngiZ/A0SXcPJoDQbftHIHOjLyTt1WoHLgBuyQ3uKylC6KBS8UyS1C/w5F3oRuDSnLWbSPqzynrbkSdFfG6nGstE3inpkbrVsf0Y0OfKVQAWA5OSwJWS9mggPEJuhN5OaLWkqBMqyfZ9QF/4rALwPHBskrZC0pgGwsPFRtbNazH+s6TIfeoA3JqqwH/nVQG4HTg3SVsnadsGwiMznQYMiM91vKmgP7tuXjHVrgJwGXBDTuC2g3kGZHbYXhQVWva7CkCkyg/nAIyRtKJuhXo9bjuSyOFJzypJ2ff/XCqHdBTwXs6gmZLm9NrAKvm29wY+zc1ZKGlqnqeYzH0PbJ8mLJM0dpABTAfuyNkwVdLCKgDFGniEpC8HC4TtaONEOyej4cUaubgDFwLzcgw9q4HrFsV2pAxvANuluaWpfRHAAUAUNJsmpmhrjJa0tk5ht8dtRx0cITqjAYlcv5c49zJHKI2QmtEG3wXbcaDGwZrRamBsmTuX1cTxEi8H8qnEJElLur3KreTZfgk4Mjc+Q9L8svmtuhLnAUWGka06A90EZjt6UdGTymiJpCxHG6CqqrHVL4lKnMMkRaXWE7J9M3BRwXUmSnqrlcK61uLbwIEF5lGSou3XVbJ9F3BOQeglkgJUS2rS3P0F2LwgYYKkaKWvN9neGYgT//QSYR9Hil/lurUAQqjtOMyK9UEkWXMlfdgJihTn45CK1GCHChmVIBoBSCBixU8qKIrdmRuXG5LigqOWbO+fjA7jizsbqcxsINLsfJ3REkRjAAlEVQUWbfDncjc0UYz/BewJjCh8lgGNZvJsSctt75MabLUg2gKQQBydSrwyn63dgRYTrpQUdwR91BRE2wAyDbYPSk2nuPOKVW6X4t15EHhS0mdlzE1AdAygsFpxwX0CEJcUuwM7lhgULhW5VRgeHYnXmiBuAeI2SXHN272b+gKgzRKQrYFIBNdI+qOJwQ13oi8/68oOdGpYO3xpJ2LV/45zI/t3hSEDoBXYIQ/gH99H3EBePlczAAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-icon-expand{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAABvJJREFUaEPVWWmIXEUQrnqzZseYxGM9QBNF4hrJEDfzqieuAY/gFRXPyMYbzUHwQBQUzx+KeBAJKhrRqEhEQWMU75AYXREPlunu3bjxIDGraIwiuJpFkL26pMK84eXtm3lvZieGFAzsTtf1VVd3V9Ug7OOE+7j/0BAAnZ2d2UmTJl2cyWTaAOBA+TDzgYjYDAB/y4eZ5fNjc3Pze7NmzfqlUYEbFwBr7TUAcAEzXwAA2bROIeKnzrkNALBeKWXTysXx1QXAGHMVANwEACePxzgzjyLi057nrczn81vr0VUTAGOMRPtmRDy7HmOVZBDxL+fcyr6+vgc7OjqGatGdGoC19hZmfrKC8t9LafEWAGzLZDL9g4OD/S0tLYM7d+6cyszTPM+biojy97kAcGoFPV8ODw8vbG9v354WRCoAxpiXAUDyPUrvAcAqIno/rUHhs9aeCQALmflyAJgUlkXEf5xzp6U9G4kAjDHcKMejeqy1xzDz/QBwXYyNViL6ISkwVQEYY74AgLkRJcuJ6M4kxbWsW2sfZua7ozJNTU1HtLW1/VFNV0UAxpjlAHBHWNg590ChUJCINZyKxeLpnud1RhSvmzJlyiWtra2DFS+AuAW5bQDg3cja60QkObvHSGstj588fGVi5heVUktqAqC1Xh+5Kj8nolP2mOchxd3d3ec55z6I2JpPROvj7I9JodIj9UqIebNz7qJCodD3fwAQG8aYhwDgnpC99UQ0Py2ALyMv7DIiWvV/OS921qxZk5k+ffon4fcCEZf4vv9i1I/ddkBrfSUivhpiMkSkanXeWnsFAFwCADNHR0fX1nPwYzJhAxGdkwTgJUQM38l1Rd8Y8yYAXFoytoOIjqo1CFrriQDwCyIeEsh6nndsPp//KayrvANbt25tHhgY+AsA9i8x/JvNZqfmcrn+Wo1bazuZ+fRAjogSH8w4G8YYOYtSOAZ0GxE9EQvAGCMRk8gF9BYRLajVeeFvIIDdrnOpt3zfnxcLwFr7CDPfFdqupfl8/oW9CUBsa63/DKXRz0R0TCUAzzDzDcGic25WoVDYvLcBGGPk/i+X7wMDA/vNmzdvJPCrnJvW2leZ+cpggZknKKWGqwGw1l7IzOcg4swoX/gMyNbH6HnO9/3XkgJkjFkLAOVUzmQyM2bPnr1lDABjjJTE58sCM/cppaanUK4BgJL44taZebtSalqSrDHmpXC1ysynKKU+j9uBj5hZ6nShLiJqT1Jurd3MzLkkvgrrfxPRwUmyxpinAODmSqkdTqE3mPmy0g70K6VakpQXi8X7Pc9bCgBHJvHGrEsjtCxJLlpqDw8PTwt3bGEAzzNzuerLZrMt9bwB4lCjrtHSLbQaEa8NgGaz2cm5XO6fuDPwGADcHjrE7UqprqQIxa03EoC1to+Zjy3ZGZN25R3QWt+IiCtDDt1JRNLU1EyNAqC1PgERvws58DYRSY1VpjKA3t7eaUNDQz+Xtybm1UuLpFEAjDFyRp4N2a1cSsTlLgCkaqyjwBoIQMrnRYH+0dHR/Jw5c3pid6B0YO5GxIdDV1ZdPbC19nLn3GOIOAUA1hLR4rS7F/B1dXUd39TUJEOFQ+U7RNzo+/5ZUT3RfsBHRGloZCgrtIOZlVLqt1odGC+/1noVIsoVHdAiIpJHbTcaU+ZqrR9BxHJRtycnEZVAGmOkfVwXOo9bJk+efGLcdGIMAGvtYcz8FQCUSwlm7lBKvTHeqKaVN8ZsBIAz0qRybKMRc6VKDuZ83/82rRP18mmtH0TE+0LyHxNRUOKMUVuxU7LWlkuLQGpwcHDi3Llz/63XuSQ5Y8zjAHBrwMfM/cy8oFAoxFWzu9iSRou/xtQ5bUT0dZIzta5rrZ+XyUNYDhFv931/RTVdVQF0d3e3OufKtXdI0QIiklH6uKmnp+co59zycC8SOrzfAEBHtdRNbLaLxeIMz/O+H3N9Ia52zq1QSvXWg6Knp+f4kZGRRZ7nXc/Mh1fSgYhVQSQCEMW9vb1HDA0NyS0UHS/KLF+2+NNqeRp2rlgs5jOZjDgtL+wBEcdlEv0oIi4O9xnVQKQCIEZkTuN53uqgZ4iJmMxrPkTEbXL4AECaceldj3POtSLicVKayP9x0UZEGSY/6vv+V9ZaaVHXpAGRGkBgtFgsnpXJZK6Ly9l6Uqkkcy8RlUsY+S4tiJoBBE5qrU9CxKvlZ1YA2G3UkRJIr4wxnXPvKKXGnLG0IOoGEHZSnn5EvIiZTwKAowEgrh39U2orRJRDLxOJz9IAjdsJAHiGiORn3sb8Uh91ZNOmTQeMjIwcjYgHIeJvEyZM2JHL5Wr6+TSsMwoCEVf4vr+re2zIDqSJ5Hh5BAQzS9R/IiJpf3fRPgOg4jsx3sjsbfn/AH37LF5g3/BiAAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-icon-expand:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAABYZJREFUaEPVmXmoVVUUxn8f0WRzVkJlIWVGUmIJWWADTVaUldFclCnSQBQYNv1RSCWGVFRSlkRh0GBS2YBmJWGJUBHNNJiYWQSZfwTRxBfrce5jv/3Ovefc++4z3oKLD/fea61v7bXXdMQQJw1x/ekKANs7AOcA44Ddkt/2wJbk9z2wTNIP3TLcgADYvhw4q/gFiLq0ClgBLJf0Ud1DZfs6AmD7UuA64JiBCAf+BR4GHpH0TSe82gJgO6x9PXBqJ8JanPktQABzJP3VDu/aAGzfADzYhPnPQLjFUuA7YHPx+xPYHxhZ/Bt/nw4c14TP+8CFkjbWBVELgO2ngfD3nJYBCyW9Wldg7LN9cigKXATsnJ39HTi+7tuoBGDb3VI852P7QOBO4MoSGaMlfVtlmJYAbL8HHJsxmSdpdhXjdtZt3wPcWnJmhKRfWvFqCsD2PODm7PBdksJiXSfbJwDvZIzfAM6VFG+plEoBFNHmlezEc5LCZweNbEcSjMSX0iJJ09sFsDwLlaslTRo0zRPGts8AXstkTZYUOvWjfjdQJKnFyc7PgCmS1m0NACHD9t3AbYm8yNiT6wKIWJxm2JmSFm4t5QsA2wBvZ/liuqRFuR59bsD2JcAzyaYPJU1oV3nbF8fjAw4DlnTy8Es8YYWk06oAPJnF5I6sb/tF4LxC2CZJ+3VghGFAVK17JmdHSVqf8uq9AdtR+kZNsmOx4Y9I/5KiLGiLbEc4jLDYQ5IqE2aZANvxFqNwbNBNkh5oBiAsFpZr0FJJU9vSvNjcRQBRPKbhfJWkE5sBuBe4JVmcIemJ/xNAyLb9a+JGGyRF+dFLqQstAK5J1g6XFCG0berWDRQA8py0raR/et2z8YftiD4RhRq0naS/W2lv+2wgIkNEm5x630BRaufrj0l6tso6tpcAqSuPkfR1GYAoic8sFtZJOqgG8w+Ao6r2NVnfKCn6hJZkO4+MkyStLgPwJhB1etBaSRNrMA8XG1u1r8n6Fkl7VJ21/VDRBTa29nHt9A28AJxf7NosaXgN5lGZzgD2rdpbsh6N0MyqcyWl9si0Y0sBPA6kVd/wTnJAKNTlR/wUcEUCdBdJ0bX1UArgPmBWsnGipLVVFipb7zKAKCJHFXL6uV0K4NpiMtDQabakaGrapm4BsH0o8GWiwEuSosbqpRRARIQNyVq/rFcXSRcBxBt5NJHbvJQo812gVmOdA+sigCifpyX8x0v6uPQGCgDRWEeD3aCOemDb0XrGm9q1KKevrnt7jX22DwFiqLBX8X8rJZ2S88n7gSOBaGiiMg3aBEyQ9FO7Cgx0v+1ooiJEN2iapEhqfaispcyLuo5uYSAAbEf7GBOJBkXpcETZdKIMwN7AGiAtJS6QFIluq5DtlcBJdVy52VglD6nBa6ykLwYbge05wB2JnLckNUqcfuJbDbbS0qJxcJik6NQGhWzfD9yYMI9ucKqkGByXUtVo8ceSOmecpE+6jcB2XsqEiFmS5reSVQVgNNBbeyeMwioxSh8w2Y6GPzJ+2os0+H4OxPtr6rqVzbbtMcBXJZpGkTVf0qedoCjifCSpq4B9WvBoCaISQDC2PQKIN5GPF6MqjCuOsqOpn6bK2R5fKB3K75QpHpPouUAkvrTPaAqiFoACRMxpwuqNniE3WsxrXk++0EQzHr3rwVGSZP+WGTymD3MlrbEdLerzdUDUBtCQaDvSeXyQKPPZTrwpztwuKS1h4tZrgWgbQALkaOCy4hNrn1FHTRTxdmKQ8LKksjdWC0THADK/jtQ/BQhQBwBl7Wi4VNRWoXhMJN6tA7TJTSyQFJ95u/OlPlfEdjzOALI7EIVgzEfb+nyaGSh3p4h+Pd1jV26gjiUHuqe4ibD6eklRqvfQkAHQzABDHsB/7aMVT352GH8AAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%}.jb-pro-container .jb-pro-menu-icon-text,.jb-pro-container .jb-pro-quality-icon-text,.jb-pro-container .jb-pro-scale-icon-text,.jb-pro-container .jb-pro-speed-icon-text{font-size:14px;min-width:30px;height:20px;line-height:20px;cursor:pointer;text-align:center}.jb-pro-container .jb-pro-speed{box-sizing:border-box;text-align:center;font-size:14px;color:#fff;width:90px}.jb-pro-container .jb-pro-menu-list,.jb-pro-container .jb-pro-quality-menu-list,.jb-pro-container .jb-pro-scale-menu-list,.jb-pro-container .jb-pro-speed-menu-list{position:absolute;left:50%;bottom:100%;visibility:hidden;opacity:0;transform:translateX(-50%);transition:visibility .3s,opacity .3s;background-color:rgba(0,0,0,.5);border-radius:4px;overflow:hidden;width:-moz-max-content;width:max-content}.jb-pro-container .jb-pro-menu-list.jb-pro-menu-shown,.jb-pro-container .jb-pro-menu-list.jb-pro-quality-menu-shown,.jb-pro-container .jb-pro-menu-list.jb-pro-scale-menu-shown,.jb-pro-container .jb-pro-menu-list.jb-pro-speed-menu-shown,.jb-pro-container .jb-pro-quality-menu-list.jb-pro-menu-shown,.jb-pro-container .jb-pro-quality-menu-list.jb-pro-quality-menu-shown,.jb-pro-container .jb-pro-quality-menu-list.jb-pro-scale-menu-shown,.jb-pro-container .jb-pro-quality-menu-list.jb-pro-speed-menu-shown,.jb-pro-container .jb-pro-scale-menu-list.jb-pro-menu-shown,.jb-pro-container .jb-pro-scale-menu-list.jb-pro-quality-menu-shown,.jb-pro-container .jb-pro-scale-menu-list.jb-pro-scale-menu-shown,.jb-pro-container .jb-pro-scale-menu-list.jb-pro-speed-menu-shown,.jb-pro-container .jb-pro-speed-menu-list.jb-pro-menu-shown,.jb-pro-container .jb-pro-speed-menu-list.jb-pro-quality-menu-shown,.jb-pro-container .jb-pro-speed-menu-list.jb-pro-scale-menu-shown,.jb-pro-container .jb-pro-speed-menu-list.jb-pro-speed-menu-shown{visibility:visible;opacity:1}.jb-pro-container .icon-title-tips{pointer-events:none;position:absolute;left:50%;bottom:100%;visibility:hidden;opacity:0;transform:translateX(-50%);transition:visibility .3s ease 0s,opacity .3s ease 0s;background-color:rgba(0,0,0,.5);border-radius:4px}.jb-pro-container .icon-title{display:inline-block;padding:5px 10px;font-size:12px;white-space:nowrap;color:#fff}.jb-pro-container .jb-pro-quality-menu{padding:8px 0}.jb-pro-container .jb-pro-menu-item,.jb-pro-container .jb-pro-quality-menu-item,.jb-pro-container .jb-pro-scale-menu-item,.jb-pro-container .jb-pro-speed-menu-item{display:block;height:25px;line-height:25px;margin:0;padding:0 10px;cursor:pointer;font-size:14px;text-align:center;width:50px;color:hsla(0,0%,100%,.5);transition:color .3s,background-color .3s}.jb-pro-container .jb-pro-menu-item:hover,.jb-pro-container .jb-pro-quality-menu-item:hover,.jb-pro-container .jb-pro-scale-menu-item:hover,.jb-pro-container .jb-pro-speed-menu-item:hover{background-color:hsla(0,0%,100%,.2)}.jb-pro-container .jb-pro-menu-item:focus,.jb-pro-container .jb-pro-quality-menu-item:focus,.jb-pro-container .jb-pro-scale-menu-item:focus,.jb-pro-container .jb-pro-speed-menu-item:focus{outline:none}.jb-pro-container .jb-pro-menu-item.jb-pro-menu-item-active,.jb-pro-container .jb-pro-menu-item.jb-pro-quality-menu-item-active,.jb-pro-container .jb-pro-menu-item.jb-pro-scale-menu-item-active,.jb-pro-container .jb-pro-menu-item.jb-pro-speed-menu-item-active,.jb-pro-container .jb-pro-quality-menu-item.jb-pro-menu-item-active,.jb-pro-container .jb-pro-quality-menu-item.jb-pro-quality-menu-item-active,.jb-pro-container .jb-pro-quality-menu-item.jb-pro-scale-menu-item-active,.jb-pro-container .jb-pro-quality-menu-item.jb-pro-speed-menu-item-active,.jb-pro-container .jb-pro-scale-menu-item.jb-pro-menu-item-active,.jb-pro-container .jb-pro-scale-menu-item.jb-pro-quality-menu-item-active,.jb-pro-container .jb-pro-scale-menu-item.jb-pro-scale-menu-item-active,.jb-pro-container .jb-pro-scale-menu-item.jb-pro-speed-menu-item-active,.jb-pro-container .jb-pro-speed-menu-item.jb-pro-menu-item-active,.jb-pro-container .jb-pro-speed-menu-item.jb-pro-quality-menu-item-active,.jb-pro-container .jb-pro-speed-menu-item.jb-pro-scale-menu-item-active,.jb-pro-container .jb-pro-speed-menu-item.jb-pro-speed-menu-item-active{color:#2298fc}.jb-pro-container .jb-pro-volume-panel-wrap{position:absolute;left:50%;bottom:100%;visibility:hidden;opacity:0;transform:translateX(-50%) translateY(22%);transition:visibility .3s,opacity .3s;background-color:rgba(0,0,0,.5);border-radius:4px;height:120px;width:50px;overflow:hidden}.jb-pro-container .jb-pro-volume-panel-wrap.jb-pro-volume-panel-wrap-show{visibility:visible;opacity:1}.jb-pro-container .jb-pro-volume-panel{cursor:pointer;position:absolute;top:21px;height:60px;width:50px;overflow:hidden}.jb-pro-container .jb-pro-volume-panel-text{position:absolute;left:0;top:0;width:50px;height:20px;line-height:20px;text-align:center;color:#fff;font-size:12px}.jb-pro-container .jb-pro-volume-panel-handle{position:absolute;top:48px;left:50%;width:12px;height:12px;border-radius:12px;margin-left:-6px;background:#fff}.jb-pro-container .jb-pro-volume-panel-handle:before{bottom:-54px;background:#fff}.jb-pro-container .jb-pro-volume-panel-handle:after{bottom:6px;background:hsla(0,0%,100%,.2)}.jb-pro-container .jb-pro-volume-panel-handle:after,.jb-pro-container .jb-pro-volume-panel-handle:before{content:"";position:absolute;display:block;left:50%;width:3px;margin-left:-1px;height:60px}.jb-pro-container.jb-pro-fullscreen-web .jb-pro-controls{width:100vh}.jb-pro-container.jb-pro-fullscreen-web .jb-pro-play-big:after{transform:translate(-50%,-50%) rotate(270deg)}.jb-pro-container.jb-pro-fullscreen-web .jb-pro-loading{flex-direction:row}.jb-pro-container.jb-pro-fullscreen-web .jb-pro-loading-text{transform:rotate(270deg)}.jb-pro-container .jb-pro-contextmenus{display:none;flex-direction:column;position:absolute;z-index:120;left:10px;top:10px;min-width:200px;padding:5px 0;background-color:rgba(0,0,0,.9);border-radius:3px}.jb-pro-container .jb-pro-contextmenus .jb-pro-contextmenu{cursor:pointer;font-size:12px;display:block;color:#fff;padding:10px 15px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-shadow:0 0 2px rgba(0,0,0,.5);border-bottom:1px solid hsla(0,0%,100%,.1)}.jb-pro-container .jb-pro-contextmenus .jb-pro-contextmenu a{color:#fff;text-decoration:none}.jb-pro-container .jb-pro-contextmenus .jb-pro-contextmenu span{display:inline-block;padding:0 7px}.jb-pro-container .jb-pro-contextmenus .jb-pro-contextmenu span.art-current,.jb-pro-container .jb-pro-contextmenus .jb-pro-contextmenu span:hover{color:var(--theme)}.jb-pro-container .jb-pro-contextmenus .jb-pro-contextmenu:hover{background-color:hsla(0,0%,100%,.1)}.jb-pro-container .jb-pro-contextmenus .jb-pro-contextmenu:last-child{border-bottom:none}.jb-pro-container.jb-pro-contextmenus-show .jb-pro-contextmenus{display:flex}.jb-pro-container .jb-pro-extend-dom{display:block;position:relative;width:100%;height:100%;display:none}.jb-pro-container-playback .jb-pro-controls{height:48px}.jb-pro-container-playback .jb-pro-controls .jb-pro-controls-bottom .jb-pro-controls-center{flex:1;display:flex;box-sizing:border-box;justify-content:space-between;font-size:12px}.jb-pro-container-playback .jb-pro-controls .jb-pro-controls-bottom .jb-pro-controls-center .jb-pro-controls-playback-time{box-sizing:border-box;flex:1;position:relative;height:100%}.jb-pro-container-playback .jb-pro-controls .jb-pro-controls-bottom .jb-pro-controls-center .jb-pro-controls-playback-time-inner{width:300px;height:100%;overflow-y:hidden;overflow-x:auto}.jb-pro-container-playback .jb-pro-controls .jb-pro-controls-bottom .jb-pro-controls-center .jb-pro-controls-playback-current-time{position:absolute;left:0;top:0;height:15px;width:1px;background-color:red;text-align:center;z-index:1}.jb-pro-container-playback .jb-pro-controls .jb-pro-controls-bottom .jb-pro-controls-center .jb-pro-controls-playback-current-time-text{position:absolute;box-sizing:border-box;padding:0 5px;width:60px;left:-25px;top:15px;border:1px solid red;height:15px;line-height:15px;cursor:move;background-color:#fff;color:#000;-webkit-user-select:none;-moz-user-select:none;user-select:none}.jb-pro-container-playback .jb-pro-controls .jb-pro-controls-bottom .jb-pro-controls-center .jb-pro-controls-playback-time-scroll{position:relative;width:1440px;margin:0 auto}.jb-pro-container-playback .jb-pro-controls .jb-pro-controls-bottom .jb-pro-controls-center .jb-pro-controls-playback-time-scroll.one-hour{width:1440px}.jb-pro-container-playback .jb-pro-controls .jb-pro-controls-bottom .jb-pro-controls-center .jb-pro-controls-playback-time-scroll.half-hour{width:2880px}.jb-pro-container-playback .jb-pro-controls .jb-pro-controls-bottom .jb-pro-controls-center .jb-pro-controls-playback-time-scroll.ten-min{width:8640px}.jb-pro-container-playback .jb-pro-controls .jb-pro-controls-bottom .jb-pro-controls-center .jb-pro-controls-playback-time-scroll.five-min{width:17280px}.jb-pro-container-playback .jb-pro-controls .jb-pro-controls-bottom .jb-pro-controls-center .jb-pro-controls-playback-time-scroll.one-min{width:86400px}.jb-pro-container-playback .jb-pro-controls .jb-pro-controls-bottom .jb-pro-controls-center .jb-pro-controls-playback-time-list{position:relative;background-color:#ccc;height:48px}.jb-pro-container-playback .jb-pro-controls .jb-pro-controls-bottom .jb-pro-controls-center .jb-pro-playback-time-day{height:100%;overflow:hidden}.jb-pro-container-playback .jb-pro-controls .jb-pro-controls-bottom .jb-pro-controls-center .jb-pro-playback-time-one-wrap{height:8px;z-index:1}.jb-pro-container-playback .jb-pro-controls .jb-pro-controls-bottom .jb-pro-controls-center .jb-pro-playback-time-second-wrap{height:25px}.jb-pro-container-playback .jb-pro-controls .jb-pro-controls-bottom .jb-pro-controls-center .jb-pro-controls-playback-btns{display:flex;align-items:center}.jb-pro-container-playback .jb-pro-controls .jb-pro-controls-bottom .jb-pro-controls-center .jb-pro-playback-time-minute-one,.jb-pro-container-playback .jb-pro-controls .jb-pro-controls-bottom .jb-pro-controls-center .jb-pro-playback-time-second-one{float:left;width:1px;height:8px;margin:0;cursor:default;position:relative;z-index:1}.jb-pro-container-playback .jb-pro-controls .jb-pro-controls-bottom .jb-pro-controls-center .jb-pro-playback-time-minute-one.active,.jb-pro-container-playback .jb-pro-controls .jb-pro-controls-bottom .jb-pro-controls-center .jb-pro-playback-time-second-one.active{background-color:orange;cursor:pointer}.jb-pro-container-playback .jb-pro-controls .jb-pro-controls-bottom .jb-pro-controls-center .jb-pro-playback-time-minute-one.start,.jb-pro-container-playback .jb-pro-controls .jb-pro-controls-bottom .jb-pro-controls-center .jb-pro-playback-time-second-one.start{background-color:#999}.jb-pro-container-playback .jb-pro-controls .jb-pro-controls-bottom .jb-pro-controls-center .jb-pro-playback-time-minute-one:hover .jb-pro-playback-time-title-tips,.jb-pro-container-playback .jb-pro-controls .jb-pro-controls-bottom .jb-pro-controls-center .jb-pro-playback-time-second-one:hover .jb-pro-playback-time-title-tips{visibility:visible;opacity:1}.jb-pro-container-playback .jb-pro-controls .jb-pro-controls-bottom .jb-pro-controls-center .jb-pro-playback-time-title-tips{pointer-events:none;position:absolute;left:0;top:100%;visibility:hidden;opacity:0;transform:translateX(13%);transition:visibility .3s ease 0s,opacity .3s ease 0s;background-color:#000;border-radius:4px;z-index:1}.jb-pro-container-playback .jb-pro-controls .jb-pro-controls-bottom .jb-pro-controls-center .jb-pro-playback-time-title-tips.jb-pro-playback-time-title-tips-left{transform:translateX(-100%)}.jb-pro-container-playback .jb-pro-controls .jb-pro-controls-bottom .jb-pro-controls-center .jb-pro-playback-time-title-tips .jb-pro-playback-time-title{display:inline-block;padding:2px 5px;font-size:12px;white-space:nowrap;color:#fff}.jb-pro-container-playback .jb-pro-controls .jb-pro-controls-bottom .jb-pro-controls-center .jb-pro-playback-time-hour,.jb-pro-container-playback .jb-pro-controls .jb-pro-controls-bottom .jb-pro-controls-center .jb-pro-playback-time-minute{float:left;position:relative;width:60px;box-sizing:border-box;border-top:1px solid #999;-webkit-user-select:none;-moz-user-select:none;user-select:none;text-align:left;height:25px;line-height:25px}.jb-pro-container-playback .jb-pro-controls .jb-pro-controls-bottom .jb-pro-controls-center .jb-pro-playback-time-hour:first-child,.jb-pro-container-playback .jb-pro-controls .jb-pro-controls-bottom .jb-pro-controls-center .jb-pro-playback-time-minute:first-child{border-left:0}.jb-pro-container-playback .jb-pro-controls .jb-pro-controls-bottom .jb-pro-controls-center .jb-pro-playback-time-hour:first-child .jb-pro-playback-time-hour-text,.jb-pro-container-playback .jb-pro-controls .jb-pro-controls-bottom .jb-pro-controls-center .jb-pro-playback-time-minute:first-child .jb-pro-playback-time-hour-text{left:0}.jb-pro-container-playback .jb-pro-controls .jb-pro-controls-bottom .jb-pro-controls-center .jb-pro-playback-time-hour:after,.jb-pro-container-playback .jb-pro-controls .jb-pro-controls-bottom .jb-pro-controls-center .jb-pro-playback-time-minute:after{content:"";position:absolute;left:0;top:-8px;width:1px;height:14px;background-color:#999}.jb-pro-container-playback .jb-pro-controls .jb-pro-controls-bottom .jb-pro-controls-center .jb-pro-playback-time-hour-text,.jb-pro-container-playback .jb-pro-controls .jb-pro-controls-bottom .jb-pro-controls-center .jb-pro-playback-time-minute-text{position:absolute;left:-13px}.jb-pro-container-playback .jb-pro-playback-expand.disabled .jb-pro-icon-expand,.jb-pro-container-playback .jb-pro-playback-narrow.disabled .jb-pro-icon-narrow{cursor:no-drop}.jb-pro-container-playback .jb-pro-control-progress-simple{position:absolute;box-sizing:border-box;left:0;top:-2px;width:100%;display:flex;flex-direction:row;align-items:center;height:8px;cursor:pointer}.jb-pro-container-playback .jb-pro-control-progress-simple:hover{top:0;align-items:flex-start}.jb-pro-container-playback .jb-pro-control-progress-simple:hover .jb-pro-control-progress-inner{height:100%}.jb-pro-container-playback .jb-pro-control-progress-simple:hover .jb-pro-control-progress-inner .jb-pro-progress-indicator{transform:scale(1);visibility:visible}.jb-pro-container-playback .jb-pro-control-progress-inner{display:flex;align-items:center;position:relative;height:50%;width:100%;transition:all .2s ease;background:hsla(0,0%,100%,.5)}.jb-pro-container-playback .jb-pro-progress-hover{display:none;width:0}.jb-pro-container-playback .jb-pro-progress-played{position:absolute;left:0;top:0;right:0;bottom:0;height:100%;width:0;background-color:orange}.jb-pro-container-playback .jb-pro-progress-indicator{visibility:hidden;align-items:center;justify-content:center;position:absolute;z-index:40;border-radius:50%;transform:scale(.1);transition:transform .1s ease-in-out}.jb-pro-container-playback .jb-pro-progress-indicator .jb-pro-icon{width:100%;height:100%;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.jb-pro-container-playback .jb-pro-progress-indicator:hover{transform:scale(1.2)!important}.jb-pro-container-playback .jb-pro-progress-tip{display:none;position:absolute;z-index:50;top:-25px;left:0;height:20px;padding:0 5px;line-height:20px;color:#fff;font-size:12px;text-align:center;background:rgba(0,0,0,.7);border-radius:3px;font-weight:700;white-space:nowrap}.jb-pro-container-playback.jb-pro-fullscreen-web .jb-pro-controls .jb-pro-controls-bottom .jb-pro-controls-playback-time-inner{overflow-y:auto}.jb-pro-zoom-control{cursor:grab}.jb-pro-performance-panel{position:absolute;box-sizing:border-box;z-index:10000;left:0;top:0;padding:5px;font-size:10px;background:rgba(0,0,0,.2);color:#fff;max-height:100%;overflow-y:auto;display:none}.jb-pro-performance-panel .jb-pro-performance-item{display:flex;align-items:center;margin-top:3px;color:#fff}.jb-pro-performance-panel .jb-pro-performance-item-block{height:10px}.jb-pro-tips-message{position:absolute;top:0;left:0;width:100%;height:100%;background:linear-gradient(180deg,rgba(0,0,0,.8),hsla(0,0%,100%,0));overflow:auto;box-sizing:content-box;display:none}.jb-pro-tips-message:before{color:hsla(0,0%,100%,.3);content:"X";font-family:Arial,Helvetica,sans-serif;font-size:40px;left:0;line-height:1;margin-top:-20px;position:absolute;text-shadow:2em 2em 4em #000;text-align:center;top:50%;vertical-align:middle;width:100%}.jb-pro-tips-message .jb-pro-tips-message-close{position:absolute;z-index:99999;right:0;top:0;width:40px;height:40px;display:flex;align-items:center;justify-content:center}.jb-pro-tips-message .jb-pro-tips-message-close .jb-pro-tips-message-close-icon{width:20px;height:20px;border-radius:10px;cursor:pointer;background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAeUExURUdwTM3Nzc7Ozs7Ozs3Nzc3NzcrKys3Nzc3Nzc3NzePZJxkAAAAJdFJOUwCtKdPBGAmNTt3jdDcAAADfSURBVDjL1dOxDoIwEADQgwR07GTCZtI/IGHgAzBhM9EPkMTB0Y3V0ZXIcn/rtRR6pefgSKeSu3ellyvA9lZ/5F9p/3K7PZY8oPG5BD6MpPUSgIITzdIStifAshjRQV1PCFT8TxaicTzzwEwINOEdHVmDmcTAkRhMhMAp7iQRjcMtDhCp8SA1v0ARGIIK/gnkv0p1OBTS4QRUIpE7DiYYXTBrzcld3JIrAarXrps4AVNwRSZgExoJmIyAaAdsShUMn/JF2fh4YEkpAcgvnuwYCIb6EbbbP4PsDfLD2dD6Av1qTvAQlzUTAAAAAElFTkSuQmCC") no-repeat 50%;background-color:#fff;background-size:100% 100%}.jb-pro-tips-message .jb-pro-tips-message-content{overflow:auto;padding:35px;box-sizing:border-box;width:100%;height:100%}.jb-pro-tips-message .jb-pro-tips-message-content .jb-pro-tips-message-content-item{font-size:14px;color:#fff;text-align:center;line-height:1.5}');class yh{constructor(e){var t;this.player=e,this.TAG_NAME="Control",this.extendBtnList=[],((e,t)=>{e._opt.hasControl&&e._opt.controlAutoHide?e.$container.classList.add("jb-pro-controls-show-auto-hide"):e.$container.classList.add("jb-pro-controls-show");const i=e._opt,s=i.operateBtns,r=`\n <div class="jb-pro-controls-center">\n <div class="jb-pro-controls-playback-time">\n <div class="jb-pro-controls-playback-time-inner">\n <div class="jb-pro-controls-playback-time-scroll">\n <div class="jb-pro-controls-playback-time-list">\n <div class="jb-pro-playback-time-day">\n <div class="jb-pro-playback-time-one-wrap"></div>\n <div class="jb-pro-playback-time-second-wrap"></div>\n </div>\n </div>\n <div class="jb-pro-controls-playback-current-time">\n <div class="jb-pro-controls-playback-current-time-text">00:00:00</div>\n </div>\n </div>\n </div>\n </div>\n ${i.playbackConfig.showPrecisionBtn?`\n <div class="jb-pro-controls-playback-btns">\n <div class="jb-pro-controls-item jb-pro-playback-narrow">${th.narrow}</div>\n <div class="jb-pro-controls-item jb-pro-playback-expand">${th.expand}</div>\n </div>\n `:""}\n </div>\n `;e.$container.insertAdjacentHTML("beforeend",`\n ${i.background?`<div class="jb-pro-poster" style="background-image: url(${i.background})"></div>`:""}\n <div class="jb-pro-loading-bg">\n <img class="jb-pro-loading-bg-image" src="" alt="">\n </div>\n ${i.loadingIcon?`\n <div class="jb-pro-loading">\n ${th.loading}\n <div class="jb-pro-loading-text">${i.loadingText}</div>\n </div>\n `:""}\n ${i.hasControl&&s.play?'<div class="jb-pro-play-big"></div>':""}\n ${i.hasControl&&s.ptz?`\n <div class="jb-pro-ptz-controls show-${i.ptzShowType}">\n <div class="jb-pro-ptz-bg-active"></div>\n <div class="jb-pro-ptz-arrow jb-pro-ptz-arrow-up" data-arrow="up"></div>\n <div class="jb-pro-ptz-arrow jb-pro-ptz-arrow-right" data-arrow="right"></div>\n <div class="jb-pro-ptz-arrow jb-pro-ptz-arrow-down" data-arrow="down"></div>\n <div class="jb-pro-ptz-arrow jb-pro-ptz-arrow-left" data-arrow="left"></div>\n ${i.ptzMoreArrowShow?'\n <div class="jb-pro-ptz-arrow jb-pro-ptz-arrow-left-up" data-arrow="left-up"></div>\n <div class="jb-pro-ptz-arrow jb-pro-ptz-arrow-right-up" data-arrow="right-up"></div>\n <div class="jb-pro-ptz-arrow jb-pro-ptz-arrow-left-down" data-arrow="left-down"></div>\n <div class="jb-pro-ptz-arrow jb-pro-ptz-arrow-right-down" data-arrow="right-down"></div>\n ':""}\n <div class="jb-pro-ptz-control"></div>\n <div class="jb-pro-ptz-btns">\n ${i.ptzZoomShow?'\n <div class="jb-pro-ptz-btn">\n <div class="jb-pro-ptz-expand jb-pro-ptz-icon">\n <i class="jb-pro-ptz-expand-icon"></i>\n <span class="icon-title-tips">\n <span class="icon-title">缩放+</span>\n </span>\n </div>\n <div class="jb-pro-ptz-narrow jb-pro-ptz-icon">\n <i class="jb-pro-ptz-narrow-icon"></i>\n <span class="icon-title-tips">\n <span class="icon-title">缩放-</span>\n </span>\n </div>\n </div>\n ':""}\n ${i.ptzApertureShow?'\n <div class="jb-pro-ptz-btn">\n <div class="jb-pro-ptz-aperture-far jb-pro-ptz-icon">\n <i class="jb-pro-ptz-aperture-icon"></i>\n <span class="icon-title-tips">\n <span class="icon-title">光圈+</span>\n </span>\n </div>\n <div class="jb-pro-ptz-aperture-near jb-pro-ptz-icon">\n <i class="jb-pro-ptz-aperture-icon"></i>\n <span class="icon-title-tips">\n <span class="icon-title">光圈-</span>\n </span>\n </div>\n </div>\n ':""}\n ${i.ptzFocusShow?'\n <div class="jb-pro-ptz-btn">\n <div class="jb-pro-ptz-focus-far jb-pro-ptz-icon">\n <i class="jb-pro-ptz-focus-icon"></i>\n <span class="icon-title-tips">\n <span class="icon-title">聚焦+</span>\n </span>\n </div>\n <div class="jb-pro-ptz-focus-near jb-pro-ptz-icon">\n <i class="jb-pro-ptz-focus-icon"></i>\n <span class="icon-title-tips">\n <span class="icon-title">聚焦-</span>\n </span>\n </div>\n </div>\n ':""}\n ${i.ptzCruiseShow?'\n <div class="jb-pro-ptz-btn">\n <div class="jb-pro-ptz-cruise-play jb-pro-ptz-icon">\n <i class="jb-pro-ptz-focus-icon"></i>\n <span class="icon-title-tips">\n <span class="icon-title">巡航开</span>\n </span>\n </div>\n <div class="jb-pro-ptz-cruise-pause jb-pro-ptz-icon">\n <i class="jb-pro-ptz-focus-icon"></i>\n <span class="icon-title-tips">\n <span class="icon-title">巡航关</span>\n </span>\n </div>\n </div>\n ':""}\n ${i.ptzFogShow?'\n <div class="jb-pro-ptz-btn">\n <div class="jb-pro-ptz-fog-open jb-pro-ptz-icon">\n <i class="jb-pro-ptz-focus-icon"></i>\n <span class="icon-title-tips">\n <span class="icon-title">透雾开</span>\n </span>\n </div>\n <div class="jb-pro-ptz-fog-close jb-pro-ptz-icon">\n <i class="jb-pro-ptz-focus-icon"></i>\n <span class="icon-title-tips">\n <span class="icon-title">透雾关</span>\n </span>\n </div>\n </div>\n ':""}\n\n ${i.ptzWiperShow?'\n <div class="jb-pro-ptz-btn">\n <div class="jb-pro-ptz-wiper-open jb-pro-ptz-icon">\n <i class="jb-pro-ptz-focus-icon"></i>\n <span class="icon-title-tips">\n <span class="icon-title">雨刷开</span>\n </span>\n </div>\n <div class="jb-pro-ptz-wiper-close jb-pro-ptz-icon">\n <i class="jb-pro-ptz-focus-icon"></i>\n <span class="icon-title-tips">\n <span class="icon-title">雨刷关</span>\n </span>\n </div>\n </div>\n ':""}\n </div>\n </div>\n `:""}\n ${i.hasVideo?`\n <div class="jb-pro-zoom-controls">\n <div class="jb-pro-zoom-narrow">${th.narrow}</div>\n <div class="jb-pro-zoom-tips">电子放大</div>\n <div class="jb-pro-zoom-expand">${th.expand}</div>\n <div class="jb-pro-zoom-stop2">${th.zoomStop}</div>\n </div>\n <div class="jb-pro-recording">\n <div class="jb-pro-recording-red-point"></div>\n <div class="jb-pro-recording-time">00:00:00</div>\n <div class="jb-pro-recording-stop">${th.recordStop}</div>\n </div>\n `:""}\n\n ${i.hasControl?`\n <div class="jb-pro-controls">\n <div class="jb-pro-controls-bottom">\n <div class="jb-pro-controls-left">\n ${i.showBandwidth?'<div class="jb-pro-controls-item jb-pro-speed"></div>':""}\n <div class="jb-pro-playback-control-time"></div>\n <div class="jb-pro-controls-item-html">${i.controlHtml}</div>\n </div>\n ${i.playType===v&&i.playbackConfig.showControl&&i.playbackConfig.controlType===Q.normal?r:""}\n ${i.playType===v&&i.playbackConfig.showControl&&i.playbackConfig.controlType===Q.simple?'\n <div class="jb-pro-control-progress-simple">\n <div class="jb-pro-control-progress-inner">\n <div class="jb-pro-progress-hover"></div>\n <div class="jb-pro-progress-played"></div>\n <div class="jb-pro-progress-indicator"></div>\n <div class="jb-pro-progress-tip">00:00</div>\n </div>\n </div>\n ':""}\n <div class="jb-pro-controls-right">\n ${i.playType===v&&i.playbackConfig.showRateBtn?'\n <div class="jb-pro-controls-item-wrap">\n <div class="jb-pro-controls-item jb-pro-speed-menu">\n <div class="jb-pro-speed-icon-text"></div>\n <div class="jb-pro-speed-menu-list"></div>\n </div>\n </div>\n ':""}\n ${s.close?`<div class="jb-pro-controls-item-wrap"><div class="jb-pro-controls-item jb-pro-close">${th.close}</div></div>`:""}\n ${s.logSave?`<div class="jb-pro-controls-item-wrap"><div class="jb-pro-controls-item jb-pro-logSave">${th.logSave}</div></div>`:""}\n ${s.performance?`<div class="jb-pro-controls-item-wrap"><div class="jb-pro-controls-item jb-pro-performance">${th.performance}</div><div class="jb-pro-controls-item jb-pro-performance-active">${th.performanceActive}</div></div>`:""}\n ${s.aiFace?`<div class="jb-pro-controls-item-wrap"><div class="jb-pro-controls-item jb-pro-face">${th.face}</div><div class="jb-pro-controls-item jb-pro-face-active">${th.faceActive}</div></div>`:""}\n ${s.aiObject?`<div class="jb-pro-controls-item-wrap"><div class="jb-pro-controls-item jb-pro-object">${th.object}</div><div class="jb-pro-controls-item jb-pro-object-active">${th.objectActive}</div></div>`:""}\n ${s.aiOcclusion?`<div class="jb-pro-controls-item-wrap"><div class="jb-pro-controls-item jb-pro-occlusion">${th.occlusion}</div><div class="jb-pro-controls-item jb-pro-occlusion-active">${th.occlusionActive}</div></div>`:""}\n ${s.quality?'\n <div class="jb-pro-controls-item-wrap">\n <div class="jb-pro-controls-item jb-pro-quality-menu">\n <div class="jb-pro-quality-icon-text"></div>\n <div class="jb-pro-quality-menu-list"></div>\n </div>\n </div>\n ':""}\n ${s.scale?'\n <div class="jb-pro-controls-item-wrap">\n <div class="jb-pro-controls-item jb-pro-scale-menu">\n <div class="jb-pro-scale-icon-text"></div>\n <div class="jb-pro-scale-menu-list"></div>\n </div>\n </div>\n ':""}\n ${s.audio?`\n <div class="jb-pro-controls-item-wrap">\n <div class="jb-pro-controls-item jb-pro-volume">\n ${th.audio}\n ${th.mute}\n <div class="jb-pro-volume-panel-wrap">\n <div class="jb-pro-volume-panel">\n <div class="jb-pro-volume-panel-handle"></div>\n </div>\n <div class="jb-pro-volume-panel-text"></div>\n </div>\n </div>\n </div>\n `:""}\n ${s.play?`<div class="jb-pro-controls-item-wrap"><div class="jb-pro-controls-item jb-pro-play">${th.play}</div><div class="jb-pro-controls-item jb-pro-pause">${th.pause}</div></div>`:""}\n ${s.screenshot?`<div class="jb-pro-controls-item-wrap"><div class="jb-pro-controls-item jb-pro-screenshot">${th.screenshot}</div></div>`:""}\n ${s.record?` <div class="jb-pro-controls-item-wrap"><div class="jb-pro-controls-item jb-pro-record">${th.record}</div><div class="jb-pro-controls-item jb-pro-record-stop">${th.recordStop}</div></div>`:""}\n ${s.ptz?` <div class="jb-pro-controls-item-wrap"><div class="jb-pro-controls-item jb-pro-ptz">${th.ptz}</div><div class="jb-pro-controls-item jb-pro-ptz-active">${th.ptzActive}</div></div>`:""}\n ${s.zoom?` <div class="jb-pro-controls-item-wrap"><div class="jb-pro-controls-item jb-pro-zoom">${th.zoom}</div><div class="jb-pro-controls-item jb-pro-zoom-stop">${th.zoomStop}</div></div>`:""}\n ${s.fullscreen?`<div class="jb-pro-controls-item-wrap"><div class="jb-pro-controls-item jb-pro-fullscreen">${th.fullscreen}</div><div class="jb-pro-controls-item jb-pro-fullscreen-exit">${th.fullscreenExit}</div></div>`:""}\n </div>\n </div>\n </div>\n `:""}\n <div class="jb-pro-performance-panel"></div>\n <div class="jb-pro-contextmenus"></div>\n <div class="jb-pro-tips-message">\n <div class="jb-pro-tips-message-close">\n <div class="jb-pro-tips-message-close-icon"></div>\n </div>\n <div class="jb-pro-tips-message-content"></div>\n </div>\n `),Object.defineProperty(t,"$poster",{value:e.$container.querySelector(".jb-pro-poster")}),Object.defineProperty(t,"$loadingBg",{value:e.$container.querySelector(".jb-pro-loading-bg")}),Object.defineProperty(t,"$loadingBgImage",{value:e.$container.querySelector(".jb-pro-loading-bg-image")}),Object.defineProperty(t,"$loading",{value:e.$container.querySelector(".jb-pro-loading")}),Object.defineProperty(t,"$loadingText",{value:e.$container.querySelector(".jb-pro-loading-text")}),Object.defineProperty(t,"$play",{value:e.$container.querySelector(".jb-pro-play")}),Object.defineProperty(t,"$playBig",{value:e.$container.querySelector(".jb-pro-play-big")}),Object.defineProperty(t,"$recording",{value:e.$container.querySelector(".jb-pro-recording")}),Object.defineProperty(t,"$recordingTime",{value:e.$container.querySelector(".jb-pro-recording-time")}),Object.defineProperty(t,"$recordingStop",{value:e.$container.querySelector(".jb-pro-recording-stop")}),Object.defineProperty(t,"$pause",{value:e.$container.querySelector(".jb-pro-pause")}),Object.defineProperty(t,"$controls",{value:e.$container.querySelector(".jb-pro-controls")}),Object.defineProperty(t,"$controlsInner",{value:e.$container.querySelector(".jb-pro-controls-bottom")}),Object.defineProperty(t,"$controlsLeft",{value:e.$container.querySelector(".jb-pro-controls-left")}),Object.defineProperty(t,"$controlsRight",{value:e.$container.querySelector(".jb-pro-controls-right")}),Object.defineProperty(t,"$volume",{value:e.$container.querySelector(".jb-pro-volume")}),Object.defineProperty(t,"$volumePanelWrap",{value:e.$container.querySelector(".jb-pro-volume-panel-wrap")}),Object.defineProperty(t,"$volumePanelText",{value:e.$container.querySelector(".jb-pro-volume-panel-text")}),Object.defineProperty(t,"$volumePanel",{value:e.$container.querySelector(".jb-pro-volume-panel")}),Object.defineProperty(t,"$volumeHandle",{value:e.$container.querySelector(".jb-pro-volume-panel-handle")}),Object.defineProperty(t,"$volumeOn",{value:e.$container.querySelector(".jb-pro-icon-audio")}),Object.defineProperty(t,"$volumeOff",{value:e.$container.querySelector(".jb-pro-icon-mute")}),Object.defineProperty(t,"$fullscreen",{value:e.$container.querySelector(".jb-pro-fullscreen")}),Object.defineProperty(t,"$fullscreenExit",{value:e.$container.querySelector(".jb-pro-fullscreen-exit")}),Object.defineProperty(t,"$record",{value:e.$container.querySelector(".jb-pro-record")}),Object.defineProperty(t,"$recordStop",{value:e.$container.querySelector(".jb-pro-record-stop")}),Object.defineProperty(t,"$screenshot",{value:e.$container.querySelector(".jb-pro-screenshot")}),Object.defineProperty(t,"$speed",{value:e.$container.querySelector(".jb-pro-speed")}),Object.defineProperty(t,"$controlHtml",{value:e.$container.querySelector(".jb-pro-controls-item-html")}),Object.defineProperty(t,"$playbackTime",{value:e.$container.querySelector(".jb-pro-controls-playback-time")}),Object.defineProperty(t,"$playbackTimeInner",{value:e.$container.querySelector(".jb-pro-controls-playback-time-inner")}),Object.defineProperty(t,"$playbackTimeScroll",{value:e.$container.querySelector(".jb-pro-controls-playback-time-scroll")}),Object.defineProperty(t,"$playbackTimeList",{value:e.$container.querySelector(".jb-pro-controls-playback-time-list")}),Object.defineProperty(t,"$playbackTimeListOne",{value:e.$container.querySelector(".jb-pro-playback-time-one-wrap")}),Object.defineProperty(t,"$playbackTimeListSecond",{value:e.$container.querySelector(".jb-pro-playback-time-second-wrap")}),Object.defineProperty(t,"$playbackCurrentTime",{value:e.$container.querySelector(".jb-pro-controls-playback-current-time")}),Object.defineProperty(t,"$playbackCurrentTimeText",{value:e.$container.querySelector(".jb-pro-controls-playback-current-time-text")}),Object.defineProperty(t,"$controlsPlaybackBtns",{value:e.$container.querySelector(".jb-pro-controls-playback-btns")}),Object.defineProperty(t,"$playbackNarrow",{value:e.$container.querySelector(".jb-pro-playback-narrow")}),Object.defineProperty(t,"$playbackExpand",{value:e.$container.querySelector(".jb-pro-playback-expand")}),Object.defineProperty(t,"$ptz",{value:e.$container.querySelector(".jb-pro-ptz")}),Object.defineProperty(t,"$ptzActive",{value:e.$container.querySelector(".jb-pro-ptz-active")}),Object.defineProperty(t,"$ptzControl",{value:e.$container.querySelector(".jb-pro-ptz-controls")}),Object.defineProperty(t,"$ptzBgActive",{value:e.$container.querySelector(".jb-pro-ptz-bg-active")}),Object.defineProperty(t,"$ptzControlCircular",{value:e.$container.querySelector(".jb-pro-ptz-control")}),Object.defineProperty(t,"$ptzArrows",{value:e.$container.querySelectorAll(".jb-pro-ptz-arrow")}),Object.defineProperty(t,"$ptzExpand",{value:e.$container.querySelector(".jb-pro-ptz-expand")}),Object.defineProperty(t,"$ptzNarrow",{value:e.$container.querySelector(".jb-pro-ptz-narrow")}),Object.defineProperty(t,"$ptzApertureFar",{value:e.$container.querySelector(".jb-pro-ptz-aperture-far")}),Object.defineProperty(t,"$ptzApertureNear",{value:e.$container.querySelector(".jb-pro-ptz-aperture-near")}),Object.defineProperty(t,"$ptzFocusFar",{value:e.$container.querySelector(".jb-pro-ptz-focus-far")}),Object.defineProperty(t,"$ptzFocusNear",{value:e.$container.querySelector(".jb-pro-ptz-focus-near")}),Object.defineProperty(t,"$ptzCruisePlay",{value:e.$container.querySelector(".jb-pro-ptz-cruise-play")}),Object.defineProperty(t,"$ptzCruisePause",{value:e.$container.querySelector(".jb-pro-ptz-cruise-pause")}),Object.defineProperty(t,"$ptzFogOpen",{value:e.$container.querySelector(".jb-pro-ptz-fog-open")}),Object.defineProperty(t,"$ptzFogClose",{value:e.$container.querySelector(".jb-pro-ptz-fog-close")}),Object.defineProperty(t,"$ptzWiperOpen",{value:e.$container.querySelector(".jb-pro-ptz-wiper-open")}),Object.defineProperty(t,"$ptzWiperClose",{value:e.$container.querySelector(".jb-pro-ptz-wiper-close")}),Object.defineProperty(t,"$qualityText",{value:e.$container.querySelector(".jb-pro-quality-icon-text")}),Object.defineProperty(t,"$qualityMenu",{value:e.$container.querySelector(".jb-pro-quality-menu")}),Object.defineProperty(t,"$qualityMenuList",{value:e.$container.querySelector(".jb-pro-quality-menu-list")}),Object.defineProperty(t,"$scaleText",{value:e.$container.querySelector(".jb-pro-scale-icon-text")}),Object.defineProperty(t,"$scaleMenu",{value:e.$container.querySelector(".jb-pro-scale-menu")}),Object.defineProperty(t,"$scaleMenuList",{value:e.$container.querySelector(".jb-pro-scale-menu-list")}),Object.defineProperty(t,"$zoom",{value:e.$container.querySelector(".jb-pro-zoom")}),Object.defineProperty(t,"$zoomStop",{value:e.$container.querySelector(".jb-pro-zoom-stop")}),Object.defineProperty(t,"$zoomNarrow",{value:e.$container.querySelector(".jb-pro-zoom-narrow")}),Object.defineProperty(t,"$zoomExpand",{value:e.$container.querySelector(".jb-pro-zoom-expand")}),Object.defineProperty(t,"$zoomStop2",{value:e.$container.querySelector(".jb-pro-zoom-stop2")}),Object.defineProperty(t,"$close",{value:e.$container.querySelector(".jb-pro-close")}),Object.defineProperty(t,"$zoomControls",{value:e.$container.querySelector(".jb-pro-zoom-controls")}),Object.defineProperty(t,"$performancePanel",{value:e.$container.querySelector(".jb-pro-performance-panel")}),Object.defineProperty(t,"$performance",{value:e.$container.querySelector(".jb-pro-performance")}),Object.defineProperty(t,"$performanceActive",{value:e.$container.querySelector(".jb-pro-performance-active")}),Object.defineProperty(t,"$faceDetect",{value:e.$container.querySelector(".jb-pro-face")}),Object.defineProperty(t,"$faceDetectActive",{value:e.$container.querySelector(".jb-pro-face-active")}),Object.defineProperty(t,"$objectDetect",{value:e.$container.querySelector(".jb-pro-object")}),Object.defineProperty(t,"$objectDetectActive",{value:e.$container.querySelector(".jb-pro-object-active")}),Object.defineProperty(t,"$occlusionDetect",{value:e.$container.querySelector(".jb-pro-occlusion")}),Object.defineProperty(t,"$occlusionDetectActive",{value:e.$container.querySelector(".jb-pro-occlusion-active")}),Object.defineProperty(t,"$contextmenus",{value:e.$container.querySelector(".jb-pro-contextmenus")}),Object.defineProperty(t,"$speedText",{value:e.$container.querySelector(".jb-pro-speed-icon-text")}),Object.defineProperty(t,"$speedMenu",{value:e.$container.querySelector(".jb-pro-speed-menu")}),Object.defineProperty(t,"$speedMenuList",{value:e.$container.querySelector(".jb-pro-speed-menu-list")}),Object.defineProperty(t,"$logSave",{value:e.$container.querySelector(".jb-pro-logSave")}),Object.defineProperty(t,"$playbackProgress",{value:e.$container.querySelector(".jb-pro-control-progress-simple")}),Object.defineProperty(t,"$playbackProgressTip",{value:e.$container.querySelector(".jb-pro-progress-tip")}),Object.defineProperty(t,"$playbackProgressHover",{value:e.$container.querySelector(".jb-pro-progress-hover")}),Object.defineProperty(t,"$playbackProgressPlayed",{value:e.$container.querySelector(".jb-pro-progress-played")}),Object.defineProperty(t,"$playbackProgressIndicator",{value:e.$container.querySelector(".jb-pro-progress-indicator")}),Object.defineProperty(t,"$playbackProgressTime",{value:e.$container.querySelector(".jb-pro-playback-control-time")}),Object.defineProperty(t,"$tipsMessage",{value:e.$container.querySelector(".jb-pro-tips-message")}),Object.defineProperty(t,"$tipsMessageClose",{value:e.$container.querySelector(".jb-pro-tips-message-close")}),Object.defineProperty(t,"$tipsMessageContent",{value:e.$container.querySelector(".jb-pro-tips-message-content")})})(e,this),e._opt.extendOperateBtns.length>0&&e._opt.extendOperateBtns.forEach((e=>{this.addExtendBtn(e)})),e._opt.extendDomConfig&&e._opt.extendDomConfig.html&&this.addExtendDom(e._opt.extendDomConfig),t=this,Object.defineProperty(t,"controlsRect",{get:()=>t.$controls.getBoundingClientRect()}),Object.defineProperty(t,"controlsInnerRect",{get:()=>t.$controlsInner.getBoundingClientRect()}),Object.defineProperty(t,"controlsLeftRect",{get:()=>t.$controlsLeft.getBoundingClientRect()}),Object.defineProperty(t,"controlsRightRect",{get:()=>t.$controlsRight.getBoundingClientRect()}),Object.defineProperty(t,"controlsPlaybackTimeInner",{get:()=>t.$playbackTimeInner&&t.$playbackTimeInner.getBoundingClientRect()||{}}),Object.defineProperty(t,"controlsPlaybackBtnsRect",{get:()=>t.$controlsPlaybackBtns&&t.$controlsPlaybackBtns.getBoundingClientRect()||{width:0}}),mh(e,this),((e,t)=>{const{events:{proxy:i},debug:s}=e,r=e._opt,a=r.operateBtns;function o(e){const{bottom:i,height:s}=t.$volumePanel.getBoundingClientRect(),{height:r}=t.$volumeHandle.getBoundingClientRect();return Xr(i-e.y-r/2,0,s-r/2)/(s-r)}if(aa()&&i(window,["click","contextmenu"],(i=>{i.composedPath().indexOf(e.$container)>-1?t.isFocus=!0:t.isFocus=!1})),i(t.$controls,"click",(e=>{e.stopPropagation()})),a.play&&(i(t.$pause,"click",(t=>{r.playType===v&&r.playbackConfig.uiUsePlaybackPause?e.playbackPause=!0:Ga(a.pauseFn)?a.pauseFn():e.pauseForControl()})),i(t.$play,"click",(t=>{r.playType===v&&e.playbackPause?e.playbackPause=!1:Ga(a.playFn)?a.playFn():e.playForControl().then((()=>{e.resumeAudioAfterPause()}))}))),i(t.$playBig,"click",(t=>{r.playType===v&&e.playbackPause?e.playbackPause=!1:Ga(a.playFn)?a.playFn():e.playForControl().then((()=>{e.resumeAudioAfterPause()}))})),a.screenshot&&i(t.$screenshot,"click",(t=>{t.stopPropagation(),Ga(a.screenshotFn)?a.screenshotFn():e.video.screenshot()})),a.audio&&(aa()&&(i(t.$volume,"mouseover",(()=>{t.$volumePanelWrap.classList.add("jb-pro-volume-panel-wrap-show")})),i(t.$volume,"mouseout",(()=>{t.$volumePanelWrap.classList.remove("jb-pro-volume-panel-wrap-show")})),i(t.$volumePanel,"click",(t=>{t.stopPropagation(),e.volume=o(t)})),i(t.$volumeHandle,"mousedown",(e=>{e.stopPropagation(),t.isVolumeDroging=!0})),i(t.$volumeHandle,"mousemove",(i=>{t.isVolumeDroging&&(e.volume=o(i))})),i(document,"mouseup",(()=>{t.isVolumeDroging&&(t.isVolumeDroging=!1)}))),i(t.$volumeOn,"click",(i=>{i.stopPropagation(),Zr(t.$volumeOn,"display","none"),Zr(t.$volumeOff,"display","block");const s=e.volume;e.volume=0,e._lastVolume=aa()?s:1})),i(t.$volumeOff,"click",(i=>{i.stopPropagation(),Zr(t.$volumeOn,"display","block"),Zr(t.$volumeOff,"display","none"),e.volume=aa()?e.lastVolume||.5:1}))),a.record&&(i(t.$record,"click",(t=>{t.stopPropagation(),Ga(a.recordFn)?a.recordFn():e.recording=!0})),i(t.$recordStop,"click",(t=>{t.stopPropagation(),Ga(a.recordStopFn)?a.recordStopFn():e.recording=!1}))),i(t.$recordingStop,"click",(t=>{t.stopPropagation(),Ga(a.recordStopFn)?a.recordStopFn():e.recording=!1})),a.fullscreen&&(i(t.$fullscreen,"click",(t=>{t.stopPropagation(),Ga(a.fullscreenFn)?a.fullscreenFn():e.fullscreen=!0})),i(t.$fullscreenExit,"click",(t=>{t.stopPropagation(),Ga(a.fullscreenExitFn)?a.fullscreenExitFn():e.fullscreen=!1}))),a.ptz){if(i(t.$ptz,"click",(e=>{e.stopPropagation(),Zr(t.$ptzActive,"display","flex"),Zr(t.$ptz,"display","none"),t.$ptzControl.classList.add("jb-pro-ptz-controls-show")})),i(t.$ptzActive,"click",(e=>{e.stopPropagation(),Zr(t.$ptz,"display","flex"),Zr(t.$ptzActive,"display","none"),t.$ptzControl.classList.remove("jb-pro-ptz-controls-show")})),t.$ptzArrows.forEach((s=>{if(r.ptzClickType===K)i(s,"click",(i=>{i.stopPropagation();const s=i.currentTarget.dataset.arrow;t.$ptzBgActive.classList.add("jb-pro-ptz-bg-active-show"),t.$ptzBgActive.classList.add(`jb-pro-ptz-bg-active-${s}`),t.$ptzControlCircular.classList.add(`jb-pro-ptz-control-${s}`),e.emit(nt.ptz,ao(s)),setTimeout((()=>{t.$ptzBgActive.classList.remove("jb-pro-ptz-bg-active-show"),_i.forEach((e=>{t.$ptzBgActive.classList.remove(`jb-pro-ptz-bg-active-${e}`),t.$ptzControlCircular.classList.remove(`jb-pro-ptz-control-${e}`)})),e.emit(nt.ptz,vi)}),1e3*r.ptzStopEmitDelay)}));else if(r.ptzClickType===Y){let r=!1;i(s,"mousedown",(i=>{i.stopPropagation(),r=!0;const s=i.currentTarget.dataset.arrow;t.$ptzBgActive.classList.add("jb-pro-ptz-bg-active-show"),t.$ptzBgActive.classList.add(`jb-pro-ptz-bg-active-${s}`),t.$ptzControlCircular.classList.add(`jb-pro-ptz-control-${s}`),e.emit(nt.ptz,ao(s))}));const a=()=>{r=!1,t.$ptzBgActive.classList.remove("jb-pro-ptz-bg-active-show"),_i.forEach((e=>{t.$ptzBgActive.classList.remove(`jb-pro-ptz-bg-active-${e}`),t.$ptzControlCircular.classList.remove(`jb-pro-ptz-control-${e}`)})),e.emit(nt.ptz,vi)};i(s,"mouseup",(e=>{e.stopPropagation(),r&&a()})),i(window,"mouseup",(e=>{e.stopPropagation(),r&&a()}))}})),r.ptzZoomShow)if(r.ptzClickType===K)i(t.$ptzExpand,"click",(t=>{t.stopPropagation(),e.emit(nt.ptz,wi),setTimeout((()=>{e.emit(nt.ptz,vi)}),1e3*r.ptzStopEmitDelay)})),i(t.$ptzNarrow,"click",(t=>{t.stopPropagation(),e.emit(nt.ptz,Ei),setTimeout((()=>{e.emit(nt.ptz,vi)}),1e3*r.ptzStopEmitDelay)}));else if(r.ptzClickType===Y){let n=!1,l=!1;i(t.$ptzExpand,"mousedown",(t=>{t.stopPropagation(),n=!0,e.emit(nt.ptz,wi)})),i(t.$ptzNarrow,"mousedown",(t=>{t.stopPropagation(),l=!0,e.emit(nt.ptz,Ei)}));const d=()=>{n=!1,l=!1,e.emit(nt.ptz,vi)};i(t.$ptzExpand,"mouseup",(e=>{e.stopPropagation(),n&&d()})),i(t.$ptzNarrow,"mouseup",(e=>{e.stopPropagation(),l&&d()})),i(window,"mouseup",(e=>{e.stopPropagation(),(n||l)&&d()}))}if(r.ptzApertureShow)if(r.ptzClickType===K)i(t.$ptzApertureFar,"click",(t=>{t.stopPropagation(),e.emit(nt.ptz,Ti),setTimeout((()=>{e.emit(nt.ptz,Si)}),1e3*r.ptzStopEmitDelay)})),i(t.$ptzApertureNear,"click",(t=>{t.stopPropagation(),e.emit(nt.ptz,ki),setTimeout((()=>{e.emit(nt.ptz,Si)}),1e3*r.ptzStopEmitDelay)}));else if(r.ptzClickType===Y){let h=!1,c=!1;i(t.$ptzApertureFar,"mousedown",(t=>{t.stopPropagation(),h=!0,e.emit(nt.ptz,Ti)})),i(t.$ptzApertureNear,"mousedown",(t=>{t.stopPropagation(),c=!0,e.emit(nt.ptz,ki)}));const u=()=>{h=!1,c=!1,e.emit(nt.ptz,Si)};i(t.$ptzApertureFar,"mouseup",(e=>{e.stopPropagation(),h&&u()})),i(t.$ptzApertureNear,"mouseup",(e=>{e.stopPropagation(),c&&u()})),i(window,"mouseup",(e=>{e.stopPropagation(),(h||c)&&u()}))}if(r.ptzFocusShow)if(r.ptzClickType===K)i(t.$ptzFocusFar,"click",(t=>{t.stopPropagation(),e.emit(nt.ptz,Ci),setTimeout((()=>{e.emit(nt.ptz,Si)}),1e3*r.ptzStopEmitDelay)})),i(t.$ptzFocusNear,"click",(t=>{t.stopPropagation(),e.emit(nt.ptz,Ri),setTimeout((()=>{e.emit(nt.ptz,Si)}),1e3*r.ptzStopEmitDelay)}));else if(r.ptzClickType===Y){let p=!1,f=!1;i(t.$ptzFocusFar,"mousedown",(t=>{t.stopPropagation(),p=!0,e.emit(nt.ptz,Ci)})),i(t.$ptzFocusNear,"mousedown",(t=>{t.stopPropagation(),f=!0,e.emit(nt.ptz,Ri)}));const m=()=>{p=!1,f=!1,e.emit(nt.ptz,Si)};i(t.$ptzFocusFar,"mouseup",(e=>{e.stopPropagation(),p&&m()})),i(t.$ptzFocusNear,"mouseup",(e=>{e.stopPropagation(),f&&m()})),i(window,"mouseup",(e=>{e.stopPropagation(),(p||f)&&m()}))}if(r.ptzCruiseShow&&(i(t.$ptzCruisePlay,"click",(t=>{t.stopPropagation(),e.emit(nt.ptz,xi)})),i(t.$ptzCruisePause,"click",(t=>{t.stopPropagation(),e.emit(nt.ptz,Di)}))),r.ptzFogShow&&(i(t.$ptzFogOpen,"click",(t=>{t.stopPropagation(),e.emit(nt.ptz,Li)})),i(t.$ptzFogClose,"click",(t=>{t.stopPropagation(),e.emit(nt.ptz,Pi)}))),r.ptzWiperShow&&(i(t.$ptzWiperOpen,"click",(t=>{t.stopPropagation(),e.emit(nt.ptz,Bi)})),i(t.$ptzWiperClose,"click",(t=>{t.stopPropagation(),e.emit(nt.ptz,Ii)}))),r.ptzSupportDraggable){function g(){t.isPtzControlDroging&&(t.isPtzControlDroging=!1,t.$ptzControl.style.cursor="grab",t.tempPtzPosition={x:0,y:0})}t.isPtzControlDroging=!1,t.tempPtzPosition={x:0,y:0},i(t.$ptzControl,ra()?"touchstart":"mousedown",(e=>{e.stopPropagation(),t.isPtzControlDroging=!0,t.$ptzControl.style.cursor="grabbing";const{posX:i,posY:s}=Ha(e);t.tempPtzPosition={x:i,y:s}})),i(t.$ptzControl,ra()?"touchmove":"mousemove",(e=>{if(t.isPtzControlDroging){e.stopPropagation();const{posX:i,posY:s}=Ha(e),r=t.tempPtzPosition.x-i,a=t.tempPtzPosition.y-s;t.$ptzControl.style.left=t.$ptzControl.offsetLeft-r+"px",t.$ptzControl.style.top=t.$ptzControl.offsetTop-a+"px",t.tempPtzPosition={x:i,y:s}}})),i(t.$ptzControl,ra()?"touchend":"mouseup",(e=>{e.stopPropagation(),g()})),i(window,ra()?"touchend":"mouseup",(e=>{e.stopPropagation(),g()}))}}if(a.performance&&(i(t.$performance,"click",(t=>{t.stopPropagation(),e.togglePerformancePanel(!0)})),i(t.$performanceActive,"click",(t=>{t.stopPropagation(),e.togglePerformancePanel(!1)}))),a.logSave&&i(t.$logSave,"click",(t=>{t.stopPropagation(),e.downloadMemoryLog()})),a.aiFace&&(i(t.$faceDetect,"click",(t=>{t.stopPropagation(),e.faceDetect(!0)})),i(t.$faceDetectActive,"click",(t=>{t.stopPropagation(),e.faceDetect(!1)}))),a.aiObject&&(i(t.$objectDetect,"click",(t=>{t.stopPropagation(),e.objectDetect(!0)})),i(t.$objectDetectActive,"click",(t=>{t.stopPropagation(),e.objectDetect(!1)}))),a.aiOcclusion&&(i(t.$occlusionDetect,"click",(t=>{t.stopPropagation(),e.occlusionDetect(!0)})),i(t.$occlusionDetectActive,"click",(t=>{t.stopPropagation(),e.occlusionDetect(!1)}))),e._opt.hasControl&&e._opt.controlAutoHide){i(e.$container,"mouseover",(()=>{e.fullscreen||(Zr(t.$controls,"display","block"),A())})),i(e.$container,"mousemove",(()=>{e.$container&&t.$controls&&(e.fullscreen,"none"===t.$controls.style.display&&(Zr(t.$controls,"display","block"),A()))})),i(e.$container,"mouseout",(()=>{b(),Zr(t.$controls,"display","none")}));let y=null;const A=()=>{b(),y=setTimeout((()=>{Zr(t.$controls,"display","none")}),5e3)},b=()=>{y&&(clearTimeout(y),y=null)}}if(e._opt.playType===v){let _=e._opt.playbackConfig.controlType;e._opt.playbackConfig.showRateBtn&&(i(t.$speedMenu,"mouseover",(()=>{t.$speedMenuList.classList.add("jb-pro-speed-menu-shown")})),i(t.$speedMenu,"mouseout",(()=>{t.$speedMenuList.classList.remove("jb-pro-speed-menu-shown")})),i(t.$speedMenuList,"click",(t=>{const i=ja(t);if(i.matches("div.jb-pro-speed-menu-item")){const t=i.dataset;e.emit(nt.playbackPreRateChange,t.speed)}}))),_===Q.normal?(i(t.$playbackNarrow,"click",(t=>{t.stopPropagation(),e.playback&&e.playback.narrowPrecision()})),i(t.$playbackExpand,"click",(t=>{t.stopPropagation(),e.playback&&e.playback.expandPrecision()})),i(t.$playbackTimeList,"click",(t=>{const i=ja(t);i.matches("div.jb-pro-playback-time-minute-one")&&e.playback&&e.playback.seek(i.dataset)})),e._opt.playbackConfig.supportWheel&&i(t.$playbackTimeInner,"wheel",(t=>{t.preventDefault(),(t.wheelDelta?t.wheelDelta/120:-(t.detail||0)/3)>0?e.playback&&e.playback.expandPrecision():e.playback&&e.playback.narrowPrecision()}))):_===Q.simple&&(t.isDroging=!1,i(t.$playbackProgress,"click",(i=>{if(i.target!==t.$playbackProgressIndicator){let s=0,r=0;if(e.isInWebFullscreen())s=i.touches[0].clientY/e.height,r=s*e.playback.totalDuration;else{const a=dh(t,e.playback.totalDuration,i);s=a.percentage,r=a.second}e.playback&&e.playback.seek({time:r})}})),i(t.$playbackProgress,"mousemove",(i=>{Zr(t.$playbackProgressTip,"display","block");const{width:s,time:r}=dh(t,e.playback.totalDuration,i);t.$playbackProgressTip.innerHTML=r;const a=t.$playbackProgressTip.clientWidth;s<=a/2?Zr(t.$playbackProgressTip,"left",0):s>t.$playbackProgress.clientWidth-a/2?Zr(t.$playbackProgressTip,"left",t.$playbackProgress-a+"px"):Zr(t.$playbackProgressTip,"left",s-a/2+"px")})),i(t.$playbackProgress,"mouseout",(()=>{Zr(t.$playbackProgressTip,"display","none")})),i(t.$playbackProgressIndicator,"mousedown",(e=>{t.isDroging=!0})),i(t.$playbackProgress,"mousemove",(i=>{if(t.isDroging){const{second:s,percentage:r}=dh(t,e.playback.totalDuration,i);e.playback&&e.playback.seek({time:s})}})),i(t.$playbackProgress,"mouseup",(e=>{t.isDroging&&(t.isDroging=!1)})))}a.quality&&(i(t.$qualityMenu,"mouseover",(()=>{t.$qualityMenuList.classList.add("jb-pro-quality-menu-shown")})),i(t.$qualityMenu,"mouseout",(()=>{t.$qualityMenuList.classList.remove("jb-pro-quality-menu-shown")})),i(t.$qualityMenuList,"click",(t=>{const i=ja(t);if(i.matches("div.jb-pro-quality-menu-item")){const t=i.dataset;e.streamQuality=t.quality}}))),a.scale&&(i(t.$scaleMenu,"mouseover",(()=>{t.$scaleMenuList.classList.add("jb-pro-scale-menu-shown")})),i(t.$scaleMenu,"mouseout",(()=>{t.$scaleMenuList.classList.remove("jb-pro-scale-menu-shown")})),i(t.$scaleMenuList,"click",(t=>{const i=ja(t);if(i.matches("div.jb-pro-scale-menu-item")){const t=i.dataset;e.setScaleMode(t.scale)}}))),a.zoom&&(i(t.$zoom,"click",(t=>{t.stopPropagation(),e.zooming=!0})),i(t.$zoomStop,"click",(t=>{t.stopPropagation(),e.zooming=!1}))),i(t.$zoomExpand,"click",(t=>{t.stopPropagation(),e.zoom&&e.zoom.expandPrecision()})),i(t.$zoomNarrow,"click",(t=>{t.stopPropagation(),e.zoom&&e.zoom.narrowPrecision()})),i(t.$zoomStop2,"click",(t=>{t.stopPropagation(),e.zooming=!1})),a.close&&i(t.$close,"click",(t=>{t.stopPropagation(),e.doDestroy()})),i(t.$tipsMessageClose,"click",(e=>{e.stopPropagation(),t.$tipsMessageContent.innerHTML="",Zr(t.$tipsMessage,"display","none")}))})(e,this),e._opt.hotKey&&((e,t)=>{const{events:{proxy:i}}=e,s={};function r(e,t){s[e]?s[e].push(t):s[e]=[t]}r(ci,(()=>{e.fullscreen&&(e.fullscreen=!1)})),r(ui,(()=>{e.volume+=.05})),r(pi,(()=>{e.volume-=.05})),i(window,"keydown",(e=>{if(t.isFocus){const t=document.activeElement.tagName.toUpperCase(),i=document.activeElement.getAttribute("contenteditable");if("INPUT"!==t&&"TEXTAREA"!==t&&""!==i&&"true"!==i){const t=s[e.keyCode];t&&(e.preventDefault(),t.forEach((e=>e())))}}}))})(e,this),this.btnIndex=0,this.initLoadingBackground(),Ua(e._opt.loadingIconStyle)&&this.initLoadingIconStyle(e._opt.loadingIconStyle),Ua(e._opt.ptzPositionConfig)&&this.updatePtzPosition(e._opt.ptzPositionConfig),this.kbpsShow="0 KB/s",this.player.debug.log("Control","init")}destroy(){if(this.$performancePanel){this.$performancePanel.innerHTML="";if(!fh(this.$performancePanel)){const e=this.player.$container.querySelector(".jb-pro-performance-panel");e&&this.player.$container&&this.player.$container.removeChild(e)}}if(this.$poster){if(!fh(this.$poster)){const e=this.player.$container.querySelector(".jb-pro-poster");e&&this.player.$container&&this.player.$container.removeChild(e)}}if(this.$loading){if(!fh(this.$loading)){const e=this.player.$container.querySelector(".jb-pro-loading");e&&this.player.$container&&this.player.$container.removeChild(e)}}if(this.$loadingBg){if(!fh(this.$loadingBg)){const e=this.player.$container.querySelector(".jb-pro-loading-bg");e&&this.player.$container&&this.player.$container.removeChild(e)}}if(this.$controls){if(!fh(this.$controls)){const e=this.player.$container.querySelector(".jb-pro-controls");e&&this.player.$container&&this.player.$container.removeChild(e)}}if(this.$playBig){if(!fh(this.$playBig)){const e=this.player.$container.querySelector(".jb-pro-play-big");e&&this.player.$container&&this.player.$container.removeChild(e)}}if(this.$recording){if(!fh(this.$recording)){const e=this.player.$container.querySelector(".jb-pro-recording");e&&this.player.$container&&this.player.$container.removeChild(e)}}if(this.$ptzControl){if(!fh(this.$ptzControl)){const e=this.player.$container.querySelector(".jb-pro-ptz-controls");e&&this.player.$container&&this.player.$container.removeChild(e)}}if(this.$zoomControls){if(!fh(this.$zoomControls)){const e=this.player.$container.querySelector(".jb-pro-zoom-controls");e&&this.player.$container&&this.player.$container.removeChild(e)}}if(this.$contextmenus){this.$contextmenus.innerHTML="";if(!fh(this.$contextmenus)){const e=this.player.$container.querySelector(".jb-pro-contextmenus");e&&this.player.$container&&this.player.$container.removeChild(e)}}if(this.$tipsMessage){if(!fh(this.$tipsMessage)){const e=this.player.$container.querySelector(".jb-pro-tips-message");e&&this.player.$container&&this.player.$container.removeChild(e)}}if(this.$extendDom){if(!fh(this.$extendDom)){const e=this.player.$container.querySelector(".jb-pro-extend-dom");e&&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("jb-pro-controls-show-auto-hide"),this.player.$container.classList.remove("jb-pro-controls-show")),this.player.debug.log("Control","destroy")}getBtnIndex(){return this.btnIndex++}autoSize(){const e=this.player;e.$container.style.padding="0 0";const t=e.width,i=e.height,s=t/i,r=e.video.$videoElement.width/e.video.$videoElement.height;if(s>r){const s=(t-i*r)/2;e.$container.style.padding=`0 ${s}px`}else{const s=(i-t/r)/2;e.$container.style.padding=`${s}px 0`}}initLoadingBackground(){const e=this.player;e._opt.loadingBackground&&e._opt.loadingBackgroundWidth&&e._opt.loadingBackgroundHeight&&(e.debug.log("Control","initLoadingBackground()"),"default"===this.player._opt.aspectRatio||ra()?(e.getRenderType()===V||e.getRenderType()===W)&&this._initLoadingBackground():this._initLoadingBackgroundForRatio(),uh(this.$loadingBg,"display","block"),e._opt.loadingBackground="",e._opt.loadingBackgroundWidth=0,e._opt.loadingBackgroundHeight=0)}initLoadingIconStyle(e){const t=this.player.$container.querySelector(".jb-pro-icon-loading");t&&(e.width&&uh(t,"width",`${e.width}px`),e.height&&uh(t,"height",`${e.height}px`),e.background&&uh(t,"backgroundImage",`url("${e.background}")`),!1===e.hasAnimation&&(uh(t,"animationName","none"),uh(t,"animationDuration",0),uh(t,"animationTimingFunction","ease"),uh(t,"animationIterationCount",1)))}_initLoadingBackgroundForRatio(){const e=this.player._opt.aspectRatio.split(":").map(Number);let t=this.player.width,i=this.player.height;const s=this.player._opt;let r=0;s.hasControl&&!s.controlAutoHide&&(r=s.playType===v?zt:jt,i-=r);const a=this.player._opt.loadingBackgroundWidth,o=this.player._opt.loadingBackgroundHeight,n=a/o,l=e[0]/e[1];if(this.$loadingBgImage.src=this.player._opt.loadingBackground,n>l){const e=l*o/a;this.$loadingBgImage.style.width=100*e+"%",this.$loadingBgImage.style.height=`calc(100% - ${r}px)`,this.$loadingBgImage.style.padding=`0 ${(t-t*e)/2}px`}else{const e=a/l/o;this.$loadingBgImage.style.width="100%",this.$loadingBgImage.style.height=`calc(${100*e}% - ${r}px)`,this.$loadingBgImage.style.padding=(i-i*e)/2+"px 0"}}_initLoadingBackground(){const e=this.player;let t=e.height;const i=e._opt;if(i.hasControl&&!i.controlAutoHide){t-=i.playType===v?zt:jt}let s=e.width,r=t;const a=i.rotate;270!==a&&90!==a||(s=t,r=e.width),this.$loadingBgImage.width=s,this.$loadingBgImage.height=r,this.$loadingBgImage.src=e._opt.loadingBackground;let o=(e.width-s)/2,n=(t-r)/2,l="contain";i.isResize||(l="fill"),i.isFullResize&&(l="none");let d="";"none"===i.mirrorRotate&&a&&(d+=" rotate("+a+"deg)"),"level"===i.mirrorRotate?d+=" rotateY(180deg)":"vertical"===i.mirrorRotate&&(d+=" rotateX(180deg)"),this.player._opt.videoRenderSupportScale&&(this.$loadingBgImage.style.objectFit=l),this.$loadingBgImage.style.transform=d,this.$loadingBgImage.style.padding="0",this.$loadingBgImage.style.left=o+"px",this.$loadingBgImage.style.top=n+"px"}_validateExtendBtn(e){let t=!0;if(e.name||(this.player.debug.warn("Control","extend button name is required"),t=!1),t){-1!==this.extendBtnList.findIndex((t=>t.name===e.name))&&(this.player.debug.warn("Control",`extend button name: ${e.name} is already exist`),t=!1)}return t&&(e.icon||(this.player.debug.warn("Control","extend button icon is required"),t=!1)),t}addExtendBtn(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=Za(Ds);if(e=Object.assign({},t,e),!this._validateExtendBtn(e))return;const i=e.name||"",s=this.$controlsRight,r=e.activeIcon&&e.activeClick,a=`\n <div class="jb-pro-controls-item-wrap jb-pro-controls-item-wrap-${i}">\n ${e.icon?`<div class="jb-pro-controls-item jb-pro-control-extend-${i}">\n <i class="jb-pro-icon jb-pro-icon-extend-${i}"></i>\n ${e.iconTitle?`\n <span class="icon-title-tips"><span class="icon-title">${e.iconTitle}</span></span>\n `:""}\n </div>`:""}\n ${e.activeIcon?`<div class="jb-pro-controls-item jb-pro-control-extend-${i}-active">\n <i class="jb-pro-icon jb-pro-icon-extend-${i}-active"></i>\n ${e.activeIconTitle?`\n <span class="icon-title-tips"><span class="icon-title">${e.activeIconTitle}</span></span>\n `:""}\n </div>`:""}\n </div>\n `,o=Array.from(s.children)[e.index];o?o.insertAdjacentHTML("beforebegin",a):ch(s,a);const n=s.querySelector(`.jb-pro-controls-item-wrap-${i}`),l=e.icon?s.querySelector(`.jb-pro-icon-extend-${i}`):null,d=e.icon?s.querySelector(`.jb-pro-control-extend-${i}`):null,h=e.activeIcon?s.querySelector(`.jb-pro-icon-extend-${i}-active`):null,c=e.activeIcon?s.querySelector(`.jb-pro-control-extend-${i}-active`):null,{events:{proxy:u},debug:p}=this.player;e.icon&&(uh(l,"background",`url(${e.icon}) no-repeat center`),uh(l,"background-size","100% 100%"),uh(d,"display","none"),e.iconHover&&(u(l,"mouseover",(()=>{uh(l,"background",`url(${e.iconHover}) no-repeat center`),uh(l,"background-size","100% 100%")})),u(l,"mouseout",(()=>{uh(l,"background",`url(${e.icon}) no-repeat center`),uh(l,"background-size","100% 100%")})))),e.activeIcon&&(uh(h,"background",`url(${e.activeIcon}) no-repeat center`),uh(h,"background-size","100% 100%"),uh(c,"display","none"),e.activeIconHover&&(u(h,"mouseover",(()=>{uh(h,"background",`url(${e.activeIconHover}) no-repeat center`),uh(h,"background-size","100% 100%")})),u(h,"mouseout",(()=>{uh(h,"background",`url(${e.activeIcon}) no-repeat center`),uh(h,"background-size","100% 100%")})))),e.click&&l&&u(l,"click",(t=>{t.preventDefault(),r&&(uh(d,"display","none"),uh(c,"display","flex")),this.player.isInMulti()?e.click.call(this.player,t,this.player._opt.multiIndex):e.click.call(this.player,t)})),e.activeClick&&h&&u(h,"click",(t=>{t.preventDefault(),uh(d,"display","flex"),uh(c,"display","none"),this.player.isInMulti()?e.activeClick.call(this.player,t,this.player._opt.multiIndex):e.activeClick.call(this.player,t)})),this.extendBtnList.push({name:i,$iconContainer:n,$iconWrap:d,$activeIconWrap:c})}addExtendDom(e){if(this.player.debug.log(this.TAG_NAME,"addExtendDom"),e.html){const t=`\n <div class="jb-pro-extend-dom">\n ${e.html}\n </div>\n `;this.player.$container.insertAdjacentHTML("beforeend",t),Object.defineProperty(this,"$extendDom",{value:this.player.$container.querySelector(".jb-pro-extend-dom")}),e.showBeforePlay&&uh(this.$extendDom,"display","block")}}toggleExtendDom(e){this.$extendDom&&(Ea(e)||(e="none"===this.$extendDom.style.display),uh(this.$extendDom,"display",e?"block":"none"))}updateExtendDom(e){this.player.debug.log(this.TAG_NAME,"updateExtendDom"),this.$extendDom&&(this.$extendDom.innerHTML=e)}removeExtendDom(){this.player.debug.log(this.TAG_NAME,"removeExtendDom"),this.$extendDom&&(this.$extendDom.innerHTML="")}updateLoadingText(e){this.$loadingText&&(this.$loadingText.innerText=e)}getExtendBtnList(){return this.extendBtnList}showTipsMessage(e,t){const i=this.$tipsMessage,s=this.$tipsMessageContent;if(i){const r=`\n <div class="jb-pro-tips-message-content-item">${e}</div>\n ${t?`<div class="jb-pro-tips-message-content-item">Error Type:${t}</div>`:""}\n `;s.innerHTML=r,uh(i,"display","block")}}hideTipsMessage(){const e=this.$tipsMessage;e&&($tipsMessageContent.innerHTML="",uh(e,"display","none"))}updatePtzPosition(e){const t=this.$ptzControl;if(Ua(e)&&t){let i="auto";e.left&&(i=Number(e.left)===e.left?e.left+"px":e.left),uh(t,"left",i);let s="auto";e.top&&(s=Number(e.top)===e.top?e.top+"px":e.top),uh(t,"top",s);let r="auto";e.bottom&&(r=Number(e.bottom)===e.bottom?e.bottom+"px":e.bottom),uh(t,"bottom",r);let a="auto";e.right&&(a=Number(e.right)===e.right?e.right+"px":e.right),uh(t,"right",a)}}}gh(".jb-pro-container{position:relative;width:100%;height:100%;overflow:hidden}.jb-pro-container.jb-pro-fullscreen-web{position:fixed;z-index:9999;left:0;top:0;right:0;bottom:0;width:100vw!important;height:100vh!important;background:#000}.jb-pro-container .jb-pro-loading-bg-for-ios{position:absolute;z-index:100;left:0;top:0;right:0;bottom:0;height:100%;width:100%;opacity:0;visibility:hidden;background-position:50%;background-repeat:no-repeat;background-size:contain;pointer-events:none}.jb-pro-container .jb-pro-loading-bg-for-ios.show{opacity:1;visibility:visible}");var Ah=e=>{const{_opt:t,debug:i,events:{proxy:s}}=e;if(t.supportDblclickFullscreen&&s(e.$container,"dblclick",(t=>{const i=ja(t).nodeName.toLowerCase();"canvas"!==i&&"video"!==i||(e.fullscreen=!e.fullscreen)})),s(document,"visibilitychange",(()=>{e.visibility="visible"===document.visibilityState,i.log("visibilitychange",document.visibilityState),t.hiddenAutoPause&&(i.log("visibilitychange","hiddenAutoPause is true ",document.visibilityState,e._isPlayingBeforePageHidden),"visible"===document.visibilityState?e._isPlayingBeforePageHidden&&e.play():(e._isPlayingBeforePageHidden=e.playing,e.playing&&e.pause()))})),aa()&&s(document,["click","contextmenu"],(t=>{ph(t,e.$container)?(so(e._opt.disableContextmenu)&&"contextmenu"===t.type&&t.preventDefault(),e.isInput="INPUT"===t.target.tagName,e.isFocus=!0,e.emit(nt.focus)):(e.isInput=!1,e.isFocus=!1,e.emit(nt.blur))})),t.isCheckInView){const t=ma((()=>{e.emit(nt.inView,function(e){const t=e.getBoundingClientRect(),i=window.innerHeight||document.documentElement.clientHeight,s=window.innerWidth||document.documentElement.clientWidth,r=t.top<=i&&t.top+t.height>=0,a=t.left<=s&&t.left+t.width>=0;return r&&a}(e.$container))}),200);s(window,"scroll",(()=>t()))}if(t.autoResize){const t=ma((()=>{e.resize()}),500);s(window,["resize","orientationchange"],(()=>{t()})),screen&&screen.orientation&&screen.orientation.onchange&&s(screen.orientation,"change",(()=>{t()}))}};class bh{static init(){bh.types={avc1:[],avcC:[],hvc1:[],hvcC:[],av01:[],av1C:[],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":[],Opus:[],dOps:[],"ac-3":[],dac3:[],"ec-3":[],dec3:[]};for(let e in bh.types)bh.types.hasOwnProperty(e)&&(bh.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);let e=bh.constants={};e.FTYP=new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]),e.STSD_PREFIX=new Uint8Array([0,0,0,0,0,0,0,1]),e.STTS=new Uint8Array([0,0,0,0,0,0,0,0]),e.STSC=e.STCO=e.STTS,e.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),e.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]),e.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]),e.DREF=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),e.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),e.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])}static box(e){let t=8,i=null,s=Array.prototype.slice.call(arguments,1),r=s.length;for(let e=0;e<r;e++)t+=s[e].byteLength;i=new Uint8Array(t),i[0]=t>>>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<r;e++)i.set(s[e],a),a+=s[e].byteLength;return i}static generateInitSegment(e){let t=bh.box(bh.types.ftyp,bh.constants.FTYP),i=bh.moov(e),s=new Uint8Array(t.byteLength+i.byteLength);return s.set(t,0),s.set(i,t.byteLength),s}static moov(e){let t=bh.mvhd(e.timescale,e.duration),i=bh.trak(e),s=bh.mvex(e);return bh.box(bh.types.moov,t,i,s)}static mvhd(e,t){return bh.box(bh.types.mvhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,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 bh.box(bh.types.trak,bh.tkhd(e),bh.mdia(e))}static tkhd(e){let t=e.id,i=e.duration,s=e.presentWidth,r=e.presentHeight;return bh.box(bh.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,s>>>8&255,255&s,0,0,r>>>8&255,255&r,0,0]))}static mdia(e){return bh.box(bh.types.mdia,bh.mdhd(e),bh.hdlr(e),bh.minf(e))}static mdhd(e){let t=e.timescale,i=e.duration;return bh.box(bh.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,i>>>24&255,i>>>16&255,i>>>8&255,255&i,85,196,0,0]))}static hdlr(e){let t=null;return t="audio"===e.type?bh.constants.HDLR_AUDIO:bh.constants.HDLR_VIDEO,bh.box(bh.types.hdlr,t)}static minf(e){let t=null;return t="audio"===e.type?bh.box(bh.types.smhd,bh.constants.SMHD):bh.box(bh.types.vmhd,bh.constants.VMHD),bh.box(bh.types.minf,t,bh.dinf(),bh.stbl(e))}static dinf(){return bh.box(bh.types.dinf,bh.box(bh.types.dref,bh.constants.DREF))}static stbl(e){return bh.box(bh.types.stbl,bh.stsd(e),bh.box(bh.types.stts,bh.constants.STTS),bh.box(bh.types.stsc,bh.constants.STSC),bh.box(bh.types.stsz,bh.constants.STSZ),bh.box(bh.types.stco,bh.constants.STCO))}static stsd(e){return"audio"===e.type?"mp3"===e.audioType?bh.box(bh.types.stsd,bh.constants.STSD_PREFIX,bh.mp3(e)):bh.box(bh.types.stsd,bh.constants.STSD_PREFIX,bh.mp4a(e)):"avc"===e.videoType?bh.box(bh.types.stsd,bh.constants.STSD_PREFIX,bh.avc1(e)):bh.box(bh.types.stsd,bh.constants.STSD_PREFIX,bh.hvc1(e))}static mp3(e){let t=e.channelCount,i=e.audioSampleRate,s=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 bh.box(bh.types[".mp3"],s)}static mp4a(e){let t=e.channelCount,i=e.audioSampleRate,s=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 bh.box(bh.types.mp4a,s,bh.esds(e))}static esds(e){let t=e.config||[],i=t.length,s=new Uint8Array([0,0,0,0,3,23+i,0,1,0,4,15+i,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([i]).concat(t).concat([6,1,2]));return bh.box(bh.types.esds,s)}static avc1(e){let t=e.avcc;const i=e.codecWidth,s=e.codecHeight;let r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,i>>>8&255,255&i,s>>>8&255,255&s,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 bh.box(bh.types.avc1,r,bh.box(bh.types.avcC,t))}static hvc1(e){let t=e.avcc;const i=e.codecWidth,s=e.codecHeight;let r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,i>>>8&255,255&i,s>>>8&255,255&s,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 bh.box(bh.types.hvc1,r,bh.box(bh.types.hvcC,t))}static mvex(e){return bh.box(bh.types.mvex,bh.trex(e))}static trex(e){let t=e.id,i=new Uint8Array([0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return bh.box(bh.types.trex,i)}static moof(e,t){return bh.box(bh.types.moof,bh.mfhd(e.sequenceNumber),bh.traf(e,t))}static mfhd(e){let t=new Uint8Array([0,0,0,0,e>>>24&255,e>>>16&255,e>>>8&255,255&e]);return bh.box(bh.types.mfhd,t)}static traf(e,t){let i=e.id,s=bh.box(bh.types.tfhd,new Uint8Array([0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i])),r=bh.box(bh.types.tfdt,new Uint8Array([0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t])),a=bh.sdtp(e),o=bh.trun(e,a.byteLength+16+16+8+16+8+8);return bh.box(bh.types.traf,s,r,o,a)}static sdtp(e){let t=new Uint8Array(5),i=e.flags;return t[4]=i.isLeading<<6|i.dependsOn<<4|i.isDependedOn<<2|i.hasRedundancy,bh.box(bh.types.sdtp,t)}static trun(e,t){let i=new Uint8Array(28);t+=36,i.set([0,0,15,1,0,0,0,1,t>>>24&255,t>>>16&255,t>>>8&255,255&t],0);let s=e.duration,r=e.size,a=e.flags,o=e.cts;return i.set([s>>>24&255,s>>>16&255,s>>>8&255,255&s,r>>>24&255,r>>>16&255,r>>>8&255,255&r,a.isLeading<<2|a.dependsOn,a.isDependedOn<<6|a.hasRedundancy<<4|a.isNonSync,0,0,o>>>24&255,o>>>16&255,o>>>8&255,255&o],12),bh.box(bh.types.trun,i)}static mdat(e){return bh.box(bh.types.mdat,e)}}bh.init();const _h=[44100,48e3,32e3,0],vh=[22050,24e3,16e3,0],Sh=[11025,12e3,8e3,0],wh=[0,32,64,96,128,160,192,224,256,288,320,352,384,416,448,-1],Eh=[0,32,48,56,64,80,96,112,128,160,192,224,256,320,384,-1],Th=[0,32,40,48,56,64,80,96,112,128,160,192,224,256,320,-1];class kh extends po{constructor(e){super(),this.TAG_NAME="MediaSource",this.player=e,this._resetInIt(),this._useManagedMediaSource="ManagedMediaSource"in self&&!("MediaSource"in self),this.mediaSource=this._useManagedMediaSource?new self.ManagedMediaSource:new self.MediaSource,this.isDecodeFirstIIframe=!!ro(e._opt.checkFirstIFrame),this.mediaSourceObjectURL=null,this._useManagedMediaSource||(this.mediaSourceObjectURL=window.URL.createObjectURL(this.mediaSource)),this.isSupportVideoFrameCallback=ho(),this.canvasRenderInterval=null,e._opt.mseUseCanvasRender?(this.$videoElement=document.createElement("video"),this._useManagedMediaSource?(this.$videoElement.disableRemotePlayback=!0,this.$videoElement.srcObject=this.mediaSource):this.$videoElement.src=this.mediaSourceObjectURL,this.initVideoEvents()):(this._useManagedMediaSource?(this.player.video.$videoElement.disableRemotePlayback=!0,this.player.video.$videoElement.srcObject=this.mediaSource):this.player.video.$videoElement.src=this.mediaSourceObjectURL,this.$videoElement=this.player.video.$videoElement),this._bindMediaSourceEvents(),this.audioSourceBufferCheckTimeout=null,this.audioSourceNoDataCheckTimeout=null,this.hasPendingEos=!1,this.player.isPlayback()&&this.player.on(nt.playbackPause,(t=>{ro(t)?(so(e._opt.checkFirstIFrame)&&(this.player.debug.log(this.TAG_NAME,"playbackPause is false and _opt.checkFirstIFrame is true so set isDecodeFirstIIframe = false"),this.isDecodeFirstIIframe=!1),this.clearUpAllSourceBuffer(),this.$videoElement.play()):(this.$videoElement.pause(),this.cacheTrack={})})),this._useManagedMediaSource?this.player.debug.log(this.TAG_NAME,"init and using ManagedMediaSource"):this.player.debug.log(this.TAG_NAME,"init")}destroy(){this.stop(),this._clearAudioSourceBufferCheckTimeout(),this._clearAudioNoDataCheckTimeout(),this._stopCanvasRender(),this.eventListenList.length&&(this.eventListenList.forEach((e=>e())),this.eventListenList=[]),this.supportVideoFrameCallbackHandle&&this.$videoElement&&(this.$videoElement.cancelVideoFrameCallback(this.supportVideoFrameCallbackHandle),this.supportVideoFrameCallbackHandle=null),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._resetInIt(),this.mediaSource=null,this.off(),this.player.debug.log(this.TAG_NAME,"destroy")}needInitAudio(){return this.player._opt.hasAudio&&this.player._opt.mseDecodeAudio}_resetInIt(){this.isAvc=null,this.isAAC=null,this.videoMeta={},this.audioMeta={},this.sourceBuffer=null,this.audioSourceBuffer=null,this.hasInit=!1,this.hasAudioInit=!1,this.isInitInfo=!1,this.isAudioInitInfo=!1,this.audioMimeType="",this.videoMimeType="",this.cacheTrack={},this.cacheAudioTrack={},this.sequenceNumber=0,this.audioSequenceNumber=0,this.firstRenderTime=null,this.firstAudioTime=null,this.$videoElement=null,this.mediaSourceAppendBufferFull=!1,this.mediaSourceAppendBufferError=!1,this.mediaSourceAddSourceBufferError=!1,this.mediaSourceBufferError=!1,this.mediaSourceError=!1,this.prevTimestamp=null,this.decodeDiffTimestamp=null,this.prevDts=null,this.prevAudioDts=null,this.prevPayloadBufferSize=0,this.isWidthOrHeightChanged=!1,this.prevTs=null,this.prevAudioTs=null,this.eventListenList=[],this.pendingRemoveRanges=[],this.pendingSegments=[],this.pendingAudioRemoveRanges=[],this.pendingAudioSegments=[],this.supportVideoFrameCallbackHandle=null}get state(){return this.mediaSource&&this.mediaSource.readyState}get isStateOpen(){return this.state===li}get isStateClosed(){return this.state===di}get isStateEnded(){return this.state===ni}get duration(){return this.mediaSource&&this.mediaSource.duration||-1}set duration(e){this.mediaSource.duration=e}_bindMediaSourceEvents(){const{debug:e,events:{proxy:t}}=this.player,i=t(this.mediaSource,zi,(()=>{this.player.debug.log(this.TAG_NAME,"sourceOpen"),this._onMediaSourceSourceOpen(),this.player.emit(nt.mseSourceOpen)})),s=t(this.mediaSource,ji,(()=>{this.player.debug.log(this.TAG_NAME,"sourceClose"),this.player.emit(nt.mseSourceClose)})),r=t(this.mediaSource,Gi,(()=>{this.player.debug.log(this.TAG_NAME,"sourceended"),this.player.emit(nt.mseSourceended)}));this.eventListenList.push(i,s,r);const a=t(this.$videoElement,qi,(e=>{if(ro(this.isSupportVideoFrameCallback))if(this.player.checkIsInRender())this.player.handleRender();else{const t=parseInt(e.timeStamp,10);this.player.debug.log(this.TAG_NAME,`mseUseCanvasRender is ${this.player._opt.mseUseCanvasRender} and\n $videoElement ts is ${t}, but not in render and vbps is ${this.player._stats.vbps} and fps is ${this.player._stats.fps}`)}}));if(this.eventListenList.push(a),this._useManagedMediaSource){const e=t(this.mediaSource,Hi,(()=>{this.player.debug.log(this.TAG_NAME,"ManagedMediaSource startstreaming"),this.player.emit(nt.mseSourceStartStreaming)})),i=t(this.mediaSource,$i,(()=>{this.player.debug.log(this.TAG_NAME,"ManagedMediaSource endstreaming"),this.player.emit(nt.mseSourceEndStreaming)})),s=t(this.mediaSource,Vi,(()=>{this.player.debug.log(this.TAG_NAME,"ManagedMediaSource qualitychange")}));this.eventListenList.push(e,i,s)}}_onMediaSourceSourceOpen(){this.sourceBuffer||(this.player.debug.log("MediaSource","onMediaSourceSourceOpen() sourceBuffer is null and next init"),this._initSourceBuffer()),this.audioSourceBuffer||(this.player.debug.log("MediaSource","onMediaSourceSourceOpen() audioSourceBuffer is null and next init"),this._initAudioSourceBuffer()),this._hasPendingSegments()&&this._doAppendSegments()}initVideoEvents(){const{proxy:e}=this.player.events;this.player.on(nt.visibilityChange,(e=>{e&&setTimeout((()=>{if(this.player.isPlaying()&&this.$videoElement){const e=this.getVideoBufferLastTime();e-this.$videoElement.currentTime>this.getMseBufferMaxDelayTime()&&(this.player.debug.log(this.TAG_NAME,`visibilityChange is true and lastTime is ${e} and currentTime is ${this.$videoElement.currentTime} so set currentTime to lastTime`),this.$videoElement.currentTime=e)}}),300)}));const t=e(this.$videoElement,Wi,(()=>{this.player.debug.log(this.TAG_NAME,"video canplay"),this.$videoElement.play().then((()=>{this.player.emit(nt.removeLoadingBgImage),ho()?this.supportVideoFrameCallbackHandle||(this.supportVideoFrameCallbackHandle=this.$videoElement.requestVideoFrameCallback(this.videoFrameCallback.bind(this))):this.player.isUseHls265()&&(this._stopCanvasRender(),this.canvasRenderInterval=setInterval((()=>{this.player.video.render({$video:this.$videoElement,ts:parseInt(1e3*this.$videoElement.currentTime,10)||0})}),40)),this.player.debug.log(this.TAG_NAME,"video play")})).catch((e=>{this.player.debug.error(this.TAG_NAME,"video play error ",e),this.player.emitError(ct.mediaSourceUseCanvasRenderPlayFailed,e)}))})),i=e(this.$videoElement,Ji,(()=>{this.player.debug.log(this.TAG_NAME,"video waiting")})),s=e(this.$videoElement,qi,(e=>{parseInt(e.timeStamp,10),this.$videoElement.paused&&(this.player.debug.warn(this.TAG_NAME,"video is paused and next try to replay"),this.$videoElement.play().then((()=>{this.player.debug.log(this.TAG_NAME,"video is paused and replay success")})).catch((e=>{this.player.debug.warn(this.TAG_NAME,"video is paused and replay error ",e)})))})),r=e(this.$videoElement,Ki,(()=>{this.player.debug.log(this.TAG_NAME,"video playback Rate change",this.$videoElement&&this.$videoElement.playbackRate),this.$videoElement&&this.$videoElement.paused&&this.player.debug.warn(this.TAG_NAME,"ratechange and video is paused")}));this.eventListenList.push(t,i,s,r)}videoFrameCallback(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.player.isDestroyedOrClosed())return void this.player.debug.log(this.TAG_NAME,"videoFrameCallback() player is destroyed");const i=parseInt(1e3*Math.max(t.mediaTime,this.$videoElement.currentTime),10)||0;this.player.handleRender(),this.player.video.render({$video:this.$videoElement,ts:i}),this.player.isUseHls265()&&this.player.updateStats({fps:!0,ts:i}),this.supportVideoFrameCallbackHandle=this.$videoElement.requestVideoFrameCallback(this.videoFrameCallback.bind(this))}decodeVideo(e,t,i,s){const r=this.player;if(r)if(this.player.isDestroyedOrClosed())this.player.debug.warn(this.TAG_NAME,"decodeVideo() player is destroyed");else if(this.hasInit)if(!this.isDecodeFirstIIframe&&i&&(this.isDecodeFirstIIframe=!0),this.isDecodeFirstIIframe){if(i&&0===e[1]){const t=15&e[0];let i={};if(t===_t){i=mn(e.slice(5))}else t===vt&&(i=Cn(e));const s=this.player.video.videoInfo;s&&s.width&&s.height&&i&&i.codecWidth&&i.codecHeight&&(i.codecWidth!==s.width||i.codecHeight!==s.height)&&(this.player.debug.warn(this.TAG_NAME,`\n decodeVideo: video width or height is changed,\n old width is ${s.width}, old height is ${s.height},\n new width is ${i.codecWidth}, new height is ${i.codecHeight},\n and emit change event`),this.isWidthOrHeightChanged=!0,this.player.emitError(ct.mseWidthOrHeightChange))}if(this.isWidthOrHeightChanged)return void this.player.debug.warn(this.TAG_NAME,"decodeVideo: video width or height is changed, and return");if(io(e))return void this.player.debug.warn(this.TAG_NAME,"decodeVideo and payload is video sequence header so drop this frame");if(e.byteLength<12)return void this.player.debug.warn(this.TAG_NAME,`decodeVideo and payload is too small , payload length is ${e.byteLength}`);let r=t;if(this.player.isPlayer()){if(null===this.firstRenderTime&&(this.firstRenderTime=t),r=t-this.firstRenderTime,r<0&&(this.player.debug.warn(this.TAG_NAME,`decodeVideo\n local dts is < 0 , ts is ${t} and prevTs is ${this.prevTs},\n firstRenderTime is ${this.firstRenderTime} and mseCorrectTimeDuration is ${this.player._opt.mseCorrectTimeDuration}`),r=null===this.prevDts?0:this.prevDts+this.player._opt.mseCorrectTimeDuration,this._checkTsIsMaxDiff(t)))return this.player.debug.warn(this.TAG_NAME,`decodeVideo is max diff , ts is ${t} and prevTs is ${this.prevTs}, diff is ${this.prevTs-t} and emit replay`),void this.player.emitError(ct.mediaSourceTsIsMaxDiff,`decodeVideo is max diff, prevTs is ${this.prevTs} and ts is ${t}`);if(null!==this.prevDts&&r<=this.prevDts){if(this.player.debug.warn(this.TAG_NAME,`\n decodeVideo dts is less than(or equal) prev dts ,\n dts is ${r} and prev dts is ${this.prevDts} ,\n and now ts is ${t} and prev ts is ${this.prevTs} ,\n and diff is ${t-this.prevTs} and firstRenderTime is ${this.firstRenderTime} and isIframe is ${i},\n and mseCorrectTimeDuration is ${this.player._opt.mseCorrectTimeDuration},\n and prevPayloadBufferSize is ${this.prevPayloadBufferSize} and payload size is ${e.byteLength}`),r===this.prevDts&&this.prevPayloadBufferSize===e.byteLength)return void this.player.debug.warn(this.TAG_NAME,"decodeVideo dts is equal to prev dts and payload size is equal to prev payload size so drop this frame");if(r=this.prevDts+this.player._opt.mseCorrectTimeDuration,this._checkTsIsMaxDiff(t))return this.player.debug.warn(this.TAG_NAME,`decodeVideo is max diff , ts is ${t} and prevTs is ${this.prevTs}, diff is ${this.prevTs-t} and emit replay`),void this.emit(ct.mediaSourceTsIsMaxDiff,`decodeVideo is max diff, prevTs is ${this.prevTs} and ts is ${t}`)}}this.player.isPlayer()?this._decodeVideo(e,r,i,s,t):this.player.isPlayback()&&ro(this.player.playbackPause)&&(this.player.playback.isUseLocalCalculateTime&&this.player.playback.increaseLocalTimestamp(),this._decodeVideo(e,r,i,s,t)),this.prevDts=r,this.prevPayloadBufferSize=e.byteLength,this.prevTs=t}else this.player.debug.log(this.TAG_NAME,"decodeVideo first frame is not iFrame");else if(i&&e[1]===us){const s=15&e[0];if(r.video.updateVideoInfo({encTypeCode:s}),s===vt&&ro(Aa()))return void this.player.emitError(ct.mediaSourceH265NotSupport);r._times.decodeStart||(r._times.decodeStart=Qr()),this.hasInit=this._decodeConfigurationRecord(e,t,i,s)}else this.player.debug.warn(this.TAG_NAME,`decodeVideo has not init , isIframe is ${i} , payload is ${e[1]}`)}decodeAudio(e,t){if(this.player)if(this.player.isDestroyedOrClosed())this.player.debug.warn(this.TAG_NAME,"decodeAudio() player is destroyed");else if(ro(this.hasAudioInit))this.hasAudioInit=this._decodeAudioConfigurationRecord(e,t);else{let i=t;if(Br(e))return void this.player.debug.log(this.TAG_NAME,"decodeAudio and has already initialized and payload is aac codec packet so drop this frame");if(this._clearAudioNoDataCheckTimeout(),this.isDecodeFirstIIframe){if(this.player.isPlayer()){if(null===this.firstAudioTime&&(this.firstAudioTime=t,null!==this.firstRenderTime&&null!==this.prevTs)){const e=Math.abs(this.firstRenderTime-this.prevTs);e>300&&(this.firstAudioTime-=e,this.player.debug.warn(this.TAG_NAME,`video\n firstAudioTime is ${this.firstRenderTime} and current time is ${this.prevTs}\n play time is ${e} and firstAudioTime ${t} - ${e} = ${this.firstAudioTime}`))}if(i=t-this.firstAudioTime,i<0&&(this.player.debug.warn(this.TAG_NAME,`decodeAudio\n local dts is < 0 , ts is ${t} and prevTs is ${this.prevAudioTs},\n firstAudioTime is ${this.firstAudioTime}`),i=null===this.prevAudioDts?0:this.prevAudioDts+this.player._opt.mseCorrectAudioTimeDuration,this._checkAudioTsIsMaxDiff(t)))return this.player.debug.warn(this.TAG_NAME,`decodeAudio is max diff , ts is ${t} and prevTs is ${this.prevAudioDts}, diff is ${this.prevAudioDts-t} and emit replay`),void this.player.emitError(ct.mediaSourceTsIsMaxDiff,`decodeAudio is max diff, prevTs is ${this.prevAudioDts} and ts is ${t}`);null!==this.prevAudioTs&&i<=this.prevAudioDts&&(this.player.debug.warn(this.TAG_NAME,`\n decodeAudio dts is less than(or equal) prev dts ,\n dts is ${i} and prev dts is ${this.prevAudioDts} ,\n and now ts is ${t} and prev ts is ${this.prevAudioTs} ,\n and diff is ${t-this.prevAudioTs}`),i=this.prevAudioDts+this.player._opt.mseCorrectAudioTimeDuration)}(this.player.isPlayer()||this.player.isPlayback()&&ro(this.player.playbackPause))&&this._decodeAudio(e,i,t),this.prevAudioTs=t,this.prevAudioDts=i}else this.player.debug.log(this.TAG_NAME,"decodeAudio first frame is not iFrame")}}_checkTsIsMaxDiff(e){return this.prevTs>0&&e<this.prevTs&&this.prevTs-e>X}_checkAudioTsIsMaxDiff(e){return this.prevAudioTs>0&&e<this.prevAudioTs&&this.prevAudioTs-e>X}_decodeConfigurationRecord(e,t,i,s){let r=e.slice(5),a={};if(s===_t?a=mn(r):s===vt&&(a=Rn(r)),Ma(a)||0===a.codecWidth&&0===a.codecHeight)return this.player.debug.warn(this.TAG_NAME,"_decodeConfigurationRecord",a),this.player.emitError(ct.mediaSourceDecoderConfigurationError),!1;this.player.recorder&&this.player._opt.recordType===S&&this.player.recorder.initMetaData(e,s);const o={id:nr,type:"video",timescale:1e3,duration:0,avcc:r,codecWidth:a.codecWidth,codecHeight:a.codecHeight,videoType:a.videoType},n=bh.generateInitSegment(o);this.isAvc=s===_t;let l=a.codec;return this.videoMimeType=l?`video/mp4; codecs="${a.codec}"`:this.isAvc?ti:ii,this._initSourceBuffer(),this.appendBuffer(n.buffer),this.sequenceNumber=0,this.cacheTrack={},!0}_decodeAudioConfigurationRecord(e,t){const i=e[0]>>4,s=i===Et.MP3,r=i===Et.AAC;if(ro(r||s))return this.player.debug.warn(this.TAG_NAME,`_decodeAudioConfigurationRecord audio codec is not support , codecId is ${i} ant auto wasm decode`),this.player.emit(ct.mediaSourceAudioG711NotSupport),!1;const a={id:lr,type:"audio",timescale:1e3};let o={};if(Br(e)){if(o=function(e){let t=new Uint8Array(e),i=null,s=0,r=0,a=0,o=null;if(s=r=t[0]>>>3,a=(7&t[0])<<1|t[1]>>>7,a<0||a>=Fr.length)return void console.error("Flv: AAC invalid sampling frequency index!");let n=Fr[a],l=(120&t[1])>>>3;if(l<0||l>=8)return void console.log("Flv: AAC invalid channel configuration");5===s&&(o=(7&t[1])<<1|t[2]>>>7,t[2]);let d=self.navigator.userAgent.toLowerCase();return-1!==d.indexOf("firefox")?a>=6?(s=5,i=new Array(4),o=a-3):(s=2,i=new Array(2),o=a):-1!==d.indexOf("android")?(s=2,i=new Array(2),o=a):(s=5,o=a,i=new Array(4),a>=6?o=a-3:1===l&&(s=2,i=new Array(2),o=a)),i[0]=s<<3,i[0]|=(15&a)>>>1,i[1]=(15&a)<<7,i[1]|=(15&l)<<3,5===s&&(i[1]|=(15&o)>>>1,i[2]=(1&o)<<7,i[2]|=8,i[3]=0),{audioType:"aac",config:i,sampleRate:n,channelCount:l,objectType:s,codec:"mp4a.40."+s,originalCodec:"mp4a.40."+r}}(e.slice(2)),!o)return!1;a.audioSampleRate=o.sampleRate,a.channelCount=o.channelCount,a.config=o.config,a.refSampleDuration=1024/a.audioSampleRate*a.timescale}else{if(!s)return!1;if(o=function(e){if(e.length<4)return void console.error("Invalid MP3 packet, header missing!");let t=new Uint8Array(e.buffer),i=null;if(255!==t[0])return void console.error("Invalid MP3 packet, first byte != 0xFF ");let s=t[1]>>>3&3,r=(6&t[1])>>1,a=(240&t[2])>>>4,o=(12&t[2])>>>2,n=3&~(t[3]>>>6)?2:1,l=0,d=0;switch(s){case 0:l=Sh[o];break;case 2:l=vh[o];break;case 3:l=_h[o]}switch(r){case 1:a<Th.length&&(d=Th[a]);break;case 2:a<Eh.length&&(d=Eh[a]);break;case 3:a<wh.length&&(d=wh[a])}return i={bitRate:d,samplingRate:l,channelCount:n,codec:"mp3",originalCodec:"mp3",audioType:"mp3"},i}(e),!o)return!1;a.audioSampleRate=o.samplingRate,a.channelCount=o.channelCount,a.refSampleDuration=1152/a.audioSampleRate*a.timescale}a.codec=o.codec,a.duration=0;let n="mp4",l=o.codec,d=null;s&&ro(na())?(n="mpeg",l="",d=new Uint8Array):d=bh.generateInitSegment(a);let h=`${a.type}/${n}`;return l&&l.length>0&&(h+=`;codecs=${l}`),ro(this.isAudioInitInfo)&&(this.player.audio.updateAudioInfo({encTypeCode:i,channels:a.channelCount,sampleRate:a.audioSampleRate}),this.isAudioInitInfo=!0),this.audioMimeType=h,this.isAAC=r,this._initAudioSourceBuffer(),this.appendAudioBuffer(d.buffer),!0}_initSourceBuffer(){const{debug:e,events:{proxy:t}}=this.player;if(null===this.sourceBuffer&&null!==this.mediaSource&&this.isStateOpen&&this.videoMimeType){try{this.sourceBuffer=this.mediaSource.addSourceBuffer(this.videoMimeType),e.log(this.TAG_NAME,"_initSourceBuffer() this.mediaSource.addSourceBuffer()",this.videoMimeType)}catch(t){return e.error(this.TAG_NAME,"appendBuffer() this.mediaSource.addSourceBuffer()",t.code,t),this.player.emitError(ct.mseAddSourceBufferError,t),void(this.mediaSourceAddSourceBufferError=!0)}if(this.sourceBuffer){const i=t(this.sourceBuffer,"error",(t=>{this.mediaSourceBufferError=!0,e.error(this.TAG_NAME,"mseSourceBufferError this.sourceBuffer",t),this.player.emitError(ct.mseSourceBufferError,t)})),s=t(this.sourceBuffer,"updateend",(()=>{this._hasPendingRemoveRanges()?this._doRemoveRanges():this._hasPendingSegments()?this._doAppendSegments():this.hasPendingEos&&(this.player.debug.log(this.TAG_NAME,"videoSourceBuffer updateend and hasPendingEos is true, next endOfStream()"),this.endOfStream())}));this.eventListenList.push(i,s)}}else e.log(this.TAG_NAME,`_initSourceBuffer and this.isStateOpen is ${this.isStateOpen} and this.isAvc === null is ${null===this.isAvc}`)}_initAudioSourceBuffer(){const{debug:e,events:{proxy:t}}=this.player;if(null===this.audioSourceBuffer&&null!==this.mediaSource&&this.isStateOpen&&this.audioMimeType){try{this.audioSourceBuffer=this.mediaSource.addSourceBuffer(this.audioMimeType),this._clearAudioSourceBufferCheckTimeout(),e.log(this.TAG_NAME,"_initAudioSourceBuffer() this.mediaSource.addSourceBuffer()",this.audioMimeType)}catch(t){return e.error(this.TAG_NAME,"appendAudioBuffer() this.mediaSource.addSourceBuffer()",t.code,t),this.player.emitError(ct.mseAddSourceBufferError,t),void(this.mediaSourceAddSourceBufferError=!0)}if(this.audioSourceBuffer){const i=t(this.audioSourceBuffer,"error",(t=>{this.mediaSourceBufferError=!0,e.error(this.TAG_NAME,"mseSourceBufferError this.audioSourceBuffer",t),this.player.emitError(ct.mseSourceBufferError,t)})),s=t(this.audioSourceBuffer,"updateend",(()=>{this._hasPendingRemoveRanges()?this._doRemoveRanges():this._hasPendingSegments()?this._doAppendSegments():this.hasPendingEos&&(this.player.debug.log(this.TAG_NAME,"audioSourceBuffer updateend and hasPendingEos is true, next endOfStream()"),this.endOfStream())}));this.eventListenList.push(i,s),null===this.audioSourceNoDataCheckTimeout&&(this.audioSourceNoDataCheckTimeout=setTimeout((()=>{this._clearAudioNoDataCheckTimeout(),this.player.emit(ct.mediaSourceAudioNoDataTimeout)}),1e3))}}else e.log(this.TAG_NAME,`_initAudioSourceBuffer and this.isStateOpen is ${this.isStateOpen} and this.audioMimeType is ${this.audioMimeType}`)}_decodeVideo(e,t,i,s,r){const a=this.player;let o=e.slice(5),n=o.byteLength;if(0===n)return void a.debug.warn(this.TAG_NAME,"_decodeVideo payload bytes is 0 and return");let l=(new Date).getTime(),d=!1;this.prevTimestamp||(this.prevTimestamp=l,d=!0);const h=l-this.prevTimestamp;this.decodeDiffTimestamp=h,h>500&&!d&&this.player.isPlayer()&&a.debug.warn(this.TAG_NAME,`_decodeVideo now time is ${l} and prev time is ${this.prevTimestamp}, diff time is ${h} ms`);const c=this.$videoElement;if(this.cacheTrack.id&&t>=this.cacheTrack.dts){let e=8+this.cacheTrack.size,i=new Uint8Array(e);i[0]=e>>>24&255,i[1]=e>>>16&255,i[2]=e>>>8&255,i[3]=255&e,i.set(bh.types.mdat,4),i.set(this.cacheTrack.data,8),this.cacheTrack.duration=t-this.cacheTrack.dts;let s=bh.moof(this.cacheTrack,this.cacheTrack.dts);this.cacheTrack={};let o=new Uint8Array(s.byteLength+i.byteLength);o.set(s,0),o.set(i,s.byteLength),this.appendBuffer(o.buffer),a.emit(nt.timeUpdate,r),a.isPlayer()?a.isUseHls265()?a.updateStats({dfps:!0,mseTs:t}):a.updateStats({fps:!0,dfps:!0,ts:r,mseTs:t}):a.isPlayback()&&a.playback.updateStats({ts:r}),a._times.videoStart||(a._times.videoStart=Qr(),a.handlePlayToRenderTimes())}else a.debug.log(this.TAG_NAME,`cacheTrack = {} now dts is ${t}, and ts is ${r} cacheTrack dts is ${this.cacheTrack&&this.cacheTrack.dts}`),this.cacheTrack={};this.cacheTrack||(this.cacheTrack={}),this.cacheTrack.id=nr,this.cacheTrack.sequenceNumber=++this.sequenceNumber,this.cacheTrack.size=n,this.cacheTrack.dts=t,this.cacheTrack.cts=s,this.cacheTrack.isKeyframe=i,this.cacheTrack.data=o,this.cacheTrack.flags={isLeading:0,dependsOn:i?2:1,isDependedOn:i?1:0,hasRedundancy:0,isNonSync:i?0:1},!this.isInitInfo&&c.videoWidth>0&&c.videoHeight>0&&(a.debug.log(this.TAG_NAME,`updateVideoInfo: ${c.videoWidth},${c.videoHeight}`),a.video.updateVideoInfo({width:c.videoWidth,height:c.videoHeight}),a.video.initCanvasViewSize(),this.isInitInfo=!0),a._opt.mseUseCanvasRender&&ro(this.isSupportVideoFrameCallback)&&ro(a.isUseHls265())&&a.video.render({$video:c,ts:t}),this.prevTimestamp=(new Date).getTime()}_stopCanvasRender(){this.canvasRenderInterval&&(clearInterval(this.canvasRenderInterval),this.canvasRenderInterval=null)}_decodeAudio(e,t,i){const s=this.player;let r=this.isAAC?e.slice(2):e.slice(1),a=r.byteLength;if(this.cacheAudioTrack.id&&t>=this.cacheAudioTrack.dts){let e=8+this.cacheAudioTrack.size,i=new Uint8Array(e);i[0]=e>>>24&255,i[1]=e>>>16&255,i[2]=e>>>8&255,i[3]=255&e,i.set(bh.types.mdat,4),i.set(this.cacheAudioTrack.data,8),this.cacheAudioTrack.duration=t-this.cacheAudioTrack.dts;let s=bh.moof(this.cacheAudioTrack,this.cacheAudioTrack.dts);this.cacheAudioTrack={};let r=new Uint8Array(s.byteLength+i.byteLength);r.set(s,0),r.set(i,s.byteLength),this.appendAudioBuffer(r.buffer)}else s.debug.log(this.TAG_NAME,`cacheAudioTrack = {} now dts is ${t} cacheAudioTrack dts is ${this.cacheAudioTrack&&this.cacheAudioTrack.dts}`),this.cacheAudioTrack={};this.cacheAudioTrack||(this.cacheAudioTrack={}),this.cacheAudioTrack.id=lr,this.cacheAudioTrack.sequenceNumber=++this.audioSequenceNumber,this.cacheAudioTrack.size=a,this.cacheAudioTrack.dts=t,this.cacheAudioTrack.cts=0,this.cacheAudioTrack.data=r,this.cacheAudioTrack.flags={isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}}appendBuffer(e){if(this.player.isDestroyedOrClosed())return void this.player.debug.warn(this.TAG_NAME,"appendBuffer() player is destroyed");const{debug:t,events:{proxy:i}}=this.player;this.mediaSourceAddSourceBufferError?t.warn(this.TAG_NAME,"appendBuffer() this.mediaSourceAddSourceBufferError is true"):this.mediaSourceAppendBufferFull?t.warn(this.TAG_NAME,"appendBuffer() this.mediaSourceAppendBufferFull is true"):this.mediaSourceAppendBufferError?t.warn(this.TAG_NAME,"appendBuffer() this.mediaSourceAppendBufferError is true"):this.mediaSourceBufferError?t.warn(this.TAG_NAME,"appendBuffer() this.mediaSourceBufferError is true"):(this.pendingSegments.push(e),this.sourceBuffer&&(this.player.isPlayer()&&this._handleUpdatePlaybackRate(),this.player.isPlayback()&&(this._handleUpdateBufferDelayTime(),this._checkVideoPlayCurrentTime()),this.player._opt.mseAutoCleanupSourceBuffer&&this._needCleanupSourceBuffer()&&this._doCleanUpSourceBuffer(),ro(this.getSourceBufferUpdating())&&this.isStateOpen&&ro(this._hasPendingRemoveRanges()))?this._doAppendSegments():this.isStateClosed?(this.mediaSourceBufferError=!0,this.player.emitError(ct.mseSourceBufferError,"mediaSource is not attached to video or mediaSource is closed")):this.isStateEnded?(this.mediaSourceBufferError=!0,this.player.emitError(ct.mseSourceBufferError,"mediaSource is end")):this._hasPendingRemoveRanges()&&t.log(this.TAG_NAME,`video has pending remove ranges and video length is ${this.pendingRemoveRanges.length}, audio length is ${this.pendingAudioRemoveRanges.length}`))}appendAudioBuffer(e){if(this.player.isDestroyedOrClosed())return void this.player.debug.warn(this.TAG_NAME,"appendAudioBuffer() player is destroyed");const{debug:t,events:{proxy:i}}=this.player;this.mediaSourceAddSourceBufferError?t.warn(this.TAG_NAME,"appendAudioBuffer() this.mediaSourceAddSourceBufferError is true"):this.mediaSourceAppendBufferFull?t.warn(this.TAG_NAME,"appendAudioBuffer() this.mediaSourceAppendBufferFull is true"):this.mediaSourceAppendBufferError?t.warn(this.TAG_NAME,"appendAudioBuffer() this.mediaSourceAppendBufferError is true"):this.mediaSourceBufferError?t.warn(this.TAG_NAME,"appendAudioBuffer() this.mediaSourceBufferError is true"):(this.pendingAudioSegments.push(e),this.audioSourceBuffer&&(this.player.isPlayer()&&this._handleUpdatePlaybackRate(),this.player.isPlayback()&&(this._handleUpdateBufferDelayTime(),this._checkVideoPlayCurrentTime()),this.player._opt.mseAutoCleanupSourceBuffer&&this._needCleanupSourceBuffer()&&this._doCleanUpSourceBuffer(),ro(this.getAudioSourceBufferUpdating())&&this.isStateOpen&&ro(this._hasPendingRemoveRanges()))?this._doAppendSegments():this.isStateClosed?(this.mediaSourceBufferError=!0,this.player.emitError(ct.mseSourceBufferError,"mediaSource is not attached to video or mediaSource is closed")):this.isStateEnded?(this.mediaSourceBufferError=!0,this.player.emitError(ct.mseSourceBufferError,"mediaSource is end")):this._hasPendingRemoveRanges()&&t.log(this.TAG_NAME,`audio has pending remove ranges and video length is ${this.pendingRemoveRanges.length}, audio length is ${this.pendingAudioRemoveRanges.length}`))}getSourceBufferUpdating(){return this.sourceBuffer&&this.sourceBuffer.updating}getAudioSourceBufferUpdating(){return this.audioSourceBuffer&&this.audioSourceBuffer.updating}stop(){this.abortSourceBuffer(),this.removeSourceBuffer(),this.endOfStream()}checkSourceBufferDelay(){const e=this.$videoElement;let t=0,i=0;return e.buffered.length>0&&(i=e.buffered.end(e.buffered.length-1),t=i-e.currentTime),t<0&&(this.player.debug.warn(this.TAG_NAME,`checkMSESourceBufferDelay ${t} < 0, and buffered is ${i} ,currentTime is ${e.currentTime} , try to seek ${e.currentTime} to ${i}`),e.currentTime=i,t=0),t}checkSourceBufferStore(){const e=this.$videoElement;let t=0;return e.buffered.length>0&&(t=e.currentTime-e.buffered.start(0)),t}getDecodeDiffTimes(){return this.decodeDiffTimestamp}removeBuffer(e,t){const i=za();if(this.player.debug.log(this.TAG_NAME,`removeBuffer() start is ${e} and end is ${t} and _isMacOsFirefox is ${i}`),this.isStateOpen&&ro(i)){if(ro(this.getSourceBufferUpdating()))try{this.sourceBuffer.remove(e,t)}catch(e){this.player.debug.warn(this.TAG_NAME,"removeBuffer() sourceBuffer error",e)}if(ro(this.getAudioSourceBufferUpdating()))try{this.audioSourceBuffer.remove(e,t)}catch(e){this.player.debug.warn(this.TAG_NAME,"removeBuffer() audioSourceBuffer error",e)}}}clearUpAllSourceBuffer(){if(this.sourceBuffer){const e=this.sourceBuffer.buffered;for(let t=0;t<e.length;t++){let i=e.start(t),s=e.end(t);this.pendingRemoveRanges.push({start:i,end:s})}ro(this.getSourceBufferUpdating())&&this._doRemoveRanges()}if(this.audioSourceBuffer){const e=this.audioSourceBuffer.buffered;for(let t=0;t<e.length;t++){let i=e.start(t),s=e.end(t);this.pendingAudioRemoveRanges.push({start:i,end:s})}ro(this.getAudioSourceBufferUpdating())&&this._doRemoveRanges()}}endOfStream(){if(this.isStateOpen&&this.$videoElement&&this.$videoElement.readyState>=1)if(this.getSourceBufferUpdating()||this.getAudioSourceBufferUpdating())this.hasPendingEos=!0;else{this.hasPendingEos=!1;try{this.player.debug.log(this.TAG_NAME,"endOfStream()"),this.mediaSource.endOfStream()}catch(e){this.player.debug.warn(this.TAG_NAME,"endOfStream() error",e)}}}abortSourceBuffer(){if(this.isStateOpen){if(this.sourceBuffer){try{this.player.debug.log(this.TAG_NAME,"abortSourceBuffer() abort sourceBuffer"),this.sourceBuffer.abort()}catch(e){}ro(this.getSourceBufferUpdating())&&this._doRemoveRanges()}if(this.audioSourceBuffer){try{this.player.debug.log(this.TAG_NAME,"abortSourceBuffer() abort audioSourceBuffer"),this.audioSourceBuffer.abort()}catch(e){}ro(this.getAudioSourceBufferUpdating())&&this._doRemoveRanges()}}this.sourceBuffer=null,this.audioSourceBuffer=null}removeSourceBuffer(){if(!this.isStateClosed&&this.mediaSource){if(this.sourceBuffer)try{this.player.debug.log(this.TAG_NAME,"removeSourceBuffer() sourceBuffer"),this.mediaSource.removeSourceBuffer(this.sourceBuffer)}catch(e){this.player.debug.error(this.TAG_NAME,"removeSourceBuffer() sourceBuffer error",e)}if(this.audioSourceBuffer)try{this.player.debug.log(this.TAG_NAME,"removeSourceBuffer() audioSourceBuffer"),this.mediaSource.removeSourceBuffer(this.audioSourceBuffer)}catch(e){this.player.debug.error(this.TAG_NAME,"removeSourceBuffer() audioSourceBuffer error",e)}}}_hasPendingSegments(){return this.pendingSegments.length>0||this.pendingAudioSegments.length>0}getPendingSegmentsLength(){return this.pendingSegments.length}_handleUpdatePlaybackRate(){if(!this.$videoElement)return;const e=this.$videoElement;this.player._opt.videoBuffer,this.player._opt.videoBufferDelay;const t=e.buffered;t.length&&t.start(0);const i=t.length?t.end(t.length-1):0;let s=e.currentTime;const r=i-s,a=this.getMseBufferMaxDelayTime();if(this.player.updateStats({mseVideoBufferDelayTime:r}),r>a)this.player.debug.log(this.TAG_NAME,`handleUpdatePlaybackRate and buffered is ${i} and current is ${s} , delay buffer is more than ${a} is ${r} and new time is ${i}`),e.currentTime=i,s=e.currentTime;else if(r<0){if(this.player.debug.warn(this.TAG_NAME,`handleUpdatePlaybackRate and delay buffer is ${i} - current is ${s} = ${r} < 0 and check video is paused : ${e.paused} `),0===i)return void this.player.emit(ct.mediaSourceBufferedIsZeroError,"video.buffered is empty");e.paused&&e.play()}const o=this._getPlaybackRate(i-s);e.playbackRate!==o&&(this.player.debug.log(this.TAG_NAME,`handleUpdatePlaybackRate and buffered is ${i} and current time is ${s} and delay is ${i-s} set playbackRate is ${o} `),e.playbackRate=o)}_handleUpdateBufferDelayTime(){const e=this.getVideoBufferDelayTime();this.player.updateStats({mseVideoBufferDelayTime:e})}_checkVideoPlayCurrentTime(){const e=this.checkSourceBufferStore();if(e<0){const t=this.getVideoBufferStartTime();this.player.debug.warn(this.TAG_NAME,`checkVideoPlayCurrentTime store is ${e} < 0 and set currentTime ${this.$videoElement.currentTime} to ${t}`),this.$videoElement.currentTime=t}}_doAppendSegments(){if(this.isStateClosed||this.isStateEnded)this.player.debug.log(this.TAG_NAME,"_doAppendSegments() mediaSource is closed or ended and return");else if(null!==this.sourceBuffer){if(this.needInitAudio()&&null===this.audioSourceBuffer)return this.player.debug.log(this.TAG_NAME,"_doAppendSegments() audioSourceBuffer is null and need init audio source buffer"),void(null===this.audioSourceBufferCheckTimeout&&(this.audioSourceBufferCheckTimeout=setTimeout((()=>{this._clearAudioSourceBufferCheckTimeout(),this.player.emit(ct.mediaSourceAudioInitTimeout)}),1e3)));if(ro(this.getSourceBufferUpdating())&&this.pendingSegments.length>0){const e=this.pendingSegments.shift();try{this.sourceBuffer.appendBuffer(e)}catch(e){this.player.debug.error(this.TAG_NAME,"this.sourceBuffer.appendBuffer()",e.code,e),22===e.code?(this.stop(),this.mediaSourceAppendBufferFull=!0,this.player.emitError(ct.mediaSourceFull)):11===e.code?(this.stop(),this.mediaSourceAppendBufferError=!0,this.player.emitError(ct.mediaSourceAppendBufferError)):(this.stop(),this.mediaSourceBufferError=!0,this.player.emitError(nt.mseSourceBufferError,e))}}if(ro(this.getAudioSourceBufferUpdating())&&this.pendingAudioSegments.length>0){const e=this.pendingAudioSegments.shift();try{this.audioSourceBuffer.appendBuffer(e)}catch(e){this.player.debug.error(this.TAG_NAME,"this.audioSourceBuffer.appendBuffer()",e.code,e),22===e.code?(this.stop(),this.mediaSourceAppendBufferFull=!0,this.player.emitError(ct.mediaSourceFull)):11===e.code?(this.stop(),this.mediaSourceAppendBufferError=!0,this.player.emitError(ct.mediaSourceAppendBufferError)):(this.stop(),this.mediaSourceBufferError=!0,this.player.emitError(nt.mseSourceBufferError,e))}}}else this.player.debug.log(this.TAG_NAME,"_doAppendSegments() sourceBuffer is null and wait init and return")}_doCleanUpSourceBuffer(){if(!this.$videoElement)return;const e=this.$videoElement.currentTime;if(this.sourceBuffer){const t=this.sourceBuffer.buffered;let i=!1;for(let s=0;s<t.length;s++){let r=t.start(s),a=t.end(s);if(r<=e&&e<a+3){if(e-r>=this.player._opt.mseAutoCleanupMaxBackwardDuration){i=!0;let t=e-this.player._opt.mseAutoCleanupMinBackwardDuration;this.pendingRemoveRanges.push({start:r,end:t})}}else a<e&&(i=!0,this.pendingRemoveRanges.push({start:r,end:a}))}i&&ro(this.getSourceBufferUpdating())&&this._doRemoveRanges()}if(this.audioSourceBuffer){const t=this.audioSourceBuffer.buffered;let i=!1;for(let s=0;s<t.length;s++){let r=t.start(s),a=t.end(s);if(r<=e&&e<a+3){if(e-r>=this.player._opt.mseAutoCleanupMaxBackwardDuration){i=!0;let t=e-this.player._opt.mseAutoCleanupMinBackwardDuration;this.pendingAudioRemoveRanges.push({start:r,end:t})}}else a<e&&(i=!0,this.pendingAudioRemoveRanges.push({start:r,end:a}))}i&&ro(this.getAudioSourceBufferUpdating())&&this._doRemoveRanges()}}_hasPendingRemoveRanges(){return this.pendingRemoveRanges.length>0||this.pendingAudioRemoveRanges.length>0}_doRemoveRanges(){if(this.sourceBuffer&&ro(this.getSourceBufferUpdating())){let e=this.pendingRemoveRanges;for(;e.length&&ro(this.getSourceBufferUpdating());){let t=e.shift();try{this.sourceBuffer.remove(t.start,t.end)}catch(e){this.player.debug.warn(this.TAG_NAME,"_doRemoveRanges() sourceBuffer error",e)}}}if(this.audioSourceBuffer&&ro(this.getAudioSourceBufferUpdating())){let e=this.pendingAudioRemoveRanges;for(;e.length&&ro(this.getAudioSourceBufferUpdating());){let t=e.shift();try{this.audioSourceBuffer.remove(t.start,t.end)}catch(e){this.player.debug.warn(this.TAG_NAME,"_doRemoveRanges() audioSourceBuffer error",e)}}}}getDecodePlaybackRate(){let e=0;const t=this.$videoElement;return t&&(e=t.playbackRate),e}_getPlaybackRate(e){const t=this.$videoElement;let i=this.player._opt.videoBufferDelay+this.player._opt.videoBuffer;const s=Math.max(i,1e3),r=s/2;return e*=1e3,1===t.playbackRate?e>s?1.2:1:e<=r?1:t.playbackRate}_needCleanupSourceBuffer(){if(ro(this.player._opt.mseAutoCleanupSourceBuffer)||!this.$videoElement)return!1;const e=this.$videoElement,t=e.buffered,i=e.currentTime;return t.length>=1&&i-t.start(0)>=this.player._opt.mseAutoCleanupMaxBackwardDuration}getVideoCurrentTime(){let e=0;return this.$videoElement&&(e=this.$videoElement.currentTime),e}getVideoBufferLastTime(){const e=this.$videoElement;let t=0;if(e){const i=e.buffered;i.length&&i.start(0);t=i.length?i.end(i.length-1):0}return t}getVideoBufferStartTime(){const e=this.$videoElement;let t=0;if(e){const i=e.buffered;t=i.length?i.start(0):0}return t}getVideoBufferDelayTime(){const e=this.$videoElement;const t=this.getVideoBufferLastTime()-e.currentTime;return t>0?t:0}_clearAudioSourceBufferCheckTimeout(){this.audioSourceBufferCheckTimeout&&(clearTimeout(this.audioSourceBufferCheckTimeout),this.audioSourceBufferCheckTimeout=null)}_clearAudioNoDataCheckTimeout(){this.audioSourceNoDataCheckTimeout&&(clearTimeout(this.audioSourceNoDataCheckTimeout),this.audioSourceNoDataCheckTimeout=null)}getMimeType(){return{video:this.videoMimeType,audio:this.audioMimeType}}getMseBufferMaxDelayTime(){let e=(this.player._opt.videoBuffer+this.player._opt.videoBufferDelay)/1e3;return Math.max(5,e+3)}}const Ch=()=>"wakeLock"in navigator&&-1===window.navigator.userAgent.indexOf("Samsung")&&ro(da());class Rh{constructor(e){this.player=e,this.enabled=!1,Ch()?(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.handleNoSleepVideoTimeUpdate=()=>{this.noSleepVideo&&this.noSleepVideo.currentTime>4&&(this.noSleepVideo.currentTime=1)},this.noSleepVideo.addEventListener("timeupdate",this.handleNoSleepVideoTimeUpdate))}destroy(){if(this._wakeLock&&(this._wakeLock.release(),this._wakeLock=null),this.noSleepVideo){this.handleNoSleepVideoTimeUpdate&&this.noSleepVideo.removeEventListener("timeupdate",this.handleNoSleepVideoTimeUpdate);try{this.noSleepVideo.parentNode&&this.noSleepVideo.parentNode.removeChild(this.noSleepVideo)}catch(e){this.player.debug.warn("NoSleep","Failed to remove noSleepVideo element.")}this.noSleepVideo=null}this.handleVisibilityChange&&(document.removeEventListener("visibilitychange",this.handleVisibilityChange),document.removeEventListener("fullscreenchange",this.handleVisibilityChange))}_addSourceToVideo(e,t,i){var s=document.createElement("source");s.src=i,s.type=`video/${t}`,e.appendChild(s)}get isEnabled(){return this.enabled}enable(){const e=this.player.debug;if(Ch())return navigator.wakeLock.request("screen").then((t=>{this._wakeLock=t,this.enabled=!0,e.log("wakeLock","Wake Lock active."),this._wakeLock.addEventListener("release",(()=>{e.log("wakeLock","Wake Lock released.")}))})).catch((t=>{throw this.enabled=!1,e.warn("wakeLock",`${t.name}, ${t.message}`),t}));return this.noSleepVideo.play().then((t=>(e.log("wakeLock","noSleepVideo Wake Lock active."),this.enabled=!0,t))).catch((t=>{throw e.warn("wakeLock",`noSleepVideo ${t.name}, ${t.message}`),this.enabled=!1,t}))}disable(){Ch()?(this._wakeLock&&this._wakeLock.release(),this._wakeLock=null):this.noSleepVideo&&this.noSleepVideo.pause(),this.enabled=!1,this.player.debug.log("wakeLock","Disabling wake lock.")}}function xh(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Dh={exports:{}};!function(e,t){var i,s,r,a,o;i=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,s=/^(?=([^\/?#]*))\1([^]*)$/,r=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,o={buildAbsoluteURL:function(e,t,i){if(i=i||{},e=e.trim(),!(t=t.trim())){if(!i.alwaysNormalize)return e;var r=o.parseURL(e);if(!r)throw new Error("Error trying to parse base URL.");return r.path=o.normalizePath(r.path),o.buildURLFromParts(r)}var a=o.parseURL(t);if(!a)throw new Error("Error trying to parse relative URL.");if(a.scheme)return i.alwaysNormalize?(a.path=o.normalizePath(a.path),o.buildURLFromParts(a)):t;var n=o.parseURL(e);if(!n)throw new Error("Error trying to parse base URL.");if(!n.netLoc&&n.path&&"/"!==n.path[0]){var l=s.exec(n.path);n.netLoc=l[1],n.path=l[2]}n.netLoc&&!n.path&&(n.path="/");var d={scheme:n.scheme,netLoc:a.netLoc,path:null,params:a.params,query:a.query,fragment:a.fragment};if(!a.netLoc&&(d.netLoc=n.netLoc,"/"!==a.path[0]))if(a.path){var h=n.path,c=h.substring(0,h.lastIndexOf("/")+1)+a.path;d.path=o.normalizePath(c)}else d.path=n.path,a.params||(d.params=n.params,a.query||(d.query=n.query));return null===d.path&&(d.path=i.alwaysNormalize?o.normalizePath(a.path):a.path),o.buildURLFromParts(d)},parseURL:function(e){var t=i.exec(e);return t?{scheme:t[1]||"",netLoc:t[2]||"",path:t[3]||"",params:t[4]||"",query:t[5]||"",fragment:t[6]||""}:null},normalizePath:function(e){for(e=e.split("").reverse().join("").replace(r,"");e.length!==(e=e.replace(a,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}},e.exports=o}(Dh);var Lh=Dh.exports;function Ph(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,s)}return i}function Bh(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?Ph(Object(i),!0).forEach((function(t){Mh(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):Ph(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function Ih(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var s=i.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}function Mh(e,t,i){return(t=Ih(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function Uh(){return Uh=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(e[s]=i[s])}return e},Uh.apply(this,arguments)}const Fh=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},Oh=Number.isSafeInteger||function(e){return"number"==typeof e&&Math.abs(e)<=Nh},Nh=Number.MAX_SAFE_INTEGER||9007199254740991;let jh=function(e){return e.MEDIA_ATTACHING="hlsMediaAttaching",e.MEDIA_ATTACHED="hlsMediaAttached",e.MEDIA_DETACHING="hlsMediaDetaching",e.MEDIA_DETACHED="hlsMediaDetached",e.BUFFER_RESET="hlsBufferReset",e.BUFFER_CODECS="hlsBufferCodecs",e.BUFFER_CREATED="hlsBufferCreated",e.BUFFER_APPENDING="hlsBufferAppending",e.BUFFER_APPENDED="hlsBufferAppended",e.BUFFER_EOS="hlsBufferEos",e.BUFFER_FLUSHING="hlsBufferFlushing",e.BUFFER_FLUSHED="hlsBufferFlushed",e.MANIFEST_LOADING="hlsManifestLoading",e.MANIFEST_LOADED="hlsManifestLoaded",e.MANIFEST_PARSED="hlsManifestParsed",e.LEVEL_SWITCHING="hlsLevelSwitching",e.LEVEL_SWITCHED="hlsLevelSwitched",e.LEVEL_LOADING="hlsLevelLoading",e.LEVEL_LOADED="hlsLevelLoaded",e.LEVEL_UPDATED="hlsLevelUpdated",e.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",e.LEVELS_UPDATED="hlsLevelsUpdated",e.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",e.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",e.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",e.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",e.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",e.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",e.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",e.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",e.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",e.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",e.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",e.CUES_PARSED="hlsCuesParsed",e.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",e.INIT_PTS_FOUND="hlsInitPtsFound",e.FRAG_LOADING="hlsFragLoading",e.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",e.FRAG_LOADED="hlsFragLoaded",e.FRAG_DECRYPTED="hlsFragDecrypted",e.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",e.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",e.FRAG_PARSING_METADATA="hlsFragParsingMetadata",e.FRAG_PARSED="hlsFragParsed",e.FRAG_BUFFERED="hlsFragBuffered",e.FRAG_CHANGED="hlsFragChanged",e.FPS_DROP="hlsFpsDrop",e.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",e.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",e.ERROR="hlsError",e.DESTROYING="hlsDestroying",e.KEY_LOADING="hlsKeyLoading",e.KEY_LOADED="hlsKeyLoaded",e.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",e.BACK_BUFFER_REACHED="hlsBackBufferReached",e.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",e}({}),zh=function(e){return e.NETWORK_ERROR="networkError",e.MEDIA_ERROR="mediaError",e.KEY_SYSTEM_ERROR="keySystemError",e.MUX_ERROR="muxError",e.OTHER_ERROR="otherError",e}({}),Gh=function(e){return e.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",e.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",e.KEY_SYSTEM_NO_SESSION="keySystemNoSession",e.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",e.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",e.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",e.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",e.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",e.MANIFEST_LOAD_ERROR="manifestLoadError",e.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",e.MANIFEST_PARSING_ERROR="manifestParsingError",e.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",e.LEVEL_EMPTY_ERROR="levelEmptyError",e.LEVEL_LOAD_ERROR="levelLoadError",e.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",e.LEVEL_PARSING_ERROR="levelParsingError",e.LEVEL_SWITCH_ERROR="levelSwitchError",e.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",e.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",e.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",e.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",e.FRAG_LOAD_ERROR="fragLoadError",e.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",e.FRAG_DECRYPT_ERROR="fragDecryptError",e.FRAG_PARSING_ERROR="fragParsingError",e.FRAG_GAP="fragGap",e.REMUX_ALLOC_ERROR="remuxAllocError",e.KEY_LOAD_ERROR="keyLoadError",e.KEY_LOAD_TIMEOUT="keyLoadTimeOut",e.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",e.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",e.BUFFER_APPEND_ERROR="bufferAppendError",e.BUFFER_APPENDING_ERROR="bufferAppendingError",e.BUFFER_STALLED_ERROR="bufferStalledError",e.BUFFER_FULL_ERROR="bufferFullError",e.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",e.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",e.INTERNAL_EXCEPTION="internalException",e.INTERNAL_ABORTED="aborted",e.UNKNOWN="unknown",e}({});const Hh=function(){},$h={trace:Hh,debug:Hh,log:Hh,warn:Hh,info:Hh,error:Hh};let Vh=$h;function Wh(e,...t){t.forEach((function(t){Vh[t]=e[t]?e[t].bind(e):function(e){const t=self.console[e];return t?t.bind(self.console,`[${e}] >`):Hh}(t)}))}const Jh=Vh,qh=/^(\d+)x(\d+)$/,Kh=/(.+?)=(".*?"|.*?)(?:,|$)/g;class Yh{constructor(e){"string"==typeof e&&(e=Yh.parseAttrList(e)),Uh(this,e)}get clientAttrs(){return Object.keys(this).filter((e=>"X-"===e.substring(0,2)))}decimalInteger(e){const t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t}hexadecimalInteger(e){if(this[e]){let t=(this[e]||"0x").slice(2);t=(1&t.length?"0":"")+t;const i=new Uint8Array(t.length/2);for(let e=0;e<t.length/2;e++)i[e]=parseInt(t.slice(2*e,2*e+2),16);return i}return null}hexadecimalIntegerAsNumber(e){const t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t}decimalFloatingPoint(e){return parseFloat(this[e])}optionalFloat(e,t){const i=this[e];return i?parseFloat(i):t}enumeratedString(e){return this[e]}bool(e){return"YES"===this[e]}decimalResolution(e){const t=qh.exec(this[e]);if(null!==t)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(e){let t;const i={};for(Kh.lastIndex=0;null!==(t=Kh.exec(e));){let e=t[2];0===e.indexOf('"')&&e.lastIndexOf('"')===e.length-1&&(e=e.slice(1,-1));i[t[1].trim()]=e}return i}}function Qh(e){return"SCTE35-OUT"===e||"SCTE35-IN"===e}class Xh{constructor(e,t){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,t){const i=t.attr;for(const t in i)if(Object.prototype.hasOwnProperty.call(e,t)&&e[t]!==i[t]){Jh.warn(`DATERANGE tag attribute: "${t}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=t;break}e=Uh(new Yh({}),i,e)}if(this.attr=e,this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){const e=new Date(this.attr["END-DATE"]);Fh(e.getTime())&&(this._endDate=e)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get startDate(){return this._startDate}get endDate(){if(this._endDate)return this._endDate;const e=this.duration;return null!==e?new Date(this._startDate.getTime()+1e3*e):null}get duration(){if("DURATION"in this.attr){const e=this.attr.decimalFloatingPoint("DURATION");if(Fh(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isValid(){return!!this.id&&!this._badValueForSameId&&Fh(this.startDate.getTime())&&(null===this.duration||this.duration>=0)&&(!this.endOnNext||!!this.class)}}class Zh{constructor(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}}var ec="audio",tc="video",ic="audiovideo";class sc{constructor(e){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[ec]:null,[tc]:null,[ic]:null},this.baseurl=e}setByteRange(e,t){const i=e.split("@",2);let s;s=1===i.length?(null==t?void 0:t.byteRangeEndOffset)||0:parseInt(i[1]),this._byteRange=[s,parseInt(i[0])+s]}get byteRange(){return this._byteRange?this._byteRange:[]}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Lh.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}}class rc extends sc{constructor(e,t){super(t),this._decryptdata=null,this.rawProgramDateTime=null,this.programDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.stats=new Zh,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.urlId=0,this.type=e}get decryptdata(){const{levelkeys:e}=this;if(!e&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){const e=this.levelkeys.identity;if(e)this._decryptdata=e.getDecryptData(this.sn);else{const e=Object.keys(this.levelkeys);if(1===e.length)return this._decryptdata=this.levelkeys[e[0]].getDecryptData(this.sn)}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(null===this.programDateTime)return null;if(!Fh(this.programDateTime))return null;const e=Fh(this.duration)?this.duration:0;return this.programDateTime+1e3*e}get encrypted(){var e;if(null!=(e=this._decryptdata)&&e.encrypted)return!0;if(this.levelkeys){const e=Object.keys(this.levelkeys),t=e.length;if(t>1||1===t&&this.levelkeys[e[0]].encrypted)return!0}return!1}setKeyFormat(e){if(this.levelkeys){const t=this.levelkeys[e];t&&!this._decryptdata&&(this._decryptdata=t.getDecryptData(this.sn))}}abortRequests(){var e,t;null==(e=this.loader)||e.abort(),null==(t=this.keyLoader)||t.abort()}setElementaryStreamInfo(e,t,i,s,r,a=!1){const{elementaryStreams:o}=this,n=o[e];n?(n.startPTS=Math.min(n.startPTS,t),n.endPTS=Math.max(n.endPTS,i),n.startDTS=Math.min(n.startDTS,s),n.endDTS=Math.max(n.endDTS,r)):o[e]={startPTS:t,endPTS:i,startDTS:s,endDTS:r,partial:a}}clearElementaryStreamInfo(){const{elementaryStreams:e}=this;e[ec]=null,e[tc]=null,e[ic]=null}}class ac extends sc{constructor(e,t,i,s,r){super(i),this.fragOffset=0,this.duration=0,this.gap=!1,this.independent=!1,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.stats=new Zh,this.duration=e.decimalFloatingPoint("DURATION"),this.gap=e.bool("GAP"),this.independent=e.bool("INDEPENDENT"),this.relurl=e.enumeratedString("URI"),this.fragment=t,this.index=s;const a=e.enumeratedString("BYTERANGE");a&&this.setByteRange(a,r),r&&(this.fragOffset=r.fragOffset+r.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){const{elementaryStreams:e}=this;return!!(e.audio||e.video||e.audiovideo)}}class oc{constructor(e){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=e}reloaded(e){if(!e)return this.advanced=!0,void(this.updated=!0);const t=this.lastPartSn-e.lastPartSn,i=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!i||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||0===t&&i>0,this.updated||this.advanced?this.misses=Math.floor(.6*e.misses):this.misses=e.misses+1,this.availabilityDelay=e.availabilityDelay}get hasProgramDateTime(){return!!this.fragments.length&&Fh(this.fragments[this.fragments.length-1].programDateTime)}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||10}get drift(){const e=this.driftEndTime-this.driftStartTime;if(e>0){return 1e3*(this.driftEnd-this.driftStart)/e}return 1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){var e;return null!=(e=this.fragments)&&e.length?this.fragments[this.fragments.length-1].end:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].index:-1}get lastPartSn(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}function nc(e){return Uint8Array.from(atob(e),(e=>e.charCodeAt(0)))}function lc(e){const t=e.split(":");let i=null;if("data"===t[0]&&2===t.length){const e=t[1].split(";"),s=e[e.length-1].split(",");if(2===s.length){const t="base64"===s[0],r=s[1];t?(e.splice(-1,1),i=nc(r)):i=function(e){const t=dc(e).subarray(0,16),i=new Uint8Array(16);return i.set(t,16-t.length),i}(r)}}return i}function dc(e){return Uint8Array.from(unescape(encodeURIComponent(e)),(e=>e.charCodeAt(0)))}const hc="undefined"!=typeof self?self:void 0;var cc={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},uc="org.w3.clearkey",pc="com.apple.streamingkeydelivery",fc="com.microsoft.playready",mc="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function gc(e){switch(e){case pc:return cc.FAIRPLAY;case fc:return cc.PLAYREADY;case mc:return cc.WIDEVINE;case uc:return cc.CLEARKEY}}var yc="edef8ba979d64acea3c827dcd51d21ed";function Ac(e){switch(e){case cc.FAIRPLAY:return pc;case cc.PLAYREADY:return fc;case cc.WIDEVINE:return mc;case cc.CLEARKEY:return uc}}function bc(e){const{drmSystems:t,widevineLicenseUrl:i}=e,s=t?[cc.FAIRPLAY,cc.WIDEVINE,cc.PLAYREADY,cc.CLEARKEY].filter((e=>!!t[e])):[];return!s[cc.WIDEVINE]&&i&&s.push(cc.WIDEVINE),s}const _c=null!=hc&&null!=(vc=hc.navigator)&&vc.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;var vc;function Sc(e,t,i){return Uint8Array.prototype.slice?e.slice(t,i):new Uint8Array(Array.prototype.slice.call(e,t,i))}const wc=(e,t)=>t+10<=e.length&&73===e[t]&&68===e[t+1]&&51===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128,Ec=(e,t)=>t+10<=e.length&&51===e[t]&&68===e[t+1]&&73===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128,Tc=(e,t)=>{const i=t;let s=0;for(;wc(e,t);){s+=10;s+=kc(e,t+6),Ec(e,t+10)&&(s+=10),t+=s}if(s>0)return e.subarray(i,i+s)},kc=(e,t)=>{let i=0;return i=(127&e[t])<<21,i|=(127&e[t+1])<<14,i|=(127&e[t+2])<<7,i|=127&e[t+3],i},Cc=(e,t)=>wc(e,t)&&kc(e,t+6)+10<=e.length-t,Rc=e=>{const t=Lc(e);for(let e=0;e<t.length;e++){const i=t[e];if(xc(i))return Uc(i)}},xc=e=>e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info,Dc=e=>{const t=String.fromCharCode(e[0],e[1],e[2],e[3]),i=kc(e,4);return{type:t,size:i,data:e.subarray(10,10+i)}},Lc=e=>{let t=0;const i=[];for(;wc(e,t);){const s=kc(e,t+6);t+=10;const r=t+s;for(;t+8<r;){const s=Dc(e.subarray(t)),r=Pc(s);r&&i.push(r),t+=s.size+10}Ec(e,t)&&(t+=10)}return i},Pc=e=>"PRIV"===e.type?Bc(e):"W"===e.type[0]?Mc(e):Ic(e),Bc=e=>{if(e.size<2)return;const t=Fc(e.data,!0),i=new Uint8Array(e.data.subarray(t.length+1));return{key:e.type,info:t,data:i.buffer}},Ic=e=>{if(e.size<2)return;if("TXXX"===e.type){let t=1;const i=Fc(e.data.subarray(t),!0);t+=i.length+1;const s=Fc(e.data.subarray(t));return{key:e.type,info:i,data:s}}const t=Fc(e.data.subarray(1));return{key:e.type,data:t}},Mc=e=>{if("WXXX"===e.type){if(e.size<2)return;let t=1;const i=Fc(e.data.subarray(t),!0);t+=i.length+1;const s=Fc(e.data.subarray(t));return{key:e.type,info:i,data:s}}const t=Fc(e.data);return{key:e.type,data:t}},Uc=e=>{if(8===e.data.byteLength){const t=new Uint8Array(e.data),i=1&t[3];let s=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return s/=45,i&&(s+=47721858.84),Math.round(s)}},Fc=(e,t=!1)=>{const i=Nc();if(i){const s=i.decode(e);if(t){const e=s.indexOf("\0");return-1!==e?s.substring(0,e):s}return s.replace(/\0/g,"")}const s=e.length;let r,a,o,n="",l=0;for(;l<s;){if(r=e[l++],0===r&&t)return n;if(0!==r&&3!==r)switch(r>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:n+=String.fromCharCode(r);break;case 12:case 13:a=e[l++],n+=String.fromCharCode((31&r)<<6|63&a);break;case 14:a=e[l++],o=e[l++],n+=String.fromCharCode((15&r)<<12|(63&a)<<6|63&o)}}return n};let Oc;function Nc(){if(!navigator.userAgent.includes("PlayStation 4"))return Oc||void 0===self.TextDecoder||(Oc=new self.TextDecoder("utf-8")),Oc}const jc=function(e){let t="";for(let i=0;i<e.length;i++){let s=e[i].toString(16);s.length<2&&(s="0"+s),t+=s}return t},zc=Math.pow(2,32)-1,Gc=[].push,Hc={video:1,audio:2,id3:3,text:4};function $c(e){return String.fromCharCode.apply(null,e)}function Vc(e,t){const i=e[t]<<8|e[t+1];return i<0?65536+i:i}function Wc(e,t){const i=qc(e,t);return i<0?4294967296+i:i}function Jc(e,t){let i=Wc(e,t);return i*=Math.pow(2,32),i+=Wc(e,t+4),i}function qc(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function Kc(e,t,i){e[t]=i>>24,e[t+1]=i>>16&255,e[t+2]=i>>8&255,e[t+3]=255&i}function Yc(e,t){const i=[];if(!t.length)return i;const s=e.byteLength;for(let r=0;r<s;){const a=Wc(e,r),o=a>1?r+a:s;if($c(e.subarray(r+4,r+8))===t[0])if(1===t.length)i.push(e.subarray(r+8,o));else{const s=Yc(e.subarray(r+8,o),t.slice(1));s.length&&Gc.apply(i,s)}r=o}return i}function Qc(e){const t=[],i=e[0];let s=8;const r=Wc(e,s);s+=4;let a=0,o=0;0===i?(a=Wc(e,s),o=Wc(e,s+4),s+=8):(a=Jc(e,s),o=Jc(e,s+8),s+=16),s+=2;let n=e.length+o;const l=Vc(e,s);s+=2;for(let i=0;i<l;i++){let i=s;const a=Wc(e,i);i+=4;const o=2147483647&a;if(1===(2147483648&a)>>>31)return Jh.warn("SIDX has hierarchical references (not supported)"),null;const l=Wc(e,i);i+=4,t.push({referenceSize:o,subsegmentDuration:l,info:{duration:l/r,start:n,end:n+o-1}}),n+=o,i+=4,s=i}return{earliestPresentationTime:a,timescale:r,version:i,referencesCount:l,references:t}}function Xc(e){const t=[],i=Yc(e,["moov","trak"]);for(let e=0;e<i.length;e++){const s=i[e],r=Yc(s,["tkhd"])[0];if(r){let e=r[0];const i=Wc(r,0===e?12:20),a=Yc(s,["mdia","mdhd"])[0];if(a){e=a[0];const r=Wc(a,0===e?12:20),o=Yc(s,["mdia","hdlr"])[0];if(o){const e=$c(o.subarray(8,12)),a={soun:ec,vide:tc}[e];if(a){const e=Zc(Yc(s,["mdia","minf","stbl","stsd"])[0]);t[i]={timescale:r,type:a},t[a]=Bh({timescale:r,id:i},e)}}}}}return Yc(e,["moov","mvex","trex"]).forEach((e=>{const i=Wc(e,4),s=t[i];s&&(s.default={duration:Wc(e,12),flags:Wc(e,20)})})),t}function Zc(e){const t=e.subarray(8),i=t.subarray(86),s=$c(t.subarray(4,8));let r=s;const a="enca"===s||"encv"===s;if(a){const e=Yc(t,[s])[0];Yc(e.subarray("enca"===s?28:78),["sinf"]).forEach((e=>{const t=Yc(e,["schm"])[0];if(t){const i=$c(t.subarray(4,8));if("cbcs"===i||"cenc"===i){const t=Yc(e,["frma"])[0];t&&(r=$c(t))}}}))}switch(r){case"avc1":case"avc2":case"avc3":case"avc4":{const e=Yc(i,["avcC"])[0];r+="."+tu(e[1])+tu(e[2])+tu(e[3]);break}case"mp4a":{const e=Yc(t,[s])[0],i=Yc(e.subarray(28),["esds"])[0];if(i&&i.length>12){let e=4;if(3!==i[e++])break;e=eu(i,e),e+=2;const t=i[e++];if(128&t&&(e+=2),64&t&&(e+=i[e++]),4!==i[e++])break;e=eu(i,e);const s=i[e++];if(64!==s)break;if(r+="."+tu(s),e+=12,5!==i[e++])break;e=eu(i,e);const a=i[e++];let o=(248&a)>>3;31===o&&(o+=1+((7&a)<<3)+((224&i[e])>>5)),r+="."+o}break}case"hvc1":case"hev1":{const e=Yc(i,["hvcC"])[0],t=e[1],s=["","A","B","C"][t>>6],a=31&t,o=Wc(e,2),n=(32&t)>>5?"H":"L",l=e[12],d=e.subarray(6,12);r+="."+s+a,r+="."+o.toString(16).toUpperCase(),r+="."+n+l;let h="";for(let e=d.length;e--;){const t=d[e];if(t||h){h="."+t.toString(16).toUpperCase()+h}}r+=h;break}case"dvh1":case"dvhe":{const e=Yc(i,["dvcC"])[0],t=e[2]>>1&127,s=e[2]<<5&32|e[3]>>3&31;r+="."+iu(t)+"."+iu(s);break}case"vp09":{const e=Yc(i,["vpcC"])[0],t=e[4],s=e[5],a=e[6]>>4&15;r+="."+iu(t)+"."+iu(s)+"."+iu(a);break}case"av01":{const e=Yc(i,["av1C"])[0],t=e[1]>>>5,s=31&e[1],a=e[2]>>>7?"H":"M",o=(64&e[2])>>6,n=(32&e[2])>>5,l=2===t&&o?n?12:10:o?10:8,d=(16&e[2])>>4,h=(8&e[2])>>3,c=(4&e[2])>>2,u=3&e[2],p=1,f=1,m=1,g=0;r+="."+t+"."+iu(s)+a+"."+iu(l)+"."+d+"."+h+c+u+"."+iu(p)+"."+iu(f)+"."+iu(m)+"."+g;break}}return{codec:r,encrypted:a}}function eu(e,t){const i=t+5;for(;128&e[t++]&&t<i;);return t}function tu(e){return("0"+e.toString(16).toUpperCase()).slice(-2)}function iu(e){return(e<10?"0":"")+e}function su(e){const t=Yc(e,["schm"])[0];if(t){const i=$c(t.subarray(4,8));if("cbcs"===i||"cenc"===i)return Yc(e,["schi","tenc"])[0]}return Jh.error("[eme] missing 'schm' box"),null}function ru(e){const t=Wc(e,0);let i=8;1&t&&(i+=4),4&t&&(i+=4);let s=0;const r=Wc(e,4);for(let a=0;a<r;a++){if(256&t){s+=Wc(e,i),i+=4}512&t&&(i+=4),1024&t&&(i+=4),2048&t&&(i+=4)}return s}function au(e,t){const i=new Uint8Array(e.length+t.length);return i.set(e),i.set(t,e.length),i}function ou(e,t){const i=[],s=t.samples,r=t.timescale,a=t.id;let o=!1;return Yc(s,["moof"]).map((n=>{const l=n.byteOffset-8;Yc(n,["traf"]).map((n=>{const d=Yc(n,["tfdt"]).map((e=>{const t=e[0];let i=Wc(e,4);return 1===t&&(i*=Math.pow(2,32),i+=Wc(e,8)),i/r}))[0];return void 0!==d&&(e=d),Yc(n,["tfhd"]).map((d=>{const h=Wc(d,4),c=16777215&Wc(d,0);let u=0;const p=!!(16&c);let f=0;const m=!!(32&c);let g=8;h===a&&(!!(1&c)&&(g+=8),!!(2&c)&&(g+=4),!!(8&c)&&(u=Wc(d,g),g+=4),p&&(f=Wc(d,g),g+=4),m&&(g+=4),"video"===t.type&&(o=function(e){if(!e)return!1;const t=e.indexOf("."),i=t<0?e:e.substring(0,t);return"hvc1"===i||"hev1"===i||"dvh1"===i||"dvhe"===i}(t.codec)),Yc(n,["trun"]).map((a=>{const n=a[0],d=16777215&Wc(a,0),h=!!(1&d);let c=0;const p=!!(4&d),m=!!(256&d);let g=0;const y=!!(512&d);let A=0;const b=!!(1024&d),_=!!(2048&d);let v=0;const S=Wc(a,4);let w=8;h&&(c=Wc(a,w),w+=4),p&&(w+=4);let E=c+l;for(let l=0;l<S;l++){if(m?(g=Wc(a,w),w+=4):g=u,y?(A=Wc(a,w),w+=4):A=f,b&&(w+=4),_&&(v=0===n?Wc(a,w):qc(a,w),w+=4),t.type===tc){let t=0;for(;t<A;){const a=Wc(s,E);if(E+=4,nu(o,s[E])){lu(s.subarray(E,E+a),o?2:1,e+v/r,i)}E+=a,t+=a+4}}e+=g/r}})))}))}))})),i}function nu(e,t){if(e){const e=t>>1&63;return 39===e||40===e}return 6===(31&t)}function lu(e,t,i,s){const r=du(e);let a=0;a+=t;let o=0,n=0,l=0;for(;a<r.length;){o=0;do{if(a>=r.length)break;l=r[a++],o+=l}while(255===l);n=0;do{if(a>=r.length)break;l=r[a++],n+=l}while(255===l);const e=r.length-a;let t=a;if(n<e)a+=n;else if(n>e){Jh.error(`Malformed SEI payload. ${n} is too small, only ${e} bytes left to parse.`);break}if(4===o){if(181===r[t++]){const e=Vc(r,t);if(t+=2,49===e){const e=Wc(r,t);if(t+=4,1195456820===e){const e=r[t++];if(3===e){const a=r[t++],n=64&a,l=n?2+3*(31&a):0,d=new Uint8Array(l);if(n){d[0]=a;for(let e=1;e<l;e++)d[e]=r[t++]}s.push({type:e,payloadType:o,pts:i,bytes:d})}}}}}else if(5===o&&n>16){const e=[];for(let i=0;i<16;i++){const s=r[t++].toString(16);e.push(1==s.length?"0"+s:s),3!==i&&5!==i&&7!==i&&9!==i||e.push("-")}const a=n-16,l=new Uint8Array(a);for(let e=0;e<a;e++)l[e]=r[t++];s.push({payloadType:o,pts:i,uuid:e.join(""),userData:Fc(l),userDataBytes:l})}}}function du(e){const t=e.byteLength,i=[];let s=1;for(;s<t-2;)0===e[s]&&0===e[s+1]&&3===e[s+2]?(i.push(s+2),s+=2):s++;if(0===i.length)return e;const r=t-i.length,a=new Uint8Array(r);let o=0;for(s=0;s<r;o++,s++)o===i[0]&&(o++,i.shift()),a[s]=e[o];return a}function hu(e,t,i){if(16!==e.byteLength)throw new RangeError("Invalid system id");let s,r,a;if(t){s=1,r=new Uint8Array(16*t.length);for(let e=0;e<t.length;e++){const i=t[e];if(16!==i.byteLength)throw new RangeError("Invalid key");r.set(i,16*e)}}else s=0,r=new Uint8Array;s>0?(a=new Uint8Array(4),t.length>0&&new DataView(a.buffer).setUint32(0,t.length,!1)):a=new Uint8Array;const o=new Uint8Array(4);return i&&i.byteLength>0&&new DataView(o.buffer).setUint32(0,i.byteLength,!1),function(e,...t){const i=t.length;let s=8,r=i;for(;r--;)s+=t[r].byteLength;const a=new Uint8Array(s);for(a[0]=s>>24&255,a[1]=s>>16&255,a[2]=s>>8&255,a[3]=255&s,a.set(e,4),r=0,s=8;r<i;r++)a.set(t[r],s),s+=t[r].byteLength;return a}([112,115,115,104],new Uint8Array([s,0,0,0]),e,a,r,o,i||new Uint8Array)}let cu={};class uu{static clearKeyUriToKeyIdMap(){cu={}}constructor(e,t,i,s=[1],r=null){this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=e,this.uri=t,this.keyFormat=i,this.keyFormatVersions=s,this.iv=r,this.encrypted=!!e&&"NONE"!==e,this.isCommonEncryption=this.encrypted&&"AES-128"!==e}isSupported(){if(this.method){if("AES-128"===this.method||"NONE"===this.method)return!0;if("identity"===this.keyFormat)return"SAMPLE-AES"===this.method;switch(this.keyFormat){case pc:case mc:case fc:case uc:return-1!==["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)}}return!1}getDecryptData(e){if(!this.encrypted||!this.uri)return null;if("AES-128"===this.method&&this.uri&&!this.iv){"number"!=typeof e&&("AES-128"!==this.method||this.iv||Jh.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0);const t=function(e){const t=new Uint8Array(16);for(let i=12;i<16;i++)t[i]=e>>8*(15-i)&255;return t}(e);return new uu(this.method,this.uri,"identity",this.keyFormatVersions,t)}const t=lc(this.uri);if(t)switch(this.keyFormat){case mc:this.pssh=t,t.length>=22&&(this.keyId=t.subarray(t.length-22,t.length-6));break;case fc:{const e=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=hu(e,null,t);const i=new Uint16Array(t.buffer,t.byteOffset,t.byteLength/2),s=String.fromCharCode.apply(null,Array.from(i)),r=s.substring(s.indexOf("<"),s.length),a=(new DOMParser).parseFromString(r,"text/xml").getElementsByTagName("KID")[0];if(a){const e=a.childNodes[0]?a.childNodes[0].nodeValue:a.getAttribute("VALUE");if(e){const t=nc(e).subarray(0,16);!function(e){const t=function(e,t,i){const s=e[t];e[t]=e[i],e[i]=s};t(e,0,3),t(e,1,2),t(e,4,5),t(e,6,7)}(t),this.keyId=t}}break}default:{let e=t.subarray(0,16);if(16!==e.length){const t=new Uint8Array(16);t.set(e,16-e.length),e=t}this.keyId=e;break}}if(!this.keyId||16!==this.keyId.byteLength){let e=cu[this.uri];if(!e){const t=Object.keys(cu).length%Number.MAX_SAFE_INTEGER;e=new Uint8Array(16);new DataView(e.buffer,12,4).setUint32(0,t),cu[this.uri]=e}this.keyId=e}return this}}const pu=/\{\$([a-zA-Z0-9-_]+)\}/g;function fu(e){return pu.test(e)}function mu(e,t,i){if(null!==e.variableList||e.hasVariableRefs)for(let s=i.length;s--;){const r=i[s],a=t[r];a&&(t[r]=gu(e,a))}}function gu(e,t){if(null!==e.variableList||e.hasVariableRefs){const i=e.variableList;return t.replace(pu,(t=>{const s=t.substring(2,t.length-1),r=null==i?void 0:i[s];return void 0===r?(e.playlistParsingError||(e.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${s}"`)),t):r}))}return t}function yu(e,t,i){let s,r,a=e.variableList;if(a||(e.variableList=a={}),"QUERYPARAM"in t){s=t.QUERYPARAM;try{const e=new self.URL(i).searchParams;if(!e.has(s))throw new Error(`"${s}" does not match any query parameter in URI: "${i}"`);r=e.get(s)}catch(t){e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${t.message}`))}}else s=t.NAME,r=t.VALUE;s in a?e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${s}"`)):a[s]=r||""}function Au(e,t,i){const s=t.IMPORT;if(i&&s in i){let t=e.variableList;t||(e.variableList=t={}),t[s]=i[s]}else e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${s}"`))}function bu(e=!0){if("undefined"==typeof self)return;return(e||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}const _u={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv60:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1}};function vu(e,t,i=!0){return!e.split(",").some((e=>!Su(e,t,i)))}function Su(e,t,i=!0){var s;const r=bu(i);return null!=(s=null==r?void 0:r.isTypeSupported(wu(e,t)))&&s}function wu(e,t){return`${t}/mp4;codecs="${e}"`}function Eu(e){if(e){const t=e.substring(0,4);return _u.video[t]}return 2}function Tu(e){return e.split(",").reduce(((e,t)=>{const i=_u.video[t];return i?(2*i+e)/(e?3:2):(_u.audio[t]+e)/(e?2:1)}),0)}const ku={};const Cu=/flac|opus/i;function Ru(e,t=!0){return e.replace(Cu,(e=>function(e,t=!0){if(ku[e])return ku[e];const i={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"]}[e];for(let s=0;s<i.length;s++)if(Su(i[s],"audio",t))return ku[e]=i[s],i[s];return e}(e.toLowerCase(),t)))}function xu(e,t){return e&&"mp4a"!==e?e:t}const Du=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,Lu=/#EXT-X-MEDIA:(.*)/g,Pu=/^#EXT(?:INF|-X-TARGETDURATION):/m,Bu=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),Iu=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP|INDEPENDENT-SEGMENTS)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|"));class Mu{static findGroup(e,t){for(let i=0;i<e.length;i++){const s=e[i];if(s.id===t)return s}}static resolve(e,t){return Lh.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return Pu.test(e)}static parseMasterPlaylist(e,t){const i={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:fu(e)},s=[];let r;for(Du.lastIndex=0;null!=(r=Du.exec(e));)if(r[1]){var a;const e=new Yh(r[1]);mu(i,e,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);const o=gu(i,r[2]),n={attrs:e,bitrate:e.decimalInteger("BANDWIDTH")||e.decimalInteger("AVERAGE-BANDWIDTH"),name:e.NAME,url:Mu.resolve(o,t)},l=e.decimalResolution("RESOLUTION");l&&(n.width=l.width,n.height=l.height),Ou(e.CODECS,n),null!=(a=n.unknownCodecs)&&a.length||s.push(n),i.levels.push(n)}else if(r[3]){const e=r[3],s=r[4];switch(e){case"SESSION-DATA":{const e=new Yh(s);mu(i,e,["DATA-ID","LANGUAGE","VALUE","URI"]);const t=e["DATA-ID"];t&&(null===i.sessionData&&(i.sessionData={}),i.sessionData[t]=e);break}case"SESSION-KEY":{const e=Uu(s,t,i);e.encrypted&&e.isSupported()?(null===i.sessionKeys&&(i.sessionKeys=[]),i.sessionKeys.push(e)):Jh.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${s}"`);break}case"DEFINE":{const e=new Yh(s);mu(i,e,["NAME","VALUE","QUERYPARAM"]),yu(i,e,t)}break;case"CONTENT-STEERING":{const e=new Yh(s);mu(i,e,["SERVER-URI","PATHWAY-ID"]),i.contentSteering={uri:Mu.resolve(e["SERVER-URI"],t),pathwayId:e["PATHWAY-ID"]||"."};break}case"START":i.startTimeOffset=Fu(s)}}const o=s.length>0&&s.length<i.levels.length;return i.levels=o?s:i.levels,0===i.levels.length&&(i.playlistParsingError=new Error("no levels found in manifest")),i}static parseMasterPlaylistMedia(e,t,i){let s;const r={},a=i.levels,o={AUDIO:a.map((e=>({id:e.attrs.AUDIO,audioCodec:e.audioCodec}))),SUBTITLES:a.map((e=>({id:e.attrs.SUBTITLES,textCodec:e.textCodec}))),"CLOSED-CAPTIONS":[]};let n=0;for(Lu.lastIndex=0;null!==(s=Lu.exec(e));){const e=new Yh(s[1]),a=e.TYPE;if(a){const s=o[a],l=r[a]||[];r[a]=l,mu(i,e,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);const d=e.LANGUAGE,h=e["ASSOC-LANGUAGE"],c=e.CHANNELS,u=e.CHARACTERISTICS,p=e["INSTREAM-ID"],f={attrs:e,bitrate:0,id:n++,groupId:e["GROUP-ID"]||"",name:e.NAME||d||"",type:a,default:e.bool("DEFAULT"),autoselect:e.bool("AUTOSELECT"),forced:e.bool("FORCED"),lang:d,url:e.URI?Mu.resolve(e.URI,t):""};if(h&&(f.assocLang=h),c&&(f.channels=c),u&&(f.characteristics=u),p&&(f.instreamId=p),null!=s&&s.length){const e=Mu.findGroup(s,f.groupId)||s[0];Nu(f,e,"audioCodec"),Nu(f,e,"textCodec")}l.push(f)}}return r}static parseLevelPlaylist(e,t,i,s,r,a){const o=new oc(t),n=o.fragments;let l,d,h,c=null,u=0,p=0,f=0,m=0,g=null,y=new rc(s,t),A=-1,b=!1,_=null;for(Bu.lastIndex=0,o.m3u8=e,o.hasVariableRefs=fu(e);null!==(l=Bu.exec(e));){b&&(b=!1,y=new rc(s,t),y.start=f,y.sn=u,y.cc=m,y.level=i,c&&(y.initSegment=c,y.rawProgramDateTime=c.rawProgramDateTime,c.rawProgramDateTime=null,_&&(y.setByteRange(_),_=null)));const e=l[1];if(e){y.duration=parseFloat(e);const t=(" "+l[2]).slice(1);y.title=t||null,y.tagList.push(t?["INF",e,t]:["INF",e])}else if(l[3]){if(Fh(y.duration)){y.start=f,h&&Gu(y,h,o),y.sn=u,y.level=i,y.cc=m,n.push(y);const e=(" "+l[3]).slice(1);y.relurl=gu(o,e),ju(y,g),g=y,f+=y.duration,u++,p=0,b=!0}}else if(l[4]){const e=(" "+l[4]).slice(1);g?y.setByteRange(e,g):y.setByteRange(e)}else if(l[5])y.rawProgramDateTime=(" "+l[5]).slice(1),y.tagList.push(["PROGRAM-DATE-TIME",y.rawProgramDateTime]),-1===A&&(A=n.length);else{if(l=l[0].match(Iu),!l){Jh.warn("No matches on slow regex match for level playlist!");continue}for(d=1;d<l.length&&void 0===l[d];d++);const e=(" "+l[d]).slice(1),r=(" "+l[d+1]).slice(1),f=l[d+2]?(" "+l[d+2]).slice(1):"";switch(e){case"PLAYLIST-TYPE":o.type=r.toUpperCase();break;case"MEDIA-SEQUENCE":u=o.startSN=parseInt(r);break;case"SKIP":{const e=new Yh(r);mu(o,e,["RECENTLY-REMOVED-DATERANGES"]);const t=e.decimalInteger("SKIPPED-SEGMENTS");if(Fh(t)){o.skippedSegments=t;for(let e=t;e--;)n.unshift(null);u+=t}const i=e.enumeratedString("RECENTLY-REMOVED-DATERANGES");i&&(o.recentlyRemovedDateranges=i.split("\t"));break}case"TARGETDURATION":o.targetduration=Math.max(parseInt(r),1);break;case"VERSION":o.version=parseInt(r);break;case"INDEPENDENT-SEGMENTS":case"EXTM3U":break;case"ENDLIST":o.live=!1;break;case"#":(r||f)&&y.tagList.push(f?[r,f]:[r]);break;case"DISCONTINUITY":m++,y.tagList.push(["DIS"]);break;case"GAP":y.gap=!0,y.tagList.push([e]);break;case"BITRATE":y.tagList.push([e,r]);break;case"DATERANGE":{const e=new Yh(r);mu(o,e,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),mu(o,e,e.clientAttrs);const t=new Xh(e,o.dateRanges[e.ID]);t.isValid||o.skippedSegments?o.dateRanges[t.id]=t:Jh.warn(`Ignoring invalid DATERANGE tag: "${r}"`),y.tagList.push(["EXT-X-DATERANGE",r]);break}case"DEFINE":{const e=new Yh(r);mu(o,e,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in e?Au(o,e,a):yu(o,e,t)}break;case"DISCONTINUITY-SEQUENCE":m=parseInt(r);break;case"KEY":{const e=Uu(r,t,o);if(e.isSupported()){if("NONE"===e.method){h=void 0;break}h||(h={}),h[e.keyFormat]&&(h=Uh({},h)),h[e.keyFormat]=e}else Jh.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${r}"`);break}case"START":o.startTimeOffset=Fu(r);break;case"MAP":{const e=new Yh(r);if(mu(o,e,["BYTERANGE","URI"]),y.duration){const r=new rc(s,t);zu(r,e,i,h),c=r,y.initSegment=c,c.rawProgramDateTime&&!y.rawProgramDateTime&&(y.rawProgramDateTime=c.rawProgramDateTime)}else{const t=y.byteRangeEndOffset;if(t){const e=y.byteRangeStartOffset;_=`${t-e}@${e}`}else _=null;zu(y,e,i,h),c=y,b=!0}break}case"SERVER-CONTROL":{const e=new Yh(r);o.canBlockReload=e.bool("CAN-BLOCK-RELOAD"),o.canSkipUntil=e.optionalFloat("CAN-SKIP-UNTIL",0),o.canSkipDateRanges=o.canSkipUntil>0&&e.bool("CAN-SKIP-DATERANGES"),o.partHoldBack=e.optionalFloat("PART-HOLD-BACK",0),o.holdBack=e.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{const e=new Yh(r);o.partTarget=e.decimalFloatingPoint("PART-TARGET");break}case"PART":{let e=o.partList;e||(e=o.partList=[]);const i=p>0?e[e.length-1]:void 0,s=p++,a=new Yh(r);mu(o,a,["BYTERANGE","URI"]);const n=new ac(a,y,t,s,i);e.push(n),y.duration+=n.duration;break}case"PRELOAD-HINT":{const e=new Yh(r);mu(o,e,["URI"]),o.preloadHint=e;break}case"RENDITION-REPORT":{const e=new Yh(r);mu(o,e,["URI"]),o.renditionReports=o.renditionReports||[],o.renditionReports.push(e);break}default:Jh.warn(`line parsed but not handled: ${l}`)}}}g&&!g.relurl?(n.pop(),f-=g.duration,o.partList&&(o.fragmentHint=g)):o.partList&&(ju(y,g),y.cc=m,o.fragmentHint=y,h&&Gu(y,h,o));const v=n.length,S=n[0],w=n[v-1];if(f+=o.skippedSegments*o.targetduration,f>0&&v&&w){o.averagetargetduration=f/v;const e=w.sn;o.endSN="initSegment"!==e?e:0,o.live||(w.endList=!0),S&&(o.startCC=S.cc)}else o.endSN=0,o.startCC=0;return o.fragmentHint&&(f+=o.fragmentHint.duration),o.totalduration=f,o.endCC=m,A>0&&function(e,t){let i=e[t];for(let s=t;s--;){const t=e[s];if(!t)return;t.programDateTime=i.programDateTime-1e3*t.duration,i=t}}(n,A),o}}function Uu(e,t,i){var s,r;const a=new Yh(e);mu(i,a,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);const o=null!=(s=a.METHOD)?s:"",n=a.URI,l=a.hexadecimalInteger("IV"),d=a.KEYFORMATVERSIONS,h=null!=(r=a.KEYFORMAT)?r:"identity";n&&a.IV&&!l&&Jh.error(`Invalid IV: ${a.IV}`);const c=n?Mu.resolve(n,t):"",u=(d||"1").split("/").map(Number).filter(Number.isFinite);return new uu(o,c,h,u,l)}function Fu(e){const t=new Yh(e).decimalFloatingPoint("TIME-OFFSET");return Fh(t)?t:null}function Ou(e,t){let i=(e||"").split(/[ ,]+/).filter((e=>e));["video","audio","text"].forEach((e=>{const s=i.filter((t=>function(e,t){const i=_u[t];return!!i&&!!i[e.slice(0,4)]}(t,e)));s.length&&(t[`${e}Codec`]=s.join(","),i=i.filter((e=>-1===s.indexOf(e))))})),t.unknownCodecs=i}function Nu(e,t,i){const s=t[i];s&&(e[i]=s)}function ju(e,t){e.rawProgramDateTime?e.programDateTime=Date.parse(e.rawProgramDateTime):null!=t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime),Fh(e.programDateTime)||(e.programDateTime=null,e.rawProgramDateTime=null)}function zu(e,t,i,s){e.relurl=t.URI,t.BYTERANGE&&e.setByteRange(t.BYTERANGE),e.level=i,e.sn="initSegment",s&&(e.levelkeys=s),e.initSegment=null}function Gu(e,t,i){e.levelkeys=t;const{encryptedFragments:s}=i;s.length&&s[s.length-1].levelkeys===t||!Object.keys(t).some((e=>t[e].isCommonEncryption))||s.push(e)}var Hu="manifest",$u="level",Vu="audioTrack",Wu="subtitleTrack",Ju="main",qu="audio",Ku="subtitle";function Yu(e){const{type:t}=e;switch(t){case Vu:return qu;case Wu:return Ku;default:return Ju}}function Qu(e,t){let i=e.url;return void 0!==i&&0!==i.indexOf("data:")||(i=t.url),i}class Xu{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=e,this.registerListeners()}startLoad(e){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){const{hls:e}=this;e.on(jh.MANIFEST_LOADING,this.onManifestLoading,this),e.on(jh.LEVEL_LOADING,this.onLevelLoading,this),e.on(jh.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(jh.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){const{hls:e}=this;e.off(jh.MANIFEST_LOADING,this.onManifestLoading,this),e.off(jh.LEVEL_LOADING,this.onLevelLoading,this),e.off(jh.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(jh.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}createInternalLoader(e){const t=this.hls.config,i=t.pLoader,s=t.loader,r=new(i||s)(t);return this.loaders[e.type]=r,r}getInternalLoader(e){return this.loaders[e.type]}resetInternalLoader(e){this.loaders[e]&&delete this.loaders[e]}destroyInternalLoaders(){for(const e in this.loaders){const t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(e,t){const{url:i}=t;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:Hu,url:i,deliveryDirectives:null})}onLevelLoading(e,t){const{id:i,level:s,pathwayId:r,url:a,deliveryDirectives:o}=t;this.load({id:i,level:s,pathwayId:r,responseType:"text",type:$u,url:a,deliveryDirectives:o})}onAudioTrackLoading(e,t){const{id:i,groupId:s,url:r,deliveryDirectives:a}=t;this.load({id:i,groupId:s,level:null,responseType:"text",type:Vu,url:r,deliveryDirectives:a})}onSubtitleTrackLoading(e,t){const{id:i,groupId:s,url:r,deliveryDirectives:a}=t;this.load({id:i,groupId:s,level:null,responseType:"text",type:Wu,url:r,deliveryDirectives:a})}load(e){var t;const i=this.hls.config;let s,r=this.getInternalLoader(e);if(r){const t=r.context;if(t&&t.url===e.url&&t.level===e.level)return void Jh.trace("[playlist-loader]: playlist request ongoing");Jh.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),r.abort()}if(s=e.type===Hu?i.manifestLoadPolicy.default:Uh({},i.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),r=this.createInternalLoader(e),Fh(null==(t=e.deliveryDirectives)?void 0:t.part)){let t;if(e.type===$u&&null!==e.level?t=this.hls.levels[e.level].details:e.type===Vu&&null!==e.id?t=this.hls.audioTracks[e.id].details:e.type===Wu&&null!==e.id&&(t=this.hls.subtitleTracks[e.id].details),t){const e=t.partTarget,i=t.targetduration;if(e&&i){const t=1e3*Math.max(3*e,.8*i);s=Uh({},s,{maxTimeToFirstByteMs:Math.min(t,s.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(t,s.maxTimeToFirstByteMs)})}}}const a=s.errorRetry||s.timeoutRetry||{},o={loadPolicy:s,timeout:s.maxLoadTimeMs,maxRetry:a.maxNumRetry||0,retryDelay:a.retryDelayMs||0,maxRetryDelay:a.maxRetryDelayMs||0},n={onSuccess:(e,t,i,s)=>{const r=this.getInternalLoader(i);this.resetInternalLoader(i.type);const a=e.data;0===a.indexOf("#EXTM3U")?(t.parsing.start=performance.now(),Mu.isMediaPlaylist(a)?this.handleTrackOrLevelPlaylist(e,t,i,s||null,r):this.handleMasterPlaylist(e,t,i,s)):this.handleManifestParsingError(e,i,new Error("no EXTM3U delimiter"),s||null,t)},onError:(e,t,i,s)=>{this.handleNetworkError(t,i,!1,e,s)},onTimeout:(e,t,i)=>{this.handleNetworkError(t,i,!0,void 0,e)}};r.load(e,o,n)}handleMasterPlaylist(e,t,i,s){const r=this.hls,a=e.data,o=Qu(e,i),n=Mu.parseMasterPlaylist(a,o);if(n.playlistParsingError)return void this.handleManifestParsingError(e,i,n.playlistParsingError,s,t);const{contentSteering:l,levels:d,sessionData:h,sessionKeys:c,startTimeOffset:u,variableList:p}=n;this.variableList=p;const{AUDIO:f=[],SUBTITLES:m,"CLOSED-CAPTIONS":g}=Mu.parseMasterPlaylistMedia(a,o,n);if(f.length){f.some((e=>!e.url))||!d[0].audioCodec||d[0].attrs.AUDIO||(Jh.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),f.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new Yh({}),bitrate:0,url:""}))}r.trigger(jh.MANIFEST_LOADED,{levels:d,audioTracks:f,subtitles:m,captions:g,contentSteering:l,url:o,stats:t,networkDetails:s,sessionData:h,sessionKeys:c,startTimeOffset:u,variableList:p})}handleTrackOrLevelPlaylist(e,t,i,s,r){const a=this.hls,{id:o,level:n,type:l}=i,d=Qu(e,i),h=Fh(n)?n:Fh(o)?o:0,c=Yu(i),u=Mu.parseLevelPlaylist(e.data,d,h,c,0,this.variableList);if(l===Hu){const e={attrs:new Yh({}),bitrate:0,details:u,name:"",url:d};a.trigger(jh.MANIFEST_LOADED,{levels:[e],audioTracks:[],url:d,stats:t,networkDetails:s,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),i.levelDetails=u,this.handlePlaylistLoaded(u,e,t,i,s,r)}handleManifestParsingError(e,t,i,s,r){this.hls.trigger(jh.ERROR,{type:zh.NETWORK_ERROR,details:Gh.MANIFEST_PARSING_ERROR,fatal:t.type===Hu,url:e.url,err:i,error:i,reason:i.message,response:e,context:t,networkDetails:s,stats:r})}handleNetworkError(e,t,i=!1,s,r){let a=`A network ${i?"timeout":"error"+(s?" (status "+s.code+")":"")} occurred while loading ${e.type}`;e.type===$u?a+=`: ${e.level} id: ${e.id}`:e.type!==Vu&&e.type!==Wu||(a+=` id: ${e.id} group-id: "${e.groupId}"`);const o=new Error(a);Jh.warn(`[playlist-loader]: ${a}`);let n=Gh.UNKNOWN,l=!1;const d=this.getInternalLoader(e);switch(e.type){case Hu:n=i?Gh.MANIFEST_LOAD_TIMEOUT:Gh.MANIFEST_LOAD_ERROR,l=!0;break;case $u:n=i?Gh.LEVEL_LOAD_TIMEOUT:Gh.LEVEL_LOAD_ERROR,l=!1;break;case Vu:n=i?Gh.AUDIO_TRACK_LOAD_TIMEOUT:Gh.AUDIO_TRACK_LOAD_ERROR,l=!1;break;case Wu:n=i?Gh.SUBTITLE_TRACK_LOAD_TIMEOUT:Gh.SUBTITLE_LOAD_ERROR,l=!1}d&&this.resetInternalLoader(e.type);const h={type:zh.NETWORK_ERROR,details:n,fatal:l,url:e.url,loader:d,context:e,error:o,networkDetails:t,stats:r};if(s){const i=(null==t?void 0:t.url)||e.url;h.response=Bh({url:i,data:void 0},s)}this.hls.trigger(jh.ERROR,h)}handlePlaylistLoaded(e,t,i,s,r,a){const o=this.hls,{type:n,level:l,id:d,groupId:h,deliveryDirectives:c}=s,u=Qu(t,s),p=Yu(s),f="number"==typeof s.level&&p===Ju?l:void 0;if(!e.fragments.length){const e=new Error("No Segments found in Playlist");return void o.trigger(jh.ERROR,{type:zh.NETWORK_ERROR,details:Gh.LEVEL_EMPTY_ERROR,fatal:!1,url:u,error:e,reason:e.message,response:t,context:s,level:f,parent:p,networkDetails:r,stats:i})}e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));const m=e.playlistParsingError;if(m)o.trigger(jh.ERROR,{type:zh.NETWORK_ERROR,details:Gh.LEVEL_PARSING_ERROR,fatal:!1,url:u,error:m,reason:m.message,response:t,context:s,level:f,parent:p,networkDetails:r,stats:i});else switch(e.live&&a&&(a.getCacheAge&&(e.ageHeader=a.getCacheAge()||0),a.getCacheAge&&!isNaN(e.ageHeader)||(e.ageHeader=0)),n){case Hu:case $u:o.trigger(jh.LEVEL_LOADED,{details:e,level:f||0,id:d||0,stats:i,networkDetails:r,deliveryDirectives:c});break;case Vu:o.trigger(jh.AUDIO_TRACK_LOADED,{details:e,id:d||0,groupId:h||"",stats:i,networkDetails:r,deliveryDirectives:c});break;case Wu:o.trigger(jh.SUBTITLE_TRACK_LOADED,{details:e,id:d||0,groupId:h||"",stats:i,networkDetails:r,deliveryDirectives:c})}}}function Zu(e,t){let i;try{i=new Event("addtrack")}catch(e){i=document.createEvent("Event"),i.initEvent("addtrack",!1,!1)}i.track=e,t.dispatchEvent(i)}function ep(e,t){const 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){Jh.debug(`[texttrack-utils]: ${i}`);try{const i=new self.TextTrackCue(t.startTime,t.endTime,t.text);i.id=t.id,e.addCue(i)}catch(e){Jh.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${e}`)}}"disabled"===i&&(e.mode=i)}function tp(e){const t=e.mode;if("disabled"===t&&(e.mode="hidden"),e.cues)for(let t=e.cues.length;t--;)e.removeCue(e.cues[t]);"disabled"===t&&(e.mode=t)}function ip(e,t,i,s){const r=e.mode;if("disabled"===r&&(e.mode="hidden"),e.cues&&e.cues.length>0){const r=function(e,t,i){const s=[],r=function(e,t){if(t<e[0].startTime)return 0;const i=e.length-1;if(t>e[i].endTime)return-1;let s=0,r=i;for(;s<=r;){const a=Math.floor((r+s)/2);if(t<e[a].startTime)r=a-1;else{if(!(t>e[a].startTime&&s<i))return a;s=a+1}}return e[s].startTime-t<t-e[r].startTime?s:r}(e,t);if(r>-1)for(let a=r,o=e.length;a<o;a++){const r=e[a];if(r.startTime>=t&&r.endTime<=i)s.push(r);else if(r.startTime>i)return s}return s}(e.cues,t,i);for(let t=0;t<r.length;t++)s&&!s(r[t])||e.removeCue(r[t])}"disabled"===r&&(e.mode=r)}function sp(e){const t=[];for(let i=0;i<e.length;i++){const s=e[i];"subtitles"!==s.kind&&"captions"!==s.kind||!s.label||t.push(e[i])}return t}var rp="org.id3",ap="com.apple.quicktime.HLS",op="https://aomedia.org/emsg/ID3";function np(){if("undefined"!=typeof self)return self.VTTCue||self.TextTrackCue}function lp(e,t,i,s,r){let a=new e(t,i,"");try{a.value=s,r&&(a.type=r)}catch(o){a=new e(t,i,JSON.stringify(r?Bh({type:r},s):s))}return a}const dp=(()=>{const e=np();try{e&&new e(0,Number.POSITIVE_INFINITY,"")}catch(e){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function hp(e,t){return e.getTime()/1e3-t}class cp{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=e,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null}_registerListeners(){const{hls:e}=this;e.on(jh.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(jh.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(jh.MANIFEST_LOADING,this.onManifestLoading,this),e.on(jh.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(jh.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(jh.LEVEL_UPDATED,this.onLevelUpdated,this)}_unregisterListeners(){const{hls:e}=this;e.off(jh.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(jh.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(jh.MANIFEST_LOADING,this.onManifestLoading,this),e.off(jh.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(jh.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(jh.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(e,t){this.media=t.media}onMediaDetaching(){this.id3Track&&(tp(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(e){const t=this.getID3Track(e.textTracks);return t.mode="hidden",t}getID3Track(e){if(this.media){for(let t=0;t<e.length;t++){const i=e[t];if("metadata"===i.kind&&"id3"===i.label)return Zu(i,this.media),i}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(e,t){if(!this.media)return;const{hls:{config:{enableEmsgMetadataCues:i,enableID3MetadataCues:s}}}=this;if(!i&&!s)return;const{samples:r}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));const a=np();if(a)for(let e=0;e<r.length;e++){const t=r[e].type;if(t===op&&!i||!s)continue;const o=Lc(r[e].data);if(o){const i=r[e].pts;let s=i+r[e].duration;s>dp&&(s=dp);s-i<=0&&(s=i+.25);for(let e=0;e<o.length;e++){const r=o[e];if(!xc(r)){this.updateId3CueEnds(i,t);const e=lp(a,i,s,r,t);e&&this.id3Track.addCue(e)}}}}}updateId3CueEnds(e,t){var i;const s=null==(i=this.id3Track)?void 0:i.cues;if(s)for(let i=s.length;i--;){const r=s[i];r.type===t&&r.startTime<e&&r.endTime===dp&&(r.endTime=e)}}onBufferFlushing(e,{startOffset:t,endOffset:i,type:s}){const{id3Track:r,hls:a}=this;if(!a)return;const{config:{enableEmsgMetadataCues:o,enableID3MetadataCues:n}}=a;if(r&&(o||n)){let e;e="audio"===s?e=>e.type===rp&&n:"video"===s?e=>e.type===op&&o:e=>e.type===rp&&n||e.type===op&&o,ip(r,t,i,e)}}onLevelUpdated(e,{details:t}){if(!this.media||!t.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;const{dateRangeCuesAppended:i,id3Track:s}=this,{dateRanges:r}=t,a=Object.keys(r);if(s){const e=Object.keys(i).filter((e=>!a.includes(e)));for(let t=e.length;t--;){const r=e[t];Object.keys(i[r].cues).forEach((e=>{s.removeCue(i[r].cues[e])})),delete i[r]}}const o=t.fragments[t.fragments.length-1];if(0===a.length||!Fh(null==o?void 0:o.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));const n=o.programDateTime/1e3-o.start,l=np();for(let e=0;e<a.length;e++){const t=a[e],s=r[t],o=hp(s.startDate,n),c=i[t],u=(null==c?void 0:c.cues)||{};let p=(null==c?void 0:c.durationKnown)||!1,f=dp;const m=s.endDate;if(m)f=hp(m,n),p=!0;else if(s.endOnNext&&!p){const e=a.reduce(((e,t)=>{if(t!==s.id){const i=r[t];if(i.class===s.class&&i.startDate>s.startDate&&(!e||s.startDate<e.startDate))return i}return e}),null);e&&(f=hp(e.startDate,n),p=!0)}const g=Object.keys(s.attr);for(let e=0;e<g.length;e++){const i=g[e];if("ID"===(h=i)||"CLASS"===h||"START-DATE"===h||"DURATION"===h||"END-DATE"===h||"END-ON-NEXT"===h)continue;const r=u[i];if(r)p&&!c.durationKnown&&(r.endTime=f);else if(l){let e=s.attr[i];Qh(i)&&(d=e,e=Uint8Array.from(d.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer);const r=lp(l,o,f,{key:i,data:e},ap);r&&(r.id=t,this.id3Track.addCue(r),u[i]=r)}}i[t]={cues:u,dateRange:s,durationKnown:p}}var d,h}}class up{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=()=>this.timeupdate(),this.hls=e,this.config=e.config,this.registerListeners()}get latency(){return this._latency||0}get maxLatency(){const{config:e,levelDetails:t}=this;return void 0!==e.liveMaxLatencyDuration?e.liveMaxLatencyDuration:t?e.liveMaxLatencyDurationCount*t.targetduration:0}get targetLatency(){const{levelDetails:e}=this;if(null===e)return null;const{holdBack:t,partHoldBack:i,targetduration:s}=e,{liveSyncDuration:r,liveSyncDurationCount:a,lowLatencyMode:o}=this.config,n=this.hls.userConfig;let l=o&&i||t;(n.liveSyncDuration||n.liveSyncDurationCount||0===l)&&(l=void 0!==r?r:a*s);const d=s;return l+Math.min(1*this.stallCount,d)}get liveSyncPosition(){const e=this.estimateLiveEdge(),t=this.targetLatency,i=this.levelDetails;if(null===e||null===t||null===i)return null;const s=i.edge,r=e-t-this.edgeStalled,a=s-i.totalduration,o=s-(this.config.lowLatencyMode&&i.partTarget||i.targetduration);return Math.min(Math.max(a,r),o)}get drift(){const{levelDetails:e}=this;return null===e?1:e.drift}get edgeStalled(){const{levelDetails:e}=this;if(null===e)return 0;const t=3*(this.config.lowLatencyMode&&e.partTarget||e.targetduration);return Math.max(e.age-t,0)}get forwardBufferLength(){const{media:e,levelDetails:t}=this;if(!e||!t)return 0;const i=e.buffered.length;return(i?e.buffered.end(i-1):t.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null}registerListeners(){this.hls.on(jh.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(jh.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(jh.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(jh.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(jh.ERROR,this.onError,this)}unregisterListeners(){this.hls.off(jh.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(jh.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(jh.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(jh.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(jh.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)}onManifestLoading(){this.levelDetails=null,this._latency=null,this.stallCount=0}onLevelUpdated(e,{details:t}){this.levelDetails=t,t.advanced&&this.timeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)}onError(e,t){var i;t.details===Gh.BUFFER_STALLED_ERROR&&(this.stallCount++,null!=(i=this.levelDetails)&&i.live&&Jh.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))}timeupdate(){const{media:e,levelDetails:t}=this;if(!e||!t)return;this.currentTime=e.currentTime;const i=this.computeLatency();if(null===i)return;this._latency=i;const{lowLatencyMode:s,maxLiveSyncPlaybackRate:r}=this.config;if(!s||1===r||!t.live)return;const a=this.targetLatency;if(null===a)return;const o=i-a;if(o<Math.min(this.maxLatency,a+t.targetduration)&&o>.05&&this.forwardBufferLength>1){const t=Math.min(2,Math.max(1,r)),i=Math.round(2/(1+Math.exp(-.75*o-this.edgeStalled))*20)/20;e.playbackRate=Math.min(t,Math.max(1,i))}else 1!==e.playbackRate&&0!==e.playbackRate&&(e.playbackRate=1)}estimateLiveEdge(){const{levelDetails:e}=this;return null===e?null:e.edge+e.age}computeLatency(){const e=this.estimateLiveEdge();return null===e?null:e-this.currentTime}}const pp=["NONE","TYPE-0","TYPE-1",null];const fp=["SDR","PQ","HLG"];var mp="",gp="YES",yp="v2";class Ap{constructor(e,t,i){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=i}addDirectives(e){const t=new self.URL(e);return void 0!==this.msn&&t.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href}}class bp{constructor(e){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=void 0,this._urlId=0,this.url=[e.url],this._attrs=[e.attrs],this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.frameRate=e.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=e.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.codecSet=[e.videoCodec,e.audioCodec].filter((e=>!!e)).map((e=>e.substring(0,4))).join(","),this.addGroupId("audio",e.attrs.AUDIO),this.addGroupId("text",e.attrs.SUBTITLES)}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get averageBitrate(){return this._avgBitrate||this.realBitrate||this.bitrate}get attrs(){return this._attrs[0]}get codecs(){return this.attrs.CODECS||""}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get videoRange(){return this.attrs["VIDEO-RANGE"]||"SDR"}get score(){return this.attrs.optionalFloat("SCORE",0)}get uri(){return this.url[0]||""}hasAudioGroup(e){return _p(this._audioGroups,e)}hasSubtitleGroup(e){return _p(this._subtitleGroups,e)}get audioGroups(){return this._audioGroups}get subtitleGroups(){return this._subtitleGroups}addGroupId(e,t){if(t)if("audio"===e){let e=this._audioGroups;e||(e=this._audioGroups=[]),-1===e.indexOf(t)&&e.push(t)}else if("text"===e){let e=this._subtitleGroups;e||(e=this._subtitleGroups=[]),-1===e.indexOf(t)&&e.push(t)}}get urlId(){return 0}set urlId(e){}get audioGroupIds(){return this.audioGroups?[this.audioGroupId]:void 0}get textGroupIds(){return this.subtitleGroups?[this.textGroupId]:void 0}get audioGroupId(){var e;return null==(e=this.audioGroups)?void 0:e[0]}get textGroupId(){var e;return null==(e=this.subtitleGroups)?void 0:e[0]}addFallback(){}}function _p(e,t){return!(!t||!e)&&-1!==e.indexOf(t)}function vp(e,t){const i=t.startPTS;if(Fh(i)){let s,r=0;t.sn>e.sn?(r=i-e.start,s=e):(r=e.start-i,s=t),s.duration!==r&&(s.duration=r)}else if(t.sn>e.sn){e.cc===t.cc&&e.minEndPTS?t.start=e.start+(e.minEndPTS-e.start):t.start=e.start+e.duration}else t.start=Math.max(e.start-t.duration,0)}function Sp(e,t,i,s,r,a){s-i<=0&&(Jh.warn("Fragment should have a positive duration",t),s=i+t.duration,a=r+t.duration);let o=i,n=s;const l=t.startPTS,d=t.endPTS;if(Fh(l)){const e=Math.abs(l-i);Fh(t.deltaPTS)?t.deltaPTS=Math.max(e,t.deltaPTS):t.deltaPTS=e,o=Math.max(i,l),i=Math.min(i,l),r=Math.min(r,t.startDTS),n=Math.min(s,d),s=Math.max(s,d),a=Math.max(a,t.endDTS)}const h=i-t.start;0!==t.start&&(t.start=i),t.duration=s-t.start,t.startPTS=i,t.maxStartPTS=o,t.startDTS=r,t.endPTS=s,t.minEndPTS=n,t.endDTS=a;const c=t.sn;if(!e||c<e.startSN||c>e.endSN)return 0;let u;const p=c-e.startSN,f=e.fragments;for(f[p]=t,u=p;u>0;u--)vp(f[u],f[u-1]);for(u=p;u<f.length-1;u++)vp(f[u],f[u+1]);return e.fragmentHint&&vp(f[f.length-1],e.fragmentHint),e.PTSKnown=e.alignedSliding=!0,h}function wp(e,t){let i=null;const s=e.fragments;for(let e=s.length-1;e>=0;e--){const t=s[e].initSegment;if(t){i=t;break}}e.fragmentHint&&delete e.fragmentHint.endPTS;let r,a=0;if(function(e,t,i){const s=t.skippedSegments,r=Math.max(e.startSN,t.startSN)-t.startSN,a=(e.fragmentHint?1:0)+(s?t.endSN:Math.min(e.endSN,t.endSN))-t.startSN,o=t.startSN-e.startSN,n=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,l=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments;for(let e=r;e<=a;e++){const r=l[o+e];let a=n[e];s&&!a&&e<s&&(a=t.fragments[e]=r),r&&a&&i(r,a)}}(e,t,((e,s)=>{e.relurl&&(a=e.cc-s.cc),Fh(e.startPTS)&&Fh(e.endPTS)&&(s.start=s.startPTS=e.startPTS,s.startDTS=e.startDTS,s.maxStartPTS=e.maxStartPTS,s.endPTS=e.endPTS,s.endDTS=e.endDTS,s.minEndPTS=e.minEndPTS,s.duration=e.endPTS-e.startPTS,s.duration&&(r=s),t.PTSKnown=t.alignedSliding=!0),s.elementaryStreams=e.elementaryStreams,s.loader=e.loader,s.stats=e.stats,e.initSegment&&(s.initSegment=e.initSegment,i=e.initSegment)})),i){(t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments).forEach((e=>{var t;!e||e.initSegment&&e.initSegment.relurl!==(null==(t=i)?void 0:t.relurl)||(e.initSegment=i)}))}if(t.skippedSegments)if(t.deltaUpdateFailed=t.fragments.some((e=>!e)),t.deltaUpdateFailed){Jh.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let e=t.skippedSegments;e--;)t.fragments.shift();t.startSN=t.fragments[0].sn,t.startCC=t.fragments[0].cc}else t.canSkipDateRanges&&(t.dateRanges=function(e,t,i){const s=Uh({},e);i&&i.forEach((e=>{delete s[e]}));return Object.keys(t).forEach((e=>{const i=new Xh(t[e].attr,s[e]);i.isValid?s[e]=i:Jh.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(t[e].attr)}"`)})),s}(e.dateRanges,t.dateRanges,t.recentlyRemovedDateranges));const o=t.fragments;if(a){Jh.warn("discontinuity sliding from playlist, take drift into account");for(let e=0;e<o.length;e++)o[e].cc+=a}t.skippedSegments&&(t.startCC=t.fragments[0].cc),function(e,t,i){if(e&&t){let s=0;for(let r=0,a=e.length;r<=a;r++){const a=e[r],o=t[r+s];a&&o&&a.index===o.index&&a.fragment.sn===o.fragment.sn?i(a,o):s--}}}(e.partList,t.partList,((e,t)=>{t.elementaryStreams=e.elementaryStreams,t.stats=e.stats})),r?Sp(t,r,r.startPTS,r.endPTS,r.startDTS,r.endDTS):Ep(e,t),o.length&&(t.totalduration=t.edge-o[0].start),t.driftStartTime=e.driftStartTime,t.driftStart=e.driftStart;const n=t.advancedDateTime;if(t.advanced&&n){const e=t.edge;t.driftStart||(t.driftStartTime=n,t.driftStart=e),t.driftEndTime=n,t.driftEnd=e}else t.driftEndTime=e.driftEndTime,t.driftEnd=e.driftEnd,t.advancedDateTime=e.advancedDateTime}function Ep(e,t){const i=t.startSN+t.skippedSegments-e.startSN,s=e.fragments;i<0||i>=s.length||Tp(t,s[i].start)}function Tp(e,t){if(t){const i=e.fragments;for(let s=e.skippedSegments;s<i.length;s++)i[s].start+=t;e.fragmentHint&&(e.fragmentHint.start+=t)}}function kp(e,t,i){var s;return null!=e&&e.details?Cp(null==(s=e.details)?void 0:s.partList,t,i):null}function Cp(e,t,i){if(e)for(let s=e.length;s--;){const r=e[s];if(r.index===i&&r.fragment.sn===t)return r}return null}function Rp(e){e.forEach(((e,t)=>{const{details:i}=e;null!=i&&i.fragments&&i.fragments.forEach((e=>{e.level=t}))}))}function xp(e){switch(e.details){case Gh.FRAG_LOAD_TIMEOUT:case Gh.KEY_LOAD_TIMEOUT:case Gh.LEVEL_LOAD_TIMEOUT:case Gh.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function Dp(e,t){const i=xp(t);return e.default[(i?"timeout":"error")+"Retry"]}function Lp(e,t){const i="linear"===e.backoff?1:Math.pow(2,t);return Math.min(i*e.retryDelayMs,e.maxRetryDelayMs)}function Pp(e){return Bh(Bh({},e),{errorRetry:null,timeoutRetry:null})}function Bp(e,t,i,s){if(!e)return!1;const r=null==s?void 0:s.code,a=t<e.maxNumRetry&&(function(e){return 0===e&&!1===navigator.onLine||!!e&&(e<400||e>499)}(r)||!!i);return e.shouldRetry?e.shouldRetry(e,t,i,s,a):a}const Ip=function(e,t){let i=0,s=e.length-1,r=null,a=null;for(;i<=s;){r=(i+s)/2|0,a=e[r];const o=t(a);if(o>0)i=r+1;else{if(!(o<0))return a;s=r-1}}return null};function Mp(e,t,i=0,s=0){let r=null;if(e){r=t[e.sn-t[0].sn+1]||null;const s=e.endDTS-i;s>0&&s<15e-7&&(i+=15e-7)}else 0===i&&0===t[0].start&&(r=t[0]);if(r&&(!e||e.level===r.level)&&0===Up(i,s,r))return r;const a=Ip(t,Up.bind(null,i,s));return!a||a===e&&r?r:a}function Up(e=0,t=0,i){if(i.start<=e&&i.start+i.duration>e)return 0;const s=Math.min(t,i.duration+(i.deltaPTS?i.deltaPTS:0));return i.start+i.duration-s<=e?1:i.start-s>e&&i.start?-1:0}function Fp(e,t,i){const s=1e3*Math.min(t,i.duration+(i.deltaPTS?i.deltaPTS:0));return(i.endProgramDateTime||0)-s>e}var Op=0,Np=2,jp=3,zp=5,Gp=0,Hp=1,$p=2;class Vp{constructor(e,t){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=Jh.log.bind(Jh,`${t}:`),this.warn=Jh.warn.bind(Jh,`${t}:`),this.hls=e}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){-1!==this.timer&&(self.clearTimeout(this.timer),this.timer=-1)}startLoad(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(e,t){const i=null==t?void 0:t.renditionReports;if(i){let s=-1;for(let r=0;r<i.length;r++){const a=i[r];let o;try{o=new self.URL(a.URI,t.url).href}catch(e){Jh.warn(`Could not construct new URL for Rendition Report: ${e}`),o=a.URI||""}if(o===e){s=r;break}o===e.substring(0,o.length)&&(s=r)}if(-1!==s){const e=i[s],r=parseInt(e["LAST-MSN"])||(null==t?void 0:t.lastPartSn);let a=parseInt(e["LAST-PART"])||(null==t?void 0:t.lastPartIndex);if(this.hls.config.lowLatencyMode){const e=Math.min(t.age-t.partTarget,t.targetduration);a>=0&&e>t.partTarget&&(a+=1)}return new Ap(r,a>=0?a:void 0,mp)}}}loadPlaylist(e){-1===this.requestScheduled&&(this.requestScheduled=self.performance.now())}shouldLoadPlaylist(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}shouldReloadPlaylist(e){return-1===this.timer&&-1===this.requestScheduled&&this.shouldLoadPlaylist(e)}playlistLoaded(e,t,i){const{details:s,stats:r}=t,a=self.performance.now(),o=r.loading.first?Math.max(0,a-r.loading.first):0;if(s.advancedDateTime=Date.now()-o,s.live||null!=i&&i.live){if(s.reloaded(i),i&&this.log(`live playlist ${e} ${s.advanced?"REFRESHED "+s.lastPartSn+"-"+s.lastPartIndex:s.updated?"UPDATED":"MISSED"}`),i&&s.fragments.length>0&&wp(i,s),!this.canLoad||!s.live)return;let o,n,l;if(s.canBlockReload&&s.endSN&&s.advanced){const e=this.hls.config.lowLatencyMode,r=s.lastPartSn,a=s.endSN,d=s.lastPartIndex,h=r===a;-1!==d?(n=h?a+1:r,l=h?e?0:d:d+1):n=a+1;const c=s.age,u=c+s.ageHeader;let p=Math.min(u-s.partTarget,1.5*s.targetduration);if(p>0){if(i&&p>i.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${i.tuneInGoal} to: ${p} with playlist age: ${s.age}`),p=0;else{const e=Math.floor(p/s.targetduration);if(n+=e,void 0!==l){l+=Math.round(p%s.targetduration/s.partTarget)}this.log(`CDN Tune-in age: ${s.ageHeader}s last advanced ${c.toFixed(2)}s goal: ${p} skip sn ${e} to part ${l}`)}s.tuneInGoal=p}if(o=this.getDeliveryDirectives(s,t.deliveryDirectives,n,l),e||!h)return void this.loadPlaylist(o)}else(s.canBlockReload||s.canSkipUntil)&&(o=this.getDeliveryDirectives(s,t.deliveryDirectives,n,l));const d=this.hls.mainForwardBufferInfo,h=d?d.end-d.len:0,c=function(e,t=1/0){let i=1e3*e.targetduration;if(e.updated){const s=e.fragments,r=4;if(s.length&&i*r>t){const e=1e3*s[s.length-1].duration;e<i&&(i=e)}}else i/=2;return Math.round(i)}(s,1e3*(s.edge-h));s.updated&&a>this.requestScheduled+c&&(this.requestScheduled=r.loading.start),void 0!==n&&s.canBlockReload?this.requestScheduled=r.loading.first+c-(1e3*s.partTarget||1e3):-1===this.requestScheduled||this.requestScheduled+c<a?this.requestScheduled=a:this.requestScheduled-a<=0&&(this.requestScheduled+=c);let u=this.requestScheduled-a;u=Math.max(0,u),this.log(`reload live playlist ${e} in ${Math.round(u)} ms`),this.timer=self.setTimeout((()=>this.loadPlaylist(o)),u)}else this.clearTimer()}getDeliveryDirectives(e,t,i,s){let r=function(e,t){const{canSkipUntil:i,canSkipDateRanges:s,endSN:r}=e;return i&&(void 0!==t?t-r:0)<i?s?yp:gp:mp}(e,i);return null!=t&&t.skip&&e.deltaUpdateFailed&&(i=t.msn,s=t.part,r=mp),new Ap(i,s,r)}checkRetry(e){const t=e.details,i=xp(e),s=e.errorAction,{action:r,retryCount:a=0,retryConfig:o}=s||{},n=!!s&&!!o&&(r===zp||!s.resolved&&r===Np);if(n){var l;if(this.requestScheduled=-1,a>=o.maxNumRetry)return!1;if(i&&null!=(l=e.context)&&l.deliveryDirectives)this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{const e=Lp(o,a);this.timer=self.setTimeout((()=>this.loadPlaylist()),e),this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${t}" in ${e}ms`)}e.levelRetry=!0,s.resolved=!0}return n}}class Wp{constructor(e,t=0,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}sample(e,t){const i=Math.pow(this.alpha_,e);this.estimate_=t*(1-i)+i*this.estimate_,this.totalWeight_+=e}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){const e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}}class Jp{constructor(e,t,i,s=100){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=i,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new Wp(e),this.fast_=new Wp(t),this.defaultTTFB_=s,this.ttfb_=new Wp(e)}update(e,t){const{slow_:i,fast_:s,ttfb_:r}=this;i.halfLife!==e&&(this.slow_=new Wp(e,i.getEstimate(),i.getTotalWeight())),s.halfLife!==t&&(this.fast_=new Wp(t,s.getEstimate(),s.getTotalWeight())),r.halfLife!==e&&(this.ttfb_=new Wp(e,r.getEstimate(),r.getTotalWeight()))}sample(e,t){const i=(e=Math.max(e,this.minDelayMs_))/1e3,s=8*t/i;this.fast_.sample(i,s),this.slow_.sample(i,s)}sampleTTFB(e){const t=e/1e3,i=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(i,Math.max(e,5))}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}destroy(){}}const qp={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]},Kp={};function Yp(e,t,i,s,r,a){const o=e.audioCodec?e.audioGroups:null,n=null==a?void 0:a.audioCodec,l=null==a?void 0:a.channels,d=l?parseInt(l):n?1/0:2;let h=null;if(null!=o&&o.length)try{h=1===o.length&&o[0]?t.groups[o[0]].channels:o.reduce(((e,i)=>{if(i){const s=t.groups[i];if(!s)throw new Error(`Audio track group ${i} not found`);Object.keys(s.channels).forEach((t=>{e[t]=(e[t]||0)+s.channels[t]}))}return e}),{2:0})}catch(e){return!0}return void 0!==e.videoCodec&&(e.width>1920&&e.height>1088||e.height>1920&&e.width>1088||e.frameRate>Math.max(s,30)||"SDR"!==e.videoRange&&e.videoRange!==i||e.bitrate>Math.max(r,8e6))||!!h&&Fh(d)&&Object.keys(h).some((e=>parseInt(e)>d))}function Qp(e,t,i){const s=e.videoCodec,r=e.audioCodec;if(!s||!r||!i)return Promise.resolve(qp);const a={width:e.width,height:e.height,bitrate:Math.ceil(Math.max(.9*e.bitrate,e.averageBitrate)),framerate:e.frameRate||30},o=e.videoRange;"SDR"!==o&&(a.transferFunction=o.toLowerCase());const n=s.split(",").map((e=>({type:"media-source",video:Bh(Bh({},a),{},{contentType:wu(e,"video")})})));return r&&e.audioGroups&&e.audioGroups.forEach((e=>{var i;e&&(null==(i=t.groups[e])||i.tracks.forEach((t=>{if(t.groupId===e){const e=t.channels||"",i=parseFloat(e);Fh(i)&&i>2&&n.push.apply(n,r.split(",").map((e=>({type:"media-source",audio:{contentType:wu(e,"audio"),channels:""+i}}))))}})))})),Promise.all(n.map((e=>{const t=function(e){const{audio:t,video:i}=e,s=i||t;if(s){const e=s.contentType.split('"')[1];if(i)return`r${i.height}x${i.width}f${Math.ceil(i.framerate)}${i.transferFunction||"sd"}_${e}_${Math.ceil(i.bitrate/1e5)}`;if(t)return`c${t.channels}${t.spatialRendering?"s":"n"}_${e}`}return""}(e);return Kp[t]||(Kp[t]=i.decodingInfo(e))}))).then((e=>({supported:!e.some((e=>!e.supported)),configurations:n,decodingInfoResults:e}))).catch((e=>({supported:!1,configurations:n,decodingInfoResults:[],error:e})))}function Xp(e,t){let i=!1,s=[];return e&&(i="SDR"!==e,s=[e]),t&&(s=t.allowedVideoRanges||fp.slice(0),i=void 0!==t.preferHDR?t.preferHDR:function(){if("function"==typeof matchMedia){const e=matchMedia("(dynamic-range: high)"),t=matchMedia("bad query");if(e.media!==t.media)return!0===e.matches}return!1}(),s=i?s.filter((e=>"SDR"!==e)):["SDR"]),{preferHDR:i,allowedVideoRanges:s}}function Zp(e,t){Jh.log(`[abr] start candidates with "${e}" ignored because ${t}`)}function ef(e,t,i){if("attrs"in e){const i=t.indexOf(e);if(-1!==i)return i}for(let s=0;s<t.length;s++){if(tf(e,t[s],i))return s}return-1}function tf(e,t,i){const{groupId:s,name:r,lang:a,assocLang:o,characteristics:n,default:l}=e,d=e.forced;return(void 0===s||t.groupId===s)&&(void 0===r||t.name===r)&&(void 0===a||t.lang===a)&&(void 0===a||t.assocLang===o)&&(void 0===l||t.default===l)&&(void 0===d||t.forced===d)&&(void 0===n||function(e,t=""){const i=e.split(","),s=t.split(",");return i.length===s.length&&!i.some((e=>-1===s.indexOf(e)))}(n,t.characteristics))&&(void 0===i||i(e,t))}function sf(e,t){const{audioCodec:i,channels:s}=e;return!(void 0!==i&&(t.audioCodec||"").substring(0,4)!==i.substring(0,4)||void 0!==s&&s!==(t.channels||"2"))}function rf(e,t,i){for(let s=t;s;s--)if(i(e[s]))return s;for(let s=t+1;s<e.length;s++)if(i(e[s]))return s;return-1}class af{constructor(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed()}onHandlerDestroying(){this.clearNextTick(),this.clearInterval()}onHandlerDestroyed(){}hasInterval(){return!!this._tickInterval}hasNextTick(){return!!this._tickTimer}setInterval(e){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)}clearInterval(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)}clearNextTick(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)}tick(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}}var of="NOT_LOADED",nf="APPENDING",lf="PARTIAL",df="OK";class hf{constructor(e){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=e,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(jh.BUFFER_APPENDED,this.onBufferAppended,this),e.on(jh.FRAG_BUFFERED,this.onFragBuffered,this),e.on(jh.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){const{hls:e}=this;e.off(jh.BUFFER_APPENDED,this.onBufferAppended,this),e.off(jh.FRAG_BUFFERED,this.onFragBuffered,this),e.off(jh.FRAG_LOADED,this.onFragLoaded,this)}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(e,t){const i=this.activePartLists[t];if(i)for(let t=i.length;t--;){const s=i[t];if(!s)break;const r=s.end;if(s.start<=e&&null!==r&&e<=r)return s}return this.getBufferedFrag(e,t)}getBufferedFrag(e,t){const{fragments:i}=this,s=Object.keys(i);for(let r=s.length;r--;){const a=i[s[r]];if((null==a?void 0:a.body.type)===t&&a.buffered){const t=a.body;if(t.start<=e&&e<=t.end)return t}}return null}detectEvictedFragments(e,t,i,s){this.timeRanges&&(this.timeRanges[e]=t);const r=(null==s?void 0:s.fragment.sn)||-1;Object.keys(this.fragments).forEach((s=>{const a=this.fragments[s];if(!a)return;if(r>=a.body.sn)return;if(!a.buffered&&!a.loaded)return void(a.body.type===i&&this.removeFragment(a.body));const o=a.range[e];o&&o.time.some((e=>{const i=!this.isTimeBuffered(e.startPTS,e.endPTS,t);return i&&this.removeFragment(a.body),i}))}))}detectPartialFragments(e){const t=this.timeRanges,{frag:i,part:s}=e;if(!t||"initSegment"===i.sn)return;const r=uf(i),a=this.fragments[r];if(!a||a.buffered&&i.gap)return;const o=!i.relurl;if(Object.keys(t).forEach((e=>{const r=i.elementaryStreams[e];if(!r)return;const n=t[e],l=o||!0===r.partial;a.range[e]=this.getBufferedTimes(i,s,l,n)})),a.loaded=null,Object.keys(a.range).length){a.buffered=!0;(a.body.endList=i.endList||a.body.endList)&&(this.endListFragments[a.body.type]=a),cf(a)||this.removeParts(i.sn-1,i.type)}else this.removeFragment(a.body)}removeParts(e,t){const i=this.activePartLists[t];i&&(this.activePartLists[t]=i.filter((t=>t.fragment.sn>=e)))}fragBuffered(e,t){const i=uf(e);let s=this.fragments[i];!s&&t&&(s=this.fragments[i]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),s&&(s.loaded=null,s.buffered=!0)}getBufferedTimes(e,t,i,s){const r={time:[],partial:i},a=e.start,o=e.end,n=e.minEndPTS||o,l=e.maxStartPTS||a;for(let e=0;e<s.length;e++){const t=s.start(e)-this.bufferPadding,i=s.end(e)+this.bufferPadding;if(l>=t&&n<=i){r.time.push({startPTS:Math.max(a,s.start(e)),endPTS:Math.min(o,s.end(e))});break}if(a<i&&o>t){const t=Math.max(a,s.start(e)),i=Math.min(o,s.end(e));i>t&&(r.partial=!0,r.time.push({startPTS:t,endPTS:i}))}else if(o<=t)break}return r}getPartialFragment(e){let t,i,s,r=null,a=0;const{bufferPadding:o,fragments:n}=this;return Object.keys(n).forEach((l=>{const d=n[l];d&&cf(d)&&(i=d.body.start-o,s=d.body.end+o,e>=i&&e<=s&&(t=Math.min(e-i,s-e),a<=t&&(r=d.body,a=t)))})),r}isEndListAppended(e){const t=this.endListFragments[e];return void 0!==t&&(t.buffered||cf(t))}getState(e){const t=uf(e),i=this.fragments[t];return i?i.buffered?cf(i)?lf:df:nf:of}isTimeBuffered(e,t,i){let s,r;for(let a=0;a<i.length;a++){if(s=i.start(a)-this.bufferPadding,r=i.end(a)+this.bufferPadding,e>=s&&t<=r)return!0;if(t<=s)return!1}return!1}onFragLoaded(e,t){const{frag:i,part:s}=t;if("initSegment"===i.sn||i.bitrateTest)return;const r=s?null:t,a=uf(i);this.fragments[a]={body:i,appendedPTS:null,loaded:r,buffered:!1,range:Object.create(null)}}onBufferAppended(e,t){const{frag:i,part:s,timeRanges:r}=t;if("initSegment"===i.sn)return;const a=i.type;if(s){let e=this.activePartLists[a];e||(this.activePartLists[a]=e=[]),e.push(s)}this.timeRanges=r,Object.keys(r).forEach((e=>{const t=r[e];this.detectEvictedFragments(e,t,a,s)}))}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){const t=uf(e);return!!this.fragments[t]}hasParts(e){var t;return!(null==(t=this.activePartLists[e])||!t.length)}removeFragmentsInRange(e,t,i,s,r){s&&!this.hasGaps||Object.keys(this.fragments).forEach((a=>{const o=this.fragments[a];if(!o)return;const n=o.body;n.type!==i||s&&!n.gap||n.start<t&&n.end>e&&(o.buffered||r)&&this.removeFragment(n)}))}removeFragment(e){const t=uf(e);e.stats.loaded=0,e.clearElementaryStreamInfo();const i=this.activePartLists[e.type];if(i){const t=e.sn;this.activePartLists[e.type]=i.filter((e=>e.fragment.sn!==t))}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}removeAllFragments(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1}}function cf(e){var t,i,s;return e.buffered&&(e.body.gap||(null==(t=e.range.video)?void 0:t.partial)||(null==(i=e.range.audio)?void 0:i.partial)||(null==(s=e.range.audiovideo)?void 0:s.partial))}function uf(e){return`${e.type}_${e.level}_${e.sn}`}const pf={length:0,start:()=>0,end:()=>0};class ff{static isBuffered(e,t){try{if(e){const i=ff.getBuffered(e);for(let e=0;e<i.length;e++)if(t>=i.start(e)&&t<=i.end(e))return!0}}catch(e){}return!1}static bufferInfo(e,t,i){try{if(e){const s=ff.getBuffered(e),r=[];let a;for(a=0;a<s.length;a++)r.push({start:s.start(a),end:s.end(a)});return this.bufferedInfo(r,t,i)}}catch(e){}return{len:0,start:t,end:t,nextStart:void 0}}static bufferedInfo(e,t,i){t=Math.max(0,t),e.sort((function(e,t){const i=e.start-t.start;return i||t.end-e.end}));let s=[];if(i)for(let t=0;t<e.length;t++){const r=s.length;if(r){const a=s[r-1].end;e[t].start-a<i?e[t].end>a&&(s[r-1].end=e[t].end):s.push(e[t])}else s.push(e[t])}else s=e;let r,a=0,o=t,n=t;for(let e=0;e<s.length;e++){const l=s[e].start,d=s[e].end;if(t+i>=l&&t<d)o=l,n=d,a=n-t;else if(t+i<l){r=l;break}}return{len:a,start:o||0,end:n||0,nextStart:r}}static getBuffered(e){try{return e.buffered}catch(e){return Jh.log("failed to get media.buffered",e),pf}}}class mf{constructor(e,t,i,s=0,r=-1,a=!1){this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing={start:0,executeStart:0,executeEnd:0,end:0},this.buffering={audio:{start:0,executeStart:0,executeEnd:0,end:0},video:{start:0,executeStart:0,executeEnd:0,end:0},audiovideo:{start:0,executeStart:0,executeEnd:0,end:0}},this.level=e,this.sn=t,this.id=i,this.size=s,this.part=r,this.partial=a}}function gf(e,t){for(let s=0,r=e.length;s<r;s++){var i;if((null==(i=e[s])?void 0:i.cc)===t)return e[s]}return null}function yf(e,t){if(e){const i=e.start+t;e.start=e.startPTS=i,e.endPTS=i+e.duration}}function Af(e,t){const i=t.fragments;for(let t=0,s=i.length;t<s;t++)yf(i[t],e);t.fragmentHint&&yf(t.fragmentHint,e),t.alignedSliding=!0}function bf(e,t,i){t&&(!function(e,t,i){if(function(e,t,i){return!(!t||!(i.endCC>i.startCC||e&&e.cc<i.startCC))}(e,i,t)){const e=function(e,t){const i=e.fragments,s=t.fragments;if(!s.length||!i.length)return void Jh.log("No fragments to align");const r=gf(i,s[0].cc);if(r&&(!r||r.startPTS))return r;Jh.log("No frag in previous level to align on")}(i,t);e&&Fh(e.start)&&(Jh.log(`Adjusting PTS using last level due to CC increase within current level ${t.url}`),Af(e.start,t))}}(e,i,t),!i.alignedSliding&&t&&_f(i,t),i.alignedSliding||!t||i.skippedSegments||Ep(t,i))}function _f(e,t){if(!e.hasProgramDateTime||!t.hasProgramDateTime)return;const i=e.fragments,s=t.fragments;if(!i.length||!s.length)return;let r,a;const o=Math.min(t.endCC,e.endCC);t.startCC<o&&e.startCC<o&&(r=gf(s,o),a=gf(i,o)),r&&a||(r=s[Math.floor(s.length/2)],a=gf(i,r.cc)||i[Math.floor(i.length/2)]);const n=r.programDateTime,l=a.programDateTime;if(!n||!l)return;Af((l-n)/1e3-(a.start-r.start),e)}const vf=Math.pow(2,17);class Sf{constructor(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(e,t){const i=e.url;if(!i)return Promise.reject(new Tf({type:zh.NETWORK_ERROR,details:Gh.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error("Fragment does not have a "+(i?"part list":"url")),networkDetails:null}));this.abort();const s=this.config,r=s.fLoader,a=s.loader;return new Promise(((o,n)=>{if(this.loader&&this.loader.destroy(),e.gap){if(e.tagList.some((e=>"GAP"===e[0])))return void n(Ef(e));e.gap=!1}const l=this.loader=e.loader=r?new r(s):new a(s),d=wf(e),h=Pp(s.fragLoadPolicy.default),c={loadPolicy:h,timeout:h.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===e.sn?1/0:vf};e.stats=l.stats,l.load(d,c,{onSuccess:(t,i,s,r)=>{this.resetLoader(e,l);let a=t.data;s.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(a.slice(0,16)),a=a.slice(16)),o({frag:e,part:null,payload:a,networkDetails:r})},onError:(t,s,r,a)=>{this.resetLoader(e,l),n(new Tf({type:zh.NETWORK_ERROR,details:Gh.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:Bh({url:i,data:void 0},t),error:new Error(`HTTP Error ${t.code} ${t.text}`),networkDetails:r,stats:a}))},onAbort:(t,i,s)=>{this.resetLoader(e,l),n(new Tf({type:zh.NETWORK_ERROR,details:Gh.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:s,stats:t}))},onTimeout:(t,i,s)=>{this.resetLoader(e,l),n(new Tf({type:zh.NETWORK_ERROR,details:Gh.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${c.timeout}ms`),networkDetails:s,stats:t}))},onProgress:(i,s,r,a)=>{t&&t({frag:e,part:null,payload:r,networkDetails:a})}})}))}loadPart(e,t,i){this.abort();const s=this.config,r=s.fLoader,a=s.loader;return new Promise(((o,n)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap)return void n(Ef(e,t));const l=this.loader=e.loader=r?new r(s):new a(s),d=wf(e,t),h=Pp(s.fragLoadPolicy.default),c={loadPolicy:h,timeout:h.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:vf};t.stats=l.stats,l.load(d,c,{onSuccess:(s,r,a,n)=>{this.resetLoader(e,l),this.updateStatsFromPart(e,t);const d={frag:e,part:t,payload:s.data,networkDetails:n};i(d),o(d)},onError:(i,s,r,a)=>{this.resetLoader(e,l),n(new Tf({type:zh.NETWORK_ERROR,details:Gh.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:Bh({url:d.url,data:void 0},i),error:new Error(`HTTP Error ${i.code} ${i.text}`),networkDetails:r,stats:a}))},onAbort:(i,s,r)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,l),n(new Tf({type:zh.NETWORK_ERROR,details:Gh.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:r,stats:i}))},onTimeout:(i,s,r)=>{this.resetLoader(e,l),n(new Tf({type:zh.NETWORK_ERROR,details:Gh.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error(`Timeout after ${c.timeout}ms`),networkDetails:r,stats:i}))}})}))}updateStatsFromPart(e,t){const i=e.stats,s=t.stats,r=s.total;if(i.loaded+=s.loaded,r){const s=Math.round(e.duration/t.duration),a=Math.min(Math.round(i.loaded/r),s),o=(s-a)*Math.round(i.loaded/a);i.total=i.loaded+o}else i.total=Math.max(i.loaded,i.total);const a=i.loading,o=s.loading;a.start?a.first+=o.first-o.start:(a.start=o.start,a.first=o.first),a.end=o.end}resetLoader(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}}function wf(e,t=null){const i=t||e,s={frag:e,part:t,responseType:"arraybuffer",url:i.url,headers:{},rangeStart:0,rangeEnd:0},r=i.byteRangeStartOffset,a=i.byteRangeEndOffset;if(Fh(r)&&Fh(a)){var o;let t=r,i=a;if("initSegment"===e.sn&&"AES-128"===(null==(o=e.decryptdata)?void 0:o.method)){const e=a-r;e%16&&(i=a+(16-e%16)),0!==r&&(s.resetIV=!0,t=r-16)}s.rangeStart=t,s.rangeEnd=i}return s}function Ef(e,t){const i=new Error(`GAP ${e.gap?"tag":"attribute"} found`),s={type:zh.MEDIA_ERROR,details:Gh.FRAG_GAP,fatal:!1,frag:e,error:i,networkDetails:null};return t&&(s.part=t),(t||e).stats.aborted=!0,new Tf(s)}class Tf extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}}class kf{constructor(e,t){this.subtle=void 0,this.aesIV=void 0,this.subtle=e,this.aesIV=t}decrypt(e,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e)}}class Cf{constructor(e,t){this.subtle=void 0,this.key=void 0,this.subtle=e,this.key=t}expandKey(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])}}class Rf{constructor(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}uint8ArrayToUint32Array_(e){const t=new DataView(e),i=new Uint32Array(4);for(let e=0;e<4;e++)i[e]=t.getUint32(4*e);return i}initTable(){const e=this.sBox,t=this.invSBox,i=this.subMix,s=i[0],r=i[1],a=i[2],o=i[3],n=this.invSubMix,l=n[0],d=n[1],h=n[2],c=n[3],u=new Uint32Array(256);let p=0,f=0,m=0;for(m=0;m<256;m++)u[m]=m<128?m<<1:m<<1^283;for(m=0;m<256;m++){let i=f^f<<1^f<<2^f<<3^f<<4;i=i>>>8^255&i^99,e[p]=i,t[i]=p;const n=u[p],m=u[n],g=u[m];let y=257*u[i]^16843008*i;s[p]=y<<24|y>>>8,r[p]=y<<16|y>>>16,a[p]=y<<8|y>>>24,o[p]=y,y=16843009*g^65537*m^257*n^16843008*p,l[i]=y<<24|y>>>8,d[i]=y<<16|y>>>16,h[i]=y<<8|y>>>24,c[i]=y,p?(p=n^u[u[u[g^n]]],f^=u[u[f]]):p=f=1}}expandKey(e){const t=this.uint8ArrayToUint32Array_(e);let i=!0,s=0;for(;s<t.length&&i;)i=t[s]===this.key[s],s++;if(i)return;this.key=t;const r=this.keySize=t.length;if(4!==r&&6!==r&&8!==r)throw new Error("Invalid aes key size="+r);const a=this.ksRows=4*(r+6+1);let o,n;const l=this.keySchedule=new Uint32Array(a),d=this.invKeySchedule=new Uint32Array(a),h=this.sBox,c=this.rcon,u=this.invSubMix,p=u[0],f=u[1],m=u[2],g=u[3];let y,A;for(o=0;o<a;o++)o<r?y=l[o]=t[o]:(A=y,o%r==0?(A=A<<8|A>>>24,A=h[A>>>24]<<24|h[A>>>16&255]<<16|h[A>>>8&255]<<8|h[255&A],A^=c[o/r|0]<<24):r>6&&o%r==4&&(A=h[A>>>24]<<24|h[A>>>16&255]<<16|h[A>>>8&255]<<8|h[255&A]),l[o]=y=(l[o-r]^A)>>>0);for(n=0;n<a;n++)o=a-n,A=3&n?l[o]:l[o-4],d[n]=n<4||o<=4?A:p[h[A>>>24]]^f[h[A>>>16&255]]^m[h[A>>>8&255]]^g[h[255&A]],d[n]=d[n]>>>0}networkToHostOrderSwap(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24}decrypt(e,t,i){const s=this.keySize+6,r=this.invKeySchedule,a=this.invSBox,o=this.invSubMix,n=o[0],l=o[1],d=o[2],h=o[3],c=this.uint8ArrayToUint32Array_(i);let u=c[0],p=c[1],f=c[2],m=c[3];const g=new Int32Array(e),y=new Int32Array(g.length);let A,b,_,v,S,w,E,T,k,C,R,x,D,L;const P=this.networkToHostOrderSwap;for(;t<g.length;){for(k=P(g[t]),C=P(g[t+1]),R=P(g[t+2]),x=P(g[t+3]),S=k^r[0],w=x^r[1],E=R^r[2],T=C^r[3],D=4,L=1;L<s;L++)A=n[S>>>24]^l[w>>16&255]^d[E>>8&255]^h[255&T]^r[D],b=n[w>>>24]^l[E>>16&255]^d[T>>8&255]^h[255&S]^r[D+1],_=n[E>>>24]^l[T>>16&255]^d[S>>8&255]^h[255&w]^r[D+2],v=n[T>>>24]^l[S>>16&255]^d[w>>8&255]^h[255&E]^r[D+3],S=A,w=b,E=_,T=v,D+=4;A=a[S>>>24]<<24^a[w>>16&255]<<16^a[E>>8&255]<<8^a[255&T]^r[D],b=a[w>>>24]<<24^a[E>>16&255]<<16^a[T>>8&255]<<8^a[255&S]^r[D+1],_=a[E>>>24]<<24^a[T>>16&255]<<16^a[S>>8&255]<<8^a[255&w]^r[D+2],v=a[T>>>24]<<24^a[S>>16&255]<<16^a[w>>8&255]<<8^a[255&E]^r[D+3],y[t]=P(A^u),y[t+1]=P(v^p),y[t+2]=P(_^f),y[t+3]=P(b^m),u=k,p=C,f=R,m=x,t+=4}return y.buffer}}class xf{constructor(e,{removePKCS7Padding:t=!0}={}){if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.useSoftware=e.enableSoftwareAES,this.removePKCS7Padding=t,t)try{const e=self.crypto;e&&(this.subtle=e.subtle||e.webkitSubtle)}catch(e){}null===this.subtle&&(this.useSoftware=!0)}destroy(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}isSync(){return this.useSoftware}flush(){const{currentResult:e,remainderData:t}=this;if(!e||t)return this.reset(),null;const i=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?function(e){const t=e.byteLength,i=t&&new DataView(e.buffer).getUint8(t-1);return i?Sc(e,0,t-i):e}(i):i}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(e,t,i){return this.useSoftware?new Promise(((s,r)=>{this.softwareDecrypt(new Uint8Array(e),t,i);const a=this.flush();a?s(a.buffer):r(new Error("[softwareDecrypt] Failed to decrypt data"))})):this.webCryptoDecrypt(new Uint8Array(e),t,i)}softwareDecrypt(e,t,i){const{currentIV:s,currentResult:r,remainderData:a}=this;this.logOnce("JS AES decrypt"),a&&(e=au(a,e),this.remainderData=null);const o=this.getValidChunk(e);if(!o.length)return null;s&&(i=s);let n=this.softwareDecrypter;n||(n=this.softwareDecrypter=new Rf),n.expandKey(t);const l=r;return this.currentResult=n.decrypt(o.buffer,0,i),this.currentIV=Sc(o,-16).buffer,l||null}webCryptoDecrypt(e,t,i){const s=this.subtle;return this.key===t&&this.fastAesKey||(this.key=t,this.fastAesKey=new Cf(s,t)),this.fastAesKey.expandKey().then((t=>{if(!s)return Promise.reject(new Error("web crypto not initialized"));this.logOnce("WebCrypto AES decrypt");return new kf(s,new Uint8Array(i)).decrypt(e.buffer,t)})).catch((s=>(Jh.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${s.name}: ${s.message}`),this.onWebCryptoError(e,t,i))))}onWebCryptoError(e,t,i){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,i);const s=this.flush();if(s)return s.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(e){let t=e;const i=e.length-e.length%16;return i!==e.length&&(t=Sc(e,0,i),this.remainderData=Sc(e,i)),t}logOnce(e){this.logEnabled&&(Jh.log(`[decrypter]: ${e}`),this.logEnabled=!1)}}const Df=function(e){let t="";const i=e.length;for(let s=0;s<i;s++)t+=`[${e.start(s).toFixed(3)}-${e.end(s).toFixed(3)}]`;return t},Lf="STOPPED",Pf="IDLE",Bf="KEY_LOADING",If="FRAG_LOADING",Mf="FRAG_LOADING_WAITING_RETRY",Uf="WAITING_TRACK",Ff="PARSING",Of="PARSED",Nf="ENDED",jf="ERROR",zf="WAITING_INIT_PTS",Gf="WAITING_LEVEL";class Hf extends af{constructor(e,t,i,s,r){super(),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=Lf,this.playlistType=void 0,this.media=null,this.mediaBuffer=null,this.config=void 0,this.bitrateTest=!1,this.lastCurrentTime=0,this.nextLoadPosition=0,this.startPosition=0,this.startTimeOffset=null,this.loadedmetadata=!1,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.keyLoader=void 0,this.levelLastLoaded=null,this.startFragRequested=!1,this.decrypter=void 0,this.initPTS=[],this.onvseeking=null,this.onvended=null,this.logPrefix="",this.log=void 0,this.warn=void 0,this.playlistType=r,this.logPrefix=s,this.log=Jh.log.bind(Jh,`${s}:`),this.warn=Jh.warn.bind(Jh,`${s}:`),this.hls=e,this.fragmentLoader=new Sf(e.config),this.keyLoader=i,this.fragmentTracker=t,this.config=e.config,this.decrypter=new xf(e.config),e.on(jh.MANIFEST_LOADED,this.onManifestLoaded,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);const e=this.fragCurrent;null!=e&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=Lf}_streamEnded(e,t){if(t.live||e.nextStart||!e.end||!this.media)return!1;const i=t.partList;if(null!=i&&i.length){const e=i[i.length-1];return ff.isBuffered(this.media,e.start+e.duration/2)}const s=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(s)}getLevelDetails(){var e;if(this.levels&&null!==this.levelLastLoaded)return null==(e=this.levelLastLoaded)?void 0:e.details}onMediaAttached(e,t){const i=this.media=this.mediaBuffer=t.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),i.addEventListener("seeking",this.onvseeking),i.addEventListener("ended",this.onvended);const s=this.config;this.levels&&s.autoStartLoad&&this.state===Lf&&this.startLoad(s.startPosition)}onMediaDetaching(){const e=this.media;null!=e&&e.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),e&&this.onvseeking&&this.onvended&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}onMediaSeeking(){const{config:e,fragCurrent:t,media:i,mediaBuffer:s,state:r}=this,a=i?i.currentTime:0,o=ff.bufferInfo(s||i,a,e.maxBufferHole);if(this.log(`media seeking to ${Fh(a)?a.toFixed(3):a}, state: ${r}`),this.state===Nf)this.resetLoadingState();else if(t){const i=e.maxFragLookUpTolerance,s=t.start-i,r=t.start+t.duration+i;if(!o.len||r<o.start||s>o.end){const e=a>r;(a<s||e)&&(e&&t.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),t.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}i&&(this.fragmentTracker.removeFragmentsInRange(a,1/0,this.playlistType,!0),this.lastCurrentTime=a),this.loadedmetadata||o.len||(this.nextLoadPosition=this.startPosition=a),this.tickImmediate()}onMediaEnded(){this.startPosition=this.lastCurrentTime=0}onManifestLoaded(e,t){this.startTimeOffset=t.startTimeOffset,this.initPTS=[]}onHandlerDestroying(){this.hls.off(jh.MANIFEST_LOADED,this.onManifestLoaded,this),this.stopLoad(),super.onHandlerDestroying(),this.hls=null}onHandlerDestroyed(){this.state=Lf,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,super.onHandlerDestroyed()}loadFragment(e,t,i){this._loadFragForPlayback(e,t,i)}_loadFragForPlayback(e,t,i){this._doFragLoad(e,t,i,(t=>{if(this.fragContextChanged(e))return this.warn(`Fragment ${e.sn}${t.part?" p: "+t.part.index:""} of level ${e.level} was dropped during download.`),void this.fragmentTracker.removeFragment(e);e.stats.chunkCount++,this._handleFragmentLoadProgress(t)})).then((t=>{if(!t)return;const i=this.state;this.fragContextChanged(e)?(i===If||!this.fragCurrent&&i===Ff)&&(this.fragmentTracker.removeFragment(e),this.state=Pf):("payload"in t&&(this.log(`Loaded fragment ${e.sn} of level ${e.level}`),this.hls.trigger(jh.FRAG_LOADED,t)),this._handleFragmentLoadComplete(t))})).catch((t=>{this.state!==Lf&&this.state!==jf&&(this.warn(t),this.resetFragmentLoading(e))}))}clearTrackerIfNeeded(e){var t;const{fragmentTracker:i}=this;if(i.getState(e)===nf){const t=e.type,s=this.getFwdBufferInfo(this.mediaBuffer,t),r=Math.max(e.duration,s?s.len:this.config.maxBufferLength);this.reduceMaxBufferLength(r)&&i.removeFragment(e)}else 0===(null==(t=this.mediaBuffer)?void 0:t.buffered.length)?i.removeAllFragments():i.hasParts(e.type)&&(i.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),i.getState(e)===lf&&i.removeFragment(e))}checkLiveUpdate(e){if(e.updated&&!e.live){const t=e.fragments[e.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type})}e.fragments[0]||(e.deltaUpdateFailed=!0)}flushMainBuffer(e,t,i=null){if(!(e-t))return;const s={startOffset:e,endOffset:t,type:i};this.hls.trigger(jh.BUFFER_FLUSHING,s)}_loadInitSegment(e,t){this._doFragLoad(e,t).then((t=>{if(!t||this.fragContextChanged(e)||!this.levels)throw new Error("init load aborted");return t})).then((t=>{const{hls:i}=this,{payload:s}=t,r=e.decryptdata;if(s&&s.byteLength>0&&null!=r&&r.key&&r.iv&&"AES-128"===r.method){const a=self.performance.now();return this.decrypter.decrypt(new Uint8Array(s),r.key.buffer,r.iv.buffer).catch((t=>{throw i.trigger(jh.ERROR,{type:zh.MEDIA_ERROR,details:Gh.FRAG_DECRYPT_ERROR,fatal:!1,error:t,reason:t.message,frag:e}),t})).then((s=>{const r=self.performance.now();return i.trigger(jh.FRAG_DECRYPTED,{frag:e,payload:s,stats:{tstart:a,tdecrypt:r}}),t.payload=s,this.completeInitSegmentLoad(t)}))}return this.completeInitSegmentLoad(t)})).catch((t=>{this.state!==Lf&&this.state!==jf&&(this.warn(t),this.resetFragmentLoading(e))}))}completeInitSegmentLoad(e){const{levels:t}=this;if(!t)throw new Error("init load aborted, missing levels");const i=e.frag.stats;this.state=Pf,e.frag.data=new Uint8Array(e.payload),i.parsing.start=i.buffering.start=self.performance.now(),i.parsing.end=i.buffering.end=self.performance.now(),this.tick()}fragContextChanged(e){const{fragCurrent:t}=this;return!e||!t||e.sn!==t.sn||e.level!==t.level}fragBufferedComplete(e,t){var i,s,r,a;const o=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log(`Buffered ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.playlistType===Ju?"level":"track"} ${e.level} (frag:[${(null!=(i=e.startPTS)?i:NaN).toFixed(3)}-${(null!=(s=e.endPTS)?s:NaN).toFixed(3)}] > buffer:${o?Df(ff.getBuffered(o)):"(detached)"})`),"initSegment"!==e.sn){var n;if(e.type!==Ku){const t=e.elementaryStreams;if(!Object.keys(t).some((e=>!!t[e])))return void(this.state=Pf)}const t=null==(n=this.levels)?void 0:n[e.level];null!=t&&t.fragmentError&&(this.log(`Resetting level fragment error count of ${t.fragmentError} on frag buffered`),t.fragmentError=0)}this.state=Pf,o&&(!this.loadedmetadata&&e.type==Ju&&o.buffered.length&&(null==(r=this.fragCurrent)?void 0:r.sn)===(null==(a=this.fragPrevious)?void 0:a.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())}seekToStartPos(){}_handleFragmentLoadComplete(e){const{transmuxer:t}=this;if(!t)return;const{frag:i,part:s,partsLoaded:r}=e,a=!r||0===r.length||r.some((e=>!e)),o=new mf(i.level,i.sn,i.stats.chunkCount+1,0,s?s.index:-1,!a);t.flush(o)}_handleFragmentLoadProgress(e){}_doFragLoad(e,t,i=null,s){var r;const a=null==t?void 0:t.details;if(!this.levels||!a)throw new Error(`frag load aborted, missing level${a?"":" detail"}s`);let o=null;if(!e.encrypted||null!=(r=e.decryptdata)&&r.key?!e.encrypted&&a.encryptedFragments.length&&this.keyLoader.loadClear(e,a.encryptedFragments):(this.log(`Loading key for ${e.sn} of [${a.startSN}-${a.endSN}], ${"[stream-controller]"===this.logPrefix?"level":"track"} ${e.level}`),this.state=Bf,this.fragCurrent=e,o=this.keyLoader.load(e).then((e=>{if(!this.fragContextChanged(e.frag))return this.hls.trigger(jh.KEY_LOADED,e),this.state===Bf&&(this.state=Pf),e})),this.hls.trigger(jh.KEY_LOADING,{frag:e}),null===this.fragCurrent&&(o=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))),i=Math.max(e.start,i||0),this.config.lowLatencyMode&&"initSegment"!==e.sn){const r=a.partList;if(r&&s){i>e.end&&a.fragmentHint&&(e=a.fragmentHint);const n=this.getNextPart(r,e,i);if(n>-1){const l=r[n];let d;return this.log(`Loading part sn: ${e.sn} p: ${l.index} cc: ${e.cc} of playlist [${a.startSN}-${a.endSN}] parts [0-${n}-${r.length-1}] ${"[stream-controller]"===this.logPrefix?"level":"track"}: ${e.level}, target: ${parseFloat(i.toFixed(3))}`),this.nextLoadPosition=l.start+l.duration,this.state=If,d=o?o.then((i=>!i||this.fragContextChanged(i.frag)?null:this.doFragPartsLoad(e,l,t,s))).catch((e=>this.handleFragLoadError(e))):this.doFragPartsLoad(e,l,t,s).catch((e=>this.handleFragLoadError(e))),this.hls.trigger(jh.FRAG_LOADING,{frag:e,part:l,targetBufferTime:i}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):d}if(!e.url||this.loadedEndOfParts(r,i))return Promise.resolve(null)}}this.log(`Loading fragment ${e.sn} cc: ${e.cc} ${a?"of ["+a.startSN+"-"+a.endSN+"] ":""}${"[stream-controller]"===this.logPrefix?"level":"track"}: ${e.level}, target: ${parseFloat(i.toFixed(3))}`),Fh(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=If;const n=this.config.progressive;let l;return l=n&&o?o.then((t=>!t||this.fragContextChanged(null==t?void 0:t.frag)?null:this.fragmentLoader.load(e,s))).catch((e=>this.handleFragLoadError(e))):Promise.all([this.fragmentLoader.load(e,n?s:void 0),o]).then((([e])=>(!n&&e&&s&&s(e),e))).catch((e=>this.handleFragLoadError(e))),this.hls.trigger(jh.FRAG_LOADING,{frag:e,targetBufferTime:i}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):l}doFragPartsLoad(e,t,i,s){return new Promise(((r,a)=>{var o;const n=[],l=null==(o=i.details)?void 0:o.partList,d=t=>{this.fragmentLoader.loadPart(e,t,s).then((s=>{n[t.index]=s;const a=s.part;this.hls.trigger(jh.FRAG_LOADED,s);const o=kp(i,e.sn,t.index+1)||Cp(l,e.sn,t.index+1);if(!o)return r({frag:e,part:a,partsLoaded:n});d(o)})).catch(a)};d(t)}))}handleFragLoadError(e){if("data"in e){const t=e.data;e.data&&t.details===Gh.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(jh.ERROR,t)}else this.hls.trigger(jh.ERROR,{type:zh.OTHER_ERROR,details:Gh.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){const t=this.getCurrentContext(e);if(!t||this.state!==Ff)return void(this.fragCurrent||this.state===Lf||this.state===jf||(this.state=Pf));const{frag:i,part:s,level:r}=t,a=self.performance.now();i.stats.parsing.end=a,s&&(s.stats.parsing.end=a),this.updateLevelTiming(i,s,r,e.partial)}getCurrentContext(e){const{levels:t,fragCurrent:i}=this,{level:s,sn:r,part:a}=e;if(null==t||!t[s])return this.warn(`Levels object was unset while buffering fragment ${r} of level ${s}. The current chunk will not be buffered.`),null;const o=t[s],n=a>-1?kp(o,r,a):null,l=n?n.fragment:function(e,t,i){if(null==e||!e.details)return null;const s=e.details;let r=s.fragments[t-s.startSN];return r||(r=s.fragmentHint,r&&r.sn===t?r:t<s.startSN&&i&&i.sn===t?i:null)}(o,r,i);return l?(i&&i!==l&&(l.stats=i.stats),{frag:l,part:n,level:o}):null}bufferFragmentData(e,t,i,s,r){var a;if(!e||this.state!==Ff)return;const{data1:o,data2:n}=e;let l=o;if(o&&n&&(l=au(o,n)),null==(a=l)||!a.length)return;const d={type:e.type,frag:t,part:i,chunkMeta:s,parent:t.type,data:l};if(this.hls.trigger(jh.BUFFER_APPENDING,d),e.dropped&&e.independent&&!i){if(r)return;this.flushBufferGap(t)}}flushBufferGap(e){const t=this.media;if(!t)return;if(!ff.isBuffered(t,t.currentTime))return void this.flushMainBuffer(0,e.start);const i=t.currentTime,s=ff.bufferInfo(t,i,0),r=e.duration,a=Math.min(2*this.config.maxFragLookUpTolerance,.25*r),o=Math.max(Math.min(e.start-a,s.end-a),i+a);e.start-o>a&&this.flushMainBuffer(o,e.start)}getFwdBufferInfo(e,t){const i=this.getLoadPosition();return Fh(i)?this.getFwdBufferInfoAtPos(e,i,t):null}getFwdBufferInfoAtPos(e,t,i){const{config:{maxBufferHole:s}}=this,r=ff.bufferInfo(e,t,s);if(0===r.len&&void 0!==r.nextStart){const a=this.fragmentTracker.getBufferedFrag(t,i);if(a&&r.nextStart<a.end)return ff.bufferInfo(e,t,Math.max(r.nextStart,s))}return r}getMaxBufferLength(e){const{config:t}=this;let i;return i=e?Math.max(8*t.maxBufferSize/e,t.maxBufferLength):t.maxBufferLength,Math.min(i,t.maxMaxBufferLength)}reduceMaxBufferLength(e){const t=this.config,i=e||t.maxBufferLength;return t.maxMaxBufferLength>=i&&(t.maxMaxBufferLength/=2,this.warn(`Reduce max buffer length to ${t.maxMaxBufferLength}s`),!0)}getAppendedFrag(e,t=Ju){const i=this.fragmentTracker.getAppendedFrag(e,Ju);return i&&"fragment"in i?i.fragment:i}getNextFragment(e,t){const i=t.fragments,s=i.length;if(!s)return null;const{config:r}=this,a=i[0].start;let o;if(t.live){const n=r.initialLiveManifestSize;if(s<n)return this.warn(`Not enough fragments to start playback (have: ${s}, need: ${n})`),null;(!t.PTSKnown&&!this.startFragRequested&&-1===this.startPosition||e<a)&&(o=this.getInitialLiveFragment(t,i),this.startPosition=this.nextLoadPosition=o?this.hls.liveSyncPosition||o.start:e)}else e<=a&&(o=i[0]);if(!o){const i=r.lowLatencyMode?t.partEnd:t.fragmentEnd;o=this.getFragmentAtPosition(e,i,t)}return this.mapToInitFragWhenRequired(o)}isLoopLoading(e,t){const i=this.fragmentTracker.getState(e);return(i===df||i===lf&&!!e.gap)&&this.nextLoadPosition>t}getNextFragmentLoopLoading(e,t,i,s,r){const a=e.gap,o=this.getNextFragment(this.nextLoadPosition,t);if(null===o)return o;if(e=o,a&&e&&!e.gap&&i.nextStart){const t=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,i.nextStart,s);if(null!==t&&i.len+t.len>=r)return this.log(`buffer full after gaps in "${s}" playlist starting at sn: ${e.sn}`),null}return e}mapToInitFragWhenRequired(e){return null==e||!e.initSegment||null!=e&&e.initSegment.data||this.bitrateTest?e:e.initSegment}getNextPart(e,t,i){let s=-1,r=!1,a=!0;for(let o=0,n=e.length;o<n;o++){const n=e[o];if(a=a&&!n.independent,s>-1&&i<n.start)break;const l=n.loaded;l?s=-1:(r||n.independent||a)&&n.fragment===t&&(s=o),r=l}return s}loadedEndOfParts(e,t){const i=e[e.length-1];return i&&t>i.start&&i.loaded}getInitialLiveFragment(e,t){const i=this.fragPrevious;let s=null;if(i){if(e.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${i.programDateTime}`),s=function(e,t,i){if(null===t||!Array.isArray(e)||!e.length||!Fh(t))return null;if(t<(e[0].programDateTime||0))return null;if(t>=(e[e.length-1].endProgramDateTime||0))return null;i=i||0;for(let s=0;s<e.length;++s){const r=e[s];if(Fp(t,i,r))return r}return null}(t,i.endProgramDateTime,this.config.maxFragLookUpTolerance)),!s){const r=i.sn+1;if(r>=e.startSN&&r<=e.endSN){const a=t[r-e.startSN];i.cc===a.cc&&(s=a,this.log(`Live playlist, switching playlist, load frag with next SN: ${s.sn}`))}s||(s=function(e,t){return Ip(e,(e=>e.cc<t?1:e.cc>t?-1:0))}(t,i.cc),s&&this.log(`Live playlist, switching playlist, load frag with same CC: ${s.sn}`))}}else{const t=this.hls.liveSyncPosition;null!==t&&(s=this.getFragmentAtPosition(t,this.bitrateTest?e.fragmentEnd:e.edge,e))}return s}getFragmentAtPosition(e,t,i){const{config:s}=this;let{fragPrevious:r}=this,{fragments:a,endSN:o}=i;const{fragmentHint:n}=i,l=s.maxFragLookUpTolerance,d=i.partList,h=!!(s.lowLatencyMode&&null!=d&&d.length&&n);let c;if(h&&n&&!this.bitrateTest&&(a=a.concat(n),o=n.sn),e<t){c=Mp(r,a,e,e>t-l?0:l)}else c=a[a.length-1];if(c){const e=c.sn-i.startSN,t=this.fragmentTracker.getState(c);if((t===df||t===lf&&c.gap)&&(r=c),r&&c.sn===r.sn&&(!h||d[0].fragment.sn>c.sn)){if(r&&c.level===r.level){const t=a[e+1];c=c.sn<o&&this.fragmentTracker.getState(t)!==df?t:null}}}return c}synchronizeToLiveEdge(e){const{config:t,media:i}=this;if(!i)return;const s=this.hls.liveSyncPosition,r=i.currentTime,a=e.fragments[0].start,o=e.edge,n=r>=a-t.maxFragLookUpTolerance&&r<=o;if(null!==s&&i.duration>s&&(r<s||!n)){const a=void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;(!n&&i.readyState<4||r<o-a)&&(this.loadedmetadata||(this.nextLoadPosition=s),i.readyState&&(this.warn(`Playback: ${r.toFixed(3)} is located too far from the end of live sliding playlist: ${o}, reset currentTime to : ${s.toFixed(3)}`),i.currentTime=s))}}alignPlaylists(e,t,i){const s=e.fragments.length;if(!s)return this.warn("No fragments in live playlist"),0;const r=e.fragments[0].start,a=!t,o=e.alignedSliding&&Fh(r);if(a||!o&&!r){const{fragPrevious:r}=this;bf(r,i,e);const a=e.fragments[0].start;return this.log(`Live playlist sliding: ${a.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${e.startSN} prev-sn: ${r?r.sn:"na"} fragments: ${s}`),a}return r}waitForCdnTuneIn(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,3*e.partTarget)}setStartPosition(e,t){let i=this.startPosition;if(i<t&&(i=-1),-1===i||-1===this.lastCurrentTime){const s=null!==this.startTimeOffset,r=s?this.startTimeOffset:e.startTimeOffset;null!==r&&Fh(r)?(i=t+r,r<0&&(i+=e.totalduration),i=Math.min(Math.max(t,i),t+e.totalduration),this.log(`Start time offset ${r} found in ${s?"multivariant":"media"} playlist, adjust startPosition to ${i}`),this.startPosition=i):e.live?i=this.hls.liveSyncPosition||t:this.startPosition=i=0,this.lastCurrentTime=i}this.nextLoadPosition=i}getLoadPosition(){const{media:e}=this;let t=0;return this.loadedmetadata&&e?t=e.currentTime:this.nextLoadPosition&&(t=this.nextLoadPosition),t}handleFragLoadAborted(e,t){this.transmuxer&&"initSegment"!==e.sn&&e.stats.aborted&&(this.warn(`Fragment ${e.sn}${t?" part "+t.index:""} of level ${e.level} was aborted`),this.resetFragmentLoading(e))}resetFragmentLoading(e){this.fragCurrent&&(this.fragContextChanged(e)||this.state===Mf)||(this.state=Pf)}onFragmentOrKeyLoadError(e,t){if(t.chunkMeta&&!t.frag){const e=this.getCurrentContext(t.chunkMeta);e&&(t.frag=e.frag)}const i=t.frag;if(!i||i.type!==e||!this.levels)return;var s;if(this.fragContextChanged(i))return void this.warn(`Frag load error must match current frag to retry ${i.url} > ${null==(s=this.fragCurrent)?void 0:s.url}`);const r=t.details===Gh.FRAG_GAP;r&&this.fragmentTracker.fragBuffered(i,!0);const a=t.errorAction,{action:o,retryCount:n=0,retryConfig:l}=a||{};if(a&&o===zp&&l){this.resetStartWhenNotLoaded(this.levelLastLoaded);const s=Lp(l,n);this.warn(`Fragment ${i.sn} of ${e} ${i.level} errored with ${t.details}, retrying loading ${n+1}/${l.maxNumRetry} in ${s}ms`),a.resolved=!0,this.retryDate=self.performance.now()+s,this.state=Mf}else if(l&&a){if(this.resetFragmentErrors(e),!(n<l.maxNumRetry))return void Jh.warn(`${t.details} reached or exceeded max retry (${n})`);r||o===jp||(a.resolved=!0)}else(null==a?void 0:a.action)===Np?this.state=Gf:this.state=jf;this.tickImmediate()}reduceLengthAndFlushBuffer(e){if(this.state===Ff||this.state===Of){const t=e.parent,i=this.getFwdBufferInfo(this.mediaBuffer,t),s=i&&i.len>.5;s&&this.reduceMaxBufferLength(i.len);const r=!s;return r&&this.warn(`Buffer full error while media.currentTime is not buffered, flush ${t} buffer`),e.frag&&(this.fragmentTracker.removeFragment(e.frag),this.nextLoadPosition=e.frag.start),this.resetLoadingState(),r}return!1}resetFragmentErrors(e){e===qu&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==Lf&&(this.state=Pf)}afterBufferFlushed(e,t,i){if(!e)return;const s=ff.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,s,i),this.state===Nf&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=Pf}resetStartWhenNotLoaded(e){if(!this.loadedmetadata){this.startFragRequested=!1;const t=e?e.details:null;null!=t&&t.live?(this.startPosition=-1,this.setStartPosition(t,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(e){this.warn(`The loading context changed while buffering fragment ${e.sn} of level ${e.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState()}removeUnbufferedFrags(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}updateLevelTiming(e,t,i,s){var r;const a=i.details;if(!a)return void this.warn("level.details undefined");if(!Object.keys(e.elementaryStreams).reduce(((t,r)=>{const o=e.elementaryStreams[r];if(o){const n=o.endPTS-o.startPTS;if(n<=0)return this.warn(`Could not parse fragment ${e.sn} ${r} duration reliably (${n})`),t||!1;const l=s?0:Sp(a,e,o.startPTS,o.endPTS,o.startDTS,o.endDTS);return this.hls.trigger(jh.LEVEL_PTS_UPDATED,{details:a,level:i,drift:l,type:r,frag:e,start:o.startPTS,end:o.endPTS}),!0}return t}),!1)&&null===(null==(r=this.transmuxer)?void 0:r.error)){const t=new Error(`Found no media in fragment ${e.sn} of level ${e.level} resetting transmuxer to fallback to playlist timing`);if(0===i.fragmentError&&(i.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)),this.warn(t.message),this.hls.trigger(jh.ERROR,{type:zh.MEDIA_ERROR,details:Gh.FRAG_PARSING_ERROR,fatal:!1,error:t,frag:e,reason:`Found no media in msn ${e.sn} of level "${i.url}"`}),!this.hls)return;this.resetTransmuxer()}this.state=Of,this.hls.trigger(jh.FRAG_PARSED,{frag:e,part:t})}resetTransmuxer(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)}recoverWorkerError(e){"demuxerWorker"===e.event&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState())}set state(e){const t=this._state;t!==e&&(this._state=e,this.log(`${t}->${e}`))}get state(){return this._state}}class $f{constructor(){this.chunks=[],this.dataLength=0}push(e){this.chunks.push(e),this.dataLength+=e.length}flush(){const{chunks:e,dataLength:t}=this;let i;return e.length?(i=1===e.length?e[0]:function(e,t){const i=new Uint8Array(t);let s=0;for(let t=0;t<e.length;t++){const r=e[t];i.set(r,s),s+=r.length}return i}(e,t),this.reset(),i):new Uint8Array(0)}reset(){this.chunks.length=0,this.dataLength=0}}function Vf(e="",t=9e4){return{type:e,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}class Wf{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(e,t,i,s){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(e){this.initPTS=e,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(e,t){return!1}appendFrame(e,t,i){}demux(e,t){this.cachedData&&(e=au(this.cachedData,e),this.cachedData=null);let i,s=Tc(e,0),r=s?s.length:0;const a=this._audioTrack,o=this._id3Track,n=s?Rc(s):void 0,l=e.length;for((null===this.basePTS||0===this.frameIndex&&Fh(n))&&(this.basePTS=Jf(n,t,this.initPTS),this.lastPTS=this.basePTS),null===this.lastPTS&&(this.lastPTS=this.basePTS),s&&s.length>0&&o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:s,type:rp,duration:Number.POSITIVE_INFINITY});r<l;){if(this.canParse(e,r)){const t=this.appendFrame(a,e,r);t?(this.frameIndex++,this.lastPTS=t.sample.pts,r+=t.length,i=r):r=l}else Cc(e,r)?(s=Tc(e,r),o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:s,type:rp,duration:Number.POSITIVE_INFINITY}),r+=s.length,i=r):r++;if(r===l&&i!==l){const t=Sc(e,i);this.cachedData?this.cachedData=au(this.cachedData,t):this.cachedData=t}}return{audioTrack:a,videoTrack:Vf(),id3Track:o,textTrack:Vf()}}demuxSampleAes(e,t,i){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(e){const t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:Vf(),id3Track:this._id3Track,textTrack:Vf()}}destroy(){}}const Jf=(e,t,i)=>{if(Fh(e))return 90*e;return 9e4*t+(i?9e4*i.baseTime/i.timescale:0)};function qf(e,t){return 255===e[t]&&240==(246&e[t+1])}function Kf(e,t){return 1&e[t+1]?7:9}function Yf(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function Qf(e,t){return t+1<e.length&&qf(e,t)}function Xf(e,t){if(Qf(e,t)){const i=Kf(e,t);if(t+i>=e.length)return!1;const s=Yf(e,t);if(s<=i)return!1;const r=t+s;return r===e.length||Qf(e,r)}return!1}function Zf(e,t,i,s,r){if(!e.samplerate){const a=function(e,t,i,s){let r,a,o,n;const l=navigator.userAgent.toLowerCase(),d=s,h=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];r=1+((192&t[i+2])>>>6);const c=(60&t[i+2])>>>2;if(!(c>h.length-1))return o=(1&t[i+2])<<2,o|=(192&t[i+3])>>>6,Jh.log(`manifest codec:${s}, ADTS type:${r}, samplingIndex:${c}`),/firefox/i.test(l)?c>=6?(r=5,n=new Array(4),a=c-3):(r=2,n=new Array(2),a=c):-1!==l.indexOf("android")?(r=2,n=new Array(2),a=c):(r=5,n=new Array(4),s&&(-1!==s.indexOf("mp4a.40.29")||-1!==s.indexOf("mp4a.40.5"))||!s&&c>=6?a=c-3:((s&&-1!==s.indexOf("mp4a.40.2")&&(c>=6&&1===o||/vivaldi/i.test(l))||!s&&1===o)&&(r=2,n=new Array(2)),a=c)),n[0]=r<<3,n[0]|=(14&c)>>1,n[1]|=(1&c)<<7,n[1]|=o<<3,5===r&&(n[1]|=(14&a)>>1,n[2]=(1&a)<<7,n[2]|=8,n[3]=0),{config:n,samplerate:h[c],channelCount:o,codec:"mp4a.40."+r,manifestCodec:d};{const t=new Error(`invalid ADTS sampling index:${c}`);e.emit(jh.ERROR,jh.ERROR,{type:zh.MEDIA_ERROR,details:Gh.FRAG_PARSING_ERROR,fatal:!0,error:t,reason:t.message})}}(t,i,s,r);if(!a)return;e.config=a.config,e.samplerate=a.samplerate,e.channelCount=a.channelCount,e.codec=a.codec,e.manifestCodec=a.manifestCodec,Jh.log(`parsed codec:${e.codec}, rate:${a.samplerate}, channels:${a.channelCount}`)}}function em(e){return 9216e4/e}function tm(e,t,i,s,r){const a=s+r*em(e.samplerate),o=function(e,t){const i=Kf(e,t);if(t+i<=e.length){const s=Yf(e,t)-i;if(s>0)return{headerLength:i,frameLength:s}}}(t,i);let n;if(o){const{frameLength:s,headerLength:r}=o,l=r+s,d=Math.max(0,i+l-t.length);d?(n=new Uint8Array(l-r),n.set(t.subarray(i+r,t.length),0)):n=t.subarray(i+r,i+l);const h={unit:n,pts:a};return d||e.samples.push(h),{sample:h,length:l,missing:d}}const l=t.length-i;n=new Uint8Array(l),n.set(t.subarray(i,t.length),0);return{sample:{unit:n,pts:a},length:l,missing:-1}}let im=null;const sm=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],rm=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],am=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],om=[0,1,1,4];function nm(e,t,i,s,r){if(i+24>t.length)return;const a=lm(t,i);if(a&&i+a.frameLength<=t.length){const o=s+r*(9e4*a.samplesPerFrame/a.sampleRate),n={unit:t.subarray(i,i+a.frameLength),pts:o,dts:o};return e.config=[],e.channelCount=a.channelCount,e.samplerate=a.sampleRate,e.samples.push(n),{sample:n,length:a.frameLength,missing:0}}}function lm(e,t){const i=e[t+1]>>3&3,s=e[t+1]>>1&3,r=e[t+2]>>4&15,a=e[t+2]>>2&3;if(1!==i&&0!==r&&15!==r&&3!==a){const o=e[t+2]>>1&1,n=e[t+3]>>6,l=1e3*sm[14*(3===i?3-s:3===s?3:4)+r-1],d=rm[3*(3===i?0:2===i?1:2)+a],h=3===n?1:2,c=am[i][s],u=om[s],p=8*c*u,f=Math.floor(c*l/d+o)*u;if(null===im){const e=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);im=e?parseInt(e[1]):0}return!!im&&im<=87&&2===s&&l>=224e3&&0===n&&(e[t+3]=128|e[t+3]),{sampleRate:d,channelCount:h,frameLength:f,samplesPerFrame:p}}}function dm(e,t){return!(255!==e[t]||224&~e[t+1]||!(6&e[t+1]))}function hm(e,t){return t+1<e.length&&dm(e,t)}function cm(e,t){if(t+1<e.length&&dm(e,t)){const i=4,s=lm(e,t);let r=i;null!=s&&s.frameLength&&(r=s.frameLength);const a=t+r;return a===e.length||hm(e,a)}return!1}const um=/\/emsg[-/]ID3/i;const pm=(e,t)=>{let i=0,s=5;t+=s;const r=new Uint32Array(1),a=new Uint32Array(1),o=new Uint8Array(1);for(;s>0;){o[0]=e[t];const n=Math.min(s,8),l=8-n;a[0]=4278190080>>>24+l<<l,r[0]=(o[0]&a[0])>>l,i=i?i<<n|r[0]:r[0],t+=1,s-=n}return i};class fm extends Wf{constructor(e){super(),this.observer=void 0,this.observer=e}resetInitSegment(e,t,i,s){super.resetInitSegment(e,t,i,s),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}canParse(e,t){return t+64<e.length}appendFrame(e,t,i){const s=mm(e,t,i,this.basePTS,this.frameIndex);if(-1!==s){return{sample:e.samples[e.samples.length-1],length:s,missing:0}}}static probe(e){if(!e)return!1;const t=Tc(e,0);if(!t)return!1;const i=t.length;return 11===e[i]&&119===e[i+1]&&void 0!==Rc(t)&&pm(e,i)<16}}function mm(e,t,i,s,r){if(i+8>t.length)return-1;if(11!==t[i]||119!==t[i+1])return-1;const a=t[i+4]>>6;if(a>=3)return-1;const o=[48e3,44100,32e3][a],n=63&t[i+4],l=2*[64,69,96,64,70,96,80,87,120,80,88,120,96,104,144,96,105,144,112,121,168,112,122,168,128,139,192,128,140,192,160,174,240,160,175,240,192,208,288,192,209,288,224,243,336,224,244,336,256,278,384,256,279,384,320,348,480,320,349,480,384,417,576,384,418,576,448,487,672,448,488,672,512,557,768,512,558,768,640,696,960,640,697,960,768,835,1152,768,836,1152,896,975,1344,896,976,1344,1024,1114,1536,1024,1115,1536,1152,1253,1728,1152,1254,1728,1280,1393,1920,1280,1394,1920][3*n+a];if(i+l>t.length)return-1;const d=t[i+6]>>5;let h=0;2===d?h+=2:(1&d&&1!==d&&(h+=2),4&d&&(h+=2));const c=(t[i+6]<<8|t[i+7])>>12-h&1,u=[2,1,2,3,3,4,4,5][d]+c,p=t[i+5]>>3,f=7&t[i+5],m=new Uint8Array([a<<6|p<<1|f>>2,(3&f)<<6|d<<3|c<<2|n>>4,n<<4&224]),g=s+r*(1536/o*9e4),y=t.subarray(i,i+l);return e.config=m,e.channelCount=u,e.samplerate=o,e.samples.push({unit:y,pts:g}),l}class gm{constructor(){this.VideoSample=null}createVideoSample(e,t,i,s){return{key:e,frame:!1,pts:t,dts:i,units:[],debug:s,length:0}}getLastNalUnit(e){var t;let i,s=this.VideoSample;if(s&&0!==s.units.length||(s=e[e.length-1]),null!=(t=s)&&t.units){const e=s.units;i=e[e.length-1]}return i}pushAccessUnit(e,t){if(e.units.length&&e.frame){if(void 0===e.pts){const i=t.samples,s=i.length;if(!s)return void t.dropped++;{const t=i[s-1];e.pts=t.pts,e.dts=t.dts}}t.samples.push(e)}e.debug.length&&Jh.log(e.pts+"/"+e.dts+":"+e.debug)}}class ym{constructor(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}loadWord(){const e=this.data,t=this.bytesAvailable,i=e.byteLength-t,s=new Uint8Array(4),r=Math.min(4,t);if(0===r)throw new Error("no bytes available");s.set(e.subarray(i,i+r)),this.word=new DataView(s.buffer).getUint32(0),this.bitsAvailable=8*r,this.bytesAvailable-=r}skipBits(e){let t;e=Math.min(e,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(t=(e-=this.bitsAvailable)>>3,e-=t<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}readBits(e){let t=Math.min(this.bitsAvailable,e);const i=this.word>>>32-t;if(e>32&&Jh.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return t=e-t,t>0&&this.bitsAvailable?i<<t|this.readBits(t):i}skipLZ(){let e;for(e=0;e<this.bitsAvailable;++e)if(this.word&2147483648>>>e)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){const e=this.skipLZ();return this.readBits(e+1)-1}readEG(){const e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}readBoolean(){return 1===this.readBits(1)}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}skipScalingList(e){let t,i=8,s=8;for(let r=0;r<e;r++)0!==s&&(t=this.readEG(),s=(i+t+256)%256),i=0===s?i:s}readSPS(){let e,t,i,s=0,r=0,a=0,o=0;const n=this.readUByte.bind(this),l=this.readBits.bind(this),d=this.readUEG.bind(this),h=this.readBoolean.bind(this),c=this.skipBits.bind(this),u=this.skipEG.bind(this),p=this.skipUEG.bind(this),f=this.skipScalingList.bind(this);n();const m=n();if(l(5),c(3),n(),p(),100===m||110===m||122===m||244===m||44===m||83===m||86===m||118===m||128===m){const e=d();if(3===e&&c(1),p(),p(),c(1),h())for(t=3!==e?8:12,i=0;i<t;i++)h()&&f(i<6?16:64)}p();const g=d();if(0===g)d();else if(1===g)for(c(1),u(),u(),e=d(),i=0;i<e;i++)u();p(),c(1);const y=d(),A=d(),b=l(1);0===b&&c(1),c(1),h()&&(s=d(),r=d(),a=d(),o=d());let _=[1,1];if(h()&&h()){switch(n()){case 1:_=[1,1];break;case 2:_=[12,11];break;case 3:_=[10,11];break;case 4:_=[16,11];break;case 5:_=[40,33];break;case 6:_=[24,11];break;case 7:_=[20,11];break;case 8:_=[32,11];break;case 9:_=[80,33];break;case 10:_=[18,11];break;case 11:_=[15,11];break;case 12:_=[64,33];break;case 13:_=[160,99];break;case 14:_=[4,3];break;case 15:_=[3,2];break;case 16:_=[2,1];break;case 255:_=[n()<<8|n(),n()<<8|n()]}}return{width:Math.ceil(16*(y+1)-2*s-2*r),height:(2-b)*(A+1)*16-(b?2:4)*(a+o),pixelRatio:_}}readSliceType(){return this.readUByte(),this.readUEG(),this.readUEG()}}class Am extends gm{parseAVCPES(e,t,i,s,r){const a=this.parseAVCNALu(e,i.data);let o,n=this.VideoSample,l=!1;i.data=null,n&&a.length&&!e.audFound&&(this.pushAccessUnit(n,e),n=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts,"")),a.forEach((s=>{var a;switch(s.type){case 1:{let t=!1;o=!0;const r=s.data;if(l&&r.length>4){const e=new ym(r).readSliceType();2!==e&&4!==e&&7!==e&&9!==e||(t=!0)}var d;if(t)null!=(d=n)&&d.frame&&!n.key&&(this.pushAccessUnit(n,e),n=this.VideoSample=null);n||(n=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts,"")),n.frame=!0,n.key=t;break}case 5:o=!0,null!=(a=n)&&a.frame&&!n.key&&(this.pushAccessUnit(n,e),n=this.VideoSample=null),n||(n=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts,"")),n.key=!0,n.frame=!0;break;case 6:o=!0,lu(s.data,1,i.pts,t.samples);break;case 7:{var h,c;o=!0,l=!0;const t=s.data,i=new ym(t).readSPS();if(!e.sps||e.width!==i.width||e.height!==i.height||(null==(h=e.pixelRatio)?void 0:h[0])!==i.pixelRatio[0]||(null==(c=e.pixelRatio)?void 0:c[1])!==i.pixelRatio[1]){e.width=i.width,e.height=i.height,e.pixelRatio=i.pixelRatio,e.sps=[t],e.duration=r;const s=t.subarray(1,4);let a="avc1.";for(let e=0;e<3;e++){let t=s[e].toString(16);t.length<2&&(t="0"+t),a+=t}e.codec=a}break}case 8:o=!0,e.pps=[s.data];break;case 9:o=!0,e.audFound=!0,n&&this.pushAccessUnit(n,e),n=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts,"");break;case 12:o=!0;break;default:o=!1,n&&(n.debug+="unknown NAL "+s.type+" ")}if(n&&o){n.units.push(s)}})),s&&n&&(this.pushAccessUnit(n,e),this.VideoSample=null)}parseAVCNALu(e,t){const i=t.byteLength;let s=e.naluState||0;const r=s,a=[];let o,n,l,d=0,h=-1,c=0;for(-1===s&&(h=0,c=31&t[0],s=0,d=1);d<i;)if(o=t[d++],s)if(1!==s)if(o)if(1===o){if(n=d-s-1,h>=0){const e={data:t.subarray(h,n),type:c};a.push(e)}else{const i=this.getLastNalUnit(e.samples);i&&(r&&d<=4-r&&i.state&&(i.data=i.data.subarray(0,i.data.byteLength-r)),n>0&&(i.data=au(i.data,t.subarray(0,n)),i.state=0))}d<i?(l=31&t[d],h=d,c=l,s=0):s=-1}else s=0;else s=3;else s=o?0:2;else s=o?0:1;if(h>=0&&s>=0){const e={data:t.subarray(h,i),type:c,state:s};a.push(e)}if(0===a.length){const i=this.getLastNalUnit(e.samples);i&&(i.data=au(i.data,t))}return e.naluState=s,a}}class bm{constructor(e,t,i){this.keyData=void 0,this.decrypter=void 0,this.keyData=i,this.decrypter=new xf(t,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer)}decryptAacSample(e,t,i){const s=e[t].unit;if(s.length<=16)return;const r=s.subarray(16,s.length-s.length%16),a=r.buffer.slice(r.byteOffset,r.byteOffset+r.length);this.decryptBuffer(a).then((r=>{const a=new Uint8Array(r);s.set(a,16),this.decrypter.isSync()||this.decryptAacSamples(e,t+1,i)}))}decryptAacSamples(e,t,i){for(;;t++){if(t>=e.length)return void i();if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,i),!this.decrypter.isSync()))return}}getAvcEncryptedData(e){const t=16*Math.floor((e.length-48)/160)+16,i=new Int8Array(t);let s=0;for(let t=32;t<e.length-16;t+=160,s+=16)i.set(e.subarray(t,t+16),s);return i}getAvcDecryptedUnit(e,t){const i=new Uint8Array(t);let s=0;for(let t=32;t<e.length-16;t+=160,s+=16)e.set(i.subarray(s,s+16),t);return e}decryptAvcSample(e,t,i,s,r){const a=du(r.data),o=this.getAvcEncryptedData(a);this.decryptBuffer(o.buffer).then((o=>{r.data=this.getAvcDecryptedUnit(a,o),this.decrypter.isSync()||this.decryptAvcSamples(e,t,i+1,s)}))}decryptAvcSamples(e,t,i,s){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,i=0){if(t>=e.length)return void s();const r=e[t].units;for(;!(i>=r.length);i++){const a=r[i];if(!(a.data.length<=48||1!==a.type&&5!==a.type||(this.decryptAvcSample(e,t,i,s,a),this.decrypter.isSync())))return}}}}const _m=188;class vm{constructor(e,t,i){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=e,this.config=t,this.typeSupported=i,this.videoParser=new Am}static probe(e){const t=vm.syncOffset(e);return t>0&&Jh.warn(`MPEG2-TS detected but first sync word found @ offset ${t}`),-1!==t}static syncOffset(e){const t=e.length;let i=Math.min(940,t-_m)+1,s=0;for(;s<i;){let r=!1,a=-1,o=0;for(let n=s;n<t;n+=_m){if(71!==e[n]||t-n!==_m&&71!==e[n+_m]){if(o)return-1;break}if(o++,-1===a&&(a=n,0!==a&&(i=Math.min(a+18612,e.length-_m)+1)),r||(r=0===Sm(e,n)),r&&o>1&&(0===a&&o>2||n+_m>i))return a}s++}return-1}static createTrack(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:Hc[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===e?t:void 0}}resetInitSegment(e,t,i,s){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=vm.createTrack("video"),this._audioTrack=vm.createTrack("audio",s),this._id3Track=vm.createTrack("id3"),this._txtTrack=vm.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=i,this._duration=s}resetTimeStamp(){}resetContiguity(){const{_audioTrack:e,_videoTrack:t,_id3Track:i}=this;e&&(e.pesData=null),t&&(t.pesData=null),i&&(i.pesData=null),this.aacOverFlow=null,this.remainderData=null}demux(e,t,i=!1,s=!1){let r;i||(this.sampleAes=null);const a=this._videoTrack,o=this._audioTrack,n=this._id3Track,l=this._txtTrack;let d=a.pid,h=a.pesData,c=o.pid,u=n.pid,p=o.pesData,f=n.pesData,m=null,g=this.pmtParsed,y=this._pmtId,A=e.length;if(this.remainderData&&(A=(e=au(this.remainderData,e)).length,this.remainderData=null),A<_m&&!s)return this.remainderData=e,{audioTrack:o,videoTrack:a,id3Track:n,textTrack:l};const b=Math.max(0,vm.syncOffset(e));A-=(A-b)%_m,A<e.byteLength&&!s&&(this.remainderData=new Uint8Array(e.buffer,A,e.buffer.byteLength-A));let _=0;for(let t=b;t<A;t+=_m)if(71===e[t]){const s=!!(64&e[t+1]),A=Sm(e,t);let _;if((48&e[t+3])>>4>1){if(_=t+5+e[t+4],_===t+_m)continue}else _=t+4;switch(A){case d:s&&(h&&(r=km(h))&&this.videoParser.parseAVCPES(a,l,r,!1,this._duration),h={data:[],size:0}),h&&(h.data.push(e.subarray(_,t+_m)),h.size+=t+_m-_);break;case c:if(s){if(p&&(r=km(p)))switch(o.segmentCodec){case"aac":this.parseAACPES(o,r);break;case"mp3":this.parseMPEGPES(o,r);break;case"ac3":this.parseAC3PES(o,r)}p={data:[],size:0}}p&&(p.data.push(e.subarray(_,t+_m)),p.size+=t+_m-_);break;case u:s&&(f&&(r=km(f))&&this.parseID3PES(n,r),f={data:[],size:0}),f&&(f.data.push(e.subarray(_,t+_m)),f.size+=t+_m-_);break;case 0:s&&(_+=e[_]+1),y=this._pmtId=wm(e,_);break;case y:{s&&(_+=e[_]+1);const r=Em(e,_,this.typeSupported,i);d=r.videoPid,d>0&&(a.pid=d,a.segmentCodec=r.segmentVideoCodec),c=r.audioPid,c>0&&(o.pid=c,o.segmentCodec=r.segmentAudioCodec),u=r.id3Pid,u>0&&(n.pid=u),null===m||g||(Jh.warn(`MPEG-TS PMT found at ${t} after unknown PID '${m}'. Backtracking to sync byte @${b} to parse all TS packets.`),m=null,t=b-188),g=this.pmtParsed=!0;break}case 17:case 8191:break;default:m=A}}else _++;if(_>0){const e=new Error(`Found ${_} TS packet/s that do not start with 0x47`);this.observer.emit(jh.ERROR,jh.ERROR,{type:zh.MEDIA_ERROR,details:Gh.FRAG_PARSING_ERROR,fatal:!1,error:e,reason:e.message})}a.pesData=h,o.pesData=p,n.pesData=f;const v={audioTrack:o,videoTrack:a,id3Track:n,textTrack:l};return s&&this.extractRemainingSamples(v),v}flush(){const{remainderData:e}=this;let t;return this.remainderData=null,t=e?this.demux(e,-1,!1,!0):{videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t}extractRemainingSamples(e){const{audioTrack:t,videoTrack:i,id3Track:s,textTrack:r}=e,a=i.pesData,o=t.pesData,n=s.pesData;let l;if(a&&(l=km(a))?(this.videoParser.parseAVCPES(i,r,l,!0,this._duration),i.pesData=null):i.pesData=a,o&&(l=km(o))){switch(t.segmentCodec){case"aac":this.parseAACPES(t,l);break;case"mp3":this.parseMPEGPES(t,l);break;case"ac3":this.parseAC3PES(t,l)}t.pesData=null}else null!=o&&o.size&&Jh.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=o;n&&(l=km(n))?(this.parseID3PES(s,l),s.pesData=null):s.pesData=n}demuxSampleAes(e,t,i){const s=this.demux(e,i,!0,!this.config.progressive),r=this.sampleAes=new bm(this.observer,this.config,t);return this.decrypt(s,r)}decrypt(e,t){return new Promise((i=>{const{audioTrack:s,videoTrack:r}=e;s.samples&&"aac"===s.segmentCodec?t.decryptAacSamples(s.samples,0,(()=>{r.samples?t.decryptAvcSamples(r.samples,0,0,(()=>{i(e)})):i(e)})):r.samples&&t.decryptAvcSamples(r.samples,0,0,(()=>{i(e)}))}))}destroy(){this._duration=0}parseAACPES(e,t){let i=0;const s=this.aacOverFlow;let r,a,o,n=t.data;if(s){this.aacOverFlow=null;const t=s.missing,r=s.sample.unit.byteLength;if(-1===t)n=au(s.sample.unit,n);else{const a=r-t;s.sample.unit.set(n.subarray(0,t),a),e.samples.push(s.sample),i=s.missing}}for(r=i,a=n.length;r<a-1&&!Qf(n,r);r++);if(r!==i){let e;const t=r<a-1;e=t?`AAC PES did not start with ADTS header,offset:${r}`:"No ADTS header found in AAC PES";const i=new Error(e);if(Jh.warn(`parsing error: ${e}`),this.observer.emit(jh.ERROR,jh.ERROR,{type:zh.MEDIA_ERROR,details:Gh.FRAG_PARSING_ERROR,fatal:!1,levelRetry:t,error:i,reason:e}),!t)return}if(Zf(e,this.observer,n,r,this.audioCodec),void 0!==t.pts)o=t.pts;else{if(!s)return void Jh.warn("[tsdemuxer]: AAC PES unknown PTS");{const t=em(e.samplerate);o=s.sample.pts+t}}let l,d=0;for(;r<a;){if(l=tm(e,n,r,o,d),r+=l.length,l.missing){this.aacOverFlow=l;break}for(d++;r<a-1&&!Qf(n,r);r++);}}parseMPEGPES(e,t){const i=t.data,s=i.length;let r=0,a=0;const o=t.pts;if(void 0!==o)for(;a<s;)if(hm(i,a)){const t=nm(e,i,a,o,r);if(!t)break;a+=t.length,r++}else a++;else Jh.warn("[tsdemuxer]: MPEG PES unknown PTS")}parseAC3PES(e,t){{const i=t.data,s=t.pts;if(void 0===s)return void Jh.warn("[tsdemuxer]: AC3 PES unknown PTS");const r=i.length;let a,o=0,n=0;for(;n<r&&(a=mm(e,i,n,s,o++))>0;)n+=a}}parseID3PES(e,t){if(void 0===t.pts)return void Jh.warn("[tsdemuxer]: ID3 PES unknown PTS");const i=Uh({},t,{type:this._videoTrack?op:rp,duration:Number.POSITIVE_INFINITY});e.samples.push(i)}}function Sm(e,t){return((31&e[t+1])<<8)+e[t+2]}function wm(e,t){return(31&e[t+10])<<8|e[t+11]}function Em(e,t,i,s){const r={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},a=t+3+((15&e[t+1])<<8|e[t+2])-4;for(t+=12+((15&e[t+10])<<8|e[t+11]);t<a;){const a=Sm(e,t),o=(15&e[t+3])<<8|e[t+4];switch(e[t]){case 207:if(!s){Tm("ADTS AAC");break}case 15:-1===r.audioPid&&(r.audioPid=a);break;case 21:-1===r.id3Pid&&(r.id3Pid=a);break;case 219:if(!s){Tm("H.264");break}case 27:-1===r.videoPid&&(r.videoPid=a,r.segmentVideoCodec="avc");break;case 3:case 4:i.mpeg||i.mp3?-1===r.audioPid&&(r.audioPid=a,r.segmentAudioCodec="mp3"):Jh.log("MPEG audio found, not supported in this browser");break;case 193:if(!s){Tm("AC-3");break}case 129:i.ac3?-1===r.audioPid&&(r.audioPid=a,r.segmentAudioCodec="ac3"):Jh.log("AC-3 audio found, not supported in this browser");break;case 6:if(-1===r.audioPid&&o>0){let s=t+5,n=o;for(;n>2;){if(106===e[s])!0!==i.ac3?Jh.log("AC-3 audio found, not supported in this browser for now"):(r.audioPid=a,r.segmentAudioCodec="ac3");const t=e[s+1]+2;s+=t,n-=t}}break;case 194:case 135:Jh.warn("Unsupported EC-3 in M2TS found");break;case 36:Jh.warn("Unsupported HEVC in M2TS found")}t+=o+5}return r}function Tm(e){Jh.log(`${e} with AES-128-CBC encryption found in unencrypted stream`)}function km(e){let t,i,s,r,a,o=0;const n=e.data;if(!e||0===e.size)return null;for(;n[0].length<19&&n.length>1;)n[0]=au(n[0],n[1]),n.splice(1,1);t=n[0];if(1===(t[0]<<16)+(t[1]<<8)+t[2]){if(i=(t[4]<<8)+t[5],i&&i>e.size-6)return null;const l=t[7];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?(a=536870912*(14&t[14])+4194304*(255&t[15])+16384*(254&t[16])+128*(255&t[17])+(254&t[18])/2,r-a>54e5&&(Jh.warn(`${Math.round((r-a)/9e4)}s delta between PTS and DTS, align them`),r=a)):a=r),s=t[8];let d=s+9;if(e.size<=d)return null;e.size-=d;const h=new Uint8Array(e.size);for(let e=0,i=n.length;e<i;e++){t=n[e];let i=t.byteLength;if(d){if(d>i){d-=i;continue}t=t.subarray(d),i-=d,d=0}h.set(t,o),o+=i}return i&&(i-=s+3),{data:h,pts:r,dts:a,len:i}}return null}class Cm{static getSilentFrame(e,t){if("mp4a.40.2"===e){if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(6===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(1===t)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(3===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}}}const Rm=Math.pow(2,32)-1;class xm{static init(){let e;for(e in xm.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],dac3:[],"ac-3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},xm.types)xm.types.hasOwnProperty(e)&&(xm.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);const t=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]),i=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]);xm.HDLR_TYPES={video:t,audio:i};const s=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),r=new Uint8Array([0,0,0,0,0,0,0,0]);xm.STTS=xm.STSC=xm.STCO=r,xm.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),xm.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),xm.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),xm.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);const a=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),n=new Uint8Array([0,0,0,1]);xm.FTYP=xm.box(xm.types.ftyp,a,n,a,o),xm.DINF=xm.box(xm.types.dinf,xm.box(xm.types.dref,s))}static box(e,...t){let i=8,s=t.length;const r=s;for(;s--;)i+=t[s].byteLength;const a=new Uint8Array(i);for(a[0]=i>>24&255,a[1]=i>>16&255,a[2]=i>>8&255,a[3]=255&i,a.set(e,4),s=0,i=8;s<r;s++)a.set(t[s],i),i+=t[s].byteLength;return a}static hdlr(e){return xm.box(xm.types.hdlr,xm.HDLR_TYPES[e])}static mdat(e){return xm.box(xm.types.mdat,e)}static mdhd(e,t){t*=e;const i=Math.floor(t/(Rm+1)),s=Math.floor(t%(Rm+1));return xm.box(xm.types.mdhd,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,s>>24,s>>16&255,s>>8&255,255&s,85,196,0,0]))}static mdia(e){return xm.box(xm.types.mdia,xm.mdhd(e.timescale,e.duration),xm.hdlr(e.type),xm.minf(e))}static mfhd(e){return xm.box(xm.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e]))}static minf(e){return"audio"===e.type?xm.box(xm.types.minf,xm.box(xm.types.smhd,xm.SMHD),xm.DINF,xm.stbl(e)):xm.box(xm.types.minf,xm.box(xm.types.vmhd,xm.VMHD),xm.DINF,xm.stbl(e))}static moof(e,t,i){return xm.box(xm.types.moof,xm.mfhd(e),xm.traf(i,t))}static moov(e){let t=e.length;const i=[];for(;t--;)i[t]=xm.trak(e[t]);return xm.box.apply(null,[xm.types.moov,xm.mvhd(e[0].timescale,e[0].duration)].concat(i).concat(xm.mvex(e)))}static mvex(e){let t=e.length;const i=[];for(;t--;)i[t]=xm.trex(e[t]);return xm.box.apply(null,[xm.types.mvex,...i])}static mvhd(e,t){t*=e;const i=Math.floor(t/(Rm+1)),s=Math.floor(t%(Rm+1)),r=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,s>>24,s>>16&255,s>>8&255,255&s,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 xm.box(xm.types.mvhd,r)}static sdtp(e){const t=e.samples||[],i=new Uint8Array(4+t.length);let s,r;for(s=0;s<t.length;s++)r=t[s].flags,i[s+4]=r.dependsOn<<4|r.isDependedOn<<2|r.hasRedundancy;return xm.box(xm.types.sdtp,i)}static stbl(e){return xm.box(xm.types.stbl,xm.stsd(e),xm.box(xm.types.stts,xm.STTS),xm.box(xm.types.stsc,xm.STSC),xm.box(xm.types.stsz,xm.STSZ),xm.box(xm.types.stco,xm.STCO))}static avc1(e){let t,i,s,r=[],a=[];for(t=0;t<e.sps.length;t++)i=e.sps[t],s=i.byteLength,r.push(s>>>8&255),r.push(255&s),r=r.concat(Array.prototype.slice.call(i));for(t=0;t<e.pps.length;t++)i=e.pps[t],s=i.byteLength,a.push(s>>>8&255),a.push(255&s),a=a.concat(Array.prototype.slice.call(i));const o=xm.box(xm.types.avcC,new Uint8Array([1,r[3],r[4],r[5],255,224|e.sps.length].concat(r).concat([e.pps.length]).concat(a))),n=e.width,l=e.height,d=e.pixelRatio[0],h=e.pixelRatio[1];return xm.box(xm.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,n>>8&255,255&n,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]),o,xm.box(xm.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),xm.box(xm.types.pasp,new Uint8Array([d>>24,d>>16&255,d>>8&255,255&d,h>>24,h>>16&255,h>>8&255,255&h])))}static esds(e){const 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]))}static audioStsd(e){const t=e.samplerate;return 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])}static mp4a(e){return xm.box(xm.types.mp4a,xm.audioStsd(e),xm.box(xm.types.esds,xm.esds(e)))}static mp3(e){return xm.box(xm.types[".mp3"],xm.audioStsd(e))}static ac3(e){return xm.box(xm.types["ac-3"],xm.audioStsd(e),xm.box(xm.types.dac3,e.config))}static stsd(e){return"audio"===e.type?"mp3"===e.segmentCodec&&"mp3"===e.codec?xm.box(xm.types.stsd,xm.STSD,xm.mp3(e)):"ac3"===e.segmentCodec?xm.box(xm.types.stsd,xm.STSD,xm.ac3(e)):xm.box(xm.types.stsd,xm.STSD,xm.mp4a(e)):xm.box(xm.types.stsd,xm.STSD,xm.avc1(e))}static tkhd(e){const t=e.id,i=e.duration*e.timescale,s=e.width,r=e.height,a=Math.floor(i/(Rm+1)),o=Math.floor(i%(Rm+1));return xm.box(xm.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,0,0,0,0,a>>24,a>>16&255,a>>8&255,255&a,o>>24,o>>16&255,o>>8&255,255&o,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,s>>8&255,255&s,0,0,r>>8&255,255&r,0,0]))}static traf(e,t){const i=xm.sdtp(e),s=e.id,r=Math.floor(t/(Rm+1)),a=Math.floor(t%(Rm+1));return xm.box(xm.types.traf,xm.box(xm.types.tfhd,new Uint8Array([0,0,0,0,s>>24,s>>16&255,s>>8&255,255&s])),xm.box(xm.types.tfdt,new Uint8Array([1,0,0,0,r>>24,r>>16&255,r>>8&255,255&r,a>>24,a>>16&255,a>>8&255,255&a])),xm.trun(e,i.length+16+20+8+16+8+8),i)}static trak(e){return e.duration=e.duration||4294967295,xm.box(xm.types.trak,xm.tkhd(e),xm.mdia(e))}static trex(e){const t=e.id;return xm.box(xm.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(e,t){const i=e.samples||[],s=i.length,r=12+16*s,a=new Uint8Array(r);let o,n,l,d,h,c;for(t+=8+r,a.set(["video"===e.type?1:0,0,15,1,s>>>24&255,s>>>16&255,s>>>8&255,255&s,t>>>24&255,t>>>16&255,t>>>8&255,255&t],0),o=0;o<s;o++)n=i[o],l=n.duration,d=n.size,h=n.flags,c=n.cts,a.set([l>>>24&255,l>>>16&255,l>>>8&255,255&l,d>>>24&255,d>>>16&255,d>>>8&255,255&d,h.isLeading<<2|h.dependsOn,h.isDependedOn<<6|h.hasRedundancy<<4|h.paddingValue<<1|h.isNonSync,61440&h.degradPrio,15&h.degradPrio,c>>>24&255,c>>>16&255,c>>>8&255,255&c],12+16*o);return xm.box(xm.types.trun,a)}static initSegment(e){xm.types||xm.init();const t=xm.moov(e);return au(xm.FTYP,t)}}xm.types=void 0,xm.HDLR_TYPES=void 0,xm.STTS=void 0,xm.STSC=void 0,xm.STCO=void 0,xm.STSZ=void 0,xm.VMHD=void 0,xm.SMHD=void 0,xm.STSD=void 0,xm.FTYP=void 0,xm.DINF=void 0;const Dm=9e4;function Lm(e,t,i=1,s=!1){const r=e*t*i;return s?Math.round(r):r}function Pm(e,t=!1){return Lm(e,1e3,1/Dm,t)}let Bm,Im=null,Mm=null;class Um{constructor(e,t,i,s=""){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.videoTrackConfig=void 0,this.observer=e,this.config=t,this.typeSupported=i,this.ISGenerated=!1,null===Im){const e=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Im=e?parseInt(e[1]):0}if(null===Mm){const e=navigator.userAgent.match(/Safari\/(\d+)/i);Mm=e?parseInt(e[1]):0}}destroy(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null}resetTimeStamp(e){Jh.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e}resetNextTimestamp(){Jh.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){Jh.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0}getVideoStartPts(e){let t=!1;const i=e.reduce(((e,i)=>{const s=i.pts-e;return s<-4294967296?(t=!0,Fm(e,i.pts)):s>0?e:i.pts}),e[0].pts);return t&&Jh.debug("PTS rollover detected"),i}remux(e,t,i,s,r,a,o,n){let l,d,h,c,u,p,f=r,m=r;const g=e.pid>-1,y=t.pid>-1,A=t.samples.length,b=e.samples.length>0,_=o&&A>0||A>1;if((!g||b)&&(!y||_)||this.ISGenerated||o){if(this.ISGenerated){var v,S,w,E;const e=this.videoTrackConfig;!e||t.width===e.width&&t.height===e.height&&(null==(v=t.pixelRatio)?void 0:v[0])===(null==(S=e.pixelRatio)?void 0:S[0])&&(null==(w=t.pixelRatio)?void 0:w[1])===(null==(E=e.pixelRatio)?void 0:E[1])||this.resetInitSegment()}else h=this.generateIS(e,t,r,a);const i=this.isVideoContiguous;let s,o=-1;if(_&&(o=function(e){for(let t=0;t<e.length;t++)if(e[t].key)return t;return-1}(t.samples),!i&&this.config.forceKeyFrameOnDiscontinuity))if(p=!0,o>0){Jh.warn(`[mp4-remuxer]: Dropped ${o} out of ${A} video samples due to a missing keyframe`);const e=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(o),t.dropped+=o,m+=(t.samples[0].pts-e)/t.inputTimeScale,s=m}else-1===o&&(Jh.warn(`[mp4-remuxer]: No keyframe found out of ${A} video samples`),p=!1);if(this.ISGenerated){if(b&&_){const i=this.getVideoStartPts(t.samples),s=(Fm(e.samples[0].pts,i)-i)/t.inputTimeScale;f+=Math.max(0,s),m+=Math.max(0,-s)}if(b){if(e.samplerate||(Jh.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),h=this.generateIS(e,t,r,a)),d=this.remuxAudio(e,f,this.isAudioContiguous,a,y||_||n===qu?m:void 0),_){const s=d?d.endPTS-d.startPTS:0;t.inputTimeScale||(Jh.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),h=this.generateIS(e,t,r,a)),l=this.remuxVideo(t,m,i,s)}}else _&&(l=this.remuxVideo(t,m,i,0));l&&(l.firstKeyFrame=o,l.independent=-1!==o,l.firstKeyFramePTS=s)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(i.samples.length&&(u=Om(i,r,this._initPTS,this._initDTS)),s.samples.length&&(c=Nm(s,r,this._initPTS))),{audio:d,video:l,initSegment:h,independent:p,text:c,id3:u}}generateIS(e,t,i,s){const r=e.samples,a=t.samples,o=this.typeSupported,n={},l=this._initPTS;let d,h,c,u=!l||s,p="audio/mp4";if(u&&(d=h=1/0),e.config&&r.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":o.mpeg?(p="audio/mpeg",e.codec=""):o.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3"}n.audio={id:"audio",container:p,codec:e.codec,initSegment:"mp3"===e.segmentCodec&&o.mpeg?new Uint8Array(0):xm.initSegment([e]),metadata:{channelCount:e.channelCount}},u&&(c=e.inputTimeScale,l&&c===l.timescale?u=!1:d=h=r[0].pts-Math.round(c*i))}if(t.sps&&t.pps&&a.length){if(t.timescale=t.inputTimeScale,n.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:xm.initSegment([t]),metadata:{width:t.width,height:t.height}},u)if(c=t.inputTimeScale,l&&c===l.timescale)u=!1;else{const e=this.getVideoStartPts(a),t=Math.round(c*i);h=Math.min(h,Fm(a[0].dts,e)-t),d=Math.min(d,e-t)}this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(n).length)return this.ISGenerated=!0,u?(this._initPTS={baseTime:d,timescale:c},this._initDTS={baseTime:h,timescale:c}):d=c=void 0,{tracks:n,initPTS:d,timescale:c}}remuxVideo(e,t,i,s){const r=e.inputTimeScale,a=e.samples,o=[],n=a.length,l=this._initPTS;let d,h,c=this.nextAvcDts,u=8,p=this.videoSampleDuration,f=Number.POSITIVE_INFINITY,m=Number.NEGATIVE_INFINITY,g=!1;if(!i||null===c){const e=t*r,s=a[0].pts-Fm(a[0].dts,a[0].pts);Im&&null!==c&&Math.abs(e-s-c)<15e3?i=!0:c=e-s}const y=l.baseTime*r/l.timescale;for(let e=0;e<n;e++){const t=a[e];t.pts=Fm(t.pts-y,c),t.dts=Fm(t.dts-y,c),t.dts<a[e>0?e-1:e].dts&&(g=!0)}g&&a.sort((function(e,t){const i=e.dts-t.dts,s=e.pts-t.pts;return i||s})),d=a[0].dts,h=a[a.length-1].dts;const A=h-d,b=A?Math.round(A/(n-1)):p||e.inputTimeScale/30;if(i){const e=d-c,i=e>b,s=e<-1;if((i||s)&&(i?Jh.warn(`AVC: ${Pm(e,!0)} ms (${e}dts) hole between fragments detected at ${t.toFixed(3)}`):Jh.warn(`AVC: ${Pm(-e,!0)} ms (${e}dts) overlapping between fragments detected at ${t.toFixed(3)}`),!s||c>=a[0].pts||Im)){d=c;const t=a[0].pts-e;if(i)a[0].dts=d,a[0].pts=t;else for(let i=0;i<a.length&&!(a[i].dts>t);i++)a[i].dts-=e,a[i].pts-=e;Jh.log(`Video: Initial PTS/DTS adjusted: ${Pm(t,!0)}/${Pm(d,!0)}, delta: ${Pm(e,!0)} ms`)}}d=Math.max(0,d);let _=0,v=0,S=d;for(let e=0;e<n;e++){const t=a[e],i=t.units,s=i.length;let r=0;for(let e=0;e<s;e++)r+=i[e].data.length;v+=r,_+=s,t.length=r,t.dts<S?(t.dts=S,S+=b/4|0||1):S=t.dts,f=Math.min(t.pts,f),m=Math.max(t.pts,m)}h=a[n-1].dts;const w=v+4*_+8;let E;try{E=new Uint8Array(w)}catch(e){return void this.observer.emit(jh.ERROR,jh.ERROR,{type:zh.MUX_ERROR,details:Gh.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:w,reason:`fail allocating video mdat ${w}`})}const T=new DataView(E.buffer);T.setUint32(0,w),E.set(xm.types.mdat,4);let k=!1,C=Number.POSITIVE_INFINITY,R=Number.POSITIVE_INFINITY,x=Number.NEGATIVE_INFINITY,D=Number.NEGATIVE_INFINITY;for(let e=0;e<n;e++){const t=a[e],i=t.units;let l,d=0;for(let e=0,t=i.length;e<t;e++){const t=i[e],s=t.data,r=t.data.byteLength;T.setUint32(u,r),u+=4,E.set(s,u),u+=r,d+=4+r}if(e<n-1)p=a[e+1].dts-t.dts,l=a[e+1].pts-t.pts;else{const i=this.config,o=e>0?t.dts-a[e-1].dts:b;if(l=e>0?t.pts-a[e-1].pts:b,i.stretchShortVideoTrack&&null!==this.nextAudioPts){const e=Math.floor(i.maxBufferHole*r),a=(s?f+s*r:this.nextAudioPts)-t.pts;a>e?(p=a-o,p<0?p=o:k=!0,Jh.log(`[mp4-remuxer]: It is approximately ${a/90} ms to the next segment; using duration ${p/90} ms for the last video frame.`)):p=o}else p=o}const h=Math.round(t.pts-t.dts);C=Math.min(C,p),x=Math.max(x,p),R=Math.min(R,l),D=Math.max(D,l),o.push(new jm(t.key,p,d,h))}if(o.length)if(Im){if(Im<70){const e=o[0].flags;e.dependsOn=2,e.isNonSync=0}}else if(Mm&&D-R<x-C&&b/x<.025&&0===o[0].cts){Jh.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let e=d;for(let t=0,i=o.length;t<i;t++){const s=e+o[t].duration,r=e+o[t].cts;if(t<i-1){const e=s+o[t+1].cts;o[t].duration=e-r}else o[t].duration=t?o[t-1].duration:b;o[t].cts=0,e=s}}p=k||!p?b:p,this.nextAvcDts=c=h+p,this.videoSampleDuration=p,this.isVideoContiguous=!0;const L={data1:xm.moof(e.sequenceNumber++,d,Uh({},e,{samples:o})),data2:E,startPTS:f/r,endPTS:(m+p)/r,startDTS:d/r,endDTS:c/r,type:"video",hasAudio:!1,hasVideo:!0,nb:o.length,dropped:e.dropped};return e.samples=[],e.dropped=0,L}getSamplesPerFrame(e){switch(e.segmentCodec){case"mp3":return 1152;case"ac3":return 1536;default:return 1024}}remuxAudio(e,t,i,s,r){const a=e.inputTimeScale,o=a/(e.samplerate?e.samplerate:a),n=this.getSamplesPerFrame(e),l=n*o,d=this._initPTS,h="mp3"===e.segmentCodec&&this.typeSupported.mpeg,c=[],u=void 0!==r;let p=e.samples,f=h?0:8,m=this.nextAudioPts||-1;const g=t*a,y=d.baseTime*a/d.timescale;if(this.isAudioContiguous=i=i||p.length&&m>0&&(s&&Math.abs(g-m)<9e3||Math.abs(Fm(p[0].pts-y,g)-m)<20*l),p.forEach((function(e){e.pts=Fm(e.pts-y,g)})),!i||m<0){if(p=p.filter((e=>e.pts>=0)),!p.length)return;m=0===r?0:s&&!u?Math.max(0,g):p[0].pts}if("aac"===e.segmentCodec){const t=this.config.maxAudioFramesDrift;for(let i=0,s=m;i<p.length;i++){const r=p[i],o=r.pts,n=o-s,d=Math.abs(1e3*n/a);if(n<=-t*l&&u)0===i&&(Jh.warn(`Audio frame @ ${(o/a).toFixed(3)}s overlaps nextAudioPts by ${Math.round(1e3*n/a)} ms.`),this.nextAudioPts=m=s=o);else if(n>=t*l&&d<1e4&&u){let t=Math.round(n/l);s=o-t*l,s<0&&(t--,s+=l),0===i&&(this.nextAudioPts=m=s),Jh.warn(`[mp4-remuxer]: Injecting ${t} audio frame @ ${(s/a).toFixed(3)}s due to ${Math.round(1e3*n/a)} ms gap.`);for(let a=0;a<t;a++){const t=Math.max(s,0);let a=Cm.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);a||(Jh.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),a=r.unit.subarray()),p.splice(i,0,{unit:a,pts:t}),s+=l,i++}}r.pts=s,s+=l}}let A,b=null,_=null,v=0,S=p.length;for(;S--;)v+=p[S].unit.byteLength;for(let t=0,s=p.length;t<s;t++){const s=p[t],r=s.unit;let a=s.pts;if(null!==_){c[t-1].duration=Math.round((a-_)/o)}else{if(i&&"aac"===e.segmentCodec&&(a=m),b=a,!(v>0))return;v+=f;try{A=new Uint8Array(v)}catch(e){return void this.observer.emit(jh.ERROR,jh.ERROR,{type:zh.MUX_ERROR,details:Gh.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:v,reason:`fail allocating audio mdat ${v}`})}if(!h){new DataView(A.buffer).setUint32(0,v),A.set(xm.types.mdat,4)}}A.set(r,f);const l=r.byteLength;f+=l,c.push(new jm(!0,n,l,0)),_=a}const w=c.length;if(!w)return;const E=c[c.length-1];this.nextAudioPts=m=_+o*E.duration;const T=h?new Uint8Array(0):xm.moof(e.sequenceNumber++,b/o,Uh({},e,{samples:c}));e.samples=[];const k=b/a,C=m/a,R={data1:T,data2:A,startPTS:k,endPTS:C,startDTS:k,endDTS:C,type:"audio",hasAudio:!0,hasVideo:!1,nb:w};return this.isAudioContiguous=!0,R}remuxEmptyAudio(e,t,i,s){const r=e.inputTimeScale,a=r/(e.samplerate?e.samplerate:r),o=this.nextAudioPts,n=this._initDTS,l=9e4*n.baseTime/n.timescale,d=(null!==o?o:s.startDTS*r)+l,h=s.endDTS*r+l,c=1024*a,u=Math.ceil((h-d)/c),p=Cm.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(Jh.warn("[mp4-remuxer]: remux empty Audio"),!p)return void Jh.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");const f=[];for(let e=0;e<u;e++){const t=d+e*c;f.push({unit:p,pts:t,dts:t})}return e.samples=f,this.remuxAudio(e,t,i,!1)}}function Fm(e,t){let i;if(null===t)return e;for(i=t<e?-8589934592:8589934592;Math.abs(e-t)>4294967296;)e+=i;return e}function Om(e,t,i,s){const r=e.samples.length;if(!r)return;const a=e.inputTimeScale;for(let o=0;o<r;o++){const r=e.samples[o];r.pts=Fm(r.pts-i.baseTime*a/i.timescale,t*a)/a,r.dts=Fm(r.dts-s.baseTime*a/s.timescale,t*a)/a}const o=e.samples;return e.samples=[],{samples:o}}function Nm(e,t,i){const s=e.samples.length;if(!s)return;const r=e.inputTimeScale;for(let a=0;a<s;a++){const s=e.samples[a];s.pts=Fm(s.pts-i.baseTime*r/i.timescale,t*r)/r}e.samples.sort(((e,t)=>e.pts-t.pts));const a=e.samples;return e.samples=[],{samples:a}}class jm{constructor(e,t,i,s){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=t,this.size=i,this.cts=s,this.flags={isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:e?2:1,isNonSync:e?0:1}}}function zm(e,t){const i=null==e?void 0:e.codec;if(i&&i.length>4)return i;if(t===ec){if("ec-3"===i||"ac-3"===i||"alac"===i)return i;if("fLaC"===i||"Opus"===i){return Ru(i,!1)}const e="mp4a.40.5";return Jh.info(`Parsed audio codec "${i}" or audio object type not handled. Using "${e}"`),e}return Jh.warn(`Unhandled video codec "${i}"`),"hvc1"===i||"hev1"===i?"hvc1.1.6.L120.90":"av01"===i?"av01.0.04M.08":"avc1.42e01e"}try{Bm=self.performance.now.bind(self.performance)}catch(e){Jh.debug("Unable to use Performance API on this environment"),Bm=null==hc?void 0:hc.Date.now}const Gm=[{demux:class{constructor(e,t){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=t}resetTimeStamp(){}resetInitSegment(e,t,i,s){const r=this.videoTrack=Vf("video",1),a=this.audioTrack=Vf("audio",1),o=this.txtTrack=Vf("text",1);if(this.id3Track=Vf("id3",1),this.timeOffset=0,null==e||!e.byteLength)return;const n=Xc(e);if(n.video){const{id:e,timescale:t,codec:i}=n.video;r.id=e,r.timescale=o.timescale=t,r.codec=i}if(n.audio){const{id:e,timescale:t,codec:i}=n.audio;a.id=e,a.timescale=t,a.codec=i}o.id=Hc.text,r.sampleDuration=0,r.duration=a.duration=s}resetContiguity(){this.remainderData=null}static probe(e){return function(e){const t=e.byteLength;for(let i=0;i<t;){const s=Wc(e,i);if(s>8&&109===e[i+4]&&111===e[i+5]&&111===e[i+6]&&102===e[i+7])return!0;i=s>1?i+s:t}return!1}(e)}demux(e,t){this.timeOffset=t;let i=e;const s=this.videoTrack,r=this.txtTrack;if(this.config.progressive){this.remainderData&&(i=au(this.remainderData,e));const t=function(e){const t={valid:null,remainder:null},i=Yc(e,["moof"]);if(i.length<2)return t.remainder=e,t;const s=i[i.length-1];return t.valid=Sc(e,0,s.byteOffset-8),t.remainder=Sc(e,s.byteOffset-8),t}(i);this.remainderData=t.remainder,s.samples=t.valid||new Uint8Array}else s.samples=i;const a=this.extractID3Track(s,t);return r.samples=ou(t,s),{videoTrack:s,audioTrack:this.audioTrack,id3Track:a,textTrack:this.txtTrack}}flush(){const e=this.timeOffset,t=this.videoTrack,i=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;const s=this.extractID3Track(t,this.timeOffset);return i.samples=ou(e,t),{videoTrack:t,audioTrack:Vf(),id3Track:s,textTrack:Vf()}}extractID3Track(e,t){const i=this.id3Track;if(e.samples.length){const s=Yc(e.samples,["emsg"]);s&&s.forEach((e=>{const s=function(e){const t=e[0];let i="",s="",r=0,a=0,o=0,n=0,l=0,d=0;if(0===t){for(;"\0"!==$c(e.subarray(d,d+1));)i+=$c(e.subarray(d,d+1)),d+=1;for(i+=$c(e.subarray(d,d+1)),d+=1;"\0"!==$c(e.subarray(d,d+1));)s+=$c(e.subarray(d,d+1)),d+=1;s+=$c(e.subarray(d,d+1)),d+=1,r=Wc(e,12),a=Wc(e,16),n=Wc(e,20),l=Wc(e,24),d=28}else if(1===t){d+=4,r=Wc(e,d),d+=4;const t=Wc(e,d);d+=4;const a=Wc(e,d);for(d+=4,o=2**32*t+a,Oh(o)||(o=Number.MAX_SAFE_INTEGER,Jh.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),n=Wc(e,d),d+=4,l=Wc(e,d),d+=4;"\0"!==$c(e.subarray(d,d+1));)i+=$c(e.subarray(d,d+1)),d+=1;for(i+=$c(e.subarray(d,d+1)),d+=1;"\0"!==$c(e.subarray(d,d+1));)s+=$c(e.subarray(d,d+1)),d+=1;s+=$c(e.subarray(d,d+1)),d+=1}return{schemeIdUri:i,value:s,timeScale:r,presentationTime:o,presentationTimeDelta:a,eventDuration:n,id:l,payload:e.subarray(d,e.byteLength)}}(e);if(um.test(s.schemeIdUri)){const e=Fh(s.presentationTime)?s.presentationTime/s.timeScale:t+s.presentationTimeDelta/s.timeScale;let r=4294967295===s.eventDuration?Number.POSITIVE_INFINITY:s.eventDuration/s.timeScale;r<=.001&&(r=Number.POSITIVE_INFINITY);const a=s.payload;i.samples.push({data:a,len:a.byteLength,dts:e,pts:e,type:op,duration:r})}}))}return i}demuxSampleAes(e,t,i){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){}},remux:class{constructor(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null}destroy(){}resetTimeStamp(e){this.initPTS=e,this.lastEndTime=null}resetNextTimestamp(){this.lastEndTime=null}resetInitSegment(e,t,i,s){this.audioCodec=t,this.videoCodec=i,this.generateInitSegment(function(e,t){if(!e||!t)return e;const i=t.keyId;i&&t.isCommonEncryption&&Yc(e,["moov","trak"]).forEach((e=>{const t=Yc(e,["mdia","minf","stbl","stsd"])[0].subarray(8);let s=Yc(t,["enca"]);const r=s.length>0;r||(s=Yc(t,["encv"])),s.forEach((e=>{Yc(r?e.subarray(28):e.subarray(78),["sinf"]).forEach((e=>{const t=su(e);if(t){const e=t.subarray(8,24);e.some((e=>0!==e))||(Jh.log(`[eme] Patching keyId in 'enc${r?"a":"v"}>sinf>>tenc' box: ${jc(e)} -> ${jc(i)}`),t.set(i,8))}}))}))}));return e}(e,s)),this.emitInitSegment=!0}generateInitSegment(e){let{audioCodec:t,videoCodec:i}=this;if(null==e||!e.byteLength)return this.initTracks=void 0,void(this.initData=void 0);const s=this.initData=Xc(e);s.audio&&(t=zm(s.audio,ec)),s.video&&(i=zm(s.video,tc));const r={};s.audio&&s.video?r.audiovideo={container:"video/mp4",codec:t+","+i,initSegment:e,id:"main"}:s.audio?r.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:s.video?r.video={container:"video/mp4",codec:i,initSegment:e,id:"main"}:Jh.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=r}remux(e,t,i,s,r,a){var o,n;let{initPTS:l,lastEndTime:d}=this;const h={audio:void 0,video:void 0,text:s,id3:i,initSegment:void 0};Fh(d)||(d=this.lastEndTime=r||0);const c=t.samples;if(null==c||!c.length)return h;const u={initPTS:void 0,timescale:1};let p=this.initData;if(null!=(o=p)&&o.length||(this.generateInitSegment(c),p=this.initData),null==(n=p)||!n.length)return Jh.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),h;this.emitInitSegment&&(u.tracks=this.initTracks,this.emitInitSegment=!1);const f=function(e,t){let i=0,s=0,r=0;const a=Yc(e,["moof","traf"]);for(let e=0;e<a.length;e++){const o=a[e],n=Yc(o,["tfhd"])[0],l=t[Wc(n,4)];if(!l)continue;const d=l.default,h=Wc(n,0)|(null==d?void 0:d.flags);let c=null==d?void 0:d.duration;8&h&&(c=Wc(n,2&h?12:8));const u=l.timescale||9e4,p=Yc(o,["trun"]);for(let e=0;e<p.length;e++)i=ru(p[e]),!i&&c&&(i=c*Wc(p[e],4)),l.type===tc?s+=i/u:l.type===ec&&(r+=i/u)}if(0===s&&0===r){let t=1/0,i=0,s=0;const r=Yc(e,["sidx"]);for(let e=0;e<r.length;e++){const a=Qc(r[e]);if(null!=a&&a.references){t=Math.min(t,a.earliestPresentationTime/a.timescale);const e=a.references.reduce(((e,t)=>e+t.info.duration||0),0);i=Math.max(i,e+a.earliestPresentationTime/a.timescale),s=i-t}}if(s&&Fh(s))return s}return s||r}(c,p),m=function(e,t){return Yc(t,["moof","traf"]).reduce(((t,i)=>{const s=Yc(i,["tfdt"])[0],r=s[0],a=Yc(i,["tfhd"]).reduce(((t,i)=>{const a=Wc(i,4),o=e[a];if(o){let e=Wc(s,4);if(1===r){if(e===zc)return Jh.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),t;e*=zc+1,e+=Wc(s,8)}const i=e/(o.timescale||9e4);if(Fh(i)&&(null===t||i<t))return i}return t}),null);return null!==a&&Fh(a)&&(null===t||a<t)?a:t}),null)}(p,c),g=null===m?r:m;(function(e,t,i,s){if(null===e)return!0;const r=Math.max(s,1),a=t-e.baseTime/e.timescale;return Math.abs(a-i)>r}(l,g,r,f)||u.timescale!==l.timescale&&a)&&(u.initPTS=g-r,l&&1===l.timescale&&Jh.warn("Adjusting initPTS by "+(u.initPTS-l.baseTime)),this.initPTS=l={baseTime:u.initPTS,timescale:1});const y=e?g-l.baseTime/l.timescale:d,A=y+f;!function(e,t,i){Yc(t,["moof","traf"]).forEach((t=>{Yc(t,["tfhd"]).forEach((s=>{const r=Wc(s,4),a=e[r];if(!a)return;const o=a.timescale||9e4;Yc(t,["tfdt"]).forEach((e=>{const t=e[0],s=i*o;if(s){let i=Wc(e,4);if(0===t)i-=s,i=Math.max(i,0),Kc(e,4,i);else{i*=Math.pow(2,32),i+=Wc(e,8),i-=s,i=Math.max(i,0);const t=Math.floor(i/(zc+1)),r=Math.floor(i%(zc+1));Kc(e,4,t),Kc(e,8,r)}}}))}))}))}(p,c,l.baseTime/l.timescale),f>0?this.lastEndTime=A:(Jh.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const b=!!p.audio,_=!!p.video;let v="";b&&(v+="audio"),_&&(v+="video");const S={data1:c,startPTS:y,startDTS:y,endPTS:A,endDTS:A,type:v,hasAudio:b,hasVideo:_,nb:1,dropped:0};return h.audio="audio"===S.type?S:void 0,h.video="audio"!==S.type?S:void 0,h.initSegment=u,h.id3=Om(i,r,l,l),s.samples.length&&(h.text=Nm(s,r,l)),h}}},{demux:vm,remux:Um},{demux:class extends Wf{constructor(e,t){super(),this.observer=void 0,this.config=void 0,this.observer=e,this.config=t}resetInitSegment(e,t,i,s){super.resetInitSegment(e,t,i,s),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;const t=Tc(e,0);let i=(null==t?void 0:t.length)||0;if(cm(e,i))return!1;for(let t=e.length;i<t;i++)if(Xf(e,i))return Jh.log("ADTS sync word found !"),!0;return!1}canParse(e,t){return function(e,t){return function(e,t){return t+5<e.length}(e,t)&&qf(e,t)&&Yf(e,t)<=e.length-t}(e,t)}appendFrame(e,t,i){Zf(e,this.observer,t,i,e.manifestCodec);const s=tm(e,t,i,this.basePTS,this.frameIndex);if(s&&0===s.missing)return s}},remux:Um},{demux:class extends Wf{resetInitSegment(e,t,i,s){super.resetInitSegment(e,t,i,s),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;const t=Tc(e,0);let i=(null==t?void 0:t.length)||0;if(t&&11===e[i]&&119===e[i+1]&&void 0!==Rc(t)&&pm(e,i)<=16)return!1;for(let t=e.length;i<t;i++)if(cm(e,i))return Jh.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return function(e,t){return dm(e,t)&&4<=e.length-t}(e,t)}appendFrame(e,t,i){if(null!==this.basePTS)return nm(e,t,i,this.basePTS,this.frameIndex)}},remux:Um}];Gm.splice(2,0,{demux:fm,remux:Um});class Hm{constructor(e,t,i,s,r){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=e,this.typeSupported=t,this.config=i,this.vendor=s,this.id=r}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(e,t,i,s){const r=i.transmuxing;r.executeStart=Bm();let a=new Uint8Array(e);const{currentTransmuxState:o,transmuxConfig:n}=this;s&&(this.currentTransmuxState=s);const{contiguous:l,discontinuity:d,trackSwitch:h,accurateTimeOffset:c,timeOffset:u,initSegmentChange:p}=s||o,{audioCodec:f,videoCodec:m,defaultInitPts:g,duration:y,initSegmentData:A}=n,b=function(e,t){let i=null;e.byteLength>0&&null!=(null==t?void 0:t.key)&&null!==t.iv&&null!=t.method&&(i=t);return i}(a,t);if(b&&"AES-128"===b.method){const e=this.getDecrypter();if(!e.isSync())return this.decryptionPromise=e.webCryptoDecrypt(a,b.key.buffer,b.iv.buffer).then((e=>{const t=this.push(e,null,i);return this.decryptionPromise=null,t})),this.decryptionPromise;{let t=e.softwareDecrypt(a,b.key.buffer,b.iv.buffer);if(i.part>-1&&(t=e.flush()),!t)return r.executeEnd=Bm(),$m(i);a=new Uint8Array(t)}}const _=this.needsProbing(d,h);if(_){const e=this.configureTransmuxer(a);if(e)return Jh.warn(`[transmuxer] ${e.message}`),this.observer.emit(jh.ERROR,jh.ERROR,{type:zh.MEDIA_ERROR,details:Gh.FRAG_PARSING_ERROR,fatal:!1,error:e,reason:e.message}),r.executeEnd=Bm(),$m(i)}(d||h||p||_)&&this.resetInitSegment(A,f,m,y,t),(d||p||_)&&this.resetInitialTimestamp(g),l||this.resetContiguity();const v=this.transmux(a,b,u,c,i),S=this.currentTransmuxState;return S.contiguous=!0,S.discontinuity=!1,S.trackSwitch=!1,r.executeEnd=Bm(),v}flush(e){const t=e.transmuxing;t.executeStart=Bm();const{decrypter:i,currentTransmuxState:s,decryptionPromise:r}=this;if(r)return r.then((()=>this.flush(e)));const a=[],{timeOffset:o}=s;if(i){const t=i.flush();t&&a.push(this.push(t,null,e))}const{demuxer:n,remuxer:l}=this;if(!n||!l)return t.executeEnd=Bm(),[$m(e)];const d=n.flush(o);return Vm(d)?d.then((t=>(this.flushRemux(a,t,e),a))):(this.flushRemux(a,d,e),a)}flushRemux(e,t,i){const{audioTrack:s,videoTrack:r,id3Track:a,textTrack:o}=t,{accurateTimeOffset:n,timeOffset:l}=this.currentTransmuxState;Jh.log(`[transmuxer.ts]: Flushed fragment ${i.sn}${i.part>-1?" p: "+i.part:""} of level ${i.level}`);const d=this.remuxer.remux(s,r,a,o,l,n,!0,this.id);e.push({remuxResult:d,chunkMeta:i}),i.transmuxing.executeEnd=Bm()}resetInitialTimestamp(e){const{demuxer:t,remuxer:i}=this;t&&i&&(t.resetTimeStamp(e),i.resetTimeStamp(e))}resetContiguity(){const{demuxer:e,remuxer:t}=this;e&&t&&(e.resetContiguity(),t.resetNextTimestamp())}resetInitSegment(e,t,i,s,r){const{demuxer:a,remuxer:o}=this;a&&o&&(a.resetInitSegment(e,t,i,s),o.resetInitSegment(e,t,i,r))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(e,t,i,s,r){let a;return a=t&&"SAMPLE-AES"===t.method?this.transmuxSampleAes(e,t,i,s,r):this.transmuxUnencrypted(e,i,s,r),a}transmuxUnencrypted(e,t,i,s){const{audioTrack:r,videoTrack:a,id3Track:o,textTrack:n}=this.demuxer.demux(e,t,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(r,a,o,n,t,i,!1,this.id),chunkMeta:s}}transmuxSampleAes(e,t,i,s,r){return this.demuxer.demuxSampleAes(e,t,i).then((e=>({remuxResult:this.remuxer.remux(e.audioTrack,e.videoTrack,e.id3Track,e.textTrack,i,s,!1,this.id),chunkMeta:r})))}configureTransmuxer(e){const{config:t,observer:i,typeSupported:s,vendor:r}=this;let a;for(let t=0,i=Gm.length;t<i;t++){var o;if(null!=(o=Gm[t].demux)&&o.probe(e)){a=Gm[t];break}}if(!a)return new Error("Failed to find demuxer by probing fragment data");const n=this.demuxer,l=this.remuxer,d=a.remux,h=a.demux;l&&l instanceof d||(this.remuxer=new d(i,t,s,r)),n&&n instanceof h||(this.demuxer=new h(i,t,s),this.probe=h.probe)}needsProbing(e,t){return!this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new xf(this.config)),e}}const $m=e=>({remuxResult:{},chunkMeta:e});function Vm(e){return"then"in e&&e.then instanceof Function}class Wm{constructor(e,t,i,s,r){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=e,this.videoCodec=t,this.initSegmentData=i,this.duration=s,this.defaultInitPts=r||null}}class Jm{constructor(e,t,i,s,r,a){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=e,this.contiguous=t,this.accurateTimeOffset=i,this.trackSwitch=s,this.timeOffset=r,this.initSegmentChange=a}}var qm={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,i="~";function s(){}function r(e,t,i){this.fn=e,this.context=t,this.once=i||!1}function a(e,t,s,a,o){if("function"!=typeof s)throw new TypeError("The listener must be a function");var n=new r(s,a||e,o),l=i?i+t:t;return e._events[l]?e._events[l].fn?e._events[l]=[e._events[l],n]:e._events[l].push(n):(e._events[l]=n,e._eventsCount++),e}function o(e,t){0==--e._eventsCount?e._events=new s:delete e._events[t]}function n(){this._events=new s,this._eventsCount=0}Object.create&&(s.prototype=Object.create(null),(new s).__proto__||(i=!1)),n.prototype.eventNames=function(){var e,s,r=[];if(0===this._eventsCount)return r;for(s in e=this._events)t.call(e,s)&&r.push(i?s.slice(1):s);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(e)):r},n.prototype.listeners=function(e){var t=i?i+e:e,s=this._events[t];if(!s)return[];if(s.fn)return[s.fn];for(var r=0,a=s.length,o=new Array(a);r<a;r++)o[r]=s[r].fn;return o},n.prototype.listenerCount=function(e){var t=i?i+e:e,s=this._events[t];return s?s.fn?1:s.length:0},n.prototype.emit=function(e,t,s,r,a,o){var n=i?i+e:e;if(!this._events[n])return!1;var l,d,h=this._events[n],c=arguments.length;if(h.fn){switch(h.once&&this.removeListener(e,h.fn,void 0,!0),c){case 1:return h.fn.call(h.context),!0;case 2:return h.fn.call(h.context,t),!0;case 3:return h.fn.call(h.context,t,s),!0;case 4:return h.fn.call(h.context,t,s,r),!0;case 5:return h.fn.call(h.context,t,s,r,a),!0;case 6:return h.fn.call(h.context,t,s,r,a,o),!0}for(d=1,l=new Array(c-1);d<c;d++)l[d-1]=arguments[d];h.fn.apply(h.context,l)}else{var u,p=h.length;for(d=0;d<p;d++)switch(h[d].once&&this.removeListener(e,h[d].fn,void 0,!0),c){case 1:h[d].fn.call(h[d].context);break;case 2:h[d].fn.call(h[d].context,t);break;case 3:h[d].fn.call(h[d].context,t,s);break;case 4:h[d].fn.call(h[d].context,t,s,r);break;default:if(!l)for(u=1,l=new Array(c-1);u<c;u++)l[u-1]=arguments[u];h[d].fn.apply(h[d].context,l)}}return!0},n.prototype.on=function(e,t,i){return a(this,e,t,i,!1)},n.prototype.once=function(e,t,i){return a(this,e,t,i,!0)},n.prototype.removeListener=function(e,t,s,r){var a=i?i+e:e;if(!this._events[a])return this;if(!t)return o(this,a),this;var n=this._events[a];if(n.fn)n.fn!==t||r&&!n.once||s&&n.context!==s||o(this,a);else{for(var l=0,d=[],h=n.length;l<h;l++)(n[l].fn!==t||r&&!n[l].once||s&&n[l].context!==s)&&d.push(n[l]);d.length?this._events[a]=1===d.length?d[0]:d:o(this,a)}return this},n.prototype.removeAllListeners=function(e){var t;return e?(t=i?i+e:e,this._events[t]&&o(this,t)):(this._events=new s,this._eventsCount=0),this},n.prototype.off=n.prototype.removeListener,n.prototype.addListener=n.prototype.on,n.prefixed=i,n.EventEmitter=n,e.exports=n}(qm);var Km=xh(qm.exports);class Ym{constructor(e,t,i,s){this.error=null,this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;const r=e.config;this.hls=e,this.id=t,this.useWorker=!!r.enableWorker,this.onTransmuxComplete=i,this.onFlush=s;const a=(e,t)=>{(t=t||{}).frag=this.frag,t.id=this.id,e===jh.ERROR&&(this.error=t.error),this.hls.trigger(e,t)};this.observer=new Km,this.observer.on(jh.FRAG_DECRYPTED,a),this.observer.on(jh.ERROR,a);const o=bu(r.preferManagedMediaSource)||{isTypeSupported:()=>!1},n={mpeg:o.isTypeSupported("audio/mpeg"),mp3:o.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:o.isTypeSupported('audio/mp4; codecs="ac-3"')},l=navigator.vendor;if(this.useWorker&&"undefined"!=typeof Worker){if(r.workerPath||"function"==typeof __HLS_WORKER_BUNDLE__){try{r.workerPath?(Jh.log(`loading Web Worker ${r.workerPath} for "${t}"`),this.workerContext=function(e){const t=new self.URL(e,self.location.href).href;return{worker:new self.Worker(t),scriptURL:t}}(r.workerPath)):(Jh.log(`injecting Web Worker for "${t}"`),this.workerContext=function(){const e=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),t=self.URL.createObjectURL(e);return{worker:new self.Worker(t),objectURL:t}}()),this.onwmsg=e=>this.onWorkerMessage(e);const{worker:e}=this.workerContext;e.addEventListener("message",this.onwmsg),e.onerror=e=>{const i=new Error(`${e.message} (${e.filename}:${e.lineno})`);r.enableWorker=!1,Jh.warn(`Error in "${t}" Web Worker, fallback to inline`),this.hls.trigger(jh.ERROR,{type:zh.OTHER_ERROR,details:Gh.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:i})},e.postMessage({cmd:"init",typeSupported:n,vendor:l,id:t,config:JSON.stringify(r)})}catch(e){Jh.warn(`Error setting up "${t}" Web Worker, fallback to inline`,e),this.resetWorker(),this.error=null,this.transmuxer=new Hm(this.observer,n,r,l,t)}return}}this.transmuxer=new Hm(this.observer,n,r,l,t)}resetWorker(){if(this.workerContext){const{worker:e,objectURL:t}=this.workerContext;t&&self.URL.revokeObjectURL(t),e.removeEventListener("message",this.onwmsg),e.onerror=null,e.terminate(),this.workerContext=null}}destroy(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{const e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}const e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null}push(e,t,i,s,r,a,o,n,l,d){var h,c;l.transmuxing.start=self.performance.now();const{transmuxer:u}=this,p=a?a.start:r.start,f=r.decryptdata,m=this.frag,g=!(m&&r.cc===m.cc),y=!(m&&l.level===m.level),A=m?l.sn-m.sn:-1,b=this.part?l.part-this.part.index:-1,_=0===A&&l.id>1&&l.id===(null==m?void 0:m.stats.chunkCount),v=!y&&(1===A||0===A&&(1===b||_&&b<=0)),S=self.performance.now();(y||A||0===r.stats.parsing.start)&&(r.stats.parsing.start=S),!a||!b&&v||(a.stats.parsing.start=S);const w=!(m&&(null==(h=r.initSegment)?void 0:h.url)===(null==(c=m.initSegment)?void 0:c.url)),E=new Jm(g,v,n,y,p,w);if(!v||g||w){Jh.log(`[transmuxer-interface, ${r.type}]: Starting new transmux session for sn: ${l.sn} p: ${l.part} level: ${l.level} id: ${l.id}\n discontinuity: ${g}\n trackSwitch: ${y}\n contiguous: ${v}\n accurateTimeOffset: ${n}\n timeOffset: ${p}\n initSegmentChange: ${w}`);const e=new Wm(i,s,t,o,d);this.configureTransmuxer(e)}if(this.frag=r,this.part=a,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:f,chunkMeta:l,state:E},e instanceof ArrayBuffer?[e]:[]);else if(u){const t=u.push(e,f,l,E);Vm(t)?(u.async=!0,t.then((e=>{this.handleTransmuxComplete(e)})).catch((e=>{this.transmuxerError(e,l,"transmuxer-interface push error")}))):(u.async=!1,this.handleTransmuxComplete(t))}}flush(e){e.transmuxing.start=self.performance.now();const{transmuxer:t}=this;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:e});else if(t){let i=t.flush(e);Vm(i)||t.async?(Vm(i)||(i=Promise.resolve(i)),i.then((t=>{this.handleFlushResult(t,e)})).catch((t=>{this.transmuxerError(t,e,"transmuxer-interface flush error")}))):this.handleFlushResult(i,e)}}transmuxerError(e,t,i){this.hls&&(this.error=e,this.hls.trigger(jh.ERROR,{type:zh.MEDIA_ERROR,details:Gh.FRAG_PARSING_ERROR,chunkMeta:t,fatal:!1,error:e,err:e,reason:i}))}handleFlushResult(e,t){e.forEach((e=>{this.handleTransmuxComplete(e)})),this.onFlush(t)}onWorkerMessage(e){const t=e.data,i=this.hls;switch(t.event){case"init":{var s;const e=null==(s=this.workerContext)?void 0:s.objectURL;e&&self.URL.revokeObjectURL(e);break}case"transmuxComplete":this.handleTransmuxComplete(t.data);break;case"flush":this.onFlush(t.data);break;case"workerLog":Jh[t.data.logType]&&Jh[t.data.logType](t.data.message);break;default:t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,i.trigger(t.event,t.data)}}configureTransmuxer(e){const{transmuxer:t}=this;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:e}):t&&t.configure(e)}handleTransmuxComplete(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}}function Qm(e,t){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!Xm(e[i].attrs,t[i].attrs))return!1;return!0}function Xm(e,t,i){const s=e["STABLE-RENDITION-ID"];return s&&!i?s===t["STABLE-RENDITION-ID"]:!(i||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).some((i=>e[i]!==t[i]))}function Zm(e,t){return t.label.toLowerCase()===e.name.toLowerCase()&&(!t.language||t.language.toLowerCase()===(e.lang||"").toLowerCase())}class eg{constructor(e){this.buffered=void 0;const t=(t,i,s)=>{if((i>>>=0)>s-1)throw new DOMException(`Failed to execute '${t}' on 'TimeRanges': The index provided (${i}) is greater than the maximum bound (${s})`);return e[i][t]};this.buffered={get length(){return e.length},end:i=>t("end",i,e.length),start:i=>t("start",i,e.length)}}}class tg{constructor(e){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=e}append(e,t,i){const s=this.queues[t];s.push(e),1!==s.length||i||this.executeNext(t)}insertAbort(e,t){this.queues[t].unshift(e),this.executeNext(t)}appendBlocker(e){let t;const i=new Promise((e=>{t=e})),s={execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};return this.append(s,e),i}executeNext(e){const t=this.queues[e];if(t.length){const i=t[0];try{i.execute()}catch(t){Jh.warn(`[buffer-operation-queue]: Exception executing "${e}" SourceBuffer operation: ${t}`),i.onError(t);const s=this.buffers[e];null!=s&&s.updating||this.shiftAndExecuteNext(e)}}}shiftAndExecuteNext(e){this.queues[e].shift(),this.executeNext(e)}current(e){return this.queues[e][0]}}const ig=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/;function sg(e){const t=e.querySelectorAll("source");[].slice.call(t).forEach((t=>{e.removeChild(t)}))}const rg={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},ag=function(e){let t=e;return rg.hasOwnProperty(e)&&(t=rg[e]),String.fromCharCode(t)},og=15,ng=100,lg={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},dg={17:2,18:4,21:6,22:8,23:10,19:13,20:15},hg={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},cg={25:2,26:4,29:6,30:8,31:10,27:13,28:15},ug=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class pg{constructor(){this.time=null,this.verboseLevel=0}log(e,t){if(this.verboseLevel>=e){const i="function"==typeof t?t():t;Jh.log(`${this.time} [${e}] ${i}`)}}}const fg=function(e){const t=[];for(let i=0;i<e.length;i++)t.push(e[i].toString(16));return t};class mg{constructor(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}reset(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}setStyles(e){const t=["foreground","underline","italics","background","flash"];for(let i=0;i<t.length;i++){const s=t[i];e.hasOwnProperty(s)&&(this[s]=e[s])}}isDefault(){return"white"===this.foreground&&!this.underline&&!this.italics&&"black"===this.background&&!this.flash}equals(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash}copy(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash}toString(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}}class gg{constructor(){this.uchar=" ",this.penState=new mg}reset(){this.uchar=" ",this.penState.reset()}setChar(e,t){this.uchar=e,this.penState.copy(t)}setPenState(e){this.penState.copy(e)}equals(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)}copy(e){this.uchar=e.uchar,this.penState.copy(e.penState)}isEmpty(){return" "===this.uchar&&this.penState.isDefault()}}class yg{constructor(e){this.chars=[],this.pos=0,this.currPenState=new mg,this.cueStartTime=null,this.logger=void 0;for(let e=0;e<ng;e++)this.chars.push(new gg);this.logger=e}equals(e){for(let t=0;t<ng;t++)if(!this.chars[t].equals(e.chars[t]))return!1;return!0}copy(e){for(let t=0;t<ng;t++)this.chars[t].copy(e.chars[t])}isEmpty(){let e=!0;for(let t=0;t<ng;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e}setCursor(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>ng&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=ng)}moveCursor(e){const t=this.pos+e;if(e>1)for(let e=this.pos+1;e<t+1;e++)this.chars[e].setPenState(this.currPenState);this.setCursor(t)}backSpace(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}insertChar(e){e>=144&&this.backSpace();const t=ag(e);this.pos>=ng?this.logger.log(0,(()=>"Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!")):(this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1))}clearFromPos(e){let t;for(t=e;t<ng;t++)this.chars[t].reset()}clear(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}clearToEndOfRow(){this.clearFromPos(this.pos)}getTextString(){const e=[];let t=!0;for(let i=0;i<ng;i++){const s=this.chars[i].uchar;" "!==s&&(t=!1),e.push(s)}return t?"":e.join("")}setPenStyles(e){this.currPenState.setStyles(e);this.chars[this.pos].setPenState(this.currPenState)}}class Ag{constructor(e){this.rows=[],this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(let t=0;t<og;t++)this.rows.push(new yg(e));this.logger=e}reset(){for(let e=0;e<og;e++)this.rows[e].clear();this.currRow=14}equals(e){let t=!0;for(let i=0;i<og;i++)if(!this.rows[i].equals(e.rows[i])){t=!1;break}return t}copy(e){for(let t=0;t<og;t++)this.rows[t].copy(e.rows[t])}isEmpty(){let e=!0;for(let t=0;t<og;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e}backSpace(){this.rows[this.currRow].backSpace()}clearToEndOfRow(){this.rows[this.currRow].clearToEndOfRow()}insertChar(e){this.rows[this.currRow].insertChar(e)}setPen(e){this.rows[this.currRow].setPenStyles(e)}moveCursor(e){this.rows[this.currRow].moveCursor(e)}setCursor(e){this.logger.log(2,"setCursor: "+e);this.rows[this.currRow].setCursor(e)}setPAC(e){this.logger.log(2,(()=>"pacData = "+JSON.stringify(e)));let t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(let e=0;e<og;e++)this.rows[e].clear();const e=this.currRow+1-this.nrRollUpRows,i=this.lastOutputScreen;if(i){const s=i.rows[e].cueStartTime,r=this.logger.time;if(null!==s&&null!==r&&s<r)for(let s=0;s<this.nrRollUpRows;s++)this.rows[t-this.nrRollUpRows+s+1].copy(i.rows[e+s])}}this.currRow=t;const i=this.rows[this.currRow];if(null!==e.indent){const t=e.indent,s=Math.max(t-1,0);i.setCursor(e.indent),e.color=i.chars[s].penState.foreground}const s={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(s)}setBkgData(e){this.logger.log(2,(()=>"bkgData = "+JSON.stringify(e))),this.backSpace(),this.setPen(e),this.insertChar(32)}setRollUpRows(e){this.nrRollUpRows=e}rollUp(){if(null===this.nrRollUpRows)return void this.logger.log(3,"roll_up but nrRollUpRows not set yet");this.logger.log(1,(()=>this.getDisplayText()));const e=this.currRow+1-this.nrRollUpRows,t=this.rows.splice(e,1)[0];t.clear(),this.rows.splice(this.currRow,0,t),this.logger.log(2,"Rolling up")}getDisplayText(e){e=e||!1;const t=[];let i="",s=-1;for(let i=0;i<og;i++){const r=this.rows[i].getTextString();r&&(s=i+1,e?t.push("Row "+s+": '"+r+"'"):t.push(r.trim()))}return t.length>0&&(i=e?"["+t.join(" | ")+"]":t.join("\n")),i}getTextAndFormat(){return this.rows}}class bg{constructor(e,t,i){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=e,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new Ag(i),this.nonDisplayedMemory=new Ag(i),this.lastOutputScreen=new Ag(i),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=i}reset(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}getHandler(){return this.outputFilter}setHandler(e){this.outputFilter=e}setPAC(e){this.writeScreen.setPAC(e)}setBkgData(e){this.writeScreen.setBkgData(e)}setMode(e){e!==this.mode&&(this.mode=e,this.logger.log(2,(()=>"MODE="+e)),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)}insertChars(e){for(let t=0;t<e.length;t++)this.writeScreen.insertChar(e[t]);const t=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,(()=>t+": "+this.writeScreen.getDisplayText(!0))),"MODE_PAINT-ON"!==this.mode&&"MODE_ROLL-UP"!==this.mode||(this.logger.log(1,(()=>"DISPLAYED: "+this.displayedMemory.getDisplayText(!0))),this.outputDataUpdate())}ccRCL(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}ccBS(){this.logger.log(2,"BS - BackSpace"),"MODE_TEXT"!==this.mode&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}ccAOF(){}ccAON(){}ccDER(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}ccRU(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)}ccFON(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}ccRDC(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}ccTR(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}ccRTD(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}ccEDM(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}ccCR(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}ccENM(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}ccEOC(){if(this.logger.log(2,"EOC - End Of Caption"),"MODE_POP-ON"===this.mode){const e=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,(()=>"DISP: "+this.displayedMemory.getDisplayText()))}this.outputDataUpdate(!0)}ccTO(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)}ccMIDROW(e){const t={flash:!1};if(t.underline=e%2==1,t.italics=e>=46,t.italics)t.foreground="white";else{const i=Math.floor(e/2)-16,s=["white","green","blue","cyan","red","yellow","magenta"];t.foreground=s[i]}this.logger.log(2,"MIDROW: "+JSON.stringify(t)),this.writeScreen.setPen(t)}outputDataUpdate(e=!1){const t=this.logger.time;null!==t&&this.outputFilter&&(null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t):this.cueStartTime=t,this.lastOutputScreen.copy(this.displayedMemory))}cueSplitAtTime(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))}}class _g{constructor(e,t,i){this.channels=void 0,this.currentChannel=0,this.cmdHistory={a:null,b:null},this.logger=void 0;const s=this.logger=new pg;this.channels=[null,new bg(e,t,s),new bg(e+1,i,s)]}getHandler(e){return this.channels[e].getHandler()}setHandler(e,t){this.channels[e].setHandler(t)}addData(e,t){let i,s,r,a=!1;this.logger.time=e;for(let e=0;e<t.length;e+=2)if(s=127&t[e],r=127&t[e+1],0!==s||0!==r){if(this.logger.log(3,"["+fg([t[e],t[e+1]])+"] -> ("+fg([s,r])+")"),i=this.parseCmd(s,r),i||(i=this.parseMidrow(s,r)),i||(i=this.parsePAC(s,r)),i||(i=this.parseBackgroundAttributes(s,r)),!i&&(a=this.parseChars(s,r),a)){const e=this.currentChannel;if(e&&e>0){this.channels[e].insertChars(a)}else this.logger.log(2,"No channel found yet. TEXT-MODE?")}i||a||this.logger.log(2,"Couldn't parse cleaned data "+fg([s,r])+" orig: "+fg([t[e],t[e+1]]))}}parseCmd(e,t){const{cmdHistory:i}=this;if(!((20===e||28===e||21===e||29===e)&&t>=32&&t<=47)&&!((23===e||31===e)&&t>=33&&t<=35))return!1;if(Sg(e,t,i))return vg(null,null,i),this.logger.log(3,"Repeated command ("+fg([e,t])+") is dropped"),!0;const s=20===e||21===e||23===e?1:2,r=this.channels[s];return 20===e||21===e||28===e||29===e?32===t?r.ccRCL():33===t?r.ccBS():34===t?r.ccAOF():35===t?r.ccAON():36===t?r.ccDER():37===t?r.ccRU(2):38===t?r.ccRU(3):39===t?r.ccRU(4):40===t?r.ccFON():41===t?r.ccRDC():42===t?r.ccTR():43===t?r.ccRTD():44===t?r.ccEDM():45===t?r.ccCR():46===t?r.ccENM():47===t&&r.ccEOC():r.ccTO(t-32),vg(e,t,i),this.currentChannel=s,!0}parseMidrow(e,t){let i=0;if((17===e||25===e)&&t>=32&&t<=47){if(i=17===e?1:2,i!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;const s=this.channels[i];return!!s&&(s.ccMIDROW(t),this.logger.log(3,"MIDROW ("+fg([e,t])+")"),!0)}return!1}parsePAC(e,t){let i;const s=this.cmdHistory;if(!((e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127)&&!((16===e||24===e)&&t>=64&&t<=95))return!1;if(Sg(e,t,s))return vg(null,null,s),!0;const r=e<=23?1:2;i=t>=64&&t<=95?1===r?lg[e]:hg[e]:1===r?dg[e]:cg[e];const a=this.channels[r];return!!a&&(a.setPAC(this.interpretPAC(i,t)),vg(e,t,s),this.currentChannel=r,!0)}interpretPAC(e,t){let i;const s={color:null,italics:!1,indent:null,underline:!1,row:e};return i=t>95?t-96:t-64,s.underline=!(1&~i),i<=13?s.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(i/2)]:i<=15?(s.italics=!0,s.color="white"):s.indent=4*Math.floor((i-16)/2),s}parseChars(e,t){let i,s=null,r=null;if(e>=25?(i=2,r=e-8):(i=1,r=e),r>=17&&r<=19){let e;e=17===r?t+80:18===r?t+112:t+144,this.logger.log(2,"Special char '"+ag(e)+"' in channel "+i),s=[e]}else e>=32&&e<=127&&(s=0===t?[e]:[e,t]);if(s){const i=fg(s);this.logger.log(3,"Char codes = "+i.join(",")),vg(e,t,this.cmdHistory)}return s}parseBackgroundAttributes(e,t){if(!((16===e||24===e)&&t>=32&&t<=47)&&!((23===e||31===e)&&t>=45&&t<=47))return!1;let i;const s={};16===e||24===e?(i=Math.floor((t-32)/2),s.background=ug[i],t%2==1&&(s.background=s.background+"_semi")):45===t?s.background="transparent":(s.foreground="black",47===t&&(s.underline=!0));const r=e<=23?1:2;return this.channels[r].setBkgData(s),vg(e,t,this.cmdHistory),!0}reset(){for(let e=0;e<Object.keys(this.channels).length;e++){const t=this.channels[e];t&&t.reset()}this.cmdHistory={a:null,b:null}}cueSplitAtTime(e){for(let t=0;t<this.channels.length;t++){const i=this.channels[t];i&&i.cueSplitAtTime(e)}}}function vg(e,t,i){i.a=e,i.b=t}function Sg(e,t,i){return i.a===e&&i.b===t}class wg{constructor(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}dispatchCue(){null!==this.startTime&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(e,t,i){(null===this.startTime||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=i,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}}var Eg=function(){if(null!=hc&&hc.VTTCue)return self.VTTCue;const e=["","lr","rl"],t=["start","middle","end","left","right"];function i(e,t){if("string"!=typeof t)return!1;if(!Array.isArray(e))return!1;const i=t.toLowerCase();return!!~e.indexOf(i)&&i}function s(e){return i(t,e)}function r(e,...t){let i=1;for(;i<arguments.length;i++){const t=arguments[i];for(const i in t)e[i]=t[i]}return e}function a(t,a,o){const n=this,l={enumerable:!0};n.hasBeenReset=!1;let d="",h=!1,c=t,u=a,p=o,f=null,m="",g=!0,y="auto",A="start",b=50,_="middle",v=50,S="middle";Object.defineProperty(n,"id",r({},l,{get:function(){return d},set:function(e){d=""+e}})),Object.defineProperty(n,"pauseOnExit",r({},l,{get:function(){return h},set:function(e){h=!!e}})),Object.defineProperty(n,"startTime",r({},l,{get:function(){return c},set:function(e){if("number"!=typeof e)throw new TypeError("Start time must be set to a number.");c=e,this.hasBeenReset=!0}})),Object.defineProperty(n,"endTime",r({},l,{get:function(){return u},set:function(e){if("number"!=typeof e)throw new TypeError("End time must be set to a number.");u=e,this.hasBeenReset=!0}})),Object.defineProperty(n,"text",r({},l,{get:function(){return p},set:function(e){p=""+e,this.hasBeenReset=!0}})),Object.defineProperty(n,"region",r({},l,{get:function(){return f},set:function(e){f=e,this.hasBeenReset=!0}})),Object.defineProperty(n,"vertical",r({},l,{get:function(){return m},set:function(t){const s=function(t){return i(e,t)}(t);if(!1===s)throw new SyntaxError("An invalid or illegal string was specified.");m=s,this.hasBeenReset=!0}})),Object.defineProperty(n,"snapToLines",r({},l,{get:function(){return g},set:function(e){g=!!e,this.hasBeenReset=!0}})),Object.defineProperty(n,"line",r({},l,{get:function(){return y},set:function(e){if("number"!=typeof e&&"auto"!==e)throw new SyntaxError("An invalid number or illegal string was specified.");y=e,this.hasBeenReset=!0}})),Object.defineProperty(n,"lineAlign",r({},l,{get:function(){return A},set:function(e){const t=s(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");A=t,this.hasBeenReset=!0}})),Object.defineProperty(n,"position",r({},l,{get:function(){return b},set:function(e){if(e<0||e>100)throw new Error("Position must be between 0 and 100.");b=e,this.hasBeenReset=!0}})),Object.defineProperty(n,"positionAlign",r({},l,{get:function(){return _},set:function(e){const t=s(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");_=t,this.hasBeenReset=!0}})),Object.defineProperty(n,"size",r({},l,{get:function(){return v},set:function(e){if(e<0||e>100)throw new Error("Size must be between 0 and 100.");v=e,this.hasBeenReset=!0}})),Object.defineProperty(n,"align",r({},l,{get:function(){return S},set:function(e){const t=s(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");S=t,this.hasBeenReset=!0}})),n.displayState=void 0}return a.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},a}();class Tg{decode(e,t){if(!e)return"";if("string"!=typeof e)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}function kg(e){function t(e,t,i,s){return 3600*(0|e)+60*(0|t)+(0|i)+parseFloat(s||0)}const i=e.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return i?parseFloat(i[2])>59?t(i[2],i[3],0,i[4]):t(i[1],i[2],i[3],i[4]):null}class Cg{constructor(){this.values=Object.create(null)}set(e,t){this.get(e)||""===t||(this.values[e]=t)}get(e,t,i){return i?this.has(e)?this.values[e]:t[i]:this.has(e)?this.values[e]:t}has(e){return e in this.values}alt(e,t,i){for(let s=0;s<i.length;++s)if(t===i[s]){this.set(e,t);break}}integer(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))}percent(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){const i=parseFloat(t);if(i>=0&&i<=100)return this.set(e,i),!0}return!1}}function Rg(e,t,i,s){const r=s?e.split(s):[e];for(const e in r){if("string"!=typeof r[e])continue;const s=r[e].split(i);if(2!==s.length)continue;t(s[0],s[1])}}const xg=new Eg(0,0,""),Dg="middle"===xg.align?"middle":"center";function Lg(e,t,i){const s=e;function r(){const t=kg(e);if(null===t)throw new Error("Malformed timestamp: "+s);return e=e.replace(/^[^\sa-zA-Z-]+/,""),t}function a(){e=e.replace(/^\s+/,"")}if(a(),t.startTime=r(),a(),"--\x3e"!==e.slice(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+s);e=e.slice(3),a(),t.endTime=r(),a(),function(e,t){const s=new Cg;Rg(e,(function(e,t){let r;switch(e){case"region":for(let r=i.length-1;r>=0;r--)if(i[r].id===t){s.set(e,i[r].region);break}break;case"vertical":s.alt(e,t,["rl","lr"]);break;case"line":r=t.split(","),s.integer(e,r[0]),s.percent(e,r[0])&&s.set("snapToLines",!1),s.alt(e,r[0],["auto"]),2===r.length&&s.alt("lineAlign",r[1],["start",Dg,"end"]);break;case"position":r=t.split(","),s.percent(e,r[0]),2===r.length&&s.alt("positionAlign",r[1],["start",Dg,"end","line-left","line-right","auto"]);break;case"size":s.percent(e,t);break;case"align":s.alt(e,t,["start",Dg,"end","left","right"])}}),/:/,/\s/),t.region=s.get("region",null),t.vertical=s.get("vertical","");let r=s.get("line","auto");"auto"===r&&-1===xg.line&&(r=-1),t.line=r,t.lineAlign=s.get("lineAlign","start"),t.snapToLines=s.get("snapToLines",!0),t.size=s.get("size",100),t.align=s.get("align",Dg);let a=s.get("position","auto");"auto"===a&&50===xg.position&&(a="start"===t.align||"left"===t.align?0:"end"===t.align||"right"===t.align?100:50),t.position=a}(e,t)}function Pg(e){return e.replace(/<br(?: \/)?>/gi,"\n")}class Bg{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new Tg,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(e){const t=this;function i(){let e=t.buffer,i=0;for(e=Pg(e);i<e.length&&"\r"!==e[i]&&"\n"!==e[i];)++i;const s=e.slice(0,i);return"\r"===e[i]&&++i,"\n"===e[i]&&++i,t.buffer=e.slice(i),s}e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));try{let e="";if("INITIAL"===t.state){if(!/\r\n|\n/.test(t.buffer))return this;e=i();const s=e.match(/^()?WEBVTT([ \t].*)?$/);if(null==s||!s[0])throw new Error("Malformed WebVTT signature.");t.state="HEADER"}let s=!1;for(;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(s?s=!1:e=i(),t.state){case"HEADER":/:/.test(e)?Rg(e,(function(e,t){}),/:/):e||(t.state="ID");continue;case"NOTE":e||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(e)){t.state="NOTE";break}if(!e)continue;if(t.cue=new Eg(0,0,""),t.state="CUE",-1===e.indexOf("--\x3e")){t.cue.id=e;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{Lg(e,t.cue,t.regionList)}catch(e){t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":{const i=-1!==e.indexOf("--\x3e");if(!e||i&&(s=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(null===t.cue)continue;t.cue.text&&(t.cue.text+="\n"),t.cue.text+=e}continue;case"BADCUE":e||(t.state="ID")}}}catch(e){"CUETEXT"===t.state&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state="INITIAL"===t.state?"BADWEBVTT":"BADCUE"}return this}flush(){const e=this;try{if((e.cue||"HEADER"===e.state)&&(e.buffer+="\n\n",e.parse()),"INITIAL"===e.state||"BADWEBVTT"===e.state)throw new Error("Malformed WebVTT signature.")}catch(t){e.onparsingerror&&e.onparsingerror(t)}return e.onflush&&e.onflush(),this}}const Ig=/\r\n|\n\r|\n|\r/g,Mg=function(e,t,i=0){return e.slice(i,i+t.length)===t},Ug=function(e){let t=5381,i=e.length;for(;i;)t=33*t^e.charCodeAt(--i);return(t>>>0).toString()};function Fg(e,t,i){return Ug(e.toString())+Ug(t.toString())+Ug(i)}function Og(e,t,i,s,r,a,o){const n=new Bg,l=Fc(new Uint8Array(e)).trim().replace(Ig,"\n").split("\n"),d=[],h=t?function(e,t=1){return Lm(e,Dm,1/t)}(t.baseTime,t.timescale):0;let c,u="00:00.000",p=0,f=0,m=!0;n.oncue=function(e){const a=i[s];let o=i.ccOffset;const n=(p-h)/9e4;if(null!=a&&a.new&&(void 0!==f?o=i.ccOffset=a.start:function(e,t,i){let s=e[t],r=e[s.prevCC];if(!r||!r.new&&s.new)return e.ccOffset=e.presentationOffset=s.start,void(s.new=!1);for(;null!=(a=r)&&a.new;){var a;e.ccOffset+=s.start-r.start,s.new=!1,s=r,r=e[s.prevCC]}e.presentationOffset=i}(i,s,n)),n){if(!t)return void(c=new Error("Missing initPTS for VTT MPEGTS"));o=n-i.presentationOffset}const l=e.endTime-e.startTime,u=Fm(9e4*(e.startTime+o-f),9e4*r)/9e4;e.startTime=Math.max(u,0),e.endTime=Math.max(u+l,0);const m=e.text.trim();e.text=decodeURIComponent(encodeURIComponent(m)),e.id||(e.id=Fg(e.startTime,e.endTime,m)),e.endTime>0&&d.push(e)},n.onparsingerror=function(e){c=e},n.onflush=function(){c?o(c):a(d)},l.forEach((e=>{if(m){if(Mg(e,"X-TIMESTAMP-MAP=")){m=!1,e.slice(16).split(",").forEach((e=>{Mg(e,"LOCAL:")?u=e.slice(6):Mg(e,"MPEGTS:")&&(p=parseInt(e.slice(7)))}));try{f=function(e){let t=parseInt(e.slice(-3));const i=parseInt(e.slice(-6,-4)),s=parseInt(e.slice(-9,-7)),r=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!(Fh(t)&&Fh(i)&&Fh(s)&&Fh(r)))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*i,t+=6e4*s,t+=36e5*r,t}(u)/1e3}catch(e){c=e}return}""===e&&(m=!1)}n.parse(e+"\n")})),n.flush()}const Ng="stpp.ttml.im1t",jg=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,zg=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,Gg={left:"start",center:"center",right:"end",start:"start",end:"end"};function Hg(e,t,i,s){const r=Yc(new Uint8Array(e),["mdat"]);if(0===r.length)return void s(new Error("Could not parse IMSC1 mdat"));const a=r.map((e=>Fc(e))),o=function(e,t,i=1,s=!1){return Lm(e,t,1/i,s)}(t.baseTime,1,t.timescale);try{a.forEach((e=>i(function(e,t){const i=(new DOMParser).parseFromString(e,"text/xml"),s=i.getElementsByTagName("tt")[0];if(!s)throw new Error("Invalid ttml");const r={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},a=Object.keys(r).reduce(((e,t)=>(e[t]=s.getAttribute(`ttp:${t}`)||r[t],e)),{}),o="preserve"!==s.getAttribute("xml:space"),n=Vg($g(s,"styling","style")),l=Vg($g(s,"layout","region")),d=$g(s,"body","[begin]");return[].map.call(d,(e=>{const i=Wg(e,o);if(!i||!e.hasAttribute("begin"))return null;const s=Kg(e.getAttribute("begin"),a),r=Kg(e.getAttribute("dur"),a);let d=Kg(e.getAttribute("end"),a);if(null===s)throw qg(e);if(null===d){if(null===r)throw qg(e);d=s+r}const h=new Eg(s-t,d-t,i);h.id=Fg(h.startTime,h.endTime,h.text);const c=function(e,t,i){const s="http://www.w3.org/ns/ttml#styling";let r=null;const a=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],o=null!=e&&e.hasAttribute("style")?e.getAttribute("style"):null;o&&i.hasOwnProperty(o)&&(r=i[o]);return a.reduce(((i,a)=>{const o=Jg(t,s,a)||Jg(e,s,a)||Jg(r,s,a);return o&&(i[a]=o),i}),{})}(l[e.getAttribute("region")],n[e.getAttribute("style")],n),{textAlign:u}=c;if(u){const e=Gg[u];e&&(h.lineAlign=e),h.align=u}return Uh(h,c),h})).filter((e=>null!==e))}(e,o))))}catch(e){s(e)}}function $g(e,t,i){const s=e.getElementsByTagName(t)[0];return s?[].slice.call(s.querySelectorAll(i)):[]}function Vg(e){return e.reduce(((e,t)=>{const i=t.getAttribute("xml:id");return i&&(e[i]=t),e}),{})}function Wg(e,t){return[].slice.call(e.childNodes).reduce(((e,i,s)=>{var r;return"br"===i.nodeName&&s?e+"\n":null!=(r=i.childNodes)&&r.length?Wg(i,t):t?e+i.textContent.trim().replace(/\s+/g," "):e+i.textContent}),"")}function Jg(e,t,i){return e&&e.hasAttributeNS(t,i)?e.getAttributeNS(t,i):null}function qg(e){return new Error(`Could not parse ttml timestamp ${e}`)}function Kg(e,t){if(!e)return null;let i=kg(e);return null===i&&(jg.test(e)?i=function(e,t){const i=jg.exec(e),s=(0|i[4])+(0|i[5])/t.subFrameRate;return 3600*(0|i[1])+60*(0|i[2])+(0|i[3])+s/t.frameRate}(e,t):zg.test(e)&&(i=function(e,t){const i=zg.exec(e),s=Number(i[1]);switch(i[2]){case"h":return 3600*s;case"m":return 60*s;case"ms":return 1e3*s;case"f":return s/t.frameRate;case"t":return s/t.tickRate}return s}(e,t))),i}function Yg(e){return e.characteristics&&/transcribes-spoken-dialog/gi.test(e.characteristics)&&/describes-music-and-sound/gi.test(e.characteristics)?"captions":"subtitles"}function Qg(e,t){return!!e&&e.kind===Yg(t)&&Zm(t,e)}class Xg{constructor(e){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=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()}setStreamController(e){this.streamController=e}destroy(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){const{hls:e}=this;e.on(jh.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(jh.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(jh.MANIFEST_PARSED,this.onManifestParsed,this),e.on(jh.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(jh.BUFFER_CODECS,this.onBufferCodecs,this),e.on(jh.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:e}=this;e.off(jh.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(jh.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(jh.MANIFEST_PARSED,this.onManifestParsed,this),e.off(jh.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(jh.BUFFER_CODECS,this.onBufferCodecs,this),e.off(jh.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(e,t){const i=this.hls.levels[t.droppedLevel];this.isLevelAllowed(i)&&this.restrictedLevels.push({bitrate:i.bitrate,height:i.height,width:i.width})}onMediaAttaching(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()}onManifestParsed(e,t){const i=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,i.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onLevelsUpdated(e,t){this.timer&&Fh(this.autoLevelCapping)&&this.detectPlayerSize()}onBufferCodecs(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onMediaDetaching(){this.stopCapping()}detectPlayerSize(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0)return void(this.clientRect=null);const e=this.hls.levels;if(e.length){const t=this.hls,i=this.getMaxLevel(e.length-1);i!==this.autoLevelCapping&&Jh.log(`Setting autoLevelCapping to ${i}: ${e[i].height}p@${e[i].bitrate} for media ${this.mediaWidth}x${this.mediaHeight}`),t.autoLevelCapping=i,t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}}getMaxLevel(e){const t=this.hls.levels;if(!t.length)return-1;const i=t.filter(((t,i)=>this.isLevelAllowed(t)&&i<=e));return this.clientRect=null,Xg.getMaxLevelByMediaSize(i,this.mediaWidth,this.mediaHeight)}startCapping(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())}stopCapping(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)}getDimensions(){if(this.clientRect)return this.clientRect;const e=this.media,t={width:0,height:0};if(e){const 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)}return this.clientRect=t,t}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch(e){}return e}isLevelAllowed(e){return!this.restrictedLevels.some((t=>e.bitrate===t.bitrate&&e.width===t.width&&e.height===t.height))}static getMaxLevelByMediaSize(e,t,i){if(null==e||!e.length)return-1;let s=e.length-1;const r=Math.max(t,i);for(let t=0;t<e.length;t+=1){const i=e[t];if((i.width>=r||i.height>=r)&&(a=i,!(o=e[t+1])||a.width!==o.width||a.height!==o.height)){s=t;break}}var a,o;return s}}const Zg="[eme]";class ey{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=ey.CDMCleanupPromise?[ey.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=Jh.debug.bind(Jh,Zg),this.log=Jh.log.bind(Jh,Zg),this.warn=Jh.warn.bind(Jh,Zg),this.error=Jh.error.bind(Jh,Zg),this.hls=e,this.config=e.config,this.registerListeners()}destroy(){this.unregisterListeners(),this.onMediaDetached();const e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null,this.config=null}registerListeners(){this.hls.on(jh.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(jh.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(jh.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(jh.MANIFEST_LOADED,this.onManifestLoaded,this)}unregisterListeners(){this.hls.off(jh.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(jh.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(jh.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(jh.MANIFEST_LOADED,this.onManifestLoaded,this)}getLicenseServerUrl(e){const{drmSystems:t,widevineLicenseUrl:i}=this.config,s=t[e];if(s)return s.licenseUrl;if(e===cc.WIDEVINE&&i)return i;throw new Error(`no license server URL configured for key-system "${e}"`)}getServerCertificateUrl(e){const{drmSystems:t}=this.config,i=t[e];if(i)return i.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`)}attemptKeySystemAccess(e){const t=this.hls.levels,i=(e,t,i)=>!!e&&i.indexOf(e)===t,s=t.map((e=>e.audioCodec)).filter(i),r=t.map((e=>e.videoCodec)).filter(i);return s.length+r.length===0&&r.push("avc1.42e01e"),new Promise(((t,i)=>{const a=e=>{const o=e.shift();this.getMediaKeysPromise(o,s,r).then((e=>t({keySystem:o,mediaKeys:e}))).catch((t=>{e.length?a(e):i(t instanceof ty?t:new ty({type:zh.KEY_SYSTEM_ERROR,details:Gh.KEY_SYSTEM_NO_ACCESS,error:t,fatal:!0},t.message))}))};a(e)}))}requestMediaKeySystemAccess(e,t){const{requestMediaKeySystemAccessFunc:i}=this.config;if("function"!=typeof i){let e=`Configured requestMediaKeySystemAccess is not a function ${i}`;return null===_c&&"http:"===self.location.protocol&&(e=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(e))}return i(e,t)}getMediaKeysPromise(e,t,i){const s=function(e,t,i,s){let r;switch(e){case cc.FAIRPLAY:r=["cenc","sinf"];break;case cc.WIDEVINE:case cc.PLAYREADY:r=["cenc"];break;case cc.CLEARKEY:r=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${e}`)}return function(e,t,i,s){return[{initDataTypes:e,persistentState:s.persistentState||"optional",distinctiveIdentifier:s.distinctiveIdentifier||"optional",sessionTypes:s.sessionTypes||[s.sessionType||"temporary"],audioCapabilities:t.map((e=>({contentType:`audio/mp4; codecs="${e}"`,robustness:s.audioRobustness||"",encryptionScheme:s.audioEncryptionScheme||null}))),videoCapabilities:i.map((e=>({contentType:`video/mp4; codecs="${e}"`,robustness:s.videoRobustness||"",encryptionScheme:s.videoEncryptionScheme||null})))}]}(r,t,i,s)}(e,t,i,this.config.drmSystemOptions),r=this.keySystemAccessPromises[e];let a=null==r?void 0:r.keySystemAccess;if(!a){this.log(`Requesting encrypted media "${e}" key-system access with config: ${JSON.stringify(s)}`),a=this.requestMediaKeySystemAccess(e,s);const t=this.keySystemAccessPromises[e]={keySystemAccess:a};return a.catch((t=>{this.log(`Failed to obtain access to key-system "${e}": ${t}`)})),a.then((i=>{this.log(`Access for key-system "${i.keySystem}" obtained`);const s=this.fetchServerCertificate(e);return this.log(`Create media-keys for "${e}"`),t.mediaKeys=i.createMediaKeys().then((t=>(this.log(`Media-keys created for "${e}"`),s.then((i=>i?this.setMediaKeysServerCertificate(t,e,i):t))))),t.mediaKeys.catch((t=>{this.error(`Failed to create media-keys for "${e}"}: ${t}`)})),t.mediaKeys}))}return a.then((()=>r.mediaKeys))}createMediaKeySessionContext({decryptdata:e,keySystem:t,mediaKeys:i}){this.log(`Creating key-system session "${t}" keyId: ${jc(e.keyId||[])}`);const s=i.createSession(),r={decryptdata:e,keySystem:t,mediaKeys:i,mediaKeysSession:s,keyStatus:"status-pending"};return this.mediaKeySessions.push(r),r}renewKeySession(e){const t=e.decryptdata;if(t.pssh){const i=this.createMediaKeySessionContext(e),s=this.getKeyIdString(t),r="cenc";this.keyIdToKeySessionPromise[s]=this.generateRequestWithPreferredKeySession(i,r,t.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)}getKeyIdString(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(null===e.keyId)throw new Error("keyId is null");return jc(e.keyId)}updateKeySession(e,t){var i;const s=e.mediaKeysSession;return this.log(`Updating key-session "${s.sessionId}" for keyID ${jc((null==(i=e.decryptdata)?void 0:i.keyId)||[])}\n } (data length: ${t?t.byteLength:t})`),s.update(t)}selectKeySystemFormat(e){const t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${e.sn} ${e.type}: ${e.level}) key formats ${t.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise}getKeyFormatPromise(e){return new Promise(((t,i)=>{const s=bc(this.config),r=e.map(gc).filter((e=>!!e&&-1!==s.indexOf(e)));return this.getKeySystemSelectionPromise(r).then((({keySystem:e})=>{const s=Ac(e);s?t(s):i(new Error(`Unable to find format for key-system "${e}"`))})).catch(i)}))}loadKey(e){const t=e.keyInfo.decryptdata,i=this.getKeyIdString(t),s=`(keyId: ${i} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${s}`);let r=this.keyIdToKeySessionPromise[i];return r||(r=this.keyIdToKeySessionPromise[i]=this.getKeySystemForKeyPromise(t).then((({keySystem:i,mediaKeys:r})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${s}`),this.attemptSetMediaKeys(i,r).then((()=>{this.throwIfDestroyed();const e=this.createMediaKeySessionContext({keySystem:i,mediaKeys:r,decryptdata:t});return this.generateRequestWithPreferredKeySession(e,"cenc",t.pssh,"playlist-key")}))))),r.catch((e=>this.handleError(e)))),r}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e){this.hls&&(this.error(e.message),e instanceof ty?this.hls.trigger(jh.ERROR,e.data):this.hls.trigger(jh.ERROR,{type:zh.KEY_SYSTEM_ERROR,details:Gh.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0}))}getKeySystemForKeyPromise(e){const t=this.getKeyIdString(e),i=this.keyIdToKeySessionPromise[t];if(!i){const t=gc(e.keyFormat),i=t?[t]:bc(this.config);return this.attemptKeySystemAccess(i)}return i}getKeySystemSelectionPromise(e){if(e.length||(e=bc(this.config)),0===e.length)throw new ty({type:zh.KEY_SYSTEM_ERROR,details:Gh.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${JSON.stringify({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}_onMediaEncrypted(e){const{initDataType:t,initData:i}=e;if(this.debug(`"${e.type}" event: init data type: "${t}"`),null===i)return;let s,r;if("sinf"===t&&this.config.drmSystems[cc.FAIRPLAY]){const e=$c(new Uint8Array(i));try{const t=nc(JSON.parse(e).sinf),i=su(new Uint8Array(t));if(!i)return;s=i.subarray(8,24),r=cc.FAIRPLAY}catch(e){return void this.warn('Failed to parse sinf "encrypted" event message initData')}}else{const e=function(e){if(!(e instanceof ArrayBuffer)||e.byteLength<32)return null;const t={version:0,systemId:"",kids:null,data:null},i=new DataView(e),s=i.getUint32(0);if(e.byteLength!==s&&s>44)return null;if(1886614376!==i.getUint32(4))return null;if(t.version=i.getUint32(8)>>>24,t.version>1)return null;t.systemId=jc(new Uint8Array(e,12,16));const r=i.getUint32(28);if(0===t.version){if(s-32<r)return null;t.data=new Uint8Array(e,32,r)}else if(1===t.version){t.kids=[];for(let i=0;i<r;i++)t.kids.push(new Uint8Array(e,32+16*i,16))}return t}(i);if(null===e)return;0===e.version&&e.systemId===yc&&e.data&&(s=e.data.subarray(8,24)),r=function(e){if(e===yc)return cc.WIDEVINE}(e.systemId)}if(!r||!s)return;const a=jc(s),{keyIdToKeySessionPromise:o,mediaKeySessions:n}=this;let l=o[a];for(let e=0;e<n.length;e++){const r=n[e],d=r.decryptdata;if(d.pssh||!d.keyId)continue;const h=jc(d.keyId);if(a===h||-1!==d.uri.replace(/-/g,"").indexOf(a)){l=o[h],delete o[h],d.pssh=new Uint8Array(i),d.keyId=s,l=o[a]=l.then((()=>this.generateRequestWithPreferredKeySession(r,t,i,"encrypted-event-key-match")));break}}l||(l=o[a]=this.getKeySystemSelectionPromise([r]).then((({keySystem:e,mediaKeys:r})=>{var o;this.throwIfDestroyed();const n=new uu("ISO-23001-7",a,null!=(o=Ac(e))?o:"");return n.pssh=new Uint8Array(i),n.keyId=s,this.attemptSetMediaKeys(e,r).then((()=>{this.throwIfDestroyed();const s=this.createMediaKeySessionContext({decryptdata:n,keySystem:e,mediaKeys:r});return this.generateRequestWithPreferredKeySession(s,t,i,"encrypted-event-no-match")}))}))),l.catch((e=>this.handleError(e)))}_onWaitingForKey(e){this.log(`"${e.type}" event`)}attemptSetMediaKeys(e,t){const i=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);const s=Promise.all(i).then((()=>{if(!this.media)throw new Error("Attempted to set mediaKeys without media element attached");return this.media.setMediaKeys(t)}));return this.setMediaKeysQueue.push(s),s.then((()=>{this.log(`Media-keys set for "${e}"`),i.push(s),this.setMediaKeysQueue=this.setMediaKeysQueue.filter((e=>-1===i.indexOf(e)))}))}generateRequestWithPreferredKeySession(e,t,i,s){var r,a;const o=null==(r=this.config.drmSystems)||null==(a=r[e.keySystem])?void 0:a.generateRequest;if(o)try{const s=o.call(this.hls,t,i,e);if(!s)throw new Error("Invalid response from configured generateRequest filter");t=s.initDataType,i=e.decryptdata.pssh=s.initData?new Uint8Array(s.initData):null}catch(e){var n;if(this.warn(e.message),null!=(n=this.hls)&&n.config.debug)throw e}if(null===i)return this.log(`Skipping key-session request for "${s}" (no initData)`),Promise.resolve(e);const l=this.getKeyIdString(e.decryptdata);this.log(`Generating key-session request for "${s}": ${l} (init data type: ${t} length: ${i?i.byteLength:null})`);const d=new Km,h=e._onmessage=t=>{const i=e.mediaKeysSession;if(!i)return void d.emit("error",new Error("invalid state"));const{messageType:s,message:r}=t;this.log(`"${s}" message event for session "${i.sessionId}" message size: ${r.byteLength}`),"license-request"===s||"license-renewal"===s?this.renewLicense(e,r).catch((e=>{this.handleError(e),d.emit("error",e)})):"license-release"===s?e.keySystem===cc.FAIRPLAY&&(this.updateKeySession(e,dc("acknowledged")),this.removeSession(e)):this.warn(`unhandled media key message type "${s}"`)},c=e._onkeystatuseschange=t=>{if(!e.mediaKeysSession)return void d.emit("error",new Error("invalid state"));this.onKeyStatusChange(e);const i=e.keyStatus;d.emit("keyStatus",i),"expired"===i&&(this.warn(`${e.keySystem} expired for key ${l}`),this.renewKeySession(e))};e.mediaKeysSession.addEventListener("message",h),e.mediaKeysSession.addEventListener("keystatuseschange",c);const u=new Promise(((e,t)=>{d.on("error",t),d.on("keyStatus",(i=>{i.startsWith("usable")?e():"output-restricted"===i?t(new ty({type:zh.KEY_SYSTEM_ERROR,details:Gh.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):"internal-error"===i?t(new ty({type:zh.KEY_SYSTEM_ERROR,details:Gh.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},`key status changed to "${i}"`)):"expired"===i?t(new Error("key expired while generating request")):this.warn(`unhandled key status change "${i}"`)}))}));return e.mediaKeysSession.generateRequest(t,i).then((()=>{var t;this.log(`Request generated for key-session "${null==(t=e.mediaKeysSession)?void 0:t.sessionId}" keyId: ${l}`)})).catch((e=>{throw new ty({type:zh.KEY_SYSTEM_ERROR,details:Gh.KEY_SYSTEM_NO_SESSION,error:e,fatal:!1},`Error generating key-session request: ${e}`)})).then((()=>u)).catch((t=>{throw d.removeAllListeners(),this.removeSession(e),t})).then((()=>(d.removeAllListeners(),e)))}onKeyStatusChange(e){e.mediaKeysSession.keyStatuses.forEach(((t,i)=>{this.log(`key status change "${t}" for keyStatuses keyId: ${jc("buffer"in i?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i))} session keyId: ${jc(new Uint8Array(e.decryptdata.keyId||[]))} uri: ${e.decryptdata.uri}`),e.keyStatus=t}))}fetchServerCertificate(e){const t=this.config,i=new(0,t.loader)(t),s=this.getServerCertificateUrl(e);return s?(this.log(`Fetching server certificate for "${e}"`),new Promise(((r,a)=>{const o={responseType:"arraybuffer",url:s},n=t.certLoadPolicy.default,l={loadPolicy:n,timeout:n.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},d={onSuccess:(e,t,i,s)=>{r(e.data)},onError:(t,i,r,n)=>{a(new ty({type:zh.KEY_SYSTEM_ERROR,details:Gh.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:r,response:Bh({url:o.url,data:void 0},t)},`"${e}" certificate request failed (${s}). Status: ${t.code} (${t.text})`))},onTimeout:(t,i,r)=>{a(new ty({type:zh.KEY_SYSTEM_ERROR,details:Gh.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:r,response:{url:o.url,data:void 0}},`"${e}" certificate request timed out (${s})`))},onAbort:(e,t,i)=>{a(new Error("aborted"))}};i.load(o,l,d)}))):Promise.resolve()}setMediaKeysServerCertificate(e,t,i){return new Promise(((s,r)=>{e.setServerCertificate(i).then((r=>{this.log(`setServerCertificate ${r?"success":"not supported by CDM"} (${null==i?void 0:i.byteLength}) on "${t}"`),s(e)})).catch((e=>{r(new ty({type:zh.KEY_SYSTEM_ERROR,details:Gh.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:e,fatal:!0},e.message))}))}))}renewLicense(e,t){return this.requestLicense(e,new Uint8Array(t)).then((t=>this.updateKeySession(e,new Uint8Array(t)).catch((e=>{throw new ty({type:zh.KEY_SYSTEM_ERROR,details:Gh.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:e,fatal:!0},e.message)}))))}unpackPlayReadyKeyMessage(e,t){const i=String.fromCharCode.apply(null,new Uint16Array(t.buffer));if(!i.includes("PlayReadyKeyMessage"))return e.setRequestHeader("Content-Type","text/xml; charset=utf-8"),t;const s=(new DOMParser).parseFromString(i,"application/xml"),r=s.querySelectorAll("HttpHeader");if(r.length>0){let t;for(let i=0,s=r.length;i<s;i++){var a,o;t=r[i];const s=null==(a=t.querySelector("name"))?void 0:a.textContent,n=null==(o=t.querySelector("value"))?void 0:o.textContent;s&&n&&e.setRequestHeader(s,n)}}const n=s.querySelector("Challenge"),l=null==n?void 0:n.textContent;if(!l)throw new Error("Cannot find <Challenge> in key message");return dc(atob(l))}setupLicenseXHR(e,t,i,s){const r=this.config.licenseXhrSetup;return r?Promise.resolve().then((()=>{if(!i.decryptdata)throw new Error("Key removed");return r.call(this.hls,e,t,i,s)})).catch((a=>{if(!i.decryptdata)throw a;return e.open("POST",t,!0),r.call(this.hls,e,t,i,s)})).then((i=>{e.readyState||e.open("POST",t,!0);return{xhr:e,licenseChallenge:i||s}})):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:s}))}requestLicense(e,t){const i=this.config.keyLoadPolicy.default;return new Promise(((s,r)=>{const a=this.getLicenseServerUrl(e.keySystem);this.log(`Sending license request to URL: ${a}`);const o=new XMLHttpRequest;o.responseType="arraybuffer",o.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return r(new Error("invalid state"));if(4===o.readyState)if(200===o.status){this._requestLicenseFailureCount=0;let t=o.response;this.log(`License received ${t instanceof ArrayBuffer?t.byteLength:t}`);const i=this.config.licenseResponseCallback;if(i)try{t=i.call(this.hls,o,a,e)}catch(e){this.error(e)}s(t)}else{const n=i.errorRetry,l=n?n.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>l||o.status>=400&&o.status<500)r(new ty({type:zh.KEY_SYSTEM_ERROR,details:Gh.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:o,response:{url:a,data:void 0,code:o.status,text:o.statusText}},`License Request XHR failed (${a}). Status: ${o.status} (${o.statusText})`));else{const i=l-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${i} attempts left`),this.requestLicense(e,t).then(s,r)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=o,this.setupLicenseXHR(o,a,e,t).then((({xhr:t,licenseChallenge:i})=>{e.keySystem==cc.PLAYREADY&&(i=this.unpackPlayReadyKeyMessage(t,i)),t.send(i)}))}))}onMediaAttached(e,t){if(!this.config.emeEnabled)return;const i=t.media;this.media=i,i.addEventListener("encrypted",this.onMediaEncrypted),i.addEventListener("waitingforkey",this.onWaitingForKey)}onMediaDetached(){const e=this.media,t=this.mediaKeySessions;e&&(e.removeEventListener("encrypted",this.onMediaEncrypted),e.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},uu.clearKeyUriToKeyIdMap();const i=t.length;ey.CDMCleanupPromise=Promise.all(t.map((e=>this.removeSession(e))).concat(null==e?void 0:e.setMediaKeys(null).catch((e=>{this.log(`Could not clear media keys: ${e}`)})))).then((()=>{i&&(this.log("finished closing key sessions and clearing media keys"),t.length=0)})).catch((e=>{this.log(`Could not close sessions and clear media keys: ${e}`)}))}onManifestLoading(){this.keyFormatPromise=null}onManifestLoaded(e,{sessionKeys:t}){if(t&&this.config.emeEnabled&&!this.keyFormatPromise){const e=t.reduce(((e,t)=>(-1===e.indexOf(t.keyFormat)&&e.push(t.keyFormat),e)),[]);this.log(`Selecting key-system from session-keys ${e.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(e)}}removeSession(e){const{mediaKeysSession:t,licenseXhr:i}=e;if(t){this.log(`Remove licenses and keys and close session ${t.sessionId}`),e._onmessage&&(t.removeEventListener("message",e._onmessage),e._onmessage=void 0),e._onkeystatuseschange&&(t.removeEventListener("keystatuseschange",e._onkeystatuseschange),e._onkeystatuseschange=void 0),i&&i.readyState!==XMLHttpRequest.DONE&&i.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;const s=this.mediaKeySessions.indexOf(e);return s>-1&&this.mediaKeySessions.splice(s,1),t.remove().catch((e=>{this.log(`Could not remove session: ${e}`)})).then((()=>t.close())).catch((e=>{this.log(`Could not close session: ${e}`)}))}}}ey.CDMCleanupPromise=void 0;class ty extends Error{constructor(e,t){super(t),this.data=void 0,e.error||(e.error=new Error(t)),this.data=e,e.err=e.error}}var iy,sy,ry;!function(e){e.MANIFEST="m",e.AUDIO="a",e.VIDEO="v",e.MUXED="av",e.INIT="i",e.CAPTION="c",e.TIMED_TEXT="tt",e.KEY="k",e.OTHER="o"}(iy||(iy={})),function(e){e.DASH="d",e.HLS="h",e.SMOOTH="s",e.OTHER="o"}(sy||(sy={})),function(e){e.OBJECT="CMCD-Object",e.REQUEST="CMCD-Request",e.SESSION="CMCD-Session",e.STATUS="CMCD-Status"}(ry||(ry={}));const ay={[ry.OBJECT]:["br","d","ot","tb"],[ry.REQUEST]:["bl","dl","mtp","nor","nrr","su"],[ry.SESSION]:["cid","pr","sf","sid","st","v"],[ry.STATUS]:["bs","rtp"]};class oy{constructor(e,t){this.value=void 0,this.params=void 0,Array.isArray(e)&&(e=e.map((e=>e instanceof oy?e:new oy(e)))),this.value=e,this.params=t}}class ny{constructor(e){this.description=void 0,this.description=e}}const ly="Dict";function dy(e,t,i,s){return new Error(`failed to ${e} "${r=t,Array.isArray(r)?JSON.stringify(r):r instanceof Map?"Map{}":r instanceof Set?"Set{}":"object"==typeof r?JSON.stringify(r):String(r)}" as ${i}`,{cause:s});var r}const hy="Bare Item",cy="Boolean",uy="Byte Sequence",py="Decimal",fy="Integer";const my=/[\x00-\x1f\x7f]+/,gy="Token",yy="Key";function Ay(e,t,i){return dy("serialize",e,t,i)}function by(e){if(!1===ArrayBuffer.isView(e))throw Ay(e,uy);return`:${t=e,btoa(String.fromCharCode(...t))}:`;var t}function _y(e){if(function(e){return e<-999999999999999||999999999999999<e}(e))throw Ay(e,fy);return e.toString()}function vy(e,t){if(e<0)return-vy(-e,t);const i=Math.pow(10,t);if(Math.abs(e*i%1-.5)<Number.EPSILON){const t=Math.floor(e*i);return(t%2==0?t:t+1)/i}return Math.round(e*i)/i}function Sy(e){const t=vy(e,3);if(Math.floor(Math.abs(t)).toString().length>12)throw Ay(e,py);const i=t.toString();return i.includes(".")?i:`${i}.0`}const wy="String";function Ey(e){const t=(i=e).description||i.toString().slice(7,-1);var i;if(!1===/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(t))throw Ay(t,gy);return t}function Ty(e){switch(typeof e){case"number":if(!Fh(e))throw Ay(e,hy);return Number.isInteger(e)?_y(e):Sy(e);case"string":return function(e){if(my.test(e))throw Ay(e,wy);return`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}(e);case"symbol":return Ey(e);case"boolean":return function(e){if("boolean"!=typeof e)throw Ay(e,cy);return e?"?1":"?0"}(e);case"object":if(e instanceof Date)return function(e){return`@${_y(e.getTime()/1e3)}`}(e);if(e instanceof Uint8Array)return by(e);if(e instanceof ny)return Ey(e);default:throw Ay(e,hy)}}function ky(e){if(!1===/^[a-z*][a-z0-9\-_.*]*$/.test(e))throw Ay(e,yy);return e}function Cy(e){return null==e?"":Object.entries(e).map((([e,t])=>!0===t?`;${ky(e)}`:`;${ky(e)}=${Ty(t)}`)).join("")}function Ry(e){return e instanceof oy?`${Ty(e.value)}${Cy(e.params)}`:Ty(e)}function xy(e,t={whitespace:!0}){if("object"!=typeof e)throw Ay(e,ly);const i=e instanceof Map?e.entries():Object.entries(e),s=null!=t&&t.whitespace?" ":"";return Array.from(i).map((([e,t])=>{t instanceof oy==!1&&(t=new oy(t));let i=ky(e);var s;return!0===t.value?i+=Cy(t.params):(i+="=",Array.isArray(t.value)?i+=`(${(s=t).value.map(Ry).join(" ")})${Cy(s.params)}`:i+=Ry(t)),i})).join(`,${s}`)}const Dy=e=>"ot"===e||"sf"===e||"st"===e,Ly=e=>"number"==typeof e?Fh(e):null!=e&&""!==e&&!1!==e;const Py=e=>Math.round(e),By=e=>100*Py(e/100),Iy={br:Py,d:Py,bl:By,dl:By,mtp:By,nor:(e,t)=>(null!=t&&t.baseUrl&&(e=function(e,t){const i=new URL(e),s=new URL(t);if(i.origin!==s.origin)return e;const r=i.pathname.split("/").slice(1),a=s.pathname.split("/").slice(1,-1);for(;r[0]===a[0];)r.shift(),a.shift();for(;a.length;)a.shift(),r.unshift("..");return r.join("/")}(e,t.baseUrl)),encodeURIComponent(e)),rtp:By,tb:Py};function My(e,t={}){return e?function(e,t){return xy(e,t)}(function(e,t){const i={};if(null==e||"object"!=typeof e)return i;const s=Object.keys(e).sort(),r=Uh({},Iy,null==t?void 0:t.formatters),a=null==t?void 0:t.filter;return s.forEach((s=>{if(null!=a&&a(s))return;let o=e[s];const n=r[s];n&&(o=n(o,t)),"v"===s&&1===o||"pr"==s&&1===o||Ly(o)&&(Dy(s)&&"string"==typeof o&&(o=new ny(o)),i[s]=o)})),i}(e,t),Uh({whitespace:!1},t)):""}function Uy(e,t,i){return Uh(e,function(e,t={}){if(!e)return{};const i=Object.entries(e),s=Object.entries(ay).concat(Object.entries((null==t?void 0:t.customHeaderMap)||{})),r=i.reduce(((e,t)=>{var i;const[r,a]=t,o=(null==(i=s.find((e=>e[1].includes(r))))?void 0:i[0])||ry.REQUEST;return null!=e[o]||(e[o]={}),e[o][r]=a,e}),{});return Object.entries(r).reduce(((e,[i,s])=>(e[i]=My(s,t),e)),{})}(t,i))}const Fy="CMCD";const Oy=/CMCD=[^&#]+/;function Ny(e,t,i){const s=function(e,t={}){if(!e)return"";const i=My(e,t);return`${Fy}=${encodeURIComponent(i)}`}(t,i);if(!s)return e;if(Oy.test(e))return e.replace(Oy,s);const r=e.includes("?")?"&":"?";return`${e}${r}${s}`}function jy(e,t,i,s){e&&Object.keys(t).forEach((r=>{const a=e.filter((e=>e.groupId===r)).map((e=>{const a=Uh({},e);return a.details=void 0,a.attrs=new Yh(a.attrs),a.url=a.attrs.URI=zy(e.url,e.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",i),a.groupId=a.attrs["GROUP-ID"]=t[r],a.attrs["PATHWAY-ID"]=s,a}));e.push(...a)}))}function zy(e,t,i,s){const{HOST:r,PARAMS:a,[i]:o}=s;let n;t&&(n=null==o?void 0:o[t],n&&(e=n));const l=new self.URL(e);return r&&!n&&(l.host=r),a&&Object.keys(a).sort().forEach((e=>{e&&l.searchParams.set(e,a[e])})),l.href}const Gy=/^age:\s*[\d.]+\s*$/im;class Hy{constructor(e){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=null,this.loader=null,this.stats=void 0,this.xhrSetup=e&&e.xhrSetup||null,this.stats=new Zh,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null,this.stats=null}abortInternal(){const e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,4!==e.readyState&&(this.stats.aborted=!0,e.abort()))}abort(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(e,t,i){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=i,this.loadInternal()}loadInternal(){const{config:e,context:t}=this;if(!e||!t)return;const i=this.loader=new self.XMLHttpRequest,s=this.stats;s.loading.first=0,s.loaded=0,s.aborted=!1;const r=this.xhrSetup;r?Promise.resolve().then((()=>{if(!this.stats.aborted)return r(i,t.url)})).catch((e=>(i.open("GET",t.url,!0),r(i,t.url)))).then((()=>{this.stats.aborted||this.openAndSendXhr(i,t,e)})).catch((e=>{this.callbacks.onError({code:i.status,text:e.message},t,i,s)})):this.openAndSendXhr(i,t,e)}openAndSendXhr(e,t,i){e.readyState||e.open("GET",t.url,!0);const s=t.headers,{maxTimeToFirstByteMs:r,maxLoadTimeMs:a}=i.loadPolicy;if(s)for(const t in s)e.setRequestHeader(t,s[t]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),i.timeout=r&&Fh(r)?r:a,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.timeout),e.send()}readystatechange(){const{context:e,loader:t,stats:i}=this;if(!e||!t)return;const s=t.readyState,r=this.config;if(!i.aborted&&s>=2&&(0===i.loading.first&&(i.loading.first=Math.max(self.performance.now(),i.loading.start),r.timeout!==r.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),r.timeout=r.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.loadPolicy.maxLoadTimeMs-(i.loading.first-i.loading.start)))),4===s)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;const s=t.status,a="text"!==t.responseType;if(s>=200&&s<300&&(a&&t.response||null!==t.responseText)){i.loading.end=Math.max(self.performance.now(),i.loading.first);const r=a?t.response:t.responseText,o="arraybuffer"===t.responseType?r.byteLength:r.length;if(i.loaded=i.total=o,i.bwEstimate=8e3*i.total/(i.loading.end-i.loading.first),!this.callbacks)return;const n=this.callbacks.onProgress;if(n&&n(i,e,r,t),!this.callbacks)return;const l={url:t.responseURL,data:r,code:s};this.callbacks.onSuccess(l,i,e,t)}else{const a=r.loadPolicy.errorRetry;Bp(a,i.retry,!1,{url:e.url,data:void 0,code:s})?this.retry(a):(Jh.error(`${s} while loading ${e.url}`),this.callbacks.onError({code:s,text:t.statusText},e,t,i))}}}loadtimeout(){var e;const t=null==(e=this.config)?void 0:e.loadPolicy.timeoutRetry;if(Bp(t,this.stats.retry,!0))this.retry(t);else{var i;Jh.warn(`timeout while loading ${null==(i=this.context)?void 0:i.url}`);const e=this.callbacks;e&&(this.abortInternal(),e.onTimeout(this.stats,this.context,this.loader))}}retry(e){const{context:t,stats:i}=this;this.retryDelay=Lp(e,i.retry),i.retry++,Jh.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${null==t?void 0:t.url}, retrying ${i.retry}/${e.maxNumRetry} in ${this.retryDelay}ms`),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)}loadprogress(e){const t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)}getCacheAge(){let e=null;if(this.loader&&Gy.test(this.loader.getAllResponseHeaders())){const t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.loader&&new RegExp(`^${e}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}}const $y=/(\d+)-(\d+)\/(\d+)/;class Vy{constructor(e){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=null,this.response=null,this.controller=void 0,this.context=null,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=e.fetchSetup||Wy,this.controller=new self.AbortController,this.stats=new Zh}destroy(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null}abortInternal(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())}abort(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(e,t,i){const s=this.stats;if(s.loading.start)throw new Error("Loader can only be used once.");s.loading.start=self.performance.now();const r=function(e,t){const i={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(Uh({},e.headers))};e.rangeEnd&&i.headers.set("Range","bytes="+e.rangeStart+"-"+String(e.rangeEnd-1));return i}(e,this.controller.signal),a=i.onProgress,o="arraybuffer"===e.responseType,n=o?"byteLength":"length",{maxTimeToFirstByteMs:l,maxLoadTimeMs:d}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=i,this.request=this.fetchSetup(e,r),self.clearTimeout(this.requestTimeout),t.timeout=l&&Fh(l)?l:d,this.requestTimeout=self.setTimeout((()=>{this.abortInternal(),i.onTimeout(s,e,this.response)}),t.timeout),self.fetch(this.request).then((r=>{this.response=this.loader=r;const n=Math.max(self.performance.now(),s.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=d,this.requestTimeout=self.setTimeout((()=>{this.abortInternal(),i.onTimeout(s,e,this.response)}),d-(n-s.loading.start)),!r.ok){const{status:e,statusText:t}=r;throw new Jy(t||"fetch, bad network response",e,r)}return s.loading.first=n,s.total=function(e){const t=e.get("Content-Range");if(t){const e=function(e){const t=$y.exec(e);if(t)return parseInt(t[2])-parseInt(t[1])+1}(t);if(Fh(e))return e}const i=e.get("Content-Length");if(i)return parseInt(i)}(r.headers)||s.total,a&&Fh(t.highWaterMark)?this.loadProgressively(r,s,e,t.highWaterMark,a):o?r.arrayBuffer():"json"===e.responseType?r.json():r.text()})).then((r=>{const o=this.response;if(!o)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),s.loading.end=Math.max(self.performance.now(),s.loading.first);const l=r[n];l&&(s.loaded=s.total=l);const d={url:o.url,data:r,code:o.status};a&&!Fh(t.highWaterMark)&&a(s,e,r,o),i.onSuccess(d,s,e,o)})).catch((t=>{if(self.clearTimeout(this.requestTimeout),s.aborted)return;const r=t&&t.code||0,a=t?t.message:null;i.onError({code:r,text:a},e,t?t.details:null,s)}))}getCacheAge(){let e=null;if(this.response){const t=this.response.headers.get("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.response?this.response.headers.get(e):null}loadProgressively(e,t,i,s=0,r){const a=new $f,o=e.body.getReader(),n=()=>o.read().then((o=>{if(o.done)return a.dataLength&&r(t,i,a.flush(),e),Promise.resolve(new ArrayBuffer(0));const l=o.value,d=l.length;return t.loaded+=d,d<s||a.dataLength?(a.push(l),a.dataLength>=s&&r(t,i,a.flush(),e)):r(t,i,l,e),n()})).catch((()=>Promise.reject()));return n()}}function Wy(e,t){return new self.Request(e.url,t)}class Jy extends Error{constructor(e,t,i){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=i}}const qy=/\s/,Ky={newCue(e,t,i,s){const r=[];let a,o,n,l,d;const h=self.VTTCue||self.TextTrackCue;for(let u=0;u<s.rows.length;u++)if(a=s.rows[u],n=!0,l=0,d="",!a.isEmpty()){var c;for(let e=0;e<a.chars.length;e++)qy.test(a.chars[e].uchar)&&n?l++:(d+=a.chars[e].uchar,n=!1);a.cueStartTime=t,t===i&&(i+=1e-4),l>=16?l--:l++;const s=Pg(d.trim()),p=Fg(t,i,s);null!=e&&null!=(c=e.cues)&&c.getCueById(p)||(o=new h(t,i,s),o.id=p,o.line=u+1,o.align="left",o.position=10+Math.min(80,10*Math.floor(8*l/32)),r.push(o))}return e&&r.length&&(r.sort(((e,t)=>"auto"===e.line||"auto"===t.line?0:e.line>8&&t.line>8?t.line-e.line:e.line-t.line)),r.forEach((t=>ep(e,t)))),r}},Yy=Bh(Bh({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,maxBufferSize:6e7,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:Hy,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:class{constructor(e){this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=-1,this.firstSelection=-1,this._nextAutoLevel=-1,this.nextAutoLevelKey="",this.audioTracksByGroup=null,this.codecTiers=null,this.timer=-1,this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this._abandonRulesCheck=()=>{const{fragCurrent:e,partCurrent:t,hls:i}=this,{autoLevelEnabled:s,media:r}=i;if(!e||!r)return;const a=performance.now(),o=t?t.stats:e.stats,n=t?t.duration:e.duration,l=a-o.loading.start,d=i.minAutoLevel;if(o.aborted||o.loaded&&o.loaded===o.total||e.level<=d)return this.clearTimer(),void(this._nextAutoLevel=-1);if(!s||r.paused||!r.playbackRate||!r.readyState)return;const h=i.mainForwardBufferInfo;if(null===h)return;const c=this.bwEstimator.getEstimateTTFB(),u=Math.abs(r.playbackRate);if(l<=Math.max(c,n/(2*u)*1e3))return;const p=h.len/u,f=o.loading.first?o.loading.first-o.loading.start:-1,m=o.loaded&&f>-1,g=this.getBwEstimate(),y=i.levels,A=y[e.level],b=o.total||Math.max(o.loaded,Math.round(n*A.averageBitrate/8));let _=m?l-f:l;_<1&&m&&(_=Math.min(l,8*o.loaded/g));const v=m?1e3*o.loaded/_:0,S=v?(b-o.loaded)/v:8*b/g+c/1e3;if(S<=p)return;const w=v?8*v:g;let E,T=Number.POSITIVE_INFINITY;for(E=e.level-1;E>d;E--){const e=y[E].maxBitrate;if(T=this.getTimeToLoadFrag(c/1e3,w,n*e,!y[E].details),T<p)break}if(T>=S)return;if(T>10*n)return;i.nextLoadLevel=i.nextAutoLevel=E,m?this.bwEstimator.sample(l-Math.min(c,f),o.loaded):this.bwEstimator.sampleTTFB(l);const k=y[E].maxBitrate;this.getBwEstimate()*this.hls.config.abrBandWidthUpFactor>k&&this.resetEstimator(k),this.clearTimer(),Jh.warn(`[abr] Fragment ${e.sn}${t?" part "+t.index:""} of level ${e.level} is loading too slowly;\n Time to underbuffer: ${p.toFixed(3)} s\n Estimated load time for current fragment: ${S.toFixed(3)} s\n Estimated load time for down switch fragment: ${T.toFixed(3)} s\n TTFB estimate: ${0|f} ms\n Current BW estimate: ${Fh(g)?0|g:"Unknown"} bps\n New BW estimate: ${0|this.getBwEstimate()} bps\n Switching to level ${E} @ ${0|k} bps`),i.trigger(jh.FRAG_LOAD_EMERGENCY_ABORTED,{frag:e,part:t,stats:o})},this.hls=e,this.bwEstimator=this.initEstimator(),this.registerListeners()}resetEstimator(e){e&&(Jh.log(`setting initial bwe to ${e}`),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()}initEstimator(){const e=this.hls.config;return new Jp(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}registerListeners(){const{hls:e}=this;e.on(jh.MANIFEST_LOADING,this.onManifestLoading,this),e.on(jh.FRAG_LOADING,this.onFragLoading,this),e.on(jh.FRAG_LOADED,this.onFragLoaded,this),e.on(jh.FRAG_BUFFERED,this.onFragBuffered,this),e.on(jh.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(jh.LEVEL_LOADED,this.onLevelLoaded,this),e.on(jh.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(jh.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(jh.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e&&(e.off(jh.MANIFEST_LOADING,this.onManifestLoading,this),e.off(jh.FRAG_LOADING,this.onFragLoading,this),e.off(jh.FRAG_LOADED,this.onFragLoaded,this),e.off(jh.FRAG_BUFFERED,this.onFragBuffered,this),e.off(jh.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(jh.LEVEL_LOADED,this.onLevelLoaded,this),e.off(jh.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(jh.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(jh.ERROR,this.onError,this))}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=null,this.fragCurrent=this.partCurrent=null}onManifestLoading(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()}onLevelsUpdated(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null}onMaxAutoLevelUpdated(){this.firstSelection=-1,this.nextAutoLevelKey=""}onFragLoading(e,t){const i=t.frag;if(!this.ignoreFragment(i)){var s;if(!i.bitrateTest)this.fragCurrent=i,this.partCurrent=null!=(s=t.part)?s:null;this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100)}}onLevelSwitching(e,t){this.clearTimer()}onError(e,t){if(!t.fatal)switch(t.details){case Gh.BUFFER_ADD_CODEC_ERROR:case Gh.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case Gh.FRAG_LOAD_TIMEOUT:{const e=t.frag,{fragCurrent:i,partCurrent:s}=this;if(e&&i&&e.sn===i.sn&&e.level===i.level){const t=performance.now(),i=s?s.stats:e.stats,r=t-i.loading.start,a=i.loading.first?i.loading.first-i.loading.start:-1;if(i.loaded&&a>-1){const e=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(r-Math.min(e,a),i.loaded)}else this.bwEstimator.sampleTTFB(r)}break}}}getTimeToLoadFrag(e,t,i,s){return e+i/t+(s?this.lastLevelLoadSec:0)}onLevelLoaded(e,t){const i=this.hls.config,{loading:s}=t.stats,r=s.end-s.start;Fh(r)&&(this.lastLevelLoadSec=r/1e3),t.details.live?this.bwEstimator.update(i.abrEwmaSlowLive,i.abrEwmaFastLive):this.bwEstimator.update(i.abrEwmaSlowVoD,i.abrEwmaFastVoD)}onFragLoaded(e,{frag:t,part:i}){const s=i?i.stats:t.stats;if(t.type===Ju&&this.bwEstimator.sampleTTFB(s.loading.first-s.loading.start),!this.ignoreFragment(t)){if(this.clearTimer(),t.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){const e=i?i.duration:t.duration,r=this.hls.levels[t.level],a=(r.loaded?r.loaded.bytes:0)+s.loaded,o=(r.loaded?r.loaded.duration:0)+e;r.loaded={bytes:a,duration:o},r.realBitrate=Math.round(8*a/o)}if(t.bitrateTest){const e={stats:s,frag:t,part:i,id:t.type};this.onFragBuffered(jh.FRAG_BUFFERED,e),t.bitrateTest=!1}else this.lastLoadedFragLevel=t.level}}onFragBuffered(e,t){const{frag:i,part:s}=t,r=null!=s&&s.stats.loaded?s.stats:i.stats;if(r.aborted)return;if(this.ignoreFragment(i))return;const a=r.parsing.end-r.loading.start-Math.min(r.loading.first-r.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(a,r.loaded),r.bwEstimate=this.getBwEstimate(),i.bitrateTest?this.bitrateTestDelay=a/1e3:this.bitrateTestDelay=0}ignoreFragment(e){return e.type!==Ju||"initSegment"===e.sn}clearTimer(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)}get firstAutoLevel(){const{maxAutoLevel:e,minAutoLevel:t}=this.hls,i=this.getBwEstimate(),s=this.hls.config.maxStarvationDelay,r=this.findBestLevel(i,t,e,0,s,1,1);if(r>-1)return r;const a=this.hls.firstLevel,o=Math.min(Math.max(a,t),e);return Jh.warn(`[abr] Could not find best starting auto level. Defaulting to first in playlist ${a} clamped to ${o}`),o}get forcedAutoLevel(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}get nextAutoLevel(){const e=this.forcedAutoLevel,t=this.bwEstimator.canEstimate(),i=this.lastLoadedFragLevel>-1;if(!(-1===e||t&&i&&this.nextAutoLevelKey!==this.getAutoLevelKey()))return e;const s=t&&i?this.getNextABRAutoLevel():this.firstAutoLevel;if(-1!==e){const t=this.hls.levels;if(t.length>Math.max(e,s)&&t[e].loadError<=t[s].loadError)return e}return this._nextAutoLevel=s,this.nextAutoLevelKey=this.getAutoLevelKey(),s}getAutoLevelKey(){return`${this.getBwEstimate()}_${this.getStarvationDelay().toFixed(2)}`}getNextABRAutoLevel(){const{fragCurrent:e,partCurrent:t,hls:i}=this,{maxAutoLevel:s,config:r,minAutoLevel:a}=i,o=t?t.duration:e?e.duration:0,n=this.getBwEstimate(),l=this.getStarvationDelay();let d=r.abrBandWidthFactor,h=r.abrBandWidthUpFactor;if(l){const e=this.findBestLevel(n,a,s,l,0,d,h);if(e>=0)return e}let c=o?Math.min(o,r.maxStarvationDelay):r.maxStarvationDelay;if(!l){const e=this.bitrateTestDelay;if(e){c=(o?Math.min(o,r.maxLoadingDelay):r.maxLoadingDelay)-e,Jh.info(`[abr] bitrate test took ${Math.round(1e3*e)}ms, set first fragment max fetchDuration to ${Math.round(1e3*c)} ms`),d=h=1}}const u=this.findBestLevel(n,a,s,l,c,d,h);if(Jh.info(`[abr] ${l?"rebuffering expected":"buffer is empty"}, optimal quality level ${u}`),u>-1)return u;const p=i.levels[a],f=i.levels[i.loadLevel];return(null==p?void 0:p.bitrate)<(null==f?void 0:f.bitrate)?a:i.loadLevel}getStarvationDelay(){const e=this.hls,t=e.media;if(!t)return 1/0;const i=t&&0!==t.playbackRate?Math.abs(t.playbackRate):1,s=e.mainForwardBufferInfo;return(s?s.len:0)/i}getBwEstimate(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate}findBestLevel(e,t,i,s,r,a,o){var n;const l=s+r,d=this.lastLoadedFragLevel,h=-1===d?this.hls.firstLevel:d,{fragCurrent:c,partCurrent:u}=this,{levels:p,allAudioTracks:f,loadLevel:m,config:g}=this.hls;if(1===p.length)return 0;const y=p[h],A=!(null==y||null==(n=y.details)||!n.live),b=-1===m||-1===d;let _,v="SDR",S=(null==y?void 0:y.frameRate)||0;const{audioPreference:w,videoPreference:E}=g,T=this.audioTracksByGroup||(this.audioTracksByGroup=function(e){return e.reduce(((e,t)=>{let i=e.groups[t.groupId];i||(i=e.groups[t.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),i.tracks.push(t);const s=t.channels||"2";return i.channels[s]=(i.channels[s]||0)+1,i.hasDefault=i.hasDefault||t.default,i.hasAutoSelect=i.hasAutoSelect||t.autoselect,i.hasDefault&&(e.hasDefaultAudio=!0),i.hasAutoSelect&&(e.hasAutoSelectAudio=!0),e}),{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}(f));if(b){if(-1!==this.firstSelection)return this.firstSelection;const s=this.codecTiers||(this.codecTiers=function(e,t,i,s){return e.slice(i,s+1).reduce(((e,i)=>{if(!i.codecSet)return e;const s=i.audioGroups;let r=e[i.codecSet];r||(e[i.codecSet]=r={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!s,fragmentError:0}),r.minBitrate=Math.min(r.minBitrate,i.bitrate);const a=Math.min(i.height,i.width);return r.minHeight=Math.min(r.minHeight,a),r.minFramerate=Math.min(r.minFramerate,i.frameRate),r.maxScore=Math.max(r.maxScore,i.score),r.fragmentError+=i.fragmentError,r.videoRanges[i.videoRange]=(r.videoRanges[i.videoRange]||0)+1,s&&s.forEach((e=>{if(!e)return;const i=t.groups[e];r.hasDefaultAudio=r.hasDefaultAudio||t.hasDefaultAudio?i.hasDefault:i.hasAutoSelect||!t.hasDefaultAudio&&!t.hasAutoSelectAudio,Object.keys(i.channels).forEach((e=>{r.channels[e]=(r.channels[e]||0)+i.channels[e]}))})),e}),{})}(p,T,t,i)),r=function(e,t,i,s,r){const a=Object.keys(e),o=null==s?void 0:s.channels,n=null==s?void 0:s.audioCodec,l=o&&2===parseInt(o);let d=!0,h=!1,c=1/0,u=1/0,p=1/0,f=0,m=[];const{preferHDR:g,allowedVideoRanges:y}=Xp(t,r);for(let t=a.length;t--;){const i=e[a[t]];d=i.channels[2]>0,c=Math.min(c,i.minHeight),u=Math.min(u,i.minFramerate),p=Math.min(p,i.minBitrate);const s=y.filter((e=>i.videoRanges[e]>0));s.length>0&&(h=!0,m=s)}c=Fh(c)?c:0,u=Fh(u)?u:0;const A=Math.max(1080,c),b=Math.max(30,u);p=Fh(p)?p:i,i=Math.max(p,i),h||(t=void 0,m=[]);const _=a.reduce(((t,s)=>{const r=e[s];if(s===t)return t;if(r.minBitrate>i)return Zp(s,`min bitrate of ${r.minBitrate} > current estimate of ${i}`),t;if(!r.hasDefaultAudio)return Zp(s,"no renditions with default or auto-select sound found"),t;if(n&&s.indexOf(n.substring(0,4))%5!=0)return Zp(s,`audio codec preference "${n}" not found`),t;if(o&&!l){if(!r.channels[o])return Zp(s,`no renditions with ${o} channel sound found (channels options: ${Object.keys(r.channels)})`),t}else if((!n||l)&&d&&0===r.channels[2])return Zp(s,"no renditions with stereo sound found"),t;return r.minHeight>A?(Zp(s,`min resolution of ${r.minHeight} > maximum of ${A}`),t):r.minFramerate>b?(Zp(s,`min framerate of ${r.minFramerate} > maximum of ${b}`),t):m.some((e=>r.videoRanges[e]>0))?r.maxScore<f?(Zp(s,`max score of ${r.maxScore} < selected max of ${f}`),t):t&&(Tu(s)>=Tu(t)||r.fragmentError>e[t].fragmentError)?t:(f=r.maxScore,s):(Zp(s,`no variants with VIDEO-RANGE of ${JSON.stringify(m)} found`),t)}),void 0);return{codecSet:_,videoRanges:m,preferHDR:g,minFramerate:u,minBitrate:p}}(s,v,e,w,E),{codecSet:a,videoRanges:o,minFramerate:n,minBitrate:l,preferHDR:d}=r;_=a,v=d?o[o.length-1]:o[0],S=n,e=Math.max(e,l),Jh.log(`[abr] picked start tier ${JSON.stringify(r)}`)}else _=null==y?void 0:y.codecSet,v=null==y?void 0:y.videoRange;const k=u?u.duration:c?c.duration:0,C=this.bwEstimator.getEstimateTTFB()/1e3,R=[];for(let n=i;n>=t;n--){var x;const t=p[n],c=n>h;if(!t)continue;if(g.useMediaCapabilities&&!t.supportedResult&&!t.supportedPromise){const i=navigator.mediaCapabilities;"function"==typeof(null==i?void 0:i.decodingInfo)&&Yp(t,T,v,S,e,w)?(t.supportedPromise=Qp(t,T,i),t.supportedPromise.then((e=>{if(!this.hls)return;t.supportedResult=e;const i=this.hls.levels,s=i.indexOf(t);e.error?Jh.warn(`[abr] MediaCapabilities decodingInfo error: "${e.error}" for level ${s} ${JSON.stringify(e)}`):e.supported||(Jh.warn(`[abr] Unsupported MediaCapabilities decodingInfo result for level ${s} ${JSON.stringify(e)}`),s>-1&&i.length>1&&(Jh.log(`[abr] Removing unsupported level ${s}`),this.hls.removeLevel(s)))}))):t.supportedResult=qp}if(_&&t.codecSet!==_||v&&t.videoRange!==v||c&&S>t.frameRate||!c&&S>0&&S<t.frameRate||t.supportedResult&&(null==(x=t.supportedResult.decodingInfoResults)||!x[0].smooth)){R.push(n);continue}const f=t.details,E=(u?null==f?void 0:f.partTarget:null==f?void 0:f.averagetargetduration)||k;let D;D=c?o*e:a*e;const L=k&&s>=2*k&&0===r?p[n].averageBitrate:p[n].maxBitrate,P=this.getTimeToLoadFrag(C,D,L*E,void 0===f);if(D>=L&&(n===d||0===t.loadError&&0===t.fragmentError)&&(P<=C||!Fh(P)||A&&!this.bitrateTestDelay||P<l)){const e=this.forcedAutoLevel;return n===m||-1!==e&&e===m||(R.length&&Jh.trace(`[abr] Skipped level(s) ${R.join(",")} of ${i} max with CODECS and VIDEO-RANGE:"${p[R[0]].codecs}" ${p[R[0]].videoRange}; not compatible with "${y.codecs}" ${v}`),Jh.info(`[abr] switch candidate:${h}->${n} adjustedbw(${Math.round(D)})-bitrate=${Math.round(D-L)} ttfb:${C.toFixed(1)} avgDuration:${E.toFixed(1)} maxFetchDuration:${l.toFixed(1)} fetchDuration:${P.toFixed(1)} firstSelection:${b} codecSet:${_} videoRange:${v} hls.loadLevel:${m}`)),b&&(this.firstSelection=n),n}}return-1}set nextAutoLevel(e){const{maxAutoLevel:t,minAutoLevel:i}=this.hls,s=Math.min(Math.max(e,i),t);this._nextAutoLevel!==s&&(this.nextAutoLevelKey="",this._nextAutoLevel=s)}},bufferController:class{constructor(e){this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendSource=void 0,this.appendErrors={audio:0,video:0,audiovideo:0},this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this.log=void 0,this.warn=void 0,this.error=void 0,this._onEndStreaming=e=>{this.hls&&this.hls.pauseBuffering()},this._onStartStreaming=e=>{this.hls&&this.hls.resumeBuffering()},this._onMediaSourceOpen=()=>{const{media:e,mediaSource:t}=this;this.log("Media source opened"),e&&(e.removeEventListener("emptied",this._onMediaEmptied),this.updateMediaElementDuration(),this.hls.trigger(jh.MEDIA_ATTACHED,{media:e,mediaSource:t})),t&&t.removeEventListener("sourceopen",this._onMediaSourceOpen),this.checkPendingTracks()},this._onMediaSourceClose=()=>{this.log("Media source closed")},this._onMediaSourceEnded=()=>{this.log("Media source ended")},this._onMediaEmptied=()=>{const{mediaSrc:e,_objectUrl:t}=this;e!==t&&Jh.error(`Media element src was set while attaching MediaSource (${t} > ${e})`)},this.hls=e;const t="[buffer-controller]";this.appendSource=e.config.preferManagedMediaSource&&"undefined"!=typeof self&&self.ManagedMediaSource,this.log=Jh.log.bind(Jh,t),this.warn=Jh.warn.bind(Jh,t),this.error=Jh.error.bind(Jh,t),this._initSourceBuffer(),this.registerListeners()}hasSourceTypes(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null,this.hls=null}registerListeners(){const{hls:e}=this;e.on(jh.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(jh.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(jh.MANIFEST_LOADING,this.onManifestLoading,this),e.on(jh.MANIFEST_PARSED,this.onManifestParsed,this),e.on(jh.BUFFER_RESET,this.onBufferReset,this),e.on(jh.BUFFER_APPENDING,this.onBufferAppending,this),e.on(jh.BUFFER_CODECS,this.onBufferCodecs,this),e.on(jh.BUFFER_EOS,this.onBufferEos,this),e.on(jh.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(jh.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(jh.FRAG_PARSED,this.onFragParsed,this),e.on(jh.FRAG_CHANGED,this.onFragChanged,this)}unregisterListeners(){const{hls:e}=this;e.off(jh.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(jh.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(jh.MANIFEST_LOADING,this.onManifestLoading,this),e.off(jh.MANIFEST_PARSED,this.onManifestParsed,this),e.off(jh.BUFFER_RESET,this.onBufferReset,this),e.off(jh.BUFFER_APPENDING,this.onBufferAppending,this),e.off(jh.BUFFER_CODECS,this.onBufferCodecs,this),e.off(jh.BUFFER_EOS,this.onBufferEos,this),e.off(jh.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(jh.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(jh.FRAG_PARSED,this.onFragParsed,this),e.off(jh.FRAG_CHANGED,this.onFragChanged,this)}_initSourceBuffer(){this.sourceBuffer={},this.operationQueue=new tg(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.appendErrors={audio:0,video:0,audiovideo:0},this.lastMpegAudioChunk=null}onManifestLoading(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null}onManifestParsed(e,t){let i=2;(t.audio&&!t.video||!t.altAudio)&&(i=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=i,this.log(`${this.bufferCodecEventsExpected} bufferCodec event(s) expected`)}onMediaAttaching(e,t){const i=this.media=t.media,s=bu(this.appendSource);if(i&&s){var r;const e=this.mediaSource=new s;this.log(`created media source: ${null==(r=e.constructor)?void 0:r.name}`),e.addEventListener("sourceopen",this._onMediaSourceOpen),e.addEventListener("sourceended",this._onMediaSourceEnded),e.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(e.addEventListener("startstreaming",this._onStartStreaming),e.addEventListener("endstreaming",this._onEndStreaming));const t=this._objectUrl=self.URL.createObjectURL(e);if(this.appendSource)try{i.removeAttribute("src");const s=self.ManagedMediaSource;i.disableRemotePlayback=i.disableRemotePlayback||s&&e instanceof s,sg(i),function(e,t){const i=self.document.createElement("source");i.type="video/mp4",i.src=t,e.appendChild(i)}(i,t),i.load()}catch(e){i.src=t}else i.src=t;i.addEventListener("emptied",this._onMediaEmptied)}}onMediaDetaching(){const{media:e,mediaSource:t,_objectUrl:i}=this;if(t){if(this.log("media source detaching"),"open"===t.readyState)try{t.endOfStream()}catch(e){this.warn(`onMediaDetaching: ${e.message} while calling endOfStream`)}this.onBufferReset(),t.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("sourceended",this._onMediaSourceEnded),t.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(t.removeEventListener("startstreaming",this._onStartStreaming),t.removeEventListener("endstreaming",this._onEndStreaming)),e&&(e.removeEventListener("emptied",this._onMediaEmptied),i&&self.URL.revokeObjectURL(i),this.mediaSrc===i?(e.removeAttribute("src"),this.appendSource&&sg(e),e.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(jh.MEDIA_DETACHED,void 0)}onBufferReset(){this.getSourceBufferTypes().forEach((e=>{this.resetBuffer(e)})),this._initSourceBuffer()}resetBuffer(e){const t=this.sourceBuffer[e];try{var i;if(t)this.removeBufferListeners(e),this.sourceBuffer[e]=void 0,null!=(i=this.mediaSource)&&i.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(t)}catch(t){this.warn(`onBufferReset ${e}`,t)}}onBufferCodecs(e,t){const i=this.getSourceBufferTypes().length,s=Object.keys(t);if(s.forEach((e=>{if(i){const i=this.tracks[e];if(i&&"function"==typeof i.buffer.changeType){var s;const{id:r,codec:a,levelCodec:o,container:n,metadata:l}=t[e],d=xu(i.codec,i.levelCodec),h=null==d?void 0:d.replace(ig,"$1");let c=xu(a,o);const u=null==(s=c)?void 0:s.replace(ig,"$1");if(c&&h!==u){"audio"===e.slice(0,5)&&(c=Ru(c,this.appendSource));const t=`${n};codecs=${c}`;this.appendChangeType(e,t),this.log(`switching codec ${d} to ${c}`),this.tracks[e]={buffer:i.buffer,codec:a,container:n,levelCodec:o,metadata:l,id:r}}}}else this.pendingTracks[e]=t[e]})),i)return;const r=Math.max(this.bufferCodecEventsExpected-1,0);this.bufferCodecEventsExpected!==r&&(this.log(`${r} bufferCodec event(s) expected ${s.join(",")}`),this.bufferCodecEventsExpected=r),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks()}appendChangeType(e,t){const{operationQueue:i}=this,s={execute:()=>{const s=this.sourceBuffer[e];s&&(this.log(`changing ${e} sourceBuffer type to ${t}`),s.changeType(t)),i.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:t=>{this.warn(`Failed to change ${e} SourceBuffer type`,t)}};i.append(s,e,!!this.pendingTracks[e])}onBufferAppending(e,t){const{hls:i,operationQueue:s,tracks:r}=this,{data:a,type:o,frag:n,part:l,chunkMeta:d}=t,h=d.buffering[o],c=self.performance.now();h.start=c;const u=n.stats.buffering,p=l?l.stats.buffering:null;0===u.start&&(u.start=c),p&&0===p.start&&(p.start=c);const f=r.audio;let m=!1;"audio"===o&&"audio/mpeg"===(null==f?void 0:f.container)&&(m=!this.lastMpegAudioChunk||1===d.id||this.lastMpegAudioChunk.sn!==d.sn,this.lastMpegAudioChunk=d);const g=n.start,y={execute:()=>{if(h.executeStart=self.performance.now(),m){const e=this.sourceBuffer[o];if(e){const t=g-e.timestampOffset;Math.abs(t)>=.1&&(this.log(`Updating audio SourceBuffer timestampOffset to ${g} (delta: ${t}) sn: ${n.sn})`),e.timestampOffset=g)}}this.appendExecutor(a,o)},onStart:()=>{},onComplete:()=>{const e=self.performance.now();h.executeEnd=h.end=e,0===u.first&&(u.first=e),p&&0===p.first&&(p.first=e);const{sourceBuffer:t}=this,i={};for(const e in t)i[e]=ff.getBuffered(t[e]);this.appendErrors[o]=0,"audio"===o||"video"===o?this.appendErrors.audiovideo=0:(this.appendErrors.audio=0,this.appendErrors.video=0),this.hls.trigger(jh.BUFFER_APPENDED,{type:o,frag:n,part:l,chunkMeta:d,parent:n.type,timeRanges:i})},onError:e=>{const t={type:zh.MEDIA_ERROR,parent:n.type,details:Gh.BUFFER_APPEND_ERROR,sourceBufferName:o,frag:n,part:l,chunkMeta:d,error:e,err:e,fatal:!1};if(e.code===DOMException.QUOTA_EXCEEDED_ERR)t.details=Gh.BUFFER_FULL_ERROR;else{const e=++this.appendErrors[o];t.details=Gh.BUFFER_APPEND_ERROR,this.warn(`Failed ${e}/${i.config.appendErrorMaxRetry} times to append segment in "${o}" sourceBuffer`),e>=i.config.appendErrorMaxRetry&&(t.fatal=!0)}i.trigger(jh.ERROR,t)}};s.append(y,o,!!this.pendingTracks[o])}onBufferFlushing(e,t){const{operationQueue:i}=this,s=e=>({execute:this.removeExecutor.bind(this,e,t.startOffset,t.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger(jh.BUFFER_FLUSHED,{type:e})},onError:t=>{this.warn(`Failed to remove from ${e} SourceBuffer`,t)}});t.type?i.append(s(t.type),t.type):this.getSourceBufferTypes().forEach((e=>{i.append(s(e),e)}))}onFragParsed(e,t){const{frag:i,part:s}=t,r=[],a=s?s.elementaryStreams:i.elementaryStreams;a[ic]?r.push("audiovideo"):(a[ec]&&r.push("audio"),a[tc]&&r.push("video"));0===r.length&&this.warn(`Fragments must have at least one ElementaryStreamType set. type: ${i.type} level: ${i.level} sn: ${i.sn}`),this.blockBuffers((()=>{const e=self.performance.now();i.stats.buffering.end=e,s&&(s.stats.buffering.end=e);const t=s?s.stats:i.stats;this.hls.trigger(jh.FRAG_BUFFERED,{frag:i,part:s,stats:t,id:i.type})}),r)}onFragChanged(e,t){this.trimBuffers()}onBufferEos(e,t){this.getSourceBufferTypes().reduce(((e,i)=>{const s=this.sourceBuffer[i];return!s||t.type&&t.type!==i||(s.ending=!0,s.ended||(s.ended=!0,this.log(`${i} sourceBuffer now EOS`))),e&&!(s&&!s.ended)}),!0)&&(this.log("Queueing mediaSource.endOfStream()"),this.blockBuffers((()=>{this.getSourceBufferTypes().forEach((e=>{const t=this.sourceBuffer[e];t&&(t.ending=!1)}));const{mediaSource:e}=this;e&&"open"===e.readyState?(this.log("Calling mediaSource.endOfStream()"),e.endOfStream()):e&&this.log(`Could not call mediaSource.endOfStream(). mediaSource.readyState: ${e.readyState}`)})))}onLevelUpdated(e,{details:t}){t.fragments.length&&(this.details=t,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())}trimBuffers(){const{hls:e,details:t,media:i}=this;if(!i||null===t)return;if(!this.getSourceBufferTypes().length)return;const s=e.config,r=i.currentTime,a=t.levelTargetDuration,o=t.live&&null!==s.liveBackBufferLength?s.liveBackBufferLength:s.backBufferLength;if(Fh(o)&&o>0){const e=Math.max(o,a),t=Math.floor(r/a)*a-e;this.flushBackBuffer(r,a,t)}if(Fh(s.frontBufferFlushThreshold)&&s.frontBufferFlushThreshold>0){const e=Math.max(s.maxBufferLength,s.frontBufferFlushThreshold),t=Math.max(e,a),i=Math.floor(r/a)*a+t;this.flushFrontBuffer(r,a,i)}}flushBackBuffer(e,t,i){const{details:s,sourceBuffer:r}=this;this.getSourceBufferTypes().forEach((a=>{const o=r[a];if(o){const r=ff.getBuffered(o);if(r.length>0&&i>r.start(0)){if(this.hls.trigger(jh.BACK_BUFFER_REACHED,{bufferEnd:i}),null!=s&&s.live)this.hls.trigger(jh.LIVE_BACK_BUFFER_REACHED,{bufferEnd:i});else if(o.ended&&r.end(r.length-1)-e<2*t)return void this.log(`Cannot flush ${a} back buffer while SourceBuffer is in ended state`);this.hls.trigger(jh.BUFFER_FLUSHING,{startOffset:0,endOffset:i,type:a})}}}))}flushFrontBuffer(e,t,i){const{sourceBuffer:s}=this;this.getSourceBufferTypes().forEach((r=>{const a=s[r];if(a){const s=ff.getBuffered(a),o=s.length;if(o<2)return;const n=s.start(o-1),l=s.end(o-1);if(i>n||e>=n&&e<=l)return;if(a.ended&&e-l<2*t)return void this.log(`Cannot flush ${r} front buffer while SourceBuffer is in ended state`);this.hls.trigger(jh.BUFFER_FLUSHING,{startOffset:n,endOffset:1/0,type:r})}}))}updateMediaElementDuration(){if(!this.details||!this.media||!this.mediaSource||"open"!==this.mediaSource.readyState)return;const{details:e,hls:t,media:i,mediaSource:s}=this,r=e.fragments[0].start+e.totalduration,a=i.duration,o=Fh(s.duration)?s.duration:0;e.live&&t.config.liveDurationInfinity?(s.duration=1/0,this.updateSeekableRange(e)):(r>o&&r>a||!Fh(a))&&(this.log(`Updating Media Source duration to ${r.toFixed(3)}`),s.duration=r)}updateSeekableRange(e){const t=this.mediaSource,i=e.fragments;if(i.length&&e.live&&null!=t&&t.setLiveSeekableRange){const s=Math.max(0,i[0].start),r=Math.max(s,s+e.totalduration);this.log(`Media Source duration is set to ${t.duration}. Setting seekable range to ${s}-${r}.`),t.setLiveSeekableRange(s,r)}}checkPendingTracks(){const{bufferCodecEventsExpected:e,operationQueue:t,pendingTracks:i}=this,s=Object.keys(i).length;if(s&&(!e||2===s||"audiovideo"in i)){this.createSourceBuffers(i),this.pendingTracks={};const e=this.getSourceBufferTypes();if(e.length)this.hls.trigger(jh.BUFFER_CREATED,{tracks:this.tracks}),e.forEach((e=>{t.executeNext(e)}));else{const e=new Error("could not create source buffer for media codec(s)");this.hls.trigger(jh.ERROR,{type:zh.MEDIA_ERROR,details:Gh.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:e,reason:e.message})}}}createSourceBuffers(e){const{sourceBuffer:t,mediaSource:i}=this;if(!i)throw Error("createSourceBuffers called when mediaSource was null");for(const s in e)if(!t[s]){const r=e[s];if(!r)throw Error(`source buffer exists for track ${s}, however track does not`);let a=r.levelCodec||r.codec;a&&"audio"===s.slice(0,5)&&(a=Ru(a,this.appendSource));const o=`${r.container};codecs=${a}`;this.log(`creating sourceBuffer(${o})`);try{const e=t[s]=i.addSourceBuffer(o),n=s;this.addBufferListener(n,"updatestart",this._onSBUpdateStart),this.addBufferListener(n,"updateend",this._onSBUpdateEnd),this.addBufferListener(n,"error",this._onSBUpdateError),this.appendSource&&this.addBufferListener(n,"bufferedchange",((e,t)=>{const i=t.removedRanges;null!=i&&i.length&&this.hls.trigger(jh.BUFFER_FLUSHED,{type:s})})),this.tracks[s]={buffer:e,codec:a,container:r.container,levelCodec:r.levelCodec,metadata:r.metadata,id:r.id}}catch(e){this.error(`error while trying to add sourceBuffer: ${e.message}`),this.hls.trigger(jh.ERROR,{type:zh.MEDIA_ERROR,details:Gh.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:e,sourceBufferName:s,mimeType:o})}}}get mediaSrc(){var e;const t=(null==(e=this.media)?void 0:e.firstChild)||this.media;return null==t?void 0:t.src}_onSBUpdateStart(e){const{operationQueue:t}=this;t.current(e).onStart()}_onSBUpdateEnd(e){var t;if("closed"===(null==(t=this.mediaSource)?void 0:t.readyState))return void this.resetBuffer(e);const{operationQueue:i}=this;i.current(e).onComplete(),i.shiftAndExecuteNext(e)}_onSBUpdateError(e,t){var i;const s=new Error(`${e} SourceBuffer error. MediaSource readyState: ${null==(i=this.mediaSource)?void 0:i.readyState}`);this.error(`${s}`,t),this.hls.trigger(jh.ERROR,{type:zh.MEDIA_ERROR,details:Gh.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:s,fatal:!1});const r=this.operationQueue.current(e);r&&r.onError(s)}removeExecutor(e,t,i){const{media:s,mediaSource:r,operationQueue:a,sourceBuffer:o}=this,n=o[e];if(!s||!r||!n)return this.warn(`Attempting to remove from the ${e} SourceBuffer, but it does not exist`),void a.shiftAndExecuteNext(e);const l=Fh(s.duration)?s.duration:1/0,d=Fh(r.duration)?r.duration:1/0,h=Math.max(0,t),c=Math.min(i,l,d);c>h&&(!n.ending||n.ended)?(n.ended=!1,this.log(`Removing [${h},${c}] from the ${e} SourceBuffer`),n.remove(h,c)):a.shiftAndExecuteNext(e)}appendExecutor(e,t){const i=this.sourceBuffer[t];if(i)i.ended=!1,i.appendBuffer(e);else if(!this.pendingTracks[t])throw new Error(`Attempting to append to the ${t} SourceBuffer, but it does not exist`)}blockBuffers(e,t=this.getSourceBufferTypes()){if(!t.length)return this.log("Blocking operation requested, but no SourceBuffers exist"),void Promise.resolve().then(e);const{operationQueue:i}=this,s=t.map((e=>i.appendBlocker(e)));Promise.all(s).then((()=>{e(),t.forEach((e=>{const t=this.sourceBuffer[e];null!=t&&t.updating||i.shiftAndExecuteNext(e)}))}))}getSourceBufferTypes(){return Object.keys(this.sourceBuffer)}addBufferListener(e,t,i){const s=this.sourceBuffer[e];if(!s)return;const r=i.bind(this,e);this.listeners[e].push({event:t,listener:r}),s.addEventListener(t,r)}removeBufferListeners(e){const t=this.sourceBuffer[e];t&&this.listeners[e].forEach((e=>{t.removeEventListener(e.event,e.listener)}))}},capLevelController:Xg,errorController:class{constructor(e){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=e,this.log=Jh.log.bind(Jh,"[info]:"),this.warn=Jh.warn.bind(Jh,"[warning]:"),this.error=Jh.error.bind(Jh,"[error]:"),this.registerListeners()}registerListeners(){const e=this.hls;e.on(jh.ERROR,this.onError,this),e.on(jh.MANIFEST_LOADING,this.onManifestLoading,this),e.on(jh.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const e=this.hls;e&&(e.off(jh.ERROR,this.onError,this),e.off(jh.ERROR,this.onErrorOut,this),e.off(jh.MANIFEST_LOADING,this.onManifestLoading,this),e.off(jh.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}}startLoad(e){}stopLoad(){this.playlistError=0}getVariantLevelIndex(e){return(null==e?void 0:e.type)===Ju?e.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={}}onLevelUpdated(){this.playlistError=0}onError(e,t){var i,s;if(t.fatal)return;const r=this.hls,a=t.context;switch(t.details){case Gh.FRAG_LOAD_ERROR:case Gh.FRAG_LOAD_TIMEOUT:case Gh.KEY_LOAD_ERROR:case Gh.KEY_LOAD_TIMEOUT:return void(t.errorAction=this.getFragRetryOrSwitchAction(t));case Gh.FRAG_PARSING_ERROR:if(null!=(i=t.frag)&&i.gap)return void(t.errorAction={action:Op,flags:Gp});case Gh.FRAG_GAP:case Gh.FRAG_DECRYPT_ERROR:return t.errorAction=this.getFragRetryOrSwitchAction(t),void(t.errorAction.action=Np);case Gh.LEVEL_EMPTY_ERROR:case Gh.LEVEL_PARSING_ERROR:{var o,n;const e=t.parent===Ju?t.level:r.loadLevel;t.details===Gh.LEVEL_EMPTY_ERROR&&null!=(o=t.context)&&null!=(n=o.levelDetails)&&n.live?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,e):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,e))}return;case Gh.LEVEL_LOAD_ERROR:case Gh.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==a?void 0:a.level)&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,a.level)));case Gh.AUDIO_TRACK_LOAD_ERROR:case Gh.AUDIO_TRACK_LOAD_TIMEOUT:case Gh.SUBTITLE_LOAD_ERROR:case Gh.SUBTITLE_TRACK_LOAD_TIMEOUT:if(a){const e=r.levels[r.loadLevel];if(e&&(a.type===Vu&&e.hasAudioGroup(a.groupId)||a.type===Wu&&e.hasSubtitleGroup(a.groupId)))return t.errorAction=this.getPlaylistRetryOrSwitchAction(t,r.loadLevel),t.errorAction.action=Np,void(t.errorAction.flags=Hp)}return;case Gh.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{const e=r.levels[r.loadLevel],i=null==e?void 0:e.attrs["HDCP-LEVEL"];i?t.errorAction={action:Np,flags:$p,hdcpLevel:i}:this.keySystemError(t)}return;case Gh.BUFFER_ADD_CODEC_ERROR:case Gh.REMUX_ALLOC_ERROR:case Gh.BUFFER_APPEND_ERROR:return void(t.errorAction=this.getLevelSwitchAction(t,null!=(s=t.level)?s:r.loadLevel));case Gh.INTERNAL_EXCEPTION:case Gh.BUFFER_APPENDING_ERROR:case Gh.BUFFER_FULL_ERROR:case Gh.LEVEL_SWITCH_ERROR:case Gh.BUFFER_STALLED_ERROR:case Gh.BUFFER_SEEK_OVER_HOLE:case Gh.BUFFER_NUDGE_ON_STALL:return void(t.errorAction={action:Op,flags:Gp})}t.type===zh.KEY_SYSTEM_ERROR&&this.keySystemError(t)}keySystemError(e){const t=this.getVariantLevelIndex(e.frag);e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,t)}getPlaylistRetryOrSwitchAction(e,t){const i=Dp(this.hls.config.playlistLoadPolicy,e),s=this.playlistError++;if(Bp(i,s,xp(e),e.response))return{action:zp,flags:Gp,retryConfig:i,retryCount:s};const r=this.getLevelSwitchAction(e,t);return i&&(r.retryConfig=i,r.retryCount=s),r}getFragRetryOrSwitchAction(e){const t=this.hls,i=this.getVariantLevelIndex(e.frag),s=t.levels[i],{fragLoadPolicy:r,keyLoadPolicy:a}=t.config,o=Dp(e.details.startsWith("key")?a:r,e),n=t.levels.reduce(((e,t)=>e+t.fragmentError),0);if(s){e.details!==Gh.FRAG_GAP&&s.fragmentError++;if(Bp(o,n,xp(e),e.response))return{action:zp,flags:Gp,retryConfig:o,retryCount:n}}const l=this.getLevelSwitchAction(e,i);return o&&(l.retryConfig=o,l.retryCount=n),l}getLevelSwitchAction(e,t){const i=this.hls;null==t&&(t=i.loadLevel);const s=this.hls.levels[t];if(s){var r,a;const t=e.details;s.loadError++,t===Gh.BUFFER_APPEND_ERROR&&s.fragmentError++;let l=-1;const{levels:d,loadLevel:h,minAutoLevel:c,maxAutoLevel:u}=i;i.autoLevelEnabled||(i.loadLevel=-1);const p=null==(r=e.frag)?void 0:r.type,f=(p===qu&&t===Gh.FRAG_PARSING_ERROR||"audio"===e.sourceBufferName&&(t===Gh.BUFFER_ADD_CODEC_ERROR||t===Gh.BUFFER_APPEND_ERROR))&&d.some((({audioCodec:e})=>s.audioCodec!==e)),m="video"===e.sourceBufferName&&(t===Gh.BUFFER_ADD_CODEC_ERROR||t===Gh.BUFFER_APPEND_ERROR)&&d.some((({codecSet:e,audioCodec:t})=>s.codecSet!==e&&s.audioCodec===t)),{type:g,groupId:y}=null!=(a=e.context)?a:{};for(let i=d.length;i--;){const r=(i+h)%d.length;if(r!==h&&r>=c&&r<=u&&0===d[r].loadError){var o,n;const i=d[r];if(t===Gh.FRAG_GAP&&e.frag){const t=d[r].details;if(t){const i=Mp(e.frag,t.fragments,e.frag.start);if(null!=i&&i.gap)continue}}else{if(g===Vu&&i.hasAudioGroup(y)||g===Wu&&i.hasSubtitleGroup(y))continue;if(p===qu&&null!=(o=s.audioGroups)&&o.some((e=>i.hasAudioGroup(e)))||p===Ku&&null!=(n=s.subtitleGroups)&&n.some((e=>i.hasSubtitleGroup(e)))||f&&s.audioCodec===i.audioCodec||!f&&s.audioCodec!==i.audioCodec||m&&s.codecSet===i.codecSet)continue}l=r;break}}if(l>-1&&i.loadLevel!==l)return e.levelRetry=!0,this.playlistError=0,{action:Np,flags:Gp,nextAutoLevel:l}}return{action:Np,flags:Hp}}onErrorOut(e,t){var i;switch(null==(i=t.errorAction)?void 0:i.action){case Op:break;case Np:this.sendAlternateToPenaltyBox(t),t.errorAction.resolved||t.details===Gh.FRAG_GAP?/MediaSource readyState: ended/.test(t.error.message)&&(this.warn(`MediaSource ended after "${t.sourceBufferName}" sourceBuffer append error. Attempting to recover from media error.`),this.hls.recoverMediaError()):t.fatal=!0}t.fatal&&this.hls.stopLoad()}sendAlternateToPenaltyBox(e){const t=this.hls,i=e.errorAction;if(!i)return;const{flags:s,hdcpLevel:r,nextAutoLevel:a}=i;switch(s){case Gp:this.switchLevel(e,a);break;case $p:r&&(t.maxHdcpLevel=pp[pp.indexOf(r)-1],i.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`)}i.resolved||this.switchLevel(e,a)}switchLevel(e,t){void 0!==t&&e.errorAction&&(this.warn(`switching to level ${t} after ${e.details}`),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)}},fpsController:class{constructor(e){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=e,this.registerListeners()}setStreamController(e){this.streamController=e}registerListeners(){this.hls.on(jh.MEDIA_ATTACHING,this.onMediaAttaching,this)}unregisterListeners(){this.hls.off(jh.MEDIA_ATTACHING,this.onMediaAttaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(e,t){const i=this.hls.config;if(i.capLevelOnFPSDrop){const e=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=e,e&&"function"==typeof e.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),i.fpsDroppedMonitoringPeriod)}}checkFPS(e,t,i){const s=performance.now();if(t){if(this.lastTime){const e=s-this.lastTime,r=i-this.lastDroppedFrames,a=t-this.lastDecodedFrames,o=1e3*r/e,n=this.hls;if(n.trigger(jh.FPS_DROP,{currentDropped:r,currentDecoded:a,totalDroppedFrames:i}),o>0&&r>n.config.fpsDroppedMonitoringThreshold*a){let e=n.currentLevel;Jh.warn("drop FPS ratio greater than max allowed value for currentLevel: "+e),e>0&&(-1===n.autoLevelCapping||n.autoLevelCapping>=e)&&(e-=1,n.trigger(jh.FPS_DROP_LEVEL_CAPPING,{level:e,droppedLevel:n.currentLevel}),n.autoLevelCapping=e,this.streamController.nextLevelSwitch())}}this.lastTime=s,this.lastDroppedFrames=i,this.lastDecodedFrames=t}}checkFPSInterval(){const e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){const t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}},stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:_c,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,useMediaCapabilities:!0,certLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null}},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},{cueHandler:Ky,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:class extends Hf{constructor(e,t,i){super(e,t,i,"[subtitle-stream-controller]",Ku),this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null}_registerListeners(){const{hls:e}=this;e.on(jh.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(jh.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(jh.MANIFEST_LOADING,this.onManifestLoading,this),e.on(jh.LEVEL_LOADED,this.onLevelLoaded,this),e.on(jh.ERROR,this.onError,this),e.on(jh.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(jh.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(jh.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(jh.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(jh.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(jh.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:e}=this;e.off(jh.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(jh.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(jh.MANIFEST_LOADING,this.onManifestLoading,this),e.off(jh.LEVEL_LOADED,this.onLevelLoaded,this),e.off(jh.ERROR,this.onError,this),e.off(jh.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(jh.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(jh.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(jh.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(jh.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(jh.FRAG_BUFFERED,this.onFragBuffered,this)}startLoad(e){this.stopLoad(),this.state=Pf,this.setInterval(500),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}onManifestLoading(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()}onMediaDetaching(){this.tracksBuffered=[],super.onMediaDetaching()}onLevelLoaded(e,t){this.mainDetails=t.details}onSubtitleFragProcessed(e,t){const{frag:i,success:s}=t;if(this.fragPrevious=i,this.state=Pf,!s)return;const r=this.tracksBuffered[this.currentTrackId];if(!r)return;let a;const o=i.start;for(let e=0;e<r.length;e++)if(o>=r[e].start&&o<=r[e].end){a=r[e];break}const n=i.start+i.duration;a?a.end=n:(a={start:o,end:n},r.push(a)),this.fragmentTracker.fragBuffered(i),this.fragBufferedComplete(i,null)}onBufferFlushing(e,t){const{startOffset:i,endOffset:s}=t;if(0===i&&s!==Number.POSITIVE_INFINITY){const e=s-1;if(e<=0)return;t.endOffsetSubtitles=Math.max(0,e),this.tracksBuffered.forEach((t=>{for(let i=0;i<t.length;)if(t[i].end<=e)t.shift();else{if(!(t[i].start<e))break;t[i].start=e,i++}})),this.fragmentTracker.removeFragmentsInRange(i,e,Ku)}}onFragBuffered(e,t){var i;this.loadedmetadata||t.frag.type!==Ju||null!=(i=this.media)&&i.buffered.length&&(this.loadedmetadata=!0)}onError(e,t){const i=t.frag;(null==i?void 0:i.type)===Ku&&(this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==Lf&&(this.state=Pf))}onSubtitleTracksUpdated(e,{subtitleTracks:t}){this.levels&&Qm(this.levels,t)?this.levels=t.map((e=>new bp(e))):(this.tracksBuffered=[],this.levels=t.map((e=>{const t=new bp(e);return this.tracksBuffered[t.id]=[],t})),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,Ku),this.fragPrevious=null,this.mediaBuffer=null)}onSubtitleTrackSwitch(e,t){var i;if(this.currentTrackId=t.id,null==(i=this.levels)||!i.length||-1===this.currentTrackId)return void this.clearInterval();const s=this.levels[this.currentTrackId];null!=s&&s.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,s&&this.setInterval(500)}onSubtitleTrackLoaded(e,t){var i;const{currentTrackId:s,levels:r}=this,{details:a,id:o}=t;if(!r)return void this.warn(`Subtitle tracks were reset while loading level ${o}`);const n=r[s];if(o>=r.length||o!==s||!n)return;this.log(`Subtitle track ${o} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""},duration:${a.totalduration}`),this.mediaBuffer=this.mediaBufferTimeRanges;let l=0;if(a.live||null!=(i=n.details)&&i.live){const e=this.mainDetails;if(a.deltaUpdateFailed||!e)return;const t=e.fragments[0];var d;if(n.details)l=this.alignPlaylists(a,n.details,null==(d=this.levelLastLoaded)?void 0:d.details),0===l&&t&&(l=t.start,Tp(a,l));else a.hasProgramDateTime&&e.hasProgramDateTime?(_f(a,e),l=a.fragments[0].start):t&&(l=t.start,Tp(a,l))}if(n.details=a,this.levelLastLoaded=n,this.startFragRequested||!this.mainDetails&&a.live||this.setStartPosition(this.mainDetails||a,l),this.tick(),a.live&&!this.fragCurrent&&this.media&&this.state===Pf){Mp(null,a.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),n.details=void 0)}}_handleFragmentLoadComplete(e){const{frag:t,payload:i}=e,s=t.decryptdata,r=this.hls;if(!this.fragContextChanged(t)&&i&&i.byteLength>0&&null!=s&&s.key&&s.iv&&"AES-128"===s.method){const e=performance.now();this.decrypter.decrypt(new Uint8Array(i),s.key.buffer,s.iv.buffer).catch((e=>{throw r.trigger(jh.ERROR,{type:zh.MEDIA_ERROR,details:Gh.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:t}),e})).then((i=>{const s=performance.now();r.trigger(jh.FRAG_DECRYPTED,{frag:t,payload:i,stats:{tstart:e,tdecrypt:s}})})).catch((e=>{this.warn(`${e.name}: ${e.message}`),this.state=Pf}))}}doTick(){if(this.media){if(this.state===Pf){const{currentTrackId:e,levels:t}=this,i=null==t?void 0:t[e];if(!i||!t.length||!i.details)return;const{config:s}=this,r=this.getLoadPosition(),a=ff.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],r,s.maxBufferHole),{end:o,len:n}=a,l=this.getFwdBufferInfo(this.media,Ju),d=i.details;if(n>this.getMaxBufferLength(null==l?void 0:l.len)+d.levelTargetDuration)return;const h=d.fragments,c=h.length,u=d.edge;let p=null;const f=this.fragPrevious;if(o<u){const e=s.maxFragLookUpTolerance,t=o>u-e?0:e;p=Mp(f,h,Math.max(h[0].start,o),t),!p&&f&&f.start<h[0].start&&(p=h[0])}else p=h[c-1];if(!p)return;if(p=this.mapToInitFragWhenRequired(p),"initSegment"!==p.sn){const e=h[p.sn-d.startSN-1];e&&e.cc===p.cc&&this.fragmentTracker.getState(e)===of&&(p=e)}this.fragmentTracker.getState(p)===of&&this.loadFragment(p,i,o)}}else this.state=Pf}getMaxBufferLength(e){const t=super.getMaxBufferLength();return e?Math.max(t,e):t}loadFragment(e,t,i){this.fragCurrent=e,"initSegment"===e.sn?this._loadInitSegment(e,t):(this.startFragRequested=!0,super.loadFragment(e,t,i))}get mediaBufferTimeRanges(){return new eg(this.tracksBuffered[this.currentTrackId]||[])}},subtitleTrackController:class extends Vp{constructor(e){super(e,"[subtitle-track-controller]"),this.media=null,this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.queuedDefaultTrack=-1,this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.onTextTracksChanged=()=>{if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let e=null;const t=sp(this.media.textTracks);for(let i=0;i<t.length;i++)if("hidden"===t[i].mode)e=t[i];else if("showing"===t[i].mode){e=t[i];break}const i=this.findTrackForTextTrack(e);this.subtitleTrack!==i&&this.setSubtitleTrack(i)},this.registerListeners()}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,this.onTextTracksChanged=this.asyncPollTrackChange=null,super.destroy()}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes()}registerListeners(){const{hls:e}=this;e.on(jh.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(jh.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(jh.MANIFEST_LOADING,this.onManifestLoading,this),e.on(jh.MANIFEST_PARSED,this.onManifestParsed,this),e.on(jh.LEVEL_LOADING,this.onLevelLoading,this),e.on(jh.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(jh.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(jh.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(jh.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(jh.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(jh.MANIFEST_LOADING,this.onManifestLoading,this),e.off(jh.MANIFEST_PARSED,this.onManifestParsed,this),e.off(jh.LEVEL_LOADING,this.onLevelLoading,this),e.off(jh.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(jh.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(jh.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))}pollTrackChange(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.onTextTracksChanged,e)}onMediaDetaching(){if(!this.media)return;self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId);sp(this.media.textTracks).forEach((e=>{tp(e)})),this.subtitleTrack=-1,this.media=null}onManifestLoading(){this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.subtitleTracks}onSubtitleTrackLoaded(e,t){const{id:i,groupId:s,details:r}=t,a=this.tracksInGroup[i];if(!a||a.groupId!==s)return void this.warn(`Subtitle track with id:${i} and group:${s} not found in active group ${null==a?void 0:a.groupId}`);const o=a.details;a.details=t.details,this.log(`Subtitle track ${i} "${a.name}" lang:${a.lang} group:${s} loaded [${r.startSN}-${r.endSN}]`),i===this.trackId&&this.playlistLoaded(i,t,o)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(!t)return;const i=t.subtitleGroups||null,s=this.groupIds;let r=this.currentTrack;if(!i||(null==s?void 0:s.length)!==(null==i?void 0:i.length)||null!=i&&i.some((e=>-1===(null==s?void 0:s.indexOf(e))))){this.groupIds=i,this.trackId=-1,this.currentTrack=null;const e=this.tracks.filter((e=>!i||-1!==i.indexOf(e.groupId)));if(e.length)this.selectDefaultTrack&&!e.some((e=>e.default))&&(this.selectDefaultTrack=!1),e.forEach(((e,t)=>{e.id=t}));else if(!r&&!this.tracksInGroup.length)return;this.tracksInGroup=e;const t=this.hls.config.subtitlePreference;if(!r&&t){this.selectDefaultTrack=!1;const i=ef(t,e);if(i>-1)r=e[i];else{const e=ef(t,this.tracks);r=this.tracks[e]}}let s=this.findTrackId(r);-1===s&&r&&(s=this.findTrackId(null));const a={subtitleTracks:e};this.log(`Updating subtitle tracks, ${e.length} track(s) found in "${null==i?void 0:i.join(",")}" group-id`),this.hls.trigger(jh.SUBTITLE_TRACKS_UPDATED,a),-1!==s&&-1===this.trackId&&this.setSubtitleTrack(s)}else this.shouldReloadPlaylist(r)&&this.setSubtitleTrack(this.trackId)}findTrackId(e){const t=this.tracksInGroup,i=this.selectDefaultTrack;for(let s=0;s<t.length;s++){const r=t[s];if((!i||r.default)&&(i||e)&&(!e||tf(r,e)))return s}if(e){for(let i=0;i<t.length;i++){const s=t[i];if(Xm(e.attrs,s.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return i}for(let i=0;i<t.length;i++){const s=t[i];if(Xm(e.attrs,s.attrs,["LANGUAGE"]))return i}}return-1}findTrackForTextTrack(e){if(e){const t=this.tracksInGroup;for(let i=0;i<t.length;i++){if(Zm(t[i],e))return i}}return-1}onError(e,t){!t.fatal&&t.context&&(t.context.type!==Wu||t.context.id!==this.trackId||this.groupIds&&-1===this.groupIds.indexOf(t.context.groupId)||this.checkRetry(t))}get allSubtitleTracks(){return this.tracks}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(e){this.selectDefaultTrack=!1,this.setSubtitleTrack(e)}setSubtitleOption(e){if(this.hls.config.subtitlePreference=e,e){const t=this.allSubtitleTracks;if(this.selectDefaultTrack=!1,t.length){const i=this.currentTrack;if(i&&tf(e,i))return i;const s=ef(e,this.tracksInGroup);if(s>-1){const e=this.tracksInGroup[s];return this.setSubtitleTrack(s),e}if(i)return null;{const i=ef(e,t);if(i>-1)return t[i]}}}return null}loadPlaylist(e){super.loadPlaylist();const t=this.currentTrack;if(this.shouldLoadPlaylist(t)&&t){const i=t.id,s=t.groupId;let r=t.url;if(e)try{r=e.addDirectives(r)}catch(e){this.warn(`Could not construct new URL with HLS Delivery Directives: ${e}`)}this.log(`Loading subtitle playlist for id ${i}`),this.hls.trigger(jh.SUBTITLE_TRACK_LOADING,{url:r,id:i,groupId:s,deliveryDirectives:e||null})}}toggleTrackModes(){const{media:e}=this;if(!e)return;const t=sp(e.textTracks),i=this.currentTrack;let s;if(i&&(s=t.filter((e=>Zm(i,e)))[0],s||this.warn(`Unable to find subtitle TextTrack with name "${i.name}" and language "${i.lang}"`)),[].slice.call(t).forEach((e=>{"disabled"!==e.mode&&e!==s&&(e.mode="disabled")})),s){const e=this.subtitleDisplay?"showing":"hidden";s.mode!==e&&(s.mode=e)}}setSubtitleTrack(e){const t=this.tracksInGroup;if(!this.media)return void(this.queuedDefaultTrack=e);if(e<-1||e>=t.length||!Fh(e))return void this.warn(`Invalid subtitle track id: ${e}`);this.clearTimer(),this.selectDefaultTrack=!1;const i=this.currentTrack,s=t[e]||null;if(this.trackId=e,this.currentTrack=s,this.toggleTrackModes(),!s)return void this.hls.trigger(jh.SUBTITLE_TRACK_SWITCH,{id:e});const r=!!s.details&&!s.details.live;if(e===this.trackId&&s===i&&r)return;this.log(`Switching to subtitle-track ${e}`+(s?` "${s.name}" lang:${s.lang} group:${s.groupId}`:""));const{id:a,groupId:o="",name:n,type:l,url:d}=s;this.hls.trigger(jh.SUBTITLE_TRACK_SWITCH,{id:a,groupId:o,name:n,type:l,url:d});const h=this.switchParams(s.url,null==i?void 0:i.details);this.loadPlaylist(h)}},timelineController:class{constructor(e){this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this.captionsProperties=void 0,this.hls=e,this.config=e.config,this.Cues=e.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},e.on(jh.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(jh.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(jh.MANIFEST_LOADING,this.onManifestLoading,this),e.on(jh.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(jh.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(jh.FRAG_LOADING,this.onFragLoading,this),e.on(jh.FRAG_LOADED,this.onFragLoaded,this),e.on(jh.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(jh.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(jh.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(jh.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(jh.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:e}=this;e.off(jh.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(jh.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(jh.MANIFEST_LOADING,this.onManifestLoading,this),e.off(jh.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(jh.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(jh.FRAG_LOADING,this.onFragLoading,this),e.off(jh.FRAG_LOADED,this.onFragLoaded,this),e.off(jh.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(jh.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(jh.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(jh.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(jh.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=null,this.cea608Parser1=this.cea608Parser2=void 0}initCea608Parsers(){if(this.config.enableCEA708Captions&&(!this.cea608Parser1||!this.cea608Parser2)){const e=new wg(this,"textTrack1"),t=new wg(this,"textTrack2"),i=new wg(this,"textTrack3"),s=new wg(this,"textTrack4");this.cea608Parser1=new _g(1,e,t),this.cea608Parser2=new _g(3,i,s)}}addCues(e,t,i,s,r){let a=!1;for(let e=r.length;e--;){const s=r[e],h=(o=s[0],n=s[1],l=t,d=i,Math.min(n,d)-Math.max(o,l));if(h>=0&&(s[0]=Math.min(s[0],t),s[1]=Math.max(s[1],i),a=!0,h/(i-t)>.5))return}var o,n,l,d;if(a||r.push([t,i]),this.config.renderTextTracksNatively){const r=this.captionsTracks[e];this.Cues.newCue(r,t,i,s)}else{const r=this.Cues.newCue(null,t,i,s);this.hls.trigger(jh.CUES_PARSED,{type:"captions",cues:r,track:e})}}onInitPtsFound(e,{frag:t,id:i,initPTS:s,timescale:r}){const{unparsedVttFrags:a}=this;"main"===i&&(this.initPTS[t.cc]={baseTime:s,timescale:r}),a.length&&(this.unparsedVttFrags=[],a.forEach((e=>{this.onFragLoaded(jh.FRAG_LOADED,e)})))}getExistingTrack(e,t){const{media:i}=this;if(i)for(let s=0;s<i.textTracks.length;s++){const r=i.textTracks[s];if(Qg(r,{name:e,lang:t,attrs:{}}))return r}return null}createCaptionsTrack(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}createNativeTrack(e){if(this.captionsTracks[e])return;const{captionsProperties:t,captionsTracks:i,media:s}=this,{label:r,languageCode:a}=t[e],o=this.getExistingTrack(r,a);if(o)i[e]=o,tp(i[e]),Zu(i[e],s);else{const t=this.createTextTrack("captions",r,a);t&&(t[e]=!0,i[e]=t)}}createNonNativeTrack(e){if(this.nonNativeCaptionsTracks[e])return;const t=this.captionsProperties[e];if(!t)return;const i={_id:e,label:t.label,kind:"captions",default:!!t.media&&!!t.media.default,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=i,this.hls.trigger(jh.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[i]})}createTextTrack(e,t,i){const s=this.media;if(s)return s.addTextTrack(e,t,i)}onMediaAttaching(e,t){this.media=t.media,this._cleanTracks()}onMediaDetaching(){const{captionsTracks:e}=this;Object.keys(e).forEach((t=>{tp(e[t]),delete e[t]})),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}_cleanTracks(){const{media:e}=this;if(!e)return;const t=e.textTracks;if(t)for(let e=0;e<t.length;e++)tp(t[e])}onSubtitleTracksUpdated(e,t){const i=t.subtitleTracks||[],s=i.some((e=>e.textCodec===Ng));if(this.config.enableWebVTT||s&&this.config.enableIMSC1){if(Qm(this.tracks,i))return void(this.tracks=i);if(this.textTracks=[],this.tracks=i,this.config.renderTextTracksNatively){const e=this.media,t=e?sp(e.textTracks):null;if(this.tracks.forEach(((e,i)=>{let s;if(t){let i=null;for(let s=0;s<t.length;s++)if(t[s]&&Qg(t[s],e)){i=t[s],t[s]=null;break}i&&(s=i)}if(s)tp(s);else{const t=Yg(e);s=this.createTextTrack(t,e.name,e.lang),s&&(s.mode="disabled")}s&&this.textTracks.push(s)})),null!=t&&t.length){const e=t.filter((e=>null!==e)).map((e=>e.label));e.length&&Jh.warn(`Media element contains unused subtitle tracks: ${e.join(", ")}. Replace media element for each source to clear TextTracks and captions menu.`)}}else if(this.tracks.length){const e=this.tracks.map((e=>({label:e.name,kind:e.type.toLowerCase(),default:e.default,subtitleTrack:e})));this.hls.trigger(jh.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:e})}}}onManifestLoaded(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach((e=>{const t=/(?:CC|SERVICE)([1-4])/.exec(e.instreamId);if(!t)return;const i=`textTrack${t[1]}`,s=this.captionsProperties[i];s&&(s.label=e.name,e.lang&&(s.languageCode=e.lang),s.media=e)}))}closedCaptionsForLevel(e){const t=this.hls.levels[e.level];return null==t?void 0:t.attrs["CLOSED-CAPTIONS"]}onFragLoading(e,t){this.initCea608Parsers();const{cea608Parser1:i,cea608Parser2:s,lastCc:r,lastSn:a,lastPartIndex:o}=this;if(this.enabled&&i&&s&&t.frag.type===Ju){var n,l;const{cc:e,sn:d}=t.frag,h=null!=(n=null==t||null==(l=t.part)?void 0:l.index)?n:-1;d===a+1||d===a&&h===o+1||e===r||(i.reset(),s.reset()),this.lastCc=e,this.lastSn=d,this.lastPartIndex=h}}onFragLoaded(e,t){const{frag:i,payload:s}=t;if(i.type===Ku)if(s.byteLength){const e=i.decryptdata,r="stats"in t;if(null==e||!e.encrypted||r){const e=this.tracks[i.level],r=this.vttCCs;r[i.cc]||(r[i.cc]={start:i.start,prevCC:this.prevCC,new:!0},this.prevCC=i.cc),e&&e.textCodec===Ng?this._parseIMSC1(i,s):this._parseVTTs(t)}}else this.hls.trigger(jh.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,t){const i=this.hls;Hg(t,this.initPTS[e.cc],(t=>{this._appendCues(t,e.level),i.trigger(jh.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})}),(t=>{Jh.log(`Failed to parse IMSC1: ${t}`),i.trigger(jh.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:t})}))}_parseVTTs(e){var t;const{frag:i,payload:s}=e,{initPTS:r,unparsedVttFrags:a}=this,o=r.length-1;if(!r[i.cc]&&-1===o)return void a.push(e);const n=this.hls;Og(null!=(t=i.initSegment)&&t.data?au(i.initSegment.data,new Uint8Array(s)):s,this.initPTS[i.cc],this.vttCCs,i.cc,i.start,(e=>{this._appendCues(e,i.level),n.trigger(jh.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:i})}),(t=>{const r="Missing initPTS for VTT MPEGTS"===t.message;r?a.push(e):this._fallbackToIMSC1(i,s),Jh.log(`Failed to parse VTT cue: ${t}`),r&&o>i.cc||n.trigger(jh.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:t})}))}_fallbackToIMSC1(e,t){const i=this.tracks[e.level];i.textCodec||Hg(t,this.initPTS[e.cc],(()=>{i.textCodec=Ng,this._parseIMSC1(e,t)}),(()=>{i.textCodec="wvtt"}))}_appendCues(e,t){const i=this.hls;if(this.config.renderTextTracksNatively){const i=this.textTracks[t];if(!i||"disabled"===i.mode)return;e.forEach((e=>ep(i,e)))}else{const s=this.tracks[t];if(!s)return;const r=s.default?"default":"subtitles"+t;i.trigger(jh.CUES_PARSED,{type:"subtitles",cues:e,track:r})}}onFragDecrypted(e,t){const{frag:i}=t;i.type===Ku&&this.onFragLoaded(jh.FRAG_LOADED,t)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(e,t){this.initCea608Parsers();const{cea608Parser1:i,cea608Parser2:s}=this;if(!this.enabled||!i||!s)return;const{frag:r,samples:a}=t;if(r.type!==Ju||"NONE"!==this.closedCaptionsForLevel(r))for(let e=0;e<a.length;e++){const t=a[e].bytes;if(t){const r=this.extractCea608Data(t);i.addData(a[e].pts,r[0]),s.addData(a[e].pts,r[1])}}}onBufferFlushing(e,{startOffset:t,endOffset:i,endOffsetSubtitles:s,type:r}){const{media:a}=this;if(a&&!(a.currentTime<i)){if(!r||"video"===r){const{captionsTracks:e}=this;Object.keys(e).forEach((s=>ip(e[s],t,i)))}if(this.config.renderTextTracksNatively&&0===t&&void 0!==s){const{textTracks:e}=this;Object.keys(e).forEach((i=>ip(e[i],t,s)))}}}extractCea608Data(e){const t=[[],[]],i=31&e[0];let s=2;for(let r=0;r<i;r++){const i=e[s++],r=127&e[s++],a=127&e[s++];if(0===r&&0===a)continue;if(!!(4&i)){const e=3&i;0!==e&&1!==e||(t[e].push(r),t[e].push(a))}}return t}},audioStreamController:class extends Hf{constructor(e,t,i){super(e,t,i,"[audio-stream-controller]",qu),this.videoBuffer=null,this.videoTrackCC=-1,this.waitingVideoCC=-1,this.bufferedTrack=null,this.switchingTrack=null,this.trackId=-1,this.waitingData=null,this.mainDetails=null,this.flushing=!1,this.bufferFlushed=!1,this.cachedTrackLoadedData=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null,this.bufferedTrack=null,this.switchingTrack=null}_registerListeners(){const{hls:e}=this;e.on(jh.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(jh.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(jh.MANIFEST_LOADING,this.onManifestLoading,this),e.on(jh.LEVEL_LOADED,this.onLevelLoaded,this),e.on(jh.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(jh.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(jh.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(jh.ERROR,this.onError,this),e.on(jh.BUFFER_RESET,this.onBufferReset,this),e.on(jh.BUFFER_CREATED,this.onBufferCreated,this),e.on(jh.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(jh.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(jh.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(jh.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:e}=this;e.off(jh.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(jh.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(jh.MANIFEST_LOADING,this.onManifestLoading,this),e.off(jh.LEVEL_LOADED,this.onLevelLoaded,this),e.off(jh.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(jh.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(jh.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(jh.ERROR,this.onError,this),e.off(jh.BUFFER_RESET,this.onBufferReset,this),e.off(jh.BUFFER_CREATED,this.onBufferCreated,this),e.off(jh.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(jh.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(jh.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(jh.FRAG_BUFFERED,this.onFragBuffered,this)}onInitPtsFound(e,{frag:t,id:i,initPTS:s,timescale:r}){if("main"===i){const e=t.cc;this.initPTS[t.cc]={baseTime:s,timescale:r},this.log(`InitPTS for cc: ${e} found from main: ${s}`),this.videoTrackCC=e,this.state===zf&&this.tick()}}startLoad(e){if(!this.levels)return this.startPosition=e,void(this.state=Lf);const t=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),t>0&&-1===e?(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t,this.state=Pf):(this.loadedmetadata=!1,this.state=Uf),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}doTick(){switch(this.state){case Pf:this.doTickIdle();break;case Uf:{var e;const{levels:t,trackId:i}=this,s=null==t||null==(e=t[i])?void 0:e.details;if(s){if(this.waitForCdnTuneIn(s))break;this.state=zf}break}case Mf:{var t;const e=performance.now(),i=this.retryDate;if(!i||e>=i||null!=(t=this.media)&&t.seeking){const{levels:e,trackId:t}=this;this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded((null==e?void 0:e[t])||null),this.state=Pf}break}case zf:{const e=this.waitingData;if(e){const{frag:t,part:i,cache:s,complete:r}=e;if(void 0!==this.initPTS[t.cc]){this.waitingData=null,this.waitingVideoCC=-1,this.state=If;const e={frag:t,part:i,payload:s.flush(),networkDetails:null};this._handleFragmentLoadProgress(e),r&&super._handleFragmentLoadComplete(e)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log(`Waiting fragment cc (${t.cc}) cancelled because video is at cc ${this.videoTrackCC}`),this.clearWaitingFragment();else{const e=this.getLoadPosition(),i=ff.bufferInfo(this.mediaBuffer,e,this.config.maxBufferHole);Up(i.end,this.config.maxFragLookUpTolerance,t)<0&&(this.log(`Waiting fragment cc (${t.cc}) @ ${t.start} cancelled because another fragment at ${i.end} is needed`),this.clearWaitingFragment())}}else this.state=Pf}}this.onTickEnd()}clearWaitingFragment(){const e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=Pf)}resetLoadingState(){this.clearWaitingFragment(),super.resetLoadingState()}onTickEnd(){const{media:e}=this;null!=e&&e.readyState&&(this.lastCurrentTime=e.currentTime)}doTickIdle(){const{hls:e,levels:t,media:i,trackId:s}=this,r=e.config;if(!i&&(this.startFragRequested||!r.startFragPrefetch)||null==t||!t[s])return;const a=t[s],o=a.details;if(!o||o.live&&this.levelLastLoaded!==a||this.waitForCdnTuneIn(o))return void(this.state=Uf);const n=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&n&&(this.bufferFlushed=!1,this.afterBufferFlushed(n,ec,qu));const l=this.getFwdBufferInfo(n,qu);if(null===l)return;const{bufferedTrack:d,switchingTrack:h}=this;if(!h&&this._streamEnded(l,o))return e.trigger(jh.BUFFER_EOS,{type:"audio"}),void(this.state=Nf);const c=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,Ju),u=l.len,p=this.getMaxBufferLength(null==c?void 0:c.len),f=o.fragments,m=f[0].start;let g=this.flushing?this.getLoadPosition():l.end;if(h&&i){const e=this.getLoadPosition();d&&!Xm(h.attrs,d.attrs)&&(g=e),o.PTSKnown&&e<m&&(l.end>m||l.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),i.currentTime=m+.05)}if(u>=p&&!h&&g<f[f.length-1].start)return;let y=this.getNextFragment(g,o),A=!1;if(y&&this.isLoopLoading(y,g)&&(A=!!y.gap,y=this.getNextFragmentLoopLoading(y,o,l,Ju,p)),!y)return void(this.bufferFlushed=!0);const b=c&&y.start>c.end+o.targetduration;if(b||(null==c||!c.len)&&l.len){const e=this.getAppendedFrag(y.start,Ju);if(null===e)return;if(A||(A=!!e.gap||!!b&&0===c.len),b&&!A||A&&l.nextStart&&l.nextStart<e.end)return}this.loadFragment(y,a,g)}getMaxBufferLength(e){const t=super.getMaxBufferLength();return e?Math.min(Math.max(t,e),this.config.maxMaxBufferLength):t}onMediaDetaching(){this.videoBuffer=null,this.bufferFlushed=this.flushing=!1,super.onMediaDetaching()}onAudioTracksUpdated(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map((e=>new bp(e)))}onAudioTrackSwitching(e,t){const i=!!t.url;this.trackId=t.id;const{fragCurrent:s}=this;s&&(s.abortRequests(),this.removeUnbufferedFrags(s.start)),this.resetLoadingState(),i?this.setInterval(100):this.resetTransmuxer(),i?(this.switchingTrack=t,this.state=Pf,this.flushAudioIfNeeded(t)):(this.switchingTrack=null,this.bufferedTrack=t,this.state=Lf),this.tick()}onManifestLoading(){this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=this.flushing=!1,this.levels=this.mainDetails=this.waitingData=this.bufferedTrack=this.cachedTrackLoadedData=this.switchingTrack=null,this.startFragRequested=!1,this.trackId=this.videoTrackCC=this.waitingVideoCC=-1}onLevelLoaded(e,t){this.mainDetails=t.details,null!==this.cachedTrackLoadedData&&(this.hls.trigger(jh.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)}onAudioTrackLoaded(e,t){var i;if(null==this.mainDetails)return void(this.cachedTrackLoadedData=t);const{levels:s}=this,{details:r,id:a}=t;if(!s)return void this.warn(`Audio tracks were reset while loading level ${a}`);this.log(`Audio track ${a} loaded [${r.startSN},${r.endSN}]${r.lastPartSn?`[part-${r.lastPartSn}-${r.lastPartIndex}]`:""},duration:${r.totalduration}`);const o=s[a];let n=0;if(r.live||null!=(i=o.details)&&i.live){this.checkLiveUpdate(r);const e=this.mainDetails;if(r.deltaUpdateFailed||!e)return;var l;if(!o.details&&r.hasProgramDateTime&&e.hasProgramDateTime)_f(r,e),n=r.fragments[0].start;else n=this.alignPlaylists(r,o.details,null==(l=this.levelLastLoaded)?void 0:l.details)}o.details=r,this.levelLastLoaded=o,this.startFragRequested||!this.mainDetails&&r.live||this.setStartPosition(this.mainDetails||r,n),this.state!==Uf||this.waitForCdnTuneIn(r)||(this.state=Pf),this.tick()}_handleFragmentLoadProgress(e){var t;const{frag:i,part:s,payload:r}=e,{config:a,trackId:o,levels:n}=this;if(!n)return void this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`);const l=n[o];if(!l)return void this.warn("Audio track is undefined on fragment load progress");const d=l.details;if(!d)return this.warn("Audio track details undefined on fragment load progress"),void this.removeUnbufferedFrags(i.start);const h=a.defaultAudioCodec||l.audioCodec||"mp4a.40.2";let c=this.transmuxer;c||(c=this.transmuxer=new Ym(this.hls,qu,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));const u=this.initPTS[i.cc],p=null==(t=i.initSegment)?void 0:t.data;if(void 0!==u){const e=!1,t=s?s.index:-1,a=-1!==t,o=new mf(i.level,i.sn,i.stats.chunkCount,r.byteLength,t,a);c.push(r,p,h,"",i,s,d.totalduration,e,o,u)}else{this.log(`Unknown video PTS for cc ${i.cc}, waiting for video PTS before demuxing audio frag ${i.sn} of [${d.startSN} ,${d.endSN}],track ${o}`);const{cache:e}=this.waitingData=this.waitingData||{frag:i,part:s,cache:new $f,complete:!1};e.push(new Uint8Array(r)),this.waitingVideoCC=this.videoTrackCC,this.state=zf}}_handleFragmentLoadComplete(e){this.waitingData?this.waitingData.complete=!0:super._handleFragmentLoadComplete(e)}onBufferReset(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1}onBufferCreated(e,t){const i=t.tracks.audio;i&&(this.mediaBuffer=i.buffer||null),t.tracks.video&&(this.videoBuffer=t.tracks.video.buffer||null)}onFragBuffered(e,t){const{frag:i,part:s}=t;if(i.type===qu)if(this.fragContextChanged(i))this.warn(`Fragment ${i.sn}${s?" p: "+s.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);else{if("initSegment"!==i.sn){this.fragPrevious=i;const e=this.switchingTrack;e&&(this.bufferedTrack=e,this.switchingTrack=null,this.hls.trigger(jh.AUDIO_TRACK_SWITCHED,Bh({},e)))}this.fragBufferedComplete(i,s)}else if(!this.loadedmetadata&&i.type===Ju){const e=this.videoBuffer||this.media;if(e){ff.getBuffered(e).length&&(this.loadedmetadata=!0)}}}onError(e,t){var i;if(t.fatal)this.state=jf;else switch(t.details){case Gh.FRAG_GAP:case Gh.FRAG_PARSING_ERROR:case Gh.FRAG_DECRYPT_ERROR:case Gh.FRAG_LOAD_ERROR:case Gh.FRAG_LOAD_TIMEOUT:case Gh.KEY_LOAD_ERROR:case Gh.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(qu,t);break;case Gh.AUDIO_TRACK_LOAD_ERROR:case Gh.AUDIO_TRACK_LOAD_TIMEOUT:case Gh.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==Uf||(null==(i=t.context)?void 0:i.type)!==Vu||(this.state=Pf);break;case Gh.BUFFER_APPEND_ERROR:case Gh.BUFFER_FULL_ERROR:if(!t.parent||"audio"!==t.parent)return;if(t.details===Gh.BUFFER_APPEND_ERROR)return void this.resetLoadingState();this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case Gh.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}onBufferFlushing(e,{type:t}){t!==tc&&(this.flushing=!0)}onBufferFlushed(e,{type:t}){if(t!==tc){this.flushing=!1,this.bufferFlushed=!0,this.state===Nf&&(this.state=Pf);const e=this.mediaBuffer||this.media;e&&(this.afterBufferFlushed(e,t,qu),this.tick())}}_handleTransmuxComplete(e){var t;const i="audio",{hls:s}=this,{remuxResult:r,chunkMeta:a}=e,o=this.getCurrentContext(a);if(!o)return void this.resetWhenMissingContext(a);const{frag:n,part:l,level:d}=o,{details:h}=d,{audio:c,text:u,id3:p,initSegment:f}=r;if(!this.fragContextChanged(n)&&h){if(this.state=Ff,this.switchingTrack&&c&&this.completeAudioSwitch(this.switchingTrack),null!=f&&f.tracks){const e=n.initSegment||n;this._bufferInitSegment(d,f.tracks,e,a),s.trigger(jh.FRAG_PARSING_INIT_SEGMENT,{frag:e,id:i,tracks:f.tracks})}if(c){const{startPTS:e,endPTS:t,startDTS:i,endDTS:s}=c;l&&(l.elementaryStreams[ec]={startPTS:e,endPTS:t,startDTS:i,endDTS:s}),n.setElementaryStreamInfo(ec,e,t,i,s),this.bufferFragmentData(c,n,l,a)}if(null!=p&&null!=(t=p.samples)&&t.length){const e=Uh({id:i,frag:n,details:h},p);s.trigger(jh.FRAG_PARSING_METADATA,e)}if(u){const e=Uh({id:i,frag:n,details:h},u);s.trigger(jh.FRAG_PARSING_USERDATA,e)}}else this.fragmentTracker.removeFragment(n)}_bufferInitSegment(e,t,i,s){if(this.state!==Ff)return;t.video&&delete t.video;const r=t.audio;if(!r)return;r.id="audio";const a=e.audioCodec;this.log(`Init audio buffer, container:${r.container}, codecs[level/parsed]=[${a}/${r.codec}]`),a&&1===a.split(",").length&&(r.levelCodec=a),this.hls.trigger(jh.BUFFER_CODECS,t);const o=r.initSegment;if(null!=o&&o.byteLength){const e={type:"audio",frag:i,part:null,chunkMeta:s,parent:i.type,data:o};this.hls.trigger(jh.BUFFER_APPENDING,e)}this.tickImmediate()}loadFragment(e,t,i){const s=this.fragmentTracker.getState(e);var r;if(this.fragCurrent=e,this.switchingTrack||s===of||s===lf)if("initSegment"===e.sn)this._loadInitSegment(e,t);else if(null!=(r=t.details)&&r.live&&!this.initPTS[e.cc]){this.log(`Waiting for video PTS in continuity counter ${e.cc} of live stream before loading audio fragment ${e.sn} of level ${this.trackId}`),this.state=zf;const i=this.mainDetails;i&&i.fragments[0].start!==t.details.fragments[0].start&&_f(t.details,i)}else this.startFragRequested=!0,super.loadFragment(e,t,i);else this.clearTrackerIfNeeded(e)}flushAudioIfNeeded(e){const{media:t,bufferedTrack:i}=this,s=null==i?void 0:i.attrs,r=e.attrs;t&&s&&(s.CHANNELS!==r.CHANNELS||i.name!==e.name||i.lang!==e.lang)&&(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"),this.bufferedTrack=null)}completeAudioSwitch(e){const{hls:t}=this;this.flushAudioIfNeeded(e),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(jh.AUDIO_TRACK_SWITCHED,Bh({},e))}},audioTrackController:class extends Vp{constructor(e){super(e,"[audio-track-controller]"),this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){const{hls:e}=this;e.on(jh.MANIFEST_LOADING,this.onManifestLoading,this),e.on(jh.MANIFEST_PARSED,this.onManifestParsed,this),e.on(jh.LEVEL_LOADING,this.onLevelLoading,this),e.on(jh.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(jh.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(jh.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(jh.MANIFEST_LOADING,this.onManifestLoading,this),e.off(jh.MANIFEST_PARSED,this.onManifestParsed,this),e.off(jh.LEVEL_LOADING,this.onLevelLoading,this),e.off(jh.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(jh.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(jh.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.tracksInGroup=[],this.groupIds=null,this.currentTrack=null,this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.audioTracks||[]}onAudioTrackLoaded(e,t){const{id:i,groupId:s,details:r}=t,a=this.tracksInGroup[i];if(!a||a.groupId!==s)return void this.warn(`Audio track with id:${i} and group:${s} not found in active group ${null==a?void 0:a.groupId}`);const o=a.details;a.details=t.details,this.log(`Audio track ${i} "${a.name}" lang:${a.lang} group:${s} loaded [${r.startSN}-${r.endSN}]`),i===this.trackId&&this.playlistLoaded(i,t,o)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(!t)return;const i=t.audioGroups||null,s=this.groupIds;let r=this.currentTrack;if(!i||(null==s?void 0:s.length)!==(null==i?void 0:i.length)||null!=i&&i.some((e=>-1===(null==s?void 0:s.indexOf(e))))){this.groupIds=i,this.trackId=-1,this.currentTrack=null;const e=this.tracks.filter((e=>!i||-1!==i.indexOf(e.groupId)));if(e.length)this.selectDefaultTrack&&!e.some((e=>e.default))&&(this.selectDefaultTrack=!1),e.forEach(((e,t)=>{e.id=t}));else if(!r&&!this.tracksInGroup.length)return;this.tracksInGroup=e;const t=this.hls.config.audioPreference;if(!r&&t){const i=ef(t,e,sf);if(i>-1)r=e[i];else{const e=ef(t,this.tracks);r=this.tracks[e]}}let s=this.findTrackId(r);-1===s&&r&&(s=this.findTrackId(null));const o={audioTracks:e};this.log(`Updating audio tracks, ${e.length} track(s) found in group(s): ${null==i?void 0:i.join(",")}`),this.hls.trigger(jh.AUDIO_TRACKS_UPDATED,o);const n=this.trackId;if(-1!==s&&-1===n)this.setAudioTrack(s);else if(e.length&&-1===n){var a;const t=new Error(`No audio track selected for current audio group-ID(s): ${null==(a=this.groupIds)?void 0:a.join(",")} track count: ${e.length}`);this.warn(t.message),this.hls.trigger(jh.ERROR,{type:zh.MEDIA_ERROR,details:Gh.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:t})}}else this.shouldReloadPlaylist(r)&&this.setAudioTrack(this.trackId)}onError(e,t){!t.fatal&&t.context&&(t.context.type!==Vu||t.context.id!==this.trackId||this.groupIds&&-1===this.groupIds.indexOf(t.context.groupId)||(this.requestScheduled=-1,this.checkRetry(t)))}get allAudioTracks(){return this.tracks}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}setAudioOption(e){const t=this.hls;if(t.config.audioPreference=e,e){const i=this.allAudioTracks;if(this.selectDefaultTrack=!1,i.length){const s=this.currentTrack;if(s&&tf(e,s,sf))return s;const r=ef(e,this.tracksInGroup,sf);if(r>-1){const e=this.tracksInGroup[r];return this.setAudioTrack(r),e}if(s){let s=t.loadLevel;-1===s&&(s=t.firstAutoLevel);const r=function(e,t,i,s,r){const a=t[s],o=t.reduce(((e,t,i)=>{const s=t.uri;return(e[s]||(e[s]=[])).push(i),e}),{})[a.uri];o.length>1&&(s=Math.max.apply(Math,o));const n=a.videoRange,l=a.frameRate,d=a.codecSet.substring(0,4),h=rf(t,s,(t=>{if(t.videoRange!==n||t.frameRate!==l||t.codecSet.substring(0,4)!==d)return!1;const s=t.audioGroups,a=i.filter((e=>!s||-1!==s.indexOf(e.groupId)));return ef(e,a,r)>-1}));return h>-1?h:rf(t,s,(t=>{const s=t.audioGroups,a=i.filter((e=>!s||-1!==s.indexOf(e.groupId)));return ef(e,a,r)>-1}))}(e,t.levels,i,s,sf);if(-1===r)return null;t.nextLoadLevel=r}if(e.channels||e.audioCodec){const t=ef(e,i);if(t>-1)return i[t]}}}return null}setAudioTrack(e){const t=this.tracksInGroup;if(e<0||e>=t.length)return void this.warn(`Invalid audio track id: ${e}`);this.clearTimer(),this.selectDefaultTrack=!1;const i=this.currentTrack,s=t[e],r=s.details&&!s.details.live;if(e===this.trackId&&s===i&&r)return;if(this.log(`Switching to audio-track ${e} "${s.name}" lang:${s.lang} group:${s.groupId} channels:${s.channels}`),this.trackId=e,this.currentTrack=s,this.hls.trigger(jh.AUDIO_TRACK_SWITCHING,Bh({},s)),r)return;const a=this.switchParams(s.url,null==i?void 0:i.details);this.loadPlaylist(a)}findTrackId(e){const t=this.tracksInGroup;for(let i=0;i<t.length;i++){const s=t[i];if((!this.selectDefaultTrack||s.default)&&(!e||tf(e,s,sf)))return i}if(e){const{name:i,lang:s,assocLang:r,characteristics:a,audioCodec:o,channels:n}=e;for(let e=0;e<t.length;e++){if(tf({name:i,lang:s,assocLang:r,characteristics:a,audioCodec:o,channels:n},t[e],sf))return e}for(let i=0;i<t.length;i++){const s=t[i];if(Xm(e.attrs,s.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return i}for(let i=0;i<t.length;i++){const s=t[i];if(Xm(e.attrs,s.attrs,["LANGUAGE"]))return i}}return-1}loadPlaylist(e){const t=this.currentTrack;if(this.shouldLoadPlaylist(t)&&t){super.loadPlaylist();const i=t.id,s=t.groupId;let r=t.url;if(e)try{r=e.addDirectives(r)}catch(e){this.warn(`Could not construct new URL with HLS Delivery Directives: ${e}`)}this.log(`loading audio-track playlist ${i} "${t.name}" lang:${t.lang} group:${s}`),this.clearTimer(),this.hls.trigger(jh.AUDIO_TRACK_LOADING,{url:r,id:i,groupId:s,deliveryDirectives:e||null})}}},emeController:ey,cmcdController:class{constructor(e){this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.includeKeys=void 0,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=e=>{try{this.apply(e,{ot:iy.MANIFEST,su:!this.initialized})}catch(e){Jh.warn("Could not generate manifest CMCD data.",e)}},this.applyFragmentData=e=>{try{const t=e.frag,i=this.hls.levels[t.level],s=this.getObjectType(t),r={d:1e3*t.duration,ot:s};s!==iy.VIDEO&&s!==iy.AUDIO&&s!=iy.MUXED||(r.br=i.bitrate/1e3,r.tb=this.getTopBandwidth(s)/1e3,r.bl=this.getBufferLength(s)),this.apply(e,r)}catch(e){Jh.warn("Could not generate segment CMCD data.",e)}},this.hls=e;const t=this.config=e.config,{cmcd:i}=t;null!=i&&(t.pLoader=this.createPlaylistLoader(),t.fLoader=this.createFragmentLoader(),this.sid=i.sessionId||function(){try{return crypto.randomUUID()}catch(e){try{const e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}catch(e){let t=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{const i=(t+16*Math.random())%16|0;return t=Math.floor(t/16),("x"==e?i:3&i|8).toString(16)}))}}}(),this.cid=i.contentId,this.useHeaders=!0===i.useHeaders,this.includeKeys=i.includeKeys,this.registerListeners())}registerListeners(){const e=this.hls;e.on(jh.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(jh.MEDIA_DETACHED,this.onMediaDetached,this),e.on(jh.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const e=this.hls;e.off(jh.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(jh.MEDIA_DETACHED,this.onMediaDetached,this),e.off(jh.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null,this.onWaiting=this.onPlaying=null}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}onMediaDetached(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}onBufferCreated(e,t){var i,s;this.audioBuffer=null==(i=t.tracks.audio)?void 0:i.buffer,this.videoBuffer=null==(s=t.tracks.video)?void 0:s.buffer}createData(){var e;return{v:1,sf:sy.HLS,sid:this.sid,cid:this.cid,pr:null==(e=this.media)?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){Uh(t,this.createData());const i=t.ot===iy.INIT||t.ot===iy.VIDEO||t.ot===iy.MUXED;this.starved&&i&&(t.bs=!0,t.su=!0,this.starved=!1),null==t.su&&(t.su=this.buffering);const{includeKeys:s}=this;s&&(t=Object.keys(t).reduce(((e,i)=>(s.includes(i)&&(e[i]=t[i]),e)),{})),this.useHeaders?(e.headers||(e.headers={}),Uy(e.headers,t)):e.url=Ny(e.url,t)}getObjectType(e){const{type:t}=e;return"subtitle"===t?iy.TIMED_TEXT:"initSegment"===e.sn?iy.INIT:"audio"===t?iy.AUDIO:"main"===t?this.hls.audioTracks.length?iy.VIDEO:iy.MUXED:void 0}getTopBandwidth(e){let t,i=0;const s=this.hls;if(e===iy.AUDIO)t=s.audioTracks;else{const e=s.maxAutoLevel,i=e>-1?e+1:s.levels.length;t=s.levels.slice(0,i)}for(const e of t)e.bitrate>i&&(i=e.bitrate);return i>0?i:NaN}getBufferLength(e){const t=this.hls.media,i=e===iy.AUDIO?this.audioBuffer:this.videoBuffer;if(!i||!t)return NaN;return 1e3*ff.bufferInfo(i,t.currentTime,this.config.maxBufferHole).len}createPlaylistLoader(){const{pLoader:e}=this.config,t=this.applyPlaylistData,i=e||this.config.loader;return class{constructor(e){this.loader=void 0,this.loader=new i(e)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(e,i,s){t(e),this.loader.load(e,i,s)}}}createFragmentLoader(){const{fLoader:e}=this.config,t=this.applyFragmentData,i=e||this.config.loader;return class{constructor(e){this.loader=void 0,this.loader=new i(e)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(e,i,s){t(e),this.loader.load(e,i,s)}}}},contentSteeringController:class{constructor(e){this.hls=void 0,this.log=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this.pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=e,this.log=Jh.log.bind(Jh,"[content-steering]:"),this.registerListeners()}registerListeners(){const e=this.hls;e.on(jh.MANIFEST_LOADING,this.onManifestLoading,this),e.on(jh.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(jh.MANIFEST_PARSED,this.onManifestParsed,this),e.on(jh.ERROR,this.onError,this)}unregisterListeners(){const e=this.hls;e&&(e.off(jh.MANIFEST_LOADING,this.onManifestLoading,this),e.off(jh.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(jh.MANIFEST_PARSED,this.onManifestParsed,this),e.off(jh.ERROR,this.onError,this))}startLoad(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){const e=1e3*this.timeToLoad-(performance.now()-this.updated);if(e>0)return void this.scheduleRefresh(this.uri,e)}this.loadSteeringManifest(this.uri)}}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()}clearTimeout(){-1!==this.reloadTimer&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(e){const t=this.levels;t&&(this.levels=t.filter((t=>t!==e)))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(e,t){const{contentSteering:i}=t;null!==i&&(this.pathwayId=i.pathwayId,this.uri=i.uri,this.started&&this.startLoad())}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}onError(e,t){const{errorAction:i}=t;if((null==i?void 0:i.action)===Np&&i.flags===Hp){const e=this.levels;let s=this.pathwayPriority,r=this.pathwayId;if(t.context){const{groupId:i,pathwayId:s,type:a}=t.context;i&&e?r=this.getPathwayForGroupId(i,a,r):s&&(r=s)}r in this.penalizedPathways||(this.penalizedPathways[r]=performance.now()),!s&&e&&(s=e.reduce(((e,t)=>(-1===e.indexOf(t.pathwayId)&&e.push(t.pathwayId),e)),[])),s&&s.length>1&&(this.updatePathwayPriority(s),i.resolved=this.pathwayId!==r),i.resolved||Jh.warn(`Could not resolve ${t.details} ("${t.error.message}") with content-steering for Pathway: ${r} levels: ${e?e.length:e} priorities: ${JSON.stringify(s)} penalized: ${JSON.stringify(this.penalizedPathways)}`)}}filterParsedLevels(e){this.levels=e;let t=this.getLevelsForPathway(this.pathwayId);if(0===t.length){const i=e[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${i}"`),t=this.getLevelsForPathway(i),this.pathwayId=i}return t.length!==e.length?(this.log(`Found ${t.length}/${e.length} levels in Pathway "${this.pathwayId}"`),t):e}getLevelsForPathway(e){return null===this.levels?[]:this.levels.filter((t=>e===t.pathwayId))}updatePathwayPriority(e){let t;this.pathwayPriority=e;const i=this.penalizedPathways,s=performance.now();Object.keys(i).forEach((e=>{s-i[e]>3e5&&delete i[e]}));for(let s=0;s<e.length;s++){const r=e[s];if(r in i)continue;if(r===this.pathwayId)return;const a=this.hls.nextLoadLevel,o=this.hls.levels[a];if(t=this.getLevelsForPathway(r),t.length>0){this.log(`Setting Pathway to "${r}"`),this.pathwayId=r,Rp(t),this.hls.trigger(jh.LEVELS_UPDATED,{levels:t});const e=this.hls.levels[a];o&&e&&this.levels&&(e.attrs["STABLE-VARIANT-ID"]!==o.attrs["STABLE-VARIANT-ID"]&&e.bitrate!==o.bitrate&&this.log(`Unstable Pathways change from bitrate ${o.bitrate} to ${e.bitrate}`),this.hls.nextLoadLevel=a);break}}}getPathwayForGroupId(e,t,i){const s=this.getLevelsForPathway(i).concat(this.levels||[]);for(let i=0;i<s.length;i++)if(t===Vu&&s[i].hasAudioGroup(e)||t===Wu&&s[i].hasSubtitleGroup(e))return s[i].pathwayId;return i}clonePathways(e){const t=this.levels;if(!t)return;const i={},s={};e.forEach((e=>{const{ID:r,"BASE-ID":a,"URI-REPLACEMENT":o}=e;if(t.some((e=>e.pathwayId===r)))return;const n=this.getLevelsForPathway(a).map((e=>{const t=new Yh(e.attrs);t["PATHWAY-ID"]=r;const a=t.AUDIO&&`${t.AUDIO}_clone_${r}`,n=t.SUBTITLES&&`${t.SUBTITLES}_clone_${r}`;a&&(i[t.AUDIO]=a,t.AUDIO=a),n&&(s[t.SUBTITLES]=n,t.SUBTITLES=n);const l=zy(e.uri,t["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",o),d=new bp({attrs:t,audioCodec:e.audioCodec,bitrate:e.bitrate,height:e.height,name:e.name,url:l,videoCodec:e.videoCodec,width:e.width});if(e.audioGroups)for(let t=1;t<e.audioGroups.length;t++)d.addGroupId("audio",`${e.audioGroups[t]}_clone_${r}`);if(e.subtitleGroups)for(let t=1;t<e.subtitleGroups.length;t++)d.addGroupId("text",`${e.subtitleGroups[t]}_clone_${r}`);return d}));t.push(...n),jy(this.audioTracks,i,o,r),jy(this.subtitleTracks,s,o,r)}))}loadSteeringManifest(e){const t=this.hls.config,i=t.loader;let s;this.loader&&this.loader.destroy(),this.loader=new i(t);try{s=new self.URL(e)}catch(t){return this.enabled=!1,void this.log(`Failed to parse Steering Manifest URI: ${e}`)}if("data:"!==s.protocol){const e=0|(this.hls.bandwidthEstimate||t.abrEwmaDefaultEstimate);s.searchParams.set("_HLS_pathway",this.pathwayId),s.searchParams.set("_HLS_throughput",""+e)}const r={responseType:"json",url:s.href},a=t.steeringManifestLoadPolicy.default,o=a.errorRetry||a.timeoutRetry||{},n={loadPolicy:a,timeout:a.maxLoadTimeMs,maxRetry:o.maxNumRetry||0,retryDelay:o.retryDelayMs||0,maxRetryDelay:o.maxRetryDelayMs||0},l={onSuccess:(e,t,i,r)=>{this.log(`Loaded steering manifest: "${s}"`);const a=e.data;if(1!==a.VERSION)return void this.log(`Steering VERSION ${a.VERSION} not supported!`);this.updated=performance.now(),this.timeToLoad=a.TTL;const{"RELOAD-URI":o,"PATHWAY-CLONES":n,"PATHWAY-PRIORITY":l}=a;if(o)try{this.uri=new self.URL(o,s).href}catch(e){return this.enabled=!1,void this.log(`Failed to parse Steering Manifest RELOAD-URI: ${o}`)}this.scheduleRefresh(this.uri||i.url),n&&this.clonePathways(n);const d={steeringManifest:a,url:s.toString()};this.hls.trigger(jh.STEERING_MANIFEST_LOADED,d),l&&this.updatePathwayPriority(l)},onError:(e,t,i,s)=>{if(this.log(`Error loading steering manifest: ${e.code} ${e.text} (${t.url})`),this.stopLoad(),410===e.code)return this.enabled=!1,void this.log(`Steering manifest ${t.url} no longer available`);let r=1e3*this.timeToLoad;if(429!==e.code)this.scheduleRefresh(this.uri||t.url,r);else{const e=this.loader;if("function"==typeof(null==e?void 0:e.getResponseHeader)){const t=e.getResponseHeader("Retry-After");t&&(r=1e3*parseFloat(t))}this.log(`Steering manifest ${t.url} rate limited`)}},onTimeout:(e,t,i)=>{this.log(`Timeout loading steering manifest (${t.url})`),this.scheduleRefresh(this.uri||t.url)}};this.log(`Requesting steering manifest: ${s}`),this.loader.load(r,n,l)}scheduleRefresh(e,t=1e3*this.timeToLoad){this.clearTimeout(),this.reloadTimer=self.setTimeout((()=>{var t;const i=null==(t=this.hls)?void 0:t.media;!i||i.ended?this.scheduleRefresh(e,1e3*this.timeToLoad):this.loadSteeringManifest(e)}),t)}}});function Qy(e){return e&&"object"==typeof e?Array.isArray(e)?e.map(Qy):Object.keys(e).reduce(((t,i)=>(t[i]=Qy(e[i]),t)),{}):e}function Xy(e){const t=e.loader;if(t!==Vy&&t!==Hy)Jh.log("[config]: Custom loader detected, cannot enable progressive streaming"),e.progressive=!1;else{(function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(e){}return!1})()&&(e.loader=Vy,e.progressive=!0,e.enableSoftwareAES=!0,Jh.log("[config]: Progressive streaming enabled, using FetchLoader"))}}let Zy;class eA extends Vp{constructor(e,t){super(e,"[level-controller]"),this._levels=[],this._firstLevel=-1,this._maxAutoLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=t,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(jh.MANIFEST_LOADING,this.onManifestLoading,this),e.on(jh.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(jh.LEVEL_LOADED,this.onLevelLoaded,this),e.on(jh.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(jh.FRAG_BUFFERED,this.onFragBuffered,this),e.on(jh.ERROR,this.onError,this)}_unregisterListeners(){const{hls:e}=this;e.off(jh.MANIFEST_LOADING,this.onManifestLoading,this),e.off(jh.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(jh.LEVEL_LOADED,this.onLevelLoaded,this),e.off(jh.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(jh.FRAG_BUFFERED,this.onFragBuffered,this),e.off(jh.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}stopLoad(){this._levels.forEach((e=>{e.loadError=0,e.fragmentError=0})),super.stopLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1}onManifestLoading(e,t){this.resetLevels()}onManifestLoaded(e,t){const i=this.hls.config.preferManagedMediaSource,s=[],r={},a={};let o=!1,n=!1,l=!1;t.levels.forEach((e=>{var t,d;const h=e.attrs;let{audioCodec:c,videoCodec:u}=e;-1!==(null==(t=c)?void 0:t.indexOf("mp4a.40.34"))&&(Zy||(Zy=/chrome|firefox/i.test(navigator.userAgent)),Zy&&(e.audioCodec=c=void 0)),c&&(e.audioCodec=c=Ru(c,i)),0===(null==(d=u)?void 0:d.indexOf("avc1"))&&(u=e.videoCodec=function(e){const t=e.split(".");if(t.length>2){let e=t.shift()+".";return e+=parseInt(t.shift()).toString(16),e+=("000"+parseInt(t.shift()).toString(16)).slice(-4),e}return e}(u));const{width:p,height:f,unknownCodecs:m}=e;if(o||(o=!(!p||!f)),n||(n=!!u),l||(l=!!c),null!=m&&m.length||c&&!vu(c,"audio",i)||u&&!vu(u,"video",i))return;const{CODECS:g,"FRAME-RATE":y,"HDCP-LEVEL":A,"PATHWAY-ID":b,RESOLUTION:_,"VIDEO-RANGE":v}=h,S=`${`${b||"."}-`}${e.bitrate}-${_}-${y}-${g}-${v}-${A}`;if(r[S])if(r[S].uri===e.url||e.attrs["PATHWAY-ID"])r[S].addGroupId("audio",h.AUDIO),r[S].addGroupId("text",h.SUBTITLES);else{const t=a[S]+=1;e.attrs["PATHWAY-ID"]=new Array(t+1).join(".");const i=new bp(e);r[S]=i,s.push(i)}else{const t=new bp(e);r[S]=t,a[S]=1,s.push(t)}})),this.filterAndSortMediaOptions(s,t,o,n,l)}filterAndSortMediaOptions(e,t,i,s,r){let a=[],o=[],n=e;if((i||s)&&r&&(n=n.filter((({videoCodec:e,videoRange:t,width:i,height:s})=>{return(!!e||!(!i||!s))&&(!!(r=t)&&fp.indexOf(r)>-1);var r}))),0===n.length)return void Promise.resolve().then((()=>{if(this.hls){t.levels.length&&this.warn(`One or more CODECS in variant not supported: ${JSON.stringify(t.levels[0].attrs)}`);const e=new Error("no level with compatible codecs found in manifest");this.hls.trigger(jh.ERROR,{type:zh.MEDIA_ERROR,details:Gh.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:e,reason:e.message})}}));if(t.audioTracks){const{preferManagedMediaSource:e}=this.hls.config;a=t.audioTracks.filter((t=>!t.audioCodec||vu(t.audioCodec,"audio",e))),tA(a)}t.subtitles&&(o=t.subtitles,tA(o));const l=n.slice(0);n.sort(((e,t)=>{if(e.attrs["HDCP-LEVEL"]!==t.attrs["HDCP-LEVEL"])return(e.attrs["HDCP-LEVEL"]||"")>(t.attrs["HDCP-LEVEL"]||"")?1:-1;if(i&&e.height!==t.height)return e.height-t.height;if(e.frameRate!==t.frameRate)return e.frameRate-t.frameRate;if(e.videoRange!==t.videoRange)return fp.indexOf(e.videoRange)-fp.indexOf(t.videoRange);if(e.videoCodec!==t.videoCodec){const i=Eu(e.videoCodec),s=Eu(t.videoCodec);if(i!==s)return s-i}if(e.uri===t.uri&&e.codecSet!==t.codecSet){const i=Tu(e.codecSet),s=Tu(t.codecSet);if(i!==s)return s-i}return e.averageBitrate!==t.averageBitrate?e.averageBitrate-t.averageBitrate:0}));let d=l[0];if(this.steering&&(n=this.steering.filterParsedLevels(n),n.length!==l.length))for(let e=0;e<l.length;e++)if(l[e].pathwayId===n[0].pathwayId){d=l[e];break}this._levels=n;for(let e=0;e<n.length;e++)if(n[e]===d){var h;this._firstLevel=e;const t=d.bitrate,i=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${n.length} level(s) found, first bitrate: ${t}`),void 0===(null==(h=this.hls.userConfig)?void 0:h.abrEwmaDefaultEstimate)){const e=Math.min(t,this.hls.config.abrEwmaDefaultEstimateMax);e>i&&i===Yy.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=e)}break}const c=r&&!s,u={levels:n,audioTracks:a,subtitleTracks:o,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:r,video:s,altAudio:!c&&a.some((e=>!!e.url))};this.hls.trigger(jh.MANIFEST_PARSED,u),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}get levels(){return 0===this._levels.length?null:this._levels}get level(){return this.currentLevelIndex}set level(e){const t=this._levels;if(0===t.length)return;if(e<0||e>=t.length){const i=new Error("invalid level idx"),s=e<0;if(this.hls.trigger(jh.ERROR,{type:zh.OTHER_ERROR,details:Gh.LEVEL_SWITCH_ERROR,level:e,fatal:s,error:i,reason:i.message}),s)return;e=Math.min(e,t.length-1)}const i=this.currentLevelIndex,s=this.currentLevel,r=s?s.attrs["PATHWAY-ID"]:void 0,a=t[e],o=a.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=a,i===e&&a.details&&s&&r===o)return;this.log(`Switching to level ${e} (${a.height?a.height+"p ":""}${a.videoRange?a.videoRange+" ":""}${a.codecSet?a.codecSet+" ":""}@${a.bitrate})${o?" with Pathway "+o:""} from level ${i}${r?" with Pathway "+r:""}`);const n={level:e,attrs:a.attrs,details:a.details,bitrate:a.bitrate,averageBitrate:a.averageBitrate,maxBitrate:a.maxBitrate,realBitrate:a.realBitrate,width:a.width,height:a.height,codecSet:a.codecSet,audioCodec:a.audioCodec,videoCodec:a.videoCodec,audioGroups:a.audioGroups,subtitleGroups:a.subtitleGroups,loaded:a.loaded,loadError:a.loadError,fragmentError:a.fragmentError,name:a.name,id:a.id,uri:a.uri,url:a.url,urlId:0,audioGroupIds:a.audioGroupIds,textGroupIds:a.textGroupIds};this.hls.trigger(jh.LEVEL_SWITCHING,n);const l=a.details;if(!l||l.live){const e=this.switchParams(a.uri,null==s?void 0:s.details);this.loadPlaylist(e)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(e){this.manualLevelIndex=e,void 0===this._startLevel&&(this._startLevel=e),-1!==e&&(this.level=e)}get firstLevel(){return this._firstLevel}set firstLevel(e){this._firstLevel=e}get startLevel(){if(void 0===this._startLevel){const e=this.hls.config.startLevel;return void 0!==e?e:this.hls.firstAutoLevel}return this._startLevel}set startLevel(e){this._startLevel=e}onError(e,t){!t.fatal&&t.context&&t.context.type===$u&&t.context.level===this.level&&this.checkRetry(t)}onFragBuffered(e,{frag:t}){if(void 0!==t&&t.type===Ju){const e=t.elementaryStreams;if(!Object.keys(e).some((t=>!!e[t])))return;const i=this._levels[t.level];null!=i&&i.loadError&&(this.log(`Resetting level error count of ${i.loadError} on frag buffered`),i.loadError=0)}}onLevelLoaded(e,t){var i;const{level:s,details:r}=t,a=this._levels[s];var o;if(!a)return this.warn(`Invalid level index ${s}`),void(null!=(o=t.deliveryDirectives)&&o.skip&&(r.deltaUpdateFailed=!0));s===this.currentLevelIndex?(0===a.fragmentError&&(a.loadError=0),this.playlistLoaded(s,t,a.details)):null!=(i=t.deliveryDirectives)&&i.skip&&(r.deltaUpdateFailed=!0)}loadPlaylist(e){super.loadPlaylist();const t=this.currentLevelIndex,i=this.currentLevel;if(i&&this.shouldLoadPlaylist(i)){let s=i.uri;if(e)try{s=e.addDirectives(s)}catch(e){this.warn(`Could not construct new URL with HLS Delivery Directives: ${e}`)}const r=i.attrs["PATHWAY-ID"];this.log(`Loading level index ${t}${void 0!==(null==e?void 0:e.msn)?" at sn "+e.msn+" part "+e.part:""} with${r?" Pathway "+r:""} ${s}`),this.clearTimer(),this.hls.trigger(jh.LEVEL_LOADING,{url:s,level:t,pathwayId:i.attrs["PATHWAY-ID"],id:0,deliveryDirectives:e||null})}}get nextLoadLevel(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(e){this.level=e,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=e)}removeLevel(e){var t;const i=this._levels.filter(((t,i)=>i!==e||(this.steering&&this.steering.removeLevel(t),t===this.currentLevel&&(this.currentLevel=null,this.currentLevelIndex=-1,t.details&&t.details.fragments.forEach((e=>e.level=-1))),!1)));Rp(i),this._levels=i,this.currentLevelIndex>-1&&null!=(t=this.currentLevel)&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.hls.trigger(jh.LEVELS_UPDATED,{levels:i})}onLevelsUpdated(e,{levels:t}){this._levels=t}checkMaxAutoUpdated(){const{autoLevelCapping:e,maxAutoLevel:t,maxHdcpLevel:i}=this.hls;this._maxAutoLevel!==t&&(this._maxAutoLevel=t,this.hls.trigger(jh.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:e,levels:this.levels,maxAutoLevel:t,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:i}))}}function tA(e){const t={};e.forEach((e=>{const i=e.groupId||"";e.id=t[i]=t[i]||0,t[i]++}))}class iA{constructor(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(const i in this.keyUriToKeyInfo){const s=this.keyUriToKeyInfo[i].loader;if(s){var t;if(e&&e!==(null==(t=s.context)?void 0:t.frag.type))return;s.abort()}}}detach(){for(const e in this.keyUriToKeyInfo){const t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}}destroy(){this.detach();for(const e in this.keyUriToKeyInfo){const t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}}createKeyLoadError(e,t=Gh.KEY_LOAD_ERROR,i,s,r){return new Tf({type:zh.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:r,error:i,networkDetails:s})}loadClear(e,t){if(this.emeController&&this.config.emeEnabled){const{sn:i,cc:s}=e;for(let e=0;e<t.length;e++){const r=t[e];if(s<=r.cc&&("initSegment"===i||"initSegment"===r.sn||i<r.sn)){this.emeController.selectKeySystemFormat(r).then((e=>{r.setKeyFormat(e)}));break}}}}load(e){return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then((t=>this.loadInternal(e,t))):this.loadInternal(e)}loadInternal(e,t){var i,s;t&&e.setKeyFormat(t);const r=e.decryptdata;if(!r){const i=new Error(t?`Expected frag.decryptdata to be defined after setting format ${t}`:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(e,Gh.KEY_LOAD_ERROR,i))}const a=r.uri;if(!a)return Promise.reject(this.createKeyLoadError(e,Gh.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${a}"`)));let o=this.keyUriToKeyInfo[a];if(null!=(i=o)&&i.decryptdata.key)return r.key=o.decryptdata.key,Promise.resolve({frag:e,keyInfo:o});var n;if(null!=(s=o)&&s.keyLoadPromise)switch(null==(n=o.mediaKeySessionContext)?void 0:n.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return o.keyLoadPromise.then((t=>(r.key=t.keyInfo.decryptdata.key,{frag:e,keyInfo:o})))}switch(o=this.keyUriToKeyInfo[a]={decryptdata:r,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},r.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return"identity"===r.keyFormat?this.loadKeyHTTP(o,e):this.loadKeyEME(o,e);case"AES-128":return this.loadKeyHTTP(o,e);default:return Promise.reject(this.createKeyLoadError(e,Gh.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${r.method}"`)))}}loadKeyEME(e,t){const i={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){const t=this.emeController.loadKey(i);if(t)return(e.keyLoadPromise=t.then((t=>(e.mediaKeySessionContext=t,i)))).catch((t=>{throw e.keyLoadPromise=null,t}))}return Promise.resolve(i)}loadKeyHTTP(e,t){const i=this.config,s=new(0,i.loader)(i);return t.keyLoader=e.loader=s,e.keyLoadPromise=new Promise(((r,a)=>{const o={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},n=i.keyLoadPolicy.default,l={loadPolicy:n,timeout:n.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},d={onSuccess:(e,t,i,s)=>{const{frag:o,keyInfo:n,url:l}=i;if(!o.decryptdata||n!==this.keyUriToKeyInfo[l])return a(this.createKeyLoadError(o,Gh.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),s));n.decryptdata.key=o.decryptdata.key=new Uint8Array(e.data),o.keyLoader=null,n.loader=null,r({frag:o,keyInfo:n})},onError:(e,i,s,r)=>{this.resetLoader(i),a(this.createKeyLoadError(t,Gh.KEY_LOAD_ERROR,new Error(`HTTP Error ${e.code} loading key ${e.text}`),s,Bh({url:o.url,data:void 0},e)))},onTimeout:(e,i,s)=>{this.resetLoader(i),a(this.createKeyLoadError(t,Gh.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),s))},onAbort:(e,i,s)=>{this.resetLoader(i),a(this.createKeyLoadError(t,Gh.INTERNAL_ABORTED,new Error("key loading aborted"),s))}};s.load(o,l,d)}))}resetLoader(e){const{frag:t,keyInfo:i,url:s}=e,r=i.loader;t.keyLoader===r&&(t.keyLoader=null,i.loader=null),delete this.keyUriToKeyInfo[s],r&&r.destroy()}}function sA(){return self.SourceBuffer||self.WebKitSourceBuffer}function rA(){if(!bu())return!1;const e=sA();return!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove}class aA{constructor(e,t,i,s){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=e,this.media=t,this.fragmentTracker=i,this.hls=s}destroy(){this.media=null,this.hls=this.fragmentTracker=null}poll(e,t){const{config:i,media:s,stalled:r}=this;if(null===s)return;const{currentTime:a,seeking:o}=s,n=this.seeking&&!o,l=!this.seeking&&o;if(this.seeking=o,a!==e){if(this.moved=!0,o||(this.nudgeRetry=0),null!==r){if(this.stallReported){const e=self.performance.now()-r;Jh.warn(`playback not stuck anymore @${a}, after ${Math.round(e)}ms`),this.stallReported=!1}this.stalled=null}return}if(l||n)return void(this.stalled=null);if(s.paused&&!o||s.ended||0===s.playbackRate||!ff.getBuffered(s).length)return void(this.nudgeRetry=0);const d=ff.bufferInfo(s,a,0),h=d.nextStart||0;if(o){const e=d.len>2,i=!h||t&&t.start<=a||h-a>2&&!this.fragmentTracker.getPartialFragment(a);if(e||i)return;this.moved=!1}if(!this.moved&&null!==this.stalled){var c;if(!(d.len>0)&&!h)return;const e=Math.max(h,d.start||0)-a,t=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,i=(null==t||null==(c=t.details)?void 0:c.live)?2*t.details.targetduration:2,r=this.fragmentTracker.getPartialFragment(a);if(e>0&&(e<=i||r))return void(s.paused||this._trySkipBufferHole(r))}const u=self.performance.now();if(null===r)return void(this.stalled=u);const p=u-r;if(!o&&p>=250&&(this._reportStall(d),!this.media))return;const f=ff.bufferInfo(s,a,i.maxBufferHole);this._tryFixBufferStall(f,p)}_tryFixBufferStall(e,t){const{config:i,fragmentTracker:s,media:r}=this;if(null===r)return;const a=r.currentTime,o=s.getPartialFragment(a);if(o){if(this._trySkipBufferHole(o)||!this.media)return}(e.len>i.maxBufferHole||e.nextStart&&e.nextStart-a<i.maxBufferHole)&&t>1e3*i.highBufferWatchdogPeriod&&(Jh.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}_reportStall(e){const{hls:t,media:i,stallReported:s}=this;if(!s&&i){this.stallReported=!0;const s=new Error(`Playback stalling at @${i.currentTime} due to low buffer (${JSON.stringify(e)})`);Jh.warn(s.message),t.trigger(jh.ERROR,{type:zh.MEDIA_ERROR,details:Gh.BUFFER_STALLED_ERROR,fatal:!1,error:s,buffer:e.len})}}_trySkipBufferHole(e){const{config:t,hls:i,media:s}=this;if(null===s)return 0;const r=s.currentTime,a=ff.bufferInfo(s,r,0),o=r<a.start?a.start:a.nextStart;if(o){const n=a.len<=t.maxBufferHole,l=a.len>0&&a.len<1&&s.readyState<3,d=o-r;if(d>0&&(n||l)){if(d>t.maxBufferHole){const{fragmentTracker:t}=this;let i=!1;if(0===r){const e=t.getAppendedFrag(0,Ju);e&&o<e.end&&(i=!0)}if(!i){const i=e||t.getAppendedFrag(r,Ju);if(i){let e=!1,s=i.end;for(;s<o;){const i=t.getPartialFragment(s);if(!i){e=!0;break}s+=i.duration}if(e)return 0}}}const a=Math.max(o+.05,r+.1);if(Jh.warn(`skipping hole, adjusting currentTime from ${r} to ${a}`),this.moved=!0,this.stalled=null,s.currentTime=a,e&&!e.gap){const t=new Error(`fragment loaded with buffer holes, seeking from ${r} to ${a}`);i.trigger(jh.ERROR,{type:zh.MEDIA_ERROR,details:Gh.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:t,reason:t.message,frag:e})}return a}}return 0}_tryNudgeBuffer(){const{config:e,hls:t,media:i,nudgeRetry:s}=this;if(null===i)return;const r=i.currentTime;if(this.nudgeRetry++,s<e.nudgeMaxRetry){const a=r+(s+1)*e.nudgeOffset,o=new Error(`Nudging 'currentTime' from ${r} to ${a}`);Jh.warn(o.message),i.currentTime=a,t.trigger(jh.ERROR,{type:zh.MEDIA_ERROR,details:Gh.BUFFER_NUDGE_ON_STALL,error:o,fatal:!1})}else{const i=new Error(`Playhead still not moving while enough data buffered @${r} after ${e.nudgeMaxRetry} nudges`);Jh.error(i.message),t.trigger(jh.ERROR,{type:zh.MEDIA_ERROR,details:Gh.BUFFER_STALLED_ERROR,error:i,fatal:!0})}}}class oA extends Hf{constructor(e,t,i){super(e,t,i,"[stream-controller]",Ju),this.audioCodecSwap=!1,this.gapController=null,this.level=-1,this._forceStartLoad=!1,this.altAudio=!1,this.audioOnly=!1,this.fragPlaying=null,this.onvplaying=null,this.onvseeked=null,this.fragLastKbps=0,this.couldBacktrack=!1,this.backtrackFragment=null,this.audioCodecSwitch=!1,this.videoBuffer=null,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(jh.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(jh.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(jh.MANIFEST_LOADING,this.onManifestLoading,this),e.on(jh.MANIFEST_PARSED,this.onManifestParsed,this),e.on(jh.LEVEL_LOADING,this.onLevelLoading,this),e.on(jh.LEVEL_LOADED,this.onLevelLoaded,this),e.on(jh.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(jh.ERROR,this.onError,this),e.on(jh.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(jh.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(jh.BUFFER_CREATED,this.onBufferCreated,this),e.on(jh.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(jh.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(jh.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:e}=this;e.off(jh.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(jh.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(jh.MANIFEST_LOADING,this.onManifestLoading,this),e.off(jh.MANIFEST_PARSED,this.onManifestParsed,this),e.off(jh.LEVEL_LOADED,this.onLevelLoaded,this),e.off(jh.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(jh.ERROR,this.onError,this),e.off(jh.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(jh.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(jh.BUFFER_CREATED,this.onBufferCreated,this),e.off(jh.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(jh.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(jh.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying()}startLoad(e){if(this.levels){const{lastCurrentTime:t,hls:i}=this;if(this.stopLoad(),this.setInterval(100),this.level=-1,!this.startFragRequested){let e=i.startLevel;-1===e&&(i.config.testBandwidth&&this.levels.length>1?(e=0,this.bitrateTest=!0):e=i.firstAutoLevel),i.nextLoadLevel=e,this.level=i.loadLevel,this.loadedmetadata=!1}t>0&&-1===e&&(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t),this.state=Pf,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this._forceStartLoad=!0,this.state=Lf}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case Gf:{const{levels:e,level:t}=this,i=null==e?void 0:e[t],s=null==i?void 0:i.details;if(s&&(!s.live||this.levelLastLoaded===i)){if(this.waitForCdnTuneIn(s))break;this.state=Pf;break}if(this.hls.nextLoadLevel!==this.level){this.state=Pf;break}break}case Mf:{var e;const t=self.performance.now(),i=this.retryDate;if(!i||t>=i||null!=(e=this.media)&&e.seeking){const{levels:e,level:t}=this,i=null==e?void 0:e[t];this.resetStartWhenNotLoaded(i||null),this.state=Pf}}}this.state===Pf&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){super.onTickEnd(),this.checkBuffer(),this.checkFragmentChanged()}doTickIdle(){const{hls:e,levelLastLoaded:t,levels:i,media:s}=this;if(null===t||!s&&(this.startFragRequested||!e.config.startFragPrefetch))return;if(this.altAudio&&this.audioOnly)return;const r=e.nextLoadLevel;if(null==i||!i[r])return;const a=i[r],o=this.getMainFwdBufferInfo();if(null===o)return;const n=this.getLevelDetails();if(n&&this._streamEnded(o,n)){const e={};return this.altAudio&&(e.type="video"),this.hls.trigger(jh.BUFFER_EOS,e),void(this.state=Nf)}e.loadLevel!==r&&-1===e.manualLevel&&this.log(`Adapting to level ${r} from level ${this.level}`),this.level=e.nextLoadLevel=r;const l=a.details;if(!l||this.state===Gf||l.live&&this.levelLastLoaded!==a)return this.level=r,void(this.state=Gf);const d=o.len,h=this.getMaxBufferLength(a.maxBitrate);if(d>=h)return;this.backtrackFragment&&this.backtrackFragment.start>o.end&&(this.backtrackFragment=null);const c=this.backtrackFragment?this.backtrackFragment.start:o.end;let u=this.getNextFragment(c,l);if(this.couldBacktrack&&!this.fragPrevious&&u&&"initSegment"!==u.sn&&this.fragmentTracker.getState(u)!==df){var p;const e=(null!=(p=this.backtrackFragment)?p:u).sn-l.startSN,t=l.fragments[e-1];t&&u.cc===t.cc&&(u=t,this.fragmentTracker.removeFragment(t))}else this.backtrackFragment&&o.len&&(this.backtrackFragment=null);if(u&&this.isLoopLoading(u,c)){if(!u.gap){const e=this.audioOnly&&!this.altAudio?ec:tc,t=(e===tc?this.videoBuffer:this.mediaBuffer)||this.media;t&&this.afterBufferFlushed(t,e,Ju)}u=this.getNextFragmentLoopLoading(u,l,o,Ju,h)}u&&(!u.initSegment||u.initSegment.data||this.bitrateTest||(u=u.initSegment),this.loadFragment(u,a,c))}loadFragment(e,t,i){const s=this.fragmentTracker.getState(e);this.fragCurrent=e,s===of||s===lf?"initSegment"===e.sn?this._loadInitSegment(e,t):this.bitrateTest?(this.log(`Fragment ${e.sn} of level ${e.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(e,t)):(this.startFragRequested=!0,super.loadFragment(e,t,i)):this.clearTrackerIfNeeded(e)}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,Ju)}followingBufferedFrag(e){return e?this.getBufferedFrag(e.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}nextLevelSwitch(){const{levels:e,media:t}=this;if(null!=t&&t.readyState){let i;const s=this.getAppendedFrag(t.currentTime);s&&s.start>1&&this.flushMainBuffer(0,s.start-1);const r=this.getLevelDetails();if(null!=r&&r.live){const e=this.getMainFwdBufferInfo();if(!e||e.len<2*r.targetduration)return}if(!t.paused&&e){const t=e[this.hls.nextLoadLevel],s=this.fragLastKbps;i=s&&this.fragCurrent?this.fragCurrent.duration*t.maxBitrate/(1e3*s)+1:0}else i=0;const a=this.getBufferedFrag(t.currentTime+i);if(a){const e=this.followingBufferedFrag(a);if(e){this.abortCurrentFrag();const t=e.maxStartPTS?e.maxStartPTS:e.start,i=e.duration,s=Math.max(a.end,t+Math.min(Math.max(i-this.config.maxFragLookUpTolerance,i*(this.couldBacktrack?.5:.125)),i*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(s,Number.POSITIVE_INFINITY)}}}}abortCurrentFrag(){const e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case Bf:case If:case Mf:case Ff:case Of:this.state=Pf}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(e,t){super.flushMainBuffer(e,t,this.altAudio?"video":null)}onMediaAttached(e,t){super.onMediaAttached(e,t);const i=t.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),i.addEventListener("playing",this.onvplaying),i.addEventListener("seeked",this.onvseeked),this.gapController=new aA(this.config,i,this.fragmentTracker,this.hls)}onMediaDetaching(){const{media:e}=this;e&&this.onvplaying&&this.onvseeked&&(e.removeEventListener("playing",this.onvplaying),e.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),super.onMediaDetaching()}onMediaPlaying(){this.tick()}onMediaSeeked(){const e=this.media,t=e?e.currentTime:null;Fh(t)&&this.log(`Media seeked to ${t.toFixed(3)}`);const i=this.getMainFwdBufferInfo();null!==i&&0!==i.len?this.tick():this.warn(`Main forward buffer length on "seeked" event ${i?i.len:"empty"})`)}onManifestLoading(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(jh.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=this.fragLastKbps=0,this.levels=this.fragPlaying=this.backtrackFragment=this.levelLastLoaded=null,this.altAudio=this.audioOnly=this.startFragRequested=!1}onManifestParsed(e,t){let i=!1,s=!1;t.levels.forEach((e=>{const t=e.audioCodec;t&&(i=i||-1!==t.indexOf("mp4a.40.2"),s=s||-1!==t.indexOf("mp4a.40.5"))})),this.audioCodecSwitch=i&&s&&!function(){var e;const t=sA();return"function"==typeof(null==t||null==(e=t.prototype)?void 0:e.changeType)}(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1}onLevelLoading(e,t){const{levels:i}=this;if(!i||this.state!==Pf)return;const s=i[t.level];(!s.details||s.details.live&&this.levelLastLoaded!==s||this.waitForCdnTuneIn(s.details))&&(this.state=Gf)}onLevelLoaded(e,t){var i;const{levels:s}=this,r=t.level,a=t.details,o=a.totalduration;if(!s)return void this.warn(`Levels were reset while loading level ${r}`);this.log(`Level ${r} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""}, cc [${a.startCC}, ${a.endCC}] duration:${o}`);const n=s[r],l=this.fragCurrent;!l||this.state!==If&&this.state!==Mf||l.level!==t.level&&l.loader&&this.abortCurrentFrag();let d=0;if(a.live||null!=(i=n.details)&&i.live){var h;if(this.checkLiveUpdate(a),a.deltaUpdateFailed)return;d=this.alignPlaylists(a,n.details,null==(h=this.levelLastLoaded)?void 0:h.details)}if(n.details=a,this.levelLastLoaded=n,this.hls.trigger(jh.LEVEL_UPDATED,{details:a,level:r}),this.state===Gf){if(this.waitForCdnTuneIn(a))return;this.state=Pf}this.startFragRequested?a.live&&this.synchronizeToLiveEdge(a):this.setStartPosition(a,d),this.tick()}_handleFragmentLoadProgress(e){var t;const{frag:i,part:s,payload:r}=e,{levels:a}=this;if(!a)return void this.warn(`Levels were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`);const o=a[i.level],n=o.details;if(!n)return this.warn(`Dropping fragment ${i.sn} of level ${i.level} after level details were reset`),void this.fragmentTracker.removeFragment(i);const l=o.videoCodec,d=n.PTSKnown||!n.live,h=null==(t=i.initSegment)?void 0:t.data,c=this._getAudioCodec(o),u=this.transmuxer=this.transmuxer||new Ym(this.hls,Ju,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),p=s?s.index:-1,f=-1!==p,m=new mf(i.level,i.sn,i.stats.chunkCount,r.byteLength,p,f),g=this.initPTS[i.cc];u.push(r,h,c,l,i,s,n.totalduration,d,m,g)}onAudioTrackSwitching(e,t){const i=this.altAudio;if(!!!t.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;const e=this.fragCurrent;e&&(this.log("Switching to main audio track, cancel main fragment load"),e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();const e=this.hls;i&&(e.trigger(jh.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),e.trigger(jh.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){const i=t.id,s=!!this.hls.audioTracks[i].url;if(s){const e=this.videoBuffer;e&&this.mediaBuffer!==e&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=e)}this.altAudio=s,this.tick()}onBufferCreated(e,t){const i=t.tracks;let s,r,a=!1;for(const e in i){const t=i[e];if("main"===t.id){if(r=e,s=t,"video"===e){const t=i[e];t&&(this.videoBuffer=t.buffer)}}else a=!0}a&&s?(this.log(`Alternate track found, use ${r}.buffered to schedule main fragment loading`),this.mediaBuffer=s.buffer):this.mediaBuffer=this.media}onFragBuffered(e,t){const{frag:i,part:s}=t;if(i&&i.type!==Ju)return;if(this.fragContextChanged(i))return this.warn(`Fragment ${i.sn}${s?" p: "+s.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}`),void(this.state===Of&&(this.state=Pf));const r=s?s.stats:i.stats;this.fragLastKbps=Math.round(8*r.total/(r.buffering.end-r.loading.first)),"initSegment"!==i.sn&&(this.fragPrevious=i),this.fragBufferedComplete(i,s)}onError(e,t){var i;if(t.fatal)this.state=jf;else switch(t.details){case Gh.FRAG_GAP:case Gh.FRAG_PARSING_ERROR:case Gh.FRAG_DECRYPT_ERROR:case Gh.FRAG_LOAD_ERROR:case Gh.FRAG_LOAD_TIMEOUT:case Gh.KEY_LOAD_ERROR:case Gh.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Ju,t);break;case Gh.LEVEL_LOAD_ERROR:case Gh.LEVEL_LOAD_TIMEOUT:case Gh.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==Gf||(null==(i=t.context)?void 0:i.type)!==$u||(this.state=Pf);break;case Gh.BUFFER_APPEND_ERROR:case Gh.BUFFER_FULL_ERROR:if(!t.parent||"main"!==t.parent)return;if(t.details===Gh.BUFFER_APPEND_ERROR)return void this.resetLoadingState();this.reduceLengthAndFlushBuffer(t)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case Gh.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}checkBuffer(){const{media:e,gapController:t}=this;if(e&&t&&e.readyState){if(this.loadedmetadata||!ff.getBuffered(e).length){const e=this.state!==Pf?this.fragCurrent:null;t.poll(this.lastCurrentTime,e)}this.lastCurrentTime=e.currentTime}}onFragLoadEmergencyAborted(){this.state=Pf,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==ec||this.audioOnly&&!this.altAudio){const e=(t===tc?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(e,t,Ju),this.tick()}}onLevelsUpdated(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level),this.levels=t.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){const{media:e}=this;if(!e)return;const t=e.currentTime;let i=this.startPosition;if(i>=0&&t<i){if(e.seeking)return void this.log(`could not seek to ${i}, already seeking at ${t}`);const s=ff.getBuffered(e),r=(s.length?s.start(0):0)-i;r>0&&(r<this.config.maxBufferHole||r<this.config.maxFragLookUpTolerance)&&(this.log(`adjusting start position by ${r} to match buffer start`),i+=r,this.startPosition=i),this.log(`seek to target start position ${i} from current time ${t}`),e.currentTime=i}}_getAudioCodec(e){let t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t=-1!==t.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),t}_loadBitrateTestFrag(e,t){e.bitrateTest=!0,this._doFragLoad(e,t).then((i=>{const{hls:s}=this;if(!i||this.fragContextChanged(e))return;t.fragmentError=0,this.state=Pf,this.startFragRequested=!1,this.bitrateTest=!1;const r=e.stats;r.parsing.start=r.parsing.end=r.buffering.start=r.buffering.end=self.performance.now(),s.trigger(jh.FRAG_LOADED,i),e.bitrateTest=!1}))}_handleTransmuxComplete(e){var t;const i="main",{hls:s}=this,{remuxResult:r,chunkMeta:a}=e,o=this.getCurrentContext(a);if(!o)return void this.resetWhenMissingContext(a);const{frag:n,part:l,level:d}=o,{video:h,text:c,id3:u,initSegment:p}=r,{details:f}=d,m=this.altAudio?void 0:r.audio;if(this.fragContextChanged(n))this.fragmentTracker.removeFragment(n);else{if(this.state=Ff,p){if(null!=p&&p.tracks){const e=n.initSegment||n;this._bufferInitSegment(d,p.tracks,e,a),s.trigger(jh.FRAG_PARSING_INIT_SEGMENT,{frag:e,id:i,tracks:p.tracks})}const e=p.initPTS,t=p.timescale;Fh(e)&&(this.initPTS[n.cc]={baseTime:e,timescale:t},s.trigger(jh.INIT_PTS_FOUND,{frag:n,id:i,initPTS:e,timescale:t}))}if(h&&f&&"initSegment"!==n.sn){const e=f.fragments[n.sn-1-f.startSN],t=n.sn===f.startSN,i=!e||n.cc>e.cc;if(!1!==r.independent){const{startPTS:e,endPTS:s,startDTS:r,endDTS:o}=h;if(l)l.elementaryStreams[h.type]={startPTS:e,endPTS:s,startDTS:r,endDTS:o};else if(h.firstKeyFrame&&h.independent&&1===a.id&&!i&&(this.couldBacktrack=!0),h.dropped&&h.independent){const r=this.getMainFwdBufferInfo(),a=(r?r.end:this.getLoadPosition())+this.config.maxBufferHole,l=h.firstKeyFramePTS?h.firstKeyFramePTS:e;if(!t&&a<l-this.config.maxBufferHole&&!i)return void this.backtrack(n);i&&(n.gap=!0),n.setElementaryStreamInfo(h.type,n.start,s,n.start,o,!0)}else t&&e>2&&(n.gap=!0);n.setElementaryStreamInfo(h.type,e,s,r,o),this.backtrackFragment&&(this.backtrackFragment=n),this.bufferFragmentData(h,n,l,a,t||i)}else{if(!t&&!i)return void this.backtrack(n);n.gap=!0}}if(m){const{startPTS:e,endPTS:t,startDTS:i,endDTS:s}=m;l&&(l.elementaryStreams[ec]={startPTS:e,endPTS:t,startDTS:i,endDTS:s}),n.setElementaryStreamInfo(ec,e,t,i,s),this.bufferFragmentData(m,n,l,a)}if(f&&null!=u&&null!=(t=u.samples)&&t.length){const e={id:i,frag:n,details:f,samples:u.samples};s.trigger(jh.FRAG_PARSING_METADATA,e)}if(f&&c){const e={id:i,frag:n,details:f,samples:c.samples};s.trigger(jh.FRAG_PARSING_USERDATA,e)}}}_bufferInitSegment(e,t,i,s){if(this.state!==Ff)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&delete t.audio;const{audio:r,video:a,audiovideo:o}=t;if(r){let t=e.audioCodec;const i=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(t&&(t=-1!==t.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),1!==r.metadata.channelCount&&-1===i.indexOf("firefox")&&(t="mp4a.40.5")),t&&-1!==t.indexOf("mp4a.40.5")&&-1!==i.indexOf("android")&&"audio/mpeg"!==r.container&&(t="mp4a.40.2",this.log(`Android: force audio codec to ${t}`)),e.audioCodec&&e.audioCodec!==t&&this.log(`Swapping manifest audio codec "${e.audioCodec}" for "${t}"`),r.levelCodec=t,r.id="main",this.log(`Init audio buffer, container:${r.container}, codecs[selected/level/parsed]=[${t||""}/${e.audioCodec||""}/${r.codec}]`)}a&&(a.levelCodec=e.videoCodec,a.id="main",this.log(`Init video buffer, container:${a.container}, codecs[level/parsed]=[${e.videoCodec||""}/${a.codec}]`)),o&&this.log(`Init audiovideo buffer, container:${o.container}, codecs[level/parsed]=[${e.codecs}/${o.codec}]`),this.hls.trigger(jh.BUFFER_CODECS,t),Object.keys(t).forEach((e=>{const r=t[e].initSegment;null!=r&&r.byteLength&&this.hls.trigger(jh.BUFFER_APPENDING,{type:e,data:r,frag:i,part:null,chunkMeta:s,parent:i.type})})),this.tickImmediate()}getMainFwdBufferInfo(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,Ju)}backtrack(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=Pf}checkFragmentChanged(){const e=this.media;let t=null;if(e&&e.readyState>1&&!1===e.seeking){const i=e.currentTime;if(ff.isBuffered(e,i)?t=this.getAppendedFrag(i):ff.isBuffered(e,i+.1)&&(t=this.getAppendedFrag(i+.1)),t){this.backtrackFragment=null;const e=this.fragPlaying,i=t.level;e&&t.sn===e.sn&&e.level===i||(this.fragPlaying=t,this.hls.trigger(jh.FRAG_CHANGED,{frag:t}),e&&e.level===i||this.hls.trigger(jh.LEVEL_SWITCHED,{level:i}))}}}get nextLevel(){const e=this.nextBufferedFrag;return e?e.level:-1}get currentFrag(){const e=this.media;return e?this.fragPlaying||this.getAppendedFrag(e.currentTime):null}get currentProgramDateTime(){const e=this.media;if(e){const t=e.currentTime,i=this.currentFrag;if(i&&Fh(t)&&Fh(i.programDateTime)){const e=i.programDateTime+1e3*(t-i.start);return new Date(e)}}return null}get currentLevel(){const e=this.currentFrag;return e?e.level:-1}get nextBufferedFrag(){const e=this.currentFrag;return e?this.followingBufferedFrag(e):null}get forceStartLoad(){return this._forceStartLoad}}class nA{static get version(){return"1.5.7"}static isMSESupported(){return rA()}static isSupported(){return function(){if(!rA())return!1;const e=bu();return"function"==typeof(null==e?void 0:e.isTypeSupported)&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some((t=>e.isTypeSupported(wu(t,"video"))))||["mp4a.40.2","fLaC"].some((t=>e.isTypeSupported(wu(t,"audio")))))}()}static getMediaSource(){return bu()}static get Events(){return jh}static get ErrorTypes(){return zh}static get ErrorDetails(){return Gh}static get DefaultConfig(){return nA.defaultConfig?nA.defaultConfig:Yy}static set DefaultConfig(e){nA.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this.started=!1,this._emitter=new Km,this._autoLevelCapping=-1,this._maxHdcpLevel=null,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,this.triggeringException=void 0,function(e,t){if("object"==typeof console&&!0===e||"object"==typeof e){Wh(e,"debug","log","info","warn","error");try{Vh.log(`Debug logs enabled for "${t}" in hls.js version 1.5.7`)}catch(e){Vh=$h}}else Vh=$h}(e.debug||!1,"Hls instance");const t=this.config=function(e,t){if((t.liveSyncDurationCount||t.liveMaxLatencyDurationCount)&&(t.liveSyncDuration||t.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==t.liveMaxLatencyDurationCount&&(void 0===t.liveSyncDurationCount||t.liveMaxLatencyDurationCount<=t.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==t.liveMaxLatencyDuration&&(void 0===t.liveSyncDuration||t.liveMaxLatencyDuration<=t.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');const i=Qy(e),s=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach((e=>{const r=`${"level"===e?"playlist":e}LoadPolicy`,a=void 0===t[r],o=[];s.forEach((s=>{const n=`${e}Loading${s}`,l=t[n];if(void 0!==l&&a){o.push(n);const e=i[r].default;switch(t[r]={default:e},s){case"TimeOut":e.maxLoadTimeMs=l,e.maxTimeToFirstByteMs=l;break;case"MaxRetry":e.errorRetry.maxNumRetry=l,e.timeoutRetry.maxNumRetry=l;break;case"RetryDelay":e.errorRetry.retryDelayMs=l,e.timeoutRetry.retryDelayMs=l;break;case"MaxRetryTimeout":e.errorRetry.maxRetryDelayMs=l,e.timeoutRetry.maxRetryDelayMs=l}}})),o.length&&Jh.warn(`hls.js config: "${o.join('", "')}" setting(s) are deprecated, use "${r}": ${JSON.stringify(t[r])}`)})),Bh(Bh({},i),t)}(nA.DefaultConfig,e);this.userConfig=e,t.progressive&&Xy(t);const{abrController:i,bufferController:s,capLevelController:r,errorController:a,fpsController:o}=t,n=new a(this),l=this.abrController=new i(this),d=this.bufferController=new s(this),h=this.capLevelController=new r(this),c=new o(this),u=new Xu(this),p=new cp(this),f=t.contentSteeringController,m=f?new f(this):null,g=this.levelController=new eA(this,m),y=new hf(this),A=new iA(this.config),b=this.streamController=new oA(this,y,A);h.setStreamController(b),c.setStreamController(b);const _=[u,g,b];m&&_.splice(1,0,m),this.networkControllers=_;const v=[l,d,h,c,p,y];this.audioTrackController=this.createController(t.audioTrackController,_);const S=t.audioStreamController;S&&_.push(new S(this,y,A)),this.subtitleTrackController=this.createController(t.subtitleTrackController,_);const w=t.subtitleStreamController;w&&_.push(new w(this,y,A)),this.createController(t.timelineController,v),A.emeController=this.emeController=this.createController(t.emeController,v),this.cmcdController=this.createController(t.cmcdController,v),this.latencyController=this.createController(up,v),this.coreComponents=v,_.push(n);const E=n.onErrorOut;"function"==typeof E&&this.on(jh.ERROR,E,n)}createController(e,t){if(e){const i=new e(this);return t&&t.push(i),i}return null}on(e,t,i=this){this._emitter.on(e,t,i)}once(e,t,i=this){this._emitter.once(e,t,i)}removeAllListeners(e){this._emitter.removeAllListeners(e)}off(e,t,i=this,s){this._emitter.off(e,t,i,s)}listeners(e){return this._emitter.listeners(e)}emit(e,t,i){return this._emitter.emit(e,t,i)}trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(t){if(Jh.error("An internal error happened while handling event "+e+'. Error message: "'+t.message+'". Here is a stacktrace:',t),!this.triggeringException){this.triggeringException=!0;const i=e===jh.ERROR;this.trigger(jh.ERROR,{type:zh.OTHER_ERROR,details:Gh.INTERNAL_EXCEPTION,fatal:i,event:e,error:t}),this.triggeringException=!1}}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){Jh.log("destroy"),this.trigger(jh.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach((e=>e.destroy())),this.networkControllers.length=0,this.coreComponents.forEach((e=>e.destroy())),this.coreComponents.length=0;const e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null}attachMedia(e){Jh.log("attachMedia"),this._media=e,this.trigger(jh.MEDIA_ATTACHING,{media:e})}detachMedia(){Jh.log("detachMedia"),this.trigger(jh.MEDIA_DETACHING,void 0),this._media=null}loadSource(e){this.stopLoad();const t=this.media,i=this.url,s=this.url=Lh.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,Jh.log(`loadSource:${s}`),t&&i&&(i!==s||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(jh.MANIFEST_LOADING,{url:e})}startLoad(e=-1){Jh.log(`startLoad(${e})`),this.started=!0,this.networkControllers.forEach((t=>{t.startLoad(e)}))}stopLoad(){Jh.log("stopLoad"),this.started=!1,this.networkControllers.forEach((e=>{e.stopLoad()}))}resumeBuffering(){this.started&&this.networkControllers.forEach((e=>{"fragmentLoader"in e&&e.startLoad(-1)}))}pauseBuffering(){this.networkControllers.forEach((e=>{"fragmentLoader"in e&&e.stopLoad()}))}swapAudioCodec(){Jh.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){Jh.log("recoverMediaError");const e=this._media;this.detachMedia(),e&&this.attachMedia(e)}removeLevel(e){this.levelController.removeLevel(e)}get levels(){const e=this.levelController.levels;return e||[]}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){Jh.log(`set currentLevel:${e}`),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){Jh.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){Jh.log(`set loadLevel:${e}`),this.levelController.manualLevel=e}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(e){this.levelController.nextLoadLevel=e}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(e){Jh.log(`set firstLevel:${e}`),this.levelController.firstLevel=e}get startLevel(){const e=this.levelController.startLevel;return-1===e&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e}set startLevel(e){Jh.log(`set startLevel:${e}`),-1!==e&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(e){const t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimate():NaN}set bandwidthEstimate(e){this.abrController.resetEstimator(e)}get ttfbEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(Jh.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){(function(e){return pp.indexOf(e)>-1})(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}get autoLevelEnabled(){return-1===this.levelController.manualLevel}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){const{levels:e,config:{minAutoBitrate:t}}=this;if(!e)return 0;const i=e.length;for(let s=0;s<i;s++)if(e[s].maxBitrate>=t)return s;return 0}get maxAutoLevel(){const{levels:e,autoLevelCapping:t,maxHdcpLevel:i}=this;let s;if(s=-1===t&&null!=e&&e.length?e.length-1:t,i)for(let t=s;t--;){const s=e[t].attrs["HDCP-LEVEL"];if(s&&s<=i)return t}return s}get firstAutoLevel(){return this.abrController.firstAutoLevel}get nextAutoLevel(){return this.abrController.nextAutoLevel}set nextAutoLevel(e){this.abrController.nextAutoLevel=e}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}setAudioOption(e){var t;return null==(t=this.audioTrackController)?void 0:t.setAudioOption(e)}setSubtitleOption(e){var t;return null==(t=this.subtitleTrackController)||t.setSubtitleOption(e),null}get allAudioTracks(){const e=this.audioTrackController;return e?e.allAudioTracks:[]}get audioTracks(){const e=this.audioTrackController;return e?e.audioTracks:[]}get audioTrack(){const e=this.audioTrackController;return e?e.audioTrack:-1}set audioTrack(e){const t=this.audioTrackController;t&&(t.audioTrack=e)}get allSubtitleTracks(){const e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}get subtitleTracks(){const e=this.subtitleTrackController;return e?e.subtitleTracks:[]}get subtitleTrack(){const e=this.subtitleTrackController;return e?e.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(e){const t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}get subtitleDisplay(){const e=this.subtitleTrackController;return!!e&&e.subtitleDisplay}set subtitleDisplay(e){const t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(e){this.config.lowLatencyMode=e}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}}nA.defaultConfig=void 0;class lA extends po{constructor(e){super(),this.player=e,this.TAG_NAME="HlsDecoder",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=[],this.supportVideoFrameCallbackHandle=null,this.player.isHlsCanVideoPlay()?(this.$videoElement=this.player.video.$videoElement,this.canVideoPlay=!0):nA.isSupported()?(this.$videoElement=this.player.video.$videoElement,this.hls=new nA({}),this._initHls(),this._bindEvents()):this.player.debug.error(this.TAG_NAME,"init hls error ,not support "),this.player.debug.log(this.TAG_NAME,"init")}destroy(){return new Promise(((e,t)=>{this.supportVideoFrameCallbackHandle&&this.$videoElement&&(this.$videoElement.cancelVideoFrameCallback(this.supportVideoFrameCallbackHandle),this.supportVideoFrameCallbackHandle=null),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(this.TAG_NAME,"destroy"),setTimeout((()=>{e()}),0)}))}checkHlsBufferedDelay(){const e=this.$videoElement;let t=0;const i=e.buffered,s=i.length?i.end(i.length-1):0;return t=s-e.currentTime,t<0&&(this.player.debug.warn(this.TAG_NAME,`checkHlsBufferedDelay ${t} < 0, and buffered is ${s} ,currentTime is ${e.currentTime} , try to seek ${e.currentTime} to ${s}`),e.currentTime=s,t=0),t}getFps(){return this.hlsFps}_startCanvasRender(){ho()?this.supportVideoFrameCallbackHandle=this.$videoElement.requestVideoFrameCallback(this.videoFrameCallback.bind(this)):(this._stopCanvasRender(),this.canvasRenderInterval=setInterval((()=>{this.player.video.render({$video:this.$videoElement,ts:parseInt(1e3*this.$videoElement.currentTime,10)||0})}),40))}_stopCanvasRender(){this.canvasRenderInterval&&(clearInterval(this.canvasRenderInterval),this.canvasRenderInterval=null)}videoFrameCallback(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.player.isDestroyedOrClosed())return void this.player.debug.log(this.TAG_NAME,"videoFrameCallback() player is destroyed");const i=parseInt(1e3*Math.max(t.mediaTime,this.$videoElement.currentTime),10)||0;this.player.video.render({$video:this.$videoElement,ts:i}),this.player.handleRender(),this.player.updateStats({dts:i}),this.supportVideoFrameCallbackHandle=this.$videoElement.requestVideoFrameCallback(this.videoFrameCallback.bind(this))}_startBandwidthEstimateInterval(){this._stopBandwidthEstimateInterval(),this.bandwidthEstimateInterval=setInterval((()=>{let e=0;this.hls.bandwidthEstimate&&(e=this.hls.bandwidthEstimate),this.player.emit(nt.kBps,(e/1024/8/10).toFixed(2))}),1e3)}_stopBandwidthEstimateInterval(){this.bandwidthEstimateInterval&&(clearInterval(this.bandwidthEstimateInterval),this.bandwidthEstimateInterval=null)}_startFpsInterval(){this._stopCanvasRender(),this.fpsInterval=setInterval((()=>{if(this.$videoElement)if(Ga(this.$videoElement.getVideoPlaybackQuality)){const e=this.$videoElement.getVideoPlaybackQuality();this.hlsFps=e.totalVideoFrames-this.hlsPrevFrams,this.hlsPrevFrams=e.totalVideoFrames}else{const e=this.$videoElement.webkitDecodedFrameCount||0;this.hlsFps=e-this.hlsPrevFrams,this.hlsPrevFrams=e}}),1e3)}_stopFpsInterval(){this.fpsInterval&&(clearInterval(this.fpsInterval),this.fpsInterval=null)}_initHls(){this.player._opt.useCanvasRender&&(this.$videoElement=document.createElement("video"),this.$videoElement.muted=!0,ha()&&(this.$videoElement.style.position="absolute"),this.initVideoEvents()),this.hls.attachMedia(this.$videoElement)}_bindEvents(){const e=this.player,{proxy:t}=this.player.events;this.hls;const i=this.$videoElement,s=ho(),r=t(i,qi,(t=>{if(this.hls){const i=parseInt(t.timeStamp,10);this.player._opt.useCanvasRender&&ro(s)&&e.updateStats({ts:i,dts:i})}}));this.eventsDestroy.push(r),this._startBandwidthEstimateInterval(),this._startFpsInterval(),this.hls.on(nA.Events.ERROR,((e,t)=>{if(t.fatal)switch(t.type){case nA.ErrorTypes.NETWORK_ERROR:this.player.debug.warn(this.TAG_NAME,"fatal network error encountered, try to recover"),this.hls.startLoad();break;case nA.ErrorTypes.MEDIA_ERROR:this.player.debug.warn(this.TAG_NAME,"fatal media error encountered, try to recover"),this.hls.recoverMediaError()}})),this.hls.on(nA.Events.MEDIA_ATTACHING,(()=>{})),this.hls.on(nA.Events.MEDIA_ATTACHED,(()=>{})),this.hls.on(nA.Events.MEDIA_DETACHING,(()=>{})),this.hls.on(nA.Events.MEDIA_DETACHED,(()=>{})),this.hls.on(nA.Events.BUFFER_RESET,(()=>{})),this.hls.on(nA.Events.BUFFER_CODECS,(()=>{})),this.hls.on(nA.Events.BUFFER_CREATED,(()=>{})),this.hls.on(nA.Events.BUFFER_APPENDING,((e,t)=>{this.player.debug.log(this.TAG_NAME,"BUFFER_APPENDING",t.type)})),this.hls.on(nA.Events.BUFFER_APPENDED,(()=>{})),this.hls.on(nA.Events.BUFFER_EOS,(()=>{})),this.hls.on(nA.Events.BUFFER_FLUSHING,(()=>{})),this.hls.on(nA.Events.BUFFER_FLUSHED,(()=>{})),this.hls.on(nA.Events.MANIFEST_LOADING,(()=>{this.player.debug.log(this.TAG_NAME,"MANIFEST_LOADING 开始加载playlist m3u8资源")})),this.hls.on(nA.Events.MANIFEST_LOADED,((e,t)=>{this.player.debug.log(this.TAG_NAME,"MANIFEST_LOADED playlist m3u8文件加载完成",t.url)})),this.hls.on(nA.Events.MANIFEST_PARSED,(()=>{this.player.debug.log(this.TAG_NAME,"MANIFEST_PARSED playlist m3u8解析完成"),e._times.demuxStart||(e._times.demuxStart=Qr())})),this.hls.on(nA.Events.LEVEL_LOADING,(()=>{})),this.hls.on(nA.Events.LEVEL_LOADED,((e,t)=>{})),this.hls.on(nA.Events.FRAG_LOADING,(()=>{})),this.hls.on(nA.Events.FRAG_LOADED,((t,i)=>{e._times.decodeStart||(e._times.decodeStart=Qr())})),this.hls.on(nA.Events.BUFFER_APPENDING,(()=>{e._times.videoStart||(e._times.videoStart=Qr(),e.handlePlayToRenderTimes())})),this.hls.on(nA.Events.FRAG_DECRYPTED,(()=>{})),this.hls.on(nA.Events.KEY_LOADING,(()=>{})),this.hls.on(nA.Events.KEY_LOADING,(()=>{})),this.hls.on(nA.Events.FPS_DROP,(e=>{})),this.hls.on(nA.Events.FPS_DROP_LEVEL_CAPPING,(e=>{})),this.hls.on(nA.Events.FRAG_PARSING_INIT_SEGMENT,((e,t)=>{this.player.debug.log(this.TAG_NAME,"FRAG_PARSING_INIT_SEGMENT",t);const i=!!(t&&t.tracks&&t.tracks.audio),s=!!(t&&t.tracks&&t.tracks.video);if(i&&t.tracks.audio){let e=t.tracks.audio;const i=e.metadata&&e.metadata.channelCount?e.metadata.channelCount:0,s=e.codec;this.player.audio&&this.player.audio.updateAudioInfo({encType:s,channels:i,sampleRate:44100})}if(s&&t.tracks.video){let e=t.tracks.video;const i={encTypeCode:-1!==e.codec.indexOf("avc")?_t:vt};e.metadata&&(i.width=e.metadata.width,i.height=e.metadata.height),this.player.video&&this.player.video.updateVideoInfo(i)}}))}initVideoPlay(e){this.player._opt.useCanvasRender&&(this.$videoElement=document.createElement("video"),this.initVideoEvents()),this.$videoElement.autoplay=!0,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(){const{proxy:e}=this.player.events,t=e(this.$videoElement,Wi,(()=>{this.player.debug.log(this.TAG_NAME,"video canplay"),this.$videoElement.play().then((()=>{this.player.debug.log(this.TAG_NAME,"video play"),this._startCanvasRender(),this._initRenderSize()})).catch((e=>{this.player.debug.warn(this.TAG_NAME,"video play error ",e)}))})),i=e(this.$videoElement,Ji,(()=>{this.player.debug.log(this.TAG_NAME,"video waiting")})),s=e(this.$videoElement,qi,(e=>{const t=parseInt(e.timeStamp,10);this.player.handleRender(),this.player.updateStats({ts:t}),this.$videoElement.paused&&(this.player.debug.warn(this.TAG_NAME,"video is paused and next try to replay"),this.$videoElement.play().then((()=>{this.player.debug.log(this.TAG_NAME,"video is paused and replay success")})).catch((e=>{this.player.debug.warn(this.TAG_NAME,"video is paused and replay error ",e)})))})),r=e(this.$videoElement,Ki,(()=>{this.player.debug.log(this.TAG_NAME,"video playback Rate change",this.$videoElement&&this.$videoElement.playbackRate)}));this.eventsDestroy.push(t,i,s,r)}loadSource(e){return new Promise(((t,i)=>{this.canVideoPlay?(this.initVideoPlay(e),t()):this.hls.on(nA.Events.MEDIA_ATTACHED,(()=>{this.hls.loadSource(e),t()}))}))}}const dA=2097152,hA="fetch",cA="xhr",uA="arraybuffer",pA="text",fA="json",mA="real_time_speed",gA=Object.prototype.toString;function yA(e){if("[object Object]"!==gA.call(e))return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function AA(e){if(!e||null===e[0]||void 0===e[0]||0===e[0]&&(null===e[1]||void 0===e[1]))return;let t="bytes="+e[0]+"-";return e[1]&&(t+=e[1]),t}function bA(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function _A(e,t){if(!e)return;if(!t)return e;let i;const s=Object.keys(t).map((e=>{if(i=t[e],null!=i)return Array.isArray(i)?e+="[]":i=[i],i.map((t=>{var i;return i=t,"[object Date]"===gA.call(i)?t=t.toISOString():function(e){return null!==e&&"object"==typeof e}(t)&&(t=JSON.stringify(t)),`${bA(e)}=${bA(t)}`})).join("&")})).filter(Boolean).join("&");if(s){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+s}return e}function vA(e,t,i,s,r,a,o,n,l,d,h){r=null!=r?parseFloat(r):null,s=parseInt(s||"0",10),Number.isNaN(s)&&(s=0);return{data:e,done:t,option:{range:l,vid:d,index:n,contentLength:s,age:r,startTime:a,firstByteTime:o,endTime:Date.now(),priOptions:h},response:i}}function SA(e,t){return Math.round(8*e*1e3/t/1024)}class wA extends Error{retryCount=0;isTimeout=!1;loaderType=hA;startTime=0;endTime=0;options={};constructor(e,t,i,s){super(s),this.url=e,this.request=t,this.response=i}}class EA extends po{_abortController=null;_timeoutTimer=null;_reader=null;_response=null;_aborted=!1;_index=-1;_range=null;_receivedLength=0;_running=!1;_logger=null;_vid="";_onProcessMinLen=0;_onCancel=null;_priOptions=null;TAG_NAME="FetchLoader";constructor(e){super(),this.player=e}load(e){let{url:t,vid:i,timeout:s,responseType:r,onProgress:a,index:o,onTimeout:n,onCancel:l,range:d,transformResponse:h,request:c,params:u,logger:p,method:f,headers:m,body:g,mode:y,credentials:A,cache:b,redirect:_,referrer:v,referrerPolicy:S,onProcessMinLen:w,priOptions:E}=e;this._aborted=!1,this._onProcessMinLen=w,this._onCancel=l,this._abortController="undefined"!=typeof AbortController&&new AbortController,this._running=!0,this._index=o,this._range=d||[0,0],this._vid=i||t,this._priOptions=E||{};const T={method:f,headers:m,body:g,mode:y,credentials:A,cache:b,redirect:_,referrer:v,referrerPolicy:S,signal:this._abortController?.signal};let k=!1;clearTimeout(this._timeoutTimer),t=_A(t,u);const C=AA(d);C&&(m=c?c.headers:T.headers=T.headers||(Headers?new Headers:{}),Headers&&m instanceof Headers?m.append("Range",C):m.Range=C),s&&(this._timeoutTimer=setTimeout((()=>{if(k=!0,this.cancel(),n){const e=new wA(t,T,null,"timeout");e.isTimeout=!0,n(e,{index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions})}}),s));const R=Date.now();return(Ta(o)||Ta(d))&&this.player.debug.log(this.TAG_NAME,"[fetch load start], index,",o,",range,",d),new Promise(((e,i)=>{fetch(c||t,c?void 0:T).then((async s=>{if(clearTimeout(this._timeoutTimer),this._response=s,this._aborted||!this._running)return;if(h&&(s=h(s,t)||s),!s.ok)throw new wA(t,T,s,"bad network response");const n=Date.now();let l;if(r===pA)l=await s.text(),this._running=!1;else if(r===fA)l=await s.json(),this._running=!1;else{if(a)return this.resolve=e,this.reject=i,void this._loadChunk(s,a,R,n);{l=await s.arrayBuffer(),l=new Uint8Array(l),this._running=!1;const e=Date.now()-R,t=SA(l.byteLength,e);this.emit(mA,{speed:t,len:l.byteLength,time:e,vid:this._vid,index:this._index,range:this._range,priOptions:this._priOptions})}}(Ta(o)||Ta(d))&&this.player.debug.log(this.TAG_NAME,"[fetch load end], index,",o,",range,",d),e(vA(l,!0,s,s.headers.get("Content-Length"),s.headers.get("age"),R,n,o,d,this._vid,this._priOptions))})).catch((e=>{clearTimeout(this._timeoutTimer),this._running=!1,this._aborted&&!k||((e=e instanceof wA?e:new wA(t,T,null,e?.message)).startTime=R,e.endTime=Date.now(),e.isTimeout=k,e.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},i(e))}))}))}async cancel(){if(!this._aborted){if(this._aborted=!0,this._running=!1,this._response){try{this._reader&&await this._reader.cancel()}catch(e){}this._response=this._reader=null}if(this._abortController){try{this._abortController.abort()}catch(e){}this._abortController=null}this._onCancel&&this._onCancel({index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions})}}_loadChunk(e,t,i,s){if(!e.body||!e.body.getReader){this._running=!1;const t=new wA(e.url,"",e,"onProgress of bad response.body.getReader");return t.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},void this.reject(t)}this._onProcessMinLen>0&&(this._cache=new Uint8Array(dA),this._writeIdx=0);const r=this._reader=e.body.getReader();let a,o,n;const l=async()=>{o=Date.now();try{a=await r.read(),n=Date.now()}catch(e){return n=Date.now(),void(this._aborted||(this._running=!1,e.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},this.reject(e)))}const d=this._range?.length>0?this._range[0]:0,h=d+this._receivedLength;if(this._aborted)return this._running=!1,void t(void 0,!1,{range:[h,h],vid:this._vid,index:this._index,startTime:o,endTime:n,st:i,firstByteTime:s,priOptions:this._priOptions},e);const c=a.value?a.value.byteLength:0;let u;if(this._receivedLength+=c,this.player.debug.log(this.TAG_NAME,"【fetchLoader,onProgress call】,task,",this._range,", start,",h,", end,",d+this._receivedLength,", done,",a.done),this._onProcessMinLen>0){if(this._writeIdx+c>=this._onProcessMinLen||a.done)u=new Uint8Array(this._writeIdx+c),u.set(this._cache.slice(0,this._writeIdx),0),c>0&&u.set(a.value,this._writeIdx),this._writeIdx=0,this.player.debug.log(this.TAG_NAME,"【fetchLoader,onProgress enough】,done,",a.done,",len,",u.byteLength,", writeIdx,",this._writeIdx);else if(c>0&&this._writeIdx+c<dA)this._cache.set(a.value,this._writeIdx),this._writeIdx+=c,this.player.debug.log(this.TAG_NAME,"【fetchLoader,onProgress cache】,len,",c,", writeIdx,",this._writeIdx);else if(c>0){const e=new Uint8Array(this._writeIdx+c+2048);this.player.debug.log(this.TAG_NAME,"【fetchLoader,onProgress extra start】,size,",this._writeIdx+c+2048,", datalen,",c,", writeIdx,",this._writeIdx),e.set(this._cache.slice(0,this._writeIdx),0),c>0&&e.set(a.value,this._writeIdx),this._writeIdx+=c,delete this._cache,this._cache=e,this.player.debug.log(this.TAG_NAME,"【fetchLoader,onProgress extra end】,len,",c,", writeIdx,",this._writeIdx)}}else u=a.value;if((u&&u.byteLength>0||a.done)&&t(u,a.done,{range:[this._range[0]+this._receivedLength-(u?u.byteLength:0),this._range[0]+this._receivedLength],vid:this._vid,index:this._index,startTime:o,endTime:n,st:i,firstByteTime:s,priOptions:this._priOptions},e),a.done){const t=Date.now()-i,r=SA(this._receivedLength,t);this.emit(mA,{speed:r,len:this._receivedLength,time:t,vid:this._vid,index:this._index,range:this._range,priOptions:this._priOptions}),this._running=!1,this.player.debug.log(this.TAG_NAME,"[fetchLoader onProgress end],task,",this._range,",done,",a.done),this.resolve(vA(a,!0,e,e.headers.get("Content-Length"),e.headers.get("age"),i,s,this._index,this._range,this._vid,this._priOptions))}else l()};l()}get receiveLen(){return this._receivedLength}get running(){return this._running}set running(e){this._running=e}static isSupported(){return!("undefined"==typeof fetch)}}class TA{TAG_NAME="Task";constructor(e,t,i){this.promise=function(){let e,t;const i=new Promise(((i,s)=>{e=i,t=s}));return i.used=!1,i.resolve=function(){return i.used=!0,e(...arguments)},i.reject=function(){return i.used=!0,t(...arguments)},i}(),this.alive=!!t.onProgress,this._loaderType=e,this.player=i,this._loader=e===hA&&window.fetch?new EA(i):new kA(i),this._config=t,this._retryCount=0,this._retryTimer=null,this._canceled=!1,this._retryCheckFunc=t.retryCheckFunc}exec(){const{retry:e,retryDelay:t,onRetryError:i,transformError:s,...r}=this._config,a=async()=>{try{const e=await this._loader.load(r);this.promise.resolve(e)}catch(o){if(this._loader.running=!1,this.player.debug.log(this.TAG_NAME,"[task request catch err]",o),this._canceled)return;o.loaderType=this._loaderType,o.retryCount=this._retryCount;let n=o;s&&(n=s(n)||n),i&&this._retryCount>0&&i(n,this._retryCount,{index:r.index,vid:r.vid,range:r.range,priOptions:r.priOptions}),this._retryCount++;let l=!0;if(this._retryCheckFunc&&(l=this._retryCheckFunc(o)),l&&this._retryCount<=e)return clearTimeout(this._retryTimer),this.player.debug.log(this.TAG_NAME,"[task request setTimeout],retry",this._retryCount,",retry range,",r.range),void(this._retryTimer=setTimeout(a,t));this.promise.reject(n)}};return a(),this.promise}async cancel(){return clearTimeout(this._retryTimer),this._canceled=!0,this._loader.running=!1,this._loader.cancel()}get running(){return this._loader&&this._loader.running}get loader(){return this._loader}}class kA extends po{_xhr=null;_aborted=!1;_timeoutTimer=null;_range=null;_receivedLength=0;_url=null;_onProgress=null;_index=-1;_headers=null;_currentChunkSizeKB=384;_timeout=null;_xhr=null;_withCredentials=null;_startTime=-1;_loadCompleteResolve=null;_loadCompleteReject=null;_runing=!1;_logger=!1;_vid="";_responseType;_credentials;_method;_transformResponse;_firstRtt;_onCancel=null;_priOptions=null;TAG_NAME="XhrLoader";constructor(e){super(),this.player=e}load(e){clearTimeout(this._timeoutTimer),this._range=e.range,this._onProgress=e.onProgress,this._index=e.index,this._headers=e.headers,this._withCredentials="include"===e.credentials||"same-origin"===e.credentials,this._body=e.body||null,e.method&&(this._method=e.method),this._timeout=e.timeout||null,this._runing=!0,this._vid=e.vid||e.url,this._responseType=e.responseType,this._firstRtt=-1,this._onTimeout=e.onTimeout,this._onCancel=e.onCancel,this._request=e.request,this._priOptions=e.priOptions||{},this.player.debug.log(this.TAG_NAME,"【xhrLoader task】, range",this._range),this._url=_A(e.url,e.params);const t=Date.now();return new Promise(((e,t)=>{this._loadCompleteResolve=e,this._loadCompleteReject=t,this._startLoad()})).catch((e=>{if(clearTimeout(this._timeoutTimer),this._runing=!1,!this._aborted)throw(e=e instanceof wA?e:new wA(this._url,this._request)).startTime=t,e.endTime=Date.now(),e.options={index:this._index,vid:this._vid,priOptions:this._priOptions},e}))}_startLoad(){let e=null;if(this._responseType===uA&&this._range&&this._range.length>1)if(this._onProgress){this._firstRtt=-1;const t=1024*this._currentChunkSizeKB,i=this._range[0]+this._receivedLength;let s=this._range[1];t<this._range[1]-i&&(s=i+t),e=[i,s],this.player.debug.log(this.TAG_NAME,"[xhr_loader->],tast :",this._range,", SubRange, ",e)}else e=this._range,this.player.debug.log(this.TAG_NAME,"[xhr_loader->],tast :",this._range,", allRange, ",e);this._internalOpen(e)}_internalOpen(e){try{this._startTime=Date.now();const t=this._xhr=new XMLHttpRequest;t.open(this._method||"GET",this._url,!0),t.responseType=this._responseType,this._timeout&&(t.timeout=this._timeout),t.withCredentials=this._withCredentials,t.onload=this._onLoad.bind(this),t.onreadystatechange=this._onReadyStatechange.bind(this),t.onerror=e=>{this._running=!1;const t=new wA(this._url,this._request,e?.currentTarget?.response,"xhr.onerror.status:"+e?.currentTarget?.status+",statusText,"+e?.currentTarget?.statusText);t.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(t)},t.ontimeout=e=>{this.cancel();const t=new wA(this._url,this._request,{status:408},"timeout");this._onTimeout&&(t.isTimeout=!0,this._onTimeout(t,{index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions})),t.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(t)};const i=this._headers||{},s=AA(e);s&&(i.Range=s),i&&Object.keys(i).forEach((e=>{t.setRequestHeader(e,i[e])})),this.player.debug.log(this.TAG_NAME,"[xhr.send->] tast,",this._range,",load sub range, ",e),t.send(this._body)}catch(t){t.options={index:this._index,range:e,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(t)}}_onReadyStatechange(e){2===e.target.readyState&&this._firstRtt<0&&(this._firstRtt=Date.now())}_onLoad(e){const t=e.target.status;if(t<200||t>299){const i=new wA(this._url,null,{...e.target.response,status:t},"bad response,status:"+t);return i.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(i)}let i,s=null,r=!1;const a=this._range?.length>0?this._range[0]:0;if(this._responseType===uA){const t=new Uint8Array(e.target.response);if(i=a+this._receivedLength,t&&t.byteLength>0){this._receivedLength+=t.byteLength;const e=Date.now()-this._startTime,s=SA(this._receivedLength,e);this.emit(mA,{speed:s,len:this._receivedLength,time:e,vid:this._vid,index:this._index,range:[i,a+this._receivedLength],priOptions:this._priOptions})}s=t,r=!(this._range?.length>1&&this._range[1]&&this._receivedLength<this._range[1]-this._range[0]),this.player.debug.log(this.TAG_NAME,"[xhr load done->], tast :",this._range,", start",i,"end ",a+this._receivedLength,",dataLen,",t?t.byteLength:0,",receivedLength",this._receivedLength,",index,",this._index,", done,",r)}else r=!0,s=e.target.response;let o={ok:t>=200&&t<300,status:t,statusText:this._xhr.statusText,url:this._xhr.responseURL,headers:this._getHeaders(this._xhr),body:this._xhr.response};this._transformResponse&&(o=this._transformResponse(o,this._url)||o),this._onProgress&&this._onProgress(s,r,{index:this._index,vid:this._vid,range:[i,a+this._receivedLength],startTime:this._startTime,endTime:Date.now(),priOptions:this._priOptions},o),r?(this._runing=!1,this._loadCompleteResolve&&this._loadCompleteResolve(vA(this._onProgress?null:s,r,o,o.headers["content-length"],o.headers.age,this._startTime,this._firstRtt,this._index,this._range,this._vid,this._priOptions))):this._startLoad()}cancel(){if(!this._aborted)return this._aborted=!0,this._runing=!1,super.removeAllListeners(),this._onCancel&&this._onCancel({index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions}),this._xhr?this._xhr.abort():void 0}static isSupported(){return"undefined"!=typeof XMLHttpRequest}get receiveLen(){return this._receivedLength}get running(){return this._running}set running(e){this._running=e}_getHeaders(e){const t=e.getAllResponseHeaders().trim().split("\r\n"),i={};for(const e of t){const t=e.split(": ");i[t[0].toLowerCase()]=t.slice(1).join(": ")}return i}}class CA extends po{type=hA;_queue=[];_alive=[];_currentTask=null;_config;constructor(e,t){super(),this.player=t,this._config=function(e){return{loaderType:hA,retry:0,retryDelay:0,timeout:0,request:null,onTimeout:void 0,onProgress:void 0,onRetryError:void 0,transformRequest:void 0,transformResponse:void 0,transformError:void 0,responseType:pA,range:void 0,url:"",params:void 0,method:"GET",headers:{},body:void 0,mode:void 0,credentials:void 0,cache:void 0,redirect:void 0,referrer:void 0,referrerPolicy:void 0,integrity:void 0,onProcessMinLen:0,...e}}(e),this._config.loaderType!==cA&&EA.isSupported()||(this.type=cA)}destroy(){this._queue=[],this._alive=[],this._currentTask=null}isFetch(){return this.type===hA}static isFetchSupport(){return EA.isSupported()}load(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};"string"!=typeof e&&e?t=e:t.url=e||t.url||this._config.url,t=Object.assign({},this._config,t),t.params&&(t.params=Object.assign({},t.params)),t.headers&&yA(t.headers)&&(t.headers=Object.assign({},t.headers)),t.body&&yA(t.body)&&(t.body=Object.assign({},t.body)),t.transformRequest&&(t=t.transformRequest(t)||t);const i=new TA(this.type,t,this.player);return i.loader.on(mA,(e=>{this.emit(mA,e)})),this._queue.push(i),1!==this._queue.length||this._currentTask&&this._currentTask.running||this._processTask(),i.promise}async cancel(){const e=this._queue.map((e=>e.cancel())).concat(this._alive.map((e=>e.cancel())));this._currentTask&&e.push(this._currentTask.cancel()),this._queue=[],this._alive=[],await Promise.all(e),await function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return new Promise((t=>setTimeout(t,e)))}()}_processTask(){if(this._currentTask=this._queue.shift(),!this._currentTask)return;this._currentTask.alive&&this._alive.push(this._currentTask);const e=this._currentTask.exec().catch((e=>{}));e&&"function"==typeof e.finally&&e.finally((()=>{this._currentTask?.alive&&this._alive?.length>0&&(this._alive=this._alive.filter((e=>e&&e!==this._currentTask))),this._processTask()}))}}const RA="network",xA="network_timeout",DA="other",LA="manifest",PA="hls",BA="demux";class IA extends Error{constructor(e,t,i,s,r){super(r||i?.message),this.errorType=e===xA?RA:e,this.originError=i,this.ext=s,this.errorMessage=this.message}static create(e,t,i,s,r){return e instanceof IA?e:(e instanceof Error&&(i=e,e=""),e||(e=DA),new IA(e,t,i,s,r))}static network(e){return new IA(e?.isTimeout?xA:RA,null,e instanceof Error?e:null,{url:e?.url,response:e?.response,httpCode:e?.response?.status})}}const MA=/^#(EXT[^:]*)(?::(.*))?$/,UA=/([^=]+)=(?:"([^"]*)"|([^",]*))(?:,|$)/g,FA=/^(?:[a-zA-Z0-9+\-.]+:)?\/\//,OA=/^((?:[a-zA-Z0-9+\-.]+:)?\/\/[^/?#]*)?([^?#]*\/)?/;function NA(e){const t=e.match(MA);if(t&&t[1])return[t[1].replace("EXT-X-",""),t[2]]}function jA(e){const t={};let i=UA.exec(e);for(;i;)t[i[1]]=i[2]||i[3],i=UA.exec(e);return t}function zA(e,t){if(!t||!e||FA.test(e))return e;const i=OA.exec(t);return i?"/"===e[0]?i[1]+e:i[1]+i[2]+e:e}const GA={audio:[/^mp4a/,/^vorbis$/,/^opus$/,/^flac$/,/^[ae]c-3$/],video:[/^avc/,/^hev/,/^hvc/,/^vp0?[89]/,/^av1$/],text:[/^vtt$/,/^wvtt/,/^stpp/]};function HA(e,t){const i=GA[e];if(i&&t&&t.length)for(let e=0;e<i.length;e++)for(let s=0;s<t.length;s++)if(i[e].test(t[s]))return t[s]}class $A{constructor(){this.version=0,this.streams=[],this.isMaster=!0}}const VA="AUDIO",WA="SUBTITLE";class JA{id=0;url="";default=!1;autoSelect=!1;forced=!1;group="";name="";lang="";segments=[];endSN=0}class qA extends JA{mediaType=VA;channels=0}class KA extends JA{mediaType=WA}class YA{id=0;bitrate=0;width=0;height=0;name="";url="";audioCodec="";videoCodec="";textCodec="";audioGroup="";audioStreams=[];subtitleStreams=[];closedCaptionsStream=[]}class QA{version=0;url="";type="";startCC=0;endCC=0;startSN=0;endSN=0;totalDuration=0;targetDuration=0;live=!0;segments=[]}class XA{sn=0;cc=0;url="";title="";start=0;duration=0;key=null;byteRange=null;isInitSegment=!1;initSegment=null;isLast=!1;hasAudio=!1;hasVideo=!1;get end(){return this.start+this.duration}setTrackExist(e,t){this.hasVideo=e,this.hasAudio=t}setByteRange(e,t){this.byteRange=[0];const i=e.split("@");1===i.length&&t&&t.byteRange?(this.byteRange[0]=t.byteRange[1]||0,this.byteRange[0]&&(this.byteRange[0]+=1)):this.byteRange[0]=parseInt(i[1]),this.byteRange[1]=this.byteRange[0]+parseInt(i[0])-1}}class ZA{method="";url="";iv=null;keyFormat="";keyFormatVersions="";constructor(e){e instanceof ZA&&(this.method=e.method,this.url=e.url,this.keyFormat=e.keyFormat,this.keyFormatVersions=e.keyFormatVersions,e.iv&&(this.iv=new Uint8Array(e.iv)))}clone(e){const t=new ZA(this);return null!=e&&t.setIVFromSN(e),t}setIVFromSN(e){if(!this.iv&&"AES-128"===this.method&&"number"==typeof e&&this.url){this.iv=new Uint8Array(16);for(let t=12;t<16;t++)this.iv[t]=e>>8*(15-t)&255}}}class eb{static parse(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1?arguments[1]:void 0;if(!e.includes("#EXTM3U"))throw new Error("Invalid m3u8 file");const i=function(e){return e.split(/[\r\n]/).map((e=>e.trim())).filter(Boolean)}(e);return eb.isMediaPlaylist(e)?function(e,t){const i=new QA;i.url=t;let s,r=new XA,a=null,o=null,n=0,l=0,d=0,h=0,c=!1;for(;(s=e[h++])&&!c;){if("#"!==s[0]){r.sn=l,r.cc=d,r.url=zA(s,t),o&&(r.key=o.clone(l)),a&&(r.initSegment=a),i.segments.push(r),r=new XA,l++;continue}const e=NA(s);if(!e)continue;const[h,u]=e;switch(h){case"VERSION":i.version=parseInt(u);break;case"PLAYLIST-TYPE":i.type=u?.toUpperCase();break;case"TARGETDURATION":i.targetDuration=parseFloat(u);break;case"ENDLIST":{const e=i.segments[i.segments.length-1];e&&(e.isLast=!0),i.live=!1,c=!0}break;case"MEDIA-SEQUENCE":l=i.startSN=parseInt(u);break;case"DISCONTINUITY-SEQUENCE":d=i.startCC=parseInt(u);break;case"DISCONTINUITY":d++;break;case"BYTERANGE":r.setByteRange(u,i.segments[i.segments.length-1]);break;case"EXTINF":{const[e,t]=u.split(",");r.start=n,r.duration=parseFloat(e),n+=r.duration,r.title=t}break;case"KEY":{const e=jA(u);if("NONE"===e.METHOD){o=null;break}if("AES-128"!==e.METHOD)throw new Error(`encrypt ${e.METHOD}/${e.KEYFORMAT} is not supported`);if(o=new ZA,o.method=e.METHOD,o.url=/^blob:/.test(e.URI)?e.URI:zA(e.URI,t),o.keyFormat=e.KEYFORMAT||"identity",o.keyFormatVersions=e.KEYFORMATVERSIONS,e.IV){let t=e.IV.slice(2);t=(1&t.length?"0":"")+t,o.iv=new Uint8Array(t.length/2);for(let e=0,i=t.length/2;e<i;e++)o.iv[e]=parseInt(t.slice(2*e,2*e+2),16)}}break;case"MAP":{const e=jA(u);r.url=zA(e.URI,t),e.BYTERANGE&&r.setByteRange(e.BYTERANGE),r.isInitSegment=!0,r.sn=0,o&&(r.key=o.clone(0)),a=r,r=new XA}}}const u=i.segments[i.segments.length-1];return u&&(i.endSN=u.sn),i.totalDuration=n,i.endCC=d,i}(i,t):function(e,t){const i=new $A;let s,r=0;const a=[],o=[];for(;s=e[r++];){const n=NA(s);if(!n)continue;const[l,d]=n;if("VERSION"===l)i.version=parseInt(d);else if("MEDIA"===l&&d){const e=jA(d);let i;switch(e.TYPE){case"AUDIO":i=new qA;break;case"SUBTITLES":i=new KA;break;default:i=new JA}i.url=zA(e.URI,t),i.default="YES"===e.DEFAULT,i.autoSelect="YES"===e.AUTOSELECT,i.group=e["GROUP-ID"],i.name=e.NAME,i.lang=e.LANGUAGE,e.CHANNELS&&(i.channels=Number(e.CHANNELS.split("/")[0]),Number.isNaN(i.channels)&&(i.channels=0)),"AUDIO"===e.TYPE&&e.URI&&a.push(i),"SUBTITLES"===e.TYPE&&o.push(i)}else if("STREAM-INF"===l&&d){const s=new YA,a=jA(d);if(s.bitrate=parseInt(a["AVERAGE-BANDWIDTH"]||a.BANDWIDTH),s.name=a.NAME,s.url=zA(e[r++],t),a.RESOLUTION){const[e,t]=a.RESOLUTION.split("x");s.width=parseInt(e),s.height=parseInt(t)}if(a.CODECS){const e=a.CODECS.split(/[ ,]+/).filter(Boolean);s.videoCodec=HA("video",e),s.audioCodec=HA("audio",e),s.textCodec=HA("text",e)}s.audioGroup=a.AUDIO,s.subtitleGroup=a.SUBTITLES,i.streams.push(s)}}return i.streams.forEach(((e,t)=>{e.id=t})),a.length&&(a.forEach(((e,t)=>{e.id=t})),i.streams.forEach((e=>{e.audioGroup&&(e.audioStreams=a.filter((t=>t.group===e.audioGroup)))}))),o.length&&(o.forEach(((e,t)=>{e.id=t})),i.streams.forEach((e=>{e.subtitleGroup&&(e.subtitleStreams=o.filter((t=>t.group===e.subtitleGroup)))}))),i}(i,t)}static isMediaPlaylist(e){return e.includes("#EXTINF:")||e.includes("#EXT-X-TARGETDURATION:")}}class tb{constructor(e){this.hls=e,this.player=e.player,this.TAG_NAME="HlsManifestLoader",this._timer=null;const{retryCount:t,retryDelay:i,loadTimeout:s,fetchOptions:r}=this.hls.config;this._loader=new CA({...r,responseType:"text",retry:t,retryDelay:i,timeout:s,onRetryError:this._onLoaderRetry},this.player),this._audioLoader=new CA({...r,responseType:"text",retry:t,retryDelay:i,timeout:s,onRetryError:this._onLoaderRetry},this.player),this._subtitleLoader=new CA({...r,responseType:"text",retry:t,retryDelay:i,timeout:s,onRetryError:this._onLoaderRetry},this.player)}async destroy(){await this.stopPoll(),this._audioLoader&&(this._audioLoader.destroy(),this._audioLoader=null),this._subtitleLoader&&(this._subtitleLoader.destroy(),this._subtitleLoader=null),this._loader&&(this._loader.destroy(),this._loader=null)}async load(e,t,i){this.player.debug.log(this.TAG_NAME,"load()",e,t,i);const s=[this._loader.load(e)];let r,a,o,n,l,d;t&&s.push(this._audioLoader.load(t)),i&&s.push(this._subtitleLoader.load(i));try{const[e,i,n]=await Promise.all(s);if(!e)return[];r=e.data,t?(a=i?.data,o=n?.data):o=i?.data}catch(e){throw IA.network(e)}try{if(n=eb.parse(r,e),!1===n?.live&&n.segments&&!n.segments.length)throw new Error("empty segments list");a&&(l=eb.parse(a,t)),o&&(d=eb.parse(o,i))}catch(e){throw new IA(LA,PA,e)}return n&&(n.isMaster?this.hls.emit(Is,{playlist:n}):this.hls.emit(Ms,{playlist:n})),[n,l,d]}poll(e,t,i,s,r,a){clearTimeout(this._timer),a=a||3e3;let o=this.hls.config.pollRetryCount;const n=async()=>{clearTimeout(this._timer);try{const r=await this.load(e,t,i);if(!r[0])return;o=this.hls.config.pollRetryCount,s(r[0],r[1],r[2])}catch(e){o--,o<=0&&r(e)}this._timer=setTimeout(n,a)};this._timer=setTimeout(n,a)}stopPoll(){return clearTimeout(this._timer),this.cancel()}cancel(){return Promise.all([this._loader.cancel(),this._audioLoader.cancel()])}_onLoaderRetry=(e,t)=>{this.hls.emit(js,{error:IA.network(e),retryTime:t})}}class ib{_chunkSpeeds=[];_speeds=[];addRecord(e,t){e&&t&&(this._speeds.push(8e3*e/t),this._speeds=this._speeds.slice(-3))}addChunkRecord(e,t){e&&t&&(this._chunkSpeeds.push(8e3*e/t),this._chunkSpeeds=this._chunkSpeeds.slice(-100))}getAvgSpeed(){return this._chunkSpeeds.length||this._speeds.length?this._speeds.length?this._speeds.reduce(((e,t)=>e+t))/this._speeds.length:this._chunkSpeeds.reduce(((e,t)=>e+t))/this._chunkSpeeds.length:0}getLatestSpeed(){return this._chunkSpeeds.length||this._speeds.length?this._speeds.length?this._speeds[this._speeds.length-1]:this._chunkSpeeds[this._chunkSpeeds.length-1]:0}reset(){this._chunkSpeeds=[],this._speeds=[]}}class sb{constructor(e){this.hls=e,this.player=e.player,this._bandwidthService=new ib;const{retryCount:t,retryDelay:i,loadTimeout:s,fetchOptions:r}=this.hls.config;this._segmentLoader=new CA({...r,responseType:"arraybuffer",retry:t,retryDelay:i,timeout:s,onRetryError:this._onLoaderRetry},this.player),this._audioSegmentLoader=new CA({...r,responseType:"arraybuffer",retry:t,retryDelay:i,timeout:s,onRetryError:this._onLoaderRetry},this.player),this._keyLoader=new CA({...r,responseType:"arraybuffer",retry:t,retryDelay:i,timeout:s,onRetryError:this._onLoaderRetry},this.player)}destroy(){this.reset(),this._keyLoader&&(this._keyLoader.destroy(),this._keyLoader=null),this._audioSegmentLoader&&(this._audioSegmentLoader.destroy(),this._audioSegmentLoader=null),this._segmentLoader&&(this._segmentLoader.destroy(),this._segmentLoader=null)}speedInfo(){return{speed:this._bandwidthService.getLatestSpeed(),avgSpeed:this._bandwidthService.getAvgSpeed()}}resetBandwidth(){this._bandwidthService.reset()}load(e,t,i){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:i;const r=[];return e&&(r[0]=this.loadVideoSegment(e,i)),t&&(r[1]=this.loadAudioSegment(t,s)),Promise.all(r)}loadVideoSegment(e,t){return this._loadSegment(this._segmentLoader,e,t)}loadAudioSegment(e,t){return this._loadSegment(this._audioSegmentLoader,e,t)}async _loadSegment(e,t,i){let s,r,a,o,n;const l=[];if(this.hls.emit(zs,{url:t.url}),l[0]=e.load(t.url),i&&t.initSegment){const i=t.initSegment.url;s=this._mapCache[i],s||(this.hls.emit(zs,{url:i}),l[1]=e.load(i).then((e=>{if(e){Object.keys(this._mapCache)>30&&(this._mapCache={}),s=this._mapCache[i]=e.data,this._emitOnLoaded(e,i)}})));const r=t.initSegment.key?.url;r&&(n=t.initSegment.key.iv,o=this._keyCache[r],o||(this.hls.emit(zs,{url:r}),l[2]=this._keyLoader.load(r).then((e=>{e&&(o=this._keyCache[r]=e.data,this._emitOnLoaded(e,r))}))))}const d=t.key?.url;d&&(a=t.key.iv,r=this._keyCache[d],r||(this.hls.emit(zs,{url:d}),l[3]=this._keyLoader.load(d).then((e=>{e&&(r=this._keyCache[d]=e.data,this._emitOnLoaded(e,d))}))));const[h]=await Promise.all(l);if(!h)return;const c=h.data;return this._emitOnLoaded(h,t.url),{data:c,map:s,key:r,mapKey:o,keyIv:a,mapKeyIv:n}}reset(){this.error=null,this._mapCache={},this._keyCache={},this._bandwidthService.reset()}async cancel(){await Promise.all([this._keyLoader.cancel(),this._segmentLoader.cancel(),this._audioSegmentLoader.cancel()])}_emitOnLoaded=(e,t)=>{const{data:i,response:s,option:r}=e,{firstByteTime:a,startTime:o,endTime:n,contentLength:l}=r||{},d=n-o;this._bandwidthService.addRecord(l||i.byteLength,d),this.hls.emit(Gs,{time:d,byteLength:l,url:t}),this.hls.emit(Hs,{url:t,elapsed:d||0}),this.hls.emit(Ns,{url:t,responseUrl:s.url,elapsed:a-o}),this.hls.emit($s,{headers:s.headers})};_onLoaderRetry=(e,t)=>{this.hls.emit(js,{error:IA.network(e),retryTime:t})}}class rb{constructor(e,t,i){this.live=void 0,this.id=0,this.bitrate=0,this.width=0,this.height=0,this.name="",this.url="",this.audioCodec="",this.videoCodec="",this.textCodec="",this.startCC=0,this.endCC=0,this.startSN=0,this.endSN=-1,this.totalDuration=0,this.targetDuration=0,this.snDiff=null,this.segments=[],this.audioStreams=[],this.subtitleStreams=[],this.closedCaptions=[],this.currentAudioStream=null,this.currentSubtitleStream=null,this.TAG_NAME="HlsStream",this.update(e,t,i)}get lastSegment(){return this.segments.length?this.segments[this.segments.length-1]:null}get segmentDuration(){return this.targetDuration||this.segments[0]?.duration||0}get liveEdge(){return this.endTime}get endTime(){return this.lastSegment?.end||0}get currentSubtitleEndSn(){return this.currentSubtitleStream?.endSN||0}clearOldSegment(e,t){return this._clearSegments(e,t)}getAudioSegment(e){if(!e||!this.currentAudioStream)return;const t=e.sn-this.snDiff;return this.currentAudioStream.segments.find((e=>e.sn===t))}update(e,t){this.url=e.url,Array.isArray(e.segments)?(null!==this.live&&void 0!==this.live||(this.live=e.live),this._updateSegments(e,this),this.startCC=e.startCC,this.endCC=e.endCC,this.startSN=e.startSN,this.endSN=e.endSN||-1,this.totalDuration=e.totalDuration,this.targetDuration=e.targetDuration,this.live=e.live,t&&this.currentAudioStream&&Array.isArray(t.segments)&&(this._updateSegments(t,this.currentAudioStream),(null===this.snDiff||void 0===this.snDiff)&&e.segments.length&&t.segments.length&&(this.snDiff=e.segments[0].sn-t.segments[0].sn))):(this.id=e.id,this.bitrate=e.bitrate,this.width=e.width,this.height=e.height,this.name=e.name,this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.textCodec=e.textCodec,this.audioStreams=e.audioStreams,this.subtitleStreams=e.subtitleStreams,!this.currentAudioStream&&this.audioStreams.length&&(this.currentAudioStream=this.audioStreams.find((e=>e.default))||this.audioStreams[0]),!this.currentSubtitleStream&&this.subtitleStreams.length&&(this.currentSubtitleStream=this.subtitleStreams.find((e=>e.default))||this.subtitleStreams[0]))}updateSubtitle(e){if(!(e&&this.currentSubtitleStream&&Array.isArray(e.segments)))return;const t=this._updateSegments(e,this.currentSubtitleStream),i=this.currentSubtitleStream.segments;return i.length>100&&(this.currentSubtitleStream.segments=i.slice(100)),t?t.map((e=>({sn:e.sn,url:e.url,duration:e.duration,start:e.start,end:e.end,lang:this.currentSubtitleStream.lang}))):void 0}switchSubtitle(e){const t=this.subtitleStreams.find((t=>t.lang===e)),i=this.currentSubtitleStream;t&&(this.currentSubtitleStream=t,i.segments=[])}_clearSegments(e,t){let i=0;const s=this.segments;for(let t=0,r=s.length;t<r;t++)if(s[t].end>=e){i=t;break}return i>t&&(i=t),i&&(this.segments=this.segments.slice(i),this.currentAudioStream&&(this.currentAudioStream.segments=this.currentAudioStream.segments.slice(i))),t-i}_updateSegments(e,t){const i=t.segments;if(this.live){const s=i[i.length-1],r=s?.sn||-1;if(r<e.endSN&&e.segments.length){const a=e.segments.findIndex((e=>e.sn===r)),o=a<0?e.segments:e.segments.slice(a+1);if(i.length&&o.length){let e=s.end;o.forEach((t=>{t.start=e,e=t.end}));const t=s?.cc||-1;t>o[0].cc&&o.forEach((e=>e.cc+=t))}return t.endSN=e.endSN,t.segments=i.concat(o),o}}else t.segments=e.segments}}class ab{constructor(e){this.hls=e,this.player=e.player,this.streams=[],this.currentStream=null,this.dvrWindow=0,this._segmentPointer=-1,this.TAG_NAME="HlsPlaylist"}destroy(){this.reset()}get lastSegment(){return this.currentStream?.lastSegment}get currentSegment(){return this.currentSegments?.[this._segmentPointer]}get nextSegment(){return this.currentSegments?.[this._segmentPointer+1]}get currentSegments(){return this.currentStream?.segments}get currentSubtitleEndSn(){return this.currentStream?.currentSubtitleEndSn}get liveEdge(){return this.currentStream?.liveEdge}get totalDuration(){return this.currentStream?.totalDuration||0}get seekRange(){const e=this.currentSegments;if(e&&e.length)return[e[0].start,e[e.length-1].end]}get isEmpty(){return!this.currentSegments?.length}get isLive(){return this.currentStream?.live}get hasSubtitle(){return!!this.currentStream?.currentSubtitleStream}getAudioSegment(e){return this.currentStream?.getAudioSegment(e)}moveSegmentPointer(e){null==e&&(e=this._segmentPointer+1),this._segmentPointer=Xr(e,-1,this.currentSegments?.length),this.player.debug.log(this.TAG_NAME,`moveSegmentPointer() and param pos is ${e} and clamp result is ${this._segmentPointer}`)}reset(){this.streams=[],this.currentStream=null,this.dvrWindow=0,this._segmentPointer=-1}getSegmentByIndex(e){return this.currentSegments?.[e]}setNextSegmentByIndex(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this._segmentPointer=e-1,this.player.debug.log(this.TAG_NAME,"setNextSegmentByIndex()",e,this._segmentPointer)}findSegmentIndexByTime(e){const t=this.currentSegments;if(t){for(let i,s=0,r=t.length;s<r;s++)if(i=t[s],e>=i.start&&e<i.end)return s;const i=t[t.length-1];if(Math.abs(e-i?.end)<.2)return t.length-1}}upsertPlaylist(e,t,i){if(!e)return void this.player.debug.warn(this.TAG_NAME,"upsertPlaylist() playlist is null");if(e.isMaster)this.streams.length=e.streams.length,e.streams.filter((e=>e.url)).forEach(((e,t)=>{this.streams[t]?this.streams[t].update(e):this.streams[t]=new rb(e)})),this.currentStream=this.streams[0];else if(Array.isArray(e.segments)){const s=this.currentStream;if(s){s.update(e,t,i);const r=s.updateSubtitle(i);r&&this.hls.emit(Bs,{list:r})}else this.reset(),this.currentStream=this.streams[0]=new rb(e,t,i)}this.currentStream&&this.hls.isLive&&!this.dvrWindow&&(this.dvrWindow=this.currentSegments.reduce(((e,t)=>e+=t.duration),0))}switchSubtitle(e){this.currentStream?.switchSubtitle(e)}clearOldSegment(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:50;const t=this.currentStream;if(!this.dvrWindow||!t)return;const i=t.endTime-this.dvrWindow;if(i<=0)return void this.player.debug.log(this.TAG_NAME,`clearOldSegment() stream.endTime:${t.endTime}, this.dvrWindow:${this.dvrWindow} startTime <= 0`);const s=t.segments;if(s.length<=e)return void this.player.debug.log(this.TAG_NAME,`clearOldSegment() segments.length:${s.length} <= maxPlaylistSize:${e}`);const r=this._segmentPointer;this._segmentPointer=t.clearOldSegment(i,r),this.player.debug.log(this.TAG_NAME,"clearOldSegment() update _segmentPointer:",r,this._segmentPointer),this.player.debug.log(this.TAG_NAME,"currentSegments",this.currentSegments)}checkSegmentTrackChange(e,t){const i=this.findSegmentIndexByTime(e),s=this.getSegmentByIndex(i);if(!s)return;if(!s.hasAudio&&!s.hasVideo)return;if(2!==t&&s.hasAudio&&s.hasVideo)return s;if(s.end-e>.3)return;const r=this.getSegmentByIndex(i+1);return r&&(r.hasAudio||r.hasVideo)&&(r.hasAudio!==s.hasAudio||r.hasVideo!==s.hasVideo)?r:void 0}}class ob{constructor(e,t){this.hls=e,this.player=t;const i=window.crypto||window.msCrypto;this.subtle=i&&(i.subtle||i.webkitSubtle),this.externalDecryptor=null}decrypt(e,t){if(!e&&!t)return;const i=[];return e&&(i[0]=this._decryptSegment(e)),t&&(i[1]=this._decryptSegment(t)),Promise.all(i)}async _decryptSegment(e){let t=e.data;return e.key&&(t=await this._decryptData(e.data,e.key,e.keyIv)),e.map?Bd(e.map,t):t}async _decryptData(e,t,i){if(this.externalDecryptor)return await this.externalDecryptor.decrypt(e,t,i);if(this.subtle){const s=await this.subtle.importKey("raw",t,{name:"AES-CBC"},!1,["encrypt","decrypt"]),r=await this.subtle.decrypt({name:"AES-CBC",iv:i},s,e);return new Uint8Array(r)}e=id(e),t=id(t),i=id(i);return function(e){const{words:t}=e,{sigBytes:i}=e,s=new Uint8Array(i);for(let e=0;e<i;e+=1)s[e]=t[e>>>2]>>>24-e%4*8&255;return s}(td.AES.decrypt({ciphertext:e},t,{iv:i,mode:td.mode.CBC}))}}class nb extends gd{constructor(e){super(e),this.player=e,this._pmtId=-1,this._remainingPacketData=null,this._videoPesData=[],this._audioPesData=[],this._gopId=0,this._videoPid=-1,this._audioPid=-1,this._codecType=_t,this._audioCodecType=Et.AAC,this._vps=null,this._sps=null,this._pps=null,this.TAG_NAME="HlsTsLoader",this._isForHls=!0,this.videoTrack=nb.initVideoTrack(),this.audioTrack=nb.initAudioTrack(),this._baseDts=-1,this._baseDtsInited=!1,this._basefps=25,this._baseFpsInterval=null,this._tempSampleTsList=[],this._hasAudio=!1,this._hasVideo=!1,this._audioNextPts=void 0,this._videoNextDts=void 0,this._audioTimestampBreak=!1,this._videoTimestampBreak=!1,this._lastAudioExceptionGapDot=0,this._lastAudioExceptionOverlapDot=0,this._lastAudioExceptionLargeGapDot=0,this._isSendAACSeqHeader=!1,this.workerClearTimeout=null,this.workerUrl=null,this.loopWorker=null,this.tempSampleListInfo={},this._isUseWorker()&&this._initLoopWorker(),this.player.debug.log(this.TAG_NAME,"init")}destroy(){super.destroy(),this.workerUrl&&(URL.revokeObjectURL(this.workerUrl),this.workerUrl=null),this.workerClearTimeout&&(clearTimeout(this.workerClearTimeout),this.workerClearTimeout=null),this.loopWorker&&(this.loopWorker.postMessage({cmd:"destroy"}),this.loopWorker.terminate(),this.loopWorker=null),this._stopDecodeLoopInterval(),this.videoTrack=null,this.audioTrack=null,this.tempSampleListInfo={},this._baseDts=-1,this._baseDtsInited=!1,this._basefps=25,this._hasCalcFps=!1,this._audioNextPts=void 0,this._videoNextDts=void 0,this._audioTimestampBreak=!1,this._videoTimestampBreak=!1,this._lastAudioExceptionGapDot=0,this._lastAudioExceptionOverlapDot=0,this._lastAudioExceptionLargeGapDot=0,this._isForHls=!0,this._isSendAACSeqHeader=!1,this.player.debug.log(this.TAG_NAME,"destroy")}static initVideoTrack(){return{samples:[]}}static initAudioTrack(){return{samples:[]}}static probe(e){return!!e.length&&(71===e[0]&&71===e[188]&&71===e[376])}_parsePES(e){const t=e[8];if(null==t||e.length<t+9)return;const i=e[0]<<16|e[1]<<8|e[2];if(1!==i)return this.player.debug.warn(this.TAG_NAME,`_parsePES startPrefix should be 1 but with value ${i}`),{error:!0,code:"startPrefixError"};const s=(e[4]<<8)+e[5];if(s&&s>e.length-6)return;let r,a;const o=e[7];return 192&o&&(r=536870912*(14&e[9])+4194304*(255&e[10])+16384*(254&e[11])+128*(255&e[12])+(254&e[13])/2,64&o?(a=536870912*(14&e[14])+4194304*(255&e[15])+16384*(254&e[16])+128*(255&e[17])+(254&e[18])/2,r-a>54e5&&(r=a)):a=r),{data:e.subarray(9+t),pts:r,dts:a,originalPts:r,originalDts:a}}_demux(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];t&&(this._pmtId=-1,this.videoTrack=nb.initVideoTrack(),this.audioTrack=nb.initAudioTrack()),!i||t?(this._remainingPacketData=null,this._videoPesData=[],this._audioPesData=[]):(this.videoTrack.samples=[],this.audioTrack.samples=[],this._remainingPacketData&&(e=Bd(this._remainingPacketData,e),this._remainingPacketData=null));let s=e.length;const r=s%188;r&&(this._remainingPacketData=e.subarray(s-r),s-=r);for(let t=0;t<s;t+=188){if(71!==e[t])throw new Error("TS packet did not start with 0x47");const i=!!(64&e[t+1]),s=((31&e[t+1])<<8)+e[t+2];let r;if((48&e[t+3])>>4>1){if(r=t+5+e[t+4],r===t+188)continue}else r=t+4;switch(s){case 0:i&&(r+=e[r]+1),this._pmtId=(31&e[r+10])<<8|e[r+11];break;case this._pmtId:{i&&(r+=e[r]+1);const t=r+3+((15&e[r+1])<<8|e[r+2])-4;for(r+=12+((15&e[r+10])<<8|e[r+11]);r<t;){const t=(31&e[r+1])<<8|e[r+2];switch(e[r]){case 15:this._audioPid=t,this._audioCodecType=Et.AAC;break;case 27:if(-1!==this._videoPid)break;this._videoPid=t,this._codecType=_t;break;case 36:if(-1!==this._videoPid)break;this._videoPid=t,this._codecType=vt;break;default:this.player.debug.log(this.TAG_NAME,`Unsupported stream. type: ${e[r]}, pid: ${t}`)}r+=5+((15&e[r+3])<<8|e[r+4])}}break;case this._videoPid:i&&this._videoPesData.length&&this._parseVideoData(),this._videoPesData.push(e.subarray(r,t+188));break;case this._audioPid:i&&this._audioPesData.length&&this._parseAudioData(),this._audioPesData.push(e.subarray(r,t+188));break;case 17:case 8191:break;default:this.player.debug.log(this.TAG_NAME,`Unknown pid: ${s}`)}}this._parseVideoData(),this._parseAudioData(),this.audioTrack.formatTimescale=this.videoTrack.formatTimescale=this.videoTrack.timescale=9e4,this.audioTrack.timescale=this.audioTrack.sampleRate||0}demuxAndFix(e,t,i,s){this.player._times.demuxStart||(this.player._times.demuxStart=Qr()),this._demux(e,t,i),this._fix(s,t,i)}_parseVideoData(){if(!this._videoPesData.length)return void this.player.debug.log(this.TAG_NAME,"_parseVideoData","no video pes data");const e=this._parsePES(Bd(...this._videoPesData));if(!e||e.error)return void(e&&"startPrefixError"===e.code&&(this._videoPesData=[]));const t=function(e){const t=e.length;let i=2,s=0;for(;null!==e[i]&&void 0!==e[i]&&1!==e[i];)i++;if(i++,s=i+2,s>=t)return[];const r=[];for(;s<t;)switch(e[s]){case 0:if(0!==e[s-1]){s+=2;break}if(0!==e[s-2]){s++;break}i!==s-2&&r.push(e.subarray(i,s-2));do{s++}while(1!==e[s]&&s<t);i=s+1,s=i+2;break;case 1:if(0!==e[s-1]||0!==e[s-2]){s+=3;break}i!==s-2&&r.push(e.subarray(i,s-2)),i=s+1,s=i+2;break;default:s+=3}return i<t&&r.push(e.subarray(i)),r}(e.data);t?this._createVideoSample(t,e.pts,e.dts):this.player.debug.warn(this.TAG_NAME,"Cannot parse avc units",e),this._videoPesData=[]}_createVideoSample(e,t,i){if(!e.length)return;const s=this._codecType===vt,r={isIFrame:!1,type:je,isHevc:s,vps:null,sps:null,pps:null,pts:t,dts:i,payload:null};e.forEach((e=>{const t=s?e[0]>>>1&63:31&e[0];switch(t){case 5:case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:if(!s&&5!==t||s&&5===t)break;r.isIFrame=!0,this._gopId++;break;case 6:case 39:case 40:if(!s&&6!==t||s&&6===t)break;return void function(e,t){const i=e.length;let s=t?2:1,r=0,a=0,o="";for(;255===e[s];)r+=255,s++;for(r+=e[s++];255===e[s];)a+=255,s++;if(a+=e[s++],5===r&&i>s+16)for(let t=0;t<16;t++)o+=e[s].toString(16),s++;e.subarray(s)}(function(e){const t=e.byteLength,i=[];let s=1;for(;s<t-2;)0===e[s]&&0===e[s+1]&&3===e[s+2]?(i.push(s+2),s+=2):s++;if(!i.length)return e;const r=t-i.length,a=new Uint8Array(r);let o=0;for(s=0;s<r;o++,s++)o===i[0]&&(o++,i.shift()),a[s]=e[o];return a}(e),s);case 32:if(!s)break;r.vps||(r.vps=e);break;case 7:case 33:if(!s&&7!==t||s&&7===t)break;r.sps||(r.sps=e);break;case 8:case 34:if(!s&&8!==t||s&&8===t)break;r.pps||(r.pps=e)}if(s&&Bn(t)||!s&&_n(t)){const t=Wr(e);if(r.payload){const e=new Uint8Array(r.payload.byteLength+t.byteLength);e.set(r.payload,0),e.set(t,r.payload.byteLength),r.payload=e}else r.payload=t}}));let a=null;s?r.sps&&r.vps&&r.pps&&(a=Dn({vps:r.vps,sps:r.sps,pps:r.pps})):r.sps&&r.pps&&(a=gn({sps:r.sps,pps:r.pps})),a&&(this.player.debug.log(this.TAG_NAME,"_createVideoSample","seqHeader"),this._doDecodeByHls(a,je,Math.round(r.pts/90),!0,0)),r.isIFrame&&this.calcIframeIntervalTimestamp(Math.round(r.dts/90)),this.videoTrack.samples=this.videoTrack.samples.concat(r)}_parseAudioData(){if(!this._audioPesData.length)return;if(!this.player._opt.hasAudio)return;const e=this._parsePES(Bd(...this._audioPesData));if(e&&!e.error){if(this._audioCodecType===Et.AAC){const t=function(e,t){const i=e.length;let s=0;for(;s+2<i&&(255!==e[s]||240!=(246&e[s+1]));)s++;if(s>=i)return;const r=s,a=[],o=(60&e[s+2])>>>2,n=xr[o];if(!n)throw new Error(`Invalid sampling index: ${o}`);const l=1+((192&e[s+2])>>>6),d=(1&e[s+2])<<2|(192&e[s+3])>>>6;let h,c,u=0;const p=Ur(n);for(;s+7<i;)if(255===e[s]&&240==(246&e[s+1])){if(c=(3&e[s+3])<<11|e[s+4]<<3|(224&e[s+5])>>5,i-s<c)break;h=2*(1&~e[s+1]),a.push({pts:t+u*p,data:e.subarray(s+7+h,s+c)}),u++,s+=c}else s++;return{skip:r,remaining:s>=i?void 0:e.subarray(s),frames:a,samplingFrequencyIndex:o,sampleRate:n,objectType:l,channelCount:d,originCodec:`mp4a.40.${l}`}}(e.data,e.originalPts);if(t){if(this.audioTrack.codec=t.codec,this.audioTrack.sampleRate=t.sampleRate,this.audioTrack.channelCount=t.channelCount,!this._isSendAACSeqHeader){const e=Pr({profile:t.objectType,sampleRate:t.samplingFrequencyIndex,channel:t.channelCount});this._isSendAACSeqHeader=!0,this.player.debug.log(this.TAG_NAME,"aac seq header",`profile: ${t.objectType}, sampleRate:${t.sampleRate},sampleRateIndex: ${t.samplingFrequencyIndex}, channel: ${t.channelCount}`),this._doDecodeByHls(e,Ne,0,!1,0)}if(this._isSendAACSeqHeader){const e=[];t.frames.forEach((t=>{const i=t.pts,s=new Uint8Array(t.data.length+2);s.set([175,1],0),s.set(t.data,2);const r={type:Ne,pts:i,dts:i,payload:s};e.push(r)})),this.audioTrack.samples=this.audioTrack.samples.concat(e)}else this.player.debug.warn(this.TAG_NAME,"aac seq header not send")}else this.player.debug.warn(this.TAG_NAME,"aac parseADTS error")}this._audioPesData=[]}else e&&"startPrefixError"===e.code&&(this._audioPesData=[])}_fix(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];e=Math.round(9e4*e);const s=this.videoTrack,r=this.audioTrack,a=s.samples,o=r.samples;if(!a.length&&!o.length)return;const n=a[0],l=o[0];let d=0;if(a.length&&o.length&&(d=n.dts-l.pts),this._baseDtsInited||this._calculateBaseDts(),t&&(this._calculateBaseDts(),this._baseDts-=e),!i){this._videoNextDts=d>0?e+d:e,this._audioNextPts=d>0?e:e-d;const t=n?n.dts-this._baseDts-this._videoNextDts:0,i=l?l.pts-this._baseDts-this._audioNextPts:0;Math.abs(t||i)>_r&&(this._calculateBaseDts(this.audioTrack,this.videoTrack),this._baseDts-=e)}this._resetBaseDtsWhenStreamBreaked(),this._fixAudio(r),this._fixVideo(s);let h=s.samples.concat(r.samples);h=h.map((e=>(e.dts=Math.round(e.dts/90),e.pts=Math.round(e.pts/90),e.cts=e.pts-e.dts,e))).sort(((e,t)=>e.dts-t.dts)),h.forEach((e=>{const t=new Uint8Array(e.payload);delete e.payload,this._isUseWorker()?this.loopWorker.postMessage({...e,payload:t,cmd:"sample"},[t.buffer]):e.type===je?this._doDecodeVideo({...e,payload:t}):e.type===Ne&&this._doDecodeAudio({...e,payload:t})})),ro(this._hasCalcFps)&&this._isUseWorker()&&(this._hasCalcFps=!0,this._calcDecodeFps(h))}_isUseWorker(){return!this.player.isUseMSE()&&this.isForHls()}_calculateBaseDts(){const e=this.audioTrack,t=this.videoTrack,i=e.samples,s=t.samples;if(!i.length&&!s.length)return!1;let r=1/0,a=1/0;i.length&&(e.baseDts=r=i[0].pts),s.length&&(t.baseDts=a=s[0].dts),this._baseDts=Math.min(r,a);const o=a-r;return Number.isFinite(o)&&Math.abs(o)>45e3&&this.player.debug.warn(this.TAG_NAME,`large av first frame gap,\n video pts: ${a},\n audio pts: ${r},\n base dts: ${this._baseDts},\n detect is: ${o}`),this._baseDtsInited=!0,!0}_resetBaseDtsWhenStreamBreaked(){if(this._baseDtsInited&&this._videoTimestampBreak&&this._audioTimestampBreak){if(!this._calculateBaseDts(this.audioTrack,this.videoTrack))return;this._baseDts-=Math.min(this._audioNextPts,this._videoNextDts),this._audioLastSample=null,this._videoLastSample=null,this._videoTimestampBreak=!1,this._audioTimestampBreak=!1}}_fixAudio(e){const t=e.samples;t.length&&(t.forEach((e=>{e.pts-=this._baseDts,e.dts=e.pts})),this._doFixAudioInternal(e,t,9e4))}_fixVideo(e){const t=e.samples;if(!t.length)return;if(t.forEach((e=>{e.dts-=this._baseDts,e.pts-=this._baseDts})),void 0===this._videoNextDts){const e=t[0];this._videoNextDts=e.dts}const i=t.length;let s=0;const r=t[0],a=t[1],o=this._videoNextDts-r.dts;let n;Math.abs(o)>45e3&&(r.dts+=o,r.pts+=o,this.player.debug.warn(this.TAG_NAME,`large video gap between chunk,\n next dts is ${this._videoNextDts},\n first dts is ${r.dts},\n next dts is ${a.dts},\n duration is ${o}`),a&&Math.abs(a.dts-r.dts)>_r&&(this._videoTimestampBreak=!0,t.forEach(((e,t)=>{0!==t&&(e.dts+=o,e.pts+=o)}))));const l=e.samples[0],d=e.samples[i-1];n=1===i?9e3:Math.floor((d.dts-l.dts)/(i-1));for(let r=0;r<i;r++){const a=t[r].dts,o=t[r+1];if(s=r<i-1?o.dts-a:t[r-1]?Math.min(a-t[r-1].dts,n):n,s>_r||s<0){this._videoTimestampBreak=!0,s=this._audioTimestampBreak?n:Math.max(s,2700);const i=this._audioNextPts||0;o&&o.dts>i&&(s=n),this.player.debug.warn(this.TAG_NAME,`large video gap between frames,\n time is ${a/e.timescale},\n dts is ${a},\n origin dts is ${t[r].originalDts},\n next dts is ${this._videoNextDts},\n sample Duration is ${s} ,\n ref Sample DurationInt is ${n}`)}t[r].duration=s,this._videoNextDts+=s}}_doFixAudioInternal(e,t,i){e.sampleDuration||(e.sampleDuration=Ur(e.timescale,i));const s=e.sampleDuration;if(void 0===this._audioNextPts){const e=t[0];this._audioNextPts=e.pts}for(let i=0;i<t.length;i++){const r=this._audioNextPts,a=t[i],o=a.pts-r;if(!this._audioTimestampBreak&&o>=3*s&&o<=Ar&&!ha()){Mr(e.codec,e.channelCount)||t[0].data.subarray();const n=Math.floor(o/s);Math.abs(a.pts-this._lastAudioExceptionGapDot)>br&&(this._lastAudioExceptionGapDot=a.pts),this.player.debug.warn(this.TAG_NAME,`audio gap detected,\n pts is ${t.pts},\n originPts is ${t.originalPts},\n count is ${n},\n nextPts is ${r},\n ref sample duration is ${s}`);for(let e=0;e<n;e++)this._audioNextPts+=s,i++;i--}else o<=-3*s&&o>=-9e4?(Math.abs(a.pts-this._lastAudioExceptionOverlapDot)>br&&(this._lastAudioExceptionOverlapDot=a.pts,this.player.debug.warn(this.TAG_NAME,`audio overlap detected,\n pts is ${a.pts},\n originPts is ${a.originalPts},\n nextPts is ${r},\n ref sample duration is ${s}`)),t.splice(i,1),i--):(Math.abs(o)>=Ar&&(this._audioTimestampBreak=!0,Math.abs(a.pts-this._lastAudioExceptionLargeGapDot)>br&&(this._lastAudioExceptionLargeGapDot=a.pts,this.player.debug.warn(this.TAG_NAME,`large audio gap detected,\n time is ${a.pts/1e3}\n pts is ${a.pts},\n originPts is ${a.originalPts},\n nextPts is ${r},\n sample duration is ${o}\n ref sample duration is ${s}`))),a.dts=a.pts=r,this._audioNextPts+=s)}}_calcDecodeFps(e){const t=Ya(e.map((e=>({ts:e.dts||e.pts,type:e.type}))),je);t&&(this.player.debug.log(this.TAG_NAME,`_calcDecodeFps() video fps is ${t}, update base fps is ${this._basefps}`),this._basefps=t),this._postMessageToLoopWorker("updateBaseFps",{baseFps:this._basefps})}_initLoopWorker(){this.player.debug.log(this.TAG_NAME,"_initLoopWorker()");const e=lo(function(){const e=1,t=2;let i=new class{constructor(){this.baseFps=0,this.fpsInterval=null,this.preLoopTimestamp=null,this.startBpsTime=null,this.allSampleList=[]}destroy(){this._clearInterval(),this.baseFps=0,this.allSampleList=[],this.preLoopTimestamp=null,this.startBpsTime=null}updateBaseFps(e){this.baseFps=e,this._clearInterval(),this._startInterval()}pushSample(e){delete e.cmd,this.allSampleList.push(e)}_startInterval(){const e=Math.ceil(1e3/this.baseFps);this.fpsInterval=setInterval((()=>{let t=(new Date).getTime();this.preLoopTimestamp||(this.preLoopTimestamp=t),this.startBpsTime||(this.startBpsTime=t);const i=t-this.preLoopTimestamp;if(i>2*e&&console.warn(`JbPro:[TsLoader LoopWorker] loop interval is ${i}ms, more than ${e} * 2ms`),this._loop(),this.preLoopTimestamp=(new Date).getTime(),this.startBpsTime){t-this.startBpsTime>=1e3&&(this._calcSampleList(),this.startBpsTime=t)}}),e)}_clearInterval(){this.fpsInterval&&(clearInterval(this.fpsInterval),this.fpsInterval=null)}_calcSampleList(){const i={buferredDuration:0,allListLength:this.allSampleList.length,audioListLength:0,videoListLength:0};this.allSampleList.forEach((s=>{s.type===t?(i.videoListLength++,s.duration&&(i.buferredDuration+=Math.round(s.duration/90))):s.type===e&&i.audioListLength++})),postMessage({cmd:"sampleListInfo",...i})}_loop(){let i=null;if(this.allSampleList.length)if(i=this.allSampleList.shift(),i.type===t){postMessage({cmd:"decodeVideo",...i},[i.payload.buffer]);let t=this.allSampleList[0];for(;t&&t.type===e;)i=this.allSampleList.shift(),postMessage({cmd:"decodeAudio",...i},[i.payload.buffer]),t=this.allSampleList[0]}else i.type===e&&(postMessage({cmd:"decodeAudio",...i},[i.payload.buffer]),this.allSampleList.length&&this.allSampleList[0].type===t&&(i=this.allSampleList.shift(),postMessage({cmd:"decodeVideo",...i},[i.payload.buffer])))}};self.onmessage=e=>{const t=e.data;switch(t.cmd){case"updateBaseFps":i.updateBaseFps(t.baseFps);break;case"sample":i.pushSample(t);break;case"destroy":i.destroy(),i=null}}}.toString()),t=new Blob([e],{type:"text/javascript"}),i=URL.createObjectURL(t);let s=new Worker(i);this.workerUrl=i,this.workerClearTimeout=setTimeout((()=>{window.URL.revokeObjectURL(this.workerUrl),this.workerUrl=null,this.workerClearTimeout=null}),te),s.onmessage=e=>{const t=e.data;switch(t.cmd){case"decodeVideo":this._doDecodeVideo(t);break;case"decodeAudio":this._doDecodeAudio(t);break;case"sampleListInfo":this.tempSampleListInfo=t}},this.loopWorker=s}_postMessageToLoopWorker(e,t){this._isUseWorker()&&(this.loopWorker?this.loopWorker.postMessage({cmd:e,...t}):this.player.debug.warn(this.TAG_NAME,"loop worker is not init, can not post message"))}_doDecodeAudio(e){const t=new Uint8Array(e.payload);this.player.updateStats({abps:t.byteLength});let i=t;so(this.player._opt.m7sCryptoAudio)&&(i=this.cryptoPayloadAudio(t)),this.isForHls()?this._doDecodeByHls(i,Ne,e.dts,!1,0):this._doDecodeByTs(i,Ne,e.dts,!1,0)}_doDecodeVideo(e){const t=new Uint8Array(e.payload);let i=null;i=e.isHevc?Ln(t,e.isIFrame):yn(t,e.isIFrame),this.player.updateStats({dts:e.dts,vbps:i.byteLength});const s=e.pts-e.dts;let r=this.cryptoPayload(i,e.isIFrame);this.isForHls()?this._doDecodeByHls(r,je,e.dts,e.isIFrame,s):this._doDecodeByTs(r,je,e.dts,e.isIFrame,s)}_stopDecodeLoopInterval(){this._baseFpsInterval&&(clearInterval(this._baseFpsInterval),this._baseFpsInterval=null)}getBuferredDuration(){return this.tempSampleListInfo.buferredDuration||0}getSampleListLength(){return this.tempSampleListInfo.allListLength||0}getSampleAudioListLength(){return this.tempSampleListInfo.audioListLength||0}getSampleVideoListLength(){return this.tempSampleListInfo.videoListLength||0}isForHls(){return this._isForHls}getInputByteLength(){return this._remainingPacketData&&this._remainingPacketData.byteLength||0}}function lb(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return(e[t]<<8)+(e[t+1]||0)}function db(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return(e[t]<<24>>>0)+(e[t+1]<<16)+(e[t+2]<<8)+(e[t+3]||0)}function hb(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const i=Math.pow(2,32);return db(e,t)*i+db(e,t+4)}const cb="aac",ub="g7110a",pb="g7110m",fb="avc",mb="hevc";class gb{static FREQ=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];static getFrameDuration(e){return 1024*(arguments.length>1&&void 0!==arguments[1]?arguments[1]:9e4)/e}static getRateIndexByRate(e){return gb.FREQ.indexOf(e)}}function yb(e,t,i,s,r,a){const o=[],n=r?.entries,l=t.entries,d=s.entries,h=i.entrySizes,c=a?.entries;let u,p,f;c&&(u={},c.forEach((e=>{u[e-1]=!0}))),n&&(p=[],n.forEach((e=>{let{count:t,offset:i}=e;for(let e=0;e<t;e++)p.push(i)})));let m=-1,g=0,y=0,A=0,b=0,_=0,v=l[0].samplesPerChunk,S=l[1]?l[1].firstChunk-1:1/0;return e.entries.forEach((e=>{let{count:t,delta:s}=e;for(let e=0;e<t;e++)f={dts:g,duration:s,size:h[y]||i.sampleSize,offset:d[A]+_,index:y},c&&(f.keyframe=u[y],f.keyframe&&m++,f.gopId=m),p&&y<p.length&&(f.pts=f.dts+p[y]),o.push(f),g+=s,y++,y<v?_+=f.size:(A++,_=0,A>=S&&(b++,S=l[b+1]?l[b+1].firstChunk-1:1/0),v+=l[b].samplesPerChunk)})),o}function Ab(e,t){return e.dataReferenceIndex=lb(t,6),e.width=lb(t,24),e.height=lb(t,26),e.horizresolution=db(t,28),e.vertresolution=db(t,32),e.frameCount=lb(t,40),e.depth=lb(t,74),78}function bb(e,t){return e.dataReferenceIndex=lb(t,6),e.channelCount=lb(t,16),e.sampleSize=lb(t,18),e.sampleRate=db(t,24)/65536,28}function _b(e,t,i){if(!e)return;if(e.size!==e.data.length)throw new Error(`box ${e.type} size !== data.length`);const s={start:e.start,size:e.size,headerSize:e.headerSize,type:e.type};return t&&(s.version=e.data[e.headerSize],s.flags=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return(e[t]<<16)+(e[t+1]<<8)+(e[t+2]||0)}(e.data,e.headerSize+1),s.headerSize+=4),i(s,e.data.subarray(s.headerSize),s.start+s.headerSize),s}const vb=function(){const e=[];for(var t=arguments.length,i=new Array(t),s=0;s<t;s++)i[s]=arguments[s];return i.forEach((t=>{e.push(function(e,t,i){const s=String(i),r=0|t;let a=Math.ceil(r/s.length);const o=[],n=String(e);for(;a--;)o.push(s);return o.join("").substring(0,r-n.length)+n}(Number(t).toString(16),2,0))})),e[0]};class Sb{static probe(e){return!!Sb.findBox(e,["ftyp"])}static findBox(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;const s=[];if(!e)return s;let r=0,a="",o=0;for(;e.length>7;){if(r=db(e),a=String.fromCharCode.apply(null,e.subarray(4,8)),o=8,1===r?(r=hb(e,8),o+=8):r||(r=e.length),!t[0]||a===t[0]){const n=e.subarray(0,r);if(!(t.length<2))return Sb.findBox(n.subarray(o),t.slice(1),i+o);s.push({start:i,size:r,headerSize:o,type:a,data:n})}i+=r,e=e.subarray(r)}return s}static tfhd(e){return _b(e,!0,((e,t)=>{e.trackId=db(t);let i=4;const s=1&e.flags,r=2&e.flags,a=8&e.flags,o=16&e.flags,n=32&e.flags;s&&(i+=4,e.baseDataOffset=db(t,i),i+=4),r&&(e.sampleDescriptionIndex=db(t,i),i+=4),a&&(e.defaultSampleDuration=db(t,i),i+=4),o&&(e.defaultSampleSize=db(t,i),i+=4),n&&(e.defaultSampleFlags=db(t,i))}))}static sidx(e){return _b(e,!0,((e,t)=>{let i=0;e.reference_ID=db(t,i),i+=4,e.timescale=db(t,i),i+=4,0===e.version?(e.earliest_presentation_time=db(t,i),i+=4,e.first_offset=db(t,i),i+=4):(e.earliest_presentation_time=hb(t,i),i+=8,e.first_offset=hb(t,i),i+=8),i+=2,e.references=[];const s=lb(t,i);i+=2;for(let r=0;r<s;r++){const s={};e.references.push(s);let r=db(t,i);i+=4,s.reference_type=r>>31&1,s.referenced_size=2147483647&r,s.subsegment_duration=db(t,i),i+=4,r=db(t,i),i+=4,s.starts_with_SAP=r>>31&1,s.SAP_type=r>>28&7,s.SAP_delta_time=268435455&r}}))}static moov(e){return _b(e,!1,((e,t,i)=>{e.mvhd=Sb.mvhd(Sb.findBox(t,["mvhd"],i)[0]),e.trak=Sb.findBox(t,["trak"],i).map((e=>Sb.trak(e))),e.pssh=Sb.pssh(Sb.findBox(t,["pssh"],i)[0])}))}static mvhd(e){return _b(e,!0,((e,t)=>{let i=0;1===e.version?(e.timescale=db(t,16),e.duration=hb(t,20),i+=28):(e.timescale=db(t,8),e.duration=db(t,12),i+=16),e.nextTrackId=db(t,i+76)}))}static trak(e){return _b(e,!1,((e,t,i)=>{e.tkhd=Sb.tkhd(Sb.findBox(t,["tkhd"],i)[0]),e.mdia=Sb.mdia(Sb.findBox(t,["mdia"],i)[0])}))}static tkhd(e){return _b(e,!0,((e,t)=>{let i=0;1===e.version?(e.trackId=db(t,16),e.duration=hb(t,24),i+=32):(e.trackId=db(t,8),e.duration=db(t,16),i+=20),e.width=db(t,i+52),e.height=db(t,i+56)}))}static mdia(e){return _b(e,!1,((e,t,i)=>{e.mdhd=Sb.mdhd(Sb.findBox(t,["mdhd"],i)[0]),e.hdlr=Sb.hdlr(Sb.findBox(t,["hdlr"],i)[0]),e.minf=Sb.minf(Sb.findBox(t,["minf"],i)[0])}))}static mdhd(e){return _b(e,!0,((e,t)=>{let i=0;1===e.version?(e.timescale=db(t,16),e.duration=hb(t,20),i+=28):(e.timescale=db(t,8),e.duration=db(t,12),i+=16);const s=lb(t,i);e.language=String.fromCharCode(96+(s>>10&31),96+(s>>5&31),96+(31&s))}))}static hdlr(e){return _b(e,!0,((e,t)=>{0===e.version&&(e.handlerType=String.fromCharCode.apply(null,t.subarray(4,8)))}))}static minf(e){return _b(e,!1,((e,t,i)=>{e.vmhd=Sb.vmhd(Sb.findBox(t,["vmhd"],i)[0]),e.smhd=Sb.smhd(Sb.findBox(t,["smhd"],i)[0]),e.stbl=Sb.stbl(Sb.findBox(t,["stbl"],i)[0])}))}static vmhd(e){return _b(e,!0,((e,t)=>{e.graphicsmode=lb(t),e.opcolor=[lb(t,2),lb(t,4),lb(t,6)]}))}static smhd(e){return _b(e,!0,((e,t)=>{e.balance=lb(t)}))}static stbl(e){return _b(e,!1,((e,t,i)=>{e.stsd=Sb.stsd(Sb.findBox(t,["stsd"],i)[0]),e.stts=Sb.stts(Sb.findBox(t,["stts"],i)[0]),e.ctts=Sb.ctts(Sb.findBox(t,["ctts"],i)[0]),e.stsc=Sb.stsc(Sb.findBox(t,["stsc"],i)[0]),e.stsz=Sb.stsz(Sb.findBox(t,["stsz"],i)[0]),e.stco=Sb.stco(Sb.findBox(t,["stco"],i)[0]),e.stco||(e.co64=Sb.co64(Sb.findBox(t,["co64"],i)[0]),e.stco=e.co64);const s=e.stsd.entries[0]?.sinf?.schi?.tenc.default_IV_size;e.stss=Sb.stss(Sb.findBox(t,["stss"],i)[0]),e.senc=Sb.senc(Sb.findBox(t,["senc"],i)[0],s)}))}static senc(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:8;return _b(e,!0,((e,i)=>{let s=0;const r=db(i,s);s+=4,e.samples=[];for(let a=0;a<r;a++){const r={InitializationVector:[]};for(let e=0;e<t;e++)r.InitializationVector[e]=i[s+e];if(s+=t,2&e.flags){r.subsamples=[];const e=lb(i,s);s+=2;for(let t=0;t<e;t++){const e={};e.BytesOfClearData=lb(i,s),s+=2,e.BytesOfProtectedData=db(i,s),s+=4,r.subsamples.push(e)}}e.samples.push(r)}}))}static pssh(e){return _b(e,!0,((e,t)=>{const i=[],s=[];let r=0;for(let e=0;e<16;e++)s.push(vb(t[r+e]));if(r+=16,e.version>0){const e=db(t,r);r+=4;for(let s=0;s<(""+e).length;s++)for(let e=0;e<16;e++){const e=t[r];r+=1,i.push(vb(e))}}const a=db(t,r);e.data_size=a,r+=4,e.kid=i,e.system_id=s,e.buffer=t}))}static stsd(e){return _b(e,!0,((e,t,i)=>{e.entryCount=db(t),e.entries=Sb.findBox(t.subarray(4),[],i+4).map((e=>{switch(e.type){case"avc1":case"avc2":case"avc3":case"avc4":return Sb.avc1(e);case"hvc1":case"hev1":return Sb.hvc1(e);case"mp4a":return Sb.mp4a(e);case"alaw":case"ulaw":return Sb.alaw(e);case"enca":return _b(e,!1,((e,t,i)=>{e.channelCount=lb(t,16),e.samplesize=lb(t,18),e.sampleRate=db(t,24)/65536,t=t.subarray(28),e.sinf=Sb.sinf(Sb.findBox(t,["sinf"],i)[0]),e.esds=Sb.esds(Sb.findBox(t,["esds"],i)[0])}));case"encv":return _b(e,!1,((e,t,i)=>{e.width=lb(t,24),e.height=lb(t,26),e.horizresolution=db(t,28),e.vertresolution=db(t,32),t=t.subarray(78),e.sinf=Sb.sinf(Sb.findBox(t,["sinf"],i)[0]),e.avcC=Sb.avcC(Sb.findBox(t,["avcC"],i)[0]),e.hvcC=Sb.hvcC(Sb.findBox(t,["hvcC"],i)[0]),e.pasp=Sb.pasp(Sb.findBox(t,["pasp"],i)[0])}))}})).filter(Boolean)}))}static tenc(e){return _b(e,!1,((e,t)=>{let i=6;e.default_IsEncrypted=t[i],i+=1,e.default_IV_size=t[i],i+=1,e.default_KID=[];for(let s=0;s<16;s++)e.default_KID.push(vb(t[i])),i+=1}))}static schi(e){return _b(e,!1,((e,t,i)=>{e.tenc=Sb.tenc(Sb.findBox(t,["tenc"],i)[0])}))}static sinf(e){return _b(e,!1,((e,t,i)=>{e.schi=Sb.schi(Sb.findBox(t,["schi"],i)[0]),e.frma=Sb.frma(Sb.findBox(t,["frma"],i)[0])}))}static frma(e){return _b(e,!1,((e,t)=>{e.data_format="";for(let i=0;i<4;i++)e.data_format+=String.fromCharCode(t[i])}))}static avc1(e){return _b(e,!1,((e,t,i)=>{const s=Ab(e,t),r=t.subarray(s);i+=s,e.avcC=Sb.avcC(Sb.findBox(r,["avcC"],i)[0]),e.pasp=Sb.pasp(Sb.findBox(r,["pasp"],i)[0])}))}static avcC(e){return _b(e,!1,((e,t)=>{e.configurationVersion=t[0],e.AVCProfileIndication=t[1],e.profileCompatibility=t[2],e.AVCLevelIndication=t[3],e.codec=function(e){let t,i="avc1.";for(let s=0;s<3;s++)t=e[s].toString(16),t.length<2&&(t=`0${t}`),i+=t;return i}([t[1],t[2],t[3]]),e.lengthSizeMinusOne=3&t[4],e.spsLength=31&t[5],e.sps=[];let i=6;for(let s=0;s<e.spsLength;s++){const s=lb(t,i);i+=2,e.sps.push(t.subarray(i,i+s)),i+=s}e.ppsLength=t[i],i+=1,e.pps=[];for(let s=0;s<e.ppsLength;s++){const s=lb(t,i);i+=2,e.pps.push(t.subarray(i,i+=s)),i+=s}}))}static hvc1(e){return _b(e,!1,((e,t,i)=>{const s=Ab(e,t),r=t.subarray(s);i+=s,e.hvcC=Sb.hvcC(Sb.findBox(r,["hvcC"],i)[0]),e.pasp=Sb.pasp(Sb.findBox(r,["pasp"],i)[0])}))}static hvcC(e){return _b(e,!1,((t,i)=>{t.data=e.data,t.codec="hev1.1.6.L93.B0",t.configurationVersion=i[0];const s=i[1];t.generalProfileSpace=s>>6,t.generalTierFlag=(32&s)>>5,t.generalProfileIdc=31&s,t.generalProfileCompatibility=db(i,2),t.generalConstraintIndicatorFlags=i.subarray(6,12),t.generalLevelIdc=i[12],t.avgFrameRate=lb(i,19),t.numOfArrays=i[22],t.vps=[],t.sps=[],t.pps=[];let r=23,a=0,o=0,n=0;for(let e=0;e<t.numOfArrays;e++){a=63&i[r],o=lb(i,r+1),r+=3;const e=[];for(let t=0;t<o;t++)n=lb(i,r),r+=2,e.push(i.subarray(r,r+n)),r+=n;32===a?t.vps.push(...e):33===a?t.sps.push(...e):34===a&&t.pps.push(...e)}}))}static pasp(e){return _b(e,!1,((e,t)=>{e.hSpacing=db(t),e.vSpacing=db(t,4)}))}static mp4a(e){return _b(e,!1,((e,t,i)=>{const s=bb(e,t);e.esds=Sb.esds(Sb.findBox(t.subarray(s),["esds"],i+s)[0])}))}static esds(e){return _b(e,!0,((e,t)=>{e.codec="mp4a.";let i=0,s=0,r=0,a=0;for(;t.length;){for(i=0,a=t[i],s=t[i+1],i+=2;128&s;)r=(127&s)<<7,s=t[i],i+=1;if(r+=127&s,3===a)t=t.subarray(i+3);else{if(4!==a){if(5===a){const s=e.config=t.subarray(i,i+r);let a=(248&s[0])>>3;return 31===a&&s.length>=2&&(a=32+((7&s[0])<<3)+((224&s[1])>>5)),e.objectType=a,e.codec+=a.toString(16),void("."===e.codec[e.codec.length-1]&&(e.codec=e.codec.substring(0,e.codec.length-1)))}return void("."===e.codec[e.codec.length-1]&&(e.codec=e.codec.substring(0,e.codec.length-1)))}e.codec+=(t[i].toString(16)+".").padStart(3,"0"),t=t.subarray(i+13)}}}))}static alaw(e){return _b(e,!1,((e,t)=>{bb(e,t)}))}static stts(e){return _b(e,!0,((e,t)=>{const i=db(t),s=[];let r=4;for(let e=0;e<i;e++)s.push({count:db(t,r),delta:db(t,r+4)}),r+=8;e.entryCount=i,e.entries=s}))}static ctts(e){return _b(e,!0,((e,t)=>{const i=db(t),s=[];let r=4;if(1===e.version)for(let e=0;e<i;e++)s.push({count:db(t,r),offset:db(t,r+4)}),r+=8;else for(let e=0;e<i;e++)s.push({count:db(t,r),offset:-(1+~db(t,r+4))}),r+=8;e.entryCount=i,e.entries=s}))}static stsc(e){return _b(e,!0,((e,t)=>{const i=db(t),s=[];let r=4;for(let e=0;e<i;e++)s.push({firstChunk:db(t,r),samplesPerChunk:db(t,r+4),sampleDescriptionIndex:db(t,r+8)}),r+=12;e.entryCount=i,e.entries=s}))}static stsz(e){return _b(e,!0,((e,t)=>{const i=db(t),s=db(t,4),r=[];if(!i){let e=8;for(let i=0;i<s;i++)r.push(db(t,e)),e+=4}e.sampleSize=i,e.sampleCount=s,e.entrySizes=r}))}static stco(e){return _b(e,!0,((e,t)=>{const i=db(t),s=[];let r=4;for(let e=0;e<i;e++)s.push(db(t,r)),r+=4;e.entryCount=i,e.entries=s}))}static co64(e){return _b(e,!0,((e,t)=>{const i=db(t),s=[];let r=4;for(let e=0;e<i;e++)s.push(hb(t,r)),r+=8;e.entryCount=i,e.entries=s}))}static stss(e){return _b(e,!0,((e,t)=>{const i=db(t),s=[];let r=4;for(let e=0;e<i;e++)s.push(db(t,r)),r+=4;e.entryCount=i,e.entries=s}))}static moof(e){return _b(e,!1,((e,t,i)=>{e.mfhd=Sb.mfhd(Sb.findBox(t,["mfhd"],i)[0]),e.traf=Sb.findBox(t,["traf"],i).map((e=>Sb.traf(e)))}))}static mfhd(e){return _b(e,!0,((e,t)=>{e.sequenceNumber=db(t)}))}static traf(e){return _b(e,!1,((e,t,i)=>{e.tfhd=Sb.tfhd(Sb.findBox(t,["tfhd"],i)[0]),e.tfdt=Sb.tfdt(Sb.findBox(t,["tfdt"],i)[0]),e.trun=Sb.trun(Sb.findBox(t,["trun"],i)[0])}))}static trun(e){return _b(e,!0,((e,t)=>{const{version:i,flags:s}=e,r=t.length,a=e.sampleCount=db(t);let o=4;if(r>o&&1&s&&(e.dataOffset=-(1+~db(t,o)),o+=4),r>o&&4&s&&(e.firstSampleFlags=db(t,o),o+=4),e.samples=[],r>o){let r;for(let n=0;n<a;n++)r={},256&s&&(r.duration=db(t,o),o+=4),512&s&&(r.size=db(t,o),o+=4),1024&s&&(r.flags=db(t,o),o+=4),2048&s&&(r.cts=i?-(1+~db(t,o+4)):db(t,o),o+=4),e.samples.push(r)}}))}static tfdt(e){return _b(e,!0,((e,t)=>{1===e.version?e.baseMediaDecodeTime=hb(t):e.baseMediaDecodeTime=db(t)}))}static probe(e){return!!Sb.findBox(e,["ftyp"])}static parseSampleFlags(e){return{isLeading:(12&e[0])>>>2,dependsOn:3&e[0],isDependedOn:(192&e[1])>>>6,hasRedundancy:(48&e[1])>>>4,paddingValue:(14&e[1])>>>1,isNonSyncSample:1&e[1],degradationPriority:e[2]<<8|e[3]}}static moovToTrack(e,t,i){const s=e.trak;if(!s||!s.length)return;const r=s.find((e=>"vide"===e.mdia?.hdlr?.handlerType)),a=s.find((e=>"soun"===e.mdia?.hdlr?.handlerType));if(r&&t){const i=t,s=r.tkhd?.trackId;null!=s&&(i.id=r.tkhd.trackId),i.tkhdDuration=r.tkhd.duration,i.mvhdDurtion=e.mvhd.duration,i.mvhdTimecale=e.mvhd.timescale,i.timescale=i.formatTimescale=r.mdia.mdhd.timescale,i.duration=r.mdia.mdhd.duration||i.mvhdDurtion/i.mvhdTimecale*i.timescale;const a=r.mdia.minf.stbl.stsd.entries[0];if(i.width=a.width,i.height=a.height,a.pasp&&(i.sarRatio=[a.pasp.hSpacing,a.pasp.vSpacing]),a.hvcC)i.codecType=mb,i.codec=a.hvcC.codec,i.vps=a.hvcC.vps,i.sps=a.hvcC.sps,i.pps=a.hvcC.pps,i.hvcC=a.hvcC.data;else{if(!a.avcC)throw new Error("unknown video stsd entry");i.codecType=fb,i.codec=a.avcC.codec,i.sps=a.avcC.sps,i.pps=a.avcC.pps}i.present=!0,i.ext={},i.ext.stss=r.mdia?.minf?.stbl?.stss,i.ext.ctts=r.mdia?.minf?.stbl?.ctts,a&&"encv"===a.type&&(i.isVideoEncryption=!0,a.default_KID=a.sinf?.schi?.tenc.default_KID,a.default_IsEncrypted=a.sinf?.schi?.tenc.default_IsEncrypted,a.default_IV_size=a.sinf?.schi?.tenc.default_IV_size,i.videoSenc=r.mdia.minf.stbl.senc&&r.mdia.minf.stbl.senc.samples,a.data_format=a.sinf?.frma?.data_format,i.useEME=e.useEME,i.kidValue=e.kidValue,i.pssh=e.pssh,i.encv=a)}if(a&&i){const t=i,s=a.tkhd?.trackId;null!=s&&(t.id=a.tkhd.trackId),t.tkhdDuration=a.tkhd.duration,t.mvhdDurtion=e.mvhd.duration,t.mvhdTimecale=e.mvhd.timescale,t.timescale=t.formatTimescale=a.mdia.mdhd.timescale,t.duration=a.mdia.mdhd.duration||t.mvhdDurtion/t.mvhdTimecale*t.timescale;const r=a.mdia.minf.stbl.stsd.entries[0];switch(t.sampleSize=r.sampleSize,t.sampleRate=r.sampleRate,t.channelCount=r.channelCount,t.present=!0,r.type){case"alaw":t.codecType=t.codec=ub,t.sampleRate=8e3;break;case"ulaw":t.codecType=t.codec=pb,t.sampleRate=8e3;break;default:t.codecType=cb,t.sampleDuration=gb.getFrameDuration(t.sampleRate,t.timescale),t.sampleRateIndex=gb.getRateIndexByRate(t.sampleRate),t.objectType=r.esds?.objectType||2,r.esds&&(t.config=Array.from(r.esds.config)),t.codec=r.esds?.codec||"mp4a.40.2"}t.sampleDuration=gb.getFrameDuration(t.sampleRate,t.timescale),t.objectType=r.esds?.objectType||2,r.esds&&(r.esds.config?t.config=Array.from(r.esds.config):console.warn("esds config is null")),t.codec=r.esds?.codec||"mp4a.40.2",t.sampleRateIndex=gb.getRateIndexByRate(t.sampleRate),t.ext={},t.ext.stss=a.mdia?.minf?.stbl?.stss,t.ext.ctts=a.mdia?.minf?.stbl?.ctts,t.present=!0,r&&"enca"===r.type&&(t.isAudioEncryption=!0,r.data_format=r.sinf?.frma?.data_format,r.default_KID=r.sinf?.schi?.tenc.default_KID,r.default_IsEncrypted=r.sinf?.schi?.tenc.default_IsEncrypted,r.default_IV_size=r.sinf?.schi?.tenc.default_IV_size,t.audioSenc=a.mdia.minf.stbl.senc&&a.mdia.minf.stbl.senc.samples,t.useEME=e.useEME,t.kidValue=e.kidValue,t.enca=r)}if(i&&(i.isVideoEncryption=!!t&&t.isVideoEncryption),t&&(t.isAudioEncryption=!!i&&i.isAudioEncryption),t?.encv||i?.enca){const e=t?.encv?.default_KID,s=i?.enca?.default_KID,r=e||s?(e||s).join(""):null;t&&(t.kid=r),i&&(i.kid=r)}return t&&(t.flags=3841),i&&(i.flags=1793),{videoTrack:t,audioTrack:i}}static evaluateDefaultDuration(e,t,i){const s=t?.samples?.length;if(!s)return 1024;return 1024*s/t.timescale*e.timescale/i}static moofToSamples(e,t,i){const s={};return e.mfhd&&(t&&(t.sequenceNumber=e.mfhd.sequenceNumber),i&&(i.sequenceNumber=e.mfhd.sequenceNumber)),e.traf.forEach((e=>{let{tfhd:r,tfdt:a,trun:o}=e;if(!r||!o)return;a&&(t&&t.id===r.trackId&&(t.baseMediaDecodeTime=a.baseMediaDecodeTime),i&&i.id===r.trackId&&(i.baseMediaDecodeTime=a.baseMediaDecodeTime));const n=r.defaultSampleSize||0,l=r.defaultSampleDuration||Sb.evaluateDefaultDuration(t,i,o.samples.length||o.sampleCount);let d=o.dataOffset||0,h=0,c=-1;if(!o.samples.length&&o.sampleCount){s[r.trackId]=[];for(let e=0;e<o.sampleCount;e++)s[r.trackId].push({offset:d,dts:h,duration:l,size:n}),h+=l,d+=n}else s[r.trackId]=o.samples.map(((e,t)=>((e={offset:d,dts:h,pts:h+(e.cts||0),duration:e.duration||l,size:e.size||n,gopId:c,keyframe:0===t||null!==e.flags&&void 0!==e.flags&&(65536&e.flags)>>>0!=65536}).keyframe&&(c++,e.gopId=c),h+=e.duration,d+=e.size,e)))})),s}static moovToSamples(e){const t=e.trak;if(!t||!t.length)return;const i=t.find((e=>"vide"===e.mdia?.hdlr?.handlerType)),s=t.find((e=>"soun"===e.mdia?.hdlr?.handlerType));if(!i&&!s)return;let r,a;if(i){const e=i.mdia?.minf?.stbl;if(!e)return;const{stts:t,stsc:s,stsz:a,stco:o,stss:n,ctts:l}=e;if(!(t&&s&&a&&o&&n))return;r=yb(t,s,a,o,l,n)}if(s){const e=s.mdia?.minf?.stbl;if(!e)return;const t=s.mdia.mdhd?.timescale,{stts:i,stsc:r,stsz:o,stco:n}=e;if(!(t&&i&&r&&o&&n))return;a=yb(i,r,o,n)}return{videoSamples:r,audioSamples:a}}}class wb extends gd{constructor(e){super(e),this.player=e,this.TAG_NAME="HlsFmp4Loader",this.tempSampleListInfo={},this.isInitVideo=!1,this.isInitAudio=!1,this.videoTrack={id:1,samples:[],sps:[],pps:[],vps:[],codec:""},this.audioTrack={id:2,samples:[],sampleRate:0,channelCount:0,codec:"",codecType:""},this.workerClearTimeout=null,this.workerUrl=null,this.loopWorker=null,this._hasCalcFps=!1,this._basefps=25,this.player.isUseMSE()||this._initLoopWorker(),e.debug.log(this.TAG_NAME,"init")}destroy(){super.destroy(),this.workerUrl&&(URL.revokeObjectURL(this.workerUrl),this.workerUrl=null),this.workerClearTimeout&&(clearTimeout(this.workerClearTimeout),this.workerClearTimeout=null),this.loopWorker&&(this.loopWorker.postMessage({cmd:"destroy"}),this.loopWorker.terminate(),this.loopWorker=null),this._hasCalcFps=!1,this.videoTrack=null,this.audioTrack=null,this.isInitVideo=!1,this.isInitAudio=!1,this._basefps=25,this.player.debug.log(this.TAG_NAME,"destroy")}demux(e,t){let i=this.audioTrack,s=this.videoTrack;if(this.checkInitAudio(),this.checkInitVideo(),i.samples=[],s.samples=[],t){if(this.player.updateStats({abps:t.byteLength}),ro(this.isInitAudio)){const e=Sb.findBox(t,["moov"])[0];if(!e)return void this.player.debug.error(this.TAG_NAME,"cannot found moov box");Sb.moovToTrack(Sb.moov(e),null,i),this.checkInitAudio()&&(this.player.debug.log(this.TAG_NAME,"audioData audio init success"),this._sendAccADTSHeader(i))}const e=Sb.findBox(t,["moof"])[0];if(e){const s=Sb.moofToSamples(Sb.moof(e),null,i)[i.id],r=i.baseMediaDecodeTime;if(s){const a=e.start;s.map((e=>{e.offset+=a;const s=t.subarray(e.offset,e.offset+e.size),o=e.dts+r,n=new Uint8Array(s.length+2);n.set([175,1],0),n.set(s,2),i.samples.push({type:Ne,pts:o,dts:o,payload:n,duration:e.duration,size:n.byteLength})}))}}}if(e){if(this.player.updateStats({vbps:e.byteLength}),ro(this.isInitVideo)&&ro(this.isInitAudio)){const t=Sb.findBox(e,["moov"])[0];if(!t)throw new Error("cannot found moov box");if(Sb.moovToTrack(Sb.moov(t),s,i),ro(this.isInitAudio)&&this.checkInitAudio()&&(this.player.debug.log(this.TAG_NAME,"videoData audio init success",i),this._sendAccADTSHeader(i)),this.checkInitVideo()){this.player.debug.log(this.TAG_NAME,"video init success");let e=null;s.codecType===Qi?s.sps.length&&s.vps.length&&s.pps.length&&(e=Dn({sps:s.sps[0],pps:s.pps[0],vps:s.vps[0]})):s.sps.length&&s.pps.length&&(e=gn({sps:s.sps[0],pps:s.pps[0]})),e&&(this.player.debug.log(this.TAG_NAME,"seqHeader"),this._doDecodeByHls(e,je,0,!0,0))}}const t=Sb.findBox(e,["moof"])[0];if(t){const r=Sb.moofToSamples(Sb.moof(t),s,i),a=s.baseMediaDecodeTime,o=i.baseMediaDecodeTime,n=t.start;Object.keys(r).forEach((t=>{s.id==t?r[t].map((t=>{t.offset+=n;const i={type:je,pts:(t.pts||t.dts)+a,dts:t.dts+a,units:[],payload:null,isIFrame:!1};i.duration=t.duration,i.gopId=t.gopId,t.keyframe&&(i.isIFrame=!0);const r=e.subarray(t.offset,t.offset+t.size);i.payload=r,s.samples.push(i)})):i.id==t&&r[t].map((t=>{t.offset+=n;const s=e.subarray(t.offset,t.offset+t.size),r=t.dts+o,a=new Uint8Array(s.length+2);a.set([175,1],0),a.set(s,2),i.samples.push({type:Ne,pts:r,dts:r,payload:a,duration:t.duration,size:a.byteLength})}))}))}}const r=s.samples.concat(i.samples);r.sort(((e,t)=>e.dts-t.dts)),r.forEach((e=>{const t=new Uint8Array(e.payload);delete e.payload,this.player.isUseMSE()?e.type===je?this._doDecodeVideo({...e,payload:t}):e.type===Ne&&this._doDecodeAudio({...e,payload:t}):this.loopWorker.postMessage({...e,payload:t,cmd:"sample"},[t.buffer])})),ro(this._hasCalcFps)&&(this._hasCalcFps=!0,this._calcDecodeFps(r))}checkInitAudio(){return this.isInitAudio=!!(this.audioTrack.sampleRate&&this.audioTrack.channelCount&&this.audioTrack.codec&&"aac"===this.audioTrack.codecType),this.isInitAudio}checkInitVideo(){return this.isInitVideo=!!(this.videoTrack.pps.length&&this.videoTrack.sps.length&&this.videoTrack.codec),this.isInitVideo}_sendAccADTSHeader(e){const t=Pr({profile:e.objectType,sampleRate:e.sampleRateIndex,channel:e.channelCount});this._doDecodeByHls(t,Ne,0,!0,0)}_calcDecodeFps(e){const t=Ya(e.map((e=>({ts:e.dts||e.pts,type:e.type}))),je);t&&(this.player.debug.log(this.TAG_NAME,`_calcDecodeFps() video fps is ${t}, update base fps is ${this._basefps}`),this._basefps=t),this._postMessageToLoopWorker("updateBaseFps",{baseFps:this._basefps})}_initLoopWorker(){this.player.debug.log(this.TAG_NAME,"_initLoopWorker()");const e=lo(function(){const e=1,t=2;let i=new class{constructor(){this.baseFps=0,this.fpsInterval=null,this.preLoopTimestamp=null,this.startBpsTime=null,this.allSampleList=[]}destroy(){this._clearInterval(),this.baseFps=0,this.allSampleList=[],this.preLoopTimestamp=null,this.startBpsTime=null}updateBaseFps(e){this.baseFps=e,this._clearInterval(),this._startInterval()}pushSample(e){delete e.cmd,this.allSampleList.push(e)}_startInterval(){const e=Math.ceil(1e3/this.baseFps);this.fpsInterval=setInterval((()=>{let t=(new Date).getTime();this.preLoopTimestamp||(this.preLoopTimestamp=t),this.startBpsTime||(this.startBpsTime=t);const i=t-this.preLoopTimestamp;if(i>2*e&&console.warn(`JbPro:[HlsFmp4Loader LoopWorker] loop interval is ${i}ms, more than ${e} * 2ms`),this._loop(),this.preLoopTimestamp=(new Date).getTime(),this.startBpsTime){t-this.startBpsTime>=1e3&&(this._calcSampleList(),this.startBpsTime=t)}}),e)}_clearInterval(){this.fpsInterval&&(clearInterval(this.fpsInterval),this.fpsInterval=null)}_calcSampleList(){const i={buferredDuration:0,allListLength:this.allSampleList.length,audioListLength:0,videoListLength:0};this.allSampleList.forEach((s=>{s.type===t?(i.videoListLength++,s.duration&&(i.buferredDuration+=s.duration)):s.type===e&&i.audioListLength++})),postMessage({cmd:"sampleListInfo",...i})}_loop(){let i=null;if(this.allSampleList.length)if(i=this.allSampleList.shift(),i.type===t){postMessage({cmd:"decodeVideo",...i},[i.payload.buffer]);let t=this.allSampleList[0];for(;t&&t.type===e;)i=this.allSampleList.shift(),postMessage({cmd:"decodeAudio",...i},[i.payload.buffer]),t=this.allSampleList[0]}else i.type===e&&(postMessage({cmd:"decodeAudio",...i},[i.payload.buffer]),this.allSampleList.length&&this.allSampleList[0].type===t&&(i=this.allSampleList.shift(),postMessage({cmd:"decodeVideo",...i},[i.payload.buffer])))}};self.onmessage=e=>{const t=e.data;switch(t.cmd){case"updateBaseFps":i.updateBaseFps(t.baseFps);break;case"sample":i.pushSample(t);break;case"destroy":i.destroy(),i=null}}}.toString()),t=new Blob([e],{type:"text/javascript"}),i=URL.createObjectURL(t);let s=new Worker(i);this.workerUrl=i,this.workerClearTimeout=setTimeout((()=>{window.URL.revokeObjectURL(this.workerUrl),this.workerUrl=null,this.workerClearTimeout=null}),te),s.onmessage=e=>{const t=e.data;switch(t.cmd){case"decodeVideo":this._doDecodeVideo(t);break;case"decodeAudio":this._doDecodeAudio(t);break;case"sampleListInfo":this.tempSampleListInfo=t}},this.loopWorker=s}_postMessageToLoopWorker(e,t){this.player.isUseMSE()||(this.loopWorker?this.loopWorker.postMessage({cmd:e,...t}):this.player.debug.warn(this.TAG_NAME,"loop worker is not init, can not post message"))}_doDecodeAudio(e){const t=new Uint8Array(e.payload);this._doDecodeByHls(t,Ne,e.dts,!1,0)}_doDecodeVideo(e){const t=new Uint8Array(e.payload);let i=null;i=e.isHevc?Ln(t,e.isIFrame):yn(t,e.isIFrame),this.player.updateStats({dts:e.dts});const s=e.pts-e.dts;this._doDecodeByHls(i,je,e.dts,e.isIFrame,s)}getBuferredDuration(){return this.tempSampleListInfo.buferredDuration||0}getSampleListLength(){return this.tempSampleListInfo.allListLength||0}getSampleAudioListLength(){return this.tempSampleListInfo.audioListLength||0}getSampleVideoListLength(){return this.tempSampleListInfo.videoListLength||0}}class Eb{constructor(e,t){this.hls=e,this.player=this.hls.player,this.isMP4=t,this._initSegmentId="",this.TAG_NAME="HlsTransmuxer",this._demuxer=t?new wb(this.hls.player):new nb(this.hls.player),this.player.debug.log(this.TAG_NAME,`init and isMP4 is ${t}`)}destroy(){this._demuxer&&(this._demuxer.destroy(),this._demuxer=null)}transmux(e,t,i,s,r,a){this.player.debug.log(this.TAG_NAME,`transmux videoChunk:${e&&e.byteLength}, audioChunk:${t&&t.byteLength}, discontinuity:${i}, contiguous:${s}, startTime:${r}, needInit:${a}`);const o=this._demuxer;try{this.isMP4?o.demux(e,t):o.demuxAndFix(Bd(e,t),i,s,r)}catch(e){throw new IA(BA,PA,e)}}}class Tb{constructor(e){this.hls=e,this.player=e.player,this._decryptor=new ob(this.hls,this.player),this._transmuxer=null,this._mse=null,this._softVideo=null,this._sourceCreated=!1,this._needInitSegment=!0,this._directAppend=!1,this.TAG_NAME="HlsBufferService"}async destroy(){this._softVideo=null,this._transmuxer&&(this._transmuxer.destroy(),this._transmuxer=null)}get baseDts(){return this._transmuxer?._demuxer?._baseDts}get nbSb(){return 0}async updateDuration(e){this.player.debug.log(this.TAG_NAME,"updateDuration()",e)}getBuferredDuration(){return this._transmuxer?._demuxer?.getBuferredDuration()}getBufferedSegments(){return this._transmuxer?._demuxer?.getSampleListLength()}getBufferedAudioSegments(){return this._transmuxer?._demuxer?.getSampleAudioListLength()}getBufferedVideoSegments(){return this._transmuxer?._demuxer?.getSampleVideoListLength()}createSource(e,t,i,s){if(this._sourceCreated)return;const r=e||t;r&&(nb.probe(r)?this._transmuxer||(this._transmuxer=new Eb(this.hls,!1)):Sb.probe(r)?this._transmuxer||(this._transmuxer=new Eb(this.hls,!0)):this.player.debug.error(this.TAG_NAME,"createSource error: chunk is not ts"))}async appendBuffer(e,t,i,s,r,a,o){if(i?.length||s?.length)return this._needInitSegment,this._transmuxer.transmux(i,s,r,a,o,this._needInitSegment||r),!0}async clearAllBuffer(){this.player.debug.log(this.TAG_NAME,"clearAllBuffer")}decryptBuffer(e,t){return this._decryptor.decrypt(e,t)}async reset(){this._transmuxer=null,this._needInitSegment=!0,this._directAppend=!1}async endOfStream(){this._softVideo&&this._softVideo.endOfStream()}async setLiveSeekableRange(e,t){}seamlessSwitch(){this._needInitSegment=!0}}class kb{constructor(e){this.emitter=e,this._seiSet=new Set,e.on(Vs,(e=>{e&&this._seiSet.add(e)}))}throw(e){if(null==e||!this._seiSet.size)return;const t=e-.2,i=e+.2,s=[];this._seiSet.forEach((e=>{e.time>=t&&e.time<=i&&s.push(e)})),s.forEach((e=>{this._seiSet.delete(e),this.emitter.emit(Ws,e)}))}reset(){this._seiSet.clear()}}class Cb{constructor(e){this._timescale=e,this.encodeType="",this.audioCodec="",this.videoCodec="",this.domain="",this.fps=0,this.bitrate=0,this.width=0,this.height=0,this.samplerate=0,this.channelCount=0,this.gop=0,this._bitsAccumulateSize=0,this._bitsAccumulateDuration=0}getStats(){return{encodeType:this.encodeType,audioCodec:this.audioCodec,videoCodec:this.videoCodec,domain:this.domain,fps:this.fps,bitrate:this.bitrate,width:this.width,height:this.height,samplerate:this.samplerate,channelCount:this.channelCount,gop:this.gop}}setEncodeType(e){this.encodeType=e}setFpsFromScriptData(e){let{data:t}=e;const i=t?.onMetaData?.framerate;i&&i>0&&i<100&&(this.fps=i)}setVideoMeta(e){if(this.width=e.width,this.height=e.height,this.videoCodec=e.codec,this.encodeType=e.codecType,e.fpsNum&&e.fpsDen){const t=e.fpsNum/e.fpsDen;t>0&&t<100&&(this.fps=t)}}setAudioMeta(e){this.audioCodec=e.codec,this.samplerate=e.sampleRate,this.channelCount=e.channelCount}setDomain(e){this.domain=e.split("/").slice(2,3)[0]}updateBitrate(e){if((!this.fps||this.fps>=100)&&e.length){const t=e.reduce(((e,t)=>e+t.duration),0)/e.length;this.fps=Math.round(this._timescale/t)}e.forEach((e=>{1===e.gopId&&this.gop++,this._bitsAccumulateDuration+=e.duration/(this._timescale/1e3),this._bitsAccumulateSize+=e.units.reduce(((e,t)=>e+t.length),0),this._bitsAccumulateDuration>=1e3&&(this.bitrate=8*this._bitsAccumulateSize,this._bitsAccumulateDuration=0,this._bitsAccumulateSize=0)}))}}class Rb{_core=null;_samples=[];constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3;this._core=e,this._timescale=t,this._stats=new Cb(t),this._bindEvents()}getStats(){const{currentTime:e=0,decodeFps:t=0}=this._core?.media||{};return{...this._stats.getStats(),downloadSpeed:this._core?.speedInfo?.().speed||0,avgSpeed:this._core?.speedInfo?.().avgSpeed||0,currentTime:e,bufferEnd:this._core?.bufferInfo()?.remaining||0,decodeFps:t}}_bindEvents(){this._core.on(Us,(e=>this._stats.updateBitrate(e.samples))),this._core.on(Fs,(e=>{this._stats.setFpsFromScriptData(e)})),this._core.on(Os,(e=>{"video"===e.type?this._stats.setVideoMeta(e.track):this._stats.setAudioMeta(e.track)})),this._core.on(Ns,(e=>{this._stats.setDomain(e.responseUrl)}))}reset(){this._samples=[],this._stats=new Cb(this._timescale)}}class xb extends po{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),this.player=e,this.config=null,this._manifestLoader=null,this._segmentLoader=null,this._playlist=null,this._bufferService=null,this._seiService=null,this._stats=null,this._prevSegSn=null,this._prevSegCc=null,this._tickTimer=null,this._tickInterval=500,this._segmentProcessing=!1,this._reloadOnPlay=!1,this._switchUrlOpts=null,this._disconnectTimer=null,this.TAG_NAME="Hls256",this.canVideoPlay=!1,this.$videoElement=null,this.config=t=function(e){return{isLive:!0,maxPlaylistSize:50,retryCount:3,retryDelay:1e3,pollRetryCount:2,loadTimeout:1e4,preloadTime:30,softDecode:!1,bufferBehind:10,maxJumpDistance:3,startTime:0,targetLatency:10,maxLatency:20,allowedStreamTrackChange:!0,...e}}(t),this._manifestLoader=new tb(this),this._segmentLoader=new sb(this),this._playlist=new ab(this),this._bufferService=new Tb(this),this._seiService=new kb(this),this._stats=new Rb(this,9e4),this.player.debug.log(this.TAG_NAME,"init")}async destroy(){this.player.debug.log(this.TAG_NAME,"destroy()"),this._playlist.reset(),this._segmentLoader.reset(),this._seiService.reset(),await Promise.all([this._clear(),this._bufferService.destroy()]),this._manifestLoader&&(await this._manifestLoader.destroy(),this._manifestLoader=null),this._segmentLoader&&(this._segmentLoader.destroy(),this._segmentLoader=null),this._playlist&&(this._playlist.destroy(),this._playlist=null),this.player.debug.log(this.TAG_NAME,"destroy end")}_startTick(){this._stopTick(),this._tickTimer=setTimeout((()=>{this._tick()}),this._tickInterval)}_stopTick(){this._tickTimer&&clearTimeout(this._tickTimer),this._tickTimer=null}_tick(){this.player.isDestroyedOrClosed()?this.player.debug.log(this.TAG_NAME,"_tick() player is destroyed"):(this._startTick(),this._loadSegment())}get isLive(){return this._playlist.isLive}get streams(){return this._playlist.streams}get currentStream(){return this._playlist.currentStream}get hasSubtitle(){return this._playlist.hasSubtitle}get baseDts(){return this._bufferService?.baseDts}speedInfo(){return this._segmentLoader.speedInfo()}resetBandwidth(){this._segmentLoader.resetBandwidth()}getStats(){return this._stats.getStats()}async loadSource(e){return await this._reset(),await this._loadData(e),this._startTick(),!0}async _loadData(e){try{e&&(e=e.trim())}catch(e){}if(!e)throw this._emitError(new IA(DA,DA,null,null,"m3u8 url is missing"));const t=await this._loadM3U8(e),{currentStream:i}=this._playlist;if(this._urlSwitching){0===i.bitrate&&this._switchUrlOpts?.bitrate&&(i.bitrate=this._switchUrlOpts?.bitrate);const e=this._getSeamlessSwitchPoint();this.config.startTime=e;const t=this._playlist.findSegmentIndexByTime(e),s=this._playlist.getSegmentByIndex(t+1);if(s){const e=s.start;this.player.debug.warn(this.TAG_NAME,`clear buffer from ${e}`)}}t&&(this.isLive?(this.player.debug.log(this.TAG_NAME,"is live"),this._bufferService.setLiveSeekableRange(0,4294967295),this.config.targetLatency<this._playlist.totalDuration&&(this.config.targetLatency=this._playlist.totalDuration,this.config.maxLatency=1.5*this.config.targetLatency),t.isMaster||this._pollM3U8(e)):(this.player.debug.log(this.TAG_NAME,`is vod and totalDuration is ${i.totalDuration} s`),await this._bufferService.updateDuration(i.totalDuration))),await this._loadSegment()}async _loadM3U8(e){let t;try{[t]=await this._manifestLoader.load(e)}catch(e){throw this._emitError(IA.create(e))}if(t)return this._playlist.upsertPlaylist(t),t.isMaster?(this._playlist.currentStream.subtitleStreams?.length&&this.emit(Ks,{list:this._playlist.currentStream.subtitleStreams}),await this._refreshM3U8()):this.player.debug.warn(this.TAG_NAME,"_loadM3U8() is not master playlist"),this.emit(Ys),t;this.player.debug.warn(this.TAG_NAME,"_loadM3U8() playlist is empty")}_refreshM3U8(){this.player.debug.log(this.TAG_NAME,"_refreshM3U8()");const e=this._playlist.currentStream;if(!e||!e.url)throw this._emitError(IA.create(null,null,new Error("m3u8 url is not defined")));const t=e.url,i=e.currentAudioStream?.url,s=e.currentSubtitleStream?.url;return this._manifestLoader.load(t,i,s).then((e=>{let[r,a,o]=e;r?(this._playlist.upsertPlaylist(r,a,o),this.isLive&&this._pollM3U8(t,i,s)):this.player.debug.warn(this.TAG_NAME,"_refreshM3U8() mediaPlaylist is empty")})).catch((e=>{throw this._emitError(IA.create(e))}))}_pollM3U8(e,t,i){let s=this._playlist.isEmpty;this._manifestLoader.poll(e,t,i,((e,t,i)=>{this._playlist.upsertPlaylist(e,t,i),this._playlist.clearOldSegment(),e&&s&&!this._playlist.isEmpty&&this._loadSegment(),s&&(s=this._playlist.isEmpty)}),(e=>{this._emitError(IA.create(e))}),1e3*(this._playlist.lastSegment?.duration||0))}_loadSegment=async()=>{if(this._segmentProcessing)return void this.player.debug.warn("_loadSegment()","_segmentProcessing is ture and return");if(!this._playlist)return void this.player.debug.warn("_loadSegment()","this._playlist is null and return");const e=this._playlist.currentSegment,t=this._playlist.nextSegment;if(this.player.debug.log(this.TAG_NAME,"_loadSegment()","curSeg",e&&e.url,"nextSeg",t&&t.url),t)return this._loadSegmentDirect();this.player.debug.log(this.TAG_NAME,"nextSeg is null and return")};async _loadSegmentDirect(){const e=this._playlist.nextSegment;if(!e)return void this.player.debug.log(this.TAG_NAME,"_loadSegmentDirect() !seg");let t=!1,i=null;try{this._segmentProcessing=!0,t=await this._reqAndBufferSegment(e,this._playlist.getAudioSegment(e))}catch(e){i=e}finally{this._segmentProcessing=!1}return i?this._emitError(IA.create(i)):(t?(this._urlSwitching&&(this._urlSwitching=!1,this.emit(qs,{url:this.config.url})),this._playlist.moveSegmentPointer(),this.player.debug.log(this.TAG_NAME,"_loadSegmentDirect()","seg.isLast",e.isLast),e.isLast?(this.player.debug.log(this.TAG_NAME,"_loadSegmentDirect()","seg.isLast"),this._end()):(this.player.debug.log(this.TAG_NAME,"_loadSegmentDirect()","and next _loadSegment()"),this._loadSegment())):this.player.debug.log(this.TAG_NAME,"_loadSegmentDirect() not appended"),t)}async _reqAndBufferSegment(e,t){this.player.debug.log(this.TAG_NAME,"video seg",e&&e.url,"audio seg",t&&t.url);const i=e?e.cc:t.cc,s=this._prevSegCc!==i;let r=[];try{r=await this._segmentLoader.load(e,t,s)}catch(e){throw e.fatal=!1,this._segmentLoader.error=e,e}if(!r[0])return;const a=await this._bufferService.decryptBuffer(...r);if(!a)return void this.player.debug.log(this.TAG_NAME,"decryptBuffer return null");const o=e?e.sn:t.sn,n=e?e.start:t.start,l=this._playlist.currentStream;return this._bufferService.createSource(a[0],a[1],l?.videoCodec,l?.audioCodec),await this._bufferService.appendBuffer(e,t,a[0],a[1],s,this._prevSegSn===o-1,n),this._prevSegCc=i,this._prevSegSn=o,!0}async _clear(){this.player.debug.log(this.TAG_NAME,"_clear()"),clearTimeout(this._disconnectTimer),this._stopTick(),await Promise.all([this._segmentLoader.cancel(),this._manifestLoader.stopPoll()]),this._segmentProcessing=!1}async _reset(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.player.debug.log(this.TAG_NAME,"_reset()"),this._reloadOnPlay=!1,this._prevSegSn=null,this._prevSegCc=null,this._switchUrlOpts=null,this._playlist.reset(),this._segmentLoader.reset(),this._seiService.reset(),this._stats.reset(),await this._clear(),this._bufferService.reset(e)}_end(){this.player.debug.log(this.TAG_NAME,"_end()"),this._clear()}_emitError(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return!1===e.originError?.fatal?console.warn(e):(console.table(e),console.error(e),console.error(this.media?.error),this._stopTick(),this._urlSwitching&&(this._urlSwitching=!1,this.emit(Js,e)),t&&this._end(),this._seiService.reset(),this.emit(Qs,e)),e}_getSeamlessSwitchPoint(){const{media:e}=this;let t=e.currentTime;if(!e.paused){const i=this._playlist.findSegmentIndexByTime(e.currentTime),s=this._playlist.getSegmentByIndex(i),r=this._stats?.getStats().downloadSpeed;if(r&&s){t+=s.duration*this._playlist.currentStream.bitrate/r+1}else t+=5}return t}getDemuxBuferredDuration(){return this._bufferService.getBuferredDuration()||0}getDemuxBufferedListLength(){return this._bufferService.getBufferedSegments()||0}getDemuxAudioBufferedListLength(){return this._bufferService.getBufferedAudioSegments()||0}getDemuxVideoBufferedListLength(){return this._bufferService.getBufferedVideoSegments()||0}}class Db extends po{TAG_NAME="Hls256Decoder";constructor(e){super(),this.player=e,this.$videoElement=this.player.video.$videoElement,this.hls=null,this.eventsDestroy=[],this.bandwidthEstimateInterval=null,this.hls=new xb(e),this._bindEvents()}async destroy(){return this._stopBandwidthEstimateInterval(),this.hls&&(await this.hls.destroy(),this.hls=null),this.eventsDestroy.length&&(this.eventsDestroy.forEach((e=>e())),this.eventsDestroy=[]),this.$videoElement=null,this.player.debug.log(this.TAG_NAME,"destroy"),!0}_bindEvents(){this.hls.on(Qs,(e=>{this.player.emitError(ct.hlsError,e)})),this._startBandwidthEstimateInterval()}_startBandwidthEstimateInterval(){this._stopBandwidthEstimateInterval(),this.bandwidthEstimateInterval=setInterval((()=>{const e=this.hls.speedInfo();this.player.emit(nt.kBps,(e.avgSpeed/1024/8).toFixed(2)),this.hls.resetBandwidth()}),1e3)}_stopBandwidthEstimateInterval(){this.bandwidthEstimateInterval&&(clearInterval(this.bandwidthEstimateInterval),this.bandwidthEstimateInterval=null)}async loadSource(e){return this.url=e,await this.hls.loadSource(e),!0}checkHlsBufferedDelay(){let e=0;return this.hls&&(e=this.hls.getDemuxBuferredDuration()),e}getDemuxBufferedListLength(){let e=0;return this.hls&&(e=this.hls.getDemuxBufferedListLength()),e}getDemuxAudioBufferedListLength(){let e=0;return this.hls&&(e=this.hls.getDemuxAudioBufferedListLength()),e}getDemuxVideoBufferedListLength(){let e=0;return this.hls&&(e=this.hls.getDemuxVideoBufferedListLength()),e}}class Lb extends po{constructor(e){super(),this.player=e,this.TAG_NAME="CommonWebrtc",this.rtcPeerConnection=null,this.videoStream=null,this.isDisconnected=!1,this.isH264=this.player.isWebrtcH264(),this.eventsDestroy=[],this.supportVideoFrameCallbackHandle=null,this.isInitInfo=!1,this.$videoElement=this.player.video.$videoElement,this.bandwidthEstimateInterval=null,this.rtcPeerTrackVideoReceiver=null,this.rtcPeerTrackAudioReceiver=null,this.prevWebrtcVideoStats={},this.prevWebrtcAudioStats={},this.currentWebrtcStats={},this.player._opt.webrtcUseCanvasRender&&this.isH264&&(this.$videoElement=document.createElement("video"),ha()&&(this.$videoElement.style.position="absolute"),this._initVideoEvents()),this.$videoElement.muted=!0,this._initRtcPeerConnection()}destroy(){this.isDisconnected=!1,this.isInitInfo=!1,this.prevWebrtcVideoStats={},this.currentWebrtcStats={},this.rtcPeerTrackVideoReceiver=null,this.rtcPeerTrackAudioReceiver=null,this._stopBandwidthEstimateInterval(),this.supportVideoFrameCallbackHandle&&this.$videoElement&&(this.$videoElement.cancelVideoFrameCallback(this.supportVideoFrameCallbackHandle),this.supportVideoFrameCallbackHandle=null),this.eventsDestroy.length&&(this.eventsDestroy.forEach((e=>e())),this.eventsDestroy=[]),this.isH264&&(this.videoStream&&(this.videoStream.getTracks().forEach((e=>e.stop())),this.videoStream=null),this.$videoElement.srcObject=null),this.rtcPeerConnection&&(this.rtcPeerConnection.onicecandidate=Jr,this.rtcPeerConnection.ontrack=Jr,this.rtcPeerConnection.onconnectionstatechange=Jr,this.rtcPeerConnection.ondatachannel=Jr,this.rtcPeerConnection.close(),this.rtcPeerConnection=null)}_initVideoEvents(){const{proxy:e}=this.player.events,t=e(this.$videoElement,Wi,(()=>{this.player.debug.log(this.TAG_NAME,"video canplay"),this.$videoElement.play().then((()=>{this.player.debug.log(this.TAG_NAME,"video play"),this._startCanvasRender(),this._initRenderSize()})).catch((e=>{this.player.debug.warn(this.TAG_NAME,"video play error ",e)}))})),i=e(this.$videoElement,Ji,(()=>{this.player.debug.log("HlsDecoder","video waiting")})),s=e(this.$videoElement,qi,(e=>{const t=parseInt(e.timeStamp,10);this.player.handleRender(),this.player.updateStats({ts:t}),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)})))})),r=e(this.$videoElement,Ki,(()=>{this.player.debug.log("HlsDecoder","video playback Rate change",this.$videoElement&&this.$videoElement.playbackRate)}));this.eventsDestroy.push(t,i,s,r)}_initRtcPeerConnection(){const e=new RTCPeerConnection,t=this.player;e.addTransceiver("video",{direction:"recvonly"}),e.addTransceiver("audio",{direction:"recvonly"}),e.onsignalingstatechange=e=>{this.player.debug.log(this.TAG_NAME,"onsignalingstatechange",e)},e.oniceconnectionstatechange=i=>{this.player.debug.log(this.TAG_NAME,"oniceconnectionstatechange",e.iceConnectionState);const s=e.iceConnectionState;switch(this.player.emit(nt.webrtcOnIceConnectionStateChange,s),this.isDisconnected="disconnected"===s,e.iceConnectionState){case"new":case"checking":case"closed":case"connected":case"completed":break;case"failed":t.emit(nt.webrtcFailed);break;case"disconnected":t.emit(nt.webrtcDisconnect);break;case"closed":t.emit(nt.webrtcClosed)}},e.onicecandidate=e=>{this.player.debug.log(this.TAG_NAME,"onicecandidate",e),e.candidate&&this.player.debug.log(this.TAG_NAME,"Remote ICE candidate: ",e.candidate.candidate)},e.ontrack=t=>{if(this.player.debug.log(this.TAG_NAME,"ontrack",t),"video"===t.track.kind){this.player.debug.log(this.TAG_NAME,"ontrack video"),this.rtcPeerTrackVideoReceiver=e.getReceivers().find((function(e){return e.track===t.track})),this.rtcPeerTrackVideoReceiver&&this._startBandwidthEstimateInterval();let i=t.streams[0];this.$videoElement.autoplay=!0,this.$videoElement.srcObject=i,this.videoStream=i}else"audio"===t.track.kind&&(this.player.debug.log(this.TAG_NAME,"ontrack audio"),this.rtcPeerTrackAudioReceiver=e.getReceivers().find((function(e){return e.track===t.track})),this.rtcPeerTrackAudioReceiver&&this._startBandwidthEstimateInterval())},e.onicecandidateerror=e=>{this.player.debug.log(this.TAG_NAME,"onicecandidateerror",e),this.player.emitError(ct.webrtcIceCandidateError,e)},e.onconnectionstatechange=i=>{switch(this.player.debug.log(this.TAG_NAME,"onconnectionstatechange",i),this.player.emit(nt.webrtcOnConnectionStateChange,e.connectionState),e.connectionState){case"new":case"connecting":case"connected":case"disconnected":break;case"failed":this.isDisconnected&&t.emit(nt.webrtcFailed)}},this.rtcPeerConnection=e}_startBandwidthEstimateInterval(){this.player.debug.log(this.TAG_NAME,"_startBandwidthEstimateInterval"),this._stopBandwidthEstimateInterval(),this.bandwidthEstimateInterval=setInterval((()=>{this.rtcPeerTrackVideoReceiver&&this.rtcPeerTrackVideoReceiver.getStats().then((e=>{let t={},i=0;e.forEach((e=>{if(e)switch(e.type){case pr:("succeeded"===e.state||e.bytesReceived)&&(this.currentWebrtcStats.timestamp=e.timestamp,this.currentWebrtcStats.rtt=e.currentRoundTripTime||-1,this.currentWebrtcStats.bytesReceived=e.bytesReceived||0,this.currentWebrtcStats.bytesSent=e.bytesSent||0);break;case gr:this.currentWebrtcStats.remoteCandidate=e||{};break;case mr:this.currentWebrtcStats.localCandidate=e||{};break;case fr:this.currentWebrtcStats.lastTimeStamp=e.timestamp;const s=((e.timestamp||0)-(this.prevWebrtcVideoStats.timestamp||0))/1e3,r=Number(e.bytesReceived||0)-Number(this.prevWebrtcVideoStats.bytesReceived||0),a=Math.floor(r/s);i+=a,t.vbps=a,this.prevWebrtcVideoStats=e;break;case yr:e.frameWidth&&e.frameHeight&&(this.currentWebrtcStats.frameWidth=e.frameWidth||0,this.currentWebrtcStats.frameHeight=e.frameHeight||0)}})),this.rtcPeerTrackAudioReceiver?this.rtcPeerTrackAudioReceiver.getStats().then((e=>{e.forEach((e=>{if(e&&e.type===fr){this.currentWebrtcStats.lastTimeStamp=e.timestamp;const s=((e.timestamp||0)-(this.prevWebrtcAudioStats.timestamp||0))/1e3,r=Number(e.bytesReceived||0)-Number(this.prevWebrtcAudioStats.bytesReceived||0),a=Math.floor(r/s);i+=a,t.abps=a,this.prevWebrtcAudioStats=e}})),this.player.updateStats(t),this.player.emit(nt.kBps,(i/1024).toFixed(2))})):(this.player.updateStats(t),this.player.emit(nt.kBps,(i/1024).toFixed(2)))}))}),1e3)}_stopBandwidthEstimateInterval(){this.player.debug.log(this.TAG_NAME,"_stopBandwidthEstimateInterval"),this.bandwidthEstimateInterval&&(clearInterval(this.bandwidthEstimateInterval),this.bandwidthEstimateInterval=null)}_startCanvasRender(){ho()?this.supportVideoFrameCallbackHandle=this.$videoElement.requestVideoFrameCallback(this.videoFrameCallback.bind(this)):(this._stopCanvasRender(),this.canvasRenderInterval=setInterval((()=>{this.player.video.render({$video:this.$videoElement,ts:0})}),40))}_stopCanvasRender(){this.canvasRenderInterval&&(clearInterval(this.canvasRenderInterval),this.canvasRenderInterval=null)}videoFrameCallback(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.player.isDestroyedOrClosed()?this.player.debug.log(this.TAG_NAME,"videoFrameCallback() player is destroyed"):(this.player.video.render({$video:this.$videoElement,ts:t.mediaTime||0}),this.player.updateStats({dts:t.mediaTime||0}),this.supportVideoFrameCallbackHandle=this.$videoElement.requestVideoFrameCallback(this.videoFrameCallback.bind(this)))}_initRenderSize(){this.isInitInfo||(this.player.video.updateVideoInfo({width:this.$videoElement.videoWidth,height:this.$videoElement.videoHeight}),this.player.video.initCanvasViewSize(),this.isInitInfo=!0)}getVideoCurrentTime(){let e=0;return this.$videoElement&&(e=this.$videoElement.currentTime),e}}class Pb extends Lb{constructor(e){super(e),this.rtcPeerConnectionDataChannel=null,this.player.isWebrtcH265()&&(this.streamRate=ia((t=>{e.emit(nt.kBps,(t/1024).toFixed(2))}))),this.TAG_NAME="WebrtcForM7SDecoder",this.player.debug.log(this.TAG_NAME,"init")}destroy(){super.destroy(),this.stopStreamRateInterval(),this.rtcPeerConnectionDataChannel&&(this.rtcPeerConnectionDataChannel.onopen=Jr,this.rtcPeerConnectionDataChannel.onclose=Jr,this.rtcPeerConnectionDataChannel.onmessage=Jr,this.rtcPeerConnectionDataChannel.close(),this.rtcPeerConnectionDataChannel=null),this.player.debug.log(this.TAG_NAME,"destroy")}_initRtcPeerConnection(){const e=new RTCPeerConnection,t=this.player;e.addTransceiver("video",{direction:"recvonly"}),e.addTransceiver("audio",{direction:"recvonly"}),e.onsignalingstatechange=e=>{this.player.debug.log(this.TAG_NAME,"onsignalingstatechange",e)},e.oniceconnectionstatechange=i=>{this.player.debug.log(this.TAG_NAME,"oniceconnectionstatechange",e.iceConnectionState);const s=e.iceConnectionState;switch(this.player.emit(nt.webrtcOnIceConnectionStateChange,s),this.isDisconnected="disconnected"===s,e.iceConnectionState){case"new":case"checking":case"closed":case"connected":case"completed":break;case"failed":t.emit(nt.webrtcFailed);break;case"disconnected":t.emit(nt.webrtcDisconnect);break;case"closed":t.emit(nt.webrtcClosed)}},e.onicecandidate=e=>{this.player.debug.log(this.TAG_NAME,"onicecandidate",e),e.candidate&&this.player.debug.log(this.TAG_NAME,"Remote ICE candidate: ",e.candidate.candidate)},e.ontrack=i=>{this.player.debug.log(this.TAG_NAME,"ontrack",i);const s=t.video.$videoElement;if(t.isWebrtcH264())if("video"===i.track.kind){this.player.debug.log(this.TAG_NAME,"ontrack video"),this.rtcPeerTrackVideoReceiver=e.getReceivers().find((function(e){return e.track===i.track})),this.rtcPeerTrackVideoReceiver&&this._startBandwidthEstimateInterval();let t=i.streams[0];s.autoplay=!0,s.srcObject=t,this.videoStream=t}else"audio"===i.track.kind&&(this.player.debug.log(this.TAG_NAME,"ontrack audio"),this.rtcPeerTrackAudioReceiver=e.getReceivers().find((function(e){return e.track===i.track})),this.rtcPeerTrackAudioReceiver&&this._startBandwidthEstimateInterval())},e.onicecandidateerror=e=>{this.player.debug.log(this.TAG_NAME,"onicecandidateerror",e),this.player.emitError(ct.webrtcIceCandidateError,e)},e.onconnectionstatechange=i=>{switch(t.debug.log(this.TAG_NAME,`sdp connect status ${e.connectionState}`),e.connectionState){case"new":case"connecting":case"connected":case"disconnected":break;case"failed":this.isDisconnected&&t.emit(nt.webrtcFailed)}},e.ondatachannel=e=>{const t=e.channel;this.player.debug.log(this.TAG_NAME,"ondatachannel"),t.onopen=()=>{this.player.debug.log(this.TAG_NAME,"ondatachannel and onopen")},t.onmessage=e=>{const t=e.data;if(this.player.isWebrtcH264())return this.player.debug.warn(this.TAG_NAME,"ondatachannel is H265 but decode is h264 so emit webrtcStreamH265 "),void this.player.emit(nt.webrtcStreamH265);this.player.isDestroyedOrClosed()?this.player.debug.warn(this.TAG_NAME,"ondatachannel and player is destroyed"):(this.streamRate&&this.streamRate(t.byteLength),this.player.demux&&this.player.demux.dispatch(t))},t.onclose=()=>{this.player.debug.warn(this.TAG_NAME,"ondatachannel and onclose")},this.rtcPeerConnectionDataChannel=t};e.createDataChannel("signal").onmessage=e=>{this.player.debug.log(this.TAG_NAME,"signalChannel,onmessage",e);JSON.parse(e.data).type},this.rtcPeerConnection=e}startStreamRateInterval(){this.stopStreamRateInterval(),this.streamRateInterval=setInterval((()=>{this.streamRate&&this.streamRate(0)}),1e3)}stopStreamRateInterval(){this.streamRateInterval&&(clearInterval(this.streamRateInterval),this.streamRateInterval=null)}loadSource(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(((i,s)=>{const r=this.rtcPeerConnection;r.createOffer().then((a=>{r.setLocalDescription(a),this.player.debug.log(this.TAG_NAME,"getWebRtcRemoteSdp loadSource"),function(e,t,i){let s={"Content-Type":"application/sdp"};return i.username&&i.password&&(s.Authorization="Basic "+btoa(i.username+":"+i.password)),fetch(e,{method:"POST",mode:"cors",cache:"no-cache",credentials:"include",redirect:"follow",referrerPolicy:"no-referrer",headers:s,body:t})}(e,a.sdp,t).then((e=>{e.text().then((e=>{this.player.debug.log(this.TAG_NAME,"getWebRtcRemoteSdp response"),e?r.setRemoteDescription(new RTCSessionDescription({type:"answer",sdp:e})).then((()=>{this.player.isWebrtcH265()&&this.startStreamRateInterval(),i()})).catch((e=>{s(e)})):s("sdp is null")})).catch((e=>{this.player.debug.error(this.TAG_NAME,"loadSource response.text() error",e),s(e)}))})).catch((e=>{this.player.debug.error(this.TAG_NAME,"loadSource getWebRtcRemoteSdp response error",e),s(e)}))})).catch((e=>{this.player.debug.error(this.TAG_NAME,"loadSource rtcPeerConnection.createOffer() error",e),s(e)}))}))}}class Bb extends Lb{constructor(e){super(e),this.TAG_NAME="WebrtcForZLMDecoder",this.player.debug.log(this.TAG_NAME,"init")}destroy(){super.destroy(),this.player.debug.log(this.TAG_NAME,"destroy")}loadSource(e){return new Promise(((t,i)=>{const s=this.rtcPeerConnection;s.createOffer().then((r=>{s.setLocalDescription(r),this.player.debug.log(this.TAG_NAME,"getWebRtcRemoteSdp loadSource"),function(e,t){return hl({url:e,type:"POST",data:t,contentType:"text/plain;charset=utf-8",processData:!1,dataType:"json"})}(e,r.sdp).then((e=>{this.player.debug.log(this.TAG_NAME,`getWebRtcRemoteSdp response and code is ${e.code}`);const r=e;if(r&&0!==r.code)return i(r.msg);r&&r.sdp?s.setRemoteDescription(new RTCSessionDescription({type:"answer",sdp:r.sdp})).then((()=>{t()})).catch((e=>{i(e)})):i("sdp is null")})).catch((e=>{this.player.debug.error(this.TAG_NAME,"loadSource getWebRtcRemoteSdp response error",e),i(e)}))})).catch((e=>{this.player.debug.error(this.TAG_NAME,"loadSource rtcPeerConnection.createOffer() error",e),i(e)}))}))}}class Ib extends po{constructor(e,t){if(super(),this.player=e,this.player.$container.classList.add("jb-pro-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=!!so(t.isUseFpsRender),this._rate=1,this._audioTimestamp=0,this._videoTimestamp=0,this.controlType=t.controlType||Q.normal,t.controlType&&-1===[Q.normal,Q.simple].indexOf(t.controlType)&&(this.player.debug.warn("Playback","constructor()","controlType is not in [normal,simple]",t.controlType),this.controlType=Q.normal),this._currentLocalTimestamp=0,this._localOneFrameTimestamp=t.localOneFrameTimestamp||40,this._localCalculateTimeInterval=null,this._isUseLocalCalculateTime=!!so(t.isUseLocalCalculateTime),this._isPlaybackPauseClearCache=!ro(t.isPlaybackPauseClearCache),this._isCacheBeforeDecodeForFpsRender=!!so(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._playbackListStartTimestamp=null,this._totalDuration=0,t.controlType===Q.normal)this.initPlaybackList(t.playList,t.showPrecision,t.startTime);else if(t.controlType===Q.simple){t.duration&&(this._totalDuration=1e3*t.duration);let e=t.startTime||0;e>this.totalDuration&&(e=this.totalDuration),this.setStartTime(e)}this.player.on(nt.playbackPause,(e=>{e?this.pause():this.resume()}));const i={fps:this._fps,isUseFpsRender:this._isUseFpsRender,localOneFrameTimestamp:this._localOneFrameTimestamp,isUseLocalCalculateTime:this._isUseLocalCalculateTime,uiUsePlaybackPause:t.uiUsePlaybackPause,showControl:t.showControl};e.debug.log("Playback","init",JSON.stringify(i))}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._playbackListStartTimestamp=null,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("jb-pro-container-playback"),this.off(),this.player.debug.log("Playback","destroy")}_listen(){this.player.on(nt.stats,(e=>{const t=e.ts;this._playStartTime||(this._playStartTime=t-1e3);let i=t-this._playStartTime;this.setPlayingTimestamp(i)}))}pause(){this.clearStatsInterval()}resume(){this.startCheckStatsInterval()}updateStats(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this._startFpsTimestamp||(this._startFpsTimestamp=Qr()),Ta(e.ts)&&(this.player.updateStats({fps:!0,ts:e.ts}),this._playbackTs=e.ts,this._startfpsTime||(this._startfpsTime=e.ts),this._renderFps+=1);const t=Qr(),i=t-this._startFpsTimestamp;if(i<1e3)return;let s=null;this._startfpsTime&&(s=this._playbackTs-this._startfpsTime),this.player.emit(nt.playbackStats,{fps:this._renderFps,rate:this.rate,start:this._startfpsTime,end:this._playbackTs,timestamp:i,dataTimestamp:s,audioBufferSize:this.player.audio?this.player.audio.bufferSize:0,videoBufferSize:this.player.video?this.player.video.bufferSize:0,ts:this._playbackTs}),this._renderFps=0,this._startfpsTime=this._playbackTs,this._startFpsTimestamp=t}updateLocalOneFrameTimestamp(e){this._localOneFrameTimestamp=e}_startLocalCalculateTime(){this._stopLocalCalculateTime(),this._localCalculateTimeInterval=setInterval((()=>{const e=this._currentLocalTimestamp;this._playStartTime||(this._playStartTime=e-1e3);let t=e-this._playStartTime;this.setPlayingTimestamp(t)}),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,t,i){this.playbackList=e||[];let s=0;if(this.playbackList.forEach(((e,t)=>{10===Ia(e.start)&&(e.startTimestamp=1e3*e.start,e.startTime=ca(e.startTimestamp)),10===Ia(e.end)&&(e.endTimestamp=1e3*e.end,e.endTime=ca(e.endTimestamp)),e.duration=e.end-e.start,s+=e.duration})),this._totalDuration=s,this.player.debug.log("Playback",this.playbackList),this.playbackList.length>0){const e=this.playbackList[0].startTimestamp;this._playbackListStartTimestamp=e;let t=e;i&&(10===Ia(i)&&(i*=1e3),this._isTimeInPlaybackList(i)&&(t=i)),this.setStartTime(t)}const r=t||fi;this.setShowPrecision(r)}get totalDuration(){return(this._totalDuration||0)/1e3}get startTime(){return this._startTime||0}setStartTime(e){this._startTime=e,this._playingTimestamp=e,this._playStartTime=null}setRate(e){this._rate=e,this.player.emit(nt.playbackRateChange,e)}get fps(){return this._fps}get rate(){return this._rate}get isUseFpsRender(){return this._isUseFpsRender}get isUseLocalCalculateTime(){return this._isUseLocalCalculateTime}get showPrecision(){return this._showPrecision}get is60Min(){return this.showPrecision===fi}get is30Min(){return this.showPrecision===mi}get is10Min(){return this.showPrecision===gi}get is5Min(){return this.showPrecision===yi}get is1Min(){return this.showPrecision===yi}get isPlaybackPauseClearCache(){return this._isPlaybackPauseClearCache}get isCacheBeforeDecodeForFpsRender(){return this._isCacheBeforeDecodeForFpsRender}setShowPrecision(e){bi.includes(e)||(this.player.debug.warn("Playback","setShowPrecision()","type is not in PLAYBACK_CONTROL_TIME_PRECISION_ARRAY",e),e=fi),this._showPrecision&&this._showPrecision===e||(this._showPrecision=e,this.player.emit(nt.playbackPrecision,this._showPrecision,this.playbackList),this.player.emit(nt.playbackShowPrecisionChange,this._showPrecision))}setPlayingTimestamp(e){let t;if(this.controlType===Q.normal){t=this.startTime+e,this._playingTimestamp=t,this.player.emit(nt.playbackTime,t);const i=new Date(t);this.player.emit(nt.playbackTimestamp,{ts:t,hour:i.getHours(),min:i.getMinutes(),second:i.getSeconds()})}else this.controlType===Q.simple&&(t=this.startTime+Math.round(e/1e3),t>this.totalDuration&&(this.player.debug.log("Playback","setPlayingTimestamp()",`timestamp ${t} > this.totalDuration ${this.totalDuration}`),t=this.totalDuration),this._playingTimestamp=t,this.player.emit(nt.playbackTime,t),this.player.emit(nt.playbackTimestamp,{ts:t}))}get playingTimestamp(){return this._playingTimestamp}narrowPrecision(){const e=bi.indexOf(this.showPrecision)-1;if(e>=0){const t=bi[e];this.setShowPrecision(t)}}expandPrecision(){const e=bi.indexOf(this.showPrecision)+1;if(e<=bi.length-1){const t=bi[e];this.setShowPrecision(t)}}seek(e){if(this.player.debug.log("Playback","seek()",e),this.controlType===Q.normal){if("true"===e.hasRecord){let t=e.time;"min"===e.type&&(t=60*e.time);let i=function(e){let t={};e>-1&&(t={hour:Math.floor(e/60/60)%60,min:Math.floor(e/60)%60,second:e%60});return t}(t);if(this._playbackListStartTimestamp){const e=new Date(this._playbackListStartTimestamp).setHours(i.hour,i.min,i.second,0);i.timestamp=e;const t=this._findMoreInfoByTimestamp(e);i&&t.more&&(i.more=t.more)}this.player.emit(nt.playbackSeek,i)}}else if(this.controlType===Q.simple){let t=e.time;this.player.emit(nt.playbackSeek,{ts:t})}}currentTimeScroll(){this.player.emit(nt.playbackTimeScroll)}_findMoreInfoByTimestamp(e){let t=null;return this.playbackList.forEach(((i,s)=>{i.startTimestamp<=e&&i.endTimestamp>=e&&(t=i)})),t}_isTimeInPlaybackList(e){let t=!1;return this.playbackList.forEach(((i,s)=>{i.startTimestamp<=e&&i.endTimestamp>=e&&(t=!0)})),t}getControlType(){return this.controlType}isControlTypeNormal(){return this.controlType===Q.normal}isControlTypeSimple(){return this.controlType===Q.simple}}class Mb extends po{constructor(e){super(),this.player=e,this.TAG_NAME="zoom",this.bindEvents=[],this.isDragging=!1,this.currentZoom=1,this.prevVideoElementStyleTransform=null,this.prevVideoElementStyleScale=null,this.maxScale=5,this.tempPosition={x:0,y:0},this.videoPosition={left:0,top:0};const{events:{proxy:t},debug:i}=this.player;this.player.on(nt.zooming,(e=>{if(e){this.player.$container.classList.add("jb-pro-zoom-control"),this._bindEvents();const e=this.player.video.$videoElement.style.transform;let t=this.player.video.$videoElement.offsetLeft,i=this.player.video.$videoElement.offsetTop;t=parseFloat(t),i=parseFloat(i),t&&(this.videoPosition.left=t),i&&(this.videoPosition.top=i),this.prevVideoElementStyleTransform=e;let s=e.match(/scale\([0-9., ]*\)/g);if(s&&s[0]){let e=s[0].replace("scale(","").replace(")","");this.prevVideoElementStyleScale=e.split(",")}}else{this.player.$container.classList.remove("jb-pro-zoom-control"),this._unbindEvents(),this._resetVideoPosition(),this.player.$container.style.cursor="auto";let e=this.prevVideoElementStyleTransform;this.player.video.$videoElement.style.transform=e,this.prevVideoElementStyleTransform=null,this.prevVideoElementStyleScale=null,ra()&&this.player._opt.useWebFullScreen&&this.player.resize()}}));const s=t(window,ra()?"touchend":"mouseup",(e=>{this.handleMouseUp(e)}));this.bindEvents.push(s),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(){const{events:{proxy:e},debug:t}=this.player,i=e(this.player.$container,ra()?"touchmove":"mousemove",(e=>{this.handleMouseMove(e)}));this.bindEvents.push(i);const s=e(this.player.$container,ra()?"touchstart":"mousedown",(e=>{this.handleMouseDown(e)}));this.bindEvents.push(s);const r=e(window,ra()?"touchend":"mouseup",(e=>{this.handleMouseUp(e)}));this.bindEvents.push(r)}_unbindEvents(){this.bindEvents.forEach((e=>{e&&e()}))}handleMouseMove(e){if(e.stopPropagation(),this.isDragging&&this.player.zooming){e.preventDefault();const{posX:t,posY:i}=Ha(e),s=this.tempPosition.x-t,r=this.tempPosition.y-i;this.videoPosition.left=this.videoPosition.left-s,this.videoPosition.top=this.videoPosition.top-r,this.tempPosition.x=t,this.tempPosition.y=i,this.updateVideoPosition()}}handleMouseDown(e){e.stopPropagation();const t=ja(e);if(this.player.zooming&&(t.matches("video")||t.matches("canvas"))){e.preventDefault();const{posX:t,posY:i}=Ha(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&&(e.preventDefault(),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(){const 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,this.isDragging=!1}narrowPrecision(){this.currentZoom<=1||(this.currentZoom-=1,this.updateVideoElementScale())}expandPrecision(){this.currentZoom>=this.maxScale||(this.currentZoom+=1,this.updateVideoElementScale())}updatePrevVideoElementStyleScale(e){this.prevVideoElementStyleScale=e}updateVideoElementScale(){const e=this.player.video.$videoElement;let t=e.style.transform,i=1,s=1;if(this.prevVideoElementStyleScale){const e=this.prevVideoElementStyleScale[0];void 0!==e&&(i=e,s=e);const t=this.prevVideoElementStyleScale[1];void 0!==t&&(s=t)}s=pa(s),i=pa(i);const r=.5*i*(this.currentZoom-1)+i,a=.5*s*(this.currentZoom-1)+s;let o;o=-1===t.indexOf("scale(")?t+` scale(${r},${a})`:t.replace(/scale\([0-9., ]*\)/,`scale(${r},${a})`),this.player.debug.log("zoom",`updateVideoElementScale end is ${r}, ${a} style is ${o}`),e.style.transform=o}}class Ub extends po{constructor(e){super(),this.player=e,this.faceDetector=null,this.objectDetector=null,this.imageDetector=null,this.occlusionDetector=null,this.initFaceDetector(),this.initObjectDetector(),this.initImageDetector(),this.initOcclusionDetector();let t="init";this.faceDetector&&(t+=" and use faceDetector"),this.objectDetector&&(t+=" and use objectDetector"),this.imageDetector&&(t+=" and use imageDetector"),this.occlusionDetector&&(t+=" and use occlusionDetector"),this.player.debug.log("AiLoader",t)}destroy(){this.off(),this.faceDetector&&(this.faceDetector.destroy(),this.faceDetector=null),this.objectDetector&&(this.objectDetector.destroy(),this.objectDetector=null),this.imageDetector&&(this.imageDetector.destroy(),this.imageDetector=null),this.occlusionDetector&&(this.occlusionDetector.destroy(),this.occlusionDetector=null),this.player.debug.log("AiLoader","destroy")}initFaceDetector(){if(this.player._opt.useFaceDetector&&window.JessibucaProFaceDetector){const e=new JessibucaProFaceDetector({detectWidth:this.player._opt.aiFaceDetectWidth,showRect:!1,debug:this.player._opt.debug,debugLevel:this.player._opt.debugLevel,debugUuid:this.player._opt.debugUuid});e.load().then((()=>{this.player.debug.log("AiLoader","init face detector success"),this.faceDetector=e,this.faceDetector.on("jessibuca-pro-face-detector-info",(e=>{if(this.player.emit(nt.aiFaceDetectorInfo,e),this.player._opt.aiFaceDetectShowRect){const t=this.player._opt.aiFaceDetectRectConfig||{},i=(e.list||[]).map((e=>(e.type="rect",e.color=t.borderColor||"#0000FF",e.lineWidth=t.borderWidth||2,e)));this.player.video&&this.player.video.addAiContentToCanvas(i)}}))}))}}initObjectDetector(){if(this.player._opt.useObjectDetector&&window.JessibucaProObjectDetector){const e=new JessibucaProObjectDetector({detectWidth:this.player._opt.aiObjectDetectWidth,showRect:!1,debug:this.player._opt.debug,debugLevel:this.player._opt.debugLevel,debugUuid:this.player._opt.debugUuid});e.load().then((()=>{this.player.debug.log("AiLoader","init object detector success"),this.objectDetector=e,this.objectDetector.on("jessibuca-pro-object-detector-info",(e=>{if(this.player.emit(nt.aiObjectDetectorInfo,e),this.player._opt.aiObjectDetectShowRect){const t=[],i=this.player._opt.aiObjectDetectRectConfig||{};(e.list||[]).forEach((e=>{const s={type:"rect",color:i.borderColor||"#0000FF",lineWidth:i.borderWidth||2,x:e.rect.x,y:e.rect.y,width:e.rect.width,height:e.rect.height},r={type:"text",color:i.color||"#000",fontSize:i.fontSize||14,text:e.zh,x:e.rect.x,y:e.rect.y-25};t.push(s,r)})),this.player.video&&this.player.video.addAiContentToCanvas(t)}}))}))}}initImageDetector(){if(this.player._opt.useImageDetector&&window.JessibucaProImageDetector){const e=new JessibucaProImageDetector({debug:this.player._opt.debug,debugLevel:this.player._opt.debugLevel,debugUuid:this.player._opt.debugUuid});e.load().then((()=>{this.player.debug.log("AiLoader","init image detector success"),this.imageDetector=e}))}}initOcclusionDetector(){if(this.player._opt.useOcclusionDetector&&window.JessibucaProOcclusionDetector){const e=new JessibucaProOcclusionDetector({debug:this.player._opt.debug,debugLevel:this.player._opt.debugLevel,debugUuid:this.player._opt.debugUuid});e.load().then((()=>{this.player.debug.log("AiLoader","init occlusion detector success"),this.occlusionDetector=e}))}}updateFaceDetectorConfig(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.faceDetector&&this.faceDetector.updateConfig(e)}updateObjectDetectorConfig(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.objectDetector&&this.objectDetector.updateConfig(e)}updateImageDetectorConfig(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.imageDetector&&this.imageDetector.updateConfig(e)}updateOcclusionDetectorConfig(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.occlusionDetector&&this.occlusionDetector.updateConfig(e)}}class Fb extends po{constructor(e){super(),this.player=e,this.LOG_NAME="Contextmenu",this.menuList=[],this.$contextmenus=e.control.$contextmenus,ra()?this.player.debug.warn(this.LOG_NAME,"not support mobile"):this.init(),e.debug.log(this.LOG_NAME,"init")}destroy(){this.menuList=[],this.player.debug.log(this.LOG_NAME,"destroy")}get isShow(){return e=this.player.$container,t="jb-pro-contextmenus-show",e.classList.contains(t);var e,t}show(){hh(this.player.$container,"jb-pro-contextmenus-show")}hide(){var e,t;e=this.player.$container,t="jb-pro-contextmenus-show",e.classList.remove(t)}init(){const{events:{proxy:e},debug:t}=this.player;this.player._opt.contextmenuBtns.length>0&&this.player._opt.contextmenuBtns.forEach((e=>{this.addMenuItem(e)})),e(this.player.$container,"contextmenu",(e=>{e.preventDefault(),this.show();const t=e.clientX,i=e.clientY,{height:s,width:r,left:a,top:o}=this.player.$container.getBoundingClientRect(),{height:n,width:l}=this.$contextmenus.getBoundingClientRect();let d=t-a,h=i-o;t+l>a+r&&(d=r-l),i+n>o+s&&(h=s-n),Zr(this.$contextmenus,{left:`${d}px`,top:`${h}px`})})),e(this.player.$container,"click",(e=>{ph(e,this.$contextmenus)||this.hide()})),this.player.on(nt.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 e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=Za(Ls);if(e=Object.assign({},t,e),!this._validateMenuItem(e))return;const{events:{proxy:i},debug:s}=this.player,r=fa(),a=`\n <div class="jb-pro-contextmenu jb-pro-contextmenu-${r}">\n ${e.content}\n </div>\n `,o=Array.from(this.$contextmenus.children)[e.index];o?o.insertAdjacentHTML("beforebegin",a):ch(this.$contextmenus,a);const n=this.$contextmenus.querySelector(`.jb-pro-contextmenu-${r}`);e.click&&i(n,"click",(t=>{t.preventDefault(),e.click.call(this.player,this,t),this.hide()})),this.menuList.push({uuid:r,$menuItem:n})}}class Ob extends Lb{constructor(e){super(e),this.TAG_NAME="WebrtcForSRSDecoder",this.player.debug.log(this.TAG_NAME,"init")}destroy(){super.destroy(),this.player.debug.log(this.TAG_NAME,"destroy")}loadSource(e){return new Promise(((t,i)=>{const s=this.rtcPeerConnection;s.createOffer().then((r=>{s.setLocalDescription(r),this.player.debug.log(this.TAG_NAME,"getWebRtcRemoteSdp loadSource"),function(e,t){return fetch(e,{method:"POST",mode:"cors",cache:"no-cache",credentials:"include",redirect:"follow",referrerPolicy:"no-referrer",headers:{"Content-Type":"application/sdp"},body:t})}(e,r.sdp).then((e=>{this.player.debug.log(this.TAG_NAME,`getWebRtcRemoteSdp response and code is ${e.code}`);const r=e;if(r&&0!==r.code)return i(r.msg);r?s.setRemoteDescription(new RTCSessionDescription({type:"answer",sdp:r})).then((()=>{t()})).catch((e=>{i(e)})):i("sdp is null")})).catch((e=>{this.player.debug.error(this.TAG_NAME,"loadSource getWebRtcRemoteSdp response error",e),i(e)}))})).catch((e=>{this.player.debug.error(this.TAG_NAME,"loadSource rtcPeerConnection.createOffer() error",e),i(e)}))}))}}class Nb extends Lb{constructor(e){super(e),this.TAG_NAME="WebrtcForOthersDecoder",this.player.debug.log(this.TAG_NAME,"init")}destroy(){super.destroy(),this.player.debug.log(this.TAG_NAME,"destroy")}loadSource(e){return new Promise(((t,i)=>{const s=this.rtcPeerConnection;s.createOffer().then((r=>{s.setLocalDescription(r),this.player.debug.log(this.TAG_NAME,"getWebRtcRemoteSdp loadSource"),function(e,t){return fetch(e,{method:"POST",mode:"cors",cache:"no-cache",credentials:"include",redirect:"follow",referrerPolicy:"no-referrer",headers:{"Content-Type":"application/sdp"},body:t})}(e,r.sdp).then((e=>{this.player.debug.log(this.TAG_NAME,`getWebRtcRemoteSdp response and code is ${e.code}`),e.text().then((e=>{this.player.debug.log(this.TAG_NAME,"getWebRtcRemoteSdp response");try{let t=JSON.parse(e);this.player.debug.log(this.TAG_NAME,"this is json sdp response"),0!=t.code&&(this.player.debug.log(this.TAG_NAME,`response json code ${t.code}`),i(new Error(`response sdp json code: ${t.code}`))),e=t.sdp}catch(e){this.player.debug.log(this.TAG_NAME,"this is raw sdp response")}e?s.setRemoteDescription(new RTCSessionDescription({type:"answer",sdp:e})).then((()=>{t()})).catch((e=>{i(e)})):i("sdp is null")})).catch((e=>{this.player.debug.error(this.TAG_NAME,"loadSource response.text() error",e),i(e)}))})).catch((e=>{this.player.debug.error(this.TAG_NAME,"loadSource getWebRtcRemoteSdp response error",e),i(e)}))})).catch((e=>{this.player.debug.error(this.TAG_NAME,"loadSource rtcPeerConnection.createOffer() error",e),i(e)}))}))}}class jb extends po{constructor(e){if(super(),this.TAG_NAME="AliyunRtc",this.player=e,!window.AliRTS)throw new Error("AliyunRtc is not defined");this.aliyunRtc=window.AliRTS.createClient(),this.aliyunRtcRemoteStream=null,this.$videoElement=this.player.video.$videoElement,this.listenEvents(),this.player.debug.log(this.TAG_NAME,"init")}destroy(){this.aliyunRtc&&(this.aliyunRtcRemoteStream&&(this.aliyunRtcRemoteStream=null),this.aliyunRtc.unsubscribe(),this.aliyunRtc=null),this.off(),this.player.debug.log(this.TAG_NAME,"destroy")}listenEvents(){this.aliyunRtc.on("onError",(e=>{this.player.debug.log(this.TAG_NAME,`onError and code is ${e.errorCode} and message: ${e.message}`),10400!==e.errorCode&&(this.player.debug.error(this.TAG_NAME,`onError and code is ${e.errorCode} and message: ${e.message}`),this.player.emitError(ct.aliyunRtcError,e))})),this.aliyunRtc.on("reconnect",(e=>{this.player.debug.log(this.TAG_NAME,"reconnect",e)}));const e="canplay",t="waiting",i="playing",s="media";this.aliyunRtc.on("onPlayEvent",(r=>{if(r.event===e)this.player.debug.log(this.TAG_NAME,"onPlayEvent and canplay");else if(r.event===t)this.player.debug.log(this.TAG_NAME,"onPlayEvent and playing - > waiting");else if(r.event===i)this.player.debug.log(this.TAG_NAME,"onPlayEvent and waiting -> playing");else if(r.event===s){const e=r.data;let t={},i=0;if(e.audio){const s=Math.floor(e.audio.bytesReceivedPerSecond);i+=s,t.abps=s}if(e.video){const s=Math.floor(e.video.bytesReceivedPerSecond);i+=s,t.vbps=s}this.player.updateStats(t),this.player.emit(nt.kBps,(i/1024).toFixed(2))}}))}loadSource(e){return new Promise(((t,i)=>{this.aliyunRtc.isSupport({isReceiveVideo:!0}).then((()=>{this.aliyunRtc.subscribe(e,{}).then((e=>{this.aliyunRtcRemoteStream=e,e.play(this.$videoElement),t()})).catch((e=>{this.player.debug.error(this.TAG_NAME,"loadSource and subscribe is not success: ",e.message),i(e.message)}))})).catch((e=>{this.player.debug.error(this.TAG_NAME,"loadSource and is not support: ",e.message),i(e.message)}))}))}getVideoCurrentTime(){let e=0;return this.$videoElement&&(e=this.$videoElement.currentTime),e}}class zb{constructor(e){this.player=e,this.TAG_NAME="PressureObserverCpu",this.observer=null,this.latestCpuInfo=null,this.currentLevel=-1,this._init(),this.player.debug.log(this.TAG_NAME,"init")}destroy(){this.observer&&(this.observer.disconnect(),this.observer=null),this.latestCpuInfo=null,this.currentLevel=-1,this.player.debug.log(this.TAG_NAME,"destroy")}getCurrentCpuState(){return this.currentLevel}_init(){ro(co())?this.player.debug.log(this.TAG_NAME,"not support PressureObserver"):(this.observer=new PressureObserver((e=>{const t=(e||[]).find((e=>"cpu"===e.source));if(t){switch(this.latestCpuInfo=t,t.state){case"nominal":this.currentLevel=0;break;case"fair":this.currentLevel=1;break;case"serious":this.currentLevel=2;break;case"critical":this.currentLevel=3;break;default:this.currentLevel=-1}this.player.emit(nt.pressureObserverCpu,this.currentLevel)}})),this.observer&&this.observer.observe("cpu"))}}class Gb extends wo{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(e),this.TAG_NAME="DynamicWatermark",this.isPauseAnimation=!1,this.isStopAnimation=!1,this.rafID=null,this.speed=t.speed||.2,this.isDynamic=!0,this.shadowRootDynamicDom=null,this.isGhost=!0===t.isGhost,this.ghostConfig={on:t.on||5,off:t.off||5},this.waterMarkWillRemove=!1,this.waterMarkWillAdd=!1,this.player.once(nt.start,(()=>{const e=t.content;let i=this.player.getVideoInfo();i||(i={width:200,height:200}),this.update({text:{content:e,fontSize:t.fontSize||18,color:t.color||"white"},left:i.width*Math.random(),top:i.height*Math.random(),opacity:t.opacity||.15}),this.startAnimation()})),this.player.debug.log(this.TAG_NAME,"int")}destroy(){super.destroy(),this.shadowRootDynamicDom=null,this.stopAnimation(),this.rafID&&(cancelAnimationFrame(this.rafID),this.rafID=null)}startAnimation(){if(!this.rafID){let e=1,t=1,i=Math.random(),s={width:0,height:0};const r=()=>{try{if(ro(this.isPauseAnimation)&&this.shadowRootDynamicDom&&this.shadowRootInnerDom){const a=this.shadowRootInnerDom,o=this.shadowRootDynamicDom,n=a.getBoundingClientRect(),l=o.getBoundingClientRect();if(l.width&&l.height&&(s.width=l.width,s.height=l.height),!this.shadowRootInnerDom.contains(this.shadowRootDynamicDom))return this.isGhost?ro(this.waterMarkWillAdd)&&(this.waterMarkWillAdd=!0,setTimeout((()=>{this._addDom(n,s),this.waterMarkWillAdd=!1}),1e3*this.ghostConfig.off)):this._addDom(n,s),void(0!==this.speed&&requestAnimationFrame(r));const d=Math.min(1,0===this.speed?0:this.speed?this.speed:.2);let h=l.left-n.left,c=l.top-n.top;h+=d*t*i,c+=d*e*(1-i),h+s.width>n.width?(t=-1,i=Math.random()):h<0&&(t=1,i=Math.random()),c+s.height>n.height?(e=-1,i=Math.random()):c<0&&(e=1,i=Math.random()),h=Math.min(n.width-s.width,h),c=Math.min(n.height-s.height,c);const u=h/n.width*100,p=c/n.height*100;this.shadowRootDynamicDom.style.left=`${u}%`,this.shadowRootDynamicDom.style.top=`${p}%`,ro(this.waterMarkWillRemove)&&this.isGhost&&(this.waterMarkWillRemove=!0,setTimeout((()=>{this._removeDom(),this.waterMarkWillRemove=!1}),1e3*this.ghostConfig.on))}}catch(e){}if(this.isStopAnimation)return this.isStopAnimation=!1,cancelAnimationFrame(this.rafID),void(this.rafID=null);0!==this.speed&&requestAnimationFrame(r)};this.rafID=requestAnimationFrame(r)}}_addDom(e,t){if(this.shadowRootInnerDom&&this.shadowRootDynamicDom){this.shadowRootInnerDom.appendChild(this.shadowRootDynamicDom);let i=e.width*Math.random(),s=e.height*Math.random();i=Math.min(e.width-2*t.width,i),s=Math.min(e.height-2*t.height,s),this.shadowRootDynamicDom.style.left=`${i}px`,this.shadowRootDynamicDom.style.top=`${s}px`}}resumeAnimation(){this.isPauseAnimation=!1}pauseAnimation(){this.isPauseAnimation=!0}stopAnimation(){this.isStopAnimation=!0}}class Hb extends po{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),this._opt={},this.TAG_NAME="Player",this.$container=e;const i=to();if(this._opt=Object.assign({},i,t),this.debug=new Er(this),this.debug.log(this.TAG_NAME,"init"),this._opt.forceNoOffscreen=!0,this._canPlayAppleMpegurl=!1,(ha()||da())&&(this._canPlayAppleMpegurl=$a(),this.debug.log(this.TAG_NAME,"isIOS or isSafari and canPlayAppleMpegurl",this._canPlayAppleMpegurl)),ra()&&(this.debug.log(this.TAG_NAME,"isMobile and set _opt.controlAutoHide false"),this._opt.controlAutoHide=!1,so(Cr.isEnabled)&&so(this._opt.useWebFullScreen)&&(this.debug.log(this.TAG_NAME,"screenfull.isEnabled is true and _opt.useWebFullScreen is true , set _opt.useWebFullScreen false"),this._opt.useWebFullScreen=!1),ro(Cr.isEnabled)&&ro(this._opt.useWebFullScreen)&&(this.debug.log(this.TAG_NAME,"screenfull.isEnabled is false and _opt.useWebFullScreen is false , set _opt.useWebFullScreen true"),this._opt.useWebFullScreen=!0)),oo()&&(this.debug.log(this.TAG_NAME,"isIphone and set _opt.videoRenderSupportScale false"),this._opt.videoRenderSupportScale=!1,Oa()&&so(this._opt.isHls)&&ro(this._opt.supportHls265)&&(this.debug.log(this.TAG_NAME,"isIphone and is in wechat and is hls so set supportHls265 true"),this._opt.supportHls265=!0)),ro(this._opt.playFailedAndReplay)&&(this.debug.log(this.TAG_NAME,"_opt.playFailedAndReplay is false and set others replay params false"),this._opt.webglAlignmentErrorReplay=!1,this._opt.webglContextLostErrorReplay=!1,this._opt.autoWasm=!1,this._opt.mseDecodeErrorReplay=!1,this._opt.mediaSourceTsIsMaxDiffReplay=!1,this._opt.wcsDecodeErrorReplay=!1,this._opt.wasmDecodeErrorReplay=!1,this._opt.simdDecodeErrorReplay=!1,this._opt.videoElementPlayingFailedReplay=!1,this._opt.networkDelayTimeoutReplay=!1,this._opt.widthOrHeightChangeReplay=!1,this._opt.simdH264DecodeVideoWidthIsTooLargeReplay=!1,this._opt.mediaSourceUseCanvasRenderPlayFailedReplay=!1,this._opt.heartTimeoutReplay=!1,this._opt.loadingTimeoutReplay=!1,this._opt.websocket1006ErrorReplay=!1,this._opt.streamErrorReplay=!1,this._opt.streamEndReplay=!1),this._opt.hiddenControl&&(this.debug.log(this.TAG_NAME,"_opt.hiddenControl is true and set others show btn to false"),Object.keys(this._opt.operateBtns).forEach((e=>{this._opt.operateBtns[e]&&-1===(""+e).indexOf("Fn")&&(this._opt.operateBtns[e]=!1)})),this._opt.showBandwidth=!1,this._opt.extendOperateBtns=[],this._opt.controlHtml="",this.isPlayback()&&(this._opt.playbackConfig.showControl=!1)),this._opt.forceNoOffscreen||("undefined"==typeof OffscreenCanvas?(this._opt.forceNoOffscreen=!0,this._opt.useOffscreen=!1):this._opt.useOffscreen=!0),this._opt.isMpeg4&&(this.debug.log(this.TAG_NAME,"isMpeg4 is true, so set _opt.useWasm true and others params false"),this._opt.useWCS=!1,this._opt.useMSE=!1,this._opt.isNakedFlow=!1,this._opt.useSIMD=!1,this._opt.isFmp4=!1,this._opt.useWasm=!0),this.isPlayback()&&(this._opt.mseDecoderUseWorker=!1),this._opt.poster&&(this._opt.background=this._opt.poster),ro(this._opt.muted)&&(this._opt.isNotMute=!0),this._opt.mseDecoderUseWorker&&(this._opt.mseDecoderUseWorker=!!(self.Worker&&self.MediaSource&&"canConstructInDedicatedWorker"in self.MediaSource&&!0===self.MediaSource.canConstructInDedicatedWorker),ro(this._opt.mseDecoderUseWorker)&&this.debug.log(this.TAG_NAME,"mseDecoderUseWorker is true but not support so set _opt.mseDecoderUseWorker = false")),(this.isOldHls()||this.isWebrtcH264()||this.isAliyunRtc())&&(this.debug.log(this.TAG_NAME,"isOldHls or isWebrtcH264 or isAliyunRtc is true, so set some params false and _opt.recordType is webm"),this._opt.useWCS=!1,this._opt.useMSE=!1,this._opt.isNakedFlow=!1,this._opt.useSIMD=!1,this._opt.isFmp4=!1,this._opt.useWasm=!1,this._opt.recordType=w),this._opt.isNakedFlow&&(this.debug.log(this.TAG_NAME,"isNakedFlow is true, so set _opt.mseDecodeAudio false"),this._opt.mseDecodeAudio=!1),na()&&(this.debug.log(this.TAG_NAME,"isFirefox is true, so set _opt.mseDecodeAudio false"),this._opt.mseDecodeAudio=!1),!this.isOldHls()&&!this.isWebrtcH264()){if(this._opt.useWCS){const e="VideoEncoder"in window,t=ba();this._opt.useWCS=e,this._opt.useWCS&&this._opt.isH265&&(this._opt.useWCS=t),this._opt.useWCS||this.debug.warn(this.TAG_NAME,`\n useWCS is true,\n and supportWCS is ${e}, supportHevcWCS is ${t} , _opt.isH265 is ${this._opt.isH265}\n so set useWCS false`),this._opt.useWCS&&(this._opt.useOffscreen?this._opt.wcsUseVideoRender=!1:this._opt.wcsUseVideoRender&&(this._opt.wcsUseVideoRender=_a()&&va(),this._opt.wcsUseVideoRender||this.debug.warn(this.TAG_NAME,"wcsUseVideoRender is true, but not support so set wcsUseVideoRender false")))}if(this._opt.useMSE){const e=function(){let e=!1;return"MediaSource"in self&&(e=!0),e}()||function(){let e=!1;return!("MediaSource"in self)&&"ManagedMediaSource"in self&&(e=!0),e}(),t=Aa()||function(){let e=!1;return!("MediaSource"in self)&&"ManagedMediaSource"in self&&(self.ManagedMediaSource.isTypeSupported(ii)||self.ManagedMediaSource.isTypeSupported(si)||self.ManagedMediaSource.isTypeSupported(ri)||self.ManagedMediaSource.isTypeSupported(ai)||self.ManagedMediaSource.isTypeSupported(oi))&&(e=!0),e}();this._opt.useMSE=e,this._opt.useMSE&&this._opt.isH265&&(this._opt.useMSE=t),this._opt.useMSE||this.debug.warn(this.TAG_NAME,`\n useMSE is true,\n and supportMSE is ${e}, supportHevcMSE is ${t} , _opt.isH265 is ${this._opt.isH265}\n so set useMSE false`)}}if(ro(this._opt.useMSE)&&(this._opt.mseDecodeAudio=!1),this._opt.useMSE?(this._opt.useWCS&&this.debug.warn(this.TAG_NAME,"useMSE is true and useWCS is true then useWCS set true->false"),this._opt.forceNoOffscreen||this.debug.warn(this.TAG_NAME,"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.isWebrtc&&this._opt.demuxUseWorker&&(this.debug.warn(this.TAG_NAME,"isWebrtc is true and demuxUseWorker is true then demuxUseWorker set true->false"),this._opt.demuxUseWorker=!1),this._opt.isHls&&this._opt.demuxUseWorker&&(this.debug.warn(this.TAG_NAME,"isHls is true and demuxUseWorker is true then demuxUseWorker set true->false"),this._opt.demuxUseWorker=!1),this._opt.isAliyunRtc&&this._opt.demuxUseWorker&&(this.debug.warn(this.TAG_NAME,"isAliyunRtc is true and demuxUseWorker is true then demuxUseWorker set true->false"),this._opt.demuxUseWorker=!1),this.isStreamWebTransport()&&this._opt.demuxUseWorker&&(this.debug.warn(this.TAG_NAME,"is stream use webTransport is true and demuxUseWorker is true then demuxUseWorker set true->false"),this._opt.demuxUseWorker=!1),ro(this._opt.demuxUseWorker)&&(this._opt.mseDecoderUseWorker=!1),this.isPlayback()&&(this._opt.mseDecoderUseWorker=!1),this._opt.useMThreading&&(this._opt.useMThreading="undefined"!=typeof SharedArrayBuffer,this._opt.useMThreading||this.debug.warn(this.TAG_NAME,"useMThreading is true, but not support so set useMThreading false")),this._opt.useSIMD||-1!==this._opt.decoder.indexOf("-simd")){const e=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])),t=oo();this._opt.useSIMD=e&&ro(t),this._opt.useSIMD||this.debug.warn(this.TAG_NAME,`useSIMD is true, but not support(isSupportSimd is ${e} ,isIphone is ${t}) so set useSIMD false`)}var s;if(this._opt.useSIMD?-1===this._opt.decoder.indexOf("-simd")?this._opt.useMThreading?this._opt.decoder=this._opt.decoder.replace("decoder-pro.js","decoder-pro-simd-mt.js"):this._opt.decoder=this._opt.decoder.replace("decoder-pro.js","decoder-pro-simd.js"):this._opt.useMThreading&&(this._opt.decoder=this._opt.decoder.replace("decoder-pro-simd.js","decoder-pro-simd-mt.js")):-1!==this._opt.decoder.indexOf("-simd")?this._opt.useMThreading?this._opt.decoder=this._opt.decoder.replace("decoder-pro-simd.js","decoder-pro-mt.js"):this._opt.decoder=this._opt.decoder.replace("decoder-pro-simd.js","decoder-pro.js"):this._opt.useMThreading&&(this._opt.decoder=this._opt.decoder.replace("decoder-pro.js","decoder-pro-mt.js")),this.debug.log(this.TAG_NAME,`_opt.decoder is ${this._opt.decoder}`),-1!==this._opt.decoder.indexOf("-simd")?this._opt.useMThreading?(this._opt.decoderAudio=this._opt.decoder.replace("decoder-pro-simd-mt.js","decoder-pro-audio.js"),this._opt.decoderHard=this._opt.decoder.replace("decoder-pro-simd-mt.js","decoder-pro-hard.js"),this._opt.decoderHardNotWasm=this._opt.decoder.replace("decoder-pro-simd-mt.js","decoder-pro-hard-not-wasm.js")):(this._opt.decoderAudio=this._opt.decoder.replace("decoder-pro-simd.js","decoder-pro-audio.js"),this._opt.decoderHard=this._opt.decoder.replace("decoder-pro-simd.js","decoder-pro-hard.js"),this._opt.decoderHardNotWasm=this._opt.decoder.replace("decoder-pro-simd.js","decoder-pro-hard-not-wasm.js")):this._opt.useMThreading?(this._opt.decoderAudio=this._opt.decoder.replace("decoder-pro-mt.js","decoder-pro-audio.js"),this._opt.decoderHard=this._opt.decoder.replace("decoder-pro-mt.js","decoder-pro-hard.js"),this._opt.decoderHardNotWasm=this._opt.decoder.replace("decoder-pro-mt.js","decoder-pro-hard-not-wasm.js")):(this._opt.decoderAudio=this._opt.decoder.replace("decoder-pro.js","decoder-pro-audio.js"),this._opt.decoderHard=this._opt.decoder.replace("decoder-pro.js","decoder-pro-hard.js"),this._opt.decoderHardNotWasm=this._opt.decoder.replace("decoder-pro.js","decoder-pro-hard-not-wasm.js")),this.debug.log(this.TAG_NAME,"编码配置"),ro(this._opt.hasAudio)&&(this._opt.operateBtns.audio=!1),ro(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.debug.log(this.TAG_NAME,`按键配置:${JSON.stringify(this._opt.operateBtns)}`),this._opt.qualityConfig&&0===this._opt.qualityConfig.length&&this._opt.operateBtns.quality&&(this._opt.operateBtns.quality=!1,this.debug.warn(this.TAG_NAME,"_opt.qualityConfig is empty, so set operateBtns.quality false")),so(this._opt.useWebGPU)&&(this._opt.useWebGPU=function(){let e=!1;return"gpu"in navigator&&(e=!0),e}(),ro(this._opt.useWebGPU)&&this.debug.warn(this.TAG_NAME,"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._closed=!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,currentPts:0,pTs:0,dts:0,mseVideoBufferDelayTime:0,isDropping:!1},this._allStatsData={},this._faceDetectActive=!1,this._objectDetectActive=!1,this._occlusionDetectActive=!1,this._imageDetectActive=!1,this._times={playInitStart:"",playStart:"",streamStart:"",streamResponse:"",demuxStart:"",decodeStart:"",videoStart:"",playTimestamp:"",streamTimestamp:"",streamResponseTimestamp:"",demuxTimestamp:"",decodeTimestamp:"",videoTimestamp:"",allTimestamp:""},this._videoTimestamp=0,this._audioTimestamp=0,this._latestAudioTimestamp=0,this._videoIframeIntervalTs=0,this._streamQuality=this._opt.defaultStreamQuality||"",!this._streamQuality&&this._opt.qualityConfig.length>0&&(this._streamQuality=this._opt.qualityConfig[0]||""),this._visibility=!0,this._lastestVisibilityChangeTimestamp=null,this._tempWorkerStats=null,this._historyFpsList=[],this._historyVideoDiffList=[],this._tempStreamList=[],this._tempInnerPlayBgobj=null,this._flvMetaData=null,this._flvMetaDataFps=null,this._mseWorkerData={},ro(this._opt.useMSE)&&ro(this._opt.useWCS)&&!this.isWebrtcH264()&&!this.isOldHls()&&(this._opt.useWasm=!0),(this.isOldHls()||this.isWebrtcH264())&&(this._opt.hasVideo=!0,this._opt.hasAudio=!0),this._opt.hasVideo||(this._opt.useMSE=!1,this._opt.useWCS=!1),this.debug.log(this.TAG_NAME,`useWasm:${this._opt.useWasm}`),this._opt.useWasm&&(this._opt.useOffscreen?this._opt.wasmUseVideoRender=!1:this._opt.wasmUseVideoRender&&(this._opt.wasmUseVideoRender=ua()&&_a()&&va(),this._opt.wasmUseVideoRender||this.debug.warn(this.TAG_NAME,"use wasm video render, but not support so set wasmUseVideoRender false")),this._opt.useSIMD?this.debug.log(this.TAG_NAME,"use simd wasm"):this.debug.log(this.TAG_NAME,"use wasm")),this._opt.useWasm&&(this._opt.useFaceDetector&&window.JessibucaProFaceDetector||this._opt.useObjectDetector&&window.JessibucaProObjectDetector||this._opt.useOcclusionDetector&&window.JessibucaProOcclusionDetector||this._opt.useImageDetector&&window.JessibucaProImageDetector)?(this.ai=new Ub(this),this._opt.useFaceDetector&&window.JessibucaProFaceDetector||(this._opt.operateBtns.aiFace=!1),this._opt.useObjectDetector&&window.JessibucaProObjectDetector||(this._opt.operateBtns.aiObject=!1),this._opt.useOcclusionDetector&&window.JessibucaProOcclusionDetector||(this._opt.operateBtns.aiOcclusion=!1),this._opt.useImageDetector&&this._opt.aiImageDetectActive&&window.JessibucaProImageDetector&&(this.imageDetectActive=!0)):(this._opt.operateBtns.aiObject=!1,this._opt.operateBtns.aiFace=!1,this._opt.operateBtns.aiOcclusion=!1),this._opt.useFaceDetector&&(this._opt.useWasm&&window.JessibucaProFaceDetector||this.debug.warn(this.TAG_NAME,`use face detector, useWasm is ${this._opt.useWasm} and window.JbProFaceDetector is null`)),this._opt.useObjectDetector&&(this._opt.useWasm&&window.JessibucaProObjectDetector||this.debug.warn(this.TAG_NAME,`use object detector, useWasm is ${this._opt.useWasm} and window.JbProObjectDetector is null`)),this._opt.useOcclusionDetector&&(this._opt.useWasm&&window.JessibucaProOcclusionDetector||this.debug.warn(this.TAG_NAME,`use occlusion detector, useWasm is ${this._opt.useWasm} and window.JessibucaProOcclusionDetector is null`)),this._opt.useImageDetector&&(this._opt.useWasm&&window.JessibucaProImageDetector||this.debug.warn(this.TAG_NAME,`use image detector, useWasm is ${this._opt.useWasm} and window.JessibucaProImageDetector is null`)),this._opt.useVideoRender&&(this._opt.useWasm&&!this._opt.useOffscreen?(this._opt.wasmUseVideoRender=ua()&&_a()&&va(),this._opt.wasmUseVideoRender||this.debug.warn(this.TAG_NAME,"use wasm video render, but not support so set wasmUseVideoRender false")):this._opt.useWCS&&!this._opt.useOffscreen&&(this._opt.wcsUseVideoRender=_a()&&va(),this._opt.wcsUseVideoRender||this.debug.warn(this.TAG_NAME,"use wcs video render, but not support so set wcsUseVideoRender false"))),this._opt.useCanvasRender&&(this._opt.useMSE&&ro(this._opt.mseDecoderUseWorker)&&(this._opt.mseUseCanvasRender=!0),this._opt.useWasm&&(this._opt.wasmUseVideoRender=!1),this._opt.useWCS&&(this._opt.wcsUseVideoRender=!1),this.isOldHls()&&!ha()&&(this._opt.hlsUseCanvasRender=!0),this.isWebrtcH264()&&(this._opt.webrtcUseCanvasRender=!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.isOldHls()?this._opt.hlsUseCanvasRender?this._opt.useCanvasRender=!0:this._opt.useVideoRender=!0:this.isWebrtcH264()&&(this._opt.webrtcUseCanvasRender?this._opt.useCanvasRender=!0:this._opt.useVideoRender=!0),this.debug.log(this.TAG_NAME,`useCanvasRender:${this._opt.useCanvasRender}`),this.debug.log(this.TAG_NAME,`useVideoRender:${this._opt.useVideoRender}`),s=this,Object.defineProperty(s,"rect",{get:()=>{let e={};return s.$container&&(e=s.$container.getBoundingClientRect(),e.width=Math.max(e.width,s.$container.clientWidth),e.height=Math.max(e.height,s.$container.clientHeight)),e}}),["bottom","height","left","right","top","width"].forEach((e=>{Object.defineProperty(s,e,{get:()=>s.rect[e]||0})})),this.events=new uo(this),this._opt.hasVideo&&(this.video=new Uo(this),this.recorder=new Vn(this)),this.isOldHls()?(this.hlsDecoder=new lA(this),this.loaded=!0):this.isWebrtcH264()?(this._opt.isWebrtcForZLM?this.webrtc=new Bb(this):this._opt.isWebrtcForSRS?this.webrtc=new Ob(this):this._opt.isWebrtcForOthers?this.webrtc=new Nb(this):this.webrtc=new Pb(this),this.loaded=!0):this.isAliyunRtc()?(this.aliyunRtcDecoder=new jb(this),this.loaded=!0):(this.isUseHls265()&&(this.hlsDecoder=new Db(this)),this.isWebrtcH265()&&(this.webrtc=new Pb(this)),ro(Va(this._opt))?this.decoderWorker=new Qn(this):this.loaded=!0),this.debug.log(this.TAG_NAME,"DecoderWorker"),this._opt.hasAudio&&(this.audio=new tn(this)),this.stream=null,this.demux=null,this._lastVolume=null,this._isMute=null,this._isInZoom=!1,this._playingStartTimestamp=null,this.isMSEVideoDecoderInitializationFailedNotSupportHevc=!1,this.isMSEAudioDecoderError=!1,this.isMSEPlaybackRateChangePause=!1,this.isPlayFailedAndPaused=!1,this.debug.log(this.TAG_NAME,`useWCS:${this._opt.useWCS}`),this._opt.useWCS&&(this.webcodecsDecoder=new Zd(this),!this._opt.hasAudio&&ro(this._opt.demuxUseWorker)&&(this.loaded=!0)),this._opt.useMSE&&ro(this._opt.mseDecoderUseWorker)&&(this.mseDecoder=new kh(this),!this._opt.hasAudio&&ro(this._opt.demuxUseWorker)&&(this.loaded=!0)),this.control=new yh(this),this._opt.contextmenuBtns.length>0&&ro(this._opt.disableContextmenu)&&aa()?this.contextmenu=new Fb(this):so(this._opt.disableContextmenu)&&this._opt.contextmenuBtns.length>0&&aa()&&this.debug.warn(this.TAG_NAME,"disableContextmenu is true, but contextmenuBtns is not empty, so Contextmenu can not be created,please check"),this.isPlayback()&&(this.playback=new Ib(this,this._opt.playbackConfig)),this._opt.operateBtns.zoom&&(this.zoom=new Mb(this)),/(iphone|ipad|ipod|ios|android)/i.test(window.navigator.userAgent.toLowerCase())&&ro(this._opt.supportLockScreenPlayAudio&&da())&&(this.keepScreenOn=new Rh(this)),this.debug.log(this.TAG_NAME,"events"),(e=>{try{const t=t=>{ja(t)===e.$container&&(e.emit(lt.fullscreen,e.fullscreen),e.fullscreen?e._opt.useMSE&&e.resize():e.resize())};Cr.on("change",t),e.events.destroys.push((()=>{Cr.off("change",t)}))}catch(e){}if(e.on(nt.decoderWorkerInit,(()=>{e.debug.log("player","listen decoderWorkerInit and set loaded true"),e.loaded=!0})),e.on(nt.play,(()=>{e.loading=!1})),e.on(nt.fullscreen,(t=>{if(t)try{Cr.request(e.$container).then((()=>{})).catch((t=>{e.debug.error("player","fullscreen request error",t),ra()&&e._opt.useWebFullScreen&&(e.webFullscreen=!0)}))}catch(t){ra()&&e._opt.useWebFullScreen&&(e.webFullscreen=!0)}else try{Cr.exit().then((()=>{e.webFullscreen&&(e.webFullscreen=!1)})).catch((t=>{e.debug.error("player","fullscreen exit error",t),e.webFullscreen&&(e.webFullscreen=!1)}))}catch(t){e.webFullscreen&&(e.webFullscreen=!1)}})),ra()&&e.on(nt.webFullscreen,(t=>{t?e.$container.classList.add("jb-pro-fullscreen-web"):e.$container.classList.remove("jb-pro-fullscreen-web"),e.emit(lt.fullscreen,e.fullscreen)})),e.on(nt.resize,(()=>{e.video&&e.video.resize()})),e._opt.debug){const t=[nt.timeUpdate,nt.currentPts,nt.videoSEI],i=[nt.stats,nt.playbackStats,nt.playbackTimestamp,nt.flvMetaData,nt.playToRenderTimes,nt.audioInfo,nt.videoInfo];Object.keys(nt).forEach((s=>{e.on(nt[s],(function(r){if(!t.includes(s)){i.includes(s)&&(r=JSON.stringify(r));for(var a=arguments.length,o=new Array(a>1?a-1:0),n=1;n<a;n++)o[n-1]=arguments[n];e.debug.log("player events",nt[s],r,...o)}}))})),Object.keys(ct).forEach((t=>{e.on(ct[t],(function(){for(var i=arguments.length,s=new Array(i),r=0;r<i;r++)s[r]=arguments[r];e.debug.warn("player event error",ct[t],...s)}))}))}})(this),this.debug.log(this.TAG_NAME,"observer"),Ah(this),this.debug.log(this.TAG_NAME,"singleWatermark"),this.singleWatermark=new wo(this),this._opt.ghostWatermarkConfig.content){const e=Object.assign({},this._opt.ghostWatermarkConfig,{isGhost:!0});this.ghostWatermark=new Gb(this,e)}this._opt.dynamicWatermarkConfig.content&&(this.dynamicWatermark=new Gb(this,this._opt.dynamicWatermarkConfig)),this._opt.watermarkConfig&&this.updateWatermark(this._opt.watermarkConfig),co()&&(this.pressureObserverCpu=new zb(this)),this._opt.useWCS&&this.debug.log(this.TAG_NAME,"use WCS"),this._opt.useMSE&&(this._opt.mseDecoderUseWorker?this.debug.log(this.TAG_NAME,"use worker MSE"):this.debug.log(this.TAG_NAME,"use MSE")),this._opt.useOffscreen&&this.debug.log(this.TAG_NAME,"use offscreen"),this._opt.isHls&&(this._opt.supportHls265?this.debug.log(this.TAG_NAME,"use hls 265"):this.debug.log(this.TAG_NAME,"use hls")),this._opt.isWebrtc&&(this._opt.isWebrtcH265?this.debug.log(this.TAG_NAME,"use webrtc h265"):this._opt.isWebrtcForZLM?this.debug.log(this.TAG_NAME,"use webrtc for ZLM"):this._opt.isWebrtcForSRS?this.debug.log(this.TAG_NAME,"use webrtc for SRS"):this._opt.isWebrtcForOthers?this.debug.log(this.TAG_NAME,"use webrtc for Others"):this.debug.log(this.TAG_NAME,"use webrtc for M7S")),this.isAliyunRtc()&&this.debug.log(this.TAG_NAME,"use aliyun rtc"),this._opt.isFmp4&&this.debug.log(this.TAG_NAME,"use fmp4"),this._opt.isMpeg4&&this.debug.log(this.TAG_NAME,"use mpeg4"),this.isPlayback()&&this.debug.log(this.TAG_NAME,"use playback"),this._opt.hasVideo&&(0===this.width&&this.debug.warn(this.TAG_NAME,"container width is 0, please check the container width"),0===this.height&&this.debug.warn(this.TAG_NAME,"container height is 0, please check the container height")),this.debug.log("Player options",JSON.stringify(this._opt))}async destroy(){this._destroyed=!0,this.emit(nt.destroy),this.off(),this.events&&(this.events.destroy(),this.events=null),this.clearCheckLoadingTimeout(),this.clearStatsInterval(),this.clearVisibilityHiddenTimeout(),this.decoderWorker&&(await this.decoderWorker.destroy(),this.decoderWorker=null),await this._destroy()}async _destroy(){this._loading=!1,this._playing=!1,this._playbackPause=!1,this._hasLoaded=!1,this._lastVolume=null,this._isMute=null,this._zooming=!1,this._faceDetectActive=!1,this._objectDetectActive=!1,this._occlusionDetectActive=!1,this._imageDetectActive=!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.ghostWatermark&&(this.ghostWatermark.destroy(),this.ghostWatermark=null),this.dynamicWatermark&&(this.dynamicWatermark.destroy(),this.dynamicWatermark=null),this.pressureObserverCpu&&(this.pressureObserverCpu.destroy(),this.pressureObserverCpu=null),this.stream&&(await this.stream.destroy(),this.stream=null),this.hlsDecoder&&(await this.hlsDecoder.destroy(),this.hlsDecoder=null),this.mseDecoder&&(this.mseDecoder.destroy(),this.mseDecoder=null),this.webrtc&&(this.webrtc.destroy(),this.webrtc=null),this.aliyunRtcDecoder&&(this.aliyunRtcDecoder.destroy(),this.aliyunRtcDecoder=null),this.video&&(await this.video.destroy(),this.video=null),this.audio&&(await this.audio.destroy(),this.audio=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.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._latestAudioTimestamp=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._tempStreamList=[],this._tempInnerPlayBgobj={},this._flvMetaData=null,this._flvMetaDataFps=null,this._mseWorkerData={},this.isMSEVideoDecoderInitializationFailedNotSupportHevc=!1,this.isMSEAudioDecoderError=!1,this.isMSEPlaybackRateChangePause=!1,this.isPlayFailedAndPaused=!1,this.debug.log("play","destroy end"),this._opt=null,this.$container=null,this.debug=null}set fullscreen(e){ra()&&this._opt.useWebFullScreen?this.webFullscreen=e:this.emit(nt.fullscreen,e)}get fullscreen(){return Cr.isFullscreen||this.webFullscreen}set webFullscreen(e){this.emit(nt.webFullscreen,e),setTimeout((()=>{this.updateOption({rotate:e?270:0}),this.resize()}),10)}get webFullscreen(){return this.$container.classList.contains("jb-pro-fullscreen-web")}set loaded(e){this._hasLoaded=e}get loaded(){return this._hasLoaded||this.isOldHls()||this.isWebrtcH264()||this._opt.useMSE&&ro(this._opt.hasAudio)&&ro(this._opt.demuxUseWorker)||this._opt.useWCS&&!this._opt.hasAudio&&ro(this._opt.demuxUseWorker)}set playing(e){this.isClosed()&&e?this.debug.log(this.TAG_NAME,"player is closed, so can not play"):(e&&so(this.loading)&&(this.loading=!1),this.playing!==e&&(this._playing=e,this.emit(nt.playing,e),this.emit(nt.volumechange,this.volume),e?this.emit(nt.play):this.emit(nt.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._isMute=0===this.volume):this.debug.warn(this.TAG_NAME,"set volume error, audio is null"))}get lastVolume(){return this._lastVolume}set loading(e){this.loading!==e&&(this._loading=e,this.emit(nt.loading,this._loading))}get loading(){return this._loading}set zooming(e){this.zooming!==e&&(this.zoom||(this.zoom=new Mb(this)),this._zooming=e,this.emit(nt.zooming,this.zooming))}get zooming(){return this._zooming}set recording(e){e?this.playing&&!this.recording&&(this.recorder&&this.recorder.startRecord(),this.isDemuxInWorker()&&this.decoderWorker&&this.decoderWorker.updateWorkConfig({key:"isRecording",value:!0})):this.recording&&(this.isDemuxInWorker()&&this.decoderWorker&&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 latestAudioTimestamp(e){null!==e&&(this._latestAudioTimestamp=e)}get latestAudioTimestamp(){return this._latestAudioTimestamp}get videoTimestamp(){return this._stats.currentPts||this._stats.ts}set streamQuality(e){this.streamQuality!==e&&(this._streamQuality=e,this.emit(nt.streamQualityChange,e))}get streamQuality(){return this._streamQuality}get isDebug(){return so(this._opt.debug)}get scaleType(){const e=this._opt,t=e.isResize,i=e.isFullResize;let s=Gt;return ro(i)&&ro(t)?s=Gt:ro(i)&&so(t)?s=Ht:so(i)&&so(t)&&(s=$t),s}set visibility(e){this._visibility!==e&&(this._visibility=e,this.emit(nt.visibilityChange,e),this._lastestVisibilityChangeTimestamp=Qr(),e?this.clearVisibilityHiddenTimeout():this.startVisibilityHiddenTimeout())}get visibility(){return this._visibility}set playbackPause(e){this._playbackPause!==e&&(this._playbackPause=e,this.emit(nt.playbackPause,e),this.emit(nt.playbackPauseOrResume,e))}get playbackPause(){return this.isPlayback()&&this._playbackPause}set videoIframeIntervalTs(e){this._videoIframeIntervalTs=e}get videoIframeIntervalTs(){return this._videoIframeIntervalTs}set faceDetectActive(e){this._faceDetectActive!==e&&(this._faceDetectActive=e,this.emit(nt.faceDetectActive,e))}get faceDetectActive(){return this._faceDetectActive}set objectDetectActive(e){this._objectDetectActive!==e&&(this._objectDetectActive=e,this.emit(nt.objectDetectActive,e))}get objectDetectActive(){return this._objectDetectActive}set occlusionDetectActive(e){this._occlusionDetectActive!==e&&(this._occlusionDetectActive=e,this.emit(nt.occlusionDetectActive,e))}get occlusionDetectActive(){return this._occlusionDetectActive}set imageDetectActive(e){this._imageDetectActive!==e&&(this._imageDetectActive=e)}get imageDetectActive(){return this._imageDetectActive}get isUseWorkerDemuxAndDecode(){return this.stream&&this.stream.getStreamType()===y}isDestroyed(){return this._destroyed}isClosed(){return this._closed}isDestroyedOrClosed(){return this.isDestroyed()||this.isClosed()}isPlaying(){let e=!1;return this._opt.playType===b?e=this.playing:this._opt.playType===v&&(e=ro(this.playbackPause)&&this.playing),e}updateOption(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this._opt=Object.assign({},this._opt,e),so(t)&&this.decoderWorker&&Object.keys(e).forEach((t=>{this.decoderWorker.updateWorkConfig({key:t,value:e[t]})}))}init(){return new Promise(((e,t)=>{this.video||this._opt.hasVideo&&(this.video=new Uo(this)),this.audio||this._opt.hasAudio&&(this.audio=new tn(this)),this.stream||(this.stream=new cn(this)),this.isOldHls()?(this.hlsDecoder||(this.hlsDecoder=new lA(this),this.loaded=!0),e()):this.isWebrtcH264()?(this.webrtc||(this._opt.isWebrtcForZLM?this.webrtc=new Bb(this):this._opt.isWebrtcForSRS?this.webrtc=new Ob(this):this._opt.isWebrtcForOthers?this.webrtc=new Nb(this):this.webrtc=new Pb(this),this.loaded=!0),e()):this.isAliyunRtc()?(this.aliyunRtcDecoder||(this.aliyunRtcDecoder=new jb(this),this.loaded=!0),e()):(this.demux||this._opt.hasVideo&&!this.isUseWorkerDemuxAndDecode&&(this.demux=new Xd(this)),this._opt.useWCS&&(this.webcodecsDecoder||(this.webcodecsDecoder=new Zd(this))),this._opt.useMSE&&ro(this._opt.mseDecoderUseWorker)&&(this.mseDecoder||(this.mseDecoder=new kh(this))),this.isUseHls265()&&(this.hlsDecoder||(this.hlsDecoder=new Db(this))),this.isWebrtcH265()&&(this.webrtc||(this.webrtc=new Pb(this))),this.decoderWorker?this.loaded?e():this.once(nt.decoderWorkerInit,(()=>{this.isDestroyedOrClosed()?(this.debug.error(this.TAG_NAME,"init() failed and player is destroyed"),t("init() failed and player is destroyed")):(this.loaded=!0,e())})):Va(this._opt)?e():(this.decoderWorker=new Qn(this),this.once(nt.decoderWorkerInit,(()=>{this.isDestroyedOrClosed()?(this.debug.error(this.TAG_NAME,"init() failed and player is destroyed"),t("init() failed and player is destroyed")):(this.loaded=!0,e())}))))}))}play(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(((i,s)=>{if(!e&&!this._opt.url)return s("url is empty");this._closed=!1,this.loading=!0,this.playing=!1,this._times.playInitStart=Qr(),e||(e=this._opt.url),this._opt.url=e,this.control&&this._opt.loadingBackground&&this.control.initLoadingBackground(),this.init().then((()=>{this.debug.log(this.TAG_NAME,"play() init and next fetch stream"),this._times.playStart=Qr(),this._opt.isNotMute&&this.mute(!1),this.enableWakeLock(),this.checkLoadingTimeout(),this.stream?(this.stream.once(ct.fetchError,(e=>{this.emitError(ct.fetchError,e)})),this.stream.once(ct.websocketError,(e=>{this.emitError(ct.websocketError,e)})),this.stream.once(nt.streamEnd,(e=>{this.emit(nt.streamEnd,e)})),this.stream.once(ct.hlsError,(e=>{this.emitError(ct.hlsError,e)})),this.stream.once(ct.webrtcError,(e=>{this.emitError(ct.webrtcError,e)})),this.stream.once(nt.streamSuccess,(()=>{i(),this._times.streamResponse=Qr(),this.video&&this.video.play(),this.checkStatsInterval(),this.isPlayback()&&this.playback&&this.playback.startCheckStatsInterval()})),this.stream.fetchStream(e,t)):(this.debug.warn(this.TAG_NAME,`play() this.stream is null and is isDestroyedOrClosed is ${this.isDestroyedOrClosed()}`),s("this.stream is null"))})).catch((e=>{s(e)}))}))}playForControl(){return new Promise(((e,t)=>{this.debug.log(this.TAG_NAME,`playForControl() and pauseAndNextPlayUseLastFrameShow is ${this._opt.pauseAndNextPlayUseLastFrameShow}`),this._opt.pauseAndNextPlayUseLastFrameShow&&this._tempInnerPlayBgobj&&this._tempInnerPlayBgobj.loadingBackground&&this.updateOption({loadingBackground:this._tempInnerPlayBgobj.loadingBackground,loadingBackgroundWidth:this._tempInnerPlayBgobj.loadingBackgroundWidth,loadingBackgroundHeight:this._tempInnerPlayBgobj.loadingBackgroundHeight}),this.play().then((t=>{e(t)})).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&&ro(this._isMute)&&(this.volume=this.lastVolume)}async _close(){this._closed=!0,this.video&&(this.video.resetInit(),this.video.pause(!0)),this.loading=!1,this.recording=!1,this.zooming=!1,this.playing=!1,this.clearCheckLoadingTimeout(),this.clearStatsInterval(),this.isPlayback()&&this.playback&&this.playback.clearStatsInterval(),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&&(await this.decoderWorker.destroy(),this.decoderWorker=null),this.stream&&(await 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&&(await this.hlsDecoder.destroy(),this.hlsDecoder=null),this.webrtc&&(this.webrtc.destroy(),this.webrtc=null),this.aliyunRtcDecoder&&(this.aliyunRtcDecoder.destroy(),this.aliyunRtcDecoder=null),this.audio&&(await this.audio.destroy(),this.audio=null)}pause(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return new Promise(((t,i)=>{e?this.close().then((()=>{t()})).catch((e=>{i(e)})):this._close().then((()=>{t()})).catch((e=>{i(e)}))}))}pauseForControl(){return new Promise(((e,t)=>{if(this.debug.log(this.TAG_NAME,"_pauseInner()"),this._opt.pauseAndNextPlayUseLastFrameShow&&this.video){const e=this.video.screenshot("","png",.92,"base64");if(e){const t=this.getVideoInfo();t?(this.debug.log(this.TAG_NAME,`pauseForControl() and loadingBackground width is ${t.width} and height is ${t.height}`),this._tempInnerPlayBgobj={loadingBackground:e,loadingBackgroundWidth:t.width,loadingBackgroundHeight:t.height}):this.debug.warn(this.TAG_NAME,"pauseForControl() and videoInfo is null")}else this.debug.warn(this.TAG_NAME,"pauseForControl() and loadingBackground is null")}this.pause().then((t=>{e(t)})).catch((e=>{t(e)}))}))}isAudioMute(){let e=!0;return this.audio&&(e=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,t){return new Promise(((i,s)=>{this.recorder||s("recorder is null"),this.recording?(this._opt.useWasm&&this.decoderWorker&&this.decoderWorker.updateWorkConfig({key:"isRecording",value:!1}),this.recorder.stopRecordAndSave(e,t).then((e=>{i(e)})).catch((e=>{s(e)}))):s("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),this._opt.extendOperateBtns&&this._opt.extendOperateBtns.length>0&&(e=!0),this.isPlayback()&&this._opt.playbackConfig.showControl&&(e=!0),this._opt.controlHtml&&(e=!0),e}useWasmDecode(){return ro(this._opt.useMSE)&&ro(this._opt.useWCS)}canVideoTrackWritter(){const e=this._opt;return!this.isOldHls()&&!this.isWebrtcH264()&&ro(e.useMSE)&&!this.isAliyunRtc()&&(e.useWCS&&ro(e.useOffscreen)&&e.wcsUseVideoRender||this.useWasmDecode())}checkHeartTimeout$2(){if(ro(this.playbackPause)&&this.playing){if(this.isDestroyedOrClosed())return void(this.debug&&this.debug.warn(this.TAG_NAME,"checkHeartTimeout$2 but player is destroyed"));if(ro(this.isHistoryFpsListAllZero()))return void(this.debug&&this.debug.warn(this.TAG_NAME,"checkHeartTimeout$2 but fps is not all zero"));if(0!==this._stats.fps)return void(this.debug&&this.debug.warn(this.TAG_NAME,`checkHeartTimeout$2 but fps is ${this._stats.fps}`));if(ro(this.visibility)&&0!==this._stats.vbps)return void(this.debug&&this.debug.warn(this.TAG_NAME,`checkHeartTimeout$2 but page is not visibility and vbps is ${this._stats.vbps}`));const e=this._historyFpsList.join(",");this.debug.warn(this.TAG_NAME,`checkHeartTimeout$2 and\n pause and emit delayTimeout event and\n current vbps is ${this._stats.vbps} and\n current fps is ${this._stats.fps} and\n history FpsList is ${e} and\n current visibility is ${this.visibility} and`),this.emit(nt.timeout,nt.delayTimeout),this.emit(nt.delayTimeout)}else this.debug.log(this.TAG_NAME,`checkHeartTimeout$2 playbackPause is ${this.playbackPause}, playing is ${this.playing}`)}checkStatsInterval(){this._checkStatsInterval=setInterval((()=>{this.updateStats()}),1e3)}checkLoadingTimeout(){this._checkLoadingTimeout=setTimeout((()=>{this.playing?this.debug.warn(this.TAG_NAME,`checkLoadingTimeout but loading is ${this.loading} and playing is ${this.playing}`):this.isDestroyedOrClosed()?this.debug&&this.debug.warn(this.TAG_NAME,"checkLoadingTimeout but player is destroyed"):(this.debug.warn(this.TAG_NAME,"checkLoadingTimeout and pause and emit loadingTimeout event"),this.emit(nt.timeout,nt.loadingTimeout),this.emit(nt.loadingTimeout))}),1e3*this._opt.loadingTimeout)}clearCheckLoadingTimeout(){this._checkLoadingTimeout&&(this.debug.log(this.TAG_NAME,"clearCheckLoadingTimeout"),clearTimeout(this._checkLoadingTimeout),this._checkLoadingTimeout=null)}clearStatsInterval(){this._checkStatsInterval&&(clearInterval(this._checkStatsInterval),this._checkStatsInterval=null)}handleRender(){this.isDestroyedOrClosed()?this.debug&&this.debug.warn(this.TAG_NAME,"handleRender but player is destroyed"):(this.loading&&(this.clearCheckLoadingTimeout(),this.loading=!1,this.emit(nt.start)),this.playing||(this.playing=!0))}updateStats(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this._startBpsTime||(this._startBpsTime=Qr()),Ta(e.ts)){const t=parseInt(e.ts,10);this._stats.ts=t,null===this._playingStartTimestamp&&t>0&&(this._playingStartTimestamp=t)}Ta(e.dts)&&(this._stats.dts=parseInt(e.dts,10)),Ta(e.mseTs)&&(this._stats.mseTs=e.mseTs),Ta(e.buf)&&(this._stats.buf=e.buf),Ta(e.netBuf)&&(this._stats.netBuf=e.netBuf),Ta(e.currentPts)&&(this._stats.currentPts=e.currentPts),e.fps&&(this._stats.fps+=1),e.dfps&&(this._stats.dfps+=1),e.abps&&(this._stats.abps+=e.abps),e.vbps&&(this._stats.vbps+=e.vbps),e.workerStats&&(this._tempWorkerStats=e.workerStats),e.isDropping&&(this._stats.isDropping=e.isDropping),e.mseVideoBufferDelayTime&&(this._stats.mseVideoBufferDelayTime=parseInt(1e3*e.mseVideoBufferDelayTime,10));const t=Qr();if(t-this._startBpsTime<1e3)return;null!==this._playingStartTimestamp&&this._stats.fps>0&&(this._stats.pTs+=1);let i=0,s=0,r=0,a=0,o=0;this._opt.useMSE&&(this.mseDecoder?(i=this.mseDecoder.checkSourceBufferDelay(),i=parseInt(1e3*i,10),s=this.mseDecoder.checkSourceBufferStore(),s=s.toFixed(2),r=this.mseDecoder.getDecodeDiffTimes(),a=this.mseDecoder.getDecodePlaybackRate(),o=this.mseDecoder.getPendingSegmentsLength()):this.isMseDecoderUseWorker()&&(i=this.video.checkSourceBufferDelay(),i=parseInt(1e3*i,10),s=this.video.checkSourceBufferStore(),s=s.toFixed(2),a=this.video.getDecodePlaybackRate())),this._opt.useWCS&&this.webcodecsDecoder&&(r=this.webcodecsDecoder.getDecodeDiffTimes()),this.isOldHls()&&this.hlsDecoder&&(i=this.hlsDecoder.checkHlsBufferedDelay(),i=parseInt(1e3*i,10));let n=0,l=0,d=0;this.isUseHls265()&&this.hlsDecoder&&(i=this.hlsDecoder.checkHlsBufferedDelay(),i=i.toFixed(2),n=this.hlsDecoder.getDemuxBufferedListLength(),d=this.hlsDecoder.getDemuxVideoBufferedListLength(),l=this.hlsDecoder.getDemuxAudioBufferedListLength());let h=0,c=0,u=0,p=!1,f=0;this._opt.useWasm||this._opt.demuxUseWorker?this._tempWorkerStats&&(c=this._tempWorkerStats.demuxBufferDelay,u=this._tempWorkerStats.audioDemuxBufferDelay,h=this._tempWorkerStats.streamBufferByteLength,this._stats.netBuf=this._tempWorkerStats.netBuf,f=this._tempWorkerStats.pushLatestDelay,p=this._tempWorkerStats.isStreamTsMoreThanLocal,this._stats.buf=this._tempWorkerStats.latestDelay):this.demux&&(h=this.demux.getInputByteLength(),f=this.demux.getPushLatestDelay(),p=this.demux.getIsStreamTsMoreThanLocal(),this.demux.bufferList&&(c=this.demux.bufferList.length));let m=0,g=0;this.audio&&this.audio.bufferList&&(m=this.audio.bufferList.length,g=parseInt(m*this.audio.oneBufferDuration,10));let y=0,A=0;if(this.isPlayback()&&this.video){this._opt.playbackConfig.isUseFpsRender&&(y=this.video.bufferList&&this.video.bufferList.length||0);let e=this.video.getStreamFps();const t=e>0?1e3/e:0;A=parseInt(t*y+t*c,10)}let b=0;this.videoTimestamp>0&&(b=this._stats.dts-this.videoTimestamp);const _=b+this._stats.netBuf;this.isOldHls()&&(this._stats.fps=this.hlsDecoder.getFps()),this._stats.fps>this._stats.maxFps&&(this._stats.maxFps=this._stats.fps);let v=this.getVideoCurrentTime();const S=this._stats.videoCurrentTime;let w=-1;S&&v&&(w=(v-S).toFixed(2),v=v.toFixed(2));let E=0;this.audioTimestamp>0&&(E=this.audioTimestamp-this.getRenderCurrentPts()),this._allStatsData=Object.assign(this._stats,{audioBuffer:m,audioBufferDelayTs:g,audioTs:this.audioTimestamp,latestAudioTs:this.latestAudioTimestamp,playbackVideoBuffer:y,playbackVideoWaitingBuffer:0,playbackAudioWaitingBuffer:0,playbackCacheDataDuration:A,demuxBuffer:c,pushLatestDelay:f,audioDemuxBuffer:u,streamBuffer:h,mseDelay:i,mseStore:s,mseDecodeDiffTimes:r,mseDecodePlaybackRate:a,msePendingBuffer:o,wcsDecodeDiffTimes:r,hlsDelay:i,hlsDemuxLength:n,hlsDemuxAudioLength:l,hlsDemuxVideoLength:d,delayTs:b,totalDelayTs:_,isStreamTsMoreThanLocal:p,videoCurrentTime:v,videoCurrentTimeDiff:w,audioSyncVideo:E});let k=null,C=null,R="";if(this.isPlayer()&&this._opt.hasVideo&&this.playing){k=function(e,t){let i=3;const s=t||25;return e<.33*s?i=0:e<.5*s?i=1:e<.83*s&&(i=2),i}(this._stats.fps,this._flvMetaDataFps),this._allStatsData.performance=k;const e=this.checkVideoSmooth(this._allStatsData);R=e.reason,C=e.result,this._allStatsData.videoSmooth=C}this.emit(nt.stats,this._allStatsData),this._allStatsData.streamBuffer>this._opt.flvDemuxBufferSizeMaxLarge&&this.getDemuxType()===T&&this.emit(ct.flvDemuxBufferSizeTooLarge,this._allStatsData.streamBuffer),this._opt.hasVideo?(this.updateHistoryFpsList(this._stats.fps,this._stats.videoCurrentTimeDiff),Ta(k)&&this.emit(nt.performance,k),Ta(C)&&this.emit(nt.videoSmooth,C,R)):this._opt.hasAudio&&this.updateHistoryFpsList(this._stats.abps,0),this._stats.fps=0,this._stats.dfps=0,this._stats.abps=0,this._stats.vbps=0,this._stats.isDropping=!1,this._startBpsTime=t}resetStats(){this._startBpsTime=null,this._playingStartTimestamp=null,this._historyFpsList=[],this._historyVideoDiffList=[],this._stats={buf:0,netBuf:0,fps:0,maxFps:0,dfps:0,abps:0,vbps:0,ts:0,mseTs:0,currentPts:0,pTs:0,dts:0,mseVideoBufferDelayTime:0,isDropping:!1},this._allStatsData={}}checkVideoSmooth(e){let t=!0,i="";if(this._opt.videoBuffer,this._opt.videoBufferDelay,this.isWebrtcH264()||this.isOldHls())return{result:t,reason:i};if(0===e.vbps&&ro(this._opt.isHls)&&(i="vbpsIsZero",this.debug.log(this.TAG_NAME,`checkVideoSmooth false because ${i}`),t=!1),t&&e.isDropping&&(i="isDroppingIsTrue",this.debug.log(this.TAG_NAME,`checkVideoSmooth false because ${i}`),t=!1),t&&this.visibility&&this._historyFpsList.length>=this._opt.heartTimeout){const s=function(e){const t=Math.max(...e),i=Math.min(...e);return e.filter((e=>e!==t&&e!==i))}(this._historyFpsList),r=s.reduce(((e,t)=>e+t),0)/s.length,a=.83*r;e.fps<a&&(i="fpsIsLow",this.debug.log(this.TAG_NAME,`checkVideoSmooth false because fps is ${e.fps} < min fix is ${a} and avgFps is ${r}`),t=!1)}return t&&this.visibility&&this._opt.useMSE&&(e.videoCurrentTimeDiff>=1.5||e.videoCurrentTimeDiff<=.5)&&-1!==e.videoCurrentTimeDiff&&(i="videoCurrentTimeDiffIsNotNormal",this.debug.log(this.TAG_NAME,`checkVideoSmooth false because videoCurrentTimeDiff is ${e.videoCurrentTimeDiff}`),t=!1),{result:t,reason:i}}enableWakeLock(){this._opt.keepScreenOn&&this.keepScreenOn&&this.keepScreenOn.enable()}releaseWakeLock(){this._opt.keepScreenOn&&this.keepScreenOn&&this.keepScreenOn.disable()}clearBufferDelay(){this._opt.useWasm?this.decoderWorker&&this.decoderWorker.clearWorkBuffer(!0):this.demux&&this.demux.clearBuffer(!0)}doDestroy(){this.emit(nt.beforeDestroy)}handlePlayToRenderTimes(){if(this.isDestroyedOrClosed())return void this.debug.log(this.TAG_NAME,"handlePlayToRenderTimes but player is closed or destroyed");const e=this.getPlayToRenderTimes();this.emit(nt.playToRenderTimes,e)}getPlayToRenderTimes(){const e=this._times;return e.playTimestamp=e.playStart-e.playInitStart,e.streamTimestamp=e.streamStart-e.playStart,e.streamResponseTimestamp=e.streamResponse-e.streamStart>0?e.streamResponse-e.streamStart:0,e.demuxTimestamp=e.demuxStart-e.streamResponse>0?e.demuxStart-e.streamResponse:0,e.decodeTimestamp=e.decodeStart-e.demuxStart>0?e.decodeStart-e.demuxStart:0,e.videoTimestamp=e.videoStart-e.decodeStart,e.allTimestamp=e.videoStart-e.playInitStart,e}getOption(){return this._opt}getPlayType(){return this._opt.playType}isPlayer(){return this._opt.playType===b}isPlayback(){return this._opt.playType===v}isDemuxSetCodecInit(){let e=!0,t=this._opt;return t.useWCS&&!t.useOffscreen?e=!!this.webcodecsDecoder&&this.webcodecsDecoder.hasInit:t.useMSE&&(e=!!this.mseDecoder&&this.mseDecoder.hasInit),e}isDemuxDecodeFirstIIframeInit(){let e=!0,t=this._opt;return t.useWCS&&!t.useOffscreen?e=!!this.webcodecsDecoder&&this.webcodecsDecoder.isDecodeFirstIIframe:t.useMSE&&(e=!!this.mseDecoder&&this.mseDecoder.isDecodeFirstIIframe),e}isAudioPlaybackRateSpeed(){let e=!1;return this.audio&&(e=this.audio.isPlaybackRateSpeed()),e}getPlayingTimestamp(){return this._stats.pTs}getRecordingType(){let e=null;return this.recorder&&(e=this.recorder.getType()),e}getRecordingByteLength(){let e=0;return this.recording&&(e=this.recorder.getToTalByteLength()),e}getRecordingDuration(){let e=0;return this.recording&&(e=this.recorder.getTotalDuration()),e}getDecodeType(){let e="";const t=this.getOption();return this.isWebrtcH264()?G:this.isAliyunRtc()?$:this.isOldHls()?H:(t.useMSE&&(e+=U+" ",t.mseDecoderUseWorker&&(e+="worker")),t.useWCS&&(e+=F+" "),t.useWasm&&(e+=N+" ",t.useSIMD&&(e+=j+" "),t.useMThreading&&(e+=z+" ")),t.useOffscreen&&(e+=O+" "),e)}getDemuxType(){return this._opt.demuxType}getRenderType(){let e="";return this.video&&(e=this.video.getType()),e}getCanvasRenderType(){let e="";return this.video&&(e=this.video.getCanvasType()),e}getAudioEngineType(){let e="";return this.audio&&(e=this.audio.getEngineType()),e}getStreamType(){let e="";return this.stream&&(e=this.stream.getStreamType()),e}getAllStatsData(){return this._allStatsData}isFlvDemux(){return this._opt.demuxType===T}isM7SDemux(){return this._opt.demuxType===k}isNakedFlowDemux(){return this._opt.demuxType===D}isMpeg4Demux(){return this._opt.demuxType===P}isTsDemux(){return this._opt.demuxType===I}isFmp4Demux(){return this._opt.demuxType===L}togglePerformancePanel(e){this.updateOption({showPerformance:e}),this.emit(nt.togglePerformancePanel,e)}setScaleMode(e){let t={isFullResize:!1,isResize:!1,aspectRatio:"default"};switch(e=Number(e)){case Gt:t.isFullResize=!1,t.isResize=!1;break;case Ht:t.isFullResize=!1,t.isResize=!0;break;case $t:t.isFullResize=!0,t.isResize=!0}this.updateOption(t),this.resize(),this.emit(nt.viewResizeChange,e)}startVisibilityHiddenTimeout(){this.clearVisibilityHiddenTimeout(),this._opt.pageVisibilityHiddenTimeout>0&&(this.visibilityHiddenTimeout=setTimeout((()=>{this.emit(nt.visibilityHiddenTimeout)}),1e3*this._opt.pageVisibilityHiddenTimeout))}clearVisibilityHiddenTimeout(){this._checkVisibleHiddenTimeout&&(clearTimeout(this._checkVisibleHiddenTimeout),this._checkVisibleHiddenTimeout=null)}faceDetect(e){this.faceDetectActive=e,ro(e)&&this.video&&this.video.addAiContentToCanvas([])}objectDetect(e){this.objectDetectActive=e,ro(e)&&this.video&&this.video.addAiContentToCanvas([])}occlusionDetect(e){this.occlusionDetectActive=e}downloadNakedFlowFile(){this.demux&&this.demux.downloadNakedFlowFile&&this.demux.downloadNakedFlowFile()}downloadFmp4File(){this.demux&&this.demux.downloadFmp4File&&this.demux.downloadFmp4File()}downloadMpeg4File(){const e=new Blob([this._tempStreamList]);try{const t=document.createElement("a");t.href=window.URL.createObjectURL(e),t.download=Date.now()+".mpeg4",t.click(),window.URL.revokeObjectURL(t.href)}catch(e){console.error("downloadMpeg4File",e)}}hasCacheOnGopBuffer(){const e=this.videoIframeIntervalTs,t=this._allStatsData.demuxBuffer,i=this._allStatsData.maxFps;let s=!1;if(e&&t&&i){s=1e3/i*t>e}return s}addContentToCanvas(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.video&&this.video.addContentToCanvas(e)}addContentToContainer(){}sendWebsocketMessage(e){const t=this.getStreamType();t===f||t===y+" "+f?this.stream.sendMessage(e):this.debug.warn(this.TAG_NAME,`sendWebsocketMessage: stream type is not websocket, current stream type is ${this.getStreamType()}`)}checkIsInRender(){const e=this._stats;return e.vbps>0&&e.fps>0}setControlHtml(e){this.control&&this.control.$controlHtml&&(this.control.$controlHtml.innerHTML=e)}clearControlHtml(){this.control&&this.control.$controlHtml&&(this.control.$controlHtml.innerHTML="")}updateWatermark(e){this.singleWatermark&&this.singleWatermark.update(e)}removeWatermark(){this.singleWatermark&&this.singleWatermark.remove()}getVideoInfo(){let e=null;return this.video&&(e=this.video.getVideoInfo()),e}getAudioInfo(){let e=null;return this.audio&&(e=this.audio.getAudioInfo()),e}getVideoPlaybackQuality(){let e=null;return this.video&&(e=this.video.getPlaybackQuality()),e}emitError(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";this.emit(nt.error,e,t),this.emit(e,t)}updateHistoryFpsList(e,t){this.playbackPause||(this._historyFpsList.length>this._opt.heartTimeout&&(this._historyFpsList.shift(),this._historyVideoDiffList.shift()),this._historyFpsList.push(e),this._historyVideoDiffList.push(t),this.isHistoryFpsListAllZero()&&this.checkHeartTimeout$2())}isHistoryFpsListAllZero(){let e=!0;if(this._historyFpsList.length<this._opt.heartTimeout&&(e=!1),e)for(let t=0;t<this._historyFpsList.length;t++)if(this._historyFpsList[t]>0){e=!1;break}if(e)for(let t=0;t<this._historyVideoDiffList.length;t++)if(this._historyVideoDiffList[t]>0){e=!1;break}return e}isUseHls265(){return so(this._opt.isHls)&&so(this._opt.supportHls265)}isHls(){return so(this._opt.isHls)}isOldHls(){return so(this._opt.isHls)&&ro(this._opt.supportHls265)}isWebrtcNotH265(){return so(this._opt.isWebrtc)&&ro(this._opt.isWebrtcH265)}isWebrtcH264(){return so(this._opt.isWebrtc)&&ro(this._opt.isWebrtcH265)}isWebrtcH265(){return so(this._opt.isWebrtc)&&so(this._opt.isWebrtcH265)}isAliyunRtc(){return so(this._opt.isAliyunRtc)}isUseHls265UseMse(){return this.isUseHls265()&&this.isUseMSE()}isStreamWebTransport(){return this.getStreamType()===g}isPlaybackCacheBeforeDecodeForFpsRender(){return this.isPlayback()&&so(this._opt.playbackConfig.isCacheBeforeDecodeForFpsRender)&&so(this._opt.useWCS)}isPlaybackUseWCS(){return this.isPlayback()&&so(this._opt.useWCS)}isPlaybackUseMSE(){return this.isPlayback()&&so(this._opt.useMSE)}isPlayUseMSE(){return this.isPlayer()&&so(this._opt.useMSE)}isInWebFullscreen(){return this._opt.useWebFullScreen&&ra()&&this.fullscreen}getPlaybackRate(){let e=1;return so(this.isPlayback())&&this.playback&&(e=this.playback.rate),e}isPlaybackOnlyDecodeIFrame(){return so(this.isPlayback())&&this.getPlaybackRate()>=this._opt.playbackForwardMaxRateDecodeIFrame}pushTempStream(e){const t=new Uint8Array(e);this._tempStreamList.push(t)}updateLoadingText(e){this.loading&&this.control&&this.control.updateLoadingText(e)}getVideoCurrentTime(){let e=0;return this.video&&(this._opt.useMSE?this.mseDecoder?e=this.mseDecoder.getVideoCurrentTime():this.isMseDecoderUseWorker()&&(e=this.video.getVideoCurrentTime()):this.isWebrtcH264()&&this.webrtc?e=this.webrtc.getVideoCurrentTime():this.isAliyunRtc()&&this.aliyunRtcDecoder&&(e=this.aliyunRtcDecoder.getVideoCurrentTime())),e}addMemoryLog(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),s=1;s<t;s++)i[s-1]=arguments[s];this.emit(nt.memoryLog,` [${e}] `,...i)}downloadMemoryLog(){this.emit(nt.downloadMemoryLog)}isInMulti(){return-1!==this._opt.multiIndex}isWebrtcForM7S(){return ro(this._opt.isWebrtcForZLM)&&ro(this._opt.isWebrtcForSRS)&&ro(this._opt.isWebrtcForOthers)}updateMetaData(e){if(this.debug.log(this.TAG_NAME,"updateMetaData",JSON.stringify(e)),this._flvMetaData=e,this._flvMetaData){const e=this._flvMetaData;if(ya(e.framerate)){const t=Math.floor(1e3*e.framerate);if(t>0){const e=t/1e3;this._flvMetaDataFps=e}}Ea(e.hasAudio)&&ro(e.hasAudio)&&(this.debug.log("updateMetaData","hasAudio",e.hasAudio,"and update _opt.hasAudio"),this._opt.hasAudio=e.hasAudio),Ea(e.hasVideo)&&ro(e.hasVideo)&&(this.debug.log("updateMetaData","hasVideo",e.hasVideo,"and update _opt.hasVideo"),this._opt.hasVideo=e.hasVideo)}this.emit(nt.flvMetaData,e)}getMetaData(){return this._flvMetaData}getExtendBtnList(){return this.control.getExtendBtnList().map((e=>({name:e.name,$container:e.$iconContainer,$btn:e.$iconWrap,$activeBtn:e.$activeIconWrap})))}getCpuLevel(){let e=null;return this.pressureObserverCpu&&(e=this.pressureObserverCpu.getCurrentCpuState()),e}isRecordTypeFlv(){return this.recorder&&this._opt.recordType===E}isRecordTypeMp4(){return this.recorder&&this._opt.recordType===S}isRecordTypeWebm(){return this.recorder&&this._opt.recordType===w}isDemuxInWorker(){return this._opt.useWasm||this._opt.demuxUseWorker}isUseMSE(){return so(this._opt.useMSE)}isUseWCS(){return so(this._opt.useWCS)}isUseWASM(){return so(this._opt.useWasm)}isMseDecoderUseWorker(){return this.isUseMSE()&&so(this._opt.mseDecoderUseWorker)}getAudioSyncVideoDiff(){return this.audioTimestamp-this.getRenderCurrentPts()}getMseVideoBufferDelayTime(){let e=0;return this._opt.useMSE&&this.mseDecoder&&(this.mseDecoder?e=this.mseDecoder.getVideoBufferDelayTime():this.isMseDecoderUseWorker()&&(e=this.video.getVideoBufferDelayTime()),e=parseInt(1e3*e,10)),e}updateCurrentPts(e){this.updateStats({currentPts:e}),this.emit(nt.currentPts,e)}getRenderCurrentPts(){let e=0;return e=this._stats.currentPts?this._stats.currentPts:this.videoTimestamp-this.getMseVideoBufferDelayTime(),e}openSyncAudioAndVideo(){return this._opt.syncAudioAndVideo&&this._opt.hasVideo}showTipsMessageByCode(e){if(this.control){const t=this._opt.showMessageConfig[e]||"未知异常";this.control.showTipsMessage(t,e)}}showTipsMessageByContent(e){this.control&&e&&this.control.showTipsMessage(e)}hideTipsMessage(){this.control&&this.control.hideTipsMessage()}decoderCheckFirstIFrame(){so(this._opt.checkFirstIFrame)&&(this.mseDecoder?this.mseDecoder.isDecodeFirstIIframe=!1:this.webcodecsDecoder&&(this.webcodecsDecoder.isDecodeFirstIIframe=!1))}isHlsCanVideoPlay(){return this._canPlayAppleMpegurl&&this.isOldHls()}setPtzPosition(e){this.control&&this.control.updatePtzPosition(e)}setPlayFailedAndPaused(){this.isPlayFailedAndPaused=!0}getMseMineType(){let e={};return this.mseDecoder&&(e=this.mseDecoder.getMimeType()),e}getMaxDelayTs(){return this._opt.videoBuffer+this._opt.videoBufferDelay}isMseVideoStateInited(){return!this.video||this.video.getReadyStateInited()}}class $b{constructor(e){const{fromSampleRate:t,toSampleRate:i,channels:s,inputBufferSize:r}=e;if(!t||!i||!s)throw new Error("Invalid settings specified for the resampler.");this.resampler=null,this.fromSampleRate=t,this.toSampleRate=i,this.channels=s||0,this.inputBufferSize=r,this.initialize()}initialize(){this.fromSampleRate==this.toSampleRate?(this.resampler=e=>e,this.ratioWeight=1):(this.fromSampleRate<this.toSampleRate?(this.linearInterpolation(),this.lastWeight=1):(this.multiTap(),this.tailExists=!1,this.lastWeight=0),this.initializeBuffers(),this.ratioWeight=this.fromSampleRate/this.toSampleRate)}bufferSlice(e){try{return this.outputBuffer.subarray(0,e)}catch(t){try{return this.outputBuffer.length=e,this.outputBuffer}catch(t){return this.outputBuffer.slice(0,e)}}}initializeBuffers(){this.outputBufferSize=Math.ceil(this.inputBufferSize*this.toSampleRate/this.fromSampleRate/this.channels*1.0000004768371582)+this.channels+this.channels;try{this.outputBuffer=new Float32Array(this.outputBufferSize),this.lastOutput=new Float32Array(this.channels)}catch(e){this.outputBuffer=[],this.lastOutput=[]}}linearInterpolation(){this.resampler=e=>{let t,i,s,r,a,o,n,l,d,h=e.length,c=this.channels;if(h%c!=0)throw new Error("Buffer was of incorrect sample length.");if(h<=0)return[];for(t=this.outputBufferSize,i=this.ratioWeight,s=this.lastWeight,r=0,a=0,o=0,n=0,l=this.outputBuffer;s<1;s+=i)for(a=s%1,r=1-a,this.lastWeight=s%1,d=0;d<this.channels;++d)l[n++]=this.lastOutput[d]*r+e[d]*a;for(s-=1,h-=c,o=Math.floor(s)*c;n<t&&o<h;){for(a=s%1,r=1-a,d=0;d<this.channels;++d)l[n++]=e[o+(d>0?d:0)]*r+e[o+(c+d)]*a;s+=i,o=Math.floor(s)*c}for(d=0;d<c;++d)this.lastOutput[d]=e[o++];return this.bufferSlice(n)}}multiTap(){this.resampler=e=>{let t,i,s,r,a,o,n,l,d,h,c,u=e.length,p=this.channels;if(u%p!=0)throw new Error("Buffer was of incorrect sample length.");if(u<=0)return[];for(t=this.outputBufferSize,i=[],s=this.ratioWeight,r=0,o=0,n=0,l=!this.tailExists,this.tailExists=!1,d=this.outputBuffer,h=0,c=0,a=0;a<p;++a)i[a]=0;do{if(l)for(r=s,a=0;a<p;++a)i[a]=0;else{for(r=this.lastWeight,a=0;a<p;++a)i[a]=this.lastOutput[a];l=!0}for(;r>0&&o<u;){if(n=1+o-c,!(r>=n)){for(a=0;a<p;++a)i[a]+=e[o+(a>0?a:0)]*r;c+=r,r=0;break}for(a=0;a<p;++a)i[a]+=e[o++]*n;c=o,r-=n}if(0!==r){for(this.lastWeight=r,a=0;a<p;++a)this.lastOutput[a]=i[a];this.tailExists=!0;break}for(a=0;a<p;++a)d[h++]=i[a]/s}while(o<u&&h<t);return this.bufferSlice(h)}}resample(e){return this.fromSampleRate==this.toSampleRate?this.ratioWeight=1:(this.fromSampleRate<this.toSampleRate?this.lastWeight=1:(this.tailExists=!1,this.lastWeight=0),this.initializeBuffers(),this.ratioWeight=this.fromSampleRate/this.toSampleRate),this.resampler(e)}}const Vb=15,Wb=4,Jb=132,qb=[255,511,1023,2047,4095,8191,16383,32767];function Kb(e,t,i){for(let s=0;s<i;s++)if(e<=t[s])return s;return i}function Yb(e){const t=[];return Array.prototype.slice.call(e).forEach(((e,i)=>{t[i]=function(e){let t,i,s;return e>=0?t=213:(t=85,(e=-e-1)<0&&(e=32767)),i=Kb(e,qb,8),i>=8?127^t:(s=i<<Wb,s|=i<2?e>>4&Vb:e>>i+3&Vb,s^t)}(e)})),t}function Qb(e){const t=[];return Array.prototype.slice.call(e).forEach(((e,i)=>{t[i]=function(e){let t=0;e<0?(e=Jb-e,t=127):(e+=Jb,t=255);let i=Kb(e,qb,8);return i>=8?127^t:(i<<4|e>>i+3&15)^t}(e)})),t}class Xb extends po{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),this._opt={},e&&(this.player=e),this.TAG_NAME="talk";const i=Za(ks);this._opt=Object.assign({},i,t),this._opt.sampleRate=parseInt(this._opt.sampleRate,10),this._opt.sampleBitsWidth=parseInt(this._opt.sampleBitsWidth,10),this.audioContext=null,this.gainNode=null,this.recorder=null,this.workletRecorder=null,this.biquadFilter=null,this.userMediaStream=null,this.clearWorkletUrlTimeout=null,this.bufferSize=512,this._opt.audioBufferLength=this.calcAudioBufferLength(),this.audioBufferList=[],this.socket=null,this.socketStatus=ut,this.mediaStreamSource=null,this.heartInterval=null,this.checkGetUserMediaTimeout=null,this.wsUrl=null,this.startTimestamp=0,this.sequenceId=0,this.tempTimestamp=null,this.tempG711BufferList=[],this.tempRtpBufferList=[],this.tempPcmBufferList=[],this.events=new uo(this),this._initTalk(),this.player||(this.debug=new Er(this)),this._opt.encType!==Mi&&this._opt.encType!==Ui||8e3===this._opt.sampleRate&&16===this._opt.sampleBitsWidth||this.warn(this.TAG_NAME,`\n encType is ${this._opt.encType} and sampleBitsWidth is ${this._opt.sampleBitsWidth}, set sampleBitsWidth to ${this._opt.sampleBitsWidth}。\n ${this._opt.encType} only support sampleRate 8000 and sampleBitsWidth 16`),this.log(this.TAG_NAME,"init",JSON.stringify(this._opt))}destroy(){this.clearWorkletUrlTimeout&&(clearTimeout(this.clearWorkletUrlTimeout),this.clearWorkletUrlTimeout=null),this.userMediaStream&&(this.userMediaStream.getTracks&&this.userMediaStream.getTracks().forEach((e=>{e.stop()})),this.userMediaStream=null),this.mediaStreamSource&&(this.mediaStreamSource.disconnect(),this.mediaStreamSource=null),this.recorder&&(this.recorder.disconnect(),this.recorder.onaudioprocess=null,this.recorder=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===pt&&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.tempG711BufferList=[],this.tempPcmBufferList=[],this.startTimestamp=0,this.log(this.TAG_NAME,"destroy")}addRtpToBuffer(e){const t=e.length+this.tempRtpBufferList.length,i=new Uint8Array(t);i.set(this.tempRtpBufferList,0),i.set(e,this.tempRtpBufferList.length),this.tempRtpBufferList=i}addG711ToBuffer(e){const t=e.length+this.tempG711BufferList.length,i=new Uint8Array(t);i.set(this.tempG711BufferList,0),i.set(e,this.tempG711BufferList.length),this.tempG711BufferList=i}addPcmToBuffer(e){const t=e.length+this.tempPcmBufferList.length,i=new Uint8Array(t);i.set(this.tempPcmBufferList,0),i.set(e,this.tempPcmBufferList.length),this.tempG711ButempPcmBufferListfferList=i}downloadRtpFile(){this.debug.log(this.TAG_NAME,"downloadRtpFile");const e=new Blob([this.tempRtpBufferList]);try{const t=document.createElement("a");t.href=window.URL.createObjectURL(e),t.download=Date.now()+".rtp",t.click(),window.URL.revokeObjectURL(t.href)}catch(e){console.error("downloadRtpFile",e)}}downloadG711File(){this.debug.log(this.TAG_NAME,"downloadG711File");const e=new Blob([this.tempG711BufferList]);try{const t=document.createElement("a");t.href=window.URL.createObjectURL(e),t.download=Date.now()+"."+this._opt.encType,t.click(),window.URL.revokeObjectURL(t.href)}catch(e){console.error("downloadG711File",e)}}downloadPcmFile(){this.debug.log(this.TAG_NAME,"downloadPcmFile");const e=new Blob([this.tempPcmBufferList]);try{const t=document.createElement("a");t.href=window.URL.createObjectURL(e),t.download=Date.now()+"."+this._opt.encType,t.click(),window.URL.revokeObjectURL(t.href)}catch(e){console.error("downloadRtpFile",e)}}downloadFile(){this._opt.packetType===As?this.downloadRtpFile():this._opt.encType===Mi||this._opt.encType===Ui?this.downloadG711File():this.downloadPcmFile()}calcAudioBufferLength(){const{sampleRate:e,sampleBitsWidth:t}=this._opt;return 8*e*.02/8}get socketStatusOpen(){return this.socketStatus===pt}log(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this._log("log",...t)}warn(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this._log("warn",...t)}error(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this._log("error",...t)}_log(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),s=1;s<t;s++)i[s-1]=arguments[s];this.player?this.player.debug[e](...i):this.debug?this.debug[e](...i):console[e](...i)}_getSequenceId(){return++this.sequenceId}_createWebSocket(){return new Promise(((e,t)=>{const i=this.events.proxy;this.socket=new WebSocket(this.wsUrl),this.socket.binaryType="arraybuffer",this.emit(nt.talkStreamStart),i(this.socket,_s,(()=>{this.socketStatus=pt,this.log(this.TAG_NAME,"websocket open -> do talk"),this.emit(nt.talkStreamOpen),e(),this._doTalk()})),i(this.socket,ws,(e=>{this.log(this.TAG_NAME,"websocket message",e.data)})),i(this.socket,vs,(e=>{this.socketStatus=ft,this.warn(this.TAG_NAME,"websocket close -> reject",e),this.emit(nt.talkStreamClose),t(e)})),i(this.socket,Ss,(e=>{this.socketStatus=mt,this.error(this.TAG_NAME,"websocket error -> reject",e),this.emit(nt.talkStreamError,e),t(e)}))}))}_sendClose(){}_initTalk(){this._initMethods(),this._opt.engine===Es?this._initWorklet():this._opt.engine===Ts&&this._initScriptProcessor(),this.log(this.TAG_NAME,"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 $b({fromSampleRate:this.audioContext.sampleRate,toSampleRate:this._opt.sampleRate,channels:this._opt.numberChannels,inputBufferSize:this.bufferSize})}_initScriptProcessor(){const 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(){const e=Wa((function(){class e extends AudioWorkletProcessor{constructor(e){super(),this._cursor=0,this._bufferSize=e.processorOptions.bufferSize,this._buffer=new Float32Array(this._bufferSize)}process(e,t,i){if(!e.length||!e[0].length)return!0;for(let t=0;t<e[0][0].length;t++)this._cursor+=1,this._cursor===this._bufferSize&&(this._cursor=0,this.port.postMessage({eventType:"data",buffer:this._buffer})),this._buffer[this._cursor]=e[0][0][t];return!0}}registerProcessor("talk-processor",e)}));this.audioContext.audioWorklet&&this.audioContext.audioWorklet.addModule(e).then((()=>{const 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})),this.clearWorkletUrlTimeout=setTimeout((()=>{URL.revokeObjectURL(e),this.clearWorkletUrlTimeout=null}),te)}_onaudioprocess(e){const t=e.inputBuffer.getChannelData(0);this._encodeAudioData(new Float32Array(t))}_encodeAudioData(e){if(0===e[0]&&0===e[1])return void this.log(this.TAG_NAME,"empty audio data");const t=this.resampler.resample(e);let i=t;if(16===this._opt.sampleBitsWidth?i=function(e){let t=e.length,i=new Int16Array(t);for(;t--;){let s=Math.max(-1,Math.min(1,e[t]));i[t]=s<0?32768*s:32767*s}return i}(t):8===this._opt.sampleBitsWidth&&(i=function(e){let t=e.length,i=new Int8Array(t);for(;t--;){let s=Math.max(-1,Math.min(1,e[t]));const r=s<0?32768*s:32767*s;i[t]=parseInt(255/(65535/(32768+r)),10)}return i}(t)),null!==i.buffer){let e=null;this._opt.encType===Mi?e=Yb(i):this._opt.encType===Ui?e=Qb(i):this._opt.encType===Fi&&(e=i);const t=new Uint8Array(e);for(let e=0;e<t.length;e++){let i=this.audioBufferList.length;this.audioBufferList[i++]=t[e],this.audioBufferList.length===this._opt.audioBufferLength&&(this._sendTalkMsg(new Uint8Array(this.audioBufferList)),this.audioBufferList=[])}}}_parseAudioMsg(e){let t=null;return this._opt.packetType!==As||this._opt.encType!==Mi&&this._opt.encType!==Ui?this._opt.packetType===ys&&(t=e):t=this.rtpPacket(e),t}rtpPacket(e){const t=[];let i=0,s=0,r=0;const a=this._opt.rtpSsrc,o=e.length;this._opt.encType===Mi?i=fs:this._opt.encType===Ui?i=ms:this._opt.encType===Oi&&(i=gs),this.startTimestamp||(this.startTimestamp=Qr()),r=Qr()-this.startTimestamp,s=this._getSequenceId();let n=0;if(this._opt.packetTcpSendType===bs){const e=o+12;t[n++]=255&e>>8,t[n++]=255&e}t[n++]=128,t[n++]=128+i,t[n++]=s/256,t[n++]=s%256,t[n++]=r/65536/256,t[n++]=r/65536%256,t[n++]=r%65536/256,t[n++]=r%65536%256,t[n++]=a/65536/256,t[n++]=a/65536%256,t[n++]=a%65536/256,t[n++]=a%65536%256;let l=t.concat([...e]),d=new Uint8Array(l.length);for(let e=0;e<l.length;e++)d[e]=l[e];return d}opusPacket(e){return e}_sendTalkMsg(e){null===this.tempTimestamp&&(this.tempTimestamp=Qr());const t=Qr(),i=t-this.tempTimestamp,s=this._parseAudioMsg(e);this.log(this.TAG_NAME,`send talk msg and diff is ${i} and byteLength is ${s.byteLength} and length is ${s.length}, and ${this._opt.encType} length is ${e.length}`),so(this._opt.saveToTempFile)&&so(this._opt.debug)&&(this._opt.packetType===As?this.addRtpToBuffer(s):this._opt.encType===Mi||this._opt.encType===Ui?this.addG711ToBuffer(s):this.addPcmToBuffer(s)),s&&(this.socketStatusOpen?this.socket.send(s.buffer):this.emit(ct.tallWebsocketClosedByError)),this.tempTimestamp=t}_doTalk(){this._getUserMedia()}_getUserMedia(){this.log(this.TAG_NAME,"getUserMedia"),void 0===window.navigator.mediaDevices&&(window.navigator.mediaDevices={}),void 0===window.navigator.mediaDevices.getUserMedia&&(this.log(this.TAG_NAME,"window.navigator.mediaDevices.getUserMedia is undefined and init function"),window.navigator.mediaDevices.getUserMedia=function(e){var t=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia;return t?new Promise((function(i,s){t.call(navigator,e,i,s)})):Promise.reject(new Error("getUserMedia is not implemented in this browser"))}),this._opt.checkGetUserMediaTimeout&&this._startCheckGetUserMediaTimeout(),window.navigator.mediaDevices.getUserMedia({audio:this._opt.audioConstraints,video:!1}).then((e=>{this.log(this.TAG_NAME,"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(nt.talkGetUserMediaSuccess),null===e.oninactive&&(e.oninactive=e=>{this._handleStreamInactive(e)})})).catch((e=>{this.error(this.TAG_NAME,"getUserMedia error",e.toString()),this.emit(nt.talkGetUserMediaFail,e.toString())})).finally((()=>{this.log(this.TAG_NAME,"getUserMedia finally"),this._stopCheckGetUserMediaTimeout()}))}_getUserMedia2(){this.log(this.TAG_NAME,"getUserMedia"),navigator.mediaDevices?navigator.mediaDevices.getUserMedia({audio:!0}).then((e=>{this.log(this.TAG_NAME,"getUserMedia2 success")})):navigator.getUserMedia({audio:!0},this.log(this.TAG_NAME,"getUserMedia2 success"),this.log(this.TAG_NAME,"getUserMedia2 fail"))}async _getUserMedia3(){this.log(this.TAG_NAME,"getUserMedia3");try{const 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_NAME,"getUserMedia3 success")}catch(e){this.log(this.TAG_NAME,"getUserMedia3 fail")}}_handleStreamInactive(e){this.userMediaStream&&(this.warn(this.TAG_NAME,"stream oninactive",e),this.emit(nt.talkStreamInactive))}_startCheckGetUserMediaTimeout(){this._stopCheckGetUserMediaTimeout(),this.checkGetUserMediaTimeout=setTimeout((()=>{this.log(this.TAG_NAME,"check getUserMedia timeout"),this.emit(nt.talkGetUserMediaTimeout)}),this._opt.getUserMediaTimeout)}_stopCheckGetUserMediaTimeout(){this.checkGetUserMediaTimeout&&(this.log(this.TAG_NAME,"stop checkGetUserMediaTimeout"),clearTimeout(this.checkGetUserMediaTimeout),this.checkGetUserMediaTimeout=null)}_startHeartInterval(){this.heartInterval=setInterval((()=>{this.log(this.TAG_NAME,"heart interval");let 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_NAME,"stop heart interval"),clearInterval(this.heartInterval),this.heartInterval=null)}startTalk(e){return new Promise(((t,i)=>{if(!function(){let e=!1;const t=window.navigator;return t&&(e=!(!t.mediaDevices||!t.mediaDevices.getUserMedia),e||(e=!!(t.getUserMedia||t.webkitGetUserMedia||t.mozGetUserMedia||t.msGetUserMedia))),e}())return i("not support getUserMedia");if(this.wsUrl=e,this._opt.testMicrophone)this._doTalk();else{if(!this.wsUrl)return i("wsUrl is null");this._createWebSocket().catch((e=>{i(e)}))}this.once(nt.talkGetUserMediaFail,(()=>{i("getUserMedia fail")})),this.once(nt.talkGetUserMediaSuccess,(()=>{t()}))}))}setVolume(e){e=parseFloat(e).toFixed(2),isNaN(e)||(e=Xr(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 Zb{constructor(e){this.player=e,this.globalSetting=null;const t=fa();this.defaultSettings={watermark_id:`JbPro_${t}`,watermark_prefix:`JbPro_mask_${t}`,watermark_txt:"JbPro 测试水印",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=null,this.player.debug.log("Watermark","destroy")}remove(){this._removeMark()}load(e){this.globalSetting=e,this._loadMark(e)}resize(){this.player.debug.log("Watermark","resize()"),this.globalSetting&&this._loadMark(this.globalSetting)}_loadMark(){let e=this.defaultSettings;if(1===arguments.length&&"object"==typeof arguments[0]){var t=arguments[0]||{};for(let i in t)t[i]&&e[i]&&t[i]===e[i]||(t[i]||0===t[i])&&(e[i]=t[i])}var i=document.getElementById(e.watermark_id);i&&i.parentNode&&i.parentNode.removeChild(i);var s="string"==typeof e.watermark_parent_node?document.getElementById(e.watermark_parent_node):e.watermark_parent_node,r=s||document.body;const a=r.getBoundingClientRect();var o=Math.max(r.scrollWidth,r.clientWidth,a.width),n=Math.max(r.scrollHeight,r.clientHeight,a.height),l=arguments[0]||{},d=r;(l.watermark_parent_width||l.watermark_parent_height)&&d&&(e.watermark_x=e.watermark_x+0,e.watermark_y=e.watermark_y+0);var h=document.getElementById(e.watermark_id),c=null;if(h)h.shadowRoot&&(c=h.shadowRoot);else{(h=document.createElement("div")).id=e.watermark_id,h.setAttribute("style","pointer-events: none !important; display: block !important"),c="function"==typeof h.attachShadow?h.attachShadow({mode:"open"}):h;var u=r.children,p=Math.floor(Math.random()*(u.length-1))+1;u[p]?r.insertBefore(h,u[p]):r.appendChild(h)}e.watermark_cols=parseInt((o-e.watermark_x)/(e.watermark_width+e.watermark_x_space));var f,m=parseInt((o-e.watermark_x-e.watermark_width*e.watermark_cols)/e.watermark_cols);e.watermark_x_space=m?e.watermark_x_space:m,e.watermark_rows=parseInt((n-e.watermark_y)/(e.watermark_height+e.watermark_y_space));var g,y,A,b=parseInt((n-e.watermark_y-e.watermark_height*e.watermark_rows)/e.watermark_rows);e.watermark_y_space=b?e.watermark_y_space:b,s?(f=e.watermark_x+e.watermark_width*e.watermark_cols+e.watermark_x_space*(e.watermark_cols-1),g=e.watermark_y+e.watermark_height*e.watermark_rows+e.watermark_y_space*(e.watermark_rows-1)):(f=0+e.watermark_x+e.watermark_width*e.watermark_cols+e.watermark_x_space*(e.watermark_cols-1),g=0+e.watermark_y+e.watermark_height*e.watermark_rows+e.watermark_y_space*(e.watermark_rows-1));for(var _=0;_<e.watermark_rows;_++){A=s?0+e.watermark_y+(n-g)/2+(e.watermark_y_space+e.watermark_height)*_:e.watermark_y+(n-g)/2+(e.watermark_y_space+e.watermark_height)*_;for(var v=0;v<e.watermark_cols;v++){y=s?0+e.watermark_x+(o-f)/2+(e.watermark_width+e.watermark_x_space)*v:e.watermark_x+(o-f)/2+(e.watermark_width+e.watermark_x_space)*v;var S=document.createElement("div"),w=document.createTextNode(e.watermark_txt);S.appendChild(w),S.id=e.watermark_prefix+_+v,S.style.webkitTransform="rotate("+e.watermark_angle+"deg)",S.style.MozTransform="rotate("+e.watermark_angle+"deg)",S.style.msTransform="rotate("+e.watermark_angle+"deg)",S.style.OTransform="rotate("+e.watermark_angle+"deg)",S.style.transform="rotate("+e.watermark_angle+"deg)",S.style.visibility="",S.style.position="absolute",S.style.left=y+"px",S.style.top=A+"px",S.style.overflow="hidden",S.style.zIndex="9999999",S.style.opacity=e.watermark_alpha,S.style.fontSize=e.watermark_fontsize,S.style.fontFamily=e.watermark_font,S.style.color=e.watermark_color,S.style.textAlign="center",S.style.width=e.watermark_width+"px",S.style.height=e.watermark_height+"px",S.style.display="block",S.style["-ms-user-select"]="none",c.appendChild(S)}}}_removeMark(){const e=this.defaultSettings;var t=document.getElementById(e.watermark_id);if(t){var i=t.parentNode;i&&i.removeChild(t)}}}class e_{constructor(e){this.player=e,this.globalSetting=null;const t=fa();this.defaultSettings={watermark_id:`JbPro_${t}`,watermark_prefix:`JbPro_mask_${t}`,watermark_txt:"JbPro 测试水印",watermark_x:0,watermark_y:0,watermark_rows:0,watermark_cols:0,watermark_x_space:100,watermark_y_space:100,watermark_font:"微软雅黑",watermark_color:"black",watermark_fontsize:18,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=null,this.player.debug.log("Watermark","destroy")}remove(){this._removeMark()}load(e){this.globalSetting=e,this._loadMark(e)}resize(){this.player.debug.log("Watermark","resize()"),this.globalSetting&&this._loadMark(this.globalSetting)}_loadMark(){let e=this.defaultSettings;if(1===arguments.length&&"object"==typeof arguments[0]){var t=arguments[0]||{};for(let i in t)t[i]&&e[i]&&t[i]===e[i]||(t[i]||0===t[i])&&(e[i]=t[i])}var i=document.getElementById(e.watermark_id);i&&i.parentNode&&i.parentNode.removeChild(i);var s="string"==typeof e.watermark_parent_node?document.getElementById(e.watermark_parent_node):e.watermark_parent_node,r=s||document.body;const a=r.getBoundingClientRect();var o=Math.max(r.scrollWidth,r.clientWidth,a.width),n=Math.max(r.scrollHeight,r.clientHeight,a.height),l=arguments[0]||{},d=r;(l.watermark_parent_width||l.watermark_parent_height)&&d&&(e.watermark_x=e.watermark_x+0,e.watermark_y=e.watermark_y+0);var h=document.getElementById(e.watermark_id),c=null;if(h)h.shadowRoot&&(c=h.shadowRoot);else{(h=document.createElement("div")).id=e.watermark_id,h.setAttribute("style","pointer-events: none !important; display: block !important"),c="function"==typeof h.attachShadow?h.attachShadow({mode:"open"}):h;var u=r.children,p=Math.floor(Math.random()*(u.length-1))+1;u[p]?r.insertBefore(h,u[p]):r.appendChild(h)}const f=this._calcTextSize(),m=this.defaultSettings,g=m.watermark_x_space+f.width,y=m.watermark_y_space+f.height,A=2*y,b=g/2,_=`<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" preserveAspectRatio="none">\n <defs>\n <pattern id="pattern1" x="0" y="0" width="${g}" height="${A}" patternUnits="userSpaceOnUse" patternTransform="rotate(${m.watermark_angle})">\n <text x="0" y="${m.watermark_fontsize}" style="font-family:${m.watermark_font}; font-size:${m.watermark_fontsize}; fill:${m.watermark_color}; fill-opacity:${m.watermark_alpha}">${m.watermark_txt}</text>\n </pattern>\n <pattern id="pattern2" x="${b}" y="${y}" width="${g}" height="${A}" patternUnits="userSpaceOnUse" patternTransform="rotate(${m.watermark_angle})">\n <text x="0" y="${m.watermark_fontsize}" style="font-family:${m.watermark_font}; font-size:${m.watermark_fontsize}; fill:${m.watermark_color}; fill-opacity:${m.watermark_alpha}">${m.watermark_txt}</text>\n </pattern>\n </defs>\n <rect x="0" y="0" width="100%" height="100%" style="fill:url(#pattern1); fill-opacity:1;" />\n <rect x="0" y="0" width="100%" height="100%" style="fill:url(#pattern2); fill-opacity:1;" />\n </svg>`,v=window.btoa(unescape(encodeURIComponent(_)));var S=document.createElement("div");S.style.position="absolute",S.style.left="0px",S.style.top="0px",S.style.overflow="hidden",S.style.zIndex="9999999",S.style.width=o+"px",S.style.height=n+"px",S.style.display="block",S.style["-ms-user-select"]="none",S.style.backgroundImage=`url(data:image/svg+xml;base64,${v})`,c.appendChild(S)}_removeMark(){const e=this.defaultSettings;var t=document.getElementById(e.watermark_id);if(t){var i=t.parentNode;i&&i.removeChild(t)}}_calcTextSize(){const{watermark_txt:e,watermark_font:t,watermark_fontsize:i}=this.globalSetting,s=document.createElement("span");s.innerHTML=e,s.setAttribute("style",`font-family: ${t}; font-size: ${i}px; visibility: hidden; display: inline-block`),document.querySelector("body").appendChild(s);const r={width:s.offsetWidth,height:s.offsetHeight};return s.remove(),r}}const t_="right",i_="left",s_="up",r_="down",a_="leftUp",o_="leftDown",n_="rightUp",l_="rightDown",d_="zoomExpand",h_="zoomNarrow",c_="apertureFar",u_="apertureNear",p_="focusFar",f_="focusNear",m_="setPos",g_="calPos",y_="delPos",A_="wiperOpen",b_="wiperClose",__="cruiseStart",v_={stop:0,fiStop:0,right:1,left:2,up:8,down:4,leftUp:10,leftDown:6,rightUp:9,rightDown:5,zoomExpand:16,zoomNarrow:32,apertureFar:72,apertureNear:68,focusFar:66,focusNear:65,setPos:129,calPos:130,delPos:131,wiperOpen:140,wiperClose:141,setCruise:132,decCruise:133,cruiseStart:136,cruiseStop:0},S_=[25,50,75,100,125,150,175,200,225,250],w_=[1,2,3,4,5,6,7,8,9,16],E_=[16,48,80,112,144,160,176,192,208,224];function T_(e){const{type:t,speed:i=5,index:s=0}=e,r=function(e){e=e||5;const t=e-1,i=S_[t]||S_[4];return i}(i);let a,o,n,l;if(a=v_[t],!a)return"";switch(t){case s_:case r_:case c_:case u_:n=r;break;case t_:case i_:case p_:case f_:o=r;break;case a_:case o_:case n_:case l_:o=r,n=r;break;case d_:case h_:l=function(e){e=e||5;const t=e-1,i=E_[t]||E_[4];return i}(i);break;case g_:case y_:case m_:n=k_(s);break;case b_:case A_:o=1;break;case __:o=k_(s)}return function(e,t,i,s){let r=[];r[0]=165,r[1]=15,r[2]=1,r[3]=0,r[4]=0,r[5]=0,r[6]=0,e&&(r[3]=e);t&&(r[4]=t);i&&(r[5]=i);s&&(r[6]=s);return r[7]=(r[0]+r[1]+r[2]+r[3]+r[4]+r[5]+r[6])%256,function(e){let t="";for(let i=0;i<e.length;i++){let s=e[i].toString(16);1===s.length&&(s="0"+s),t+=s.toUpperCase()}return t}(r)}(a,o,n,l)}function k_(e){return w_[e-1]}const C_=["Boolean","Number","String","Undefined","Null","Date","Object"];function R_(e){if("object"!=typeof e)return e;const t=Object.prototype.toString.call(e).slice(8,-1);switch(t){case"Array":case"Uint8Array":case"ArrayBuffer":return t+"["+e.length+"]";case"Object":return"{}";default:return t}}function x_(e,t,i){i||(i=1),t||(t=2);const s={};if(!e||"object"!=typeof e)return e;const r=Object.prototype.toString.call(e).slice(8,-1);if(!C_.includes(r))return r;if(!(i>t)){for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(i===t?s[r]=R_(e[r]):"object"==typeof e[r]?s[r]=x_(e[r],t,i+1):s[r]=e[r]);return s}}function D_(){return(new Date).toLocaleString()}class L_{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.player=e,this.TAG_NAME="MemoryLogger",this.logMaxSize=t?.logMaxSize||204800,this.logSize=0,this.logTextArray=[],this.player.debug.log(this.TAG_NAME,"init")}destroy(){this.clear(),this.player.debug.log(this.TAG_NAME,"destroy")}clear(){this.logSize=0,this.logTextArray=[]}logCache(){let e="";try{for(var t=arguments.length,i=new Array(t),s=0;s<t;s++)i[s]=arguments[s];const r=i.map((e=>x_(e)));e="[JbPro] "+D_()+JSON.stringify(r)}catch(e){return}if(this.logSize+=e.length,this.logTextArray.push(e),this.logSize>this.logMaxSize){const e=this.logTextArray.shift();this.logSize-=e.length}}getLog(){return this.logTextArray.join("\n")}getLogBlob(){const e=this.getLog();return new Blob([e],{type:"text/plain"})}download(){const e=this.getLog();this.clear();const t=new Blob([e],{type:"text/plain"});Do(t,"JbPro-"+D_()+".log")}}class P_ extends po{constructor(e){super(),this.player=e,this.TAG_NAME="Network",this.online=this.isOnline(),this.prevOnline=this.online,this.interval=null,this._initListener(),this.player.debug.log(this.TAG_NAME,"init")}destroy(){this.off(),this._stopCheck(),window.removeEventListener("online",this._updateOnlineStatus),window.removeEventListener("offline",this._updateOfflineStatus),this.player.debug.log(this.TAG_NAME,"destroy")}_initListener(){window.addEventListener("online",this._updateOnlineStatus.bind(this)),window.addEventListener("offline",this._updateOfflineStatus.bind(this))}_stopCheck(){this.interval&&(clearInterval(this.interval),this.interval=null)}_startCheck(){this.interval=setInterval((()=>{this.isOnline()!==this.prevOnline&&(this.isOnline()?this._updateOnlineStatus():this._updateOfflineStatus())}),1e3)}_updateOnlineStatus(){this.prevOnline=this.online,this.online=!0,this.logStatus(),this.emit("online")}_updateOfflineStatus(){this.prevOnline=this.online,this.online=!1,this.logStatus(),this.emit("offline")}logStatus(){const e=this.prevOnline?"online":"offline",t=this.online?"online":"offline";this.player.debug.log(this.TAG_NAME,`prevOnline: ${this.prevOnline}, online: ${this.online}, status: ${e} -> ${t}`)}isOnline(){return void 0===navigator.onLine||navigator.onLine}isOffline(){return!this.isOnline()}}class B_ extends po{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(),this._opt={},this.TAG_NAME="JbPro",this.$container=null,Object.keys(e).forEach((t=>{if(void 0===e[t])throw new Error(`JbPro option "${t}" can not be undefined`)})),this.originalOptions=e;const t=eo();let i=Object.assign({},t,e);i.url="",i.isMulti&&(i.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 Er(this),this.debug.log("JbPro","init");let s=e.container;if("string"==typeof e.container&&(s=document.querySelector(e.container)),!s)throw this.debug.error("JbPro","JbPro need container option and now container is",e.container),new Error("JbPro need container option");if(i.decoder&&ro(-1!==i.decoder.indexOf("decoder-pro.js")||-1!==i.decoder.indexOf("decoder-pro-simd.js")))throw this.debug.error("JbPro",`JbPro decoder ${i.decoder} must be decoder-pro.js or decoder-pro-simd.js`),new Error(`JbPro decoder ${i.decoder} must be decoder-pro.js or decoder-pro-simd.js`);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(i.videoBuffer>=i.heartTimeout)throw this.debug.error("JbPro",`JbPro videoBuffer ${i.videoBuffer}s must be less than heartTimeout ${i.heartTimeout}s`),new Error(`JbPro videoBuffer ${i.videoBuffer}s must be less than heartTimeout ${i.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)throw this.debug.error(this.TAG_NAME,"JbPro container is invalid, must be a DOM Element",s),new Error("JbPro container is invalid, must be a DOM Element",s);var r,a,o;if(i.videoBuffer>10&&console.warn("JbPro",`videoBuffer ${i.videoBuffer}s is too long, will black screen for ${i.videoBuffer}s , it is recommended to set it to less than 10s`),s.classList.add("jb-pro-container"),r=s,a=ee,o=fa(),r&&(r.dataset?r.dataset[a]=o:r.setAttribute("data-"+a,o)),ro(i.isLive)){const e=document.createElement("video");return e.muted=!0,e.setAttribute("controlsList","nodownload"),e.disablePictureInPicture="disablePictureInPicture",e.style.position="absolute",e.style.top=0,e.style.left=0,e.style.height="100%",e.style.width="100%",s.appendChild(e),this.$videoElement=e,this.$container=s,void(this._opt=i)}if(delete i.container,Ta(i.videoBuffer)&&(i.videoBuffer=1e3*Number(i.videoBuffer)),Ta(i.videoBufferDelay)&&(i.videoBufferDelay=1e3*Number(i.videoBufferDelay)),Ta(i.networkDelay)&&(i.networkDelay=1e3*Number(i.networkDelay)),Ta(i.aiFaceDetectInterval)&&(i.aiFaceDetectInterval=1e3*Number(i.aiFaceDetectInterval)),Ta(i.aiObjectDetectInterval)&&(i.aiObjectDetectInterval=1e3*Number(i.aiObjectDetectInterval)),Ta(i.timeout)&&(wa(i.loadingTimeout)&&(i.loadingTimeout=i.timeout),wa(i.heartTimeout)&&(i.heartTimeout=i.timeout)),Ta(i.autoWasm)&&(wa(i.decoderErrorAutoWasm)&&(i.decoderErrorAutoWasm=i.autoWasm),wa(i.hardDecodingNotSupportAutoWasm)&&(i.hardDecodingNotSupportAutoWasm=i.autoWasm)),Ta(i.aiFaceDetectLevel)&&wa(i.aiFaceDetectWidth)){const e=Xs[i.aiFaceDetectLevel];e&&(i.aiFaceDetectWidth=e)}if(Ta(i.aiObjectDetectLevel)&&wa(i.aiObjectDetectWidth)){const e=Zs[i.aiObjectDetectLevel];e&&(i.aiObjectDetectWidth=e)}so(i.isCrypto)&&(i.isM7sCrypto=!0),this._opt=i,this._destroyed=!1,this.$container=s,this._tempPlayBgObj={},this._tempVideoLastIframeInfo={},this._tempPlayerIsMute=!0,this._loadingTimeoutReplayTimes=0,this._heartTimeoutReplayTimes=0,this._streamErrorReplayTimes=0,this._streamEndReplayTimes=0,this._websocket1006ErrorReplayTimes=0,this.events=new uo(this),this._opt.isUseNewFullscreenWatermark?this.watermark=new e_(this):this.watermark=new Zb(this),this.memoryLogger=new L_(this),this.network=new P_(this),this._websocket1006ErrorRetryLog=[],this._mseDecodeErrorRetryLog=[],this._wcsDecodeErrorRetryLog=[],this._isNetworkOfflinePaused=!1,this._isNetworkOfflinePausedAndNextPlayConfig={},this.widthOrHeightChangeReplayDelayTimeout=null,this.streamErrorReplayDelayTimeout=null,this.streamEndReplayDelayTimeout=null,this.$loadingBgImage=null,this.$loadingBg=null,this.debug.log("JbPro","_initPlayer"),this._initPlayer(s,i),this.debug.log("JbPro","_initPlayer success "),this._initWatermark(),this.debug.log("JbPro","_initWatermark success "),this._initNetwork(),this.debug.log("JbPro",`init success and version is ${sa}`),console.log(`JbPro Version is ${sa}`)}destroy(){return new Promise(((e,t)=>{this.debug.log("JbPro","destroy()"),this._destroyed=!0,this.off(),this._removeTimeout(),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&&this.$container.removeChild(this.$videoElement),this.$videoElement=null),this._removeLoadingBackgroundForIOS(),this.player?this.player.destroy().then((()=>{this.player=null,this._destroy(),e()})).catch((()=>{t()})):(this._destroy(),e())}))}_removeTimeout(){this.widthOrHeightChangeReplayDelayTimeout&&(clearTimeout(this.widthOrHeightChangeReplayDelayTimeout),this.widthOrHeightChangeReplayDelayTimeout=null),this.streamErrorReplayDelayTimeout&&(clearTimeout(this.streamErrorReplayDelayTimeout),this.streamErrorReplayDelayTimeout=null),this.streamEndReplayDelayTimeout&&(clearTimeout(this.streamEndReplayDelayTimeout),this.streamEndReplayDelayTimeout=null)}_destroy(){var e,t;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.network&&(this.network.destroy(),this.network=null),this.memoryLogger&&(this.memoryLogger.destroy(),this.memoryLogger=null),this.$container&&(this.$container.classList.remove("jb-pro-container"),this.$container.classList.remove("jb-pro-fullscreen-web"),e=this.$container,t=ee,e&&(e.dataset?delete e.dataset[t]:e.removeAttribute("data-"+t)),this.$container=null),this._tempPlayBgObj=null,this._tempVideoLastIframeInfo=null,this._isNetworkOfflinePaused=!1,this._isNetworkOfflinePausedAndNextPlayConfig={},this._tempPlayerIsMute=!0,this._resetReplayTimes(),this.debug&&this.debug.log("JbPro","destroy end"),this._opt=null,this.debug=null}_resetReplayTimes(){this._loadingTimeoutReplayTimes=0,this._heartTimeoutReplayTimes=0,this._streamErrorReplayTimes=0,this._streamEndReplayTimes=0,this._websocket1006ErrorReplayTimes=0,this._websocket1006ErrorRetryLog=[],this._mseDecodeErrorRetryLog=[],this._wcsDecodeErrorRetryLog=[]}_getOriginalOpt(){const e=eo();return Object.assign({},e,this.originalOptions)}_initPlayer(e,t){this.player=new Hb(e,t),this._bindEvents()}_initTalk(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.talk&&(this.talk.destroy(),this.talk=null),this.player&&(e.debug=this.player._opt.debug),this.talk=new Xb(this.player,e),this.debug.log("JbPro","_initTalk",this.talk.getOption()),this._bindTalkEvents()}_resetPlayer(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Promise(((t,i)=>{this.debug.log(this.TAG_NAME,"_resetPlayer()",JSON.stringify(e));const s=()=>{this._opt.url="",this._opt.playOptions={},this._opt=Object.assign(this._opt,e),this._initPlayer(this.$container,this._opt)};this.player?this.player.destroy().then((()=>{this.player=null,s(),this.debug.log(this.TAG_NAME,"_resetPlayer() end"),t()})).catch((()=>{i()})):(s(),this.debug.log(this.TAG_NAME,"_resetPlayer() end"),t())}))}_bindEvents(){var e=this;Object.keys(lt).forEach((t=>{this.player.on(lt[t],(function(){for(var i=arguments.length,s=new Array(i),r=0;r<i;r++)s[r]=arguments[r];e.emit(t,...s)}))})),this._opt.playFailedAndPausedShowMessage&&this.on(nt.playFailedAndPaused,(e=>{this.player&&this.player.showTipsMessageByCode(e)})),this.player.once(nt.beforeDestroy,(()=>{this.emit(nt.close),this.destroy().then((()=>{})).catch((e=>{}))})),this.player.on(nt.resize,(()=>{this.watermark&&this.watermark.resize()})),this.player.on(nt.fullscreen,(()=>{this.watermark&&this.watermark.resize()})),this.player.on(nt.videoInfo,(()=>{this.player&&(this.player.singleWatermark&&this.player.singleWatermark.resize(),this.player.ghostWatermark&&this.player.ghostWatermark.resize(),this.player.dynamicWatermark&&this.player.dynamicWatermark.resize())})),this.player.on(nt.memoryLog,(function(){e.memoryLogger.logCache(...arguments)})),this.player.on(nt.downloadMemoryLog,(()=>{this.downloadMemoryLog()}))}_bindTalkEvents(){Object.keys(dt).forEach((e=>{this.player.on(dt[e],(t=>{this.emit(e,t)}))}))}_initWatermark(){if(Ua(this._opt.fullscreenWatermarkConfig)){const e=Ca(this.$container,this._opt.fullscreenWatermarkConfig);if(!e.watermark_txt)return void this.debug.warn("JbPro","fullscreenWatermarkConfig text is empty");this.watermark.load(e)}}_initNetwork(){this.network.on(nt.online,(()=>{if(this.emit(nt.networkState,nt.online),this.isDestroyed())this.debug.log(this.TAG_NAME,"network online and JbPro is destroyed");else if(this._isNetworkOfflinePaused&&this._isNetworkOfflinePausedAndNextPlayConfig&&this._isNetworkOfflinePausedAndNextPlayConfig.url){const e=this._isNetworkOfflinePausedAndNextPlayConfig.url,t=this._isNetworkOfflinePausedAndNextPlayConfig.playOptions;this._streamErrorReplayTimes++;const i=this._isNetworkOfflinePausedAndNextPlayConfig.type||"unknown";this._isNetworkOfflinePaused=!1,this._isNetworkOfflinePausedAndNextPlayConfig={},this.debug.log(this.TAG_NAME,`${i} and network online and reset player and play`),this.play(e,t).then((()=>{this.debug.log(this.TAG_NAME,`${i} and network online and play success`)})).catch((e=>{this.emit(nt.playFailedAndPaused,ct.fetchError,{},error),this.debug.error(this.TAG_NAME,`${i} and network online and play error`,e)}))}})),this.network.on(nt.offline,(()=>{this.emit(nt.networkState,nt.offline)}))}_checkHasCreated(e){if(!e)return!1;const t=function(e,t){return e?e.dataset?e.dataset[t]:e.getAttribute("data-"+t):""}(e,ee);return!!t}isDestroyed(){return this._destroyed}getOption(){return this.player?this.player.getOption():{}}setDebug(e){this.debug.log("JbPro",`setDebug() ${e}`),this._opt.debug=!!e,this.player?this.player.updateOption({debug:!!e},!0):this.debug.warn("JbPro","player is not init")}getIsDebug(){let e=!1;return this.player&&(e=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._opt.timeout=e,this._opt.loadingTimeout=e,this._opt.heartTimeout=e,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=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return new Promise(((t,i)=>{this.debug.log("JbPro",`pause() ${e}`),(this._opt.pauseAndNextPlayUseLastFrameShow||this._opt.replayUseLastFrameShow)&&(this._tempPlayBgObj=this._getVideoLastIframeInfo()),this._tempPlayerIsMute=this.isMute(),this._pause(e).then((e=>{t(e)})).catch((e=>{i(e)}))}))}_pause(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return new Promise(((t,i)=>{if(this.debug.log("JbPro",`_pause() ${e}`),this.isDestroyed())return i("JbPro is destroyed");this._resetReplayTimes(),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._resetReplayTimes(),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 e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(((i,s)=>{if(this.debug.log("JbPro",`play() ${e}`,JSON.stringify(t)),!e&&!this._opt.url)return this.emit(nt.error,ct.playError),void s("url is null and this._opt.url is null");if(e&&(e=(""+e).trim(),-1===e.indexOf("http:")&&-1===e.indexOf("https:")&&-1===e.indexOf("webrtc:")&&-1===e.indexOf("ws:")&&-1===e.indexOf("wss:")&&-1===e.indexOf("wt:")&&-1===e.indexOf("artc:")))return s(`url ${e} must be "http:" or "https:" or "webrtc:" or "ws:" or "wss:" or "wt:" or "artc:" protocol`);if(ro(this._opt.isLive))return this.$videoElement.controls="controls",this.$videoElement.muted=!1,this.$videoElement.src=e,this.$videoElement.play(),void i(this.$videoElement);if(this._opt.isM7sCrypto){let r=t.cryptoKey||this._opt.playOptions.cryptoKey,a=t.cryptoIV||this._opt.playOptions.cryptoIV;if(this._opt.m7sCryptoKey&&(!r||!a)){const e=this._opt.m7sCryptoKey.split(".");r=Qa(e[0]),a=Qa(e[1])}if(!r||!a){const r=e||this._opt.url;return void this._cryptoPlay(r).then((r=>{let{cryptoIV:a,cryptoKey:o}=r;this._opt.playOptions.cryptoKey=o,this._opt.playOptions.cryptoIV=a,t.cryptoIV=a,t.cryptoKey=o,this._playBefore(e,t).then((()=>{i()})).catch((e=>{s(e)}))})).catch((e=>{s(e)}))}this._opt.playOptions.cryptoKey=r,this._opt.playOptions.cryptoIV=a,t.cryptoIV=a,t.cryptoKey=r}else if(this._opt.isXorCrypto){let e=t.cryptoKey||this._opt.playOptions.cryptoKey,i=t.cryptoIV||this._opt.playOptions.cryptoIV;if(this._opt.xorCryptoKey&&(!e||!i)){const t=this._opt.xorCryptoKey.split(".");e=Qa(t[0]),i=Qa(t[1])}e&&i&&(this._opt.playOptions.cryptoKey=e,this._opt.playOptions.cryptoIV=i,t.cryptoIV=i,t.cryptoKey=e)}this._playBefore(e,t).then((()=>{i()})).catch((e=>{s(e)}))}))}_playBefore(e,t){return new Promise(((i,s)=>{if(this.player)if(e)if(this._opt.url)if(e===this._opt.url)if(this.player.playing)this.debug.log("JbPro","_playBefore","playing and resolve()"),i();else{this.debug.log("JbPro","_playBefore","this._opt.url === url and pause -> play and destroy play");let e=this._getOriginalOpt();(this._opt.pauseAndNextPlayUseLastFrameShow||this._opt.replayUseLastFrameShow)&&this._tempPlayBgObj&&this._tempPlayBgObj.loadingBackground&&(e=Object.assign(e,this._tempPlayBgObj)),ro(this._tempPlayerIsMute)&&(e.isNotMute=!0,this._tempPlayerIsMute=!0);const t=this._opt.url,r=this._opt.playOptions;this._resetPlayer(e).then((()=>{this._play(t,r).then((()=>{i()})).catch((e=>{this.debug.error("JbPro","_playBefore this.player.play error",e),this.emit(nt.crashLog,this.getCrashLog("this.player.play 1",e)),s(e)}))})).catch((e=>{this.debug.error("JbPro","_resetPlayer error",e)}))}else{this.debug.log("JbPro","_playBefore",`\n this._url.url is ${this._opt.url}\n and new url is ${e}\n and destroy and play new url`);const r=this._getOriginalOpt();this._resetPlayer(r).then((()=>{this._play(e,t).then((()=>{i()})).catch((e=>{this.debug.error("JbPro","_playBefore _play error",e),this.emit(nt.crashLog,this.getCrashLog("this.player.play 2",e)),s(e)}))})).catch((e=>{this.debug.error("JbPro","_resetPlayer error",e)}))}else this._play(e,t).then((()=>{i()})).catch((e=>{this.debug.error("JbPro","_playBefore _play error",e),this.emit(nt.crashLog,this.getCrashLog("this.player.play 3",e)),s(e)}));else{let e=this._getOriginalOpt();(this._opt.pauseAndNextPlayUseLastFrameShow||this._opt.replayUseLastFrameShow)&&this._tempPlayBgObj&&this._tempPlayBgObj.loadingBackground&&(e=Object.assign(e,this._tempPlayBgObj)),ro(this._tempPlayerIsMute)&&(e.isNotMute=!0,this._tempPlayerIsMute=!0);const t=this._opt.url,r=this._opt.playOptions;this._resetPlayer(e).then((()=>{this._play(t,r).then((()=>{i()})).catch((e=>{this.debug.error("JbPro","_playBefore _play error",e),this.emit(nt.crashLog,this.getCrashLog("this.player.play 4",e)),s(e)}))})).catch((e=>{this.debug.error("JbPro","_resetPlayer error",e)}))}else e?this._play(e,t).then((()=>{i()})).catch((e=>{this.debug.error("JbPro","_playBefore _play error",e),this.emit(nt.crashLog,this.getCrashLog("this.player.play 5",e)),s(e)})):this._play(this._opt.url,this._opt.playOptions).then((()=>{i()})).catch((e=>{this.debug.error("JbPro","_playBefore _play error",e),this.emit(nt.crashLog,this.getCrashLog("this.player.play 6",e)),s(e)}))}))}_cryptoPlay(e){return new Promise(((t,i)=>{const s=function(e){const t=(e||document.location.toString()).split("//"),i=t[1].indexOf("/");let s=t[1].substring(i);return-1!=s.indexOf("?")&&(s=s.split("?")[0]),s}(e);let r=this._opt.cryptoKeyUrl,a="";const o=Xa(e);if(r){if(a=r,this._opt.isM7sCrypto&&-1===a.indexOf(`${Z}?stream=`)){const e=Xa(r);a=e.origin+Z+`?stream=${s}`}}else r=o.origin+Z,a=r+`?stream=${s}`;var n;this.player.debug.log("JbPro",`_cryptoPlay() cryptoKeyUrl: ${a} and opt.cryptoKeyUrl: ${this._opt.cryptoKeyUrl}`),(n=a,new Promise(((e,t)=>{hl.get(n).then((t=>{e(t)})).catch((e=>{t(e)}))}))).then((e=>{if(e){const s=e.split("."),r=Qa(s[0]),a=Qa(s[1]);a&&r?t({cryptoIV:a,cryptoKey:r}):i("get cryptoIV or cryptoKey error")}else i(`cryptoKeyUrl: getM7SCryptoStreamKey ${a} res is null`)})).catch((e=>{i(e)}))}))}playback(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(((i,s)=>{if(this.debug.log("JbPro",`playback() ${e}, options: ${JSON.stringify(t)}`),ro(this._opt.isLive))return s("this._opt.isLive is false, can not playback");const r=to(),a=Object.assign({},r.playbackConfig,this._opt.playbackConfig,t);a.isUseFpsRender||a.isCacheBeforeDecodeForFpsRender&&(a.isCacheBeforeDecodeForFpsRender=!1,this.debug.warn("JbPro","playbackConfig.isUseFpsRender is false, isCacheBeforeDecodeForFpsRender can not be ture, isCacheBeforeDecodeForFpsRender is set to false")),0===a.rateConfig.length&&a.showRateBtn&&(a.showRateBtn=!1,this.debug.warn("JbPro","playbackConfig.rateConfig.length is 0, showRateBtn can not be ture, showRateBtn is set to false")),a.controlType,Q.simple,this._resetPlayer({videoBuffer:0,playbackConfig:a,playType:v,openWebglAlignment:!0,useMSE:a.useMSE,useWCS:a.useWCS,useSIMD:!0}).then((()=>{this.play(e,t).then((()=>{i()})).catch((e=>{s(e)}))})).catch((e=>{s(e)}))}))}playbackPause(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.debug.log("JbPro",`playbackPause() ${e}`),this._opt.playType===b?Promise.reject("playType is player, can not call playbackPause method"):new Promise(((t,i)=>{if(!this.player)return i("player is null");so(e)?this._pause().then((()=>{t()})).catch((e=>{i(e)})):(this.player.playbackPause=!0,t())}))}playbackResume(){return this.debug.log("JbPro","playbackResume()"),this._opt.playType===b?Promise.reject("playType is player, can not call playbackResume method"):new Promise(((e,t)=>{if(!this.player)return t("player is null");this.player.playbackPause=!1,e()}))}forward(e){return this.debug.log("JbPro",`forward() ${e}`),ro(this._opt.isLive)||this._opt.playType===b?Promise.reject("forward() method only just for playback type"):ya(Number(e))?new Promise(((t,i)=>{this.player?(e=Xr(Number(e),.1,32),this.player.decoderWorker&&this.player.decoderWorker.updateWorkConfig({key:"playbackRate",value:e}),this.player.playback.setRate(e),this.player.video&&this.player.video.setRate(e),this.player.audio&&this.player.audio.setRate(e),(this.player.isPlaybackUseWCS()||this.player.isPlaybackUseMSE())&&(this.player.demux.dropBuffer$2(),this.player.isPlaybackCacheBeforeDecodeForFpsRender()&&this.player.demux.initPlaybackCacheLoop()),t()):i("player is not playing")})):Promise.reject(`forward() params "rate": ${e} 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=Xr(e=parseInt(e,10),1,8),this._opt.playbackForwardMaxRateDecodeIFrame=e,this.player?this.player.updateOption({playbackForwardMaxRateDecodeIFrame:e},!0):this.debug.warn("JbPro","updatePlaybackForwardMaxRateDecodeIFrame() player is null")}setPlaybackStartTime(e){this.debug.log("JbPro",`setPlaybackStartTime() ${e}`);const t=Ia(e);this.player?this.player.isPlayback()?t<10&&0!==e&&this.player.playback.isControlTypeNormal()?this.debug.warn("JbPro",`setPlaybackStartTime() control type is normal and timestamp: ${e} is not valid`):this.player.playback.isControlTypeSimple()&&e>this.player.playback.totalDuration?this.debug.warn("JbPro",`setPlaybackStartTime() control type is simple and timestamp: ${e} is more than ${this.player.playback.totalDuration}`):this.player.playing&&(this.player.playback.isControlTypeNormal()&&10===t&&(e*=1e3),this.player.playback.setStartTime(e),this.playbackClearCacheBuffer()):this.debug.warn("JbPro","setPlaybackStartTime() playType is not playback"):this.debug.warn("JbPro","setPlaybackStartTime() player is null")}setPlaybackShowPrecision(e){this.debug.log("JbPro",`setPlaybackShowPrecision() ${e}`),this.player?this.player.isPlayback()?this.player.playback.isControlTypeNormal()?this.player.playback.setShowPrecision(e):this.debug.warn("JbPro","control type is not normal , not support!"):this.debug.warn("JbPro","playType is not playback"):this.debug.warn("JbPro","player is null")}playbackCurrentTimeScroll(){this.debug.log("JbPro","playbackCurrentTimeScroll()"),this.player?this.player.isPlayback()?this.player.playback.isControlTypeNormal()?this.player.playback.currentTimeScroll():this.debug.warn("JbPro","control type is not normal , not support!"):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.clearBufferDelay()):this.debug.warn("JbPro","playType is not playback"):this.debug.warn("JbPro","player is null")}getPlaybackCurrentRate(){if(this.player){if(this.player.isPlayback())return this.player.getPlaybackRate();this.debug.warn("JbPro","playType is not playback")}else this.debug.warn("JbPro","player is null")}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){if(this.debug.log("JbPro",`setStreamQuality() ${e}`),!this.player)return void this.debug.warn("JbPro","player is null");if(!this.player._opt.operateBtns.quality)return void this.debug.warn("JbPro","player._opt.operateBtns.quality is false");(this.player._opt.qualityConfig||[]).includes(e)?this.player.streamQuality=e:this.debug.warn("JbPro",`quality: ${e} is not in qualityList`)}_play(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(((s,r)=>{if(!this.player)return r("player is null");let u=!1;this._opt.url&&this._opt.url!==t&&(u=!0),this._opt.url=t,this._opt.playOptions=i;const p=t.split("?")[0],f=p.startsWith("http://")||p.startsWith("https://"),m=p.startsWith("webrtc://"),g=p.startsWith("artc://"),y=p.startsWith("wt://"),A=p.startsWith("ws://")||p.startsWith("wss://"),b=f||A,_=f&&p.endsWith(".m3u8"),v=b&&p.endsWith(".flv"),S=b&&(p.endsWith(".fmp4")||p.endsWith(".mp4")),w=b&&p.endsWith(".mpeg4"),E=b&&(p.endsWith(".h264")||p.endsWith(".h265")),M=b&&p.endsWith(".ts");let U=this._opt.isWebrtcForZLM||!1,F=this._opt.isWebrtcForSRS||!1,O=this._opt.isWebrtcForOthers||!1;m&&(-1!==t.indexOf("/index/api/webrtc")?(U=!0,F=!1,O=!1):-1!==t.indexOf("/rtc/v1/play/")&&(F=!0,U=!1,O=!1));let j=null,z=null;if(v&&ro(this._opt.isFlv)&&this._resetDemuxType("isFlv"),S&&ro(this._opt.isFmp4)&&this._resetDemuxType("isFmp4"),w&&ro(this._opt.isMpeg4)&&this._resetDemuxType("isMpeg4"),E&&ro(this._opt.isNakedFlow)&&this._resetDemuxType("isNakedFlow"),M&&ro(this._opt.isTs)&&this._resetDemuxType("isTs"),f?j=_?n:o:y?j=d:m?j=l:g?j=h:A&&(j=a),this._opt.isNakedFlow?z=D:this._opt.isFmp4?z=L:this._opt.isMpeg4?z=P:this._opt.isFlv?z=T:this._opt.isTs?z=I:_?z=C:m?z=R:g?z=B:y?z=x:A&&(z=k),!j||!z)return this._opt.playFailedAndPausedShowMessage&&this.showErrorMessageTips("url is not support"),r(`play url ${t} is invalid, protocol is ${c[j]}, demuxType is ${z}`);this.debug.log("JbPro",`play url ${t} protocol is ${c[j]}, demuxType is ${z}`);const G=()=>{this.player.once(ct.webglAlignmentError,(e=>{if(this.isDestroyed())this.debug.log("JbPro","webglAlignmentError but player is destroyed");else if(this.emit(nt.crashLog,this.getCrashLog(ct.webglAlignmentError,e)),this.player&&this.player._opt.webglAlignmentErrorReplay){this.debug.log("JbPro","webglAlignmentError");const t=this._opt.url,i=this._opt.playOptions;this._resetPlayer({openWebglAlignment:!0}).then((()=>{this.play(t,i).then((()=>{this.debug.log("JbPro","webglAlignmentError and play success")})).catch((t=>{this.emit(nt.playFailedAndPaused,ct.webglAlignmentError,{},e),this.debug.error("JbPro","webglAlignmentError and play error",t)}))})).catch((e=>{this.debug.error("JbPro","webglAlignmentError and _resetPlayer error",e)}))}else{const t=!1===this._opt.playFailedUseLastFrameShow;this.player.setPlayFailedAndPaused(),this._pause(t).then((()=>{this.emit(nt.playFailedAndPaused,ct.webglAlignmentError,{},e),this.debug.log("JbPro","webglAlignmentError and webglAlignmentErrorReplay is false")})).catch((t=>{this.emit(nt.playFailedAndPaused,ct.webglAlignmentError,{},e),this.debug.error("JbPro","webglAlignmentError and pause error",t)}))}})),this.player.once(ct.webglContextLostError,(e=>{if(this.isDestroyed())return void this.debug.log("JbPro","webglContextLostError but player is destroyed");this.emit(nt.crashLog,this.getCrashLog(ct.webglContextLostError,e));const t=this._getVideoLastIframeInfo();if(this.player&&this.player._opt.webglContextLostErrorReplay){this.debug.log("JbPro","webglContextLostError");const i=this._opt.url,s=this._opt.playOptions;let r={};this.player._opt.replayUseLastFrameShow&&(r=Object.assign({},r,t,{loadingIcon:this.player._opt.replayShowLoadingIcon})),ro(this.isMute())&&(r.isNotMute=!0),this._resetPlayer(r).then((()=>{this.play(i,s).then((()=>{this.debug.log("JbPro","webglContextLostError and play success")})).catch((i=>{this.emit(nt.playFailedAndPaused,ct.webglContextLostError,t,e),this.debug.error("JbPro","webglContextLostError and play error",i)}))})).catch((i=>{this.emit(nt.playFailedAndPaused,ct.webglContextLostError,t,e),this.debug.error("JbPro","webglContextLostError and _resetPlayer error",i)}))}else{const i=!1===this._opt.playFailedUseLastFrameShow;this.player.setPlayFailedAndPaused(),this._pause(i).then((()=>{this.emit(nt.playFailedAndPaused,ct.webglContextLostError,t,e),this.debug.log("JbPro","webglContextLostError and webglContextLostErrorReplay is false")})).catch((i=>{this.emit(nt.playFailedAndPaused,ct.webglContextLostError,t,e),this.debug.error("JbPro","webglAlignmentError and pause error",i)}))}})),this.player.once(ct.mediaSourceH265NotSupport,(e=>{if(this.isDestroyed())this.debug.log("JbPro","mediaSourceH265NotSupport but player is destroyed");else if(this.emit(nt.crashLog,this.getCrashLog(ct.mediaSourceH265NotSupport,e)),this.player&&this.player._opt.hardDecodingNotSupportAutoWasm){this.debug.log("JbPro","mediaSourceH265NotSupport auto wasm [mse-> wasm] reset player and play");const t=this._opt.url,i=this._opt.playOptions;this._resetPlayer({useMSE:!1,useWCS:!1}).then((()=>{this.play(t,i).then((()=>{this.debug.log("JbPro","mediaSourceH265NotSupport auto wasm [mse-> wasm] reset player and play success")})).catch((t=>{this.emit(nt.playFailedAndPaused,ct.mediaSourceH265NotSupport,e),this.debug.error("JbPro","mediaSourceH265NotSupport auto wasm [mse-> wasm] reset player and play error",t)}))})).catch((t=>{this.emit(nt.playFailedAndPaused,ct.mediaSourceH265NotSupport,{},e),this.debug.error("JbPro","mediaSourceH265NotSupport auto wasm [mse-> wasm] _resetPlayer error",t)}))}else{const t=!1===this._opt.playFailedUseLastFrameShow;this.player.setPlayFailedAndPaused(),this._pause(t).then((()=>{this.emit(nt.playFailedAndPaused,ct.mediaSourceH265NotSupport,{},e),this.debug.log("JbPro","mediaSourceH265NotSupport and autoWasm is false")})).catch((t=>{this.emit(nt.playFailedAndPaused,ct.mediaSourceH265NotSupport,{},e),this.debug.error("JbPro","mediaSourceH265NotSupport and pause error",t)}))}})),this.player.once(ct.mediaSourceFull,(e=>{if(this.isDestroyed())return void this.debug.log("JbPro","mediaSourceFull but player is destroyed");this.emit(nt.crashLog,this.getCrashLog(ct.mediaSourceFull,e));const t=this._getVideoLastIframeInfo();if(this.player&&this.player._opt.mseDecodeErrorReplay){const i=this._opt.url,s=this._opt.playOptions;let r={},a=this.player._opt.decoderErrorAutoWasm,o=!0;a?r={useMSE:!1,useWCS:!1}:this._checkIsMeaningfulRetry(Sr)?this._mseDecodeErrorRetryLog.push(Qr()):(a=!0,o=!1,r={useMSE:!1,useWCS:!1}),this.debug.log("JbPro",`mediaSourceFull and auto wasm ${ro(o)?" and is not meaningful Retry":""} [mse-> ${a?"wasm":"mse"}] reset player and play`),this.player._opt.replayUseLastFrameShow&&(r=Object.assign({},r,t,{loadingIcon:this.player._opt.replayShowLoadingIcon})),ro(this.isMute())&&(r.isNotMute=!0),this._resetPlayer(r).then((()=>{this.play(i,s).then((()=>{this.debug.log("JbPro","mediaSourceFull and reset player and play success")})).catch((i=>{this.emit(nt.playFailedAndPaused,ct.mediaSourceFull,t,e),this.debug.error("JbPro","mediaSourceFull and reset player and play error",i)}))})).catch((i=>{this.emit(nt.playFailedAndPaused,ct.mediaSourceFull,t,e),this.debug.error("JbPro","mediaSourceFull and _resetPlayer error",i)}))}else{const i=!1===this._opt.playFailedUseLastFrameShow;this.player.setPlayFailedAndPaused(),this._pause(i).then((()=>{this.emit(nt.playFailedAndPaused,ct.mediaSourceFull,t,e),this.debug.log("JbPro","mediaSourceFull and autoWasm is false")})).catch((i=>{this.emit(nt.playFailedAndPaused,ct.mediaSourceFull,t,e),this.debug.error("JbPro","mediaSourceFull and pause error",i)}))}})),this.player.once(ct.mediaSourceAppendBufferError,(e=>{if(this.isDestroyed())return void this.debug.log("JbPro","mediaSourceAppendBufferError but player is destroyed");this.emit(nt.crashLog,this.getCrashLog(ct.mediaSourceAppendBufferError,e));const t=this._getVideoLastIframeInfo();if(this.player&&this.player._opt.mseDecodeErrorReplay){const i=this._opt.url,s=this._opt.playOptions;let r={},a=this.player._opt.decoderErrorAutoWasm,o=!0;a?r={useMSE:!1,useWCS:!1}:this._checkIsMeaningfulRetry(Sr)?this._mseDecodeErrorRetryLog.push(Qr()):(a=!0,o=!1,r={useMSE:!1,useWCS:!1}),this.player.isMSEAudioDecoderError&&(this.player.debug.log("JbPro","mediaSourceAppendBufferError and isMSEAudioDecoderError is true so set mseDecodeAudio = false"),r.mseDecodeAudio=!1),this.debug.log("JbPro",`mediaSourceAppendBufferError and auto wasm ${ro(o)?" and is not meaningful Retry":""} [mse-> ${a?"wasm":"mse"}] reset player and play`),this.player._opt.replayUseLastFrameShow&&(r=Object.assign({},r,t,{loadingIcon:this.player._opt.replayShowLoadingIcon})),ro(this.isMute())&&(r.isNotMute=!0),this._resetPlayer(r).then((()=>{this.play(i,s).then((()=>{this.debug.log("JbPro","mediaSourceAppendBufferError and reset player and play success")})).catch((i=>{this.emit(nt.playFailedAndPaused,ct.mediaSourceAppendBufferError,t,e),this.debug.error("JbPro","mediaSourceAppendBufferError and reset player and play error",i)}))})).catch((i=>{this.emit(nt.playFailedAndPaused,ct.mediaSourceAppendBufferError,t,e),this.debug.error("JbPro","mediaSourceAppendBufferError and _resetPlayer error",i)}))}else{const i=!1===this._opt.playFailedUseLastFrameShow;this.player.setPlayFailedAndPaused(),this._pause(i).then((()=>{this.emit(nt.playFailedAndPaused,ct.mediaSourceAppendBufferError,t,e),this.debug.log("JbPro","mediaSourceAppendBufferError and autoWasm is false")})).catch((i=>{this.emit(nt.playFailedAndPaused,ct.mediaSourceAppendBufferError,t,e),this.debug.error("JbPro","mediaSourceAppendBufferError and pause error",i)}))}})),this.player.once(ct.mseSourceBufferError,(e=>{if(this.isDestroyed())return void this.debug.log("JbPro","mseSourceBufferError but player is destroyed");this.emit(nt.crashLog,this.getCrashLog(ct.mseSourceBufferError,e));const t=this._getVideoLastIframeInfo();if(this.player&&this.player._opt.mseDecodeErrorReplay){const i=this._opt.url,s=this._opt.playOptions;let r={};if(this.player._opt.mseDecoderUseWorker)r={mseDecoderUseWorker:!1},this.debug.log("JbPro","mseSourceBufferError auto wasm [mse worker -> mse] reset player and play");else{let e=this.player._opt.decoderErrorAutoWasm,t=!0;e?r={useMSE:!1,useWCS:!1}:this._checkIsMeaningfulRetry(Sr)?this._mseDecodeErrorRetryLog.push(Qr()):(e=!0,t=!1,r={useMSE:!1,useWCS:!1}),this.player.isMSEVideoDecoderInitializationFailedNotSupportHevc&&(this.debug.log("JbPro","mseSourceBufferError and isMSEVideoDecoderInitializationFailedNotSupportHevc is true so auto wasm"),r={useMSE:!1,useWCS:!1}),this.debug.log("JbPro",`mseSourceBufferError auto wasm ${ro(t)?" and is not meaningful Retry":""} [mse-> ${e?"wasm":"mse"}] reset player and play`)}this.player._opt.replayUseLastFrameShow&&(r=Object.assign({},r,t,{loadingIcon:this.player._opt.replayShowLoadingIcon})),ro(this.isMute())&&(r.isNotMute=!0),this._resetPlayer(r).then((()=>{this.play(i,s).then((()=>{this.debug.log("JbPro","mseSourceBufferError reset player and play success")})).catch((i=>{this.emit(nt.playFailedAndPaused,ct.mseSourceBufferError,t,e),this.debug.error("JbPro","mseSourceBufferError reset player and play error",i)}))})).catch((i=>{this.emit(nt.playFailedAndPaused,ct.mseSourceBufferError,t,e),this.debug.error("JbPro","mseSourceBufferError _resetPlayer and play error",i)}))}else{const i=!1===this._opt.playFailedUseLastFrameShow;this.player.setPlayFailedAndPaused(),this._pause(i).then((()=>{this.emit(nt.playFailedAndPaused,ct.mseSourceBufferError,t,e),this.debug.log("JbPro","mseSourceBufferError and autoWasm is false")})).catch((i=>{this.emit(nt.playFailedAndPaused,ct.mseSourceBufferError,t,e),this.debug.error("JbPro","mseSourceBufferError and pause error:",i)}))}})),this.player.once(ct.mediaSourceBufferedIsZeroError,(e=>{if(this.isDestroyed())return void this.debug.log("JbPro","mediaSourceBufferedIsZeroError but player is destroyed");this.emit(nt.crashLog,this.getCrashLog(ct.mediaSourceBufferedIsZeroError,e));const t=this._getVideoLastIframeInfo();if(this.player&&this.player._opt.mseDecodeErrorReplay){const i=this._opt.url,s=this._opt.playOptions;let r={},a=this.player._opt.decoderErrorAutoWasm,o=!0;a?r={useMSE:!1,useWCS:!1}:this._checkIsMeaningfulRetry(Sr)?this._mseDecodeErrorRetryLog.push(Qr()):(a=!0,o=!1,r={useMSE:!1,useWCS:!1}),this.debug.log("JbPro",`mediaSourceBufferedIsZeroError auto wasm ${ro(o)?" and is not meaningful Retry":""} [mse-> ${a?"wasm":"mse"}] reset player and play`),this.player._opt.replayUseLastFrameShow&&(r=Object.assign({},r,t,{loadingIcon:this.player._opt.replayShowLoadingIcon})),ro(this.isMute())&&(r.isNotMute=!0),this._resetPlayer(r).then((()=>{this.play(i,s).then((()=>{this.debug.log("JbPro","mediaSourceBufferedIsZeroError reset player and play success")})).catch((i=>{this.emit(nt.playFailedAndPaused,ct.mediaSourceBufferedIsZeroError,t,e),this.debug.error("JbPro","mediaSourceBufferedIsZeroError reset player and play error",i)}))})).catch((i=>{this.emit(nt.playFailedAndPaused,ct.mediaSourceBufferedIsZeroError,t,e),this.debug.error("JbPro","mediaSourceBufferedIsZeroError _resetPlayer and play error",i)}))}else{const i=!1===this._opt.playFailedUseLastFrameShow;this.player.setPlayFailedAndPaused(),this._pause(i).then((()=>{this.emit(nt.playFailedAndPaused,ct.mediaSourceBufferedIsZeroError,t,e),this.debug.log("JbPro","mediaSourceBufferedIsZeroError and autoWasm is false")})).catch((i=>{this.emit(nt.playFailedAndPaused,ct.mediaSourceBufferedIsZeroError,t,e),this.debug.error("JbPro","mediaSourceBufferedIsZeroError and pause error:",i)}))}})),this.player.once(ct.mseAddSourceBufferError,(e=>{if(this.isDestroyed())return void this.debug.log("JbPro","mseAddSourceBufferError but player is destroyed");this.emit(nt.crashLog,this.getCrashLog(ct.mseAddSourceBufferError,e));const t=this._getVideoLastIframeInfo();if(this.player&&this.player._opt.hardDecodingNotSupportAutoWasm){this.debug.log("JbPro","mseAddSourceBufferError auto wasm [mse-> wasm] reset player and play");const i=this._opt.url,s=this._opt.playOptions;let r={useMSE:!1,useWCS:!1};this.player._opt.replayUseLastFrameShow&&(r=Object.assign({},r,t,{loadingIcon:this.player._opt.replayShowLoadingIcon})),ro(this.isMute())&&(r.isNotMute=!0),this._resetPlayer(r).then((()=>{this.play(i,s).then((()=>{this.debug.log("JbPro","mseAddSourceBufferError auto wasm [mse-> wasm] reset player and play success")})).catch((i=>{this.emit(nt.playFailedAndPaused,ct.mseAddSourceBufferError,t,e),this.debug.error("JbPro","mseAddSourceBufferError auto wasm [mse-> wasm] reset player and play error",i)}))})).catch((i=>{this.emit(nt.playFailedAndPaused,ct.mseAddSourceBufferError,t,e),this.debug.error("JbPro","mseAddSourceBufferError auto wasm [mse-> wasm] _resetPlayer and play error",i)}))}else{const i=!1===this._opt.playFailedUseLastFrameShow;this.player.setPlayFailedAndPaused(),this._pause(i).then((()=>{this.emit(nt.playFailedAndPaused,ct.mseAddSourceBufferError,t,e),this.debug.log("JbPro","mseAddSourceBufferError and autoWasm is false")})).catch((i=>{this.emit(nt.playFailedAndPaused,ct.mseAddSourceBufferError,t,e),this.debug.error("JbPro","mseAddSourceBufferError and pause error",i)}))}})),this.player.once(ct.mediaSourceDecoderConfigurationError,(e=>{if(this.isDestroyed())this.debug.log("JbPro","mediaSourceDecoderConfigurationError but player is destroyed");else if(this.emit(nt.crashLog,this.getCrashLog(ct.mediaSourceDecoderConfigurationError,e)),this.player&&this.player._opt.hardDecodingNotSupportAutoWasm){this.debug.log("JbPro","mediaSourceDecoderConfigurationError auto wasm [mse-> wasm] reset player and play");const t=this._opt.url,i=this._opt.playOptions;let s={useMSE:!1,useWCS:!1};this._resetPlayer(s).then((()=>{this.play(t,i).then((()=>{this.debug.log("JbPro","mediaSourceDecoderConfigurationError auto wasm [mse-> wasm] reset player and play success")})).catch((t=>{this.emit(nt.playFailedAndPaused,ct.mediaSourceDecoderConfigurationError,e),this.debug.error("JbPro","mediaSourceDecoderConfigurationError auto wasm [mse-> wasm] reset player and play error",t)}))})).catch((t=>{this.emit(nt.playFailedAndPaused,ct.mediaSourceDecoderConfigurationError,e),this.debug.error("JbPro","mediaSourceDecoderConfigurationError auto wasm [mse-> wasm] _resetPlayer and play error",t)}))}else{const t=!1===this._opt.playFailedUseLastFrameShow;this.player.setPlayFailedAndPaused(),this._pause(t).then((()=>{this.emit(nt.playFailedAndPaused,ct.mediaSourceDecoderConfigurationError,e),this.debug.log("JbPro","mediaSourceDecoderConfigurationError and autoWasm is false")})).catch((t=>{this.emit(nt.playFailedAndPaused,ct.mediaSourceDecoderConfigurationError,e),this.debug.error("JbPro","mediaSourceDecoderConfigurationError and pause error",t)}))}})),this.player.once(ct.mediaSourceTsIsMaxDiff,(e=>{if(this.isDestroyed())return void this.debug.log("JbPro","mediaSourceTsIsMaxDiff but player is destroyed");this.emit(nt.crashLog,this.getCrashLog(ct.mediaSourceTsIsMaxDiff,e));const t=this._getVideoLastIframeInfo();if(this.player&&this.player._opt.mediaSourceTsIsMaxDiffReplay){this.debug.log("JbPro","mediaSourceTsIsMaxDiff reset player and play");const i=this._opt.url,s=this._opt.playOptions;let r={};this.player._opt.replayUseLastFrameShow&&(r=Object.assign({},r,t,{loadingIcon:this.player._opt.replayShowLoadingIcon})),ro(this.isMute())&&(r.isNotMute=!0),this._resetPlayer(r).then((()=>{this.play(i,s).then((()=>{this.debug.log("JbPro","mediaSourceTsIsMaxDiff replay success")})).catch((i=>{this.emit(nt.playFailedAndPaused,ct.mediaSourceTsIsMaxDiff,t,e),this.debug.error("JbPro","mediaSourceTsIsMaxDiff replay error",i)}))})).catch((i=>{this.emit(nt.playFailedAndPaused,ct.mediaSourceTsIsMaxDiff,t,e),this.debug.error("JbPro","mediaSourceTsIsMaxDiff _resetPlayer error",i)}))}else{const i=!1===this._opt.playFailedUseLastFrameShow;this.player.setPlayFailedAndPaused(),this._pause(i).then((()=>{this.emit(nt.playFailedAndPaused,ct.mediaSourceTsIsMaxDiff,t,e),this.debug.log("JbPro","mediaSourceTsIsMaxDiff and replay is false")})).catch((i=>{this.emit(nt.playFailedAndPaused,ct.mediaSourceTsIsMaxDiff,t,e),this.debug.error("JbPro","mediaSourceTsIsMaxDiff and pause error",i)}))}})),this.player.once(ct.mseWidthOrHeightChange,(t=>{if(this.isDestroyed())return void this.debug.log("JbPro","mseWidthOrHeightChange but player is destroyed");this.emit(nt.crashLog,this.getCrashLog(ct.mseWidthOrHeightChange,t));const i=this._getVideoLastIframeInfo();if(this.player&&this.player._opt.widthOrHeightChangeReplay){this.debug.log("JbPro","mseWidthOrHeightChange and reset player and play");const e=this._opt.url,s=this._opt.playOptions;let r={};this.player._opt.replayUseLastFrameShow&&(r=Object.assign({},r,i,{loadingIcon:this.player._opt.replayShowLoadingIcon})),ro(this.isMute())&&(r.isNotMute=!0),this._resetPlayer(r).then((()=>{this.player._opt.widthOrHeightChangeReplayDelayTime>0?this.widthOrHeightChangeReplayDelayTimeout=setTimeout((()=>{this.isDestroyed()?this.debug.log("JbPro","mseWidthOrHeightChange and widthOrHeightChangeReplayDelayTime but player is destroyed"):this.play(e,s).then((()=>{this.debug.log("JbPro","mseWidthOrHeightChange and reset player and play success")})).catch((e=>{this.emit(nt.playFailedAndPaused,ct.mseWidthOrHeightChange,i,t),this.debug.error("JbPro","mseWidthOrHeightChange and reset player and play error",e)}))}),1e3*this.player._opt.widthOrHeightChangeReplayDelayTime):this.play(e,s).then((()=>{this.debug.log("JbPro","mseWidthOrHeightChange and reset player and play success")})).catch((e=>{this.emit(nt.playFailedAndPaused,ct.mseWidthOrHeightChange,i,t),this.debug.error("JbPro","mseWidthOrHeightChange and reset player and play error",e)}))})).catch((e=>{this.emit(nt.playFailedAndPaused,ct.mseWidthOrHeightChange,i,t),this.debug.error("JbPro","mseWidthOrHeightChange and _resetPlayer error",e)}))}else{const s=!1===this._opt.playFailedUseLastFrameShow;this.player.setPlayFailedAndPaused(),this._pause(s).then((()=>{this.emit(nt.playFailedAndPaused,ct.mseWidthOrHeightChange,i,t),this.debug.error("JbPro","mseWidthOrHeightChange and _resetPlayer error",e)})).catch((e=>{this.emit(nt.playFailedAndPaused,ct.mseWidthOrHeightChange,i,t),this.debug.error("JbPro","mseWidthOrHeightChange error and pause error",e)}))}})),this.player.once(ct.mediaSourceAudioG711NotSupport,(t=>{if(this.isDestroyed())return void this.debug.log("JbPro","mediaSourceAudioG711NotSupport but player is destroyed");const i=this._getVideoLastIframeInfo();if(this.player&&this.player._opt.mediaSourceAudioG711NotSupportReplay){this.debug.log("JbPro","mediaSourceAudioG711NotSupport and reset player and play");const e=this._opt.url,s=this._opt.playOptions;let r={mseDecodeAudio:!1};this.player._opt.replayUseLastFrameShow&&(r=Object.assign({},r,i,{loadingIcon:this.player._opt.replayShowLoadingIcon})),ro(this.isMute())&&(r.isNotMute=!0),this._resetPlayer(r).then((()=>{this.play(e,s).then((()=>{this.debug.log("JbPro","mediaSourceAudioG711NotSupport and reset player and play success")})).catch((e=>{this.emit(nt.playFailedAndPaused,ct.mediaSourceAudioG711NotSupport,i,t),this.debug.error("JbPro","mediaSourceAudioG711NotSupport and reset player and play error",e)}))})).catch((e=>{this.emit(nt.playFailedAndPaused,ct.mediaSourceAudioG711NotSupport,i,t),this.debug.error("JbPro","mediaSourceAudioG711NotSupport and _resetPlayer error",e)}))}else{const s=!1===this._opt.playFailedUseLastFrameShow;this.player.setPlayFailedAndPaused(),this._pause(s).then((()=>{this.emit(nt.playFailedAndPaused,ct.mediaSourceAudioG711NotSupport,i,t),this.debug.error("JbPro","mediaSourceAudioG711NotSupport and _resetPlayer error",e)})).catch((e=>{this.emit(nt.playFailedAndPaused,ct.mediaSourceAudioG711NotSupport,i,t),this.debug.error("JbPro","mediaSourceAudioG711NotSupport error and pause error",e)}))}})),this.player.once(ct.mediaSourceAudioInitTimeout,(t=>{if(this.isDestroyed())return void this.debug.log("JbPro","mediaSourceAudioInitTimeout but player is destroyed");const i=this._getVideoLastIframeInfo();if(this.player&&this.player._opt.mediaSourceAudioInitTimeoutReplay){this.debug.log("JbPro","mediaSourceAudioInitTimeout and reset player and play");const e=this._opt.url,s=this._opt.playOptions;let r={mseDecodeAudio:!1};this.player._opt.replayUseLastFrameShow&&(r=Object.assign({},r,i,{loadingIcon:this.player._opt.replayShowLoadingIcon})),ro(this.isMute())&&(r.isNotMute=!0),this._resetPlayer(r).then((()=>{this.play(e,s).then((()=>{this.debug.log("JbPro","mediaSourceAudioInitTimeout and reset player and play success")})).catch((e=>{this.emit(nt.playFailedAndPaused,ct.mediaSourceAudioInitTimeout,i,t),this.debug.error("JbPro","mediaSourceAudioInitTimeout and reset player and play error",e)}))})).catch((e=>{this.emit(nt.playFailedAndPaused,ct.mediaSourceAudioInitTimeout,i,t),this.debug.error("JbPro","mediaSourceAudioInitTimeout and _resetPlayer error",e)}))}else{const t=!1===this._opt.playFailedUseLastFrameShow;this.player.setPlayFailedAndPaused(),this._pause(t).then((()=>{this.emit(nt.playFailedAndPaused,ct.mediaSourceAudioInitTimeout,i),this.debug.error("JbPro","mediaSourceAudioInitTimeout and _resetPlayer error",e)})).catch((e=>{this.emit(nt.playFailedAndPaused,ct.mediaSourceAudioInitTimeout,i),this.debug.error("JbPro","mediaSourceAudioInitTimeout error and pause error",e)}))}})),this.player.once(ct.mediaSourceAudioNoDataTimeout,(t=>{if(this.isDestroyed())return void this.debug.log("JbPro","mediaSourceAudioNoDataTimeout but player is destroyed");const i=this._getVideoLastIframeInfo();if(this.player&&this.player._opt.mediaSourceAudioInitTimeoutReplay){this.debug.log("JbPro","mediaSourceAudioNoDataTimeout and reset player and play");const e=this._opt.url,s=this._opt.playOptions;let r={mseDecodeAudio:!1};this.player._opt.replayUseLastFrameShow&&(r=Object.assign({},r,i,{loadingIcon:this.player._opt.replayShowLoadingIcon})),ro(this.isMute())&&(r.isNotMute=!0),this._resetPlayer(r).then((()=>{this.play(e,s).then((()=>{this.debug.log("JbPro","mediaSourceAudioNoDataTimeout and reset player and play success")})).catch((e=>{this.emit(nt.playFailedAndPaused,ct.mediaSourceAudioNoDataTimeout,i,t),this.debug.error("JbPro","mediaSourceAudioNoDataTimeout and reset player and play error",e)}))})).catch((e=>{this.emit(nt.playFailedAndPaused,ct.mediaSourceAudioNoDataTimeout,i,t),this.debug.error("JbPro","mediaSourceAudioNoDataTimeout and _resetPlayer error",e)}))}else{const t=!1===this._opt.playFailedUseLastFrameShow;this.player.setPlayFailedAndPaused(),this._pause(t).then((()=>{this.emit(nt.playFailedAndPaused,ct.mediaSourceAudioNoDataTimeout,i),this.debug.error("JbPro","mediaSourceAudioNoDataTimeout and _resetPlayer error",e)})).catch((e=>{this.emit(nt.playFailedAndPaused,ct.mediaSourceAudioNoDataTimeout,i),this.debug.error("JbPro","mediaSourceAudioNoDataTimeout error and pause error",e)}))}})),this.player.once(ct.mediaSourceUseCanvasRenderPlayFailed,(e=>{if(this.isDestroyed())this.debug.log("JbPro","mediaSourceUseCanvasRenderPlayFailed but player is destroyed");else if(this.emit(nt.crashLog,this.getCrashLog(ct.mediaSourceUseCanvasRenderPlayFailed,e)),this.player&&this.player._opt.mediaSourceUseCanvasRenderPlayFailedReplay&&this.player._opt.mediaSourceUseCanvasRenderPlayFailedReplayType){this.debug.log("JbPro",`mediaSourceUseCanvasRenderPlayFailed relayType is ${this.player._opt.mediaSourceUseCanvasRenderPlayFailedReplayType} and reset player and play`);const t=this._opt.url,i=this._opt.playOptions;let s={};const r=this.player._opt.mediaSourceUseCanvasRenderPlayFailedReplayType;r===V?s={useMSE:!1,useWCS:!1}:r===W&&(s={useVideoRender:!0,useCanvasRender:!1}),this._resetPlayer(s).then((()=>{this.play(t,i).then((()=>{this.debug.log("JbPro","mediaSourceUseCanvasRenderPlayFailed and reset player and play success")})).catch((t=>{this.emit(nt.playFailedAndPaused,ct.mediaSourceUseCanvasRenderPlayFailed,e),this.debug.error("JbPro","mediaSourceUseCanvasRenderPlayFailed and reset player and play error",t)}))})).catch((e=>{this.debug.error("JbPro","mediaSourceUseCanvasRenderPlayFailed auto and _resetPlayer and play error",e)}))}else{const t=!1===this._opt.playFailedUseLastFrameShow;this.player.setPlayFailedAndPaused(),this._pause(t).then((()=>{this.debug.log("JbPro","mediaSourceUseCanvasRenderPlayFailed and pause player success")})).catch((t=>{this.emit(nt.playFailedAndPaused,ct.mediaSourceUseCanvasRenderPlayFailed,e),this.debug.error("JbPro","mediaSourceUseCanvasRenderPlayFailed and pause",t)}))}})),this.player.once(ct.webcodecsH265NotSupport,(e=>{if(this.isDestroyed())this.debug.log("JbPro","webcodecsH265NotSupport but player is destroyed");else if(this.emit(nt.crashLog,this.getCrashLog(ct.webcodecsH265NotSupport,e)),this.player&&this.player._opt.hardDecodingNotSupportAutoWasm){this.debug.log("JbPro","webcodecsH265NotSupport auto wasm [wcs-> wasm] reset player and play");const t=this._opt.url,i=this._opt.playOptions;this._resetPlayer({useMSE:!1,useWCS:!1}).then((()=>{this.play(t,i).then((()=>{this.debug.log("JbPro","webcodecsH265NotSupport auto wasm [wcs-> wasm] reset player and play success")})).catch((t=>{this.emit(nt.playFailedAndPaused,ct.webcodecsH265NotSupport,e),this.debug.error("JbPro","webcodecsH265NotSupport auto wasm [wcs-> wasm] reset player and play error",t)}))})).catch((e=>{this.debug.error("JbPro","webcodecsH265NotSupport auto wasm [wcs-> wasm] _resetPlayer and play error",e)}))}else{const t=!1===this._opt.playFailedUseLastFrameShow;this.player.setPlayFailedAndPaused(),this._pause(t).then((()=>{this.emit(nt.playFailedAndPaused,ct.webcodecsH265NotSupport,e),this.debug.log("JbPro","webcodecsH265NotSupport and autoWasm is false")})).catch((t=>{this.emit(nt.playFailedAndPaused,ct.webcodecsH265NotSupport,e),this.debug.error("JbPro","webcodecsH265NotSupport and pause error",t)}))}})),this.player.once(ct.webcodecsUnsupportedConfigurationError,(e=>{if(this.isDestroyed())this.debug.log("JbPro","webcodecsUnsupportedConfigurationError but player is destroyed");else if(this.emit(nt.crashLog,this.getCrashLog(ct.webcodecsUnsupportedConfigurationError,e)),this.player&&this.player._opt.hardDecodingNotSupportAutoWasm){this.debug.log("JbPro","webcodecsUnsupportedConfigurationError auto wasm [wcs-> wasm] reset player and play");const t=this._opt.url,i=this._opt.playOptions;this._resetPlayer({useMSE:!1,useWCS:!1}).then((()=>{this.play(t,i).then((()=>{this.debug.log("JbPro","webcodecsUnsupportedConfigurationError auto wasm [wcs-> wasm] reset player and play success")})).catch((t=>{this.emit(nt.playFailedAndPaused,ct.webcodecsUnsupportedConfigurationError,e),this.debug.error("JbPro","webcodecsUnsupportedConfigurationError auto wasm [wcs-> wasm] reset player and play error",t)}))})).catch((t=>{this.emit(nt.playFailedAndPaused,ct.webcodecsUnsupportedConfigurationError,e),this.debug.error("JbPro","webcodecsUnsupportedConfigurationError auto wasm [wcs-> wasm] _resetPlayer and play error",t)}))}else{const t=!1===this._opt.playFailedUseLastFrameShow;this.player.setPlayFailedAndPaused(),this._pause(t).then((()=>{this.emit(nt.playFailedAndPaused,ct.webcodecsUnsupportedConfigurationError,e),this.debug.log("JbPro","webcodecsUnsupportedConfigurationError and autoWasm is false")})).catch((t=>{this.emit(nt.playFailedAndPaused,ct.webcodecsUnsupportedConfigurationError,e),this.debug.error("JbPro","webcodecsUnsupportedConfigurationError and pause error",t)}))}})),this.player.once(ct.webcodecsDecodeConfigureError,(e=>{if(this.isDestroyed())this.debug.log("JbPro","webcodecsDecodeConfigureError but player is destroyed");else if(this.emit(nt.crashLog,this.getCrashLog(ct.webcodecsDecodeConfigureError,e)),this.player&&this.player._opt.hardDecodingNotSupportAutoWasm){this.debug.log("JbPro","webcodecsDecodeConfigureError auto wasm [wcs-> wasm] reset player and play");const t=this._opt.url,i=this._opt.playOptions;this._resetPlayer({useMSE:!1,useWCS:!1}).then((()=>{this.play(t,i).then((()=>{this.debug.log("JbPro","webcodecsDecodeConfigureError auto wasm [wcs-> wasm] reset player and play success")})).catch((t=>{this.emit(nt.playFailedAndPaused,ct.webcodecsDecodeConfigureError,e),this.debug.error("JbPro","webcodecsDecodeConfigureError auto wasm [wcs-> wasm] reset player and play error",t)}))})).catch((t=>{this.emit(nt.playFailedAndPaused,ct.webcodecsDecodeConfigureError,e),this.debug.error("JbPro","webcodecsDecodeConfigureError auto wasm [wcs-> wasm] _resetPlayer and play error",t)}))}else{const t=!1===this._opt.playFailedUseLastFrameShow;this.player.setPlayFailedAndPaused(),this._pause(t).then((()=>{this.emit(nt.playFailedAndPaused,ct.webcodecsDecodeConfigureError,e),this.debug.log("JbPro","webcodecsDecodeConfigureError and autoWasm is false")})).catch((t=>{this.emit(nt.playFailedAndPaused,ct.webcodecsDecodeConfigureError,e),this.debug.error("JbPro","webcodecsDecodeConfigureError and pause error",t)}))}})),this.player.once(ct.webcodecsDecodeError,(e=>{if(this.isDestroyed())return void this.debug.log("JbPro","webcodecsDecodeError but player is destroyed");this.emit(nt.crashLog,this.getCrashLog(ct.webcodecsDecodeError,e));const t=this._getVideoLastIframeInfo();if(this.player&&this.player._opt.wcsDecodeErrorReplay){const i=this._opt.url,s=this._opt.playOptions;let r={},a=this.player._opt.decoderErrorAutoWasm,o=!0;a?r={useMSE:!1,useWCS:!1}:this._checkIsMeaningfulRetry(wr)?this._wcsDecodeErrorRetryLog.push(Qr()):(a=!0,o=!1,r={useMSE:!1,useWCS:!1}),this.debug.log("JbPro",`webcodecs decode error autoWasm ${ro(o)?" and is not meaningful Retry":""} [wcs-> ${a?"wasm":"wcs"}] reset player and play`),this.player._opt.replayUseLastFrameShow&&(r=Object.assign({},r,t,{loadingIcon:this.player._opt.replayShowLoadingIcon})),ro(this.isMute())&&(r.isNotMute=!0),this._resetPlayer(r).then((()=>{this.play(i,s).then((()=>{this.debug.log("JbPro","webcodecs decode error reset player and play success")})).catch((i=>{this.emit(nt.playFailedAndPaused,ct.webcodecsDecodeError,t,e),this.debug.error("JbPro","webcodecs decode error reset player and play error",i)}))})).catch((()=>{this.emit(nt.playFailedAndPaused,ct.webcodecsDecodeError,t,e),this.debug.error("JbPro","webcodecs decode error _resetPlayer error")}))}else{const i=!1===this._opt.playFailedUseLastFrameShow;this.player.setPlayFailedAndPaused(),this._pause(i).then((()=>{this.emit(nt.playFailedAndPaused,ct.webcodecsDecodeError,t,e),this.debug.log("JbPro","webcodecs decode error and autoWasm is false")})).catch((i=>{this.emit(nt.playFailedAndPaused,ct.webcodecsDecodeError,t,e),this.debug.error("JbPro","webcodecs decode error and pause error",i)}))}})),this.player.once(ct.wcsWidthOrHeightChange,(t=>{if(this.isDestroyed())return void this.debug.log("JbPro","wcsWidthOrHeightChange but player is destroyed");this.emit(nt.crashLog,this.getCrashLog(ct.wcsWidthOrHeightChange,t));const i=this._getVideoLastIframeInfo();if(this.player&&this.player._opt.widthOrHeightChangeReplay){this.debug.log("JbPro","wcsWidthOrHeightChange and reset player and play");const e=this._opt.url,s=this._opt.playOptions;let r={};this.player._opt.replayUseLastFrameShow&&(r=Object.assign({},r,i,{loadingIcon:this.player._opt.replayShowLoadingIcon})),ro(this.isMute())&&(r.isNotMute=!0),this._resetPlayer(r).then((()=>{this._opt.widthOrHeightChangeReplayDelayTime>0?this.widthOrHeightChangeReplayDelayTimeout=setTimeout((()=>{this.isDestroyed()?this.debug.log("JbPro","wcsWidthOrHeightChange and widthOrHeightChangeReplayDelayTime but player is destroyed"):this.play(e,s).then((()=>{this.debug.log("JbPro","wcsWidthOrHeightChange and reset player and play success")})).catch((e=>{this.emit(nt.playFailedAndPaused,ct.wcsWidthOrHeightChange,i,t),this.debug.error("JbPro","wcsWidthOrHeightChange and reset player and play error",e)}))}),1e3*this._opt.widthOrHeightChangeReplayDelayTime):this.play(e,s).then((()=>{this.debug.log("JbPro","wcsWidthOrHeightChange and reset player and play success")})).catch((e=>{this.emit(nt.playFailedAndPaused,ct.wcsWidthOrHeightChange,i,t),this.debug.error("JbPro","wcsWidthOrHeightChange and reset player and play error",e)}))})).catch((e=>{this.emit(nt.playFailedAndPaused,ct.wcsWidthOrHeightChange,i,t),this.debug.error("JbPro","wcsWidthOrHeightChange and _resetPlayer error",e)}))}else{const s=!1===this._opt.playFailedUseLastFrameShow;this.player.setPlayFailedAndPaused(),this._pause(s).then((()=>{this.emit(nt.playFailedAndPaused,ct.wcsWidthOrHeightChange,i,t),this.debug.error("JbPro","wcsWidthOrHeightChange and _resetPlayer error",e)})).catch((e=>{this.emit(nt.playFailedAndPaused,ct.wcsWidthOrHeightChange,i,t),this.debug.error("JbPro","wcsWidthOrHeightChange error and pause error",e)}))}})),this.player.once(ct.wasmDecodeError,(e=>{if(this.isDestroyed())return void this.debug.log("JbPro","wasmDecodeError but player is destroyed");this.emit(nt.crashLog,this.getCrashLog(ct.wasmDecodeError,e));const t=this._getVideoLastIframeInfo();if(this.player&&this.player._opt.wasmDecodeErrorReplay){this.debug.log("JbPro","wasm decode error and reset player and play");const i=this._opt.url,s=this._opt.playOptions;let r={};this.player._opt.replayUseLastFrameShow&&(r=Object.assign({},r,t,{loadingIcon:this.player._opt.replayShowLoadingIcon})),ro(this.isMute())&&(r.isNotMute=!0),this._resetPlayer(r).then((()=>{this.play(i,s).then((()=>{this.debug.log("JbPro","wasm decode error and reset player and play success")})).catch((i=>{this.emit(nt.playFailedAndPaused,ct.wasmDecodeError,t,e),this.debug.error("JbPro","wasm decode error and reset player and play error",i)}))})).catch((()=>{this.emit(nt.playFailedAndPaused,ct.wasmDecodeError,t,e),this.debug.error("JbPro","wasm decode error and _resetPlayer error")}))}else{const i=!1===this._opt.playFailedUseLastFrameShow;this.player.setPlayFailedAndPaused(),this._pause(i).then((()=>{this.emit(nt.playFailedAndPaused,ct.wasmDecodeError,t,e),this.debug.log("JbPro","wasm decode error and wasmDecodeErrorReplay is false")})).catch((i=>{this.emit(nt.playFailedAndPaused,ct.wasmDecodeError,t,e),this.debug.error("JbPro","wasm decode error and pause error",i)}))}})),this.player.once(ct.simdDecodeError,(e=>{if(this.isDestroyed())return void this.debug.log("JbPro","simdDecodeError but player is destroyed");this.emit(nt.crashLog,this.getCrashLog(ct.simdDecodeError,e));const t=this._getVideoLastIframeInfo();if(this.player&&this.player._opt.simdDecodeErrorReplay){this.debug.log("JbPro",`simdDecodeError error simdDecodeErrorReplayType is ${this.player._opt.simdDecodeErrorReplayType} and reset player and play`);const i=this._opt.url,s=this._opt.playOptions;let r={};this.player._opt.simdDecodeErrorReplayType===N&&(r={useSIMD:!1}),this.player._opt.replayUseLastFrameShow&&(r=Object.assign({},r,t,{loadingIcon:this.player._opt.replayShowLoadingIcon})),ro(this.isMute())&&(r.isNotMute=!0),this._resetPlayer(r).then((()=>{this.play(i,s).then((()=>{this.debug.log("JbPro","simdDecodeError and reset player and play success")})).catch((i=>{this.emit(nt.playFailedAndPaused,ct.simdDecodeError,t,e),this.debug.error("JbPro","simdDecodeError and reset player and play error",i)}))})).catch((i=>{this.emit(nt.playFailedAndPaused,ct.simdDecodeError,t,e),this.debug.error("JbPro","simdDecodeError and _resetPlayer error",i)}))}else{const i=!1===this._opt.playFailedUseLastFrameShow;this.player.setPlayFailedAndPaused(),this._pause(i).then((()=>{this.emit(nt.playFailedAndPaused,ct.simdDecodeError,t,e),this.debug.error("JbPro","simdDecodeError and simdDecodeErrorReplay is false")})).catch((i=>{this.emit(nt.playFailedAndPaused,ct.simdDecodeError,t,e),this.debug.error("JbPro","simdDecodeError error and pause error",i)}))}})),this.player.once(ct.wasmWidthOrHeightChange,(t=>{if(this.isDestroyed())return void this.debug.log("JbPro","wasmWidthOrHeightChange but player is destroyed");this.emit(nt.crashLog,this.getCrashLog(ct.wasmWidthOrHeightChange,t));const i=this._getVideoLastIframeInfo();if(this.player&&this.player._opt.widthOrHeightChangeReplay){this.debug.log("JbPro","wasmWidthOrHeightChange and reset player and play");const e=this._opt.url,s=this._opt.playOptions;let r={};this.player._opt.replayUseLastFrameShow&&(r=Object.assign({},r,i,{loadingIcon:this.player._opt.replayShowLoadingIcon})),ro(this.isMute())&&(r.isNotMute=!0),this._resetPlayer(r).then((()=>{this._opt.widthOrHeightChangeReplayDelayTime>0?this.widthOrHeightChangeReplayDelayTimeout=setTimeout((()=>{this.isDestroyed()?this.debug.log("JbPro","wasmWidthOrHeightChange and widthOrHeightChangeReplayDelayTime but player is destroyed"):this.play(e,s).then((()=>{this.debug.log("JbPro","wasmWidthOrHeightChange and reset player and play success")})).catch((e=>{this.emit(nt.playFailedAndPaused,ct.wasmWidthOrHeightChange,i,t),this.debug.error("JbPro","wasmWidthOrHeightChange and reset player and play error",e)}))}),1e3*this._opt.widthOrHeightChangeReplayDelayTime):this.play(e,s).then((()=>{this.debug.log("JbPro","wasmWidthOrHeightChange and reset player and play success")})).catch((e=>{this.emit(nt.playFailedAndPaused,ct.wasmWidthOrHeightChange,i,t),this.debug.error("JbPro","wasmWidthOrHeightChange and reset player and play error",e)}))})).catch((e=>{this.emit(nt.playFailedAndPaused,ct.wasmWidthOrHeightChange,i,t),this.debug.error("JbPro","wasmWidthOrHeightChange and _resetPlayer error",e)}))}else{const s=!1===this._opt.playFailedUseLastFrameShow;this.player.setPlayFailedAndPaused(),this._pause(s).then((()=>{this.emit(nt.playFailedAndPaused,ct.wasmWidthOrHeightChange,i,t),this.debug.error("JbPro","wasmWidthOrHeightChange and _resetPlayer error",e)})).catch((e=>{this.emit(nt.playFailedAndPaused,ct.wasmWidthOrHeightChange,i),this.debug.error("JbPro","wasmWidthOrHeightChange error and pause error",e)}))}})),this.player.once(ct.wasmUseVideoRenderError,(e=>{if(this.isDestroyed())return void this.debug.log("JbPro","wasmUseVideoRenderError but player is destroyed");this.emit(nt.crashLog,this.getCrashLog(ct.wasmUseVideoRenderError,e)),this.debug.log("JbPro","wasmUseVideoRenderError and reset player and play");const t=this._opt.url,i=this._opt.playOptions;this._resetPlayer({useVideoRender:!1,useCanvasRender:!0}).then((()=>{this.play(t,i).then((()=>{this.debug.log("JbPro","wasmUseVideoRenderError and reset player and play success")})).catch((t=>{this.emit(nt.playFailedAndPaused,ct.wasmUseVideoRenderError,{},e),this.debug.error("JbPro","wasmUseVideoRenderError and reset player and play error",t)}))})).catch((t=>{this.emit(nt.playFailedAndPaused,ct.wasmUseVideoRenderError,{},e),this.debug.error("JbPro","wasmUseVideoRenderError and _resetPlayer error",t)}))})),this.player.once(ct.videoElementPlayingFailed,(e=>{if(this.isDestroyed())this.debug.log("JbPro","videoElementPlayingFailed but player is destroyed");else if(this.emit(nt.crashLog,this.getCrashLog(ct.videoElementPlayingFailed,e)),this.player&&this.player._opt.videoElementPlayingFailedReplay){this.debug.log("JbPro",`videoElementPlayingFailed and useMSE is ${this._opt.useMSE} and reset player and play`);const t=this._opt.url,i=this._opt.playOptions;this._resetPlayer({useMSE:!1,useVideoRender:!1,useCanvasRender:!0}).then((()=>{this.play(t,i).then((()=>{this.debug.log("JbPro","videoElementPlayingFailed and reset player and play success")})).catch((t=>{this.emit(nt.playFailedAndPaused,ct.videoElementPlayingFailed,{},e),this.debug.error("JbPro","videoElementPlayingFailed and reset player and play error",t)}))})).catch((t=>{this.emit(nt.playFailedAndPaused,ct.videoElementPlayingFailed,{},e),this.debug.error("JbPro","videoElementPlayingFailed and _resetPlayer error",t)}))}else{const t=!1===this._opt.playFailedUseLastFrameShow;this.player.setPlayFailedAndPaused(),this._pause(t).then((()=>{this.emit(nt.playFailedAndPaused,ct.videoElementPlayingFailed,{},e),this.debug.error("JbPro","videoElementPlayingFailed and videoElementPlayingFailedReplay is false")})).catch((t=>{this.emit(nt.playFailedAndPaused,ct.videoElementPlayingFailed,{},e),this.debug.error("JbPro","videoElementPlayingFailed and _pause error",t)}))}})),this.player.once(ct.simdH264DecodeVideoWidthIsTooLarge,(e=>{if(this.isDestroyed())this.debug.log("JbPro","simdH264DecodeVideoWidthIsTooLarge but player is destroyed");else if(this.emit(nt.crashLog,this.getCrashLog(ct.simdH264DecodeVideoWidthIsTooLarge,e)),this.player&&this.player._opt.simdH264DecodeVideoWidthIsTooLargeReplay){this.debug.log("JbPro","simdH264DecodeVideoWidthIsTooLarge and reset player and play");const t=this._opt.url,i=this._opt.playOptions;this._resetPlayer({useSIMD:!1}).then((()=>{this.play(t,i).then((()=>{this.debug.log("JbPro","simdH264DecodeVideoWidthIsTooLarge and reset player and play success")})).catch((t=>{this.emit(nt.playFailedAndPaused,ct.simdH264DecodeVideoWidthIsTooLarge,{},e),this.debug.error("JbPro","simdH264DecodeVideoWidthIsTooLarge and reset player and play error",t)}))})).catch((t=>{this.emit(nt.playFailedAndPaused,ct.simdH264DecodeVideoWidthIsTooLarge,{},e),this.debug.error("JbPro","simdH264DecodeVideoWidthIsTooLarge and _resetPlayer error",t)}))}else{const t=!1===this._opt.playFailedUseLastFrameShow;this.player.setPlayFailedAndPaused(),this._pause(t).then((()=>{this.emit(nt.playFailedAndPaused,ct.simdH264DecodeVideoWidthIsTooLarge,{},e),this.debug.error("JbPro","simdH264DecodeVideoWidthIsTooLarge and simdDecodeErrorReplay is false")})).catch((t=>{this.emit(nt.playFailedAndPaused,ct.simdH264DecodeVideoWidthIsTooLarge,{},e),this.debug.error("JbPro","simdH264DecodeVideoWidthIsTooLarge and pause error",t)}))}})),this.player.once(nt.networkDelayTimeout,(e=>{if(this.player._opt.networkDelayTimeoutReplay){if(this.isDestroyed())return void this.debug.log("JbPro","networkDelayTimeout but player is destroyed");this.emit(nt.crashLog,this.getCrashLog(nt.networkDelayTimeout,e));const t=this._getVideoLastIframeInfo();this.debug.log("JbPro","network delay time out and reset player and play");const i=this._opt.url,s=this._opt.playOptions;let r={};this.player&&this.player._opt.replayUseLastFrameShow&&(r=Object.assign({},r,t,{loadingIcon:this.player._opt.replayShowLoadingIcon})),ro(this.isMute())&&(r.isNotMute=!0),this._resetPlayer(r).then((()=>{this.play(i,s).then((()=>{this.debug.log("JbPro","wasm decode error and reset player and play success")})).catch((i=>{this.emit(nt.playFailedAndPaused,nt.networkDelayTimeout,t,e),this.debug.error("JbPro","wasm decode error and reset player and play error",i)}))})).catch((()=>{this.emit(nt.playFailedAndPaused,nt.networkDelayTimeout,t,e),this.debug.error("JbPro","wasm decode error and _resetPlayer error")}))}})),this.player.once(nt.flvDemuxBufferSizeTooLarge,(e=>{if(this.isDestroyed())return void this.debug.log("JbPro","flvDemuxBufferSizeTooLarge but player is destroyed");const t=this._getVideoLastIframeInfo();if(this.player._opt.flvDemuxBufferSizeTooLargeReplay){this.emit(nt.crashLog,this.getCrashLog(nt.flvDemuxBufferSizeTooLarge,e)),this.debug.log("JbPro","flv Demux Buffer Size Too Large and flvDemuxBufferSizeTooLargeReplay = true and reset player and play");const i=this._opt.url,s=this._opt.playOptions;let r={};this.player&&this.player._opt.replayUseLastFrameShow&&(r=Object.assign({},r,t,{loadingIcon:this.player._opt.replayShowLoadingIcon})),ro(this.isMute())&&(r.isNotMute=!0),this._resetPlayer(r).then((()=>{this.play(i,s).then((()=>{this.debug.log(this.TAG_NAME,"flv Demux Buffer Size Too Large and reset player and play success")})).catch((i=>{this.emit(nt.playFailedAndPaused,nt.flvDemuxBufferSizeTooLarge,t,e),this.debug.error(this.TAG_NAME,"flv Demux Buffer Size Too Large and reset player and play error",i)}))})).catch((()=>{this.emit(nt.playFailedAndPaused,nt.flvDemuxBufferSizeTooLarge,t,e),this.debug.error(this.TAG_NAME,"flv Demux Buffer Size Too Large and _resetPlayer error")}))}else if(this._opt.flvDemuxBufferSizeTooLargeEmitFailed){this.debug.log(this.TAG_NAME,"flv Demux Buffer Size Too Large and flvDemuxBufferSizeTooLargeEmitFailed = true and pause player");const i=!1===this._opt.playFailedUseLastFrameShow;this.player.setPlayFailedAndPaused(),this._pause(i).then((()=>{this.emit(nt.playFailedAndPaused,ct.flvDemuxBufferSizeTooLarge,t,e)})).catch((i=>{this.emit(nt.playFailedAndPaused,ct.flvDemuxBufferSizeTooLarge,t,e),this.debug.error(this.TAG_NAME,"flv Demux Buffer Size Too Large",i)}))}})),this.player.once(ct.fetchError,(e=>{if(this.isDestroyed())return void this.debug.log("JbPro","fetchError but player is destroyed");this.emit(nt.crashLog,this.getCrashLog(ct.fetchError,e));const t=this._getVideoLastIframeInfo(),i=this._isNeedNetworkDisconnectReplay();if(this.player._opt.streamErrorReplay||i){i?this.debug.log("JbPro","fetch error and network is disconnect and reset player and play"):this.debug.log("JbPro",`fetch error and streamErrorReplay is true and _streamErrorReplayTimes is ${this._streamErrorReplayTimes}, streamErrorReplayDelayTime is ${this._opt.streamErrorReplayDelayTime}, next replay`);let s={};this.player._opt.replayUseLastFrameShow&&(s=Object.assign({},s,t,{loadingIcon:this.player._opt.replayShowLoadingIcon})),ro(this.isMute())&&(s.isNotMute=!0);const r=this._opt.playOptions,a=this._opt.url,o=i?1:this._opt.streamErrorReplayDelayTime;this._resetPlayer(s).then((()=>{this.streamErrorReplayDelayTimeout=setTimeout((()=>{if(this.isDestroyed())this.debug.log("JbPro","fetch error and _resetPlayer but player is destroyed and return");else{if(this.network.isOffline())return this.debug.log("JbPro","fetch error and network is offline and wait network online to play , so return"),this._isNetworkOfflinePaused=!0,void(this._isNetworkOfflinePausedAndNextPlayConfig={url:a,options:r,type:ct.fetchError});this._streamErrorReplayTimes++,this.play(a,r).then((()=>{this.debug.log("JbPro","fetch error and reset player and play success")})).catch((t=>{this.emit(nt.playFailedAndPaused,ct.fetchError,{},e),this.debug.error("JbPro","fetch error and reset player and play error",t)}))}}),1e3*o)})).catch((t=>{this.emit(nt.playFailedAndPaused,ct.fetchError,{},e),this.debug.error("JbPro","fetch error and _resetPlayer error",t)}))}else{this.debug.log("JbPro","fetch error and pause player");const i=!1===this._opt.playFailedUseLastFrameShow;this.player.setPlayFailedAndPaused(),this._pause(i).then((()=>{this.emit(nt.playFailedAndPaused,ct.fetchError,t,e)})).catch((i=>{this.emit(nt.playFailedAndPaused,ct.fetchError,t,e),this.debug.error("JbPro","fetch error and pause",i)}))}})),this.player.once(nt.streamEnd,(e=>{if(this.isDestroyed())return void this.debug.log("JbPro","streamEnd but player is destroyed and return");this.emit(nt.crashLog,this.getCrashLog(nt.streamEnd,e));const t=this._getVideoLastIframeInfo(),i=this._checkIsMeaningfulRetry(vr),s=""+e=="1006"&&this.player._opt.websocket1006ErrorReplay,r=s&&i,a=this.player._opt.streamEndReplay,o=this._isNeedNetworkDisconnectReplay();if(r||a||o){o?this.debug.log("JbPro","streamEnd and network is disconnect and reset player and play"):r?this.debug.log("JbPro",`streamEnd and websocket1006ErrorReplay is true and error is 1006 and _websocket1006ErrorReplayTimes is ${this._websocket1006ErrorReplayTimes} , delay ${this._opt.websocket1006ErrorReplayDelayTime}s reset player and play`):this.debug.log("JbPro",`streamEnd and isStreamEndReplay is true and and _streamEndReplayTimes is ${this._streamEndReplayTimes} , delay ${this._opt.streamEndReplayDelayTime}s reset player and play`);const i=this._opt.playOptions,s=this._opt.url;this._websocket1006ErrorRetryLog.push(Qr());let a={};this.player._opt.replayUseLastFrameShow&&(a=Object.assign({},a,t,{loadingIcon:this.player._opt.replayShowLoadingIcon})),ro(this.isMute())&&(a.isNotMute=!0);let n=r?this._opt.websocket1006ErrorReplayDelayTime:this._opt.streamEndReplayDelayTime;o&&(n=1),this._initLoadingBackgroundForIOS(t),this._resetPlayer(a).then((()=>{this.streamEndReplayDelayTimeout=setTimeout((()=>{if(this._removeLoadingBackgroundForIOS(),this.isDestroyed())o?this.debug.log("JbPro","streamEnd and network is disconnect and _resetPlayer() but player is destroyed and return"):r?this.debug.log("JbPro","streamEnd and 1006 error and _resetPlayer() but player is destroyed and return"):this.debug.log("JbPro","streamEnd and _resetPlayer() but player is destroyed and return");else{if(this.network.isOffline())return r?this.debug.log("JbPro","streamEnd and 1006 error network is offline and wait network online to play , so return"):this.debug.log("JbPro","streamEnd and network is offline and wait network online to play , so return"),this._isNetworkOfflinePaused=!0,void(this._isNetworkOfflinePausedAndNextPlayConfig={url:s,options:i,type:r?ct.websocket1006Error:ct.streamEnd});r?this._websocket1006ErrorReplayTimes++:this._streamEndReplayTimes++,this.play(s,i).then((()=>{r?this.debug.log("JbPro","streamEnd and 1006 error and reset player and play success"):this.debug.log("JbPro","streamEnd and reset player and play success")})).catch((t=>{this.emit(nt.playFailedAndPaused,ct.streamEnd,{},e),r?this.debug.error("JbPro","streamEnd and 1006 error and reset player and play error",t):this.debug.error("JbPro","streamEnd and reset player and play error",t)}))}}),1e3*n)})).catch((t=>{this.emit(nt.playFailedAndPaused,ct.streamEnd,{},e),r?this.debug.error("JbPro","streamEnd and 1006 and _resetPlayer error",t):this.debug.error("JbPro","streamEnd and _resetPlayer error",t)}))}else{s?this.debug.log("JbPro","streamEnd pause player "+(ro(i)?"and is not meaningful retry":"")):this.debug.log("JbPro","streamEnd pause player");const r=!1===this._opt.playFailedUseLastFrameShow;this.player.setPlayFailedAndPaused(),this._pause(r).then((()=>{this.emit(nt.playFailedAndPaused,nt.streamEnd,t,e)})).catch((i=>{this.emit(nt.playFailedAndPaused,nt.streamEnd,t,e),this.debug.error("JbPro","streamEnd pause",i)}))}})),this.player.once(ct.websocketError,(e=>{if(this.isDestroyed())return void this.debug.log("JbPro","websocketError but player is destroyed");this.emit(nt.crashLog,this.getCrashLog(ct.websocketError,e));const t=this._getVideoLastIframeInfo(),i=this._isNeedNetworkDisconnectReplay();if(this.player._opt.streamErrorReplay||i){i?this.debug.log("JbPro","websocketError error and network is disconnect and reset player and play"):this.debug.log("JbPro",`websocketError error and streamErrorReplay is true and _streamErrorReplayTimes is ${this._streamErrorReplayTimes} and streamErrorReplayDelayTime is ${this._opt.streamErrorReplayDelayTime}, next replay`);let s={};this.player._opt.replayUseLastFrameShow&&(s=Object.assign({},s,t,{loadingIcon:this.player._opt.replayShowLoadingIcon})),ro(this.isMute())&&(s.isNotMute=!0);const r=this._opt.playOptions,a=this._opt.url,o=i?1:this._opt.streamErrorReplayDelayTime;this._resetPlayer(s).then((()=>{this.streamErrorReplayDelayTimeout=setTimeout((()=>{if(this.isDestroyed())i?this.debug.log("JbPro","websocketError error and network is disconnect and _resetPlayer() but player is destroyed and return"):this.debug.log("JbPro","websocketError error and _resetPlayer() but player is destroyed and return");else{if(this.network.isOffline())return this.debug.log("JbPro","websocketError error and network is offline and wait network online to play , so return"),this._isNetworkOfflinePaused=!0,void(this._isNetworkOfflinePausedAndNextPlayConfig={url:a,options:r,type:ct.websocketError});this._streamErrorReplayTimes++,this.play(a,r).then((()=>{this.debug.log("JbPro","websocketError error and reset player and play success")})).catch((t=>{this.emit(nt.playFailedAndPaused,ct.fetchError,{},e),this.debug.error("JbPro","websocketError error and reset player and play error",t)}))}}),1e3*o)})).catch((t=>{this.emit(nt.playFailedAndPaused,ct.fetchError,{},e),this.debug.error("JbPro","websocketError error and _resetPlayer error",t)}))}else{this.debug.log("JbPro","websocketError and pause player");const i=!1===this._opt.playFailedUseLastFrameShow;this.player.setPlayFailedAndPaused(),this._pause(i).then((()=>{this.emit(nt.playFailedAndPaused,ct.websocketError,t,e)})).catch((i=>{this.emit(nt.playFailedAndPaused,ct.websocketError,t,e),this.debug.error("JbPro","websocketError and pause",i)}))}})),this.player.once(ct.webrtcError,(e=>{if(this.isDestroyed())return void this.debug.log("JbPro","webrtcError but player is destroyed");this.emit(nt.crashLog,this.getCrashLog(ct.webrtcError,e));const t=this._getVideoLastIframeInfo();this.debug.log("JbPro","webrtcError and pause player");const i=!1===this._opt.playFailedUseLastFrameShow;this.player.setPlayFailedAndPaused(),this._pause(i).then((()=>{this.emit(nt.playFailedAndPaused,ct.webrtcError,t,e)})).catch((i=>{this.emit(nt.playFailedAndPaused,ct.webrtcError,t,e),this.debug.error("JbPro","webrtcError and pause",i)}))})),this.player.once(ct.hlsError,(e=>{if(this.isDestroyed())return void this.debug.log("JbPro","hlsError but player is destroyed");this.emit(nt.crashLog,this.getCrashLog(ct.hlsError,e));const t=this._getVideoLastIframeInfo();this.debug.log("JbPro","hlsError and pause player");const i=!1===this._opt.playFailedUseLastFrameShow;this.player.setPlayFailedAndPaused(),this._pause(i).then((()=>{this.emit(nt.playFailedAndPaused,ct.hlsError,t,e)})).catch((i=>{this.emit(nt.playFailedAndPaused,ct.hlsError,t,e),this.debug.error("JbPro","hlsError and pause",i)}))})),this.player.once(ct.aliyunRtcError,(e=>{if(this.isDestroyed())return void this.debug.log("JbPro","aliyunRtcError but player is destroyed");this.emit(nt.crashLog,this.getCrashLog(ct.aliyunRtcError,e));const t=this._getVideoLastIframeInfo();this.debug.log("JbPro","aliyunRtcError and pause player");const i=!1===this._opt.playFailedUseLastFrameShow;this.player.setPlayFailedAndPaused(),this._pause(i).then((()=>{this.emit(nt.playFailedAndPaused,ct.aliyunRtcError,t,e)})).catch((i=>{this.emit(nt.playFailedAndPaused,ct.aliyunRtcError,t,e),this.debug.error("JbPro","aliyunRtcError and pause",i)}))})),this.player.once(ct.decoderWorkerInitError,(e=>{if(this.isDestroyed())return void this.debug.log("JbPro","decoderWorkerInitError but player is destroyed");this.emit(nt.crashLog,this.getCrashLog(ct.decoderWorkerInitError,e)),this.debug.log("JbPro","decoderWorkerInitError and pause player");const t=!1===this._opt.playFailedUseLastFrameShow;this.player.setPlayFailedAndPaused(),this._pause(t).then((()=>{this.emit(nt.playFailedAndPaused,ct.decoderWorkerInitError,{},e)})).catch((t=>{this.emit(nt.playFailedAndPaused,ct.decoderWorkerInitError,{},e),this.debug.error("JbPro","decoderWorkerInitError and pause",t)}))})),this.player.once(ct.videoElementPlayingFailedForWebrtc,(e=>{if(this.isDestroyed())return void this.debug.log("JbPro","videoElementPlayingFailedForWebrtc but player is destroyed");this.emit(nt.crashLog,this.getCrashLog(ct.videoElementPlayingFailedForWebrtc,e)),this.debug.log("JbPro","videoElementPlayingFailedForWebrtc and pause player");const t=!1===this._opt.playFailedUseLastFrameShow;this.player.setPlayFailedAndPaused(),this._pause(t).then((()=>{this.emit(nt.playFailedAndPaused,ct.videoElementPlayingFailedForWebrtc,{},e)})).catch((t=>{this.emit(nt.playFailedAndPaused,ct.videoElementPlayingFailedForWebrtc,{},e),this.debug.error("JbPro","videoElementPlayingFailedForWebrtc and pause",t)}))})),this.player.once(ct.videoInfoError,(e=>{if(this.isDestroyed())return void this.debug.log("JbPro","videoInfoError but player is destroyed");this.emit(nt.crashLog,this.getCrashLog(ct.videoInfoError,e)),this.debug.log("JbPro","videoInfoError and pause player");const t=!1===this._opt.playFailedUseLastFrameShow;this.player.setPlayFailedAndPaused(),this._pause(t).then((()=>{this.emit(nt.playFailedAndPaused,ct.videoInfoError,{},e)})).catch((t=>{this.emit(nt.playFailedAndPaused,ct.videoInfoError,{},e),this.debug.error("JbPro","videoInfoError and pause",t)}))})),this.player.once(nt.webrtcStreamH265,(e=>{if(this.isDestroyed())return void this.debug.log("JbPro","webrtcStreamH265 but player is destroyed");this.debug.log("JbPro","webrtcStreamH265 and reset player and play");const t=this._opt.url,i=this._opt.playOptions;this._resetPlayer({isWebrtcH265:!0}).then((()=>{this.play(t,i).then((()=>{this.debug.log("JbPro","webrtcStreamH265 and reset player and play success")})).catch((t=>{this.emit(nt.playFailedAndPaused,nt.webrtcStreamH265,{},e),this.debug.error("JbPro","webrtcStreamH265 and reset player and play error",t)}))})).catch((()=>{this.emit(nt.playFailedAndPaused,nt.webrtcStreamH265,{},e),this.debug.error("JbPro","webrtcStreamH265 and _resetPlayer error")}))})),this.player.on(nt.delayTimeout,(e=>{if(this.isDestroyed())return void this.debug.log("JbPro","delay timeout but player is destroyed");this.emit(nt.crashLog,this.getCrashLog(nt.delayTimeout,e));const t=this._getVideoLastIframeInfo();if(this.player&&this.player._opt.heartTimeoutReplay&&(this._heartTimeoutReplayTimes<this.player._opt.heartTimeoutReplayTimes||-1===this.player._opt.heartTimeoutReplayTimes)){if(this.debug.log("JbPro",`delay timeout replay time is ${this._heartTimeoutReplayTimes} and heartTimeoutReplayTimes is ${this.player._opt.heartTimeoutReplayTimes}`),this.isDestroyed())return void(this.debug&&this.debug.warn("JbPro","delay timeout replay but player is destroyed"));this._heartTimeoutReplayTimes+=1;const i=this._opt.url,s=this._opt.playOptions;let r={};(this.player._opt.heartTimeoutReplayUseLastFrameShow||this.player._opt.replayUseLastFrameShow)&&(r=Object.assign({},r,t,{loadingIcon:this.player._opt.replayShowLoadingIcon})),ro(this.isMute())&&(r.isNotMute=!0),this._resetPlayer(r).then((()=>{if(this._isNeedNetworkDisconnectReplay())return this.debug.log("JbPro","delayTimeout and network is offline and wait network online to play , so return"),this._isNetworkOfflinePaused=!0,void(this._isNetworkOfflinePausedAndNextPlayConfig={url:i,options:s,type:nt.delayTimeout});this.play(i,s).then((()=>{})).catch((i=>{this.emit(nt.playFailedAndPaused,nt.delayTimeout,t,e),this.debug.error("JbPro","delay timeout replay error",i)}))})).catch((i=>{this.emit(nt.playFailedAndPaused,nt.delayTimeout,t,e),this.debug.error("JbPro","delay timeout _resetPlayer error",i)}))}else{const i=!1===this._opt.playFailedUseLastFrameShow;this.player.setPlayFailedAndPaused(),this._pause(i).then((()=>{this.emit(nt.playFailedAndPaused,nt.delayTimeout,t,e),this.player&&(this.emit(nt.delayTimeoutRetryEnd),this.emit(nt.playFailedAndPaused,nt.delayTimeoutRetryEnd)),this.debug.warn("JbPro",`delayTimeoutRetryEnd and\n opt.heartTimeout is ${this.player&&this.player._opt.heartTimeout} and\n opt.heartTimeoutReplay is ${this.player&&this.player._opt.heartTimeoutReplay} and\n opt.heartTimeoutReplayTimes is ${this.player&&this.player._opt.heartTimeoutReplayTimes},and\n local._heartTimeoutReplayTimes is ${this._heartTimeoutReplayTimes}`)})).catch((i=>{this.emit(nt.playFailedAndPaused,nt.delayTimeout,t,e),this.debug.error("JbPro","delay timeout and pause error",i)}))}})),this.player.on(nt.loadingTimeout,(e=>{if(this.emit(nt.crashLog,this.getCrashLog(nt.loadingTimeout,e)),this.isDestroyed())this.debug.log("JbPro","loading timeout but player is destroyed");else if(this.player&&this.player._opt.loadingTimeoutReplay&&(this._loadingTimeoutReplayTimes<this.player._opt.loadingTimeoutReplayTimes||-1===this.player._opt.loadingTimeoutReplayTimes)){if(this.debug.log("JbPro",`loading timeout and\n replay time is ${this._loadingTimeoutReplayTimes} and\n loadingTimeoutReplayTimes is ${this.player._opt.loadingTimeoutReplayTimes}`),this.isDestroyed())return void(this.debug&&this.debug.warn("JbPro","delay timeout replay but player is destroyed"));this._loadingTimeoutReplayTimes+=1;const t=this._opt.url,i=this._opt.playOptions;this._resetPlayer().then((()=>{if(this._isNeedNetworkDisconnectReplay())return this.debug.log("JbPro","loadingTimeout and network is offline and wait network online to play , so return"),this._isNetworkOfflinePaused=!0,void(this._isNetworkOfflinePausedAndNextPlayConfig={url:t,options:i,type:nt.loadingTimeout});this.play(t,i).then((()=>{})).catch((t=>{this.emit(nt.playFailedAndPaused,nt.loadingTimeout,{},e),this.debug.error("JbPro","loading timeout replay error",t)}))})).catch((t=>{this.emit(nt.playFailedAndPaused,nt.loadingTimeout,{},e),this.debug.error("JbPro","loading timeout _resetPlayer error",t)}))}else{const t=!1===this._opt.playFailedUseLastFrameShow;this.player.setPlayFailedAndPaused(),this._pause(t).then((()=>{this.emit(nt.playFailedAndPaused,nt.loadingTimeout,{},e),this.player&&(this.emit(nt.loadingTimeoutRetryEnd),this.emit(nt.playFailedAndPaused,nt.loadingTimeoutRetryEnd,{},e)),this.debug.log("JbPro",`loadingTimeoutRetryEnd and\n opt.loadingTimeout is ${this.player&&this.player._opt.loadingTimeout} and\n opt.loadingTimeoutReplay is ${this.player&&this.player._opt.loadingTimeoutReplay} and\n local._loadingTimeoutReplayTimes time is ${this._loadingTimeoutReplayTimes} and\n opt.loadingTimeoutReplayTimes is ${this.player&&this.player._opt.loadingTimeoutReplayTimes}`)})).catch((t=>{this.emit(nt.playFailedAndPaused,nt.loadingTimeout,{},e),this.debug.error("JbPro","loading timeout and pause error",t)}))}})),this._hasLoaded()?this.player.play(t,i).then((()=>{s()})).catch((e=>{this.debug.error("JbPro","_hasLoaded() and play error",e),this.emit(nt.crashLog,this.getCrashLog("_hasLoaded() and play error",e)),this.player&&this.player.pause().then((()=>{r(e)})).catch((e=>{r(e),this.debug.error("JbPro","_hasLoaded() and play error and next pause error",e)}))})):this.player.once(nt.decoderWorkerInit,(()=>{this.player.play(t,i).then((()=>{s()})).catch((e=>{this.debug.error("JbPro","decoderWorkerInit and play error",e),this.emit(nt.crashLog,this.getCrashLog("decoderWorkerInit and play error",e)),this.player&&this.player.pause().then((()=>{r(e)})).catch((e=>{r(e),this.debug.error("JbPro","decoderWorkerInit and play error and next pause error",e)}))}))}))},H=this.player.getOption(),$=_&&ro(this._opt.supportHls265),J=m&&ro(this._opt.isWebrtcH265),q=_&&!!$a(),K=_&&H.demuxUseWorker;if($||J||g||u||w||q||K)this.debug.log("JbPro",`need reset player and\n isOldHls is ${$} and isOldWebrtc is ${J} and\n isAliyunRtc is ${g} and\n needResetPlayer(url change) is ${u} and\n isMpeg4 is ${w} and\n isHlsCanVideoPlay is ${q} and\n isHlsButDemuxUseWorker is ${K}`),this._resetPlayer({protocol:j,demuxType:z,isHls:_,isWebrtc:m,isWebrtcForZLM:U,isWebrtcForSRS:F,isWebrtcForOthers:O,isAliyunRtc:g,cryptoKey:i.cryptoKey||"",cryptoIV:i.cryptoIV||"",url:t,playOptions:i}).then((()=>{G()})).catch((e=>{r("reset player error")}));else{const e={protocol:j,demuxType:z,isHls:_,isWebrtc:m,isAliyunRtc:g,isFlv:this._opt.isFlv,isFmp4:this._opt.isFmp4,isMpeg4:this._opt.isMpeg4,isNakedFlow:this._opt.isNakedFlow,isTs:this._opt.isTs,cryptoKey:i.cryptoKey||"",cryptoIV:i.cryptoIV||""};this._opt.isNakedFlow&&(e.mseDecodeAudio=!1),this.player.updateOption(e),i.cryptoKey&&i.cryptoIV&&this.player.decoderWorker&&(this.player.decoderWorker.updateWorkConfig({key:"cryptoKey",value:i.cryptoKey}),this.player.decoderWorker.updateWorkConfig({key:"cryptoIV",value:i.cryptoIV})),G()}}))}_resetDemuxType(e){this._opt.isFlv=!1,this._opt.isFmp4=!1,this._opt.isMpeg4=!1,this._opt.isNakedFlow=!1,this._opt.isHls=!1,this._opt.isWebrtc=!1,this._opt.isWebrtcForZLM=!1,this._opt.isWebrtcForSRS=!1,this._opt.isWebrtcForOthers=!1,this._opt.isAliyunRtc=!1,this._opt.isTs=!1,e&&(this._opt[e]=!0),"isFmp4"!==e&&(this._opt.isFmp4Private=!1)}resize(){this.debug.log("JbPro","resize()"),this.player&&this.player.resize()}setBufferTime(e){this.debug.log("JbPro",`setBufferTime() ${e}`),(e=Number(e))>10&&this.debug.warn("JbPro",`setBufferTime() buffer time is ${e} second, is too large, video will show blank screen until cache ${e} second buffer data`);const t=1e3*e;this._opt.videoBuffer=t,this.player?this.player.updateOption({videoBuffer:t},!0):this.debug.warn("JbPro","setBufferTime() player is null")}setBufferDelayTime(e){this.debug.log("JbPro",`setBufferDelayTime() ${e}`),(e=Number(e))<.2&&this.debug.warn("JbPro",`setBufferDelayTime() buffer time delay is ${e} second, is too small`);const t=1e3*(e=Xr(e,.2,100));this._opt.videoBufferDelay=t,this.player?this.player.updateOption({videoBufferDelay:t},!0):this.debug.warn("JbPro","setBufferDelayTime() player is null")}setRotate(e){this.debug.log("JbPro",`setRotate() ${e}`),e=parseInt(e,10);this._opt.rotate!==e&&-1!==[0,90,180,270].indexOf(e)?(this._opt.rotate=e,this.player?(this.player.updateOption({rotate:e}),this.resize()):this.debug.warn("JbPro","setRotate() player is null")):this.debug.warn("JbPro",`setRotate() rotate is ${e} and this._opt.rotate is ${this._opt.rotate}`)}setMirrorRotate(e){this.debug.log("JbPro",`setMirrorRotate() ${e}`);e||(e="none"),this._opt.mirrorRotate!==e&&-1!==["none","level","vertical"].indexOf(e)?(this._opt.mirrorRotate=e,this.player?(this.player.updateOption({mirrorRotate:e}),this.resize()):this.debug.warn("JbPro","setMirrorRotate() player is null")):this.debug.warn("JbPro",`setMirrorRotate() mirrorRotate is ${e} and this._opt.mirrorRotate is ${this._opt.mirrorRotate}`)}setAspectRatio(e){this.debug.log("JbPro",`setAspectRatio() ${e}`);e||(e="default"),this._opt.aspectRatio!==e&&-1!==["default","4:3","16:9"].indexOf(e)?(this._opt.aspectRatio=e,this.player?(this.player.updateOption({aspectRatio:e}),this.resize()):this.debug.warn("JbPro","setAspectRatio() player is null")):this.debug.warn("JbPro",`setAspectRatio() aspectRatio is ${e} and this._opt.aspectRatio is ${this._opt.mirrorRotate}`)}hasLoaded(){return!0}_hasLoaded(){return this.player&&this.player.loaded||!1}setKeepScreenOn(){this.debug.log("JbPro","setKeepScreenOn()"),this._opt.keepScreenOn=!0,this.player?this.player.updateOption({keepScreenOn:!0}):this.debug.warn("JbPro","setKeepScreenOn() player is not ready")}setFullscreen(e){this.debug.log("JbPro",`setFullscreen() ${e}`);const t=!!e;this.player?this.player.fullscreen!==t?this.player.fullscreen=t:this.debug.warn("JbPro",`setFullscreen() fullscreen is ${t} and this.player.fullscreen is ${this.player.fullscreen}`):this.debug.warn("JbPro","setFullscreen() player is not ready")}setWebFullscreen(e){this.debug.log("JbPro",`setWebFullscreen() ${e}`);const t=!!e;this.player?this.player.webFullscreen=t:this.debug.warn("JbPro","setWebFullscreen() player is not ready")}screenshot(e,t,i,s){return this.debug.log("JbPro",`screenshot() ${e} ${t} ${i} ${s}`),this.player&&this.player.video?this.player.video.screenshot(e,t,i,s):(this.debug.warn("JbPro","screenshot() player is not ready"),null)}screenshotWatermark(e){return new Promise(((t,i)=>{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(e,t){return new Promise(((i,s)=>{if(this.debug.log("JbPro",`startRecord() ${e} ${t}`),!this.player)return this.debug.warn("JbPro","startRecord() player is not ready"),s("player is not ready");this.player.playing?(this.player.startRecord(e,t),i()):(this.debug.warn("JbPro","startRecord() player is not playing"),s("not playing"))}))}stopRecordAndSave(e,t){return new Promise(((i,s)=>{this.debug.log("JbPro",`stopRecordAndSave() ${e} ${t}`),this.player&&this.player.recording?this.player.stopRecordAndSave(e,t).then((e=>{i(e)})).catch((e=>{s(e)})):s("not recording")}))}isPlaying(){let e=!1;return this.player&&(e=this.player.isPlaying()),e}isLoading(){return!!this.player&&this.player.loading}isPause(){let e=!1;return this._opt.playType===b?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 this._opt.playType===v&&this.player&&(e=this.player.playbackPause),e}isMute(){let e=!0;return this.player&&(e=this.player.isAudioMute()),e}isRecording(){return this.player&&this.player.recorder&&this.player.recorder.recording||!1}isFullscreen(){let e=!1;return this.player&&(e=this.player.fullscreen),e}isWebFullscreen(){let e=!1;return this.player&&(e=this.player.webFullscreen),e}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))<1&&this.debug.warn("JbPro",`setNetworkDelayTime() network delay is ${e} second, is too small`);const t=1e3*(e=Xr(e,1,100));this._opt.networkDelay=t,this.player?this.player.updateOption({networkDelay:t},!0):this.debug.warn("JbPro","setNetworkDelayTime() player is null")}getDecodeType(){let e="";return this.player&&(e=this.player.getDecodeType()),e}getRenderType(){let e="";return this.player&&(e=this.player.getRenderType()),e}getAudioEngineType(){let e="";return this.player&&(e=this.player.getAudioEngineType()),e}getPlayingTimestamp(){let e=0;return this.player&&(e=this.player.getPlayingTimestamp()),e}getStatus(){let e=cs;return this.player&&(e=this.player.loading?ls:this.player.playing?ds:hs),e}getPlayType(){return this.player?this.player._opt.playType:b}togglePerformancePanel(e){this.debug.log("JbPro",`togglePerformancePanel() ${e}`);const t=this.player._opt.showPerformance;let i=!t;Ea(e)&&(i=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 this.player&&(e=this.player.zooming),e}toggleZoom(e){this.debug.log("JbPro",`toggleZoom() ${e}`),Ea(e)||(e=!this.isZoomOpen()),so(e)?this.openZoom():ro(!1)&&this.closeZoom()}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 this.player&&this.player.zoom&&(e=this.player.zoom.currentZoom),e}startTalk(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(((i,s)=>{this.debug.log("JbPro","startTalk()",e,t),this._initTalk(t),this.talk.startTalk(e).then((()=>{i(),this.talk.once(nt.talkStreamClose,(()=>{this.debug.warn("JbPro","talk stream close"),this.stopTalk().catch((e=>{}))})),this.talk.once(nt.talkStreamError,(e=>{this.debug.warn("JbPro","talk stream error",e),this.stopTalk().catch((e=>{}))})),this.talk.once(nt.talkStreamInactive,(()=>{this.debug.warn("JbPro","talk stream inactive"),this.stopTalk().catch((e=>{}))}))})).catch((e=>{s(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(e){return new Promise(((t,i)=>{if(this.debug.log("JbPro","setTalkVolume()",e),!this.talk)return i("setTalkVolume() talk is not init");this.talk.setVolume(e/100),t()}))}setNakedFlowFps(e){return new Promise(((t,i)=>{if(this.debug.log("JbPro","setNakedFlowFps()",e),wa(e))return i("setNakedFlowFps() fps is empty");let s=Number(e);s=Xr(s,1,100),this._opt.nakedFlowFps=s,this.player?this.player.updateOption({nakedFlowFps:s}):this.debug.warn("JbPro","setNakedFlowFps() player is null"),t()}))}getCrashLog(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(!this.player)return;const i=this.player.getAllStatsData(),s=this.player;let r={url:this._opt.url,playType:s.isPlayback()?"playback":"live",demuxType:s.getDemuxType(),decoderType:s.getDecodeType(),renderType:s.getRenderType(),videoInfo:{encType:"",width:"",height:""},audioInfo:{encType:"",sampleRate:"",channels:""},audioEngine:s.getAudioEngineType(),allTimes:i.pTs,timestamp:Qr(),type:e,error:Ka(t)||e};if(s.video){const e=s.video.videoInfo||{};r.videoInfo={encType:e.encType||"",width:e.width||"",height:e.height||""}}if(s.audio){const e=s.audio.audioInfo||{};r.audioInfo={encType:e.encType||"",sampleRate:e.sampleRate||"",channels:e.channels||""}}return r}updateDebugLevel(e){this.debug.log("JbPro","updateDebugLevel()",e),e===J||e===q?e!==this.player._opt.debugLevel?(this._opt.debugLevel=e,this.player?this.player.updateOption({debugLevel:e},!0):this.debug.warn("JbPro","updateDebugLevel() player is null")):this.debug.warn("JbPro",`updateDebugLevel() level is same, level: ${e}`):this.debug.warn("JbPro",`updateDebugLevel() level is not valid, level: ${e}`)}updateWatermark(e){this.debug.log("JbPro","updateWatermark()",e),this.player?this.player.updateWatermark(e):this.debug.warn("JbPro","updateWatermark() player is not init")}removeWatermark(){this.debug.log("JbPro","removeWatermark()"),this.player?this.player.removeWatermark():this.debug.warn("JbPro","removeWatermark() player is not init")}updateFullscreenWatermark(e){if(this.debug.log("JbPro","updateFullscreenWatermark()",e),Ua(e)){this._opt.fullscreenWatermarkConfig=e;const t=Ca(this.$container,e);if(!t.watermark_txt)return void this.debug.warn("JbPro","fullscreenWatermarkConfig text is empty");this.watermark.load(t)}else this.debug.warn("JbPro",`updateFullscreenWatermark() config is not valid, config: ${e}`)}removeFullscreenWatermark(){this.debug.log("JbPro","removeFullscreenWatermark()"),this.watermark?this.watermark.remove():this.debug.warn("JbPro","removeFullscreenWatermark() watermark is not init")}faceDetectOpen(){this.debug.log("JbPro","faceDetectOpen()"),this.player?this.player.faceDetect(!0):this.debug.warn("JbPro","faceDetectOpen() player is not init")}faceDetectClose(){this.debug.log("JbPro","faceDetectClose()"),this.player?this.player.faceDetect(!1):this.debug.warn("JbPro","faceDetectClose() player is not init")}objectDetectOpen(){this.debug.log("JbPro","objectDetectOpen()"),this.player?this.player.objectDetect(!0):this.debug.warn("JbPro","objectDetectOpen() player is not init")}objectDetectClose(){this.debug.log("JbPro","objectDetectClose()"),this.player?this.player.objectDetect(!1):this.debug.warn("JbPro","objectDetectClose() player is not init")}sendWebsocketMessage(e){this.debug.log("JbPro","sendWebsocketMessage()",e),this.player?this.player.sendWebsocketMessage(e):this.debug.warn("JbPro","sendWebsocketMessage() player is not init")}addContentToCanvas(e){this.debug.log("JbPro","addContentToCanvas()"),this.player?this.player.addContentToCanvas(e):this.debug.warn("JbPro","addContentToCanvas() player is not init")}clearContentToCanvas(){this.debug.log("JbPro","clearContentToCanvas()"),this.player?this.player.addContentToCanvas([]):this.debug.warn("JbPro","clearContentToCanvas() player is not init")}addContentToContainer(e){this.debug.log("JbPro","addContentToContainer()"),this.player?this.player.addContentToContainer(e):this.debug.warn("JbPro","addContentToContainer() player is not init")}clearContentToContainer(){this.debug.log("JbPro","clearContentToContainer()"),this.player?this.player.addContentToContainer([]):this.debug.warn("JbPro","clearContentToContainer() player is not init")}setControlHtml(e){this.debug.log("JbPro","setControlHtml()",e),this.player?this.player.setControlHtml(e):this.debug.warn("JbPro","setControlHtml() player is not init")}clearControlHtml(){this.debug.log("JbPro","clearControlHtml()"),this.player?this.player.clearControlHtml():this.debug.warn("JbPro","clearControlHtml() player is not init")}getVideoInfo(){let e=null;return this.player&&(e=this.player.getVideoInfo()),e}getAudioInfo(){let e=null;return this.player&&(e=this.player.getAudioInfo()),e}setSm4CryptoKey(e){this.debug.log("JbPro","setSm4CryptoKey()",e),32===(e=""+e).length?(this._opt.sm4CryptoKey=e,this.player?this.player.updateOption({sm4CryptoKey:e},!0):this.debug.warn("JbPro","setSm4CryptoKey() player is null")):this.debug.warn("JbPro",`setSm4CryptoKey() key is invalid and length is ${e.length} !== 32`)}setM7sCryptoKey(e){this.debug.log("JbPro","setM7sCryptoKey()",e),e=""+e,this._opt.m7sCryptoKey=e,this.player?this.player.updateOption({m7sCryptoKey:e},!0):this.debug.warn("JbPro","setM7sCryptoKey() player is null")}setXorCryptoKey(e){this.debug.log("JbPro","setXorCryptoKey()",e),e=""+e,this._opt.xorCryptoKey=e,this.player?this.player.updateOption({xorCryptoKey:e},!0):this.debug.warn("JbPro","setXorCryptoKey() player is null")}updateLoadingText(e){this.debug.log("JbPro","updateLoadingText()",e),this.player?this.player.updateLoadingText(e):this.debug.warn("JbPro","updateLoadingText() player is null")}updateIsEmitSEI(e){this.debug.log("JbPro","updateIsEmitSEI()",e),this._opt.isEmitSEI=e,this.player?this.player.updateOption({isEmitSEI:e},!0):this.debug.warn("JbPro","updateIsEmitSEI() player is null")}getPTZCmd(e,t){if(this.debug.log("JbPro","getPTZCmd()",e),e)return this.player?T_({type:e,index:0,speed:t}):void this.debug.warn("JbPro","getPTZCmd() player is null");this.debug.warn("JbPro","getPTZCmd() ptz is null")}downloadTempNakedFlowFile(){return new Promise(((e,t)=>{this.player?(this.player.downloadNakedFlowFile(),e()):t("player is not init")}))}downloadTempFmp4File(){return new Promise(((e,t)=>{this.player?(this.player.downloadFmp4File(),e()):t("player is not init")}))}downloadTempMpeg4File(){return new Promise(((e,t)=>{this.player?(this.player.downloadMpeg4File(),e()):t("player is not init")}))}downloadTempRtpFile(){return new Promise(((e,t)=>{this.talk?(this.talk.downloadRtpFile(),e()):t("talk is not init")}))}downloadMemoryLog(){this.memoryLogger&&this.memoryLogger.download()}_getVideoLastIframeInfo(){const e=this.getVideoInfo()||{},t={loadingBackground:this.screenshot("","png",.92,"base64"),loadingBackgroundWidth:e.width||0,loadingBackgroundHeight:e.height||0};return t.loadingBackground&&t.loadingBackgroundWidth&&t.loadingBackgroundHeight&&(this._tempVideoLastIframeInfo=t),this._tempVideoLastIframeInfo||{}}getExtendBtnList(){this.debug.log("JbPro","getExtendBtnList()");let e=[];return this.player?e=this.player.getExtendBtnList():this.debug.warn("JbPro","getExtendBtnList() player is null"),e}getFlvMetaData(){this.debug.log("JbPro","getFlvMetaData()");let e=null;return this.player?e=this.player.getMetaData():this.debug.warn("JbPro","getFlvMetaData() player is null"),e}updateAiFaceDetectInterval(e){this.debug.log("JbPro","updateAiFaceDetectInterval()",e);const t=1e3*(e=Number(e));this._opt.aiFaceDetectInterval=t,this.player?this.player.updateOption({aiFaceDetectInterval:t}):this.debug.warn("JbPro","updateAiFaceDetectInterval() player is null")}updateAiFaceDetectLevel(e){if(this.debug.log("JbPro","updateAiFaceDetectLevel()",e),!Xs[e])return void this.debug.warn("JbPro",`'updateAiFaceDetectLevel() level ${e} is invalid'`);const t=Xs[e];this._opt.aiFaceDetectWidth=t,this.player?(this.player.updateOption({aiFaceDetectWidth:t}),this.player.ai&&this.player.ai.updateFaceDetectorConfig({detectWidth:t})):this.debug.warn("JbPro","updateAiFaceDetectLevel() player is null")}updateAiObjectDetectInterval(e){this.debug.log("JbPro","updateAiObjectDetectInterval()",e);const t=1e3*(e=Number(e));this._opt.aiObjectDetectInterval=t,this.player?this.player.updateOption({aiObjectDetectInterval:t}):this.debug.warn("JbPro","updateAiObjectDetectInterval() player is null")}updateAiObjectDetectLevel(e){if(this.debug.log("JbPro","updateAiObjectDetectLevel()",e),!Zs[e])return void this.debug.warn("JbPro",`'updateAiObjectDetectLevel() level ${e} is invalid'`);const t=Zs[e];this._opt.aiObjectDetectWidth=t,this.player?(this.player.updateOption({aiObjectDetectWidth:t}),this.player.ai&&this.player.ai.updateObjectDetectorConfig({detectWidth:t})):this.debug.warn("JbPro","updateAiObjectDetectLevel() player is null")}setCryptoKeyUrl(e){this.debug.log("JbPro","setCryptoKeyUrl()",e),e&&(this._opt.cryptoKeyUrl=e)}showErrorMessageTips(e){this.debug.log("JbPro","showErrorMessageTips()",e),e&&(this.player?this.player.showTipsMessageByContent(e):this.debug.warn("JbPro","showErrorMessageTips() player is null"))}setPtzPosition(e){this.debug.log("JbPro","setPtzPosition()",e),e&&!Ma(e)&&(this.player?this.player.setPtzPosition(e):this.debug.warn("JbPro","setPtzPosition() player is null"))}hideErrorMessageTips(){this.debug.log("JbPro","hideErrorMessageTips()"),this.player?this.player.hideTipsMessage():this.debug.warn("JbPro","hideErrorMessageTips() player is null")}getContainerRect(){return this._getContainerRect()}proxy(e,t,i,s){return this.events.proxy(e,t,i,s)}_checkIsMeaningfulRetry(e){let t=!0,i=[];if(e===vr?i=this._websocket1006ErrorRetryLog:e===Sr?i=this._mseDecodeErrorRetryLog:e===wr&&(i=this._wcsDecodeErrorRetryLog),this.debug.log(this.TAG_NAME,`_checkIsMeaningfulRetry() type is ${e}, and retryLog is ${i.join(",")}`),i.length>=5){const s=i[0],r=i[i.length-1],a=r-s;a<=1e4&&(this.debug.warn(this.TAG_NAME,`retry type is ${e}, and retry length is ${i.length}, and start is ${s} and end is ${r} and diff is ${a}`),t=!1)}return t}_initLoadingBackgroundForIOS(e){(da()||ha())&&e.loadingBackground&&e.loadingBackgroundWidth&&e.loadingBackgroundHeight&&(this.debug.log(this.TAG_NAME,"_initLoadingBackgroundForIOS"),this._initLoadingBg(),"default"===this.player._opt.aspectRatio||ra()?this._doInitLoadingBackground(e):this._doInitLoadingBackgroundForRatio(e))}_doInitLoadingBackground(e){const t=this._getContainerRect();let i=t.height;const s=this.player._opt;if(s.hasControl&&!s.controlAutoHide){i-=s.playType===v?zt:jt}let r=t.width,a=i;const o=s.rotate;270!==o&&90!==o||(r=i,a=t.width),this.$loadingBgImage.width=r,this.$loadingBgImage.height=a,this.$loadingBgImage.src=e.loadingBackground;let n=(t.width-r)/2,l=(i-a)/2,d="contain";s.isResize||(d="fill"),s.isFullResize&&(d="none");let h="";"none"===s.mirrorRotate&&o&&(h+=" rotate("+o+"deg)"),"level"===s.mirrorRotate?h+=" rotateY(180deg)":"vertical"===s.mirrorRotate&&(h+=" rotateX(180deg)"),this._opt.videoRenderSupportScale&&(this.$loadingBgImage.style.objectFit=d),this.$loadingBgImage.style.transform=h,this.$loadingBgImage.style.padding="0",this.$loadingBgImage.style.left=n+"px",this.$loadingBgImage.style.top=l+"px",this.$loadingBgImage.complete?hh(this.$loadingBg,"show"):this.$loadingBgImage.onload=()=>{hh(this.$loadingBg,"show"),this.$loadingBgImage.onload=null}}_doInitLoadingBackgroundForRatio(e){const t=this.player._opt.aspectRatio.split(":").map(Number),i=this._getContainerRect();let s=i.width,r=i.height;const a=this.player._opt;let o=0;a.hasControl&&!a.controlAutoHide&&(o=a.playType===v?zt:jt,r-=o);const n=e.loadingBackgroundWidth,l=e.loadingBackgroundHeight,d=n/l,h=t[0]/t[1];if(this.$loadingBgImage.src=e.loadingBackground,d>h){const e=h*l/n;this.$loadingBgImage.style.width=100*e+"%",this.$loadingBgImage.style.height=`calc(100% - ${o}px)`,this.$loadingBgImage.style.padding=`0 ${(s-s*e)/2}px`}else{const e=n/h/l;this.$loadingBgImage.style.width="100%",this.$loadingBgImage.style.height=`calc(${100*e}% - ${o}px)`,this.$loadingBgImage.style.padding=(r-r*e)/2+"px 0"}this.$loadingBgImage.complete?hh(this.$loadingBg,"show"):this.$loadingBgImage.onload=()=>{hh(this.$loadingBg,"show"),this.$loadingBgImage.onload=null}}_initLoadingBg(){if(!this.$loadingBg){const e=document.createElement("div"),t=document.createElement("img");e.className="jb-pro-loading-bg-for-ios",this.$loadingBg=e,this.$loadingBgImage=t,e.appendChild(t),this.$container.appendChild(e)}}_removeLoadingBackgroundForIOS(){if(this.$loadingBg){this.debug.log(this.TAG_NAME,"_removeLoadingBackgroundForIOS()");if(!fh(this.$loadingBg)){const e=this.$container.querySelector(".jb-pro-loading-bg-for-ios");e&&this.$container&&this.$container.removeChild(e)}this.$loadingBg=null,this.$loadingBgImage=null}}_getContainerRect(){let e={};return this.$container&&(e=this.$container.getBoundingClientRect(),e.width=Math.max(e.width,this.$container.clientWidth),e.height=Math.max(e.height,this.$container.clientHeight)),e}_isNeedNetworkDisconnectReplay(){return this._opt.networkDisconnectReplay&&this.network.isOffline()}}return B_.ERROR=ct,B_.EVENTS=lt,window.JessibucaPro=B_,window.JbPro=B_,window.WebPlayerPro=B_,B_}));